diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index fd100f73..defe5702 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,6 +1,6 @@ name: Release -run-name: Release next ${{ inputs.bump || 'patch' }} from ${{ github.ref_name }} +run-name: Release ${{ inputs.version || 'next' }} ${{ inputs.version == '' && format('({0} bump)', inputs.bump || 'patch') || '' }} from ${{ github.ref_name }} on: workflow_dispatch: @@ -13,6 +13,14 @@ on: - patch - minor - major + version: + description: Optional explicit x.y.z version; it must be exactly the next patch after the latest published release (use bump=minor/major to change the line) + type: string + required: false + allow_rewind: + description: Permit an explicit version below the latest tag when the tag is free (numbering reset) + type: boolean + default: false concurrency: group: release @@ -68,6 +76,8 @@ jobs: env: GH_TOKEN: ${{ github.token }} BUMP: ${{ inputs.bump || 'patch' }} + EXPLICIT_VERSION: ${{ inputs.version }} + ALLOW_REWIND: ${{ inputs.allow_rewind }} run: | set -euo pipefail if [[ "$GITHUB_REF" != "refs/heads/main" ]]; then @@ -86,9 +96,45 @@ jobs: previous_tag="$({ gh api --paginate "repos/${GITHUB_REPOSITORY}/releases?per_page=100" \ --jq '.[] | select(.draft == false and .prerelease == false) | .tag_name' + # A fork can carry the version history as tags before it has any + # published release of its own; fall back to the highest semantic + # tag reachable from the commit being released. + git tag --merged "$GITHUB_SHA" --list 'v[0-9]*' } | awk '/^v[0-9]+\.[0-9]+\.[0-9]+$/ { print }' | sort -V | tail -n 1)" - if [[ -z "$previous_tag" ]]; then + explicit="${EXPLICIT_VERSION:-}" + if [[ -n "$explicit" && ! "$explicit" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "Explicit version must be x.y.z, got $explicit" >&2 + exit 1 + fi + + if [[ -n "$explicit" ]]; then + IFS=. read -r major minor patch <<< "$explicit" + if [[ "${ALLOW_REWIND:-false}" == "true" ]]; then + # Intentional numbering reset: the operator deliberately reuses a + # version number below the latest tag, so the number must be free. + if git rev-parse -q --verify "refs/tags/v$explicit" >/dev/null; then + echo "Tag v$explicit still exists; delete its release and tag first" >&2 + exit 1 + fi + elif [[ -n "$previous_tag" ]]; then + # Versions iterate by exactly one patch on the 0.7.x line: no + # jumps, no rewinds, no reuse. An explicit number is only the next + # patch of the latest published release; line changes go through + # bump=minor/major. + prev="${previous_tag#v}" + IFS=. read -r prev_major prev_minor prev_patch <<< "$prev" + expected="$prev_major.$prev_minor.$((prev_patch + 1))" + if [[ "$explicit" != "$expected" ]]; then + echo "Explicit version $explicit must be the next patch $expected after $previous_tag" >&2 + exit 1 + fi + fi + if [[ -n "$previous_tag" ]] && ! git merge-base --is-ancestor "$previous_tag" "$GITHUB_SHA"; then + echo "$previous_tag is not an ancestor of $GITHUB_SHA" >&2 + exit 1 + fi + elif [[ -z "$previous_tag" ]]; then major=0 minor=1 patch=0 diff --git a/.github/workflows/republish.yml b/.github/workflows/republish.yml new file mode 100644 index 00000000..c172b147 --- /dev/null +++ b/.github/workflows/republish.yml @@ -0,0 +1,101 @@ +name: Republish + +# Rebuild an already published release without minting a new version: the +# image tags and the seven updater assets are overwritten. Normal releases +# still go through release.yml exactly once. + +on: + workflow_dispatch: + inputs: + tag: + description: Published release tag to rebuild (for example v0.7.46) + required: true + type: string + +permissions: + contents: read + +concurrency: + group: republish-${{ inputs.tag }} + cancel-in-progress: false + +jobs: + assets: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v5 + with: + go-version-file: go.mod + - name: Build host updater assets + env: + APP_VERSION: ${{ inputs.tag }} + APP_COMMIT: ${{ github.sha }} + run: ./scripts/build-updater-assets.sh release-assets + - uses: actions/upload-artifact@v4 + with: + name: updater-assets-${{ inputs.tag }} + path: release-assets/ + if-no-files-found: error + retention-days: 7 + + image: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - uses: actions/checkout@v4 + - uses: docker/setup-qemu-action@v3 + - uses: docker/setup-buildx-action@v3 + - uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Publish image under the existing tag set + env: + TAG: ${{ inputs.tag }} + run: | + set -euo pipefail + image="ghcr.io/${GITHUB_REPOSITORY,,}" + version="${TAG#v}" + series="${version%.*}" + docker buildx build \ + --file deploy/Dockerfile \ + --platform linux/amd64,linux/arm64 \ + --build-arg APP_VERSION="$TAG" \ + --build-arg APP_COMMIT="$GITHUB_SHA" \ + --label "org.opencontainers.image.source=https://github.com/${GITHUB_REPOSITORY}" \ + --label "org.opencontainers.image.version=$TAG" \ + --label "org.opencontainers.image.revision=$GITHUB_SHA" \ + --tag "$image:$TAG" \ + --tag "$image:$version" \ + --tag "$image:$series" \ + --tag "$image:latest" \ + --push . + manifest="$(docker buildx imagetools inspect --raw "$image:$TAG")" + jq -e '.manifests[] | select(.platform.os == "linux" and .platform.architecture == "amd64")' <<< "$manifest" >/dev/null + jq -e '.manifests[] | select(.platform.os == "linux" and .platform.architecture == "arm64")' <<< "$manifest" >/dev/null + echo "Republished $image:$TAG from $GITHUB_SHA" >> "$GITHUB_STEP_SUMMARY" + + attach: + needs: [assets, image] + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/download-artifact@v4 + with: + name: updater-assets-${{ inputs.tag }} + path: release-assets + - name: Replace the release assets + env: + GH_TOKEN: ${{ github.token }} + TAG: ${{ inputs.tag }} + run: | + set -euo pipefail + gh release upload "$TAG" release-assets/* --clobber --repo "$GITHUB_REPOSITORY" + count="$(gh release view "$TAG" --repo "$GITHUB_REPOSITORY" --json assets --jq '.assets | length')" + test "$count" -eq 7 + echo "Release $TAG now carries $count rebuilt assets" >> "$GITHUB_STEP_SUMMARY" diff --git a/AGENTS.md b/AGENTS.md index 1d9a1811..e0048cc8 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -44,11 +44,13 @@ live-account acceptance, and release status separate. - Pull latest `main` and merge it into the current branch before starting any feature work (skip only when already on up-to-date `main`) - After console UI changes, run `cd frontend && npm run sync` so `internal/webui/static` matches `frontend/dist`. Do not commit a stale hashed JS/CSS pair. - User-facing changes add one bilingual file in `changelog/unreleased/` (`### English` / `### 中文`). Do not put upcoming notes in `CHANGELOG.md` and do not add `## Unreleased` there. Do not freeze or unfreeze changelog sections by hand. Do not reuse a fragment filename until that tag's archive PR has merged. +- Version numbers iterate by exactly one patch on the 0.7.x line (baseline `v0.7.45`): the next release is the latest published version +1. Never jump, reuse a tag, or rewind a published version; an explicit release version must equal previous+1, and a deliberate numbering reset needs `allow_rewind` with the old release and tag deleted first. - When `main` is checked out in another worktree, merge PRs with `gh api` / GitHub; do not `git checkout main` here. - Keep architecture: auth / endpoint / executor / translate, plus `internal/store` (SQLite), `internal/control` (console facade: accounts, keys, settings, catalog, login, import), `internal/runtime` (Manager lifecycle), `internal/providers/qoder` (Qoder HOME/CLI/worker protocol and Adapter), `internal/gateway` (public protocol HTTP), `internal/console` (operator HTTP), `internal/server` (routes/middleware/webui), and `internal/app` (process assembly). `internal/api` is a test-only compatibility facade (`api.New` → `app.New`); do not add business there. Account entities stay in `accounts`; Pool/Item/RouteQuery/Classify and request Prepare live in `executor`. Display catalog cache lives in `control.Catalog`; catalog aggregation, identity filter, and settings decoration live in `control`, not `app`. Public `/v1/chat/completions`, `/v1/messages`, `/v1/responses`, and `/v1/models` live in `gateway`; console `/api/*` lives in `console`; `internal/server` registers both. Console HTTP decodes and maps errors; persist/apply for system settings and console-key rotation live in `control.System` / `control.KeyRotation`. Update job/maintenance lives in `internal/update.Coordinator`. SQLite lives in `internal/store`; process tables live in runtime. Runtime constructs the one Pool and injects it into executor. PAT-backed Qoder accounts (`qoder-pat-v1`) run login, catalog, quota, check-in, and chat in-process through the qauth Bridge; do not spawn a Node worker for them. Accounts that still carry the legacy `qoder-native-v1` CLI blob keep one child process per HOME until the operator re-logs them with a PAT. The registered Adapter includes a Prober and sends chat through the in-process COSY client. `cmd/server` constructs `app.New`. `accounts` must not import `runtime` or `executor`. Executor Prepare must not take `*http.Request` or import store. Gateway, console, and server must not import store or runtime Manager. App/server/gateway/console must not import `internal/api`. Provider packages must not receive `http.ResponseWriter` or import executor taxonomy; OAuth loopback HTTP stays in `auth.ServeLoopback`. Adapter error classification and cooldown math live in `executor`; gateway only formats the result. - Prefer direct HTTP/SSE to Qoder cloud APIs - Pin qodercli / qoderclicn hooks in `worker/src/compat.mjs`; fail loudly on mismatch. Qoder CN is `provider=qoder` + `region=cn`, not a new family -- Reasoning levels are catalog-driven: map client values through `internal/providers/reasoning.go` (`none`/`low`/`medium`/`high`/`xhigh`/`max`), clamp anything the model does not allow back to an allowed level, and treat the console value as a default only (it never locks a call or caps a higher client value) +- Reasoning levels follow CC Switch: a level the client sends is forwarded untouched whenever the model declares it, an undeclared level degrades to the nearest lower declared tier (never upward, never to the model default), a request below the floor lands on the cheapest declared tier, and a reasoning mismatch must never move the request to another provider +- Output and context limits are client-owned: forward `max_tokens` / `max_output_tokens` exactly as sent, never replace an absent value with the model's catalog maximum, and publish `context_length` / `max_output_tokens` in `/v1/models` so the client can size its own request. No implicit default knobs unless the upstream protocol itself requires the field - Console UI: React + Tailwind v4 + **HeroUI only** for components - Follow `docs/DESIGN.md` (taste v1 adapted for this console) - Keep iterating Qoder login, usage, and account routing. Keep scheduling focused on personal-account routing rather than commercial gateway features diff --git a/CHANGELOG.md b/CHANGELOG.md index a0c41281..7b9b671b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,133 +3,87 @@ Published user-facing notes for GitHub Releases and the console update page. Write upcoming notes as bilingual files in `changelog/unreleased/`. -## 0.7.45 - 2026-11-24 +## 0.7.45 - 2026-11-25 ### English -- Release the implicit region latch on cross-provider routes so a bare model shared by multiple providers can fail over to another supplier. -- Keep the Qoder global/CN region isolation for provider-scoped routes. -- Preserve the retry budget after the first pick instead of shrinking it to the pinned region's account count. -- Give each priority tier its own retry budget so sibling accounts cannot consume the whole budget before a lower-priority provider is reached. -- Apply account model aliases in the legacy worker request path. -- Add `account_id` to aggregation members so one logical model can target a specific account/deployment instead of fanning out over every account of a provider. -- Persist the field in SQLite and expose it through the console API and model pool editor. -- Keep legacy members without `account_id` on the existing provider/region pool behavior. -- Cross-provider model pool saves now validate every member against the provider policy. A disabled model is rejected instead of being stored as a dead route. +- Releases now come from this fork by default: the console checks `guyu233/cli2api`, the host updater pulls `ghcr.io/guyu233/cli2api`, and both installers use the same repository unless `UPDATE_GITHUB_REPO`, `CLI2API_IMAGE_REPOSITORY`, or `CLI2API_GITHUB_REPOSITORY` say otherwise. +- The System update panel now prints which release repository it follows, and when the host updater is missing it says how to enable one instead of reporting a generic "temporarily unavailable" message. A failed prepare also names the missing updater daemon and the installer script. +- `release.yml` also derives the previous version from reachable `v*` tags when the repository has no published release yet, so a fork's first release continues its version line instead of starting at v0.1.0. +- Model-pool IDs may now contain dots (`deepseek-v4.1-flash`), so an upstream model name can be reused verbatim; spaces, underscores and stray symbols are still rejected with an inline message instead of a silent server error. +- The display name is optional: leave it blank and the model ID is used, and validation errors stay pinned above the footer even when the member list is scrolled. +- Cross-provider model pool members now follow the connected providers and their provider settings. The editor lists only connected provider/region combinations and only models enabled for that provider, and saving an aggregation validates every member against the provider policy. A disabled model is rejected instead of being stored as a dead route. - An aggregated logical model is no longer listed in `/v1/models` when provider policy filters out every one of its members. -- Align reasoning conversion with CC Switch: accept `ultra` as the deepest tier and normalize Anthropic `thinking.budget_tokens` (2048 / 8192 / 16384 / 24576) onto the catalog-driven reasoning ladder. -- Unify provider reasoning intent parsing behind one shared parser while keeping each provider's legacy wire behavior: explicit `thinking:{"type":"disabled"}` stays a separate off switch, and effort strings, effort objects, and enable-thinking flags resolve as before. -- Canonicalize protocol usage across Anthropic, OpenAI chat, and Responses streams: `input_tokens` now excludes cache read/write, cache buckets are always reported, and usage fields from provider aliases (`cache_read_input_tokens`, `cached_tokens`, `cache_creation_input_tokens`) are folded into one shape. -- Keep Trae max mode client-owned: only an explicit `is_max_mode` request is forwarded, never inferred from the catalog or a stored console setting. -- CodeArts requests that the upstream rejects as an unsafe image now fail once with a 400 instead of failing over across every account. -- Codex model catalog adds `gpt-6.2-sol` (GPT-6.2-Sol) and `gpt-6.2-astra` (GPT-6.2-Astra) from the upstream client / CLIProxyAPI list, using the same slim field shape as the 6.1 entries. `gpt-6.2-sol` routes at a 500K context window, `gpt-6.2-astra` at 272K. -- Split console pages into per-route chunks so the first screen loads less JavaScript; rejected chat attachments now use the console toast instead of a browser alert. -- The overview resource panel now follows the backend's 30s sample cadence instead of polling every 5s, account countdowns share one timer, and runtime logs stop polling while the tab is hidden. -- Request statistics now stream the window once instead of running about ten SQL scans; the local 20k-row benchmark drops from ~227 ms to ~57 ms per call. -- The expanded live card now polls at 800ms instead of 400ms, and the inflight depth chart loads only when expanded. The 60s concurrency sparkline stays on Recharts inside that lazy card, so the 316 kB chart bundle remains outside the default console preload. -- The console shell keeps its HeroUI primitives (Drawer, Button, Tooltip, Skeleton) per the design system; the first-screen win comes from route-level lazy pages plus an on-demand update dialog. The entry chunk is 431.4 kB (130.6 kB gzip) with a 348 kB preload group (shim 13 kB, shared HeroUI chunk 94 kB, i18n 148 kB, GSAP 93 kB), down from the previous 461 + 239 + 94 + 13 kB. -- Provider-wide settings now live in a modal on the Models page. Account editing keeps only name, concurrency, and priority; provider policy owns floors, proxy, system-prompt handling, aliases, enabled models, and check-in time. Saving provider settings closes immediately and re-filters the cached catalog in the background instead of waiting for an upstream refresh. -- The Models page groups models into one card per connected provider and region, with a model count in the header. The provider filter lists only connected provider/region pairs, defaults to the first one, and the redundant "Model catalog" intro header is gone. A provider restricted to a selected model list no longer shows `auto`. -- The cross-provider model editor keeps its header and footer visible and scrolls the form body on short screens. Members are configured by provider, region, and model only; the account is chosen automatically from the provider account pool instead of being pinned in the editor. The editor lists only connected provider/region combinations and models enabled by that provider's policy. -- Account cards show the upstream check-in state (`already`, `pending`, `skipped`, or `unknown`) with the last sync time, and scheduled check-in defaults to automatic mode based on the upstream window. -- Added a "Cross-provider model pool" page between Models and Access. It appears only while the existing cross-provider model pool setting is enabled, and toggling that setting updates the navigation immediately. -- You can now define logical models that aggregate multiple real provider models behind one client-facing ID, for both same-named models across providers and differently named models. Each logical model has its own routing strategy (priority order, round robin, fill first, or FEFO), failover settings, and an ordered, weighted member list. -- `/v1/models` now exposes the logical IDs instead of the aggregated per-provider entries; member capabilities are merged conservatively. Logical models are served through the existing route loop and failover/cooldown system, with cooldowns recorded against the real member model. The per-model strategy (priority order by default, round robin, fill first, FEFO) and member weights are honored during routing; priority order keeps using the first healthy member and falls through on failure. -- An account whose first health probe fails no longer stays in `error` until an operator clicks Refresh. The maintenance watchdog now re-runs the full account refresh for a worker that answers `/health` but is still absent from routing, throttled to once every two minutes per account. This covers both the boot-time probe racing a worker that has not bound its port yet and a worker that came back through crash recovery — either case previously left the account, and every model only it could serve, unrouteable. -- A request no enabled account can serve is now answered with `503 no_accounts` instead of the generic `502 upstream_error` the gateway synthesizes for unclassified failures. That 502 read as an origin outage (a proxy in front of the gateway replaced it with its own Bad gateway page) while the real cause was local routing, and a 429 would have made SDKs auto-retry on a fixed schedule a condition only the account watchdog can heal. The `Retry-After` hint matches the watchdog's two-minute per-account re-probe cadence. A key that cannot use the requested provider gets `403 provider_not_allowed`, and an instance with no accounts at all gets `503 no_accounts_configured`. -- API keys can now enable cross-provider model aggregation. An aggregation key's `/v1/models` returns only the public model aliases its granted accounts define, folded into one provider-neutral name per alias; requests still route through the account pool and may only call those names. -- Account model aliases appear in `/v1/models` for ordinary keys too: one public name can route to a different native model per account and provider, while an existing real model id always wins over an alias. -- The key editor now scrolls its provider list so the save/cancel footer stays reachable on shorter screens. -- MiniMax Code accounts now support daily check-in across the console: card status, manual and bulk check-in, check-in history, and scheduled auto check-in. -- Added a one-click model availability check on the Models page. It sends one minimal 1-token, thinking-disabled live request per model per available account, then reports per-account reachability and latency without changing routing cooldowns or the Usage page totals; each probe still consumes one real 1-token upstream request from that account's quota. -- The Models page status column now shows the latest availability result instead of custom/default settings, and the action column is labeled Model details. -- Removed the console reasoning-strength default selector. The Models page now shows the maximum context, the reasoning levels each model actually declares, and image input capability. -- Keep aggregate logical-model sessions bound to a member account instead of resetting to the general pool on every turn. -- Bind a streaming request as soon as the upstream accepts the response headers/first event, not after the body ends; a follow-up turn can then reuse the same account while the first stream is still running. -- Always bind, cool down, and fail over by pool account ID. Worker response labels are never used as routing keys. -- Invalidate a session binding on failover, including sticky escapes. -- Canonicalize provider cache token fields so reported cache usage is stable across provider protocols. +- Retry a transient upstream failure once on the same account before failing over: a stream that dies before its first event or returns an empty body usually recovers on the same worker, and switching accounts throws away the whole prompt cache. +- Stop the local backoff ladder from multiplying a cooldown the upstream declared itself. Transient failures are capped at 60s, and a quota reset reported in the response body is used verbatim (bounded to 24h) instead of being clamped to the 10-minute rate-limit window or scaled up the exponential ladder. +- Keep a session anchor through a short cooldown: a failover whose anchor account is still ready and cooling for five minutes or less no longer clears the binding, so the next turn returns to the cache-warm account instead of walking the pool. +- Raise the default session-affinity TTL from 1h to 4h and expose `CLI2API_AFFINITY_TTL` / `CLI2API_AFFINITY_CAPACITY` (48h and one million bindings are the hard caps). +- Answer a request with no usable account, and an upstream body that cannot be decoded, with `503 no_accounts` / `502 upstream_decode_error` instead of an unclassified `502 upstream_error`. +- Report cache-hit and miss reason distributions (`SessionAffinityStats.miss_reasons` / `escape_reasons`), a per-total `cache_hit_rate`, and per-component session-seed hashes in the affinity debug log, so a chat that silently re-anchors every turn can be traced to a volatile system prefix or a changed first message. +- Saving provider settings no longer waits for an upstream model-catalog refresh; the dialog closes after the policy write and the cached catalog re-filters in the background. +- One-click check-in now runs up to four accounts in parallel instead of waiting through the scheduled check-in gap, so a full account set no longer stalls for tens of seconds. +- The cross-provider model editor now keeps its header and footer visible and scrolls the form body on narrow or short screens, so the member weight and advanced fields are reachable. +- Model-pool members are configured by provider, region, and model only. The account is chosen automatically from the provider account pool instead of being pinned in the editor. +- Normalize the tools array before hashing the session seed, so a client that rebuilds its tool list in a different order no longer scatters one conversation across accounts. `CLI2API_TOOLS_NORMALIZE=1` additionally normalizes the outbound payload order and protects the upstream cached prefix; the default keeps the payload byte-identical. +- Escape a sticky provider binding when every account of that provider is cooling for a real reason (quota, or a retry hint of two minutes or more) and another provider family can serve the model, instead of answering `429` while a healthy supplier sits idle. Shorter cooldowns still return a Retry-After so the chat keeps its warm cache. +- The Models page now renders one card per provider with the model table inside each card. "All providers" is back: it shows cards for every connected provider and those cards can collapse, while selecting one provider keeps that card expanded. - Aligned the in-process client identities with the current official builds: Qoder CLI `1.1.96` (Bun `1.4.4`, global inference on `api2.qoder.sh`), WorkBuddy desktop `5.11.3` CN / `5.11.4` Global with bundled CLI `2.176.0`, Trae CN `3.4.24` (AI extension `2.3.106768`, version code `20260212`), and QwenWork `2.1.0` build `26111906` with COSY `1.1.71`. - WorkBuddy chat now sends the desktop `5.11.3`/`5.11.4` UA, `X-Client-*` identity and `X-Agent-Runtime: local-agent`, and drops the obsolete `X-Root-Request-ID`/`X-No-*` placeholders. Billing and check-in use the desktop AuthService shape (`axios/1.16.1`, a fresh `X-Request-ID`). - WorkBuddy CN now uses the official primary entry `www.workbuddy.cn`; the old `copilot.tencent.com` host still resolves, but the client no longer sends there by default. +- WorkBuddy check-in now queries `/v2/billing/meter/checkin-activity-status` before claiming. Inactive campaigns and same-day repeats are reported as `skipped`/`already` without a duplicate claim. The Global edition no longer advertises or attempts daily check-in because the official desktop disables it. +- Qoder, Trae, QwenWork, MiniMax Code, CodeArts, and Doubao check-in flows were re-audited; no public endpoint change was found, so their claim paths remain as-is. - A provider restricted to a selected model list no longer shows `auto`; it stays visible only while that provider keeps the full model catalog. -- Provider-level floors, proxy, system-prompt handling, aliases, enabled models, and check-in time are now stored as one policy per provider/region. The policy is the single source of truth: account reads overlay it at runtime, saving it refreshes the live pool instead of writing the same values back to every account, and new or imported accounts inherit it automatically. Existing provider groups are seeded once at startup from their current account values without rewriting account rows. -- Qoder check-in now counts a reward as already claimed only when the upstream says so. A blocked or closed campaign stays a failure and can be retried later the same day. -- Codex requests present the official stable CLI identity, `codex_cli_rs/0.171.0`. -- Added `least-quota-first` and `most-quota-first` routing strategies for both global account scheduling and aggregation model pools. They rank accounts by remaining quota ratio and place accounts with unknown quota last. -- Fixed model-pool strategy overrides so FEFO candidate counting matches account selection, and normalized stored aggregation strategies so legacy/case-variant values do not silently fall back to round robin. -- Aggregated model-pool failover no longer pins the first member's region or recomputes the plan's attempt budget, so cross-provider members stay reachable and MaxAttempts is honored. -- Check-in status is now read from the provider instead of trusting the last local attempt. The account API returns upstream `already`, `pending`, `skipped`, or `unknown`, with the last sync time. -- One-click check-in now runs up to four accounts in parallel instead of waiting through the scheduled check-in gap, so a full account set no longer stalls for tens of seconds. -- WorkBuddy queries `/v2/billing/meter/checkin-activity-status` before claiming. Inactive campaigns and same-day repeats are reported as `skipped`/`already` without a duplicate claim. The Global edition no longer advertises or attempts daily check-in because the official desktop disables it. +- Account-level floors, proxy, system-prompt handling, aliases, enabled models, and check-in time move to a provider-wide settings modal on the Models page. The provider policy is now the single source of truth: accounts no longer store the effective provider settings, reads overlay the policy at runtime, and saving it refreshes the live pool instead of writing the same values back to every account. Existing provider groups are seeded once at startup from their current account values without rewriting account rows. Once a provider policy exists, new or imported accounts inherit it automatically, and the account editor keeps only name, concurrency, and priority. +- The Models page provider filter now lists only provider/region pairs that have an account, drops the "All providers" option, and defaults to the first connected provider so only one provider group is shown at a time. +- The Models page now groups models by provider and region, with a provider header showing the model count. Search, provider filtering, pagination, model defaults, Max mode, status checks, and model details stay available after the grouping change. +- Remove the redundant model-catalog intro header from the Models page; model rows and provider groups stay unchanged. +- Check-in status is now read from the provider instead of trusting the last local attempt. The account card shows upstream `already`, `pending`, `skipped`, or `unknown`, with the last sync time. - Scheduled check-in is automatic by default: the upstream daily window start plus one hour (Qoder 10:00 → 11:00, other providers 00:00 → 01:00). Manual provider times still override auto mode. - Check-in scheduling uses the provider server clock (`Asia/Shanghai`), not the operator PC's local timezone. - A campaign status that carries no per-day flag (CodeArts) is treated as provisional until 02:00 Asia/Shanghai; an "already claimed" replay during the first two hours of the day is not recorded as today's success, and the scheduler retries at 02:05, 12:05, and 21:00. - CodeArts reports `already` only for the `USER_LOGIN` daily campaign, not for a used-up new-user or student reward, and posts the IDE's confirmation step when the claim returns a benefit id. -- WorkBuddy now merges adjacent assistant tool-call messages before sending them upstream, so a split Codex replay no longer fails with tool-call sequence error 11148. +- Update checks and the host updater's self-update no longer hardcode the upstream repository: `UPDATE_GITHUB_REPO` (service) and `--github-repo` (updater) accept any owner/repo, so a fork that publishes its own releases is detected and can refresh its updater binary. +- `deploy/install-updater.sh` and `deploy/install-updater.ps1` honor `CLI2API_IMAGE_REPOSITORY` / `CLI2API_GITHUB_REPOSITORY` and pass the release repository to the updater, so a fork deployment installs without editing the scripts. ### 中文 -- 跨供应商裸模型路由不再被第一次选中的 region 隐式锁住,失败后可以切换到其他供应商。 -- Qoder 等 provider-scoped 路由继续保持 global/CN 区域隔离。 -- 首次选号后保留原重试预算,不再按 pinned region 的账号数量缩小 attempts。 -- 每个 priority tier 使用独立重试预算,避免第一供应商的 sibling accounts 耗尽全局预算,导致低优先级供应商完全无法被尝试。 -- legacy worker 请求路径也应用账号模型别名。 -- 聚合成员新增 `account_id`,让一个逻辑模型可以固定到一个具体账号/deployment,而不是默认在该供应商下扇出到所有账号。 -- 该字段持久化到 SQLite,并通过控制台 API 和模型池编辑器暴露。 -- 未填写 `account_id` 的旧成员保持原有 provider/region 池行为。 -- 保存跨 Provider 模型池时会逐个校验成员是否符合供应商策略。未启用的模型会被拒绝,不会再存成无法路由的死成员。 +- 发布源默认改为本 fork:控制台检查 `guyu233/cli2api`,宿主机 updater 拉取 `ghcr.io/guyu233/cli2api`,两个安装脚本也默认使用同一仓库;需要跟随其它仓库时用 `UPDATE_GITHUB_REPO`、`CLI2API_IMAGE_REPOSITORY`、`CLI2API_GITHUB_REPOSITORY` 覆盖。 +- 系统更新的版本面板会显示当前跟随的发布仓库;宿主机 updater 缺失时给出启用方法,而不是笼统的"暂时无法更新";准备阶段失败时错误信息也会指出缺失的 updater 守护进程和安装脚本。 +- `release.yml` 在仓库还没有已发布 Release 时会从可达的 `v*` tag 推算上一个版本,fork 的首次发布会延续版本线,而不是从 v0.1.0 重新开始。 +- 模型池 ID 现在允许点号(`deepseek-v4.1-flash`),可以直接沿用上游模型名;空格、下划线等仍然会被就地拒绝并说明原因,不再等到服务端返回一个看不见的错误。 +- 显示名称变为可选:留空则直接使用模型 ID;校验失败的错误固定显示在底部按钮上方,成员列表滚到底也可见。 +- 跨 Provider 模型池的成员现在严格跟随已接入的供应商及其供应商设置:编辑器只列出已接入的供应商/区域组合和该供应商启用的模型,保存聚合模型时会逐个校验成员是否符合供应商策略。未启用的模型会被拒绝,不会再存成无法路由的死成员。 - 当供应商策略把所有成员都过滤掉时,聚合逻辑模型不再出现在 `/v1/models` 中。 -- 推理转换对齐 CC Switch 约定:接受 `ultra` 作为最深档,并把 Anthropic `thinking.budget_tokens`(2048 / 8192 / 16384 / 24576)归一化到由 catalog 驱动的推理档位。 -- 用统一的解析器处理各供应商的推理意图,同时保持各自的旧有请求行为:`thinking:{"type":"disabled"}` 仍是独立的关闭开关,effort 字符串、effort 对象和 enable-thinking 开关的解析结果不变。 -- 统一 Anthropic、OpenAI chat 和 Responses 流的 usage 口径:`input_tokens` 不再包含缓存读写,缓存字段始终上报,并把供应商别名(`cache_read_input_tokens`、`cached_tokens`、`cache_creation_input_tokens`)折算为同一形状。 -- Trae 的 Max 模式保持由客户端决定:只有请求显式带上 `is_max_mode` 才透传,不再从 catalog 或控制台保存的设置推断。 -- CodeArts 上游判定图片内容不安全时,请求现在直接以 400 失败一次,不再对所有账号逐个故障转移。 -- Codex 模型目录新增上游客户端 / CLIProxyAPI 列表中的 `gpt-6.2-sol`(GPT-6.2-Sol)与 `gpt-6.2-astra`(GPT-6.2-Astra),字段结构与 6.1 条目一致。`gpt-6.2-sol` 按 500K 上下文窗口路由,`gpt-6.2-astra` 为 272K。 -- 控制台页面按路由拆包,首屏加载的 JavaScript 更少;聊天不支持的文件改用控制台提示,不再弹浏览器 alert。 -- 概览资源面板改为对齐后端 30 秒采样节奏,不再每 5 秒重复请求;账号冷却倒计时共用一个定时器;运行日志在标签页隐藏时停止轮询。 -- 请求统计改为单次扫描窗口并在 Go 内聚合,本机 20,000 行基准从约 227 ms/次降到约 57 ms/次。 -- 展开态实时卡片轮询从 400ms 放慢到 800ms;inflight 深度图表只在展开时加载。60 秒并发曲线仍使用 Recharts 并位于该懒加载卡片内,316 kB 图表包依旧不进入控制台默认预加载。 -- 控制台外壳按设计规范保留 HeroUI 原语(Drawer、Button、Tooltip、Skeleton);首屏收益来自路由级拆包和按需加载的版本更新弹窗。入口为 431.4 kB(gzip 130.6 kB),预加载组 348 kB(shim 13 kB、HeroUI 共享块 94 kB、i18n 148 kB、GSAP 93 kB),此前为 461 + 239 + 94 + 13 kB。 -- 供应商级设置改为模型页上的统一弹窗。账号编辑只保留名称、并发和优先级;积分/百分比保底、代理、系统提示词处理、别名、可用模型和签到时间由供应商策略统一管理。保存供应商设置后弹窗立即关闭,已缓存目录在后台重新过滤,不再等待上游刷新。 -- 模型页按已接入的供应商与区域分组,每个供应商一张卡片,标题显示模型数量。供应商筛选只列出有账号接入的供应商/区域并默认选中第一个,顶部冗余的“模型目录”说明栏已移除。限制为勾选模型的供应商不再显示 `auto`。 -- 跨 Provider 模型编辑器在矮屏下固定标题和底部操作区、让表单内容独立滚动。成员只按供应商、区域和模型配置,账号由供应商账号池自动选择,不再在编辑器里指定单个账号;编辑器只列出已接入的供应商/区域和该供应商策略启用的模型。 -- 账号卡片显示上游签到状态(已签到、未签到、未开放或状态未知)和最近同步时间;自动签到默认按上游窗口自动排期。 -- 在“模型”和“接入与调试”之间新增“跨 Provider 模型池”页面;仅当现有的跨 Provider 模型池开关开启时出现,切换开关后导航会立即更新。 -- 现在可以定义逻辑模型,把多个真实供应商模型聚合到同一个客户端 ID 下,既支持跨供应商的同名模型,也支持不同名称的模型。每个逻辑模型都可以单独配置路由策略(优先级顺序、轮询、优先填满或 FEFO)、故障转移规则,以及有序带权重的成员列表。 -- `/v1/models` 现在返回聚合后的逻辑 ID,而不再展示被聚合的逐供应商条目;成员能力按保守方式合并。逻辑模型复用现有选路与故障转移/冷却体系,冷却记录在真实成员模型上。每个逻辑模型的策略和成员权重现在真正参与选路;优先级顺序会持续使用第一个健康成员并在失败时顺延,未配置时默认按优先级顺序。 -- 首次健康探测失败的账号不再卡在 `error` 状态等人工点刷新:维护看门狗现在会对「`/health` 有响应但没进路由」的 worker 重跑一次账号刷新,每个账号两分钟最多一次。既覆盖开机时探测早于 worker 绑定端口的竞态,也覆盖崩溃恢复后重新拉起的 worker——这两种情况以前都会让该账号(以及只有它能提供的模型)一直不可路由。 -- 没有任何可用账号的请求现在返回 `503 no_accounts`,不再落到网关对未分类错误兜底的 `502 upstream_error`。那个 502 看起来像源站故障(网关前面的代理还会把它替换成自己的 Bad gateway 页),实际原因是本地路由;而 429 会让 SDK 按固定节奏自动重试一个只有账号看门狗才能恢复的问题。`Retry-After` 与看门狗每账号两分钟的重探节奏一致。密钥无权使用请求的 provider 时返回 `403 provider_not_allowed`,实例里一个账号都没有时返回 `503 no_accounts_configured`。 -- API 密钥可以开启「跨供应商模型聚合」。开启后,`/v1/models` 只返回该密钥可访问账号上配置的公共模型别名,并按别名合并成一条、不显示供应商;请求仍按账号池路由,且只能调用这些聚合名称。 -- 普通密钥的 `/v1/models` 也会展示账号模型别名:同一个公共模型名可以按账号和 Provider 路由到不同的原生模型;与真实模型同名的别名不会覆盖真实模型。 -- 密钥编辑弹窗在屏幕较矮时改为滚动供应商列表,保存与取消按钮始终可见。 -- MiniMax Code 账号现已支持每日签到:账号卡片状态、手动/一键签到、签到记录以及定时自动签到均已接入。 -- 模型页新增一键可通性检查:对“每个模型 × 每个可用账号”发送一次仅 1 token、关闭思考的真实请求,返回逐账号可通状态与延迟,且不会改变路由冷却状态或用量页统计;每次探测会真实消耗该账号的一次 1 token 上游额度。 -- 模型页状态列改为显示最近一次可通性检查结果,不再显示默认/自定义;操作表头改为“模型详情”。 -- 移除控制台推理强度默认选择器;模型页改为展示最大上下文、每个模型实际声明的思考档位和图片输入能力。 -- 聚合逻辑模型的会话持续绑定到成员账号,不再每轮重置为通用路由池。 -- 流式请求在上游接受响应头/首个成功事件时就完成绑定,而不是等整个响应体结束;第一轮流式请求尚未结束时,下一轮也能复用同一账号。 -- 绑定、冷却和故障转移全部使用 pool account ID;worker 回写的响应标签不会作为路由键。 -- 发生 failover 时失效会话绑定,包括 sticky-escape 场景。 -- 统一各 provider 的缓存 token 字段口径,让上报的缓存用量在不同协议下保持稳定。 +- 上游瞬时失败先在同一账号重试一次再切号:首个事件之前就断流或返回空 body 的请求通常在同一 worker 上就能恢复,而换号会把整个 prompt 缓存丢掉。 +- 本地指数退避不再放大上游自己给出的冷却时间。瞬时失败封顶 60 秒;响应体里上报的 quota 重置时间按原值使用(上限 24 小时),既不被 10 分钟的限流窗口截断,也不被指数阶梯成倍放大。 +- 短冷却期间保留会话锚点:failover 时若原账号仍然 Ready 且冷却不超过 5 分钟,不再清空绑定,下一轮直接回到缓存已预热的账号,而不是重新在池子里轮转。 +- 会话亲和默认 TTL 从 1 小时提升到 4 小时,并新增 `CLI2API_AFFINITY_TTL` / `CLI2API_AFFINITY_CAPACITY`(硬上限 48 小时、一百万条绑定)。 +- 没有可用账号的请求、以及上游返回无法解码的响应体,分别返回 `503 no_accounts` 和 `502 upstream_decode_error`,不再落到未分类的 `502 upstream_error`。 +- 上报缓存命中的 miss/escape 原因分布(`SessionAffinityStats.miss_reasons` / `escape_reasons`)、按总量计算的 `cache_hit_rate`,并在亲和调试日志中输出会话指纹的分量哈希,这样"每轮都在悄悄换号"的对话可以直接定位到是 system 前缀抖动还是首条消息变了。 +- 保存供应商设置不再等待上游模型目录刷新;策略写入后对话框立即关闭,已缓存的目录在后台重新过滤。 +- 一键签到改为最多四个账号并行执行,不再逐个等待定时签到间隔,整批账号不会再卡几十秒。 +- 跨 Provider 模型编辑器在窄屏或矮屏下会固定标题和底部操作区、让表单内容区域独立滚动,成员权重等底部字段不会再被裁掉。 +- 模型池成员只按供应商、区域和模型配置,账号由供应商账号池自动选择,不再在编辑器里指定单个账号。 +- 计算会话指纹前先归一化 tools 数组顺序,客户端每轮重建工具列表不再把同一段对话打散到多个账号。设置 `CLI2API_TOOLS_NORMALIZE=1` 会同时归一化发往上游的 payload 顺序,进一步保护上游的缓存前缀;默认保持 payload 字节不变。 +- 当某供应商所有账号都在因为真实原因冷却(额度耗尽,或上游给出两分钟以上的重试提示),而另一供应商家族还能服务该模型时,允许脱离 sticky 绑定改走可用供应商,不再一边返回 `429` 一边让健康账号闲置。更短的冷却仍然返回 Retry-After,让对话保住已预热的缓存。 +- 模型页现在每个供应商一个卡片,模型表格放在卡片内部。恢复“全部供应商”:展示所有已接入供应商的卡片,这些卡片可以折叠;选中单个供应商时卡片只能展开。 - 将进程内客户端身份对齐到当前官方客户端:Qoder CLI `1.1.96`(Bun `1.4.4`,国际版推理走 `api2.qoder.sh`)、WorkBuddy 国内桌面端 `5.11.3` / 国际版 `5.11.4`(内置 CLI `2.176.0`)、Trae 国内版 `3.4.24`(AI 扩展 `2.3.106768`,版本码 `20260212`)、千问办公 `2.1.0`(构建 `26111906`,COSY `1.1.71`)。 - WorkBuddy 对话改用桌面端 `5.11.3` / `5.11.4` 的 UA、`X-Client-*` 身份和 `X-Agent-Runtime: local-agent`,去掉过时的 `X-Root-Request-ID` / `X-No-*` 占位头;积分与签到改用桌面 AuthService 的 `axios/1.16.1` 身份和每次新生成的 `X-Request-ID`。 - WorkBuddy 国内版改用官方主入口 `www.workbuddy.cn`;旧的 `copilot.tencent.com` 仍能解析,但客户端默认不再请求。 +- WorkBuddy 签到在领取前先查询 `/v2/billing/meter/checkin-activity-status`。活动未开启和今日已签分别返回 `skipped` / `already`,不会再重复领取。由于官方国际版桌面端关闭了签到,国际版不再声明或尝试每日签到。 +- 重新核对了 Qoder、Trae、千问办公、MiniMax Code、CodeArts、豆包签到流程;未发现公开端点变更,领取路径保持不变。 - 限制为勾选模型的供应商不再显示 `auto`;只有保持完整模型目录的供应商才会保留该目录项。 -- 积分/百分比保底、代理、系统提示词处理、别名、可用模型和签到时间改为按供应商/区域保存的统一策略。策略是唯一事实源:账号读取时在运行时叠加,保存策略只刷新池子,不再把同一组值写回每个账号;新建或导入账号会自动继承。已有供应商分组会在启动时用现有账号值一次性生成策略,同样不写账号行。 -- Qoder 签到只在上游明确表示已领取时记为已签到。活动被拦截或未开放仍记为失败,当天可以再试。 -- Codex 请求使用官方稳定版 CLI 身份 `codex_cli_rs/0.171.0`。 -- 新增 `least-quota-first`(剩余额度最少优先)和 `most-quota-first`(剩余额度最多优先)路由策略,全局账号调度和模型池都可使用;按剩余额度百分比排序,额度未知的账号排在最后。 -- 修复模型池策略覆盖时 FEFO 候选计数与实际选号不一致的问题,并在读取存储的模型池策略时做归一化,避免历史大小写或旧值静默退回轮询。 -- 聚合模型池的故障转移不再锁定首个成员的 region,也不再重算尝试预算,跨供应商成员仍可被尝试,配置的 MaxAttempts 会被遵守。 -- 签到状态改为读取上游真实状态,不再只信任本地上一次执行结果。账号接口返回上游的已签到、未签到、未开放或状态未知,并标注最近同步时间。 -- 一键签到改为最多四个账号并行执行,不再逐个等待定时签到间隔,整批账号不会再卡几十秒。 -- WorkBuddy 在领取前先查询 `/v2/billing/meter/checkin-activity-status`。活动未开启和今日已签分别返回 `skipped` / `already`,不会重复领取。由于官方国际版桌面端关闭了签到,国际版不再声明或尝试每日签到。 +- 积分/百分比保底、代理、系统提示词处理、别名、可用模型和签到时间改为模型页每个供应商分组里的统一设置。供应商策略现在是唯一事实源:账号行不再承载生效的供应商设置,运行时读取时叠加策略,保存策略只刷新池子,不再把同一组值写回每个账号。已有供应商分组会在启动时用现有账号值一次性生成策略,同样不写账号行。供应商策略存在后,新建或导入账号会自动继承,账号编辑只保留名称、并发和优先级。 +- 模型页供应商筛选现在只列出有账号接入的供应商/区域,移除“全部供应商”,并默认选中第一个已接入供应商,一次只展示一个供应商分组。 +- 模型页面改为按供应商与区域分组,每个分组标题显示该组模型数量。搜索、供应商筛选、分页、模型默认上下文与推理档位、Max 模式、状态检查、模型详情等能力保持不变。 +- 移除模型页顶部冗余的“模型目录”说明栏,模型列表和供应商分组保持不变。 +- 签到状态改为读取上游真实状态,不再只信任本地上一次执行结果。账号卡片显示上游返回的已签到、未签到、未开放或状态未知,并标注最近同步时间。 - 自动签到时间默认改为“上游每日窗口开始 + 1 小时”(Qoder 10:00 → 11:00,其他供应商 00:00 → 01:00)。供应商设置切换为手动时仍按手动时间执行。 - 签到排期按供应商服务器时钟(`Asia/Shanghai`)计算,不再跟随电脑本地时区。 - 不带“当天”字段的活动状态(CodeArts)在服务器时间 02:00 前仍视为待确认;前两小时的“已领取”回放不会被记成今天的成功,调度会在 02:05、12:05、21:00 重试。 - CodeArts 只有 `USER_LOGIN` 每日活动才显示“已签到”,不会再把已用完的新用户/学生奖励当成今天已签;领取返回 benefit id 时补发 IDE 的确认请求。 -- WorkBuddy 会先把相邻的助手工具调用合并再发给上游,拆开的 Codex 回放不再因工具调用顺序错误 11148 失败。 +- 更新检查与宿主 updater 的自我更新不再写死上游仓库:`UPDATE_GITHUB_REPO`(服务端)和 `--github-repo`(updater)可指向任意 owner/repo,发布在 fork 的版本因此能被发现,updater 二进制也能随之更新。 +- `deploy/install-updater.sh` 与 `deploy/install-updater.ps1` 支持 `CLI2API_IMAGE_REPOSITORY` / `CLI2API_GITHUB_REPOSITORY` 覆盖并把发布仓库传给 updater,fork 部署无需改脚本即可安装。 ## 0.7.44 - 2026-11-20 diff --git a/changelog/unreleased/account-select-checkbox-fix.md b/changelog/unreleased/account-select-checkbox-fix.md new file mode 100644 index 00000000..01563d66 --- /dev/null +++ b/changelog/unreleased/account-select-checkbox-fix.md @@ -0,0 +1,7 @@ +### English + +- Accounts page: the bulk re-login checkbox is clickable again. HeroUI v3 keeps the interactive control inside `Checkbox.Content`; the card rendered the indicator on its own, so it looked correct but swallowed every click and no account could be selected. + +### 中文 + +- 账号页:批量重新登录的勾选框恢复可点。HeroUI v3 的可交互控件在 `Checkbox.Content` 里,卡片此前只渲染了指示器本身,看上去正常但吃掉了所有点击,导致一个账号都选不中。 diff --git a/changelog/unreleased/checkin-time-setting.md b/changelog/unreleased/checkin-time-setting.md new file mode 100644 index 00000000..5aca9cb3 --- /dev/null +++ b/changelog/unreleased/checkin-time-setting.md @@ -0,0 +1,9 @@ +### English + +- Automatic check-in now follows one operator-set time per provider instead of a learned upstream window. The setting defaults to 09:00 for every provider, lives in the console system settings, and takes effect for any account without a per-account custom time as soon as it is saved; the stored per-account auto time is only a display mirror and no longer outranks the setting. +- Removed the upstream earliest-window learning and the per-provider/region provenance table (`earliest`, `window_from_upstream`, `window_source`); upstream status payloads now only report check-in status. + +### 中文 + +- 自动签到改为跟随「按供应商统一设置的时间」,默认全部为 09:00,在控制台系统设置里调整;未单独设置时间的账号在保存后立刻按新时间排期,账号上存的自动时间只做展示、不再压过设置。 +- 移除了按上游最早窗口学习以及注册表里的窗口出处表(`earliest`、`window_from_upstream`、`window_source`),上游状态只用来回报签到状态。 diff --git a/changelog/unreleased/console-bulk-relogin.md b/changelog/unreleased/console-bulk-relogin.md new file mode 100644 index 00000000..fd9218da --- /dev/null +++ b/changelog/unreleased/console-bulk-relogin.md @@ -0,0 +1,9 @@ +### English + +- Accounts page: new "Re-login" mode. Tick the account cards, press confirm, and the console walks the selected accounts one by one, opening each account's authorization page, polling the login status, and advancing automatically once an account is signed in. A cancel button stops the walkthrough at any point; each row keeps its own status and the verbatim upstream message. +- Accounts are authorized sequentially on purpose: WorkBuddy accounts often share one SSO session, and parallel flows would hand the same freshly issued token to different account records. + +### 中文 + +- 账号页新增「重新登录」模式:勾选账号卡片后点确定,控制台会按顺序逐个走授权流程——打开该账号的登录页、轮询登录状态,登录成功后自动进入下一个;随时可点取消中止,每一行都保留自己的状态和上游原文消息。 +- 故意串行授权:多个 WorkBuddy 账号常共用一个 SSO 会话,并发授权会把同一份新签发的令牌塞给不同账号。 diff --git a/changelog/unreleased/max-output-no-implicit-default.md b/changelog/unreleased/max-output-no-implicit-default.md new file mode 100644 index 00000000..8a355410 --- /dev/null +++ b/changelog/unreleased/max-output-no-implicit-default.md @@ -0,0 +1,7 @@ +### English + +- Reverted the implicit max-output default: a request that omits `max_tokens` is passed through to the upstream again, and the gateway only publishes the model's limits in `/v1/models` instead of forcing the model's maximum output size. + +### 中文 + +- 回退了隐式最大输出兜底:客户端不传 `max_tokens` 时重新原样透传给上游,网关只在 `/v1/models` 里声明模型的上限,不再替客户端把输出上限拉到模型最大值。 diff --git a/changelog/unreleased/model-pool-capability-limits.md b/changelog/unreleased/model-pool-capability-limits.md new file mode 100644 index 00000000..f724d9c7 --- /dev/null +++ b/changelog/unreleased/model-pool-capability-limits.md @@ -0,0 +1,7 @@ +### English + +- The logical model editor no longer rejects capability values on its own rules: the 1024-token floor and the "max output must not exceed context length" rule are gone, so any non-negative integer is accepted and 0 still means auto. + +### 中文 + +- 逻辑模型编辑不再按自身规则拦下能力值:取消 1024 下限,也取消「最大输出不能超过上下文长度」的限制,任意非负整数都可以保存,0 仍表示自动。 diff --git a/changelog/unreleased/model-pool-reasoning-picker.md b/changelog/unreleased/model-pool-reasoning-picker.md new file mode 100644 index 00000000..5bee51f8 --- /dev/null +++ b/changelog/unreleased/model-pool-reasoning-picker.md @@ -0,0 +1,9 @@ +### English + +- Reasoning levels in the logical-model editor are now real checkboxes: each tier shows its meaning, the panel shows `n/6 selected`, and Select all / Clear remove mistakes in one click. +- The default level list stays limited to the selected tiers, and dropping a tier resets an invalid default back to Automatic instead of silently keeping it. + +### 中文 + +- 逻辑模型编辑器里的思考档位改成真正的复选框:每一档都有含义说明,面板显示「已选 n/6 档」,并有「全选」「清空」可以一键纠正选错。 +- 默认档位只在已选档位里取值;取消某档时,非法的默认值会自动回到「自动」,不再静默保留。 diff --git a/changelog/unreleased/reasoning-ccswitch-passthrough.md b/changelog/unreleased/reasoning-ccswitch-passthrough.md new file mode 100644 index 00000000..2cdbf00d --- /dev/null +++ b/changelog/unreleased/reasoning-ccswitch-passthrough.md @@ -0,0 +1,7 @@ +### English + +- Reasoning effort now follows the CC Switch rule end to end: a level the client sends is passed through untouched whenever the model declares it, an undeclared level only degrades to the nearest lower declared level, and it is never promoted to the model default — including the WorkBuddy "none" path that used to fall back to the default tier. + +### 中文 + +- 思考强度按 CC Switch 规则处理:客户端传来的档位只要模型声明过就原样透传,未声明时只向下退到最近的已声明档位,绝不再被提升为模型默认档——WorkBuddy 原先回落到默认档的「none」分支也一并修正。 diff --git a/changelog/unreleased/reasoning-effort-degrade.md b/changelog/unreleased/reasoning-effort-degrade.md new file mode 100644 index 00000000..159c6a22 --- /dev/null +++ b/changelog/unreleased/reasoning-effort-degrade.md @@ -0,0 +1,11 @@ +### English + +- Reasoning effort now degrades the CC Switch way: a level the model does not declare resolves to the nearest lower level it does declare, and never upgrades. +- A request below the model's floor (for example `reasoning_effort: none` against a model that only offers low/high/max) lands on the cheapest declared level instead of the model default, so "do not think hard" no longer becomes full-strength thinking. +- Declared levels are forwarded untouched, and `max` is never downgraded. + +### 中文 + +- 思考强度改为按 CC Switch 的方式降级:模型没有声明的档位解析为它声明过的最近更低档,且永不升档。 +- 请求低于模型最低档时(例如对只提供 low/high/max 的模型传 `reasoning_effort: none`),落到最低可用档而不是模型默认档,因此「不要高强度思考」不会再变成满档思考。 +- 模型声明了的档位原样下发,`max` 永不被降级。 diff --git a/changelog/unreleased/stream-idle-timeout.md b/changelog/unreleased/stream-idle-timeout.md new file mode 100644 index 00000000..bc566f95 --- /dev/null +++ b/changelog/unreleased/stream-idle-timeout.md @@ -0,0 +1,9 @@ +### English + +- Streaming responses now carry a 5-minute upstream idle deadline (`CLI2API_STREAM_IDLE_MS`, clamped to at least 30s). An upstream that answers the response head and then goes silent no longer holds the account's in-flight slot, the client connection and a permanently "streaming" request row: the relay reports `stream_idle_timeout`, the account cools down for 10s, and the slot is released. +- On boot, request rows a previous process left in `started`/`streaming` are closed as `error` / `stream_abandoned`, so the console stops showing phantom running requests after every restart. + +### 中文 + +- 流式响应新增 5 分钟上游空闲上限(`CLI2API_STREAM_IDLE_MS`,最低按 30 秒)。上游回了响应头后长时间不吐字节时,不再永久占住账号并发槽位、客户端连接和一直显示 `streaming` 的请求记录:转发报 `stream_idle_timeout`,该账号冷却 10 秒并释放槽位。 +- 启动时会把上一进程遗留的 `started`/`streaming` 请求记录收尾为 `error` / `stream_abandoned`,重启后控制台不再出现幽灵运行中的请求。 diff --git a/changelog/unreleased/tool-call-arguments-repair.md b/changelog/unreleased/tool-call-arguments-repair.md new file mode 100644 index 00000000..c32fbba0 --- /dev/null +++ b/changelog/unreleased/tool-call-arguments-repair.md @@ -0,0 +1,11 @@ +### English + +- Tool calls: stop dropping or failing on argument text that is only formatting-damaged. Trailing commas, bare quotes inside a value, missing closing brackets, and prose appended after the object are now repaired before a call is validated, on `/v1/responses`, `/v1/messages`, and the OpenAI compatibility paths. +- Streaming assembly no longer mangles arguments when an upstream resends the whole argument buffer on each chunk, omits `index`, reports `index` 0 for every call, or sends a JSON object where the schema expects a string. Those cases previously produced `{"a":1}{"a":1}` or silently lost fragments, which clients report as "arguments are invalid JSON". +- Arguments genuinely cut mid-string (output-token limit) are still rejected instead of being padded into a valid-looking command, and the error now says the model hit its token limit. + +### 中文 + +- 工具调用:参数文本只是格式损坏时不再丢弃或直接报错。结尾多余逗号、值内部裸引号、缺少闭合括号、对象后面跟了一段解释文字,都会先修复再校验,覆盖 `/v1/responses`、`/v1/messages` 和 OpenAI 兼容路径。 +- 流式拼接不再被上游的坏习惯整坏:上游每帧重发完整参数缓冲、省略 `index`、所有调用都写 `index:0`、或者该给字符串却给了 JSON 对象,以前会拼出 `{"a":1}{"a":1}` 或静默丢片段,客户端那边就报「arguments are invalid JSON」。 +- 真被输出 token 上限截断在字符串中间的参数仍然报错(不会补成看起来合法、实际却不是模型本意的命令),并在错误里说明是触到 token 上限。 diff --git a/changelog/unreleased/tool-call-arguments-stream-normalize.md b/changelog/unreleased/tool-call-arguments-stream-normalize.md new file mode 100644 index 00000000..5c3d9e9e --- /dev/null +++ b/changelog/unreleased/tool-call-arguments-stream-normalize.md @@ -0,0 +1,9 @@ +### English + +- Streaming tool calls now deliver arguments as one already-normalized string instead of relaying upstream fragments. `/v1/responses` sends the repaired arguments once in `response.function_call_arguments.delta` and repeats them in `.done`, `/v1/messages` sends them at block close, and `/v1/chat/completions` withholds tool frames until the call is complete. Clients that concatenate deltas and clients that read the done event therefore receive identical, valid JSON. +- Arguments truncated mid-string are no longer padded. The unfinished trailing member is dropped, so the call still parses and the tool or model can recover, instead of the round failing with "arguments are invalid JSON". + +### 中文 + +- 流式工具调用不再把上游碎片直接转发,而是一次性下发已经归一化好的参数:`/v1/responses` 在 `response.function_call_arguments.delta` 给出修复后的完整参数并在 `.done` 重复一次,`/v1/messages` 在 block 收尾时发,`/v1/chat/completions` 把工具帧拦到调用结束再发。因此「拼接 delta 的客户端」和「读 done 事件的客户端」拿到的是同一份合法 JSON。 +- 截断在字符串中间的参数不再补齐:只丢弃尾部未完成的那个成员,调用仍然能解析,交给工具或模型自己纠正,而不是整轮报「arguments are invalid JSON」。 diff --git a/changelog/unreleased/trae-max-window-unlocked.md b/changelog/unreleased/trae-max-window-unlocked.md new file mode 100644 index 00000000..abd5e72e --- /dev/null +++ b/changelog/unreleased/trae-max-window-unlocked.md @@ -0,0 +1,7 @@ +### English + +- Trae models that declare a larger Max tier are unlocked by the catalogue itself: the adapter asks upstream for the bigger context window on every request, `/v1/models` advertises it, and the console shows a single context size instead of a per-model Max switch. + +### 中文 + +- Trae 里声明了更大 Max 档的模型改为自动解锁:适配器每次请求都向上游要更大的上下文窗口,`/v1/models` 直接按大窗口声明,控制台只显示一个上下文数值,不再挂一个按模型的 Max 开关。 diff --git a/changelog/unreleased/update-follows-latest-marker.md b/changelog/unreleased/update-follows-latest-marker.md new file mode 100644 index 00000000..0137fd40 --- /dev/null +++ b/changelog/unreleased/update-follows-latest-marker.md @@ -0,0 +1,7 @@ +### English + +- Follow the repository's own latest-release marker when deciding what to update to, instead of always taking the highest tag, so a deliberate version renumbering keeps pointing clients at the version the project actually publishes. + +### 中文 + +- 更新检查改为跟随仓库标记的 latest 发布,而不是永远取最高标签;这样主动重排版本号后,客户端看到的仍然是项目真正发布的那一版。 diff --git a/changelog/unreleased/updater-health-version-match.md b/changelog/unreleased/updater-health-version-match.md new file mode 100644 index 00000000..769062f0 --- /dev/null +++ b/changelog/unreleased/updater-health-version-match.md @@ -0,0 +1,7 @@ +### English + +- Fix the updater's post-restart health gate: images report the release tag (`v0.7.52`) while the console sends the bare semver (`0.7.52`), so the previous strict string comparison failed every deploy and forced a needless rollback. Versions are now compared as semver, ignoring the leading `v`. + +### 中文 + +- 修复更新器重启后的健康校验:镜像里的 `/health` 回报的是发布 tag(`v0.7.52`),控制台送来的是不带 `v` 的版本号(`0.7.52`),原来按字符串严格比较会让每次部署都判定失败并触发一次无谓的回滚。现在按语义版本比较,忽略前缀 `v`。 diff --git a/changelog/unreleased/upstream-release-defaults.md b/changelog/unreleased/upstream-release-defaults.md new file mode 100644 index 00000000..5bb9c0ea --- /dev/null +++ b/changelog/unreleased/upstream-release-defaults.md @@ -0,0 +1,7 @@ +### English + +- Release defaults follow upstream again: the console checks `caigee-cmd/cli2api`, `deploy/docker-compose.yml` pulls `ghcr.io/caigee-cmd/cli2api:latest`, and the host updater and both installers use the same repository unless `UPDATE_GITHUB_REPO`, `CLI2API_IMAGE_REPOSITORY`, or `CLI2API_GITHUB_REPOSITORY` say otherwise. A fork that publishes its own builds sets those variables instead of changing the defaults, so a standard deployment keeps pulling upstream images and following upstream releases. + +### 中文 + +- 发布源默认值恢复为上游:控制台检查 `caigee-cmd/cli2api`,`deploy/docker-compose.yml` 拉取 `ghcr.io/caigee-cmd/cli2api:latest`,宿主机 updater 与两个安装脚本也默认使用同一仓库;需要跟随其它仓库时用 `UPDATE_GITHUB_REPO`、`CLI2API_IMAGE_REPOSITORY`、`CLI2API_GITHUB_REPOSITORY` 覆盖。自行发布镜像的 fork 应设置这些变量,而不是修改默认值,这样标准部署仍然拉取上游镜像、跟踪上游发布。 diff --git a/cmd/updater/main.go b/cmd/updater/main.go index b17259ca..6bfa989b 100644 --- a/cmd/updater/main.go +++ b/cmd/updater/main.go @@ -24,6 +24,7 @@ func main() { var serviceName string var containerName string var imageRepository string + var githubRepo string var healthURL string var healthTimeout time.Duration flag.StringVar(&socketPath, "socket", "/run/cli2api-updater/updater.sock", "Unix socket path") @@ -36,6 +37,7 @@ func main() { flag.StringVar(&serviceName, "service", "qoder-api-proxy", "Compose service name") flag.StringVar(&containerName, "container", "qoder-api-proxy", "container name") flag.StringVar(&imageRepository, "image-repository", "ghcr.io/caigee-cmd/cli2api", "allowed image repository") + flag.StringVar(&githubRepo, "github-repo", "caigee-cmd/cli2api", "GitHub owner/repo whose releases carry updater binaries") flag.StringVar(&healthURL, "health-url", "http://127.0.0.1:3010/health", "service health URL") flag.DurationVar(&healthTimeout, "health-timeout", 120*time.Second, "versioned health-check timeout") flag.Parse() @@ -55,6 +57,7 @@ func main() { ComposeFile: composeFile, EnvFile: envFile, ServiceName: serviceName, ContainerName: containerName, ImageRepository: imageRepository, HealthURL: healthURL, HealthTimeout: healthTimeout, HostBinaryPath: hostBinary, + GitHubRepo: strings.TrimSpace(githubRepo), GitHubToken: strings.TrimSpace(os.Getenv("UPDATE_GITHUB_TOKEN")), }) service := updater.NewService(updater.Config{ diff --git a/deploy/.env.example b/deploy/.env.example index 1614ecda..620d3b10 100644 --- a/deploy/.env.example +++ b/deploy/.env.example @@ -6,6 +6,9 @@ # Optional GitHub token for release checks. # UPDATE_GITHUB_TOKEN= +# Release repository for update checks (owner/repo). Defaults to caigee-cmd/cli2api; +# a fork sets it to its own owner/repo (for example guyu233/cli2api) instead. +# UPDATE_GITHUB_REPO= # macOS and Windows installers write the loopback updater endpoint and token here. # UPDATE_AGENT_URL= # UPDATE_AGENT_TOKEN= diff --git a/deploy/README.md b/deploy/README.md index 0e129793..b6501276 100644 --- a/deploy/README.md +++ b/deploy/README.md @@ -166,6 +166,7 @@ console; environment variables cannot replace it. | `QODERCLI_JS` | image default | Pinned Qoder Global CLI bundle | | `QODERCNCLI_JS` | image default | Pinned Qoder CN CLI bundle | | `UPDATE_GITHUB_TOKEN` | empty | Optional GitHub token for release checks | +| `UPDATE_GITHUB_REPO` | `caigee-cmd/cli2api` | Release repository (`owner/repo`) whose GitHub releases the console follows; set it to `caigee-cmd/cli2api` to follow upstream instead | | `UPDATE_AGENT_URL` | empty | Docker Desktop host updater URL, written by the installer | | `UPDATE_AGENT_TOKEN` | empty | Docker Desktop updater token, written by the installer | | `CLI2API_UPDATER_SOCKET_DIR` | platform-specific | Host directory mounted read-only for the Linux updater socket | @@ -219,8 +220,21 @@ Start `qoder-api-proxy` once before installing the optional host updater. | Windows x86-64 | Docker Desktop Linux containers | `cli2api-updater_windows_amd64.exe` | | Windows ARM64 | Docker Desktop Linux containers | `cli2api-updater_windows_arm64.exe` | -Installers prefer checksum-verified release binaries and fall back to the -running container's binary or a local Go build when needed. +Installers take the updater binary from the running container first, so the +installed updater always matches the deployed image and no release asset has to +be downloaded. They fall back to checksum-verified release binaries or a local +Go build when the container is unreachable. Both installers default to +`ghcr.io/caigee-cmd/cli2api` and `caigee-cmd/cli2api`; override them with +`CLI2API_IMAGE_REPOSITORY` and `CLI2API_GITHUB_REPOSITORY` when the deployment +follows another repository. + +On Linux, `./scripts/start.sh` runs the installer automatically when no +`cli2api-updater.service` exists yet (set `CLI2API_SKIP_UPDATER_INSTALL=1` to +skip it). The console's **Download update** then pulls the target image on the +host, recreates the container, health-checks the new version, and rolls back to +the previous image and SQLite backup if that check fails. The updater binary is +copied out of the pulled image, so an update never depends on GitHub asset +downloads. macOS + Docker Desktop: diff --git a/deploy/docker-compose.yml b/deploy/docker-compose.yml index 9e7e91d9..08ccd401 100644 --- a/deploy/docker-compose.yml +++ b/deploy/docker-compose.yml @@ -17,6 +17,7 @@ services: UPDATE_AGENT_URL: "${UPDATE_AGENT_URL:-}" UPDATE_AGENT_TOKEN: "${UPDATE_AGENT_TOKEN:-}" UPDATE_GITHUB_TOKEN: "${UPDATE_GITHUB_TOKEN:-}" + UPDATE_GITHUB_REPO: "${UPDATE_GITHUB_REPO:-}" # Request-log retention: default 7 days / 20k rows. Raise both when the # usage/cost panel needs a longer history (~0.7 KB/row; ~150 MB at 90d @ 1.5k rows/day). CLI2API_LOG_RETENTION_DAYS: "${CLI2API_LOG_RETENTION_DAYS:-7}" diff --git a/deploy/install-updater.ps1 b/deploy/install-updater.ps1 index a341e202..a674aff1 100644 --- a/deploy/install-updater.ps1 +++ b/deploy/install-updater.ps1 @@ -20,9 +20,9 @@ $SocketPlaceholder = Join-Path $InstallDir "socket-placeholder" $TaskName = "CLI2API Updater" $ContainerName = "qoder-api-proxy" $ServiceName = "qoder-api-proxy" -$ImageRepository = "ghcr.io/caigee-cmd/cli2api" +$ImageRepository = if ($env:CLI2API_IMAGE_REPOSITORY) { $env:CLI2API_IMAGE_REPOSITORY } else { "ghcr.io/caigee-cmd/cli2api" } $ListenAddress = "127.0.0.1:3011" -$GitHubRepository = "caigee-cmd/cli2api" +$GitHubRepository = if ($env:CLI2API_GITHUB_REPOSITORY) { $env:CLI2API_GITHUB_REPOSITORY } else { "caigee-cmd/cli2api" } function Require-Command { param([string]$Name) @@ -273,6 +273,7 @@ Set-StrictMode -Version Latest "--service", "$ServiceName", "--container", "$ContainerName", "--image-repository", "$ImageRepository", + "--github-repo", "$GitHubRepository", "--health-url", "http://127.0.0.1:3010/health" ) & "$Binary" `$UpdaterArguments 1>> "$StdoutLog" 2>> "$StderrLog" diff --git a/deploy/install-updater.sh b/deploy/install-updater.sh index e8ce8721..52f2db6d 100755 --- a/deploy/install-updater.sh +++ b/deploy/install-updater.sh @@ -6,8 +6,8 @@ ENV_FILE="${ROOT_DIR}/deploy/.env" COMPOSE_FILE="${ROOT_DIR}/deploy/docker-compose.yml" CONTAINER_NAME="qoder-api-proxy" SERVICE_NAME="qoder-api-proxy" -IMAGE_REPOSITORY="ghcr.io/caigee-cmd/cli2api" -GITHUB_REPOSITORY="caigee-cmd/cli2api" +IMAGE_REPOSITORY="${CLI2API_IMAGE_REPOSITORY:-ghcr.io/caigee-cmd/cli2api}" +GITHUB_REPOSITORY="${CLI2API_GITHUB_REPOSITORY:-caigee-cmd/cli2api}" require_commands() { for command in "$@"; do @@ -172,27 +172,30 @@ install_linux() { local temp_dir status temp_dir="$(mktemp -d)" - if install_released_updater /usr/local/bin/cli2api-updater linux; then - : - elif docker cp "${CONTAINER_NAME}:/app/cli2api-updater" "${temp_dir}/cli2api-updater" >/dev/null 2>&1; then + # The updater inside the running container always matches the deployed image + # and needs no network round trip, so prefer it over the GitHub asset. + if docker cp "${CONTAINER_NAME}:/app/cli2api-updater" "${temp_dir}/cli2api-updater" >/dev/null 2>&1 && [[ -s "${temp_dir}/cli2api-updater" ]]; then + install -m 0755 "${temp_dir}/cli2api-updater" /usr/local/bin/cli2api-updater + echo "Installed updater from the running container." + else + install_released_updater /usr/local/bin/cli2api-updater linux + status=$? + if [[ "${status}" -ne 0 && "${status}" -ne 1 ]]; then + rm -rf "${temp_dir}" + exit "${status}" + fi + if [[ "${status}" -eq 1 ]]; then + if ! command -v go >/dev/null 2>&1; then + rm -rf "${temp_dir}" + echo "No updater binary is available. Install Go 1.25.6+ to build it locally." >&2 + exit 1 + fi + echo "Released updater asset unavailable; building from the checked-out source." + (cd "${ROOT_DIR}" && go build -trimpath -o "${temp_dir}/cli2api-updater" ./cmd/updater) || { rm -rf "${temp_dir}"; exit 1; } install -m 0755 "${temp_dir}/cli2api-updater" /usr/local/bin/cli2api-updater - echo "Installed updater from the running container." - else - status=$? - if [[ "${status}" -ne 1 ]]; then - rm -rf "${temp_dir}" - exit "${status}" - fi - if ! command -v go >/dev/null 2>&1; then - rm -rf "${temp_dir}" - echo "No updater binary is available. Install Go 1.25.6+ to build it locally." >&2 - exit 1 - fi - echo "Released updater asset unavailable; building from the checked-out source." - (cd "${ROOT_DIR}" && go build -trimpath -o "${temp_dir}/cli2api-updater" ./cmd/updater) - install -m 0755 "${temp_dir}/cli2api-updater" /usr/local/bin/cli2api-updater - fi - rm -rf "${temp_dir}" + fi + fi + rm -rf "${temp_dir}" install -d -m 0750 /run/cli2api-updater install -d -m 0700 /var/lib/cli2api-updater @@ -215,6 +218,7 @@ ExecStart=/usr/local/bin/cli2api-updater \\ --service ${SERVICE_NAME} \\ --container ${CONTAINER_NAME} \\ --image-repository ${IMAGE_REPOSITORY} \\ + --github-repo ${GITHUB_REPOSITORY} \\ --health-url http://127.0.0.1:3010/health Restart=always RestartSec=3 @@ -295,6 +299,7 @@ install_macos() { printf ' %q' --service "${SERVICE_NAME}" printf ' %q' --container "${CONTAINER_NAME}" printf ' %q' --image-repository "${IMAGE_REPOSITORY}" + printf ' %q' --github-repo "${GITHUB_REPOSITORY}" printf ' %q' --health-url http://127.0.0.1:3010/health printf '\n' } > "${wrapper}" diff --git a/frontend/src/api/events.ts b/frontend/src/api/events.ts new file mode 100644 index 00000000..293eacdc --- /dev/null +++ b/frontend/src/api/events.ts @@ -0,0 +1,179 @@ +import { ApiError } from './client' +import { readStoredApiKey } from '@/hooks/useApiKey' +import type { AccountQuota } from './types' + +/** Event types published by the runtime event bus (`internal/events`). */ +export type ServerEventType = 'account' | 'accounts' | 'quota' | 'checkin' | 'refresh' | 'bulk' + +/** Real per-account payloads carried by each event type. */ +export type AccountStateEvent = { + account_id?: string + runtime_state?: string + ready?: boolean + cooldown_until?: string + last_error?: string + last_kind?: string +} + +export type QuotaStateEvent = { + account_id?: string + quota?: AccountQuota +} + +export type CheckinStateEvent = { + account_id?: string + status?: string + message?: string + reward_credits?: number + at?: string +} + +export type RefreshStateEvent = { + account_id?: string + provider?: string + region?: string + ok?: boolean + status?: string + code?: string + kind?: string + message?: string + http_status?: number + quota?: AccountQuota +} + +export type BulkEventData = { + op_id?: string + kind?: 'checkin' | 'refresh' + phase?: 'start' | 'account' | 'done' + total?: number + done?: number + account_id?: string + result?: Record +} + +/** One SSE frame as delivered by GET /api/events. */ +export type ServerEvent = { + seq: number + type: ServerEventType + time: string + account_id?: string + op_id?: string + data?: AccountStateEvent | QuotaStateEvent | CheckinStateEvent | RefreshStateEvent | BulkEventData +} + +export type EventStreamStatus = 'connecting' | 'live' | 'offline' + +type StreamOptions = { + /** Last seen seq; the server replays newer ring events before streaming live. */ + lastSeq: number + signal: AbortSignal + onEvent: (event: ServerEvent) => void + onOpen?: () => void +} + +function splitFrames(buffer: string): { frames: string[]; rest: string } { + const frames: string[] = [] + let rest = buffer.replace(/\r\n/g, '\n') + let index = rest.indexOf('\n\n') + while (index !== -1) { + frames.push(rest.slice(0, index)) + rest = rest.slice(index + 2) + index = rest.indexOf('\n\n') + } + return { frames, rest } +} + +function parseFrame(frame: string): { id?: number; event?: string; data?: string } { + const out: { id?: number; event?: string; data?: string } = {} + const dataLines: string[] = [] + for (const line of frame.split('\n')) { + if (!line || line.startsWith(':')) continue + const colon = line.indexOf(':') + const field = colon === -1 ? line : line.slice(0, colon) + const rawValue = colon === -1 ? '' : line.slice(colon + 1) + const value = rawValue.startsWith(' ') ? rawValue.slice(1) : rawValue + if (field === 'id') { + const id = Number(value) + if (Number.isFinite(id)) out.id = id + } else if (field === 'event') { + out.event = value + } else if (field === 'data') { + dataLines.push(value) + } + } + if (dataLines.length) out.data = dataLines.join('\n') + return out +} + +/** + * Opens one console event stream and resolves when it ends (server close, + * network failure, or abort). The console key travels in the Authorization + * header — EventSource cannot do that, so the stream is read with fetch. + */ +export async function openEventStream(opts: StreamOptions): Promise { + const headers: Record = { Accept: 'text/event-stream' } + const key = readStoredApiKey().trim() + if (key) headers.Authorization = `Bearer ${key}` + if (opts.lastSeq > 0) headers['Last-Event-ID'] = String(opts.lastSeq) + const url = opts.lastSeq > 0 ? `/api/events?last_seq=${opts.lastSeq}` : '/api/events' + + let res: Response + try { + res = await fetch(url, { headers, signal: opts.signal, cache: 'no-store' }) + } catch (error) { + if (opts.signal.aborted) return + throw error + } + if (!res.ok) { + let message = `${res.status} ${res.statusText}` + try { + const body = await res.text() + try { + const parsed = JSON.parse(body) + message = parsed?.error?.message || parsed?.message || message + } catch { + if (body) message = body.slice(0, 200) + } + } catch { + /* keep status text */ + } + throw new ApiError(message, res.status) + } + + opts.onOpen?.() + const reader = res.body?.getReader() + if (!reader) throw new ApiError('event stream unavailable', res.status) + + const decoder = new TextDecoder() + let buffer = '' + try { + while (true) { + const { done, value } = await reader.read() + if (done) break + buffer += decoder.decode(value, { stream: true }) + const split = splitFrames(buffer) + buffer = split.rest + for (const frame of split.frames) { + const parsed = parseFrame(frame) + // Comments (heartbeats) and bare `id:` frames carry no state change. + if (!parsed.data) continue + let payload: ServerEvent + try { + payload = JSON.parse(parsed.data) as ServerEvent + } catch { + continue + } + if (typeof payload?.type !== 'string') continue + if (!Number.isFinite(payload.seq) && parsed.id != null) payload.seq = parsed.id + opts.onEvent(payload) + } + if (opts.signal.aborted) break + } + } finally { + try { + await reader.cancel() + } catch { + /* stream already closed */ + } + } +} diff --git a/frontend/src/api/modelPools.ts b/frontend/src/api/modelPools.ts index e01916f1..c289ebbb 100644 --- a/frontend/src/api/modelPools.ts +++ b/frontend/src/api/modelPools.ts @@ -17,6 +17,10 @@ export type AggregationRecord = { strategy: string allow_fallbacks: boolean max_attempts: number + context_length?: number + max_output_tokens?: number + reasoning_options?: string[] + reasoning_effort?: string members: AggregationMember[] created_at: string updated_at: string @@ -29,6 +33,10 @@ export type AggregationInput = { strategy: string allow_fallbacks?: boolean max_attempts: number + context_length?: number + max_output_tokens?: number + reasoning_options?: string[] + reasoning_effort?: string members: AggregationMember[] } diff --git a/frontend/src/api/overview.ts b/frontend/src/api/overview.ts index dac73d7b..44baeca0 100644 --- a/frontend/src/api/overview.ts +++ b/frontend/src/api/overview.ts @@ -1,6 +1,6 @@ import { api, ApiError } from './client' import { readStoredApiKey } from '@/hooks/useApiKey' -import type { CheckinRecord, Overview } from './types' +import type { AccountQuota, CheckinRecord, Overview } from './types' export function fetchOverviewSummary(keyOverride?: string) { return api('/api/overview/summary', {}, keyOverride) @@ -138,10 +138,6 @@ export function updateModelContext(modelKey: string, contextLength: number) { }) } -export function updateTraeMaxMode(modelKey: string, maxMode: boolean) { - return updateProviderMaxMode('trae', modelKey, maxMode) -} - export function updateProviderMaxMode(provider: string, modelKey: string, maxMode: boolean, contextWindow?: number | null) { return api<{ model: string @@ -470,7 +466,13 @@ export type ProviderDescriptor = { pat_login: boolean import_export: boolean } - regions: Array<{ id: string; label: string; checkin?: { timezone: string } }> + regions: Array<{ + id: string + label: string + checkin?: { + timezone: string + } + }> default_region: string } @@ -525,6 +527,13 @@ export type CheckinAllResult = { region: string status: string message?: string + /** Real upstream grant amount; absent when the provider reported none. */ + reward_credits?: number + /** Verbatim upstream error classification when the check-in failed. */ + code?: string + kind?: string + http_status?: number + quota_refreshed?: boolean } export function checkinAll(input?: { force?: boolean; include_disabled?: boolean }) { @@ -534,6 +543,31 @@ export function checkinAll(input?: { force?: boolean; include_disabled?: boolean }) } +export type AccountRefreshResult = { + account_id: string + provider?: string + region?: string + ok: boolean + status?: string + code?: string + kind?: string + message?: string + http_status?: number + quota?: AccountQuota +} + +/** + * One-shot refresh for every account, fully concurrent on the backend — no + * client batching or queueing. Each row carries the real probe outcome and the + * verbatim upstream error, so a partial failure stays visible per account. + */ +export function refreshAllAccounts(input?: { quota?: boolean; include_disabled?: boolean }) { + return api<{ object?: string; data?: AccountRefreshResult[] }>('/api/accounts/refresh-all', { + method: 'POST', + body: JSON.stringify(input || {}), + }) +} + export function fetchCheckinRecords(accountId: string) { return api<{ object?: string; data?: CheckinRecord[] }>(`/api/accounts/${encodeURIComponent(accountId)}/checkins`) } diff --git a/frontend/src/api/system.ts b/frontend/src/api/system.ts index 886ff538..d7d6fbed 100644 --- a/frontend/src/api/system.ts +++ b/frontend/src/api/system.ts @@ -57,6 +57,7 @@ export type SystemUpdateInfo = { } agent: UpdateAgentStatus update?: UpdatePreparationStatus + source?: string } export type SystemSettings = { diff --git a/frontend/src/api/types.ts b/frontend/src/api/types.ts index 189db8ea..342ea765 100644 --- a/frontend/src/api/types.ts +++ b/frontend/src/api/types.ts @@ -184,6 +184,9 @@ export type Overview = { last_checkin_synced_at?: string checkin_auto_time?: string quota?: AccountQuota + /** Local force-ready marker is active: the account enters the pool without + * a real probe. Quota below still comes from the real stored snapshot. */ + force_ready_override?: boolean created_at?: string updated_at?: string }> diff --git a/frontend/src/components/account/AccountCard.tsx b/frontend/src/components/account/AccountCard.tsx index 8f571f93..7c8e6262 100644 --- a/frontend/src/components/account/AccountCard.tsx +++ b/frontend/src/components/account/AccountCard.tsx @@ -1,7 +1,7 @@ import { CopyIcon } from '@/components/motion/CopyIcon' import { useEffect, useLayoutEffect, useRef, useState } from 'react' import { useSharedClock } from '@/hooks/useSharedClock' -import { Button, Card, Chip, Dropdown, Input, Label, TextArea, TextField, Tooltip } from '@heroui/react' +import { Button, Card, Checkbox, Chip, Dropdown, Input, Label, TextArea, TextField, Tooltip } from '@heroui/react' import { ArrowClockwise, ArrowSquareOut, @@ -59,7 +59,7 @@ function formatCheckinMoment(value: string, timezone: string) { // `kind` selects the glyph/colour; `message` is the raw upstream error text // (only present for failures) and may be truncated in the UI with a copy button. export type CheckinFeedback = { - kind: 'success' | 'already' | 'skipped' | 'error' + kind: 'success' | 'already' | 'skipped' | 'error' | 'unknown' message?: string } @@ -90,6 +90,11 @@ type Props = { onEdit: () => void onToggleAuthPanel: () => void onViewModels: () => void + // Selection mode used by the bulk re-login flow. The checkbox stays out of + // the normal card layout so single-account work is unchanged. + selectable?: boolean + selected?: boolean + onSelectToggle?: () => void } function stateCopyFor(state: ReturnType, cooldown: string, t: Translate) { @@ -133,6 +138,9 @@ export function AccountCard({ onEdit, onToggleAuthPanel, onViewModels, + selectable = false, + selected = false, + onSelectToggle, }: Props) { const chipRef = useRef(null) const authRef = useRef(null) @@ -249,7 +257,17 @@ export function AccountCard({ >
-
+ {selectable ? ( + // HeroUI v3 keeps the clickable control in Checkbox.Content: a + // Checkbox without it renders the indicator as a plain span and + // nothing responds to clicks. + onSelectToggle?.()} className="shrink-0"> + + + + + ) : null} +
@@ -303,6 +321,14 @@ export function AccountCard({ {stateCopy} )} + {account.force_ready_override ? ( + + + {t('forceReadyBadge')} + + {t('forceReadyHint')} + + ) : null} {modelCooldowns.length && state !== 'cooling' ? ( @@ -377,6 +403,8 @@ export function AccountCard({ {t('checkinRecordAlready')} ) : feedback.kind === 'skipped' ? ( {t('checkinRecordSkipped')} + ) : feedback.kind === 'unknown' ? ( + {t('checkinStatusUnknown')} ) : ( {t('checkinRecordFailed')} )} diff --git a/frontend/src/components/account/BatchReloginModal.tsx b/frontend/src/components/account/BatchReloginModal.tsx new file mode 100644 index 00000000..da774218 --- /dev/null +++ b/frontend/src/components/account/BatchReloginModal.tsx @@ -0,0 +1,183 @@ +import { useEffect, useRef, useState } from 'react' +import { Button, Chip, Modal } from '@heroui/react' +import { fetchLoginStatus, startDeviceLogin } from '@/api/overview' +import type { AccountRow } from '@/lib/account' +import { ProviderMark } from '@/components/ProviderMark' + +type Translate = (key: string, vars?: Record) => string + +export type BatchLoginPhase = 'pending' | 'starting' | 'waiting' | 'ok' | 'error' | 'skipped' | 'stopped' + +export type BatchLoginRow = { + account: AccountRow + phase: BatchLoginPhase + message: string + authUrl: string +} + +const POLL_INTERVAL_MS = 2000 +const ACCOUNT_TIMEOUT_MS = 5 * 60 * 1000 + +/** + * Re-login several accounts one after another. Each account gets its own + * authorization page: the console starts the flow, the operator authorizes + * (an already signed-in browser does it silently), and polling moves on to + * the next account. Accounts are never started in parallel on purpose — several + * WorkBuddy accounts often share one SSO session, and parallel flows would hand + * the same fresh token to different account records. + */ +export function BatchReloginModal({ + isOpen, + accounts, + t, + onClose, + onFinished, +}: { + isOpen: boolean + accounts: AccountRow[] + t: Translate + onClose: () => void + onFinished: () => void +}) { + const [rows, setRows] = useState([]) + const cancelled = useRef(false) + const running = useRef(false) + + useEffect(() => { + if (!isOpen) { + cancelled.current = true + running.current = false + return + } + cancelled.current = false + setRows(accounts.map((account) => ({ account, phase: 'pending', message: '', authUrl: '' }))) + if (running.current) return + running.current = true + void run(accounts) + return () => { + cancelled.current = true + running.current = false + } + // accounts is the snapshot captured by the page when the dialog opened. + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [isOpen]) + + function patch(id: string, next: Partial) { + setRows((current) => current.map((row) => (row.account.id === id ? { ...row, ...next } : row))) + } + + async function run(list: AccountRow[]) { + for (const account of list) { + if (cancelled.current) { + patch(account.id, { phase: 'stopped', message: t('reloginStopped') }) + continue + } + patch(account.id, { phase: 'starting', message: t('wizardStartingSession') }) + let authUrl = '' + try { + const output = await startDeviceLogin(account.id) + authUrl = output.authUrl || '' + patch(account.id, { authUrl, phase: 'waiting', message: output.message || t('reloginWaitingAuth') }) + } catch (error) { + patch(account.id, { phase: 'error', message: error instanceof Error ? error.message : String(error) }) + continue + } + const deadline = Date.now() + ACCOUNT_TIMEOUT_MS + let settled = false + while (!settled) { + if (cancelled.current) { + patch(account.id, { phase: 'stopped', message: t('reloginStopped') }) + break + } + if (Date.now() > deadline) { + patch(account.id, { phase: 'error', message: t('reloginTimeout') }) + break + } + await new Promise((resolve) => window.setTimeout(resolve, POLL_INTERVAL_MS)) + try { + const status = await fetchLoginStatus(account.id) + const login = status.login || {} + const message = login.message || '' + if (login.status === 'ok') { + patch(account.id, { phase: 'ok', message: message || t('reloginDone') }) + settled = true + } else if (login.status === 'error') { + patch(account.id, { phase: 'error', message: message || t('reloginFailed') }) + settled = true + } else if (message) { + patch(account.id, { message }) + } + } catch (error) { + patch(account.id, { message: error instanceof Error ? error.message : String(error) }) + } + } + } + running.current = false + if (!cancelled.current) onFinished() + } + + function stop() { + cancelled.current = true + running.current = false + onClose() + } + + const finished = rows.filter((row) => row.phase === 'ok' || row.phase === 'error' || row.phase === 'stopped').length + + return ( + { if (!next) stop() }}> + + + + + {t('reloginTitle')} +

{t('reloginHint')}

+
+ +
+ {t('reloginProgress', { done: finished, total: rows.length })} +
+ {rows.map((row) => ( +
+
+ + {row.account.name || row.account.id} + {t(phaseKey(row.phase))} + {row.authUrl ? ( + + ) : null} +
+ {row.message ?

{row.message}

: null} + {row.authUrl ?

{row.authUrl}

: null} +
+ ))} +
+ + + +
+
+
+
+ ) +} + +function phaseKey(phase: BatchLoginPhase) { + switch (phase) { + case 'starting': return 'reloginPhaseStarting' + case 'waiting': return 'reloginPhaseWaiting' + case 'ok': return 'reloginPhaseDone' + case 'error': return 'reloginPhaseFailed' + case 'stopped': return 'reloginPhaseStopped' + default: return 'reloginPhasePending' + } +} + +function phaseColor(phase: BatchLoginPhase) { + if (phase === 'ok') return 'success' + if (phase === 'error') return 'danger' + if (phase === 'waiting' || phase === 'starting') return 'warning' + return 'default' +} diff --git a/frontend/src/components/account/QuotaMeter.tsx b/frontend/src/components/account/QuotaMeter.tsx index 550f6d40..1ae0ae0b 100644 --- a/frontend/src/components/account/QuotaMeter.tsx +++ b/frontend/src/components/account/QuotaMeter.tsx @@ -27,6 +27,19 @@ type Props = { provider?: string } +/** + * Honest snapshot age: the meter shows the real stored reading, so tell the + * operator how old it is instead of implying it is live. Anything ≥5 minutes + * reads as stale (the background sweep refreshes every 60s by default). + */ +function quotaAgeLabel(fetchedAt: string | undefined, t: Translate) { + if (!fetchedAt) return '' + const at = Date.parse(fetchedAt) + if (!Number.isFinite(at)) return '' + const minutes = Math.max(0, Math.round((Date.now() - at) / 60_000)) + return minutes >= 5 ? t('quotaStale', { n: minutes }) : t('quotaUsedAt', { n: minutes }) +} + function extraQuotaLines(quota: AccountQuota, remainingLabel: string, addOnLabel: string, resourcePackageLabel: string, t: Translate, provider?: string) { const addOn = quota.has_add_on && quota.add_on_available !== false ? `${addOnLabel} ${formatQuotaAmount(quota.add_on_used)} / ${formatQuotaAmount(quota.add_on_total)} ${quota.add_on_unit || 'credits'}` @@ -109,6 +122,7 @@ export function QuotaMeter({ quota, t, label, usedLabel, remainingLabel, addOnLa const color = tone === 'danger' ? 'danger' : tone === 'warn' ? 'warning' : 'success' const rootRef = useRef(null) useFillReveal(rootRef) + const age = quotaAgeLabel(quota.fetched_at, t) const valueLabel = `${usedLabel} ${used} ${unit} · ${remainingLabel} ${remaining} ${unit}${extra.length ? ` · ${extra.join(' · ')}` : ''}` if (windows.length > 0) { @@ -129,6 +143,7 @@ export function QuotaMeter({ quota, t, label, usedLabel, remainingLabel, addOnLa />
))} + {age ?
{age}
: null}
) } @@ -159,6 +174,7 @@ export function QuotaMeter({ quota, t, label, usedLabel, remainingLabel, addOnLa + {age ?
{age}
: null}
@@ -166,6 +182,7 @@ export function QuotaMeter({ quota, t, label, usedLabel, remainingLabel, addOnLa
{usedLabel} {used} {unit}
{remainingLabel} {remaining} {unit}
{extra.map((line) =>
{line}
)} + {age ?
{age}
: null}
diff --git a/frontend/src/components/checkin/CheckinDefaults.tsx b/frontend/src/components/checkin/CheckinDefaults.tsx index dd8b37a7..de49a685 100644 --- a/frontend/src/components/checkin/CheckinDefaults.tsx +++ b/frontend/src/components/checkin/CheckinDefaults.tsx @@ -8,6 +8,8 @@ import { PageAlert } from '@/components/ui/PageAlert' import { SkeletonBlock } from '@/components/ui/PageSkeletons' import { useI18n } from '@/hooks/useI18n' +const DEFAULT_CHECKIN_TIME = '09:00' + export function CheckinDefaults({ settings, onSaved }: { settings: SystemSettings | null; onSaved: (settings: SystemSettings) => void }) { const { t } = useI18n() const navigate = useNavigate() @@ -25,7 +27,16 @@ export function CheckinDefaults({ settings, onSaved }: { settings: SystemSetting }, []) async function save(providerID: string, value: string) { - if (!settings || value === settings.checkin_times[providerID]) return + if (!settings) return + const current = settings.checkin_times[providerID] ?? DEFAULT_CHECKIN_TIME + if (!value || value === current) { + setDrafts((draftsNow) => { + const next = { ...draftsNow } + delete next[providerID] + return next + }) + return + } setBusy(true) setError('') try { @@ -33,8 +44,8 @@ export function CheckinDefaults({ settings, onSaved }: { settings: SystemSetting } catch (err) { setError(err instanceof Error ? err.message : String(err)) } finally { - setDrafts((current) => { - const next = { ...current } + setDrafts((draftsNow) => { + const next = { ...draftsNow } delete next[providerID] return next }) @@ -52,8 +63,11 @@ export function CheckinDefaults({ settings, onSaved }: { settings: SystemSetting {error ? : null} {!settings || !providers ? : providers.map((provider) => ( region.checkin).map((region) => `${region.label} · ${region.checkin?.timezone === 'Local' ? settings.timezone : region.checkin?.timezone}`).join(' / ')}> - region.checkin).map((region) => { + const zone = region.checkin?.timezone === 'Local' ? settings.timezone : (region.checkin?.timezone || '') + return `${region.label} · ${zone}` + }).join(' / ')}> + setDrafts((current) => ({ ...current, [provider.id]: event.target.value }))} onBlur={(event) => void save(provider.id, event.target.value)} /> diff --git a/frontend/src/components/overview/InflightLiveCard.tsx b/frontend/src/components/overview/InflightLiveCard.tsx index 1f9083c9..2b2fcf54 100644 --- a/frontend/src/components/overview/InflightLiveCard.tsx +++ b/frontend/src/components/overview/InflightLiveCard.tsx @@ -8,42 +8,20 @@ import { MotionPathPlugin } from 'gsap/MotionPathPlugin' import { applyLiveProjection, clampSlotConcurrency, - cloneMockInflight, - getIdleInflightSnapshot, - getMockInflightSnapshot, - isIdleInflightSnapshot, - summarizeMockInflight, - tickMockInflight, - type MockAccountSlot, - type MockInflightJob, - type MockInflightSnapshot, - type MockJobKind, -} from '@/lib/mockInflight' + cloneInflight, + emptyInflightSnapshot, + summarizeInflight, + type LiveAccountSlot, + type LiveInflightJob, + type LiveInflightSnapshot, + type LiveJobKind, +} from '@/lib/liveInflight' import { CountUp } from '@/components/overview/CountUp' import { ProviderMark } from '@/components/ProviderMark' -import { CompactSwitch } from '@/components/ui/CompactSwitch' import { ease, gsap, motionDuration, prefersReducedMotion } from '@/lib/motion' const InflightDepthChart = lazy(() => import('@/components/overview/InflightDepthChart').then((mod) => ({ default: mod.InflightDepthChart }))) -const MOCK_DEMO_STORAGE_KEY = 'cli2api_inflight_mock_demo' - -function readMockDemoPref(): boolean { - try { - return localStorage.getItem(MOCK_DEMO_STORAGE_KEY) === '1' - } catch { - return false - } -} - -function writeMockDemoPref(on: boolean) { - try { - localStorage.setItem(MOCK_DEMO_STORAGE_KEY, on ? '1' : '0') - } catch { - /* ignore quota / private mode */ - } -} - gsap.registerPlugin(CustomEase, MotionPathPlugin) const queueEase = CustomEase.get('inflightQueue') || @@ -92,7 +70,7 @@ function formatElapsed(ms: number) { } /** Busy-slot elapsed: prefer wall-clock startedAtMs + live clock; else mock elapsedMs. */ -function jobElapsedMs(job: MockInflightJob | undefined, clockMs: number): number { +function jobElapsedMs(job: LiveInflightJob | undefined, clockMs: number): number { if (!job) return 0 if (job.startedAtMs != null) return Math.max(0, clockMs - job.startedAtMs) return Math.max(0, job.elapsedMs) @@ -102,7 +80,7 @@ function jobElapsedMs(job: MockInflightJob | undefined, clockMs: number): number * Kind identity from public AffectUI demo hierarchy (llm/tool/agent washes), * remapped to project chart / foreground tokens — never a second brand palette. */ -function kindDot(kind: MockJobKind): string { +function kindDot(kind: LiveJobKind): string { switch (kind) { case 'chat': return 'bg-[color-mix(in_oklab,var(--chart-1)_55%,var(--surface))]' @@ -115,7 +93,7 @@ function kindDot(kind: MockJobKind): string { } } -function kindIcon(kind: MockJobKind) { +function kindIcon(kind: LiveJobKind) { const glyph = kind === 'embed' ? : kind === 'tools' @@ -135,7 +113,7 @@ function kindIcon(kind: MockJobKind) { ) } -function kindPill(kind: MockJobKind): string { +function kindPill(kind: LiveJobKind): string { switch (kind) { case 'chat': return 'border border-[color-mix(in_oklab,var(--chart-1)_16%,transparent)] bg-[color-mix(in_oklab,var(--chart-1)_8%,var(--surface))] text-foreground/75' @@ -155,8 +133,8 @@ function SlotBar({ idleLabel, landedCellIds, }: { - slot: MockAccountSlot - jobById: Map + slot: LiveAccountSlot + jobById: Map clockMs: number idleLabel: string /** Cell ids whose inbound fly has landed (or no-fly grace / auto-land). */ @@ -264,10 +242,10 @@ function SlotBar({ /** * Overview summary: Agent Queue feel over cli2api pool/inflight concepts. - * Default collapsed — no /api/live consume and no mock loop until expanded + * Default collapsed — no /api/live consume until expanded * (toggle or LiveStrip「当前并发」). When open, project live workers / - * sticky (in-progress only — no rate-limit remaining chips/bands); mock tick - * only when 示意/demo is on (default off). Session Done/Failed reset on each expand. + * sticky (in-progress only — no rate-limit remaining chips/bands). Only real + * /api/live data is shown; each expand starts a fresh session. * Motion timings from public AffectUI Agent Queue demo (mapped to project * tokens). Link targets `/live` later — no Pause/Cancel/stepper. */ @@ -275,25 +253,22 @@ export function InflightLiveCard({ t, snapshot, live = null, + liveError = null, expanded: expandedProp, onExpandedChange, defaultExpanded = false, - forceMockDemo = false, - mockPace = 1, bare = false, }: { t: T - snapshot?: MockInflightSnapshot + snapshot?: LiveInflightSnapshot /** Parent /api/live snapshot — only passed while expanded so the card does not drive fetches. */ live?: LiveSnapshot | null + /** Real /api/live fetch error, shown instead of pretending data exists. */ + liveError?: string | null expanded?: boolean onExpandedChange?: (open: boolean) => void defaultExpanded?: boolean - /** Login showcase: play the mock loop without reading or writing the overview demo preference. */ - forceMockDemo?: boolean - /** Scale mock time. Login uses a slower pace; overview stays at 1. */ - mockPace?: number - /** Login showcase: animation only — no title, chrome, demo switch, or view-all link. */ + /** Login showcase: animation only — no title, chrome, or view-all link. */ bare?: boolean }) { const controlled = snapshot !== undefined @@ -304,17 +279,11 @@ export function InflightLiveCard({ if (expandedProp === undefined) setUncontrolledOpen(open) } - const [mockDemoEnabled, setMockDemoEnabled] = useState(() => forceMockDemo || readMockDemoPref()) - const setMockDemo = (on: boolean) => { - setMockDemoEnabled(on) - if (!forceMockDemo) writeMockDemoPref(on) - } - const [liveSnap, setLiveSnap] = useState(() => - cloneMockInflight(snapshot ?? getIdleInflightSnapshot()), + const [liveSnap, setLiveSnap] = useState(() => + cloneInflight(snapshot ?? emptyInflightSnapshot()), ) - const [useMockFallback, setUseMockFallback] = useState(false) const [sticky, setSticky] = useState(null) - /** Wall clock for live startedAtMs elapsed (mock uses tickMockInflight elapsedMs). */ + /** Wall clock for live startedAtMs elapsed. */ const [clockMs, setClockMs] = useState(() => Date.now()) /** * Display-only land gate: occupied chrome (model + elapsed) shows only after @@ -352,10 +321,10 @@ export function InflightLiveCard({ ) } const snap = controlled ? snapshot! : liveSnap - const summary = useMemo(() => summarizeMockInflight(snap), [snap]) + const summary = useMemo(() => summarizeInflight(snap), [snap]) const rootRef = useRef(null) const enteredRef = useRef(false) - const prevRef = useRef(snap) + const prevRef = useRef(snap) /** Last painted rects — handoff flies read these after the source unmounts. */ const rectCache = useRef<{ wait: Record @@ -387,79 +356,40 @@ export function InflightLiveCard({ const viewingSessionRef = useRef(false) // External snapshot (tests) wins. Otherwise: when expanded, project /api/live - // (even idle — no mock throughput/p95/depth bleed). Mock tick only if - // live is null AND 示意/demo is on (default off → calm idle zeros). + // (even idle — zeros mean the pool really is idle, never a synthetic demo). // useLayoutEffect so the first expanded paint is already clean. useLayoutEffect(() => { if (controlled) { - setLiveSnap(cloneMockInflight(snapshot!)) - setUseMockFallback(false) + setLiveSnap(cloneInflight(snapshot!)) setSticky(null) viewingSessionRef.current = false return } if (!expanded) { - setUseMockFallback(false) viewingSessionRef.current = false return } if (live !== null) { - setUseMockFallback(false) setSticky(live.sticky) setClockMs(Date.now()) // First live projection this expand: keep enteredRef false so soft // bootstrap syncLandGate('all') and never treats hydrate as flies. if (!viewingSessionRef.current) enteredRef.current = false setLiveSnap((prev) => { - // New viewing session → force first projection (totals 0, depth reset). - const base = !viewingSessionRef.current - ? { ...cloneMockInflight(prev), waitP95Ms: 1, totals: { done: 0, failed: 0 } } - : prev + // New viewing session starts from an honest empty board: totals 0, + // depth zeros. Every number afterwards comes from /api/live. + const base = !viewingSessionRef.current ? emptyInflightSnapshot() : prev viewingSessionRef.current = true return applyLiveProjection(base, live) }) return } - // live === null → optional Stage-1 mock (示意) or calm idle board. + // live === null → no real data yet. Show the honest empty board. setSticky(null) viewingSessionRef.current = false enteredRef.current = false - if (mockDemoEnabled) { - setUseMockFallback(true) - setLiveSnap((prev) => - isIdleInflightSnapshot(prev) - ? cloneMockInflight(getMockInflightSnapshot()) - : prev, - ) - } else { - setUseMockFallback(false) - setLiveSnap(cloneMockInflight(getIdleInflightSnapshot())) - } - }, [controlled, snapshot, expanded, live, mockDemoEnabled]) - - // Mock raf loop — gated on useMockFallback + 示意 on (live === null only). - useEffect(() => { - if (controlled || !expanded || !useMockFallback || !mockDemoEnabled || live !== null) return - if (prefersReducedMotion()) return - let raf = 0 - let last = performance.now() - let alive = true - const step = (now: number) => { - if (!alive) return - const dt = now - last - if (!document.hidden && dt >= 260) { - last = now - const pace = Number.isFinite(mockPace) ? Math.min(1, Math.max(0.2, mockPace ?? 1)) : 1 - setLiveSnap((prev) => tickMockInflight(prev, dt * pace)) - } - raf = requestAnimationFrame(step) - } - raf = requestAnimationFrame(step) - return () => { - alive = false - cancelAnimationFrame(raf) - } - }, [controlled, expanded, useMockFallback, mockDemoEnabled, live, mockPace]) + setLiveSnap(cloneInflight(emptyInflightSnapshot())) + }, [controlled, snapshot, expanded, live]) // Elapsed tick (~150ms): wall-clock since started_at so busy slots don't stick at 0.0s between /api/live polls. useEffect(() => { @@ -612,8 +542,7 @@ export function InflightLiveCard({ const bootstrapped = controlled || viewingSessionRef.current || - (live === null && mockDemoEnabled && useMockFallback) || - (live === null && !mockDemoEnabled && isIdleInflightSnapshot(snap)) + live === null if (!bootstrapped) { gsap.set(root, { opacity: 0 }) } else { @@ -661,7 +590,7 @@ export function InflightLiveCard({ from: DOMRect | HTMLElement | null | undefined, to: DOMRect | HTMLElement | null | undefined, label: string, - kind: MockJobKind, + kind: LiveJobKind, tone: 'run' | 'ok' | 'danger' | 'retry', beatEl?: HTMLElement | null, onLand?: () => void, @@ -961,7 +890,7 @@ export function InflightLiveCard({ const flyQueueToSlot = ( id: string, label: string, - kind: MockJobKind, + kind: LiveJobKind, workerId: string, ) => { if (!workerId || flewFromQueue.has(id)) return @@ -1113,7 +1042,7 @@ export function InflightLiveCard({ type CellExit = { id: string name: string - kind: MockJobKind + kind: LiveJobKind workerId: string cellIndex: number } @@ -1381,11 +1310,11 @@ export function InflightLiveCard({ } refreshCache() - }, [snap, expanded, controlled, useMockFallback, mockDemoEnabled, live]) + }, [snap, expanded, controlled, live]) const depthLabel = t('inflightDepthHint', { n: summary.depthNow }) - const liveBadge = !useMockFallback && Boolean(live) - const mockBadge = useMockFallback && mockDemoEnabled && !live + const liveBadge = Boolean(live) + const offlineBadge = !live && Boolean(liveError) const stickyBindings = sticky?.bindings ?? 0 return ( @@ -1460,8 +1389,8 @@ export function InflightLiveCard({ {liveBadge ? t('inflightLiveBadge') - : mockBadge - ? t('inflightMockBadge') + : offlineBadge + ? t('inflightOfflineBadge') : t('inflightIdleBadge')} {expanded && stickyBindings > 0 ? ( @@ -1494,21 +1423,6 @@ export function InflightLiveCard({ )} - {expanded && !controlled ? ( -
e.stopPropagation()} - onKeyDown={(e) => e.stopPropagation()} - > - -
- ) : null} } @@ -1526,8 +1440,15 @@ export function InflightLiveCard({ suffix={`/${summary.workerSlots}`} /> - + {/* The live API reports no P95 yet: render an honest dash instead + of a fabricated 0ms. */} + 0 ? snap.waitP95Ms : null} kind="ms" /> + {liveError ? ( +
+ {liveError} +
+ ) : null} {/* Waiting → account-slot bars → Done/Failed (AffectUI Agent Queue flow) */}
@@ -1659,7 +1580,8 @@ function Metric({ warn, }: { label: string - value: number + /** null renders an honest "—" (not measured), never a fabricated zero. */ + value: number | null suffix?: string kind?: 'int' | 'ms' warn?: boolean @@ -1672,7 +1594,11 @@ function Metric({ warn ? 'text-[var(--il-warn-fg)]' : 'text-foreground' }`} > - + {value == null ? ( + — + ) : ( + + )} {suffix ? {suffix} : null}
diff --git a/frontend/src/components/system/UpdateControls.tsx b/frontend/src/components/system/UpdateControls.tsx index aa780f64..b707693c 100644 --- a/frontend/src/components/system/UpdateControls.tsx +++ b/frontend/src/components/system/UpdateControls.tsx @@ -19,7 +19,8 @@ export function UpdateControls({ update }: { update: SystemUpdateController }) {
{t('latestVersion')}
-
{info?.next_version || '—'}
+
{info?.next_version || (info?.has_update ? '—' : info?.current_version) || '—'}
+ {info?.managed && !info?.has_update && !busy ?
{t('upToDate')}
: null}
@@ -34,7 +35,8 @@ export function UpdateControls({ update }: { update: SystemUpdateController }) { {primaryLabel} - {!info?.agent?.available && !busy ?

{t('updateUnavailableHint')}

: null} + {info?.source ?

{t('updateSourceHint', { repo: info.source })}

: null} + {!info?.agent?.available && !busy ?

{t('updateAgentMissingHint')}

: null} {info?.agent?.available && !info.agent.staged_update && !busy ?

{t('updateLegacyOneShotHint')}

: null} {readyToApply || busy || reloadIn != null || justUpdated ? (
diff --git a/frontend/src/components/ui/FilterSelect.tsx b/frontend/src/components/ui/FilterSelect.tsx index fbe711cf..5dad2d39 100644 --- a/frontend/src/components/ui/FilterSelect.tsx +++ b/frontend/src/components/ui/FilterSelect.tsx @@ -13,12 +13,14 @@ export function FilterSelect({ ariaLabel, options, className, + isDisabled = false, }: { value: string onChange: (value: string) => void ariaLabel: string options: FilterSelectOption[] className?: string + isDisabled?: boolean }) { const items = options.map((option) => ({ id: option.id || ALL_VALUE, @@ -33,6 +35,7 @@ export function FilterSelect({ className={className ?? 'w-fit min-w-36'} aria-label={ariaLabel} value={selectedId} + isDisabled={isDisabled} onChange={(next) => { if (typeof next !== 'string') return onChange(next === ALL_VALUE ? '' : next) diff --git a/frontend/src/hooks/useAccountEvents.ts b/frontend/src/hooks/useAccountEvents.ts new file mode 100644 index 00000000..41e5c756 --- /dev/null +++ b/frontend/src/hooks/useAccountEvents.ts @@ -0,0 +1,86 @@ +import { useEffect, useRef, useState } from 'react' +import { openEventStream, type EventStreamStatus, type ServerEvent } from '@/api/events' + +const MIN_BACKOFF_MS = 1000 +const MAX_BACKOFF_MS = 15_000 + +/** + * Console real-time channel: streams real runtime events from `GET /api/events`. + * Reconnects with capped exponential backoff, replays from the last seen seq + * (the bus ring buffers 1024 events), and tears the connection down while the + * document is hidden so a background tab costs nothing. `status` lets a page + * degrade to polling exactly when the stream is not live. + */ +export function useAccountEvents( + onEvent: (event: ServerEvent) => void, + opts?: { enabled?: boolean }, +): { status: EventStreamStatus; lastSeq: number } { + const handlerRef = useRef(onEvent) + useEffect(() => { + handlerRef.current = onEvent + }, [onEvent]) + const enabled = opts?.enabled !== false + const [status, setStatus] = useState('connecting') + const [visible, setVisible] = useState(() => (typeof document === 'undefined' ? true : !document.hidden)) + const [lastSeq, setLastSeq] = useState(0) + const lastSeqRef = useRef(0) + + useEffect(() => { + if (typeof document === 'undefined') return + const onVisibility = () => setVisible(!document.hidden) + document.addEventListener('visibilitychange', onVisibility) + return () => document.removeEventListener('visibilitychange', onVisibility) + }, []) + + useEffect(() => { + if (!enabled || !visible) return + let disposed = false + const controller = new AbortController() + let backoff = MIN_BACKOFF_MS + let timer: number | null = null + setStatus((current) => (current === 'live' ? current : 'connecting')) + + const run = async () => { + while (!disposed) { + try { + await openEventStream({ + lastSeq: lastSeqRef.current, + signal: controller.signal, + onOpen: () => { + backoff = MIN_BACKOFF_MS + if (!disposed) setStatus('live') + }, + onEvent: (event) => { + if (event.seq > lastSeqRef.current) { + lastSeqRef.current = event.seq + setLastSeq(event.seq) + } + if (!disposed) handlerRef.current(event) + }, + }) + if (disposed) break + setStatus('offline') + } catch { + if (disposed || controller.signal.aborted) break + setStatus('offline') + } + // Wait before reconnecting; the delay doubles until the cap so a + // down console does not get hammered. + await new Promise((resolve) => { + timer = window.setTimeout(resolve, backoff) + }) + timer = null + backoff = Math.min(MAX_BACKOFF_MS, backoff * 2) + } + } + + void run() + return () => { + disposed = true + controller.abort() + if (timer != null) window.clearTimeout(timer) + } + }, [enabled, visible]) + + return { status, lastSeq } +} diff --git a/frontend/src/hooks/useLive.ts b/frontend/src/hooks/useLive.ts index 716475e0..5a779973 100644 --- a/frontend/src/hooks/useLive.ts +++ b/frontend/src/hooks/useLive.ts @@ -21,6 +21,7 @@ export const LIVE_POLL_EXPANDED_MS = 800 export function useLive(opts?: { intervalMs?: number }) { const intervalMs = opts?.intervalMs ?? LIVE_POLL_MS const [live, setLive] = useState(null) + const [error, setError] = useState(null) const [samples, setSamples] = useState([]) useEffect(() => { @@ -32,11 +33,17 @@ export function useLive(opts?: { intervalMs?: number }) { .then((data) => { if (cancelled) return setLive(data) + setError(null) // Keep ~60s of sparkline history even when expanded poll is faster. const keep = Math.max(LIVE_SAMPLES, Math.round(60_000 / intervalMs)) setSamples((prev) => [...prev, { at: Date.now(), value: data.in_flight }].slice(-keep)) }) - .catch(() => { /* keep last good snapshot */ }) + .catch((err: unknown) => { + // Keep the last good snapshot, but surface the real failure instead of + // pretending the pool is idle. + if (cancelled) return + setError(err instanceof Error ? err.message : String(err)) + }) } const start = () => { if (timer || document.hidden) return @@ -57,5 +64,5 @@ export function useLive(opts?: { intervalMs?: number }) { } }, [intervalMs]) - return { live, samples } + return { live, samples, error } } diff --git a/frontend/src/hooks/useSystemUpdate.ts b/frontend/src/hooks/useSystemUpdate.ts index 9d02d1d8..63040173 100644 --- a/frontend/src/hooks/useSystemUpdate.ts +++ b/frontend/src/hooks/useSystemUpdate.ts @@ -102,7 +102,9 @@ export function useSystemUpdate() { ? t('updateInProgress') : preparing || submitting ? t('updatePreparingImage') - : t('updateNow') + : info?.managed && !info?.has_update + ? t('upToDate') + : t('updateNow') const statusHint = reloadIn != null ? t('updateReloadingHint') : readyToApply diff --git a/frontend/src/i18n/messages.ts b/frontend/src/i18n/messages.ts index aa6c78df..f3c92ad2 100644 --- a/frontend/src/i18n/messages.ts +++ b/frontend/src/i18n/messages.ts @@ -43,7 +43,28 @@ export const messages: Record = { navAccess: 'Access & try', navAccounts: 'Accounts', checkinDefaultsTitle: 'Automatic check-in', - checkinDefaultsHint: 'Set a default time for each provider. Accounts following the default pick up changes automatically; custom times stay unchanged.', + checkinDefaultsHint: 'Automatic check-in time per provider. Defaults to 09:00; every account without a custom time follows it.', + reloginEntry: 'Re-login', + reloginSelected: 'Selected {count}', + reloginSelectPage: 'Select page', + reloginClear: 'Clear selection', + reloginConfirm: 'Re-login selected', + reloginSelectAccount: 'Select account', + reloginTitle: 'Re-login accounts', + reloginHint: 'Accounts are authorized one at a time: open each account login page, sign in, and the console moves on to the next automatically. An account whose browser session is already signed in completes without typing.', + reloginProgress: '{done}/{total} finished', + reloginOpenPage: 'Open login page', + reloginWaitingAuth: 'Waiting for authorization', + reloginDone: 'Signed in', + reloginFailed: 'Login failed', + reloginTimeout: 'Timed out waiting for authorization', + reloginStopped: 'Cancelled', + reloginPhasePending: 'Queued', + reloginPhaseStarting: 'Starting', + reloginPhaseWaiting: 'Waiting', + reloginPhaseDone: 'Done', + reloginPhaseFailed: 'Failed', + reloginPhaseStopped: 'Cancelled', checkinDisabledAccountsTitle: 'Check in disabled accounts', checkinDisabledAccountsHint: 'When enabled, accounts disabled for chat can still run their opted-in automatic check-in. Manual check-in remains unavailable for disabled accounts.', checkinDisabledAccountsStatus: 'Current status', @@ -143,9 +164,10 @@ export const messages: Record = { modelPoolEdit: 'Edit model', modelPoolEditorHint: 'Name the logical model, choose a routing strategy, then add the real provider models behind it.', modelPoolId: 'Model ID', - modelPoolIdHint: 'Client-facing ID, e.g. my-claude. Lowercase letters, digits, - and /.', + modelPoolIdHint: 'Client-facing ID, e.g. my-claude or deepseek-v4.1-flash. Lowercase letters, digits, ".", - and /.', modelPoolName: 'Display name', - modelPoolNamePh: 'My Claude', + modelPoolNamePh: 'Defaults to the model ID', + modelPoolNameHint: 'Optional. Leave blank to reuse the model ID.', modelPoolStrategy: 'Routing strategy', modelPoolStrategyHint: 'Priority: always use the first working member (primary/backup). Round robin: spread requests evenly. Fill first: favor the highest-weight member. FEFO: prefer the member whose quota expires soonest.', modelPoolStrategy_priority: 'Priority order', @@ -157,6 +179,29 @@ export const messages: Record = { modelPoolFailover: 'Failover', modelPoolMaxAttempts: 'Max attempts', modelPoolMaxAttemptsHint: 'Maximum providers tried before the request fails (1-64).', + modelPoolCapabilities: 'Model capabilities', + modelPoolCapabilitiesHint: 'What the logical model advertises in /v1/models. Leave automatic to use the conservative intersection of its members.', + modelPoolContextLength: 'Context length', + modelPoolContextLengthHint: '0 = automatic: the smallest window every member declares.', + modelPoolMaxOutput: 'Max output', + modelPoolMaxOutputHint: '0 = automatic: the smallest output ceiling every member declares.', + modelPoolReasoningLevels: 'Reasoning levels', + modelPoolReasoningLevelsHint: 'Levels the logical model advertises. Select none to use the levels every member shares.', + modelPoolReasoningDefault: 'Default level', + modelPoolReasoningDefaultHint: 'Advertised as the default effort. Clients may still request any other advertised level.', + modelPoolReasoningAuto: 'Automatic', + modelPoolReasoningSelected: '{n}/{total} selected', + modelPoolReasoningSelectAll: 'Select all', + modelPoolReasoningClear: 'Clear', + modelPoolReasoningEmpty: 'No level selected: only the levels every member shares are advertised.', + modelPoolReasoningLevelNone: 'Thinking off', + modelPoolReasoningLevelLow: 'Shallowest tier', + modelPoolReasoningLevelMedium: 'Balanced', + modelPoolReasoningLevelHigh: 'Deeper', + modelPoolReasoningLevelXhigh: 'Very deep, above high', + modelPoolReasoningLevelMax: 'Deepest', + modelPoolCapabilitiesInvalid: 'Context length and max output must be whole numbers not below 0 (0 = auto).', + modelPoolReasoningInvalid: 'The default level must be one of the selected reasoning levels.', modelPoolMembers: 'Provider models', modelPoolMembersHint: 'Only connected providers and the models enabled in their provider settings are selectable. The provider account pool picks the serving account automatically; order sets priority.', modelPoolAddMember: 'Add provider model', @@ -170,6 +215,7 @@ export const messages: Record = { modelPoolWeight: 'Weight', modelPoolNoModels: 'No models available', modelPoolIdRequired: 'Model ID is required.', + modelPoolIdInvalid: 'Model ID may only contain lowercase letters, digits, ".", - and / (no spaces or underscores).', modelPoolNameRequired: 'Display name is required.', modelPoolMembersRequired: 'Add at least one provider model.', modelPoolMemberIncomplete: 'Every member needs a provider and a model.', @@ -257,6 +303,8 @@ export const messages: Record = { updateApplyingHint: 'Applying the update. This page will refresh when it is ready.', updateInProgressHint: 'The service is updating and will refresh automatically when it is ready.', updateUnavailableHint: 'Updates are temporarily unavailable. Please try again later.', + updateAgentMissingHint: 'The host updater is not connected. On the server, run sudo ./deploy/install-updater.sh once, then recreate qoder-api-proxy.', + updateSourceHint: 'Update source: {repo}', updateFailedHint: 'The update could not be completed. Please try again.', updateCheckFailedHint: 'Unable to check for updates. Please try again later.', updatePreparingHint: 'Getting the update ready: checking the version and saving a backup. Existing connections may be interrupted; clients can retry.', @@ -757,10 +805,8 @@ export const messages: Record = { livePeak: 'peak {n}', liveSaturated: 'Saturated', inflightTitle: 'Live now', - inflightMockBadge: 'mock', + inflightOfflineBadge: 'offline', inflightIdleBadge: 'idle', - inflightMockToggle: 'Demo', - inflightMockToggleAria: 'Show mock demo when live is unavailable', inflightLiveBadge: 'live', inflightHint: 'Slots · in-flight · cooldown', inflightCardAria: 'Open live detail', @@ -802,6 +848,8 @@ export const messages: Record = { toastCheckingInAll: 'Checking in {done} of {total}…', toastCheckedInAll: 'Checked in {checked}, skipped {skipped}', toastCheckedInAllFailed: 'Checked in {checked}, skipped {skipped}, failed {failed}', + checkinRewardSuffix: ' · +{credits} credits', + checkinRewardTotal: '{credits} credits granted in total', lastCheckin: 'Last check-in', lastCheckinNone: 'No check-in yet', checkinStatus: 'Check-in', @@ -839,6 +887,11 @@ export const messages: Record = { quota: 'Quota', quotaUsed: 'Used', + quotaUsedAt: 'quota read {n} min ago', + quotaStale: 'quota snapshot is {n} min old', + forceReadyBadge: 'Force ready', + forceReadyHint: 'A local force-ready marker is active: this account enters the pool without a real probe. The quota shown still comes from the last real upstream snapshot.', + eventsOffline: 'Live stream offline — polling every 5s', quotaRemaining: 'Remaining', quotaDaily: 'Daily quota', quotaWeekly: 'Weekly quota', @@ -1108,7 +1161,7 @@ export const messages: Record = { keysMaxInflightValue: 'Up to {count} at once', keysMaxInflightUnlimited: 'No concurrency limit', keysModelAggregation: 'Cross-provider aggregation', - keysModelAggregationHint: 'When on, /v1/models lists only the public model aliases configured on accounts this key can reach, merged into one provider-neutral name. Requests still route through the account pool.', + keysModelAggregationHint: 'When on, /v1/models lists the enabled models from the cross-provider model pool plus the public aliases this key can reach, merged into one provider-neutral name. Requests still route through the account pool. Provider selection is locked while this stays on.', keysModelAggregationBadge: 'Aggregated', keysLastUsed: 'Last used {time}', keysNeverUsed: 'Not used yet', @@ -1165,7 +1218,28 @@ export const messages: Record = { navAccess: '接入与调试', navAccounts: '账号', checkinDefaultsTitle: '自动签到', - checkinDefaultsHint: '按供应商设置默认时间。跟随默认的账号会立即采用新时间,账号自定义时间不受影响。', + checkinDefaultsHint: '按供应商统一设置自动签到时间,默认 09:00;未单独设置时间的账号立即跟随。', + reloginEntry: '重新登录', + reloginSelected: '已选 {count} 个', + reloginSelectPage: '全选本页', + reloginClear: '清空选择', + reloginConfirm: '确定重新登录', + reloginSelectAccount: '选择账号', + reloginTitle: '重新登录账号', + reloginHint: '按顺序逐个授权:打开每个账号的登录页完成登录后,控制台会自动进入下一个。浏览器已登录同一身份时会自动完成,无需输入。', + reloginProgress: '已完成 {done}/{total}', + reloginOpenPage: '打开登录页', + reloginWaitingAuth: '等待授权', + reloginDone: '已登录', + reloginFailed: '登录失败', + reloginTimeout: '等待授权超时', + reloginStopped: '已取消', + reloginPhasePending: '待处理', + reloginPhaseStarting: '启动中', + reloginPhaseWaiting: '等待授权', + reloginPhaseDone: '成功', + reloginPhaseFailed: '失败', + reloginPhaseStopped: '已取消', checkinDisabledAccountsTitle: '停用账号也自动签到', checkinDisabledAccountsHint: '开启后,停用聊天功能的账号仍可执行已开启的自动签到;停用账号仍不可手动签到。', checkinDisabledAccountsStatus: '当前状态', @@ -1265,9 +1339,10 @@ export const messages: Record = { modelPoolEdit: '编辑模型', modelPoolEditorHint: '为逻辑模型命名、选择路由策略,然后添加它背后的真实供应商模型。', modelPoolId: '模型 ID', - modelPoolIdHint: '客户端使用的 ID,例如 my-claude。小写字母、数字、- 和 /。', + modelPoolIdHint: '客户端使用的 ID,例如 my-claude、deepseek-v4.1-flash。小写字母、数字、"."、- 和 /。', modelPoolName: '显示名称', - modelPoolNamePh: '我的 Claude', + modelPoolNamePh: '留空则沿用模型 ID', + modelPoolNameHint: '可选。留空时直接使用模型 ID。', modelPoolStrategy: '路由策略', modelPoolStrategyHint: '优先级顺序:始终使用第一个可用成员(主备)。轮询:均匀分摊请求。优先填满:偏向权重最高的成员。最先过期优先:优先使用额度最快到期的成员。', modelPoolStrategy_priority: '优先级顺序', @@ -1279,6 +1354,29 @@ export const messages: Record = { modelPoolFailover: '故障转移', modelPoolMaxAttempts: '最大尝试次数', modelPoolMaxAttemptsHint: '请求失败前最多尝试的供应商数量(1-64)。', + modelPoolCapabilities: '模型能力', + modelPoolCapabilitiesHint: '逻辑模型在 /v1/models 中对外声明的参数。留空自动时取各成员保守的交集。', + modelPoolContextLength: '上下文长度', + modelPoolContextLengthHint: '0 = 自动:取所有成员声明的最小窗口。', + modelPoolMaxOutput: '最大输出', + modelPoolMaxOutputHint: '0 = 自动:取所有成员声明的最小输出上限。', + modelPoolReasoningLevels: '思考档位', + modelPoolReasoningLevelsHint: '逻辑模型对外声明的思考档位。不选时取所有成员共有的档位。', + modelPoolReasoningDefault: '默认档位', + modelPoolReasoningDefaultHint: '作为默认思考强度对外声明;客户端仍可请求任一已声明的档位。', + modelPoolReasoningAuto: '自动', + modelPoolReasoningSelected: '已选 {n}/{total} 档', + modelPoolReasoningSelectAll: '全选', + modelPoolReasoningClear: '清空', + modelPoolReasoningEmpty: '未选择档位:对外只声明所有成员共有的档位。', + modelPoolReasoningLevelNone: '关闭思考', + modelPoolReasoningLevelLow: '最浅一档', + modelPoolReasoningLevelMedium: '中等', + modelPoolReasoningLevelHigh: '较深', + modelPoolReasoningLevelXhigh: '很深(高于 high)', + modelPoolReasoningLevelMax: '最深', + modelPoolCapabilitiesInvalid: '上下文长度和最大输出需填不小于 0 的整数(0 表示自动)。', + modelPoolReasoningInvalid: '默认档位必须从已选中的思考档位中选择。', modelPoolMembers: '供应商模型', modelPoolMembersHint: '仅可选出已接入的供应商,以及对应供应商设置中启用的模型。账号由供应商账号池自动选择,顺序即优先级。', modelPoolAddMember: '添加供应商模型', @@ -1292,6 +1390,7 @@ export const messages: Record = { modelPoolWeight: '权重', modelPoolNoModels: '暂无可用模型', modelPoolIdRequired: '请填写模型 ID。', + modelPoolIdInvalid: '模型 ID 只能包含小写字母、数字、"."、- 和 /(不能有空格或下划线)。', modelPoolNameRequired: '请填写显示名称。', modelPoolMembersRequired: '请至少添加一个供应商模型。', modelPoolMemberIncomplete: '每个成员都需要选择供应商和模型。', @@ -1379,6 +1478,8 @@ export const messages: Record = { updateApplyingHint: '正在安装更新。完成后会自动刷新这个页面。', updateInProgressHint: '系统正在更新,准备就绪后会自动刷新页面。', updateUnavailableHint: '暂时无法更新,请稍后重试。', + updateAgentMissingHint: '宿主机 updater 未连接。请在服务器仓库目录执行一次 sudo ./deploy/install-updater.sh,然后重建 qoder-api-proxy。', + updateSourceHint: '更新源:{repo}', updateFailedHint: '更新未完成,请重试。', updateCheckFailedHint: '暂时无法检查更新,请稍后重试。', updatePreparingHint: '正在准备更新:检查版本并保存备份。现有连接可能会被中断,客户端可自行重试。', @@ -1879,10 +1980,8 @@ export const messages: Record = { livePeak: '峰值 {n}', liveSaturated: '已满载', inflightTitle: '实时进行中', - inflightMockBadge: '示意', + inflightOfflineBadge: '未连接', inflightIdleBadge: '空闲', - inflightMockToggle: '示意', - inflightMockToggleAria: '无实时数据时显示示意动画', inflightLiveBadge: '实时', inflightHint: '槽位 · 进行中 · 冷却', inflightCardAria: '打开实时详情', @@ -1924,6 +2023,8 @@ export const messages: Record = { toastCheckingInAll: '正在签到 {done}/{total}…', toastCheckedInAll: '已签到 {checked} 个,跳过 {skipped} 个', toastCheckedInAllFailed: '已签到 {checked} 个,跳过 {skipped} 个,失败 {failed} 个', + checkinRewardSuffix: ' · +{credits} 积分', + checkinRewardTotal: '本次共获得 {credits} 积分', lastCheckin: '最近签到', lastCheckinNone: '还没有签到记录', checkinStatus: '签到', @@ -1961,6 +2062,11 @@ export const messages: Record = { quota: '额度', quotaUsed: '已用', + quotaUsedAt: '额度 {n} 分钟前读取', + quotaStale: '额度快照已过期 {n} 分钟', + forceReadyBadge: '强制就绪', + forceReadyHint: '本地强制就绪标记生效中:该账号跳过真实探测直接进池;这里显示的额度仍来自最近一次真实上游快照。', + eventsOffline: '实时通道未连接,已降级为 5 秒轮询', quotaRemaining: '剩余', quotaDaily: '日额度', quotaWeekly: '周额度', @@ -2230,7 +2336,7 @@ export const messages: Record = { keysMaxInflightValue: '同时最多 {count} 条', keysMaxInflightUnlimited: '不限制并发', keysModelAggregation: '跨供应商模型聚合', - keysModelAggregationHint: '开启后,/v1/models 只返回这把密钥可访问账号上配置的公共模型别名,并按名称合并成一条、不显示供应商。请求仍按账号池路由。', + keysModelAggregationHint: '开启后,/v1/models 返回模型池里已启用的跨供应商聚合模型,以及这把密钥可访问账号上配置的公共别名,并按名称合并成一条、不显示供应商;请求仍按账号池路由。开启期间供应商选项锁定。', keysModelAggregationBadge: '聚合', keysLastUsed: '最近使用 {time}', keysNeverUsed: '尚未使用', diff --git a/frontend/src/lib/mockInflight.ts b/frontend/src/lib/liveInflight.ts similarity index 51% rename from frontend/src/lib/mockInflight.ts rename to frontend/src/lib/liveInflight.ts index 19ebfa74..a4c5e1ce 100644 --- a/frontend/src/lib/mockInflight.ts +++ b/frontend/src/lib/liveInflight.ts @@ -1,31 +1,28 @@ /** - * Phase-1 fake snapshot for Overview「实时进行中」. - * Shaped like cli2api runtime concepts (not a parallel control plane): - * jobs ≈ in-flight / waiting proxy requests - * workers ≈ account slots currently (or recently) hitting upstream - * rateLimits≈ cooldown / provider rate-limit windows - * depth ≈ recent waiting + concurrency approx - * totals ≈ session Done/Failed while viewing (mock tick; live bumps) - * Stage-3 swaps workers/rateLimits/sticky/queue onto /api/live (LiveWorker, - * LiveRateLimit, LiveSticky, LiveJob); depth stays client-rolled. Do not invent - * a parallel /api/inflight*. + * Real inflight projection for Overview「实时进行中」. * - * Live loop (`tickMockInflight`) mirrors public AffectUI Motion prose: - * progress fill, queue→worker handoff, DONE/FAILED stack, depth scroll — - * Stage-1 only; real /api/live projection stays read-only. + * Everything rendered comes from /api/live: workers (account slots + their + * in-flight cells), rate-limit/cooldown windows, the selecting queue, occupied + * requests, sticky stats and RPM. There is no seed, no tick, and no demo mode: + * when live data is unavailable the card shows an honest empty state. */ -export type MockJobKind = 'chat' | 'embed' | 'tools' | 'other' -export type MockJobStatus = 'queued' | 'running' | 'done' | 'failed' +export type LiveJobKind = 'chat' | 'embed' | 'tools' | 'other' +export type LiveJobStatus = 'queued' | 'running' | 'done' | 'failed' -export type MockJobPriority = 'high' | 'normal' | 'low' +export type LiveJobPriority = 'high' | 'normal' | 'low' -export type MockInflightJob = { +/** Recent concurrency depth window kept for the sparkline. */ +const DEPTH_SERIES_LEN = 24 +/** Queue depth at which the waiting metric turns amber (UI guideline). */ +const BACKPRESSURE_DEPTH = 6 + +export type LiveInflightJob = { id: string /** Short label — model / route style. */ name: string - kind: MockJobKind - status: MockJobStatus + kind: LiveJobKind + status: LiveJobStatus /** Account id holding the request when running. */ accountId?: string progress: number @@ -36,13 +33,13 @@ export type MockInflightJob = { /** Sticky session hint (affinity hit). */ sticky?: boolean /** AffectUI priority — high lands at back then glides past. */ - priority?: MockJobPriority + priority?: LiveJobPriority /** Retry attempt count when failed job slides back to queue. */ attempt?: number } /** One occupied concurrency cell on an account slot bar. */ -export type MockSlotCell = { +export type LiveSlotCell = { id: string /** Requested model / short label. */ name: string @@ -57,7 +54,7 @@ export type MockSlotCell = { pendingInbound?: boolean } -export type MockAccountSlot = { +export type LiveAccountSlot = { id: string /** Account display name. */ name: string @@ -77,10 +74,10 @@ export type MockAccountSlot = { /** Current occupied concurrency cells (in_flight). */ inFlight?: number /** Per-cell model + elapsed (length ≤ inFlight). */ - cells?: MockSlotCell[] + cells?: LiveSlotCell[] } -export type MockRateLimitWindow = { +export type LiveRateLimitWindow = { id: string label: string /** Remaining cooldown / rate-limit window in ms. */ @@ -91,17 +88,17 @@ export type MockRateLimitWindow = { } /** One job that just landed on Done or Failed this tick (GSAP fly-out routing). */ -export type MockCompletion = { +export type LiveCompletion = { id: string name: string - kind: MockJobKind + kind: LiveJobKind ok: boolean } -export type MockInflightSnapshot = { - jobs: MockInflightJob[] - workers: MockAccountSlot[] - rateLimits: MockRateLimitWindow[] +export type LiveInflightSnapshot = { + jobs: LiveInflightJob[] + workers: LiveAccountSlot[] + rateLimits: LiveRateLimitWindow[] /** Recent waiting+concurrency depth (oldest → newest). */ depthSeries: number[] /** Soft backpressure guide on the depth chart. */ @@ -117,81 +114,10 @@ export type MockInflightSnapshot = { * Live `totals` are session counters (since expand/mount), bumped from * completions — not historical DB totals. priorIsLive uses waitP95Ms === 0. */ - completions?: MockCompletion[] -} - -/** Stable demo seed — deterministic for first paint / screenshots. */ -export const MOCK_INFLIGHT: MockInflightSnapshot = { - generatedAt: 0, - backpressure: 6, - throughputPerMin: 42, - waitP95Ms: 2800, - totals: { done: 186, failed: 4 }, - workers: [ - { - id: 'acc-wb-a1', name: 'WorkBuddy', provider: 'workbuddy', busy: true, progress: 0.72, jobId: 'j1', concurrency: 4, inFlight: 3, - cells: [ - { id: 'j1', name: 'glm-5.2', startedAtMs: 0, elapsedMs: 11_200 }, - { id: 'j1b', name: 'kimi-k2.7-code', startedAtMs: 0, elapsedMs: 8400 }, - { id: 'j1c', name: 'qwen3-embedding', startedAtMs: 0, elapsedMs: 4100 }, - ], - }, - { - id: 'acc-wb-a2', name: 'Zhipu', provider: 'zhipu', busy: true, progress: 0.41, jobId: 'j2', rateLimited: true, concurrency: 2, inFlight: 1, - cells: [{ id: 'j2', name: 'deepseek-v4-pro', startedAtMs: 0, elapsedMs: 9400 }], - }, - { - id: 'acc-qd-b1', name: 'Qoder', provider: 'qoder', busy: true, progress: 0.88, jobId: 'j3', concurrency: 1, inFlight: 1, - cells: [{ id: 'j3', name: 'glm-5.3', startedAtMs: 0, elapsedMs: 6200 }], - }, - { id: 'acc-qd-b2', name: 'Kimi', provider: 'kimi', busy: false, progress: 0, concurrency: 4, inFlight: 0, cells: [] }, - { - id: 'acc-trae-c1', name: 'Trae', provider: 'trae', busy: true, progress: 0.23, jobId: 'j4', concurrency: 3, inFlight: 2, - cells: [ - { id: 'j4', name: 'qwen3-coder', startedAtMs: 0, elapsedMs: 3100 }, - { id: 'j4b', name: 'glm-5.3-flash', startedAtMs: 0, elapsedMs: 1800 }, - ], - }, - { id: 'acc-codex-d1', name: 'Codex', provider: 'codex', busy: false, progress: 0, rateLimited: true, concurrency: 2, inFlight: 0, cells: [] }, - ], - jobs: [ - { id: 'j1', name: 'glm-5.2', kind: 'chat', status: 'running', accountId: 'acc-wb-a1', progress: 0.72, elapsedMs: 11_200, sticky: true }, - { id: 'j1b', name: 'kimi-k2.7-code', kind: 'chat', status: 'running', accountId: 'acc-wb-a1', progress: 0.55, elapsedMs: 8400 }, - { id: 'j1c', name: 'qwen3-embedding', kind: 'embed', status: 'running', accountId: 'acc-wb-a1', progress: 0.3, elapsedMs: 4100 }, - { id: 'j2', name: 'deepseek-v4-pro', kind: 'embed', status: 'running', accountId: 'acc-wb-a2', progress: 0.41, elapsedMs: 9400 }, - { id: 'j3', name: 'glm-5.3', kind: 'chat', status: 'running', accountId: 'acc-qd-b1', progress: 0.88, elapsedMs: 6200 }, - { id: 'j4', name: 'qwen3-coder', kind: 'tools', status: 'running', accountId: 'acc-trae-c1', progress: 0.23, elapsedMs: 3100 }, - { id: 'j4b', name: 'glm-5.3-flash', kind: 'chat', status: 'running', accountId: 'acc-trae-c1', progress: 0.15, elapsedMs: 1800 }, - { id: 'j5', name: 'deepseek-v4.1-flash', kind: 'chat', status: 'queued', progress: 0, elapsedMs: 7200 }, - { id: 'j6', name: 'glm-5.2', kind: 'chat', status: 'queued', progress: 0, elapsedMs: 5100 }, - { id: 'j7', name: 'kimi-k2.7-code', kind: 'chat', status: 'queued', progress: 0, elapsedMs: 2800, sticky: true, priority: 'high' }, - { id: 'j8', name: 'qwen3-embedding', kind: 'embed', status: 'queued', progress: 0, elapsedMs: 1400 }, - { id: 'j9', name: 'qwen3-coder', kind: 'tools', status: 'queued', progress: 0, elapsedMs: 900 }, - { id: 'j10', name: 'glm-5.3-flash', kind: 'chat', status: 'queued', progress: 0, elapsedMs: 600 }, - { id: 'j11', name: 'deepseek-v4-pro', kind: 'embed', status: 'queued', progress: 0, elapsedMs: 400 }, - { id: 'j12', name: 'glm-5.3', kind: 'chat', status: 'queued', progress: 0, elapsedMs: 200, priority: 'high' }, - ], - rateLimits: [ - { id: 'rl1', label: 'Zhipu 限流', remainingMs: 97_000, from: 0.55, until: 0.72 }, - { id: 'rl2', label: 'Codex 冷却', remainingMs: 41_000, from: 0.82, until: 1 }, - ], - // Soft hump under rate-limit, then partial drain. - depthSeries: [1, 1, 2, 2, 3, 4, 5, 6, 7, 6, 5, 4, 3, 4, 5, 6, 5, 4, 3, 3, 2, 3, 4, 3], + completions?: LiveCompletion[] } -const SEED_NAMES: Array<{ name: string; kind: MockJobKind; sticky?: boolean }> = [ - { name: 'glm-5.3', kind: 'chat' }, - { name: 'qwen3-embedding', kind: 'embed' }, - { name: 'qwen3-coder', kind: 'tools' }, - { name: 'glm-5.3-flash', kind: 'chat', sticky: true }, - { name: 'deepseek-v4.1-flash', kind: 'chat' }, - { name: 'deepseek-v4-pro', kind: 'embed' }, - { name: 'kimi-k2.7-code', kind: 'chat' }, -] - -let seq = 100 - -export function cloneMockInflight(snap: MockInflightSnapshot = MOCK_INFLIGHT): MockInflightSnapshot { +export function cloneInflight(snap: LiveInflightSnapshot): LiveInflightSnapshot { return { ...snap, workers: snap.workers.map((w) => ({ @@ -207,215 +133,19 @@ export function cloneMockInflight(snap: MockInflightSnapshot = MOCK_INFLIGHT): M } } -export function getMockInflightSnapshot(): MockInflightSnapshot { - return cloneMockInflight() -} - -/** Calm empty board when live is unavailable and mock 示意 is off. */ -export function getIdleInflightSnapshot(): MockInflightSnapshot { - const n = Math.max(1, MOCK_INFLIGHT.depthSeries.length) +/** Honest empty board: no fabricated numbers, used until /api/live responds. */ +export function emptyInflightSnapshot(): LiveInflightSnapshot { return { generatedAt: Date.now(), - backpressure: MOCK_INFLIGHT.backpressure, + backpressure: BACKPRESSURE_DEPTH, throughputPerMin: 0, waitP95Ms: 0, totals: { done: 0, failed: 0 }, workers: [], jobs: [], rateLimits: [], - depthSeries: Array.from({ length: n }, () => 0), - } -} - -export function isIdleInflightSnapshot(snap: MockInflightSnapshot): boolean { - return ( - snap.jobs.length === 0 && - snap.workers.length === 0 && - snap.throughputPerMin === 0 && - (snap.totals?.done ?? 0) === 0 && - (snap.totals?.failed ?? 0) === 0 - ) -} - -/** - * Advance the Stage-1 mock one frame. Mirrors public AffectUI loop: - * progress fills (frozen under rate-limit), completed jobs → Done/Failed, - * free slots pull the front of the waiting queue, depth series scrolls, - * rate-limit remaining counts down. Deterministic-ish for a given dt. - */ -export function tickMockInflight(prev: MockInflightSnapshot, dtMs: number): MockInflightSnapshot { - const dt = Math.max(16, Math.min(500, dtMs)) - const next = cloneMockInflight(prev) - next.generatedAt = (prev.generatedAt || 0) + dt - - // Countdown rate-limit windows; clear expired → unfreeze matching slots. - next.rateLimits = next.rateLimits - .map((r) => ({ ...r, remainingMs: Math.max(0, r.remainingMs - dt) })) - .filter((r) => r.remainingMs > 0) - // Keep rateLimited flag in sync with remaining windows (seed label → slot). - for (const w of next.workers) { - if (w.id === 'acc-wb-a2') w.rateLimited = next.rateLimits.some((r) => r.label.includes('Zhipu')) - else if (w.id === 'acc-codex-d1') w.rateLimited = next.rateLimits.some((r) => r.label.includes('Codex')) - } - - const jobById = new Map(next.jobs.map((j) => [j.id, j])) - - // Per-cell elapsed + independent progress (rate-limit freezes the account). - for (const w of next.workers) { - if (w.cells?.length) { - for (const c of w.cells) c.elapsedMs += dt - } - if (w.rateLimited) continue - let maxP = 0 - for (const c of w.cells ?? []) { - const job = jobById.get(c.id) - if (!job || job.status !== 'running') continue - job.elapsedMs = c.elapsedMs - // ~8–14s per cell from current progress, paced by dt + cell id. - const speed = 0.045 + (c.id.charCodeAt(c.id.length - 1) % 5) * 0.008 - job.progress = Math.min(1, job.progress + speed * (dt / 1000)) - maxP = Math.max(maxP, job.progress) - } - if ((w.cells?.length ?? 0) > 0) { - w.progress = maxP - w.busy = true - w.jobId = w.cells![0].id - w.inFlight = w.cells!.length - } - } - - // Finish ONE ready cell per worker per tick so each concurrency cell gets - // its own Done/Failed fly-out (do not clear the whole account at once). - const finished: Array<{ jobId: string; workerId: string; ok: boolean }> = [] - for (const w of next.workers) { - if (w.rateLimited || !(w.cells?.length)) continue - const ready = w.cells.find((c) => { - const j = jobById.get(c.id) - return Boolean(j && j.status === 'running' && j.progress >= 0.995) - }) - if (!ready) continue - const ok = (ready.id.charCodeAt(1) + Math.floor(next.generatedAt / 1000)) % 9 !== 0 - finished.push({ jobId: ready.id, workerId: w.id, ok }) - } - for (const f of finished) { - const job = jobById.get(f.jobId) - const w = next.workers.find((x) => x.id === f.workerId) - if (!job || !w) continue - w.cells = (w.cells ?? []).filter((c) => c.id !== f.jobId) - w.inFlight = w.cells.length - w.jobId = w.cells[0]?.id - w.busy = w.cells.length > 0 - w.progress = w.busy - ? Math.max(0.04, ...w.cells.map((c) => jobById.get(c.id)?.progress ?? 0.04)) - : 0 - job.accountId = undefined - if (f.ok) { - job.status = 'done' - job.progress = 1 - next.totals.done += 1 - continue - } - // AffectUI: failed shakes — or retry slides back to queue (same id). - const attempt = (job.attempt ?? 1) + 1 - const canRetry = attempt <= 3 && (f.jobId.charCodeAt(0) + Math.floor(next.generatedAt / 900)) % 2 === 0 - if (canRetry) { - job.status = 'queued' - job.progress = 0 - job.elapsedMs = 80 - job.attempt = attempt - job.priority = 'high' - continue - } - job.status = 'failed' - job.progress = 1 - next.totals.failed += 1 - } - - // Per-job outcomes for GSAP (retry back to queue is not a sink landing). - const completions: MockCompletion[] = [] - for (const f of finished) { - const job = jobById.get(f.jobId) - if (!job) continue - if (job.status === 'done' || job.status === 'failed') { - completions.push({ id: job.id, name: job.name, kind: job.kind, ok: job.status === 'done' }) - } - } - next.completions = completions.length > 0 ? completions : undefined - - // Drop terminal jobs from the active list (keep queue + running only). - next.jobs = next.jobs.filter((j) => j.status === 'queued' || j.status === 'running') - - // Waiting elapsed ticks up. - for (const j of next.jobs) { - if (j.status === 'queued') j.elapsedMs += dt - } - - // Free concurrency cells pull front of queue (partially busy accounts included). - const queue = next.jobs.filter((j) => j.status === 'queued') - for (const w of next.workers) { - if (w.rateLimited) continue - const cap = clampSlotConcurrency(w.concurrency ?? 1) - w.cells = w.cells ?? [] - while (w.cells.length < cap) { - const job = queue.shift() - if (!job) break - job.status = 'running' - job.accountId = w.id - job.progress = 0.04 - job.elapsedMs = 0 - const cell = { id: job.id, name: job.name, startedAtMs: Date.now(), elapsedMs: 0 } - w.cells = [...w.cells.filter((c) => c.id !== job.id), cell].slice(0, cap) - w.busy = true - w.progress = Math.max(w.progress, 0.04) - w.jobId = w.cells[0]?.id - w.inFlight = w.cells.length - } - } - - // Soft enqueue so the waiting rail doesn’t drain dry. Keep enough - // queued jobs that the rail shows several timed pills, not just dots. - const waiting = next.jobs.filter((j) => j.status === 'queued').length - if (waiting < 10 && next.generatedAt % 1600 < dt) { - const pick = SEED_NAMES[seq % SEED_NAMES.length] - seq += 1 - // Every ~4th job is high priority (lands at back, then glides past). - const priority = seq % 4 === 0 ? 'high' as const : 'normal' as const - next.jobs.push({ - id: `j${seq}`, - name: pick.name, - kind: pick.kind, - status: 'queued', - progress: 0, - elapsedMs: 200 + (seq % 7) * 400, - sticky: pick.sticky, - priority, - }) - } - - // High-priority: after a brief back-of-queue land (~400ms), glide past to front. - { - const running = next.jobs.filter((j) => j.status === 'running') - const queued = next.jobs.filter((j) => j.status === 'queued') - const promote = queued.filter((j) => j.priority === 'high' && j.elapsedMs >= 400) - const rest = queued.filter((j) => !(j.priority === 'high' && j.elapsedMs >= 400)) - // Stable: already-promoted highs keep relative order at front; new promotes append after them. - const highs = promote - next.jobs = [...running, ...highs, ...rest] + depthSeries: Array.from({ length: DEPTH_SERIES_LEN }, () => 0), } - - // Depth chart scrolls: shift left, append current waiting+busy approx. - const busy = next.workers.filter((w) => w.busy).length - const waitNow = next.jobs.filter((j) => j.status === 'queued').length - const depthNow = Math.max(1, waitNow + Math.max(0, busy - 2)) - const series = next.depthSeries.slice(1) - series.push(depthNow) - next.depthSeries = series - - // Throughput / p95 drift gently. - next.throughputPerMin = Math.max(28, Math.min(58, next.throughputPerMin + ((seq % 3) - 1))) - next.waitP95Ms = Math.max(900, Math.min(5200, next.waitP95Ms + (waitNow > 4 ? 40 : -20))) - - return next } /** Clamp account concurrency for slot-bar cells (UI + summary). */ @@ -424,7 +154,7 @@ export function clampSlotConcurrency(n: number | undefined): number { return Math.max(1, Math.min(16, Math.floor(n))) } -export function summarizeMockInflight(snap: MockInflightSnapshot) { +export function summarizeInflight(snap: LiveInflightSnapshot) { const running = snap.jobs.filter((j) => j.status === 'running').length const waiting = snap.jobs.filter((j) => j.status === 'queued').length const busyWorkers = snap.workers.filter((w) => w.busy).length @@ -455,7 +185,7 @@ export function summarizeMockInflight(snap: MockInflightSnapshot) { } /** Optional sticky projection from /api/live (Stage-3 wire). */ -export type MockStickyStats = { +export type LiveStickyStats = { bindings: number hits: number misses: number @@ -506,7 +236,7 @@ export type LiveStickyLike = { export type LiveQueueJobLike = { id: string name: string - /** RequestStatus* — UI maps selecting onto MockJobStatus queued. */ + /** RequestStatus* — UI maps selecting onto LiveJobStatus queued. */ status: string started_at?: string /** Bind target while dwell still projects onto the waiting rail. */ @@ -541,14 +271,14 @@ export type LiveProjectionInput = { * showing occupied chrome until the inbound animation lands. */ export function applyLiveProjection( - base: MockInflightSnapshot, + base: LiveInflightSnapshot, live: LiveProjectionInput, -): MockInflightSnapshot { +): LiveInflightSnapshot { const now = Date.now() const prevById = new Map(base.jobs.map((j) => [j.id, j])) - const n = Math.max(1, MOCK_INFLIGHT.depthSeries.length) - const rateLimits: MockRateLimitWindow[] = live.rate_limits.map((r, i) => { + const n = DEPTH_SERIES_LEN + const rateLimits: LiveRateLimitWindow[] = live.rate_limits.map((r, i) => { const span = 0.14 const from = Math.min(0.86, ((i * 0.22) % 0.86)) return { @@ -561,7 +291,7 @@ export function applyLiveProjection( }) // Selecting queue first — ids still on wait rail (incl. dwell-bound). - const queuedJobs: MockInflightJob[] = (live.queue ?? []).map((q) => { + const queuedJobs: LiveInflightJob[] = (live.queue ?? []).map((q) => { const id = (q.id || '').trim() const prev = prevById.get(id) let startedAtMs: number | undefined @@ -608,7 +338,7 @@ export function applyLiveProjection( occByAccount.set(acc, list) } - const prevCellsByAccount = new Map() + const prevCellsByAccount = new Map() for (const w of base.workers) { if (w.cells?.length) prevCellsByAccount.set(w.id, w.cells) } @@ -627,7 +357,7 @@ export function applyLiveProjection( return fallback } - const workers: MockAccountSlot[] = live.workers.map((w) => { + const workers: LiveAccountSlot[] = live.workers.map((w) => { const concurrency = clampSlotConcurrency(w.max_inflight ?? 4) const rawIn = w.in_flight != null && Number.isFinite(w.in_flight) @@ -639,7 +369,7 @@ export function applyLiveProjection( const prevCells = prevCellsByAccount.get(w.id) ?? [] const prevByCellId = new Map(prevCells.map((c) => [c.id, c])) const occ = occByAccount.get(w.id) ?? [] - const cells: MockSlotCell[] = [] + const cells: LiveSlotCell[] = [] for (const o of occ) { if (cells.length >= inFlight) break @@ -696,7 +426,7 @@ export function applyLiveProjection( }) // Running jobs = occupancy cells not still on the wait rail (dwell). - const runningJobs: MockInflightJob[] = [] + const runningJobs: LiveInflightJob[] = [] for (const w of workers) { for (const c of w.cells ?? []) { if (queueIds.has(c.id)) continue // still selecting for display @@ -704,7 +434,7 @@ export function applyLiveProjection( runningJobs.push({ id: c.id, name: c.name, - kind: (prev?.kind as MockJobKind | undefined) ?? 'chat', + kind: (prev?.kind as LiveJobKind | undefined) ?? 'chat', status: 'running', accountId: w.id, progress: w.progress, @@ -714,7 +444,7 @@ export function applyLiveProjection( } } - const jobs: MockInflightJob[] = [...runningJobs, ...queuedJobs] + const jobs: LiveInflightJob[] = [...runningJobs, ...queuedJobs] // Continue rolling depth only after a prior live projection (cleared p95). // Mock seed/tick always leaves waitP95Ms > 0 — start zeros. Session totals @@ -741,7 +471,7 @@ export function applyLiveProjection( pendingByAccount.set(acc, list) } const stillIds = new Set(jobs.map((j) => j.id)) - const completions: MockCompletion[] = [] + const completions: LiveCompletion[] = [] for (const prev of base.jobs) { if (prev.status !== 'running') continue if (stillIds.has(prev.id)) continue diff --git a/frontend/src/pages/AccountsPage.tsx b/frontend/src/pages/AccountsPage.tsx index 8928e1cf..4560ed20 100644 --- a/frontend/src/pages/AccountsPage.tsx +++ b/frontend/src/pages/AccountsPage.tsx @@ -1,6 +1,6 @@ import { toast } from '@/lib/toast' import { copyText } from '@/lib/clipboard' -import { useCallback, useEffect, useMemo, useState, type ChangeEvent } from 'react' +import { useCallback, useEffect, useMemo, useRef, useState, type ChangeEvent } from 'react' import { Button, Label, ListBox, Select } from '@heroui/react' import { ArrowsClockwise, @@ -8,9 +8,11 @@ import { DownloadSimple, MagnifyingGlass, Plus, + SignIn, UploadSimple, } from '@phosphor-icons/react' import { AccountCard, type AccountBusyKind, type CheckinFeedback } from '@/components/account/AccountCard' +import { BatchReloginModal } from '@/components/account/BatchReloginModal' import { AccountCheckinRecordsModal } from '@/components/account/AccountCheckinRecordsModal' import { AccountModelsModal } from '@/components/account/AccountModelsModal' import { EditAccountModal } from '@/components/account/EditAccountModal' @@ -38,6 +40,7 @@ import { importAccount, loginWithPat, refreshAccount, + refreshAllAccounts, startDeviceLogin, updateAccount, type ProviderDescriptor, @@ -46,8 +49,17 @@ import { fetchSystemSettings, type SystemSettings } from '@/api/system' import { AccountsPageSkeleton } from '@/components/ui/PageSkeletons' import { accountState, + formatQuotaAmount, type AccountRow, } from '@/lib/account' +import { useAccountEvents } from '@/hooks/useAccountEvents' +import type { + AccountStateEvent, + BulkEventData, + CheckinStateEvent, + QuotaStateEvent, + ServerEvent, +} from '@/api/events' import { accountProviderFamilyLabel } from '@/lib/provider' import { ProviderMark } from '@/components/ProviderMark' import { BatchImportConfirmModal } from '@/components/account/BatchImportConfirmModal' @@ -99,7 +111,6 @@ type AccountFilter = 'all' | 'available' | 'attention' | 'disabled' const ALL_PROVIDERS = '__all__' const EMPTY_ACCOUNTS: AccountRow[] = [] -const ACCOUNT_REFRESH_BATCH_SIZE = 2 export function AccountsPage() { const { t } = useI18n() @@ -143,6 +154,16 @@ export function AccountsPage() { const [priorityById, setPriorityById] = useState>({}) const [quotaRefreshing, setQuotaRefreshing] = useState(false) const [checkinAllRunning, setCheckinAllRunning] = useState(false) + // Bulk re-login: selection mode on the account cards, then a sequential + // authorization walkthrough (see BatchReloginModal). + const [reloginMode, setReloginMode] = useState(false) + const [reloginSelected, setReloginSelected] = useState([]) + const [reloginOpen, setReloginOpen] = useState(false) + /** + * Live bulk-op progress streamed from GET /api/events (real per-account + * frames). Null when no bulk op is running. + */ + const [bulkProgress, setBulkProgress] = useState<{ kind: 'checkin' | 'refresh'; total: number; done: number } | null>(null) const reloadAccounts = useCallback(async (refresh = false) => { try { const response = await fetchAccounts(refresh) @@ -154,36 +175,158 @@ export function AccountsPage() { } }, []) - const refreshAccountsInBatches = useCallback(async (ids: string[], forceQuota = true) => { - const accountIds = [...new Set(ids)] - if (!accountIds.length) return { total: 0, failed: 0, errors: [] as string[] } - const total = accountIds.length - // Aggregate failures per account instead of mutating a shared object inside - // the concurrent Promise.all workers: those interleaved `failed += 1` - // updates race each other and lose counts, so a batch where several - // accounts failed could under-report how many really did. - const failures = new Map() - for (let start = 0; start < accountIds.length; start += ACCOUNT_REFRESH_BATCH_SIZE) { - const batch = accountIds.slice(start, start + ACCOUNT_REFRESH_BATCH_SIZE) - await Promise.all(batch.map(async (id) => { - try { - const refreshed = await refreshAccount(id, { quota: forceQuota }) - setAccounts((current) => current.map((account) => account.id === id ? refreshed : account)) - } catch (error) { - // Surface the failure to the caller instead of swallowing it: a - // batch where every account failed must not report success. - const message = error instanceof Error ? error.message : String(error) - failures.set(id, message) - setNoteById((current) => ({ ...current, [id]: message })) + /** Single-account refresh: the response is the real post-probe row. */ + const refreshOne = useCallback(async (id: string, forceQuota = true) => { + const refreshed = await refreshAccount(id, { quota: forceQuota }) + setAccounts((current) => current.map((account) => account.id === id ? { ...account, ...refreshed } : account)) + }, []) + + /** + * One-shot refresh for every account. The backend fans out to all accounts + * concurrently — no client batching, no queue — and every row returns the + * real probe outcome with the verbatim upstream error. + */ + const refreshEveryAccount = useCallback(async (forceQuota = true) => { + const response = await refreshAllAccounts({ quota: forceQuota }) + const results = response.data || [] + const notes: Record = {} + const errors: string[] = [] + const quotas: Record> = {} + let failed = 0 + for (const result of results) { + if (result.ok) { + if (result.quota) quotas[result.account_id] = result.quota + continue + } + failed += 1 + const message = result.message || result.code || result.kind || t('toastFailed') + notes[result.account_id] = message + errors.push(message) + } + if (Object.keys(quotas).length) { + setAccounts((current) => current.map((account) => quotas[account.id] + ? { ...account, quota: quotas[account.id] } + : account)) + } + if (failed) setNoteById((current) => ({ ...current, ...notes })) + // Events already patch rows as they land; this pull keeps the list truthful + // when the stream is offline. + await reloadAccounts(false).catch(() => undefined) + return { total: results.length, failed, errors } + }, [reloadAccounts, t]) + + /** + * Events patch rows in place for instant feedback; a trailing debounced re-read + * then reconciles every field with the server's truth (derived status, hot + * flags, fields the event does not carry) without a manual reload. + */ + const reconcileTimer = useRef(null) + const scheduleReconcile = useCallback(() => { + if (reconcileTimer.current != null) return + reconcileTimer.current = window.setTimeout(() => { + reconcileTimer.current = null + void reloadAccounts(false).catch(() => undefined) + }, 400) + }, [reloadAccounts]) + + const onAccountEvent = useCallback((event: ServerEvent) => { + const type = event.type + if (type === 'account') { + const data = (event.data || {}) as AccountStateEvent + const id = data.account_id || event.account_id + if (!id) return + setAccounts((current) => current.map((account) => { + if (account.id !== id) return account + const next = { ...account } + if (data.runtime_state) next.runtime_state = data.runtime_state + if (typeof data.ready === 'boolean') { + next.ready = data.ready + if (data.ready) next.hot = account.hot && data.runtime_state !== 'ready' } + if (data.cooldown_until) next.cooldown_until = data.cooldown_until + else if (data.ready) next.cooldown_until = null + if (data.last_error !== undefined) { + next.last_error = data.last_error + next.lastError = data.last_error || undefined + } + if (data.last_kind !== undefined) next.last_error_kind = data.last_kind || undefined + return next + })) + scheduleReconcile() + return + } + if (type === 'quota') { + const data = (event.data || {}) as QuotaStateEvent + const id = data.account_id || event.account_id + if (!id || !data.quota) return + setAccounts((current) => current.map((account) => account.id === id ? { ...account, quota: data.quota } : account)) + scheduleReconcile() + return + } + if (type === 'checkin') { + const data = (event.data || {}) as CheckinStateEvent + const id = data.account_id || event.account_id + if (!id) return + const status = String(data.status || '').toLowerCase() + const kind = status === 'already' || status === 'skipped' || status === 'error' || status === 'unknown' + ? status + : 'success' + const reward = typeof data.reward_credits === 'number' && data.reward_credits > 0 + ? t('checkinRewardSuffix', { credits: formatQuotaAmount(data.reward_credits) }) + : '' + const message = `${data.message || (kind === 'error' ? t('checkinRecordFailed') : kind === 'unknown' ? t('checkinStatusUnknown') : '')}${reward}`.trim() + setCheckinFeedbackById((current) => ({ + ...current, + [id]: { kind, message: message || undefined }, })) + setAccounts((current) => current.map((account) => account.id === id + ? { + ...account, + last_checkin_status: data.status || account.last_checkin_status, + last_checkin_msg: data.message || account.last_checkin_msg, + last_checkin_at: data.at || account.last_checkin_at, + } + : account)) + return + } + if (type === 'accounts') { + void reloadAccounts(false).catch(() => undefined) + return } - return { total, failed: failures.size, errors: [...failures.values()] } + if (type === 'bulk') { + const data = (event.data || {}) as BulkEventData + const kind = data.kind === 'refresh' ? 'refresh' : data.kind === 'checkin' ? 'checkin' : null + if (!kind) return + if (data.phase === 'done') { + setBulkProgress(null) + return + } + if (!data.total) return + setBulkProgress({ kind, total: data.total, done: data.done || 0 }) + } + }, [reloadAccounts, scheduleReconcile, t]) + + const { status: eventStatus } = useAccountEvents(onAccountEvent) + + useEffect(() => () => { + if (reconcileTimer.current != null) window.clearTimeout(reconcileTimer.current) }, []) useEffect(() => { void reloadAccounts(false).catch(() => undefined) }, [reloadAccounts]) + // The page no longer re-probes every account on mount: the background quota + // sweep already keeps snapshots fresh, and the event stream patches rows live. + useEffect(() => { + if (eventStatus === 'live') return + // Stream unavailable (401/offline): fall back to a 5s list poll so the page + // still converges on real state without manual refreshes. + const timer = window.setInterval(() => { + if (document.hidden) return + void reloadAccounts(false).catch(() => undefined) + }, 5000) + return () => window.clearInterval(timer) + }, [eventStatus, reloadAccounts]) useEffect(() => { let active = true void Promise.all([fetchProviders(), fetchSystemSettings()]).then(([providerData, systemData]) => { @@ -195,18 +338,9 @@ export function AccountsPage() { }) return () => { active = false } }, []) - // Each time the page mounts (navigated into), re-pull the real upstream - // quota and last check-in status so cards show the freshest state. - useEffect(() => { - let active = true - void reloadAccounts(false) - .then((next) => { - if (!active) return - return refreshAccountsInBatches((next || []).map((account) => account.id)) - }) - .catch(() => undefined) - return () => { active = false } - }, [reloadAccounts, refreshAccountsInBatches]) + // On mount the page reads the real stored state once. It no longer re-probes + // every account: the background quota sweep keeps snapshots fresh and the + // event stream patches cards live, so mounting stays cheap and truthful. function checkinPolicyFor(account: AccountRow) { return providers.find((provider) => provider.id === account.provider)?.regions.find((region) => region.id === account.region)?.checkin @@ -290,6 +424,10 @@ export function AccountsPage() { const start = (currentPage - 1) * pageSize return filteredRows.slice(start, start + pageSize) }, [currentPage, filteredRows, pageSize]) + const reloginAccounts = useMemo( + () => rows.filter((account) => reloginSelected.includes(account.id)), + [rows, reloginSelected], + ) if (accountsLoading && !hasAccounts) return @@ -323,7 +461,7 @@ export function AccountsPage() { if (login.status === 'ok' || login.status === 'error') break } await reloadAccounts(false) - await refreshAccountsInBatches([id]) + await refreshOne(id) }) } @@ -338,7 +476,7 @@ export function AccountsPage() { await completeLoginCallback(id, pasted) setCallbackById((current) => ({ ...current, [id]: '' })) await reloadAccounts(false) - await refreshAccountsInBatches([id]) + await refreshOne(id) }) if (ok) { setAuthPanelId((current) => (current === id ? null : current)) @@ -357,7 +495,7 @@ export function AccountsPage() { await loginWithPat(pat, id) setPatById((current) => ({ ...current, [id]: '' })) await reloadAccounts(false) - await refreshAccountsInBatches([id]) + await refreshOne(id) }) } @@ -481,17 +619,12 @@ export function AccountsPage() { return next }) try { - const result = await refreshAccountsInBatches([id]) - if (result.failed > 0) { - toast({ - id: `refresh-${id}`, - type: 'error', - title: t('toastFailed'), - description: result.errors[0] || t('toastFailed'), - }) - return - } + await refreshOne(id) toast({ id: `refresh-${id}`, type: 'success', title: t('toastAccountRefreshed') }) + } catch (error) { + const message = error instanceof Error ? error.message : String(error) + setNoteById((current) => ({ ...current, [id]: message })) + toast({ id: `refresh-${id}`, type: 'error', title: t('toastFailed'), description: message }) } finally { setBusy(null) } @@ -501,7 +634,7 @@ export function AccountsPage() { setQuotaRefreshing(true) toast({ id: 'refresh-credits', type: 'loading', title: t('toastRefreshingCredits') }) try { - const result = await refreshAccountsInBatches(accounts.map((account) => account.id)) + const result = await refreshEveryAccount(true) if (result.failed > 0) { // Report a partial failure honestly: some accounts refreshed fine, so // name how many failed instead of implying the whole batch did. @@ -517,6 +650,14 @@ export function AccountsPage() { return } toast({ id: 'refresh-credits', type: 'success', title: t('toastCreditsRefreshed') }) + } catch (error) { + // A whole-request failure (network / console key) surfaces verbatim. + toast({ + id: 'refresh-credits', + type: 'error', + title: t('toastFailed'), + description: error instanceof Error ? error.message : String(error), + }) } finally { setQuotaRefreshing(false) } @@ -609,25 +750,51 @@ export function AccountsPage() { toast({ id: 'checkin-all', type: 'info', title: t('checkinAllEmpty') }) return } - const summary = { checked: 0, skipped: 0, failed: 0 } - const feedback: Record = {} + const summary = { checked: 0, skipped: 0, failed: 0, unknown: 0, credits: 0 } + const feedback: Record = {} + const notes: Record = {} + let firstError = '' for (const result of results) { const raw = String(result.status || '').toLowerCase() - const kind = raw === 'already' || raw === 'skipped' || raw === 'error' ? raw : 'success' - if (kind === 'error') summary.failed += 1 - else if (kind === 'skipped' || kind === 'already') summary.skipped += 1 + const kind: CheckinFeedback['kind'] = raw === 'already' || raw === 'skipped' || raw === 'error' || raw === 'unknown' + ? raw + : 'success' + if (kind === 'error') { + summary.failed += 1 + if (!firstError) firstError = result.message || '' + } else if (kind === 'skipped' || kind === 'already') summary.skipped += 1 + else if (kind === 'unknown') summary.unknown += 1 else summary.checked += 1 - feedback[result.account_id] = { - kind, - message: kind === 'error' ? result.message || t('checkinRecordFailed') : result.message, + // Real upstream grant only — omitted when the provider reported none. + if (typeof result.reward_credits === 'number' && result.reward_credits > 0) { + summary.credits += result.reward_credits + } + const reward = result.reward_credits && result.reward_credits > 0 + ? t('checkinRewardSuffix', { credits: formatQuotaAmount(result.reward_credits) }) + : '' + const message = `${result.message || (kind === 'error' ? t('checkinRecordFailed') : kind === 'unknown' ? t('checkinStatusUnknown') : '')}${reward}`.trim() + feedback[result.account_id] = { kind, message: message || undefined } + // Keep the verbatim upstream classification on the card so a failure + // never collapses into a generic "failed". + if (kind === 'error') { + notes[result.account_id] = [ + result.message, + result.code, + result.http_status ? `HTTP ${result.http_status}` : '', + ].filter(Boolean).join(' · ') || t('checkinRecordFailed') } } setCheckinFeedbackById((current) => ({ ...current, ...feedback })) - const values = { checked: summary.checked, skipped: summary.skipped, failed: summary.failed } + if (Object.keys(notes).length) setNoteById((current) => ({ ...current, ...notes })) + const values = { checked: summary.checked, skipped: summary.skipped, failed: summary.failed, total: results.length } + const description = summary.credits > 0 + ? t('checkinRewardTotal', { credits: formatQuotaAmount(summary.credits) }) + : summary.failed && firstError ? firstError : undefined toast({ id: 'checkin-all', - type: summary.failed ? 'error' : 'success', + type: summary.failed ? 'error' : summary.unknown ? 'info' : 'success', title: t(summary.failed ? 'toastCheckedInAllFailed' : 'toastCheckedInAll', values), + description, }) } catch (error) { toast({ @@ -653,12 +820,12 @@ export function AccountsPage() { [id]: { kind: 'error', message: error instanceof Error ? error.message : String(error) }, })) await reloadAccounts(false).catch(() => undefined) - await refreshAccountsInBatches([id]).catch(() => undefined) + await refreshOne(id).catch(() => undefined) return } const status = result?.last_checkin_status const message = result?.last_checkin_msg - const kind = status === 'already' ? 'already' : status === 'skipped' ? 'skipped' : status === 'error' ? 'error' : 'success' + const kind = status === 'already' ? 'already' : status === 'skipped' ? 'skipped' : status === 'error' ? 'error' : status === 'unknown' ? 'unknown' : 'success' setCheckinFeedbackById((current) => ({ ...current, [id]: { kind, message: kind === 'error' ? message || t('checkinRecordFailed') : message }, @@ -666,7 +833,7 @@ export function AccountsPage() { await reloadAccounts(false).catch(() => undefined) // Pull the real upstream quota/credits once more so the card reflects // the check-in grant (do not rely on the check-in response alone). - await refreshAccountsInBatches([id]).catch(() => undefined) + await refreshOne(id).catch(() => undefined) }) } @@ -785,6 +952,17 @@ export function AccountsPage() { + {/* Mobile Safari ignores programmatic input.click() from React Aria onPress when the file input is display:none. Associate a real @@ -810,8 +988,38 @@ export function AccountsPage() { />
+ {eventStatus === 'offline' ? ( + + + {t('eventsOffline')} + + ) : null} + {bulkProgress ? ( +
+ + + {bulkProgress.kind === 'checkin' ? t('checkinAll') : t('refreshCredits')} + + + {bulkProgress.done}/{bulkProgress.total} + +
+
+
+
+ ) : null} + setAddOpen(false)} onAdded={() => { toast({ type: 'success', title: t('toastAccountAdded') }); void reloadAccounts(false) }} /> { void onBatchImportConfirm(region) }} /> setModelsId(null)} /> + { setReloginOpen(false); setReloginMode(false); setReloginSelected([]) }} + onFinished={() => { void reloadAccounts(false) }} + /> setCheckinHistoryId(null)} /> ) : null} + {reloginMode ? ( +
+ {t('reloginSelected', { count: reloginSelected.length })} + + +
+ + +
+
+ ) : null} +
{pagedRows.map((account) => ( setReloginSelected((current) => ( + current.includes(account.id) ? current.filter((id) => id !== account.id) : [...current, account.id] + ))} busyKind={busy?.id === account.id ? busy.kind : ''} authPanelOpen={authPanelId === account.id} authUrl={urlById[account.id]} diff --git a/frontend/src/pages/KeysPage.tsx b/frontend/src/pages/KeysPage.tsx index 70df25b0..9c247f67 100644 --- a/frontend/src/pages/KeysPage.tsx +++ b/frontend/src/pages/KeysPage.tsx @@ -482,8 +482,9 @@ function KeyEditorModal({ {options.map((option) => { const checked = selected.includes(option.value) const allRegions = allRegionsFamilies.has(option.provider) + const locked = busy || modelAggregation return ( - toggle(option.value)} className="rounded-xl bg-surface-secondary px-3 py-2.5 data-selected:border-accent data-selected:bg-accent-soft"> + toggle(option.value)} className={`rounded-xl bg-surface-secondary px-3 py-2.5 data-selected:border-accent data-selected:bg-accent-soft ${locked ? 'cursor-not-allowed opacity-50 grayscale' : ''}`}> diff --git a/frontend/src/pages/LoginPage.tsx b/frontend/src/pages/LoginPage.tsx index e85635c3..817a7451 100644 --- a/frontend/src/pages/LoginPage.tsx +++ b/frontend/src/pages/LoginPage.tsx @@ -3,7 +3,6 @@ import { Navigate, useLocation, useNavigate } from 'react-router-dom' import { Button, Card, InputGroup, Label, TextField, Toolbar, Tooltip } from '@heroui/react' import { ArrowRight, Eye, EyeSlash, Globe, Moon, Sun } from '@phosphor-icons/react' import { BrandMark } from '@/components/BrandMark' -import { InflightLiveCard } from '@/components/overview/InflightLiveCard' import { PageAlert } from '@/components/ui/PageAlert' import { useI18n } from '@/hooks/useI18n' import { useApiKey } from '@/hooks/useApiKey' @@ -82,11 +81,7 @@ export function LoginPage() { -
- -
- -
+
{t('loginHint')} {t('routesHint')}
diff --git a/frontend/src/pages/ModelPoolPage.tsx b/frontend/src/pages/ModelPoolPage.tsx index 74818c09..66c21e49 100644 --- a/frontend/src/pages/ModelPoolPage.tsx +++ b/frontend/src/pages/ModelPoolPage.tsx @@ -5,6 +5,7 @@ import { Button, Card, Chip, + Checkbox, Description, Form, Input, @@ -42,6 +43,19 @@ import { accountProviderLabel } from '@/lib/provider' type TFunc = (key: string, vars?: Record) => string type AccountRow = NonNullable[number] +const REASONING_LEVELS = ['none', 'low', 'medium', 'high', 'xhigh', 'max'] as const + +// One caption per tier so the selector never reads as six bare words: the +// console has to say what each level means before it is picked. +const REASONING_LEVEL_HINTS: Record = { + none: 'modelPoolReasoningLevelNone', + low: 'modelPoolReasoningLevelLow', + medium: 'modelPoolReasoningLevelMedium', + high: 'modelPoolReasoningLevelHigh', + xhigh: 'modelPoolReasoningLevelXhigh', + max: 'modelPoolReasoningLevelMax', +} + type MemberDraft = AggregationMember & { key: string } function newMemberDraft(): MemberDraft { @@ -303,6 +317,10 @@ function AggregationEditorModal({ const [strategy, setStrategy] = useState('priority') const [allowFallbacks, setAllowFallbacks] = useState(true) const [maxAttempts, setMaxAttempts] = useState(3) + const [contextLength, setContextLength] = useState(0) + const [maxOutput, setMaxOutput] = useState(0) + const [reasoningOptions, setReasoningOptions] = useState([]) + const [reasoningEffort, setReasoningEffort] = useState('') const [members, setMembers] = useState([]) const [error, setError] = useState('') const [busy, setBusy] = useState(false) @@ -314,6 +332,10 @@ function AggregationEditorModal({ setStrategy(initial?.strategy || 'priority') setAllowFallbacks(initial?.allow_fallbacks ?? true) setMaxAttempts(initial?.max_attempts ?? 3) + setContextLength(initial?.context_length ?? 0) + setMaxOutput(initial?.max_output_tokens ?? 0) + setReasoningOptions(initial?.reasoning_options ?? []) + setReasoningEffort(initial?.reasoning_effort ?? '') setMembers((initial?.members || []).map((m) => ({ ...m, key: `${m.provider}-${m.model}-${Math.random()}` }))) setError('') }, [initial, isOpen]) @@ -339,26 +361,47 @@ function AggregationEditorModal({ }) } + function toggleReasoningLevel(level: string) { + const next = reasoningOptions.includes(level) + ? reasoningOptions.filter((item) => item !== level) + : [...reasoningOptions, level] + setReasoningOptions(next) + if (reasoningEffort && !next.includes(reasoningEffort)) setReasoningEffort('') + } + async function submit(event?: { preventDefault(): void }) { event?.preventDefault() if (!initial) { const trimmed = id.trim().toLowerCase() if (!trimmed) { setError(t('modelPoolIdRequired')); return } + if (!/^[a-z0-9.\-\/]+$/.test(trimmed)) { setError(t('modelPoolIdInvalid')); return } } - if (!name.trim()) { setError(t('modelPoolNameRequired')); return } if (!members.length) { setError(t('modelPoolMembersRequired')); return } if (members.some((m) => !m.provider || !m.model)) { setError(t('modelPoolMemberIncomplete')); return } if (!Number.isInteger(maxAttempts) || maxAttempts < 1 || maxAttempts > 64) { setError(t('modelPoolAttemptsInvalid')); return } + if (!Number.isInteger(contextLength) || contextLength < 0) { + setError(t('modelPoolCapabilitiesInvalid')); return + } + if (!Number.isInteger(maxOutput) || maxOutput < 0) { + setError(t('modelPoolCapabilitiesInvalid')); return + } + if (reasoningEffort && !reasoningOptions.includes(reasoningEffort)) { + setError(t('modelPoolReasoningInvalid')); return + } setBusy(true) setError('') try { const payload: AggregationInput = { - name: name.trim(), + name: name.trim() || (initial?.id || id.trim().toLowerCase()), strategy, allow_fallbacks: allowFallbacks, max_attempts: maxAttempts, + context_length: contextLength, + max_output_tokens: maxOutput, + reasoning_options: reasoningOptions, + reasoning_effort: reasoningEffort, members: members.map((m, i) => ({ provider: m.provider, region: m.region || '', @@ -393,15 +436,12 @@ function AggregationEditorModal({ - {error ? ( - {error} - ) : null} {!initial ? ( setId(e.target.value)} placeholder="my-claude" aria-label={t('modelPoolId')} disabled={busy} /> ) : null} - + setName(e.target.value)} placeholder={t('modelPoolNamePh')} aria-label={t('modelPoolName')} disabled={busy} /> @@ -421,6 +461,98 @@ function AggregationEditorModal({
+
+
+ + {t('modelPoolCapabilitiesHint')} +
+
+ + setContextLength(v ?? 0)} minValue={0} maxValue={4000000} isDisabled={busy}> + + + + + + + + + setMaxOutput(v ?? 0)} minValue={0} maxValue={4000000} isDisabled={busy}> + + + + + + + +
+ +
+
+ + {t('modelPoolReasoningSelected', { n: reasoningOptions.length, total: REASONING_LEVELS.length })} + +
+ + +
+
+
+ {REASONING_LEVELS.map((level) => { + const selected = reasoningOptions.includes(level) + return ( + toggleReasoningLevel(level)} + className={`rounded-xl border px-3 py-2 transition-colors ${selected ? 'border-accent bg-surface-secondary' : 'border-separator hover:bg-surface-secondary/60'}`} + > + + + + {level} + {t(REASONING_LEVEL_HINTS[level])} + + + + ) + })} +
+ {reasoningOptions.length === 0 ? ( + {t('modelPoolReasoningEmpty')} + ) : null} +
+
+ + ({ id: level, label: level }))]} + className="w-full" + isDisabled={busy || reasoningOptions.length === 0} + /> + +
+
@@ -483,6 +615,11 @@ function AggregationEditorModal({ )}
+ {error ? ( +
+ {error} +
+ ) : null} diff --git a/frontend/src/pages/OverviewPage.tsx b/frontend/src/pages/OverviewPage.tsx index a2ff803e..432138ac 100644 --- a/frontend/src/pages/OverviewPage.tsx +++ b/frontend/src/pages/OverviewPage.tsx @@ -12,6 +12,7 @@ import { TrendUp, } from '@phosphor-icons/react' import { fetchRequestStats, type RequestStats } from '@/api/logs' +import { useAccountEvents } from '@/hooks/useAccountEvents' import { fetchSystemResources, type SystemResources } from '@/api/system' import type { Overview } from '@/api/types' import { CountUp } from '@/components/overview/CountUp' @@ -130,7 +131,7 @@ function quotaTone(percentage?: number, exceeded?: boolean) { export function OverviewPage() { const { lang, t } = useI18n() - const { overview, loading, error } = useOverview() + const { overview, loading, error, refresh } = useOverview() const [statsWindow, setStatsWindow] = useState('today') const [customRange, setCustomRange] = useState(null) const [paused, setPaused] = useState(false) @@ -145,7 +146,7 @@ export function OverviewPage() { const [now, setNow] = useState(() => Date.now()) const [inflightOpen, setInflightOpen] = useState(false) const [coolingOpen, setCoolingOpen] = useState(false) - const { live, samples: liveSamples } = useLive({ + const { live, samples: liveSamples, error: liveError } = useLive({ intervalMs: inflightOpen ? LIVE_POLL_EXPANDED_MS : LIVE_POLL_MS, }) const liveById = new Map((live?.accounts ?? []).map((item) => [item.id, item])) @@ -201,6 +202,44 @@ export function OverviewPage() { return () => { cancelled = true } }, []) + /** + * Real-time convergence: every runtime event (pool health, cooldown, quota, + * check-in, bulk progress) debounces into one cheap re-read of the account + * list plus a silent overview refresh, so counts move within ~a second of the + * backend changing instead of waiting for a manual reload. + */ + const reloadAccounts = useCallback(() => { + void fetchAccounts(false) + .then((res) => setAccounts(res.data || [])) + .catch(() => { /* keep the last good list */ }) + }, []) + const eventRefreshTimer = useRef(null) + const onRuntimeEvent = useCallback(() => { + if (eventRefreshTimer.current != null) return + eventRefreshTimer.current = window.setTimeout(() => { + eventRefreshTimer.current = null + reloadAccounts() + void refresh(undefined, { silent: true }).catch(() => { /* keep last good summary */ }) + }, 600) + }, [refresh, reloadAccounts]) + const { status: eventStatus } = useAccountEvents(onRuntimeEvent) + useEffect(() => { + return () => { + if (eventRefreshTimer.current != null) window.clearTimeout(eventRefreshTimer.current) + } + }, []) + // Degraded path: when the stream is not live (401 / network / unsupported), + // poll the same real endpoints every 5s instead of showing stale numbers. + useEffect(() => { + if (eventStatus === 'live') return + const timer = window.setInterval(() => { + if (document.hidden) return + reloadAccounts() + void refresh(undefined, { silent: true }).catch(() => { /* keep last good summary */ }) + }, 5000) + return () => window.clearInterval(timer) + }, [eventStatus, reloadAccounts, refresh]) + const customFrom = customRange?.start?.toString() ?? '' const customTo = customRange?.end?.toString() ?? '' const statsRequestRef = useRef(0) @@ -358,7 +397,7 @@ export function OverviewPage() { setInflightOpen(true)} /> - +
{metrics.map((metric) => ( diff --git a/frontend/src/pages/ProvidersPage.tsx b/frontend/src/pages/ProvidersPage.tsx index 23b294f0..1f8d6f19 100644 --- a/frontend/src/pages/ProvidersPage.tsx +++ b/frontend/src/pages/ProvidersPage.tsx @@ -99,6 +99,9 @@ function groupModelsByProvider(models: ModelInfo[], t: Translate): ModelGroup[] const groups = new Map() for (const model of models) { const provider = modelProvider(model) + // "aggregation" is the model-pool's synthetic logical-model label, not a + // upstream provider. Never render it as a provider or a settings card. + if (provider === 'aggregation') continue const region = modelRegion(model) const key = `${provider}:${region || 'any'}` let group = groups.get(key) @@ -173,11 +176,14 @@ function ModelContextControls({ }) { const provider = modelProvider(model) const isCard = variant === 'card' - const defaultWindow = model.catalog_context_length || model.context_length + // The effective window already carries the unlocked tier for providers that + // ask upstream for the larger context on every request (Trae), so only Qoder + // still exposes a selectable window. + const defaultWindow = model.context_length || model.catalog_context_length const maxWindow = model.catalog_context_length_max const hasMaxWindow = Boolean(maxWindow && maxWindow !== defaultWindow) const reasoningOptions = model.reasoning_options || [] - const canToggleMax = (provider === 'trae' || provider === 'qoder') && model.supports_max_mode + const canToggleMax = provider === 'qoder' && Boolean(model.supports_max_mode) const reasoningText = reasoningOptions.length ? reasoningOptions.join(' / ') : model.reasoning_type diff --git a/internal/accounts/aggregation.go b/internal/accounts/aggregation.go index 9f3ac808..addbaf7e 100644 --- a/internal/accounts/aggregation.go +++ b/internal/accounts/aggregation.go @@ -5,6 +5,8 @@ import ( "sort" "strings" "time" + + "github.com/caigee-cmd/cli2api/internal/providers" ) // AggregationStrategy is the routing strategy for one logical aggregation @@ -47,28 +49,48 @@ type Aggregation struct { Strategy AggregationStrategy `json:"strategy"` AllowFallbacks bool `json:"allow_fallbacks"` MaxAttempts int `json:"max_attempts"` - Members []AggregationMember `json:"members"` - CreatedAt time.Time `json:"created_at"` - UpdatedAt time.Time `json:"updated_at"` + // ContextLength overrides the context window advertised for the logical + // model. Zero keeps the conservative value derived from the members. + ContextLength int `json:"context_length,omitempty"` + // MaxOutputTokens overrides the largest output advertised for the logical + // model. Zero keeps the members' conservative value. + MaxOutputTokens int `json:"max_output_tokens,omitempty"` + // ReasoningOptions pins the reasoning levels the logical model advertises. + // Empty keeps the intersection of the members' declared levels. + ReasoningOptions []string `json:"reasoning_options,omitempty"` + // ReasoningEffort is the default reasoning level advertised for the logical + // model. It is a default only: a client may still request any other level. + ReasoningEffort string `json:"reasoning_effort,omitempty"` + Members []AggregationMember `json:"members"` + CreatedAt time.Time `json:"created_at"` + UpdatedAt time.Time `json:"updated_at"` } type CreateAggregation struct { - ID string - Name string - Enabled bool - Strategy AggregationStrategy - AllowFallbacks bool - MaxAttempts int - Members []AggregationMember + ID string + Name string + Enabled bool + Strategy AggregationStrategy + AllowFallbacks bool + MaxAttempts int + ContextLength int + MaxOutputTokens int + ReasoningOptions []string + ReasoningEffort string + Members []AggregationMember } type UpdateAggregation struct { - Name *string - Enabled *bool - Strategy *AggregationStrategy - AllowFallbacks *bool - MaxAttempts *int - Members *[]AggregationMember + Name *string + Enabled *bool + Strategy *AggregationStrategy + AllowFallbacks *bool + MaxAttempts *int + ContextLength *int + MaxOutputTokens *int + ReasoningOptions *[]string + ReasoningEffort *string + Members *[]AggregationMember } // NormalizeAggregationStrategy keeps the per-model strategy inside the four @@ -160,10 +182,88 @@ func normalizeAggregationMaxAttempts(value int) int { return value } +// reasoningOrderIndex positions a normalized level on the gateway vocabulary so +// the advertised list is deterministic. Unknown levels sort last. +func reasoningOrderIndex(level string) int { + for index, option := range providers.GatewayReasoningOptions() { + if option == level { + return index + } + } + return len(providers.GatewayReasoningOptions()) +} + +func normalizeAggregationReasoningOptions(raw []string) ([]string, error) { + if len(raw) == 0 { + return nil, nil + } + out := make([]string, 0, len(raw)) + seen := map[string]bool{} + for _, value := range raw { + level := providers.NormalizeReasoningLevel(value) + if level == "" { + return nil, fmt.Errorf("unsupported reasoning level %q", strings.TrimSpace(value)) + } + if seen[level] { + continue + } + seen[level] = true + out = append(out, level) + } + sort.Slice(out, func(i, j int) bool { + return reasoningOrderIndex(out[i]) < reasoningOrderIndex(out[j]) + }) + return out, nil +} + +func normalizeAggregationReasoningEffort(raw string, options []string) (string, error) { + raw = strings.TrimSpace(raw) + if raw == "" { + return "", nil + } + level := providers.NormalizeReasoningLevel(raw) + if level == "" { + return "", fmt.Errorf("unsupported reasoning effort %q", raw) + } + if len(options) == 0 { + return "", fmt.Errorf("reasoning_effort requires reasoning_options") + } + for _, option := range options { + if option == level { + return level, nil + } + } + return "", fmt.Errorf("reasoning_effort %q must be one of the configured reasoning options", level) +} + +// normalizeAggregationCapabilities validates the logical model's advertised +// capability overrides. Zero/empty values mean "derive from the members", so an +// unspecified aggregation behaves exactly like before this feature. +func normalizeAggregationCapabilities(contextLength, maxOutput int, options []string, effort string) (int, int, []string, string, error) { + if contextLength < 0 || contextLength > 4_000_000 { + return 0, 0, nil, "", fmt.Errorf("aggregation context_length must be between 0 and 4000000") + } + if maxOutput < 0 || maxOutput > 4_000_000 { + return 0, 0, nil, "", fmt.Errorf("aggregation max_output_tokens must be between 0 and 4000000") + } + normalizedOptions, err := normalizeAggregationReasoningOptions(options) + if err != nil { + return 0, 0, nil, "", err + } + normalizedEffort, err := normalizeAggregationReasoningEffort(effort, normalizedOptions) + if err != nil { + return 0, 0, nil, "", err + } + return contextLength, maxOutput, normalizedOptions, normalizedEffort, nil +} + func PrepareCreateAggregation(input CreateAggregation) (CreateAggregation, error) { id := strings.ToLower(strings.TrimSpace(input.ID)) + if id == "" { + return CreateAggregation{}, fmt.Errorf("aggregation id required") + } if !validAggregationID(id) { - return CreateAggregation{}, fmt.Errorf("aggregation id required (lowercase letters, digits, '-' and '/')") + return CreateAggregation{}, fmt.Errorf("aggregation id may only contain lowercase letters, digits, '.', '-' and '/', got %q", id) } name := strings.TrimSpace(input.Name) if name == "" { @@ -176,14 +276,24 @@ func PrepareCreateAggregation(input CreateAggregation) (CreateAggregation, error if err != nil { return CreateAggregation{}, err } + contextLength, maxOutput, options, effort, err := normalizeAggregationCapabilities( + input.ContextLength, input.MaxOutputTokens, input.ReasoningOptions, input.ReasoningEffort, + ) + if err != nil { + return CreateAggregation{}, err + } return CreateAggregation{ - ID: id, - Name: name, - Enabled: input.Enabled, - Strategy: NormalizeAggregationStrategy(string(input.Strategy)), - AllowFallbacks: input.AllowFallbacks, - MaxAttempts: normalizeAggregationMaxAttempts(input.MaxAttempts), - Members: members, + ID: id, + Name: name, + Enabled: input.Enabled, + Strategy: NormalizeAggregationStrategy(string(input.Strategy)), + AllowFallbacks: input.AllowFallbacks, + MaxAttempts: normalizeAggregationMaxAttempts(input.MaxAttempts), + ContextLength: contextLength, + MaxOutputTokens: maxOutput, + ReasoningOptions: options, + ReasoningEffort: effort, + Members: members, }, nil } @@ -207,6 +317,18 @@ func ApplyAggregationUpdate(current Aggregation, input UpdateAggregation) (Aggre if input.MaxAttempts != nil { current.MaxAttempts = normalizeAggregationMaxAttempts(*input.MaxAttempts) } + if input.ContextLength != nil { + current.ContextLength = *input.ContextLength + } + if input.MaxOutputTokens != nil { + current.MaxOutputTokens = *input.MaxOutputTokens + } + if input.ReasoningOptions != nil { + current.ReasoningOptions = *input.ReasoningOptions + } + if input.ReasoningEffort != nil { + current.ReasoningEffort = *input.ReasoningEffort + } if input.Members != nil { members, err := normalizeAggregationMembers(*input.Members) if err != nil { @@ -214,6 +336,16 @@ func ApplyAggregationUpdate(current Aggregation, input UpdateAggregation) (Aggre } current.Members = members } + contextLength, maxOutput, options, effort, err := normalizeAggregationCapabilities( + current.ContextLength, current.MaxOutputTokens, current.ReasoningOptions, current.ReasoningEffort, + ) + if err != nil { + return Aggregation{}, err + } + current.ContextLength = contextLength + current.MaxOutputTokens = maxOutput + current.ReasoningOptions = options + current.ReasoningEffort = effort return current, nil } @@ -222,7 +354,7 @@ func validAggregationID(id string) bool { return false } for _, r := range id { - if (r >= 'a' && r <= 'z') || (r >= '0' && r <= '9') || r == '-' || r == '/' { + if (r >= 'a' && r <= 'z') || (r >= '0' && r <= '9') || r == '-' || r == '/' || r == '.' { continue } return false diff --git a/internal/accounts/aggregation_capabilities_test.go b/internal/accounts/aggregation_capabilities_test.go new file mode 100644 index 00000000..f2e57abc --- /dev/null +++ b/internal/accounts/aggregation_capabilities_test.go @@ -0,0 +1,118 @@ +package accounts + +import ( + "strings" + "testing" +) + +func capabilityTestCreate() CreateAggregation { + return CreateAggregation{ + ID: "pool", + Name: "Pool", + Enabled: true, + Members: []AggregationMember{{Provider: "qoder", Model: "glm-5.2"}}, + } +} + +func TestPrepareCreateAggregationNormalizesCapabilities(t *testing.T) { + input := capabilityTestCreate() + input.ContextLength = 1_000_000 + input.MaxOutputTokens = 32_000 + input.ReasoningOptions = []string{"HIGH", "low", "max", "high"} + input.ReasoningEffort = "HIGH" + + got, err := PrepareCreateAggregation(input) + if err != nil { + t.Fatal(err) + } + if got.ContextLength != 1_000_000 || got.MaxOutputTokens != 32_000 { + t.Fatalf("numeric caps = %d/%d", got.ContextLength, got.MaxOutputTokens) + } + if len(got.ReasoningOptions) != 3 || got.ReasoningOptions[0] != "low" || got.ReasoningOptions[1] != "high" || got.ReasoningOptions[2] != "max" { + t.Fatalf("options = %v", got.ReasoningOptions) + } + if got.ReasoningEffort != "high" { + t.Fatalf("effort = %q", got.ReasoningEffort) + } +} + +func TestPrepareCreateAggregationRejectsInvalidCapabilities(t *testing.T) { + cases := []struct { + name string + mutate func(*CreateAggregation) + want string + }{ + {"unknown level", func(in *CreateAggregation) { in.ReasoningOptions = []string{"turbo"} }, "unsupported reasoning level"}, + {"effort without options", func(in *CreateAggregation) { in.ReasoningEffort = "high" }, "requires reasoning_options"}, + {"effort outside options", func(in *CreateAggregation) { + in.ReasoningOptions = []string{"low", "medium"} + in.ReasoningEffort = "high" + }, "must be one of the configured reasoning options"}, + {"negative context", func(in *CreateAggregation) { in.ContextLength = -1 }, "context_length must be"}, + {"negative output", func(in *CreateAggregation) { in.MaxOutputTokens = -1 }, "max_output_tokens must be"}, + } + for _, tc := range cases { + t.Run(tc.name, func(t *testing.T) { + input := capabilityTestCreate() + tc.mutate(&input) + _, err := PrepareCreateAggregation(input) + if err == nil || !strings.Contains(err.Error(), tc.want) { + t.Fatalf("err = %v, want %q", err, tc.want) + } + }) + } +} + +func TestPrepareCreateAggregationAcceptsUnconstrainedCapabilities(t *testing.T) { + input := capabilityTestCreate() + // The console mirrors CC Switch: no 1024 floor and no max-output <= context + // rule, so an operator can declare whatever the upstream really accepts. + input.ContextLength = 512 + input.MaxOutputTokens = 64_000 + + got, err := PrepareCreateAggregation(input) + if err != nil { + t.Fatal(err) + } + if got.ContextLength != 512 || got.MaxOutputTokens != 64_000 { + t.Fatalf("numeric caps = %d/%d", got.ContextLength, got.MaxOutputTokens) + } +} + +func TestApplyAggregationUpdateClearsAndRevalidatesCapabilities(t *testing.T) { + current, err := PrepareCreateAggregation(func() CreateAggregation { + input := capabilityTestCreate() + input.ContextLength = 200_000 + input.MaxOutputTokens = 16_000 + input.ReasoningOptions = []string{"low", "high"} + input.ReasoningEffort = "high" + return input + }()) + if err != nil { + t.Fatal(err) + } + emptyOptions := []string{} + emptyEffort := "" + updated, err := ApplyAggregationUpdate(Aggregation{ + ID: current.ID, Name: current.Name, Enabled: current.Enabled, + Strategy: current.Strategy, AllowFallbacks: current.AllowFallbacks, MaxAttempts: current.MaxAttempts, + ContextLength: current.ContextLength, MaxOutputTokens: current.MaxOutputTokens, + ReasoningOptions: current.ReasoningOptions, ReasoningEffort: current.ReasoningEffort, + Members: current.Members, + }, UpdateAggregation{ReasoningOptions: &emptyOptions, ReasoningEffort: &emptyEffort}) + if err != nil { + t.Fatal(err) + } + if len(updated.ReasoningOptions) != 0 || updated.ReasoningEffort != "" { + t.Fatalf("cleared reasoning = %v %q", updated.ReasoningOptions, updated.ReasoningEffort) + } + + zeroContext := 0 + output := 32_000 + _, err = ApplyAggregationUpdate(Aggregation{ReasoningOptions: []string{"low"}}, UpdateAggregation{ + ContextLength: &zeroContext, MaxOutputTokens: &output, + }) + if err != nil { + t.Fatalf("output without a configured context should be allowed: %v", err) + } +} diff --git a/internal/accounts/aggregation_id_test.go b/internal/accounts/aggregation_id_test.go new file mode 100644 index 00000000..3bb5b810 --- /dev/null +++ b/internal/accounts/aggregation_id_test.go @@ -0,0 +1,67 @@ +package accounts + +import ( + "strings" + "testing" +) + +func TestValidAggregationIDAcceptsOnlyClientSafeChars(t *testing.T) { + for _, id := range []string{"my-claude", "deepseek-v4.1-flash-1017", "gpt-4.1", "deepseek/v4-flash-1017", "glm-5", "a1"} { + if !validAggregationID(id) { + t.Fatalf("%q should be valid", id) + } + } + for _, id := range []string{"", "DeepSeek-V4.1", "with space", "under_score", "colon:name"} { + if validAggregationID(id) { + t.Fatalf("%q should be invalid", id) + } + } +} + +func TestPrepareCreateAggregationRejectsUnsupportedCharsWithActionableMessage(t *testing.T) { + _, err := PrepareCreateAggregation(CreateAggregation{ID: "deep seek"}) + if err == nil { + t.Fatal("expected an error") + } + if !strings.Contains(err.Error(), "may only contain lowercase letters, digits, '.', '-' and '/'") { + t.Fatalf("message = %q", err.Error()) + } +} + +func TestPrepareCreateAggregationRequiresAnID(t *testing.T) { + _, err := PrepareCreateAggregation(CreateAggregation{ID: " "}) + if err == nil || err.Error() != "aggregation id required" { + t.Fatalf("err = %v", err) + } +} + +func TestPrepareCreateAggregationDefaultsNameToID(t *testing.T) { + input := CreateAggregation{ + ID: "DeepSeek-V4.1-Flash", + Members: []AggregationMember{{Provider: "qoder", Region: "cn", Model: "glm-5", Weight: 100}}, + } + prepared, err := PrepareCreateAggregation(input) + if err != nil { + t.Fatal(err) + } + if prepared.ID != "deepseek-v4.1-flash" { + t.Fatalf("id = %q", prepared.ID) + } + if prepared.Name != "deepseek-v4.1-flash" { + t.Fatalf("name = %q", prepared.Name) + } +} + +func TestPrepareCreateAggregationKeepsExplicitName(t *testing.T) { + prepared, err := PrepareCreateAggregation(CreateAggregation{ + ID: "my-claude", + Name: "My Claude", + Members: []AggregationMember{{Provider: "qoder", Region: "cn", Model: "glm-5", Weight: 100}}, + }) + if err != nil { + t.Fatal(err) + } + if prepared.Name != "My Claude" { + t.Fatalf("name = %q", prepared.Name) + } +} diff --git a/internal/accounts/checkin.go b/internal/accounts/checkin.go index 692dea0d..a4b3e1fc 100644 --- a/internal/accounts/checkin.go +++ b/internal/accounts/checkin.go @@ -49,43 +49,19 @@ func ResolveCheckinTime(ctx context.Context, store CheckinSettingsReader, accoun if account.CheckinTime != "" { return NormalizeCheckinTime(account.CheckinTime) } + // The provider check-in time setting is the operator's single source of + // truth for every account of that provider, and it defaults to 09:00. + // The stored per-account auto time is only a mirror of that setting kept + // for display, so it must not outrank the setting after it changes. + if store != nil { + if value, err := CheckinTimeDefault(ctx, store, account.Provider); err == nil { + return value, nil + } + } if account.CheckinAutoTime != "" { return NormalizeCheckinTime(account.CheckinAutoTime) } - // Before the first upstream status sync, keep the legacy provider default - // as a fallback. The first sync writes CheckinAutoTime and takes over. - fallback, err := CheckinTimeDefault(ctx, store, account.Provider) - if err != nil { - return "", err - } - return fallback, nil -} - -// EarliestCheckinClock is the provider's fallback daily window start when the -// upstream status response does not carry one. Qoder's activity refreshes at -// 10:00 Asia/Shanghai; the other currently supported check-in providers roll -// over at local midnight. -func EarliestCheckinClock(provider string) string { - if provider == "qoder" { - return "10:00" - } - return "00:00" -} - -// AutoCheckinTimeFromEarliest delays the upstream window by one hour so the -// scheduler never races the reset. An invalid or empty clock returns empty. -func AutoCheckinTimeFromEarliest(earliest string) string { - parsed, err := time.Parse("15:04", strings.TrimSpace(earliest)) - if err != nil { - return "" - } - return parsed.Add(time.Hour).Format("15:04") -} - -// DefaultCheckinAutoTime is the provider fallback window + 1 hour, used before -// the first upstream sync has produced an account-specific value. -func DefaultCheckinAutoTime(provider string) string { - return AutoCheckinTimeFromEarliest(EarliestCheckinClock(provider)) + return DefaultCheckinTime, nil } func ValidateCheckinSettings(providerID, regionID string, enabled bool, override string) error { diff --git a/internal/accounts/checkin_test.go b/internal/accounts/checkin_test.go new file mode 100644 index 00000000..d105f13c --- /dev/null +++ b/internal/accounts/checkin_test.go @@ -0,0 +1,48 @@ +package accounts + +import ( + "context" + "testing" +) + +type checkinSecretReader map[string]string + +func (r checkinSecretReader) GetSecret(_ context.Context, name string) (string, bool, error) { + value, ok := r[name] + return value, ok, nil +} + +// The provider check-in time setting is the operator's single source of truth. +// Every provider defaults to 09:00, a stored per-account auto time never +// outranks it, and only a per-account manual override does. +func TestResolveCheckinTimeFollowsProviderSetting(t *testing.T) { + ctx := context.Background() + for _, provider := range []string{"qoder", "workbuddy", "trae", "qwenwork", "codearts", "doubaowork", "minimaxcode"} { + account := Account{Provider: provider, ProviderRegion: "cn", CheckinAutoTime: "01:00"} + effective, err := ResolveCheckinTime(ctx, checkinSecretReader{}, account) + if err != nil || effective != DefaultCheckinTime { + t.Fatalf("%s default=%q err=%v want %q", provider, effective, err, DefaultCheckinTime) + } + store := checkinSecretReader{CheckinTimeSecret(provider): "10:30"} + effective, err = ResolveCheckinTime(ctx, store, account) + if err != nil || effective != "10:30" { + t.Fatalf("%s setting=%q err=%v", provider, effective, err) + } + account.CheckinTime = "18:30" + effective, err = ResolveCheckinTime(ctx, store, account) + if err != nil || effective != "18:30" { + t.Fatalf("%s manual override=%q err=%v", provider, effective, err) + } + } +} + +func TestResolveCheckinTimeFallsBackWithoutReader(t *testing.T) { + account := Account{Provider: "qoder"} + if got, err := ResolveCheckinTime(context.Background(), nil, account); err != nil || got != DefaultCheckinTime { + t.Fatalf("nil reader=%q err=%v", got, err) + } + account.CheckinAutoTime = "11:00" + if got, err := ResolveCheckinTime(context.Background(), nil, account); err != nil || got != "11:00" { + t.Fatalf("stored mirror=%q err=%v", got, err) + } +} diff --git a/internal/accounts/policy.go b/internal/accounts/policy.go index 70359145..cc3fc136 100644 --- a/internal/accounts/policy.go +++ b/internal/accounts/policy.go @@ -72,8 +72,8 @@ func DefaultWorkBuddyAutoCheckin(value *bool) bool { } func ValidateModelContextLength(contextLength int) error { - if contextLength < 0 || contextLength > 4_000_000 || (contextLength > 0 && contextLength < 1024) { - return fmt.Errorf("context_length must be 0 or between 1024 and 4000000") + if contextLength < 0 || contextLength > 4_000_000 { + return fmt.Errorf("context_length must be between 0 and 4000000") } return nil } diff --git a/internal/accounts/policy_test.go b/internal/accounts/policy_test.go index 5714bf0e..d0c161b2 100644 --- a/internal/accounts/policy_test.go +++ b/internal/accounts/policy_test.go @@ -64,7 +64,8 @@ func TestValidateModelContextLength(t *testing.T) { }{ {-1, false}, {0, true}, - {1023, false}, + {512, true}, + {1023, true}, {1024, true}, {4000000, true}, {4000001, false}, diff --git a/internal/accounts/quota.go b/internal/accounts/quota.go index 5f5adf6d..9448d133 100644 --- a/internal/accounts/quota.go +++ b/internal/accounts/quota.go @@ -1,5 +1,7 @@ package accounts +import "fmt" + // QuotaWindow is one provider-native usage period, such as Devin daily // and weekly included quota. The top-level QuotaSnapshot fields stay the // tighter of these windows for routing. @@ -66,3 +68,28 @@ type QuotaSnapshot struct { // Plan is the upstream subscription tier. Empty means not reported. Plan string `json:"plan,omitempty"` } + +// QuotaFreshIntervalSecret stores the background quota-freshness sweep cadence +// (seconds) so console credit readings stay real-time without a manual refresh. +const QuotaFreshIntervalSecret = "quota_fresh_interval_seconds" + +const ( + // DefaultQuotaFreshIntervalSeconds is the sweep cadence when unset. + DefaultQuotaFreshIntervalSeconds = 60 + // MinQuotaFreshIntervalSeconds bounds how aggressive the sweep may get. + MinQuotaFreshIntervalSeconds = 10 + // MaxQuotaFreshIntervalSeconds bounds how stale readings may become. + MaxQuotaFreshIntervalSeconds = 3600 +) + +// NormalizeQuotaFreshIntervalSeconds validates a sweep cadence. Zero disables +// the periodic sweep (manual refresh and post-chat refresh still apply). +func NormalizeQuotaFreshIntervalSeconds(value int) (int, error) { + if value == 0 { + return 0, nil + } + if value < MinQuotaFreshIntervalSeconds || value > MaxQuotaFreshIntervalSeconds { + return 0, fmt.Errorf("quota_fresh_interval_seconds must be 0 (disabled) or %d..%d", MinQuotaFreshIntervalSeconds, MaxQuotaFreshIntervalSeconds) + } + return value, nil +} diff --git a/internal/accounts/request_logs.go b/internal/accounts/request_logs.go index fd074356..d2469daa 100644 --- a/internal/accounts/request_logs.go +++ b/internal/accounts/request_logs.go @@ -25,31 +25,31 @@ const ( var ErrRequestLogNotFound = errors.New("request log not found") type RequestLog struct { - ID string `json:"id"` - CreatedAt time.Time `json:"created_at"` - FinishedAt *time.Time `json:"finished_at,omitempty"` - Stream bool `json:"stream"` - Status string `json:"status"` - RequestedModel string `json:"requested_model"` - MappedModel string `json:"mapped_model,omitempty"` - RequestedReasoning string `json:"requested_reasoning,omitempty"` - ResolvedReasoning string `json:"resolved_reasoning,omitempty"` - AccountID string `json:"account_id,omitempty"` - APIKeyID string `json:"api_key_id,omitempty"` // console API key id; "" for console-key traffic and legacy rows - Provider string `json:"provider,omitempty"` - Routing string `json:"routing,omitempty"` - PromptTokens *int `json:"prompt_tokens,omitempty"` - CompletionTokens *int `json:"completion_tokens,omitempty"` - CacheReadTokens *int `json:"cache_read_tokens,omitempty"` - CacheWriteTokens *int `json:"cache_write_tokens,omitempty"` - UsageSource string `json:"usage_source,omitempty"` - Credits *float64 `json:"credits,omitempty"` - LatencyMs *int `json:"latency_ms,omitempty"` - TTFBMs *int `json:"ttfb_ms,omitempty"` - ErrorKind string `json:"error_kind,omitempty"` - ErrorCode string `json:"error_code,omitempty"` - ErrorMessage string `json:"error_message,omitempty"` - AttemptCount int `json:"attempt_count"` + ID string `json:"id"` + CreatedAt time.Time `json:"created_at"` + FinishedAt *time.Time `json:"finished_at,omitempty"` + Stream bool `json:"stream"` + Status string `json:"status"` + RequestedModel string `json:"requested_model"` + MappedModel string `json:"mapped_model,omitempty"` + RequestedReasoning string `json:"requested_reasoning,omitempty"` + ResolvedReasoning string `json:"resolved_reasoning,omitempty"` + AccountID string `json:"account_id,omitempty"` + APIKeyID string `json:"api_key_id,omitempty"` // console API key id; "" for console-key traffic and legacy rows + Provider string `json:"provider,omitempty"` + Routing string `json:"routing,omitempty"` + PromptTokens *int `json:"prompt_tokens,omitempty"` + CompletionTokens *int `json:"completion_tokens,omitempty"` + CacheReadTokens *int `json:"cache_read_tokens,omitempty"` + CacheWriteTokens *int `json:"cache_write_tokens,omitempty"` + UsageSource string `json:"usage_source,omitempty"` + Credits *float64 `json:"credits,omitempty"` + LatencyMs *int `json:"latency_ms,omitempty"` + TTFBMs *int `json:"ttfb_ms,omitempty"` + ErrorKind string `json:"error_kind,omitempty"` + ErrorCode string `json:"error_code,omitempty"` + ErrorMessage string `json:"error_message,omitempty"` + AttemptCount int `json:"attempt_count"` // DetailExpired marks a log whose detail rows and detail-only columns were // cleared by retention. The aggregate columns (tokens, credits, latency, // status, model) are still present, so usage totals stay exact; only the @@ -276,11 +276,15 @@ type RequestUsage struct { } type RequestUsageTotals struct { - TotalTokens int64 `json:"total_tokens"` - PromptTokens int64 `json:"prompt_tokens"` - CompletionTokens int64 `json:"completion_tokens"` - CacheHitTokens int64 `json:"cache_hit_tokens"` - CacheMissTokens int64 `json:"cache_miss_tokens"` + TotalTokens int64 `json:"total_tokens"` + PromptTokens int64 `json:"prompt_tokens"` + CompletionTokens int64 `json:"completion_tokens"` + CacheHitTokens int64 `json:"cache_hit_tokens"` + CacheMissTokens int64 `json:"cache_miss_tokens"` + // CacheHitRate is CacheHitTokens / (CacheHitTokens + CacheMissTokens). Nil + // when no cache accounting was reported in the window, so a fresh install + // reads as "no data" instead of a 0% hit rate. + CacheHitRate *float64 `json:"cache_hit_rate,omitempty"` Requests int `json:"requests"` Errors int `json:"errors"` AvgLatencyMs *int `json:"avg_latency_ms,omitempty"` diff --git a/internal/accounts/types.go b/internal/accounts/types.go index 6cfd3040..0c5babaf 100644 --- a/internal/accounts/types.go +++ b/internal/accounts/types.go @@ -82,6 +82,33 @@ type CheckinAllResult struct { Region string `json:"region"` Status string `json:"status"` Message string `json:"message,omitempty"` + // RewardCredits is the real upstream grant amount reported by the provider + // claim response. Zero/omitted means the provider did not report an amount. + RewardCredits float64 `json:"reward_credits,omitempty"` + // Code and Kind carry the real upstream error classification when the + // check-in failed; they are never synthesized. + Code string `json:"code,omitempty"` + Kind string `json:"kind,omitempty"` + HTTPStatus int `json:"http_status,omitempty"` + // QuotaRefreshed reports whether the post-check-in upstream quota fetch + // completed and persisted a real snapshot. + QuotaRefreshed bool `json:"quota_refreshed,omitempty"` +} + +// AccountRefreshResult is the per-account outcome of a bulk refresh pass. +// Every field reflects the real probe/quota outcome; Message carries the +// upstream or probe error verbatim when OK is false. +type AccountRefreshResult struct { + AccountID string `json:"account_id"` + Provider string `json:"provider"` + Region string `json:"region"` + OK bool `json:"ok"` + Status string `json:"status,omitempty"` + Code string `json:"code,omitempty"` + Kind string `json:"kind,omitempty"` + Message string `json:"message,omitempty"` + HTTPStatus int `json:"http_status,omitempty"` + Quota *QuotaSnapshot `json:"quota,omitempty"` } // CheckinStatusUpdate persists an upstream status read. CheckinAt is only set @@ -182,6 +209,10 @@ type AccountView struct { ModelCooldowns map[string]string `json:"model_cooldowns,omitempty"` Quota *QuotaSnapshot `json:"quota,omitempty"` ProxyURL string `json:"proxy_url,omitempty"` + // ForceReadyOverride marks the local/dev force-ready marker active for + // this account: routing ignores the hard-zero balance, but Quota above + // still shows the real upstream snapshot. + ForceReadyOverride bool `json:"force_ready_override,omitempty"` } type ProviderModelSetting struct { diff --git a/internal/app/aggregation_models.go b/internal/app/aggregation_models.go new file mode 100644 index 00000000..b38da21b --- /dev/null +++ b/internal/app/aggregation_models.go @@ -0,0 +1,57 @@ +package app + +import ( + "context" + "net/http" + "sort" + + "github.com/caigee-cmd/cli2api/internal/control" +) + +// aggregationKeyModels is the final /v1/models view for an aggregation key: +// enabled logical model-pool entries plus the provider-neutral account aliases +// the key can reach. Real catalog rows never appear, so the client cannot see +// which provider serves a name. Routing is unchanged and still resolves both +// kinds through the account pool / aggregation plan. +func (a *App) aggregationKeyModels(ctx context.Context, r *http.Request, models []map[string]any) []map[string]any { + if a == nil { + return models + } + identity := a.requestIdentity(r) + if !identity.ModelAggregation { + return models + } + aliases := control.AggregateModelEntries(models, identity, a.accountModelAllows()) + var lister control.AggregationLister + if a.Control != nil { + lister = a.Control.Aggregations + } + merged := control.MergeAggregationModels(ctx, lister, models) + out := make([]map[string]any, 0, len(merged)+len(aliases)) + seen := make(map[string]bool, len(merged)+len(aliases)) + for _, model := range merged { + if provider, _ := model["provider"].(string); provider != "aggregation" { + continue + } + id, _ := model["id"].(string) + if id == "" || seen[id] { + continue + } + seen[id] = true + out = append(out, model) + } + for _, model := range aliases { + id, _ := model["id"].(string) + if id == "" || seen[id] { + continue + } + seen[id] = true + out = append(out, model) + } + sort.SliceStable(out, func(i, j int) bool { + left, _ := out[i]["id"].(string) + right, _ := out[j]["id"].(string) + return left < right + }) + return out +} diff --git a/internal/app/aggregation_models_test.go b/internal/app/aggregation_models_test.go new file mode 100644 index 00000000..2274165a --- /dev/null +++ b/internal/app/aggregation_models_test.go @@ -0,0 +1,94 @@ +package app + +import ( + "context" + "net/http/httptest" + "testing" + + "github.com/caigee-cmd/cli2api/internal/accounts" + "github.com/caigee-cmd/cli2api/internal/auth" + appsvc "github.com/caigee-cmd/cli2api/internal/control" + "github.com/caigee-cmd/cli2api/internal/executor" +) + +type aggregationStoreStub struct { + list []accounts.Aggregation +} + +func (s *aggregationStoreStub) InsertAggregation(_ context.Context, agg accounts.Aggregation) (accounts.Aggregation, error) { + s.list = append(s.list, agg) + return agg, nil +} + +func (s *aggregationStoreStub) SaveAggregation(_ context.Context, agg accounts.Aggregation) (accounts.Aggregation, error) { + for i := range s.list { + if s.list[i].ID == agg.ID { + s.list[i] = agg + } + } + return agg, nil +} + +func (s *aggregationStoreStub) ListAggregations(context.Context) ([]accounts.Aggregation, error) { + return s.list, nil +} + +func (s *aggregationStoreStub) GetAggregation(_ context.Context, id string) (accounts.Aggregation, error) { + for _, agg := range s.list { + if agg.ID == id { + return agg, nil + } + } + return accounts.Aggregation{}, accounts.ErrAggregationNotFound +} + +func (s *aggregationStoreStub) DeleteAggregation(_ context.Context, id string) error { + for i := range s.list { + if s.list[i].ID == id { + s.list = append(s.list[:i], s.list[i+1:]...) + return nil + } + } + return accounts.ErrAggregationNotFound +} + +func TestAggregationKeyModelsListsConfiguredAndAccountAliases(t *testing.T) { + store := &aggregationStoreStub{list: []accounts.Aggregation{{ + ID: "glm-5.2", Name: "GLM 5.2", Enabled: true, Strategy: accounts.AggregationPriority, + Members: []accounts.AggregationMember{{Provider: "qoder", Model: "kimi-k2.6"}}, + }}} + pool := executor.NewPool(nil, nil) + pool.Upsert(executor.Item{ + ID: "q1", Provider: "qoder", Models: []string{"kimi-k2.6"}, + ModelAliases: map[string]string{"fast": "kimi-k2.6"}, + }) + a := &App{Pool: pool, Control: &appsvc.Services{Aggregations: appsvc.NewAggregations(store)}} + models := []map[string]any{ + {"id": "kimi-k2.6", "object": "model", "provider": "qoder", "native_model": "kimi-k2.6"}, + } + req := httptest.NewRequest("GET", "/v1/models", nil) + req = req.WithContext(auth.WithIdentity(req.Context(), auth.Identity{ + Kind: auth.KindKey, KeyID: "k1", ModelAggregation: true, AllowedProviders: []string{"qoder"}, + })) + out := a.aggregationKeyModels(context.Background(), req, models) + byID := map[string]map[string]any{} + for _, model := range out { + byID[model["id"].(string)] = model + } + if len(out) != 2 { + t.Fatalf("models=%v", out) + } + logical := byID["glm-5.2"] + if logical == nil || logical["provider"] != "aggregation" || logical["owned_by"] != "aggregation" { + t.Fatalf("logical=%v out=%v", logical, out) + } + if logical["native_model"] != nil { + t.Fatalf("native model leaked: %v", logical) + } + if byID["fast"] == nil || byID["fast"]["provider"] != nil { + t.Fatalf("alias=%v out=%v", byID["fast"], out) + } + if byID["kimi-k2.6"] != nil { + t.Fatalf("real model leaked: %v", out) + } +} diff --git a/internal/app/app.go b/internal/app/app.go index ac065794..fffff68b 100644 --- a/internal/app/app.go +++ b/internal/app/app.go @@ -74,6 +74,14 @@ func New(cfg config.Config) *App { if err != nil { panic(err) } + // Rows still marked started/streaming belong to the previous process. Their + // in-memory in-flight state is gone, so they can never finish on their own; + // leaving them open makes the console show phantom running requests. + if closed, err := store.CloseAbandonedRequestLogs(context.Background(), time.Now()); err != nil { + log.Printf("[request-logs] close abandoned rows: %v", err) + } else if closed > 0 { + log.Printf("[request-logs] marked %d abandoned request(s) from the previous process", closed) + } proxyAPIKey, initialized, err := EnsureProxyAPIKey(context.Background(), store, cfg.ProxyAPIKey) if err != nil { panic(err) @@ -163,7 +171,7 @@ func New(cfg config.Config) *App { stopLogs := make(chan struct{}) go recorder.PurgeLoop(stopLogs, time.Hour) go manager.RunMaintenanceLoop(stopLogs) - checker := appupdate.NewChecker(buildinfo.Version, appupdate.NewGitHubReleaseSource("caigee-cmd/cli2api", cfg.UpdateGitHubToken)) + checker := appupdate.NewChecker(buildinfo.Version, appupdate.NewGitHubReleaseSource(cfg.UpdateGitHubRepo, cfg.UpdateGitHubToken)) var agent appupdate.Agent = appupdate.NewUnixAgentClient(cfg.UpdateSocketPath) if strings.TrimSpace(cfg.UpdateAgentURL) != "" { agent = appupdate.NewHTTPAgentClient(cfg.UpdateAgentURL, cfg.UpdateAgentToken) diff --git a/internal/app/gateway.go b/internal/app/gateway.go index 706f6274..bf509661 100644 --- a/internal/app/gateway.go +++ b/internal/app/gateway.go @@ -29,12 +29,7 @@ func (a *App) newGateway() *apigateway.Handler { Models: func(refresh bool, accountID string) ([]map[string]any, error) { return a.fetchDisplayModels(refresh, accountID, control.CatalogModeMerge) }, - MergeAggregationModels: func(ctx context.Context, models []map[string]any) []map[string]any { - if a.Control == nil { - return models - } - return control.MergeAggregationModels(ctx, a.Control.Aggregations, models) - }, + AggregationKeyModels: a.aggregationKeyModels, CatalogStatus: func() map[string]any { if a.Control == nil || a.Control.Catalog == nil { return nil diff --git a/internal/app/model_catalog.go b/internal/app/model_catalog.go index c0d5966e..738ff64e 100644 --- a/internal/app/model_catalog.go +++ b/internal/app/model_catalog.go @@ -17,7 +17,13 @@ func (a *App) filterModelsForIdentity(r *http.Request, models []map[string]any) } models = control.FilterModelsByAccountAllow(models, identity, allow) models = control.FilterModelsForIdentity(identity, models) - models = control.AggregateModelEntries(models, identity, allow) + if !identity.ModelAggregation { + models = control.AggregateModelEntries(models, identity, allow) + } + // Aggregation keys get their final provider-neutral list from + // aggregationKeyModels after this filter: configured logical models first, + // then account aliases. Returning the filtered catalog here keeps every + // aggregation member available for that merge. return models } diff --git a/internal/config/config.go b/internal/config/config.go index 8e6ada70..9d39ecc0 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -14,6 +14,29 @@ import ( // minutes); 0 disables the loop and leaves only manual/console refreshes. const DefaultCatalogRefreshInterval = 10 * time.Minute +// DefaultUpdateGitHubRepo is the upstream repository whose GitHub releases the +// console follows. A fork that publishes its own images sets UPDATE_GITHUB_REPO +// (and CLI2API_IMAGE_REPOSITORY / CLI2API_GITHUB_REPOSITORY for the installers) +// instead of changing this default. +const DefaultUpdateGitHubRepo = "caigee-cmd/cli2api" + +func updateGitHubRepo(value string) string { + repo := strings.TrimSpace(value) + if repo == "" { + return DefaultUpdateGitHubRepo + } + for _, prefix := range []string{"https://github.com/", "http://github.com/", "github.com/"} { + repo = strings.TrimPrefix(repo, prefix) + } + repo = strings.Trim(strings.TrimSpace(repo), "/") + repo = strings.TrimSuffix(repo, ".git") + repo = strings.Trim(repo, "/") + if repo == "" { + return DefaultUpdateGitHubRepo + } + return repo +} + type Config struct { Host string Port int @@ -33,6 +56,7 @@ type Config struct { UpdateAgentURL string UpdateAgentToken string UpdateGitHubToken string + UpdateGitHubRepo string CatalogRefreshInterval time.Duration // CreditFloor is the global default credit floor. Zero disables the gate; // per-account credit_floor overrides it when set. @@ -112,6 +136,7 @@ func Load() (Config, error) { UpdateAgentURL: strings.TrimSpace(os.Getenv("UPDATE_AGENT_URL")), UpdateAgentToken: strings.TrimSpace(os.Getenv("UPDATE_AGENT_TOKEN")), UpdateGitHubToken: strings.TrimSpace(os.Getenv("UPDATE_GITHUB_TOKEN")), + UpdateGitHubRepo: updateGitHubRepo(os.Getenv("UPDATE_GITHUB_REPO")), CatalogRefreshInterval: catalogRefreshInterval(os.Getenv("CLI2API_CATALOG_REFRESH_INTERVAL")), CreditFloor: creditFloor, PercentFloor: percentFloor, diff --git a/internal/config/config_test.go b/internal/config/config_test.go index 74db6f39..cabe03fe 100644 --- a/internal/config/config_test.go +++ b/internal/config/config_test.go @@ -70,3 +70,32 @@ func TestLoadRetryAccountBudget(t *testing.T) { t.Fatalf("max retry accounts = %d", cfg.MaxRetryAccounts) } } + +func TestLoadUpdateGitHubRepo(t *testing.T) { + t.Setenv("UPDATE_GITHUB_REPO", "") + cfg, err := Load() + if err != nil { + t.Fatal(err) + } + if cfg.UpdateGitHubRepo != DefaultUpdateGitHubRepo { + t.Fatalf("default repo = %q", cfg.UpdateGitHubRepo) + } + + t.Setenv("UPDATE_GITHUB_REPO", "guyu233/cli2api") + cfg, err = Load() + if err != nil { + t.Fatal(err) + } + if cfg.UpdateGitHubRepo != "guyu233/cli2api" { + t.Fatalf("override repo = %q", cfg.UpdateGitHubRepo) + } + + t.Setenv("UPDATE_GITHUB_REPO", " https://github.com/guyu233/cli2api.git/ ") + cfg, err = Load() + if err != nil { + t.Fatal(err) + } + if cfg.UpdateGitHubRepo != "guyu233/cli2api" { + t.Fatalf("normalized repo = %q", cfg.UpdateGitHubRepo) + } +} diff --git a/internal/console/accounts.go b/internal/console/accounts.go index 0935de55..aba21551 100644 --- a/internal/console/accounts.go +++ b/internal/console/accounts.go @@ -100,6 +100,38 @@ func (h *Handler) HandleCheckinAll(w http.ResponseWriter, r *http.Request) { writeJSON(w, http.StatusOK, map[string]any{"object": "list", "data": results}) } +// HandleRefreshAll refreshes every account concurrently (full fan-out) and +// returns each account's real outcome, including the verbatim upstream error +// and the fresh quota snapshot. Disabled accounts are included only when the +// caller asks for them or the system setting enables it. +func (h *Handler) HandleRefreshAll(w http.ResponseWriter, r *http.Request) { + if r.Method != http.MethodPost { + writeErr(w, http.StatusMethodNotAllowed, "method_not_allowed", "POST only") + return + } + var input struct { + Quota *bool `json:"quota"` + IncludeDisabled *bool `json:"include_disabled"` + } + if err := json.NewDecoder(http.MaxBytesReader(w, r.Body, maxConsoleBodyBytes)).Decode(&input); err != nil && err != io.EOF { + writeErr(w, http.StatusBadRequest, "invalid_request", err.Error()) + return + } + forceQuota := true + if input.Quota != nil { + forceQuota = *input.Quota + } + includeDisabled := false + if input.IncludeDisabled != nil { + includeDisabled = *input.IncludeDisabled + } + results := h.Control.Accounts.RefreshAllResults(r.Context(), forceQuota, includeDisabled) + if results == nil { + results = []accounts.AccountRefreshResult{} + } + writeJSON(w, http.StatusOK, map[string]any{"object": "list", "data": results}) +} + func (h *Handler) HandleAccountImport(w http.ResponseWriter, r *http.Request) { if r.Method != http.MethodPost { writeErr(w, http.StatusMethodNotAllowed, "method_not_allowed", "POST only") diff --git a/internal/console/aggregations.go b/internal/console/aggregations.go index cd74d573..37dca09a 100644 --- a/internal/console/aggregations.go +++ b/internal/console/aggregations.go @@ -50,13 +50,17 @@ func (h *Handler) HandleAggregations(w http.ResponseWriter, r *http.Request) { writeJSON(w, http.StatusOK, map[string]any{"object": "list", "data": list}) case http.MethodPost: var input struct { - ID string `json:"id"` - Name string `json:"name"` - Enabled *bool `json:"enabled"` - Strategy string `json:"strategy"` - AllowFallbacks *bool `json:"allow_fallbacks"` - MaxAttempts int `json:"max_attempts"` - Members []aggregationMemberInput `json:"members"` + ID string `json:"id"` + Name string `json:"name"` + Enabled *bool `json:"enabled"` + Strategy string `json:"strategy"` + AllowFallbacks *bool `json:"allow_fallbacks"` + MaxAttempts int `json:"max_attempts"` + ContextLength int `json:"context_length"` + MaxOutputTokens int `json:"max_output_tokens"` + ReasoningOptions []string `json:"reasoning_options"` + ReasoningEffort string `json:"reasoning_effort"` + Members []aggregationMemberInput `json:"members"` } if err := json.NewDecoder(http.MaxBytesReader(w, r.Body, maxConsoleBodyBytes)).Decode(&input); err != nil { writeErr(w, http.StatusBadRequest, "invalid_request", err.Error()) @@ -71,13 +75,17 @@ func (h *Handler) HandleAggregations(w http.ResponseWriter, r *http.Request) { allowFallbacks = *input.AllowFallbacks } agg, err := h.Control.Aggregations.Create(r.Context(), accounts.CreateAggregation{ - ID: input.ID, - Name: input.Name, - Enabled: enabled, - Strategy: accounts.AggregationStrategy(input.Strategy), - AllowFallbacks: allowFallbacks, - MaxAttempts: input.MaxAttempts, - Members: decodeAggregationMembers(input.Members), + ID: input.ID, + Name: input.Name, + Enabled: enabled, + Strategy: accounts.AggregationStrategy(input.Strategy), + AllowFallbacks: allowFallbacks, + MaxAttempts: input.MaxAttempts, + ContextLength: input.ContextLength, + MaxOutputTokens: input.MaxOutputTokens, + ReasoningOptions: input.ReasoningOptions, + ReasoningEffort: input.ReasoningEffort, + Members: decodeAggregationMembers(input.Members), }) if err != nil { writeAggregationError(w, err, "create") @@ -105,12 +113,16 @@ func (h *Handler) HandleAggregationByID(w http.ResponseWriter, r *http.Request) writeJSON(w, http.StatusOK, agg) case http.MethodPatch: var input struct { - Name *string `json:"name"` - Enabled *bool `json:"enabled"` - Strategy *string `json:"strategy"` - AllowFallbacks *bool `json:"allow_fallbacks"` - MaxAttempts *int `json:"max_attempts"` - Members *[]aggregationMemberInput `json:"members"` + Name *string `json:"name"` + Enabled *bool `json:"enabled"` + Strategy *string `json:"strategy"` + AllowFallbacks *bool `json:"allow_fallbacks"` + MaxAttempts *int `json:"max_attempts"` + ContextLength *int `json:"context_length"` + MaxOutputTokens *int `json:"max_output_tokens"` + ReasoningOptions *[]string `json:"reasoning_options"` + ReasoningEffort *string `json:"reasoning_effort"` + Members *[]aggregationMemberInput `json:"members"` } if err := json.NewDecoder(http.MaxBytesReader(w, r.Body, maxConsoleBodyBytes)).Decode(&input); err != nil { writeErr(w, http.StatusBadRequest, "invalid_request", err.Error()) @@ -128,7 +140,10 @@ func (h *Handler) HandleAggregationByID(w http.ResponseWriter, r *http.Request) } agg, err := h.Control.Aggregations.Update(r.Context(), id, accounts.UpdateAggregation{ Name: input.Name, Enabled: input.Enabled, Strategy: strategy, - AllowFallbacks: input.AllowFallbacks, MaxAttempts: input.MaxAttempts, Members: members, + AllowFallbacks: input.AllowFallbacks, MaxAttempts: input.MaxAttempts, + ContextLength: input.ContextLength, MaxOutputTokens: input.MaxOutputTokens, + ReasoningOptions: input.ReasoningOptions, ReasoningEffort: input.ReasoningEffort, + Members: members, }) if err != nil { writeAggregationError(w, err, "update") diff --git a/internal/console/events.go b/internal/console/events.go new file mode 100644 index 00000000..ea350d42 --- /dev/null +++ b/internal/console/events.go @@ -0,0 +1,64 @@ +package console + +import ( + "encoding/json" + "fmt" + "net/http" + "strconv" + "time" +) + +// HandleEvents streams real backend state changes (quota snapshots, check-in +// outcomes, health/cooldown merges, bulk-op progress) as Server-Sent Events. +// Every frame reflects an actual backend mutation; nothing is synthesized. +// Reconnects send Last-Event-ID (or ?last_seq=) and the bus replays its ring. +func (h *Handler) HandleEvents(w http.ResponseWriter, r *http.Request) { + if r.Method != http.MethodGet { + writeErr(w, http.StatusMethodNotAllowed, "method_not_allowed", "GET only") + return + } + flusher, ok := w.(http.Flusher) + if !ok { + writeErr(w, http.StatusInternalServerError, "streaming_unsupported", "response writer cannot stream") + return + } + var lastSeq uint64 + if raw := r.Header.Get("Last-Event-ID"); raw != "" { + lastSeq, _ = strconv.ParseUint(raw, 10, 64) + } else if raw := r.URL.Query().Get("last_seq"); raw != "" { + lastSeq, _ = strconv.ParseUint(raw, 10, 64) + } + stream, cancel := h.Control.SubscribeEvents(lastSeq) + defer cancel() + + w.Header().Set("Content-Type", "text/event-stream") + w.Header().Set("Cache-Control", "no-cache") + w.Header().Set("Connection", "keep-alive") + w.Header().Set("X-Accel-Buffering", "no") + w.WriteHeader(http.StatusOK) + flusher.Flush() + + heartbeat := time.NewTicker(15 * time.Second) + defer heartbeat.Stop() + for { + select { + case <-r.Context().Done(): + return + case event, ok := <-stream: + if !ok { + // The bus closed a slow consumer. The client reconnects with + // Last-Event-ID and replays missed events from the ring. + return + } + payload, err := json.Marshal(event) + if err != nil { + continue + } + fmt.Fprintf(w, "id: %d\nevent: %s\ndata: %s\n\n", event.Seq, event.Type, payload) + flusher.Flush() + case <-heartbeat.C: + fmt.Fprint(w, ": keepalive\n\n") + flusher.Flush() + } + } +} diff --git a/internal/console/events_test.go b/internal/console/events_test.go new file mode 100644 index 00000000..b9095dce --- /dev/null +++ b/internal/console/events_test.go @@ -0,0 +1,96 @@ +package console + +import ( + "bufio" + "context" + "encoding/json" + "net/http" + "net/http/httptest" + "path/filepath" + "strings" + "testing" + "time" + + "github.com/caigee-cmd/cli2api/internal/accounts" + "github.com/caigee-cmd/cli2api/internal/control" + "github.com/caigee-cmd/cli2api/internal/events" + "github.com/caigee-cmd/cli2api/internal/runtime" + sqlstore "github.com/caigee-cmd/cli2api/internal/store" +) + +// The SSE endpoint must stream the real backend event envelope (seq/type/time +// and data) with SSE framing, and honor the documented authentication-wrapped +// route shape used by the server. +func TestHandleEventsStreamsRealFrames(t *testing.T) { + store, err := sqlstore.OpenStore(filepath.Join(t.TempDir(), "sse.db")) + if err != nil { + t.Fatal(err) + } + t.Cleanup(func() { store.Close() }) + manager := runtime.NewManager(runtime.ManagerConfig{DataDir: t.TempDir()}, store, nil) + t.Cleanup(func() { manager.Close() }) + h := &Handler{Control: control.New(manager)} + + server := httptest.NewServer(http.HandlerFunc(h.HandleEvents)) + defer server.Close() + + resp, err := http.Get(server.URL) + if err != nil { + t.Fatal(err) + } + defer resp.Body.Close() + if resp.StatusCode != http.StatusOK { + t.Fatalf("status=%d", resp.StatusCode) + } + if got := resp.Header.Get("Content-Type"); !strings.HasPrefix(got, "text/event-stream") { + t.Fatalf("content-type=%q", got) + } + + // Trigger a real structural change after the stream is open. + account, err := store.Create(context.Background(), accounts.CreateAccount{ + Name: "sse-account", Provider: "qoder", Region: "cn", Enabled: true, + }) + if err != nil { + t.Fatal(err) + } + if err := manager.SyncAccount(context.Background(), account, account); err != nil { + t.Fatal(err) + } + + type result struct { + event events.Event + err error + } + found := make(chan result, 1) + go func() { + scanner := bufio.NewScanner(resp.Body) + for scanner.Scan() { + line := scanner.Text() + if !strings.HasPrefix(line, "data: ") { + continue + } + var event events.Event + if err := json.Unmarshal([]byte(strings.TrimPrefix(line, "data: ")), &event); err != nil { + found <- result{err: err} + return + } + if event.Type == events.TypeAccounts { + found <- result{event: event} + return + } + } + found <- result{err: context.DeadlineExceeded} + }() + + select { + case got := <-found: + if got.err != nil { + t.Fatalf("stream read: %v", got.err) + } + if got.event.Seq == 0 || got.event.Time == "" || got.event.AccountID != account.ID { + t.Fatalf("event = %+v", got.event) + } + case <-time.After(3 * time.Second): + t.Fatal("no real event frame arrived") + } +} diff --git a/internal/console/models.go b/internal/console/models.go index 0cb2cf30..f3353c29 100644 --- a/internal/console/models.go +++ b/internal/console/models.go @@ -40,9 +40,12 @@ func (h *Handler) HandleModelsAPI(w http.ResponseWriter, r *http.Request) { return } data := h.decorateModels(r.Context(), h.filterModels(r, models)) - if h.crossProviderPoolOn() && h.Control != nil { - data = control.MergeAggregationModels(r.Context(), h.Control.Aggregations, data) - } + // Aggregation models are a model-pool concept, not a provider. Do not merge + // them into the console catalog: provider settings, account directories and + // the model-pool member picker all group by provider, so a synthetic + // "aggregation" row there either creates a phantom provider card or hides a + // real model that happens to share the logical ID. Clients discover logical + // models through the key-scoped /v1/models view instead. if !h.crossProviderPoolOn() { // The gateway refuses bare ids with the pool off; serve prefixed ids so // every client that picks from this list produces a request it accepts. diff --git a/internal/console/models_test.go b/internal/console/models_test.go index 9105e658..de277e9d 100644 --- a/internal/console/models_test.go +++ b/internal/console/models_test.go @@ -1,12 +1,14 @@ package console import ( + "context" "encoding/json" "net/http" "net/http/httptest" "sync/atomic" "testing" + "github.com/caigee-cmd/cli2api/internal/accounts" "github.com/caigee-cmd/cli2api/internal/control" ) @@ -113,6 +115,82 @@ func TestHandleModelsAPIDefaultRemainsUnpaginated(t *testing.T) { } } +func TestHandleModelsAPIKeepsSyntheticAggregationOutOfConsoleCatalog(t *testing.T) { + store := &consoleAggregationStore{list: []accounts.Aggregation{{ + ID: "deepseek-v4.1-flash", Enabled: true, + Members: []accounts.AggregationMember{{Provider: "trae", Model: "deepseek-v4.1-flash"}}, + }}} + var pool atomic.Bool + pool.Store(true) + h := &Handler{ + Control: &control.Services{Aggregations: control.NewAggregations(store)}, + CrossProviderPool: &pool, + FetchDisplayModels: func(bool, string, control.CatalogMode) ([]map[string]any, error) { + return []map[string]any{{ + "id": "deepseek-v4.1-flash", "provider": "trae", "owned_by": "trae", + }}, nil + }, + } + rec := httptest.NewRecorder() + h.HandleModelsAPI(rec, httptest.NewRequest(http.MethodGet, "/api/models", nil)) + if rec.Code != http.StatusOK { + t.Fatalf("status = %d body = %s", rec.Code, rec.Body.String()) + } + var body struct { + Data []map[string]any `json:"data"` + } + if err := json.Unmarshal(rec.Body.Bytes(), &body); err != nil { + t.Fatal(err) + } + if len(body.Data) != 1 { + t.Fatalf("data = %#v", body.Data) + } + if body.Data[0]["provider"] != "trae" || body.Data[0]["id"] != "deepseek-v4.1-flash" { + t.Fatalf("real provider row was replaced: %#v", body.Data[0]) + } +} + +type consoleAggregationStore struct { + list []accounts.Aggregation +} + +func (s *consoleAggregationStore) InsertAggregation(_ context.Context, agg accounts.Aggregation) (accounts.Aggregation, error) { + s.list = append(s.list, agg) + return agg, nil +} + +func (s *consoleAggregationStore) SaveAggregation(_ context.Context, agg accounts.Aggregation) (accounts.Aggregation, error) { + for i := range s.list { + if s.list[i].ID == agg.ID { + s.list[i] = agg + } + } + return agg, nil +} + +func (s *consoleAggregationStore) ListAggregations(context.Context) ([]accounts.Aggregation, error) { + return s.list, nil +} + +func (s *consoleAggregationStore) GetAggregation(_ context.Context, id string) (accounts.Aggregation, error) { + for _, agg := range s.list { + if agg.ID == id { + return agg, nil + } + } + return accounts.Aggregation{}, accounts.ErrAggregationNotFound +} + +func (s *consoleAggregationStore) DeleteAggregation(_ context.Context, id string) error { + for i := range s.list { + if s.list[i].ID == id { + s.list = append(s.list[:i], s.list[i+1:]...) + return nil + } + } + return accounts.ErrAggregationNotFound +} + func TestHandleModelsAPIRejectsInvalidPagination(t *testing.T) { h := &Handler{FetchDisplayModels: func(bool, string, control.CatalogMode) ([]map[string]any, error) { return []map[string]any{{"id": "model"}}, nil diff --git a/internal/console/overview.go b/internal/console/overview.go index 24828b9d..b8b552bd 100644 --- a/internal/console/overview.go +++ b/internal/console/overview.go @@ -1,7 +1,6 @@ package console import ( - "context" "net/http" "time" @@ -13,9 +12,10 @@ import ( func (h *Handler) HandleOverview(w http.ResponseWriter, r *http.Request) { if r.URL.Query().Get("refresh") == "1" { - refreshCtx, refreshCancel := context.WithTimeout(context.Background(), 5*time.Second) - _ = h.Control.Accounts.RefreshAll(refreshCtx, true) - refreshCancel() + // Trigger a full concurrent background refresh and return the current + // real views immediately. Per-account outcomes are persisted and pushed + // on the event channel instead of being truncated by a short timeout. + h.Control.Accounts.TriggerRefresh(r.Context()) } accountViews, err := h.Control.Accounts.List(r.Context(), false) if err != nil { diff --git a/internal/control/accounts.go b/internal/control/accounts.go index bd9f8a45..85558c17 100644 --- a/internal/control/accounts.go +++ b/internal/control/accounts.go @@ -7,6 +7,7 @@ import ( "errors" "github.com/caigee-cmd/cli2api/internal/accounts" + "github.com/caigee-cmd/cli2api/internal/events" "github.com/caigee-cmd/cli2api/internal/providers" ) @@ -21,6 +22,9 @@ type Runtime interface { Accounts(ctx context.Context) ([]accounts.AccountView, error) RefreshAccount(ctx context.Context, id string, forceQuota bool) error RefreshAll(ctx context.Context, forceQuota bool) error + RefreshAllResults(ctx context.Context, forceQuota, includeDisabled bool) []accounts.AccountRefreshResult + RefreshAllAsync(ctx context.Context, forceQuota, includeDisabled bool) + SubscribeEvents(lastSeq uint64) (<-chan events.Event, func()) CheckinAccount(ctx context.Context, accountID string) (accounts.Account, error) CheckinAll(ctx context.Context, force, includeDisabled bool) ([]accounts.CheckinAllResult, error) ReloadProxyURL(ctx context.Context, value string) error @@ -49,7 +53,10 @@ func (a *Accounts) store() accounts.AccountStore { func (a *Accounts) List(ctx context.Context, refresh bool) ([]accounts.AccountView, error) { if refresh { - _ = a.runtime.RefreshAll(ctx, true) + // Full fan-out runs in the background; the list returns the current + // real stored views immediately and per-account outcomes arrive via + // the event channel (and the persisted status/quota on next read). + a.runtime.RefreshAllAsync(ctx, true, false) } return a.runtime.Accounts(ctx) } @@ -165,6 +172,19 @@ func (a *Accounts) RefreshAll(ctx context.Context, forceQuota bool) error { return a.runtime.RefreshAll(ctx, forceQuota) } +// RefreshAllResults runs a full concurrent refresh and returns each account's +// real outcome (status, upstream error, fresh quota snapshot). +func (a *Accounts) RefreshAllResults(ctx context.Context, forceQuota, includeDisabled bool) []accounts.AccountRefreshResult { + return a.runtime.RefreshAllResults(ctx, forceQuota, includeDisabled) +} + +// TriggerRefresh starts a background full concurrent refresh. Per-account +// outcomes are persisted and published on the event channel; nothing is +// swallowed. +func (a *Accounts) TriggerRefresh(ctx context.Context) { + a.runtime.RefreshAllAsync(ctx, true, false) +} + func (a *Accounts) RefreshAccount(ctx context.Context, id string, forceQuota bool) error { return a.runtime.RefreshAccount(ctx, id, forceQuota) } diff --git a/internal/control/aggregation.go b/internal/control/aggregation.go index c1257f1d..e30fad6a 100644 --- a/internal/control/aggregation.go +++ b/internal/control/aggregation.go @@ -87,15 +87,19 @@ func (a *Aggregations) Create(ctx context.Context, input accounts.CreateAggregat } now := time.Now().UTC() created, err := a.store.InsertAggregation(ctx, accounts.Aggregation{ - ID: prepared.ID, - Name: prepared.Name, - Enabled: prepared.Enabled, - Strategy: prepared.Strategy, - AllowFallbacks: prepared.AllowFallbacks, - MaxAttempts: prepared.MaxAttempts, - Members: prepared.Members, - CreatedAt: now, - UpdatedAt: now, + ID: prepared.ID, + Name: prepared.Name, + Enabled: prepared.Enabled, + Strategy: prepared.Strategy, + AllowFallbacks: prepared.AllowFallbacks, + MaxAttempts: prepared.MaxAttempts, + ContextLength: prepared.ContextLength, + MaxOutputTokens: prepared.MaxOutputTokens, + ReasoningOptions: prepared.ReasoningOptions, + ReasoningEffort: prepared.ReasoningEffort, + Members: prepared.Members, + CreatedAt: now, + UpdatedAt: now, }) if err != nil { return accounts.Aggregation{}, err diff --git a/internal/control/aggregation_catalog.go b/internal/control/aggregation_catalog.go index 57ef30bc..4533d82e 100644 --- a/internal/control/aggregation_catalog.go +++ b/internal/control/aggregation_catalog.go @@ -3,19 +3,64 @@ package control import ( "context" "sort" + "strings" "github.com/caigee-cmd/cli2api/internal/accounts" + "github.com/caigee-cmd/cli2api/internal/providers" ) type AggregationLister interface { List(ctx context.Context) ([]accounts.Aggregation, error) } +// aggregationCatalogMember is one configured member resolved to the catalog +// entry that actually serves it. Provider and region are honored so a member +// never borrows another provider's copy of the same model name. +type aggregationCatalogMember struct { + id string + entry map[string]any +} + +// aggregationCapabilities is the conservative intersection of every resolved +// member's declared capabilities. A logical model fails over between members, +// so anything advertised here must hold for all of them. +type aggregationCapabilities struct { + window int + hasWindow bool + maxOutput int + hasMaxOutput bool + promptMax int + hasPromptMax bool + reasoning []string + hasReasoning bool + defaultReasoning string + hasDefault bool + reasoningType string + hasReasoningType bool + images bool + canDisableThink bool +} + +// inheritedAggregationFields are decoration and provider metadata that must not +// survive into a provider-neutral logical entry. The merge starts from the +// first member's (already decorated) catalog row, so these either describe one +// member or duplicate a field this function re-derives. +var inheritedAggregationFields = []string{ + "alias_of", "native_model", "mapped_key", "region", "regions", "credits", "free", + "catalog_context_length", "catalog_context_length_max", + "max_output_tokens", "max_output_tokens_max", + "prompt_max_tokens", "prompt_max_tokens_max", + "supports_max_mode", "can_disable_thinking", "supports_images", + "reasoning_options", "reasoning_option_values", "reasoning_default", "reasoning_type", + "context_length", "default_context_length", "context_custom", "context_editable", + "settings_key", "max_mode", "reasoning_effort", +} + // MergeAggregationModels folds enabled logical models into the display catalog. -// Each aggregated entry is built by merging the capability fields of all its -// member models (conservative intersection), then member models are hidden so -// clients see one stable ID instead of one row per provider. Models that are -// not part of any enabled aggregation are left untouched. +// Each logical entry advertises the conservative intersection of its members' +// capabilities (or the operator-configured overrides), then member models are +// hidden so clients see one stable ID instead of one row per provider. Models +// that are not part of any enabled aggregation are left untouched. // // The catalog slices passed in/out are plain value maps, so this never mutates // the shared catalog cache. @@ -28,48 +73,23 @@ func MergeAggregationModels(ctx context.Context, lister AggregationLister, model return models } - byID := make(map[string]map[string]any, len(models)) - for _, model := range models { - id, _ := model["id"].(string) - if id != "" { - byID[id] = model - } - } - + index := aggregationCatalogIndex(models) hidden := map[string]bool{} entries := make([]map[string]any, 0, len(aggs)) for _, agg := range aggs { if !agg.Enabled || len(agg.Members) == 0 { continue } - var merged map[string]any - for _, member := range agg.Members { - model := byID[member.Model] - if model == nil { - continue - } - hidden[member.Model] = true - if merged == nil { - merged = CloneModelEntry(model) - continue - } - MergeModelEntryCapabilities(merged, model) - } - if merged == nil { + members := resolveAggregationCatalogMembers(agg, index) + if len(members) == 0 { // Every member is filtered out by the caller's provider policy. Do // not advertise a logical ID that cannot route to any real model. continue } - merged["id"] = agg.ID - merged["display_name"] = agg.Name - merged["provider"] = "aggregation" - merged["owned_by"] = "aggregation" - merged["aggregation"] = true - merged["aggregation_strategy"] = string(agg.Strategy) - merged["aggregation_members"] = len(agg.Members) - delete(merged, "native_model") - delete(merged, "mapped_key") - entries = append(entries, merged) + for _, member := range members { + hidden[member.id] = true + } + entries = append(entries, buildAggregationEntry(agg, members)) } if len(entries) == 0 && len(hidden) == 0 { return models @@ -91,3 +111,243 @@ func MergeAggregationModels(ctx context.Context, lister AggregationLister, model }) return out } + +// aggregationCatalogIndex groups catalog rows by (provider family, canonical +// model name). The shared catalog keeps one row per provider, so an index keyed +// by id alone would let whichever provider was appended last win. +func aggregationCatalogIndex(models []map[string]any) map[string][]map[string]any { + index := make(map[string][]map[string]any, len(models)) + for _, model := range models { + id, _ := model["id"].(string) + if strings.TrimSpace(id) == "" { + continue + } + key := aggregationCatalogKey(modelEntryProvider(model), modelAllowKey(id)) + if key == "" { + continue + } + index[key] = append(index[key], model) + } + return index +} + +func aggregationCatalogKey(provider, modelKey string) string { + provider = accounts.NormalizeProviderFamily(provider) + if provider == "" || modelKey == "" { + return "" + } + return provider + "\x00" + modelKey +} + +func resolveAggregationCatalogMembers(agg accounts.Aggregation, index map[string][]map[string]any) []aggregationCatalogMember { + resolved := make([]aggregationCatalogMember, 0, len(agg.Members)) + for _, member := range agg.Members { + key := aggregationCatalogKey(member.Provider, modelAllowKey(member.Model)) + if key == "" { + continue + } + var picked map[string]any + for _, candidate := range index[key] { + if member.Region == "" || accountServesRegion(member.Region, EntryModelRegions(candidate)) { + picked = candidate + break + } + } + if picked == nil { + continue + } + id, _ := picked["id"].(string) + resolved = append(resolved, aggregationCatalogMember{id: id, entry: picked}) + } + return resolved +} + +func summarizeAggregationCapabilities(members []aggregationCatalogMember) aggregationCapabilities { + caps := aggregationCapabilities{hasReasoning: len(members) > 0, images: true, canDisableThink: true} + var reasoningSets []map[string]bool + for index, member := range members { + options := reasoningValues(member.entry) + if len(options) == 0 { + caps.hasReasoning = false + reasoningSets = append(reasoningSets, nil) + } else { + set := make(map[string]bool, len(options)) + for _, option := range providers.UniqueReasoningOptions(options) { + set[option] = true + } + reasoningSets = append(reasoningSets, set) + } + + level, _ := member.entry["reasoning_default"].(string) + level = providers.NormalizeReasoningLevel(level) + if index == 0 { + caps.defaultReasoning = level + caps.hasDefault = level != "" + } else if level != caps.defaultReasoning { + // Members disagree on the default: advertise none rather than pick one + // member's choice for the whole pool. + caps.hasDefault = false + } + + reasoningType, _ := member.entry["reasoning_type"].(string) + reasoningType = strings.TrimSpace(reasoningType) + if index == 0 { + caps.reasoningType = reasoningType + caps.hasReasoningType = reasoningType != "" + } else if reasoningType != caps.reasoningType { + caps.hasReasoningType = false + } + + if supported, ok := member.entry["supports_images"].(bool); !ok || !supported { + caps.images = false + } + if enabled, ok := member.entry["can_disable_thinking"].(bool); !ok || !enabled { + caps.canDisableThink = false + } + } + caps.hasReasoning = caps.hasReasoning && len(reasoningSets) > 0 + caps.window, caps.hasWindow = minDeclaredCatalogInt(members, "catalog_context_length") + caps.maxOutput, caps.hasMaxOutput = minDeclaredCatalogInt(members, "max_output_tokens") + caps.promptMax, caps.hasPromptMax = minDeclaredCatalogInt(members, "prompt_max_tokens") + if caps.hasReasoning { + caps.reasoning = intersectReasoningOptions(reasoningSets) + if len(caps.reasoning) == 0 { + caps.hasReasoning = false + } + } + if caps.hasDefault && !reasoningAccepted(caps.reasoning, caps.defaultReasoning) { + caps.hasDefault = false + } + return caps +} + +// minDeclaredCatalogInt returns the smallest value every member declares. A +// member that does not declare the field makes the whole capability unknown: +// the logical model fails over between members, so the conservative answer is +// no claim rather than the maximum of what some members happen to report. +func minDeclaredCatalogInt(members []aggregationCatalogMember, field string) (int, bool) { + value := 0 + for _, member := range members { + declared, ok := catalogInt(member.entry[field]) + if !ok || declared <= 0 { + return 0, false + } + if value == 0 || declared < value { + value = declared + } + } + return value, value > 0 +} + +func intersectReasoningOptions(sets []map[string]bool) []string { + if len(sets) == 0 || sets[0] == nil { + return nil + } + out := make([]string, 0, len(sets[0])) + for level := range sets[0] { + inAll := true + for _, set := range sets[1:] { + if set == nil || !set[level] { + inAll = false + break + } + } + if inAll { + out = append(out, level) + } + } + sort.Slice(out, func(i, j int) bool { + return aggregationReasoningOrder(out[i]) < aggregationReasoningOrder(out[j]) + }) + return out +} + +// aggregationReasoningOrder positions a level on the gateway vocabulary so +// the advertised list is deterministic. +func aggregationReasoningOrder(level string) int { + for index, option := range providers.GatewayReasoningOptions() { + if option == level { + return index + } + } + return len(providers.GatewayReasoningOptions()) +} + +func reasoningAccepted(options []string, level string) bool { + for _, option := range options { + if option == level { + return true + } + } + return false +} + +// buildAggregationEntry derives one provider-neutral catalog row. Configured +// overrides win; otherwise every capability is the conservative intersection +// computed from the resolved members. +func buildAggregationEntry(agg accounts.Aggregation, members []aggregationCatalogMember) map[string]any { + entry := CloneModelEntry(members[0].entry) + for _, field := range inheritedAggregationFields { + delete(entry, field) + } + caps := summarizeAggregationCapabilities(members) + + entry["id"] = agg.ID + entry["display_name"] = agg.Name + entry["provider"] = "aggregation" + entry["owned_by"] = "aggregation" + entry["aggregation"] = true + entry["aggregation_strategy"] = string(agg.Strategy) + entry["aggregation_members"] = len(agg.Members) + entry["context_editable"] = false + + window := agg.ContextLength + if window <= 0 && caps.hasWindow { + window = caps.window + } + if window > 0 { + entry["catalog_context_length"] = window + entry["context_length"] = window + entry["default_context_length"] = window + } + if agg.ContextLength > 0 { + entry["context_custom"] = true + } + + maxOutput := agg.MaxOutputTokens + if maxOutput <= 0 && caps.hasMaxOutput { + maxOutput = caps.maxOutput + } + if maxOutput > 0 { + entry["max_output_tokens"] = maxOutput + } + if caps.hasPromptMax { + entry["prompt_max_tokens"] = caps.promptMax + } + + options := providers.UniqueReasoningOptions(agg.ReasoningOptions) + if len(options) == 0 && caps.hasReasoning { + options = caps.reasoning + } + if len(options) > 0 { + entry["reasoning_options"] = options + } + effort := agg.ReasoningEffort + if effort == "" && caps.hasDefault { + effort = caps.defaultReasoning + } + if effort != "" && reasoningAccepted(options, effort) { + entry["reasoning_default"] = effort + entry["reasoning_effort"] = effort + } + if caps.hasReasoningType { + entry["reasoning_type"] = caps.reasoningType + } + // Both flags are failover-safe only when every member declares them: a + // client trusts them for every retry hop, not just the first attempt. + entry["supports_images"] = caps.images + if caps.canDisableThink { + entry["can_disable_thinking"] = true + } + return entry +} diff --git a/internal/control/aggregation_catalog_test.go b/internal/control/aggregation_catalog_test.go index 7b952d16..63b549fd 100644 --- a/internal/control/aggregation_catalog_test.go +++ b/internal/control/aggregation_catalog_test.go @@ -42,3 +42,143 @@ func TestMergeAggregationModelsKeepsAggregationWithOneVisibleMember(t *testing.T t.Fatalf("expected aggregation provider, got %#v", got[0]) } } + +func aggregationTestEntry(models []map[string]any, id string) map[string]any { + for _, model := range models { + if model["id"] == id { + return model + } + } + return nil +} + +func TestMergeAggregationModelsResolvesMemberByProvider(t *testing.T) { + models := []map[string]any{ + {"id": "glm-5.2", "provider": "qoder", "catalog_context_length": 200000, "max_output_tokens": 64000}, + {"id": "glm-5.2", "provider": "workbuddy", "regions": []string{"cn"}, "catalog_context_length": 128000, "max_output_tokens": 32000}, + } + list := aggregationCatalogLister{{ + ID: "pool", Name: "Pool", Enabled: true, + Members: []accounts.AggregationMember{{Provider: "workbuddy", Region: "cn", Model: "glm-5.2"}}, + }} + got := MergeAggregationModels(context.Background(), list, models) + if len(got) != 1 { + t.Fatalf("both provider rows should be hidden, got %#v", got) + } + entry := got[0] + if entry["catalog_context_length"] != 128000 || entry["max_output_tokens"] != 32000 { + t.Fatalf("member pinned to workbuddy picked another provider's capabilities: %#v", entry) + } + if entry["context_length"] != 128000 || entry["default_context_length"] != 128000 { + t.Fatalf("display window = %v/%v", entry["context_length"], entry["default_context_length"]) + } +} + +func TestMergeAggregationModelsStaysConservativeAcrossMembers(t *testing.T) { + models := []map[string]any{ + { + "id": "model-a", "provider": "qoder", + "catalog_context_length": 200000, "max_output_tokens": 64000, "prompt_max_tokens": 160000, + "reasoning_options": []string{"none", "low", "medium", "high", "max"}, + "reasoning_default": "medium", "supports_images": true, "can_disable_thinking": true, + }, + { + "id": "model-b", "provider": "workbuddy", + "catalog_context_length": 128000, "max_output_tokens": 32000, "prompt_max_tokens": 100000, + "reasoning_options": []string{"high", "max"}, + "reasoning_default": "high", "supports_images": false, + }, + } + list := aggregationCatalogLister{{ + ID: "pool", Name: "Pool", Enabled: true, + Members: []accounts.AggregationMember{ + {Provider: "qoder", Model: "model-a"}, + {Provider: "workbuddy", Model: "model-b"}, + }, + }} + got := MergeAggregationModels(context.Background(), list, models) + entry := aggregationTestEntry(got, "pool") + if entry == nil { + t.Fatalf("missing logical entry: %#v", got) + } + if entry["catalog_context_length"] != 128000 || entry["max_output_tokens"] != 32000 || entry["prompt_max_tokens"] != 100000 { + t.Fatalf("numeric intersection = %#v", entry) + } + options, _ := entry["reasoning_options"].([]string) + if len(options) != 2 || options[0] != "high" || options[1] != "max" { + t.Fatalf("reasoning options = %#v", entry["reasoning_options"]) + } + if entry["reasoning_default"] != nil || entry["reasoning_effort"] != nil { + t.Fatalf("members disagree on default, got %#v", entry["reasoning_default"]) + } + if entry["supports_images"] != false || entry["can_disable_thinking"] != nil { + t.Fatalf("boolean intersection = %#v", entry) + } + if entry["supports_max_mode"] != nil || entry["max_mode"] != nil { + t.Fatalf("aggregation must not advertise a max tier: %#v", entry["supports_max_mode"]) + } +} + +func TestMergeAggregationModelsAppliesConfiguredOverrides(t *testing.T) { + models := []map[string]any{{ + "id": "model-a", "provider": "qoder", + "catalog_context_length": 200000, "max_output_tokens": 64000, + "reasoning_options": []string{"none", "low", "medium", "high", "max"}, + "reasoning_default": "medium", + }} + list := aggregationCatalogLister{{ + ID: "pool", Name: "Pool", Enabled: true, + ContextLength: 1_000_000, MaxOutputTokens: 32000, + ReasoningOptions: []string{"low", "high", "max"}, ReasoningEffort: "high", + Members: []accounts.AggregationMember{{Provider: "qoder", Model: "model-a"}}, + }} + got := MergeAggregationModels(context.Background(), list, models) + entry := aggregationTestEntry(got, "pool") + if entry == nil { + t.Fatalf("missing logical entry: %#v", got) + } + if entry["catalog_context_length"] != 1_000_000 || entry["context_length"] != 1_000_000 || entry["default_context_length"] != 1_000_000 { + t.Fatalf("context override = %#v", entry) + } + if entry["max_output_tokens"] != 32000 || entry["context_custom"] != true { + t.Fatalf("max output override = %#v", entry) + } + options, _ := entry["reasoning_options"].([]string) + if len(options) != 3 || options[0] != "low" || options[1] != "high" || options[2] != "max" { + t.Fatalf("reasoning override = %#v", entry["reasoning_options"]) + } + if entry["reasoning_default"] != "high" || entry["reasoning_effort"] != "high" { + t.Fatalf("default effort = %#v", entry["reasoning_default"]) + } +} + +func TestMergeAggregationModelsDropsInheritedDecoration(t *testing.T) { + models := []map[string]any{{ + "id": "model-a", "provider": "qoder", "native_model": "native-a", "alias_of": "target", + "catalog_context_length": 200000, + "context_length": 1_000_000, "default_context_length": 1_000_000, + "reasoning_effort": "max", "max_mode": true, "context_custom": true, + "settings_key": "k1", "region": "global", "regions": []string{"global"}, + "credits": "x", "free": true, "supports_max_mode": true, + }} + list := aggregationCatalogLister{{ + ID: "pool", Name: "Pool", Enabled: true, + Members: []accounts.AggregationMember{{Provider: "qoder", Model: "model-a"}}, + }} + got := MergeAggregationModels(context.Background(), list, models) + entry := aggregationTestEntry(got, "pool") + if entry == nil { + t.Fatalf("missing logical entry: %#v", got) + } + for _, field := range []string{"native_model", "alias_of", "region", "regions", "credits", "free", "supports_max_mode", "max_mode", "settings_key", "reasoning_effort"} { + if entry[field] != nil { + t.Fatalf("%s leaked into the aggregation entry: %#v", field, entry[field]) + } + } + if entry["context_length"] != 200000 || entry["default_context_length"] != 200000 { + t.Fatalf("decorated window leaked: %#v", entry) + } + if entry["context_editable"] != false { + t.Fatalf("context_editable = %v", entry["context_editable"]) + } +} diff --git a/internal/control/catalog_policy.go b/internal/control/catalog_policy.go index 5b72e451..0adafc32 100644 --- a/internal/control/catalog_policy.go +++ b/internal/control/catalog_policy.go @@ -687,7 +687,10 @@ func decorateProviderSettings(ctx context.Context, settings *Settings, item map[ if settings != nil { setting, _ = settings.GetProviderModelSetting(ctx, provider, settingsKey) } - maxMode := setting.MaxMode && supportsMax && provider == "trae" + // Trae models with a real Max tier stay unlocked: the adapter asks upstream + // for the larger window on every request, so the console shows one context + // size instead of a per-model switch. + maxMode := supportsMax && provider == "trae" item["max_mode"] = maxMode window := dev if maxMode && max > 0 { @@ -699,8 +702,8 @@ func decorateProviderSettings(ctx context.Context, settings *Settings, item map[ } // The prompt/output ceilings deliberately stay at the default tier here. The // console selects the Max tier from prompt_max_tokens_max / max_output_tokens_max - // at render time based on the toggle, so turning max mode off always restores - // the default tier instead of leaving the mutated Max value in place. + // at render time, so the advertised ceiling follows the tier the adapter + // actually asks for instead of leaving a mutated Max value in place. defaultLevel, _ := item["reasoning_default"].(string) selected := defaultLevel if setting.ReasoningEffort != "" { diff --git a/internal/control/catalog_source_test.go b/internal/control/catalog_source_test.go index 3f4c99a3..d1282dfd 100644 --- a/internal/control/catalog_source_test.go +++ b/internal/control/catalog_source_test.go @@ -509,11 +509,10 @@ func TestDecorateKeepsMaxModeForCeilingOnlyTier(test *testing.T) { } } -// The Trae max-mode toggle switches the window server-side, but the prompt and -// output ceilings stay at their catalog defaults — the console resolves the Max -// tier from *_max at render time. This keeps the toggle reversible: turning max -// mode off must never leave a mutated Max ceiling behind. -func TestDecorateTraeMaxModeSwitchesWindowNotCeilings(t *testing.T) { +// A Trae model with a real Max tier is unlocked by the catalogue itself: the +// window the console advertises is the larger tier, with no stored setting +// needed, while the prompt and output ceilings stay at their catalog defaults. +func TestDecorateTraeMaxWindowIsUnlockedWithoutSetting(t *testing.T) { entry := map[string]any{ "id": "glm-5.3", "provider": "trae", "catalog_context_length": 200000, "catalog_context_length_max": 1000000, @@ -521,24 +520,19 @@ func TestDecorateTraeMaxModeSwitchesWindowNotCeilings(t *testing.T) { "prompt_max_tokens_max": 936000, "max_output_tokens_max": 64000, "supports_max_mode": true, "reasoning_default": "high", } - // max_mode off -> default window, ceilings at baseline. store := newFakeStore(&callLog{}) - off := DecorateModelsWithContext(context.Background(), NewSettings(store), []map[string]any{cloneMap(entry)}) - if off[0]["context_length"] != 200000 || off[0]["prompt_max_tokens"] != 168000 || off[0]["max_output_tokens"] != 32000 { - t.Fatalf("off tier=%v", off[0]) - } - // max_mode on -> max window; ceilings stay at baseline (frontend picks *_max). - storeOn := newFakeStore(&callLog{}) - storeOn.providerSetting.MaxMode = true - on := DecorateModelsWithContext(context.Background(), NewSettings(storeOn), []map[string]any{cloneMap(entry)}) - if on[0]["context_length"] != 1000000 { - t.Fatalf("on window=%v", on[0]) - } - if on[0]["prompt_max_tokens"] != 168000 || on[0]["max_output_tokens"] != 32000 { - t.Fatalf("ceilings must stay at baseline: %v", on[0]) - } - if on[0]["prompt_max_tokens_max"] != 936000 || on[0]["max_output_tokens_max"] != 64000 { - t.Fatalf("max tier must remain available: %v", on[0]) + decorated := DecorateModelsWithContext(context.Background(), NewSettings(store), []map[string]any{cloneMap(entry)}) + if decorated[0]["max_mode"] != true || decorated[0]["context_length"] != 1000000 { + t.Fatalf("max tier not unlocked: %v", decorated[0]) + } + if decorated[0]["default_context_length"] != 200000 { + t.Fatalf("default tier lost: %v", decorated[0]) + } + if decorated[0]["prompt_max_tokens"] != 168000 || decorated[0]["max_output_tokens"] != 32000 { + t.Fatalf("ceilings must stay at baseline: %v", decorated[0]) + } + if decorated[0]["prompt_max_tokens_max"] != 936000 || decorated[0]["max_output_tokens_max"] != 64000 { + t.Fatalf("max tier must remain available: %v", decorated[0]) } } diff --git a/internal/control/control.go b/internal/control/control.go index 56861b59..6b170887 100644 --- a/internal/control/control.go +++ b/internal/control/control.go @@ -1,5 +1,7 @@ package control +import "github.com/caigee-cmd/cli2api/internal/events" + // Services is the console application surface assembled by app.New. type Services struct { Accounts *Accounts @@ -9,6 +11,8 @@ type Services struct { Backup *Backup Catalog *Catalog Aggregations *Aggregations + + runtime Runtime } func New(runtime Runtime) *Services { @@ -24,5 +28,17 @@ func New(runtime Runtime) *Services { Settings: NewSettings(store), Backup: NewBackup(store), Aggregations: NewAggregations(store, provider), + runtime: runtime, + } +} + +// SubscribeEvents exposes the real backend state-change stream (quota, +// check-in, health/cooldown, bulk progress) to the console SSE handler. +func (s *Services) SubscribeEvents(lastSeq uint64) (<-chan events.Event, func()) { + if s == nil || s.runtime == nil { + ch := make(chan events.Event) + close(ch) + return ch, func() {} } + return s.runtime.SubscribeEvents(lastSeq) } diff --git a/internal/control/provider_settings_integration_test.go b/internal/control/provider_settings_integration_test.go index 3988fbbe..a702f062 100644 --- a/internal/control/provider_settings_integration_test.go +++ b/internal/control/provider_settings_integration_test.go @@ -6,6 +6,7 @@ import ( "testing" "github.com/caigee-cmd/cli2api/internal/accounts" + "github.com/caigee-cmd/cli2api/internal/events" "github.com/caigee-cmd/cli2api/internal/providers" "github.com/caigee-cmd/cli2api/internal/store" ) @@ -35,6 +36,15 @@ func (r *providerTestRuntime) Accounts(context.Context) ([]accounts.AccountView, } func (r *providerTestRuntime) RefreshAccount(context.Context, string, bool) error { return nil } func (r *providerTestRuntime) RefreshAll(context.Context, bool) error { return nil } +func (r *providerTestRuntime) RefreshAllResults(context.Context, bool, bool) []accounts.AccountRefreshResult { + return nil +} +func (r *providerTestRuntime) RefreshAllAsync(context.Context, bool, bool) {} +func (r *providerTestRuntime) SubscribeEvents(uint64) (<-chan events.Event, func()) { + ch := make(chan events.Event) + close(ch) + return ch, func() {} +} func (r *providerTestRuntime) CheckinAccount(context.Context, string) (accounts.Account, error) { return accounts.Account{}, nil } diff --git a/internal/control/s06_control_test.go b/internal/control/s06_control_test.go index e7baf583..1d0477de 100644 --- a/internal/control/s06_control_test.go +++ b/internal/control/s06_control_test.go @@ -9,6 +9,7 @@ import ( "time" "github.com/caigee-cmd/cli2api/internal/accounts" + "github.com/caigee-cmd/cli2api/internal/events" "github.com/caigee-cmd/cli2api/internal/providers" ) @@ -386,6 +387,22 @@ func (r *fakeRuntime) RefreshAll(_ context.Context, forceQuota bool) error { r.forceQuota = forceQuota return r.refreshErr } +func (r *fakeRuntime) RefreshAllResults(_ context.Context, forceQuota, _ bool) []accounts.AccountRefreshResult { + r.log.add("runtime.RefreshAllResults") + r.refreshAll = true + r.forceQuota = forceQuota + return nil +} +func (r *fakeRuntime) RefreshAllAsync(_ context.Context, forceQuota, _ bool) { + r.log.add("runtime.RefreshAllAsync") + r.refreshAll = true + r.forceQuota = forceQuota +} +func (r *fakeRuntime) SubscribeEvents(uint64) (<-chan events.Event, func()) { + ch := make(chan events.Event) + close(ch) + return ch, func() {} +} func (r *fakeRuntime) CheckinAccount(_ context.Context, id string) (accounts.Account, error) { r.log.add("runtime.CheckinAccount") if r.checkinErr != nil { @@ -511,7 +528,7 @@ func TestUpdateReadsStoreAfterRuntime(t *testing.T) { } } -func TestListRefreshUsesForceQuotaThenAccounts(t *testing.T) { +func TestListRefreshTriggersAsyncRefreshThenAccounts(t *testing.T) { svc, runtime, _, log := newTestServices() runtime.views = []accounts.AccountView{{Account: accounts.Account{ID: "acc-1"}}} items, err := svc.Accounts.List(context.Background(), true) @@ -521,7 +538,7 @@ func TestListRefreshUsesForceQuotaThenAccounts(t *testing.T) { if !runtime.refreshAll || !runtime.forceQuota { t.Fatalf("refreshAll=%v forceQuota=%v", runtime.refreshAll, runtime.forceQuota) } - if got := log.names; !equalCalls(got, []string{"runtime.RefreshAll", "runtime.Accounts"}) { + if got := log.names; !equalCalls(got, []string{"runtime.RefreshAllAsync", "runtime.Accounts"}) { t.Fatalf("calls=%v", got) } } diff --git a/internal/control/settings_bootstrap.go b/internal/control/settings_bootstrap.go index 43215dee..72e55729 100644 --- a/internal/control/settings_bootstrap.go +++ b/internal/control/settings_bootstrap.go @@ -14,6 +14,7 @@ const ( routingStrategySecret = "routing_strategy" proxyURLSecret = "proxy_url" checkinDisabledAccountsSecret = accounts.CheckinDisabledAccountsSecret + quotaFreshIntervalSecret = accounts.QuotaFreshIntervalSecret ) func EnsureProxyURL(ctx context.Context, store SecretStore, bootstrap string) (string, error) { diff --git a/internal/control/system.go b/internal/control/system.go index 1da832b0..a5186585 100644 --- a/internal/control/system.go +++ b/internal/control/system.go @@ -2,14 +2,16 @@ package control import ( "context" - "github.com/caigee-cmd/cli2api/internal/accounts" - "github.com/caigee-cmd/cli2api/internal/executor" - "github.com/caigee-cmd/cli2api/internal/providers" - "github.com/caigee-cmd/cli2api/internal/proxy" + "strconv" "strings" "sync" "sync/atomic" "time" + + "github.com/caigee-cmd/cli2api/internal/accounts" + "github.com/caigee-cmd/cli2api/internal/executor" + "github.com/caigee-cmd/cli2api/internal/providers" + "github.com/caigee-cmd/cli2api/internal/proxy" ) type System struct { @@ -21,28 +23,31 @@ type System struct { Mu *sync.Mutex } type SystemSettingsPatch struct { - CrossProviderModelPool *bool `json:"cross_provider_model_pool"` - CheckinDisabledAccounts *bool `json:"checkin_disabled_accounts"` - RoutingStrategy *string `json:"routing_strategy"` - ProxyURL *string `json:"proxy_url"` - WorkBuddyCheckinTime *string `json:"workbuddy_checkin_time"` - CheckinTimes map[string]string `json:"checkin_times"` + CrossProviderModelPool *bool `json:"cross_provider_model_pool"` + CheckinDisabledAccounts *bool `json:"checkin_disabled_accounts"` + RoutingStrategy *string `json:"routing_strategy"` + ProxyURL *string `json:"proxy_url"` + WorkBuddyCheckinTime *string `json:"workbuddy_checkin_time"` + CheckinTimes map[string]string `json:"checkin_times"` + QuotaFreshIntervalSeconds *int `json:"quota_fresh_interval_seconds"` } type SystemSettings struct { - CrossProviderModelPool bool `json:"cross_provider_model_pool"` - CheckinDisabledAccounts bool `json:"checkin_disabled_accounts"` - RoutingStrategy string `json:"routing_strategy"` - ProxyURL string `json:"proxy_url"` - WorkBuddyCheckinTime string `json:"workbuddy_checkin_time"` - CheckinTimes map[string]string `json:"checkin_times"` - Timezone string `json:"timezone"` - SessionAffinity executor.SessionAffinityStats `json:"session_affinity"` + CrossProviderModelPool bool `json:"cross_provider_model_pool"` + CheckinDisabledAccounts bool `json:"checkin_disabled_accounts"` + RoutingStrategy string `json:"routing_strategy"` + ProxyURL string `json:"proxy_url"` + WorkBuddyCheckinTime string `json:"workbuddy_checkin_time"` + CheckinTimes map[string]string `json:"checkin_times"` + Timezone string `json:"timezone"` + SessionAffinity executor.SessionAffinityStats `json:"session_affinity"` + QuotaFreshIntervalSeconds int `json:"quota_fresh_interval_seconds"` } func (h *System) Current(ctx context.Context) SystemSettings { var proxyURL string checkin := "" checkinDisabledAccounts := false + quotaFreshInterval := accounts.DefaultQuotaFreshIntervalSeconds if h.Settings != nil { proxyURL, _, _ = h.Settings.GetSecret(ctx, proxyURLSecret) checkin = h.Settings.WorkBuddyCheckinTimeDefault(ctx) @@ -50,14 +55,22 @@ func (h *System) Current(ctx context.Context) SystemSettings { if ok && err == nil { checkinDisabledAccounts, _ = parseSettingBool(value) } + if raw, ok, err := h.Settings.GetSecret(ctx, quotaFreshIntervalSecret); ok && err == nil && strings.TrimSpace(raw) != "" { + if seconds, convErr := strconv.Atoi(strings.TrimSpace(raw)); convErr == nil { + if normalized, normErr := accounts.NormalizeQuotaFreshIntervalSeconds(seconds); normErr == nil { + quotaFreshInterval = normalized + } + } + } } settings := SystemSettings{ - CrossProviderModelPool: h.CrossProviderPool.Load(), - CheckinDisabledAccounts: checkinDisabledAccounts, - ProxyURL: proxy.Redact(proxyURL), - WorkBuddyCheckinTime: checkin, - CheckinTimes: map[string]string{}, - Timezone: time.Now().Format("MST -07:00"), + CrossProviderModelPool: h.CrossProviderPool.Load(), + CheckinDisabledAccounts: checkinDisabledAccounts, + ProxyURL: proxy.Redact(proxyURL), + WorkBuddyCheckinTime: checkin, + CheckinTimes: map[string]string{}, + Timezone: time.Now().Format("MST -07:00"), + QuotaFreshIntervalSeconds: quotaFreshInterval, } for _, descriptor := range providers.List() { if descriptor.SupportsCheckin() && h.Settings != nil { @@ -74,9 +87,14 @@ func (h *System) Current(ctx context.Context) SystemSettings { } func (h *System) Patch(ctx context.Context, input SystemSettingsPatch) error { - if input.CrossProviderModelPool == nil && input.CheckinDisabledAccounts == nil && input.RoutingStrategy == nil && input.ProxyURL == nil && input.WorkBuddyCheckinTime == nil && len(input.CheckinTimes) == 0 { + if input.CrossProviderModelPool == nil && input.CheckinDisabledAccounts == nil && input.RoutingStrategy == nil && input.ProxyURL == nil && input.WorkBuddyCheckinTime == nil && len(input.CheckinTimes) == 0 && input.QuotaFreshIntervalSeconds == nil { return operationError("invalid_request", "a system setting is required") } + if input.QuotaFreshIntervalSeconds != nil { + if _, err := accounts.NormalizeQuotaFreshIntervalSeconds(*input.QuotaFreshIntervalSeconds); err != nil { + return operationError("invalid_quota_fresh_interval", err.Error()) + } + } var strategy string if input.RoutingStrategy != nil { rawStrategy := strings.ToLower(strings.TrimSpace(*input.RoutingStrategy)) @@ -178,5 +196,10 @@ func (h *System) Patch(ctx context.Context, input SystemSettingsPatch) error { return operationError("system_settings_save_failed", err.Error()) } } + if input.QuotaFreshIntervalSeconds != nil { + if err := h.Settings.SetSecret(ctx, quotaFreshIntervalSecret, strconv.Itoa(*input.QuotaFreshIntervalSeconds)); err != nil { + return operationError("system_settings_save_failed", err.Error()) + } + } return nil } diff --git a/internal/events/events.go b/internal/events/events.go new file mode 100644 index 00000000..658ce0e7 --- /dev/null +++ b/internal/events/events.go @@ -0,0 +1,157 @@ +// Package events carries real console state changes from the runtime to the +// console SSE channel. Every event reflects an actual backend mutation (quota +// fetch, check-in record, cooldown/health merge, bulk-op progress); nothing is +// synthesized. The package is a leaf utility: runtime publishes, control +// exposes subscription, console streams — no boundary is crossed. +package events + +import ( + "sync" + "time" + + "github.com/caigee-cmd/cli2api/internal/accounts" +) + +// Event is one real state change. Seq is monotonic per bus and doubles as the +// SSE id; Time is the actual emit instant. +type Event struct { + Seq uint64 `json:"seq"` + Type string `json:"type"` + Time string `json:"time"` + AccountID string `json:"account_id,omitempty"` + OpID string `json:"op_id,omitempty"` + Data any `json:"data,omitempty"` +} + +// Event types. +const ( + TypeAccount = "account" // one account's real routing/health state changed + TypeAccounts = "accounts" // structural change: create/enable/disable/remove + TypeQuota = "quota" // a real upstream quota snapshot was persisted + TypeCheckin = "checkin" // a real check-in outcome was recorded + TypeRefresh = "refresh" // one account's real refresh outcome + TypeBulk = "bulk" // bulk-op progress (start / per-account / done) +) + +// AccountState is the real routing projection of one account after a health +// or cooldown merge. +type AccountState struct { + AccountID string `json:"account_id"` + RuntimeState string `json:"runtime_state,omitempty"` + Ready bool `json:"ready"` + CooldownUntil string `json:"cooldown_until,omitempty"` + LastError string `json:"last_error,omitempty"` + LastKind string `json:"last_kind,omitempty"` +} + +// QuotaState carries the exact snapshot persisted from upstream. +type QuotaState struct { + AccountID string `json:"account_id"` + Quota *accounts.QuotaSnapshot `json:"quota"` +} + +// CheckinState carries the verbatim provider check-in outcome. +type CheckinState struct { + AccountID string `json:"account_id"` + Status string `json:"status"` + Message string `json:"message,omitempty"` + RewardCredits float64 `json:"reward_credits,omitempty"` + At string `json:"at"` +} + +// BulkProgress reports one bulk operation's real per-account progress. +// Phase is "start", "account", or "done"; Result carries the per-account +// outcome (accounts.CheckinAllResult / accounts.AccountRefreshResult) on +// "account" and "done" frames. +type BulkProgress struct { + OpID string `json:"op_id"` + Kind string `json:"kind"` + Phase string `json:"phase"` + Total int `json:"total"` + Done int `json:"done"` + AccountID string `json:"account_id,omitempty"` + Result any `json:"result,omitempty"` +} + +const ( + ringSize = 1024 + subBuffer = ringSize + 64 +) + +// Bus is a bounded in-memory fan-out. Publishers never block: a subscriber +// that cannot keep up is closed, and its SSE client reconnects with +// Last-Event-ID to replay from the ring. +type Bus struct { + mu sync.Mutex + seq uint64 + ring []Event + subs map[chan Event]struct{} +} + +func NewBus() *Bus { + return &Bus{ring: make([]Event, 0, ringSize), subs: map[chan Event]struct{}{}} +} + +// Publish records one real event and fans it out to every subscriber. +func (b *Bus) Publish(eventType, accountID, opID string, data any) { + if b == nil { + return + } + b.mu.Lock() + defer b.mu.Unlock() + b.seq++ + event := Event{ + Seq: b.seq, + Type: eventType, + Time: time.Now().UTC().Format(time.RFC3339Nano), + AccountID: accountID, + OpID: opID, + Data: data, + } + if len(b.ring) == ringSize { + copy(b.ring, b.ring[1:]) + b.ring[len(b.ring)-1] = event + } else { + b.ring = append(b.ring, event) + } + for ch := range b.subs { + select { + case ch <- event: + default: + // Slow consumer: drop it. The client reconnects and replays. + delete(b.subs, ch) + close(ch) + } + } +} + +// Subscribe replays ring events newer than lastSeq, then streams live events. +// The returned cancel deregisters and closes the channel exactly once. +func (b *Bus) Subscribe(lastSeq uint64) (<-chan Event, func()) { + ch := make(chan Event, subBuffer) + if b == nil { + close(ch) + return ch, func() {} + } + b.mu.Lock() + b.subs[ch] = struct{}{} + for _, event := range b.ring { + if event.Seq > lastSeq { + // Buffer is sized to hold the whole ring, so replay never drops. + ch <- event + } + } + b.mu.Unlock() + var once sync.Once + cancel := func() { + once.Do(func() { + b.mu.Lock() + if _, ok := b.subs[ch]; ok { + delete(b.subs, ch) + close(ch) + } + b.mu.Unlock() + }) + } + return ch, cancel +} diff --git a/internal/events/events_test.go b/internal/events/events_test.go new file mode 100644 index 00000000..323f9a6b --- /dev/null +++ b/internal/events/events_test.go @@ -0,0 +1,104 @@ +package events + +import ( + "testing" + "time" +) + +func TestBusPublishAssignsMonotonicSeqAndTime(t *testing.T) { + bus := NewBus() + bus.Publish(TypeAccounts, "acc-1", "", nil) + bus.Publish(TypeQuota, "acc-1", "", QuotaState{AccountID: "acc-1"}) + stream, cancel := bus.Subscribe(0) + defer cancel() + first := <-stream + second := <-stream + if first.Seq != 1 || second.Seq != 2 { + t.Fatalf("seq = %d,%d", first.Seq, second.Seq) + } + if first.Type != TypeAccounts || second.Type != TypeQuota { + t.Fatalf("types = %s,%s", first.Type, second.Type) + } + if first.Time == "" { + t.Fatal("event time must be the real emit instant") + } + if _, err := time.Parse(time.RFC3339Nano, first.Time); err != nil { + t.Fatalf("event time not RFC3339Nano: %v", err) + } +} + +func TestBusReplaysOnlyEventsNewerThanLastSeq(t *testing.T) { + bus := NewBus() + for i := 0; i < 3; i++ { + bus.Publish(TypeQuota, "acc", "", nil) + } + stream, cancel := bus.Subscribe(2) + defer cancel() + replayed := <-stream + if replayed.Seq != 3 { + t.Fatalf("replayed seq = %d want 3", replayed.Seq) + } + // Live events continue after the replay. + bus.Publish(TypeCheckin, "acc", "", nil) + live := <-stream + if live.Seq != 4 || live.Type != TypeCheckin { + t.Fatalf("live = %+v", live) + } +} + +func TestBusFansOutToEverySubscriber(t *testing.T) { + bus := NewBus() + a, cancelA := bus.Subscribe(0) + defer cancelA() + b, cancelB := bus.Subscribe(0) + defer cancelB() + bus.Publish(TypeAccount, "acc", "", AccountState{AccountID: "acc", Ready: true}) + if got := <-a; got.AccountID != "acc" { + t.Fatalf("a = %+v", got) + } + if got := <-b; got.AccountID != "acc" { + t.Fatalf("b = %+v", got) + } +} + +func TestBusClosesSlowConsumerWithoutBlockingPublisher(t *testing.T) { + bus := NewBus() + slow, cancel := bus.Subscribe(0) + defer cancel() + // Fill the subscriber buffer plus the ring, so the slow consumer overflows + // and is closed while publishing stays non-blocking. + for i := 0; i < subBuffer+ringSize+10; i++ { + bus.Publish(TypeQuota, "acc", "", nil) + } + deadline := time.After(200 * time.Millisecond) + for { + select { + case _, ok := <-slow: + if !ok { + return // closed as designed + } + case <-deadline: + t.Fatal("slow consumer was not closed") + } + } +} + +func TestBusCancelIsIdempotent(t *testing.T) { + bus := NewBus() + stream, cancel := bus.Subscribe(0) + cancel() + cancel() // must not panic or double-close + if _, ok := <-stream; ok { + t.Fatal("canceled subscription must be closed") + } +} + +func TestNilBusIsSafe(t *testing.T) { + var bus *Bus + bus.Publish(TypeQuota, "acc", "", nil) + stream, cancel := bus.Subscribe(0) + cancel() + if _, ok := <-stream; ok { + t.Fatal("nil bus subscription must be closed") + } +} diff --git a/internal/executor/aggregation_e2e_test.go b/internal/executor/aggregation_e2e_test.go index 3b80f551..2f96c9f7 100644 --- a/internal/executor/aggregation_e2e_test.go +++ b/internal/executor/aggregation_e2e_test.go @@ -39,6 +39,7 @@ func TestAggregateFailoverSettingsDriveAttempts(t *testing.T) { Request: translate.ChatRequest{Model: "my-model", Messages: []translate.ChatMessage{{Role: "user", Content: "hi"}}}, Identity: auth.ConsoleIdentity(), CrossProviderPool: true, + ModelAggregation: true, Aggregations: resolver, Now: time.Now(), }) @@ -57,6 +58,7 @@ func TestAggregateFailoverSettingsDriveAttempts(t *testing.T) { Request: translate.ChatRequest{Model: "my-model", Messages: []translate.ChatMessage{{Role: "user", Content: "hi"}}}, Identity: auth.ConsoleIdentity(), CrossProviderPool: true, + ModelAggregation: true, Aggregations: resolver, Now: time.Now(), }) @@ -86,6 +88,7 @@ func TestAggregatePrepareToRoute(t *testing.T) { Request: translate.ChatRequest{Model: "my-model", Messages: []translate.ChatMessage{{Role: "user", Content: "hi"}}}, Identity: auth.ConsoleIdentity(), CrossProviderPool: true, + ModelAggregation: true, Aggregations: resolver, Now: time.Now(), }) diff --git a/internal/executor/aggregation_plan.go b/internal/executor/aggregation_plan.go index 5cdc696c..b5b1765f 100644 --- a/internal/executor/aggregation_plan.go +++ b/internal/executor/aggregation_plan.go @@ -17,6 +17,10 @@ type AggregatePlan struct { Strategy accounts.AggregationStrategy AllowFallbacks bool MaxAttempts int + // ReasoningEffort is the logical model's configured default level. It fills + // a request that carried no reasoning intent at all; it never overrides or + // caps a level the client actually asked for. + ReasoningEffort string // Members already filtered by the caller's provider grants and sorted by // priority. Immutable for the lifetime of the request. Members []accounts.AggregationMember @@ -29,12 +33,13 @@ type AggregatePlan struct { // snapshot whose Members slice will not be mutated afterwards. func NewAggregatePlan(agg accounts.Aggregation) *AggregatePlan { plan := &AggregatePlan{ - ID: agg.ID, - Strategy: agg.Strategy, - AllowFallbacks: agg.AllowFallbacks, - MaxAttempts: agg.MaxAttempts, - Members: agg.Members, - byProvider: make(map[string][]accounts.AggregationMember, len(agg.Members)), + ID: agg.ID, + Strategy: agg.Strategy, + AllowFallbacks: agg.AllowFallbacks, + MaxAttempts: agg.MaxAttempts, + ReasoningEffort: agg.ReasoningEffort, + Members: agg.Members, + byProvider: make(map[string][]accounts.AggregationMember, len(agg.Members)), } for _, member := range agg.Members { key := strings.ToLower(strings.TrimSpace(member.Provider)) diff --git a/internal/executor/cache_affinity_test.go b/internal/executor/cache_affinity_test.go new file mode 100644 index 00000000..a0ea1c0b --- /dev/null +++ b/internal/executor/cache_affinity_test.go @@ -0,0 +1,414 @@ +package executor + +import ( + "context" + "errors" + "net/http" + "sync" + "testing" + "time" + + "github.com/caigee-cmd/cli2api/internal/accounts" + "github.com/caigee-cmd/cli2api/internal/auth" + "github.com/caigee-cmd/cli2api/internal/providers" + "github.com/caigee-cmd/cli2api/internal/translate" +) + +// scriptedChat fails or succeeds per call index so a test can express +// "first attempt hiccups, second succeeds" without a real upstream. +type scriptedChat struct { + mu sync.Mutex + calls int + fn func(call int) (providers.ChatOutcome, error) +} + +func (s *scriptedChat) ChatNonStream(_ context.Context, _ string, req translate.ChatRequest) (providers.ChatOutcome, error) { + s.mu.Lock() + s.calls++ + call := s.calls + s.mu.Unlock() + return s.fn(call) +} + +func (s *scriptedChat) ChatStream(context.Context, string, translate.ChatRequest) (*http.Response, providers.ResolvedChat, error) { + return nil, providers.ResolvedChat{}, errors.New("stream not scripted") +} + +func (s *scriptedChat) Calls() int { + s.mu.Lock() + defer s.mu.Unlock() + return s.calls +} + +func inProcessExecutor(t *testing.T, chat providers.ProviderChat, items ...Item) ChatExecutor { + t.Helper() + pool := NewPool(nil, nil) + for _, item := range items { + if item.Provider == "" { + item.Provider = "workbuddy" + } + if item.Region == "" { + item.Region = "cn" + } + if item.Runtime == "" { + item.Runtime = string(providers.RuntimeInProcess) + } + pool.Upsert(item) + } + registry := providers.NewRegistry() + registry.Register(providers.Adapter{ID: "workbuddy", Chat: chat}) + ex := NewChatExecutor(pool, "") + ex.Providers = registry + return ex +} + +func okOutcome(req translate.ChatRequest) (providers.ChatOutcome, error) { + return providers.ChatOutcome{Model: req.Model, Content: "ok", FinishReason: "stop"}, nil +} + +func emptyStreamErr() error { + return &providers.Error{ + Kind: accounts.KindUnavailable, Status: 200, + Message: "upstream answered 200 but the stream was empty", Code: "upstream_empty", + } +} + +func TestTransientFailureRetriesSameAccountBeforeFailover(t *testing.T) { + chat := &scriptedChat{fn: func(call int) (providers.ChatOutcome, error) { + if call == 1 { + return providers.ChatOutcome{}, emptyStreamErr() + } + return providers.ChatOutcome{Model: "glm-5.2", Content: "ok", FinishReason: "stop"}, nil + }} + ex := inProcessExecutor(t, chat, Item{ID: "wb1"}) + + ctx := WithSessionKey(context.Background(), "retry-session") + result, err := ex.ChatNonStream(ctx, translate.ChatRequest{ + Model: "glm-5.2", Messages: []translate.ChatMessage{{Role: "user", Content: "hi"}}, + }, "", "") + if err != nil { + t.Fatalf("err = %v", err) + } + if result.AccountID != "wb1" { + t.Fatalf("account = %q, want wb1", result.AccountID) + } + // The retry must not consume the failover budget: this request had exactly + // one candidate account. + if result.AttemptCount != 1 { + t.Fatalf("attempt count = %d, want 1", result.AttemptCount) + } + if chat.Calls() != 2 { + t.Fatalf("adapter calls = %d, want 2", chat.Calls()) + } + if bound, ok := ex.SessionAffinity.Get("retry-session"); !ok || bound != "wb1" { + t.Fatalf("binding = %q ok=%v, want wb1", bound, ok) + } +} + +func TestRateLimitIsNotRetriedOnSameAccount(t *testing.T) { + chat := &scriptedChat{fn: func(int) (providers.ChatOutcome, error) { + return providers.ChatOutcome{}, &providers.Error{ + Kind: accounts.KindRateLimit, Status: 429, + Message: "too many requests", Code: "rate_limit", RetryAfter: time.Minute, + } + }} + ex := inProcessExecutor(t, chat, Item{ID: "wb1"}) + + _, err := ex.ChatNonStream(context.Background(), translate.ChatRequest{ + Model: "glm-5.2", Messages: []translate.ChatMessage{{Role: "user", Content: "hi"}}, + }, "", "") + if err == nil { + t.Fatal("expected rate limit error") + } + if chat.Calls() != 1 { + t.Fatalf("adapter calls = %d, want 1 (no same-account retry for 429)", chat.Calls()) + } +} + +func TestTransientFailureDoesNotEscalateBackoff(t *testing.T) { + pool := NewPool(nil, nil) + pool.Upsert(Item{ID: "a"}) + ex := NewChatExecutor(pool, "") + + for i := 0; i < 4; i++ { + ex.markClassified("a", Classified{ + Kind: accounts.KindUnavailable, Cooldown: 10 * time.Second, Transient: true, + }, "") + } + item, ok := pool.ByID("a") + if !ok { + t.Fatal("account missing") + } + if item.BackoffLevel != 0 { + t.Fatalf("backoff level = %d, want 0 for transient failures", item.BackoffLevel) + } + if remaining := time.Until(item.DownUntil); remaining > 15*time.Second { + t.Fatalf("cooldown = %s, want the classifier window, not an escalated one", remaining) + } +} + +func TestExactResetIsNotMultiplied(t *testing.T) { + pool := NewPool(nil, nil) + pool.Upsert(Item{ID: "a"}) + ex := NewChatExecutor(pool, "") + + for i := 0; i < 4; i++ { + ex.markClassified("a", Classified{ + Kind: accounts.KindQuota, Cooldown: 15 * time.Minute, ExactReset: true, + }, "") + } + item, ok := pool.ByID("a") + if !ok { + t.Fatal("account missing") + } + if item.BackoffLevel != 0 { + t.Fatalf("backoff level = %d, want 0 for an authoritative reset", item.BackoffLevel) + } + if remaining := time.Until(item.DownUntil); remaining > 16*time.Minute { + t.Fatalf("cooldown = %s, want the upstream reset window", remaining) + } +} + +func TestDurableAuthFailureStillEscalates(t *testing.T) { + pool := NewPool(nil, nil) + pool.Upsert(Item{ID: "a"}) + ex := NewChatExecutor(pool, "") + + for i := 0; i < 4; i++ { + ex.markClassified("a", Classified{Kind: accounts.KindAuth, Cooldown: 30 * time.Second}, "") + } + item, ok := pool.ByID("a") + if !ok { + t.Fatal("account missing") + } + if remaining := time.Until(item.DownUntil); remaining <= 30*time.Second { + t.Fatalf("cooldown = %s, want escalation above the base window", remaining) + } +} + +func TestShortCooldownKeepsAnchorAndReturnsToOriginal(t *testing.T) { + chat := &scriptedChat{fn: func(int) (providers.ChatOutcome, error) { + return providers.ChatOutcome{Model: "glm-5.2", Content: "ok", FinishReason: "stop"}, nil + }} + ex := inProcessExecutor(t, chat, Item{ID: "a"}, Item{ID: "b"}) + ex.SessionAffinity.Bind("cache-session", "a") + // A short cooling window keeps a's prompt cache plausibly warm. + ex.Pool.MarkClassified("a", Classified{Kind: accounts.KindRateLimit, Cooldown: 30 * time.Second, Model: "glm-5.2"}) + + ctx := WithSessionKey(context.Background(), "cache-session") + first, err := ex.ChatNonStream(ctx, translate.ChatRequest{ + Model: "glm-5.2", Messages: []translate.ChatMessage{{Role: "user", Content: "hi"}}, + }, "", "") + if err != nil { + t.Fatalf("err = %v", err) + } + if first.AccountID != "b" { + t.Fatalf("served by %q, want the healthy sibling b", first.AccountID) + } + if bound, ok := ex.SessionAffinity.Get("cache-session"); !ok || bound != "a" { + t.Fatalf("binding = %q ok=%v, want the original anchor a", bound, ok) + } + + // Once the cooldown lifts, the chat returns to its original account. + ex.Pool.MarkOK("a", "glm-5.2") + second, err := ex.ChatNonStream(ctx, translate.ChatRequest{ + Model: "glm-5.2", Messages: []translate.ChatMessage{{Role: "user", Content: "hi"}}, + }, "", "") + if err != nil { + t.Fatalf("err = %v", err) + } + if second.AccountID != "a" || second.Routing != routingSticky { + t.Fatalf("second = %+v, want sticky back on a", second) + } +} + +func TestLongCooldownReanchorsToServingAccount(t *testing.T) { + chat := &scriptedChat{fn: func(int) (providers.ChatOutcome, error) { + return providers.ChatOutcome{Model: "glm-5.2", Content: "ok", FinishReason: "stop"}, nil + }} + ex := inProcessExecutor(t, chat, Item{ID: "a"}, Item{ID: "b"}) + ex.SessionAffinity.Bind("long-session", "a") + ex.Pool.MarkClassified("a", Classified{Kind: accounts.KindAuth, Cooldown: time.Hour}) + + _, err := ex.ChatNonStream(WithSessionKey(context.Background(), "long-session"), translate.ChatRequest{ + Model: "glm-5.2", Messages: []translate.ChatMessage{{Role: "user", Content: "hi"}}, + }, "", "") + if err != nil { + t.Fatalf("err = %v", err) + } + // A one-hour wait outlives the cached prefix, so the chat follows the + // account that actually served it. + if bound, ok := ex.SessionAffinity.Get("long-session"); !ok || bound != "b" { + t.Fatalf("binding = %q ok=%v, want b", bound, ok) + } +} + +func TestZeroCooldownFailoverStillForgets(t *testing.T) { + chat := &scriptedChat{fn: func(call int) (providers.ChatOutcome, error) { + if call <= 2 { + return providers.ChatOutcome{}, emptyStreamErr() + } + return providers.ChatOutcome{Model: "glm-5.2", Content: "ok", FinishReason: "stop"}, nil + }} + // Both accounts share one adapter, so account a fails on its retry and + // then the failover to b succeeds. + ex := inProcessExecutor(t, chat, Item{ID: "a"}, Item{ID: "b"}) + ex.SessionAffinity.Bind("cold-stream", "a") + + result, err := ex.ChatNonStream(WithSessionKey(context.Background(), "cold-stream"), translate.ChatRequest{ + Model: "glm-5.2", Messages: []translate.ChatMessage{{Role: "user", Content: "hi"}}, + }, "", "") + if err != nil { + t.Fatalf("err = %v", err) + } + if result.AccountID != "b" { + t.Fatalf("account = %q, want b", result.AccountID) + } + if bound, ok := ex.SessionAffinity.Get("cold-stream"); !ok || bound != "b" { + t.Fatalf("binding = %q ok=%v, want b after a zero-cooldown failure", bound, ok) + } +} + +func TestQuotaResetHintIsNotClampedToRateLimitWindow(t *testing.T) { + body := `{"error":{"message":"insufficient_quota","code":"insufficient_quota"},"resets_in_seconds":7200}` + classified := Classify(429, body, "", "", "") + if classified.Kind != accounts.KindQuota { + t.Fatalf("kind = %q, want quota", classified.Kind) + } + if classified.Cooldown < 90*time.Minute { + t.Fatalf("cooldown = %s, want the full upstream reset window", classified.Cooldown) + } + if !classified.ExactReset { + t.Fatal("quota reset from upstream must be marked ExactReset") + } +} + +func TestQuotaWithoutHintFallsBackToLocalMidnight(t *testing.T) { + classified := Classify(429, `{"error":{"message":"insufficient_quota","code":"insufficient_quota"}}`, "", "", "") + if classified.Kind != accounts.KindQuota { + t.Fatalf("kind = %q, want quota", classified.Kind) + } + if classified.Cooldown <= 0 { + t.Fatalf("cooldown = %s, want the local-midnight fallback", classified.Cooldown) + } + if classified.ExactReset { + t.Fatal("a guessed midnight fallback must not claim an exact reset") + } +} + +func TestSessionAffinityReportsReasonDistributions(t *testing.T) { + affinity := NewSessionAffinity(time.Minute, 32) + affinity.Bind("one", "a") + if _, ok := affinity.Get("one"); !ok { + t.Fatal("expected a hit") + } + affinity.Get("missing") + // Shrink the TTL before binding so the next binding is already expiring. + affinity.ttl = time.Millisecond + affinity.Bind("short", "a") + time.Sleep(5 * time.Millisecond) + affinity.Get("short") + affinity.RecordEscape("provider_cooldown") + affinity.RecordEscape("provider_cooldown") + affinity.RecordEscape("concurrency_saturated") + + stats := affinity.Stats() + if stats.MissReasons["not_found"] != 1 || stats.MissReasons["expired"] != 1 { + t.Fatalf("miss reasons = %v", stats.MissReasons) + } + if stats.EscapeReasons["provider_cooldown"] != 2 || stats.EscapeReasons["concurrency_saturated"] != 1 { + t.Fatalf("escape reasons = %v", stats.EscapeReasons) + } + if stats.Hits != 1 || stats.Misses != 2 || stats.Escapes != 3 { + t.Fatalf("counters = hits %d misses %d escapes %d", stats.Hits, stats.Misses, stats.Escapes) + } +} + +func TestPeekDoesNotCountAsHit(t *testing.T) { + affinity := NewSessionAffinity(time.Minute, 8) + affinity.Bind("s", "a") + if anchor, ok := affinity.Peek("s"); !ok || anchor != "a" { + t.Fatalf("peek = %q ok=%v", anchor, ok) + } + if stats := affinity.Stats(); stats.Hits != 0 && stats.Misses != 0 { + t.Fatalf("peek changed routing counters: %+v", stats) + } +} + +func TestResolveSessionAffinityConfigDefaultsAndOverrides(t *testing.T) { + t.Setenv("CLI2API_AFFINITY_TTL", "") + t.Setenv("CLI2API_AFFINITY_CAPACITY", "") + ttl, capacity := ResolveSessionAffinityConfig() + if ttl != 4*time.Hour || capacity != 10_000 { + t.Fatalf("defaults = %s/%d", ttl, capacity) + } + + t.Setenv("CLI2API_AFFINITY_TTL", "90m") + t.Setenv("CLI2API_AFFINITY_CAPACITY", "2048") + ttl, capacity = ResolveSessionAffinityConfig() + if ttl != 90*time.Minute || capacity != 2048 { + t.Fatalf("override = %s/%d", ttl, capacity) + } + + // Bare seconds stay supported, invalid values fall back, and the ceiling + // keeps a typo from making bindings effectively permanent. + t.Setenv("CLI2API_AFFINITY_TTL", "7200") + if ttl, _ = ResolveSessionAffinityConfig(); ttl != 2*time.Hour { + t.Fatalf("seconds override = %s", ttl) + } + t.Setenv("CLI2API_AFFINITY_TTL", "not-a-duration") + if ttl, _ = ResolveSessionAffinityConfig(); ttl != 4*time.Hour { + t.Fatalf("invalid override = %s", ttl) + } + t.Setenv("CLI2API_AFFINITY_TTL", "720h") + if ttl, _ = ResolveSessionAffinityConfig(); ttl != maxSessionAffinityTTL { + t.Fatalf("ceiling = %s", ttl) + } +} + +func TestStickyCoolingEscapesOnlyWhenWaitIsLongAndFamilyDiffers(t *testing.T) { + chat := &scriptedChat{fn: func(int) (providers.ChatOutcome, error) { + return providers.ChatOutcome{Model: "shared", Content: "ok", FinishReason: "stop"}, nil + }} + pool := NewPool(nil, nil) + pool.Upsert(Item{ID: "q1", Provider: "qoder", Region: "global", Runtime: string(providers.RuntimeInProcess), Models: []string{"shared"}}) + pool.Upsert(Item{ID: "w1", Provider: "workbuddy", Region: "cn", Runtime: string(providers.RuntimeInProcess), Models: []string{"shared"}}) + registry := providers.NewRegistry() + registry.Register(providers.Adapter{ID: "qoder", Chat: chat}) + registry.Register(providers.Adapter{ID: "workbuddy", Chat: chat}) + ex := NewChatExecutor(pool, "") + ex.Providers = registry + ex.SessionAffinity.Bind("cooling-session", "q1") + + // A short rate-limit window is better served by Retry-After: a cross-provider + // hop would lose the prompt cache for a wait the client can absorb. + pool.MarkClassified("q1", Classified{Kind: accounts.KindRateLimit, Cooldown: 20 * time.Second, Model: "shared"}) + _, err := ex.ChatNonStream(WithSessionKey(context.Background(), "cooling-session"), translate.ChatRequest{ + Model: "shared", Messages: []translate.ChatMessage{{Role: "user", Content: "hi"}}, + }, "", "") + var execution *ExecutionError + if !errors.As(err, &execution) || execution.Classified.Status != 429 { + t.Fatalf("short cooldown err = %v, want a 429 retry-after", err) + } + + // A quota wait (typically until local midnight) would leave the chat dead + // while another provider is idle, so escaping is correct there. + pool.MarkClassified("q1", Classified{Kind: accounts.KindQuota, Cooldown: 30 * time.Minute}) + result, err := ex.ChatNonStream(WithSessionKey(context.Background(), "cooling-session"), translate.ChatRequest{ + Model: "shared", Messages: []translate.ChatMessage{{Role: "user", Content: "hi"}}, + }, "", "") + if err != nil { + t.Fatalf("long cooldown err = %v", err) + } + if result.AccountID != "w1" || result.Routing != routingStickyEscape { + t.Fatalf("result = %+v, want escaped to w1", result) + } +} + +func TestKeyedIdentityStillIsolatesBindings(t *testing.T) { + if got := SessionKeyFor("h", auth.ConsoleIdentity(), translate.ChatRequest{ + Model: "glm-5.2", Messages: []translate.ChatMessage{{Role: "user", Content: "hi"}}, + }); got == "" { + t.Fatal("empty session key") + } +} diff --git a/internal/executor/chat.go b/internal/executor/chat.go index 47f7f475..4ac6f148 100644 --- a/internal/executor/chat.go +++ b/internal/executor/chat.go @@ -173,15 +173,64 @@ type routingPlan struct { SessionKey string BoundAccount string PublicModel string + // Aggregate marks a request routed through a logical (virtual) model. + // Escaping such a request changes the concrete upstream model, so the + // session must follow the member that answered rather than snap back to + // a member that is merely cooling. + Aggregate bool } func (e ChatExecutor) bindSession(plan routingPlan, accountID string) { if plan.Source == routingPin || plan.SessionKey == "" || e.SessionAffinity == nil { return } + if plan.Source == routingStickyEscape && e.keepAnchorOnEscape(plan, accountID) { + return + } e.SessionAffinity.Bind(plan.SessionKey, accountID) } +// keepAnchorMaxCooldown is how long a bound account may stay unavailable +// before an escape stops preserving the anchor. Upstream prompt caches are +// measured in minutes: below this window the original account's prefix is +// still warm and returning to it is cheaper than re-anchoring, above it the +// cache is gone and the chat should follow the account that actually serves. +const keepAnchorMaxCooldown = 5 * time.Minute + +// keepAnchorOnEscape reports whether a sticky-escape should leave the existing +// binding intact. Keeping it lets the next turn return to the original account +// — and its warm prompt cache — as soon as a short cooldown lifts. A binding +// that would be wrong to keep: +// - the account is gone, disabled, or the request is aggregated (escaping +// swaps the concrete model, so the session must follow the answerer); +// - the cooldown is long enough that the cached prefix has expired anyway. +func (e ChatExecutor) keepAnchorOnEscape(plan routingPlan, accountID string) bool { + if e.SessionAffinity == nil || e.Pool == nil || plan.Aggregate { + return false + } + anchor, ok := e.SessionAffinity.Peek(plan.SessionKey) + if !ok || anchor == "" || anchor == accountID { + return false + } + item, ok := e.Pool.ByID(anchor) + if !ok { + return false + } + if item.Ready != nil && !*item.Ready { + return false + } + // Only a short, known cooldown keeps the anchor: the original account's + // prompt cache is still warm, so returning there is cheaper than + // re-anchoring. An unknown window (concurrency saturation has no resume + // time) or a long quota wait means the cached prefix is gone and the chat + // should follow the account that actually serves it. + remaining := e.Pool.RetryAfter(item, plan.PublicModel) + if remaining <= 0 || remaining > keepAnchorMaxCooldown { + return false + } + return true +} + func (e ChatExecutor) observeRouting(plan *routingPlan, accountID string) { if plan == nil || plan.Source != routingSticky || plan.BoundAccount == "" { return @@ -228,7 +277,12 @@ func (e ChatExecutor) CommitSession(ctx context.Context, req translate.ChatReque if routing == routingPin || e.SessionAffinity == nil { return } - e.SessionAffinity.Bind(resolveSessionKey(ctx, req), accountID) + key := resolveSessionKey(ctx, req) + plan := routingPlan{Source: routing, SessionKey: key, PublicModel: req.Model} + if routing == routingStickyEscape && e.keepAnchorOnEscape(plan, accountID) { + return + } + e.SessionAffinity.Bind(key, accountID) } func itemProvider(item Item) string { @@ -258,10 +312,10 @@ func (e ChatExecutor) prepareRouting(ctx context.Context, prefer, providerFilter providerFilter = strings.ToLower(strings.TrimSpace(providerFilter)) publicModel := req.Model if prefer != "" { - return prefer, providerFilter, "", routingPlan{Source: routingPin, PublicModel: publicModel} + return prefer, providerFilter, "", routingPlan{Source: routingPin, PublicModel: publicModel, Aggregate: plan != nil} } - planRoute := routingPlan{Source: routingPool, SessionKey: resolveSessionKey(ctx, req), PublicModel: publicModel} + planRoute := routingPlan{Source: routingPool, SessionKey: resolveSessionKey(ctx, req), PublicModel: publicModel, Aggregate: plan != nil} if planRoute.SessionKey == "" || e.SessionAffinity == nil || e.Pool == nil { return "", providerFilter, "", planRoute } @@ -294,6 +348,7 @@ func (e ChatExecutor) prepareRouting(ctx context.Context, prefer, providerFilter } return item.ID, itemProvider(item), accounts.NormalizeRegion(item.Region), routingPlan{ Source: routingSticky, SessionKey: planRoute.SessionKey, BoundAccount: item.ID, PublicModel: publicModel, + Aggregate: plan != nil, } } @@ -301,11 +356,12 @@ func NewChatExecutor(pool *Pool, workerKey string) ChatExecutor { if pool == nil { pool = NewPool(nil, nil) } + affinityTTL, affinityCapacity := ResolveSessionAffinityConfig() return ChatExecutor{ Pool: pool, WorkerKey: strings.TrimSpace(workerKey), MaxAttempts: 4, - SessionAffinity: NewSessionAffinity(defaultSessionAffinityTTL, defaultSessionAffinityCapacity), + SessionAffinity: NewSessionAffinity(affinityTTL, affinityCapacity), HTTPClient: &http.Client{ Timeout: 120 * time.Second, }, @@ -348,6 +404,47 @@ func (e ChatExecutor) providerHasCapacity(pinnedProvider, pinnedRegion, publicMo return e.Pool.HasCapacity(query) } +// capacityOutsideProvider reports whether a *different provider family* can +// serve this model right now. Cooling escape uses this rather than +// providerHasCapacity: Qoder global and CN are isolated upstreams, so hopping +// from one to the other mid-chat loses the prompt cache and lands on a +// different catalog for no benefit. Only a genuinely different family counts. +func (e ChatExecutor) capacityOutsideProvider(pinnedProvider, publicModel string, allowed []string, eligible func(Item) bool) bool { + if e.Pool == nil || pinnedProvider == "" { + return false + } + query := e.routeQuery("", "", "", publicModel, allowed, nil, func(item Item) bool { + if itemProvider(item) == pinnedProvider { + return false + } + now := time.Now() + if itemDown(item, now) || itemModelDown(item, RouteQuery{PublicModel: publicModel}, now) { + return false + } + return eligible == nil || eligible(item) + }) + return e.Pool.HasCapacity(query) +} + +// stickyEscapeMinCooldown is the cooling window above which a sticky chat +// leaves its bound provider. Below it the client is better served by a +// Retry-After: the wait is short and the prompt cache stays warm. +const stickyEscapeMinCooldown = 2 * time.Minute + +// coolingWorthEscaping reports whether a cooling pick error is long enough to +// justify leaving the bound provider. Quota waits (typically until local +// midnight) always qualify; a short rate-limit window does not. +func coolingWorthEscaping(err error) bool { + var execution *ExecutionError + if !errors.As(err, &execution) || execution == nil { + return false + } + if execution.Classified.Kind == accounts.KindQuota { + return true + } + return execution.Classified.RetryAfter >= stickyEscapeMinCooldown +} + func (e ChatExecutor) routeQuery(prefer, providerFilter, regionFilter, publicModel string, allowed []string, excluded map[string]struct{}, eligible func(Item) bool, plan ...*AggregatePlan) RouteQuery { q := RouteQuery{ PublicModel: publicModel, @@ -961,8 +1058,19 @@ type routeLoop struct { // excluded. tierAttempts map[int]int tierBudget int + // sameAccountRetries counts how many transient same-account retries this + // request has already spent. It is a separate budget from attempts: a + // retry on the same account must not consume a failover hop, because + // attemptsFor already caps attempts at the number of candidate accounts. + sameAccountRetries int } +// maxSameAccountRetries bounds same-account retries per request. One is enough: +// the transient cases are empty/heartbeat-only streams and a first-byte +// timeout, where a second identical attempt almost always succeeds, and +// more retries would stack latency ahead of a real failover. +const maxSameAccountRetries = 1 + func (e ChatExecutor) newRouteLoop(ctx context.Context, prefer, providerFilter string, req translate.ChatRequest) routeLoop { aggPlan := aggregatePlanFrom(ctx) prefer, providerFilter, regionFilter, routing := e.prepareRouting(ctx, prefer, providerFilter, req, aggPlan) @@ -989,10 +1097,10 @@ func (e ChatExecutor) newRouteLoop(ctx context.Context, prefer, providerFilter s } } prefer = "" - routing = routingPlan{Source: routingPool, SessionKey: routing.SessionKey, PublicModel: req.Model} + routing = routingPlan{Source: routingPool, SessionKey: routing.SessionKey, PublicModel: req.Model, Aggregate: true} default: prefer = "" - routing = routingPlan{Source: routingPool, SessionKey: routing.SessionKey, PublicModel: req.Model} + routing = routingPlan{Source: routingPool, SessionKey: routing.SessionKey, PublicModel: req.Model, Aggregate: true} } } // A model-name region prefix (e.g. "workbuddy-cn/model") sets an explicit @@ -1087,11 +1195,37 @@ func (l *routeLoop) pickNext(e ChatExecutor, publicModel string) (Item, int, err // provider into rate_limit while another provider still has room. // Drop the pin only after the pick itself reports saturation, and only // when this request did not ask for that provider. - if l.routing.Source == routingSticky && l.index == 0 && l.pinned == "" && capacityError(err) && e.providerHasCapacity(l.providerFilter, l.regionFilter, publicModel, l.allowed, l.eligible) { + reason := "" + if l.routing.Source == routingSticky && l.index == 0 && l.pinned == "" { + switch { + case capacityError(err): + if e.providerHasCapacity(l.providerFilter, l.regionFilter, publicModel, l.allowed, l.eligible) { + reason = "concurrency_saturated" + } + case coolingWorthEscaping(err): + // Every account of the bound provider/region is cooling. A short + // window is better served by a Retry-After (the chat keeps its + // cache and comes back), but a long quota wait would leave the + // chat dead for hours while another provider is idle. + if e.capacityOutsideProvider(l.providerFilter, publicModel, l.allowed, l.eligible) { + reason = "provider_cooldown" + } + } + } + if reason != "" { if e.SessionAffinity != nil { - e.SessionAffinity.RecordEscape("concurrency_saturated") + e.SessionAffinity.RecordEscape(reason) + } + // A cooldown escape keeps the sticky-escape marker so a successful + // turn does not steal the session anchor from the account that is + // merely cooling (see keepAnchorOnEscape). A capacity escape + // re-picks freely and rebinds to whoever had room, because an + // unknown saturation window has no cache to return to. + if reason == "provider_cooldown" { + l.routing.Source = routingStickyEscape + } else { + l.routing.Source = routingPool } - l.routing.Source = routingPool l.prefer = "" l.providerFilter = "" l.regionFilter = "" @@ -1145,6 +1279,23 @@ func (l routeLoop) canFailover(classified Classified) bool { return classified.Failover && l.index < l.attempts } +// canSameAccountRetry reports whether this failure may be retried once on the +// account that produced it. Only transient upstream hiccups qualify, and only +// while the caller is still connected: retrying after the client left would +// burn an upstream slot for nothing. +func (l *routeLoop) canSameAccountRetry(ctx context.Context, classified Classified) bool { + if l.sameAccountRetries >= maxSameAccountRetries { + return false + } + if !classified.Transient { + return false + } + if ctx != nil && ctx.Err() != nil { + return false + } + return true +} + func (l *routeLoop) exclude(item Item) { l.excluded[item.ID] = struct{}{} // A cross-provider route (no explicit provider filter) must be able to @@ -1166,20 +1317,27 @@ func (l *routeLoop) exclude(item Item) { // next pick can leave the first supplier's region. Provider-scoped routes keep // their region pin. // -// A sticky binding is invalidated on failover (401/429/5xx and other -// failover-classified failures), including after a sticky escape. The next -// request then rebinds to a healthy account instead of retrying the dead one -// first; a successfully retried request rebinds through bindSession. This -// mirrors mature gateways' session affinity: sticky on the cache-hit path, -// failover invalidates the binding. -func (l *routeLoop) failover(e ChatExecutor, item Item) { +// The session binding survives a cooldown-carrying failure: the account is +// parked, not dead, and the next request should fall through to a sibling and +// then return to the original account (and its warm prompt cache). A failure +// that leaves no cooldown invalidates the binding instead, because retrying +// that account first next turn would fail identically. +func (l *routeLoop) failover(e ChatExecutor, item Item, classified Classified) { l.exclude(item) l.noteTierFailure(e, item) // Any non-pin route that already carries a session key can have a stale // binding (including a sticky-escape that started on another account). - // Invalidate it so the next turn does not retry the failed account first. + // + // A cooling account is only temporarily unavailable. Keep the binding so + // the next turn's PreferAccount falls through to a healthy sibling now and + // returns to the original account — and its warm prompt cache — once the + // cooldown lifts. Only a failure that leaves no cooldown (a cold upstream + // or a model this account does not serve) invalidates the anchor, because + // retrying it first next turn would just fail the same way. if l.routing.Source != routingPin && l.routing.SessionKey != "" && e.SessionAffinity != nil { - e.SessionAffinity.Forget(l.routing.SessionKey) + if classified.Cooldown <= 0 { + e.SessionAffinity.Forget(l.routing.SessionKey) + } } } @@ -1267,12 +1425,15 @@ func (e ChatExecutor) releaseInFlight(requestID, id string) { // attachInFlightRelease transfers an acquired slot to the response body. // Close releases the pool id that was Acquired (not a rewritten account id). +// The body also carries an idle deadline: an upstream that sent the head and +// then went silent must not keep the slot (or the client connection) forever. func (e ChatExecutor) attachInFlightRelease(resp *http.Response, requestID, poolID string) *http.Response { if resp == nil || resp.Body == nil { e.releaseInFlight(requestID, poolID) return resp } - resp.Body = &releaseCloser{ReadCloser: resp.Body, release: func() { e.releaseInFlight(requestID, poolID) }} + guarded := guardStreamIdle(resp.Body, resolveStreamIdleTimeout()) + resp.Body = &releaseCloser{ReadCloser: guarded, release: func() { e.releaseInFlight(requestID, poolID) }} return resp } @@ -1296,7 +1457,23 @@ func (e ChatExecutor) ChatNonStream(ctx context.Context, req translate.ChatReque } release := func() { e.releaseInFlight(loop.requestID, poolID) } if isInProcessItem(item) || e.qoderDirect(item) { - result, classified, err := e.chatInProcessNonStreamAttempt(ctx, item, loop.dispatchRequest(item, req), i) + // Retry a transient upstream hiccup once on the same account before + // spending a failover hop. The prompt cache is still warm here, so a + // same-account retry usually succeeds and keeps the turn on the + // account the session is anchored to. + dispatch := loop.dispatchRequest(item, req) + var result ChatResult + var classified Classified + var err error + for { + result, classified, err = e.chatInProcessNonStreamAttempt(ctx, item, dispatch, i) + if err == nil || !loop.canSameAccountRetry(ctx, classified) { + break + } + loop.sameAccountRetries++ + log.Printf("chat same-account retry request_id=%q account=%q code=%q kind=%q retry=%d", + loop.requestID, poolID, classified.Code, classified.Kind, loop.sameAccountRetries) + } if err == nil { result.AttemptCount = i + 1 e.observeRouting(&loop.routing, poolID) @@ -1314,7 +1491,7 @@ func (e ChatExecutor) ChatNonStream(ctx context.Context, req translate.ChatReque } if loop.canFailover(classified) { release() - loop.failover(e, item) + loop.failover(e, item, classified) continue } release() @@ -1352,7 +1529,7 @@ func (e ChatExecutor) ChatNonStream(ctx context.Context, req translate.ChatReque Status: accounts.AttemptStatusFailover, ErrorKind: classified.Kind, ErrorMessage: loop.lastErr.Error(), LatencyMs: &latency, }) release() - loop.failover(e, item) + loop.failover(e, item, classified) continue } // Non-stream worker responses are buffered whole; cap them so a @@ -1377,7 +1554,7 @@ func (e ChatExecutor) ChatNonStream(ctx context.Context, req translate.ChatReque status := accounts.AttemptStatusError if loop.canFailover(classified) { status = accounts.AttemptStatusFailover - loop.failover(e, poolItem) + loop.failover(e, poolItem, classified) e.recordAttempt(ctx, accounts.RequestAttempt{ AttemptIndex: i, AccountID: item.ID, StartedAt: started, FinishedAt: &finished, Status: status, HTTPStatus: ptrInt(resp.StatusCode), ErrorKind: classified.Kind, @@ -1396,13 +1573,23 @@ func (e ChatExecutor) ChatNonStream(ctx context.Context, req translate.ChatReque } result, err := decodeChatResult(req, body) if err != nil { + // A body this account answered with but this gateway cannot decode is + // an upstream protocol failure, not a routing miss. Classify it here + // so the HTTP layer does not fall back to a bare 502 "upstream_error" + // for a problem that is already understood. + classified := Classified{ + Kind: accounts.KindUnavailable, Status: http.StatusBadGateway, + Code: "upstream_decode_error", Type: "api_error", Message: err.Error(), + } + loop.lastErr = NewExecutionError(classified, err) + e.markClassified(poolID, classified, loop.attemptModel(item, req)) e.recordAttempt(ctx, accounts.RequestAttempt{ AttemptIndex: i, AccountID: item.ID, StartedAt: started, FinishedAt: &finished, Status: accounts.AttemptStatusError, HTTPStatus: ptrInt(resp.StatusCode), ErrorKind: accounts.KindUnavailable, ErrorMessage: truncateErr(err.Error()), LatencyMs: &latency, }) release() - return ChatResult{AttemptCount: i + 1, AccountID: item.ID, Provider: loop.resultProvider(item)}, err + return ChatResult{AttemptCount: i + 1, AccountID: item.ID, Provider: loop.resultProvider(item)}, loop.lastErr } result.AccountID = item.ID result.Provider = loop.resultProvider(item) @@ -1424,7 +1611,11 @@ func (e ChatExecutor) ChatNonStream(ctx context.Context, req translate.ChatReque return result, nil } if loop.lastErr == nil { - loop.lastErr = fmt.Errorf("no worker accounts available") + // Exhausting the loop without a selected account is a routing outcome, + // not an origin outage. Report it with the routing taxonomy (503 + + // Retry-After) instead of handing the HTTP layer a bare error it would + // render as 502 upstream_error. + loop.lastErr = noAccountsError("no worker accounts available") } return ChatResult{AttemptCount: loop.attempts}, loop.lastErr } @@ -1439,6 +1630,10 @@ func sanitizeForItem(item Item, req translate.ChatRequest) translate.ChatRequest if native := NativeModelID(item, req.Model); native != "" { req.Model = native } + // Stable tool order keeps the upstream cached prefix intact when a client + // rebuilds its tool list in a different order. Opt-in: some models react to + // a reordered array, so only the fingerprint side is always normalized. + req.Tools = translate.NormalizeToolsForPayload(req.Tools) if item.DropSystemPrompt && itemProvider(item) != "qoder" { return translate.DropSystemMessages(req) } @@ -1808,7 +2003,22 @@ func (e ChatExecutor) chatStreamProxy(ctx context.Context, req translate.ChatReq } release := func() { e.releaseInFlight(loop.requestID, poolID) } if isInProcessItem(item) || (e.qoderDirect(item) && !(preferNativeResponses && native != nil)) { - result, classified, err := e.chatInProcessStreamAttempt(ctx, item, loop.dispatchRequest(item, req), native, i, preferNativeResponses) + dispatch := loop.dispatchRequest(item, req) + var result StreamResult + var classified Classified + var err error + for { + result, classified, err = e.chatInProcessStreamAttempt(ctx, item, dispatch, native, i, preferNativeResponses) + if err == nil || !loop.canSameAccountRetry(ctx, classified) { + break + } + // Nothing has been relayed to the client: the attempt failed + // before the first meaningful event, so a same-account retry is + // both safe and cache-warm. + loop.sameAccountRetries++ + log.Printf("chat stream same-account retry request_id=%q account=%q code=%q kind=%q retry=%d", + loop.requestID, poolID, classified.Code, classified.Kind, loop.sameAccountRetries) + } if err == nil { result.AttemptCount = i + 1 @@ -1829,7 +2039,7 @@ func (e ChatExecutor) chatStreamProxy(ctx context.Context, req translate.ChatReq } if loop.canFailover(classified) { release() - loop.failover(e, item) + loop.failover(e, item, classified) continue } release() @@ -1867,7 +2077,7 @@ func (e ChatExecutor) chatStreamProxy(ctx context.Context, req translate.ChatReq Status: accounts.AttemptStatusFailover, ErrorKind: classified.Kind, ErrorMessage: loop.lastErr.Error(), LatencyMs: &latency, }) release() - loop.failover(e, item) + loop.failover(e, item, classified) continue } if account := resp.Header.Get("X-Qoder-Account"); account != "" { @@ -1891,7 +2101,7 @@ func (e ChatExecutor) chatStreamProxy(ctx context.Context, req translate.ChatReq status := accounts.AttemptStatusError if loop.canFailover(classified) { status = accounts.AttemptStatusFailover - loop.failover(e, poolItem) + loop.failover(e, poolItem, classified) e.recordAttempt(ctx, accounts.RequestAttempt{ AttemptIndex: i, AccountID: item.ID, StartedAt: started, FinishedAt: &finished, Status: status, HTTPStatus: ptrInt(resp.StatusCode), ErrorKind: classified.Kind, @@ -1938,7 +2148,7 @@ func (e ChatExecutor) chatStreamProxy(ctx context.Context, req translate.ChatReq Status: status, HTTPStatus: ptrInt(resp.StatusCode), ErrorKind: classified.Kind, ErrorMessage: truncateErr(probeErr.Error()), LatencyMs: &latency, }) - loop.failover(e, poolItem) + loop.failover(e, poolItem, classified) release() continue } @@ -1976,7 +2186,11 @@ func (e ChatExecutor) chatStreamProxy(ctx context.Context, req translate.ChatReq }, nil } if loop.lastErr == nil { - loop.lastErr = fmt.Errorf("no worker accounts available") + // Exhausting the loop without a selected account is a routing outcome, + // not an origin outage. Report it with the routing taxonomy (503 + + // Retry-After) instead of handing the HTTP layer a bare error it would + // render as 502 upstream_error. + loop.lastErr = noAccountsError("no worker accounts available") } return StreamResult{AttemptCount: loop.attempts}, loop.lastErr } diff --git a/internal/executor/chat_test.go b/internal/executor/chat_test.go index a2ae876f..e28bd1cc 100644 --- a/internal/executor/chat_test.go +++ b/internal/executor/chat_test.go @@ -289,7 +289,7 @@ func TestRouteFailoverKeepsAttemptBudgetAndCrossesRegion(t *testing.T) { t.Fatalf("attempt budget shrank after region pin: %d", loop.attempts) } - loop.failover(e, first) + loop.failover(e, first, Classified{Kind: "unavailable"}) second, _, err := loop.pickNext(e, "shared") if err != nil { t.Fatalf("failover pick: %v", err) diff --git a/internal/executor/classify.go b/internal/executor/classify.go index 6104f1c0..6ceaf70c 100644 --- a/internal/executor/classify.go +++ b/internal/executor/classify.go @@ -25,6 +25,17 @@ type Classified struct { // Model scopes the cooldown to one public model. When set, only that // model is cooled; the account keeps serving everything else. Model string + // Transient marks an upstream hiccup that says nothing about the account's + // credential, quota, or rate limit: an empty stream, a stream that died + // mid-body, or a first-byte timeout. A transient failure may be retried on + // the same account, and it must never escalate the cooldown ladder — one + // flaky turn would otherwise park a healthy account for minutes. + Transient bool + // ExactReset marks a cooldown taken verbatim from an upstream hint + // (Retry-After header/body or a quota reset time). The exponential ladder + // must not multiply it: the upstream already said when it recovers, and + // doubling that parks the account past the real reset. + ExactReset bool } // backoffFloor and backoffCeiling bound the exponential backoff applied to @@ -34,6 +45,11 @@ const ( backoffFloor = 30 * time.Second backoffCeiling = 6 * time.Hour backoffMaxLevel = BackoffMaxLevel + // transientCooldownCap bounds how long a transient upstream hiccup may + // park an account. The classifier's own window (10s for a first-byte + // timeout) is the intent; this cap only guards against a caller handing a + // transient classification a wider window by mistake. + transientCooldownCap = 60 * time.Second ) func nextBackoffCooldown(base time.Duration, level int) (time.Duration, int) { @@ -62,14 +78,35 @@ func ParseRetryAfter(raw string, fallback time.Duration) time.Duration { } func ParseRetryAfterHint(body, header string, fallback time.Duration) time.Duration { + if hint, ok := parseUpstreamRetryHint(body, header); ok { + return hint + } + return clampRetryAfter(fallback) +} + +// parseUpstreamRetryHint returns only a hint the upstream actually sent. +// Unlike ParseRetryAfterHint it never substitutes a local fallback, so callers +// can tell "the upstream told us when it recovers" from "we guessed". +func parseUpstreamRetryHint(body, header string) (time.Duration, bool) { + raw, ok := parseUpstreamRetryHintRaw(body, header) + if !ok { + return 0, false + } + return clampRetryAfter(raw), true +} + +// parseUpstreamRetryHintRaw is parseUpstreamRetryHint without the general +// retry-after ceiling. Quota resets are legitimately hours away and must not be +// shortened to a rate-limit window. +func parseUpstreamRetryHintRaw(body, header string) (time.Duration, bool) { now := time.Now() if parsed := parseRetryAfterValue(header, now); parsed > 0 { - return clampRetryAfter(parsed) + return parsed, true } if parsed := retryAfterFromBody(body, now); parsed > 0 { - return clampRetryAfter(parsed) + return parsed, true } - return clampRetryAfter(fallback) + return 0, false } func parseRetryAfterValue(raw string, now time.Time) time.Duration { @@ -200,6 +237,12 @@ func Classify(status int, body, retryAfter, kindHint, failoverHint string) Class } out := Classified{Kind: kind, Message: strings.TrimSpace(msg), Code: firstNonEmpty(code, kind), Type: firstNonEmpty(typ, "api_error")} + // A hint the upstream actually sent is authoritative: use it verbatim and + // never let the local backoff ladder multiply it. + _, hasHint := parseUpstreamRetryHint(body, retryAfter) + if hasHint { + out.ExactReset = true + } switch kind { case KindQuota: out.Status = 429 @@ -208,7 +251,22 @@ func Classify(status int, body, retryAfter, kindHint, failoverHint string) Class // When every account is exhausted the route itself stops with // insufficient_quota (see quotaBlockedMessage / coolingPickError). out.Failover = true - out.Cooldown = NextLocalMidnightCooldown() + // A parsed upstream reset beats the local-midnight fallback, but only + // when it is long enough to be a real reset window. The generic hint + // path clamps at maxRetryAfter (10m) for rate limits; applying that cap + // to a multi-hour quota reset would retry a dead account every ten + // minutes. A short hint (a transient blip reported as quota) falls back + // to the local rollover, which is the safer park. + if raw, ok := parseUpstreamRetryHintRaw(body, retryAfter); ok && raw >= time.Minute { + if raw > 24*time.Hour { + raw = 24 * time.Hour + } + out.Cooldown = raw + out.ExactReset = true + } else { + out.Cooldown = NextLocalMidnightCooldown() + out.ExactReset = false + } out.Code = firstNonEmpty(code, "insufficient_quota") out.Type = "insufficient_quota" case KindRateLimit: @@ -222,12 +280,14 @@ func Classify(status int, body, retryAfter, kindHint, failoverHint string) Class out.Failover = false out.Cooldown = 0 out.RetryAfter = ParseRetryAfterHint(body, retryAfter, 0) + out.ExactReset = false break } out.Failover = true out.Cooldown = ParseRetryAfterHint(body, retryAfter, 60*time.Second) if out.Cooldown > 0 && out.Cooldown < minRateLimitCooldown { out.Cooldown = minRateLimitCooldown + out.ExactReset = false } case KindAuth: if status == 401 { diff --git a/internal/executor/error.go b/internal/executor/error.go index d9d3247c..46f6e4bb 100644 --- a/internal/executor/error.go +++ b/internal/executor/error.go @@ -78,6 +78,9 @@ func newUnavailableStreamError(code, message string, status int, cause error) er classified.Message = message classified.Status = status classified.Type = "api_error" + // A stream that ended without [DONE] or broke mid-read is an upstream + // hiccup, not proof that this account's credential or quota is broken. + classified.Transient = true return NewExecutionError(classified, cause) } @@ -98,7 +101,18 @@ func ClassifyError(err error) Classified { return Classified{ Kind: accounts.KindUnavailable, Status: http.StatusBadGateway, Failover: true, Cooldown: 10 * time.Second, RetryAfter: 10 * time.Second, - Code: "first_byte_timeout", Message: err.Error(), + Code: "first_byte_timeout", Message: err.Error(), Transient: true, + } + } + // An upstream that sent the head and then went silent for the whole idle + // deadline is a hang, not a client cancel: the caller is still waiting. Bytes + // are already on the wire, so there is no failover hop left; cool the account + // briefly so the next turn starts somewhere else. + if errors.Is(err, ErrStreamIdle) { + return Classified{ + Kind: accounts.KindUnavailable, Status: http.StatusBadGateway, + Cooldown: 10 * time.Second, Code: "stream_idle_timeout", + Type: "api_error", Message: err.Error(), Transient: true, } } if errors.Is(err, context.Canceled) || errors.Is(err, context.DeadlineExceeded) { @@ -179,6 +193,7 @@ func ClassifyError(err error) Classified { // another account serves the turn, but never cool this one down. classified.Failover = true classified.Cooldown = 0 + classified.Transient = true } switch classified.Kind { case accounts.KindRateLimit: @@ -187,8 +202,10 @@ func ClassifyError(err error) Classified { classified.Cooldown = 5 * time.Minute case providerErr.RetryAfter > 0: classified.Cooldown = providerErr.RetryAfter + classified.ExactReset = true if classified.Cooldown < 30*time.Second { classified.Cooldown = 30 * time.Second + classified.ExactReset = false } } case accounts.KindQuota: @@ -196,6 +213,7 @@ func ClassifyError(err error) Classified { // Quota stays account-wide; Classify already marks it for failover. if providerErr.RetryAfter > 0 { classified.Cooldown = providerErr.RetryAfter + classified.ExactReset = true } } classified.RetryAfter = classified.Cooldown diff --git a/internal/executor/pool.go b/internal/executor/pool.go index 91330ea2..c3ed17fe 100644 --- a/internal/executor/pool.go +++ b/internal/executor/pool.go @@ -1266,8 +1266,14 @@ func (p *Pool) MarkClassified(id string, c Classified) { // interval. A new failure kind starts the ladder over. Backoff is // tracked per model when the cooldown is model-scoped, so one // model's repeat failures don't inflate another model's ladder. + // Escalation is only for failures that say something durable about + // the account. A transient upstream hiccup (empty stream, first-byte + // timeout) and an upstream-supplied reset time are already accurate, + // so multiplying them parks a healthy account well past recovery. + escalate := !c.Transient && !c.ExactReset && c.Kind != KindInvalidRequest level := 0 - if prevKind == c.Kind && c.Kind != KindInvalidRequest { + switch { + case prevKind == c.Kind && escalate: if model != "" { if p.items[i].ModelBackoff == nil { p.items[i].ModelBackoff = map[string]int{} @@ -1282,7 +1288,11 @@ func (p *Pool) MarkClassified(id string, c Classified) { } level = p.items[i].BackoffLevel } - } else { + case !escalate: + // Leave the ladder untouched. Resetting it on a transient blip + // would erase an earned level for the durable failure that + // follows, and bumping it would punish a healthy account. + default: // New kind: reset that ladder so it starts over. if model != "" { if p.items[i].ModelBackoff == nil { @@ -1294,7 +1304,10 @@ func (p *Pool) MarkClassified(id string, c Classified) { } } cooldown := c.Cooldown - if level > 1 { + if c.Transient && cooldown > transientCooldownCap { + cooldown = transientCooldownCap + } + if escalate && level > 1 { cooldown, _ = nextBackoffCooldown(c.Cooldown, level-1) } until := time.Now().Add(cooldown) diff --git a/internal/executor/prepare.go b/internal/executor/prepare.go index d1af9da2..40c5e2fb 100644 --- a/internal/executor/prepare.go +++ b/internal/executor/prepare.go @@ -69,8 +69,9 @@ type PrepareInput struct { SessionHeader string ConversationID string CrossProviderPool bool - // ModelAggregation lets a key call bare aggregate aliases even when the - // cross-provider pool setting is off. Only account-defined aliases qualify. + // ModelAggregation lets a key call provider-neutral names even when the + // cross-provider pool setting is off: account-defined aliases or logical + // models configured in the model pool. ModelAggregation bool Now time.Time NewRequestID func() string @@ -102,11 +103,25 @@ func (e ChatExecutor) Prepare(in PrepareInput) (PreparedRequest, error) { request.Model = publicModel request.Stream = in.NativeRequest.Stream() } + // Resolve a logical aggregation model into an immutable per-request plan. + // This happens once, before any Pool lock, and the plan is carried in the + // context so routing uses a stable snapshot (no DB/facade access under lock, + // no cross-request mutable state). Only an aggregation key may opt into the + // logical namespace: a normal key always routes the real provider model, so + // a logical ID that collides with a real catalog ID can never shadow it. + var aggregatePlan *AggregatePlan + if in.Aggregations != nil && in.ModelAggregation && ProviderPrefix(publicModel) == "" { + if plan, ok := e.resolveAggregation(in.Context, in.Aggregations, publicModel, in.Identity.AllowedProviders); ok { + aggregatePlan = plan + } + } if in.ModelAggregation { // An aggregation key's contract is stricter than the shared pool: it may - // only call the provider-neutral aliases its own accounts define. A real - // catalog id or a provider-prefixed id would leak the split view back. - if strings.Contains(strings.TrimSpace(publicModel), "/") || !e.servesAggregationAlias(publicModel, in.Identity) { + // only call the provider-neutral names it exposes — an account alias or a + // configured logical model. A real catalog id or a provider-prefixed id + // would leak the split view back. + if strings.Contains(strings.TrimSpace(publicModel), "/") || + (aggregatePlan == nil && !e.servesAggregationAlias(publicModel, in.Identity)) { return PreparedRequest{}, &PrepareError{ Status: 400, Code: "model_not_aggregated", @@ -120,16 +135,6 @@ func (e ChatExecutor) Prepare(in PrepareInput) (PreparedRequest, error) { Message: "cross-provider model pool is disabled; use a provider-prefixed model ID such as qoder/glm-5.2", } } - // Resolve a logical aggregation model into an immutable per-request plan. - // This happens once, before any Pool lock, and the plan is carried in the - // context so routing uses a stable snapshot (no DB/facade access under lock, - // no cross-request mutable state). - var aggregatePlan *AggregatePlan - if in.Aggregations != nil && (in.CrossProviderPool || in.ModelAggregation) && ProviderPrefix(publicModel) == "" { - if plan, ok := e.resolveAggregation(in.Context, in.Aggregations, publicModel, in.Identity.AllowedProviders); ok { - aggregatePlan = plan - } - } providerFilter, modelRegion := ResolveProviderFilter(&request, in.CrossProviderPool || in.ModelAggregation) prefer := strings.TrimSpace(in.PreferAccount) @@ -166,6 +171,19 @@ func (e ChatExecutor) Prepare(in PrepareInput) (PreparedRequest, error) { requestedReasoning = level } } + if requestedReasoning == "" && aggregatePlan != nil && aggregatePlan.ReasoningEffort != "" && + !providers.RequestsDisabledThinking(request) { + // The logical model's configured default fills a request that carried no + // reasoning intent at all. Each member's adapter still clamps the level + // to that model's own vocabulary, so the default never invents a level a + // provider cannot honor; an explicit client level is never overridden. + level := aggregatePlan.ReasoningEffort + if in.NativeRequest != nil { + in.NativeRequest = in.NativeRequest.WithDefaultReasoning(level) + } + request.ReasoningEffort = json.RawMessage(strconv.Quote(level)) + requestedReasoning = level + } if in.Logs != nil { in.Logs.Start(accounts.RequestLog{ ID: requestID, @@ -223,8 +241,13 @@ func (e ChatExecutor) Prepare(in PrepareInput) (PreparedRequest, error) { } else if sessionKeyFor("", "", in.Identity, request) == "" && MessageStatShards() > 0 { source = "shard" } + // The component hashes answer the question a bare key cannot: when a + // chat re-anchors every turn, which part of the request moved? + parts := translate.SeedComponents(request) log.Printf("session affinity request_id=%q source=%q key=%q model=%q tools=%t msgs=%d", requestID, source, shortSessionKey(sessionKey), request.Model, len(request.Tools) > 0, len(request.Messages)) + log.Printf("session affinity components request_id=%q key=%q model_hash=%q tools_hash=%q prefix_hash=%q first_user_hash=%q", + requestID, shortSessionKey(sessionKey), parts.Model, parts.Tools, parts.Prefix, parts.FirstUser) } return PreparedRequest{ Context: ctx, diff --git a/internal/executor/prepare_test.go b/internal/executor/prepare_test.go index 8f257671..19d80dd1 100644 --- a/internal/executor/prepare_test.go +++ b/internal/executor/prepare_test.go @@ -74,7 +74,27 @@ func TestPrepareStripsPrefixAndChecksGrants(t *testing.T) { } } -func TestPrepareAggregationKeyOnlyAcceptsItsAliases(t *testing.T) { +func TestPrepareNormalKeyDoesNotResolveAggregationNamespace(t *testing.T) { + resolver := &aggResolverStub{agg: accounts.Aggregation{ + ID: "deepseek-v4.1-flash", Enabled: true, + Members: []accounts.AggregationMember{{Provider: "trae", Model: "deepseek-v4.1-flash"}}, + }} + ex := NewChatExecutor(NewPool(nil, nil), "") + got, err := ex.Prepare(PrepareInput{ + Request: translate.ChatRequest{Model: "deepseek-v4.1-flash", Messages: []translate.ChatMessage{{Role: "user", Content: "hi"}}}, + Identity: auth.KeyIdentity(accounts.APIKey{ID: "key_1", Name: "normal", Enabled: true}), + CrossProviderPool: true, + Aggregations: resolver, + }) + if err != nil { + t.Fatal(err) + } + if aggregatePlanFrom(got.Context) != nil || resolver.hit != 0 { + t.Fatalf("normal key entered aggregation namespace: hit=%d plan=%+v", resolver.hit, aggregatePlanFrom(got.Context)) + } +} + +func TestPrepareAggregationKeyAliasesAndLogicalModels(t *testing.T) { pool := NewPool(nil, nil) pool.Upsert(Item{ ID: "q1", Provider: "qoder", Models: []string{"kimi-k2.6"}, @@ -119,6 +139,62 @@ func TestPrepareAggregationKeyOnlyAcceptsItsAliases(t *testing.T) { } } +func TestPrepareAggregationKeyAcceptsLogicalModel(t *testing.T) { + pool := NewPool(nil, nil) + pool.Upsert(Item{ID: "q1", Provider: "qoder", Models: []string{"kimi-k2.6"}}) + ex := NewChatExecutor(pool, "") + identity := auth.KeyIdentity(accounts.APIKey{ + ID: "key_agg", Name: "agg", Providers: []string{"qoder"}, Enabled: true, ModelAggregation: true, + }) + resolver := stubAggregationResolver{agg: accounts.Aggregation{ + ID: "glm-5.2", Enabled: true, + Members: []accounts.AggregationMember{{Provider: "qoder", Model: "kimi-k2.6"}}, + }} + got, err := ex.Prepare(PrepareInput{ + Request: translate.ChatRequest{Model: "glm-5.2", Messages: []translate.ChatMessage{{Role: "user", Content: "hi"}}}, + Identity: identity, + ModelAggregation: true, + Aggregations: resolver, + }) + if err != nil { + t.Fatalf("logical model on aggregation key: %v", err) + } + plan := aggregatePlanFrom(got.Context) + if plan == nil || plan.ID != "glm-5.2" || len(plan.Members) != 1 { + t.Fatalf("plan=%+v", plan) + } + + // A logical model whose members are all outside the key's grants stays + // unreachable. + identity.AllowedProviders = []string{"workbuddy"} + if _, err := ex.Prepare(PrepareInput{ + Request: translate.ChatRequest{Model: "glm-5.2", Messages: []translate.ChatMessage{{Role: "user", Content: "hi"}}}, + Identity: identity, + ModelAggregation: true, + Aggregations: resolver, + }); err == nil { + t.Fatal("logical model outside provider grants was accepted") + } +} + +type stubAggregationResolver struct { + agg accounts.Aggregation +} + +func (s stubAggregationResolver) Resolve(_ context.Context, id string, allowed map[string]bool) (accounts.Aggregation, error) { + if id != s.agg.ID { + return accounts.Aggregation{}, context.Canceled + } + out := s.agg + out.Members = nil + for _, member := range s.agg.Members { + if allowed == nil || allowed[member.Provider] { + out.Members = append(out.Members, member) + } + } + return out, nil +} + func TestPrepareDeniesUngrantedProvider(t *testing.T) { ex := NewChatExecutor(NewPool(nil, nil), "") _, err := ex.Prepare(PrepareInput{ @@ -520,3 +596,78 @@ func TestPrepareQoder1MToggleFlowsToUpstreamBody(t *testing.T) { t.Errorf("model_config.max_input_tokens = %v, want 1000000 (1M must reach upstream)", modelCfg["max_input_tokens"]) } } + +func TestPrepareAppliesAggregationDefaultReasoning(t *testing.T) { + pool := NewPool(nil, nil) + pool.Upsert(Item{ID: "q1", Provider: "qoder", Models: []string{"kimi-k2.6"}}) + ex := NewChatExecutor(pool, "") + identity := auth.KeyIdentity(accounts.APIKey{ + ID: "key_agg", Name: "agg", Providers: []string{"qoder"}, Enabled: true, ModelAggregation: true, + }) + resolver := stubAggregationResolver{agg: accounts.Aggregation{ + ID: "pool-model", Enabled: true, ReasoningEffort: "high", + Members: []accounts.AggregationMember{{Provider: "qoder", Model: "kimi-k2.6"}}, + }} + base := translate.ChatRequest{Model: "pool-model", Messages: []translate.ChatMessage{{Role: "user", Content: "hi"}}} + + got, err := ex.Prepare(PrepareInput{ + Request: base, Identity: identity, ModelAggregation: true, Aggregations: resolver, + }) + if err != nil { + t.Fatal(err) + } + if string(got.Request.ReasoningEffort) != `"high"` { + t.Fatalf("default reasoning = %s", got.Request.ReasoningEffort) + } + + explicit := base + explicit.ReasoningEffort = json.RawMessage(`"low"`) + got, err = ex.Prepare(PrepareInput{ + Request: explicit, Identity: identity, ModelAggregation: true, Aggregations: resolver, + }) + if err != nil { + t.Fatal(err) + } + if string(got.Request.ReasoningEffort) != `"low"` { + t.Fatalf("client level was overridden: %s", got.Request.ReasoningEffort) + } + + disabled := base + disabled.Thinking = json.RawMessage(`{"type":"disabled"}`) + got, err = ex.Prepare(PrepareInput{ + Request: disabled, Identity: identity, ModelAggregation: true, Aggregations: resolver, + }) + if err != nil { + t.Fatal(err) + } + if len(got.Request.ReasoningEffort) != 0 { + t.Fatalf("disabled thinking must not pick up the default: %s", got.Request.ReasoningEffort) + } +} + +func TestPrepareAppliesAggregationDefaultReasoningToNativeResponses(t *testing.T) { + pool := NewPool(nil, nil) + pool.Upsert(Item{ID: "q1", Provider: "qoder", Models: []string{"kimi-k2.6"}}) + ex := NewChatExecutor(pool, "") + identity := auth.KeyIdentity(accounts.APIKey{ + ID: "key_agg", Name: "agg", Providers: []string{"qoder"}, Enabled: true, ModelAggregation: true, + }) + resolver := stubAggregationResolver{agg: accounts.Aggregation{ + ID: "pool-model", Enabled: true, ReasoningEffort: "high", + Members: []accounts.AggregationMember{{Provider: "qoder", Model: "kimi-k2.6"}}, + }} + native, err := translate.ParseNativeResponses([]byte(`{"model":"pool-model","input":"hi"}`)) + if err != nil { + t.Fatal(err) + } + got, err := ex.Prepare(PrepareInput{ + Request: translate.ChatRequest{Model: "pool-model", Messages: []translate.ChatMessage{{Role: "user", Content: "hi"}}}, + NativeRequest: native, Identity: identity, ModelAggregation: true, Aggregations: resolver, + }) + if err != nil { + t.Fatal(err) + } + if got.NativeRequest == nil || got.NativeRequest.RequestedReasoningEffort() != "high" { + t.Fatalf("native reasoning = %v", got.NativeRequest) + } +} diff --git a/internal/executor/session_affinity.go b/internal/executor/session_affinity.go index a4152b38..d0d7eec9 100644 --- a/internal/executor/session_affinity.go +++ b/internal/executor/session_affinity.go @@ -5,6 +5,8 @@ import ( "context" "crypto/sha256" "encoding/hex" + "os" + "strconv" "strings" "sync" "time" @@ -13,8 +15,16 @@ import ( ) const ( - defaultSessionAffinityTTL = time.Hour + // defaultSessionAffinityTTL bounds how long a chat stays pinned to one + // account. A working session routinely idles longer than an hour between + // turns, and every expired binding costs one full prompt-cache rebuild, so + // the default matches a working half-day rather than a coffee break. + defaultSessionAffinityTTL = 4 * time.Hour defaultSessionAffinityCapacity = 10_000 + // maxSessionAffinityTTL keeps an operator override from turning the LRU + // into durable account state by accident. + maxSessionAffinityTTL = 48 * time.Hour + maxSessionAffinityCapacity = 1_000_000 ) type sessionKeyContextKey struct{} @@ -67,6 +77,13 @@ type SessionAffinityStats struct { LastEscapeAt string `json:"last_escape_at,omitempty"` LastEscapeReason string `json:"last_escape_reason,omitempty"` LastMissReason string `json:"last_miss_reason,omitempty"` + // MissReasons and EscapeReasons are distributions, not single samples. + // A cache-hit regression is diagnosed by which reason dominates: a rising + // "expired" count is a TTL problem, "account_missing"/"model_unavailable" + // is a pool problem, and "upstream_failover" is the failover path eating + // affinity. The last-value fields above stay for older console builds. + MissReasons map[string]int `json:"miss_reasons,omitempty"` + EscapeReasons map[string]int `json:"escape_reasons,omitempty"` } // SessionAffinity is a bounded process-local LRU. Session bindings are a @@ -85,6 +102,8 @@ type SessionAffinity struct { lastEscapeAt time.Time lastEscapeReason string lastMissReason string + missReasons map[string]int + escapeReasons map[string]int } func NewSessionAffinity(ttl time.Duration, capacity int) *SessionAffinity { @@ -95,13 +114,50 @@ func NewSessionAffinity(ttl time.Duration, capacity int) *SessionAffinity { capacity = defaultSessionAffinityCapacity } return &SessionAffinity{ - ttl: ttl, - capacity: capacity, - entries: make(map[string]*list.Element, capacity), - lru: list.New(), + ttl: ttl, + capacity: capacity, + entries: make(map[string]*list.Element, capacity), + lru: list.New(), + missReasons: map[string]int{}, + escapeReasons: map[string]int{}, } } +// ResolveSessionAffinityConfig reads the optional operator overrides. Both +// knobs are deliberately env-only: they describe host capacity, not per-route +// behaviour, and a wrong value must never be persisted into a shared store. +func ResolveSessionAffinityConfig() (time.Duration, int) { + ttl := defaultSessionAffinityTTL + if raw := strings.TrimSpace(os.Getenv("CLI2API_AFFINITY_TTL")); raw != "" { + parsed, err := time.ParseDuration(raw) + if err != nil { + // A bare integer is accepted as seconds so `CLI2API_AFFINITY_TTL=14400` + // does not silently fall back to the default. + if seconds, convErr := strconv.Atoi(raw); convErr == nil { + parsed = time.Duration(seconds) * time.Second + } else { + parsed = 0 + } + } + if parsed > 0 { + if parsed > maxSessionAffinityTTL { + parsed = maxSessionAffinityTTL + } + ttl = parsed + } + } + capacity := defaultSessionAffinityCapacity + if raw := strings.TrimSpace(os.Getenv("CLI2API_AFFINITY_CAPACITY")); raw != "" { + if n, err := strconv.Atoi(raw); err == nil && n > 0 { + if n > maxSessionAffinityCapacity { + n = maxSessionAffinityCapacity + } + capacity = n + } + } + return ttl, capacity +} + func (a *SessionAffinity) Get(key string) (string, bool) { if a == nil { return "", false @@ -116,6 +172,7 @@ func (a *SessionAffinity) Get(key string) (string, bool) { if !ok { a.misses++ a.lastMissReason = "not_found" + a.missReasons["not_found"]++ return "", false } binding := element.Value.(sessionBinding) @@ -123,6 +180,7 @@ func (a *SessionAffinity) Get(key string) (string, bool) { a.remove(element) a.misses++ a.lastMissReason = "expired" + a.missReasons["expired"]++ return "", false } a.hits++ @@ -130,6 +188,31 @@ func (a *SessionAffinity) Get(key string) (string, bool) { return binding.accountID, true } +// Peek reads a binding without counting a hit. Callers that only ask "who is +// this session anchored to?" (bind-time decisions) must not inflate the hit +// rate, which is a routing-quality signal. +func (a *SessionAffinity) Peek(key string) (string, bool) { + if a == nil { + return "", false + } + key = strings.TrimSpace(key) + if key == "" { + return "", false + } + a.mu.Lock() + defer a.mu.Unlock() + element, ok := a.entries[key] + if !ok { + return "", false + } + binding := element.Value.(sessionBinding) + if !binding.expiresAt.After(time.Now()) { + a.remove(element) + return "", false + } + return binding.accountID, true +} + func (a *SessionAffinity) Bind(key, accountID string) { if a == nil { return @@ -165,6 +248,7 @@ func (a *SessionAffinity) RecordEscape(reason string) { a.escapes++ a.lastEscapeAt = time.Now().UTC() a.lastEscapeReason = strings.TrimSpace(reason) + a.escapeReasons[strings.TrimSpace(reason)]++ a.mu.Unlock() } @@ -184,7 +268,20 @@ func (a *SessionAffinity) Stats() SessionAffinityStats { Escapes: a.escapes, Rebindings: a.rebindings, LastEscapeAt: lastAt, LastEscapeReason: a.lastEscapeReason, LastMissReason: a.lastMissReason, + MissReasons: cloneReasonCounts(a.missReasons), + EscapeReasons: cloneReasonCounts(a.escapeReasons), + } +} + +func cloneReasonCounts(src map[string]int) map[string]int { + if len(src) == 0 { + return nil + } + dst := make(map[string]int, len(src)) + for reason, count := range src { + dst[reason] = count } + return dst } func (a *SessionAffinity) Forget(key string) { diff --git a/internal/executor/stream_idle.go b/internal/executor/stream_idle.go new file mode 100644 index 00000000..850caad5 --- /dev/null +++ b/internal/executor/stream_idle.go @@ -0,0 +1,132 @@ +package executor + +import ( + "errors" + "fmt" + "io" + "os" + "strconv" + "strings" + "sync" + "sync/atomic" + "time" +) + +// ErrStreamIdle reports that an upstream answered the response head and then +// stopped sending bytes for longer than the idle deadline. It is deliberately +// distinct from a client cancel: the caller is still there and the upstream is +// the one that went silent. +var ErrStreamIdle = errors.New("upstream stream idle timeout") + +// idleStreamDefault is how long a streaming response may stay silent before the +// gateway gives up on it. +// +// Without this bound an upstream that accepts a request, sends the head plus a +// token or two, and then stalls keeps the pool slot, the client connection and +// the request log open forever. The client-side heartbeat hides the stall from +// the caller, so nothing ever gives up: the console keeps showing an extra +// in-flight slot until the container restarts. qauth already bounds Qoder PAT +// streams this way; in-process adapters like WorkBuddy stream with a zero +// http.Client timeout, so the executor has to own the deadline. +const idleStreamDefault = 5 * time.Minute + +// idleStreamEnv overrides the idle deadline in milliseconds. +const idleStreamEnv = "CLI2API_STREAM_IDLE_MS" + +// resolveStreamIdleTimeout reads CLI2API_STREAM_IDLE_MS. Absent, invalid or +// sub-30s values fall back to the default (and clamp up): a shorter deadline +// would cut legitimate slow prefills. +func resolveStreamIdleTimeout() time.Duration { + raw := strings.TrimSpace(os.Getenv(idleStreamEnv)) + if raw == "" { + return idleStreamDefault + } + ms, err := strconv.Atoi(raw) + if err != nil || ms <= 0 { + return idleStreamDefault + } + d := time.Duration(ms) * time.Millisecond + if d < 30*time.Second { + return 30 * time.Second + } + return d +} + +// idleGuardBody closes the wrapped body once a read has been blocked longer +// than the deadline. Upstream bodies cannot be given a read deadline in +// general, but Close unblocks a pending Read, which is how the relay learns the +// stream is dead instead of waiting forever. +type idleGuardBody struct { + inner io.ReadCloser + timeout time.Duration + last atomic.Int64 // UnixNano of the last byte received, or of the current blocked Read + pending atomic.Int32 // number of Reads currently blocked on the inner body + tripped atomic.Bool + done chan struct{} + once sync.Once +} + +func guardStreamIdle(body io.ReadCloser, timeout time.Duration) io.ReadCloser { + if body == nil { + return body + } + if timeout <= 0 { + timeout = idleStreamDefault + } + b := &idleGuardBody{inner: body, timeout: timeout, done: make(chan struct{})} + b.last.Store(time.Now().UnixNano()) + go b.watch() + return b +} + +func (b *idleGuardBody) watch() { + every := b.timeout / 4 + if every < 50*time.Millisecond { + every = 50 * time.Millisecond + } + ticker := time.NewTicker(every) + defer ticker.Stop() + for { + select { + case <-b.done: + return + case <-ticker.C: + // Only a blocked Read can be idle-worthy. While the relay is writing + // to a slow client no Read is pending, and the upstream is not at + // fault for that wait. + if b.pending.Load() == 0 { + continue + } + if time.Since(time.Unix(0, b.last.Load())) >= b.timeout { + b.tripped.Store(true) + // Unblock the in-flight Read. The error it returns is mapped back + // to ErrStreamIdle so the relay reports an upstream timeout rather + // than a truncated body. + b.inner.Close() + return + } + } + } +} + +func (b *idleGuardBody) Read(p []byte) (int, error) { + if b.pending.Add(1) == 1 { + // Start the idle clock when the read actually starts waiting; bytes that + // were consumed earlier belong to the previous read. + b.last.Store(time.Now().UnixNano()) + } + n, err := b.inner.Read(p) + b.pending.Add(-1) + if n > 0 { + b.last.Store(time.Now().UnixNano()) + } + if err != nil && b.tripped.Load() { + return n, fmt.Errorf("%w: no bytes for %s", ErrStreamIdle, b.timeout) + } + return n, err +} + +func (b *idleGuardBody) Close() error { + b.once.Do(func() { close(b.done) }) + return b.inner.Close() +} diff --git a/internal/executor/stream_idle_test.go b/internal/executor/stream_idle_test.go new file mode 100644 index 00000000..cbd381c6 --- /dev/null +++ b/internal/executor/stream_idle_test.go @@ -0,0 +1,158 @@ +package executor + +import ( + "errors" + "io" + "net/http" + "strings" + "sync" + "testing" + "time" + + "github.com/caigee-cmd/cli2api/internal/accounts" +) + +// silentBody blocks every Read until Close is called, mimicking an upstream +// that sent the response head and then stopped writing bytes. +type silentBody struct { + ch chan struct{} + once sync.Once +} + +func newSilentBody() *silentBody { return &silentBody{ch: make(chan struct{})} } + +func (b *silentBody) Read(p []byte) (int, error) { + <-b.ch + return 0, errors.New("body closed") +} + +func (b *silentBody) Close() error { + b.once.Do(func() { close(b.ch) }) + return nil +} + +func TestStreamIdleGuardTripsOnSilentBody(t *testing.T) { + body := newSilentBody() + guarded := guardStreamIdle(body, 80*time.Millisecond) + done := make(chan error, 1) + go func() { + buf := make([]byte, 8) + _, err := guarded.Read(buf) + done <- err + }() + select { + case err := <-done: + if !errors.Is(err, ErrStreamIdle) { + t.Fatalf("Read err = %v, want ErrStreamIdle", err) + } + if !strings.Contains(err.Error(), "80ms") { + t.Fatalf("err message lost the deadline: %v", err) + } + case <-time.After(2 * time.Second): + t.Fatal("idle guard did not unblock a silent read") + } + if err := guarded.Close(); err != nil { + t.Fatalf("close: %v", err) + } +} + +func TestStreamIdleGuardIgnoresConsumerStall(t *testing.T) { + body := newSilentBody() + guarded := guardStreamIdle(body, 60*time.Millisecond) + // No Read is pending: the relay is busy writing to a slow client, which is + // not the upstream's fault. The guard must not close the body behind it. + time.Sleep(200 * time.Millisecond) + if err := guarded.Close(); err != nil { + t.Fatalf("close: %v", err) + } + buf := make([]byte, 8) + _, err := guarded.Read(buf) + if errors.Is(err, ErrStreamIdle) { + t.Fatalf("idle guard fired without a pending read: %v", err) + } +} + +func TestStreamIdleGuardKeepsActiveStreams(t *testing.T) { + reader, writer := io.Pipe() + go func() { + for i := 0; i < 6; i++ { + time.Sleep(30 * time.Millisecond) + if _, err := writer.Write([]byte("x")); err != nil { + return + } + } + writer.Close() + }() + guarded := guardStreamIdle(reader, 100*time.Millisecond) + data, err := io.ReadAll(guarded) + if err != nil { + t.Fatalf("active stream tripped the idle guard: %v", err) + } + if len(data) != 6 { + t.Fatalf("read %d bytes, want 6", len(data)) + } + if err := guarded.Close(); err != nil { + t.Fatalf("close: %v", err) + } +} + +func TestAttachInFlightReleaseGuardsIdleAndReleasesSlot(t *testing.T) { + pool := NewPool([]string{"http://a:3020"}, []string{"a"}) + if !pool.Acquire("a") { + t.Fatal("acquire") + } + body := newSilentBody() + resp := &http.Response{StatusCode: http.StatusOK, Body: body} + e := ChatExecutor{Pool: pool} + got := e.attachInFlightRelease(resp, "req-1", "a") + + closer, ok := got.Body.(*releaseCloser) + if !ok { + t.Fatalf("body = %T, want *releaseCloser", got.Body) + } + if _, ok := closer.ReadCloser.(*idleGuardBody); !ok { + t.Fatalf("inner body = %T, want *idleGuardBody", closer.ReadCloser) + } + if err := got.Body.Close(); err != nil { + t.Fatalf("close: %v", err) + } + item, ok := pool.ByID("a") + if !ok { + t.Fatal("account missing from pool") + } + if item.InFlight != 0 { + t.Fatalf("slot not released after Close: in_flight=%d", item.InFlight) + } +} + +func TestClassifyStreamIdleIsUpstreamHang(t *testing.T) { + classified := ClassifyError(errors.Join(ErrStreamIdle, errors.New("no bytes for 5m0s"))) + if classified.Kind != accounts.KindUnavailable { + t.Fatalf("kind = %q, want unavailable", classified.Kind) + } + if classified.Code != "stream_idle_timeout" { + t.Fatalf("code = %q, want stream_idle_timeout", classified.Code) + } + if classified.Failover { + t.Fatal("idle trips after bytes are on the wire; must not claim a failover hop") + } +} + +func TestResolveStreamIdleTimeout(t *testing.T) { + t.Setenv(idleStreamEnv, "") + if got := resolveStreamIdleTimeout(); got != idleStreamDefault { + t.Fatalf("default = %s, want %s", got, idleStreamDefault) + } + t.Setenv(idleStreamEnv, "90") + if got := resolveStreamIdleTimeout(); got != 30*time.Second { + t.Fatalf("sub-30s value = %s, want clamp to 30s", got) + } + t.Setenv(idleStreamEnv, "240000") + if got := resolveStreamIdleTimeout(); got != 4*time.Minute { + t.Fatalf("value = %s, want 4m", got) + } + t.Setenv(idleStreamEnv, "bogus") + if got := resolveStreamIdleTimeout(); got != idleStreamDefault { + t.Fatalf("invalid value = %s, want default", got) + } +} diff --git a/internal/gateway/anthropic.go b/internal/gateway/anthropic.go index f45ff9ea..4af2932d 100644 --- a/internal/gateway/anthropic.go +++ b/internal/gateway/anthropic.go @@ -197,7 +197,8 @@ func anthropicMessageResponse(requestID, model, content, reasoning string, toolC blocks = append(blocks, map[string]any{"type": "text", "text": content}) } for _, call := range toolCalls { - input := json.RawMessage(call.Arguments) + arguments, _ := translate.NormalizeToolCallArguments(call.Arguments) + input := json.RawMessage(arguments) if !json.Valid(input) { input = json.RawMessage(`{}`) } diff --git a/internal/gateway/compat.go b/internal/gateway/compat.go index 77b7b39f..c0a75d7f 100644 --- a/internal/gateway/compat.go +++ b/internal/gateway/compat.go @@ -65,30 +65,33 @@ func decodeOpenAIToolCalls(raw json.RawMessage) []proxyToolCall { arguments = "{}" } if _, _, custom := translate.DecodeCustomToolName(call.Function.Name); !custom && !json.Valid([]byte(arguments)) { - continue + normalized, _ := translate.NormalizeToolCallArguments(arguments) + arguments = normalized } calls = append(calls, proxyToolCall{ID: call.ID, Name: call.Function.Name, Arguments: arguments}) } return calls } -func validateProxyToolCallArguments(calls []proxyToolCall) error { +// normalizeProxyToolCallArguments makes every function call carry valid JSON +// arguments. It never fails the turn: a call the model mangled or left +// unfinished keeps only the fields it completed, so the client can run the tool +// and hand the validation error back to the model instead of the client +// aborting the whole round with "arguments are invalid JSON". +func normalizeProxyToolCallArguments(calls []proxyToolCall) bool { + changed := false for index := range calls { call := &calls[index] if _, _, custom := translate.DecodeCustomToolName(call.Name); custom { continue } - arguments := strings.TrimSpace(call.Arguments) - if arguments == "" { - call.Arguments = "{}" - continue - } - if !json.Valid([]byte(arguments)) { - return fmt.Errorf("tool call %q (%s) arguments are invalid JSON", call.ID, call.Name) + normalized, normalizedChanged := translate.NormalizeToolCallArguments(call.Arguments) + call.Arguments = normalized + if normalizedChanged { + changed = true } - call.Arguments = arguments } - return nil + return changed } func (h *Handler) PrepareCompatibilityExecution(r *http.Request, request translate.ChatRequest) (Execution, error) { diff --git a/internal/gateway/compat_stream.go b/internal/gateway/compat_stream.go index 982da19d..8fd5a271 100644 --- a/internal/gateway/compat_stream.go +++ b/internal/gateway/compat_stream.go @@ -7,6 +7,7 @@ import ( "errors" "fmt" "io" + "log" "net/http" "sort" "strings" @@ -114,6 +115,9 @@ type streamedChatOutput struct { reasoning strings.Builder toolCalls map[int]*proxyToolCall finishReason string + // resolved maps a chunk's tool_call position to the call index it belongs + // to, so converters can reuse the same grouping the accumulator chose. + resolved []int } func (o *streamedChatOutput) add(payload json.RawMessage) { @@ -124,11 +128,11 @@ func (o *streamedChatOutput) add(payload json.RawMessage) { Content string `json:"content"` ReasoningContent string `json:"reasoning_content"` ToolCalls []struct { - Index int `json:"index"` + Index *int `json:"index"` ID string `json:"id"` Function struct { - Name string `json:"name"` - Arguments string `json:"arguments"` + Name string `json:"name"` + Arguments json.RawMessage `json:"arguments"` } `json:"function"` } `json:"tool_calls"` } `json:"delta"` @@ -137,6 +141,8 @@ func (o *streamedChatOutput) add(payload json.RawMessage) { if json.Unmarshal(payload, &chunk) != nil { return } + o.resolved = o.resolved[:0] + lastIndex := -1 for _, choice := range chunk.Choices { if choice.FinishReason != "" { o.finishReason = choice.FinishReason @@ -151,10 +157,8 @@ func (o *streamedChatOutput) add(payload json.RawMessage) { if o.toolCalls == nil { o.toolCalls = map[int]*proxyToolCall{} } - index := delta.Index - if index == 0 && callPosition > 0 { - index = callPosition - } + index := o.resolveToolCallIndex(delta.Index, delta.ID, delta.Function.Name, callPosition, lastIndex) + lastIndex = index call := o.toolCalls[index] if call == nil { call = &proxyToolCall{} @@ -166,11 +170,102 @@ func (o *streamedChatOutput) add(payload json.RawMessage) { if delta.Function.Name != "" { call.Name = delta.Function.Name } - call.Arguments += delta.Function.Arguments + call.Arguments = mergeToolArguments(call.Arguments, argumentFragment(delta.Function.Arguments)) + o.resolved = append(o.resolved, index) } } } +// resolveToolCallIndex keeps fragments with one call together. Upstreams that +// omit `index` either keep streaming the same call (no id/name, fold into +// the previous one) or start a new call (id or name present, next slot). +func (o *streamedChatOutput) resolveToolCallIndex(declared *int, id, name string, position, lastIndex int) int { + startsCall := id != "" || name != "" + switch { + case declared != nil && *declared > 0: + return *declared + case declared != nil && !startsCall: + return *declared + case declared != nil && startsCall: + if o.callIsDifferent(*declared, id, name) { + return maxToolCallIndex(o.toolCalls) + 1 + } + return *declared + case startsCall: + if position == 0 && !o.callIsDifferent(0, id, name) { + return 0 + } + return maxToolCallIndex(o.toolCalls) + 1 + case lastIndex >= 0: + return lastIndex + default: + return position + } +} + +// callIsDifferent reports whether this delta starts a new call on an index +// that already holds one. Two calls of the same tool are common, so the +// call id is what separates them; a name-only comparison would merge them. +func (o *streamedChatOutput) callIsDifferent(index int, id, name string) bool { + existing := o.toolCalls[index] + if existing == nil || (existing.Name == "" && existing.ID == "") { + return false + } + if id != "" && existing.ID != "" { + return existing.ID != id + } + return name != "" && existing.Name != "" && existing.Name != name +} + +func maxToolCallIndex(calls map[int]*proxyToolCall) int { + maximum := -1 + for index := range calls { + if index > maximum { + maximum = index + } + } + return maximum +} + +// argumentFragment normalizes the arguments field of a stream delta. Some +// upstreams send a JSON object where the OpenAI schema expects a string; a +// strict `string` decode would drop the whole chunk, content included. +func argumentFragment(raw json.RawMessage) string { + if len(raw) == 0 || string(raw) == "null" { + return "" + } + var text string + if json.Unmarshal(raw, &text) == nil { + return text + } + var value any + if json.Unmarshal(raw, &value) == nil { + if encoded, err := json.Marshal(value); err == nil { + return string(encoded) + } + } + return "" +} + +// mergeToolArguments appends a delta fragment, but tolerates upstreams that +// resend the whole argument buffer (or its tail) on every chunk — concatenating +// those blindly is what produces `{"a":1}{"a":1}` and an invalid tool call. +func mergeToolArguments(base, fragment string) string { + if fragment == "" { + return base + } + if base == "" { + return fragment + } + if len(fragment) > len(base) && strings.HasPrefix(fragment, base) { + return fragment + } + if len(fragment) >= 8 && strings.HasSuffix(base, fragment) { + return base + } + return base + fragment +} + func (o *streamedChatOutput) calls() []proxyToolCall { indexes := make([]int, 0, len(o.toolCalls)) for index := range o.toolCalls { @@ -289,11 +384,11 @@ func RelayAnthropicStream(writer io.Writer, body io.Reader, requestID, model str Content string `json:"content"` ReasoningContent string `json:"reasoning_content"` ToolCalls []struct { - Index int `json:"index"` + Index *int `json:"index"` ID string `json:"id"` Function struct { - Name string `json:"name"` - Arguments string `json:"arguments"` + Name string `json:"name"` + Arguments json.RawMessage `json:"arguments"` } `json:"function"` } `json:"tool_calls"` } `json:"delta"` @@ -336,9 +431,9 @@ func RelayAnthropicStream(writer io.Writer, body io.Reader, requestID, model str if err := closeThinking(); err != nil { return err } - index := delta.Index - if index == 0 && callPosition > 0 { - index = callPosition + index, ok := resolvedCallIndex(current, callPosition) + if !ok { + continue } blockIndex, exists := toolBlocks[index] if !exists && delta.Function.Name != "" { @@ -359,10 +454,8 @@ func RelayAnthropicStream(writer io.Writer, body io.Reader, requestID, model str } exists = true } - if exists && delta.Function.Arguments != "" { - if err := writeSSEEvent(writer, "content_block_delta", map[string]any{"type": "content_block_delta", "index": blockIndex, "delta": map[string]string{"type": "input_json_delta", "partial_json": delta.Function.Arguments}}); err != nil { - return err - } + if !exists { + continue } } } @@ -377,6 +470,12 @@ func RelayAnthropicStream(writer io.Writer, body io.Reader, requestID, model str if err := closeText(); err != nil { return stats, err } + // Arguments are held until the block closes so they can be normalized + // first: a damaged buffer would otherwise reach the client as several + // input_json_delta fragments that never parse. + if err := writeToolArguments(writer, &output, toolBlocks, requestID, model); err != nil { + return stats, err + } for _, blockIndex := range sortedBlockIndexes(toolBlocks) { if err := writeSSEEvent(writer, "content_block_stop", map[string]any{"type": "content_block_stop", "index": blockIndex}); err != nil { return stats, err @@ -426,7 +525,6 @@ func RelayResponsesStream(writer io.Writer, body io.Reader, requestID, model str toolAnnounced := map[int]bool{} toolCallIDs := map[int]string{} toolCallNames := map[int]string{} - toolArgumentLengths := map[int]int{} toolOutputIndexes := map[int]int{} nextOutputIndex := 0 reasoningOutputIndex := -1 @@ -454,11 +552,11 @@ func RelayResponsesStream(writer io.Writer, body io.Reader, requestID, model str Content string `json:"content"` ReasoningContent string `json:"reasoning_content"` ToolCalls []struct { - Index int `json:"index"` + Index *int `json:"index"` ID string `json:"id"` Function struct { - Name string `json:"name"` - Arguments string `json:"arguments"` + Name string `json:"name"` + Arguments json.RawMessage `json:"arguments"` } `json:"function"` } `json:"tool_calls"` } `json:"delta"` @@ -505,9 +603,9 @@ func RelayResponsesStream(writer io.Writer, body io.Reader, requestID, model str } } for callPosition, delta := range choice.Delta.ToolCalls { - index := delta.Index - if index == 0 && callPosition > 0 { - index = callPosition + index, ok := resolvedCallIndex(current, callPosition) + if !ok { + continue } if err := closeReasoning(); err != nil { return err @@ -536,25 +634,9 @@ func RelayResponsesStream(writer io.Writer, body io.Reader, requestID, model str } toolAnnounced[index] = true } - if toolAnnounced[index] { - accumulated := "" - if currentCall := current.toolCalls[index]; currentCall != nil { - accumulated = currentCall.Arguments - } - emitted := toolArgumentLengths[index] - if len(accumulated) > emitted { - deltaPayload := map[string]any{"type": "response.function_call_arguments.delta", "output_index": toolOutputIndexes[index], "item_id": fmt.Sprintf("fc_%s_%d", requestID, index), "call_id": toolCallIDs[index], "name": toolCallNames[index], "delta": accumulated[emitted:]} - if _, _, custom := translate.DecodeCustomToolName(toolCallNames[index]); custom { - toolArgumentLengths[index] = len(accumulated) - continue - } - eventName, _ := deltaPayload["type"].(string) - if err := eventWriter.write(eventName, deltaPayload); err != nil { - return err - } - toolArgumentLengths[index] = len(accumulated) - } - } + // Arguments are not streamed as deltas: a damaged buffer would + // reach the client as fragments that never parse. The normalized + // full string is delivered once in response.function_call_arguments.done. } } return nil @@ -568,8 +650,8 @@ func RelayResponsesStream(writer io.Writer, body io.Reader, requestID, model str } content := output.content.String() calls := output.calls() - if err := validateProxyToolCallArguments(calls); err != nil { - return stats, err + if normalizeProxyToolCallArguments(calls) { + log.Printf("tool call arguments normalized request_id=%q model=%q finish_reason=%q calls=%d", requestID, model, output.finishReason, len(calls)) } if textStarted { if err := eventWriter.write("response.output_text.done", map[string]any{"type": "response.output_text.done", "item_id": "msg_" + requestID, "output_index": textOutputIndex, "content_index": 0, "text": content}); err != nil { @@ -628,6 +710,14 @@ func RelayResponsesStream(writer io.Writer, body io.Reader, requestID, model str return stats, err } } + // The normalized string goes out once, as a single delta followed by + // done: clients that concatenate deltas get the same text as clients + // that read the done event, and neither ever sees a broken fragment. + if call.Arguments != "" { + if err := eventWriter.write("response.function_call_arguments.delta", map[string]any{"type": "response.function_call_arguments.delta", "output_index": outputIndex, "item_id": item["id"], "call_id": call.ID, "name": call.Name, "delta": call.Arguments}); err != nil { + return stats, err + } + } if err := eventWriter.write("response.function_call_arguments.done", map[string]any{"type": "response.function_call_arguments.done", "output_index": outputIndex, "item_id": item["id"], "call_id": call.ID, "name": call.Name, "arguments": call.Arguments}); err != nil { return stats, err } @@ -648,6 +738,53 @@ func RelayResponsesStream(writer io.Writer, body io.Reader, requestID, model str return stats, nil } +// writeToolArguments emits one normalized input_json_delta per tool block. The +// Anthropic wire format has no way to retract a delta, so the arguments are +// buffered to block-close time; that keeps a damaged buffer from reaching the +// client as fragments that never parse. +func writeToolArguments(writer io.Writer, output *streamedChatOutput, toolBlocks map[int]int, requestID, model string) error { + if output == nil { + return nil + } + indexes := make([]int, 0, len(toolBlocks)) + for index := range toolBlocks { + indexes = append(indexes, index) + } + sort.Ints(indexes) + for _, index := range indexes { + blockIndex := toolBlocks[index] + call := output.toolCalls[index] + if call == nil || strings.TrimSpace(call.Arguments) == "" { + continue + } + arguments, changed := translate.NormalizeToolCallArguments(call.Arguments) + if changed { + log.Printf("tool call arguments normalized request_id=%q model=%q tool=%q truncated=%v", requestID, model, call.Name, !json.Valid([]byte(strings.TrimSpace(call.Arguments)))) + } + if err := writeSSEEvent(writer, "content_block_delta", map[string]any{"type": "content_block_delta", "index": blockIndex, "delta": map[string]string{"type": "input_json_delta", "partial_json": arguments}}); err != nil { + return err + } + } + return nil +} + +func resolvedCallIndex(output *streamedChatOutput, position int) (int, bool) { + if output == nil || position >= len(output.resolved) { + return 0, false + } + return output.resolved[position], true +} + +func accumulatedToolArguments(output *streamedChatOutput, index int) string { + if output == nil { + return "" + } + if call := output.toolCalls[index]; call != nil { + return call.Arguments + } + return "" +} + func sortedBlockIndexes(blocks map[int]int) []int { indexes := make([]int, 0, len(blocks)) for _, blockIndex := range blocks { diff --git a/internal/gateway/handler.go b/internal/gateway/handler.go index 94638d44..da3b3db5 100644 --- a/internal/gateway/handler.go +++ b/internal/gateway/handler.go @@ -28,9 +28,9 @@ type Handler struct { RequestedAccount func(*http.Request) string FilterModels func(*http.Request, []map[string]any) []map[string]any DecorateModels func(*http.Request, []map[string]any) []map[string]any - // MergeAggregationModels folds logical aggregation models into /v1/models. - // Injected by app so gateway does not import control/store. - MergeAggregationModels func(context.Context, []map[string]any) []map[string]any + // AggregationKeyModels builds the provider-neutral list for a key with + // model aggregation on: configured logical models plus account aliases. + AggregationKeyModels func(context.Context, *http.Request, []map[string]any) []map[string]any // AfterAccountUse is an optional non-blocking quota invalidation hook. It // runs after the response/stream finishes, never on receipt of SSE headers. AfterAccountUse func(accountID, publicModel string) diff --git a/internal/gateway/models.go b/internal/gateway/models.go index 24046cb3..2ce31293 100644 --- a/internal/gateway/models.go +++ b/internal/gateway/models.go @@ -3,6 +3,7 @@ package gateway import ( "net/http" + "github.com/caigee-cmd/cli2api/internal/auth" "github.com/caigee-cmd/cli2api/internal/control" ) @@ -20,11 +21,19 @@ func (h *Handler) HandleModels(w http.ResponseWriter, r *http.Request) { if h != nil && h.DecorateModels != nil { models = h.DecorateModels(r, models) } - if h != nil && h.crossProviderPoolOn() && h.MergeAggregationModels != nil { - ctx := r.Context() - models = h.MergeAggregationModels(ctx, models) + var identity auth.Identity + if h != nil { + identity = h.requestIdentity(r) } - if h.crossProviderPoolOn() == false && !h.requestIdentity(r).ModelAggregation { + if h != nil && identity.ModelAggregation && h.AggregationKeyModels != nil { + // Aggregation keys expose only provider-neutral names (logical model-pool + // entries and account aliases), never real provider rows. + models = h.AggregationKeyModels(r.Context(), r, models) + } + // The shared catalog never carries logical aggregation entries: they belong + // to aggregation keys only, so a logical ID can never hide or replace a real + // provider model for an ordinary client. + if h.crossProviderPoolOn() == false && !identity.ModelAggregation { // The gateway refuses bare ids with the pool off; serve prefixed ids so // OpenAI-compatible clients see exactly what the gateway accepts. // Aggregation keys are the exception: their whole point is a diff --git a/internal/gateway/models_aggregation_test.go b/internal/gateway/models_aggregation_test.go new file mode 100644 index 00000000..0da82db2 --- /dev/null +++ b/internal/gateway/models_aggregation_test.go @@ -0,0 +1,102 @@ +package gateway + +import ( + "context" + "encoding/json" + "net/http" + "net/http/httptest" + "testing" + + "github.com/caigee-cmd/cli2api/internal/auth" +) + +func TestHandleModelsUsesAggregationKeyList(t *testing.T) { + called := false + h := &Handler{ + Models: func(bool, string) ([]map[string]any, error) { + return []map[string]any{{"id": "kimi-k2.6", "object": "model", "provider": "qoder"}}, nil + }, + FilterModels: func(_ *http.Request, models []map[string]any) []map[string]any { return models }, + AggregationKeyModels: func(_ context.Context, _ *http.Request, models []map[string]any) []map[string]any { + called = true + if len(models) != 1 || models[0]["id"] != "kimi-k2.6" { + t.Fatalf("aggregation callback input=%v", models) + } + return []map[string]any{{"id": "glm-5.2", "object": "model", "owned_by": "aggregation"}} + }, + } + req := httptest.NewRequest(http.MethodGet, "/v1/models", nil) + req = req.WithContext(auth.WithIdentity(req.Context(), auth.Identity{Kind: auth.KindKey, ModelAggregation: true})) + rec := httptest.NewRecorder() + h.HandleModels(rec, req) + if rec.Code != http.StatusOK { + t.Fatalf("status=%d body=%s", rec.Code, rec.Body.String()) + } + var body struct { + Data []map[string]any `json:"data"` + } + if err := json.Unmarshal(rec.Body.Bytes(), &body); err != nil { + t.Fatal(err) + } + if !called { + t.Fatal("aggregation callback was not used") + } + if len(body.Data) != 1 || body.Data[0]["id"] != "glm-5.2" { + t.Fatalf("data=%v", body.Data) + } + for _, model := range body.Data { + if model["provider"] != nil || model["native_model"] != nil { + t.Fatalf("provider metadata leaked: %v", model) + } + } +} + +func TestHandleModelsNormalKeyIgnoresAggregationCallback(t *testing.T) { + called := false + h := &Handler{ + Models: func(bool, string) ([]map[string]any, error) { + return []map[string]any{{"id": "deepseek-v4.1-flash", "object": "model", "provider": "trae"}}, nil + }, + AggregationKeyModels: func(_ context.Context, _ *http.Request, models []map[string]any) []map[string]any { + called = true + return []map[string]any{{"id": "deepseek-v4.1-flash", "object": "model", "owned_by": "aggregation"}} + }, + } + req := httptest.NewRequest(http.MethodGet, "/v1/models", nil) + req = req.WithContext(auth.WithIdentity(req.Context(), auth.Identity{Kind: auth.KindKey})) + rec := httptest.NewRecorder() + h.HandleModels(rec, req) + var body struct { + Data []map[string]any `json:"data"` + } + if err := json.Unmarshal(rec.Body.Bytes(), &body); err != nil { + t.Fatal(err) + } + if called { + t.Fatal("normal key must not enter the aggregation namespace") + } + if len(body.Data) != 1 || body.Data[0]["provider"] != "trae" { + t.Fatalf("data=%v", body.Data) + } +} + +func TestHandleModelsAggregationKeyWithoutCallbackKeepsPrefixOff(t *testing.T) { + h := &Handler{ + Models: func(bool, string) ([]map[string]any, error) { + return []map[string]any{{"id": "kimi-k2.6", "object": "model", "provider": "qoder"}}, nil + }, + } + req := httptest.NewRequest(http.MethodGet, "/v1/models", nil) + req = req.WithContext(auth.WithIdentity(req.Context(), auth.Identity{Kind: auth.KindKey, ModelAggregation: true})) + rec := httptest.NewRecorder() + h.HandleModels(rec, req) + var body struct { + Data []map[string]any `json:"data"` + } + if err := json.Unmarshal(rec.Body.Bytes(), &body); err != nil { + t.Fatal(err) + } + if len(body.Data) != 1 || body.Data[0]["id"] != "kimi-k2.6" { + t.Fatalf("data=%v", body.Data) + } +} diff --git a/internal/gateway/openai_stream.go b/internal/gateway/openai_stream.go index babb7e69..8071cc2f 100644 --- a/internal/gateway/openai_stream.go +++ b/internal/gateway/openai_stream.go @@ -5,6 +5,7 @@ import ( "encoding/json" "errors" "io" + "log" "net/http" "strings" "time" @@ -89,6 +90,32 @@ func RelayOpenAIStream(w http.ResponseWriter, body io.Reader) (stats StreamRelay sawDone := false var frame []string var streamErr error + normalizer := newOpenAIToolNormalizer() + argsFlushed := false + + flushToolArguments := func() error { + if argsFlushed { + return nil + } + argsFlushed = true + frames := normalizer.flushFrames() + if len(frames) == 0 { + return nil + } + if normalizer.changed { + log.Printf("tool call arguments normalized stream=chat_completion calls=%d finish_reason=%q", len(frames), normalizer.finish) + } + for _, payload := range frames { + encoded, err := json.Marshal(payload) + if err != nil { + continue + } + if _, err := io.WriteString(writer, "data: "+string(encoded)+"\n\n"); err != nil { + return &StreamRelayWriteError{err: err} + } + } + return nil + } flushFrame := func() error { if len(frame) == 0 { @@ -107,12 +134,54 @@ func RelayOpenAIStream(w http.ResponseWriter, body io.Reader) (stats StreamRelay frame = nil return nil } - for _, line := range frame { - line = strings.TrimSuffix(line, "\r") - if stats.FirstTokenAt == nil && SSEDeltaHasToken(line) { - now := time.Now() - stats.FirstTokenAt = &now + // Each data line is handled on its own: upstreams differ on whether they + // put one JSON payload per line, and a frame may bundle content, usage and + // [DONE] together. Tool-call fragments are absorbed and withheld here so + // a damaged buffer never reaches the client as fragments. + lines := make([]string, 0, len(frame)) + for _, rawLine := range frame { + line := strings.TrimSuffix(rawLine, "\r") + if strings.TrimSpace(line) == "" { + continue + } + if !strings.HasPrefix(line, "data:") { + lines = append(lines, line) + continue + } + payload := strings.TrimSpace(strings.TrimPrefix(line, "data:")) + if payload == "[DONE]" { + if err := flushToolArguments(); err != nil { + return err + } + sawDone = true + stats.SawDone = true + lines = append(lines, line) + continue + } + if payload != "" { + var decoded map[string]any + if json.Unmarshal([]byte(payload), &decoded) == nil { + if _, ok := decoded["choices"]; ok { + if stats.FirstTokenAt == nil && SSEDeltaHasToken(line) { + now := time.Now() + stats.FirstTokenAt = &now + } + if relayed := normalizer.absorb(decoded); relayed == nil { + continue + } else if encoded, err := json.Marshal(relayed); err == nil { + line = "data: " + string(encoded) + } + if normalizer.finish != "" { + if err := flushToolArguments(); err != nil { + return err + } + } + } + } } + lines = append(lines, line) + } + for _, line := range lines { if fr := SSEDeltaFinishReason(line); fr != "" { stats.FinishReason = fr } @@ -125,17 +194,10 @@ func RelayOpenAIStream(w http.ResponseWriter, body io.Reader) (stats StreamRelay usage.FinishReason = stats.FinishReason stats = usage } - if strings.TrimSpace(strings.TrimPrefix(line, "data:")) == "[DONE]" { - sawDone = true - } } - output := strings.Join(frame, "\n") + "\n\n" - if _, err := io.WriteString(writer, output); err != nil { + if _, err := io.WriteString(writer, strings.Join(lines, "\n")+"\n\n"); err != nil { return &StreamRelayWriteError{err: err} } - if sawDone { - stats.SawDone = true - } frame = nil return nil } @@ -170,6 +232,9 @@ func RelayOpenAIStream(w http.ResponseWriter, body io.Reader) (stats StreamRelay if stats.FinishReason != "" && (stats.FirstTokenAt != nil || stats.SSEEventCount > 0) { sawDone = true stats.SawDone = true + if err := flushToolArguments(); err != nil { + return stats, err + } if _, err := io.WriteString(writer, "data: [DONE]\n\n"); err != nil { return stats, &StreamRelayWriteError{err: err} } diff --git a/internal/gateway/openai_tool_normalizer.go b/internal/gateway/openai_tool_normalizer.go new file mode 100644 index 00000000..ec3ce400 --- /dev/null +++ b/internal/gateway/openai_tool_normalizer.go @@ -0,0 +1,221 @@ +package gateway + +import ( + "encoding/json" + "sort" + "strconv" + + "github.com/caigee-cmd/cli2api/internal/translate" +) + +// openAIToolNormalizer keeps an OpenAI chat-completions stream faithful frame +// by frame except for tool-call arguments. Arguments are accumulated and +// flushed once per call, normalized to valid JSON, because a client that +// concatenates damaged upstream fragments aborts the round with "arguments are +// invalid JSON". Content, reasoning, usage and finish frames relay unchanged. +type openAIToolNormalizer struct { + calls map[int]*proxyToolCall + emitted map[int]bool + changed bool + finish string + meta map[string]any +} + +func newOpenAIToolNormalizer() *openAIToolNormalizer { + return &openAIToolNormalizer{ + calls: map[int]*proxyToolCall{}, + emitted: map[int]bool{}, + } +} + +// absorb consumes one chunk payload and returns the payload that should still +// be relayed, or nil when the chunk carried nothing but tool-call fragments. +func (n *openAIToolNormalizer) absorb(payload map[string]any) map[string]any { + choices, ok := payload["choices"].([]any) + if !ok || len(choices) == 0 { + return payload + } + for _, key := range []string{"id", "object", "created", "model", "system_fingerprint"} { + if value, ok := payload[key]; ok && value != nil { + if n.meta == nil { + n.meta = map[string]any{} + } + n.meta[key] = value + } + } + dropped := false + for _, rawChoice := range choices { + choice, ok := rawChoice.(map[string]any) + if !ok { + continue + } + if finish, ok := choice["finish_reason"].(string); ok && finish != "" { + n.finish = finish + } + delta, ok := choice["delta"].(map[string]any) + if !ok { + continue + } + rawCalls, hasCalls := delta["tool_calls"].([]any) + if !hasCalls || len(rawCalls) == 0 { + continue + } + n.absorbCalls(rawCalls) + delete(delta, "tool_calls") + if len(delta) == 0 && choice["finish_reason"] == nil { + dropped = true + } + } + if dropped { + return nil + } + return payload +} + +func (n *openAIToolNormalizer) absorbCalls(rawCalls []any) { + for position, rawCall := range rawCalls { + call, ok := rawCall.(map[string]any) + if !ok { + continue + } + id, _ := call["id"].(string) + function, _ := call["function"].(map[string]any) + name, _ := function["name"].(string) + arguments := argumentFragment(rawArguments(function["arguments"])) + index := n.resolveIndex(call, id, name, position) + entry := n.calls[index] + if entry == nil { + entry = &proxyToolCall{} + n.calls[index] = entry + } + if id != "" { + entry.ID = id + } + if name != "" { + entry.Name = name + } + merged := mergeToolArguments(entry.Arguments, arguments) + if merged != entry.Arguments { + entry.Arguments = merged + } + } +} + +func (n *openAIToolNormalizer) resolveIndex(call map[string]any, id, name string, position int) int { + declared := -1 + if value, ok := call["index"].(float64); ok { + declared = int(value) + } + startsCall := id != "" || name != "" + if declared >= 0 && !startsCall { + return declared + } + if declared >= 0 { + if n.callIsDifferent(declared, id, name) { + return n.nextIndex() + } + return declared + } + if startsCall { + if n.callIsDifferent(0, id, name) { + return n.nextIndex() + } + return 0 + } + return n.lastIndex(position) +} + +func (n *openAIToolNormalizer) callIsDifferent(index int, id, name string) bool { + existing := n.calls[index] + if existing == nil || (existing.Name == "" && existing.ID == "") { + return false + } + if id != "" && existing.ID != "" { + return existing.ID != id + } + return name != "" && existing.Name != "" && existing.Name != name +} + +func (n *openAIToolNormalizer) nextIndex() int { + maximum := -1 + for index := range n.calls { + if index > maximum { + maximum = index + } + } + return maximum + 1 +} + +func (n *openAIToolNormalizer) lastIndex(position int) int { + maximum := -1 + for index, call := range n.calls { + if call != nil && call.Name != "" && index > maximum { + maximum = index + } + } + if maximum >= 0 { + return maximum + } + return position +} + +// flushFrames returns one frame per call that has not been delivered yet, each +// carrying the normalized full argument string. +func (n *openAIToolNormalizer) flushFrames() []map[string]any { + indexes := make([]int, 0, len(n.calls)) + for index, call := range n.calls { + if call == nil || call.Name == "" || n.emitted[index] { + continue + } + indexes = append(indexes, index) + } + sort.Ints(indexes) + frames := make([]map[string]any, 0, len(indexes)) + for _, index := range indexes { + call := n.calls[index] + arguments, changed := translate.NormalizeToolCallArguments(call.Arguments) + if changed { + n.changed = true + } + if call.ID == "" { + call.ID = "call_" + call.Name + "_" + strconv.Itoa(index) + } + frames = append(frames, n.frame(map[string]any{ + "index": index, + "id": call.ID, + "type": "function", + "function": map[string]any{ + "name": call.Name, + "arguments": arguments, + }, + })) + n.emitted[index] = true + } + return frames +} + +func (n *openAIToolNormalizer) frame(call map[string]any) map[string]any { + payload := map[string]any{ + "object": "chat.completion.chunk", + "choices": []any{map[string]any{ + "index": 0, + "delta": map[string]any{"tool_calls": []any{call}}, + "finish_reason": nil, + }}, + } + for key, value := range n.meta { + payload[key] = value + } + return payload +} + +func rawArguments(value any) json.RawMessage { + if value == nil { + return nil + } + encoded, err := json.Marshal(value) + if err != nil { + return nil + } + return encoded +} diff --git a/internal/gateway/responses_test.go b/internal/gateway/responses_test.go index 11a88f76..2fe8a8d3 100644 --- a/internal/gateway/responses_test.go +++ b/internal/gateway/responses_test.go @@ -208,25 +208,31 @@ func TestParseStreamUsageLineCacheReadFallback(t *testing.T) { } } -func TestDecodeOpenAIToolCallsDropsInvalidArguments(t *testing.T) { +func TestDecodeOpenAIToolCallsNormalizesInvalidArguments(t *testing.T) { calls := decodeOpenAIToolCalls(json.RawMessage(`[ {"id":"call_bad","function":{"name":"mcp__fastctx__read","arguments":"{\"path\":\"x\",\"error_retry:: 240}"}}, {"id":"call_good","function":{"name":"mcp__fastctx__grep","arguments":"{\"pattern\":\"x\"}"}} ]`)) - if len(calls) != 1 || calls[0].ID != "call_good" { + if len(calls) != 2 { t.Fatalf("calls=%#v", calls) } + if calls[0].ID != "call_bad" || calls[0].Arguments != `{"path":"x"}` { + t.Fatalf("bad call was not normalized: %#v", calls[0]) + } + if calls[1].Arguments != `{"pattern":"x"}` { + t.Fatalf("good call changed: %#v", calls[1]) + } } -func TestRelayResponsesStreamRejectsInvalidToolArgumentsBeforeFinalize(t *testing.T) { +func TestRelayResponsesStreamNormalizesInvalidToolArguments(t *testing.T) { upstream := strings.NewReader( `data: {"choices":[{"delta":{"tool_calls":[{"index":0,"id":"call_bad","function":{"name":"mcp__fastctx__read","arguments":"{\"path\":\"x\",\"error_retry:: 240}"}}]}}]}` + "\n\n" + `data: {"choices":[{"finish_reason":"tool_calls"}]}` + "\n\n" + "data: [DONE]\n\n", ) var output strings.Builder - _, err := RelayResponsesStream(&output, upstream, "req", "model", nil) - if err == nil || !strings.Contains(err.Error(), "arguments are invalid JSON") { + stats, err := RelayResponsesStream(&output, upstream, "req", "model", nil) + if err != nil { t.Fatalf("error=%v", err) } body := output.String() @@ -235,8 +241,14 @@ func TestRelayResponsesStreamRejectsInvalidToolArgumentsBeforeFinalize(t *testin "event: response.output_item.done", "event: response.completed", } { - if strings.Contains(body, event) { - t.Fatalf("invalid tool call was finalized with %q:\n%s", event, body) + if !strings.Contains(body, event) { + t.Fatalf("missing %q in:\n%s", event, body) } } + if strings.Contains(body, "error_retry") { + t.Fatalf("garbage arguments leaked into the stream:\n%s", body) + } + if stats.FinishReason != "tool_calls" { + t.Fatalf("finish reason=%q", stats.FinishReason) + } } diff --git a/internal/gateway/toolargs_stream_test.go b/internal/gateway/toolargs_stream_test.go new file mode 100644 index 00000000..c442004c --- /dev/null +++ b/internal/gateway/toolargs_stream_test.go @@ -0,0 +1,195 @@ +package gateway + +import ( + "encoding/json" + "net/http/httptest" + "strings" + "testing" +) + +func feedChunks(t *testing.T, chunks ...string) *streamedChatOutput { + t.Helper() + output := &streamedChatOutput{} + for _, chunk := range chunks { + output.add([]byte(chunk)) + } + return output +} + +func TestStreamAccumulatesSplitArguments(t *testing.T) { + output := feedChunks(t, + `{"choices":[{"delta":{"tool_calls":[{"index":0,"id":"call_1","function":{"name":"read_file","arguments":""}}]}}]}`, + `{"choices":[{"delta":{"tool_calls":[{"index":0,"function":{"arguments":"{\"path\":"}}]}}]}`, + `{"choices":[{"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\"a.go\"}"}}]},"finish_reason":"tool_calls"}]}`, + ) + calls := output.calls() + if len(calls) != 1 { + t.Fatalf("calls = %d, want 1: %+v", len(calls), calls) + } + if calls[0].Arguments != `{"path":"a.go"}` { + t.Fatalf("arguments = %q", calls[0].Arguments) + } +} + +// Some upstreams resend the whole argument buffer on every chunk. Concatenating +// those blindly yields `{"a":1}{"a":1}`, which clients reject as invalid JSON. +func TestStreamHandlesCumulativeArguments(t *testing.T) { + output := feedChunks(t, + `{"choices":[{"delta":{"tool_calls":[{"index":0,"id":"call_1","function":{"name":"write_file","arguments":"{\"path\":"}}]}}]}`, + `{"choices":[{"delta":{"tool_calls":[{"index":0,"function":{"arguments":"{\"path\":\"a.go\""}}]}}]}`, + `{"choices":[{"delta":{"tool_calls":[{"index":0,"function":{"arguments":"{\"path\":\"a.go\",\"body\":\"x\"}"}}]},"finish_reason":"tool_calls"}]}`, + ) + calls := output.calls() + if len(calls) != 1 { + t.Fatalf("calls = %d, want 1: %+v", len(calls), calls) + } + if calls[0].Arguments != `{"path":"a.go","body":"x"}` { + t.Fatalf("arguments = %q", calls[0].Arguments) + } + if normalizeProxyToolCallArguments(calls) { + t.Fatal("valid arguments should not be reported as changed") + } +} + +// An upstream that omits `index` on continuation deltas must not lose the +// fragments into a phantom second call. +func TestStreamWithoutIndexKeepsOneCall(t *testing.T) { + output := feedChunks(t, + `{"choices":[{"delta":{"tool_calls":[{"id":"call_1","function":{"name":"grep","arguments":"{\"q\":"}}]}}]}`, + `{"choices":[{"delta":{"tool_calls":[{"function":{"arguments":"\"x\"}"}}]}}]}`, + ) + calls := output.calls() + if len(calls) != 1 || calls[0].Arguments != `{"q":"x"}` { + t.Fatalf("calls = %+v", calls) + } +} + +// Two calls that both report index 0 must stay separate calls. +func TestStreamZeroIndexPerCallStaysSeparate(t *testing.T) { + output := feedChunks(t, + `{"choices":[{"delta":{"tool_calls":[{"index":0,"id":"call_1","function":{"name":"a","arguments":"{\"x\":1}"}}]}}]}`, + `{"choices":[{"delta":{"tool_calls":[{"index":0,"id":"call_2","function":{"name":"b","arguments":"{\"y\":2}"}}]},"finish_reason":"tool_calls"}]}`, + ) + calls := output.calls() + if len(calls) != 2 { + t.Fatalf("calls = %+v", calls) + } + if calls[0].Name != "a" || calls[0].Arguments != `{"x":1}` { + t.Fatalf("first call = %+v", calls[0]) + } + if calls[1].Name != "b" || calls[1].Arguments != `{"y":2}` { + t.Fatalf("second call = %+v", calls[1]) + } +} + +// Some upstreams send a JSON object where the OpenAI schema expects a +// string. Decoding strictly as string dropped the whole chunk. +func TestStreamAcceptsObjectArguments(t *testing.T) { + output := feedChunks(t, + `{"choices":[{"delta":{"tool_calls":[{"index":0,"id":"call_1","function":{"name":"read_file","arguments":{"path":"a.go"}}}]}}]}`, + ) + calls := output.calls() + if len(calls) != 1 || calls[0].Arguments != `{"path":"a.go"}` { + t.Fatalf("calls = %+v", calls) + } +} + +// Two calls of the same tool, each announcing index 0 with its own call id, +// must not be merged into one argument buffer. +func TestStreamSameToolTwiceStaysSeparate(t *testing.T) { + output := feedChunks(t, + `{"choices":[{"delta":{"tool_calls":[{"index":0,"id":"call_1","function":{"name":"read_file","arguments":"{\"path\":\"a\"}"}}]}}]}`, + `{"choices":[{"delta":{"tool_calls":[{"index":0,"id":"call_2","function":{"name":"read_file","arguments":"{\"path\":\"b\"}"}}]},"finish_reason":"tool_calls"}]}`, + ) + calls := output.calls() + if len(calls) != 2 { + t.Fatalf("calls = %+v", calls) + } + if calls[0].Arguments != `{"path":"a"}` || calls[1].Arguments != `{"path":"b"}` { + t.Fatalf("calls = %+v", calls) + } +} + +func TestRelayOpenAIStreamNormalizesFragmentedToolArguments(t *testing.T) { + body := strings.Join([]string{ + `data: {"id":"c1","model":"m","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"id":"call_1","type":"function","function":{"name":"write_file","arguments":"{\"path\":"}}]}}]}`, + "", + `data: {"id":"c1","model":"m","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\"a.go\","}}]}}]}`, + "", + `data: {"id":"c1","model":"m","choices":[{"index":0,"delta":{"tool_calls":[{"index":0,"function":{"arguments":"\"body\":\"par"}}]}}]}`, + "", + `data: {"id":"c1","model":"m","choices":[{"index":0,"delta":{},"finish_reason":"tool_calls"}]}`, + "", + "data: [DONE]", + "", + }, "\n") + recorder := httptest.NewRecorder() + stats, err := RelayOpenAIStream(recorder, strings.NewReader(body)) + if err != nil { + t.Fatal(err) + } + if !stats.SawDone { + t.Fatalf("stats=%+v", stats) + } + var arguments []string + for _, line := range strings.Split(recorder.Body.String(), "\n") { + payload := strings.TrimSpace(strings.TrimPrefix(line, "data:")) + if payload == "" || payload == "[DONE]" { + continue + } + var chunk struct { + Choices []struct { + Delta struct { + ToolCalls []struct { + Function struct { + Arguments string `json:"arguments"` + } `json:"function"` + } `json:"tool_calls"` + } `json:"delta"` + } `json:"choices"` + } + if json.Unmarshal([]byte(payload), &chunk) != nil { + continue + } + for _, choice := range chunk.Choices { + for _, call := range choice.Delta.ToolCalls { + arguments = append(arguments, call.Function.Arguments) + } + } + } + if len(arguments) != 1 { + t.Fatalf("expected exactly one arguments frame, got %d: %#v", len(arguments), arguments) + } + // The body field was cut mid-string, so it is dropped rather than padded + // into a plausible-looking value; everything the model finished survives. + if arguments[0] != `{"path":"a.go"}` { + t.Fatalf("arguments = %q", arguments[0]) + } + if !json.Valid([]byte(arguments[0])) { + t.Fatalf("arguments not valid JSON: %q", arguments[0]) + } +} + +func TestNormalizeRepairsFormattingDamage(t *testing.T) { + calls := []proxyToolCall{{ID: "call_1", Name: "write_file", Arguments: `{"path":"a.go",`}} + if !normalizeProxyToolCallArguments(calls) { + t.Fatal("expected repair to be reported") + } + if !json.Valid([]byte(calls[0].Arguments)) { + t.Fatalf("arguments not valid after normalize: %q", calls[0].Arguments) + } +} + +func TestNormalizeTruncatedArgumentsNeverFails(t *testing.T) { + calls := []proxyToolCall{{ID: "call_1", Name: "run_command", Arguments: `{"cmd":"rm -rf /tmp/fo`}} + if !normalizeProxyToolCallArguments(calls) { + t.Fatal("expected normalize to change truncated arguments") + } + if !json.Valid([]byte(calls[0].Arguments)) { + t.Fatalf("arguments still invalid: %q", calls[0].Arguments) + } + // The unfinished command must not survive as a runnable string. + if strings.Contains(calls[0].Arguments, "rm -rf") { + t.Fatalf("truncated command leaked into arguments: %q", calls[0].Arguments) + } +} diff --git a/internal/providers/checkin.go b/internal/providers/checkin.go index 6bf7b261..31e14554 100644 --- a/internal/providers/checkin.go +++ b/internal/providers/checkin.go @@ -15,11 +15,11 @@ import ( const CheckinSureHour = 2 // CheckinClaimSettledHour is the first hour from which a claim endpoint's -// "already claimed" answer is trusted. The automatic schedule runs at 01:00 -// (earliest window + 1h); a vendor that has not rolled its day yet can still -// answer with yesterday's "already" at that hour. Treat that answer as -// unconfirmed for one more hour and let the retry pick it up, rather than -// recording a false success and skipping the whole day. +// "already claimed" answer is trusted. The automatic schedule runs at the +// operator-configured hour (09:00 by default); a vendor that has not rolled its +// day yet can still answer with yesterday's "already" at that hour. Treat that +// answer as unconfirmed for one more hour and let the retry pick it up, rather +// than recording a false success and skipping the whole day. const CheckinClaimSettledHour = 2 var checkinCalendarZone = time.FixedZone("UTC+8", 8*3600) @@ -55,7 +55,8 @@ type CheckinResult struct { RewardCredits float64 `json:"reward_credits,omitempty"` Streak int `json:"streak,omitempty"` // EarliestCheckin is the upstream daily window start as HH:MM in the - // provider's configured timezone. Empty means the provider did not expose it. + // provider's configured timezone. It is reported for diagnostics only: the + // automatic schedule follows the operator's provider check-in time setting. EarliestCheckin string `json:"earliest_checkin,omitempty"` } diff --git a/internal/providers/codearts/constants.go b/internal/providers/codearts/constants.go index d32c6ae6..364d67db 100644 --- a/internal/providers/codearts/constants.go +++ b/internal/providers/codearts/constants.go @@ -47,9 +47,17 @@ const ( ) // Client identity reported to the OAuth portal and gateway. +// +// Both shipped clients - the CodeArts Agent IDE (product "CodeArts Agent" +// 26.11.200 today) and the VS Code extension (HuaweiCloud.vscode-codebot +// 26.11.300, 2026-11-25) - run the same snap extension and build the login +// query as `plugin-name=${brand}_vscode` with `plugin-version` set to the raw +// extension version (the `Vscode_` prefix is only used when a caller asks for +// the prefixed form, which the login path does not). The old `snap_AIIDE` / +// `5.2.0` pair does not appear anywhere in either package. const ( - PluginName = "snap_AIIDE" - PluginVersion = "5.2.0" + PluginName = "snap_vscode" + PluginVersion = "26.11.300" OAuthRedirect = "/oauth/callback" Language = "zh-cn" AppID = "CodeAgent3.0" diff --git a/internal/providers/command/constants.go b/internal/providers/command/constants.go index 1dfb08dd..3e7bc17a 100644 --- a/internal/providers/command/constants.go +++ b/internal/providers/command/constants.go @@ -34,9 +34,10 @@ const ( KeyPrefix = "user_" // PinnedCLIVersion is sent as x-command-code-version on /alpha/generate. - // Verified against the published `command-code` npm package. Override at - // runtime with CMD_CLI_VERSION when the gateway moves ahead of this build. - PinnedCLIVersion = "1.65.0" + // Verified against the published `command-code` npm package (1.93.3 as of + // 2026-11-25). Override at runtime with CMD_CLI_VERSION when the gateway + // moves ahead of this build. + PinnedCLIVersion = "1.93.3" // CLIEnvironment is the x-cli-environment header value. CLIEnvironment = "production" diff --git a/internal/providers/devin/constants.go b/internal/providers/devin/constants.go index 65b47049..55a97b37 100644 --- a/internal/providers/devin/constants.go +++ b/internal/providers/devin/constants.go @@ -18,7 +18,9 @@ const ( ClientProductLabel = "devin-cli" ClientName = "chisel" - ClientVersion = "3000.10.21" + // ClientVersion tracks the stable Devin CLI release (v3000.14.30821, + // 2026-11-17 per docs.devin.ai/cli/changelog/stable). + ClientVersion = "3000.14.30821" FingerprintHexLen = 732 DefaultMaxTokens = 128000 diff --git a/internal/providers/doubaowork/session.go b/internal/providers/doubaowork/session.go index 64b849c8..873eab95 100644 --- a/internal/providers/doubaowork/session.go +++ b/internal/providers/doubaowork/session.go @@ -16,7 +16,10 @@ import ( // desktopParams are the query parameters that make a request look like the // Doubao Work web client. aid must be 497858 (the web/desktop chat app); the -// other product line returns no office model menu. +// other product line returns no office model menu. version_code 20800 is the +// value the official doubao.com page still uses today (register banner, +// 2026-11-25); the Doubao desktop app has its own build code (2.32.6 -> 23206) +// and is a different client. var desktopParams = map[string]string{ "aid": "497858", "real_aid": "497858", @@ -153,7 +156,9 @@ func (s *session) initialize(ctx context.Context) error { identity, err := s.json(ctx, http.MethodGet, "/passport/account/info/v2/", nil, map[string]string{ "account_sdk_source": "web", - "sdk_version": "2.2.5", + // 2.2.10 is the account SDK version the official doubao.com download / + // web page requests today (seen in its register banner, 2026-11-25). + "sdk_version": "2.2.10", }) if err != nil { return err diff --git a/internal/providers/httptimeout.go b/internal/providers/httptimeout.go new file mode 100644 index 00000000..5478d0e4 --- /dev/null +++ b/internal/providers/httptimeout.go @@ -0,0 +1,87 @@ +// Shared streaming head timeout: an upstream that accepts the request and then +// sends nothing is a hang, not a rejection. Every adapter that streams should +// fail the attempt over with ErrFirstByteTimeout instead of letting the relay +// wait until the client gives up. +package providers + +import ( + "context" + "errors" + "fmt" + "io" + "net/http" + "os" + "strconv" + "strings" + "time" +) + +// DefaultStreamHeadTimeout is the shared ceiling before a silent upstream is +// treated as a hang. +const DefaultStreamHeadTimeout = 60 * time.Second + +// HeadTimeoutFromEnv resolves a per-provider knob (milliseconds). Unset or +// invalid values fall back to the default; anything under five seconds clamps up +// so normal upstream latency is never mistaken for a hang. +func HeadTimeoutFromEnv(env string, def time.Duration) time.Duration { + if def <= 0 { + def = DefaultStreamHeadTimeout + } + raw := strings.TrimSpace(os.Getenv(env)) + if raw == "" { + return def + } + ms, err := strconv.Atoi(raw) + if err != nil || ms <= 0 { + return def + } + d := time.Duration(ms) * time.Millisecond + if d < 5*time.Second { + return 5 * time.Second + } + return d +} + +// DoWithHeadTimeout sends req and returns once the response head arrives. +// +// A timeout wraps ErrFirstByteTimeout so the executor can fail the attempt over +// to another account. The deadline context must not be cancelled after a +// successful head — Go ties the body to the request context, so cancelling would +// truncate a stream that already started. Only the error path cancels; on +// success the timer stops and the derived context is released when the body is +// closed. +func DoWithHeadTimeout(client *http.Client, req *http.Request, timeout time.Duration) (*http.Response, error) { + if timeout <= 0 { + timeout = DefaultStreamHeadTimeout + } + parent := req.Context() + headCtx, cancelHead := context.WithCancel(parent) + timer := time.AfterFunc(timeout, cancelHead) + resp, err := client.Do(req.WithContext(headCtx)) + if err == nil { + timer.Stop() + resp.Body = &cancelOnCloseBody{ReadCloser: resp.Body, cancel: cancelHead} + return resp, nil + } + timer.Stop() + // Decide the cause before cancelHead, which would otherwise make + // headCtx.Err() non-nil regardless of what actually happened. A parent cancel + // stays a plain cancel so a client disconnect is not cooled down. + timedOut := parent.Err() == nil && headCtx.Err() != nil && !errors.Is(parent.Err(), context.Canceled) + cancelHead() + if timedOut { + return nil, fmt.Errorf("%w: no response head within %s", ErrFirstByteTimeout, timeout) + } + return nil, err +} + +type cancelOnCloseBody struct { + io.ReadCloser + cancel context.CancelFunc +} + +func (b *cancelOnCloseBody) Close() error { + err := b.ReadCloser.Close() + b.cancel() + return err +} diff --git a/internal/providers/httptimeout_test.go b/internal/providers/httptimeout_test.go new file mode 100644 index 00000000..7c4bc866 --- /dev/null +++ b/internal/providers/httptimeout_test.go @@ -0,0 +1,74 @@ +package providers + +import ( + "errors" + "net/http" + "net/http/httptest" + "strings" + "testing" + "time" +) + +func TestDoWithHeadTimeoutFailsWhenUpstreamStaysSilent(t *testing.T) { + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + select { + case <-r.Context().Done(): + case <-time.After(2 * time.Second): + } + })) + defer server.Close() + + req, err := http.NewRequest(http.MethodPost, server.URL, strings.NewReader("{}")) + if err != nil { + t.Fatal(err) + } + start := time.Now() + _, err = DoWithHeadTimeout(server.Client(), req, 50*time.Millisecond) + if err == nil { + t.Fatal("want a timeout error") + } + if !errors.Is(err, ErrFirstByteTimeout) { + t.Fatalf("err = %v, want ErrFirstByteTimeout", err) + } + if elapsed := time.Since(start); elapsed > time.Second { + t.Fatalf("head timeout took %s, want a fast fail", elapsed) + } +} + +func TestDoWithHeadTimeoutKeepsBodyReadable(t *testing.T) { + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(http.StatusOK) + _, _ = w.Write([]byte("data: ok\n\n")) + })) + defer server.Close() + + req, err := http.NewRequest(http.MethodPost, server.URL, strings.NewReader("{}")) + if err != nil { + t.Fatal(err) + } + resp, err := DoWithHeadTimeout(server.Client(), req, 100*time.Millisecond) + if err != nil { + t.Fatalf("successful head must not fail: %v", err) + } + defer resp.Body.Close() + // The derived deadline must not cut the body after the head arrives. + time.Sleep(150 * time.Millisecond) + if _, err := resp.Body.Read(make([]byte, 16)); err != nil && !strings.Contains(err.Error(), "EOF") { + t.Fatalf("body read after head: %v", err) + } +} + +func TestHeadTimeoutFromEnvClampsAndDefaults(t *testing.T) { + t.Setenv("TEST_TTFB_MS", "") + if got := HeadTimeoutFromEnv("TEST_TTFB_MS", 0); got != DefaultStreamHeadTimeout { + t.Fatalf("default = %s", got) + } + t.Setenv("TEST_TTFB_MS", "1200") + if got := HeadTimeoutFromEnv("TEST_TTFB_MS", 0); got != 5*time.Second { + t.Fatalf("sub-5s value must clamp up, got %s", got) + } + t.Setenv("TEST_TTFB_MS", "15000") + if got := HeadTimeoutFromEnv("TEST_TTFB_MS", 0); got != 15*time.Second { + t.Fatalf("explicit value = %s", got) + } +} diff --git a/internal/providers/kimi/constants.go b/internal/providers/kimi/constants.go index 43a59e70..0cd1b77c 100644 --- a/internal/providers/kimi/constants.go +++ b/internal/providers/kimi/constants.go @@ -36,7 +36,7 @@ const ( // from the official CLI on the wire. const ( Platform = "kimi_code_cli" - ClientVersion = "1.1.2" + ClientVersion = "2.7.3" UserAgent = "kimi-code-cli/" + ClientVersion ) diff --git a/internal/providers/kimi/flows_test.go b/internal/providers/kimi/flows_test.go index bc08f4b9..0b3a41f9 100644 --- a/internal/providers/kimi/flows_test.go +++ b/internal/providers/kimi/flows_test.go @@ -835,7 +835,7 @@ func TestReasoningPriority(t *testing.T) { {"catalog default when nothing is saved", "", "", "high"}, {"saved console default beats the catalog default", "low", "", "low"}, {"client value beats the saved default", "low", "high", "high"}, - {"saved default is clamped to the declared ladder", "medium", "", "high"}, + {"saved default is clamped to the declared ladder", "medium", "", "low"}, {"client value is clamped to the declared ladder", "", "xhigh", "high"}, } for _, tc := range cases { diff --git a/internal/providers/kiro/constants.go b/internal/providers/kiro/constants.go index 84982445..0f61a72d 100644 --- a/internal/providers/kiro/constants.go +++ b/internal/providers/kiro/constants.go @@ -15,10 +15,15 @@ const ( // IDEVersion is the fallback advertised until the stable update feed answers. // Kiro's version gate rejects older builds with FEATURE_NOT_SUPPORTED, so the - // fallback stays near the current stable release. A fetched build older than - // this is ignored. - IDEVersion = "1.4.236" - AgentVersion = "0.66.102-hotfix.1" + // fallback stays at the current stable release (1.5.37, published 2026-11-24 + // on prod.download.desktop.kiro.dev/stable). A fetched build older than this + // is ignored. + // AgentVersion is the bundled Kiro agent server (KAS) release. The package + // ships @kiro/agent 0.66.123 inside IDE 1.5.37 (kiro.kiro-agent 1.1.1168, + // product.json commit 03cd03a, 2026-11-24), which is what the IDE appends + // as `KAS/` to its user agent. + IDEVersion = "1.5.37" + AgentVersion = "0.66.123" // nodeVersion is the Node runtime the IDE names in the AWS SDK user agent. nodeVersion = "22.22.0" diff --git a/internal/providers/kiro/fingerprint_test.go b/internal/providers/kiro/fingerprint_test.go index 99644168..e28e2635 100644 --- a/internal/providers/kiro/fingerprint_test.go +++ b/internal/providers/kiro/fingerprint_test.go @@ -1,6 +1,7 @@ package kiro import ( + "fmt" "net/http" "strings" "testing" @@ -38,8 +39,13 @@ func TestNewerIDEVersionRejectsStaleFeed(t *testing.T) { if newerIDEVersion(IDEVersion, IDEVersion) { t.Fatal("the fallback was treated as newer than itself") } - if !newerIDEVersion("1.5.0", IDEVersion) { - t.Fatal("a newer build was rejected") + parts, ok := parseIDEVersion(IDEVersion) + if !ok || len(parts) == 0 { + t.Fatalf("fallback %q is not parseable", IDEVersion) + } + next := fmt.Sprintf("%d.0.0", parts[0]+1) + if !newerIDEVersion(next, IDEVersion) { + t.Fatalf("a newer build (%s) was rejected against %s", next, IDEVersion) } if newerIDEVersion("not-a-version", IDEVersion) { t.Fatal("an unparsed feed was treated as newer") diff --git a/internal/providers/meta/constants.go b/internal/providers/meta/constants.go index 677ce49a..46d5a903 100644 --- a/internal/providers/meta/constants.go +++ b/internal/providers/meta/constants.go @@ -1,6 +1,9 @@ package meta -import "time" +import ( + "runtime" + "time" +) // ProviderID is the canonical family id. Alias "muse" resolves to this at // registry Get / NormalizeProviderFamily only; it is not a second family. @@ -15,23 +18,56 @@ const ( // Wire constants aligned with CPA v8.0.40 (internal/auth/meta + meta_executor). const ( - ClientID = "1031625952748946" - AuthHost = "https://auth.meta.com" - ChatBase = "https://api.meta.ai/v1" - MintURL = "https://api.meta.ai/muse-code/key" + ClientID = "1031625952748946" + AuthHost = "https://auth.meta.com" + ChatBase = "https://api.meta.ai/v1" + MintURL = "https://api.meta.ai/muse-code/key" DeviceAuthorizationPath = "/oidc/device/authorization/" TokenPath = "/oidc/device/token/" DeviceGrantType = "urn:ietf:params:oauth:grant-type:device_code" - // AuthUserAgent is sent on device/token/mint (CPA muse-code/1.0.2). + // AuthUserAgent is sent on device/token/mint and has not moved with the + // CLI (CPA and every community client still send muse-code/1.0.2). AuthUserAgent = "muse-code/1.0.2" - // ChatUserAgent and ClientIDHeader match CPA meta_executor fingerprints. - ChatUserAgent = "muse-build/1.3.0 (interactive; macos-aarch64; build ac7280f2aca67769d1455a8847bb502b617d50f6)" - ClientIDHeader = "tbh:tui" - ResponsesPath = "/responses" + // ClientIDHeader marks the caller as a non-interactive Muse Code client. + // `tbh:exec` is what the gateway-shaped clients send (CLIProxyAPI v8.0.63, + // magpie-muse-auth); `tbh:tui` belongs to the interactive terminal. + ClientIDHeader = "tbh:exec" + + ResponsesPath = "/responses" + + // MuseCodeVersion / MuseCodeBuild are the client version and build hash the + // official CLI reported on 2026-11-16 (Muse Code 1.4.14-R7309.1, captured + // by magpie-muse-auth and shipped by CLIProxyAPI v8.0.63). They must move + // together: a new version with an old build hash is an inconsistent + // fingerprint, and Meta can tell. The SDK line is already at 1.4.25 + // (2026-11-21), but no published build hash for it exists yet, so the + // verified pair stays pinned until one does. + MuseCodeVersion = "1.4.14" + MuseCodeBuild = "dec7d7497fecdad135ec5835a8161dbc92e55b58" ) +// ChatUserAgent is the muse-build UA for Responses calls. Platform comes from +// the host, the way CLIProxyAPI builds it from runtime.GOOS/GOARCH. +var ChatUserAgent = museBuildUserAgent() + +func museBuildUserAgent() string { + osName := runtime.GOOS + switch osName { + case "darwin": + osName = "macos" + } + arch := runtime.GOARCH + switch arch { + case "amd64": + arch = "x86_64" + case "arm64": + arch = "aarch64" + } + return "muse-build/" + MuseCodeVersion + " (non-interactive; " + osName + "-" + arch + "; build " + MuseCodeBuild + ")" +} + const ( deviceLoginTimeout = 15 * time.Minute pollFloor = 5 * time.Second diff --git a/internal/providers/minimaxcode/checkin.go b/internal/providers/minimaxcode/checkin.go index 989705c9..792f0bcc 100644 --- a/internal/providers/minimaxcode/checkin.go +++ b/internal/providers/minimaxcode/checkin.go @@ -29,8 +29,10 @@ const ( userInfoPath = "/v1/api/user/info" // Public-gateway attribution fields. The route validates the signature built - // from these fixed values; desktop_version only tags the caller. - gatewayAppVersion = "0.7.2" + // from the exact path+query, so the version fields only tag the caller. + // 0.7.9 is the current MCode TUI release (npm @minimax-ai/code, 2026-11-20); + // the build code is a fixed tag the gateway does not gate on. + gatewayAppVersion = "0.7.9" gatewayVersionCode = "22201" gatewaySignature = "I*7Cf%WZ#S&%1RlZJ&C2" // The daily panel rolls over at 00:00 Asia/Shanghai for both regions, so the diff --git a/internal/providers/qoder/checkin.go b/internal/providers/qoder/checkin.go index a76bc08e..0039ec1f 100644 --- a/internal/providers/qoder/checkin.go +++ b/internal/providers/qoder/checkin.go @@ -141,7 +141,7 @@ func (b *Bridge) checkinDoer(ctx context.Context) (checkinRequester, *string, er } req.Header.Set("User-Agent", "Qoder") req.Header.Set("Cosy-ClientType", "10") - req.Header.Set("Cosy-Version", qauth.DesktopCosyVersion) + req.Header.Set("Cosy-Version", qauth.DesktopCosyVersion(b.Region)) req.Header.Set("Origin", endpoint.origin) req.Header.Set("Referer", endpoint.base+"/growth-page/activity-iframe") resp, err := checkinHTTPClient.Do(req) diff --git a/internal/providers/qoder/checkin_inprocess_test.go b/internal/providers/qoder/checkin_inprocess_test.go index 25dbdf63..1a16b629 100644 --- a/internal/providers/qoder/checkin_inprocess_test.go +++ b/internal/providers/qoder/checkin_inprocess_test.go @@ -203,8 +203,8 @@ func TestBridgeCheckinHappyPath(t *testing.T) { if got := gotHeaders.Get("Cosy-ClientType"); got != "10" { t.Fatalf("Cosy-ClientType = %q want 10", got) } - if got := gotHeaders.Get("Cosy-Version"); got != "0.4.8" { - t.Fatalf("Cosy-Version = %q want 0.4.8", got) + if got := gotHeaders.Get("Cosy-Version"); got != "0.5.18" { + t.Fatalf("Cosy-Version = %q want 0.5.18", got) } if got := gotHeaders.Get("Origin"); got != "https://stub.test" { t.Fatalf("Origin = %q want activity page origin", got) diff --git a/internal/providers/qoder/direct.go b/internal/providers/qoder/direct.go index f5ac340d..11bf8f17 100644 --- a/internal/providers/qoder/direct.go +++ b/internal/providers/qoder/direct.go @@ -155,6 +155,14 @@ func (d *Direct) prepare(ctx context.Context, accountID string, req translate.Ch return directPrepared{}, err } } + // The Qoder prompt builder mirrors content into text/image parts only, so a + // video / audio / file part would be dropped silently. Refuse it with a real + // 400 (same rule the gateway applies) instead of losing the caller's content. + if err := translate.ValidateChatRequest(&req); err != nil { + return directPrepared{}, &providers.Error{ + Kind: "invalid_request", Status: 400, Code: "invalid_request", Type: "invalid_request_error", Message: err.Error(), + } + } plain := BuildPlainChatBody(req, d.now()) // The gateway discounts a repeated prefix only inside one session. A fresh // session_id on every call splits one chat into one-shot sessions, so pin it diff --git a/internal/providers/qoder/qauth/fingerprint.go b/internal/providers/qoder/qauth/fingerprint.go index c02904a0..39f531cd 100644 --- a/internal/providers/qoder/qauth/fingerprint.go +++ b/internal/providers/qoder/qauth/fingerprint.go @@ -18,10 +18,26 @@ import ( // version stays separate because campaign endpoints use their own identity. const CosyVersion = "1.1.96" -// DesktopCosyVersion is the Cosy-Version the official desktop app sends on -// campaign / check-in requests (hub desktop 0.4.8). Distinct from CosyVersion -// (CLI / reasoning). -const DesktopCosyVersion = "0.4.8" +// DesktopCosyVersionCN / DesktopCosyVersionGlobal are the Cosy-Version values +// the official desktop apps send on campaign / check-in requests, per edition. +// They track the published desktop releases rather than the CLI: Qoder CN is +// 0.5.18 (2026-11-24, changelog.qoder.cn/app) and the international app is +// 0.5.3 (2026-11-03, qoder.com/zh/changelog). Distinct from CosyVersion (CLI / +// reasoning). Campaign endpoints only care about the client type and identity; +// the value is attribution, not a gate, so keeping it on the current app +// release is safe. +const ( + DesktopCosyVersionCN = "0.5.18" + DesktopCosyVersionGlobal = "0.5.3" +) + +// DesktopCosyVersion returns the desktop check-in version for an edition. +func DesktopCosyVersion(region *RegionConfig) string { + if region != nil && region.Name == "global" { + return DesktopCosyVersionGlobal + } + return DesktopCosyVersionCN +} // CosyUserAgent is the User-Agent the current official qodercli leaves on // COSY requests. The CLI runs on Bun and lets its bundled fetch supply diff --git a/internal/providers/qoder/qauth/fingerprint_test.go b/internal/providers/qoder/qauth/fingerprint_test.go index a9b2aaa5..bb1450cc 100644 --- a/internal/providers/qoder/qauth/fingerprint_test.go +++ b/internal/providers/qoder/qauth/fingerprint_test.go @@ -26,8 +26,8 @@ func TestUserAgentIsBun(t *testing.T) { if CosyVersion != "1.1.96" { t.Fatalf("CosyVersion=%q want 1.1.96", CosyVersion) } - if DesktopCosyVersion != "0.4.8" { - t.Fatalf("DesktopCosyVersion=%q want 0.4.8", DesktopCosyVersion) + if DesktopCosyVersion(CN) != "0.5.18" || DesktopCosyVersion(Global) != "0.5.3" { + t.Fatalf("DesktopCosyVersion CN=%q global=%q", DesktopCosyVersion(CN), DesktopCosyVersion(Global)) } } diff --git a/internal/providers/reasoning.go b/internal/providers/reasoning.go index 5aa6f964..79ba0cf0 100644 --- a/internal/providers/reasoning.go +++ b/internal/providers/reasoning.go @@ -108,29 +108,70 @@ func ResolveReasoningLevel(level string, caps ModelCapabilities) string { } normalized := NormalizeReasoningLevel(level) if normalized != "" { - for _, option := range caps.ReasoningOptions { - if option == normalized { - return normalized - } + if containsReasoningOption(caps.ReasoningOptions, normalized) { + return normalized } - if chain := reasoningDegradationChain(normalized); chain != nil { - for _, candidate := range chain { + // Declared ladder: a level the model does not advertise degrades to + // the nearest lower level it does advertise (CC Switch behavior), and + // never upgrades. A request below the model's floor (for example "none" + // against low/high/max) lands on the lowest declared level instead of + // the model default, so "do not think hard" never becomes "think hard". + if rank := reasoningRank(normalized); rank >= 0 { + for _, candidate := range reasoningDegradationChain(normalized) { if containsReasoningOption(caps.ReasoningOptions, candidate) { return candidate } } + if lowest := lowestReasoningOption(caps); lowest != "" { + return lowest + } } } if fallback := NormalizeReasoningLevel(caps.ReasoningDefault); fallback != "" { - for _, option := range caps.ReasoningOptions { - if option == fallback { - return fallback - } + if containsReasoningOption(caps.ReasoningOptions, fallback) { + return fallback } } return caps.ReasoningOptions[0] } +// lowestReasoningOption returns the cheapest declared level in the neutral +// vocabulary, so a client asking for less thinking than a model supports still +// gets the minimum instead of the model's default tier. +func lowestReasoningOption(caps ModelCapabilities) string { + lowest := "" + lowestRank := len(reasoningLadder) + for _, option := range caps.ReasoningOptions { + normalized := NormalizeReasoningLevel(option) + if normalized == "" { + continue + } + if rank := reasoningRank(normalized); rank >= 0 && rank < lowestRank { + lowest, lowestRank = normalized, rank + } + } + return lowest +} + +// LowestThinkingOption returns the cheapest declared level that still thinks. +// Adapters use it when a client asks for "none" on a model that cannot turn +// thinking off: the level degrades down to this tier and is never promoted to +// the model default, which could be higher than what the client asked for. +func LowestThinkingOption(caps ModelCapabilities) string { + lowest := "" + lowestRank := len(reasoningLadder) + for _, option := range caps.ReasoningOptions { + normalized := NormalizeReasoningLevel(option) + if normalized == "" || normalized == "none" { + continue + } + if rank := reasoningRank(normalized); rank >= 0 && rank < lowestRank { + lowest, lowestRank = normalized, rank + } + } + return lowest +} + func containsReasoningOption(options []string, level string) bool { for _, option := range options { if NormalizeReasoningLevel(option) == level { @@ -148,16 +189,31 @@ func ReasoningOptionIncludes(options []string, level string) bool { return containsReasoningOption(options, NormalizeReasoningLevel(level)) } -// reasoningDegradationChain returns lower tiers ordered from nearest to -// farthest. Only high tiers need explicit degradation; lower/unknown values -// fall through to the model default in ResolveReasoningLevel. +// reasoningLadder is the neutral effort ladder from cheapest to most expensive. +// CC Switch uses the same tiers when converting effort into thinking budgets +// (2048 / 8192 / 16384 / 24576), so ranking them here keeps one vocabulary. +var reasoningLadder = []string{"none", "low", "medium", "high", "xhigh", "max"} + +func reasoningRank(level string) int { + for i, candidate := range reasoningLadder { + if candidate == level { + return i + } + } + return -1 +} + +// reasoningDegradationChain returns every lower tier ordered from nearest to +// farthest, and nil for an unknown level. Callers pick the first one the model +// actually declares. func reasoningDegradationChain(level string) []string { - switch level { - case "max": - return []string{"xhigh", "high", "medium", "low", "none"} - case "xhigh": - return []string{"high", "medium", "low", "none"} - default: + rank := reasoningRank(level) + if rank <= 0 { return nil } + chain := make([]string, 0, rank) + for i := rank - 1; i >= 0; i-- { + chain = append(chain, reasoningLadder[i]) + } + return chain } diff --git a/internal/providers/reasoning_test.go b/internal/providers/reasoning_test.go index 26f40e99..1818a8c4 100644 --- a/internal/providers/reasoning_test.go +++ b/internal/providers/reasoning_test.go @@ -43,10 +43,10 @@ func TestReasoningLevelFromThinkingBudget(t *testing.T) { } } -func TestResolveReasoningLevelKeepsOlderFallbackForUnknownAndLowerTiers(t *testing.T) { +func TestResolveReasoningLevelDegradesLowerTiersToNearestDeclared(t *testing.T) { caps := ModelCapabilities{ReasoningOptions: []string{"low", "high"}, ReasoningDefault: "high"} - if got := ResolveReasoningLevel("medium", caps); got != "high" { - t.Fatalf("medium clamp=%q, want default high", got) + if got := ResolveReasoningLevel("medium", caps); got != "low" { + t.Fatalf("medium clamp=%q, want low", got) } if got := ResolveReasoningLevel("bogus", caps); got != "high" { t.Fatalf("unknown clamp=%q, want default high", got) @@ -55,3 +55,89 @@ func TestResolveReasoningLevelKeepsOlderFallbackForUnknownAndLowerTiers(t *testi t.Fatalf("empty caps clamp=%q, want empty", got) } } + +func TestResolveReasoningLevelBelowFloorUsesLowestDeclared(t *testing.T) { + // deepseek-v4.1-flash on WorkBuddy advertises low/high/max with high as the + // default. A client that disables thinking satisfies none of those, and the + // answer is the cheapest declared tier — never the default high. + caps := ModelCapabilities{ReasoningOptions: []string{"low", "high", "max"}, ReasoningDefault: "high"} + if got := ResolveReasoningLevel("none", caps); got != "low" { + t.Fatalf("none clamp=%q, want low", got) + } + if got := ResolveReasoningLevel("off", caps); got != "low" { + t.Fatalf("off clamp=%q, want low", got) + } + if got := ResolveReasoningLevel("max", caps); got != "max" { + t.Fatalf("max clamp=%q, want max (never downgraded)", got) + } + if got := ResolveReasoningLevel("", caps); got != "high" { + t.Fatalf("empty request=%q, want default high", got) + } +} + +func TestResolveReasoningLevelKeepsDeclaredOff(t *testing.T) { + caps := ModelCapabilities{ReasoningOptions: []string{"none", "low", "high"}, ReasoningDefault: "high"} + if got := ResolveReasoningLevel("none", caps); got != "none" { + t.Fatalf("none on an off-capable model=%q, want none", got) + } +} + +func TestResolveReasoningLevelDegradesDownOnly(t *testing.T) { + caps := ModelCapabilities{ReasoningOptions: []string{"low", "medium", "high"}, ReasoningDefault: "medium"} + for requested, want := range map[string]string{ + "max": "high", + "xhigh": "high", + "high": "high", + "medium": "medium", + "low": "low", + "none": "low", + } { + if got := ResolveReasoningLevel(requested, caps); got != want { + t.Fatalf("%s resolved to %q, want %q", requested, got, want) + } + } +} + +// TestResolveReasoningLevelNeverUpgrades guards the CC Switch rule: a level the +// client sent is passed through when the model declares it, and otherwise only +// ever degrades downward. Replying with a stronger level than requested is never +// acceptable, whatever the model's default happens to be. +func TestResolveReasoningLevelNeverUpgrades(t *testing.T) { + sets := [][]string{ + {"low", "high"}, + {"none", "low", "high"}, + {"low", "high", "max"}, + {"none", "low", "medium", "high", "xhigh", "max"}, + } + for _, options := range sets { + caps := ModelCapabilities{ReasoningOptions: options, ReasoningDefault: "high"} + for _, requested := range reasoningLadder { + requestedRank := reasoningRank(requested) + resolved := ResolveReasoningLevel(requested, caps) + if resolved == "" { + t.Fatalf("options=%v requested=%s resolved empty", options, requested) + } + if requestedRank == 0 { + // "do not think" below the model floor can only land on the + // cheapest declared tier; it must never be the default tier. + if got := reasoningRank(resolved); got != reasoningRank(lowestReasoningOption(caps)) { + t.Fatalf("options=%v requested=%s resolved=%s, want the model floor", options, requested, resolved) + } + continue + } + if got := reasoningRank(resolved); got > requestedRank { + t.Fatalf("options=%v requested=%s resolved=%s upgraded", options, requested, resolved) + } + } + } +} + +func TestLowestThinkingOptionSkipsNone(t *testing.T) { + caps := ModelCapabilities{ReasoningOptions: []string{"none", "medium", "high"}} + if got := LowestThinkingOption(caps); got != "medium" { + t.Fatalf("lowest thinking option=%q want medium", got) + } + if got := LowestThinkingOption(ModelCapabilities{ReasoningOptions: []string{"none"}}); got != "" { + t.Fatalf("lowest thinking option=%q want empty", got) + } +} diff --git a/internal/providers/registry.go b/internal/providers/registry.go index 43d67523..1cc11934 100644 --- a/internal/providers/registry.go +++ b/internal/providers/registry.go @@ -101,13 +101,17 @@ var Qoder = ProviderDescriptor{ ID: "global", Label: "Global", ChatBase: "https://api2.qoder.sh", BillingBase: "https://openapi.qoder.sh", AuthBase: "https://qoder.sh", DefaultDomain: "qoder.global", - Checkin: &CheckinPolicy{Timezone: "Asia/Shanghai"}, + Checkin: &CheckinPolicy{ + Timezone: "Asia/Shanghai", + }, }, { ID: "cn", Label: "CN", ChatBase: "https://gateway.qoder.com.cn", BillingBase: "https://openapi.qoder.com.cn", AuthBase: "https://qoder.com.cn", DefaultDomain: "qoder.com.cn", - Checkin: &CheckinPolicy{Timezone: "Asia/Shanghai"}, + Checkin: &CheckinPolicy{ + Timezone: "Asia/Shanghai", + }, }, }, DefaultRegion: "global", @@ -131,7 +135,9 @@ var WorkBuddy = ProviderDescriptor{ ID: "cn", Label: "CN", ChatBase: "https://www.workbuddy.cn", BillingBase: "https://www.workbuddy.cn", AuthBase: "https://www.workbuddy.cn", DefaultDomain: "codebuddy.cn", - Checkin: &CheckinPolicy{Timezone: "Asia/Shanghai"}, + Checkin: &CheckinPolicy{ + Timezone: "Asia/Shanghai", + }, }, { ID: "global", Label: "Global", ChatBase: "https://www.workbuddy.ai", @@ -161,7 +167,9 @@ var Trae = ProviderDescriptor{ ID: "cn", Label: "CN Solo", ChatBase: "https://trae-api-cn.mchost.guru", BillingBase: "https://api.trae.cn", AuthBase: "https://api.trae.com.cn", DefaultDomain: "trae.cn", - Checkin: &CheckinPolicy{Timezone: "Asia/Shanghai"}, + Checkin: &CheckinPolicy{ + Timezone: "Asia/Shanghai", + }, }, }, DefaultRegion: "cn", @@ -285,13 +293,17 @@ var QwenWork = ProviderDescriptor{ ID: "global", Label: "International", ChatBase: "https://gateway.qwenwork.ai", BillingBase: "https://gateway.qwenwork.ai", AuthBase: "https://gateway.qwenwork.ai", DefaultDomain: "qwenwork.ai", - Checkin: &CheckinPolicy{Timezone: "Asia/Shanghai"}, + Checkin: &CheckinPolicy{ + Timezone: "Asia/Shanghai", + }, }, { ID: "cn", Label: "CN", ChatBase: "https://gateway.qwenwork.cn", BillingBase: "https://gateway.qwenwork.cn", AuthBase: "https://gateway.qwenwork.cn", DefaultDomain: "qwenwork.cn", - Checkin: &CheckinPolicy{Timezone: "Asia/Shanghai"}, + Checkin: &CheckinPolicy{ + Timezone: "Asia/Shanghai", + }, }, }, DefaultRegion: "global", @@ -345,7 +357,9 @@ var CodeArts = ProviderDescriptor{ BillingBase: "https://snap-access.cn-north-4.myhuaweicloud.com", AuthBase: "https://codearts.huaweicloud.com", DefaultDomain: "huaweicloud.com", - Checkin: &CheckinPolicy{Timezone: "Asia/Shanghai"}, + Checkin: &CheckinPolicy{ + Timezone: "Asia/Shanghai", + }, }, }, DefaultRegion: "cn-north-4", @@ -426,7 +440,9 @@ var DoubaoWork = ProviderDescriptor{ ID: "cn", Label: "CN", ChatBase: "https://www.doubao.com", BillingBase: "https://www.doubao.com", AuthBase: "https://www.doubao.com", DefaultDomain: "doubao.com", - Checkin: &CheckinPolicy{Timezone: "Asia/Shanghai"}, + Checkin: &CheckinPolicy{ + Timezone: "Asia/Shanghai", + }, }, }, DefaultRegion: "cn", @@ -451,13 +467,17 @@ var MiniMaxCode = ProviderDescriptor{ ID: "cn", Label: "CN", ChatBase: "https://agent.minimax.cn", BillingBase: "https://agent.minimax.cn", AuthBase: "https://account.minimax.cn", DefaultDomain: "minimax.cn", - Checkin: &CheckinPolicy{Timezone: "Asia/Shanghai"}, + Checkin: &CheckinPolicy{ + Timezone: "Asia/Shanghai", + }, }, { ID: "global", Label: "Global", ChatBase: "https://agent.minimax.io", BillingBase: "https://agent.minimax.io", AuthBase: "https://account.minimax.io", DefaultDomain: "minimax.io", - Checkin: &CheckinPolicy{Timezone: "Asia/Shanghai"}, + Checkin: &CheckinPolicy{ + Timezone: "Asia/Shanghai", + }, }, }, DefaultRegion: "cn", diff --git a/internal/providers/trae/checkin.go b/internal/providers/trae/checkin.go index 58b9bc3e..e339af4b 100644 --- a/internal/providers/trae/checkin.go +++ b/internal/providers/trae/checkin.go @@ -32,6 +32,11 @@ func (AlreadyCheckedInError) AlreadyCheckedIn() bool { return true } // re-probe so success is only reported when the account actually flipped. // "今日已签到" maps to Status="already"; session-dead surfaces KindAuth so the // manager can flag the account for re-login. +// +// The ug endpoints do not gate on the client build code: a live probe on +// 2026-11-25 returned the same status body with and without the SOLO +// X-Ide-Version-Code headers, so check-in keeps the UG identity (UA + device +// id) while catalog and chat carry the version pair. func (client *Client) Checkin(ctx context.Context, accountID string) (providers.CheckinResult, error) { credential, err := client.credential(ctx, accountID) if err != nil { diff --git a/internal/providers/trae/client.go b/internal/providers/trae/client.go index ec222c19..8ec43c5b 100644 --- a/internal/providers/trae/client.go +++ b/internal/providers/trae/client.go @@ -150,6 +150,11 @@ func (c *Client) httpClient(ctx context.Context, accountID string) (*http.Client return &client, nil } +// traeStreamHeadTimeoutEnv overrides the streaming head deadline (milliseconds). +// TRAE CN Work occasionally accepts a chat request and then sends nothing for +// minutes; without this the relay waits until the client gives up. +const traeStreamHeadTimeoutEnv = "TRAE_STREAM_TTFB_MS" + func (c *Client) do(ctx context.Context, accountID, method, rawURL string, body []byte, setHeaders func(http.Header)) ([]byte, int, error) { var reader io.Reader if body != nil { @@ -1098,23 +1103,11 @@ func (c *Client) chatRequest(ctx context.Context, credential Credential, req tra if err := json.Unmarshal(rewritten, &obj); err == nil { maxMode := false storedLevel := "" - if req.IsMaxMode != nil { - maxMode = *req.IsMaxMode - } caps := c.capsFor(req.Model) if setter, ok := c.store.(ModelSettingReader); ok { if stored, err := setter.GetProviderModelSetting(ctx, "trae", settingModelKey(req.Model)); err == nil { - if req.IsMaxMode == nil { - maxMode = stored.MaxMode - } storedLevel = stored.ReasoningEffort } - } else if req.IsMaxMode == nil { - if maxSetter, ok := c.store.(ModelMaxModeReader); ok { - if stored, err := maxSetter.GetProviderModelMaxMode(ctx, "trae", settingModelKey(req.Model)); err == nil { - maxMode = stored - } - } } // Caps may be empty because the catalog has not been fetched (fresh // process, first request) or the model is unknown. Only the unknown @@ -1123,8 +1116,12 @@ func (c *Client) chatRequest(ctx context.Context, credential Credential, req tra _, _ = c.Models(ctx, accountID) caps = c.capsFor(req.Model) } - if maxMode && !caps.MaxMode { - log.Printf("trae model %q: max mode requested but catalog says unsupported; sending default context window", req.Model) + // Models with a real Max tier stay unlocked: ask upstream for the larger + // window on every request instead of relying on a console switch. A + // client that explicitly clears the flag still gets the default window. + maxMode = caps.MaxMode + if req.IsMaxMode != nil { + maxMode = *req.IsMaxMode && caps.MaxMode } applySoloChatFields(obj, req, maxMode, storedLevel, caps, credential.UID, providers.ConversationFromContext(ctx)) resolved.ReasoningLevel = resolvedReasoningLevel(req, storedLevel, caps) @@ -1155,7 +1152,7 @@ func (c *Client) ChatNonStream(ctx context.Context, accountID string, req transl return providers.ChatOutcome{}, err } client.Timeout = 0 - resp, err := client.Do(httpReq) + resp, err := providers.DoWithHeadTimeout(client, httpReq, providers.HeadTimeoutFromEnv(traeStreamHeadTimeoutEnv, providers.DefaultStreamHeadTimeout)) if err != nil { return providers.ChatOutcome{}, err } @@ -1190,7 +1187,7 @@ func (c *Client) ChatStream(ctx context.Context, accountID string, req translate return nil, providers.ResolvedChat{}, err } client.Timeout = 0 - resp, err := client.Do(httpReq) + resp, err := providers.DoWithHeadTimeout(client, httpReq, providers.HeadTimeoutFromEnv(traeStreamHeadTimeoutEnv, providers.DefaultStreamHeadTimeout)) if err != nil { return nil, providers.ResolvedChat{}, err } diff --git a/internal/providers/trae/credential.go b/internal/providers/trae/credential.go index 4e708877..e24a399e 100644 --- a/internal/providers/trae/credential.go +++ b/internal/providers/trae/credential.go @@ -22,13 +22,24 @@ const ( ConsoleHost = "https://www.trae.cn" // Login uses the IDE product markers (PKCE authorization-code flow): - // client_id below, auth_from=trae, x_app_version=3.4.24. + // client_id below, auth_from=trae, x_app_version=3.4.21. ClientID = "ono9krqynydwx5" AuthFrom = "trae" AppID = "6eefa01c-1036-4c7e-9ca5-d891f63bfcd8" // IdeVersion is the x_app_version / IDEVersion sent on login + exchange. - IdeVersion = "3.4.24" - IdeVersionCode = "20260212" + // IdeVersionCode is the client build date Trae gates both the model catalog + // and chat serving on: X-Ide-Version-Code / X-App-Version-Code carry it, and + // an older value silently downgrades the account to a legacy cohort (20260212 + // returned 45 entries / 6 visible models and rejected current models with + // 4001, while 20261117 returned 65 / 21). The version string itself is not + // gated (3.3.62 and 9.9.9 return the same catalog as the current 3.4.x for + // one code). + // Keep both aligned with the newest *published* Trae CN build: 3.4.21 + // shipped 2026-11-17 (trae.cn/changelog), so its build date is 20261117. + // Do not copy a larger gray-channel version such as 3.4.24: it is not in + // the public release line, so it says nothing true about the client. + IdeVersion = "3.4.21" + IdeVersionCode = "20261117" DeviceBrand = "83DG" OSVersion = "Windows 11 Pro" // Function is the fallback scene for a model that is in no fetched scene diff --git a/internal/providers/trae/s04_interfaces_test.go b/internal/providers/trae/s04_interfaces_test.go index af33c6ca..2a201a7e 100644 --- a/internal/providers/trae/s04_interfaces_test.go +++ b/internal/providers/trae/s04_interfaces_test.go @@ -53,7 +53,7 @@ func TestMissingSecretReaderSkipsGlobalProxy(t *testing.T) { } } -func TestMissingModelSettingReaderFallsBackToMaxMode(t *testing.T) { +func TestChatRequestUnlocksMaxTierWithoutStoredSetting(t *testing.T) { payload, _ := Credential{AccessToken: "at", RefreshToken: "rt", UID: "u1", Domain: DomainCN, ExpiresAt: 4102444800}.Encode() store := &maxModeOnlyStore{requiredStore: requiredStore{items: map[string][]byte{"acc1": payload}}} var got map[string]any @@ -77,15 +77,52 @@ func TestMissingModelSettingReaderFallsBackToMaxMode(t *testing.T) { client.http = server.Client() client.http.Transport = rewriteTransport{server: server.URL, round: server.Client().Transport} + // The catalog alone unlocks the larger window: no stored setting and no + // max-mode-only reader are needed for the request to carry is_max_mode. if _, err := client.ChatNonStream(context.Background(), "acc1", translate.ChatRequest{ Model: "DeepSeek-V4-Pro-Official", }); err != nil { t.Fatal(err) } if got["is_max_mode"] != float64(1) { - t.Fatalf("legacy max-mode fallback not applied: %v", got) + t.Fatalf("max tier not unlocked from the catalog: %v", got) } - if len(store.lookups) == 0 || store.lookups[0] != "trae/deepseek-v4-pro-official" { - t.Fatalf("lookup key mismatch: %v", store.lookups) +} + +// A client that explicitly clears is_max_mode keeps the default window even on +// a model whose Max tier is otherwise unlocked. +func TestChatRequestHonoursExplicitMaxModeOff(t *testing.T) { + payload, _ := Credential{AccessToken: "at", RefreshToken: "rt", UID: "u1", Domain: DomainCN, ExpiresAt: 4102444800}.Encode() + store := &maxModeOnlyStore{requiredStore: requiredStore{items: map[string][]byte{"acc1": payload}}} + var got map[string]any + server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if r.URL.Path == pathModels { + _ = json.NewEncoder(w).Encode(map[string]any{ + "config_info_list": []map[string]any{{ + "config_name": "DeepSeek-V4-Pro-Official", + "context_window_tokens": map[string]any{"dev": 200000, "max": 1000000}, + "display_config": map[string]any{"display_name": "DeepSeek-V4-Pro 正式版"}, + }}, + }) + return + } + _ = json.NewDecoder(r.Body).Decode(&got) + w.Header().Set("Content-Type", "text/event-stream") + _, _ = w.Write([]byte(soloSSE)) + })) + defer server.Close() + client := NewClient(store) + client.http = server.Client() + client.http.Transport = rewriteTransport{server: server.URL, round: server.Client().Transport} + + off := false + if _, err := client.ChatNonStream(context.Background(), "acc1", translate.ChatRequest{ + Model: "DeepSeek-V4-Pro-Official", + IsMaxMode: &off, + }); err != nil { + t.Fatal(err) + } + if _, ok := got["is_max_mode"]; ok { + t.Fatalf("explicit opt-out must drop is_max_mode: %v", got) } } diff --git a/internal/providers/trae/versions_test.go b/internal/providers/trae/versions_test.go new file mode 100644 index 00000000..d41f14fe --- /dev/null +++ b/internal/providers/trae/versions_test.go @@ -0,0 +1,25 @@ +package trae + +import "testing" + +// Trae serves its model catalog and chat by client build-date cohort: the +// X-Ide-Version-Code / X-App-Version-Code headers carry IdeVersionCode, and a +// value before the current cohort silently downgrades the account to a legacy +// catalog. Measured against the live CN upstream on 2026-11-25: 20260212 +// returned 45 entries / 6 visible models and answered current models with +// 4001, while 20260811 and anything newer returned 65 entries / 21 visible +// models. The version string itself is not gated. +func TestIdeVersionCodeIsInCurrentModelCohort(t *testing.T) { + if len(IdeVersionCode) != 8 { + t.Fatalf("IdeVersionCode=%q must be an eight-digit build date", IdeVersionCode) + } + for _, digit := range IdeVersionCode { + if digit < '0' || digit > '9' { + t.Fatalf("IdeVersionCode=%q must be numeric", IdeVersionCode) + } + } + const minModelCohort = "20261117" // v3.4.21 release build; bump with IdeVersionCode when the client line moves + if IdeVersionCode < minModelCohort { + t.Fatalf("IdeVersionCode=%q is below the %s model cohort; the catalog would collapse to the legacy six", IdeVersionCode, minModelCohort) + } +} diff --git a/internal/providers/workbuddy/client.go b/internal/providers/workbuddy/client.go index 28cf1dd5..c8a90743 100644 --- a/internal/providers/workbuddy/client.go +++ b/internal/providers/workbuddy/client.go @@ -1218,14 +1218,15 @@ func aggregateUserResource(packages []resourcePackage, totalDosage int64) (remai // Adapter returns the provider capability bundle for registration. func (c *Client) Adapter() providers.Adapter { return providers.Adapter{ - ID: "workbuddy", - Credential: credentialCodec{}, - Login: c, - Chat: c, - Models: c, - Classifier: classifier{}, - Prober: c, - Checkin: c, + ID: "workbuddy", + Credential: credentialCodec{}, + Login: c, + Chat: c, + Models: c, + Classifier: classifier{}, + Prober: c, + Checkin: c, + CheckinStatus: c, } } diff --git a/internal/providers/workbuddy/credential.go b/internal/providers/workbuddy/credential.go index 359445fc..1155c5cf 100644 --- a/internal/providers/workbuddy/credential.go +++ b/internal/providers/workbuddy/credential.go @@ -24,10 +24,12 @@ const ( // UserAgent is the CN CLI/chat UA the current desktop sends: app token, // edition token, then the bundled CLI. Origin/Referer stay region-specific // and must never mix CN with Global. All client versions live here. - // CLIVersion is the unpacked @tencent-ai/codebuddy-code package version - // bundled in desktop 5.11.3 / 5.11.4 (2.176.0). The desktop app version, - // not the bundled CLI version, is the UA/version segment. - CLIVersion = "2.176.0" + // CLIVersion tracks the published @tencent-ai/codebuddy-code package + // (2.186.0, 2026-11-24). The desktop app version, not the bundled CLI + // version, is the UA/version segment; live A/B on CN 2026-11-25 showed + // CLI 2.176.0 and 2.186.0 return the same 57-model catalog and both stream + // chat, so the CLI segment follows the package rather than a frozen bundle. + CLIVersion = "2.186.0" UserAgent = "WorkBuddy/" + DesktopVersionCN + " WorkBuddy/" + DesktopVersionCN + " CLI/" + DesktopCLIVersionCN // OpenAI Node SDK fingerprint the official CLI attaches to chat. @@ -45,20 +47,22 @@ const ( // Desktop clients ship separately per edition. Their UA is three-part: // app token, edition token, then the CLI bundled inside that desktop - // build. The current official builds are CN 5.11.3 and Global 5.11.4; - // both bundle CLI 2.176.0. + // build. The current official builds are CN 5.11.3 and Global 5.11.4 + // (both 2026-11); their CLI segment follows the published CLI package. DesktopVersionGlobal = "5.11.4" - DesktopCLIVersionGlobal = "2.176.0" + DesktopCLIVersionGlobal = "2.186.0" DesktopVersionCN = "5.11.3" - DesktopCLIVersionCN = "2.176.0" + DesktopCLIVersionCN = "2.186.0" DesktopUserAgentGlobal = "WorkBuddy/" + DesktopVersionGlobal + " workbuddy-ai/" + DesktopVersionGlobal + " CLI/" + DesktopCLIVersionGlobal DesktopUserAgentCN = UserAgent // DaemonUserAgentGlobal is the background-service UA: the global edition's // applicationName is used for both app segments. CN equals UserAgent. DaemonUserAgentGlobal = "workbuddy-ai/" + DesktopVersionGlobal + " workbuddy-ai/" + DesktopVersionGlobal + " CLI/" + DesktopCLIVersionGlobal - // IDEVersion is the CodeBuddy IDE plugin release, kept with the others. - IDEVersion = "2.176.0" + // IDEVersion is the CodeBuddy IDE plugin release. It is not on the wire + // today; it is kept aligned with the bundled CLI identity so no stale + // version number is left in the package. + IDEVersion = "2.186.0" // DesktopVersion/DesktopUserAgent are for /v3/config only (Global). Live // A/B showed the same Global account returns the IDE dropdown (incl. @@ -86,8 +90,8 @@ const ( pathModelsCN = "/console/enterprises/personal/models" pathModelsGlobal = "/v2/enterprises/personal/models" pathProductConfig = "/v3/config" - pathUserResource = "/v2/billing/meter/get-user-resource" - pathDailyCheckin = "/v2/billing/meter/daily-checkin" + pathUserResource = "/v2/billing/meter/get-user-resource" + pathDailyCheckin = "/v2/billing/meter/daily-checkin" sessionDeadCode = 12153 sessionDeadText = "Offline user session not found" diff --git a/internal/providers/workbuddy/mapping.go b/internal/providers/workbuddy/mapping.go index fb0f16a0..9c6fedf8 100644 --- a/internal/providers/workbuddy/mapping.go +++ b/internal/providers/workbuddy/mapping.go @@ -52,8 +52,11 @@ func applyChatReasoning(obj map[string]any, req translate.ChatRequest, storedLev } if level == "none" { if !caps.CanDisableThinking { - level = providers.ResolveReasoningLevel(caps.ReasoningDefault, caps) - if level == "" || level == "none" { + // The model declares "none" but cannot actually turn thinking off. + // Degrade down to the cheapest thinking tier; never fall back to the + // model default, which could upgrade the level the client asked for. + level = providers.LowestThinkingOption(caps) + if level == "" { clearChatReasoning(obj) return "" } diff --git a/internal/providers/workbuddy/thinking_toggle_test.go b/internal/providers/workbuddy/thinking_toggle_test.go index ffa57c5c..619c7a66 100644 --- a/internal/providers/workbuddy/thinking_toggle_test.go +++ b/internal/providers/workbuddy/thinking_toggle_test.go @@ -18,12 +18,12 @@ func TestApplyChatReasoningDisabledThinking(t *testing.T) { CanDisableThinking: false, } disabled := translate.ChatRequest{ - Model: "deepseek-v4.1-flash", + Model: "deepseek-v4.1-flash", Thinking: json.RawMessage(`{"type":"disabled"}`), } obj := map[string]any{ - "reasoning": map[string]any{"effort": "stale"}, - "reasoning_effort": "max", + "reasoning": map[string]any{"effort": "stale"}, + "reasoning_effort": "max", "reasoning_summary": "auto", "verbosity": "high", } @@ -41,13 +41,33 @@ func TestApplyChatReasoningDisabledThinking(t *testing.T) { } } +func TestApplyChatReasoningNoneNeverUpgrades(t *testing.T) { + // A model that declares "none" but cannot turn thinking off must degrade + // down to the cheapest thinking tier, never up to the model default. + caps := providers.ModelCapabilities{ + ReasoningOptions: []string{"none", "medium", "high"}, + ReasoningDefault: "high", + CanDisableThinking: false, + } + req := translate.ChatRequest{Model: "glm-5.3", ReasoningEffort: json.RawMessage(`"none"`)} + obj := map[string]any{"reasoning_effort": "stale"} + if got := applyChatReasoning(obj, req, "", caps); got != "medium" { + t.Fatalf("resolved level=%q want medium (cheapest thinking tier)", got) + } + reasoning, ok := obj["reasoning"].(map[string]any) + if !ok || reasoning["effort"] != "medium" { + t.Fatalf("reasoning=%v want effort medium", obj["reasoning"]) + } +} + func TestApplyChatReasoningDisabledDoesNotHijackLevels(t *testing.T) { caps := providers.ModelCapabilities{ ReasoningOptions: []string{"low", "high", "max"}, ReasoningDefault: "high", } - // Negative controls: enabled thinking and reasoning_effort:none must keep - // the existing catalog-clamped behaviour. + // Negative controls: enabled thinking keeps the catalog default, while + // reasoning_effort:none degrades to the cheapest declared tier instead of + // being clamped back up to the default. for _, tc := range []struct { name string req translate.ChatRequest @@ -56,9 +76,9 @@ func TestApplyChatReasoningDisabledDoesNotHijackLevels(t *testing.T) { {"enabled thinking", translate.ChatRequest{ Model: "deepseek-v4.1-flash", Thinking: json.RawMessage(`{"type":"enabled"}`), }, "high"}, - {"effort none clamped", translate.ChatRequest{ + {"effort none degrades to lowest declared", translate.ChatRequest{ Model: "deepseek-v4.1-flash", ReasoningEffort: json.RawMessage(`"none"`), - }, "high"}, + }, "low"}, {"effort low preserved", translate.ChatRequest{ Model: "deepseek-v4.1-flash", ReasoningEffort: json.RawMessage(`"low"`), }, "low"}, diff --git a/internal/providers/workbuddy/versions_test.go b/internal/providers/workbuddy/versions_test.go index 32661c3b..8a29e9b6 100644 --- a/internal/providers/workbuddy/versions_test.go +++ b/internal/providers/workbuddy/versions_test.go @@ -6,25 +6,25 @@ import ( ) func TestClientVersionsAndDesktopUserAgents(t *testing.T) { - if CLIVersion != "2.176.0" || IDEVersion != "2.176.0" { + if CLIVersion != "2.186.0" || IDEVersion != "2.186.0" { t.Fatalf("CLI=%q IDE=%q", CLIVersion, IDEVersion) } - if UserAgent != "WorkBuddy/5.11.3 WorkBuddy/5.11.3 CLI/2.176.0" { + if UserAgent != "WorkBuddy/5.11.3 WorkBuddy/5.11.3 CLI/2.186.0" { t.Fatalf("CN desktop UA=%q", UserAgent) } if CLIStainlessPackageVersion != "6.25.0" || CLIStainlessRuntimeVersion != "v22.21.1" { t.Fatalf("SDK fingerprint package=%q runtime=%q", CLIStainlessPackageVersion, CLIStainlessRuntimeVersion) } - if DesktopVersionGlobal != "5.11.4" || DesktopCLIVersionGlobal != "2.176.0" { + if DesktopVersionGlobal != "5.11.4" || DesktopCLIVersionGlobal != "2.186.0" { t.Fatalf("global desktop=%q cli=%q", DesktopVersionGlobal, DesktopCLIVersionGlobal) } - if got := DesktopUserAgentFor(true); got != "WorkBuddy/5.11.4 workbuddy-ai/5.11.4 CLI/2.176.0" { + if got := DesktopUserAgentFor(true); got != "WorkBuddy/5.11.4 workbuddy-ai/5.11.4 CLI/2.186.0" { t.Fatalf("global desktop UA=%q", got) } if got := DesktopUserAgentFor(false); got != UserAgent { t.Fatalf("CN desktop UA=%q", got) } - if got := DaemonUserAgentFor(true); got != "workbuddy-ai/5.11.4 workbuddy-ai/5.11.4 CLI/2.176.0" { + if got := DaemonUserAgentFor(true); got != "workbuddy-ai/5.11.4 workbuddy-ai/5.11.4 CLI/2.186.0" { t.Fatalf("global daemon UA=%q", got) } if got := DaemonUserAgentFor(false); got != UserAgent { diff --git a/internal/runtime/checkin_integration_test.go b/internal/runtime/checkin_integration_test.go index 122f2f85..322971ea 100644 --- a/internal/runtime/checkin_integration_test.go +++ b/internal/runtime/checkin_integration_test.go @@ -57,7 +57,7 @@ func TestCheckinCapabilityRecordsAndDeduplicates(t *testing.T) { } } -func TestCheckinAllRunsWithBoundedConcurrency(t *testing.T) { +func TestCheckinAllRunsFullFanOut(t *testing.T) { var active atomic.Int32 var maxActive atomic.Int32 manager, _ := newCheckinManager(t, checkinFunc(func(context.Context, string) (providers.CheckinResult, error) { @@ -70,7 +70,7 @@ func TestCheckinAllRunsWithBoundedConcurrency(t *testing.T) { } } time.Sleep(40 * time.Millisecond) - return providers.CheckinResult{Status: "success", Message: "claimed"}, nil + return providers.CheckinResult{Status: "success", Message: "claimed", RewardCredits: 150}, nil })) enabled := true for i := 0; i < 8; i++ { @@ -80,7 +80,9 @@ func TestCheckinAllRunsWithBoundedConcurrency(t *testing.T) { t.Fatal(err) } } + start := time.Now() results, err := manager.CheckinAll(context.Background(), false, false) + elapsed := time.Since(start) if err != nil { t.Fatal(err) } @@ -91,9 +93,17 @@ func TestCheckinAllRunsWithBoundedConcurrency(t *testing.T) { if result.Status != "success" { t.Fatalf("result=%+v", result) } + if result.RewardCredits != 150 { + t.Fatalf("real reward not carried: %+v", result) + } + } + // Full fan-out: every account starts at once, so all 9 overlap and the + // wall clock stays near a single attempt instead of 9 sequential ones. + if got := maxActive.Load(); got != 9 { + t.Fatalf("max concurrency=%d want 9 (full fan-out)", got) } - if got := maxActive.Load(); got < 2 || got > manualCheckinConcurrency { - t.Fatalf("max concurrency=%d want 2..%d", got, manualCheckinConcurrency) + if elapsed > time.Second { + t.Fatalf("one-click check-in took %v; accounts were queued", elapsed) } } diff --git a/internal/runtime/checkin_status_test.go b/internal/runtime/checkin_status_test.go index c20f3917..4c582caa 100644 --- a/internal/runtime/checkin_status_test.go +++ b/internal/runtime/checkin_status_test.go @@ -54,7 +54,7 @@ func TestSyncCheckinStatusPersistsUpstreamAlreadyAndAutoTime(t *testing.T) { t.Fatal(err) } if updated.LastCheckinStatus != "already" || updated.LastCheckinSource != "upstream" || - updated.LastCheckinSyncedAt == "" || updated.CheckinAutoTime != "11:00" || + updated.LastCheckinSyncedAt == "" || updated.CheckinAutoTime != "09:00" || updated.LastCheckinAt == "" { t.Fatalf("synced=%+v", updated) } @@ -79,8 +79,8 @@ func TestSyncCheckinStatusPendingKeepsLastAttemptAndDerivesOneHour(t *testing.T) // Within the post-check-in grace window the fresh local success stands. t.Fatalf("grace clobbered=%+v", updated) } - if updated.CheckinAutoTime != "01:00" { - t.Fatalf("auto time=%q want 01:00", updated.CheckinAutoTime) + if updated.CheckinAutoTime != "09:00" { + t.Fatalf("auto time=%q want 09:00", updated.CheckinAutoTime) } if updated.LastCheckinSource != "local" { t.Fatalf("grace must keep the local source, got %q", updated.LastCheckinSource) @@ -100,7 +100,7 @@ func TestSyncCheckinStatusPendingWinsAfterGrace(t *testing.T) { if err != nil { t.Fatal(err) } - if updated.LastCheckinStatus != "pending" || updated.LastCheckinSource != "upstream" || updated.CheckinAutoTime != "01:00" { + if updated.LastCheckinStatus != "pending" || updated.LastCheckinSource != "upstream" || updated.CheckinAutoTime != "09:00" { t.Fatalf("pending=%+v", updated) } if updated.LastCheckinAt == "" { @@ -118,7 +118,7 @@ func TestSyncCheckinStatusErrorMarksUnknownWithoutFakeCheckin(t *testing.T) { t.Fatal(err) } if updated.LastCheckinStatus != "unknown" || updated.LastCheckinSource != "upstream" || - updated.LastCheckinAt != "" || updated.CheckinAutoTime != "11:00" { + updated.LastCheckinAt != "" || updated.CheckinAutoTime != "09:00" { t.Fatalf("unknown=%+v", updated) } } @@ -175,6 +175,66 @@ func TestSyncCheckinStatusUnknownKeepsRealLocalSuccess(t *testing.T) { } } +func TestSyncCheckinStatusAppliesProviderSettingWhenProbeFails(t *testing.T) { + manager, account := newStatusManager(t, checkinStatusFunc(func(context.Context, string) (providers.CheckinResult, error) { + return providers.CheckinResult{}, errors.New("upstream unavailable") + })) + ctx := context.Background() + if err := manager.store.SetSecret(ctx, accounts.CheckinTimeSecret("qoder"), "10:30"); err != nil { + t.Fatal(err) + } + if err := manager.store.RecordCheckinStatus(ctx, account.ID, accounts.CheckinStatusUpdate{Status: "pending", AutoTime: "11:00"}); err != nil { + t.Fatal(err) + } + manager.SyncCheckinStatuses(ctx) + updated, err := manager.store.Get(ctx, account.ID) + if err != nil { + t.Fatal(err) + } + if updated.CheckinAutoTime != "10:30" { + t.Fatalf("the provider setting did not reach the account: %q", updated.CheckinAutoTime) + } +} + +func TestSyncCheckinStatusRewritesStoredAutoTimeFromSetting(t *testing.T) { + store, err := sqlstore.OpenStore(filepath.Join(t.TempDir(), "checkin-window.db")) + if err != nil { + t.Fatal(err) + } + t.Cleanup(func() { store.Close() }) + manager := NewManager(ManagerConfig{DataDir: t.TempDir()}, store, nil) + t.Cleanup(func() { manager.Close() }) + registry := providers.NewRegistry() + registry.Register(providers.Adapter{ + ID: "trae", + Checkin: checkinFunc(func(context.Context, string) (providers.CheckinResult, error) { + return providers.CheckinResult{Status: "skipped"}, nil + }), + CheckinStatus: checkinStatusFunc(func(context.Context, string) (providers.CheckinResult, error) { + // Trae only reports the day flag, never a window start. + return providers.CheckinResult{Status: "pending", Message: "上游显示今日未签到"}, nil + }), + }) + manager.SetProviders(registry) + enabled := true + account, err := store.Create(context.Background(), accounts.CreateAccount{Name: "TRAE", Provider: "trae", Region: "cn", Enabled: true, AutoCheckin: &enabled}) + if err != nil { + t.Fatal(err) + } + ctx := context.Background() + if err := store.RecordCheckinStatus(ctx, account.ID, accounts.CheckinStatusUpdate{Status: "pending", AutoTime: "05:00"}); err != nil { + t.Fatal(err) + } + manager.SyncCheckinStatuses(ctx) + updated, err := store.Get(ctx, account.ID) + if err != nil { + t.Fatal(err) + } + if updated.CheckinAutoTime != accounts.DefaultCheckinTime { + t.Fatalf("default setting not applied: %q", updated.CheckinAutoTime) + } +} + func mustCheckinRecords(t *testing.T, manager *Manager, id string) []accounts.CheckinRecord { t.Helper() records, err := manager.store.ListCheckinRecords(context.Background(), id, 20) diff --git a/internal/runtime/events_test.go b/internal/runtime/events_test.go new file mode 100644 index 00000000..a3163c9d --- /dev/null +++ b/internal/runtime/events_test.go @@ -0,0 +1,146 @@ +package runtime + +import ( + "context" + "os" + "path/filepath" + "testing" + "time" + + "github.com/caigee-cmd/cli2api/internal/accounts" + "github.com/caigee-cmd/cli2api/internal/events" + "github.com/caigee-cmd/cli2api/internal/providers" + sqlstore "github.com/caigee-cmd/cli2api/internal/store" +) + +func openEventTestManager(t *testing.T) (*Manager, *sqlstore.Store) { + t.Helper() + store, err := sqlstore.OpenStore(filepath.Join(t.TempDir(), "events.db")) + if err != nil { + t.Fatal(err) + } + t.Cleanup(func() { store.Close() }) + manager := NewManager(ManagerConfig{DataDir: t.TempDir()}, store, nil) + t.Cleanup(func() { manager.Close() }) + return manager, store +} + +// persistQuota must publish the exact snapshot it persisted, never a copy or +// a synthesized value. +func TestPersistQuotaPublishesRealSnapshot(t *testing.T) { + manager, _ := openEventTestManager(t) + stream, cancel := manager.SubscribeEvents(0) + defer cancel() + + quota := &accounts.QuotaSnapshot{Total: 1000, Remaining: 240, Percentage: 76, FetchedAt: time.Now().UTC().Format(time.RFC3339)} + manager.persistQuota(context.Background(), "acc-quota", quota) + + event := <-stream + if event.Type != events.TypeQuota { + t.Fatalf("event = %+v", event) + } + state, ok := event.Data.(events.QuotaState) + if !ok || state.Quota == nil || state.Quota.Remaining != 240 { + t.Fatalf("data = %#v", event.Data) + } +} + +// One-click check-in must publish start, per-account, and done frames carrying +// the real provider outcome and reward. +func TestCheckinAllPublishesBulkProgressWithRealReward(t *testing.T) { + manager, _ := openEventTestManager(t) + registry := providers.NewRegistry() + registry.Register(providers.Adapter{ID: "qoder", Checkin: checkinFunc(func(context.Context, string) (providers.CheckinResult, error) { + return providers.CheckinResult{Status: "success", Message: "claimed", RewardCredits: 150}, nil + })}) + manager.SetProviders(registry) + enabled := true + for i := 0; i < 2; i++ { + if _, err := manager.store.Create(context.Background(), accounts.CreateAccount{ + Name: "batch", Provider: "qoder", Region: "cn", Enabled: true, AutoCheckin: &enabled, + }); err != nil { + t.Fatal(err) + } + } + stream, cancel := manager.SubscribeEvents(0) + defer cancel() + + results, err := manager.CheckinAll(context.Background(), true, false) + if err != nil { + t.Fatal(err) + } + if len(results) != 2 { + t.Fatalf("results=%d", len(results)) + } + + var sawStart, sawDone, sawReward bool + deadline := time.After(2 * time.Second) + for !(sawStart && sawDone && sawReward) { + select { + case <-deadline: + t.Fatalf("missing bulk frames start=%v done=%v reward=%v", sawStart, sawDone, sawReward) + case event := <-stream: + if event.Type != events.TypeBulk { + continue + } + progress, ok := event.Data.(events.BulkProgress) + if !ok { + continue + } + switch progress.Phase { + case "start": + sawStart = progress.Total == 2 + case "done": + sawDone = progress.Done == 2 + case "account": + if result, ok := progress.Result.(accounts.CheckinAllResult); ok && result.RewardCredits == 150 { + sawReward = true + } + } + } + } +} + +// The force-ready override must affect routing only: SQLite keeps the real +// snapshot, the view shows the real snapshot, and the override is badged. +func TestForceReadyOverrideNeverFabricatesStorage(t *testing.T) { + manager, store := openEventTestManager(t) + account, err := store.Create(context.Background(), accounts.CreateAccount{ + Name: "forced", Provider: "qoder", Region: "cn", Enabled: true, + }) + if err != nil { + t.Fatal(err) + } + if err := os.MkdirAll(filepath.Join(manager.config.DataDir, "force-ready"), 0o755); err != nil { + t.Fatal(err) + } + if err := os.WriteFile(filepath.Join(manager.config.DataDir, "force-ready", account.ID), []byte("1"), 0o600); err != nil { + t.Fatal(err) + } + manager.pool.Upsert(Item{ID: account.ID, Provider: "qoder", Region: "cn", RuntimeState: "ready"}) + + realQuota := &accounts.QuotaSnapshot{Total: 100, Remaining: 0, Percentage: 100, Exceeded: true, FetchedAt: time.Now().UTC().Format(time.RFC3339)} + manager.persistQuota(context.Background(), account.ID, realQuota) + + stored, err := store.Get(context.Background(), account.ID) + if err != nil || stored.Quota == nil { + t.Fatalf("stored=%+v err=%v", stored.Quota, err) + } + if !stored.Quota.Exceeded || stored.Quota.Remaining != 0 { + t.Fatalf("storage must hold the real exhausted snapshot, got %+v", stored.Quota) + } + item, ok := manager.pool.ByID(account.ID) + if !ok || item.Quota == nil || item.Quota.Exceeded || item.Quota.Remaining <= 0 { + t.Fatalf("routing copy must be overridden, got %+v", item.Quota) + } + view, err := manager.AccountView(context.Background(), account.ID) + if err != nil { + t.Fatal(err) + } + if !view.ForceReadyOverride { + t.Fatal("view must badge the local override") + } + if view.Quota == nil || !view.Quota.Exceeded || view.Quota.Remaining != 0 { + t.Fatalf("view must show the real snapshot, got %+v", view.Quota) + } +} diff --git a/internal/runtime/maintenance_burst_test.go b/internal/runtime/maintenance_burst_test.go index 25707bf3..68c4abd6 100644 --- a/internal/runtime/maintenance_burst_test.go +++ b/internal/runtime/maintenance_burst_test.go @@ -12,34 +12,6 @@ import ( sqlstore "github.com/caigee-cmd/cli2api/internal/store" ) -func TestMaintenanceAccountGapForStableJitter(t *testing.T) { - base := 2 * time.Second - a := maintenanceAccountGapFor("acct-a", base) - b := maintenanceAccountGapFor("acct-a", base) - c := maintenanceAccountGapFor("acct-b", base) - if a != b { - t.Fatalf("gap not stable for same id: %v vs %v", a, b) - } - if a < base || a >= base+time.Duration(maintenanceGapJitterMS)*time.Millisecond { - t.Fatalf("gap out of range: %v", a) - } - if c < base || c >= base+time.Duration(maintenanceGapJitterMS)*time.Millisecond { - t.Fatalf("gap out of range for other id: %v", c) - } -} - -func TestSleepMaintenanceGapHonorsCancel(t *testing.T) { - ctx, cancel := context.WithCancel(context.Background()) - cancel() - start := time.Now() - if sleepMaintenanceGap(ctx, "acct", time.Hour) { - t.Fatal("canceled ctx should not sleep successfully") - } - if time.Since(start) > 200*time.Millisecond { - t.Fatal("canceled gap slept too long") - } -} - type recordingKeepalive struct { mu sync.Mutex calls []string @@ -64,18 +36,25 @@ func (r *recordingKeepalive) snapshot() []string { return out } -func TestRunScheduledCheckinsCapsPerTick(t *testing.T) { - prevCap, prevGap := maintenancePerTickCap, maintenanceAccountGap - maintenancePerTickCap = 2 - maintenanceAccountGap = 0 - t.Cleanup(func() { - maintenancePerTickCap = prevCap - maintenanceAccountGap = prevGap - }) - +// One maintenance tick must fan out every due account concurrently instead of +// queuing them across ticks: all 6 opted-in accounts check in on the first +// tick, and a repeat tick does not re-run already-checked accounts. +func TestRunScheduledCheckinsFansOutAllDueAccounts(t *testing.T) { var mu sync.Mutex var calls []string + var active, maxActive int32 + var activeMu sync.Mutex manager, _ := newCheckinManager(t, checkinFunc(func(_ context.Context, accountID string) (providers.CheckinResult, error) { + activeMu.Lock() + active++ + if active > maxActive { + maxActive = active + } + activeMu.Unlock() + time.Sleep(30 * time.Millisecond) + activeMu.Lock() + active-- + activeMu.Unlock() mu.Lock() calls = append(calls, accountID) mu.Unlock() @@ -97,30 +76,22 @@ func TestRunScheduledCheckinsCapsPerTick(t *testing.T) { now := time.Now().In(location) dueAt := time.Date(now.Year(), now.Month(), now.Day(), 23, 59, 0, 0, location) + start := time.Now() manager.runScheduledCheckins(context.Background(), dueAt) + elapsed := time.Since(start) mu.Lock() first := append([]string(nil), calls...) mu.Unlock() - if len(first) != 2 { - t.Fatalf("first tick calls=%d want 2 ids=%v", len(first), first) + if len(first) != 6 { + t.Fatalf("first tick calls=%d want 6 ids=%v", len(first), first) } - - manager.runScheduledCheckins(context.Background(), dueAt) - mu.Lock() - second := append([]string(nil), calls...) - mu.Unlock() - if len(second) != 4 { - t.Fatalf("second tick cumulative calls=%d want 4 ids=%v", len(second), second) + if maxActive < 6 { + t.Fatalf("scheduled check-ins were not fully concurrent: maxActive=%d want 6", maxActive) } - - manager.runScheduledCheckins(context.Background(), dueAt) - manager.runScheduledCheckins(context.Background(), dueAt) - mu.Lock() - total := len(calls) - mu.Unlock() - if total != 6 { - t.Fatalf("after draining calls=%d want 6", total) + if elapsed > time.Second { + t.Fatalf("full fan-out took %v; accounts were queued", elapsed) } + manager.runScheduledCheckins(context.Background(), dueAt) mu.Lock() after := len(calls) @@ -130,15 +101,9 @@ func TestRunScheduledCheckinsCapsPerTick(t *testing.T) { } } -func TestKeepaliveWorkBuddyCapsPerTickAndResumes(t *testing.T) { - prevCap, prevGap := maintenancePerTickCap, maintenanceAccountGap - maintenancePerTickCap = 2 - maintenanceAccountGap = 0 - t.Cleanup(func() { - maintenancePerTickCap = prevCap - maintenanceAccountGap = prevGap - }) - +// Keepalive must refresh every eligible account in one concurrent call and +// report no remaining work; the done map still deduplicates across ticks. +func TestKeepaliveWorkBuddyFansOutAndDeduplicates(t *testing.T) { store, err := sqlstore.OpenStore(filepath.Join(t.TempDir(), "keepalive.db")) if err != nil { t.Fatal(err) @@ -160,30 +125,14 @@ func TestKeepaliveWorkBuddyCapsPerTickAndResumes(t *testing.T) { done := map[string]struct{}{} more := manager.KeepaliveWorkBuddy(context.Background(), true, done) - if !more { - t.Fatal("expected more accounts after first capped tick") - } - if got := rec.snapshot(); len(got) != 2 { - t.Fatalf("first tick keepalive calls=%d want 2 ids=%v", len(got), got) - } - if len(done) != 2 { - t.Fatalf("done map size=%d want 2", len(done)) - } - - more = manager.KeepaliveWorkBuddy(context.Background(), true, done) - if !more { - t.Fatal("expected more after second tick") - } - if got := rec.snapshot(); len(got) != 4 { - t.Fatalf("second tick cumulative=%d want 4", len(got)) - } - - more = manager.KeepaliveWorkBuddy(context.Background(), true, done) if more { - t.Fatal("expected no more after final tick") + t.Fatal("full fan-out must finish every pending account in one call") } if got := rec.snapshot(); len(got) != 5 { - t.Fatalf("final cumulative=%d want 5", len(got)) + t.Fatalf("keepalive calls=%d want 5 ids=%v", len(got), got) + } + if len(done) != 5 { + t.Fatalf("done map size=%d want 5", len(done)) } more = manager.KeepaliveWorkBuddy(context.Background(), true, done) diff --git a/internal/runtime/manager.go b/internal/runtime/manager.go index 04fa017c..da8d313b 100644 --- a/internal/runtime/manager.go +++ b/internal/runtime/manager.go @@ -10,6 +10,7 @@ import ( "sync/atomic" "time" + "github.com/caigee-cmd/cli2api/internal/events" "github.com/caigee-cmd/cli2api/internal/providers" ) @@ -74,12 +75,17 @@ type Manager struct { workbuddy WorkBuddyMaintainer checkinRunning map[string]bool checkinStatusRunning bool - mu sync.Mutex - processes map[string]ManagedProcess - restarts map[string]int - restartBackoff map[string]int - recovering map[string]bool - recoverPending map[string]string + quotaFreshRunning bool + + // events publishes real console state changes (quota/checkin/health/bulk + // progress) to the console SSE channel. Never nil after NewManager. + events *events.Bus + mu sync.Mutex + processes map[string]ManagedProcess + restarts map[string]int + restartBackoff map[string]int + recovering map[string]bool + recoverPending map[string]string // recoverUnwindHook runs (tests only) as a recovery goroutine starts unwinding. recoverUnwindHook func(id string) recoverDone sync.WaitGroup @@ -202,6 +208,7 @@ func NewManager(config ManagerConfig, store AccountStore, starter ProcessStarter quotaProbeLevels: map[string]int{}, healthFailures: map[string]int{}, reconcileAt: map[string]time.Time{}, + events: events.NewBus(), } manager.persistCond = sync.NewCond(&manager.persistMu) manager.persistDone.Add(1) @@ -222,10 +229,35 @@ func NewManager(config ManagerConfig, store AccountStore, starter ProcessStarter } } manager.persistMu.Unlock() + // Publish the real routing state change (cooldown/health merges from + // chat failover included) so the console reflects it in real time. + state := events.AccountState{ + AccountID: item.ID, + RuntimeState: item.RuntimeState, + LastError: item.LastError, + LastKind: item.LastKind, + } + if item.Ready != nil { + state.Ready = *item.Ready + } + if !item.DownUntil.IsZero() { + state.CooldownUntil = item.DownUntil.UTC().Format(time.RFC3339) + } + manager.events.Publish(events.TypeAccount, item.ID, "", state) }) return manager } +// SubscribeEvents exposes the real state-change stream to the console facade. +func (m *Manager) SubscribeEvents(lastSeq uint64) (<-chan events.Event, func()) { + if m == nil || m.events == nil { + ch := make(chan events.Event) + close(ch) + return ch, func() {} + } + return m.events.Subscribe(lastSeq) +} + // drainCooldowns persists pool state changes for one account at a time, // draining the per-account dirty set to empty before signaling any flush. // Because each entry in the dirty set is the newest-known snapshot for its diff --git a/internal/runtime/manager_accounts.go b/internal/runtime/manager_accounts.go index 4f496051..598bb98b 100644 --- a/internal/runtime/manager_accounts.go +++ b/internal/runtime/manager_accounts.go @@ -7,6 +7,7 @@ import ( "path/filepath" "time" + "github.com/caigee-cmd/cli2api/internal/events" "github.com/caigee-cmd/cli2api/internal/providers" proxyutil "github.com/caigee-cmd/cli2api/internal/proxy" ) @@ -37,10 +38,19 @@ func (m *Manager) RemoveAccount(id string) error { if err := os.RemoveAll(runtimeDir); err != nil { return fmt.Errorf("remove account runtime: %w", err) } + m.events.Publish(events.TypeAccounts, id, "", nil) return nil } func (m *Manager) SyncAccount(ctx context.Context, before, after Account) error { + err := m.syncAccount(ctx, before, after) + // Structural change (enable/disable/proxy/concurrency): tell the console + // to re-read the real store state regardless of which path succeeded. + m.events.Publish(events.TypeAccounts, after.ID, "", nil) + return err +} + +func (m *Manager) syncAccount(ctx context.Context, before, after Account) error { // Request sanitization applies per request, so sync it into the pool // without restarting anything. if before.DropSystemPrompt != after.DropSystemPrompt { @@ -92,6 +102,7 @@ func (m *Manager) Create(ctx context.Context, input CreateAccount) (Account, err return account, err } } + m.events.Publish(events.TypeAccounts, account.ID, "", nil) return account, nil } @@ -182,6 +193,7 @@ func (m *Manager) Import(ctx context.Context, input ImportAccount) (Account, err return account, err } } + m.events.Publish(events.TypeAccounts, account.ID, "", nil) return m.store.Get(ctx, account.ID) } @@ -224,6 +236,12 @@ func (m *Manager) AccountView(ctx context.Context, id string) (AccountView, erro view.LastErrorKind = item.LastKind } } + if m.forceReady(account.ID) { + // The pool carries the routing override; the console shows the real + // stored snapshot and badges the override instead. + view.ForceReadyOverride = true + view.Quota = account.Quota + } reconcileExpiredCooldown(&view, time.Now()) return view, nil } @@ -263,6 +281,10 @@ func (m *Manager) Accounts(ctx context.Context) ([]AccountView, error) { view.LastErrorKind = item.LastKind } } + if m.forceReady(account.ID) { + view.ForceReadyOverride = true + view.Quota = account.Quota + } reconcileExpiredCooldown(&view, time.Now()) views = append(views, view) } diff --git a/internal/runtime/manager_maintenance.go b/internal/runtime/manager_maintenance.go index 7407e097..c27ef746 100644 --- a/internal/runtime/manager_maintenance.go +++ b/internal/runtime/manager_maintenance.go @@ -6,26 +6,39 @@ import ( "fmt" "hash/fnv" "log" + "strconv" "strings" "sync" + "sync/atomic" "time" _ "time/tzdata" "github.com/caigee-cmd/cli2api/internal/accounts" + "github.com/caigee-cmd/cli2api/internal/events" "github.com/caigee-cmd/cli2api/internal/providers" "github.com/caigee-cmd/cli2api/internal/providers/qoder" ) func (manager *Manager) CheckinAccount(ctx context.Context, accountID string) (Account, error) { - return manager.checkinAccount(ctx, accountID, false, false) + outcome, err := manager.checkinAccount(ctx, accountID, false, false) + return outcome.account, err +} + +// checkinOutcome carries the real per-attempt facts a bulk pass reports: +// the updated account, the provider's verbatim check-in result (including the +// real reward amount), and whether the post-check-in quota fetch persisted. +type checkinOutcome struct { + account Account + result providers.CheckinResult + quotaRefreshed bool } // CheckinAll runs a manual all-account pass on the server. It selects from the // full store instead of the browser's current page/filter, honors the system // "check in disabled accounts" setting, and reports every account outcome. -// Manual passes use bounded concurrency instead of the scheduled loop's -// inter-account gap: waiting on the UI for 13 sequential network check-ins is -// unacceptable, while four in flight keeps upstream bursts modest. +// All target accounts start concurrently (full fan-out): there is no +// concurrency cap and no inter-account gap. The per-account checkinRunning +// gate still deduplicates an overlapping manual/scheduled attempt. func (manager *Manager) CheckinAll(ctx context.Context, force, includeDisabled bool) ([]accounts.CheckinAllResult, error) { if manager == nil { return nil, fmt.Errorf("account manager unavailable") @@ -48,44 +61,69 @@ func (manager *Manager) CheckinAll(ctx context.Context, force, includeDisabled b targets = append(targets, item) } results := make([]accounts.CheckinAllResult, len(targets)) + opID := newOpID() + total := len(targets) + var done atomic.Int64 + manager.events.Publish(events.TypeBulk, "", opID, events.BulkProgress{OpID: opID, Kind: "checkin", Phase: "start", Total: total}) var wg sync.WaitGroup - sem := make(chan struct{}, manualCheckinConcurrency) - started := 0 -loop: for i, item := range targets { - select { - case sem <- struct{}{}: - case <-ctx.Done(): - break loop + if ctx.Err() != nil { + // Report the accounts that never started as unknown, never success. + for j := i; j < len(targets); j++ { + results[j] = accounts.CheckinAllResult{ + AccountID: targets[j].ID, + Provider: targets[j].Provider, + Region: targets[j].ProviderRegion, + Status: "unknown", + Message: ctx.Err().Error(), + } + } + break } - started = i + 1 wg.Add(1) go func(index int, account accounts.Account) { defer wg.Done() - defer func() { <-sem }() - updated, checkErr := manager.checkinAccount(ctx, account.ID, includeDisabled, force) + outcome, checkErr := manager.checkinAccount(ctx, account.ID, includeDisabled, force) + updated := outcome.account result := accounts.CheckinAllResult{ - AccountID: account.ID, - Provider: account.Provider, - Region: account.ProviderRegion, - Status: updated.LastCheckinStatus, - Message: updated.LastCheckinMsg, + AccountID: account.ID, + Provider: account.Provider, + Region: account.ProviderRegion, + Status: updated.LastCheckinStatus, + Message: updated.LastCheckinMsg, + RewardCredits: outcome.result.RewardCredits, + QuotaRefreshed: outcome.quotaRefreshed, } if result.Status == "" { - result.Status = "success" + // No recorded status is not evidence of success. + result.Status = "unknown" + if result.Message == "" { + result.Message = "no check-in status recorded" + } } if checkErr != nil { result.Status = "error" if result.Message == "" { result.Message = checkErr.Error() } + var providerErr *providers.Error + if errors.As(checkErr, &providerErr) && providerErr != nil { + result.Code = providerErr.Code + result.Kind = providerErr.Kind + result.HTTPStatus = providerErr.Status + } } results[index] = result + manager.events.Publish(events.TypeBulk, account.ID, opID, events.BulkProgress{ + OpID: opID, Kind: "checkin", Phase: "account", Total: total, + Done: int(done.Add(1)), AccountID: account.ID, Result: result, + }) }(i, item) } wg.Wait() + manager.events.Publish(events.TypeBulk, "", opID, events.BulkProgress{OpID: opID, Kind: "checkin", Phase: "done", Total: total, Done: int(done.Load())}) if ctx.Err() != nil { - return results[:started], ctx.Err() + return results, ctx.Err() } // Verify the claims against upstream after the pass; this refreshes the // true today flag and the derived auto schedule without delaying the UI. @@ -94,9 +132,9 @@ loop: return results, nil } -func (manager *Manager) checkinAccount(ctx context.Context, accountID string, allowDisabled, force bool) (Account, error) { +func (manager *Manager) checkinAccount(ctx context.Context, accountID string, allowDisabled, force bool) (checkinOutcome, error) { if manager == nil { - return Account{}, fmt.Errorf("account manager unavailable") + return checkinOutcome{}, fmt.Errorf("account manager unavailable") } manager.mu.Lock() if manager.checkinRunning == nil { @@ -104,7 +142,7 @@ func (manager *Manager) checkinAccount(ctx context.Context, accountID string, al } if manager.checkinRunning[accountID] { manager.mu.Unlock() - return Account{}, fmt.Errorf("check-in is already running for this account") + return checkinOutcome{}, fmt.Errorf("check-in is already running for this account") } manager.checkinRunning[accountID] = true manager.mu.Unlock() @@ -115,19 +153,19 @@ func (manager *Manager) checkinAccount(ctx context.Context, accountID string, al }() account, err := manager.store.Get(ctx, accountID) if err != nil { - return Account{}, err + return checkinOutcome{}, err } if !account.Enabled && !allowDisabled { - return account, fmt.Errorf("account is disabled") + return checkinOutcome{account: account}, fmt.Errorf("account is disabled") } policy, supported := providers.CheckinFor(account.Provider, account.ProviderRegion) adapter, registered := manager.providers.Get(account.Provider) if !supported || !registered || adapter.Checkin == nil { - return account, providers.ErrUnsupported + return checkinOutcome{account: account}, providers.ErrUnsupported } location, err := time.LoadLocation(policy.Timezone) if err != nil { - return account, fmt.Errorf("invalid check-in timezone: %w", err) + return checkinOutcome{account: account}, fmt.Errorf("invalid check-in timezone: %w", err) } ctx, cancel := context.WithTimeout(ctx, 90*time.Second) defer cancel() @@ -136,11 +174,16 @@ func (manager *Manager) checkinAccount(ctx context.Context, accountID string, al if !force && CheckedInLocalDay(account.LastCheckinAt, account.LastCheckinStatus, time.Now().In(location)) { if account.Provider == "workbuddy" { if err := manager.clearCheckinCooldown(ctx, accountID); err != nil { - return account, fmt.Errorf("clear cooldown after check-in: %w", err) + return checkinOutcome{account: account}, fmt.Errorf("clear cooldown after check-in: %w", err) } } - manager.refreshCheckinQuota(ctx, accountID, adapter) - return manager.store.Get(ctx, accountID) + refreshed := manager.refreshCheckinQuota(ctx, accountID, adapter) + updated, getErr := manager.store.Get(ctx, accountID) + return checkinOutcome{ + account: updated, + result: providers.CheckinResult{Status: "already", Message: account.LastCheckinMsg}, + quotaRefreshed: refreshed, + }, getErr } result, checkErr := adapter.Checkin.Checkin(ctx, accountID) if checkErr == nil && !result.Valid() { @@ -153,29 +196,36 @@ func (manager *Manager) checkinAccount(ctx context.Context, accountID string, al recordErr := manager.store.RecordCheckin(recordCtx, accountID, result.Status, result.Message, time.Now().UTC()) stopRecording() if recordErr != nil { - return account, errors.Join(checkErr, fmt.Errorf("save check-in result: %w", recordErr)) - } + return checkinOutcome{account: account, result: result}, errors.Join(checkErr, fmt.Errorf("save check-in result: %w", recordErr)) + } + manager.events.Publish(events.TypeCheckin, accountID, "", events.CheckinState{ + AccountID: accountID, + Status: result.Status, + Message: result.Message, + RewardCredits: result.RewardCredits, + At: time.Now().UTC().Format(time.RFC3339), + }) if account.Provider == "workbuddy" && (result.Status == "success" || result.Status == "already") { if err := manager.clearCheckinCooldown(ctx, accountID); err != nil { - return account, errors.Join(checkErr, fmt.Errorf("clear cooldown after check-in: %w", err)) + return checkinOutcome{account: account, result: result}, errors.Join(checkErr, fmt.Errorf("clear cooldown after check-in: %w", err)) } } + quotaRefreshed := false if result.Status != "skipped" { - manager.refreshCheckinQuota(ctx, accountID, adapter) + quotaRefreshed = manager.refreshCheckinQuota(ctx, accountID, adapter) } readCtx, stopReading := context.WithTimeout(context.WithoutCancel(ctx), 5*time.Second) defer stopReading() updated, err := manager.store.Get(readCtx, accountID) - return updated, errors.Join(checkErr, err) + return checkinOutcome{account: updated, result: result, quotaRefreshed: quotaRefreshed}, errors.Join(checkErr, err) } const ( // checkinStatusInterval is how often the console refreshes the true // upstream check-in state. Verification is read-only and bounded; it never // claims a reward. - checkinStatusInterval = 15 * time.Minute - checkinStatusTimeout = 75 * time.Second - checkinStatusConcurrency = 4 + checkinStatusInterval = 15 * time.Minute + checkinStatusTimeout = 75 * time.Second // A real check-in can take a few seconds to become visible upstream. Do not // downgrade a local success inside this grace window. checkinStatusGrace = 15 * time.Minute @@ -217,18 +267,13 @@ func (manager *Manager) SyncCheckinStatuses(ctx context.Context) { candidates = append(candidates, account) } var wg sync.WaitGroup - sem := make(chan struct{}, checkinStatusConcurrency) for _, account := range candidates { - select { - case sem <- struct{}{}: - case <-ctx.Done(): - wg.Wait() - return + if ctx.Err() != nil { + break } wg.Add(1) go func(account Account) { defer wg.Done() - defer func() { <-sem }() manager.syncCheckinStatus(ctx, account) }(account) } @@ -275,15 +320,18 @@ func (manager *Manager) syncCheckinStatus(ctx context.Context, account Account) if busy { return } - earliest := strings.TrimSpace(result.EarliestCheckin) - if earliest == "" { - earliest = accounts.EarliestCheckinClock(account.Provider) - } update := accounts.CheckinStatusUpdate{ Source: "upstream", - AutoTime: accounts.AutoCheckinTimeFromEarliest(earliest), SyncedAt: now, } + // The provider check-in time setting is the single source of truth for the + // automatic schedule and defaults to 09:00 for every provider. Upstream + // payloads only report status; they must not reschedule the claim. The + // stored auto time is rewritten on every sync so the console row follows the + // setting even when another client changed it. + if value, err := accounts.CheckinTimeDefault(ctx, manager.store, account.Provider); err == nil { + update.AutoTime = value + } if readErr != nil { update.Status = "unknown" update.Message = "上游状态同步失败:" + readErr.Error() @@ -338,7 +386,14 @@ func (manager *Manager) syncCheckinStatus(ctx context.Context, account Account) defer cancelPersist() if err := manager.store.RecordCheckinStatus(persistCtx, account.ID, update); err != nil { log.Printf("checkin status account=%s: %v", account.ID, err) + return } + manager.events.Publish(events.TypeCheckin, account.ID, "", events.CheckinState{ + AccountID: account.ID, + Status: update.Status, + Message: update.Message, + At: now.UTC().Format(time.RFC3339), + }) } func (manager *Manager) clearCheckinCooldown(ctx context.Context, accountID string) error { @@ -358,13 +413,15 @@ func (manager *Manager) clearCheckinCooldown(ctx context.Context, accountID stri return manager.poolState.SaveCooldowns(persistCtx, accountID, nil) } -func (manager *Manager) refreshCheckinQuota(ctx context.Context, accountID string, adapter providers.Adapter) { +// refreshCheckinQuota refreshes the real upstream balance after a check-in and +// reports whether a fresh snapshot was persisted. +func (manager *Manager) refreshCheckinQuota(ctx context.Context, accountID string, adapter providers.Adapter) bool { if ctx.Err() != nil { - return + return false } account, err := manager.store.Get(ctx, accountID) if err != nil { - return + return false } // Qoder check-in lands its reward in the OpenAPI add-on bucket. Refresh the // real upstream OpenAPI quota in-process explicitly (the same force path the @@ -373,31 +430,33 @@ func (manager *Manager) refreshCheckinQuota(ctx context.Context, accountID strin if account.Provider == "qoder" { if registered, ok := manager.providers.Get(account.Provider); ok { if q, ok := registered.Chat.(*qoder.Client); ok { - manager.refreshQoderQuota(ctx, accountID, q) - return + return manager.refreshQoderQuota(ctx, accountID, q) } } } if adapter.Prober != nil { - manager.fetchProviderQuota(ctx, accountID, adapter.Prober) - } else if workerURL, found := manager.AccountURL(accountID); found { - manager.fetchQuota(ctx, accountID, workerURL, true) + return manager.fetchProviderQuotaErr(ctx, accountID, adapter.Prober) == nil + } + if workerURL, found := manager.AccountURL(accountID); found { + return manager.fetchQuota(ctx, accountID, workerURL, true) == nil } + return false } // refreshQoderQuota pulls the real upstream OpenAPI quota (which includes the // daily check-in add-on grant) and persists it. It never synthesizes a number. -func (manager *Manager) refreshQoderQuota(ctx context.Context, accountID string, client *qoder.Client) { +func (manager *Manager) refreshQoderQuota(ctx context.Context, accountID string, client *qoder.Client) bool { // quotaSnapshot already refreshes upstream itself; do not take the shared // quota-fetch gate here, or a concurrent fetchProviderQuotaErr (manual // refresh) would deadlock until this returns. snapshot, err := client.QuotaSnapshot(ctx, accountID, true) if err != nil || snapshot == nil { - return + return false } persistCtx, cancel := context.WithTimeout(context.WithoutCancel(ctx), 5*time.Second) defer cancel() manager.persistQuota(persistCtx, accountID, snapshot) + return true } func CheckedInLocalDay(at, status string, now time.Time) bool { @@ -416,43 +475,14 @@ func recordedToday(at string, now time.Time) bool { return local.Year() == now.Year() && local.YearDay() == now.YearDay() } -// Cross-account burst limits for scheduled check-in / WorkBuddy keepalive. -// One 30s maintenance tick processes at most maintenancePerTickCap due -// accounts, with maintenanceAccountGap (+ FNV jitter) between them, so a -// large AutoCheckin fleet is spread across successive ticks instead of -// hammering upstream in one burst. -const ( - keepaliveTickTimeout = 90 * time.Second - maintenanceGapJitterMS = 1000 - // manualCheckinConcurrency caps a user-triggered one-click check-in. It is - // independent of the scheduled loop's per-tick cap and gap. - manualCheckinConcurrency = 4 -) - -// Defaults are conservative; tests may override the vars to skip real sleeps. -var ( - maintenancePerTickCap = 2 - maintenanceAccountGap = 2 * time.Second -) - -// maintenanceAccountGapFor returns base delay plus a stable 0..(jitter-1)ms -// offset derived from accountID (same FNV style as checkinSlot). -func maintenanceAccountGapFor(accountID string, base time.Duration) time.Duration { - hash := fnv.New32a() - _, _ = hash.Write([]byte(accountID)) - return base + time.Duration(hash.Sum32()%uint32(maintenanceGapJitterMS))*time.Millisecond -} - -func sleepMaintenanceGap(ctx context.Context, accountID string, base time.Duration) bool { - timer := time.NewTimer(maintenanceAccountGapFor(accountID, base)) - defer timer.Stop() - select { - case <-ctx.Done(): - return false - case <-timer.C: - return true - } -} +// Scheduled check-in / WorkBuddy keepalive fan out every due account in one +// tick concurrently. There is no per-tick cap and no inter-account gap: the +// per-account checkinSlot second-level hash jitter (0..59s inside the +// configured minute) is the schedule itself and naturally spreads starts, +// while per-account single-flight gates deduplicate overlapping attempts. +// Real upstream rate limits surface as genuine 429 classifications and the +// executor cooldown/failover handles them — never hidden by client queuing. +const keepaliveTickTimeout = 90 * time.Second func checkinSlot(value, accountID string, now time.Time) (time.Time, error) { parsed, err := time.Parse("15:04", value) @@ -503,10 +533,10 @@ func (manager *Manager) runScheduledCheckins(ctx context.Context, now time.Time) return } allowDisabled := manager.allowDisabledCheckin(ctx) - processed := 0 + var wg sync.WaitGroup for _, account := range items { if ctx.Err() != nil { - return + break } policy, supported := providers.CheckinFor(account.Provider, account.ProviderRegion) adapter, registered := manager.providers.Get(account.Provider) @@ -526,18 +556,15 @@ func (manager *Manager) runScheduledCheckins(ctx context.Context, now time.Time) if !checkinDueFor(account, configuredTime, now.In(location), allowDisabled) { continue } - if processed >= maintenancePerTickCap { - // Remaining due accounts stay due; the next 30s tick picks them up. - return - } - if processed > 0 && !sleepMaintenanceGap(ctx, account.ID, maintenanceAccountGap) { - return - } - if _, err := manager.checkinAccount(ctx, account.ID, allowDisabled, false); err != nil { - log.Printf("checkin account=%s: %v", account.ID, err) - } - processed++ + wg.Add(1) + go func(account accounts.Account) { + defer wg.Done() + if _, err := manager.checkinAccount(ctx, account.ID, allowDisabled, false); err != nil { + log.Printf("checkin account=%s: %v", account.ID, err) + } + }(account) } + wg.Wait() } func (manager *Manager) CheckinOptedIn(ctx context.Context) { @@ -551,6 +578,7 @@ func (manager *Manager) checkinOptedIn(ctx context.Context, now time.Time, sched return } allowDisabled := manager.allowDisabledCheckin(ctx) + var wg sync.WaitGroup for _, account := range items { if (!account.Enabled && !allowDisabled) || !account.AutoCheckin { continue @@ -568,10 +596,15 @@ func (manager *Manager) checkinOptedIn(ctx context.Context, now time.Time, sched continue } } - if _, err := manager.checkinAccount(ctx, account.ID, allowDisabled, false); err != nil { - log.Printf("checkin account=%s: %v", account.ID, err) - } + wg.Add(1) + go func(account accounts.Account) { + defer wg.Done() + if _, err := manager.checkinAccount(ctx, account.ID, allowDisabled, false); err != nil { + log.Printf("checkin account=%s: %v", account.ID, err) + } + }(account) } + wg.Wait() } func (manager *Manager) allowDisabledCheckin(ctx context.Context) bool { @@ -587,11 +620,11 @@ func (manager *Manager) allowDisabledCheckin(ctx context.Context) bool { } } -// KeepaliveWorkBuddy refreshes WorkBuddy sessions. At most -// maintenancePerTickCap accounts are processed per call, with -// maintenanceAccountGap between them. done tracks account IDs already -// refreshed for the current local day; pass the same map across successive -// maintenance ticks. Returns true when more eligible accounts remain. +// KeepaliveWorkBuddy refreshes WorkBuddy sessions. Every eligible account is +// refreshed concurrently in one call (full fan-out, no cap or gap). done +// tracks account IDs already refreshed for the current local day; pass the +// same map across successive maintenance ticks. Returns true only when the +// context ended before every pending account could start. func (manager *Manager) KeepaliveWorkBuddy(ctx context.Context, onlyOptIn bool, done map[string]struct{}) (more bool) { if manager == nil || manager.workbuddy == nil { return false @@ -617,24 +650,24 @@ func (manager *Manager) KeepaliveWorkBuddy(ctx context.Context, onlyOptIn bool, if len(pending) == 0 { return false } - batch := pending - if len(batch) > maintenancePerTickCap { - batch = batch[:maintenancePerTickCap] - more = true - } - for i, accountID := range batch { + var wg sync.WaitGroup + for _, accountID := range pending { if ctx.Err() != nil { return true } - if i > 0 && !sleepMaintenanceGap(ctx, accountID, maintenanceAccountGap) { - return true - } - if err := manager.workbuddy.Keepalive(ctx, accountID); err != nil { - log.Printf("workbuddy keepalive account=%s: %v", accountID, err) - } - done[accountID] = struct{}{} + wg.Add(1) + go func(accountID string) { + defer wg.Done() + if err := manager.workbuddy.Keepalive(ctx, accountID); err != nil { + log.Printf("workbuddy keepalive account=%s: %v", accountID, err) + } + manager.mu.Lock() + done[accountID] = struct{}{} + manager.mu.Unlock() + }(accountID) } - return more + wg.Wait() + return ctx.Err() != nil } func (manager *Manager) RunMaintenanceLoop(stop <-chan struct{}) { @@ -655,6 +688,7 @@ func (manager *Manager) RunMaintenanceLoop(stop <-chan struct{}) { // Seed the throttle so the first pass does not duplicate the boot-time // RefreshAll: the next stale-quota sweep runs 5 minutes after startup. lastStaleQuota := time.Now() + lastQuotaFresh := time.Now() lastCheckinStatusSync := time.Time{} // Liveness probes start one tick in so boot-time RefreshAll owns the first // /health round-trip and short-lived tests with a stub worker are not probed @@ -694,6 +728,10 @@ func (manager *Manager) RunMaintenanceLoop(stop <-chan struct{}) { manager.refreshStaleQuota(ctx) lastStaleQuota = now } + if freshInterval := manager.quotaFreshInterval(ctx); freshInterval > 0 && now.Sub(lastQuotaFresh) >= freshInterval { + lastQuotaFresh = now + go manager.refreshQuotaFresh(ctx) + } select { case <-ctx.Done(): return @@ -707,6 +745,68 @@ func (manager *Manager) RunMaintenanceLoop(stop <-chan struct{}) { // decides whether a given account is actually re-fetched on that sweep. const staleQuotaInterval = 5 * time.Minute +// quotaFreshInterval reads the configurable background quota-freshness sweep +// cadence. Zero disables the sweep; unset uses the default. +func (manager *Manager) quotaFreshInterval(ctx context.Context) time.Duration { + value, ok, err := manager.store.GetSecret(ctx, accounts.QuotaFreshIntervalSecret) + if err != nil || !ok || strings.TrimSpace(value) == "" { + return accounts.DefaultQuotaFreshIntervalSeconds * time.Second + } + seconds, err := strconv.Atoi(strings.TrimSpace(value)) + if err != nil { + return accounts.DefaultQuotaFreshIntervalSeconds * time.Second + } + normalized, err := accounts.NormalizeQuotaFreshIntervalSeconds(seconds) + if err != nil { + return accounts.DefaultQuotaFreshIntervalSeconds * time.Second + } + return time.Duration(normalized) * time.Second +} + +// refreshQuotaFresh re-fetches the real upstream balance of every healthy +// routable account concurrently so console credit readings stay current +// without a manual refresh. Exhausted accounts are left to refreshStaleQuota's +// backoff ladder; the per-account quota-fetch gate deduplicates overlapping +// fetches. Only one sweep runs at a time. +func (manager *Manager) refreshQuotaFresh(ctx context.Context) { + if manager == nil || manager.pool == nil { + return + } + manager.mu.Lock() + if manager.quotaFreshRunning { + manager.mu.Unlock() + return + } + manager.quotaFreshRunning = true + manager.mu.Unlock() + defer func() { + manager.mu.Lock() + manager.quotaFreshRunning = false + manager.mu.Unlock() + }() + now := time.Now() + var wg sync.WaitGroup + for _, item := range manager.pool.Items() { + if ctx.Err() != nil { + break + } + if item.RuntimeState == "dead" { + continue + } + if manager.quotaNeedsRevalidationFor(item, now) { + continue + } + wg.Add(1) + go func(item Item) { + defer wg.Done() + refreshCtx, cancel := context.WithTimeout(ctx, 15*time.Second) + defer cancel() + manager.refreshQuotaOnly(refreshCtx, item) + }(item) + } + wg.Wait() +} + // quotaProbeBackoff is the per-account wait between consecutive quota probes // while an account keeps reporting Exceeded, indexed by the number of // consecutive exhausted probes already spent. The first few probes stay at diff --git a/internal/runtime/manager_probe.go b/internal/runtime/manager_probe.go index 717dd22e..9bb93fae 100644 --- a/internal/runtime/manager_probe.go +++ b/internal/runtime/manager_probe.go @@ -2,17 +2,33 @@ package runtime import ( "context" + "crypto/rand" + "encoding/hex" "errors" "fmt" "os" "path/filepath" "strings" + "sync" + "sync/atomic" "time" + "github.com/caigee-cmd/cli2api/internal/accounts" + "github.com/caigee-cmd/cli2api/internal/events" "github.com/caigee-cmd/cli2api/internal/providers" "github.com/caigee-cmd/cli2api/internal/providers/qoder" ) +// newOpID identifies one bulk operation so the console can correlate its +// per-account progress events. +func newOpID() string { + var buf [8]byte + if _, err := rand.Read(buf[:]); err != nil { + return fmt.Sprintf("op-%d", time.Now().UnixNano()) + } + return hex.EncodeToString(buf[:]) +} + // Health/probe scheduling. Quota fetch failures must not flip Ready. // Reads pool items and writes runtime/health via existing Merge/Set helpers. @@ -20,23 +36,29 @@ func (m *Manager) RefreshAccount(ctx context.Context, id string, forceQuota bool if m == nil || m.pool == nil { return fmt.Errorf("account manager not ready") } - item, ok := m.pool.ByID(id) - if ok { - return m.refreshOne(ctx, item, forceQuota) - } - // Disabled accounts are deliberately kept out of the routing pool, so they - // have no pool item to refresh. Refresh their health and quota straight - // through the provider adapter instead of failing closed: the operator may - // still want to inspect a disabled account's live status/credits. Nothing - // is written back into the pool, so the account stays out of routing. - account, err := m.store.Get(ctx, id) - if err != nil { - return err - } - if account.Enabled { - return fmt.Errorf("account %s is not running", id) + var err error + provider, region := "", "" + if item, ok := m.pool.ByID(id); ok { + provider, region = item.Provider, item.Region + err = m.refreshOne(ctx, item, forceQuota) + } else { + // Disabled accounts are deliberately kept out of the routing pool, so they + // have no pool item to refresh. Refresh their health and quota straight + // through the provider adapter instead of failing closed: the operator may + // still want to inspect a disabled account's live status/credits. Nothing + // is written back into the pool, so the account stays out of routing. + account, getErr := m.store.Get(ctx, id) + if getErr != nil { + return getErr + } + if account.Enabled { + return fmt.Errorf("account %s is not running", id) + } + provider, region = account.Provider, account.ProviderRegion + err = m.refreshDetached(ctx, account, forceQuota) } - return m.refreshDetached(ctx, account, forceQuota) + m.events.Publish(events.TypeRefresh, id, "", m.refreshResult(ctx, id, provider, region, err)) + return err } // DetachedRefreshError reports that a disabled account cannot be refreshed. It @@ -125,23 +147,146 @@ func (m *Manager) refreshDetached(ctx context.Context, account Account, forceQuo } // AccountView returns the same projection the accounts list builds, for one +// RefreshAll refreshes every routable account concurrently (full fan-out, no +// inter-account queue) and joins the non-quota failures. Quota refresh +// failures stay best-effort for background maintenance; the per-account +// detail is available through RefreshAllResults. func (m *Manager) RefreshAll(ctx context.Context, forceQuota bool) error { var joined error - for _, item := range m.pool.Items() { - if err := m.refreshOne(ctx, item, forceQuota); err != nil { - var quotaErr *QuotaRefreshError - if errors.As(err, "aErr) { - // Background maintenance must remain best-effort. The manual - // single-account endpoint still returns this typed error so the - // console can show that quota refresh did not complete. - continue - } - joined = errors.Join(joined, err) + for _, result := range m.RefreshAllResults(ctx, forceQuota, false) { + if result.OK || result.Code == "quota_refresh_failed" { + continue } + joined = errors.Join(joined, fmt.Errorf("account %s: %s", result.AccountID, result.Message)) } return joined } +// RefreshAllResults refreshes every account concurrently and reports each +// account's real outcome. All accounts start at once: there is no semaphore +// and no inter-account gap; per-account single-flight gates (quota fetch, +// check-in running) still deduplicate overlapping work. When includeDisabled +// is set, disabled accounts are refreshed through the detached probe path in +// the same fan-out without re-entering the routing pool. +func (m *Manager) RefreshAllResults(ctx context.Context, forceQuota, includeDisabled bool) []accounts.AccountRefreshResult { + if m == nil || m.pool == nil { + return nil + } + items := m.pool.Items() + var detached []Account + if includeDisabled { + if stored, err := m.store.List(ctx); err == nil { + for _, account := range stored { + if !account.Enabled { + detached = append(detached, account) + } + } + } + } + results := make([]accounts.AccountRefreshResult, len(items)+len(detached)) + opID := newOpID() + total := len(results) + var done atomic.Int64 + m.events.Publish(events.TypeBulk, "", opID, events.BulkProgress{OpID: opID, Kind: "refresh", Phase: "start", Total: total}) + publish := func(result accounts.AccountRefreshResult) { + m.events.Publish(events.TypeRefresh, result.AccountID, opID, result) + m.events.Publish(events.TypeBulk, result.AccountID, opID, events.BulkProgress{ + OpID: opID, Kind: "refresh", Phase: "account", Total: total, + Done: int(done.Add(1)), AccountID: result.AccountID, Result: result, + }) + } + var wg sync.WaitGroup + for i, item := range items { + wg.Add(1) + go func(index int, item Item) { + defer wg.Done() + err := m.refreshOne(ctx, item, forceQuota) + results[index] = m.refreshResult(ctx, item.ID, item.Provider, item.Region, err) + publish(results[index]) + }(i, item) + } + for i, account := range detached { + wg.Add(1) + go func(index int, account Account) { + defer wg.Done() + err := m.refreshDetached(ctx, account, forceQuota) + results[len(items)+index] = m.refreshResult(ctx, account.ID, account.Provider, account.ProviderRegion, err) + publish(results[len(items)+index]) + }(i, account) + } + wg.Wait() + m.events.Publish(events.TypeBulk, "", opID, events.BulkProgress{OpID: opID, Kind: "refresh", Phase: "done", Total: total, Done: total}) + return results +} + +// RefreshAllAsync triggers a full concurrent refresh in the background bound +// to the manager lifecycle. Per-account outcomes are persisted (status, +// last_error, quota) and published on the event bus, so no error is swallowed. +func (m *Manager) RefreshAllAsync(ctx context.Context, forceQuota, includeDisabled bool) { + if m == nil { + return + } + go func() { + bg, cancel := context.WithTimeout(context.WithoutCancel(ctx), 90*time.Second) + defer cancel() + stop := context.AfterFunc(m.runCtx, cancel) + defer stop() + m.RefreshAllResults(bg, forceQuota, includeDisabled) + }() +} + +// refreshResult projects the real post-refresh state of one account: the +// persisted status/error from the store and the live quota snapshot from the +// pool (or the store for detached accounts). The probe error is carried +// verbatim; typed provider errors contribute their real code/kind/status. +func (m *Manager) refreshResult(ctx context.Context, accountID, provider, region string, err error) accounts.AccountRefreshResult { + result := accounts.AccountRefreshResult{ + AccountID: accountID, + Provider: provider, + Region: region, + OK: err == nil, + } + if err != nil { + result.Message = err.Error() + var quotaErr *QuotaRefreshError + if errors.As(err, "aErr) { + result.Code = "quota_refresh_failed" + } + var providerErr *providers.Error + if errors.As(err, &providerErr) && providerErr != nil { + if result.Code == "" { + result.Code = providerErr.Code + } + result.Kind = providerErr.Kind + result.HTTPStatus = providerErr.Status + } + } + readCtx, cancel := context.WithTimeout(context.WithoutCancel(ctx), 5*time.Second) + defer cancel() + if stored, getErr := m.store.Get(readCtx, accountID); getErr == nil { + result.Status = stored.Status + if result.Message == "" { + result.Message = stored.LastError + } + if result.Kind == "" { + result.Kind = stored.LastErrorKind + } + if result.Provider == "" { + result.Provider = stored.Provider + } + if result.Region == "" { + result.Region = stored.ProviderRegion + } + if stored.Quota != nil { + result.Quota = stored.Quota + } + } + if item, ok := m.pool.ByID(accountID); ok && item.Quota != nil { + result.Quota = item.Quota + } + return result +} + func (m *Manager) refreshOne(ctx context.Context, item Item, forceQuota bool) error { if item.RuntimeState == "dead" { return nil diff --git a/internal/runtime/manager_quota.go b/internal/runtime/manager_quota.go index 0caf7d11..9e93650b 100644 --- a/internal/runtime/manager_quota.go +++ b/internal/runtime/manager_quota.go @@ -9,6 +9,7 @@ import ( "time" "github.com/caigee-cmd/cli2api/internal/accounts" + "github.com/caigee-cmd/cli2api/internal/events" "github.com/caigee-cmd/cli2api/internal/providers" "github.com/caigee-cmd/cli2api/internal/providers/qoder" ) @@ -212,22 +213,28 @@ func (m *Manager) persistQuota(ctx context.Context, accountID string, quota *Quo if quota == nil { return } + // Storage and the console always carry the real upstream snapshot. The + // local/dev force-ready override (marker file + // $QODER_DATA_DIR/force-ready/) only affects routing: it is + // applied to a copy merged into the pool, never persisted, and the view + // badges it so no displayed number is silently fabricated. + routed := quota if m.forceReady(accountID) { - // Local/dev override: keep the account routable even when upstream - // still reports a hard zero balance. Marker file: - // $QODER_DATA_DIR/force-ready/ - quota.Exceeded = false - if quota.Remaining <= 0 { - quota.Remaining = 1 + override := *quota + override.Exceeded = false + if override.Remaining <= 0 { + override.Remaining = 1 } - if quota.Percentage >= 100 { - quota.Percentage = 99 + if override.Percentage >= 100 { + override.Percentage = 99 } + routed = &override } - m.pool.MergeQuota(accountID, quota) + m.pool.MergeQuota(accountID, routed) if err := m.store.SaveQuota(ctx, accountID, quota); err != nil { log.Printf("persist quota account=%s: %v", accountID, err) } + m.events.Publish(events.TypeQuota, accountID, "", events.QuotaState{AccountID: accountID, Quota: quota}) } func (m *Manager) fetchQuota(ctx context.Context, accountID, workerURL string, force bool) error { diff --git a/internal/server/router.go b/internal/server/router.go index 7780ca06..3830eb71 100644 --- a/internal/server/router.go +++ b/internal/server/router.go @@ -13,6 +13,7 @@ func (s *Server) routes() { s.mux.HandleFunc("/api/overview", s.withConsoleKey(s.consoleHandler().HandleOverview)) s.mux.HandleFunc("/api/overview/summary", s.withConsoleKey(s.consoleHandler().HandleOverviewSummary)) s.mux.HandleFunc("/api/live", s.withConsoleKey(s.consoleHandler().HandleLive)) + s.mux.HandleFunc("/api/events", s.withConsoleKey(s.consoleHandler().HandleEvents)) s.mux.HandleFunc("/api/system/update", s.withConsoleKey(s.consoleHandler().HandleSystemUpdate)) s.mux.HandleFunc("/api/system/update/prepare", s.withConsoleKey(s.consoleHandler().HandleSystemUpdatePrepare)) s.mux.HandleFunc("/api/system/update/apply", s.withConsoleKey(s.consoleHandler().HandleSystemUpdateConfirm)) @@ -37,6 +38,7 @@ func (s *Server) routes() { s.mux.HandleFunc("/api/accounts/export", s.withConsoleKey(s.consoleHandler().HandleAccountBundleExport)) s.mux.HandleFunc("/api/accounts/import/bundle", s.withConsoleKey(s.consoleHandler().HandleAccountBundleImport)) s.mux.HandleFunc("/api/accounts/checkin-all", s.withConsoleKey(s.consoleHandler().HandleCheckinAll)) + s.mux.HandleFunc("/api/accounts/refresh-all", s.withConsoleKey(s.consoleHandler().HandleRefreshAll)) s.mux.HandleFunc("/api/accounts/", s.withConsoleKey(s.consoleHandler().HandleAccountByID)) s.mux.HandleFunc("/api/logs", s.withConsoleKey(s.consoleHandler().HandleLogs)) s.mux.HandleFunc("/api/logs/", s.withConsoleKey(s.consoleHandler().HandleLogs)) diff --git a/internal/store/aggregation_account_test.go b/internal/store/aggregation_account_test.go index 3d53d8a4..75aab92f 100644 --- a/internal/store/aggregation_account_test.go +++ b/internal/store/aggregation_account_test.go @@ -33,3 +33,43 @@ func TestAggregationMemberAccountIDRoundTrip(t *testing.T) { t.Fatalf("members = %+v", saved.Members) } } + +func TestAggregationCapabilitiesRoundTrip(t *testing.T) { + s, err := OpenStore(filepath.Join(t.TempDir(), "aggregation-capabilities.db")) + if err != nil { + t.Fatal(err) + } + defer s.Close() + + agg := accounts.Aggregation{ + ID: "logical", Name: "Logical", Enabled: true, + Strategy: accounts.AggregationPriority, AllowFallbacks: true, MaxAttempts: 2, + ContextLength: 1_000_000, MaxOutputTokens: 32_000, + ReasoningOptions: []string{"low", "high", "max"}, ReasoningEffort: "high", + CreatedAt: time.Now().UTC(), UpdatedAt: time.Now().UTC(), + Members: []accounts.AggregationMember{{Provider: "qoder", Model: "model-a", Priority: 0, Weight: 100}}, + } + saved, err := s.InsertAggregation(context.Background(), agg) + if err != nil { + t.Fatal(err) + } + if saved.ContextLength != 1_000_000 || saved.MaxOutputTokens != 32_000 { + t.Fatalf("numeric overrides = %d/%d", saved.ContextLength, saved.MaxOutputTokens) + } + if len(saved.ReasoningOptions) != 3 || saved.ReasoningOptions[0] != "low" || saved.ReasoningEffort != "high" { + t.Fatalf("reasoning = %v %q", saved.ReasoningOptions, saved.ReasoningEffort) + } + + saved.ContextLength = 0 + saved.MaxOutputTokens = 0 + saved.ReasoningOptions = nil + saved.ReasoningEffort = "" + saved.UpdatedAt = time.Now().UTC() + cleared, err := s.SaveAggregation(context.Background(), saved) + if err != nil { + t.Fatal(err) + } + if cleared.ContextLength != 0 || cleared.MaxOutputTokens != 0 || len(cleared.ReasoningOptions) != 0 || cleared.ReasoningEffort != "" { + t.Fatalf("cleared = %+v", cleared) + } +} diff --git a/internal/store/aggregations.go b/internal/store/aggregations.go index 61239020..e7a112c7 100644 --- a/internal/store/aggregations.go +++ b/internal/store/aggregations.go @@ -5,6 +5,7 @@ import ( "crypto/rand" "database/sql" "encoding/hex" + "encoding/json" "errors" "fmt" "strings" @@ -63,7 +64,7 @@ func (s *Store) SaveAggregation(ctx context.Context, agg accounts.Aggregation) ( func (s *Store) ListAggregations(ctx context.Context) ([]accounts.Aggregation, error) { rows, err := s.db.QueryContext(ctx, ` -SELECT id, name, enabled, strategy, allow_fallbacks, max_attempts, created_at, updated_at +SELECT id, name, enabled, strategy, allow_fallbacks, max_attempts, context_length, max_output_tokens, reasoning_options, reasoning_effort, created_at, updated_at FROM aggregation_models ORDER BY created_at DESC, id DESC`) if err != nil { return nil, fmt.Errorf("list aggregations: %w", err) @@ -92,7 +93,7 @@ FROM aggregation_models ORDER BY created_at DESC, id DESC`) func (s *Store) GetAggregation(ctx context.Context, id string) (accounts.Aggregation, error) { row := s.db.QueryRowContext(ctx, ` -SELECT id, name, enabled, strategy, allow_fallbacks, max_attempts, created_at, updated_at +SELECT id, name, enabled, strategy, allow_fallbacks, max_attempts, context_length, max_output_tokens, reasoning_options, reasoning_effort, created_at, updated_at FROM aggregation_models WHERE id = ?`, strings.TrimSpace(id)) agg, err := scanAggregation(row) if errors.Is(err, sql.ErrNoRows) { @@ -133,16 +134,18 @@ func (s *Store) saveAggregation(ctx context.Context, agg accounts.Aggregation, i var result sql.Result if insert { result, err = tx.ExecContext(ctx, ` -INSERT INTO aggregation_models (id, name, enabled, strategy, allow_fallbacks, max_attempts, created_at, updated_at) -VALUES (?, ?, ?, ?, ?, ?, ?, ?)`, +INSERT INTO aggregation_models (id, name, enabled, strategy, allow_fallbacks, max_attempts, context_length, max_output_tokens, reasoning_options, reasoning_effort, created_at, updated_at) +VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`, agg.ID, agg.Name, boolToInt(agg.Enabled), string(agg.Strategy), boolToInt(agg.AllowFallbacks), agg.MaxAttempts, + agg.ContextLength, agg.MaxOutputTokens, encodeAggregationReasoningOptions(agg.ReasoningOptions), agg.ReasoningEffort, formatTime(agg.CreatedAt), formatTime(agg.UpdatedAt), ) } else { result, err = tx.ExecContext(ctx, ` -UPDATE aggregation_models SET name = ?, enabled = ?, strategy = ?, allow_fallbacks = ?, max_attempts = ?, updated_at = ? +UPDATE aggregation_models SET name = ?, enabled = ?, strategy = ?, allow_fallbacks = ?, max_attempts = ?, context_length = ?, max_output_tokens = ?, reasoning_options = ?, reasoning_effort = ?, updated_at = ? WHERE id = ?`, agg.Name, boolToInt(agg.Enabled), string(agg.Strategy), boolToInt(agg.AllowFallbacks), agg.MaxAttempts, + agg.ContextLength, agg.MaxOutputTokens, encodeAggregationReasoningOptions(agg.ReasoningOptions), agg.ReasoningEffort, formatTime(agg.UpdatedAt), agg.ID, ) } @@ -198,15 +201,42 @@ FROM aggregation_members WHERE agg_id = ? ORDER BY priority ASC, id ASC`, string func scanAggregation(row rowScanner) (accounts.Aggregation, error) { var agg accounts.Aggregation var enabled, allowFallbacks int + var reasoningOptions, reasoningEffort string var created, updated sql.NullString - if err := row.Scan(&agg.ID, &agg.Name, &enabled, &agg.Strategy, &allowFallbacks, &agg.MaxAttempts, &created, &updated); err != nil { + if err := row.Scan(&agg.ID, &agg.Name, &enabled, &agg.Strategy, &allowFallbacks, &agg.MaxAttempts, + &agg.ContextLength, &agg.MaxOutputTokens, &reasoningOptions, &reasoningEffort, &created, &updated); err != nil { return accounts.Aggregation{}, err } agg.Enabled = enabled != 0 agg.Strategy = accounts.NormalizeAggregationStrategy(string(agg.Strategy)) agg.AllowFallbacks = allowFallbacks != 0 + agg.ReasoningOptions = decodeAggregationReasoningOptions(reasoningOptions) + agg.ReasoningEffort = strings.TrimSpace(reasoningEffort) agg.CreatedAt = parseTime(created.String) agg.UpdatedAt = parseTime(updated.String) agg.Members = []accounts.AggregationMember{} return agg, nil } + +func encodeAggregationReasoningOptions(options []string) string { + if len(options) == 0 { + return "" + } + payload, err := json.Marshal(options) + if err != nil { + return "" + } + return string(payload) +} + +func decodeAggregationReasoningOptions(raw string) []string { + raw = strings.TrimSpace(raw) + if raw == "" { + return nil + } + var options []string + if err := json.Unmarshal([]byte(raw), &options); err != nil { + return nil + } + return options +} diff --git a/internal/store/backup_test.go b/internal/store/backup_test.go index 81969739..29204563 100644 --- a/internal/store/backup_test.go +++ b/internal/store/backup_test.go @@ -113,6 +113,7 @@ func TestPublishedMigrationsKeepOrderedFilenameAndSQLDigest(t *testing.T) { {"031_aggregations.sql", "3edaa45d50fe907d4ace839297d0264ad199ae19de97f007f248c6301239f928"}, {"032_aggregation_member_account.sql", "2e24df6d7363faf5f383887d589ab47bf2f0398f1e30338812066587dbf0ea01"}, {"033_account_checkin_status.sql", "0e4b4466a23d58eb9e7e370053ad7b52bc3285ea9461a8b99cac2bae88bba49d"}, + {"034_aggregation_capabilities.sql", "9a280f0afde18d33a6a278fe2577668c315abd88591d6aa1eebdfd3cf18ab74d"}, } if len(sqliteMigrations) != len(want) { t.Fatalf("migration count = %d, want %d", len(sqliteMigrations), len(want)) diff --git a/internal/store/checkin_test.go b/internal/store/checkin_test.go index 384fe85f..adf2ab2e 100644 --- a/internal/store/checkin_test.go +++ b/internal/store/checkin_test.go @@ -28,8 +28,8 @@ func TestProviderCheckinInheritanceAndReset(t *testing.T) { t.Fatal(err) } effective, err := accounts.ResolveCheckinTime(ctx, store, account) - if err != nil || effective != accounts.DefaultCheckinAutoTime(providerID) { - t.Fatalf("effective=%q err=%v", effective, err) + if err != nil || effective != "10:30" { + t.Fatalf("the provider setting must drive the schedule: effective=%q err=%v", effective, err) } if err := store.Update(ctx, account.ID, accounts.UpdateAccount{AutoCheckin: boolPtr(true), CheckinTime: stringPtr("18:30")}); err != nil { t.Fatal(err) @@ -53,7 +53,7 @@ func TestProviderCheckinInheritanceAndReset(t *testing.T) { t.Fatal(err) } effective, err = accounts.ResolveCheckinTime(ctx, store, account) - if err != nil || effective != accounts.DefaultCheckinAutoTime(providerID) || account.CheckinTime != "" { + if err != nil || effective != "11:30" || account.CheckinTime != "" { t.Fatalf("reset=%q err=%v", effective, err) } } diff --git a/internal/store/migrations.go b/internal/store/migrations.go index feb60cc1..96db69ae 100644 --- a/internal/store/migrations.go +++ b/internal/store/migrations.go @@ -289,6 +289,11 @@ ALTER TABLE aggregation_members ADD COLUMN account_id TEXT NOT NULL DEFAULT '';` ALTER TABLE accounts ADD COLUMN last_checkin_source TEXT NOT NULL DEFAULT ''; ALTER TABLE accounts ADD COLUMN last_checkin_synced_at TEXT NOT NULL DEFAULT ''; ALTER TABLE accounts ADD COLUMN checkin_auto_time TEXT NOT NULL DEFAULT '';`}, + {filename: "034_aggregation_capabilities.sql", sql: ` +ALTER TABLE aggregation_models ADD COLUMN context_length INTEGER NOT NULL DEFAULT 0; +ALTER TABLE aggregation_models ADD COLUMN max_output_tokens INTEGER NOT NULL DEFAULT 0; +ALTER TABLE aggregation_models ADD COLUMN reasoning_options TEXT NOT NULL DEFAULT ''; +ALTER TABLE aggregation_models ADD COLUMN reasoning_effort TEXT NOT NULL DEFAULT '';`}, } const schemaMigrationsDDL = ` diff --git a/internal/store/request_logs.go b/internal/store/request_logs.go index c249b678..298e9992 100644 --- a/internal/store/request_logs.go +++ b/internal/store/request_logs.go @@ -76,6 +76,30 @@ func (s *Store) UpdateRequestLog(ctx context.Context, log accounts.RequestLog) e return nil } +// CloseAbandonedRequestLogs marks request rows a previous process left in a +// non-terminal state. In-flight request state lives in memory only, so after a +// restart nothing can ever finish those rows: without this sweep every crash or +// container replacement leaves permanently "streaming" entries that make the +// console's running count and usage windows lie. +func (s *Store) CloseAbandonedRequestLogs(ctx context.Context, now time.Time) (int, error) { + if now.IsZero() { + now = time.Now() + } + result, err := s.db.ExecContext(ctx, ` + UPDATE request_logs SET + finished_at = ?, status = ?, error_kind = ?, error_code = ?, error_message = ? + WHERE status IN (?, ?) AND (finished_at IS NULL OR finished_at = '')`, + formatTime(now.UTC()), accounts.RequestStatusError, accounts.KindUnavailable, + "stream_abandoned", "gateway restarted before the request finished", + accounts.RequestStatusStarted, accounts.RequestStatusStreaming, + ) + if err != nil { + return 0, fmt.Errorf("close abandoned request logs: %w", err) + } + changed, _ := result.RowsAffected() + return int(changed), nil +} + func (s *Store) InsertRequestAttempt(ctx context.Context, attempt accounts.RequestAttempt) error { if strings.TrimSpace(attempt.ID) == "" { return fmt.Errorf("request attempt id required") @@ -250,6 +274,10 @@ FROM request_logs`+where, args...) if usage.Totals.CacheMissTokens < 0 { usage.Totals.CacheMissTokens = 0 } + if cacheTokens := usage.Totals.CacheHitTokens + usage.Totals.CacheMissTokens; cacheTokens > 0 { + rate := float64(usage.Totals.CacheHitTokens) / float64(cacheTokens) + usage.Totals.CacheHitRate = &rate + } usage.Totals.AvgLatencyMs = roundedNullInt(avgLatency) if usage.Totals.Requests > 0 { usage.Totals.SuccessRate = float64(usage.Totals.Requests-usage.Totals.Errors) / float64(usage.Totals.Requests) diff --git a/internal/store/request_logs_abandoned_test.go b/internal/store/request_logs_abandoned_test.go new file mode 100644 index 00000000..880362c0 --- /dev/null +++ b/internal/store/request_logs_abandoned_test.go @@ -0,0 +1,67 @@ +package store + +import ( + "context" + "path/filepath" + "testing" + "time" + + "github.com/caigee-cmd/cli2api/internal/accounts" +) + +func TestCloseAbandonedRequestLogs(t *testing.T) { + ctx := context.Background() + store, err := OpenStore(filepath.Join(t.TempDir(), "qoder.db")) + if err != nil { + t.Fatal(err) + } + defer store.Close() + + now := time.Now().UTC() + open := []accounts.RequestLog{ + {ID: "req-open-start", CreatedAt: now, Status: accounts.RequestStatusStarted}, + {ID: "req-open-stream", CreatedAt: now, Status: accounts.RequestStatusStreaming, Stream: true}, + } + for _, log := range open { + if err := store.InsertRequestLog(ctx, log); err != nil { + t.Fatal(err) + } + } + finished := now.Add(time.Second) + if err := store.UpdateRequestLog(ctx, accounts.RequestLog{ + ID: "req-open-stream", CreatedAt: now, FinishedAt: &finished, + Status: accounts.RequestStatusOK, Stream: true, + }); err != nil { + t.Fatal(err) + } + + closed, err := store.CloseAbandonedRequestLogs(ctx, now.Add(2*time.Hour)) + if err != nil { + t.Fatalf("close abandoned: %v", err) + } + if closed != 1 { + t.Fatalf("closed = %d, want 1 (only the row still running)", closed) + } + + row, err := store.GetRequestLog(ctx, "req-open-start") + if err != nil { + t.Fatal(err) + } + if row.Status != accounts.RequestStatusError { + t.Fatalf("status = %q, want error", row.Status) + } + if row.ErrorCode != "stream_abandoned" { + t.Fatalf("error_code = %q, want stream_abandoned", row.ErrorCode) + } + if row.FinishedAt == nil { + t.Fatal("abandoned row must carry finished_at") + } + + done, err := store.GetRequestLog(ctx, "req-open-stream") + if err != nil { + t.Fatal(err) + } + if done.Status != accounts.RequestStatusOK { + t.Fatalf("completed row was rewritten: %q", done.Status) + } +} diff --git a/internal/store/request_logs_test.go b/internal/store/request_logs_test.go index bfc3bdcc..e2dfd30d 100644 --- a/internal/store/request_logs_test.go +++ b/internal/store/request_logs_test.go @@ -890,3 +890,43 @@ func TestSummarizeModelCostsUsesServedModel(t *testing.T) { }) } } + +func TestSummarizeRequestUsageReportsCacheHitRate(t *testing.T) { + ctx := context.Background() + store, err := OpenStore(filepath.Join(t.TempDir(), "qoder.db")) + if err != nil { + t.Fatal(err) + } + defer store.Close() + + base := time.Date(2026, 10, 2, 12, 0, 0, 0, time.UTC) + iptr := func(v int) *int { return &v } + insert := func(id string, at time.Time, prompt, cacheRead int) { + t.Helper() + if err := store.InsertRequestLog(ctx, accounts.RequestLog{ + ID: id, CreatedAt: at, Status: accounts.RequestStatusOK, + RequestedModel: "glm", PromptTokens: iptr(prompt), CacheReadTokens: iptr(cacheRead), + }); err != nil { + t.Fatal(err) + } + } + insert("req_hit", base, 1000, 900) + insert("req_miss", base.Add(time.Minute), 1000, 0) + + usage, err := store.SummarizeRequestUsage(ctx, base.Add(-time.Minute), base.Add(time.Hour), "") + if err != nil { + t.Fatal(err) + } + if usage.Totals.CacheHitRate == nil { + t.Fatal("cache hit rate missing") + } + if got := *usage.Totals.CacheHitRate; got < 0.44 || got > 0.46 { + t.Fatalf("cache hit rate = %v, want 0.45", got) + } + if usage.Totals.CacheHitTokens != 900 || usage.Totals.CacheMissTokens != 1100 { + t.Fatalf("hit/miss = %d/%d", usage.Totals.CacheHitTokens, usage.Totals.CacheMissTokens) + } + if usage.Totals.CacheHitRate != nil && (usage.Totals.Requests != 2) { + t.Fatalf("requests = %d", usage.Totals.Requests) + } +} diff --git a/internal/store/store.go b/internal/store/store.go index b98943fa..cebccea7 100644 --- a/internal/store/store.go +++ b/internal/store/store.go @@ -174,7 +174,10 @@ func (s *Store) Create(ctx context.Context, input accounts.CreateAccount) (accou } checkinAutoTime := "" if _, supported := providers.CheckinFor(descriptor.ID, region.ID); supported { - checkinAutoTime = accounts.DefaultCheckinAutoTime(descriptor.ID) + // The provider check-in time setting drives the schedule; the stored + // per-account mirror starts at the 09:00 default and is rewritten on the + // next status sync once the operator changes the setting. + checkinAutoTime = accounts.DefaultCheckinTime } account := accounts.Account{ ID: newAccountID(), @@ -298,10 +301,9 @@ func scanAccount(row rowScanner) (accounts.Account, error) { account.WorkBuddyCheckinTime = accounts.DefaultWorkBuddyCheckinTime } if _, supported := providers.CheckinFor(account.Provider, account.ProviderRegion); supported && account.CheckinAutoTime == "" { - // The first upstream sync overwrites this with the observed window. The - // in-memory fallback makes the scheduler use the new auto rule immediately - // after upgrade instead of waiting for the first sweep. - account.CheckinAutoTime = accounts.DefaultCheckinAutoTime(account.Provider) + // The setting drives the schedule; this is only the display mirror for + // rows created before the first sync wrote one. + account.CheckinAutoTime = accounts.DefaultCheckinTime } account.CreatedAt = parseTime(created.String) account.UpdatedAt = parseTime(updated.String) diff --git a/internal/store/store_test.go b/internal/store/store_test.go index 839ceccb..2cccd58b 100644 --- a/internal/store/store_test.go +++ b/internal/store/store_test.go @@ -75,8 +75,8 @@ func TestStorePersistsModelContextSettings(t *testing.T) { if !ok || got != 500000 { t.Fatalf("model context = %d, %v", got, ok) } - if err := reopened.SetModelContext(ctx, "minimax-m3", 1); err == nil { - t.Fatal("expected too-small context length to fail") + if err := reopened.SetModelContext(ctx, "minimax-m3", -1); err == nil { + t.Fatal("expected negative context length to fail") } if err := reopened.SetModelContext(ctx, "minimax-m3", 0); err != nil { t.Fatal(err) @@ -542,7 +542,7 @@ func TestStoreCreateWorkBuddyCheckinTimeFallsBackToAuto(t *testing.T) { t.Fatal(err) } updated, err := store.Get(ctx, account.ID) - if err != nil || updated.WorkBuddyCheckinTime != "01:00" { + if err != nil || updated.WorkBuddyCheckinTime != "07:15" { t.Fatalf("updated=%+v err=%v", updated, err) } } diff --git a/internal/translate/compat.go b/internal/translate/compat.go index 6429a1e4..a41688a9 100644 --- a/internal/translate/compat.go +++ b/internal/translate/compat.go @@ -783,10 +783,41 @@ func ValidateChatRequest(request *ChatRequest) error { if len(request.MaxTokens) > 0 && len(request.MaxCompletionTokens) > 0 { return fmt.Errorf("max_tokens and max_completion_tokens are mutually exclusive") } + if err := rejectUnsupportedMedia(request); err != nil { + return err + } request.ToolChoice = sanitizeToolChoice(request.Tools, request.ToolChoice) return validateToolChoice(request.Tools, request.ToolChoice) } +// rejectUnsupportedMedia refuses media parts that no configured provider path +// can carry. The provider adapters build their prompts from text and image +// parts only, so letting a video / audio / file part through would silently +// discard the caller's content. Answer with a real 400 instead of dropping it. +// Video stays refused until an upstream video channel is verified end to end. +func rejectUnsupportedMedia(request *ChatRequest) error { + for index, message := range request.Messages { + parts, ok := message.Content.([]any) + if !ok { + continue + } + for partIndex, raw := range parts { + part, ok := raw.(map[string]any) + if !ok { + continue + } + switch strings.ToLower(strings.TrimSpace(anyString(part["type"]))) { + case "video_url", "input_video", "video", "input_audio", "audio_url", "audio", "input_file", "file": + return fmt.Errorf( + "messages[%d].content[%d] type %q is not supported: no provider path carries video, audio or file parts; send image_url parts or describe the media in text", + index, partIndex, anyString(part["type"]), + ) + } + } + } + return nil +} + // sanitizeToolChoice drops orphan tool_choice values when tools are empty, and // clears named tool choices that no longer exist after tool normalization. func sanitizeToolChoice(tools, choice json.RawMessage) json.RawMessage { diff --git a/internal/translate/media_test.go b/internal/translate/media_test.go new file mode 100644 index 00000000..c983c493 --- /dev/null +++ b/internal/translate/media_test.go @@ -0,0 +1,67 @@ +package translate + +import ( + "strings" + "testing" +) + +func TestValidateChatRequestRejectsUnsupportedMedia(t *testing.T) { + request := ChatRequest{ + Model: "glm-5.2", + Messages: []ChatMessage{{ + Role: "user", + Content: []any{ + map[string]any{"type": "text", "text": "what happens in this clip?"}, + map[string]any{"type": "video_url", "video_url": map[string]any{"url": "https://example.com/clip.mp4"}}, + }, + }}, + } + err := ValidateChatRequest(&request) + if err == nil { + t.Fatal("a video part must be refused, not silently dropped") + } + if !strings.Contains(err.Error(), "video_url") || !strings.Contains(err.Error(), "messages[0].content[1]") { + t.Fatalf("error must name the offending part, got %v", err) + } +} + +func TestValidateChatRequestRejectsAudioAndFileParts(t *testing.T) { + for _, partType := range []string{"input_audio", "input_file"} { + request := ChatRequest{ + Model: "glm-5.2", + Messages: []ChatMessage{{ + Role: "user", + Content: []any{map[string]any{"type": partType}}, + }}, + } + if err := ValidateChatRequest(&request); err == nil { + t.Fatalf("%s must be refused", partType) + } + } +} + +func TestValidateChatRequestKeepsImageParts(t *testing.T) { + request := ChatRequest{ + Model: "glm-5.2", + Messages: []ChatMessage{{ + Role: "user", + Content: []any{ + map[string]any{"type": "text", "text": "describe this"}, + map[string]any{"type": "image_url", "image_url": map[string]any{"url": "https://example.com/cat.png"}}, + }, + }}, + } + if err := ValidateChatRequest(&request); err != nil { + t.Fatalf("image parts must stay accepted: %v", err) + } +} + +func TestValidateChatRequestKeepsStringContent(t *testing.T) { + request := ChatRequest{ + Model: "glm-5.2", + Messages: []ChatMessage{{Role: "user", Content: "hello"}}, + } + if err := ValidateChatRequest(&request); err != nil { + t.Fatalf("plain text content must stay accepted: %v", err) + } +} diff --git a/internal/translate/native_responses.go b/internal/translate/native_responses.go index 0b24097e..d11a68c0 100644 --- a/internal/translate/native_responses.go +++ b/internal/translate/native_responses.go @@ -154,6 +154,45 @@ func (r *NativeResponsesRequest) RequestedReasoningEffort() string { return strings.TrimSpace(reasoning.Effort) } +// WithDefaultReasoning returns a copy whose reasoning.effort is set to level +// when the client sent no effort. A client-specified effort is preserved, and +// the original request is never mutated, so per-attempt rewrites and failover +// are unaffected. +func (r *NativeResponsesRequest) WithDefaultReasoning(level string) *NativeResponsesRequest { + if r == nil { + return nil + } + level = strings.TrimSpace(level) + if level == "" || r.RequestedReasoningEffort() != "" { + return r + } + fields := r.Fields() + reasoning := map[string]json.RawMessage{} + if value := fields["reasoning"]; jsonKind(value) == '{' { + if err := json.Unmarshal(value, &reasoning); err != nil { + return r + } + } + if reasoning == nil { + reasoning = map[string]json.RawMessage{} + } + encoded, err := json.Marshal(level) + if err != nil { + return r + } + reasoning["effort"] = encoded + rawReasoning, err := json.Marshal(reasoning) + if err != nil { + return r + } + fields["reasoning"] = rawReasoning + raw, err := json.Marshal(fields) + if err != nil { + return r + } + return &NativeResponsesRequest{raw: raw, fields: fields, model: r.model, stream: r.stream} +} + // SessionSeed is the sticky-routing anchor used when the request cannot be // expressed in the chat form (the chat form's ContentSessionSeed is preferred // whenever it exists, so accepted requests keep their existing affinity). It diff --git a/internal/translate/seed_components_test.go b/internal/translate/seed_components_test.go new file mode 100644 index 00000000..574c3c02 --- /dev/null +++ b/internal/translate/seed_components_test.go @@ -0,0 +1,58 @@ +package translate + +import "testing" + +// TestSeedComponentsExposePerComponentHash pins the diagnostic split used by +// the affinity debug log: each seed component must move independently, so an +// operator can tell a volatile system prefix from a changed model or a new +// first message. Tool reorder invariance is covered where the tools order is +// normalized, not here. +func TestSeedComponentsExposePerComponentHash(t *testing.T) { + base := ChatRequest{ + Model: "glm-5.2", + Messages: []ChatMessage{ + {Role: "system", Content: "stable prefix"}, + {Role: "user", Content: "first question"}, + }, + } + baseParts := SeedComponents(base) + if baseParts.Model == "" || baseParts.Prefix == "" || baseParts.FirstUser == "" { + t.Fatalf("components missing: %+v", baseParts) + } + + otherModel := base + otherModel.Model = "deepseek-v4.1-flash" + got := SeedComponents(otherModel) + if got.Model == baseParts.Model { + t.Fatal("model change did not move the model component") + } + if got.Prefix != baseParts.Prefix || got.FirstUser != baseParts.FirstUser { + t.Fatalf("model change moved unrelated components: %+v", got) + } + + volatilePrefix := base + volatilePrefix.Messages = []ChatMessage{ + {Role: "system", Content: "today is 2026-11-24 17:45:03"}, + {Role: "user", Content: "first question"}, + } + got = SeedComponents(volatilePrefix) + if got.Prefix == baseParts.Prefix { + t.Fatal("prefix change did not move the prefix component") + } + if got.FirstUser != baseParts.FirstUser { + t.Fatalf("prefix change moved the first-user component: %+v", got) + } +} + +// TestSeedComponentsMissingWithoutUserAnchor keeps the "no user message means +// no session key" invariant visible: reporting all-zero components matches an +// empty ContentSessionSeed. +func TestSeedComponentsMissingWithoutUserAnchor(t *testing.T) { + parts := SeedComponents(ChatRequest{ + Model: "glm-5.2", + Messages: []ChatMessage{{Role: "system", Content: "only a prefix"}}, + }) + if parts != (SessionSeedComponents{}) { + t.Fatalf("components = %+v, want zero value", parts) + } +} diff --git a/internal/translate/session_seed.go b/internal/translate/session_seed.go index e22599fb..abb39138 100644 --- a/internal/translate/session_seed.go +++ b/internal/translate/session_seed.go @@ -5,6 +5,8 @@ import ( "crypto/sha256" "encoding/hex" "encoding/json" + "os" + "sort" "strings" ) @@ -51,7 +53,7 @@ func ContentSessionSeed(req ChatRequest) string { func buildContentSessionFingerprint(req ChatRequest) (contentSessionFingerprint, bool) { fingerprint := contentSessionFingerprint{ Model: strings.ToLower(strings.TrimSpace(req.Model)), - Tools: compactSessionJSON(req.Tools), + Tools: compactSessionJSON(NormalizeToolsOrder(req.Tools)), } systemPrefixOpen := true sawFirstUser := false @@ -261,7 +263,6 @@ func compactSessionJSON(raw json.RawMessage) string { return compact.String() } - // PrefixSessionSeed is the cache-affine part of ContentSessionSeed: model, // tools and the leading system/developer prefix only. It deliberately excludes // the first user message so workbuddy2api-hub-style sharding does not scatter @@ -269,7 +270,7 @@ func compactSessionJSON(raw json.RawMessage) string { func PrefixSessionSeed(req ChatRequest) string { parts := []string{ strings.ToLower(strings.TrimSpace(req.Model)), - compactSessionJSON(req.Tools), + compactSessionJSON(NormalizeToolsOrder(req.Tools)), } for _, message := range req.Messages { role := strings.ToLower(strings.TrimSpace(message.Role)) @@ -287,3 +288,133 @@ func PrefixSessionSeed(req ChatRequest) string { sum := sha256.Sum256(raw) return hex.EncodeToString(sum[:]) } + +// SessionSeedComponents exposes the per-component hashes behind +// ContentSessionSeed. Routing only needs the combined hash; diagnostics need +// this split to answer "which part of the request moved", because a chat that +// silently re-anchors every turn is usually carrying a volatile timestamp in +// its system prefix or reordering its tool list. +type SessionSeedComponents struct { + Model string `json:"model"` + Tools string `json:"tools"` + Prefix string `json:"prefix"` + FirstUser string `json:"first_user"` +} + +// SeedComponents returns short component hashes. Zero values mean the component +// is absent (for example no system prefix at all). +func SeedComponents(req ChatRequest) SessionSeedComponents { + fingerprint, ok := buildContentSessionFingerprint(req) + if !ok { + return SessionSeedComponents{} + } + out := SessionSeedComponents{ + Model: shortHash(fingerprint.Model), + Tools: shortHash(fingerprint.Tools), + } + if len(fingerprint.Prefix) > 0 { + if raw, err := json.Marshal(fingerprint.Prefix); err == nil { + out.Prefix = shortHash(string(raw)) + } + } + if raw, err := json.Marshal(fingerprint.FirstUser); err == nil { + out.FirstUser = shortHash(string(raw)) + } + return out +} + +func shortHash(value string) string { + if strings.TrimSpace(value) == "" { + return "" + } + sum := sha256.Sum256([]byte(value)) + return hex.EncodeToString(sum[:4]) +} + +// NormalizeToolsOrder rewrites a tools array into a stable, name-ordered form. +// Tool definitions are a set: their order carries no meaning to the model but +// changes both the session fingerprint and the upstream cached prefix. Clients +// such as Claude Code and Cline rebuild the array per turn, which would +// otherwise scatter one chat across accounts and defeat prompt caching. +// +// A payload without names, an empty array, or invalid JSON is returned +// unchanged, so callers can apply this unconditionally to the fingerprint. +func NormalizeToolsOrder(raw json.RawMessage) json.RawMessage { + trimmed := bytes.TrimSpace(raw) + if len(trimmed) == 0 || bytes.Equal(trimmed, []byte("null")) { + return raw + } + var items []json.RawMessage + if err := json.Unmarshal(trimmed, &items); err != nil || len(items) < 2 { + return raw + } + type keyedTool struct { + key string + item json.RawMessage + } + keyed := make([]keyedTool, len(items)) + sorted := true + for i, item := range items { + keyed[i] = keyedTool{key: toolSortKey(item), item: item} + if i > 0 && keyed[i-1].key > keyed[i].key { + sorted = false + } + } + if sorted { + return raw + } + sort.SliceStable(keyed, func(i, j int) bool { return keyed[i].key < keyed[j].key }) + out := make([]json.RawMessage, len(keyed)) + for i := range keyed { + out[i] = keyed[i].item + } + encoded, err := json.Marshal(out) + if err != nil { + return raw + } + return encoded +} + +// toolSortKey is the tool's name when it has one, plus the compact body so two +// tools that share a name still order deterministically. Unnamed tools sort +// last under a marker no real name can produce. +func toolSortKey(raw json.RawMessage) string { + var probe struct { + Name string `json:"name"` + Function struct { + Name string `json:"name"` + } `json:"function"` + } + name := "" + if err := json.Unmarshal(raw, &probe); err == nil { + name = strings.TrimSpace(probe.Name) + if name == "" { + name = strings.TrimSpace(probe.Function.Name) + } + } + if name == "" { + return "\uffff" + compactSessionJSON(raw) + } + return name + "\x00" + compactSessionJSON(raw) +} + +// NormalizeToolsForPayload returns the payload tools array. Ordering is only +// rewritten when the operator opts in: reordering the outbound array is a +// semantic change some models notice, so it ships behind +// CLI2API_TOOLS_NORMALIZE and the fingerprint normalization alone (which is +// always on) is the safe default. +func NormalizeToolsForPayload(raw json.RawMessage) json.RawMessage { + if !payloadToolsNormalizeOn() { + return raw + } + return NormalizeToolsOrder(raw) +} + +func payloadToolsNormalizeOn() bool { + switch strings.ToLower(strings.TrimSpace(os.Getenv("CLI2API_TOOLS_NORMALIZE"))) { + case "1", "true", "on", "yes": + return true + default: + return false + } +} diff --git a/internal/translate/toolargs.go b/internal/translate/toolargs.go new file mode 100644 index 00000000..7ab618a1 --- /dev/null +++ b/internal/translate/toolargs.go @@ -0,0 +1,276 @@ +package translate + +import ( + "encoding/json" + "strings" +) + +const maxCloseClosers = 24 + +// NormalizeToolCallArguments always returns valid JSON for a function tool's +// argument text, so a damaged tool call degrades into a call the model can +// retry instead of killing the whole turn. The bool reports whether anything +// had to change. +// +// Order: formatting repair first; then drop the trailing incomplete member +// (a value cut mid-string, usually by the output-token limit) and keep only +// fields the model finished writing; last resort an empty object. Dropping +// beats inventing: a tool called without its unfinished field validates and +// fails visibly, while padding a truncated `rm -rf /tmp/fo` would execute +// something the model never wrote. +func NormalizeToolCallArguments(raw string) (string, bool) { + text := strings.TrimSpace(raw) + if text == "" { + return "{}", true + } + if json.Valid([]byte(text)) { + return text, false + } + if repaired, ok := RepairToolCallArguments(text); ok { + return repaired, true + } + if trimmed, ok := dropIncompleteMember(text); ok { + return trimmed, true + } + return "{}", true +} + +// RepairToolCallArguments fixes formatting-level damage only: bare quotes +// inside a value, a trailing comma, missing closing brackets after a complete +// value, or prose appended after the object. It never pads a value that was +// cut mid-string and reports ok=false for that case. +func RepairToolCallArguments(raw string) (string, bool) { + text := strings.TrimSpace(raw) + if text == "" { + return "{}", true + } + if json.Valid([]byte(text)) { + return text, true + } + candidates := argumentRepairCandidates(text) + for _, candidate := range candidates { + if json.Valid([]byte(candidate)) { + return candidate, true + } + } + for _, candidate := range candidates { + if closed, ok := closeArgumentTail(candidate); ok { + return closed, true + } + } + // A model sometimes appends prose after a complete object: keep the value + // the decoder actually finished and drop the trailing noise. + if prefix, ok := decodeArgumentPrefix(text); ok { + return prefix, true + } + return "", false +} + +// dropIncompleteMember keeps only the members the model finished writing: it +// cuts at the last top-level comma whose prefix can be closed into valid JSON. +func dropIncompleteMember(text string) (string, bool) { + if !strings.HasPrefix(text, "{") { + return "", false + } + commas := topLevelCommaPositions(text) + for index := len(commas) - 1; index >= 0; index-- { + prefix := strings.TrimSpace(strings.TrimSuffix(text[:commas[index]], ",")) + if prefix == "" || prefix == "{" { + continue + } + if closed, ok := closeArgumentTail(prefix); ok { + return closed, true + } + } + if closed, ok := closeArgumentTail("{"); ok { + return closed, true + } + return "", false +} + +// topLevelCommaPositions returns the byte offsets of commas that sit directly +// inside the outermost object, outside any nested structure or string. +func topLevelCommaPositions(text string) []int { + positions := make([]int, 0, 8) + depth := 0 + inString := false + for index := 0; index < len(text); index++ { + character := text[index] + if inString { + if character == '\\' { + index++ + continue + } + if character == '"' { + inString = false + } + continue + } + switch character { + case '"': + inString = true + case '{', '[': + depth++ + case '}', ']': + depth-- + case ',': + if depth == 1 { + positions = append(positions, index) + } + } + } + return positions +} + +func argumentRepairCandidates(text string) []string { + candidates := []string{text} + if withoutTrailing := stripTrailingCommas(text); withoutTrailing != text { + candidates = append(candidates, withoutTrailing) + } + if escaped := escapeBareQuotes(text); escaped != text { + candidates = append(candidates, escaped, stripTrailingCommas(escaped)) + } + return candidates +} + +// stripTrailingCommas removes `,` that directly precede a closing brace or +// bracket, which models emit routinely and strict JSON rejects. +func stripTrailingCommas(text string) string { + var out strings.Builder + out.Grow(len(text)) + for index := 0; index < len(text); index++ { + character := text[index] + if character == ',' { + next := index + 1 + for next < len(text) && isJSONSpace(text[next]) { + next++ + } + if next < len(text) && (text[next] == '}' || text[next] == ']') { + continue + } + } + out.WriteByte(character) + } + return out.String() +} + +// escapeBareQuotes escapes `"` characters that appear inside a JSON string +// value. A closing quote is accepted only when the next non-space byte is one +// of `, } ] :` or the end of the buffer. +func escapeBareQuotes(text string) string { + var out strings.Builder + out.Grow(len(text)) + inString := false + for index := 0; index < len(text); { + character := text[index] + if !inString { + out.WriteByte(character) + if character == '"' { + inString = true + } + index++ + continue + } + if character == '\\' && index+1 < len(text) { + out.WriteString(text[index : index+2]) + index += 2 + continue + } + if character == '"' { + next := index + 1 + for next < len(text) && isJSONSpace(text[next]) { + next++ + } + if next >= len(text) || strings.IndexByte(",}]:", text[next]) >= 0 { + out.WriteByte(character) + inString = false + } else { + out.WriteString(`\"`) + } + index++ + continue + } + out.WriteByte(character) + index++ + } + return out.String() +} + +// closeArgumentTail appends the closers the model never got to emit, but only +// when no string is left open — a value cut mid-string stays unrepaired. +func closeArgumentTail(text string) (string, bool) { + stack := make([]byte, 0, maxCloseClosers) + var out strings.Builder + out.Grow(len(text) + maxCloseClosers) + inString := false + for index := 0; index < len(text); index++ { + character := text[index] + if inString { + out.WriteByte(character) + if character == '\\' && index+1 < len(text) { + out.WriteByte(text[index+1]) + index++ + continue + } + if character == '"' { + inString = false + } + continue + } + switch character { + case '"': + inString = true + out.WriteByte(character) + case '{', '[': + if len(stack) >= maxCloseClosers { + return "", false + } + stack = append(stack, character) + out.WriteByte(character) + case '}', ']': + if len(stack) == 0 { + return "", false + } + open := stack[len(stack)-1] + if (character == '}' && open != '{') || (character == ']' && open != '[') { + return "", false + } + stack = stack[:len(stack)-1] + out.WriteByte(character) + default: + out.WriteByte(character) + } + } + if inString || len(stack) == 0 { + return "", false + } + for index := len(stack) - 1; index >= 0; index-- { + if stack[index] == '{' { + out.WriteString("}") + } else { + out.WriteString("]") + } + } + closed := stripTrailingCommas(out.String()) + if json.Valid([]byte(closed)) { + return closed, true + } + return "", false +} + +func decodeArgumentPrefix(text string) (string, bool) { + decoder := json.NewDecoder(strings.NewReader(text)) + var value any + if decoder.Decode(&value) != nil { + return "", false + } + prefix := strings.TrimSpace(text[:decoder.InputOffset()]) + if prefix == "" || !json.Valid([]byte(prefix)) { + return "", false + } + return prefix, true +} + +func isJSONSpace(character byte) bool { + return character == ' ' || character == '\t' || character == '\r' || character == '\n' +} diff --git a/internal/translate/toolargs_normalize_test.go b/internal/translate/toolargs_normalize_test.go new file mode 100644 index 00000000..c2cb00e8 --- /dev/null +++ b/internal/translate/toolargs_normalize_test.go @@ -0,0 +1,36 @@ +package translate + +import ( + "encoding/json" + "testing" +) + +func TestNormalizeToolCallArgumentsNeverReturnsInvalidJSON(t *testing.T) { + cases := []struct { + name string + raw string + want string + wantChange bool + }{ + {name: "valid", raw: `{"path":"a.go"}`, want: `{"path":"a.go"}`}, + {name: "blank", raw: " ", want: "{}", wantChange: true}, + {name: "trailing comma", raw: `{"path":"a.go",}`, want: `{"path":"a.go"}`, wantChange: true}, + {name: "missing brace", raw: `{"path":"a.go"`, want: `{"path":"a.go"}`, wantChange: true}, + {name: "truncated last field dropped", raw: `{"path":"a.go","body":"partial`, want: `{"path":"a.go"}`, wantChange: true}, + {name: "truncated only field becomes empty", raw: `{"command":"rm -rf /tmp/fo`, want: "{}", wantChange: true}, + {name: "truncated nested field dropped", raw: `{"path":"a.go","edits":[{"old":"x","new":"y`, want: `{"path":"a.go"}`, wantChange: true}, + {name: "not json at all", raw: `please read the file`, want: "{}", wantChange: true}, + } + for _, tc := range cases { + got, changed := NormalizeToolCallArguments(tc.raw) + if !json.Valid([]byte(got)) { + t.Fatalf("%s: result is not valid JSON: %q", tc.name, got) + } + if got != tc.want { + t.Fatalf("%s: got %q, want %q", tc.name, got, tc.want) + } + if changed != tc.wantChange { + t.Fatalf("%s: changed = %v, want %v", tc.name, changed, tc.wantChange) + } + } +} diff --git a/internal/translate/toolargs_test.go b/internal/translate/toolargs_test.go new file mode 100644 index 00000000..5232e1f0 --- /dev/null +++ b/internal/translate/toolargs_test.go @@ -0,0 +1,41 @@ +package translate + +import ( + "encoding/json" + "testing" +) + +func TestRepairToolCallArguments(t *testing.T) { + cases := []struct { + name string + raw string + want string + ok bool + }{ + {name: "valid passthrough", raw: `{"path":"a.go"}`, want: `{"path":"a.go"}`, ok: true}, + {name: "blank becomes object", raw: " ", want: "{}", ok: true}, + {name: "trailing comma", raw: `{"path":"a.go",}`, want: `{"path":"a.go"}`, ok: true}, + {name: "missing closing brace", raw: `{"path":"a.go"`, want: `{"path":"a.go"}`, ok: true}, + {name: "missing nested closers", raw: `{"pattern":"x","paths":["a","b"`, want: `{"pattern":"x","paths":["a","b"]}`, ok: true}, + {name: "bare quote inside value", raw: `{"cmd":"echo "hi""}`, want: `{"cmd":"echo \"hi\""}`, ok: true}, + {name: "prose after object", raw: `{"path":"a.go"} and then explain`, want: `{"path":"a.go"}`, ok: true}, + {name: "cut mid string", raw: `{"cmd":"rm -rf /tmp/fo`, ok: false}, + {name: "cut mid key", raw: `{"pa`, ok: false}, + {name: "not json at all", raw: `please read the file`, ok: false}, + } + for _, tc := range cases { + got, ok := RepairToolCallArguments(tc.raw) + if ok != tc.ok { + t.Fatalf("%s: ok = %v, want %v (got %q)", tc.name, ok, tc.ok, got) + } + if !ok { + continue + } + if got != tc.want { + t.Fatalf("%s: got %q, want %q", tc.name, got, tc.want) + } + if !json.Valid([]byte(got)) { + t.Fatalf("%s: repaired value is not valid JSON: %q", tc.name, got) + } + } +} diff --git a/internal/translate/tools_normalize_test.go b/internal/translate/tools_normalize_test.go new file mode 100644 index 00000000..6e66f19d --- /dev/null +++ b/internal/translate/tools_normalize_test.go @@ -0,0 +1,142 @@ +package translate + +import ( + "encoding/json" + "testing" +) + +func toolsJSON(names ...string) json.RawMessage { + items := make([]map[string]any, 0, len(names)) + for _, name := range names { + items = append(items, map[string]any{ + "type": "function", + "function": map[string]any{"name": name, "description": name + " desc"}, + }) + } + raw, _ := json.Marshal(items) + return raw +} + +func seedRequest(model string, tools json.RawMessage) ChatRequest { + return ChatRequest{ + Model: model, + Tools: tools, + Messages: []ChatMessage{{Role: "user", Content: "hi"}}, + } +} + +func TestToolsOrderDoesNotChangeSessionSeed(t *testing.T) { + ordered := toolsJSON("alpha", "beta", "gamma") + shuffled := toolsJSON("gamma", "alpha", "beta") + if ContentSessionSeed(seedRequest("glm-5.2", ordered)) != ContentSessionSeed(seedRequest("glm-5.2", shuffled)) { + t.Fatal("tool order changed the session seed") + } + if PrefixSessionSeed(seedRequest("glm-5.2", ordered)) != PrefixSessionSeed(seedRequest("glm-5.2", shuffled)) { + t.Fatal("tool order changed the shard prefix seed") + } +} + +func TestToolsOrderStillChangesWithDifferentDefinitions(t *testing.T) { + if ContentSessionSeed(seedRequest("glm-5.2", toolsJSON("alpha", "beta"))) == + ContentSessionSeed(seedRequest("glm-5.2", toolsJSON("alpha", "delta"))) { + t.Fatal("a different tool set must produce a different seed") + } +} + +func TestNormalizeToolsOrderSortsByName(t *testing.T) { + raw := toolsJSON("beta", "alpha") + var got []struct { + Function struct { + Name string `json:"name"` + } `json:"function"` + } + if err := json.Unmarshal(NormalizeToolsOrder(raw), &got); err != nil { + t.Fatalf("decode normalized tools: %v", err) + } + if len(got) != 2 || got[0].Function.Name != "alpha" || got[1].Function.Name != "beta" { + t.Fatalf("normalized order = %+v", got) + } +} + +func TestNormalizeToolsOrderKeepsInputWhenAlreadySorted(t *testing.T) { + raw := toolsJSON("alpha", "beta") + if string(NormalizeToolsOrder(raw)) != string(raw) { + t.Fatal("an already-sorted array must be returned byte-identical") + } +} + +func TestNormalizeToolsOrderLeavesInvalidInputAlone(t *testing.T) { + cases := []json.RawMessage{ + nil, + json.RawMessage(`null`), + json.RawMessage(`[]`), + json.RawMessage(`"not-an-array"`), + json.RawMessage(`[{"type":"function"}]`), + } + for _, raw := range cases { + if string(NormalizeToolsOrder(raw)) != string(raw) { + t.Fatalf("input %q was rewritten", string(raw)) + } + } +} + +func TestNormalizeToolsForPayloadObeysKillSwitch(t *testing.T) { + raw := toolsJSON("beta", "alpha") + + t.Setenv("CLI2API_TOOLS_NORMALIZE", "") + if string(NormalizeToolsForPayload(raw)) != string(raw) { + t.Fatal("payload order must stay untouched by default") + } + + t.Setenv("CLI2API_TOOLS_NORMALIZE", "1") + if string(NormalizeToolsForPayload(raw)) == string(raw) { + t.Fatal("payload order should be normalized when the switch is on") + } +} + +func TestSeedComponentsAttribution(t *testing.T) { + base := ChatRequest{ + Model: "glm-5.2", + Tools: toolsJSON("alpha", "beta"), + Messages: []ChatMessage{ + {Role: "system", Content: "stable prefix"}, + {Role: "user", Content: "first question"}, + }, + } + baseParts := SeedComponents(base) + if baseParts.Model == "" || baseParts.Tools == "" || baseParts.Prefix == "" || baseParts.FirstUser == "" { + t.Fatalf("components missing: %+v", baseParts) + } + + // Reordering tools must not move any component hash. + shuffled := base + shuffled.Tools = toolsJSON("beta", "alpha") + if got := SeedComponents(shuffled); got != baseParts { + t.Fatalf("tool reorder changed components: %+v vs %+v", got, baseParts) + } + + // A different model moves only the model component. + otherModel := base + otherModel.Model = "deepseek-v4.1-flash" + got := SeedComponents(otherModel) + if got.Model == baseParts.Model { + t.Fatal("model change did not move the model component") + } + if got.Tools != baseParts.Tools || got.Prefix != baseParts.Prefix || got.FirstUser != baseParts.FirstUser { + t.Fatalf("model change moved unrelated components: %+v", got) + } + + // A volatile system prefix moves only the prefix component. + volatilePrefix := base + volatilePrefix.Messages = []ChatMessage{ + {Role: "system", Content: "today is 2026-11-24 17:45:03"}, + {Role: "user", Content: "first question"}, + } + got = SeedComponents(volatilePrefix) + if got.Prefix == baseParts.Prefix { + t.Fatal("prefix change did not move the prefix component") + } + if got.FirstUser != baseParts.FirstUser { + t.Fatalf("prefix change moved the first-user component: %+v", got) + } +} diff --git a/internal/update/checker.go b/internal/update/checker.go index da5b0c3e..554ffea3 100644 --- a/internal/update/checker.go +++ b/internal/update/checker.go @@ -36,6 +36,18 @@ func NewChecker(currentVersion string, source ReleaseSource) *Checker { return &Checker{currentVersion: currentVersion, source: source, cacheTTL: 10 * time.Minute} } +// ReleaseRepo reports the owner/repo behind the release source when it can name +// itself, so the console can explain which repository it follows. +func (c *Checker) ReleaseRepo() string { + if c == nil || c.source == nil { + return "" + } + if named, ok := c.source.(interface{ Repo() string }); ok { + return named.Repo() + } + return "" +} + func (c *Checker) Check(ctx context.Context, force bool) (Info, error) { current, err := ParseVersion(c.currentVersion) if err != nil { diff --git a/internal/update/coordinator.go b/internal/update/coordinator.go index 3eb22a49..b38efedb 100644 --- a/internal/update/coordinator.go +++ b/internal/update/coordinator.go @@ -75,6 +75,7 @@ type systemUpdateInfo struct { Info Agent AgentStatus `json:"agent"` Update *Job `json:"update,omitempty"` + Source string `json:"source,omitempty"` } func (c *Coordinator) Handle(w http.ResponseWriter, r *http.Request) { @@ -150,7 +151,7 @@ func (c *Coordinator) HandleCancel(w http.ResponseWriter, r *http.Request) { status, statusErr := c.Agent.Status(statusCtx) cancel() if statusErr != nil || !status.Available { - message := "Updater daemon is unavailable" + message := "Updater daemon is unavailable; run deploy/install-updater.sh on the host, then recreate qoder-api-proxy" if statusErr != nil { message = statusErr.Error() } @@ -224,7 +225,19 @@ func (c *Coordinator) HandleInfo(w http.ResponseWriter, r *http.Request) { if job == nil && status.State == "succeeded" && strings.TrimSpace(status.JobID) != "" { job = &Job{JobID: "agent-" + status.JobID, AgentJobID: status.JobID, State: "succeeded", CurrentVersion: status.CurrentVersion, TargetVersion: status.TargetVersion, StartedAt: status.StartedAt, FinishedAt: status.FinishedAt} } - writeJSON(w, http.StatusOK, systemUpdateInfo{Info: info, Agent: status, Update: job}) + writeJSON(w, http.StatusOK, systemUpdateInfo{Info: info, Agent: status, Update: job, Source: c.releaseRepo()}) +} + +// releaseRepo names the repository the checker reads releases from; empty when +// the injected source cannot report it. +func (c *Coordinator) releaseRepo() string { + if c == nil || c.Checker == nil { + return "" + } + if repoer, ok := c.Checker.(interface{ ReleaseRepo() string }); ok { + return repoer.ReleaseRepo() + } + return "" } func (c *Coordinator) HandleApplyNow(w http.ResponseWriter, _ *http.Request) { @@ -285,7 +298,7 @@ func (c *Coordinator) prepareImage(jobID string) { status, err := c.Agent.Status(statusCtx) statusCancel() if err != nil || !status.Available { - message := "Updater daemon is unavailable" + message := "Updater daemon is unavailable; run deploy/install-updater.sh on the host, then recreate qoder-api-proxy" if err != nil { message = err.Error() } @@ -362,7 +375,7 @@ func (c *Coordinator) prepareOneShot(jobID string) { status, err := c.Agent.Status(statusCtx) statusCancel() if err != nil || !status.Available { - message := "Updater daemon is unavailable" + message := "Updater daemon is unavailable; run deploy/install-updater.sh on the host, then recreate qoder-api-proxy" if err != nil { message = err.Error() } @@ -413,7 +426,7 @@ func (c *Coordinator) rollback(jobID, targetVersion string) { status, err := c.Agent.Status(statusCtx) statusCancel() if err != nil || !status.Available { - message := "Updater daemon is unavailable" + message := "Updater daemon is unavailable; run deploy/install-updater.sh on the host, then recreate qoder-api-proxy" if err != nil { message = err.Error() } diff --git a/internal/update/github.go b/internal/update/github.go index b2b34442..66b682c8 100644 --- a/internal/update/github.go +++ b/internal/update/github.go @@ -31,6 +31,15 @@ func NewGitHubReleaseSource(repo, token string) *GitHubReleaseSource { return &GitHubReleaseSource{client: client, baseURL: defaultGitHubAPI, repo: repo, token: strings.TrimSpace(token)} } +// Repo reports the owner/repo whose releases this source reads, so the console +// can show which repository an installation follows. +func (s *GitHubReleaseSource) Repo() string { + if s == nil { + return "" + } + return s.repo +} + func (s *GitHubReleaseSource) ListReleases(ctx context.Context) ([]Release, error) { if strings.TrimSpace(s.repo) == "" { return nil, fmt.Errorf("update repository required") @@ -43,8 +52,55 @@ func (s *GitHubReleaseSource) ListReleases(ctx context.Context) ([]Release, erro } releases = append(releases, batch...) if len(batch) < 100 { - return releases, nil + break + } + } + s.markLatest(ctx, releases) + return releases, nil +} + +// markLatest records which release the repository currently flags as latest. +// It is best effort: when the endpoint is unavailable the caller falls back to +// the highest tag. +func (s *GitHubReleaseSource) markLatest(ctx context.Context, releases []Release) { + if len(releases) == 0 { + return + } + requestURL := fmt.Sprintf("%s/repos/%s/releases/latest", strings.TrimRight(s.baseURL, "/"), s.repo) + req, err := http.NewRequestWithContext(ctx, http.MethodGet, requestURL, nil) + if err != nil { + return + } + req.Header.Set("Accept", "application/vnd.github+json") + req.Header.Set("User-Agent", "cli2api-updater") + if s.token != "" && isTrustedGitHubAPI(req.URL) { + req.Header.Set("Authorization", "Bearer "+s.token) + } + resp, err := s.client.Do(req) + if err != nil { + return + } + defer resp.Body.Close() + if resp.StatusCode != http.StatusOK { + return + } + var latest struct { + TagName string `json:"tag_name"` + } + if err := json.NewDecoder(io.LimitReader(resp.Body, 1<<20)).Decode(&latest); err != nil { + return + } + tag, err := ParseVersion(latest.TagName) + if err != nil { + return + } + for index := range releases { + version, err := ParseVersion(releases[index].TagName) + if err != nil || version.Compare(tag) != 0 { + continue } + releases[index].Latest = true + return } } diff --git a/internal/update/github_test.go b/internal/update/github_test.go index 78b415f3..19178f2c 100644 --- a/internal/update/github_test.go +++ b/internal/update/github_test.go @@ -6,11 +6,18 @@ import ( "net/http" "net/http/httptest" "strconv" + "strings" "testing" ) func TestGitHubReleaseSourcePaginatesAllReleases(t *testing.T) { server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + if strings.HasSuffix(r.URL.Path, "/releases/latest") { + if err := json.NewEncoder(w).Encode(Release{TagName: "v0.2.102"}); err != nil { + t.Fatal(err) + } + return + } if r.URL.Query().Get("per_page") != "100" { t.Fatalf("per_page = %q", r.URL.Query().Get("per_page")) } diff --git a/internal/update/version.go b/internal/update/version.go index ed4792e8..cb933484 100644 --- a/internal/update/version.go +++ b/internal/update/version.go @@ -59,6 +59,11 @@ type Release struct { HTMLURL string `json:"html_url"` Draft bool `json:"draft"` Prerelease bool `json:"prerelease"` + // Latest marks the release the repository designates as its latest one. + // It comes from the /releases/latest endpoint, not the list payload, so a + // deliberate numbering reset can point the update channel at a lower + // version than the highest tag. + Latest bool `json:"-"` } func SelectNextRelease(current string, releases []Release) (Release, bool) { @@ -66,6 +71,16 @@ func SelectNextRelease(current string, releases []Release) (Release, bool) { if err != nil { return Release{}, false } + // The repository's own latest marker is authoritative: after a version + // renumbering the marked release can sit below the highest tag, and clients + // must not be pushed past it. Without a marker, fall back to the highest tag. + if marked, version, ok := latestMarkedRelease(releases); ok { + if version.Compare(currentVersion) <= 0 { + return Release{}, false + } + marked.TagName = version.String() + return marked, true + } candidates := make([]Release, 0, len(releases)) for _, release := range releases { if release.Draft || release.Prerelease { @@ -89,6 +104,22 @@ func SelectNextRelease(current string, releases []Release) (Release, bool) { return candidates[len(candidates)-1], true } +// latestMarkedRelease returns the stable release carrying the repository's +// latest marker. +func latestMarkedRelease(releases []Release) (Release, Version, bool) { + for _, release := range releases { + if !release.Latest || release.Draft || release.Prerelease { + continue + } + version, err := ParseVersion(release.TagName) + if err != nil { + continue + } + return release, version, true + } + return Release{}, Version{}, false +} + // UpgradePath lists every stable release strictly between current and target, // in ascending order, so the console can show what a direct update passes over. // Versions the release list does not cover are silently skipped. diff --git a/internal/update/version_test.go b/internal/update/version_test.go index 9485a21f..3c73e8f6 100644 --- a/internal/update/version_test.go +++ b/internal/update/version_test.go @@ -28,6 +28,39 @@ func TestSelectNextReleaseSkipsOlderVersions(t *testing.T) { } } +func TestSelectNextReleaseFollowsTheLatestMarker(t *testing.T) { + releases := []Release{ + {TagName: "v0.7.45", Latest: true}, + {TagName: "v0.7.59"}, + {TagName: "v0.45.2"}, + } + + next, ok := SelectNextRelease("v0.7.44", releases) + if !ok || next.TagName != "v0.7.45" { + t.Fatalf("next = %+v, ok = %v, want v0.7.45", next, ok) + } + // Running the marked latest must not offer the higher tag as an update. + if _, ok := SelectNextRelease("v0.7.45", releases); ok { + t.Fatal("no update when already on the marked latest") + } + // Running above the marked latest must not be pushed anywhere. + if _, ok := SelectNextRelease("v0.7.59", releases); ok { + t.Fatal("no update when running above the marked latest") + } +} + +func TestSelectNextReleaseIgnoresDraftOrPrereleaseMarker(t *testing.T) { + releases := []Release{ + {TagName: "v0.2.6", Latest: true, Prerelease: true}, + {TagName: "v0.2.5"}, + } + + next, ok := SelectNextRelease("v0.2.4", releases) + if !ok || next.TagName != "v0.2.5" { + t.Fatalf("next = %+v, ok = %v, want v0.2.5", next, ok) + } +} + func TestUpgradePathListsIntermediateStableVersions(t *testing.T) { releases := []Release{ {TagName: "v0.2.3"}, diff --git a/internal/updater/executor.go b/internal/updater/executor.go index 143e7eab..56cfdf98 100644 --- a/internal/updater/executor.go +++ b/internal/updater/executor.go @@ -37,6 +37,9 @@ type Executor struct { client *http.Client download *http.Client fetch func(context.Context, string, string) ([]byte, error) + // pullBackoff is the first retry delay after a stalled docker pull. Zero + // uses pullRetryBase so tests can retry instantly. + pullBackoff time.Duration } type commandRunner interface { @@ -102,6 +105,44 @@ func NewExecutor(config ExecutorConfig) *Executor { } } +// One docker pull attempt is bounded so a stalled registry connection cannot +// consume the whole preparation budget: layers that already arrived stay in the +// local cache, so the retry resumes instead of starting the pull over. +const ( + pullAttempts = 3 + pullAttemptTimeout = 4 * time.Minute + pullRetryBase = 15 * time.Second +) + +func (e *Executor) pullImage(ctx context.Context, image string) error { + var lastErr error + for attempt := 1; attempt <= pullAttempts; attempt++ { + pullCtx, cancel := context.WithTimeout(ctx, pullAttemptTimeout) + _, err := e.runner.Run(pullCtx, "docker", "pull", image) + cancel() + if err == nil { + return nil + } + lastErr = fmt.Errorf("pull %s (attempt %d/%d): %w", image, attempt, pullAttempts, err) + if ctx.Err() != nil { + return ctx.Err() + } + if attempt == pullAttempts { + break + } + backoff := e.pullBackoff + if backoff <= 0 { + backoff = pullRetryBase + } + select { + case <-ctx.Done(): + return ctx.Err() + case <-time.After(time.Duration(attempt) * backoff): + } + } + return lastErr +} + func (e *Executor) Prepare(ctx context.Context, _ string, request control.PrepareRequest, progress func(string)) error { if err := e.validateConfig(); err != nil { return err @@ -114,10 +155,14 @@ func (e *Executor) Prepare(ctx context.Context, _ string, request control.Prepar } targetImage := e.config.ImageRepository + ":" + request.TargetVersion progress("pulling") - if _, err := e.runner.Run(ctx, "docker", "pull", targetImage); err != nil { + if err := e.pullImage(ctx, targetImage); err != nil { return fmt.Errorf("pull target image: %w", err) } - return e.stageHostBinary(ctx, request.TargetVersion, progress) + // The pulled image is what the update needs. The host updater binary is taken + // from that image (and refreshed again from the recreated container during + // apply), so a staging hiccup must not fail an otherwise ready update. + _ = e.stageHostBinary(ctx, request.TargetVersion, progress) + return nil } func (e *Executor) Apply(ctx context.Context, _ string, request ApplyRequest, progress func(string)) (bool, error) { @@ -151,17 +196,15 @@ func (e *Executor) Apply(ctx context.Context, _ string, request ApplyRequest, pr if _, err := e.runner.Run(ctx, "docker", "image", "inspect", targetImage); err != nil { return false, fmt.Errorf("prepared image is unavailable: %w", err) } - if err := e.stageHostBinary(ctx, request.TargetVersion, progress); err != nil { - return false, err - } + // A staging failure never blocks the update: the updater binary is + // refreshed from the recreated container below. + _ = e.stageHostBinary(ctx, request.TargetVersion, progress) } else { progress("pulling") - if _, err := e.runner.Run(ctx, "docker", "pull", targetImage); err != nil { - return false, err - } - if err := e.stageHostBinary(ctx, request.TargetVersion, progress); err != nil { + if err := e.pullImage(ctx, targetImage); err != nil { return false, err } + _ = e.stageHostBinary(ctx, request.TargetVersion, progress) } if err := setEnvValueAtomic(e.config.EnvFile, envMode, "CLI2API_IMAGE", targetImage); err != nil { return false, err @@ -189,11 +232,10 @@ func (e *Executor) Apply(ctx context.Context, _ string, request ApplyRequest, pr } return e.rollback(request, before, mount, currentImage, envMode, err, progress) } - if err := e.refreshStagedHostBinaryFromContainer(ctx); err != nil && strings.TrimSpace(e.config.HostBinaryPath) != "" { - if _, statErr := os.Stat(e.config.HostBinaryPath + ".new"); statErr != nil { - return e.rollback(request, before, mount, currentImage, envMode, fmt.Errorf("copy host updater from container: %w", err), progress) - } - } + // Refresh the host updater binary from the freshly recreated container. + // Failure here only leaves the previous updater in place: the app update is + // already health-checked, so it must not be rolled back for this alone. + _ = e.refreshStagedHostBinaryFromContainer(ctx) if err := e.CommitHostBinary(); err != nil { return e.rollback(request, before, mount, currentImage, envMode, err, progress) } @@ -362,7 +404,7 @@ func (e *Executor) waitForVersion(ctx context.Context, expected string) error { } decodeErr := json.NewDecoder(io.LimitReader(resp.Body, 64<<10)).Decode(&health) _ = resp.Body.Close() - if resp.StatusCode < 300 && decodeErr == nil && health.OK && health.Version == expected { + if resp.StatusCode < 300 && decodeErr == nil && health.OK && versionsMatch(health.Version, expected) { return nil } } @@ -376,6 +418,24 @@ func (e *Executor) waitForVersion(ctx context.Context, expected string) error { return fmt.Errorf("health check did not reach version %s", expected) } +// versionsMatch compares the version reported by /health with the version the +// updater expects. Images are built with APP_VERSION set to the release tag +// ("v0.7.52") while the console sends the bare semver ("0.7.52"), so a string +// equality check would fail every deploy and trigger a needless rollback. +func versionsMatch(reported, expected string) bool { + reported = strings.TrimSpace(reported) + expected = strings.TrimSpace(expected) + if reported == expected { + return true + } + left, leftErr := control.ParseVersion(reported) + right, rightErr := control.ParseVersion(expected) + if leftErr != nil || rightErr != nil { + return false + } + return left.Compare(right) == 0 +} + func (e *Executor) validateConfig() error { for name, value := range map[string]string{ "compose file": e.config.ComposeFile, diff --git a/internal/updater/executor_test.go b/internal/updater/executor_test.go index ac4d0587..9ff317cf 100644 --- a/internal/updater/executor_test.go +++ b/internal/updater/executor_test.go @@ -299,6 +299,18 @@ func composeArgs(envPath, composePath string, args ...string) []string { return append(result, args...) } +func TestNewExecutorResolvesGitHubRepo(t *testing.T) { + if got := NewExecutor(ExecutorConfig{}).config.GitHubRepo; got != "caigee-cmd/cli2api" { + t.Fatalf("default repo = %q", got) + } + if got := NewExecutor(ExecutorConfig{GitHubRepo: "caigee-cmd/cli2api"}).config.GitHubRepo; got != "caigee-cmd/cli2api" { + t.Fatalf("override repo = %q", got) + } + if got := NewExecutor(ExecutorConfig{}).config.ImageRepository; got != "ghcr.io/caigee-cmd/cli2api" { + t.Fatalf("default image repository = %q", got) + } +} + func restoreSQLiteScript() string { return `set -eu test -f "$BACKUP_PATH" diff --git a/internal/updater/host_binary.go b/internal/updater/host_binary.go index aff2f8ca..2f97a7ab 100644 --- a/internal/updater/host_binary.go +++ b/internal/updater/host_binary.go @@ -17,6 +17,10 @@ import ( const maxHostBinaryBytes = 64 << 20 +// imageUpdaterPath is where the app image carries the updater binary, so the +// host copy can always come from the image that was just pulled. +const imageUpdaterPath = "/app/cli2api-updater" + func (e *Executor) stageHostBinary(ctx context.Context, version string, progress func(string)) error { hostPath := strings.TrimSpace(e.config.HostBinaryPath) if hostPath == "" { @@ -25,10 +29,14 @@ func (e *Executor) stageHostBinary(ctx context.Context, version string, progress if progress != nil { progress("host_binary") } + imageErr := e.stageHostBinaryFromImage(ctx, version) + if imageErr == nil { + return nil + } asset := hostUpdaterAssetName() body, err := e.downloadReleaseFile(ctx, version, asset) if err != nil { - return fmt.Errorf("download host updater: %w", err) + return fmt.Errorf("download host updater: %w (image extraction failed: %v)", err, imageErr) } if len(body) == 0 || len(body) > maxHostBinaryBytes { return fmt.Errorf("host updater is empty or too large") @@ -47,6 +55,57 @@ func (e *Executor) stageHostBinary(ctx context.Context, version string, progress return nil } +// stageHostBinaryFromImage copies the updater binary out of the target image. +// The image that was just pulled always carries a matching updater, so this +// keeps the host binary in lockstep with the released version and removes the +// dependency on GitHub release-asset downloads (which stall on slow routes). +func (e *Executor) stageHostBinaryFromImage(ctx context.Context, version string) error { + hostPath := strings.TrimSpace(e.config.HostBinaryPath) + if hostPath == "" { + return nil + } + repository := strings.Trim(strings.TrimSpace(e.config.ImageRepository), "/") + if repository == "" { + return fmt.Errorf("image repository is empty") + } + targetImage := repository + ":" + version + output, err := e.runner.Run(ctx, "docker", "create", targetImage) + containerID := lastNonEmptyLine(string(output)) + if err != nil { + return fmt.Errorf("create updater staging container: %w", err) + } + if containerID == "" { + return fmt.Errorf("docker create returned no container id") + } + defer func() { + cleanupCtx, cancel := context.WithTimeout(context.Background(), 30*time.Second) + defer cancel() + _, _ = e.runner.Run(cleanupCtx, "docker", "rm", "-f", containerID) + }() + staged := hostPath + ".new" + if _, err := e.runner.Run(ctx, "docker", "cp", containerID+":"+imageUpdaterPath, staged); err != nil { + return fmt.Errorf("copy updater from image: %w", err) + } + info, err := os.Stat(staged) + if err != nil { + return fmt.Errorf("stat staged host updater: %w", err) + } + if info.Size() == 0 || info.Size() > maxHostBinaryBytes { + return fmt.Errorf("host updater from image is empty or too large") + } + return os.Chmod(staged, 0o755) +} + +func lastNonEmptyLine(text string) string { + lines := strings.Split(text, "\n") + for i := len(lines) - 1; i >= 0; i-- { + if line := strings.TrimSpace(lines[i]); line != "" { + return line + } + } + return "" +} + func (e *Executor) refreshStagedHostBinaryFromContainer(ctx context.Context) error { if runtime.GOOS != "linux" { return nil diff --git a/internal/updater/host_binary_test.go b/internal/updater/host_binary_test.go index 14d9ee9d..8812f53d 100644 --- a/internal/updater/host_binary_test.go +++ b/internal/updater/host_binary_test.go @@ -4,8 +4,10 @@ import ( "context" "crypto/sha256" "encoding/hex" + "errors" "os" "path/filepath" + "runtime" "testing" ) @@ -19,6 +21,7 @@ func TestStageHostBinaryWritesVerifiedPayload(t *testing.T) { sum := sha256.Sum256(payload) asset := hostUpdaterAssetName() executor := NewExecutor(ExecutorConfig{HostBinaryPath: hostPath}) + executor.runner = failingRunner{} executor.fetch = func(_ context.Context, version, name string) ([]byte, error) { if version != "v0.2.47" { t.Fatalf("version = %s", version) @@ -80,6 +83,52 @@ func TestVerifyHostBinaryChecksumRejectsMismatch(t *testing.T) { } } +func TestStageHostBinaryPrefersBinaryFromImage(t *testing.T) { + directory := t.TempDir() + hostPath := filepath.Join(directory, "cli2api-updater") + payload := []byte("image-updater-binary") + const containerID = "abc123def456" + runner := &scriptedRunner{t: t, steps: []runnerStep{ + {name: "docker", args: []string{"create", "ghcr.io/guyu233/cli2api:v0.3.0"}, output: []byte(containerID + "\n")}, + {name: "docker", args: []string{"cp", containerID + ":" + imageUpdaterPath, hostPath + ".new"}, beforeReturn: func() { + if err := os.WriteFile(hostPath+".new", payload, 0o600); err != nil { + t.Fatal(err) + } + }}, + {name: "docker", args: []string{"rm", "-f", containerID}}, + }} + executor := NewExecutor(ExecutorConfig{HostBinaryPath: hostPath, ImageRepository: "ghcr.io/guyu233/cli2api"}) + executor.runner = runner + executor.fetch = func(context.Context, string, string) ([]byte, error) { + t.Fatal("GitHub fallback must not run when the image carries the updater") + return nil, nil + } + if err := executor.stageHostBinary(context.Background(), "v0.3.0", nil); err != nil { + t.Fatal(err) + } + staged, err := os.ReadFile(hostPath + ".new") + if err != nil { + t.Fatal(err) + } + if string(staged) != string(payload) { + t.Fatalf("staged = %q", staged) + } + info, err := os.Stat(hostPath + ".new") + if err != nil { + t.Fatal(err) + } + if runtime.GOOS != "windows" && info.Mode().Perm() != 0o755 { + t.Fatalf("mode = %v", info.Mode().Perm()) + } + runner.assertDone() +} + +type failingRunner struct{} + +func (failingRunner) Run(context.Context, string, ...string) ([]byte, error) { + return nil, errors.New("docker unavailable") +} + func TestRestartHostExitsProcess(t *testing.T) { exited := 0 original := osExit diff --git a/internal/updater/pull_test.go b/internal/updater/pull_test.go new file mode 100644 index 00000000..2f933f9d --- /dev/null +++ b/internal/updater/pull_test.go @@ -0,0 +1,40 @@ +package updater + +import ( + "context" + "errors" + "testing" + "time" +) + +func TestPullImageRetriesAfterStalledAttempt(t *testing.T) { + image := "ghcr.io/guyu233/cli2api:v0.3.0" + runner := &scriptedRunner{t: t, steps: []runnerStep{ + {name: "docker", args: []string{"pull", image}, err: errors.New("unexpected EOF")}, + {name: "docker", args: []string{"pull", image}}, + }} + executor := NewExecutor(ExecutorConfig{}) + executor.runner = runner + executor.pullBackoff = time.Millisecond + if err := executor.pullImage(context.Background(), image); err != nil { + t.Fatal(err) + } + runner.assertDone() +} + +func TestPullImageGivesUpAfterAllAttempts(t *testing.T) { + image := "ghcr.io/guyu233/cli2api:v0.3.0" + stalled := errors.New("stalled") + runner := &scriptedRunner{t: t, steps: []runnerStep{ + {name: "docker", args: []string{"pull", image}, err: stalled}, + {name: "docker", args: []string{"pull", image}, err: stalled}, + {name: "docker", args: []string{"pull", image}, err: stalled}, + }} + executor := NewExecutor(ExecutorConfig{}) + executor.runner = runner + executor.pullBackoff = time.Millisecond + if err := executor.pullImage(context.Background(), image); err == nil { + t.Fatal("expected the pull to fail after all attempts") + } + runner.assertDone() +} diff --git a/internal/updater/version_match_test.go b/internal/updater/version_match_test.go new file mode 100644 index 00000000..57bfe651 --- /dev/null +++ b/internal/updater/version_match_test.go @@ -0,0 +1,25 @@ +package updater + +import "testing" + +func TestVersionsMatch(t *testing.T) { + cases := []struct { + reported string + expected string + want bool + }{ + {"v0.7.52", "0.7.52", true}, + {"0.7.52", "v0.7.52", true}, + {"v0.7.52", "v0.7.52", true}, + {" v0.7.52 ", "0.7.52", true}, + {"v0.7.51", "0.7.52", false}, + {"v0.7.520", "0.7.52", false}, + {"dev", "0.7.52", false}, + {"", "0.7.52", false}, + } + for _, tc := range cases { + if got := versionsMatch(tc.reported, tc.expected); got != tc.want { + t.Fatalf("versionsMatch(%q, %q) = %v, want %v", tc.reported, tc.expected, got, tc.want) + } + } +} diff --git a/internal/webui/static/assets/AccessPage-B5Xris9V.js b/internal/webui/static/assets/AccessPage-Drab69vZ.js similarity index 56% rename from internal/webui/static/assets/AccessPage-B5Xris9V.js rename to internal/webui/static/assets/AccessPage-Drab69vZ.js index fc2025ab..7d58923e 100644 --- a/internal/webui/static/assets/AccessPage-B5Xris9V.js +++ b/internal/webui/static/assets/AccessPage-Drab69vZ.js @@ -1,10 +1,10 @@ -import{a as e,c as t,n}from"./shim-mfK0Rmj6.js";import{a as r,i,n as a,o,r as s,s as c,t as l}from"./CaiaiSoftLink-BXfOUHck.js";import{t as u}from"./CaretRight.es-D5fytEam.js";import{t as d}from"./clipboard-BMEt1jHG.js";import{t as f}from"./Plus.es-W6ztpkEI.js";import{n as p,pt as m,r as h}from"./useI18n-BSw4X3mq.js";import{t as g}from"./label-n7vfsS35.js";import{t as _}from"./list-box-DD4xJ3gX.js";import{t as v}from"./PageAlert-CaDjxveS.js";import{t as y}from"./EmptyPanel-Bs-jQMvG.js";import{n as b,t as x}from"./tabs-Cm-IDu6Q.js";import{t as S}from"./select-CtWmaZQ5.js";import{T as ee,p as te,t as ne,u as re,w as C}from"./overview-m01k08K8.js";import{r as w}from"./gsap-C3sDxib7.js";import{Dt as ie,M as ae,Mt as T,O as oe,Ot as se,Vt as ce,i as le,j as E,jt as ue,t as de,v as D,x as O,y as k}from"./index-C8_qeOs_.js";import{t as fe}from"./FilterToggle-16Av-HiR.js";import{d as pe,f as me,i as he,o as A}from"./format-B6SmebW-.js";import{t as ge}from"./ProviderMark-IiAZTaQS.js";import{n as _e}from"./provider-gHnttGKq.js";import{t as ve}from"./LatencyStats-DmxRwO-O.js";var j=t(e(),1),ye=new Map([[`bold`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M54.8,119.49A35.06,35.06,0,0,1,49.05,128a35.06,35.06,0,0,1,5.75,8.51C60,147.24,60,159.83,60,172c0,25.94,1.84,32,20,32a12,12,0,0,1,0,24c-19.14,0-32.2-6.9-38.8-20.51C36,196.76,36,184.17,36,172c0-25.94-1.84-32-20-32a12,12,0,0,1,0-24c18.16,0,20-6.06,20-32,0-12.17,0-24.76,5.2-35.49C47.8,34.9,60.86,28,80,28a12,12,0,0,1,0,24c-18.16,0-20,6.06-20,32C60,96.17,60,108.76,54.8,119.49ZM240,116c-18.16,0-20-6.06-20-32,0-12.17,0-24.76-5.2-35.49C208.2,34.9,195.14,28,176,28a12,12,0,0,0,0,24c18.16,0,20,6.06,20,32,0,12.17,0,24.76,5.2,35.49A35.06,35.06,0,0,0,207,128a35.06,35.06,0,0,0-5.75,8.51C196,147.24,196,159.83,196,172c0,25.94-1.84,32-20,32a12,12,0,0,0,0,24c19.14,0,32.2-6.9,38.8-20.51C220,196.76,220,184.17,220,172c0-25.94,1.84-32,20-32a12,12,0,0,0,0-24Z`}))],[`duotone`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M240,128c-64,0,0,88-64,88H80c-64,0,0-88-64-88,64,0,0-88,64-88h96C240,40,176,128,240,128Z`,opacity:`0.2`}),j.createElement(`path`,{d:`M43.18,128a29.78,29.78,0,0,1,8,10.26c4.8,9.9,4.8,22,4.8,33.74,0,24.31,1,36,24,36a8,8,0,0,1,0,16c-17.48,0-29.32-6.14-35.2-18.26-4.8-9.9-4.8-22-4.8-33.74,0-24.31-1-36-24-36a8,8,0,0,1,0-16c23,0,24-11.69,24-36,0-11.72,0-23.84,4.8-33.74C50.68,38.14,62.52,32,80,32a8,8,0,0,1,0,16C57,48,56,59.69,56,84c0,11.72,0,23.84-4.8,33.74A29.78,29.78,0,0,1,43.18,128ZM240,120c-23,0-24-11.69-24-36,0-11.72,0-23.84-4.8-33.74C205.32,38.14,193.48,32,176,32a8,8,0,0,0,0,16c23,0,24,11.69,24,36,0,11.72,0,23.84,4.8,33.74a29.78,29.78,0,0,0,8,10.26,29.78,29.78,0,0,0-8,10.26c-4.8,9.9-4.8,22-4.8,33.74,0,24.31-1,36-24,36a8,8,0,0,0,0,16c17.48,0,29.32-6.14,35.2-18.26,4.8-9.9,4.8-22,4.8-33.74,0-24.31,1-36,24-36a8,8,0,0,0,0-16Z`}))],[`fill`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M216,40H40A16,16,0,0,0,24,56V200a16,16,0,0,0,16,16H216a16,16,0,0,0,16-16V56A16,16,0,0,0,216,40ZM88,155.84c.29,14.26.41,20.16,16,20.16a8,8,0,0,1,0,16c-31.27,0-31.72-22.43-32-35.84C71.71,141.9,71.59,136,56,136a8,8,0,0,1,0-16c15.59,0,15.71-5.9,16-20.16C72.28,86.43,72.73,64,104,64a8,8,0,0,1,0,16c-15.59,0-15.71,5.9-16,20.16-.17,8.31-.41,20.09-8,27.84C87.59,135.75,87.83,147.53,88,155.84ZM200,136c-15.59,0-15.71,5.9-16,20.16-.28,13.41-.73,35.84-32,35.84a8,8,0,0,1,0-16c15.59,0,15.71-5.9,16-20.16.17-8.31.41-20.09,8-27.84-7.6-7.75-7.84-19.53-8-27.84C167.71,85.9,167.59,80,152,80a8,8,0,0,1,0-16c31.27,0,31.72,22.43,32,35.84.29,14.26.41,20.16,16,20.16a8,8,0,0,1,0,16Z`}))],[`light`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M39.91,128a27.68,27.68,0,0,1,9.49,11.13C54,148.62,54,160.51,54,172c0,24.27,1.21,38,26,38a6,6,0,0,1,0,12c-16.88,0-27.81-5.6-33.4-17.13C42,195.38,42,183.49,42,172c0-24.27-1.21-38-26-38a6,6,0,0,1,0-12c24.79,0,26-13.73,26-38,0-11.49,0-23.38,4.6-32.87C52.19,39.6,63.12,34,80,34a6,6,0,0,1,0,12C55.21,46,54,59.73,54,84c0,11.49,0,23.38-4.6,32.87A27.68,27.68,0,0,1,39.91,128ZM240,122c-24.79,0-26-13.73-26-38,0-11.49,0-23.38-4.6-32.87C203.81,39.6,192.88,34,176,34a6,6,0,0,0,0,12c24.79,0,26,13.73,26,38,0,11.49,0,23.38,4.6,32.87A27.68,27.68,0,0,0,216.09,128a27.68,27.68,0,0,0-9.49,11.13C202,148.62,202,160.51,202,172c0,24.27-1.21,38-26,38a6,6,0,0,0,0,12c16.88,0,27.81-5.6,33.4-17.13,4.6-9.49,4.6-21.38,4.6-32.87,0-24.27,1.21-38,26-38a6,6,0,0,0,0-12Z`}))],[`regular`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M43.18,128a29.78,29.78,0,0,1,8,10.26c4.8,9.9,4.8,22,4.8,33.74,0,24.31,1,36,24,36a8,8,0,0,1,0,16c-17.48,0-29.32-6.14-35.2-18.26-4.8-9.9-4.8-22-4.8-33.74,0-24.31-1-36-24-36a8,8,0,0,1,0-16c23,0,24-11.69,24-36,0-11.72,0-23.84,4.8-33.74C50.68,38.14,62.52,32,80,32a8,8,0,0,1,0,16C57,48,56,59.69,56,84c0,11.72,0,23.84-4.8,33.74A29.78,29.78,0,0,1,43.18,128ZM240,120c-23,0-24-11.69-24-36,0-11.72,0-23.84-4.8-33.74C205.32,38.14,193.48,32,176,32a8,8,0,0,0,0,16c23,0,24,11.69,24,36,0,11.72,0,23.84,4.8,33.74a29.78,29.78,0,0,0,8,10.26,29.78,29.78,0,0,0-8,10.26c-4.8,9.9-4.8,22-4.8,33.74,0,24.31-1,36-24,36a8,8,0,0,0,0,16c17.48,0,29.32-6.14,35.2-18.26,4.8-9.9,4.8-22,4.8-33.74,0-24.31,1-36,24-36a8,8,0,0,0,0-16Z`}))],[`thin`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M35.89,128C52,136.23,52,155.64,52,172c0,24.8,1.35,40,28,40a4,4,0,0,1,0,8c-36,0-36-26.61-36-48,0-24.8-1.35-40-28-40a4,4,0,0,1,0-8c26.65,0,28-15.2,28-40,0-21.39,0-48,36-48a4,4,0,0,1,0,8C53.35,44,52,59.2,52,84,52,100.36,52,119.77,35.89,128ZM240,124c-26.65,0-28-15.2-28-40,0-21.39,0-48-36-48a4,4,0,0,0,0,8c26.65,0,28,15.2,28,40,0,16.36,0,35.77,16.11,44C204,136.23,204,155.64,204,172c0,24.8-1.35,40-28,40a4,4,0,0,0,0,8c36,0,36-26.61,36-48,0-24.8,1.35-40,28-40a4,4,0,0,0,0-8Z`}))]]),M=new Map([[`bold`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M120,128a16,16,0,1,1-16-16A16,16,0,0,1,120,128Zm32-16a16,16,0,1,0,16,16A16,16,0,0,0,152,112Zm84,16A108,108,0,0,1,78.77,224.15L46.34,235A20,20,0,0,1,21,209.66l10.81-32.43A108,108,0,1,1,236,128Zm-24,0A84,84,0,1,0,55.27,170.06a12,12,0,0,1,1,9.81l-9.93,29.79,29.79-9.93a12.1,12.1,0,0,1,3.8-.62,12,12,0,0,1,6,1.62A84,84,0,0,0,212,128Z`}))],[`duotone`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M224,128A96,96,0,0,1,79.93,211.11h0L42.54,223.58a8,8,0,0,1-10.12-10.12l12.47-37.39h0A96,96,0,1,1,224,128Z`,opacity:`0.2`}),j.createElement(`path`,{d:`M128,24A104,104,0,0,0,36.18,176.88L24.83,210.93a16,16,0,0,0,20.24,20.24l34.05-11.35A104,104,0,1,0,128,24Zm0,192a87.87,87.87,0,0,1-44.06-11.81,8,8,0,0,0-4-1.08,7.85,7.85,0,0,0-2.53.42L40,216,52.47,178.6a8,8,0,0,0-.66-6.54A88,88,0,1,1,128,216Zm12-88a12,12,0,1,1-12-12A12,12,0,0,1,140,128Zm-44,0a12,12,0,1,1-12-12A12,12,0,0,1,96,128Zm88,0a12,12,0,1,1-12-12A12,12,0,0,1,184,128Z`}))],[`fill`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M128,24A104,104,0,0,0,36.18,176.88L24.83,210.93a16,16,0,0,0,20.24,20.24l34.05-11.35A104,104,0,1,0,128,24ZM84,140a12,12,0,1,1,12-12A12,12,0,0,1,84,140Zm44,0a12,12,0,1,1,12-12A12,12,0,0,1,128,140Zm44,0a12,12,0,1,1,12-12A12,12,0,0,1,172,140Z`}))],[`light`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M138,128a10,10,0,1,1-10-10A10,10,0,0,1,138,128ZM84,118a10,10,0,1,0,10,10A10,10,0,0,0,84,118Zm88,0a10,10,0,1,0,10,10A10,10,0,0,0,172,118Zm58,10A102,102,0,0,1,79.31,217.65L44.44,229.27a14,14,0,0,1-17.71-17.71l11.62-34.87A102,102,0,1,1,230,128Zm-12,0A90,90,0,1,0,50.08,173.06a6,6,0,0,1,.5,4.91L38.12,215.35a2,2,0,0,0,2.53,2.53L78,205.42a6.2,6.2,0,0,1,1.9-.31,6.09,6.09,0,0,1,3,.81A90,90,0,0,0,218,128Z`}))],[`regular`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M140,128a12,12,0,1,1-12-12A12,12,0,0,1,140,128ZM84,116a12,12,0,1,0,12,12A12,12,0,0,0,84,116Zm88,0a12,12,0,1,0,12,12A12,12,0,0,0,172,116Zm60,12A104,104,0,0,1,79.12,219.82L45.07,231.17a16,16,0,0,1-20.24-20.24l11.35-34.05A104,104,0,1,1,232,128Zm-16,0A88,88,0,1,0,51.81,172.06a8,8,0,0,1,.66,6.54L40,216,77.4,203.53a7.85,7.85,0,0,1,2.53-.42,8,8,0,0,1,4,1.08A88,88,0,0,0,216,128Z`}))],[`thin`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M136,128a8,8,0,1,1-8-8A8,8,0,0,1,136,128Zm-52-8a8,8,0,1,0,8,8A8,8,0,0,0,84,120Zm88,0a8,8,0,1,0,8,8A8,8,0,0,0,172,120Zm56,8A100,100,0,0,1,79.5,215.47l-35.69,11.9a12,12,0,0,1-15.18-15.18l11.9-35.69A100,100,0,1,1,228,128Zm-8,0A92,92,0,1,0,48.35,174.07a4,4,0,0,1,.33,3.27L36.22,214.72a4,4,0,0,0,5.06,5.06l37.38-12.46a3.93,3.93,0,0,1,1.27-.21,4.05,4.05,0,0,1,2,.54A92,92,0,0,0,220,128Z`}))]]),be=new Map([[`bold`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M236,128a108,108,0,0,1-216,0c0-42.52,24.73-81.34,63-98.9A12,12,0,1,1,93,50.91C63.24,64.57,44,94.83,44,128a84,84,0,0,0,168,0c0-33.17-19.24-63.43-49-77.09A12,12,0,1,1,173,29.1C211.27,46.66,236,85.48,236,128Z`}))],[`duotone`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M224,128a96,96,0,1,1-96-96A96,96,0,0,1,224,128Z`,opacity:`0.2`}),j.createElement(`path`,{d:`M232,128a104,104,0,0,1-208,0c0-41,23.81-78.36,60.66-95.27a8,8,0,0,1,6.68,14.54C60.15,61.59,40,93.27,40,128a88,88,0,0,0,176,0c0-34.73-20.15-66.41-51.34-80.73a8,8,0,0,1,6.68-14.54C208.19,49.64,232,87,232,128Z`}))],[`fill`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,176A72,72,0,0,1,92,65.64a8,8,0,0,1,8,13.85,56,56,0,1,0,56,0,8,8,0,0,1,8-13.85A72,72,0,0,1,128,200Z`}))],[`light`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M230,128a102,102,0,0,1-204,0c0-40.18,23.35-76.86,59.5-93.45a6,6,0,0,1,5,10.9C58.61,60.09,38,92.49,38,128a90,90,0,0,0,180,0c0-35.51-20.61-67.91-52.5-82.55a6,6,0,0,1,5-10.9C206.65,51.14,230,87.82,230,128Z`}))],[`regular`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M232,128a104,104,0,0,1-208,0c0-41,23.81-78.36,60.66-95.27a8,8,0,0,1,6.68,14.54C60.15,61.59,40,93.27,40,128a88,88,0,0,0,176,0c0-34.73-20.15-66.41-51.34-80.73a8,8,0,0,1,6.68-14.54C208.19,49.64,232,87,232,128Z`}))],[`thin`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M228,128a100,100,0,0,1-200,0c0-39.4,22.9-75.37,58.33-91.63a4,4,0,1,1,3.34,7.27C57.07,58.6,36,91.71,36,128a92,92,0,0,0,184,0c0-36.29-21.07-69.4-53.67-84.36a4,4,0,1,1,3.34-7.27C205.1,52.63,228,88.6,228,128Z`}))]]),xe=new Map([[`bold`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M128,20A108,108,0,1,0,236,128,108.12,108.12,0,0,0,128,20Zm0,192a84,84,0,1,1,84-84A84.09,84.09,0,0,1,128,212Zm68-84a12,12,0,0,1-12,12H128a12,12,0,0,1-12-12V72a12,12,0,0,1,24,0v44h44A12,12,0,0,1,196,128Z`}))],[`duotone`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M224,128a96,96,0,1,1-96-96A96,96,0,0,1,224,128Z`,opacity:`0.2`}),j.createElement(`path`,{d:`M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Zm64-88a8,8,0,0,1-8,8H128a8,8,0,0,1-8-8V72a8,8,0,0,1,16,0v48h48A8,8,0,0,1,192,128Z`}))],[`fill`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm56,112H128a8,8,0,0,1-8-8V72a8,8,0,0,1,16,0v48h48a8,8,0,0,1,0,16Z`}))],[`light`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M128,26A102,102,0,1,0,230,128,102.12,102.12,0,0,0,128,26Zm0,192a90,90,0,1,1,90-90A90.1,90.1,0,0,1,128,218Zm62-90a6,6,0,0,1-6,6H128a6,6,0,0,1-6-6V72a6,6,0,0,1,12,0v50h50A6,6,0,0,1,190,128Z`}))],[`regular`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Zm64-88a8,8,0,0,1-8,8H128a8,8,0,0,1-8-8V72a8,8,0,0,1,16,0v48h48A8,8,0,0,1,192,128Z`}))],[`thin`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M128,28A100,100,0,1,0,228,128,100.11,100.11,0,0,0,128,28Zm0,192a92,92,0,1,1,92-92A92.1,92.1,0,0,1,128,220Zm60-92a4,4,0,0,1-4,4H128a4,4,0,0,1-4-4V72a4,4,0,0,1,8,0v52h52A4,4,0,0,1,188,128Z`}))]]),N=new Map([[`bold`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M180,64H40A12,12,0,0,0,28,76V216a12,12,0,0,0,12,12H180a12,12,0,0,0,12-12V76A12,12,0,0,0,180,64ZM168,204H52V88H168ZM228,40V180a12,12,0,0,1-24,0V52H76a12,12,0,0,1,0-24H216A12,12,0,0,1,228,40Z`}))],[`duotone`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M184,72V216H40V72Z`,opacity:`0.2`}),j.createElement(`path`,{d:`M184,64H40a8,8,0,0,0-8,8V216a8,8,0,0,0,8,8H184a8,8,0,0,0,8-8V72A8,8,0,0,0,184,64Zm-8,144H48V80H176ZM224,40V184a8,8,0,0,1-16,0V48H72a8,8,0,0,1,0-16H216A8,8,0,0,1,224,40Z`}))],[`fill`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M192,72V216a8,8,0,0,1-8,8H40a8,8,0,0,1-8-8V72a8,8,0,0,1,8-8H184A8,8,0,0,1,192,72Zm24-40H72a8,8,0,0,0,0,16H208V184a8,8,0,0,0,16,0V40A8,8,0,0,0,216,32Z`}))],[`light`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M184,66H40a6,6,0,0,0-6,6V216a6,6,0,0,0,6,6H184a6,6,0,0,0,6-6V72A6,6,0,0,0,184,66Zm-6,144H46V78H178ZM222,40V184a6,6,0,0,1-12,0V46H72a6,6,0,0,1,0-12H216A6,6,0,0,1,222,40Z`}))],[`regular`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M184,64H40a8,8,0,0,0-8,8V216a8,8,0,0,0,8,8H184a8,8,0,0,0,8-8V72A8,8,0,0,0,184,64Zm-8,144H48V80H176ZM224,40V184a8,8,0,0,1-16,0V48H72a8,8,0,0,1,0-16H216A8,8,0,0,1,224,40Z`}))],[`thin`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M184,68H40a4,4,0,0,0-4,4V216a4,4,0,0,0,4,4H184a4,4,0,0,0,4-4V72A4,4,0,0,0,184,68Zm-4,144H44V76H180ZM220,40V184a4,4,0,0,1-8,0V44H72a4,4,0,0,1,0-8H216A4,4,0,0,1,220,40Z`}))]]),P=new Map([[`bold`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M216.49,79.52l-56-56A12,12,0,0,0,152,20H56A20,20,0,0,0,36,40V216a20,20,0,0,0,20,20H200a20,20,0,0,0,20-20V88A12,12,0,0,0,216.49,79.52ZM160,57l23,23H160ZM60,212V44h76V92a12,12,0,0,0,12,12h48V212Zm112-80a12,12,0,0,1-12,12H96a12,12,0,0,1,0-24h64A12,12,0,0,1,172,132Zm0,40a12,12,0,0,1-12,12H96a12,12,0,0,1,0-24h64A12,12,0,0,1,172,172Z`}))],[`duotone`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M208,88H152V32Z`,opacity:`0.2`}),j.createElement(`path`,{d:`M213.66,82.34l-56-56A8,8,0,0,0,152,24H56A16,16,0,0,0,40,40V216a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V88A8,8,0,0,0,213.66,82.34ZM160,51.31,188.69,80H160ZM200,216H56V40h88V88a8,8,0,0,0,8,8h48V216Zm-32-80a8,8,0,0,1-8,8H96a8,8,0,0,1,0-16h64A8,8,0,0,1,168,136Zm0,32a8,8,0,0,1-8,8H96a8,8,0,0,1,0-16h64A8,8,0,0,1,168,168Z`}))],[`fill`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M213.66,82.34l-56-56A8,8,0,0,0,152,24H56A16,16,0,0,0,40,40V216a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V88A8,8,0,0,0,213.66,82.34ZM160,176H96a8,8,0,0,1,0-16h64a8,8,0,0,1,0,16Zm0-32H96a8,8,0,0,1,0-16h64a8,8,0,0,1,0,16Zm-8-56V44l44,44Z`}))],[`light`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M212.24,83.76l-56-56A6,6,0,0,0,152,26H56A14,14,0,0,0,42,40V216a14,14,0,0,0,14,14H200a14,14,0,0,0,14-14V88A6,6,0,0,0,212.24,83.76ZM158,46.48,193.52,82H158ZM200,218H56a2,2,0,0,1-2-2V40a2,2,0,0,1,2-2h90V88a6,6,0,0,0,6,6h50V216A2,2,0,0,1,200,218Zm-34-82a6,6,0,0,1-6,6H96a6,6,0,0,1,0-12h64A6,6,0,0,1,166,136Zm0,32a6,6,0,0,1-6,6H96a6,6,0,0,1,0-12h64A6,6,0,0,1,166,168Z`}))],[`regular`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M213.66,82.34l-56-56A8,8,0,0,0,152,24H56A16,16,0,0,0,40,40V216a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V88A8,8,0,0,0,213.66,82.34ZM160,51.31,188.69,80H160ZM200,216H56V40h88V88a8,8,0,0,0,8,8h48V216Zm-32-80a8,8,0,0,1-8,8H96a8,8,0,0,1,0-16h64A8,8,0,0,1,168,136Zm0,32a8,8,0,0,1-8,8H96a8,8,0,0,1,0-16h64A8,8,0,0,1,168,168Z`}))],[`thin`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M210.83,85.17l-56-56A4,4,0,0,0,152,28H56A12,12,0,0,0,44,40V216a12,12,0,0,0,12,12H200a12,12,0,0,0,12-12V88A4,4,0,0,0,210.83,85.17ZM156,41.65,198.34,84H156ZM200,220H56a4,4,0,0,1-4-4V40a4,4,0,0,1,4-4h92V88a4,4,0,0,0,4,4h52V216A4,4,0,0,1,200,220Zm-36-84a4,4,0,0,1-4,4H96a4,4,0,0,1,0-8h64A4,4,0,0,1,164,136Zm0,32a4,4,0,0,1-4,4H96a4,4,0,0,1,0-8h64A4,4,0,0,1,164,168Z`}))]]),F=new Map([[`bold`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M71.76,148H31.7a12,12,0,1,1,0-24H65.33l12.45-18.66a12,12,0,0,1,20,0l22,33,6-9a12,12,0,0,1,10-5.34h24a12,12,0,1,1,0,24h-17.6l-12.46,18.66a12,12,0,0,1-20,0l-22-33-6,9A12,12,0,0,1,71.76,148ZM177.91,36c-20.12,0-38,7.93-50.07,21.56C115.74,43.93,97.89,36,77.76,36A66,66,0,0,0,12.07,94.68,12,12,0,0,0,36,97.32,42,42,0,0,1,77.76,60c17.83,0,32.75,9.4,38.95,24.54a12,12,0,0,0,22.25,0C145.16,69.4,160.08,60,177.91,60A42.08,42.08,0,0,1,220,102c0,29.42-25.86,57.77-47.56,76.36a329,329,0,0,1-44.58,31.81c-10.87-6.45-35.37-22-56.51-42.73a12,12,0,1,0-16.84,17.12c30.39,29.81,66.15,49.2,67.66,50a12.06,12.06,0,0,0,11.39,0C138,232.14,244,174.34,244,102A66.12,66.12,0,0,0,177.91,36Z`}))],[`duotone`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M232,102c0,66-104,122-104,122S24,168,24,102A54,54,0,0,1,78,48c22.59,0,41.94,12.31,50,32,8.06-19.69,27.41-32,50-32A54,54,0,0,1,232,102Z`,opacity:`0.2`}),j.createElement(`path`,{d:`M72,144H32a8,8,0,0,1,0-16H67.72l13.62-20.44a8,8,0,0,1,13.32,0l25.34,38,9.34-14A8,8,0,0,1,136,128h24a8,8,0,0,1,0,16H140.28l-13.62,20.44a8,8,0,0,1-13.32,0L88,126.42l-9.34,14A8,8,0,0,1,72,144ZM178,40c-20.65,0-38.73,8.88-50,23.89C116.73,48.88,98.65,40,78,40a62.07,62.07,0,0,0-62,62c0,.75,0,1.5,0,2.25a8,8,0,1,0,16-.5c0-.58,0-1.17,0-1.75A46.06,46.06,0,0,1,78,56c19.45,0,35.78,10.36,42.6,27a8,8,0,0,0,14.8,0c6.82-16.67,23.15-27,42.6-27a46.06,46.06,0,0,1,46,46c0,53.61-77.76,102.15-96,112.8-10.83-6.31-42.63-26-66.68-52.21a8,8,0,1,0-11.8,10.82c31.17,34,72.93,56.68,74.69,57.63a8,8,0,0,0,7.58,0C136.21,228.66,240,172,240,102A62.07,62.07,0,0,0,178,40Z`}))],[`fill`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M240,102c0,70-103.79,126.66-108.21,129a8,8,0,0,1-7.58,0c-3.35-1.8-63.55-34.69-92.68-80.89A4,4,0,0,1,34.92,144H72a8,8,0,0,0,6.66-3.56l9.34-14,25.34,38a8,8,0,0,0,9.16,3.16,8.23,8.23,0,0,0,4.28-3.34L140.28,144H160a8,8,0,0,0,8-8.53,8.18,8.18,0,0,0-8.25-7.47H136a8,8,0,0,0-6.66,3.56l-9.34,14-25.34-38a8,8,0,0,0-9.17-3.16,8.25,8.25,0,0,0-4.27,3.34L67.72,128H23.53a4,4,0,0,1-3.83-2.81A76.93,76.93,0,0,1,16,102,62.07,62.07,0,0,1,78,40c20.65,0,38.73,8.88,50,23.89C139.27,48.88,157.35,40,178,40A62.07,62.07,0,0,1,240,102Z`}))],[`light`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M72,142H32a6,6,0,0,1,0-12H68.79L83,108.67a6,6,0,0,1,10,0l27,40.51,11-16.51a6,6,0,0,1,5-2.67h24a6,6,0,0,1,0,12H139.21L125,163.33a6,6,0,0,1-10,0L88,122.82,77,139.33A6,6,0,0,1,72,142ZM178,42c-21,0-39.26,9.47-50,25.34C117.26,51.47,99,42,78,42a60.07,60.07,0,0,0-60,60q0,1.09,0,2.19a6,6,0,0,0,12-.38c0-.6,0-1.21,0-1.81A48.05,48.05,0,0,1,78,54c20.28,0,37.31,10.83,44.45,28.27a6,6,0,0,0,11.1,0C140.69,64.83,157.72,54,178,54a48.05,48.05,0,0,1,48,48c0,55.73-81.61,105.65-98,115.11-9.84-5.66-43.09-25.82-68.16-53.16a6,6,0,1,0-8.84,8.1c30.94,33.77,72.41,56.29,74.16,57.23a6,6,0,0,0,5.68,0,334.68,334.68,0,0,0,53.06-37C219.8,161.59,238,131.2,238,102A60.07,60.07,0,0,0,178,42Z`}))],[`regular`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M72,144H32a8,8,0,0,1,0-16H67.72l13.62-20.44a8,8,0,0,1,13.32,0l25.34,38,9.34-14A8,8,0,0,1,136,128h24a8,8,0,0,1,0,16H140.28l-13.62,20.44a8,8,0,0,1-13.32,0L88,126.42l-9.34,14A8,8,0,0,1,72,144ZM178,40c-20.65,0-38.73,8.88-50,23.89C116.73,48.88,98.65,40,78,40a62.07,62.07,0,0,0-62,62c0,.75,0,1.5,0,2.25a8,8,0,1,0,16-.5c0-.58,0-1.17,0-1.75A46.06,46.06,0,0,1,78,56c19.45,0,35.78,10.36,42.6,27a8,8,0,0,0,14.8,0c6.82-16.67,23.15-27,42.6-27a46.06,46.06,0,0,1,46,46c0,53.61-77.76,102.15-96,112.8-10.83-6.31-42.63-26-66.68-52.21a8,8,0,1,0-11.8,10.82c31.17,34,72.93,56.68,74.69,57.63a8,8,0,0,0,7.58,0C136.21,228.66,240,172,240,102A62.07,62.07,0,0,0,178,40Z`}))],[`thin`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M72,140H32a4,4,0,0,1,0-8H69.86l14.81-22.22a4,4,0,0,1,6.66,0l28.67,43,12.67-19A4,4,0,0,1,136,132h24a4,4,0,0,1,0,8H138.14l-14.81,22.22a4,4,0,0,1-6.66,0L88,119.21l-12.67,19A4,4,0,0,1,72,140ZM178,44c-21.44,0-39.92,10.19-50,27.07C117.92,54.19,99.44,44,78,44a58.07,58.07,0,0,0-58,58q0,1.06,0,2.13a4,4,0,1,0,8-.26c0-.62,0-1.24,0-1.87A50.06,50.06,0,0,1,78,52c21.11,0,38.85,11.31,46.3,29.51a4,4,0,0,0,7.4,0C139.15,63.31,156.89,52,178,52a50.06,50.06,0,0,1,50,50c0,58-86,109.46-100,117.42-8.47-4.82-43.5-25.61-69.63-54.12a4,4,0,0,0-5.9,5.4c30.72,33.52,71.9,55.89,73.63,56.82a4,4,0,0,0,3.8,0,333.81,333.81,0,0,0,52.7-36.73C218,160.47,236,130.59,236,102A58.07,58.07,0,0,0,178,44Z`}))]]),Se=new Map([[`bold`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M230.14,25.86a20,20,0,0,0-19.57-5.11l-.22.07L18.44,79a20,20,0,0,0-3.06,37.25L99,157l40.71,83.65a19.81,19.81,0,0,0,18,11.38c.57,0,1.15,0,1.73-.07A19.82,19.82,0,0,0,177,237.56L235.18,45.65a1.42,1.42,0,0,0,.07-.22A20,20,0,0,0,230.14,25.86ZM156.91,221.07l-34.37-70.64,46-45.95a12,12,0,0,0-17-17l-46,46L34.93,99.09,210,46Z`}))],[`duotone`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M223.69,42.18l-58.22,192a8,8,0,0,1-14.92,1.25L108,148,20.58,105.45a8,8,0,0,1,1.25-14.92l192-58.22A8,8,0,0,1,223.69,42.18Z`,opacity:`0.2`}),j.createElement(`path`,{d:`M227.32,28.68a16,16,0,0,0-15.66-4.08l-.15,0L19.57,82.84a16,16,0,0,0-2.49,29.8L102,154l41.3,84.87A15.86,15.86,0,0,0,157.74,248q.69,0,1.38-.06a15.88,15.88,0,0,0,14-11.51l58.2-191.94c0-.05,0-.1,0-.15A16,16,0,0,0,227.32,28.68ZM157.83,231.85l-.05.14,0-.07-40.06-82.3,48-48a8,8,0,0,0-11.31-11.31l-48,48L24.08,98.25l-.07,0,.14,0L216,40Z`}))],[`fill`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M231.4,44.34s0,.1,0,.15l-58.2,191.94a15.88,15.88,0,0,1-14,11.51q-.69.06-1.38.06a15.86,15.86,0,0,1-14.42-9.15L107,164.15a4,4,0,0,1,.77-4.58l57.92-57.92a8,8,0,0,0-11.31-11.31L96.43,148.26a4,4,0,0,1-4.58.77L17.08,112.64a16,16,0,0,1,2.49-29.8l191.94-58.2.15,0A16,16,0,0,1,231.4,44.34Z`}))],[`light`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M225.88,30.12a13.83,13.83,0,0,0-13.7-3.58l-.11,0L20.14,84.77A14,14,0,0,0,18,110.85l85.56,41.64L145.12,238a13.87,13.87,0,0,0,12.61,8c.4,0,.81,0,1.21-.05a13.9,13.9,0,0,0,12.29-10.09l58.2-191.93,0-.11A13.83,13.83,0,0,0,225.88,30.12Zm-8,10.4L159.73,232.43l0,.11a2,2,0,0,1-3.76.26l-40.68-83.58,49-49a6,6,0,1,0-8.49-8.49l-49,49L23.15,100a2,2,0,0,1,.31-3.74l.11,0L215.48,38.08a1.94,1.94,0,0,1,1.92.52A2,2,0,0,1,217.92,40.52Z`}))],[`regular`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M227.32,28.68a16,16,0,0,0-15.66-4.08l-.15,0L19.57,82.84a16,16,0,0,0-2.49,29.8L102,154l41.3,84.87A15.86,15.86,0,0,0,157.74,248q.69,0,1.38-.06a15.88,15.88,0,0,0,14-11.51l58.2-191.94c0-.05,0-.1,0-.15A16,16,0,0,0,227.32,28.68ZM157.83,231.85l-.05.14,0-.07-40.06-82.3,48-48a8,8,0,0,0-11.31-11.31l-48,48L24.08,98.25l-.07,0,.14,0L216,40Z`}))],[`thin`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M224.47,31.52a11.87,11.87,0,0,0-11.82-3L20.74,86.67a12,12,0,0,0-1.91,22.38L105,151l41.92,86.15A11.88,11.88,0,0,0,157.74,244c.34,0,.69,0,1,0a11.89,11.89,0,0,0,10.52-8.63l58.21-192,0-.08A11.85,11.85,0,0,0,224.47,31.52Zm-4.62,9.54-58.23,192a4,4,0,0,1-7.48.59l-41.3-84.86,50-50a4,4,0,1,0-5.66-5.66l-50,50-84.9-41.31a3.88,3.88,0,0,1-2.27-4,3.93,3.93,0,0,1,3-3.54L214.9,36.16A3.93,3.93,0,0,1,216,36a4,4,0,0,1,2.79,1.19A3.93,3.93,0,0,1,219.85,41.06Z`}))]]),I=new Map([[`bold`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M200,36H56A20,20,0,0,0,36,56V200a20,20,0,0,0,20,20H200a20,20,0,0,0,20-20V56A20,20,0,0,0,200,36Zm-4,160H60V60H196Z`}))],[`duotone`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M208,56V200a8,8,0,0,1-8,8H56a8,8,0,0,1-8-8V56a8,8,0,0,1,8-8H200A8,8,0,0,1,208,56Z`,opacity:`0.2`}),j.createElement(`path`,{d:`M200,40H56A16,16,0,0,0,40,56V200a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V56A16,16,0,0,0,200,40Zm0,160H56V56H200V200Z`}))],[`fill`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M216,56V200a16,16,0,0,1-16,16H56a16,16,0,0,1-16-16V56A16,16,0,0,1,56,40H200A16,16,0,0,1,216,56Z`}))],[`light`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M200,42H56A14,14,0,0,0,42,56V200a14,14,0,0,0,14,14H200a14,14,0,0,0,14-14V56A14,14,0,0,0,200,42Zm2,158a2,2,0,0,1-2,2H56a2,2,0,0,1-2-2V56a2,2,0,0,1,2-2H200a2,2,0,0,1,2,2Z`}))],[`regular`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M200,40H56A16,16,0,0,0,40,56V200a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V56A16,16,0,0,0,200,40Zm0,160H56V56H200V200Z`}))],[`thin`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M200,44H56A12,12,0,0,0,44,56V200a12,12,0,0,0,12,12H200a12,12,0,0,0,12-12V56A12,12,0,0,0,200,44Zm4,156a4,4,0,0,1-4,4H56a4,4,0,0,1-4-4V56a4,4,0,0,1,4-4H200a4,4,0,0,1,4,4Z`}))]]),L=j.forwardRef((e,t)=>j.createElement(m,{ref:t,...e,weights:ye}));L.displayName=`BracketsCurlyIcon`;var Ce=L,R=j.forwardRef((e,t)=>j.createElement(m,{ref:t,...e,weights:M}));R.displayName=`ChatCircleDotsIcon`;var z=R,B=j.forwardRef((e,t)=>j.createElement(m,{ref:t,...e,weights:be}));B.displayName=`CircleNotchIcon`;var we=B,Te=j.forwardRef((e,t)=>j.createElement(m,{ref:t,...e,weights:xe}));Te.displayName=`ClockIcon`;var Ee=Te,De=j.forwardRef((e,t)=>j.createElement(m,{ref:t,...e,weights:N}));De.displayName=`CopySimpleIcon`;var V=De,H=j.forwardRef((e,t)=>j.createElement(m,{ref:t,...e,weights:P}));H.displayName=`FileTextIcon`;var U=H,W=j.forwardRef((e,t)=>j.createElement(m,{ref:t,...e,weights:F}));W.displayName=`HeartbeatIcon`;var Oe=W,ke=j.forwardRef((e,t)=>j.createElement(m,{ref:t,...e,weights:Se}));ke.displayName=`PaperPlaneTiltIcon`;var G=ke,K=j.forwardRef((e,t)=>j.createElement(m,{ref:t,...e,weights:I}));K.displayName=`StopIcon`;var Ae=K;function q(){return`${location.protocol}//${location.host}`}function J(e){return e?/^https?:\/\//i.test(e)?e:e.startsWith(`/`)?`${q()}${e}`:`${q()}/${e}`:q()}var Y=n();function je({access:e}){let{t}=p(),[n,r]=(0,j.useState)(``),o=J(e?.openai_base_url||`/v1`),s=(0,j.useMemo)(()=>[{name:t(`endpointOpenAI`),url:o,method:`BASE`,hint:t(`endpointBaseHint`),icon:(0,Y.jsx)(Ce,{size:15})},{name:t(`endpointChat`),url:J(e?.chat_completions||`${o}/chat/completions`),method:`POST`,hint:t(`endpointChatHint`),icon:(0,Y.jsx)(G,{size:15})},{name:t(`endpointMessages`),url:J(e?.messages||`${o}/messages`),method:`POST`,hint:t(`endpointMessagesHint`),icon:(0,Y.jsx)(G,{size:15})},{name:t(`endpointResponses`),url:J(e?.responses||`${o}/responses`),method:`POST`,hint:t(`endpointResponsesHint`),icon:(0,Y.jsx)(G,{size:15})},{name:t(`endpointModels`),url:J(e?.models||`${o}/models`),method:`GET`,hint:t(`endpointModelsHint`),icon:(0,Y.jsx)(i,{size:15})},{name:t(`endpointHealth`),url:J(e?.health||`/health`),method:`GET`,hint:t(`endpointHealthHint`),icon:(0,Y.jsx)(Oe,{size:15})}],[e,o,t]);return(0,Y.jsxs)(`section`,{className:`overflow-hidden rounded-3xl bg-surface shadow-surface`,children:[(0,Y.jsx)(`div`,{className:`flex items-start justify-between gap-4 px-5 py-4 sm:px-6`,children:(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`h3`,{className:`font-semibold`,children:t(`endpoints`)}),(0,Y.jsx)(ae,{size:`sm`,variant:`soft`,children:t(`endpointCount`,{count:s.length-1})})]}),(0,Y.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:t(`routesHint`)})]})}),(0,Y.jsx)(`div`,{className:`grid gap-2 px-3 pb-3 sm:grid-cols-2 sm:px-4 sm:pb-4 lg:grid-cols-3`,children:s.map(e=>(0,Y.jsxs)(`div`,{className:`group min-w-0 rounded-xl bg-surface-secondary/40 p-3 transition-colors hover:bg-surface-secondary/70`,children:[(0,Y.jsxs)(`div`,{className:`flex items-start justify-between gap-2.5`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,Y.jsx)(`span`,{className:`grid size-7 shrink-0 place-items-center rounded-lg bg-surface text-muted`,children:e.icon}),(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`div`,{className:`truncate text-body font-semibold`,children:e.name}),(0,Y.jsx)(`code`,{className:`mono mt-0.5 block truncate text-caption text-muted`,children:e.url})]})]}),(0,Y.jsx)(ae,{size:`sm`,variant:`soft`,children:e.method})]}),(0,Y.jsx)(`p`,{className:`mt-2 text-caption leading-5 text-muted`,children:e.hint}),(0,Y.jsxs)(`div`,{className:`mt-2 flex items-center justify-between gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-caption font-medium text-muted`,children:e.method===`BASE`?t(`endpointBaseLabel`):t(`endpointAuthLabel`)}),(0,Y.jsxs)(`div`,{className:`flex gap-1`,children:[(0,Y.jsx)(h,{isIconOnly:!0,size:`sm`,variant:`ghost`,"aria-label":t(`copy`),onPress:()=>{d(e.url),r(e.name),window.setTimeout(()=>r(``),1100)},children:(0,Y.jsx)(a,{copied:n===e.name})}),(0,Y.jsx)(h,{isIconOnly:!0,size:`sm`,variant:`ghost`,"aria-label":t(`open`),onPress:()=>window.open(e.url,`_blank`,`noopener,noreferrer`),children:(0,Y.jsx)(c,{size:14})})]})]})]},e.name))})]})}var Me=new Set(`txt.md.markdown.json.csv.tsv.yml.yaml.toml.xml.html.htm.css.scss.js.jsx.ts.tsx.mjs.cjs.py.go.rs.java.kt.swift.c.h.cpp.hpp.sh.bash.zsh.sql.graphql.env.ini.conf.log.rst.tex`.split(`.`)),Ne=new Set([`image/png`,`image/jpeg`,`image/jpg`,`image/gif`,`image/webp`]);function X(e){let t=e.lastIndexOf(`.`);return t>=0?e.slice(t+1).toLowerCase():``}function Pe(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}async function Z(e){let t=X(e.name),n=e.type||`application/octet-stream`,r=`${e.name}-${e.size}-${e.lastModified}-${Math.random().toString(36).slice(2,8)}`;if(Ne.has(n)||[`png`,`jpg`,`jpeg`,`gif`,`webp`].includes(t)){let t=await new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(String(r.result||``)),r.onerror=()=>n(r.error||Error(`read failed`)),r.readAsDataURL(e)});return{id:r,name:e.name,mime:n,kind:`image`,dataUrl:t,size:e.size}}if(Me.has(t)||n.startsWith(`text/`)||n===`application/json`){let t=await e.text();return{id:r,name:e.name,mime:n,kind:`text`,text:t,size:e.size}}return null}function Q({ariaLabel:e,value:t,onChange:n,placeholder:r,isDisabled:i,options:a,className:o,tone:s=`default`}){let c=a.find(e=>e.id===t),l=s===`muted`?`text-muted hover:text-foreground`:`text-foreground`;return(0,Y.jsxs)(S,{className:o??`w-auto max-w-[11rem] min-w-0`,"aria-label":e,value:t||null,placeholder:r,isDisabled:i,onChange:e=>{typeof e==`string`&&e&&n(e)},children:[(0,Y.jsxs)(S.Trigger,{className:`h-8 min-h-8 gap-1 rounded-[10px] border-0 bg-transparent px-2.5 shadow-none items-center hover:bg-surface-secondary/80 data-[focus-visible=true]:bg-surface-secondary/80 ${l}`,children:[(0,Y.jsx)(S.Value,{className:`min-w-0 truncate text-caption font-medium`,children:({defaultChildren:e,isPlaceholder:t})=>t||!c?e:(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1`,children:[c.icon?(0,Y.jsx)(`span`,{className:`grid size-3.5 shrink-0 place-items-center opacity-80`,children:c.icon}):null,(0,Y.jsx)(`span`,{className:`truncate`,children:c.label})]})}),(0,Y.jsx)(S.Indicator,{className:`size-2.5 opacity-50`})]}),(0,Y.jsx)(S.Popover,{placement:`top end`,className:`max-h-72 min-w-48`,children:(0,Y.jsx)(_,{children:a.map(e=>(0,Y.jsxs)(_.Item,{id:e.id,textValue:e.textValue,className:`gap-2`,children:[e.icon?(0,Y.jsx)(`span`,{className:`grid size-5 shrink-0 place-items-center`,children:e.icon}):null,(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(g,{className:`block truncate text-caption`,children:e.label}),e.hint?(0,Y.jsx)(`span`,{className:`block truncate text-caption text-muted`,children:e.hint}):null]}),(0,Y.jsx)(_.ItemIndicator,{})]},e.id))})})]})}function Fe({value:e,onChange:t,attachments:n,onAttachmentsChange:r,disabled:i,streaming:a,canSend:o,onSend:c,onStop:l,accountValue:u,onAccountChange:d,accountOptions:m,modelValue:g,onModelChange:_,modelOptions:v,modelsLoading:y}){let{t:b}=p(),x=(0,j.useRef)(null);async function S(e){if(!e?.length)return;let t=[],i=[];for(let n of Array.from(e))try{let e=await Z(n);e?t.push(e):i.push(n.name)}catch{i.push(n.name)}t.length&&r([...n,...t]),i.length&&de({type:`error`,title:b(`chatAttachUnsupported`,{names:i.join(`, `)})}),x.current&&(x.current.value=``)}function ee(e){e.key!==`Enter`||e.shiftKey||e.nativeEvent.isComposing||(e.preventDefault(),!a&&o&&c())}return(0,Y.jsxs)(`div`,{className:`access-composer px-3 pb-3 pt-2.5 sm:px-4 sm:pb-3.5 sm:pt-3`,children:[(0,Y.jsxs)(`div`,{className:`access-composer-well overflow-hidden rounded-2xl`,children:[n.length?(0,Y.jsx)(`div`,{className:`flex flex-wrap gap-2 px-3 pt-3`,children:n.map(e=>(0,Y.jsxs)(`span`,{className:`inline-flex max-w-[14rem] items-center gap-2 rounded-xl bg-surface/80 px-1.5 py-1.5 text-caption text-foreground`,children:[e.kind===`image`&&e.dataUrl?(0,Y.jsx)(`img`,{src:e.dataUrl,alt:``,className:`size-8 shrink-0 rounded-lg object-cover`}):(0,Y.jsx)(`span`,{className:`grid size-8 shrink-0 place-items-center rounded-lg bg-surface-secondary text-muted`,children:(0,Y.jsx)(U,{size:14})}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`span`,{className:`block truncate font-medium`,children:e.name}),(0,Y.jsx)(`span`,{className:`mono text-muted`,children:Pe(e.size)})]}),(0,Y.jsx)(`button`,{type:`button`,className:`grid size-6 shrink-0 place-items-center rounded-md text-muted hover:bg-surface-secondary hover:text-foreground`,"aria-label":b(`chatAttachRemove`),onClick:()=>r(n.filter(t=>t.id!==e.id)),children:(0,Y.jsx)(ie,{size:12})})]},e.id))}):null,(0,Y.jsx)(s,{fullWidth:!0,rows:3,className:`min-h-20 resize-none border-0 bg-transparent px-3.5 py-3 text-body leading-[1.65] shadow-none focus-visible:ring-0`,value:e,onChange:e=>t(e.target.value),onKeyDown:ee,placeholder:b(`promptPlaceholder`),"aria-label":b(`prompt`),disabled:i||a}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-0.5 px-2 pb-2 pt-0.5`,children:[(0,Y.jsx)(`input`,{ref:x,type:`file`,className:`hidden`,multiple:!0,accept:`.txt,.md,.json,.csv,.yml,.yaml,.toml,.xml,.html,.css,.js,.jsx,.ts,.tsx,.py,.go,.rs,.sh,.sql,.png,.jpg,.jpeg,.gif,.webp,text/*,image/png,image/jpeg,image/gif,image/webp,application/json`,onChange:e=>void S(e.target.files)}),(0,Y.jsx)(h,{isIconOnly:!0,size:`sm`,variant:`ghost`,className:`size-8 min-w-8 shrink-0 rounded-[10px]`,"aria-label":b(`chatAttach`),isDisabled:i||a,onPress:()=>x.current?.click(),children:(0,Y.jsx)(f,{size:15})}),(0,Y.jsx)(`div`,{className:`min-w-0 flex-1`}),(0,Y.jsx)(Q,{ariaLabel:b(`account`),value:u,onChange:d,options:m,isDisabled:i||a,tone:`muted`,className:`w-auto max-w-[8.5rem] min-w-0`}),(0,Y.jsx)(Q,{ariaLabel:b(`model`),value:g,onChange:_,placeholder:b(y?`requesting`:`model`),options:v,isDisabled:i||a||y||!v.length,className:`w-auto max-w-[10.5rem] min-w-0`}),(0,Y.jsxs)(`div`,{className:`relative size-8 shrink-0`,children:[(0,Y.jsx)(h,{isIconOnly:!0,size:`sm`,variant:`secondary`,className:`absolute inset-0 size-8 rounded-[10px] transition-opacity duration-200 ease-[cubic-bezier(0.2,0.7,0.2,1)] ${a?`opacity-100`:`pointer-events-none opacity-0`}`,"aria-label":b(`chatTryStop`),onPress:l,children:(0,Y.jsx)(Ae,{size:14,weight:`fill`})}),(0,Y.jsx)(h,{isIconOnly:!0,size:`sm`,className:`absolute inset-0 size-8 rounded-[10px] transition-opacity duration-200 ease-[cubic-bezier(0.2,0.7,0.2,1)] ${a?`pointer-events-none opacity-0`:`opacity-100`}`,"aria-label":b(`chatTrySend`),isDisabled:!o||i||a,onPress:c,children:(0,Y.jsx)(G,{size:14,weight:`fill`})})]})]})]}),(0,Y.jsx)(`p`,{className:`mt-1 px-1 text-caption leading-4 text-muted/65`,children:b(`chatTryHelper`)})]})}function Ie({collapsed:e,onCollapsedChange:t,items:n,activeId:i,onSelect:a,onNew:o}){let{t:s}=p(),c=(0,j.useRef)(null);return(0,j.useEffect)(()=>{let t=c.current;!t||O()||e||w.fromTo(t,{autoAlpha:0},{autoAlpha:1,duration:D.fast,ease:`power2.out`})},[e]),e?(0,Y.jsxs)(`div`,{className:`access-hist-rail flex w-9 shrink-0 flex-col items-center gap-1 border-r py-2`,children:[(0,Y.jsx)(h,{isIconOnly:!0,size:`sm`,variant:`ghost`,className:`size-8 min-w-8 rounded-[10px] text-muted`,"aria-label":s(`chatHistoryExpand`),onPress:()=>t(!1),children:(0,Y.jsx)(T,{size:15})}),(0,Y.jsx)(h,{isIconOnly:!0,size:`sm`,variant:`ghost`,className:`size-8 min-w-8 rounded-[10px] text-muted`,"aria-label":s(`chatHistoryNew`),onPress:o,children:(0,Y.jsx)(f,{size:14})})]}):(0,Y.jsxs)(`aside`,{ref:c,className:`access-hist-rail flex w-[13rem] shrink-0 flex-col border-r`,"aria-label":s(`chatHistoryTitle`),children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 px-2 py-2`,children:[(0,Y.jsx)(`div`,{className:`min-w-0 flex-1 truncate px-1.5 text-caption font-medium text-muted`,children:s(`chatHistoryTitle`)}),(0,Y.jsx)(h,{isIconOnly:!0,size:`sm`,variant:`ghost`,className:`size-8 min-w-8 rounded-[10px] text-muted`,"aria-label":s(`chatHistoryCollapse`),onPress:()=>t(!0),children:(0,Y.jsx)(r,{size:14})})]}),(0,Y.jsx)(`div`,{className:`px-2 pb-1.5`,children:(0,Y.jsxs)(h,{size:`sm`,variant:`ghost`,className:`h-8 w-full justify-start gap-1.5 rounded-[10px] px-2.5 text-caption font-medium text-muted hover:bg-[var(--sidebar-hover)] hover:text-foreground`,onPress:o,children:[(0,Y.jsx)(f,{size:13}),s(`chatHistoryNew`)]})}),(0,Y.jsx)(`div`,{className:`min-h-0 flex-1 space-y-0.5 overflow-y-auto px-1.5 pb-2.5`,children:n.length?n.map(e=>{let t=e.id===i;return(0,Y.jsx)(`button`,{type:`button`,"data-active":t?`true`:void 0,className:`access-hist-item flex h-8 w-full items-center rounded-[10px] px-2.5 text-left text-caption leading-5 ${t?`font-medium text-foreground`:`font-normal text-muted`}`,onClick:()=>a(e.id),children:(0,Y.jsx)(`span`,{className:`line-clamp-1 tracking-tight`,children:e.title||s(`chatHistoryUntitled`)})},e.id)}):(0,Y.jsx)(`p`,{className:`px-2.5 py-6 text-center text-caption leading-5 text-muted/70`,children:s(`chatHistoryEmpty`)})})]})}function Le({text:e,streaming:t,defaultOpen:n}){let{t:r}=p(),[i,a]=(0,j.useState)(!!n),[o,s]=(0,j.useState)(0),c=(0,j.useRef)(0),l=(0,j.useRef)(null),d=(0,j.useRef)(null);if((0,j.useEffect)(()=>{t?a(!1):n!=null&&a(!!n)},[t,n]),(0,j.useEffect)(()=>{if(!t)return;let e=Date.now();s(0);let n=window.setInterval(()=>{let t=Math.floor((Date.now()-e)/1e3);s(t),c.current=t},250);return()=>window.clearInterval(n)},[t]),(0,j.useEffect)(()=>{!t&&o===0&&c.current>0&&s(c.current)},[t,o]),(0,j.useEffect)(()=>{let t=l.current,n=d.current;if(!t)return;let r=O();if(!i||!e){if(r){t.style.height=`0px`,t.style.opacity=`0`;return}w.to(t,{height:0,opacity:0,duration:D.fast,ease:k.inOut,overwrite:!0});return}let a=n?.scrollHeight??0;if(r){t.style.height=`auto`,t.style.opacity=`1`;return}w.fromTo(t,{height:0,opacity:0},{height:a,opacity:1,duration:D.base,ease:k.out,overwrite:!0,onComplete:()=>{t.style.height=`auto`}})},[i,e]),!e&&!t)return null;let f=O(),m=t?o:o||c.current;return(0,Y.jsxs)(`div`,{className:`overflow-hidden rounded-xl`,children:[(0,Y.jsx)(`button`,{type:`button`,className:`inline-flex max-w-full items-center gap-1.5 rounded-full bg-surface-secondary px-2.5 py-1 text-left text-caption text-muted`,"aria-expanded":i,onClick:()=>a(e=>!e),children:t?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(we,{size:12,className:`shrink-0 text-muted ${f?``:`animate-spin`}`}),(0,Y.jsx)(`span`,{className:f?``:`access-thinking-shimmer`,children:r(`thinkingWorking`)}),(0,Y.jsxs)(`span`,{className:`mono text-muted/80`,children:[o,`s`]})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(u,{size:11,className:`shrink-0 transition-transform duration-200 ease-out ${i?`rotate-90`:``}`}),(0,Y.jsx)(`span`,{children:r(`thinkingDone`)}),m>0?(0,Y.jsx)(`span`,{className:`mono text-muted/80`,children:r(`thinkingElapsed`,{n:m})}):null,!m&&e?(0,Y.jsx)(`span`,{className:`mono text-muted/80`,children:r(`thinkingChars`,{count:e.length})}):null]})}),(0,Y.jsx)(`div`,{ref:l,className:`overflow-hidden`,style:{height:0,opacity:0},children:e?(0,Y.jsx)(`pre`,{ref:d,className:`mt-1.5 max-h-52 overflow-auto whitespace-pre-wrap break-words rounded-xl bg-surface-secondary/80 px-3 py-2 text-caption leading-5 text-muted`,children:e}):null})]})}function Re(e,t){return t(e===`running`?`toolCallRunning`:e===`error`?`toolCallError`:`toolCallSuccess`)}function ze({status:e}){return e===`running`?(0,Y.jsx)(ue,{size:12,className:`animate-spin text-muted`}):e===`error`?(0,Y.jsx)(se,{size:12,weight:`fill`,className:`text-danger`}):(0,Y.jsx)(ce,{size:12,weight:`fill`,className:`text-success`})}function Be(e){if(!e.trim())return``;try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function Ve({call:e,forceOpen:t}){let{t:n}=p(),[r,i]=(0,j.useState)(e.status===`error`||!!t),[a,o]=(0,j.useState)(!1),s=(0,j.useMemo)(()=>Be(e.arguments||``),[e.arguments]);(0,j.useEffect)(()=>{e.status===`error`&&i(!0)},[e.status]),(0,j.useEffect)(()=>{t&&i(!0)},[t]);async function c(){s&&(await d(s),o(!0),window.setTimeout(()=>o(!1),1200))}return(0,Y.jsxs)(`div`,{className:`overflow-hidden rounded-lg`,children:[(0,Y.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 px-2 py-1.5 text-left`,"aria-expanded":r,onClick:()=>i(e=>!e),children:[(0,Y.jsx)(u,{size:11,className:`shrink-0 text-muted transition-transform ${r?`rotate-90`:``}`}),(0,Y.jsx)(`span`,{className:`mono min-w-0 flex-1 truncate text-caption font-medium text-foreground`,children:e.name||n(`toolCallUntitled`)}),(0,Y.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 text-caption text-muted`,children:[(0,Y.jsx)(ze,{status:e.status}),Re(e.status,n)]})]}),r?(0,Y.jsxs)(`div`,{className:`space-y-1.5 px-2 pb-2`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Y.jsx)(`div`,{className:`text-caption font-medium text-muted`,children:n(`toolCallArgs`)}),(0,Y.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-caption text-muted hover:bg-surface-secondary hover:text-foreground`,onClick:e=>{e.stopPropagation(),c()},children:[(0,Y.jsx)(V,{size:12}),n(a?`copied`:`copy`)]})]}),(0,Y.jsx)(`pre`,{className:`mono max-h-40 overflow-auto whitespace-pre-wrap break-words rounded-lg bg-surface-secondary/80 px-2.5 py-2 text-caption leading-5 text-muted`,children:s||n(`toolCallArgsEmpty`)})]}):null]})}function He({calls:e}){let{t}=p(),n=e.some(e=>e.status===`error`),r=e.some(e=>e.status===`running`),[i,a]=(0,j.useState)(n||r||e.length===1);return(0,j.useEffect)(()=>{(n||r)&&a(!0)},[n,r]),e.length?e.length===1?(0,Y.jsx)(`div`,{className:`rounded-xl bg-surface-secondary/70`,children:(0,Y.jsx)(Ve,{call:e[0],forceOpen:e[0].status===`error`})}):(0,Y.jsxs)(`div`,{className:`overflow-hidden rounded-xl bg-surface-secondary/70`,children:[(0,Y.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 px-2.5 py-1.5 text-left text-caption text-muted`,"aria-expanded":i,onClick:()=>a(e=>!e),children:[(0,Y.jsx)(u,{size:11,className:`shrink-0 transition-transform ${i?`rotate-90`:``}`}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium text-foreground`,children:t(`toolCallGroup`,{n:e.length})}),r?(0,Y.jsx)(ue,{size:12,className:`animate-spin`}):null]}),i?(0,Y.jsx)(`div`,{className:`space-y-0.5 border-t border-separator/40 px-0.5 py-1`,children:e.map(e=>(0,Y.jsx)(Ve,{call:e},`${e.index}-${e.id||e.name}`))}):null]}):null}function Ue({message:e}){return e.attachments?.length?(0,Y.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:e.attachments.map(e=>(0,Y.jsxs)(`span`,{className:`inline-flex max-w-[12rem] items-center gap-1.5 rounded-xl bg-surface/70 px-1.5 py-1 text-caption text-muted`,children:[e.kind===`image`&&e.dataUrl?(0,Y.jsx)(`img`,{src:e.dataUrl,alt:``,className:`size-7 shrink-0 rounded-lg object-cover`}):(0,Y.jsx)(`span`,{className:`grid size-7 shrink-0 place-items-center rounded-lg bg-surface`,children:(0,Y.jsx)(U,{size:12})}),(0,Y.jsx)(`span`,{className:`truncate`,children:e.name})]},e.id))}):null}function We({message:e}){let{t}=p(),n=e.usage;if(!n||n.credits==null)return null;let r=n.prompt_tokens,i=n.completion_tokens,a=typeof r==`number`||typeof i==`number`?t(`chatTryUsageTokens`,{prompt:he(r??0),completion:he(i??0)}):``;return(0,Y.jsx)(`span`,{className:`mono text-caption text-muted`,children:a?t(`chatTryUsageFoot`,{tokens:a,amount:A(n.credits)}):t(`chatTryCreditsUsed`,{amount:A(n.credits)})})}function Ge({text:e,streaming:t}){let n=e.split(/(\n{2,})/),r=-1;for(let e=n.length-1;e>=0;--e)if(n[e]&&!/^\n{2,}$/.test(n[e])){r=e;break}return(0,Y.jsx)(`div`,{className:`whitespace-pre-wrap break-words text-body leading-[1.65] text-foreground ${t?`access-streaming`:``}`,children:n.map((e,n)=>e?/^\n{2,}$/.test(e)?(0,Y.jsx)(`span`,{children:e},`s-${n}`):(0,Y.jsx)(`span`,{className:t&&n===r?`access-stream-seg`:void 0,children:e},`p-${n}`):null)})}function Ke(){let e=(0,j.useRef)(null);return(0,j.useEffect)(()=>{let t=e.current;!t||O()||w.from(t,{autoAlpha:0,duration:D.fast,ease:`power2.out`})},[]),e}function qe({message:e}){let{t}=p(),[n,r]=(0,j.useState)(!1),i=e.role===`user`,o=Ke();if(i)return(0,Y.jsx)(`div`,{ref:o,className:`ml-auto max-w-[92%] sm:max-w-[78%]`,children:(0,Y.jsxs)(`div`,{className:`access-bubble access-bubble--user rounded-2xl rounded-br-md px-3.5 py-2.5`,children:[e.content?(0,Y.jsx)(`div`,{className:`whitespace-pre-wrap break-words text-body leading-[1.65] text-foreground`,children:e.content}):null,(0,Y.jsx)(Ue,{message:e})]})});let s=e.status===`streaming`&&!e.content&&!e.reasoning&&!e.toolCalls?.length,c=!!e.content&&e.status===`done`,l=e.status===`streaming`,u=!!(e.usage&&e.usage.credits!=null),f=e.status===`done`&&(e.latency_ms!=null||e.ttfb_ms!=null||typeof e.usage?.completion_tokens==`number`);async function m(){e.content&&(await d(e.content),r(!0),window.setTimeout(()=>r(!1),1200))}return(0,Y.jsxs)(`div`,{className:`group/access-msg max-w-[96%] space-y-1.5 sm:max-w-[88%]`,children:[(0,Y.jsx)(`div`,{className:`flex items-center gap-1.5 px-0.5`,children:(0,Y.jsx)(`span`,{className:`grid size-5 shrink-0 place-items-center rounded-lg border border-border bg-surface-secondary`,children:(0,Y.jsx)(ge,{provider:e.provider,size:13})})}),e.reasoning||l?(0,Y.jsx)(Le,{text:e.reasoning||``,streaming:l&&(!e.content||!!e.reasoning),defaultOpen:e.reasoningOpen}):null,e.toolCalls?.length?(0,Y.jsx)(He,{calls:e.toolCalls}):null,e.status===`error`?(0,Y.jsx)(v,{status:`danger`,title:t(`requestFailed`),description:e.error||``}):s?(0,Y.jsxs)(`div`,{className:`space-y-2 pt-0.5`,children:[(0,Y.jsx)(E,{className:`h-3 w-28 rounded-md`}),(0,Y.jsx)(E,{className:`h-3 w-full rounded-md`}),(0,Y.jsx)(E,{className:`h-3 w-[86%] rounded-md`}),(0,Y.jsx)(E,{className:`h-3 w-[68%] rounded-md`})]}):e.content?(0,Y.jsx)(`div`,{className:`access-bubble access-bubble--assistant px-0.5 py-0`,children:(0,Y.jsx)(Ge,{text:e.content,streaming:l})}):null,c||u||f?(0,Y.jsxs)(`div`,{className:`access-msg-foot space-y-1 px-0.5 pt-0.5`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[c?(0,Y.jsxs)(h,{size:`sm`,variant:`ghost`,className:`h-5 min-h-5 gap-1 px-1.5 text-caption text-muted/80`,onPress:()=>void m(),children:[(0,Y.jsx)(a,{copied:n,size:12}),t(n?`copied`:`copy`)]}):null,(0,Y.jsx)(We,{message:e})]}),f?(0,Y.jsx)(ve,{variant:`inline`,latencyMs:e.latency_ms,ttfbMs:e.ttfb_ms,completionTokens:e.usage?.completion_tokens,stream:!0,className:`access-latency-inline max-h-0 overflow-hidden opacity-0 transition-[opacity,max-height] duration-200 ease-[cubic-bezier(0.2,0.7,0.2,1)] group-hover/access-msg:max-h-5 group-hover/access-msg:opacity-100 focus-within:max-h-5 focus-within:opacity-100`,labels:{ttft:t(`logsColTTFT`),total:t(`logsLatencyTotal`),tps:t(`logsOutputTPS`)}}):null]}):null]})}function Je({messages:e,busy:t,onLoadDemo:n}){let{t:r}=p(),i=(0,j.useRef)(null);(0,j.useEffect)(()=>{i.current?.scrollIntoView({block:`end`})},[e,t]);let a=!e.length;return(0,Y.jsxs)(`div`,{className:`access-thread min-h-0 flex-1 overflow-y-auto px-4 sm:px-6 ${a?`py-5 sm:py-6`:`pb-2 pt-4 sm:pb-2.5 sm:pt-5`}`,"aria-live":`polite`,"aria-busy":t,children:[a?(0,Y.jsx)(y,{className:`min-h-56`,icon:(0,Y.jsx)(z,{size:22}),title:r(`chatTryEmptyTitle`),hint:r(`chatTryEmptyHint`),action:n?(0,Y.jsx)(`button`,{type:`button`,className:`inline-flex h-8 items-center rounded-[10px] px-2.5 text-caption font-medium text-muted transition-colors hover:bg-[var(--sidebar-hover)] hover:text-foreground`,onClick:n,children:r(`chatDemoLoad`)}):void 0}):(0,Y.jsx)(`div`,{className:`space-y-4`,children:e.map(e=>(0,Y.jsx)(qe,{message:e},e.id))}),(0,Y.jsx)(`div`,{ref:i})]})}function Ye({format:e,onFormatChange:t,requestPath:n,prompt:r,onPromptChange:i,onTest:o,requestState:c,elapsedMs:l,output:u,responseStatus:d,curl:f,copiedCurl:m,onCopyCurl:g,canSend:_,accountValue:b,onAccountChange:x,accountOptions:S,modelValue:ee,onModelChange:te,modelOptions:ne,modelsLoading:re,disabled:C}){let{t:w}=p();return(0,Y.jsxs)(`div`,{className:`space-y-4`,children:[(0,Y.jsx)(`p`,{className:`px-1 text-caption leading-5 text-muted`,children:w(`rawFormatHint`)}),(0,Y.jsx)(`div`,{className:`access-raw-panel overflow-hidden rounded-2xl`,children:(0,Y.jsxs)(`div`,{className:`grid xl:grid-cols-[minmax(420px,.92fr)_minmax(0,1.08fr)]`,children:[(0,Y.jsxs)(`div`,{className:`xl:border-r xl:border-[color-mix(in_oklab,var(--foreground)_6%,transparent)]`,children:[(0,Y.jsxs)(`div`,{className:`px-4 py-3.5 sm:px-5`,children:[(0,Y.jsx)(`h3`,{className:`text-body font-semibold`,children:w(`requestBuilder`)}),(0,Y.jsxs)(`p`,{className:`mt-0.5 text-caption text-muted`,children:[`POST `,n]})]}),(0,Y.jsxs)(`div`,{className:`space-y-4 px-4 pb-4 sm:px-5 sm:pb-5`,children:[(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[(0,Y.jsx)(`div`,{className:`text-caption font-medium text-muted`,children:w(`rawFormatLabel`)}),(0,Y.jsx)(fe,{className:`access-format-chips`,ariaLabel:w(`rawFormatLabel`),value:e,onChange:e=>t(e),options:[{id:`chat`,label:w(`rawFormatChat`)},{id:`messages`,label:w(`rawFormatMessages`)},{id:`responses`,label:w(`rawFormatResponses`)}]})]}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(0,Y.jsx)(Q,{ariaLabel:w(`account`),value:b,onChange:x,options:S,isDisabled:C||c===`loading`,tone:`muted`,className:`w-auto max-w-[8.5rem] min-w-0`}),(0,Y.jsx)(Q,{ariaLabel:w(`model`),value:ee,onChange:te,placeholder:w(re?`requesting`:`model`),options:ne,isDisabled:C||c===`loading`||re||!ne.length,className:`w-auto max-w-[10.5rem] min-w-0`})]}),(0,Y.jsxs)(`div`,{className:`space-y-2.5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Y.jsx)(`div`,{className:`text-caption font-medium text-muted`,children:w(`prompt`)}),(0,Y.jsx)(`span`,{className:`mono text-caption text-muted`,children:r.length})]}),(0,Y.jsx)(s,{fullWidth:!0,rows:9,className:`min-h-52 resize-y rounded-xl border-0 bg-[var(--field-background)] px-3.5 py-3 text-body leading-[1.65] shadow-[inset_0_0_0_1px_color-mix(in_oklab,var(--field-border)_78%,var(--foreground))] focus-visible:ring-0`,value:r,onChange:e=>i(e.target.value),placeholder:w(`promptPlaceholder`),"aria-label":w(`prompt`),disabled:C||c===`loading`}),(0,Y.jsx)(`p`,{className:`text-caption leading-5 text-muted/70`,children:w(`promptHelper`)})]}),(0,Y.jsxs)(h,{fullWidth:!0,isPending:c===`loading`,isDisabled:!_||C,onPress:o,children:[(0,Y.jsx)(G,{size:15}),w(c===`loading`?`requesting`:`sendRequest`)]})]})]}),(0,Y.jsxs)(`div`,{className:`access-raw-panel__inspector flex min-h-[440px] min-w-0 flex-col`,"aria-live":`polite`,"aria-busy":c===`loading`,children:[(0,Y.jsxs)(`div`,{className:`flex min-h-12 items-center justify-between gap-4 px-4 py-3 sm:px-5`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h3`,{className:`text-body font-semibold`,children:w(`responseInspector`)}),(0,Y.jsx)(`p`,{className:`mt-0.5 text-caption text-muted`,children:w(`responseInspectorHint`)})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[l===null?null:(0,Y.jsxs)(`span`,{className:`mono flex items-center gap-1.5 text-caption text-muted`,children:[(0,Y.jsx)(Ee,{size:12}),l,` ms`]}),(0,Y.jsx)(ae,{size:`sm`,variant:`soft`,color:c===`success`?`success`:c===`error`?`danger`:void 0,children:d})]})]}),(0,Y.jsx)(`div`,{className:`min-h-0 flex-1 px-4 pb-4 sm:px-5 sm:pb-5`,children:c===`idle`?(0,Y.jsx)(y,{className:`min-h-64`,title:w(`responseEmptyTitle`),hint:w(`responseEmptyHint`)}):c===`loading`?(0,Y.jsxs)(`div`,{className:`space-y-3 pt-1`,children:[(0,Y.jsx)(E,{className:`h-3 w-32 rounded-lg`}),(0,Y.jsx)(E,{className:`h-3 w-full rounded-lg`}),(0,Y.jsx)(E,{className:`h-3 w-[88%] rounded-lg`}),(0,Y.jsx)(E,{className:`h-3 w-[72%] rounded-lg`}),(0,Y.jsx)(E,{className:`mt-7 h-3 w-[92%] rounded-lg`}),(0,Y.jsx)(E,{className:`h-3 w-[64%] rounded-lg`})]}):c===`error`?(0,Y.jsx)(`div`,{className:`space-y-3`,children:(0,Y.jsx)(v,{status:`danger`,title:w(`requestFailed`),description:u})}):(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 text-caption font-medium text-success`,children:[(0,Y.jsx)(ce,{size:14,weight:`fill`}),w(`responseReceived`)]}),(0,Y.jsx)(`pre`,{className:`mono overflow-x-auto whitespace-pre-wrap break-words text-caption leading-6 text-muted`,children:u})]})})]})]})}),(0,Y.jsxs)(`section`,{className:`access-raw-panel overflow-hidden rounded-2xl`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-4 px-4 py-3 sm:px-5`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`div`,{className:`text-body font-semibold`,children:w(`curlExample`)}),(0,Y.jsx)(`div`,{className:`mt-0.5 truncate text-caption text-muted`,children:w(`curlGeneratedHint`)})]}),(0,Y.jsxs)(h,{size:`sm`,variant:`ghost`,onPress:g,children:[(0,Y.jsx)(a,{copied:m}),w(m?`copied`:`copy`)]})]}),(0,Y.jsx)(`pre`,{className:`mono max-h-72 overflow-auto whitespace-pre-wrap px-4 pb-4 text-caption leading-6 text-muted sm:px-5 sm:pb-5`,children:f})]})]})}function Xe(e,t){let n=t.filter(e=>e.kind===`text`),r=t.filter(e=>e.kind===`image`&&e.dataUrl),i=e.trim();for(let e of n){let t=e.text??``;i=`${i}${i?` +import{a as e,c as t,n}from"./shim-mfK0Rmj6.js";import{a as r,i,n as a,o,r as s,s as c,t as l}from"./CaiaiSoftLink-6tjwsEDV.js";import{t as u}from"./CaretRight.es-DGKxUxz5.js";import{t as d}from"./clipboard-BWzpPXn-.js";import{t as f}from"./Plus.es-CSLpU0CT.js";import{dt as p,n as m,r as h}from"./useI18n-BBOAnu2u.js";import{t as g}from"./label-BVCjtfNQ.js";import{t as _}from"./list-box-1t_n3N3P.js";import{t as v}from"./PageAlert-DZC7IhXp.js";import{t as y}from"./EmptyPanel-Bs-jQMvG.js";import{n as b,t as x}from"./tabs-CQ7Gr_Df.js";import{t as S}from"./select-BYBzHj05.js";import{d as ee,f as te,i as C,o as w}from"./format-kRpr2wxA.js";import{E as T,T as E,p as ne,t as re,u as ie}from"./overview-CJvUvgoD.js";import{r as D}from"./gsap-C3sDxib7.js";import{At as ae,M as oe,Nt as se,O as ce,Pt as le,Ut as ue,i as de,j as O,kt as fe,t as pe,v as k,x as A,y as me}from"./index-B9eWF6SH.js";import{t as he}from"./FilterToggle-AieL1mQy.js";import{t as ge}from"./ProviderMark-IiAZTaQS.js";import{n as _e}from"./provider-gHnttGKq.js";import{t as ve}from"./LatencyStats-lecg2Ory.js";var j=t(e(),1),ye=new Map([[`bold`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M54.8,119.49A35.06,35.06,0,0,1,49.05,128a35.06,35.06,0,0,1,5.75,8.51C60,147.24,60,159.83,60,172c0,25.94,1.84,32,20,32a12,12,0,0,1,0,24c-19.14,0-32.2-6.9-38.8-20.51C36,196.76,36,184.17,36,172c0-25.94-1.84-32-20-32a12,12,0,0,1,0-24c18.16,0,20-6.06,20-32,0-12.17,0-24.76,5.2-35.49C47.8,34.9,60.86,28,80,28a12,12,0,0,1,0,24c-18.16,0-20,6.06-20,32C60,96.17,60,108.76,54.8,119.49ZM240,116c-18.16,0-20-6.06-20-32,0-12.17,0-24.76-5.2-35.49C208.2,34.9,195.14,28,176,28a12,12,0,0,0,0,24c18.16,0,20,6.06,20,32,0,12.17,0,24.76,5.2,35.49A35.06,35.06,0,0,0,207,128a35.06,35.06,0,0,0-5.75,8.51C196,147.24,196,159.83,196,172c0,25.94-1.84,32-20,32a12,12,0,0,0,0,24c19.14,0,32.2-6.9,38.8-20.51C220,196.76,220,184.17,220,172c0-25.94,1.84-32,20-32a12,12,0,0,0,0-24Z`}))],[`duotone`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M240,128c-64,0,0,88-64,88H80c-64,0,0-88-64-88,64,0,0-88,64-88h96C240,40,176,128,240,128Z`,opacity:`0.2`}),j.createElement(`path`,{d:`M43.18,128a29.78,29.78,0,0,1,8,10.26c4.8,9.9,4.8,22,4.8,33.74,0,24.31,1,36,24,36a8,8,0,0,1,0,16c-17.48,0-29.32-6.14-35.2-18.26-4.8-9.9-4.8-22-4.8-33.74,0-24.31-1-36-24-36a8,8,0,0,1,0-16c23,0,24-11.69,24-36,0-11.72,0-23.84,4.8-33.74C50.68,38.14,62.52,32,80,32a8,8,0,0,1,0,16C57,48,56,59.69,56,84c0,11.72,0,23.84-4.8,33.74A29.78,29.78,0,0,1,43.18,128ZM240,120c-23,0-24-11.69-24-36,0-11.72,0-23.84-4.8-33.74C205.32,38.14,193.48,32,176,32a8,8,0,0,0,0,16c23,0,24,11.69,24,36,0,11.72,0,23.84,4.8,33.74a29.78,29.78,0,0,0,8,10.26,29.78,29.78,0,0,0-8,10.26c-4.8,9.9-4.8,22-4.8,33.74,0,24.31-1,36-24,36a8,8,0,0,0,0,16c17.48,0,29.32-6.14,35.2-18.26,4.8-9.9,4.8-22,4.8-33.74,0-24.31,1-36,24-36a8,8,0,0,0,0-16Z`}))],[`fill`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M216,40H40A16,16,0,0,0,24,56V200a16,16,0,0,0,16,16H216a16,16,0,0,0,16-16V56A16,16,0,0,0,216,40ZM88,155.84c.29,14.26.41,20.16,16,20.16a8,8,0,0,1,0,16c-31.27,0-31.72-22.43-32-35.84C71.71,141.9,71.59,136,56,136a8,8,0,0,1,0-16c15.59,0,15.71-5.9,16-20.16C72.28,86.43,72.73,64,104,64a8,8,0,0,1,0,16c-15.59,0-15.71,5.9-16,20.16-.17,8.31-.41,20.09-8,27.84C87.59,135.75,87.83,147.53,88,155.84ZM200,136c-15.59,0-15.71,5.9-16,20.16-.28,13.41-.73,35.84-32,35.84a8,8,0,0,1,0-16c15.59,0,15.71-5.9,16-20.16.17-8.31.41-20.09,8-27.84-7.6-7.75-7.84-19.53-8-27.84C167.71,85.9,167.59,80,152,80a8,8,0,0,1,0-16c31.27,0,31.72,22.43,32,35.84.29,14.26.41,20.16,16,20.16a8,8,0,0,1,0,16Z`}))],[`light`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M39.91,128a27.68,27.68,0,0,1,9.49,11.13C54,148.62,54,160.51,54,172c0,24.27,1.21,38,26,38a6,6,0,0,1,0,12c-16.88,0-27.81-5.6-33.4-17.13C42,195.38,42,183.49,42,172c0-24.27-1.21-38-26-38a6,6,0,0,1,0-12c24.79,0,26-13.73,26-38,0-11.49,0-23.38,4.6-32.87C52.19,39.6,63.12,34,80,34a6,6,0,0,1,0,12C55.21,46,54,59.73,54,84c0,11.49,0,23.38-4.6,32.87A27.68,27.68,0,0,1,39.91,128ZM240,122c-24.79,0-26-13.73-26-38,0-11.49,0-23.38-4.6-32.87C203.81,39.6,192.88,34,176,34a6,6,0,0,0,0,12c24.79,0,26,13.73,26,38,0,11.49,0,23.38,4.6,32.87A27.68,27.68,0,0,0,216.09,128a27.68,27.68,0,0,0-9.49,11.13C202,148.62,202,160.51,202,172c0,24.27-1.21,38-26,38a6,6,0,0,0,0,12c16.88,0,27.81-5.6,33.4-17.13,4.6-9.49,4.6-21.38,4.6-32.87,0-24.27,1.21-38,26-38a6,6,0,0,0,0-12Z`}))],[`regular`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M43.18,128a29.78,29.78,0,0,1,8,10.26c4.8,9.9,4.8,22,4.8,33.74,0,24.31,1,36,24,36a8,8,0,0,1,0,16c-17.48,0-29.32-6.14-35.2-18.26-4.8-9.9-4.8-22-4.8-33.74,0-24.31-1-36-24-36a8,8,0,0,1,0-16c23,0,24-11.69,24-36,0-11.72,0-23.84,4.8-33.74C50.68,38.14,62.52,32,80,32a8,8,0,0,1,0,16C57,48,56,59.69,56,84c0,11.72,0,23.84-4.8,33.74A29.78,29.78,0,0,1,43.18,128ZM240,120c-23,0-24-11.69-24-36,0-11.72,0-23.84-4.8-33.74C205.32,38.14,193.48,32,176,32a8,8,0,0,0,0,16c23,0,24,11.69,24,36,0,11.72,0,23.84,4.8,33.74a29.78,29.78,0,0,0,8,10.26,29.78,29.78,0,0,0-8,10.26c-4.8,9.9-4.8,22-4.8,33.74,0,24.31-1,36-24,36a8,8,0,0,0,0,16c17.48,0,29.32-6.14,35.2-18.26,4.8-9.9,4.8-22,4.8-33.74,0-24.31,1-36,24-36a8,8,0,0,0,0-16Z`}))],[`thin`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M35.89,128C52,136.23,52,155.64,52,172c0,24.8,1.35,40,28,40a4,4,0,0,1,0,8c-36,0-36-26.61-36-48,0-24.8-1.35-40-28-40a4,4,0,0,1,0-8c26.65,0,28-15.2,28-40,0-21.39,0-48,36-48a4,4,0,0,1,0,8C53.35,44,52,59.2,52,84,52,100.36,52,119.77,35.89,128ZM240,124c-26.65,0-28-15.2-28-40,0-21.39,0-48-36-48a4,4,0,0,0,0,8c26.65,0,28,15.2,28,40,0,16.36,0,35.77,16.11,44C204,136.23,204,155.64,204,172c0,24.8-1.35,40-28,40a4,4,0,0,0,0,8c36,0,36-26.61,36-48,0-24.8,1.35-40,28-40a4,4,0,0,0,0-8Z`}))]]),M=new Map([[`bold`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M120,128a16,16,0,1,1-16-16A16,16,0,0,1,120,128Zm32-16a16,16,0,1,0,16,16A16,16,0,0,0,152,112Zm84,16A108,108,0,0,1,78.77,224.15L46.34,235A20,20,0,0,1,21,209.66l10.81-32.43A108,108,0,1,1,236,128Zm-24,0A84,84,0,1,0,55.27,170.06a12,12,0,0,1,1,9.81l-9.93,29.79,29.79-9.93a12.1,12.1,0,0,1,3.8-.62,12,12,0,0,1,6,1.62A84,84,0,0,0,212,128Z`}))],[`duotone`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M224,128A96,96,0,0,1,79.93,211.11h0L42.54,223.58a8,8,0,0,1-10.12-10.12l12.47-37.39h0A96,96,0,1,1,224,128Z`,opacity:`0.2`}),j.createElement(`path`,{d:`M128,24A104,104,0,0,0,36.18,176.88L24.83,210.93a16,16,0,0,0,20.24,20.24l34.05-11.35A104,104,0,1,0,128,24Zm0,192a87.87,87.87,0,0,1-44.06-11.81,8,8,0,0,0-4-1.08,7.85,7.85,0,0,0-2.53.42L40,216,52.47,178.6a8,8,0,0,0-.66-6.54A88,88,0,1,1,128,216Zm12-88a12,12,0,1,1-12-12A12,12,0,0,1,140,128Zm-44,0a12,12,0,1,1-12-12A12,12,0,0,1,96,128Zm88,0a12,12,0,1,1-12-12A12,12,0,0,1,184,128Z`}))],[`fill`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M128,24A104,104,0,0,0,36.18,176.88L24.83,210.93a16,16,0,0,0,20.24,20.24l34.05-11.35A104,104,0,1,0,128,24ZM84,140a12,12,0,1,1,12-12A12,12,0,0,1,84,140Zm44,0a12,12,0,1,1,12-12A12,12,0,0,1,128,140Zm44,0a12,12,0,1,1,12-12A12,12,0,0,1,172,140Z`}))],[`light`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M138,128a10,10,0,1,1-10-10A10,10,0,0,1,138,128ZM84,118a10,10,0,1,0,10,10A10,10,0,0,0,84,118Zm88,0a10,10,0,1,0,10,10A10,10,0,0,0,172,118Zm58,10A102,102,0,0,1,79.31,217.65L44.44,229.27a14,14,0,0,1-17.71-17.71l11.62-34.87A102,102,0,1,1,230,128Zm-12,0A90,90,0,1,0,50.08,173.06a6,6,0,0,1,.5,4.91L38.12,215.35a2,2,0,0,0,2.53,2.53L78,205.42a6.2,6.2,0,0,1,1.9-.31,6.09,6.09,0,0,1,3,.81A90,90,0,0,0,218,128Z`}))],[`regular`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M140,128a12,12,0,1,1-12-12A12,12,0,0,1,140,128ZM84,116a12,12,0,1,0,12,12A12,12,0,0,0,84,116Zm88,0a12,12,0,1,0,12,12A12,12,0,0,0,172,116Zm60,12A104,104,0,0,1,79.12,219.82L45.07,231.17a16,16,0,0,1-20.24-20.24l11.35-34.05A104,104,0,1,1,232,128Zm-16,0A88,88,0,1,0,51.81,172.06a8,8,0,0,1,.66,6.54L40,216,77.4,203.53a7.85,7.85,0,0,1,2.53-.42,8,8,0,0,1,4,1.08A88,88,0,0,0,216,128Z`}))],[`thin`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M136,128a8,8,0,1,1-8-8A8,8,0,0,1,136,128Zm-52-8a8,8,0,1,0,8,8A8,8,0,0,0,84,120Zm88,0a8,8,0,1,0,8,8A8,8,0,0,0,172,120Zm56,8A100,100,0,0,1,79.5,215.47l-35.69,11.9a12,12,0,0,1-15.18-15.18l11.9-35.69A100,100,0,1,1,228,128Zm-8,0A92,92,0,1,0,48.35,174.07a4,4,0,0,1,.33,3.27L36.22,214.72a4,4,0,0,0,5.06,5.06l37.38-12.46a3.93,3.93,0,0,1,1.27-.21,4.05,4.05,0,0,1,2,.54A92,92,0,0,0,220,128Z`}))]]),be=new Map([[`bold`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M236,128a108,108,0,0,1-216,0c0-42.52,24.73-81.34,63-98.9A12,12,0,1,1,93,50.91C63.24,64.57,44,94.83,44,128a84,84,0,0,0,168,0c0-33.17-19.24-63.43-49-77.09A12,12,0,1,1,173,29.1C211.27,46.66,236,85.48,236,128Z`}))],[`duotone`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M224,128a96,96,0,1,1-96-96A96,96,0,0,1,224,128Z`,opacity:`0.2`}),j.createElement(`path`,{d:`M232,128a104,104,0,0,1-208,0c0-41,23.81-78.36,60.66-95.27a8,8,0,0,1,6.68,14.54C60.15,61.59,40,93.27,40,128a88,88,0,0,0,176,0c0-34.73-20.15-66.41-51.34-80.73a8,8,0,0,1,6.68-14.54C208.19,49.64,232,87,232,128Z`}))],[`fill`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,176A72,72,0,0,1,92,65.64a8,8,0,0,1,8,13.85,56,56,0,1,0,56,0,8,8,0,0,1,8-13.85A72,72,0,0,1,128,200Z`}))],[`light`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M230,128a102,102,0,0,1-204,0c0-40.18,23.35-76.86,59.5-93.45a6,6,0,0,1,5,10.9C58.61,60.09,38,92.49,38,128a90,90,0,0,0,180,0c0-35.51-20.61-67.91-52.5-82.55a6,6,0,0,1,5-10.9C206.65,51.14,230,87.82,230,128Z`}))],[`regular`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M232,128a104,104,0,0,1-208,0c0-41,23.81-78.36,60.66-95.27a8,8,0,0,1,6.68,14.54C60.15,61.59,40,93.27,40,128a88,88,0,0,0,176,0c0-34.73-20.15-66.41-51.34-80.73a8,8,0,0,1,6.68-14.54C208.19,49.64,232,87,232,128Z`}))],[`thin`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M228,128a100,100,0,0,1-200,0c0-39.4,22.9-75.37,58.33-91.63a4,4,0,1,1,3.34,7.27C57.07,58.6,36,91.71,36,128a92,92,0,0,0,184,0c0-36.29-21.07-69.4-53.67-84.36a4,4,0,1,1,3.34-7.27C205.1,52.63,228,88.6,228,128Z`}))]]),xe=new Map([[`bold`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M128,20A108,108,0,1,0,236,128,108.12,108.12,0,0,0,128,20Zm0,192a84,84,0,1,1,84-84A84.09,84.09,0,0,1,128,212Zm68-84a12,12,0,0,1-12,12H128a12,12,0,0,1-12-12V72a12,12,0,0,1,24,0v44h44A12,12,0,0,1,196,128Z`}))],[`duotone`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M224,128a96,96,0,1,1-96-96A96,96,0,0,1,224,128Z`,opacity:`0.2`}),j.createElement(`path`,{d:`M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Zm64-88a8,8,0,0,1-8,8H128a8,8,0,0,1-8-8V72a8,8,0,0,1,16,0v48h48A8,8,0,0,1,192,128Z`}))],[`fill`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm56,112H128a8,8,0,0,1-8-8V72a8,8,0,0,1,16,0v48h48a8,8,0,0,1,0,16Z`}))],[`light`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M128,26A102,102,0,1,0,230,128,102.12,102.12,0,0,0,128,26Zm0,192a90,90,0,1,1,90-90A90.1,90.1,0,0,1,128,218Zm62-90a6,6,0,0,1-6,6H128a6,6,0,0,1-6-6V72a6,6,0,0,1,12,0v50h50A6,6,0,0,1,190,128Z`}))],[`regular`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Zm64-88a8,8,0,0,1-8,8H128a8,8,0,0,1-8-8V72a8,8,0,0,1,16,0v48h48A8,8,0,0,1,192,128Z`}))],[`thin`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M128,28A100,100,0,1,0,228,128,100.11,100.11,0,0,0,128,28Zm0,192a92,92,0,1,1,92-92A92.1,92.1,0,0,1,128,220Zm60-92a4,4,0,0,1-4,4H128a4,4,0,0,1-4-4V72a4,4,0,0,1,8,0v52h52A4,4,0,0,1,188,128Z`}))]]),N=new Map([[`bold`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M180,64H40A12,12,0,0,0,28,76V216a12,12,0,0,0,12,12H180a12,12,0,0,0,12-12V76A12,12,0,0,0,180,64ZM168,204H52V88H168ZM228,40V180a12,12,0,0,1-24,0V52H76a12,12,0,0,1,0-24H216A12,12,0,0,1,228,40Z`}))],[`duotone`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M184,72V216H40V72Z`,opacity:`0.2`}),j.createElement(`path`,{d:`M184,64H40a8,8,0,0,0-8,8V216a8,8,0,0,0,8,8H184a8,8,0,0,0,8-8V72A8,8,0,0,0,184,64Zm-8,144H48V80H176ZM224,40V184a8,8,0,0,1-16,0V48H72a8,8,0,0,1,0-16H216A8,8,0,0,1,224,40Z`}))],[`fill`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M192,72V216a8,8,0,0,1-8,8H40a8,8,0,0,1-8-8V72a8,8,0,0,1,8-8H184A8,8,0,0,1,192,72Zm24-40H72a8,8,0,0,0,0,16H208V184a8,8,0,0,0,16,0V40A8,8,0,0,0,216,32Z`}))],[`light`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M184,66H40a6,6,0,0,0-6,6V216a6,6,0,0,0,6,6H184a6,6,0,0,0,6-6V72A6,6,0,0,0,184,66Zm-6,144H46V78H178ZM222,40V184a6,6,0,0,1-12,0V46H72a6,6,0,0,1,0-12H216A6,6,0,0,1,222,40Z`}))],[`regular`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M184,64H40a8,8,0,0,0-8,8V216a8,8,0,0,0,8,8H184a8,8,0,0,0,8-8V72A8,8,0,0,0,184,64Zm-8,144H48V80H176ZM224,40V184a8,8,0,0,1-16,0V48H72a8,8,0,0,1,0-16H216A8,8,0,0,1,224,40Z`}))],[`thin`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M184,68H40a4,4,0,0,0-4,4V216a4,4,0,0,0,4,4H184a4,4,0,0,0,4-4V72A4,4,0,0,0,184,68Zm-4,144H44V76H180ZM220,40V184a4,4,0,0,1-8,0V44H72a4,4,0,0,1,0-8H216A4,4,0,0,1,220,40Z`}))]]),P=new Map([[`bold`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M216.49,79.52l-56-56A12,12,0,0,0,152,20H56A20,20,0,0,0,36,40V216a20,20,0,0,0,20,20H200a20,20,0,0,0,20-20V88A12,12,0,0,0,216.49,79.52ZM160,57l23,23H160ZM60,212V44h76V92a12,12,0,0,0,12,12h48V212Zm112-80a12,12,0,0,1-12,12H96a12,12,0,0,1,0-24h64A12,12,0,0,1,172,132Zm0,40a12,12,0,0,1-12,12H96a12,12,0,0,1,0-24h64A12,12,0,0,1,172,172Z`}))],[`duotone`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M208,88H152V32Z`,opacity:`0.2`}),j.createElement(`path`,{d:`M213.66,82.34l-56-56A8,8,0,0,0,152,24H56A16,16,0,0,0,40,40V216a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V88A8,8,0,0,0,213.66,82.34ZM160,51.31,188.69,80H160ZM200,216H56V40h88V88a8,8,0,0,0,8,8h48V216Zm-32-80a8,8,0,0,1-8,8H96a8,8,0,0,1,0-16h64A8,8,0,0,1,168,136Zm0,32a8,8,0,0,1-8,8H96a8,8,0,0,1,0-16h64A8,8,0,0,1,168,168Z`}))],[`fill`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M213.66,82.34l-56-56A8,8,0,0,0,152,24H56A16,16,0,0,0,40,40V216a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V88A8,8,0,0,0,213.66,82.34ZM160,176H96a8,8,0,0,1,0-16h64a8,8,0,0,1,0,16Zm0-32H96a8,8,0,0,1,0-16h64a8,8,0,0,1,0,16Zm-8-56V44l44,44Z`}))],[`light`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M212.24,83.76l-56-56A6,6,0,0,0,152,26H56A14,14,0,0,0,42,40V216a14,14,0,0,0,14,14H200a14,14,0,0,0,14-14V88A6,6,0,0,0,212.24,83.76ZM158,46.48,193.52,82H158ZM200,218H56a2,2,0,0,1-2-2V40a2,2,0,0,1,2-2h90V88a6,6,0,0,0,6,6h50V216A2,2,0,0,1,200,218Zm-34-82a6,6,0,0,1-6,6H96a6,6,0,0,1,0-12h64A6,6,0,0,1,166,136Zm0,32a6,6,0,0,1-6,6H96a6,6,0,0,1,0-12h64A6,6,0,0,1,166,168Z`}))],[`regular`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M213.66,82.34l-56-56A8,8,0,0,0,152,24H56A16,16,0,0,0,40,40V216a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V88A8,8,0,0,0,213.66,82.34ZM160,51.31,188.69,80H160ZM200,216H56V40h88V88a8,8,0,0,0,8,8h48V216Zm-32-80a8,8,0,0,1-8,8H96a8,8,0,0,1,0-16h64A8,8,0,0,1,168,136Zm0,32a8,8,0,0,1-8,8H96a8,8,0,0,1,0-16h64A8,8,0,0,1,168,168Z`}))],[`thin`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M210.83,85.17l-56-56A4,4,0,0,0,152,28H56A12,12,0,0,0,44,40V216a12,12,0,0,0,12,12H200a12,12,0,0,0,12-12V88A4,4,0,0,0,210.83,85.17ZM156,41.65,198.34,84H156ZM200,220H56a4,4,0,0,1-4-4V40a4,4,0,0,1,4-4h92V88a4,4,0,0,0,4,4h52V216A4,4,0,0,1,200,220Zm-36-84a4,4,0,0,1-4,4H96a4,4,0,0,1,0-8h64A4,4,0,0,1,164,136Zm0,32a4,4,0,0,1-4,4H96a4,4,0,0,1,0-8h64A4,4,0,0,1,164,168Z`}))]]),F=new Map([[`bold`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M71.76,148H31.7a12,12,0,1,1,0-24H65.33l12.45-18.66a12,12,0,0,1,20,0l22,33,6-9a12,12,0,0,1,10-5.34h24a12,12,0,1,1,0,24h-17.6l-12.46,18.66a12,12,0,0,1-20,0l-22-33-6,9A12,12,0,0,1,71.76,148ZM177.91,36c-20.12,0-38,7.93-50.07,21.56C115.74,43.93,97.89,36,77.76,36A66,66,0,0,0,12.07,94.68,12,12,0,0,0,36,97.32,42,42,0,0,1,77.76,60c17.83,0,32.75,9.4,38.95,24.54a12,12,0,0,0,22.25,0C145.16,69.4,160.08,60,177.91,60A42.08,42.08,0,0,1,220,102c0,29.42-25.86,57.77-47.56,76.36a329,329,0,0,1-44.58,31.81c-10.87-6.45-35.37-22-56.51-42.73a12,12,0,1,0-16.84,17.12c30.39,29.81,66.15,49.2,67.66,50a12.06,12.06,0,0,0,11.39,0C138,232.14,244,174.34,244,102A66.12,66.12,0,0,0,177.91,36Z`}))],[`duotone`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M232,102c0,66-104,122-104,122S24,168,24,102A54,54,0,0,1,78,48c22.59,0,41.94,12.31,50,32,8.06-19.69,27.41-32,50-32A54,54,0,0,1,232,102Z`,opacity:`0.2`}),j.createElement(`path`,{d:`M72,144H32a8,8,0,0,1,0-16H67.72l13.62-20.44a8,8,0,0,1,13.32,0l25.34,38,9.34-14A8,8,0,0,1,136,128h24a8,8,0,0,1,0,16H140.28l-13.62,20.44a8,8,0,0,1-13.32,0L88,126.42l-9.34,14A8,8,0,0,1,72,144ZM178,40c-20.65,0-38.73,8.88-50,23.89C116.73,48.88,98.65,40,78,40a62.07,62.07,0,0,0-62,62c0,.75,0,1.5,0,2.25a8,8,0,1,0,16-.5c0-.58,0-1.17,0-1.75A46.06,46.06,0,0,1,78,56c19.45,0,35.78,10.36,42.6,27a8,8,0,0,0,14.8,0c6.82-16.67,23.15-27,42.6-27a46.06,46.06,0,0,1,46,46c0,53.61-77.76,102.15-96,112.8-10.83-6.31-42.63-26-66.68-52.21a8,8,0,1,0-11.8,10.82c31.17,34,72.93,56.68,74.69,57.63a8,8,0,0,0,7.58,0C136.21,228.66,240,172,240,102A62.07,62.07,0,0,0,178,40Z`}))],[`fill`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M240,102c0,70-103.79,126.66-108.21,129a8,8,0,0,1-7.58,0c-3.35-1.8-63.55-34.69-92.68-80.89A4,4,0,0,1,34.92,144H72a8,8,0,0,0,6.66-3.56l9.34-14,25.34,38a8,8,0,0,0,9.16,3.16,8.23,8.23,0,0,0,4.28-3.34L140.28,144H160a8,8,0,0,0,8-8.53,8.18,8.18,0,0,0-8.25-7.47H136a8,8,0,0,0-6.66,3.56l-9.34,14-25.34-38a8,8,0,0,0-9.17-3.16,8.25,8.25,0,0,0-4.27,3.34L67.72,128H23.53a4,4,0,0,1-3.83-2.81A76.93,76.93,0,0,1,16,102,62.07,62.07,0,0,1,78,40c20.65,0,38.73,8.88,50,23.89C139.27,48.88,157.35,40,178,40A62.07,62.07,0,0,1,240,102Z`}))],[`light`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M72,142H32a6,6,0,0,1,0-12H68.79L83,108.67a6,6,0,0,1,10,0l27,40.51,11-16.51a6,6,0,0,1,5-2.67h24a6,6,0,0,1,0,12H139.21L125,163.33a6,6,0,0,1-10,0L88,122.82,77,139.33A6,6,0,0,1,72,142ZM178,42c-21,0-39.26,9.47-50,25.34C117.26,51.47,99,42,78,42a60.07,60.07,0,0,0-60,60q0,1.09,0,2.19a6,6,0,0,0,12-.38c0-.6,0-1.21,0-1.81A48.05,48.05,0,0,1,78,54c20.28,0,37.31,10.83,44.45,28.27a6,6,0,0,0,11.1,0C140.69,64.83,157.72,54,178,54a48.05,48.05,0,0,1,48,48c0,55.73-81.61,105.65-98,115.11-9.84-5.66-43.09-25.82-68.16-53.16a6,6,0,1,0-8.84,8.1c30.94,33.77,72.41,56.29,74.16,57.23a6,6,0,0,0,5.68,0,334.68,334.68,0,0,0,53.06-37C219.8,161.59,238,131.2,238,102A60.07,60.07,0,0,0,178,42Z`}))],[`regular`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M72,144H32a8,8,0,0,1,0-16H67.72l13.62-20.44a8,8,0,0,1,13.32,0l25.34,38,9.34-14A8,8,0,0,1,136,128h24a8,8,0,0,1,0,16H140.28l-13.62,20.44a8,8,0,0,1-13.32,0L88,126.42l-9.34,14A8,8,0,0,1,72,144ZM178,40c-20.65,0-38.73,8.88-50,23.89C116.73,48.88,98.65,40,78,40a62.07,62.07,0,0,0-62,62c0,.75,0,1.5,0,2.25a8,8,0,1,0,16-.5c0-.58,0-1.17,0-1.75A46.06,46.06,0,0,1,78,56c19.45,0,35.78,10.36,42.6,27a8,8,0,0,0,14.8,0c6.82-16.67,23.15-27,42.6-27a46.06,46.06,0,0,1,46,46c0,53.61-77.76,102.15-96,112.8-10.83-6.31-42.63-26-66.68-52.21a8,8,0,1,0-11.8,10.82c31.17,34,72.93,56.68,74.69,57.63a8,8,0,0,0,7.58,0C136.21,228.66,240,172,240,102A62.07,62.07,0,0,0,178,40Z`}))],[`thin`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M72,140H32a4,4,0,0,1,0-8H69.86l14.81-22.22a4,4,0,0,1,6.66,0l28.67,43,12.67-19A4,4,0,0,1,136,132h24a4,4,0,0,1,0,8H138.14l-14.81,22.22a4,4,0,0,1-6.66,0L88,119.21l-12.67,19A4,4,0,0,1,72,140ZM178,44c-21.44,0-39.92,10.19-50,27.07C117.92,54.19,99.44,44,78,44a58.07,58.07,0,0,0-58,58q0,1.06,0,2.13a4,4,0,1,0,8-.26c0-.62,0-1.24,0-1.87A50.06,50.06,0,0,1,78,52c21.11,0,38.85,11.31,46.3,29.51a4,4,0,0,0,7.4,0C139.15,63.31,156.89,52,178,52a50.06,50.06,0,0,1,50,50c0,58-86,109.46-100,117.42-8.47-4.82-43.5-25.61-69.63-54.12a4,4,0,0,0-5.9,5.4c30.72,33.52,71.9,55.89,73.63,56.82a4,4,0,0,0,3.8,0,333.81,333.81,0,0,0,52.7-36.73C218,160.47,236,130.59,236,102A58.07,58.07,0,0,0,178,44Z`}))]]),Se=new Map([[`bold`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M230.14,25.86a20,20,0,0,0-19.57-5.11l-.22.07L18.44,79a20,20,0,0,0-3.06,37.25L99,157l40.71,83.65a19.81,19.81,0,0,0,18,11.38c.57,0,1.15,0,1.73-.07A19.82,19.82,0,0,0,177,237.56L235.18,45.65a1.42,1.42,0,0,0,.07-.22A20,20,0,0,0,230.14,25.86ZM156.91,221.07l-34.37-70.64,46-45.95a12,12,0,0,0-17-17l-46,46L34.93,99.09,210,46Z`}))],[`duotone`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M223.69,42.18l-58.22,192a8,8,0,0,1-14.92,1.25L108,148,20.58,105.45a8,8,0,0,1,1.25-14.92l192-58.22A8,8,0,0,1,223.69,42.18Z`,opacity:`0.2`}),j.createElement(`path`,{d:`M227.32,28.68a16,16,0,0,0-15.66-4.08l-.15,0L19.57,82.84a16,16,0,0,0-2.49,29.8L102,154l41.3,84.87A15.86,15.86,0,0,0,157.74,248q.69,0,1.38-.06a15.88,15.88,0,0,0,14-11.51l58.2-191.94c0-.05,0-.1,0-.15A16,16,0,0,0,227.32,28.68ZM157.83,231.85l-.05.14,0-.07-40.06-82.3,48-48a8,8,0,0,0-11.31-11.31l-48,48L24.08,98.25l-.07,0,.14,0L216,40Z`}))],[`fill`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M231.4,44.34s0,.1,0,.15l-58.2,191.94a15.88,15.88,0,0,1-14,11.51q-.69.06-1.38.06a15.86,15.86,0,0,1-14.42-9.15L107,164.15a4,4,0,0,1,.77-4.58l57.92-57.92a8,8,0,0,0-11.31-11.31L96.43,148.26a4,4,0,0,1-4.58.77L17.08,112.64a16,16,0,0,1,2.49-29.8l191.94-58.2.15,0A16,16,0,0,1,231.4,44.34Z`}))],[`light`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M225.88,30.12a13.83,13.83,0,0,0-13.7-3.58l-.11,0L20.14,84.77A14,14,0,0,0,18,110.85l85.56,41.64L145.12,238a13.87,13.87,0,0,0,12.61,8c.4,0,.81,0,1.21-.05a13.9,13.9,0,0,0,12.29-10.09l58.2-191.93,0-.11A13.83,13.83,0,0,0,225.88,30.12Zm-8,10.4L159.73,232.43l0,.11a2,2,0,0,1-3.76.26l-40.68-83.58,49-49a6,6,0,1,0-8.49-8.49l-49,49L23.15,100a2,2,0,0,1,.31-3.74l.11,0L215.48,38.08a1.94,1.94,0,0,1,1.92.52A2,2,0,0,1,217.92,40.52Z`}))],[`regular`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M227.32,28.68a16,16,0,0,0-15.66-4.08l-.15,0L19.57,82.84a16,16,0,0,0-2.49,29.8L102,154l41.3,84.87A15.86,15.86,0,0,0,157.74,248q.69,0,1.38-.06a15.88,15.88,0,0,0,14-11.51l58.2-191.94c0-.05,0-.1,0-.15A16,16,0,0,0,227.32,28.68ZM157.83,231.85l-.05.14,0-.07-40.06-82.3,48-48a8,8,0,0,0-11.31-11.31l-48,48L24.08,98.25l-.07,0,.14,0L216,40Z`}))],[`thin`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M224.47,31.52a11.87,11.87,0,0,0-11.82-3L20.74,86.67a12,12,0,0,0-1.91,22.38L105,151l41.92,86.15A11.88,11.88,0,0,0,157.74,244c.34,0,.69,0,1,0a11.89,11.89,0,0,0,10.52-8.63l58.21-192,0-.08A11.85,11.85,0,0,0,224.47,31.52Zm-4.62,9.54-58.23,192a4,4,0,0,1-7.48.59l-41.3-84.86,50-50a4,4,0,1,0-5.66-5.66l-50,50-84.9-41.31a3.88,3.88,0,0,1-2.27-4,3.93,3.93,0,0,1,3-3.54L214.9,36.16A3.93,3.93,0,0,1,216,36a4,4,0,0,1,2.79,1.19A3.93,3.93,0,0,1,219.85,41.06Z`}))]]),I=new Map([[`bold`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M200,36H56A20,20,0,0,0,36,56V200a20,20,0,0,0,20,20H200a20,20,0,0,0,20-20V56A20,20,0,0,0,200,36Zm-4,160H60V60H196Z`}))],[`duotone`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M208,56V200a8,8,0,0,1-8,8H56a8,8,0,0,1-8-8V56a8,8,0,0,1,8-8H200A8,8,0,0,1,208,56Z`,opacity:`0.2`}),j.createElement(`path`,{d:`M200,40H56A16,16,0,0,0,40,56V200a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V56A16,16,0,0,0,200,40Zm0,160H56V56H200V200Z`}))],[`fill`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M216,56V200a16,16,0,0,1-16,16H56a16,16,0,0,1-16-16V56A16,16,0,0,1,56,40H200A16,16,0,0,1,216,56Z`}))],[`light`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M200,42H56A14,14,0,0,0,42,56V200a14,14,0,0,0,14,14H200a14,14,0,0,0,14-14V56A14,14,0,0,0,200,42Zm2,158a2,2,0,0,1-2,2H56a2,2,0,0,1-2-2V56a2,2,0,0,1,2-2H200a2,2,0,0,1,2,2Z`}))],[`regular`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M200,40H56A16,16,0,0,0,40,56V200a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V56A16,16,0,0,0,200,40Zm0,160H56V56H200V200Z`}))],[`thin`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M200,44H56A12,12,0,0,0,44,56V200a12,12,0,0,0,12,12H200a12,12,0,0,0,12-12V56A12,12,0,0,0,200,44Zm4,156a4,4,0,0,1-4,4H56a4,4,0,0,1-4-4V56a4,4,0,0,1,4-4H200a4,4,0,0,1,4,4Z`}))]]),L=j.forwardRef((e,t)=>j.createElement(p,{ref:t,...e,weights:ye}));L.displayName=`BracketsCurlyIcon`;var Ce=L,R=j.forwardRef((e,t)=>j.createElement(p,{ref:t,...e,weights:M}));R.displayName=`ChatCircleDotsIcon`;var z=R,B=j.forwardRef((e,t)=>j.createElement(p,{ref:t,...e,weights:be}));B.displayName=`CircleNotchIcon`;var we=B,Te=j.forwardRef((e,t)=>j.createElement(p,{ref:t,...e,weights:xe}));Te.displayName=`ClockIcon`;var Ee=Te,De=j.forwardRef((e,t)=>j.createElement(p,{ref:t,...e,weights:N}));De.displayName=`CopySimpleIcon`;var V=De,H=j.forwardRef((e,t)=>j.createElement(p,{ref:t,...e,weights:P}));H.displayName=`FileTextIcon`;var U=H,W=j.forwardRef((e,t)=>j.createElement(p,{ref:t,...e,weights:F}));W.displayName=`HeartbeatIcon`;var Oe=W,ke=j.forwardRef((e,t)=>j.createElement(p,{ref:t,...e,weights:Se}));ke.displayName=`PaperPlaneTiltIcon`;var G=ke,K=j.forwardRef((e,t)=>j.createElement(p,{ref:t,...e,weights:I}));K.displayName=`StopIcon`;var Ae=K;function q(){return`${location.protocol}//${location.host}`}function J(e){return e?/^https?:\/\//i.test(e)?e:e.startsWith(`/`)?`${q()}${e}`:`${q()}/${e}`:q()}var Y=n();function je({access:e}){let{t}=m(),[n,r]=(0,j.useState)(``),o=J(e?.openai_base_url||`/v1`),s=(0,j.useMemo)(()=>[{name:t(`endpointOpenAI`),url:o,method:`BASE`,hint:t(`endpointBaseHint`),icon:(0,Y.jsx)(Ce,{size:15})},{name:t(`endpointChat`),url:J(e?.chat_completions||`${o}/chat/completions`),method:`POST`,hint:t(`endpointChatHint`),icon:(0,Y.jsx)(G,{size:15})},{name:t(`endpointMessages`),url:J(e?.messages||`${o}/messages`),method:`POST`,hint:t(`endpointMessagesHint`),icon:(0,Y.jsx)(G,{size:15})},{name:t(`endpointResponses`),url:J(e?.responses||`${o}/responses`),method:`POST`,hint:t(`endpointResponsesHint`),icon:(0,Y.jsx)(G,{size:15})},{name:t(`endpointModels`),url:J(e?.models||`${o}/models`),method:`GET`,hint:t(`endpointModelsHint`),icon:(0,Y.jsx)(i,{size:15})},{name:t(`endpointHealth`),url:J(e?.health||`/health`),method:`GET`,hint:t(`endpointHealthHint`),icon:(0,Y.jsx)(Oe,{size:15})}],[e,o,t]);return(0,Y.jsxs)(`section`,{className:`overflow-hidden rounded-3xl bg-surface shadow-surface`,children:[(0,Y.jsx)(`div`,{className:`flex items-start justify-between gap-4 px-5 py-4 sm:px-6`,children:(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`h3`,{className:`font-semibold`,children:t(`endpoints`)}),(0,Y.jsx)(oe,{size:`sm`,variant:`soft`,children:t(`endpointCount`,{count:s.length-1})})]}),(0,Y.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:t(`routesHint`)})]})}),(0,Y.jsx)(`div`,{className:`grid gap-2 px-3 pb-3 sm:grid-cols-2 sm:px-4 sm:pb-4 lg:grid-cols-3`,children:s.map(e=>(0,Y.jsxs)(`div`,{className:`group min-w-0 rounded-xl bg-surface-secondary/40 p-3 transition-colors hover:bg-surface-secondary/70`,children:[(0,Y.jsxs)(`div`,{className:`flex items-start justify-between gap-2.5`,children:[(0,Y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,Y.jsx)(`span`,{className:`grid size-7 shrink-0 place-items-center rounded-lg bg-surface text-muted`,children:e.icon}),(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`div`,{className:`truncate text-body font-semibold`,children:e.name}),(0,Y.jsx)(`code`,{className:`mono mt-0.5 block truncate text-caption text-muted`,children:e.url})]})]}),(0,Y.jsx)(oe,{size:`sm`,variant:`soft`,children:e.method})]}),(0,Y.jsx)(`p`,{className:`mt-2 text-caption leading-5 text-muted`,children:e.hint}),(0,Y.jsxs)(`div`,{className:`mt-2 flex items-center justify-between gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-caption font-medium text-muted`,children:e.method===`BASE`?t(`endpointBaseLabel`):t(`endpointAuthLabel`)}),(0,Y.jsxs)(`div`,{className:`flex gap-1`,children:[(0,Y.jsx)(h,{isIconOnly:!0,size:`sm`,variant:`ghost`,"aria-label":t(`copy`),onPress:()=>{d(e.url),r(e.name),window.setTimeout(()=>r(``),1100)},children:(0,Y.jsx)(a,{copied:n===e.name})}),(0,Y.jsx)(h,{isIconOnly:!0,size:`sm`,variant:`ghost`,"aria-label":t(`open`),onPress:()=>window.open(e.url,`_blank`,`noopener,noreferrer`),children:(0,Y.jsx)(c,{size:14})})]})]})]},e.name))})]})}var Me=new Set(`txt.md.markdown.json.csv.tsv.yml.yaml.toml.xml.html.htm.css.scss.js.jsx.ts.tsx.mjs.cjs.py.go.rs.java.kt.swift.c.h.cpp.hpp.sh.bash.zsh.sql.graphql.env.ini.conf.log.rst.tex`.split(`.`)),Ne=new Set([`image/png`,`image/jpeg`,`image/jpg`,`image/gif`,`image/webp`]);function X(e){let t=e.lastIndexOf(`.`);return t>=0?e.slice(t+1).toLowerCase():``}function Pe(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}async function Z(e){let t=X(e.name),n=e.type||`application/octet-stream`,r=`${e.name}-${e.size}-${e.lastModified}-${Math.random().toString(36).slice(2,8)}`;if(Ne.has(n)||[`png`,`jpg`,`jpeg`,`gif`,`webp`].includes(t)){let t=await new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(String(r.result||``)),r.onerror=()=>n(r.error||Error(`read failed`)),r.readAsDataURL(e)});return{id:r,name:e.name,mime:n,kind:`image`,dataUrl:t,size:e.size}}if(Me.has(t)||n.startsWith(`text/`)||n===`application/json`){let t=await e.text();return{id:r,name:e.name,mime:n,kind:`text`,text:t,size:e.size}}return null}function Q({ariaLabel:e,value:t,onChange:n,placeholder:r,isDisabled:i,options:a,className:o,tone:s=`default`}){let c=a.find(e=>e.id===t),l=s===`muted`?`text-muted hover:text-foreground`:`text-foreground`;return(0,Y.jsxs)(S,{className:o??`w-auto max-w-[11rem] min-w-0`,"aria-label":e,value:t||null,placeholder:r,isDisabled:i,onChange:e=>{typeof e==`string`&&e&&n(e)},children:[(0,Y.jsxs)(S.Trigger,{className:`h-8 min-h-8 gap-1 rounded-[10px] border-0 bg-transparent px-2.5 shadow-none items-center hover:bg-surface-secondary/80 data-[focus-visible=true]:bg-surface-secondary/80 ${l}`,children:[(0,Y.jsx)(S.Value,{className:`min-w-0 truncate text-caption font-medium`,children:({defaultChildren:e,isPlaceholder:t})=>t||!c?e:(0,Y.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1`,children:[c.icon?(0,Y.jsx)(`span`,{className:`grid size-3.5 shrink-0 place-items-center opacity-80`,children:c.icon}):null,(0,Y.jsx)(`span`,{className:`truncate`,children:c.label})]})}),(0,Y.jsx)(S.Indicator,{className:`size-2.5 opacity-50`})]}),(0,Y.jsx)(S.Popover,{placement:`top end`,className:`max-h-72 min-w-48`,children:(0,Y.jsx)(_,{children:a.map(e=>(0,Y.jsxs)(_.Item,{id:e.id,textValue:e.textValue,className:`gap-2`,children:[e.icon?(0,Y.jsx)(`span`,{className:`grid size-5 shrink-0 place-items-center`,children:e.icon}):null,(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(g,{className:`block truncate text-caption`,children:e.label}),e.hint?(0,Y.jsx)(`span`,{className:`block truncate text-caption text-muted`,children:e.hint}):null]}),(0,Y.jsx)(_.ItemIndicator,{})]},e.id))})})]})}function Fe({value:e,onChange:t,attachments:n,onAttachmentsChange:r,disabled:i,streaming:a,canSend:o,onSend:c,onStop:l,accountValue:u,onAccountChange:d,accountOptions:p,modelValue:g,onModelChange:_,modelOptions:v,modelsLoading:y}){let{t:b}=m(),x=(0,j.useRef)(null);async function S(e){if(!e?.length)return;let t=[],i=[];for(let n of Array.from(e))try{let e=await Z(n);e?t.push(e):i.push(n.name)}catch{i.push(n.name)}t.length&&r([...n,...t]),i.length&&pe({type:`error`,title:b(`chatAttachUnsupported`,{names:i.join(`, `)})}),x.current&&(x.current.value=``)}function ee(e){e.key!==`Enter`||e.shiftKey||e.nativeEvent.isComposing||(e.preventDefault(),!a&&o&&c())}return(0,Y.jsxs)(`div`,{className:`access-composer px-3 pb-3 pt-2.5 sm:px-4 sm:pb-3.5 sm:pt-3`,children:[(0,Y.jsxs)(`div`,{className:`access-composer-well overflow-hidden rounded-2xl`,children:[n.length?(0,Y.jsx)(`div`,{className:`flex flex-wrap gap-2 px-3 pt-3`,children:n.map(e=>(0,Y.jsxs)(`span`,{className:`inline-flex max-w-[14rem] items-center gap-2 rounded-xl bg-surface/80 px-1.5 py-1.5 text-caption text-foreground`,children:[e.kind===`image`&&e.dataUrl?(0,Y.jsx)(`img`,{src:e.dataUrl,alt:``,className:`size-8 shrink-0 rounded-lg object-cover`}):(0,Y.jsx)(`span`,{className:`grid size-8 shrink-0 place-items-center rounded-lg bg-surface-secondary text-muted`,children:(0,Y.jsx)(U,{size:14})}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`span`,{className:`block truncate font-medium`,children:e.name}),(0,Y.jsx)(`span`,{className:`mono text-muted`,children:Pe(e.size)})]}),(0,Y.jsx)(`button`,{type:`button`,className:`grid size-6 shrink-0 place-items-center rounded-md text-muted hover:bg-surface-secondary hover:text-foreground`,"aria-label":b(`chatAttachRemove`),onClick:()=>r(n.filter(t=>t.id!==e.id)),children:(0,Y.jsx)(fe,{size:12})})]},e.id))}):null,(0,Y.jsx)(s,{fullWidth:!0,rows:3,className:`min-h-20 resize-none border-0 bg-transparent px-3.5 py-3 text-body leading-[1.65] shadow-none focus-visible:ring-0`,value:e,onChange:e=>t(e.target.value),onKeyDown:ee,placeholder:b(`promptPlaceholder`),"aria-label":b(`prompt`),disabled:i||a}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-0.5 px-2 pb-2 pt-0.5`,children:[(0,Y.jsx)(`input`,{ref:x,type:`file`,className:`hidden`,multiple:!0,accept:`.txt,.md,.json,.csv,.yml,.yaml,.toml,.xml,.html,.css,.js,.jsx,.ts,.tsx,.py,.go,.rs,.sh,.sql,.png,.jpg,.jpeg,.gif,.webp,text/*,image/png,image/jpeg,image/gif,image/webp,application/json`,onChange:e=>void S(e.target.files)}),(0,Y.jsx)(h,{isIconOnly:!0,size:`sm`,variant:`ghost`,className:`size-8 min-w-8 shrink-0 rounded-[10px]`,"aria-label":b(`chatAttach`),isDisabled:i||a,onPress:()=>x.current?.click(),children:(0,Y.jsx)(f,{size:15})}),(0,Y.jsx)(`div`,{className:`min-w-0 flex-1`}),(0,Y.jsx)(Q,{ariaLabel:b(`account`),value:u,onChange:d,options:p,isDisabled:i||a,tone:`muted`,className:`w-auto max-w-[8.5rem] min-w-0`}),(0,Y.jsx)(Q,{ariaLabel:b(`model`),value:g,onChange:_,placeholder:b(y?`requesting`:`model`),options:v,isDisabled:i||a||y||!v.length,className:`w-auto max-w-[10.5rem] min-w-0`}),(0,Y.jsxs)(`div`,{className:`relative size-8 shrink-0`,children:[(0,Y.jsx)(h,{isIconOnly:!0,size:`sm`,variant:`secondary`,className:`absolute inset-0 size-8 rounded-[10px] transition-opacity duration-200 ease-[cubic-bezier(0.2,0.7,0.2,1)] ${a?`opacity-100`:`pointer-events-none opacity-0`}`,"aria-label":b(`chatTryStop`),onPress:l,children:(0,Y.jsx)(Ae,{size:14,weight:`fill`})}),(0,Y.jsx)(h,{isIconOnly:!0,size:`sm`,className:`absolute inset-0 size-8 rounded-[10px] transition-opacity duration-200 ease-[cubic-bezier(0.2,0.7,0.2,1)] ${a?`pointer-events-none opacity-0`:`opacity-100`}`,"aria-label":b(`chatTrySend`),isDisabled:!o||i||a,onPress:c,children:(0,Y.jsx)(G,{size:14,weight:`fill`})})]})]})]}),(0,Y.jsx)(`p`,{className:`mt-1 px-1 text-caption leading-4 text-muted/65`,children:b(`chatTryHelper`)})]})}function Ie({collapsed:e,onCollapsedChange:t,items:n,activeId:i,onSelect:a,onNew:o}){let{t:s}=m(),c=(0,j.useRef)(null);return(0,j.useEffect)(()=>{let t=c.current;!t||A()||e||D.fromTo(t,{autoAlpha:0},{autoAlpha:1,duration:k.fast,ease:`power2.out`})},[e]),e?(0,Y.jsxs)(`div`,{className:`access-hist-rail flex w-9 shrink-0 flex-col items-center gap-1 border-r py-2`,children:[(0,Y.jsx)(h,{isIconOnly:!0,size:`sm`,variant:`ghost`,className:`size-8 min-w-8 rounded-[10px] text-muted`,"aria-label":s(`chatHistoryExpand`),onPress:()=>t(!1),children:(0,Y.jsx)(le,{size:15})}),(0,Y.jsx)(h,{isIconOnly:!0,size:`sm`,variant:`ghost`,className:`size-8 min-w-8 rounded-[10px] text-muted`,"aria-label":s(`chatHistoryNew`),onPress:o,children:(0,Y.jsx)(f,{size:14})})]}):(0,Y.jsxs)(`aside`,{ref:c,className:`access-hist-rail flex w-[13rem] shrink-0 flex-col border-r`,"aria-label":s(`chatHistoryTitle`),children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1 px-2 py-2`,children:[(0,Y.jsx)(`div`,{className:`min-w-0 flex-1 truncate px-1.5 text-caption font-medium text-muted`,children:s(`chatHistoryTitle`)}),(0,Y.jsx)(h,{isIconOnly:!0,size:`sm`,variant:`ghost`,className:`size-8 min-w-8 rounded-[10px] text-muted`,"aria-label":s(`chatHistoryCollapse`),onPress:()=>t(!0),children:(0,Y.jsx)(r,{size:14})})]}),(0,Y.jsx)(`div`,{className:`px-2 pb-1.5`,children:(0,Y.jsxs)(h,{size:`sm`,variant:`ghost`,className:`h-8 w-full justify-start gap-1.5 rounded-[10px] px-2.5 text-caption font-medium text-muted hover:bg-[var(--sidebar-hover)] hover:text-foreground`,onPress:o,children:[(0,Y.jsx)(f,{size:13}),s(`chatHistoryNew`)]})}),(0,Y.jsx)(`div`,{className:`min-h-0 flex-1 space-y-0.5 overflow-y-auto px-1.5 pb-2.5`,children:n.length?n.map(e=>{let t=e.id===i;return(0,Y.jsx)(`button`,{type:`button`,"data-active":t?`true`:void 0,className:`access-hist-item flex h-8 w-full items-center rounded-[10px] px-2.5 text-left text-caption leading-5 ${t?`font-medium text-foreground`:`font-normal text-muted`}`,onClick:()=>a(e.id),children:(0,Y.jsx)(`span`,{className:`line-clamp-1 tracking-tight`,children:e.title||s(`chatHistoryUntitled`)})},e.id)}):(0,Y.jsx)(`p`,{className:`px-2.5 py-6 text-center text-caption leading-5 text-muted/70`,children:s(`chatHistoryEmpty`)})})]})}function Le({text:e,streaming:t,defaultOpen:n}){let{t:r}=m(),[i,a]=(0,j.useState)(!!n),[o,s]=(0,j.useState)(0),c=(0,j.useRef)(0),l=(0,j.useRef)(null),d=(0,j.useRef)(null);if((0,j.useEffect)(()=>{t?a(!1):n!=null&&a(!!n)},[t,n]),(0,j.useEffect)(()=>{if(!t)return;let e=Date.now();s(0);let n=window.setInterval(()=>{let t=Math.floor((Date.now()-e)/1e3);s(t),c.current=t},250);return()=>window.clearInterval(n)},[t]),(0,j.useEffect)(()=>{!t&&o===0&&c.current>0&&s(c.current)},[t,o]),(0,j.useEffect)(()=>{let t=l.current,n=d.current;if(!t)return;let r=A();if(!i||!e){if(r){t.style.height=`0px`,t.style.opacity=`0`;return}D.to(t,{height:0,opacity:0,duration:k.fast,ease:me.inOut,overwrite:!0});return}let a=n?.scrollHeight??0;if(r){t.style.height=`auto`,t.style.opacity=`1`;return}D.fromTo(t,{height:0,opacity:0},{height:a,opacity:1,duration:k.base,ease:me.out,overwrite:!0,onComplete:()=>{t.style.height=`auto`}})},[i,e]),!e&&!t)return null;let f=A(),p=t?o:o||c.current;return(0,Y.jsxs)(`div`,{className:`overflow-hidden rounded-xl`,children:[(0,Y.jsx)(`button`,{type:`button`,className:`inline-flex max-w-full items-center gap-1.5 rounded-full bg-surface-secondary px-2.5 py-1 text-left text-caption text-muted`,"aria-expanded":i,onClick:()=>a(e=>!e),children:t?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(we,{size:12,className:`shrink-0 text-muted ${f?``:`animate-spin`}`}),(0,Y.jsx)(`span`,{className:f?``:`access-thinking-shimmer`,children:r(`thinkingWorking`)}),(0,Y.jsxs)(`span`,{className:`mono text-muted/80`,children:[o,`s`]})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(u,{size:11,className:`shrink-0 transition-transform duration-200 ease-out ${i?`rotate-90`:``}`}),(0,Y.jsx)(`span`,{children:r(`thinkingDone`)}),p>0?(0,Y.jsx)(`span`,{className:`mono text-muted/80`,children:r(`thinkingElapsed`,{n:p})}):null,!p&&e?(0,Y.jsx)(`span`,{className:`mono text-muted/80`,children:r(`thinkingChars`,{count:e.length})}):null]})}),(0,Y.jsx)(`div`,{ref:l,className:`overflow-hidden`,style:{height:0,opacity:0},children:e?(0,Y.jsx)(`pre`,{ref:d,className:`mt-1.5 max-h-52 overflow-auto whitespace-pre-wrap break-words rounded-xl bg-surface-secondary/80 px-3 py-2 text-caption leading-5 text-muted`,children:e}):null})]})}function Re(e,t){return t(e===`running`?`toolCallRunning`:e===`error`?`toolCallError`:`toolCallSuccess`)}function ze({status:e}){return e===`running`?(0,Y.jsx)(se,{size:12,className:`animate-spin text-muted`}):e===`error`?(0,Y.jsx)(ae,{size:12,weight:`fill`,className:`text-danger`}):(0,Y.jsx)(ue,{size:12,weight:`fill`,className:`text-success`})}function Be(e){if(!e.trim())return``;try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function Ve({call:e,forceOpen:t}){let{t:n}=m(),[r,i]=(0,j.useState)(e.status===`error`||!!t),[a,o]=(0,j.useState)(!1),s=(0,j.useMemo)(()=>Be(e.arguments||``),[e.arguments]);(0,j.useEffect)(()=>{e.status===`error`&&i(!0)},[e.status]),(0,j.useEffect)(()=>{t&&i(!0)},[t]);async function c(){s&&(await d(s),o(!0),window.setTimeout(()=>o(!1),1200))}return(0,Y.jsxs)(`div`,{className:`overflow-hidden rounded-lg`,children:[(0,Y.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 px-2 py-1.5 text-left`,"aria-expanded":r,onClick:()=>i(e=>!e),children:[(0,Y.jsx)(u,{size:11,className:`shrink-0 text-muted transition-transform ${r?`rotate-90`:``}`}),(0,Y.jsx)(`span`,{className:`mono min-w-0 flex-1 truncate text-caption font-medium text-foreground`,children:e.name||n(`toolCallUntitled`)}),(0,Y.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 text-caption text-muted`,children:[(0,Y.jsx)(ze,{status:e.status}),Re(e.status,n)]})]}),r?(0,Y.jsxs)(`div`,{className:`space-y-1.5 px-2 pb-2`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Y.jsx)(`div`,{className:`text-caption font-medium text-muted`,children:n(`toolCallArgs`)}),(0,Y.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 rounded-md px-1.5 py-0.5 text-caption text-muted hover:bg-surface-secondary hover:text-foreground`,onClick:e=>{e.stopPropagation(),c()},children:[(0,Y.jsx)(V,{size:12}),n(a?`copied`:`copy`)]})]}),(0,Y.jsx)(`pre`,{className:`mono max-h-40 overflow-auto whitespace-pre-wrap break-words rounded-lg bg-surface-secondary/80 px-2.5 py-2 text-caption leading-5 text-muted`,children:s||n(`toolCallArgsEmpty`)})]}):null]})}function He({calls:e}){let{t}=m(),n=e.some(e=>e.status===`error`),r=e.some(e=>e.status===`running`),[i,a]=(0,j.useState)(n||r||e.length===1);return(0,j.useEffect)(()=>{(n||r)&&a(!0)},[n,r]),e.length?e.length===1?(0,Y.jsx)(`div`,{className:`rounded-xl bg-surface-secondary/70`,children:(0,Y.jsx)(Ve,{call:e[0],forceOpen:e[0].status===`error`})}):(0,Y.jsxs)(`div`,{className:`overflow-hidden rounded-xl bg-surface-secondary/70`,children:[(0,Y.jsxs)(`button`,{type:`button`,className:`flex w-full items-center gap-2 px-2.5 py-1.5 text-left text-caption text-muted`,"aria-expanded":i,onClick:()=>a(e=>!e),children:[(0,Y.jsx)(u,{size:11,className:`shrink-0 transition-transform ${i?`rotate-90`:``}`}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium text-foreground`,children:t(`toolCallGroup`,{n:e.length})}),r?(0,Y.jsx)(se,{size:12,className:`animate-spin`}):null]}),i?(0,Y.jsx)(`div`,{className:`space-y-0.5 border-t border-separator/40 px-0.5 py-1`,children:e.map(e=>(0,Y.jsx)(Ve,{call:e},`${e.index}-${e.id||e.name}`))}):null]}):null}function Ue({message:e}){return e.attachments?.length?(0,Y.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:e.attachments.map(e=>(0,Y.jsxs)(`span`,{className:`inline-flex max-w-[12rem] items-center gap-1.5 rounded-xl bg-surface/70 px-1.5 py-1 text-caption text-muted`,children:[e.kind===`image`&&e.dataUrl?(0,Y.jsx)(`img`,{src:e.dataUrl,alt:``,className:`size-7 shrink-0 rounded-lg object-cover`}):(0,Y.jsx)(`span`,{className:`grid size-7 shrink-0 place-items-center rounded-lg bg-surface`,children:(0,Y.jsx)(U,{size:12})}),(0,Y.jsx)(`span`,{className:`truncate`,children:e.name})]},e.id))}):null}function We({message:e}){let{t}=m(),n=e.usage;if(!n||n.credits==null)return null;let r=n.prompt_tokens,i=n.completion_tokens,a=typeof r==`number`||typeof i==`number`?t(`chatTryUsageTokens`,{prompt:C(r??0),completion:C(i??0)}):``;return(0,Y.jsx)(`span`,{className:`mono text-caption text-muted`,children:a?t(`chatTryUsageFoot`,{tokens:a,amount:w(n.credits)}):t(`chatTryCreditsUsed`,{amount:w(n.credits)})})}function Ge({text:e,streaming:t}){let n=e.split(/(\n{2,})/),r=-1;for(let e=n.length-1;e>=0;--e)if(n[e]&&!/^\n{2,}$/.test(n[e])){r=e;break}return(0,Y.jsx)(`div`,{className:`whitespace-pre-wrap break-words text-body leading-[1.65] text-foreground ${t?`access-streaming`:``}`,children:n.map((e,n)=>e?/^\n{2,}$/.test(e)?(0,Y.jsx)(`span`,{children:e},`s-${n}`):(0,Y.jsx)(`span`,{className:t&&n===r?`access-stream-seg`:void 0,children:e},`p-${n}`):null)})}function Ke(){let e=(0,j.useRef)(null);return(0,j.useEffect)(()=>{let t=e.current;!t||A()||D.from(t,{autoAlpha:0,duration:k.fast,ease:`power2.out`})},[]),e}function qe({message:e}){let{t}=m(),[n,r]=(0,j.useState)(!1),i=e.role===`user`,o=Ke();if(i)return(0,Y.jsx)(`div`,{ref:o,className:`ml-auto max-w-[92%] sm:max-w-[78%]`,children:(0,Y.jsxs)(`div`,{className:`access-bubble access-bubble--user rounded-2xl rounded-br-md px-3.5 py-2.5`,children:[e.content?(0,Y.jsx)(`div`,{className:`whitespace-pre-wrap break-words text-body leading-[1.65] text-foreground`,children:e.content}):null,(0,Y.jsx)(Ue,{message:e})]})});let s=e.status===`streaming`&&!e.content&&!e.reasoning&&!e.toolCalls?.length,c=!!e.content&&e.status===`done`,l=e.status===`streaming`,u=!!(e.usage&&e.usage.credits!=null),f=e.status===`done`&&(e.latency_ms!=null||e.ttfb_ms!=null||typeof e.usage?.completion_tokens==`number`);async function p(){e.content&&(await d(e.content),r(!0),window.setTimeout(()=>r(!1),1200))}return(0,Y.jsxs)(`div`,{className:`group/access-msg max-w-[96%] space-y-1.5 sm:max-w-[88%]`,children:[(0,Y.jsx)(`div`,{className:`flex items-center gap-1.5 px-0.5`,children:(0,Y.jsx)(`span`,{className:`grid size-5 shrink-0 place-items-center rounded-lg border border-border bg-surface-secondary`,children:(0,Y.jsx)(ge,{provider:e.provider,size:13})})}),e.reasoning||l?(0,Y.jsx)(Le,{text:e.reasoning||``,streaming:l&&(!e.content||!!e.reasoning),defaultOpen:e.reasoningOpen}):null,e.toolCalls?.length?(0,Y.jsx)(He,{calls:e.toolCalls}):null,e.status===`error`?(0,Y.jsx)(v,{status:`danger`,title:t(`requestFailed`),description:e.error||``}):s?(0,Y.jsxs)(`div`,{className:`space-y-2 pt-0.5`,children:[(0,Y.jsx)(O,{className:`h-3 w-28 rounded-md`}),(0,Y.jsx)(O,{className:`h-3 w-full rounded-md`}),(0,Y.jsx)(O,{className:`h-3 w-[86%] rounded-md`}),(0,Y.jsx)(O,{className:`h-3 w-[68%] rounded-md`})]}):e.content?(0,Y.jsx)(`div`,{className:`access-bubble access-bubble--assistant px-0.5 py-0`,children:(0,Y.jsx)(Ge,{text:e.content,streaming:l})}):null,c||u||f?(0,Y.jsxs)(`div`,{className:`access-msg-foot space-y-1 px-0.5 pt-0.5`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[c?(0,Y.jsxs)(h,{size:`sm`,variant:`ghost`,className:`h-5 min-h-5 gap-1 px-1.5 text-caption text-muted/80`,onPress:()=>void p(),children:[(0,Y.jsx)(a,{copied:n,size:12}),t(n?`copied`:`copy`)]}):null,(0,Y.jsx)(We,{message:e})]}),f?(0,Y.jsx)(ve,{variant:`inline`,latencyMs:e.latency_ms,ttfbMs:e.ttfb_ms,completionTokens:e.usage?.completion_tokens,stream:!0,className:`access-latency-inline max-h-0 overflow-hidden opacity-0 transition-[opacity,max-height] duration-200 ease-[cubic-bezier(0.2,0.7,0.2,1)] group-hover/access-msg:max-h-5 group-hover/access-msg:opacity-100 focus-within:max-h-5 focus-within:opacity-100`,labels:{ttft:t(`logsColTTFT`),total:t(`logsLatencyTotal`),tps:t(`logsOutputTPS`)}}):null]}):null]})}function Je({messages:e,busy:t,onLoadDemo:n}){let{t:r}=m(),i=(0,j.useRef)(null);(0,j.useEffect)(()=>{i.current?.scrollIntoView({block:`end`})},[e,t]);let a=!e.length;return(0,Y.jsxs)(`div`,{className:`access-thread min-h-0 flex-1 overflow-y-auto px-4 sm:px-6 ${a?`py-5 sm:py-6`:`pb-2 pt-4 sm:pb-2.5 sm:pt-5`}`,"aria-live":`polite`,"aria-busy":t,children:[a?(0,Y.jsx)(y,{className:`min-h-56`,icon:(0,Y.jsx)(z,{size:22}),title:r(`chatTryEmptyTitle`),hint:r(`chatTryEmptyHint`),action:n?(0,Y.jsx)(`button`,{type:`button`,className:`inline-flex h-8 items-center rounded-[10px] px-2.5 text-caption font-medium text-muted transition-colors hover:bg-[var(--sidebar-hover)] hover:text-foreground`,onClick:n,children:r(`chatDemoLoad`)}):void 0}):(0,Y.jsx)(`div`,{className:`space-y-4`,children:e.map(e=>(0,Y.jsx)(qe,{message:e},e.id))}),(0,Y.jsx)(`div`,{ref:i})]})}function Ye({format:e,onFormatChange:t,requestPath:n,prompt:r,onPromptChange:i,onTest:o,requestState:c,elapsedMs:l,output:u,responseStatus:d,curl:f,copiedCurl:p,onCopyCurl:g,canSend:_,accountValue:b,onAccountChange:x,accountOptions:S,modelValue:ee,onModelChange:te,modelOptions:C,modelsLoading:w,disabled:T}){let{t:E}=m();return(0,Y.jsxs)(`div`,{className:`space-y-4`,children:[(0,Y.jsx)(`p`,{className:`px-1 text-caption leading-5 text-muted`,children:E(`rawFormatHint`)}),(0,Y.jsx)(`div`,{className:`access-raw-panel overflow-hidden rounded-2xl`,children:(0,Y.jsxs)(`div`,{className:`grid xl:grid-cols-[minmax(420px,.92fr)_minmax(0,1.08fr)]`,children:[(0,Y.jsxs)(`div`,{className:`xl:border-r xl:border-[color-mix(in_oklab,var(--foreground)_6%,transparent)]`,children:[(0,Y.jsxs)(`div`,{className:`px-4 py-3.5 sm:px-5`,children:[(0,Y.jsx)(`h3`,{className:`text-body font-semibold`,children:E(`requestBuilder`)}),(0,Y.jsxs)(`p`,{className:`mt-0.5 text-caption text-muted`,children:[`POST `,n]})]}),(0,Y.jsxs)(`div`,{className:`space-y-4 px-4 pb-4 sm:px-5 sm:pb-5`,children:[(0,Y.jsxs)(`div`,{className:`space-y-2`,children:[(0,Y.jsx)(`div`,{className:`text-caption font-medium text-muted`,children:E(`rawFormatLabel`)}),(0,Y.jsx)(he,{className:`access-format-chips`,ariaLabel:E(`rawFormatLabel`),value:e,onChange:e=>t(e),options:[{id:`chat`,label:E(`rawFormatChat`)},{id:`messages`,label:E(`rawFormatMessages`)},{id:`responses`,label:E(`rawFormatResponses`)}]})]}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(0,Y.jsx)(Q,{ariaLabel:E(`account`),value:b,onChange:x,options:S,isDisabled:T||c===`loading`,tone:`muted`,className:`w-auto max-w-[8.5rem] min-w-0`}),(0,Y.jsx)(Q,{ariaLabel:E(`model`),value:ee,onChange:te,placeholder:E(w?`requesting`:`model`),options:C,isDisabled:T||c===`loading`||w||!C.length,className:`w-auto max-w-[10.5rem] min-w-0`})]}),(0,Y.jsxs)(`div`,{className:`space-y-2.5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,Y.jsx)(`div`,{className:`text-caption font-medium text-muted`,children:E(`prompt`)}),(0,Y.jsx)(`span`,{className:`mono text-caption text-muted`,children:r.length})]}),(0,Y.jsx)(s,{fullWidth:!0,rows:9,className:`min-h-52 resize-y rounded-xl border-0 bg-[var(--field-background)] px-3.5 py-3 text-body leading-[1.65] shadow-[inset_0_0_0_1px_color-mix(in_oklab,var(--field-border)_78%,var(--foreground))] focus-visible:ring-0`,value:r,onChange:e=>i(e.target.value),placeholder:E(`promptPlaceholder`),"aria-label":E(`prompt`),disabled:T||c===`loading`}),(0,Y.jsx)(`p`,{className:`text-caption leading-5 text-muted/70`,children:E(`promptHelper`)})]}),(0,Y.jsxs)(h,{fullWidth:!0,isPending:c===`loading`,isDisabled:!_||T,onPress:o,children:[(0,Y.jsx)(G,{size:15}),E(c===`loading`?`requesting`:`sendRequest`)]})]})]}),(0,Y.jsxs)(`div`,{className:`access-raw-panel__inspector flex min-h-[440px] min-w-0 flex-col`,"aria-live":`polite`,"aria-busy":c===`loading`,children:[(0,Y.jsxs)(`div`,{className:`flex min-h-12 items-center justify-between gap-4 px-4 py-3 sm:px-5`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`h3`,{className:`text-body font-semibold`,children:E(`responseInspector`)}),(0,Y.jsx)(`p`,{className:`mt-0.5 text-caption text-muted`,children:E(`responseInspectorHint`)})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[l===null?null:(0,Y.jsxs)(`span`,{className:`mono flex items-center gap-1.5 text-caption text-muted`,children:[(0,Y.jsx)(Ee,{size:12}),l,` ms`]}),(0,Y.jsx)(oe,{size:`sm`,variant:`soft`,color:c===`success`?`success`:c===`error`?`danger`:void 0,children:d})]})]}),(0,Y.jsx)(`div`,{className:`min-h-0 flex-1 px-4 pb-4 sm:px-5 sm:pb-5`,children:c===`idle`?(0,Y.jsx)(y,{className:`min-h-64`,title:E(`responseEmptyTitle`),hint:E(`responseEmptyHint`)}):c===`loading`?(0,Y.jsxs)(`div`,{className:`space-y-3 pt-1`,children:[(0,Y.jsx)(O,{className:`h-3 w-32 rounded-lg`}),(0,Y.jsx)(O,{className:`h-3 w-full rounded-lg`}),(0,Y.jsx)(O,{className:`h-3 w-[88%] rounded-lg`}),(0,Y.jsx)(O,{className:`h-3 w-[72%] rounded-lg`}),(0,Y.jsx)(O,{className:`mt-7 h-3 w-[92%] rounded-lg`}),(0,Y.jsx)(O,{className:`h-3 w-[64%] rounded-lg`})]}):c===`error`?(0,Y.jsx)(`div`,{className:`space-y-3`,children:(0,Y.jsx)(v,{status:`danger`,title:E(`requestFailed`),description:u})}):(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 text-caption font-medium text-success`,children:[(0,Y.jsx)(ue,{size:14,weight:`fill`}),E(`responseReceived`)]}),(0,Y.jsx)(`pre`,{className:`mono overflow-x-auto whitespace-pre-wrap break-words text-caption leading-6 text-muted`,children:u})]})})]})]})}),(0,Y.jsxs)(`section`,{className:`access-raw-panel overflow-hidden rounded-2xl`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-4 px-4 py-3 sm:px-5`,children:[(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`div`,{className:`text-body font-semibold`,children:E(`curlExample`)}),(0,Y.jsx)(`div`,{className:`mt-0.5 truncate text-caption text-muted`,children:E(`curlGeneratedHint`)})]}),(0,Y.jsxs)(h,{size:`sm`,variant:`ghost`,onPress:g,children:[(0,Y.jsx)(a,{copied:p}),E(p?`copied`:`copy`)]})]}),(0,Y.jsx)(`pre`,{className:`mono max-h-72 overflow-auto whitespace-pre-wrap px-4 pb-4 text-caption leading-6 text-muted sm:px-5 sm:pb-5`,children:f})]})]})}function Xe(e,t){let n=t.filter(e=>e.kind===`text`),r=t.filter(e=>e.kind===`image`&&e.dataUrl),i=e.trim();for(let e of n){let t=e.text??``;i=`${i}${i?` `:``}--- file: ${e.name} ---\n${t}`}if(!r.length)return i;let a=[];i&&a.push({type:`text`,text:i});for(let e of r)a.push({type:`image_url`,image_url:{url:e.dataUrl}});return a}function Ze(e,t){let n=[];for(let t of e)if(!(t.status===`error`&&t.role===`assistant`&&!t.content)){if(t.role===`user`){n.push({role:`user`,content:Xe(t.content,t.attachments||[])});continue}t.content&&n.push({role:`assistant`,content:t.content})}return[...n,t]}var Qe=`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAFUlEQVR42mNkYPhfz0AEYBxVSF+FABJADveWkH6aAAAAAElFTkSuQmCC`;function $e(){return[{id:`demo-user-1`,role:`user`,content:`Summarize the attached screenshot and look up the endpoint.`,attachments:[{id:`demo-img-1`,name:`screenshot.png`,mime:`image/png`,kind:`image`,dataUrl:Qe,size:2048},{id:`demo-txt-1`,name:`notes.md`,mime:`text/markdown`,kind:`text`,text:`# notes placeholder`,size:128}],status:`done`},{id:`demo-assistant-1`,role:`assistant`,provider:`workbuddy`,content:`The screenshot shows the Access playground. I looked up the chat completions route and drafted a short summary below.`,reasoning:`User attached a UI screenshot and a notes file. I should call the models/list helper, then summarize the visible chrome without inventing product claims. -Keep the reply short and ops-console toned.`,toolCalls:[{index:0,id:`call_demo_list`,name:`list_endpoints`,arguments:JSON.stringify({base:`/v1`,filter:`chat`},null,2),status:`success`},{index:1,id:`call_demo_read`,name:`read_attachment`,arguments:JSON.stringify({name:`notes.md`,max_chars:400},null,2),status:`success`}],reasoningOpen:!1,usage:{credits:.75,prompt_tokens:1840,completion_tokens:126,source:`upstream`},ttfb_ms:380,latency_ms:2140,status:`done`}]}function et(){return[{id:`demo-user-thinking`,role:`user`,content:`Walk through the Access playground layout.`,status:`done`},{id:`demo-assistant-thinking`,role:`assistant`,provider:`workbuddy`,content:``,reasoning:`Scan the stage chrome, then the composer controls, then draft a short reply without inventing product claims.`,status:`streaming`}]}function tt(e){return`'${e.replaceAll(`'`,`'"'"'`)}'`}function nt(e){return`${e}-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function rt(e,t){return e.map((e,n)=>({index:typeof e.index==`number`?e.index:n,id:e.id||`tool-${n}`,name:e.function?.name||``,arguments:e.function?.arguments||``,status:t?`running`:`success`}))}function $(){if(typeof window>`u`)return null;try{let e=new URLSearchParams(window.location.search).get(`demo`);return e===`1`||e===`full`?`full`:e===`thinking`?`thinking`:null}catch{return null}}function it(){let e=$();return e===`thinking`?et():e===`full`?$e():[]}function at(e){let t=e.find(e=>e.role===`user`&&e.content.trim());if(!t)return``;let n=t.content.trim().replace(/\s+/g,` `);return n.length>36?`${n.slice(0,36)}…`:n}function ot(e=[]){return{id:nt(`session`),title:at(e),messages:e,updatedAt:Date.now()}}var st=[{id:`hy3`,display_name:`HY3`,credits:`0.75 credits`,provider:`workbuddy`},{id:`glm-4.6`,display_name:`GLM-4.6`,credits:`0.5 credits`,provider:`workbuddy`},{id:`free-demo`,display_name:`Free Demo`,credits:`0 credits`,free:!0,provider:`workbuddy`}];function ct(){let{t:e}=p(),{overview:t,loading:n}=oe(),[r,i]=(0,j.useState)(`chat`),[s,c]=(0,j.useState)(`chat`),[u,f]=(0,j.useState)(!0),[m,g]=(0,j.useState)(()=>[ot(it())]),[_,v]=(0,j.useState)(``),y=_||m[0]?.id||``,S=(m.find(e=>e.id===y)||m[0])?.messages||[],[w,ie]=(0,j.useState)([]),[T,se]=(0,j.useState)([]);(0,j.useEffect)(()=>{let e=!1;return Promise.allSettled([te(),re(!1)]).then(([t,n])=>{e||(t.status===`fulfilled`&&ie(t.value.data||[]),n.status===`fulfilled`&&se(n.value.data||[]))}),()=>{e=!0}},[]);let ce=J(t?.access?.openai_base_url||`/v1`),E=t?.access?.chat_completions||`/v1/chat/completions`,ue=t?.access?.messages||`/v1/messages`,de=t?.access?.responses||`/v1/responses`,D=s===`messages`?ue:s===`responses`?de:E,O=J(D),[k,fe]=(0,j.useState)(``),[he,A]=(0,j.useState)(``),[ve,ye]=(0,j.useState)(null),[M,be]=(0,j.useState)(`只回复OK`),[xe,N]=(0,j.useState)(``),[P,F]=(0,j.useState)([]),[Se,I]=(0,j.useState)(`idle`),L=(0,j.useRef)(null),[Ce,R]=(0,j.useState)(``),[z,B]=(0,j.useState)(`idle`),[we,Te]=(0,j.useState)(null),[Ee,De]=(0,j.useState)(``),V=he||``,H=!V||ve?.accountId===V,U=V?H&&ve?.models||[]:w,W=!!V&&!H,Oe=H&&ve?.error||``,ke=$()==null?[]:st.map(e=>e.id),G=U.some(e=>e.id===k)||ke.includes(k)?k:U[0]?.id||ke[0]||``;(0,j.useEffect)(()=>{if(!V)return;let e=!1;return te(V).then(t=>{e||ye({accountId:V,models:t.data||[],error:``})}).catch(t=>{e||ye({accountId:V,models:[],error:t instanceof Error?t.message:String(t)})}),()=>{e=!0}},[V]),(0,j.useEffect)(()=>()=>{L.current?.abort()},[]);let K=T.filter(e=>e.enabled!==!1&&(e.ready===!0||e.hot===!0||e.status===`ready`||e.status===`hot`)),Ae=(0,j.useMemo)(()=>ne(s,G,M),[M,s,G]),q=(0,j.useMemo)(()=>`curl -sS ${tt(O)} \\ +Keep the reply short and ops-console toned.`,toolCalls:[{index:0,id:`call_demo_list`,name:`list_endpoints`,arguments:JSON.stringify({base:`/v1`,filter:`chat`},null,2),status:`success`},{index:1,id:`call_demo_read`,name:`read_attachment`,arguments:JSON.stringify({name:`notes.md`,max_chars:400},null,2),status:`success`}],reasoningOpen:!1,usage:{credits:.75,prompt_tokens:1840,completion_tokens:126,source:`upstream`},ttfb_ms:380,latency_ms:2140,status:`done`}]}function et(){return[{id:`demo-user-thinking`,role:`user`,content:`Walk through the Access playground layout.`,status:`done`},{id:`demo-assistant-thinking`,role:`assistant`,provider:`workbuddy`,content:``,reasoning:`Scan the stage chrome, then the composer controls, then draft a short reply without inventing product claims.`,status:`streaming`}]}function tt(e){return`'${e.replaceAll(`'`,`'"'"'`)}'`}function nt(e){return`${e}-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function rt(e,t){return e.map((e,n)=>({index:typeof e.index==`number`?e.index:n,id:e.id||`tool-${n}`,name:e.function?.name||``,arguments:e.function?.arguments||``,status:t?`running`:`success`}))}function $(){if(typeof window>`u`)return null;try{let e=new URLSearchParams(window.location.search).get(`demo`);return e===`1`||e===`full`?`full`:e===`thinking`?`thinking`:null}catch{return null}}function it(){let e=$();return e===`thinking`?et():e===`full`?$e():[]}function at(e){let t=e.find(e=>e.role===`user`&&e.content.trim());if(!t)return``;let n=t.content.trim().replace(/\s+/g,` `);return n.length>36?`${n.slice(0,36)}…`:n}function ot(e=[]){return{id:nt(`session`),title:at(e),messages:e,updatedAt:Date.now()}}var st=[{id:`hy3`,display_name:`HY3`,credits:`0.75 credits`,provider:`workbuddy`},{id:`glm-4.6`,display_name:`GLM-4.6`,credits:`0.5 credits`,provider:`workbuddy`},{id:`free-demo`,display_name:`Free Demo`,credits:`0 credits`,free:!0,provider:`workbuddy`}];function ct(){let{t:e}=m(),{overview:t,loading:n}=ce(),[r,i]=(0,j.useState)(`chat`),[s,c]=(0,j.useState)(`chat`),[u,f]=(0,j.useState)(!0),[p,g]=(0,j.useState)(()=>[ot(it())]),[_,v]=(0,j.useState)(``),y=_||p[0]?.id||``,S=(p.find(e=>e.id===y)||p[0])?.messages||[],[C,w]=(0,j.useState)([]),[D,ae]=(0,j.useState)([]);(0,j.useEffect)(()=>{let e=!1;return Promise.allSettled([ne(),ie(!1)]).then(([t,n])=>{e||(t.status===`fulfilled`&&w(t.value.data||[]),n.status===`fulfilled`&&ae(n.value.data||[]))}),()=>{e=!0}},[]);let se=J(t?.access?.openai_base_url||`/v1`),le=t?.access?.chat_completions||`/v1/chat/completions`,ue=t?.access?.messages||`/v1/messages`,O=t?.access?.responses||`/v1/responses`,fe=s===`messages`?ue:s===`responses`?O:le,pe=J(fe),[k,A]=(0,j.useState)(``),[me,he]=(0,j.useState)(``),[ve,ye]=(0,j.useState)(null),[M,be]=(0,j.useState)(`只回复OK`),[xe,N]=(0,j.useState)(``),[P,F]=(0,j.useState)([]),[Se,I]=(0,j.useState)(`idle`),L=(0,j.useRef)(null),[Ce,R]=(0,j.useState)(``),[z,B]=(0,j.useState)(`idle`),[we,Te]=(0,j.useState)(null),[Ee,De]=(0,j.useState)(``),V=me||``,H=!V||ve?.accountId===V,U=V?H&&ve?.models||[]:C,W=!!V&&!H,Oe=H&&ve?.error||``,ke=$()==null?[]:st.map(e=>e.id),G=U.some(e=>e.id===k)||ke.includes(k)?k:U[0]?.id||ke[0]||``;(0,j.useEffect)(()=>{if(!V)return;let e=!1;return ne(V).then(t=>{e||ye({accountId:V,models:t.data||[],error:``})}).catch(t=>{e||ye({accountId:V,models:[],error:t instanceof Error?t.message:String(t)})}),()=>{e=!0}},[V]),(0,j.useEffect)(()=>()=>{L.current?.abort()},[]);let K=D.filter(e=>e.enabled!==!1&&(e.ready===!0||e.hot===!0||e.status===`ready`||e.status===`hot`)),Ae=(0,j.useMemo)(()=>re(s,G,M),[M,s,G]),q=(0,j.useMemo)(()=>`curl -sS ${tt(pe)} \\ -H "Authorization: Bearer $CLI2API_API_KEY" \\ -H ${tt(`Content-Type: application/json`)}${V?` \\ -H ${tt(`X-Qoder-Account: ${V}`)}`:``} \\ - -d ${tt(JSON.stringify(Ae))}`,[Ae,O,V]);if(n&&!t)return(0,Y.jsx)(le,{});async function Me(e,t){await d(e),De(t),window.setTimeout(()=>De(``),1100)}async function Ne(){let e=performance.now();B(`loading`),Te(null),R(``);try{let e=await ee(D,Ae,V||void 0);R(JSON.stringify(e,null,2)),B(`success`)}catch(e){R(e instanceof Error?e.message:String(e)),B(`error`)}finally{Te(Math.round(performance.now()-e))}}function X(){L.current?.abort(),L.current=null}function Pe(e){let t=y;g(n=>n.map(n=>{if(n.id!==t)return n;let r=typeof e==`function`?e(n.messages):e;return{...n,messages:r,title:at(r)||n.title,updatedAt:Date.now()}}))}function Z(e,t){Pe(n=>n.map(n=>{if(n.id!==e)return n;let r=typeof t==`function`?t(n):t;return{...n,...r}}))}async function Q(){let e=xe.trim();if(!e&&!P.length||!G||W||Se===`loading`)return;X();let t=new AbortController;L.current=t;let n=P,r={id:nt(`user`),role:`user`,content:e,attachments:n,status:`done`},i=nt(`assistant`),a={id:i,role:`assistant`,provider:T.find(e=>e.id===V)?.provider||U.find(e=>e.id===G)?.provider||``,content:``,status:`streaming`},o=S;Pe([...o,r,a]),N(``),F([]),I(`loading`);let s=Ze(o,{role:`user`,content:Xe(e,n)}),c=performance.now(),l=null,u=()=>{l??=performance.now()},d=()=>{let e=performance.now();return{latency_ms:Math.max(0,Math.round(e-c)),ttfb_ms:l==null?void 0:Math.max(0,Math.round(l-c))}};try{await C(G,s,V||void 0,{signal:t.signal,onContent:(e,t)=>{e&&u(),Z(i,{content:t})},onReasoning:(e,t)=>{e&&u(),Z(i,{reasoning:t})},onToolCalls:e=>{u(),Z(i,{toolCalls:rt(e,!0)})},onUsage:e=>Z(i,{usage:e})}),Z(i,e=>({status:`done`,...d(),toolCalls:e.toolCalls?.map(e=>({...e,status:`success`}))})),I(`success`)}catch(e){if(t.signal.aborted){Z(i,e=>({status:`done`,...d(),toolCalls:e.toolCalls?.map(e=>({...e,status:`success`}))})),I(`success`);return}Z(i,{status:`error`,error:e instanceof Error?e.message:String(e),...d()}),I(`error`)}finally{L.current===t&&(L.current=null)}}let Le=e(z===`success`?`requestComplete`:z===`error`?`requestFailed`:z===`loading`?`requesting`:`requestIdle`),Re=$()!=null,ze=[{id:`auto`,textValue:e(`autoAccount`),label:e(`autoAccount`),icon:(0,Y.jsx)(o,{size:14,className:`text-muted`})},...T.map(t=>({id:t.id,textValue:`${t.name||t.id} ${_e(t.provider,t.region,e)}`,label:t.name||t.id,hint:_e(t.provider,t.region,e),icon:(0,Y.jsx)(ge,{provider:t.provider,size:14})}))],Be=T.length||!Re?ze:[{id:`auto`,textValue:e(`autoAccount`),label:e(`autoAccount`),icon:(0,Y.jsx)(o,{size:14,className:`text-muted`})},{id:`demo-wb`,textValue:`wb-demo WorkBuddy`,label:`wb-demo`,hint:`WorkBuddy`}],Ve=U.map(t=>{let n=pe(t),r=me(t),i=t.display_name||t.id,a=r?e(`modelFree`):n,o=t.provider||t.owned_by||``;return{id:t.id,textValue:`${i} ${t.id} ${o} ${n} ${r?`free`:``}`,label:a?`${i} ${a}`:i,hint:[t.id,o,a].filter(Boolean).join(` · `)}}),He=Ve.length||!Re?Ve:st.map(t=>{let n=pe(t),r=me(t),i=t.display_name||t.id,a=r?e(`modelFree`):n;return{id:t.id,textValue:`${i} ${t.id} ${t.provider} ${n} ${r?`free`:``}`,label:a?`${i} ${a}`:i,hint:[t.id,t.provider,a].filter(Boolean).join(` · `)}}),Ue=!!((xe.trim()||P.length)&&G&&!W&&(T.length||Re));function We(){Pe($e()),I(`idle`)}function Ge(){X(),I(`idle`),N(``),F([]);let e=ot([]);g(t=>[e,...t]),v(e.id)}function Ke(e){e!==y&&(X(),I(`idle`),N(``),F([]),v(e))}let qe=m.slice().sort((e,t)=>t.updatedAt-e.updatedAt).map(t=>({id:t.id,title:t.title||e(`chatHistoryUntitled`),updatedAt:t.updatedAt}));return(0,Y.jsxs)(`div`,{className:`access-page space-y-4`,children:[(0,Y.jsxs)(`section`,{className:`access-info-row flex flex-wrap items-center gap-x-3 gap-y-2 px-0.5 py-0.5`,title:e(`apiPlaygroundHint`),children:[(0,Y.jsx)(`h2`,{className:`shrink-0 text-body font-semibold text-foreground`,children:e(`apiPlayground`)}),(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5 text-caption text-muted`,children:[(0,Y.jsx)(`span`,{className:`shrink-0`,children:e(`baseUrl`)}),(0,Y.jsx)(`code`,{className:`mono min-w-0 truncate font-medium text-foreground`,children:ce}),(0,Y.jsx)(h,{isIconOnly:!0,size:`sm`,variant:`ghost`,className:`size-6 min-w-6 shrink-0`,"aria-label":e(`copyBaseUrl`),onPress:()=>void Me(ce,`base`),children:(0,Y.jsx)(a,{copied:Ee===`base`,size:13})})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-caption text-muted`,children:[(0,Y.jsx)(`span`,{className:`status-dot`,"data-state":K.length?`ok`:void 0}),(0,Y.jsx)(`span`,{children:e(`readyAccounts`,{ready:K.length,total:T.length})}),(0,Y.jsx)(ae,{size:`sm`,variant:`soft`,color:K.length?`success`:`warning`,children:K.length?e(`endpointReady`):e(`degraded`)})]})]}),T.length?null:(0,Y.jsxs)(`div`,{className:`space-y-1 px-1`,children:[(0,Y.jsx)(`p`,{className:`text-caption text-muted`,children:e(`noAccountsForTest`)}),(0,Y.jsx)(l,{})]}),Oe?(0,Y.jsx)(`p`,{className:`px-1 text-caption text-danger`,children:Oe}):null,(0,Y.jsxs)(x,{selectedKey:r,onSelectionChange:e=>i(String(e)),children:[(0,Y.jsx)(x.ListContainer,{className:`w-fit`,children:(0,Y.jsxs)(x.List,{"aria-label":e(`accessTabsLabel`),children:[(0,Y.jsxs)(b,{id:`chat`,className:`gap-1.5 whitespace-nowrap`,children:[(0,Y.jsx)(x.Indicator,{className:`transition-none`}),e(`accessTabChat`)]}),(0,Y.jsxs)(b,{id:`raw`,className:`gap-1.5 whitespace-nowrap`,children:[(0,Y.jsx)(x.Indicator,{className:`transition-none`}),e(`accessTabApi`)]})]})}),(0,Y.jsx)(x.Panel,{id:`chat`,className:`pt-4`,children:(0,Y.jsxs)(`div`,{className:`flex min-h-[640px] md:min-h-[72vh]`,children:[(0,Y.jsx)(Ie,{collapsed:u,onCollapsedChange:f,items:qe,activeId:y,onSelect:Ke,onNew:Ge}),(0,Y.jsxs)(`div`,{className:`access-chat-stage flex min-w-0 flex-1 flex-col`,children:[(0,Y.jsx)(Je,{messages:S,busy:Se===`loading`,onLoadDemo:We}),(0,Y.jsx)(Fe,{value:xe,onChange:N,attachments:P,onAttachmentsChange:F,disabled:!T.length&&$()==null,streaming:Se===`loading`,canSend:Ue,onSend:()=>void Q(),onStop:X,accountValue:V||`auto`,onAccountChange:e=>A(e===`auto`?``:e),accountOptions:Be,modelValue:G,onModelChange:fe,modelOptions:He,modelsLoading:W})]})]})}),(0,Y.jsxs)(x.Panel,{id:`raw`,className:`space-y-4 pt-4`,children:[(0,Y.jsx)(Ye,{format:s,onFormatChange:c,requestPath:D,prompt:M,onPromptChange:be,onTest:()=>void Ne(),requestState:z,elapsedMs:we,output:Ce,responseStatus:Le,curl:q,copiedCurl:Ee===`curl`,onCopyCurl:()=>void Me(q,`curl`),canSend:!!(M.trim()&&G&&!W),accountValue:V||`auto`,onAccountChange:e=>A(e===`auto`?``:e),accountOptions:Be,modelValue:G,onModelChange:fe,modelOptions:He,modelsLoading:W,disabled:!T.length&&$()==null}),(0,Y.jsx)(je,{access:t?.access})]})]})]})}export{ct as AccessPage}; \ No newline at end of file + -d ${tt(JSON.stringify(Ae))}`,[Ae,pe,V]);if(n&&!t)return(0,Y.jsx)(de,{});async function Me(e,t){await d(e),De(t),window.setTimeout(()=>De(``),1100)}async function Ne(){let e=performance.now();B(`loading`),Te(null),R(``);try{let e=await T(fe,Ae,V||void 0);R(JSON.stringify(e,null,2)),B(`success`)}catch(e){R(e instanceof Error?e.message:String(e)),B(`error`)}finally{Te(Math.round(performance.now()-e))}}function X(){L.current?.abort(),L.current=null}function Pe(e){let t=y;g(n=>n.map(n=>{if(n.id!==t)return n;let r=typeof e==`function`?e(n.messages):e;return{...n,messages:r,title:at(r)||n.title,updatedAt:Date.now()}}))}function Z(e,t){Pe(n=>n.map(n=>{if(n.id!==e)return n;let r=typeof t==`function`?t(n):t;return{...n,...r}}))}async function Q(){let e=xe.trim();if(!e&&!P.length||!G||W||Se===`loading`)return;X();let t=new AbortController;L.current=t;let n=P,r={id:nt(`user`),role:`user`,content:e,attachments:n,status:`done`},i=nt(`assistant`),a={id:i,role:`assistant`,provider:D.find(e=>e.id===V)?.provider||U.find(e=>e.id===G)?.provider||``,content:``,status:`streaming`},o=S;Pe([...o,r,a]),N(``),F([]),I(`loading`);let s=Ze(o,{role:`user`,content:Xe(e,n)}),c=performance.now(),l=null,u=()=>{l??=performance.now()},d=()=>{let e=performance.now();return{latency_ms:Math.max(0,Math.round(e-c)),ttfb_ms:l==null?void 0:Math.max(0,Math.round(l-c))}};try{await E(G,s,V||void 0,{signal:t.signal,onContent:(e,t)=>{e&&u(),Z(i,{content:t})},onReasoning:(e,t)=>{e&&u(),Z(i,{reasoning:t})},onToolCalls:e=>{u(),Z(i,{toolCalls:rt(e,!0)})},onUsage:e=>Z(i,{usage:e})}),Z(i,e=>({status:`done`,...d(),toolCalls:e.toolCalls?.map(e=>({...e,status:`success`}))})),I(`success`)}catch(e){if(t.signal.aborted){Z(i,e=>({status:`done`,...d(),toolCalls:e.toolCalls?.map(e=>({...e,status:`success`}))})),I(`success`);return}Z(i,{status:`error`,error:e instanceof Error?e.message:String(e),...d()}),I(`error`)}finally{L.current===t&&(L.current=null)}}let Le=e(z===`success`?`requestComplete`:z===`error`?`requestFailed`:z===`loading`?`requesting`:`requestIdle`),Re=$()!=null,ze=[{id:`auto`,textValue:e(`autoAccount`),label:e(`autoAccount`),icon:(0,Y.jsx)(o,{size:14,className:`text-muted`})},...D.map(t=>({id:t.id,textValue:`${t.name||t.id} ${_e(t.provider,t.region,e)}`,label:t.name||t.id,hint:_e(t.provider,t.region,e),icon:(0,Y.jsx)(ge,{provider:t.provider,size:14})}))],Be=D.length||!Re?ze:[{id:`auto`,textValue:e(`autoAccount`),label:e(`autoAccount`),icon:(0,Y.jsx)(o,{size:14,className:`text-muted`})},{id:`demo-wb`,textValue:`wb-demo WorkBuddy`,label:`wb-demo`,hint:`WorkBuddy`}],Ve=U.map(t=>{let n=ee(t),r=te(t),i=t.display_name||t.id,a=r?e(`modelFree`):n,o=t.provider||t.owned_by||``;return{id:t.id,textValue:`${i} ${t.id} ${o} ${n} ${r?`free`:``}`,label:a?`${i} ${a}`:i,hint:[t.id,o,a].filter(Boolean).join(` · `)}}),He=Ve.length||!Re?Ve:st.map(t=>{let n=ee(t),r=te(t),i=t.display_name||t.id,a=r?e(`modelFree`):n;return{id:t.id,textValue:`${i} ${t.id} ${t.provider} ${n} ${r?`free`:``}`,label:a?`${i} ${a}`:i,hint:[t.id,t.provider,a].filter(Boolean).join(` · `)}}),Ue=!!((xe.trim()||P.length)&&G&&!W&&(D.length||Re));function We(){Pe($e()),I(`idle`)}function Ge(){X(),I(`idle`),N(``),F([]);let e=ot([]);g(t=>[e,...t]),v(e.id)}function Ke(e){e!==y&&(X(),I(`idle`),N(``),F([]),v(e))}let qe=p.slice().sort((e,t)=>t.updatedAt-e.updatedAt).map(t=>({id:t.id,title:t.title||e(`chatHistoryUntitled`),updatedAt:t.updatedAt}));return(0,Y.jsxs)(`div`,{className:`access-page space-y-4`,children:[(0,Y.jsxs)(`section`,{className:`access-info-row flex flex-wrap items-center gap-x-3 gap-y-2 px-0.5 py-0.5`,title:e(`apiPlaygroundHint`),children:[(0,Y.jsx)(`h2`,{className:`shrink-0 text-body font-semibold text-foreground`,children:e(`apiPlayground`)}),(0,Y.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5 text-caption text-muted`,children:[(0,Y.jsx)(`span`,{className:`shrink-0`,children:e(`baseUrl`)}),(0,Y.jsx)(`code`,{className:`mono min-w-0 truncate font-medium text-foreground`,children:se}),(0,Y.jsx)(h,{isIconOnly:!0,size:`sm`,variant:`ghost`,className:`size-6 min-w-6 shrink-0`,"aria-label":e(`copyBaseUrl`),onPress:()=>void Me(se,`base`),children:(0,Y.jsx)(a,{copied:Ee===`base`,size:13})})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 text-caption text-muted`,children:[(0,Y.jsx)(`span`,{className:`status-dot`,"data-state":K.length?`ok`:void 0}),(0,Y.jsx)(`span`,{children:e(`readyAccounts`,{ready:K.length,total:D.length})}),(0,Y.jsx)(oe,{size:`sm`,variant:`soft`,color:K.length?`success`:`warning`,children:K.length?e(`endpointReady`):e(`degraded`)})]})]}),D.length?null:(0,Y.jsxs)(`div`,{className:`space-y-1 px-1`,children:[(0,Y.jsx)(`p`,{className:`text-caption text-muted`,children:e(`noAccountsForTest`)}),(0,Y.jsx)(l,{})]}),Oe?(0,Y.jsx)(`p`,{className:`px-1 text-caption text-danger`,children:Oe}):null,(0,Y.jsxs)(x,{selectedKey:r,onSelectionChange:e=>i(String(e)),children:[(0,Y.jsx)(x.ListContainer,{className:`w-fit`,children:(0,Y.jsxs)(x.List,{"aria-label":e(`accessTabsLabel`),children:[(0,Y.jsxs)(b,{id:`chat`,className:`gap-1.5 whitespace-nowrap`,children:[(0,Y.jsx)(x.Indicator,{className:`transition-none`}),e(`accessTabChat`)]}),(0,Y.jsxs)(b,{id:`raw`,className:`gap-1.5 whitespace-nowrap`,children:[(0,Y.jsx)(x.Indicator,{className:`transition-none`}),e(`accessTabApi`)]})]})}),(0,Y.jsx)(x.Panel,{id:`chat`,className:`pt-4`,children:(0,Y.jsxs)(`div`,{className:`flex min-h-[640px] md:min-h-[72vh]`,children:[(0,Y.jsx)(Ie,{collapsed:u,onCollapsedChange:f,items:qe,activeId:y,onSelect:Ke,onNew:Ge}),(0,Y.jsxs)(`div`,{className:`access-chat-stage flex min-w-0 flex-1 flex-col`,children:[(0,Y.jsx)(Je,{messages:S,busy:Se===`loading`,onLoadDemo:We}),(0,Y.jsx)(Fe,{value:xe,onChange:N,attachments:P,onAttachmentsChange:F,disabled:!D.length&&$()==null,streaming:Se===`loading`,canSend:Ue,onSend:()=>void Q(),onStop:X,accountValue:V||`auto`,onAccountChange:e=>he(e===`auto`?``:e),accountOptions:Be,modelValue:G,onModelChange:A,modelOptions:He,modelsLoading:W})]})]})}),(0,Y.jsxs)(x.Panel,{id:`raw`,className:`space-y-4 pt-4`,children:[(0,Y.jsx)(Ye,{format:s,onFormatChange:c,requestPath:fe,prompt:M,onPromptChange:be,onTest:()=>void Ne(),requestState:z,elapsedMs:we,output:Ce,responseStatus:Le,curl:q,copiedCurl:Ee===`curl`,onCopyCurl:()=>void Me(q,`curl`),canSend:!!(M.trim()&&G&&!W),accountValue:V||`auto`,onAccountChange:e=>he(e===`auto`?``:e),accountOptions:Be,modelValue:G,onModelChange:A,modelOptions:He,modelsLoading:W,disabled:!D.length&&$()==null}),(0,Y.jsx)(je,{access:t?.access})]})]})]})}export{ct as AccessPage}; \ No newline at end of file diff --git a/internal/webui/static/assets/AccountsPage-BlPRKunm.js b/internal/webui/static/assets/AccountsPage-BlPRKunm.js deleted file mode 100644 index 1faa9769..00000000 --- a/internal/webui/static/assets/AccountsPage-BlPRKunm.js +++ /dev/null @@ -1 +0,0 @@ -import{a as e,c as t,n}from"./shim-mfK0Rmj6.js";import{a as r,i,n as a,o,r as s,s as c,t as l}from"./CaiaiSoftLink-BXfOUHck.js";import{t as u}from"./CaretRight.es-D5fytEam.js";import{n as d,t as f}from"./clipboard-BMEt1jHG.js";import{i as p,n as m,r as ee,t as h}from"./SearchBar-Cehxs-tj.js";import{t as te}from"./Plus.es-W6ztpkEI.js";import{t as g}from"./ShieldCheck.es-DZbwX87Q.js";import{t as _}from"./TrashSimple.es-BiXnQzNp.js";import{H as v,I as y,Z as ne,n as re,nt as b,pt as x,r as S}from"./useI18n-BSw4X3mq.js";import{B as C,F as ie,J as w,M as ae,N as T,c as E,j as oe,q as se,s as ce,z as D}from"./SharedElementTransition-BlCsXfb1.js";import{_ as le,t as ue,v as de}from"./label-n7vfsS35.js";import{t as fe}from"./list-box-DD4xJ3gX.js";import{n as pe,t as me}from"./PageAlert-CaDjxveS.js";import{t as he}from"./ConfirmDialog-C6PfmZuk.js";import{n as ge}from"./useToggle-HDaAPzVy.js";import{t as _e}from"./description-0cu8nG7R.js";import{t as O}from"./EmptyPanel-Bs-jQMvG.js";import{n as k,t as A}from"./FormRow-D36RiZfK.js";import{t as j}from"./modal-BVwBjYX-.js";import{n as M,r as N,t as P}from"./number-field-D7UJ0QLF.js";import{t as F}from"./select-CtWmaZQ5.js";import{t as I}from"./CompactSwitch-DH1Gk66-.js";import{C as ve,E as L,_ as R,a as ye,b as be,c as xe,d as Se,f as Ce,g as we,i as Te,l as Ee,o as De,p as Oe,r as ke,s as Ae,u as je,v as Me,x as z,y as Ne}from"./overview-m01k08K8.js";import{t as Pe}from"./textfield-v0vQVfYo.js";import{r as B}from"./gsap-C3sDxib7.js";import{Bt as Fe,Dt as Ie,G as Le,It as Re,J as V,K as ze,M as Be,Ot as Ve,S as H,T as He,Vt as U,Wt as Ue,Y as We,_ as Ge,a as Ke,j as W,k as G,m as K,q as qe,t as q,v as Je,y as Ye,yt as Xe}from"./index-C8_qeOs_.js";import{t as Ze}from"./FilterToggle-16Av-HiR.js";import{d as Qe,f as $e}from"./format-B6SmebW-.js";import{t as et}from"./ProviderMark-IiAZTaQS.js";import{n as tt,t as nt}from"./provider-gHnttGKq.js";import{a as rt,c as it,d as at,f as ot,i as st,l as ct,m as lt,n as ut,o as dt,p as ft,r as pt,s as mt,t as ht,u as J}from"./account-BJHim5bc.js";var Y=t(e(),1),gt=new Map([[`bold`,Y.createElement(Y.Fragment,null,Y.createElement(`path`,{d:`M208,28H188V24a12,12,0,0,0-24,0v4H92V24a12,12,0,0,0-24,0v4H48A20,20,0,0,0,28,48V208a20,20,0,0,0,20,20H208a20,20,0,0,0,20-20V48A20,20,0,0,0,208,28ZM68,52a12,12,0,0,0,24,0h72a12,12,0,0,0,24,0h16V76H52V52ZM52,204V100H204V204Zm120.49-84.49a12,12,0,0,1,0,17l-48,48a12,12,0,0,1-17,0l-24-24a12,12,0,0,1,17-17L116,159l39.51-39.52A12,12,0,0,1,172.49,119.51Z`}))],[`duotone`,Y.createElement(Y.Fragment,null,Y.createElement(`path`,{d:`M216,48V88H40V48a8,8,0,0,1,8-8H208A8,8,0,0,1,216,48Z`,opacity:`0.2`}),Y.createElement(`path`,{d:`M208,32H184V24a8,8,0,0,0-16,0v8H88V24a8,8,0,0,0-16,0v8H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM72,48v8a8,8,0,0,0,16,0V48h80v8a8,8,0,0,0,16,0V48h24V80H48V48ZM208,208H48V96H208V208Zm-38.34-85.66a8,8,0,0,1,0,11.32l-48,48a8,8,0,0,1-11.32,0l-24-24a8,8,0,0,1,11.32-11.32L116,164.69l42.34-42.35A8,8,0,0,1,169.66,122.34Z`}))],[`fill`,Y.createElement(Y.Fragment,null,Y.createElement(`path`,{d:`M208,32H184V24a8,8,0,0,0-16,0v8H88V24a8,8,0,0,0-16,0v8H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM169.66,133.66l-48,48a8,8,0,0,1-11.32,0l-24-24a8,8,0,0,1,11.32-11.32L116,164.69l42.34-42.35a8,8,0,0,1,11.32,11.32ZM48,80V48H72v8a8,8,0,0,0,16,0V48h80v8a8,8,0,0,0,16,0V48h24V80Z`}))],[`light`,Y.createElement(Y.Fragment,null,Y.createElement(`path`,{d:`M208,34H182V24a6,6,0,0,0-12,0V34H86V24a6,6,0,0,0-12,0V34H48A14,14,0,0,0,34,48V208a14,14,0,0,0,14,14H208a14,14,0,0,0,14-14V48A14,14,0,0,0,208,34ZM48,46H74V56a6,6,0,0,0,12,0V46h84V56a6,6,0,0,0,12,0V46h26a2,2,0,0,1,2,2V82H46V48A2,2,0,0,1,48,46ZM208,210H48a2,2,0,0,1-2-2V94H210V208A2,2,0,0,1,208,210Zm-39.76-86.24a6,6,0,0,1,0,8.48l-48,48a6,6,0,0,1-8.48,0l-24-24a6,6,0,0,1,8.48-8.48L116,167.51l43.76-43.75A6,6,0,0,1,168.24,123.76Z`}))],[`regular`,Y.createElement(Y.Fragment,null,Y.createElement(`path`,{d:`M208,32H184V24a8,8,0,0,0-16,0v8H88V24a8,8,0,0,0-16,0v8H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM72,48v8a8,8,0,0,0,16,0V48h80v8a8,8,0,0,0,16,0V48h24V80H48V48ZM208,208H48V96H208V208Zm-38.34-85.66a8,8,0,0,1,0,11.32l-48,48a8,8,0,0,1-11.32,0l-24-24a8,8,0,0,1,11.32-11.32L116,164.69l42.34-42.35A8,8,0,0,1,169.66,122.34Z`}))],[`thin`,Y.createElement(Y.Fragment,null,Y.createElement(`path`,{d:`M208,36H180V24a4,4,0,0,0-8,0V36H84V24a4,4,0,0,0-8,0V36H48A12,12,0,0,0,36,48V208a12,12,0,0,0,12,12H208a12,12,0,0,0,12-12V48A12,12,0,0,0,208,36ZM48,44H76V56a4,4,0,0,0,8,0V44h88V56a4,4,0,0,0,8,0V44h28a4,4,0,0,1,4,4V84H44V48A4,4,0,0,1,48,44ZM208,212H48a4,4,0,0,1-4-4V92H212V208A4,4,0,0,1,208,212Zm-41.17-86.83a4,4,0,0,1,0,5.66l-48,48a4,4,0,0,1-5.66,0l-24-24a4,4,0,0,1,5.66-5.66L116,170.34l45.17-45.17A4,4,0,0,1,166.83,125.17Z`}))]]),_t=new Map([[`bold`,Y.createElement(Y.Fragment,null,Y.createElement(`path`,{d:`M112,60a16,16,0,1,1,16,16A16,16,0,0,1,112,60Zm16,52a16,16,0,1,0,16,16A16,16,0,0,0,128,112Zm0,68a16,16,0,1,0,16,16A16,16,0,0,0,128,180Z`}))],[`duotone`,Y.createElement(Y.Fragment,null,Y.createElement(`path`,{d:`M176,32V224a16,16,0,0,1-16,16H96a16,16,0,0,1-16-16V32A16,16,0,0,1,96,16h64A16,16,0,0,1,176,32Z`,opacity:`0.2`}),Y.createElement(`path`,{d:`M140,128a12,12,0,1,1-12-12A12,12,0,0,1,140,128ZM128,72a12,12,0,1,0-12-12A12,12,0,0,0,128,72Zm0,112a12,12,0,1,0,12,12A12,12,0,0,0,128,184Z`}))],[`fill`,Y.createElement(Y.Fragment,null,Y.createElement(`path`,{d:`M160,16H96A16,16,0,0,0,80,32V224a16,16,0,0,0,16,16h64a16,16,0,0,0,16-16V32A16,16,0,0,0,160,16ZM128,208a12,12,0,1,1,12-12A12,12,0,0,1,128,208Zm0-68a12,12,0,1,1,12-12A12,12,0,0,1,128,140Zm0-68a12,12,0,1,1,12-12A12,12,0,0,1,128,72Z`}))],[`light`,Y.createElement(Y.Fragment,null,Y.createElement(`path`,{d:`M118,60a10,10,0,1,1,10,10A10,10,0,0,1,118,60Zm10,58a10,10,0,1,0,10,10A10,10,0,0,0,128,118Zm0,68a10,10,0,1,0,10,10A10,10,0,0,0,128,186Z`}))],[`regular`,Y.createElement(Y.Fragment,null,Y.createElement(`path`,{d:`M140,128a12,12,0,1,1-12-12A12,12,0,0,1,140,128ZM128,72a12,12,0,1,0-12-12A12,12,0,0,0,128,72Zm0,112a12,12,0,1,0,12,12A12,12,0,0,0,128,184Z`}))],[`thin`,Y.createElement(Y.Fragment,null,Y.createElement(`path`,{d:`M120,60a8,8,0,1,1,8,8A8,8,0,0,1,120,60Zm8,60a8,8,0,1,0,8,8A8,8,0,0,0,128,120Zm0,68a8,8,0,1,0,8,8A8,8,0,0,0,128,188Z`}))]]),vt=new Map([[`bold`,Y.createElement(Y.Fragment,null,Y.createElement(`path`,{d:`M228,144v64a12,12,0,0,1-12,12H40a12,12,0,0,1-12-12V144a12,12,0,0,1,24,0v52H204V144a12,12,0,0,1,24,0Zm-108.49,8.49a12,12,0,0,0,17,0l40-40a12,12,0,0,0-17-17L140,115V32a12,12,0,0,0-24,0v83L96.49,95.51a12,12,0,0,0-17,17Z`}))],[`duotone`,Y.createElement(Y.Fragment,null,Y.createElement(`path`,{d:`M216,48V208H40V48A16,16,0,0,1,56,32H200A16,16,0,0,1,216,48Z`,opacity:`0.2`}),Y.createElement(`path`,{d:`M224,144v64a8,8,0,0,1-8,8H40a8,8,0,0,1-8-8V144a8,8,0,0,1,16,0v56H208V144a8,8,0,0,1,16,0Zm-101.66,5.66a8,8,0,0,0,11.32,0l40-40a8,8,0,0,0-11.32-11.32L136,124.69V32a8,8,0,0,0-16,0v92.69L93.66,98.34a8,8,0,0,0-11.32,11.32Z`}))],[`fill`,Y.createElement(Y.Fragment,null,Y.createElement(`path`,{d:`M224,144v64a8,8,0,0,1-8,8H40a8,8,0,0,1-8-8V144a8,8,0,0,1,16,0v56H208V144a8,8,0,0,1,16,0Zm-101.66,5.66a8,8,0,0,0,11.32,0l40-40A8,8,0,0,0,168,96H136V32a8,8,0,0,0-16,0V96H88a8,8,0,0,0-5.66,13.66Z`}))],[`light`,Y.createElement(Y.Fragment,null,Y.createElement(`path`,{d:`M222,144v64a6,6,0,0,1-6,6H40a6,6,0,0,1-6-6V144a6,6,0,0,1,12,0v58H210V144a6,6,0,0,1,12,0Zm-98.24,4.24a6,6,0,0,0,8.48,0l40-40a6,6,0,0,0-8.48-8.48L134,129.51V32a6,6,0,0,0-12,0v97.51L92.24,99.76a6,6,0,0,0-8.48,8.48Z`}))],[`regular`,Y.createElement(Y.Fragment,null,Y.createElement(`path`,{d:`M224,144v64a8,8,0,0,1-8,8H40a8,8,0,0,1-8-8V144a8,8,0,0,1,16,0v56H208V144a8,8,0,0,1,16,0Zm-101.66,5.66a8,8,0,0,0,11.32,0l40-40a8,8,0,0,0-11.32-11.32L136,124.69V32a8,8,0,0,0-16,0v92.69L93.66,98.34a8,8,0,0,0-11.32,11.32Z`}))],[`thin`,Y.createElement(Y.Fragment,null,Y.createElement(`path`,{d:`M220,144v64a4,4,0,0,1-4,4H40a4,4,0,0,1-4-4V144a4,4,0,0,1,8,0v60H212V144a4,4,0,0,1,8,0Zm-94.83,2.83a4,4,0,0,0,5.66,0l40-40a4,4,0,1,0-5.66-5.66L132,134.34V32a4,4,0,0,0-8,0V134.34L90.83,101.17a4,4,0,0,0-5.66,5.66Z`}))]]),X=new Map([[`bold`,Y.createElement(Y.Fragment,null,Y.createElement(`path`,{d:`M180.49,143.51a12,12,0,0,1,0,17l-24,24a12,12,0,0,1-17-17L155,152l-15.52-15.51a12,12,0,1,1,17-17Zm-64-24a12,12,0,0,0-17,0l-24,24a12,12,0,0,0,0,17l24,24a12,12,0,0,0,17-17L101,152l15.52-15.51A12,12,0,0,0,116.49,119.51ZM220,88V216a20,20,0,0,1-20,20H56a20,20,0,0,1-20-20V40A20,20,0,0,1,56,20h96a12,12,0,0,1,8.49,3.52l56,56A12,12,0,0,1,220,88ZM160,57V80h23Zm36,155V104H148a12,12,0,0,1-12-12V44H60V212Z`}))],[`duotone`,Y.createElement(Y.Fragment,null,Y.createElement(`path`,{d:`M208,88H152V32Z`,opacity:`0.2`}),Y.createElement(`path`,{d:`M181.66,146.34a8,8,0,0,1,0,11.32l-24,24a8,8,0,0,1-11.32-11.32L164.69,152l-18.35-18.34a8,8,0,0,1,11.32-11.32Zm-72-24a8,8,0,0,0-11.32,0l-24,24a8,8,0,0,0,0,11.32l24,24a8,8,0,0,0,11.32-11.32L91.31,152l18.35-18.34A8,8,0,0,0,109.66,122.34ZM216,88V216a16,16,0,0,1-16,16H56a16,16,0,0,1-16-16V40A16,16,0,0,1,56,24h96a8,8,0,0,1,5.66,2.34l56,56A8,8,0,0,1,216,88Zm-56-8h28.69L160,51.31Zm40,136V96H152a8,8,0,0,1-8-8V40H56V216H200Z`}))],[`fill`,Y.createElement(Y.Fragment,null,Y.createElement(`path`,{d:`M213.66,82.34l-56-56A8,8,0,0,0,152,24H56A16,16,0,0,0,40,40V216a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V88A8,8,0,0,0,213.66,82.34Zm-104,88a8,8,0,0,1-11.32,11.32l-24-24a8,8,0,0,1,0-11.32l24-24a8,8,0,0,1,11.32,11.32L91.31,152Zm72-12.68-24,24a8,8,0,0,1-11.32-11.32L164.69,152l-18.35-18.34a8,8,0,0,1,11.32-11.32l24,24A8,8,0,0,1,181.66,157.66ZM152,88V44l44,44Z`}))],[`light`,Y.createElement(Y.Fragment,null,Y.createElement(`path`,{d:`M180.24,147.76a6,6,0,0,1,0,8.48l-24,24a6,6,0,0,1-8.48-8.48L167.51,152l-19.75-19.76a6,6,0,1,1,8.48-8.48Zm-72-24a6,6,0,0,0-8.48,0l-24,24a6,6,0,0,0,0,8.48l24,24a6,6,0,1,0,8.48-8.48L88.49,152l19.75-19.76A6,6,0,0,0,108.24,123.76ZM214,88V216a14,14,0,0,1-14,14H56a14,14,0,0,1-14-14V40A14,14,0,0,1,56,26h96a6,6,0,0,1,4.25,1.76l56,56A6,6,0,0,1,214,88Zm-56-6h35.52L158,46.48Zm44,134V94H152a6,6,0,0,1-6-6V38H56a2,2,0,0,0-2,2V216a2,2,0,0,0,2,2H200A2,2,0,0,0,202,216Z`}))],[`regular`,Y.createElement(Y.Fragment,null,Y.createElement(`path`,{d:`M181.66,146.34a8,8,0,0,1,0,11.32l-24,24a8,8,0,0,1-11.32-11.32L164.69,152l-18.35-18.34a8,8,0,0,1,11.32-11.32Zm-72-24a8,8,0,0,0-11.32,0l-24,24a8,8,0,0,0,0,11.32l24,24a8,8,0,0,0,11.32-11.32L91.31,152l18.35-18.34A8,8,0,0,0,109.66,122.34ZM216,88V216a16,16,0,0,1-16,16H56a16,16,0,0,1-16-16V40A16,16,0,0,1,56,24h96a8,8,0,0,1,5.66,2.34l56,56A8,8,0,0,1,216,88Zm-56-8h28.69L160,51.31Zm40,136V96H152a8,8,0,0,1-8-8V40H56V216H200Z`}))],[`thin`,Y.createElement(Y.Fragment,null,Y.createElement(`path`,{d:`M178.83,149.17a4,4,0,0,1,0,5.66l-24,24a4,4,0,0,1-5.66-5.66L170.34,152l-21.17-21.17a4,4,0,1,1,5.66-5.66Zm-72-24a4,4,0,0,0-5.66,0l-24,24a4,4,0,0,0,0,5.66l24,24a4,4,0,1,0,5.66-5.66L85.66,152l21.17-21.17A4,4,0,0,0,106.83,125.17ZM212,88V216a12,12,0,0,1-12,12H56a12,12,0,0,1-12-12V40A12,12,0,0,1,56,28h96a4,4,0,0,1,2.83,1.17l56,56A4,4,0,0,1,212,88Zm-56-4h42.34L156,41.65Zm48,132V92H152a4,4,0,0,1-4-4V36H56a4,4,0,0,0-4,4V216a4,4,0,0,0,4,4H200A4,4,0,0,0,204,216Z`}))]]),yt=new Map([[`bold`,Y.createElement(Y.Fragment,null,Y.createElement(`path`,{d:`M230.14,70.54,185.46,25.85a20,20,0,0,0-28.29,0L33.86,149.17A19.85,19.85,0,0,0,28,163.31V208a20,20,0,0,0,20,20H92.69a19.86,19.86,0,0,0,14.14-5.86L230.14,98.82a20,20,0,0,0,0-28.28ZM91,204H52V165l84-84,39,39ZM192,103,153,64l18.34-18.34,39,39Z`}))],[`duotone`,Y.createElement(Y.Fragment,null,Y.createElement(`path`,{d:`M221.66,90.34,192,120,136,64l29.66-29.66a8,8,0,0,1,11.31,0L221.66,79A8,8,0,0,1,221.66,90.34Z`,opacity:`0.2`}),Y.createElement(`path`,{d:`M227.31,73.37,182.63,28.68a16,16,0,0,0-22.63,0L36.69,152A15.86,15.86,0,0,0,32,163.31V208a16,16,0,0,0,16,16H92.69A15.86,15.86,0,0,0,104,219.31L227.31,96a16,16,0,0,0,0-22.63ZM92.69,208H48V163.31l88-88L180.69,120ZM192,108.68,147.31,64l24-24L216,84.68Z`}))],[`fill`,Y.createElement(Y.Fragment,null,Y.createElement(`path`,{d:`M227.31,73.37,182.63,28.68a16,16,0,0,0-22.63,0L36.69,152A15.86,15.86,0,0,0,32,163.31V208a16,16,0,0,0,16,16H92.69A15.86,15.86,0,0,0,104,219.31L227.31,96a16,16,0,0,0,0-22.63ZM192,108.68,147.31,64l24-24L216,84.68Z`}))],[`light`,Y.createElement(Y.Fragment,null,Y.createElement(`path`,{d:`M225.9,74.78,181.21,30.09a14,14,0,0,0-19.8,0L38.1,153.41a13.94,13.94,0,0,0-4.1,9.9V208a14,14,0,0,0,14,14H92.69a13.94,13.94,0,0,0,9.9-4.1L225.9,94.58a14,14,0,0,0,0-19.8ZM94.1,209.41a2,2,0,0,1-1.41.59H48a2,2,0,0,1-2-2V163.31a2,2,0,0,1,.59-1.41L136,72.48,183.51,120ZM217.41,86.1,192,111.51,144.49,64,169.9,38.58a2,2,0,0,1,2.83,0l44.68,44.69a2,2,0,0,1,0,2.83Z`}))],[`regular`,Y.createElement(Y.Fragment,null,Y.createElement(`path`,{d:`M227.31,73.37,182.63,28.68a16,16,0,0,0-22.63,0L36.69,152A15.86,15.86,0,0,0,32,163.31V208a16,16,0,0,0,16,16H92.69A15.86,15.86,0,0,0,104,219.31L227.31,96a16,16,0,0,0,0-22.63ZM92.69,208H48V163.31l88-88L180.69,120ZM192,108.68,147.31,64l24-24L216,84.68Z`}))],[`thin`,Y.createElement(Y.Fragment,null,Y.createElement(`path`,{d:`M224.49,76.2,179.8,31.51a12,12,0,0,0-17,0L133.17,61.17h0L39.52,154.83A11.9,11.9,0,0,0,36,163.31V208a12,12,0,0,0,12,12H92.69a12,12,0,0,0,8.48-3.51L224.48,93.17a12,12,0,0,0,0-17Zm-129,134.63A4,4,0,0,1,92.69,212H48a4,4,0,0,1-4-4V163.31a4,4,0,0,1,1.17-2.83L136,69.65,186.34,120ZM218.83,87.51,192,114.34,141.66,64l26.82-26.83a4,4,0,0,1,5.66,0l44.69,44.68a4,4,0,0,1,0,5.66Z`}))]]),bt=new Map([[`bold`,Y.createElement(Y.Fragment,null,Y.createElement(`path`,{d:`M128,44a96,96,0,1,0,96,96A96.11,96.11,0,0,0,128,44Zm0,168a72,72,0,1,1,72-72A72.08,72.08,0,0,1,128,212ZM164.49,99.51a12,12,0,0,1,0,17l-28,28a12,12,0,0,1-17-17l28-28A12,12,0,0,1,164.49,99.51ZM92,16A12,12,0,0,1,104,4h48a12,12,0,0,1,0,24H104A12,12,0,0,1,92,16Z`}))],[`duotone`,Y.createElement(Y.Fragment,null,Y.createElement(`path`,{d:`M216,136a88,88,0,1,1-88-88A88,88,0,0,1,216,136Z`,opacity:`0.2`}),Y.createElement(`path`,{d:`M128,40a96,96,0,1,0,96,96A96.11,96.11,0,0,0,128,40Zm0,176a80,80,0,1,1,80-80A80.09,80.09,0,0,1,128,216ZM173.66,90.34a8,8,0,0,1,0,11.32l-40,40a8,8,0,0,1-11.32-11.32l40-40A8,8,0,0,1,173.66,90.34ZM96,16a8,8,0,0,1,8-8h48a8,8,0,0,1,0,16H104A8,8,0,0,1,96,16Z`}))],[`fill`,Y.createElement(Y.Fragment,null,Y.createElement(`path`,{d:`M128,40a96,96,0,1,0,96,96A96.11,96.11,0,0,0,128,40Zm45.66,61.66-40,40a8,8,0,0,1-11.32-11.32l40-40a8,8,0,0,1,11.32,11.32ZM96,16a8,8,0,0,1,8-8h48a8,8,0,0,1,0,16H104A8,8,0,0,1,96,16Z`}))],[`light`,Y.createElement(Y.Fragment,null,Y.createElement(`path`,{d:`M128,42a94,94,0,1,0,94,94A94.11,94.11,0,0,0,128,42Zm0,176a82,82,0,1,1,82-82A82.1,82.1,0,0,1,128,218ZM172.24,91.76a6,6,0,0,1,0,8.48l-40,40a6,6,0,1,1-8.48-8.48l40-40A6,6,0,0,1,172.24,91.76ZM98,16a6,6,0,0,1,6-6h48a6,6,0,0,1,0,12H104A6,6,0,0,1,98,16Z`}))],[`regular`,Y.createElement(Y.Fragment,null,Y.createElement(`path`,{d:`M128,40a96,96,0,1,0,96,96A96.11,96.11,0,0,0,128,40Zm0,176a80,80,0,1,1,80-80A80.09,80.09,0,0,1,128,216ZM173.66,90.34a8,8,0,0,1,0,11.32l-40,40a8,8,0,0,1-11.32-11.32l40-40A8,8,0,0,1,173.66,90.34ZM96,16a8,8,0,0,1,8-8h48a8,8,0,0,1,0,16H104A8,8,0,0,1,96,16Z`}))],[`thin`,Y.createElement(Y.Fragment,null,Y.createElement(`path`,{d:`M128,44a92,92,0,1,0,92,92A92.1,92.1,0,0,0,128,44Zm0,176a84,84,0,1,1,84-84A84.09,84.09,0,0,1,128,220ZM170.83,93.17a4,4,0,0,1,0,5.66l-40,40a4,4,0,1,1-5.66-5.66l40-40A4,4,0,0,1,170.83,93.17ZM100,16a4,4,0,0,1,4-4h48a4,4,0,0,1,0,8H104A4,4,0,0,1,100,16Z`}))]]),xt=new Map([[`bold`,Y.createElement(Y.Fragment,null,Y.createElement(`path`,{d:`M228,144v64a12,12,0,0,1-12,12H40a12,12,0,0,1-12-12V144a12,12,0,0,1,24,0v52H204V144a12,12,0,0,1,24,0ZM96.49,80.49,116,61v83a12,12,0,0,0,24,0V61l19.51,19.52a12,12,0,1,0,17-17l-40-40a12,12,0,0,0-17,0l-40,40a12,12,0,1,0,17,17Z`}))],[`duotone`,Y.createElement(Y.Fragment,null,Y.createElement(`path`,{d:`M216,48V208H40V48A16,16,0,0,1,56,32H200A16,16,0,0,1,216,48Z`,opacity:`0.2`}),Y.createElement(`path`,{d:`M224,144v64a8,8,0,0,1-8,8H40a8,8,0,0,1-8-8V144a8,8,0,0,1,16,0v56H208V144a8,8,0,0,1,16,0ZM93.66,77.66,120,51.31V144a8,8,0,0,0,16,0V51.31l26.34,26.35a8,8,0,0,0,11.32-11.32l-40-40a8,8,0,0,0-11.32,0l-40,40A8,8,0,0,0,93.66,77.66Z`}))],[`fill`,Y.createElement(Y.Fragment,null,Y.createElement(`path`,{d:`M224,144v64a8,8,0,0,1-8,8H40a8,8,0,0,1-8-8V144a8,8,0,0,1,16,0v56H208V144a8,8,0,0,1,16,0ZM88,80h32v64a8,8,0,0,0,16,0V80h32a8,8,0,0,0,5.66-13.66l-40-40a8,8,0,0,0-11.32,0l-40,40A8,8,0,0,0,88,80Z`}))],[`light`,Y.createElement(Y.Fragment,null,Y.createElement(`path`,{d:`M222,144v64a6,6,0,0,1-6,6H40a6,6,0,0,1-6-6V144a6,6,0,0,1,12,0v58H210V144a6,6,0,0,1,12,0ZM92.24,76.24,122,46.49V144a6,6,0,0,0,12,0V46.49l29.76,29.75a6,6,0,0,0,8.48-8.48l-40-40a6,6,0,0,0-8.48,0l-40,40a6,6,0,0,0,8.48,8.48Z`}))],[`regular`,Y.createElement(Y.Fragment,null,Y.createElement(`path`,{d:`M224,144v64a8,8,0,0,1-8,8H40a8,8,0,0,1-8-8V144a8,8,0,0,1,16,0v56H208V144a8,8,0,0,1,16,0ZM93.66,77.66,120,51.31V144a8,8,0,0,0,16,0V51.31l26.34,26.35a8,8,0,0,0,11.32-11.32l-40-40a8,8,0,0,0-11.32,0l-40,40A8,8,0,0,0,93.66,77.66Z`}))],[`thin`,Y.createElement(Y.Fragment,null,Y.createElement(`path`,{d:`M220,144v64a4,4,0,0,1-4,4H40a4,4,0,0,1-4-4V144a4,4,0,0,1,8,0v60H212V144a4,4,0,0,1,8,0ZM90.83,74.83,124,41.66V144a4,4,0,0,0,8,0V41.66l33.17,33.17a4,4,0,1,0,5.66-5.66l-40-40a4,4,0,0,0-5.66,0l-40,40a4,4,0,0,0,5.66,5.66Z`}))]]),St=new Map([[`bold`,Y.createElement(Y.Fragment,null,Y.createElement(`path`,{d:`M168.49,104.49,145,128l23.52,23.51a12,12,0,0,1-17,17L128,145l-23.51,23.52a12,12,0,0,1-17-17L111,128,87.51,104.49a12,12,0,0,1,17-17L128,111l23.51-23.52a12,12,0,0,1,17,17ZM236,128A108,108,0,1,1,128,20,108.12,108.12,0,0,1,236,128Zm-24,0a84,84,0,1,0-84,84A84.09,84.09,0,0,0,212,128Z`}))],[`duotone`,Y.createElement(Y.Fragment,null,Y.createElement(`path`,{d:`M224,128a96,96,0,1,1-96-96A96,96,0,0,1,224,128Z`,opacity:`0.2`}),Y.createElement(`path`,{d:`M165.66,101.66,139.31,128l26.35,26.34a8,8,0,0,1-11.32,11.32L128,139.31l-26.34,26.35a8,8,0,0,1-11.32-11.32L116.69,128,90.34,101.66a8,8,0,0,1,11.32-11.32L128,116.69l26.34-26.35a8,8,0,0,1,11.32,11.32ZM232,128A104,104,0,1,1,128,24,104.11,104.11,0,0,1,232,128Zm-16,0a88,88,0,1,0-88,88A88.1,88.1,0,0,0,216,128Z`}))],[`fill`,Y.createElement(Y.Fragment,null,Y.createElement(`path`,{d:`M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm37.66,130.34a8,8,0,0,1-11.32,11.32L128,139.31l-26.34,26.35a8,8,0,0,1-11.32-11.32L116.69,128,90.34,101.66a8,8,0,0,1,11.32-11.32L128,116.69l26.34-26.35a8,8,0,0,1,11.32,11.32L139.31,128Z`}))],[`light`,Y.createElement(Y.Fragment,null,Y.createElement(`path`,{d:`M164.24,100.24,136.48,128l27.76,27.76a6,6,0,1,1-8.48,8.48L128,136.48l-27.76,27.76a6,6,0,0,1-8.48-8.48L119.52,128,91.76,100.24a6,6,0,0,1,8.48-8.48L128,119.52l27.76-27.76a6,6,0,0,1,8.48,8.48ZM230,128A102,102,0,1,1,128,26,102.12,102.12,0,0,1,230,128Zm-12,0a90,90,0,1,0-90,90A90.1,90.1,0,0,0,218,128Z`}))],[`regular`,Y.createElement(Y.Fragment,null,Y.createElement(`path`,{d:`M165.66,101.66,139.31,128l26.35,26.34a8,8,0,0,1-11.32,11.32L128,139.31l-26.34,26.35a8,8,0,0,1-11.32-11.32L116.69,128,90.34,101.66a8,8,0,0,1,11.32-11.32L128,116.69l26.34-26.35a8,8,0,0,1,11.32,11.32ZM232,128A104,104,0,1,1,128,24,104.11,104.11,0,0,1,232,128Zm-16,0a88,88,0,1,0-88,88A88.1,88.1,0,0,0,216,128Z`}))],[`thin`,Y.createElement(Y.Fragment,null,Y.createElement(`path`,{d:`M162.83,98.83,133.66,128l29.17,29.17a4,4,0,0,1-5.66,5.66L128,133.66,98.83,162.83a4,4,0,0,1-5.66-5.66L122.34,128,93.17,98.83a4,4,0,0,1,5.66-5.66L128,122.34l29.17-29.17a4,4,0,1,1,5.66,5.66ZM228,128A100,100,0,1,1,128,28,100.11,100.11,0,0,1,228,128Zm-8,0a92,92,0,1,0-92,92A92.1,92.1,0,0,0,220,128Z`}))]]),Ct=Y.forwardRef((e,t)=>Y.createElement(x,{ref:t,...e,weights:gt}));Ct.displayName=`CalendarCheckIcon`;var wt=Ct,Tt=Y.forwardRef((e,t)=>Y.createElement(x,{ref:t,...e,weights:_t}));Tt.displayName=`DotsThreeVerticalIcon`;var Et=Tt,Dt=Y.forwardRef((e,t)=>Y.createElement(x,{ref:t,...e,weights:vt}));Dt.displayName=`DownloadSimpleIcon`;var Ot=Dt,kt=Y.forwardRef((e,t)=>Y.createElement(x,{ref:t,...e,weights:X}));kt.displayName=`FileCodeIcon`;var At=kt,jt=Y.forwardRef((e,t)=>Y.createElement(x,{ref:t,...e,weights:yt}));jt.displayName=`PencilSimpleIcon`;var Mt=jt,Nt=Y.forwardRef((e,t)=>Y.createElement(x,{ref:t,...e,weights:bt}));Nt.displayName=`TimerIcon`;var Pt=Nt,Ft=Y.forwardRef((e,t)=>Y.createElement(x,{ref:t,...e,weights:xt}));Ft.displayName=`UploadSimpleIcon`;var It=Ft,Lt=Y.forwardRef((e,t)=>Y.createElement(x,{ref:t,...e,weights:St}));Lt.displayName=`XCircleIcon`;var Rt=Lt,zt=D({slots:{menu:`dropdown__menu`,popover:`dropdown__popover`,root:`dropdown`,trigger:`dropdown__trigger`}}),Bt=D({defaultVariants:{color:`accent`,size:`md`},slots:{base:`meter`,fill:`meter__fill`,output:`meter__output`,track:`meter__track`},variants:{color:{accent:{base:`meter--accent`},danger:{base:`meter--danger`},default:{base:`meter--default`},success:{base:`meter--success`},warning:{base:`meter--warning`}},size:{lg:{base:`meter--lg`},md:{base:`meter--md`},sm:{base:`meter--sm`}}}}),Vt=D({defaultVariants:{variant:`default`},slots:{indicator:`menu-item__indicator`,item:`menu-item`,submenuIndicator:`menu-item__indicator menu-item__indicator--submenu`},variants:{variant:{danger:{item:`menu-item--danger`},default:{item:`menu-item--default`}}}}),Ht=D({base:`menu-section`});function Ut(e){let{value:t=0,minValue:n=0,maxValue:r=100,valueLabel:i,isIndeterminate:a,formatOptions:o={style:`percent`}}=e,s=se(e,{labelable:!0}),{labelProps:c,fieldProps:l}=le({...e,labelElementType:`span`});t=b(t,n,r);let u=r-n,d=u===0?0:(t-n)/u,f=N(o);if(!a&&!i){let e=o.style===`percent`?d:t;i=f.format(e)}return{progressBarProps:w(s,{...l,"aria-valuenow":a?void 0:t,"aria-valuemin":n,"aria-valuemax":r,"aria-valuetext":a?void 0:i,role:`progressbar`}),labelProps:c}}function Wt(e){let{progressBarProps:t,labelProps:n}=Ut(e);return{meterProps:{...t,role:`meter progressbar`},labelProps:n}}var Gt=(0,Y.createContext)(null),Kt=(0,Y.forwardRef)(function(e,t){[e,t]=oe(e,t,Gt);let{value:n=0,minValue:r=0,maxValue:i=100}=e;n=b(n,r,i);let a=i-r,[o,s]=T(!e[`aria-label`]&&!e[`aria-labelledby`]),{meterProps:c,labelProps:l}=Wt({...e,label:s}),u=a===0?0:(n-r)/a*100,d=ae({...e,defaultClassName:`react-aria-Meter`,values:{percentage:u,valueText:c[`aria-valuetext`]}}),f=se(e,{global:!0});return Y.createElement(ie.div,{...w(f,d,c),ref:t,slot:e.slot||void 0},Y.createElement(de.Provider,{value:{...l,ref:o,elementType:`span`}},d.children))}),Z=n(),qt=(0,Y.createContext)({}),Jt=({children:e,className:t,variant:n,...r})=>{let i=Y.useMemo(()=>Vt({variant:n}),[n]);return(0,Z.jsx)(ze,{className:E(t,i.item()),"data-slot":`menu-item`,...r,children:t=>(0,Z.jsx)(qt,{value:{slots:i,state:t},children:typeof e==`function`?e(t):e})})},Yt=({children:e,className:t,type:n=`checkmark`,...r})=>{let{slots:i,state:a}=(0,Y.use)(qt),o=a?.isSelected,s=typeof e==`function`?e(a??{}):e||(n===`dot`?(0,Z.jsx)(`svg`,{"aria-hidden":`true`,"data-slot":`menu-item-indicator--dot`,fill:`currentColor`,fillRule:`evenodd`,role:`presentation`,viewBox:`0 0 16 16`,xmlns:`http://www.w3.org/2000/svg`,children:(0,Z.jsx)(`path`,{clipRule:`evenodd`,d:`M8 15A7 7 0 1 0 8 1a7 7 0 0 0 0 14`,fillRule:`evenodd`})}):(0,Z.jsx)(`svg`,{"aria-hidden":`true`,"data-slot":`menu-item-indicator--checkmark`,fill:`none`,role:`presentation`,stroke:`currentColor`,strokeDasharray:22,strokeDashoffset:o?44:66,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,viewBox:`0 0 17 18`,children:(0,Z.jsx)(`polyline`,{points:`1 9 7 14 15 4`})}));return(0,Z.jsx)(C.span,{"aria-hidden":`true`,className:ce(i?.indicator,t),"data-slot":`menu-item-indicator`,"data-type":n,"data-visible":o||void 0,...r,children:s})},Xt=({children:e,className:t,...n})=>{let{slots:r,state:i}=(0,Y.use)(qt);if(!i?.hasSubmenu)return null;let a=e??(0,Z.jsx)(v,{});return(0,Z.jsx)(C.span,{"aria-hidden":`true`,className:ce(r?.submenuIndicator,t),"data-slot":`submenu-indicator`,...n,children:a})},Zt=({children:e,className:t,...n})=>{let r=Y.useMemo(()=>Ht({class:typeof t==`string`?t:void 0}),[t]);return(0,Z.jsx)(qe,{className:r,...n,children:e})},Qt=(0,Y.createContext)({}),$t=({children:e,...t})=>{let n=Y.useMemo(()=>zt(),[]);return(0,Z.jsx)(Qt,{value:{slots:n},children:(0,Z.jsx)(Le,{...t,children:e})})},en=({children:e,className:t,...n})=>{let{slots:r}=(0,Y.use)(Qt);return(0,Z.jsx)(ne,{className:E(t,r?.trigger()),"data-slot":`dropdown-trigger`,...n,children:t=>(0,Z.jsx)(Z.Fragment,{children:typeof e==`function`?e(t):e})})},tn=({children:e,className:t,placement:n,...r})=>{let{slots:i}=(0,Y.use)(Qt);return(0,Z.jsx)(y,{value:{variant:`default`},children:(0,Z.jsx)(Xe,{...r,className:E(t,i?.popover()),"data-slot":`dropdown-popover`,placement:n,children:e})})};function nn({className:e,...t}){let{slots:n}=(0,Y.use)(Qt);return(0,Z.jsx)(V,{className:E(e,n?.menu()),"data-selection-mode":t.selectionMode,"data-slot":`dropdown-menu`,...t})}var rn=Object.assign($t,{Root:$t,Trigger:en,Popover:tn,Menu:nn,Section:e=>(0,Z.jsx)(Zt,{...e}),Item:e=>(0,Z.jsx)(Jt,{...e}),ItemIndicator:e=>(0,Z.jsx)(Yt,{...e}),SubmenuIndicator:e=>(0,Z.jsx)(Xt,{...e}),SubmenuTrigger:({children:e,...t})=>(0,Z.jsx)(We,{"data-slot":`dropdown-submenu-trigger`,...t,children:e})}),an=(0,Y.createContext)({}),on=({children:e,className:t,color:n,size:r,...i})=>{let a=Y.useMemo(()=>Bt({color:n,size:r}),[n,r]);return(0,Z.jsx)(Kt,{"data-slot":`meter`,...i,className:E(t,a.base()),children:t=>(0,Z.jsx)(an,{value:{slots:a,state:t},children:typeof e==`function`?e(t):e})})};on.displayName=`HeroUI.Meter`;var sn=({children:e,className:t,...n})=>{let{slots:r,state:i}=(0,Y.use)(an);return(0,Z.jsx)(C.span,{className:ce(r?.output,t),"data-slot":`meter-output`,...n,children:e??i?.valueText})};sn.displayName=`HeroUI.Meter.Output`;var cn=({children:e,className:t,...n})=>{let{slots:r}=(0,Y.use)(an);return(0,Z.jsx)(C.div,{className:ce(r?.track,t),"data-slot":`meter-track`,...n,children:e})};cn.displayName=`HeroUI.Meter.Track`;var ln=({className:e,style:t,...n})=>{let{slots:r,state:i}=(0,Y.use)(an);return(0,Z.jsx)(C.div,{className:ce(r?.fill,e),"data-slot":`meter-fill`,style:{...t,width:`${i?.percentage??0}%`},...n})};ln.displayName=`HeroUI.Meter.Fill`;var un=Object.assign(on,{Root:on,Output:sn,Track:cn,Fill:ln}),dn=()=>()=>{},fn=new Set,pn=Date.now(),mn=null;function hn(){pn=Date.now();for(let e of fn)e()}function gn(e){return fn.size===0&&(pn=Date.now()),fn.add(e),mn===null&&(mn=window.setInterval(hn,1e3)),()=>{fn.delete(e),fn.size===0&&mn!==null&&(window.clearInterval(mn),mn=null)}}function _n(){return pn}function vn(e=!0){return(0,Y.useSyncExternalStore)(e?gn:dn,_n,_n)}function yn(e){(0,Y.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let n=B.context(()=>{B.matchMedia().add(`(prefers-reduced-motion: no-preference)`,()=>{let e=B.utils.toArray(`.meter__fill`);e.length&&B.from(e,{scaleX:0,transformOrigin:`left center`,duration:Je.calm,ease:Ye.emphasized,stagger:H.base,clearProps:`transform,transformOrigin`})})},t);return()=>n.revert()},[e])}function bn(e,t,n,r,i,a){return[e.has_add_on&&e.add_on_available!==!1?`${n} ${rt(e.add_on_used)} / ${rt(e.add_on_total)} ${e.add_on_unit||`credits`}`:``,e.has_resource_package&&e.resource_package_available!==!1?`${r} ${t} ${rt(e.resource_package_remaining)} ${e.resource_package_unit||`credits`}`:``,a===`workbuddy`?mt(e,i):``].filter(Boolean)}function xn({window:e,t,extra:n}){let r=Math.round(e.percentage??0),i=at(e,t),a=t(`quotaUsedPercent`,{n:r}),o=it(e.reset_at,t),s=`${i} · ${a}${o?` · ${o}`:``}`,c=J(e),l=ct(e),u=l===`danger`?`danger`:l===`warn`?`warning`:`success`;return(0,Z.jsxs)(G,{children:[(0,Z.jsx)(G.Trigger,{className:`block w-full min-w-0`,children:(0,Z.jsxs)(`div`,{className:`w-full min-w-0 cursor-help`,children:[(0,Z.jsxs)(un,{className:`account-meter account-meter--window w-full`,color:u,size:`md`,minValue:0,maxValue:100,value:Math.round(c*100),"aria-label":i,valueLabel:s,children:[(0,Z.jsxs)(un.Output,{className:`flex w-full items-baseline justify-between gap-3 text-caption`,children:[(0,Z.jsx)(`span`,{className:`min-w-0 truncate font-medium text-foreground`,children:i}),(0,Z.jsx)(`span`,{className:`mono shrink-0 text-foreground/70`,children:a})]}),(0,Z.jsx)(un.Track,{children:(0,Z.jsx)(un.Fill,{})})]}),o?(0,Z.jsx)(`div`,{className:`mt-1 text-caption leading-4 text-muted`,children:o}):null]})}),(0,Z.jsx)(G.Content,{children:(0,Z.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,Z.jsx)(`div`,{children:s}),n?.map(e=>(0,Z.jsx)(`div`,{children:e},e))]})})]})}function Sn({quota:e,t,label:n,usedLabel:r,remainingLabel:i,addOnLabel:a,resourcePackageLabel:o,exceededLabel:s,provider:c}){let l=e.unit||`credits`,u=`${rt(e.used)} / ${rt(e.total)}`,d=`${rt(e.remaining)}`,f=bn(e,i,a,o,t,c),p=ot(e),m=c===`codex`||c===`kiro`?pt(e.plan):``,ee=J(e),h=ct(e),te=h===`danger`?`danger`:h===`warn`?`warning`:`success`,g=(0,Y.useRef)(null);yn(g);let _=`${r} ${u} ${l} · ${i} ${d} ${l}${f.length?` · ${f.join(` · `)}`:``}`;return p.length>0?(0,Z.jsxs)(`div`,{ref:g,className:`account-quota-windows flex w-full min-w-0 flex-col gap-3`,children:[m?(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-caption`,children:[(0,Z.jsx)(`span`,{className:`text-muted`,children:t(`quotaPlan`)}),(0,Z.jsx)(`span`,{className:`font-medium text-foreground`,children:m})]}):null,p.map((e,n)=>(0,Z.jsx)(`div`,{className:`w-full min-w-0`,children:(0,Z.jsx)(xn,{window:e,t,extra:n===0?f:void 0})},e.id||String(n)))]}):(0,Z.jsxs)(G,{children:[(0,Z.jsx)(G.Trigger,{children:(0,Z.jsx)(`div`,{ref:g,className:`w-full cursor-help`,children:(0,Z.jsxs)(un,{className:`account-meter w-full`,color:te,size:`md`,minValue:0,maxValue:100,value:Math.round(ee*100),"aria-label":n,valueLabel:_,children:[(0,Z.jsxs)(un.Output,{className:`flex w-full items-baseline justify-between text-caption`,children:[(0,Z.jsxs)(`span`,{className:`text-body font-semibold leading-5 text-foreground tabular-nums`,children:[e.exceeded?(0,Z.jsx)(`span`,{className:`mr-1.5 text-danger`,children:s}):(0,Z.jsx)(`span`,{className:`mr-1.5 text-caption font-normal text-muted`,children:i}),d,(0,Z.jsx)(`span`,{className:`ml-1 text-caption font-normal text-foreground/60`,children:l})]}),(0,Z.jsxs)(`span`,{className:`mono text-foreground/55`,children:[u,` · `,Math.round(ee*100),`%`]})]}),(0,Z.jsx)(un.Track,{children:(0,Z.jsx)(un.Fill,{})})]})})}),(0,Z.jsx)(G.Content,{children:(0,Z.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,Z.jsxs)(`div`,{children:[r,` `,u,` `,l]}),(0,Z.jsxs)(`div`,{children:[i,` `,d,` `,l]}),f.map(e=>(0,Z.jsx)(`div`,{children:e},e))]})})]})}function Cn({state:e,stateCopy:t,t:n}){let r=(0,Y.useRef)(null),i=ft(e),a=lt(e);return(0,Y.useLayoutEffect)(()=>{let e=r.current;if(!e)return;let t=B.context(()=>{let e=B.utils.toArray(`[data-runtime-seg]`),t=e.filter((e,t)=>tt>=i),r=B.matchMedia();r.add(`(prefers-reduced-motion: reduce)`,()=>{B.set(t,{scaleY:1,autoAlpha:1}),B.set(n,{scaleY:.32,autoAlpha:.45})}),r.add(`(prefers-reduced-motion: no-preference)`,()=>{B.set(e,{transformOrigin:`center bottom`}),B.to(n,{scaleY:.32,autoAlpha:.45,duration:Je.fast,ease:Ye.out,overwrite:!0}),B.to(t,{scaleY:1,autoAlpha:1,duration:Je.base,ease:Ye.out,stagger:{amount:.08,from:`start`},overwrite:!0})})},e);return()=>t.revert()},[i,e]),(0,Z.jsx)(`div`,{ref:r,className:`flex items-center`,children:(0,Z.jsx)(`div`,{className:`runtime-meter min-w-[80px] flex-1`,"data-quiet":a===`ok`?`true`:void 0,role:`meter`,"aria-label":n(`runtimeState`),"aria-valuemin":0,"aria-valuemax":12,"aria-valuenow":i,"aria-valuetext":t,children:Array.from({length:12},(e,t)=>(0,Z.jsx)(`span`,{"data-runtime-seg":!0,"data-on":t{if(T)return L.current&&window.clearTimeout(L.current),L.current=window.setTimeout(()=>P(T),3e3),()=>{L.current&&window.clearTimeout(L.current)}},[T]);let be=Tn(O,O===`dead`?j:A,u),xe=O===`hot`||O===`ready`?`success`:O===`cooling`?`warning`:O===`quota_exhausted`||O===`login`||O===`unavailable`||O===`dead`||O===`auth_failed`?`danger`:void 0,Se=e.last_error||e.lastError,Ce=e.last_error_kind||e.kind,we=tt(e.provider,e.region,u),Te=String(e.region||``).toLowerCase(),Ee=Te===`cn`?u(`regionCN`):Te===`global`?u(`regionGlobal`):``,De=e.remote_uid||e.id,Oe=De.length>12?De.slice(0,8):De,ke=e.last_checkin_status,Ae=ke===`success`?`checkinRecordSuccess`:ke===`already`?`checkinRecordAlready`:ke===`pending`?`checkinStatusPending`:ke===`unknown`?`checkinStatusUnknown`:ke===`skipped`?`checkinRecordSkipped`:ke===`error`?`checkinRecordFailed`:`lastCheckinNone`,je=ut(e,C),Me=e.checkin_time||e.checkin_auto_time||x,z=C&&C!==`Local`?C:`Asia/Shanghai`,Ne=e.last_checkin_synced_at?wn(e.last_checkin_synced_at,z):``;return(0,Y.useLayoutEffect)(()=>{let e=ce.current;if(!e)return;let t=_e.current;if(_e.current=O,!t||t===O)return;let n=B.context(()=>{let t=B.matchMedia();t.add(`(prefers-reduced-motion: reduce)`,()=>{B.set(e,{scale:1,autoAlpha:1})}),t.add(`(prefers-reduced-motion: no-preference)`,()=>{B.fromTo(e,{scale:.94,autoAlpha:.65},{scale:1,autoAlpha:1,duration:.2,ease:`power2.out`,overwrite:!0})})},e);return()=>n.revert()},[O]),(0,Y.useLayoutEffect)(()=>{let e=D.current;if(!e||!n)return;let t=B.context(()=>{let t=B.matchMedia();t.add(`(prefers-reduced-motion: reduce)`,()=>{B.set(e,{autoAlpha:1,y:0})}),t.add(`(prefers-reduced-motion: no-preference)`,()=>{B.fromTo(e,{autoAlpha:0,y:-6},{autoAlpha:1,y:0,duration:.2,ease:`power3.out`,overwrite:!0})})},e);return()=>t.revert()},[n]),(0,Z.jsxs)(ge,{"data-gsap-reveal":!0,"data-state":O,className:`account-card overflow-hidden p-0`,children:[(0,Z.jsxs)(ge.Header,{className:`flex-row items-start justify-between gap-2.5 px-4 pt-3.5 pb-2`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,Z.jsx)(`div`,{className:`flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-tertiary`,title:we,children:(0,Z.jsx)(et,{provider:e.provider,size:20})}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(ge.Title,{className:`truncate text-body leading-5`,children:e.name||e.id}),Ee?(0,Z.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-secondary px-1.5 py-px text-caption text-muted`,title:we,children:Ee}):null]}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1`,children:[(0,Z.jsx)(ge.Description,{className:`mono truncate text-caption leading-4 text-foreground/60`,title:`${e.id}${e.remote_uid?` · UID ${e.remote_uid}`:``}`,children:Oe}),(0,Z.jsx)(S,{isIconOnly:!0,size:`sm`,variant:`ghost`,className:`size-5 min-w-0 shrink-0 text-muted`,"aria-label":u(fe?`copied`:`copy`),onPress:()=>{f(De).then(e=>{e&&(pe(!0),window.setTimeout(()=>pe(!1),1100))})},children:(0,Z.jsx)(a,{copied:fe,size:12})})]})]})]}),(0,Z.jsxs)(`div`,{className:`flex max-w-[48%] shrink-0 flex-wrap justify-end gap-1.5`,children:[(0,Z.jsx)(`span`,{ref:ce,children:M.length&&O===`cooling`?(0,Z.jsxs)(G,{children:[(0,Z.jsx)(G.Trigger,{children:(0,Z.jsx)(`span`,{className:`inline-flex cursor-help`,children:(0,Z.jsx)(Be,{size:`sm`,variant:`soft`,color:xe,children:be})})}),(0,Z.jsx)(G.Content,{children:(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(`div`,{className:`font-medium`,children:u(`partialCooling`)}),M.map(([e,t])=>(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-4 text-caption`,children:[(0,Z.jsx)(`span`,{children:e}),(0,Z.jsx)(`span`,{className:`mono text-foreground/65`,children:st(t)})]},e))]})})]}):(0,Z.jsx)(Be,{size:`sm`,variant:`soft`,color:xe,children:be})}),M.length&&O!==`cooling`?(0,Z.jsxs)(G,{children:[(0,Z.jsx)(G.Trigger,{children:(0,Z.jsx)(`span`,{className:`inline-flex cursor-help`,children:(0,Z.jsx)(Be,{size:`sm`,variant:`soft`,color:`warning`,children:u(`partialCooling`)})})}),(0,Z.jsx)(G.Content,{children:(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(`div`,{className:`font-medium`,children:u(`partialCooling`)}),M.map(([e,t])=>(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-4 text-caption`,children:[(0,Z.jsx)(`span`,{children:e}),(0,Z.jsx)(`span`,{className:`mono text-foreground/65`,children:st(t)})]},e))]})})]}):null]})]}),(0,Z.jsxs)(ge.Content,{className:`gap-1.5 px-4 pb-3`,children:[(0,Z.jsx)(Cn,{state:O,stateCopy:be,t:u}),e.quota?(0,Z.jsx)(Sn,{quota:e.quota,t:u,label:u(`quota`),usedLabel:u(`quotaUsed`),remainingLabel:u(`quotaRemaining`),addOnLabel:u(`quotaAddOn`),resourcePackageLabel:u(`quotaResourcePackage`),exceededLabel:u(`quotaExceeded`),provider:e.provider}):(0,Z.jsx)(`span`,{className:`text-caption text-foreground/65`,children:u(O===`hot`||O===`ready`||O===`loading`||O===`starting`?`quotaLoading`:`quotaUnavailable`)}),Se?(0,Z.jsxs)(G,{children:[(0,Z.jsx)(G.Trigger,{children:(0,Z.jsxs)(`div`,{className:`flex w-full cursor-help gap-2 rounded-lg bg-surface-secondary p-2 text-left text-caption leading-5 text-foreground`,children:[(0,Z.jsx)(Ve,{size:14,className:`mt-0.5 shrink-0 text-danger`}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[Ce?(0,Z.jsx)(`div`,{className:`mono mb-0.5 truncate text-caption opacity-75`,children:Ce}):null,(0,Z.jsx)(`p`,{className:`break-words line-clamp-3`,children:Se})]})]})}),(0,Z.jsx)(G.Content,{children:(0,Z.jsxs)(`div`,{className:`max-w-md whitespace-pre-wrap break-words`,children:[Ce?(0,Z.jsx)(`div`,{className:`mono mb-1 text-caption opacity-75`,children:Ce}):null,Se]})})]}):null,R?(0,Z.jsxs)(`div`,{className:`flex w-full items-start gap-2 rounded-lg bg-surface-secondary p-2 text-caption leading-5`,children:[R.kind===`success`?(0,Z.jsx)(U,{size:14,weight:`fill`,className:`mt-0.5 shrink-0 text-success`}):R.kind===`error`?(0,Z.jsx)(Rt,{size:14,weight:`fill`,className:`mt-0.5 shrink-0 text-danger`}):(0,Z.jsx)(Ve,{size:14,weight:`fill`,className:`mt-0.5 shrink-0 text-warning`}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[R.kind===`success`?(0,Z.jsx)(`span`,{className:`font-medium text-success`,children:u(`checkinRecordSuccess`)}):R.kind===`already`?(0,Z.jsx)(`span`,{className:`font-medium text-warning`,children:u(`checkinRecordAlready`)}):R.kind===`skipped`?(0,Z.jsx)(`span`,{className:`font-medium text-warning`,children:u(`checkinRecordSkipped`)}):(0,Z.jsx)(`span`,{className:`font-medium text-danger`,children:u(`checkinRecordFailed`)}),R.message?(0,Z.jsxs)(`div`,{className:`mt-0.5`,children:[(0,Z.jsx)(`p`,{className:`break-words line-clamp-2 text-foreground/80`,children:R.message}),(0,Z.jsxs)(`div`,{className:`mt-1 flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-caption text-muted`,children:u(`checkinTruncated`)}),(0,Z.jsxs)(S,{size:`sm`,variant:`ghost`,className:`h-6 min-w-0 gap-1 px-1.5 text-caption`,onPress:()=>{f(R.message||``).then(e=>{!e||!R||(ve(R),window.setTimeout(()=>ve(null),1100))})},children:[(0,Z.jsx)(a,{copied:ye,size:13}),u(ye?`copied`:`checkinCopyError`)]})]})]}):null]})]}):null]}),n&&e.enabled?(0,Z.jsx)(`section`,{ref:D,className:`grid gap-3 bg-surface-secondary/55 px-3 py-3`,children:e.provider===`doubaowork`?(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-caption font-medium text-muted`,children:u(`doubaoCookieLabel`)}),(0,Z.jsx)(`p`,{className:`mt-1.5 text-caption leading-5 text-muted`,children:u(`doubaoCookieLead`)}),(0,Z.jsxs)(`div`,{className:`mt-2.5 flex flex-col gap-2 sm:flex-row`,children:[(0,Z.jsxs)(Pe,{className:`flex-1`,type:`password`,value:l,onChange:p,children:[(0,Z.jsx)(ue,{className:`sr-only`,children:u(`doubaoCookieLabel`)}),(0,Z.jsx)(k,{placeholder:u(`doubaoCookiePh`),"aria-label":u(`doubaoCookieLabel`)})]}),(0,Z.jsxs)(S,{size:`sm`,variant:`secondary`,isPending:t===`pat`,onPress:ee,children:[(0,Z.jsx)(Re,{size:14}),u(`doubaoSaveCookie`)]})]}),o?(0,Z.jsx)(`p`,{className:`mt-1 text-caption text-muted`,children:o}):null]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-caption font-medium text-muted`,children:u(`oauthDeviceFlow`)}),(0,Z.jsx)(`p`,{className:`mt-1.5 text-caption leading-5 text-muted`,children:e.provider===`codex`?u(`wizardCodexBrowserLead`):u(`qoderLoginHint`)}),(0,Z.jsx)(`div`,{className:`mt-2.5 flex flex-wrap gap-2`,children:e.provider===`codex`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(S,{size:`sm`,isPending:t===`device`,onPress:()=>m(`cli`),children:[(0,Z.jsx)(g,{size:14}),u(`startCodexCliLogin`)]}),(0,Z.jsxs)(S,{size:`sm`,variant:`secondary`,isPending:t===`device`,onPress:()=>m(`chatgpt`),children:[(0,Z.jsx)(g,{size:14}),u(`startCodexChatGPTLogin`)]})]}):e.provider===`kiro`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(S,{size:`sm`,isPending:t===`device`,onPress:()=>m(`builder_id`),children:[(0,Z.jsx)(g,{size:14}),u(`kiroLoginBuilder`)]}),(0,Z.jsxs)(S,{size:`sm`,variant:`secondary`,isPending:t===`device`,onPress:()=>m(`idc`),children:[(0,Z.jsx)(g,{size:14}),u(`kiroLoginIDC`)]}),(0,Z.jsxs)(S,{size:`sm`,variant:`secondary`,isPending:t===`device`,onPress:()=>m(`microsoft`),children:[(0,Z.jsx)(g,{size:14}),u(`kiroLoginMicrosoft`)]}),(0,Z.jsxs)(S,{size:`sm`,variant:`secondary`,isPending:t===`device`,onPress:()=>m(`sso`),children:[(0,Z.jsx)(g,{size:14}),u(`kiroLoginSSO`)]})]}):(0,Z.jsxs)(S,{size:`sm`,isPending:t===`device`,onPress:()=>m(),children:[(0,Z.jsx)(g,{size:14}),u(`startBrowserLogin`)]})}),(e.provider===`trae`||e.provider===`codex`||e.provider===`devin`||e.provider===`kiro`)&&v&&te?(0,Z.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[(0,Z.jsx)(`p`,{className:`text-caption leading-4 text-muted`,children:u(`wizardCallbackLead`)}),(0,Z.jsx)(s,{className:`h-24 w-full resize-none font-mono text-caption leading-5`,value:h||``,onChange:e=>te(e.target.value),placeholder:u(`wizardCallbackPh`),"aria-label":u(`wizardCallbackPh`)}),(0,Z.jsx)(S,{size:`sm`,variant:`secondary`,isPending:t===`callback`,onPress:v,children:u(`wizardSubmitCallback`)})]}):null]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-caption font-medium text-muted`,children:u(`patFallback`)}),(0,Z.jsxs)(`div`,{className:`mt-2.5 flex flex-col gap-2 sm:flex-row`,children:[(0,Z.jsxs)(Pe,{className:`flex-1`,type:`password`,value:l,onChange:p,children:[(0,Z.jsx)(ue,{className:`sr-only`,children:u(`pat`)}),(0,Z.jsx)(k,{placeholder:u(`pasteToken`),"aria-label":u(`pat`)})]}),(0,Z.jsxs)(S,{size:`sm`,variant:`secondary`,isPending:t===`pat`,onPress:ee,children:[(0,Z.jsx)(Re,{size:14}),u(`usePat`)]})]})]}),r||o?(0,Z.jsxs)(`div`,{className:`text-caption`,children:[r?(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`mb-1 text-caption font-medium text-muted`,children:u(`authUrl`)}),(0,Z.jsx)(`code`,{className:`mono block break-all text-foreground`,children:r}),(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:[(0,Z.jsxs)(S,{size:`sm`,variant:`secondary`,onPress:()=>window.open(r,`_blank`,`noopener,noreferrer`),children:[(0,Z.jsx)(c,{size:14}),u(`openAuthUrl`)]}),(0,Z.jsxs)(S,{size:`sm`,variant:`ghost`,onPress:()=>{f(r).then(e=>{e&&(de(!0),window.setTimeout(()=>de(!1),1100))})},children:[(0,Z.jsx)(a,{copied:le}),u(le?`copied`:`copy`)]})]})]}):null,o?(0,Z.jsx)(`p`,{className:`mt-1 text-muted`,children:o}):null]}):null]})}):null,w?(0,Z.jsxs)(`div`,{className:`mt-auto flex items-center justify-between gap-2 px-4 pb-2.5 text-caption text-muted`,children:[(0,Z.jsxs)(G,{children:[(0,Z.jsx)(G.Trigger,{children:(0,Z.jsxs)(`span`,{className:`flex min-w-0 cursor-help flex-wrap items-center gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`font-medium text-foreground/75`,children:u(`checkinStatus`)}),(0,Z.jsx)(`span`,{className:ke===`error`?`text-danger`:``,children:u(Ae)}),!je&&ke===`pending`?(0,Z.jsx)(`span`,{className:`whitespace-nowrap rounded-full bg-warning/15 px-1.5 py-px font-medium text-warning`,children:u(`checkinPending`)}):null]})}),(0,Z.jsxs)(G.Content,{children:[e.last_checkin_at?u(`checkinServerTime`,{time:wn(e.last_checkin_at,z)}):u(`lastCheckinNone`),e.last_checkin_msg?` · ${e.last_checkin_msg}`:``,Ne?` · ${u(`checkinUpstreamSynced`,{time:Ne})}`:``]})]}),(0,Z.jsxs)(G,{children:[(0,Z.jsx)(G.Trigger,{children:(0,Z.jsxs)(`span`,{className:`flex shrink-0 cursor-help items-center gap-1.5 whitespace-nowrap`,children:[(0,Z.jsx)(`span`,{children:u(`checkinDaily`)}),(0,Z.jsx)(`span`,{className:`mono text-caption text-foreground/55`,children:Me}),(0,Z.jsx)(I,{isSelected:!!e.auto_checkin,isDisabled:!!t,ariaLabel:u(`autoCheckin`),onChange:e=>ie?.(e)})]})}),(0,Z.jsxs)(G.Content,{children:[u(`checkinAutoScheduleHint`,{time:Me??``}),` · ${u(`checkinServerClock`,{timezone:z})}`]})]})]}):null,(0,Z.jsxs)(ge.Footer,{className:`flex flex-nowrap items-center gap-1 bg-surface-secondary px-2 py-2${w?``:` mt-auto`}`,children:[ne?(0,Z.jsxs)(G,{children:[(0,Z.jsx)(G.Trigger,{children:(0,Z.jsx)(S,{isIconOnly:!0,size:`sm`,variant:`ghost`,isPending:t===`refresh`,onPress:ne,"aria-label":u(`refreshAccount`),children:(0,Z.jsx)(Ue,{size:15})})}),(0,Z.jsx)(G.Content,{children:u(`refreshAccount`)})]}):null,(0,Z.jsxs)(G,{children:[(0,Z.jsx)(G.Trigger,{children:(0,Z.jsx)(S,{isIconOnly:!0,size:`sm`,variant:n?`secondary`:`ghost`,isDisabled:!e.enabled,onPress:oe,"aria-label":u(`authentication`),children:(0,Z.jsx)(Re,{size:15})})}),(0,Z.jsx)(G.Content,{children:u(`authentication`)})]}),(0,Z.jsxs)(G,{children:[(0,Z.jsx)(G.Trigger,{children:(0,Z.jsx)(S,{isIconOnly:!0,size:`sm`,variant:`ghost`,onPress:E,"aria-label":u(`editAccount`),children:(0,Z.jsx)(Mt,{size:15})})}),(0,Z.jsx)(G.Content,{children:u(`editAccount`)})]}),(0,Z.jsxs)(rn,{children:[(0,Z.jsx)(rn.Trigger,{children:(0,Z.jsxs)(S,{isIconOnly:!0,size:`sm`,variant:me?`secondary`:`ghost`,isPending:t===`checkin`,"aria-label":u(`more`),className:`relative`,children:[(0,Z.jsx)(Et,{size:16}),M.length?(0,Z.jsx)(`span`,{className:`absolute top-1 right-1 size-1.5 rounded-full bg-warning`,"aria-hidden":!0}):null]})}),(0,Z.jsx)(rn.Popover,{placement:`bottom start`,children:(0,Z.jsxs)(rn.Menu,{"aria-label":u(`more`),disabledKeys:!e.enabled||t?[`checkin`]:[],onAction:e=>{e===`models`&&se(),e===`cooldowns`&&he(e=>!e),e===`checkin`&&w?.(),e===`checkin-records`&&ae?.(),e===`export`&&y(),e===`delete`&&re()},children:[(0,Z.jsxs)(rn.Item,{id:`models`,textValue:u(`accountModels`),children:[(0,Z.jsx)(Fe,{size:15}),u(`accountModels`)]}),(0,Z.jsxs)(rn.Item,{id:`cooldowns`,textValue:u(`modelCooldowns`),children:[(0,Z.jsx)(Pt,{size:15,className:M.length?`text-warning`:void 0}),u(`modelCooldowns`),M.length?(0,Z.jsx)(`span`,{className:`mono ml-auto text-caption text-warning`,children:M.length}):null]}),w?(0,Z.jsxs)(rn.Item,{id:`checkin`,textValue:u(`checkinNow`),children:[(0,Z.jsx)(wt,{size:15}),u(`checkinNow`)]}):null,ae?(0,Z.jsxs)(rn.Item,{id:`checkin-records`,textValue:u(`checkinRecords`),children:[(0,Z.jsx)(i,{size:15}),u(`checkinRecords`)]}):null,e.auth_type===`none`?null:(0,Z.jsxs)(rn.Item,{id:`export`,textValue:u(`export`),children:[(0,Z.jsx)(d,{size:15}),u(`export`)]}),(0,Z.jsxs)(rn.Item,{id:`delete`,textValue:u(`delete`),className:`text-danger`,children:[(0,Z.jsx)(_,{size:15}),u(`delete`)]})]})})]}),(0,Z.jsx)(`div`,{className:`ml-auto flex shrink-0 flex-nowrap items-center whitespace-nowrap`,children:(0,Z.jsx)(I,{isSelected:!!e.enabled,isDisabled:t===`toggle`,ariaLabel:e.enabled?u(`disable`):u(`enable`),label:e.enabled?u(`enabledState`):u(`disabled`),onChange:b})})]}),me?(0,Z.jsxs)(`section`,{className:`border-t border-separator bg-surface-secondary/55 px-4 py-2.5`,children:[(0,Z.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-caption font-medium text-muted`,children:u(`modelCooldownsTitle`)}),(0,Z.jsx)(`span`,{className:`mono text-caption text-muted`,children:M.length})]}),M.length?(0,Z.jsx)(`div`,{className:`space-y-1`,children:M.map(([e,t])=>(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg bg-surface px-2 py-1.5 text-caption`,children:[(0,Z.jsx)(`span`,{className:`mono min-w-0 truncate`,title:e,children:e}),(0,Z.jsx)(`span`,{className:`mono shrink-0 text-warning`,children:st(t)})]},e))}):(0,Z.jsx)(`p`,{className:`text-caption text-muted`,children:u(`modelCooldownsEmpty`)})]}):null]})}function Dn(e,t){return e.status===`success`?{label:t(`checkinRecordSuccess`),color:`success`}:e.status===`already`?{label:t(`checkinRecordAlready`),color:`warning`}:e.status===`skipped`?{label:t(`checkinRecordSkipped`),color:`default`}:{label:t(`checkinRecordFailed`),color:`danger`}}function On(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}function kn({account:e,t,onClose:n}){let[r,i]=(0,Y.useState)([]),[a,o]=(0,Y.useState)(!!e?.id),[s,c]=(0,Y.useState)(``),l=e?.id||``,u=t(`checkinRecordsTitle`,{name:e?.name||e?.id||``});async function d(){if(l){o(!0),c(``);try{let e=await Se(l);i(e.data||[])}catch(e){i([]),c(e instanceof Error?e.message:String(e))}finally{o(!1)}}}return(0,Y.useEffect)(()=>{l&&d()},[l]),(0,Z.jsx)(j.Root,{isOpen:!!e,onOpenChange:e=>{e||n()},children:(0,Z.jsx)(j.Backdrop,{variant:`blur`,children:(0,Z.jsx)(j.Container,{size:`lg`,scroll:`inside`,children:(0,Z.jsxs)(j.Dialog,{children:[(0,Z.jsxs)(j.Header,{className:`items-start justify-between gap-4 px-5 pt-5`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(j.Heading,{className:`text-section font-semibold`,children:u}),(0,Z.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:t(`checkinRecordsHint`)})]}),(0,Z.jsx)(j.CloseTrigger,{"aria-label":t(`close`),className:`grid size-8 shrink-0 place-items-center rounded-lg text-muted transition-colors hover:bg-surface-secondary hover:text-foreground`,children:(0,Z.jsx)(Ie,{size:16})})]}),(0,Z.jsxs)(j.Body,{className:`px-5 pb-2`,children:[s?(0,Z.jsx)(`div`,{className:`mb-3`,children:(0,Z.jsx)(me,{title:s})}):null,a?(0,Z.jsxs)(`div`,{className:`space-y-2 py-1`,children:[(0,Z.jsx)(K,{className:`h-16 w-full`}),(0,Z.jsx)(K,{className:`h-16 w-full`}),(0,Z.jsx)(K,{className:`h-16 w-full`})]}):r.length?(0,Z.jsx)(`div`,{className:`divide-y divide-separator overflow-hidden rounded-lg bg-surface-secondary`,children:r.map(e=>{let n=Dn(e,t);return(0,Z.jsxs)(`div`,{className:`flex items-start gap-3 px-3 py-3`,children:[(0,Z.jsx)(`span`,{className:`status-dot mt-1.5 shrink-0`,"data-state":e.status===`error`?`warn`:`ok`}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(Be,{size:`sm`,variant:`soft`,color:n.color,children:n.label}),(0,Z.jsx)(`span`,{className:`mono text-caption text-muted`,children:On(e.created_at)})]}),(0,Z.jsx)(`p`,{className:`mt-1 break-words text-caption leading-5 text-foreground/75`,children:e.message||`—`})]})]},e.id)})}):(0,Z.jsx)(O,{className:`min-h-44 rounded-3xl bg-surface-secondary`,title:t(`checkinRecordsEmpty`),hint:t(`checkinRecordsHint`)})]}),(0,Z.jsxs)(j.Footer,{className:`justify-between px-5 pb-5`,children:[(0,Z.jsx)(`span`,{className:`mono text-caption text-muted`,children:t(`checkinRecordsCount`,{count:r.length})}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(S,{size:`sm`,variant:`ghost`,onPress:n,children:t(`close`)}),(0,Z.jsxs)(S,{size:`sm`,variant:`secondary`,isPending:a,onPress:()=>void d(),children:[(0,Z.jsx)(Ue,{size:14}),t(`refresh`)]})]})]})]})})})})}function An(e){let t=e.route_display_name||``;return t&&t!==(e.display_name||e.id)?t:``}function jn({account:e,t,onClose:n}){let[r,i]=(0,Y.useState)([]),[a,o]=(0,Y.useState)(!!e?.id),[s,c]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)(``),[d,f]=(0,Y.useState)(1),[p,m]=(0,Y.useState)(20),[h,te]=(0,Y.useState)(0),[g,_]=(0,Y.useState)(1),v=(0,Y.useRef)(0),y=e?.id||``,ne=t(`accountModelsTitle`,{name:e?.name||e?.id||``}),re=e?tt(e.provider,e.region,t):``;async function b(e=1,t=p,n=!1){if(!y)return;let r=++v.current;n?c(!0):o(!0),u(``);try{let a=await(n?z(y,void 0,{page:e,pageSize:t}):Oe(y,!1,void 0,{page:e,pageSize:t})),o=a.data||[],s=a.pagination,c=s?.total??o.length,l=s?.total_pages??Math.max(1,Math.ceil(c/t)),u=Math.min(Math.max(1,s?.page??e),l);if(r!==v.current)return;i(s?o:o.slice((u-1)*t,u*t)),te(c),_(l),f(u)}catch(e){if(r!==v.current)return;i([]),te(0),_(1),u(e instanceof Error?e.message:String(e))}finally{r===v.current&&(o(!1),c(!1))}}(0,Y.useEffect)(()=>{y&&(f(1),b(1,p))},[y]);let x=h===0?0:(d-1)*p+1,C=h===0?0:Math.min(h,x+r.length-1);return(0,Z.jsx)(j.Root,{isOpen:!!e,onOpenChange:e=>{e||n()},children:(0,Z.jsx)(j.Backdrop,{variant:`blur`,children:(0,Z.jsx)(j.Container,{size:`lg`,scroll:`inside`,children:(0,Z.jsxs)(j.Dialog,{children:[(0,Z.jsxs)(j.Header,{className:`items-start justify-between gap-4 px-5 pt-5`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(j.Heading,{className:`text-section font-semibold`,children:ne}),(0,Z.jsx)(`p`,{className:`mt-1 text-caption font-normal leading-5 text-muted`,children:t(`accountModelsHint`)}),e?(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-caption text-muted`,children:[(0,Z.jsx)(et,{provider:e.provider,size:14}),(0,Z.jsx)(`span`,{children:re}),(0,Z.jsx)(`span`,{className:`text-border`,children:`·`}),(0,Z.jsx)(`span`,{className:`mono`,children:e.id})]}):null]}),(0,Z.jsx)(j.CloseTrigger,{"aria-label":t(`close`),className:`grid size-8 shrink-0 place-items-center rounded-lg text-muted transition-colors hover:bg-surface-secondary hover:text-foreground`,children:(0,Z.jsx)(Ie,{size:16})})]}),(0,Z.jsxs)(j.Body,{className:`px-5 pb-2`,children:[l?(0,Z.jsx)(`div`,{className:`mb-3`,children:(0,Z.jsx)(me,{title:t(`accountModelsError`,{msg:l})})}):null,a||s?(0,Z.jsxs)(`div`,{className:`space-y-2 py-1`,children:[(0,Z.jsx)(K,{className:`h-14 w-full`}),(0,Z.jsx)(K,{className:`h-14 w-full`}),(0,Z.jsx)(K,{className:`h-14 w-full`})]}):r.length?(0,Z.jsx)(`ul`,{className:`divide-y divide-separator overflow-hidden rounded-lg bg-surface-secondary`,children:r.map(n=>{let r=n.provider||n.owned_by||e?.provider||`qoder`,i=An(n),a=Qe(n),o=$e(n);return(0,Z.jsxs)(`li`,{className:`flex items-start gap-3 px-3 py-2.5`,children:[(0,Z.jsx)(`span`,{className:`status-dot mt-1.5`,"data-state":n.stale?void 0:`ok`}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`truncate text-body font-medium`,children:n.display_name||n.id}),o?(0,Z.jsx)(Be,{size:`sm`,variant:`soft`,color:`success`,children:t(`modelFree`)}):null,a?(0,Z.jsx)(`span`,{className:`mono text-caption text-muted`,children:a}):null,n.stale?(0,Z.jsx)(Be,{size:`sm`,variant:`soft`,color:`warning`,children:t(`fallback`)}):null]}),(0,Z.jsx)(`div`,{className:`mono mt-0.5 truncate text-caption text-muted`,children:n.id}),i?(0,Z.jsx)(`div`,{className:`mt-0.5 text-caption text-muted`,children:t(`routedTo`,{model:i})}):null]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5 pt-0.5 text-caption text-muted`,children:[(0,Z.jsx)(et,{provider:r,size:12}),(0,Z.jsx)(`span`,{children:r})]})]},n.id)})}):(0,Z.jsx)(O,{className:`min-h-48 rounded-3xl bg-surface-secondary`,icon:(0,Z.jsx)(Fe,{size:22}),title:t(`accountModelsEmpty`),hint:t(`noModelsYet`)})]}),(0,Z.jsxs)(j.Footer,{className:`flex-col items-stretch gap-3 px-5 pb-5`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsx)(`span`,{className:`mono text-caption text-muted`,children:a?t(`refreshing`):t(`shownTotal`,{shown:h?`${x}–${C}`:0,total:h})}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(S,{size:`sm`,variant:`ghost`,onPress:n,children:t(`close`)}),(0,Z.jsxs)(S,{size:`sm`,variant:`secondary`,isPending:s,onPress:()=>void b(1,p,!0),children:[(0,Z.jsx)(Ue,{size:14}),t(s?`refreshing`:`refresh`)]})]})]}),h>0?(0,Z.jsx)(ee,{total:h,page:d,pageCount:g,pageSize:p,loading:a||s,pageSizeLabel:t(`logsPageSize`),pageLabel:t(`logsPage`,{page:d,pages:g}),prevLabel:t(`logsPrevPage`),nextLabel:t(`logsNextPage`),onPage:e=>void b(e,p),onPageSize:e=>{m(e),b(1,e)}}):null]})]})})})})}function Mn({account:e,busy:t,t:n,onClose:r,onSave:i}){let[a,o]=(0,Y.useState)(e?.name||``),[s,c]=(0,Y.useState)(e?.max_inflight??4),[l,u]=(0,Y.useState)(e?.priority??50),[d,f]=(0,Y.useState)(``),p=n(`editAccountTitle`,{name:e?.name||e?.id||``}),m=e?tt(e.provider,e.region,n):``;async function ee(e){e?.preventDefault();let t=a.trim();if(!t){f(n(`accountNameRequired`));return}if(!Number.isInteger(s)||s<1||s>32){f(n(`maxInflightInvalid`));return}if(!Number.isInteger(l)||l<1||l>100){f(n(`priorityInvalid`));return}f(``);try{await i({name:t,max_inflight:s,priority:l}),r()}catch(e){f(e instanceof Error?e.message:String(e))}}return(0,Z.jsx)(j.Root,{isOpen:!!e,onOpenChange:e=>{!e&&!t&&r()},children:(0,Z.jsx)(j.Backdrop,{variant:`blur`,children:(0,Z.jsx)(j.Container,{placement:`center`,size:`lg`,scroll:`inside`,children:(0,Z.jsxs)(j.Dialog,{className:`w-full sm:w-[42rem] sm:max-w-[calc(100vw-2rem)]`,children:[(0,Z.jsxs)(j.Header,{className:`items-start justify-between gap-4 px-6 pt-6`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(j.Heading,{className:`text-section font-semibold`,children:p}),(0,Z.jsx)(`p`,{className:`mt-1.5 text-body font-normal leading-6 text-muted`,children:n(`editAccountHint`)}),e?(0,Z.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(Be,{size:`sm`,variant:`soft`,children:(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(et,{provider:e.provider,size:14}),(0,Z.jsx)(`span`,{children:m})]})}),(0,Z.jsx)(`span`,{className:`mono text-caption text-muted`,children:e.id})]}):null]}),(0,Z.jsx)(j.CloseTrigger,{isDisabled:t,"aria-label":n(`close`),className:`grid size-9 shrink-0 place-items-center rounded-lg text-muted hover:bg-surface-secondary`,children:(0,Z.jsx)(Ie,{size:18})})]}),(0,Z.jsxs)(j.Body,{className:`px-6 pb-2 pt-1`,children:[d?(0,Z.jsxs)(pe,{status:`danger`,className:`mb-4`,children:[(0,Z.jsx)(pe.Indicator,{}),(0,Z.jsx)(pe.Content,{children:(0,Z.jsx)(pe.Title,{children:d})})]}):null,(0,Z.jsxs)(M,{className:`space-y-4`,onSubmit:e=>void ee(e),children:[(0,Z.jsx)(A,{label:n(`accountName`),children:(0,Z.jsx)(k,{value:a,onChange:e=>o(e.target.value),placeholder:n(`wizardNamePh`),"aria-label":n(`accountName`),disabled:t,autoFocus:!0})}),(0,Z.jsx)(A,{label:n(`maxInflight`),hint:n(`maxInflightHint`),children:(0,Z.jsx)(P,{value:s,onChange:e=>c(e??4),minValue:1,maxValue:32,isDisabled:t,isRequired:!0,children:(0,Z.jsxs)(P.Group,{children:[(0,Z.jsx)(P.DecrementButton,{}),(0,Z.jsx)(P.Input,{"aria-label":n(`maxInflight`)}),(0,Z.jsx)(P.IncrementButton,{})]})})}),(0,Z.jsx)(A,{label:n(`priority`),hint:n(`priorityHint`),children:(0,Z.jsx)(P,{value:l,onChange:e=>u(e??50),minValue:1,maxValue:100,isDisabled:t,isRequired:!0,children:(0,Z.jsxs)(P.Group,{children:[(0,Z.jsx)(P.DecrementButton,{}),(0,Z.jsx)(P.Input,{"aria-label":n(`priority`)}),(0,Z.jsx)(P.IncrementButton,{})]})})})]})]}),(0,Z.jsxs)(j.Footer,{className:`justify-end gap-2 px-6 pb-6`,children:[(0,Z.jsx)(S,{variant:`ghost`,isDisabled:t,onPress:r,children:n(`cancel`)}),(0,Z.jsx)(S,{isPending:t,onPress:()=>void ee(),children:n(`save`)})]})]})})})})}var Nn={1:`grid-cols-1`,2:`grid-cols-1 sm:grid-cols-2`,3:`grid-cols-1 sm:grid-cols-3`};function Pn({options:e,value:t,onChange:n,ariaLabel:r,columns:i=2,className:a=``}){let o=(0,Y.useRef)(null);return(0,Y.useLayoutEffect)(()=>{let e=o.current;if(!e)return;let t=B.context(()=>{let e=B.matchMedia();e.add(`(prefers-reduced-motion: reduce)`,()=>{B.set(`[data-option-tile]`,{autoAlpha:1,y:0})}),e.add(`(prefers-reduced-motion: no-preference)`,()=>{B.fromTo(`[data-option-tile]`,{autoAlpha:0,y:8},{autoAlpha:1,y:0,duration:.32,stagger:.035,ease:`power3.out`,overwrite:!0})})},e);return()=>t.revert()},[e.length]),(0,Z.jsx)(`div`,{ref:o,role:`radiogroup`,"aria-label":r,className:`grid gap-3 ${Nn[i]} ${a}`.trim(),children:e.map(e=>{let r=e.value===t;return(0,Z.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":r,"data-option-tile":``,"data-selected":r||void 0,disabled:e.disabled,title:e.hint,onClick:()=>n(e.value),className:`flex h-16 min-w-0 items-center gap-3 rounded-xl bg-surface shadow-surface px-4 text-left transition-colors hover:bg-surface-secondary disabled:cursor-not-allowed disabled:opacity-50 data-selected:border-accent data-selected:bg-accent-soft`,children:[e.icon?(0,Z.jsx)(`span`,{className:`grid size-8 shrink-0 place-items-center rounded-lg bg-surface-secondary text-foreground [&_svg]:size-[18px]`,children:e.icon}):null,(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-body font-medium leading-5 text-foreground`,children:e.label})]},e.value)})})}var Fn=new Set([`qoder-global`,`qoder-cn`,`workbuddy-global`,`workbuddy-cn`,`trae-cn`]),In=[`qoder-global`,`qoder-cn`,`workbuddy-global`,`workbuddy-cn`,`trae-cn`];function Ln(e,t){let n=new Map(t.map((e,t)=>[e,t]));return[...e].sort((e,t)=>{let r=n.get(e.id)??2**53-1,i=n.get(t.id)??2**53-1;return r===i?e.label.localeCompare(t.label):r-i})}function Rn(e,t){return!t||`${e.label} ${e.subtitle||``} ${e.hint||``} ${e.provider} ${e.id}`.toLowerCase().includes(t)}function zn({ariaLabel:e}){return(0,Z.jsx)(`div`,{className:`space-y-8`,"aria-busy":`true`,"aria-label":e,children:Array.from({length:2},(e,t)=>(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(W,{className:`h-3 w-24 rounded-lg`}),(0,Z.jsx)(W,{className:`h-3 w-40 rounded-lg`})]}),(0,Z.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:Array.from({length:t===0?5:6},(e,t)=>(0,Z.jsxs)(`div`,{className:`card flex flex-row items-center gap-3.5 rounded-xl bg-surface px-4 py-3.5`,children:[(0,Z.jsx)(W,{className:`size-10 shrink-0 rounded-lg`}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1.5`,children:[(0,Z.jsx)(W,{className:`h-3.5 w-28 rounded-lg`}),(0,Z.jsx)(W,{className:`h-3 w-36 rounded-lg`})]})]},t))})]},t))})}function Bn({tile:e,disabled:t,onSelect:n}){return(0,Z.jsxs)(`button`,{type:`button`,disabled:t,title:e.hint||e.subtitle||e.label,onClick:()=>n(e.id),className:`card flex min-w-0 flex-row items-center gap-3 rounded-xl bg-surface px-3.5 py-3 text-left transition-[transform,opacity,background-color] duration-200 ease-out hover:bg-surface-secondary active:translate-y-px active:scale-[0.98] motion-reduce:transition-none motion-reduce:active:translate-y-0 motion-reduce:active:scale-100 disabled:cursor-not-allowed disabled:opacity-50 disabled:active:translate-y-0 disabled:active:scale-100`,children:[(0,Z.jsx)(`span`,{className:`grid size-9 shrink-0 place-items-center rounded-lg text-foreground [&_svg]:size-[18px]`,children:(0,Z.jsx)(et,{provider:e.provider,size:18})}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`span`,{className:`block truncate text-body font-medium leading-5 text-foreground`,children:e.label}),e.subtitle?(0,Z.jsx)(`span`,{className:`mt-0.5 block truncate text-caption leading-4 text-muted`,children:e.subtitle}):null]})]})}function Vn({title:e,subtitle:t,tiles:n,disabled:r,onSelect:i}){return n.length?(0,Z.jsxs)(`section`,{className:`space-y-3.5`,children:[(0,Z.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,Z.jsx)(`h3`,{className:`text-[10px] font-semibold tracking-[0.12em] uppercase text-muted`,children:e}),t?(0,Z.jsx)(`p`,{className:`text-caption leading-5 text-muted`,children:t}):null]}),(0,Z.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:n.map(e=>(0,Z.jsx)(Bn,{tile:e,disabled:r,onSelect:i},e.id))})]}):null}function Hn({options:e,onSelect:t,disabled:n,empty:r,ariaLabel:i}){let{t:a}=re(),[o,s]=(0,Y.useState)(``),c=o.trim().toLowerCase(),l=(0,Y.useMemo)(()=>{let t=Ln(e.filter(e=>Fn.has(e.id)),In),n=e.filter(e=>!Fn.has(e.id)).sort((e,t)=>e.label.localeCompare(t.label));return[{id:`subscriptions`,titleKey:`providerGroupSubscriptions`,subtitleKey:`providerGroupSubscriptionsHint`,tiles:t.filter(e=>Rn(e,c))},{id:`experimental`,titleKey:`providerGroupExperimental`,subtitleKey:`providerGroupExperimentalHint`,tiles:n.filter(e=>Rn(e,c))}]},[c,e]),u=l.reduce((e,t)=>e+t.tiles.length,0);return(0,Z.jsxs)(`div`,{className:`space-y-8`,role:`listbox`,"aria-label":i,children:[(0,Z.jsx)(h,{value:o,onChange:s,placeholder:a(`providerFindPlaceholder`),ariaLabel:a(`providerFindPlaceholder`),className:`max-w-sm`}),u===0?r||(0,Z.jsx)(`p`,{className:`rounded-lg bg-surface-secondary/45 px-3.5 py-3 text-caption leading-5 text-muted`,children:a(`providerFindEmpty`)}):l.map(e=>(0,Z.jsx)(Vn,{title:a(e.titleKey),subtitle:a(e.subtitleKey),tiles:e.tiles,disabled:n,onSelect:t},e.id))]})}var Un={"workbuddy-accounts":`workbuddy`,"workbuddy-oauth-v1":`workbuddy`,"qoder-native-v1":`qoder`,"trae-oauth-v1":`trae`,"devin-session-v1":`devin`,"command-key-v1":`command`,"codex-oauth-v1":`codex`,"zhipu-key-v1":`zhipu`,"qwenwork-oauth-v1":`qwenwork`,"meta-oauth-v1":`meta`,"meta-key-v1":`meta`,"kiro-oauth-v1":`kiro`,"doubaowork-cookie-v1":`doubaowork`},Wn=[`codebuddy.cn`,`workbuddy.cn`],Gn=[`workbuddy.ai`,`workbuddy.com`],Kn=new Set([`us-east-1`,`eu-central-1`]),qn=/arn:aws:codewhisperer:([a-z0-9-]+):/;function Q(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function $(e){return typeof e==`string`?e.trim():``}function Jn(e){let t=e.trim();if(!t)return``;let n=t.toLowerCase();return n===`workbuddy-accounts`?`workbuddy-accounts`:n}function Yn(e){return typeof e.format==`string`&&e.format.trim()?Jn(e.format):typeof e.exportType==`string`&&e.exportType.trim()?Jn(e.exportType):``}function Xn(e){let t=[],n=e=>{typeof e==`string`&&e.trim()&&t.push(e.trim().toLowerCase())};if(n(e.domain),Q(e.account)&&n(e.account.domain),Q(e.auth)&&n(e.auth.domain),Array.isArray(e.accounts))for(let t of e.accounts)Q(t)&&(n(t.domain),Q(t.account)&&n(t.account.domain),Q(t.auth)&&n(t.auth.domain));return t}function Zn(e){return Wn.some(t=>e.includes(t))}function Qn(e){return Gn.some(t=>e.includes(t))}function $n(e){return typeof e.accessToken==`string`||typeof e.access_token==`string`||typeof e.refreshToken==`string`||typeof e.refresh_token==`string`}function er(e){if(!Q(e))return!1;if($n(e)||typeof e.domain==`string`||typeof e.uid==`string`)return!0;if(Q(e.account)||Q(e.auth)){let t=Q(e.account)?e.account:null,n=Q(e.auth)?e.auth:null;if(n&&($n(n)||typeof n.domain==`string`)||t&&(typeof t.uid==`string`||typeof t.domain==`string`))return!0}return!1}function tr(e){let t=Xn(e);if(t.length===0)return{region:`cn`,ambiguous:!0,warning:`region_unknown`};let n=t.some(Zn),r=t.some(Qn);return n&&r?{region:null,ambiguous:!0,warning:`region_mixed`}:n?{region:`cn`,ambiguous:!1}:r?{region:`global`,ambiguous:!1}:{region:`cn`,ambiguous:!0,warning:`region_unknown`}}function nr(e){let t=$(e.region).toLowerCase();if(Kn.has(t))return t;if(t===`eu`||t===`europe`)return`eu-central-1`;let n=$(e.profileArn)||$(e.profile_arn),r=qn.exec(n);if(r&&Kn.has(r[1]))return r[1];for(let t of[`kiroApiKey`,`apiKey`,`api_key`,`accessToken`,`access_token`]){let n=$(e[t]),r=n.split(`|`);if(n.startsWith(`ksk_`)&&r.length===2&&Kn.has(r[1].trim().toLowerCase()))return r[1].trim().toLowerCase()}return null}function rr(e){if(Yn(e)===`kiro-oauth-v1`||nr(e))return!0;let t=($(e.authMethod)||$(e.auth_method)).toLowerCase();if([`builder_id`,`builderid`,`external_idp`,`idc`,`social`].includes(t))return!0;let n=$(e.provider).toLowerCase();if([`builderid`,`kiro`,`apikey`,`github`,`google`,`social`].includes(n))return!0;for(let t of[`kiroApiKey`,`apiKey`,`api_key`,`accessToken`,`access_token`])if($(e[t]).startsWith(`ksk_`))return!0;let r=$(e.clientId)||$(e.client_id),i=$(e.clientSecret)||$(e.client_secret),a=$(e.refreshToken)||$(e.refresh_token),o=$(e.startUrl)||$(e.start_url);if(r&&i&&a||o.includes(`awsapps.com`)&&a||($(e.profileArn)||$(e.profile_arn)).includes(`codewhisperer`)&&(a||$(e.accessToken)||$(e.access_token)))return!0;let s=$(e.tokenEndpoint)||$(e.token_endpoint),c=$(e.issuerUrl)||$(e.issuer_url);return!!((s.includes(`microsoftonline`)||c.includes(`microsoftonline`))&&a)}function ir(e){return Array.isArray(e.accounts)?e.accounts.filter(e=>Q(e)&&rr(e)):[]}function ar(e){return rr(e)||ir(e).length>0?{format:`kiro-oauth-v1`,provider:`kiro`,confidence:`medium`}:Array.isArray(e.accounts)&&e.accounts.some(er)?{format:`workbuddy-accounts`,provider:`workbuddy`,confidence:`medium`}:(typeof e.user_blob==`string`||typeof e.userBlob==`string`)&&(typeof e.machine_id==`string`||typeof e.machineId==`string`)?{format:`qoder-native-v1`,provider:`qoder`,confidence:`medium`}:typeof e.session_token==`string`||typeof e.sessionToken==`string`?{format:`devin-session-v1`,provider:`devin`,confidence:`low`}:$n(e)||Q(e.account)&&$n(e.account)||Q(e.auth)?{format:`workbuddy-oauth-v1`,provider:`workbuddy`,confidence:`low`}:typeof e.dca_token==`string`||typeof e.dcaToken==`string`||typeof e.access_token==`string`&&String(e.access_token).startsWith(`dca:`)||typeof e.accessToken==`string`&&String(e.accessToken).startsWith(`dca:`)?{format:`meta-oauth-v1`,provider:`meta`,confidence:`medium`}:typeof e.api_key==`string`||typeof e.apiKey==`string`?typeof e.organization==`string`||typeof e.project==`string`?{format:`zhipu-key-v1`,provider:`zhipu`,confidence:`low`}:typeof e.base_url==`string`&&String(e.base_url).includes(`meta.ai`)||typeof e.baseUrl==`string`&&String(e.baseUrl).includes(`meta.ai`)||typeof e.email==`string`?{format:`meta-key-v1`,provider:`meta`,confidence:`low`}:{format:`command-key-v1`,provider:`command`,confidence:`low`}:{format:null,provider:null,confidence:`low`}}function or(e){let t=ir(e),n=t.length>0?t:[e],r=new Set(n.map(nr).filter(e=>e!=null));return r.size===1?{region:[...r][0],ambiguous:!1}:(r.size,{region:null,ambiguous:!0})}function sr(e){if(!Q(e))return{format:null,provider:null,region:null,regionAmbiguous:!0,confidence:`low`,warnings:[`not_object`],batchImportSupported:!1};let t=[],n=Yn(e),r=typeof e.format==`string`?e.format.trim():``,i=typeof e.exportType==`string`?e.exportType.trim():``,a=r||i,o=n||null,s=o?Un[o]??null:null,c=o&&s?`high`:`low`;if(!s){let r=ar(e);o||=r.format,s=r.provider,c=n&&!Un[n]?`low`:r.confidence,a&&!Un[n]&&t.push(`unknown_format`)}s!==`kiro`&&(rr(e)||ir(e).length>0)&&(s=`kiro`,o=`kiro-oauth-v1`,c=n===`kiro-oauth-v1`?`high`:`medium`),s===`workbuddy`&&Array.isArray(e.accounts)&&(o=`workbuddy-accounts`);let l=null,u=!1;if(s===`workbuddy`){let n=tr(e);l=n.region,u=n.ambiguous,n.warning&&t.push(n.warning)}if(s===`kiro`){let n=or(e);l=n.region,u=n.ambiguous,u&&t.push(ir(e).length>1?`region_mixed`:`region_unknown`)}return{format:o,provider:s,region:l,regionAmbiguous:u,confidence:c,warnings:t,batchImportSupported:s===`workbuddy`||s===`kiro`}}function cr(e){let t;try{t=JSON.parse(e)}catch{throw Error(`bad_json`)}if(Array.isArray(t)){if(t.length===0||!t.every(Q))throw Error(`bad_json`);return{accounts:t}}if(!Q(t))throw Error(`bad_json`);return t}function lr(e,t){let n={...e},r=n.format===`workbuddy-accounts`||Array.isArray(n.accounts);return n.format?r&&(n.format=`workbuddy-accounts`):n.format=r?`workbuddy-accounts`:`workbuddy-oauth-v1`,{...n,name:t.name?.trim()||n.name,enabled:t.enabled??!0,provider:`workbuddy`,region:t.region,max_inflight:t.max_inflight??4,priority:t.priority??50,drop_system_prompt:t.drop_system_prompt??!0,...t.proxy_url!=null&&t.proxy_url!==``?{proxy_url:t.proxy_url}:{}}}function ur(e,t){let n=typeof e?.succeeded==`number`?e.succeeded:e?.id||e?1:0,r=typeof e?.failed==`number`?e.failed:0,i=(e?.errors||[]).slice(0,3).map(e=>e.message||`index ${e.index}`).filter(Boolean).join(`; `),a;return a=r>0?t(`accountImportPartial`).replace(`{ok}`,String(n)).replace(`{fail}`,String(r))+(i?` — ${i}`:``):n>1?t(`accountImportBatch`).replace(`{n}`,String(n)):t(`accountImported`),{succeeded:n,failed:r,message:a}}async function dr(e,t){let n=lr(e,t);return R(n)}var fr={global:`Global`,cn:`CN`},pr={"qoder-global":`accountTypeQoderGlobal`,"qoder-cn":`accountTypeQoderCN`,"workbuddy-cn":`accountTypeWorkBuddyCN`,"workbuddy-global":`accountTypeWorkBuddyGlobal`,"trae-cn":`accountTypeTraeCN`,"devin-global":`accountTypeDevinGlobal`,"command-global":`accountTypeCommandGlobal`,"codex-global":`accountTypeCodexGlobal`,"zhipu-cn":`accountTypeZhipuCN`,"qwenwork-global":`accountTypeQwenworkGlobal`,"qwenwork-cn":`accountTypeQwenworkCN`,"kimi-cn":`accountTypeKimiCN`,"codearts-cn-north-4":`accountTypeCodeArtsCN`,"doubaowork-cn":`accountTypeDoubaoworkCN`,"kiro-us-east-1":`accountTypeKiroUS`,"kiro-eu-central-1":`accountTypeKiroEU`,"meta-global":`accountTypeMetaGlobal`,"minimaxcode-cn":`accountTypeMiniMaxCodeCN`,"minimaxcode-global":`accountTypeMiniMaxCodeGlobal`},mr={"qoder-global":`accountTypeQoderGlobalHint`,"qoder-cn":`accountTypeQoderCNHint`,"workbuddy-cn":`accountTypeWorkBuddyCNHint`,"workbuddy-global":`accountTypeWorkBuddyGlobalHint`,"trae-cn":`accountTypeTraeCNHint`,"devin-global":`accountTypeDevinGlobalHint`,"command-global":`accountTypeCommandGlobalHint`,"codex-global":`accountTypeCodexGlobalHint`,"zhipu-cn":`accountTypeZhipuCNHint`,"qwenwork-global":`accountTypeQwenworkGlobalHint`,"qwenwork-cn":`accountTypeQwenworkCNHint`,"kimi-cn":`accountTypeKimiCNHint`,"codearts-cn-north-4":`accountTypeCodeArtsCNHint`,"doubaowork-cn":`accountTypeDoubaoworkCNHint`,"kiro-us-east-1":`accountTypeKiroUSHint`,"kiro-eu-central-1":`accountTypeKiroEUHint`,"meta-global":`accountTypeMetaGlobalHint`,"minimaxcode-cn":`accountTypeMiniMaxCodeCNHint`,"minimaxcode-global":`accountTypeMiniMaxCodeGlobalHint`};async function hr(){let e=(await we().catch(()=>null))?.data||[],t=[];for(let n of e)for(let e of n.regions)t.push({id:`${n.id}-${e.id}`,provider:n.id,region:e.id,descriptor:n});return t}function gr(e,t){let n=pr[e.id];if(n){let e=t(n);if(e!==n)return e}let r=e.descriptor.regions.find(t=>t.id===e.region)?.label||fr[e.region]||``,i=e.descriptor.regions.length>1&&r?` ${r}`:``;return`${e.descriptor.label}${i}`.trim()}function _r(e,t){if(!e)return``;let n=mr[e.id];if(!n)return``;let r=t(n);return r===n?``:r}function vr({phase:e,busy:t,tab:n,forTab:r}){return e===`done`?(0,Z.jsx)(U,{size:16,className:`text-success`}):t&&n===r?(0,Z.jsx)(Ge,{size:16,loading:!0}):null}var yr=90,br=2e3;function xr({isOpen:e,onClose:t,onAdded:n}){let{t:i}=re(),[o,d]=(0,Y.useState)(`method`),[p,m]=(0,Y.useState)(`browser`),[ee,h]=(0,Y.useState)(``),[te,_]=(0,Y.useState)([]),[v,y]=(0,Y.useState)(!1),[ne,b]=(0,Y.useState)(!1),[x,C]=(0,Y.useState)(``),[ie,w]=(0,Y.useState)(4),[ae,T]=(0,Y.useState)(50),[E,oe]=(0,Y.useState)(``),[se,ce]=(0,Y.useState)(``),[D,le]=(0,Y.useState)(`payg`),[de,fe]=(0,Y.useState)(``),[pe,me]=(0,Y.useState)(``),[he,ge]=(0,Y.useState)(``),[O,M]=(0,Y.useState)(``),[N,F]=(0,Y.useState)(`idle`),[I,L]=(0,Y.useState)(``),[be,xe]=(0,Y.useState)(``),[Se,we]=(0,Y.useState)(!1),[Te,Ee]=(0,Y.useState)(``),[Oe,ke]=(0,Y.useState)(`cli`),[Ae,je]=(0,Y.useState)(`builder_id`),[Me,z]=(0,Y.useState)(``),Pe=(0,Y.useRef)(null),Fe=(0,Y.useRef)(null),Le=(0,Y.useRef)(null),V=(0,Y.useRef)(``),ze=(0,Y.useRef)(null),Be=(0,Y.useRef)(null);function Ve(){ze.current!==null&&(window.clearTimeout(ze.current),ze.current=null)}(0,Y.useEffect)(()=>()=>Ve(),[]),(0,Y.useEffect)(()=>{if(!e)return;let t=!1;return y(!0),_([]),h(``),hr().then(e=>{t||(_(e),h(``),m(`browser`))}).finally(()=>{t||y(!1)}),()=>{t=!0}},[e]);let H=te.find(e=>e.id===ee),He=!v&&te.length>0,Ue=H?.descriptor.capabilities?.pat_login!==!1,We=H?.descriptor.capabilities?.import_export!==!1,Ge=H?.descriptor.capabilities?.browser_login!==!1,Ke=H?.provider===`trae`||H?.provider===`devin`||H?.provider===`codex`||H?.provider===`codearts`,W=N===`busy`||N===`polling`,G=!!V.current||W,K=N===`done`,qe=_r(H,i);(0,Y.useEffect)(()=>{p===`pat`&&!Ue&&m(`browser`),p===`import`&&!We&&m(`browser`)},[We,Ue,p]),(0,Y.useEffect)(()=>{Ge||(Ue?m(`pat`):We&&m(`import`))},[Ge,We,Ue]);function q(){return!Number.isInteger(ie)||ie<1||ie>32?4:ie}function Xe(){return!Number.isInteger(ae)||ae<1||ae>100?50:ae}function Qe(){return{max_inflight:q(),priority:Xe()}}function $e(){Ve(),d(`method`),m(`browser`),h(``),_([]),y(!1),C(``),w(4),T(50),oe(``),ce(``),le(`payg`),fe(``),me(``),ge(``),M(``),b(!1),F(`idle`),L(``),xe(``),we(!1),Ee(``),ke(`cli`),V.current=``}function tt(){W||($e(),t())}function nt(){$e(),t()}(0,Y.useLayoutEffect)(()=>{let t=Pe.current;if(e||(Le.current=null),!t||!e)return;let n=B.context(()=>{let e=B.matchMedia();e.add(`(prefers-reduced-motion: reduce)`,()=>{B.set(t,{autoAlpha:1,x:0,y:0})}),e.add(`(prefers-reduced-motion: no-preference)`,()=>{let e=Le.current,n=e&&e!==o?o===`login`?1:-1:0;B.fromTo(t,{autoAlpha:0,x:20*n,y:n?0:12},{autoAlpha:1,x:0,y:0,duration:Je.slow,ease:Ye.out,overwrite:!0}),n&&Fe.current&&B.fromTo(Fe.current,{autoAlpha:0,y:6},{autoAlpha:1,y:0,duration:Je.base,ease:Ye.out,overwrite:!0})})},t);return Le.current=o,()=>n.revert()},[e,o]);function rt(e){if(W||!He)return;let t=te.find(t=>t.id===e);h(e),m(t?.provider===`zhipu`||t?.provider===`doubaowork`?`pat`:`browser`),L(``),d(`login`)}async function it(){if(V.current)return V.current;if(!H)throw Error(i(`accountTypeHint`));let e=Qe(),t=await De(x.trim()||i(`account`),H.provider,H.region,e),n=t?.id||t?.data?.id;if(!n)throw Error(`create account returned no id`);return V.current=n,n}async function at(){L(``),xe(``);try{F(`busy`);let e=await it();L(i(`wizardStartingSession`)),F(`polling`);let t=H?.provider===`codex`?Oe:H?.provider===`kiro`?Ae:void 0,r=await ve(e,t,Ae===`idc`?Me.trim():void 0);r.authUrl&&xe(r.authUrl),L(i(`wizardWaitingBrowser`));for(let t=0;t{ze.current=window.setTimeout(e,br)});let n=(await Ce(e)).login||{};if(n.message&&L(n.message),n.status===`ok`)break;if(n.status===`error`)throw Error(n.message||`login failed`);if(t===89)throw Error(i(`wizardLoginTimeout`))}F(`done`),L(i(`wizardAccountReady`)),n(),window.setTimeout(nt,900)}catch(e){F(`idle`),L(e instanceof Error?e.message:String(e))}}async function ot(){let e=Te.trim();if(!e){L(i(`wizardCallbackPh`));return}try{F(`busy`);let t=await it();Ve(),await ye(t,e),F(`done`),L(i(`wizardAccountReady`)),n(),window.setTimeout(nt,900)}catch(e){F(`polling`),L(e instanceof Error?e.message:String(e))}}async function st(){let e=de.trim();if(!e){L(i(`zhipuKeyRequired`));return}if(!H){L(i(`accountTypeHint`));return}L(``);try{F(`busy`);let t=Qe();await R({format:`zhipu-key-v1`,api_key:e,mode:D,organization:D===`coding`?pe.trim():``,project:D===`coding`?he.trim():``,name:x.trim()||i(`accountTypeZhipuCN`),enabled:!0,provider:H.provider,region:H.region,max_inflight:t.max_inflight,priority:t.priority}),F(`done`),L(i(`wizardAccountReady`)),n(),window.setTimeout(nt,700)}catch(e){F(`idle`),L(e instanceof Error?e.message:String(e))}}async function ct(){let e=E.trim();if(!e){L(i(`pastePatFirst`));return}L(``);try{F(`busy`);let t=await it();L(i(`wizardStartingSession`)),await Ne(e,t),F(`done`),L(i(`patDone`)),n(),window.setTimeout(nt,700)}catch(e){F(`idle`),L(e instanceof Error?e.message:String(e))}}async function lt(){let e=O.trim();if(!e){L(i(`doubaoCookieRequired`));return}if(!H){L(i(`accountTypeHint`));return}L(``);try{F(`busy`);let t=Qe();await R({format:`doubaowork-cookie-v1`,cookie:e,name:x.trim()||i(`accountTypeDoubaoworkCN`),enabled:!0,provider:H.provider,region:H.region,max_inflight:t.max_inflight,priority:t.priority}),F(`done`),L(i(`wizardAccountReady`)),n(),window.setTimeout(nt,900)}catch(e){F(`idle`),L(e instanceof Error?e.message:String(e))}}async function ut(){L(``);let e;try{e=JSON.parse(se)}catch{L(i(`wizardBadJson`));return}if(Array.isArray(e)){if(!e.every(e=>e&&typeof e==`object`&&!Array.isArray(e))){L(i(`wizardBadJson`));return}e={accounts:e}}if(!e||typeof e!=`object`){L(i(`wizardBadJson`));return}if(!H){L(i(`accountTypeHint`));return}let t=sr(e),r=t.provider||H.provider;if(r===`qoder`&&(typeof e.user_blob!=`string`||typeof e.machine_id!=`string`)){L(i(`wizardBadJson`));return}let a=Qe(),o;if(r===`kiro`){let t=typeof e.email==`string`?e.email.trim():``,n=typeof e.nickname==`string`?e.nickname.trim():``,r=nr(e),{provider:i,accounts:s,...c}=e,l=Array.isArray(s)?s:[{...c,...i?{provider:i}:{}}];o={format:`kiro-oauth-v1`,provider:`kiro`,region:r||(H.provider===`kiro`?H.region:`us-east-1`),name:x.trim()||n||t||void 0,enabled:!0,accounts:l,max_inflight:a.max_inflight,priority:a.priority}}else if(r===`workbuddy`)o=lr(e,{region:H.region===`global`?`global`:`cn`,name:x.trim()||void 0,enabled:!0,max_inflight:a.max_inflight,priority:a.priority});else{if(!e.format){let t=r;t===`trae`?e.format=`trae-oauth-v1`:t===`devin`?e.format=`devin-session-v1`:t===`command`?e.format=`command-key-v1`:t===`qwenwork`?e.format=`qwenwork-oauth-v1`:t===`kimi`?e.format=`kimi-oauth-v1`:t===`codearts`?e.format=`codearts-oauth-v1`:t===`codex`?e.format=`codex-oauth-v1`:t===`meta`?e.format=`meta-oauth-v1`:e.format=`qoder-native-v1`}o={...e,name:x.trim()||e.name,enabled:!0,provider:r,region:t.region||H.region,max_inflight:a.max_inflight,priority:a.priority}}try{F(`busy`);let{failed:e,message:t}=ur(await R(o),i);F(`done`),L(t),n(),window.setTimeout(nt,e>0?1600:700)}catch(e){F(`idle`),L(e instanceof Error?e.message:String(e))}}function dt(){Be.current?.click()}function ft(e){let t=e.target.files?.[0];if(!t)return;let n=new FileReader;n.onload=()=>ce(String(n.result||``)),n.readAsText(t),e.target.value=``}let pt=e=>W&&p===e,mt=H?.provider===`zhipu`,ht=H?.provider===`doubaowork`,J=[H?.descriptor.capabilities?.browser_login===!1?null:{value:`browser`,label:i(`tabBrowser`)},Ue?{value:`pat`,label:i(`tabPat`)}:null,We?{value:`import`,label:i(`tabImport`)}:null].filter(Boolean),gt=i(p===`browser`?H?.provider===`codex`?`wizardCodexBrowserLead`:`wizardBrowserLead`:p===`pat`?H?.provider===`command`?`wizardPatLeadCommand`:H?.region===`cn`&&H?.provider===`qoder`?`wizardPatLeadCN`:`wizardPatLead`:`wizardImportLead`);return(0,Z.jsx)(j.Root,{isOpen:e,onOpenChange:e=>{e||tt()},children:(0,Z.jsx)(j.Backdrop,{variant:`blur`,isDismissable:!W,children:(0,Z.jsx)(j.Container,{size:`lg`,scroll:`inside`,children:(0,Z.jsxs)(j.Dialog,{className:`w-full sm:w-[36rem] sm:max-w-[calc(100vw-2rem)] sm:min-h-[36rem]`,children:[(0,Z.jsxs)(j.Header,{className:`relative items-center justify-center px-12 pt-5 text-center`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(j.Heading,{className:`text-section font-semibold`,children:i(`addAccountTitle`)}),(0,Z.jsx)(`p`,{ref:Fe,className:`mt-1 text-caption font-normal leading-5 text-muted`,children:o===`method`?i(`addAccountDesc`):qe||i(`addAccountDesc`)})]}),(0,Z.jsx)(j.CloseTrigger,{"aria-label":i(`close`),className:`absolute right-4 top-4 grid size-8 shrink-0 place-items-center rounded-lg text-muted transition-colors hover:bg-surface-secondary hover:text-foreground`,children:(0,Z.jsx)(Ie,{size:16})})]}),(0,Z.jsx)(j.Body,{className:o===`method`?`px-8 pb-5 sm:px-10`:`px-6 pb-2`,children:(0,Z.jsx)(`div`,{ref:Pe,children:o===`method`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`section`,{className:`space-y-2.5`,children:v?(0,Z.jsx)(zn,{ariaLabel:i(`accountType`)}):He?(0,Z.jsx)(Hn,{ariaLabel:i(`accountType`),options:te.map(e=>{let t=e.descriptor.regions.find(t=>t.id===e.region)?.label||fr[e.region]||``;return{id:e.id,provider:e.provider,label:gr(e,i),subtitle:t,hint:_r(e,i)}}),onSelect:rt,disabled:G}):(0,Z.jsx)(`p`,{className:`rounded-lg bg-surface-secondary/45 px-3.5 py-3 text-caption leading-5 text-muted`,children:i(`accountTypeHint`)})}),(0,Z.jsx)(`div`,{className:`mt-4 text-center`,children:(0,Z.jsx)(l,{className:`text-xs`})})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`card flex flex-row items-center gap-3 rounded-xl bg-surface px-3 py-2.5`,children:[(0,Z.jsx)(`span`,{className:`shrink-0`,children:(0,Z.jsx)(et,{provider:H?.provider,size:18})}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`div`,{className:`truncate text-body font-medium text-foreground`,children:H?gr(H,i):i(`accountType`)}),(0,Z.jsx)(`div`,{className:`truncate text-caption text-muted`,children:qe})]}),(0,Z.jsxs)(S,{size:`sm`,variant:`ghost`,onPress:()=>d(`method`),isDisabled:W||!!V.current,children:[(0,Z.jsx)(r,{size:12}),i(`wizardBack`)]})]}),(0,Z.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(ue,{className:`text-body font-medium text-muted`,children:i(`accountName`)}),(0,Z.jsx)(k,{fullWidth:!0,value:x,onChange:e=>C(e.target.value),"aria-label":i(`accountName`),disabled:G,autoFocus:!0})]}),(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>b(e=>!e),"aria-expanded":ne,className:`inline-flex items-center gap-1 text-caption font-medium text-muted transition-colors hover:text-foreground`,children:[(0,Z.jsx)(u,{size:12,className:`transition-transform duration-200 ${ne?`rotate-90`:``}`}),i(`wizardAdvanced`)]}),ne?(0,Z.jsx)(`div`,{className:`card gap-3 rounded-xl bg-surface px-3.5 py-3.5`,children:(0,Z.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(ue,{className:`text-body font-medium text-muted`,children:i(`maxInflight`)}),(0,Z.jsx)(P,{value:ie,onChange:e=>w(e??4),minValue:1,maxValue:32,isDisabled:G,isRequired:!0,children:(0,Z.jsxs)(P.Group,{className:`w-full`,children:[(0,Z.jsx)(P.DecrementButton,{}),(0,Z.jsx)(P.Input,{"aria-label":i(`maxInflight`)}),(0,Z.jsx)(P.IncrementButton,{})]})}),(0,Z.jsx)(_e,{className:`text-caption leading-5 text-muted`,children:i(`maxInflightHint`)})]}),(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(ue,{className:`text-body font-medium text-muted`,children:i(`priority`)}),(0,Z.jsx)(P,{value:ae,onChange:e=>T(e??50),minValue:1,maxValue:100,isDisabled:G,isRequired:!0,children:(0,Z.jsxs)(P.Group,{className:`w-full`,children:[(0,Z.jsx)(P.DecrementButton,{}),(0,Z.jsx)(P.Input,{"aria-label":i(`priority`)}),(0,Z.jsx)(P.IncrementButton,{})]})}),(0,Z.jsx)(_e,{className:`text-caption leading-5 text-muted`,children:i(`priorityHint`)})]})]})}):null]}),mt?(0,Z.jsxs)(`div`,{className:`mt-4 flex flex-col gap-4`,children:[(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`span`,{className:`text-body font-medium text-muted`,children:i(`zhipuAccountMode`)}),(0,Z.jsx)(Pn,{ariaLabel:i(`zhipuAccountMode`),columns:2,value:D,onChange:e=>{W||le(e)},options:[{value:`payg`,label:i(`zhipuModePayg`),hint:i(`zhipuModePaygHint`),disabled:W},{value:`coding`,label:i(`zhipuModeCoding`),hint:i(`zhipuModeCodingHint`),disabled:W}]})]}),(0,Z.jsx)(A,{label:i(`zhipuApiKey`),children:(0,Z.jsx)(k,{type:`password`,value:de,onChange:e=>fe(e.target.value),placeholder:i(`zhipuApiKeyPh`),"aria-label":i(`zhipuApiKey`),disabled:W})}),D===`coding`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(A,{label:i(`zhipuOrganization`),children:(0,Z.jsx)(k,{value:pe,onChange:e=>me(e.target.value),placeholder:i(`zhipuOrganizationPh`),"aria-label":i(`zhipuOrganization`),disabled:W})}),(0,Z.jsx)(A,{label:i(`zhipuProject`),children:(0,Z.jsx)(k,{value:he,onChange:e=>ge(e.target.value),placeholder:i(`zhipuProjectPh`),"aria-label":i(`zhipuProject`),disabled:W})})]}):null,I?(0,Z.jsxs)(`p`,{className:`flex items-center gap-2 rounded-lg bg-surface-secondary px-3 py-2 text-caption`,children:[K?(0,Z.jsx)(U,{size:14,className:`shrink-0 text-success`}):null,(0,Z.jsx)(`span`,{className:K?`font-medium text-foreground`:`text-muted`,children:I})]}):null]}):null,ht?(0,Z.jsxs)(`div`,{className:`mt-4 flex flex-col gap-4`,children:[(0,Z.jsx)(`p`,{className:`rounded-lg bg-surface-secondary/45 px-3.5 py-3 text-caption leading-5 text-muted`,children:i(`doubaoCookieLead`)}),(0,Z.jsx)(A,{label:i(`doubaoCookieLabel`),children:(0,Z.jsx)(s,{className:`min-h-28 font-mono text-caption leading-5`,value:O,onChange:e=>M(e.target.value),placeholder:i(`doubaoCookiePh`),"aria-label":i(`doubaoCookieLabel`),disabled:W})}),I?(0,Z.jsxs)(`p`,{className:`flex items-center gap-2 rounded-lg bg-surface-secondary px-3 py-2 text-caption`,children:[K?(0,Z.jsx)(U,{size:14,className:`shrink-0 text-success`}):null,(0,Z.jsx)(`span`,{className:K?`font-medium text-foreground`:`text-muted`,children:I})]}):null]}):null,mt||ht?null:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Ze,{className:`mt-3`,value:p,onChange:e=>{!W&&e!==p&&(m(e),L(``),xe(``),we(!1))},ariaLabel:i(`authentication`),options:J.map(e=>({id:e.value,label:e.label}))}),(0,Z.jsx)(`p`,{className:`mt-2 min-h-5 text-caption leading-5 text-muted`,children:gt}),(0,Z.jsx)(`div`,{className:`mt-3 flex flex-col gap-4`,children:p===`browser`?(0,Z.jsxs)(Z.Fragment,{children:[H?.provider===`codex`?(0,Z.jsx)(Pn,{ariaLabel:i(`codexLoginMethod`),columns:2,value:Oe,onChange:e=>{W||ke(e)},options:[{value:`cli`,label:i(`codexLoginCli`),hint:i(`codexLoginCliHint`),disabled:W||!!V.current},{value:`chatgpt`,label:i(`codexLoginChatGPT`),hint:i(`codexLoginChatGPTHint`),disabled:W||!!V.current}]}):null,H?.provider===`kiro`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Pn,{ariaLabel:i(`kiroLoginMethod`),columns:2,value:Ae,onChange:e=>{W||je(e)},options:[{value:`builder_id`,label:i(`kiroLoginBuilder`),hint:i(`kiroLoginBuilderHint`),disabled:W||!!V.current},{value:`idc`,label:i(`kiroLoginIDC`),hint:i(`kiroLoginIDCHint`),disabled:W||!!V.current},{value:`sso`,label:i(`kiroLoginSSO`),hint:i(`kiroLoginSSOHint`),disabled:W||!!V.current},{value:`microsoft`,label:i(`kiroLoginMicrosoft`),hint:i(`kiroLoginMicrosoftHint`),disabled:W||!!V.current}]}),Ae===`idc`?(0,Z.jsx)(A,{label:i(`kiroIDCStartURL`),children:(0,Z.jsx)(k,{value:Me,onChange:e=>z(e.target.value),placeholder:i(`kiroIDCStartURLPh`),"aria-label":i(`kiroIDCStartURL`),disabled:W})}):null]}):null,be?(0,Z.jsxs)(`div`,{className:`card rounded-xl bg-surface px-3 py-2.5`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-caption`,children:[(0,Z.jsx)(vr,{phase:N,busy:W,tab:p,forTab:`browser`}),(0,Z.jsx)(`span`,{className:`text-muted`,children:I||i(`loginOpenMsg`)})]}),(0,Z.jsx)(`code`,{className:`mono mt-2 block break-all text-caption leading-5 text-foreground`,children:be}),(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:[(0,Z.jsxs)(S,{size:`sm`,variant:`secondary`,onPress:()=>window.open(be,`_blank`,`noopener,noreferrer`),children:[(0,Z.jsx)(c,{size:14}),i(`openAuthUrl`)]}),(0,Z.jsxs)(S,{size:`sm`,variant:`ghost`,onPress:()=>{f(be).then(e=>{e&&(we(!0),window.setTimeout(()=>we(!1),1100))})},children:[(0,Z.jsx)(a,{copied:Se}),i(Se?`copied`:`copy`)]})]})]}):null,I&&!be?(0,Z.jsxs)(`p`,{className:`flex items-center gap-2 rounded-lg bg-surface-secondary px-3 py-2 text-caption`,children:[K?(0,Z.jsx)(U,{size:14,className:`shrink-0 text-success`}):null,(0,Z.jsx)(`span`,{className:K?`font-medium text-foreground`:`text-muted`,children:I})]}):null,Ke?(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`p`,{className:`text-caption leading-4 text-muted`,children:i(`wizardCallbackLead`)}),(0,Z.jsx)(s,{className:`h-28 w-full resize-none font-mono text-caption leading-5`,value:Te,onChange:e=>Ee(e.target.value),placeholder:i(`wizardCallbackPh`),"aria-label":i(`wizardCallbackPh`),disabled:K}),(0,Z.jsx)(S,{size:`sm`,variant:`secondary`,isPending:N===`busy`&&!!Te.trim(),onPress:()=>void ot(),isDisabled:K,children:i(`wizardSubmitCallback`)})]}):null]}):p===`pat`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(A,{label:i(`tabPat`),children:(0,Z.jsx)(k,{type:`password`,value:E,onChange:e=>oe(e.target.value),placeholder:i(`wizardPatPh`),"aria-label":i(`wizardPatPh`),disabled:W})}),I?(0,Z.jsxs)(`p`,{className:`flex items-center gap-2 rounded-lg bg-surface-secondary px-3 py-2 text-caption`,children:[K?(0,Z.jsx)(U,{size:14,className:`shrink-0 text-success`}):null,(0,Z.jsx)(`span`,{className:K?`font-medium text-foreground`:`text-muted`,children:I})]}):null]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsx)(`span`,{className:`text-caption font-medium text-muted`,children:`JSON`}),(0,Z.jsxs)(S,{size:`sm`,variant:`secondary`,onPress:dt,isDisabled:W,children:[(0,Z.jsx)(At,{size:13}),i(`wizardChooseFile`)]}),(0,Z.jsx)(`input`,{ref:Be,type:`file`,accept:`application/json,.json`,className:`hidden`,onChange:ft})]}),(0,Z.jsx)(s,{className:`min-h-32 font-mono text-caption`,value:se,onChange:e=>ce(e.target.value),placeholder:i(`wizardImportPh`),"aria-label":i(`tabImport`),disabled:W}),I?(0,Z.jsxs)(`p`,{className:`flex items-center gap-2 rounded-lg bg-surface-secondary px-3 py-2 text-caption`,children:[K?(0,Z.jsx)(U,{size:14,className:`shrink-0 text-success`}):null,(0,Z.jsx)(`span`,{className:K?`font-medium text-foreground`:`text-muted`,children:I})]}):null]})})]})]})})}),(0,Z.jsxs)(j.Footer,{className:`justify-end gap-2 px-5 pb-5`,children:[(0,Z.jsx)(S,{variant:`ghost`,onPress:tt,isDisabled:W,children:i(`cancel`)}),o===`login`&&mt?(0,Z.jsx)(S,{isPending:N===`busy`,onPress:()=>void st(),isDisabled:K,children:K?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(U,{size:15}),i(`wizardAccountReady`)]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Re,{size:15}),i(`zhipuCreate`)]})}):null,o===`login`&&ht?(0,Z.jsx)(S,{isPending:N===`busy`,onPress:()=>void lt(),isDisabled:K,children:K?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(U,{size:15}),i(`wizardAccountReady`)]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Re,{size:15}),i(`doubaoImport`)]})}):null,o===`login`&&!mt&&!ht&&p===`browser`?(0,Z.jsx)(S,{isPending:pt(`browser`),onPress:()=>void at(),isDisabled:K,children:K?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(U,{size:15}),i(`wizardAccountReady`)]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(g,{size:15}),i(`wizardStartBrowser`)]})}):null,o===`login`&&!mt&&!ht&&p===`pat`?(0,Z.jsx)(S,{isPending:pt(`pat`),onPress:()=>void ct(),isDisabled:K,children:K?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(U,{size:15}),i(`patDone`)]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Re,{size:15}),i(`wizardCreateAndLogin`)]})}):null,o===`login`&&!mt&&!ht&&p===`import`?(0,Z.jsx)(S,{isPending:pt(`import`),onPress:()=>void ut(),isDisabled:K,children:K?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(U,{size:15}),i(`accountImported`)]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(At,{size:15}),i(`importCredential`)]})}):null]})]})})})})}function Sr(e,t){return e===`region_mixed`?t(`batchImportRegionMixed`):e===`region_unknown`?t(`batchImportRegionUnknown`):e===`unknown_format`?t(`batchImportUnknownFormat`):``}function Cr({isOpen:e,detection:t,fileName:n,isPending:r,t:i,onClose:a,onConfirm:o}){let s=t?.provider===`kiro`?[`us-east-1`,`eu-central-1`]:[`cn`,`global`],[c,l]=(0,Y.useState)(t?.region&&s.includes(t.region)?t.region:s[0]);(0,Y.useEffect)(()=>{if(!t)return;let e=t.provider===`kiro`?[`us-east-1`,`eu-central-1`]:[`cn`,`global`];t.region&&e.includes(t.region)?l(t.region):l(e[0])},[t]);let u=!!t?.batchImportSupported,d=t?.provider,f=t?.format||i(`batchImportFormatUnknown`),p=d?nt(d,i):i(`batchImportProviderUnknown`),m=(t?.warnings||[]).map(e=>Sr(e,i)).filter(Boolean);return(0,Z.jsx)(j.Root,{isOpen:e,onOpenChange:e=>{!e&&!r&&a()},children:(0,Z.jsx)(j.Backdrop,{variant:`blur`,isDismissable:!r,children:(0,Z.jsx)(j.Container,{placement:`center`,size:`md`,scroll:`inside`,className:`mx-3 w-full max-w-[min(100%,32rem)] sm:mx-0`,children:(0,Z.jsxs)(j.Dialog,{children:[(0,Z.jsxs)(j.Header,{className:`items-start justify-between gap-4 px-6 pt-6`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(j.Heading,{className:`text-section font-semibold`,children:i(`batchImportConfirmTitle`)}),(0,Z.jsx)(`p`,{className:`mt-1 break-all text-caption leading-5 text-muted`,children:n?i(`batchImportConfirmHint`,{file:n}):i(`batchImportConfirmHintNoFile`)})]}),(0,Z.jsx)(j.CloseTrigger,{isDisabled:r,"aria-label":i(`close`),className:`grid size-8 shrink-0 place-items-center rounded-lg text-muted transition-colors hover:bg-surface-secondary hover:text-foreground`,children:(0,Z.jsx)(Ie,{size:16})})]}),(0,Z.jsxs)(j.Body,{className:`space-y-4 px-6 pb-2`,children:[(0,Z.jsx)(`div`,{className:`rounded-xl bg-surface-secondary px-3.5 py-3`,children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[d?(0,Z.jsx)(et,{provider:d,size:18}):null,(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`text-body font-medium text-foreground`,children:p}),(0,Z.jsx)(`div`,{className:`mono mt-0.5 truncate text-caption text-muted`,children:f})]})]})}),u?(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`div`,{className:`text-body font-medium text-muted`,children:i(d===`kiro`?`batchImportKiroRegion`:`batchImportRegion`)}),(0,Z.jsx)(Ze,{value:c,onChange:e=>{s.includes(e)&&l(e)},ariaLabel:i(d===`kiro`?`batchImportKiroRegion`:`batchImportRegion`),options:d===`kiro`?[{id:`us-east-1`,label:i(`accountTypeKiroUS`)},{id:`eu-central-1`,label:i(`accountTypeKiroEU`)}]:[{id:`cn`,label:i(`accountTypeWorkBuddyCN`)},{id:`global`,label:i(`accountTypeWorkBuddyGlobal`)}]}),t?.regionAmbiguous?(0,Z.jsx)(`p`,{className:`text-caption leading-5 text-muted`,children:i(d===`kiro`?`batchImportKiroRegionPickHint`:`batchImportRegionPickHint`)}):null]}):(0,Z.jsx)(`p`,{className:`text-body leading-6 text-muted`,children:i(`batchImportProviderUnsupported`)}),m.length?(0,Z.jsx)(`ul`,{className:`space-y-1 text-caption leading-5 text-muted`,children:m.map(e=>(0,Z.jsx)(`li`,{children:e},e))}):null]}),(0,Z.jsxs)(j.Footer,{className:`flex-col-reverse gap-2 px-6 pb-6 sm:flex-row sm:justify-end`,children:[(0,Z.jsx)(S,{size:`sm`,variant:`ghost`,className:`w-full sm:w-auto`,isDisabled:r,onPress:a,children:i(u?`cancel`:`close`)}),u?(0,Z.jsx)(S,{size:`sm`,className:`w-full sm:w-auto`,isPending:r,onPress:()=>o(c),children:i(`batchImportConfirmAction`)}):null]})]})})})})}function wr(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return typeof t.format==`string`&&t.format.trim().toLowerCase()===`cli2api-accounts`&&Array.isArray(t.accounts)}function Tr(e){let t;try{t=JSON.parse(e)}catch{throw Error(`bad_json`)}if(!wr(t))throw Error(`bad_bundle`);return t}function Er(e){let t=JSON.stringify(e,null,2),n=new Blob([t],{type:`application/json`}),r=URL.createObjectURL(n),i=(e.exported_at||new Date().toISOString()).replace(/[:.]/g,`-`).slice(0,19),a=document.createElement(`a`);a.href=r,a.download=`cli2api-accounts-${i}.json`,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(r)}function Dr({isOpen:e,bundle:t,fileName:n,isPending:r,t:i,onClose:a,onConfirm:o}){let s=t?.accounts?.length??0,c=t?.accounts?.filter(e=>!!e.credential).length??0;return(0,Z.jsx)(j.Root,{isOpen:e,onOpenChange:e=>{!e&&!r&&a()},children:(0,Z.jsx)(j.Backdrop,{variant:`blur`,isDismissable:!r,children:(0,Z.jsx)(j.Container,{placement:`center`,size:`md`,scroll:`inside`,className:`mx-3 w-full max-w-[min(100%,32rem)] sm:mx-0`,children:(0,Z.jsxs)(j.Dialog,{children:[(0,Z.jsxs)(j.Header,{className:`items-start justify-between gap-4 px-6 pt-6`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(j.Heading,{className:`text-section font-semibold`,children:i(`bundleImportConfirmTitle`)}),(0,Z.jsx)(`p`,{className:`mt-1 break-all text-caption leading-5 text-muted`,children:n?i(`bundleImportConfirmHint`,{file:n}):i(`bundleImportConfirmHintNoFile`)})]}),(0,Z.jsx)(j.CloseTrigger,{isDisabled:r,"aria-label":i(`close`),className:`grid size-8 shrink-0 place-items-center rounded-lg text-muted transition-colors hover:bg-surface-secondary hover:text-foreground`,children:(0,Z.jsx)(Ie,{size:16})})]}),(0,Z.jsxs)(j.Body,{className:`space-y-3 px-6 pb-2`,children:[(0,Z.jsxs)(`div`,{className:`rounded-xl bg-surface-secondary px-3.5 py-3 text-body leading-6 text-foreground`,children:[(0,Z.jsx)(`div`,{className:`mono text-lg font-semibold`,children:s}),(0,Z.jsx)(`div`,{className:`text-muted`,children:i(`bundleImportAccountCount`)})]}),(0,Z.jsx)(`p`,{className:`text-body leading-6 text-muted`,children:i(`bundleImportCountDetail`,{credentials:c})}),(0,Z.jsx)(`p`,{className:`text-body leading-6 text-muted`,children:i(`bundleImportAdditiveHint`)}),(0,Z.jsx)(`p`,{className:`text-caption leading-5 text-muted`,children:i(`bundleExportHint`)})]}),(0,Z.jsxs)(j.Footer,{className:`flex-col-reverse gap-2 px-6 pb-6 sm:flex-row sm:justify-end`,children:[(0,Z.jsx)(S,{size:`sm`,variant:`ghost`,className:`w-full sm:w-auto`,isDisabled:r,onPress:a,children:i(`cancel`)}),(0,Z.jsx)(S,{size:`sm`,className:`w-full sm:w-auto`,isPending:r,isDisabled:s===0,onPress:o,children:i(`bundleImportConfirmAction`)})]})]})})})})}function Or(e){if(!Array.isArray(e.accounts))return[e];let t=e.accounts.filter(e=>!!e&&typeof e==`object`&&!Array.isArray(e)&&rr(e));return t.length>0?t:[e]}function kr(e,t){let n=Or(e),r=n.find(e=>typeof e.nickname==`string`||typeof e.email==`string`),i=typeof r?.nickname==`string`?r.nickname.trim():``,a=typeof r?.email==`string`?r.email.trim():``;return{format:`kiro-oauth-v1`,provider:`kiro`,region:nr(n[0]||e)||t,enabled:!0,name:n.length===1&&(i||a)||void 0,accounts:n.map(e=>({...e,region:nr(e)||t}))}}var Ar=`__all__`,jr=[],Mr=2;function Nr(){let{t:e}=re(),[t,n]=(0,Y.useState)([]),[r,i]=(0,Y.useState)(null),[a,s]=(0,Y.useState)(``),[c,u]=(0,Y.useState)([]),[d,g]=(0,Y.useState)(!0),_=c,v=_.length>0,[y,ne]=(0,Y.useState)(!1),[b,x]=(0,Y.useState)(!1),[C,ie]=(0,Y.useState)(!1),[w,ae]=(0,Y.useState)(!1),[T,E]=(0,Y.useState)(!1),[oe,se]=(0,Y.useState)(null),[ce,D]=(0,Y.useState)(``),[le,de]=(0,Y.useState)(!1),[pe,ge]=(0,Y.useState)(null),[_e,k]=(0,Y.useState)(null),[A,j]=(0,Y.useState)(``),[M,N]=(0,Y.useState)(null),[P,I]=(0,Y.useState)({}),[Se,De]=(0,Y.useState)({}),[Oe,z]=(0,Y.useState)({}),[Pe,B]=(0,Y.useState)({}),[Fe,Ie]=(0,Y.useState)({}),[Le,Re]=(0,Y.useState)(null),[V,ze]=(0,Y.useState)(null),[Be,Ve]=(0,Y.useState)(null),[H,U]=(0,Y.useState)(null),[Ue,We]=(0,Y.useState)(null),[W,G]=(0,Y.useState)(``),[K,qe]=(0,Y.useState)(`all`),[Je,Ye]=(0,Y.useState)(``),[Xe,Qe]=(0,Y.useState)(1),[$e,tt]=(0,Y.useState)(20),[rt,it]=(0,Y.useState)({}),[at,ot]=(0,Y.useState)({}),[st,ct]=(0,Y.useState)({}),[lt,ut]=(0,Y.useState)({}),[dt,ft]=(0,Y.useState)(!1),[pt,mt]=(0,Y.useState)(!1),J=(0,Y.useCallback)(async(e=!1)=>{try{let t=(await je(e)).data||jr;return u(t),t}finally{g(!1)}},[]),gt=(0,Y.useCallback)(async(e,t=!0)=>{let n=[...new Set(e)];if(!n.length)return{total:0,failed:0,errors:[]};let r=n.length,i=new Map;for(let e=0;e{try{let n=await be(e,{quota:t});u(t=>t.map(t=>t.id===e?n:t))}catch(t){let n=t instanceof Error?t.message:String(t);i.set(e,n),z(t=>({...t,[e]:n}))}}))}return{total:r,failed:i.size,errors:[...i.values()]}},[]);(0,Y.useEffect)(()=>{J(!1).catch(()=>void 0)},[J]),(0,Y.useEffect)(()=>{let e=!0;return Promise.all([we(),He()]).then(([t,r])=>{e&&(n(t.data||[]),i(r))}).catch(t=>{e&&s(t instanceof Error?t.message:String(t))}),()=>{e=!1}},[]),(0,Y.useEffect)(()=>{let e=!0;return J(!1).then(t=>{if(e)return gt((t||[]).map(e=>e.id))}).catch(()=>void 0),()=>{e=!1}},[J,gt]);function _t(e){return t.find(t=>t.id===e.provider)?.regions.find(t=>t.id===e.region)?.checkin}function vt(e){let t=_t(e)?.timezone,n=t===`Local`?`Asia/Shanghai`:t||`Asia/Shanghai`;try{return Intl.DateTimeFormat(`en-CA`,{timeZone:n}),n}catch{return}}let X=(0,Y.useMemo)(()=>_.map(e=>{let t=rt[e.id],n=at[e.id],r=st[e.id],i=lt[e.id],a=e;return t!==void 0&&(a={...a,enabled:t}),n!==void 0&&(a={...a,name:n}),r!==void 0&&(a={...a,max_inflight:r}),i!==void 0&&(a={...a,priority:i}),a}),[rt,st,at,lt,_]),yt=(0,Y.useMemo)(()=>{let e={all:X.length,available:0,attention:0,disabled:0};for(let t of X){let n=ht(t);n===`hot`||n===`ready`?e.available+=1:n===`disabled`&&(e.disabled+=1),t.enabled&&n!==`hot`&&n!==`ready`&&(e.attention+=1)}return e},[X]),bt=(0,Y.useMemo)(()=>{let e=new Map;for(let t of X){let n=String(t.provider||`qoder`).toLowerCase();e.set(n,(e.get(n)||0)+1)}return[...e.entries()].sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0]))},[X]),xt=X.find(e=>e.id===Le),St=X.find(e=>e.id===V)||null,Ct=X.find(e=>e.id===Be)||null,Tt=X.find(e=>e.id===H)||null,Et=(0,Y.useMemo)(()=>{let e=W.trim().toLowerCase();return X.filter(t=>{let n=ht(t);return!(K===`all`||K===`available`&&(n===`hot`||n===`ready`)||K===`attention`&&t.enabled&&n!==`hot`&&n!==`ready`||K===`disabled`&&n===`disabled`)||Je&&String(t.provider||`qoder`).toLowerCase()!==Je?!1:!e||[t.name,t.id,t.remote_uid,t.provider,t.auth_type].some(t=>String(t||``).toLowerCase().includes(e))})},[X,K,Je,W]),Dt=[W,K,Je,$e].join(`\0`),[kt,At]=(0,Y.useState)(Dt);kt!==Dt&&(At(Dt),Qe(1));let jt=Math.max(1,Math.ceil(Et.length/$e)),Mt=Math.min(kt===Dt?Math.max(1,Xe):1,jt);Xe!==Mt&&Qe(Mt);let Nt=(0,Y.useMemo)(()=>{let e=(Mt-1)*$e;return Et.slice(e,e+$e)},[Mt,Et,$e]);if(d&&!v)return(0,Z.jsx)(Ke,{});async function Pt(e,t,n){N({id:e,kind:t}),z(t=>({...t,[e]:``}));try{return await n(),!0}catch(t){return z(n=>({...n,[e]:t instanceof Error?t.message:String(t)})),!1}finally{N(null)}}async function Ft(t,n){We(t),await Pt(t,`device`,async()=>{z(n=>({...n,[t]:e(`wizardStartingSession`)}));let r=await ve(t,n);r.authUrl&&Ie(e=>({...e,[t]:r.authUrl||``}));for(let n=0;n<60;n++){await new Promise(e=>window.setTimeout(e,2e3));let n=(await Ce(t)).login||{};if(z(r=>({...r,[t]:n.message||e(`waitingQoderLogin`)})),n.status===`ok`||n.status===`error`)break}await J(!1),await gt([t])})}async function Lt(t){let n=(Se[t]||``).trim();if(!n){z(n=>({...n,[t]:e(`wizardCallbackPh`)}));return}await Pt(t,`callback`,async()=>{z(n=>({...n,[t]:e(`wizardStartingSession`)})),await ye(t,n),De(e=>({...e,[t]:``})),await J(!1),await gt([t])})&&(We(e=>e===t?null:e),z(e=>({...e,[t]:``})))}async function Rt(t){let n=(P[t]||``).trim();if(!n){z(n=>({...n,[t]:e(`pastePatFirst`)}));return}await Pt(t,`pat`,async()=>{z(n=>({...n,[t]:e(`wizardStartingSession`)})),await Ne(n,t),I(e=>({...e,[t]:``})),await J(!1),await gt([t])})}async function zt(t){await Pt(t,`export`,async()=>{let n=await xe(t);await f(JSON.stringify(n,null,2)),z(n=>({...n,[t]:e(`credentialCopied`)}))})}async function Bt(){if(C)return;ie(!0);let t=`accounts-export-all`;q({id:t,type:`loading`,title:e(`toastAccountsExporting`)});try{let n=await Ee();Er(n),q({id:t,type:`success`,title:e(`toastAccountsExported`,{n:n.count??n.accounts.length}),description:e(`bundleExportHint`)})}catch(n){q({id:t,type:`error`,title:e(`toastFailed`),description:n instanceof Error?n.message:String(n)})}finally{ie(!1)}}function Vt(){w||(E(!1),se(null),D(``))}async function Ht(t){let n=t.target.files?.[0];if(t.target.value=``,n)try{let e=Tr(await n.text());se(e),D(n.name),E(!0)}catch(t){let n=t instanceof Error?t.message:String(t);q({type:`error`,title:e(n===`bad_json`?`wizardBadJson`:`bundleImportUnrecognized`)})}}async function Ut(){if(!oe||w)return;ae(!0);let t=`bundle-import-accounts`;q({id:t,type:`loading`,title:e(`bundleImportLoading`)});try{let n=await Me(oe),r=n.succeeded??0,i=n.failed??0,a=(n.errors||[]).slice(0,3).map(e=>e.message||`index ${e.index}`).filter(Boolean).join(`; `);q({id:t,type:i>0&&r===0?`error`:i>0?`info`:`success`,title:i>0?e(`accountImportPartial`).replace(`{ok}`,String(r)).replace(`{fail}`,String(i)):e(`accountImportBatch`).replace(`{n}`,String(r)),description:a||void 0}),E(!1),se(null),D(``),r>0&&await J(!1)}catch(n){q({id:t,type:`error`,title:e(`toastFailed`),description:n instanceof Error?n.message:String(n)})}finally{ae(!1)}}async function Wt(e,t){it(n=>({...n,[e]:t})),await Pt(e,`toggle`,async()=>{await L(e,{enabled:t}),await J(!1)}),it(t=>{let n={...t};return delete n[e],n})}async function Gt(t){q({id:`refresh-${t}`,type:`loading`,title:e(`toastRefreshingAccount`)}),N({id:t,kind:`refresh`}),z(e=>{let n={...e};return delete n[t],n});try{let n=await gt([t]);if(n.failed>0){q({id:`refresh-${t}`,type:`error`,title:e(`toastFailed`),description:n.errors[0]||e(`toastFailed`)});return}q({id:`refresh-${t}`,type:`success`,title:e(`toastAccountRefreshed`)})}finally{N(null)}}async function Kt(){ft(!0),q({id:`refresh-credits`,type:`loading`,title:e(`toastRefreshingCredits`)});try{let t=await gt(c.map(e=>e.id));if(t.failed>0){let n=t.failed0&&r===0?`error`:i>0?`info`:`success`,title:a}),de(!1),ge(null),k(null),j(``),r>0&&await J(!1)}catch(t){q({id:n,type:`error`,title:e(`toastFailed`),description:t instanceof Error?t.message:String(t)})}finally{x(!1)}}async function Xt(e,t){await Pt(e,`toggle`,async()=>{await L(e,{auto_checkin:t}),await J(!1)})}async function Zt(){mt(!0),q({id:`checkin-all`,type:`loading`,title:e(`toastCheckingInAll`,{done:0,total:_.length})});try{let t=(await Te()).data||[];if(t.length===0){q({id:`checkin-all`,type:`info`,title:e(`checkinAllEmpty`)});return}let n={checked:0,skipped:0,failed:0},r={};for(let i of t){let t=String(i.status||``).toLowerCase(),a=t===`already`||t===`skipped`||t===`error`?t:`success`;a===`error`?n.failed+=1:a===`skipped`||a===`already`?n.skipped+=1:n.checked+=1,r[i.account_id]={kind:a,message:a===`error`?i.message||e(`checkinRecordFailed`):i.message}}B(e=>({...e,...r}));let i={checked:n.checked,skipped:n.skipped,failed:n.failed};q({id:`checkin-all`,type:n.failed?`error`:`success`,title:e(n.failed?`toastCheckedInAllFailed`:`toastCheckedInAll`,i)})}catch(t){q({id:`checkin-all`,type:`error`,title:e(`toastFailed`),description:t instanceof Error?t.message:String(t)})}finally{mt(!1),await J(!1).catch(()=>void 0)}}async function Qt(t){await Pt(t,`checkin`,async()=>{let n;try{n=await ke(t)}catch(e){B(n=>({...n,[t]:{kind:`error`,message:e instanceof Error?e.message:String(e)}})),await J(!1).catch(()=>void 0),await gt([t]).catch(()=>void 0);return}let r=n?.last_checkin_status,i=n?.last_checkin_msg,a=r===`already`?`already`:r===`skipped`?`skipped`:r===`error`?`error`:`success`;B(n=>({...n,[t]:{kind:a,message:a===`error`?i||e(`checkinRecordFailed`):i}})),await J(!1).catch(()=>void 0),await gt([t]).catch(()=>void 0)})}async function $t(t,n){if(!t)throw Error(e(`accountNameRequired`));ot(e=>({...e,[t]:n.name})),ct(e=>({...e,[t]:n.max_inflight})),ut(e=>({...e,[t]:n.priority})),N({id:t,kind:`settings`});try{await L(t,n),await J(!1)}catch(e){throw e instanceof Error?e:Error(String(e))}finally{N(null),ot(e=>{let n={...e};return delete n[t],n}),ct(e=>{let n={...e};return delete n[t],n}),ut(e=>{let n={...e};return delete n[t],n})}}return(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[a?(0,Z.jsx)(me,{title:a}):null,(0,Z.jsxs)(`section`,{"data-gsap-reveal":!0,className:`flex flex-wrap items-center gap-2`,children:[_.length?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Ze,{value:K,onChange:e=>qe(e),ariaLabel:e(`accountStatusFilter`),options:[{id:`all`,label:(0,Z.jsxs)(Z.Fragment,{children:[e(`filterAll`),(0,Z.jsx)(`span`,{className:`mono text-muted`,children:yt.all})]})},{id:`available`,label:(0,Z.jsxs)(Z.Fragment,{children:[e(`availableAccounts`),(0,Z.jsx)(`span`,{className:`mono text-muted`,children:yt.available})]})},{id:`attention`,label:(0,Z.jsxs)(Z.Fragment,{children:[e(`needsAttention`),(0,Z.jsx)(`span`,{className:`mono ${yt.attention?`text-danger`:`text-muted`}`,children:yt.attention})]})},{id:`disabled`,label:(0,Z.jsxs)(Z.Fragment,{children:[e(`disabled`),(0,Z.jsx)(`span`,{className:`mono text-muted`,children:yt.disabled})]})}]}),(0,Z.jsxs)(F,{className:`w-48`,"aria-label":e(`providerFilterAll`),value:Je||Ar,onChange:e=>{typeof e==`string`&&Ye(e===Ar?``:e)},children:[(0,Z.jsxs)(F.Trigger,{className:`items-center`,children:[(0,Z.jsx)(F.Value,{className:`min-w-0 truncate`}),(0,Z.jsx)(F.Indicator,{})]}),(0,Z.jsx)(F.Popover,{children:(0,Z.jsxs)(fe,{children:[(0,Z.jsxs)(fe.Item,{id:Ar,textValue:e(`providerFilterAll`),children:[(0,Z.jsxs)(ue,{className:`flex items-center gap-2`,children:[e(`providerFilterAll`),(0,Z.jsx)(`span`,{className:`mono text-muted`,children:_.length})]}),(0,Z.jsx)(fe.ItemIndicator,{})]}),bt.map(([t,n])=>(0,Z.jsxs)(fe.Item,{id:t,textValue:nt(t,e),children:[(0,Z.jsxs)(ue,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(et,{provider:t,size:13}),nt(t,e),(0,Z.jsx)(`span`,{className:`mono text-muted`,children:n})]}),(0,Z.jsx)(fe.ItemIndicator,{})]},t))]})})]}),(0,Z.jsx)(h,{className:`w-full sm:w-60`,value:W,onChange:G,placeholder:e(`searchAccounts`),ariaLabel:e(`searchAccounts`)})]}):null,(0,Z.jsxs)(`div`,{className:`flex w-full flex-wrap items-center justify-end gap-2 sm:ml-auto sm:w-auto`,children:[(0,Z.jsxs)(S,{size:`sm`,variant:`secondary`,isPending:C,isDisabled:b||le||w||T,onPress:()=>void Bt(),children:[(0,Z.jsx)(Ot,{size:14}),e(`exportAll`)]}),(0,Z.jsxs)(`label`,{htmlFor:`accounts-bundle-import-file`,className:`button button--sm button--secondary inline-flex items-center gap-1.5 ${w||T||b||le||C?`pointer-events-none opacity-60`:`cursor-pointer`}`,children:[w?(0,Z.jsx)(Ge,{size:14,loading:!0}):(0,Z.jsx)(Ot,{size:14}),e(`importAll`)]}),(0,Z.jsx)(`input`,{id:`accounts-bundle-import-file`,type:`file`,accept:`.json,application/json,text/json`,disabled:w||T||b||le||C,className:`sr-only`,onChange:e=>void Ht(e)}),(0,Z.jsxs)(S,{size:`sm`,variant:`secondary`,isPending:pt,isDisabled:dt,onPress:()=>void Zt(),children:[(0,Z.jsx)(wt,{size:14}),e(`checkinAll`)]}),(0,Z.jsxs)(S,{size:`sm`,variant:`secondary`,isPending:dt,isDisabled:pt,onPress:()=>void Kt(),children:[(0,Z.jsx)(o,{size:14}),e(`refreshCredits`)]}),(0,Z.jsxs)(`label`,{htmlFor:`accounts-batch-import-file`,className:`button button--sm button--secondary inline-flex items-center gap-1.5 ${b||le||w||T||C?`pointer-events-none opacity-60`:`cursor-pointer`}`,children:[b?(0,Z.jsx)(Ge,{size:14,loading:!0}):(0,Z.jsx)(It,{size:14}),e(`batchImport`)]}),(0,Z.jsx)(`input`,{id:`accounts-batch-import-file`,type:`file`,accept:`.json,application/json,text/json`,disabled:b||le||w||T||C,className:`sr-only`,onChange:e=>void Jt(e)}),(0,Z.jsxs)(S,{size:`sm`,onPress:()=>ne(!0),children:[(0,Z.jsx)(te,{size:14}),e(`addAccount`)]})]})]}),(0,Z.jsx)(xr,{isOpen:y,onClose:()=>ne(!1),onAdded:()=>{q({type:`success`,title:e(`toastAccountAdded`)}),J(!1)}}),(0,Z.jsx)(Dr,{isOpen:T,bundle:oe,fileName:ce,isPending:w,t:e,onClose:Vt,onConfirm:()=>{Ut()}}),(0,Z.jsx)(Cr,{isOpen:le,detection:pe,fileName:A,isPending:b,t:e,onClose:qt,onConfirm:e=>{Yt(e)}}),(0,Z.jsx)(jn,{account:St,t:e,onClose:()=>ze(null)},V??`closed`),(0,Z.jsx)(kn,{account:Ct,t:e,onClose:()=>Ve(null)},Be??`closed`),(0,Z.jsx)(Mn,{account:Tt,busy:!!(M&&M.id===H&&M.kind===`settings`),t:e,onClose:()=>U(null),onSave:e=>$t(H||``,e)},H??`closed`),(0,Z.jsx)(he,{isOpen:!!xt,title:e(`delete`),description:e(`deleteAccountConfirm`,{name:xt?.name||xt?.id||``}),confirmLabel:e(`delete`),cancelLabel:e(`cancel`),closeLabel:e(`close`),isPending:M?.id===Le&&M.kind===`delete`,onClose:()=>Re(null),onConfirm:()=>{if(!xt)return;let t=xt.id;Re(null),Pt(t,`delete`,async()=>{await Ae(t),await J(!1)}).then(t=>{t&&q({type:`success`,title:e(`toastAccountDeleted`)})})}}),v?null:(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsx)(O,{className:`rounded-3xl bg-surface-secondary`,icon:(0,Z.jsx)(Ge,{size:28}),title:e(`noAccounts`),hint:e(`accountEmptyHint`),action:(0,Z.jsxs)(S,{size:`sm`,onPress:()=>ne(!0),children:[(0,Z.jsx)(te,{size:14}),e(`addAccount`)]})}),(0,Z.jsx)(`div`,{className:`text-center`,children:(0,Z.jsx)(l,{})})]}),v&&!Et.length?(0,Z.jsx)(O,{className:`rounded-3xl bg-surface-secondary`,icon:(0,Z.jsx)(p,{size:22}),title:e(`noAccountsMatch`),action:(0,Z.jsx)(S,{size:`sm`,variant:`ghost`,onPress:()=>{G(``),qe(`all`),Ye(``)},children:e(`clearFilters`)})}):null,(0,Z.jsx)(`section`,{className:`grid auto-rows-[minmax(280px,auto)] gap-2.5 lg:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4`,children:Nt.map(t=>(0,Z.jsx)(En,{account:t,busyKind:M?.id===t.id?M.kind:``,authPanelOpen:Ue===t.id,authUrl:Fe[t.id],note:Oe[t.id],pat:P[t.id]||``,t:e,onPatChange:e=>I(n=>({...n,[t.id]:e})),callbackUrl:Se[t.id]||``,onCallbackChange:e=>De(n=>({...n,[t.id]:e})),onSubmitCallback:()=>void Lt(t.id),onDeviceLogin:e=>void Ft(t.id,e),onPatLogin:()=>void Rt(t.id),onExport:()=>void zt(t.id),onRefresh:()=>void Gt(t.id),onDelete:()=>Re(t.id),onToggle:e=>void Wt(t.id,e),checkinDefaultTime:r?.checkin_times[t.provider||``],checkinTimezone:vt(t),onToggleAutoCheckin:_t(t)?e=>void Xt(t.id,e):void 0,onCheckin:_t(t)?()=>void Qt(t.id):void 0,checkinFeedback:Pe[t.id]??null,onViewCheckins:_t(t)?()=>Ve(t.id):void 0,onEdit:()=>U(t.id),onToggleAuthPanel:()=>We(e=>e===t.id?null:t.id),onViewModels:()=>ze(t.id)},t.id))}),Et.length?(0,Z.jsx)(ee,{total:Et.length,page:Mt,pageCount:jt,pageSize:$e,pageSizes:m,loading:!1,pageSizeLabel:e(`logsPageSize`),pageLabel:e(`logsPage`,{page:Mt,pages:jt}),prevLabel:e(`logsPrevPage`),nextLabel:e(`logsNextPage`),onPage:Qe,onPageSize:tt}):null]})}export{Nr as AccountsPage}; \ No newline at end of file diff --git a/internal/webui/static/assets/AccountsPage-C7wtKWtS.js b/internal/webui/static/assets/AccountsPage-C7wtKWtS.js new file mode 100644 index 00000000..08001d44 --- /dev/null +++ b/internal/webui/static/assets/AccountsPage-C7wtKWtS.js @@ -0,0 +1 @@ +import{a as e,c as t,n}from"./shim-mfK0Rmj6.js";import{a as r,i,n as a,o,r as s,s as c,t as l}from"./CaiaiSoftLink-6tjwsEDV.js";import{t as u}from"./CaretRight.es-DGKxUxz5.js";import{n as d,t as f}from"./clipboard-BWzpPXn-.js";import{i as p,n as m,r as ee,t as h}from"./SearchBar-DXjI_cjB.js";import{t as te}from"./Plus.es-CSLpU0CT.js";import{t as g}from"./ShieldCheck.es-DReH26Zt.js";import{t as _}from"./TrashSimple.es-51cVgQMz.js";import{B as v,P as y,Y as ne,dt as b,et as x,n as re,r as S}from"./useI18n-BBOAnu2u.js";import{B as C,F as ie,J as w,M as ae,N as T,c as oe,j as se,q as ce,s as le,z as E}from"./SharedElementTransition-BlCsXfb1.js";import{_ as ue,g as de,t as fe}from"./label-BVCjtfNQ.js";import{t as pe}from"./list-box-1t_n3N3P.js";import{n as me,t as he}from"./PageAlert-DZC7IhXp.js";import{t as ge}from"./ConfirmDialog-D6gNei8x.js";import{t as _e}from"./card-QlCdtlk0.js";import{i as ve,n as ye,r as D,t as O}from"./number-field-nGZCb975.js";import{t as be}from"./description-CNxrVc-S.js";import{t as k}from"./EmptyPanel-Bs-jQMvG.js";import{n as A,r as xe,t as j}from"./FormRow-Bhp_wPvH.js";import{t as M}from"./modal-DHeFzFnN.js";import{t as N}from"./select-BYBzHj05.js";import{d as Se,f as Ce}from"./format-kRpr2wxA.js";import{D as we,S as P,_ as Te,a as F,b as Ee,c as De,d as Oe,f as ke,g as Ae,i as je,l as Me,o as Ne,p as Pe,r as Fe,s as Ie,u as Le,v as Re,w as ze,x as I,y as Be}from"./overview-CJvUvgoD.js";import{t as Ve}from"./textfield-BJXzgJRr.js";import{r as L}from"./gsap-C3sDxib7.js";import{At as He,G as Ue,Ht as R,J as We,K as Ge,Kt as z,M as B,Rt as Ke,S as qe,T as V,Ut as H,Y as Je,_ as U,a as Ye,j as W,k as G,kt as Xe,m as K,q as Ze,t as q,v as Qe,y as $e,yt as et}from"./index-B9eWF6SH.js";import{t as tt}from"./FilterToggle-AieL1mQy.js";import{t as nt}from"./ProviderMark-IiAZTaQS.js";import{n as rt,t as it}from"./provider-gHnttGKq.js";import{a as at,c as ot,d as st,f as ct,i as lt,l as ut,m as dt,n as ft,o as pt,p as mt,r as ht,s as gt,t as _t,u as vt}from"./account-BJHim5bc.js";import{t as yt}from"./useAccountEvents-CCHBF_7j.js";var J=t(e(),1),bt=new Map([[`bold`,J.createElement(J.Fragment,null,J.createElement(`path`,{d:`M208,28H188V24a12,12,0,0,0-24,0v4H92V24a12,12,0,0,0-24,0v4H48A20,20,0,0,0,28,48V208a20,20,0,0,0,20,20H208a20,20,0,0,0,20-20V48A20,20,0,0,0,208,28ZM68,52a12,12,0,0,0,24,0h72a12,12,0,0,0,24,0h16V76H52V52ZM52,204V100H204V204Zm120.49-84.49a12,12,0,0,1,0,17l-48,48a12,12,0,0,1-17,0l-24-24a12,12,0,0,1,17-17L116,159l39.51-39.52A12,12,0,0,1,172.49,119.51Z`}))],[`duotone`,J.createElement(J.Fragment,null,J.createElement(`path`,{d:`M216,48V88H40V48a8,8,0,0,1,8-8H208A8,8,0,0,1,216,48Z`,opacity:`0.2`}),J.createElement(`path`,{d:`M208,32H184V24a8,8,0,0,0-16,0v8H88V24a8,8,0,0,0-16,0v8H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM72,48v8a8,8,0,0,0,16,0V48h80v8a8,8,0,0,0,16,0V48h24V80H48V48ZM208,208H48V96H208V208Zm-38.34-85.66a8,8,0,0,1,0,11.32l-48,48a8,8,0,0,1-11.32,0l-24-24a8,8,0,0,1,11.32-11.32L116,164.69l42.34-42.35A8,8,0,0,1,169.66,122.34Z`}))],[`fill`,J.createElement(J.Fragment,null,J.createElement(`path`,{d:`M208,32H184V24a8,8,0,0,0-16,0v8H88V24a8,8,0,0,0-16,0v8H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM169.66,133.66l-48,48a8,8,0,0,1-11.32,0l-24-24a8,8,0,0,1,11.32-11.32L116,164.69l42.34-42.35a8,8,0,0,1,11.32,11.32ZM48,80V48H72v8a8,8,0,0,0,16,0V48h80v8a8,8,0,0,0,16,0V48h24V80Z`}))],[`light`,J.createElement(J.Fragment,null,J.createElement(`path`,{d:`M208,34H182V24a6,6,0,0,0-12,0V34H86V24a6,6,0,0,0-12,0V34H48A14,14,0,0,0,34,48V208a14,14,0,0,0,14,14H208a14,14,0,0,0,14-14V48A14,14,0,0,0,208,34ZM48,46H74V56a6,6,0,0,0,12,0V46h84V56a6,6,0,0,0,12,0V46h26a2,2,0,0,1,2,2V82H46V48A2,2,0,0,1,48,46ZM208,210H48a2,2,0,0,1-2-2V94H210V208A2,2,0,0,1,208,210Zm-39.76-86.24a6,6,0,0,1,0,8.48l-48,48a6,6,0,0,1-8.48,0l-24-24a6,6,0,0,1,8.48-8.48L116,167.51l43.76-43.75A6,6,0,0,1,168.24,123.76Z`}))],[`regular`,J.createElement(J.Fragment,null,J.createElement(`path`,{d:`M208,32H184V24a8,8,0,0,0-16,0v8H88V24a8,8,0,0,0-16,0v8H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM72,48v8a8,8,0,0,0,16,0V48h80v8a8,8,0,0,0,16,0V48h24V80H48V48ZM208,208H48V96H208V208Zm-38.34-85.66a8,8,0,0,1,0,11.32l-48,48a8,8,0,0,1-11.32,0l-24-24a8,8,0,0,1,11.32-11.32L116,164.69l42.34-42.35A8,8,0,0,1,169.66,122.34Z`}))],[`thin`,J.createElement(J.Fragment,null,J.createElement(`path`,{d:`M208,36H180V24a4,4,0,0,0-8,0V36H84V24a4,4,0,0,0-8,0V36H48A12,12,0,0,0,36,48V208a12,12,0,0,0,12,12H208a12,12,0,0,0,12-12V48A12,12,0,0,0,208,36ZM48,44H76V56a4,4,0,0,0,8,0V44h88V56a4,4,0,0,0,8,0V44h28a4,4,0,0,1,4,4V84H44V48A4,4,0,0,1,48,44ZM208,212H48a4,4,0,0,1-4-4V92H212V208A4,4,0,0,1,208,212Zm-41.17-86.83a4,4,0,0,1,0,5.66l-48,48a4,4,0,0,1-5.66,0l-24-24a4,4,0,0,1,5.66-5.66L116,170.34l45.17-45.17A4,4,0,0,1,166.83,125.17Z`}))]]),xt=new Map([[`bold`,J.createElement(J.Fragment,null,J.createElement(`path`,{d:`M112,60a16,16,0,1,1,16,16A16,16,0,0,1,112,60Zm16,52a16,16,0,1,0,16,16A16,16,0,0,0,128,112Zm0,68a16,16,0,1,0,16,16A16,16,0,0,0,128,180Z`}))],[`duotone`,J.createElement(J.Fragment,null,J.createElement(`path`,{d:`M176,32V224a16,16,0,0,1-16,16H96a16,16,0,0,1-16-16V32A16,16,0,0,1,96,16h64A16,16,0,0,1,176,32Z`,opacity:`0.2`}),J.createElement(`path`,{d:`M140,128a12,12,0,1,1-12-12A12,12,0,0,1,140,128ZM128,72a12,12,0,1,0-12-12A12,12,0,0,0,128,72Zm0,112a12,12,0,1,0,12,12A12,12,0,0,0,128,184Z`}))],[`fill`,J.createElement(J.Fragment,null,J.createElement(`path`,{d:`M160,16H96A16,16,0,0,0,80,32V224a16,16,0,0,0,16,16h64a16,16,0,0,0,16-16V32A16,16,0,0,0,160,16ZM128,208a12,12,0,1,1,12-12A12,12,0,0,1,128,208Zm0-68a12,12,0,1,1,12-12A12,12,0,0,1,128,140Zm0-68a12,12,0,1,1,12-12A12,12,0,0,1,128,72Z`}))],[`light`,J.createElement(J.Fragment,null,J.createElement(`path`,{d:`M118,60a10,10,0,1,1,10,10A10,10,0,0,1,118,60Zm10,58a10,10,0,1,0,10,10A10,10,0,0,0,128,118Zm0,68a10,10,0,1,0,10,10A10,10,0,0,0,128,186Z`}))],[`regular`,J.createElement(J.Fragment,null,J.createElement(`path`,{d:`M140,128a12,12,0,1,1-12-12A12,12,0,0,1,140,128ZM128,72a12,12,0,1,0-12-12A12,12,0,0,0,128,72Zm0,112a12,12,0,1,0,12,12A12,12,0,0,0,128,184Z`}))],[`thin`,J.createElement(J.Fragment,null,J.createElement(`path`,{d:`M120,60a8,8,0,1,1,8,8A8,8,0,0,1,120,60Zm8,60a8,8,0,1,0,8,8A8,8,0,0,0,128,120Zm0,68a8,8,0,1,0,8,8A8,8,0,0,0,128,188Z`}))]]),St=new Map([[`bold`,J.createElement(J.Fragment,null,J.createElement(`path`,{d:`M228,144v64a12,12,0,0,1-12,12H40a12,12,0,0,1-12-12V144a12,12,0,0,1,24,0v52H204V144a12,12,0,0,1,24,0Zm-108.49,8.49a12,12,0,0,0,17,0l40-40a12,12,0,0,0-17-17L140,115V32a12,12,0,0,0-24,0v83L96.49,95.51a12,12,0,0,0-17,17Z`}))],[`duotone`,J.createElement(J.Fragment,null,J.createElement(`path`,{d:`M216,48V208H40V48A16,16,0,0,1,56,32H200A16,16,0,0,1,216,48Z`,opacity:`0.2`}),J.createElement(`path`,{d:`M224,144v64a8,8,0,0,1-8,8H40a8,8,0,0,1-8-8V144a8,8,0,0,1,16,0v56H208V144a8,8,0,0,1,16,0Zm-101.66,5.66a8,8,0,0,0,11.32,0l40-40a8,8,0,0,0-11.32-11.32L136,124.69V32a8,8,0,0,0-16,0v92.69L93.66,98.34a8,8,0,0,0-11.32,11.32Z`}))],[`fill`,J.createElement(J.Fragment,null,J.createElement(`path`,{d:`M224,144v64a8,8,0,0,1-8,8H40a8,8,0,0,1-8-8V144a8,8,0,0,1,16,0v56H208V144a8,8,0,0,1,16,0Zm-101.66,5.66a8,8,0,0,0,11.32,0l40-40A8,8,0,0,0,168,96H136V32a8,8,0,0,0-16,0V96H88a8,8,0,0,0-5.66,13.66Z`}))],[`light`,J.createElement(J.Fragment,null,J.createElement(`path`,{d:`M222,144v64a6,6,0,0,1-6,6H40a6,6,0,0,1-6-6V144a6,6,0,0,1,12,0v58H210V144a6,6,0,0,1,12,0Zm-98.24,4.24a6,6,0,0,0,8.48,0l40-40a6,6,0,0,0-8.48-8.48L134,129.51V32a6,6,0,0,0-12,0v97.51L92.24,99.76a6,6,0,0,0-8.48,8.48Z`}))],[`regular`,J.createElement(J.Fragment,null,J.createElement(`path`,{d:`M224,144v64a8,8,0,0,1-8,8H40a8,8,0,0,1-8-8V144a8,8,0,0,1,16,0v56H208V144a8,8,0,0,1,16,0Zm-101.66,5.66a8,8,0,0,0,11.32,0l40-40a8,8,0,0,0-11.32-11.32L136,124.69V32a8,8,0,0,0-16,0v92.69L93.66,98.34a8,8,0,0,0-11.32,11.32Z`}))],[`thin`,J.createElement(J.Fragment,null,J.createElement(`path`,{d:`M220,144v64a4,4,0,0,1-4,4H40a4,4,0,0,1-4-4V144a4,4,0,0,1,8,0v60H212V144a4,4,0,0,1,8,0Zm-94.83,2.83a4,4,0,0,0,5.66,0l40-40a4,4,0,1,0-5.66-5.66L132,134.34V32a4,4,0,0,0-8,0V134.34L90.83,101.17a4,4,0,0,0-5.66,5.66Z`}))]]),Ct=new Map([[`bold`,J.createElement(J.Fragment,null,J.createElement(`path`,{d:`M180.49,143.51a12,12,0,0,1,0,17l-24,24a12,12,0,0,1-17-17L155,152l-15.52-15.51a12,12,0,1,1,17-17Zm-64-24a12,12,0,0,0-17,0l-24,24a12,12,0,0,0,0,17l24,24a12,12,0,0,0,17-17L101,152l15.52-15.51A12,12,0,0,0,116.49,119.51ZM220,88V216a20,20,0,0,1-20,20H56a20,20,0,0,1-20-20V40A20,20,0,0,1,56,20h96a12,12,0,0,1,8.49,3.52l56,56A12,12,0,0,1,220,88ZM160,57V80h23Zm36,155V104H148a12,12,0,0,1-12-12V44H60V212Z`}))],[`duotone`,J.createElement(J.Fragment,null,J.createElement(`path`,{d:`M208,88H152V32Z`,opacity:`0.2`}),J.createElement(`path`,{d:`M181.66,146.34a8,8,0,0,1,0,11.32l-24,24a8,8,0,0,1-11.32-11.32L164.69,152l-18.35-18.34a8,8,0,0,1,11.32-11.32Zm-72-24a8,8,0,0,0-11.32,0l-24,24a8,8,0,0,0,0,11.32l24,24a8,8,0,0,0,11.32-11.32L91.31,152l18.35-18.34A8,8,0,0,0,109.66,122.34ZM216,88V216a16,16,0,0,1-16,16H56a16,16,0,0,1-16-16V40A16,16,0,0,1,56,24h96a8,8,0,0,1,5.66,2.34l56,56A8,8,0,0,1,216,88Zm-56-8h28.69L160,51.31Zm40,136V96H152a8,8,0,0,1-8-8V40H56V216H200Z`}))],[`fill`,J.createElement(J.Fragment,null,J.createElement(`path`,{d:`M213.66,82.34l-56-56A8,8,0,0,0,152,24H56A16,16,0,0,0,40,40V216a16,16,0,0,0,16,16H200a16,16,0,0,0,16-16V88A8,8,0,0,0,213.66,82.34Zm-104,88a8,8,0,0,1-11.32,11.32l-24-24a8,8,0,0,1,0-11.32l24-24a8,8,0,0,1,11.32,11.32L91.31,152Zm72-12.68-24,24a8,8,0,0,1-11.32-11.32L164.69,152l-18.35-18.34a8,8,0,0,1,11.32-11.32l24,24A8,8,0,0,1,181.66,157.66ZM152,88V44l44,44Z`}))],[`light`,J.createElement(J.Fragment,null,J.createElement(`path`,{d:`M180.24,147.76a6,6,0,0,1,0,8.48l-24,24a6,6,0,0,1-8.48-8.48L167.51,152l-19.75-19.76a6,6,0,1,1,8.48-8.48Zm-72-24a6,6,0,0,0-8.48,0l-24,24a6,6,0,0,0,0,8.48l24,24a6,6,0,1,0,8.48-8.48L88.49,152l19.75-19.76A6,6,0,0,0,108.24,123.76ZM214,88V216a14,14,0,0,1-14,14H56a14,14,0,0,1-14-14V40A14,14,0,0,1,56,26h96a6,6,0,0,1,4.25,1.76l56,56A6,6,0,0,1,214,88Zm-56-6h35.52L158,46.48Zm44,134V94H152a6,6,0,0,1-6-6V38H56a2,2,0,0,0-2,2V216a2,2,0,0,0,2,2H200A2,2,0,0,0,202,216Z`}))],[`regular`,J.createElement(J.Fragment,null,J.createElement(`path`,{d:`M181.66,146.34a8,8,0,0,1,0,11.32l-24,24a8,8,0,0,1-11.32-11.32L164.69,152l-18.35-18.34a8,8,0,0,1,11.32-11.32Zm-72-24a8,8,0,0,0-11.32,0l-24,24a8,8,0,0,0,0,11.32l24,24a8,8,0,0,0,11.32-11.32L91.31,152l18.35-18.34A8,8,0,0,0,109.66,122.34ZM216,88V216a16,16,0,0,1-16,16H56a16,16,0,0,1-16-16V40A16,16,0,0,1,56,24h96a8,8,0,0,1,5.66,2.34l56,56A8,8,0,0,1,216,88Zm-56-8h28.69L160,51.31Zm40,136V96H152a8,8,0,0,1-8-8V40H56V216H200Z`}))],[`thin`,J.createElement(J.Fragment,null,J.createElement(`path`,{d:`M178.83,149.17a4,4,0,0,1,0,5.66l-24,24a4,4,0,0,1-5.66-5.66L170.34,152l-21.17-21.17a4,4,0,1,1,5.66-5.66Zm-72-24a4,4,0,0,0-5.66,0l-24,24a4,4,0,0,0,0,5.66l24,24a4,4,0,1,0,5.66-5.66L85.66,152l21.17-21.17A4,4,0,0,0,106.83,125.17ZM212,88V216a12,12,0,0,1-12,12H56a12,12,0,0,1-12-12V40A12,12,0,0,1,56,28h96a4,4,0,0,1,2.83,1.17l56,56A4,4,0,0,1,212,88Zm-56-4h42.34L156,41.65Zm48,132V92H152a4,4,0,0,1-4-4V36H56a4,4,0,0,0-4,4V216a4,4,0,0,0,4,4H200A4,4,0,0,0,204,216Z`}))]]),wt=new Map([[`bold`,J.createElement(J.Fragment,null,J.createElement(`path`,{d:`M230.14,70.54,185.46,25.85a20,20,0,0,0-28.29,0L33.86,149.17A19.85,19.85,0,0,0,28,163.31V208a20,20,0,0,0,20,20H92.69a19.86,19.86,0,0,0,14.14-5.86L230.14,98.82a20,20,0,0,0,0-28.28ZM91,204H52V165l84-84,39,39ZM192,103,153,64l18.34-18.34,39,39Z`}))],[`duotone`,J.createElement(J.Fragment,null,J.createElement(`path`,{d:`M221.66,90.34,192,120,136,64l29.66-29.66a8,8,0,0,1,11.31,0L221.66,79A8,8,0,0,1,221.66,90.34Z`,opacity:`0.2`}),J.createElement(`path`,{d:`M227.31,73.37,182.63,28.68a16,16,0,0,0-22.63,0L36.69,152A15.86,15.86,0,0,0,32,163.31V208a16,16,0,0,0,16,16H92.69A15.86,15.86,0,0,0,104,219.31L227.31,96a16,16,0,0,0,0-22.63ZM92.69,208H48V163.31l88-88L180.69,120ZM192,108.68,147.31,64l24-24L216,84.68Z`}))],[`fill`,J.createElement(J.Fragment,null,J.createElement(`path`,{d:`M227.31,73.37,182.63,28.68a16,16,0,0,0-22.63,0L36.69,152A15.86,15.86,0,0,0,32,163.31V208a16,16,0,0,0,16,16H92.69A15.86,15.86,0,0,0,104,219.31L227.31,96a16,16,0,0,0,0-22.63ZM192,108.68,147.31,64l24-24L216,84.68Z`}))],[`light`,J.createElement(J.Fragment,null,J.createElement(`path`,{d:`M225.9,74.78,181.21,30.09a14,14,0,0,0-19.8,0L38.1,153.41a13.94,13.94,0,0,0-4.1,9.9V208a14,14,0,0,0,14,14H92.69a13.94,13.94,0,0,0,9.9-4.1L225.9,94.58a14,14,0,0,0,0-19.8ZM94.1,209.41a2,2,0,0,1-1.41.59H48a2,2,0,0,1-2-2V163.31a2,2,0,0,1,.59-1.41L136,72.48,183.51,120ZM217.41,86.1,192,111.51,144.49,64,169.9,38.58a2,2,0,0,1,2.83,0l44.68,44.69a2,2,0,0,1,0,2.83Z`}))],[`regular`,J.createElement(J.Fragment,null,J.createElement(`path`,{d:`M227.31,73.37,182.63,28.68a16,16,0,0,0-22.63,0L36.69,152A15.86,15.86,0,0,0,32,163.31V208a16,16,0,0,0,16,16H92.69A15.86,15.86,0,0,0,104,219.31L227.31,96a16,16,0,0,0,0-22.63ZM92.69,208H48V163.31l88-88L180.69,120ZM192,108.68,147.31,64l24-24L216,84.68Z`}))],[`thin`,J.createElement(J.Fragment,null,J.createElement(`path`,{d:`M224.49,76.2,179.8,31.51a12,12,0,0,0-17,0L133.17,61.17h0L39.52,154.83A11.9,11.9,0,0,0,36,163.31V208a12,12,0,0,0,12,12H92.69a12,12,0,0,0,8.48-3.51L224.48,93.17a12,12,0,0,0,0-17Zm-129,134.63A4,4,0,0,1,92.69,212H48a4,4,0,0,1-4-4V163.31a4,4,0,0,1,1.17-2.83L136,69.65,186.34,120ZM218.83,87.51,192,114.34,141.66,64l26.82-26.83a4,4,0,0,1,5.66,0l44.69,44.68a4,4,0,0,1,0,5.66Z`}))]]),Tt=new Map([[`bold`,J.createElement(J.Fragment,null,J.createElement(`path`,{d:`M144.49,136.49l-40,40a12,12,0,0,1-17-17L107,140H24a12,12,0,0,1,0-24h83L87.51,96.49a12,12,0,0,1,17-17l40,40A12,12,0,0,1,144.49,136.49ZM200,28H136a12,12,0,0,0,0,24h52V204H136a12,12,0,0,0,0,24h64a12,12,0,0,0,12-12V40A12,12,0,0,0,200,28Z`}))],[`duotone`,J.createElement(J.Fragment,null,J.createElement(`path`,{d:`M200,40V216H40a16,16,0,0,1-16-16V56A16,16,0,0,1,40,40Z`,opacity:`0.2`}),J.createElement(`path`,{d:`M141.66,133.66l-40,40a8,8,0,0,1-11.32-11.32L116.69,136H24a8,8,0,0,1,0-16h92.69L90.34,93.66a8,8,0,0,1,11.32-11.32l40,40A8,8,0,0,1,141.66,133.66ZM200,32H136a8,8,0,0,0,0,16h56V208H136a8,8,0,0,0,0,16h64a8,8,0,0,0,8-8V40A8,8,0,0,0,200,32Z`}))],[`fill`,J.createElement(J.Fragment,null,J.createElement(`path`,{d:`M141.66,133.66l-40,40A8,8,0,0,1,88,168V136H24a8,8,0,0,1,0-16H88V88a8,8,0,0,1,13.66-5.66l40,40A8,8,0,0,1,141.66,133.66ZM200,32H136a8,8,0,0,0,0,16h56V208H136a8,8,0,0,0,0,16h64a8,8,0,0,0,8-8V40A8,8,0,0,0,200,32Z`}))],[`light`,J.createElement(J.Fragment,null,J.createElement(`path`,{d:`M140.24,132.24l-40,40a6,6,0,0,1-8.48-8.48L121.51,134H24a6,6,0,0,1,0-12h97.51L91.76,92.24a6,6,0,0,1,8.48-8.48l40,40A6,6,0,0,1,140.24,132.24ZM200,34H136a6,6,0,0,0,0,12h58V210H136a6,6,0,0,0,0,12h64a6,6,0,0,0,6-6V40A6,6,0,0,0,200,34Z`}))],[`regular`,J.createElement(J.Fragment,null,J.createElement(`path`,{d:`M141.66,133.66l-40,40a8,8,0,0,1-11.32-11.32L116.69,136H24a8,8,0,0,1,0-16h92.69L90.34,93.66a8,8,0,0,1,11.32-11.32l40,40A8,8,0,0,1,141.66,133.66ZM200,32H136a8,8,0,0,0,0,16h56V208H136a8,8,0,0,0,0,16h64a8,8,0,0,0,8-8V40A8,8,0,0,0,200,32Z`}))],[`thin`,J.createElement(J.Fragment,null,J.createElement(`path`,{d:`M138.83,130.83l-40,40a4,4,0,0,1-5.66-5.66L126.34,132H24a4,4,0,0,1,0-8H126.34L93.17,90.83a4,4,0,0,1,5.66-5.66l40,40A4,4,0,0,1,138.83,130.83ZM200,36H136a4,4,0,0,0,0,8h60V212H136a4,4,0,0,0,0,8h64a4,4,0,0,0,4-4V40A4,4,0,0,0,200,36Z`}))]]),Et=new Map([[`bold`,J.createElement(J.Fragment,null,J.createElement(`path`,{d:`M128,44a96,96,0,1,0,96,96A96.11,96.11,0,0,0,128,44Zm0,168a72,72,0,1,1,72-72A72.08,72.08,0,0,1,128,212ZM164.49,99.51a12,12,0,0,1,0,17l-28,28a12,12,0,0,1-17-17l28-28A12,12,0,0,1,164.49,99.51ZM92,16A12,12,0,0,1,104,4h48a12,12,0,0,1,0,24H104A12,12,0,0,1,92,16Z`}))],[`duotone`,J.createElement(J.Fragment,null,J.createElement(`path`,{d:`M216,136a88,88,0,1,1-88-88A88,88,0,0,1,216,136Z`,opacity:`0.2`}),J.createElement(`path`,{d:`M128,40a96,96,0,1,0,96,96A96.11,96.11,0,0,0,128,40Zm0,176a80,80,0,1,1,80-80A80.09,80.09,0,0,1,128,216ZM173.66,90.34a8,8,0,0,1,0,11.32l-40,40a8,8,0,0,1-11.32-11.32l40-40A8,8,0,0,1,173.66,90.34ZM96,16a8,8,0,0,1,8-8h48a8,8,0,0,1,0,16H104A8,8,0,0,1,96,16Z`}))],[`fill`,J.createElement(J.Fragment,null,J.createElement(`path`,{d:`M128,40a96,96,0,1,0,96,96A96.11,96.11,0,0,0,128,40Zm45.66,61.66-40,40a8,8,0,0,1-11.32-11.32l40-40a8,8,0,0,1,11.32,11.32ZM96,16a8,8,0,0,1,8-8h48a8,8,0,0,1,0,16H104A8,8,0,0,1,96,16Z`}))],[`light`,J.createElement(J.Fragment,null,J.createElement(`path`,{d:`M128,42a94,94,0,1,0,94,94A94.11,94.11,0,0,0,128,42Zm0,176a82,82,0,1,1,82-82A82.1,82.1,0,0,1,128,218ZM172.24,91.76a6,6,0,0,1,0,8.48l-40,40a6,6,0,1,1-8.48-8.48l40-40A6,6,0,0,1,172.24,91.76ZM98,16a6,6,0,0,1,6-6h48a6,6,0,0,1,0,12H104A6,6,0,0,1,98,16Z`}))],[`regular`,J.createElement(J.Fragment,null,J.createElement(`path`,{d:`M128,40a96,96,0,1,0,96,96A96.11,96.11,0,0,0,128,40Zm0,176a80,80,0,1,1,80-80A80.09,80.09,0,0,1,128,216ZM173.66,90.34a8,8,0,0,1,0,11.32l-40,40a8,8,0,0,1-11.32-11.32l40-40A8,8,0,0,1,173.66,90.34ZM96,16a8,8,0,0,1,8-8h48a8,8,0,0,1,0,16H104A8,8,0,0,1,96,16Z`}))],[`thin`,J.createElement(J.Fragment,null,J.createElement(`path`,{d:`M128,44a92,92,0,1,0,92,92A92.1,92.1,0,0,0,128,44Zm0,176a84,84,0,1,1,84-84A84.09,84.09,0,0,1,128,220ZM170.83,93.17a4,4,0,0,1,0,5.66l-40,40a4,4,0,1,1-5.66-5.66l40-40A4,4,0,0,1,170.83,93.17ZM100,16a4,4,0,0,1,4-4h48a4,4,0,0,1,0,8H104A4,4,0,0,1,100,16Z`}))]]),Y=new Map([[`bold`,J.createElement(J.Fragment,null,J.createElement(`path`,{d:`M228,144v64a12,12,0,0,1-12,12H40a12,12,0,0,1-12-12V144a12,12,0,0,1,24,0v52H204V144a12,12,0,0,1,24,0ZM96.49,80.49,116,61v83a12,12,0,0,0,24,0V61l19.51,19.52a12,12,0,1,0,17-17l-40-40a12,12,0,0,0-17,0l-40,40a12,12,0,1,0,17,17Z`}))],[`duotone`,J.createElement(J.Fragment,null,J.createElement(`path`,{d:`M216,48V208H40V48A16,16,0,0,1,56,32H200A16,16,0,0,1,216,48Z`,opacity:`0.2`}),J.createElement(`path`,{d:`M224,144v64a8,8,0,0,1-8,8H40a8,8,0,0,1-8-8V144a8,8,0,0,1,16,0v56H208V144a8,8,0,0,1,16,0ZM93.66,77.66,120,51.31V144a8,8,0,0,0,16,0V51.31l26.34,26.35a8,8,0,0,0,11.32-11.32l-40-40a8,8,0,0,0-11.32,0l-40,40A8,8,0,0,0,93.66,77.66Z`}))],[`fill`,J.createElement(J.Fragment,null,J.createElement(`path`,{d:`M224,144v64a8,8,0,0,1-8,8H40a8,8,0,0,1-8-8V144a8,8,0,0,1,16,0v56H208V144a8,8,0,0,1,16,0ZM88,80h32v64a8,8,0,0,0,16,0V80h32a8,8,0,0,0,5.66-13.66l-40-40a8,8,0,0,0-11.32,0l-40,40A8,8,0,0,0,88,80Z`}))],[`light`,J.createElement(J.Fragment,null,J.createElement(`path`,{d:`M222,144v64a6,6,0,0,1-6,6H40a6,6,0,0,1-6-6V144a6,6,0,0,1,12,0v58H210V144a6,6,0,0,1,12,0ZM92.24,76.24,122,46.49V144a6,6,0,0,0,12,0V46.49l29.76,29.75a6,6,0,0,0,8.48-8.48l-40-40a6,6,0,0,0-8.48,0l-40,40a6,6,0,0,0,8.48,8.48Z`}))],[`regular`,J.createElement(J.Fragment,null,J.createElement(`path`,{d:`M224,144v64a8,8,0,0,1-8,8H40a8,8,0,0,1-8-8V144a8,8,0,0,1,16,0v56H208V144a8,8,0,0,1,16,0ZM93.66,77.66,120,51.31V144a8,8,0,0,0,16,0V51.31l26.34,26.35a8,8,0,0,0,11.32-11.32l-40-40a8,8,0,0,0-11.32,0l-40,40A8,8,0,0,0,93.66,77.66Z`}))],[`thin`,J.createElement(J.Fragment,null,J.createElement(`path`,{d:`M220,144v64a4,4,0,0,1-4,4H40a4,4,0,0,1-4-4V144a4,4,0,0,1,8,0v60H212V144a4,4,0,0,1,8,0ZM90.83,74.83,124,41.66V144a4,4,0,0,0,8,0V41.66l33.17,33.17a4,4,0,1,0,5.66-5.66l-40-40a4,4,0,0,0-5.66,0l-40,40a4,4,0,0,0,5.66,5.66Z`}))]]),Dt=new Map([[`bold`,J.createElement(J.Fragment,null,J.createElement(`path`,{d:`M168.49,104.49,145,128l23.52,23.51a12,12,0,0,1-17,17L128,145l-23.51,23.52a12,12,0,0,1-17-17L111,128,87.51,104.49a12,12,0,0,1,17-17L128,111l23.51-23.52a12,12,0,0,1,17,17ZM236,128A108,108,0,1,1,128,20,108.12,108.12,0,0,1,236,128Zm-24,0a84,84,0,1,0-84,84A84.09,84.09,0,0,0,212,128Z`}))],[`duotone`,J.createElement(J.Fragment,null,J.createElement(`path`,{d:`M224,128a96,96,0,1,1-96-96A96,96,0,0,1,224,128Z`,opacity:`0.2`}),J.createElement(`path`,{d:`M165.66,101.66,139.31,128l26.35,26.34a8,8,0,0,1-11.32,11.32L128,139.31l-26.34,26.35a8,8,0,0,1-11.32-11.32L116.69,128,90.34,101.66a8,8,0,0,1,11.32-11.32L128,116.69l26.34-26.35a8,8,0,0,1,11.32,11.32ZM232,128A104,104,0,1,1,128,24,104.11,104.11,0,0,1,232,128Zm-16,0a88,88,0,1,0-88,88A88.1,88.1,0,0,0,216,128Z`}))],[`fill`,J.createElement(J.Fragment,null,J.createElement(`path`,{d:`M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm37.66,130.34a8,8,0,0,1-11.32,11.32L128,139.31l-26.34,26.35a8,8,0,0,1-11.32-11.32L116.69,128,90.34,101.66a8,8,0,0,1,11.32-11.32L128,116.69l26.34-26.35a8,8,0,0,1,11.32,11.32L139.31,128Z`}))],[`light`,J.createElement(J.Fragment,null,J.createElement(`path`,{d:`M164.24,100.24,136.48,128l27.76,27.76a6,6,0,1,1-8.48,8.48L128,136.48l-27.76,27.76a6,6,0,0,1-8.48-8.48L119.52,128,91.76,100.24a6,6,0,0,1,8.48-8.48L128,119.52l27.76-27.76a6,6,0,0,1,8.48,8.48ZM230,128A102,102,0,1,1,128,26,102.12,102.12,0,0,1,230,128Zm-12,0a90,90,0,1,0-90,90A90.1,90.1,0,0,0,218,128Z`}))],[`regular`,J.createElement(J.Fragment,null,J.createElement(`path`,{d:`M165.66,101.66,139.31,128l26.35,26.34a8,8,0,0,1-11.32,11.32L128,139.31l-26.34,26.35a8,8,0,0,1-11.32-11.32L116.69,128,90.34,101.66a8,8,0,0,1,11.32-11.32L128,116.69l26.34-26.35a8,8,0,0,1,11.32,11.32ZM232,128A104,104,0,1,1,128,24,104.11,104.11,0,0,1,232,128Zm-16,0a88,88,0,1,0-88,88A88.1,88.1,0,0,0,216,128Z`}))],[`thin`,J.createElement(J.Fragment,null,J.createElement(`path`,{d:`M162.83,98.83,133.66,128l29.17,29.17a4,4,0,0,1-5.66,5.66L128,133.66,98.83,162.83a4,4,0,0,1-5.66-5.66L122.34,128,93.17,98.83a4,4,0,0,1,5.66-5.66L128,122.34l29.17-29.17a4,4,0,1,1,5.66,5.66ZM228,128A100,100,0,1,1,128,28,100.11,100.11,0,0,1,228,128Zm-8,0a92,92,0,1,0-92,92A92.1,92.1,0,0,0,220,128Z`}))]]),Ot=J.forwardRef((e,t)=>J.createElement(b,{ref:t,...e,weights:bt}));Ot.displayName=`CalendarCheckIcon`;var kt=Ot,At=J.forwardRef((e,t)=>J.createElement(b,{ref:t,...e,weights:xt}));At.displayName=`DotsThreeVerticalIcon`;var jt=At,Mt=J.forwardRef((e,t)=>J.createElement(b,{ref:t,...e,weights:St}));Mt.displayName=`DownloadSimpleIcon`;var Nt=Mt,Pt=J.forwardRef((e,t)=>J.createElement(b,{ref:t,...e,weights:Ct}));Pt.displayName=`FileCodeIcon`;var Ft=Pt,It=J.forwardRef((e,t)=>J.createElement(b,{ref:t,...e,weights:wt}));It.displayName=`PencilSimpleIcon`;var X=It,Lt=J.forwardRef((e,t)=>J.createElement(b,{ref:t,...e,weights:Tt}));Lt.displayName=`SignInIcon`;var Rt=Lt,zt=J.forwardRef((e,t)=>J.createElement(b,{ref:t,...e,weights:Et}));zt.displayName=`TimerIcon`;var Bt=zt,Vt=J.forwardRef((e,t)=>J.createElement(b,{ref:t,...e,weights:Y}));Vt.displayName=`UploadSimpleIcon`;var Ht=Vt,Ut=J.forwardRef((e,t)=>J.createElement(b,{ref:t,...e,weights:Dt}));Ut.displayName=`XCircleIcon`;var Wt=Ut,Gt=E({slots:{menu:`dropdown__menu`,popover:`dropdown__popover`,root:`dropdown`,trigger:`dropdown__trigger`}}),Kt=E({defaultVariants:{color:`accent`,size:`md`},slots:{base:`meter`,fill:`meter__fill`,output:`meter__output`,track:`meter__track`},variants:{color:{accent:{base:`meter--accent`},danger:{base:`meter--danger`},default:{base:`meter--default`},success:{base:`meter--success`},warning:{base:`meter--warning`}},size:{lg:{base:`meter--lg`},md:{base:`meter--md`},sm:{base:`meter--sm`}}}}),qt=E({defaultVariants:{variant:`default`},slots:{indicator:`menu-item__indicator`,item:`menu-item`,submenuIndicator:`menu-item__indicator menu-item__indicator--submenu`},variants:{variant:{danger:{item:`menu-item--danger`},default:{item:`menu-item--default`}}}}),Jt=E({base:`menu-section`});function Yt(e){let{value:t=0,minValue:n=0,maxValue:r=100,valueLabel:i,isIndeterminate:a,formatOptions:o={style:`percent`}}=e,s=ce(e,{labelable:!0}),{labelProps:c,fieldProps:l}=de({...e,labelElementType:`span`});t=x(t,n,r);let u=r-n,d=u===0?0:(t-n)/u,f=ve(o);if(!a&&!i){let e=o.style===`percent`?d:t;i=f.format(e)}return{progressBarProps:w(s,{...l,"aria-valuenow":a?void 0:t,"aria-valuemin":n,"aria-valuemax":r,"aria-valuetext":a?void 0:i,role:`progressbar`}),labelProps:c}}function Xt(e){let{progressBarProps:t,labelProps:n}=Yt(e);return{meterProps:{...t,role:`meter progressbar`},labelProps:n}}var Zt=(0,J.createContext)(null),Qt=(0,J.forwardRef)(function(e,t){[e,t]=se(e,t,Zt);let{value:n=0,minValue:r=0,maxValue:i=100}=e;n=x(n,r,i);let a=i-r,[o,s]=T(!e[`aria-label`]&&!e[`aria-labelledby`]),{meterProps:c,labelProps:l}=Xt({...e,label:s}),u=a===0?0:(n-r)/a*100,d=ae({...e,defaultClassName:`react-aria-Meter`,values:{percentage:u,valueText:c[`aria-valuetext`]}}),f=ce(e,{global:!0});return J.createElement(ie.div,{...w(f,d,c),ref:t,slot:e.slot||void 0},J.createElement(ue.Provider,{value:{...l,ref:o,elementType:`span`}},d.children))}),Z=n(),$t=(0,J.createContext)({}),en=({children:e,className:t,variant:n,...r})=>{let i=J.useMemo(()=>qt({variant:n}),[n]);return(0,Z.jsx)(Ge,{className:oe(t,i.item()),"data-slot":`menu-item`,...r,children:t=>(0,Z.jsx)($t,{value:{slots:i,state:t},children:typeof e==`function`?e(t):e})})},tn=({children:e,className:t,type:n=`checkmark`,...r})=>{let{slots:i,state:a}=(0,J.use)($t),o=a?.isSelected,s=typeof e==`function`?e(a??{}):e||(n===`dot`?(0,Z.jsx)(`svg`,{"aria-hidden":`true`,"data-slot":`menu-item-indicator--dot`,fill:`currentColor`,fillRule:`evenodd`,role:`presentation`,viewBox:`0 0 16 16`,xmlns:`http://www.w3.org/2000/svg`,children:(0,Z.jsx)(`path`,{clipRule:`evenodd`,d:`M8 15A7 7 0 1 0 8 1a7 7 0 0 0 0 14`,fillRule:`evenodd`})}):(0,Z.jsx)(`svg`,{"aria-hidden":`true`,"data-slot":`menu-item-indicator--checkmark`,fill:`none`,role:`presentation`,stroke:`currentColor`,strokeDasharray:22,strokeDashoffset:o?44:66,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,viewBox:`0 0 17 18`,children:(0,Z.jsx)(`polyline`,{points:`1 9 7 14 15 4`})}));return(0,Z.jsx)(C.span,{"aria-hidden":`true`,className:le(i?.indicator,t),"data-slot":`menu-item-indicator`,"data-type":n,"data-visible":o||void 0,...r,children:s})},nn=({children:e,className:t,...n})=>{let{slots:r,state:i}=(0,J.use)($t);if(!i?.hasSubmenu)return null;let a=e??(0,Z.jsx)(v,{});return(0,Z.jsx)(C.span,{"aria-hidden":`true`,className:le(r?.submenuIndicator,t),"data-slot":`submenu-indicator`,...n,children:a})},rn=({children:e,className:t,...n})=>{let r=J.useMemo(()=>Jt({class:typeof t==`string`?t:void 0}),[t]);return(0,Z.jsx)(Ze,{className:r,...n,children:e})},an=(0,J.createContext)({}),on=({children:e,...t})=>{let n=J.useMemo(()=>Gt(),[]);return(0,Z.jsx)(an,{value:{slots:n},children:(0,Z.jsx)(Ue,{...t,children:e})})},sn=({children:e,className:t,...n})=>{let{slots:r}=(0,J.use)(an);return(0,Z.jsx)(ne,{className:oe(t,r?.trigger()),"data-slot":`dropdown-trigger`,...n,children:t=>(0,Z.jsx)(Z.Fragment,{children:typeof e==`function`?e(t):e})})},cn=({children:e,className:t,placement:n,...r})=>{let{slots:i}=(0,J.use)(an);return(0,Z.jsx)(y,{value:{variant:`default`},children:(0,Z.jsx)(et,{...r,className:oe(t,i?.popover()),"data-slot":`dropdown-popover`,placement:n,children:e})})};function ln({className:e,...t}){let{slots:n}=(0,J.use)(an);return(0,Z.jsx)(We,{className:oe(e,n?.menu()),"data-selection-mode":t.selectionMode,"data-slot":`dropdown-menu`,...t})}var un=Object.assign(on,{Root:on,Trigger:sn,Popover:cn,Menu:ln,Section:e=>(0,Z.jsx)(rn,{...e}),Item:e=>(0,Z.jsx)(en,{...e}),ItemIndicator:e=>(0,Z.jsx)(tn,{...e}),SubmenuIndicator:e=>(0,Z.jsx)(nn,{...e}),SubmenuTrigger:({children:e,...t})=>(0,Z.jsx)(Je,{"data-slot":`dropdown-submenu-trigger`,...t,children:e})}),dn=(0,J.createContext)({}),fn=({children:e,className:t,color:n,size:r,...i})=>{let a=J.useMemo(()=>Kt({color:n,size:r}),[n,r]);return(0,Z.jsx)(Qt,{"data-slot":`meter`,...i,className:oe(t,a.base()),children:t=>(0,Z.jsx)(dn,{value:{slots:a,state:t},children:typeof e==`function`?e(t):e})})};fn.displayName=`HeroUI.Meter`;var pn=({children:e,className:t,...n})=>{let{slots:r,state:i}=(0,J.use)(dn);return(0,Z.jsx)(C.span,{className:le(r?.output,t),"data-slot":`meter-output`,...n,children:e??i?.valueText})};pn.displayName=`HeroUI.Meter.Output`;var mn=({children:e,className:t,...n})=>{let{slots:r}=(0,J.use)(dn);return(0,Z.jsx)(C.div,{className:le(r?.track,t),"data-slot":`meter-track`,...n,children:e})};mn.displayName=`HeroUI.Meter.Track`;var hn=({className:e,style:t,...n})=>{let{slots:r,state:i}=(0,J.use)(dn);return(0,Z.jsx)(C.div,{className:le(r?.fill,e),"data-slot":`meter-fill`,style:{...t,width:`${i?.percentage??0}%`},...n})};hn.displayName=`HeroUI.Meter.Fill`;var gn=Object.assign(fn,{Root:fn,Output:pn,Track:mn,Fill:hn}),_n=()=>()=>{},vn=new Set,yn=Date.now(),bn=null;function xn(){yn=Date.now();for(let e of vn)e()}function Sn(e){return vn.size===0&&(yn=Date.now()),vn.add(e),bn===null&&(bn=window.setInterval(xn,1e3)),()=>{vn.delete(e),vn.size===0&&bn!==null&&(window.clearInterval(bn),bn=null)}}function Cn(){return yn}function wn(e=!0){return(0,J.useSyncExternalStore)(e?Sn:_n,Cn,Cn)}function Tn(e){(0,J.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let n=L.context(()=>{L.matchMedia().add(`(prefers-reduced-motion: no-preference)`,()=>{let e=L.utils.toArray(`.meter__fill`);e.length&&L.from(e,{scaleX:0,transformOrigin:`left center`,duration:Qe.calm,ease:$e.emphasized,stagger:qe.base,clearProps:`transform,transformOrigin`})})},t);return()=>n.revert()},[e])}function En(e,t){if(!e)return``;let n=Date.parse(e);if(!Number.isFinite(n))return``;let r=Math.max(0,Math.round((Date.now()-n)/6e4));return t(r>=5?`quotaStale`:`quotaUsedAt`,{n:r})}function Dn(e,t,n,r,i,a){return[e.has_add_on&&e.add_on_available!==!1?`${n} ${at(e.add_on_used)} / ${at(e.add_on_total)} ${e.add_on_unit||`credits`}`:``,e.has_resource_package&&e.resource_package_available!==!1?`${r} ${t} ${at(e.resource_package_remaining)} ${e.resource_package_unit||`credits`}`:``,a===`workbuddy`?gt(e,i):``].filter(Boolean)}function On({window:e,t,extra:n}){let r=Math.round(e.percentage??0),i=st(e,t),a=t(`quotaUsedPercent`,{n:r}),o=ot(e.reset_at,t),s=`${i} · ${a}${o?` · ${o}`:``}`,c=vt(e),l=ut(e),u=l===`danger`?`danger`:l===`warn`?`warning`:`success`;return(0,Z.jsxs)(G,{children:[(0,Z.jsx)(G.Trigger,{className:`block w-full min-w-0`,children:(0,Z.jsxs)(`div`,{className:`w-full min-w-0 cursor-help`,children:[(0,Z.jsxs)(gn,{className:`account-meter account-meter--window w-full`,color:u,size:`md`,minValue:0,maxValue:100,value:Math.round(c*100),"aria-label":i,valueLabel:s,children:[(0,Z.jsxs)(gn.Output,{className:`flex w-full items-baseline justify-between gap-3 text-caption`,children:[(0,Z.jsx)(`span`,{className:`min-w-0 truncate font-medium text-foreground`,children:i}),(0,Z.jsx)(`span`,{className:`mono shrink-0 text-foreground/70`,children:a})]}),(0,Z.jsx)(gn.Track,{children:(0,Z.jsx)(gn.Fill,{})})]}),o?(0,Z.jsx)(`div`,{className:`mt-1 text-caption leading-4 text-muted`,children:o}):null]})}),(0,Z.jsx)(G.Content,{children:(0,Z.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,Z.jsx)(`div`,{children:s}),n?.map(e=>(0,Z.jsx)(`div`,{children:e},e))]})})]})}function kn({quota:e,t,label:n,usedLabel:r,remainingLabel:i,addOnLabel:a,resourcePackageLabel:o,exceededLabel:s,provider:c}){let l=e.unit||`credits`,u=`${at(e.used)} / ${at(e.total)}`,d=`${at(e.remaining)}`,f=Dn(e,i,a,o,t,c),p=ct(e),m=c===`codex`||c===`kiro`?ht(e.plan):``,ee=vt(e),h=ut(e),te=h===`danger`?`danger`:h===`warn`?`warning`:`success`,g=(0,J.useRef)(null);Tn(g);let _=En(e.fetched_at,t),v=`${r} ${u} ${l} · ${i} ${d} ${l}${f.length?` · ${f.join(` · `)}`:``}`;return p.length>0?(0,Z.jsxs)(`div`,{ref:g,className:`account-quota-windows flex w-full min-w-0 flex-col gap-3`,children:[m?(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-caption`,children:[(0,Z.jsx)(`span`,{className:`text-muted`,children:t(`quotaPlan`)}),(0,Z.jsx)(`span`,{className:`font-medium text-foreground`,children:m})]}):null,p.map((e,n)=>(0,Z.jsx)(`div`,{className:`w-full min-w-0`,children:(0,Z.jsx)(On,{window:e,t,extra:n===0?f:void 0})},e.id||String(n))),_?(0,Z.jsx)(`div`,{className:`text-caption leading-4 text-muted`,children:_}):null]}):(0,Z.jsxs)(G,{children:[(0,Z.jsx)(G.Trigger,{children:(0,Z.jsxs)(`div`,{ref:g,className:`w-full cursor-help`,children:[(0,Z.jsxs)(gn,{className:`account-meter w-full`,color:te,size:`md`,minValue:0,maxValue:100,value:Math.round(ee*100),"aria-label":n,valueLabel:v,children:[(0,Z.jsxs)(gn.Output,{className:`flex w-full items-baseline justify-between text-caption`,children:[(0,Z.jsxs)(`span`,{className:`text-body font-semibold leading-5 text-foreground tabular-nums`,children:[e.exceeded?(0,Z.jsx)(`span`,{className:`mr-1.5 text-danger`,children:s}):(0,Z.jsx)(`span`,{className:`mr-1.5 text-caption font-normal text-muted`,children:i}),d,(0,Z.jsx)(`span`,{className:`ml-1 text-caption font-normal text-foreground/60`,children:l})]}),(0,Z.jsxs)(`span`,{className:`mono text-foreground/55`,children:[u,` · `,Math.round(ee*100),`%`]})]}),(0,Z.jsx)(gn.Track,{children:(0,Z.jsx)(gn.Fill,{})})]}),_?(0,Z.jsx)(`div`,{className:`mt-1 text-caption leading-4 text-muted`,children:_}):null]})}),(0,Z.jsx)(G.Content,{children:(0,Z.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,Z.jsxs)(`div`,{children:[r,` `,u,` `,l]}),(0,Z.jsxs)(`div`,{children:[i,` `,d,` `,l]}),f.map(e=>(0,Z.jsx)(`div`,{children:e},e)),_?(0,Z.jsx)(`div`,{children:_}):null]})})]})}function An({state:e,stateCopy:t,t:n}){let r=(0,J.useRef)(null),i=mt(e),a=dt(e);return(0,J.useLayoutEffect)(()=>{let e=r.current;if(!e)return;let t=L.context(()=>{let e=L.utils.toArray(`[data-runtime-seg]`),t=e.filter((e,t)=>tt>=i),r=L.matchMedia();r.add(`(prefers-reduced-motion: reduce)`,()=>{L.set(t,{scaleY:1,autoAlpha:1}),L.set(n,{scaleY:.32,autoAlpha:.45})}),r.add(`(prefers-reduced-motion: no-preference)`,()=>{L.set(e,{transformOrigin:`center bottom`}),L.to(n,{scaleY:.32,autoAlpha:.45,duration:Qe.fast,ease:$e.out,overwrite:!0}),L.to(t,{scaleY:1,autoAlpha:1,duration:Qe.base,ease:$e.out,stagger:{amount:.08,from:`start`},overwrite:!0})})},e);return()=>t.revert()},[i,e]),(0,Z.jsx)(`div`,{ref:r,className:`flex items-center`,children:(0,Z.jsx)(`div`,{className:`runtime-meter min-w-[80px] flex-1`,"data-quiet":a===`ok`?`true`:void 0,role:`meter`,"aria-label":n(`runtimeState`),"aria-valuemin":0,"aria-valuemax":12,"aria-valuenow":i,"aria-valuetext":t,children:Array.from({length:12},(e,t)=>(0,Z.jsx)(`span`,{"data-runtime-seg":!0,"data-on":t{if(T)return Te.current&&window.clearTimeout(Te.current),Te.current=window.setTimeout(()=>Ce(T),3e3),()=>{Te.current&&window.clearTimeout(Te.current)}},[T]);let De=Mn(k,k===`dead`?M:j,u),Oe=k===`hot`||k===`ready`?`success`:k===`cooling`?`warning`:k===`quota_exhausted`||k===`login`||k===`unavailable`||k===`dead`||k===`auth_failed`?`danger`:void 0,ke=e.last_error||e.lastError,Ae=e.last_error_kind||e.kind,je=rt(e.provider,e.region,u),Me=String(e.region||``).toLowerCase(),Ne=Me===`cn`?u(`regionCN`):Me===`global`?u(`regionGlobal`):``,Pe=e.remote_uid||e.id,Fe=Pe.length>12?Pe.slice(0,8):Pe,Ie=e.last_checkin_status,Le=Ie===`success`?`checkinRecordSuccess`:Ie===`already`?`checkinRecordAlready`:Ie===`pending`?`checkinStatusPending`:Ie===`unknown`?`checkinStatusUnknown`:Ie===`skipped`?`checkinRecordSkipped`:Ie===`error`?`checkinRecordFailed`:`lastCheckinNone`,Re=ft(e,C),ze=e.checkin_time||e.checkin_auto_time||re,I=C&&C!==`Local`?C:`Asia/Shanghai`,Be=e.last_checkin_synced_at?jn(e.last_checkin_synced_at,I):``;return(0,J.useLayoutEffect)(()=>{let e=de.current;if(!e)return;let t=be.current;if(be.current=k,!t||t===k)return;let n=L.context(()=>{let t=L.matchMedia();t.add(`(prefers-reduced-motion: reduce)`,()=>{L.set(e,{scale:1,autoAlpha:1})}),t.add(`(prefers-reduced-motion: no-preference)`,()=>{L.fromTo(e,{scale:.94,autoAlpha:.65},{scale:1,autoAlpha:1,duration:.2,ease:`power2.out`,overwrite:!0})})},e);return()=>n.revert()},[k]),(0,J.useLayoutEffect)(()=>{let e=pe.current;if(!e||!n)return;let t=L.context(()=>{let t=L.matchMedia();t.add(`(prefers-reduced-motion: reduce)`,()=>{L.set(e,{autoAlpha:1,y:0})}),t.add(`(prefers-reduced-motion: no-preference)`,()=>{L.fromTo(e,{autoAlpha:0,y:-6},{autoAlpha:1,y:0,duration:.2,ease:`power3.out`,overwrite:!0})})},e);return()=>t.revert()},[n]),(0,Z.jsxs)(_e,{"data-gsap-reveal":!0,"data-state":k,className:`account-card overflow-hidden p-0`,children:[(0,Z.jsxs)(_e.Header,{className:`flex-row items-start justify-between gap-2.5 px-4 pt-3.5 pb-2`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[le?(0,Z.jsx)(D,{isSelected:E,onChange:()=>ue?.(),className:`shrink-0`,children:(0,Z.jsx)(D.Content,{"aria-label":`${u(`reloginSelectAccount`)} ${e.name||e.id}`,className:`cursor-pointer p-1`,children:(0,Z.jsx)(D.Control,{children:(0,Z.jsx)(D.Indicator,{})})})}):null,(0,Z.jsx)(`div`,{className:`flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-tertiary ${E?`ring-2 ring-accent`:``}`,title:je,children:(0,Z.jsx)(nt,{provider:e.provider,size:20})}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(_e.Title,{className:`truncate text-body leading-5`,children:e.name||e.id}),Ne?(0,Z.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-secondary px-1.5 py-px text-caption text-muted`,title:je,children:Ne}):null]}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1`,children:[(0,Z.jsx)(_e.Description,{className:`mono truncate text-caption leading-4 text-foreground/60`,title:`${e.id}${e.remote_uid?` · UID ${e.remote_uid}`:``}`,children:Fe}),(0,Z.jsx)(S,{isIconOnly:!0,size:`sm`,variant:`ghost`,className:`size-5 min-w-0 shrink-0 text-muted`,"aria-label":u(ge?`copied`:`copy`),onPress:()=>{f(Pe).then(e=>{e&&(ve(!0),window.setTimeout(()=>ve(!1),1100))})},children:(0,Z.jsx)(a,{copied:ge,size:12})})]})]})]}),(0,Z.jsxs)(`div`,{className:`flex max-w-[48%] shrink-0 flex-wrap justify-end gap-1.5`,children:[(0,Z.jsx)(`span`,{ref:de,children:N.length&&k===`cooling`?(0,Z.jsxs)(G,{children:[(0,Z.jsx)(G.Trigger,{children:(0,Z.jsx)(`span`,{className:`inline-flex cursor-help`,children:(0,Z.jsx)(B,{size:`sm`,variant:`soft`,color:Oe,children:De})})}),(0,Z.jsx)(G.Content,{children:(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(`div`,{className:`font-medium`,children:u(`partialCooling`)}),N.map(([e,t])=>(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-4 text-caption`,children:[(0,Z.jsx)(`span`,{children:e}),(0,Z.jsx)(`span`,{className:`mono text-foreground/65`,children:lt(t)})]},e))]})})]}):(0,Z.jsx)(B,{size:`sm`,variant:`soft`,color:Oe,children:De})}),e.force_ready_override?(0,Z.jsxs)(G,{children:[(0,Z.jsx)(G.Trigger,{children:(0,Z.jsx)(`span`,{className:`inline-flex cursor-help`,children:(0,Z.jsx)(B,{size:`sm`,variant:`soft`,color:`warning`,children:u(`forceReadyBadge`)})})}),(0,Z.jsx)(G.Content,{children:u(`forceReadyHint`)})]}):null,N.length&&k!==`cooling`?(0,Z.jsxs)(G,{children:[(0,Z.jsx)(G.Trigger,{children:(0,Z.jsx)(`span`,{className:`inline-flex cursor-help`,children:(0,Z.jsx)(B,{size:`sm`,variant:`soft`,color:`warning`,children:u(`partialCooling`)})})}),(0,Z.jsx)(G.Content,{children:(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(`div`,{className:`font-medium`,children:u(`partialCooling`)}),N.map(([e,t])=>(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-4 text-caption`,children:[(0,Z.jsx)(`span`,{children:e}),(0,Z.jsx)(`span`,{className:`mono text-foreground/65`,children:lt(t)})]},e))]})})]}):null]})]}),(0,Z.jsxs)(_e.Content,{className:`gap-1.5 px-4 pb-3`,children:[(0,Z.jsx)(An,{state:k,stateCopy:De,t:u}),e.quota?(0,Z.jsx)(kn,{quota:e.quota,t:u,label:u(`quota`),usedLabel:u(`quotaUsed`),remainingLabel:u(`quotaRemaining`),addOnLabel:u(`quotaAddOn`),resourcePackageLabel:u(`quotaResourcePackage`),exceededLabel:u(`quotaExceeded`),provider:e.provider}):(0,Z.jsx)(`span`,{className:`text-caption text-foreground/65`,children:u(k===`hot`||k===`ready`||k===`loading`||k===`starting`?`quotaLoading`:`quotaUnavailable`)}),ke?(0,Z.jsxs)(G,{children:[(0,Z.jsx)(G.Trigger,{children:(0,Z.jsxs)(`div`,{className:`flex w-full cursor-help gap-2 rounded-lg bg-surface-secondary p-2 text-left text-caption leading-5 text-foreground`,children:[(0,Z.jsx)(He,{size:14,className:`mt-0.5 shrink-0 text-danger`}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[Ae?(0,Z.jsx)(`div`,{className:`mono mb-0.5 truncate text-caption opacity-75`,children:Ae}):null,(0,Z.jsx)(`p`,{className:`break-words line-clamp-3`,children:ke})]})]})}),(0,Z.jsx)(G.Content,{children:(0,Z.jsxs)(`div`,{className:`max-w-md whitespace-pre-wrap break-words`,children:[Ae?(0,Z.jsx)(`div`,{className:`mono mb-1 text-caption opacity-75`,children:Ae}):null,ke]})})]}):null,F?(0,Z.jsxs)(`div`,{className:`flex w-full items-start gap-2 rounded-lg bg-surface-secondary p-2 text-caption leading-5`,children:[F.kind===`success`?(0,Z.jsx)(H,{size:14,weight:`fill`,className:`mt-0.5 shrink-0 text-success`}):F.kind===`error`?(0,Z.jsx)(Wt,{size:14,weight:`fill`,className:`mt-0.5 shrink-0 text-danger`}):(0,Z.jsx)(He,{size:14,weight:`fill`,className:`mt-0.5 shrink-0 text-warning`}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[F.kind===`success`?(0,Z.jsx)(`span`,{className:`font-medium text-success`,children:u(`checkinRecordSuccess`)}):F.kind===`already`?(0,Z.jsx)(`span`,{className:`font-medium text-warning`,children:u(`checkinRecordAlready`)}):F.kind===`skipped`?(0,Z.jsx)(`span`,{className:`font-medium text-warning`,children:u(`checkinRecordSkipped`)}):F.kind===`unknown`?(0,Z.jsx)(`span`,{className:`font-medium text-muted`,children:u(`checkinStatusUnknown`)}):(0,Z.jsx)(`span`,{className:`font-medium text-danger`,children:u(`checkinRecordFailed`)}),F.message?(0,Z.jsxs)(`div`,{className:`mt-0.5`,children:[(0,Z.jsx)(`p`,{className:`break-words line-clamp-2 text-foreground/80`,children:F.message}),(0,Z.jsxs)(`div`,{className:`mt-1 flex items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-caption text-muted`,children:u(`checkinTruncated`)}),(0,Z.jsxs)(S,{size:`sm`,variant:`ghost`,className:`h-6 min-w-0 gap-1 px-1.5 text-caption`,onPress:()=>{f(F.message||``).then(e=>{!e||!F||(P(F),window.setTimeout(()=>P(null),1100))})},children:[(0,Z.jsx)(a,{copied:Ee,size:13}),u(Ee?`copied`:`checkinCopyError`)]})]})]}):null]})]}):null]}),n&&e.enabled?(0,Z.jsx)(`section`,{ref:pe,className:`grid gap-3 bg-surface-secondary/55 px-3 py-3`,children:e.provider===`doubaowork`?(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-caption font-medium text-muted`,children:u(`doubaoCookieLabel`)}),(0,Z.jsx)(`p`,{className:`mt-1.5 text-caption leading-5 text-muted`,children:u(`doubaoCookieLead`)}),(0,Z.jsxs)(`div`,{className:`mt-2.5 flex flex-col gap-2 sm:flex-row`,children:[(0,Z.jsxs)(Ve,{className:`flex-1`,type:`password`,value:l,onChange:p,children:[(0,Z.jsx)(fe,{className:`sr-only`,children:u(`doubaoCookieLabel`)}),(0,Z.jsx)(xe,{placeholder:u(`doubaoCookiePh`),"aria-label":u(`doubaoCookieLabel`)})]}),(0,Z.jsxs)(S,{size:`sm`,variant:`secondary`,isPending:t===`pat`,onPress:ee,children:[(0,Z.jsx)(Ke,{size:14}),u(`doubaoSaveCookie`)]})]}),o?(0,Z.jsx)(`p`,{className:`mt-1 text-caption text-muted`,children:o}):null]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-caption font-medium text-muted`,children:u(`oauthDeviceFlow`)}),(0,Z.jsx)(`p`,{className:`mt-1.5 text-caption leading-5 text-muted`,children:e.provider===`codex`?u(`wizardCodexBrowserLead`):u(`qoderLoginHint`)}),(0,Z.jsx)(`div`,{className:`mt-2.5 flex flex-wrap gap-2`,children:e.provider===`codex`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(S,{size:`sm`,isPending:t===`device`,onPress:()=>m(`cli`),children:[(0,Z.jsx)(g,{size:14}),u(`startCodexCliLogin`)]}),(0,Z.jsxs)(S,{size:`sm`,variant:`secondary`,isPending:t===`device`,onPress:()=>m(`chatgpt`),children:[(0,Z.jsx)(g,{size:14}),u(`startCodexChatGPTLogin`)]})]}):e.provider===`kiro`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(S,{size:`sm`,isPending:t===`device`,onPress:()=>m(`builder_id`),children:[(0,Z.jsx)(g,{size:14}),u(`kiroLoginBuilder`)]}),(0,Z.jsxs)(S,{size:`sm`,variant:`secondary`,isPending:t===`device`,onPress:()=>m(`idc`),children:[(0,Z.jsx)(g,{size:14}),u(`kiroLoginIDC`)]}),(0,Z.jsxs)(S,{size:`sm`,variant:`secondary`,isPending:t===`device`,onPress:()=>m(`microsoft`),children:[(0,Z.jsx)(g,{size:14}),u(`kiroLoginMicrosoft`)]}),(0,Z.jsxs)(S,{size:`sm`,variant:`secondary`,isPending:t===`device`,onPress:()=>m(`sso`),children:[(0,Z.jsx)(g,{size:14}),u(`kiroLoginSSO`)]})]}):(0,Z.jsxs)(S,{size:`sm`,isPending:t===`device`,onPress:()=>m(),children:[(0,Z.jsx)(g,{size:14}),u(`startBrowserLogin`)]})}),(e.provider===`trae`||e.provider===`codex`||e.provider===`devin`||e.provider===`kiro`)&&v&&te?(0,Z.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[(0,Z.jsx)(`p`,{className:`text-caption leading-4 text-muted`,children:u(`wizardCallbackLead`)}),(0,Z.jsx)(s,{className:`h-24 w-full resize-none font-mono text-caption leading-5`,value:h||``,onChange:e=>te(e.target.value),placeholder:u(`wizardCallbackPh`),"aria-label":u(`wizardCallbackPh`)}),(0,Z.jsx)(S,{size:`sm`,variant:`secondary`,isPending:t===`callback`,onPress:v,children:u(`wizardSubmitCallback`)})]}):null]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-caption font-medium text-muted`,children:u(`patFallback`)}),(0,Z.jsxs)(`div`,{className:`mt-2.5 flex flex-col gap-2 sm:flex-row`,children:[(0,Z.jsxs)(Ve,{className:`flex-1`,type:`password`,value:l,onChange:p,children:[(0,Z.jsx)(fe,{className:`sr-only`,children:u(`pat`)}),(0,Z.jsx)(xe,{placeholder:u(`pasteToken`),"aria-label":u(`pat`)})]}),(0,Z.jsxs)(S,{size:`sm`,variant:`secondary`,isPending:t===`pat`,onPress:ee,children:[(0,Z.jsx)(Ke,{size:14}),u(`usePat`)]})]})]}),r||o?(0,Z.jsxs)(`div`,{className:`text-caption`,children:[r?(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`mb-1 text-caption font-medium text-muted`,children:u(`authUrl`)}),(0,Z.jsx)(`code`,{className:`mono block break-all text-foreground`,children:r}),(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:[(0,Z.jsxs)(S,{size:`sm`,variant:`secondary`,onPress:()=>window.open(r,`_blank`,`noopener,noreferrer`),children:[(0,Z.jsx)(c,{size:14}),u(`openAuthUrl`)]}),(0,Z.jsxs)(S,{size:`sm`,variant:`ghost`,onPress:()=>{f(r).then(e=>{e&&(he(!0),window.setTimeout(()=>he(!1),1100))})},children:[(0,Z.jsx)(a,{copied:me}),u(me?`copied`:`copy`)]})]})]}):null,o?(0,Z.jsx)(`p`,{className:`mt-1 text-muted`,children:o}):null]}):null]})}):null,w?(0,Z.jsxs)(`div`,{className:`mt-auto flex items-center justify-between gap-2 px-4 pb-2.5 text-caption text-muted`,children:[(0,Z.jsxs)(G,{children:[(0,Z.jsx)(G.Trigger,{children:(0,Z.jsxs)(`span`,{className:`flex min-w-0 cursor-help flex-wrap items-center gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`font-medium text-foreground/75`,children:u(`checkinStatus`)}),(0,Z.jsx)(`span`,{className:Ie===`error`?`text-danger`:``,children:u(Le)}),!Re&&Ie===`pending`?(0,Z.jsx)(`span`,{className:`whitespace-nowrap rounded-full bg-warning/15 px-1.5 py-px font-medium text-warning`,children:u(`checkinPending`)}):null]})}),(0,Z.jsxs)(G.Content,{children:[e.last_checkin_at?u(`checkinServerTime`,{time:jn(e.last_checkin_at,I)}):u(`lastCheckinNone`),e.last_checkin_msg?` · ${e.last_checkin_msg}`:``,Be?` · ${u(`checkinUpstreamSynced`,{time:Be})}`:``]})]}),(0,Z.jsxs)(G,{children:[(0,Z.jsx)(G.Trigger,{children:(0,Z.jsxs)(`span`,{className:`flex shrink-0 cursor-help items-center gap-1.5 whitespace-nowrap`,children:[(0,Z.jsx)(`span`,{children:u(`checkinDaily`)}),(0,Z.jsx)(`span`,{className:`mono text-caption text-foreground/55`,children:ze}),(0,Z.jsx)(A,{isSelected:!!e.auto_checkin,isDisabled:!!t,ariaLabel:u(`autoCheckin`),onChange:e=>ie?.(e)})]})}),(0,Z.jsxs)(G.Content,{children:[u(`checkinAutoScheduleHint`,{time:ze??``}),` · ${u(`checkinServerClock`,{timezone:I})}`]})]})]}):null,(0,Z.jsxs)(_e.Footer,{className:`flex flex-nowrap items-center gap-1 bg-surface-secondary px-2 py-2${w?``:` mt-auto`}`,children:[ne?(0,Z.jsxs)(G,{children:[(0,Z.jsx)(G.Trigger,{children:(0,Z.jsx)(S,{isIconOnly:!0,size:`sm`,variant:`ghost`,isPending:t===`refresh`,onPress:ne,"aria-label":u(`refreshAccount`),children:(0,Z.jsx)(z,{size:15})})}),(0,Z.jsx)(G.Content,{children:u(`refreshAccount`)})]}):null,(0,Z.jsxs)(G,{children:[(0,Z.jsx)(G.Trigger,{children:(0,Z.jsx)(S,{isIconOnly:!0,size:`sm`,variant:n?`secondary`:`ghost`,isDisabled:!e.enabled,onPress:se,"aria-label":u(`authentication`),children:(0,Z.jsx)(Ke,{size:15})})}),(0,Z.jsx)(G.Content,{children:u(`authentication`)})]}),(0,Z.jsxs)(G,{children:[(0,Z.jsx)(G.Trigger,{children:(0,Z.jsx)(S,{isIconOnly:!0,size:`sm`,variant:`ghost`,onPress:oe,"aria-label":u(`editAccount`),children:(0,Z.jsx)(X,{size:15})})}),(0,Z.jsx)(G.Content,{children:u(`editAccount`)})]}),(0,Z.jsxs)(un,{children:[(0,Z.jsx)(un.Trigger,{children:(0,Z.jsxs)(S,{isIconOnly:!0,size:`sm`,variant:ye?`secondary`:`ghost`,isPending:t===`checkin`,"aria-label":u(`more`),className:`relative`,children:[(0,Z.jsx)(jt,{size:16}),N.length?(0,Z.jsx)(`span`,{className:`absolute top-1 right-1 size-1.5 rounded-full bg-warning`,"aria-hidden":!0}):null]})}),(0,Z.jsx)(un.Popover,{placement:`bottom start`,children:(0,Z.jsxs)(un.Menu,{"aria-label":u(`more`),disabledKeys:!e.enabled||t?[`checkin`]:[],onAction:e=>{e===`models`&&ce(),e===`cooldowns`&&O(e=>!e),e===`checkin`&&w?.(),e===`checkin-records`&&ae?.(),e===`export`&&y(),e===`delete`&&b()},children:[(0,Z.jsxs)(un.Item,{id:`models`,textValue:u(`accountModels`),children:[(0,Z.jsx)(R,{size:15}),u(`accountModels`)]}),(0,Z.jsxs)(un.Item,{id:`cooldowns`,textValue:u(`modelCooldowns`),children:[(0,Z.jsx)(Bt,{size:15,className:N.length?`text-warning`:void 0}),u(`modelCooldowns`),N.length?(0,Z.jsx)(`span`,{className:`mono ml-auto text-caption text-warning`,children:N.length}):null]}),w?(0,Z.jsxs)(un.Item,{id:`checkin`,textValue:u(`checkinNow`),children:[(0,Z.jsx)(kt,{size:15}),u(`checkinNow`)]}):null,ae?(0,Z.jsxs)(un.Item,{id:`checkin-records`,textValue:u(`checkinRecords`),children:[(0,Z.jsx)(i,{size:15}),u(`checkinRecords`)]}):null,e.auth_type===`none`?null:(0,Z.jsxs)(un.Item,{id:`export`,textValue:u(`export`),children:[(0,Z.jsx)(d,{size:15}),u(`export`)]}),(0,Z.jsxs)(un.Item,{id:`delete`,textValue:u(`delete`),className:`text-danger`,children:[(0,Z.jsx)(_,{size:15}),u(`delete`)]})]})})]}),(0,Z.jsx)(`div`,{className:`ml-auto flex shrink-0 flex-nowrap items-center whitespace-nowrap`,children:(0,Z.jsx)(A,{isSelected:!!e.enabled,isDisabled:t===`toggle`,ariaLabel:e.enabled?u(`disable`):u(`enable`),label:e.enabled?u(`enabledState`):u(`disabled`),onChange:x})})]}),ye?(0,Z.jsxs)(`section`,{className:`border-t border-separator bg-surface-secondary/55 px-4 py-2.5`,children:[(0,Z.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-caption font-medium text-muted`,children:u(`modelCooldownsTitle`)}),(0,Z.jsx)(`span`,{className:`mono text-caption text-muted`,children:N.length})]}),N.length?(0,Z.jsx)(`div`,{className:`space-y-1`,children:N.map(([e,t])=>(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg bg-surface px-2 py-1.5 text-caption`,children:[(0,Z.jsx)(`span`,{className:`mono min-w-0 truncate`,title:e,children:e}),(0,Z.jsx)(`span`,{className:`mono shrink-0 text-warning`,children:lt(t)})]},e))}):(0,Z.jsx)(`p`,{className:`text-caption text-muted`,children:u(`modelCooldownsEmpty`)})]}):null]})}var Pn=2e3,Fn=3e5;function In({isOpen:e,accounts:t,t:n,onClose:r,onFinished:i}){let[a,o]=(0,J.useState)([]),s=(0,J.useRef)(!1),c=(0,J.useRef)(!1);(0,J.useEffect)(()=>{if(!e){s.current=!0,c.current=!1;return}if(s.current=!1,o(t.map(e=>({account:e,phase:`pending`,message:``,authUrl:``}))),!c.current)return c.current=!0,u(t),()=>{s.current=!0,c.current=!1}},[e]);function l(e,t){o(n=>n.map(n=>n.account.id===e?{...n,...t}:n))}async function u(e){for(let t of e){if(s.current){l(t.id,{phase:`stopped`,message:n(`reloginStopped`)});continue}l(t.id,{phase:`starting`,message:n(`wizardStartingSession`)});let e=``;try{let r=await ze(t.id);e=r.authUrl||``,l(t.id,{authUrl:e,phase:`waiting`,message:r.message||n(`reloginWaitingAuth`)})}catch(e){l(t.id,{phase:`error`,message:e instanceof Error?e.message:String(e)});continue}let r=Date.now()+Fn,i=!1;for(;!i;){if(s.current){l(t.id,{phase:`stopped`,message:n(`reloginStopped`)});break}if(Date.now()>r){l(t.id,{phase:`error`,message:n(`reloginTimeout`)});break}await new Promise(e=>window.setTimeout(e,Pn));try{let e=(await ke(t.id)).login||{},r=e.message||``;e.status===`ok`?(l(t.id,{phase:`ok`,message:r||n(`reloginDone`)}),i=!0):e.status===`error`?(l(t.id,{phase:`error`,message:r||n(`reloginFailed`)}),i=!0):r&&l(t.id,{message:r})}catch(e){l(t.id,{message:e instanceof Error?e.message:String(e)})}}}c.current=!1,s.current||i()}function d(){s.current=!0,c.current=!1,r()}let f=a.filter(e=>e.phase===`ok`||e.phase===`error`||e.phase===`stopped`).length;return(0,Z.jsx)(M.Root,{isOpen:e,onOpenChange:e=>{e||d()},children:(0,Z.jsx)(M.Backdrop,{variant:`blur`,children:(0,Z.jsx)(M.Container,{size:`lg`,scroll:`inside`,children:(0,Z.jsxs)(M.Dialog,{children:[(0,Z.jsxs)(M.Header,{className:`px-5 pt-5`,children:[(0,Z.jsx)(M.Heading,{className:`text-section font-semibold`,children:n(`reloginTitle`)}),(0,Z.jsx)(`p`,{className:`mt-1 text-caption font-normal leading-5 text-muted`,children:n(`reloginHint`)})]}),(0,Z.jsxs)(M.Body,{className:`space-y-2 px-5 pb-2`,children:[(0,Z.jsx)(`div`,{className:`mono text-caption tabular-nums text-muted`,children:n(`reloginProgress`,{done:f,total:a.length})}),a.map(e=>(0,Z.jsxs)(`div`,{className:`rounded-lg border border-divider bg-surface-secondary px-3 py-2`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2.5`,children:[(0,Z.jsx)(nt,{provider:e.account.provider,size:16}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-body`,children:e.account.name||e.account.id}),(0,Z.jsx)(B,{size:`sm`,variant:`soft`,color:Rn(e.phase),children:n(Ln(e.phase))}),e.authUrl?(0,Z.jsx)(S,{size:`sm`,variant:`secondary`,onPress:()=>window.open(e.authUrl,`_blank`,`noopener,noreferrer`),children:n(`reloginOpenPage`)}):null]}),e.message?(0,Z.jsx)(`p`,{className:`mt-1 break-words text-caption text-foreground/70`,children:e.message}):null,e.authUrl?(0,Z.jsx)(`p`,{className:`mono mt-1 truncate text-caption text-muted`,title:e.authUrl,children:e.authUrl}):null]},e.account.id))]}),(0,Z.jsx)(M.Footer,{className:`justify-end px-5 pb-5`,children:(0,Z.jsx)(S,{variant:`secondary`,onPress:d,children:n(`cancel`)})})]})})})})}function Ln(e){switch(e){case`starting`:return`reloginPhaseStarting`;case`waiting`:return`reloginPhaseWaiting`;case`ok`:return`reloginPhaseDone`;case`error`:return`reloginPhaseFailed`;case`stopped`:return`reloginPhaseStopped`;default:return`reloginPhasePending`}}function Rn(e){return e===`ok`?`success`:e===`error`?`danger`:e===`waiting`||e===`starting`?`warning`:`default`}function zn(e,t){return e.status===`success`?{label:t(`checkinRecordSuccess`),color:`success`}:e.status===`already`?{label:t(`checkinRecordAlready`),color:`warning`}:e.status===`skipped`?{label:t(`checkinRecordSkipped`),color:`default`}:{label:t(`checkinRecordFailed`),color:`danger`}}function Bn(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}function Vn({account:e,t,onClose:n}){let[r,i]=(0,J.useState)([]),[a,o]=(0,J.useState)(!!e?.id),[s,c]=(0,J.useState)(``),l=e?.id||``,u=t(`checkinRecordsTitle`,{name:e?.name||e?.id||``});async function d(){if(l){o(!0),c(``);try{let e=await Oe(l);i(e.data||[])}catch(e){i([]),c(e instanceof Error?e.message:String(e))}finally{o(!1)}}}return(0,J.useEffect)(()=>{l&&d()},[l]),(0,Z.jsx)(M.Root,{isOpen:!!e,onOpenChange:e=>{e||n()},children:(0,Z.jsx)(M.Backdrop,{variant:`blur`,children:(0,Z.jsx)(M.Container,{size:`lg`,scroll:`inside`,children:(0,Z.jsxs)(M.Dialog,{children:[(0,Z.jsxs)(M.Header,{className:`items-start justify-between gap-4 px-5 pt-5`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(M.Heading,{className:`text-section font-semibold`,children:u}),(0,Z.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:t(`checkinRecordsHint`)})]}),(0,Z.jsx)(M.CloseTrigger,{"aria-label":t(`close`),className:`grid size-8 shrink-0 place-items-center rounded-lg text-muted transition-colors hover:bg-surface-secondary hover:text-foreground`,children:(0,Z.jsx)(Xe,{size:16})})]}),(0,Z.jsxs)(M.Body,{className:`px-5 pb-2`,children:[s?(0,Z.jsx)(`div`,{className:`mb-3`,children:(0,Z.jsx)(he,{title:s})}):null,a?(0,Z.jsxs)(`div`,{className:`space-y-2 py-1`,children:[(0,Z.jsx)(K,{className:`h-16 w-full`}),(0,Z.jsx)(K,{className:`h-16 w-full`}),(0,Z.jsx)(K,{className:`h-16 w-full`})]}):r.length?(0,Z.jsx)(`div`,{className:`divide-y divide-separator overflow-hidden rounded-lg bg-surface-secondary`,children:r.map(e=>{let n=zn(e,t);return(0,Z.jsxs)(`div`,{className:`flex items-start gap-3 px-3 py-3`,children:[(0,Z.jsx)(`span`,{className:`status-dot mt-1.5 shrink-0`,"data-state":e.status===`error`?`warn`:`ok`}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(B,{size:`sm`,variant:`soft`,color:n.color,children:n.label}),(0,Z.jsx)(`span`,{className:`mono text-caption text-muted`,children:Bn(e.created_at)})]}),(0,Z.jsx)(`p`,{className:`mt-1 break-words text-caption leading-5 text-foreground/75`,children:e.message||`—`})]})]},e.id)})}):(0,Z.jsx)(k,{className:`min-h-44 rounded-3xl bg-surface-secondary`,title:t(`checkinRecordsEmpty`),hint:t(`checkinRecordsHint`)})]}),(0,Z.jsxs)(M.Footer,{className:`justify-between px-5 pb-5`,children:[(0,Z.jsx)(`span`,{className:`mono text-caption text-muted`,children:t(`checkinRecordsCount`,{count:r.length})}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(S,{size:`sm`,variant:`ghost`,onPress:n,children:t(`close`)}),(0,Z.jsxs)(S,{size:`sm`,variant:`secondary`,isPending:a,onPress:()=>void d(),children:[(0,Z.jsx)(z,{size:14}),t(`refresh`)]})]})]})]})})})})}function Hn(e){let t=e.route_display_name||``;return t&&t!==(e.display_name||e.id)?t:``}function Un({account:e,t,onClose:n}){let[r,i]=(0,J.useState)([]),[a,o]=(0,J.useState)(!!e?.id),[s,c]=(0,J.useState)(!1),[l,u]=(0,J.useState)(``),[d,f]=(0,J.useState)(1),[p,m]=(0,J.useState)(20),[h,te]=(0,J.useState)(0),[g,_]=(0,J.useState)(1),v=(0,J.useRef)(0),y=e?.id||``,ne=t(`accountModelsTitle`,{name:e?.name||e?.id||``}),b=e?rt(e.provider,e.region,t):``;async function x(e=1,t=p,n=!1){if(!y)return;let r=++v.current;n?c(!0):o(!0),u(``);try{let a=await(n?P(y,void 0,{page:e,pageSize:t}):Pe(y,!1,void 0,{page:e,pageSize:t})),o=a.data||[],s=a.pagination,c=s?.total??o.length,l=s?.total_pages??Math.max(1,Math.ceil(c/t)),u=Math.min(Math.max(1,s?.page??e),l);if(r!==v.current)return;i(s?o:o.slice((u-1)*t,u*t)),te(c),_(l),f(u)}catch(e){if(r!==v.current)return;i([]),te(0),_(1),u(e instanceof Error?e.message:String(e))}finally{r===v.current&&(o(!1),c(!1))}}(0,J.useEffect)(()=>{y&&(f(1),x(1,p))},[y]);let re=h===0?0:(d-1)*p+1,C=h===0?0:Math.min(h,re+r.length-1);return(0,Z.jsx)(M.Root,{isOpen:!!e,onOpenChange:e=>{e||n()},children:(0,Z.jsx)(M.Backdrop,{variant:`blur`,children:(0,Z.jsx)(M.Container,{size:`lg`,scroll:`inside`,children:(0,Z.jsxs)(M.Dialog,{children:[(0,Z.jsxs)(M.Header,{className:`items-start justify-between gap-4 px-5 pt-5`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(M.Heading,{className:`text-section font-semibold`,children:ne}),(0,Z.jsx)(`p`,{className:`mt-1 text-caption font-normal leading-5 text-muted`,children:t(`accountModelsHint`)}),e?(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-caption text-muted`,children:[(0,Z.jsx)(nt,{provider:e.provider,size:14}),(0,Z.jsx)(`span`,{children:b}),(0,Z.jsx)(`span`,{className:`text-border`,children:`·`}),(0,Z.jsx)(`span`,{className:`mono`,children:e.id})]}):null]}),(0,Z.jsx)(M.CloseTrigger,{"aria-label":t(`close`),className:`grid size-8 shrink-0 place-items-center rounded-lg text-muted transition-colors hover:bg-surface-secondary hover:text-foreground`,children:(0,Z.jsx)(Xe,{size:16})})]}),(0,Z.jsxs)(M.Body,{className:`px-5 pb-2`,children:[l?(0,Z.jsx)(`div`,{className:`mb-3`,children:(0,Z.jsx)(he,{title:t(`accountModelsError`,{msg:l})})}):null,a||s?(0,Z.jsxs)(`div`,{className:`space-y-2 py-1`,children:[(0,Z.jsx)(K,{className:`h-14 w-full`}),(0,Z.jsx)(K,{className:`h-14 w-full`}),(0,Z.jsx)(K,{className:`h-14 w-full`})]}):r.length?(0,Z.jsx)(`ul`,{className:`divide-y divide-separator overflow-hidden rounded-lg bg-surface-secondary`,children:r.map(n=>{let r=n.provider||n.owned_by||e?.provider||`qoder`,i=Hn(n),a=Se(n),o=Ce(n);return(0,Z.jsxs)(`li`,{className:`flex items-start gap-3 px-3 py-2.5`,children:[(0,Z.jsx)(`span`,{className:`status-dot mt-1.5`,"data-state":n.stale?void 0:`ok`}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`truncate text-body font-medium`,children:n.display_name||n.id}),o?(0,Z.jsx)(B,{size:`sm`,variant:`soft`,color:`success`,children:t(`modelFree`)}):null,a?(0,Z.jsx)(`span`,{className:`mono text-caption text-muted`,children:a}):null,n.stale?(0,Z.jsx)(B,{size:`sm`,variant:`soft`,color:`warning`,children:t(`fallback`)}):null]}),(0,Z.jsx)(`div`,{className:`mono mt-0.5 truncate text-caption text-muted`,children:n.id}),i?(0,Z.jsx)(`div`,{className:`mt-0.5 text-caption text-muted`,children:t(`routedTo`,{model:i})}):null]}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5 pt-0.5 text-caption text-muted`,children:[(0,Z.jsx)(nt,{provider:r,size:12}),(0,Z.jsx)(`span`,{children:r})]})]},n.id)})}):(0,Z.jsx)(k,{className:`min-h-48 rounded-3xl bg-surface-secondary`,icon:(0,Z.jsx)(R,{size:22}),title:t(`accountModelsEmpty`),hint:t(`noModelsYet`)})]}),(0,Z.jsxs)(M.Footer,{className:`flex-col items-stretch gap-3 px-5 pb-5`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsx)(`span`,{className:`mono text-caption text-muted`,children:a?t(`refreshing`):t(`shownTotal`,{shown:h?`${re}–${C}`:0,total:h})}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(S,{size:`sm`,variant:`ghost`,onPress:n,children:t(`close`)}),(0,Z.jsxs)(S,{size:`sm`,variant:`secondary`,isPending:s,onPress:()=>void x(1,p,!0),children:[(0,Z.jsx)(z,{size:14}),t(s?`refreshing`:`refresh`)]})]})]}),h>0?(0,Z.jsx)(ee,{total:h,page:d,pageCount:g,pageSize:p,loading:a||s,pageSizeLabel:t(`logsPageSize`),pageLabel:t(`logsPage`,{page:d,pages:g}),prevLabel:t(`logsPrevPage`),nextLabel:t(`logsNextPage`),onPage:e=>void x(e,p),onPageSize:e=>{m(e),x(1,e)}}):null]})]})})})})}function Wn({account:e,busy:t,t:n,onClose:r,onSave:i}){let[a,o]=(0,J.useState)(e?.name||``),[s,c]=(0,J.useState)(e?.max_inflight??4),[l,u]=(0,J.useState)(e?.priority??50),[d,f]=(0,J.useState)(``),p=n(`editAccountTitle`,{name:e?.name||e?.id||``}),m=e?rt(e.provider,e.region,n):``;async function ee(e){e?.preventDefault();let t=a.trim();if(!t){f(n(`accountNameRequired`));return}if(!Number.isInteger(s)||s<1||s>32){f(n(`maxInflightInvalid`));return}if(!Number.isInteger(l)||l<1||l>100){f(n(`priorityInvalid`));return}f(``);try{await i({name:t,max_inflight:s,priority:l}),r()}catch(e){f(e instanceof Error?e.message:String(e))}}return(0,Z.jsx)(M.Root,{isOpen:!!e,onOpenChange:e=>{!e&&!t&&r()},children:(0,Z.jsx)(M.Backdrop,{variant:`blur`,children:(0,Z.jsx)(M.Container,{placement:`center`,size:`lg`,scroll:`inside`,children:(0,Z.jsxs)(M.Dialog,{className:`w-full sm:w-[42rem] sm:max-w-[calc(100vw-2rem)]`,children:[(0,Z.jsxs)(M.Header,{className:`items-start justify-between gap-4 px-6 pt-6`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(M.Heading,{className:`text-section font-semibold`,children:p}),(0,Z.jsx)(`p`,{className:`mt-1.5 text-body font-normal leading-6 text-muted`,children:n(`editAccountHint`)}),e?(0,Z.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(B,{size:`sm`,variant:`soft`,children:(0,Z.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,Z.jsx)(nt,{provider:e.provider,size:14}),(0,Z.jsx)(`span`,{children:m})]})}),(0,Z.jsx)(`span`,{className:`mono text-caption text-muted`,children:e.id})]}):null]}),(0,Z.jsx)(M.CloseTrigger,{isDisabled:t,"aria-label":n(`close`),className:`grid size-9 shrink-0 place-items-center rounded-lg text-muted hover:bg-surface-secondary`,children:(0,Z.jsx)(Xe,{size:18})})]}),(0,Z.jsxs)(M.Body,{className:`px-6 pb-2 pt-1`,children:[d?(0,Z.jsxs)(me,{status:`danger`,className:`mb-4`,children:[(0,Z.jsx)(me.Indicator,{}),(0,Z.jsx)(me.Content,{children:(0,Z.jsx)(me.Title,{children:d})})]}):null,(0,Z.jsxs)(ye,{className:`space-y-4`,onSubmit:e=>void ee(e),children:[(0,Z.jsx)(j,{label:n(`accountName`),children:(0,Z.jsx)(xe,{value:a,onChange:e=>o(e.target.value),placeholder:n(`wizardNamePh`),"aria-label":n(`accountName`),disabled:t,autoFocus:!0})}),(0,Z.jsx)(j,{label:n(`maxInflight`),hint:n(`maxInflightHint`),children:(0,Z.jsx)(O,{value:s,onChange:e=>c(e??4),minValue:1,maxValue:32,isDisabled:t,isRequired:!0,children:(0,Z.jsxs)(O.Group,{children:[(0,Z.jsx)(O.DecrementButton,{}),(0,Z.jsx)(O.Input,{"aria-label":n(`maxInflight`)}),(0,Z.jsx)(O.IncrementButton,{})]})})}),(0,Z.jsx)(j,{label:n(`priority`),hint:n(`priorityHint`),children:(0,Z.jsx)(O,{value:l,onChange:e=>u(e??50),minValue:1,maxValue:100,isDisabled:t,isRequired:!0,children:(0,Z.jsxs)(O.Group,{children:[(0,Z.jsx)(O.DecrementButton,{}),(0,Z.jsx)(O.Input,{"aria-label":n(`priority`)}),(0,Z.jsx)(O.IncrementButton,{})]})})})]})]}),(0,Z.jsxs)(M.Footer,{className:`justify-end gap-2 px-6 pb-6`,children:[(0,Z.jsx)(S,{variant:`ghost`,isDisabled:t,onPress:r,children:n(`cancel`)}),(0,Z.jsx)(S,{isPending:t,onPress:()=>void ee(),children:n(`save`)})]})]})})})})}var Gn={1:`grid-cols-1`,2:`grid-cols-1 sm:grid-cols-2`,3:`grid-cols-1 sm:grid-cols-3`};function Kn({options:e,value:t,onChange:n,ariaLabel:r,columns:i=2,className:a=``}){let o=(0,J.useRef)(null);return(0,J.useLayoutEffect)(()=>{let e=o.current;if(!e)return;let t=L.context(()=>{let e=L.matchMedia();e.add(`(prefers-reduced-motion: reduce)`,()=>{L.set(`[data-option-tile]`,{autoAlpha:1,y:0})}),e.add(`(prefers-reduced-motion: no-preference)`,()=>{L.fromTo(`[data-option-tile]`,{autoAlpha:0,y:8},{autoAlpha:1,y:0,duration:.32,stagger:.035,ease:`power3.out`,overwrite:!0})})},e);return()=>t.revert()},[e.length]),(0,Z.jsx)(`div`,{ref:o,role:`radiogroup`,"aria-label":r,className:`grid gap-3 ${Gn[i]} ${a}`.trim(),children:e.map(e=>{let r=e.value===t;return(0,Z.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":r,"data-option-tile":``,"data-selected":r||void 0,disabled:e.disabled,title:e.hint,onClick:()=>n(e.value),className:`flex h-16 min-w-0 items-center gap-3 rounded-xl bg-surface shadow-surface px-4 text-left transition-colors hover:bg-surface-secondary disabled:cursor-not-allowed disabled:opacity-50 data-selected:border-accent data-selected:bg-accent-soft`,children:[e.icon?(0,Z.jsx)(`span`,{className:`grid size-8 shrink-0 place-items-center rounded-lg bg-surface-secondary text-foreground [&_svg]:size-[18px]`,children:e.icon}):null,(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-body font-medium leading-5 text-foreground`,children:e.label})]},e.value)})})}var qn=new Set([`qoder-global`,`qoder-cn`,`workbuddy-global`,`workbuddy-cn`,`trae-cn`]),Jn=[`qoder-global`,`qoder-cn`,`workbuddy-global`,`workbuddy-cn`,`trae-cn`];function Yn(e,t){let n=new Map(t.map((e,t)=>[e,t]));return[...e].sort((e,t)=>{let r=n.get(e.id)??2**53-1,i=n.get(t.id)??2**53-1;return r===i?e.label.localeCompare(t.label):r-i})}function Xn(e,t){return!t||`${e.label} ${e.subtitle||``} ${e.hint||``} ${e.provider} ${e.id}`.toLowerCase().includes(t)}function Zn({ariaLabel:e}){return(0,Z.jsx)(`div`,{className:`space-y-8`,"aria-busy":`true`,"aria-label":e,children:Array.from({length:2},(e,t)=>(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(W,{className:`h-3 w-24 rounded-lg`}),(0,Z.jsx)(W,{className:`h-3 w-40 rounded-lg`})]}),(0,Z.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:Array.from({length:t===0?5:6},(e,t)=>(0,Z.jsxs)(`div`,{className:`card flex flex-row items-center gap-3.5 rounded-xl bg-surface px-4 py-3.5`,children:[(0,Z.jsx)(W,{className:`size-10 shrink-0 rounded-lg`}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1.5`,children:[(0,Z.jsx)(W,{className:`h-3.5 w-28 rounded-lg`}),(0,Z.jsx)(W,{className:`h-3 w-36 rounded-lg`})]})]},t))})]},t))})}function Qn({tile:e,disabled:t,onSelect:n}){return(0,Z.jsxs)(`button`,{type:`button`,disabled:t,title:e.hint||e.subtitle||e.label,onClick:()=>n(e.id),className:`card flex min-w-0 flex-row items-center gap-3 rounded-xl bg-surface px-3.5 py-3 text-left transition-[transform,opacity,background-color] duration-200 ease-out hover:bg-surface-secondary active:translate-y-px active:scale-[0.98] motion-reduce:transition-none motion-reduce:active:translate-y-0 motion-reduce:active:scale-100 disabled:cursor-not-allowed disabled:opacity-50 disabled:active:translate-y-0 disabled:active:scale-100`,children:[(0,Z.jsx)(`span`,{className:`grid size-9 shrink-0 place-items-center rounded-lg text-foreground [&_svg]:size-[18px]`,children:(0,Z.jsx)(nt,{provider:e.provider,size:18})}),(0,Z.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`span`,{className:`block truncate text-body font-medium leading-5 text-foreground`,children:e.label}),e.subtitle?(0,Z.jsx)(`span`,{className:`mt-0.5 block truncate text-caption leading-4 text-muted`,children:e.subtitle}):null]})]})}function $n({title:e,subtitle:t,tiles:n,disabled:r,onSelect:i}){return n.length?(0,Z.jsxs)(`section`,{className:`space-y-3.5`,children:[(0,Z.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,Z.jsx)(`h3`,{className:`text-[10px] font-semibold tracking-[0.12em] uppercase text-muted`,children:e}),t?(0,Z.jsx)(`p`,{className:`text-caption leading-5 text-muted`,children:t}):null]}),(0,Z.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:n.map(e=>(0,Z.jsx)(Qn,{tile:e,disabled:r,onSelect:i},e.id))})]}):null}function er({options:e,onSelect:t,disabled:n,empty:r,ariaLabel:i}){let{t:a}=re(),[o,s]=(0,J.useState)(``),c=o.trim().toLowerCase(),l=(0,J.useMemo)(()=>{let t=Yn(e.filter(e=>qn.has(e.id)),Jn),n=e.filter(e=>!qn.has(e.id)).sort((e,t)=>e.label.localeCompare(t.label));return[{id:`subscriptions`,titleKey:`providerGroupSubscriptions`,subtitleKey:`providerGroupSubscriptionsHint`,tiles:t.filter(e=>Xn(e,c))},{id:`experimental`,titleKey:`providerGroupExperimental`,subtitleKey:`providerGroupExperimentalHint`,tiles:n.filter(e=>Xn(e,c))}]},[c,e]),u=l.reduce((e,t)=>e+t.tiles.length,0);return(0,Z.jsxs)(`div`,{className:`space-y-8`,role:`listbox`,"aria-label":i,children:[(0,Z.jsx)(h,{value:o,onChange:s,placeholder:a(`providerFindPlaceholder`),ariaLabel:a(`providerFindPlaceholder`),className:`max-w-sm`}),u===0?r||(0,Z.jsx)(`p`,{className:`rounded-lg bg-surface-secondary/45 px-3.5 py-3 text-caption leading-5 text-muted`,children:a(`providerFindEmpty`)}):l.map(e=>(0,Z.jsx)($n,{title:a(e.titleKey),subtitle:a(e.subtitleKey),tiles:e.tiles,disabled:n,onSelect:t},e.id))]})}var tr={"workbuddy-accounts":`workbuddy`,"workbuddy-oauth-v1":`workbuddy`,"qoder-native-v1":`qoder`,"trae-oauth-v1":`trae`,"devin-session-v1":`devin`,"command-key-v1":`command`,"codex-oauth-v1":`codex`,"zhipu-key-v1":`zhipu`,"qwenwork-oauth-v1":`qwenwork`,"meta-oauth-v1":`meta`,"meta-key-v1":`meta`,"kiro-oauth-v1":`kiro`,"doubaowork-cookie-v1":`doubaowork`},nr=[`codebuddy.cn`,`workbuddy.cn`],rr=[`workbuddy.ai`,`workbuddy.com`],ir=new Set([`us-east-1`,`eu-central-1`]),ar=/arn:aws:codewhisperer:([a-z0-9-]+):/;function Q(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function $(e){return typeof e==`string`?e.trim():``}function or(e){let t=e.trim();if(!t)return``;let n=t.toLowerCase();return n===`workbuddy-accounts`?`workbuddy-accounts`:n}function sr(e){return typeof e.format==`string`&&e.format.trim()?or(e.format):typeof e.exportType==`string`&&e.exportType.trim()?or(e.exportType):``}function cr(e){let t=[],n=e=>{typeof e==`string`&&e.trim()&&t.push(e.trim().toLowerCase())};if(n(e.domain),Q(e.account)&&n(e.account.domain),Q(e.auth)&&n(e.auth.domain),Array.isArray(e.accounts))for(let t of e.accounts)Q(t)&&(n(t.domain),Q(t.account)&&n(t.account.domain),Q(t.auth)&&n(t.auth.domain));return t}function lr(e){return nr.some(t=>e.includes(t))}function ur(e){return rr.some(t=>e.includes(t))}function dr(e){return typeof e.accessToken==`string`||typeof e.access_token==`string`||typeof e.refreshToken==`string`||typeof e.refresh_token==`string`}function fr(e){if(!Q(e))return!1;if(dr(e)||typeof e.domain==`string`||typeof e.uid==`string`)return!0;if(Q(e.account)||Q(e.auth)){let t=Q(e.account)?e.account:null,n=Q(e.auth)?e.auth:null;if(n&&(dr(n)||typeof n.domain==`string`)||t&&(typeof t.uid==`string`||typeof t.domain==`string`))return!0}return!1}function pr(e){let t=cr(e);if(t.length===0)return{region:`cn`,ambiguous:!0,warning:`region_unknown`};let n=t.some(lr),r=t.some(ur);return n&&r?{region:null,ambiguous:!0,warning:`region_mixed`}:n?{region:`cn`,ambiguous:!1}:r?{region:`global`,ambiguous:!1}:{region:`cn`,ambiguous:!0,warning:`region_unknown`}}function mr(e){let t=$(e.region).toLowerCase();if(ir.has(t))return t;if(t===`eu`||t===`europe`)return`eu-central-1`;let n=$(e.profileArn)||$(e.profile_arn),r=ar.exec(n);if(r&&ir.has(r[1]))return r[1];for(let t of[`kiroApiKey`,`apiKey`,`api_key`,`accessToken`,`access_token`]){let n=$(e[t]),r=n.split(`|`);if(n.startsWith(`ksk_`)&&r.length===2&&ir.has(r[1].trim().toLowerCase()))return r[1].trim().toLowerCase()}return null}function hr(e){if(sr(e)===`kiro-oauth-v1`||mr(e))return!0;let t=($(e.authMethod)||$(e.auth_method)).toLowerCase();if([`builder_id`,`builderid`,`external_idp`,`idc`,`social`].includes(t))return!0;let n=$(e.provider).toLowerCase();if([`builderid`,`kiro`,`apikey`,`github`,`google`,`social`].includes(n))return!0;for(let t of[`kiroApiKey`,`apiKey`,`api_key`,`accessToken`,`access_token`])if($(e[t]).startsWith(`ksk_`))return!0;let r=$(e.clientId)||$(e.client_id),i=$(e.clientSecret)||$(e.client_secret),a=$(e.refreshToken)||$(e.refresh_token),o=$(e.startUrl)||$(e.start_url);if(r&&i&&a||o.includes(`awsapps.com`)&&a||($(e.profileArn)||$(e.profile_arn)).includes(`codewhisperer`)&&(a||$(e.accessToken)||$(e.access_token)))return!0;let s=$(e.tokenEndpoint)||$(e.token_endpoint),c=$(e.issuerUrl)||$(e.issuer_url);return!!((s.includes(`microsoftonline`)||c.includes(`microsoftonline`))&&a)}function gr(e){return Array.isArray(e.accounts)?e.accounts.filter(e=>Q(e)&&hr(e)):[]}function _r(e){return hr(e)||gr(e).length>0?{format:`kiro-oauth-v1`,provider:`kiro`,confidence:`medium`}:Array.isArray(e.accounts)&&e.accounts.some(fr)?{format:`workbuddy-accounts`,provider:`workbuddy`,confidence:`medium`}:(typeof e.user_blob==`string`||typeof e.userBlob==`string`)&&(typeof e.machine_id==`string`||typeof e.machineId==`string`)?{format:`qoder-native-v1`,provider:`qoder`,confidence:`medium`}:typeof e.session_token==`string`||typeof e.sessionToken==`string`?{format:`devin-session-v1`,provider:`devin`,confidence:`low`}:dr(e)||Q(e.account)&&dr(e.account)||Q(e.auth)?{format:`workbuddy-oauth-v1`,provider:`workbuddy`,confidence:`low`}:typeof e.dca_token==`string`||typeof e.dcaToken==`string`||typeof e.access_token==`string`&&String(e.access_token).startsWith(`dca:`)||typeof e.accessToken==`string`&&String(e.accessToken).startsWith(`dca:`)?{format:`meta-oauth-v1`,provider:`meta`,confidence:`medium`}:typeof e.api_key==`string`||typeof e.apiKey==`string`?typeof e.organization==`string`||typeof e.project==`string`?{format:`zhipu-key-v1`,provider:`zhipu`,confidence:`low`}:typeof e.base_url==`string`&&String(e.base_url).includes(`meta.ai`)||typeof e.baseUrl==`string`&&String(e.baseUrl).includes(`meta.ai`)||typeof e.email==`string`?{format:`meta-key-v1`,provider:`meta`,confidence:`low`}:{format:`command-key-v1`,provider:`command`,confidence:`low`}:{format:null,provider:null,confidence:`low`}}function vr(e){let t=gr(e),n=t.length>0?t:[e],r=new Set(n.map(mr).filter(e=>e!=null));return r.size===1?{region:[...r][0],ambiguous:!1}:(r.size,{region:null,ambiguous:!0})}function yr(e){if(!Q(e))return{format:null,provider:null,region:null,regionAmbiguous:!0,confidence:`low`,warnings:[`not_object`],batchImportSupported:!1};let t=[],n=sr(e),r=typeof e.format==`string`?e.format.trim():``,i=typeof e.exportType==`string`?e.exportType.trim():``,a=r||i,o=n||null,s=o?tr[o]??null:null,c=o&&s?`high`:`low`;if(!s){let r=_r(e);o||=r.format,s=r.provider,c=n&&!tr[n]?`low`:r.confidence,a&&!tr[n]&&t.push(`unknown_format`)}s!==`kiro`&&(hr(e)||gr(e).length>0)&&(s=`kiro`,o=`kiro-oauth-v1`,c=n===`kiro-oauth-v1`?`high`:`medium`),s===`workbuddy`&&Array.isArray(e.accounts)&&(o=`workbuddy-accounts`);let l=null,u=!1;if(s===`workbuddy`){let n=pr(e);l=n.region,u=n.ambiguous,n.warning&&t.push(n.warning)}if(s===`kiro`){let n=vr(e);l=n.region,u=n.ambiguous,u&&t.push(gr(e).length>1?`region_mixed`:`region_unknown`)}return{format:o,provider:s,region:l,regionAmbiguous:u,confidence:c,warnings:t,batchImportSupported:s===`workbuddy`||s===`kiro`}}function br(e){let t;try{t=JSON.parse(e)}catch{throw Error(`bad_json`)}if(Array.isArray(t)){if(t.length===0||!t.every(Q))throw Error(`bad_json`);return{accounts:t}}if(!Q(t))throw Error(`bad_json`);return t}function xr(e,t){let n={...e},r=n.format===`workbuddy-accounts`||Array.isArray(n.accounts);return n.format?r&&(n.format=`workbuddy-accounts`):n.format=r?`workbuddy-accounts`:`workbuddy-oauth-v1`,{...n,name:t.name?.trim()||n.name,enabled:t.enabled??!0,provider:`workbuddy`,region:t.region,max_inflight:t.max_inflight??4,priority:t.priority??50,drop_system_prompt:t.drop_system_prompt??!0,...t.proxy_url!=null&&t.proxy_url!==``?{proxy_url:t.proxy_url}:{}}}function Sr(e,t){let n=typeof e?.succeeded==`number`?e.succeeded:e?.id||e?1:0,r=typeof e?.failed==`number`?e.failed:0,i=(e?.errors||[]).slice(0,3).map(e=>e.message||`index ${e.index}`).filter(Boolean).join(`; `),a;return a=r>0?t(`accountImportPartial`).replace(`{ok}`,String(n)).replace(`{fail}`,String(r))+(i?` — ${i}`:``):n>1?t(`accountImportBatch`).replace(`{n}`,String(n)):t(`accountImported`),{succeeded:n,failed:r,message:a}}async function Cr(e,t){let n=xr(e,t);return Te(n)}var wr={global:`Global`,cn:`CN`},Tr={"qoder-global":`accountTypeQoderGlobal`,"qoder-cn":`accountTypeQoderCN`,"workbuddy-cn":`accountTypeWorkBuddyCN`,"workbuddy-global":`accountTypeWorkBuddyGlobal`,"trae-cn":`accountTypeTraeCN`,"devin-global":`accountTypeDevinGlobal`,"command-global":`accountTypeCommandGlobal`,"codex-global":`accountTypeCodexGlobal`,"zhipu-cn":`accountTypeZhipuCN`,"qwenwork-global":`accountTypeQwenworkGlobal`,"qwenwork-cn":`accountTypeQwenworkCN`,"kimi-cn":`accountTypeKimiCN`,"codearts-cn-north-4":`accountTypeCodeArtsCN`,"doubaowork-cn":`accountTypeDoubaoworkCN`,"kiro-us-east-1":`accountTypeKiroUS`,"kiro-eu-central-1":`accountTypeKiroEU`,"meta-global":`accountTypeMetaGlobal`,"minimaxcode-cn":`accountTypeMiniMaxCodeCN`,"minimaxcode-global":`accountTypeMiniMaxCodeGlobal`},Er={"qoder-global":`accountTypeQoderGlobalHint`,"qoder-cn":`accountTypeQoderCNHint`,"workbuddy-cn":`accountTypeWorkBuddyCNHint`,"workbuddy-global":`accountTypeWorkBuddyGlobalHint`,"trae-cn":`accountTypeTraeCNHint`,"devin-global":`accountTypeDevinGlobalHint`,"command-global":`accountTypeCommandGlobalHint`,"codex-global":`accountTypeCodexGlobalHint`,"zhipu-cn":`accountTypeZhipuCNHint`,"qwenwork-global":`accountTypeQwenworkGlobalHint`,"qwenwork-cn":`accountTypeQwenworkCNHint`,"kimi-cn":`accountTypeKimiCNHint`,"codearts-cn-north-4":`accountTypeCodeArtsCNHint`,"doubaowork-cn":`accountTypeDoubaoworkCNHint`,"kiro-us-east-1":`accountTypeKiroUSHint`,"kiro-eu-central-1":`accountTypeKiroEUHint`,"meta-global":`accountTypeMetaGlobalHint`,"minimaxcode-cn":`accountTypeMiniMaxCodeCNHint`,"minimaxcode-global":`accountTypeMiniMaxCodeGlobalHint`};async function Dr(){let e=(await Ae().catch(()=>null))?.data||[],t=[];for(let n of e)for(let e of n.regions)t.push({id:`${n.id}-${e.id}`,provider:n.id,region:e.id,descriptor:n});return t}function Or(e,t){let n=Tr[e.id];if(n){let e=t(n);if(e!==n)return e}let r=e.descriptor.regions.find(t=>t.id===e.region)?.label||wr[e.region]||``,i=e.descriptor.regions.length>1&&r?` ${r}`:``;return`${e.descriptor.label}${i}`.trim()}function kr(e,t){if(!e)return``;let n=Er[e.id];if(!n)return``;let r=t(n);return r===n?``:r}function Ar({phase:e,busy:t,tab:n,forTab:r}){return e===`done`?(0,Z.jsx)(H,{size:16,className:`text-success`}):t&&n===r?(0,Z.jsx)(U,{size:16,loading:!0}):null}var jr=90,Mr=2e3;function Nr({isOpen:e,onClose:t,onAdded:n}){let{t:i}=re(),[o,d]=(0,J.useState)(`method`),[p,m]=(0,J.useState)(`browser`),[ee,h]=(0,J.useState)(``),[te,_]=(0,J.useState)([]),[v,y]=(0,J.useState)(!1),[ne,b]=(0,J.useState)(!1),[x,C]=(0,J.useState)(``),[ie,w]=(0,J.useState)(4),[ae,T]=(0,J.useState)(50),[oe,se]=(0,J.useState)(``),[ce,le]=(0,J.useState)(``),[E,ue]=(0,J.useState)(`payg`),[de,pe]=(0,J.useState)(``),[me,he]=(0,J.useState)(``),[ge,_e]=(0,J.useState)(``),[ve,ye]=(0,J.useState)(``),[D,k]=(0,J.useState)(`idle`),[A,N]=(0,J.useState)(``),[Se,Ce]=(0,J.useState)(``),[we,P]=(0,J.useState)(!1),[Ee,De]=(0,J.useState)(``),[Oe,Ae]=(0,J.useState)(`cli`),[je,Me]=(0,J.useState)(`builder_id`),[Pe,Fe]=(0,J.useState)(``),Ie=(0,J.useRef)(null),Le=(0,J.useRef)(null),Re=(0,J.useRef)(null),I=(0,J.useRef)(``),Ve=(0,J.useRef)(null),He=(0,J.useRef)(null);function Ue(){Ve.current!==null&&(window.clearTimeout(Ve.current),Ve.current=null)}(0,J.useEffect)(()=>()=>Ue(),[]),(0,J.useEffect)(()=>{if(!e)return;let t=!1;return y(!0),_([]),h(``),Dr().then(e=>{t||(_(e),h(``),m(`browser`))}).finally(()=>{t||y(!1)}),()=>{t=!0}},[e]);let R=te.find(e=>e.id===ee),We=!v&&te.length>0,Ge=R?.descriptor.capabilities?.pat_login!==!1,z=R?.descriptor.capabilities?.import_export!==!1,B=R?.descriptor.capabilities?.browser_login!==!1,qe=R?.provider===`trae`||R?.provider===`devin`||R?.provider===`codex`||R?.provider===`codearts`,V=D===`busy`||D===`polling`,Je=!!I.current||V,U=D===`done`,Ye=kr(R,i);(0,J.useEffect)(()=>{p===`pat`&&!Ge&&m(`browser`),p===`import`&&!z&&m(`browser`)},[z,Ge,p]),(0,J.useEffect)(()=>{B||(Ge?m(`pat`):z&&m(`import`))},[B,z,Ge]);function W(){return!Number.isInteger(ie)||ie<1||ie>32?4:ie}function G(){return!Number.isInteger(ae)||ae<1||ae>100?50:ae}function K(){return{max_inflight:W(),priority:G()}}function Ze(){Ue(),d(`method`),m(`browser`),h(``),_([]),y(!1),C(``),w(4),T(50),se(``),le(``),ue(`payg`),pe(``),he(``),_e(``),ye(``),b(!1),k(`idle`),N(``),Ce(``),P(!1),De(``),Ae(`cli`),I.current=``}function q(){V||(Ze(),t())}function et(){Ze(),t()}(0,J.useLayoutEffect)(()=>{let t=Ie.current;if(e||(Re.current=null),!t||!e)return;let n=L.context(()=>{let e=L.matchMedia();e.add(`(prefers-reduced-motion: reduce)`,()=>{L.set(t,{autoAlpha:1,x:0,y:0})}),e.add(`(prefers-reduced-motion: no-preference)`,()=>{let e=Re.current,n=e&&e!==o?o===`login`?1:-1:0;L.fromTo(t,{autoAlpha:0,x:20*n,y:n?0:12},{autoAlpha:1,x:0,y:0,duration:Qe.slow,ease:$e.out,overwrite:!0}),n&&Le.current&&L.fromTo(Le.current,{autoAlpha:0,y:6},{autoAlpha:1,y:0,duration:Qe.base,ease:$e.out,overwrite:!0})})},t);return Re.current=o,()=>n.revert()},[e,o]);function rt(e){if(V||!We)return;let t=te.find(t=>t.id===e);h(e),m(t?.provider===`zhipu`||t?.provider===`doubaowork`?`pat`:`browser`),N(``),d(`login`)}async function it(){if(I.current)return I.current;if(!R)throw Error(i(`accountTypeHint`));let e=K(),t=await Ne(x.trim()||i(`account`),R.provider,R.region,e),n=t?.id||t?.data?.id;if(!n)throw Error(`create account returned no id`);return I.current=n,n}async function at(){N(``),Ce(``);try{k(`busy`);let e=await it();N(i(`wizardStartingSession`)),k(`polling`);let t=R?.provider===`codex`?Oe:R?.provider===`kiro`?je:void 0,r=await ze(e,t,je===`idc`?Pe.trim():void 0);r.authUrl&&Ce(r.authUrl),N(i(`wizardWaitingBrowser`));for(let t=0;t{Ve.current=window.setTimeout(e,Mr)});let n=(await ke(e)).login||{};if(n.message&&N(n.message),n.status===`ok`)break;if(n.status===`error`)throw Error(n.message||`login failed`);if(t===89)throw Error(i(`wizardLoginTimeout`))}k(`done`),N(i(`wizardAccountReady`)),n(),window.setTimeout(et,900)}catch(e){k(`idle`),N(e instanceof Error?e.message:String(e))}}async function ot(){let e=Ee.trim();if(!e){N(i(`wizardCallbackPh`));return}try{k(`busy`);let t=await it();Ue(),await F(t,e),k(`done`),N(i(`wizardAccountReady`)),n(),window.setTimeout(et,900)}catch(e){k(`polling`),N(e instanceof Error?e.message:String(e))}}async function st(){let e=de.trim();if(!e){N(i(`zhipuKeyRequired`));return}if(!R){N(i(`accountTypeHint`));return}N(``);try{k(`busy`);let t=K();await Te({format:`zhipu-key-v1`,api_key:e,mode:E,organization:E===`coding`?me.trim():``,project:E===`coding`?ge.trim():``,name:x.trim()||i(`accountTypeZhipuCN`),enabled:!0,provider:R.provider,region:R.region,max_inflight:t.max_inflight,priority:t.priority}),k(`done`),N(i(`wizardAccountReady`)),n(),window.setTimeout(et,700)}catch(e){k(`idle`),N(e instanceof Error?e.message:String(e))}}async function ct(){let e=oe.trim();if(!e){N(i(`pastePatFirst`));return}N(``);try{k(`busy`);let t=await it();N(i(`wizardStartingSession`)),await Be(e,t),k(`done`),N(i(`patDone`)),n(),window.setTimeout(et,700)}catch(e){k(`idle`),N(e instanceof Error?e.message:String(e))}}async function lt(){let e=ve.trim();if(!e){N(i(`doubaoCookieRequired`));return}if(!R){N(i(`accountTypeHint`));return}N(``);try{k(`busy`);let t=K();await Te({format:`doubaowork-cookie-v1`,cookie:e,name:x.trim()||i(`accountTypeDoubaoworkCN`),enabled:!0,provider:R.provider,region:R.region,max_inflight:t.max_inflight,priority:t.priority}),k(`done`),N(i(`wizardAccountReady`)),n(),window.setTimeout(et,900)}catch(e){k(`idle`),N(e instanceof Error?e.message:String(e))}}async function ut(){N(``);let e;try{e=JSON.parse(ce)}catch{N(i(`wizardBadJson`));return}if(Array.isArray(e)){if(!e.every(e=>e&&typeof e==`object`&&!Array.isArray(e))){N(i(`wizardBadJson`));return}e={accounts:e}}if(!e||typeof e!=`object`){N(i(`wizardBadJson`));return}if(!R){N(i(`accountTypeHint`));return}let t=yr(e),r=t.provider||R.provider;if(r===`qoder`&&(typeof e.user_blob!=`string`||typeof e.machine_id!=`string`)){N(i(`wizardBadJson`));return}let a=K(),o;if(r===`kiro`){let t=typeof e.email==`string`?e.email.trim():``,n=typeof e.nickname==`string`?e.nickname.trim():``,r=mr(e),{provider:i,accounts:s,...c}=e,l=Array.isArray(s)?s:[{...c,...i?{provider:i}:{}}];o={format:`kiro-oauth-v1`,provider:`kiro`,region:r||(R.provider===`kiro`?R.region:`us-east-1`),name:x.trim()||n||t||void 0,enabled:!0,accounts:l,max_inflight:a.max_inflight,priority:a.priority}}else if(r===`workbuddy`)o=xr(e,{region:R.region===`global`?`global`:`cn`,name:x.trim()||void 0,enabled:!0,max_inflight:a.max_inflight,priority:a.priority});else{if(!e.format){let t=r;t===`trae`?e.format=`trae-oauth-v1`:t===`devin`?e.format=`devin-session-v1`:t===`command`?e.format=`command-key-v1`:t===`qwenwork`?e.format=`qwenwork-oauth-v1`:t===`kimi`?e.format=`kimi-oauth-v1`:t===`codearts`?e.format=`codearts-oauth-v1`:t===`codex`?e.format=`codex-oauth-v1`:t===`meta`?e.format=`meta-oauth-v1`:e.format=`qoder-native-v1`}o={...e,name:x.trim()||e.name,enabled:!0,provider:r,region:t.region||R.region,max_inflight:a.max_inflight,priority:a.priority}}try{k(`busy`);let{failed:e,message:t}=Sr(await Te(o),i);k(`done`),N(t),n(),window.setTimeout(et,e>0?1600:700)}catch(e){k(`idle`),N(e instanceof Error?e.message:String(e))}}function dt(){He.current?.click()}function ft(e){let t=e.target.files?.[0];if(!t)return;let n=new FileReader;n.onload=()=>le(String(n.result||``)),n.readAsText(t),e.target.value=``}let pt=e=>V&&p===e,mt=R?.provider===`zhipu`,ht=R?.provider===`doubaowork`,gt=[R?.descriptor.capabilities?.browser_login===!1?null:{value:`browser`,label:i(`tabBrowser`)},Ge?{value:`pat`,label:i(`tabPat`)}:null,z?{value:`import`,label:i(`tabImport`)}:null].filter(Boolean),_t=i(p===`browser`?R?.provider===`codex`?`wizardCodexBrowserLead`:`wizardBrowserLead`:p===`pat`?R?.provider===`command`?`wizardPatLeadCommand`:R?.region===`cn`&&R?.provider===`qoder`?`wizardPatLeadCN`:`wizardPatLead`:`wizardImportLead`);return(0,Z.jsx)(M.Root,{isOpen:e,onOpenChange:e=>{e||q()},children:(0,Z.jsx)(M.Backdrop,{variant:`blur`,isDismissable:!V,children:(0,Z.jsx)(M.Container,{size:`lg`,scroll:`inside`,children:(0,Z.jsxs)(M.Dialog,{className:`w-full sm:w-[36rem] sm:max-w-[calc(100vw-2rem)] sm:min-h-[36rem]`,children:[(0,Z.jsxs)(M.Header,{className:`relative items-center justify-center px-12 pt-5 text-center`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(M.Heading,{className:`text-section font-semibold`,children:i(`addAccountTitle`)}),(0,Z.jsx)(`p`,{ref:Le,className:`mt-1 text-caption font-normal leading-5 text-muted`,children:o===`method`?i(`addAccountDesc`):Ye||i(`addAccountDesc`)})]}),(0,Z.jsx)(M.CloseTrigger,{"aria-label":i(`close`),className:`absolute right-4 top-4 grid size-8 shrink-0 place-items-center rounded-lg text-muted transition-colors hover:bg-surface-secondary hover:text-foreground`,children:(0,Z.jsx)(Xe,{size:16})})]}),(0,Z.jsx)(M.Body,{className:o===`method`?`px-8 pb-5 sm:px-10`:`px-6 pb-2`,children:(0,Z.jsx)(`div`,{ref:Ie,children:o===`method`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`section`,{className:`space-y-2.5`,children:v?(0,Z.jsx)(Zn,{ariaLabel:i(`accountType`)}):We?(0,Z.jsx)(er,{ariaLabel:i(`accountType`),options:te.map(e=>{let t=e.descriptor.regions.find(t=>t.id===e.region)?.label||wr[e.region]||``;return{id:e.id,provider:e.provider,label:Or(e,i),subtitle:t,hint:kr(e,i)}}),onSelect:rt,disabled:Je}):(0,Z.jsx)(`p`,{className:`rounded-lg bg-surface-secondary/45 px-3.5 py-3 text-caption leading-5 text-muted`,children:i(`accountTypeHint`)})}),(0,Z.jsx)(`div`,{className:`mt-4 text-center`,children:(0,Z.jsx)(l,{className:`text-xs`})})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`card flex flex-row items-center gap-3 rounded-xl bg-surface px-3 py-2.5`,children:[(0,Z.jsx)(`span`,{className:`shrink-0`,children:(0,Z.jsx)(nt,{provider:R?.provider,size:18})}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`div`,{className:`truncate text-body font-medium text-foreground`,children:R?Or(R,i):i(`accountType`)}),(0,Z.jsx)(`div`,{className:`truncate text-caption text-muted`,children:Ye})]}),(0,Z.jsxs)(S,{size:`sm`,variant:`ghost`,onPress:()=>d(`method`),isDisabled:V||!!I.current,children:[(0,Z.jsx)(r,{size:12}),i(`wizardBack`)]})]}),(0,Z.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(fe,{className:`text-body font-medium text-muted`,children:i(`accountName`)}),(0,Z.jsx)(xe,{fullWidth:!0,value:x,onChange:e=>C(e.target.value),"aria-label":i(`accountName`),disabled:Je,autoFocus:!0})]}),(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>b(e=>!e),"aria-expanded":ne,className:`inline-flex items-center gap-1 text-caption font-medium text-muted transition-colors hover:text-foreground`,children:[(0,Z.jsx)(u,{size:12,className:`transition-transform duration-200 ${ne?`rotate-90`:``}`}),i(`wizardAdvanced`)]}),ne?(0,Z.jsx)(`div`,{className:`card gap-3 rounded-xl bg-surface px-3.5 py-3.5`,children:(0,Z.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(fe,{className:`text-body font-medium text-muted`,children:i(`maxInflight`)}),(0,Z.jsx)(O,{value:ie,onChange:e=>w(e??4),minValue:1,maxValue:32,isDisabled:Je,isRequired:!0,children:(0,Z.jsxs)(O.Group,{className:`w-full`,children:[(0,Z.jsx)(O.DecrementButton,{}),(0,Z.jsx)(O.Input,{"aria-label":i(`maxInflight`)}),(0,Z.jsx)(O.IncrementButton,{})]})}),(0,Z.jsx)(be,{className:`text-caption leading-5 text-muted`,children:i(`maxInflightHint`)})]}),(0,Z.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,Z.jsx)(fe,{className:`text-body font-medium text-muted`,children:i(`priority`)}),(0,Z.jsx)(O,{value:ae,onChange:e=>T(e??50),minValue:1,maxValue:100,isDisabled:Je,isRequired:!0,children:(0,Z.jsxs)(O.Group,{className:`w-full`,children:[(0,Z.jsx)(O.DecrementButton,{}),(0,Z.jsx)(O.Input,{"aria-label":i(`priority`)}),(0,Z.jsx)(O.IncrementButton,{})]})}),(0,Z.jsx)(be,{className:`text-caption leading-5 text-muted`,children:i(`priorityHint`)})]})]})}):null]}),mt?(0,Z.jsxs)(`div`,{className:`mt-4 flex flex-col gap-4`,children:[(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`span`,{className:`text-body font-medium text-muted`,children:i(`zhipuAccountMode`)}),(0,Z.jsx)(Kn,{ariaLabel:i(`zhipuAccountMode`),columns:2,value:E,onChange:e=>{V||ue(e)},options:[{value:`payg`,label:i(`zhipuModePayg`),hint:i(`zhipuModePaygHint`),disabled:V},{value:`coding`,label:i(`zhipuModeCoding`),hint:i(`zhipuModeCodingHint`),disabled:V}]})]}),(0,Z.jsx)(j,{label:i(`zhipuApiKey`),children:(0,Z.jsx)(xe,{type:`password`,value:de,onChange:e=>pe(e.target.value),placeholder:i(`zhipuApiKeyPh`),"aria-label":i(`zhipuApiKey`),disabled:V})}),E===`coding`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(j,{label:i(`zhipuOrganization`),children:(0,Z.jsx)(xe,{value:me,onChange:e=>he(e.target.value),placeholder:i(`zhipuOrganizationPh`),"aria-label":i(`zhipuOrganization`),disabled:V})}),(0,Z.jsx)(j,{label:i(`zhipuProject`),children:(0,Z.jsx)(xe,{value:ge,onChange:e=>_e(e.target.value),placeholder:i(`zhipuProjectPh`),"aria-label":i(`zhipuProject`),disabled:V})})]}):null,A?(0,Z.jsxs)(`p`,{className:`flex items-center gap-2 rounded-lg bg-surface-secondary px-3 py-2 text-caption`,children:[U?(0,Z.jsx)(H,{size:14,className:`shrink-0 text-success`}):null,(0,Z.jsx)(`span`,{className:U?`font-medium text-foreground`:`text-muted`,children:A})]}):null]}):null,ht?(0,Z.jsxs)(`div`,{className:`mt-4 flex flex-col gap-4`,children:[(0,Z.jsx)(`p`,{className:`rounded-lg bg-surface-secondary/45 px-3.5 py-3 text-caption leading-5 text-muted`,children:i(`doubaoCookieLead`)}),(0,Z.jsx)(j,{label:i(`doubaoCookieLabel`),children:(0,Z.jsx)(s,{className:`min-h-28 font-mono text-caption leading-5`,value:ve,onChange:e=>ye(e.target.value),placeholder:i(`doubaoCookiePh`),"aria-label":i(`doubaoCookieLabel`),disabled:V})}),A?(0,Z.jsxs)(`p`,{className:`flex items-center gap-2 rounded-lg bg-surface-secondary px-3 py-2 text-caption`,children:[U?(0,Z.jsx)(H,{size:14,className:`shrink-0 text-success`}):null,(0,Z.jsx)(`span`,{className:U?`font-medium text-foreground`:`text-muted`,children:A})]}):null]}):null,mt||ht?null:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(tt,{className:`mt-3`,value:p,onChange:e=>{!V&&e!==p&&(m(e),N(``),Ce(``),P(!1))},ariaLabel:i(`authentication`),options:gt.map(e=>({id:e.value,label:e.label}))}),(0,Z.jsx)(`p`,{className:`mt-2 min-h-5 text-caption leading-5 text-muted`,children:_t}),(0,Z.jsx)(`div`,{className:`mt-3 flex flex-col gap-4`,children:p===`browser`?(0,Z.jsxs)(Z.Fragment,{children:[R?.provider===`codex`?(0,Z.jsx)(Kn,{ariaLabel:i(`codexLoginMethod`),columns:2,value:Oe,onChange:e=>{V||Ae(e)},options:[{value:`cli`,label:i(`codexLoginCli`),hint:i(`codexLoginCliHint`),disabled:V||!!I.current},{value:`chatgpt`,label:i(`codexLoginChatGPT`),hint:i(`codexLoginChatGPTHint`),disabled:V||!!I.current}]}):null,R?.provider===`kiro`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Kn,{ariaLabel:i(`kiroLoginMethod`),columns:2,value:je,onChange:e=>{V||Me(e)},options:[{value:`builder_id`,label:i(`kiroLoginBuilder`),hint:i(`kiroLoginBuilderHint`),disabled:V||!!I.current},{value:`idc`,label:i(`kiroLoginIDC`),hint:i(`kiroLoginIDCHint`),disabled:V||!!I.current},{value:`sso`,label:i(`kiroLoginSSO`),hint:i(`kiroLoginSSOHint`),disabled:V||!!I.current},{value:`microsoft`,label:i(`kiroLoginMicrosoft`),hint:i(`kiroLoginMicrosoftHint`),disabled:V||!!I.current}]}),je===`idc`?(0,Z.jsx)(j,{label:i(`kiroIDCStartURL`),children:(0,Z.jsx)(xe,{value:Pe,onChange:e=>Fe(e.target.value),placeholder:i(`kiroIDCStartURLPh`),"aria-label":i(`kiroIDCStartURL`),disabled:V})}):null]}):null,Se?(0,Z.jsxs)(`div`,{className:`card rounded-xl bg-surface px-3 py-2.5`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-caption`,children:[(0,Z.jsx)(Ar,{phase:D,busy:V,tab:p,forTab:`browser`}),(0,Z.jsx)(`span`,{className:`text-muted`,children:A||i(`loginOpenMsg`)})]}),(0,Z.jsx)(`code`,{className:`mono mt-2 block break-all text-caption leading-5 text-foreground`,children:Se}),(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:[(0,Z.jsxs)(S,{size:`sm`,variant:`secondary`,onPress:()=>window.open(Se,`_blank`,`noopener,noreferrer`),children:[(0,Z.jsx)(c,{size:14}),i(`openAuthUrl`)]}),(0,Z.jsxs)(S,{size:`sm`,variant:`ghost`,onPress:()=>{f(Se).then(e=>{e&&(P(!0),window.setTimeout(()=>P(!1),1100))})},children:[(0,Z.jsx)(a,{copied:we}),i(we?`copied`:`copy`)]})]})]}):null,A&&!Se?(0,Z.jsxs)(`p`,{className:`flex items-center gap-2 rounded-lg bg-surface-secondary px-3 py-2 text-caption`,children:[U?(0,Z.jsx)(H,{size:14,className:`shrink-0 text-success`}):null,(0,Z.jsx)(`span`,{className:U?`font-medium text-foreground`:`text-muted`,children:A})]}):null,qe?(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`p`,{className:`text-caption leading-4 text-muted`,children:i(`wizardCallbackLead`)}),(0,Z.jsx)(s,{className:`h-28 w-full resize-none font-mono text-caption leading-5`,value:Ee,onChange:e=>De(e.target.value),placeholder:i(`wizardCallbackPh`),"aria-label":i(`wizardCallbackPh`),disabled:U}),(0,Z.jsx)(S,{size:`sm`,variant:`secondary`,isPending:D===`busy`&&!!Ee.trim(),onPress:()=>void ot(),isDisabled:U,children:i(`wizardSubmitCallback`)})]}):null]}):p===`pat`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(j,{label:i(`tabPat`),children:(0,Z.jsx)(xe,{type:`password`,value:oe,onChange:e=>se(e.target.value),placeholder:i(`wizardPatPh`),"aria-label":i(`wizardPatPh`),disabled:V})}),A?(0,Z.jsxs)(`p`,{className:`flex items-center gap-2 rounded-lg bg-surface-secondary px-3 py-2 text-caption`,children:[U?(0,Z.jsx)(H,{size:14,className:`shrink-0 text-success`}):null,(0,Z.jsx)(`span`,{className:U?`font-medium text-foreground`:`text-muted`,children:A})]}):null]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsx)(`span`,{className:`text-caption font-medium text-muted`,children:`JSON`}),(0,Z.jsxs)(S,{size:`sm`,variant:`secondary`,onPress:dt,isDisabled:V,children:[(0,Z.jsx)(Ft,{size:13}),i(`wizardChooseFile`)]}),(0,Z.jsx)(`input`,{ref:He,type:`file`,accept:`application/json,.json`,className:`hidden`,onChange:ft})]}),(0,Z.jsx)(s,{className:`min-h-32 font-mono text-caption`,value:ce,onChange:e=>le(e.target.value),placeholder:i(`wizardImportPh`),"aria-label":i(`tabImport`),disabled:V}),A?(0,Z.jsxs)(`p`,{className:`flex items-center gap-2 rounded-lg bg-surface-secondary px-3 py-2 text-caption`,children:[U?(0,Z.jsx)(H,{size:14,className:`shrink-0 text-success`}):null,(0,Z.jsx)(`span`,{className:U?`font-medium text-foreground`:`text-muted`,children:A})]}):null]})})]})]})})}),(0,Z.jsxs)(M.Footer,{className:`justify-end gap-2 px-5 pb-5`,children:[(0,Z.jsx)(S,{variant:`ghost`,onPress:q,isDisabled:V,children:i(`cancel`)}),o===`login`&&mt?(0,Z.jsx)(S,{isPending:D===`busy`,onPress:()=>void st(),isDisabled:U,children:U?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(H,{size:15}),i(`wizardAccountReady`)]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Ke,{size:15}),i(`zhipuCreate`)]})}):null,o===`login`&&ht?(0,Z.jsx)(S,{isPending:D===`busy`,onPress:()=>void lt(),isDisabled:U,children:U?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(H,{size:15}),i(`wizardAccountReady`)]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Ke,{size:15}),i(`doubaoImport`)]})}):null,o===`login`&&!mt&&!ht&&p===`browser`?(0,Z.jsx)(S,{isPending:pt(`browser`),onPress:()=>void at(),isDisabled:U,children:U?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(H,{size:15}),i(`wizardAccountReady`)]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(g,{size:15}),i(`wizardStartBrowser`)]})}):null,o===`login`&&!mt&&!ht&&p===`pat`?(0,Z.jsx)(S,{isPending:pt(`pat`),onPress:()=>void ct(),isDisabled:U,children:U?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(H,{size:15}),i(`patDone`)]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Ke,{size:15}),i(`wizardCreateAndLogin`)]})}):null,o===`login`&&!mt&&!ht&&p===`import`?(0,Z.jsx)(S,{isPending:pt(`import`),onPress:()=>void ut(),isDisabled:U,children:U?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(H,{size:15}),i(`accountImported`)]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Ft,{size:15}),i(`importCredential`)]})}):null]})]})})})})}function Pr(e,t){return e===`region_mixed`?t(`batchImportRegionMixed`):e===`region_unknown`?t(`batchImportRegionUnknown`):e===`unknown_format`?t(`batchImportUnknownFormat`):``}function Fr({isOpen:e,detection:t,fileName:n,isPending:r,t:i,onClose:a,onConfirm:o}){let s=t?.provider===`kiro`?[`us-east-1`,`eu-central-1`]:[`cn`,`global`],[c,l]=(0,J.useState)(t?.region&&s.includes(t.region)?t.region:s[0]);(0,J.useEffect)(()=>{if(!t)return;let e=t.provider===`kiro`?[`us-east-1`,`eu-central-1`]:[`cn`,`global`];t.region&&e.includes(t.region)?l(t.region):l(e[0])},[t]);let u=!!t?.batchImportSupported,d=t?.provider,f=t?.format||i(`batchImportFormatUnknown`),p=d?it(d,i):i(`batchImportProviderUnknown`),m=(t?.warnings||[]).map(e=>Pr(e,i)).filter(Boolean);return(0,Z.jsx)(M.Root,{isOpen:e,onOpenChange:e=>{!e&&!r&&a()},children:(0,Z.jsx)(M.Backdrop,{variant:`blur`,isDismissable:!r,children:(0,Z.jsx)(M.Container,{placement:`center`,size:`md`,scroll:`inside`,className:`mx-3 w-full max-w-[min(100%,32rem)] sm:mx-0`,children:(0,Z.jsxs)(M.Dialog,{children:[(0,Z.jsxs)(M.Header,{className:`items-start justify-between gap-4 px-6 pt-6`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(M.Heading,{className:`text-section font-semibold`,children:i(`batchImportConfirmTitle`)}),(0,Z.jsx)(`p`,{className:`mt-1 break-all text-caption leading-5 text-muted`,children:n?i(`batchImportConfirmHint`,{file:n}):i(`batchImportConfirmHintNoFile`)})]}),(0,Z.jsx)(M.CloseTrigger,{isDisabled:r,"aria-label":i(`close`),className:`grid size-8 shrink-0 place-items-center rounded-lg text-muted transition-colors hover:bg-surface-secondary hover:text-foreground`,children:(0,Z.jsx)(Xe,{size:16})})]}),(0,Z.jsxs)(M.Body,{className:`space-y-4 px-6 pb-2`,children:[(0,Z.jsx)(`div`,{className:`rounded-xl bg-surface-secondary px-3.5 py-3`,children:(0,Z.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[d?(0,Z.jsx)(nt,{provider:d,size:18}):null,(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`text-body font-medium text-foreground`,children:p}),(0,Z.jsx)(`div`,{className:`mono mt-0.5 truncate text-caption text-muted`,children:f})]})]})}),u?(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`div`,{className:`text-body font-medium text-muted`,children:i(d===`kiro`?`batchImportKiroRegion`:`batchImportRegion`)}),(0,Z.jsx)(tt,{value:c,onChange:e=>{s.includes(e)&&l(e)},ariaLabel:i(d===`kiro`?`batchImportKiroRegion`:`batchImportRegion`),options:d===`kiro`?[{id:`us-east-1`,label:i(`accountTypeKiroUS`)},{id:`eu-central-1`,label:i(`accountTypeKiroEU`)}]:[{id:`cn`,label:i(`accountTypeWorkBuddyCN`)},{id:`global`,label:i(`accountTypeWorkBuddyGlobal`)}]}),t?.regionAmbiguous?(0,Z.jsx)(`p`,{className:`text-caption leading-5 text-muted`,children:i(d===`kiro`?`batchImportKiroRegionPickHint`:`batchImportRegionPickHint`)}):null]}):(0,Z.jsx)(`p`,{className:`text-body leading-6 text-muted`,children:i(`batchImportProviderUnsupported`)}),m.length?(0,Z.jsx)(`ul`,{className:`space-y-1 text-caption leading-5 text-muted`,children:m.map(e=>(0,Z.jsx)(`li`,{children:e},e))}):null]}),(0,Z.jsxs)(M.Footer,{className:`flex-col-reverse gap-2 px-6 pb-6 sm:flex-row sm:justify-end`,children:[(0,Z.jsx)(S,{size:`sm`,variant:`ghost`,className:`w-full sm:w-auto`,isDisabled:r,onPress:a,children:i(u?`cancel`:`close`)}),u?(0,Z.jsx)(S,{size:`sm`,className:`w-full sm:w-auto`,isPending:r,onPress:()=>o(c),children:i(`batchImportConfirmAction`)}):null]})]})})})})}function Ir(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return typeof t.format==`string`&&t.format.trim().toLowerCase()===`cli2api-accounts`&&Array.isArray(t.accounts)}function Lr(e){let t;try{t=JSON.parse(e)}catch{throw Error(`bad_json`)}if(!Ir(t))throw Error(`bad_bundle`);return t}function Rr(e){let t=JSON.stringify(e,null,2),n=new Blob([t],{type:`application/json`}),r=URL.createObjectURL(n),i=(e.exported_at||new Date().toISOString()).replace(/[:.]/g,`-`).slice(0,19),a=document.createElement(`a`);a.href=r,a.download=`cli2api-accounts-${i}.json`,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(r)}function zr({isOpen:e,bundle:t,fileName:n,isPending:r,t:i,onClose:a,onConfirm:o}){let s=t?.accounts?.length??0,c=t?.accounts?.filter(e=>!!e.credential).length??0;return(0,Z.jsx)(M.Root,{isOpen:e,onOpenChange:e=>{!e&&!r&&a()},children:(0,Z.jsx)(M.Backdrop,{variant:`blur`,isDismissable:!r,children:(0,Z.jsx)(M.Container,{placement:`center`,size:`md`,scroll:`inside`,className:`mx-3 w-full max-w-[min(100%,32rem)] sm:mx-0`,children:(0,Z.jsxs)(M.Dialog,{children:[(0,Z.jsxs)(M.Header,{className:`items-start justify-between gap-4 px-6 pt-6`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(M.Heading,{className:`text-section font-semibold`,children:i(`bundleImportConfirmTitle`)}),(0,Z.jsx)(`p`,{className:`mt-1 break-all text-caption leading-5 text-muted`,children:n?i(`bundleImportConfirmHint`,{file:n}):i(`bundleImportConfirmHintNoFile`)})]}),(0,Z.jsx)(M.CloseTrigger,{isDisabled:r,"aria-label":i(`close`),className:`grid size-8 shrink-0 place-items-center rounded-lg text-muted transition-colors hover:bg-surface-secondary hover:text-foreground`,children:(0,Z.jsx)(Xe,{size:16})})]}),(0,Z.jsxs)(M.Body,{className:`space-y-3 px-6 pb-2`,children:[(0,Z.jsxs)(`div`,{className:`rounded-xl bg-surface-secondary px-3.5 py-3 text-body leading-6 text-foreground`,children:[(0,Z.jsx)(`div`,{className:`mono text-lg font-semibold`,children:s}),(0,Z.jsx)(`div`,{className:`text-muted`,children:i(`bundleImportAccountCount`)})]}),(0,Z.jsx)(`p`,{className:`text-body leading-6 text-muted`,children:i(`bundleImportCountDetail`,{credentials:c})}),(0,Z.jsx)(`p`,{className:`text-body leading-6 text-muted`,children:i(`bundleImportAdditiveHint`)}),(0,Z.jsx)(`p`,{className:`text-caption leading-5 text-muted`,children:i(`bundleExportHint`)})]}),(0,Z.jsxs)(M.Footer,{className:`flex-col-reverse gap-2 px-6 pb-6 sm:flex-row sm:justify-end`,children:[(0,Z.jsx)(S,{size:`sm`,variant:`ghost`,className:`w-full sm:w-auto`,isDisabled:r,onPress:a,children:i(`cancel`)}),(0,Z.jsx)(S,{size:`sm`,className:`w-full sm:w-auto`,isPending:r,isDisabled:s===0,onPress:o,children:i(`bundleImportConfirmAction`)})]})]})})})})}function Br(e){if(!Array.isArray(e.accounts))return[e];let t=e.accounts.filter(e=>!!e&&typeof e==`object`&&!Array.isArray(e)&&hr(e));return t.length>0?t:[e]}function Vr(e,t){let n=Br(e),r=n.find(e=>typeof e.nickname==`string`||typeof e.email==`string`),i=typeof r?.nickname==`string`?r.nickname.trim():``,a=typeof r?.email==`string`?r.email.trim():``;return{format:`kiro-oauth-v1`,provider:`kiro`,region:mr(n[0]||e)||t,enabled:!0,name:n.length===1&&(i||a)||void 0,accounts:n.map(e=>({...e,region:mr(e)||t}))}}var Hr=`__all__`,Ur=[];function Wr(){let{t:e}=re(),[t,n]=(0,J.useState)([]),[r,i]=(0,J.useState)(null),[a,s]=(0,J.useState)(``),[c,u]=(0,J.useState)([]),[d,g]=(0,J.useState)(!0),_=c,v=_.length>0,[y,ne]=(0,J.useState)(!1),[b,x]=(0,J.useState)(!1),[C,ie]=(0,J.useState)(!1),[w,ae]=(0,J.useState)(!1),[T,oe]=(0,J.useState)(!1),[se,ce]=(0,J.useState)(null),[le,E]=(0,J.useState)(``),[ue,de]=(0,J.useState)(!1),[me,_e]=(0,J.useState)(null),[ve,ye]=(0,J.useState)(null),[D,O]=(0,J.useState)(``),[be,A]=(0,J.useState)(null),[xe,j]=(0,J.useState)({}),[M,Se]=(0,J.useState)({}),[Ce,P]=(0,J.useState)({}),[Oe,Ne]=(0,J.useState)({}),[Pe,Ve]=(0,J.useState)({}),[L,He]=(0,J.useState)(null),[Ue,R]=(0,J.useState)(null),[We,Ge]=(0,J.useState)(null),[z,B]=(0,J.useState)(null),[Ke,qe]=(0,J.useState)(null),[H,Je]=(0,J.useState)(``),[W,G]=(0,J.useState)(`all`),[Xe,K]=(0,J.useState)(``),[Ze,Qe]=(0,J.useState)(1),[$e,et]=(0,J.useState)(20),[rt,ot]=(0,J.useState)({}),[st,ct]=(0,J.useState)({}),[lt,ut]=(0,J.useState)({}),[dt,ft]=(0,J.useState)({}),[pt,mt]=(0,J.useState)(!1),[ht,gt]=(0,J.useState)(!1),[vt,bt]=(0,J.useState)(!1),[xt,St]=(0,J.useState)([]),[Ct,wt]=(0,J.useState)(!1),[Tt,Et]=(0,J.useState)(null),Y=(0,J.useCallback)(async(e=!1)=>{try{let t=(await Le(e)).data||Ur;return u(t),t}finally{g(!1)}},[]),Dt=(0,J.useCallback)(async(e,t=!0)=>{let n=await Ee(e,{quota:t});u(t=>t.map(t=>t.id===e?{...t,...n}:t))},[]),Ot=(0,J.useCallback)(async(t=!0)=>{let n=(await I({quota:t})).data||[],r={},i=[],a={},o=0;for(let t of n){if(t.ok){t.quota&&(a[t.account_id]=t.quota);continue}o+=1;let n=t.message||t.code||t.kind||e(`toastFailed`);r[t.account_id]=n,i.push(n)}return Object.keys(a).length&&u(e=>e.map(e=>a[e.id]?{...e,quota:a[e.id]}:e)),o&&P(e=>({...e,...r})),await Y(!1).catch(()=>void 0),{total:n.length,failed:o,errors:i}},[Y,e]),At=(0,J.useRef)(null),jt=(0,J.useCallback)(()=>{At.current??=window.setTimeout(()=>{At.current=null,Y(!1).catch(()=>void 0)},400)},[Y]),Mt=(0,J.useCallback)(t=>{let n=t.type;if(n===`account`){let e=t.data||{},n=e.account_id||t.account_id;if(!n)return;u(t=>t.map(t=>{if(t.id!==n)return t;let r={...t};return e.runtime_state&&(r.runtime_state=e.runtime_state),typeof e.ready==`boolean`&&(r.ready=e.ready,e.ready&&(r.hot=t.hot&&e.runtime_state!==`ready`)),e.cooldown_until?r.cooldown_until=e.cooldown_until:e.ready&&(r.cooldown_until=null),e.last_error!==void 0&&(r.last_error=e.last_error,r.lastError=e.last_error||void 0),e.last_kind!==void 0&&(r.last_error_kind=e.last_kind||void 0),r})),jt();return}if(n===`quota`){let e=t.data||{},n=e.account_id||t.account_id;if(!n||!e.quota)return;u(t=>t.map(t=>t.id===n?{...t,quota:e.quota}:t)),jt();return}if(n===`checkin`){let n=t.data||{},r=n.account_id||t.account_id;if(!r)return;let i=String(n.status||``).toLowerCase(),a=i===`already`||i===`skipped`||i===`error`||i===`unknown`?i:`success`,o=typeof n.reward_credits==`number`&&n.reward_credits>0?e(`checkinRewardSuffix`,{credits:at(n.reward_credits)}):``,s=`${n.message||(a===`error`?e(`checkinRecordFailed`):a===`unknown`?e(`checkinStatusUnknown`):``)}${o}`.trim();Ne(e=>({...e,[r]:{kind:a,message:s||void 0}})),u(e=>e.map(e=>e.id===r?{...e,last_checkin_status:n.status||e.last_checkin_status,last_checkin_msg:n.message||e.last_checkin_msg,last_checkin_at:n.at||e.last_checkin_at}:e));return}if(n===`accounts`){Y(!1).catch(()=>void 0);return}if(n===`bulk`){let e=t.data||{},n=e.kind===`refresh`?`refresh`:e.kind===`checkin`?`checkin`:null;if(!n)return;if(e.phase===`done`){Et(null);return}if(!e.total)return;Et({kind:n,total:e.total,done:e.done||0})}},[Y,jt,e]),{status:Pt}=yt(Mt);(0,J.useEffect)(()=>()=>{At.current!=null&&window.clearTimeout(At.current)},[]),(0,J.useEffect)(()=>{Y(!1).catch(()=>void 0)},[Y]),(0,J.useEffect)(()=>{if(Pt===`live`)return;let e=window.setInterval(()=>{document.hidden||Y(!1).catch(()=>void 0)},5e3);return()=>window.clearInterval(e)},[Pt,Y]),(0,J.useEffect)(()=>{let e=!0;return Promise.all([Ae(),V()]).then(([t,r])=>{e&&(n(t.data||[]),i(r))}).catch(t=>{e&&s(t instanceof Error?t.message:String(t))}),()=>{e=!1}},[]);function Ft(e){return t.find(t=>t.id===e.provider)?.regions.find(t=>t.id===e.region)?.checkin}function It(e){let t=Ft(e)?.timezone,n=t===`Local`?`Asia/Shanghai`:t||`Asia/Shanghai`;try{return Intl.DateTimeFormat(`en-CA`,{timeZone:n}),n}catch{return}}let X=(0,J.useMemo)(()=>_.map(e=>{let t=rt[e.id],n=st[e.id],r=lt[e.id],i=dt[e.id],a=e;return t!==void 0&&(a={...a,enabled:t}),n!==void 0&&(a={...a,name:n}),r!==void 0&&(a={...a,max_inflight:r}),i!==void 0&&(a={...a,priority:i}),a}),[rt,lt,st,dt,_]),Lt=(0,J.useMemo)(()=>{let e={all:X.length,available:0,attention:0,disabled:0};for(let t of X){let n=_t(t);n===`hot`||n===`ready`?e.available+=1:n===`disabled`&&(e.disabled+=1),t.enabled&&n!==`hot`&&n!==`ready`&&(e.attention+=1)}return e},[X]),zt=(0,J.useMemo)(()=>{let e=new Map;for(let t of X){let n=String(t.provider||`qoder`).toLowerCase();e.set(n,(e.get(n)||0)+1)}return[...e.entries()].sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0]))},[X]),Bt=X.find(e=>e.id===L),Vt=X.find(e=>e.id===Ue)||null,Ut=X.find(e=>e.id===We)||null,Wt=X.find(e=>e.id===z)||null,Gt=(0,J.useMemo)(()=>{let e=H.trim().toLowerCase();return X.filter(t=>{let n=_t(t);return!(W===`all`||W===`available`&&(n===`hot`||n===`ready`)||W===`attention`&&t.enabled&&n!==`hot`&&n!==`ready`||W===`disabled`&&n===`disabled`)||Xe&&String(t.provider||`qoder`).toLowerCase()!==Xe?!1:!e||[t.name,t.id,t.remote_uid,t.provider,t.auth_type].some(t=>String(t||``).toLowerCase().includes(e))})},[X,W,Xe,H]),Kt=[H,W,Xe,$e].join(`\0`),[qt,Jt]=(0,J.useState)(Kt);qt!==Kt&&(Jt(Kt),Qe(1));let Yt=Math.max(1,Math.ceil(Gt.length/$e)),Xt=Math.min(qt===Kt?Math.max(1,Ze):1,Yt);Ze!==Xt&&Qe(Xt);let Zt=(0,J.useMemo)(()=>{let e=(Xt-1)*$e;return Gt.slice(e,e+$e)},[Xt,Gt,$e]),Qt=(0,J.useMemo)(()=>_.filter(e=>xt.includes(e.id)),[_,xt]);if(d&&!v)return(0,Z.jsx)(Ye,{});async function $t(e,t,n){A({id:e,kind:t}),P(t=>({...t,[e]:``}));try{return await n(),!0}catch(t){return P(n=>({...n,[e]:t instanceof Error?t.message:String(t)})),!1}finally{A(null)}}async function en(t,n){qe(t),await $t(t,`device`,async()=>{P(n=>({...n,[t]:e(`wizardStartingSession`)}));let r=await ze(t,n);r.authUrl&&Ve(e=>({...e,[t]:r.authUrl||``}));for(let n=0;n<60;n++){await new Promise(e=>window.setTimeout(e,2e3));let n=(await ke(t)).login||{};if(P(r=>({...r,[t]:n.message||e(`waitingQoderLogin`)})),n.status===`ok`||n.status===`error`)break}await Y(!1),await Dt(t)})}async function tn(t){let n=(M[t]||``).trim();if(!n){P(n=>({...n,[t]:e(`wizardCallbackPh`)}));return}await $t(t,`callback`,async()=>{P(n=>({...n,[t]:e(`wizardStartingSession`)})),await F(t,n),Se(e=>({...e,[t]:``})),await Y(!1),await Dt(t)})&&(qe(e=>e===t?null:e),P(e=>({...e,[t]:``})))}async function nn(t){let n=(xe[t]||``).trim();if(!n){P(n=>({...n,[t]:e(`pastePatFirst`)}));return}await $t(t,`pat`,async()=>{P(n=>({...n,[t]:e(`wizardStartingSession`)})),await Be(n,t),j(e=>({...e,[t]:``})),await Y(!1),await Dt(t)})}async function rn(t){await $t(t,`export`,async()=>{let n=await De(t);await f(JSON.stringify(n,null,2)),P(n=>({...n,[t]:e(`credentialCopied`)}))})}async function an(){if(C)return;ie(!0);let t=`accounts-export-all`;q({id:t,type:`loading`,title:e(`toastAccountsExporting`)});try{let n=await Me();Rr(n),q({id:t,type:`success`,title:e(`toastAccountsExported`,{n:n.count??n.accounts.length}),description:e(`bundleExportHint`)})}catch(n){q({id:t,type:`error`,title:e(`toastFailed`),description:n instanceof Error?n.message:String(n)})}finally{ie(!1)}}function on(){w||(oe(!1),ce(null),E(``))}async function sn(t){let n=t.target.files?.[0];if(t.target.value=``,n)try{let e=Lr(await n.text());ce(e),E(n.name),oe(!0)}catch(t){let n=t instanceof Error?t.message:String(t);q({type:`error`,title:e(n===`bad_json`?`wizardBadJson`:`bundleImportUnrecognized`)})}}async function cn(){if(!se||w)return;ae(!0);let t=`bundle-import-accounts`;q({id:t,type:`loading`,title:e(`bundleImportLoading`)});try{let n=await Re(se),r=n.succeeded??0,i=n.failed??0,a=(n.errors||[]).slice(0,3).map(e=>e.message||`index ${e.index}`).filter(Boolean).join(`; `);q({id:t,type:i>0&&r===0?`error`:i>0?`info`:`success`,title:i>0?e(`accountImportPartial`).replace(`{ok}`,String(r)).replace(`{fail}`,String(i)):e(`accountImportBatch`).replace(`{n}`,String(r)),description:a||void 0}),oe(!1),ce(null),E(``),r>0&&await Y(!1)}catch(n){q({id:t,type:`error`,title:e(`toastFailed`),description:n instanceof Error?n.message:String(n)})}finally{ae(!1)}}async function ln(e,t){ot(n=>({...n,[e]:t})),await $t(e,`toggle`,async()=>{await we(e,{enabled:t}),await Y(!1)}),ot(t=>{let n={...t};return delete n[e],n})}async function un(t){q({id:`refresh-${t}`,type:`loading`,title:e(`toastRefreshingAccount`)}),A({id:t,kind:`refresh`}),P(e=>{let n={...e};return delete n[t],n});try{await Dt(t),q({id:`refresh-${t}`,type:`success`,title:e(`toastAccountRefreshed`)})}catch(n){let r=n instanceof Error?n.message:String(n);P(e=>({...e,[t]:r})),q({id:`refresh-${t}`,type:`error`,title:e(`toastFailed`),description:r})}finally{A(null)}}async function dn(){mt(!0),q({id:`refresh-credits`,type:`loading`,title:e(`toastRefreshingCredits`)});try{let t=await Ot(!0);if(t.failed>0){let n=t.failed0&&r===0?`error`:i>0?`info`:`success`,title:a}),de(!1),_e(null),ye(null),O(``),r>0&&await Y(!1)}catch(t){q({id:n,type:`error`,title:e(`toastFailed`),description:t instanceof Error?t.message:String(t)})}finally{x(!1)}}async function hn(e,t){await $t(e,`toggle`,async()=>{await we(e,{auto_checkin:t}),await Y(!1)})}async function gn(){gt(!0),q({id:`checkin-all`,type:`loading`,title:e(`toastCheckingInAll`,{done:0,total:_.length})});try{let t=(await je()).data||[];if(t.length===0){q({id:`checkin-all`,type:`info`,title:e(`checkinAllEmpty`)});return}let n={checked:0,skipped:0,failed:0,unknown:0,credits:0},r={},i={},a=``;for(let o of t){let t=String(o.status||``).toLowerCase(),s=t===`already`||t===`skipped`||t===`error`||t===`unknown`?t:`success`;s===`error`?(n.failed+=1,a||=o.message||``):s===`skipped`||s===`already`?n.skipped+=1:s===`unknown`?n.unknown+=1:n.checked+=1,typeof o.reward_credits==`number`&&o.reward_credits>0&&(n.credits+=o.reward_credits);let c=o.reward_credits&&o.reward_credits>0?e(`checkinRewardSuffix`,{credits:at(o.reward_credits)}):``,l=`${o.message||(s===`error`?e(`checkinRecordFailed`):s===`unknown`?e(`checkinStatusUnknown`):``)}${c}`.trim();r[o.account_id]={kind:s,message:l||void 0},s===`error`&&(i[o.account_id]=[o.message,o.code,o.http_status?`HTTP ${o.http_status}`:``].filter(Boolean).join(` · `)||e(`checkinRecordFailed`))}Ne(e=>({...e,...r})),Object.keys(i).length&&P(e=>({...e,...i}));let o={checked:n.checked,skipped:n.skipped,failed:n.failed,total:t.length},s=n.credits>0?e(`checkinRewardTotal`,{credits:at(n.credits)}):n.failed&&a?a:void 0;q({id:`checkin-all`,type:n.failed?`error`:n.unknown?`info`:`success`,title:e(n.failed?`toastCheckedInAllFailed`:`toastCheckedInAll`,o),description:s})}catch(t){q({id:`checkin-all`,type:`error`,title:e(`toastFailed`),description:t instanceof Error?t.message:String(t)})}finally{gt(!1),await Y(!1).catch(()=>void 0)}}async function _n(t){await $t(t,`checkin`,async()=>{let n;try{n=await Fe(t)}catch(e){Ne(n=>({...n,[t]:{kind:`error`,message:e instanceof Error?e.message:String(e)}})),await Y(!1).catch(()=>void 0),await Dt(t).catch(()=>void 0);return}let r=n?.last_checkin_status,i=n?.last_checkin_msg,a=r===`already`?`already`:r===`skipped`?`skipped`:r===`error`?`error`:r===`unknown`?`unknown`:`success`;Ne(n=>({...n,[t]:{kind:a,message:a===`error`?i||e(`checkinRecordFailed`):i}})),await Y(!1).catch(()=>void 0),await Dt(t).catch(()=>void 0)})}async function vn(t,n){if(!t)throw Error(e(`accountNameRequired`));ct(e=>({...e,[t]:n.name})),ut(e=>({...e,[t]:n.max_inflight})),ft(e=>({...e,[t]:n.priority})),A({id:t,kind:`settings`});try{await we(t,n),await Y(!1)}catch(e){throw e instanceof Error?e:Error(String(e))}finally{A(null),ct(e=>{let n={...e};return delete n[t],n}),ut(e=>{let n={...e};return delete n[t],n}),ft(e=>{let n={...e};return delete n[t],n})}}return(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[a?(0,Z.jsx)(he,{title:a}):null,(0,Z.jsxs)(`section`,{"data-gsap-reveal":!0,className:`flex flex-wrap items-center gap-2`,children:[_.length?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(tt,{value:W,onChange:e=>G(e),ariaLabel:e(`accountStatusFilter`),options:[{id:`all`,label:(0,Z.jsxs)(Z.Fragment,{children:[e(`filterAll`),(0,Z.jsx)(`span`,{className:`mono text-muted`,children:Lt.all})]})},{id:`available`,label:(0,Z.jsxs)(Z.Fragment,{children:[e(`availableAccounts`),(0,Z.jsx)(`span`,{className:`mono text-muted`,children:Lt.available})]})},{id:`attention`,label:(0,Z.jsxs)(Z.Fragment,{children:[e(`needsAttention`),(0,Z.jsx)(`span`,{className:`mono ${Lt.attention?`text-danger`:`text-muted`}`,children:Lt.attention})]})},{id:`disabled`,label:(0,Z.jsxs)(Z.Fragment,{children:[e(`disabled`),(0,Z.jsx)(`span`,{className:`mono text-muted`,children:Lt.disabled})]})}]}),(0,Z.jsxs)(N,{className:`w-48`,"aria-label":e(`providerFilterAll`),value:Xe||Hr,onChange:e=>{typeof e==`string`&&K(e===Hr?``:e)},children:[(0,Z.jsxs)(N.Trigger,{className:`items-center`,children:[(0,Z.jsx)(N.Value,{className:`min-w-0 truncate`}),(0,Z.jsx)(N.Indicator,{})]}),(0,Z.jsx)(N.Popover,{children:(0,Z.jsxs)(pe,{children:[(0,Z.jsxs)(pe.Item,{id:Hr,textValue:e(`providerFilterAll`),children:[(0,Z.jsxs)(fe,{className:`flex items-center gap-2`,children:[e(`providerFilterAll`),(0,Z.jsx)(`span`,{className:`mono text-muted`,children:_.length})]}),(0,Z.jsx)(pe.ItemIndicator,{})]}),zt.map(([t,n])=>(0,Z.jsxs)(pe.Item,{id:t,textValue:it(t,e),children:[(0,Z.jsxs)(fe,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(nt,{provider:t,size:13}),it(t,e),(0,Z.jsx)(`span`,{className:`mono text-muted`,children:n})]}),(0,Z.jsx)(pe.ItemIndicator,{})]},t))]})})]}),(0,Z.jsx)(h,{className:`w-full sm:w-60`,value:H,onChange:Je,placeholder:e(`searchAccounts`),ariaLabel:e(`searchAccounts`)})]}):null,(0,Z.jsxs)(`div`,{className:`flex w-full flex-wrap items-center justify-end gap-2 sm:ml-auto sm:w-auto`,children:[(0,Z.jsxs)(S,{size:`sm`,variant:`secondary`,isPending:C,isDisabled:b||ue||w||T,onPress:()=>void an(),children:[(0,Z.jsx)(Nt,{size:14}),e(`exportAll`)]}),(0,Z.jsxs)(`label`,{htmlFor:`accounts-bundle-import-file`,className:`button button--sm button--secondary inline-flex items-center gap-1.5 ${w||T||b||ue||C?`pointer-events-none opacity-60`:`cursor-pointer`}`,children:[w?(0,Z.jsx)(U,{size:14,loading:!0}):(0,Z.jsx)(Nt,{size:14}),e(`importAll`)]}),(0,Z.jsx)(`input`,{id:`accounts-bundle-import-file`,type:`file`,accept:`.json,application/json,text/json`,disabled:w||T||b||ue||C,className:`sr-only`,onChange:e=>void sn(e)}),(0,Z.jsxs)(S,{size:`sm`,variant:`secondary`,isPending:ht,isDisabled:pt,onPress:()=>void gn(),children:[(0,Z.jsx)(kt,{size:14}),e(`checkinAll`)]}),(0,Z.jsxs)(S,{size:`sm`,variant:`secondary`,isPending:pt,isDisabled:ht,onPress:()=>void dn(),children:[(0,Z.jsx)(o,{size:14}),e(`refreshCredits`)]}),(0,Z.jsxs)(S,{size:`sm`,variant:vt?`primary`:`secondary`,isDisabled:ht||pt,onPress:()=>{bt(e=>!e),St([])},children:[(0,Z.jsx)(Rt,{size:14}),e(`reloginEntry`)]}),(0,Z.jsxs)(`label`,{htmlFor:`accounts-batch-import-file`,className:`button button--sm button--secondary inline-flex items-center gap-1.5 ${b||ue||w||T||C?`pointer-events-none opacity-60`:`cursor-pointer`}`,children:[b?(0,Z.jsx)(U,{size:14,loading:!0}):(0,Z.jsx)(Ht,{size:14}),e(`batchImport`)]}),(0,Z.jsx)(`input`,{id:`accounts-batch-import-file`,type:`file`,accept:`.json,application/json,text/json`,disabled:b||ue||w||T||C,className:`sr-only`,onChange:e=>void pn(e)}),(0,Z.jsxs)(S,{size:`sm`,onPress:()=>ne(!0),children:[(0,Z.jsx)(te,{size:14}),e(`addAccount`)]})]}),Pt===`offline`?(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full bg-surface-secondary px-2 py-0.5 text-caption text-muted`,"data-events-offline":!0,children:[(0,Z.jsx)(`span`,{className:`size-1.5 rounded-full bg-warning`}),e(`eventsOffline`)]}):null]}),Tt?(0,Z.jsxs)(`div`,{"data-bulk-progress":!0,className:`flex items-center gap-3 rounded-lg bg-surface-secondary px-3 py-2 text-caption`,children:[(0,Z.jsx)(U,{size:14,loading:!0}),(0,Z.jsx)(`span`,{className:`shrink-0 font-medium text-foreground`,children:Tt.kind===`checkin`?e(`checkinAll`):e(`refreshCredits`)}),(0,Z.jsxs)(`span`,{className:`mono shrink-0 tabular-nums text-foreground/70`,children:[Tt.done,`/`,Tt.total]}),(0,Z.jsx)(`div`,{className:`h-1.5 min-w-16 flex-1 overflow-hidden rounded-full bg-surface`,children:(0,Z.jsx)(`div`,{className:`h-full rounded-full bg-success transition-[width] duration-200`,style:{width:`${Math.min(100,Math.round(Tt.done/Math.max(1,Tt.total)*100))}%`}})})]}):null,(0,Z.jsx)(Nr,{isOpen:y,onClose:()=>ne(!1),onAdded:()=>{q({type:`success`,title:e(`toastAccountAdded`)}),Y(!1)}}),(0,Z.jsx)(zr,{isOpen:T,bundle:se,fileName:le,isPending:w,t:e,onClose:on,onConfirm:()=>{cn()}}),(0,Z.jsx)(Fr,{isOpen:ue,detection:me,fileName:D,isPending:b,t:e,onClose:fn,onConfirm:e=>{mn(e)}}),(0,Z.jsx)(Un,{account:Vt,t:e,onClose:()=>R(null)},Ue??`closed`),(0,Z.jsx)(In,{isOpen:Ct,accounts:Qt,t:e,onClose:()=>{wt(!1),bt(!1),St([])},onFinished:()=>{Y(!1)}}),(0,Z.jsx)(Vn,{account:Ut,t:e,onClose:()=>Ge(null)},We??`closed`),(0,Z.jsx)(Wn,{account:Wt,busy:!!(be&&be.id===z&&be.kind===`settings`),t:e,onClose:()=>B(null),onSave:e=>vn(z||``,e)},z??`closed`),(0,Z.jsx)(ge,{isOpen:!!Bt,title:e(`delete`),description:e(`deleteAccountConfirm`,{name:Bt?.name||Bt?.id||``}),confirmLabel:e(`delete`),cancelLabel:e(`cancel`),closeLabel:e(`close`),isPending:be?.id===L&&be.kind===`delete`,onClose:()=>He(null),onConfirm:()=>{if(!Bt)return;let t=Bt.id;He(null),$t(t,`delete`,async()=>{await Ie(t),await Y(!1)}).then(t=>{t&&q({type:`success`,title:e(`toastAccountDeleted`)})})}}),v?null:(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsx)(k,{className:`rounded-3xl bg-surface-secondary`,icon:(0,Z.jsx)(U,{size:28}),title:e(`noAccounts`),hint:e(`accountEmptyHint`),action:(0,Z.jsxs)(S,{size:`sm`,onPress:()=>ne(!0),children:[(0,Z.jsx)(te,{size:14}),e(`addAccount`)]})}),(0,Z.jsx)(`div`,{className:`text-center`,children:(0,Z.jsx)(l,{})})]}),v&&!Gt.length?(0,Z.jsx)(k,{className:`rounded-3xl bg-surface-secondary`,icon:(0,Z.jsx)(p,{size:22}),title:e(`noAccountsMatch`),action:(0,Z.jsx)(S,{size:`sm`,variant:`ghost`,onPress:()=>{Je(``),G(`all`),K(``)},children:e(`clearFilters`)})}):null,vt?(0,Z.jsxs)(`div`,{"data-relogin-bar":!0,className:`flex flex-wrap items-center gap-2 rounded-lg border border-accent/40 bg-surface-secondary px-3 py-2 text-caption`,children:[(0,Z.jsx)(`span`,{className:`font-medium text-foreground`,children:e(`reloginSelected`,{count:xt.length})}),(0,Z.jsx)(S,{size:`sm`,variant:`ghost`,onPress:()=>St(Zt.map(e=>e.id)),children:e(`reloginSelectPage`)}),(0,Z.jsx)(S,{size:`sm`,variant:`ghost`,isDisabled:!xt.length,onPress:()=>St([]),children:e(`reloginClear`)}),(0,Z.jsxs)(`div`,{className:`ml-auto flex items-center gap-2`,children:[(0,Z.jsx)(S,{size:`sm`,variant:`secondary`,onPress:()=>{bt(!1),St([])},children:e(`cancel`)}),(0,Z.jsx)(S,{size:`sm`,isDisabled:!xt.length,onPress:()=>wt(!0),children:e(`reloginConfirm`)})]})]}):null,(0,Z.jsx)(`section`,{className:`grid auto-rows-[minmax(280px,auto)] gap-2.5 lg:grid-cols-2 xl:grid-cols-3 2xl:grid-cols-4`,children:Zt.map(t=>(0,Z.jsx)(Nn,{account:t,selectable:vt,selected:xt.includes(t.id),onSelectToggle:()=>St(e=>e.includes(t.id)?e.filter(e=>e!==t.id):[...e,t.id]),busyKind:be?.id===t.id?be.kind:``,authPanelOpen:Ke===t.id,authUrl:Pe[t.id],note:Ce[t.id],pat:xe[t.id]||``,t:e,onPatChange:e=>j(n=>({...n,[t.id]:e})),callbackUrl:M[t.id]||``,onCallbackChange:e=>Se(n=>({...n,[t.id]:e})),onSubmitCallback:()=>void tn(t.id),onDeviceLogin:e=>void en(t.id,e),onPatLogin:()=>void nn(t.id),onExport:()=>void rn(t.id),onRefresh:()=>void un(t.id),onDelete:()=>He(t.id),onToggle:e=>void ln(t.id,e),checkinDefaultTime:r?.checkin_times[t.provider||``],checkinTimezone:It(t),onToggleAutoCheckin:Ft(t)?e=>void hn(t.id,e):void 0,onCheckin:Ft(t)?()=>void _n(t.id):void 0,checkinFeedback:Oe[t.id]??null,onViewCheckins:Ft(t)?()=>Ge(t.id):void 0,onEdit:()=>B(t.id),onToggleAuthPanel:()=>qe(e=>e===t.id?null:t.id),onViewModels:()=>R(t.id)},t.id))}),Gt.length?(0,Z.jsx)(ee,{total:Gt.length,page:Xt,pageCount:Yt,pageSize:$e,pageSizes:m,loading:!1,pageSizeLabel:e(`logsPageSize`),pageLabel:e(`logsPage`,{page:Xt,pages:Yt}),prevLabel:e(`logsPrevPage`),nextLabel:e(`logsNextPage`),onPage:Qe,onPageSize:et}):null]})}export{Wr as AccountsPage}; \ No newline at end of file diff --git a/internal/webui/static/assets/CaiaiSoftLink-BXfOUHck.js b/internal/webui/static/assets/CaiaiSoftLink-6tjwsEDV.js similarity index 94% rename from internal/webui/static/assets/CaiaiSoftLink-BXfOUHck.js rename to internal/webui/static/assets/CaiaiSoftLink-6tjwsEDV.js index 364c948c..4a9e9b06 100644 --- a/internal/webui/static/assets/CaiaiSoftLink-BXfOUHck.js +++ b/internal/webui/static/assets/CaiaiSoftLink-6tjwsEDV.js @@ -1 +1 @@ -import{a as e,c as t,n}from"./shim-mfK0Rmj6.js";import{t as r}from"./Check.es-Bl43hv4j.js";import{n as i}from"./clipboard-BMEt1jHG.js";import{n as a,pt as o}from"./useI18n-BSw4X3mq.js";import{c as s,z as c}from"./SharedElementTransition-BlCsXfb1.js";import{r as l,t as u}from"./textfield-IBBKEG4T.js";import{r as d}from"./gsap-C3sDxib7.js";import{v as f,x as p,y as m}from"./index-C8_qeOs_.js";var h=t(e(),1),g=new Map([[`bold`,h.createElement(h.Fragment,null,h.createElement(`path`,{d:`M228,104a12,12,0,0,1-24,0V69l-59.51,59.51a12,12,0,0,1-17-17L187,52H152a12,12,0,0,1,0-24h64a12,12,0,0,1,12,12Zm-44,24a12,12,0,0,0-12,12v64H52V84h64a12,12,0,0,0,0-24H48A20,20,0,0,0,28,80V208a20,20,0,0,0,20,20H176a20,20,0,0,0,20-20V140A12,12,0,0,0,184,128Z`}))],[`duotone`,h.createElement(h.Fragment,null,h.createElement(`path`,{d:`M184,80V208a8,8,0,0,1-8,8H48a8,8,0,0,1-8-8V80a8,8,0,0,1,8-8H176A8,8,0,0,1,184,80Z`,opacity:`0.2`}),h.createElement(`path`,{d:`M224,104a8,8,0,0,1-16,0V59.32l-66.33,66.34a8,8,0,0,1-11.32-11.32L196.68,48H152a8,8,0,0,1,0-16h64a8,8,0,0,1,8,8Zm-40,24a8,8,0,0,0-8,8v72H48V80h72a8,8,0,0,0,0-16H48A16,16,0,0,0,32,80V208a16,16,0,0,0,16,16H176a16,16,0,0,0,16-16V136A8,8,0,0,0,184,128Z`}))],[`fill`,h.createElement(h.Fragment,null,h.createElement(`path`,{d:`M192,136v72a16,16,0,0,1-16,16H48a16,16,0,0,1-16-16V80A16,16,0,0,1,48,64h72a8,8,0,0,1,0,16H48V208H176V136a8,8,0,0,1,16,0Zm32-96a8,8,0,0,0-8-8H152a8,8,0,0,0-5.66,13.66L172.69,72l-42.35,42.34a8,8,0,0,0,11.32,11.32L184,83.31l26.34,26.35A8,8,0,0,0,224,104Z`}))],[`light`,h.createElement(h.Fragment,null,h.createElement(`path`,{d:`M222,104a6,6,0,0,1-12,0V54.49l-69.75,69.75a6,6,0,0,1-8.48-8.48L201.51,46H152a6,6,0,0,1,0-12h64a6,6,0,0,1,6,6Zm-38,26a6,6,0,0,0-6,6v72a2,2,0,0,1-2,2H48a2,2,0,0,1-2-2V80a2,2,0,0,1,2-2h72a6,6,0,0,0,0-12H48A14,14,0,0,0,34,80V208a14,14,0,0,0,14,14H176a14,14,0,0,0,14-14V136A6,6,0,0,0,184,130Z`}))],[`regular`,h.createElement(h.Fragment,null,h.createElement(`path`,{d:`M224,104a8,8,0,0,1-16,0V59.32l-66.33,66.34a8,8,0,0,1-11.32-11.32L196.68,48H152a8,8,0,0,1,0-16h64a8,8,0,0,1,8,8Zm-40,24a8,8,0,0,0-8,8v72H48V80h72a8,8,0,0,0,0-16H48A16,16,0,0,0,32,80V208a16,16,0,0,0,16,16H176a16,16,0,0,0,16-16V136A8,8,0,0,0,184,128Z`}))],[`thin`,h.createElement(h.Fragment,null,h.createElement(`path`,{d:`M220,104a4,4,0,0,1-8,0V49.66l-73.16,73.17a4,4,0,0,1-5.66-5.66L206.34,44H152a4,4,0,0,1,0-8h64a4,4,0,0,1,4,4Zm-36,28a4,4,0,0,0-4,4v72a4,4,0,0,1-4,4H48a4,4,0,0,1-4-4V80a4,4,0,0,1,4-4h72a4,4,0,0,0,0-8H48A12,12,0,0,0,36,80V208a12,12,0,0,0,12,12H176a12,12,0,0,0,12-12V136A4,4,0,0,0,184,132Z`}))]]),_=new Map([[`bold`,h.createElement(h.Fragment,null,h.createElement(`path`,{d:`M228,48V96a12,12,0,0,1-12,12H168a12,12,0,0,1,0-24h19l-7.8-7.8a75.55,75.55,0,0,0-53.32-22.26h-.43A75.49,75.49,0,0,0,72.39,75.57,12,12,0,1,1,55.61,58.41a99.38,99.38,0,0,1,69.87-28.47H126A99.42,99.42,0,0,1,196.2,59.23L204,67V48a12,12,0,0,1,24,0ZM183.61,180.43a75.49,75.49,0,0,1-53.09,21.63h-.43A75.55,75.55,0,0,1,76.77,179.8L69,172H88a12,12,0,0,0,0-24H40a12,12,0,0,0-12,12v48a12,12,0,0,0,24,0V189l7.8,7.8A99.42,99.42,0,0,0,130,226.06h.56a99.38,99.38,0,0,0,69.87-28.47,12,12,0,0,0-16.78-17.16Z`}))],[`duotone`,h.createElement(h.Fragment,null,h.createElement(`path`,{d:`M216,128a88,88,0,1,1-88-88A88,88,0,0,1,216,128Z`,opacity:`0.2`}),h.createElement(`path`,{d:`M224,48V96a8,8,0,0,1-8,8H168a8,8,0,0,1,0-16h28.69L182.06,73.37a79.56,79.56,0,0,0-56.13-23.43h-.45A79.52,79.52,0,0,0,69.59,72.71,8,8,0,0,1,58.41,61.27a96,96,0,0,1,135,.79L208,76.69V48a8,8,0,0,1,16,0ZM186.41,183.29a80,80,0,0,1-112.47-.66L59.31,168H88a8,8,0,0,0,0-16H40a8,8,0,0,0-8,8v48a8,8,0,0,0,16,0V179.31l14.63,14.63A95.43,95.43,0,0,0,130,222.06h.53a95.36,95.36,0,0,0,67.07-27.33,8,8,0,0,0-11.18-11.44Z`}))],[`fill`,h.createElement(h.Fragment,null,h.createElement(`path`,{d:`M224,48V96a8,8,0,0,1-8,8H168a8,8,0,0,1-5.66-13.66L180.65,72a79.48,79.48,0,0,0-54.72-22.09h-.45A79.52,79.52,0,0,0,69.59,72.71,8,8,0,0,1,58.41,61.27,96,96,0,0,1,192,60.7l18.36-18.36A8,8,0,0,1,224,48ZM186.41,183.29A80,80,0,0,1,75.35,184l18.31-18.31A8,8,0,0,0,88,152H40a8,8,0,0,0-8,8v48a8,8,0,0,0,13.66,5.66L64,195.3a95.42,95.42,0,0,0,66,26.76h.53a95.36,95.36,0,0,0,67.07-27.33,8,8,0,0,0-11.18-11.44Z`}))],[`light`,h.createElement(h.Fragment,null,h.createElement(`path`,{d:`M222,48V96a6,6,0,0,1-6,6H168a6,6,0,0,1,0-12h33.52L183.47,72a81.51,81.51,0,0,0-57.53-24h-.46A81.5,81.5,0,0,0,68.19,71.28a6,6,0,1,1-8.38-8.58,93.38,93.38,0,0,1,65.67-26.76H126a93.45,93.45,0,0,1,66,27.53l18,18V48a6,6,0,0,1,12,0ZM187.81,184.72a81.5,81.5,0,0,1-57.29,23.34h-.46a81.51,81.51,0,0,1-57.53-24L54.48,166H88a6,6,0,0,0,0-12H40a6,6,0,0,0-6,6v48a6,6,0,0,0,12,0V174.48l18,18.05a93.45,93.45,0,0,0,66,27.53h.52a93.38,93.38,0,0,0,65.67-26.76,6,6,0,1,0-8.38-8.58Z`}))],[`regular`,h.createElement(h.Fragment,null,h.createElement(`path`,{d:`M224,48V96a8,8,0,0,1-8,8H168a8,8,0,0,1,0-16h28.69L182.06,73.37a79.56,79.56,0,0,0-56.13-23.43h-.45A79.52,79.52,0,0,0,69.59,72.71,8,8,0,0,1,58.41,61.27a96,96,0,0,1,135,.79L208,76.69V48a8,8,0,0,1,16,0ZM186.41,183.29a80,80,0,0,1-112.47-.66L59.31,168H88a8,8,0,0,0,0-16H40a8,8,0,0,0-8,8v48a8,8,0,0,0,16,0V179.31l14.63,14.63A95.43,95.43,0,0,0,130,222.06h.53a95.36,95.36,0,0,0,67.07-27.33,8,8,0,0,0-11.18-11.44Z`}))],[`thin`,h.createElement(h.Fragment,null,h.createElement(`path`,{d:`M220,48V96a4,4,0,0,1-4,4H168a4,4,0,0,1,0-8h38.34L184.89,70.54A84,84,0,0,0,66.8,69.85a4,4,0,1,1-5.6-5.72,92,92,0,0,1,129.34.76L212,86.34V48a4,4,0,0,1,8,0ZM189.2,186.15a83.44,83.44,0,0,1-58.68,23.91h-.47a83.52,83.52,0,0,1-58.94-24.6L49.66,164H88a4,4,0,0,0,0-8H40a4,4,0,0,0-4,4v48a4,4,0,0,0,8,0V169.66l21.46,21.45A91.43,91.43,0,0,0,130,218.06h.51a91.45,91.45,0,0,0,64.28-26.19,4,4,0,1,0-5.6-5.72Z`}))]]),v=new Map([[`bold`,h.createElement(h.Fragment,null,h.createElement(`path`,{d:`M168.49,199.51a12,12,0,0,1-17,17l-80-80a12,12,0,0,1,0-17l80-80a12,12,0,0,1,17,17L97,128Z`}))],[`duotone`,h.createElement(h.Fragment,null,h.createElement(`path`,{d:`M160,48V208L80,128Z`,opacity:`0.2`}),h.createElement(`path`,{d:`M163.06,40.61a8,8,0,0,0-8.72,1.73l-80,80a8,8,0,0,0,0,11.32l80,80A8,8,0,0,0,168,208V48A8,8,0,0,0,163.06,40.61ZM152,188.69,91.31,128,152,67.31Z`}))],[`fill`,h.createElement(h.Fragment,null,h.createElement(`path`,{d:`M168,48V208a8,8,0,0,1-13.66,5.66l-80-80a8,8,0,0,1,0-11.32l80-80A8,8,0,0,1,168,48Z`}))],[`light`,h.createElement(h.Fragment,null,h.createElement(`path`,{d:`M164.24,203.76a6,6,0,1,1-8.48,8.48l-80-80a6,6,0,0,1,0-8.48l80-80a6,6,0,0,1,8.48,8.48L88.49,128Z`}))],[`regular`,h.createElement(h.Fragment,null,h.createElement(`path`,{d:`M165.66,202.34a8,8,0,0,1-11.32,11.32l-80-80a8,8,0,0,1,0-11.32l80-80a8,8,0,0,1,11.32,11.32L91.31,128Z`}))],[`thin`,h.createElement(h.Fragment,null,h.createElement(`path`,{d:`M162.83,205.17a4,4,0,0,1-5.66,5.66l-80-80a4,4,0,0,1,0-5.66l80-80a4,4,0,1,1,5.66,5.66L85.66,128Z`}))]]),y=new Map([[`bold`,h.createElement(h.Fragment,null,h.createElement(`path`,{d:`M76,64A12,12,0,0,1,88,52H216a12,12,0,0,1,0,24H88A12,12,0,0,1,76,64Zm140,52H88a12,12,0,0,0,0,24H216a12,12,0,0,0,0-24Zm0,64H88a12,12,0,0,0,0,24H216a12,12,0,0,0,0-24ZM44,112a16,16,0,1,0,16,16A16,16,0,0,0,44,112Zm0-64A16,16,0,1,0,60,64,16,16,0,0,0,44,48Zm0,128a16,16,0,1,0,16,16A16,16,0,0,0,44,176Z`}))],[`duotone`,h.createElement(h.Fragment,null,h.createElement(`path`,{d:`M216,64V192H88V64Z`,opacity:`0.2`}),h.createElement(`path`,{d:`M80,64a8,8,0,0,1,8-8H216a8,8,0,0,1,0,16H88A8,8,0,0,1,80,64Zm136,56H88a8,8,0,1,0,0,16H216a8,8,0,0,0,0-16Zm0,64H88a8,8,0,1,0,0,16H216a8,8,0,0,0,0-16ZM44,52A12,12,0,1,0,56,64,12,12,0,0,0,44,52Zm0,64a12,12,0,1,0,12,12A12,12,0,0,0,44,116Zm0,64a12,12,0,1,0,12,12A12,12,0,0,0,44,180Z`}))],[`fill`,h.createElement(h.Fragment,null,h.createElement(`path`,{d:`M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM68,188a12,12,0,1,1,12-12A12,12,0,0,1,68,188Zm0-48a12,12,0,1,1,12-12A12,12,0,0,1,68,140Zm0-48A12,12,0,1,1,80,80,12,12,0,0,1,68,92Zm124,92H104a8,8,0,0,1,0-16h88a8,8,0,0,1,0,16Zm0-48H104a8,8,0,0,1,0-16h88a8,8,0,0,1,0,16Zm0-48H104a8,8,0,0,1,0-16h88a8,8,0,0,1,0,16Z`}))],[`light`,h.createElement(h.Fragment,null,h.createElement(`path`,{d:`M82,64a6,6,0,0,1,6-6H216a6,6,0,0,1,0,12H88A6,6,0,0,1,82,64Zm134,58H88a6,6,0,0,0,0,12H216a6,6,0,0,0,0-12Zm0,64H88a6,6,0,0,0,0,12H216a6,6,0,0,0,0-12ZM44,54A10,10,0,1,0,54,64,10,10,0,0,0,44,54Zm0,128a10,10,0,1,0,10,10A10,10,0,0,0,44,182Zm0-64a10,10,0,1,0,10,10A10,10,0,0,0,44,118Z`}))],[`regular`,h.createElement(h.Fragment,null,h.createElement(`path`,{d:`M80,64a8,8,0,0,1,8-8H216a8,8,0,0,1,0,16H88A8,8,0,0,1,80,64Zm136,56H88a8,8,0,0,0,0,16H216a8,8,0,0,0,0-16Zm0,64H88a8,8,0,0,0,0,16H216a8,8,0,0,0,0-16ZM44,52A12,12,0,1,0,56,64,12,12,0,0,0,44,52Zm0,64a12,12,0,1,0,12,12A12,12,0,0,0,44,116Zm0,64a12,12,0,1,0,12,12A12,12,0,0,0,44,180Z`}))],[`thin`,h.createElement(h.Fragment,null,h.createElement(`path`,{d:`M84,64a4,4,0,0,1,4-4H216a4,4,0,0,1,0,8H88A4,4,0,0,1,84,64Zm132,60H88a4,4,0,0,0,0,8H216a4,4,0,0,0,0-8Zm0,64H88a4,4,0,0,0,0,8H216a4,4,0,0,0,0-8ZM44,120a8,8,0,1,0,8,8A8,8,0,0,0,44,120Zm0-64a8,8,0,1,0,8,8A8,8,0,0,0,44,56Zm0,128a8,8,0,1,0,8,8A8,8,0,0,0,44,184Z`}))]]),b=h.forwardRef((e,t)=>h.createElement(o,{ref:t,...e,weights:g}));b.displayName=`ArrowSquareOutIcon`;var x=b,S=h.forwardRef((e,t)=>h.createElement(o,{ref:t,...e,weights:_}));S.displayName=`ArrowsClockwiseIcon`;var C=S,w=h.forwardRef((e,t)=>h.createElement(o,{ref:t,...e,weights:v}));w.displayName=`CaretLeftIcon`;var T=w,E=h.forwardRef((e,t)=>h.createElement(o,{ref:t,...e,weights:y}));E.displayName=`ListBulletsIcon`;var D=E,O=c({base:`textarea`,defaultVariants:{fullWidth:!1,variant:`primary`},variants:{fullWidth:{false:``,true:`textarea--full-width`},variant:{primary:`textarea--primary`,secondary:`textarea--secondary`}}}),k=n(),A=({className:e,fullWidth:t,variant:n,...r})=>{let i=(0,h.use)(u),a=n??i?.variant;return(0,k.jsx)(l,{"data-slot":`textarea`,className:s(e,O({fullWidth:t,variant:a})),...r})},j=Object.assign(A,{Root:A});function M({copied:e,size:t=14,className:n}){let a=(0,h.useRef)(null),o=(0,h.useRef)(null),s=(0,h.useRef)(!0);return(0,h.useLayoutEffect)(()=>{let t=e?o.current:a.current,n=e?a.current:o.current;if(!t||!n)return;let r={autoAlpha:1,scale:1,filter:`blur(0px)`},i={autoAlpha:0,scale:.5,filter:`blur(4px)`};if(s.current||p()){s.current=!1,d.set(t,r),d.set(n,i);return}d.to(n,{...i,duration:f.fast,ease:m.out,overwrite:!0}),d.fromTo(t,i,{...r,duration:f.base,ease:m.soft,delay:f.instant/2,overwrite:!0})},[e]),(0,k.jsxs)(`span`,{className:`relative inline-grid place-items-center ${n??``}`,style:{width:t,height:t},children:[(0,k.jsx)(`span`,{ref:a,className:`col-start-1 row-start-1 inline-flex`,children:(0,k.jsx)(i,{size:t})}),(0,k.jsx)(`span`,{ref:o,className:`col-start-1 row-start-1 inline-flex text-success`,children:(0,k.jsx)(r,{size:t})})]})}var N=`https://caiaiu.com`;function P({className:e=``}){let{t}=a();return(0,k.jsx)(`p`,{className:`text-caption leading-5 text-muted ${e}`.trim(),children:(0,k.jsx)(`a`,{href:N,target:`_blank`,rel:`noopener noreferrer`,className:`underline-offset-2 transition-colors hover:text-foreground hover:underline`,children:t(`caiaiSoftLink`)})})}export{T as a,D as i,M as n,C as o,j as r,x as s,P as t}; \ No newline at end of file +import{a as e,c as t,n}from"./shim-mfK0Rmj6.js";import{t as r}from"./Check.es-PrgGvQWD.js";import{n as i}from"./clipboard-BWzpPXn-.js";import{dt as a,n as o}from"./useI18n-BBOAnu2u.js";import{c as s,z as c}from"./SharedElementTransition-BlCsXfb1.js";import{r as l,t as u}from"./textfield-DczGuWn0.js";import{r as d}from"./gsap-C3sDxib7.js";import{v as f,x as p,y as m}from"./index-B9eWF6SH.js";var h=t(e(),1),g=new Map([[`bold`,h.createElement(h.Fragment,null,h.createElement(`path`,{d:`M228,104a12,12,0,0,1-24,0V69l-59.51,59.51a12,12,0,0,1-17-17L187,52H152a12,12,0,0,1,0-24h64a12,12,0,0,1,12,12Zm-44,24a12,12,0,0,0-12,12v64H52V84h64a12,12,0,0,0,0-24H48A20,20,0,0,0,28,80V208a20,20,0,0,0,20,20H176a20,20,0,0,0,20-20V140A12,12,0,0,0,184,128Z`}))],[`duotone`,h.createElement(h.Fragment,null,h.createElement(`path`,{d:`M184,80V208a8,8,0,0,1-8,8H48a8,8,0,0,1-8-8V80a8,8,0,0,1,8-8H176A8,8,0,0,1,184,80Z`,opacity:`0.2`}),h.createElement(`path`,{d:`M224,104a8,8,0,0,1-16,0V59.32l-66.33,66.34a8,8,0,0,1-11.32-11.32L196.68,48H152a8,8,0,0,1,0-16h64a8,8,0,0,1,8,8Zm-40,24a8,8,0,0,0-8,8v72H48V80h72a8,8,0,0,0,0-16H48A16,16,0,0,0,32,80V208a16,16,0,0,0,16,16H176a16,16,0,0,0,16-16V136A8,8,0,0,0,184,128Z`}))],[`fill`,h.createElement(h.Fragment,null,h.createElement(`path`,{d:`M192,136v72a16,16,0,0,1-16,16H48a16,16,0,0,1-16-16V80A16,16,0,0,1,48,64h72a8,8,0,0,1,0,16H48V208H176V136a8,8,0,0,1,16,0Zm32-96a8,8,0,0,0-8-8H152a8,8,0,0,0-5.66,13.66L172.69,72l-42.35,42.34a8,8,0,0,0,11.32,11.32L184,83.31l26.34,26.35A8,8,0,0,0,224,104Z`}))],[`light`,h.createElement(h.Fragment,null,h.createElement(`path`,{d:`M222,104a6,6,0,0,1-12,0V54.49l-69.75,69.75a6,6,0,0,1-8.48-8.48L201.51,46H152a6,6,0,0,1,0-12h64a6,6,0,0,1,6,6Zm-38,26a6,6,0,0,0-6,6v72a2,2,0,0,1-2,2H48a2,2,0,0,1-2-2V80a2,2,0,0,1,2-2h72a6,6,0,0,0,0-12H48A14,14,0,0,0,34,80V208a14,14,0,0,0,14,14H176a14,14,0,0,0,14-14V136A6,6,0,0,0,184,130Z`}))],[`regular`,h.createElement(h.Fragment,null,h.createElement(`path`,{d:`M224,104a8,8,0,0,1-16,0V59.32l-66.33,66.34a8,8,0,0,1-11.32-11.32L196.68,48H152a8,8,0,0,1,0-16h64a8,8,0,0,1,8,8Zm-40,24a8,8,0,0,0-8,8v72H48V80h72a8,8,0,0,0,0-16H48A16,16,0,0,0,32,80V208a16,16,0,0,0,16,16H176a16,16,0,0,0,16-16V136A8,8,0,0,0,184,128Z`}))],[`thin`,h.createElement(h.Fragment,null,h.createElement(`path`,{d:`M220,104a4,4,0,0,1-8,0V49.66l-73.16,73.17a4,4,0,0,1-5.66-5.66L206.34,44H152a4,4,0,0,1,0-8h64a4,4,0,0,1,4,4Zm-36,28a4,4,0,0,0-4,4v72a4,4,0,0,1-4,4H48a4,4,0,0,1-4-4V80a4,4,0,0,1,4-4h72a4,4,0,0,0,0-8H48A12,12,0,0,0,36,80V208a12,12,0,0,0,12,12H176a12,12,0,0,0,12-12V136A4,4,0,0,0,184,132Z`}))]]),_=new Map([[`bold`,h.createElement(h.Fragment,null,h.createElement(`path`,{d:`M228,48V96a12,12,0,0,1-12,12H168a12,12,0,0,1,0-24h19l-7.8-7.8a75.55,75.55,0,0,0-53.32-22.26h-.43A75.49,75.49,0,0,0,72.39,75.57,12,12,0,1,1,55.61,58.41a99.38,99.38,0,0,1,69.87-28.47H126A99.42,99.42,0,0,1,196.2,59.23L204,67V48a12,12,0,0,1,24,0ZM183.61,180.43a75.49,75.49,0,0,1-53.09,21.63h-.43A75.55,75.55,0,0,1,76.77,179.8L69,172H88a12,12,0,0,0,0-24H40a12,12,0,0,0-12,12v48a12,12,0,0,0,24,0V189l7.8,7.8A99.42,99.42,0,0,0,130,226.06h.56a99.38,99.38,0,0,0,69.87-28.47,12,12,0,0,0-16.78-17.16Z`}))],[`duotone`,h.createElement(h.Fragment,null,h.createElement(`path`,{d:`M216,128a88,88,0,1,1-88-88A88,88,0,0,1,216,128Z`,opacity:`0.2`}),h.createElement(`path`,{d:`M224,48V96a8,8,0,0,1-8,8H168a8,8,0,0,1,0-16h28.69L182.06,73.37a79.56,79.56,0,0,0-56.13-23.43h-.45A79.52,79.52,0,0,0,69.59,72.71,8,8,0,0,1,58.41,61.27a96,96,0,0,1,135,.79L208,76.69V48a8,8,0,0,1,16,0ZM186.41,183.29a80,80,0,0,1-112.47-.66L59.31,168H88a8,8,0,0,0,0-16H40a8,8,0,0,0-8,8v48a8,8,0,0,0,16,0V179.31l14.63,14.63A95.43,95.43,0,0,0,130,222.06h.53a95.36,95.36,0,0,0,67.07-27.33,8,8,0,0,0-11.18-11.44Z`}))],[`fill`,h.createElement(h.Fragment,null,h.createElement(`path`,{d:`M224,48V96a8,8,0,0,1-8,8H168a8,8,0,0,1-5.66-13.66L180.65,72a79.48,79.48,0,0,0-54.72-22.09h-.45A79.52,79.52,0,0,0,69.59,72.71,8,8,0,0,1,58.41,61.27,96,96,0,0,1,192,60.7l18.36-18.36A8,8,0,0,1,224,48ZM186.41,183.29A80,80,0,0,1,75.35,184l18.31-18.31A8,8,0,0,0,88,152H40a8,8,0,0,0-8,8v48a8,8,0,0,0,13.66,5.66L64,195.3a95.42,95.42,0,0,0,66,26.76h.53a95.36,95.36,0,0,0,67.07-27.33,8,8,0,0,0-11.18-11.44Z`}))],[`light`,h.createElement(h.Fragment,null,h.createElement(`path`,{d:`M222,48V96a6,6,0,0,1-6,6H168a6,6,0,0,1,0-12h33.52L183.47,72a81.51,81.51,0,0,0-57.53-24h-.46A81.5,81.5,0,0,0,68.19,71.28a6,6,0,1,1-8.38-8.58,93.38,93.38,0,0,1,65.67-26.76H126a93.45,93.45,0,0,1,66,27.53l18,18V48a6,6,0,0,1,12,0ZM187.81,184.72a81.5,81.5,0,0,1-57.29,23.34h-.46a81.51,81.51,0,0,1-57.53-24L54.48,166H88a6,6,0,0,0,0-12H40a6,6,0,0,0-6,6v48a6,6,0,0,0,12,0V174.48l18,18.05a93.45,93.45,0,0,0,66,27.53h.52a93.38,93.38,0,0,0,65.67-26.76,6,6,0,1,0-8.38-8.58Z`}))],[`regular`,h.createElement(h.Fragment,null,h.createElement(`path`,{d:`M224,48V96a8,8,0,0,1-8,8H168a8,8,0,0,1,0-16h28.69L182.06,73.37a79.56,79.56,0,0,0-56.13-23.43h-.45A79.52,79.52,0,0,0,69.59,72.71,8,8,0,0,1,58.41,61.27a96,96,0,0,1,135,.79L208,76.69V48a8,8,0,0,1,16,0ZM186.41,183.29a80,80,0,0,1-112.47-.66L59.31,168H88a8,8,0,0,0,0-16H40a8,8,0,0,0-8,8v48a8,8,0,0,0,16,0V179.31l14.63,14.63A95.43,95.43,0,0,0,130,222.06h.53a95.36,95.36,0,0,0,67.07-27.33,8,8,0,0,0-11.18-11.44Z`}))],[`thin`,h.createElement(h.Fragment,null,h.createElement(`path`,{d:`M220,48V96a4,4,0,0,1-4,4H168a4,4,0,0,1,0-8h38.34L184.89,70.54A84,84,0,0,0,66.8,69.85a4,4,0,1,1-5.6-5.72,92,92,0,0,1,129.34.76L212,86.34V48a4,4,0,0,1,8,0ZM189.2,186.15a83.44,83.44,0,0,1-58.68,23.91h-.47a83.52,83.52,0,0,1-58.94-24.6L49.66,164H88a4,4,0,0,0,0-8H40a4,4,0,0,0-4,4v48a4,4,0,0,0,8,0V169.66l21.46,21.45A91.43,91.43,0,0,0,130,218.06h.51a91.45,91.45,0,0,0,64.28-26.19,4,4,0,1,0-5.6-5.72Z`}))]]),v=new Map([[`bold`,h.createElement(h.Fragment,null,h.createElement(`path`,{d:`M168.49,199.51a12,12,0,0,1-17,17l-80-80a12,12,0,0,1,0-17l80-80a12,12,0,0,1,17,17L97,128Z`}))],[`duotone`,h.createElement(h.Fragment,null,h.createElement(`path`,{d:`M160,48V208L80,128Z`,opacity:`0.2`}),h.createElement(`path`,{d:`M163.06,40.61a8,8,0,0,0-8.72,1.73l-80,80a8,8,0,0,0,0,11.32l80,80A8,8,0,0,0,168,208V48A8,8,0,0,0,163.06,40.61ZM152,188.69,91.31,128,152,67.31Z`}))],[`fill`,h.createElement(h.Fragment,null,h.createElement(`path`,{d:`M168,48V208a8,8,0,0,1-13.66,5.66l-80-80a8,8,0,0,1,0-11.32l80-80A8,8,0,0,1,168,48Z`}))],[`light`,h.createElement(h.Fragment,null,h.createElement(`path`,{d:`M164.24,203.76a6,6,0,1,1-8.48,8.48l-80-80a6,6,0,0,1,0-8.48l80-80a6,6,0,0,1,8.48,8.48L88.49,128Z`}))],[`regular`,h.createElement(h.Fragment,null,h.createElement(`path`,{d:`M165.66,202.34a8,8,0,0,1-11.32,11.32l-80-80a8,8,0,0,1,0-11.32l80-80a8,8,0,0,1,11.32,11.32L91.31,128Z`}))],[`thin`,h.createElement(h.Fragment,null,h.createElement(`path`,{d:`M162.83,205.17a4,4,0,0,1-5.66,5.66l-80-80a4,4,0,0,1,0-5.66l80-80a4,4,0,1,1,5.66,5.66L85.66,128Z`}))]]),y=new Map([[`bold`,h.createElement(h.Fragment,null,h.createElement(`path`,{d:`M76,64A12,12,0,0,1,88,52H216a12,12,0,0,1,0,24H88A12,12,0,0,1,76,64Zm140,52H88a12,12,0,0,0,0,24H216a12,12,0,0,0,0-24Zm0,64H88a12,12,0,0,0,0,24H216a12,12,0,0,0,0-24ZM44,112a16,16,0,1,0,16,16A16,16,0,0,0,44,112Zm0-64A16,16,0,1,0,60,64,16,16,0,0,0,44,48Zm0,128a16,16,0,1,0,16,16A16,16,0,0,0,44,176Z`}))],[`duotone`,h.createElement(h.Fragment,null,h.createElement(`path`,{d:`M216,64V192H88V64Z`,opacity:`0.2`}),h.createElement(`path`,{d:`M80,64a8,8,0,0,1,8-8H216a8,8,0,0,1,0,16H88A8,8,0,0,1,80,64Zm136,56H88a8,8,0,1,0,0,16H216a8,8,0,0,0,0-16Zm0,64H88a8,8,0,1,0,0,16H216a8,8,0,0,0,0-16ZM44,52A12,12,0,1,0,56,64,12,12,0,0,0,44,52Zm0,64a12,12,0,1,0,12,12A12,12,0,0,0,44,116Zm0,64a12,12,0,1,0,12,12A12,12,0,0,0,44,180Z`}))],[`fill`,h.createElement(h.Fragment,null,h.createElement(`path`,{d:`M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM68,188a12,12,0,1,1,12-12A12,12,0,0,1,68,188Zm0-48a12,12,0,1,1,12-12A12,12,0,0,1,68,140Zm0-48A12,12,0,1,1,80,80,12,12,0,0,1,68,92Zm124,92H104a8,8,0,0,1,0-16h88a8,8,0,0,1,0,16Zm0-48H104a8,8,0,0,1,0-16h88a8,8,0,0,1,0,16Zm0-48H104a8,8,0,0,1,0-16h88a8,8,0,0,1,0,16Z`}))],[`light`,h.createElement(h.Fragment,null,h.createElement(`path`,{d:`M82,64a6,6,0,0,1,6-6H216a6,6,0,0,1,0,12H88A6,6,0,0,1,82,64Zm134,58H88a6,6,0,0,0,0,12H216a6,6,0,0,0,0-12Zm0,64H88a6,6,0,0,0,0,12H216a6,6,0,0,0,0-12ZM44,54A10,10,0,1,0,54,64,10,10,0,0,0,44,54Zm0,128a10,10,0,1,0,10,10A10,10,0,0,0,44,182Zm0-64a10,10,0,1,0,10,10A10,10,0,0,0,44,118Z`}))],[`regular`,h.createElement(h.Fragment,null,h.createElement(`path`,{d:`M80,64a8,8,0,0,1,8-8H216a8,8,0,0,1,0,16H88A8,8,0,0,1,80,64Zm136,56H88a8,8,0,0,0,0,16H216a8,8,0,0,0,0-16Zm0,64H88a8,8,0,0,0,0,16H216a8,8,0,0,0,0-16ZM44,52A12,12,0,1,0,56,64,12,12,0,0,0,44,52Zm0,64a12,12,0,1,0,12,12A12,12,0,0,0,44,116Zm0,64a12,12,0,1,0,12,12A12,12,0,0,0,44,180Z`}))],[`thin`,h.createElement(h.Fragment,null,h.createElement(`path`,{d:`M84,64a4,4,0,0,1,4-4H216a4,4,0,0,1,0,8H88A4,4,0,0,1,84,64Zm132,60H88a4,4,0,0,0,0,8H216a4,4,0,0,0,0-8Zm0,64H88a4,4,0,0,0,0,8H216a4,4,0,0,0,0-8ZM44,120a8,8,0,1,0,8,8A8,8,0,0,0,44,120Zm0-64a8,8,0,1,0,8,8A8,8,0,0,0,44,56Zm0,128a8,8,0,1,0,8,8A8,8,0,0,0,44,184Z`}))]]),b=h.forwardRef((e,t)=>h.createElement(a,{ref:t,...e,weights:g}));b.displayName=`ArrowSquareOutIcon`;var x=b,S=h.forwardRef((e,t)=>h.createElement(a,{ref:t,...e,weights:_}));S.displayName=`ArrowsClockwiseIcon`;var C=S,w=h.forwardRef((e,t)=>h.createElement(a,{ref:t,...e,weights:v}));w.displayName=`CaretLeftIcon`;var T=w,E=h.forwardRef((e,t)=>h.createElement(a,{ref:t,...e,weights:y}));E.displayName=`ListBulletsIcon`;var D=E,O=c({base:`textarea`,defaultVariants:{fullWidth:!1,variant:`primary`},variants:{fullWidth:{false:``,true:`textarea--full-width`},variant:{primary:`textarea--primary`,secondary:`textarea--secondary`}}}),k=n(),A=({className:e,fullWidth:t,variant:n,...r})=>{let i=(0,h.use)(u),a=n??i?.variant;return(0,k.jsx)(l,{"data-slot":`textarea`,className:s(e,O({fullWidth:t,variant:a})),...r})},j=Object.assign(A,{Root:A});function M({copied:e,size:t=14,className:n}){let a=(0,h.useRef)(null),o=(0,h.useRef)(null),s=(0,h.useRef)(!0);return(0,h.useLayoutEffect)(()=>{let t=e?o.current:a.current,n=e?a.current:o.current;if(!t||!n)return;let r={autoAlpha:1,scale:1,filter:`blur(0px)`},i={autoAlpha:0,scale:.5,filter:`blur(4px)`};if(s.current||p()){s.current=!1,d.set(t,r),d.set(n,i);return}d.to(n,{...i,duration:f.fast,ease:m.out,overwrite:!0}),d.fromTo(t,i,{...r,duration:f.base,ease:m.soft,delay:f.instant/2,overwrite:!0})},[e]),(0,k.jsxs)(`span`,{className:`relative inline-grid place-items-center ${n??``}`,style:{width:t,height:t},children:[(0,k.jsx)(`span`,{ref:a,className:`col-start-1 row-start-1 inline-flex`,children:(0,k.jsx)(i,{size:t})}),(0,k.jsx)(`span`,{ref:o,className:`col-start-1 row-start-1 inline-flex text-success`,children:(0,k.jsx)(r,{size:t})})]})}var N=`https://caiaiu.com`;function P({className:e=``}){let{t}=o();return(0,k.jsx)(`p`,{className:`text-caption leading-5 text-muted ${e}`.trim(),children:(0,k.jsx)(`a`,{href:N,target:`_blank`,rel:`noopener noreferrer`,className:`underline-offset-2 transition-colors hover:text-foreground hover:underline`,children:t(`caiaiSoftLink`)})})}export{T as a,D as i,M as n,C as o,j as r,x as s,P as t}; \ No newline at end of file diff --git a/internal/webui/static/assets/CaretRight.es-D5fytEam.js b/internal/webui/static/assets/CaretRight.es-DGKxUxz5.js similarity index 90% rename from internal/webui/static/assets/CaretRight.es-D5fytEam.js rename to internal/webui/static/assets/CaretRight.es-DGKxUxz5.js index d51a3b8c..947dd84d 100644 --- a/internal/webui/static/assets/CaretRight.es-D5fytEam.js +++ b/internal/webui/static/assets/CaretRight.es-DGKxUxz5.js @@ -1 +1 @@ -import{a as e,c as t}from"./shim-mfK0Rmj6.js";import{pt as n}from"./useI18n-BSw4X3mq.js";var r=t(e(),1),i=new Map([[`bold`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M184.49,136.49l-80,80a12,12,0,0,1-17-17L159,128,87.51,56.49a12,12,0,1,1,17-17l80,80A12,12,0,0,1,184.49,136.49Z`}))],[`duotone`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M176,128,96,208V48Z`,opacity:`0.2`}),r.createElement(`path`,{d:`M181.66,122.34l-80-80A8,8,0,0,0,88,48V208a8,8,0,0,0,13.66,5.66l80-80A8,8,0,0,0,181.66,122.34ZM104,188.69V67.31L164.69,128Z`}))],[`fill`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M181.66,133.66l-80,80A8,8,0,0,1,88,208V48a8,8,0,0,1,13.66-5.66l80,80A8,8,0,0,1,181.66,133.66Z`}))],[`light`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M180.24,132.24l-80,80a6,6,0,0,1-8.48-8.48L167.51,128,91.76,52.24a6,6,0,0,1,8.48-8.48l80,80A6,6,0,0,1,180.24,132.24Z`}))],[`regular`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M181.66,133.66l-80,80a8,8,0,0,1-11.32-11.32L164.69,128,90.34,53.66a8,8,0,0,1,11.32-11.32l80,80A8,8,0,0,1,181.66,133.66Z`}))],[`thin`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M178.83,130.83l-80,80a4,4,0,0,1-5.66-5.66L170.34,128,93.17,50.83a4,4,0,0,1,5.66-5.66l80,80A4,4,0,0,1,178.83,130.83Z`}))]]),a=r.forwardRef((e,t)=>r.createElement(n,{ref:t,...e,weights:i}));a.displayName=`CaretRightIcon`;var o=a;export{o as t}; \ No newline at end of file +import{a as e,c as t}from"./shim-mfK0Rmj6.js";import{dt as n}from"./useI18n-BBOAnu2u.js";var r=t(e(),1),i=new Map([[`bold`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M184.49,136.49l-80,80a12,12,0,0,1-17-17L159,128,87.51,56.49a12,12,0,1,1,17-17l80,80A12,12,0,0,1,184.49,136.49Z`}))],[`duotone`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M176,128,96,208V48Z`,opacity:`0.2`}),r.createElement(`path`,{d:`M181.66,122.34l-80-80A8,8,0,0,0,88,48V208a8,8,0,0,0,13.66,5.66l80-80A8,8,0,0,0,181.66,122.34ZM104,188.69V67.31L164.69,128Z`}))],[`fill`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M181.66,133.66l-80,80A8,8,0,0,1,88,208V48a8,8,0,0,1,13.66-5.66l80,80A8,8,0,0,1,181.66,133.66Z`}))],[`light`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M180.24,132.24l-80,80a6,6,0,0,1-8.48-8.48L167.51,128,91.76,52.24a6,6,0,0,1,8.48-8.48l80,80A6,6,0,0,1,180.24,132.24Z`}))],[`regular`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M181.66,133.66l-80,80a8,8,0,0,1-11.32-11.32L164.69,128,90.34,53.66a8,8,0,0,1,11.32-11.32l80,80A8,8,0,0,1,181.66,133.66Z`}))],[`thin`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M178.83,130.83l-80,80a4,4,0,0,1-5.66-5.66L170.34,128,93.17,50.83a4,4,0,0,1,5.66-5.66l80,80A4,4,0,0,1,178.83,130.83Z`}))]]),a=r.forwardRef((e,t)=>r.createElement(n,{ref:t,...e,weights:i}));a.displayName=`CaretRightIcon`;var o=a;export{o as t}; \ No newline at end of file diff --git a/internal/webui/static/assets/Check.es-Bl43hv4j.js b/internal/webui/static/assets/Check.es-PrgGvQWD.js similarity index 91% rename from internal/webui/static/assets/Check.es-Bl43hv4j.js rename to internal/webui/static/assets/Check.es-PrgGvQWD.js index ffe62efc..ea926e74 100644 --- a/internal/webui/static/assets/Check.es-Bl43hv4j.js +++ b/internal/webui/static/assets/Check.es-PrgGvQWD.js @@ -1 +1 @@ -import{a as e,c as t}from"./shim-mfK0Rmj6.js";import{pt as n}from"./useI18n-BSw4X3mq.js";var r=t(e(),1),i=new Map([[`bold`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M232.49,80.49l-128,128a12,12,0,0,1-17,0l-56-56a12,12,0,1,1,17-17L96,183,215.51,63.51a12,12,0,0,1,17,17Z`}))],[`duotone`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M232,56V200a16,16,0,0,1-16,16H40a16,16,0,0,1-16-16V56A16,16,0,0,1,40,40H216A16,16,0,0,1,232,56Z`,opacity:`0.2`}),r.createElement(`path`,{d:`M205.66,85.66l-96,96a8,8,0,0,1-11.32,0l-40-40a8,8,0,0,1,11.32-11.32L104,164.69l90.34-90.35a8,8,0,0,1,11.32,11.32Z`}))],[`fill`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M216,40H40A16,16,0,0,0,24,56V200a16,16,0,0,0,16,16H216a16,16,0,0,0,16-16V56A16,16,0,0,0,216,40ZM205.66,85.66l-96,96a8,8,0,0,1-11.32,0l-40-40a8,8,0,0,1,11.32-11.32L104,164.69l90.34-90.35a8,8,0,0,1,11.32,11.32Z`}))],[`light`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M228.24,76.24l-128,128a6,6,0,0,1-8.48,0l-56-56a6,6,0,0,1,8.48-8.48L96,191.51,219.76,67.76a6,6,0,0,1,8.48,8.48Z`}))],[`regular`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M229.66,77.66l-128,128a8,8,0,0,1-11.32,0l-56-56a8,8,0,0,1,11.32-11.32L96,188.69,218.34,66.34a8,8,0,0,1,11.32,11.32Z`}))],[`thin`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M226.83,74.83l-128,128a4,4,0,0,1-5.66,0l-56-56a4,4,0,0,1,5.66-5.66L96,194.34,221.17,69.17a4,4,0,1,1,5.66,5.66Z`}))]]),a=r.forwardRef((e,t)=>r.createElement(n,{ref:t,...e,weights:i}));a.displayName=`CheckIcon`;var o=a;export{o as t}; \ No newline at end of file +import{a as e,c as t}from"./shim-mfK0Rmj6.js";import{dt as n}from"./useI18n-BBOAnu2u.js";var r=t(e(),1),i=new Map([[`bold`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M232.49,80.49l-128,128a12,12,0,0,1-17,0l-56-56a12,12,0,1,1,17-17L96,183,215.51,63.51a12,12,0,0,1,17,17Z`}))],[`duotone`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M232,56V200a16,16,0,0,1-16,16H40a16,16,0,0,1-16-16V56A16,16,0,0,1,40,40H216A16,16,0,0,1,232,56Z`,opacity:`0.2`}),r.createElement(`path`,{d:`M205.66,85.66l-96,96a8,8,0,0,1-11.32,0l-40-40a8,8,0,0,1,11.32-11.32L104,164.69l90.34-90.35a8,8,0,0,1,11.32,11.32Z`}))],[`fill`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M216,40H40A16,16,0,0,0,24,56V200a16,16,0,0,0,16,16H216a16,16,0,0,0,16-16V56A16,16,0,0,0,216,40ZM205.66,85.66l-96,96a8,8,0,0,1-11.32,0l-40-40a8,8,0,0,1,11.32-11.32L104,164.69l90.34-90.35a8,8,0,0,1,11.32,11.32Z`}))],[`light`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M228.24,76.24l-128,128a6,6,0,0,1-8.48,0l-56-56a6,6,0,0,1,8.48-8.48L96,191.51,219.76,67.76a6,6,0,0,1,8.48,8.48Z`}))],[`regular`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M229.66,77.66l-128,128a8,8,0,0,1-11.32,0l-56-56a8,8,0,0,1,11.32-11.32L96,188.69,218.34,66.34a8,8,0,0,1,11.32,11.32Z`}))],[`thin`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M226.83,74.83l-128,128a4,4,0,0,1-5.66,0l-56-56a4,4,0,0,1,5.66-5.66L96,194.34,221.17,69.17a4,4,0,1,1,5.66,5.66Z`}))]]),a=r.forwardRef((e,t)=>r.createElement(n,{ref:t,...e,weights:i}));a.displayName=`CheckIcon`;var o=a;export{o as t}; \ No newline at end of file diff --git a/internal/webui/static/assets/Checkbox-5_DFnahA.js b/internal/webui/static/assets/Checkbox-5_DFnahA.js new file mode 100644 index 00000000..a05a89e8 --- /dev/null +++ b/internal/webui/static/assets/Checkbox-5_DFnahA.js @@ -0,0 +1 @@ +import{a as e,c as t}from"./shim-mfK0Rmj6.js";import{a as n}from"./useI18n-BBOAnu2u.js";import{A as r,F as i,G as a,I as o,J as s,L as c,M as l,Y as u,d,j as f,q as p,u as m}from"./SharedElementTransition-BlCsXfb1.js";import{d as h,f as g,l as _,p as v,s as y}from"./label-BVCjtfNQ.js";import{t as b}from"./useToggleState-DpzdeNPF.js";import{t as x}from"./useToggle-BkQ49Unj.js";import{xt as S}from"./index-B9eWF6SH.js";var C=t(e(),1),w=new WeakMap;function T(e,t,n){let{labelProps:r,inputProps:i,descriptionProps:a,errorMessageProps:o,isSelected:c,isPressed:l,isDisabled:u,isReadOnly:d,isInvalid:f,validationErrors:p,validationDetails:m}=x(e,t,n),{isIndeterminate:h}=e;return(0,C.useEffect)(()=>{n.current&&(n.current.indeterminate=!!h)}),{labelProps:s(r,(0,C.useMemo)(()=>({onMouseDown:e=>e.preventDefault()}),[])),inputProps:i,descriptionProps:a,errorMessageProps:o,isSelected:c,isPressed:l,isDisabled:u,isReadOnly:d,isInvalid:f,validationErrors:p,validationDetails:m}}function E(e,t,n){let r=b({isReadOnly:e.isReadOnly||t.isReadOnly,isSelected:t.isSelected(e.value),defaultSelected:t.defaultValue.includes(e.value),onChange(n){n?t.addValue(e.value):t.removeValue(e.value),e.onChange&&e.onChange(n)}}),{name:i,form:a,descriptionId:o,errorMessageId:s,validationBehavior:c}=w.get(t);c=e.validationBehavior??c;let{realtimeValidation:l}=g({...e,value:r.isSelected,name:void 0,validationBehavior:`aria`}),u=(0,C.useRef)(h),d=()=>{t.setInvalid(e.value,l.isInvalid?l:u.current)};(0,C.useEffect)(d);let f=t.realtimeValidation.isInvalid?t.realtimeValidation:l,p=c===`native`?t.displayValidation:f,m=T({...e,isReadOnly:e.isReadOnly||t.isReadOnly,isDisabled:e.isDisabled||t.isDisabled,name:e.name||i,form:e.form||a,isRequired:e.isRequired??t.isRequired,validationBehavior:c,[_]:{realtimeValidation:f,displayValidation:p,resetValidation:t.resetValidation,commitValidation:t.commitValidation,updateValidation(e){u.current=e,d()}}},r,n);return{...m,inputProps:{...m.inputProps,"aria-describedby":[m.inputProps[`aria-describedby`],t.isInvalid?s:null,o].filter(Boolean).join(` `)||void 0}}}var D=(0,C.createContext)(null),O=(0,C.createContext)(null),k=(0,C.createContext)(null),A=(0,C.createContext)(null),j=(0,C.forwardRef)(function(e,t){let{inputRef:a=null,...o}=e;[e,t]=f(o,t,O);let c=(0,C.useContext)(k),[u,d]=M(e,a),{descriptionProps:m,errorMessageProps:h,isSelected:g,isDisabled:_,isReadOnly:y,isInvalid:b,validationDetails:x,validationErrors:S}=u,w=l({...e,defaultClassName:`react-aria-CheckboxField`,values:{isSelected:g,isIndeterminate:e.isIndeterminate||!1,isDisabled:_,isReadOnly:y,isInvalid:b,isRequired:e.isRequired||!1}}),T=p(e,{global:!0});return delete T.id,delete T.onClick,C.createElement(i.div,{...s(T,w),ref:t,slot:e.slot||void 0,"data-selected":g||void 0,"data-indeterminate":e.isIndeterminate||void 0,"data-disabled":_||void 0,"data-readonly":y||void 0,"data-invalid":b||void 0,"data-required":e.isRequired||void 0},C.createElement(r,{values:[[A,{...u,inputRef:d,defaultClassName:`react-aria-CheckboxButton`,isIndeterminate:e.isIndeterminate,isRequired:e.isRequired}],[n,{slots:{description:m,errorMessage:h}}],[v,c?null:{isInvalid:b,validationDetails:x,validationErrors:S}]]},w.children))});function M(e,t){let{validationBehavior:n}=c(y)||{},r=e.validationBehavior??n??`native`,i=(0,C.useContext)(k),s=a((0,C.useMemo)(()=>u(t,e.inputRef===void 0?null:e.inputRef),[t,e.inputRef])),l={...o(e),children:typeof e.children==`function`||e.children,value:e.value,validationBehavior:r};return[i?E(l,i,s):T(l,b(e),s),s]}var N=(0,C.forwardRef)(function(e,t){let{labelProps:n,inputProps:r,isSelected:a,isDisabled:o,isReadOnly:c,isPressed:u,isInvalid:f,inputRef:h,defaultClassName:g,isIndeterminate:_,isRequired:v}=(0,C.useContext)(A),{isFocused:y,isFocusVisible:b,focusProps:x}=d(),w=o||c,{hoverProps:T,isHovered:E}=m({...e,isDisabled:w}),D=l({...e,defaultClassName:g,values:{isSelected:a,isIndeterminate:_||!1,isPressed:u,isHovered:E,isFocused:y,isFocusVisible:b,isDisabled:o,isReadOnly:c,isInvalid:f,isRequired:v||!1}}),O=p(e,{global:!0});return delete O.id,delete O.onClick,C.createElement(i.label,{...s(O,n,T,D),ref:t,slot:e.slot||void 0,"data-selected":a||void 0,"data-indeterminate":_||void 0,"data-pressed":u||void 0,"data-hovered":E||void 0,"data-focused":y||void 0,"data-focus-visible":b||void 0,"data-disabled":o||void 0,"data-readonly":c||void 0,"data-invalid":f||void 0,"data-required":v||void 0},C.createElement(S,{elementType:`span`},C.createElement(`input`,{...s(r,x),ref:h})),D.children)});export{O as i,j as n,D as r,N as t}; \ No newline at end of file diff --git a/internal/webui/static/assets/Checkbox-DbM57zbg.js b/internal/webui/static/assets/Checkbox-DbM57zbg.js deleted file mode 100644 index 37028512..00000000 --- a/internal/webui/static/assets/Checkbox-DbM57zbg.js +++ /dev/null @@ -1 +0,0 @@ -import{a as e,c as t}from"./shim-mfK0Rmj6.js";import{E as n,a as r}from"./useI18n-BSw4X3mq.js";import{A as i,F as a,G as o,I as s,J as c,L as l,M as u,Y as d,d as f,j as p,q as m,u as h}from"./SharedElementTransition-BlCsXfb1.js";import{c as g,f as _,i as v,m as y,p as b,u as x}from"./label-n7vfsS35.js";import{t as S}from"./useToggle-HDaAPzVy.js";var C=t(e(),1),w=new WeakMap;function T(e,t,n){let{labelProps:r,inputProps:i,descriptionProps:a,errorMessageProps:o,isSelected:s,isPressed:l,isDisabled:u,isReadOnly:d,isInvalid:f,validationErrors:p,validationDetails:m}=S(e,t,n),{isIndeterminate:h}=e;return(0,C.useEffect)(()=>{n.current&&(n.current.indeterminate=!!h)}),{labelProps:c(r,(0,C.useMemo)(()=>({onMouseDown:e=>e.preventDefault()}),[])),inputProps:i,descriptionProps:a,errorMessageProps:o,isSelected:s,isPressed:l,isDisabled:u,isReadOnly:d,isInvalid:f,validationErrors:p,validationDetails:m}}function E(e,t,n){let r=v({isReadOnly:e.isReadOnly||t.isReadOnly,isSelected:t.isSelected(e.value),defaultSelected:t.defaultValue.includes(e.value),onChange(n){n?t.addValue(e.value):t.removeValue(e.value),e.onChange&&e.onChange(n)}}),{name:i,form:a,descriptionId:o,errorMessageId:s,validationBehavior:c}=w.get(t);c=e.validationBehavior??c;let{realtimeValidation:l}=b({...e,value:r.isSelected,name:void 0,validationBehavior:`aria`}),u=(0,C.useRef)(_),d=()=>{t.setInvalid(e.value,l.isInvalid?l:u.current)};(0,C.useEffect)(d);let f=t.realtimeValidation.isInvalid?t.realtimeValidation:l,p=c===`native`?t.displayValidation:f,m=T({...e,isReadOnly:e.isReadOnly||t.isReadOnly,isDisabled:e.isDisabled||t.isDisabled,name:e.name||i,form:e.form||a,isRequired:e.isRequired??t.isRequired,validationBehavior:c,[x]:{realtimeValidation:f,displayValidation:p,resetValidation:t.resetValidation,commitValidation:t.commitValidation,updateValidation(e){u.current=e,d()}}},r,n);return{...m,inputProps:{...m.inputProps,"aria-describedby":[m.inputProps[`aria-describedby`],t.isInvalid?s:null,o].filter(Boolean).join(` `)||void 0}}}var D=(0,C.createContext)(null),O=(0,C.createContext)(null),k=(0,C.createContext)(null),A=(0,C.createContext)(null),j=(0,C.forwardRef)(function(e,t){let{inputRef:n=null,...o}=e;[e,t]=p(o,t,O);let s=(0,C.useContext)(k),[l,d]=M(e,n),{descriptionProps:f,errorMessageProps:h,isSelected:g,isDisabled:_,isReadOnly:v,isInvalid:b,validationDetails:x,validationErrors:S}=l,w=u({...e,defaultClassName:`react-aria-CheckboxField`,values:{isSelected:g,isIndeterminate:e.isIndeterminate||!1,isDisabled:_,isReadOnly:v,isInvalid:b,isRequired:e.isRequired||!1}}),T=m(e,{global:!0});return delete T.id,delete T.onClick,C.createElement(a.div,{...c(T,w),ref:t,slot:e.slot||void 0,"data-selected":g||void 0,"data-indeterminate":e.isIndeterminate||void 0,"data-disabled":_||void 0,"data-readonly":v||void 0,"data-invalid":b||void 0,"data-required":e.isRequired||void 0},C.createElement(i,{values:[[A,{...l,inputRef:d,defaultClassName:`react-aria-CheckboxButton`,isIndeterminate:e.isIndeterminate,isRequired:e.isRequired}],[r,{slots:{description:f,errorMessage:h}}],[y,s?null:{isInvalid:b,validationDetails:x,validationErrors:S}]]},w.children))});function M(e,t){let{validationBehavior:n}=l(g)||{},r=e.validationBehavior??n??`native`,i=(0,C.useContext)(k),a=o((0,C.useMemo)(()=>d(t,e.inputRef===void 0?null:e.inputRef),[t,e.inputRef])),c={...s(e),children:typeof e.children==`function`||e.children,value:e.value,validationBehavior:r};return[i?E(c,i,a):T(c,v(e),a),a]}var N=(0,C.forwardRef)(function(e,t){let{labelProps:r,inputProps:i,isSelected:o,isDisabled:s,isReadOnly:l,isPressed:d,isInvalid:p,inputRef:g,defaultClassName:_,isIndeterminate:v,isRequired:y}=(0,C.useContext)(A),{isFocused:b,isFocusVisible:x,focusProps:S}=f(),w=s||l,{hoverProps:T,isHovered:E}=h({...e,isDisabled:w}),D=u({...e,defaultClassName:_,values:{isSelected:o,isIndeterminate:v||!1,isPressed:d,isHovered:E,isFocused:b,isFocusVisible:x,isDisabled:s,isReadOnly:l,isInvalid:p,isRequired:y||!1}}),O=m(e,{global:!0});return delete O.id,delete O.onClick,C.createElement(a.label,{...c(O,r,T,D),ref:t,slot:e.slot||void 0,"data-selected":o||void 0,"data-indeterminate":v||void 0,"data-pressed":d||void 0,"data-hovered":E||void 0,"data-focused":b||void 0,"data-focus-visible":x||void 0,"data-disabled":s||void 0,"data-readonly":l||void 0,"data-invalid":p||void 0,"data-required":y||void 0},C.createElement(n,{elementType:`span`},C.createElement(`input`,{...c(i,S),ref:g})),D.children)});export{O as i,j as n,D as r,N as t}; \ No newline at end of file diff --git a/internal/webui/static/assets/CompactSwitch-DH1Gk66-.js b/internal/webui/static/assets/CompactSwitch-DH1Gk66-.js deleted file mode 100644 index 262c084b..00000000 --- a/internal/webui/static/assets/CompactSwitch-DH1Gk66-.js +++ /dev/null @@ -1 +0,0 @@ -import{a as e,c as t,n}from"./shim-mfK0Rmj6.js";import{E as r,a as i}from"./useI18n-BSw4X3mq.js";import{A as a,B as o,F as s,G as c,I as l,J as u,L as d,M as f,Y as p,c as m,d as h,j as g,q as _,s as v,u as y,z as b}from"./SharedElementTransition-BlCsXfb1.js";import{c as x,i as S,m as C,t as w}from"./label-n7vfsS35.js";import{t as T}from"./useToggle-HDaAPzVy.js";var E=b({defaultVariants:{size:`md`},slots:{base:`switch`,content:`switch__content`,control:`switch__control`,icon:`switch__icon`,thumb:`switch__thumb`},variants:{size:{lg:{base:`switch--lg`},md:{base:`switch--md`},sm:{base:`switch--sm`}}}});function D(e,t,n){let{labelProps:r,inputProps:i,isSelected:a,...o}=T(e,t,n);return{labelProps:r,inputProps:{...i,role:`switch`,checked:a},isSelected:a,...o}}var O=t(e(),1),k=(0,O.createContext)(null),A=(0,O.createContext)(null),j=(0,O.createContext)(null),M=(0,O.forwardRef)(function(e,t){let{inputRef:n=null,...r}=e;[e,t]=g(r,t,k);let{validationBehavior:o}=d(x)||{},m=e.validationBehavior??o??`native`,h=c(p(n,e.inputRef===void 0?null:e.inputRef)),v=S(e),y=D({...l(e),children:typeof e.children==`function`||e.children,validationBehavior:m},v,h),{descriptionProps:b,errorMessageProps:w,isSelected:T,isDisabled:E,isReadOnly:M,isInvalid:N,validationDetails:P,validationErrors:F}=y,I=f({...e,defaultClassName:`react-aria-SwitchField`,values:{isSelected:T,isDisabled:E,isReadOnly:M,isInvalid:N,isRequired:e.isRequired||!1,state:v}}),L=_(e,{global:!0});return delete L.id,delete L.onClick,O.createElement(s.div,{...u(L,I),ref:t,slot:e.slot||void 0,"data-selected":T||void 0,"data-disabled":E||void 0,"data-readonly":M||void 0,"data-invalid":N||void 0,"data-required":e.isRequired||void 0},O.createElement(a,{values:[[A,v],[j,{...y,inputRef:h,defaultClassName:`react-aria-SwitchButton`,isRequired:e.isRequired}],[i,{slots:{description:b,errorMessage:w}}],[C,{isInvalid:N,validationDetails:P,validationErrors:F}]]},I.children))}),N=(0,O.forwardRef)(function(e,t){let{labelProps:n,inputProps:i,isSelected:a,isDisabled:o,isReadOnly:c,isPressed:l,isInvalid:d,inputRef:p,defaultClassName:m,isRequired:g}=(0,O.useContext)(j),{isFocused:v,isFocusVisible:b,focusProps:x}=h(),S=o||c,C=(0,O.useContext)(A),{hoverProps:w,isHovered:T}=y({...e,isDisabled:S}),E=f({...e,defaultClassName:m,values:{isSelected:a,isPressed:l,isHovered:T,isFocused:v,isFocusVisible:b,isDisabled:o,isReadOnly:c,isInvalid:d,isRequired:g||!1,state:C}}),D=_(e,{global:!0});return delete D.id,delete D.onClick,O.createElement(s.label,{...u(D,n,w,E),ref:t,slot:e.slot||void 0,"data-selected":a||void 0,"data-pressed":l||void 0,"data-hovered":T||void 0,"data-focused":v||void 0,"data-focus-visible":b||void 0,"data-disabled":o||void 0,"data-readonly":c||void 0,"data-invalid":d||void 0,"data-required":g||void 0},O.createElement(r,{elementType:`span`},O.createElement(`input`,{...u(i,x),ref:p})),E.children)}),P=n(),F=(0,O.createContext)({}),I=({children:e,className:t,size:n,...r})=>{let i=O.useMemo(()=>E({size:n}),[n]);return(0,P.jsx)(M,{"data-slot":`switch`,...r,className:m(t,i.base()),children:t=>(0,P.jsx)(F,{value:{slots:i,state:t},children:typeof e==`function`?e(t):e})})};I.displayName=`HeroUI.Switch`;var L=({children:e,className:t,...n})=>{let{slots:r}=(0,O.use)(F);return(0,P.jsx)(N,{"data-slot":`switch-content`,...n,className:m(t,r?.content()),children:e})};L.displayName=`HeroUI.Switch.Content`;var R=({children:e,className:t,...n})=>{let{slots:r}=(0,O.use)(F);return(0,P.jsx)(o.span,{className:v(r?.control,t),"data-slot":`switch-control`,...n,children:e})};R.displayName=`HeroUI.Switch.Control`;var z=({children:e,className:t,...n})=>{let{slots:r}=(0,O.use)(F);return(0,P.jsx)(o.span,{className:v(r?.thumb,t),"data-slot":`switch-thumb`,...n,children:e})};z.displayName=`HeroUI.Switch.Thumb`;var B=({children:e,className:t,...n})=>{let{slots:r}=(0,O.use)(F);return(0,P.jsx)(o.span,{className:v(r?.icon,t),"data-slot":`switch-icon`,...n,children:e})};B.displayName=`HeroUI.Switch.Icon`;var V=Object.assign(I,{Root:I,Content:L,Control:R,Thumb:z,Icon:B});function H({isSelected:e,isDisabled:t,ariaLabel:n,label:r,size:i=`sm`,onChange:a}){return(0,P.jsx)(V,{size:i,isSelected:e,isDisabled:t,onChange:a,children:(0,P.jsxs)(V.Content,{children:[(0,P.jsx)(V.Control,{children:(0,P.jsx)(V.Thumb,{})}),r?(0,P.jsx)(w,{children:r}):(0,P.jsx)(`span`,{className:`sr-only`,children:n})]})})}export{H as t}; \ No newline at end of file diff --git a/internal/webui/static/assets/ConfirmDialog-C6PfmZuk.js b/internal/webui/static/assets/ConfirmDialog-D6gNei8x.js similarity index 85% rename from internal/webui/static/assets/ConfirmDialog-C6PfmZuk.js rename to internal/webui/static/assets/ConfirmDialog-D6gNei8x.js index db7a4b9c..a75e1caa 100644 --- a/internal/webui/static/assets/ConfirmDialog-C6PfmZuk.js +++ b/internal/webui/static/assets/ConfirmDialog-D6gNei8x.js @@ -1 +1 @@ -import{a as e,c as t,n}from"./shim-mfK0Rmj6.js";import{J as r,R as i,Y as a,q as o,r as s}from"./useI18n-BSw4X3mq.js";import{B as c,c as l,s as u,z as d}from"./SharedElementTransition-BlCsXfb1.js";import{n as f}from"./modal-BVwBjYX-.js";import{B as p,H as m,R as h,V as g,xt as _,z as v}from"./index-C8_qeOs_.js";var y=d({defaultVariants:{size:`md`,status:`danger`,variant:`opaque`},slots:{backdrop:`alert-dialog__backdrop`,body:`alert-dialog__body`,closeTrigger:`alert-dialog__close-trigger`,container:`alert-dialog__container`,dialog:`alert-dialog__dialog`,footer:`alert-dialog__footer`,header:`alert-dialog__header`,heading:`alert-dialog__heading`,icon:`alert-dialog__icon`,trigger:`alert-dialog__trigger`},variants:{size:{cover:{dialog:`alert-dialog__dialog--cover`},lg:{dialog:`alert-dialog__dialog--lg`},md:{dialog:`alert-dialog__dialog--md`},sm:{dialog:`alert-dialog__dialog--sm`},xs:{dialog:`alert-dialog__dialog--xs`}},status:{accent:{icon:`alert-dialog__icon--accent`},danger:{icon:`alert-dialog__icon--danger`},default:{icon:`alert-dialog__icon--default`},success:{icon:`alert-dialog__icon--success`},warning:{icon:`alert-dialog__icon--warning`}},variant:{blur:{backdrop:`alert-dialog__backdrop--blur`},opaque:{backdrop:`alert-dialog__backdrop--opaque`},transparent:{backdrop:`alert-dialog__backdrop--transparent`}}}}),b=t(e(),1),x=n(),S=(0,b.createContext)({}),C=({children:e,...t})=>{let n=(0,b.useMemo)(()=>({slots:y(),placement:void 0}),[]);return(0,x.jsx)(S,{value:n,children:(0,x.jsx)(g,{"data-slot":`alert-dialog-root`,...t,children:e})})},w=Object.assign(C,{Root:C,Trigger:({children:e,className:t,...n})=>{let{slots:r}=(0,b.use)(S);return(0,x.jsx)(f,{children:(0,x.jsx)(`div`,{className:u(r?.trigger,t),"data-slot":`alert-dialog-trigger`,role:`button`,...n,children:e})})},Backdrop:({children:e,className:t,isDismissable:n=!1,isKeyboardDismissDisabled:r=!0,onClick:i,variant:a,...o})=>{let{slots:s}=(0,b.use)(S),c=(0,b.useMemo)(()=>y({variant:a}),[a]),u=(0,b.useMemo)(()=>({slots:{...s,...c}}),[s,c]);return(0,x.jsx)(p,{className:l(t,c?.backdrop()),"data-slot":`alert-dialog-backdrop`,isDismissable:n,isKeyboardDismissDisabled:r,onClick:e=>{e.stopPropagation(),i?.(e)},...o,children:t=>(0,x.jsxs)(S,{value:u,children:[typeof e==`function`?e(t):e,` `]})})},Container:({children:e,className:t,placement:n=`auto`,size:r,...i})=>{let{slots:a}=(0,b.use)(S),o=(0,b.useMemo)(()=>y({size:r}),[r]),s=(0,b.useMemo)(()=>({placement:n,slots:{...a,...o}}),[n,a,o]);return(0,x.jsx)(v,{className:l(t,o?.container()),"data-placement":n,"data-slot":`alert-dialog-container`,...i,children:t=>(0,x.jsx)(S,{value:s,children:typeof e==`function`?e(t):e})})},Dialog:({children:e,className:t,...n})=>{let{placement:r,slots:i}=(0,b.use)(S);return(0,x.jsx)(m,{className:u(i?.dialog,t),"data-placement":r,"data-slot":`alert-dialog-dialog`,role:`alertdialog`,...n,children:e})},Header:({children:e,className:t,...n})=>{let{slots:r}=(0,b.use)(S);return(0,x.jsx)(`div`,{className:u(r?.header,t),"data-slot":`alert-dialog-header`,...n,children:e})},Heading:({children:e,className:t,...n})=>{let{slots:r}=(0,b.use)(S);return(0,x.jsx)(_,{className:u(r?.heading,t),"data-slot":`alert-dialog-heading`,slot:`title`,...n,children:e})},Body:({children:e,className:t,...n})=>{let{slots:r}=(0,b.use)(S);return(0,x.jsx)(`div`,{className:u(r?.body,t),"data-slot":`alert-dialog-body`,...n,children:e})},Footer:({children:e,className:t,...n})=>{let{slots:r}=(0,b.use)(S);return(0,x.jsx)(`div`,{className:u(r?.footer,t),"data-slot":`alert-dialog-footer`,...n,children:e})},Icon:({children:e,className:t,status:n=`danger`,...s})=>{let l=(0,b.useMemo)(()=>y({status:n}),[n]),u=()=>{switch(n){case`default`:return(0,x.jsx)(o,{"data-slot":`alert-dialog-default-icon`});case`accent`:return(0,x.jsx)(o,{"data-slot":`alert-dialog-default-icon`});case`success`:return(0,x.jsx)(r,{"data-slot":`alert-dialog-default-icon`});case`warning`:return(0,x.jsx)(a,{"data-slot":`alert-dialog-default-icon`});case`danger`:return(0,x.jsx)(i,{"data-slot":`alert-dialog-default-icon`});default:return(0,x.jsx)(i,{"data-slot":`alert-dialog-default-icon`})}};return(0,x.jsx)(c.div,{className:l?.icon({className:t}),"data-slot":`alert-dialog-icon`,...s,children:e??u()})},CloseTrigger:({className:e,...t})=>{let{slots:n}=(0,b.use)(S);return(0,x.jsx)(h,{className:l(e,n?.closeTrigger()),"data-slot":`alert-dialog-close-trigger`,slot:`close`,...t})}});function T({isOpen:e,title:t,description:n,confirmLabel:r,cancelLabel:i,closeLabel:a,isPending:o,status:c=`danger`,confirmVariant:l=`danger`,onClose:u,onConfirm:d}){return(0,x.jsx)(w.Root,{isOpen:e,onOpenChange:e=>{!e&&!o&&u()},children:(0,x.jsx)(w.Backdrop,{variant:`blur`,isDismissable:!o,children:(0,x.jsx)(w.Container,{placement:`center`,size:`sm`,children:(0,x.jsxs)(w.Dialog,{children:[(0,x.jsxs)(w.Header,{className:`items-start justify-between gap-4`,children:[(0,x.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,x.jsx)(w.Icon,{status:c}),(0,x.jsx)(`div`,{children:(0,x.jsx)(w.Heading,{children:t})})]}),(0,x.jsx)(w.CloseTrigger,{isDisabled:o,"aria-label":a})]}),(0,x.jsx)(w.Body,{children:(0,x.jsx)(`p`,{className:`text-body leading-6 text-muted`,children:n})}),(0,x.jsxs)(w.Footer,{children:[(0,x.jsx)(s,{size:`sm`,variant:`ghost`,isDisabled:o,onPress:u,children:i}),(0,x.jsx)(s,{size:`sm`,variant:l,isPending:o,onPress:d,children:r})]})]})})})})}export{T as t}; \ No newline at end of file +import{a as e,c as t,n}from"./shim-mfK0Rmj6.js";import{G as r,I as i,K as a,q as o,r as s}from"./useI18n-BBOAnu2u.js";import{B as c,c as l,s as u,z as d}from"./SharedElementTransition-BlCsXfb1.js";import{n as f}from"./modal-DHeFzFnN.js";import{B as p,Ct as m,H as h,R as g,V as _,z as v}from"./index-B9eWF6SH.js";var y=d({defaultVariants:{size:`md`,status:`danger`,variant:`opaque`},slots:{backdrop:`alert-dialog__backdrop`,body:`alert-dialog__body`,closeTrigger:`alert-dialog__close-trigger`,container:`alert-dialog__container`,dialog:`alert-dialog__dialog`,footer:`alert-dialog__footer`,header:`alert-dialog__header`,heading:`alert-dialog__heading`,icon:`alert-dialog__icon`,trigger:`alert-dialog__trigger`},variants:{size:{cover:{dialog:`alert-dialog__dialog--cover`},lg:{dialog:`alert-dialog__dialog--lg`},md:{dialog:`alert-dialog__dialog--md`},sm:{dialog:`alert-dialog__dialog--sm`},xs:{dialog:`alert-dialog__dialog--xs`}},status:{accent:{icon:`alert-dialog__icon--accent`},danger:{icon:`alert-dialog__icon--danger`},default:{icon:`alert-dialog__icon--default`},success:{icon:`alert-dialog__icon--success`},warning:{icon:`alert-dialog__icon--warning`}},variant:{blur:{backdrop:`alert-dialog__backdrop--blur`},opaque:{backdrop:`alert-dialog__backdrop--opaque`},transparent:{backdrop:`alert-dialog__backdrop--transparent`}}}}),b=t(e(),1),x=n(),S=(0,b.createContext)({}),C=({children:e,...t})=>{let n=(0,b.useMemo)(()=>({slots:y(),placement:void 0}),[]);return(0,x.jsx)(S,{value:n,children:(0,x.jsx)(_,{"data-slot":`alert-dialog-root`,...t,children:e})})},w=Object.assign(C,{Root:C,Trigger:({children:e,className:t,...n})=>{let{slots:r}=(0,b.use)(S);return(0,x.jsx)(f,{children:(0,x.jsx)(`div`,{className:u(r?.trigger,t),"data-slot":`alert-dialog-trigger`,role:`button`,...n,children:e})})},Backdrop:({children:e,className:t,isDismissable:n=!1,isKeyboardDismissDisabled:r=!0,onClick:i,variant:a,...o})=>{let{slots:s}=(0,b.use)(S),c=(0,b.useMemo)(()=>y({variant:a}),[a]),u=(0,b.useMemo)(()=>({slots:{...s,...c}}),[s,c]);return(0,x.jsx)(p,{className:l(t,c?.backdrop()),"data-slot":`alert-dialog-backdrop`,isDismissable:n,isKeyboardDismissDisabled:r,onClick:e=>{e.stopPropagation(),i?.(e)},...o,children:t=>(0,x.jsxs)(S,{value:u,children:[typeof e==`function`?e(t):e,` `]})})},Container:({children:e,className:t,placement:n=`auto`,size:r,...i})=>{let{slots:a}=(0,b.use)(S),o=(0,b.useMemo)(()=>y({size:r}),[r]),s=(0,b.useMemo)(()=>({placement:n,slots:{...a,...o}}),[n,a,o]);return(0,x.jsx)(v,{className:l(t,o?.container()),"data-placement":n,"data-slot":`alert-dialog-container`,...i,children:t=>(0,x.jsx)(S,{value:s,children:typeof e==`function`?e(t):e})})},Dialog:({children:e,className:t,...n})=>{let{placement:r,slots:i}=(0,b.use)(S);return(0,x.jsx)(h,{className:u(i?.dialog,t),"data-placement":r,"data-slot":`alert-dialog-dialog`,role:`alertdialog`,...n,children:e})},Header:({children:e,className:t,...n})=>{let{slots:r}=(0,b.use)(S);return(0,x.jsx)(`div`,{className:u(r?.header,t),"data-slot":`alert-dialog-header`,...n,children:e})},Heading:({children:e,className:t,...n})=>{let{slots:r}=(0,b.use)(S);return(0,x.jsx)(m,{className:u(r?.heading,t),"data-slot":`alert-dialog-heading`,slot:`title`,...n,children:e})},Body:({children:e,className:t,...n})=>{let{slots:r}=(0,b.use)(S);return(0,x.jsx)(`div`,{className:u(r?.body,t),"data-slot":`alert-dialog-body`,...n,children:e})},Footer:({children:e,className:t,...n})=>{let{slots:r}=(0,b.use)(S);return(0,x.jsx)(`div`,{className:u(r?.footer,t),"data-slot":`alert-dialog-footer`,...n,children:e})},Icon:({children:e,className:t,status:n=`danger`,...s})=>{let l=(0,b.useMemo)(()=>y({status:n}),[n]),u=()=>{switch(n){case`default`:return(0,x.jsx)(r,{"data-slot":`alert-dialog-default-icon`});case`accent`:return(0,x.jsx)(r,{"data-slot":`alert-dialog-default-icon`});case`success`:return(0,x.jsx)(a,{"data-slot":`alert-dialog-default-icon`});case`warning`:return(0,x.jsx)(o,{"data-slot":`alert-dialog-default-icon`});case`danger`:return(0,x.jsx)(i,{"data-slot":`alert-dialog-default-icon`});default:return(0,x.jsx)(i,{"data-slot":`alert-dialog-default-icon`})}};return(0,x.jsx)(c.div,{className:l?.icon({className:t}),"data-slot":`alert-dialog-icon`,...s,children:e??u()})},CloseTrigger:({className:e,...t})=>{let{slots:n}=(0,b.use)(S);return(0,x.jsx)(g,{className:l(e,n?.closeTrigger()),"data-slot":`alert-dialog-close-trigger`,slot:`close`,...t})}});function T({isOpen:e,title:t,description:n,confirmLabel:r,cancelLabel:i,closeLabel:a,isPending:o,status:c=`danger`,confirmVariant:l=`danger`,onClose:u,onConfirm:d}){return(0,x.jsx)(w.Root,{isOpen:e,onOpenChange:e=>{!e&&!o&&u()},children:(0,x.jsx)(w.Backdrop,{variant:`blur`,isDismissable:!o,children:(0,x.jsx)(w.Container,{placement:`center`,size:`sm`,children:(0,x.jsxs)(w.Dialog,{children:[(0,x.jsxs)(w.Header,{className:`items-start justify-between gap-4`,children:[(0,x.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,x.jsx)(w.Icon,{status:c}),(0,x.jsx)(`div`,{children:(0,x.jsx)(w.Heading,{children:t})})]}),(0,x.jsx)(w.CloseTrigger,{isDisabled:o,"aria-label":a})]}),(0,x.jsx)(w.Body,{children:(0,x.jsx)(`p`,{className:`text-body leading-6 text-muted`,children:n})}),(0,x.jsxs)(w.Footer,{children:[(0,x.jsx)(s,{size:`sm`,variant:`ghost`,isDisabled:o,onPress:u,children:i}),(0,x.jsx)(s,{size:`sm`,variant:l,isPending:o,onPress:d,children:r})]})]})})})})}export{T as t}; \ No newline at end of file diff --git a/internal/webui/static/assets/CostChart-DMfp1L5p.js b/internal/webui/static/assets/CostChart-DOuzu6PW.js similarity index 67% rename from internal/webui/static/assets/CostChart-DMfp1L5p.js rename to internal/webui/static/assets/CostChart-DOuzu6PW.js index 4ec3cf1b..0e5f639b 100644 --- a/internal/webui/static/assets/CostChart-DMfp1L5p.js +++ b/internal/webui/static/assets/CostChart-DOuzu6PW.js @@ -1 +1 @@ -import{a as e,c as t,n}from"./shim-mfK0Rmj6.js";import{At as r,a as i,r as a,t as o}from"./AreaChart-B0YOdVBx.js";import{n as s,t as c}from"./CartesianGrid-BJyfpdDb.js";import{t as l}from"./XAxis-DLQkFqxC.js";import{i as u,o as d,r as f}from"./format-B6SmebW-.js";var p=t(e(),1),m=n(),h=[`var(--accent)`,`var(--muted)`,`var(--success)`,`var(--warning)`];function g(e,t,n){let r=new Date(e);return Number.isFinite(r.getTime())?new Intl.DateTimeFormat(n===`zh`?`zh-CN`:`en-US`,t?{month:`short`,day:`numeric`}:{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,hour12:!1}).format(r):``}function _(e,t){return t===`credits`?e.per_model_credits??{}:t===`tokens`?e.per_model_tokens??{}:e.per_model??{}}function v(e,t){return t===`cost`?f(e):t===`tokens`?u(e):d(e)}function y(e,t){return t===`cost`?`¥${e>=10?Math.round(e):Number(e.toFixed(1))}`:t===`tokens`?u(e):d(e)}function b({active:e,payload:t,label:n,daily:r,lang:i,models:a,totalLabel:o,metric:s}){if(!e||!t?.length)return null;let c=new Map(a.map(e=>[e.id,e.label])),l=t.filter(e=>(e.value??0)>0).sort((e,t)=>t.value-e.value),u=t.reduce((e,t)=>e+(t.value??0),0);return(0,m.jsxs)(`div`,{className:`rounded-xl bg-overlay px-3 py-2 text-caption text-overlay-foreground shadow-overlay`,children:[(0,m.jsx)(`div`,{className:`mono text-muted`,children:g(String(n),r,i)}),(0,m.jsxs)(`div`,{className:`mt-1.5 grid gap-1`,children:[l.map(e=>(0,m.jsxs)(`div`,{className:`flex items-center justify-between gap-6`,children:[(0,m.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,m.jsx)(`span`,{className:`size-1.5 rounded-full`,style:{background:h[a.findIndex(t=>t.id===e.dataKey)%h.length]}}),c.get(e.dataKey)||e.dataKey]}),(0,m.jsx)(`span`,{className:`mono font-medium`,children:v(e.value,s)})]},e.dataKey)),(0,m.jsxs)(`div`,{className:`flex items-center justify-between gap-6 border-t border-separator pt-1`,children:[(0,m.jsx)(`span`,{className:`text-muted`,children:o}),(0,m.jsx)(`span`,{className:`mono font-medium`,children:v(u,s)})]})]})]})}function x({series:e,models:t,lang:n,emptyLabel:u,totalLabel:d,metric:f=`credits`}){let v=(0,p.useMemo)(()=>t.map(e=>e.id),[t]),x=(0,p.useMemo)(()=>e.map(e=>{let t=_(e,f),n={at:e.at};for(let e of v){let r=Number(t[e]??0);n[e]=f===`tokens`?r:Number(r.toFixed(4))}return n}),[e,v,f]),S=Math.max(0,...x.map(e=>v.reduce((t,n)=>t+Number(e[n]??0),0)))>0,C=(x.length>1?Date.parse(x[x.length-1].at)-Date.parse(x[0].at):0)>1728e5;return!e.length||!S?(0,m.jsx)(`div`,{className:`grid min-h-56 place-items-center px-6 py-12 text-center text-sm text-muted`,children:u}):(0,m.jsxs)(`div`,{className:`min-w-0`,children:[(0,m.jsx)(`div`,{className:`h-72 w-full`,children:(0,m.jsx)(r,{width:`100%`,height:`100%`,children:(0,m.jsxs)(o,{data:x,margin:{top:8,right:8,bottom:0,left:0},children:[(0,m.jsx)(`defs`,{children:v.map((e,t)=>(0,m.jsxs)(`linearGradient`,{id:`cost-${f}-${e}`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,m.jsx)(`stop`,{offset:`0%`,stopColor:h[t%h.length],stopOpacity:.32}),(0,m.jsx)(`stop`,{offset:`100%`,stopColor:h[t%h.length],stopOpacity:.04})]},e))}),(0,m.jsx)(c,{vertical:!1,stroke:`var(--separator)`,strokeDasharray:`3 6`}),(0,m.jsx)(l,{dataKey:`at`,tickLine:!1,axisLine:!1,minTickGap:28,tick:{fill:`var(--muted)`,fontSize:10,fontFamily:`var(--font-mono)`},tickFormatter:e=>g(e,C,n)}),(0,m.jsx)(a,{width:52,tickLine:!1,axisLine:!1,tick:{fill:`var(--muted)`,fontSize:10,fontFamily:`var(--font-mono)`},tickFormatter:e=>y(e,f)}),(0,m.jsx)(s,{cursor:{stroke:`var(--border)`,strokeDasharray:`3 3`},content:(0,m.jsx)(b,{daily:C,lang:n,models:t,totalLabel:d,metric:f})}),v.map((e,t)=>(0,m.jsx)(i,{type:`monotone`,dataKey:e,stackId:`usage`,stroke:h[t%h.length],strokeWidth:1.5,fill:`url(#cost-${f}-${e})`,isAnimationActive:!1,dot:!1,activeDot:{r:3,strokeWidth:1.2}},e))]})})}),(0,m.jsx)(`div`,{className:`mt-2 flex flex-wrap items-center gap-x-4 gap-y-1 text-[10px] text-muted`,children:t.map((e,t)=>(0,m.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,m.jsx)(`span`,{className:`size-1.5 rounded-full`,style:{background:h[t%h.length]}}),e.label]},e.id))})]})}export{x as CostChart}; \ No newline at end of file +import{a as e,c as t,n}from"./shim-mfK0Rmj6.js";import{i as r,o as i,r as a}from"./format-kRpr2wxA.js";import{At as o,a as s,r as c,t as l}from"./AreaChart-B0YOdVBx.js";import{n as u,t as d}from"./CartesianGrid-BJyfpdDb.js";import{t as f}from"./XAxis-DLQkFqxC.js";var p=t(e(),1),m=n(),h=[`var(--accent)`,`var(--muted)`,`var(--success)`,`var(--warning)`];function g(e,t,n){let r=new Date(e);return Number.isFinite(r.getTime())?new Intl.DateTimeFormat(n===`zh`?`zh-CN`:`en-US`,t?{month:`short`,day:`numeric`}:{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,hour12:!1}).format(r):``}function _(e,t){return t===`credits`?e.per_model_credits??{}:t===`tokens`?e.per_model_tokens??{}:e.per_model??{}}function v(e,t){return t===`cost`?a(e):t===`tokens`?r(e):i(e)}function y(e,t){return t===`cost`?`¥${e>=10?Math.round(e):Number(e.toFixed(1))}`:t===`tokens`?r(e):i(e)}function b({active:e,payload:t,label:n,daily:r,lang:i,models:a,totalLabel:o,metric:s}){if(!e||!t?.length)return null;let c=new Map(a.map(e=>[e.id,e.label])),l=t.filter(e=>(e.value??0)>0).sort((e,t)=>t.value-e.value),u=t.reduce((e,t)=>e+(t.value??0),0);return(0,m.jsxs)(`div`,{className:`rounded-xl bg-overlay px-3 py-2 text-caption text-overlay-foreground shadow-overlay`,children:[(0,m.jsx)(`div`,{className:`mono text-muted`,children:g(String(n),r,i)}),(0,m.jsxs)(`div`,{className:`mt-1.5 grid gap-1`,children:[l.map(e=>(0,m.jsxs)(`div`,{className:`flex items-center justify-between gap-6`,children:[(0,m.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,m.jsx)(`span`,{className:`size-1.5 rounded-full`,style:{background:h[a.findIndex(t=>t.id===e.dataKey)%h.length]}}),c.get(e.dataKey)||e.dataKey]}),(0,m.jsx)(`span`,{className:`mono font-medium`,children:v(e.value,s)})]},e.dataKey)),(0,m.jsxs)(`div`,{className:`flex items-center justify-between gap-6 border-t border-separator pt-1`,children:[(0,m.jsx)(`span`,{className:`text-muted`,children:o}),(0,m.jsx)(`span`,{className:`mono font-medium`,children:v(u,s)})]})]})]})}function x({series:e,models:t,lang:n,emptyLabel:r,totalLabel:i,metric:a=`credits`}){let v=(0,p.useMemo)(()=>t.map(e=>e.id),[t]),x=(0,p.useMemo)(()=>e.map(e=>{let t=_(e,a),n={at:e.at};for(let e of v){let r=Number(t[e]??0);n[e]=a===`tokens`?r:Number(r.toFixed(4))}return n}),[e,v,a]),S=Math.max(0,...x.map(e=>v.reduce((t,n)=>t+Number(e[n]??0),0)))>0,C=(x.length>1?Date.parse(x[x.length-1].at)-Date.parse(x[0].at):0)>1728e5;return!e.length||!S?(0,m.jsx)(`div`,{className:`grid min-h-56 place-items-center px-6 py-12 text-center text-sm text-muted`,children:r}):(0,m.jsxs)(`div`,{className:`min-w-0`,children:[(0,m.jsx)(`div`,{className:`h-72 w-full`,children:(0,m.jsx)(o,{width:`100%`,height:`100%`,children:(0,m.jsxs)(l,{data:x,margin:{top:8,right:8,bottom:0,left:0},children:[(0,m.jsx)(`defs`,{children:v.map((e,t)=>(0,m.jsxs)(`linearGradient`,{id:`cost-${a}-${e}`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,m.jsx)(`stop`,{offset:`0%`,stopColor:h[t%h.length],stopOpacity:.32}),(0,m.jsx)(`stop`,{offset:`100%`,stopColor:h[t%h.length],stopOpacity:.04})]},e))}),(0,m.jsx)(d,{vertical:!1,stroke:`var(--separator)`,strokeDasharray:`3 6`}),(0,m.jsx)(f,{dataKey:`at`,tickLine:!1,axisLine:!1,minTickGap:28,tick:{fill:`var(--muted)`,fontSize:10,fontFamily:`var(--font-mono)`},tickFormatter:e=>g(e,C,n)}),(0,m.jsx)(c,{width:52,tickLine:!1,axisLine:!1,tick:{fill:`var(--muted)`,fontSize:10,fontFamily:`var(--font-mono)`},tickFormatter:e=>y(e,a)}),(0,m.jsx)(u,{cursor:{stroke:`var(--border)`,strokeDasharray:`3 3`},content:(0,m.jsx)(b,{daily:C,lang:n,models:t,totalLabel:i,metric:a})}),v.map((e,t)=>(0,m.jsx)(s,{type:`monotone`,dataKey:e,stackId:`usage`,stroke:h[t%h.length],strokeWidth:1.5,fill:`url(#cost-${a}-${e})`,isAnimationActive:!1,dot:!1,activeDot:{r:3,strokeWidth:1.2}},e))]})})}),(0,m.jsx)(`div`,{className:`mt-2 flex flex-wrap items-center gap-x-4 gap-y-1 text-[10px] text-muted`,children:t.map((e,t)=>(0,m.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,m.jsx)(`span`,{className:`size-1.5 rounded-full`,style:{background:h[t%h.length]}}),e.label]},e.id))})]})}export{x as CostChart}; \ No newline at end of file diff --git a/internal/webui/static/assets/FilterSelect-CNXkxdW1.js b/internal/webui/static/assets/FilterSelect-CNXkxdW1.js deleted file mode 100644 index a018b34c..00000000 --- a/internal/webui/static/assets/FilterSelect-CNXkxdW1.js +++ /dev/null @@ -1 +0,0 @@ -import{n as e}from"./shim-mfK0Rmj6.js";import{t}from"./label-n7vfsS35.js";import{t as n}from"./list-box-DD4xJ3gX.js";import{t as r}from"./select-CtWmaZQ5.js";var i=e(),a=`__all__`;function o({value:e,onChange:o,ariaLabel:s,options:c,className:l}){let u=c.map(e=>({id:e.id||a,label:e.label})),d=e||a,f=u.find(e=>e.id===d);return(0,i.jsxs)(r,{className:l??`w-fit min-w-36`,"aria-label":s,value:d,onChange:e=>{typeof e==`string`&&o(e===a?``:e)},children:[(0,i.jsxs)(r.Trigger,{className:`min-w-0 w-full items-center`,children:[(0,i.jsx)(r.Value,{className:`min-w-0 truncate`,children:({defaultChildren:e,isPlaceholder:t})=>t||!f?e:(0,i.jsx)(`span`,{className:`truncate`,children:f.label})}),(0,i.jsx)(r.Indicator,{})]}),(0,i.jsx)(r.Popover,{className:`max-h-72 min-w-36`,children:(0,i.jsx)(n,{children:u.map(e=>(0,i.jsxs)(n.Item,{id:e.id,textValue:e.label,children:[(0,i.jsx)(t,{className:`block truncate`,children:e.label}),(0,i.jsx)(n.ItemIndicator,{})]},e.id))})})]})}export{o as t}; \ No newline at end of file diff --git a/internal/webui/static/assets/FilterSelect-GGHAJGuF.js b/internal/webui/static/assets/FilterSelect-GGHAJGuF.js new file mode 100644 index 00000000..a8585615 --- /dev/null +++ b/internal/webui/static/assets/FilterSelect-GGHAJGuF.js @@ -0,0 +1 @@ +import{n as e}from"./shim-mfK0Rmj6.js";import{t}from"./label-BVCjtfNQ.js";import{t as n}from"./list-box-1t_n3N3P.js";import{t as r}from"./select-BYBzHj05.js";var i=e(),a=`__all__`;function o({value:e,onChange:o,ariaLabel:s,options:c,className:l,isDisabled:u=!1}){let d=c.map(e=>({id:e.id||a,label:e.label})),f=e||a,p=d.find(e=>e.id===f);return(0,i.jsxs)(r,{className:l??`w-fit min-w-36`,"aria-label":s,value:f,isDisabled:u,onChange:e=>{typeof e==`string`&&o(e===a?``:e)},children:[(0,i.jsxs)(r.Trigger,{className:`min-w-0 w-full items-center`,children:[(0,i.jsx)(r.Value,{className:`min-w-0 truncate`,children:({defaultChildren:e,isPlaceholder:t})=>t||!p?e:(0,i.jsx)(`span`,{className:`truncate`,children:p.label})}),(0,i.jsx)(r.Indicator,{})]}),(0,i.jsx)(r.Popover,{className:`max-h-72 min-w-36`,children:(0,i.jsx)(n,{children:d.map(e=>(0,i.jsxs)(n.Item,{id:e.id,textValue:e.label,children:[(0,i.jsx)(t,{className:`block truncate`,children:e.label}),(0,i.jsx)(n.ItemIndicator,{})]},e.id))})})]})}export{o as t}; \ No newline at end of file diff --git a/internal/webui/static/assets/FilterToggle-16Av-HiR.js b/internal/webui/static/assets/FilterToggle-16Av-HiR.js deleted file mode 100644 index 61309686..00000000 --- a/internal/webui/static/assets/FilterToggle-16Av-HiR.js +++ /dev/null @@ -1 +0,0 @@ -import{a as e,c as t,n}from"./shim-mfK0Rmj6.js";import{n as r,t as i}from"./toggle-button-group-C6lenpLr.js";import{r as a}from"./gsap-C3sDxib7.js";import{b as o,v as s,y as c}from"./index-C8_qeOs_.js";var l=t(e(),1),u=n(),d={"--toggle-button-bg-selected":`transparent`,"--toggle-button-bg-selected-hover":`transparent`,"--toggle-button-bg-selected-pressed":`transparent`};function f({value:e,onChange:t,options:n,ariaLabel:f,className:p}){let m=(0,l.useRef)(null),h=(0,l.useRef)(null),g=(0,l.useRef)(!1);return(0,l.useLayoutEffect)(()=>{let e=m.current,t=h.current;if(!e||!t)return;let n=n=>{let r=e.querySelector(`[data-selected="true"]`);if(!r){a.set(t,{autoAlpha:0});return}let i=e.getBoundingClientRect(),l=r.getBoundingClientRect();a.to(t,{x:l.left-i.left,y:l.top-i.top,width:l.width,height:l.height,autoAlpha:1,duration:n?o(s.base):0,ease:c.out,overwrite:!0})};n(g.current),g.current=!0;let r=new ResizeObserver(()=>n(!1));return r.observe(e),()=>{r.disconnect(),a.killTweensOf(t)}},[e,n]),(0,u.jsxs)(`div`,{ref:m,className:`filter-toggle relative inline-flex ${p??``}`,children:[(0,u.jsx)(`span`,{ref:h,"aria-hidden":!0,className:`filter-toggle__pill pointer-events-none absolute left-0 top-0 opacity-0`}),(0,u.jsx)(i,{"aria-label":f,size:`sm`,selectionMode:`single`,disallowEmptySelection:!0,selectedKeys:new Set([e]),onSelectionChange:n=>{let r=[...n][0];typeof r==`string`&&r!==e&&t(r)},children:n.map(e=>(0,u.jsxs)(r,{id:e.id,className:`relative z-[1]`,style:d,children:[e.icon,e.label]},e.id))})]})}export{f as t}; \ No newline at end of file diff --git a/internal/webui/static/assets/FilterToggle-AieL1mQy.js b/internal/webui/static/assets/FilterToggle-AieL1mQy.js new file mode 100644 index 00000000..f8f75a3e --- /dev/null +++ b/internal/webui/static/assets/FilterToggle-AieL1mQy.js @@ -0,0 +1 @@ +import{a as e,c as t,n}from"./shim-mfK0Rmj6.js";import{m as r,p as i}from"./format-kRpr2wxA.js";import{r as a}from"./gsap-C3sDxib7.js";import{b as o,v as s,y as c}from"./index-B9eWF6SH.js";var l=t(e(),1),u=n(),d={"--toggle-button-bg-selected":`transparent`,"--toggle-button-bg-selected-hover":`transparent`,"--toggle-button-bg-selected-pressed":`transparent`};function f({value:e,onChange:t,options:n,ariaLabel:f,className:p}){let m=(0,l.useRef)(null),h=(0,l.useRef)(null),g=(0,l.useRef)(!1);return(0,l.useLayoutEffect)(()=>{let e=m.current,t=h.current;if(!e||!t)return;let n=n=>{let r=e.querySelector(`[data-selected="true"]`);if(!r){a.set(t,{autoAlpha:0});return}let i=e.getBoundingClientRect(),l=r.getBoundingClientRect();a.to(t,{x:l.left-i.left,y:l.top-i.top,width:l.width,height:l.height,autoAlpha:1,duration:n?o(s.base):0,ease:c.out,overwrite:!0})};n(g.current),g.current=!0;let r=new ResizeObserver(()=>n(!1));return r.observe(e),()=>{r.disconnect(),a.killTweensOf(t)}},[e,n]),(0,u.jsxs)(`div`,{ref:m,className:`filter-toggle relative inline-flex ${p??``}`,children:[(0,u.jsx)(`span`,{ref:h,"aria-hidden":!0,className:`filter-toggle__pill pointer-events-none absolute left-0 top-0 opacity-0`}),(0,u.jsx)(i,{"aria-label":f,size:`sm`,selectionMode:`single`,disallowEmptySelection:!0,selectedKeys:new Set([e]),onSelectionChange:n=>{let r=[...n][0];typeof r==`string`&&r!==e&&t(r)},children:n.map(e=>(0,u.jsxs)(r,{id:e.id,className:`relative z-[1]`,style:d,children:[e.icon,e.label]},e.id))})]})}export{f as t}; \ No newline at end of file diff --git a/internal/webui/static/assets/FormRow-Bhp_wPvH.js b/internal/webui/static/assets/FormRow-Bhp_wPvH.js new file mode 100644 index 00000000..b814046f --- /dev/null +++ b/internal/webui/static/assets/FormRow-Bhp_wPvH.js @@ -0,0 +1 @@ +import{a as e,c as t,n}from"./shim-mfK0Rmj6.js";import{a as r}from"./useI18n-BBOAnu2u.js";import{A as i,B as a,F as o,G as s,I as c,J as l,L as u,M as d,Y as f,c as p,d as m,j as h,q as g,s as _,u as v,z as y}from"./SharedElementTransition-BlCsXfb1.js";import{p as b,r as x,s as S,t as C}from"./label-BVCjtfNQ.js";import{t as w}from"./textfield-DczGuWn0.js";import{t as T}from"./collection-prop-injection-CF1SevF_.js";import{t as E}from"./useToggleState-DpzdeNPF.js";import{t as D}from"./useToggle-BkQ49Unj.js";import{xt as O}from"./index-B9eWF6SH.js";var k=y({base:`input`,defaultVariants:{fullWidth:!1,variant:`primary`},variants:{fullWidth:{false:``,true:`input--full-width`},variant:{primary:`input--primary`,secondary:`input--secondary`}}}),A=y({defaultVariants:{size:`md`},slots:{base:`switch`,content:`switch__content`,control:`switch__control`,icon:`switch__icon`,thumb:`switch__thumb`},variants:{size:{lg:{base:`switch--lg`},md:{base:`switch--md`},sm:{base:`switch--sm`}}}}),j=t(e(),1),M=n(),N=(0,j.createContext)({});T(`combo-box.inputGroup`);function P(e,t,n){let{labelProps:r,inputProps:i,isSelected:a,...o}=D(e,t,n);return{labelProps:r,inputProps:{...i,role:`switch`,checked:a},isSelected:a,...o}}var F=(0,j.createContext)(null),I=(0,j.createContext)(null),L=(0,j.createContext)(null),R=(0,j.forwardRef)(function(e,t){let{inputRef:n=null,...a}=e;[e,t]=h(a,t,F);let{validationBehavior:p}=u(S)||{},m=e.validationBehavior??p??`native`,_=s(f(n,e.inputRef===void 0?null:e.inputRef)),v=E(e),y=P({...c(e),children:typeof e.children==`function`||e.children,validationBehavior:m},v,_),{descriptionProps:x,errorMessageProps:C,isSelected:w,isDisabled:T,isReadOnly:D,isInvalid:O,validationDetails:k,validationErrors:A}=y,M=d({...e,defaultClassName:`react-aria-SwitchField`,values:{isSelected:w,isDisabled:T,isReadOnly:D,isInvalid:O,isRequired:e.isRequired||!1,state:v}}),N=g(e,{global:!0});return delete N.id,delete N.onClick,j.createElement(o.div,{...l(N,M),ref:t,slot:e.slot||void 0,"data-selected":w||void 0,"data-disabled":T||void 0,"data-readonly":D||void 0,"data-invalid":O||void 0,"data-required":e.isRequired||void 0},j.createElement(i,{values:[[I,v],[L,{...y,inputRef:_,defaultClassName:`react-aria-SwitchButton`,isRequired:e.isRequired}],[r,{slots:{description:x,errorMessage:C}}],[b,{isInvalid:O,validationDetails:k,validationErrors:A}]]},M.children))}),z=(0,j.forwardRef)(function(e,t){let{labelProps:n,inputProps:r,isSelected:i,isDisabled:a,isReadOnly:s,isPressed:c,isInvalid:u,inputRef:f,defaultClassName:p,isRequired:h}=(0,j.useContext)(L),{isFocused:_,isFocusVisible:y,focusProps:b}=m(),x=a||s,S=(0,j.useContext)(I),{hoverProps:C,isHovered:w}=v({...e,isDisabled:x}),T=d({...e,defaultClassName:p,values:{isSelected:i,isPressed:c,isHovered:w,isFocused:_,isFocusVisible:y,isDisabled:a,isReadOnly:s,isInvalid:u,isRequired:h||!1,state:S}}),E=g(e,{global:!0});return delete E.id,delete E.onClick,j.createElement(o.label,{...l(E,n,C,T),ref:t,slot:e.slot||void 0,"data-selected":i||void 0,"data-pressed":c||void 0,"data-hovered":w||void 0,"data-focused":_||void 0,"data-focus-visible":y||void 0,"data-disabled":a||void 0,"data-readonly":s||void 0,"data-invalid":u||void 0,"data-required":h||void 0},j.createElement(O,{elementType:`span`},j.createElement(`input`,{...l(r,b),ref:f})),T.children)}),B=(0,j.createContext)({}),V=({children:e,className:t,size:n,...r})=>{let i=j.useMemo(()=>A({size:n}),[n]);return(0,M.jsx)(R,{"data-slot":`switch`,...r,className:p(t,i.base()),children:t=>(0,M.jsx)(B,{value:{slots:i,state:t},children:typeof e==`function`?e(t):e})})};V.displayName=`HeroUI.Switch`;var H=({children:e,className:t,...n})=>{let{slots:r}=(0,j.use)(B);return(0,M.jsx)(z,{"data-slot":`switch-content`,...n,className:p(t,r?.content()),children:e})};H.displayName=`HeroUI.Switch.Content`;var U=({children:e,className:t,...n})=>{let{slots:r}=(0,j.use)(B);return(0,M.jsx)(a.span,{className:_(r?.control,t),"data-slot":`switch-control`,...n,children:e})};U.displayName=`HeroUI.Switch.Control`;var W=({children:e,className:t,...n})=>{let{slots:r}=(0,j.use)(B);return(0,M.jsx)(a.span,{className:_(r?.thumb,t),"data-slot":`switch-thumb`,...n,children:e})};W.displayName=`HeroUI.Switch.Thumb`;var G=({children:e,className:t,...n})=>{let{slots:r}=(0,j.use)(B);return(0,M.jsx)(a.span,{className:_(r?.icon,t),"data-slot":`switch-icon`,...n,children:e})};G.displayName=`HeroUI.Switch.Icon`;var K=Object.assign(V,{Root:V,Content:H,Control:U,Thumb:W,Icon:G}),q=({className:e,fullWidth:t,variant:n,...r})=>{let i=(0,j.use)(w),a=(0,j.use)(N),o=n??i.variant??a.variant;return(0,M.jsx)(x,{className:p(e,k({fullWidth:t,variant:o})),"data-slot":`input`,...r})},J=Object.assign(q,{Root:q});function Y({isSelected:e,isDisabled:t,ariaLabel:n,label:r,size:i=`sm`,onChange:a}){return(0,M.jsx)(K,{size:i,isSelected:e,isDisabled:t,onChange:a,children:(0,M.jsxs)(K.Content,{children:[(0,M.jsx)(K.Control,{children:(0,M.jsx)(K.Thumb,{})}),r?(0,M.jsx)(C,{children:r}):(0,M.jsx)(`span`,{className:`sr-only`,children:n})]})})}var X=`w-28`;function Z({label:e,hint:t,labelWidthClass:n=X,htmlFor:r,align:i=`center`,children:a}){return(0,M.jsxs)(`div`,{children:[(0,M.jsxs)(`div`,{className:`flex gap-3 ${i===`start`?`items-start`:`items-center`}`,children:[(0,M.jsx)(C,{htmlFor:r,className:`${n} shrink-0 ${i===`start`?`pt-2`:``} text-body font-medium text-foreground`,children:e}),(0,M.jsx)(`div`,{className:`min-w-0 flex-1 [&_[data-slot=input]]:w-full [&_[data-slot=textarea]]:w-full`,children:a})]}),t?(0,M.jsx)(`p`,{className:`mt-1.5 pl-[7.75rem] text-caption leading-5 text-muted`,children:t}):null]})}export{Y as n,J as r,Z as t}; \ No newline at end of file diff --git a/internal/webui/static/assets/FormRow-D36RiZfK.js b/internal/webui/static/assets/FormRow-D36RiZfK.js deleted file mode 100644 index 3b42c9a4..00000000 --- a/internal/webui/static/assets/FormRow-D36RiZfK.js +++ /dev/null @@ -1 +0,0 @@ -import{a as e,c as t,n}from"./shim-mfK0Rmj6.js";import{c as r,z as i}from"./SharedElementTransition-BlCsXfb1.js";import{r as a,t as o}from"./label-n7vfsS35.js";import{t as s}from"./textfield-IBBKEG4T.js";import{t as c}from"./collection-prop-injection-ChD21sys.js";var l=i({base:`input`,defaultVariants:{fullWidth:!1,variant:`primary`},variants:{fullWidth:{false:``,true:`input--full-width`},variant:{primary:`input--primary`,secondary:`input--secondary`}}}),u=t(e(),1),d=n(),f=(0,u.createContext)({});c(`combo-box.inputGroup`);var p=({className:e,fullWidth:t,variant:n,...i})=>{let o=(0,u.use)(s),c=(0,u.use)(f),p=n??o.variant??c.variant;return(0,d.jsx)(a,{className:r(e,l({fullWidth:t,variant:p})),"data-slot":`input`,...i})},m=Object.assign(p,{Root:p}),h=`w-28`;function g({label:e,hint:t,labelWidthClass:n=h,htmlFor:r,align:i=`center`,children:a}){return(0,d.jsxs)(`div`,{children:[(0,d.jsxs)(`div`,{className:`flex gap-3 ${i===`start`?`items-start`:`items-center`}`,children:[(0,d.jsx)(o,{htmlFor:r,className:`${n} shrink-0 ${i===`start`?`pt-2`:``} text-body font-medium text-foreground`,children:e}),(0,d.jsx)(`div`,{className:`min-w-0 flex-1 [&_[data-slot=input]]:w-full [&_[data-slot=textarea]]:w-full`,children:a})]}),t?(0,d.jsx)(`p`,{className:`mt-1.5 pl-[7.75rem] text-caption leading-5 text-muted`,children:t}):null]})}export{m as n,g as t}; \ No newline at end of file diff --git a/internal/webui/static/assets/InflightDepthChart-BxVa9hs3.js b/internal/webui/static/assets/InflightDepthChart-Cl1KjYdd.js similarity index 98% rename from internal/webui/static/assets/InflightDepthChart-BxVa9hs3.js rename to internal/webui/static/assets/InflightDepthChart-Cl1KjYdd.js index ac50d28a..d87841e6 100644 --- a/internal/webui/static/assets/InflightDepthChart-BxVa9hs3.js +++ b/internal/webui/static/assets/InflightDepthChart-Cl1KjYdd.js @@ -1 +1 @@ -import{a as e,c as t,n,r}from"./shim-mfK0Rmj6.js";import{b as i,x as a}from"./index-C8_qeOs_.js";import{At as o,Dn as s,Gt as c,Ht as l,Kt as u,L as d,Ln as f,Mt as p,R as m,Rn as h,Sn as g,U as _,_ as v,a as y,ct as b,dt as x,f as S,g as C,kt as w,m as T,pt as E,r as D,t as O,tt as k}from"./AreaChart-B0YOdVBx.js";import{t as A}from"./XAxis-DLQkFqxC.js";import{n as j,t as M}from"./ReferenceArea-CiIBWWEY.js";var N=t(e());function P(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function F(e){for(var t=1;t{var n;if(N.isValidElement(e))n=N.cloneElement(e,t);else if(typeof e==`function`)n=e(t);else{if(!l(t.x1)||!l(t.y1)||!l(t.x2)||!l(t.y2))return null;n=N.createElement(`line`,z({},t,{className:`recharts-reference-line-line`}))}return n},V=(e,t,n,r,i,a)=>{var o=a.x,s=a.width,c=i.map(e,{position:n});if(!l(c)||t===`discard`&&!i.isInRange(c))return null;var u=[{x:o+s,y:c},{x:o,y:c}];return r===`left`?u.reverse():u},H=(e,t,n,r,i,a)=>{var o=a.y,s=a.height,c=i.map(e,{position:n});if(!l(c)||t===`discard`&&!i.isInRange(c))return null;var u=[{x:c,y:o+s},{x:c,y:o}];return r===`top`?u.reverse():u},U=(e,t,n,r)=>{var i=[r.mapWithFallback(e[0],{position:n,fallback:`rangeMin`}),r.mapWithFallback(e[1],{position:n,fallback:`rangeMax`})];return t===`discard`&&i.some(e=>!r.isInRange(e))?null:i},W=(e,t,n,r,i,a,o)=>{var c=o.x,l=o.y,u=o.segment,d=o.ifOverflow,f=s(c);return s(l)?V(l,d,r,a,t,n):f?H(c,d,r,i,e,n):u!=null&&u.length===2?U(u,d,r,new j({x:e,y:t})):null};function G(e){var t=c();return(0,N.useEffect)(()=>(t(T(e)),()=>{t(C(e))})),null}function K(e){var t=e.xAxisId,n=e.yAxisId,i=e.shape,a=e.className,o=e.ifOverflow,s=p(),c=S(),l=u(e=>b(e,t)),g=u(e=>x(e,n)),y=u(e=>k(e,`xAxis`,t,s)),C=u(e=>k(e,`yAxis`,n,s)),T=w();if(!c||!T||l==null||g==null||y==null||C==null)return null;var E=W(y,C,T,e.position,l.orientation,g.orientation,e);if(!E)return null;var D=E[0],O=E[1];if(D==null||O==null)return null;var A=D.x,j=D.y,M=O.x,P=O.y,I=F(F({clipPath:o===`hidden`?`url(#${c})`:void 0},h(e)),{},{x1:A,y1:j,x2:M,y2:P}),L=v({x1:A,y1:j,x2:M,y2:P});return N.createElement(_,{zIndex:e.zIndex},N.createElement(f,{className:r(`recharts-reference-line`,a)},B(i,I),N.createElement(d,z({},L,{lowerWidth:L.width,upperWidth:L.width}),N.createElement(m,{label:e.label}),e.children)))}var q={ifOverflow:`discard`,xAxisId:0,yAxisId:0,fill:`none`,label:!1,stroke:`#ccc`,fillOpacity:1,strokeWidth:1,position:`middle`,zIndex:E.line};function J(e){var t=g(e,q);return N.createElement(N.Fragment,null,N.createElement(G,{yAxisId:t.yAxisId,xAxisId:t.xAxisId,ifOverflow:t.ifOverflow,x:t.x,y:t.y,segment:t.segment}),N.createElement(K,t))}J.displayName=`ReferenceLine`;var Y=n();function X({series:e,bands:t,backpressure:n,label:r}){let s=Math.max(n,...e,1),c=(0,N.useRef)(s),[l,u]=(0,N.useState)(s);(0,N.useEffect)(()=>{if(a()){c.current=s,u(s);return}let e=c.current,t=s;if(Math.abs(t-e)<.01)return;let n=0,r=performance.now(),o=i(.56)*1e3,l=i=>{let a=Math.min(1,(i-r)/o),s=1-(1-a)**3,d=e+(t-e)*s;c.current=d,u(d),a<1&&(n=requestAnimationFrame(l))};return n=requestAnimationFrame(l),()=>cancelAnimationFrame(n)},[s]);let d=(0,N.useMemo)(()=>e.map((e,t)=>({i:t,v:e,bp:n})),[e,n]),f=(0,N.useMemo)(()=>t.map((t,n)=>{let r=Math.max(1,e.length-1);return{key:n,x1:t.from*r,x2:Math.max(t.from*r+.35,t.until*r)}}),[t,e.length]),p=Math.max(l,n,1);return(0,Y.jsx)(`div`,{className:`h-11 w-full overflow-hidden`,role:`img`,"aria-label":r,"data-depth-chart":!0,children:(0,Y.jsx)(o,{width:`100%`,height:`100%`,children:(0,Y.jsxs)(O,{data:d,margin:{top:4,right:2,bottom:2,left:2},children:[(0,Y.jsx)(D,{hide:!0,domain:[0,p],allowDataOverflow:!0}),(0,Y.jsx)(A,{hide:!0,dataKey:`i`,type:`number`,domain:[0,Math.max(0,e.length-1)]}),f.map(e=>(0,Y.jsx)(M,{x1:e.x1,x2:e.x2,y1:0,y2:p,fill:`var(--il-warn, var(--warning))`,fillOpacity:.14,ifOverflow:`extendDomain`},e.key)),(0,Y.jsx)(J,{y:n,stroke:`var(--il-faint, var(--foreground))`,strokeOpacity:.35,strokeDasharray:`3 3`,ifOverflow:`extendDomain`}),(0,Y.jsx)(`defs`,{children:(0,Y.jsxs)(`linearGradient`,{id:`il-depth-fill`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,Y.jsx)(`stop`,{offset:`0%`,stopColor:`var(--il-depth, var(--chart-1))`,stopOpacity:.28}),(0,Y.jsx)(`stop`,{offset:`100%`,stopColor:`var(--il-depth, var(--chart-1))`,stopOpacity:.04})]})}),(0,Y.jsx)(y,{type:`monotone`,dataKey:`v`,stroke:`var(--il-depth, var(--chart-1))`,strokeOpacity:.95,strokeWidth:1.85,fill:`url(#il-depth-fill)`,fillOpacity:1,isAnimationActive:!a(),animationDuration:Math.round(i(.56)*1e3),animationEasing:`linear`,dot:!1,activeDot:!1})]})})})}export{X as InflightDepthChart}; \ No newline at end of file +import{a as e,c as t,n,r}from"./shim-mfK0Rmj6.js";import{b as i,x as a}from"./index-B9eWF6SH.js";import{At as o,Dn as s,Gt as c,Ht as l,Kt as u,L as d,Ln as f,Mt as p,R as m,Rn as h,Sn as g,U as _,_ as v,a as y,ct as b,dt as x,f as S,g as C,kt as w,m as T,pt as E,r as D,t as O,tt as k}from"./AreaChart-B0YOdVBx.js";import{t as A}from"./XAxis-DLQkFqxC.js";import{n as j,t as M}from"./ReferenceArea-CiIBWWEY.js";var N=t(e());function P(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function F(e){for(var t=1;t{var n;if(N.isValidElement(e))n=N.cloneElement(e,t);else if(typeof e==`function`)n=e(t);else{if(!l(t.x1)||!l(t.y1)||!l(t.x2)||!l(t.y2))return null;n=N.createElement(`line`,z({},t,{className:`recharts-reference-line-line`}))}return n},V=(e,t,n,r,i,a)=>{var o=a.x,s=a.width,c=i.map(e,{position:n});if(!l(c)||t===`discard`&&!i.isInRange(c))return null;var u=[{x:o+s,y:c},{x:o,y:c}];return r===`left`?u.reverse():u},H=(e,t,n,r,i,a)=>{var o=a.y,s=a.height,c=i.map(e,{position:n});if(!l(c)||t===`discard`&&!i.isInRange(c))return null;var u=[{x:c,y:o+s},{x:c,y:o}];return r===`top`?u.reverse():u},U=(e,t,n,r)=>{var i=[r.mapWithFallback(e[0],{position:n,fallback:`rangeMin`}),r.mapWithFallback(e[1],{position:n,fallback:`rangeMax`})];return t===`discard`&&i.some(e=>!r.isInRange(e))?null:i},W=(e,t,n,r,i,a,o)=>{var c=o.x,l=o.y,u=o.segment,d=o.ifOverflow,f=s(c);return s(l)?V(l,d,r,a,t,n):f?H(c,d,r,i,e,n):u!=null&&u.length===2?U(u,d,r,new j({x:e,y:t})):null};function G(e){var t=c();return(0,N.useEffect)(()=>(t(T(e)),()=>{t(C(e))})),null}function K(e){var t=e.xAxisId,n=e.yAxisId,i=e.shape,a=e.className,o=e.ifOverflow,s=p(),c=S(),l=u(e=>b(e,t)),g=u(e=>x(e,n)),y=u(e=>k(e,`xAxis`,t,s)),C=u(e=>k(e,`yAxis`,n,s)),T=w();if(!c||!T||l==null||g==null||y==null||C==null)return null;var E=W(y,C,T,e.position,l.orientation,g.orientation,e);if(!E)return null;var D=E[0],O=E[1];if(D==null||O==null)return null;var A=D.x,j=D.y,M=O.x,P=O.y,I=F(F({clipPath:o===`hidden`?`url(#${c})`:void 0},h(e)),{},{x1:A,y1:j,x2:M,y2:P}),L=v({x1:A,y1:j,x2:M,y2:P});return N.createElement(_,{zIndex:e.zIndex},N.createElement(f,{className:r(`recharts-reference-line`,a)},B(i,I),N.createElement(d,z({},L,{lowerWidth:L.width,upperWidth:L.width}),N.createElement(m,{label:e.label}),e.children)))}var q={ifOverflow:`discard`,xAxisId:0,yAxisId:0,fill:`none`,label:!1,stroke:`#ccc`,fillOpacity:1,strokeWidth:1,position:`middle`,zIndex:E.line};function J(e){var t=g(e,q);return N.createElement(N.Fragment,null,N.createElement(G,{yAxisId:t.yAxisId,xAxisId:t.xAxisId,ifOverflow:t.ifOverflow,x:t.x,y:t.y,segment:t.segment}),N.createElement(K,t))}J.displayName=`ReferenceLine`;var Y=n();function X({series:e,bands:t,backpressure:n,label:r}){let s=Math.max(n,...e,1),c=(0,N.useRef)(s),[l,u]=(0,N.useState)(s);(0,N.useEffect)(()=>{if(a()){c.current=s,u(s);return}let e=c.current,t=s;if(Math.abs(t-e)<.01)return;let n=0,r=performance.now(),o=i(.56)*1e3,l=i=>{let a=Math.min(1,(i-r)/o),s=1-(1-a)**3,d=e+(t-e)*s;c.current=d,u(d),a<1&&(n=requestAnimationFrame(l))};return n=requestAnimationFrame(l),()=>cancelAnimationFrame(n)},[s]);let d=(0,N.useMemo)(()=>e.map((e,t)=>({i:t,v:e,bp:n})),[e,n]),f=(0,N.useMemo)(()=>t.map((t,n)=>{let r=Math.max(1,e.length-1);return{key:n,x1:t.from*r,x2:Math.max(t.from*r+.35,t.until*r)}}),[t,e.length]),p=Math.max(l,n,1);return(0,Y.jsx)(`div`,{className:`h-11 w-full overflow-hidden`,role:`img`,"aria-label":r,"data-depth-chart":!0,children:(0,Y.jsx)(o,{width:`100%`,height:`100%`,children:(0,Y.jsxs)(O,{data:d,margin:{top:4,right:2,bottom:2,left:2},children:[(0,Y.jsx)(D,{hide:!0,domain:[0,p],allowDataOverflow:!0}),(0,Y.jsx)(A,{hide:!0,dataKey:`i`,type:`number`,domain:[0,Math.max(0,e.length-1)]}),f.map(e=>(0,Y.jsx)(M,{x1:e.x1,x2:e.x2,y1:0,y2:p,fill:`var(--il-warn, var(--warning))`,fillOpacity:.14,ifOverflow:`extendDomain`},e.key)),(0,Y.jsx)(J,{y:n,stroke:`var(--il-faint, var(--foreground))`,strokeOpacity:.35,strokeDasharray:`3 3`,ifOverflow:`extendDomain`}),(0,Y.jsx)(`defs`,{children:(0,Y.jsxs)(`linearGradient`,{id:`il-depth-fill`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,Y.jsx)(`stop`,{offset:`0%`,stopColor:`var(--il-depth, var(--chart-1))`,stopOpacity:.28}),(0,Y.jsx)(`stop`,{offset:`100%`,stopColor:`var(--il-depth, var(--chart-1))`,stopOpacity:.04})]})}),(0,Y.jsx)(y,{type:`monotone`,dataKey:`v`,stroke:`var(--il-depth, var(--chart-1))`,strokeOpacity:.95,strokeWidth:1.85,fill:`url(#il-depth-fill)`,fillOpacity:1,isAnimationActive:!a(),animationDuration:Math.round(i(.56)*1e3),animationEasing:`linear`,dot:!1,activeDot:!1})]})})})}export{X as InflightDepthChart}; \ No newline at end of file diff --git a/internal/webui/static/assets/InflightLiveCard-cw_BuJ7y.js b/internal/webui/static/assets/InflightLiveCard-cw_BuJ7y.js deleted file mode 100644 index bceb9f4e..00000000 --- a/internal/webui/static/assets/InflightLiveCard-cw_BuJ7y.js +++ /dev/null @@ -1,104 +0,0 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/InflightDepthChart-BxVa9hs3.js","assets/shim-mfK0Rmj6.js","assets/index-C8_qeOs_.js","assets/useI18n-BSw4X3mq.js","assets/SharedElementTransition-BlCsXfb1.js","assets/overview-m01k08K8.js","assets/gsap-C3sDxib7.js","assets/index-CsQdDtGs.css","assets/AreaChart-B0YOdVBx.js","assets/XAxis-DLQkFqxC.js","assets/ReferenceArea-CiIBWWEY.js"])))=>i.map(i=>d[i]); -import{a as e,c as t,n}from"./shim-mfK0Rmj6.js";import{t as r}from"./CaretRight.es-D5fytEam.js";import{t as i}from"./Check.es-Bl43hv4j.js";import{pt as a}from"./useI18n-BSw4X3mq.js";import{n as o}from"./useToggle-HDaAPzVy.js";import{t as s}from"./CompactSwitch-DH1Gk66-.js";import{n as c,r as l,t as u}from"./gsap-C3sDxib7.js";import{Bt as d,Dt as f,Kt as p,Zt as m,b as h,x as g,y as _}from"./index-C8_qeOs_.js";import{a as v}from"./format-B6SmebW-.js";import{t as y}from"./ProviderMark-IiAZTaQS.js";var b=t(e(),1),x=new Map([[`bold`,b.createElement(b.Fragment,null,b.createElement(`path`,{d:`M204,64V168a12,12,0,0,1-24,0V93L72.49,200.49a12,12,0,0,1-17-17L163,76H88a12,12,0,0,1,0-24H192A12,12,0,0,1,204,64Z`}))],[`duotone`,b.createElement(b.Fragment,null,b.createElement(`path`,{d:`M192,64V168L88,64Z`,opacity:`0.2`}),b.createElement(`path`,{d:`M192,56H88a8,8,0,0,0-5.66,13.66L128.69,116,58.34,186.34a8,8,0,0,0,11.32,11.32L140,127.31l46.34,46.35A8,8,0,0,0,200,168V64A8,8,0,0,0,192,56Zm-8,92.69-38.34-38.34h0L107.31,72H184Z`}))],[`fill`,b.createElement(b.Fragment,null,b.createElement(`path`,{d:`M200,64V168a8,8,0,0,1-13.66,5.66L140,127.31,69.66,197.66a8,8,0,0,1-11.32-11.32L128.69,116,82.34,69.66A8,8,0,0,1,88,56H192A8,8,0,0,1,200,64Z`}))],[`light`,b.createElement(b.Fragment,null,b.createElement(`path`,{d:`M198,64V168a6,6,0,0,1-12,0V78.48L68.24,196.24a6,6,0,0,1-8.48-8.48L177.52,70H88a6,6,0,0,1,0-12H192A6,6,0,0,1,198,64Z`}))],[`regular`,b.createElement(b.Fragment,null,b.createElement(`path`,{d:`M200,64V168a8,8,0,0,1-16,0V83.31L69.66,197.66a8,8,0,0,1-11.32-11.32L172.69,72H88a8,8,0,0,1,0-16H192A8,8,0,0,1,200,64Z`}))],[`thin`,b.createElement(b.Fragment,null,b.createElement(`path`,{d:`M196,64V168a4,4,0,0,1-8,0V73.66L66.83,194.83a4,4,0,0,1-5.66-5.66L182.34,68H88a4,4,0,0,1,0-8H192A4,4,0,0,1,196,64Z`}))]]),S=new Map([[`bold`,b.createElement(b.Fragment,null,b.createElement(`path`,{d:`M128,20A108,108,0,0,0,31.85,177.23L21,209.66A20,20,0,0,0,46.34,235l32.43-10.81A108,108,0,1,0,128,20Zm0,192a84,84,0,0,1-42.06-11.27,12,12,0,0,0-6-1.62,12.1,12.1,0,0,0-3.8.62l-29.79,9.93,9.93-29.79a12,12,0,0,0-1-9.81A84,84,0,1,1,128,212Z`}))],[`duotone`,b.createElement(b.Fragment,null,b.createElement(`path`,{d:`M224,128A96,96,0,0,1,79.93,211.11h0L42.54,223.58a8,8,0,0,1-10.12-10.12l12.47-37.39h0A96,96,0,1,1,224,128Z`,opacity:`0.2`}),b.createElement(`path`,{d:`M128,24A104,104,0,0,0,36.18,176.88L24.83,210.93a16,16,0,0,0,20.24,20.24l34.05-11.35A104,104,0,1,0,128,24Zm0,192a87.87,87.87,0,0,1-44.06-11.81,8,8,0,0,0-6.54-.67L40,216,52.47,178.6a8,8,0,0,0-.66-6.54A88,88,0,1,1,128,216Z`}))],[`fill`,b.createElement(b.Fragment,null,b.createElement(`path`,{d:`M232,128A104,104,0,0,1,79.12,219.82L45.07,231.17a16,16,0,0,1-20.24-20.24l11.35-34.05A104,104,0,1,1,232,128Z`}))],[`light`,b.createElement(b.Fragment,null,b.createElement(`path`,{d:`M128,26A102,102,0,0,0,38.35,176.69L26.73,211.56a14,14,0,0,0,17.71,17.71l34.87-11.62A102,102,0,1,0,128,26Zm0,192a90,90,0,0,1-45.06-12.08,6.09,6.09,0,0,0-3-.81,6.2,6.2,0,0,0-1.9.31L40.65,217.88a2,2,0,0,1-2.53-2.53L50.58,178a6,6,0,0,0-.5-4.91A90,90,0,1,1,128,218Z`}))],[`regular`,b.createElement(b.Fragment,null,b.createElement(`path`,{d:`M128,24A104,104,0,0,0,36.18,176.88L24.83,210.93a16,16,0,0,0,20.24,20.24l34.05-11.35A104,104,0,1,0,128,24Zm0,192a87.87,87.87,0,0,1-44.06-11.81,8,8,0,0,0-6.54-.67L40,216,52.47,178.6a8,8,0,0,0-.66-6.54A88,88,0,1,1,128,216Z`}))],[`thin`,b.createElement(b.Fragment,null,b.createElement(`path`,{d:`M128,28A100,100,0,0,0,40.53,176.5l-11.9,35.69a12,12,0,0,0,15.18,15.18l35.69-11.9A100,100,0,1,0,128,28Zm0,192a92,92,0,0,1-46.07-12.35,4.05,4.05,0,0,0-2-.54,3.93,3.93,0,0,0-1.27.21L41.28,219.78a4,4,0,0,1-5.06-5.06l12.46-37.38a4,4,0,0,0-.33-3.27A92,92,0,1,1,128,220Z`}))]]),C=new Map([[`bold`,b.createElement(b.Fragment,null,b.createElement(`path`,{d:`M230.47,67.5a12,12,0,0,0-19.26-4.32L172.43,99l-12.68-2.72L157,83.57l35.79-38.78a12,12,0,0,0-4.32-19.26A76.07,76.07,0,0,0,88.41,121.64L30.92,174.18a4.68,4.68,0,0,0-.39.38,36,36,0,0,0,50.91,50.91l.38-.39,52.54-57.49A76.05,76.05,0,0,0,230.47,67.5ZM160,148a51.5,51.5,0,0,1-23.35-5.52,12,12,0,0,0-14.26,2.62L64.31,208.66a12,12,0,0,1-17-17l63.55-58.07a12,12,0,0,0,2.62-14.26A51.5,51.5,0,0,1,108,96a52.06,52.06,0,0,1,52-52h.89L135.17,71.87a12,12,0,0,0-2.91,10.65l5.66,26.35a12,12,0,0,0,9.21,9.21l26.35,5.66a12,12,0,0,0,10.65-2.91L212,95.12c0,.3,0,.59,0,.89A52.06,52.06,0,0,1,160,148Z`}))],[`duotone`,b.createElement(b.Fragment,null,b.createElement(`path`,{d:`M224,96a64,64,0,0,1-94.94,56L73,217A24,24,0,0,1,39,183L104,126.94a64,64,0,0,1,80-90.29L144,80l5.66,26.34L176,112l43.35-40A63.8,63.8,0,0,1,224,96Z`,opacity:`0.2`}),b.createElement(`path`,{d:`M226.76,69a8,8,0,0,0-12.84-2.88l-40.3,37.19-17.23-3.7-3.7-17.23,37.19-40.3A8,8,0,0,0,187,29.24,72,72,0,0,0,88,96,72.34,72.34,0,0,0,94,124.94L33.79,177c-.15.12-.29.26-.43.39a32,32,0,0,0,45.26,45.26c.13-.13.27-.28.39-.42L131.06,162A72,72,0,0,0,232,96,71.56,71.56,0,0,0,226.76,69ZM160,152a56.14,56.14,0,0,1-27.07-7,8,8,0,0,0-9.92,1.77L67.11,211.51a16,16,0,0,1-22.62-22.62L109.18,133a8,8,0,0,0,1.77-9.93,56,56,0,0,1,58.36-82.31l-31.2,33.81a8,8,0,0,0-1.94,7.1L141.83,108a8,8,0,0,0,6.14,6.14l26.35,5.66a8,8,0,0,0,7.1-1.94l33.81-31.2A56.06,56.06,0,0,1,160,152Z`}))],[`fill`,b.createElement(b.Fragment,null,b.createElement(`path`,{d:`M232,96a72,72,0,0,1-100.94,66L79,222.22c-.12.14-.26.29-.39.42a32,32,0,0,1-45.26-45.26c.14-.13.28-.27.43-.39L94,124.94a72.07,72.07,0,0,1,83.54-98.78,8,8,0,0,1,3.93,13.19L144,80l5.66,26.35L176,112l40.65-37.52a8,8,0,0,1,13.19,3.93A72.6,72.6,0,0,1,232,96Z`}))],[`light`,b.createElement(b.Fragment,null,b.createElement(`path`,{d:`M224.91,69.75a6,6,0,0,0-9.63-2.16l-41.07,37.9L154.7,101.3l-4.19-19.51,37.9-41.07a6,6,0,0,0-2.16-9.63,70,70,0,0,0-89.77,94.39l-61.39,53c-.11.09-.21.19-.32.3A30,30,0,0,0,77.2,221.23c.11-.11.21-.21.3-.32l53-61.39a70,70,0,0,0,94.39-89.77ZM160,154a58,58,0,0,1-28-7.22,6,6,0,0,0-7.45,1.33L68.57,212.88a18,18,0,0,1-25.45-25.45l64.76-55.94A6,6,0,0,0,109.2,124a58,58,0,0,1,64-84.53L139.58,75.93a6,6,0,0,0-1.45,5.33l5.65,26.35a6,6,0,0,0,4.61,4.61l26.35,5.65a6,6,0,0,0,5.33-1.45L216.49,82.8A58.06,58.06,0,0,1,160,154Z`}))],[`regular`,b.createElement(b.Fragment,null,b.createElement(`path`,{d:`M226.76,69a8,8,0,0,0-12.84-2.88l-40.3,37.19-17.23-3.7-3.7-17.23,37.19-40.3A8,8,0,0,0,187,29.24,72,72,0,0,0,88,96,72.34,72.34,0,0,0,94,124.94L33.79,177c-.15.12-.29.26-.43.39a32,32,0,0,0,45.26,45.26c.13-.13.27-.28.39-.42L131.06,162A72,72,0,0,0,232,96,71.56,71.56,0,0,0,226.76,69ZM160,152a56.14,56.14,0,0,1-27.07-7,8,8,0,0,0-9.92,1.77L67.11,211.51a16,16,0,0,1-22.62-22.62L109.18,133a8,8,0,0,0,1.77-9.93,56,56,0,0,1,58.36-82.31l-31.2,33.81a8,8,0,0,0-1.94,7.1L141.83,108a8,8,0,0,0,6.14,6.14l26.35,5.66a8,8,0,0,0,7.1-1.94l33.81-31.2A56.06,56.06,0,0,1,160,152Z`}))],[`thin`,b.createElement(b.Fragment,null,b.createElement(`path`,{d:`M223.05,70.5a4,4,0,0,0-6.42-1.44l-41.82,38.6L153,103l-4.68-21.79,38.6-41.82a4,4,0,0,0-1.44-6.43A68,68,0,0,0,98.94,126L36.4,180l-.21.2a28,28,0,0,0,39.6,39.6l.2-.21,54-62.54A68,68,0,0,0,228,96,67.51,67.51,0,0,0,223.05,70.5ZM160,156a60,60,0,0,1-29-7.47,4,4,0,0,0-5,.89L70,214.25A20,20,0,0,1,41.75,186l64.82-56a4,4,0,0,0,.89-5,60,60,0,0,1,69.46-86.59L141.05,77.29a4,4,0,0,0-1,3.55l5.66,26.35a4,4,0,0,0,3.07,3.07l26.35,5.66a4,4,0,0,0,3.55-1l38.87-35.87A60.05,60.05,0,0,1,160,156Z`}))]]),w=b.forwardRef((e,t)=>b.createElement(a,{ref:t,...e,weights:x}));w.displayName=`ArrowUpRightIcon`;var ee=w,T=b.forwardRef((e,t)=>b.createElement(a,{ref:t,...e,weights:S}));T.displayName=`ChatCircleIcon`;var te=T,E=b.forwardRef((e,t)=>b.createElement(a,{ref:t,...e,weights:C}));E.displayName=`WrenchIcon`;var D=E,O={generatedAt:0,backpressure:6,throughputPerMin:42,waitP95Ms:2800,totals:{done:186,failed:4},workers:[{id:`acc-wb-a1`,name:`WorkBuddy`,provider:`workbuddy`,busy:!0,progress:.72,jobId:`j1`,concurrency:4,inFlight:3,cells:[{id:`j1`,name:`glm-5.2`,startedAtMs:0,elapsedMs:11200},{id:`j1b`,name:`kimi-k2.7-code`,startedAtMs:0,elapsedMs:8400},{id:`j1c`,name:`qwen3-embedding`,startedAtMs:0,elapsedMs:4100}]},{id:`acc-wb-a2`,name:`Zhipu`,provider:`zhipu`,busy:!0,progress:.41,jobId:`j2`,rateLimited:!0,concurrency:2,inFlight:1,cells:[{id:`j2`,name:`deepseek-v4-pro`,startedAtMs:0,elapsedMs:9400}]},{id:`acc-qd-b1`,name:`Qoder`,provider:`qoder`,busy:!0,progress:.88,jobId:`j3`,concurrency:1,inFlight:1,cells:[{id:`j3`,name:`glm-5.3`,startedAtMs:0,elapsedMs:6200}]},{id:`acc-qd-b2`,name:`Kimi`,provider:`kimi`,busy:!1,progress:0,concurrency:4,inFlight:0,cells:[]},{id:`acc-trae-c1`,name:`Trae`,provider:`trae`,busy:!0,progress:.23,jobId:`j4`,concurrency:3,inFlight:2,cells:[{id:`j4`,name:`qwen3-coder`,startedAtMs:0,elapsedMs:3100},{id:`j4b`,name:`glm-5.3-flash`,startedAtMs:0,elapsedMs:1800}]},{id:`acc-codex-d1`,name:`Codex`,provider:`codex`,busy:!1,progress:0,rateLimited:!0,concurrency:2,inFlight:0,cells:[]}],jobs:[{id:`j1`,name:`glm-5.2`,kind:`chat`,status:`running`,accountId:`acc-wb-a1`,progress:.72,elapsedMs:11200,sticky:!0},{id:`j1b`,name:`kimi-k2.7-code`,kind:`chat`,status:`running`,accountId:`acc-wb-a1`,progress:.55,elapsedMs:8400},{id:`j1c`,name:`qwen3-embedding`,kind:`embed`,status:`running`,accountId:`acc-wb-a1`,progress:.3,elapsedMs:4100},{id:`j2`,name:`deepseek-v4-pro`,kind:`embed`,status:`running`,accountId:`acc-wb-a2`,progress:.41,elapsedMs:9400},{id:`j3`,name:`glm-5.3`,kind:`chat`,status:`running`,accountId:`acc-qd-b1`,progress:.88,elapsedMs:6200},{id:`j4`,name:`qwen3-coder`,kind:`tools`,status:`running`,accountId:`acc-trae-c1`,progress:.23,elapsedMs:3100},{id:`j4b`,name:`glm-5.3-flash`,kind:`chat`,status:`running`,accountId:`acc-trae-c1`,progress:.15,elapsedMs:1800},{id:`j5`,name:`deepseek-v4.1-flash`,kind:`chat`,status:`queued`,progress:0,elapsedMs:7200},{id:`j6`,name:`glm-5.2`,kind:`chat`,status:`queued`,progress:0,elapsedMs:5100},{id:`j7`,name:`kimi-k2.7-code`,kind:`chat`,status:`queued`,progress:0,elapsedMs:2800,sticky:!0,priority:`high`},{id:`j8`,name:`qwen3-embedding`,kind:`embed`,status:`queued`,progress:0,elapsedMs:1400},{id:`j9`,name:`qwen3-coder`,kind:`tools`,status:`queued`,progress:0,elapsedMs:900},{id:`j10`,name:`glm-5.3-flash`,kind:`chat`,status:`queued`,progress:0,elapsedMs:600},{id:`j11`,name:`deepseek-v4-pro`,kind:`embed`,status:`queued`,progress:0,elapsedMs:400},{id:`j12`,name:`glm-5.3`,kind:`chat`,status:`queued`,progress:0,elapsedMs:200,priority:`high`}],rateLimits:[{id:`rl1`,label:`Zhipu 限流`,remainingMs:97e3,from:.55,until:.72},{id:`rl2`,label:`Codex 冷却`,remainingMs:41e3,from:.82,until:1}],depthSeries:[1,1,2,2,3,4,5,6,7,6,5,4,3,4,5,6,5,4,3,3,2,3,4,3]},k=[{name:`glm-5.3`,kind:`chat`},{name:`qwen3-embedding`,kind:`embed`},{name:`qwen3-coder`,kind:`tools`},{name:`glm-5.3-flash`,kind:`chat`,sticky:!0},{name:`deepseek-v4.1-flash`,kind:`chat`},{name:`deepseek-v4-pro`,kind:`embed`},{name:`kimi-k2.7-code`,kind:`chat`}],A=100;function j(e=O){return{...e,workers:e.workers.map(e=>({...e,cells:e.cells?.map(e=>({...e}))})),jobs:e.jobs.map(e=>({...e})),rateLimits:e.rateLimits.map(e=>({...e})),depthSeries:[...e.depthSeries],totals:{...e.totals},completions:void 0}}function M(){return j()}function N(){let e=Math.max(1,O.depthSeries.length);return{generatedAt:Date.now(),backpressure:O.backpressure,throughputPerMin:0,waitP95Ms:0,totals:{done:0,failed:0},workers:[],jobs:[],rateLimits:[],depthSeries:Array.from({length:e},()=>0)}}function P(e){return e.jobs.length===0&&e.workers.length===0&&e.throughputPerMin===0&&(e.totals?.done??0)===0&&(e.totals?.failed??0)===0}function ne(e,t){let n=Math.max(16,Math.min(500,t)),r=j(e);r.generatedAt=(e.generatedAt||0)+n,r.rateLimits=r.rateLimits.map(e=>({...e,remainingMs:Math.max(0,e.remainingMs-n)})).filter(e=>e.remainingMs>0);for(let e of r.workers)e.id===`acc-wb-a2`?e.rateLimited=r.rateLimits.some(e=>e.label.includes(`Zhipu`)):e.id===`acc-codex-d1`&&(e.rateLimited=r.rateLimits.some(e=>e.label.includes(`Codex`)));let i=new Map(r.jobs.map(e=>[e.id,e]));for(let e of r.workers){if(e.cells?.length)for(let t of e.cells)t.elapsedMs+=n;if(e.rateLimited)continue;let t=0;for(let r of e.cells??[]){let e=i.get(r.id);if(!e||e.status!==`running`)continue;e.elapsedMs=r.elapsedMs;let a=.045+r.id.charCodeAt(r.id.length-1)%5*.008;e.progress=Math.min(1,e.progress+n/1e3*a),t=Math.max(t,e.progress)}(e.cells?.length??0)>0&&(e.progress=t,e.busy=!0,e.jobId=e.cells[0].id,e.inFlight=e.cells.length)}let a=[];for(let e of r.workers){if(e.rateLimited||!e.cells?.length)continue;let t=e.cells.find(e=>{let t=i.get(e.id);return!!(t&&t.status===`running`&&t.progress>=.995)});if(!t)continue;let n=(t.id.charCodeAt(1)+Math.floor(r.generatedAt/1e3))%9!=0;a.push({jobId:t.id,workerId:e.id,ok:n})}for(let e of a){let t=i.get(e.jobId),n=r.workers.find(t=>t.id===e.workerId);if(!t||!n)continue;if(n.cells=(n.cells??[]).filter(t=>t.id!==e.jobId),n.inFlight=n.cells.length,n.jobId=n.cells[0]?.id,n.busy=n.cells.length>0,n.progress=n.busy?Math.max(.04,...n.cells.map(e=>i.get(e.id)?.progress??.04)):0,t.accountId=void 0,e.ok){t.status=`done`,t.progress=1,r.totals.done+=1;continue}let a=(t.attempt??1)+1;if(a<=3&&(e.jobId.charCodeAt(0)+Math.floor(r.generatedAt/900))%2==0){t.status=`queued`,t.progress=0,t.elapsedMs=80,t.attempt=a,t.priority=`high`;continue}t.status=`failed`,t.progress=1,r.totals.failed+=1}let o=[];for(let e of a){let t=i.get(e.jobId);t&&(t.status===`done`||t.status===`failed`)&&o.push({id:t.id,name:t.name,kind:t.kind,ok:t.status===`done`})}r.completions=o.length>0?o:void 0,r.jobs=r.jobs.filter(e=>e.status===`queued`||e.status===`running`);for(let e of r.jobs)e.status===`queued`&&(e.elapsedMs+=n);let s=r.jobs.filter(e=>e.status===`queued`);for(let e of r.workers){if(e.rateLimited)continue;let t=F(e.concurrency??1);for(e.cells=e.cells??[];e.cells.lengthe.id!==n.id),r].slice(0,t),e.busy=!0,e.progress=Math.max(e.progress,.04),e.jobId=e.cells[0]?.id,e.inFlight=e.cells.length}}if(r.jobs.filter(e=>e.status===`queued`).length<10&&r.generatedAt%1600e.status===`running`),t=r.jobs.filter(e=>e.status===`queued`),n=t.filter(e=>e.priority===`high`&&e.elapsedMs>=400),i=t.filter(e=>!(e.priority===`high`&&e.elapsedMs>=400)),a=n;r.jobs=[...e,...a,...i]}let c=r.workers.filter(e=>e.busy).length,l=r.jobs.filter(e=>e.status===`queued`).length,u=Math.max(1,l+Math.max(0,c-2)),d=r.depthSeries.slice(1);return d.push(u),r.depthSeries=d,r.throughputPerMin=Math.max(28,Math.min(58,r.throughputPerMin+(A%3-1))),r.waitP95Ms=Math.max(900,Math.min(5200,r.waitP95Ms+(l>4?40:-20))),r}function F(e){return e==null||!Number.isFinite(e)?1:Math.max(1,Math.min(16,Math.floor(e)))}function I(e){let t=e.jobs.filter(e=>e.status===`running`).length,n=e.jobs.filter(e=>e.status===`queued`).length,r=e.workers.filter(e=>e.busy).length,i=0,a=0;for(let t of e.workers){let e=F(t.concurrency??1);i+=e;let n=t.inFlight==null?+!!t.busy:Math.max(0,Math.min(e,Math.floor(t.inFlight)));a+=n}let o=e.depthSeries[e.depthSeries.length-1]??n;return{running:t,waiting:n,busyWorkers:r,occupiedSlots:a,workerSlots:i,rateLimitActive:e.rateLimits.length,depthNow:o}}function re(e,t){let n=Date.now(),r=new Map(e.jobs.map(e=>[e.id,e])),i=Math.max(1,O.depthSeries.length),a=t.rate_limits.map((e,t)=>{let n=Math.min(.86,t*.22%.86);return{id:e.id,label:e.label,remainingMs:Math.max(0,e.remaining_ms),from:n,until:Math.min(1,n+.14)}}),o=(t.queue??[]).map(e=>{let t=(e.id||``).trim(),i=r.get(t),a,o=e.started_at?.trim();if(o){let e=Date.parse(o);Number.isNaN(e)||(a=e)}return a==null&&i?.startedAtMs!=null&&(a=i.startedAtMs),a??=n,{id:t,name:(e.name||``).trim()||t,kind:`chat`,status:`queued`,accountId:(e.account_id||``).trim()||void 0,progress:0,startedAtMs:a,elapsedMs:Math.max(0,n-a)}}),s=new Set(o.map(e=>e.id)),c=new Map;for(let e of o){let t=(e.accountId||``).trim();t&&e.name&&!c.has(t)&&c.set(t,e.name)}let l=new Map;for(let e of t.occupancy??[]){let t=(e.account_id||``).trim(),n=(e.id||``).trim();if(!t||!n)continue;let r=l.get(t)??[];r.push(e),l.set(t,r)}let u=new Map;for(let t of e.workers)t.cells?.length&&u.set(t.id,t.cells);let d=(e,t,n)=>{let r=e?.trim();if(r){let e=Date.parse(r);if(!Number.isNaN(e))return e}return t??n},f=t.workers.map(e=>{let i=F(e.max_inflight??4),a=e.in_flight!=null&&Number.isFinite(e.in_flight)?Math.max(0,Math.floor(e.in_flight)):+!!e.busy,o=Math.min(i,a),f=u.get(e.id)??[],p=new Map(f.map(e=>[e.id,e])),m=l.get(e.id)??[],h=[];for(let e of m){if(h.length>=o)break;let t=(e.id||``).trim();if(!t)continue;let i=p.get(t),a=r.get(t),c=d(e.started_at,i?.startedAtMs??a?.startedAtMs,n),l=(e.name||``).trim()||t;h.push({id:t,name:l,startedAtMs:c,elapsedMs:Math.max(0,n-c),pendingInbound:s.has(t)})}let g=t.workers.find(t=>t.id===e.id),_=d(g?.started_at,void 0,n);for(;h.length0;return{id:e.id,name:e.name,provider:e.provider,busy:v,progress:v?Math.max(.04,Math.min(1,e.progress||0)):0,rateLimited:e.rate_limited,jobId:h[0]?.id,concurrency:i,inFlight:o,cells:h}}),p=[];for(let e of f)for(let t of e.cells??[]){if(s.has(t.id))continue;let n=r.get(t.id);p.push({id:t.id,name:t.name,kind:n?.kind??`chat`,status:`running`,accountId:e.id,progress:e.progress,startedAtMs:t.startedAtMs,elapsedMs:t.elapsedMs})}let m=[...p,...o],h=e.waitP95Ms===0,g=h?e.depthSeries.slice(1):Array.from({length:Math.max(0,i-1)},()=>0);for(g.push(Math.max(0,t.in_flight));g.lengthe.id)),b=[];for(let n of e.jobs){if(n.status!==`running`||y.has(n.id))continue;let e=(n.accountId||n.id.replace(/^live-/,``)).trim(),r=!0;if(_.has(n.id))r=_.get(n.id),_.delete(n.id);else{let n=v.get(e);if(n&&n.length>0)r=n.shift();else{let n=t.workers.find(t=>t.id===e);n?.last_error_kind&&n.last_error_kind.trim()!==``&&(r=!1)}}b.push({id:n.id,name:n.name,kind:n.kind,ok:r})}let x=0,S=0;if(h){x=e.totals.done,S=e.totals.failed;let n=t.recent_completions??[];if(n.length>0)for(let e of n)(e.status||``).trim()===`ok`?x+=1:S+=1;else for(let e of b)e.ok?x+=1:S+=1}return{generatedAt:n,backpressure:e.backpressure,throughputPerMin:Math.max(0,t.rpm),waitP95Ms:0,totals:{done:x,failed:S},workers:f,rateLimits:a,jobs:m,depthSeries:g.slice(-i),completions:b.length>0?b:void 0}}var L=n();function R(e){let t=Array.from(e),n=[],r=0,i=0;for(let e=t.length-1;e>=0;e--){let a=t[e];a>=`0`&&a<=`9`?n.unshift({key:`d${r++}`,digit:a.charCodeAt(0)-48}):n.unshift({key:`s${i++}`,char:a})}return n}var z=e=>(e%10+10)%10,B=e=>1-(1-e)**4,V=(e,t)=>{e.style.transform=`translateY(${-z(t)/11*100}%)`};function H({value:e,kind:t=`int`,duration:n=900,className:r}){let i=(0,b.useMemo)(()=>v(e,t),[e,t]),a=(0,b.useMemo)(()=>R(i),[i]),o=(0,b.useRef)(null),s=(0,b.useRef)(new Map),c=(0,b.useRef)(new Map),l=(0,b.useRef)(0),u=(0,b.useRef)(!0),d=(0,b.useRef)(!1),f=(0,b.useRef)(new Set),p=(0,b.useRef)(new Set),m=new Set(a.filter(e=>`digit`in e).map(e=>e.key));for(let e of m)d.current&&!p.current.has(e)&&f.current.add(e);for(let e of f.current)m.has(e)||f.current.delete(e);return p.current=m,(0,b.useEffect)(()=>{d.current=!0},[]),(0,b.useEffect)(()=>{e!==l.current&&(u.current=e>l.current),l.current=e;let t=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,r=new Set;for(let e of a){if(!(`digit`in e))continue;r.add(e.key);let n=s.current.get(e.key)??{pos:0,from:0,to:0},i=u.current?z(e.digit-n.pos):-z(n.pos-e.digit);n.from=n.pos,n.to=n.pos+i,t&&(n.pos=n.from=n.to),s.current.set(e.key,n)}for(let e of s.current.keys())r.has(e)||s.current.delete(e);let i=()=>{for(let[e,t]of s.current){let n=c.current.get(e);n&&V(n,t.pos)}};if(t)return i();let o=0,d=performance.now(),f=e=>{let t=Math.min(1,(e-d)/n),r=B(t);for(let e of s.current.values())e.pos=e.from+(e.to-e.from)*r;i(),t<1&&(o=requestAnimationFrame(f))};return o=requestAnimationFrame(f),()=>cancelAnimationFrame(o)},[a,e,n]),(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`style`,{href:`ui-number-ticker`,precedence:`default`,children:U}),(0,L.jsxs)(`span`,{ref:o,className:[`ui-nt`,r].filter(Boolean).join(` `),"aria-live":`polite`,children:[(0,L.jsx)(`span`,{className:`ui-nt__sr`,children:i}),(0,L.jsx)(`span`,{className:`ui-nt__track`,"aria-hidden":`true`,children:a.map(e=>`digit`in e?(0,L.jsx)(`span`,{className:`ui-nt__col`,"data-enter":f.current.has(e.key)||void 0,children:(0,L.jsx)(`span`,{className:`ui-nt__stack`,ref:t=>{if(t)return c.current.set(e.key,t),V(t,s.current.get(e.key)?.pos??0),()=>{c.current.get(e.key)===t&&c.current.delete(e.key)}},children:[0,1,2,3,4,5,6,7,8,9,0].map((e,t)=>(0,L.jsx)(`span`,{className:`ui-nt__cell`,children:e},t))})},e.key):(0,L.jsx)(`span`,{className:`ui-nt__static`,children:e.char},e.key))})]})]})}var U=` -.ui-nt { - --ui-nt-lh: 1.15em; - --ui-nt-ease: cubic-bezier(0.22, 1, 0.36, 1); - position: relative; - display: inline-flex; - line-height: var(--ui-nt-lh); - font-variant-numeric: tabular-nums; - white-space: nowrap; -} -.ui-nt__sr { - position: absolute; - width: 1px; - height: 1px; - margin: -1px; - padding: 0; - overflow: hidden; - clip: rect(0 0 0 0); - white-space: nowrap; - border: 0; -} -.ui-nt__track { - display: inline-flex; - align-items: flex-start; - height: var(--ui-nt-lh); - line-height: var(--ui-nt-lh); -} -.ui-nt__col { - display: inline-block; - height: var(--ui-nt-lh); - overflow: hidden; - /* Soft top and bottom edges while digits pass through */ - -webkit-mask-image: linear-gradient(transparent, #000 14%, #000 86%, transparent); - mask-image: linear-gradient(transparent, #000 14%, #000 86%, transparent); -} -.ui-nt__col[data-enter] { animation: ui-nt-in 450ms var(--ui-nt-ease) both; } -.ui-nt__stack { - display: flex; - flex-direction: column; - will-change: transform; -} -.ui-nt__cell, -.ui-nt__static { - display: block; - height: var(--ui-nt-lh); - text-align: center; -} -.ui-nt__static { white-space: pre; } - -@keyframes ui-nt-in { - from { transform: translateY(-35%); } -} -@media (prefers-reduced-motion: reduce) { - .ui-nt__col[data-enter] { animation: none; } -} - -/* Dark mode: follows a .dark class or data-theme="dark" on any ancestor, e.g. . - The ticker inherits its color, so nothing needs to change here. */ -:where(.dark, [data-theme="dark"]) .ui-nt { - --ui-nt-lh: 1.15em; -} -`,ie=(0,b.lazy)(()=>m(()=>import(`./InflightDepthChart-BxVa9hs3.js`).then(e=>({default:e.InflightDepthChart})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10]))),W=`cli2api_inflight_mock_demo`;function ae(){try{return localStorage.getItem(W)===`1`}catch{return!1}}function oe(e){try{localStorage.setItem(W,e?`1`:`0`)}catch{}}l.registerPlugin(c,u);var G=c.get(`inflightQueue`)||c.create(`inflightQueue`,`0.22, 1, 0.36, 1`),K=c.get(`inflightSlide`)||c.create(`inflightSlide`,`0.16, 1, 0.3, 1`),q=6,se=4,ce=.88,le=.56,ue=140;function de(e){let t=Math.max(0,e/1e3);if(t>=60){let e=Math.floor(t/60),n=Math.floor(t%60);return`${e}m ${String(n).padStart(2,`0`)}s`}return t>=10?`${t.toFixed(0)}s`:`${t.toFixed(1)}s`}function fe(e,t){return e?e.startedAtMs==null?Math.max(0,e.elapsedMs):Math.max(0,t-e.startedAtMs):0}function pe(e){switch(e){case`chat`:return`bg-[color-mix(in_oklab,var(--chart-1)_55%,var(--surface))]`;case`embed`:return`bg-[color-mix(in_oklab,var(--chart-6)_55%,var(--surface))]`;case`tools`:return`bg-[color-mix(in_oklab,var(--chart-5)_50%,var(--surface))]`;default:return`bg-foreground/25`}}function me(e){return(0,L.jsx)(`span`,{className:`grid size-7 shrink-0 place-items-center rounded-lg ${e===`embed`?`bg-[color-mix(in_oklab,var(--chart-6)_16%,var(--surface))] text-[color-mix(in_oklab,var(--chart-6)_70%,var(--foreground))]`:e===`tools`?`bg-[color-mix(in_oklab,var(--chart-5)_14%,var(--surface))] text-[color-mix(in_oklab,var(--chart-5)_68%,var(--foreground))]`:e===`chat`?`bg-[color-mix(in_oklab,var(--chart-1)_16%,var(--surface))] text-[color-mix(in_oklab,var(--chart-1)_70%,var(--foreground))]`:`bg-surface-secondary text-muted`}`,"aria-hidden":!0,children:e===`embed`?(0,L.jsx)(d,{size:15}):e===`tools`?(0,L.jsx)(D,{size:15}):(0,L.jsx)(te,{size:15})})}function he(e){switch(e){case`chat`:return`border border-[color-mix(in_oklab,var(--chart-1)_16%,transparent)] bg-[color-mix(in_oklab,var(--chart-1)_8%,var(--surface))] text-foreground/75`;case`embed`:return`border border-[color-mix(in_oklab,var(--chart-6)_16%,transparent)] bg-[color-mix(in_oklab,var(--chart-6)_8%,var(--surface))] text-foreground/75`;case`tools`:return`border border-[color-mix(in_oklab,var(--chart-5)_14%,transparent)] bg-[color-mix(in_oklab,var(--chart-5)_7%,var(--surface))] text-foreground/72`;default:return`border border-foreground/8 bg-[color-mix(in_oklab,var(--foreground)_3%,var(--surface))] text-foreground/68`}}function ge({slot:e,jobById:t,clockMs:n,idleLabel:r,landedCellIds:i}){let a=F(e.concurrency??1),o=e.inFlight==null?+!!e.busy:Math.max(0,Math.floor(e.inFlight)),s=Math.min(a,o),c=s>0,l=(e.cells??[]).slice(0,s),u=l.filter(e=>!e.pendingInbound&&i.has(e.id)).map(e=>`${e.name} ${de(Math.max(0,n-e.startedAtMs))}`),d=`${e.name} · ${s}/${a}${u.length?` · ${u.join(`, `)}`:``}`;return(0,L.jsxs)(`div`,{"data-slot":!0,"data-slot-id":e.id,"data-slot-job":e.jobId??``,"data-slot-busy":c?``:void 0,"data-slot-concurrency":a,"data-slot-inflight":s,className:`relative flex min-w-0 items-center gap-2 overflow-hidden rounded-xl px-2.5 py-2 ${c?`border border-foreground/12 bg-[var(--il-busy-bg)]`:`border border-foreground/8 bg-[var(--il-item-bg)]`}`,title:d,children:[(0,L.jsxs)(`span`,{className:`relative z-[1] flex min-w-0 w-[5.5rem] shrink-0 items-center gap-1.5 ${c?`text-foreground/85`:`text-muted opacity-55`}`,title:`${e.name} · ${e.provider}`,children:[(0,L.jsx)(`span`,{className:`grid size-5 shrink-0 place-items-center ${c?``:`opacity-70`}`,"aria-hidden":!0,children:(0,L.jsx)(y,{provider:e.provider,size:18})}),(0,L.jsx)(`span`,{className:`mono min-w-0 truncate text-caption leading-none ${c?`font-medium`:``}`,children:e.name})]}),(0,L.jsx)(`div`,{className:`relative z-[1] flex min-h-[2rem] min-w-0 flex-1 gap-0.5`,role:`img`,"aria-label":`${s}/${a}`,children:Array.from({length:a},(e,a)=>{let o=l[a],s=!!o,c=s&&!o.pendingInbound&&i.has(o.id),u=c?t.get(o.id):void 0,d=c?Math.max(0,n-o.startedAtMs):0,f=o?.name||r;return(0,L.jsx)(`div`,{"data-slot-cell":``,"data-slot-fill":s?``:void 0,"data-cell-id":o?.id??``,"data-cell-index":a,"data-cell-pending":s&&!c?``:void 0,className:`relative flex min-w-0 flex-1 flex-col justify-center overflow-hidden rounded-[2px] px-1 ${c?`border border-foreground/14 bg-[var(--il-busy-fill)] text-foreground/85`:`bg-[var(--il-track)] opacity-55`}`,children:c?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-y-0 w-[62%] bg-gradient-to-r from-transparent via-[color-mix(in_oklab,var(--foreground)_9%,transparent)] to-transparent motion-safe:animate-[inflight-shimmer_1.35s_linear_infinite]`}),(0,L.jsxs)(`span`,{className:`relative z-[1] flex min-w-0 items-center gap-1 truncate text-caption font-medium leading-tight`,children:[u?(0,L.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-[2px] ${pe(u.kind)}`,"aria-hidden":!0}):null,(0,L.jsx)(`span`,{className:`truncate`,"data-slot-job-pill":``,children:f})]}),(0,L.jsx)(`span`,{className:`relative z-[1] mono truncate text-[9px] leading-tight tabular text-foreground/70`,children:de(d)})]}):(0,L.jsx)(`span`,{className:`relative z-[1] mono text-center text-[9px] text-muted/50`,children:`—`})},o?.id??`empty-${a}`)})})]})}function _e({t:e,snapshot:t,live:n=null,expanded:a,onExpandedChange:c,defaultExpanded:u=!1,forceMockDemo:d=!1,mockPace:m=1,bare:v=!1}){let y=t!==void 0,[x,S]=(0,b.useState)(u),C=a??x,w=e=>{c?.(e),a===void 0&&S(e)},[T,te]=(0,b.useState)(()=>d||ae()),E=e=>{te(e),d||oe(e)},[D,O]=(0,b.useState)(()=>j(t??N())),[k,A]=(0,b.useState)(!1),[F,R]=(0,b.useState)(null),[z,B]=(0,b.useState)(()=>Date.now()),[V,H]=(0,b.useState)(()=>new Set),U=(0,b.useRef)(new Map),W=e=>{let t=(e||``).trim();if(!t)return;let n=U.current.get(t);n&&(clearTimeout(n),U.current.delete(t)),H(e=>{if(e.has(t))return e;let n=new Set(e);return n.add(t),n})},_e=e=>{let t=(e||``).trim();if(!t)return;let n=U.current.get(t);n&&clearTimeout(n),U.current.set(t,setTimeout(()=>{U.current.delete(t),W(t)},ue))},Y=y?t:D,X=(0,b.useMemo)(()=>I(Y),[Y]),ye=(0,b.useRef)(null),Z=(0,b.useRef)(!1),be=(0,b.useRef)(Y),Q=(0,b.useRef)({wait:{},slot:{},outcome:{}}),xe=(0,b.useMemo)(()=>new Map(Y.jobs.map(e=>[e.id,e])),[Y.jobs]),Se=Y.jobs.filter(e=>e.status===`queued`),Ce=Se.slice(0,q),we=Se.slice(q),Te=(0,b.useMemo)(()=>{let e=Y.workers.filter(e=>e.busy),t=Y.workers.filter(e=>!e.busy),n=[],r=new Set;for(let i of[...e,...t])if(!r.has(i.id)&&(r.add(i.id),n.push(i),n.length>=se))break;return n},[Y.workers]),Ee=X.waiting>=Y.backpressure,$=(0,b.useRef)(!1);(0,b.useLayoutEffect)(()=>{if(y){O(j(t)),A(!1),R(null),$.current=!1;return}if(!C){A(!1),$.current=!1;return}if(n!==null){A(!1),R(n.sticky),B(Date.now()),$.current||(Z.current=!1),O(e=>{let t=$.current?e:{...j(e),waitP95Ms:1,totals:{done:0,failed:0}};return $.current=!0,re(t,n)});return}R(null),$.current=!1,Z.current=!1,T?(A(!0),O(e=>P(e)?j(M()):e)):(A(!1),O(j(N())))},[y,t,C,n,T]),(0,b.useEffect)(()=>{if(y||!C||!k||!T||n!==null||g())return;let e=0,t=performance.now(),r=!0,i=n=>{if(!r)return;let a=n-t;if(!document.hidden&&a>=260){t=n;let e=Number.isFinite(m)?Math.min(1,Math.max(.2,m??1)):1;O(t=>ne(t,a*e))}e=requestAnimationFrame(i)};return e=requestAnimationFrame(i),()=>{r=!1,cancelAnimationFrame(e)}},[y,C,k,T,n,m]),(0,b.useEffect)(()=>{if(!C)return;if(g()){B(Date.now());return}let e=0,t=0,n=!0,r=i=>{n&&(!document.hidden&&i-t>=150&&(t=i,B(Date.now())),e=requestAnimationFrame(r))};return B(Date.now()),e=requestAnimationFrame(r),()=>{n=!1,cancelAnimationFrame(e)}},[C]),(0,b.useEffect)(()=>{C||(Z.current=!1)},[C]),(0,b.useEffect)(()=>{if(!C){for(let e of U.current.values())clearTimeout(e);U.current.clear(),H(new Set)}},[C]),(0,b.useEffect)(()=>()=>{for(let e of U.current.values())clearTimeout(e);U.current.clear()},[]),(0,b.useLayoutEffect)(()=>{let e=ye.current,t=be.current;be.current=Y;let r=()=>{if(!e)return;let t={};e.querySelectorAll(`[data-wait-id]`).forEach(e=>{let n=e.getAttribute(`data-wait-id`);n&&(t[n]=e.getBoundingClientRect())});let n={};e.querySelectorAll(`[data-slot-id]`).forEach(e=>{let t=e.getAttribute(`data-slot-id`);t&&(n[t]=e.getBoundingClientRect())}),e.querySelectorAll(`[data-cell-id]`).forEach(e=>{let t=e.getAttribute(`data-cell-id`);t&&(n[`cell:${t}`]=e.getBoundingClientRect())}),Q.current={wait:t,slot:n,outcome:{ok:e.querySelector(`[data-outcome="ok"]`)?.getBoundingClientRect(),danger:e.querySelector(`[data-outcome="danger"]`)?.getBoundingClientRect()}}},i=e=>{let n=new Set(t.jobs.filter(e=>e.status===`queued`).map(e=>e.id));H(t=>{let r=new Set,i=new Set;for(let a of Y.workers)for(let o of a.cells??[]){let a=o.id;if(r.add(a),!o.pendingInbound){if(t.has(a)){i.add(a);continue}if(e===`all`){i.add(a);continue}Y.jobs.some(e=>e.id===a&&e.status===`queued`)||n.has(a)||i.add(a)}}let a=i.size===t.size;if(a){for(let e of i)if(!t.has(e)){a=!1;break}}if(a){for(let e of t)if(!r.has(e)){a=!1;break}}return a?t:i})};if(!e||g()||!Z.current){r(),i(`all`),C&&e&&!Z.current&&!g()&&(y||$.current||n===null&&T&&k||n===null&&!T&&P(Y)?(Z.current=!0,l.killTweensOf(e),l.fromTo(e,{opacity:0,y:6},{opacity:1,y:0,duration:h(.22),ease:_.out,clearProps:`opacity,transform`,force3D:!0})):l.set(e,{opacity:0}));return}if(t===Y){r(),i(`stable`);return}i(`stable`);let a=new Map(t.jobs.map(e=>[e.id,e])),o=new Map(Y.jobs.map(e=>[e.id,e])),s=new Map;for(let e of t.workers){e.jobId&&s.set(e.jobId,e.id);for(let t of e.cells??[])s.set(t.id,e.id)}let c=new Map;for(let e of Y.workers){e.jobId&&c.set(e.jobId,e.id);for(let t of e.cells??[])c.set(t.id,e.id)}let u=(e,t,n,r,i,a,o,s=0)=>{let c=e instanceof HTMLElement?e.getBoundingClientRect():e,u=t instanceof HTMLElement?t.getBoundingClientRect():t;if(!c||!u||c.width<2||u.width<2){o?.();return}let d=r===`chat`?`var(--chart-1)`:r===`embed`?`var(--chart-6)`:r===`tools`?`var(--chart-5)`:`var(--foreground)`,f=i===`ok`?`color-mix(in oklab, var(--success) 24%, var(--surface))`:i===`danger`?`color-mix(in oklab, var(--danger) 22%, var(--surface))`:i===`retry`?`color-mix(in oklab, var(--warning) 16%, var(--surface))`:r===`chat`?`color-mix(in oklab, var(--chart-1) 32%, var(--surface))`:r===`embed`?`color-mix(in oklab, var(--chart-6) 32%, var(--surface))`:r===`tools`?`color-mix(in oklab, var(--chart-5) 26%, var(--surface))`:`var(--surface)`,p=i===`ok`?`var(--success)`:i===`danger`?`var(--danger)`:i===`retry`?`var(--warning)`:`var(--foreground)`,m=i===`ok`?`var(--success)`:i===`danger`?`var(--danger)`:i===`retry`?`var(--warning)`:d,g=d,_=`inset 0 1px 0 var(--surface-rim), inset 0 0 0 1px var(--surface-edge), var(--surface-contact), 0 0 0 1px color-mix(in oklab, ${m} 28%, transparent), 0 6px 18px color-mix(in oklab, ${m} 36%, transparent), 0 12px 32px color-mix(in oklab, var(--foreground) 16%, transparent)`,v=`inset 0 1px 0 var(--surface-rim), 0 0 14px color-mix(in oklab, ${m} 48%, transparent), 0 0 28px color-mix(in oklab, ${m} 28%, transparent)`,y=i===`run`,b=y?Math.max(c.width,72):Math.max(c.width,88),x=y?Math.max(c.height,22):Math.max(c.height,26),S=y?Math.max(u.width,40):void 0,C=y?Math.max(u.height,22):void 0,w=S??b*.92,ee=C??x,T=u.left+Math.max(0,(u.width-w)/2),te=u.top+Math.max(0,(u.height-ee)/2),E=i===`ok`||i===`danger`?.86:1,D=c.left+(T-c.left)*E,O=c.top+(te-c.top)*E,k=h(y?ce:.72),A=h(y?.12:.16),j=h(y?.18:.14),M=h(Math.max(0,s)),N=e=>{let t=document.createElement(`div`);t.setAttribute(`aria-hidden`,`true`),Object.assign(t.style,{position:`fixed`,left:`${c.left}px`,top:`${c.top}px`,width:`${b}px`,height:`${x}px`,zIndex:e.asTrail?`78`:`80`,pointerEvents:`none`,display:`flex`,alignItems:`center`,gap:`6px`,padding:`0 8px`,borderRadius:`8px`,fontSize:`11px`,fontWeight:`500`,lineHeight:`1`,color:p,background:f,boxShadow:e.asTrail?v:_,whiteSpace:`nowrap`,overflow:`hidden`,textOverflow:`ellipsis`,opacity:String(e.opacity),willChange:`transform, left, top, opacity, filter`,transform:e.asTrail?`scaleX(1.12)`:`none`,filter:e.asTrail?`blur(0.9px) brightness(1.18) saturate(1.25)`:`none`});let r=document.createElement(`span`);Object.assign(r.style,{width:`6px`,height:`6px`,borderRadius:`2px`,flexShrink:`0`,background:g});let i=document.createElement(`span`);return i.textContent=n,Object.assign(i.style,{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,minWidth:`0`,flex:`1`}),t.append(r,i),document.body.appendChild(t),t},P=i===`ok`||i===`danger`,ne=P?b*.55:b*.92,F=y?S:ne,I=y?1:i===`retry`?.96:.42,re=y?.82:i===`retry`?.9:.28,L=N({opacity:1});l.set(L,{transformOrigin:`center center`,x:0,y:0});let R=D-c.left,z=O-c.top,B=y?-Math.min(42,14+Math.abs(R)*.1):0;[.72,.46,.26].map((e,t)=>{let n=N({opacity:e,asTrail:!0});return l.set(n,{transformOrigin:`center center`,x:0,y:0}),y?l.to(n,{motionPath:{path:[{x:0,y:0},{x:R*.45,y:z*.35+B},{x:R,y:z}],curviness:1.35,autoRotate:!1},width:F,height:C,scaleX:1.18+t*.08,opacity:0,duration:k,delay:M+h(.05+t*.05),ease:K,force3D:!0,onComplete:()=>n.remove()}):l.to(n,{left:D,top:O,width:F,...P?{scale:I*(.92-t*.08)}:{scaleX:1.28+t*.1},opacity:0,duration:k,delay:M+h(.04+t*.045),ease:G,force3D:!0,onComplete:()=>n.remove()}),n});let V=y?{motionPath:{path:[{x:0,y:0},{x:R*.45,y:z*.35+B},{x:R,y:z}],curviness:1.35,autoRotate:!1},width:F,height:C,scale:I,opacity:1,duration:k,delay:M,ease:K,force3D:!0}:{left:D,top:O,width:F,scale:I,opacity:1,duration:k,delay:M,ease:G,force3D:!0};l.to(L,{...V,onComplete:()=>{let e=a;if(e&&(i===`ok`||i===`danger`)){let t=i===`ok`?`inset 0 0 0 1px color-mix(in oklab, var(--success) 28%, transparent)`:`inset 0 0 0 1px color-mix(in oklab, var(--danger) 28%, transparent)`,n=i===`ok`?`inset 0 0 0 1.5px color-mix(in oklab, var(--success) 52%, transparent), 0 0 10px color-mix(in oklab, var(--success) 20%, transparent)`:`inset 0 0 0 1.5px color-mix(in oklab, var(--danger) 52%, transparent), 0 0 10px color-mix(in oklab, var(--danger) 20%, transparent)`;l.set(e,{transformOrigin:`center center`});let r=l.timeline({onComplete:()=>{l.set(e,{clearProps:`boxShadow,transform,x,scale`})}});r.fromTo(e,{boxShadow:t},{boxShadow:n,duration:h(.16),ease:`power1.inOut`,yoyo:!0,repeat:1}),r.to(e,{keyframes:[{x:2.8,scale:1.07,duration:h(.07)},{x:-3.2,scale:.93,duration:h(.09)},{x:2.2,scale:1.05,duration:h(.08)},{x:-1.2,scale:.98,duration:h(.07)},{x:0,scale:1,duration:h(.1)}],ease:`power1.inOut`})}o?.(),l.to(L,{opacity:0,scale:re,duration:j,delay:A,ease:`power1.out`,onComplete:()=>L.remove()})}})},d=Q.current,f=new Set,p=(t,n,r,i)=>{if(!i||f.has(t))return;f.add(t);let a=d.wait[t],o=e.querySelector(`[data-slot-id="${CSS.escape(i)}"]`),s=o?.querySelector(`[data-cell-id="${CSS.escape(t)}"]`)??o?.querySelector(`[data-slot-fill]:last-of-type`)??null,c=s?.getBoundingClientRect()??o?.getBoundingClientRect()??d.slot[i],p=s;if(!(a&&c&&a.width>=2&&c.width>=2)){_e(t);return}u(a,c,n,r,`run`,null,()=>{W(t),o&&(l.fromTo(o,{filter:`brightness(1.28)`},{filter:`brightness(1)`,duration:h(.48),ease:_.soft}),p&&l.fromTo(p,{scale:.92,transformOrigin:`left center`},{scale:1,duration:h(.48),ease:K}))})};for(let[e,t]of o){let n=a.get(e);if(!n||n.status!==`queued`||t.status!==`running`)continue;let r=c.get(e)||t.accountId||n.accountId;r&&p(e,t.name,t.kind,r)}let m=Y.workers.filter(e=>e.busy&&!t.workers.some(t=>t.id===e.id&&t.busy));for(let[e,t]of a){if(t.status!==`queued`||o.has(e))continue;let n=(t.accountId||``).trim();if(!n&&m.length===1&&(n=m[0].id),!n)continue;let r=Y.workers.find(e=>e.id===n);r&&!r.busy&&m.every(e=>e.id!==n)||p(e,t.name,t.kind,n)}for(let[e,t]of a)t.status===`queued`&&(o.has(e)||f.has(e)||Y.workers.some(t=>(t.cells??[]).some(t=>t.id===e))&&_e(e));{let t=new Set;for(let[e,n]of a){if(n.status!==`queued`)continue;let r=o.get(e);r&&r.status===`queued`||t.add(e)}if(t.size){let n=h(le),r=e=>{let t=e.dataset.waitId;t&&(Q.current.wait[t]=e.getBoundingClientRect())},i=(e,i)=>{let a=e.dataset.waitId;if(!a||t.has(a))return;let o=e.getBoundingClientRect();l.killTweensOf(e),l.set(e,{x:0,y:0,scale:1});let s=e.getBoundingClientRect(),c=o.left-s.left,u=o.top-s.top;if(Math.abs(c)<.5&&Math.abs(u)<.5){r(e);return}l.fromTo(e,{x:c,y:u,...i?.promote?{scale:1.15}:{}},{x:0,y:0,scale:1,duration:n,ease:G,force3D:!0,onUpdate:()=>r(e),onComplete:()=>{l.set(e,{clearProps:`transform`}),r(e)}})};e.querySelectorAll(`[data-wait-pill][data-wait-id]`).forEach(e=>i(e)),e.querySelectorAll(`[data-wait-token][data-wait-id]`).forEach(e=>i(e,{promote:!0}))}}{let n=new Set;for(let e of Y.workers)for(let t of e.cells??[])n.add(t.id);let r=[],i=new Set;for(let e of t.workers)(e.cells??[]).forEach((t,s)=>{if(n.has(t.id)||i.has(t.id))return;let c=o.get(t.id);if(c?.status===`queued`||c?.status===`running`)return;i.add(t.id);let l=a.get(t.id);r.push({id:t.id,name:t.name||l?.name||e.name,kind:l?.kind??`chat`,workerId:e.id,cellIndex:s})});for(let[e,t]of a){if(t.status!==`running`||i.has(e)||n.has(e))continue;let a=o.get(e);a?.status!==`queued`&&a?.status!==`running`&&(i.add(e),r.push({id:e,name:t.name,kind:t.kind,workerId:s.get(e)??``,cellIndex:0}))}let c=new Map;for(let e of r){let t=c.get(e.workerId)??[];t.push(e),c.set(e.workerId,t)}for(let n of c.values())n.sort((e,t)=>e.cellIndex-t.cellIndex),n.forEach((n,r)=>{let i=d.slot[`cell:${n.id}`]??(n.workerId?d.slot[n.workerId]:void 0),a=o.get(n.id),s=Y.completions?.find(e=>e.id===n.id),c;if(s)c=s.ok?`ok`:`danger`;else if(a?.status===`failed`)c=`danger`;else if(a?.status===`done`)c=`ok`;else{let e=Y.totals.done>t.totals.done;c=Y.totals.failed>t.totals.failed&&!e?`danger`:`ok`}let l=e.querySelector(c===`ok`?`[data-outcome="ok"]`:`[data-outcome="danger"]`),f=l?.getBoundingClientRect()??d.outcome[c];u(i,f,n.name,n.kind,c,l,void 0,r*.1)})}for(let[t,n]of a){if(n.status!==`running`)continue;let r=o.get(t);if(!r||r.status!==`queued`)continue;let i=s.get(t),a=d.slot[`cell:${t}`]??(i?d.slot[i]:void 0),c=(e.querySelector(`[data-wait-id="${CSS.escape(t)}"]`)??e.querySelector(`[data-queue-col]`))?.getBoundingClientRect();u(a,c,n.name,n.kind,`retry`,null,()=>{let n=e.querySelector(`[data-wait-id="${CSS.escape(t)}"]`);n&&l.fromTo(n,{opacity:.4,scale:.85},{opacity:1,scale:1,duration:h(.42),ease:G})})}for(let[t,n]of o){if(n.status!==`queued`||a.has(t))continue;let r=e.querySelector(`[data-wait-id="${CSS.escape(t)}"]`);r&&l.fromTo(r,{opacity:0,y:-10,scale:.6},{opacity:1,y:0,scale:1,duration:h(.52),ease:G})}{let n=t.jobs.filter(e=>e.status===`queued`).map(e=>e.id),r=Y.jobs.filter(e=>e.status===`queued`).map(e=>e.id);if(n.length===r.length&&n.some((e,t)=>e!==r[t])){let t=h(le);for(let n of r){let r=e.querySelector(`[data-wait-id="${CSS.escape(n)}"]`);if(!r)continue;let i=r.getBoundingClientRect();l.killTweensOf(r),l.set(r,{x:0,y:0});let a=r.getBoundingClientRect(),o=i.left-a.left,s=i.top-a.top;if(Math.abs(o)<.5&&Math.abs(s)<.5){Q.current.wait[n]=a;continue}l.fromTo(r,{x:o,y:s},{x:0,y:0,duration:t,ease:G,force3D:!0,onUpdate:()=>{Q.current.wait[n]=r.getBoundingClientRect()},onComplete:()=>{l.set(r,{clearProps:`transform`}),Q.current.wait[n]=r.getBoundingClientRect()}})}}}{let n=t.jobs.filter(e=>e.status===`queued`).map(e=>e.id),r=Y.jobs.filter(e=>e.status===`queued`).map(e=>e.id);for(let t=0;t{let t=e.filter(e=>e.busy),n=e.filter(e=>!e.busy),r=[],i=new Set;for(let e of[...t,...n])if(!i.has(e.id)&&(i.add(e.id),r.push(e.id),r.length>=se))break;return r},r=n(t.workers),i=n(Y.workers);if(r.length!==i.length||r.some((e,t)=>e!==i[t])){let t=new Map(r.map((e,t)=>[e,t]));for(let n=0;nf,g=h(p?0:m?.07:.04),_=h(p?.72:.64);l.killTweensOf(a),l.fromTo(a,{x:c,y:u,scale:p?1.035:1,zIndex:p?6:m?2:3},{x:0,y:0,scale:1,zIndex:1,duration:_,delay:g,ease:G,force3D:!0,onComplete:()=>{l.set(a,{clearProps:`transform,zIndex`})}})}for(let n of i){if(t.has(n))continue;let r=e.querySelector(`[data-slot-id="${CSS.escape(n)}"]`);r&&(l.killTweensOf(r),l.fromTo(r,{opacity:.35,y:14,scale:.96},{opacity:1,y:0,scale:1,duration:h(.56),delay:h(.08),ease:G,onComplete:()=>l.set(r,{clearProps:`transform`})}))}}}r()},[Y,C,y,k,T,n]);let De=e(`inflightDepthHint`,{n:X.depthNow}),Oe=!k&&!!n,ke=k&&T&&!n,Ae=F?.bindings??0;return(0,L.jsxs)(o,{"data-testid":`inflight-live-card`,"data-expanded":C?`true`:`false`,"data-gsap-reveal":!0,variant:v?`transparent`:void 0,className:`group overflow-hidden p-0 ${v?`bg-transparent shadow-none`:`transition-[box-shadow] duration-200`}`,children:[(0,L.jsx)(`style`,{children:` - [data-testid="inflight-live-card"]{ - /* Public AffectUI hierarchy → project tokens. - Outer Card keeps solid-glass; nested queue/slots/outcomes use - color wash + spacing (no section rules / stacked inset rings). - chart-3 stays out of surfaces. Depth curve uses chart-1. */ - /* Nested items: color wash + spacing — avoid section rules / stacked frames. */ - --il-well: var(--surface); - --il-chip: var(--surface); - --il-item-bg: color-mix(in oklab, var(--surface-secondary) 38%, var(--surface)); - --il-track: color-mix(in oklab, var(--foreground) 8%, var(--surface-secondary)); - --il-busy-bg: color-mix(in oklab, var(--chart-1) 7%, var(--surface)); - --il-busy-fill: color-mix(in oklab, var(--chart-1) 9%, var(--surface)); - --il-busy-glow: none; - --il-run: color-mix(in oklab, var(--foreground) 84%, transparent); - --il-warn: var(--warning); - --il-warn-fg: var(--warning); - /* Amber only for rate-limit/cooldown — light wash, not saturated orange panel */ - --il-warn-bg: color-mix(in oklab, var(--warning) 11%, var(--surface)); - --il-warn-hatch: color-mix(in oklab, var(--warning) 22%, transparent); - /* AffectUI-ish mint / coral outcome sinks — a touch richer wash */ - --il-ok-bg: color-mix(in oklab, var(--success) 8%, var(--surface)); - --il-ok-fg: color-mix(in oklab, var(--success) 78%, var(--foreground)); - --il-err-bg: color-mix(in oklab, var(--danger) 7%, var(--surface)); - --il-err-fg: var(--danger); - --il-depth: var(--chart-1); - --il-depth-fill: color-mix(in oklab, var(--chart-1) 20%, transparent); - --il-faint: color-mix(in oklab, var(--foreground) 42%, transparent); - } - /* Busy slot: cool wash + soft glow — no stacked glass rings */ - [data-testid="inflight-live-card"] [data-slot-busy]{ - box-shadow: var(--il-busy-glow); - } - @keyframes inflight-shimmer{0%{transform:translateX(-130%)}100%{transform:translateX(230%)}} - @keyframes inflight-queue-shimmer{0%{transform:translateX(-140%);opacity:.4}50%{opacity:.9}100%{transform:translateX(240%);opacity:.4}} - @keyframes inflight-glow{from{opacity:.45}to{opacity:1}} - @media (prefers-reduced-motion: reduce){ - [class*="animate-[inflight-shimmer_"], - [class*="animate-[inflight-queue-shimmer_"], - [class*="animate-[inflight-glow_"]{animation:none!important} - } - `}),v?null:(0,L.jsxs)(`div`,{className:`flex items-start justify-between gap-3 px-4 py-3`,children:[(0,L.jsxs)(`button`,{type:`button`,"data-testid":`inflight-live-toggle`,"aria-expanded":C,"aria-controls":`inflight-live-body`,onClick:()=>w(!C),className:`flex min-w-0 flex-1 items-start gap-2 text-left outline-none focus-visible:ring-2 focus-visible:ring-focus focus-visible:ring-offset-2 focus-visible:ring-offset-background`,children:[(0,L.jsx)(r,{size:14,"aria-hidden":!0,className:`mt-1 shrink-0 text-muted transition-transform duration-200 ${C?`rotate-90`:``}`}),(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,L.jsx)(`h3`,{className:`font-semibold`,children:e(`inflightTitle`)}),(0,L.jsxs)(`span`,{className:`mono inline-flex items-center gap-1 rounded-[3px] px-1.5 py-0.5 text-caption text-muted`,children:[(0,L.jsx)(`span`,{className:`status-dot`,"data-state":Oe?`ok`:``}),e(Oe?`inflightLiveBadge`:ke?`inflightMockBadge`:`inflightIdleBadge`)]}),C&&Ae>0?(0,L.jsx)(`span`,{className:`mono text-caption text-muted`,children:e(`inflightStickyBindings`,{n:Ae})}):null]}),(0,L.jsx)(`p`,{className:`mt-0.5 text-caption text-muted`,children:e(`inflightHint`)})]})]}),(0,L.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-2`,children:[C?(0,L.jsxs)(p,{to:`/live`,className:`inline-flex shrink-0 items-center gap-1 text-caption text-muted transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus`,"aria-label":e(`inflightCardAria`),onClick:e=>e.stopPropagation(),children:[e(`inflightOpen`),(0,L.jsx)(ee,{size:14,"aria-hidden":!0})]}):(0,L.jsxs)(`button`,{type:`button`,className:`inline-flex shrink-0 items-center gap-1 text-caption text-muted transition-colors hover:text-foreground`,onClick:()=>w(!0),children:[e(`inflightExpand`),(0,L.jsx)(r,{size:14,"aria-hidden":!0})]}),C&&!y?(0,L.jsx)(`div`,{className:`flex items-center gap-1.5`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:(0,L.jsx)(s,{size:`sm`,isSelected:T,ariaLabel:e(`inflightMockToggleAria`),label:e(`inflightMockToggle`),onChange:E})}):null]})]}),C?(0,L.jsxs)(`div`,{id:`inflight-live-body`,ref:ye,children:[(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 px-4 pb-1 pt-0 sm:grid-cols-4`,children:[(0,L.jsx)(J,{label:e(`inflightWaiting`),value:X.waiting,warn:Ee}),(0,L.jsx)(J,{label:e(`inflightRunning`),value:X.occupiedSlots,suffix:`/${X.workerSlots}`}),(0,L.jsx)(J,{label:e(`inflightThroughput`),value:Y.throughputPerMin,suffix:`/min`}),(0,L.jsx)(J,{label:e(`inflightWaitP95`),value:Y.waitP95Ms,kind:`ms`})]}),(0,L.jsxs)(`div`,{className:`grid gap-3 px-4 py-3 lg:grid-cols-[minmax(11rem,0.7fr)_minmax(0,2.1fr)_auto]`,children:[(0,L.jsxs)(`div`,{className:`min-w-0`,"data-queue-col":!0,children:[(0,L.jsxs)(`div`,{className:`mb-1.5 flex items-baseline justify-between gap-2`,children:[(0,L.jsx)(`span`,{className:`text-caption uppercase tracking-wide text-muted`,children:e(`inflightQueue`)}),(0,L.jsx)(`span`,{className:`mono text-[10px] tabular ${Ee?`text-[var(--il-warn-fg)]`:`text-muted`}`,children:X.waiting})]}),(0,L.jsxs)(`div`,{className:`space-y-1.5`,children:[Ce.map(t=>(0,L.jsxs)(`div`,{"data-wait-pill":!0,"data-wait-id":t.id,"data-priority":t.priority??`normal`,className:`relative flex items-center justify-between gap-2 overflow-hidden rounded-xl px-2.5 py-2 ${he(t.kind)}`,children:[(0,L.jsx)(`span`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-y-0 w-2/5 bg-gradient-to-r from-transparent via-[color-mix(in_oklab,var(--foreground)_8%,transparent)] to-transparent motion-safe:animate-[inflight-queue-shimmer_2.8s_linear_infinite]`}),(0,L.jsxs)(`span`,{className:`relative z-[1] flex min-w-0 items-center gap-2.5 truncate text-caption font-medium text-foreground/78`,children:[me(t.kind),(0,L.jsxs)(`span`,{className:`truncate`,children:[t.name,t.priority===`high`?(0,L.jsx)(`span`,{className:`mono ml-1 text-[10px] text-muted`,children:`↑`}):null,t.sticky?(0,L.jsx)(`span`,{className:`mono ml-1 text-[10px] text-muted`,children:e(`inflightSticky`)}):null]})]}),(0,L.jsx)(`span`,{className:`relative z-[1] mono shrink-0 text-caption text-muted`,children:de(fe(t,z))})]},t.id)),we.length?(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 pt-1`,"data-queue-overflow":!0,children:[we.map(e=>(0,L.jsx)(`span`,{"data-wait-token":!0,"data-wait-id":e.id,"data-priority":e.priority??`normal`,className:`size-2 rounded-[2px] ${pe(e.kind)} ${e.priority===`high`?`ring-1 ring-foreground/20`:``}`,title:e.name},e.id)),(0,L.jsxs)(`span`,{className:`mono text-[10px] text-muted`,children:[`+`,we.length]})]}):Ce.length===0?(0,L.jsx)(`div`,{className:`text-caption text-muted`,children:e(`inflightQueueEmpty`)}):null]})]}),(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsxs)(`div`,{className:`mb-1.5 flex items-baseline justify-between gap-2`,children:[(0,L.jsx)(`span`,{className:`text-caption uppercase tracking-wide text-muted`,children:e(`inflightSlots`)}),(0,L.jsxs)(`span`,{className:`mono text-[10px] tabular text-muted`,children:[X.occupiedSlots,`/`,X.workerSlots]})]}),(0,L.jsx)(`div`,{className:`flex flex-col gap-2`,"data-worker-rail":!0,children:Te.map(t=>(0,L.jsx)(ge,{slot:t,jobById:xe,clockMs:z,idleLabel:e(`inflightSlotIdle`),landedCellIds:V},t.id))})]}),(0,L.jsxs)(`div`,{className:`flex gap-2 sm:gap-2.5 lg:w-[6.75rem] lg:flex-col lg:gap-2.5`,children:[(0,L.jsx)(ve,{label:e(`inflightDone`),value:Y.totals.done,tone:`ok`,icon:(0,L.jsx)(i,{size:22,"aria-hidden":!0})}),(0,L.jsx)(ve,{label:e(`inflightFailed`),value:Y.totals.failed,tone:`danger`,icon:(0,L.jsx)(f,{size:22,"aria-hidden":!0})})]})]}),(0,L.jsxs)(`div`,{"data-depth":!0,className:`px-4 py-3`,children:[(0,L.jsxs)(`div`,{className:`mb-1 flex items-baseline justify-between gap-2`,children:[(0,L.jsx)(`span`,{className:`text-caption uppercase tracking-wide text-muted`,children:e(`inflightDepth`)}),(0,L.jsx)(`span`,{className:`mono text-caption tabular text-muted`,children:De})]}),(0,L.jsx)(`div`,{className:`rounded-lg bg-[var(--il-item-bg)] px-1.5 pt-1.5 pb-1`,children:(0,L.jsx)(b.Suspense,{fallback:(0,L.jsx)(`div`,{className:`h-11 w-full`,"aria-hidden":!0}),children:(0,L.jsx)(ie,{series:Y.depthSeries,bands:[],backpressure:Y.backpressure,label:De})})})]})]}):null]})}function J({label:e,value:t,suffix:n,kind:r=`int`,warn:i}){return(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsx)(`div`,{className:`text-caption uppercase tracking-wide text-muted`,children:e}),(0,L.jsxs)(`div`,{className:`mono mt-1 flex items-baseline gap-0.5 text-section font-semibold tabular ${i?`text-[var(--il-warn-fg)]`:`text-foreground`}`,children:[(0,L.jsx)(H,{value:t,kind:r,duration:560}),n?(0,L.jsx)(`span`,{className:`text-[0.92em] opacity-80`,children:n}):null]})]})}function ve({label:e,value:t,tone:n,icon:r}){let i=n===`ok`;return(0,L.jsxs)(`div`,{"data-outcome":n,role:`group`,"aria-label":`${e}: ${t}`,title:`${e}: ${t}`,className:`flex min-h-28 min-w-[3.6rem] flex-1 flex-col items-center justify-center gap-2 rounded-2xl border px-3 py-4 ${i?`border-[color-mix(in_oklab,var(--success)_14%,transparent)] bg-[var(--il-ok-bg)]`:`border-[color-mix(in_oklab,var(--danger)_12%,transparent)] bg-[var(--il-err-bg)]`}`,children:[(0,L.jsx)(`span`,{className:`inline-flex size-12 items-center justify-center rounded-2xl ${i?`bg-[color-mix(in_oklab,var(--success)_14%,var(--surface))] text-[var(--il-ok-fg)]`:`bg-[color-mix(in_oklab,var(--danger)_12%,var(--surface))] text-[var(--il-err-fg)]`}`,"aria-hidden":!0,children:r}),(0,L.jsx)(`div`,{className:`mono text-[1.7rem] font-semibold tabular leading-none tracking-tight ${i?`text-[var(--il-ok-fg)]`:`text-[var(--il-err-fg)]`}`,children:(0,L.jsx)(H,{value:t,kind:`int`,duration:560})}),(0,L.jsx)(`span`,{className:`text-caption font-medium ${i?`text-[color-mix(in_oklab,var(--success)_55%,var(--muted))]`:`text-[color-mix(in_oklab,var(--danger)_55%,var(--muted))]`}`,children:e})]})}export{H as n,ee as r,_e as t}; \ No newline at end of file diff --git a/internal/webui/static/assets/KeysPage-B5bwtFjj.js b/internal/webui/static/assets/KeysPage-B5bwtFjj.js deleted file mode 100644 index 918f6eb0..00000000 --- a/internal/webui/static/assets/KeysPage-B5bwtFjj.js +++ /dev/null @@ -1 +0,0 @@ -import{a as e,c as t,n}from"./shim-mfK0Rmj6.js";import{n as r,t as i}from"./clipboard-BMEt1jHG.js";import{t as a}from"./Plus.es-W6ztpkEI.js";import{t as o}from"./TrashSimple.es-BiXnQzNp.js";import{n as s,r as c}from"./useI18n-BSw4X3mq.js";import{t as l}from"./label-n7vfsS35.js";import{n as u,t as d}from"./PageAlert-CaDjxveS.js";import{n as f}from"./useToggle-HDaAPzVy.js";import{t as p}from"./checkbox-Dkk25tsQ.js";import{t as m}from"./description-0cu8nG7R.js";import{t as h}from"./EmptyPanel-Bs-jQMvG.js";import{n as g,t as _}from"./FormRow-D36RiZfK.js";import{t as v}from"./modal-BVwBjYX-.js";import{n as y,t as b}from"./number-field-D7UJ0QLF.js";import{t as x}from"./CompactSwitch-DH1Gk66-.js";import{g as S}from"./overview-m01k08K8.js";import{r as C}from"./gsap-C3sDxib7.js";import{Dt as w,It as T,M as E,_ as D,k as O,m as k,o as A,t as j,v as M,x as N,y as P}from"./index-C8_qeOs_.js";import{t as F}from"./ProviderMark-IiAZTaQS.js";import{n as I,t as L}from"./provider-gHnttGKq.js";import{n as R,o as z,r as ee,t as B}from"./keys-BOKh04gY.js";var V=t(e(),1),H=n(),U=1.1;function W({label:e,onConfirm:t,isPending:n,children:r}){let i=(0,V.useRef)(null),a=(0,V.useRef)(null);return(0,V.useEffect)(()=>()=>{a.current?.kill()},[]),(0,H.jsxs)(O,{delay:300,children:[(0,H.jsx)(O.Trigger,{children:(0,H.jsxs)(c,{isIconOnly:!0,size:`sm`,variant:`ghost`,"aria-label":e,isPending:n,className:`relative overflow-hidden`,onPressStart:()=>{let e=i.current;!e||n||(a.current?.kill(),a.current=C.to(e,{scaleX:1,duration:U*(1-Number(C.getProperty(e,`scaleX`))),ease:P.linear,onComplete:()=>{a.current=null,C.to(e,{scaleX:0,duration:N()?0:M.base,ease:P.out,delay:M.fast}),t()}}))},onPressEnd:()=>{let e=i.current;!e||!a.current||(a.current.kill(),a.current=null,C.to(e,{scaleX:0,duration:N()?0:M.base,ease:P.soft}))},children:[(0,H.jsx)(`span`,{ref:i,"aria-hidden":!0,className:`pointer-events-none absolute inset-0 origin-left scale-x-0 bg-danger/20`}),(0,H.jsx)(`span`,{className:`relative inline-flex`,children:r})]})}),(0,H.jsx)(O.Content,{children:e})]})}function G(e){let t=[];for(let n of e)for(let e of n.regions||[])e?.id&&t.push({value:`${n.id}:${e.id}`,provider:n.id,region:e.id});return t}function K(e,t){let n=e.indexOf(`:`),r=n===-1?e:e.slice(0,n),i=n===-1?``:e.slice(n+1);return i?I(r,i,t):L(r,t)}function q(e){let t=e.indexOf(`:`);return t===-1?e:e.slice(0,t)}function J(e,t){let n=[],r=new Set(e.filter(e=>!e.includes(`:`)).map(e=>e.toLowerCase()));for(let t of e)t.includes(`:`)&&n.push(t);for(let e of t)r.has(e.provider)&&!n.includes(e.value)&&n.push(e.value);return n}function Y(e,t){return e.length?e.map(e=>K(e,t)).join(` · `):t(`keysAllProviders`)}function te(e){if(!e)return``;let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}function X(){let{t:e}=s(),[t,n]=(0,V.useState)([]),[l,p]=(0,V.useState)(!1),[m,g]=(0,V.useState)(``),[_,y]=(0,V.useState)([]),[b,C]=(0,V.useState)(!0),[O,M]=(0,V.useState)(``),[N,P]=(0,V.useState)(``),[I,L]=(0,V.useState)(!1),[U,J]=(0,V.useState)(null),[Y,X]=(0,V.useState)(null),[ne,Q]=(0,V.useState)(!1);(0,V.useEffect)(()=>{S().then(e=>{let t=G(e.data||[]);n(t),p(t.length>0),g(``)}).catch(e=>{g(e instanceof Error?e.message:String(e))})},[]);async function $(){C(!0);try{let e=await ee();y(e.data||[]),P(``)}catch(e){P(e instanceof Error?e.message:String(e))}finally{C(!1)}}(0,V.useEffect)(()=>{let e=window.setTimeout(()=>void $(),0);return()=>window.clearTimeout(e)},[]);async function re(e){await i(e),Q(!0),window.setTimeout(()=>Q(!1),1200)}async function ie(e,t){M(e.id),y(n=>n.map(n=>n.id===e.id?{...n,enabled:t}:n));try{let n=await z(e.id,{enabled:t});y(t=>t.map(t=>t.id===e.id?{...t,...n,secret:void 0}:t))}catch(e){P(e instanceof Error?e.message:String(e)),await $()}finally{M(``)}}async function ae(t){M(t.id);try{await R(t.id),y(e=>e.filter(e=>e.id!==t.id)),j({type:`success`,title:e(`toastKeyDeleted`)})}catch(e){P(e instanceof Error?e.message:String(e))}finally{M(``)}}return b&&!_.length?(0,H.jsx)(A,{}):(0,H.jsxs)(`div`,{className:`space-y-6`,children:[(0,H.jsxs)(`section`,{className:`flex flex-wrap items-end justify-between gap-4 pb-4`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h2`,{"data-gsap-reveal":!0,className:`text-title font-semibold`,children:e(`navKeys`)}),(0,H.jsx)(`p`,{className:`mt-1 max-w-2xl text-body leading-6 text-muted`,children:e(`keysLead`)})]}),(0,H.jsxs)(c,{size:`sm`,isDisabled:!l,onPress:()=>L(!0),children:[(0,H.jsx)(a,{size:14}),e(`keysCreate`)]})]}),N?(0,H.jsx)(d,{title:N}):null,m?(0,H.jsx)(d,{title:e(`keysProvidersLoadFailed`,{message:m})}):null,b?(0,H.jsx)(`section`,{className:`grid gap-2.5 lg:grid-cols-2 xl:grid-cols-3`,"aria-busy":!0,children:Array.from({length:Math.max(3,_.length)},(e,t)=>(0,H.jsxs)(`div`,{className:`overflow-hidden rounded-3xl bg-surface shadow-surface p-3`,children:[(0,H.jsx)(k,{className:`h-4 w-28`}),(0,H.jsx)(k,{className:`mt-2 h-3 w-40`}),(0,H.jsx)(k,{className:`mt-4 h-6 w-24`}),(0,H.jsx)(k,{className:`mt-6 h-8 w-full`})]},t))}):_.length?(0,H.jsx)(`section`,{className:`grid gap-2.5 lg:grid-cols-2 xl:grid-cols-3`,children:_.map(t=>(0,H.jsxs)(f,{className:`overflow-hidden p-0`,children:[(0,H.jsxs)(f.Header,{className:`flex-row items-start justify-between gap-3 px-3 pt-3 pb-2.5`,children:[(0,H.jsx)(`div`,{className:`min-w-0`,children:(0,H.jsx)(f.Title,{className:`truncate text-body`,children:t.name})}),(0,H.jsx)(E,{size:`sm`,variant:`soft`,color:t.enabled?`success`:`default`,children:t.enabled?e(`enabled`):e(`disabled`)})]}),(0,H.jsxs)(f.Content,{className:`space-y-2.5 px-3 pb-2.5`,children:[(0,H.jsx)(`div`,{className:`mono w-full rounded-lg bg-surface-secondary px-3 py-2 text-body text-foreground`,title:t.prefix,children:t.prefix}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(t.providers.length?t.providers:[`all`]).map(t=>(0,H.jsx)(E,{size:`sm`,variant:`soft`,children:(0,H.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[t===`all`?(0,H.jsx)(T,{size:12}):(0,H.jsx)(F,{provider:q(t),size:12}),(0,H.jsx)(`span`,{children:t===`all`?e(`keysAllProviders`):K(t,e)})]})},t)),t.model_aggregation?(0,H.jsx)(E,{size:`sm`,variant:`soft`,children:e(`keysModelAggregationBadge`)}):null]}),(0,H.jsxs)(`p`,{className:`text-caption leading-5 text-muted`,children:[t.max_inflight>0?e(`keysMaxInflightValue`,{count:t.max_inflight}):e(`keysMaxInflightUnlimited`),` · `,t.last_used_at?e(`keysLastUsed`,{time:te(t.last_used_at)}):e(`keysNeverUsed`)]})]}),(0,H.jsxs)(f.Footer,{className:`gap-1.5 bg-surface-secondary px-3 py-2`,children:[(0,H.jsx)(c,{size:`sm`,variant:`ghost`,isDisabled:!l,onPress:()=>J(t),children:e(`edit`)}),(0,H.jsx)(W,{label:e(`holdToDelete`),isPending:O===t.id,onConfirm:()=>void ae(t),children:(0,H.jsx)(o,{size:14})}),(0,H.jsx)(`div`,{className:`ml-auto`,children:(0,H.jsx)(x,{isSelected:t.enabled,isDisabled:O===t.id,ariaLabel:e(`enable`),onChange:e=>void ie(t,e)})})]})]},t.id))}):(0,H.jsx)(h,{className:`rounded-3xl bg-surface-secondary`,icon:(0,H.jsx)(D,{size:28}),title:e(`keysEmpty`),hint:e(`keysEmptyHint`),action:(0,H.jsxs)(c,{size:`sm`,isDisabled:!l,onPress:()=>L(!0),children:[(0,H.jsx)(a,{size:14}),e(`keysCreate`)]})}),(0,H.jsx)(Z,{isOpen:I,title:e(`keysCreateTitle`),hint:e(`keysCreateHint`),options:t,t:e,onClose:()=>L(!1),onSave:async e=>{let t=await B(e);y(e=>[t,...e.map(e=>({...e,secret:void 0}))]),L(!1),X(t)}}),(0,H.jsx)(Z,{isOpen:!!U,title:e(`keysEditTitle`),hint:e(`keysEditHint`),initial:U,options:t,t:e,onClose:()=>J(null),onSave:async e=>{if(!U)return;let t=await z(U.id,e);y(e=>e.map(e=>e.id===U.id?{...e,...t,secret:void 0}:e)),J(null)}}),(0,H.jsx)(v.Root,{isOpen:!!Y?.secret,onOpenChange:e=>{e||X(null)},children:(0,H.jsx)(v.Backdrop,{variant:`blur`,children:(0,H.jsx)(v.Container,{placement:`center`,size:`lg`,children:(0,H.jsxs)(v.Dialog,{children:[(0,H.jsxs)(v.Header,{className:`items-start justify-between gap-4 px-6 pt-6`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(v.Heading,{className:`text-section font-semibold`,children:e(`keysSecretTitle`)}),(0,H.jsx)(`p`,{className:`mt-1.5 text-body leading-6 text-muted`,children:e(`keysSecretHint`)})]}),(0,H.jsx)(v.CloseTrigger,{"aria-label":e(`close`),className:`grid size-9 place-items-center rounded-lg text-muted hover:bg-surface-secondary`,children:(0,H.jsx)(w,{size:18})})]}),(0,H.jsxs)(v.Body,{className:`px-6 pb-2`,children:[(0,H.jsxs)(u,{status:`warning`,className:`mb-4`,children:[(0,H.jsx)(u.Indicator,{}),(0,H.jsx)(u.Content,{children:(0,H.jsx)(u.Title,{children:e(`keysSecretOnce`)})})]}),(0,H.jsx)(`code`,{className:`mono block break-all rounded-lg bg-surface-secondary px-3 py-3 text-body`,children:Y?.secret})]}),(0,H.jsxs)(v.Footer,{className:`justify-end`,children:[(0,H.jsx)(c,{variant:`ghost`,onPress:()=>X(null),children:e(`close`)}),(0,H.jsxs)(c,{onPress:()=>{Y?.secret&&re(Y.secret)},children:[(0,H.jsx)(r,{size:14}),e(ne?`copied`:`copy`)]})]})]})})})})]})}function Z({isOpen:e,title:t,hint:n,initial:r,options:i,t:a,onClose:o,onSave:s}){let[d,f]=(0,V.useState)(r?.name||``),[h,S]=(0,V.useState)(r?.max_inflight||0),[C,T]=(0,V.useState)(r?.model_aggregation||!1),[E,D]=(0,V.useState)([]),[O,k]=(0,V.useState)(new Set),[A,j]=(0,V.useState)(!0),[M,N]=(0,V.useState)(``),[P,L]=(0,V.useState)(!1);(0,V.useEffect)(()=>{if(!e)return;f(r?.name||``),S(r?.max_inflight||0),T(!!r?.model_aggregation),D(J(r?.providers||[],i));let t=new Set((r?.providers||[]).filter(e=>!e.includes(`:`)).map(e=>e.toLowerCase()));k(t),j(!0),N(``)},[r,e,i]);function R(e){let t=i.find(t=>t.value===e);j(!1),D(n=>n.includes(e)?(t&&k(e=>{let n=new Set(e);return n.delete(t.provider),n}),n.filter(t=>t!==e)):[...n,e])}async function z(e){e?.preventDefault();let t=d.trim();if(!t){N(a(`keysNameRequired`));return}if(!Number.isInteger(h)||h<0||h>256){N(a(`keysMaxInflightInvalid`));return}if(!i.length){N(a(`keysProvidersNotLoaded`));return}L(!0),N(``);try{await s({name:t,providers:A?r?.providers||[]:E,max_inflight:h,model_aggregation:C})}catch(e){N(e instanceof Error?e.message:String(e))}finally{L(!1)}}return(0,H.jsx)(v.Root,{isOpen:e,onOpenChange:e=>{!e&&!P&&o()},children:(0,H.jsx)(v.Backdrop,{variant:`blur`,children:(0,H.jsx)(v.Container,{placement:`center`,size:`lg`,scroll:`inside`,children:(0,H.jsx)(v.Dialog,{className:`sm:min-w-[32rem]`,children:(0,H.jsxs)(y,{className:`flex min-h-0 flex-1 flex-col`,onSubmit:z,children:[(0,H.jsxs)(v.Header,{className:`items-start justify-between gap-4 px-6 pt-6`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(v.Heading,{className:`text-section font-semibold`,children:t}),(0,H.jsx)(`p`,{className:`mt-1.5 text-body leading-6 text-muted`,children:n})]}),(0,H.jsx)(v.CloseTrigger,{isDisabled:P,"aria-label":a(`close`),className:`grid size-9 place-items-center rounded-lg text-muted hover:bg-surface-secondary`,children:(0,H.jsx)(w,{size:18})})]}),(0,H.jsxs)(v.Body,{className:`space-y-5 px-6 pb-2 pt-1`,children:[M?(0,H.jsxs)(u,{status:`danger`,children:[(0,H.jsx)(u.Indicator,{}),(0,H.jsx)(u.Content,{children:(0,H.jsx)(u.Title,{children:M})})]}):null,(0,H.jsx)(_,{label:a(`keysName`),children:(0,H.jsx)(g,{value:d,onChange:e=>f(e.target.value),placeholder:a(`keysNamePh`),"aria-label":a(`keysName`)})}),(0,H.jsx)(_,{label:a(`keysMaxInflight`),hint:a(`keysMaxInflightHint`),children:(0,H.jsx)(b,{value:h,onChange:e=>S(e??0),minValue:0,maxValue:256,isDisabled:P,children:(0,H.jsxs)(b.Group,{children:[(0,H.jsx)(b.DecrementButton,{}),(0,H.jsx)(b.Input,{"aria-label":a(`keysMaxInflight`)}),(0,H.jsx)(b.IncrementButton,{})]})})}),(0,H.jsx)(_,{label:a(`keysModelAggregation`),hint:a(`keysModelAggregationHint`),children:(0,H.jsx)(x,{isSelected:C,isDisabled:P,ariaLabel:a(`keysModelAggregation`),onChange:T})}),(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(l,{className:`text-body font-medium text-muted`,children:a(`keysProviders`)}),(0,H.jsx)(m,{className:`text-caption leading-5 text-muted`,children:a(`keysProvidersHint`)}),i.length?(0,H.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:i.map(e=>{let t=E.includes(e.value),n=O.has(e.provider);return(0,H.jsx)(p,{isSelected:t,onChange:()=>R(e.value),className:`rounded-xl bg-surface-secondary px-3 py-2.5 data-selected:border-accent data-selected:bg-accent-soft`,children:(0,H.jsxs)(p.Content,{className:`flex items-center gap-2.5`,children:[(0,H.jsx)(p.Control,{children:(0,H.jsx)(p.Indicator,{})}),(0,H.jsx)(F,{provider:e.provider,size:16}),(0,H.jsx)(`span`,{className:`text-body font-medium`,children:I(e.provider,e.region,a)}),n?(0,H.jsx)(`span`,{className:`rounded-lg bg-surface-secondary px-1.5 py-0.5 text-caption font-medium text-muted`,children:a(`keysAllRegions`)}):null]})},e.value)})}):(0,H.jsx)(`p`,{className:`rounded-lg bg-surface-secondary px-3 py-2.5 text-caption leading-5 text-muted`,children:a(`keysProvidersNotLoaded`)}),(0,H.jsx)(`p`,{className:`text-caption text-muted`,children:Y(E,a)})]})]}),(0,H.jsxs)(v.Footer,{className:`justify-end`,children:[(0,H.jsx)(c,{variant:`ghost`,isDisabled:P,onPress:o,children:a(`cancel`)}),(0,H.jsx)(c,{type:`submit`,isPending:P,isDisabled:!i.length,children:a(r?`save`:`create`)})]})]})})})})})}export{X as KeysPage}; \ No newline at end of file diff --git a/internal/webui/static/assets/KeysPage-CzYDs0oe.js b/internal/webui/static/assets/KeysPage-CzYDs0oe.js new file mode 100644 index 00000000..3cd9e0f5 --- /dev/null +++ b/internal/webui/static/assets/KeysPage-CzYDs0oe.js @@ -0,0 +1 @@ +import{a as e,c as t,n}from"./shim-mfK0Rmj6.js";import{n as r,t as i}from"./clipboard-BWzpPXn-.js";import{t as a}from"./Plus.es-CSLpU0CT.js";import{t as o}from"./TrashSimple.es-51cVgQMz.js";import{n as s,r as c}from"./useI18n-BBOAnu2u.js";import{t as l}from"./label-BVCjtfNQ.js";import{n as u,t as d}from"./PageAlert-DZC7IhXp.js";import{t as f}from"./card-QlCdtlk0.js";import{n as p,r as m,t as h}from"./number-field-nGZCb975.js";import{t as g}from"./description-CNxrVc-S.js";import{t as _}from"./EmptyPanel-Bs-jQMvG.js";import{n as v,r as y,t as b}from"./FormRow-Bhp_wPvH.js";import{t as x}from"./modal-DHeFzFnN.js";import{g as S}from"./overview-CJvUvgoD.js";import{r as C}from"./gsap-C3sDxib7.js";import{M as w,Rt as T,_ as E,k as D,kt as O,m as k,o as A,t as j,v as M,x as N,y as P}from"./index-B9eWF6SH.js";import{t as F}from"./ProviderMark-IiAZTaQS.js";import{n as I,t as L}from"./provider-gHnttGKq.js";import{n as R,o as z,r as B,t as V}from"./keys-Kp99scw1.js";var H=t(e(),1),U=n(),W=1.1;function G({label:e,onConfirm:t,isPending:n,children:r}){let i=(0,H.useRef)(null),a=(0,H.useRef)(null);return(0,H.useEffect)(()=>()=>{a.current?.kill()},[]),(0,U.jsxs)(D,{delay:300,children:[(0,U.jsx)(D.Trigger,{children:(0,U.jsxs)(c,{isIconOnly:!0,size:`sm`,variant:`ghost`,"aria-label":e,isPending:n,className:`relative overflow-hidden`,onPressStart:()=>{let e=i.current;!e||n||(a.current?.kill(),a.current=C.to(e,{scaleX:1,duration:W*(1-Number(C.getProperty(e,`scaleX`))),ease:P.linear,onComplete:()=>{a.current=null,C.to(e,{scaleX:0,duration:N()?0:M.base,ease:P.out,delay:M.fast}),t()}}))},onPressEnd:()=>{let e=i.current;!e||!a.current||(a.current.kill(),a.current=null,C.to(e,{scaleX:0,duration:N()?0:M.base,ease:P.soft}))},children:[(0,U.jsx)(`span`,{ref:i,"aria-hidden":!0,className:`pointer-events-none absolute inset-0 origin-left scale-x-0 bg-danger/20`}),(0,U.jsx)(`span`,{className:`relative inline-flex`,children:r})]})}),(0,U.jsx)(D.Content,{children:e})]})}function K(e){let t=[];for(let n of e)for(let e of n.regions||[])e?.id&&t.push({value:`${n.id}:${e.id}`,provider:n.id,region:e.id});return t}function q(e,t){let n=e.indexOf(`:`),r=n===-1?e:e.slice(0,n),i=n===-1?``:e.slice(n+1);return i?I(r,i,t):L(r,t)}function ee(e){let t=e.indexOf(`:`);return t===-1?e:e.slice(0,t)}function J(e,t){let n=[],r=new Set(e.filter(e=>!e.includes(`:`)).map(e=>e.toLowerCase()));for(let t of e)t.includes(`:`)&&n.push(t);for(let e of t)r.has(e.provider)&&!n.includes(e.value)&&n.push(e.value);return n}function Y(e,t){return e.length?e.map(e=>q(e,t)).join(` · `):t(`keysAllProviders`)}function te(e){if(!e)return``;let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}function X(){let{t:e}=s(),[t,n]=(0,H.useState)([]),[l,p]=(0,H.useState)(!1),[m,h]=(0,H.useState)(``),[g,y]=(0,H.useState)([]),[b,C]=(0,H.useState)(!0),[D,M]=(0,H.useState)(``),[N,P]=(0,H.useState)(``),[I,L]=(0,H.useState)(!1),[W,J]=(0,H.useState)(null),[Y,X]=(0,H.useState)(null),[ne,Q]=(0,H.useState)(!1);(0,H.useEffect)(()=>{S().then(e=>{let t=K(e.data||[]);n(t),p(t.length>0),h(``)}).catch(e=>{h(e instanceof Error?e.message:String(e))})},[]);async function $(){C(!0);try{let e=await B();y(e.data||[]),P(``)}catch(e){P(e instanceof Error?e.message:String(e))}finally{C(!1)}}(0,H.useEffect)(()=>{let e=window.setTimeout(()=>void $(),0);return()=>window.clearTimeout(e)},[]);async function re(e){await i(e),Q(!0),window.setTimeout(()=>Q(!1),1200)}async function ie(e,t){M(e.id),y(n=>n.map(n=>n.id===e.id?{...n,enabled:t}:n));try{let n=await z(e.id,{enabled:t});y(t=>t.map(t=>t.id===e.id?{...t,...n,secret:void 0}:t))}catch(e){P(e instanceof Error?e.message:String(e)),await $()}finally{M(``)}}async function ae(t){M(t.id);try{await R(t.id),y(e=>e.filter(e=>e.id!==t.id)),j({type:`success`,title:e(`toastKeyDeleted`)})}catch(e){P(e instanceof Error?e.message:String(e))}finally{M(``)}}return b&&!g.length?(0,U.jsx)(A,{}):(0,U.jsxs)(`div`,{className:`space-y-6`,children:[(0,U.jsxs)(`section`,{className:`flex flex-wrap items-end justify-between gap-4 pb-4`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`h2`,{"data-gsap-reveal":!0,className:`text-title font-semibold`,children:e(`navKeys`)}),(0,U.jsx)(`p`,{className:`mt-1 max-w-2xl text-body leading-6 text-muted`,children:e(`keysLead`)})]}),(0,U.jsxs)(c,{size:`sm`,isDisabled:!l,onPress:()=>L(!0),children:[(0,U.jsx)(a,{size:14}),e(`keysCreate`)]})]}),N?(0,U.jsx)(d,{title:N}):null,m?(0,U.jsx)(d,{title:e(`keysProvidersLoadFailed`,{message:m})}):null,b?(0,U.jsx)(`section`,{className:`grid gap-2.5 lg:grid-cols-2 xl:grid-cols-3`,"aria-busy":!0,children:Array.from({length:Math.max(3,g.length)},(e,t)=>(0,U.jsxs)(`div`,{className:`overflow-hidden rounded-3xl bg-surface shadow-surface p-3`,children:[(0,U.jsx)(k,{className:`h-4 w-28`}),(0,U.jsx)(k,{className:`mt-2 h-3 w-40`}),(0,U.jsx)(k,{className:`mt-4 h-6 w-24`}),(0,U.jsx)(k,{className:`mt-6 h-8 w-full`})]},t))}):g.length?(0,U.jsx)(`section`,{className:`grid gap-2.5 lg:grid-cols-2 xl:grid-cols-3`,children:g.map(t=>(0,U.jsxs)(f,{className:`overflow-hidden p-0`,children:[(0,U.jsxs)(f.Header,{className:`flex-row items-start justify-between gap-3 px-3 pt-3 pb-2.5`,children:[(0,U.jsx)(`div`,{className:`min-w-0`,children:(0,U.jsx)(f.Title,{className:`truncate text-body`,children:t.name})}),(0,U.jsx)(w,{size:`sm`,variant:`soft`,color:t.enabled?`success`:`default`,children:t.enabled?e(`enabled`):e(`disabled`)})]}),(0,U.jsxs)(f.Content,{className:`space-y-2.5 px-3 pb-2.5`,children:[(0,U.jsx)(`div`,{className:`mono w-full rounded-lg bg-surface-secondary px-3 py-2 text-body text-foreground`,title:t.prefix,children:t.prefix}),(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(t.providers.length?t.providers:[`all`]).map(t=>(0,U.jsx)(w,{size:`sm`,variant:`soft`,children:(0,U.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[t===`all`?(0,U.jsx)(T,{size:12}):(0,U.jsx)(F,{provider:ee(t),size:12}),(0,U.jsx)(`span`,{children:t===`all`?e(`keysAllProviders`):q(t,e)})]})},t)),t.model_aggregation?(0,U.jsx)(w,{size:`sm`,variant:`soft`,children:e(`keysModelAggregationBadge`)}):null]}),(0,U.jsxs)(`p`,{className:`text-caption leading-5 text-muted`,children:[t.max_inflight>0?e(`keysMaxInflightValue`,{count:t.max_inflight}):e(`keysMaxInflightUnlimited`),` · `,t.last_used_at?e(`keysLastUsed`,{time:te(t.last_used_at)}):e(`keysNeverUsed`)]})]}),(0,U.jsxs)(f.Footer,{className:`gap-1.5 bg-surface-secondary px-3 py-2`,children:[(0,U.jsx)(c,{size:`sm`,variant:`ghost`,isDisabled:!l,onPress:()=>J(t),children:e(`edit`)}),(0,U.jsx)(G,{label:e(`holdToDelete`),isPending:D===t.id,onConfirm:()=>void ae(t),children:(0,U.jsx)(o,{size:14})}),(0,U.jsx)(`div`,{className:`ml-auto`,children:(0,U.jsx)(v,{isSelected:t.enabled,isDisabled:D===t.id,ariaLabel:e(`enable`),onChange:e=>void ie(t,e)})})]})]},t.id))}):(0,U.jsx)(_,{className:`rounded-3xl bg-surface-secondary`,icon:(0,U.jsx)(E,{size:28}),title:e(`keysEmpty`),hint:e(`keysEmptyHint`),action:(0,U.jsxs)(c,{size:`sm`,isDisabled:!l,onPress:()=>L(!0),children:[(0,U.jsx)(a,{size:14}),e(`keysCreate`)]})}),(0,U.jsx)(Z,{isOpen:I,title:e(`keysCreateTitle`),hint:e(`keysCreateHint`),options:t,t:e,onClose:()=>L(!1),onSave:async e=>{let t=await V(e);y(e=>[t,...e.map(e=>({...e,secret:void 0}))]),L(!1),X(t)}}),(0,U.jsx)(Z,{isOpen:!!W,title:e(`keysEditTitle`),hint:e(`keysEditHint`),initial:W,options:t,t:e,onClose:()=>J(null),onSave:async e=>{if(!W)return;let t=await z(W.id,e);y(e=>e.map(e=>e.id===W.id?{...e,...t,secret:void 0}:e)),J(null)}}),(0,U.jsx)(x.Root,{isOpen:!!Y?.secret,onOpenChange:e=>{e||X(null)},children:(0,U.jsx)(x.Backdrop,{variant:`blur`,children:(0,U.jsx)(x.Container,{placement:`center`,size:`lg`,children:(0,U.jsxs)(x.Dialog,{children:[(0,U.jsxs)(x.Header,{className:`items-start justify-between gap-4 px-6 pt-6`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(x.Heading,{className:`text-section font-semibold`,children:e(`keysSecretTitle`)}),(0,U.jsx)(`p`,{className:`mt-1.5 text-body leading-6 text-muted`,children:e(`keysSecretHint`)})]}),(0,U.jsx)(x.CloseTrigger,{"aria-label":e(`close`),className:`grid size-9 place-items-center rounded-lg text-muted hover:bg-surface-secondary`,children:(0,U.jsx)(O,{size:18})})]}),(0,U.jsxs)(x.Body,{className:`px-6 pb-2`,children:[(0,U.jsxs)(u,{status:`warning`,className:`mb-4`,children:[(0,U.jsx)(u.Indicator,{}),(0,U.jsx)(u.Content,{children:(0,U.jsx)(u.Title,{children:e(`keysSecretOnce`)})})]}),(0,U.jsx)(`code`,{className:`mono block break-all rounded-lg bg-surface-secondary px-3 py-3 text-body`,children:Y?.secret})]}),(0,U.jsxs)(x.Footer,{className:`justify-end`,children:[(0,U.jsx)(c,{variant:`ghost`,onPress:()=>X(null),children:e(`close`)}),(0,U.jsxs)(c,{onPress:()=>{Y?.secret&&re(Y.secret)},children:[(0,U.jsx)(r,{size:14}),e(ne?`copied`:`copy`)]})]})]})})})})]})}function Z({isOpen:e,title:t,hint:n,initial:r,options:i,t:a,onClose:o,onSave:s}){let[d,f]=(0,H.useState)(r?.name||``),[_,S]=(0,H.useState)(r?.max_inflight||0),[C,w]=(0,H.useState)(r?.model_aggregation||!1),[T,E]=(0,H.useState)([]),[D,k]=(0,H.useState)(new Set),[A,j]=(0,H.useState)(!0),[M,N]=(0,H.useState)(``),[P,L]=(0,H.useState)(!1);(0,H.useEffect)(()=>{if(!e)return;f(r?.name||``),S(r?.max_inflight||0),w(!!r?.model_aggregation),E(J(r?.providers||[],i));let t=new Set((r?.providers||[]).filter(e=>!e.includes(`:`)).map(e=>e.toLowerCase()));k(t),j(!0),N(``)},[r,e,i]);function R(e){let t=i.find(t=>t.value===e);j(!1),E(n=>n.includes(e)?(t&&k(e=>{let n=new Set(e);return n.delete(t.provider),n}),n.filter(t=>t!==e)):[...n,e])}async function z(e){e?.preventDefault();let t=d.trim();if(!t){N(a(`keysNameRequired`));return}if(!Number.isInteger(_)||_<0||_>256){N(a(`keysMaxInflightInvalid`));return}if(!i.length){N(a(`keysProvidersNotLoaded`));return}L(!0),N(``);try{await s({name:t,providers:A?r?.providers||[]:T,max_inflight:_,model_aggregation:C})}catch(e){N(e instanceof Error?e.message:String(e))}finally{L(!1)}}return(0,U.jsx)(x.Root,{isOpen:e,onOpenChange:e=>{!e&&!P&&o()},children:(0,U.jsx)(x.Backdrop,{variant:`blur`,children:(0,U.jsx)(x.Container,{placement:`center`,size:`lg`,scroll:`inside`,children:(0,U.jsx)(x.Dialog,{className:`sm:min-w-[32rem]`,children:(0,U.jsxs)(p,{className:`flex min-h-0 flex-1 flex-col`,onSubmit:z,children:[(0,U.jsxs)(x.Header,{className:`items-start justify-between gap-4 px-6 pt-6`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(x.Heading,{className:`text-section font-semibold`,children:t}),(0,U.jsx)(`p`,{className:`mt-1.5 text-body leading-6 text-muted`,children:n})]}),(0,U.jsx)(x.CloseTrigger,{isDisabled:P,"aria-label":a(`close`),className:`grid size-9 place-items-center rounded-lg text-muted hover:bg-surface-secondary`,children:(0,U.jsx)(O,{size:18})})]}),(0,U.jsxs)(x.Body,{className:`space-y-5 px-6 pb-2 pt-1`,children:[M?(0,U.jsxs)(u,{status:`danger`,children:[(0,U.jsx)(u.Indicator,{}),(0,U.jsx)(u.Content,{children:(0,U.jsx)(u.Title,{children:M})})]}):null,(0,U.jsx)(b,{label:a(`keysName`),children:(0,U.jsx)(y,{value:d,onChange:e=>f(e.target.value),placeholder:a(`keysNamePh`),"aria-label":a(`keysName`)})}),(0,U.jsx)(b,{label:a(`keysMaxInflight`),hint:a(`keysMaxInflightHint`),children:(0,U.jsx)(h,{value:_,onChange:e=>S(e??0),minValue:0,maxValue:256,isDisabled:P,children:(0,U.jsxs)(h.Group,{children:[(0,U.jsx)(h.DecrementButton,{}),(0,U.jsx)(h.Input,{"aria-label":a(`keysMaxInflight`)}),(0,U.jsx)(h.IncrementButton,{})]})})}),(0,U.jsx)(b,{label:a(`keysModelAggregation`),hint:a(`keysModelAggregationHint`),children:(0,U.jsx)(v,{isSelected:C,isDisabled:P,ariaLabel:a(`keysModelAggregation`),onChange:w})}),(0,U.jsxs)(`div`,{className:`space-y-2`,children:[(0,U.jsx)(l,{className:`text-body font-medium text-muted`,children:a(`keysProviders`)}),(0,U.jsx)(g,{className:`text-caption leading-5 text-muted`,children:a(`keysProvidersHint`)}),i.length?(0,U.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:i.map(e=>{let t=T.includes(e.value),n=D.has(e.provider),r=P||C;return(0,U.jsx)(m,{isSelected:t,isDisabled:r,onChange:()=>R(e.value),className:`rounded-xl bg-surface-secondary px-3 py-2.5 data-selected:border-accent data-selected:bg-accent-soft ${r?`cursor-not-allowed opacity-50 grayscale`:``}`,children:(0,U.jsxs)(m.Content,{className:`flex items-center gap-2.5`,children:[(0,U.jsx)(m.Control,{children:(0,U.jsx)(m.Indicator,{})}),(0,U.jsx)(F,{provider:e.provider,size:16}),(0,U.jsx)(`span`,{className:`text-body font-medium`,children:I(e.provider,e.region,a)}),n?(0,U.jsx)(`span`,{className:`rounded-lg bg-surface-secondary px-1.5 py-0.5 text-caption font-medium text-muted`,children:a(`keysAllRegions`)}):null]})},e.value)})}):(0,U.jsx)(`p`,{className:`rounded-lg bg-surface-secondary px-3 py-2.5 text-caption leading-5 text-muted`,children:a(`keysProvidersNotLoaded`)}),(0,U.jsx)(`p`,{className:`text-caption text-muted`,children:Y(T,a)})]})]}),(0,U.jsxs)(x.Footer,{className:`justify-end`,children:[(0,U.jsx)(c,{variant:`ghost`,isDisabled:P,onPress:o,children:a(`cancel`)}),(0,U.jsx)(c,{type:`submit`,isPending:P,isDisabled:!i.length,children:a(r?`save`:`create`)})]})]})})})})})}export{X as KeysPage}; \ No newline at end of file diff --git a/internal/webui/static/assets/LatencyStats-DmxRwO-O.js b/internal/webui/static/assets/LatencyStats-lecg2Ory.js similarity index 94% rename from internal/webui/static/assets/LatencyStats-DmxRwO-O.js rename to internal/webui/static/assets/LatencyStats-lecg2Ory.js index 148fbb0c..cfe1e5f8 100644 --- a/internal/webui/static/assets/LatencyStats-DmxRwO-O.js +++ b/internal/webui/static/assets/LatencyStats-lecg2Ory.js @@ -1 +1 @@ -import{n as e}from"./shim-mfK0Rmj6.js";import{l as t,s as n,t as r}from"./format-B6SmebW-.js";var i=e();function a({latencyMs:e,ttfbMs:a,completionTokens:o,stream:s,labels:c,className:l=``,variant:u=`block`}){let d=t(r({completionTokens:o,latencyMs:e,ttfbMs:a,stream:s})),f=n(a),p=n(e);if(u===`inline`)return(0,i.jsxs)(`div`,{className:`mono text-caption leading-4 text-muted ${l}`.trim(),children:[(0,i.jsxs)(`span`,{children:[c.ttft,` `,f]}),(0,i.jsx)(`span`,{className:`mx-1.5 text-separator`,children:`·`}),(0,i.jsxs)(`span`,{children:[c.total,` `,p]}),(0,i.jsx)(`span`,{className:`mx-1.5 text-separator`,children:`·`}),(0,i.jsx)(`span`,{children:d})]});let m=[[c.ttft,f],[c.total,p],[c.tps,d]];return(0,i.jsxs)(`div`,{className:l,children:[c.heading?(0,i.jsx)(`div`,{className:`mb-1 text-caption font-medium text-muted`,children:c.heading}):null,(0,i.jsx)(`div`,{className:`border-l border-separator pl-2 leading-4`,children:m.map(([e,t])=>(0,i.jsxs)(`div`,{className:`flex items-baseline gap-2 py-px`,children:[(0,i.jsx)(`span`,{className:`shrink-0 text-caption text-muted`,children:e}),(0,i.jsx)(`span`,{className:`mono text-xs text-foreground`,children:t})]},e))})]})}export{a as t}; \ No newline at end of file +import{n as e}from"./shim-mfK0Rmj6.js";import{l as t,s as n,t as r}from"./format-kRpr2wxA.js";var i=e();function a({latencyMs:e,ttfbMs:a,completionTokens:o,stream:s,labels:c,className:l=``,variant:u=`block`}){let d=t(r({completionTokens:o,latencyMs:e,ttfbMs:a,stream:s})),f=n(a),p=n(e);if(u===`inline`)return(0,i.jsxs)(`div`,{className:`mono text-caption leading-4 text-muted ${l}`.trim(),children:[(0,i.jsxs)(`span`,{children:[c.ttft,` `,f]}),(0,i.jsx)(`span`,{className:`mx-1.5 text-separator`,children:`·`}),(0,i.jsxs)(`span`,{children:[c.total,` `,p]}),(0,i.jsx)(`span`,{className:`mx-1.5 text-separator`,children:`·`}),(0,i.jsx)(`span`,{children:d})]});let m=[[c.ttft,f],[c.total,p],[c.tps,d]];return(0,i.jsxs)(`div`,{className:l,children:[c.heading?(0,i.jsx)(`div`,{className:`mb-1 text-caption font-medium text-muted`,children:c.heading}):null,(0,i.jsx)(`div`,{className:`border-l border-separator pl-2 leading-4`,children:m.map(([e,t])=>(0,i.jsxs)(`div`,{className:`flex items-baseline gap-2 py-px`,children:[(0,i.jsx)(`span`,{className:`shrink-0 text-caption text-muted`,children:e}),(0,i.jsx)(`span`,{className:`mono text-xs text-foreground`,children:t})]},e))})]})}export{a as t}; \ No newline at end of file diff --git a/internal/webui/static/assets/LoginPage-BE11SySg.js b/internal/webui/static/assets/LoginPage-BE11SySg.js new file mode 100644 index 00000000..763e4f13 --- /dev/null +++ b/internal/webui/static/assets/LoginPage-BE11SySg.js @@ -0,0 +1 @@ +import{a as e,c as t,n}from"./shim-mfK0Rmj6.js";import{dt as r,n as i,r as a}from"./useI18n-BBOAnu2u.js";import{c as o,s,z as c}from"./SharedElementTransition-BlCsXfb1.js";import{m as l,r as u,t as d}from"./label-BVCjtfNQ.js";import{t as f}from"./PageAlert-DZC7IhXp.js";import{t as p}from"./card-QlCdtlk0.js";import{r as m,t as h}from"./textfield-DczGuWn0.js";import{P as g,j as _}from"./overview-CJvUvgoD.js";import{t as v}from"./textfield-BJXzgJRr.js";import{A as y,Bt as b,D as x,It as S,Mt as C,O as w,Xt as T,Yt as E,Zt as D,_ as O,k,r as A}from"./index-B9eWF6SH.js";var j=t(e(),1),M=new Map([[`bold`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M224.49,136.49l-72,72a12,12,0,0,1-17-17L187,140H40a12,12,0,0,1,0-24H187L135.51,64.48a12,12,0,0,1,17-17l72,72A12,12,0,0,1,224.49,136.49Z`}))],[`duotone`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M216,128l-72,72V56Z`,opacity:`0.2`}),j.createElement(`path`,{d:`M221.66,122.34l-72-72A8,8,0,0,0,136,56v64H40a8,8,0,0,0,0,16h96v64a8,8,0,0,0,13.66,5.66l72-72A8,8,0,0,0,221.66,122.34ZM152,180.69V75.31L204.69,128Z`}))],[`fill`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M221.66,133.66l-72,72A8,8,0,0,1,136,200V136H40a8,8,0,0,1,0-16h96V56a8,8,0,0,1,13.66-5.66l72,72A8,8,0,0,1,221.66,133.66Z`}))],[`light`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M220.24,132.24l-72,72a6,6,0,0,1-8.48-8.48L201.51,134H40a6,6,0,0,1,0-12H201.51L139.76,60.24a6,6,0,0,1,8.48-8.48l72,72A6,6,0,0,1,220.24,132.24Z`}))],[`regular`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M221.66,133.66l-72,72a8,8,0,0,1-11.32-11.32L196.69,136H40a8,8,0,0,1,0-16H196.69L138.34,61.66a8,8,0,0,1,11.32-11.32l72,72A8,8,0,0,1,221.66,133.66Z`}))],[`thin`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M218.83,130.83l-72,72a4,4,0,0,1-5.66-5.66L206.34,132H40a4,4,0,0,1,0-8H206.34L141.17,58.83a4,4,0,0,1,5.66-5.66l72,72A4,4,0,0,1,218.83,130.83Z`}))]]),N=new Map([[`bold`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M251,123.13c-.37-.81-9.13-20.26-28.48-39.61C196.63,57.67,164,44,128,44S59.37,57.67,33.51,83.52C14.16,102.87,5.4,122.32,5,123.13a12.08,12.08,0,0,0,0,9.75c.37.82,9.13,20.26,28.49,39.61C59.37,198.34,92,212,128,212s68.63-13.66,94.48-39.51c19.36-19.35,28.12-38.79,28.49-39.61A12.08,12.08,0,0,0,251,123.13Zm-46.06,33C183.47,177.27,157.59,188,128,188s-55.47-10.73-76.91-31.88A130.36,130.36,0,0,1,29.52,128,130.45,130.45,0,0,1,51.09,99.89C72.54,78.73,98.41,68,128,68s55.46,10.73,76.91,31.89A130.36,130.36,0,0,1,226.48,128,130.45,130.45,0,0,1,204.91,156.12ZM128,84a44,44,0,1,0,44,44A44.05,44.05,0,0,0,128,84Zm0,64a20,20,0,1,1,20-20A20,20,0,0,1,128,148Z`}))],[`duotone`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M128,56C48,56,16,128,16,128s32,72,112,72,112-72,112-72S208,56,128,56Zm0,112a40,40,0,1,1,40-40A40,40,0,0,1,128,168Z`,opacity:`0.2`}),j.createElement(`path`,{d:`M247.31,124.76c-.35-.79-8.82-19.58-27.65-38.41C194.57,61.26,162.88,48,128,48S61.43,61.26,36.34,86.35C17.51,105.18,9,124,8.69,124.76a8,8,0,0,0,0,6.5c.35.79,8.82,19.57,27.65,38.4C61.43,194.74,93.12,208,128,208s66.57-13.26,91.66-38.34c18.83-18.83,27.3-37.61,27.65-38.4A8,8,0,0,0,247.31,124.76ZM128,192c-30.78,0-57.67-11.19-79.93-33.25A133.47,133.47,0,0,1,25,128,133.33,133.33,0,0,1,48.07,97.25C70.33,75.19,97.22,64,128,64s57.67,11.19,79.93,33.25A133.46,133.46,0,0,1,231.05,128C223.84,141.46,192.43,192,128,192Zm0-112a48,48,0,1,0,48,48A48.05,48.05,0,0,0,128,80Zm0,80a32,32,0,1,1,32-32A32,32,0,0,1,128,160Z`}))],[`fill`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M247.31,124.76c-.35-.79-8.82-19.58-27.65-38.41C194.57,61.26,162.88,48,128,48S61.43,61.26,36.34,86.35C17.51,105.18,9,124,8.69,124.76a8,8,0,0,0,0,6.5c.35.79,8.82,19.57,27.65,38.4C61.43,194.74,93.12,208,128,208s66.57-13.26,91.66-38.34c18.83-18.83,27.3-37.61,27.65-38.4A8,8,0,0,0,247.31,124.76ZM128,168a40,40,0,1,1,40-40A40,40,0,0,1,128,168Z`}))],[`light`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M245.48,125.57c-.34-.78-8.66-19.23-27.24-37.81C201,70.54,171.38,50,128,50S55,70.54,37.76,87.76c-18.58,18.58-26.9,37-27.24,37.81a6,6,0,0,0,0,4.88c.34.77,8.66,19.22,27.24,37.8C55,185.47,84.62,206,128,206s73-20.53,90.24-37.75c18.58-18.58,26.9-37,27.24-37.8A6,6,0,0,0,245.48,125.57ZM128,194c-31.38,0-58.78-11.42-81.45-33.93A134.77,134.77,0,0,1,22.69,128,134.56,134.56,0,0,1,46.55,95.94C69.22,73.42,96.62,62,128,62s58.78,11.42,81.45,33.94A134.56,134.56,0,0,1,233.31,128C226.94,140.21,195,194,128,194Zm0-112a46,46,0,1,0,46,46A46.06,46.06,0,0,0,128,82Zm0,80a34,34,0,1,1,34-34A34,34,0,0,1,128,162Z`}))],[`regular`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M247.31,124.76c-.35-.79-8.82-19.58-27.65-38.41C194.57,61.26,162.88,48,128,48S61.43,61.26,36.34,86.35C17.51,105.18,9,124,8.69,124.76a8,8,0,0,0,0,6.5c.35.79,8.82,19.57,27.65,38.4C61.43,194.74,93.12,208,128,208s66.57-13.26,91.66-38.34c18.83-18.83,27.3-37.61,27.65-38.4A8,8,0,0,0,247.31,124.76ZM128,192c-30.78,0-57.67-11.19-79.93-33.25A133.47,133.47,0,0,1,25,128,133.33,133.33,0,0,1,48.07,97.25C70.33,75.19,97.22,64,128,64s57.67,11.19,79.93,33.25A133.46,133.46,0,0,1,231.05,128C223.84,141.46,192.43,192,128,192Zm0-112a48,48,0,1,0,48,48A48.05,48.05,0,0,0,128,80Zm0,80a32,32,0,1,1,32-32A32,32,0,0,1,128,160Z`}))],[`thin`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M243.66,126.38c-.34-.76-8.52-18.89-26.83-37.2C199.87,72.22,170.7,52,128,52S56.13,72.22,39.17,89.18c-18.31,18.31-26.49,36.44-26.83,37.2a4.08,4.08,0,0,0,0,3.25c.34.77,8.52,18.89,26.83,37.2,17,17,46.14,37.17,88.83,37.17s71.87-20.21,88.83-37.17c18.31-18.31,26.49-36.43,26.83-37.2A4.08,4.08,0,0,0,243.66,126.38Zm-32.7,35c-23.07,23-51,34.62-83,34.62s-59.89-11.65-83-34.62A135.71,135.71,0,0,1,20.44,128,135.69,135.69,0,0,1,45,94.62C68.11,71.65,96,60,128,60s59.89,11.65,83,34.62A135.79,135.79,0,0,1,235.56,128,135.71,135.71,0,0,1,211,161.38ZM128,84a44,44,0,1,0,44,44A44.05,44.05,0,0,0,128,84Zm0,80a36,36,0,1,1,36-36A36,36,0,0,1,128,164Z`}))]]),P=new Map([[`bold`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M56.88,31.93A12,12,0,1,0,39.12,48.07l16,17.65C20.67,88.66,5.72,121.58,5,123.13a12.08,12.08,0,0,0,0,9.75c.37.82,9.13,20.26,28.49,39.61C59.37,198.34,92,212,128,212a131.34,131.34,0,0,0,51-10l20.09,22.1a12,12,0,0,0,17.76-16.14ZM128,188c-29.59,0-55.47-10.73-76.91-31.88A130.69,130.69,0,0,1,29.52,128c5.27-9.31,18.79-29.9,42-44.29l90.09,99.11A109.33,109.33,0,0,1,128,188Zm123-55.12c-.36.81-9,20-28,39.16a12,12,0,1,1-17-16.9A130.48,130.48,0,0,0,226.48,128a130.36,130.36,0,0,0-21.57-28.12C183.46,78.73,157.59,68,128,68c-3.35,0-6.7.14-10,.42a12,12,0,1,1-2-23.91c3.93-.34,8-.51,12-.51,36,0,68.63,13.67,94.49,39.52,19.35,19.35,28.11,38.8,28.48,39.61A12.08,12.08,0,0,1,251,132.88Z`}))],[`duotone`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M128,56C48,56,16,128,16,128s32,72,112,72,112-72,112-72S208,56,128,56Zm0,112a40,40,0,1,1,40-40A40,40,0,0,1,128,168Z`,opacity:`0.2`}),j.createElement(`path`,{d:`M53.92,34.62A8,8,0,1,0,42.08,45.38L61.32,66.55C25,88.84,9.38,123.2,8.69,124.76a8,8,0,0,0,0,6.5c.35.79,8.82,19.57,27.65,38.4C61.43,194.74,93.12,208,128,208a127.11,127.11,0,0,0,52.07-10.83l22,24.21a8,8,0,1,0,11.84-10.76Zm47.33,75.84,41.67,45.85a32,32,0,0,1-41.67-45.85ZM128,192c-30.78,0-57.67-11.19-79.93-33.25A133.16,133.16,0,0,1,25,128c4.69-8.79,19.66-33.39,47.35-49.38l18,19.75a48,48,0,0,0,63.66,70l14.73,16.2A112,112,0,0,1,128,192Zm6-95.43a8,8,0,0,1,3-15.72,48.16,48.16,0,0,1,38.77,42.64,8,8,0,0,1-7.22,8.71,6.39,6.39,0,0,1-.75,0,8,8,0,0,1-8-7.26A32.09,32.09,0,0,0,134,96.57Zm113.28,34.69c-.42.94-10.55,23.37-33.36,43.8a8,8,0,1,1-10.67-11.92A132.77,132.77,0,0,0,231.05,128a133.15,133.15,0,0,0-23.12-30.77C185.67,75.19,158.78,64,128,64a118.37,118.37,0,0,0-19.36,1.57A8,8,0,1,1,106,49.79,134,134,0,0,1,128,48c34.88,0,66.57,13.26,91.66,38.35,18.83,18.83,27.3,37.62,27.65,38.41A8,8,0,0,1,247.31,131.26Z`}))],[`fill`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M96.68,57.87a4,4,0,0,1,2.08-6.6A130.13,130.13,0,0,1,128,48c34.88,0,66.57,13.26,91.66,38.35,18.83,18.83,27.3,37.62,27.65,38.41a8,8,0,0,1,0,6.5c-.35.79-8.82,19.57-27.65,38.4q-4.28,4.26-8.79,8.07a4,4,0,0,1-5.55-.36ZM213.92,210.62a8,8,0,1,1-11.84,10.76L180,197.13A127.21,127.21,0,0,1,128,208c-34.88,0-66.57-13.26-91.66-38.34C17.51,150.83,9,132.05,8.69,131.26a8,8,0,0,1,0-6.5C9,124,17.51,105.18,36.34,86.35a135,135,0,0,1,25-19.78L42.08,45.38A8,8,0,1,1,53.92,34.62Zm-65.49-48.25-52.69-58a40,40,0,0,0,52.69,58Z`}))],[`light`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M52.44,36A6,6,0,0,0,43.56,44L64.44,67c-37.28,21.9-53.23,57-53.92,58.57a6,6,0,0,0,0,4.88c.34.77,8.66,19.22,27.24,37.8C55,185.47,84.62,206,128,206a124.91,124.91,0,0,0,52.57-11.25l23,25.29a6,6,0,0,0,8.88-8.08Zm48.62,71.32,45,49.52a34,34,0,0,1-45-49.52ZM128,194c-31.38,0-58.78-11.42-81.45-33.93A134.57,134.57,0,0,1,22.69,128c4.29-8.2,20.1-35.18,50-51.91L92.89,98.3a46,46,0,0,0,61.35,67.48l17.81,19.6A113.47,113.47,0,0,1,128,194Zm6.4-99.4a6,6,0,0,1,2.25-11.79,46.17,46.17,0,0,1,37.15,40.87,6,6,0,0,1-5.42,6.53l-.56,0a6,6,0,0,1-6-5.45A34.1,34.1,0,0,0,134.4,94.6Zm111.08,35.85c-.41.92-10.37,23-32.86,43.12a6,6,0,1,1-8-8.94A134.07,134.07,0,0,0,233.31,128a134.67,134.67,0,0,0-23.86-32.07C186.78,73.42,159.38,62,128,62a120.19,120.19,0,0,0-19.69,1.6,6,6,0,1,1-2-11.83A131.12,131.12,0,0,1,128,50c43.38,0,73,20.54,90.24,37.76,18.58,18.58,26.9,37,27.24,37.81A6,6,0,0,1,245.48,130.45Z`}))],[`regular`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M53.92,34.62A8,8,0,1,0,42.08,45.38L61.32,66.55C25,88.84,9.38,123.2,8.69,124.76a8,8,0,0,0,0,6.5c.35.79,8.82,19.57,27.65,38.4C61.43,194.74,93.12,208,128,208a127.11,127.11,0,0,0,52.07-10.83l22,24.21a8,8,0,1,0,11.84-10.76Zm47.33,75.84,41.67,45.85a32,32,0,0,1-41.67-45.85ZM128,192c-30.78,0-57.67-11.19-79.93-33.25A133.16,133.16,0,0,1,25,128c4.69-8.79,19.66-33.39,47.35-49.38l18,19.75a48,48,0,0,0,63.66,70l14.73,16.2A112,112,0,0,1,128,192Zm6-95.43a8,8,0,0,1,3-15.72,48.16,48.16,0,0,1,38.77,42.64,8,8,0,0,1-7.22,8.71,6.39,6.39,0,0,1-.75,0,8,8,0,0,1-8-7.26A32.09,32.09,0,0,0,134,96.57Zm113.28,34.69c-.42.94-10.55,23.37-33.36,43.8a8,8,0,1,1-10.67-11.92A132.77,132.77,0,0,0,231.05,128a133.15,133.15,0,0,0-23.12-30.77C185.67,75.19,158.78,64,128,64a118.37,118.37,0,0,0-19.36,1.57A8,8,0,1,1,106,49.79,134,134,0,0,1,128,48c34.88,0,66.57,13.26,91.66,38.35,18.83,18.83,27.3,37.62,27.65,38.41A8,8,0,0,1,247.31,131.26Z`}))],[`thin`,j.createElement(j.Fragment,null,j.createElement(`path`,{d:`M51,37.31A4,4,0,0,0,45,42.69L67.59,67.5C29.34,89,13,124.81,12.34,126.38a4.08,4.08,0,0,0,0,3.25c.34.77,8.52,18.89,26.83,37.2,17,17,46.14,37.17,88.83,37.17a122.59,122.59,0,0,0,53.06-11.69l24,26.38a4,4,0,1,0,5.92-5.38ZM149.1,157.16A36,36,0,0,1,101,104.22ZM128,196c-32,0-59.89-11.65-83-34.62A135.81,135.81,0,0,1,20.44,128c3.65-7.23,20.09-36.81,52.68-54.43l22.45,24.7a44,44,0,0,0,59,64.83l20.89,23A114.94,114.94,0,0,1,128,196Zm6.78-103.36a4,4,0,0,1,1.49-7.86,44.15,44.15,0,0,1,35.54,39.09,4,4,0,0,1-3.61,4.35l-.38,0a4,4,0,0,1-4-3.63A36.1,36.1,0,0,0,134.78,92.64Zm108.88,37c-.41.91-10.2,22.58-32.38,42.45a4,4,0,0,1-2.67,1,4,4,0,0,1-2.67-7A136.71,136.71,0,0,0,235.56,128,136.07,136.07,0,0,0,211,94.62C187.89,71.65,160,60,128,60a122,122,0,0,0-20,1.63,4,4,0,0,1-1.32-7.89A129.3,129.3,0,0,1,128,52c42.7,0,71.87,20.22,88.83,37.18,18.31,18.31,26.49,36.44,26.83,37.2A4.08,4.08,0,0,1,243.66,129.63Z`}))]]),F=j.forwardRef((e,t)=>j.createElement(r,{ref:t,...e,weights:M}));F.displayName=`ArrowRightIcon`;var I=F,L=j.forwardRef((e,t)=>j.createElement(r,{ref:t,...e,weights:N}));L.displayName=`EyeIcon`;var R=L,z=j.forwardRef((e,t)=>j.createElement(r,{ref:t,...e,weights:P}));z.displayName=`EyeSlashIcon`;var B=z,V=c({defaultVariants:{fullWidth:!1,variant:`primary`},slots:{base:`input-group`,input:`input-group__input`,prefix:`input-group__prefix`,suffix:`input-group__suffix`},variants:{fullWidth:{false:{},true:{base:`input-group--full-width`}},variant:{primary:{base:`input-group--primary`},secondary:{base:`input-group--secondary`}}}}),H=n(),U=(0,j.createContext)({}),W=({children:e,className:t,fullWidth:n,onClick:r,variant:i,...a})=>{let s=(0,j.use)(h),c=i??s?.variant,u=j.useRef(null),d=j.useMemo(()=>V({fullWidth:n,variant:c}),[n,c]),f=e=>{let t=e.target,n=u.current?.querySelector(`input`);n&&t!==n&&!n.contains(t)&&n.focus(),r?.(e)};return(0,H.jsx)(U,{value:{slots:d},children:(0,H.jsx)(l,{...a,ref:u,className:o(t,d?.base()),"data-slot":`input-group`,onClick:f,children:t=>typeof e==`function`?e(t):e})})},G=Object.assign(W,{Root:W,Input:({className:e,...t})=>{let{slots:n}=(0,j.use)(U);return(0,H.jsx)(u,{className:o(e,n?.input()),"data-slot":`input-group-input`,...t})},TextArea:({className:e,...t})=>{let{slots:n}=(0,j.use)(U);return(0,H.jsx)(m,{className:o(e,n?.input()),"data-slot":`input-group-textarea`,...t})},Prefix:({children:e,className:t,...n})=>{let{slots:r}=(0,j.use)(U);return(0,H.jsx)(`div`,{className:s(r?.prefix,t),"data-slot":`input-group-prefix`,...n,children:e})},Suffix:({children:e,className:t,...n})=>{let{slots:r}=(0,j.use)(U);return(0,H.jsx)(`div`,{className:s(r?.suffix,t),"data-slot":`input-group-suffix`,...n,children:e})}});function K(){let{t:e,lang:t,setLang:n}=i(),{setApiKey:r}=g(),{overview:o,refresh:s}=w(),{theme:c,toggleTheme:l}=x(),[u,m]=(0,j.useState)(``),[h,M]=(0,j.useState)(!1),[N,P]=(0,j.useState)(!1),[F,L]=(0,j.useState)(``),z=D(),V=T().state?.from||`/`,U=(0,j.useRef)(null);if(A(U,`login`),o)return(0,H.jsx)(E,{to:V===`/login`?`/`:V,replace:!0});async function W(t){t.preventDefault();let n=u.trim();if(!n){L(e(`loginNeedKey`));return}P(!0),L(``);try{r(n),await s(n),z(V===`/login`?`/`:V,{replace:!0})}catch(t){L(_(t)?e(`loginBadKey`):t instanceof Error?t.message:String(t))}finally{P(!1)}}return(0,H.jsxs)(`div`,{className:`relative min-h-dvh overflow-hidden bg-background text-foreground`,children:[(0,H.jsx)(`div`,{className:`absolute inset-x-0 top-0 h-px bg-border`}),(0,H.jsxs)(`main`,{ref:U,className:`relative z-10 mx-auto grid min-h-dvh w-full max-w-[1480px] lg:grid-cols-[minmax(0,1fr)_minmax(380px,30rem)]`,children:[(0,H.jsxs)(`section`,{className:`flex min-h-[52vh] flex-col px-5 py-6 sm:px-8 sm:py-8 lg:min-h-dvh lg:px-8 lg:py-10 xl:px-10`,children:[(0,H.jsxs)(`header`,{className:`flex items-center justify-between gap-4`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,H.jsx)(O,{size:36}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`div`,{className:`font-semibold`,children:`CLI2API`}),(0,H.jsx)(`div`,{className:`text-caption text-muted`,children:e(`controlPlane`)})]})]}),(0,H.jsxs)(y,{isAttached:!0,children:[(0,H.jsxs)(k,{children:[(0,H.jsx)(k.Trigger,{children:(0,H.jsx)(a,{isIconOnly:!0,size:`sm`,variant:`ghost`,onPress:()=>n(t===`zh`?`en`:`zh`),"aria-label":t===`zh`?`English`:`中文`,children:(0,H.jsx)(b,{size:15})})}),(0,H.jsx)(k.Content,{children:t===`zh`?`English`:`中文`})]}),(0,H.jsxs)(k,{children:[(0,H.jsx)(k.Trigger,{children:(0,H.jsx)(a,{isIconOnly:!0,size:`sm`,variant:`ghost`,onPress:l,"aria-label":c===`dark`?`Light mode`:`Dark mode`,children:c===`dark`?(0,H.jsx)(C,{size:15}):(0,H.jsx)(S,{size:15})})}),(0,H.jsx)(k.Content,{children:c===`dark`?`Light mode`:`Dark mode`})]})]})]}),(0,H.jsxs)(`footer`,{className:`mt-auto hidden items-center justify-between text-caption text-muted lg:flex`,children:[(0,H.jsx)(`span`,{children:e(`loginHint`)}),(0,H.jsx)(`span`,{children:e(`routesHint`)})]})]}),(0,H.jsx)(`section`,{className:`flex items-center px-5 py-10 sm:px-8 lg:px-8 xl:px-10`,children:(0,H.jsx)(p,{"data-gsap-reveal":!0,variant:`transparent`,className:`w-full bg-transparent p-0 shadow-none`,children:(0,H.jsxs)(`form`,{onSubmit:e=>void W(e),children:[(0,H.jsx)(p.Header,{className:`px-2 py-6 sm:px-4`,children:(0,H.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,H.jsx)(O,{size:28,loading:N}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(p.Title,{className:`text-title`,children:e(`loginFormTitle`)}),(0,H.jsx)(p.Description,{className:`mt-1`,children:e(`loginDesc`)})]})]})}),(0,H.jsxs)(p.Content,{className:`space-y-5 px-6 py-7 sm:px-8 sm:py-8`,children:[(0,H.jsxs)(v,{name:`console-password`,className:`w-full`,isInvalid:!!F,children:[(0,H.jsx)(d,{children:e(`loginPassword`)}),(0,H.jsxs)(G,{children:[(0,H.jsx)(G.Input,{id:`console-password`,type:h?`text`:`password`,value:u,onChange:e=>m(e.target.value),placeholder:e(`loginPasswordPh`),autoComplete:`current-password`,autoFocus:!0,"aria-label":e(`loginPassword`),spellCheck:!1}),(0,H.jsx)(G.Suffix,{children:(0,H.jsx)(a,{isIconOnly:!0,size:`sm`,variant:`ghost`,type:`button`,"aria-label":e(h?`hidePassword`:`showPassword`),onPress:()=>M(e=>!e),children:h?(0,H.jsx)(B,{size:16}):(0,H.jsx)(R,{size:16})})})]})]}),F?(0,H.jsx)(f,{title:F}):(0,H.jsx)(`p`,{className:`text-caption text-muted`,children:e(`loginHint`)}),(0,H.jsxs)(a,{type:`submit`,fullWidth:!0,size:`lg`,isPending:N,children:[e(N?`loggingInConsole`:`loginSubmit`),N?null:(0,H.jsx)(I,{size:17})]})]})]})})})]})]})}export{K as LoginPage}; \ No newline at end of file diff --git a/internal/webui/static/assets/LoginPage-CD-WFiat.js b/internal/webui/static/assets/LoginPage-CD-WFiat.js deleted file mode 100644 index 96fce7fc..00000000 --- a/internal/webui/static/assets/LoginPage-CD-WFiat.js +++ /dev/null @@ -1 +0,0 @@ -import{a as e,c as t,n}from"./shim-mfK0Rmj6.js";import{t as r}from"./InflightLiveCard-cw_BuJ7y.js";import{n as i,pt as a,r as o}from"./useI18n-BSw4X3mq.js";import{c as s,s as c,z as l}from"./SharedElementTransition-BlCsXfb1.js";import{h as u,r as d,t as f}from"./label-n7vfsS35.js";import{t as p}from"./PageAlert-CaDjxveS.js";import{n as m}from"./useToggle-HDaAPzVy.js";import{r as h,t as g}from"./textfield-IBBKEG4T.js";import{j as _,k as v}from"./overview-m01k08K8.js";import{t as y}from"./textfield-v0vQVfYo.js";import{A as b,At as x,D as S,Jt as C,O as w,Pt as T,Rt as E,Yt as D,_ as O,k,qt as A,r as j}from"./index-C8_qeOs_.js";var M=t(e(),1),N=new Map([[`bold`,M.createElement(M.Fragment,null,M.createElement(`path`,{d:`M224.49,136.49l-72,72a12,12,0,0,1-17-17L187,140H40a12,12,0,0,1,0-24H187L135.51,64.48a12,12,0,0,1,17-17l72,72A12,12,0,0,1,224.49,136.49Z`}))],[`duotone`,M.createElement(M.Fragment,null,M.createElement(`path`,{d:`M216,128l-72,72V56Z`,opacity:`0.2`}),M.createElement(`path`,{d:`M221.66,122.34l-72-72A8,8,0,0,0,136,56v64H40a8,8,0,0,0,0,16h96v64a8,8,0,0,0,13.66,5.66l72-72A8,8,0,0,0,221.66,122.34ZM152,180.69V75.31L204.69,128Z`}))],[`fill`,M.createElement(M.Fragment,null,M.createElement(`path`,{d:`M221.66,133.66l-72,72A8,8,0,0,1,136,200V136H40a8,8,0,0,1,0-16h96V56a8,8,0,0,1,13.66-5.66l72,72A8,8,0,0,1,221.66,133.66Z`}))],[`light`,M.createElement(M.Fragment,null,M.createElement(`path`,{d:`M220.24,132.24l-72,72a6,6,0,0,1-8.48-8.48L201.51,134H40a6,6,0,0,1,0-12H201.51L139.76,60.24a6,6,0,0,1,8.48-8.48l72,72A6,6,0,0,1,220.24,132.24Z`}))],[`regular`,M.createElement(M.Fragment,null,M.createElement(`path`,{d:`M221.66,133.66l-72,72a8,8,0,0,1-11.32-11.32L196.69,136H40a8,8,0,0,1,0-16H196.69L138.34,61.66a8,8,0,0,1,11.32-11.32l72,72A8,8,0,0,1,221.66,133.66Z`}))],[`thin`,M.createElement(M.Fragment,null,M.createElement(`path`,{d:`M218.83,130.83l-72,72a4,4,0,0,1-5.66-5.66L206.34,132H40a4,4,0,0,1,0-8H206.34L141.17,58.83a4,4,0,0,1,5.66-5.66l72,72A4,4,0,0,1,218.83,130.83Z`}))]]),P=new Map([[`bold`,M.createElement(M.Fragment,null,M.createElement(`path`,{d:`M251,123.13c-.37-.81-9.13-20.26-28.48-39.61C196.63,57.67,164,44,128,44S59.37,57.67,33.51,83.52C14.16,102.87,5.4,122.32,5,123.13a12.08,12.08,0,0,0,0,9.75c.37.82,9.13,20.26,28.49,39.61C59.37,198.34,92,212,128,212s68.63-13.66,94.48-39.51c19.36-19.35,28.12-38.79,28.49-39.61A12.08,12.08,0,0,0,251,123.13Zm-46.06,33C183.47,177.27,157.59,188,128,188s-55.47-10.73-76.91-31.88A130.36,130.36,0,0,1,29.52,128,130.45,130.45,0,0,1,51.09,99.89C72.54,78.73,98.41,68,128,68s55.46,10.73,76.91,31.89A130.36,130.36,0,0,1,226.48,128,130.45,130.45,0,0,1,204.91,156.12ZM128,84a44,44,0,1,0,44,44A44.05,44.05,0,0,0,128,84Zm0,64a20,20,0,1,1,20-20A20,20,0,0,1,128,148Z`}))],[`duotone`,M.createElement(M.Fragment,null,M.createElement(`path`,{d:`M128,56C48,56,16,128,16,128s32,72,112,72,112-72,112-72S208,56,128,56Zm0,112a40,40,0,1,1,40-40A40,40,0,0,1,128,168Z`,opacity:`0.2`}),M.createElement(`path`,{d:`M247.31,124.76c-.35-.79-8.82-19.58-27.65-38.41C194.57,61.26,162.88,48,128,48S61.43,61.26,36.34,86.35C17.51,105.18,9,124,8.69,124.76a8,8,0,0,0,0,6.5c.35.79,8.82,19.57,27.65,38.4C61.43,194.74,93.12,208,128,208s66.57-13.26,91.66-38.34c18.83-18.83,27.3-37.61,27.65-38.4A8,8,0,0,0,247.31,124.76ZM128,192c-30.78,0-57.67-11.19-79.93-33.25A133.47,133.47,0,0,1,25,128,133.33,133.33,0,0,1,48.07,97.25C70.33,75.19,97.22,64,128,64s57.67,11.19,79.93,33.25A133.46,133.46,0,0,1,231.05,128C223.84,141.46,192.43,192,128,192Zm0-112a48,48,0,1,0,48,48A48.05,48.05,0,0,0,128,80Zm0,80a32,32,0,1,1,32-32A32,32,0,0,1,128,160Z`}))],[`fill`,M.createElement(M.Fragment,null,M.createElement(`path`,{d:`M247.31,124.76c-.35-.79-8.82-19.58-27.65-38.41C194.57,61.26,162.88,48,128,48S61.43,61.26,36.34,86.35C17.51,105.18,9,124,8.69,124.76a8,8,0,0,0,0,6.5c.35.79,8.82,19.57,27.65,38.4C61.43,194.74,93.12,208,128,208s66.57-13.26,91.66-38.34c18.83-18.83,27.3-37.61,27.65-38.4A8,8,0,0,0,247.31,124.76ZM128,168a40,40,0,1,1,40-40A40,40,0,0,1,128,168Z`}))],[`light`,M.createElement(M.Fragment,null,M.createElement(`path`,{d:`M245.48,125.57c-.34-.78-8.66-19.23-27.24-37.81C201,70.54,171.38,50,128,50S55,70.54,37.76,87.76c-18.58,18.58-26.9,37-27.24,37.81a6,6,0,0,0,0,4.88c.34.77,8.66,19.22,27.24,37.8C55,185.47,84.62,206,128,206s73-20.53,90.24-37.75c18.58-18.58,26.9-37,27.24-37.8A6,6,0,0,0,245.48,125.57ZM128,194c-31.38,0-58.78-11.42-81.45-33.93A134.77,134.77,0,0,1,22.69,128,134.56,134.56,0,0,1,46.55,95.94C69.22,73.42,96.62,62,128,62s58.78,11.42,81.45,33.94A134.56,134.56,0,0,1,233.31,128C226.94,140.21,195,194,128,194Zm0-112a46,46,0,1,0,46,46A46.06,46.06,0,0,0,128,82Zm0,80a34,34,0,1,1,34-34A34,34,0,0,1,128,162Z`}))],[`regular`,M.createElement(M.Fragment,null,M.createElement(`path`,{d:`M247.31,124.76c-.35-.79-8.82-19.58-27.65-38.41C194.57,61.26,162.88,48,128,48S61.43,61.26,36.34,86.35C17.51,105.18,9,124,8.69,124.76a8,8,0,0,0,0,6.5c.35.79,8.82,19.57,27.65,38.4C61.43,194.74,93.12,208,128,208s66.57-13.26,91.66-38.34c18.83-18.83,27.3-37.61,27.65-38.4A8,8,0,0,0,247.31,124.76ZM128,192c-30.78,0-57.67-11.19-79.93-33.25A133.47,133.47,0,0,1,25,128,133.33,133.33,0,0,1,48.07,97.25C70.33,75.19,97.22,64,128,64s57.67,11.19,79.93,33.25A133.46,133.46,0,0,1,231.05,128C223.84,141.46,192.43,192,128,192Zm0-112a48,48,0,1,0,48,48A48.05,48.05,0,0,0,128,80Zm0,80a32,32,0,1,1,32-32A32,32,0,0,1,128,160Z`}))],[`thin`,M.createElement(M.Fragment,null,M.createElement(`path`,{d:`M243.66,126.38c-.34-.76-8.52-18.89-26.83-37.2C199.87,72.22,170.7,52,128,52S56.13,72.22,39.17,89.18c-18.31,18.31-26.49,36.44-26.83,37.2a4.08,4.08,0,0,0,0,3.25c.34.77,8.52,18.89,26.83,37.2,17,17,46.14,37.17,88.83,37.17s71.87-20.21,88.83-37.17c18.31-18.31,26.49-36.43,26.83-37.2A4.08,4.08,0,0,0,243.66,126.38Zm-32.7,35c-23.07,23-51,34.62-83,34.62s-59.89-11.65-83-34.62A135.71,135.71,0,0,1,20.44,128,135.69,135.69,0,0,1,45,94.62C68.11,71.65,96,60,128,60s59.89,11.65,83,34.62A135.79,135.79,0,0,1,235.56,128,135.71,135.71,0,0,1,211,161.38ZM128,84a44,44,0,1,0,44,44A44.05,44.05,0,0,0,128,84Zm0,80a36,36,0,1,1,36-36A36,36,0,0,1,128,164Z`}))]]),F=new Map([[`bold`,M.createElement(M.Fragment,null,M.createElement(`path`,{d:`M56.88,31.93A12,12,0,1,0,39.12,48.07l16,17.65C20.67,88.66,5.72,121.58,5,123.13a12.08,12.08,0,0,0,0,9.75c.37.82,9.13,20.26,28.49,39.61C59.37,198.34,92,212,128,212a131.34,131.34,0,0,0,51-10l20.09,22.1a12,12,0,0,0,17.76-16.14ZM128,188c-29.59,0-55.47-10.73-76.91-31.88A130.69,130.69,0,0,1,29.52,128c5.27-9.31,18.79-29.9,42-44.29l90.09,99.11A109.33,109.33,0,0,1,128,188Zm123-55.12c-.36.81-9,20-28,39.16a12,12,0,1,1-17-16.9A130.48,130.48,0,0,0,226.48,128a130.36,130.36,0,0,0-21.57-28.12C183.46,78.73,157.59,68,128,68c-3.35,0-6.7.14-10,.42a12,12,0,1,1-2-23.91c3.93-.34,8-.51,12-.51,36,0,68.63,13.67,94.49,39.52,19.35,19.35,28.11,38.8,28.48,39.61A12.08,12.08,0,0,1,251,132.88Z`}))],[`duotone`,M.createElement(M.Fragment,null,M.createElement(`path`,{d:`M128,56C48,56,16,128,16,128s32,72,112,72,112-72,112-72S208,56,128,56Zm0,112a40,40,0,1,1,40-40A40,40,0,0,1,128,168Z`,opacity:`0.2`}),M.createElement(`path`,{d:`M53.92,34.62A8,8,0,1,0,42.08,45.38L61.32,66.55C25,88.84,9.38,123.2,8.69,124.76a8,8,0,0,0,0,6.5c.35.79,8.82,19.57,27.65,38.4C61.43,194.74,93.12,208,128,208a127.11,127.11,0,0,0,52.07-10.83l22,24.21a8,8,0,1,0,11.84-10.76Zm47.33,75.84,41.67,45.85a32,32,0,0,1-41.67-45.85ZM128,192c-30.78,0-57.67-11.19-79.93-33.25A133.16,133.16,0,0,1,25,128c4.69-8.79,19.66-33.39,47.35-49.38l18,19.75a48,48,0,0,0,63.66,70l14.73,16.2A112,112,0,0,1,128,192Zm6-95.43a8,8,0,0,1,3-15.72,48.16,48.16,0,0,1,38.77,42.64,8,8,0,0,1-7.22,8.71,6.39,6.39,0,0,1-.75,0,8,8,0,0,1-8-7.26A32.09,32.09,0,0,0,134,96.57Zm113.28,34.69c-.42.94-10.55,23.37-33.36,43.8a8,8,0,1,1-10.67-11.92A132.77,132.77,0,0,0,231.05,128a133.15,133.15,0,0,0-23.12-30.77C185.67,75.19,158.78,64,128,64a118.37,118.37,0,0,0-19.36,1.57A8,8,0,1,1,106,49.79,134,134,0,0,1,128,48c34.88,0,66.57,13.26,91.66,38.35,18.83,18.83,27.3,37.62,27.65,38.41A8,8,0,0,1,247.31,131.26Z`}))],[`fill`,M.createElement(M.Fragment,null,M.createElement(`path`,{d:`M96.68,57.87a4,4,0,0,1,2.08-6.6A130.13,130.13,0,0,1,128,48c34.88,0,66.57,13.26,91.66,38.35,18.83,18.83,27.3,37.62,27.65,38.41a8,8,0,0,1,0,6.5c-.35.79-8.82,19.57-27.65,38.4q-4.28,4.26-8.79,8.07a4,4,0,0,1-5.55-.36ZM213.92,210.62a8,8,0,1,1-11.84,10.76L180,197.13A127.21,127.21,0,0,1,128,208c-34.88,0-66.57-13.26-91.66-38.34C17.51,150.83,9,132.05,8.69,131.26a8,8,0,0,1,0-6.5C9,124,17.51,105.18,36.34,86.35a135,135,0,0,1,25-19.78L42.08,45.38A8,8,0,1,1,53.92,34.62Zm-65.49-48.25-52.69-58a40,40,0,0,0,52.69,58Z`}))],[`light`,M.createElement(M.Fragment,null,M.createElement(`path`,{d:`M52.44,36A6,6,0,0,0,43.56,44L64.44,67c-37.28,21.9-53.23,57-53.92,58.57a6,6,0,0,0,0,4.88c.34.77,8.66,19.22,27.24,37.8C55,185.47,84.62,206,128,206a124.91,124.91,0,0,0,52.57-11.25l23,25.29a6,6,0,0,0,8.88-8.08Zm48.62,71.32,45,49.52a34,34,0,0,1-45-49.52ZM128,194c-31.38,0-58.78-11.42-81.45-33.93A134.57,134.57,0,0,1,22.69,128c4.29-8.2,20.1-35.18,50-51.91L92.89,98.3a46,46,0,0,0,61.35,67.48l17.81,19.6A113.47,113.47,0,0,1,128,194Zm6.4-99.4a6,6,0,0,1,2.25-11.79,46.17,46.17,0,0,1,37.15,40.87,6,6,0,0,1-5.42,6.53l-.56,0a6,6,0,0,1-6-5.45A34.1,34.1,0,0,0,134.4,94.6Zm111.08,35.85c-.41.92-10.37,23-32.86,43.12a6,6,0,1,1-8-8.94A134.07,134.07,0,0,0,233.31,128a134.67,134.67,0,0,0-23.86-32.07C186.78,73.42,159.38,62,128,62a120.19,120.19,0,0,0-19.69,1.6,6,6,0,1,1-2-11.83A131.12,131.12,0,0,1,128,50c43.38,0,73,20.54,90.24,37.76,18.58,18.58,26.9,37,27.24,37.81A6,6,0,0,1,245.48,130.45Z`}))],[`regular`,M.createElement(M.Fragment,null,M.createElement(`path`,{d:`M53.92,34.62A8,8,0,1,0,42.08,45.38L61.32,66.55C25,88.84,9.38,123.2,8.69,124.76a8,8,0,0,0,0,6.5c.35.79,8.82,19.57,27.65,38.4C61.43,194.74,93.12,208,128,208a127.11,127.11,0,0,0,52.07-10.83l22,24.21a8,8,0,1,0,11.84-10.76Zm47.33,75.84,41.67,45.85a32,32,0,0,1-41.67-45.85ZM128,192c-30.78,0-57.67-11.19-79.93-33.25A133.16,133.16,0,0,1,25,128c4.69-8.79,19.66-33.39,47.35-49.38l18,19.75a48,48,0,0,0,63.66,70l14.73,16.2A112,112,0,0,1,128,192Zm6-95.43a8,8,0,0,1,3-15.72,48.16,48.16,0,0,1,38.77,42.64,8,8,0,0,1-7.22,8.71,6.39,6.39,0,0,1-.75,0,8,8,0,0,1-8-7.26A32.09,32.09,0,0,0,134,96.57Zm113.28,34.69c-.42.94-10.55,23.37-33.36,43.8a8,8,0,1,1-10.67-11.92A132.77,132.77,0,0,0,231.05,128a133.15,133.15,0,0,0-23.12-30.77C185.67,75.19,158.78,64,128,64a118.37,118.37,0,0,0-19.36,1.57A8,8,0,1,1,106,49.79,134,134,0,0,1,128,48c34.88,0,66.57,13.26,91.66,38.35,18.83,18.83,27.3,37.62,27.65,38.41A8,8,0,0,1,247.31,131.26Z`}))],[`thin`,M.createElement(M.Fragment,null,M.createElement(`path`,{d:`M51,37.31A4,4,0,0,0,45,42.69L67.59,67.5C29.34,89,13,124.81,12.34,126.38a4.08,4.08,0,0,0,0,3.25c.34.77,8.52,18.89,26.83,37.2,17,17,46.14,37.17,88.83,37.17a122.59,122.59,0,0,0,53.06-11.69l24,26.38a4,4,0,1,0,5.92-5.38ZM149.1,157.16A36,36,0,0,1,101,104.22ZM128,196c-32,0-59.89-11.65-83-34.62A135.81,135.81,0,0,1,20.44,128c3.65-7.23,20.09-36.81,52.68-54.43l22.45,24.7a44,44,0,0,0,59,64.83l20.89,23A114.94,114.94,0,0,1,128,196Zm6.78-103.36a4,4,0,0,1,1.49-7.86,44.15,44.15,0,0,1,35.54,39.09,4,4,0,0,1-3.61,4.35l-.38,0a4,4,0,0,1-4-3.63A36.1,36.1,0,0,0,134.78,92.64Zm108.88,37c-.41.91-10.2,22.58-32.38,42.45a4,4,0,0,1-2.67,1,4,4,0,0,1-2.67-7A136.71,136.71,0,0,0,235.56,128,136.07,136.07,0,0,0,211,94.62C187.89,71.65,160,60,128,60a122,122,0,0,0-20,1.63,4,4,0,0,1-1.32-7.89A129.3,129.3,0,0,1,128,52c42.7,0,71.87,20.22,88.83,37.18,18.31,18.31,26.49,36.44,26.83,37.2A4.08,4.08,0,0,1,243.66,129.63Z`}))]]),I=M.forwardRef((e,t)=>M.createElement(a,{ref:t,...e,weights:N}));I.displayName=`ArrowRightIcon`;var L=I,R=M.forwardRef((e,t)=>M.createElement(a,{ref:t,...e,weights:P}));R.displayName=`EyeIcon`;var z=R,B=M.forwardRef((e,t)=>M.createElement(a,{ref:t,...e,weights:F}));B.displayName=`EyeSlashIcon`;var V=B,H=l({defaultVariants:{fullWidth:!1,variant:`primary`},slots:{base:`input-group`,input:`input-group__input`,prefix:`input-group__prefix`,suffix:`input-group__suffix`},variants:{fullWidth:{false:{},true:{base:`input-group--full-width`}},variant:{primary:{base:`input-group--primary`},secondary:{base:`input-group--secondary`}}}}),U=n(),W=(0,M.createContext)({}),G=({children:e,className:t,fullWidth:n,onClick:r,variant:i,...a})=>{let o=(0,M.use)(g),c=i??o?.variant,l=M.useRef(null),d=M.useMemo(()=>H({fullWidth:n,variant:c}),[n,c]),f=e=>{let t=e.target,n=l.current?.querySelector(`input`);n&&t!==n&&!n.contains(t)&&n.focus(),r?.(e)};return(0,U.jsx)(W,{value:{slots:d},children:(0,U.jsx)(u,{...a,ref:l,className:s(t,d?.base()),"data-slot":`input-group`,onClick:f,children:t=>typeof e==`function`?e(t):e})})},K=Object.assign(G,{Root:G,Input:({className:e,...t})=>{let{slots:n}=(0,M.use)(W);return(0,U.jsx)(d,{className:s(e,n?.input()),"data-slot":`input-group-input`,...t})},TextArea:({className:e,...t})=>{let{slots:n}=(0,M.use)(W);return(0,U.jsx)(h,{className:s(e,n?.input()),"data-slot":`input-group-textarea`,...t})},Prefix:({children:e,className:t,...n})=>{let{slots:r}=(0,M.use)(W);return(0,U.jsx)(`div`,{className:c(r?.prefix,t),"data-slot":`input-group-prefix`,...n,children:e})},Suffix:({children:e,className:t,...n})=>{let{slots:r}=(0,M.use)(W);return(0,U.jsx)(`div`,{className:c(r?.suffix,t),"data-slot":`input-group-suffix`,...n,children:e})}});function q(){let{t:e,lang:t,setLang:n}=i(),{setApiKey:a}=_(),{overview:s,refresh:c}=w(),{theme:l,toggleTheme:u}=S(),[d,h]=(0,M.useState)(``),[g,N]=(0,M.useState)(!1),[P,F]=(0,M.useState)(!1),[I,R]=(0,M.useState)(``),B=D(),H=C().state?.from||`/`,W=(0,M.useRef)(null);if(j(W,`login`),s)return(0,U.jsx)(A,{to:H===`/login`?`/`:H,replace:!0});async function G(t){t.preventDefault();let n=d.trim();if(!n){R(e(`loginNeedKey`));return}F(!0),R(``);try{a(n),await c(n),B(H===`/login`?`/`:H,{replace:!0})}catch(t){R(v(t)?e(`loginBadKey`):t instanceof Error?t.message:String(t))}finally{F(!1)}}return(0,U.jsxs)(`div`,{className:`relative min-h-dvh overflow-hidden bg-background text-foreground`,children:[(0,U.jsx)(`div`,{className:`absolute inset-x-0 top-0 h-px bg-border`}),(0,U.jsxs)(`main`,{ref:W,className:`relative z-10 mx-auto grid min-h-dvh w-full max-w-[1480px] lg:grid-cols-[minmax(0,1fr)_minmax(380px,30rem)]`,children:[(0,U.jsxs)(`section`,{className:`flex min-h-[52vh] flex-col px-5 py-6 sm:px-8 sm:py-8 lg:min-h-dvh lg:px-8 lg:py-10 xl:px-10`,children:[(0,U.jsxs)(`header`,{className:`flex items-center justify-between gap-4`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,U.jsx)(O,{size:36}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`div`,{className:`font-semibold`,children:`CLI2API`}),(0,U.jsx)(`div`,{className:`text-caption text-muted`,children:e(`controlPlane`)})]})]}),(0,U.jsxs)(b,{isAttached:!0,children:[(0,U.jsxs)(k,{children:[(0,U.jsx)(k.Trigger,{children:(0,U.jsx)(o,{isIconOnly:!0,size:`sm`,variant:`ghost`,onPress:()=>n(t===`zh`?`en`:`zh`),"aria-label":t===`zh`?`English`:`中文`,children:(0,U.jsx)(E,{size:15})})}),(0,U.jsx)(k.Content,{children:t===`zh`?`English`:`中文`})]}),(0,U.jsxs)(k,{children:[(0,U.jsx)(k.Trigger,{children:(0,U.jsx)(o,{isIconOnly:!0,size:`sm`,variant:`ghost`,onPress:u,"aria-label":l===`dark`?`Light mode`:`Dark mode`,children:l===`dark`?(0,U.jsx)(x,{size:15}):(0,U.jsx)(T,{size:15})})}),(0,U.jsx)(k.Content,{children:l===`dark`?`Light mode`:`Dark mode`})]})]})]}),(0,U.jsx)(`div`,{className:`my-auto w-full py-8 lg:py-10`,children:(0,U.jsx)(r,{t:e,defaultExpanded:!0,forceMockDemo:!0,bare:!0,live:null,mockPace:.45})}),(0,U.jsxs)(`footer`,{className:`hidden items-center justify-between text-caption text-muted lg:flex`,children:[(0,U.jsx)(`span`,{children:e(`loginHint`)}),(0,U.jsx)(`span`,{children:e(`routesHint`)})]})]}),(0,U.jsx)(`section`,{className:`flex items-center px-5 py-10 sm:px-8 lg:px-8 xl:px-10`,children:(0,U.jsx)(m,{"data-gsap-reveal":!0,variant:`transparent`,className:`w-full bg-transparent p-0 shadow-none`,children:(0,U.jsxs)(`form`,{onSubmit:e=>void G(e),children:[(0,U.jsx)(m.Header,{className:`px-2 py-6 sm:px-4`,children:(0,U.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,U.jsx)(O,{size:28,loading:P}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(m.Title,{className:`text-title`,children:e(`loginFormTitle`)}),(0,U.jsx)(m.Description,{className:`mt-1`,children:e(`loginDesc`)})]})]})}),(0,U.jsxs)(m.Content,{className:`space-y-5 px-6 py-7 sm:px-8 sm:py-8`,children:[(0,U.jsxs)(y,{name:`console-password`,className:`w-full`,isInvalid:!!I,children:[(0,U.jsx)(f,{children:e(`loginPassword`)}),(0,U.jsxs)(K,{children:[(0,U.jsx)(K.Input,{id:`console-password`,type:g?`text`:`password`,value:d,onChange:e=>h(e.target.value),placeholder:e(`loginPasswordPh`),autoComplete:`current-password`,autoFocus:!0,"aria-label":e(`loginPassword`),spellCheck:!1}),(0,U.jsx)(K.Suffix,{children:(0,U.jsx)(o,{isIconOnly:!0,size:`sm`,variant:`ghost`,type:`button`,"aria-label":e(g?`hidePassword`:`showPassword`),onPress:()=>N(e=>!e),children:g?(0,U.jsx)(V,{size:16}):(0,U.jsx)(z,{size:16})})})]})]}),I?(0,U.jsx)(p,{title:I}):(0,U.jsx)(`p`,{className:`text-caption text-muted`,children:e(`loginHint`)}),(0,U.jsxs)(o,{type:`submit`,fullWidth:!0,size:`lg`,isPending:P,children:[e(P?`loggingInConsole`:`loginSubmit`),P?null:(0,U.jsx)(L,{size:17})]})]})]})})})]})]})}export{q as LoginPage}; \ No newline at end of file diff --git a/internal/webui/static/assets/LogsPage-BnUmENGj.js b/internal/webui/static/assets/LogsPage-BnUmENGj.js new file mode 100644 index 00000000..f2b2bab4 --- /dev/null +++ b/internal/webui/static/assets/LogsPage-BnUmENGj.js @@ -0,0 +1 @@ +import{a as e,c as t,n}from"./shim-mfK0Rmj6.js";import{i as r,r as i,t as a}from"./SearchBar-DXjI_cjB.js";import{t as o}from"./TrashSimple.es-51cVgQMz.js";import{dt as s,n as ee,r as c}from"./useI18n-BBOAnu2u.js";import{a as te,c as ne,i as re,n as l,o as ie,r as u,t as ae}from"./TimeRangePicker-CLtIDMZF.js";import{t as oe}from"./PageAlert-DZC7IhXp.js";import{t as se}from"./ConfirmDialog-D6gNei8x.js";import{n as d,t as ce}from"./useApiKeyOptions-D6h0C_rA.js";import{t as le}from"./card-QlCdtlk0.js";import{t as ue}from"./EmptyPanel-Bs-jQMvG.js";import{t as f}from"./modal-DHeFzFnN.js";import{n as de,t as p}from"./tabs-CQ7Gr_Df.js";import{t as m}from"./table-D-oKYYsp.js";import{l as fe,n as pe,s as me,t as he}from"./format-kRpr2wxA.js";import{p as ge,u as _e}from"./overview-CJvUvgoD.js";import{Ft as ve,Kt as ye,M as be,Qt as xe,c as Se,kt as Ce,l as we,m as h,s as Te,t as Ee}from"./index-B9eWF6SH.js";import{t as g}from"./FilterToggle-AieL1mQy.js";import{n as De,t as Oe}from"./provider-gHnttGKq.js";import{t as ke}from"./LatencyStats-lecg2Ory.js";import{t as Ae}from"./FilterSelect-GGHAJGuF.js";var _=t(e(),1),je=new Map([[`bold`,_.createElement(_.Fragment,null,_.createElement(`path`,{d:`M72.5,150.63,100.79,128,72.5,105.37a12,12,0,1,1,15-18.74l40,32a12,12,0,0,1,0,18.74l-40,32a12,12,0,0,1-15-18.74ZM144,172h32a12,12,0,0,0,0-24H144a12,12,0,0,0,0,24ZM236,56V200a20,20,0,0,1-20,20H40a20,20,0,0,1-20-20V56A20,20,0,0,1,40,36H216A20,20,0,0,1,236,56Zm-24,4H44V196H212Z`}))],[`duotone`,_.createElement(_.Fragment,null,_.createElement(`path`,{d:`M224,56V200a8,8,0,0,1-8,8H40a8,8,0,0,1-8-8V56a8,8,0,0,1,8-8H216A8,8,0,0,1,224,56Z`,opacity:`0.2`}),_.createElement(`path`,{d:`M128,128a8,8,0,0,1-3,6.25l-40,32a8,8,0,1,1-10-12.5L107.19,128,75,102.25a8,8,0,1,1,10-12.5l40,32A8,8,0,0,1,128,128Zm48,24H136a8,8,0,0,0,0,16h40a8,8,0,0,0,0-16Zm56-96V200a16,16,0,0,1-16,16H40a16,16,0,0,1-16-16V56A16,16,0,0,1,40,40H216A16,16,0,0,1,232,56ZM216,200V56H40V200H216Z`}))],[`fill`,_.createElement(_.Fragment,null,_.createElement(`path`,{d:`M216,40H40A16,16,0,0,0,24,56V200a16,16,0,0,0,16,16H216a16,16,0,0,0,16-16V56A16,16,0,0,0,216,40Zm-91,94.25-40,32a8,8,0,1,1-10-12.5L107.19,128,75,102.25a8,8,0,1,1,10-12.5l40,32a8,8,0,0,1,0,12.5ZM176,168H136a8,8,0,0,1,0-16h40a8,8,0,0,1,0,16Z`}))],[`light`,_.createElement(_.Fragment,null,_.createElement(`path`,{d:`M126,128a6,6,0,0,1-2.25,4.69l-40,32a6,6,0,0,1-7.5-9.38L110.4,128,76.25,100.69a6,6,0,1,1,7.5-9.38l40,32A6,6,0,0,1,126,128Zm50,26H136a6,6,0,0,0,0,12h40a6,6,0,0,0,0-12Zm54-98V200a14,14,0,0,1-14,14H40a14,14,0,0,1-14-14V56A14,14,0,0,1,40,42H216A14,14,0,0,1,230,56Zm-12,0a2,2,0,0,0-2-2H40a2,2,0,0,0-2,2V200a2,2,0,0,0,2,2H216a2,2,0,0,0,2-2Z`}))],[`regular`,_.createElement(_.Fragment,null,_.createElement(`path`,{d:`M128,128a8,8,0,0,1-3,6.25l-40,32a8,8,0,1,1-10-12.5L107.19,128,75,102.25a8,8,0,1,1,10-12.5l40,32A8,8,0,0,1,128,128Zm48,24H136a8,8,0,0,0,0,16h40a8,8,0,0,0,0-16Zm56-96V200a16,16,0,0,1-16,16H40a16,16,0,0,1-16-16V56A16,16,0,0,1,40,40H216A16,16,0,0,1,232,56ZM216,200V56H40V200H216Z`}))],[`thin`,_.createElement(_.Fragment,null,_.createElement(`path`,{d:`M122.5,124.88a4,4,0,0,1,0,6.24l-40,32a4,4,0,0,1-5-6.24L113.6,128,77.5,99.12a4,4,0,0,1,5-6.24ZM176,156H136a4,4,0,0,0,0,8h40a4,4,0,0,0,0-8ZM228,56V200a12,12,0,0,1-12,12H40a12,12,0,0,1-12-12V56A12,12,0,0,1,40,44H216A12,12,0,0,1,228,56Zm-8,0a4,4,0,0,0-4-4H40a4,4,0,0,0-4,4V200a4,4,0,0,0,4,4H216a4,4,0,0,0,4-4Z`}))]]),v=_.forwardRef((e,t)=>_.createElement(s,{ref:t,...e,weights:je}));v.displayName=`TerminalWindowIcon`;var Me=v,y=n();function Ne(e){return e===`ok`?`success`:e===`streaming`||e===`started`||e===`incomplete`?`warning`:e===`error`||e===`canceled`?`danger`:`default`}function Pe(e){if(e===`error`)return`danger`;if(e!==`warn`)return`ok`}function Fe(e){return e===`error`?`danger`:e===`warn`?`warning`:e===`info`?`success`:`default`}function b(e,t=`zh`){if(!e)return`—`;let n=new Date(e);return Number.isFinite(n.getTime())?new Intl.DateTimeFormat(t===`zh`?`zh-CN`:`en-US`,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1}).format(n):e}function Ie(e){let t=e.requested_reasoning?.trim()||``,n=e.resolved_reasoning?.trim()||``;return!t&&!n?``:t&&n&&t!==n?`${t} → ${n}`:n||t}function Le({log:e,inLabel:t,outLabel:n,pointsLabel:r}){let i=e.prompt_tokens,a=e.completion_tokens,o=e.credits??e.usage_detail?.credit,s=o!=null&&Number.isFinite(o)?Be(o):null;return i==null&&a==null&&s==null?(0,y.jsx)(`span`,{className:`mono text-xs text-muted`,children:`—`}):(0,y.jsxs)(`div`,{className:`leading-4`,children:[i!=null||a!=null?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(`div`,{className:`mono text-xs`,children:[i??0,` / `,a??0]}),(0,y.jsxs)(`div`,{className:`mt-0.5 text-caption text-muted`,children:[t,` / `,n]})]}):null,s==null?null:(0,y.jsx)(`div`,{className:`mono text-caption text-success ${i!=null||a!=null?`mt-0.5`:``}`,children:r?r(s):s})]})}function Re(){return(0,y.jsxs)(`div`,{className:`space-y-5`,"aria-busy":`true`,"aria-live":`polite`,children:[(0,y.jsxs)(`div`,{className:`space-y-4 rounded-lg bg-surface-secondary px-4 py-4`,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,y.jsx)(h,{className:`h-5 w-14`}),(0,y.jsx)(h,{className:`h-5 w-48 max-w-full`})]}),(0,y.jsx)(`div`,{className:`grid grid-cols-2 gap-x-4 gap-y-3 sm:grid-cols-3`,children:Array.from({length:6},(e,t)=>(0,y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,y.jsx)(h,{className:`h-3 w-16`}),(0,y.jsx)(h,{className:`h-4 w-20`})]},t))})]}),(0,y.jsxs)(`div`,{className:`space-y-2`,children:[(0,y.jsx)(h,{className:`h-3 w-20`}),(0,y.jsx)(`div`,{className:`grid gap-x-4 gap-y-3 sm:grid-cols-3`,children:Array.from({length:6},(e,t)=>(0,y.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,y.jsx)(h,{className:`h-3 w-16`}),(0,y.jsx)(h,{className:`h-4 w-28 max-w-full`})]},t))})]}),(0,y.jsxs)(`div`,{className:`space-y-2`,children:[(0,y.jsx)(h,{className:`h-3 w-20`}),(0,y.jsx)(h,{className:`h-14 w-full`})]})]})}function ze({title:e,aside:t,children:n}){return(0,y.jsxs)(`section`,{className:`space-y-2`,children:[(0,y.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,y.jsx)(`h3`,{className:`text-xs font-medium text-muted`,children:e}),t]}),n]})}function x({label:e,value:t,mono:n=!1,wide:r=!1}){return(0,y.jsxs)(`div`,{className:`min-w-0 ${r?`col-span-full`:``}`,children:[(0,y.jsx)(`dt`,{className:`text-caption text-muted`,children:e}),(0,y.jsx)(`dd`,{className:`mt-0.5 break-all text-body ${n?`mono`:`font-medium`}`,children:t})]})}function Be(e){return e==null||!Number.isFinite(e)?`—`:String(Math.round(e*1e4)/1e4)}var Ve=[`all`,`ok`,`incomplete`,`error`,`canceled`],S=[`all`,`quota`,`rate_limit`,`auth`,`not_ready`,`unavailable`,`invalid_request`,`model_not_available`],He=[`all`,`1h`,`24h`,`7d`,`custom`];function Ue(e){let t=(e,t,n)=>t.includes(e??``)?e:n,n=u(e.get(`from`)),r=u(e.get(`to`)),i=n&&r?{start:n,end:r}:null,a=e.get(`stream`);return{requestFilter:t(e.get(`status`),Ve,`all`),requestId:e.get(`id`)??``,accountFilter:e.get(`account`)??``,apiKeyFilter:e.get(`api_key`)??``,modelFilter:e.get(`model`)??``,providerFilter:e.get(`provider`)??``,streamFilter:a===`stream`||a===`true`?`stream`:a===`sync`||a===`false`?`sync`:`all`,errorKind:t(e.get(`error_kind`),S,`all`),timeRange:i?`custom`:t(e.get(`range`),He,`1h`),customRange:i}}function We(e){let t=new URLSearchParams;e.requestFilter!==`all`&&t.set(`status`,e.requestFilter),e.requestId&&t.set(`id`,e.requestId),e.accountFilter&&t.set(`account`,e.accountFilter),e.apiKeyFilter&&t.set(`api_key`,e.apiKeyFilter),e.modelFilter&&t.set(`model`,e.modelFilter),e.providerFilter&&t.set(`provider`,e.providerFilter),e.streamFilter!==`all`&&t.set(`stream`,e.streamFilter),e.errorKind!==`all`&&t.set(`error_kind`,e.errorKind);let n=e.timeRange===`custom`?l(e.customRange?.start):void 0,r=e.timeRange===`custom`?l(e.customRange?.end,!0):void 0;return n&&r?(t.set(`from`,n),t.set(`to`,r)):e.timeRange!==`1h`&&t.set(`range`,e.timeRange),t.toString()}function Ge(e){if(e===`all`||e===`custom`)return{from:void 0,to:void 0};let t=new Date,n=new Date(t);return e===`1h`&&n.setHours(n.getHours()-1),e===`24h`&&n.setHours(n.getHours()-24),e===`7d`&&n.setDate(n.getDate()-7),{from:n.toISOString(),to:t.toISOString()}}function C(){let{t:e,lang:t}=ee(),[n,s]=xe(),[u]=(0,_.useState)(()=>Ue(new URLSearchParams(window.location.search))),[h,je]=(0,_.useState)([]),[v,Ve]=(0,_.useState)([]),[S,He]=(0,_.useState)(`requests`),[C,w]=(0,_.useState)(!0),[Ke,qe]=(0,_.useState)(!1),[Je,T]=(0,_.useState)(``),[E,Ye]=(0,_.useState)(u.requestFilter),[D,Xe]=(0,_.useState)(`all`),[O,Ze]=(0,_.useState)(u.requestId),[k,Qe]=(0,_.useState)(``),[A,$e]=(0,_.useState)(u.accountFilter),[j,et]=(0,_.useState)(u.apiKeyFilter),[M,tt]=(0,_.useState)(``),[N,nt]=(0,_.useState)(u.modelFilter),[P,rt]=(0,_.useState)(u.providerFilter),[F,it]=(0,_.useState)(u.streamFilter),[I,at]=(0,_.useState)(u.errorKind),[L,ot]=(0,_.useState)(u.timeRange),[R,st]=(0,_.useState)(u.customRange),[ct,z]=(0,_.useState)(1),[B,lt]=(0,_.useState)(50),[ut,dt]=(0,_.useState)(1),[V,ft]=(0,_.useState)(50),[H,pt]=(0,_.useState)([]),[U,mt]=(0,_.useState)(0),[W,ht]=(0,_.useState)([]),[G,gt]=(0,_.useState)(0),[K,_t]=(0,_.useState)(null),[vt,yt]=(0,_.useState)(!1),[q,bt]=(0,_.useState)(null),[xt,St]=(0,_.useState)(!1),[Ct,wt]=(0,_.useState)(!1),[Tt,Et]=(0,_.useState)(``),J=(0,_.useRef)(0),[Dt,Ot]=(0,_.useState)(!1),[kt,At]=(0,_.useState)(!1),Y=n.toString(),X=We({requestFilter:E,requestId:O,accountFilter:A,apiKeyFilter:j,modelFilter:N,providerFilter:P,streamFilter:F,errorKind:I,timeRange:L,customRange:R}),jt=(0,_.useRef)(Y);(0,_.useEffect)(()=>{if(Y===jt.current)return;jt.current=Y;let e=Ue(new URLSearchParams(Y));Ye(e.requestFilter),Ze(e.requestId),$e(e.accountFilter),et(e.apiKeyFilter),nt(e.modelFilter),rt(e.providerFilter),it(e.streamFilter),at(e.errorKind),ot(e.timeRange),st(e.customRange)},[Y]),(0,_.useEffect)(()=>{X!==jt.current&&(jt.current=X,s(X,{replace:!0}))},[X,s]),(0,_.useEffect)(()=>{let e=!1;return Promise.allSettled([_e(!1),ge()]).then(([t,n])=>{e||(t.status===`fulfilled`&&je(t.value.data||[]),n.status===`fulfilled`&&Ve(n.value.data||[]))}),()=>{e=!0}},[]);let Z=(0,_.useMemo)(()=>{let e=new Map;for(let t of h||[])e.set(t.id,t.name||t.id);return e},[h]),Mt=(0,_.useMemo)(()=>{let e=new Map;for(let t of h||[])e.set(t.id,{provider:t.provider,region:t.region});return e},[h]);function Nt(t){let n=t.account_id?Mt.get(t.account_id):void 0,r=t.provider||n?.provider;return r?De(r,n?.region,e):`—`}function Pt(t){switch(t){case`pin`:return e(`logsRouting_pin`);case`sticky`:return e(`logsRouting_sticky`);case`sticky_escape`:return e(`logsRouting_sticky_escape`);default:return e(`logsRouting_pool`)}}let Ft=(0,_.useMemo)(()=>(h||[]).map(e=>({id:e.id,label:e.name||e.id})),[h]),{nameById:It,options:Lt}=ce();function Rt(e){let t=e.api_key_id?.trim();return t?It.get(t)||t:`—`}let zt=(0,_.useMemo)(()=>{let t=new Set;for(let e of h||[])e.provider&&t.add(e.provider);return P&&t.add(P),[{id:``,label:e(`logsFilterProviderAll`)},...[...t].sort().map(t=>({id:t,label:Oe(t,e)}))]},[h,P,e]),Bt=(0,_.useMemo)(()=>{let e=new Map;for(let t of v||[])e.has(t.id)||e.set(t.id,{id:t.id,label:t.display_name||t.id});return[...e.values()]},[v]),Vt=(0,_.useCallback)(async e=>((await ie({q:e||void 0,limit:20,offset:0})).items||[]).map(e=>({id:e.id,label:e.id})),[]),Ht=!!(O||E!==`all`||A||j||N||P||F!==`all`||I!==`all`||L!==`1h`),Ut=[E,O,A,j,N,P,F,I,L,R?.start?.toString()??``,R?.end?.toString()??``,B].join(`\0`),Wt=[D,k,M,V].join(`\0`),[Gt,Kt]=(0,_.useState)(Ut),[qt,Jt]=(0,_.useState)(Wt);Gt!==Ut&&(Kt(Ut),z(1)),qt!==Wt&&(Jt(Wt),dt(1));let Yt=Math.max(1,Math.ceil(U/B)),Q=Math.min(Gt===Ut?Math.max(1,ct):1,Yt);ct!==Q&&z(Q);let Xt=Math.max(1,Math.ceil(G/V)),$=Math.min(qt===Wt?Math.max(1,ut):1,Xt);ut!==$&&dt($);let Zt=(0,_.useCallback)(async(e=!1)=>{e||w(!0);try{let e=O?{from:void 0,to:void 0}:L===`custom`?{from:l(R?.start),to:l(R?.end,!0)}:Ge(L),t=await ie({status:E===`all`?void 0:E,id:O||void 0,account:A||void 0,api_key:j||void 0,model:N||void 0,provider:P||void 0,stream:F===`all`?void 0:F===`stream`,error_kind:I===`all`?void 0:I,from:e.from,to:e.to,limit:B,offset:(Q-1)*B});pt(t.items||[]),mt(t.total||0),T(``)}catch(t){e||T(t instanceof Error?t.message:String(t))}finally{e||(w(!1),qe(!0))}},[E,O,A,j,N,P,F,I,L,R,Q,B]),Qt=(0,_.useCallback)(async(e=!1)=>{e||w(!0);try{let e=await ne({level:D===`all`?void 0:D,q:k.trim()||void 0,account:M||void 0,limit:V,offset:($-1)*V});ht(e.items||[]),gt(e.total??0),T(``)}catch(t){e||T(t instanceof Error?t.message:String(t))}finally{e||(w(!1),qe(!0))}},[D,k,M,$,V]),$t=(0,_.useCallback)(async(e=!1)=>{S===`requests`?await Zt(e):await Qt(e)},[S,Zt,Qt]);(0,_.useEffect)(()=>{w(!0);let e=S===`runtime`&&k.trim()?280:0,t=window.setTimeout(()=>void $t(!1),e);return()=>window.clearTimeout(t)},[$t,S,k]),(0,_.useEffect)(()=>{if(S!==`runtime`||$!==1)return;let e=window.setInterval(()=>{document.hidden||Qt(!0)},3e3);return()=>window.clearInterval(e)},[S,$,Qt]);let en=U===0?0:(Q-1)*B+1,tn=Math.min(U,Q*B),nn=G===0?0:($-1)*V+1,rn=Math.min(G,$*V),an=(0,_.useMemo)(()=>S===`requests`?e(`logsShownTotal`,{shown:H.length?`${en}–${tn}`:0,total:U}):e(`logsShownTotal`,{shown:W.length?`${nn}–${rn}`:0,total:G}),[S,H.length,W.length,en,tn,U,nn,rn,G,e]);function on(){Ze(``),Ye(`all`),$e(``),et(``),nt(``),rt(``),it(`all`),at(`all`),ot(`1h`),st(null),z(1)}async function sn(e){let t=++J.current;bt(e),Et(``),wt(!0),St(!0);try{let n=await te(e.id);if(J.current!==t)return;bt(n)}catch(e){if(J.current!==t)return;Et(e instanceof Error?e.message:String(e))}finally{J.current===t&&wt(!1)}}function cn(e){_t(e),yt(!0)}async function ln(){At(!0),Ee({id:`logs-clear`,type:`loading`,title:e(`toastClearingLogs`)});try{await re(),Ot(!1),await Zt(!1),Ee({id:`logs-clear`,type:`success`,title:e(`toastLogsCleared`)})}catch(t){T(t instanceof Error?t.message:String(t)),Ee({id:`logs-clear`,type:`error`,title:e(`toastFailed`),description:t instanceof Error?t.message:String(t)})}finally{At(!1)}}let un=C&&(S===`requests`?H.length===0:W.length===0);return C&&!Ke?(0,y.jsx)(Te,{}):(0,y.jsxs)(`div`,{className:`space-y-6`,children:[(0,y.jsxs)(`section`,{className:`flex flex-wrap items-end justify-between gap-4 pb-4`,children:[(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`h2`,{className:`text-title font-semibold`,children:e(`navLogs`)}),(0,y.jsx)(`p`,{className:`mt-1 max-w-2xl text-body leading-6 text-muted`,children:e(`logsLead`)})]}),(0,y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[S===`requests`?(0,y.jsxs)(c,{size:`sm`,variant:`ghost`,onPress:()=>Ot(!0),isDisabled:kt||U===0,children:[(0,y.jsx)(o,{size:14}),e(`logsClear`)]}):null,(0,y.jsxs)(c,{size:`sm`,variant:`secondary`,isPending:C,onPress:()=>void $t(!1),children:[(0,y.jsx)(ye,{size:15}),e(`refresh`)]})]})]}),Je?(0,y.jsx)(oe,{title:e(`failedLogs`,{msg:Je})}):null,(0,y.jsxs)(p,{selectedKey:S,onSelectionChange:e=>He(String(e)),children:[(0,y.jsx)(p.ListContainer,{className:`w-fit`,children:(0,y.jsxs)(p.List,{children:[(0,y.jsxs)(de,{id:`requests`,className:`gap-1.5`,children:[(0,y.jsx)(p.Indicator,{className:`transition-none`}),(0,y.jsx)(ve,{size:13}),e(`logsRequests`)]}),(0,y.jsxs)(de,{id:`runtime`,className:`gap-1.5`,children:[(0,y.jsx)(p.Indicator,{className:`transition-none`}),(0,y.jsx)(Me,{size:13}),e(`logsRuntime`)]})]})}),(0,y.jsxs)(p.Panel,{id:`requests`,"data-tab-panel":`requests`,className:`space-y-4 pt-5`,children:[(0,y.jsxs)(`div`,{className:`data-toolbar flex flex-col gap-2`,children:[(0,y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,y.jsx)(g,{value:E,onChange:e=>Ye(e),ariaLabel:e(`logsFilterAll`),options:[{id:`all`,label:e(`logsFilterAll`)},{id:`ok`,label:e(`logsFilterOk`)},{id:`incomplete`,label:e(`logsFilterIncomplete`)},{id:`error`,label:e(`logsFilterError`)},{id:`canceled`,label:e(`logsFilterCanceled`)}]}),(0,y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[Ht?(0,y.jsx)(c,{size:`sm`,variant:`ghost`,onPress:on,children:e(`clearFilters`)}):null,(0,y.jsx)(`div`,{className:`mono text-caption text-muted`,children:an})]})]}),(0,y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,y.jsx)(d,{ariaLabel:e(`logsColAccount`),value:A,onChange:$e,options:Ft,allLabel:e(`logsFilterAccountAll`),searchPlaceholder:e(`logsSearchAccount`),emptyLabel:e(`logsNoFilterOptions`)}),(0,y.jsx)(d,{ariaLabel:e(`logsColApiKey`),value:j,onChange:et,options:Lt,allLabel:e(`logsFilterApiKeyAll`),searchPlaceholder:e(`logsSearchApiKey`),emptyLabel:e(`logsNoFilterOptions`)}),(0,y.jsx)(d,{ariaLabel:e(`logsColModel`),value:N,onChange:nt,options:Bt,allLabel:e(`logsFilterModelAll`),searchPlaceholder:e(`logsSearchModel`),emptyLabel:e(`logsNoFilterOptions`)}),(0,y.jsx)(Ae,{ariaLabel:e(`logsColProvider`),value:P,onChange:rt,options:zt}),(0,y.jsx)(d,{ariaLabel:e(`logsSearchRequestId`),value:O,onChange:Ze,options:O?[{id:O,label:O}]:[],allLabel:e(`logsFilterIdAll`),searchPlaceholder:e(`logsSearchRequestId`),emptyLabel:e(`logsNoFilterOptions`),loadOptions:Vt,className:`min-w-56`}),(0,y.jsx)(g,{value:F,onChange:e=>it(e),ariaLabel:e(`logsFilterStreamAll`),options:[{id:`all`,label:e(`logsFilterStreamAll`)},{id:`stream`,label:e(`logsStreamYes`)},{id:`sync`,label:e(`logsStreamNo`)}]}),(0,y.jsx)(Ae,{ariaLabel:e(`errorKind`),value:I===`all`?``:I,onChange:e=>at(e||`all`),options:[{id:``,label:e(`logsFilterKindAll`)},{id:`quota`,label:e(`logsKindQuota`)},{id:`rate_limit`,label:e(`logsKindRateLimit`)},{id:`auth`,label:e(`logsKindAuth`)},{id:`not_ready`,label:e(`logsKindNotReady`)},{id:`unavailable`,label:e(`logsKindUnavailable`)},{id:`invalid_request`,label:e(`logsKindInvalidRequest`)},{id:`model_not_available`,label:e(`logsKindModelNotAvailable`)}]})]}),(0,y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,y.jsx)(`span`,{className:`text-xs font-medium text-muted`,children:e(`logsTimeRange`)}),(0,y.jsx)(g,{value:L,onChange:e=>ot(e),ariaLabel:e(`logsTimeRange`),options:[{id:`all`,label:e(`logsTimeAll`)},{id:`1h`,label:e(`logsTime1h`)},{id:`24h`,label:e(`logsTime24h`)},{id:`7d`,label:e(`logsTime7d`)},{id:`custom`,label:e(`logsTimeCustom`)}]}),L===`custom`?(0,y.jsx)(ae,{className:`w-[min(100%,42rem)]`,value:R,onChange:st,ariaLabel:e(`logsTimeRange`),fromLabel:e(`logsTimeFrom`),toLabel:e(`logsTimeTo`)}):null]})]}),(0,y.jsx)(le,{className:`overflow-hidden p-0`,"aria-busy":C,children:un?(0,y.jsx)(Se,{}):H.length===0?(0,y.jsx)(ue,{icon:(0,y.jsx)(r,{size:22}),title:e(Ht?`logsNoMatch`:`logsEmptyRequests`),action:Ht?(0,y.jsx)(c,{size:`sm`,variant:`ghost`,onPress:on,children:e(`clearFilters`)}):null}):(0,y.jsx)(m,{children:(0,y.jsx)(m.ScrollContainer,{children:(0,y.jsxs)(m.Content,{"aria-label":e(`logsRequests`),children:[(0,y.jsxs)(m.Header,{children:[(0,y.jsx)(m.Column,{isRowHeader:!0,children:e(`logsColTime`)}),(0,y.jsx)(m.Column,{children:e(`logsColModel`)}),(0,y.jsx)(m.Column,{children:e(`logsColReasoning`)}),(0,y.jsx)(m.Column,{children:e(`logsColProvider`)}),(0,y.jsx)(m.Column,{children:e(`logsColAccount`)}),(0,y.jsx)(m.Column,{children:e(`logsColApiKey`)}),(0,y.jsx)(m.Column,{children:e(`logsColStatus`)}),(0,y.jsx)(m.Column,{children:e(`logsColStream`)}),(0,y.jsx)(m.Column,{children:e(`logsColLatency`)}),(0,y.jsx)(m.Column,{children:e(`logsColTokens`)})]}),(0,y.jsx)(m.Body,{children:H.map(n=>(0,y.jsxs)(m.Row,{className:`cursor-pointer`,onAction:()=>void sn(n),children:[(0,y.jsx)(m.Cell,{children:(0,y.jsxs)(`div`,{className:`py-1`,children:[(0,y.jsx)(`div`,{className:`mono text-xs`,children:b(n.created_at,t)}),(0,y.jsx)(`div`,{className:`mono mt-0.5 text-caption text-muted`,children:n.id})]})}),(0,y.jsxs)(m.Cell,{children:[(0,y.jsx)(`div`,{className:`text-body font-medium`,children:n.requested_model||`—`}),n.mapped_model&&n.mapped_model!==n.requested_model?(0,y.jsx)(`div`,{className:`mono mt-0.5 text-caption text-muted`,children:n.mapped_model}):null]}),(0,y.jsx)(m.Cell,{children:(0,y.jsx)(`span`,{className:`mono text-xs`,children:Ie(n)||`—`})}),(0,y.jsx)(m.Cell,{children:(0,y.jsx)(`span`,{className:`text-xs`,children:Nt(n)})}),(0,y.jsxs)(m.Cell,{children:[(0,y.jsx)(`span`,{className:`text-xs`,children:n.account_id?Z.get(n.account_id)||n.account_id:`—`}),n.account_id&&Z.get(n.account_id)&&Z.get(n.account_id)!==n.account_id?(0,y.jsx)(`div`,{className:`mono mt-0.5 text-caption text-muted`,children:n.account_id}):null]}),(0,y.jsx)(m.Cell,{children:(0,y.jsx)(`span`,{className:`text-xs`,children:Rt(n)})}),(0,y.jsxs)(m.Cell,{children:[(0,y.jsx)(be,{size:`sm`,variant:`soft`,color:Ne(n.status),children:n.status}),n.error_kind?(0,y.jsx)(`div`,{className:`mono mt-1 text-caption text-muted`,children:n.error_kind}):null]}),(0,y.jsx)(m.Cell,{children:(0,y.jsx)(`span`,{className:`text-xs text-muted`,children:n.stream?e(`logsStreamYes`):e(`logsStreamNo`)})}),(0,y.jsx)(m.Cell,{children:(0,y.jsx)(ke,{latencyMs:n.latency_ms,ttfbMs:n.ttfb_ms,completionTokens:n.completion_tokens,stream:n.stream,labels:{ttft:e(`logsColTTFT`),total:e(`logsLatencyTotal`),tps:e(`logsOutputTPS`)}})}),(0,y.jsx)(m.Cell,{children:(0,y.jsx)(Le,{log:n,inLabel:e(`logsTokensIn`),outLabel:e(`logsTokensOut`),pointsLabel:t=>e(`logsTokensPoints`,{value:t})})})]},n.id))})]})})})}),(0,y.jsx)(i,{total:U,page:Q,pageCount:Yt,pageSize:B,loading:C,pageSizeLabel:e(`logsPageSize`),pageLabel:e(`logsPage`,{page:Q,pages:Yt}),prevLabel:e(`logsPrevPage`),nextLabel:e(`logsNextPage`),onPage:z,onPageSize:lt})]}),(0,y.jsxs)(p.Panel,{id:`runtime`,"data-tab-panel":`runtime`,className:`space-y-4 pt-5`,children:[(0,y.jsxs)(`div`,{className:`data-toolbar flex flex-wrap items-center justify-between gap-2`,children:[(0,y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,y.jsx)(a,{className:`sm:w-72`,value:k,onChange:Qe,placeholder:e(`logsSearchRuntime`),ariaLabel:e(`logsSearchRuntime`)}),(0,y.jsx)(d,{ariaLabel:e(`logsColAccount`),value:M,onChange:tt,options:Ft,allLabel:e(`logsFilterAccountAll`),searchPlaceholder:e(`logsSearchAccount`),emptyLabel:e(`logsNoFilterOptions`)}),(0,y.jsx)(g,{value:D,onChange:e=>Xe(e),ariaLabel:e(`logsLevelAll`),options:[{id:`all`,label:e(`logsLevelAll`)},{id:`info`,label:e(`logsLevelInfo`)},{id:`warn`,label:e(`logsLevelWarn`)},{id:`error`,label:e(`logsLevelError`)}]})]}),(0,y.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted`,children:[$===1?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`span`,{className:`status-dot`,"data-state":`ok`}),e(`logsAutoRefresh`)]}):null,(0,y.jsx)(`span`,{className:`mono`,children:an})]})]}),(0,y.jsx)(le,{className:`overflow-hidden p-0`,"aria-busy":C,children:un?(0,y.jsx)(we,{}):W.length===0?(0,y.jsx)(ue,{icon:(0,y.jsx)(Me,{size:22}),title:e(`logsEmptyRuntime`)}):(0,y.jsx)(`div`,{className:`divide-y divide-separator`,children:W.map(e=>(0,y.jsxs)(`div`,{className:`grid cursor-pointer gap-2 px-5 py-3 transition-colors hover:bg-surface-secondary/55 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent sm:grid-cols-[150px_72px_minmax(0,1fr)] sm:items-start`,role:`button`,tabIndex:0,onClick:()=>cn(e),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),cn(e))},children:[(0,y.jsx)(`div`,{className:`mono text-caption text-muted`,children:b(e.time,t)}),(0,y.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,y.jsx)(`span`,{className:`status-dot`,"data-state":Pe(e.level)}),(0,y.jsx)(`span`,{className:`font-medium text-muted`,children:e.level})]}),(0,y.jsxs)(`div`,{className:`min-w-0`,children:[e.account_id?(0,y.jsx)(`div`,{className:`mono mb-1 text-caption text-muted`,children:e.account_id}):null,(0,y.jsx)(`div`,{className:`mono break-all text-xs leading-5 text-foreground`,children:e.message})]})]},e.id))})}),(0,y.jsx)(i,{total:G,page:$,pageCount:Xt,pageSize:V,loading:C,pageSizeLabel:e(`logsPageSize`),pageLabel:e(`logsPage`,{page:$,pages:Xt}),prevLabel:e(`logsPrevPage`),nextLabel:e(`logsNextPage`),onPage:dt,onPageSize:ft})]})]}),(0,y.jsx)(f.Root,{isOpen:vt,onOpenChange:e=>{yt(e),e||_t(null)},children:(0,y.jsx)(f.Backdrop,{variant:`blur`,children:(0,y.jsx)(f.Container,{size:`lg`,scroll:`inside`,children:(0,y.jsxs)(f.Dialog,{className:`w-full max-w-4xl`,children:[(0,y.jsxs)(f.Header,{className:`items-start justify-between gap-4 px-5 pt-5`,children:[(0,y.jsxs)(`div`,{className:`min-w-0`,children:[(0,y.jsx)(f.Heading,{className:`text-section font-semibold`,children:e(`logsRuntimeDetailTitle`)}),(0,y.jsx)(`p`,{className:`mono mt-1 text-caption text-muted`,children:K?`#${K.id}`:`—`})]}),(0,y.jsx)(f.CloseTrigger,{"aria-label":e(`close`),className:`grid size-8 shrink-0 place-items-center rounded-lg text-muted transition-colors hover:bg-surface-secondary hover:text-foreground`,children:(0,y.jsx)(Ce,{size:16})})]}),(0,y.jsxs)(f.Body,{className:`space-y-5 px-5 pb-5`,children:[(0,y.jsx)(`dl`,{className:`grid gap-3 sm:grid-cols-2`,children:[[e(`logsColTime`),K?b(K.time,t):`—`],[e(`logsRuntimeLevel`),K?.level||`—`],[e(`logsRuntimeSource`),K?.source||`—`],[e(`logsColAccount`),K?.account_id||`—`]].map(([t,n])=>(0,y.jsxs)(`div`,{children:[(0,y.jsx)(`dt`,{className:`text-caption text-muted`,children:t}),(0,y.jsx)(`dd`,{className:`mt-1 break-all text-body font-medium`,children:t===e(`logsRuntimeLevel`)&&K?(0,y.jsx)(be,{size:`sm`,variant:`soft`,color:Fe(K.level),children:K.level}):n})]},String(t)))}),(0,y.jsxs)(`section`,{className:`space-y-2`,children:[(0,y.jsx)(`div`,{className:`text-xs font-medium text-muted`,children:e(`logsRuntimeMessage`)}),(0,y.jsx)(`pre`,{className:`mono max-h-[min(38rem,60vh)] overflow-auto whitespace-pre-wrap break-words rounded-lg bg-surface-secondary px-4 py-3 text-xs leading-6 text-foreground`,children:K?.message||`—`})]})]})]})})})}),(0,y.jsx)(f.Root,{isOpen:xt,onOpenChange:e=>{St(e),e||(J.current+=1,wt(!1),Et(``),bt(null))},children:(0,y.jsx)(f.Backdrop,{variant:`blur`,children:(0,y.jsx)(f.Container,{size:`lg`,scroll:`inside`,children:(0,y.jsxs)(f.Dialog,{className:`w-full max-w-4xl`,children:[(0,y.jsxs)(f.Header,{className:`items-start justify-between gap-4 px-5 pt-5`,children:[(0,y.jsxs)(`div`,{className:`min-w-0`,children:[(0,y.jsx)(f.Heading,{className:`text-section font-semibold`,children:e(`logsDetailTitle`)}),(0,y.jsx)(`p`,{className:`mono mt-1 text-caption text-muted`,children:q?.id})]}),(0,y.jsx)(f.CloseTrigger,{"aria-label":e(`close`),className:`grid size-8 shrink-0 place-items-center rounded-lg text-muted transition-colors hover:bg-surface-secondary hover:text-foreground`,children:(0,y.jsx)(Ce,{size:16})})]}),(0,y.jsx)(f.Body,{className:`space-y-5 px-5 pb-5`,children:Ct?(0,y.jsx)(Re,{}):Tt?(0,y.jsx)(oe,{title:e(`requestFailed`),description:Tt}):q?(0,y.jsxs)(y.Fragment,{children:[q.error_message?(0,y.jsx)(oe,{title:q.error_kind||e(`requestFailed`),description:q.error_message}):null,(0,y.jsxs)(`div`,{className:`space-y-4 rounded-lg bg-surface-secondary px-4 py-4`,children:[(0,y.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,y.jsx)(be,{size:`sm`,variant:`soft`,color:Ne(q.status),children:q.status||`—`}),(0,y.jsx)(`span`,{className:`mono min-w-0 break-all text-body font-medium`,children:q.requested_model||`—`}),q.mapped_model&&q.mapped_model!==q.requested_model?(0,y.jsxs)(`span`,{className:`mono break-all text-caption text-muted`,children:[`→ `,q.mapped_model]}):null,Ie(q)?(0,y.jsxs)(`span`,{className:`mono text-caption text-muted`,children:[`· `,Ie(q)]}):null,(0,y.jsx)(`span`,{className:`mono ml-auto text-caption text-muted`,children:b(q.created_at,t)})]}),(0,y.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-4 gap-y-3 sm:grid-cols-3`,children:[(0,y.jsx)(x,{mono:!0,label:`${e(`logsColTokens`)} · ${e(`logsTokensIn`)} / ${e(`logsTokensOut`)}`,value:q.prompt_tokens==null&&q.completion_tokens==null?`—`:`${q.prompt_tokens??0} / ${q.completion_tokens??0}`}),(q.credits??q.usage_detail?.credit)==null?null:(0,y.jsx)(x,{mono:!0,label:e(`logsCreditConsumed`),value:`${Be(q.credits??q.usage_detail?.credit)}${q.usage_detail?.unit?` ${q.usage_detail.unit}`:``}`}),(0,y.jsx)(x,{mono:!0,label:e(`logsColTTFT`),value:me(q.ttfb_ms)}),(0,y.jsx)(x,{mono:!0,label:e(`logsLatencyTotal`),value:me(q.latency_ms)}),(0,y.jsx)(x,{mono:!0,label:e(`logsOutputTPS`),value:fe(he({completionTokens:q.completion_tokens,latencyMs:q.latency_ms,ttfbMs:q.ttfb_ms,stream:q.stream}))})]})]}),(0,y.jsx)(ze,{title:e(`logsSectionCall`),children:(0,y.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-4 gap-y-3 sm:grid-cols-3`,children:[(0,y.jsx)(x,{label:e(`logsColProvider`),value:Nt(q)}),(0,y.jsx)(x,{label:e(`logsColAccount`),value:q.account_id?Z.get(q.account_id)||q.account_id:`—`}),(0,y.jsx)(x,{label:e(`logsColApiKey`),value:Rt(q)}),(0,y.jsx)(x,{label:e(`logsColStream`),value:q.stream?e(`logsStreamYes`):e(`logsStreamNo`)}),(0,y.jsx)(x,{label:e(`logsRouting`),value:Pt(q.routing)})]})}),(0,y.jsx)(ze,{title:e(`logsAttempts`),aside:q.attempts?.length?(0,y.jsx)(`span`,{className:`mono text-caption text-muted`,children:q.attempts.length}):null,children:q.attempts?.length?(0,y.jsx)(`div`,{className:`divide-y divide-separator overflow-hidden rounded-lg bg-surface-secondary`,children:q.attempts.map(e=>(0,y.jsxs)(`div`,{className:`grid grid-cols-[32px_minmax(0,1fr)_auto] items-start gap-x-3 px-3 py-2.5`,children:[(0,y.jsxs)(`div`,{className:`mono pt-0.5 text-caption text-muted`,children:[`#`,e.attempt_index]}),(0,y.jsxs)(`div`,{className:`min-w-0`,children:[(0,y.jsx)(`div`,{className:`truncate text-body font-medium`,children:e.account_id?Z.get(e.account_id)||e.account_id:`—`}),e.error_message?(0,y.jsxs)(`div`,{className:`mt-0.5 break-all text-caption text-muted`,children:[e.error_kind?(0,y.jsx)(`span`,{className:`mono mr-1.5`,children:e.error_kind}):null,e.error_message]}):null]}),(0,y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.latency_ms==null?null:(0,y.jsx)(`span`,{className:`mono text-caption text-muted`,children:me(e.latency_ms)}),(0,y.jsx)(be,{size:`sm`,variant:`soft`,color:Ne(e.status===`failover`?`canceled`:e.status),children:e.status})]})]},e.id))}):(0,y.jsx)(`p`,{className:`text-caption text-muted`,children:e(`logsNoAttempts`)})}),q.message_count||q.stream_diagnostic?(0,y.jsx)(ze,{title:e(`logsSectionDiagnostics`),children:(0,y.jsxs)(`div`,{className:`space-y-4 rounded-lg bg-surface-secondary px-4 py-3`,children:[q.message_count?(0,y.jsxs)(`div`,{className:`space-y-2`,children:[(0,y.jsx)(`div`,{className:`text-caption font-medium text-muted`,children:e(`logsMessageShape`)}),(0,y.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-4 gap-y-3 sm:grid-cols-3`,children:[(0,y.jsx)(x,{mono:!0,label:e(`logsMessageCount`),value:q.message_count}),(0,y.jsx)(x,{mono:!0,label:e(`logsEmptyMessageIndexes`),value:q.empty_message_indexes?.length?q.empty_message_indexes.join(`, `):`—`}),(0,y.jsx)(x,{mono:!0,wide:!0,label:e(`logsMessageRoles`),value:q.message_roles?.join(` → `)||`—`})]})]}):null,q.message_count&&q.stream_diagnostic?(0,y.jsx)(`div`,{className:`border-t border-separator`}):null,q.stream_diagnostic?(0,y.jsxs)(`div`,{className:`space-y-2`,children:[(0,y.jsx)(`div`,{className:`text-caption font-medium text-muted`,children:e(`logsStreamDiagnostics`)}),(0,y.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-4 gap-y-3 sm:grid-cols-3`,children:[(0,y.jsx)(x,{mono:!0,label:e(`logsUpstreamStatus`),value:q.stream_diagnostic.upstream_status??`—`}),(0,y.jsx)(x,{mono:!0,label:e(`logsStreamComplete`),value:q.stream_diagnostic.saw_done?e(`yes`):e(`no`)}),(0,y.jsx)(x,{mono:!0,label:e(`logsCancellationSource`),value:q.stream_diagnostic.cancellation_source||`—`}),(0,y.jsx)(x,{mono:!0,label:e(`logsSSEEvents`),value:q.stream_diagnostic.sse_event_count}),(0,y.jsx)(x,{mono:!0,label:e(`logsBytesRead`),value:pe(q.stream_diagnostic.bytes_read)}),(0,y.jsx)(x,{mono:!0,label:e(`logsLastEvent`),value:q.stream_diagnostic.last_event||`—`}),q.stream_diagnostic.context_err?(0,y.jsx)(x,{mono:!0,wide:!0,label:`context`,value:q.stream_diagnostic.context_err}):null,q.stream_diagnostic.relay_error?(0,y.jsx)(x,{mono:!0,wide:!0,label:`relay`,value:q.stream_diagnostic.relay_error}):null]})]}):null]})}):null]}):null})]})})})}),(0,y.jsx)(se,{isOpen:Dt,title:e(`logsClear`),description:e(`logsClearConfirm`),confirmLabel:e(`logsClear`),cancelLabel:e(`close`),closeLabel:e(`close`),isPending:kt,onClose:()=>Ot(!1),onConfirm:()=>void ln()})]})}export{C as LogsPage}; \ No newline at end of file diff --git a/internal/webui/static/assets/LogsPage-rWFU3Cam.js b/internal/webui/static/assets/LogsPage-rWFU3Cam.js deleted file mode 100644 index 8d7999ab..00000000 --- a/internal/webui/static/assets/LogsPage-rWFU3Cam.js +++ /dev/null @@ -1 +0,0 @@ -import{a as e,c as t,n}from"./shim-mfK0Rmj6.js";import{i as r,r as i,t as a}from"./SearchBar-Cehxs-tj.js";import{t as o}from"./TrashSimple.es-BiXnQzNp.js";import{n as s,pt as ee,r as te}from"./useI18n-BSw4X3mq.js";import{a as ne,c as re,i as ie,n as c,o as ae,r as l,t as oe}from"./TimeRangePicker-C118rt0G.js";import{t as se}from"./PageAlert-CaDjxveS.js";import{t as ce}from"./ConfirmDialog-C6PfmZuk.js";import{n as u,t as le}from"./useApiKeyOptions-BUxE7IB2.js";import{n as ue}from"./useToggle-HDaAPzVy.js";import{t as de}from"./EmptyPanel-Bs-jQMvG.js";import{t as d}from"./modal-BVwBjYX-.js";import{n as fe,t as f}from"./tabs-Cm-IDu6Q.js";import{t as p}from"./table-BE40Giyo.js";import{p as pe,u as me}from"./overview-m01k08K8.js";import{Dt as he,M as ge,Nt as _e,Wt as ve,Xt as ye,c as be,l as xe,m,s as Se,t as Ce}from"./index-C8_qeOs_.js";import{t as h}from"./FilterToggle-16Av-HiR.js";import{l as we,n as Te,s as Ee,t as De}from"./format-B6SmebW-.js";import{n as Oe,t as ke}from"./provider-gHnttGKq.js";import{t as Ae}from"./LatencyStats-DmxRwO-O.js";import{t as je}from"./FilterSelect-CNXkxdW1.js";var g=t(e(),1),Me=new Map([[`bold`,g.createElement(g.Fragment,null,g.createElement(`path`,{d:`M72.5,150.63,100.79,128,72.5,105.37a12,12,0,1,1,15-18.74l40,32a12,12,0,0,1,0,18.74l-40,32a12,12,0,0,1-15-18.74ZM144,172h32a12,12,0,0,0,0-24H144a12,12,0,0,0,0,24ZM236,56V200a20,20,0,0,1-20,20H40a20,20,0,0,1-20-20V56A20,20,0,0,1,40,36H216A20,20,0,0,1,236,56Zm-24,4H44V196H212Z`}))],[`duotone`,g.createElement(g.Fragment,null,g.createElement(`path`,{d:`M224,56V200a8,8,0,0,1-8,8H40a8,8,0,0,1-8-8V56a8,8,0,0,1,8-8H216A8,8,0,0,1,224,56Z`,opacity:`0.2`}),g.createElement(`path`,{d:`M128,128a8,8,0,0,1-3,6.25l-40,32a8,8,0,1,1-10-12.5L107.19,128,75,102.25a8,8,0,1,1,10-12.5l40,32A8,8,0,0,1,128,128Zm48,24H136a8,8,0,0,0,0,16h40a8,8,0,0,0,0-16Zm56-96V200a16,16,0,0,1-16,16H40a16,16,0,0,1-16-16V56A16,16,0,0,1,40,40H216A16,16,0,0,1,232,56ZM216,200V56H40V200H216Z`}))],[`fill`,g.createElement(g.Fragment,null,g.createElement(`path`,{d:`M216,40H40A16,16,0,0,0,24,56V200a16,16,0,0,0,16,16H216a16,16,0,0,0,16-16V56A16,16,0,0,0,216,40Zm-91,94.25-40,32a8,8,0,1,1-10-12.5L107.19,128,75,102.25a8,8,0,1,1,10-12.5l40,32a8,8,0,0,1,0,12.5ZM176,168H136a8,8,0,0,1,0-16h40a8,8,0,0,1,0,16Z`}))],[`light`,g.createElement(g.Fragment,null,g.createElement(`path`,{d:`M126,128a6,6,0,0,1-2.25,4.69l-40,32a6,6,0,0,1-7.5-9.38L110.4,128,76.25,100.69a6,6,0,1,1,7.5-9.38l40,32A6,6,0,0,1,126,128Zm50,26H136a6,6,0,0,0,0,12h40a6,6,0,0,0,0-12Zm54-98V200a14,14,0,0,1-14,14H40a14,14,0,0,1-14-14V56A14,14,0,0,1,40,42H216A14,14,0,0,1,230,56Zm-12,0a2,2,0,0,0-2-2H40a2,2,0,0,0-2,2V200a2,2,0,0,0,2,2H216a2,2,0,0,0,2-2Z`}))],[`regular`,g.createElement(g.Fragment,null,g.createElement(`path`,{d:`M128,128a8,8,0,0,1-3,6.25l-40,32a8,8,0,1,1-10-12.5L107.19,128,75,102.25a8,8,0,1,1,10-12.5l40,32A8,8,0,0,1,128,128Zm48,24H136a8,8,0,0,0,0,16h40a8,8,0,0,0,0-16Zm56-96V200a16,16,0,0,1-16,16H40a16,16,0,0,1-16-16V56A16,16,0,0,1,40,40H216A16,16,0,0,1,232,56ZM216,200V56H40V200H216Z`}))],[`thin`,g.createElement(g.Fragment,null,g.createElement(`path`,{d:`M122.5,124.88a4,4,0,0,1,0,6.24l-40,32a4,4,0,0,1-5-6.24L113.6,128,77.5,99.12a4,4,0,0,1,5-6.24ZM176,156H136a4,4,0,0,0,0,8h40a4,4,0,0,0,0-8ZM228,56V200a12,12,0,0,1-12,12H40a12,12,0,0,1-12-12V56A12,12,0,0,1,40,44H216A12,12,0,0,1,228,56Zm-8,0a4,4,0,0,0-4-4H40a4,4,0,0,0-4,4V200a4,4,0,0,0,4,4H216a4,4,0,0,0,4-4Z`}))]]),_=g.forwardRef((e,t)=>g.createElement(ee,{ref:t,...e,weights:Me}));_.displayName=`TerminalWindowIcon`;var Ne=_,v=n();function Pe(e){return e===`ok`?`success`:e===`streaming`||e===`started`||e===`incomplete`?`warning`:e===`error`||e===`canceled`?`danger`:`default`}function Fe(e){if(e===`error`)return`danger`;if(e!==`warn`)return`ok`}function Ie(e){return e===`error`?`danger`:e===`warn`?`warning`:e===`info`?`success`:`default`}function y(e,t=`zh`){if(!e)return`—`;let n=new Date(e);return Number.isFinite(n.getTime())?new Intl.DateTimeFormat(t===`zh`?`zh-CN`:`en-US`,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1}).format(n):e}function Le(e){let t=e.requested_reasoning?.trim()||``,n=e.resolved_reasoning?.trim()||``;return!t&&!n?``:t&&n&&t!==n?`${t} → ${n}`:n||t}function Re({log:e,inLabel:t,outLabel:n,pointsLabel:r}){let i=e.prompt_tokens,a=e.completion_tokens,o=e.credits??e.usage_detail?.credit,s=o!=null&&Number.isFinite(o)?Ve(o):null;return i==null&&a==null&&s==null?(0,v.jsx)(`span`,{className:`mono text-xs text-muted`,children:`—`}):(0,v.jsxs)(`div`,{className:`leading-4`,children:[i!=null||a!=null?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(`div`,{className:`mono text-xs`,children:[i??0,` / `,a??0]}),(0,v.jsxs)(`div`,{className:`mt-0.5 text-caption text-muted`,children:[t,` / `,n]})]}):null,s==null?null:(0,v.jsx)(`div`,{className:`mono text-caption text-success ${i!=null||a!=null?`mt-0.5`:``}`,children:r?r(s):s})]})}function ze(){return(0,v.jsxs)(`div`,{className:`space-y-5`,"aria-busy":`true`,"aria-live":`polite`,children:[(0,v.jsxs)(`div`,{className:`space-y-4 rounded-lg bg-surface-secondary px-4 py-4`,children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,v.jsx)(m,{className:`h-5 w-14`}),(0,v.jsx)(m,{className:`h-5 w-48 max-w-full`})]}),(0,v.jsx)(`div`,{className:`grid grid-cols-2 gap-x-4 gap-y-3 sm:grid-cols-3`,children:Array.from({length:6},(e,t)=>(0,v.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,v.jsx)(m,{className:`h-3 w-16`}),(0,v.jsx)(m,{className:`h-4 w-20`})]},t))})]}),(0,v.jsxs)(`div`,{className:`space-y-2`,children:[(0,v.jsx)(m,{className:`h-3 w-20`}),(0,v.jsx)(`div`,{className:`grid gap-x-4 gap-y-3 sm:grid-cols-3`,children:Array.from({length:6},(e,t)=>(0,v.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,v.jsx)(m,{className:`h-3 w-16`}),(0,v.jsx)(m,{className:`h-4 w-28 max-w-full`})]},t))})]}),(0,v.jsxs)(`div`,{className:`space-y-2`,children:[(0,v.jsx)(m,{className:`h-3 w-20`}),(0,v.jsx)(m,{className:`h-14 w-full`})]})]})}function Be({title:e,aside:t,children:n}){return(0,v.jsxs)(`section`,{className:`space-y-2`,children:[(0,v.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,v.jsx)(`h3`,{className:`text-xs font-medium text-muted`,children:e}),t]}),n]})}function b({label:e,value:t,mono:n=!1,wide:r=!1}){return(0,v.jsxs)(`div`,{className:`min-w-0 ${r?`col-span-full`:``}`,children:[(0,v.jsx)(`dt`,{className:`text-caption text-muted`,children:e}),(0,v.jsx)(`dd`,{className:`mt-0.5 break-all text-body ${n?`mono`:`font-medium`}`,children:t})]})}function Ve(e){return e==null||!Number.isFinite(e)?`—`:String(Math.round(e*1e4)/1e4)}var He=[`all`,`ok`,`incomplete`,`error`,`canceled`],x=[`all`,`quota`,`rate_limit`,`auth`,`not_ready`,`unavailable`,`invalid_request`,`model_not_available`],Ue=[`all`,`1h`,`24h`,`7d`,`custom`];function We(e){let t=(e,t,n)=>t.includes(e??``)?e:n,n=l(e.get(`from`)),r=l(e.get(`to`)),i=n&&r?{start:n,end:r}:null,a=e.get(`stream`);return{requestFilter:t(e.get(`status`),He,`all`),requestId:e.get(`id`)??``,accountFilter:e.get(`account`)??``,apiKeyFilter:e.get(`api_key`)??``,modelFilter:e.get(`model`)??``,providerFilter:e.get(`provider`)??``,streamFilter:a===`stream`||a===`true`?`stream`:a===`sync`||a===`false`?`sync`:`all`,errorKind:t(e.get(`error_kind`),x,`all`),timeRange:i?`custom`:t(e.get(`range`),Ue,`1h`),customRange:i}}function Ge(e){let t=new URLSearchParams;e.requestFilter!==`all`&&t.set(`status`,e.requestFilter),e.requestId&&t.set(`id`,e.requestId),e.accountFilter&&t.set(`account`,e.accountFilter),e.apiKeyFilter&&t.set(`api_key`,e.apiKeyFilter),e.modelFilter&&t.set(`model`,e.modelFilter),e.providerFilter&&t.set(`provider`,e.providerFilter),e.streamFilter!==`all`&&t.set(`stream`,e.streamFilter),e.errorKind!==`all`&&t.set(`error_kind`,e.errorKind);let n=e.timeRange===`custom`?c(e.customRange?.start):void 0,r=e.timeRange===`custom`?c(e.customRange?.end,!0):void 0;return n&&r?(t.set(`from`,n),t.set(`to`,r)):e.timeRange!==`1h`&&t.set(`range`,e.timeRange),t.toString()}function Ke(e){if(e===`all`||e===`custom`)return{from:void 0,to:void 0};let t=new Date,n=new Date(t);return e===`1h`&&n.setHours(n.getHours()-1),e===`24h`&&n.setHours(n.getHours()-24),e===`7d`&&n.setDate(n.getDate()-7),{from:n.toISOString(),to:t.toISOString()}}function S(){let{t:e,lang:t}=s(),[n,ee]=ye(),[l]=(0,g.useState)(()=>We(new URLSearchParams(window.location.search))),[m,Me]=(0,g.useState)([]),[_,He]=(0,g.useState)([]),[x,Ue]=(0,g.useState)(`requests`),[S,C]=(0,g.useState)(!0),[qe,Je]=(0,g.useState)(!1),[Ye,w]=(0,g.useState)(``),[T,Xe]=(0,g.useState)(l.requestFilter),[E,Ze]=(0,g.useState)(`all`),[D,Qe]=(0,g.useState)(l.requestId),[O,$e]=(0,g.useState)(``),[k,et]=(0,g.useState)(l.accountFilter),[A,tt]=(0,g.useState)(l.apiKeyFilter),[j,nt]=(0,g.useState)(``),[M,rt]=(0,g.useState)(l.modelFilter),[N,it]=(0,g.useState)(l.providerFilter),[P,at]=(0,g.useState)(l.streamFilter),[F,ot]=(0,g.useState)(l.errorKind),[I,st]=(0,g.useState)(l.timeRange),[L,ct]=(0,g.useState)(l.customRange),[lt,R]=(0,g.useState)(1),[z,ut]=(0,g.useState)(50),[dt,ft]=(0,g.useState)(1),[B,pt]=(0,g.useState)(50),[V,mt]=(0,g.useState)([]),[H,ht]=(0,g.useState)(0),[U,gt]=(0,g.useState)([]),[W,_t]=(0,g.useState)(0),[G,vt]=(0,g.useState)(null),[yt,bt]=(0,g.useState)(!1),[K,xt]=(0,g.useState)(null),[St,Ct]=(0,g.useState)(!1),[wt,Tt]=(0,g.useState)(!1),[Et,Dt]=(0,g.useState)(``),q=(0,g.useRef)(0),[Ot,kt]=(0,g.useState)(!1),[At,jt]=(0,g.useState)(!1),J=n.toString(),Y=Ge({requestFilter:T,requestId:D,accountFilter:k,apiKeyFilter:A,modelFilter:M,providerFilter:N,streamFilter:P,errorKind:F,timeRange:I,customRange:L}),X=(0,g.useRef)(J);(0,g.useEffect)(()=>{if(J===X.current)return;X.current=J;let e=We(new URLSearchParams(J));Xe(e.requestFilter),Qe(e.requestId),et(e.accountFilter),tt(e.apiKeyFilter),rt(e.modelFilter),it(e.providerFilter),at(e.streamFilter),ot(e.errorKind),st(e.timeRange),ct(e.customRange)},[J]),(0,g.useEffect)(()=>{Y!==X.current&&(X.current=Y,ee(Y,{replace:!0}))},[Y,ee]),(0,g.useEffect)(()=>{let e=!1;return Promise.allSettled([me(!1),pe()]).then(([t,n])=>{e||(t.status===`fulfilled`&&Me(t.value.data||[]),n.status===`fulfilled`&&He(n.value.data||[]))}),()=>{e=!0}},[]);let Z=(0,g.useMemo)(()=>{let e=new Map;for(let t of m||[])e.set(t.id,t.name||t.id);return e},[m]),Mt=(0,g.useMemo)(()=>{let e=new Map;for(let t of m||[])e.set(t.id,{provider:t.provider,region:t.region});return e},[m]);function Nt(t){let n=t.account_id?Mt.get(t.account_id):void 0,r=t.provider||n?.provider;return r?Oe(r,n?.region,e):`—`}function Pt(t){switch(t){case`pin`:return e(`logsRouting_pin`);case`sticky`:return e(`logsRouting_sticky`);case`sticky_escape`:return e(`logsRouting_sticky_escape`);default:return e(`logsRouting_pool`)}}let Ft=(0,g.useMemo)(()=>(m||[]).map(e=>({id:e.id,label:e.name||e.id})),[m]),{nameById:It,options:Lt}=le();function Rt(e){let t=e.api_key_id?.trim();return t?It.get(t)||t:`—`}let zt=(0,g.useMemo)(()=>{let t=new Set;for(let e of m||[])e.provider&&t.add(e.provider);return N&&t.add(N),[{id:``,label:e(`logsFilterProviderAll`)},...[...t].sort().map(t=>({id:t,label:ke(t,e)}))]},[m,N,e]),Bt=(0,g.useMemo)(()=>{let e=new Map;for(let t of _||[])e.has(t.id)||e.set(t.id,{id:t.id,label:t.display_name||t.id});return[...e.values()]},[_]),Vt=(0,g.useCallback)(async e=>((await ae({q:e||void 0,limit:20,offset:0})).items||[]).map(e=>({id:e.id,label:e.id})),[]),Ht=!!(D||T!==`all`||k||A||M||N||P!==`all`||F!==`all`||I!==`1h`),Ut=[T,D,k,A,M,N,P,F,I,L?.start?.toString()??``,L?.end?.toString()??``,z].join(`\0`),Wt=[E,O,j,B].join(`\0`),[Gt,Kt]=(0,g.useState)(Ut),[qt,Jt]=(0,g.useState)(Wt);Gt!==Ut&&(Kt(Ut),R(1)),qt!==Wt&&(Jt(Wt),ft(1));let Yt=Math.max(1,Math.ceil(H/z)),Q=Math.min(Gt===Ut?Math.max(1,lt):1,Yt);lt!==Q&&R(Q);let Xt=Math.max(1,Math.ceil(W/B)),$=Math.min(qt===Wt?Math.max(1,dt):1,Xt);dt!==$&&ft($);let Zt=(0,g.useCallback)(async(e=!1)=>{e||C(!0);try{let e=D?{from:void 0,to:void 0}:I===`custom`?{from:c(L?.start),to:c(L?.end,!0)}:Ke(I),t=await ae({status:T===`all`?void 0:T,id:D||void 0,account:k||void 0,api_key:A||void 0,model:M||void 0,provider:N||void 0,stream:P===`all`?void 0:P===`stream`,error_kind:F===`all`?void 0:F,from:e.from,to:e.to,limit:z,offset:(Q-1)*z});mt(t.items||[]),ht(t.total||0),w(``)}catch(t){e||w(t instanceof Error?t.message:String(t))}finally{e||(C(!1),Je(!0))}},[T,D,k,A,M,N,P,F,I,L,Q,z]),Qt=(0,g.useCallback)(async(e=!1)=>{e||C(!0);try{let e=await re({level:E===`all`?void 0:E,q:O.trim()||void 0,account:j||void 0,limit:B,offset:($-1)*B});gt(e.items||[]),_t(e.total??0),w(``)}catch(t){e||w(t instanceof Error?t.message:String(t))}finally{e||(C(!1),Je(!0))}},[E,O,j,$,B]),$t=(0,g.useCallback)(async(e=!1)=>{x===`requests`?await Zt(e):await Qt(e)},[x,Zt,Qt]);(0,g.useEffect)(()=>{C(!0);let e=x===`runtime`&&O.trim()?280:0,t=window.setTimeout(()=>void $t(!1),e);return()=>window.clearTimeout(t)},[$t,x,O]),(0,g.useEffect)(()=>{if(x!==`runtime`||$!==1)return;let e=window.setInterval(()=>{document.hidden||Qt(!0)},3e3);return()=>window.clearInterval(e)},[x,$,Qt]);let en=H===0?0:(Q-1)*z+1,tn=Math.min(H,Q*z),nn=W===0?0:($-1)*B+1,rn=Math.min(W,$*B),an=(0,g.useMemo)(()=>x===`requests`?e(`logsShownTotal`,{shown:V.length?`${en}–${tn}`:0,total:H}):e(`logsShownTotal`,{shown:U.length?`${nn}–${rn}`:0,total:W}),[x,V.length,U.length,en,tn,H,nn,rn,W,e]);function on(){Qe(``),Xe(`all`),et(``),tt(``),rt(``),it(``),at(`all`),ot(`all`),st(`1h`),ct(null),R(1)}async function sn(e){let t=++q.current;xt(e),Dt(``),Tt(!0),Ct(!0);try{let n=await ne(e.id);if(q.current!==t)return;xt(n)}catch(e){if(q.current!==t)return;Dt(e instanceof Error?e.message:String(e))}finally{q.current===t&&Tt(!1)}}function cn(e){vt(e),bt(!0)}async function ln(){jt(!0),Ce({id:`logs-clear`,type:`loading`,title:e(`toastClearingLogs`)});try{await ie(),kt(!1),await Zt(!1),Ce({id:`logs-clear`,type:`success`,title:e(`toastLogsCleared`)})}catch(t){w(t instanceof Error?t.message:String(t)),Ce({id:`logs-clear`,type:`error`,title:e(`toastFailed`),description:t instanceof Error?t.message:String(t)})}finally{jt(!1)}}let un=S&&(x===`requests`?V.length===0:U.length===0);return S&&!qe?(0,v.jsx)(Se,{}):(0,v.jsxs)(`div`,{className:`space-y-6`,children:[(0,v.jsxs)(`section`,{className:`flex flex-wrap items-end justify-between gap-4 pb-4`,children:[(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`h2`,{className:`text-title font-semibold`,children:e(`navLogs`)}),(0,v.jsx)(`p`,{className:`mt-1 max-w-2xl text-body leading-6 text-muted`,children:e(`logsLead`)})]}),(0,v.jsxs)(`div`,{className:`flex items-center gap-2`,children:[x===`requests`?(0,v.jsxs)(te,{size:`sm`,variant:`ghost`,onPress:()=>kt(!0),isDisabled:At||H===0,children:[(0,v.jsx)(o,{size:14}),e(`logsClear`)]}):null,(0,v.jsxs)(te,{size:`sm`,variant:`secondary`,isPending:S,onPress:()=>void $t(!1),children:[(0,v.jsx)(ve,{size:15}),e(`refresh`)]})]})]}),Ye?(0,v.jsx)(se,{title:e(`failedLogs`,{msg:Ye})}):null,(0,v.jsxs)(f,{selectedKey:x,onSelectionChange:e=>Ue(String(e)),children:[(0,v.jsx)(f.ListContainer,{className:`w-fit`,children:(0,v.jsxs)(f.List,{children:[(0,v.jsxs)(fe,{id:`requests`,className:`gap-1.5`,children:[(0,v.jsx)(f.Indicator,{className:`transition-none`}),(0,v.jsx)(_e,{size:13}),e(`logsRequests`)]}),(0,v.jsxs)(fe,{id:`runtime`,className:`gap-1.5`,children:[(0,v.jsx)(f.Indicator,{className:`transition-none`}),(0,v.jsx)(Ne,{size:13}),e(`logsRuntime`)]})]})}),(0,v.jsxs)(f.Panel,{id:`requests`,"data-tab-panel":`requests`,className:`space-y-4 pt-5`,children:[(0,v.jsxs)(`div`,{className:`data-toolbar flex flex-col gap-2`,children:[(0,v.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,v.jsx)(h,{value:T,onChange:e=>Xe(e),ariaLabel:e(`logsFilterAll`),options:[{id:`all`,label:e(`logsFilterAll`)},{id:`ok`,label:e(`logsFilterOk`)},{id:`incomplete`,label:e(`logsFilterIncomplete`)},{id:`error`,label:e(`logsFilterError`)},{id:`canceled`,label:e(`logsFilterCanceled`)}]}),(0,v.jsxs)(`div`,{className:`flex items-center gap-2`,children:[Ht?(0,v.jsx)(te,{size:`sm`,variant:`ghost`,onPress:on,children:e(`clearFilters`)}):null,(0,v.jsx)(`div`,{className:`mono text-caption text-muted`,children:an})]})]}),(0,v.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,v.jsx)(u,{ariaLabel:e(`logsColAccount`),value:k,onChange:et,options:Ft,allLabel:e(`logsFilterAccountAll`),searchPlaceholder:e(`logsSearchAccount`),emptyLabel:e(`logsNoFilterOptions`)}),(0,v.jsx)(u,{ariaLabel:e(`logsColApiKey`),value:A,onChange:tt,options:Lt,allLabel:e(`logsFilterApiKeyAll`),searchPlaceholder:e(`logsSearchApiKey`),emptyLabel:e(`logsNoFilterOptions`)}),(0,v.jsx)(u,{ariaLabel:e(`logsColModel`),value:M,onChange:rt,options:Bt,allLabel:e(`logsFilterModelAll`),searchPlaceholder:e(`logsSearchModel`),emptyLabel:e(`logsNoFilterOptions`)}),(0,v.jsx)(je,{ariaLabel:e(`logsColProvider`),value:N,onChange:it,options:zt}),(0,v.jsx)(u,{ariaLabel:e(`logsSearchRequestId`),value:D,onChange:Qe,options:D?[{id:D,label:D}]:[],allLabel:e(`logsFilterIdAll`),searchPlaceholder:e(`logsSearchRequestId`),emptyLabel:e(`logsNoFilterOptions`),loadOptions:Vt,className:`min-w-56`}),(0,v.jsx)(h,{value:P,onChange:e=>at(e),ariaLabel:e(`logsFilterStreamAll`),options:[{id:`all`,label:e(`logsFilterStreamAll`)},{id:`stream`,label:e(`logsStreamYes`)},{id:`sync`,label:e(`logsStreamNo`)}]}),(0,v.jsx)(je,{ariaLabel:e(`errorKind`),value:F===`all`?``:F,onChange:e=>ot(e||`all`),options:[{id:``,label:e(`logsFilterKindAll`)},{id:`quota`,label:e(`logsKindQuota`)},{id:`rate_limit`,label:e(`logsKindRateLimit`)},{id:`auth`,label:e(`logsKindAuth`)},{id:`not_ready`,label:e(`logsKindNotReady`)},{id:`unavailable`,label:e(`logsKindUnavailable`)},{id:`invalid_request`,label:e(`logsKindInvalidRequest`)},{id:`model_not_available`,label:e(`logsKindModelNotAvailable`)}]})]}),(0,v.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,v.jsx)(`span`,{className:`text-xs font-medium text-muted`,children:e(`logsTimeRange`)}),(0,v.jsx)(h,{value:I,onChange:e=>st(e),ariaLabel:e(`logsTimeRange`),options:[{id:`all`,label:e(`logsTimeAll`)},{id:`1h`,label:e(`logsTime1h`)},{id:`24h`,label:e(`logsTime24h`)},{id:`7d`,label:e(`logsTime7d`)},{id:`custom`,label:e(`logsTimeCustom`)}]}),I===`custom`?(0,v.jsx)(oe,{className:`w-[min(100%,42rem)]`,value:L,onChange:ct,ariaLabel:e(`logsTimeRange`),fromLabel:e(`logsTimeFrom`),toLabel:e(`logsTimeTo`)}):null]})]}),(0,v.jsx)(ue,{className:`overflow-hidden p-0`,"aria-busy":S,children:un?(0,v.jsx)(be,{}):V.length===0?(0,v.jsx)(de,{icon:(0,v.jsx)(r,{size:22}),title:e(Ht?`logsNoMatch`:`logsEmptyRequests`),action:Ht?(0,v.jsx)(te,{size:`sm`,variant:`ghost`,onPress:on,children:e(`clearFilters`)}):null}):(0,v.jsx)(p,{children:(0,v.jsx)(p.ScrollContainer,{children:(0,v.jsxs)(p.Content,{"aria-label":e(`logsRequests`),children:[(0,v.jsxs)(p.Header,{children:[(0,v.jsx)(p.Column,{isRowHeader:!0,children:e(`logsColTime`)}),(0,v.jsx)(p.Column,{children:e(`logsColModel`)}),(0,v.jsx)(p.Column,{children:e(`logsColReasoning`)}),(0,v.jsx)(p.Column,{children:e(`logsColProvider`)}),(0,v.jsx)(p.Column,{children:e(`logsColAccount`)}),(0,v.jsx)(p.Column,{children:e(`logsColApiKey`)}),(0,v.jsx)(p.Column,{children:e(`logsColStatus`)}),(0,v.jsx)(p.Column,{children:e(`logsColStream`)}),(0,v.jsx)(p.Column,{children:e(`logsColLatency`)}),(0,v.jsx)(p.Column,{children:e(`logsColTokens`)})]}),(0,v.jsx)(p.Body,{children:V.map(n=>(0,v.jsxs)(p.Row,{className:`cursor-pointer`,onAction:()=>void sn(n),children:[(0,v.jsx)(p.Cell,{children:(0,v.jsxs)(`div`,{className:`py-1`,children:[(0,v.jsx)(`div`,{className:`mono text-xs`,children:y(n.created_at,t)}),(0,v.jsx)(`div`,{className:`mono mt-0.5 text-caption text-muted`,children:n.id})]})}),(0,v.jsxs)(p.Cell,{children:[(0,v.jsx)(`div`,{className:`text-body font-medium`,children:n.requested_model||`—`}),n.mapped_model&&n.mapped_model!==n.requested_model?(0,v.jsx)(`div`,{className:`mono mt-0.5 text-caption text-muted`,children:n.mapped_model}):null]}),(0,v.jsx)(p.Cell,{children:(0,v.jsx)(`span`,{className:`mono text-xs`,children:Le(n)||`—`})}),(0,v.jsx)(p.Cell,{children:(0,v.jsx)(`span`,{className:`text-xs`,children:Nt(n)})}),(0,v.jsxs)(p.Cell,{children:[(0,v.jsx)(`span`,{className:`text-xs`,children:n.account_id?Z.get(n.account_id)||n.account_id:`—`}),n.account_id&&Z.get(n.account_id)&&Z.get(n.account_id)!==n.account_id?(0,v.jsx)(`div`,{className:`mono mt-0.5 text-caption text-muted`,children:n.account_id}):null]}),(0,v.jsx)(p.Cell,{children:(0,v.jsx)(`span`,{className:`text-xs`,children:Rt(n)})}),(0,v.jsxs)(p.Cell,{children:[(0,v.jsx)(ge,{size:`sm`,variant:`soft`,color:Pe(n.status),children:n.status}),n.error_kind?(0,v.jsx)(`div`,{className:`mono mt-1 text-caption text-muted`,children:n.error_kind}):null]}),(0,v.jsx)(p.Cell,{children:(0,v.jsx)(`span`,{className:`text-xs text-muted`,children:n.stream?e(`logsStreamYes`):e(`logsStreamNo`)})}),(0,v.jsx)(p.Cell,{children:(0,v.jsx)(Ae,{latencyMs:n.latency_ms,ttfbMs:n.ttfb_ms,completionTokens:n.completion_tokens,stream:n.stream,labels:{ttft:e(`logsColTTFT`),total:e(`logsLatencyTotal`),tps:e(`logsOutputTPS`)}})}),(0,v.jsx)(p.Cell,{children:(0,v.jsx)(Re,{log:n,inLabel:e(`logsTokensIn`),outLabel:e(`logsTokensOut`),pointsLabel:t=>e(`logsTokensPoints`,{value:t})})})]},n.id))})]})})})}),(0,v.jsx)(i,{total:H,page:Q,pageCount:Yt,pageSize:z,loading:S,pageSizeLabel:e(`logsPageSize`),pageLabel:e(`logsPage`,{page:Q,pages:Yt}),prevLabel:e(`logsPrevPage`),nextLabel:e(`logsNextPage`),onPage:R,onPageSize:ut})]}),(0,v.jsxs)(f.Panel,{id:`runtime`,"data-tab-panel":`runtime`,className:`space-y-4 pt-5`,children:[(0,v.jsxs)(`div`,{className:`data-toolbar flex flex-wrap items-center justify-between gap-2`,children:[(0,v.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,v.jsx)(a,{className:`sm:w-72`,value:O,onChange:$e,placeholder:e(`logsSearchRuntime`),ariaLabel:e(`logsSearchRuntime`)}),(0,v.jsx)(u,{ariaLabel:e(`logsColAccount`),value:j,onChange:nt,options:Ft,allLabel:e(`logsFilterAccountAll`),searchPlaceholder:e(`logsSearchAccount`),emptyLabel:e(`logsNoFilterOptions`)}),(0,v.jsx)(h,{value:E,onChange:e=>Ze(e),ariaLabel:e(`logsLevelAll`),options:[{id:`all`,label:e(`logsLevelAll`)},{id:`info`,label:e(`logsLevelInfo`)},{id:`warn`,label:e(`logsLevelWarn`)},{id:`error`,label:e(`logsLevelError`)}]})]}),(0,v.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted`,children:[$===1?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)(`span`,{className:`status-dot`,"data-state":`ok`}),e(`logsAutoRefresh`)]}):null,(0,v.jsx)(`span`,{className:`mono`,children:an})]})]}),(0,v.jsx)(ue,{className:`overflow-hidden p-0`,"aria-busy":S,children:un?(0,v.jsx)(xe,{}):U.length===0?(0,v.jsx)(de,{icon:(0,v.jsx)(Ne,{size:22}),title:e(`logsEmptyRuntime`)}):(0,v.jsx)(`div`,{className:`divide-y divide-separator`,children:U.map(e=>(0,v.jsxs)(`div`,{className:`grid cursor-pointer gap-2 px-5 py-3 transition-colors hover:bg-surface-secondary/55 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent sm:grid-cols-[150px_72px_minmax(0,1fr)] sm:items-start`,role:`button`,tabIndex:0,onClick:()=>cn(e),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),cn(e))},children:[(0,v.jsx)(`div`,{className:`mono text-caption text-muted`,children:y(e.time,t)}),(0,v.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,v.jsx)(`span`,{className:`status-dot`,"data-state":Fe(e.level)}),(0,v.jsx)(`span`,{className:`font-medium text-muted`,children:e.level})]}),(0,v.jsxs)(`div`,{className:`min-w-0`,children:[e.account_id?(0,v.jsx)(`div`,{className:`mono mb-1 text-caption text-muted`,children:e.account_id}):null,(0,v.jsx)(`div`,{className:`mono break-all text-xs leading-5 text-foreground`,children:e.message})]})]},e.id))})}),(0,v.jsx)(i,{total:W,page:$,pageCount:Xt,pageSize:B,loading:S,pageSizeLabel:e(`logsPageSize`),pageLabel:e(`logsPage`,{page:$,pages:Xt}),prevLabel:e(`logsPrevPage`),nextLabel:e(`logsNextPage`),onPage:ft,onPageSize:pt})]})]}),(0,v.jsx)(d.Root,{isOpen:yt,onOpenChange:e=>{bt(e),e||vt(null)},children:(0,v.jsx)(d.Backdrop,{variant:`blur`,children:(0,v.jsx)(d.Container,{size:`lg`,scroll:`inside`,children:(0,v.jsxs)(d.Dialog,{className:`w-full max-w-4xl`,children:[(0,v.jsxs)(d.Header,{className:`items-start justify-between gap-4 px-5 pt-5`,children:[(0,v.jsxs)(`div`,{className:`min-w-0`,children:[(0,v.jsx)(d.Heading,{className:`text-section font-semibold`,children:e(`logsRuntimeDetailTitle`)}),(0,v.jsx)(`p`,{className:`mono mt-1 text-caption text-muted`,children:G?`#${G.id}`:`—`})]}),(0,v.jsx)(d.CloseTrigger,{"aria-label":e(`close`),className:`grid size-8 shrink-0 place-items-center rounded-lg text-muted transition-colors hover:bg-surface-secondary hover:text-foreground`,children:(0,v.jsx)(he,{size:16})})]}),(0,v.jsxs)(d.Body,{className:`space-y-5 px-5 pb-5`,children:[(0,v.jsx)(`dl`,{className:`grid gap-3 sm:grid-cols-2`,children:[[e(`logsColTime`),G?y(G.time,t):`—`],[e(`logsRuntimeLevel`),G?.level||`—`],[e(`logsRuntimeSource`),G?.source||`—`],[e(`logsColAccount`),G?.account_id||`—`]].map(([t,n])=>(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`dt`,{className:`text-caption text-muted`,children:t}),(0,v.jsx)(`dd`,{className:`mt-1 break-all text-body font-medium`,children:t===e(`logsRuntimeLevel`)&&G?(0,v.jsx)(ge,{size:`sm`,variant:`soft`,color:Ie(G.level),children:G.level}):n})]},String(t)))}),(0,v.jsxs)(`section`,{className:`space-y-2`,children:[(0,v.jsx)(`div`,{className:`text-xs font-medium text-muted`,children:e(`logsRuntimeMessage`)}),(0,v.jsx)(`pre`,{className:`mono max-h-[min(38rem,60vh)] overflow-auto whitespace-pre-wrap break-words rounded-lg bg-surface-secondary px-4 py-3 text-xs leading-6 text-foreground`,children:G?.message||`—`})]})]})]})})})}),(0,v.jsx)(d.Root,{isOpen:St,onOpenChange:e=>{Ct(e),e||(q.current+=1,Tt(!1),Dt(``),xt(null))},children:(0,v.jsx)(d.Backdrop,{variant:`blur`,children:(0,v.jsx)(d.Container,{size:`lg`,scroll:`inside`,children:(0,v.jsxs)(d.Dialog,{className:`w-full max-w-4xl`,children:[(0,v.jsxs)(d.Header,{className:`items-start justify-between gap-4 px-5 pt-5`,children:[(0,v.jsxs)(`div`,{className:`min-w-0`,children:[(0,v.jsx)(d.Heading,{className:`text-section font-semibold`,children:e(`logsDetailTitle`)}),(0,v.jsx)(`p`,{className:`mono mt-1 text-caption text-muted`,children:K?.id})]}),(0,v.jsx)(d.CloseTrigger,{"aria-label":e(`close`),className:`grid size-8 shrink-0 place-items-center rounded-lg text-muted transition-colors hover:bg-surface-secondary hover:text-foreground`,children:(0,v.jsx)(he,{size:16})})]}),(0,v.jsx)(d.Body,{className:`space-y-5 px-5 pb-5`,children:wt?(0,v.jsx)(ze,{}):Et?(0,v.jsx)(se,{title:e(`requestFailed`),description:Et}):K?(0,v.jsxs)(v.Fragment,{children:[K.error_message?(0,v.jsx)(se,{title:K.error_kind||e(`requestFailed`),description:K.error_message}):null,(0,v.jsxs)(`div`,{className:`space-y-4 rounded-lg bg-surface-secondary px-4 py-4`,children:[(0,v.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,v.jsx)(ge,{size:`sm`,variant:`soft`,color:Pe(K.status),children:K.status||`—`}),(0,v.jsx)(`span`,{className:`mono min-w-0 break-all text-body font-medium`,children:K.requested_model||`—`}),K.mapped_model&&K.mapped_model!==K.requested_model?(0,v.jsxs)(`span`,{className:`mono break-all text-caption text-muted`,children:[`→ `,K.mapped_model]}):null,Le(K)?(0,v.jsxs)(`span`,{className:`mono text-caption text-muted`,children:[`· `,Le(K)]}):null,(0,v.jsx)(`span`,{className:`mono ml-auto text-caption text-muted`,children:y(K.created_at,t)})]}),(0,v.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-4 gap-y-3 sm:grid-cols-3`,children:[(0,v.jsx)(b,{mono:!0,label:`${e(`logsColTokens`)} · ${e(`logsTokensIn`)} / ${e(`logsTokensOut`)}`,value:K.prompt_tokens==null&&K.completion_tokens==null?`—`:`${K.prompt_tokens??0} / ${K.completion_tokens??0}`}),(K.credits??K.usage_detail?.credit)==null?null:(0,v.jsx)(b,{mono:!0,label:e(`logsCreditConsumed`),value:`${Ve(K.credits??K.usage_detail?.credit)}${K.usage_detail?.unit?` ${K.usage_detail.unit}`:``}`}),(0,v.jsx)(b,{mono:!0,label:e(`logsColTTFT`),value:Ee(K.ttfb_ms)}),(0,v.jsx)(b,{mono:!0,label:e(`logsLatencyTotal`),value:Ee(K.latency_ms)}),(0,v.jsx)(b,{mono:!0,label:e(`logsOutputTPS`),value:we(De({completionTokens:K.completion_tokens,latencyMs:K.latency_ms,ttfbMs:K.ttfb_ms,stream:K.stream}))})]})]}),(0,v.jsx)(Be,{title:e(`logsSectionCall`),children:(0,v.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-4 gap-y-3 sm:grid-cols-3`,children:[(0,v.jsx)(b,{label:e(`logsColProvider`),value:Nt(K)}),(0,v.jsx)(b,{label:e(`logsColAccount`),value:K.account_id?Z.get(K.account_id)||K.account_id:`—`}),(0,v.jsx)(b,{label:e(`logsColApiKey`),value:Rt(K)}),(0,v.jsx)(b,{label:e(`logsColStream`),value:K.stream?e(`logsStreamYes`):e(`logsStreamNo`)}),(0,v.jsx)(b,{label:e(`logsRouting`),value:Pt(K.routing)})]})}),(0,v.jsx)(Be,{title:e(`logsAttempts`),aside:K.attempts?.length?(0,v.jsx)(`span`,{className:`mono text-caption text-muted`,children:K.attempts.length}):null,children:K.attempts?.length?(0,v.jsx)(`div`,{className:`divide-y divide-separator overflow-hidden rounded-lg bg-surface-secondary`,children:K.attempts.map(e=>(0,v.jsxs)(`div`,{className:`grid grid-cols-[32px_minmax(0,1fr)_auto] items-start gap-x-3 px-3 py-2.5`,children:[(0,v.jsxs)(`div`,{className:`mono pt-0.5 text-caption text-muted`,children:[`#`,e.attempt_index]}),(0,v.jsxs)(`div`,{className:`min-w-0`,children:[(0,v.jsx)(`div`,{className:`truncate text-body font-medium`,children:e.account_id?Z.get(e.account_id)||e.account_id:`—`}),e.error_message?(0,v.jsxs)(`div`,{className:`mt-0.5 break-all text-caption text-muted`,children:[e.error_kind?(0,v.jsx)(`span`,{className:`mono mr-1.5`,children:e.error_kind}):null,e.error_message]}):null]}),(0,v.jsxs)(`div`,{className:`flex items-center gap-2`,children:[e.latency_ms==null?null:(0,v.jsx)(`span`,{className:`mono text-caption text-muted`,children:Ee(e.latency_ms)}),(0,v.jsx)(ge,{size:`sm`,variant:`soft`,color:Pe(e.status===`failover`?`canceled`:e.status),children:e.status})]})]},e.id))}):(0,v.jsx)(`p`,{className:`text-caption text-muted`,children:e(`logsNoAttempts`)})}),K.message_count||K.stream_diagnostic?(0,v.jsx)(Be,{title:e(`logsSectionDiagnostics`),children:(0,v.jsxs)(`div`,{className:`space-y-4 rounded-lg bg-surface-secondary px-4 py-3`,children:[K.message_count?(0,v.jsxs)(`div`,{className:`space-y-2`,children:[(0,v.jsx)(`div`,{className:`text-caption font-medium text-muted`,children:e(`logsMessageShape`)}),(0,v.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-4 gap-y-3 sm:grid-cols-3`,children:[(0,v.jsx)(b,{mono:!0,label:e(`logsMessageCount`),value:K.message_count}),(0,v.jsx)(b,{mono:!0,label:e(`logsEmptyMessageIndexes`),value:K.empty_message_indexes?.length?K.empty_message_indexes.join(`, `):`—`}),(0,v.jsx)(b,{mono:!0,wide:!0,label:e(`logsMessageRoles`),value:K.message_roles?.join(` → `)||`—`})]})]}):null,K.message_count&&K.stream_diagnostic?(0,v.jsx)(`div`,{className:`border-t border-separator`}):null,K.stream_diagnostic?(0,v.jsxs)(`div`,{className:`space-y-2`,children:[(0,v.jsx)(`div`,{className:`text-caption font-medium text-muted`,children:e(`logsStreamDiagnostics`)}),(0,v.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-4 gap-y-3 sm:grid-cols-3`,children:[(0,v.jsx)(b,{mono:!0,label:e(`logsUpstreamStatus`),value:K.stream_diagnostic.upstream_status??`—`}),(0,v.jsx)(b,{mono:!0,label:e(`logsStreamComplete`),value:K.stream_diagnostic.saw_done?e(`yes`):e(`no`)}),(0,v.jsx)(b,{mono:!0,label:e(`logsCancellationSource`),value:K.stream_diagnostic.cancellation_source||`—`}),(0,v.jsx)(b,{mono:!0,label:e(`logsSSEEvents`),value:K.stream_diagnostic.sse_event_count}),(0,v.jsx)(b,{mono:!0,label:e(`logsBytesRead`),value:Te(K.stream_diagnostic.bytes_read)}),(0,v.jsx)(b,{mono:!0,label:e(`logsLastEvent`),value:K.stream_diagnostic.last_event||`—`}),K.stream_diagnostic.context_err?(0,v.jsx)(b,{mono:!0,wide:!0,label:`context`,value:K.stream_diagnostic.context_err}):null,K.stream_diagnostic.relay_error?(0,v.jsx)(b,{mono:!0,wide:!0,label:`relay`,value:K.stream_diagnostic.relay_error}):null]})]}):null]})}):null]}):null})]})})})}),(0,v.jsx)(ce,{isOpen:Ot,title:e(`logsClear`),description:e(`logsClearConfirm`),confirmLabel:e(`logsClear`),cancelLabel:e(`close`),closeLabel:e(`close`),isPending:At,onClose:()=>kt(!1),onConfirm:()=>void ln()})]})}export{S as LogsPage}; \ No newline at end of file diff --git a/internal/webui/static/assets/ModelPoolPage-ARfxpk1G.js b/internal/webui/static/assets/ModelPoolPage-ARfxpk1G.js new file mode 100644 index 00000000..49ee4fbb --- /dev/null +++ b/internal/webui/static/assets/ModelPoolPage-ARfxpk1G.js @@ -0,0 +1 @@ +import{a as e,c as t,n}from"./shim-mfK0Rmj6.js";import{t as r}from"./Plus.es-CSLpU0CT.js";import{t as i}from"./TrashSimple.es-51cVgQMz.js";import{dt as a,n as o,r as s}from"./useI18n-BBOAnu2u.js";import{t as c}from"./label-BVCjtfNQ.js";import{n as l,t as u}from"./PageAlert-DZC7IhXp.js";import{t as d}from"./ConfirmDialog-D6gNei8x.js";import{t as f}from"./card-QlCdtlk0.js";import{n as ee,r as p,t as m}from"./number-field-nGZCb975.js";import{t as h}from"./description-CNxrVc-S.js";import{t as g}from"./EmptyPanel-Bs-jQMvG.js";import{n as te,r as _,t as v}from"./FormRow-Bhp_wPvH.js";import{t as y}from"./modal-DHeFzFnN.js";import{t as b}from"./table-D-oKYYsp.js";import{A as x,g as S,p as C,u as w}from"./overview-CJvUvgoD.js";import{M as T,Yt as E,kt as D,m as O,n as k,t as A}from"./index-B9eWF6SH.js";import{t as j}from"./ProviderMark-IiAZTaQS.js";import{n as M}from"./provider-gHnttGKq.js";import{t as N}from"./FilterSelect-GGHAJGuF.js";var P=t(e(),1),F=new Map([[`bold`,P.createElement(P.Fragment,null,P.createElement(`path`,{d:`M208.49,152.49l-72,72a12,12,0,0,1-17,0l-72-72a12,12,0,0,1,17-17L116,187V40a12,12,0,0,1,24,0V187l51.51-51.52a12,12,0,0,1,17,17Z`}))],[`duotone`,P.createElement(P.Fragment,null,P.createElement(`path`,{d:`M200,144l-72,72L56,144Z`,opacity:`0.2`}),P.createElement(`path`,{d:`M207.39,140.94A8,8,0,0,0,200,136H136V40a8,8,0,0,0-16,0v96H56a8,8,0,0,0-5.66,13.66l72,72a8,8,0,0,0,11.32,0l72-72A8,8,0,0,0,207.39,140.94ZM128,204.69,75.31,152H180.69Z`}))],[`fill`,P.createElement(P.Fragment,null,P.createElement(`path`,{d:`M205.66,149.66l-72,72a8,8,0,0,1-11.32,0l-72-72A8,8,0,0,1,56,136h64V40a8,8,0,0,1,16,0v96h64a8,8,0,0,1,5.66,13.66Z`}))],[`light`,P.createElement(P.Fragment,null,P.createElement(`path`,{d:`M204.24,148.24l-72,72a6,6,0,0,1-8.48,0l-72-72a6,6,0,0,1,8.48-8.48L122,201.51V40a6,6,0,0,1,12,0V201.51l61.76-61.75a6,6,0,0,1,8.48,8.48Z`}))],[`regular`,P.createElement(P.Fragment,null,P.createElement(`path`,{d:`M205.66,149.66l-72,72a8,8,0,0,1-11.32,0l-72-72a8,8,0,0,1,11.32-11.32L120,196.69V40a8,8,0,0,1,16,0V196.69l58.34-58.35a8,8,0,0,1,11.32,11.32Z`}))],[`thin`,P.createElement(P.Fragment,null,P.createElement(`path`,{d:`M202.83,146.83l-72,72a4,4,0,0,1-5.66,0l-72-72a4,4,0,0,1,5.66-5.66L124,206.34V40a4,4,0,0,1,8,0V206.34l65.17-65.17a4,4,0,0,1,5.66,5.66Z`}))]]),I=new Map([[`bold`,P.createElement(P.Fragment,null,P.createElement(`path`,{d:`M208.49,120.49a12,12,0,0,1-17,0L140,69V216a12,12,0,0,1-24,0V69L64.49,120.49a12,12,0,0,1-17-17l72-72a12,12,0,0,1,17,0l72,72A12,12,0,0,1,208.49,120.49Z`}))],[`duotone`,P.createElement(P.Fragment,null,P.createElement(`path`,{d:`M200,112H56l72-72Z`,opacity:`0.2`}),P.createElement(`path`,{d:`M205.66,106.34l-72-72a8,8,0,0,0-11.32,0l-72,72A8,8,0,0,0,56,120h64v96a8,8,0,0,0,16,0V120h64a8,8,0,0,0,5.66-13.66ZM75.31,104,128,51.31,180.69,104Z`}))],[`fill`,P.createElement(P.Fragment,null,P.createElement(`path`,{d:`M207.39,115.06A8,8,0,0,1,200,120H136v96a8,8,0,0,1-16,0V120H56a8,8,0,0,1-5.66-13.66l72-72a8,8,0,0,1,11.32,0l72,72A8,8,0,0,1,207.39,115.06Z`}))],[`light`,P.createElement(P.Fragment,null,P.createElement(`path`,{d:`M204.24,116.24a6,6,0,0,1-8.48,0L134,54.49V216a6,6,0,0,1-12,0V54.49L60.24,116.24a6,6,0,0,1-8.48-8.48l72-72a6,6,0,0,1,8.48,0l72,72A6,6,0,0,1,204.24,116.24Z`}))],[`regular`,P.createElement(P.Fragment,null,P.createElement(`path`,{d:`M205.66,117.66a8,8,0,0,1-11.32,0L136,59.31V216a8,8,0,0,1-16,0V59.31L61.66,117.66a8,8,0,0,1-11.32-11.32l72-72a8,8,0,0,1,11.32,0l72,72A8,8,0,0,1,205.66,117.66Z`}))],[`thin`,P.createElement(P.Fragment,null,P.createElement(`path`,{d:`M202.83,114.83a4,4,0,0,1-5.66,0L132,49.66V216a4,4,0,0,1-8,0V49.66L58.83,114.83a4,4,0,0,1-5.66-5.66l72-72a4,4,0,0,1,5.66,0l72,72A4,4,0,0,1,202.83,114.83Z`}))]]),L=P.forwardRef((e,t)=>P.createElement(a,{ref:t,...e,weights:F}));L.displayName=`ArrowDownIcon`;var ne=L,R=P.forwardRef((e,t)=>P.createElement(a,{ref:t,...e,weights:I}));R.displayName=`ArrowUpIcon`;var z=R;function B(){return x(`/api/aggregations`)}function V(e){return x(`/api/aggregations`,{method:`POST`,body:JSON.stringify(e)})}function H(e,t){return x(`/api/aggregations/${encodeURIComponent(e)}`,{method:`PATCH`,body:JSON.stringify(t)})}function U(e){return x(`/api/aggregations/${encodeURIComponent(e)}`,{method:`DELETE`})}var W=[`priority`,`round-robin`,`fill-first`,`fefo`,`least-quota-first`,`most-quota-first`],G=n(),K=[`none`,`low`,`medium`,`high`,`xhigh`,`max`],re={none:`modelPoolReasoningLevelNone`,low:`modelPoolReasoningLevelLow`,medium:`modelPoolReasoningLevelMedium`,high:`modelPoolReasoningLevelHigh`,xhigh:`modelPoolReasoningLevelXhigh`,max:`modelPoolReasoningLevelMax`};function ie(){return{key:`${Date.now()}-${Math.random()}`,provider:``,region:``,model:``,account_id:``,priority:0,weight:100}}function q(e){return String(e||`qoder`).trim().toLowerCase()}function J(e){let t=String(e||``).trim().toLowerCase();return t===``||t===`gl`?`global`:t}function ae(e,t){let n=new Set(t.map(e=>q(e.provider)));return e.filter(e=>n.has(q(e.id))).map(e=>({id:e.id,label:e.label}))}function oe(e,t,n){let r=e.find(e=>e.id===n);if(!r)return[];let i=new Set(t.filter(e=>q(e.provider)===q(n)).map(e=>J(e.region)));return(r.regions||[]).filter(e=>i.has(J(e.id))).map(e=>({id:e.id,label:e.label}))}function se(e,t,n,r){let i=new Set,a=[],o=String(t||``).trim().toLowerCase(),s=String(n||``).trim()?J(n):``;for(let t of e){let e=String(t.provider||t.owned_by||``).trim().toLowerCase();if(e&&e!==o)continue;if(s){let e=[t.region,...t.regions||[]].map(e=>J(e)).filter(Boolean);if(e.length&&!e.includes(s))continue}let n=t.id;if(!n||i.has(n))continue;i.add(n);let r=t.display_name||t.route_display_name||n;a.push({id:n,label:`${r} (${n})`})}return a.length||a.push({id:``,label:r(`modelPoolNoModels`)}),a}function Y(e,t){return t(`modelPoolStrategy_${e}`)}function X(){let{t:e}=o(),{enabled:t,loading:n}=k(),[a,c]=(0,P.useState)([]),[l,ee]=(0,P.useState)([]),[p,m]=(0,P.useState)([]),[h,_]=(0,P.useState)([]),[v,y]=(0,P.useState)(!0),[x,D]=(0,P.useState)(``),[j,M]=(0,P.useState)(!1),[N,F]=(0,P.useState)(null),[I,L]=(0,P.useState)(null),[ne,R]=(0,P.useState)(!1),W=(0,P.useCallback)(async()=>{y(!0);try{let[e,t,n,r]=await Promise.all([B(),S(),C(void 0,!1,`regional`),w()]);c(e.data||[]),ee(t.data||[]),m(n.data||[]),_(r.data||[]),D(``)}catch(e){D(e instanceof Error?e.message:String(e))}finally{y(!1)}},[]);(0,P.useEffect)(()=>{!t||n||W()},[t,n,W]);async function K(t,n){let r=t.enabled;c(e=>e.map(e=>e.id===t.id?{...e,enabled:n}:e));try{let r=await H(t.id,{enabled:n});c(e=>e.map(e=>e.id===t.id?r:e)),A({type:`success`,title:e(`modelPoolSaved`)})}catch(e){c(e=>e.map(e=>e.id===t.id?{...e,enabled:r}:e)),A({type:`error`,title:e instanceof Error?e.message:String(e)})}}async function re(){if(I){R(!0);try{await U(I.id),c(e=>e.filter(e=>e.id!==I.id)),A({type:`success`,title:e(`modelPoolDeleted`)}),L(null)}catch(e){A({type:`error`,title:e instanceof Error?e.message:String(e)})}finally{R(!1)}}}return n?(0,G.jsx)(O,{className:`h-64 w-full rounded-xl`}):t?(0,G.jsxs)(`div`,{className:`space-y-6`,children:[(0,G.jsxs)(`section`,{className:`flex flex-wrap items-end justify-between gap-4 pb-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h1`,{className:`text-title font-semibold tracking-tight`,children:e(`modelPoolTitle`)}),(0,G.jsx)(`p`,{className:`mt-1 max-w-2xl text-caption text-muted`,children:e(`modelPoolLead`)})]}),(0,G.jsxs)(s,{onPress:()=>M(!0),children:[(0,G.jsx)(r,{size:16}),e(`modelPoolCreate`)]})]}),x?(0,G.jsx)(u,{status:`danger`,title:x}):null,(0,G.jsx)(f,{className:`overflow-hidden`,children:v?(0,G.jsxs)(`div`,{className:`space-y-3 p-5`,children:[(0,G.jsx)(O,{className:`h-10 w-full`}),(0,G.jsx)(O,{className:`h-10 w-full`}),(0,G.jsx)(O,{className:`h-10 w-full`})]}):a.length===0?(0,G.jsx)(g,{title:e(`modelPoolEmpty`),hint:e(`modelPoolEmptyHint`),icon:(0,G.jsx)(z,{size:28})}):(0,G.jsx)(b,{children:(0,G.jsx)(b.ScrollContainer,{children:(0,G.jsxs)(b.Content,{"aria-label":e(`modelPoolTitle`),children:[(0,G.jsxs)(b.Header,{children:[(0,G.jsx)(b.Column,{children:e(`modelPoolColName`)}),(0,G.jsx)(b.Column,{children:e(`modelPoolColStrategy`)}),(0,G.jsx)(b.Column,{children:e(`modelPoolColMembers`)}),(0,G.jsx)(b.Column,{children:e(`modelPoolColFailover`)}),(0,G.jsx)(b.Column,{children:e(`modelPoolColEnabled`)}),(0,G.jsx)(b.Column,{children:e(`modelPoolColActions`)})]}),(0,G.jsx)(b.Body,{children:a.map(t=>(0,G.jsxs)(b.Row,{children:[(0,G.jsx)(b.Cell,{children:(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`div`,{className:`font-medium`,children:t.name}),(0,G.jsx)(`div`,{className:`mono text-caption text-muted`,children:t.id})]})}),(0,G.jsx)(b.Cell,{children:(0,G.jsx)(T,{size:`sm`,variant:`soft`,children:Y(t.strategy,e)})}),(0,G.jsx)(b.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-caption`,children:t.members.length})}),(0,G.jsx)(b.Cell,{children:(0,G.jsx)(`span`,{className:`text-caption text-muted`,children:t.allow_fallbacks?e(`modelPoolFailoverOn`,{count:t.max_attempts}):e(`modelPoolFailoverOff`)})}),(0,G.jsx)(b.Cell,{children:(0,G.jsx)(te,{isSelected:t.enabled,ariaLabel:`${e(`modelPoolColEnabled`)} ${t.id}`,onChange:e=>void K(t,e)})}),(0,G.jsx)(b.Cell,{children:(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(s,{size:`sm`,variant:`ghost`,onPress:()=>F(t),children:e(`edit`)}),(0,G.jsx)(s,{isIconOnly:!0,size:`sm`,variant:`ghost`,"aria-label":e(`delete`),onPress:()=>L(t),children:(0,G.jsx)(i,{size:16})})]})})]},t.id))})]})})})}),(j||N)&&(0,G.jsx)(Z,{isOpen:!0,initial:N,descriptors:l,models:p,accounts:h,t:e,onClose:()=>{M(!1),F(null)},onSave:async t=>{N?await H(N.id,t):await V(t),A({type:`success`,title:e(`modelPoolSaved`)}),M(!1),F(null),await W()}}),(0,G.jsx)(d,{isOpen:!!I,title:e(`modelPoolDeleteTitle`),description:I?e(`modelPoolDeleteDesc`,{name:I.name}):``,confirmLabel:e(`delete`),cancelLabel:e(`cancel`),closeLabel:e(`close`),isPending:ne,onClose:()=>L(null),onConfirm:()=>void re()})]}):(0,G.jsx)(E,{to:`/`,replace:!0})}function Z({isOpen:e,initial:t,descriptors:n,models:a,accounts:o,t:u,onClose:d,onSave:f}){let[g,b]=(0,P.useState)(``),[x,S]=(0,P.useState)(``),[C,w]=(0,P.useState)(`priority`),[T,E]=(0,P.useState)(!0),[O,k]=(0,P.useState)(3),[A,F]=(0,P.useState)(0),[I,L]=(0,P.useState)(0),[R,B]=(0,P.useState)([]),[V,H]=(0,P.useState)(``),[U,q]=(0,P.useState)([]),[J,X]=(0,P.useState)(``),[Z,Q]=(0,P.useState)(!1);(0,P.useEffect)(()=>{e&&(b(t?.id||``),S(t?.name||``),w(t?.strategy||`priority`),E(t?.allow_fallbacks??!0),k(t?.max_attempts??3),F(t?.context_length??0),L(t?.max_output_tokens??0),B(t?.reasoning_options??[]),H(t?.reasoning_effort??``),q((t?.members||[]).map(e=>({...e,key:`${e.provider}-${e.model}-${Math.random()}`}))),X(``))},[t,e]);let ce=(0,P.useMemo)(()=>W.map(e=>({id:e,label:Y(e,u)})),[u]),le=(0,P.useMemo)(()=>ae(n,o),[n,o]);function $(e,t){q(n=>n.map(n=>n.key===e?{...n,...t}:n))}function ue(e,t){q(n=>{let r=[...n],i=e+t;return i<0||i>=r.length?n:([r[e],r[i]]=[r[i],r[e]],r.map((e,t)=>({...e,priority:t})))})}function de(e){let t=R.includes(e)?R.filter(t=>t!==e):[...R,e];B(t),V&&!t.includes(V)&&H(``)}async function fe(e){if(e?.preventDefault(),!t){let e=g.trim().toLowerCase();if(!e){X(u(`modelPoolIdRequired`));return}if(!/^[a-z0-9.\-\/]+$/.test(e)){X(u(`modelPoolIdInvalid`));return}}if(!U.length){X(u(`modelPoolMembersRequired`));return}if(U.some(e=>!e.provider||!e.model)){X(u(`modelPoolMemberIncomplete`));return}if(!Number.isInteger(O)||O<1||O>64){X(u(`modelPoolAttemptsInvalid`));return}if(!Number.isInteger(A)||A<0){X(u(`modelPoolCapabilitiesInvalid`));return}if(!Number.isInteger(I)||I<0){X(u(`modelPoolCapabilitiesInvalid`));return}if(V&&!R.includes(V)){X(u(`modelPoolReasoningInvalid`));return}Q(!0),X(``);try{let e={name:x.trim()||t?.id||g.trim().toLowerCase(),strategy:C,allow_fallbacks:T,max_attempts:O,context_length:A,max_output_tokens:I,reasoning_options:R,reasoning_effort:V,members:U.map((e,t)=>({provider:e.provider,region:e.region||``,model:e.model,account_id:``,priority:t,weight:e.weight||100}))};t||(e.id=g.trim().toLowerCase()),await f(e)}catch(e){X(e instanceof Error?e.message:String(e))}finally{Q(!1)}}return(0,G.jsx)(y.Root,{isOpen:e,onOpenChange:e=>{!e&&!Z&&d()},children:(0,G.jsx)(y.Backdrop,{variant:`blur`,children:(0,G.jsx)(y.Container,{placement:`center`,size:`lg`,scroll:`inside`,children:(0,G.jsx)(y.Dialog,{className:`sm:min-w-[40rem]`,children:(0,G.jsxs)(ee,{className:`flex min-h-0 flex-1 flex-col`,onSubmit:fe,children:[(0,G.jsxs)(y.Header,{className:`items-start justify-between gap-4 px-6 pt-6`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(y.Heading,{className:`text-section font-semibold`,children:u(t?`modelPoolEdit`:`modelPoolCreate`)}),(0,G.jsx)(`p`,{className:`mt-1.5 text-body leading-6 text-muted`,children:u(`modelPoolEditorHint`)})]}),(0,G.jsx)(y.CloseTrigger,{isDisabled:Z,"aria-label":u(`close`),className:`grid size-9 place-items-center rounded-lg text-muted hover:bg-surface-secondary`,children:(0,G.jsx)(D,{size:18})})]}),(0,G.jsxs)(y.Body,{className:`space-y-5 px-6 pb-2 pt-1`,children:[t?null:(0,G.jsx)(v,{label:u(`modelPoolId`),hint:u(`modelPoolIdHint`),children:(0,G.jsx)(_,{value:g,onChange:e=>b(e.target.value),placeholder:`my-claude`,"aria-label":u(`modelPoolId`),disabled:Z})}),(0,G.jsx)(v,{label:u(`modelPoolName`),hint:u(`modelPoolNameHint`),children:(0,G.jsx)(_,{value:x,onChange:e=>S(e.target.value),placeholder:u(`modelPoolNamePh`),"aria-label":u(`modelPoolName`),disabled:Z})}),(0,G.jsx)(v,{label:u(`modelPoolStrategy`),hint:u(`modelPoolStrategyHint`),children:(0,G.jsx)(N,{value:C,onChange:w,ariaLabel:u(`modelPoolStrategy`),options:ce,className:`w-full`})}),(0,G.jsx)(v,{label:u(`modelPoolFailover`),children:(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4`,children:[(0,G.jsx)(te,{isSelected:T,ariaLabel:u(`modelPoolFailover`),label:u(`modelPoolFailover`),onChange:E,isDisabled:Z}),(0,G.jsx)(m,{value:O,onChange:e=>k(e??3),minValue:1,maxValue:64,isDisabled:Z||!T,children:(0,G.jsxs)(m.Group,{children:[(0,G.jsx)(m.DecrementButton,{}),(0,G.jsx)(m.Input,{"aria-label":u(`modelPoolMaxAttempts`)}),(0,G.jsx)(m.IncrementButton,{})]})}),(0,G.jsx)(h,{className:`text-caption text-muted`,children:u(`modelPoolMaxAttemptsHint`)})]})}),(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(c,{className:`text-body font-medium text-muted`,children:u(`modelPoolCapabilities`)}),(0,G.jsx)(h,{className:`text-caption leading-5 text-muted`,children:u(`modelPoolCapabilitiesHint`)})]}),(0,G.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,G.jsx)(v,{label:u(`modelPoolContextLength`),hint:u(`modelPoolContextLengthHint`),align:`start`,children:(0,G.jsx)(m,{value:A,onChange:e=>F(e??0),minValue:0,maxValue:4e6,isDisabled:Z,children:(0,G.jsxs)(m.Group,{children:[(0,G.jsx)(m.DecrementButton,{}),(0,G.jsx)(m.Input,{"aria-label":u(`modelPoolContextLength`)}),(0,G.jsx)(m.IncrementButton,{})]})})}),(0,G.jsx)(v,{label:u(`modelPoolMaxOutput`),hint:u(`modelPoolMaxOutputHint`),align:`start`,children:(0,G.jsx)(m,{value:I,onChange:e=>L(e??0),minValue:0,maxValue:4e6,isDisabled:Z,children:(0,G.jsxs)(m.Group,{children:[(0,G.jsx)(m.DecrementButton,{}),(0,G.jsx)(m.Input,{"aria-label":u(`modelPoolMaxOutput`)}),(0,G.jsx)(m.IncrementButton,{})]})})})]}),(0,G.jsx)(v,{label:u(`modelPoolReasoningLevels`),hint:u(`modelPoolReasoningLevelsHint`),align:`start`,children:(0,G.jsxs)(`div`,{className:`space-y-2.5`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,G.jsx)(`span`,{className:`mono text-caption text-muted`,children:u(`modelPoolReasoningSelected`,{n:R.length,total:K.length})}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(s,{size:`sm`,variant:`ghost`,onPress:()=>B([...K]),isDisabled:Z||R.length===K.length,children:u(`modelPoolReasoningSelectAll`)}),(0,G.jsx)(s,{size:`sm`,variant:`ghost`,onPress:()=>{B([]),H(``)},isDisabled:Z||R.length===0,children:u(`modelPoolReasoningClear`)})]})]}),(0,G.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:K.map(e=>{let t=R.includes(e);return(0,G.jsx)(p,{isSelected:t,isDisabled:Z,onChange:()=>de(e),className:`rounded-xl border px-3 py-2 transition-colors ${t?`border-accent bg-surface-secondary`:`border-separator hover:bg-surface-secondary/60`}`,children:(0,G.jsxs)(p.Content,{"aria-label":`${u(`modelPoolReasoningLevels`)} ${e}`,className:`w-full cursor-pointer items-start gap-2.5`,children:[(0,G.jsx)(p.Control,{children:(0,G.jsx)(p.Indicator,{})}),(0,G.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,G.jsx)(`span`,{className:`mono text-body leading-5`,children:e}),(0,G.jsx)(`span`,{className:`text-caption leading-4 text-muted`,children:u(re[e])})]})]})},e)})}),R.length===0?(0,G.jsx)(h,{className:`text-caption leading-5 text-muted`,children:u(`modelPoolReasoningEmpty`)}):null]})}),(0,G.jsx)(v,{label:u(`modelPoolReasoningDefault`),hint:u(`modelPoolReasoningDefaultHint`),align:`start`,children:(0,G.jsx)(N,{value:V,onChange:H,ariaLabel:u(`modelPoolReasoningDefault`),options:[{id:``,label:u(`modelPoolReasoningAuto`)},...R.map(e=>({id:e,label:e}))],className:`w-full`,isDisabled:Z||R.length===0})})]}),(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(c,{className:`text-body font-medium text-muted`,children:u(`modelPoolMembers`)}),(0,G.jsx)(h,{className:`text-caption leading-5 text-muted`,children:u(`modelPoolMembersHint`)})]}),(0,G.jsxs)(s,{size:`sm`,variant:`ghost`,onPress:()=>q(e=>[...e,ie()]),isDisabled:Z,children:[(0,G.jsx)(r,{size:14}),u(`modelPoolAddMember`)]})]}),U.length===0?(0,G.jsx)(`p`,{className:`rounded-lg bg-surface-secondary px-3 py-2.5 text-caption text-muted`,children:u(`modelPoolMembersEmpty`)}):(0,G.jsx)(`div`,{className:`space-y-2`,children:U.map((e,t)=>{let r=oe(n,o,e.provider),l=se(a,e.provider,e.region||``,u);return(0,G.jsxs)(`div`,{className:`rounded-xl bg-surface-secondary p-3`,children:[(0,G.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,G.jsxs)(`span`,{className:`text-caption font-medium text-muted`,children:[`#`,t+1]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(s,{isIconOnly:!0,size:`sm`,variant:`ghost`,"aria-label":u(`modelPoolMoveUp`),onPress:()=>ue(t,-1),isDisabled:Z||t===0,children:(0,G.jsx)(z,{size:15})}),(0,G.jsx)(s,{isIconOnly:!0,size:`sm`,variant:`ghost`,"aria-label":u(`modelPoolMoveDown`),onPress:()=>ue(t,1),isDisabled:Z||t===U.length-1,children:(0,G.jsx)(ne,{size:15})}),(0,G.jsx)(s,{isIconOnly:!0,size:`sm`,variant:`ghost`,"aria-label":u(`delete`),onPress:()=>q(t=>t.filter(t=>t.key!==e.key)),isDisabled:Z,children:(0,G.jsx)(i,{size:15})})]})]}),(0,G.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:[(0,G.jsxs)(`div`,{className:`space-y-1`,children:[(0,G.jsx)(c,{className:`text-caption text-muted`,children:u(`modelPoolProvider`)}),(0,G.jsx)(N,{value:e.provider,onChange:t=>$(e.key,{provider:t,region:``,model:``,account_id:``}),ariaLabel:u(`modelPoolProvider`),options:le,className:`w-full`})]}),(0,G.jsxs)(`div`,{className:`space-y-1`,children:[(0,G.jsx)(c,{className:`text-caption text-muted`,children:u(`modelPoolRegion`)}),(0,G.jsx)(N,{value:e.region||``,onChange:t=>$(e.key,{region:t,model:``,account_id:``}),ariaLabel:u(`modelPoolRegion`),options:[{id:``,label:u(`modelPoolAnyRegion`)},...r],className:`w-full`})]}),(0,G.jsxs)(`div`,{className:`space-y-1 sm:col-span-2`,children:[(0,G.jsx)(c,{className:`text-caption text-muted`,children:u(`modelPoolModel`)}),(0,G.jsx)(N,{value:e.model,onChange:t=>$(e.key,{model:t}),ariaLabel:u(`modelPoolModel`),options:l,className:`w-full`})]}),(0,G.jsxs)(`div`,{className:`space-y-1 sm:col-span-2`,children:[(0,G.jsx)(c,{className:`text-caption text-muted`,children:u(`modelPoolWeight`)}),(0,G.jsx)(m,{value:e.weight,onChange:t=>$(e.key,{weight:t??100}),minValue:1,maxValue:1e6,isDisabled:Z,children:(0,G.jsxs)(m.Group,{children:[(0,G.jsx)(m.DecrementButton,{}),(0,G.jsx)(m.Input,{"aria-label":u(`modelPoolWeight`)}),(0,G.jsx)(m.IncrementButton,{})]})})]})]}),e.provider?(0,G.jsxs)(`div`,{className:`mt-2 flex items-center gap-2 text-caption text-muted`,children:[(0,G.jsx)(j,{provider:e.provider,size:14}),(0,G.jsx)(`span`,{children:M(e.provider,e.region||``,u)})]}):null]},e.key)})})]})]}),J?(0,G.jsx)(`div`,{className:`px-6 pb-2`,children:(0,G.jsxs)(l,{status:`danger`,children:[(0,G.jsx)(l.Indicator,{}),(0,G.jsx)(l.Content,{children:(0,G.jsx)(l.Title,{children:J})})]})}):null,(0,G.jsxs)(y.Footer,{className:`justify-end`,children:[(0,G.jsx)(s,{variant:`ghost`,isDisabled:Z,onPress:d,children:u(`cancel`)}),(0,G.jsx)(s,{type:`submit`,isPending:Z,children:u(t?`save`:`create`)})]})]})})})})})}export{X as ModelPoolPage}; \ No newline at end of file diff --git a/internal/webui/static/assets/ModelPoolPage-BuIJpHXI.js b/internal/webui/static/assets/ModelPoolPage-BuIJpHXI.js deleted file mode 100644 index 26912aff..00000000 --- a/internal/webui/static/assets/ModelPoolPage-BuIJpHXI.js +++ /dev/null @@ -1 +0,0 @@ -import{a as e,c as t,n}from"./shim-mfK0Rmj6.js";import{t as r}from"./Plus.es-W6ztpkEI.js";import{t as i}from"./TrashSimple.es-BiXnQzNp.js";import{n as a,pt as o,r as s}from"./useI18n-BSw4X3mq.js";import{t as c}from"./label-n7vfsS35.js";import{n as l,t as u}from"./PageAlert-CaDjxveS.js";import{t as d}from"./ConfirmDialog-C6PfmZuk.js";import{n as f}from"./useToggle-HDaAPzVy.js";import{t as p}from"./description-0cu8nG7R.js";import{t as m}from"./EmptyPanel-Bs-jQMvG.js";import{n as h,t as g}from"./FormRow-D36RiZfK.js";import{t as _}from"./modal-BVwBjYX-.js";import{n as v,t as y}from"./number-field-D7UJ0QLF.js";import{t as b}from"./CompactSwitch-DH1Gk66-.js";import{t as x}from"./table-BE40Giyo.js";import{O as S,g as C,p as w,u as T}from"./overview-m01k08K8.js";import{Dt as E,M as D,m as O,n as k,qt as A,t as j}from"./index-C8_qeOs_.js";import{t as M}from"./ProviderMark-IiAZTaQS.js";import{n as N}from"./provider-gHnttGKq.js";import{t as P}from"./FilterSelect-CNXkxdW1.js";var F=t(e(),1),I=new Map([[`bold`,F.createElement(F.Fragment,null,F.createElement(`path`,{d:`M208.49,152.49l-72,72a12,12,0,0,1-17,0l-72-72a12,12,0,0,1,17-17L116,187V40a12,12,0,0,1,24,0V187l51.51-51.52a12,12,0,0,1,17,17Z`}))],[`duotone`,F.createElement(F.Fragment,null,F.createElement(`path`,{d:`M200,144l-72,72L56,144Z`,opacity:`0.2`}),F.createElement(`path`,{d:`M207.39,140.94A8,8,0,0,0,200,136H136V40a8,8,0,0,0-16,0v96H56a8,8,0,0,0-5.66,13.66l72,72a8,8,0,0,0,11.32,0l72-72A8,8,0,0,0,207.39,140.94ZM128,204.69,75.31,152H180.69Z`}))],[`fill`,F.createElement(F.Fragment,null,F.createElement(`path`,{d:`M205.66,149.66l-72,72a8,8,0,0,1-11.32,0l-72-72A8,8,0,0,1,56,136h64V40a8,8,0,0,1,16,0v96h64a8,8,0,0,1,5.66,13.66Z`}))],[`light`,F.createElement(F.Fragment,null,F.createElement(`path`,{d:`M204.24,148.24l-72,72a6,6,0,0,1-8.48,0l-72-72a6,6,0,0,1,8.48-8.48L122,201.51V40a6,6,0,0,1,12,0V201.51l61.76-61.75a6,6,0,0,1,8.48,8.48Z`}))],[`regular`,F.createElement(F.Fragment,null,F.createElement(`path`,{d:`M205.66,149.66l-72,72a8,8,0,0,1-11.32,0l-72-72a8,8,0,0,1,11.32-11.32L120,196.69V40a8,8,0,0,1,16,0V196.69l58.34-58.35a8,8,0,0,1,11.32,11.32Z`}))],[`thin`,F.createElement(F.Fragment,null,F.createElement(`path`,{d:`M202.83,146.83l-72,72a4,4,0,0,1-5.66,0l-72-72a4,4,0,0,1,5.66-5.66L124,206.34V40a4,4,0,0,1,8,0V206.34l65.17-65.17a4,4,0,0,1,5.66,5.66Z`}))]]),L=new Map([[`bold`,F.createElement(F.Fragment,null,F.createElement(`path`,{d:`M208.49,120.49a12,12,0,0,1-17,0L140,69V216a12,12,0,0,1-24,0V69L64.49,120.49a12,12,0,0,1-17-17l72-72a12,12,0,0,1,17,0l72,72A12,12,0,0,1,208.49,120.49Z`}))],[`duotone`,F.createElement(F.Fragment,null,F.createElement(`path`,{d:`M200,112H56l72-72Z`,opacity:`0.2`}),F.createElement(`path`,{d:`M205.66,106.34l-72-72a8,8,0,0,0-11.32,0l-72,72A8,8,0,0,0,56,120h64v96a8,8,0,0,0,16,0V120h64a8,8,0,0,0,5.66-13.66ZM75.31,104,128,51.31,180.69,104Z`}))],[`fill`,F.createElement(F.Fragment,null,F.createElement(`path`,{d:`M207.39,115.06A8,8,0,0,1,200,120H136v96a8,8,0,0,1-16,0V120H56a8,8,0,0,1-5.66-13.66l72-72a8,8,0,0,1,11.32,0l72,72A8,8,0,0,1,207.39,115.06Z`}))],[`light`,F.createElement(F.Fragment,null,F.createElement(`path`,{d:`M204.24,116.24a6,6,0,0,1-8.48,0L134,54.49V216a6,6,0,0,1-12,0V54.49L60.24,116.24a6,6,0,0,1-8.48-8.48l72-72a6,6,0,0,1,8.48,0l72,72A6,6,0,0,1,204.24,116.24Z`}))],[`regular`,F.createElement(F.Fragment,null,F.createElement(`path`,{d:`M205.66,117.66a8,8,0,0,1-11.32,0L136,59.31V216a8,8,0,0,1-16,0V59.31L61.66,117.66a8,8,0,0,1-11.32-11.32l72-72a8,8,0,0,1,11.32,0l72,72A8,8,0,0,1,205.66,117.66Z`}))],[`thin`,F.createElement(F.Fragment,null,F.createElement(`path`,{d:`M202.83,114.83a4,4,0,0,1-5.66,0L132,49.66V216a4,4,0,0,1-8,0V49.66L58.83,114.83a4,4,0,0,1-5.66-5.66l72-72a4,4,0,0,1,5.66,0l72,72A4,4,0,0,1,202.83,114.83Z`}))]]),R=F.forwardRef((e,t)=>F.createElement(o,{ref:t,...e,weights:I}));R.displayName=`ArrowDownIcon`;var z=R,B=F.forwardRef((e,t)=>F.createElement(o,{ref:t,...e,weights:L}));B.displayName=`ArrowUpIcon`;var V=B;function H(){return S(`/api/aggregations`)}function U(e){return S(`/api/aggregations`,{method:`POST`,body:JSON.stringify(e)})}function W(e,t){return S(`/api/aggregations/${encodeURIComponent(e)}`,{method:`PATCH`,body:JSON.stringify(t)})}function G(e){return S(`/api/aggregations/${encodeURIComponent(e)}`,{method:`DELETE`})}var K=[`priority`,`round-robin`,`fill-first`,`fefo`,`least-quota-first`,`most-quota-first`],q=n();function J(){return{key:`${Date.now()}-${Math.random()}`,provider:``,region:``,model:``,account_id:``,priority:0,weight:100}}function Y(e){return String(e||`qoder`).trim().toLowerCase()}function X(e){let t=String(e||``).trim().toLowerCase();return t===``||t===`gl`?`global`:t}function Z(e,t){let n=new Set(t.map(e=>Y(e.provider)));return e.filter(e=>n.has(Y(e.id))).map(e=>({id:e.id,label:e.label}))}function Q(e,t,n){let r=e.find(e=>e.id===n);if(!r)return[];let i=new Set(t.filter(e=>Y(e.provider)===Y(n)).map(e=>X(e.region)));return(r.regions||[]).filter(e=>i.has(X(e.id))).map(e=>({id:e.id,label:e.label}))}function ee(e,t,n,r){let i=new Set,a=[],o=String(t||``).trim().toLowerCase(),s=String(n||``).trim()?X(n):``;for(let t of e){let e=String(t.provider||t.owned_by||``).trim().toLowerCase();if(e&&e!==o)continue;if(s){let e=[t.region,...t.regions||[]].map(e=>X(e)).filter(Boolean);if(e.length&&!e.includes(s))continue}let n=t.id;if(!n||i.has(n))continue;i.add(n);let r=t.display_name||t.route_display_name||n;a.push({id:n,label:`${r} (${n})`})}return a.length||a.push({id:``,label:r(`modelPoolNoModels`)}),a}function $(e,t){return t(`modelPoolStrategy_${e}`)}function te(){let{t:e}=a(),{enabled:t,loading:n}=k(),[o,c]=(0,F.useState)([]),[l,p]=(0,F.useState)([]),[h,g]=(0,F.useState)([]),[_,v]=(0,F.useState)([]),[y,S]=(0,F.useState)(!0),[E,M]=(0,F.useState)(``),[N,P]=(0,F.useState)(!1),[I,L]=(0,F.useState)(null),[R,z]=(0,F.useState)(null),[B,K]=(0,F.useState)(!1),J=(0,F.useCallback)(async()=>{S(!0);try{let[e,t,n,r]=await Promise.all([H(),C(),w(void 0,!1,`regional`),T()]);c(e.data||[]),p(t.data||[]),g(n.data||[]),v(r.data||[]),M(``)}catch(e){M(e instanceof Error?e.message:String(e))}finally{S(!1)}},[]);(0,F.useEffect)(()=>{!t||n||J()},[t,n,J]);async function Y(t,n){let r=t.enabled;c(e=>e.map(e=>e.id===t.id?{...e,enabled:n}:e));try{let r=await W(t.id,{enabled:n});c(e=>e.map(e=>e.id===t.id?r:e)),j({type:`success`,title:e(`modelPoolSaved`)})}catch(e){c(e=>e.map(e=>e.id===t.id?{...e,enabled:r}:e)),j({type:`error`,title:e instanceof Error?e.message:String(e)})}}async function X(){if(R){K(!0);try{await G(R.id),c(e=>e.filter(e=>e.id!==R.id)),j({type:`success`,title:e(`modelPoolDeleted`)}),z(null)}catch(e){j({type:`error`,title:e instanceof Error?e.message:String(e)})}finally{K(!1)}}}return n?(0,q.jsx)(O,{className:`h-64 w-full rounded-xl`}):t?(0,q.jsxs)(`div`,{className:`space-y-6`,children:[(0,q.jsxs)(`section`,{className:`flex flex-wrap items-end justify-between gap-4 pb-4`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`h1`,{className:`text-title font-semibold tracking-tight`,children:e(`modelPoolTitle`)}),(0,q.jsx)(`p`,{className:`mt-1 max-w-2xl text-caption text-muted`,children:e(`modelPoolLead`)})]}),(0,q.jsxs)(s,{onPress:()=>P(!0),children:[(0,q.jsx)(r,{size:16}),e(`modelPoolCreate`)]})]}),E?(0,q.jsx)(u,{status:`danger`,title:E}):null,(0,q.jsx)(f,{className:`overflow-hidden`,children:y?(0,q.jsxs)(`div`,{className:`space-y-3 p-5`,children:[(0,q.jsx)(O,{className:`h-10 w-full`}),(0,q.jsx)(O,{className:`h-10 w-full`}),(0,q.jsx)(O,{className:`h-10 w-full`})]}):o.length===0?(0,q.jsx)(m,{title:e(`modelPoolEmpty`),hint:e(`modelPoolEmptyHint`),icon:(0,q.jsx)(V,{size:28})}):(0,q.jsx)(x,{children:(0,q.jsx)(x.ScrollContainer,{children:(0,q.jsxs)(x.Content,{"aria-label":e(`modelPoolTitle`),children:[(0,q.jsxs)(x.Header,{children:[(0,q.jsx)(x.Column,{children:e(`modelPoolColName`)}),(0,q.jsx)(x.Column,{children:e(`modelPoolColStrategy`)}),(0,q.jsx)(x.Column,{children:e(`modelPoolColMembers`)}),(0,q.jsx)(x.Column,{children:e(`modelPoolColFailover`)}),(0,q.jsx)(x.Column,{children:e(`modelPoolColEnabled`)}),(0,q.jsx)(x.Column,{children:e(`modelPoolColActions`)})]}),(0,q.jsx)(x.Body,{children:o.map(t=>(0,q.jsxs)(x.Row,{children:[(0,q.jsx)(x.Cell,{children:(0,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsx)(`div`,{className:`font-medium`,children:t.name}),(0,q.jsx)(`div`,{className:`mono text-caption text-muted`,children:t.id})]})}),(0,q.jsx)(x.Cell,{children:(0,q.jsx)(D,{size:`sm`,variant:`soft`,children:$(t.strategy,e)})}),(0,q.jsx)(x.Cell,{children:(0,q.jsx)(`span`,{className:`mono text-caption`,children:t.members.length})}),(0,q.jsx)(x.Cell,{children:(0,q.jsx)(`span`,{className:`text-caption text-muted`,children:t.allow_fallbacks?e(`modelPoolFailoverOn`,{count:t.max_attempts}):e(`modelPoolFailoverOff`)})}),(0,q.jsx)(x.Cell,{children:(0,q.jsx)(b,{isSelected:t.enabled,ariaLabel:`${e(`modelPoolColEnabled`)} ${t.id}`,onChange:e=>void Y(t,e)})}),(0,q.jsx)(x.Cell,{children:(0,q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,q.jsx)(s,{size:`sm`,variant:`ghost`,onPress:()=>L(t),children:e(`edit`)}),(0,q.jsx)(s,{isIconOnly:!0,size:`sm`,variant:`ghost`,"aria-label":e(`delete`),onPress:()=>z(t),children:(0,q.jsx)(i,{size:16})})]})})]},t.id))})]})})})}),(N||I)&&(0,q.jsx)(ne,{isOpen:!0,initial:I,descriptors:l,models:h,accounts:_,t:e,onClose:()=>{P(!1),L(null)},onSave:async t=>{I?await W(I.id,t):await U(t),j({type:`success`,title:e(`modelPoolSaved`)}),P(!1),L(null),await J()}}),(0,q.jsx)(d,{isOpen:!!R,title:e(`modelPoolDeleteTitle`),description:R?e(`modelPoolDeleteDesc`,{name:R.name}):``,confirmLabel:e(`delete`),cancelLabel:e(`cancel`),closeLabel:e(`close`),isPending:B,onClose:()=>z(null),onConfirm:()=>void X()})]}):(0,q.jsx)(A,{to:`/`,replace:!0})}function ne({isOpen:e,initial:t,descriptors:n,models:a,accounts:o,t:u,onClose:d,onSave:f}){let[m,x]=(0,F.useState)(``),[S,C]=(0,F.useState)(``),[w,T]=(0,F.useState)(`priority`),[D,O]=(0,F.useState)(!0),[k,A]=(0,F.useState)(3),[j,I]=(0,F.useState)([]),[L,R]=(0,F.useState)(``),[B,H]=(0,F.useState)(!1);(0,F.useEffect)(()=>{e&&(x(t?.id||``),C(t?.name||``),T(t?.strategy||`priority`),O(t?.allow_fallbacks??!0),A(t?.max_attempts??3),I((t?.members||[]).map(e=>({...e,key:`${e.provider}-${e.model}-${Math.random()}`}))),R(``))},[t,e]);let U=(0,F.useMemo)(()=>K.map(e=>({id:e,label:$(e,u)})),[u]),W=(0,F.useMemo)(()=>Z(n,o),[n,o]);function G(e,t){I(n=>n.map(n=>n.key===e?{...n,...t}:n))}function Y(e,t){I(n=>{let r=[...n],i=e+t;return i<0||i>=r.length?n:([r[e],r[i]]=[r[i],r[e]],r.map((e,t)=>({...e,priority:t})))})}async function X(e){if(e?.preventDefault(),!t&&!m.trim().toLowerCase()){R(u(`modelPoolIdRequired`));return}if(!S.trim()){R(u(`modelPoolNameRequired`));return}if(!j.length){R(u(`modelPoolMembersRequired`));return}if(j.some(e=>!e.provider||!e.model)){R(u(`modelPoolMemberIncomplete`));return}if(!Number.isInteger(k)||k<1||k>64){R(u(`modelPoolAttemptsInvalid`));return}H(!0),R(``);try{let e={name:S.trim(),strategy:w,allow_fallbacks:D,max_attempts:k,members:j.map((e,t)=>({provider:e.provider,region:e.region||``,model:e.model,account_id:``,priority:t,weight:e.weight||100}))};t||(e.id=m.trim().toLowerCase()),await f(e)}catch(e){R(e instanceof Error?e.message:String(e))}finally{H(!1)}}return(0,q.jsx)(_.Root,{isOpen:e,onOpenChange:e=>{!e&&!B&&d()},children:(0,q.jsx)(_.Backdrop,{variant:`blur`,children:(0,q.jsx)(_.Container,{placement:`center`,size:`lg`,scroll:`inside`,children:(0,q.jsx)(_.Dialog,{className:`sm:min-w-[40rem]`,children:(0,q.jsxs)(v,{className:`flex min-h-0 flex-1 flex-col`,onSubmit:X,children:[(0,q.jsxs)(_.Header,{className:`items-start justify-between gap-4 px-6 pt-6`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(_.Heading,{className:`text-section font-semibold`,children:u(t?`modelPoolEdit`:`modelPoolCreate`)}),(0,q.jsx)(`p`,{className:`mt-1.5 text-body leading-6 text-muted`,children:u(`modelPoolEditorHint`)})]}),(0,q.jsx)(_.CloseTrigger,{isDisabled:B,"aria-label":u(`close`),className:`grid size-9 place-items-center rounded-lg text-muted hover:bg-surface-secondary`,children:(0,q.jsx)(E,{size:18})})]}),(0,q.jsxs)(_.Body,{className:`space-y-5 px-6 pb-2 pt-1`,children:[L?(0,q.jsxs)(l,{status:`danger`,children:[(0,q.jsx)(l.Indicator,{}),(0,q.jsx)(l.Content,{children:(0,q.jsx)(l.Title,{children:L})})]}):null,t?null:(0,q.jsx)(g,{label:u(`modelPoolId`),hint:u(`modelPoolIdHint`),children:(0,q.jsx)(h,{value:m,onChange:e=>x(e.target.value),placeholder:`my-claude`,"aria-label":u(`modelPoolId`),disabled:B})}),(0,q.jsx)(g,{label:u(`modelPoolName`),children:(0,q.jsx)(h,{value:S,onChange:e=>C(e.target.value),placeholder:u(`modelPoolNamePh`),"aria-label":u(`modelPoolName`),disabled:B})}),(0,q.jsx)(g,{label:u(`modelPoolStrategy`),hint:u(`modelPoolStrategyHint`),children:(0,q.jsx)(P,{value:w,onChange:T,ariaLabel:u(`modelPoolStrategy`),options:U,className:`w-full`})}),(0,q.jsx)(g,{label:u(`modelPoolFailover`),children:(0,q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-4`,children:[(0,q.jsx)(b,{isSelected:D,ariaLabel:u(`modelPoolFailover`),label:u(`modelPoolFailover`),onChange:O,isDisabled:B}),(0,q.jsx)(y,{value:k,onChange:e=>A(e??3),minValue:1,maxValue:64,isDisabled:B||!D,children:(0,q.jsxs)(y.Group,{children:[(0,q.jsx)(y.DecrementButton,{}),(0,q.jsx)(y.Input,{"aria-label":u(`modelPoolMaxAttempts`)}),(0,q.jsx)(y.IncrementButton,{})]})}),(0,q.jsx)(p,{className:`text-caption text-muted`,children:u(`modelPoolMaxAttemptsHint`)})]})}),(0,q.jsxs)(`div`,{className:`space-y-3`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,q.jsxs)(`div`,{children:[(0,q.jsx)(c,{className:`text-body font-medium text-muted`,children:u(`modelPoolMembers`)}),(0,q.jsx)(p,{className:`text-caption leading-5 text-muted`,children:u(`modelPoolMembersHint`)})]}),(0,q.jsxs)(s,{size:`sm`,variant:`ghost`,onPress:()=>I(e=>[...e,J()]),isDisabled:B,children:[(0,q.jsx)(r,{size:14}),u(`modelPoolAddMember`)]})]}),j.length===0?(0,q.jsx)(`p`,{className:`rounded-lg bg-surface-secondary px-3 py-2.5 text-caption text-muted`,children:u(`modelPoolMembersEmpty`)}):(0,q.jsx)(`div`,{className:`space-y-2`,children:j.map((e,t)=>{let r=Q(n,o,e.provider),l=ee(a,e.provider,e.region||``,u);return(0,q.jsxs)(`div`,{className:`rounded-xl bg-surface-secondary p-3`,children:[(0,q.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,q.jsxs)(`span`,{className:`text-caption font-medium text-muted`,children:[`#`,t+1]}),(0,q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,q.jsx)(s,{isIconOnly:!0,size:`sm`,variant:`ghost`,"aria-label":u(`modelPoolMoveUp`),onPress:()=>Y(t,-1),isDisabled:B||t===0,children:(0,q.jsx)(V,{size:15})}),(0,q.jsx)(s,{isIconOnly:!0,size:`sm`,variant:`ghost`,"aria-label":u(`modelPoolMoveDown`),onPress:()=>Y(t,1),isDisabled:B||t===j.length-1,children:(0,q.jsx)(z,{size:15})}),(0,q.jsx)(s,{isIconOnly:!0,size:`sm`,variant:`ghost`,"aria-label":u(`delete`),onPress:()=>I(t=>t.filter(t=>t.key!==e.key)),isDisabled:B,children:(0,q.jsx)(i,{size:15})})]})]}),(0,q.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:[(0,q.jsxs)(`div`,{className:`space-y-1`,children:[(0,q.jsx)(c,{className:`text-caption text-muted`,children:u(`modelPoolProvider`)}),(0,q.jsx)(P,{value:e.provider,onChange:t=>G(e.key,{provider:t,region:``,model:``,account_id:``}),ariaLabel:u(`modelPoolProvider`),options:W,className:`w-full`})]}),(0,q.jsxs)(`div`,{className:`space-y-1`,children:[(0,q.jsx)(c,{className:`text-caption text-muted`,children:u(`modelPoolRegion`)}),(0,q.jsx)(P,{value:e.region||``,onChange:t=>G(e.key,{region:t,model:``,account_id:``}),ariaLabel:u(`modelPoolRegion`),options:[{id:``,label:u(`modelPoolAnyRegion`)},...r],className:`w-full`})]}),(0,q.jsxs)(`div`,{className:`space-y-1 sm:col-span-2`,children:[(0,q.jsx)(c,{className:`text-caption text-muted`,children:u(`modelPoolModel`)}),(0,q.jsx)(P,{value:e.model,onChange:t=>G(e.key,{model:t}),ariaLabel:u(`modelPoolModel`),options:l,className:`w-full`})]}),(0,q.jsxs)(`div`,{className:`space-y-1 sm:col-span-2`,children:[(0,q.jsx)(c,{className:`text-caption text-muted`,children:u(`modelPoolWeight`)}),(0,q.jsx)(y,{value:e.weight,onChange:t=>G(e.key,{weight:t??100}),minValue:1,maxValue:1e6,isDisabled:B,children:(0,q.jsxs)(y.Group,{children:[(0,q.jsx)(y.DecrementButton,{}),(0,q.jsx)(y.Input,{"aria-label":u(`modelPoolWeight`)}),(0,q.jsx)(y.IncrementButton,{})]})})]})]}),e.provider?(0,q.jsxs)(`div`,{className:`mt-2 flex items-center gap-2 text-caption text-muted`,children:[(0,q.jsx)(M,{provider:e.provider,size:14}),(0,q.jsx)(`span`,{children:N(e.provider,e.region||``,u)})]}):null]},e.key)})})]})]}),(0,q.jsxs)(_.Footer,{className:`justify-end`,children:[(0,q.jsx)(s,{variant:`ghost`,isDisabled:B,onPress:d,children:u(`cancel`)}),(0,q.jsx)(s,{type:`submit`,isPending:B,children:u(t?`save`:`create`)})]})]})})})})})}export{te as ModelPoolPage}; \ No newline at end of file diff --git a/internal/webui/static/assets/OverviewPage-BAlBmY5L.js b/internal/webui/static/assets/OverviewPage-BAlBmY5L.js deleted file mode 100644 index 20ac13b4..00000000 --- a/internal/webui/static/assets/OverviewPage-BAlBmY5L.js +++ /dev/null @@ -1,2 +0,0 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TrafficChart-ROSzf7de.js","assets/shim-mfK0Rmj6.js","assets/gsap-C3sDxib7.js","assets/AreaChart-B0YOdVBx.js","assets/CartesianGrid-BJyfpdDb.js","assets/XAxis-DLQkFqxC.js","assets/ReferenceArea-CiIBWWEY.js","assets/FilterToggle-16Av-HiR.js","assets/toggle-button-group-C6lenpLr.js","assets/SharedElementTransition-BlCsXfb1.js","assets/label-n7vfsS35.js","assets/useI18n-BSw4X3mq.js","assets/index-C8_qeOs_.js","assets/overview-m01k08K8.js","assets/index-CsQdDtGs.css","assets/format-B6SmebW-.js"])))=>i.map(i=>d[i]); -import{a as e,c as t,n}from"./shim-mfK0Rmj6.js";import{n as r,r as i,t as a}from"./InflightLiveCard-cw_BuJ7y.js";import{t as o}from"./CaretRight.es-D5fytEam.js";import{n as s,pt as c,r as ee}from"./useI18n-BSw4X3mq.js";import{s as te}from"./TimeRangePicker-C118rt0G.js";import{t as ne}from"./PageAlert-CaDjxveS.js";import{n as l}from"./useToggle-HDaAPzVy.js";import{O as u,p as re,u as ie}from"./overview-m01k08K8.js";import{r as d}from"./gsap-C3sDxib7.js";import{Kt as ae,M as oe,O as se,Yt as ce,Zt as le,g as ue,k as de,m as f,p,u as fe,w as pe}from"./index-C8_qeOs_.js";import{At as m,a as h,r as g,t as _}from"./AreaChart-B0YOdVBx.js";import{c as v,i as y,n as b,s as x}from"./format-B6SmebW-.js";import{t as S}from"./ProviderMark-IiAZTaQS.js";import{n as me,t as he}from"./provider-gHnttGKq.js";import{i as ge,n as _e,r as ve,t as ye}from"./logsLink-iPK79PD2.js";var C=t(e(),1),w=new Map([[`bold`,C.createElement(C.Fragment,null,C.createElement(`path`,{d:`M236,208a12,12,0,0,1-12,12H32a12,12,0,0,1-12-12V48a12,12,0,0,1,24,0v99l43.51-43.52a12,12,0,0,1,17,0L128,127l43-43H160a12,12,0,0,1,0-24h40a12,12,0,0,1,12,12v40a12,12,0,0,1-24,0V101l-51.51,51.52a12,12,0,0,1-17,0L96,129,44,181v15H224A12,12,0,0,1,236,208Z`}))],[`duotone`,C.createElement(C.Fragment,null,C.createElement(`path`,{d:`M224,64V208H32V48H208A16,16,0,0,1,224,64Z`,opacity:`0.2`}),C.createElement(`path`,{d:`M232,208a8,8,0,0,1-8,8H32a8,8,0,0,1-8-8V48a8,8,0,0,1,16,0V156.69l50.34-50.35a8,8,0,0,1,11.32,0L128,132.69,180.69,80H160a8,8,0,0,1,0-16h40a8,8,0,0,1,8,8v40a8,8,0,0,1-16,0V91.31l-58.34,58.35a8,8,0,0,1-11.32,0L96,123.31l-56,56V200H224A8,8,0,0,1,232,208Z`}))],[`fill`,C.createElement(C.Fragment,null,C.createElement(`path`,{d:`M216,40H40A16,16,0,0,0,24,56V200a16,16,0,0,0,16,16H216a16,16,0,0,0,16-16V56A16,16,0,0,0,216,40ZM200,192H56a8,8,0,0,1-8-8V72a8,8,0,0,1,16,0v76.69l34.34-34.35a8,8,0,0,1,11.32,0L128,132.69,172.69,88H144a8,8,0,0,1,0-16h48a8,8,0,0,1,8,8v48a8,8,0,0,1-16,0V99.31l-50.34,50.35a8,8,0,0,1-11.32,0L104,131.31l-40,40V176H200a8,8,0,0,1,0,16Z`}))],[`light`,C.createElement(C.Fragment,null,C.createElement(`path`,{d:`M230,208a6,6,0,0,1-6,6H32a6,6,0,0,1-6-6V48a6,6,0,0,1,12,0V161.52l53.76-53.76a6,6,0,0,1,8.48,0L128,135.51,185.52,78H160a6,6,0,0,1,0-12h40a6,6,0,0,1,6,6v40a6,6,0,0,1-12,0V86.48l-61.76,61.76a6,6,0,0,1-8.48,0L96,120.49l-58,58V202H224A6,6,0,0,1,230,208Z`}))],[`regular`,C.createElement(C.Fragment,null,C.createElement(`path`,{d:`M232,208a8,8,0,0,1-8,8H32a8,8,0,0,1-8-8V48a8,8,0,0,1,16,0V156.69l50.34-50.35a8,8,0,0,1,11.32,0L128,132.69,180.69,80H160a8,8,0,0,1,0-16h40a8,8,0,0,1,8,8v40a8,8,0,0,1-16,0V91.31l-58.34,58.35a8,8,0,0,1-11.32,0L96,123.31l-56,56V200H224A8,8,0,0,1,232,208Z`}))],[`thin`,C.createElement(C.Fragment,null,C.createElement(`path`,{d:`M228,208a4,4,0,0,1-4,4H32a4,4,0,0,1-4-4V48a4,4,0,0,1,8,0V166.34l57.17-57.17a4,4,0,0,1,5.66,0L128,138.34,190.34,76H160a4,4,0,0,1,0-8h40a4,4,0,0,1,4,4v40a4,4,0,0,1-8,0V81.66l-65.17,65.17a4,4,0,0,1-5.66,0L96,117.66l-60,60V204H224A4,4,0,0,1,228,208Z`}))]]),T=new Map([[`bold`,C.createElement(C.Fragment,null,C.createElement(`path`,{d:`M200,28H160a20,20,0,0,0-20,20V208a20,20,0,0,0,20,20h40a20,20,0,0,0,20-20V48A20,20,0,0,0,200,28Zm-4,176H164V52h32ZM96,28H56A20,20,0,0,0,36,48V208a20,20,0,0,0,20,20H96a20,20,0,0,0,20-20V48A20,20,0,0,0,96,28ZM92,204H60V52H92Z`}))],[`duotone`,C.createElement(C.Fragment,null,C.createElement(`path`,{d:`M208,48V208a8,8,0,0,1-8,8H160a8,8,0,0,1-8-8V48a8,8,0,0,1,8-8h40A8,8,0,0,1,208,48ZM96,40H56a8,8,0,0,0-8,8V208a8,8,0,0,0,8,8H96a8,8,0,0,0,8-8V48A8,8,0,0,0,96,40Z`,opacity:`0.2`}),C.createElement(`path`,{d:`M200,32H160a16,16,0,0,0-16,16V208a16,16,0,0,0,16,16h40a16,16,0,0,0,16-16V48A16,16,0,0,0,200,32Zm0,176H160V48h40ZM96,32H56A16,16,0,0,0,40,48V208a16,16,0,0,0,16,16H96a16,16,0,0,0,16-16V48A16,16,0,0,0,96,32Zm0,176H56V48H96Z`}))],[`fill`,C.createElement(C.Fragment,null,C.createElement(`path`,{d:`M216,48V208a16,16,0,0,1-16,16H160a16,16,0,0,1-16-16V48a16,16,0,0,1,16-16h40A16,16,0,0,1,216,48ZM96,32H56A16,16,0,0,0,40,48V208a16,16,0,0,0,16,16H96a16,16,0,0,0,16-16V48A16,16,0,0,0,96,32Z`}))],[`light`,C.createElement(C.Fragment,null,C.createElement(`path`,{d:`M200,34H160a14,14,0,0,0-14,14V208a14,14,0,0,0,14,14h40a14,14,0,0,0,14-14V48A14,14,0,0,0,200,34Zm2,174a2,2,0,0,1-2,2H160a2,2,0,0,1-2-2V48a2,2,0,0,1,2-2h40a2,2,0,0,1,2,2ZM96,34H56A14,14,0,0,0,42,48V208a14,14,0,0,0,14,14H96a14,14,0,0,0,14-14V48A14,14,0,0,0,96,34Zm2,174a2,2,0,0,1-2,2H56a2,2,0,0,1-2-2V48a2,2,0,0,1,2-2H96a2,2,0,0,1,2,2Z`}))],[`regular`,C.createElement(C.Fragment,null,C.createElement(`path`,{d:`M200,32H160a16,16,0,0,0-16,16V208a16,16,0,0,0,16,16h40a16,16,0,0,0,16-16V48A16,16,0,0,0,200,32Zm0,176H160V48h40ZM96,32H56A16,16,0,0,0,40,48V208a16,16,0,0,0,16,16H96a16,16,0,0,0,16-16V48A16,16,0,0,0,96,32Zm0,176H56V48H96Z`}))],[`thin`,C.createElement(C.Fragment,null,C.createElement(`path`,{d:`M200,36H160a12,12,0,0,0-12,12V208a12,12,0,0,0,12,12h40a12,12,0,0,0,12-12V48A12,12,0,0,0,200,36Zm4,172a4,4,0,0,1-4,4H160a4,4,0,0,1-4-4V48a4,4,0,0,1,4-4h40a4,4,0,0,1,4,4ZM96,36H56A12,12,0,0,0,44,48V208a12,12,0,0,0,12,12H96a12,12,0,0,0,12-12V48A12,12,0,0,0,96,36Zm4,172a4,4,0,0,1-4,4H56a4,4,0,0,1-4-4V48a4,4,0,0,1,4-4H96a4,4,0,0,1,4,4Z`}))]]),E=new Map([[`bold`,C.createElement(C.Fragment,null,C.createElement(`path`,{d:`M234.49,111.07,90.41,22.94A20,20,0,0,0,60,39.87V216.13a20,20,0,0,0,30.41,16.93l144.08-88.13a19.82,19.82,0,0,0,0-33.86ZM84,208.85V47.15L216.16,128Z`}))],[`duotone`,C.createElement(C.Fragment,null,C.createElement(`path`,{d:`M228.23,134.69,84.15,222.81A8,8,0,0,1,72,216.12V39.88a8,8,0,0,1,12.15-6.69l144.08,88.12A7.82,7.82,0,0,1,228.23,134.69Z`,opacity:`0.2`}),C.createElement(`path`,{d:`M232.4,114.49,88.32,26.35a16,16,0,0,0-16.2-.3A15.86,15.86,0,0,0,64,39.87V216.13A15.94,15.94,0,0,0,80,232a16.07,16.07,0,0,0,8.36-2.35L232.4,141.51a15.81,15.81,0,0,0,0-27ZM80,215.94V40l143.83,88Z`}))],[`fill`,C.createElement(C.Fragment,null,C.createElement(`path`,{d:`M240,128a15.74,15.74,0,0,1-7.6,13.51L88.32,229.65a16,16,0,0,1-16.2.3A15.86,15.86,0,0,1,64,216.13V39.87a15.86,15.86,0,0,1,8.12-13.82,16,16,0,0,1,16.2.3L232.4,114.49A15.74,15.74,0,0,1,240,128Z`}))],[`light`,C.createElement(C.Fragment,null,C.createElement(`path`,{d:`M231.36,116.19,87.28,28.06a14,14,0,0,0-14.18-.27A13.69,13.69,0,0,0,66,39.87V216.13a13.69,13.69,0,0,0,7.1,12.08,14,14,0,0,0,14.18-.27l144.08-88.13a13.82,13.82,0,0,0,0-23.62Zm-6.26,13.38L81,217.7a2,2,0,0,1-2.06,0,1.78,1.78,0,0,1-1-1.61V39.87a1.78,1.78,0,0,1,1-1.61A2.06,2.06,0,0,1,80,38a2,2,0,0,1,1,.31L225.1,126.43a1.82,1.82,0,0,1,0,3.14Z`}))],[`regular`,C.createElement(C.Fragment,null,C.createElement(`path`,{d:`M232.4,114.49,88.32,26.35a16,16,0,0,0-16.2-.3A15.86,15.86,0,0,0,64,39.87V216.13A15.94,15.94,0,0,0,80,232a16.07,16.07,0,0,0,8.36-2.35L232.4,141.51a15.81,15.81,0,0,0,0-27ZM80,215.94V40l143.83,88Z`}))],[`thin`,C.createElement(C.Fragment,null,C.createElement(`path`,{d:`M230.32,117.9,86.24,29.79a11.91,11.91,0,0,0-12.17-.23A11.71,11.71,0,0,0,68,39.89V216.11a11.71,11.71,0,0,0,6.07,10.33,11.91,11.91,0,0,0,12.17-.23L230.32,138.1a11.82,11.82,0,0,0,0-20.2Zm-4.18,13.37L82.06,219.39a4,4,0,0,1-4.07.07,3.77,3.77,0,0,1-2-3.35V39.89a3.77,3.77,0,0,1,2-3.35,4,4,0,0,1,4.07.07l144.08,88.12a3.8,3.8,0,0,1,0,6.54Z`}))]]),D=new Map([[`bold`,C.createElement(C.Fragment,null,C.createElement(`path`,{d:`M244,128v64a12,12,0,0,1-12,12H168a12,12,0,0,1,0-24h35l-67-67-31.51,31.52a12,12,0,0,1-17,0l-72-72a12,12,0,0,1,17-17L96,119l31.51-31.52a12,12,0,0,1,17,0L220,163V128a12,12,0,0,1,24,0Z`}))],[`duotone`,C.createElement(C.Fragment,null,C.createElement(`path`,{d:`M232,128v64H168Z`,opacity:`0.2`}),C.createElement(`path`,{d:`M235.06,120.61a8,8,0,0,0-8.72,1.73L200,148.69,141.66,90.34a8,8,0,0,0-11.32,0L96,124.69,29.66,58.34A8,8,0,0,0,18.34,69.66l72,72a8,8,0,0,0,11.32,0L136,107.31,188.69,160l-26.35,26.34A8,8,0,0,0,168,200h64a8,8,0,0,0,8-8V128A8,8,0,0,0,235.06,120.61ZM224,184H187.31L224,147.31Z`}))],[`fill`,C.createElement(C.Fragment,null,C.createElement(`path`,{d:`M240,128v64a8,8,0,0,1-8,8H168a8,8,0,0,1-5.66-13.66L188.69,160,136,107.31l-34.34,34.35a8,8,0,0,1-11.32,0l-72-72A8,8,0,0,1,29.66,58.34L96,124.69l34.34-34.35a8,8,0,0,1,11.32,0L200,148.69l26.34-26.35A8,8,0,0,1,240,128Z`}))],[`light`,C.createElement(C.Fragment,null,C.createElement(`path`,{d:`M238,128v64a6,6,0,0,1-6,6H168a6,6,0,0,1,0-12h49.52L136,104.49l-35.76,35.75a6,6,0,0,1-8.48,0l-72-72a6,6,0,0,1,8.48-8.48L96,127.51l35.76-35.75a6,6,0,0,1,8.48,0L226,177.52V128a6,6,0,0,1,12,0Z`}))],[`regular`,C.createElement(C.Fragment,null,C.createElement(`path`,{d:`M240,128v64a8,8,0,0,1-8,8H168a8,8,0,0,1,0-16h44.69L136,107.31l-34.34,34.35a8,8,0,0,1-11.32,0l-72-72A8,8,0,0,1,29.66,58.34L96,124.69l34.34-34.35a8,8,0,0,1,11.32,0L224,172.69V128a8,8,0,0,1,16,0Z`}))],[`thin`,C.createElement(C.Fragment,null,C.createElement(`path`,{d:`M236,128v64a4,4,0,0,1-4,4H168a4,4,0,0,1,0-8h54.34L136,101.66,98.83,138.83a4,4,0,0,1-5.66,0l-72-72a4,4,0,0,1,5.66-5.66L96,130.34l37.17-37.17a4,4,0,0,1,5.66,0L228,182.34V128a4,4,0,0,1,8,0Z`}))]]),O=new Map([[`bold`,C.createElement(C.Fragment,null,C.createElement(`path`,{d:`M244,56v64a12,12,0,0,1-24,0V85l-75.51,75.52a12,12,0,0,1-17,0L96,129,32.49,192.49a12,12,0,0,1-17-17l72-72a12,12,0,0,1,17,0L136,135l67-67H168a12,12,0,0,1,0-24h64A12,12,0,0,1,244,56Z`}))],[`duotone`,C.createElement(C.Fragment,null,C.createElement(`path`,{d:`M232,56v64L168,56Z`,opacity:`0.2`}),C.createElement(`path`,{d:`M232,48H168a8,8,0,0,0-5.66,13.66L188.69,88,136,140.69l-34.34-34.35a8,8,0,0,0-11.32,0l-72,72a8,8,0,0,0,11.32,11.32L96,123.31l34.34,34.35a8,8,0,0,0,11.32,0L200,99.31l26.34,26.35A8,8,0,0,0,240,120V56A8,8,0,0,0,232,48Zm-8,52.69L187.31,64H224Z`}))],[`fill`,C.createElement(C.Fragment,null,C.createElement(`path`,{d:`M240,56v64a8,8,0,0,1-13.66,5.66L200,99.31l-58.34,58.35a8,8,0,0,1-11.32,0L96,123.31,29.66,189.66a8,8,0,0,1-11.32-11.32l72-72a8,8,0,0,1,11.32,0L136,140.69,188.69,88,162.34,61.66A8,8,0,0,1,168,48h64A8,8,0,0,1,240,56Z`}))],[`light`,C.createElement(C.Fragment,null,C.createElement(`path`,{d:`M238,56v64a6,6,0,0,1-12,0V70.48l-85.76,85.76a6,6,0,0,1-8.48,0L96,120.49,28.24,188.24a6,6,0,0,1-8.48-8.48l72-72a6,6,0,0,1,8.48,0L136,143.51,217.52,62H168a6,6,0,0,1,0-12h64A6,6,0,0,1,238,56Z`}))],[`regular`,C.createElement(C.Fragment,null,C.createElement(`path`,{d:`M240,56v64a8,8,0,0,1-16,0V75.31l-82.34,82.35a8,8,0,0,1-11.32,0L96,123.31,29.66,189.66a8,8,0,0,1-11.32-11.32l72-72a8,8,0,0,1,11.32,0L136,140.69,212.69,64H168a8,8,0,0,1,0-16h64A8,8,0,0,1,240,56Z`}))],[`thin`,C.createElement(C.Fragment,null,C.createElement(`path`,{d:`M236,56v64a4,4,0,0,1-8,0V65.66l-89.17,89.17a4,4,0,0,1-5.66,0L96,117.66,26.83,186.83a4,4,0,0,1-5.66-5.66l72-72a4,4,0,0,1,5.66,0L136,146.34,222.34,60H168a4,4,0,0,1,0-8h64A4,4,0,0,1,236,56Z`}))]]),k=C.forwardRef((e,t)=>C.createElement(c,{ref:t,...e,weights:w}));k.displayName=`ChartLineUpIcon`;var be=k,A=C.forwardRef((e,t)=>C.createElement(c,{ref:t,...e,weights:T}));A.displayName=`PauseIcon`;var xe=A,j=C.forwardRef((e,t)=>C.createElement(c,{ref:t,...e,weights:E}));j.displayName=`PlayIcon`;var Se=j,M=C.forwardRef((e,t)=>C.createElement(c,{ref:t,...e,weights:D}));M.displayName=`TrendDownIcon`;var N=M,P=C.forwardRef((e,t)=>C.createElement(c,{ref:t,...e,weights:O}));P.displayName=`TrendUpIcon`;var Ce=P,F=n();function we({emptyLabel:e}){return(0,F.jsx)(`div`,{className:`grid min-h-56 place-items-center rounded-lg bg-surface-secondary px-4 text-body text-muted`,children:e})}function I({samples:e,capacity:t,label:n}){let r=e.length?e:[{at:0,value:0}],i=Math.max(1,t,...r.map(e=>e.value));return(0,F.jsx)(`div`,{className:`h-6 w-[120px] shrink-0`,role:`img`,"aria-label":n,children:(0,F.jsx)(m,{width:`100%`,height:`100%`,children:(0,F.jsxs)(_,{data:r,margin:{top:1,right:0,bottom:1,left:0},children:[(0,F.jsx)(g,{hide:!0,domain:[0,i]}),(0,F.jsx)(h,{type:`monotone`,dataKey:`value`,stroke:`var(--foreground)`,strokeOpacity:.7,strokeWidth:1.25,fill:`var(--foreground)`,fillOpacity:.08,isAnimationActive:!1,dot:!1})]})})})}function Te({live:e,samples:t,t:n,onConcurrencyClick:r}){let i=e?.in_flight??null,a=e?.capacity??0,o=i!=null&&a>0?i/a:0,s=a>0&&i!=null&&i>=a,c=(0,F.jsxs)(F.Fragment,{children:[n(`liveConcurrency`),(0,F.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,F.jsxs)(`span`,{className:`mono tabular text-body font-semibold ${s?`text-warning`:`text-foreground`}`,children:[i??`—`,(0,F.jsxs)(`span`,{className:`font-normal text-muted`,children:[`/`,e?a:`—`]})]}),(0,F.jsx)(`span`,{className:`inline-block h-[3px] w-12 overflow-hidden rounded-[2px] bg-separator`,children:(0,F.jsx)(`span`,{className:`block h-full ${s?`bg-warning`:`bg-foreground/60`}`,style:{width:`${Math.min(100,o*100)}%`}})})]})]});return(0,F.jsxs)(`div`,{"data-testid":`live-strip`,className:`flex min-h-11 flex-wrap items-center gap-x-5 gap-y-2 overflow-hidden rounded-lg bg-surface-secondary px-4 py-2.5 text-caption text-muted sm:h-11 sm:gap-x-6 sm:gap-y-1 sm:py-0`,children:[(0,F.jsx)(`span`,{className:`inline-flex items-center`,children:(0,F.jsx)(`span`,{className:`status-dot`,"data-state":i==null?``:s?`warn`:i>0?`ok`:``})}),r?(0,F.jsx)(`button`,{type:`button`,"data-testid":`live-strip-concurrency`,onClick:r,className:`inline-flex flex-col gap-1 rounded-lg text-left outline-none transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-focus sm:flex-row sm:items-center sm:gap-2`,"aria-label":n(`inflightExpandFromConcurrency`),children:c}):(0,F.jsx)(`span`,{className:`inline-flex flex-col gap-1 sm:flex-row sm:items-center sm:gap-2`,children:c}),(0,F.jsxs)(`span`,{className:`inline-flex flex-col gap-1 sm:flex-row sm:items-center sm:gap-2`,children:[n(`liveRpm`),(0,F.jsx)(`span`,{className:`mono tabular text-body font-semibold text-foreground`,children:e?.rpm??`—`})]}),(0,F.jsxs)(`span`,{className:`inline-flex flex-col gap-1 sm:flex-row sm:items-center sm:gap-2`,children:[n(`liveTrace`),(0,F.jsx)(I,{samples:t,capacity:a,label:n(`liveTrace`)})]})]})}function Ee(){return u(`/api/live`)}var De=2500,L=Math.round(6e4/De);function Oe(e){let t=e?.intervalMs??2500,[n,r]=(0,C.useState)(null),[i,a]=(0,C.useState)([]);return(0,C.useEffect)(()=>{let e=!1,n=null,i=()=>{document.hidden||Ee().then(n=>{if(e)return;r(n);let i=Math.max(L,Math.round(6e4/t));a(e=>[...e,{at:Date.now(),value:n.in_flight}].slice(-i))}).catch(()=>{})},o=()=>{n||document.hidden||(i(),n=setInterval(i,t))},s=()=>{n&&clearInterval(n),n=null},c=()=>document.hidden?s():o();return o(),document.addEventListener(`visibilitychange`,c),()=>{e=!0,s(),document.removeEventListener(`visibilitychange`,c)}},[t]),{live:n,samples:i}}var ke=(0,C.lazy)(()=>le(()=>import(`./TrafficChart-ROSzf7de.js`).then(e=>({default:e.TrafficChart})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]))),Ae=3e4,je=3e4,Me={window:{from:``,to:``,hours:24},totals:{requests:0,ok:0,incomplete:0,error:0,canceled:0,streaming:0,success_rate:0},latency:{},tokens:{prompt:0,completion:0,cache_read:0,total:0},status:[],errors:[],models:[],accounts:[],providers:[],series:[]};function Ne(e,t){return!e||e===`(unknown)`?t(`statsUnknown`):he(e,t)}function Pe(e,t,n){return!t||t===`(unassigned)`?n:e.find(e=>e.id===t)?.name||t}var Fe=new Set([`quota`,`rate_limit`,`auth`,`not_ready`,`unavailable`,`invalid_request`,`model_not_available`]);function Ie(e,t){let n={quota:`logsKindQuota`,rate_limit:`logsKindRateLimit`,auth:`logsKindAuth`,not_ready:`logsKindNotReady`,unavailable:`logsKindUnavailable`,invalid_request:`logsKindInvalidRequest`,model_not_available:`logsKindModelNotAvailable`};return n[e]?t(n[e]):e}var Le=[`ok`,`incomplete`,`error`,`canceled`],R={ok:`bg-success`,incomplete:`bg-warning`,error:`bg-danger`,canceled:`bg-muted`},z={ok:`logsFilterOk`,incomplete:`logsFilterIncomplete`,error:`logsFilterError`,canceled:`logsFilterCanceled`};function B(e,t){return t>0?e/t:null}function Re(e,t){if(!e)return null;let n=Date.parse(e);if(!Number.isFinite(n))return null;let r=Math.max(0,Math.round((n-t)/1e3));if(r<=0)return null;let i=Math.floor(r/3600),a=Math.floor(r%3600/60),o=r%60;return i?`${i}h ${a}m`:a?`${a}m ${String(o).padStart(2,`0`)}s`:`${o}s`}function ze(e,t){let n=[e.down_until,e.cooldown_until].filter(e=>!!e).filter(e=>Date.parse(e)>t);return n.length?n.reduce((e,t)=>Date.parse(e)>=Date.parse(t)?e:t):null}function Be(e,t){return t?`danger`:(e??0)>=80?`warning`:`ok`}function Ve(){let{lang:e,t}=s(),{overview:n,loading:c,error:u}=se(),[d,le]=(0,C.useState)(`today`),[m,h]=(0,C.useState)(null),[g,_]=(0,C.useState)(!1),b=ce(),[he,w]=(0,C.useState)(null),[T,E]=(0,C.useState)(``),[D,O]=(0,C.useState)(!0),[k,be]=(0,C.useState)([]),[A,j]=(0,C.useState)(!0),[M,N]=(0,C.useState)(0),[P,Ce]=(0,C.useState)(null),[I,Ee]=(0,C.useState)(()=>Date.now()),[L,R]=(0,C.useState)(!1),[z,Ve]=(0,C.useState)(!1),{live:V,samples:Ge}=Oe({intervalMs:L?800:De}),Ke=new Map((V?.accounts??[]).map(e=>[e.id,e])),qe=!!n?.proxy?.ok,Je=!!n?.worker?.ok,Ye=n?.worker?.ready_count??0,Xe=n?.worker?.hot_count??0,Ze=V?.in_flight??n?.worker?.in_flight??0,U=he??Me,Qe=(0,C.useMemo)(()=>({requests:t(`chartMetricRequests`),tokens:t(`chartMetricTokens`),latency:t(`chartMetricLatency`),input:t(`chartInput`),output:t(`chartOutput`),cacheRead:t(`chartCacheRead`),p50:t(`statsLatencyP50`),p95:t(`statsLatencyP95`),total:t(`chartTotal`)}),[t]),$e=(0,C.useCallback)((e,t)=>b(ye({},e,t)),[b]),W=n?.routing?.session_affinity,et=(W?.hits??0)+(W?.misses??0),tt=B(W?.hits??0,et),G=k.map(e=>({account:e,until:ze(e,I)})).filter(e=>e.until!=null),nt=G.length>0,rt=new Set(G.map(e=>e.account.id)),it=[...k.filter(e=>e.ready&&!rt.has(e.id)),...k.filter(e=>!e.ready&&!rt.has(e.id))].slice(0,6);(0,C.useEffect)(()=>{if(!nt)return;let e=setInterval(()=>Ee(Date.now()),1e3);return()=>clearInterval(e)},[nt]),(0,C.useEffect)(()=>{let e=!1;return Promise.allSettled([ie(!1),re()]).then(([t,n])=>{e||(t.status===`fulfilled`&&be(t.value.data||[]),n.status===`fulfilled`&&N((n.value.data||[]).length))}).finally(()=>{e||j(!1)}),()=>{e=!0}},[]);let at=m?.start?.toString()??``,ot=m?.end?.toString()??``,K=(0,C.useRef)(0),q=(0,C.useCallback)(e=>{let t=ge(d,m);if(!t){O(!1);return}let n=++K.current;te(t).then(e=>{n===K.current&&(w(e),E(``))}).catch(t=>{n!==K.current||e||(w(null),E(t instanceof Error?t.message:String(t)))}).finally(()=>{n===K.current&&O(!1)})},[d,at,ot]);(0,C.useEffect)(()=>(q(!1),()=>{K.current++}),[q]),(0,C.useEffect)(()=>{if(g)return;let e=Date.now(),t=()=>{document.hidden||(e=Date.now(),q(!0))},n=setInterval(t,Ae),r=()=>{!document.hidden&&Date.now()-e>=Ae&&t()};return document.addEventListener(`visibilitychange`,r),()=>{clearInterval(n),document.removeEventListener(`visibilitychange`,r)}},[g,q]),(0,C.useEffect)(()=>{let e=!1,t=Date.now(),n=()=>{document.hidden||(t=Date.now(),pe().then(t=>{e||Ce(t)}).catch(()=>{}))};n();let r=setInterval(n,je),i=()=>{!document.hidden&&Date.now()-t>=je&&n()};return document.addEventListener(`visibilitychange`,i),()=>{e=!0,clearInterval(r),document.removeEventListener(`visibilitychange`,i)}},[]);let J=Math.floor(U.series.length/2),Y=(e,t)=>e.reduce((e,n)=>e+n[t],0),X=U.series.slice(0,J),Z=U.series.slice(J),st=((e,t)=>e>0?(t-e)/e:null)(Y(X,`requests`),Y(Z,`requests`)),ct=Y(X,`requests`)?Y(X,`ok`)/Y(X,`requests`):null,Q=Y(Z,`requests`)?Y(Z,`ok`)/Y(Z,`requests`):null,lt=ct!=null&&Q!=null?Q-ct:null,ut=[{label:t(`metricRequests`),value:U.totals.requests,kind:`compact`,detail:t(`statsWindowHint`,{window:t(ve[d])}),ok:U.totals.requests>0,trend:st},{label:t(`metricSuccess`),value:U.totals.success_rate,kind:`percent`,detail:`${U.totals.ok} ${t(`logsFilterOk`)} · ${U.totals.incomplete} ${t(`logsFilterIncomplete`)} · ${U.totals.error} ${t(`logsFilterError`)}`,ok:U.totals.requests===0||U.totals.success_rate>=.9,trend:lt},{label:t(`metricLatency`),value:U.latency.p95_ms??U.latency.avg_ms,kind:`ms`,detail:`p50 ${x(U.latency.p50_ms)} · avg ${x(U.latency.avg_ms)}`,ok:U.latency.p95_ms==null||U.latency.p95_ms<8e3,trend:null},{label:t(`metricTokens`),value:U.tokens.total,kind:`compact`,detail:`${y(U.tokens.prompt)} / ${y(U.tokens.completion)}`,ok:!0,trend:null}],dt=B(U.tokens.cache_read,U.tokens.prompt),ft=B(U.totals.streaming,U.totals.requests),pt=[{label:t(`metricCacheHit`),value:dt,kind:`percent`,detail:t(`metricCacheHitDetail`,{read:y(U.tokens.cache_read),prompt:y(U.tokens.prompt)})},{label:t(`metricStreaming`),value:ft,kind:`percent`,detail:t(`metricStreamingDetail`,{count:U.totals.streaming,total:U.totals.requests})},{label:t(`metricCanceled`),value:U.totals.canceled,kind:`int`,detail:t(`metricCanceledDetail`,{rate:v(B(U.totals.canceled,U.totals.requests)??0)})}],mt=Le.map(e=>({key:e,count:U.status.find(t=>t.key===e)?.count??U.totals[e]??0})),$=e=>ye(e,U.window.from,U.window.to);return c&&!n?(0,F.jsx)(fe,{}):(0,F.jsxs)(`div`,{className:`space-y-5 sm:space-y-4`,children:[(0,F.jsxs)(`section`,{className:`grid gap-3 pb-1 lg:grid-cols-[minmax(0,1fr)_auto] lg:items-end`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h2`,{"data-gsap-reveal":!0,className:`text-title font-semibold`,children:t(`homeDisplay`)}),(0,F.jsx)(`p`,{className:`mt-1 max-w-2xl text-body leading-6 text-muted`,children:t(`homeLead`)})]}),(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,F.jsx)(_e,{value:d,onChange:le,custom:m,onCustomChange:h,onBusy:()=>O(!0),t}),(0,F.jsxs)(de,{delay:300,children:[(0,F.jsx)(ee,{isIconOnly:!0,size:`sm`,variant:`ghost`,"aria-label":t(g?`statsRefreshResume`:`statsRefreshPause`),"aria-pressed":g,onPress:()=>_(e=>!e),children:g?(0,F.jsx)(Se,{size:14}):(0,F.jsx)(xe,{size:14})}),(0,F.jsx)(de.Content,{children:t(g?`statsRefreshPaused`:`statsRefreshAuto`)})]}),(0,F.jsxs)(`div`,{className:`text-left sm:text-right`,children:[(0,F.jsx)(`div`,{className:`mono text-caption text-muted`,children:n?.time||`—`}),(0,F.jsxs)(`div`,{className:`mt-1 inline-flex items-center gap-2 text-body font-medium`,children:[(0,F.jsx)(`span`,{className:`status-dot`,"data-state":qe&&Je?`ok`:`danger`}),t(qe&&Je?`running`:`degraded`)]})]})]})]}),u?(0,F.jsx)(ne,{title:t(`failedOverview`,{msg:u})}):null,(0,F.jsx)(Te,{live:V,samples:Ge,t,onConcurrencyClick:()=>R(!0)}),(0,F.jsx)(a,{t,expanded:L,onExpandedChange:R,live:L?V:null}),(0,F.jsx)(`section`,{"data-gsap-reveal":!0,className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-4`,children:ut.map(e=>(0,F.jsxs)(l,{className:`gap-0 p-3.5`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,F.jsx)(`div`,{className:`text-body text-muted`,children:e.label}),(0,F.jsx)(`span`,{className:`status-dot`,"data-state":e.ok?`ok`:`danger`})]}),(0,F.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-2`,children:[(0,F.jsx)(`div`,{className:`tabular text-metric font-medium leading-none`,children:D?(0,F.jsx)(f,{className:`h-7 w-24`}):e.value==null?`—`:(0,F.jsx)(r,{value:e.value,kind:e.kind})}),!D&&e.trend!=null?(0,F.jsx)(Ue,{value:e.trend,hint:t(`trendHalfHint`)}):null]}),(0,F.jsx)(`div`,{className:`mono mt-2 truncate text-caption text-muted`,children:D?(0,F.jsx)(f,{className:`h-3 w-28`}):e.detail})]},e.label))}),(0,F.jsx)(`section`,{className:`grid gap-3 sm:grid-cols-3`,children:pt.map(e=>(0,F.jsx)(l,{className:`gap-0 p-3.5`,children:(0,F.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:gap-3`,children:[(0,F.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,F.jsx)(`div`,{className:`text-body text-muted`,children:e.label}),(0,F.jsx)(`div`,{className:`mono mt-0.5 truncate text-caption text-muted`,children:D?(0,F.jsx)(f,{className:`h-3 w-28`}):e.detail})]}),(0,F.jsx)(`div`,{className:`tabular text-section font-semibold sm:shrink-0`,children:D?(0,F.jsx)(f,{className:`h-5 w-12`}):e.value==null?`—`:(0,F.jsx)(r,{value:e.value,kind:e.kind})})]})},e.label))}),(0,F.jsx)(`section`,{className:`grid gap-3`,children:(0,F.jsxs)(l,{"data-gsap-reveal":!0,className:`overflow-hidden p-0`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-separator px-4 py-3`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h3`,{className:`font-semibold`,children:t(`statsTraffic`)}),(0,F.jsx)(`p`,{className:`mt-0.5 text-caption text-muted`,children:t(`statsTrafficHint`)})]}),(0,F.jsx)(oe,{size:`sm`,variant:`soft`,color:U.totals.error?`warning`:`success`,children:v(U.totals.success_rate)})]}),(0,F.jsxs)(`div`,{className:`space-y-4 p-4`,children:[T?(0,F.jsx)(`div`,{className:`text-body text-danger`,children:t(`failedStats`,{msg:T})}):D?(0,F.jsx)(ue,{}):U.series.some(e=>e.requests>0)?(0,F.jsx)(C.Suspense,{fallback:(0,F.jsx)(ue,{}),children:(0,F.jsx)(ke,{series:U.series,lang:e,emptyLabel:t(`statsEmptyTraffic`),okLabel:t(`logsFilterOk`),errorLabel:t(`logsFilterError`),selectHint:t(`statsDragHint`),labels:Qe,onSelectRange:$e})}):(0,F.jsx)(we,{emptyLabel:t(`statsEmptyTraffic`)}),(0,F.jsx)(`div`,{className:`grid grid-cols-2 gap-x-4 gap-y-4 pt-3 sm:grid-cols-4 sm:gap-3`,children:[[t(`statsLatencyP50`),x(U.latency.p50_ms)],[t(`statsLatencyP95`),x(U.latency.p95_ms)],[t(`statsLatencyAvg`),x(U.latency.avg_ms)],[t(`statsTTFB`),x(U.latency.ttfb_avg_ms)]].map(([e,t])=>(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`div`,{className:`text-caption text-muted`,children:e}),(0,F.jsx)(`div`,{className:`mono mt-1 text-body font-medium`,children:D?(0,F.jsx)(f,{className:`h-4 w-16`}):t})]},String(e)))})]})]})}),(0,F.jsxs)(`section`,{className:`grid gap-3 xl:grid-cols-[minmax(0,1.15fr)_minmax(0,.85fr)]`,children:[(0,F.jsxs)(l,{"data-gsap-reveal":!0,className:`overflow-hidden p-0`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-separator px-4 py-3`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h3`,{className:`font-semibold`,children:t(`statsPool`)}),(0,F.jsx)(`p`,{className:`mt-0.5 text-caption text-muted`,children:t(`statsPoolHint`)})]}),(0,F.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[!A&&G.length?(0,F.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 rounded-2xl bg-surface-secondary px-2 py-0.5 text-caption text-muted transition-colors hover:text-foreground`,"aria-expanded":z,"aria-label":t(`statsCoolingChip`,{count:G.length}),onClick:()=>Ve(e=>!e),children:[(0,F.jsx)(`span`,{className:`status-dot shrink-0`,"data-state":`warn`}),(0,F.jsx)(`span`,{className:`mono tabular`,children:t(`statsCoolingChip`,{count:G.length})}),(0,F.jsx)(o,{size:10,className:`transition-transform duration-200 ${z?`rotate-90`:``}`,"aria-hidden":!0})]}):null,(0,F.jsxs)(ae,{to:`/accounts`,className:`inline-flex items-center gap-1 text-caption font-medium text-muted hover:text-foreground`,children:[t(`navAccounts`),(0,F.jsx)(i,{size:12})]})]})]}),(0,F.jsx)(`div`,{className:`grid grid-cols-2 gap-y-1 border-b border-separator sm:grid-cols-4 sm:gap-y-0`,children:[[t(`ready`),Ye,`ok`],[t(`hot`),Xe,Xe?`ok`:``],[t(`inFlight`),Ze,Ze?`ok`:``],[t(`statsAffinityHit`),tt==null?`—`:v(tt),``,W?t(`statsAffinityHint`,{hits:W.hits??0,misses:W.misses??0,bindings:W.bindings??0}):``]].map(([e,t,n,r])=>(0,F.jsxs)(`div`,{className:`px-4 py-3 sm:py-2.5`,title:r?String(r):void 0,children:[(0,F.jsx)(`div`,{className:`text-caption text-muted`,children:e}),(0,F.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-2 sm:mt-1`,children:[(0,F.jsx)(`span`,{className:`mono text-section font-semibold`,children:t}),n?(0,F.jsx)(`span`,{className:`status-dot`,"data-state":n}):null]})]},String(e)))}),z&&G.length?(0,F.jsxs)(`div`,{className:`border-b border-separator bg-surface-secondary/50 px-4 py-2`,children:[(0,F.jsx)(`div`,{className:`text-caption text-muted`,children:t(`statsCoolingDetails`)}),(0,F.jsx)(`div`,{className:`mt-1.5 space-y-1`,children:G.map(({account:e,until:n})=>(0,F.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-caption`,children:[(0,F.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-foreground/80`,children:e.name||e.id}),(0,F.jsx)(`span`,{className:`mono shrink-0 text-muted`,children:e.last_error_kind?Ie(e.last_error_kind,t):t(`statsUnknown`)}),(0,F.jsx)(`span`,{className:`mono shrink-0 tabular text-muted sm:w-16 sm:text-right`,children:Re(n,I)??`—`}),(0,F.jsx)(`span`,{className:`mono hidden shrink-0 text-muted sm:inline sm:w-10 sm:text-right`,title:t(`statsBackoffLevel`),children:e.restart_backoff_level?`L${e.restart_backoff_level}`:`—`})]},e.id))})]}):null,(0,F.jsx)(`div`,{className:`divide-y divide-separator`,children:A?(0,F.jsx)(p,{}):k.length===0?(0,F.jsx)(`div`,{className:`px-4 py-6 text-body text-muted`,children:t(`noAccounts`)}):it.length===0?(0,F.jsx)(`div`,{className:`px-4 py-6 text-body text-muted`,children:t(`statsPoolReadyEmpty`)}):it.map(e=>{let n=e.quota,r=Be(n?.percentage,n?.exceeded),i=Ke.get(e.id),a=i?.in_flight??e.in_flight??e.inFlight??0,o=i?.max_inflight||e.max_inflight||4,s=a>=o;return(0,F.jsxs)(`div`,{className:`flex flex-col gap-2.5 px-4 py-3 sm:flex-row sm:items-center sm:gap-3 sm:py-2.5`,children:[(0,F.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-3 sm:items-center`,children:[(0,F.jsx)(`span`,{className:`status-dot mt-1.5 shrink-0 sm:mt-0`,"data-state":e.ready?`ok`:`danger`}),(0,F.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,F.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,F.jsx)(S,{provider:e.provider,size:14}),(0,F.jsx)(`div`,{className:`truncate text-body font-medium`,children:e.name||e.id})]}),(0,F.jsxs)(`div`,{className:`mono mt-0.5 text-caption text-muted`,children:[me(e.provider,e.region,t),` · `,e.hot?t(`hot`):e.ready?t(`ready`):t(`degraded`)]})]})]}),(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2 pl-6 sm:shrink-0 sm:pl-0`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5`,title:t(s?`liveSaturated`:`inFlight`),"data-testid":`account-inflight`,children:[(0,F.jsx)(`span`,{className:`text-caption text-muted sm:hidden`,children:t(`inFlight`)}),(0,F.jsxs)(`span`,{className:`mono text-caption tabular ${s?`text-warning`:`text-muted`}`,children:[a,`/`,o]}),(0,F.jsx)(`span`,{className:`inline-block h-[2px] w-10 overflow-hidden rounded-[1px] bg-separator`,children:(0,F.jsx)(`span`,{className:`block h-full ${s?`bg-warning`:`bg-foreground/50`}`,style:{width:`${Math.min(100,a/o*100)}%`}})})]}),n?(0,F.jsxs)(`div`,{className:`flex items-center gap-1.5`,title:t(`quota`),children:[(0,F.jsx)(`span`,{className:`text-caption text-muted sm:hidden`,children:t(`quota`)}),(0,F.jsxs)(`span`,{className:`mono text-caption tabular text-muted`,children:[Math.round(n.percentage??0),`%`]}),(0,F.jsx)(`span`,{className:`inline-block h-[2px] w-10 overflow-hidden rounded-[1px] bg-separator`,children:(0,F.jsx)(`span`,{className:`block h-full ${r===`danger`?`bg-danger`:r===`warning`?`bg-warning`:`bg-success`}`,style:{width:`${Math.min(100,Math.max(0,n.percentage??0))}%`}})})]}):null]})]},e.id)})}),(0,F.jsxs)(`div`,{className:`flex items-center justify-between border-t border-separator px-4 py-2.5 text-caption text-muted`,children:[(0,F.jsxs)(`span`,{children:[t(`metricModels`),` `,M]}),(0,F.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center justify-end gap-x-2 gap-y-1`,children:[[`qoder`,`workbuddy`,`trae`].map(e=>{let t=k.filter(t=>String(t.provider||`qoder`).toLowerCase()===e).length;return t?(0,F.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,F.jsx)(S,{provider:e,size:11}),t]},e):null}),(0,F.jsxs)(`span`,{children:[k.length,` `,t(`accountCount`)]})]})]})]}),(0,F.jsx)(He,{resources:P,t})]}),(0,F.jsxs)(`section`,{className:`grid gap-3 xl:grid-cols-2 2xl:grid-cols-3`,children:[(0,F.jsxs)(l,{"data-gsap-reveal":!0,className:`overflow-hidden p-0`,children:[(0,F.jsx)(`div`,{className:`flex items-center justify-between gap-3 border-b border-separator px-4 py-3`,children:(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h3`,{className:`font-semibold`,children:t(`statsTopProviders`)}),(0,F.jsx)(`p`,{className:`mt-0.5 text-caption text-muted`,children:t(`statsTopProvidersHint`)})]})}),D?(0,F.jsx)(p,{}):(0,F.jsx)(H,{empty:t(`statsNoProviders`),items:(U.providers||[]).map(e=>({key:e.key,label:Ne(e.key,t),count:e.count,meta:`${e.ok}/${e.count}`,mark:e.key===`(unknown)`?void 0:e.key,href:e.key===`(unknown)`?void 0:$({provider:e.key})}))})]}),(0,F.jsxs)(l,{"data-gsap-reveal":!0,className:`overflow-hidden p-0`,children:[(0,F.jsx)(`div`,{className:`flex items-center justify-between gap-3 border-b border-separator px-4 py-3`,children:(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h3`,{className:`font-semibold`,children:t(`statsTopModels`)}),(0,F.jsx)(`p`,{className:`mt-0.5 text-caption text-muted`,children:t(`providerCatalog`)})]})}),D?(0,F.jsx)(p,{rows:4}):(0,F.jsx)(H,{empty:t(`statsNoModels`),items:U.models.map(e=>({key:e.key,label:e.key===`(unknown)`?t(`statsUnknown`):e.key,count:e.count,href:e.key===`(unknown)`?void 0:$({model:e.key}),meta:e.latency_avg_ms==null?`${e.ok}/${e.count}`:x(e.latency_avg_ms)}))})]}),(0,F.jsxs)(l,{"data-gsap-reveal":!0,className:`overflow-hidden p-0`,children:[(0,F.jsx)(`div`,{className:`flex items-center justify-between gap-3 border-b border-separator px-4 py-3`,children:(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h3`,{className:`font-semibold`,children:t(`statsStatusMix`)}),(0,F.jsx)(`p`,{className:`mt-0.5 text-caption text-muted`,children:t(`statsStatusMixHint`)})]})}),D?(0,F.jsx)(p,{rows:4}):(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(We,{items:mt,t}),(0,F.jsx)(`div`,{className:`border-t border-separator px-4 pt-2.5 text-caption font-medium text-muted`,children:t(`statsErrorMix`)}),(0,F.jsx)(H,{empty:t(`statsNoErrors`),danger:!0,items:U.errors.map(e=>({key:e.key,label:Ie(e.key,t),count:e.count,href:Fe.has(e.key)?$({error_kind:e.key}):void 0}))}),(0,F.jsx)(`div`,{className:`border-t border-separator px-4 pt-2.5 text-caption font-medium text-muted`,children:t(`statsTopAccounts`)}),(0,F.jsx)(H,{empty:t(`statsNoAccounts`),items:U.accounts.slice(0,5).map(e=>({key:e.key,label:Pe(k,e.key,t(`statsUnassigned`)),count:e.count,href:!e.key||e.key===`(unassigned)`?void 0:$({account:e.key}),meta:`${e.ok}/${e.count}`}))})]})]})]})]})}function V(e,t){return e>=2147483648||t>=200?`danger`:e>=1073741824||t>=100?`warning`:`ok`}function He({resources:e,t}){let n=[...e?.workers??[]].sort((e,t)=>t.rss_bytes-e.rss_bytes),r=e?.server;return(0,F.jsxs)(l,{"data-gsap-reveal":!0,className:`overflow-hidden p-0`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-separator px-4 py-3`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h3`,{className:`font-semibold`,children:t(`resTitle`)}),(0,F.jsx)(`p`,{className:`mt-0.5 text-caption text-muted`,children:t(`resHint`)})]}),(0,F.jsx)(oe,{size:`sm`,variant:`soft`,color:e?`success`:`default`,children:e?b(e.total_rss_bytes):`—`})]}),(0,F.jsx)(`div`,{className:`divide-y divide-separator`,children:e?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`div`,{className:`px-4 py-2.5`,children:(0,F.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,F.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,F.jsx)(`span`,{className:`status-dot shrink-0`,"data-state":V(r?.rss_bytes??0,r?.cpu_percent??0)}),(0,F.jsx)(`div`,{className:`truncate text-body font-medium`,children:t(`resServer`)}),(0,F.jsxs)(`span`,{className:`mono text-caption text-muted`,children:[`pid `,r?.pid]})]}),(0,F.jsxs)(`div`,{className:`mono shrink-0 text-caption text-muted`,children:[b(r?.rss_bytes),` · `,(r?.cpu_percent??0).toFixed(1),`%`]})]})}),n.length===0?(0,F.jsx)(`div`,{className:`px-4 py-3 text-body text-muted`,children:t(`resEmpty`)}):n.map(e=>(0,F.jsx)(`div`,{className:`px-4 py-2.5`,children:(0,F.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,F.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,F.jsx)(`span`,{className:`status-dot shrink-0`,"data-state":V(e.rss_bytes,e.cpu_percent)}),(0,F.jsx)(`div`,{className:`truncate text-body font-medium`,children:e.label||e.account_id}),(0,F.jsxs)(`span`,{className:`mono text-caption text-muted`,children:[`pid `,e.pid]})]}),(0,F.jsxs)(`div`,{className:`mono shrink-0 text-caption text-muted`,children:[b(e.rss_bytes),` · `,e.cpu_percent.toFixed(1),`%`]})]})},e.pid))]}):(0,F.jsx)(p,{rows:3})}),(0,F.jsxs)(`div`,{className:`flex items-center justify-between border-t border-separator px-4 py-2.5 text-caption text-muted`,children:[(0,F.jsxs)(`span`,{className:`mono`,children:[r?.goroutines??0,` `,t(`resGoroutines`)]}),(0,F.jsx)(`span`,{className:`mono`,children:e?.sampled_at?new Date(e.sampled_at).toLocaleTimeString():`—`})]})]})}function H({items:e,empty:t,danger:n}){let r=(0,C.useRef)(null),i=Math.max(1,...e.map(e=>e.count)),a=e.map(e=>`${e.key}:${e.count}`).join(`|`);return(0,C.useLayoutEffect)(()=>{let e=r.current;if(!e)return;let t=d.context(()=>{let e=d.matchMedia();e.add(`(prefers-reduced-motion: reduce)`,()=>{d.set(`[data-rank-fill]`,{clearProps:`transform`})}),e.add(`(prefers-reduced-motion: no-preference)`,()=>{let e=d.utils.toArray(`[data-rank-fill]`);e.length&&d.fromTo(e,{scaleX:0},{scaleX:1,duration:.38,ease:`power2.out`,stagger:.05,transformOrigin:`0% 50%`})})},e);return()=>t.revert()},[a]),e.length?(0,F.jsx)(`div`,{ref:r,className:`divide-y divide-separator`,children:e.map(e=>{let t=(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,F.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[e.mark?(0,F.jsx)(S,{provider:e.mark,size:14}):null,(0,F.jsx)(`div`,{className:`truncate text-body font-medium`,children:e.label})]}),(0,F.jsx)(`div`,{className:`mono shrink-0 text-caption text-muted`,children:e.meta?`${e.count} · ${e.meta}`:e.count})]}),(0,F.jsx)(`div`,{className:`mt-2 h-1 overflow-hidden rounded-[2px] bg-separator`,children:(0,F.jsx)(`div`,{"data-rank-fill":!0,className:`h-full origin-left rounded-[2px] ${n?`bg-danger`:`bg-success`}`,style:{width:`${Math.max(6,e.count/i*100)}%`}})})]});return e.href?(0,F.jsx)(ae,{to:e.href,className:`rank-row block px-4 py-2.5`,title:e.label,children:t},e.key):(0,F.jsx)(`div`,{className:`px-4 py-2.5`,children:t},e.key)})}):(0,F.jsx)(`div`,{className:`px-4 py-6 text-body text-muted`,children:t})}function Ue({value:e,hint:t}){let n=Math.abs(e)<.005?`flat`:e>0?`up`:`down`;return(0,F.jsxs)(`span`,{className:`trend-chip`,"data-tone":n,title:t,children:[(0,F.jsx)(n===`down`?N:n===`up`?Ce:be,{size:12,weight:`bold`}),e>0?`+`:``,(e*100).toFixed(1),`%`]})}function We({items:e,t}){let n=e.reduce((e,t)=>e+t.count,0);return n?(0,F.jsxs)(`div`,{className:`px-4 py-3`,children:[(0,F.jsx)(`div`,{className:`flex h-2 gap-px overflow-hidden rounded-[3px] bg-separator`,role:`img`,"aria-label":e.map(e=>`${t(z[e.key])} ${e.count}`).join(`, `),children:e.filter(e=>e.count>0).map(e=>(0,F.jsx)(`div`,{className:R[e.key],style:{width:`${e.count/n*100}%`,minWidth:2}},e.key))}),(0,F.jsx)(`div`,{className:`mt-3 grid grid-cols-2 gap-x-4 gap-y-1.5`,children:e.map(e=>(0,F.jsxs)(`div`,{className:`flex items-center gap-2 text-caption`,children:[(0,F.jsx)(`span`,{className:`inline-block size-2 shrink-0 rounded-[2px] ${R[e.key]}`}),(0,F.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-muted`,children:t(z[e.key])}),(0,F.jsx)(`span`,{className:`mono tabular`,children:e.count}),(0,F.jsx)(`span`,{className:`mono w-10 text-right tabular text-muted`,children:v(e.count/n)})]},e.key))})]}):(0,F.jsx)(`div`,{className:`px-4 py-3 text-body text-muted`,children:t(`statsEmptyTraffic`)})}export{Ve as OverviewPage,we as t}; \ No newline at end of file diff --git a/internal/webui/static/assets/OverviewPage-BbcGKR4s.js b/internal/webui/static/assets/OverviewPage-BbcGKR4s.js new file mode 100644 index 00000000..1e7e043e --- /dev/null +++ b/internal/webui/static/assets/OverviewPage-BbcGKR4s.js @@ -0,0 +1,104 @@ +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/InflightDepthChart-Cl1KjYdd.js","assets/shim-mfK0Rmj6.js","assets/index-B9eWF6SH.js","assets/useI18n-BBOAnu2u.js","assets/SharedElementTransition-BlCsXfb1.js","assets/overview-CJvUvgoD.js","assets/gsap-C3sDxib7.js","assets/index-i4CFf7iO.css","assets/AreaChart-B0YOdVBx.js","assets/XAxis-DLQkFqxC.js","assets/ReferenceArea-CiIBWWEY.js","assets/TrafficChart-CJw8f4Wi.js","assets/format-kRpr2wxA.js","assets/useToggleState-DpzdeNPF.js","assets/CartesianGrid-BJyfpdDb.js","assets/FilterToggle-AieL1mQy.js"])))=>i.map(i=>d[i]); +import{a as e,c as t,n}from"./shim-mfK0Rmj6.js";import{t as r}from"./CaretRight.es-DGKxUxz5.js";import{t as i}from"./Check.es-PrgGvQWD.js";import{dt as a,n as o,r as s}from"./useI18n-BBOAnu2u.js";import{s as c}from"./TimeRangePicker-CLtIDMZF.js";import{t as l}from"./PageAlert-DZC7IhXp.js";import{t as u}from"./card-QlCdtlk0.js";import{a as d,c as f,i as p,n as m,s as h}from"./format-kRpr2wxA.js";import{A as g,p as _,u as v}from"./overview-CJvUvgoD.js";import{n as y,r as b,t as x}from"./gsap-C3sDxib7.js";import{$t as S,Ht as ee,Jt as te,M as C,O as w,Zt as ne,b as T,g as E,k as D,kt as O,m as k,p as A,u as j,w as re,x as M,y as ie}from"./index-B9eWF6SH.js";import{At as N,a as P,r as F,t as I}from"./AreaChart-B0YOdVBx.js";import{t as L}from"./ProviderMark-IiAZTaQS.js";import{n as R,t as z}from"./provider-gHnttGKq.js";import{t as B}from"./useAccountEvents-CCHBF_7j.js";import{i as ae,n as oe,r as se,t as ce}from"./logsLink-CEEottPg.js";var V=t(e(),1),le=new Map([[`bold`,V.createElement(V.Fragment,null,V.createElement(`path`,{d:`M204,64V168a12,12,0,0,1-24,0V93L72.49,200.49a12,12,0,0,1-17-17L163,76H88a12,12,0,0,1,0-24H192A12,12,0,0,1,204,64Z`}))],[`duotone`,V.createElement(V.Fragment,null,V.createElement(`path`,{d:`M192,64V168L88,64Z`,opacity:`0.2`}),V.createElement(`path`,{d:`M192,56H88a8,8,0,0,0-5.66,13.66L128.69,116,58.34,186.34a8,8,0,0,0,11.32,11.32L140,127.31l46.34,46.35A8,8,0,0,0,200,168V64A8,8,0,0,0,192,56Zm-8,92.69-38.34-38.34h0L107.31,72H184Z`}))],[`fill`,V.createElement(V.Fragment,null,V.createElement(`path`,{d:`M200,64V168a8,8,0,0,1-13.66,5.66L140,127.31,69.66,197.66a8,8,0,0,1-11.32-11.32L128.69,116,82.34,69.66A8,8,0,0,1,88,56H192A8,8,0,0,1,200,64Z`}))],[`light`,V.createElement(V.Fragment,null,V.createElement(`path`,{d:`M198,64V168a6,6,0,0,1-12,0V78.48L68.24,196.24a6,6,0,0,1-8.48-8.48L177.52,70H88a6,6,0,0,1,0-12H192A6,6,0,0,1,198,64Z`}))],[`regular`,V.createElement(V.Fragment,null,V.createElement(`path`,{d:`M200,64V168a8,8,0,0,1-16,0V83.31L69.66,197.66a8,8,0,0,1-11.32-11.32L172.69,72H88a8,8,0,0,1,0-16H192A8,8,0,0,1,200,64Z`}))],[`thin`,V.createElement(V.Fragment,null,V.createElement(`path`,{d:`M196,64V168a4,4,0,0,1-8,0V73.66L66.83,194.83a4,4,0,0,1-5.66-5.66L182.34,68H88a4,4,0,0,1,0-8H192A4,4,0,0,1,196,64Z`}))]]),ue=new Map([[`bold`,V.createElement(V.Fragment,null,V.createElement(`path`,{d:`M236,208a12,12,0,0,1-12,12H32a12,12,0,0,1-12-12V48a12,12,0,0,1,24,0v99l43.51-43.52a12,12,0,0,1,17,0L128,127l43-43H160a12,12,0,0,1,0-24h40a12,12,0,0,1,12,12v40a12,12,0,0,1-24,0V101l-51.51,51.52a12,12,0,0,1-17,0L96,129,44,181v15H224A12,12,0,0,1,236,208Z`}))],[`duotone`,V.createElement(V.Fragment,null,V.createElement(`path`,{d:`M224,64V208H32V48H208A16,16,0,0,1,224,64Z`,opacity:`0.2`}),V.createElement(`path`,{d:`M232,208a8,8,0,0,1-8,8H32a8,8,0,0,1-8-8V48a8,8,0,0,1,16,0V156.69l50.34-50.35a8,8,0,0,1,11.32,0L128,132.69,180.69,80H160a8,8,0,0,1,0-16h40a8,8,0,0,1,8,8v40a8,8,0,0,1-16,0V91.31l-58.34,58.35a8,8,0,0,1-11.32,0L96,123.31l-56,56V200H224A8,8,0,0,1,232,208Z`}))],[`fill`,V.createElement(V.Fragment,null,V.createElement(`path`,{d:`M216,40H40A16,16,0,0,0,24,56V200a16,16,0,0,0,16,16H216a16,16,0,0,0,16-16V56A16,16,0,0,0,216,40ZM200,192H56a8,8,0,0,1-8-8V72a8,8,0,0,1,16,0v76.69l34.34-34.35a8,8,0,0,1,11.32,0L128,132.69,172.69,88H144a8,8,0,0,1,0-16h48a8,8,0,0,1,8,8v48a8,8,0,0,1-16,0V99.31l-50.34,50.35a8,8,0,0,1-11.32,0L104,131.31l-40,40V176H200a8,8,0,0,1,0,16Z`}))],[`light`,V.createElement(V.Fragment,null,V.createElement(`path`,{d:`M230,208a6,6,0,0,1-6,6H32a6,6,0,0,1-6-6V48a6,6,0,0,1,12,0V161.52l53.76-53.76a6,6,0,0,1,8.48,0L128,135.51,185.52,78H160a6,6,0,0,1,0-12h40a6,6,0,0,1,6,6v40a6,6,0,0,1-12,0V86.48l-61.76,61.76a6,6,0,0,1-8.48,0L96,120.49l-58,58V202H224A6,6,0,0,1,230,208Z`}))],[`regular`,V.createElement(V.Fragment,null,V.createElement(`path`,{d:`M232,208a8,8,0,0,1-8,8H32a8,8,0,0,1-8-8V48a8,8,0,0,1,16,0V156.69l50.34-50.35a8,8,0,0,1,11.32,0L128,132.69,180.69,80H160a8,8,0,0,1,0-16h40a8,8,0,0,1,8,8v40a8,8,0,0,1-16,0V91.31l-58.34,58.35a8,8,0,0,1-11.32,0L96,123.31l-56,56V200H224A8,8,0,0,1,232,208Z`}))],[`thin`,V.createElement(V.Fragment,null,V.createElement(`path`,{d:`M228,208a4,4,0,0,1-4,4H32a4,4,0,0,1-4-4V48a4,4,0,0,1,8,0V166.34l57.17-57.17a4,4,0,0,1,5.66,0L128,138.34,190.34,76H160a4,4,0,0,1,0-8h40a4,4,0,0,1,4,4v40a4,4,0,0,1-8,0V81.66l-65.17,65.17a4,4,0,0,1-5.66,0L96,117.66l-60,60V204H224A4,4,0,0,1,228,208Z`}))]]),de=new Map([[`bold`,V.createElement(V.Fragment,null,V.createElement(`path`,{d:`M128,20A108,108,0,0,0,31.85,177.23L21,209.66A20,20,0,0,0,46.34,235l32.43-10.81A108,108,0,1,0,128,20Zm0,192a84,84,0,0,1-42.06-11.27,12,12,0,0,0-6-1.62,12.1,12.1,0,0,0-3.8.62l-29.79,9.93,9.93-29.79a12,12,0,0,0-1-9.81A84,84,0,1,1,128,212Z`}))],[`duotone`,V.createElement(V.Fragment,null,V.createElement(`path`,{d:`M224,128A96,96,0,0,1,79.93,211.11h0L42.54,223.58a8,8,0,0,1-10.12-10.12l12.47-37.39h0A96,96,0,1,1,224,128Z`,opacity:`0.2`}),V.createElement(`path`,{d:`M128,24A104,104,0,0,0,36.18,176.88L24.83,210.93a16,16,0,0,0,20.24,20.24l34.05-11.35A104,104,0,1,0,128,24Zm0,192a87.87,87.87,0,0,1-44.06-11.81,8,8,0,0,0-6.54-.67L40,216,52.47,178.6a8,8,0,0,0-.66-6.54A88,88,0,1,1,128,216Z`}))],[`fill`,V.createElement(V.Fragment,null,V.createElement(`path`,{d:`M232,128A104,104,0,0,1,79.12,219.82L45.07,231.17a16,16,0,0,1-20.24-20.24l11.35-34.05A104,104,0,1,1,232,128Z`}))],[`light`,V.createElement(V.Fragment,null,V.createElement(`path`,{d:`M128,26A102,102,0,0,0,38.35,176.69L26.73,211.56a14,14,0,0,0,17.71,17.71l34.87-11.62A102,102,0,1,0,128,26Zm0,192a90,90,0,0,1-45.06-12.08,6.09,6.09,0,0,0-3-.81,6.2,6.2,0,0,0-1.9.31L40.65,217.88a2,2,0,0,1-2.53-2.53L50.58,178a6,6,0,0,0-.5-4.91A90,90,0,1,1,128,218Z`}))],[`regular`,V.createElement(V.Fragment,null,V.createElement(`path`,{d:`M128,24A104,104,0,0,0,36.18,176.88L24.83,210.93a16,16,0,0,0,20.24,20.24l34.05-11.35A104,104,0,1,0,128,24Zm0,192a87.87,87.87,0,0,1-44.06-11.81,8,8,0,0,0-6.54-.67L40,216,52.47,178.6a8,8,0,0,0-.66-6.54A88,88,0,1,1,128,216Z`}))],[`thin`,V.createElement(V.Fragment,null,V.createElement(`path`,{d:`M128,28A100,100,0,0,0,40.53,176.5l-11.9,35.69a12,12,0,0,0,15.18,15.18l35.69-11.9A100,100,0,1,0,128,28Zm0,192a92,92,0,0,1-46.07-12.35,4.05,4.05,0,0,0-2-.54,3.93,3.93,0,0,0-1.27.21L41.28,219.78a4,4,0,0,1-5.06-5.06l12.46-37.38a4,4,0,0,0-.33-3.27A92,92,0,1,1,128,220Z`}))]]),fe=new Map([[`bold`,V.createElement(V.Fragment,null,V.createElement(`path`,{d:`M200,28H160a20,20,0,0,0-20,20V208a20,20,0,0,0,20,20h40a20,20,0,0,0,20-20V48A20,20,0,0,0,200,28Zm-4,176H164V52h32ZM96,28H56A20,20,0,0,0,36,48V208a20,20,0,0,0,20,20H96a20,20,0,0,0,20-20V48A20,20,0,0,0,96,28ZM92,204H60V52H92Z`}))],[`duotone`,V.createElement(V.Fragment,null,V.createElement(`path`,{d:`M208,48V208a8,8,0,0,1-8,8H160a8,8,0,0,1-8-8V48a8,8,0,0,1,8-8h40A8,8,0,0,1,208,48ZM96,40H56a8,8,0,0,0-8,8V208a8,8,0,0,0,8,8H96a8,8,0,0,0,8-8V48A8,8,0,0,0,96,40Z`,opacity:`0.2`}),V.createElement(`path`,{d:`M200,32H160a16,16,0,0,0-16,16V208a16,16,0,0,0,16,16h40a16,16,0,0,0,16-16V48A16,16,0,0,0,200,32Zm0,176H160V48h40ZM96,32H56A16,16,0,0,0,40,48V208a16,16,0,0,0,16,16H96a16,16,0,0,0,16-16V48A16,16,0,0,0,96,32Zm0,176H56V48H96Z`}))],[`fill`,V.createElement(V.Fragment,null,V.createElement(`path`,{d:`M216,48V208a16,16,0,0,1-16,16H160a16,16,0,0,1-16-16V48a16,16,0,0,1,16-16h40A16,16,0,0,1,216,48ZM96,32H56A16,16,0,0,0,40,48V208a16,16,0,0,0,16,16H96a16,16,0,0,0,16-16V48A16,16,0,0,0,96,32Z`}))],[`light`,V.createElement(V.Fragment,null,V.createElement(`path`,{d:`M200,34H160a14,14,0,0,0-14,14V208a14,14,0,0,0,14,14h40a14,14,0,0,0,14-14V48A14,14,0,0,0,200,34Zm2,174a2,2,0,0,1-2,2H160a2,2,0,0,1-2-2V48a2,2,0,0,1,2-2h40a2,2,0,0,1,2,2ZM96,34H56A14,14,0,0,0,42,48V208a14,14,0,0,0,14,14H96a14,14,0,0,0,14-14V48A14,14,0,0,0,96,34Zm2,174a2,2,0,0,1-2,2H56a2,2,0,0,1-2-2V48a2,2,0,0,1,2-2H96a2,2,0,0,1,2,2Z`}))],[`regular`,V.createElement(V.Fragment,null,V.createElement(`path`,{d:`M200,32H160a16,16,0,0,0-16,16V208a16,16,0,0,0,16,16h40a16,16,0,0,0,16-16V48A16,16,0,0,0,200,32Zm0,176H160V48h40ZM96,32H56A16,16,0,0,0,40,48V208a16,16,0,0,0,16,16H96a16,16,0,0,0,16-16V48A16,16,0,0,0,96,32Zm0,176H56V48H96Z`}))],[`thin`,V.createElement(V.Fragment,null,V.createElement(`path`,{d:`M200,36H160a12,12,0,0,0-12,12V208a12,12,0,0,0,12,12h40a12,12,0,0,0,12-12V48A12,12,0,0,0,200,36Zm4,172a4,4,0,0,1-4,4H160a4,4,0,0,1-4-4V48a4,4,0,0,1,4-4h40a4,4,0,0,1,4,4ZM96,36H56A12,12,0,0,0,44,48V208a12,12,0,0,0,12,12H96a12,12,0,0,0,12-12V48A12,12,0,0,0,96,36Zm4,172a4,4,0,0,1-4,4H56a4,4,0,0,1-4-4V48a4,4,0,0,1,4-4H96a4,4,0,0,1,4,4Z`}))]]),pe=new Map([[`bold`,V.createElement(V.Fragment,null,V.createElement(`path`,{d:`M234.49,111.07,90.41,22.94A20,20,0,0,0,60,39.87V216.13a20,20,0,0,0,30.41,16.93l144.08-88.13a19.82,19.82,0,0,0,0-33.86ZM84,208.85V47.15L216.16,128Z`}))],[`duotone`,V.createElement(V.Fragment,null,V.createElement(`path`,{d:`M228.23,134.69,84.15,222.81A8,8,0,0,1,72,216.12V39.88a8,8,0,0,1,12.15-6.69l144.08,88.12A7.82,7.82,0,0,1,228.23,134.69Z`,opacity:`0.2`}),V.createElement(`path`,{d:`M232.4,114.49,88.32,26.35a16,16,0,0,0-16.2-.3A15.86,15.86,0,0,0,64,39.87V216.13A15.94,15.94,0,0,0,80,232a16.07,16.07,0,0,0,8.36-2.35L232.4,141.51a15.81,15.81,0,0,0,0-27ZM80,215.94V40l143.83,88Z`}))],[`fill`,V.createElement(V.Fragment,null,V.createElement(`path`,{d:`M240,128a15.74,15.74,0,0,1-7.6,13.51L88.32,229.65a16,16,0,0,1-16.2.3A15.86,15.86,0,0,1,64,216.13V39.87a15.86,15.86,0,0,1,8.12-13.82,16,16,0,0,1,16.2.3L232.4,114.49A15.74,15.74,0,0,1,240,128Z`}))],[`light`,V.createElement(V.Fragment,null,V.createElement(`path`,{d:`M231.36,116.19,87.28,28.06a14,14,0,0,0-14.18-.27A13.69,13.69,0,0,0,66,39.87V216.13a13.69,13.69,0,0,0,7.1,12.08,14,14,0,0,0,14.18-.27l144.08-88.13a13.82,13.82,0,0,0,0-23.62Zm-6.26,13.38L81,217.7a2,2,0,0,1-2.06,0,1.78,1.78,0,0,1-1-1.61V39.87a1.78,1.78,0,0,1,1-1.61A2.06,2.06,0,0,1,80,38a2,2,0,0,1,1,.31L225.1,126.43a1.82,1.82,0,0,1,0,3.14Z`}))],[`regular`,V.createElement(V.Fragment,null,V.createElement(`path`,{d:`M232.4,114.49,88.32,26.35a16,16,0,0,0-16.2-.3A15.86,15.86,0,0,0,64,39.87V216.13A15.94,15.94,0,0,0,80,232a16.07,16.07,0,0,0,8.36-2.35L232.4,141.51a15.81,15.81,0,0,0,0-27ZM80,215.94V40l143.83,88Z`}))],[`thin`,V.createElement(V.Fragment,null,V.createElement(`path`,{d:`M230.32,117.9,86.24,29.79a11.91,11.91,0,0,0-12.17-.23A11.71,11.71,0,0,0,68,39.89V216.11a11.71,11.71,0,0,0,6.07,10.33,11.91,11.91,0,0,0,12.17-.23L230.32,138.1a11.82,11.82,0,0,0,0-20.2Zm-4.18,13.37L82.06,219.39a4,4,0,0,1-4.07.07,3.77,3.77,0,0,1-2-3.35V39.89a3.77,3.77,0,0,1,2-3.35,4,4,0,0,1,4.07.07l144.08,88.12a3.8,3.8,0,0,1,0,6.54Z`}))]]),me=new Map([[`bold`,V.createElement(V.Fragment,null,V.createElement(`path`,{d:`M244,128v64a12,12,0,0,1-12,12H168a12,12,0,0,1,0-24h35l-67-67-31.51,31.52a12,12,0,0,1-17,0l-72-72a12,12,0,0,1,17-17L96,119l31.51-31.52a12,12,0,0,1,17,0L220,163V128a12,12,0,0,1,24,0Z`}))],[`duotone`,V.createElement(V.Fragment,null,V.createElement(`path`,{d:`M232,128v64H168Z`,opacity:`0.2`}),V.createElement(`path`,{d:`M235.06,120.61a8,8,0,0,0-8.72,1.73L200,148.69,141.66,90.34a8,8,0,0,0-11.32,0L96,124.69,29.66,58.34A8,8,0,0,0,18.34,69.66l72,72a8,8,0,0,0,11.32,0L136,107.31,188.69,160l-26.35,26.34A8,8,0,0,0,168,200h64a8,8,0,0,0,8-8V128A8,8,0,0,0,235.06,120.61ZM224,184H187.31L224,147.31Z`}))],[`fill`,V.createElement(V.Fragment,null,V.createElement(`path`,{d:`M240,128v64a8,8,0,0,1-8,8H168a8,8,0,0,1-5.66-13.66L188.69,160,136,107.31l-34.34,34.35a8,8,0,0,1-11.32,0l-72-72A8,8,0,0,1,29.66,58.34L96,124.69l34.34-34.35a8,8,0,0,1,11.32,0L200,148.69l26.34-26.35A8,8,0,0,1,240,128Z`}))],[`light`,V.createElement(V.Fragment,null,V.createElement(`path`,{d:`M238,128v64a6,6,0,0,1-6,6H168a6,6,0,0,1,0-12h49.52L136,104.49l-35.76,35.75a6,6,0,0,1-8.48,0l-72-72a6,6,0,0,1,8.48-8.48L96,127.51l35.76-35.75a6,6,0,0,1,8.48,0L226,177.52V128a6,6,0,0,1,12,0Z`}))],[`regular`,V.createElement(V.Fragment,null,V.createElement(`path`,{d:`M240,128v64a8,8,0,0,1-8,8H168a8,8,0,0,1,0-16h44.69L136,107.31l-34.34,34.35a8,8,0,0,1-11.32,0l-72-72A8,8,0,0,1,29.66,58.34L96,124.69l34.34-34.35a8,8,0,0,1,11.32,0L224,172.69V128a8,8,0,0,1,16,0Z`}))],[`thin`,V.createElement(V.Fragment,null,V.createElement(`path`,{d:`M236,128v64a4,4,0,0,1-4,4H168a4,4,0,0,1,0-8h54.34L136,101.66,98.83,138.83a4,4,0,0,1-5.66,0l-72-72a4,4,0,0,1,5.66-5.66L96,130.34l37.17-37.17a4,4,0,0,1,5.66,0L228,182.34V128a4,4,0,0,1,8,0Z`}))]]),he=new Map([[`bold`,V.createElement(V.Fragment,null,V.createElement(`path`,{d:`M244,56v64a12,12,0,0,1-24,0V85l-75.51,75.52a12,12,0,0,1-17,0L96,129,32.49,192.49a12,12,0,0,1-17-17l72-72a12,12,0,0,1,17,0L136,135l67-67H168a12,12,0,0,1,0-24h64A12,12,0,0,1,244,56Z`}))],[`duotone`,V.createElement(V.Fragment,null,V.createElement(`path`,{d:`M232,56v64L168,56Z`,opacity:`0.2`}),V.createElement(`path`,{d:`M232,48H168a8,8,0,0,0-5.66,13.66L188.69,88,136,140.69l-34.34-34.35a8,8,0,0,0-11.32,0l-72,72a8,8,0,0,0,11.32,11.32L96,123.31l34.34,34.35a8,8,0,0,0,11.32,0L200,99.31l26.34,26.35A8,8,0,0,0,240,120V56A8,8,0,0,0,232,48Zm-8,52.69L187.31,64H224Z`}))],[`fill`,V.createElement(V.Fragment,null,V.createElement(`path`,{d:`M240,56v64a8,8,0,0,1-13.66,5.66L200,99.31l-58.34,58.35a8,8,0,0,1-11.32,0L96,123.31,29.66,189.66a8,8,0,0,1-11.32-11.32l72-72a8,8,0,0,1,11.32,0L136,140.69,188.69,88,162.34,61.66A8,8,0,0,1,168,48h64A8,8,0,0,1,240,56Z`}))],[`light`,V.createElement(V.Fragment,null,V.createElement(`path`,{d:`M238,56v64a6,6,0,0,1-12,0V70.48l-85.76,85.76a6,6,0,0,1-8.48,0L96,120.49,28.24,188.24a6,6,0,0,1-8.48-8.48l72-72a6,6,0,0,1,8.48,0L136,143.51,217.52,62H168a6,6,0,0,1,0-12h64A6,6,0,0,1,238,56Z`}))],[`regular`,V.createElement(V.Fragment,null,V.createElement(`path`,{d:`M240,56v64a8,8,0,0,1-16,0V75.31l-82.34,82.35a8,8,0,0,1-11.32,0L96,123.31,29.66,189.66a8,8,0,0,1-11.32-11.32l72-72a8,8,0,0,1,11.32,0L136,140.69,212.69,64H168a8,8,0,0,1,0-16h64A8,8,0,0,1,240,56Z`}))],[`thin`,V.createElement(V.Fragment,null,V.createElement(`path`,{d:`M236,56v64a4,4,0,0,1-8,0V65.66l-89.17,89.17a4,4,0,0,1-5.66,0L96,117.66,26.83,186.83a4,4,0,0,1-5.66-5.66l72-72a4,4,0,0,1,5.66,0L136,146.34,222.34,60H168a4,4,0,0,1,0-8h64A4,4,0,0,1,236,56Z`}))]]),ge=new Map([[`bold`,V.createElement(V.Fragment,null,V.createElement(`path`,{d:`M230.47,67.5a12,12,0,0,0-19.26-4.32L172.43,99l-12.68-2.72L157,83.57l35.79-38.78a12,12,0,0,0-4.32-19.26A76.07,76.07,0,0,0,88.41,121.64L30.92,174.18a4.68,4.68,0,0,0-.39.38,36,36,0,0,0,50.91,50.91l.38-.39,52.54-57.49A76.05,76.05,0,0,0,230.47,67.5ZM160,148a51.5,51.5,0,0,1-23.35-5.52,12,12,0,0,0-14.26,2.62L64.31,208.66a12,12,0,0,1-17-17l63.55-58.07a12,12,0,0,0,2.62-14.26A51.5,51.5,0,0,1,108,96a52.06,52.06,0,0,1,52-52h.89L135.17,71.87a12,12,0,0,0-2.91,10.65l5.66,26.35a12,12,0,0,0,9.21,9.21l26.35,5.66a12,12,0,0,0,10.65-2.91L212,95.12c0,.3,0,.59,0,.89A52.06,52.06,0,0,1,160,148Z`}))],[`duotone`,V.createElement(V.Fragment,null,V.createElement(`path`,{d:`M224,96a64,64,0,0,1-94.94,56L73,217A24,24,0,0,1,39,183L104,126.94a64,64,0,0,1,80-90.29L144,80l5.66,26.34L176,112l43.35-40A63.8,63.8,0,0,1,224,96Z`,opacity:`0.2`}),V.createElement(`path`,{d:`M226.76,69a8,8,0,0,0-12.84-2.88l-40.3,37.19-17.23-3.7-3.7-17.23,37.19-40.3A8,8,0,0,0,187,29.24,72,72,0,0,0,88,96,72.34,72.34,0,0,0,94,124.94L33.79,177c-.15.12-.29.26-.43.39a32,32,0,0,0,45.26,45.26c.13-.13.27-.28.39-.42L131.06,162A72,72,0,0,0,232,96,71.56,71.56,0,0,0,226.76,69ZM160,152a56.14,56.14,0,0,1-27.07-7,8,8,0,0,0-9.92,1.77L67.11,211.51a16,16,0,0,1-22.62-22.62L109.18,133a8,8,0,0,0,1.77-9.93,56,56,0,0,1,58.36-82.31l-31.2,33.81a8,8,0,0,0-1.94,7.1L141.83,108a8,8,0,0,0,6.14,6.14l26.35,5.66a8,8,0,0,0,7.1-1.94l33.81-31.2A56.06,56.06,0,0,1,160,152Z`}))],[`fill`,V.createElement(V.Fragment,null,V.createElement(`path`,{d:`M232,96a72,72,0,0,1-100.94,66L79,222.22c-.12.14-.26.29-.39.42a32,32,0,0,1-45.26-45.26c.14-.13.28-.27.43-.39L94,124.94a72.07,72.07,0,0,1,83.54-98.78,8,8,0,0,1,3.93,13.19L144,80l5.66,26.35L176,112l40.65-37.52a8,8,0,0,1,13.19,3.93A72.6,72.6,0,0,1,232,96Z`}))],[`light`,V.createElement(V.Fragment,null,V.createElement(`path`,{d:`M224.91,69.75a6,6,0,0,0-9.63-2.16l-41.07,37.9L154.7,101.3l-4.19-19.51,37.9-41.07a6,6,0,0,0-2.16-9.63,70,70,0,0,0-89.77,94.39l-61.39,53c-.11.09-.21.19-.32.3A30,30,0,0,0,77.2,221.23c.11-.11.21-.21.3-.32l53-61.39a70,70,0,0,0,94.39-89.77ZM160,154a58,58,0,0,1-28-7.22,6,6,0,0,0-7.45,1.33L68.57,212.88a18,18,0,0,1-25.45-25.45l64.76-55.94A6,6,0,0,0,109.2,124a58,58,0,0,1,64-84.53L139.58,75.93a6,6,0,0,0-1.45,5.33l5.65,26.35a6,6,0,0,0,4.61,4.61l26.35,5.65a6,6,0,0,0,5.33-1.45L216.49,82.8A58.06,58.06,0,0,1,160,154Z`}))],[`regular`,V.createElement(V.Fragment,null,V.createElement(`path`,{d:`M226.76,69a8,8,0,0,0-12.84-2.88l-40.3,37.19-17.23-3.7-3.7-17.23,37.19-40.3A8,8,0,0,0,187,29.24,72,72,0,0,0,88,96,72.34,72.34,0,0,0,94,124.94L33.79,177c-.15.12-.29.26-.43.39a32,32,0,0,0,45.26,45.26c.13-.13.27-.28.39-.42L131.06,162A72,72,0,0,0,232,96,71.56,71.56,0,0,0,226.76,69ZM160,152a56.14,56.14,0,0,1-27.07-7,8,8,0,0,0-9.92,1.77L67.11,211.51a16,16,0,0,1-22.62-22.62L109.18,133a8,8,0,0,0,1.77-9.93,56,56,0,0,1,58.36-82.31l-31.2,33.81a8,8,0,0,0-1.94,7.1L141.83,108a8,8,0,0,0,6.14,6.14l26.35,5.66a8,8,0,0,0,7.1-1.94l33.81-31.2A56.06,56.06,0,0,1,160,152Z`}))],[`thin`,V.createElement(V.Fragment,null,V.createElement(`path`,{d:`M223.05,70.5a4,4,0,0,0-6.42-1.44l-41.82,38.6L153,103l-4.68-21.79,38.6-41.82a4,4,0,0,0-1.44-6.43A68,68,0,0,0,98.94,126L36.4,180l-.21.2a28,28,0,0,0,39.6,39.6l.2-.21,54-62.54A68,68,0,0,0,228,96,67.51,67.51,0,0,0,223.05,70.5ZM160,156a60,60,0,0,1-29-7.47,4,4,0,0,0-5,.89L70,214.25A20,20,0,0,1,41.75,186l64.82-56a4,4,0,0,0,.89-5,60,60,0,0,1,69.46-86.59L141.05,77.29a4,4,0,0,0-1,3.55l5.66,26.35a4,4,0,0,0,3.07,3.07l26.35,5.66a4,4,0,0,0,3.55-1l38.87-35.87A60.05,60.05,0,0,1,160,156Z`}))]]),_e=V.forwardRef((e,t)=>V.createElement(a,{ref:t,...e,weights:le}));_e.displayName=`ArrowUpRightIcon`;var ve=_e,ye=V.forwardRef((e,t)=>V.createElement(a,{ref:t,...e,weights:ue}));ye.displayName=`ChartLineUpIcon`;var be=ye,H=V.forwardRef((e,t)=>V.createElement(a,{ref:t,...e,weights:de}));H.displayName=`ChatCircleIcon`;var xe=H,Se=V.forwardRef((e,t)=>V.createElement(a,{ref:t,...e,weights:fe}));Se.displayName=`PauseIcon`;var Ce=Se,we=V.forwardRef((e,t)=>V.createElement(a,{ref:t,...e,weights:pe}));we.displayName=`PlayIcon`;var Te=we,Ee=V.forwardRef((e,t)=>V.createElement(a,{ref:t,...e,weights:me}));Ee.displayName=`TrendDownIcon`;var De=Ee,Oe=V.forwardRef((e,t)=>V.createElement(a,{ref:t,...e,weights:he}));Oe.displayName=`TrendUpIcon`;var ke=Oe,Ae=V.forwardRef((e,t)=>V.createElement(a,{ref:t,...e,weights:ge}));Ae.displayName=`WrenchIcon`;var U=Ae,W=n();function je({emptyLabel:e}){return(0,W.jsx)(`div`,{className:`grid min-h-56 place-items-center rounded-lg bg-surface-secondary px-4 text-body text-muted`,children:e})}function Me(e){let t=Array.from(e),n=[],r=0,i=0;for(let e=t.length-1;e>=0;e--){let a=t[e];a>=`0`&&a<=`9`?n.unshift({key:`d${r++}`,digit:a.charCodeAt(0)-48}):n.unshift({key:`s${i++}`,char:a})}return n}var Ne=e=>(e%10+10)%10,G=e=>1-(1-e)**4,Pe=(e,t)=>{e.style.transform=`translateY(${-Ne(t)/11*100}%)`};function Fe({value:e,kind:t=`int`,duration:n=900,className:r}){let i=(0,V.useMemo)(()=>d(e,t),[e,t]),a=(0,V.useMemo)(()=>Me(i),[i]),o=(0,V.useRef)(null),s=(0,V.useRef)(new Map),c=(0,V.useRef)(new Map),l=(0,V.useRef)(0),u=(0,V.useRef)(!0),f=(0,V.useRef)(!1),p=(0,V.useRef)(new Set),m=(0,V.useRef)(new Set),h=new Set(a.filter(e=>`digit`in e).map(e=>e.key));for(let e of h)f.current&&!m.current.has(e)&&p.current.add(e);for(let e of p.current)h.has(e)||p.current.delete(e);return m.current=h,(0,V.useEffect)(()=>{f.current=!0},[]),(0,V.useEffect)(()=>{e!==l.current&&(u.current=e>l.current),l.current=e;let t=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,r=new Set;for(let e of a){if(!(`digit`in e))continue;r.add(e.key);let n=s.current.get(e.key)??{pos:0,from:0,to:0},i=u.current?Ne(e.digit-n.pos):-Ne(n.pos-e.digit);n.from=n.pos,n.to=n.pos+i,t&&(n.pos=n.from=n.to),s.current.set(e.key,n)}for(let e of s.current.keys())r.has(e)||s.current.delete(e);let i=()=>{for(let[e,t]of s.current){let n=c.current.get(e);n&&Pe(n,t.pos)}};if(t)return i();let o=0,d=performance.now(),f=e=>{let t=Math.min(1,(e-d)/n),r=G(t);for(let e of s.current.values())e.pos=e.from+(e.to-e.from)*r;i(),t<1&&(o=requestAnimationFrame(f))};return o=requestAnimationFrame(f),()=>cancelAnimationFrame(o)},[a,e,n]),(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`style`,{href:`ui-number-ticker`,precedence:`default`,children:Ie}),(0,W.jsxs)(`span`,{ref:o,className:[`ui-nt`,r].filter(Boolean).join(` `),"aria-live":`polite`,children:[(0,W.jsx)(`span`,{className:`ui-nt__sr`,children:i}),(0,W.jsx)(`span`,{className:`ui-nt__track`,"aria-hidden":`true`,children:a.map(e=>`digit`in e?(0,W.jsx)(`span`,{className:`ui-nt__col`,"data-enter":p.current.has(e.key)||void 0,children:(0,W.jsx)(`span`,{className:`ui-nt__stack`,ref:t=>{if(t)return c.current.set(e.key,t),Pe(t,s.current.get(e.key)?.pos??0),()=>{c.current.get(e.key)===t&&c.current.delete(e.key)}},children:[0,1,2,3,4,5,6,7,8,9,0].map((e,t)=>(0,W.jsx)(`span`,{className:`ui-nt__cell`,children:e},t))})},e.key):(0,W.jsx)(`span`,{className:`ui-nt__static`,children:e.char},e.key))})]})]})}var Ie=` +.ui-nt { + --ui-nt-lh: 1.15em; + --ui-nt-ease: cubic-bezier(0.22, 1, 0.36, 1); + position: relative; + display: inline-flex; + line-height: var(--ui-nt-lh); + font-variant-numeric: tabular-nums; + white-space: nowrap; +} +.ui-nt__sr { + position: absolute; + width: 1px; + height: 1px; + margin: -1px; + padding: 0; + overflow: hidden; + clip: rect(0 0 0 0); + white-space: nowrap; + border: 0; +} +.ui-nt__track { + display: inline-flex; + align-items: flex-start; + height: var(--ui-nt-lh); + line-height: var(--ui-nt-lh); +} +.ui-nt__col { + display: inline-block; + height: var(--ui-nt-lh); + overflow: hidden; + /* Soft top and bottom edges while digits pass through */ + -webkit-mask-image: linear-gradient(transparent, #000 14%, #000 86%, transparent); + mask-image: linear-gradient(transparent, #000 14%, #000 86%, transparent); +} +.ui-nt__col[data-enter] { animation: ui-nt-in 450ms var(--ui-nt-ease) both; } +.ui-nt__stack { + display: flex; + flex-direction: column; + will-change: transform; +} +.ui-nt__cell, +.ui-nt__static { + display: block; + height: var(--ui-nt-lh); + text-align: center; +} +.ui-nt__static { white-space: pre; } + +@keyframes ui-nt-in { + from { transform: translateY(-35%); } +} +@media (prefers-reduced-motion: reduce) { + .ui-nt__col[data-enter] { animation: none; } +} + +/* Dark mode: follows a .dark class or data-theme="dark" on any ancestor, e.g. . + The ticker inherits its color, so nothing needs to change here. */ +:where(.dark, [data-theme="dark"]) .ui-nt { + --ui-nt-lh: 1.15em; +} +`;function K({samples:e,capacity:t,label:n}){let r=e.length?e:[{at:0,value:0}],i=Math.max(1,t,...r.map(e=>e.value));return(0,W.jsx)(`div`,{className:`h-6 w-[120px] shrink-0`,role:`img`,"aria-label":n,children:(0,W.jsx)(N,{width:`100%`,height:`100%`,children:(0,W.jsxs)(I,{data:r,margin:{top:1,right:0,bottom:1,left:0},children:[(0,W.jsx)(F,{hide:!0,domain:[0,i]}),(0,W.jsx)(P,{type:`monotone`,dataKey:`value`,stroke:`var(--foreground)`,strokeOpacity:.7,strokeWidth:1.25,fill:`var(--foreground)`,fillOpacity:.08,isAnimationActive:!1,dot:!1})]})})})}function Le({live:e,samples:t,t:n,onConcurrencyClick:r}){let i=e?.in_flight??null,a=e?.capacity??0,o=i!=null&&a>0?i/a:0,s=a>0&&i!=null&&i>=a,c=(0,W.jsxs)(W.Fragment,{children:[n(`liveConcurrency`),(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,W.jsxs)(`span`,{className:`mono tabular text-body font-semibold ${s?`text-warning`:`text-foreground`}`,children:[i??`—`,(0,W.jsxs)(`span`,{className:`font-normal text-muted`,children:[`/`,e?a:`—`]})]}),(0,W.jsx)(`span`,{className:`inline-block h-[3px] w-12 overflow-hidden rounded-[2px] bg-separator`,children:(0,W.jsx)(`span`,{className:`block h-full ${s?`bg-warning`:`bg-foreground/60`}`,style:{width:`${Math.min(100,o*100)}%`}})})]})]});return(0,W.jsxs)(`div`,{"data-testid":`live-strip`,className:`flex min-h-11 flex-wrap items-center gap-x-5 gap-y-2 overflow-hidden rounded-lg bg-surface-secondary px-4 py-2.5 text-caption text-muted sm:h-11 sm:gap-x-6 sm:gap-y-1 sm:py-0`,children:[(0,W.jsx)(`span`,{className:`inline-flex items-center`,children:(0,W.jsx)(`span`,{className:`status-dot`,"data-state":i==null?``:s?`warn`:i>0?`ok`:``})}),r?(0,W.jsx)(`button`,{type:`button`,"data-testid":`live-strip-concurrency`,onClick:r,className:`inline-flex flex-col gap-1 rounded-lg text-left outline-none transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-focus sm:flex-row sm:items-center sm:gap-2`,"aria-label":n(`inflightExpandFromConcurrency`),children:c}):(0,W.jsx)(`span`,{className:`inline-flex flex-col gap-1 sm:flex-row sm:items-center sm:gap-2`,children:c}),(0,W.jsxs)(`span`,{className:`inline-flex flex-col gap-1 sm:flex-row sm:items-center sm:gap-2`,children:[n(`liveRpm`),(0,W.jsx)(`span`,{className:`mono tabular text-body font-semibold text-foreground`,children:e?.rpm??`—`})]}),(0,W.jsxs)(`span`,{className:`inline-flex flex-col gap-1 sm:flex-row sm:items-center sm:gap-2`,children:[n(`liveTrace`),(0,W.jsx)(K,{samples:t,capacity:a,label:n(`liveTrace`)})]})]})}var Re=24,ze=6;function Be(e){return{...e,workers:e.workers.map(e=>({...e,cells:e.cells?.map(e=>({...e}))})),jobs:e.jobs.map(e=>({...e})),rateLimits:e.rateLimits.map(e=>({...e})),depthSeries:[...e.depthSeries],totals:{...e.totals},completions:void 0}}function q(){return{generatedAt:Date.now(),backpressure:ze,throughputPerMin:0,waitP95Ms:0,totals:{done:0,failed:0},workers:[],jobs:[],rateLimits:[],depthSeries:Array.from({length:Re},()=>0)}}function J(e){return e==null||!Number.isFinite(e)?1:Math.max(1,Math.min(16,Math.floor(e)))}function Ve(e){let t=e.jobs.filter(e=>e.status===`running`).length,n=e.jobs.filter(e=>e.status===`queued`).length,r=e.workers.filter(e=>e.busy).length,i=0,a=0;for(let t of e.workers){let e=J(t.concurrency??1);i+=e;let n=t.inFlight==null?+!!t.busy:Math.max(0,Math.min(e,Math.floor(t.inFlight)));a+=n}let o=e.depthSeries[e.depthSeries.length-1]??n;return{running:t,waiting:n,busyWorkers:r,occupiedSlots:a,workerSlots:i,rateLimitActive:e.rateLimits.length,depthNow:o}}function He(e,t){let n=Date.now(),r=new Map(e.jobs.map(e=>[e.id,e])),i=Re,a=t.rate_limits.map((e,t)=>{let n=Math.min(.86,t*.22%.86);return{id:e.id,label:e.label,remainingMs:Math.max(0,e.remaining_ms),from:n,until:Math.min(1,n+.14)}}),o=(t.queue??[]).map(e=>{let t=(e.id||``).trim(),i=r.get(t),a,o=e.started_at?.trim();if(o){let e=Date.parse(o);Number.isNaN(e)||(a=e)}return a==null&&i?.startedAtMs!=null&&(a=i.startedAtMs),a??=n,{id:t,name:(e.name||``).trim()||t,kind:`chat`,status:`queued`,accountId:(e.account_id||``).trim()||void 0,progress:0,startedAtMs:a,elapsedMs:Math.max(0,n-a)}}),s=new Set(o.map(e=>e.id)),c=new Map;for(let e of o){let t=(e.accountId||``).trim();t&&e.name&&!c.has(t)&&c.set(t,e.name)}let l=new Map;for(let e of t.occupancy??[]){let t=(e.account_id||``).trim(),n=(e.id||``).trim();if(!t||!n)continue;let r=l.get(t)??[];r.push(e),l.set(t,r)}let u=new Map;for(let t of e.workers)t.cells?.length&&u.set(t.id,t.cells);let d=(e,t,n)=>{let r=e?.trim();if(r){let e=Date.parse(r);if(!Number.isNaN(e))return e}return t??n},f=t.workers.map(e=>{let i=J(e.max_inflight??4),a=e.in_flight!=null&&Number.isFinite(e.in_flight)?Math.max(0,Math.floor(e.in_flight)):+!!e.busy,o=Math.min(i,a),f=u.get(e.id)??[],p=new Map(f.map(e=>[e.id,e])),m=l.get(e.id)??[],h=[];for(let e of m){if(h.length>=o)break;let t=(e.id||``).trim();if(!t)continue;let i=p.get(t),a=r.get(t),c=d(e.started_at,i?.startedAtMs??a?.startedAtMs,n),l=(e.name||``).trim()||t;h.push({id:t,name:l,startedAtMs:c,elapsedMs:Math.max(0,n-c),pendingInbound:s.has(t)})}let g=t.workers.find(t=>t.id===e.id),_=d(g?.started_at,void 0,n);for(;h.length0;return{id:e.id,name:e.name,provider:e.provider,busy:v,progress:v?Math.max(.04,Math.min(1,e.progress||0)):0,rateLimited:e.rate_limited,jobId:h[0]?.id,concurrency:i,inFlight:o,cells:h}}),p=[];for(let e of f)for(let t of e.cells??[]){if(s.has(t.id))continue;let n=r.get(t.id);p.push({id:t.id,name:t.name,kind:n?.kind??`chat`,status:`running`,accountId:e.id,progress:e.progress,startedAtMs:t.startedAtMs,elapsedMs:t.elapsedMs})}let m=[...p,...o],h=e.waitP95Ms===0,g=h?e.depthSeries.slice(1):Array.from({length:23},()=>0);for(g.push(Math.max(0,t.in_flight));g.lengthe.id)),b=[];for(let n of e.jobs){if(n.status!==`running`||y.has(n.id))continue;let e=(n.accountId||n.id.replace(/^live-/,``)).trim(),r=!0;if(_.has(n.id))r=_.get(n.id),_.delete(n.id);else{let n=v.get(e);if(n&&n.length>0)r=n.shift();else{let n=t.workers.find(t=>t.id===e);n?.last_error_kind&&n.last_error_kind.trim()!==``&&(r=!1)}}b.push({id:n.id,name:n.name,kind:n.kind,ok:r})}let x=0,S=0;if(h){x=e.totals.done,S=e.totals.failed;let n=t.recent_completions??[];if(n.length>0)for(let e of n)(e.status||``).trim()===`ok`?x+=1:S+=1;else for(let e of b)e.ok?x+=1:S+=1}return{generatedAt:n,backpressure:e.backpressure,throughputPerMin:Math.max(0,t.rpm),waitP95Ms:0,totals:{done:x,failed:S},workers:f,rateLimits:a,jobs:m,depthSeries:g.slice(-24),completions:b.length>0?b:void 0}}var Ue=(0,V.lazy)(()=>S(()=>import(`./InflightDepthChart-Cl1KjYdd.js`).then(e=>({default:e.InflightDepthChart})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10])));b.registerPlugin(y,x);var Y=y.get(`inflightQueue`)||y.create(`inflightQueue`,`0.22, 1, 0.36, 1`),X=y.get(`inflightSlide`)||y.create(`inflightSlide`,`0.16, 1, 0.3, 1`),Z=6,We=4,Q=.88,$=.56,Ge=140;function Ke(e){let t=Math.max(0,e/1e3);if(t>=60){let e=Math.floor(t/60),n=Math.floor(t%60);return`${e}m ${String(n).padStart(2,`0`)}s`}return t>=10?`${t.toFixed(0)}s`:`${t.toFixed(1)}s`}function qe(e,t){return e?e.startedAtMs==null?Math.max(0,e.elapsedMs):Math.max(0,t-e.startedAtMs):0}function Je(e){switch(e){case`chat`:return`bg-[color-mix(in_oklab,var(--chart-1)_55%,var(--surface))]`;case`embed`:return`bg-[color-mix(in_oklab,var(--chart-6)_55%,var(--surface))]`;case`tools`:return`bg-[color-mix(in_oklab,var(--chart-5)_50%,var(--surface))]`;default:return`bg-foreground/25`}}function Ye(e){return(0,W.jsx)(`span`,{className:`grid size-7 shrink-0 place-items-center rounded-lg ${e===`embed`?`bg-[color-mix(in_oklab,var(--chart-6)_16%,var(--surface))] text-[color-mix(in_oklab,var(--chart-6)_70%,var(--foreground))]`:e===`tools`?`bg-[color-mix(in_oklab,var(--chart-5)_14%,var(--surface))] text-[color-mix(in_oklab,var(--chart-5)_68%,var(--foreground))]`:e===`chat`?`bg-[color-mix(in_oklab,var(--chart-1)_16%,var(--surface))] text-[color-mix(in_oklab,var(--chart-1)_70%,var(--foreground))]`:`bg-surface-secondary text-muted`}`,"aria-hidden":!0,children:e===`embed`?(0,W.jsx)(ee,{size:15}):e===`tools`?(0,W.jsx)(U,{size:15}):(0,W.jsx)(xe,{size:15})})}function Xe(e){switch(e){case`chat`:return`border border-[color-mix(in_oklab,var(--chart-1)_16%,transparent)] bg-[color-mix(in_oklab,var(--chart-1)_8%,var(--surface))] text-foreground/75`;case`embed`:return`border border-[color-mix(in_oklab,var(--chart-6)_16%,transparent)] bg-[color-mix(in_oklab,var(--chart-6)_8%,var(--surface))] text-foreground/75`;case`tools`:return`border border-[color-mix(in_oklab,var(--chart-5)_14%,transparent)] bg-[color-mix(in_oklab,var(--chart-5)_7%,var(--surface))] text-foreground/72`;default:return`border border-foreground/8 bg-[color-mix(in_oklab,var(--foreground)_3%,var(--surface))] text-foreground/68`}}function Ze({slot:e,jobById:t,clockMs:n,idleLabel:r,landedCellIds:i}){let a=J(e.concurrency??1),o=e.inFlight==null?+!!e.busy:Math.max(0,Math.floor(e.inFlight)),s=Math.min(a,o),c=s>0,l=(e.cells??[]).slice(0,s),u=l.filter(e=>!e.pendingInbound&&i.has(e.id)).map(e=>`${e.name} ${Ke(Math.max(0,n-e.startedAtMs))}`),d=`${e.name} · ${s}/${a}${u.length?` · ${u.join(`, `)}`:``}`;return(0,W.jsxs)(`div`,{"data-slot":!0,"data-slot-id":e.id,"data-slot-job":e.jobId??``,"data-slot-busy":c?``:void 0,"data-slot-concurrency":a,"data-slot-inflight":s,className:`relative flex min-w-0 items-center gap-2 overflow-hidden rounded-xl px-2.5 py-2 ${c?`border border-foreground/12 bg-[var(--il-busy-bg)]`:`border border-foreground/8 bg-[var(--il-item-bg)]`}`,title:d,children:[(0,W.jsxs)(`span`,{className:`relative z-[1] flex min-w-0 w-[5.5rem] shrink-0 items-center gap-1.5 ${c?`text-foreground/85`:`text-muted opacity-55`}`,title:`${e.name} · ${e.provider}`,children:[(0,W.jsx)(`span`,{className:`grid size-5 shrink-0 place-items-center ${c?``:`opacity-70`}`,"aria-hidden":!0,children:(0,W.jsx)(L,{provider:e.provider,size:18})}),(0,W.jsx)(`span`,{className:`mono min-w-0 truncate text-caption leading-none ${c?`font-medium`:``}`,children:e.name})]}),(0,W.jsx)(`div`,{className:`relative z-[1] flex min-h-[2rem] min-w-0 flex-1 gap-0.5`,role:`img`,"aria-label":`${s}/${a}`,children:Array.from({length:a},(e,a)=>{let o=l[a],s=!!o,c=s&&!o.pendingInbound&&i.has(o.id),u=c?t.get(o.id):void 0,d=c?Math.max(0,n-o.startedAtMs):0,f=o?.name||r;return(0,W.jsx)(`div`,{"data-slot-cell":``,"data-slot-fill":s?``:void 0,"data-cell-id":o?.id??``,"data-cell-index":a,"data-cell-pending":s&&!c?``:void 0,className:`relative flex min-w-0 flex-1 flex-col justify-center overflow-hidden rounded-[2px] px-1 ${c?`border border-foreground/14 bg-[var(--il-busy-fill)] text-foreground/85`:`bg-[var(--il-track)] opacity-55`}`,children:c?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`span`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-y-0 w-[62%] bg-gradient-to-r from-transparent via-[color-mix(in_oklab,var(--foreground)_9%,transparent)] to-transparent motion-safe:animate-[inflight-shimmer_1.35s_linear_infinite]`}),(0,W.jsxs)(`span`,{className:`relative z-[1] flex min-w-0 items-center gap-1 truncate text-caption font-medium leading-tight`,children:[u?(0,W.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-[2px] ${Je(u.kind)}`,"aria-hidden":!0}):null,(0,W.jsx)(`span`,{className:`truncate`,"data-slot-job-pill":``,children:f})]}),(0,W.jsx)(`span`,{className:`relative z-[1] mono truncate text-[9px] leading-tight tabular text-foreground/70`,children:Ke(d)})]}):(0,W.jsx)(`span`,{className:`relative z-[1] mono text-center text-[9px] text-muted/50`,children:`—`})},o?.id??`empty-${a}`)})})]})}function Qe({t:e,snapshot:t,live:n=null,liveError:a=null,expanded:o,onExpandedChange:s,defaultExpanded:c=!1,bare:l=!1}){let d=t!==void 0,[f,p]=(0,V.useState)(c),m=o??f,h=e=>{s?.(e),o===void 0&&p(e)},[g,_]=(0,V.useState)(()=>Be(t??q())),[v,y]=(0,V.useState)(null),[x,S]=(0,V.useState)(()=>Date.now()),[ee,C]=(0,V.useState)(()=>new Set),w=(0,V.useRef)(new Map),ne=e=>{let t=(e||``).trim();if(!t)return;let n=w.current.get(t);n&&(clearTimeout(n),w.current.delete(t)),C(e=>{if(e.has(t))return e;let n=new Set(e);return n.add(t),n})},E=e=>{let t=(e||``).trim();if(!t)return;let n=w.current.get(t);n&&clearTimeout(n),w.current.set(t,setTimeout(()=>{w.current.delete(t),ne(t)},Ge))},D=d?t:g,k=(0,V.useMemo)(()=>Ve(D),[D]),A=(0,V.useRef)(null),j=(0,V.useRef)(!1),re=(0,V.useRef)(D),N=(0,V.useRef)({wait:{},slot:{},outcome:{}}),P=(0,V.useMemo)(()=>new Map(D.jobs.map(e=>[e.id,e])),[D.jobs]),F=D.jobs.filter(e=>e.status===`queued`),I=F.slice(0,Z),L=F.slice(Z),R=(0,V.useMemo)(()=>{let e=D.workers.filter(e=>e.busy),t=D.workers.filter(e=>!e.busy),n=[],r=new Set;for(let i of[...e,...t])if(!r.has(i.id)&&(r.add(i.id),n.push(i),n.length>=We))break;return n},[D.workers]),z=k.waiting>=D.backpressure,B=(0,V.useRef)(!1);(0,V.useLayoutEffect)(()=>{if(d){_(Be(t)),y(null),B.current=!1;return}if(!m){B.current=!1;return}if(n!==null){y(n.sticky),S(Date.now()),B.current||(j.current=!1),_(e=>{let t=B.current?e:q();return B.current=!0,He(t,n)});return}y(null),B.current=!1,j.current=!1,_(Be(q()))},[d,t,m,n]),(0,V.useEffect)(()=>{if(!m)return;if(M()){S(Date.now());return}let e=0,t=0,n=!0,r=i=>{n&&(!document.hidden&&i-t>=150&&(t=i,S(Date.now())),e=requestAnimationFrame(r))};return S(Date.now()),e=requestAnimationFrame(r),()=>{n=!1,cancelAnimationFrame(e)}},[m]),(0,V.useEffect)(()=>{m||(j.current=!1)},[m]),(0,V.useEffect)(()=>{if(!m){for(let e of w.current.values())clearTimeout(e);w.current.clear(),C(new Set)}},[m]),(0,V.useEffect)(()=>()=>{for(let e of w.current.values())clearTimeout(e);w.current.clear()},[]),(0,V.useLayoutEffect)(()=>{let e=A.current,t=re.current;re.current=D;let r=()=>{if(!e)return;let t={};e.querySelectorAll(`[data-wait-id]`).forEach(e=>{let n=e.getAttribute(`data-wait-id`);n&&(t[n]=e.getBoundingClientRect())});let n={};e.querySelectorAll(`[data-slot-id]`).forEach(e=>{let t=e.getAttribute(`data-slot-id`);t&&(n[t]=e.getBoundingClientRect())}),e.querySelectorAll(`[data-cell-id]`).forEach(e=>{let t=e.getAttribute(`data-cell-id`);t&&(n[`cell:${t}`]=e.getBoundingClientRect())}),N.current={wait:t,slot:n,outcome:{ok:e.querySelector(`[data-outcome="ok"]`)?.getBoundingClientRect(),danger:e.querySelector(`[data-outcome="danger"]`)?.getBoundingClientRect()}}},i=e=>{let n=new Set(t.jobs.filter(e=>e.status===`queued`).map(e=>e.id));C(t=>{let r=new Set,i=new Set;for(let a of D.workers)for(let o of a.cells??[]){let a=o.id;if(r.add(a),!o.pendingInbound){if(t.has(a)){i.add(a);continue}if(e===`all`){i.add(a);continue}D.jobs.some(e=>e.id===a&&e.status===`queued`)||n.has(a)||i.add(a)}}let a=i.size===t.size;if(a){for(let e of i)if(!t.has(e)){a=!1;break}}if(a){for(let e of t)if(!r.has(e)){a=!1;break}}return a?t:i})};if(!e||M()||!j.current){r(),i(`all`),m&&e&&!j.current&&!M()&&(d||B.current||n===null?(j.current=!0,b.killTweensOf(e),b.fromTo(e,{opacity:0,y:6},{opacity:1,y:0,duration:T(.22),ease:ie.out,clearProps:`opacity,transform`,force3D:!0})):b.set(e,{opacity:0}));return}if(t===D){r(),i(`stable`);return}i(`stable`);let a=new Map(t.jobs.map(e=>[e.id,e])),o=new Map(D.jobs.map(e=>[e.id,e])),s=new Map;for(let e of t.workers){e.jobId&&s.set(e.jobId,e.id);for(let t of e.cells??[])s.set(t.id,e.id)}let c=new Map;for(let e of D.workers){e.jobId&&c.set(e.jobId,e.id);for(let t of e.cells??[])c.set(t.id,e.id)}let l=(e,t,n,r,i,a,o,s=0)=>{let c=e instanceof HTMLElement?e.getBoundingClientRect():e,l=t instanceof HTMLElement?t.getBoundingClientRect():t;if(!c||!l||c.width<2||l.width<2){o?.();return}let u=r===`chat`?`var(--chart-1)`:r===`embed`?`var(--chart-6)`:r===`tools`?`var(--chart-5)`:`var(--foreground)`,d=i===`ok`?`color-mix(in oklab, var(--success) 24%, var(--surface))`:i===`danger`?`color-mix(in oklab, var(--danger) 22%, var(--surface))`:i===`retry`?`color-mix(in oklab, var(--warning) 16%, var(--surface))`:r===`chat`?`color-mix(in oklab, var(--chart-1) 32%, var(--surface))`:r===`embed`?`color-mix(in oklab, var(--chart-6) 32%, var(--surface))`:r===`tools`?`color-mix(in oklab, var(--chart-5) 26%, var(--surface))`:`var(--surface)`,f=i===`ok`?`var(--success)`:i===`danger`?`var(--danger)`:i===`retry`?`var(--warning)`:`var(--foreground)`,p=i===`ok`?`var(--success)`:i===`danger`?`var(--danger)`:i===`retry`?`var(--warning)`:u,m=u,h=`inset 0 1px 0 var(--surface-rim), inset 0 0 0 1px var(--surface-edge), var(--surface-contact), 0 0 0 1px color-mix(in oklab, ${p} 28%, transparent), 0 6px 18px color-mix(in oklab, ${p} 36%, transparent), 0 12px 32px color-mix(in oklab, var(--foreground) 16%, transparent)`,g=`inset 0 1px 0 var(--surface-rim), 0 0 14px color-mix(in oklab, ${p} 48%, transparent), 0 0 28px color-mix(in oklab, ${p} 28%, transparent)`,_=i===`run`,v=_?Math.max(c.width,72):Math.max(c.width,88),y=_?Math.max(c.height,22):Math.max(c.height,26),x=_?Math.max(l.width,40):void 0,S=_?Math.max(l.height,22):void 0,ee=x??v*.92,te=S??y,C=l.left+Math.max(0,(l.width-ee)/2),w=l.top+Math.max(0,(l.height-te)/2),ne=i===`ok`||i===`danger`?.86:1,E=c.left+(C-c.left)*ne,D=c.top+(w-c.top)*ne,O=T(_?Q:.72),k=T(_?.12:.16),A=T(_?.18:.14),j=T(Math.max(0,s)),re=e=>{let t=document.createElement(`div`);t.setAttribute(`aria-hidden`,`true`),Object.assign(t.style,{position:`fixed`,left:`${c.left}px`,top:`${c.top}px`,width:`${v}px`,height:`${y}px`,zIndex:e.asTrail?`78`:`80`,pointerEvents:`none`,display:`flex`,alignItems:`center`,gap:`6px`,padding:`0 8px`,borderRadius:`8px`,fontSize:`11px`,fontWeight:`500`,lineHeight:`1`,color:f,background:d,boxShadow:e.asTrail?g:h,whiteSpace:`nowrap`,overflow:`hidden`,textOverflow:`ellipsis`,opacity:String(e.opacity),willChange:`transform, left, top, opacity, filter`,transform:e.asTrail?`scaleX(1.12)`:`none`,filter:e.asTrail?`blur(0.9px) brightness(1.18) saturate(1.25)`:`none`});let r=document.createElement(`span`);Object.assign(r.style,{width:`6px`,height:`6px`,borderRadius:`2px`,flexShrink:`0`,background:m});let i=document.createElement(`span`);return i.textContent=n,Object.assign(i.style,{overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`,minWidth:`0`,flex:`1`}),t.append(r,i),document.body.appendChild(t),t},M=i===`ok`||i===`danger`,ie=M?v*.55:v*.92,N=_?x:ie,P=_?1:i===`retry`?.96:.42,F=_?.82:i===`retry`?.9:.28,I=re({opacity:1});b.set(I,{transformOrigin:`center center`,x:0,y:0});let L=E-c.left,R=D-c.top,z=_?-Math.min(42,14+Math.abs(L)*.1):0;[.72,.46,.26].map((e,t)=>{let n=re({opacity:e,asTrail:!0});return b.set(n,{transformOrigin:`center center`,x:0,y:0}),_?b.to(n,{motionPath:{path:[{x:0,y:0},{x:L*.45,y:R*.35+z},{x:L,y:R}],curviness:1.35,autoRotate:!1},width:N,height:S,scaleX:1.18+t*.08,opacity:0,duration:O,delay:j+T(.05+t*.05),ease:X,force3D:!0,onComplete:()=>n.remove()}):b.to(n,{left:E,top:D,width:N,...M?{scale:P*(.92-t*.08)}:{scaleX:1.28+t*.1},opacity:0,duration:O,delay:j+T(.04+t*.045),ease:Y,force3D:!0,onComplete:()=>n.remove()}),n});let B=_?{motionPath:{path:[{x:0,y:0},{x:L*.45,y:R*.35+z},{x:L,y:R}],curviness:1.35,autoRotate:!1},width:N,height:S,scale:P,opacity:1,duration:O,delay:j,ease:X,force3D:!0}:{left:E,top:D,width:N,scale:P,opacity:1,duration:O,delay:j,ease:Y,force3D:!0};b.to(I,{...B,onComplete:()=>{let e=a;if(e&&(i===`ok`||i===`danger`)){let t=i===`ok`?`inset 0 0 0 1px color-mix(in oklab, var(--success) 28%, transparent)`:`inset 0 0 0 1px color-mix(in oklab, var(--danger) 28%, transparent)`,n=i===`ok`?`inset 0 0 0 1.5px color-mix(in oklab, var(--success) 52%, transparent), 0 0 10px color-mix(in oklab, var(--success) 20%, transparent)`:`inset 0 0 0 1.5px color-mix(in oklab, var(--danger) 52%, transparent), 0 0 10px color-mix(in oklab, var(--danger) 20%, transparent)`;b.set(e,{transformOrigin:`center center`});let r=b.timeline({onComplete:()=>{b.set(e,{clearProps:`boxShadow,transform,x,scale`})}});r.fromTo(e,{boxShadow:t},{boxShadow:n,duration:T(.16),ease:`power1.inOut`,yoyo:!0,repeat:1}),r.to(e,{keyframes:[{x:2.8,scale:1.07,duration:T(.07)},{x:-3.2,scale:.93,duration:T(.09)},{x:2.2,scale:1.05,duration:T(.08)},{x:-1.2,scale:.98,duration:T(.07)},{x:0,scale:1,duration:T(.1)}],ease:`power1.inOut`})}o?.(),b.to(I,{opacity:0,scale:F,duration:A,delay:k,ease:`power1.out`,onComplete:()=>I.remove()})}})},u=N.current,f=new Set,p=(t,n,r,i)=>{if(!i||f.has(t))return;f.add(t);let a=u.wait[t],o=e.querySelector(`[data-slot-id="${CSS.escape(i)}"]`),s=o?.querySelector(`[data-cell-id="${CSS.escape(t)}"]`)??o?.querySelector(`[data-slot-fill]:last-of-type`)??null,c=s?.getBoundingClientRect()??o?.getBoundingClientRect()??u.slot[i],d=s;if(!(a&&c&&a.width>=2&&c.width>=2)){E(t);return}l(a,c,n,r,`run`,null,()=>{ne(t),o&&(b.fromTo(o,{filter:`brightness(1.28)`},{filter:`brightness(1)`,duration:T(.48),ease:ie.soft}),d&&b.fromTo(d,{scale:.92,transformOrigin:`left center`},{scale:1,duration:T(.48),ease:X}))})};for(let[e,t]of o){let n=a.get(e);if(!n||n.status!==`queued`||t.status!==`running`)continue;let r=c.get(e)||t.accountId||n.accountId;r&&p(e,t.name,t.kind,r)}let h=D.workers.filter(e=>e.busy&&!t.workers.some(t=>t.id===e.id&&t.busy));for(let[e,t]of a){if(t.status!==`queued`||o.has(e))continue;let n=(t.accountId||``).trim();if(!n&&h.length===1&&(n=h[0].id),!n)continue;let r=D.workers.find(e=>e.id===n);r&&!r.busy&&h.every(e=>e.id!==n)||p(e,t.name,t.kind,n)}for(let[e,t]of a)t.status===`queued`&&(o.has(e)||f.has(e)||D.workers.some(t=>(t.cells??[]).some(t=>t.id===e))&&E(e));{let t=new Set;for(let[e,n]of a){if(n.status!==`queued`)continue;let r=o.get(e);r&&r.status===`queued`||t.add(e)}if(t.size){let n=T($),r=e=>{let t=e.dataset.waitId;t&&(N.current.wait[t]=e.getBoundingClientRect())},i=(e,i)=>{let a=e.dataset.waitId;if(!a||t.has(a))return;let o=e.getBoundingClientRect();b.killTweensOf(e),b.set(e,{x:0,y:0,scale:1});let s=e.getBoundingClientRect(),c=o.left-s.left,l=o.top-s.top;if(Math.abs(c)<.5&&Math.abs(l)<.5){r(e);return}b.fromTo(e,{x:c,y:l,...i?.promote?{scale:1.15}:{}},{x:0,y:0,scale:1,duration:n,ease:Y,force3D:!0,onUpdate:()=>r(e),onComplete:()=>{b.set(e,{clearProps:`transform`}),r(e)}})};e.querySelectorAll(`[data-wait-pill][data-wait-id]`).forEach(e=>i(e)),e.querySelectorAll(`[data-wait-token][data-wait-id]`).forEach(e=>i(e,{promote:!0}))}}{let n=new Set;for(let e of D.workers)for(let t of e.cells??[])n.add(t.id);let r=[],i=new Set;for(let e of t.workers)(e.cells??[]).forEach((t,s)=>{if(n.has(t.id)||i.has(t.id))return;let c=o.get(t.id);if(c?.status===`queued`||c?.status===`running`)return;i.add(t.id);let l=a.get(t.id);r.push({id:t.id,name:t.name||l?.name||e.name,kind:l?.kind??`chat`,workerId:e.id,cellIndex:s})});for(let[e,t]of a){if(t.status!==`running`||i.has(e)||n.has(e))continue;let a=o.get(e);a?.status!==`queued`&&a?.status!==`running`&&(i.add(e),r.push({id:e,name:t.name,kind:t.kind,workerId:s.get(e)??``,cellIndex:0}))}let c=new Map;for(let e of r){let t=c.get(e.workerId)??[];t.push(e),c.set(e.workerId,t)}for(let n of c.values())n.sort((e,t)=>e.cellIndex-t.cellIndex),n.forEach((n,r)=>{let i=u.slot[`cell:${n.id}`]??(n.workerId?u.slot[n.workerId]:void 0),a=o.get(n.id),s=D.completions?.find(e=>e.id===n.id),c;if(s)c=s.ok?`ok`:`danger`;else if(a?.status===`failed`)c=`danger`;else if(a?.status===`done`)c=`ok`;else{let e=D.totals.done>t.totals.done;c=D.totals.failed>t.totals.failed&&!e?`danger`:`ok`}let d=e.querySelector(c===`ok`?`[data-outcome="ok"]`:`[data-outcome="danger"]`),f=d?.getBoundingClientRect()??u.outcome[c];l(i,f,n.name,n.kind,c,d,void 0,r*.1)})}for(let[t,n]of a){if(n.status!==`running`)continue;let r=o.get(t);if(!r||r.status!==`queued`)continue;let i=s.get(t),a=u.slot[`cell:${t}`]??(i?u.slot[i]:void 0),c=(e.querySelector(`[data-wait-id="${CSS.escape(t)}"]`)??e.querySelector(`[data-queue-col]`))?.getBoundingClientRect();l(a,c,n.name,n.kind,`retry`,null,()=>{let n=e.querySelector(`[data-wait-id="${CSS.escape(t)}"]`);n&&b.fromTo(n,{opacity:.4,scale:.85},{opacity:1,scale:1,duration:T(.42),ease:Y})})}for(let[t,n]of o){if(n.status!==`queued`||a.has(t))continue;let r=e.querySelector(`[data-wait-id="${CSS.escape(t)}"]`);r&&b.fromTo(r,{opacity:0,y:-10,scale:.6},{opacity:1,y:0,scale:1,duration:T(.52),ease:Y})}{let n=t.jobs.filter(e=>e.status===`queued`).map(e=>e.id),r=D.jobs.filter(e=>e.status===`queued`).map(e=>e.id);if(n.length===r.length&&n.some((e,t)=>e!==r[t])){let t=T($);for(let n of r){let r=e.querySelector(`[data-wait-id="${CSS.escape(n)}"]`);if(!r)continue;let i=r.getBoundingClientRect();b.killTweensOf(r),b.set(r,{x:0,y:0});let a=r.getBoundingClientRect(),o=i.left-a.left,s=i.top-a.top;if(Math.abs(o)<.5&&Math.abs(s)<.5){N.current.wait[n]=a;continue}b.fromTo(r,{x:o,y:s},{x:0,y:0,duration:t,ease:Y,force3D:!0,onUpdate:()=>{N.current.wait[n]=r.getBoundingClientRect()},onComplete:()=>{b.set(r,{clearProps:`transform`}),N.current.wait[n]=r.getBoundingClientRect()}})}}}{let n=t.jobs.filter(e=>e.status===`queued`).map(e=>e.id),r=D.jobs.filter(e=>e.status===`queued`).map(e=>e.id);for(let t=0;t{let t=e.filter(e=>e.busy),n=e.filter(e=>!e.busy),r=[],i=new Set;for(let e of[...t,...n])if(!i.has(e.id)&&(i.add(e.id),r.push(e.id),r.length>=We))break;return r},r=n(t.workers),i=n(D.workers);if(r.length!==i.length||r.some((e,t)=>e!==i[t])){let t=new Map(r.map((e,t)=>[e,t]));for(let n=0;nd,m=T(f?0:p?.07:.04),h=T(f?.72:.64);b.killTweensOf(a),b.fromTo(a,{x:c,y:l,scale:f?1.035:1,zIndex:f?6:p?2:3},{x:0,y:0,scale:1,zIndex:1,duration:h,delay:m,ease:Y,force3D:!0,onComplete:()=>{b.set(a,{clearProps:`transform,zIndex`})}})}for(let n of i){if(t.has(n))continue;let r=e.querySelector(`[data-slot-id="${CSS.escape(n)}"]`);r&&(b.killTweensOf(r),b.fromTo(r,{opacity:.35,y:14,scale:.96},{opacity:1,y:0,scale:1,duration:T(.56),delay:T(.08),ease:Y,onComplete:()=>b.set(r,{clearProps:`transform`})}))}}}r()},[D,m,d,n]);let ae=e(`inflightDepthHint`,{n:k.depthNow}),oe=!!n,se=!n&&!!a,ce=v?.bindings??0;return(0,W.jsxs)(u,{"data-testid":`inflight-live-card`,"data-expanded":m?`true`:`false`,"data-gsap-reveal":!0,variant:l?`transparent`:void 0,className:`group overflow-hidden p-0 ${l?`bg-transparent shadow-none`:`transition-[box-shadow] duration-200`}`,children:[(0,W.jsx)(`style`,{children:` + [data-testid="inflight-live-card"]{ + /* Public AffectUI hierarchy → project tokens. + Outer Card keeps solid-glass; nested queue/slots/outcomes use + color wash + spacing (no section rules / stacked inset rings). + chart-3 stays out of surfaces. Depth curve uses chart-1. */ + /* Nested items: color wash + spacing — avoid section rules / stacked frames. */ + --il-well: var(--surface); + --il-chip: var(--surface); + --il-item-bg: color-mix(in oklab, var(--surface-secondary) 38%, var(--surface)); + --il-track: color-mix(in oklab, var(--foreground) 8%, var(--surface-secondary)); + --il-busy-bg: color-mix(in oklab, var(--chart-1) 7%, var(--surface)); + --il-busy-fill: color-mix(in oklab, var(--chart-1) 9%, var(--surface)); + --il-busy-glow: none; + --il-run: color-mix(in oklab, var(--foreground) 84%, transparent); + --il-warn: var(--warning); + --il-warn-fg: var(--warning); + /* Amber only for rate-limit/cooldown — light wash, not saturated orange panel */ + --il-warn-bg: color-mix(in oklab, var(--warning) 11%, var(--surface)); + --il-warn-hatch: color-mix(in oklab, var(--warning) 22%, transparent); + /* AffectUI-ish mint / coral outcome sinks — a touch richer wash */ + --il-ok-bg: color-mix(in oklab, var(--success) 8%, var(--surface)); + --il-ok-fg: color-mix(in oklab, var(--success) 78%, var(--foreground)); + --il-err-bg: color-mix(in oklab, var(--danger) 7%, var(--surface)); + --il-err-fg: var(--danger); + --il-depth: var(--chart-1); + --il-depth-fill: color-mix(in oklab, var(--chart-1) 20%, transparent); + --il-faint: color-mix(in oklab, var(--foreground) 42%, transparent); + } + /* Busy slot: cool wash + soft glow — no stacked glass rings */ + [data-testid="inflight-live-card"] [data-slot-busy]{ + box-shadow: var(--il-busy-glow); + } + @keyframes inflight-shimmer{0%{transform:translateX(-130%)}100%{transform:translateX(230%)}} + @keyframes inflight-queue-shimmer{0%{transform:translateX(-140%);opacity:.4}50%{opacity:.9}100%{transform:translateX(240%);opacity:.4}} + @keyframes inflight-glow{from{opacity:.45}to{opacity:1}} + @media (prefers-reduced-motion: reduce){ + [class*="animate-[inflight-shimmer_"], + [class*="animate-[inflight-queue-shimmer_"], + [class*="animate-[inflight-glow_"]{animation:none!important} + } + `}),l?null:(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3 px-4 py-3`,children:[(0,W.jsxs)(`button`,{type:`button`,"data-testid":`inflight-live-toggle`,"aria-expanded":m,"aria-controls":`inflight-live-body`,onClick:()=>h(!m),className:`flex min-w-0 flex-1 items-start gap-2 text-left outline-none focus-visible:ring-2 focus-visible:ring-focus focus-visible:ring-offset-2 focus-visible:ring-offset-background`,children:[(0,W.jsx)(r,{size:14,"aria-hidden":!0,className:`mt-1 shrink-0 text-muted transition-transform duration-200 ${m?`rotate-90`:``}`}),(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`h3`,{className:`font-semibold`,children:e(`inflightTitle`)}),(0,W.jsxs)(`span`,{className:`mono inline-flex items-center gap-1 rounded-[3px] px-1.5 py-0.5 text-caption text-muted`,children:[(0,W.jsx)(`span`,{className:`status-dot`,"data-state":oe?`ok`:``}),e(oe?`inflightLiveBadge`:se?`inflightOfflineBadge`:`inflightIdleBadge`)]}),m&&ce>0?(0,W.jsx)(`span`,{className:`mono text-caption text-muted`,children:e(`inflightStickyBindings`,{n:ce})}):null]}),(0,W.jsx)(`p`,{className:`mt-0.5 text-caption text-muted`,children:e(`inflightHint`)})]})]}),(0,W.jsx)(`div`,{className:`flex shrink-0 flex-col items-end gap-2`,children:m?(0,W.jsxs)(te,{to:`/live`,className:`inline-flex shrink-0 items-center gap-1 text-caption text-muted transition-colors hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus`,"aria-label":e(`inflightCardAria`),onClick:e=>e.stopPropagation(),children:[e(`inflightOpen`),(0,W.jsx)(ve,{size:14,"aria-hidden":!0})]}):(0,W.jsxs)(`button`,{type:`button`,className:`inline-flex shrink-0 items-center gap-1 text-caption text-muted transition-colors hover:text-foreground`,onClick:()=>h(!0),children:[e(`inflightExpand`),(0,W.jsx)(r,{size:14,"aria-hidden":!0})]})})]}),m?(0,W.jsxs)(`div`,{id:`inflight-live-body`,ref:A,children:[(0,W.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 px-4 pb-1 pt-0 sm:grid-cols-4`,children:[(0,W.jsx)($e,{label:e(`inflightWaiting`),value:k.waiting,warn:z}),(0,W.jsx)($e,{label:e(`inflightRunning`),value:k.occupiedSlots,suffix:`/${k.workerSlots}`}),(0,W.jsx)($e,{label:e(`inflightThroughput`),value:D.throughputPerMin,suffix:`/min`}),(0,W.jsx)($e,{label:e(`inflightWaitP95`),value:D.waitP95Ms>0?D.waitP95Ms:null,kind:`ms`})]}),a?(0,W.jsx)(`div`,{className:`px-4 pt-1 text-caption text-[var(--il-err-fg)]`,"data-live-error":!0,children:a}):null,(0,W.jsxs)(`div`,{className:`grid gap-3 px-4 py-3 lg:grid-cols-[minmax(11rem,0.7fr)_minmax(0,2.1fr)_auto]`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,"data-queue-col":!0,children:[(0,W.jsxs)(`div`,{className:`mb-1.5 flex items-baseline justify-between gap-2`,children:[(0,W.jsx)(`span`,{className:`text-caption uppercase tracking-wide text-muted`,children:e(`inflightQueue`)}),(0,W.jsx)(`span`,{className:`mono text-[10px] tabular ${z?`text-[var(--il-warn-fg)]`:`text-muted`}`,children:k.waiting})]}),(0,W.jsxs)(`div`,{className:`space-y-1.5`,children:[I.map(t=>(0,W.jsxs)(`div`,{"data-wait-pill":!0,"data-wait-id":t.id,"data-priority":t.priority??`normal`,className:`relative flex items-center justify-between gap-2 overflow-hidden rounded-xl px-2.5 py-2 ${Xe(t.kind)}`,children:[(0,W.jsx)(`span`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-y-0 w-2/5 bg-gradient-to-r from-transparent via-[color-mix(in_oklab,var(--foreground)_8%,transparent)] to-transparent motion-safe:animate-[inflight-queue-shimmer_2.8s_linear_infinite]`}),(0,W.jsxs)(`span`,{className:`relative z-[1] flex min-w-0 items-center gap-2.5 truncate text-caption font-medium text-foreground/78`,children:[Ye(t.kind),(0,W.jsxs)(`span`,{className:`truncate`,children:[t.name,t.priority===`high`?(0,W.jsx)(`span`,{className:`mono ml-1 text-[10px] text-muted`,children:`↑`}):null,t.sticky?(0,W.jsx)(`span`,{className:`mono ml-1 text-[10px] text-muted`,children:e(`inflightSticky`)}):null]})]}),(0,W.jsx)(`span`,{className:`relative z-[1] mono shrink-0 text-caption text-muted`,children:Ke(qe(t,x))})]},t.id)),L.length?(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 pt-1`,"data-queue-overflow":!0,children:[L.map(e=>(0,W.jsx)(`span`,{"data-wait-token":!0,"data-wait-id":e.id,"data-priority":e.priority??`normal`,className:`size-2 rounded-[2px] ${Je(e.kind)} ${e.priority===`high`?`ring-1 ring-foreground/20`:``}`,title:e.name},e.id)),(0,W.jsxs)(`span`,{className:`mono text-[10px] text-muted`,children:[`+`,L.length]})]}):I.length===0?(0,W.jsx)(`div`,{className:`text-caption text-muted`,children:e(`inflightQueueEmpty`)}):null]})]}),(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsxs)(`div`,{className:`mb-1.5 flex items-baseline justify-between gap-2`,children:[(0,W.jsx)(`span`,{className:`text-caption uppercase tracking-wide text-muted`,children:e(`inflightSlots`)}),(0,W.jsxs)(`span`,{className:`mono text-[10px] tabular text-muted`,children:[k.occupiedSlots,`/`,k.workerSlots]})]}),(0,W.jsx)(`div`,{className:`flex flex-col gap-2`,"data-worker-rail":!0,children:R.map(t=>(0,W.jsx)(Ze,{slot:t,jobById:P,clockMs:x,idleLabel:e(`inflightSlotIdle`),landedCellIds:ee},t.id))})]}),(0,W.jsxs)(`div`,{className:`flex gap-2 sm:gap-2.5 lg:w-[6.75rem] lg:flex-col lg:gap-2.5`,children:[(0,W.jsx)(et,{label:e(`inflightDone`),value:D.totals.done,tone:`ok`,icon:(0,W.jsx)(i,{size:22,"aria-hidden":!0})}),(0,W.jsx)(et,{label:e(`inflightFailed`),value:D.totals.failed,tone:`danger`,icon:(0,W.jsx)(O,{size:22,"aria-hidden":!0})})]})]}),(0,W.jsxs)(`div`,{"data-depth":!0,className:`px-4 py-3`,children:[(0,W.jsxs)(`div`,{className:`mb-1 flex items-baseline justify-between gap-2`,children:[(0,W.jsx)(`span`,{className:`text-caption uppercase tracking-wide text-muted`,children:e(`inflightDepth`)}),(0,W.jsx)(`span`,{className:`mono text-caption tabular text-muted`,children:ae})]}),(0,W.jsx)(`div`,{className:`rounded-lg bg-[var(--il-item-bg)] px-1.5 pt-1.5 pb-1`,children:(0,W.jsx)(V.Suspense,{fallback:(0,W.jsx)(`div`,{className:`h-11 w-full`,"aria-hidden":!0}),children:(0,W.jsx)(Ue,{series:D.depthSeries,bands:[],backpressure:D.backpressure,label:ae})})})]})]}):null]})}function $e({label:e,value:t,suffix:n,kind:r=`int`,warn:i}){return(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`div`,{className:`text-caption uppercase tracking-wide text-muted`,children:e}),(0,W.jsxs)(`div`,{className:`mono mt-1 flex items-baseline gap-0.5 text-section font-semibold tabular ${i?`text-[var(--il-warn-fg)]`:`text-foreground`}`,children:[t==null?(0,W.jsx)(`span`,{className:`text-muted`,children:`—`}):(0,W.jsx)(Fe,{value:t,kind:r,duration:560}),n?(0,W.jsx)(`span`,{className:`text-[0.92em] opacity-80`,children:n}):null]})]})}function et({label:e,value:t,tone:n,icon:r}){let i=n===`ok`;return(0,W.jsxs)(`div`,{"data-outcome":n,role:`group`,"aria-label":`${e}: ${t}`,title:`${e}: ${t}`,className:`flex min-h-28 min-w-[3.6rem] flex-1 flex-col items-center justify-center gap-2 rounded-2xl border px-3 py-4 ${i?`border-[color-mix(in_oklab,var(--success)_14%,transparent)] bg-[var(--il-ok-bg)]`:`border-[color-mix(in_oklab,var(--danger)_12%,transparent)] bg-[var(--il-err-bg)]`}`,children:[(0,W.jsx)(`span`,{className:`inline-flex size-12 items-center justify-center rounded-2xl ${i?`bg-[color-mix(in_oklab,var(--success)_14%,var(--surface))] text-[var(--il-ok-fg)]`:`bg-[color-mix(in_oklab,var(--danger)_12%,var(--surface))] text-[var(--il-err-fg)]`}`,"aria-hidden":!0,children:r}),(0,W.jsx)(`div`,{className:`mono text-[1.7rem] font-semibold tabular leading-none tracking-tight ${i?`text-[var(--il-ok-fg)]`:`text-[var(--il-err-fg)]`}`,children:(0,W.jsx)(Fe,{value:t,kind:`int`,duration:560})}),(0,W.jsx)(`span`,{className:`text-caption font-medium ${i?`text-[color-mix(in_oklab,var(--success)_55%,var(--muted))]`:`text-[color-mix(in_oklab,var(--danger)_55%,var(--muted))]`}`,children:e})]})}function tt(){return g(`/api/live`)}var nt=2500,rt=Math.round(6e4/nt);function it(e){let t=e?.intervalMs??2500,[n,r]=(0,V.useState)(null),[i,a]=(0,V.useState)(null),[o,s]=(0,V.useState)([]);return(0,V.useEffect)(()=>{let e=!1,n=null,i=()=>{document.hidden||tt().then(n=>{if(e)return;r(n),a(null);let i=Math.max(rt,Math.round(6e4/t));s(e=>[...e,{at:Date.now(),value:n.in_flight}].slice(-i))}).catch(t=>{e||a(t instanceof Error?t.message:String(t))})},o=()=>{n||document.hidden||(i(),n=setInterval(i,t))},c=()=>{n&&clearInterval(n),n=null},l=()=>document.hidden?c():o();return o(),document.addEventListener(`visibilitychange`,l),()=>{e=!0,c(),document.removeEventListener(`visibilitychange`,l)}},[t]),{live:n,samples:o,error:i}}var at=(0,V.lazy)(()=>S(()=>import(`./TrafficChart-CJw8f4Wi.js`).then(e=>({default:e.TrafficChart})),__vite__mapDeps([11,1,12,4,13,2,3,5,6,7,8,14,9,10,15]))),ot=3e4,st=3e4,ct={window:{from:``,to:``,hours:24},totals:{requests:0,ok:0,incomplete:0,error:0,canceled:0,streaming:0,success_rate:0},latency:{},tokens:{prompt:0,completion:0,cache_read:0,total:0},status:[],errors:[],models:[],accounts:[],providers:[],series:[]};function lt(e,t){return!e||e===`(unknown)`?t(`statsUnknown`):z(e,t)}function ut(e,t,n){return!t||t===`(unassigned)`?n:e.find(e=>e.id===t)?.name||t}var dt=new Set([`quota`,`rate_limit`,`auth`,`not_ready`,`unavailable`,`invalid_request`,`model_not_available`]);function ft(e,t){let n={quota:`logsKindQuota`,rate_limit:`logsKindRateLimit`,auth:`logsKindAuth`,not_ready:`logsKindNotReady`,unavailable:`logsKindUnavailable`,invalid_request:`logsKindInvalidRequest`,model_not_available:`logsKindModelNotAvailable`};return n[e]?t(n[e]):e}var pt=[`ok`,`incomplete`,`error`,`canceled`],mt={ok:`bg-success`,incomplete:`bg-warning`,error:`bg-danger`,canceled:`bg-muted`},ht={ok:`logsFilterOk`,incomplete:`logsFilterIncomplete`,error:`logsFilterError`,canceled:`logsFilterCanceled`};function gt(e,t){return t>0?e/t:null}function _t(e,t){if(!e)return null;let n=Date.parse(e);if(!Number.isFinite(n))return null;let r=Math.max(0,Math.round((n-t)/1e3));if(r<=0)return null;let i=Math.floor(r/3600),a=Math.floor(r%3600/60),o=r%60;return i?`${i}h ${a}m`:a?`${a}m ${String(o).padStart(2,`0`)}s`:`${o}s`}function vt(e,t){let n=[e.down_until,e.cooldown_until].filter(e=>!!e).filter(e=>Date.parse(e)>t);return n.length?n.reduce((e,t)=>Date.parse(e)>=Date.parse(t)?e:t):null}function yt(e,t){return t?`danger`:(e??0)>=80?`warning`:`ok`}function bt(){let{lang:e,t}=o(),{overview:n,loading:i,error:a,refresh:d}=w(),[m,g]=(0,V.useState)(`today`),[y,b]=(0,V.useState)(null),[x,S]=(0,V.useState)(!1),ee=ne(),[T,O]=(0,V.useState)(null),[M,ie]=(0,V.useState)(``),[N,P]=(0,V.useState)(!0),[F,I]=(0,V.useState)([]),[z,le]=(0,V.useState)(!0),[ue,de]=(0,V.useState)(0),[fe,pe]=(0,V.useState)(null),[me,he]=(0,V.useState)(()=>Date.now()),[ge,_e]=(0,V.useState)(!1),[ye,be]=(0,V.useState)(!1),{live:H,samples:xe,error:Se}=it({intervalMs:ge?800:nt}),we=new Map((H?.accounts??[]).map(e=>[e.id,e])),Ee=!!n?.proxy?.ok,De=!!n?.worker?.ok,Oe=n?.worker?.ready_count??0,ke=n?.worker?.hot_count??0,Ae=H?.in_flight??n?.worker?.in_flight??0,U=T??ct,Me=(0,V.useMemo)(()=>({requests:t(`chartMetricRequests`),tokens:t(`chartMetricTokens`),latency:t(`chartMetricLatency`),input:t(`chartInput`),output:t(`chartOutput`),cacheRead:t(`chartCacheRead`),p50:t(`statsLatencyP50`),p95:t(`statsLatencyP95`),total:t(`chartTotal`)}),[t]),Ne=(0,V.useCallback)((e,t)=>ee(ce({},e,t)),[ee]),G=n?.routing?.session_affinity,Pe=(G?.hits??0)+(G?.misses??0),Ie=gt(G?.hits??0,Pe),K=F.map(e=>({account:e,until:vt(e,me)})).filter(e=>e.until!=null),Re=K.length>0,ze=new Set(K.map(e=>e.account.id)),Be=[...F.filter(e=>e.ready&&!ze.has(e.id)),...F.filter(e=>!e.ready&&!ze.has(e.id))].slice(0,6);(0,V.useEffect)(()=>{if(!Re)return;let e=setInterval(()=>he(Date.now()),1e3);return()=>clearInterval(e)},[Re]),(0,V.useEffect)(()=>{let e=!1;return Promise.allSettled([v(!1),_()]).then(([t,n])=>{e||(t.status===`fulfilled`&&I(t.value.data||[]),n.status===`fulfilled`&&de((n.value.data||[]).length))}).finally(()=>{e||le(!1)}),()=>{e=!0}},[]);let q=(0,V.useCallback)(()=>{v(!1).then(e=>I(e.data||[])).catch(()=>{})},[]),J=(0,V.useRef)(null),Ve=(0,V.useCallback)(()=>{J.current??=window.setTimeout(()=>{J.current=null,q(),d(void 0,{silent:!0}).catch(()=>{})},600)},[d,q]),{status:He}=B(Ve);(0,V.useEffect)(()=>()=>{J.current!=null&&window.clearTimeout(J.current)},[]),(0,V.useEffect)(()=>{if(He===`live`)return;let e=window.setInterval(()=>{document.hidden||(q(),d(void 0,{silent:!0}).catch(()=>{}))},5e3);return()=>window.clearInterval(e)},[He,q,d]);let Ue=y?.start?.toString()??``,Y=y?.end?.toString()??``,X=(0,V.useRef)(0),Z=(0,V.useCallback)(e=>{let t=ae(m,y);if(!t){P(!1);return}let n=++X.current;c(t).then(e=>{n===X.current&&(O(e),ie(``))}).catch(t=>{n!==X.current||e||(O(null),ie(t instanceof Error?t.message:String(t)))}).finally(()=>{n===X.current&&P(!1)})},[m,Ue,Y]);(0,V.useEffect)(()=>(Z(!1),()=>{X.current++}),[Z]),(0,V.useEffect)(()=>{if(x)return;let e=Date.now(),t=()=>{document.hidden||(e=Date.now(),Z(!0))},n=setInterval(t,ot),r=()=>{!document.hidden&&Date.now()-e>=ot&&t()};return document.addEventListener(`visibilitychange`,r),()=>{clearInterval(n),document.removeEventListener(`visibilitychange`,r)}},[x,Z]),(0,V.useEffect)(()=>{let e=!1,t=Date.now(),n=()=>{document.hidden||(t=Date.now(),re().then(t=>{e||pe(t)}).catch(()=>{}))};n();let r=setInterval(n,st),i=()=>{!document.hidden&&Date.now()-t>=st&&n()};return document.addEventListener(`visibilitychange`,i),()=>{e=!0,clearInterval(r),document.removeEventListener(`visibilitychange`,i)}},[]);let We=Math.floor(U.series.length/2),Q=(e,t)=>e.reduce((e,n)=>e+n[t],0),$=U.series.slice(0,We),Ge=U.series.slice(We),Ke=((e,t)=>e>0?(t-e)/e:null)(Q($,`requests`),Q(Ge,`requests`)),qe=Q($,`requests`)?Q($,`ok`)/Q($,`requests`):null,Je=Q(Ge,`requests`)?Q(Ge,`ok`)/Q(Ge,`requests`):null,Ye=qe!=null&&Je!=null?Je-qe:null,Xe=[{label:t(`metricRequests`),value:U.totals.requests,kind:`compact`,detail:t(`statsWindowHint`,{window:t(se[m])}),ok:U.totals.requests>0,trend:Ke},{label:t(`metricSuccess`),value:U.totals.success_rate,kind:`percent`,detail:`${U.totals.ok} ${t(`logsFilterOk`)} · ${U.totals.incomplete} ${t(`logsFilterIncomplete`)} · ${U.totals.error} ${t(`logsFilterError`)}`,ok:U.totals.requests===0||U.totals.success_rate>=.9,trend:Ye},{label:t(`metricLatency`),value:U.latency.p95_ms??U.latency.avg_ms,kind:`ms`,detail:`p50 ${h(U.latency.p50_ms)} · avg ${h(U.latency.avg_ms)}`,ok:U.latency.p95_ms==null||U.latency.p95_ms<8e3,trend:null},{label:t(`metricTokens`),value:U.tokens.total,kind:`compact`,detail:`${p(U.tokens.prompt)} / ${p(U.tokens.completion)}`,ok:!0,trend:null}],Ze=gt(U.tokens.cache_read,U.tokens.prompt),$e=gt(U.totals.streaming,U.totals.requests),et=[{label:t(`metricCacheHit`),value:Ze,kind:`percent`,detail:t(`metricCacheHitDetail`,{read:p(U.tokens.cache_read),prompt:p(U.tokens.prompt)})},{label:t(`metricStreaming`),value:$e,kind:`percent`,detail:t(`metricStreamingDetail`,{count:U.totals.streaming,total:U.totals.requests})},{label:t(`metricCanceled`),value:U.totals.canceled,kind:`int`,detail:t(`metricCanceledDetail`,{rate:f(gt(U.totals.canceled,U.totals.requests)??0)})}],tt=pt.map(e=>({key:e,count:U.status.find(t=>t.key===e)?.count??U.totals[e]??0})),rt=e=>ce(e,U.window.from,U.window.to);return i&&!n?(0,W.jsx)(j,{}):(0,W.jsxs)(`div`,{className:`space-y-5 sm:space-y-4`,children:[(0,W.jsxs)(`section`,{className:`grid gap-3 pb-1 lg:grid-cols-[minmax(0,1fr)_auto] lg:items-end`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h2`,{"data-gsap-reveal":!0,className:`text-title font-semibold`,children:t(`homeDisplay`)}),(0,W.jsx)(`p`,{className:`mt-1 max-w-2xl text-body leading-6 text-muted`,children:t(`homeLead`)})]}),(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,W.jsx)(oe,{value:m,onChange:g,custom:y,onCustomChange:b,onBusy:()=>P(!0),t}),(0,W.jsxs)(D,{delay:300,children:[(0,W.jsx)(s,{isIconOnly:!0,size:`sm`,variant:`ghost`,"aria-label":t(x?`statsRefreshResume`:`statsRefreshPause`),"aria-pressed":x,onPress:()=>S(e=>!e),children:x?(0,W.jsx)(Te,{size:14}):(0,W.jsx)(Ce,{size:14})}),(0,W.jsx)(D.Content,{children:t(x?`statsRefreshPaused`:`statsRefreshAuto`)})]}),(0,W.jsxs)(`div`,{className:`text-left sm:text-right`,children:[(0,W.jsx)(`div`,{className:`mono text-caption text-muted`,children:n?.time||`—`}),(0,W.jsxs)(`div`,{className:`mt-1 inline-flex items-center gap-2 text-body font-medium`,children:[(0,W.jsx)(`span`,{className:`status-dot`,"data-state":Ee&&De?`ok`:`danger`}),t(Ee&&De?`running`:`degraded`)]})]})]})]}),a?(0,W.jsx)(l,{title:t(`failedOverview`,{msg:a})}):null,(0,W.jsx)(Le,{live:H,samples:xe,t,onConcurrencyClick:()=>_e(!0)}),(0,W.jsx)(Qe,{t,expanded:ge,onExpandedChange:_e,live:ge?H:null,liveError:ge?Se:null}),(0,W.jsx)(`section`,{"data-gsap-reveal":!0,className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-4`,children:Xe.map(e=>(0,W.jsxs)(u,{className:`gap-0 p-3.5`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,W.jsx)(`div`,{className:`text-body text-muted`,children:e.label}),(0,W.jsx)(`span`,{className:`status-dot`,"data-state":e.ok?`ok`:`danger`})]}),(0,W.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`div`,{className:`tabular text-metric font-medium leading-none`,children:N?(0,W.jsx)(k,{className:`h-7 w-24`}):e.value==null?`—`:(0,W.jsx)(Fe,{value:e.value,kind:e.kind})}),!N&&e.trend!=null?(0,W.jsx)(wt,{value:e.trend,hint:t(`trendHalfHint`)}):null]}),(0,W.jsx)(`div`,{className:`mono mt-2 truncate text-caption text-muted`,children:N?(0,W.jsx)(k,{className:`h-3 w-28`}):e.detail})]},e.label))}),(0,W.jsx)(`section`,{className:`grid gap-3 sm:grid-cols-3`,children:et.map(e=>(0,W.jsx)(u,{className:`gap-0 p-3.5`,children:(0,W.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:gap-3`,children:[(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(`div`,{className:`text-body text-muted`,children:e.label}),(0,W.jsx)(`div`,{className:`mono mt-0.5 truncate text-caption text-muted`,children:N?(0,W.jsx)(k,{className:`h-3 w-28`}):e.detail})]}),(0,W.jsx)(`div`,{className:`tabular text-section font-semibold sm:shrink-0`,children:N?(0,W.jsx)(k,{className:`h-5 w-12`}):e.value==null?`—`:(0,W.jsx)(Fe,{value:e.value,kind:e.kind})})]})},e.label))}),(0,W.jsx)(`section`,{className:`grid gap-3`,children:(0,W.jsxs)(u,{"data-gsap-reveal":!0,className:`overflow-hidden p-0`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-separator px-4 py-3`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h3`,{className:`font-semibold`,children:t(`statsTraffic`)}),(0,W.jsx)(`p`,{className:`mt-0.5 text-caption text-muted`,children:t(`statsTrafficHint`)})]}),(0,W.jsx)(C,{size:`sm`,variant:`soft`,color:U.totals.error?`warning`:`success`,children:f(U.totals.success_rate)})]}),(0,W.jsxs)(`div`,{className:`space-y-4 p-4`,children:[M?(0,W.jsx)(`div`,{className:`text-body text-danger`,children:t(`failedStats`,{msg:M})}):N?(0,W.jsx)(E,{}):U.series.some(e=>e.requests>0)?(0,W.jsx)(V.Suspense,{fallback:(0,W.jsx)(E,{}),children:(0,W.jsx)(at,{series:U.series,lang:e,emptyLabel:t(`statsEmptyTraffic`),okLabel:t(`logsFilterOk`),errorLabel:t(`logsFilterError`),selectHint:t(`statsDragHint`),labels:Me,onSelectRange:Ne})}):(0,W.jsx)(je,{emptyLabel:t(`statsEmptyTraffic`)}),(0,W.jsx)(`div`,{className:`grid grid-cols-2 gap-x-4 gap-y-4 pt-3 sm:grid-cols-4 sm:gap-3`,children:[[t(`statsLatencyP50`),h(U.latency.p50_ms)],[t(`statsLatencyP95`),h(U.latency.p95_ms)],[t(`statsLatencyAvg`),h(U.latency.avg_ms)],[t(`statsTTFB`),h(U.latency.ttfb_avg_ms)]].map(([e,t])=>(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`div`,{className:`text-caption text-muted`,children:e}),(0,W.jsx)(`div`,{className:`mono mt-1 text-body font-medium`,children:N?(0,W.jsx)(k,{className:`h-4 w-16`}):t})]},String(e)))})]})]})}),(0,W.jsxs)(`section`,{className:`grid gap-3 xl:grid-cols-[minmax(0,1.15fr)_minmax(0,.85fr)]`,children:[(0,W.jsxs)(u,{"data-gsap-reveal":!0,className:`overflow-hidden p-0`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-separator px-4 py-3`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h3`,{className:`font-semibold`,children:t(`statsPool`)}),(0,W.jsx)(`p`,{className:`mt-0.5 text-caption text-muted`,children:t(`statsPoolHint`)})]}),(0,W.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[!z&&K.length?(0,W.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 rounded-2xl bg-surface-secondary px-2 py-0.5 text-caption text-muted transition-colors hover:text-foreground`,"aria-expanded":ye,"aria-label":t(`statsCoolingChip`,{count:K.length}),onClick:()=>be(e=>!e),children:[(0,W.jsx)(`span`,{className:`status-dot shrink-0`,"data-state":`warn`}),(0,W.jsx)(`span`,{className:`mono tabular`,children:t(`statsCoolingChip`,{count:K.length})}),(0,W.jsx)(r,{size:10,className:`transition-transform duration-200 ${ye?`rotate-90`:``}`,"aria-hidden":!0})]}):null,(0,W.jsxs)(te,{to:`/accounts`,className:`inline-flex items-center gap-1 text-caption font-medium text-muted hover:text-foreground`,children:[t(`navAccounts`),(0,W.jsx)(ve,{size:12})]})]})]}),(0,W.jsx)(`div`,{className:`grid grid-cols-2 gap-y-1 border-b border-separator sm:grid-cols-4 sm:gap-y-0`,children:[[t(`ready`),Oe,`ok`],[t(`hot`),ke,ke?`ok`:``],[t(`inFlight`),Ae,Ae?`ok`:``],[t(`statsAffinityHit`),Ie==null?`—`:f(Ie),``,G?t(`statsAffinityHint`,{hits:G.hits??0,misses:G.misses??0,bindings:G.bindings??0}):``]].map(([e,t,n,r])=>(0,W.jsxs)(`div`,{className:`px-4 py-3 sm:py-2.5`,title:r?String(r):void 0,children:[(0,W.jsx)(`div`,{className:`text-caption text-muted`,children:e}),(0,W.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-2 sm:mt-1`,children:[(0,W.jsx)(`span`,{className:`mono text-section font-semibold`,children:t}),n?(0,W.jsx)(`span`,{className:`status-dot`,"data-state":n}):null]})]},String(e)))}),ye&&K.length?(0,W.jsxs)(`div`,{className:`border-b border-separator bg-surface-secondary/50 px-4 py-2`,children:[(0,W.jsx)(`div`,{className:`text-caption text-muted`,children:t(`statsCoolingDetails`)}),(0,W.jsx)(`div`,{className:`mt-1.5 space-y-1`,children:K.map(({account:e,until:n})=>(0,W.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-caption`,children:[(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-foreground/80`,children:e.name||e.id}),(0,W.jsx)(`span`,{className:`mono shrink-0 text-muted`,children:e.last_error_kind?ft(e.last_error_kind,t):t(`statsUnknown`)}),(0,W.jsx)(`span`,{className:`mono shrink-0 tabular text-muted sm:w-16 sm:text-right`,children:_t(n,me)??`—`}),(0,W.jsx)(`span`,{className:`mono hidden shrink-0 text-muted sm:inline sm:w-10 sm:text-right`,title:t(`statsBackoffLevel`),children:e.restart_backoff_level?`L${e.restart_backoff_level}`:`—`})]},e.id))})]}):null,(0,W.jsx)(`div`,{className:`divide-y divide-separator`,children:z?(0,W.jsx)(A,{}):F.length===0?(0,W.jsx)(`div`,{className:`px-4 py-6 text-body text-muted`,children:t(`noAccounts`)}):Be.length===0?(0,W.jsx)(`div`,{className:`px-4 py-6 text-body text-muted`,children:t(`statsPoolReadyEmpty`)}):Be.map(e=>{let n=e.quota,r=yt(n?.percentage,n?.exceeded),i=we.get(e.id),a=i?.in_flight??e.in_flight??e.inFlight??0,o=i?.max_inflight||e.max_inflight||4,s=a>=o;return(0,W.jsxs)(`div`,{className:`flex flex-col gap-2.5 px-4 py-3 sm:flex-row sm:items-center sm:gap-3 sm:py-2.5`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-3 sm:items-center`,children:[(0,W.jsx)(`span`,{className:`status-dot mt-1.5 shrink-0 sm:mt-0`,"data-state":e.ready?`ok`:`danger`}),(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,W.jsx)(L,{provider:e.provider,size:14}),(0,W.jsx)(`div`,{className:`truncate text-body font-medium`,children:e.name||e.id})]}),(0,W.jsxs)(`div`,{className:`mono mt-0.5 text-caption text-muted`,children:[R(e.provider,e.region,t),` · `,e.hot?t(`hot`):e.ready?t(`ready`):t(`degraded`)]})]})]}),(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2 pl-6 sm:shrink-0 sm:pl-0`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-1.5`,title:t(s?`liveSaturated`:`inFlight`),"data-testid":`account-inflight`,children:[(0,W.jsx)(`span`,{className:`text-caption text-muted sm:hidden`,children:t(`inFlight`)}),(0,W.jsxs)(`span`,{className:`mono text-caption tabular ${s?`text-warning`:`text-muted`}`,children:[a,`/`,o]}),(0,W.jsx)(`span`,{className:`inline-block h-[2px] w-10 overflow-hidden rounded-[1px] bg-separator`,children:(0,W.jsx)(`span`,{className:`block h-full ${s?`bg-warning`:`bg-foreground/50`}`,style:{width:`${Math.min(100,a/o*100)}%`}})})]}),n?(0,W.jsxs)(`div`,{className:`flex items-center gap-1.5`,title:t(`quota`),children:[(0,W.jsx)(`span`,{className:`text-caption text-muted sm:hidden`,children:t(`quota`)}),(0,W.jsxs)(`span`,{className:`mono text-caption tabular text-muted`,children:[Math.round(n.percentage??0),`%`]}),(0,W.jsx)(`span`,{className:`inline-block h-[2px] w-10 overflow-hidden rounded-[1px] bg-separator`,children:(0,W.jsx)(`span`,{className:`block h-full ${r===`danger`?`bg-danger`:r===`warning`?`bg-warning`:`bg-success`}`,style:{width:`${Math.min(100,Math.max(0,n.percentage??0))}%`}})})]}):null]})]},e.id)})}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between border-t border-separator px-4 py-2.5 text-caption text-muted`,children:[(0,W.jsxs)(`span`,{children:[t(`metricModels`),` `,ue]}),(0,W.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-center justify-end gap-x-2 gap-y-1`,children:[[`qoder`,`workbuddy`,`trae`].map(e=>{let t=F.filter(t=>String(t.provider||`qoder`).toLowerCase()===e).length;return t?(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,W.jsx)(L,{provider:e,size:11}),t]},e):null}),(0,W.jsxs)(`span`,{children:[F.length,` `,t(`accountCount`)]})]})]})]}),(0,W.jsx)(St,{resources:fe,t})]}),(0,W.jsxs)(`section`,{className:`grid gap-3 xl:grid-cols-2 2xl:grid-cols-3`,children:[(0,W.jsxs)(u,{"data-gsap-reveal":!0,className:`overflow-hidden p-0`,children:[(0,W.jsx)(`div`,{className:`flex items-center justify-between gap-3 border-b border-separator px-4 py-3`,children:(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h3`,{className:`font-semibold`,children:t(`statsTopProviders`)}),(0,W.jsx)(`p`,{className:`mt-0.5 text-caption text-muted`,children:t(`statsTopProvidersHint`)})]})}),N?(0,W.jsx)(A,{}):(0,W.jsx)(Ct,{empty:t(`statsNoProviders`),items:(U.providers||[]).map(e=>({key:e.key,label:lt(e.key,t),count:e.count,meta:`${e.ok}/${e.count}`,mark:e.key===`(unknown)`?void 0:e.key,href:e.key===`(unknown)`?void 0:rt({provider:e.key})}))})]}),(0,W.jsxs)(u,{"data-gsap-reveal":!0,className:`overflow-hidden p-0`,children:[(0,W.jsx)(`div`,{className:`flex items-center justify-between gap-3 border-b border-separator px-4 py-3`,children:(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h3`,{className:`font-semibold`,children:t(`statsTopModels`)}),(0,W.jsx)(`p`,{className:`mt-0.5 text-caption text-muted`,children:t(`providerCatalog`)})]})}),N?(0,W.jsx)(A,{rows:4}):(0,W.jsx)(Ct,{empty:t(`statsNoModels`),items:U.models.map(e=>({key:e.key,label:e.key===`(unknown)`?t(`statsUnknown`):e.key,count:e.count,href:e.key===`(unknown)`?void 0:rt({model:e.key}),meta:e.latency_avg_ms==null?`${e.ok}/${e.count}`:h(e.latency_avg_ms)}))})]}),(0,W.jsxs)(u,{"data-gsap-reveal":!0,className:`overflow-hidden p-0`,children:[(0,W.jsx)(`div`,{className:`flex items-center justify-between gap-3 border-b border-separator px-4 py-3`,children:(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h3`,{className:`font-semibold`,children:t(`statsStatusMix`)}),(0,W.jsx)(`p`,{className:`mt-0.5 text-caption text-muted`,children:t(`statsStatusMixHint`)})]})}),N?(0,W.jsx)(A,{rows:4}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Tt,{items:tt,t}),(0,W.jsx)(`div`,{className:`border-t border-separator px-4 pt-2.5 text-caption font-medium text-muted`,children:t(`statsErrorMix`)}),(0,W.jsx)(Ct,{empty:t(`statsNoErrors`),danger:!0,items:U.errors.map(e=>({key:e.key,label:ft(e.key,t),count:e.count,href:dt.has(e.key)?rt({error_kind:e.key}):void 0}))}),(0,W.jsx)(`div`,{className:`border-t border-separator px-4 pt-2.5 text-caption font-medium text-muted`,children:t(`statsTopAccounts`)}),(0,W.jsx)(Ct,{empty:t(`statsNoAccounts`),items:U.accounts.slice(0,5).map(e=>({key:e.key,label:ut(F,e.key,t(`statsUnassigned`)),count:e.count,href:!e.key||e.key===`(unassigned)`?void 0:rt({account:e.key}),meta:`${e.ok}/${e.count}`}))})]})]})]})]})}function xt(e,t){return e>=2147483648||t>=200?`danger`:e>=1073741824||t>=100?`warning`:`ok`}function St({resources:e,t}){let n=[...e?.workers??[]].sort((e,t)=>t.rss_bytes-e.rss_bytes),r=e?.server;return(0,W.jsxs)(u,{"data-gsap-reveal":!0,className:`overflow-hidden p-0`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-separator px-4 py-3`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h3`,{className:`font-semibold`,children:t(`resTitle`)}),(0,W.jsx)(`p`,{className:`mt-0.5 text-caption text-muted`,children:t(`resHint`)})]}),(0,W.jsx)(C,{size:`sm`,variant:`soft`,color:e?`success`:`default`,children:e?m(e.total_rss_bytes):`—`})]}),(0,W.jsx)(`div`,{className:`divide-y divide-separator`,children:e?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{className:`px-4 py-2.5`,children:(0,W.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`status-dot shrink-0`,"data-state":xt(r?.rss_bytes??0,r?.cpu_percent??0)}),(0,W.jsx)(`div`,{className:`truncate text-body font-medium`,children:t(`resServer`)}),(0,W.jsxs)(`span`,{className:`mono text-caption text-muted`,children:[`pid `,r?.pid]})]}),(0,W.jsxs)(`div`,{className:`mono shrink-0 text-caption text-muted`,children:[m(r?.rss_bytes),` · `,(r?.cpu_percent??0).toFixed(1),`%`]})]})}),n.length===0?(0,W.jsx)(`div`,{className:`px-4 py-3 text-body text-muted`,children:t(`resEmpty`)}):n.map(e=>(0,W.jsx)(`div`,{className:`px-4 py-2.5`,children:(0,W.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`status-dot shrink-0`,"data-state":xt(e.rss_bytes,e.cpu_percent)}),(0,W.jsx)(`div`,{className:`truncate text-body font-medium`,children:e.label||e.account_id}),(0,W.jsxs)(`span`,{className:`mono text-caption text-muted`,children:[`pid `,e.pid]})]}),(0,W.jsxs)(`div`,{className:`mono shrink-0 text-caption text-muted`,children:[m(e.rss_bytes),` · `,e.cpu_percent.toFixed(1),`%`]})]})},e.pid))]}):(0,W.jsx)(A,{rows:3})}),(0,W.jsxs)(`div`,{className:`flex items-center justify-between border-t border-separator px-4 py-2.5 text-caption text-muted`,children:[(0,W.jsxs)(`span`,{className:`mono`,children:[r?.goroutines??0,` `,t(`resGoroutines`)]}),(0,W.jsx)(`span`,{className:`mono`,children:e?.sampled_at?new Date(e.sampled_at).toLocaleTimeString():`—`})]})]})}function Ct({items:e,empty:t,danger:n}){let r=(0,V.useRef)(null),i=Math.max(1,...e.map(e=>e.count)),a=e.map(e=>`${e.key}:${e.count}`).join(`|`);return(0,V.useLayoutEffect)(()=>{let e=r.current;if(!e)return;let t=b.context(()=>{let e=b.matchMedia();e.add(`(prefers-reduced-motion: reduce)`,()=>{b.set(`[data-rank-fill]`,{clearProps:`transform`})}),e.add(`(prefers-reduced-motion: no-preference)`,()=>{let e=b.utils.toArray(`[data-rank-fill]`);e.length&&b.fromTo(e,{scaleX:0},{scaleX:1,duration:.38,ease:`power2.out`,stagger:.05,transformOrigin:`0% 50%`})})},e);return()=>t.revert()},[a]),e.length?(0,W.jsx)(`div`,{ref:r,className:`divide-y divide-separator`,children:e.map(e=>{let t=(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[e.mark?(0,W.jsx)(L,{provider:e.mark,size:14}):null,(0,W.jsx)(`div`,{className:`truncate text-body font-medium`,children:e.label})]}),(0,W.jsx)(`div`,{className:`mono shrink-0 text-caption text-muted`,children:e.meta?`${e.count} · ${e.meta}`:e.count})]}),(0,W.jsx)(`div`,{className:`mt-2 h-1 overflow-hidden rounded-[2px] bg-separator`,children:(0,W.jsx)(`div`,{"data-rank-fill":!0,className:`h-full origin-left rounded-[2px] ${n?`bg-danger`:`bg-success`}`,style:{width:`${Math.max(6,e.count/i*100)}%`}})})]});return e.href?(0,W.jsx)(te,{to:e.href,className:`rank-row block px-4 py-2.5`,title:e.label,children:t},e.key):(0,W.jsx)(`div`,{className:`px-4 py-2.5`,children:t},e.key)})}):(0,W.jsx)(`div`,{className:`px-4 py-6 text-body text-muted`,children:t})}function wt({value:e,hint:t}){let n=Math.abs(e)<.005?`flat`:e>0?`up`:`down`;return(0,W.jsxs)(`span`,{className:`trend-chip`,"data-tone":n,title:t,children:[(0,W.jsx)(n===`down`?De:n===`up`?ke:be,{size:12,weight:`bold`}),e>0?`+`:``,(e*100).toFixed(1),`%`]})}function Tt({items:e,t}){let n=e.reduce((e,t)=>e+t.count,0);return n?(0,W.jsxs)(`div`,{className:`px-4 py-3`,children:[(0,W.jsx)(`div`,{className:`flex h-2 gap-px overflow-hidden rounded-[3px] bg-separator`,role:`img`,"aria-label":e.map(e=>`${t(ht[e.key])} ${e.count}`).join(`, `),children:e.filter(e=>e.count>0).map(e=>(0,W.jsx)(`div`,{className:mt[e.key],style:{width:`${e.count/n*100}%`,minWidth:2}},e.key))}),(0,W.jsx)(`div`,{className:`mt-3 grid grid-cols-2 gap-x-4 gap-y-1.5`,children:e.map(e=>(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-caption`,children:[(0,W.jsx)(`span`,{className:`inline-block size-2 shrink-0 rounded-[2px] ${mt[e.key]}`}),(0,W.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-muted`,children:t(ht[e.key])}),(0,W.jsx)(`span`,{className:`mono tabular`,children:e.count}),(0,W.jsx)(`span`,{className:`mono w-10 text-right tabular text-muted`,children:f(e.count/n)})]},e.key))})]}):(0,W.jsx)(`div`,{className:`px-4 py-3 text-body text-muted`,children:t(`statsEmptyTraffic`)})}export{bt as OverviewPage,je as t}; \ No newline at end of file diff --git a/internal/webui/static/assets/PageAlert-CaDjxveS.js b/internal/webui/static/assets/PageAlert-DZC7IhXp.js similarity index 58% rename from internal/webui/static/assets/PageAlert-CaDjxveS.js rename to internal/webui/static/assets/PageAlert-DZC7IhXp.js index fc333886..ece86f79 100644 --- a/internal/webui/static/assets/PageAlert-CaDjxveS.js +++ b/internal/webui/static/assets/PageAlert-DZC7IhXp.js @@ -1 +1 @@ -import{a as e,c as t,n}from"./shim-mfK0Rmj6.js";import{I as r,J as i,R as a,Y as o,q as s}from"./useI18n-BSw4X3mq.js";import{B as c,s as l,z as u}from"./SharedElementTransition-BlCsXfb1.js";var d=u({defaultVariants:{status:`default`},slots:{base:`alert`,content:`alert__content`,description:`alert__description`,indicator:`alert__indicator`,title:`alert__title`},variants:{status:{accent:{base:`alert--accent`},danger:{base:`alert--danger`},default:{base:`alert--default`},success:{base:`alert--success`},warning:{base:`alert--warning`}}}}),f=t(e(),1),p=n(),m=(0,f.createContext)({}),h=({children:e,className:t,status:n,...i})=>{let a=f.useMemo(()=>d({status:n}),[n]);return(0,p.jsx)(m,{value:{slots:a,status:n},children:(0,p.jsx)(r,{value:{variant:`default`},children:(0,p.jsx)(c.div,{className:a?.base({className:t}),"data-slot":`alert-root`,...i,children:e})})})},g=Object.assign(h,{Root:h,Indicator:({children:e,className:t,...n})=>{let{slots:r,status:u}=(0,f.use)(m),d=()=>{switch(u){case`accent`:return(0,p.jsx)(s,{"data-slot":`alert-default-icon`});case`success`:return(0,p.jsx)(i,{"data-slot":`alert-default-icon`});case`warning`:return(0,p.jsx)(o,{"data-slot":`alert-default-icon`});case`danger`:return(0,p.jsx)(a,{"data-slot":`alert-default-icon`});default:return(0,p.jsx)(s,{"data-slot":`alert-default-icon`})}};return(0,p.jsx)(c.div,{className:l(r?.indicator,t),"data-slot":`alert-indicator`,...n,children:e??d()})},Content:({children:e,className:t,...n})=>{let{slots:r}=(0,f.use)(m);return(0,p.jsx)(c.div,{className:l(r?.content,t),"data-slot":`alert-content`,...n,children:e})},Title:({children:e,className:t,...n})=>{let{slots:r}=(0,f.use)(m);return(0,p.jsx)(c.p,{className:l(r?.title,t),"data-slot":`alert-title`,...n,children:e})},Description:({children:e,className:t,...n})=>{let{slots:r}=(0,f.use)(m);return(0,p.jsx)(c.span,{className:l(r?.description,t),"data-slot":`alert-description`,...n,children:e})}});function _({status:e=`danger`,title:t,description:n}){return(0,p.jsxs)(g,{status:e,children:[(0,p.jsx)(g.Indicator,{}),(0,p.jsxs)(g.Content,{children:[(0,p.jsx)(g.Title,{children:t}),n?(0,p.jsx)(g.Description,{children:n}):null]})]})}export{g as n,_ as t}; \ No newline at end of file +import{a as e,c as t,n}from"./shim-mfK0Rmj6.js";import{G as r,I as i,K as a,P as o,q as s}from"./useI18n-BBOAnu2u.js";import{B as c,s as l,z as u}from"./SharedElementTransition-BlCsXfb1.js";var d=u({defaultVariants:{status:`default`},slots:{base:`alert`,content:`alert__content`,description:`alert__description`,indicator:`alert__indicator`,title:`alert__title`},variants:{status:{accent:{base:`alert--accent`},danger:{base:`alert--danger`},default:{base:`alert--default`},success:{base:`alert--success`},warning:{base:`alert--warning`}}}}),f=t(e(),1),p=n(),m=(0,f.createContext)({}),h=({children:e,className:t,status:n,...r})=>{let i=f.useMemo(()=>d({status:n}),[n]);return(0,p.jsx)(m,{value:{slots:i,status:n},children:(0,p.jsx)(o,{value:{variant:`default`},children:(0,p.jsx)(c.div,{className:i?.base({className:t}),"data-slot":`alert-root`,...r,children:e})})})},g=Object.assign(h,{Root:h,Indicator:({children:e,className:t,...n})=>{let{slots:o,status:u}=(0,f.use)(m),d=()=>{switch(u){case`accent`:return(0,p.jsx)(r,{"data-slot":`alert-default-icon`});case`success`:return(0,p.jsx)(a,{"data-slot":`alert-default-icon`});case`warning`:return(0,p.jsx)(s,{"data-slot":`alert-default-icon`});case`danger`:return(0,p.jsx)(i,{"data-slot":`alert-default-icon`});default:return(0,p.jsx)(r,{"data-slot":`alert-default-icon`})}};return(0,p.jsx)(c.div,{className:l(o?.indicator,t),"data-slot":`alert-indicator`,...n,children:e??d()})},Content:({children:e,className:t,...n})=>{let{slots:r}=(0,f.use)(m);return(0,p.jsx)(c.div,{className:l(r?.content,t),"data-slot":`alert-content`,...n,children:e})},Title:({children:e,className:t,...n})=>{let{slots:r}=(0,f.use)(m);return(0,p.jsx)(c.p,{className:l(r?.title,t),"data-slot":`alert-title`,...n,children:e})},Description:({children:e,className:t,...n})=>{let{slots:r}=(0,f.use)(m);return(0,p.jsx)(c.span,{className:l(r?.description,t),"data-slot":`alert-description`,...n,children:e})}});function _({status:e=`danger`,title:t,description:n}){return(0,p.jsxs)(g,{status:e,children:[(0,p.jsx)(g.Indicator,{}),(0,p.jsxs)(g.Content,{children:[(0,p.jsx)(g.Title,{children:t}),n?(0,p.jsx)(g.Description,{children:n}):null]})]})}export{g as n,_ as t}; \ No newline at end of file diff --git a/internal/webui/static/assets/Plus.es-W6ztpkEI.js b/internal/webui/static/assets/Plus.es-CSLpU0CT.js similarity index 91% rename from internal/webui/static/assets/Plus.es-W6ztpkEI.js rename to internal/webui/static/assets/Plus.es-CSLpU0CT.js index 3d80f9a0..722b3a15 100644 --- a/internal/webui/static/assets/Plus.es-W6ztpkEI.js +++ b/internal/webui/static/assets/Plus.es-CSLpU0CT.js @@ -1 +1 @@ -import{a as e,c as t}from"./shim-mfK0Rmj6.js";import{pt as n}from"./useI18n-BSw4X3mq.js";var r=t(e(),1),i=new Map([[`bold`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M228,128a12,12,0,0,1-12,12H140v76a12,12,0,0,1-24,0V140H40a12,12,0,0,1,0-24h76V40a12,12,0,0,1,24,0v76h76A12,12,0,0,1,228,128Z`}))],[`duotone`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M216,56V200a16,16,0,0,1-16,16H56a16,16,0,0,1-16-16V56A16,16,0,0,1,56,40H200A16,16,0,0,1,216,56Z`,opacity:`0.2`}),r.createElement(`path`,{d:`M224,128a8,8,0,0,1-8,8H136v80a8,8,0,0,1-16,0V136H40a8,8,0,0,1,0-16h80V40a8,8,0,0,1,16,0v80h80A8,8,0,0,1,224,128Z`}))],[`fill`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM184,136H136v48a8,8,0,0,1-16,0V136H72a8,8,0,0,1,0-16h48V72a8,8,0,0,1,16,0v48h48a8,8,0,0,1,0,16Z`}))],[`light`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M222,128a6,6,0,0,1-6,6H134v82a6,6,0,0,1-12,0V134H40a6,6,0,0,1,0-12h82V40a6,6,0,0,1,12,0v82h82A6,6,0,0,1,222,128Z`}))],[`regular`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M224,128a8,8,0,0,1-8,8H136v80a8,8,0,0,1-16,0V136H40a8,8,0,0,1,0-16h80V40a8,8,0,0,1,16,0v80h80A8,8,0,0,1,224,128Z`}))],[`thin`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M220,128a4,4,0,0,1-4,4H132v84a4,4,0,0,1-8,0V132H40a4,4,0,0,1,0-8h84V40a4,4,0,0,1,8,0v84h84A4,4,0,0,1,220,128Z`}))]]),a=r.forwardRef((e,t)=>r.createElement(n,{ref:t,...e,weights:i}));a.displayName=`PlusIcon`;var o=a;export{o as t}; \ No newline at end of file +import{a as e,c as t}from"./shim-mfK0Rmj6.js";import{dt as n}from"./useI18n-BBOAnu2u.js";var r=t(e(),1),i=new Map([[`bold`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M228,128a12,12,0,0,1-12,12H140v76a12,12,0,0,1-24,0V140H40a12,12,0,0,1,0-24h76V40a12,12,0,0,1,24,0v76h76A12,12,0,0,1,228,128Z`}))],[`duotone`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M216,56V200a16,16,0,0,1-16,16H56a16,16,0,0,1-16-16V56A16,16,0,0,1,56,40H200A16,16,0,0,1,216,56Z`,opacity:`0.2`}),r.createElement(`path`,{d:`M224,128a8,8,0,0,1-8,8H136v80a8,8,0,0,1-16,0V136H40a8,8,0,0,1,0-16h80V40a8,8,0,0,1,16,0v80h80A8,8,0,0,1,224,128Z`}))],[`fill`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32ZM184,136H136v48a8,8,0,0,1-16,0V136H72a8,8,0,0,1,0-16h48V72a8,8,0,0,1,16,0v48h48a8,8,0,0,1,0,16Z`}))],[`light`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M222,128a6,6,0,0,1-6,6H134v82a6,6,0,0,1-12,0V134H40a6,6,0,0,1,0-12h82V40a6,6,0,0,1,12,0v82h82A6,6,0,0,1,222,128Z`}))],[`regular`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M224,128a8,8,0,0,1-8,8H136v80a8,8,0,0,1-16,0V136H40a8,8,0,0,1,0-16h80V40a8,8,0,0,1,16,0v80h80A8,8,0,0,1,224,128Z`}))],[`thin`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M220,128a4,4,0,0,1-4,4H132v84a4,4,0,0,1-8,0V132H40a4,4,0,0,1,0-8h84V40a4,4,0,0,1,8,0v84h84A4,4,0,0,1,220,128Z`}))]]),a=r.forwardRef((e,t)=>r.createElement(n,{ref:t,...e,weights:i}));a.displayName=`PlusIcon`;var o=a;export{o as t}; \ No newline at end of file diff --git a/internal/webui/static/assets/ProvidersPage-CNL-F1kI.js b/internal/webui/static/assets/ProvidersPage-CNL-F1kI.js new file mode 100644 index 00000000..e5d653fa --- /dev/null +++ b/internal/webui/static/assets/ProvidersPage-CNL-F1kI.js @@ -0,0 +1 @@ +import{a as e,c as t,n}from"./shim-mfK0Rmj6.js";import{t as r}from"./CaretRight.es-DGKxUxz5.js";import{i,r as a,t as o}from"./SearchBar-DXjI_cjB.js";import{dt as s,n as c,r as l}from"./useI18n-BBOAnu2u.js";import{n as u,t as d}from"./PageAlert-DZC7IhXp.js";import{t as f}from"./card-QlCdtlk0.js";import{n as p,r as m,t as h}from"./number-field-nGZCb975.js";import{t as ee}from"./EmptyPanel-Bs-jQMvG.js";import{n as g,r as _,t as v}from"./FormRow-Bhp_wPvH.js";import{t as y}from"./modal-DHeFzFnN.js";import{t as b}from"./search-field-Daz5dML3.js";import{t as x}from"./table-D-oKYYsp.js";import{d as S,f as C}from"./format-kRpr2wxA.js";import{A as w,C as te,O as ne,S as re,g as ie,m as ae,n as T,u as oe}from"./overview-CJvUvgoD.js";import{r as E}from"./gsap-C3sDxib7.js";import{Kt as se,Lt as ce,M as D,O as le,Vt as ue,b as O,d as de,f as fe,k,kt as pe,v as A,y as j,zt as me}from"./index-B9eWF6SH.js";import{t as he}from"./ProviderMark-IiAZTaQS.js";import{n as M,r as N}from"./provider-gHnttGKq.js";import{t as ge}from"./FilterSelect-GGHAJGuF.js";var P=t(e(),1),F=new Map([[`bold`,P.createElement(P.Fragment,null,P.createElement(`path`,{d:`M79.51,144.49a12,12,0,1,1,17-17L112,143l47.51-47.52a12,12,0,0,1,17,17l-56,56a12,12,0,0,1-17,0ZM228,48V208a20,20,0,0,1-20,20H48a20,20,0,0,1-20-20V48A20,20,0,0,1,48,28H208A20,20,0,0,1,228,48Zm-24,4H52V204H204Z`}))],[`duotone`,P.createElement(P.Fragment,null,P.createElement(`path`,{d:`M216,48V208a8,8,0,0,1-8,8H48a8,8,0,0,1-8-8V48a8,8,0,0,1,8-8H208A8,8,0,0,1,216,48Z`,opacity:`0.2`}),P.createElement(`path`,{d:`M173.66,98.34a8,8,0,0,1,0,11.32l-56,56a8,8,0,0,1-11.32,0l-24-24a8,8,0,0,1,11.32-11.32L112,148.69l50.34-50.35A8,8,0,0,1,173.66,98.34ZM224,48V208a16,16,0,0,1-16,16H48a16,16,0,0,1-16-16V48A16,16,0,0,1,48,32H208A16,16,0,0,1,224,48ZM208,208V48H48V208H208Z`}))],[`fill`,P.createElement(P.Fragment,null,P.createElement(`path`,{d:`M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32Zm-34.34,77.66-56,56a8,8,0,0,1-11.32,0l-24-24a8,8,0,0,1,11.32-11.32L112,148.69l50.34-50.35a8,8,0,0,1,11.32,11.32Z`}))],[`light`,P.createElement(P.Fragment,null,P.createElement(`path`,{d:`M172.24,99.76a6,6,0,0,1,0,8.48l-56,56a6,6,0,0,1-8.48,0l-24-24a6,6,0,0,1,8.48-8.48L112,151.51l51.76-51.75A6,6,0,0,1,172.24,99.76ZM222,48V208a14,14,0,0,1-14,14H48a14,14,0,0,1-14-14V48A14,14,0,0,1,48,34H208A14,14,0,0,1,222,48Zm-12,0a2,2,0,0,0-2-2H48a2,2,0,0,0-2,2V208a2,2,0,0,0,2,2H208a2,2,0,0,0,2-2Z`}))],[`regular`,P.createElement(P.Fragment,null,P.createElement(`path`,{d:`M173.66,98.34a8,8,0,0,1,0,11.32l-56,56a8,8,0,0,1-11.32,0l-24-24a8,8,0,0,1,11.32-11.32L112,148.69l50.34-50.35A8,8,0,0,1,173.66,98.34ZM224,48V208a16,16,0,0,1-16,16H48a16,16,0,0,1-16-16V48A16,16,0,0,1,48,32H208A16,16,0,0,1,224,48ZM208,208V48H48V208H208Z`}))],[`thin`,P.createElement(P.Fragment,null,P.createElement(`path`,{d:`M170.83,101.17a4,4,0,0,1,0,5.66l-56,56a4,4,0,0,1-5.66,0l-24-24a4,4,0,0,1,5.66-5.66L112,154.34l53.17-53.17A4,4,0,0,1,170.83,101.17ZM220,48V208a12,12,0,0,1-12,12H48a12,12,0,0,1-12-12V48A12,12,0,0,1,48,36H208A12,12,0,0,1,220,48Zm-8,0a4,4,0,0,0-4-4H48a4,4,0,0,0-4,4V208a4,4,0,0,0,4,4H208a4,4,0,0,0,4-4Z`}))]]),I=new Map([[`bold`,P.createElement(P.Fragment,null,P.createElement(`path`,{d:`M208,28H48A20,20,0,0,0,28,48V208a20,20,0,0,0,20,20H208a20,20,0,0,0,20-20V48A20,20,0,0,0,208,28Zm-4,176H52V52H204Z`}))],[`duotone`,P.createElement(P.Fragment,null,P.createElement(`path`,{d:`M216,48V208a8,8,0,0,1-8,8H48a8,8,0,0,1-8-8V48a8,8,0,0,1,8-8H208A8,8,0,0,1,216,48Z`,opacity:`0.2`}),P.createElement(`path`,{d:`M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32Zm0,176H48V48H208V208Z`}))],[`fill`,P.createElement(P.Fragment,null,P.createElement(`path`,{d:`M224,48V208a16,16,0,0,1-16,16H48a16,16,0,0,1-16-16V48A16,16,0,0,1,48,32H208A16,16,0,0,1,224,48Z`}))],[`light`,P.createElement(P.Fragment,null,P.createElement(`path`,{d:`M208,34H48A14,14,0,0,0,34,48V208a14,14,0,0,0,14,14H208a14,14,0,0,0,14-14V48A14,14,0,0,0,208,34Zm2,174a2,2,0,0,1-2,2H48a2,2,0,0,1-2-2V48a2,2,0,0,1,2-2H208a2,2,0,0,1,2,2Z`}))],[`regular`,P.createElement(P.Fragment,null,P.createElement(`path`,{d:`M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32Zm0,176H48V48H208V208Z`}))],[`thin`,P.createElement(P.Fragment,null,P.createElement(`path`,{d:`M208,36H48A12,12,0,0,0,36,48V208a12,12,0,0,0,12,12H208a12,12,0,0,0,12-12V48A12,12,0,0,0,208,36Zm4,172a4,4,0,0,1-4,4H48a4,4,0,0,1-4-4V48a4,4,0,0,1,4-4H208a4,4,0,0,1,4,4Z`}))]]),L=P.forwardRef((e,t)=>P.createElement(s,{ref:t,...e,weights:F}));L.displayName=`CheckSquareIcon`;var R=L,z=P.forwardRef((e,t)=>P.createElement(s,{ref:t,...e,weights:I}));z.displayName=`SquareIcon`;var _e=z;function ve(e){let[t,n]=(0,P.useState)(e);e&&!t&&n(!0);let r=(0,P.useRef)(null),i=(0,P.useRef)(null),a=(0,P.useRef)(e);return(0,P.useLayoutEffect)(()=>{let t=r.current,o=i.current;if(!t||!o)return;if(a.current){a.current=!1;return}E.killTweensOf([t,o]);let s=t.getBoundingClientRect().height;if(e){E.set(t,{overflow:`hidden`});let e=t.scrollHeight;E.fromTo(t,{height:s===e?0:s},{height:e,duration:O(A.base),ease:j.out,onComplete:()=>E.set(t,{clearProps:`height,overflow`})}),E.fromTo(o,{autoAlpha:0,y:-6},{autoAlpha:1,y:0,duration:O(A.base),ease:j.out})}else E.set(t,{overflow:`hidden`,height:s}),E.to(o,{autoAlpha:0,y:-4,duration:O(A.fast),ease:j.inOut}),E.to(t,{height:0,duration:O(A.fast+.04),ease:j.inOut,onComplete:()=>n(!1)});return()=>{E.killTweensOf([t,o])}},[e,t]),{mounted:t,outerRef:r,innerRef:i}}function ye(){return w(`/api/provider-settings`)}function be(e){return w(`/api/provider-settings`,{method:`PATCH`,body:JSON.stringify(e)})}function B(e,t){let n=new URLSearchParams({provider:e,region:t});return w(`/api/provider-settings/catalog?${n.toString()}`)}var V=n();function H(e){return e?e>=1e6?`${(e/1e6).toString().replace(/\.0$/,``)}M`:e>=1e3?`${Math.round(e/1e3)}k`:String(e):`—`}function U({label:e,value:t}){return(0,V.jsxs)(`div`,{className:`flex items-start justify-between gap-4 py-1.5`,children:[(0,V.jsx)(`span`,{className:`text-caption text-muted`,children:e}),(0,V.jsx)(`span`,{className:`min-w-0 text-right text-caption font-medium`,children:t})]})}function xe({model:e,t,onClose:n}){if(!e)return null;let r=e.reasoning_options||[],i=e.catalog_context_length||e.default_context_length||e.context_length,a=e.catalog_context_length_max,o=C(e),s=String(e.provider||e.owned_by||`qoder`).trim().toLowerCase(),c=String(e.region||e.regions?.[0]||``).trim().toLowerCase(),l=M(s,c||void 0,t),u=s===`trae`?N(e):void 0,d=e.supports_images===!0?t(`imageInputDeclared`):e.supports_images===!1?t(`imageInputUnsupported`):t(`imageInputNotDeclared`),f=u?.prompt_max_tokens||e.prompt_max_tokens,p=u?.max_output_tokens||e.max_output_tokens;return(0,V.jsx)(y.Root,{isOpen:!0,onOpenChange:e=>{e||n()},children:(0,V.jsx)(y.Backdrop,{variant:`blur`,children:(0,V.jsx)(y.Container,{size:`md`,scroll:`inside`,children:(0,V.jsxs)(y.Dialog,{children:[(0,V.jsxs)(y.Header,{className:`items-start justify-between gap-4 px-5 pt-5`,children:[(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,V.jsx)(`div`,{className:`truncate text-section`,children:e.display_name||e.id}),o?(0,V.jsx)(D,{size:`sm`,variant:`soft`,color:`success`,children:t(`modelFree`)}):null]}),(0,V.jsx)(`div`,{className:`mono mt-1 truncate text-caption text-muted`,children:e.id})]}),(0,V.jsx)(y.CloseTrigger,{"aria-label":t(`close`),className:`grid size-8 shrink-0 place-items-center rounded-lg text-muted hover:bg-surface-secondary`,children:(0,V.jsx)(pe,{size:16})})]}),(0,V.jsxs)(y.Body,{className:`space-y-3 px-5 pb-5`,children:[(0,V.jsxs)(`section`,{className:`divide-y divide-separator rounded-lg border border-separator px-3 py-1`,children:[(0,V.jsx)(U,{label:t(`providerCol`),value:l}),(0,V.jsx)(U,{label:t(`contextWindowCol`),value:(0,V.jsxs)(`span`,{className:`mono`,children:[H(i),a&&a!==i?` → ${H(a)}`:``]})}),f?(0,V.jsx)(U,{label:t(`promptMaxTokens`),value:(0,V.jsx)(`span`,{className:`mono`,children:H(f)})}):null,p?(0,V.jsx)(U,{label:t(`maxOutputTokens`),value:(0,V.jsx)(`span`,{className:`mono`,children:H(p)})}):null,(0,V.jsx)(U,{label:t(`imageInput`),value:d})]}),(0,V.jsxs)(`section`,{children:[(0,V.jsx)(`div`,{className:`mb-1 text-caption font-medium text-muted`,children:t(`reasoningLevels`)}),r.length?(0,V.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:r.map(e=>(0,V.jsx)(D,{size:`sm`,variant:`soft`,color:`default`,children:(0,V.jsx)(`span`,{className:`mono`,children:e})},e))}):(0,V.jsx)(`div`,{className:`text-caption text-muted`,children:e.reasoning_type?t(`reasoningFixed`,{type:e.reasoning_type}):t(`noReasoningLevels`)})]})]})]})})})})}function Se({catalog:e,selected:t,onChange:n,isDisabled:r,t:i}){let[a,o]=(0,P.useState)(``),[s,c]=(0,P.useState)(t),u=(0,P.useMemo)(()=>new Set(t),[t]),d=(0,P.useMemo)(()=>{let t=new Set(s),n=a.trim().toLowerCase(),r=(e||[]).filter(e=>!n||e.toLowerCase().includes(n));return[...r.filter(e=>t.has(e)),...r.filter(e=>!t.has(e))]},[e,a,s]),f=(0,P.useMemo)(()=>{if(!e)return[];let n=new Set(e);return t.filter(e=>!n.has(e))},[e,t]),p=e?.length??0,h=t.filter(e=>!f.includes(e)).length;function ee(e){o(e),c(t)}function g(e,r){n(r?[...t,e]:t.filter(t=>t!==e))}function _(){let e=new Set(t);d.forEach(t=>e.add(t)),n([...e])}function v(){let e=new Set(d);n(t.filter(t=>!e.has(t)))}return(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,V.jsx)(b,{"aria-label":i(`modelPickerSearch`),value:a,onChange:ee,isDisabled:r,className:`min-w-0 flex-1 basis-48`,children:(0,V.jsxs)(b.Group,{children:[(0,V.jsx)(b.SearchIcon,{}),(0,V.jsx)(b.Input,{placeholder:i(`modelPickerSearch`)}),(0,V.jsx)(b.ClearButton,{})]})}),(0,V.jsx)(`span`,{className:`mono shrink-0 text-caption text-muted`,children:i(`modelPickerCount`,{selected:h,total:p})}),(0,V.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,V.jsxs)(l,{size:`sm`,variant:`ghost`,isDisabled:r||d.length===0,onPress:_,children:[(0,V.jsx)(R,{size:14}),i(`modelPickerSelectAll`)]}),(0,V.jsxs)(l,{size:`sm`,variant:`ghost`,isDisabled:r||t.length===0,onPress:v,children:[(0,V.jsx)(_e,{size:14}),i(`modelPickerClear`)]})]})]}),(0,V.jsxs)(`div`,{className:`max-h-[300px] overflow-y-auto overscroll-contain rounded-lg bg-surface-secondary p-1`,children:[e===null?(0,V.jsx)(`p`,{className:`px-2.5 py-2 text-caption text-muted`,children:i(`refreshing`)}):null,f.map(e=>(0,V.jsxs)(`div`,{className:`flex items-center gap-2.5 rounded-md px-2.5 py-1.5`,children:[(0,V.jsx)(`span`,{className:`mono min-w-0 flex-1 truncate text-body text-muted line-through`,children:e}),(0,V.jsx)(`span`,{className:`shrink-0 text-caption text-warning`,children:i(`modelPickerOffline`)}),(0,V.jsx)(l,{isIconOnly:!0,size:`sm`,variant:`ghost`,isDisabled:r,"aria-label":i(`modelPickerRemove`,{model:e}),onPress:()=>g(e,!1),children:(0,V.jsx)(pe,{size:14})})]},`offline-${e}`)),d.map(e=>(0,V.jsx)(m,{isSelected:u.has(e),isDisabled:r,onChange:t=>g(e,t),className:`flex w-full cursor-pointer rounded-md px-2.5 py-1.5 transition-colors hover:bg-default`,children:(0,V.jsxs)(m.Content,{className:`flex min-w-0 flex-1 items-center gap-2.5`,children:[(0,V.jsx)(m.Control,{children:(0,V.jsx)(m.Indicator,{})}),(0,V.jsx)(`span`,{className:`mono min-w-0 truncate text-body text-foreground`,children:e})]})},e)),e!==null&&d.length===0?(0,V.jsx)(`p`,{className:`px-2.5 py-2 text-caption text-muted`,children:i(p===0?`noAccountModels`:`modelPickerNoMatch`)}):null]})]})}function Ce(e){let t=e.toLowerCase();return![`trae`,`kimi`,`codearts`,`minimaxcode`].includes(t)}function W(e){let t=e.toLowerCase();return t===`workbuddy`||t===`trae`}function G(e){return e.toLowerCase()===`qoder`?`11:00`:`01:00`}function we({provider:e,region:t,label:n,policy:r,checkinSupported:i,checkinTimezone:a,t:o,onClose:s,onSaved:c}){let[d,f]=(0,P.useState)(r.credit_floor==null?`inherit`:`custom`),[m,ee]=(0,P.useState)(r.credit_floor??0),[b,x]=(0,P.useState)(r.percent_floor==null?`inherit`:`custom`),[S,C]=(0,P.useState)(r.percent_floor??0),[w,te]=(0,P.useState)(r.proxy_url||``),[ne,re]=(0,P.useState)(r.drop_system_prompt??Ce(e)),[ie,ae]=(0,P.useState)(Object.entries(r.model_aliases||{}).map(([e,t])=>({alias:e,model:t}))),[T,oe]=(0,P.useState)({alias:``,model:``}),[E,se]=(0,P.useState)(!!r.models_restricted||!!(r.enabled_models||[]).length),[ce,le]=(0,P.useState)(r.enabled_models||[]),{mounted:ue,outerRef:O,innerRef:de}=ve(E),[fe,k]=(0,P.useState)(null),[A,j]=(0,P.useState)(``),[me,M]=(0,P.useState)(r.checkin_time||(e.toLowerCase()===`qoder`?`11:00`:`01:00`)),[N,ge]=(0,P.useState)(r.checkin_auto!==!1),[F,I]=(0,P.useState)(!1),[L,R]=(0,P.useState)(``);(0,P.useEffect)(()=>{let n=!1;return B(e,t).then(e=>{n||(k((e.data||[]).map(e=>e.id)),j(``))}).catch(e=>{n||(k([]),j(e instanceof Error?e.message:String(e)))}),()=>{n=!0}},[e,t]);async function z(n){if(n?.preventDefault(),d===`custom`&&(!Number.isFinite(m)||m<0)){R(o(`creditFloorInvalid`));return}if(b===`custom`&&(!Number.isFinite(S)||S<0||S>100)){R(o(`percentFloorInvalid`));return}if(i&&!N&&!/^([01]\d|2[0-3]):[0-5]\d$/.test(me)){R(o(`checkinTimeInvalid`));return}if(E&&ce.length===0){R(o(`providerModelsEmpty`));return}R(``),I(!0);try{let n={provider:e,region:t,credit_floor:d===`custom`?m:null,percent_floor:b===`custom`?S:null,proxy_url:w.trim(),drop_system_prompt:ne,model_aliases:Object.fromEntries(ie.filter(e=>e.alias.trim()&&e.model.trim()).map(e=>[e.alias.trim(),e.model.trim()])),enabled_models:E?ce:[],models_restricted:E,checkin_time:i?me:``,checkin_auto:i?N:!1};c((await be(n)).data||n),s()}catch(e){R(e instanceof Error?e.message:String(e))}finally{I(!1)}}return(0,V.jsx)(y.Root,{isOpen:!0,onOpenChange:e=>{!e&&!F&&s()},children:(0,V.jsx)(y.Backdrop,{variant:`blur`,children:(0,V.jsx)(y.Container,{placement:`center`,size:`lg`,scroll:`inside`,children:(0,V.jsxs)(y.Dialog,{className:`w-full sm:w-[42rem] sm:max-w-[calc(100vw-2rem)]`,children:[(0,V.jsxs)(y.Header,{className:`items-start justify-between gap-4 px-6 pt-6`,children:[(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(y.Heading,{className:`text-section font-semibold`,children:o(`providerSettingsTitle`)}),(0,V.jsx)(`p`,{className:`mt-1.5 text-body font-normal leading-6 text-muted`,children:o(`providerSettingsHint`)}),(0,V.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[(0,V.jsx)(D,{size:`sm`,variant:`soft`,children:(0,V.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,V.jsx)(he,{provider:e,size:14}),(0,V.jsx)(`span`,{children:n})]})}),(0,V.jsx)(`span`,{className:`mono text-caption text-muted`,children:t||`any`})]})]}),(0,V.jsx)(y.CloseTrigger,{isDisabled:F,"aria-label":o(`close`),className:`grid size-9 shrink-0 place-items-center rounded-lg text-muted hover:bg-surface-secondary`,children:(0,V.jsx)(pe,{size:18})})]}),(0,V.jsxs)(y.Body,{className:`px-6 pb-2 pt-1`,children:[L?(0,V.jsxs)(u,{status:`danger`,className:`mb-4`,children:[(0,V.jsx)(u.Indicator,{}),(0,V.jsx)(u.Content,{children:(0,V.jsx)(u.Title,{children:L})})]}):null,A?(0,V.jsxs)(u,{status:`warning`,className:`mb-4`,children:[(0,V.jsx)(u.Indicator,{}),(0,V.jsx)(u.Content,{children:(0,V.jsx)(u.Title,{children:A})})]}):null,(0,V.jsxs)(p,{className:`space-y-4`,onSubmit:e=>void z(e),children:[(0,V.jsx)(v,{label:o(`creditFloor`),hint:o(`creditFloorHint`),align:`start`,children:(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(g,{isSelected:d===`custom`,isDisabled:F,ariaLabel:o(`creditFloorCustom`),label:o(`creditFloorCustom`),onChange:e=>f(e?`custom`:`inherit`)}),d===`custom`?(0,V.jsx)(h,{value:m,onChange:e=>ee(e??0),minValue:0,step:1,isDisabled:F,isRequired:!0,children:(0,V.jsxs)(h.Group,{children:[(0,V.jsx)(h.DecrementButton,{}),(0,V.jsx)(h.Input,{"aria-label":o(`creditFloor`)}),(0,V.jsx)(h.IncrementButton,{})]})}):(0,V.jsx)(`p`,{className:`text-caption text-muted`,children:o(`creditFloorInheritHint`)})]})}),(0,V.jsx)(v,{label:o(`percentFloor`),hint:o(`percentFloorHint`),align:`start`,children:(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(g,{isSelected:b===`custom`,isDisabled:F,ariaLabel:o(`percentFloorCustom`),label:o(`percentFloorCustom`),onChange:e=>x(e?`custom`:`inherit`)}),b===`custom`?(0,V.jsx)(h,{value:S,onChange:e=>C(e??0),minValue:0,maxValue:100,step:1,isDisabled:F,isRequired:!0,children:(0,V.jsxs)(h.Group,{children:[(0,V.jsx)(h.DecrementButton,{}),(0,V.jsx)(h.Input,{"aria-label":o(`percentFloor`)}),(0,V.jsx)(h.IncrementButton,{})]})}):(0,V.jsx)(`p`,{className:`text-caption text-muted`,children:o(`percentFloorInheritHint`)})]})}),(0,V.jsx)(v,{label:o(`proxyUrl`),hint:o(`proxyUrlHint`),children:(0,V.jsx)(_,{value:w,onChange:e=>te(e.target.value),placeholder:o(`proxyUrlPlaceholder`),"aria-label":o(`proxyUrl`),disabled:F})}),W(e)?(0,V.jsx)(v,{label:o(`dropSystemPrompt`),hint:o(e===`trae`?`dropSystemPromptTraeHint`:`dropSystemPromptHint`),children:(0,V.jsx)(g,{isSelected:ne,isDisabled:F,ariaLabel:o(`dropSystemPrompt`),onChange:re})}):null,(0,V.jsx)(v,{align:`start`,label:o(`accountModelAliases`),hint:o(`accountModelAliasesHint`),children:(0,V.jsxs)(`div`,{className:`space-y-2`,children:[ie.map(e=>(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,V.jsxs)(`span`,{className:`mono min-w-0 truncate text-body`,children:[e.alias,` → `,e.model]}),(0,V.jsx)(l,{size:`sm`,variant:`ghost`,isDisabled:F,onPress:()=>ae(t=>t.filter(t=>t.alias!==e.alias)),children:o(`modelAliasRemove`)})]},e.alias)),(0,V.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-[1fr_1fr_auto]`,children:[(0,V.jsx)(_,{"aria-label":o(`modelAliasName`),value:T.alias,onChange:e=>oe(t=>({...t,alias:e.target.value})),placeholder:o(`modelAliasPlaceholder`),disabled:F}),(0,V.jsx)(_,{"aria-label":o(`modelAliasTarget`),value:T.model,onChange:e=>oe(t=>({...t,model:e.target.value})),placeholder:o(`accountModelAliasTargetPlaceholder`),disabled:F}),(0,V.jsx)(l,{size:`sm`,variant:`secondary`,isDisabled:F||!T.alias.trim()||!T.model.trim(),onPress:()=>{ae(e=>[...e.filter(e=>e.alias!==T.alias.trim()),{alias:T.alias.trim(),model:T.model.trim()}]),oe({alias:``,model:``})},children:o(`modelAliasAdd`)})]})]})}),(0,V.jsxs)(`section`,{className:`space-y-3 pt-1`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`div`,{className:`text-body font-medium text-foreground`,children:o(`enabledModels`)}),(0,V.jsx)(`p`,{className:`mt-0.5 text-caption leading-5 text-muted`,children:o(`enabledModelsHint`)})]}),(0,V.jsx)(g,{isSelected:E,isDisabled:F,ariaLabel:o(`restrictModels`),label:o(E?`restrictModels`:`allModels`),onChange:se})]}),ue?(0,V.jsx)(`div`,{ref:O,children:(0,V.jsx)(`div`,{ref:de,children:(0,V.jsx)(Se,{catalog:fe,selected:ce,onChange:le,isDisabled:F,t:o})})}):null]}),i?(0,V.jsx)(v,{label:o(`autoCheckinTime`),hint:o(`checkinScheduleHint`),children:(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,V.jsx)(`span`,{className:`text-caption text-muted`,children:o(`checkinAutoMode`)}),(0,V.jsx)(g,{isSelected:N,isDisabled:F,ariaLabel:o(`checkinAutoMode`),onChange:ge})]}),(0,V.jsx)(_,{type:`time`,value:N?G(e):me,onChange:e=>M(e.target.value),"aria-label":o(`autoCheckinTime`),disabled:F||N,required:!N}),a?(0,V.jsx)(`p`,{className:`text-caption text-muted`,children:o(`checkinServerClock`,{timezone:a})}):null,N?(0,V.jsx)(`p`,{className:`text-caption text-muted`,children:o(`checkinAutoFallbackHint`)}):null]})}):null]})]}),(0,V.jsxs)(y.Footer,{className:`justify-end gap-2 px-6 pb-6`,children:[(0,V.jsx)(l,{variant:`ghost`,isDisabled:F,onPress:s,children:o(`cancel`)}),(0,V.jsx)(l,{isPending:F,onPress:()=>void z(),children:o(`save`)})]})]})})})})}function Te(e){let t=[];for(let n of e)for(let e of n.regions||[])e?.id&&t.push({value:`${n.id}:${e.id}`,provider:n.id,region:e.id,checkin:!!e.checkin,checkinTimezone:e.checkin?.timezone===`Local`?`Asia/Shanghai`:e.checkin?.timezone});return t}function Ee(e,t){let n=new Set;for(let r of e){let e=String(r.provider||`qoder`).trim().toLowerCase(),i=String(r.region||``).trim().toLowerCase(),a=t.find(t=>t.provider===e&&t.region===i)||t.find(t=>t.provider===e);a&&n.add(a.value)}return Array.from(n)}function K(e){return e.settings_key||e.id}function q(e){return String(e.provider||e.owned_by||`qoder`).trim().toLowerCase()}function De(e){let t=String(e.region||``).trim().toLowerCase();if(t)return t;let n=e.regions||[];return String(n[0]||``).trim().toLowerCase()}function Oe(e){return`${q(e)}:${De(e)||`any`}:${e.settings_key||e.id}:${e.native_model||e.mapped_key||``}`}function J(e){let t=e.route_display_name||``;return t&&t!==(e.display_name||e.id)?t:``}function ke(e,t){let n=new Map;for(let r of e){let e=q(r);if(e===`aggregation`)continue;let i=De(r),a=`${e}:${i||`any`}`,o=n.get(a);o||(o={key:a,provider:e,region:i,label:M(e,i||void 0,t),models:[]},n.set(a,o)),o.models.push(r)}return Array.from(n.values())}function Ae(e){let t=e.toLowerCase();return![`trae`,`kimi`,`codearts`,`minimaxcode`].includes(t)}function je(e,t){return e.region&&e.region!==`any`?e.region:t.find(t=>t.provider===e.provider)?.region||``}function Me(e,t){let n=new Map(t.map((e,t)=>[`${e.provider}:${e.region||`any`}`,t]));return[...e].sort((e,t)=>{let r=n.get(e.key),i=n.get(t.key);return r!=null&&i!=null?r-i:r==null?i==null?0:1:-1})}function Ne(e,t,n){return e.find(e=>e.provider===t&&(e.region||`any`)===n)||{provider:t,region:n,credit_floor:null,percent_floor:null,proxy_url:``,drop_system_prompt:Ae(t),model_aliases:{},enabled_models:[],models_restricted:!1,checkin_time:`09:00`,checkin_auto:!0}}function Pe({model:e,saving:t,t:n,variant:r=`table`,onToggleTraeMax:i}){let a=q(e),o=r===`card`,s=e.context_length||e.catalog_context_length,c=e.catalog_context_length_max,l=!!(c&&c!==s),u=e.reasoning_options||[],d=a===`qoder`&&!!e.supports_max_mode,f=u.length?u.join(` / `):e.reasoning_type?n(`reasoningFixed`,{type:e.reasoning_type}):`—`;return(0,V.jsxs)(`div`,{className:o?`flex min-w-0 flex-col gap-2`:`flex min-w-0 flex-col gap-1`,children:[(0,V.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,V.jsxs)(`span`,{className:`mono text-caption font-medium`,children:[H(s),l?` → ${H(c)}`:``]}),d?(0,V.jsx)(g,{isSelected:!!e.max_mode,isDisabled:t,ariaLabel:`${e.id} ${n(`maxMode`)}`,onChange:t=>i(e,t)}):null]}),(0,V.jsx)(`div`,{className:`min-w-0 truncate text-caption text-muted`,title:f,children:f})]})}function Fe({model:e,t,onDetails:n}){return(0,V.jsxs)(l,{size:`sm`,variant:`ghost`,onPress:()=>n(e),children:[(0,V.jsx)(me,{size:14}),t(`modelDetails`)]})}function Y({group:e,t}){return(0,V.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,V.jsx)(`div`,{className:`grid size-8 shrink-0 place-items-center rounded-lg bg-surface text-foreground`,children:(0,V.jsx)(he,{provider:e.provider,size:16})}),(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`div`,{className:`truncate text-body font-semibold`,children:e.label}),(0,V.jsx)(`div`,{className:`text-caption text-muted`,children:t(`usageModelCount`,{count:e.models.length})})]})]})}function Ie({group:e,t,collapsible:n,collapsed:i,onToggle:a,onSettings:o,settingsDisabled:s,savingKey:c,modelCheckChip:u,onToggleTraeMax:d,onDetails:p}){let m=(0,P.useId)(),{mounted:h,outerRef:ee,innerRef:g}=ve(!n||!i);return(0,V.jsxs)(f,{className:`overflow-hidden p-0`,children:[(0,V.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 bg-surface-secondary px-4 py-3 ${h?`border-b border-separator`:``}`,children:[n?(0,V.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center justify-between gap-3 rounded-lg text-left outline-none focus-visible:ring-2 focus-visible:ring-focus`,"aria-expanded":!i,"aria-controls":m,"aria-label":`${t(i?`providerExpand`:`providerCollapse`)} ${e.label}`,onClick:a,children:[(0,V.jsx)(Y,{group:e,t}),(0,V.jsx)(r,{size:16,className:`shrink-0 text-muted transition-transform ${i?``:`rotate-90`}`,"aria-hidden":!0})]}):(0,V.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center`,children:(0,V.jsx)(Y,{group:e,t})}),(0,V.jsxs)(l,{className:`shrink-0`,size:`sm`,variant:`ghost`,isDisabled:s,onPress:o,children:[(0,V.jsx)(ue,{size:14}),t(`providerSettingsOpen`)]})]}),h?(0,V.jsx)(`div`,{id:m,ref:ee,className:`min-w-0`,children:(0,V.jsx)(`div`,{ref:g,children:e.models.length===0?(0,V.jsx)(`div`,{className:`px-4 py-8 text-center text-caption text-muted`,children:t(`noModelsYet`)}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`div`,{className:`divide-y divide-separator lg:hidden`,children:e.models.map(e=>{let n=c===K(e),r=S(e),i=C(e);return(0,V.jsxs)(`article`,{className:`space-y-3 px-4 py-4`,children:[(0,V.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,V.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,V.jsx)(`span`,{className:`status-dot mt-1.5`,"data-state":e.stale?void 0:`ok`}),(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,V.jsx)(`div`,{className:`truncate font-medium`,children:e.display_name||e.id}),i?(0,V.jsx)(D,{size:`sm`,variant:`soft`,color:`success`,children:t(`modelFree`)}):null,r?(0,V.jsx)(`span`,{className:`mono text-caption text-muted`,children:r}):null]}),(0,V.jsx)(`div`,{className:`mono mt-0.5 truncate text-caption text-muted`,children:e.id}),J(e)?(0,V.jsx)(`div`,{className:`mt-0.5 text-caption text-muted`,children:t(`routedTo`,{model:J(e)})}):null]})]}),u(e)]}),(0,V.jsx)(`div`,{className:`mono break-all text-caption text-muted`,children:e.mapped_key||e.native_model||e.id}),(0,V.jsx)(Pe,{model:e,saving:n,t,variant:`card`,onToggleTraeMax:d}),(0,V.jsx)(Fe,{model:e,t,onDetails:p})]},Oe(e))})}),(0,V.jsx)(x,{className:`hidden min-w-0 lg:block`,children:(0,V.jsx)(x.ScrollContainer,{className:`min-w-0 overflow-x-auto`,children:(0,V.jsxs)(x.Content,{"aria-label":`${e.label} ${t(`availableModels`)}`,className:`min-w-[58rem]`,children:[(0,V.jsxs)(x.Header,{children:[(0,V.jsx)(x.Column,{isRowHeader:!0,children:t(`modelCol`)}),(0,V.jsx)(x.Column,{children:t(`requestIdCol`)}),(0,V.jsx)(x.Column,{children:t(`qoderKeyCol`)}),(0,V.jsx)(x.Column,{children:t(`modelDefaultsCol`)}),(0,V.jsx)(x.Column,{children:t(`stateCol`)}),(0,V.jsx)(x.Column,{children:t(`modelDetailsCol`)})]}),(0,V.jsx)(x.Body,{children:e.models.map(e=>{let n=c===K(e),r=S(e),i=C(e);return(0,V.jsxs)(x.Row,{children:[(0,V.jsx)(x.Cell,{children:(0,V.jsxs)(`div`,{className:`flex items-center gap-3 py-1`,children:[(0,V.jsx)(`span`,{className:`status-dot`,"data-state":e.stale?void 0:`ok`}),(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,V.jsx)(`div`,{className:`font-medium`,children:e.display_name||e.id}),i?(0,V.jsx)(D,{size:`sm`,variant:`soft`,color:`success`,children:t(`modelFree`)}):null,r?(0,V.jsx)(`span`,{className:`mono text-caption text-muted`,children:r}):null]}),J(e)?(0,V.jsx)(`div`,{className:`mt-0.5 text-caption text-muted`,children:t(`routedTo`,{model:J(e)})}):null]})]})}),(0,V.jsx)(x.Cell,{children:(0,V.jsx)(`span`,{className:`mono text-caption font-medium`,children:e.id})}),(0,V.jsx)(x.Cell,{children:(0,V.jsx)(`span`,{className:`mono text-caption text-muted`,children:e.mapped_key||e.native_model||e.id})}),(0,V.jsx)(x.Cell,{children:(0,V.jsx)(Pe,{model:e,saving:n,t,variant:`table`,onToggleTraeMax:d})}),(0,V.jsx)(x.Cell,{children:u(e)}),(0,V.jsx)(x.Cell,{children:(0,V.jsx)(Fe,{model:e,t,onDetails:p})})]},Oe(e))})})]})})})]})})}):null]})}function Le(){let{t:e}=c(),{overview:t,loading:n}=le(),[r,s]=(0,P.useState)(``),[u,p]=(0,P.useState)(``),[m,h]=(0,P.useState)([]),[g,_]=(0,P.useState)(!0),[v,y]=(0,P.useState)(null),[b,S]=(0,P.useState)(!0),[C,w]=(0,P.useState)([]),[E,ue]=(0,P.useState)(!0),[O,pe]=(0,P.useState)(!1),[A,j]=(0,P.useState)(null),[me,he]=(0,P.useState)(new Set),[N,F]=(0,P.useState)(1),[I,L]=(0,P.useState)(50),[R,z]=(0,P.useState)(!1),[_e,ve]=(0,P.useState)(``),[be,B]=(0,P.useState)(``),[H,U]=(0,P.useState)(!1),[Se,Ce]=(0,P.useState)(null),[W,G]=(0,P.useState)([]),[J,Ae]=(0,P.useState)(!0),[Pe,Fe]=(0,P.useState)(!1),[Y,Le]=(0,P.useState)(null);(0,P.useEffect)(()=>{let e=!1;return ae(void 0,`regional`).then(t=>{e||G(t.data||[])}).catch(()=>void 0).finally(()=>{e||Ae(!1)}),ie().then(t=>{e||h(Te(t.data||[]))}).catch(()=>void 0).finally(()=>{e||_(!1)}),oe(!1).then(t=>{e||y(t.data||[])}).catch(()=>{e||y(null)}).finally(()=>{e||S(!1)}),ye().then(t=>{e||w(t.data||[])}).catch(t=>{e||(pe(!0),U(!0),B(t instanceof Error?t.message:String(t)))}).finally(()=>{e||ue(!1)}),()=>{e=!0}},[]);let Re=(0,P.useMemo)(()=>v?Ee(v,m):null,[v,m]),ze=(0,P.useMemo)(()=>{let e=new Set;for(let t of W){let n=q(t),r=De(t),i=m.find(e=>e.provider===n&&e.region===r)||m.find(e=>e.provider===n);i&&e.add(i.value)}return Array.from(e)},[W,m]),X=(0,P.useMemo)(()=>{let e=Re&&Re.length?Re:ze;return e.length?m.filter(t=>e.includes(t.value)):[]},[Re,ze,m]),Z=u===``||X.some(e=>e.value===u)?u:X[0]?.value||``,Be=Z===``,Q=(0,P.useMemo)(()=>{let t=r.trim().toLowerCase(),[n,i]=Z.includes(`:`)?Z.split(`:`,2):[Z,``];return W.filter(r=>{let a=q(r),o=De(r);if(n&&a!==n||i&&o!==i)return!1;if(!t)return!0;let s=M(a,o||void 0,e);return`${r.display_name||``} ${r.id} ${r.mapped_key||``} ${a} ${s} ${r.owned_by||``} ${o} ${r.credits||``} ${r.free?`free`:``}`.toLowerCase().includes(t)})},[r,W,Z,e]),Ve=[r,Z,I].join(`\0`),[He,Ue]=(0,P.useState)(Ve);He!==Ve&&(Ue(Ve),F(1));let We=(0,P.useMemo)(()=>{let t=ke(Q,e);if(r.trim())return Me(t,X);let n=new Set(t.map(e=>e.key)),i=r=>{let i=`${r.provider}:${r.region||`any`}`;n.has(i)||(n.add(i),t.push({key:i,provider:r.provider,region:r.region,label:M(r.provider,r.region,e),models:[]}))};if(Z){let e=X.find(e=>e.value===Z);e&&i(e)}else for(let e of X)i(e);for(let r of C){if(!r.models_restricted||!r.provider||!r.region||r.region===`any`)continue;if(Z){let[e,t]=Z.includes(`:`)?Z.split(`:`,2):[Z,``];if(e&&e!==r.provider||t&&t!==r.region)continue}let i=`${r.provider}:${r.region}`;n.has(i)||(n.add(i),t.push({key:i,provider:r.provider,region:r.region,label:M(r.provider,r.region,e),models:[]}))}return Me(t,X)},[Q,r,Z,X,C,e]),Ge=(0,P.useMemo)(()=>{let e=[],t=[],n=0;for(let r of We)t.length>0&&n+r.models.length>I&&(e.push(t),t=[],n=0),t.push(r),n+=r.models.length;return t.length>0&&e.push(t),e.length>0?e:[[]]},[We,I]),Ke=Math.max(1,Ge.length),$=Math.min(He===Ve?Math.max(1,N):1,Ke);N!==$&&F($);let qe=Ge[$-1]??[],Je=Ge.slice(0,$-1).reduce((e,t)=>e+t.reduce((e,t)=>e+t.models.length,0),0),Ye=qe.reduce((e,t)=>e+t.models.length,0),Xe=Q.length===0?0:Je+1,Ze=Q.length===0?0:Je+Ye,Qe=Q.length?e(`logsShownTotal`,{shown:`${Xe}–${Ze}`,total:Q.length}):e(`shownTotal`,{shown:0,total:W.length}),$e=A?m.find(e=>e.provider===A.provider&&e.region===A.region):void 0,et=A?Ne(C,A.provider,A.region):null;if(n&&!t||J||b||g)return(0,V.jsx)(de,{});function tt(e,t){let n=K(e),r=q(e),i=W.map(e=>{if(K(e)!==n||q(e)!==r)return e;let i=e.reasoning_effort||e.reasoning_default||``,a=e.catalog_context_length||e.default_context_length||e.context_length||0,o=e.catalog_context_length_max||0;return{...e,max_mode:t,context_length:t&&o?o:a,default_context_length:a,context_custom:r===`qoder`?t:t||!!(i&&i!==e.reasoning_default)}});G(i)}function nt(e){he(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}async function rt(){z(!0),B(``),U(!1);try{let e=await re(void 0,`regional`);G(e.data||[])}catch(e){U(!0),B(e instanceof Error?e.message:String(e))}finally{z(!1)}}function it(e){return Y?.results.find(t=>t.model===e.id)}function at(t){let n=it(t);if(!n)return(0,V.jsx)(D,{size:`sm`,variant:`soft`,color:`default`,children:e(`checkNotRun`)});let r=n.accounts||[],i=r.length?r.filter(e=>e.ok).length:+!!n.ok,a=r.length||n.attempt_count||+!!n.ok;return(0,V.jsxs)(D,{size:`sm`,variant:`soft`,color:n.ok?`success`:`danger`,children:[n.ok?e(`checkResultOK`):e(`checkResultFailed`),a?` · ${e(`checkPassedAccounts`,{passed:i,total:a})}`:``]})}async function ot(){if(!W.length){B(e(`checkModelsEmpty`)),U(!1);return}Fe(!0),Le(null),B(``),U(!1);try{let t=await T(W.map(e=>e.id));Le(t),B(e(`checkModelsSummary`,{passed:t.summary.passed,failed:t.summary.failed,total:t.summary.total,elapsed:t.elapsed_ms}))}catch(e){U(!0),B(e instanceof Error?e.message:String(e))}finally{Fe(!1)}}async function st(t,n){if(!t.supports_max_mode){U(!0),B(e(`contextMaxUnavailable`));return}let r=K(t),i=q(t);ve(r),B(``),U(!1);try{await ne(i,r,n,t.catalog_context_length_max),tt(t,n),B(e(n?`contextMaxOn`:`contextMaxOff`,{model:t.id}))}catch(e){U(!0),B(e instanceof Error?e.message:String(e))}finally{ve(``)}}function ct(t){if(E||O){U(!0),B(e(O?`providerSettingsLoadFailed`:`refreshing`));return}let n=je(t,m);if(!n&&m.some(e=>e.provider===t.provider)){U(!0),B(e(`providerSettingsRegionMissing`));return}j({provider:t.provider,region:n,label:t.label})}function lt(t){w(e=>[...e.filter(e=>e.provider!==t.provider||(e.region||`any`)!==(t.region||`any`)),t]),U(!1),B(e(`providerSettingsSaved`)),te(void 0,`regional`).then(e=>G(e.data||[])).catch(t=>{U(!0),B(e(`providerSettingsSavedRefreshFailed`,{message:t instanceof Error?t.message:String(t)}))})}return(0,V.jsxs)(`div`,{className:`space-y-6`,children:[(0,V.jsxs)(`section`,{className:`grid gap-5 pb-6 lg:grid-cols-[minmax(0,1fr)_auto] lg:items-end`,children:[(0,V.jsxs)(`div`,{"data-gsap-reveal":!0,children:[(0,V.jsx)(`h2`,{className:`text-title font-semibold`,children:e(`availableModels`)}),(0,V.jsx)(`p`,{className:`mt-1 text-body text-muted`,children:W.length?Qe:e(`noModelsYet`)})]}),(0,V.jsxs)(`div`,{"data-gsap-reveal":!0,className:`flex min-w-0 flex-col gap-2 sm:flex-row sm:flex-wrap sm:items-center`,children:[(0,V.jsx)(o,{className:`w-full min-w-0 sm:w-72`,value:r,onChange:s,placeholder:e(`filterPh`),ariaLabel:e(`filter`)}),(0,V.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[X.length?(0,V.jsx)(ge,{ariaLabel:e(`providerCol`),value:Z,onChange:p,options:[{id:``,label:e(`providerFilterAll`)},...X.map(t=>({id:t.value,label:M(t.provider,t.region,e)}))]}):null,(0,V.jsxs)(l,{size:`sm`,variant:`secondary`,isPending:R||Pe,onPress:()=>void rt(),children:[(0,V.jsx)(se,{size:14}),e(R?`refreshing`:`refresh`)]}),(0,V.jsxs)(k,{children:[(0,V.jsx)(k.Trigger,{children:(0,V.jsxs)(l,{size:`sm`,variant:`secondary`,isPending:Pe,isDisabled:R||W.length===0,onPress:()=>void ot(),children:[(0,V.jsx)(ce,{size:14}),e(Pe?`checkingModels`:`checkAllModels`)]})}),(0,V.jsx)(k.Content,{children:(0,V.jsx)(`p`,{className:`max-w-xs text-caption leading-5`,children:e(`checkModelsHint`)})})]})]})]})]}),be?(0,V.jsx)(d,{status:H?`danger`:`success`,title:be}):null,Y?(0,V.jsxs)(f,{"data-gsap-reveal":!0,className:`overflow-hidden p-0`,children:[(0,V.jsxs)(`div`,{className:`flex items-start justify-between gap-4 border-b border-separator px-4 py-4 sm:items-center sm:px-5`,children:[(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`div`,{className:`text-body font-semibold`,children:e(`checkAllModels`)}),(0,V.jsx)(`div`,{className:`mt-0.5 text-caption leading-5 text-muted`,children:e(`checkModelsSummary`,{passed:Y.summary.passed,failed:Y.summary.failed,total:Y.summary.total,elapsed:Y.elapsed_ms})})]}),(0,V.jsxs)(D,{size:`sm`,variant:`soft`,color:Y.summary.failed?`warning`:`success`,className:`shrink-0`,children:[Y.summary.passed,`/`,Y.summary.total]})]}),(0,V.jsx)(x,{className:`hidden min-w-0 lg:block`,children:(0,V.jsx)(x.ScrollContainer,{className:`max-h-[24rem] min-w-0 overflow-auto`,children:(0,V.jsxs)(x.Content,{"aria-label":e(`checkAllModels`),className:`min-w-[52rem]`,children:[(0,V.jsxs)(x.Header,{children:[(0,V.jsx)(x.Column,{isRowHeader:!0,children:e(`modelCol`)}),(0,V.jsx)(x.Column,{children:e(`stateCol`)}),(0,V.jsx)(x.Column,{children:e(`account`)}),(0,V.jsx)(x.Column,{children:e(`providerCol`)}),(0,V.jsx)(x.Column,{children:e(`logsColLatency`)}),(0,V.jsx)(x.Column,{children:e(`checkAccountResults`)}),(0,V.jsx)(x.Column,{children:e(`response`)})]}),(0,V.jsx)(x.Body,{children:Y.results.map(t=>(0,V.jsxs)(x.Row,{children:[(0,V.jsx)(x.Cell,{children:(0,V.jsx)(`span`,{className:`mono text-caption font-medium`,children:t.model})}),(0,V.jsx)(x.Cell,{children:(0,V.jsx)(D,{size:`sm`,variant:`soft`,color:t.ok?`success`:t.code===`no_models`||t.message===`model required`?`warning`:`danger`,children:t.ok?e(`checkResultOK`):t.code===`no_models`||t.message===`model required`?e(`checkResultSkipped`):e(`checkResultFailed`)})}),(0,V.jsx)(x.Cell,{children:(0,V.jsx)(`span`,{className:`mono text-caption text-muted`,children:t.account_id||`—`})}),(0,V.jsx)(x.Cell,{children:(0,V.jsx)(`span`,{className:`text-caption`,children:t.provider||`—`})}),(0,V.jsx)(x.Cell,{children:(0,V.jsxs)(`span`,{className:`mono text-caption text-muted`,children:[t.latency_ms,`ms`]})}),(0,V.jsx)(x.Cell,{children:(0,V.jsx)(`div`,{className:`space-y-1`,children:(t.accounts||[]).length?t.accounts.map(n=>(0,V.jsxs)(`div`,{className:`text-caption leading-4`,children:[(0,V.jsx)(`span`,{className:`mono font-medium`,children:n.account_id}),(0,V.jsxs)(`span`,{className:n.ok?`text-success`:`text-danger`,children:[` `,n.ok?e(`checkResultOK`):e(`checkResultFailed`)]}),(0,V.jsxs)(`span`,{className:`text-muted`,children:[` · `,n.latency_ms,`ms`]}),n.message?(0,V.jsx)(`span`,{className:`block break-all text-muted`,children:n.message}):null]},`${t.model}:${n.account_id}`)):(0,V.jsx)(`span`,{className:`text-caption text-muted`,children:`—`})})}),(0,V.jsx)(x.Cell,{children:(0,V.jsx)(`span`,{className:`break-all text-caption text-muted`,children:t.message||(t.ok?e(`checkResultOK`):``)})})]},t.model))})]})})}),(0,V.jsx)(`div`,{className:`divide-y divide-separator lg:hidden`,children:Y.results.map(t=>(0,V.jsxs)(`div`,{className:`space-y-1 px-4 py-3`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,V.jsx)(`span`,{className:`mono min-w-0 truncate text-caption font-medium`,children:t.model}),(0,V.jsx)(D,{size:`sm`,variant:`soft`,color:t.ok?`success`:`danger`,children:t.ok?e(`checkResultOK`):e(`checkResultFailed`)})]}),(0,V.jsxs)(`div`,{className:`text-caption text-muted`,children:[t.account_id||t.provider||`—`,` · `,t.latency_ms,`ms`]}),(t.accounts||[]).length?(0,V.jsx)(`div`,{className:`space-y-0.5`,children:t.accounts.map(n=>(0,V.jsxs)(`div`,{className:`text-caption leading-4`,children:[(0,V.jsx)(`span`,{className:`mono font-medium`,children:n.account_id}),(0,V.jsxs)(`span`,{className:n.ok?`text-success`:`text-danger`,children:[` `,n.ok?e(`checkResultOK`):e(`checkResultFailed`)]}),(0,V.jsxs)(`span`,{className:`text-muted`,children:[` · `,n.latency_ms,`ms`]}),n.message?(0,V.jsx)(`span`,{className:`block break-all text-muted`,children:n.message}):null]},`${t.model}:${n.account_id}`))}):null,t.message?(0,V.jsx)(`div`,{className:`break-all text-caption text-muted`,children:t.message}):null]},t.model))})]}):null,R||n?(0,V.jsx)(f,{"data-gsap-reveal":!0,className:`overflow-hidden p-0`,children:(0,V.jsx)(fe,{})}):We.length===0?(0,V.jsx)(f,{"data-gsap-reveal":!0,className:`overflow-hidden p-0`,children:(0,V.jsx)(ee,{icon:(0,V.jsx)(i,{size:22}),title:W.length?e(`noModelsMatch`):e(`noProviders`),hint:W.length?e(`noModelsMatch`):e(`noModelsYet`)})}):(0,V.jsx)(`div`,{"data-gsap-reveal":!0,className:`space-y-4`,children:qe.map(t=>(0,V.jsx)(Ie,{group:t,t:e,collapsible:Be,collapsed:Be&&me.has(t.key),onToggle:()=>nt(t.key),onSettings:()=>ct(t),settingsDisabled:E||O,savingKey:_e,modelCheckChip:at,onToggleTraeMax:(e,t)=>void st(e,t),onDetails:Ce},t.key))}),(0,V.jsx)(xe,{model:Se?W.find(e=>Oe(e)===Oe(Se))||Se:null,t:e,onClose:()=>Ce(null)}),A&&et?(0,V.jsx)(we,{provider:A.provider,region:A.region,label:A.label,policy:et,checkinSupported:!!$e?.checkin,checkinTimezone:$e?.checkinTimezone,t:e,onClose:()=>j(null),onSaved:e=>lt(e)},`${A.provider}:${A.region}`):null,(0,V.jsx)(a,{total:Q.length,page:$,pageCount:Ke,pageSize:I,loading:R,pageSizeLabel:e(`logsPageSize`),pageLabel:e(`logsPage`,{page:$,pages:Ke}),prevLabel:e(`logsPrevPage`),nextLabel:e(`logsNextPage`),onPage:F,onPageSize:L})]})}export{Le as ProvidersPage}; \ No newline at end of file diff --git a/internal/webui/static/assets/ProvidersPage-D2CirlKt.js b/internal/webui/static/assets/ProvidersPage-D2CirlKt.js deleted file mode 100644 index 1e49d117..00000000 --- a/internal/webui/static/assets/ProvidersPage-D2CirlKt.js +++ /dev/null @@ -1 +0,0 @@ -import{a as e,c as t,n}from"./shim-mfK0Rmj6.js";import{t as r}from"./CaretRight.es-D5fytEam.js";import{i,r as a,t as o}from"./SearchBar-Cehxs-tj.js";import{n as s,pt as c,r as l}from"./useI18n-BSw4X3mq.js";import{n as u,t as d}from"./PageAlert-CaDjxveS.js";import{n as f}from"./useToggle-HDaAPzVy.js";import{t as p}from"./checkbox-Dkk25tsQ.js";import{t as m}from"./EmptyPanel-Bs-jQMvG.js";import{n as h,t as g}from"./FormRow-D36RiZfK.js";import{t as _}from"./modal-BVwBjYX-.js";import{n as ee,t as v}from"./number-field-D7UJ0QLF.js";import{t as y}from"./search-field-D9bfZlUZ.js";import{t as b}from"./CompactSwitch-DH1Gk66-.js";import{t as x}from"./table-BE40Giyo.js";import{D as S,O as te,S as ne,g as re,m as ie,n as ae,u as oe,x as se}from"./overview-m01k08K8.js";import{r as C}from"./gsap-C3sDxib7.js";import{Dt as w,Ft as ce,Lt as T,M as E,O as le,Wt as ue,b as D,d as de,f as fe,k as pe,v as O,y as k,zt as A}from"./index-C8_qeOs_.js";import{d as j,f as M}from"./format-B6SmebW-.js";import{t as me}from"./ProviderMark-IiAZTaQS.js";import{n as N,r as P}from"./provider-gHnttGKq.js";import{t as he}from"./FilterSelect-CNXkxdW1.js";var F=t(e(),1),I=new Map([[`bold`,F.createElement(F.Fragment,null,F.createElement(`path`,{d:`M79.51,144.49a12,12,0,1,1,17-17L112,143l47.51-47.52a12,12,0,0,1,17,17l-56,56a12,12,0,0,1-17,0ZM228,48V208a20,20,0,0,1-20,20H48a20,20,0,0,1-20-20V48A20,20,0,0,1,48,28H208A20,20,0,0,1,228,48Zm-24,4H52V204H204Z`}))],[`duotone`,F.createElement(F.Fragment,null,F.createElement(`path`,{d:`M216,48V208a8,8,0,0,1-8,8H48a8,8,0,0,1-8-8V48a8,8,0,0,1,8-8H208A8,8,0,0,1,216,48Z`,opacity:`0.2`}),F.createElement(`path`,{d:`M173.66,98.34a8,8,0,0,1,0,11.32l-56,56a8,8,0,0,1-11.32,0l-24-24a8,8,0,0,1,11.32-11.32L112,148.69l50.34-50.35A8,8,0,0,1,173.66,98.34ZM224,48V208a16,16,0,0,1-16,16H48a16,16,0,0,1-16-16V48A16,16,0,0,1,48,32H208A16,16,0,0,1,224,48ZM208,208V48H48V208H208Z`}))],[`fill`,F.createElement(F.Fragment,null,F.createElement(`path`,{d:`M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32Zm-34.34,77.66-56,56a8,8,0,0,1-11.32,0l-24-24a8,8,0,0,1,11.32-11.32L112,148.69l50.34-50.35a8,8,0,0,1,11.32,11.32Z`}))],[`light`,F.createElement(F.Fragment,null,F.createElement(`path`,{d:`M172.24,99.76a6,6,0,0,1,0,8.48l-56,56a6,6,0,0,1-8.48,0l-24-24a6,6,0,0,1,8.48-8.48L112,151.51l51.76-51.75A6,6,0,0,1,172.24,99.76ZM222,48V208a14,14,0,0,1-14,14H48a14,14,0,0,1-14-14V48A14,14,0,0,1,48,34H208A14,14,0,0,1,222,48Zm-12,0a2,2,0,0,0-2-2H48a2,2,0,0,0-2,2V208a2,2,0,0,0,2,2H208a2,2,0,0,0,2-2Z`}))],[`regular`,F.createElement(F.Fragment,null,F.createElement(`path`,{d:`M173.66,98.34a8,8,0,0,1,0,11.32l-56,56a8,8,0,0,1-11.32,0l-24-24a8,8,0,0,1,11.32-11.32L112,148.69l50.34-50.35A8,8,0,0,1,173.66,98.34ZM224,48V208a16,16,0,0,1-16,16H48a16,16,0,0,1-16-16V48A16,16,0,0,1,48,32H208A16,16,0,0,1,224,48ZM208,208V48H48V208H208Z`}))],[`thin`,F.createElement(F.Fragment,null,F.createElement(`path`,{d:`M170.83,101.17a4,4,0,0,1,0,5.66l-56,56a4,4,0,0,1-5.66,0l-24-24a4,4,0,0,1,5.66-5.66L112,154.34l53.17-53.17A4,4,0,0,1,170.83,101.17ZM220,48V208a12,12,0,0,1-12,12H48a12,12,0,0,1-12-12V48A12,12,0,0,1,48,36H208A12,12,0,0,1,220,48Zm-8,0a4,4,0,0,0-4-4H48a4,4,0,0,0-4,4V208a4,4,0,0,0,4,4H208a4,4,0,0,0,4-4Z`}))]]),L=new Map([[`bold`,F.createElement(F.Fragment,null,F.createElement(`path`,{d:`M208,28H48A20,20,0,0,0,28,48V208a20,20,0,0,0,20,20H208a20,20,0,0,0,20-20V48A20,20,0,0,0,208,28Zm-4,176H52V52H204Z`}))],[`duotone`,F.createElement(F.Fragment,null,F.createElement(`path`,{d:`M216,48V208a8,8,0,0,1-8,8H48a8,8,0,0,1-8-8V48a8,8,0,0,1,8-8H208A8,8,0,0,1,216,48Z`,opacity:`0.2`}),F.createElement(`path`,{d:`M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32Zm0,176H48V48H208V208Z`}))],[`fill`,F.createElement(F.Fragment,null,F.createElement(`path`,{d:`M224,48V208a16,16,0,0,1-16,16H48a16,16,0,0,1-16-16V48A16,16,0,0,1,48,32H208A16,16,0,0,1,224,48Z`}))],[`light`,F.createElement(F.Fragment,null,F.createElement(`path`,{d:`M208,34H48A14,14,0,0,0,34,48V208a14,14,0,0,0,14,14H208a14,14,0,0,0,14-14V48A14,14,0,0,0,208,34Zm2,174a2,2,0,0,1-2,2H48a2,2,0,0,1-2-2V48a2,2,0,0,1,2-2H208a2,2,0,0,1,2,2Z`}))],[`regular`,F.createElement(F.Fragment,null,F.createElement(`path`,{d:`M208,32H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32Zm0,176H48V48H208V208Z`}))],[`thin`,F.createElement(F.Fragment,null,F.createElement(`path`,{d:`M208,36H48A12,12,0,0,0,36,48V208a12,12,0,0,0,12,12H208a12,12,0,0,0,12-12V48A12,12,0,0,0,208,36Zm4,172a4,4,0,0,1-4,4H48a4,4,0,0,1-4-4V48a4,4,0,0,1,4-4H208a4,4,0,0,1,4,4Z`}))]]),R=F.forwardRef((e,t)=>F.createElement(c,{ref:t,...e,weights:I}));R.displayName=`CheckSquareIcon`;var z=R,B=F.forwardRef((e,t)=>F.createElement(c,{ref:t,...e,weights:L}));B.displayName=`SquareIcon`;var ge=B;function _e(e){let[t,n]=(0,F.useState)(e);e&&!t&&n(!0);let r=(0,F.useRef)(null),i=(0,F.useRef)(null),a=(0,F.useRef)(e);return(0,F.useLayoutEffect)(()=>{let t=r.current,o=i.current;if(!t||!o)return;if(a.current){a.current=!1;return}C.killTweensOf([t,o]);let s=t.getBoundingClientRect().height;if(e){C.set(t,{overflow:`hidden`});let e=t.scrollHeight;C.fromTo(t,{height:s===e?0:s},{height:e,duration:D(O.base),ease:k.out,onComplete:()=>C.set(t,{clearProps:`height,overflow`})}),C.fromTo(o,{autoAlpha:0,y:-6},{autoAlpha:1,y:0,duration:D(O.base),ease:k.out})}else C.set(t,{overflow:`hidden`,height:s}),C.to(o,{autoAlpha:0,y:-4,duration:D(O.fast),ease:k.inOut}),C.to(t,{height:0,duration:D(O.fast+.04),ease:k.inOut,onComplete:()=>n(!1)});return()=>{C.killTweensOf([t,o])}},[e,t]),{mounted:t,outerRef:r,innerRef:i}}function ve(){return te(`/api/provider-settings`)}function ye(e){return te(`/api/provider-settings`,{method:`PATCH`,body:JSON.stringify(e)})}function V(e,t){let n=new URLSearchParams({provider:e,region:t});return te(`/api/provider-settings/catalog?${n.toString()}`)}var H=n();function U(e){return e?e>=1e6?`${(e/1e6).toString().replace(/\.0$/,``)}M`:e>=1e3?`${Math.round(e/1e3)}k`:String(e):`—`}function W({label:e,value:t}){return(0,H.jsxs)(`div`,{className:`flex items-start justify-between gap-4 py-1.5`,children:[(0,H.jsx)(`span`,{className:`text-caption text-muted`,children:e}),(0,H.jsx)(`span`,{className:`min-w-0 text-right text-caption font-medium`,children:t})]})}function be({model:e,t,onClose:n}){if(!e)return null;let r=e.reasoning_options||[],i=e.catalog_context_length||e.default_context_length||e.context_length,a=e.catalog_context_length_max,o=M(e),s=String(e.provider||e.owned_by||`qoder`).trim().toLowerCase(),c=String(e.region||e.regions?.[0]||``).trim().toLowerCase(),l=N(s,c||void 0,t),u=s===`trae`?P(e):void 0,d=e.supports_images===!0?t(`imageInputDeclared`):e.supports_images===!1?t(`imageInputUnsupported`):t(`imageInputNotDeclared`),f=u?.prompt_max_tokens||e.prompt_max_tokens,p=u?.max_output_tokens||e.max_output_tokens;return(0,H.jsx)(_.Root,{isOpen:!0,onOpenChange:e=>{e||n()},children:(0,H.jsx)(_.Backdrop,{variant:`blur`,children:(0,H.jsx)(_.Container,{size:`md`,scroll:`inside`,children:(0,H.jsxs)(_.Dialog,{children:[(0,H.jsxs)(_.Header,{className:`items-start justify-between gap-4 px-5 pt-5`,children:[(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(`div`,{className:`truncate text-section`,children:e.display_name||e.id}),o?(0,H.jsx)(E,{size:`sm`,variant:`soft`,color:`success`,children:t(`modelFree`)}):null]}),(0,H.jsx)(`div`,{className:`mono mt-1 truncate text-caption text-muted`,children:e.id})]}),(0,H.jsx)(_.CloseTrigger,{"aria-label":t(`close`),className:`grid size-8 shrink-0 place-items-center rounded-lg text-muted hover:bg-surface-secondary`,children:(0,H.jsx)(w,{size:16})})]}),(0,H.jsxs)(_.Body,{className:`space-y-3 px-5 pb-5`,children:[(0,H.jsxs)(`section`,{className:`divide-y divide-separator rounded-lg border border-separator px-3 py-1`,children:[(0,H.jsx)(W,{label:t(`providerCol`),value:l}),(0,H.jsx)(W,{label:t(`contextWindowCol`),value:(0,H.jsxs)(`span`,{className:`mono`,children:[U(i),a&&a!==i?` → ${U(a)}`:``]})}),f?(0,H.jsx)(W,{label:t(`promptMaxTokens`),value:(0,H.jsx)(`span`,{className:`mono`,children:U(f)})}):null,p?(0,H.jsx)(W,{label:t(`maxOutputTokens`),value:(0,H.jsx)(`span`,{className:`mono`,children:U(p)})}):null,(0,H.jsx)(W,{label:t(`imageInput`),value:d})]}),(0,H.jsxs)(`section`,{children:[(0,H.jsx)(`div`,{className:`mb-1 text-caption font-medium text-muted`,children:t(`reasoningLevels`)}),r.length?(0,H.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:r.map(e=>(0,H.jsx)(E,{size:`sm`,variant:`soft`,color:`default`,children:(0,H.jsx)(`span`,{className:`mono`,children:e})},e))}):(0,H.jsx)(`div`,{className:`text-caption text-muted`,children:e.reasoning_type?t(`reasoningFixed`,{type:e.reasoning_type}):t(`noReasoningLevels`)})]})]})]})})})})}function xe({catalog:e,selected:t,onChange:n,isDisabled:r,t:i}){let[a,o]=(0,F.useState)(``),[s,c]=(0,F.useState)(t),u=(0,F.useMemo)(()=>new Set(t),[t]),d=(0,F.useMemo)(()=>{let t=new Set(s),n=a.trim().toLowerCase(),r=(e||[]).filter(e=>!n||e.toLowerCase().includes(n));return[...r.filter(e=>t.has(e)),...r.filter(e=>!t.has(e))]},[e,a,s]),f=(0,F.useMemo)(()=>{if(!e)return[];let n=new Set(e);return t.filter(e=>!n.has(e))},[e,t]),m=e?.length??0,h=t.filter(e=>!f.includes(e)).length;function g(e){o(e),c(t)}function _(e,r){n(r?[...t,e]:t.filter(t=>t!==e))}function ee(){let e=new Set(t);d.forEach(t=>e.add(t)),n([...e])}function v(){let e=new Set(d);n(t.filter(t=>!e.has(t)))}return(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(y,{"aria-label":i(`modelPickerSearch`),value:a,onChange:g,isDisabled:r,className:`min-w-0 flex-1 basis-48`,children:(0,H.jsxs)(y.Group,{children:[(0,H.jsx)(y.SearchIcon,{}),(0,H.jsx)(y.Input,{placeholder:i(`modelPickerSearch`)}),(0,H.jsx)(y.ClearButton,{})]})}),(0,H.jsx)(`span`,{className:`mono shrink-0 text-caption text-muted`,children:i(`modelPickerCount`,{selected:h,total:m})}),(0,H.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,H.jsxs)(l,{size:`sm`,variant:`ghost`,isDisabled:r||d.length===0,onPress:ee,children:[(0,H.jsx)(z,{size:14}),i(`modelPickerSelectAll`)]}),(0,H.jsxs)(l,{size:`sm`,variant:`ghost`,isDisabled:r||t.length===0,onPress:v,children:[(0,H.jsx)(ge,{size:14}),i(`modelPickerClear`)]})]})]}),(0,H.jsxs)(`div`,{className:`max-h-[300px] overflow-y-auto overscroll-contain rounded-lg bg-surface-secondary p-1`,children:[e===null?(0,H.jsx)(`p`,{className:`px-2.5 py-2 text-caption text-muted`,children:i(`refreshing`)}):null,f.map(e=>(0,H.jsxs)(`div`,{className:`flex items-center gap-2.5 rounded-md px-2.5 py-1.5`,children:[(0,H.jsx)(`span`,{className:`mono min-w-0 flex-1 truncate text-body text-muted line-through`,children:e}),(0,H.jsx)(`span`,{className:`shrink-0 text-caption text-warning`,children:i(`modelPickerOffline`)}),(0,H.jsx)(l,{isIconOnly:!0,size:`sm`,variant:`ghost`,isDisabled:r,"aria-label":i(`modelPickerRemove`,{model:e}),onPress:()=>_(e,!1),children:(0,H.jsx)(w,{size:14})})]},`offline-${e}`)),d.map(e=>(0,H.jsx)(p,{isSelected:u.has(e),isDisabled:r,onChange:t=>_(e,t),className:`flex w-full cursor-pointer rounded-md px-2.5 py-1.5 transition-colors hover:bg-default`,children:(0,H.jsxs)(p.Content,{className:`flex min-w-0 flex-1 items-center gap-2.5`,children:[(0,H.jsx)(p.Control,{children:(0,H.jsx)(p.Indicator,{})}),(0,H.jsx)(`span`,{className:`mono min-w-0 truncate text-body text-foreground`,children:e})]})},e)),e!==null&&d.length===0?(0,H.jsx)(`p`,{className:`px-2.5 py-2 text-caption text-muted`,children:i(m===0?`noAccountModels`:`modelPickerNoMatch`)}):null]})]})}function Se(e){let t=e.toLowerCase();return![`trae`,`kimi`,`codearts`,`minimaxcode`].includes(t)}function G(e){let t=e.toLowerCase();return t===`workbuddy`||t===`trae`}function K(e){return e.toLowerCase()===`qoder`?`11:00`:`01:00`}function Ce({provider:e,region:t,label:n,policy:r,checkinSupported:i,checkinTimezone:a,t:o,onClose:s,onSaved:c}){let[d,f]=(0,F.useState)(r.credit_floor==null?`inherit`:`custom`),[p,m]=(0,F.useState)(r.credit_floor??0),[y,x]=(0,F.useState)(r.percent_floor==null?`inherit`:`custom`),[S,te]=(0,F.useState)(r.percent_floor??0),[ne,re]=(0,F.useState)(r.proxy_url||``),[ie,ae]=(0,F.useState)(r.drop_system_prompt??Se(e)),[oe,se]=(0,F.useState)(Object.entries(r.model_aliases||{}).map(([e,t])=>({alias:e,model:t}))),[C,ce]=(0,F.useState)({alias:``,model:``}),[T,le]=(0,F.useState)(!!r.models_restricted||!!(r.enabled_models||[]).length),[ue,D]=(0,F.useState)(r.enabled_models||[]),{mounted:de,outerRef:fe,innerRef:pe}=_e(T),[O,k]=(0,F.useState)(null),[A,j]=(0,F.useState)(``),[M,N]=(0,F.useState)(r.checkin_time||(e.toLowerCase()===`qoder`?`11:00`:`01:00`)),[P,he]=(0,F.useState)(r.checkin_auto!==!1),[I,L]=(0,F.useState)(!1),[R,z]=(0,F.useState)(``);(0,F.useEffect)(()=>{let n=!1;return V(e,t).then(e=>{n||(k((e.data||[]).map(e=>e.id)),j(``))}).catch(e=>{n||(k([]),j(e instanceof Error?e.message:String(e)))}),()=>{n=!0}},[e,t]);async function B(n){if(n?.preventDefault(),d===`custom`&&(!Number.isFinite(p)||p<0)){z(o(`creditFloorInvalid`));return}if(y===`custom`&&(!Number.isFinite(S)||S<0||S>100)){z(o(`percentFloorInvalid`));return}if(i&&!P&&!/^([01]\d|2[0-3]):[0-5]\d$/.test(M)){z(o(`checkinTimeInvalid`));return}if(T&&ue.length===0){z(o(`providerModelsEmpty`));return}z(``),L(!0);try{let n={provider:e,region:t,credit_floor:d===`custom`?p:null,percent_floor:y===`custom`?S:null,proxy_url:ne.trim(),drop_system_prompt:ie,model_aliases:Object.fromEntries(oe.filter(e=>e.alias.trim()&&e.model.trim()).map(e=>[e.alias.trim(),e.model.trim()])),enabled_models:T?ue:[],models_restricted:T,checkin_time:i?M:``,checkin_auto:i?P:!1};c((await ye(n)).data||n),s()}catch(e){z(e instanceof Error?e.message:String(e))}finally{L(!1)}}return(0,H.jsx)(_.Root,{isOpen:!0,onOpenChange:e=>{!e&&!I&&s()},children:(0,H.jsx)(_.Backdrop,{variant:`blur`,children:(0,H.jsx)(_.Container,{placement:`center`,size:`lg`,scroll:`inside`,children:(0,H.jsxs)(_.Dialog,{className:`w-full sm:w-[42rem] sm:max-w-[calc(100vw-2rem)]`,children:[(0,H.jsxs)(_.Header,{className:`items-start justify-between gap-4 px-6 pt-6`,children:[(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(_.Heading,{className:`text-section font-semibold`,children:o(`providerSettingsTitle`)}),(0,H.jsx)(`p`,{className:`mt-1.5 text-body font-normal leading-6 text-muted`,children:o(`providerSettingsHint`)}),(0,H.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(E,{size:`sm`,variant:`soft`,children:(0,H.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,H.jsx)(me,{provider:e,size:14}),(0,H.jsx)(`span`,{children:n})]})}),(0,H.jsx)(`span`,{className:`mono text-caption text-muted`,children:t||`any`})]})]}),(0,H.jsx)(_.CloseTrigger,{isDisabled:I,"aria-label":o(`close`),className:`grid size-9 shrink-0 place-items-center rounded-lg text-muted hover:bg-surface-secondary`,children:(0,H.jsx)(w,{size:18})})]}),(0,H.jsxs)(_.Body,{className:`px-6 pb-2 pt-1`,children:[R?(0,H.jsxs)(u,{status:`danger`,className:`mb-4`,children:[(0,H.jsx)(u.Indicator,{}),(0,H.jsx)(u.Content,{children:(0,H.jsx)(u.Title,{children:R})})]}):null,A?(0,H.jsxs)(u,{status:`warning`,className:`mb-4`,children:[(0,H.jsx)(u.Indicator,{}),(0,H.jsx)(u.Content,{children:(0,H.jsx)(u.Title,{children:A})})]}):null,(0,H.jsxs)(ee,{className:`space-y-4`,onSubmit:e=>void B(e),children:[(0,H.jsx)(g,{label:o(`creditFloor`),hint:o(`creditFloorHint`),align:`start`,children:(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(b,{isSelected:d===`custom`,isDisabled:I,ariaLabel:o(`creditFloorCustom`),label:o(`creditFloorCustom`),onChange:e=>f(e?`custom`:`inherit`)}),d===`custom`?(0,H.jsx)(v,{value:p,onChange:e=>m(e??0),minValue:0,step:1,isDisabled:I,isRequired:!0,children:(0,H.jsxs)(v.Group,{children:[(0,H.jsx)(v.DecrementButton,{}),(0,H.jsx)(v.Input,{"aria-label":o(`creditFloor`)}),(0,H.jsx)(v.IncrementButton,{})]})}):(0,H.jsx)(`p`,{className:`text-caption text-muted`,children:o(`creditFloorInheritHint`)})]})}),(0,H.jsx)(g,{label:o(`percentFloor`),hint:o(`percentFloorHint`),align:`start`,children:(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsx)(b,{isSelected:y===`custom`,isDisabled:I,ariaLabel:o(`percentFloorCustom`),label:o(`percentFloorCustom`),onChange:e=>x(e?`custom`:`inherit`)}),y===`custom`?(0,H.jsx)(v,{value:S,onChange:e=>te(e??0),minValue:0,maxValue:100,step:1,isDisabled:I,isRequired:!0,children:(0,H.jsxs)(v.Group,{children:[(0,H.jsx)(v.DecrementButton,{}),(0,H.jsx)(v.Input,{"aria-label":o(`percentFloor`)}),(0,H.jsx)(v.IncrementButton,{})]})}):(0,H.jsx)(`p`,{className:`text-caption text-muted`,children:o(`percentFloorInheritHint`)})]})}),(0,H.jsx)(g,{label:o(`proxyUrl`),hint:o(`proxyUrlHint`),children:(0,H.jsx)(h,{value:ne,onChange:e=>re(e.target.value),placeholder:o(`proxyUrlPlaceholder`),"aria-label":o(`proxyUrl`),disabled:I})}),G(e)?(0,H.jsx)(g,{label:o(`dropSystemPrompt`),hint:o(e===`trae`?`dropSystemPromptTraeHint`:`dropSystemPromptHint`),children:(0,H.jsx)(b,{isSelected:ie,isDisabled:I,ariaLabel:o(`dropSystemPrompt`),onChange:ae})}):null,(0,H.jsx)(g,{align:`start`,label:o(`accountModelAliases`),hint:o(`accountModelAliasesHint`),children:(0,H.jsxs)(`div`,{className:`space-y-2`,children:[oe.map(e=>(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,H.jsxs)(`span`,{className:`mono min-w-0 truncate text-body`,children:[e.alias,` → `,e.model]}),(0,H.jsx)(l,{size:`sm`,variant:`ghost`,isDisabled:I,onPress:()=>se(t=>t.filter(t=>t.alias!==e.alias)),children:o(`modelAliasRemove`)})]},e.alias)),(0,H.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-[1fr_1fr_auto]`,children:[(0,H.jsx)(h,{"aria-label":o(`modelAliasName`),value:C.alias,onChange:e=>ce(t=>({...t,alias:e.target.value})),placeholder:o(`modelAliasPlaceholder`),disabled:I}),(0,H.jsx)(h,{"aria-label":o(`modelAliasTarget`),value:C.model,onChange:e=>ce(t=>({...t,model:e.target.value})),placeholder:o(`accountModelAliasTargetPlaceholder`),disabled:I}),(0,H.jsx)(l,{size:`sm`,variant:`secondary`,isDisabled:I||!C.alias.trim()||!C.model.trim(),onPress:()=>{se(e=>[...e.filter(e=>e.alias!==C.alias.trim()),{alias:C.alias.trim(),model:C.model.trim()}]),ce({alias:``,model:``})},children:o(`modelAliasAdd`)})]})]})}),(0,H.jsxs)(`section`,{className:`space-y-3 pt-1`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`div`,{className:`text-body font-medium text-foreground`,children:o(`enabledModels`)}),(0,H.jsx)(`p`,{className:`mt-0.5 text-caption leading-5 text-muted`,children:o(`enabledModelsHint`)})]}),(0,H.jsx)(b,{isSelected:T,isDisabled:I,ariaLabel:o(`restrictModels`),label:o(T?`restrictModels`:`allModels`),onChange:le})]}),de?(0,H.jsx)(`div`,{ref:fe,children:(0,H.jsx)(`div`,{ref:pe,children:(0,H.jsx)(xe,{catalog:O,selected:ue,onChange:D,isDisabled:I,t:o})})}):null]}),i?(0,H.jsx)(g,{label:o(`autoCheckinTime`),hint:o(`checkinScheduleHint`),children:(0,H.jsxs)(`div`,{className:`space-y-2`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,H.jsx)(`span`,{className:`text-caption text-muted`,children:o(`checkinAutoMode`)}),(0,H.jsx)(b,{isSelected:P,isDisabled:I,ariaLabel:o(`checkinAutoMode`),onChange:he})]}),(0,H.jsx)(h,{type:`time`,value:P?K(e):M,onChange:e=>N(e.target.value),"aria-label":o(`autoCheckinTime`),disabled:I||P,required:!P}),a?(0,H.jsx)(`p`,{className:`text-caption text-muted`,children:o(`checkinServerClock`,{timezone:a})}):null,P?(0,H.jsx)(`p`,{className:`text-caption text-muted`,children:o(`checkinAutoFallbackHint`)}):null]})}):null]})]}),(0,H.jsxs)(_.Footer,{className:`justify-end gap-2 px-6 pb-6`,children:[(0,H.jsx)(l,{variant:`ghost`,isDisabled:I,onPress:s,children:o(`cancel`)}),(0,H.jsx)(l,{isPending:I,onPress:()=>void B(),children:o(`save`)})]})]})})})})}function we(e){let t=[];for(let n of e)for(let e of n.regions||[])e?.id&&t.push({value:`${n.id}:${e.id}`,provider:n.id,region:e.id,checkin:!!e.checkin,checkinTimezone:e.checkin?.timezone===`Local`?`Asia/Shanghai`:e.checkin?.timezone});return t}function Te(e,t){let n=new Set;for(let r of e){let e=String(r.provider||`qoder`).trim().toLowerCase(),i=String(r.region||``).trim().toLowerCase(),a=t.find(t=>t.provider===e&&t.region===i)||t.find(t=>t.provider===e);a&&n.add(a.value)}return Array.from(n)}function q(e){return e.settings_key||e.id}function J(e){return String(e.provider||e.owned_by||`qoder`).trim().toLowerCase()}function Ee(e){let t=String(e.region||``).trim().toLowerCase();if(t)return t;let n=e.regions||[];return String(n[0]||``).trim().toLowerCase()}function De(e){return`${J(e)}:${Ee(e)||`any`}:${e.settings_key||e.id}:${e.native_model||e.mapped_key||``}`}function Oe(e){let t=e.route_display_name||``;return t&&t!==(e.display_name||e.id)?t:``}function ke(e,t){let n=new Map;for(let r of e){let e=J(r),i=Ee(r),a=`${e}:${i||`any`}`,o=n.get(a);o||(o={key:a,provider:e,region:i,label:N(e,i||void 0,t),models:[]},n.set(a,o)),o.models.push(r)}return Array.from(n.values())}function Ae(e){let t=e.toLowerCase();return![`trae`,`kimi`,`codearts`,`minimaxcode`].includes(t)}function je(e,t){return e.region&&e.region!==`any`?e.region:t.find(t=>t.provider===e.provider)?.region||``}function Me(e,t){let n=new Map(t.map((e,t)=>[`${e.provider}:${e.region||`any`}`,t]));return[...e].sort((e,t)=>{let r=n.get(e.key),i=n.get(t.key);return r!=null&&i!=null?r-i:r==null?i==null?0:1:-1})}function Ne(e,t,n){return e.find(e=>e.provider===t&&(e.region||`any`)===n)||{provider:t,region:n,credit_floor:null,percent_floor:null,proxy_url:``,drop_system_prompt:Ae(t),model_aliases:{},enabled_models:[],models_restricted:!1,checkin_time:`09:00`,checkin_auto:!0}}function Pe({model:e,saving:t,t:n,variant:r=`table`,onToggleTraeMax:i}){let a=J(e),o=r===`card`,s=e.catalog_context_length||e.context_length,c=e.catalog_context_length_max,l=!!(c&&c!==s),u=e.reasoning_options||[],d=(a===`trae`||a===`qoder`)&&e.supports_max_mode,f=u.length?u.join(` / `):e.reasoning_type?n(`reasoningFixed`,{type:e.reasoning_type}):`—`;return(0,H.jsxs)(`div`,{className:o?`flex min-w-0 flex-col gap-2`:`flex min-w-0 flex-col gap-1`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,H.jsxs)(`span`,{className:`mono text-caption font-medium`,children:[U(s),l?` → ${U(c)}`:``]}),d?(0,H.jsx)(b,{isSelected:!!e.max_mode,isDisabled:t,ariaLabel:`${e.id} ${n(`maxMode`)}`,onChange:t=>i(e,t)}):null]}),(0,H.jsx)(`div`,{className:`min-w-0 truncate text-caption text-muted`,title:f,children:f})]})}function Fe({model:e,t,onDetails:n}){return(0,H.jsxs)(l,{size:`sm`,variant:`ghost`,onPress:()=>n(e),children:[(0,H.jsx)(T,{size:14}),t(`modelDetails`)]})}function Y({group:e,t}){return(0,H.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,H.jsx)(`div`,{className:`grid size-8 shrink-0 place-items-center rounded-lg bg-surface text-foreground`,children:(0,H.jsx)(me,{provider:e.provider,size:16})}),(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`div`,{className:`truncate text-body font-semibold`,children:e.label}),(0,H.jsx)(`div`,{className:`text-caption text-muted`,children:t(`usageModelCount`,{count:e.models.length})})]})]})}function Ie({group:e,t,collapsible:n,collapsed:i,onToggle:a,onSettings:o,settingsDisabled:s,savingKey:c,modelCheckChip:u,onToggleTraeMax:d,onDetails:p}){let m=(0,F.useId)(),{mounted:h,outerRef:g,innerRef:_}=_e(!n||!i);return(0,H.jsxs)(f,{className:`overflow-hidden p-0`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 bg-surface-secondary px-4 py-3 ${h?`border-b border-separator`:``}`,children:[n?(0,H.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center justify-between gap-3 rounded-lg text-left outline-none focus-visible:ring-2 focus-visible:ring-focus`,"aria-expanded":!i,"aria-controls":m,"aria-label":`${t(i?`providerExpand`:`providerCollapse`)} ${e.label}`,onClick:a,children:[(0,H.jsx)(Y,{group:e,t}),(0,H.jsx)(r,{size:16,className:`shrink-0 text-muted transition-transform ${i?``:`rotate-90`}`,"aria-hidden":!0})]}):(0,H.jsx)(`div`,{className:`flex min-w-0 flex-1 items-center`,children:(0,H.jsx)(Y,{group:e,t})}),(0,H.jsxs)(l,{className:`shrink-0`,size:`sm`,variant:`ghost`,isDisabled:s,onPress:o,children:[(0,H.jsx)(A,{size:14}),t(`providerSettingsOpen`)]})]}),h?(0,H.jsx)(`div`,{id:m,ref:g,className:`min-w-0`,children:(0,H.jsx)(`div`,{ref:_,children:e.models.length===0?(0,H.jsx)(`div`,{className:`px-4 py-8 text-center text-caption text-muted`,children:t(`noModelsYet`)}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:`divide-y divide-separator lg:hidden`,children:e.models.map(e=>{let n=c===q(e),r=j(e),i=M(e);return(0,H.jsxs)(`article`,{className:`space-y-3 px-4 py-4`,children:[(0,H.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,H.jsx)(`span`,{className:`status-dot mt-1.5`,"data-state":e.stale?void 0:`ok`}),(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(`div`,{className:`truncate font-medium`,children:e.display_name||e.id}),i?(0,H.jsx)(E,{size:`sm`,variant:`soft`,color:`success`,children:t(`modelFree`)}):null,r?(0,H.jsx)(`span`,{className:`mono text-caption text-muted`,children:r}):null]}),(0,H.jsx)(`div`,{className:`mono mt-0.5 truncate text-caption text-muted`,children:e.id}),Oe(e)?(0,H.jsx)(`div`,{className:`mt-0.5 text-caption text-muted`,children:t(`routedTo`,{model:Oe(e)})}):null]})]}),u(e)]}),(0,H.jsx)(`div`,{className:`mono break-all text-caption text-muted`,children:e.mapped_key||e.native_model||e.id}),(0,H.jsx)(Pe,{model:e,saving:n,t,variant:`card`,onToggleTraeMax:d}),(0,H.jsx)(Fe,{model:e,t,onDetails:p})]},De(e))})}),(0,H.jsx)(x,{className:`hidden min-w-0 lg:block`,children:(0,H.jsx)(x.ScrollContainer,{className:`min-w-0 overflow-x-auto`,children:(0,H.jsxs)(x.Content,{"aria-label":`${e.label} ${t(`availableModels`)}`,className:`min-w-[58rem]`,children:[(0,H.jsxs)(x.Header,{children:[(0,H.jsx)(x.Column,{isRowHeader:!0,children:t(`modelCol`)}),(0,H.jsx)(x.Column,{children:t(`requestIdCol`)}),(0,H.jsx)(x.Column,{children:t(`qoderKeyCol`)}),(0,H.jsx)(x.Column,{children:t(`modelDefaultsCol`)}),(0,H.jsx)(x.Column,{children:t(`stateCol`)}),(0,H.jsx)(x.Column,{children:t(`modelDetailsCol`)})]}),(0,H.jsx)(x.Body,{children:e.models.map(e=>{let n=c===q(e),r=j(e),i=M(e);return(0,H.jsxs)(x.Row,{children:[(0,H.jsx)(x.Cell,{children:(0,H.jsxs)(`div`,{className:`flex items-center gap-3 py-1`,children:[(0,H.jsx)(`span`,{className:`status-dot`,"data-state":e.stale?void 0:`ok`}),(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(`div`,{className:`font-medium`,children:e.display_name||e.id}),i?(0,H.jsx)(E,{size:`sm`,variant:`soft`,color:`success`,children:t(`modelFree`)}):null,r?(0,H.jsx)(`span`,{className:`mono text-caption text-muted`,children:r}):null]}),Oe(e)?(0,H.jsx)(`div`,{className:`mt-0.5 text-caption text-muted`,children:t(`routedTo`,{model:Oe(e)})}):null]})]})}),(0,H.jsx)(x.Cell,{children:(0,H.jsx)(`span`,{className:`mono text-caption font-medium`,children:e.id})}),(0,H.jsx)(x.Cell,{children:(0,H.jsx)(`span`,{className:`mono text-caption text-muted`,children:e.mapped_key||e.native_model||e.id})}),(0,H.jsx)(x.Cell,{children:(0,H.jsx)(Pe,{model:e,saving:n,t,variant:`table`,onToggleTraeMax:d})}),(0,H.jsx)(x.Cell,{children:u(e)}),(0,H.jsx)(x.Cell,{children:(0,H.jsx)(Fe,{model:e,t,onDetails:p})})]},De(e))})})]})})})]})})}):null]})}function Le(){let{t:e}=s(),{overview:t,loading:n}=le(),[r,c]=(0,F.useState)(``),[u,p]=(0,F.useState)(``),[h,g]=(0,F.useState)([]),[_,ee]=(0,F.useState)(!0),[v,y]=(0,F.useState)(null),[b,te]=(0,F.useState)(!0),[C,w]=(0,F.useState)([]),[T,D]=(0,F.useState)(!0),[O,k]=(0,F.useState)(!1),[A,j]=(0,F.useState)(null),[M,me]=(0,F.useState)(new Set),[P,I]=(0,F.useState)(1),[L,R]=(0,F.useState)(50),[z,B]=(0,F.useState)(!1),[ge,_e]=(0,F.useState)(``),[ye,V]=(0,F.useState)(``),[U,W]=(0,F.useState)(!1),[xe,Se]=(0,F.useState)(null),[G,K]=(0,F.useState)([]),[Oe,Ae]=(0,F.useState)(!0),[Pe,Fe]=(0,F.useState)(!1),[Y,Le]=(0,F.useState)(null);(0,F.useEffect)(()=>{let e=!1;return ie(void 0,`regional`).then(t=>{e||K(t.data||[])}).catch(()=>void 0).finally(()=>{e||Ae(!1)}),re().then(t=>{e||g(we(t.data||[]))}).catch(()=>void 0).finally(()=>{e||ee(!1)}),oe(!1).then(t=>{e||y(t.data||[])}).catch(()=>{e||y(null)}).finally(()=>{e||te(!1)}),ve().then(t=>{e||w(t.data||[])}).catch(t=>{e||(k(!0),W(!0),V(t instanceof Error?t.message:String(t)))}).finally(()=>{e||D(!1)}),()=>{e=!0}},[]);let Re=(0,F.useMemo)(()=>v?Te(v,h):null,[v,h]),ze=(0,F.useMemo)(()=>{let e=new Set;for(let t of G){let n=J(t),r=Ee(t),i=h.find(e=>e.provider===n&&e.region===r)||h.find(e=>e.provider===n);i&&e.add(i.value)}return Array.from(e)},[G,h]),X=(0,F.useMemo)(()=>{let e=Re&&Re.length?Re:ze;return e.length?h.filter(t=>e.includes(t.value)):[]},[Re,ze,h]),Z=u===``||X.some(e=>e.value===u)?u:X[0]?.value||``,Be=Z===``,Q=(0,F.useMemo)(()=>{let t=r.trim().toLowerCase(),[n,i]=Z.includes(`:`)?Z.split(`:`,2):[Z,``];return G.filter(r=>{let a=J(r),o=Ee(r);if(n&&a!==n||i&&o!==i)return!1;if(!t)return!0;let s=N(a,o||void 0,e);return`${r.display_name||``} ${r.id} ${r.mapped_key||``} ${a} ${s} ${r.owned_by||``} ${o} ${r.credits||``} ${r.free?`free`:``}`.toLowerCase().includes(t)})},[r,G,Z,e]),Ve=[r,Z,L].join(`\0`),[He,Ue]=(0,F.useState)(Ve);He!==Ve&&(Ue(Ve),I(1));let We=(0,F.useMemo)(()=>{let t=ke(Q,e);if(r.trim())return Me(t,X);let n=new Set(t.map(e=>e.key)),i=r=>{let i=`${r.provider}:${r.region||`any`}`;n.has(i)||(n.add(i),t.push({key:i,provider:r.provider,region:r.region,label:N(r.provider,r.region,e),models:[]}))};if(Z){let e=X.find(e=>e.value===Z);e&&i(e)}else for(let e of X)i(e);for(let r of C){if(!r.models_restricted||!r.provider||!r.region||r.region===`any`)continue;if(Z){let[e,t]=Z.includes(`:`)?Z.split(`:`,2):[Z,``];if(e&&e!==r.provider||t&&t!==r.region)continue}let i=`${r.provider}:${r.region}`;n.has(i)||(n.add(i),t.push({key:i,provider:r.provider,region:r.region,label:N(r.provider,r.region,e),models:[]}))}return Me(t,X)},[Q,r,Z,X,C,e]),Ge=(0,F.useMemo)(()=>{let e=[],t=[],n=0;for(let r of We)t.length>0&&n+r.models.length>L&&(e.push(t),t=[],n=0),t.push(r),n+=r.models.length;return t.length>0&&e.push(t),e.length>0?e:[[]]},[We,L]),Ke=Math.max(1,Ge.length),$=Math.min(He===Ve?Math.max(1,P):1,Ke);P!==$&&I($);let qe=Ge[$-1]??[],Je=Ge.slice(0,$-1).reduce((e,t)=>e+t.reduce((e,t)=>e+t.models.length,0),0),Ye=qe.reduce((e,t)=>e+t.models.length,0),Xe=Q.length===0?0:Je+1,Ze=Q.length===0?0:Je+Ye,Qe=Q.length?e(`logsShownTotal`,{shown:`${Xe}–${Ze}`,total:Q.length}):e(`shownTotal`,{shown:0,total:G.length}),$e=A?h.find(e=>e.provider===A.provider&&e.region===A.region):void 0,et=A?Ne(C,A.provider,A.region):null;if(n&&!t||Oe||b||_)return(0,H.jsx)(de,{});function tt(e,t){let n=q(e),r=J(e),i=G.map(e=>{if(q(e)!==n||J(e)!==r)return e;let i=e.reasoning_effort||e.reasoning_default||``,a=e.catalog_context_length||e.default_context_length||e.context_length||0,o=e.catalog_context_length_max||0;return{...e,max_mode:t,context_length:t&&o?o:a,default_context_length:a,context_custom:r===`qoder`?t:t||!!(i&&i!==e.reasoning_default)}});K(i)}function nt(e){me(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}async function rt(){B(!0),V(``),W(!1);try{let e=await se(void 0,`regional`);K(e.data||[])}catch(e){W(!0),V(e instanceof Error?e.message:String(e))}finally{B(!1)}}function it(e){return Y?.results.find(t=>t.model===e.id)}function at(t){let n=it(t);if(!n)return(0,H.jsx)(E,{size:`sm`,variant:`soft`,color:`default`,children:e(`checkNotRun`)});let r=n.accounts||[],i=r.length?r.filter(e=>e.ok).length:+!!n.ok,a=r.length||n.attempt_count||+!!n.ok;return(0,H.jsxs)(E,{size:`sm`,variant:`soft`,color:n.ok?`success`:`danger`,children:[n.ok?e(`checkResultOK`):e(`checkResultFailed`),a?` · ${e(`checkPassedAccounts`,{passed:i,total:a})}`:``]})}async function ot(){if(!G.length){V(e(`checkModelsEmpty`)),W(!1);return}Fe(!0),Le(null),V(``),W(!1);try{let t=await ae(G.map(e=>e.id));Le(t),V(e(`checkModelsSummary`,{passed:t.summary.passed,failed:t.summary.failed,total:t.summary.total,elapsed:t.elapsed_ms}))}catch(e){W(!0),V(e instanceof Error?e.message:String(e))}finally{Fe(!1)}}async function st(t,n){if(!t.supports_max_mode){W(!0),V(e(`contextMaxUnavailable`));return}let r=q(t),i=J(t);_e(r),V(``),W(!1);try{await S(i,r,n,t.catalog_context_length_max),tt(t,n),V(e(n?`contextMaxOn`:`contextMaxOff`,{model:t.id}))}catch(e){W(!0),V(e instanceof Error?e.message:String(e))}finally{_e(``)}}function ct(t){if(T||O){W(!0),V(e(O?`providerSettingsLoadFailed`:`refreshing`));return}let n=je(t,h);if(!n&&h.some(e=>e.provider===t.provider)){W(!0),V(e(`providerSettingsRegionMissing`));return}j({provider:t.provider,region:n,label:t.label})}function lt(t){w(e=>[...e.filter(e=>e.provider!==t.provider||(e.region||`any`)!==(t.region||`any`)),t]),W(!1),V(e(`providerSettingsSaved`)),ne(void 0,`regional`).then(e=>K(e.data||[])).catch(t=>{W(!0),V(e(`providerSettingsSavedRefreshFailed`,{message:t instanceof Error?t.message:String(t)}))})}return(0,H.jsxs)(`div`,{className:`space-y-6`,children:[(0,H.jsxs)(`section`,{className:`grid gap-5 pb-6 lg:grid-cols-[minmax(0,1fr)_auto] lg:items-end`,children:[(0,H.jsxs)(`div`,{"data-gsap-reveal":!0,children:[(0,H.jsx)(`h2`,{className:`text-title font-semibold`,children:e(`availableModels`)}),(0,H.jsx)(`p`,{className:`mt-1 text-body text-muted`,children:G.length?Qe:e(`noModelsYet`)})]}),(0,H.jsxs)(`div`,{"data-gsap-reveal":!0,className:`flex min-w-0 flex-col gap-2 sm:flex-row sm:flex-wrap sm:items-center`,children:[(0,H.jsx)(o,{className:`w-full min-w-0 sm:w-72`,value:r,onChange:c,placeholder:e(`filterPh`),ariaLabel:e(`filter`)}),(0,H.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[X.length?(0,H.jsx)(he,{ariaLabel:e(`providerCol`),value:Z,onChange:p,options:[{id:``,label:e(`providerFilterAll`)},...X.map(t=>({id:t.value,label:N(t.provider,t.region,e)}))]}):null,(0,H.jsxs)(l,{size:`sm`,variant:`secondary`,isPending:z||Pe,onPress:()=>void rt(),children:[(0,H.jsx)(ue,{size:14}),e(z?`refreshing`:`refresh`)]}),(0,H.jsxs)(pe,{children:[(0,H.jsx)(pe.Trigger,{children:(0,H.jsxs)(l,{size:`sm`,variant:`secondary`,isPending:Pe,isDisabled:z||G.length===0,onPress:()=>void ot(),children:[(0,H.jsx)(ce,{size:14}),e(Pe?`checkingModels`:`checkAllModels`)]})}),(0,H.jsx)(pe.Content,{children:(0,H.jsx)(`p`,{className:`max-w-xs text-caption leading-5`,children:e(`checkModelsHint`)})})]})]})]})]}),ye?(0,H.jsx)(d,{status:U?`danger`:`success`,title:ye}):null,Y?(0,H.jsxs)(f,{"data-gsap-reveal":!0,className:`overflow-hidden p-0`,children:[(0,H.jsxs)(`div`,{className:`flex items-start justify-between gap-4 border-b border-separator px-4 py-4 sm:items-center sm:px-5`,children:[(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsx)(`div`,{className:`text-body font-semibold`,children:e(`checkAllModels`)}),(0,H.jsx)(`div`,{className:`mt-0.5 text-caption leading-5 text-muted`,children:e(`checkModelsSummary`,{passed:Y.summary.passed,failed:Y.summary.failed,total:Y.summary.total,elapsed:Y.elapsed_ms})})]}),(0,H.jsxs)(E,{size:`sm`,variant:`soft`,color:Y.summary.failed?`warning`:`success`,className:`shrink-0`,children:[Y.summary.passed,`/`,Y.summary.total]})]}),(0,H.jsx)(x,{className:`hidden min-w-0 lg:block`,children:(0,H.jsx)(x.ScrollContainer,{className:`max-h-[24rem] min-w-0 overflow-auto`,children:(0,H.jsxs)(x.Content,{"aria-label":e(`checkAllModels`),className:`min-w-[52rem]`,children:[(0,H.jsxs)(x.Header,{children:[(0,H.jsx)(x.Column,{isRowHeader:!0,children:e(`modelCol`)}),(0,H.jsx)(x.Column,{children:e(`stateCol`)}),(0,H.jsx)(x.Column,{children:e(`account`)}),(0,H.jsx)(x.Column,{children:e(`providerCol`)}),(0,H.jsx)(x.Column,{children:e(`logsColLatency`)}),(0,H.jsx)(x.Column,{children:e(`checkAccountResults`)}),(0,H.jsx)(x.Column,{children:e(`response`)})]}),(0,H.jsx)(x.Body,{children:Y.results.map(t=>(0,H.jsxs)(x.Row,{children:[(0,H.jsx)(x.Cell,{children:(0,H.jsx)(`span`,{className:`mono text-caption font-medium`,children:t.model})}),(0,H.jsx)(x.Cell,{children:(0,H.jsx)(E,{size:`sm`,variant:`soft`,color:t.ok?`success`:t.code===`no_models`||t.message===`model required`?`warning`:`danger`,children:t.ok?e(`checkResultOK`):t.code===`no_models`||t.message===`model required`?e(`checkResultSkipped`):e(`checkResultFailed`)})}),(0,H.jsx)(x.Cell,{children:(0,H.jsx)(`span`,{className:`mono text-caption text-muted`,children:t.account_id||`—`})}),(0,H.jsx)(x.Cell,{children:(0,H.jsx)(`span`,{className:`text-caption`,children:t.provider||`—`})}),(0,H.jsx)(x.Cell,{children:(0,H.jsxs)(`span`,{className:`mono text-caption text-muted`,children:[t.latency_ms,`ms`]})}),(0,H.jsx)(x.Cell,{children:(0,H.jsx)(`div`,{className:`space-y-1`,children:(t.accounts||[]).length?t.accounts.map(n=>(0,H.jsxs)(`div`,{className:`text-caption leading-4`,children:[(0,H.jsx)(`span`,{className:`mono font-medium`,children:n.account_id}),(0,H.jsxs)(`span`,{className:n.ok?`text-success`:`text-danger`,children:[` `,n.ok?e(`checkResultOK`):e(`checkResultFailed`)]}),(0,H.jsxs)(`span`,{className:`text-muted`,children:[` · `,n.latency_ms,`ms`]}),n.message?(0,H.jsx)(`span`,{className:`block break-all text-muted`,children:n.message}):null]},`${t.model}:${n.account_id}`)):(0,H.jsx)(`span`,{className:`text-caption text-muted`,children:`—`})})}),(0,H.jsx)(x.Cell,{children:(0,H.jsx)(`span`,{className:`break-all text-caption text-muted`,children:t.message||(t.ok?e(`checkResultOK`):``)})})]},t.model))})]})})}),(0,H.jsx)(`div`,{className:`divide-y divide-separator lg:hidden`,children:Y.results.map(t=>(0,H.jsxs)(`div`,{className:`space-y-1 px-4 py-3`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,H.jsx)(`span`,{className:`mono min-w-0 truncate text-caption font-medium`,children:t.model}),(0,H.jsx)(E,{size:`sm`,variant:`soft`,color:t.ok?`success`:`danger`,children:t.ok?e(`checkResultOK`):e(`checkResultFailed`)})]}),(0,H.jsxs)(`div`,{className:`text-caption text-muted`,children:[t.account_id||t.provider||`—`,` · `,t.latency_ms,`ms`]}),(t.accounts||[]).length?(0,H.jsx)(`div`,{className:`space-y-0.5`,children:t.accounts.map(n=>(0,H.jsxs)(`div`,{className:`text-caption leading-4`,children:[(0,H.jsx)(`span`,{className:`mono font-medium`,children:n.account_id}),(0,H.jsxs)(`span`,{className:n.ok?`text-success`:`text-danger`,children:[` `,n.ok?e(`checkResultOK`):e(`checkResultFailed`)]}),(0,H.jsxs)(`span`,{className:`text-muted`,children:[` · `,n.latency_ms,`ms`]}),n.message?(0,H.jsx)(`span`,{className:`block break-all text-muted`,children:n.message}):null]},`${t.model}:${n.account_id}`))}):null,t.message?(0,H.jsx)(`div`,{className:`break-all text-caption text-muted`,children:t.message}):null]},t.model))})]}):null,z||n?(0,H.jsx)(f,{"data-gsap-reveal":!0,className:`overflow-hidden p-0`,children:(0,H.jsx)(fe,{})}):We.length===0?(0,H.jsx)(f,{"data-gsap-reveal":!0,className:`overflow-hidden p-0`,children:(0,H.jsx)(m,{icon:(0,H.jsx)(i,{size:22}),title:G.length?e(`noModelsMatch`):e(`noProviders`),hint:G.length?e(`noModelsMatch`):e(`noModelsYet`)})}):(0,H.jsx)(`div`,{"data-gsap-reveal":!0,className:`space-y-4`,children:qe.map(t=>(0,H.jsx)(Ie,{group:t,t:e,collapsible:Be,collapsed:Be&&M.has(t.key),onToggle:()=>nt(t.key),onSettings:()=>ct(t),settingsDisabled:T||O,savingKey:ge,modelCheckChip:at,onToggleTraeMax:(e,t)=>void st(e,t),onDetails:Se},t.key))}),(0,H.jsx)(be,{model:xe?G.find(e=>De(e)===De(xe))||xe:null,t:e,onClose:()=>Se(null)}),A&&et?(0,H.jsx)(Ce,{provider:A.provider,region:A.region,label:A.label,policy:et,checkinSupported:!!$e?.checkin,checkinTimezone:$e?.checkinTimezone,t:e,onClose:()=>j(null),onSaved:e=>lt(e)},`${A.provider}:${A.region}`):null,(0,H.jsx)(a,{total:Q.length,page:$,pageCount:Ke,pageSize:L,loading:z,pageSizeLabel:e(`logsPageSize`),pageLabel:e(`logsPage`,{page:$,pages:Ke}),prevLabel:e(`logsPrevPage`),nextLabel:e(`logsNextPage`),onPage:I,onPageSize:R})]})}export{Le as ProvidersPage}; \ No newline at end of file diff --git a/internal/webui/static/assets/SearchBar-Cehxs-tj.js b/internal/webui/static/assets/SearchBar-Cehxs-tj.js deleted file mode 100644 index 24c758dd..00000000 --- a/internal/webui/static/assets/SearchBar-Cehxs-tj.js +++ /dev/null @@ -1 +0,0 @@ -import{a as e,c as t,n}from"./shim-mfK0Rmj6.js";import{H as r,V as i,Z as a,pt as o}from"./useI18n-BSw4X3mq.js";import{B as s,c,s as l,z as u}from"./SharedElementTransition-BlCsXfb1.js";import{t as d}from"./search-field-D9bfZlUZ.js";import{n as f,t as p}from"./toggle-button-group-C6lenpLr.js";var m=t(e(),1),h=new Map([[`bold`,m.createElement(m.Fragment,null,m.createElement(`path`,{d:`M232.49,215.51,185,168a92.12,92.12,0,1,0-17,17l47.53,47.54a12,12,0,0,0,17-17ZM44,112a68,68,0,1,1,68,68A68.07,68.07,0,0,1,44,112Z`}))],[`duotone`,m.createElement(m.Fragment,null,m.createElement(`path`,{d:`M192,112a80,80,0,1,1-80-80A80,80,0,0,1,192,112Z`,opacity:`0.2`}),m.createElement(`path`,{d:`M229.66,218.34,179.6,168.28a88.21,88.21,0,1,0-11.32,11.31l50.06,50.07a8,8,0,0,0,11.32-11.32ZM40,112a72,72,0,1,1,72,72A72.08,72.08,0,0,1,40,112Z`}))],[`fill`,m.createElement(m.Fragment,null,m.createElement(`path`,{d:`M168,112a56,56,0,1,1-56-56A56,56,0,0,1,168,112Zm61.66,117.66a8,8,0,0,1-11.32,0l-50.06-50.07a88,88,0,1,1,11.32-11.31l50.06,50.06A8,8,0,0,1,229.66,229.66ZM112,184a72,72,0,1,0-72-72A72.08,72.08,0,0,0,112,184Z`}))],[`light`,m.createElement(m.Fragment,null,m.createElement(`path`,{d:`M228.24,219.76l-51.38-51.38a86.15,86.15,0,1,0-8.48,8.48l51.38,51.38a6,6,0,0,0,8.48-8.48ZM38,112a74,74,0,1,1,74,74A74.09,74.09,0,0,1,38,112Z`}))],[`regular`,m.createElement(m.Fragment,null,m.createElement(`path`,{d:`M229.66,218.34l-50.07-50.06a88.11,88.11,0,1,0-11.31,11.31l50.06,50.07a8,8,0,0,0,11.32-11.32ZM40,112a72,72,0,1,1,72,72A72.08,72.08,0,0,1,40,112Z`}))],[`thin`,m.createElement(m.Fragment,null,m.createElement(`path`,{d:`M226.83,221.17l-52.7-52.7a84.1,84.1,0,1,0-5.66,5.66l52.7,52.7a4,4,0,0,0,5.66-5.66ZM36,112a76,76,0,1,1,76,76A76.08,76.08,0,0,1,36,112Z`}))]]),g=m.forwardRef((e,t)=>m.createElement(o,{ref:t,...e,weights:h}));g.displayName=`MagnifyingGlassIcon`;var _=g,v=u({defaultVariants:{size:`md`},slots:{base:`pagination`,content:`pagination__content`,ellipsis:`pagination__ellipsis`,item:`pagination__item`,link:`pagination__link`,summary:`pagination__summary`},variants:{size:{lg:{base:`pagination--lg`},md:{base:`pagination--md`},sm:{base:`pagination--sm`}}}}),y=n(),b=(0,m.createContext)({}),x=({children:e,className:t,size:n,...r})=>{let i=m.useMemo(()=>v({size:n}),[n]);return(0,y.jsx)(b,{value:{slots:i},children:(0,y.jsx)(s.nav,{"aria-label":`pagination`,"data-slot":`pagination`,role:`navigation`,...r,className:l(i.base,t),children:e})})};x.displayName=`HeroUI.Pagination`;var S=({children:e,className:t,...n})=>{let{slots:r}=(0,m.use)(b);return(0,y.jsx)(s.div,{className:l(r?.summary,t),"data-slot":`pagination-summary`,dir:`auto`,...n,children:e})};S.displayName=`HeroUI.Pagination.Summary`;var C=({children:e,className:t,...n})=>{let{slots:r}=(0,m.use)(b);return(0,y.jsx)(s.ul,{className:l(r?.content,t),"data-slot":`pagination-content`,...n,children:e})};C.displayName=`HeroUI.Pagination.Content`;var w=({children:e,className:t,...n})=>{let{slots:r}=(0,m.use)(b);return(0,y.jsx)(s.li,{className:l(r?.item,t),"data-slot":`pagination-item`,...n,children:e})};w.displayName=`HeroUI.Pagination.Item`;var T=({children:e,className:t,isActive:n,...r})=>{let{slots:i}=(0,m.use)(b);return(0,y.jsx)(a,{"aria-current":n?`page`:void 0,className:c(t,i?.link()),"data-active":n?`true`:void 0,"data-slot":`pagination-link`,...r,children:e})};T.displayName=`HeroUI.Pagination.Link`;var E=({children:e,className:t,...n})=>{let{slots:r}=(0,m.use)(b),i=`${r?.link()??``} pagination__link--nav`.trim();return(0,y.jsx)(a,{className:c(t,i),"data-slot":`pagination-previous`,...n,children:e})};E.displayName=`HeroUI.Pagination.Previous`;var D=({children:e,className:t,...n})=>(0,y.jsx)(s.span,{"aria-hidden":`true`,className:t,"data-slot":`pagination-previous-icon`,...n,children:e??(0,y.jsx)(i,{})});D.displayName=`HeroUI.Pagination.PreviousIcon`;var O=({children:e,className:t,...n})=>{let{slots:r}=(0,m.use)(b),i=`${r?.link()??``} pagination__link--nav`.trim();return(0,y.jsx)(a,{className:c(t,i),"data-slot":`pagination-next`,...n,children:e})};O.displayName=`HeroUI.Pagination.Next`;var k=({children:e,className:t,...n})=>(0,y.jsx)(s.span,{"aria-hidden":`true`,className:t,"data-slot":`pagination-next-icon`,...n,children:e??(0,y.jsx)(r,{})});k.displayName=`HeroUI.Pagination.NextIcon`;var A=({className:e,...t})=>{let{slots:n}=(0,m.use)(b);return(0,y.jsx)(s.span,{"aria-hidden":`true`,className:l(n?.ellipsis,e),"data-slot":`pagination-ellipsis`,...t,children:`…`})};A.displayName=`HeroUI.Pagination.Ellipsis`;var j=Object.assign(x,{Content:C,Ellipsis:A,Item:w,Link:T,Next:O,NextIcon:k,Previous:E,PreviousIcon:D,Root:x,Summary:S}),M=[20,50,100],N=[20,50,100];function P(e,t){if(t<=7)return Array.from({length:t},(e,t)=>t+1);let n=[1];e>3&&n.push(`gap`);let r=Math.max(2,e-1),i=Math.min(t-1,e+1);for(let e=r;e<=i;e++)n.push(e);return e{let t=Number([...e][0]);d.includes(t)&&u(t)},"aria-label":a,children:d.map(e=>(0,y.jsx)(f,{id:String(e),children:e},e))})]}),(0,y.jsxs)(j,{size:`sm`,className:`w-fit`,children:[(0,y.jsx)(j.Summary,{className:`mono text-caption`,children:o}),(0,y.jsxs)(j.Content,{children:[(0,y.jsx)(j.Item,{children:(0,y.jsx)(j.Previous,{isDisabled:i||t<=1,onPress:()=>l(Math.max(1,t-1)),"aria-label":s,children:(0,y.jsx)(j.PreviousIcon,{})})}),m.map((e,n)=>e===`gap`?(0,y.jsx)(j.Item,{children:(0,y.jsx)(j.Ellipsis,{})},`gap-${n}`):(0,y.jsx)(j.Item,{children:(0,y.jsx)(j.Link,{isActive:e===t,isDisabled:i,onPress:()=>l(e),children:e})},e)),(0,y.jsx)(j.Item,{children:(0,y.jsx)(j.Next,{isDisabled:i||t>=n,onPress:()=>l(Math.min(n,t+1)),"aria-label":c,children:(0,y.jsx)(j.NextIcon,{})})})]})]})]})}function I({value:e,onChange:t,placeholder:n,ariaLabel:r,className:i}){return(0,y.jsx)(d,{"aria-label":r,value:e,onChange:t,className:i,children:(0,y.jsxs)(d.Group,{children:[(0,y.jsx)(d.SearchIcon,{}),(0,y.jsx)(d.Input,{placeholder:n}),(0,y.jsx)(d.ClearButton,{})]})})}export{_ as i,N as n,F as r,I as t}; \ No newline at end of file diff --git a/internal/webui/static/assets/SearchBar-DXjI_cjB.js b/internal/webui/static/assets/SearchBar-DXjI_cjB.js new file mode 100644 index 00000000..9e8bafad --- /dev/null +++ b/internal/webui/static/assets/SearchBar-DXjI_cjB.js @@ -0,0 +1 @@ +import{a as e,c as t,n}from"./shim-mfK0Rmj6.js";import{B as r,Y as i,dt as a,z as o}from"./useI18n-BBOAnu2u.js";import{B as s,c,s as l,z as u}from"./SharedElementTransition-BlCsXfb1.js";import{t as d}from"./search-field-Daz5dML3.js";import{m as f,p}from"./format-kRpr2wxA.js";var m=t(e(),1),h=new Map([[`bold`,m.createElement(m.Fragment,null,m.createElement(`path`,{d:`M232.49,215.51,185,168a92.12,92.12,0,1,0-17,17l47.53,47.54a12,12,0,0,0,17-17ZM44,112a68,68,0,1,1,68,68A68.07,68.07,0,0,1,44,112Z`}))],[`duotone`,m.createElement(m.Fragment,null,m.createElement(`path`,{d:`M192,112a80,80,0,1,1-80-80A80,80,0,0,1,192,112Z`,opacity:`0.2`}),m.createElement(`path`,{d:`M229.66,218.34,179.6,168.28a88.21,88.21,0,1,0-11.32,11.31l50.06,50.07a8,8,0,0,0,11.32-11.32ZM40,112a72,72,0,1,1,72,72A72.08,72.08,0,0,1,40,112Z`}))],[`fill`,m.createElement(m.Fragment,null,m.createElement(`path`,{d:`M168,112a56,56,0,1,1-56-56A56,56,0,0,1,168,112Zm61.66,117.66a8,8,0,0,1-11.32,0l-50.06-50.07a88,88,0,1,1,11.32-11.31l50.06,50.06A8,8,0,0,1,229.66,229.66ZM112,184a72,72,0,1,0-72-72A72.08,72.08,0,0,0,112,184Z`}))],[`light`,m.createElement(m.Fragment,null,m.createElement(`path`,{d:`M228.24,219.76l-51.38-51.38a86.15,86.15,0,1,0-8.48,8.48l51.38,51.38a6,6,0,0,0,8.48-8.48ZM38,112a74,74,0,1,1,74,74A74.09,74.09,0,0,1,38,112Z`}))],[`regular`,m.createElement(m.Fragment,null,m.createElement(`path`,{d:`M229.66,218.34l-50.07-50.06a88.11,88.11,0,1,0-11.31,11.31l50.06,50.07a8,8,0,0,0,11.32-11.32ZM40,112a72,72,0,1,1,72,72A72.08,72.08,0,0,1,40,112Z`}))],[`thin`,m.createElement(m.Fragment,null,m.createElement(`path`,{d:`M226.83,221.17l-52.7-52.7a84.1,84.1,0,1,0-5.66,5.66l52.7,52.7a4,4,0,0,0,5.66-5.66ZM36,112a76,76,0,1,1,76,76A76.08,76.08,0,0,1,36,112Z`}))]]),g=m.forwardRef((e,t)=>m.createElement(a,{ref:t,...e,weights:h}));g.displayName=`MagnifyingGlassIcon`;var _=g,v=u({defaultVariants:{size:`md`},slots:{base:`pagination`,content:`pagination__content`,ellipsis:`pagination__ellipsis`,item:`pagination__item`,link:`pagination__link`,summary:`pagination__summary`},variants:{size:{lg:{base:`pagination--lg`},md:{base:`pagination--md`},sm:{base:`pagination--sm`}}}}),y=n(),b=(0,m.createContext)({}),x=({children:e,className:t,size:n,...r})=>{let i=m.useMemo(()=>v({size:n}),[n]);return(0,y.jsx)(b,{value:{slots:i},children:(0,y.jsx)(s.nav,{"aria-label":`pagination`,"data-slot":`pagination`,role:`navigation`,...r,className:l(i.base,t),children:e})})};x.displayName=`HeroUI.Pagination`;var S=({children:e,className:t,...n})=>{let{slots:r}=(0,m.use)(b);return(0,y.jsx)(s.div,{className:l(r?.summary,t),"data-slot":`pagination-summary`,dir:`auto`,...n,children:e})};S.displayName=`HeroUI.Pagination.Summary`;var C=({children:e,className:t,...n})=>{let{slots:r}=(0,m.use)(b);return(0,y.jsx)(s.ul,{className:l(r?.content,t),"data-slot":`pagination-content`,...n,children:e})};C.displayName=`HeroUI.Pagination.Content`;var w=({children:e,className:t,...n})=>{let{slots:r}=(0,m.use)(b);return(0,y.jsx)(s.li,{className:l(r?.item,t),"data-slot":`pagination-item`,...n,children:e})};w.displayName=`HeroUI.Pagination.Item`;var T=({children:e,className:t,isActive:n,...r})=>{let{slots:a}=(0,m.use)(b);return(0,y.jsx)(i,{"aria-current":n?`page`:void 0,className:c(t,a?.link()),"data-active":n?`true`:void 0,"data-slot":`pagination-link`,...r,children:e})};T.displayName=`HeroUI.Pagination.Link`;var E=({children:e,className:t,...n})=>{let{slots:r}=(0,m.use)(b),a=`${r?.link()??``} pagination__link--nav`.trim();return(0,y.jsx)(i,{className:c(t,a),"data-slot":`pagination-previous`,...n,children:e})};E.displayName=`HeroUI.Pagination.Previous`;var D=({children:e,className:t,...n})=>(0,y.jsx)(s.span,{"aria-hidden":`true`,className:t,"data-slot":`pagination-previous-icon`,...n,children:e??(0,y.jsx)(o,{})});D.displayName=`HeroUI.Pagination.PreviousIcon`;var O=({children:e,className:t,...n})=>{let{slots:r}=(0,m.use)(b),a=`${r?.link()??``} pagination__link--nav`.trim();return(0,y.jsx)(i,{className:c(t,a),"data-slot":`pagination-next`,...n,children:e})};O.displayName=`HeroUI.Pagination.Next`;var k=({children:e,className:t,...n})=>(0,y.jsx)(s.span,{"aria-hidden":`true`,className:t,"data-slot":`pagination-next-icon`,...n,children:e??(0,y.jsx)(r,{})});k.displayName=`HeroUI.Pagination.NextIcon`;var A=({className:e,...t})=>{let{slots:n}=(0,m.use)(b);return(0,y.jsx)(s.span,{"aria-hidden":`true`,className:l(n?.ellipsis,e),"data-slot":`pagination-ellipsis`,...t,children:`…`})};A.displayName=`HeroUI.Pagination.Ellipsis`;var j=Object.assign(x,{Content:C,Ellipsis:A,Item:w,Link:T,Next:O,NextIcon:k,Previous:E,PreviousIcon:D,Root:x,Summary:S}),M=[20,50,100],N=[20,50,100];function P(e,t){if(t<=7)return Array.from({length:t},(e,t)=>t+1);let n=[1];e>3&&n.push(`gap`);let r=Math.max(2,e-1),i=Math.min(t-1,e+1);for(let e=r;e<=i;e++)n.push(e);return e{let t=Number([...e][0]);d.includes(t)&&u(t)},"aria-label":a,children:d.map(e=>(0,y.jsx)(f,{id:String(e),children:e},e))})]}),(0,y.jsxs)(j,{size:`sm`,className:`w-fit`,children:[(0,y.jsx)(j.Summary,{className:`mono text-caption`,children:o}),(0,y.jsxs)(j.Content,{children:[(0,y.jsx)(j.Item,{children:(0,y.jsx)(j.Previous,{isDisabled:i||t<=1,onPress:()=>l(Math.max(1,t-1)),"aria-label":s,children:(0,y.jsx)(j.PreviousIcon,{})})}),m.map((e,n)=>e===`gap`?(0,y.jsx)(j.Item,{children:(0,y.jsx)(j.Ellipsis,{})},`gap-${n}`):(0,y.jsx)(j.Item,{children:(0,y.jsx)(j.Link,{isActive:e===t,isDisabled:i,onPress:()=>l(e),children:e})},e)),(0,y.jsx)(j.Item,{children:(0,y.jsx)(j.Next,{isDisabled:i||t>=n,onPress:()=>l(Math.min(n,t+1)),"aria-label":c,children:(0,y.jsx)(j.NextIcon,{})})})]})]})]})}function I({value:e,onChange:t,placeholder:n,ariaLabel:r,className:i}){return(0,y.jsx)(d,{"aria-label":r,value:e,onChange:t,className:i,children:(0,y.jsxs)(d.Group,{children:[(0,y.jsx)(d.SearchIcon,{}),(0,y.jsx)(d.Input,{placeholder:n}),(0,y.jsx)(d.ClearButton,{})]})})}export{_ as i,N as n,F as r,I as t}; \ No newline at end of file diff --git a/internal/webui/static/assets/ShieldCheck.es-DZbwX87Q.js b/internal/webui/static/assets/ShieldCheck.es-DReH26Zt.js similarity index 96% rename from internal/webui/static/assets/ShieldCheck.es-DZbwX87Q.js rename to internal/webui/static/assets/ShieldCheck.es-DReH26Zt.js index 281b6889..1f4c940c 100644 --- a/internal/webui/static/assets/ShieldCheck.es-DZbwX87Q.js +++ b/internal/webui/static/assets/ShieldCheck.es-DReH26Zt.js @@ -1 +1 @@ -import{a as e,c as t}from"./shim-mfK0Rmj6.js";import{pt as n}from"./useI18n-BSw4X3mq.js";var r=t(e(),1),i=new Map([[`bold`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M208,36H48A20,20,0,0,0,28,56v56c0,54.29,26.32,87.22,48.4,105.29,23.71,19.39,47.44,26,48.44,26.29a12.1,12.1,0,0,0,6.32,0c1-.28,24.73-6.9,48.44-26.29,22.08-18.07,48.4-51,48.4-105.29V56A20,20,0,0,0,208,36Zm-4,76c0,35.71-13.09,64.69-38.91,86.15A126.28,126.28,0,0,1,128,219.38a126.14,126.14,0,0,1-37.09-21.23C65.09,176.69,52,147.71,52,112V60H204ZM79.51,144.49a12,12,0,1,1,17-17L112,143l47.51-47.52a12,12,0,0,1,17,17l-56,56a12,12,0,0,1-17,0Z`}))],[`duotone`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M216,56v56c0,96-88,120-88,120S40,208,40,112V56a8,8,0,0,1,8-8H208A8,8,0,0,1,216,56Z`,opacity:`0.2`}),r.createElement(`path`,{d:`M208,40H48A16,16,0,0,0,32,56v56c0,52.72,25.52,84.67,46.93,102.19,23.06,18.86,46,25.26,47,25.53a8,8,0,0,0,4.2,0c1-.27,23.91-6.67,47-25.53C198.48,196.67,224,164.72,224,112V56A16,16,0,0,0,208,40Zm0,72c0,37.07-13.66,67.16-40.6,89.42A129.3,129.3,0,0,1,128,223.62a128.25,128.25,0,0,1-38.92-21.81C61.82,179.51,48,149.3,48,112l0-56,160,0ZM82.34,141.66a8,8,0,0,1,11.32-11.32L112,148.69l50.34-50.35a8,8,0,0,1,11.32,11.32l-56,56a8,8,0,0,1-11.32,0Z`}))],[`fill`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M208,40H48A16,16,0,0,0,32,56v56c0,52.72,25.52,84.67,46.93,102.19,23.06,18.86,46,25.26,47,25.53a8,8,0,0,0,4.2,0c1-.27,23.91-6.67,47-25.53C198.48,196.67,224,164.72,224,112V56A16,16,0,0,0,208,40Zm-34.32,69.66-56,56a8,8,0,0,1-11.32,0l-24-24a8,8,0,0,1,11.32-11.32L112,148.69l50.34-50.35a8,8,0,0,1,11.32,11.32Z`}))],[`light`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M208,42H48A14,14,0,0,0,34,56v56c0,51.94,25.12,83.4,46.2,100.64,22.73,18.6,45.27,24.89,46.22,25.15a6,6,0,0,0,3.16,0c.95-.26,23.49-6.55,46.22-25.15C196.88,195.4,222,163.94,222,112V56A14,14,0,0,0,208,42Zm2,70c0,37.76-13.94,68.39-41.44,91.06A131.17,131.17,0,0,1,128,225.72a130.94,130.94,0,0,1-40.56-22.66C59.94,180.39,46,149.76,46,112V56a2,2,0,0,1,2-2H208a2,2,0,0,1,2,2ZM172.24,99.76a6,6,0,0,1,0,8.48l-56,56a6,6,0,0,1-8.48,0l-24-24a6,6,0,0,1,8.48-8.48L112,151.51l51.76-51.75A6,6,0,0,1,172.24,99.76Z`}))],[`regular`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M208,40H48A16,16,0,0,0,32,56v56c0,52.72,25.52,84.67,46.93,102.19,23.06,18.86,46,25.26,47,25.53a8,8,0,0,0,4.2,0c1-.27,23.91-6.67,47-25.53C198.48,196.67,224,164.72,224,112V56A16,16,0,0,0,208,40Zm0,72c0,37.07-13.66,67.16-40.6,89.42A129.3,129.3,0,0,1,128,223.62a128.25,128.25,0,0,1-38.92-21.81C61.82,179.51,48,149.3,48,112l0-56,160,0ZM82.34,141.66a8,8,0,0,1,11.32-11.32L112,148.69l50.34-50.35a8,8,0,0,1,11.32,11.32l-56,56a8,8,0,0,1-11.32,0Z`}))],[`thin`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M208,44H48A12,12,0,0,0,36,56v56c0,51.16,24.73,82.12,45.47,99.1,22.4,18.32,44.55,24.5,45.48,24.76a4,4,0,0,0,2.1,0c.93-.26,23.08-6.44,45.48-24.76,20.74-17,45.47-47.94,45.47-99.1V56A12,12,0,0,0,208,44Zm4,68c0,38.44-14.23,69.63-42.29,92.71A132.45,132.45,0,0,1,128,227.82a132.23,132.23,0,0,1-41.71-23.11C58.23,181.63,44,150.44,44,112V56a4,4,0,0,1,4-4H208a4,4,0,0,1,4,4Zm-41.17-10.83a4,4,0,0,1,0,5.66l-56,56a4,4,0,0,1-5.66,0l-24-24a4,4,0,0,1,5.66-5.66L112,154.34l53.17-53.17A4,4,0,0,1,170.83,101.17Z`}))]]),a=r.forwardRef((e,t)=>r.createElement(n,{ref:t,...e,weights:i}));a.displayName=`ShieldCheckIcon`;var o=a;export{o as t}; \ No newline at end of file +import{a as e,c as t}from"./shim-mfK0Rmj6.js";import{dt as n}from"./useI18n-BBOAnu2u.js";var r=t(e(),1),i=new Map([[`bold`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M208,36H48A20,20,0,0,0,28,56v56c0,54.29,26.32,87.22,48.4,105.29,23.71,19.39,47.44,26,48.44,26.29a12.1,12.1,0,0,0,6.32,0c1-.28,24.73-6.9,48.44-26.29,22.08-18.07,48.4-51,48.4-105.29V56A20,20,0,0,0,208,36Zm-4,76c0,35.71-13.09,64.69-38.91,86.15A126.28,126.28,0,0,1,128,219.38a126.14,126.14,0,0,1-37.09-21.23C65.09,176.69,52,147.71,52,112V60H204ZM79.51,144.49a12,12,0,1,1,17-17L112,143l47.51-47.52a12,12,0,0,1,17,17l-56,56a12,12,0,0,1-17,0Z`}))],[`duotone`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M216,56v56c0,96-88,120-88,120S40,208,40,112V56a8,8,0,0,1,8-8H208A8,8,0,0,1,216,56Z`,opacity:`0.2`}),r.createElement(`path`,{d:`M208,40H48A16,16,0,0,0,32,56v56c0,52.72,25.52,84.67,46.93,102.19,23.06,18.86,46,25.26,47,25.53a8,8,0,0,0,4.2,0c1-.27,23.91-6.67,47-25.53C198.48,196.67,224,164.72,224,112V56A16,16,0,0,0,208,40Zm0,72c0,37.07-13.66,67.16-40.6,89.42A129.3,129.3,0,0,1,128,223.62a128.25,128.25,0,0,1-38.92-21.81C61.82,179.51,48,149.3,48,112l0-56,160,0ZM82.34,141.66a8,8,0,0,1,11.32-11.32L112,148.69l50.34-50.35a8,8,0,0,1,11.32,11.32l-56,56a8,8,0,0,1-11.32,0Z`}))],[`fill`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M208,40H48A16,16,0,0,0,32,56v56c0,52.72,25.52,84.67,46.93,102.19,23.06,18.86,46,25.26,47,25.53a8,8,0,0,0,4.2,0c1-.27,23.91-6.67,47-25.53C198.48,196.67,224,164.72,224,112V56A16,16,0,0,0,208,40Zm-34.32,69.66-56,56a8,8,0,0,1-11.32,0l-24-24a8,8,0,0,1,11.32-11.32L112,148.69l50.34-50.35a8,8,0,0,1,11.32,11.32Z`}))],[`light`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M208,42H48A14,14,0,0,0,34,56v56c0,51.94,25.12,83.4,46.2,100.64,22.73,18.6,45.27,24.89,46.22,25.15a6,6,0,0,0,3.16,0c.95-.26,23.49-6.55,46.22-25.15C196.88,195.4,222,163.94,222,112V56A14,14,0,0,0,208,42Zm2,70c0,37.76-13.94,68.39-41.44,91.06A131.17,131.17,0,0,1,128,225.72a130.94,130.94,0,0,1-40.56-22.66C59.94,180.39,46,149.76,46,112V56a2,2,0,0,1,2-2H208a2,2,0,0,1,2,2ZM172.24,99.76a6,6,0,0,1,0,8.48l-56,56a6,6,0,0,1-8.48,0l-24-24a6,6,0,0,1,8.48-8.48L112,151.51l51.76-51.75A6,6,0,0,1,172.24,99.76Z`}))],[`regular`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M208,40H48A16,16,0,0,0,32,56v56c0,52.72,25.52,84.67,46.93,102.19,23.06,18.86,46,25.26,47,25.53a8,8,0,0,0,4.2,0c1-.27,23.91-6.67,47-25.53C198.48,196.67,224,164.72,224,112V56A16,16,0,0,0,208,40Zm0,72c0,37.07-13.66,67.16-40.6,89.42A129.3,129.3,0,0,1,128,223.62a128.25,128.25,0,0,1-38.92-21.81C61.82,179.51,48,149.3,48,112l0-56,160,0ZM82.34,141.66a8,8,0,0,1,11.32-11.32L112,148.69l50.34-50.35a8,8,0,0,1,11.32,11.32l-56,56a8,8,0,0,1-11.32,0Z`}))],[`thin`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M208,44H48A12,12,0,0,0,36,56v56c0,51.16,24.73,82.12,45.47,99.1,22.4,18.32,44.55,24.5,45.48,24.76a4,4,0,0,0,2.1,0c.93-.26,23.08-6.44,45.48-24.76,20.74-17,45.47-47.94,45.47-99.1V56A12,12,0,0,0,208,44Zm4,68c0,38.44-14.23,69.63-42.29,92.71A132.45,132.45,0,0,1,128,227.82a132.23,132.23,0,0,1-41.71-23.11C58.23,181.63,44,150.44,44,112V56a4,4,0,0,1,4-4H208a4,4,0,0,1,4,4Zm-41.17-10.83a4,4,0,0,1,0,5.66l-56,56a4,4,0,0,1-5.66,0l-24-24a4,4,0,0,1,5.66-5.66L112,154.34l53.17-53.17A4,4,0,0,1,170.83,101.17Z`}))]]),a=r.forwardRef((e,t)=>r.createElement(n,{ref:t,...e,weights:i}));a.displayName=`ShieldCheckIcon`;var o=a;export{o as t}; \ No newline at end of file diff --git a/internal/webui/static/assets/SidebarUpdateDialog-BpYF6S7N.js b/internal/webui/static/assets/SidebarUpdateDialog-BBhlV1LN.js similarity index 83% rename from internal/webui/static/assets/SidebarUpdateDialog-BpYF6S7N.js rename to internal/webui/static/assets/SidebarUpdateDialog-BBhlV1LN.js index 1ae5087f..8c15bb53 100644 --- a/internal/webui/static/assets/SidebarUpdateDialog-BpYF6S7N.js +++ b/internal/webui/static/assets/SidebarUpdateDialog-BBhlV1LN.js @@ -1 +1 @@ -import{n as e}from"./shim-mfK0Rmj6.js";import{r as t}from"./useI18n-BSw4X3mq.js";import{t as n}from"./PageAlert-CaDjxveS.js";import{t as r}from"./modal-BVwBjYX-.js";import{Dt as i}from"./index-C8_qeOs_.js";import{n as a,r as o,t as s}from"./UpdateControls-exMtCvDY.js";var c=e();function l({open:e,update:l,release:u,version:d,lang:f,labels:p,onClose:m,onGoToUpdate:h}){return(0,c.jsx)(r.Root,{isOpen:e,onOpenChange:e=>{e||m()},children:(0,c.jsx)(r.Backdrop,{variant:`blur`,children:(0,c.jsx)(r.Container,{placement:`center`,size:`lg`,scroll:`inside`,children:(0,c.jsxs)(r.Dialog,{children:[(0,c.jsxs)(r.Header,{className:`items-start justify-between gap-4`,children:[(0,c.jsxs)(`div`,{children:[(0,c.jsx)(r.Heading,{className:`text-section font-semibold`,children:p.versionUpdate}),(0,c.jsx)(`p`,{className:`mono mt-1 text-caption text-muted`,children:u?.tag_name||d})]}),(0,c.jsx)(r.CloseTrigger,{"aria-label":p.close,className:`grid size-8 place-items-center rounded-lg text-muted hover:bg-surface-secondary`,children:(0,c.jsx)(i,{size:16})})]}),(0,c.jsxs)(r.Body,{className:`space-y-4`,children:[l.error?(0,c.jsx)(n,{title:l.error}):null,(0,c.jsx)(s,{update:l}),(0,c.jsx)(`div`,{className:`text-caption font-medium text-muted`,children:p.releaseNotes}),(0,c.jsx)(a,{markdown:o(u?.body,f),emptyLabel:p.emptyNotes})]}),(0,c.jsxs)(r.Footer,{className:`justify-end`,children:[(0,c.jsx)(t,{variant:`ghost`,className:`mr-auto`,onPress:h,children:p.goToUpdate}),(0,c.jsx)(t,{variant:`secondary`,onPress:m,children:p.close})]})]})})})})}export{l as SidebarUpdateDialog}; \ No newline at end of file +import{n as e}from"./shim-mfK0Rmj6.js";import{r as t}from"./useI18n-BBOAnu2u.js";import{t as n}from"./PageAlert-DZC7IhXp.js";import{t as r}from"./modal-DHeFzFnN.js";import{kt as i}from"./index-B9eWF6SH.js";import{n as a,r as o,t as s}from"./UpdateControls-BMVq7AGm.js";var c=e();function l({open:e,update:l,release:u,version:d,lang:f,labels:p,onClose:m,onGoToUpdate:h}){return(0,c.jsx)(r.Root,{isOpen:e,onOpenChange:e=>{e||m()},children:(0,c.jsx)(r.Backdrop,{variant:`blur`,children:(0,c.jsx)(r.Container,{placement:`center`,size:`lg`,scroll:`inside`,children:(0,c.jsxs)(r.Dialog,{children:[(0,c.jsxs)(r.Header,{className:`items-start justify-between gap-4`,children:[(0,c.jsxs)(`div`,{children:[(0,c.jsx)(r.Heading,{className:`text-section font-semibold`,children:p.versionUpdate}),(0,c.jsx)(`p`,{className:`mono mt-1 text-caption text-muted`,children:u?.tag_name||d})]}),(0,c.jsx)(r.CloseTrigger,{"aria-label":p.close,className:`grid size-8 place-items-center rounded-lg text-muted hover:bg-surface-secondary`,children:(0,c.jsx)(i,{size:16})})]}),(0,c.jsxs)(r.Body,{className:`space-y-4`,children:[l.error?(0,c.jsx)(n,{title:l.error}):null,(0,c.jsx)(s,{update:l}),(0,c.jsx)(`div`,{className:`text-caption font-medium text-muted`,children:p.releaseNotes}),(0,c.jsx)(a,{markdown:o(u?.body,f),emptyLabel:p.emptyNotes})]}),(0,c.jsxs)(r.Footer,{className:`justify-end`,children:[(0,c.jsx)(t,{variant:`ghost`,className:`mr-auto`,onPress:h,children:p.goToUpdate}),(0,c.jsx)(t,{variant:`secondary`,onPress:m,children:p.close})]})]})})})})}export{l as SidebarUpdateDialog}; \ No newline at end of file diff --git a/internal/webui/static/assets/SystemPage-COFtEolX.js b/internal/webui/static/assets/SystemPage-COFtEolX.js deleted file mode 100644 index 803a3c09..00000000 --- a/internal/webui/static/assets/SystemPage-COFtEolX.js +++ /dev/null @@ -1 +0,0 @@ -import{a as e,c as t,n}from"./shim-mfK0Rmj6.js";import{n as r,t as i}from"./clipboard-BMEt1jHG.js";import{t as a}from"./ShieldCheck.es-DZbwX87Q.js";import{n as o,pt as s,r as c}from"./useI18n-BSw4X3mq.js";import{t as l}from"./label-n7vfsS35.js";import{t as u}from"./list-box-DD4xJ3gX.js";import{t as d}from"./accordion-Bi_Adwlu.js";import{t as f}from"./PageAlert-CaDjxveS.js";import{t as p}from"./ConfirmDialog-C6PfmZuk.js";import{n as m}from"./useToggle-HDaAPzVy.js";import{t as h}from"./description-0cu8nG7R.js";import{n as ee,t as g}from"./FormRow-D36RiZfK.js";import{t as _}from"./modal-BVwBjYX-.js";import{n as v,t as y}from"./tabs-Cm-IDu6Q.js";import{t as b}from"./select-CtWmaZQ5.js";import{t as x}from"./CompactSwitch-DH1Gk66-.js";import{j as te}from"./overview-m01k08K8.js";import{C as ne,Dt as S,E as C,Gt as re,It as ie,M as w,O as ae,T as oe,Ut as se,Vt as T,Wt as ce,Xt as E,h as le,zt as ue}from"./index-C8_qeOs_.js";import{n as D,r as O,t as de}from"./UpdateControls-exMtCvDY.js";import{a as fe,i as pe}from"./keys-BOKh04gY.js";var k=t(e(),1),A=new Map([[`bold`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M196,35.52C177.62,25.51,153.48,20,128,20S78.38,25.51,60,35.52C39.37,46.79,28,62.58,28,80v96c0,17.42,11.37,33.21,32,44.48,18.35,10,42.49,15.52,68,15.52s49.62-5.51,68-15.52c20.66-11.27,32-27.06,32-44.48V80C228,62.58,216.63,46.79,196,35.52ZM204,128c0,17-31.21,36-76,36s-76-19-76-36v-8.46a88.9,88.9,0,0,0,8,4.94c18.35,10,42.49,15.52,68,15.52s49.62-5.51,68-15.52a88.9,88.9,0,0,0,8-4.94ZM128,44c44.79,0,76,19,76,36s-31.21,36-76,36S52,97,52,80,83.21,44,128,44Zm0,168c-44.79,0-76-19-76-36v-8.46a88.9,88.9,0,0,0,8,4.94c18.35,10,42.49,15.52,68,15.52s49.62-5.51,68-15.52a88.9,88.9,0,0,0,8-4.94V176C204,193,172.79,212,128,212Z`}))],[`duotone`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M216,80c0,26.51-39.4,48-88,48S40,106.51,40,80s39.4-48,88-48S216,53.49,216,80Z`,opacity:`0.2`}),k.createElement(`path`,{d:`M128,24C74.17,24,32,48.6,32,80v96c0,31.4,42.17,56,96,56s96-24.6,96-56V80C224,48.6,181.83,24,128,24Zm80,104c0,9.62-7.88,19.43-21.61,26.92C170.93,163.35,150.19,168,128,168s-42.93-4.65-58.39-13.08C55.88,147.43,48,137.62,48,128V111.36c17.06,15,46.23,24.64,80,24.64s62.94-9.68,80-24.64ZM69.61,53.08C85.07,44.65,105.81,40,128,40s42.93,4.65,58.39,13.08C200.12,60.57,208,70.38,208,80s-7.88,19.43-21.61,26.92C170.93,115.35,150.19,120,128,120s-42.93-4.65-58.39-13.08C55.88,99.43,48,89.62,48,80S55.88,60.57,69.61,53.08ZM186.39,202.92C170.93,211.35,150.19,216,128,216s-42.93-4.65-58.39-13.08C55.88,195.43,48,185.62,48,176V159.36c17.06,15,46.23,24.64,80,24.64s62.94-9.68,80-24.64V176C208,185.62,200.12,195.43,186.39,202.92Z`}))],[`fill`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M128,24C74.17,24,32,48.6,32,80v96c0,31.4,42.17,56,96,56s96-24.6,96-56V80C224,48.6,181.83,24,128,24Zm80,104c0,9.62-7.88,19.43-21.61,26.92C170.93,163.35,150.19,168,128,168s-42.93-4.65-58.39-13.08C55.88,147.43,48,137.62,48,128V111.36c17.06,15,46.23,24.64,80,24.64s62.94-9.68,80-24.64Zm-21.61,74.92C170.93,211.35,150.19,216,128,216s-42.93-4.65-58.39-13.08C55.88,195.43,48,185.62,48,176V159.36c17.06,15,46.23,24.64,80,24.64s62.94-9.68,80-24.64V176C208,185.62,200.12,195.43,186.39,202.92Z`}))],[`light`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M128,26C75.29,26,34,49.72,34,80v96c0,30.28,41.29,54,94,54s94-23.72,94-54V80C222,49.72,180.71,26,128,26Zm0,12c44.45,0,82,19.23,82,42s-37.55,42-82,42S46,102.77,46,80,83.55,38,128,38Zm82,138c0,22.77-37.55,42-82,42s-82-19.23-82-42V154.79C62,171.16,92.37,182,128,182s66-10.84,82-27.21Zm0-48c0,22.77-37.55,42-82,42s-82-19.23-82-42V106.79C62,123.16,92.37,134,128,134s66-10.84,82-27.21Z`}))],[`regular`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M128,24C74.17,24,32,48.6,32,80v96c0,31.4,42.17,56,96,56s96-24.6,96-56V80C224,48.6,181.83,24,128,24Zm80,104c0,9.62-7.88,19.43-21.61,26.92C170.93,163.35,150.19,168,128,168s-42.93-4.65-58.39-13.08C55.88,147.43,48,137.62,48,128V111.36c17.06,15,46.23,24.64,80,24.64s62.94-9.68,80-24.64ZM69.61,53.08C85.07,44.65,105.81,40,128,40s42.93,4.65,58.39,13.08C200.12,60.57,208,70.38,208,80s-7.88,19.43-21.61,26.92C170.93,115.35,150.19,120,128,120s-42.93-4.65-58.39-13.08C55.88,99.43,48,89.62,48,80S55.88,60.57,69.61,53.08ZM186.39,202.92C170.93,211.35,150.19,216,128,216s-42.93-4.65-58.39-13.08C55.88,195.43,48,185.62,48,176V159.36c17.06,15,46.23,24.64,80,24.64s62.94-9.68,80-24.64V176C208,185.62,200.12,195.43,186.39,202.92Z`}))],[`thin`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M192.14,42.55C174.94,33.17,152.16,28,128,28S81.06,33.17,63.86,42.55C45.89,52.35,36,65.65,36,80v96c0,14.35,9.89,27.65,27.86,37.45,17.2,9.38,40,14.55,64.14,14.55s46.94-5.17,64.14-14.55c18-9.8,27.86-23.1,27.86-37.45V80C220,65.65,210.11,52.35,192.14,42.55ZM212,176c0,11.29-8.41,22.1-23.69,30.43C172.27,215.18,150.85,220,128,220s-44.27-4.82-60.31-13.57C52.41,198.1,44,187.29,44,176V149.48c4.69,5.93,11.37,11.34,19.86,16,17.2,9.38,40,14.55,64.14,14.55s46.94-5.17,64.14-14.55c8.49-4.63,15.17-10,19.86-16Zm0-48c0,11.29-8.41,22.1-23.69,30.43C172.27,167.18,150.85,172,128,172s-44.27-4.82-60.31-13.57C52.41,150.1,44,139.29,44,128V101.48c4.69,5.93,11.37,11.34,19.86,16,17.2,9.38,40,14.55,64.14,14.55s46.94-5.17,64.14-14.55c8.49-4.63,15.17-10,19.86-16Zm-23.69-17.57C172.27,119.18,150.85,124,128,124s-44.27-4.82-60.31-13.57C52.41,102.1,44,91.29,44,80s8.41-22.1,23.69-30.43C83.73,40.82,105.15,36,128,36s44.27,4.82,60.31,13.57C203.59,57.9,212,68.71,212,80S203.59,102.1,188.31,110.43Z`}))]]),j=new Map([[`bold`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M40,92H70.06a36,36,0,0,0,67.88,0H216a12,12,0,0,0,0-24H137.94a36,36,0,0,0-67.88,0H40a12,12,0,0,0,0,24Zm64-24A12,12,0,1,1,92,80,12,12,0,0,1,104,68Zm112,96H201.94a36,36,0,0,0-67.88,0H40a12,12,0,0,0,0,24h94.06a36,36,0,0,0,67.88,0H216a12,12,0,0,0,0-24Zm-48,24a12,12,0,1,1,12-12A12,12,0,0,1,168,188Z`}))],[`duotone`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M128,80a24,24,0,1,1-24-24A24,24,0,0,1,128,80Zm40,72a24,24,0,1,0,24,24A24,24,0,0,0,168,152Z`,opacity:`0.2`}),k.createElement(`path`,{d:`M40,88H73a32,32,0,0,0,62,0h81a8,8,0,0,0,0-16H135a32,32,0,0,0-62,0H40a8,8,0,0,0,0,16Zm64-24A16,16,0,1,1,88,80,16,16,0,0,1,104,64ZM216,168H199a32,32,0,0,0-62,0H40a8,8,0,0,0,0,16h97a32,32,0,0,0,62,0h17a8,8,0,0,0,0-16Zm-48,24a16,16,0,1,1,16-16A16,16,0,0,1,168,192Z`}))],[`fill`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M32,80a8,8,0,0,1,8-8H77.17a28,28,0,0,1,53.66,0H216a8,8,0,0,1,0,16H130.83a28,28,0,0,1-53.66,0H40A8,8,0,0,1,32,80Zm184,88H194.83a28,28,0,0,0-53.66,0H40a8,8,0,0,0,0,16H141.17a28,28,0,0,0,53.66,0H216a8,8,0,0,0,0-16Z`}))],[`light`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M40,86H74.6a30,30,0,0,0,58.8,0H216a6,6,0,0,0,0-12H133.4a30,30,0,0,0-58.8,0H40a6,6,0,0,0,0,12Zm64-24A18,18,0,1,1,86,80,18,18,0,0,1,104,62ZM216,170H197.4a30,30,0,0,0-58.8,0H40a6,6,0,0,0,0,12h98.6a30,30,0,0,0,58.8,0H216a6,6,0,0,0,0-12Zm-48,24a18,18,0,1,1,18-18A18,18,0,0,1,168,194Z`}))],[`regular`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M40,88H73a32,32,0,0,0,62,0h81a8,8,0,0,0,0-16H135a32,32,0,0,0-62,0H40a8,8,0,0,0,0,16Zm64-24A16,16,0,1,1,88,80,16,16,0,0,1,104,64ZM216,168H199a32,32,0,0,0-62,0H40a8,8,0,0,0,0,16h97a32,32,0,0,0,62,0h17a8,8,0,0,0,0-16Zm-48,24a16,16,0,1,1,16-16A16,16,0,0,1,168,192Z`}))],[`thin`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M40,84H76.29a28,28,0,0,0,55.42,0H216a4,4,0,0,0,0-8H131.71a28,28,0,0,0-55.42,0H40a4,4,0,0,0,0,8Zm64-24A20,20,0,1,1,84,80,20,20,0,0,1,104,60ZM216,172H195.71a28,28,0,0,0-55.42,0H40a4,4,0,0,0,0,8H140.29a28,28,0,0,0,55.42,0H216a4,4,0,0,0,0-8Zm-48,24a20,20,0,1,1,20-20A20,20,0,0,1,168,196Z`}))]]),M=k.forwardRef((e,t)=>k.createElement(s,{ref:t,...e,weights:A}));M.displayName=`DatabaseIcon`;var me=M,N=k.forwardRef((e,t)=>k.createElement(s,{ref:t,...e,weights:j}));N.displayName=`SlidersHorizontalIcon`;var P=N,F=n();function I(e,t){if(!e)return``;let n=new Date(e);return Number.isNaN(n.getTime())?``:n.toLocaleDateString(t===`zh`?`zh-CN`:`en-US`,{year:`numeric`,month:`short`,day:`numeric`})}function he({releases:e,currentVersion:t,nextVersion:n,rollbackTags:r,canRollback:i,submitting:a,onRestore:s}){let{t:l,lang:u}=o();if(!e.length)return null;let f=n&&n!==t?n:t,p=e.some(e=>e.tag_name===f)?f:e[0]?.tag_name,m=new Set(r);return(0,F.jsxs)(`div`,{className:`mt-5`,children:[(0,F.jsx)(`div`,{className:`mb-2`,children:(0,F.jsx)(`p`,{className:`text-caption font-medium text-foreground`,children:l(`versionHistory`)})}),(0,F.jsx)(d,{className:`rounded-lg bg-surface-secondary`,hideSeparator:!0,defaultExpandedKeys:p?[p]:[],children:e.map(e=>{let r=e.tag_name,o=r===t,f=!!(n&&r===n&&n!==t),p=i&&m.has(r)&&!o,h=I(e.published_at,u);return(0,F.jsxs)(d.Item,{id:r,children:[(0,F.jsx)(d.Heading,{children:(0,F.jsxs)(d.Trigger,{className:`items-center gap-3 px-3 py-2.5 text-left`,children:[(0,F.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,F.jsx)(`span`,{className:`mono text-body font-semibold`,children:r}),o?(0,F.jsx)(w,{size:`sm`,variant:`soft`,color:`success`,children:l(`versionCurrentBadge`)}):null,f?(0,F.jsx)(w,{size:`sm`,variant:`soft`,color:`warning`,children:l(`versionLatestBadge`)}):null,h?(0,F.jsx)(`span`,{className:`truncate text-caption text-muted`,children:h}):null]}),(0,F.jsx)(d.Indicator,{})]})}),(0,F.jsx)(d.Panel,{children:(0,F.jsxs)(d.Body,{className:`px-3 pb-3`,children:[(0,F.jsx)(`div`,{className:`release-notes-box release-notes-box--compact`,children:(0,F.jsx)(D,{markdown:O(e.body,u),emptyLabel:l(`updateNoNotes`)})}),p?(0,F.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,F.jsx)(c,{size:`sm`,variant:`ghost`,isDisabled:a,onPress:()=>s(r),children:l(`restoreThisVersion`)})}):null]})})]},r)})})]})}function L(e){let t=new Set,n=[];for(let r of e){let e=r.tag_name?.trim();!e||t.has(e)||(t.add(e),n.push({...r,tag_name:e}))}return n}function ge(e,t,n,r,i){return r?.length?L(r):L([...n?[n]:t?[{tag_name:t}]:[],...e?[{tag_name:e}]:[],...i||[]])}var _e=[`general`,`routing`,`security`,`updates`];function R(){let{t:e}=o(),[t,n]=E(),s=t.get(`tab`),d=s&&_e.includes(s)?s:`general`,D=e=>n(e===`general`?{}:{tab:e},{replace:!0}),{setApiKey:O}=te(),{refresh:A}=ae(),[j,M]=(0,k.useState)(null),[N,I]=(0,k.useState)(null),[L,R]=(0,k.useState)(``),[z,B]=(0,k.useState)(!1),[V,H]=(0,k.useState)(!1),[ve,U]=(0,k.useState)(!1),[W,G]=(0,k.useState)(``),[ye,K]=(0,k.useState)(!1),[q,J]=(0,k.useState)(``),Y=ne(),{info:X,loading:be,checking:xe,submitting:Z,error:Q,setError:$,load:Se,canRollback:Ce,rollbackTo:we}=Y,Te=(0,k.useMemo)(()=>ge(X?.current_version||``,X?.next_version,X?.release,X?.recent_releases,X?.rollback_versions),[X?.current_version,X?.next_version,X?.release,X?.recent_releases,X?.rollback_versions]),Ee=(0,k.useMemo)(()=>(X?.rollback_versions||[]).map(e=>e.tag_name),[X?.rollback_versions]);(0,k.useEffect)(()=>{let e=window.setTimeout(()=>{pe().then(M).catch(()=>void 0),oe().then(e=>{I(e),R(e.proxy_url||``)}).catch(e=>$(e instanceof Error?e.message:String(e)))},0);return()=>window.clearTimeout(e)},[$]);async function De(e){let t=N?.cross_provider_model_pool??!0;I(t=>t&&{...t,cross_provider_model_pool:e}),B(!0),$(``);try{I(await C({cross_provider_model_pool:e})),A(void 0,{silent:!0}).catch(()=>void 0)}catch(e){I(e=>e&&{...e,cross_provider_model_pool:t}),$(e instanceof Error?e.message:String(e))}finally{B(!1)}}async function Oe(e){let t=N?.checkin_disabled_accounts??!1;I(t=>t&&{...t,checkin_disabled_accounts:e}),B(!0),$(``);try{I(await C({checkin_disabled_accounts:e}))}catch(e){I(e=>e&&{...e,checkin_disabled_accounts:t}),$(e instanceof Error?e.message:String(e))}finally{B(!1)}}async function ke(e){let t=N?.proxy_url||``;if(e===t){R(t);return}let n=L;R(e),I(t=>t&&{...t,proxy_url:e}),B(!0),$(``);try{let t=await C({proxy_url:e});I(t),R(t.proxy_url||``)}catch(e){R(n),I(e=>e&&{...e,proxy_url:t}),$(e instanceof Error?e.message:String(e))}finally{B(!1)}}async function Ae(e){let t=N?.routing_strategy||`round-robin`;I(t=>t&&{...t,routing_strategy:e}),B(!0),$(``);try{I(await C({routing_strategy:e}))}catch(e){I(e=>e&&{...e,routing_strategy:t}),$(e instanceof Error?e.message:String(e))}finally{B(!1)}}return be&&!X?(0,F.jsx)(le,{}):(0,F.jsxs)(`div`,{className:`space-y-6`,children:[(0,F.jsxs)(`section`,{className:`flex flex-wrap items-end justify-between gap-4 pb-4`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h2`,{"data-gsap-reveal":!0,className:`text-title font-semibold`,children:e(`systemSettingsTitle`)}),(0,F.jsx)(`p`,{className:`mt-1 max-w-2xl text-body leading-6 text-muted`,children:e(`systemSettingsLead`)})]}),(0,F.jsxs)(c,{size:`sm`,variant:`secondary`,isPending:xe,onPress:()=>void Se(!0),children:[(0,F.jsx)(ce,{size:15}),e(`checkUpdates`)]})]}),Q?(0,F.jsx)(f,{title:Q}):null,(0,F.jsxs)(y,{selectedKey:d,onSelectionChange:e=>D(String(e)),children:[(0,F.jsx)(y.ListContainer,{className:`w-fit max-w-full overflow-x-auto`,children:(0,F.jsxs)(y.List,{"aria-label":e(`systemSettingsTitle`),children:[(0,F.jsxs)(v,{id:`general`,className:`gap-1.5 whitespace-nowrap`,children:[(0,F.jsx)(y.Indicator,{}),(0,F.jsx)(ue,{size:13}),e(`settingsTabGeneral`)]}),(0,F.jsxs)(v,{id:`routing`,className:`gap-1.5 whitespace-nowrap`,children:[(0,F.jsx)(y.Indicator,{}),(0,F.jsx)(se,{size:13}),e(`settingsTabRouting`)]}),(0,F.jsxs)(v,{id:`security`,className:`gap-1.5 whitespace-nowrap`,children:[(0,F.jsx)(y.Indicator,{}),(0,F.jsx)(a,{size:13}),e(`settingsTabSecurity`)]}),(0,F.jsxs)(v,{id:`updates`,className:`gap-1.5 whitespace-nowrap`,children:[(0,F.jsx)(y.Indicator,{}),(0,F.jsx)(re,{size:13}),e(`settingsTabUpdates`)]})]})}),(0,F.jsx)(y.Panel,{id:`general`,className:`pt-5`,children:(0,F.jsxs)(`div`,{className:`grid gap-5 xl:grid-cols-2 items-start`,children:[(0,F.jsxs)(m,{"data-gsap-reveal":!0,children:[(0,F.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,F.jsx)(`div`,{className:`grid size-8 shrink-0 place-items-center rounded-lg bg-surface-secondary text-foreground`,children:(0,F.jsx)(P,{size:15})}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h3`,{className:`font-semibold`,children:e(`proxySettingsTitle`)}),(0,F.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:e(`proxySettingsHint`)})]})]}),(0,F.jsxs)(`div`,{className:`mt-4 space-y-1.5`,children:[(0,F.jsx)(l,{className:`text-body font-medium text-muted`,children:e(`proxyUrl`)}),(0,F.jsx)(ee,{value:L,onChange:e=>R(e.target.value),onBlur:e=>void ke(e.target.value.trim()),placeholder:e(`proxyUrlPlaceholder`),disabled:z||!N}),(0,F.jsx)(h,{className:`text-caption leading-5 text-muted`,children:e(`proxyUrlHint`)})]})]}),(0,F.jsxs)(m,{"data-gsap-reveal":!0,children:[(0,F.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,F.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,F.jsx)(`div`,{className:`grid size-8 shrink-0 place-items-center rounded-lg bg-surface-secondary text-foreground`,children:(0,F.jsx)(T,{size:15})}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h3`,{className:`font-semibold`,children:e(`checkinDisabledAccountsTitle`)}),(0,F.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:e(`checkinDisabledAccountsHint`)})]})]}),(0,F.jsx)(x,{isSelected:N?.checkin_disabled_accounts??!1,isDisabled:z||!N,ariaLabel:e(`checkinDisabledAccountsAriaLabel`),onChange:e=>void Oe(e)})]}),(0,F.jsxs)(`div`,{className:`mt-4 flex items-center justify-between pt-3 text-caption text-muted`,children:[(0,F.jsx)(`span`,{children:e(`checkinDisabledAccountsStatus`)}),(0,F.jsx)(`span`,{className:`font-medium text-foreground`,children:N?.checkin_disabled_accounts?e(`enabled`):e(`disabled`)})]})]})]})}),(0,F.jsx)(y.Panel,{id:`routing`,className:`pt-5`,children:(0,F.jsxs)(`div`,{className:`grid gap-5 xl:grid-cols-2 items-start`,children:[(0,F.jsxs)(m,{"data-gsap-reveal":!0,children:[(0,F.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,F.jsx)(`div`,{className:`grid size-8 shrink-0 place-items-center rounded-lg bg-surface-secondary text-foreground`,children:(0,F.jsx)(P,{size:15})}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h3`,{className:`font-semibold`,children:e(`routingStrategyTitle`)}),(0,F.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:e(`routingStrategyHint`)})]})]}),(0,F.jsx)(`div`,{className:`mt-4 pt-4`,children:(0,F.jsx)(g,{label:e(`routingStrategy`),children:(0,F.jsxs)(b,{fullWidth:!0,"aria-label":e(`routingStrategy`),value:N?.routing_strategy||`round-robin`,isDisabled:z||!N,onChange:e=>{typeof e==`string`&&e&&Ae(e)},children:[(0,F.jsxs)(b.Trigger,{className:`items-center`,children:[(0,F.jsx)(b.Value,{className:`min-w-0 truncate`}),(0,F.jsx)(b.Indicator,{})]}),(0,F.jsx)(b.Popover,{children:(0,F.jsxs)(u,{children:[(0,F.jsxs)(u.Item,{id:`round-robin`,textValue:`round-robin`,children:[(0,F.jsx)(l,{children:e(`routingRoundRobin`)}),(0,F.jsx)(u.ItemIndicator,{})]}),(0,F.jsxs)(u.Item,{id:`weighted-round-robin`,textValue:`weighted-round-robin`,children:[(0,F.jsx)(l,{children:e(`routingWeightedRoundRobin`)}),(0,F.jsx)(u.ItemIndicator,{})]}),(0,F.jsxs)(u.Item,{id:`fill-first`,textValue:`fill-first`,children:[(0,F.jsx)(l,{children:e(`routingFillFirst`)}),(0,F.jsx)(u.ItemIndicator,{})]}),(0,F.jsxs)(u.Item,{id:`fefo`,textValue:`fefo`,children:[(0,F.jsx)(l,{children:e(`routingFEFO`)}),(0,F.jsx)(u.ItemIndicator,{})]}),(0,F.jsxs)(u.Item,{id:`least-quota-first`,textValue:`least-quota-first`,children:[(0,F.jsx)(l,{children:e(`routingLeastQuotaFirst`)}),(0,F.jsx)(u.ItemIndicator,{})]}),(0,F.jsxs)(u.Item,{id:`most-quota-first`,textValue:`most-quota-first`,children:[(0,F.jsx)(l,{children:e(`routingMostQuotaFirst`)}),(0,F.jsx)(u.ItemIndicator,{})]})]})})]})})}),(0,F.jsxs)(`div`,{className:`mt-4 grid grid-cols-2 gap-2 pt-3 text-caption text-muted sm:grid-cols-4`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`span`,{className:`mono block text-body font-medium text-foreground`,children:N?.session_affinity?.ttl_seconds?`${Math.round(N.session_affinity.ttl_seconds/60)}m`:`—`}),e(`sessionAffinityTTL`)]}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`span`,{className:`mono block text-body font-medium text-foreground`,children:N?.session_affinity?.hits??0}),e(`sessionAffinityHits`)]}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`span`,{className:`mono block text-body font-medium text-foreground`,children:N?.session_affinity?.misses??0}),e(`sessionAffinityMisses`)]}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`span`,{className:`mono block text-body font-medium text-foreground`,children:N?.session_affinity?.escapes??0}),e(`sessionAffinityEscapes`)]})]}),N?.session_affinity?.last_escape_reason?(0,F.jsxs)(h,{className:`mt-3 text-caption`,children:[e(`lastSessionEscape`),`: `,N.session_affinity.last_escape_reason]}):null,N?.session_affinity?.last_miss_reason?(0,F.jsxs)(h,{className:`mt-1 text-caption`,children:[e(`lastSessionMiss`),`: `,N.session_affinity.last_miss_reason]}):null]}),(0,F.jsxs)(m,{"data-gsap-reveal":!0,children:[(0,F.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,F.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,F.jsx)(`div`,{className:`grid size-8 shrink-0 place-items-center rounded-lg bg-surface-secondary text-foreground`,children:(0,F.jsx)(P,{size:15})}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h3`,{className:`font-semibold`,children:e(`crossProviderModelPoolTitle`)}),(0,F.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:e(`crossProviderModelPoolHint`)})]})]}),(0,F.jsx)(x,{isSelected:N?.cross_provider_model_pool??!0,isDisabled:z||!N,ariaLabel:e(`crossProviderModelPoolAriaLabel`),onChange:e=>void De(e)})]}),(0,F.jsxs)(`div`,{className:`mt-4 flex items-center justify-between pt-3 text-caption text-muted`,children:[(0,F.jsx)(`span`,{children:e(`crossProviderModelPoolStatus`)}),(0,F.jsx)(`span`,{className:`font-medium text-foreground`,children:N?.cross_provider_model_pool?e(`enabled`):e(`disabled`)})]})]})]})}),(0,F.jsx)(y.Panel,{id:`security`,className:`pt-5`,children:(0,F.jsxs)(`div`,{className:`grid gap-5 xl:grid-cols-2 items-start`,children:[(0,F.jsxs)(m,{"data-gsap-reveal":!0,children:[(0,F.jsx)(`div`,{className:`flex items-start justify-between gap-4`,children:(0,F.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,F.jsx)(`div`,{className:`grid size-8 shrink-0 place-items-center rounded-lg bg-surface-secondary text-foreground`,children:(0,F.jsx)(ie,{size:15})}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h3`,{className:`font-semibold`,children:e(`consoleKeyTitle`)}),(0,F.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:e(`consoleKeyHint`)})]})]})}),(0,F.jsx)(`code`,{className:`mono mt-4 block rounded-lg bg-surface-secondary px-3 py-2 text-caption text-muted`,children:j?.prefix||`—`}),(0,F.jsx)(`p`,{className:`mt-3 text-caption leading-5 text-muted`,children:e(`consoleKeyLead`)}),(0,F.jsx)(`div`,{className:`mt-4 flex justify-end`,children:(0,F.jsx)(c,{size:`sm`,variant:`ghost`,isPending:V,onPress:()=>U(!0),children:e(`consoleKeyRotate`)})})]}),(0,F.jsxs)(m,{"data-gsap-reveal":!0,children:[(0,F.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,F.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,F.jsx)(`div`,{className:`grid size-8 shrink-0 place-items-center rounded-lg bg-surface-secondary text-foreground`,children:(0,F.jsx)(me,{size:15})}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h3`,{className:`font-semibold`,children:e(`sqliteProtection`)}),(0,F.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:e(`sqliteProtectionHint`)})]})]}),(0,F.jsx)(a,{size:18,className:`text-success`})]}),(0,F.jsx)(`div`,{className:`mono mt-4 rounded-lg bg-surface-secondary px-3 py-2 text-caption text-muted`,children:`/data`}),(0,F.jsxs)(`div`,{className:`mt-3 grid gap-2 text-caption text-muted`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(T,{size:14,className:`text-muted`}),e(`sqliteBackupBeforeUpdate`)]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(T,{size:14,className:`text-muted`}),e(`sqliteKeepFive`)]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(T,{size:14,className:`text-muted`}),e(`sqliteRollbackTogether`)]})]})]})]})}),(0,F.jsx)(y.Panel,{id:`updates`,className:`pt-5`,children:(0,F.jsx)(`div`,{className:`grid gap-5`,children:(0,F.jsxs)(m,{"data-gsap-reveal":!0,className:`overflow-hidden p-0`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-separator px-5 py-4`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h3`,{className:`font-semibold`,children:e(`versionUpdate`)}),(0,F.jsx)(`p`,{className:`mt-0.5 text-caption text-muted`,children:e(`latestVersionHint`)})]}),(0,F.jsx)(w,{size:`sm`,variant:`soft`,color:X?.has_update?`warning`:`success`,children:X?.has_update?e(`updateAvailable`):e(`upToDate`)})]}),(0,F.jsxs)(`div`,{className:`px-5 py-5`,children:[(0,F.jsx)(de,{update:Y}),(0,F.jsx)(he,{releases:Te,currentVersion:X?.current_version||``,nextVersion:X?.next_version,rollbackTags:Ee,canRollback:Ce,submitting:Z,onRestore:J})]})]})})})]}),(0,F.jsx)(p,{isOpen:!!q,title:e(`restoreVersionTitle`,{version:q}),description:e(`restoreVersionHint`),confirmLabel:e(`restoreThisVersion`),cancelLabel:e(`cancel`),closeLabel:e(`close`),isPending:Z,status:`warning`,confirmVariant:`primary`,onClose:()=>{Z||J(``)},onConfirm:()=>{let e=q;J(``),we(e)}}),(0,F.jsx)(_.Root,{isOpen:ve,onOpenChange:e=>{!e&&!V&&U(!1)},children:(0,F.jsx)(_.Backdrop,{variant:`blur`,isDismissable:!V,children:(0,F.jsx)(_.Container,{placement:`center`,size:`sm`,children:(0,F.jsxs)(_.Dialog,{children:[(0,F.jsxs)(_.Header,{className:`items-start justify-between gap-4`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(_.Heading,{className:`text-section font-semibold`,children:e(`consoleKeyRotate`)}),(0,F.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:e(`consoleKeyRotateHint`)})]}),(0,F.jsx)(_.CloseTrigger,{isDisabled:V,"aria-label":e(`close`),className:`grid size-8 place-items-center rounded-lg text-muted hover:bg-surface-secondary`,children:(0,F.jsx)(S,{size:16})})]}),(0,F.jsxs)(_.Footer,{className:`justify-end`,children:[(0,F.jsx)(c,{variant:`ghost`,isDisabled:V,onPress:()=>U(!1),children:e(`cancel`)}),(0,F.jsx)(c,{variant:`danger`,isPending:V,onPress:()=>{H(!0),fe().then(e=>{M(e),G(e.secret||``),e.secret&&O(e.secret),U(!1)}).catch(e=>{$(e instanceof Error?e.message:String(e))}).finally(()=>H(!1))},children:e(`consoleKeyRotateNow`)})]})]})})})}),(0,F.jsx)(_.Root,{isOpen:!!W,onOpenChange:e=>{e||G(``)},children:(0,F.jsx)(_.Backdrop,{variant:`blur`,children:(0,F.jsx)(_.Container,{placement:`center`,size:`lg`,children:(0,F.jsxs)(_.Dialog,{children:[(0,F.jsxs)(_.Header,{className:`items-start justify-between gap-4 px-6 pt-6`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(_.Heading,{className:`text-section font-semibold`,children:e(`consoleKeySecretTitle`)}),(0,F.jsx)(`p`,{className:`mt-1.5 text-body leading-6 text-muted`,children:e(`consoleKeySecretHint`)})]}),(0,F.jsx)(_.CloseTrigger,{"aria-label":e(`close`),className:`grid size-9 place-items-center rounded-lg text-muted hover:bg-surface-secondary`,children:(0,F.jsx)(S,{size:18})})]}),(0,F.jsx)(_.Body,{className:`px-6 pb-2`,children:(0,F.jsx)(`code`,{className:`mono block break-all rounded-lg bg-surface-secondary px-3 py-3 text-body`,children:W})}),(0,F.jsxs)(_.Footer,{className:`justify-end`,children:[(0,F.jsx)(c,{variant:`ghost`,onPress:()=>G(``),children:e(`close`)}),(0,F.jsxs)(c,{onPress:()=>{i(W),K(!0),window.setTimeout(()=>K(!1),1200)},children:[(0,F.jsx)(r,{size:14}),e(ye?`copied`:`copy`)]})]})]})})})})]})}export{R as SystemPage}; \ No newline at end of file diff --git a/internal/webui/static/assets/SystemPage-PP9VvzOw.js b/internal/webui/static/assets/SystemPage-PP9VvzOw.js new file mode 100644 index 00000000..5c48e8fe --- /dev/null +++ b/internal/webui/static/assets/SystemPage-PP9VvzOw.js @@ -0,0 +1 @@ +import{a as e,c as t,n}from"./shim-mfK0Rmj6.js";import{n as r,t as i}from"./clipboard-BWzpPXn-.js";import{t as a}from"./ShieldCheck.es-DReH26Zt.js";import{dt as o,n as s,r as c}from"./useI18n-BBOAnu2u.js";import{t as l}from"./label-BVCjtfNQ.js";import{t as u}from"./list-box-1t_n3N3P.js";import{t as d}from"./accordion-B-CD5Nsb.js";import{t as f}from"./PageAlert-DZC7IhXp.js";import{t as p}from"./ConfirmDialog-D6gNei8x.js";import{t as m}from"./card-QlCdtlk0.js";import{t as h}from"./description-CNxrVc-S.js";import{n as g,r as ee,t as te}from"./FormRow-Bhp_wPvH.js";import{t as _}from"./modal-DHeFzFnN.js";import{n as v,t as y}from"./tabs-CQ7Gr_Df.js";import{t as b}from"./select-BYBzHj05.js";import{P as ne}from"./overview-CJvUvgoD.js";import{C as re,E as x,Gt as ie,Kt as ae,M as S,O as C,Qt as oe,Rt as se,T as ce,Ut as w,Vt as le,h as T,kt as E,qt as ue}from"./index-B9eWF6SH.js";import{n as D,r as O,t as de}from"./UpdateControls-BMVq7AGm.js";import{a as fe,i as pe}from"./keys-Kp99scw1.js";var k=t(e(),1),A=new Map([[`bold`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M196,35.52C177.62,25.51,153.48,20,128,20S78.38,25.51,60,35.52C39.37,46.79,28,62.58,28,80v96c0,17.42,11.37,33.21,32,44.48,18.35,10,42.49,15.52,68,15.52s49.62-5.51,68-15.52c20.66-11.27,32-27.06,32-44.48V80C228,62.58,216.63,46.79,196,35.52ZM204,128c0,17-31.21,36-76,36s-76-19-76-36v-8.46a88.9,88.9,0,0,0,8,4.94c18.35,10,42.49,15.52,68,15.52s49.62-5.51,68-15.52a88.9,88.9,0,0,0,8-4.94ZM128,44c44.79,0,76,19,76,36s-31.21,36-76,36S52,97,52,80,83.21,44,128,44Zm0,168c-44.79,0-76-19-76-36v-8.46a88.9,88.9,0,0,0,8,4.94c18.35,10,42.49,15.52,68,15.52s49.62-5.51,68-15.52a88.9,88.9,0,0,0,8-4.94V176C204,193,172.79,212,128,212Z`}))],[`duotone`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M216,80c0,26.51-39.4,48-88,48S40,106.51,40,80s39.4-48,88-48S216,53.49,216,80Z`,opacity:`0.2`}),k.createElement(`path`,{d:`M128,24C74.17,24,32,48.6,32,80v96c0,31.4,42.17,56,96,56s96-24.6,96-56V80C224,48.6,181.83,24,128,24Zm80,104c0,9.62-7.88,19.43-21.61,26.92C170.93,163.35,150.19,168,128,168s-42.93-4.65-58.39-13.08C55.88,147.43,48,137.62,48,128V111.36c17.06,15,46.23,24.64,80,24.64s62.94-9.68,80-24.64ZM69.61,53.08C85.07,44.65,105.81,40,128,40s42.93,4.65,58.39,13.08C200.12,60.57,208,70.38,208,80s-7.88,19.43-21.61,26.92C170.93,115.35,150.19,120,128,120s-42.93-4.65-58.39-13.08C55.88,99.43,48,89.62,48,80S55.88,60.57,69.61,53.08ZM186.39,202.92C170.93,211.35,150.19,216,128,216s-42.93-4.65-58.39-13.08C55.88,195.43,48,185.62,48,176V159.36c17.06,15,46.23,24.64,80,24.64s62.94-9.68,80-24.64V176C208,185.62,200.12,195.43,186.39,202.92Z`}))],[`fill`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M128,24C74.17,24,32,48.6,32,80v96c0,31.4,42.17,56,96,56s96-24.6,96-56V80C224,48.6,181.83,24,128,24Zm80,104c0,9.62-7.88,19.43-21.61,26.92C170.93,163.35,150.19,168,128,168s-42.93-4.65-58.39-13.08C55.88,147.43,48,137.62,48,128V111.36c17.06,15,46.23,24.64,80,24.64s62.94-9.68,80-24.64Zm-21.61,74.92C170.93,211.35,150.19,216,128,216s-42.93-4.65-58.39-13.08C55.88,195.43,48,185.62,48,176V159.36c17.06,15,46.23,24.64,80,24.64s62.94-9.68,80-24.64V176C208,185.62,200.12,195.43,186.39,202.92Z`}))],[`light`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M128,26C75.29,26,34,49.72,34,80v96c0,30.28,41.29,54,94,54s94-23.72,94-54V80C222,49.72,180.71,26,128,26Zm0,12c44.45,0,82,19.23,82,42s-37.55,42-82,42S46,102.77,46,80,83.55,38,128,38Zm82,138c0,22.77-37.55,42-82,42s-82-19.23-82-42V154.79C62,171.16,92.37,182,128,182s66-10.84,82-27.21Zm0-48c0,22.77-37.55,42-82,42s-82-19.23-82-42V106.79C62,123.16,92.37,134,128,134s66-10.84,82-27.21Z`}))],[`regular`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M128,24C74.17,24,32,48.6,32,80v96c0,31.4,42.17,56,96,56s96-24.6,96-56V80C224,48.6,181.83,24,128,24Zm80,104c0,9.62-7.88,19.43-21.61,26.92C170.93,163.35,150.19,168,128,168s-42.93-4.65-58.39-13.08C55.88,147.43,48,137.62,48,128V111.36c17.06,15,46.23,24.64,80,24.64s62.94-9.68,80-24.64ZM69.61,53.08C85.07,44.65,105.81,40,128,40s42.93,4.65,58.39,13.08C200.12,60.57,208,70.38,208,80s-7.88,19.43-21.61,26.92C170.93,115.35,150.19,120,128,120s-42.93-4.65-58.39-13.08C55.88,99.43,48,89.62,48,80S55.88,60.57,69.61,53.08ZM186.39,202.92C170.93,211.35,150.19,216,128,216s-42.93-4.65-58.39-13.08C55.88,195.43,48,185.62,48,176V159.36c17.06,15,46.23,24.64,80,24.64s62.94-9.68,80-24.64V176C208,185.62,200.12,195.43,186.39,202.92Z`}))],[`thin`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M192.14,42.55C174.94,33.17,152.16,28,128,28S81.06,33.17,63.86,42.55C45.89,52.35,36,65.65,36,80v96c0,14.35,9.89,27.65,27.86,37.45,17.2,9.38,40,14.55,64.14,14.55s46.94-5.17,64.14-14.55c18-9.8,27.86-23.1,27.86-37.45V80C220,65.65,210.11,52.35,192.14,42.55ZM212,176c0,11.29-8.41,22.1-23.69,30.43C172.27,215.18,150.85,220,128,220s-44.27-4.82-60.31-13.57C52.41,198.1,44,187.29,44,176V149.48c4.69,5.93,11.37,11.34,19.86,16,17.2,9.38,40,14.55,64.14,14.55s46.94-5.17,64.14-14.55c8.49-4.63,15.17-10,19.86-16Zm0-48c0,11.29-8.41,22.1-23.69,30.43C172.27,167.18,150.85,172,128,172s-44.27-4.82-60.31-13.57C52.41,150.1,44,139.29,44,128V101.48c4.69,5.93,11.37,11.34,19.86,16,17.2,9.38,40,14.55,64.14,14.55s46.94-5.17,64.14-14.55c8.49-4.63,15.17-10,19.86-16Zm-23.69-17.57C172.27,119.18,150.85,124,128,124s-44.27-4.82-60.31-13.57C52.41,102.1,44,91.29,44,80s8.41-22.1,23.69-30.43C83.73,40.82,105.15,36,128,36s44.27,4.82,60.31,13.57C203.59,57.9,212,68.71,212,80S203.59,102.1,188.31,110.43Z`}))]]),j=new Map([[`bold`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M40,92H70.06a36,36,0,0,0,67.88,0H216a12,12,0,0,0,0-24H137.94a36,36,0,0,0-67.88,0H40a12,12,0,0,0,0,24Zm64-24A12,12,0,1,1,92,80,12,12,0,0,1,104,68Zm112,96H201.94a36,36,0,0,0-67.88,0H40a12,12,0,0,0,0,24h94.06a36,36,0,0,0,67.88,0H216a12,12,0,0,0,0-24Zm-48,24a12,12,0,1,1,12-12A12,12,0,0,1,168,188Z`}))],[`duotone`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M128,80a24,24,0,1,1-24-24A24,24,0,0,1,128,80Zm40,72a24,24,0,1,0,24,24A24,24,0,0,0,168,152Z`,opacity:`0.2`}),k.createElement(`path`,{d:`M40,88H73a32,32,0,0,0,62,0h81a8,8,0,0,0,0-16H135a32,32,0,0,0-62,0H40a8,8,0,0,0,0,16Zm64-24A16,16,0,1,1,88,80,16,16,0,0,1,104,64ZM216,168H199a32,32,0,0,0-62,0H40a8,8,0,0,0,0,16h97a32,32,0,0,0,62,0h17a8,8,0,0,0,0-16Zm-48,24a16,16,0,1,1,16-16A16,16,0,0,1,168,192Z`}))],[`fill`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M32,80a8,8,0,0,1,8-8H77.17a28,28,0,0,1,53.66,0H216a8,8,0,0,1,0,16H130.83a28,28,0,0,1-53.66,0H40A8,8,0,0,1,32,80Zm184,88H194.83a28,28,0,0,0-53.66,0H40a8,8,0,0,0,0,16H141.17a28,28,0,0,0,53.66,0H216a8,8,0,0,0,0-16Z`}))],[`light`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M40,86H74.6a30,30,0,0,0,58.8,0H216a6,6,0,0,0,0-12H133.4a30,30,0,0,0-58.8,0H40a6,6,0,0,0,0,12Zm64-24A18,18,0,1,1,86,80,18,18,0,0,1,104,62ZM216,170H197.4a30,30,0,0,0-58.8,0H40a6,6,0,0,0,0,12h98.6a30,30,0,0,0,58.8,0H216a6,6,0,0,0,0-12Zm-48,24a18,18,0,1,1,18-18A18,18,0,0,1,168,194Z`}))],[`regular`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M40,88H73a32,32,0,0,0,62,0h81a8,8,0,0,0,0-16H135a32,32,0,0,0-62,0H40a8,8,0,0,0,0,16Zm64-24A16,16,0,1,1,88,80,16,16,0,0,1,104,64ZM216,168H199a32,32,0,0,0-62,0H40a8,8,0,0,0,0,16h97a32,32,0,0,0,62,0h17a8,8,0,0,0,0-16Zm-48,24a16,16,0,1,1,16-16A16,16,0,0,1,168,192Z`}))],[`thin`,k.createElement(k.Fragment,null,k.createElement(`path`,{d:`M40,84H76.29a28,28,0,0,0,55.42,0H216a4,4,0,0,0,0-8H131.71a28,28,0,0,0-55.42,0H40a4,4,0,0,0,0,8Zm64-24A20,20,0,1,1,84,80,20,20,0,0,1,104,60ZM216,172H195.71a28,28,0,0,0-55.42,0H40a4,4,0,0,0,0,8H140.29a28,28,0,0,0,55.42,0H216a4,4,0,0,0,0-8Zm-48,24a20,20,0,1,1,20-20A20,20,0,0,1,168,196Z`}))]]),M=k.forwardRef((e,t)=>k.createElement(o,{ref:t,...e,weights:A}));M.displayName=`DatabaseIcon`;var me=M,N=k.forwardRef((e,t)=>k.createElement(o,{ref:t,...e,weights:j}));N.displayName=`SlidersHorizontalIcon`;var P=N,F=n();function I(e,t){if(!e)return``;let n=new Date(e);return Number.isNaN(n.getTime())?``:n.toLocaleDateString(t===`zh`?`zh-CN`:`en-US`,{year:`numeric`,month:`short`,day:`numeric`})}function he({releases:e,currentVersion:t,nextVersion:n,rollbackTags:r,canRollback:i,submitting:a,onRestore:o}){let{t:l,lang:u}=s();if(!e.length)return null;let f=n&&n!==t?n:t,p=e.some(e=>e.tag_name===f)?f:e[0]?.tag_name,m=new Set(r);return(0,F.jsxs)(`div`,{className:`mt-5`,children:[(0,F.jsx)(`div`,{className:`mb-2`,children:(0,F.jsx)(`p`,{className:`text-caption font-medium text-foreground`,children:l(`versionHistory`)})}),(0,F.jsx)(d,{className:`rounded-lg bg-surface-secondary`,hideSeparator:!0,defaultExpandedKeys:p?[p]:[],children:e.map(e=>{let r=e.tag_name,s=r===t,f=!!(n&&r===n&&n!==t),p=i&&m.has(r)&&!s,h=I(e.published_at,u);return(0,F.jsxs)(d.Item,{id:r,children:[(0,F.jsx)(d.Heading,{children:(0,F.jsxs)(d.Trigger,{className:`items-center gap-3 px-3 py-2.5 text-left`,children:[(0,F.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,F.jsx)(`span`,{className:`mono text-body font-semibold`,children:r}),s?(0,F.jsx)(S,{size:`sm`,variant:`soft`,color:`success`,children:l(`versionCurrentBadge`)}):null,f?(0,F.jsx)(S,{size:`sm`,variant:`soft`,color:`warning`,children:l(`versionLatestBadge`)}):null,h?(0,F.jsx)(`span`,{className:`truncate text-caption text-muted`,children:h}):null]}),(0,F.jsx)(d.Indicator,{})]})}),(0,F.jsx)(d.Panel,{children:(0,F.jsxs)(d.Body,{className:`px-3 pb-3`,children:[(0,F.jsx)(`div`,{className:`release-notes-box release-notes-box--compact`,children:(0,F.jsx)(D,{markdown:O(e.body,u),emptyLabel:l(`updateNoNotes`)})}),p?(0,F.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,F.jsx)(c,{size:`sm`,variant:`ghost`,isDisabled:a,onPress:()=>o(r),children:l(`restoreThisVersion`)})}):null]})})]},r)})})]})}function L(e){let t=new Set,n=[];for(let r of e){let e=r.tag_name?.trim();!e||t.has(e)||(t.add(e),n.push({...r,tag_name:e}))}return n}function ge(e,t,n,r,i){return r?.length?L(r):L([...n?[n]:t?[{tag_name:t}]:[],...e?[{tag_name:e}]:[],...i||[]])}var _e=[`general`,`routing`,`security`,`updates`];function R(){let{t:e}=s(),[t,n]=oe(),o=t.get(`tab`),d=o&&_e.includes(o)?o:`general`,D=e=>n(e===`general`?{}:{tab:e},{replace:!0}),{setApiKey:O}=ne(),{refresh:A}=C(),[j,M]=(0,k.useState)(null),[N,I]=(0,k.useState)(null),[L,R]=(0,k.useState)(``),[z,B]=(0,k.useState)(!1),[V,H]=(0,k.useState)(!1),[ve,U]=(0,k.useState)(!1),[W,G]=(0,k.useState)(``),[ye,K]=(0,k.useState)(!1),[q,J]=(0,k.useState)(``),Y=re(),{info:X,loading:be,checking:xe,submitting:Z,error:Q,setError:$,load:Se,canRollback:Ce,rollbackTo:we}=Y,Te=(0,k.useMemo)(()=>ge(X?.current_version||``,X?.next_version,X?.release,X?.recent_releases,X?.rollback_versions),[X?.current_version,X?.next_version,X?.release,X?.recent_releases,X?.rollback_versions]),Ee=(0,k.useMemo)(()=>(X?.rollback_versions||[]).map(e=>e.tag_name),[X?.rollback_versions]);(0,k.useEffect)(()=>{let e=window.setTimeout(()=>{pe().then(M).catch(()=>void 0),ce().then(e=>{I(e),R(e.proxy_url||``)}).catch(e=>$(e instanceof Error?e.message:String(e)))},0);return()=>window.clearTimeout(e)},[$]);async function De(e){let t=N?.cross_provider_model_pool??!0;I(t=>t&&{...t,cross_provider_model_pool:e}),B(!0),$(``);try{I(await x({cross_provider_model_pool:e})),A(void 0,{silent:!0}).catch(()=>void 0)}catch(e){I(e=>e&&{...e,cross_provider_model_pool:t}),$(e instanceof Error?e.message:String(e))}finally{B(!1)}}async function Oe(e){let t=N?.checkin_disabled_accounts??!1;I(t=>t&&{...t,checkin_disabled_accounts:e}),B(!0),$(``);try{I(await x({checkin_disabled_accounts:e}))}catch(e){I(e=>e&&{...e,checkin_disabled_accounts:t}),$(e instanceof Error?e.message:String(e))}finally{B(!1)}}async function ke(e){let t=N?.proxy_url||``;if(e===t){R(t);return}let n=L;R(e),I(t=>t&&{...t,proxy_url:e}),B(!0),$(``);try{let t=await x({proxy_url:e});I(t),R(t.proxy_url||``)}catch(e){R(n),I(e=>e&&{...e,proxy_url:t}),$(e instanceof Error?e.message:String(e))}finally{B(!1)}}async function Ae(e){let t=N?.routing_strategy||`round-robin`;I(t=>t&&{...t,routing_strategy:e}),B(!0),$(``);try{I(await x({routing_strategy:e}))}catch(e){I(e=>e&&{...e,routing_strategy:t}),$(e instanceof Error?e.message:String(e))}finally{B(!1)}}return be&&!X?(0,F.jsx)(T,{}):(0,F.jsxs)(`div`,{className:`space-y-6`,children:[(0,F.jsxs)(`section`,{className:`flex flex-wrap items-end justify-between gap-4 pb-4`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h2`,{"data-gsap-reveal":!0,className:`text-title font-semibold`,children:e(`systemSettingsTitle`)}),(0,F.jsx)(`p`,{className:`mt-1 max-w-2xl text-body leading-6 text-muted`,children:e(`systemSettingsLead`)})]}),(0,F.jsxs)(c,{size:`sm`,variant:`secondary`,isPending:xe,onPress:()=>void Se(!0),children:[(0,F.jsx)(ae,{size:15}),e(`checkUpdates`)]})]}),Q?(0,F.jsx)(f,{title:Q}):null,(0,F.jsxs)(y,{selectedKey:d,onSelectionChange:e=>D(String(e)),children:[(0,F.jsx)(y.ListContainer,{className:`w-fit max-w-full overflow-x-auto`,children:(0,F.jsxs)(y.List,{"aria-label":e(`systemSettingsTitle`),children:[(0,F.jsxs)(v,{id:`general`,className:`gap-1.5 whitespace-nowrap`,children:[(0,F.jsx)(y.Indicator,{}),(0,F.jsx)(le,{size:13}),e(`settingsTabGeneral`)]}),(0,F.jsxs)(v,{id:`routing`,className:`gap-1.5 whitespace-nowrap`,children:[(0,F.jsx)(y.Indicator,{}),(0,F.jsx)(ie,{size:13}),e(`settingsTabRouting`)]}),(0,F.jsxs)(v,{id:`security`,className:`gap-1.5 whitespace-nowrap`,children:[(0,F.jsx)(y.Indicator,{}),(0,F.jsx)(a,{size:13}),e(`settingsTabSecurity`)]}),(0,F.jsxs)(v,{id:`updates`,className:`gap-1.5 whitespace-nowrap`,children:[(0,F.jsx)(y.Indicator,{}),(0,F.jsx)(ue,{size:13}),e(`settingsTabUpdates`)]})]})}),(0,F.jsx)(y.Panel,{id:`general`,className:`pt-5`,children:(0,F.jsxs)(`div`,{className:`grid gap-5 xl:grid-cols-2 items-start`,children:[(0,F.jsxs)(m,{"data-gsap-reveal":!0,children:[(0,F.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,F.jsx)(`div`,{className:`grid size-8 shrink-0 place-items-center rounded-lg bg-surface-secondary text-foreground`,children:(0,F.jsx)(P,{size:15})}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h3`,{className:`font-semibold`,children:e(`proxySettingsTitle`)}),(0,F.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:e(`proxySettingsHint`)})]})]}),(0,F.jsxs)(`div`,{className:`mt-4 space-y-1.5`,children:[(0,F.jsx)(l,{className:`text-body font-medium text-muted`,children:e(`proxyUrl`)}),(0,F.jsx)(ee,{value:L,onChange:e=>R(e.target.value),onBlur:e=>void ke(e.target.value.trim()),placeholder:e(`proxyUrlPlaceholder`),disabled:z||!N}),(0,F.jsx)(h,{className:`text-caption leading-5 text-muted`,children:e(`proxyUrlHint`)})]})]}),(0,F.jsxs)(m,{"data-gsap-reveal":!0,children:[(0,F.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,F.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,F.jsx)(`div`,{className:`grid size-8 shrink-0 place-items-center rounded-lg bg-surface-secondary text-foreground`,children:(0,F.jsx)(w,{size:15})}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h3`,{className:`font-semibold`,children:e(`checkinDisabledAccountsTitle`)}),(0,F.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:e(`checkinDisabledAccountsHint`)})]})]}),(0,F.jsx)(g,{isSelected:N?.checkin_disabled_accounts??!1,isDisabled:z||!N,ariaLabel:e(`checkinDisabledAccountsAriaLabel`),onChange:e=>void Oe(e)})]}),(0,F.jsxs)(`div`,{className:`mt-4 flex items-center justify-between pt-3 text-caption text-muted`,children:[(0,F.jsx)(`span`,{children:e(`checkinDisabledAccountsStatus`)}),(0,F.jsx)(`span`,{className:`font-medium text-foreground`,children:N?.checkin_disabled_accounts?e(`enabled`):e(`disabled`)})]})]})]})}),(0,F.jsx)(y.Panel,{id:`routing`,className:`pt-5`,children:(0,F.jsxs)(`div`,{className:`grid gap-5 xl:grid-cols-2 items-start`,children:[(0,F.jsxs)(m,{"data-gsap-reveal":!0,children:[(0,F.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,F.jsx)(`div`,{className:`grid size-8 shrink-0 place-items-center rounded-lg bg-surface-secondary text-foreground`,children:(0,F.jsx)(P,{size:15})}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h3`,{className:`font-semibold`,children:e(`routingStrategyTitle`)}),(0,F.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:e(`routingStrategyHint`)})]})]}),(0,F.jsx)(`div`,{className:`mt-4 pt-4`,children:(0,F.jsx)(te,{label:e(`routingStrategy`),children:(0,F.jsxs)(b,{fullWidth:!0,"aria-label":e(`routingStrategy`),value:N?.routing_strategy||`round-robin`,isDisabled:z||!N,onChange:e=>{typeof e==`string`&&e&&Ae(e)},children:[(0,F.jsxs)(b.Trigger,{className:`items-center`,children:[(0,F.jsx)(b.Value,{className:`min-w-0 truncate`}),(0,F.jsx)(b.Indicator,{})]}),(0,F.jsx)(b.Popover,{children:(0,F.jsxs)(u,{children:[(0,F.jsxs)(u.Item,{id:`round-robin`,textValue:`round-robin`,children:[(0,F.jsx)(l,{children:e(`routingRoundRobin`)}),(0,F.jsx)(u.ItemIndicator,{})]}),(0,F.jsxs)(u.Item,{id:`weighted-round-robin`,textValue:`weighted-round-robin`,children:[(0,F.jsx)(l,{children:e(`routingWeightedRoundRobin`)}),(0,F.jsx)(u.ItemIndicator,{})]}),(0,F.jsxs)(u.Item,{id:`fill-first`,textValue:`fill-first`,children:[(0,F.jsx)(l,{children:e(`routingFillFirst`)}),(0,F.jsx)(u.ItemIndicator,{})]}),(0,F.jsxs)(u.Item,{id:`fefo`,textValue:`fefo`,children:[(0,F.jsx)(l,{children:e(`routingFEFO`)}),(0,F.jsx)(u.ItemIndicator,{})]}),(0,F.jsxs)(u.Item,{id:`least-quota-first`,textValue:`least-quota-first`,children:[(0,F.jsx)(l,{children:e(`routingLeastQuotaFirst`)}),(0,F.jsx)(u.ItemIndicator,{})]}),(0,F.jsxs)(u.Item,{id:`most-quota-first`,textValue:`most-quota-first`,children:[(0,F.jsx)(l,{children:e(`routingMostQuotaFirst`)}),(0,F.jsx)(u.ItemIndicator,{})]})]})})]})})}),(0,F.jsxs)(`div`,{className:`mt-4 grid grid-cols-2 gap-2 pt-3 text-caption text-muted sm:grid-cols-4`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`span`,{className:`mono block text-body font-medium text-foreground`,children:N?.session_affinity?.ttl_seconds?`${Math.round(N.session_affinity.ttl_seconds/60)}m`:`—`}),e(`sessionAffinityTTL`)]}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`span`,{className:`mono block text-body font-medium text-foreground`,children:N?.session_affinity?.hits??0}),e(`sessionAffinityHits`)]}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`span`,{className:`mono block text-body font-medium text-foreground`,children:N?.session_affinity?.misses??0}),e(`sessionAffinityMisses`)]}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`span`,{className:`mono block text-body font-medium text-foreground`,children:N?.session_affinity?.escapes??0}),e(`sessionAffinityEscapes`)]})]}),N?.session_affinity?.last_escape_reason?(0,F.jsxs)(h,{className:`mt-3 text-caption`,children:[e(`lastSessionEscape`),`: `,N.session_affinity.last_escape_reason]}):null,N?.session_affinity?.last_miss_reason?(0,F.jsxs)(h,{className:`mt-1 text-caption`,children:[e(`lastSessionMiss`),`: `,N.session_affinity.last_miss_reason]}):null]}),(0,F.jsxs)(m,{"data-gsap-reveal":!0,children:[(0,F.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,F.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,F.jsx)(`div`,{className:`grid size-8 shrink-0 place-items-center rounded-lg bg-surface-secondary text-foreground`,children:(0,F.jsx)(P,{size:15})}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h3`,{className:`font-semibold`,children:e(`crossProviderModelPoolTitle`)}),(0,F.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:e(`crossProviderModelPoolHint`)})]})]}),(0,F.jsx)(g,{isSelected:N?.cross_provider_model_pool??!0,isDisabled:z||!N,ariaLabel:e(`crossProviderModelPoolAriaLabel`),onChange:e=>void De(e)})]}),(0,F.jsxs)(`div`,{className:`mt-4 flex items-center justify-between pt-3 text-caption text-muted`,children:[(0,F.jsx)(`span`,{children:e(`crossProviderModelPoolStatus`)}),(0,F.jsx)(`span`,{className:`font-medium text-foreground`,children:N?.cross_provider_model_pool?e(`enabled`):e(`disabled`)})]})]})]})}),(0,F.jsx)(y.Panel,{id:`security`,className:`pt-5`,children:(0,F.jsxs)(`div`,{className:`grid gap-5 xl:grid-cols-2 items-start`,children:[(0,F.jsxs)(m,{"data-gsap-reveal":!0,children:[(0,F.jsx)(`div`,{className:`flex items-start justify-between gap-4`,children:(0,F.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,F.jsx)(`div`,{className:`grid size-8 shrink-0 place-items-center rounded-lg bg-surface-secondary text-foreground`,children:(0,F.jsx)(se,{size:15})}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h3`,{className:`font-semibold`,children:e(`consoleKeyTitle`)}),(0,F.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:e(`consoleKeyHint`)})]})]})}),(0,F.jsx)(`code`,{className:`mono mt-4 block rounded-lg bg-surface-secondary px-3 py-2 text-caption text-muted`,children:j?.prefix||`—`}),(0,F.jsx)(`p`,{className:`mt-3 text-caption leading-5 text-muted`,children:e(`consoleKeyLead`)}),(0,F.jsx)(`div`,{className:`mt-4 flex justify-end`,children:(0,F.jsx)(c,{size:`sm`,variant:`ghost`,isPending:V,onPress:()=>U(!0),children:e(`consoleKeyRotate`)})})]}),(0,F.jsxs)(m,{"data-gsap-reveal":!0,children:[(0,F.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,F.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,F.jsx)(`div`,{className:`grid size-8 shrink-0 place-items-center rounded-lg bg-surface-secondary text-foreground`,children:(0,F.jsx)(me,{size:15})}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h3`,{className:`font-semibold`,children:e(`sqliteProtection`)}),(0,F.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:e(`sqliteProtectionHint`)})]})]}),(0,F.jsx)(a,{size:18,className:`text-success`})]}),(0,F.jsx)(`div`,{className:`mono mt-4 rounded-lg bg-surface-secondary px-3 py-2 text-caption text-muted`,children:`/data`}),(0,F.jsxs)(`div`,{className:`mt-3 grid gap-2 text-caption text-muted`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(w,{size:14,className:`text-muted`}),e(`sqliteBackupBeforeUpdate`)]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(w,{size:14,className:`text-muted`}),e(`sqliteKeepFive`)]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(w,{size:14,className:`text-muted`}),e(`sqliteRollbackTogether`)]})]})]})]})}),(0,F.jsx)(y.Panel,{id:`updates`,className:`pt-5`,children:(0,F.jsx)(`div`,{className:`grid gap-5`,children:(0,F.jsxs)(m,{"data-gsap-reveal":!0,className:`overflow-hidden p-0`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-separator px-5 py-4`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h3`,{className:`font-semibold`,children:e(`versionUpdate`)}),(0,F.jsx)(`p`,{className:`mt-0.5 text-caption text-muted`,children:e(`latestVersionHint`)})]}),(0,F.jsx)(S,{size:`sm`,variant:`soft`,color:X?.has_update?`warning`:`success`,children:X?.has_update?e(`updateAvailable`):e(`upToDate`)})]}),(0,F.jsxs)(`div`,{className:`px-5 py-5`,children:[(0,F.jsx)(de,{update:Y}),(0,F.jsx)(he,{releases:Te,currentVersion:X?.current_version||``,nextVersion:X?.next_version,rollbackTags:Ee,canRollback:Ce,submitting:Z,onRestore:J})]})]})})})]}),(0,F.jsx)(p,{isOpen:!!q,title:e(`restoreVersionTitle`,{version:q}),description:e(`restoreVersionHint`),confirmLabel:e(`restoreThisVersion`),cancelLabel:e(`cancel`),closeLabel:e(`close`),isPending:Z,status:`warning`,confirmVariant:`primary`,onClose:()=>{Z||J(``)},onConfirm:()=>{let e=q;J(``),we(e)}}),(0,F.jsx)(_.Root,{isOpen:ve,onOpenChange:e=>{!e&&!V&&U(!1)},children:(0,F.jsx)(_.Backdrop,{variant:`blur`,isDismissable:!V,children:(0,F.jsx)(_.Container,{placement:`center`,size:`sm`,children:(0,F.jsxs)(_.Dialog,{children:[(0,F.jsxs)(_.Header,{className:`items-start justify-between gap-4`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(_.Heading,{className:`text-section font-semibold`,children:e(`consoleKeyRotate`)}),(0,F.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:e(`consoleKeyRotateHint`)})]}),(0,F.jsx)(_.CloseTrigger,{isDisabled:V,"aria-label":e(`close`),className:`grid size-8 place-items-center rounded-lg text-muted hover:bg-surface-secondary`,children:(0,F.jsx)(E,{size:16})})]}),(0,F.jsxs)(_.Footer,{className:`justify-end`,children:[(0,F.jsx)(c,{variant:`ghost`,isDisabled:V,onPress:()=>U(!1),children:e(`cancel`)}),(0,F.jsx)(c,{variant:`danger`,isPending:V,onPress:()=>{H(!0),fe().then(e=>{M(e),G(e.secret||``),e.secret&&O(e.secret),U(!1)}).catch(e=>{$(e instanceof Error?e.message:String(e))}).finally(()=>H(!1))},children:e(`consoleKeyRotateNow`)})]})]})})})}),(0,F.jsx)(_.Root,{isOpen:!!W,onOpenChange:e=>{e||G(``)},children:(0,F.jsx)(_.Backdrop,{variant:`blur`,children:(0,F.jsx)(_.Container,{placement:`center`,size:`lg`,children:(0,F.jsxs)(_.Dialog,{children:[(0,F.jsxs)(_.Header,{className:`items-start justify-between gap-4 px-6 pt-6`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(_.Heading,{className:`text-section font-semibold`,children:e(`consoleKeySecretTitle`)}),(0,F.jsx)(`p`,{className:`mt-1.5 text-body leading-6 text-muted`,children:e(`consoleKeySecretHint`)})]}),(0,F.jsx)(_.CloseTrigger,{"aria-label":e(`close`),className:`grid size-9 place-items-center rounded-lg text-muted hover:bg-surface-secondary`,children:(0,F.jsx)(E,{size:18})})]}),(0,F.jsx)(_.Body,{className:`px-6 pb-2`,children:(0,F.jsx)(`code`,{className:`mono block break-all rounded-lg bg-surface-secondary px-3 py-3 text-body`,children:W})}),(0,F.jsxs)(_.Footer,{className:`justify-end`,children:[(0,F.jsx)(c,{variant:`ghost`,onPress:()=>G(``),children:e(`close`)}),(0,F.jsxs)(c,{onPress:()=>{i(W),K(!0),window.setTimeout(()=>K(!1),1200)},children:[(0,F.jsx)(r,{size:14}),e(ye?`copied`:`copy`)]})]})]})})})})]})}export{R as SystemPage}; \ No newline at end of file diff --git a/internal/webui/static/assets/TimeRangePicker-C118rt0G.js b/internal/webui/static/assets/TimeRangePicker-C118rt0G.js deleted file mode 100644 index 3aa5ab21..00000000 --- a/internal/webui/static/assets/TimeRangePicker-C118rt0G.js +++ /dev/null @@ -1 +0,0 @@ -import{a as e,c as t,n}from"./shim-mfK0Rmj6.js";import{A as r,D as i,E as a,H as o,I as s,O as c,Q as l,V as u,X as d,Z as f,a as p,j as m,k as h,ot as g,ut as _,w as v,z as y}from"./useI18n-BSw4X3mq.js";import{$ as b,A as x,B as S,Ct as C,F as w,G as T,I as E,J as D,L as O,M as k,N as A,Q as ee,R as te,Y as j,Z as ne,_t as M,a as re,c as N,ct as ie,d as P,dt as ae,f as oe,j as se,k as F,l as ce,lt as le,m as ue,o as de,q as I,s as L,tt as fe,u as pe,w as me,x as he,z as ge}from"./SharedElementTransition-BlCsXfb1.js";import{t as _e}from"./useUpdateEffect-DR9d7F-l.js";import{a as ve,c as ye,d as be,f as xe,g as Se,h as Ce,l as we,m as Te,n as Ee,o as De,p as Oe,r as ke,t as Ae,u as je,v as Me,y as Ne}from"./label-n7vfsS35.js";import{n as Pe,r as Fe,t as Ie}from"./useSpinButton-F2mxX7Qy.js";import{t as Le}from"./assertion-BLQtDfw6.js";import{O as Re}from"./overview-m01k08K8.js";import{Ct as ze,St as Be,Tt as Ve,U as He,W as Ue,bt as We,ot as Ge,wt as Ke,xt as qe,yt as Je}from"./index-C8_qeOs_.js";var R=t(e(),1);function Ye(e,t){let n=(0,R.useRef)(null);return e&&n.current&&t(e,n.current)&&(e=n.current),n.current=e,e}var Xe=ge({slots:{trigger:`calendar-year-picker__trigger`,triggerHeading:`calendar-year-picker__trigger-heading`,triggerIndicator:`calendar-year-picker__trigger-indicator`,yearCell:`calendar-year-picker__year-cell`,yearGrid:`calendar-year-picker__year-grid`}}),Ze=ge({defaultVariants:{},slots:{base:`range-calendar`,cell:`range-calendar__cell`,cellIndicator:`range-calendar__cell-indicator`,grid:`range-calendar__grid`,gridBody:`range-calendar__grid-body`,gridHeader:`range-calendar__grid-header`,gridRow:`range-calendar__grid-row`,header:`range-calendar__header`,headerCell:`range-calendar__header-cell`,heading:`range-calendar__heading`,navButton:`range-calendar__nav-button`,navButtonIcon:`range-calendar__nav-button-icon`},variants:{}}),Qe=ge({base:`date-field`,defaultVariants:{fullWidth:!1},variants:{fullWidth:{false:``,true:`date-field--full-width`}}}),$e=ge({slots:{base:`date-range-picker`,popover:`date-range-picker__popover`,rangeSeparator:`date-range-picker__range-separator`,trigger:`date-range-picker__trigger`,triggerIndicator:`date-range-picker__trigger-indicator`}}),et=ge({defaultVariants:{fullWidth:!1,variant:`primary`},slots:{base:`date-input-group`,input:`date-input-group__input`,inputContainer:`date-input-group__input-container`,prefix:`date-input-group__prefix`,segment:`date-input-group__segment`,suffix:`date-input-group__suffix`},variants:{fullWidth:{false:{},true:{base:`date-input-group--full-width`}},variant:{primary:{base:`date-input-group--primary`},secondary:{base:`date-input-group--secondary`}}}}),tt=ge({base:`time-field`,defaultVariants:{fullWidth:!1},variants:{fullWidth:{false:``,true:`time-field--full-width`}}});function nt(e){let t=Ge({usage:`search`,...e}),n=(0,R.useCallback)((e,n)=>n.length===0||(e=e.normalize(`NFC`),n=n.normalize(`NFC`),t.compare(e.slice(0,n.length),n)===0),[t]),r=(0,R.useCallback)((e,n)=>n.length===0||(e=e.normalize(`NFC`),n=n.normalize(`NFC`),t.compare(e.slice(-n.length),n)===0),[t]),i=(0,R.useCallback)((e,n)=>{if(n.length===0)return!0;e=e.normalize(`NFC`),n=n.normalize(`NFC`);let r=0,i=n.length;for(;r+i<=e.length;r++){let a=e.slice(r,r+i);if(t.compare(n,a)===0)return!0}return!1},[t]);return(0,R.useMemo)(()=>({startsWith:n,endsWith:r,contains:i}),[n,r,i])}function rt(e,t){return e-t*Math.floor(e/t)}var it=1721426;function at(e,t,n,r){t=st(e,t);let i=t-1,a=-2;return n<=2?a=0:ot(t)&&(a=-1),1721425+365*i+Math.floor(i/4)-Math.floor(i/100)+Math.floor(i/400)+Math.floor((367*n-362)/12+a+r)}function ot(e){return e%4==0&&(e%100!=0||e%400==0)}function st(e,t){return e===`BC`?1-t:t}function ct(e){let t=`AD`;return e<=0&&(t=`BC`,e=1-e),[t,e]}var lt={standard:[31,28,31,30,31,30,31,31,30,31,30,31],leapyear:[31,29,31,30,31,30,31,31,30,31,30,31]},z=class{fromJulianDay(e){let t=e,n=t-it,r=Math.floor(n/146097),i=rt(n,146097),a=Math.floor(i/36524),o=rt(i,36524),s=Math.floor(o/1461),c=rt(o,1461),l=Math.floor(c/365),[u,d]=ct(r*400+a*100+s*4+l+ +(a!==4&&l!==4)),f=t-at(u,d,1,1),p=2;t=0?e:t:e||t}function zt(e){return e=G(e,new z),Bt(st(e.era,e.year),e.month,e.day,e.hour,e.minute,e.second,e.millisecond)}function Bt(e,t,n,r,i,a,o){let s=new Date;return s.setUTCHours(r,i,a,o),s.setUTCFullYear(e,t-1,n),s.getTime()}function Vt(e,t){if(t===`UTC`)return 0;if(e>0&&t===Tt()&&!Et())return new Date(e).getTimezoneOffset()*-6e4;let{year:n,month:r,day:i,hour:a,minute:o,second:s}=Ut(e,t);return Bt(n,r,i,a,o,s,0)-Math.floor(e/1e3)*1e3}var Ht=new Map;function Ut(e,t){let n=Ht.get(t);n||(n=new Intl.DateTimeFormat(`en-US`,{timeZone:t,hour12:!1,era:`short`,year:`numeric`,month:`numeric`,day:`numeric`,hour:`numeric`,minute:`numeric`,second:`numeric`}),Ht.set(t,n));let r=n.formatToParts(new Date(e)),i={};for(let e of r)e.type!==`literal`&&(i[e.type]=e.value);return{year:i.era===`BC`||i.era===`B`?-i.year+1:+i.year,month:+i.month,day:+i.day,hour:i.hour===`24`?0:+i.hour,minute:+i.minute,second:+i.second}}var Wt=864e5;function Gt(e,t,n,r){return(n===r?[n]:[n,r]).filter(n=>Kt(e,t,n))}function Kt(e,t,n){let r=Ut(n,t);return e.year===r.year&&e.month===r.month&&e.day===r.day&&e.hour===r.hour&&e.minute===r.minute&&e.second===r.second}function V(e,t,n=`compatible`){let r=W(e);if(t===`UTC`)return zt(r);if(t===Tt()&&n===`compatible`&&!Et()){r=G(r,new z);let e=new Date,t=st(r.era,r.year);return e.setFullYear(t,r.month-1,r.day),e.setHours(r.hour,r.minute,r.second,r.millisecond),e.getTime()}let i=zt(r),a=Vt(i-Wt,t),o=Vt(i+Wt,t),s=Gt(r,t,i-a,i-o);if(s.length===1)return s[0];if(s.length>1)switch(n){case`compatible`:case`earlier`:return s[0];case`later`:return s[s.length-1];case`reject`:throw RangeError(`Multiple possible absolute times found`)}switch(n){case`earlier`:return Math.min(i-a,i-o);case`compatible`:case`later`:return Math.max(i-a,i-o);case`reject`:throw RangeError(`No such absolute time found`)}}function qt(e,t,n=`compatible`){return new Date(V(e,t,n))}function H(e,t){let n=Vt(e,t),r=new Date(e+n),i=r.getUTCFullYear(),a=r.getUTCMonth()+1,o=r.getUTCDate(),s=r.getUTCHours(),c=r.getUTCMinutes(),l=r.getUTCSeconds(),u=r.getUTCMilliseconds();return new zn(i<1?`BC`:`AD`,i<1?-i+1:i,a,o,t,n,s,c,l,u)}function U(e){return new q(e.calendar,e.era,e.year,e.month,e.day)}function W(e,t){let n=0,r=0,i=0,a=0;if(`timeZone`in e)({hour:n,minute:r,second:i,millisecond:a}=e);else if(`hour`in e&&!t)return e;return t&&({hour:n,minute:r,second:i,millisecond:a}=t),new Rn(e.calendar,e.era,e.year,e.month,e.day,n,r,i,a)}function Jt(e){return new Ln(e.hour,e.minute,e.second,e.millisecond)}function G(e,t){if(mt(e.calendar,t))return e;let n=t.fromJulianDay(e.calendar.toJulianDay(e)),r=e.copy();return r.calendar=t,r.era=n.era,r.year=n.year,r.month=n.month,r.day=n.day,on(r),r}function Yt(e,t,n){return e instanceof zn?e.timeZone===t?e:Zt(e,t):H(V(e,t,n),t)}function Xt(e){let t=zt(e)-e.offset;return new Date(t)}function Zt(e,t){return G(H(zt(e)-e.offset,t),e.calendar)}function Qt(e){return Zt(e,Tt())}var $t=36e5;function en(e,t){let n=e.copy(),r=`hour`in n?mn(n,t):0;tn(n,t.years||0),n.calendar.balanceYearMonth&&n.calendar.balanceYearMonth(n,e),n.month+=t.months||0,nn(n),an(n),n.day+=(t.weeks||0)*7,n.day+=t.days||0,n.day+=r,rn(n),n.calendar.balanceDate&&n.calendar.balanceDate(n),n.year<1&&(n.year=1,n.month=1,n.day=1);let i=n.calendar.getYearsInEra(n);if(n.year>i){let e=n.calendar.isInverseEra?.(n);n.year=i,n.month=e?1:n.calendar.getMonthsInYear(n),n.day=e?1:n.calendar.getDaysInMonth(n)}n.month<1&&(n.month=1,n.day=1);let a=n.calendar.getMonthsInYear(n);return n.month>a&&(n.month=a,n.day=n.calendar.getDaysInMonth(n)),n.day=Math.max(1,Math.min(n.calendar.getDaysInMonth(n),n.day)),n}function tn(e,t){e.calendar.isInverseEra?.(e)&&(t=-t),e.year+=t}function nn(e){for(;e.month<1;)tn(e,-1),e.month+=e.calendar.getMonthsInYear(e);let t=0;for(;e.month>(t=e.calendar.getMonthsInYear(e));)e.month-=t,tn(e,1)}function rn(e){for(;e.day<1;)e.month--,nn(e),e.day+=e.calendar.getDaysInMonth(e);for(;e.day>e.calendar.getDaysInMonth(e);)e.day-=e.calendar.getDaysInMonth(e),e.month++,nn(e)}function an(e){e.month=Math.max(1,Math.min(e.calendar.getMonthsInYear(e),e.month)),e.day=Math.max(1,Math.min(e.calendar.getDaysInMonth(e),e.day))}function on(e){e.calendar.constrainDate&&e.calendar.constrainDate(e),e.year=Math.max(1,Math.min(e.calendar.getYearsInEra(e),e.year)),an(e)}function sn(e){let t={};for(let n in e)typeof e[n]==`number`&&(t[n]=-e[n]);return t}function cn(e,t){return en(e,sn(t))}function ln(e,t){let n=e.copy();return t.era!=null&&(n.era=t.era),t.year!=null&&(n.year=t.year),t.month!=null&&(n.month=t.month),t.day!=null&&(n.day=t.day),on(n),n}function un(e,t){let n=e.copy();return t.hour!=null&&(n.hour=t.hour),t.minute!=null&&(n.minute=t.minute),t.second!=null&&(n.second=t.second),t.millisecond!=null&&(n.millisecond=t.millisecond),fn(n),n}function dn(e){e.second+=Math.floor(e.millisecond/1e3),e.millisecond=pn(e.millisecond,1e3),e.minute+=Math.floor(e.second/60),e.second=pn(e.second,60),e.hour+=Math.floor(e.minute/60),e.minute=pn(e.minute,60);let t=Math.floor(e.hour/24);return e.hour=pn(e.hour,24),t}function fn(e){e.millisecond=Math.max(0,Math.min(e.millisecond,999)),e.second=Math.max(0,Math.min(e.second,59)),e.minute=Math.max(0,Math.min(e.minute,59)),e.hour=Math.max(0,Math.min(e.hour,23))}function pn(e,t){let n=e%t;return n<0&&(n+=t),n}function mn(e,t){return e.hour+=t.hours||0,e.minute+=t.minutes||0,e.second+=t.seconds||0,e.millisecond+=t.milliseconds||0,dn(e)}function hn(e,t){let n=e.copy();return mn(n,t),n}function gn(e,t){return hn(e,sn(t))}function _n(e,t,n,r){let i=e.copy();switch(t){case`era`:{let t=e.calendar.getEras(),a=t.indexOf(e.era);if(a<0)throw Error(`Invalid era: `+e.era);a=yn(a,n,0,t.length-1,r?.round),i.era=t[a],on(i);break}case`year`:i.calendar.isInverseEra?.(i)&&(n=-n),i.year=yn(e.year,n,-1/0,9999,r?.round),i.year===-1/0&&(i.year=1),i.calendar.balanceYearMonth&&i.calendar.balanceYearMonth(i,e);break;case`month`:i.month=yn(e.month,n,1,e.calendar.getMonthsInYear(e),r?.round);break;case`day`:i.day=yn(e.day,n,1,e.calendar.getDaysInMonth(e),r?.round);break;default:throw Error(`Unsupported field `+t)}return e.calendar.balanceDate&&e.calendar.balanceDate(i),on(i),i}function vn(e,t,n,r){let i=e.copy();switch(t){case`hour`:{let t=e.hour,a=0,o=23;if(r?.hourCycle===12){let e=t>=12;a=e?12:0,o=e?23:11}i.hour=yn(t,n,a,o,r?.round);break}case`minute`:i.minute=yn(e.minute,n,0,59,r?.round);break;case`second`:i.second=yn(e.second,n,0,59,r?.round);break;case`millisecond`:i.millisecond=yn(e.millisecond,n,0,999,r?.round);break;default:throw Error(`Unsupported field `+t)}return i}function yn(e,t,n,r,i=!1){if(i){e+=Math.sign(t),e0?Math.ceil(e/i)*i:Math.floor(e/i)*i,e>r&&(e=n)}else e+=t,er&&(e=n+(e-r-1));return e}function bn(e,t){let n;return n=t.years!=null&&t.years!==0||t.months!=null&&t.months!==0||t.weeks!=null&&t.weeks!==0||t.days!=null&&t.days!==0?V(en(W(e),{years:t.years,months:t.months,weeks:t.weeks,days:t.days}),e.timeZone):zt(e)-e.offset,n+=t.milliseconds||0,n+=(t.seconds||0)*1e3,n+=(t.minutes||0)*6e4,n+=(t.hours||0)*36e5,G(H(n,e.timeZone),e.calendar)}function xn(e,t){return bn(e,sn(t))}function Sn(e,t,n,r){switch(t){case`hour`:{let t=0,i=23;if(r?.hourCycle===12){let n=e.hour>=12;t=n?12:0,i=n?23:11}let a=W(e),o=G(un(a,{hour:t}),new z),s=[V(o,e.timeZone,`earlier`),V(o,e.timeZone,`later`)].filter(t=>H(t,e.timeZone).day===o.day)[0],c=G(un(a,{hour:i}),new z),l=[V(c,e.timeZone,`earlier`),V(c,e.timeZone,`later`)].filter(t=>H(t,e.timeZone).day===c.day).pop(),u=zt(e)-e.offset,d=Math.floor(u/$t),f=u%$t;return u=yn(d,n,Math.floor(s/$t),Math.floor(l/$t),r?.round)*$t+f,G(H(u,e.timeZone),e.calendar)}case`minute`:case`second`:case`millisecond`:return vn(e,t,n,r);case`era`:case`year`:case`month`:case`day`:return G(H(V(_n(W(e),t,n,r),e.timeZone),e.timeZone),e.calendar);default:throw Error(`Unsupported field `+t)}}function Cn(e,t,n){let r=W(e),i=un(ln(r,t),t);return i.compare(r)===0?e:G(H(V(i,e.timeZone,n),e.timeZone),e.calendar)}var wn=/^([+-]\d{6}|\d{4})-(\d{2})-(\d{2})$/,Tn=/^([+-]\d{6}|\d{4})-(\d{2})-(\d{2})(?:T(\d{2}))?(?::(\d{2}))?(?::(\d{2}))?(\.\d+)?$/,En=/^([+-]\d{6}|\d{4})-(\d{2})-(\d{2})(?:T(\d{2}))?(?::(\d{2}))?(?::(\d{2}))?(\.\d+)?(?:(?:([+-]\d{2})(?::?(\d{2}))?)|Z)$/;function Dn(e){let t=e.match(wn);if(!t)throw En.test(e)?Error(`Invalid ISO 8601 date string: ${e}. Use parseAbsolute() instead.`):Error(`Invalid ISO 8601 date string: `+e);let n=new q(K(t[1],0,9999),K(t[2],1,12),1);return n.day=K(t[3],1,n.calendar.getDaysInMonth(n)),n}function On(e){let t=e.match(Tn);if(!t)throw En.test(e)?Error(`Invalid ISO 8601 date time string: ${e}. Use parseAbsolute() instead.`):Error(`Invalid ISO 8601 date time string: `+e);let n=K(t[1],-9999,9999),r=new Rn(n<1?`BC`:`AD`,n<1?-n+1:n,K(t[2],1,12),1,t[4]?K(t[4],0,23):0,t[5]?K(t[5],0,59):0,t[6]?K(t[6],0,59):0,t[7]?K(t[7],0,1/0)*1e3:0);return r.day=K(t[3],0,r.calendar.getDaysInMonth(r)),r}function kn(e,t){let n=e.match(En);if(!n)throw Error(`Invalid ISO 8601 date time string: `+e);let r=K(n[1],-9999,9999),i=new zn(r<1?`BC`:`AD`,r<1?-r+1:r,K(n[2],1,12),1,t,0,n[4]?K(n[4],0,23):0,n[5]?K(n[5],0,59):0,n[6]?K(n[6],0,59):0,n[7]?K(n[7],0,1/0)*1e3:0);return i.day=K(n[3],0,i.calendar.getDaysInMonth(i)),n[8]&&(i.offset=K(n[8],-23,23)*36e5+K(n[9]??`0`,0,59)*6e4),Zt(i,t)}function An(e){return kn(e,Tt())}function K(e,t,n){let r=Number(e);if(rn)throw RangeError(`Value out of range: ${t} <= ${r} <= ${n}`);return r}function jn(e){return`${String(e.hour).padStart(2,`0`)}:${String(e.minute).padStart(2,`0`)}:${String(e.second).padStart(2,`0`)}${e.millisecond?String(e.millisecond/1e3).slice(1):``}`}function Mn(e){let t=G(e,new z),n;return n=t.era===`BC`?t.year===1?`0000`:`-`+String(Math.abs(1-t.year)).padStart(6,`00`):String(t.year).padStart(4,`0`),`${n}-${String(t.month).padStart(2,`0`)}-${String(t.day).padStart(2,`0`)}`}function Nn(e){return`${Mn(e)}T${jn(e)}`}function Pn(e){let t=Math.sign(e)<0?`-`:`+`;e=Math.abs(e);let n=Math.floor(e/36e5),r=Math.floor(e%36e5/6e4),i=Math.floor(e%36e5%6e4/1e3),a=`${t}${String(n).padStart(2,`0`)}:${String(r).padStart(2,`0`)}`;return i!==0&&(a+=`:${String(i).padStart(2,`0`)}`),a}function Fn(e){return`${Nn(e)}${Pn(e.offset)}[${e.timeZone}]`}function In(e){let t=typeof e[0]==`object`?e.shift():new z,n;if(typeof e[0]==`string`)n=e.shift();else{let e=t.getEras();n=e[e.length-1]}let r=e.shift(),i=e.shift(),a=e.shift();return[t,n,r,i,a]}var q=class e{constructor(...e){let[t,n,r,i,a]=In(e);this.calendar=t,this.era=n,this.year=r,this.month=i,this.day=a,on(this)}copy(){return this.era?new e(this.calendar,this.era,this.year,this.month,this.day):new e(this.calendar,this.year,this.month,this.day)}add(e){return en(this,e)}subtract(e){return cn(this,e)}set(e){return ln(this,e)}cycle(e,t,n){return _n(this,e,t,n)}toDate(e){return qt(this,e)}toString(){return Mn(this)}compare(e){return bt(this,e)}},Ln=class e{constructor(e=0,t=0,n=0,r=0){this.hour=e,this.minute=t,this.second=n,this.millisecond=r,fn(this)}copy(){return new e(this.hour,this.minute,this.second,this.millisecond)}add(e){return hn(this,e)}subtract(e){return gn(this,e)}set(e){return un(this,e)}cycle(e,t,n){return vn(this,e,t,n)}toString(){return jn(this)}compare(e){return xt(this,e)}},Rn=class e{constructor(...e){let[t,n,r,i,a]=In(e);this.calendar=t,this.era=n,this.year=r,this.month=i,this.day=a,this.hour=e.shift()||0,this.minute=e.shift()||0,this.second=e.shift()||0,this.millisecond=e.shift()||0,on(this)}copy(){return this.era?new e(this.calendar,this.era,this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond):new e(this.calendar,this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond)}add(e){return en(this,e)}subtract(e){return cn(this,e)}set(e){return ln(un(this,e),e)}cycle(e,t,n){switch(e){case`era`:case`year`:case`month`:case`day`:return _n(this,e,t,n);default:return vn(this,e,t,n)}}toDate(e,t){return qt(this,e,t)}toString(){return Nn(this)}compare(e){let t=bt(this,e);return t===0?xt(this,W(e)):t}},zn=class e{constructor(...e){let[t,n,r,i,a]=In(e),o=e.shift(),s=e.shift();this.calendar=t,this.era=n,this.year=r,this.month=i,this.day=a,this.timeZone=o,this.offset=s,this.hour=e.shift()||0,this.minute=e.shift()||0,this.second=e.shift()||0,this.millisecond=e.shift()||0,on(this)}copy(){return this.era?new e(this.calendar,this.era,this.year,this.month,this.day,this.timeZone,this.offset,this.hour,this.minute,this.second,this.millisecond):new e(this.calendar,this.year,this.month,this.day,this.timeZone,this.offset,this.hour,this.minute,this.second,this.millisecond)}add(e){return bn(this,e)}subtract(e){return xn(this,e)}set(e,t){return Cn(this,e,t)}cycle(e,t,n){return Sn(this,e,t,n)}toDate(){return Xt(this)}toString(){return Fn(this)}toAbsoluteString(){return this.toDate().toISOString()}compare(e){return this.toDate().getTime()-Yt(e,this.timeZone).toDate().getTime()}},Bn=[[1868,9,8],[1912,7,30],[1926,12,25],[1989,1,8],[2019,5,1]],Vn=[[1912,7,29],[1926,12,24],[1989,1,7],[2019,4,30]],Hn=[1867,1911,1925,1988,2018],Un=[`meiji`,`taisho`,`showa`,`heisei`,`reiwa`];function Wn(e){let t=Bn.findIndex(([t,n,r])=>e.year=0){let[,n,r]=Bn[t];e.month=Math.max(n,e.month),e.month===n&&(e.day=Math.max(r,e.day))}}getEras(){return Un}getYearsInEra(e){let t=Un.indexOf(e.era),n=Bn[t],r=Bn[t+1];if(r==null)return 9999-n[0]+1;let i=r[0]-n[0];return(e.month0?[`minguo`,t]:[`before_minguo`,1-t]}var er=class extends z{fromJulianDay(e){let t=super.fromJulianDay(e),[n,r]=$n(st(t.era,t.year));return new q(this,n,r,t.month,t.day)}toJulianDay(e){return super.toJulianDay(tr(e))}getEras(){return[`before_minguo`,`minguo`]}balanceDate(e){let[t,n]=$n(Qn(e));e.era=t,e.year=n}isInverseEra(e){return e.era===`before_minguo`}getDaysInMonth(e){return super.getDaysInMonth(tr(e))}getYearsInEra(e){return e.era===`before_minguo`?9999:8088}constructor(...e){super(...e),this.identifier=`roc`}};function tr(e){let[t,n]=ct(Qn(e));return new q(t,n,e.month,e.day)}var nr=1948320,rr=[0,31,62,93,124,155,186,216,246,276,306,336],ir=class{fromJulianDay(e){let t=e-nr,n=1+Math.floor((33*t+3)/12053),r=t-(365*(n-1)+Math.floor((8*n+21)/33)),i=Math.floor(r<216?r/31:(r-6)/30),a=r-rr[i]+1;return new q(this,n,i+1,a)}toJulianDay(e){let t=1948319+365*(e.year-1)+Math.floor((8*e.year+21)/33);return t+=rr[e.month-1],t+=e.day,t}getMonthsInYear(){return 12}getDaysInMonth(e){return e.month<=6?31:e.month<=11||rt(25*e.year+11,33)<8?30:29}getMaximumMonthsInYear(){return 12}getMaximumDaysInMonth(){return 31}getEras(){return[`AP`]}getYearsInEra(){return 9377}constructor(){this.identifier=`persian`}},ar=78,or=80,sr=class extends z{fromJulianDay(e){let t=super.fromJulianDay(e),n=t.year-ar,r=e-at(t.era,t.year,1,1),i;r=8&&(i+=(e.month-7)*30),i+=e.day-1,i)}getDaysInMonth(e){return e.month===1&&ot(e.year+ar)||e.month>=2&&e.month<=6?31:30}getYearsInEra(){return 9919}getEras(){return[`saka`]}balanceDate(){}constructor(...e){super(...e),this.identifier=`indian`}},cr=1948440,lr=1948439,J=1300,ur=1600,dr=460322;function fr(e,t,n,r){return r+Math.ceil(29.5*(n-1))+(t-1)*354+Math.floor((3+11*t)/30)+e-1}function pr(e,t,n){let r=Math.floor((30*(n-t)+10646)/10631),i=Math.min(12,Math.ceil((n-(29+fr(t,r,1,1)))/29.5)+1);return new q(e,r,i,n-fr(t,r,i,1)+1)}function mr(e){return(14+11*e)%30<11}var hr=class{fromJulianDay(e){return pr(this,cr,e)}toJulianDay(e){return fr(cr,e.year,e.month,e.day)}getDaysInMonth(e){let t=29+e.month%2;return e.month===12&&mr(e.year)&&t++,t}getMonthsInYear(){return 12}getDaysInYear(e){return mr(e.year)?355:354}getMaximumMonthsInYear(){return 12}getMaximumDaysInMonth(){return 30}getYearsInEra(){return 9665}getEras(){return[`AH`]}constructor(){this.identifier=`islamic-civil`}},gr=class extends hr{fromJulianDay(e){return pr(this,lr,e)}toJulianDay(e){return fr(lr,e.year,e.month,e.day)}constructor(...e){super(...e),this.identifier=`islamic-tbla`}},_r=`qgpUDckO1AbqBmwDrQpVBakGkgepC9QF2gpcBS0NlQZKB1QLagutBa4ETwoXBYsGpQbVCtYCWwmdBE0KJg2VDawFtgm6AlsKKwWVCsoG6Qr0AnYJtgJWCcoKpAvSC9kF3AJtCU0FpQpSC6ULtAW2CVcFlwJLBaMGUgdlC2oFqworBZUMSg2lDcoF1gpXCasESwmlClILagt1BXYCtwhbBFUFqQW0BdoJ3QRuAjYJqgpUDbIN1QXaAlsJqwRVCkkLZAtxC7QFtQpVCiUNkg7JDtQG6QprCasEkwpJDaQNsg25CroEWworBZUKKgtVC1wFvQQ9Ah0JlQpKC1oLbQW2AjsJmwRVBqkGVAdqC2wFrQpVBSkLkgupC9QF2gpaBasKlQVJB2QHqgu1BbYCVgpNDiULUgtqC60FrgIvCZcESwalBqwG1gpdBZ0ETQoWDZUNqgW1BdoCWwmtBJUFygbkBuoK9QS2AlYJqgpUC9IL2QXqAm0JrQSVCkoLpQuyBbUJ1gSXCkcFkwZJB1ULagVrCisFiwpGDaMNygXWCtsEawJLCaUKUgtpC3UFdgG3CFsCKwVlBbQF2gntBG0BtgimClINqQ3UBdoKWwmrBFMGKQdiB6kLsgW1ClUFJQuSDckO0gbpCmsFqwRVCikNVA2qDbUJugQ7CpsETQqqCtUK2gJdCV4ELgqaDFUNsga5BroEXQotBZUKUguoC7QLuQXaAloJSgukDdEO6AZqC20FNQWVBkoNqA3UDdoGWwWdAisGFQtKC5ULqgWuCi4JjwwnBZUGqgbWCl0FnQI=`,vr,yr;function br(e){return dr+yr[e-J]}function xr(e,t){let n=e-J,r=1<<11-(t-1);return(vr[n]&r)===0?29:30}function Sr(e,t){let n=br(e);for(let r=1;re.charCodeAt(0)).buffer),!yr){yr=new Uint32Array(301);let e=0;for(let t=J;t<=ur;t++){yr[t-J]=e;for(let n=1;n<=12;n++)e+=xr(t,n)}}}fromJulianDay(e){let t=e-cr,n=br(J),r=br(ur);if(tr)return super.fromJulianDay(e);{let e=1299,n=1,r=1;for(;r>0;){e++,r=t-br(e)+1;let i=Cr(e);if(r===i){n=12;break}if(rt;)r-=t,n++,t=xr(e,n);break}}return new q(this,e,n,t-Sr(e,n)+1)}}toJulianDay(e){return e.yearur?super.toJulianDay(e):cr+Sr(e.year,e.month)+(e.day-1)}getDaysInMonth(e){return e.yearur?super.getDaysInMonth(e):xr(e.year,e.month)}getDaysInYear(e){return e.yearur?super.getDaysInYear(e):Cr(e.year)}},Tr=347997,Er=25920,Dr=765433;function Or(e){return rt(e*7+1,19)<7}function kr(e){let t=Math.floor((235*e-234)/19),n=12084+13753*t,r=t*29+Math.floor(n/25920);return rt(3*(r+1),7)<3&&(r+=1),r}function Ar(e){let t=kr(e-1),n=kr(e);return kr(e+1)-n===356?2:+(n-t===382)}function jr(e){return kr(e)+Ar(e)}function Mr(e){return jr(e+1)-jr(e)}function Nr(e){let t=Mr(e);switch(t>380&&(t-=30),t){case 353:return 0;case 354:return 1;case 355:return 2}}function Pr(e,t){if(t>=6&&!Or(e)&&t++,t===4||t===7||t===9||t===11||t===13)return 29;let n=Nr(e);return t===2?n===2?30:29:t===3?n===0?29:30:t===6?Or(e)?30:0:30}var Fr=class{fromJulianDay(e){let t=e-Tr,n=t*Er/Dr,r=Math.floor((19*n+234)/235)+1,i=jr(r),a=Math.floor(t-i);for(;a<1;)r--,i=jr(r),a=Math.floor(t-i);let o=1,s=0;for(;s6?e.month--:!Or(t.year)&&Or(e.year)&&t.month>6&&e.month++)}constructor(){this.identifier=`hebrew`}},Ir=1723856,Lr=1824665,Rr=5500;function zr(e,t,n,r){return e+365*t+Math.floor(t/4)+30*(n-1)+r-1}function Br(e,t){let n=Math.floor(4*(t-e)/1461),r=1+Math.floor((t-zr(e,n,1,1))/30);return[n,r,t+1-zr(e,n,r,1)]}function Vr(e){return Math.floor(e%4/3)}function Hr(e,t){return t%13==0?Vr(e)+5:30}var Ur=class{fromJulianDay(e){let[t,n,r]=Br(Ir,e),i=`AM`;return t<=0&&(i=`AA`,t+=Rr),new q(this,i,t,n,r)}toJulianDay(e){let t=e.year;return e.era===`AA`&&(t-=Rr),zr(Ir,t,e.month,e.day)}getDaysInMonth(e){return Hr(e.year,e.month)}getMonthsInYear(){return 13}getDaysInYear(e){return 365+Vr(e.year)}getMaximumMonthsInYear(){return 13}getMaximumDaysInMonth(){return 30}getYearsInEra(e){return e.era===`AA`?9999:9991}getEras(){return[`AA`,`AM`]}constructor(){this.identifier=`ethiopic`}},Wr=class extends Ur{fromJulianDay(e){let[t,n,r]=Br(Ir,e);return t+=Rr,new q(this,`AA`,t,n,r)}getEras(){return[`AA`]}getYearsInEra(){return 9999}constructor(...e){super(...e),this.identifier=`ethioaa`}},Gr=class extends Ur{fromJulianDay(e){let[t,n,r]=Br(Lr,e),i=`CE`;return t<=0&&(i=`BCE`,t=1-t),new q(this,i,t,n,r)}toJulianDay(e){let t=e.year;return e.era===`BCE`&&(t=1-t),zr(Lr,t,e.month,e.day)}getDaysInMonth(e){let t=e.year;return e.era===`BCE`&&(t=1-t),Hr(t,e.month)}isInverseEra(e){return e.era===`BCE`}balanceDate(e){e.year<=0&&(e.era=e.era===`BCE`?`CE`:`BCE`,e.year=1-e.year)}getEras(){return[`BCE`,`CE`]}getYearsInEra(e){return e.era===`BCE`?9999:9715}constructor(...e){super(...e),this.identifier=`coptic`}};function Kr(e){switch(e){case`buddhist`:return new Yn;case`ethiopic`:return new Ur;case`ethioaa`:return new Wr;case`coptic`:return new Gr;case`hebrew`:return new Fr;case`indian`:return new sr;case`islamic-civil`:return new hr;case`islamic-tbla`:return new gr;case`islamic-umalqura`:return new wr;case`japanese`:return new Kn;case`persian`:return new ir;case`roc`:return new er;default:return new z}}var qr=new Map,Y=class{constructor(e,t={}){this.formatter=Yr(e,t),this.options=t}format(e){return this.formatter.format(e)}formatToParts(e){return this.formatter.formatToParts(e)}formatRange(e,t){if(typeof this.formatter.formatRange==`function`)return this.formatter.formatRange(e,t);if(t= start date`);return`${this.formatter.format(e)} \u{2013} ${this.formatter.format(t)}`}formatRangeToParts(e,t){if(typeof this.formatter.formatRangeToParts==`function`)return this.formatter.formatRangeToParts(e,t);if(t= start date`);let n=this.formatter.formatToParts(e),r=this.formatter.formatToParts(t);return[...n.map(e=>({...e,source:`startRange`})),{type:`literal`,value:` – `,source:`shared`},...r.map(e=>({...e,source:`endRange`}))]}resolvedOptions(){let e=this.formatter.resolvedOptions();return $r()&&(this.resolvedHourCycle||=ei(e.locale,this.options),e.hourCycle=this.resolvedHourCycle,e.hour12=this.resolvedHourCycle===`h11`||this.resolvedHourCycle===`h12`),e.calendar===`ethiopic-amete-alem`&&(e.calendar=`ethioaa`),e}},Jr={true:{ja:`h11`},false:{}};function Yr(e,t={}){if(typeof t.hour12==`boolean`&&Zr()){t={...t};let n=Jr[String(t.hour12)][e.split(`-`)[0]],r=t.hour12?`h12`:`h23`;t.hourCycle=n??r,delete t.hour12}let n=e+(t?Object.entries(t).sort((e,t)=>e[0]e.type===`hour`).value,10),i=parseInt(n.formatToParts(new Date(2020,2,3,23)).find(e=>e.type===`hour`).value,10);if(r===0&&i===23)return`h23`;if(r===24&&i===23)return`h24`;if(r===0&&i===11)return`h11`;if(r===12&&i===11)return`h12`;throw Error(`Unexpected hour cycle result`)}var X=n(),ti=[`day`,`month`,`year`],ni={hour:1,minute:2,second:3};function ri(e,t){let{autoComplete:n,isDisabled:r,name:a}=e,{visuallyHiddenProps:o}=i({style:{position:`fixed`,top:0,left:0}}),s=60;t.granularity===`second`?s=1:t.granularity===`hour`&&(s=3600);let c=``;t.value&&(c=t.granularity===`day`?U(t.value).toString():W(`timeZone`in t.value?Qt(t.value):t.value).toString());let l=t.granularity===`day`?`date`:`datetime-local`,u=[`hour`,`minute`,`second`],d=0;return u.includes(t.granularity)&&(d=ni[t.granularity],u=u.slice(0,d)),{containerProps:{...o,"aria-hidden":!0,"data-react-aria-prevent-focus":!0,"data-a11y-ignore":`aria-hidden-focus`},inputProps:{tabIndex:-1,autoComplete:n,disabled:r,type:l,form:``,name:a,step:s,value:c,onChange:e=>{let n=fe(e).value.toString();if(n)try{let e=On(n);if(t.granularity===`day`&&(e=Dn(n)),`setSegment`in t)for(let n in e)ti.includes(n)&&t.setSegment(n,e[n]),u.includes(n)&&t.setSegment(n,e[n]);t.setValue(e)}catch{}}}}}function ii(e){let{state:t}=e,{containerProps:n,inputProps:r}=ri({...e},t);return R.createElement(`div`,{...n,"data-testid":`hidden-dateinput-container`},R.createElement(`input`,r))}var ai={};ai={calendar:`التقويم`,day:`يوم`,dayPeriod:`ص/م`,endDate:`تاريخ الانتهاء`,era:`العصر`,hour:`الساعات`,minute:`الدقائق`,month:`الشهر`,second:`الثواني`,selectedDateDescription:e=>`\u{62A}\u{627}\u{631}\u{64A}\u{62E} \u{645}\u{62D}\u{62F}\u{62F}: ${e.date}`,selectedRangeDescription:e=>`\u{627}\u{644}\u{645}\u{62F}\u{649} \u{627}\u{644}\u{632}\u{645}\u{646}\u{64A} \u{627}\u{644}\u{645}\u{62D}\u{62F}\u{62F}: ${e.startDate} \u{625}\u{644}\u{649} ${e.endDate}`,selectedTimeDescription:e=>`\u{627}\u{644}\u{648}\u{642}\u{62A} \u{627}\u{644}\u{645}\u{62D}\u{62F}\u{62F}: ${e.time}`,startDate:`تاريخ البدء`,timeZoneName:`التوقيت`,weekday:`اليوم`,year:`السنة`};var oi={};oi={calendar:`Календар`,day:`ден`,dayPeriod:`пр.об./сл.об.`,endDate:`Крайна дата`,era:`ера`,hour:`час`,minute:`минута`,month:`месец`,second:`секунда`,selectedDateDescription:e=>`\u{418}\u{437}\u{431}\u{440}\u{430}\u{43D}\u{430} \u{434}\u{430}\u{442}\u{430}: ${e.date}`,selectedRangeDescription:e=>`\u{418}\u{437}\u{431}\u{440}\u{430}\u{43D} \u{434}\u{438}\u{430}\u{43F}\u{430}\u{437}\u{43E}\u{43D}: ${e.startDate} \u{434}\u{43E} ${e.endDate}`,selectedTimeDescription:e=>`\u{418}\u{437}\u{431}\u{440}\u{430}\u{43D}\u{43E} \u{432}\u{440}\u{435}\u{43C}\u{435}: ${e.time}`,startDate:`Начална дата`,timeZoneName:`часова зона`,weekday:`ден от седмицата`,year:`година`};var si={};si={calendar:`Kalendář`,day:`den`,dayPeriod:`část dne`,endDate:`Konečné datum`,era:`letopočet`,hour:`hodina`,minute:`minuta`,month:`měsíc`,second:`sekunda`,selectedDateDescription:e=>`Vybran\xe9 datum: ${e.date}`,selectedRangeDescription:e=>`Vybran\xe9 obdob\xed: ${e.startDate} a\u{17E} ${e.endDate}`,selectedTimeDescription:e=>`Vybran\xfd \u{10D}as: ${e.time}`,startDate:`Počáteční datum`,timeZoneName:`časové pásmo`,weekday:`den v týdnu`,year:`rok`};var ci={};ci={calendar:`Kalender`,day:`dag`,dayPeriod:`AM/PM`,endDate:`Slutdato`,era:`æra`,hour:`time`,minute:`minut`,month:`måned`,second:`sekund`,selectedDateDescription:e=>`Valgt dato: ${e.date}`,selectedRangeDescription:e=>`Valgt interval: ${e.startDate} til ${e.endDate}`,selectedTimeDescription:e=>`Valgt tidspunkt: ${e.time}`,startDate:`Startdato`,timeZoneName:`tidszone`,weekday:`ugedag`,year:`år`};var li={};li={calendar:`Kalender`,day:`Tag`,dayPeriod:`Tageshälfte`,endDate:`Enddatum`,era:`Epoche`,hour:`Stunde`,minute:`Minute`,month:`Monat`,second:`Sekunde`,selectedDateDescription:e=>`Ausgew\xe4hltes Datum: ${e.date}`,selectedRangeDescription:e=>`Ausgew\xe4hlter Bereich: ${e.startDate} bis ${e.endDate}`,selectedTimeDescription:e=>`Ausgew\xe4hlte Zeit: ${e.time}`,startDate:`Startdatum`,timeZoneName:`Zeitzone`,weekday:`Wochentag`,year:`Jahr`};var ui={};ui={calendar:`Ημερολόγιο`,day:`ημέρα`,dayPeriod:`π.μ./μ.μ.`,endDate:`Ημερομηνία λήξης`,era:`περίοδος`,hour:`ώρα`,minute:`λεπτό`,month:`μήνας`,second:`δευτερόλεπτο`,selectedDateDescription:e=>`\u{395}\u{3C0}\u{3B9}\u{3BB}\u{3B5}\u{3B3}\u{3BC}\u{3AD}\u{3BD}\u{3B7} \u{3B7}\u{3BC}\u{3B5}\u{3C1}\u{3BF}\u{3BC}\u{3B7}\u{3BD}\u{3AF}\u{3B1}: ${e.date}`,selectedRangeDescription:e=>`\u{395}\u{3C0}\u{3B9}\u{3BB}\u{3B5}\u{3B3}\u{3BC}\u{3AD}\u{3BD}\u{3BF} \u{3B5}\u{3CD}\u{3C1}\u{3BF}\u{3C2}: ${e.startDate} \u{3AD}\u{3C9}\u{3C2} ${e.endDate}`,selectedTimeDescription:e=>`\u{395}\u{3C0}\u{3B9}\u{3BB}\u{3B5}\u{3B3}\u{3BC}\u{3AD}\u{3BD}\u{3B7} \u{3CE}\u{3C1}\u{3B1}: ${e.time}`,startDate:`Ημερομηνία έναρξης`,timeZoneName:`ζώνη ώρας`,weekday:`καθημερινή`,year:`έτος`};var di={};di={era:`era`,year:`year`,month:`month`,day:`day`,hour:`hour`,minute:`minute`,second:`second`,dayPeriod:`AM/PM`,calendar:`Calendar`,startDate:`Start Date`,endDate:`End Date`,weekday:`day of the week`,timeZoneName:`time zone`,selectedDateDescription:e=>`Selected Date: ${e.date}`,selectedRangeDescription:e=>`Selected Range: ${e.startDate} to ${e.endDate}`,selectedTimeDescription:e=>`Selected Time: ${e.time}`};var fi={};fi={calendar:`Calendario`,day:`día`,dayPeriod:`a.\xA0m./p.\xA0m.`,endDate:`Fecha final`,era:`era`,hour:`hora`,minute:`minuto`,month:`mes`,second:`segundo`,selectedDateDescription:e=>`Fecha seleccionada: ${e.date}`,selectedRangeDescription:e=>`Rango seleccionado: ${e.startDate} a ${e.endDate}`,selectedTimeDescription:e=>`Hora seleccionada: ${e.time}`,startDate:`Fecha de inicio`,timeZoneName:`zona horaria`,weekday:`día de la semana`,year:`año`};var pi={};pi={calendar:`Kalender`,day:`päev`,dayPeriod:`enne/pärast lõunat`,endDate:`Lõppkuupäev`,era:`ajastu`,hour:`tund`,minute:`minut`,month:`kuu`,second:`sekund`,selectedDateDescription:e=>`Valitud kuup\xe4ev: ${e.date}`,selectedRangeDescription:e=>`Valitud vahemik: ${e.startDate} kuni ${e.endDate}`,selectedTimeDescription:e=>`Valitud aeg: ${e.time}`,startDate:`Alguskuupäev`,timeZoneName:`ajavöönd`,weekday:`nädalapäev`,year:`aasta`};var mi={};mi={calendar:`Kalenteri`,day:`päivä`,dayPeriod:`vuorokaudenaika`,endDate:`Päättymispäivä`,era:`aikakausi`,hour:`tunti`,minute:`minuutti`,month:`kuukausi`,second:`sekunti`,selectedDateDescription:e=>`Valittu p\xe4iv\xe4m\xe4\xe4r\xe4: ${e.date}`,selectedRangeDescription:e=>`Valittu aikav\xe4li: ${e.startDate} \u{2013} ${e.endDate}`,selectedTimeDescription:e=>`Valittu aika: ${e.time}`,startDate:`Alkamispäivä`,timeZoneName:`aikavyöhyke`,weekday:`viikonpäivä`,year:`vuosi`};var hi={};hi={calendar:`Calendrier`,day:`jour`,dayPeriod:`cadran`,endDate:`Date de fin`,era:`ère`,hour:`heure`,minute:`minute`,month:`mois`,second:`seconde`,selectedDateDescription:e=>`Date s\xe9lectionn\xe9e\xa0: ${e.date}`,selectedRangeDescription:e=>`Plage s\xe9lectionn\xe9e\xa0: ${e.startDate} au ${e.endDate}`,selectedTimeDescription:e=>`Heure choisie\xa0: ${e.time}`,startDate:`Date de début`,timeZoneName:`fuseau horaire`,weekday:`jour de la semaine`,year:`année`};var gi={};gi={calendar:`לוח שנה`,day:`יום`,dayPeriod:`לפנה״צ/אחה״צ`,endDate:`תאריך סיום`,era:`תקופה`,hour:`שעה`,minute:`דקה`,month:`חודש`,second:`שנייה`,selectedDateDescription:e=>`\u{5EA}\u{5D0}\u{5E8}\u{5D9}\u{5DA} \u{5E0}\u{5D1}\u{5D7}\u{5E8}: ${e.date}`,selectedRangeDescription:e=>`\u{5D8}\u{5D5}\u{5D5}\u{5D7} \u{5E0}\u{5D1}\u{5D7}\u{5E8}: ${e.startDate} \u{5E2}\u{5D3} ${e.endDate}`,selectedTimeDescription:e=>`\u{5D6}\u{5DE}\u{5DF} \u{5E0}\u{5D1}\u{5D7}\u{5E8}: ${e.time}`,startDate:`תאריך התחלה`,timeZoneName:`אזור זמן`,weekday:`יום בשבוע`,year:`שנה`};var _i={};_i={calendar:`Kalendar`,day:`dan`,dayPeriod:`AM/PM`,endDate:`Datum završetka`,era:`era`,hour:`sat`,minute:`minuta`,month:`mjesec`,second:`sekunda`,selectedDateDescription:e=>`Odabrani datum: ${e.date}`,selectedRangeDescription:e=>`Odabrani raspon: ${e.startDate} do ${e.endDate}`,selectedTimeDescription:e=>`Odabrano vrijeme: ${e.time}`,startDate:`Datum početka`,timeZoneName:`vremenska zona`,weekday:`dan u tjednu`,year:`godina`};var vi={};vi={calendar:`Naptár`,day:`nap`,dayPeriod:`napszak`,endDate:`Befejező dátum`,era:`éra`,hour:`óra`,minute:`perc`,month:`hónap`,second:`másodperc`,selectedDateDescription:e=>`Kijel\xf6lt d\xe1tum: ${e.date}`,selectedRangeDescription:e=>`Kijel\xf6lt tartom\xe1ny: ${e.startDate}\u{2013}${e.endDate}`,selectedTimeDescription:e=>`Kijel\xf6lt id\u{151}: ${e.time}`,startDate:`Kezdő dátum`,timeZoneName:`időzóna`,weekday:`hét napja`,year:`év`};var yi={};yi={calendar:`Calendario`,day:`giorno`,dayPeriod:`AM/PM`,endDate:`Data finale`,era:`era`,hour:`ora`,minute:`minuto`,month:`mese`,second:`secondo`,selectedDateDescription:e=>`Data selezionata: ${e.date}`,selectedRangeDescription:e=>`Intervallo selezionato: da ${e.startDate} a ${e.endDate}`,selectedTimeDescription:e=>`Ora selezionata: ${e.time}`,startDate:`Data iniziale`,timeZoneName:`fuso orario`,weekday:`giorno della settimana`,year:`anno`};var bi={};bi={calendar:`カレンダー`,day:`日`,dayPeriod:`午前/午後`,endDate:`終了日`,era:`時代`,hour:`時`,minute:`分`,month:`月`,second:`秒`,selectedDateDescription:e=>`\u{9078}\u{629E}\u{3057}\u{305F}\u{65E5}\u{4ED8} : ${e.date}`,selectedRangeDescription:e=>`\u{9078}\u{629E}\u{7BC4}\u{56F2} : ${e.startDate} \u{304B}\u{3089} ${e.endDate}`,selectedTimeDescription:e=>`\u{9078}\u{629E}\u{3057}\u{305F}\u{6642}\u{9593} : ${e.time}`,startDate:`開始日`,timeZoneName:`タイムゾーン`,weekday:`曜日`,year:`年`};var xi={};xi={calendar:`달력`,day:`일`,dayPeriod:`오전/오후`,endDate:`종료일`,era:`연호`,hour:`시`,minute:`분`,month:`월`,second:`초`,selectedDateDescription:e=>`\u{C120}\u{D0DD} \u{C77C}\u{C790}: ${e.date}`,selectedRangeDescription:e=>`\u{C120}\u{D0DD} \u{BC94}\u{C704}: ${e.startDate} ~ ${e.endDate}`,selectedTimeDescription:e=>`\u{C120}\u{D0DD} \u{C2DC}\u{AC04}: ${e.time}`,startDate:`시작일`,timeZoneName:`시간대`,weekday:`요일`,year:`년`};var Si={};Si={calendar:`Kalendorius`,day:`diena`,dayPeriod:`iki pietų / po pietų`,endDate:`Pabaigos data`,era:`era`,hour:`valanda`,minute:`minutė`,month:`mėnuo`,second:`sekundė`,selectedDateDescription:e=>`Pasirinkta data: ${e.date}`,selectedRangeDescription:e=>`Pasirinktas intervalas: nuo ${e.startDate} iki ${e.endDate}`,selectedTimeDescription:e=>`Pasirinktas laikas: ${e.time}`,startDate:`Pradžios data`,timeZoneName:`laiko juosta`,weekday:`savaitės diena`,year:`metai`};var Ci={};Ci={calendar:`Kalendārs`,day:`diena`,dayPeriod:`priekšpusdienā/pēcpusdienā`,endDate:`Beigu datums`,era:`ēra`,hour:`stundas`,minute:`minūtes`,month:`mēnesis`,second:`sekundes`,selectedDateDescription:e=>`Atlas\u{12B}tais datums: ${e.date}`,selectedRangeDescription:e=>`Atlas\u{12B}tais diapazons: no ${e.startDate} l\u{12B}dz ${e.endDate}`,selectedTimeDescription:e=>`Atlas\u{12B}tais laiks: ${e.time}`,startDate:`Sākuma datums`,timeZoneName:`laika josla`,weekday:`nedēļas diena`,year:`gads`};var wi={};wi={calendar:`Kalender`,day:`dag`,dayPeriod:`a.m./p.m.`,endDate:`Sluttdato`,era:`tidsalder`,hour:`time`,minute:`minutt`,month:`måned`,second:`sekund`,selectedDateDescription:e=>`Valgt dato: ${e.date}`,selectedRangeDescription:e=>`Valgt omr\xe5de: ${e.startDate} til ${e.endDate}`,selectedTimeDescription:e=>`Valgt tid: ${e.time}`,startDate:`Startdato`,timeZoneName:`tidssone`,weekday:`ukedag`,year:`år`};var Ti={};Ti={calendar:`Kalender`,day:`dag`,dayPeriod:`a.m./p.m.`,endDate:`Einddatum`,era:`tijdperk`,hour:`uur`,minute:`minuut`,month:`maand`,second:`seconde`,selectedDateDescription:e=>`Geselecteerde datum: ${e.date}`,selectedRangeDescription:e=>`Geselecteerd bereik: ${e.startDate} tot ${e.endDate}`,selectedTimeDescription:e=>`Geselecteerde tijd: ${e.time}`,startDate:`Startdatum`,timeZoneName:`tijdzone`,weekday:`dag van de week`,year:`jaar`};var Ei={};Ei={calendar:`Kalendarz`,day:`dzień`,dayPeriod:`rano / po południu / wieczorem`,endDate:`Data końcowa`,era:`era`,hour:`godzina`,minute:`minuta`,month:`miesiąc`,second:`sekunda`,selectedDateDescription:e=>`Wybrana data: ${e.date}`,selectedRangeDescription:e=>`Wybrany zakres: ${e.startDate} do ${e.endDate}`,selectedTimeDescription:e=>`Wybrany czas: ${e.time}`,startDate:`Data początkowa`,timeZoneName:`strefa czasowa`,weekday:`dzień tygodnia`,year:`rok`};var Di={};Di={calendar:`Calendário`,day:`dia`,dayPeriod:`AM/PM`,endDate:`Data final`,era:`era`,hour:`hora`,minute:`minuto`,month:`mês`,second:`segundo`,selectedDateDescription:e=>`Data selecionada: ${e.date}`,selectedRangeDescription:e=>`Intervalo selecionado: ${e.startDate} a ${e.endDate}`,selectedTimeDescription:e=>`Hora selecionada: ${e.time}`,startDate:`Data inicial`,timeZoneName:`fuso horário`,weekday:`dia da semana`,year:`ano`};var Oi={};Oi={calendar:`Calendário`,day:`dia`,dayPeriod:`am/pm`,endDate:`Data de Término`,era:`era`,hour:`hora`,minute:`minuto`,month:`mês`,second:`segundo`,selectedDateDescription:e=>`Data selecionada: ${e.date}`,selectedRangeDescription:e=>`Intervalo selecionado: ${e.startDate} a ${e.endDate}`,selectedTimeDescription:e=>`Hora selecionada: ${e.time}`,startDate:`Data de Início`,timeZoneName:`fuso horário`,weekday:`dia da semana`,year:`ano`};var ki={};ki={calendar:`Calendar`,day:`zi`,dayPeriod:`a.m/p.m.`,endDate:`Dată final`,era:`eră`,hour:`oră`,minute:`minut`,month:`lună`,second:`secundă`,selectedDateDescription:e=>`Dat\u{103} selectat\u{103}: ${e.date}`,selectedRangeDescription:e=>`Interval selectat: de la ${e.startDate} p\xe2n\u{103} la ${e.endDate}`,selectedTimeDescription:e=>`Ora selectat\u{103}: ${e.time}`,startDate:`Dată început`,timeZoneName:`fus orar`,weekday:`ziua din săptămână`,year:`an`};var Ai={};Ai={calendar:`Календарь`,day:`день`,dayPeriod:`AM/PM`,endDate:`Дата окончания`,era:`эра`,hour:`час`,minute:`минута`,month:`месяц`,second:`секунда`,selectedDateDescription:e=>`\u{412}\u{44B}\u{431}\u{440}\u{430}\u{43D}\u{43D}\u{430}\u{44F} \u{434}\u{430}\u{442}\u{430}: ${e.date}`,selectedRangeDescription:e=>`\u{412}\u{44B}\u{431}\u{440}\u{430}\u{43D}\u{43D}\u{44B}\u{439} \u{434}\u{438}\u{430}\u{43F}\u{430}\u{437}\u{43E}\u{43D}: \u{441} ${e.startDate} \u{43F}\u{43E} ${e.endDate}`,selectedTimeDescription:e=>`\u{412}\u{44B}\u{431}\u{440}\u{430}\u{43D}\u{43D}\u{43E}\u{435} \u{432}\u{440}\u{435}\u{43C}\u{44F}: ${e.time}`,startDate:`Дата начала`,timeZoneName:`часовой пояс`,weekday:`день недели`,year:`год`};var ji={};ji={calendar:`Kalendár`,day:`deň`,dayPeriod:`AM/PM`,endDate:`Dátum ukončenia`,era:`letopočet`,hour:`hodina`,minute:`minúta`,month:`mesiac`,second:`sekunda`,selectedDateDescription:e=>`Vybrat\xfd d\xe1tum: ${e.date}`,selectedRangeDescription:e=>`Vybrat\xfd rozsah: od ${e.startDate} do ${e.endDate}`,selectedTimeDescription:e=>`Vybrat\xfd \u{10D}as: ${e.time}`,startDate:`Dátum začatia`,timeZoneName:`časové pásmo`,weekday:`deň týždňa`,year:`rok`};var Mi={};Mi={calendar:`Koledar`,day:`dan`,dayPeriod:`dop/pop`,endDate:`Datum konca`,era:`doba`,hour:`ura`,minute:`minuta`,month:`mesec`,second:`sekunda`,selectedDateDescription:e=>`Izbrani datum: ${e.date}`,selectedRangeDescription:e=>`Izbrano obmo\u{10D}je: ${e.startDate} do ${e.endDate}`,selectedTimeDescription:e=>`Izbrani \u{10D}as: ${e.time}`,startDate:`Datum začetka`,timeZoneName:`časovni pas`,weekday:`dan v tednu`,year:`leto`};var Ni={};Ni={calendar:`Kalendar`,day:`дан`,dayPeriod:`пре подне/по подне`,endDate:`Datum završetka`,era:`ера`,hour:`сат`,minute:`минут`,month:`месец`,second:`секунд`,selectedDateDescription:e=>`Izabrani datum: ${e.date}`,selectedRangeDescription:e=>`Izabrani opseg: od ${e.startDate} do ${e.endDate}`,selectedTimeDescription:e=>`Izabrano vreme: ${e.time}`,startDate:`Datum početka`,timeZoneName:`временска зона`,weekday:`дан у недељи`,year:`година`};var Pi={};Pi={calendar:`Kalender`,day:`dag`,dayPeriod:`fm/em`,endDate:`Slutdatum`,era:`era`,hour:`timme`,minute:`minut`,month:`månad`,second:`sekund`,selectedDateDescription:e=>`Valt datum: ${e.date}`,selectedRangeDescription:e=>`Valt intervall: ${e.startDate} till ${e.endDate}`,selectedTimeDescription:e=>`Vald tid: ${e.time}`,startDate:`Startdatum`,timeZoneName:`tidszon`,weekday:`veckodag`,year:`år`};var Fi={};Fi={calendar:`Takvim`,day:`gün`,dayPeriod:`ÖÖ/ÖS`,endDate:`Bitiş Tarihi`,era:`çağ`,hour:`saat`,minute:`dakika`,month:`ay`,second:`saniye`,selectedDateDescription:e=>`Se\xe7ilen Tarih: ${e.date}`,selectedRangeDescription:e=>`Se\xe7ilen Aral\u{131}k: ${e.startDate} - ${e.endDate}`,selectedTimeDescription:e=>`Se\xe7ilen Zaman: ${e.time}`,startDate:`Başlangıç Tarihi`,timeZoneName:`saat dilimi`,weekday:`haftanın günü`,year:`yıl`};var Ii={};Ii={calendar:`Календар`,day:`день`,dayPeriod:`дп/пп`,endDate:`Дата завершення`,era:`ера`,hour:`година`,minute:`хвилина`,month:`місяць`,second:`секунда`,selectedDateDescription:e=>`\u{412}\u{438}\u{431}\u{440}\u{430}\u{43D}\u{430} \u{434}\u{430}\u{442}\u{430}: ${e.date}`,selectedRangeDescription:e=>`\u{412}\u{438}\u{431}\u{440}\u{430}\u{43D}\u{438}\u{439} \u{434}\u{456}\u{430}\u{43F}\u{430}\u{437}\u{43E}\u{43D}: ${e.startDate} \u{2014} ${e.endDate}`,selectedTimeDescription:e=>`\u{412}\u{438}\u{431}\u{440}\u{430}\u{43D}\u{438}\u{439} \u{447}\u{430}\u{441}: ${e.time}`,startDate:`Дата початку`,timeZoneName:`часовий пояс`,weekday:`день тижня`,year:`рік`};var Li={};Li={calendar:`日历`,day:`日`,dayPeriod:`上午/下午`,endDate:`结束日期`,era:`纪元`,hour:`小时`,minute:`分钟`,month:`月`,second:`秒`,selectedDateDescription:e=>`\u{9009}\u{5B9A}\u{7684}\u{65E5}\u{671F}\u{FF1A}${e.date}`,selectedRangeDescription:e=>`\u{9009}\u{5B9A}\u{7684}\u{8303}\u{56F4}\u{FF1A}${e.startDate} \u{81F3} ${e.endDate}`,selectedTimeDescription:e=>`\u{9009}\u{5B9A}\u{7684}\u{65F6}\u{95F4}\u{FF1A}${e.time}`,startDate:`开始日期`,timeZoneName:`时区`,weekday:`工作日`,year:`年`};var Ri={};Ri={calendar:`日曆`,day:`日`,dayPeriod:`上午/下午`,endDate:`結束日期`,era:`纪元`,hour:`小时`,minute:`分钟`,month:`月`,second:`秒`,selectedDateDescription:e=>`\u{9078}\u{5B9A}\u{7684}\u{65E5}\u{671F}\u{FF1A}${e.date}`,selectedRangeDescription:e=>`\u{9078}\u{5B9A}\u{7684}\u{7BC4}\u{570D}\u{FF1A}${e.startDate} \u{81F3} ${e.endDate}`,selectedTimeDescription:e=>`\u{9078}\u{5B9A}\u{7684}\u{6642}\u{9593}\u{FF1A}${e.time}`,startDate:`開始日期`,timeZoneName:`时区`,weekday:`工作日`,year:`年`};var zi={};zi={"ar-AE":ai,"bg-BG":oi,"cs-CZ":si,"da-DK":ci,"de-DE":li,"el-GR":ui,"en-US":di,"es-ES":fi,"et-EE":pi,"fi-FI":mi,"fr-FR":hi,"he-IL":gi,"hr-HR":_i,"hu-HU":vi,"it-IT":yi,"ja-JP":bi,"ko-KR":xi,"lt-LT":Si,"lv-LV":Ci,"nb-NO":wi,"nl-NL":Ti,"pl-PL":Ei,"pt-BR":Di,"pt-PT":Oi,"ro-RO":ki,"ru-RU":Ai,"sk-SK":ji,"sl-SI":Mi,"sr-SP":Ni,"sv-SE":Pi,"tr-TR":Fi,"uk-UA":Ii,"zh-CN":Li,"zh-TW":Ri};function Bi(e,t,n){let{direction:r}=F(),i=(0,R.useMemo)(()=>de(t),[t]),{keyboardProps:a}=he({shortcuts:{"Alt+ArrowDown":()=>{if(`setOpen`in e){e.setOpen(!0);return}return!1},"Alt+ArrowUp":()=>{if(`setOpen`in e){e.setOpen(!0);return}return!1},ArrowLeft:e=>{if(n)return!1;if(r===`rtl`){if(t.current){let n=fe(e),r=Vi(t.current,n.getBoundingClientRect().left,-1);if(r){r.focus();return}}}else{i.focusPrevious();return}return!1},ArrowRight:e=>{if(n)return!1;if(r===`rtl`){if(t.current){let n=fe(e),r=Vi(t.current,n.getBoundingClientRect().left,1);if(r){r.focus();return}}}else{i.focusNext();return}return!1}},allowRepeats:!0}),o=()=>{if(!t.current)return;let e=window.event?fe(window.event):null,n=re(t.current,{tabbable:!0});if(e&&=(n.currentNode=e,n.previousNode()),!e){let t;do t=n.lastChild(),t&&(e=t);while(t)}for(;e?.hasAttribute(`data-placeholder`);){let t=n.previousNode();if(t&&t.hasAttribute(`data-placeholder`))e=t;else break}e&&e.focus()},{pressProps:s}=ue({preventFocusOnPress:!0,allowTextSelectionOnPress:!0,onPressStart(e){e.pointerType===`mouse`&&o()},onPress(e){(e.pointerType===`touch`||e.pointerType===`pen`)&&o()}});return D(s,a)}function Vi(e,t,n){let r=re(e,{tabbable:!0}),i=r.nextNode(),a=null,o=1/0;for(;i;){let e=i.getBoundingClientRect().left-t,s=Math.abs(e);Math.sign(e)===n&&s{t.confirmPlaceholder(),t.value!==u.current&&t.commitValidation(),e.onBlur?.(n)},onFocusWithinChange:e.onFocusChange}),f=h(Hi(zi),`@react-aria/datepicker`),p=t.maxGranularity===`hour`?`selectedTimeDescription`:`selectedDateDescription`,m=t.maxGranularity===`hour`?`time`:`date`,g=t.value?f.format(p,{[m]:t.formatValue({month:`long`})}):``,_=Ke(g),v=e.__reactAriaDateFieldRole===`presentation`?s[`aria-describedby`]:[_[`aria-describedby`],s[`aria-describedby`]].filter(Boolean).join(` `)||void 0,y=e[Gi],b=(0,R.useMemo)(()=>y||de(n),[y,n]),x=Bi(t,n,e[Wi]===`presentation`);Ui.set(t,{ariaLabel:e[`aria-label`],ariaLabelledBy:[o.id,e[`aria-labelledby`]].filter(Boolean).join(` `)||void 0,ariaDescribedBy:v,focusManager:b});let S=(0,R.useRef)(e.autoFocus),C;C=e.__reactAriaDateFieldRole===`presentation`?{role:`presentation`}:D(s,{role:`group`,"aria-disabled":e.isDisabled||void 0,"aria-describedby":v}),(0,R.useEffect)(()=>{S.current&&b.focusFirst(),S.current=!1},[b]),Ne(e.inputRef,t.defaultValue,t.setValue),ve({...e,focus(){b.focusFirst()}},t,e.inputRef);let w={type:`hidden`,name:e.name,form:e.form,value:t.value?.toString()||``,disabled:e.isDisabled};e.validationBehavior===`native`&&(w.type=`text`,w.hidden=!0,w.required=e.isRequired,w.onChange=()=>{});let T=I(e);return{labelProps:{...o,onClick:()=>{b.focusFirst()}},fieldProps:D(T,C,x,d,{onKeyDown:e.onKeyDown,onKeyUp:e.onKeyUp,style:{unicodeBidi:`isolate`}}),inputProps:w,descriptionProps:c,errorMessageProps:l,isInvalid:r,validationErrors:i,validationDetails:a}}function qi(e,t,n){let r=Ki(e,t,n);return r.inputProps.value=t.timeValue?.toString()||``,r}function Z(e){e=Ye(e??{},Ji);let{locale:t}=F();return(0,R.useMemo)(()=>new Y(t,e),[t,e])}function Ji(e,t){if(e===t)return!0;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(t[r]!==e[r])return!1;return!0}function Yi(e){return e&&e.__esModule?e.default:e}function Xi(){let{locale:e}=F(),t=c(Yi(zi),`@react-aria/datepicker`);return(0,R.useMemo)(()=>{try{return new Intl.DisplayNames(e,{type:`dateTimeField`})}catch{return new Zi(e,t)}},[e,t])}var Zi=class{constructor(e,t){this.locale=e,this.dictionary=t}of(e){return this.dictionary.getStringForLocale(e,this.locale)}};function Qi(e,t,n){let r=(0,R.useRef)(``),{locale:i,direction:a}=F(),o=Xi(),{ariaLabel:s,ariaLabelledBy:c,ariaDescribedBy:l,focusManager:u}=Ui.get(t),d=e.isPlaceholder?``:e.text,f=(0,R.useMemo)(()=>t.dateFormatter.resolvedOptions(),[t.dateFormatter]),p=Z({month:`long`,timeZone:f.timeZone}),m=Z({hour:`numeric`,hour12:f.hour12,timeZone:f.timeZone});if(e.type===`month`&&!e.isPlaceholder){let e=p.format(t.dateValue);d=e===d?e:`${d} \u{2013} ${e}`}else e.type===`hour`&&!e.isPlaceholder&&(d=m.format(t.dateValue));let{spinButtonProps:h}=Ie({value:e.value??void 0,textValue:d,minValue:e.minValue,maxValue:e.maxValue,isDisabled:t.isDisabled,isReadOnly:t.isReadOnly||!e.isEditable,isRequired:t.isRequired,onIncrement:()=>{r.current=``,t.increment(e.type)},onDecrement:()=>{r.current=``,t.decrement(e.type)},onIncrementPage:()=>{r.current=``,t.incrementPage(e.type)},onDecrementPage:()=>{r.current=``,t.decrementPage(e.type)},onIncrementToMax:()=>{r.current=``,t.incrementToMax(e.type)},onDecrementToMin:()=>{r.current=``,t.decrementToMin(e.type)}}),v=(0,R.useMemo)(()=>new Pe(i,{maximumFractionDigits:0}),[i]),y=()=>{if(e.text===e.placeholder&&u.focusPrevious(),v.isValidPartialNumber(e.text)&&!t.isReadOnly&&!e.isPlaceholder){let n=e.text.slice(0,-1),i=v.parse(n);n=i===0?``:n,n.length===0||i===0?t.clearSegment(e.type):t.setSegment(e.type,i),r.current=n}else(e.type===`dayPeriod`||e.type===`era`)&&t.clearSegment(e.type)},{keyboardProps:x}=he({shortcuts:{Backspace:()=>{y()},Delete:()=>{y()},"Mod+a":()=>{}},allowRepeats:!0}),{startsWith:S}=nt({sensitivity:`base`}),w=Z({hour:`numeric`,hour12:!0}),T=(0,R.useMemo)(()=>{let e=new Date;return e.setHours(0),w.formatToParts(e).find(e=>e.type===`dayPeriod`).value},[w]),E=(0,R.useMemo)(()=>{let e=new Date;return e.setHours(12),w.formatToParts(e).find(e=>e.type===`dayPeriod`).value},[w]),O=Z({year:`numeric`,era:`narrow`,timeZone:`UTC`}),k=(0,R.useMemo)(()=>{if(e.type!==`era`)return[];let n=G(new q(1,1,1),t.calendar),r=t.calendar.getEras().map(e=>{let t=n.set({year:1,month:1,day:1,era:e}).toDate(`UTC`);return{era:e,formatted:O.formatToParts(t).find(e=>e.type===`era`).value}}),i=$i(r.map(e=>e.formatted));if(i)for(let e of r)e.formatted=e.formatted.slice(i);return r},[O,t.calendar,e.type]),A=n=>{if(t.isDisabled||t.isReadOnly)return;let i=r.current+n;switch(e.type){case`dayPeriod`:if(S(T,n))t.setSegment(`dayPeriod`,0);else if(S(E,n))t.setSegment(`dayPeriod`,1);else break;u.focusNext();break;case`era`:{let e=k.find(e=>S(e.formatted,n));e&&(t.setSegment(`era`,e.era),u.focusNext());break}case`day`:case`hour`:case`minute`:case`second`:case`month`:case`year`:{if(!v.isValidPartialNumber(i))return;let a=v.parse(i),o=a;if(e.maxValue!==void 0&&a>e.maxValue&&(o=v.parse(n)),isNaN(a))return;t.setSegment(e.type,o),e.maxValue!==void 0&&(Number(a+`0`)>e.maxValue||i.length>=String(e.maxValue).length)?(r.current=``,u.focusNext()):r.current=i;break}}},ee=()=>{r.current=``,n.current&&ze(n.current,{containingElement:Ve(n.current)}),window.getSelection()?.collapse(n.current)},te=(0,R.useRef)(typeof document<`u`?document:null);g(te,`selectionchange`,()=>{let e=window.getSelection();e?.anchorNode&&ne(n.current,e?.anchorNode)&&b()===n.current&&e.collapse(n.current)});let j=(0,R.useRef)(``);g(n,`beforeinput`,r=>{if(n.current)switch(r.preventDefault(),r.inputType){case`deleteContentBackward`:case`deleteContentForward`:v.isValidPartialNumber(e.text)&&!t.isReadOnly&&y();break;case`insertCompositionText`:j.current=n.current.textContent,n.current.textContent=n.current.textContent;break;default:r.data!=null&&A(r.data)}}),g(n,`input`,e=>{let{inputType:t,data:r}=e;t===`insertCompositionText`&&(n.current&&(n.current.textContent=j.current),r!=null&&(S(T,r)||S(E,r))&&A(r))}),ae(()=>{let e=n.current;return()=>{b()===e&&(u.focusPrevious()||u.focusNext())}},[n,u]);let M=C()||e.type===`timeZoneName`?{role:`textbox`,"aria-valuemax":null,"aria-valuemin":null,"aria-valuetext":null,"aria-valuenow":null}:{};e!==(0,R.useMemo)(()=>t.segments.find(e=>e.isEditable),[t.segments])&&!t.isInvalid&&(l=void 0);let re=le(),N=!t.isDisabled&&!t.isReadOnly&&e.isEditable,ie=e.type===`literal`?``:o.of(e.type),P=_({"aria-label":`${ie}${s?`, ${s}`:``}${c?`, `:``}`,"aria-labelledby":c});if(e.type===`literal`)return{segmentProps:{"aria-hidden":!0}};let oe={caretColor:`transparent`};if(a===`rtl`){oe.unicodeBidi=`embed`;let t=f[e.type];(t===`numeric`||t===`2-digit`)&&(oe.direction=`ltr`)}return{segmentProps:D(h,P,{id:re,...M,...x,"aria-invalid":t.isInvalid?`true`:void 0,"aria-describedby":l,"aria-readonly":t.isReadOnly||!e.isEditable?`true`:void 0,"data-placeholder":e.isPlaceholder||void 0,contentEditable:N,suppressContentEditableWarning:N,spellCheck:N?`false`:void 0,autoCorrect:N?`off`:void 0,enterKeyHint:N?`next`:void 0,inputMode:t.isDisabled||e.type===`dayPeriod`||e.type===`era`||!N?void 0:`numeric`,tabIndex:t.isDisabled?void 0:0,onFocus:ee,style:oe,onPointerDown(e){e.stopPropagation()},onMouseDown(e){e.stopPropagation()}})}}function $i(e){e.sort();let t=e[0],n=e[e.length-1];for(let e=0;e`\u{64A}\u{62C}\u{628} \u{623}\u{646} \u{62A}\u{643}\u{648}\u{646} \u{627}\u{644}\u{642}\u{64A}\u{645}\u{629} ${e.maxValue} \u{623}\u{648} \u{642}\u{628}\u{644} \u{630}\u{644}\u{643}.`,rangeReversed:`تاريخ البدء يجب أن يكون قبل تاريخ الانتهاء.`,rangeUnderflow:e=>`\u{64A}\u{62C}\u{628} \u{623}\u{646} \u{62A}\u{643}\u{648}\u{646} \u{627}\u{644}\u{642}\u{64A}\u{645}\u{629} ${e.minValue} \u{623}\u{648} \u{628}\u{639}\u{62F} \u{630}\u{644}\u{643}.`,unavailableDate:`البيانات المحددة غير متاحة.`};var ta={};ta={rangeOverflow:e=>`\u{421}\u{442}\u{43E}\u{439}\u{43D}\u{43E}\u{441}\u{442}\u{442}\u{430} \u{442}\u{440}\u{44F}\u{431}\u{432}\u{430} \u{434}\u{430} \u{435} ${e.maxValue} \u{438}\u{43B}\u{438} \u{43F}\u{43E}-\u{440}\u{430}\u{43D}\u{43D}\u{430}.`,rangeReversed:`Началната дата трябва да е преди крайната.`,rangeUnderflow:e=>`\u{421}\u{442}\u{43E}\u{439}\u{43D}\u{43E}\u{441}\u{442}\u{442}\u{430} \u{442}\u{440}\u{44F}\u{431}\u{432}\u{430} \u{434}\u{430} \u{435} ${e.minValue} \u{438}\u{43B}\u{438} \u{43F}\u{43E}-\u{43A}\u{44A}\u{441}\u{43D}\u{43E}.`,unavailableDate:`Избраната дата не е налична.`};var na={};na={rangeOverflow:e=>`Hodnota mus\xed b\xfdt ${e.maxValue} nebo d\u{159}\xedv\u{11B}j\u{161}\xed.`,rangeReversed:`Datum zahájení musí předcházet datu ukončení.`,rangeUnderflow:e=>`Hodnota mus\xed b\xfdt ${e.minValue} nebo pozd\u{11B}j\u{161}\xed.`,unavailableDate:`Vybrané datum není k dispozici.`};var ra={};ra={rangeOverflow:e=>`V\xe6rdien skal v\xe6re ${e.maxValue} eller tidligere.`,rangeReversed:`Startdatoen skal være før slutdatoen.`,rangeUnderflow:e=>`V\xe6rdien skal v\xe6re ${e.minValue} eller nyere.`,unavailableDate:`Den valgte dato er ikke tilgængelig.`};var ia={};ia={rangeOverflow:e=>`Der Wert muss ${e.maxValue} oder fr\xfcher sein.`,rangeReversed:`Das Startdatum muss vor dem Enddatum liegen.`,rangeUnderflow:e=>`Der Wert muss ${e.minValue} oder sp\xe4ter sein.`,unavailableDate:`Das ausgewählte Datum ist nicht verfügbar.`};var aa={};aa={rangeOverflow:e=>`\u{397} \u{3C4}\u{3B9}\u{3BC}\u{3AE} \u{3C0}\u{3C1}\u{3AD}\u{3C0}\u{3B5}\u{3B9} \u{3BD}\u{3B1} \u{3B5}\u{3AF}\u{3BD}\u{3B1}\u{3B9} ${e.maxValue} \u{3AE} \u{3C0}\u{3B1}\u{3BB}\u{3B1}\u{3B9}\u{3CC}\u{3C4}\u{3B5}\u{3C1}\u{3B7}.`,rangeReversed:`Η ημερομηνία έναρξης πρέπει να είναι πριν από την ημερομηνία λήξης.`,rangeUnderflow:e=>`\u{397} \u{3C4}\u{3B9}\u{3BC}\u{3AE} \u{3C0}\u{3C1}\u{3AD}\u{3C0}\u{3B5}\u{3B9} \u{3BD}\u{3B1} \u{3B5}\u{3AF}\u{3BD}\u{3B1}\u{3B9} ${e.minValue} \u{3AE} \u{3BC}\u{3B5}\u{3C4}\u{3B1}\u{3B3}\u{3B5}\u{3BD}\u{3AD}\u{3C3}\u{3C4}\u{3B5}\u{3C1}\u{3B7}.`,unavailableDate:`Η επιλεγμένη ημερομηνία δεν είναι διαθέσιμη.`};var oa={};oa={rangeUnderflow:e=>`Value must be ${e.minValue} or later.`,rangeOverflow:e=>`Value must be ${e.maxValue} or earlier.`,rangeReversed:`Start date must be before end date.`,unavailableDate:`Selected date unavailable.`};var sa={};sa={rangeOverflow:e=>`El valor debe ser ${e.maxValue} o anterior.`,rangeReversed:`La fecha de inicio debe ser anterior a la fecha de finalización.`,rangeUnderflow:e=>`El valor debe ser ${e.minValue} o posterior.`,unavailableDate:`Fecha seleccionada no disponible.`};var ca={};ca={rangeOverflow:e=>`V\xe4\xe4rtus peab olema ${e.maxValue} v\xf5i varasem.`,rangeReversed:`Alguskuupäev peab olema enne lõppkuupäeva.`,rangeUnderflow:e=>`V\xe4\xe4rtus peab olema ${e.minValue} v\xf5i hilisem.`,unavailableDate:`Valitud kuupäev pole saadaval.`};var la={};la={rangeOverflow:e=>`Arvon on oltava ${e.maxValue} tai sit\xe4 aikaisempi.`,rangeReversed:`Aloituspäivän on oltava ennen lopetuspäivää.`,rangeUnderflow:e=>`Arvon on oltava ${e.minValue} tai sit\xe4 my\xf6h\xe4isempi.`,unavailableDate:`Valittu päivämäärä ei ole käytettävissä.`};var ua={};ua={rangeOverflow:e=>`La valeur doit \xeatre ${e.maxValue} ou ant\xe9rieure.`,rangeReversed:`La date de début doit être antérieure à la date de fin.`,rangeUnderflow:e=>`La valeur doit \xeatre ${e.minValue} ou ult\xe9rieure.`,unavailableDate:`La date sélectionnée n’est pas disponible.`};var da={};da={rangeOverflow:e=>`\u{5D4}\u{5E2}\u{5E8}\u{5DA} \u{5D7}\u{5D9}\u{5D9}\u{5D1} \u{5DC}\u{5D4}\u{5D9}\u{5D5}\u{5EA} ${e.maxValue} \u{5D0}\u{5D5} \u{5DE}\u{5D5}\u{5E7}\u{5D3}\u{5DD} \u{5D9}\u{5D5}\u{5EA}\u{5E8}.`,rangeReversed:`תאריך ההתחלה חייב להיות לפני תאריך הסיום.`,rangeUnderflow:e=>`\u{5D4}\u{5E2}\u{5E8}\u{5DA} \u{5D7}\u{5D9}\u{5D9}\u{5D1} \u{5DC}\u{5D4}\u{5D9}\u{5D5}\u{5EA} ${e.minValue} \u{5D0}\u{5D5} \u{5DE}\u{5D0}\u{5D5}\u{5D7}\u{5E8} \u{5D9}\u{5D5}\u{5EA}\u{5E8}.`,unavailableDate:`התאריך הנבחר אינו זמין.`};var fa={};fa={rangeOverflow:e=>`Vrijednost mora biti ${e.maxValue} ili ranije.`,rangeReversed:`Datum početka mora biti prije datuma završetka.`,rangeUnderflow:e=>`Vrijednost mora biti ${e.minValue} ili kasnije.`,unavailableDate:`Odabrani datum nije dostupan.`};var pa={};pa={rangeOverflow:e=>`Az \xe9rt\xe9knek ${e.maxValue} vagy kor\xe1bbinak kell lennie.`,rangeReversed:`A kezdő dátumnak a befejező dátumnál korábbinak kell lennie.`,rangeUnderflow:e=>`Az \xe9rt\xe9knek ${e.minValue} vagy k\xe9s\u{151}bbinek kell lennie.`,unavailableDate:`A kiválasztott dátum nem érhető el.`};var ma={};ma={rangeOverflow:e=>`Il valore deve essere ${e.maxValue} o precedente.`,rangeReversed:`La data di inizio deve essere antecedente alla data di fine.`,rangeUnderflow:e=>`Il valore deve essere ${e.minValue} o successivo.`,unavailableDate:`Data selezionata non disponibile.`};var ha={};ha={rangeOverflow:e=>`\u{5024}\u{306F} ${e.maxValue} \u{4EE5}\u{4E0B}\u{306B}\u{3059}\u{308B}\u{5FC5}\u{8981}\u{304C}\u{3042}\u{308A}\u{307E}\u{3059}\u{3002}`,rangeReversed:`開始日は終了日より前にする必要があります。`,rangeUnderflow:e=>`\u{5024}\u{306F} ${e.minValue} \u{4EE5}\u{4E0A}\u{306B}\u{3059}\u{308B}\u{5FC5}\u{8981}\u{304C}\u{3042}\u{308A}\u{307E}\u{3059}\u{3002}`,unavailableDate:`選択した日付は使用できません。`};var ga={};ga={rangeOverflow:e=>`\u{AC12}\u{C740} ${e.maxValue} \u{C774}\u{C804}\u{C774}\u{C5B4}\u{C57C} \u{D569}\u{B2C8}\u{B2E4}.`,rangeReversed:`시작일은 종료일 이전이어야 합니다.`,rangeUnderflow:e=>`\u{AC12}\u{C740} ${e.minValue} \u{C774}\u{D6C4}\u{C5EC}\u{C57C} \u{D569}\u{B2C8}\u{B2E4}.`,unavailableDate:`선택한 날짜를 사용할 수 없습니다.`};var _a={};_a={rangeOverflow:e=>`Reik\u{161}m\u{117} turi b\u{16B}ti ${e.maxValue} arba ankstesn\u{117}.`,rangeReversed:`Pradžios data turi būti ankstesnė nei pabaigos data.`,rangeUnderflow:e=>`Reik\u{161}m\u{117} turi b\u{16B}ti ${e.minValue} arba naujesn\u{117}.`,unavailableDate:`Pasirinkta data nepasiekiama.`};var va={};va={rangeOverflow:e=>`V\u{113}rt\u{12B}bai ir j\u{101}b\u{16B}t ${e.maxValue} vai agr\u{101}kai.`,rangeReversed:`Sākuma datumam ir jābūt pirms beigu datuma.`,rangeUnderflow:e=>`V\u{113}rt\u{12B}bai ir j\u{101}b\u{16B}t ${e.minValue} vai v\u{113}l\u{101}kai.`,unavailableDate:`Atlasītais datums nav pieejams.`};var ya={};ya={rangeOverflow:e=>`Verdien m\xe5 v\xe6re ${e.maxValue} eller tidligere.`,rangeReversed:`Startdatoen må være før sluttdatoen.`,rangeUnderflow:e=>`Verdien m\xe5 v\xe6re ${e.minValue} eller senere.`,unavailableDate:`Valgt dato utilgjengelig.`};var ba={};ba={rangeOverflow:e=>`Waarde moet ${e.maxValue} of eerder zijn.`,rangeReversed:`De startdatum moet voor de einddatum liggen.`,rangeUnderflow:e=>`Waarde moet ${e.minValue} of later zijn.`,unavailableDate:`Geselecteerde datum niet beschikbaar.`};var xa={};xa={rangeOverflow:e=>`Warto\u{15B}\u{107} musi mie\u{107} warto\u{15B}\u{107} ${e.maxValue} lub wcze\u{15B}niejsz\u{105}.`,rangeReversed:`Data rozpoczęcia musi być wcześniejsza niż data zakończenia.`,rangeUnderflow:e=>`Warto\u{15B}\u{107} musi mie\u{107} warto\u{15B}\u{107} ${e.minValue} lub p\xf3\u{17A}niejsz\u{105}.`,unavailableDate:`Wybrana data jest niedostępna.`};var Sa={};Sa={rangeOverflow:e=>`O valor deve ser ${e.maxValue} ou anterior.`,rangeReversed:`A data inicial deve ser anterior à data final.`,rangeUnderflow:e=>`O valor deve ser ${e.minValue} ou posterior.`,unavailableDate:`Data selecionada indisponível.`};var Ca={};Ca={rangeOverflow:e=>`O valor tem de ser ${e.maxValue} ou anterior.`,rangeReversed:`A data de início deve ser anterior à data de fim.`,rangeUnderflow:e=>`O valor tem de ser ${e.minValue} ou posterior.`,unavailableDate:`Data selecionada indisponível.`};var wa={};wa={rangeOverflow:e=>`Valoarea trebuie s\u{103} fie ${e.maxValue} sau anterioar\u{103}.`,rangeReversed:`Data de început trebuie să fie anterioară datei de sfârșit.`,rangeUnderflow:e=>`Valoarea trebuie s\u{103} fie ${e.minValue} sau ulterioar\u{103}.`,unavailableDate:`Data selectată nu este disponibilă.`};var Ta={};Ta={rangeOverflow:e=>`\u{417}\u{43D}\u{430}\u{447}\u{435}\u{43D}\u{438}\u{435} \u{434}\u{43E}\u{43B}\u{436}\u{43D}\u{43E} \u{431}\u{44B}\u{442}\u{44C} \u{43D}\u{435} \u{43F}\u{43E}\u{437}\u{436}\u{435} ${e.maxValue}.`,rangeReversed:`Дата начала должна предшествовать дате окончания.`,rangeUnderflow:e=>`\u{417}\u{43D}\u{430}\u{447}\u{435}\u{43D}\u{438}\u{435} \u{434}\u{43E}\u{43B}\u{436}\u{43D}\u{43E} \u{431}\u{44B}\u{442}\u{44C} \u{43D}\u{435} \u{440}\u{430}\u{43D}\u{44C}\u{448}\u{435} ${e.minValue}.`,unavailableDate:`Выбранная дата недоступна.`};var Ea={};Ea={rangeOverflow:e=>`Hodnota mus\xed by\u{165} ${e.maxValue} alebo skor\u{161}ia.`,rangeReversed:`Dátum začiatku musí byť skorší ako dátum konca.`,rangeUnderflow:e=>`Hodnota mus\xed by\u{165} ${e.minValue} alebo neskor\u{161}ia.`,unavailableDate:`Vybratý dátum je nedostupný.`};var Da={};Da={rangeOverflow:e=>`Vrednost mora biti ${e.maxValue} ali starej\u{161}a.`,rangeReversed:`Začetni datum mora biti pred končnim datumom.`,rangeUnderflow:e=>`Vrednost mora biti ${e.minValue} ali novej\u{161}a.`,unavailableDate:`Izbrani datum ni na voljo.`};var Oa={};Oa={rangeOverflow:e=>`Vrednost mora da bude ${e.maxValue} ili starija.`,rangeReversed:`Datum početka mora biti pre datuma završetka.`,rangeUnderflow:e=>`Vrednost mora da bude ${e.minValue} ili novija.`,unavailableDate:`Izabrani datum nije dostupan.`};var ka={};ka={rangeOverflow:e=>`V\xe4rdet m\xe5ste vara ${e.maxValue} eller tidigare.`,rangeReversed:`Startdatumet måste vara före slutdatumet.`,rangeUnderflow:e=>`V\xe4rdet m\xe5ste vara ${e.minValue} eller senare.`,unavailableDate:`Det valda datumet är inte tillgängligt.`};var Aa={};Aa={rangeOverflow:e=>`De\u{11F}er, ${e.maxValue} veya \xf6ncesi olmal\u{131}d\u{131}r.`,rangeReversed:`Başlangıç tarihi bitiş tarihinden önce olmalıdır.`,rangeUnderflow:e=>`De\u{11F}er, ${e.minValue} veya sonras\u{131} olmal\u{131}d\u{131}r.`,unavailableDate:`Seçilen tarih kullanılamıyor.`};var ja={};ja={rangeOverflow:e=>`\u{417}\u{43D}\u{430}\u{447}\u{435}\u{43D}\u{43D}\u{44F} \u{43C}\u{430}\u{454} \u{431}\u{443}\u{442}\u{438} \u{43D}\u{435} \u{43F}\u{456}\u{437}\u{43D}\u{456}\u{448}\u{435} ${e.maxValue}.`,rangeReversed:`Дата початку має передувати даті завершення.`,rangeUnderflow:e=>`\u{417}\u{43D}\u{430}\u{447}\u{435}\u{43D}\u{43D}\u{44F} \u{43C}\u{430}\u{454} \u{431}\u{443}\u{442}\u{438} \u{43D}\u{435} \u{440}\u{430}\u{43D}\u{456}\u{448}\u{435} ${e.minValue}.`,unavailableDate:`Вибрана дата недоступна.`};var Ma={};Ma={rangeOverflow:e=>`\u{503C}\u{5FC5}\u{987B}\u{662F} ${e.maxValue} \u{6216}\u{66F4}\u{65E9}\u{65E5}\u{671F}\u{3002}`,rangeReversed:`开始日期必须早于结束日期。`,rangeUnderflow:e=>`\u{503C}\u{5FC5}\u{987B}\u{662F} ${e.minValue} \u{6216}\u{66F4}\u{665A}\u{65E5}\u{671F}\u{3002}`,unavailableDate:`所选日期不可用。`};var Na={};Na={rangeOverflow:e=>`\u{503C}\u{5FC5}\u{9808}\u{662F} ${e.maxValue} \u{6216}\u{66F4}\u{65E9}\u{3002}`,rangeReversed:`開始日期必須在結束日期之前。`,rangeUnderflow:e=>`\u{503C}\u{5FC5}\u{9808}\u{662F} ${e.minValue} \u{6216}\u{66F4}\u{665A}\u{3002}`,unavailableDate:`所選日期無法使用。`};var Pa={};Pa={"ar-AE":ea,"bg-BG":ta,"cs-CZ":na,"da-DK":ra,"de-DE":ia,"el-GR":aa,"en-US":oa,"es-ES":sa,"et-EE":ca,"fi-FI":la,"fr-FR":ua,"he-IL":da,"hr-HR":fa,"hu-HU":pa,"it-IT":ma,"ja-JP":ha,"ko-KR":ga,"lt-LT":_a,"lv-LV":va,"nb-NO":ya,"nl-NL":ba,"pl-PL":xa,"pt-BR":Sa,"pt-PT":Ca,"ro-RO":wa,"ru-RU":Ta,"sk-SK":Ea,"sl-SI":Da,"sr-SP":Oa,"sv-SE":ka,"tr-TR":Aa,"uk-UA":ja,"zh-CN":Ma,"zh-TW":Na};function Fa(e){return e&&e.__esModule?e.default:e}var Ia=new m(Fa(Pa));function La(){let e=typeof navigator<`u`&&(navigator.language||navigator.userLanguage)||`en-US`;try{Intl.DateTimeFormat.supportedLocalesOf([e])}catch{e=`en-US`}return e}function Ra(e,t,n,i,a){let o=e!=null&&n!=null&&e.compare(n)>0,s=e!=null&&t!=null&&e.compare(t)<0,c=e!=null&&i?.(e)||!1,l=o||s||c,u=[];if(l){let e=La(),i=m.getGlobalDictionaryForPackage(`@react-stately/datepicker`)||Ia,l=new r(e,i),d=new Y(e,Ha({},a)),f=d.resolvedOptions().timeZone;s&&t!=null&&u.push(l.format(`rangeUnderflow`,{minValue:d.format(t.toDate(f))})),o&&n!=null&&u.push(l.format(`rangeOverflow`,{maxValue:d.format(n.toDate(f))})),c&&u.push(l.format(`unavailableDate`))}return{isInvalid:l,validationErrors:u,validationDetails:{badInput:c,customError:!1,patternMismatch:!1,rangeOverflow:o,rangeUnderflow:s,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valueMissing:!1,valid:!l}}}function za(e,t,n,r,i){let a=Ra(e?.start??null,t,n,r,i),o=Ra(e?.end??null,t,n,r,i),s=we(a,o);if(e?.end!=null&&e.start!=null&&e.end.compare(e.start)<0){let e=m.getGlobalDictionaryForPackage(`@react-stately/datepicker`)||Ia;s=we(s,{isInvalid:!0,validationErrors:[e.getStringForLocale(`rangeReversed`,La())],validationDetails:{...be,rangeUnderflow:!0,rangeOverflow:!0,valid:!1}})}return s}var Ba={year:`numeric`,month:`numeric`,day:`numeric`,hour:`numeric`,minute:`2-digit`,second:`2-digit`},Va={year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`};function Ha(e,t){e={...t.shouldForceLeadingZeros?Va:Ba,...e};let n=t.granularity||`minute`,r=Object.keys(e),i=r.indexOf(t.maxGranularity??`year`);i<0&&(i=0);let a=r.indexOf(n);if(a<0&&(a=2),i>a)throw Error(`maxGranularity must be greater than granularity`);let o=r.slice(i,a+1).reduce((t,n)=>(t[n]=e[n],t),{});return t.hourCycle!=null&&(o.hour12=t.hourCycle===12),o.timeZone=t.timeZone||`UTC`,(n===`hour`||n===`minute`||n===`second`)&&t.timeZone&&!t.hideTimeZone&&(o.timeZoneName=`short`),t.showEra&&i===0&&(o.era=`short`),o}function Ua(e){return e&&`hour`in e?e:new Ln}function Wa(e,t){if(e===null)return null;if(e)return G(e,t)}function Ga(e,t,n,r){if(e)return Wa(e,n);let i=G(vt(r??Tt()).set({hour:0,minute:0,second:0,millisecond:0}),n);return t===`year`||t===`month`||t===`day`?U(i):r?i:W(i)}function Ka(e,t){let n=e&&`timeZone`in e?e.timeZone:void 0,r=e&&`minute`in e?`minute`:`day`;if(e&&t&&!(t in e))throw Error(`Invalid granularity `+t+` for value `+e.toString());let[i,a]=(0,R.useState)([r,n]);e&&(i[0]!==r||i[1]!==n)&&a([r,n]),t||=e?r:i[0];let o=e?n:i[1];return[t,o]}var qa=new m({ach:{year:`mwaka`,month:`dwe`,day:`nino`},af:{year:`jjjj`,month:`mm`,day:`dd`},am:{year:`ዓዓዓዓ`,month:`ሚሜ`,day:`ቀቀ`},an:{year:`aaaa`,month:`mm`,day:`dd`},ar:{year:`سنة`,month:`شهر`,day:`يوم`},ast:{year:`aaaa`,month:`mm`,day:`dd`},az:{year:`iiii`,month:`aa`,day:`gg`},be:{year:`гггг`,month:`мм`,day:`дд`},bg:{year:`гггг`,month:`мм`,day:`дд`},bn:{year:`yyyy`,month:`মিমি`,day:`dd`},br:{year:`bbbb`,month:`mm`,day:`dd`},bs:{year:`gggg`,month:`mm`,day:`dd`},ca:{year:`aaaa`,month:`mm`,day:`dd`},cak:{year:`jjjj`,month:`ii`,day:`q'q'`},ckb:{year:`ساڵ`,month:`مانگ`,day:`ڕۆژ`},cs:{year:`rrrr`,month:`mm`,day:`dd`},cy:{year:`bbbb`,month:`mm`,day:`dd`},da:{year:`åååå`,month:`mm`,day:`dd`},de:{year:`jjjj`,month:`mm`,day:`tt`},dsb:{year:`llll`,month:`mm`,day:`źź`},el:{year:`εεεε`,month:`μμ`,day:`ηη`},en:{year:`yyyy`,month:`mm`,day:`dd`},eo:{year:`jjjj`,month:`mm`,day:`tt`},es:{year:`aaaa`,month:`mm`,day:`dd`},et:{year:`aaaa`,month:`kk`,day:`pp`},eu:{year:`uuuu`,month:`hh`,day:`ee`},fa:{year:`سال`,month:`ماه`,day:`روز`},ff:{year:`hhhh`,month:`ll`,day:`ññ`},fi:{year:`vvvv`,month:`kk`,day:`pp`},fr:{year:`aaaa`,month:`mm`,day:`jj`},fy:{year:`jjjj`,month:`mm`,day:`dd`},ga:{year:`bbbb`,month:`mm`,day:`ll`},gd:{year:`bbbb`,month:`mm`,day:`ll`},gl:{year:`aaaa`,month:`mm`,day:`dd`},he:{year:`שנה`,month:`חודש`,day:`יום`},hr:{year:`gggg`,month:`mm`,day:`dd`},hsb:{year:`llll`,month:`mm`,day:`dd`},hu:{year:`éééé`,month:`hh`,day:`nn`},ia:{year:`aaaa`,month:`mm`,day:`dd`},id:{year:`tttt`,month:`bb`,day:`hh`},is:{year:`áááá`,month:`mm`,day:`dd`},it:{year:`aaaa`,month:`mm`,day:`gg`},ja:{year:`年`,month:`月`,day:`日`},ka:{year:`წწწწ`,month:`თთ`,day:`რრ`},kk:{year:`жжжж`,month:`аа`,day:`кк`},kn:{year:`ವವವವ`,month:`ಮಿಮೀ`,day:`ದಿದಿ`},ko:{year:`연도`,month:`월`,day:`일`},lb:{year:`jjjj`,month:`mm`,day:`dd`},lo:{year:`ປປປປ`,month:`ດດ`,day:`ວວ`},lt:{year:`mmmm`,month:`mm`,day:`dd`},lv:{year:`gggg`,month:`mm`,day:`dd`},meh:{year:`aaaa`,month:`mm`,day:`dd`},ml:{year:`വർഷം`,month:`മാസം`,day:`തീയതി`},ms:{year:`tttt`,month:`mm`,day:`hh`},nb:{year:`åååå`,month:`mm`,day:`dd`},nl:{year:`jjjj`,month:`mm`,day:`dd`},nn:{year:`åååå`,month:`mm`,day:`dd`},no:{year:`åååå`,month:`mm`,day:`dd`},oc:{year:`aaaa`,month:`mm`,day:`jj`},pl:{year:`rrrr`,month:`mm`,day:`dd`},pt:{year:`aaaa`,month:`mm`,day:`dd`},rm:{year:`oooo`,month:`mm`,day:`dd`},ro:{year:`aaaa`,month:`ll`,day:`zz`},ru:{year:`гггг`,month:`мм`,day:`дд`},sc:{year:`aaaa`,month:`mm`,day:`dd`},scn:{year:`aaaa`,month:`mm`,day:`jj`},sk:{year:`rrrr`,month:`mm`,day:`dd`},sl:{year:`llll`,month:`mm`,day:`dd`},sr:{year:`гггг`,month:`мм`,day:`дд`},"sr-Latn":{year:`gggg`,month:`mm`,day:`dd`},sv:{year:`åååå`,month:`mm`,day:`dd`},szl:{year:`rrrr`,month:`mm`,day:`dd`},tg:{year:`сссс`,month:`мм`,day:`рр`},th:{year:`ปปปป`,month:`ดด`,day:`วว`},tr:{year:`yyyy`,month:`aa`,day:`gg`},uk:{year:`рррр`,month:`мм`,day:`дд`},"zh-CN":{year:`年`,month:`月`,day:`日`},"zh-TW":{year:`年`,month:`月`,day:`日`}},`en`);function Ja(e,t,n){return e===`era`||e===`dayPeriod`?t:e===`year`||e===`month`||e===`day`?qa.getStringForLocale(e,n):`––`}var Ya=class e{constructor(e,t,n){if(this.era=n?.era??null,this.calendar=e,this.year=n?.year??null,this.month=n?.month??null,this.day=n?.day??null,this.hour=n?.hour??null,this.hourCycle=t,this.dayPeriod=null,this.minute=n?.minute??null,this.second=n?.second??null,this.millisecond=n?.millisecond??null,this.offset=`offset`in(n??{})?n.offset:null,this.hour!=null){let[e,n]=Za(this.hour,t);this.dayPeriod=e,this.hour=n}}copy(){let t=new e(this.calendar,this.hourCycle);return t.era=this.era,t.year=this.year,t.month=this.month,t.day=this.day,t.hour=this.hour,t.dayPeriod=this.dayPeriod,t.minute=this.minute,t.second=this.second,t.millisecond=this.millisecond,t.offset=this.offset,t}isComplete(e){return e.every(e=>this[e]!=null)}validate(e,t){return t.every(t=>{if((t===`hour`||t===`dayPeriod`)&&`hour`in e){let[t,n]=Za(e.hour,this.hourCycle);return this.dayPeriod===t&&this.hour===n}return this[t]===e[t]})}isCleared(e){return e.every(e=>this[e]===null)}set(e,t,n){let r=this.copy();return r[e]=t,e===`hour`&&r.dayPeriod==null&&`hour`in n&&(r.dayPeriod=Za(n.hour,this.hourCycle)[0]),e===`year`&&r.era==null&&(r.era=n.era),e!==`second`&&e!==`literal`&&e!==`timeZoneName`&&(r.offset=null),r}clear(e){let t=this.copy();return t[e]=null,e===`year`&&(t.era=null),t.offset=null,t}cycle(e,t,n,r){let i=this.copy();if(i[e]==null&&e!==`dayPeriod`&&e!==`era`){if(e===`hour`&&`hour`in n){let[e,t]=Za(n.hour,this.hourCycle);i.dayPeriod=e,i.hour=t}else i[e]=n[e];return e===`year`&&i.era==null&&(i.era=n.era),i}switch(e){case`era`:{let e=this.calendar.getEras(),n=e.indexOf(i.era);n=Xa(n,t,0,e.length-1),i.era=e[n];break}case`year`:{let r=new q(this.calendar,this.era??n.era,this.year??n.year,this.month??1,this.day??1);r=r.cycle(e,t,{round:e===`year`}),i.era=r.era,i.year=r.year;break}case`month`:i.month=Xa(i.month??1,t,1,this.calendar.getMaximumMonthsInYear());break;case`day`:i.day=Xa(i.day??1,t,1,this.calendar.getMaximumDaysInMonth());break;case`hour`:{let e=r.some(e=>[`year`,`month`,`day`].includes(e));if(`timeZone`in n&&(!e||i.year!=null&&i.month!=null&&i.day!=null)){let e=this.toValue(n);e=e.cycle(`hour`,t,{hourCycle:this.hourCycle===`h12`?12:24,round:!1});let[r,a]=Za(e.hour,this.hourCycle);i.hour=a,i.dayPeriod=r,i.offset=e.offset}else{let e=i.hour??0,r=this.getSegmentLimits(`hour`);i.hour=Xa(e,t,r.minValue,r.maxValue),i.dayPeriod==null&&`hour`in n&&(i.dayPeriod=Za(n.hour,this.hourCycle)[0])}break}case`dayPeriod`:i.dayPeriod=Xa(i.dayPeriod??0,t,0,1);break;case`minute`:i.minute=Xa(i.minute??0,t,0,59,!0);break;case`second`:i.second=Xa(i.second??0,t,0,59,!0)}return i}toValue(e){if(`hour`in e){let t=this.hour;t==null?(this.hourCycle===`h12`||this.hourCycle===`h11`)&&(t=this.dayPeriod===1?12:0):t=Qa(t,this.dayPeriod??0,this.hourCycle);let n=e.set({era:this.era??e.era,year:this.year??e.year,month:this.month??e.month,day:this.day??e.day,hour:t??e.hour,minute:this.minute??e.minute,second:this.second??e.second,millisecond:this.millisecond??e.millisecond});return`offset`in n&&this.offset!=null&&n.offset!==this.offset&&(n=n.add({milliseconds:n.offset-this.offset})),n}return e.set({era:this.era??e.era,year:this.year??e.year,month:this.month??e.month,day:this.day??e.day})}getSegmentLimits(e){switch(e){case`era`:{let e=this.calendar.getEras();return{value:this.era==null?e.length-1:e.indexOf(this.era),minValue:0,maxValue:e.length-1}}case`year`:return{value:this.year,minValue:1,maxValue:9999};case`month`:return{value:this.month,minValue:1,maxValue:this.calendar.getMaximumMonthsInYear()};case`day`:return{value:this.day,minValue:1,maxValue:this.calendar.getMaximumDaysInMonth()};case`dayPeriod`:return{value:this.dayPeriod,minValue:0,maxValue:1};case`hour`:{let e=0,t=23;return this.hourCycle===`h12`?(e=1,t=12):this.hourCycle===`h11`&&(e=0,t=11),{value:this.hour,minValue:e,maxValue:t}}case`minute`:return{value:this.minute,minValue:0,maxValue:59};case`second`:return{value:this.second,minValue:0,maxValue:59}}}};function Xa(e,t,n,r,i=!1){if(i){e+=Math.sign(t),e0?Math.ceil(e/i)*i:Math.floor(e/i)*i,e>r&&(e=n)}else e+=t,er&&(e=n+(e-r-1));return e}function Za(e,t){let n=+(e>=12);switch(t){case`h11`:e>=12&&(e-=12);break;case`h12`:e===0?e=12:e>12&&(e-=12);break;case`h23`:n=null;break;case`h24`:e+=1,n=null}return[n,e]}function Qa(e,t,n){switch(n){case`h11`:t===1&&(e+=12);break;case`h12`:e===12&&(e=0),t===1&&(e+=12);break;case`h24`:--e}return e}var $a={year:!0,month:!0,day:!0,hour:!0,minute:!0,second:!0,dayPeriod:!0,era:!0},eo={year:5,month:2,day:7,hour:2,minute:15,second:15},to={dayperiod:`dayPeriod`,relatedYear:`year`,yearName:`literal`,unknown:`literal`};function no(e){let{locale:t,createCalendar:n,hideTimeZone:r,isDisabled:i=!1,isReadOnly:a=!1,isRequired:o=!1,minValue:s,maxValue:c,isDateUnavailable:l}=e,u=e.value||e.defaultValue||e.placeholderValue||null,[d,f]=Ka(u,e.granularity),p=f||`UTC`;if(u&&!(d in u))throw Error(`Invalid granularity `+d+` for value `+u.toString());let[m,h]=(0,R.useMemo)(()=>{let r=new Y(t,{dateStyle:`short`,timeStyle:`short`,hour12:e.hourCycle==null?void 0:e.hourCycle===12}).resolvedOptions();return[n(r.calendar),r.hourCycle]},[t,e.hourCycle,n]),[g,_]=ce(e.value,e.defaultValue??null,e.onChange),[v]=(0,R.useState)(g),y=(0,R.useMemo)(()=>Wa(g,m)??null,[g,m]),[b,x]=(0,R.useState)(()=>new Ya(m,h,y)),S=m.identifier===`gregory`&&b.era===`BC`,C=(0,R.useMemo)(()=>({granularity:d,maxGranularity:e.maxGranularity??`year`,timeZone:f,hideTimeZone:r,hourCycle:e.hourCycle,showEra:S,shouldForceLeadingZeros:e.shouldForceLeadingZeros}),[e.maxGranularity,d,e.hourCycle,e.shouldForceLeadingZeros,f,r,S]),w=(0,R.useMemo)(()=>Ha({},C),[C]),T=(0,R.useMemo)(()=>new Y(t,w),[t,w]),E=(0,R.useMemo)(()=>T.resolvedOptions(),[T]),D=(0,R.useMemo)(()=>Ga(e.placeholderValue,d,m,f),[e.placeholderValue,d,m,f]),O=(0,R.useMemo)(()=>{let t=h===`h11`||h===`h12`,n=[`era`,`year`,`month`,`day`,`hour`,...t?[`dayPeriod`]:[],`minute`,`second`],r=n.indexOf(e.maxGranularity||`era`),i=n.indexOf(d===`hour`&&t?`dayPeriod`:d);return n.slice(r,i+1)},[e.maxGranularity,d,h]),[k,A]=(0,R.useState)(y),[ee,te]=(0,R.useState)(m),[j,ne]=(0,R.useState)(h);(y!==k||h!==j||!mt(m,ee))&&(b=new Ya(m,h,y),A(y),te(m),ne(h),x(b));let M=t=>{if(!(e.isDisabled||e.isReadOnly)){if(t==null||t instanceof Ya&&t.isCleared(O))x(new Ya(m,h,y)),_(null);else if(!(t instanceof Ya))t=G(t,u?.calendar||new z),x(new Ya(m,h,y)),_(t);else{if(t.isComplete(O)){let e=t.toValue(y??D);if(t.validate(e,O)){let t=G(e,u?.calendar||new z);if(!g||t.compare(g)!==0){x(new Ya(m,h,y)),_(t);return}}}x(t)}}},re=(0,R.useMemo)(()=>b.toValue(y??D).toDate(p),[b,p,y,D]),N=(0,R.useMemo)(()=>ro(re,b,T,E,m,t,d),[re,T,E,b,m,t,d]),ie=(e,t)=>{M(b.cycle(e,t,D,O))},P=(0,R.useMemo)(()=>Ra(g,s,c,l,C),[g,s,c,l,C]),ae=Oe({...e,value:g,builtinValidation:P}),oe=ae.displayValidation.isInvalid,se=e.validationState||(oe?`invalid`:null);return{...ae,value:y,defaultValue:e.defaultValue??v,dateValue:re,calendar:m,setValue:M,segments:N,dateFormatter:T,validationState:se,isInvalid:oe,granularity:d,maxGranularity:e.maxGranularity??`year`,isDisabled:i,isReadOnly:a,isRequired:o,increment(e){ie(e,1)},decrement(e){ie(e,-1)},incrementPage(e){ie(e,eo[e]||1)},decrementPage(e){ie(e,-(eo[e]||1))},incrementToMax(e){let t=e===`hour`&&h===`h12`?11:b.getSegmentLimits(e).maxValue;M(b.set(e,t,D))},decrementToMin(e){let t=e===`hour`&&h===`h12`?12:b.getSegmentLimits(e).minValue;M(b.set(e,t,D))},setSegment(e,t){M(b.set(e,t,D))},confirmPlaceholder(){if(!(e.isDisabled||e.isReadOnly)&&b.isComplete(O)){let e=G(b.toValue(y??D),u?.calendar||new z);(!g||e.compare(g)!==0)&&_(e),x(new Ya(m,h,y))}},clearSegment(e){let t=b;e!==`timeZoneName`&&e!==`literal`&&(t=b.clear(e)),M(t)},formatValue(e){if(!y)return``;let n=Ha(e,C);return new Y(t,n).format(re)},getDateFormatter(e,t){return new Y(e,Ha({},{...C,...t}))}}}function ro(e,t,n,r,i,a,o){let s=[`hour`,`minute`,`second`],c=n.formatToParts(e),l=new Fe(a,{useGrouping:!1}),u=new Fe(a,{useGrouping:!1,minimumIntegerDigits:2});for(let e of c)if(e.type===`year`||e.type===`month`||e.type===`day`||e.type===`hour`){let n=t[e.type]??0;e.value=r[e.type]===`2-digit`?u.format(n):l.format(n)}let d=[];for(let e of c){let n=to[e.type]||e.type,r=$a[n];n===`era`&&i.getEras().length===1&&(r=!1);let c=$a[n]&&t[e.type]==null,l=$a[n]?Ja(n,e.value,a):null,u={type:n,text:c?l:e.value,...t.getSegmentLimits(n),isPlaceholder:c,placeholder:l,isEditable:r};n===`hour`?(d.push({type:`literal`,text:`⁦`,isPlaceholder:!1,placeholder:``,isEditable:!1}),d.push(u),n===o&&d.push({type:`literal`,text:`⁩`,isPlaceholder:!1,placeholder:``,isEditable:!1})):s.includes(n)&&n===o?(d.push(u),d.push({type:`literal`,text:`⁩`,isPlaceholder:!1,placeholder:``,isEditable:!1})):d.push(u)}return d}function io(e){let{placeholderValue:t=new Ln,minValue:n,maxValue:r,defaultValue:i,granularity:a,validate:o}=e,[s,c]=ce(e.value,i??null,e.onChange),l=s||t,u=l&&`day`in l?l:void 0,d=i&&`timeZone`in i?i.timeZone:void 0,f=(0,R.useMemo)(()=>{let e=l&&`timeZone`in l?l.timeZone:void 0;return(e||d)&&t?Yt(ao(t),e||d):ao(t)},[t,l,d]),p=(0,R.useMemo)(()=>ao(n,u),[n,u]),m=(0,R.useMemo)(()=>ao(r,u),[r,u]),h=(0,R.useMemo)(()=>s&&`day`in s?Jt(s):s,[s]),g=(0,R.useMemo)(()=>s==null?null:ao(s),[s]),_=(0,R.useMemo)(()=>i==null?null:ao(i),[i]),v=e=>{c(u||d?e:e&&Jt(e))};return{...no({...e,value:g,defaultValue:_,minValue:p,maxValue:m,onChange:v,granularity:a||`minute`,maxGranularity:`hour`,placeholderValue:f??void 0,createCalendar:()=>new z,validate:(0,R.useCallback)(()=>o?.(s),[o,s])}),timeValue:h}}function ao(e,t=yt(Tt())){return e?`day`in e?e:W(t,e):null}var oo=(0,R.createContext)(null),so=(0,R.createContext)(null),co=(0,R.createContext)(null),lo=(0,R.createContext)(null),uo=(0,R.forwardRef)(function(e,t){[e,t]=se(e,t,oo);let{validationBehavior:n}=O(ye)||{},r=e.validationBehavior??n??`native`,{locale:i}=F(),a=no({...e,locale:i,createCalendar:Kr,validationBehavior:r}),o=(0,R.useRef)(null),[s,c]=A(!e[`aria-label`]&&!e[`aria-labelledby`]),l=(0,R.useRef)(null),{labelProps:u,fieldProps:d,inputProps:f,descriptionProps:m,errorMessageProps:h,...g}=Ki({...E(e),label:c,inputRef:l,validationBehavior:r},a,o),_=k({...E(e),values:{state:a,isInvalid:a.isInvalid,isDisabled:a.isDisabled,isReadOnly:a.isReadOnly,isRequired:e.isRequired||!1},defaultClassName:`react-aria-DateField`}),v=I(e,{global:!0});return delete v.id,R.createElement(x,{values:[[co,a],[Se,{...d,ref:o,isInvalid:a.isInvalid,isDisabled:a.isDisabled}],[Ee,{...f,ref:l}],[Me,{...u,ref:s,elementType:`span`}],[p,{slots:{description:m,errorMessage:h}}],[Te,g]]},R.createElement(w.div,{...v,..._,ref:t,slot:e.slot||void 0,"data-invalid":a.isInvalid||void 0,"data-disabled":a.isDisabled||void 0,"data-readonly":a.isReadOnly||void 0,"data-required":e.isRequired||void 0}),R.createElement(ii,{autoComplete:e.autoComplete,name:e.name,isDisabled:e.isDisabled,state:a}))}),fo=(0,R.forwardRef)(function(e,t){[e,t]=se(e,t,so);let{validationBehavior:n}=O(ye)||{},r=e.validationBehavior??n??`native`,{locale:i}=F(),a=io({...e,locale:i,validationBehavior:r}),o=(0,R.useRef)(null),[s,c]=A(!e[`aria-label`]&&!e[`aria-labelledby`]),l=(0,R.useRef)(null),{labelProps:u,fieldProps:d,inputProps:f,descriptionProps:m,errorMessageProps:h,...g}=qi({...E(e),label:c,inputRef:l,validationBehavior:r},a,o),_=k({...e,values:{state:a,isInvalid:a.isInvalid,isDisabled:a.isDisabled,isReadOnly:a.isReadOnly,isRequired:e.isRequired||!1},defaultClassName:`react-aria-TimeField`}),v=I(e,{global:!0});return delete v.id,R.createElement(x,{values:[[lo,a],[Se,{...d,ref:o,isInvalid:a.isInvalid,isDisabled:a.isDisabled}],[Ee,{...f,ref:l}],[Me,{...u,ref:s,elementType:`span`}],[p,{slots:{description:m,errorMessage:h}}],[Te,g]]},R.createElement(w.div,{...v,..._,ref:t,slot:e.slot||void 0,"data-invalid":a.isInvalid||void 0,"data-disabled":a.isDisabled||void 0,"data-readonly":a.isReadOnly||void 0,"data-required":e.isRequired||void 0}))}),po=(0,R.forwardRef)(function(e,t){let n=(0,R.useContext)(co),r=(0,R.useContext)(lo);return n||r?R.createElement(ho,{...e,ref:t}):R.createElement(mo,{...e,ref:t})}),mo=(0,R.forwardRef)((e,t)=>{let[n,r]=se({slot:e.slot},t,oo),{locale:i}=F(),a=no({...n,locale:i,createCalendar:Kr}),o=(0,R.useRef)(null),{fieldProps:s,inputProps:c}=Ki({...n,inputRef:o},a,r);return R.createElement(x,{values:[[co,a],[Ee,{...c,ref:o}],[Se,{...s,ref:r,isInvalid:a.isInvalid,isDisabled:a.isDisabled}]]},R.createElement(ho,e))}),ho=(0,R.forwardRef)((e,t)=>{let{className:n,children:r}=e,i=(0,R.useContext)(co),a=(0,R.useContext)(lo),o=i??a;return R.createElement(R.Fragment,null,R.createElement(Ce,{...e,ref:t,slot:e.slot||void 0,className:n??`react-aria-DateInput`,isReadOnly:o.isReadOnly,isInvalid:o.isInvalid,isDisabled:o.isDisabled},o.segments.map((e,t)=>(0,R.cloneElement)(r(e),{key:t}))),R.createElement(ke,{className:``}))}),go=(0,R.forwardRef)(function({segment:e,...t},n){let r=(0,R.useContext)(co),i=(0,R.useContext)(lo),a=r??i,o=T(n),{segmentProps:s}=Qi(e,a,o),{focusProps:c,isFocused:l,isFocusVisible:u}=P(),{hoverProps:d,isHovered:f}=pe({...t,isDisabled:a.isDisabled||e.type===`literal`}),p=k({...t,values:{...e,isReadOnly:a.isReadOnly,isInvalid:a.isInvalid,isDisabled:a.isDisabled,isHovered:f,isFocused:l,isFocusVisible:u},defaultChildren:e.text,defaultClassName:`react-aria-DateSegment`});return R.createElement(w.span,{...D(I(t,{global:!0}),s,c,d),...p,style:s.style,ref:o,"data-placeholder":e.isPlaceholder||void 0,"data-invalid":a.isInvalid||void 0,"data-readonly":a.isReadOnly||void 0,"data-disabled":a.isDisabled||void 0,"data-type":e.type,"data-hovered":f||void 0,"data-focused":l||void 0,"data-focus-visible":u||void 0})}),_o=(0,R.createContext)({}),vo=({children:e,className:t,fullWidth:n,variant:r,...i})=>{let a=R.useMemo(()=>et({fullWidth:n,variant:r}),[n,r]);return(0,X.jsx)(_o,{value:{slots:a},children:(0,X.jsx)(Ce,{className:N(t,a?.base()),"data-slot":`date-input-group`,...i,children:t=>(0,X.jsx)(X.Fragment,{children:typeof e==`function`?e(t):e})})})},yo=({children:e,className:t,...n})=>{let{slots:r}=(0,R.use)(_o);return(0,X.jsx)(S.div,{className:L(r?.prefix,t),"data-slot":`date-input-group-prefix`,...n,children:e})},bo=({className:e,...t})=>{let{slots:n}=(0,R.use)(_o);return(0,X.jsx)(po,{className:N(e,n?.input()),"data-slot":`date-input-group-input`,...t})},xo=({className:e,segment:t,...n})=>{let{slots:r}=(0,R.use)(_o);return(0,X.jsx)(go,{className:L(r?.segment,e),"data-slot":`date-input-group-segment`,segment:t,...n})},So=({children:e,className:t,...n})=>{let{slots:r}=(0,R.use)(_o);return(0,X.jsx)(S.div,{className:L(r?.inputContainer,t),"data-slot":`date-input-group-input-container`,...n,children:e})},Co=({children:e,className:t,...n})=>{let{slots:r}=(0,R.use)(_o);return(0,X.jsx)(S.div,{className:L(r?.suffix,t),"data-slot":`date-input-group-suffix`,...n,children:e})};function wo({children:e,className:t,fullWidth:n,...r}){let i=R.useMemo(()=>Qe({fullWidth:n}),[n]);return(0,X.jsx)(uo,{"data-required":Le(r.isRequired),"data-slot":`date-field`,...r,className:N(t,i),children:t=>(0,X.jsx)(X.Fragment,{children:typeof e==`function`?e(t):e})})}var To=Object.assign(wo,{Root:wo,Group:vo,Input:bo,InputContainer:So,Segment:xo,Prefix:yo,Suffix:Co}),Eo={};Eo={dateRange:e=>`${e.startDate} \u{625}\u{644}\u{649} ${e.endDate}`,dateSelected:e=>`${e.date} \u{627}\u{644}\u{645}\u{62D}\u{62F}\u{62F}`,finishRangeSelectionPrompt:`انقر لإنهاء عملية تحديد نطاق التاريخ`,maximumDate:`آخر تاريخ متاح`,minimumDate:`أول تاريخ متاح`,next:`التالي`,previous:`السابق`,selectedDateDescription:e=>`\u{62A}\u{627}\u{631}\u{64A}\u{62E} \u{645}\u{62D}\u{62F}\u{62F}: ${e.date}`,selectedRangeDescription:e=>`\u{627}\u{644}\u{645}\u{62F}\u{649} \u{627}\u{644}\u{632}\u{645}\u{646}\u{64A} \u{627}\u{644}\u{645}\u{62D}\u{62F}\u{62F}: ${e.dateRange}`,startRangeSelectionPrompt:`انقر لبدء عملية تحديد نطاق التاريخ`,todayDate:e=>`\u{627}\u{644}\u{64A}\u{648}\u{645}\u{60C} ${e.date}`,todayDateSelected:e=>`\u{627}\u{644}\u{64A}\u{648}\u{645}\u{60C} ${e.date} \u{645}\u{62D}\u{62F}\u{62F}`};var Do={};Do={dateRange:e=>`${e.startDate} \u{434}\u{43E} ${e.endDate}`,dateSelected:e=>`\u{418}\u{437}\u{431}\u{440}\u{430}\u{43D}\u{43E} \u{435} ${e.date}`,finishRangeSelectionPrompt:`Натиснете, за да довършите избора на времеви интервал`,maximumDate:`Последна налична дата`,minimumDate:`Първа налична дата`,next:`Напред`,previous:`Назад`,selectedDateDescription:e=>`\u{418}\u{437}\u{431}\u{440}\u{430}\u{43D}\u{430} \u{434}\u{430}\u{442}\u{430}: ${e.date}`,selectedRangeDescription:e=>`\u{418}\u{437}\u{431}\u{440}\u{430}\u{43D} \u{434}\u{438}\u{430}\u{43F}\u{430}\u{437}\u{43E}\u{43D}: ${e.dateRange}`,startRangeSelectionPrompt:`Натиснете, за да пристъпите към избора на времеви интервал`,todayDate:e=>`\u{414}\u{43D}\u{435}\u{441}, ${e.date}`,todayDateSelected:e=>`\u{414}\u{43D}\u{435}\u{441}, ${e.date} \u{441}\u{430} \u{438}\u{437}\u{431}\u{440}\u{430}\u{43D}\u{438}`};var Oo={};Oo={dateRange:e=>`${e.startDate} a\u{17E} ${e.endDate}`,dateSelected:e=>`Vybr\xe1no ${e.date}`,finishRangeSelectionPrompt:`Kliknutím dokončíte výběr rozsahu dat`,maximumDate:`Poslední dostupné datum`,minimumDate:`První dostupné datum`,next:`Další`,previous:`Předchozí`,selectedDateDescription:e=>`Vybran\xe9 datum: ${e.date}`,selectedRangeDescription:e=>`Vybran\xe9 obdob\xed: ${e.dateRange}`,startRangeSelectionPrompt:`Kliknutím zahájíte výběr rozsahu dat`,todayDate:e=>`Dnes, ${e.date}`,todayDateSelected:e=>`Dnes, vybr\xe1no ${e.date}`};var ko={};ko={dateRange:e=>`${e.startDate} til ${e.endDate}`,dateSelected:e=>`${e.date} valgt`,finishRangeSelectionPrompt:`Klik for at fuldføre valg af datoområde`,maximumDate:`Sidste ledige dato`,minimumDate:`Første ledige dato`,next:`Næste`,previous:`Forrige`,selectedDateDescription:e=>`Valgt dato: ${e.date}`,selectedRangeDescription:e=>`Valgt interval: ${e.dateRange}`,startRangeSelectionPrompt:`Klik for at starte valg af datoområde`,todayDate:e=>`I dag, ${e.date}`,todayDateSelected:e=>`I dag, ${e.date} valgt`};var Ao={};Ao={dateRange:e=>`${e.startDate} bis ${e.endDate}`,dateSelected:e=>`${e.date} ausgew\xe4hlt`,finishRangeSelectionPrompt:`Klicken, um die Auswahl des Datumsbereichs zu beenden`,maximumDate:`Letztes verfügbares Datum`,minimumDate:`Erstes verfügbares Datum`,next:`Weiter`,previous:`Zurück`,selectedDateDescription:e=>`Ausgew\xe4hltes Datum: ${e.date}`,selectedRangeDescription:e=>`Ausgew\xe4hlter Bereich: ${e.dateRange}`,startRangeSelectionPrompt:`Klicken, um die Auswahl des Datumsbereichs zu beginnen`,todayDate:e=>`Heute, ${e.date}`,todayDateSelected:e=>`Heute, ${e.date} ausgew\xe4hlt`};var jo={};jo={dateRange:e=>`${e.startDate} \u{3AD}\u{3C9}\u{3C2} ${e.endDate}`,dateSelected:e=>`\u{395}\u{3C0}\u{3B9}\u{3BB}\u{3AD}\u{3C7}\u{3B8}\u{3B7}\u{3BA}\u{3B5} ${e.date}`,finishRangeSelectionPrompt:`Κάντε κλικ για να ολοκληρώσετε την επιλογή εύρους ημερομηνιών`,maximumDate:`Τελευταία διαθέσιμη ημερομηνία`,minimumDate:`Πρώτη διαθέσιμη ημερομηνία`,next:`Επόμενο`,previous:`Προηγούμενο`,selectedDateDescription:e=>`\u{395}\u{3C0}\u{3B9}\u{3BB}\u{3B5}\u{3B3}\u{3BC}\u{3AD}\u{3BD}\u{3B7} \u{3B7}\u{3BC}\u{3B5}\u{3C1}\u{3BF}\u{3BC}\u{3B7}\u{3BD}\u{3AF}\u{3B1}: ${e.date}`,selectedRangeDescription:e=>`\u{395}\u{3C0}\u{3B9}\u{3BB}\u{3B5}\u{3B3}\u{3BC}\u{3AD}\u{3BD}\u{3BF} \u{3B5}\u{3CD}\u{3C1}\u{3BF}\u{3C2}: ${e.dateRange}`,startRangeSelectionPrompt:`Κάντε κλικ για να ξεκινήσετε την επιλογή εύρους ημερομηνιών`,todayDate:e=>`\u{3A3}\u{3AE}\u{3BC}\u{3B5}\u{3C1}\u{3B1}, ${e.date}`,todayDateSelected:e=>`\u{3A3}\u{3AE}\u{3BC}\u{3B5}\u{3C1}\u{3B1}, \u{3B5}\u{3C0}\u{3B9}\u{3BB}\u{3AD}\u{3C7}\u{3C4}\u{3B7}\u{3BA}\u{3B5} ${e.date}`};var Mo={};Mo={previous:`Previous`,next:`Next`,selectedDateDescription:e=>`Selected Date: ${e.date}`,selectedRangeDescription:e=>`Selected Range: ${e.dateRange}`,todayDate:e=>`Today, ${e.date}`,todayDateSelected:e=>`Today, ${e.date} selected`,dateSelected:e=>`${e.date} selected`,startRangeSelectionPrompt:`Click to start selecting date range`,finishRangeSelectionPrompt:`Click to finish selecting date range`,minimumDate:`First available date`,maximumDate:`Last available date`,dateRange:e=>`${e.startDate} to ${e.endDate}`};var No={};No={dateRange:e=>`${e.startDate} a ${e.endDate}`,dateSelected:e=>`${e.date} seleccionado`,finishRangeSelectionPrompt:`Haga clic para terminar de seleccionar rango de fechas`,maximumDate:`Última fecha disponible`,minimumDate:`Primera fecha disponible`,next:`Siguiente`,previous:`Anterior`,selectedDateDescription:e=>`Fecha seleccionada: ${e.date}`,selectedRangeDescription:e=>`Intervalo seleccionado: ${e.dateRange}`,startRangeSelectionPrompt:`Haga clic para comenzar a seleccionar un rango de fechas`,todayDate:e=>`Hoy, ${e.date}`,todayDateSelected:e=>`Hoy, ${e.date} seleccionado`};var Po={};Po={dateRange:e=>`${e.startDate} kuni ${e.endDate}`,dateSelected:e=>`${e.date} valitud`,finishRangeSelectionPrompt:`Klõpsake kuupäevavahemiku valimise lõpetamiseks`,maximumDate:`Viimane saadaolev kuupäev`,minimumDate:`Esimene saadaolev kuupäev`,next:`Järgmine`,previous:`Eelmine`,selectedDateDescription:e=>`Valitud kuup\xe4ev: ${e.date}`,selectedRangeDescription:e=>`Valitud vahemik: ${e.dateRange}`,startRangeSelectionPrompt:`Klõpsake kuupäevavahemiku valimiseks`,todayDate:e=>`T\xe4na, ${e.date}`,todayDateSelected:e=>`T\xe4na, ${e.date} valitud`};var Fo={};Fo={dateRange:e=>`${e.startDate} \u{2013} ${e.endDate}`,dateSelected:e=>`${e.date} valittu`,finishRangeSelectionPrompt:`Lopeta päivämääräalueen valinta napsauttamalla tätä.`,maximumDate:`Viimeinen varattavissa oleva päivämäärä`,minimumDate:`Ensimmäinen varattavissa oleva päivämäärä`,next:`Seuraava`,previous:`Edellinen`,selectedDateDescription:e=>`Valittu p\xe4iv\xe4m\xe4\xe4r\xe4: ${e.date}`,selectedRangeDescription:e=>`Valittu aikav\xe4li: ${e.dateRange}`,startRangeSelectionPrompt:`Aloita päivämääräalueen valinta napsauttamalla tätä.`,todayDate:e=>`T\xe4n\xe4\xe4n, ${e.date}`,todayDateSelected:e=>`T\xe4n\xe4\xe4n, ${e.date} valittu`};var Io={};Io={dateRange:e=>`${e.startDate} \xe0 ${e.endDate}`,dateSelected:e=>`${e.date} s\xe9lectionn\xe9`,finishRangeSelectionPrompt:`Cliquer pour finir de sélectionner la plage de dates`,maximumDate:`Dernière date disponible`,minimumDate:`Première date disponible`,next:`Suivant`,previous:`Précédent`,selectedDateDescription:e=>`Date s\xe9lectionn\xe9e\xa0: ${e.date}`,selectedRangeDescription:e=>`Plage s\xe9lectionn\xe9e\xa0: ${e.dateRange}`,startRangeSelectionPrompt:`Cliquer pour commencer à sélectionner la plage de dates`,todayDate:e=>`Aujourd'hui, ${e.date}`,todayDateSelected:e=>`Aujourd\u{2019}hui, ${e.date} s\xe9lectionn\xe9`};var Lo={};Lo={dateRange:e=>`${e.startDate} \u{5E2}\u{5D3} ${e.endDate}`,dateSelected:e=>`${e.date} \u{5E0}\u{5D1}\u{5D7}\u{5E8}`,finishRangeSelectionPrompt:`חץ כדי לסיים את בחירת טווח התאריכים`,maximumDate:`תאריך פנוי אחרון`,minimumDate:`תאריך פנוי ראשון`,next:`הבא`,previous:`הקודם`,selectedDateDescription:e=>`\u{5EA}\u{5D0}\u{5E8}\u{5D9}\u{5DA} \u{5E0}\u{5D1}\u{5D7}\u{5E8}: ${e.date}`,selectedRangeDescription:e=>`\u{5D8}\u{5D5}\u{5D5}\u{5D7} \u{5E0}\u{5D1}\u{5D7}\u{5E8}: ${e.dateRange}`,startRangeSelectionPrompt:`לחץ כדי להתחיל בבחירת טווח התאריכים`,todayDate:e=>`\u{5D4}\u{5D9}\u{5D5}\u{5DD}, ${e.date}`,todayDateSelected:e=>`\u{5D4}\u{5D9}\u{5D5}\u{5DD}, ${e.date} \u{5E0}\u{5D1}\u{5D7}\u{5E8}`};var Ro={};Ro={dateRange:e=>`${e.startDate} do ${e.endDate}`,dateSelected:e=>`${e.date} odabran`,finishRangeSelectionPrompt:`Kliknite da dovršite raspon odabranih datuma`,maximumDate:`Posljednji raspoloživi datum`,minimumDate:`Prvi raspoloživi datum`,next:`Sljedeći`,previous:`Prethodni`,selectedDateDescription:e=>`Odabrani datum: ${e.date}`,selectedRangeDescription:e=>`Odabrani raspon: ${e.dateRange}`,startRangeSelectionPrompt:`Kliknite da započnete raspon odabranih datuma`,todayDate:e=>`Danas, ${e.date}`,todayDateSelected:e=>`Danas, odabran ${e.date}`};var zo={};zo={dateRange:e=>`${e.startDate}\u{2013}${e.endDate}`,dateSelected:e=>`${e.date} kiv\xe1lasztva`,finishRangeSelectionPrompt:`Kattintson a dátumtartomány kijelölésének befejezéséhez`,maximumDate:`Utolsó elérhető dátum`,minimumDate:`Az első elérhető dátum`,next:`Következő`,previous:`Előző`,selectedDateDescription:e=>`Kijel\xf6lt d\xe1tum: ${e.date}`,selectedRangeDescription:e=>`Kijel\xf6lt tartom\xe1ny: ${e.dateRange}`,startRangeSelectionPrompt:`Kattintson a dátumtartomány kijelölésének indításához`,todayDate:e=>`Ma, ${e.date}`,todayDateSelected:e=>`Ma, ${e.date} kijel\xf6lve`};var Bo={};Bo={dateRange:e=>`Da ${e.startDate} a ${e.endDate}`,dateSelected:e=>`${e.date} selezionata`,finishRangeSelectionPrompt:`Fai clic per completare la selezione dell’intervallo di date`,maximumDate:`Ultima data disponibile`,minimumDate:`Prima data disponibile`,next:`Successivo`,previous:`Precedente`,selectedDateDescription:e=>`Data selezionata: ${e.date}`,selectedRangeDescription:e=>`Intervallo selezionato: ${e.dateRange}`,startRangeSelectionPrompt:`Fai clic per selezionare l’intervallo di date`,todayDate:e=>`Oggi, ${e.date}`,todayDateSelected:e=>`Oggi, ${e.date} selezionata`};var Vo={};Vo={dateRange:e=>`${e.startDate} \u{304B}\u{3089} ${e.endDate}`,dateSelected:e=>`${e.date} \u{3092}\u{9078}\u{629E}`,finishRangeSelectionPrompt:`クリックして日付範囲の選択を終了`,maximumDate:`最終利用可能日`,minimumDate:`最初の利用可能日`,next:`次へ`,previous:`前へ`,selectedDateDescription:e=>`\u{9078}\u{629E}\u{3057}\u{305F}\u{65E5}\u{4ED8} : ${e.date}`,selectedRangeDescription:e=>`\u{9078}\u{629E}\u{7BC4}\u{56F2} : ${e.dateRange}`,startRangeSelectionPrompt:`クリックして日付範囲の選択を開始`,todayDate:e=>`\u{672C}\u{65E5}\u{3001}${e.date}`,todayDateSelected:e=>`\u{672C}\u{65E5}\u{3001}${e.date} \u{3092}\u{9078}\u{629E}`};var Ho={};Ho={dateRange:e=>`${e.startDate} ~ ${e.endDate}`,dateSelected:e=>`${e.date} \u{C120}\u{D0DD}\u{B428}`,finishRangeSelectionPrompt:`날짜 범위 선택을 완료하려면 클릭하십시오.`,maximumDate:`마지막으로 사용 가능한 일자`,minimumDate:`처음으로 사용 가능한 일자`,next:`다음`,previous:`이전`,selectedDateDescription:e=>`\u{C120}\u{D0DD} \u{C77C}\u{C790}: ${e.date}`,selectedRangeDescription:e=>`\u{C120}\u{D0DD} \u{BC94}\u{C704}: ${e.dateRange}`,startRangeSelectionPrompt:`날짜 범위 선택을 시작하려면 클릭하십시오.`,todayDate:e=>`\u{C624}\u{B298}, ${e.date}`,todayDateSelected:e=>`\u{C624}\u{B298}, ${e.date} \u{C120}\u{D0DD}\u{B428}`};var Uo={};Uo={dateRange:e=>`Nuo ${e.startDate} iki ${e.endDate}`,dateSelected:e=>`Pasirinkta ${e.date}`,finishRangeSelectionPrompt:`Spustelėkite, kad baigtumėte pasirinkti datų intervalą`,maximumDate:`Paskutinė galima data`,minimumDate:`Pirmoji galima data`,next:`Paskesnis`,previous:`Ankstesnis`,selectedDateDescription:e=>`Pasirinkta data: ${e.date}`,selectedRangeDescription:e=>`Pasirinktas intervalas: ${e.dateRange}`,startRangeSelectionPrompt:`Spustelėkite, kad pradėtumėte pasirinkti datų intervalą`,todayDate:e=>`\u{160}iandien, ${e.date}`,todayDateSelected:e=>`\u{160}iandien, pasirinkta ${e.date}`};var Wo={};Wo={dateRange:e=>`No ${e.startDate} l\u{12B}dz ${e.endDate}`,dateSelected:e=>`Atlas\u{12B}ts: ${e.date}`,finishRangeSelectionPrompt:`Noklikšķiniet, lai pabeigtu datumu diapazona atlasi`,maximumDate:`Pēdējais pieejamais datums`,minimumDate:`Pirmais pieejamais datums`,next:`Tālāk`,previous:`Atpakaļ`,selectedDateDescription:e=>`Atlas\u{12B}tais datums: ${e.date}`,selectedRangeDescription:e=>`Atlas\u{12B}tais diapazons: ${e.dateRange}`,startRangeSelectionPrompt:`Noklikšķiniet, lai sāktu datumu diapazona atlasi`,todayDate:e=>`\u{160}odien, ${e.date}`,todayDateSelected:e=>`Atlas\u{12B}ta \u{161}odiena, ${e.date}`};var Go={};Go={dateRange:e=>`${e.startDate} til ${e.endDate}`,dateSelected:e=>`${e.date} valgt`,finishRangeSelectionPrompt:`Klikk for å fullføre valg av datoområde`,maximumDate:`Siste tilgjengelige dato`,minimumDate:`Første tilgjengelige dato`,next:`Neste`,previous:`Forrige`,selectedDateDescription:e=>`Valgt dato: ${e.date}`,selectedRangeDescription:e=>`Valgt omr\xe5de: ${e.dateRange}`,startRangeSelectionPrompt:`Klikk for å starte valg av datoområde`,todayDate:e=>`I dag, ${e.date}`,todayDateSelected:e=>`I dag, ${e.date} valgt`};var Ko={};Ko={dateRange:e=>`${e.startDate} tot ${e.endDate}`,dateSelected:e=>`${e.date} geselecteerd`,finishRangeSelectionPrompt:`Klik om de selectie van het datumbereik te voltooien`,maximumDate:`Laatste beschikbare datum`,minimumDate:`Eerste beschikbare datum`,next:`Volgende`,previous:`Vorige`,selectedDateDescription:e=>`Geselecteerde datum: ${e.date}`,selectedRangeDescription:e=>`Geselecteerd bereik: ${e.dateRange}`,startRangeSelectionPrompt:`Klik om het datumbereik te selecteren`,todayDate:e=>`Vandaag, ${e.date}`,todayDateSelected:e=>`Vandaag, ${e.date} geselecteerd`};var qo={};qo={dateRange:e=>`${e.startDate} do ${e.endDate}`,dateSelected:e=>`Wybrano ${e.date}`,finishRangeSelectionPrompt:`Kliknij, aby zakończyć wybór zakresu dat`,maximumDate:`Ostatnia dostępna data`,minimumDate:`Pierwsza dostępna data`,next:`Dalej`,previous:`Wstecz`,selectedDateDescription:e=>`Wybrana data: ${e.date}`,selectedRangeDescription:e=>`Wybrany zakres: ${e.dateRange}`,startRangeSelectionPrompt:`Kliknij, aby rozpocząć wybór zakresu dat`,todayDate:e=>`Dzisiaj, ${e.date}`,todayDateSelected:e=>`Dzisiaj wybrano ${e.date}`};var Jo={};Jo={dateRange:e=>`${e.startDate} a ${e.endDate}`,dateSelected:e=>`${e.date} selecionado`,finishRangeSelectionPrompt:`Clique para concluir a seleção do intervalo de datas`,maximumDate:`Última data disponível`,minimumDate:`Primeira data disponível`,next:`Próximo`,previous:`Anterior`,selectedDateDescription:e=>`Data selecionada: ${e.date}`,selectedRangeDescription:e=>`Intervalo selecionado: ${e.dateRange}`,startRangeSelectionPrompt:`Clique para iniciar a seleção do intervalo de datas`,todayDate:e=>`Hoje, ${e.date}`,todayDateSelected:e=>`Hoje, ${e.date} selecionado`};var Yo={};Yo={dateRange:e=>`${e.startDate} a ${e.endDate}`,dateSelected:e=>`${e.date} selecionado`,finishRangeSelectionPrompt:`Clique para terminar de selecionar o intervalo de datas`,maximumDate:`Última data disponível`,minimumDate:`Primeira data disponível`,next:`Próximo`,previous:`Anterior`,selectedDateDescription:e=>`Data selecionada: ${e.date}`,selectedRangeDescription:e=>`Intervalo selecionado: ${e.dateRange}`,startRangeSelectionPrompt:`Clique para começar a selecionar o intervalo de datas`,todayDate:e=>`Hoje, ${e.date}`,todayDateSelected:e=>`Hoje, ${e.date} selecionado`};var Xo={};Xo={dateRange:e=>`De la ${e.startDate} p\xe2n\u{103} la ${e.endDate}`,dateSelected:e=>`${e.date} selectat\u{103}`,finishRangeSelectionPrompt:`Apăsaţi pentru a finaliza selecţia razei pentru dată`,maximumDate:`Ultima dată disponibilă`,minimumDate:`Prima dată disponibilă`,next:`Următorul`,previous:`Înainte`,selectedDateDescription:e=>`Dat\u{103} selectat\u{103}: ${e.date}`,selectedRangeDescription:e=>`Interval selectat: ${e.dateRange}`,startRangeSelectionPrompt:`Apăsaţi pentru a începe selecţia razei pentru dată`,todayDate:e=>`Ast\u{103}zi, ${e.date}`,todayDateSelected:e=>`Azi, ${e.date} selectat\u{103}`};var Zo={};Zo={dateRange:e=>`\u{421} ${e.startDate} \u{43F}\u{43E} ${e.endDate}`,dateSelected:e=>`\u{412}\u{44B}\u{431}\u{440}\u{430}\u{43D}\u{43E} ${e.date}`,finishRangeSelectionPrompt:`Щелкните, чтобы завершить выбор диапазона дат`,maximumDate:`Последняя доступная дата`,minimumDate:`Первая доступная дата`,next:`Далее`,previous:`Назад`,selectedDateDescription:e=>`\u{412}\u{44B}\u{431}\u{440}\u{430}\u{43D}\u{43D}\u{430}\u{44F} \u{434}\u{430}\u{442}\u{430}: ${e.date}`,selectedRangeDescription:e=>`\u{412}\u{44B}\u{431}\u{440}\u{430}\u{43D}\u{43D}\u{44B}\u{439} \u{434}\u{438}\u{430}\u{43F}\u{430}\u{437}\u{43E}\u{43D}: ${e.dateRange}`,startRangeSelectionPrompt:`Щелкните, чтобы начать выбор диапазона дат`,todayDate:e=>`\u{421}\u{435}\u{433}\u{43E}\u{434}\u{43D}\u{44F}, ${e.date}`,todayDateSelected:e=>`\u{421}\u{435}\u{433}\u{43E}\u{434}\u{43D}\u{44F}, \u{432}\u{44B}\u{431}\u{440}\u{430}\u{43D}\u{43E} ${e.date}`};var Qo={};Qo={dateRange:e=>`Od ${e.startDate} do ${e.endDate}`,dateSelected:e=>`Vybrat\xfd d\xe1tum ${e.date}`,finishRangeSelectionPrompt:`Kliknutím dokončíte výber rozsahu dátumov`,maximumDate:`Posledný dostupný dátum`,minimumDate:`Prvý dostupný dátum`,next:`Nasledujúce`,previous:`Predchádzajúce`,selectedDateDescription:e=>`Vybrat\xfd d\xe1tum: ${e.date}`,selectedRangeDescription:e=>`Vybrat\xfd rozsah: ${e.dateRange}`,startRangeSelectionPrompt:`Kliknutím spustíte výber rozsahu dátumov`,todayDate:e=>`Dnes ${e.date}`,todayDateSelected:e=>`Vybrat\xfd dne\u{161}n\xfd d\xe1tum ${e.date}`};var $o={};$o={dateRange:e=>`${e.startDate} do ${e.endDate}`,dateSelected:e=>`${e.date} izbrano`,finishRangeSelectionPrompt:`Kliknite za dokončanje izbire datumskega obsega`,maximumDate:`Zadnji razpoložljivi datum`,minimumDate:`Prvi razpoložljivi datum`,next:`Naprej`,previous:`Nazaj`,selectedDateDescription:e=>`Izbrani datum: ${e.date}`,selectedRangeDescription:e=>`Izbrano obmo\u{10D}je: ${e.dateRange}`,startRangeSelectionPrompt:`Kliknite za začetek izbire datumskega obsega`,todayDate:e=>`Danes, ${e.date}`,todayDateSelected:e=>`Danes, ${e.date} izbrano`};var es={};es={dateRange:e=>`${e.startDate} do ${e.endDate}`,dateSelected:e=>`${e.date} izabran`,finishRangeSelectionPrompt:`Kliknite da dovršite opseg izabranih datuma`,maximumDate:`Zadnji raspoloživi datum`,minimumDate:`Prvi raspoloživi datum`,next:`Sledeći`,previous:`Prethodni`,selectedDateDescription:e=>`Izabrani datum: ${e.date}`,selectedRangeDescription:e=>`Izabrani period: ${e.dateRange}`,startRangeSelectionPrompt:`Kliknite da započnete opseg izabranih datuma`,todayDate:e=>`Danas, ${e.date}`,todayDateSelected:e=>`Danas, izabran ${e.date}`};var ts={};ts={dateRange:e=>`${e.startDate} till ${e.endDate}`,dateSelected:e=>`${e.date} har valts`,finishRangeSelectionPrompt:`Klicka för att avsluta val av datumintervall`,maximumDate:`Sista tillgängliga datum`,minimumDate:`Första tillgängliga datum`,next:`Nästa`,previous:`Föregående`,selectedDateDescription:e=>`Valt datum: ${e.date}`,selectedRangeDescription:e=>`Valt intervall: ${e.dateRange}`,startRangeSelectionPrompt:`Klicka för att välja datumintervall`,todayDate:e=>`Idag, ${e.date}`,todayDateSelected:e=>`Idag, ${e.date} har valts`};var ns={};ns={dateRange:e=>`${e.startDate} - ${e.endDate}`,dateSelected:e=>`${e.date} se\xe7ildi`,finishRangeSelectionPrompt:`Tarih aralığı seçimini tamamlamak için tıklayın`,maximumDate:`Son müsait tarih`,minimumDate:`İlk müsait tarih`,next:`Sonraki`,previous:`Önceki`,selectedDateDescription:e=>`Se\xe7ilen Tarih: ${e.date}`,selectedRangeDescription:e=>`Se\xe7ilen Aral\u{131}k: ${e.dateRange}`,startRangeSelectionPrompt:`Tarih aralığı seçimini başlatmak için tıklayın`,todayDate:e=>`Bug\xfcn, ${e.date}`,todayDateSelected:e=>`Bug\xfcn, ${e.date} se\xe7ildi`};var rs={};rs={dateRange:e=>`${e.startDate} \u{2014} ${e.endDate}`,dateSelected:e=>`\u{412}\u{438}\u{431}\u{440}\u{430}\u{43D}\u{43E} ${e.date}`,finishRangeSelectionPrompt:`Натисніть, щоб завершити вибір діапазону дат`,maximumDate:`Остання доступна дата`,minimumDate:`Перша доступна дата`,next:`Наступний`,previous:`Попередній`,selectedDateDescription:e=>`\u{412}\u{438}\u{431}\u{440}\u{430}\u{43D}\u{430} \u{434}\u{430}\u{442}\u{430}: ${e.date}`,selectedRangeDescription:e=>`\u{412}\u{438}\u{431}\u{440}\u{430}\u{43D}\u{438}\u{439} \u{434}\u{456}\u{430}\u{43F}\u{430}\u{437}\u{43E}\u{43D}: ${e.dateRange}`,startRangeSelectionPrompt:`Натисніть, щоб почати вибір діапазону дат`,todayDate:e=>`\u{421}\u{44C}\u{43E}\u{433}\u{43E}\u{434}\u{43D}\u{456}, ${e.date}`,todayDateSelected:e=>`\u{421}\u{44C}\u{43E}\u{433}\u{43E}\u{434}\u{43D}\u{456}, \u{432}\u{438}\u{431}\u{440}\u{430}\u{43D}\u{43E} ${e.date}`};var is={};is={dateRange:e=>`${e.startDate} \u{81F3} ${e.endDate}`,dateSelected:e=>`\u{5DF2}\u{9009}\u{62E9} ${e.date}`,finishRangeSelectionPrompt:`单击以完成选择日期范围`,maximumDate:`最后一个可用日期`,minimumDate:`第一个可用日期`,next:`下一页`,previous:`上一页`,selectedDateDescription:e=>`\u{9009}\u{5B9A}\u{7684}\u{65E5}\u{671F}\u{FF1A}${e.date}`,selectedRangeDescription:e=>`\u{9009}\u{5B9A}\u{7684}\u{8303}\u{56F4}\u{FF1A}${e.dateRange}`,startRangeSelectionPrompt:`单击以开始选择日期范围`,todayDate:e=>`\u{4ECA}\u{5929}\u{FF0C}\u{5373} ${e.date}`,todayDateSelected:e=>`\u{5DF2}\u{9009}\u{62E9}\u{4ECA}\u{5929}\u{FF0C}\u{5373} ${e.date}`};var as={};as={dateRange:e=>`${e.startDate} \u{81F3} ${e.endDate}`,dateSelected:e=>`\u{5DF2}\u{9078}\u{53D6} ${e.date}`,finishRangeSelectionPrompt:`按一下以完成選取日期範圍`,maximumDate:`最後一個可用日期`,minimumDate:`第一個可用日期`,next:`下一頁`,previous:`上一頁`,selectedDateDescription:e=>`\u{9078}\u{5B9A}\u{7684}\u{65E5}\u{671F}\u{FF1A}${e.date}`,selectedRangeDescription:e=>`\u{9078}\u{5B9A}\u{7684}\u{7BC4}\u{570D}\u{FF1A}${e.dateRange}`,startRangeSelectionPrompt:`按一下以開始選取日期範圍`,todayDate:e=>`\u{4ECA}\u{5929}\u{FF0C}${e.date}`,todayDateSelected:e=>`\u{5DF2}\u{9078}\u{53D6}\u{4ECA}\u{5929}\u{FF0C}${e.date}`};var os={};os={"ar-AE":Eo,"bg-BG":Do,"cs-CZ":Oo,"da-DK":ko,"de-DE":Ao,"el-GR":jo,"en-US":Mo,"es-ES":No,"et-EE":Po,"fi-FI":Fo,"fr-FR":Io,"he-IL":Lo,"hr-HR":Ro,"hu-HU":zo,"it-IT":Bo,"ja-JP":Vo,"ko-KR":Ho,"lt-LT":Uo,"lv-LV":Wo,"nb-NO":Go,"nl-NL":Ko,"pl-PL":qo,"pt-BR":Jo,"pt-PT":Yo,"ro-RO":Xo,"ru-RU":Zo,"sk-SK":Qo,"sl-SI":$o,"sr-SP":es,"sv-SE":ts,"tr-TR":ns,"uk-UA":rs,"zh-CN":is,"zh-TW":as};function ss(e){return e&&e.__esModule?e.default:e}var cs=new WeakMap;function ls(e){return e?.calendar.identifier===`gregory`&&e.era===`BC`?`short`:void 0}function us(e){let t=h(ss(os),`@react-aria/calendar`),n,r;`highlightedRange`in e?{start:n,end:r}=e.highlightedRange||{}:(n=Array.isArray(e.value)?e.value[0]:e.value??void 0,r=Array.isArray(e.value)?e.value.at(-1):e.value??void 0);let i=Z({weekday:`long`,month:`long`,year:`numeric`,day:`numeric`,era:ls(n)||ls(r),timeZone:e.timeZone}),{locale:a}=F(),o=(0,R.useMemo)(()=>new Intl.ListFormat(a),[a]),s=`anchorDate`in e?e.anchorDate:null;return(0,R.useMemo)(()=>{if(!s&&n&&r){if(B(n,r)){let r=i.format(n.toDate(e.timeZone));return t.format(`selectedDateDescription`,{date:r})}if(`highlightedRange`in e){let a=fs(i,t,n,r,e.timeZone);return t.format(`selectedRangeDescription`,{dateRange:a})}if(Array.isArray(e.value)){let n=e.value.map(t=>i.format(t.toDate(e.timeZone))),r=o.format(n);return t.format(`selectedDateDescription`,{date:r})}}return``},[n,r,s,e,t,i,o])}function ds(e,t,n,r){let i=h(ss(os),`@react-aria/calendar`),a=ls(e)||ls(t),o=Z({month:`long`,year:`numeric`,era:a,calendar:e.calendar.identifier,timeZone:n}),s=Z({month:`long`,year:`numeric`,day:`numeric`,era:a,calendar:e.calendar.identifier,timeZone:n});return(0,R.useMemo)(()=>{if(B(e,Dt(e))){let a=e,s=t;if(e.calendar.getFormattableMonth&&(a=e.calendar.getFormattableMonth(e)),t.calendar.getFormattableMonth&&(s=t.calendar.getFormattableMonth(t)),B(t,Ot(e)))return o.format(a.toDate(n));if(B(t,Ot(t)))return r?fs(o,i,a,s,n):o.formatRange(a.toDate(n),s.toDate(n))}return r?fs(s,i,e,t,n):s.formatRange(e.toDate(n),t.toDate(n))},[e,t,o,s,i,n,r])}function fs(e,t,n,r,i){let a=e.formatRangeToParts(n.toDate(i),r.toDate(i)),o=-1;for(let e=0;eo&&(c+=a[e].value);return t.format(`dateRange`,{startDate:s,endDate:c})}function ps(e){return e&&e.__esModule?e.default:e}function ms(e,t){let n=h(ps(os),`@react-aria/calendar`),r=I(e),i=ds(t.visibleRange.start,t.visibleRange.end,t.timeZone,!1),a=ds(t.visibleRange.start,t.visibleRange.end,t.timeZone,!0);_e(()=>{t.isFocused||l(a)},[a]);let o=us(t);_e(()=>{o&&l(o,`polite`,4e3)},[o]);let s=ie([!!e.errorMessage,e.isInvalid,e.validationState]);cs.set(t,{ariaLabel:e[`aria-label`],ariaLabelledBy:e[`aria-labelledby`],errorMessageId:s,selectedDateDescription:o});let[c,u]=(0,R.useState)(!1),d=e.isDisabled||t.isNextVisibleRangeInvalid();d&&c&&(u(!1),t.setFocused(!0));let[f,p]=(0,R.useState)(!1),m=e.isDisabled||t.isPreviousVisibleRangeInvalid();m&&f&&(p(!1),t.setFocused(!0));let g=_({id:e.id,"aria-label":[e[`aria-label`],a].filter(Boolean).join(`, `),"aria-labelledby":e[`aria-labelledby`]});return{calendarProps:D(r,g,{role:`application`,"aria-details":e[`aria-details`]||void 0,"aria-describedby":e[`aria-describedby`]||void 0}),nextButtonProps:{onPress:()=>t.focusNextPage(),"aria-label":n.format(`next`),isDisabled:d,onFocusChange:u},prevButtonProps:{onPress:()=>t.focusPreviousPage(),"aria-label":n.format(`previous`),isDisabled:m,onFocusChange:p},errorMessageProps:{id:s},title:i}}function hs(e,t){let{startDate:n=t.visibleRange.start,endDate:r=t.visibleRange.end,firstDayOfWeek:i}=e,{direction:a}=F(),{keyboardProps:o}=he({shortcuts:{End:()=>{t.focusSectionEnd()},Home:()=>{t.focusSectionStart()},Escape:()=>(`setAnchorDate`in t&&t.setAnchorDate(null),!1)}}),{keyboardProps:s}=he({shortcuts:{Enter:()=>{t.selectFocusedDate()}," ":()=>{t.selectFocusedDate()},PageUp:()=>{t.focusPreviousSection()},"Shift+PageUp":()=>{t.focusPreviousSection(!0)},PageDown:()=>{t.focusNextSection()},"Shift+PageDown":()=>{t.focusNextSection(!0)},ArrowLeft:()=>{a===`rtl`?t.focusNextDay():t.focusPreviousDay()},ArrowUp:()=>{t.focusPreviousRow()},ArrowRight:()=>{a===`rtl`?t.focusPreviousDay():t.focusNextDay()},ArrowDown:()=>{t.focusNextRow()}},allowRepeats:!0}),c=ds(n,r,t.timeZone,!0),{ariaLabel:l,ariaLabelledBy:u}=cs.get(t),d=_({"aria-label":[l,c].filter(Boolean).join(`, `),"aria-labelledby":u}),f=Z({weekday:e.weekdayStyle||`narrow`,timeZone:t.timeZone}),{locale:p}=F(),m=(0,R.useMemo)(()=>{let e=t.visibleDuration.days&&t.visibleDuration.days<7,r=e?n:At(yt(t.timeZone),p,i),a=e?t.visibleDuration.days:7;return[...Array(a).keys()].map(e=>{let n=r.add({days:e}).toDate(t.timeZone);return f.format(n)})},[p,t.timeZone,f,i,n,t.visibleDuration.days]),h=t.getWeeksInMonth(n);return{gridProps:D(d,{role:`grid`,"aria-readonly":t.isReadOnly||void 0,"aria-disabled":t.isDisabled||void 0,"aria-multiselectable":`highlightedRange`in t||t.selectionMode===`multiple`||void 0,onFocus:()=>t.setFocused(!0),onBlur:()=>t.setFocused(!1)},o,s),headerProps:{"aria-hidden":!0},weekDays:m,weeksInMonth:h}}function gs(e){return e&&e.__esModule?e.default:e}function _s(e,t,n){let{date:r,isDisabled:i}=e,{errorMessageId:a,selectedDateDescription:o}=cs.get(t),s=h(gs(os),`@react-aria/calendar`),c=Z({weekday:`long`,day:`numeric`,month:`long`,year:`numeric`,era:ls(r),timeZone:t.timeZone}),l=t.isCellFocused(r)&&!e.isOutsideMonth;i=i||t.isCellDisabled(r)||!!e.isOutsideMonth;let u=t.isCellUnavailable(r),d=!i&&!u,f=t.isSelected(r)&&d,p=!1;t.isValueInvalid&&(`highlightedRange`in t?p=!t.anchorDate&&t.highlightedRange!=null&&r.compare(t.highlightedRange.start)>=0&&r.compare(t.highlightedRange.end)<=0:Array.isArray(t.value)?p=t.value.some(e=>B(e,r)):t.value&&(p=B(t.value,r))),p&&!i&&(f=!0),r=Ye(r,pt);let m=(0,R.useMemo)(()=>r.toDate(t.timeZone),[r,t.timeZone]),g=ht(r,t.timeZone),_=(0,R.useMemo)(()=>{let e=``;return`highlightedRange`in t&&t.value&&!t.anchorDate&&(B(r,t.value.start)||B(r,t.value.end))&&(e=o+`, `),e+=c.format(m),g?e=s.format(f?`todayDateSelected`:`todayDate`,{date:e}):f&&(e=s.format(`dateSelected`,{date:e})),t.minValue&&B(r,t.minValue)?e+=`, `+s.format(`minimumDate`):t.maxValue&&B(r,t.maxValue)&&(e+=`, `+s.format(`maximumDate`)),e},[c,m,s,f,g,r,t,o]),v=``;`anchorDate`in t&&l&&!t.isReadOnly&&d&&(v=t.anchorDate?s.format(`finishRangeSelectionPrompt`):s.format(`startRangeSelectionPrompt`));let y=Ke(v),x=(0,R.useRef)(!1),S=(0,R.useRef)(!1),C=(0,R.useRef)(void 0),{pressProps:w,isPressed:T}=ue({shouldCancelOnPointerExit:`anchorDate`in t&&!!t.anchorDate,preventFocusOnPress:!0,isDisabled:!d||t.isReadOnly,onPressStart(e){if(t.isReadOnly){t.setFocusedDate(r),t.setFocused(!0);return}if(`highlightedRange`in t&&!t.anchorDate&&(e.pointerType===`mouse`||e.pointerType===`touch`)){if(t.highlightedRange&&!p){if(B(r,t.highlightedRange.start)){t.setAnchorDate(t.highlightedRange.end),t.setFocusedDate(r),t.setFocused(!0),t.setDragging(!0),S.current=!0;return}if(B(r,t.highlightedRange.end)){t.setAnchorDate(t.highlightedRange.start),t.setFocusedDate(r),t.setFocused(!0),t.setDragging(!0),S.current=!0;return}}let n=()=>{t.setDragging(!0),C.current=void 0,t.selectDate(r),t.setFocusedDate(r),t.setFocused(!0),x.current=!0};e.pointerType===`touch`?C.current=setTimeout(n,200):n()}},onPressEnd(){S.current=!1,x.current=!1,clearTimeout(C.current),C.current=void 0},onPress(){!(`anchorDate`in t)&&!t.isReadOnly&&(t.selectDate(r),t.setFocusedDate(r),t.setFocused(!0))},onPressUp(e){t.isReadOnly||(`anchorDate`in t&&C.current&&(t.selectDate(r),t.setFocusedDate(r),t.setFocused(!0)),`anchorDate`in t&&(S.current?t.setAnchorDate(r):t.anchorDate&&!x.current?(t.selectDate(r),t.setFocusedDate(r),t.setFocused(!0)):e.pointerType===`keyboard`&&!t.anchorDate?(t.selectDate(r),t.focusNearestAvailableDate(r)):e.pointerType===`virtual`&&(t.selectDate(r),t.setFocusedDate(r),t.setFocused(!0))))}}),E;i||(E=B(r,t.focusedDate)?0:-1),(0,R.useEffect)(()=>{l&&n.current&&(M(n.current),me()!==`pointer`&&b()===n.current&&ze(n.current,{containingElement:Ve(n.current)}))},[l,n]);let O=Z({day:`numeric`,timeZone:t.timeZone,calendar:r.calendar.identifier}),k=(0,R.useMemo)(()=>O.formatToParts(m).find(e=>e.type===`day`).value,[O,m]);return{cellProps:{role:`gridcell`,"aria-disabled":!d||void 0,"aria-selected":f||void 0,"aria-invalid":p||void 0},buttonProps:D(w,{onFocus(){i||(t.setFocusedDate(r),t.setFocused(!0))},tabIndex:E,role:`button`,"aria-disabled":!d||void 0,"aria-label":_,"aria-invalid":p||void 0,"aria-describedby":[p?a:void 0,y[`aria-describedby`]].filter(Boolean).join(` `)||void 0,onPointerEnter(e){`highlightDate`in t&&(e.pointerType!==`touch`||t.isDragging)&&d&&t.highlightDate(r)},onPointerDown(e){let t=fe(e);t instanceof HTMLElement&&`releasePointerCapture`in t&&(`hasPointerCapture`in t?t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId):t.releasePointerCapture(e.pointerId))},onContextMenu(e){e.preventDefault()}}),isPressed:T,isFocused:l,isSelected:f,isDisabled:i,isUnavailable:u,isOutsideVisibleRange:r.compare(t.visibleRange.start)<0||r.compare(t.visibleRange.end)>0,isInvalid:p,formattedDate:k}}function vs(e,t){let n=Z({year:e.format?.year||`numeric`,era:e.format?.era||(t.focusedDate.calendar.identifier===`gregory`&&t.focusedDate.era===`BC`?`short`:void 0),calendar:t.focusedDate.calendar.identifier,timeZone:t.timeZone}),r=e.visibleYears||20,i=t.focusedDate.subtract({years:Math.floor(r/2)}),a=t.focusedDate.add({years:Math.ceil(r/2)-1});t.maxValue&&a.compare(t.maxValue)>0&&(a=U(t.maxValue),i=a.subtract({years:r-1})),t.minValue&&i.compare(t.minValue)<0&&(i=U(t.minValue),a=i.add({years:r-1}),t.maxValue&&a.compare(t.maxValue)>0&&(a=U(t.maxValue)));let o=[],s=i,c=0;for(;s.compare(a)<=0;)ft(s,t.focusedDate)&&(c=o.length),o.push({id:o.length,date:s,formatted:n.format(s.toDate(t.timeZone))}),s=s.add({years:1});let{locale:l}=F();return{"aria-label":(0,R.useMemo)(()=>new Intl.DisplayNames(l,{type:`dateTimeField`}).of(`year`),[l]),value:c,onChange:e=>{e!=null&&t.setFocusedDate(o[e].date)},items:o}}function ys(e,t){let n=(0,R.useMemo)(()=>{let n=t.visibleRange.start;return e.offset&&(n=n.add(e.offset)),n},[t.visibleRange.start,e.offset]),r=t.visibleDuration.days||t.visibleDuration.weeks,i=Z({day:e.format?.day||(r?`numeric`:void 0),month:e.format?.month||`long`,year:e.format?.year||`numeric`,era:e.format?.era||n&&n.calendar.identifier===`gregory`&&n.era===`BC`?`short`:void 0,calendar:t.visibleRange?.start.calendar.identifier,timeZone:t.timeZone});return(0,R.useMemo)(()=>{if(r)return i.formatRange(n.toDate(t.timeZone),t.visibleRange.end.toDate(t.timeZone));let e=n.calendar.getFormattableMonth?n.calendar.getFormattableMonth(n):n;return i.format(e.toDate(t.timeZone))},[i,r,n,t.timeZone,t.visibleRange.end])}function bs(e,t,n){let{commitBehavior:r=`select`,...i}=e,a=ms(i,t),o=(0,R.useRef)(!1),s=(0,R.useRef)(typeof window<`u`?window:null);g(s,`pointerdown`,e=>{o.current=e.width===0&&e.height===0});let c={clear:()=>t.clearSelection(),reset:()=>t.setAnchorDate(null),select:()=>t.commitSelection()};return g(s,`pointerup`,e=>{if(o.current){o.current=!1;return}if(t.setDragging(!1),!t.anchorDate)return;let i=e.target;n.current&&ee(n.current)&&(!ne(n.current,i)||!i.closest(`button, [role="button"]`))&&c[r]()}),a.calendarProps.onBlur=e=>{n.current&&(!e.relatedTarget||!ne(n.current,e.relatedTarget))&&t.anchorDate&&c[r]()},g(n,`touchmove`,e=>{t.isDragging&&e.preventDefault()},{passive:!1,capture:!0}),a}function xs(e,t,n){return t!=null&&e.compare(t)<0||n!=null&&e.compare(n)>0}function Ss(e,t,n,r,i){let a={};for(let e in t)a[e]=Math.floor(t[e]/2),a[e]>0&&t[e]%2==0&&a[e]--;return Ts(e,Cs(e,t,n).subtract(a),t,n,r,i)}function Cs(e,t,n,r,i){let a=e;return t.years?a=kt(e):t.months?a=Dt(e):(t.weeks||t.days&&t.days>7)&&(a=At(e,n)),Ts(e,a,t,n,r,i)}function ws(e,t,n,r,i){let a={...t};return a.days?a.days--:a.weeks?a.weeks--:a.months?a.months--:a.years&&a.years--,Ts(e,Cs(e,t,n).subtract(a),t,n,r,i)}function Ts(e,t,n,r,i,a){if(i&&e.compare(i)>=0){let e=Rt(t,Cs(U(i),n,r));e&&(t=e)}if(a&&e.compare(a)<=0){let e=Lt(t,ws(U(a),n,r));e&&(t=e)}return t}function Es(e,t,n){if(t){let n=Rt(e,U(t));n&&(e=n)}if(n){let t=Lt(e,U(n));t&&(e=t)}return e}function Ds(e,t,n){if(!n)return e;for(;e.compare(t)>=0&&n(e);)e=e.subtract({days:1});return e.compare(t)>=0?e:null}function Os(e,t){return e===t||e.days===t.days&&e.weeks===t.weeks&&e.months===t.months&&e.years===t.years}function ks(e){let t=(0,R.useMemo)(()=>new Y(e.locale),[e.locale]),n=(0,R.useMemo)(()=>t.resolvedOptions(),[t]),{locale:r,createCalendar:i,visibleDuration:a={months:1},minValue:o,maxValue:s,selectionAlignment:c,isDateUnavailable:l,pageBehavior:u=`visible`,selectionMode:d=`single`,firstDayOfWeek:f,weeksInMonth:p}=e,m=(0,R.useMemo)(()=>i(n.calendar),[i,n.calendar]),[h,g]=ce(e.value,e.defaultValue??null,e.onChange),_=(0,R.useMemo)(()=>Array.isArray(h)?h.map(e=>G(U(e),m)):h?G(U(h),m):null,[h,m]),v=(0,R.useMemo)(()=>{let e=Array.isArray(h)?h[0]:h;return e&&`timeZone`in e?e.timeZone:n.timeZone},[h,n.timeZone]),y=(0,R.useMemo)(()=>e.focusedValue?Es(G(U(e.focusedValue),m),o,s):void 0,[e.focusedValue,m,o,s]),b=(0,R.useMemo)(()=>e.defaultFocusedValue?Es(G(U(e.defaultFocusedValue),m),o,s):Es(_?Array.isArray(_)?_[0]:_:G(yt(v),m),o,s),[e.defaultFocusedValue,_,v,m,o,s]),[x,S]=ce(y,b,e.onFocusChange),C=()=>{switch(c){case`start`:return Cs(x,a,r,o,s);case`end`:return ws(x,a,r,o,s);default:return Ss(x,a,r,o,s)}},[w,T]=(0,R.useState)(C),[E,D]=(0,R.useState)(e.autoFocus||!1),[O,k]=(0,R.useState)(a);Os(a,O)||(k(a),T(C()));let A=(0,R.useMemo)(()=>{let e={...a};return e.days?e.days--:e.days=-1,w.add(e)},[w,a]),[ee,te]=(0,R.useState)(m);if(!mt(m,ee)){let e=G(x,m);T(Ss(e,a,r,o,s)),S(e),te(m)}xs(x,o,s)?S(Es(x,o,s)):x.compare(w)<0?T(ws(x,a,r,o,s)):x.compare(A)>0&&T(Cs(x,a,r,o,s));function j(e){e=Es(e,o,s),S(e)}function ne(e){let t=Ds(Es(e,o,s),w,l);if(!t)return null;let n=Array.isArray(h)?h[0]:h,r=G(t,n?.calendar||new z);return n&&`hour`in n?n.set(r):r}function M(t){if(!e.isDisabled&&!e.isReadOnly){if(t===null){g(d===`multiple`?[]:null);return}if(Array.isArray(t))g(t.map(ne).filter(Boolean));else{let e=ne(t);e&&g(e)}}}let re=(0,R.useMemo)(()=>_?Array.isArray(_)?_.some(e=>l?.(e)||xs(e,o,s)):l?.(_)||xs(_,o,s):!1,[_,l,o,s]),N=e.isInvalid||e.validationState===`invalid`||re,ie=N?`invalid`:null,P=(0,R.useMemo)(()=>u===`visible`?a:As(a),[u,a]);return{isDisabled:e.isDisabled??!1,isReadOnly:e.isReadOnly??!1,value:_,setValue:M,selectionMode:d,visibleDuration:a,visibleRange:{start:w,end:A},minValue:o,maxValue:s,focusedDate:x,timeZone:v,validationState:ie,isValueInvalid:N,setFocusedDate(e){j(e)},focusNextDay(){j(x.add({days:1}))},focusPreviousDay(){j(x.subtract({days:1}))},focusNextRow(){a.days?this.focusNextPage():(a.weeks||a.months||a.years)&&j(x.add({weeks:1}))},focusPreviousRow(){a.days?this.focusPreviousPage():(a.weeks||a.months||a.years)&&j(x.subtract({weeks:1}))},focusNextPage(){let e=w.add(P);S(Es(x.add(P),o,s)),T(Cs(Ts(x,e,P,r,o,s),P,r))},focusPreviousPage(){let e=w.subtract(P);S(Es(x.subtract(P),o,s)),T(Cs(Ts(x,e,P,r,o,s),P,r))},focusSectionStart(){a.days?j(w):a.weeks?j(At(x,r)):(a.months||a.years)&&j(Dt(x))},focusSectionEnd(){a.days?j(A):a.weeks?j(jt(x,r)):(a.months||a.years)&&j(Ot(x))},focusNextSection(e){if(!e&&!a.days){j(x.add(As(a)));return}a.days?this.focusNextPage():a.weeks?j(x.add({months:1})):(a.months||a.years)&&j(x.add({years:1}))},focusPreviousSection(e){if(!e&&!a.days){j(x.subtract(As(a)));return}a.days?this.focusPreviousPage():a.weeks?j(x.subtract({months:1})):(a.months||a.years)&&j(x.subtract({years:1}))},selectFocusedDate(){l&&l(x)||this.selectDate(x)},selectDate(t){if(!(e.isDisabled||e.isReadOnly)){if(d===`multiple`&&t!=null){let e=ne(t);if(!e)return;let n=[];Array.isArray(h)?n=h:h!=null&&(n=[h]);let r=n.findIndex(t=>B(t,e)),i=r>=0?n.slice(0,r).concat(n.slice(r+1)):[...n,e];g(i)}else M(t)}},isFocused:E,setFocused:D,isInvalid(e){return xs(e,o,s)},isSelected(e){return!_||this.isCellDisabled(e)||this.isCellUnavailable(e)?!1:Array.isArray(_)?_.some(t=>B(t,e)):B(e,_)},isCellFocused(e){return E&&x&&B(e,x)},isCellDisabled(t){return e.isDisabled||t.compare(w)<0||t.compare(A)>0||this.isInvalid(t)},isCellUnavailable(t){return e.isDateUnavailable?e.isDateUnavailable(t):!1},isPreviousVisibleRangeInvalid(){let e=w.subtract({days:1});return B(e,w)||this.isInvalid(e)},isNextVisibleRangeInvalid(){let e=A.add({days:1});return B(e,A)||this.isInvalid(e)},getDatesInWeek(e,t=w){let n=t.add({weeks:e}),i=[],o=a.days&&a.days<7?a.days:7;if(o===7){n=At(n,r,f);let e=_t(n,r,f);for(let t=0;t0&&(m=`start`)}let h=(0,R.useMemo)(()=>{let t=e.isDateUnavailable;if(t)return e=>t(e,f)},[e.isDateUnavailable,f]),g=(0,R.useCallback)(t=>t&&h&&!e.allowsNonContiguousRanges?{start:Ps(t,h,o,-1),end:Ps(t,h,o,1)}:null,[h,o,e.allowsNonContiguousRanges]),_=(0,R.useMemo)(()=>g(f),[g,f]),v=(0,R.useMemo)(()=>Rt(s,_?.start),[s,_]),y=(0,R.useMemo)(()=>Lt(c,_?.end),[c,_]),b=ks({...l,value:u&&u.start,createCalendar:i,locale:a,visibleDuration:o,minValue:v,maxValue:y,selectionAlignment:e.selectionAlignment||m,isDateUnavailable:h}),x=f?Ms(f,b.focusedDate):u&&Ms(u.start,u.end),S=t=>{if(e.isReadOnly)return;let n=Ds(Es(t,v,y),b.visibleRange.start,h);if(n){if(!f)p(n);else{let e=Ms(f,n);e&&d({start:Ns(e.start,u?.start),end:Ns(e.end,u?.end)}),p(null)}}},[C,w]=(0,R.useState)(!1),T=(0,R.useMemo)(()=>!u||f?!1:h&&(h(u.start)||h(u.end))?!0:xs(u.start,s,c)||xs(u.end,s,c),[h,u,f,s,c]),E=e.isInvalid||e.validationState===`invalid`||T,D=E?`invalid`:null;return{...b,value:u,setValue:d,anchorDate:f,setAnchorDate:p,highlightedRange:x,validationState:D,isValueInvalid:E,selectFocusedDate(){b.isCellUnavailable(b.focusedDate)||S(b.focusedDate)},commitSelection(){S(b.focusedDate)},selectDate:S,highlightDate(e){f&&b.setFocusedDate(e)},isSelected(e){return!!(x&&e.compare(x.start)>=0&&e.compare(x.end)<=0&&!b.isCellDisabled(e)&&!b.isCellUnavailable(e))},isInvalid(e){return b.isInvalid(e)||xs(e,_?.start,_?.end)},isDragging:C,setDragging:w,clearSelection(){p(null),d(null)},focusNearestAvailableDate(e){let t=g(e),n=e=>this.isInvalid(e)||xs(e,t?.start,t?.end),r=e.add({days:1});n(r)&&(r=e.subtract({days:1})),n(r)||(this.setFocusedDate(r),this.setFocused(!0))}}}function Ms(e,t){return!e||!t?null:(t.compare(e)<0&&([e,t]=[t,e]),{start:U(e),end:U(t)})}function Ns(e,t){return e=G(e,t?.calendar||new z),t&&`hour`in t?t.set(e):e}function Ps(e,t,n,r){let i=e.add({days:r}),a=e.subtract(n),o=e.add(n);for(;(r<0?i.compare(a)>=0:i.compare(o)<=0)&&!t(i);)i=i.add({days:r});if(t(i))return i.add({days:-r})}var Fs=(0,R.createContext)(null),Is=(0,R.createContext)(null),Ls=(0,R.createContext)(null),Rs=(0,R.createContext)(null),zs=(0,R.forwardRef)(function(e,t){[e,t]=se(e,t,Is);let{locale:n}=F(),r=js({...e,locale:n,createCalendar:e.createCalendar||Kr}),{calendarProps:i,prevButtonProps:o,nextButtonProps:s,errorMessageProps:c,title:l}=bs(e,r,t),u=k({...e,values:{state:r,isDisabled:e.isDisabled||!1,isInvalid:r.isValueInvalid},defaultClassName:`react-aria-RangeCalendar`}),f=I(e,{global:!0});return R.createElement(w.div,{...D(u,f,i),ref:t,slot:e.slot||void 0,"data-disabled":e.isDisabled||void 0,"data-invalid":r.isValueInvalid||void 0},R.createElement(x,{values:[[d,{slots:{previous:o,next:s}}],[Be,{"aria-hidden":!0,level:2,children:l}],[Rs,r],[Is,e],[p,{slots:{errorMessage:c}}]]},R.createElement(a,null,R.createElement(`h2`,null,i[`aria-label`])),u.children,R.createElement(a,null,R.createElement(`button`,{"aria-label":s[`aria-label`],disabled:s.isDisabled,onClick:()=>r.focusNextPage(),tabIndex:-1}))))}),Bs=(0,R.createContext)(null),Vs=(0,R.forwardRef)(function(e,t){let n=(0,R.useContext)(Ls),r=(0,R.useContext)(Rs),i=O(Fs),a=O(Is),o=n??r,s=o.visibleRange.start;e.offset&&(s=s.add(e.offset));let c=i?.firstDayOfWeek??a?.firstDayOfWeek,{gridProps:l,headerProps:u,weekDays:d,weeksInMonth:f}=hs({startDate:s,endDate:Ot(s),weekdayStyle:e.weekdayStyle,firstDayOfWeek:c},o),p=I(e,{global:!0});return R.createElement(Bs.Provider,{value:{headerProps:u,weekDays:d,startDate:s,weeksInMonth:f}},R.createElement(w.table,{render:e.render,...D(p,l),ref:t,style:e.style,cellPadding:0,className:e.className??`react-aria-CalendarGrid`},typeof e.children==`function`?R.createElement(R.Fragment,null,R.createElement(Us,null,e=>R.createElement(Gs,null,e)),R.createElement(qs,null,e.children)):e.children))});function Hs(e,t){let{children:n,style:r,className:i}=e,{headerProps:a,weekDays:o}=(0,R.useContext)(Bs),s=I(e,{global:!0});return R.createElement(w.thead,{render:e.render,...D(s,a),ref:t,style:r,className:i??`react-aria-CalendarGridHeader`},R.createElement(`tr`,null,o.map((e,t)=>R.cloneElement(n(e),{key:t}))))}var Us=(0,R.forwardRef)(Hs);function Ws(e,t){let{children:n,style:r,className:i}=e,a=I(e,{global:!0});return R.createElement(w.th,{render:e.render,...a,ref:t,style:r,className:i||`react-aria-CalendarHeaderCell`},n)}var Gs=(0,R.forwardRef)(Ws);function Ks(e,t){let{children:n,style:r,className:i}=e,a=(0,R.useContext)(Ls),o=(0,R.useContext)(Rs),s=a??o,{startDate:c,weeksInMonth:l}=(0,R.useContext)(Bs),u=I(e,{global:!0});return R.createElement(w.tbody,{render:e.render,...u,ref:t,style:r,className:i??`react-aria-CalendarGridBody`},[...Array(l).keys()].map(e=>R.createElement(`tr`,{key:e},s.getDatesInWeek(e,c).map((e,t)=>e?R.cloneElement(n(e),{key:t}):R.createElement(`td`,{key:t})))))}var qs=(0,R.forwardRef)(Ks),Js=(0,R.forwardRef)(function({date:e,...t},n){let r=(0,R.useContext)(Ls),i=(0,R.useContext)(Rs),a=r??i,{startDate:o}=(0,R.useContext)(Bs)??{startDate:a.visibleRange.start},s=a.visibleDuration.days||a.visibleDuration.weeks?!1:!dt(o,e),c=ht(e,a.timeZone),l=(0,R.useRef)(null),{cellProps:u,buttonProps:d,...f}=_s({date:e,isOutsideMonth:s},a,l),{hoverProps:p,isHovered:m}=pe({...t,isDisabled:f.isDisabled||f.isUnavailable}),{focusProps:h,isFocusVisible:g}=P();g&&=f.isFocused;let _=!1,v=!1;`highlightedRange`in a&&a.highlightedRange&&(_=B(e,a.highlightedRange.start),v=B(e,a.highlightedRange.end));let y=k({...t,defaultChildren:f.formattedDate,defaultClassName:`react-aria-CalendarCell`,values:{date:e,isHovered:m,isOutsideMonth:s,isFocusVisible:g,isSelectionStart:_,isSelectionEnd:v,isToday:c,...f}}),b={"data-focused":f.isFocused||void 0,"data-hovered":m||void 0,"data-pressed":f.isPressed||void 0,"data-unavailable":f.isUnavailable||void 0,"data-disabled":f.isDisabled||void 0,"data-focus-visible":g||void 0,"data-outside-visible-range":f.isOutsideVisibleRange||void 0,"data-outside-month":s||void 0,"data-selected":f.isSelected||void 0,"data-selection-start":_||void 0,"data-selection-end":v||void 0,"data-invalid":f.isInvalid||void 0,"data-today":c||void 0},x=I(t,{global:!0});return R.createElement(`td`,{...u,ref:n},R.createElement(w.div,{...D(x,d,h,p,b,y),ref:l}))}),Ys=(0,R.forwardRef)(function(e,t){let{offset:n,format:r,className:i=`react-aria-CalendarHeading`,...a}=e,o=R.useContext(Ls),s=R.useContext(Rs),c=ys({offset:n,format:r},o||s);return R.createElement(qe,{...a,className:i,ref:t},c)});function Xs(e){return e&&e.__esModule?e.default:e}function Zs(e,t,n){let r=h(Xs(zi),`@react-aria/datepicker`),{isInvalid:i,validationErrors:a,validationDetails:o}=t.displayValidation,{labelProps:s,fieldProps:c,descriptionProps:l,errorMessageProps:u}=De({...e,labelElementType:`span`,isInvalid:i,errorMessage:e.errorMessage||a}),d=c[`aria-labelledby`]||c.id,{locale:f}=F(),p=t.formatValue(f,{month:`long`}),m=p?r.format(`selectedRangeDescription`,{startDate:p.start,endDate:p.end}):``,g=Ke(m),_={"aria-label":r.format(`startDate`),"aria-labelledby":d},v={"aria-label":r.format(`endDate`),"aria-labelledby":d},y=le(),b=le(),x=Bi(t,n),S=[g[`aria-describedby`],c[`aria-describedby`]].filter(Boolean).join(` `)||void 0,C=(0,R.useMemo)(()=>de(n,{accept:e=>e.id!==y}),[n,y]),w={[Gi]:C,[Wi]:`presentation`,"aria-describedby":S,placeholderValue:e.placeholderValue,hideTimeZone:e.hideTimeZone,hourCycle:e.hourCycle,granularity:e.granularity,shouldForceLeadingZeros:e.shouldForceLeadingZeros,isDisabled:e.isDisabled,isReadOnly:e.isReadOnly,isRequired:e.isRequired,validationBehavior:e.validationBehavior},T=I(e),E=(0,R.useRef)(!1),{focusWithinProps:O}=oe({...e,isDisabled:t.isOpen,onBlurWithin:t=>{let n=document.getElementById(b);ne(n,t.relatedTarget)||(E.current=!1,e.onBlur?.(t),e.onFocusChange?.(!1))},onFocusWithin:t=>{E.current||(E.current=!0,e.onFocus?.(t),e.onFocusChange?.(!0))}}),k=(0,R.useRef)(xe),A=(0,R.useRef)(xe);return{groupProps:D(T,x,c,g,O,{role:`group`,"aria-disabled":e.isDisabled||null,"aria-describedby":S,onKeyDown(n){t.isOpen||e.onKeyDown&&e.onKeyDown(n)},onKeyUp(n){t.isOpen||e.onKeyUp&&e.onKeyUp(n)}}),labelProps:{...s,onClick:()=>{C.focusFirst()}},buttonProps:{...g,id:y,"aria-haspopup":`dialog`,"aria-label":r.format(`calendar`),"aria-labelledby":`${y} ${d}`,"aria-describedby":S,"aria-expanded":t.isOpen,isDisabled:e.isDisabled||e.isReadOnly,onPress:()=>t.setOpen(!0)},dialogProps:{id:b,"aria-labelledby":`${y} ${d}`},startFieldProps:{..._,...w,value:t.value?.start??null,defaultValue:t.defaultValue?.start,onChange:e=>t.setDateTime(`start`,e),autoFocus:e.autoFocus,name:e.startName,form:e.form,[je]:{realtimeValidation:t.realtimeValidation,displayValidation:t.displayValidation,updateValidation(e){k.current=e,t.updateValidation(we(e,A.current))},resetValidation:t.resetValidation,commitValidation:t.commitValidation}},endFieldProps:{...v,...w,value:t.value?.end??null,defaultValue:t.defaultValue?.end,onChange:e=>t.setDateTime(`end`,e),name:e.endName,form:e.form,[je]:{realtimeValidation:t.realtimeValidation,displayValidation:t.displayValidation,updateValidation(e){A.current=e,t.updateValidation(we(k.current,e))},resetValidation:t.resetValidation,commitValidation:t.commitValidation}},descriptionProps:l,errorMessageProps:u,calendarProps:{autoFocus:!0,value:t.dateRange?.start&&t.dateRange.end?t.dateRange:null,onChange:t.setDateRange,minValue:e.minValue,maxValue:e.maxValue,isDisabled:e.isDisabled,isReadOnly:e.isReadOnly,isDateUnavailable:e.isDateUnavailable,allowsNonContiguousRanges:e.allowsNonContiguousRanges,defaultFocusedValue:t.dateRange?void 0:e.placeholderValue,isInvalid:t.isInvalid,errorMessage:typeof e.errorMessage==`function`?e.errorMessage(t.displayValidation):e.errorMessage||t.displayValidation.validationErrors.join(` `),firstDayOfWeek:e.firstDayOfWeek,pageBehavior:e.pageBehavior},isInvalid:i,validationErrors:a,validationDetails:o}}function Qs(e){let t=v(e),[n,r]=ce(e.value,e.defaultValue||null,e.onChange),[i]=(0,R.useState)(n),[a,o]=(0,R.useState)(()=>n||{start:null,end:null});n==null&&a.start&&a.end&&(a={start:null,end:null},o(a));let s=n||a,c=e=>{s=e||{start:null,end:null},o(s),$s(s)?r(s):r(null)},[l,u]=Ka(s?.start||s?.end||e.placeholderValue||null,e.granularity),d=l===`hour`||l===`minute`||l===`second`,f=e.shouldCloseOnSelect??!0,[p,m]=(0,R.useState)(null),[h,g]=(0,R.useState)(null);s&&$s(s)&&(p=s,`hour`in s.start&&(h=s));let _=(e,t)=>{c({start:`timeZone`in t.start?t.start.set(U(e.start)):W(e.start,t.start),end:`timeZone`in t.end?t.end.set(U(e.end)):W(e.end,t.end)}),m(null),g(null),D.commitValidation()},y=n=>{let r=typeof f==`function`?f():f;d?$s(n)&&(r||h?.start&&h?.end)?_(n,{start:h?.start||Ua(e.placeholderValue),end:h?.end||Ua(e.placeholderValue)}):m(n):$s(n)?(c(n),D.commitValidation()):m(n),r&&t.setOpen(!1)},b=e=>{$s(p)&&$s(e)?_(p,e):g(e)},x=s?.start?.calendar.identifier===`gregory`&&s.start.era===`BC`||s?.end?.calendar.identifier===`gregory`&&s.end.era===`BC`,S=(0,R.useMemo)(()=>({granularity:l,timeZone:u,hideTimeZone:e.hideTimeZone,hourCycle:e.hourCycle,shouldForceLeadingZeros:e.shouldForceLeadingZeros,showEra:x}),[l,e.hourCycle,e.shouldForceLeadingZeros,u,e.hideTimeZone,x]),{minValue:C,maxValue:w,isDateUnavailable:T}=e,E=(0,R.useMemo)(()=>za(s,C,w,T?e=>T(e,null):void 0,S),[s,C,w,T,S]),D=Oe({...e,value:n,name:(0,R.useMemo)(()=>[e.startName,e.endName].filter(e=>e!=null),[e.startName,e.endName]),builtinValidation:E}),O=D.displayValidation.isInvalid,k=e.validationState||(O?`invalid`:null);return{...D,value:s,defaultValue:e.defaultValue??i,setValue:c,dateRange:p,timeRange:h,granularity:l,hasTime:d,setDate(e,t){y(e===`start`?{start:t,end:p?.end??null}:{start:p?.start??null,end:t})},setTime(e,t){b(e===`start`?{start:t,end:h?.end??null}:{start:h?.start??null,end:t})},setDateTime(e,t){c(e===`start`?{start:t,end:s?.end??null}:{start:s?.start??null,end:t})},setDateRange:y,setTimeRange:b,...t,setOpen(n){!n&&!(s?.start&&s?.end)&&$s(p)&&d&&_(p,{start:h?.start||Ua(e.placeholderValue),end:h?.end||Ua(e.placeholderValue)}),t.setOpen(n)},validationState:k,isInvalid:O,formatValue(t,n){if(!s||!s.start||!s.end)return null;let r=`timeZone`in s.start?s.start.timeZone:void 0,i=e.granularity||(s.start&&`minute`in s.start?`minute`:`day`),a=`timeZone`in s.end?s.end.timeZone:void 0,o=e.granularity||(s.end&&`minute`in s.end?`minute`:`day`),c=Ha(n,{granularity:i,timeZone:r,hideTimeZone:e.hideTimeZone,hourCycle:e.hourCycle,showEra:s.start.calendar.identifier===`gregory`&&s.start.era===`BC`||s.end.calendar.identifier===`gregory`&&s.end.era===`BC`}),l=s.start.toDate(r||`UTC`),u=s.end.toDate(a||`UTC`),d=new Y(t,c),f;if(r===a&&i===o&&s.start.compare(s.end)!==0){try{let e=d.formatRangeToParts(l,u),t=-1;for(let n=0;nt&&(r+=e[i].value);return{start:n,end:r}}catch{}f=d}else f=new Y(t,Ha(n,{granularity:o,timeZone:a,hideTimeZone:e.hideTimeZone,hourCycle:e.hourCycle}));return{start:d.format(l),end:f.format(u)}},getDateFormatter(e,t){return new Y(e,Ha({},{...S,...t}))}}}function $s(e){return e?.start!=null&&e.end!=null}var ec=(0,R.createContext)(null),tc=(0,R.createContext)(null),nc=[Se,d,Me,p],rc=(0,R.forwardRef)(function(e,t){[e,t]=se(e,t,ec);let{validationBehavior:n}=O(ye)||{},r=e.validationBehavior??n??`native`,i=Qs({...e,validationBehavior:r}),a=(0,R.useRef)(null),[o,s]=A(!e[`aria-label`]&&!e[`aria-labelledby`]),{groupProps:c,labelProps:l,startFieldProps:u,endFieldProps:f,buttonProps:m,dialogProps:h,calendarProps:g,descriptionProps:_,errorMessageProps:v,...y}=Zs({...E(e),label:s,validationBehavior:r},i,a),{focusProps:b,isFocused:S,isFocusVisible:C}=P({within:!0}),T=k({...e,values:{state:i,isFocusWithin:S,isFocusVisible:C,isDisabled:e.isDisabled||!1,isInvalid:i.isInvalid,isOpen:i.isOpen,isReadOnly:e.isReadOnly||!1,isRequired:e.isRequired||!1},defaultClassName:`react-aria-DateRangePicker`}),ee=I(e,{global:!0});return delete ee.id,R.createElement(x,{values:[[tc,i],[Se,{...c,ref:a,isInvalid:i.isInvalid}],[d,{...m,isPressed:i.isOpen}],[Me,{...l,ref:o,elementType:`span`}],[Is,g],[Ue,i],[We,{trigger:`DateRangePicker`,triggerRef:a,placement:`bottom start`,clearContexts:nc}],[He,h],[oo,{slots:{start:u,end:f}}],[p,{slots:{description:_,errorMessage:v}}],[Te,y]]},R.createElement(w.div,{...D(ee,T,b),ref:t,slot:e.slot||void 0,"data-focus-within":S||void 0,"data-invalid":i.isInvalid||void 0,"data-focus-visible":C||void 0,"data-disabled":e.isDisabled||void 0,"data-readonly":e.isReadOnly||void 0,"data-required":e.isRequired||void 0,"data-open":i.isOpen||void 0}))}),ic=(0,R.createContext)({triggerRef:{current:null}}),ac=({children:e,className:t,onOpenChange:n,...r})=>{let i=R.useMemo(()=>$e(),[]),a=(0,R.useRef)(null),[o,s]=R.useState(!1),c=(0,R.useRef)(!1);(0,R.useEffect)(()=>{if(!o)return;let e=e=>{!e.metaKey&&!e.ctrlKey&&!e.altKey&&(c.current=!0)};return window.addEventListener(`keydown`,e,!0),()=>{window.removeEventListener(`keydown`,e,!0)}},[o]);let l=e=>{s(e),!e&&c.current&&window.requestAnimationFrame(()=>{a.current?.focus()}),c.current=!1,n?.(e)};return(0,X.jsx)(ic,{value:{slots:i,triggerRef:a},children:(0,X.jsx)(rc,{"data-required":Le(r.isRequired),"data-slot":`date-range-picker`,...r,className:N(t,i?.base()),onOpenChange:l,children:t=>(0,X.jsx)(X.Fragment,{children:typeof e==`function`?e(t):e})})})};ac.displayName=`HeroUI.DateRangePicker`;var oc=({children:e,className:t,ref:n,...r})=>{let{slots:i,triggerRef:a}=(0,R.use)(ic),o=R.useCallback(e=>{a.current=e},[a]),s=j(o,n);return(0,X.jsx)(f,{ref:s,className:N(t,i?.trigger()),"data-slot":`date-range-picker-trigger`,...r,children:t=>(0,X.jsx)(X.Fragment,{children:typeof e==`function`?e(t):e})})};oc.displayName=`HeroUI.DateRangePicker.Trigger`;var sc=({children:e,className:t,...n})=>{let{slots:r}=(0,R.use)(ic);return(0,X.jsx)(S.span,{"aria-hidden":`true`,className:L(r?.triggerIndicator,t),"data-slot":`date-range-picker-trigger-indicator`,...n,children:e||(0,X.jsx)(y,{})})};sc.displayName=`HeroUI.DateRangePicker.TriggerIndicator`;var cc=({children:e=` - `,className:t,...n})=>{let{slots:r}=(0,R.use)(ic);return(0,X.jsx)(S.span,{"aria-hidden":`true`,className:L(r?.rangeSeparator,t),"data-slot":`date-range-picker-range-separator`,...n,children:e})};cc.displayName=`HeroUI.DateRangePicker.RangeSeparator`;var lc=({children:e,className:t,placement:n=`bottom`,...r})=>{let{slots:i}=(0,R.use)(ic);return(0,X.jsx)(s,{value:{variant:`default`},children:(0,X.jsx)(Je,{...r,className:N(t,i?.popover()),"data-slot":`date-range-picker-popover`,placement:n,children:e})})};lc.displayName=`HeroUI.DateRangePicker.Popover`;var uc=Object.assign(ac,{Root:ac,Trigger:oc,TriggerIndicator:sc,RangeSeparator:cc,Popover:lc});function dc({children:e,className:t,fullWidth:n,...r}){let i=R.useMemo(()=>tt({fullWidth:n}),[n]);return(0,X.jsx)(fo,{"data-required":Le(r.isRequired),"data-slot":`time-field`,...r,className:N(t,i),children:t=>(0,X.jsx)(X.Fragment,{children:typeof e==`function`?e(t):e})})}var fc=Object.assign(dc,{Root:dc,Group:vo,Input:bo,InputContainer:So,Segment:xo,Prefix:yo,Suffix:Co}),pc=(0,R.createContext)(null);function mc(){let e=(0,R.use)(pc);if(!e)throw Error(`useYearPicker must be used within a or component.`);return e}function hc(){let e=(0,R.use)(Ls),t=(0,R.use)(Rs),n=e??t;if(!n)throw Error(`useCalendarOrRangeState must be used within a or component.`);return n}function gc(e){switch(e){case`buddhist`:return 543;case`ethiopic`:case`ethioaa`:return-8;case`coptic`:return-284;case`hebrew`:return 3760;case`indian`:return-78;case`islamic-civil`:case`islamic-tbla`:case`islamic-umalqura`:return-579;case`persian`:return-600;default:return 0}}function _c(e,t){let n=[];if(!e||!t)return n;let r=kt(e);for(;r.compare(t)<=0;)n.push(r),r=kt(r.add({years:1}));return n}function vc(e,t,n,r=`short`,i=`UTC`){let a=new Intl.DateTimeFormat(t,{weekday:r,timeZone:i}),o=At(e,t,n),s=[],c=o;for(let e=0;e<7;e++){s.push(a.format(c.toDate(i)));let e=c.add({days:1});if(B(c,e))break;c=e}for(;s.length<7;)s.push(``);return s}function yc(e,t){let n=[],r=e;for(let e=0;e<7;e++){n.push(r.compare(t)>0?null:r);let e=r.add({days:1});if(B(r,e)){for(;n.length<7;)n.push(null);return n}r=e}return n}function bc(e,t,n,r){let i=[],a=At(e,n,r);for(i.push(yc(a,t)),a=a.add({weeks:1});a.compare(t)<=0;){i.push(yc(a,t));let e=a.add({weeks:1});if(B(a,e))break;a=e}return i}var xc=R.createContext(null);function Sc(){let e=R.use(xc);if(!e)throw Error(`CalendarYearPicker trigger components must be used within .`);return e}var Cc=({children:e,className:t,onKeyDown:n,onPress:r,...i})=>{let{isYearPickerOpen:a,setIsYearPickerOpen:o}=mc(),s=ys({},hc()),c=R.useMemo(()=>Xe(),[]),l=R.useCallback(()=>{o(!a)},[a,o]),u=e=>{n?.(e),!e.defaultPrevented&&e.key===`Escape`&&a&&(e.preventDefault(),o(!1))},d=R.useMemo(()=>({isOpen:a,monthYear:s,toggle:l}),[l,a,s]),p=R.useMemo(()=>({...d,slots:c}),[c,d]);return(0,X.jsx)(xc,{value:p,children:(0,X.jsx)(f,{"aria-expanded":a,"aria-label":`${s}, year selector`,className:N(t,c.trigger()),"data-open":a||void 0,"data-slot":`calendar-year-picker-trigger`,slot:null,onKeyDown:u,onPress:e=>{r?.(e),l()},...i,children:typeof e==`function`?e(d):e})})};Cc.displayName=`HeroUI.CalendarYearPicker.Trigger`;var wc=({children:e,className:t,format:n,offset:r,...i})=>{let{monthYear:a,slots:o,...s}=Sc(),c=hc(),l=ys({format:n,offset:r},c);return(0,X.jsx)(S.span,{className:L(o.triggerHeading,t),"data-slot":`calendar-year-picker-trigger-heading`,...i,children:typeof e==`function`?e({monthYear:a,...s}):e||l})};wc.displayName=`HeroUI.CalendarYearPicker.TriggerHeading`;var Tc=({children:e,className:t,...n})=>{let{monthYear:r,slots:i,...a}=Sc();return(0,X.jsx)(S.span,{"aria-hidden":`true`,className:L(i.triggerIndicator,t),"data-slot":`calendar-year-picker-trigger-indicator`,...n,children:typeof e==`function`?e({monthYear:r,...a}):e||(0,X.jsx)(o,{height:`1em`,width:`1em`})})};Tc.displayName=`HeroUI.CalendarYearPicker.TriggerIndicator`;var Ec=R.createContext(null);function Dc(){let e=R.use(Ec);if(!e)throw Error(`CalendarYearPicker components must be used within .`);return e}var Oc=({children:e,className:t,format:n,onKeyDown:r,visibleYears:i,...a})=>{let{calendarGridSlot:o,calendarRef:s,isYearPickerOpen:c,setIsYearPickerOpen:l}=mc(),u=hc(),d=R.useRef(null),f=R.useMemo(()=>Xe(),[]),{"aria-label":p,items:m,onChange:h,value:g}=vs({format:n,visibleYears:R.useMemo(()=>i??(!u.minValue||!u.maxValue?20:_c(u.minValue,u.maxValue).length),[u.maxValue,u.minValue,i])},u),_=m.map(e=>`${e.id}:${e.date.year}`).join(`|`),v=m.map(e=>e.date.year),y=new Map(m.map(e=>[e.date.year,e])),b=m[g]?.date.year??u.focusedDate.year,x=R.useCallback(e=>y.get(e)?.formatted??String(e),[y]),[C,w]=R.useState(b),T=R.useRef(!1);R.useEffect(()=>{let e=d.current;if(!e)return;let t=s.current?.querySelector(`[data-slot='${o}']`);t&&(e.style.top=`${t.offsetTop}px`,e.style.height=`${t.offsetHeight}px`)},[o,s,u.focusedDate]);let E=R.useCallback(e=>{let t=d.current;if(!t)return;let n=t.querySelector(`[data-year='${e}']`);n&&n.focus()},[]);R.useEffect(()=>{let e=c&&!T.current;if(T.current=c,!e||v.length===0)return;let[t]=v;if(t==null)return;let n=v.includes(b)?b:t;w(n);let r=requestAnimationFrame(()=>{E(n)});return()=>{cancelAnimationFrame(r)}},[E,b,c,_,v.length]),R.useEffect(()=>{if(!c||v.length===0)return;let[e]=v;e!=null&&(v.includes(C)||w(e))},[C,c,_,v]);let D=R.useCallback(e=>{let t=y.get(e);t!=null&&(l(!1),h(t.id))},[y,h,l]),O=e=>{if(r?.(e),e.defaultPrevented)return;if(e.key===`Escape`&&c){e.preventDefault(),l(!1);return}if(!c||v.length===0)return;let t=v.indexOf(C);if(t===-1)return;let n=t;switch(e.key){case`ArrowRight`:n=Math.min(t+1,v.length-1);break;case`ArrowLeft`:n=Math.max(t-1,0);break;case`ArrowDown`:n=Math.min(t+3,v.length-1);break;case`ArrowUp`:n=Math.max(t-3,0);break;case`Home`:n=0;break;case`End`:n=v.length-1;break;default:return}if(n!==t){let t=v[n];if(t==null)return;e.preventDefault(),w(t),E(t)}},k=R.useMemo(()=>({activeYear:C,focusedYear:b,getFormattedYear:x,isYearPickerOpen:c,selectYear:D,setActiveYear:w,slots:f,years:v}),[C,b,x,D,c,f,v]);return(0,X.jsx)(Ec,{value:k,children:(0,X.jsx)(S.div,{ref:d,"aria-hidden":!c,"aria-label":p,className:L(f.yearGrid,t),"data-open":c||void 0,"data-slot":`calendar-year-picker-grid`,role:`listbox`,tabIndex:-1,onKeyDown:O,...a,children:e})})};Oc.displayName=`HeroUI.CalendarYearPicker.Grid`;var kc=({children:e})=>{let{focusedYear:t,getFormattedYear:n,isYearPickerOpen:r,selectYear:i,years:a}=Dc(),o=new Date().getFullYear();return(0,X.jsx)(X.Fragment,{children:a.map(a=>{let s=a===t,c={formattedYear:n(a),isCurrentYear:a===o,isOpen:r,isSelected:s,selectYear:()=>i(a),year:a};return(0,X.jsx)(R.Fragment,{children:typeof e==`function`?e(c):(0,X.jsx)(Ac,{year:a})},a)})})};kc.displayName=`HeroUI.CalendarYearPicker.GridBody`;var Ac=({children:e,className:t,excludeFromTabOrder:n,onFocus:r,onPress:i,year:a,...o})=>{let{activeYear:s,focusedYear:c,getFormattedYear:l,isYearPickerOpen:u,selectYear:d,setActiveYear:p,slots:m}=Dc(),h=a===c,g=a===s,_=l(a),v={formattedYear:_,isCurrentYear:a===new Date().getFullYear(),isOpen:u,isSelected:h,selectYear:()=>d(a),year:a};return(0,X.jsx)(f,{"aria-label":_,"aria-selected":h,className:N(t,m.yearCell()),"data-selected":h||void 0,"data-slot":`calendar-year-picker-year-cell`,"data-year":a,excludeFromTabOrder:n??!(u&&g),slot:null,onFocus:e=>{r?.(e),p(a)},onPress:e=>{i?.(e),d(a)},...o,children:typeof e==`function`?e(v):e||_})};Ac.displayName=`HeroUI.CalendarYearPicker.Cell`;function jc({children:e,className:t,"data-slot":n=`calendar-grid-body`,firstDayOfWeek:r,visibleRange:i}){let{locale:a}=F(),o=R.useMemo(()=>bc(i.start,i.end,a,r),[r,a,i.end,i.start]);return(0,X.jsx)(S.tbody,{className:t,"data-slot":n,children:o.map((t,n)=>(0,X.jsx)(`tr`,{children:t.map((t,n)=>t?R.cloneElement(e(t),{key:n}):(0,X.jsx)(`td`,{},n))},n))})}function Mc({children:e,className:t,"data-slot":n=`calendar-grid-header`,firstDayOfWeek:r,timeZone:i=`UTC`,visibleRange:a,weekdayStyle:o=`short`}){let{locale:s}=F(),c=R.useMemo(()=>vc(a.start,s,r,o,i),[r,s,i,a.start,o]);return(0,X.jsx)(S.thead,{"aria-hidden":!0,className:t,"data-slot":n,children:(0,X.jsx)(`tr`,{children:c.map((t,n)=>R.cloneElement(e(t),{key:n}))})})}var Q=(0,R.createContext)({});function Nc({children:e,className:t,defaultYearPickerOpen:n=!1,firstDayOfWeek:r,isYearPickerOpen:i,maxValue:a,minValue:o,onYearPickerOpenChange:s,visibleDuration:c,...l}){let u=c?.weeks!=null,d=c?.days!=null,f=c?.days,{locale:p}=F(),m=R.useMemo(()=>Ze(),[]),h=R.useRef(null),[g,_]=ce(i,n,s),v=R.useMemo(()=>{let e=new Y(p).resolvedOptions().calendar;return Kr(e)},[p]),y=R.useMemo(()=>gc(v.identifier),[v.identifier]),b=o??new q(v,1900+y,1,1),x=a??new q(v,2099+y,12,31);return(0,X.jsx)(pc,{value:{calendarGridSlot:`range-calendar-grid`,isYearPickerOpen:g,setIsYearPickerOpen:_,calendarRef:h},children:(0,X.jsx)(zs,{ref:h,"data-slot":`range-calendar`,firstDayOfWeek:r,maxValue:x,minValue:b,visibleDuration:c,...l,className:N(t,te(m.base(),u&&`range-calendar--week-view`,d&&`range-calendar--day-view`)),children:t=>(0,X.jsx)(Q,{value:{dayView:d&&f!=null?{days:f,firstDayOfWeek:r,timeZone:t.state.timeZone,visibleRange:t.state.visibleRange}:void 0,slots:m},children:typeof e==`function`?e(t):e})})})}Nc.displayName=`HeroUI.RangeCalendar`;var Pc=({children:e,className:t,...n})=>{let{slots:r}=(0,R.use)(Q);return(0,X.jsx)(S.header,{className:L(r?.header,t),"data-slot":`range-calendar-header`,...n,children:e})};Pc.displayName=`HeroUI.RangeCalendar.Header`;var Fc=({className:e,...t})=>{let{slots:n}=(0,R.use)(Q);return(0,X.jsx)(Ys,{"data-slot":`range-calendar-heading`,...t,className:L(n?.heading,e)})};Fc.displayName=`HeroUI.RangeCalendar.Heading`;var Ic=({children:e,className:t,slot:n,...r})=>{let{slots:i}=(0,R.use)(Q);return(0,X.jsx)(f,{"data-slot":`range-calendar-nav-button`,slot:n,...r,className:N(t,i?.navButton()),children:e||(n===`previous`?(0,X.jsx)(u,{className:i?.navButtonIcon(),"data-slot":`range-calendar-nav-button-icon`}):(0,X.jsx)(o,{className:i?.navButtonIcon(),"data-slot":`range-calendar-nav-button-icon`}))})};Ic.displayName=`HeroUI.RangeCalendar.NavButton`;var Lc=({children:e,className:t,weekdayStyle:n=`short`,...r})=>{let i=(0,R.use)(Q),{dayView:a,slots:o}=i,s=R.useMemo(()=>({...i,dayView:a?{...a,weekdayStyle:n}:void 0}),[a,i,n]);return(0,X.jsx)(Q,{value:s,children:(0,X.jsx)(Vs,{"data-slot":`range-calendar-grid`,weekdayStyle:n,...r,className:L(o?.grid,t),children:e})})};Lc.displayName=`HeroUI.RangeCalendar.Grid`;var Rc=({children:e,className:t,...n})=>{let{dayView:r,slots:i}=(0,R.use)(Q);return r&&r.days>=7&&typeof e==`function`?(0,X.jsx)(Mc,{className:L(i?.gridHeader,t),"data-slot":`range-calendar-grid-header`,firstDayOfWeek:r.firstDayOfWeek,timeZone:r.timeZone,visibleRange:r.visibleRange,weekdayStyle:r.weekdayStyle,children:e}):(0,X.jsx)(Us,{"data-slot":`range-calendar-grid-header`,...n,className:L(i?.gridHeader,t),children:e})};Rc.displayName=`HeroUI.RangeCalendar.GridHeader`;var zc=({children:e,className:t,...n})=>{let{dayView:r,slots:i}=(0,R.use)(Q);return r&&r.days>=7&&typeof e==`function`?(0,X.jsx)(jc,{className:L(i?.gridBody,t),"data-slot":`range-calendar-grid-body`,firstDayOfWeek:r.firstDayOfWeek,visibleRange:r.visibleRange,children:e}):(0,X.jsx)(qs,{"data-slot":`range-calendar-grid-body`,...n,className:L(i?.gridBody,t),children:e})};zc.displayName=`HeroUI.RangeCalendar.GridBody`;var Bc=({className:e,...t})=>{let{slots:n}=(0,R.use)(Q);return(0,X.jsx)(Gs,{"data-slot":`range-calendar-header-cell`,...t,className:L(n?.headerCell,e)})};Bc.displayName=`HeroUI.RangeCalendar.HeaderCell`;var Vc=({children:e,className:t,...n})=>{let{slots:r}=(0,R.use)(Q);return(0,X.jsx)(Js,{"data-slot":`range-calendar-cell`,...n,className:N(t,r?.cell()),children:t=>{let{formattedDate:n,isDisabled:r,isHovered:i,isPressed:a,isSelectionEnd:o,isSelectionStart:s}=t,c=typeof e==`function`?e(t):e||n;return(0,X.jsx)(`span`,{className:`range-calendar__cell-button`,"data-disabled":Le(r),"data-hovered":Le(i),"data-pressed":Le(a),"data-selected":Le(s||o),"data-slot":`range-calendar-cell-button`,children:c})}})};Vc.displayName=`HeroUI.RangeCalendar.Cell`;var Hc=({className:e,...t})=>{let{slots:n}=(0,R.use)(Q);return(0,X.jsx)(S.span,{"aria-hidden":`true`,className:L(n?.cellIndicator,e),"data-slot":`range-calendar-cell-indicator`,...t})};Hc.displayName=`HeroUI.RangeCalendar.CellIndicator`;var $=Object.assign(Nc,{Root:Nc,Header:Pc,Heading:Fc,NavButton:Ic,Grid:Lc,GridHeader:Rc,GridBody:zc,HeaderCell:Bc,Cell:Vc,CellIndicator:Hc,YearPickerTrigger:Cc,YearPickerTriggerHeading:wc,YearPickerTriggerIndicator:Tc,YearPickerGrid:Oc,YearPickerGridBody:kc,YearPickerCell:Ac});function Uc(e={}){let t=new URLSearchParams;e.dim?.length&&t.set(`dim`,e.dim.join(`,`)),e.limit!=null&&t.set(`limit`,String(e.limit)),e.hours!=null&&t.set(`hours`,String(e.hours)),e.from&&t.set(`from`,e.from),e.to&&t.set(`to`,e.to),e.api_key&&t.set(`api_key`,e.api_key);let n=t.toString()?`?${t}`:``;return Re(`/api/logs/stats${n}`)}function Wc(e={}){let t=new URLSearchParams;e.account&&t.set(`account`,e.account),e.api_key&&t.set(`api_key`,e.api_key),e.status&&t.set(`status`,e.status),e.stream!=null&&t.set(`stream`,e.stream?`1`:`0`),e.error_kind&&t.set(`error_kind`,e.error_kind),e.model&&t.set(`model`,e.model),e.provider&&t.set(`provider`,e.provider),e.id&&t.set(`id`,e.id),e.q&&t.set(`q`,e.q),e.from&&t.set(`from`,e.from),e.to&&t.set(`to`,e.to),e.limit!=null&&t.set(`limit`,String(e.limit)),e.offset!=null&&t.set(`offset`,String(e.offset));let n=t.toString()?`?${t}`:``;return Re(`/api/logs/requests${n}`)}function Gc(e){return Re(`/api/logs/requests/${encodeURIComponent(e)}`)}function Kc(){return Re(`/api/logs/requests`,{method:`DELETE`})}function qc(e={}){let t=new URLSearchParams;e.after!=null&&t.set(`after`,String(e.after)),e.limit!=null&&t.set(`limit`,String(e.limit)),e.offset!=null&&t.set(`offset`,String(e.offset)),e.level&&t.set(`level`,e.level),e.q&&t.set(`q`,e.q),e.account&&t.set(`account`,e.account);let n=t.toString()?`?${t}`:``;return Re(`/api/logs/runtime${n}`)}function Jc(e,t=!1){if(!e)return;let n=e.toDate(Tt());if(Number.isFinite(n.getTime()))return t&&n.setSeconds(59,999),n.toISOString()}function Yc(e){if(!e)return null;let t=Date.parse(e);if(!Number.isFinite(t))return null;try{return W(An(new Date(t).toISOString()))}catch{return null}}function Xc({value:e,onChange:t,ariaLabel:n,fromLabel:r,toLabel:i,className:a}){return(0,X.jsx)(uc,{className:a,granularity:`minute`,hourCycle:24,shouldForceLeadingZeros:!0,value:e,onChange:e=>t(e),"aria-label":n,children:({state:e})=>(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(To.Group,{className:`w-full min-w-0`,variant:`secondary`,children:[(0,X.jsx)(To.Input,{className:`min-w-0`,slot:`start`,"aria-label":r,children:e=>(0,X.jsx)(To.Segment,{segment:e})}),(0,X.jsx)(uc.RangeSeparator,{}),(0,X.jsx)(To.Input,{className:`min-w-0`,slot:`end`,"aria-label":i,children:e=>(0,X.jsx)(To.Segment,{segment:e})}),(0,X.jsx)(To.Suffix,{children:(0,X.jsx)(uc.Trigger,{children:(0,X.jsx)(uc.TriggerIndicator,{})})})]}),(0,X.jsxs)(uc.Popover,{className:`flex w-[20.5rem] max-w-[calc(100vw-2rem)] flex-col gap-3 p-3`,children:[(0,X.jsxs)($,{"aria-label":n,children:[(0,X.jsxs)($.Header,{children:[(0,X.jsxs)($.YearPickerTrigger,{children:[(0,X.jsx)($.YearPickerTriggerHeading,{}),(0,X.jsx)($.YearPickerTriggerIndicator,{})]}),(0,X.jsx)($.NavButton,{slot:`previous`}),(0,X.jsx)($.NavButton,{slot:`next`})]}),(0,X.jsxs)($.Grid,{children:[(0,X.jsx)($.GridHeader,{children:e=>(0,X.jsx)($.HeaderCell,{children:e})}),(0,X.jsx)($.GridBody,{children:e=>(0,X.jsx)($.Cell,{date:e})})]}),(0,X.jsx)($.YearPickerGrid,{children:(0,X.jsx)($.YearPickerGridBody,{children:({year:e})=>(0,X.jsx)($.YearPickerCell,{year:e})})})]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,X.jsx)(Ae,{className:`text-xs`,children:r}),(0,X.jsx)(fc,{"aria-label":r,granularity:`minute`,hourCycle:24,value:e.timeRange?.start??null,onChange:t=>e.setTimeRange({start:t,end:e.timeRange?.end}),children:(0,X.jsx)(fc.Group,{className:`w-[7.5rem]`,variant:`secondary`,children:(0,X.jsx)(fc.Input,{children:e=>(0,X.jsx)(fc.Segment,{segment:e})})})})]}),(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,X.jsx)(Ae,{className:`text-xs`,children:i}),(0,X.jsx)(fc,{"aria-label":i,granularity:`minute`,hourCycle:24,value:e.timeRange?.end??null,onChange:t=>e.setTimeRange({start:e.timeRange?.start,end:t}),children:(0,X.jsx)(fc.Group,{className:`w-[7.5rem]`,variant:`secondary`,children:(0,X.jsx)(fc.Input,{children:e=>(0,X.jsx)(fc.Segment,{segment:e})})})})]})]})]})]})})}export{Gc as a,qc as c,Kc as i,Jc as n,Wc as o,Yc as r,Uc as s,Xc as t}; \ No newline at end of file diff --git a/internal/webui/static/assets/TimeRangePicker-CLtIDMZF.js b/internal/webui/static/assets/TimeRangePicker-CLtIDMZF.js new file mode 100644 index 00000000..5ad09c07 --- /dev/null +++ b/internal/webui/static/assets/TimeRangePicker-CLtIDMZF.js @@ -0,0 +1 @@ +import{a as e,c as t,n}from"./shim-mfK0Rmj6.js";import{B as r,D as i,E as a,J as o,L as s,O as c,P as l,X as u,Y as d,a as f,ct as p,it as m,k as h,w as g,z as _}from"./useI18n-BBOAnu2u.js";import{$ as v,A as y,B as b,Ct as x,F as S,G as C,I as w,J as T,L as E,M as D,N as O,Q as k,R as A,Y as ee,Z as te,_t as j,a as ne,c as M,ct as re,d as N,dt as ie,f as P,j as ae,k as F,l as I,lt as oe,m as se,o as ce,q as L,s as R,tt as le,u as ue,w as de,x as fe,z as pe}from"./SharedElementTransition-BlCsXfb1.js";import{t as me}from"./useUpdateEffect-DR9d7F-l.js";import{_ as he,a as ge,c as _e,d as ve,f as ye,h as be,i as xe,l as Se,m as Ce,n as we,p as Te,r as Ee,s as De,t as Oe,u as ke,v as Ae}from"./label-BVCjtfNQ.js";import{n as je,r as Me,t as Ne}from"./useSpinButton-D63Afzx1.js";import{t as Pe}from"./assertion-BLQtDfw6.js";import{A as Fe}from"./overview-CJvUvgoD.js";import{Ct as Ie,Dt as Le,Et as Re,St as ze,Tt as Be,U as Ve,W as He,bt as Ue,ot as We,wt as Ge,xt as Ke,yt as qe}from"./index-B9eWF6SH.js";var z=t(e(),1);function Je(e,t){let n=(0,z.useRef)(null);return e&&n.current&&t(e,n.current)&&(e=n.current),n.current=e,e}var Ye=pe({slots:{trigger:`calendar-year-picker__trigger`,triggerHeading:`calendar-year-picker__trigger-heading`,triggerIndicator:`calendar-year-picker__trigger-indicator`,yearCell:`calendar-year-picker__year-cell`,yearGrid:`calendar-year-picker__year-grid`}}),Xe=pe({defaultVariants:{},slots:{base:`range-calendar`,cell:`range-calendar__cell`,cellIndicator:`range-calendar__cell-indicator`,grid:`range-calendar__grid`,gridBody:`range-calendar__grid-body`,gridHeader:`range-calendar__grid-header`,gridRow:`range-calendar__grid-row`,header:`range-calendar__header`,headerCell:`range-calendar__header-cell`,heading:`range-calendar__heading`,navButton:`range-calendar__nav-button`,navButtonIcon:`range-calendar__nav-button-icon`},variants:{}}),Ze=pe({base:`date-field`,defaultVariants:{fullWidth:!1},variants:{fullWidth:{false:``,true:`date-field--full-width`}}}),Qe=pe({slots:{base:`date-range-picker`,popover:`date-range-picker__popover`,rangeSeparator:`date-range-picker__range-separator`,trigger:`date-range-picker__trigger`,triggerIndicator:`date-range-picker__trigger-indicator`}}),$e=pe({defaultVariants:{fullWidth:!1,variant:`primary`},slots:{base:`date-input-group`,input:`date-input-group__input`,inputContainer:`date-input-group__input-container`,prefix:`date-input-group__prefix`,segment:`date-input-group__segment`,suffix:`date-input-group__suffix`},variants:{fullWidth:{false:{},true:{base:`date-input-group--full-width`}},variant:{primary:{base:`date-input-group--primary`},secondary:{base:`date-input-group--secondary`}}}}),et=pe({base:`time-field`,defaultVariants:{fullWidth:!1},variants:{fullWidth:{false:``,true:`time-field--full-width`}}});function tt(e){let t=We({usage:`search`,...e}),n=(0,z.useCallback)((e,n)=>n.length===0||(e=e.normalize(`NFC`),n=n.normalize(`NFC`),t.compare(e.slice(0,n.length),n)===0),[t]),r=(0,z.useCallback)((e,n)=>n.length===0||(e=e.normalize(`NFC`),n=n.normalize(`NFC`),t.compare(e.slice(-n.length),n)===0),[t]),i=(0,z.useCallback)((e,n)=>{if(n.length===0)return!0;e=e.normalize(`NFC`),n=n.normalize(`NFC`);let r=0,i=n.length;for(;r+i<=e.length;r++){let a=e.slice(r,r+i);if(t.compare(n,a)===0)return!0}return!1},[t]);return(0,z.useMemo)(()=>({startsWith:n,endsWith:r,contains:i}),[n,r,i])}function nt(e,t){return e-t*Math.floor(e/t)}var rt=1721426;function it(e,t,n,r){t=ot(e,t);let i=t-1,a=-2;return n<=2?a=0:at(t)&&(a=-1),1721425+365*i+Math.floor(i/4)-Math.floor(i/100)+Math.floor(i/400)+Math.floor((367*n-362)/12+a+r)}function at(e){return e%4==0&&(e%100!=0||e%400==0)}function ot(e,t){return e===`BC`?1-t:t}function st(e){let t=`AD`;return e<=0&&(t=`BC`,e=1-e),[t,e]}var ct={standard:[31,28,31,30,31,30,31,31,30,31,30,31],leapyear:[31,29,31,30,31,30,31,31,30,31,30,31]},B=class{fromJulianDay(e){let t=e,n=t-rt,r=Math.floor(n/146097),i=nt(n,146097),a=Math.floor(i/36524),o=nt(i,36524),s=Math.floor(o/1461),c=nt(o,1461),l=Math.floor(c/365),[u,d]=st(r*400+a*100+s*4+l+ +(a!==4&&l!==4)),f=t-it(u,d,1,1),p=2;t=0?e:t:e||t}function Rt(e){return e=W(e,new B),zt(ot(e.era,e.year),e.month,e.day,e.hour,e.minute,e.second,e.millisecond)}function zt(e,t,n,r,i,a,o){let s=new Date;return s.setUTCHours(r,i,a,o),s.setUTCFullYear(e,t-1,n),s.getTime()}function Bt(e,t){if(t===`UTC`)return 0;if(e>0&&t===wt()&&!Tt())return new Date(e).getTimezoneOffset()*-6e4;let{year:n,month:r,day:i,hour:a,minute:o,second:s}=Ht(e,t);return zt(n,r,i,a,o,s,0)-Math.floor(e/1e3)*1e3}var Vt=new Map;function Ht(e,t){let n=Vt.get(t);n||(n=new Intl.DateTimeFormat(`en-US`,{timeZone:t,hour12:!1,era:`short`,year:`numeric`,month:`numeric`,day:`numeric`,hour:`numeric`,minute:`numeric`,second:`numeric`}),Vt.set(t,n));let r=n.formatToParts(new Date(e)),i={};for(let e of r)e.type!==`literal`&&(i[e.type]=e.value);return{year:i.era===`BC`||i.era===`B`?-i.year+1:+i.year,month:+i.month,day:+i.day,hour:i.hour===`24`?0:+i.hour,minute:+i.minute,second:+i.second}}var Ut=864e5;function Wt(e,t,n,r){return(n===r?[n]:[n,r]).filter(n=>Gt(e,t,n))}function Gt(e,t,n){let r=Ht(n,t);return e.year===r.year&&e.month===r.month&&e.day===r.day&&e.hour===r.hour&&e.minute===r.minute&&e.second===r.second}function Kt(e,t,n=`compatible`){let r=U(e);if(t===`UTC`)return Rt(r);if(t===wt()&&n===`compatible`&&!Tt()){r=W(r,new B);let e=new Date,t=ot(r.era,r.year);return e.setFullYear(t,r.month-1,r.day),e.setHours(r.hour,r.minute,r.second,r.millisecond),e.getTime()}let i=Rt(r),a=Bt(i-Ut,t),o=Bt(i+Ut,t),s=Wt(r,t,i-a,i-o);if(s.length===1)return s[0];if(s.length>1)switch(n){case`compatible`:case`earlier`:return s[0];case`later`:return s[s.length-1];case`reject`:throw RangeError(`Multiple possible absolute times found`)}switch(n){case`earlier`:return Math.min(i-a,i-o);case`compatible`:case`later`:return Math.max(i-a,i-o);case`reject`:throw RangeError(`No such absolute time found`)}}function qt(e,t,n=`compatible`){return new Date(Kt(e,t,n))}function Jt(e,t){let n=Bt(e,t),r=new Date(e+n),i=r.getUTCFullYear(),a=r.getUTCMonth()+1,o=r.getUTCDate(),s=r.getUTCHours(),c=r.getUTCMinutes(),l=r.getUTCSeconds(),u=r.getUTCMilliseconds();return new zn(i<1?`BC`:`AD`,i<1?-i+1:i,a,o,t,n,s,c,l,u)}function H(e){return new q(e.calendar,e.era,e.year,e.month,e.day)}function U(e,t){let n=0,r=0,i=0,a=0;if(`timeZone`in e)({hour:n,minute:r,second:i,millisecond:a}=e);else if(`hour`in e&&!t)return e;return t&&({hour:n,minute:r,second:i,millisecond:a}=t),new Rn(e.calendar,e.era,e.year,e.month,e.day,n,r,i,a)}function Yt(e){return new Ln(e.hour,e.minute,e.second,e.millisecond)}function W(e,t){if(pt(e.calendar,t))return e;let n=t.fromJulianDay(e.calendar.toJulianDay(e)),r=e.copy();return r.calendar=t,r.era=n.era,r.year=n.year,r.month=n.month,r.day=n.day,sn(r),r}function Xt(e,t,n){return e instanceof zn?e.timeZone===t?e:Qt(e,t):Jt(Kt(e,t,n),t)}function Zt(e){let t=Rt(e)-e.offset;return new Date(t)}function Qt(e,t){return W(Jt(Rt(e)-e.offset,t),e.calendar)}function $t(e){return Qt(e,wt())}var en=36e5;function tn(e,t){let n=e.copy(),r=`hour`in n?hn(n,t):0;nn(n,t.years||0),n.calendar.balanceYearMonth&&n.calendar.balanceYearMonth(n,e),n.month+=t.months||0,rn(n),on(n),n.day+=(t.weeks||0)*7,n.day+=t.days||0,n.day+=r,an(n),n.calendar.balanceDate&&n.calendar.balanceDate(n),n.year<1&&(n.year=1,n.month=1,n.day=1);let i=n.calendar.getYearsInEra(n);if(n.year>i){let e=n.calendar.isInverseEra?.(n);n.year=i,n.month=e?1:n.calendar.getMonthsInYear(n),n.day=e?1:n.calendar.getDaysInMonth(n)}n.month<1&&(n.month=1,n.day=1);let a=n.calendar.getMonthsInYear(n);return n.month>a&&(n.month=a,n.day=n.calendar.getDaysInMonth(n)),n.day=Math.max(1,Math.min(n.calendar.getDaysInMonth(n),n.day)),n}function nn(e,t){e.calendar.isInverseEra?.(e)&&(t=-t),e.year+=t}function rn(e){for(;e.month<1;)nn(e,-1),e.month+=e.calendar.getMonthsInYear(e);let t=0;for(;e.month>(t=e.calendar.getMonthsInYear(e));)e.month-=t,nn(e,1)}function an(e){for(;e.day<1;)e.month--,rn(e),e.day+=e.calendar.getDaysInMonth(e);for(;e.day>e.calendar.getDaysInMonth(e);)e.day-=e.calendar.getDaysInMonth(e),e.month++,rn(e)}function on(e){e.month=Math.max(1,Math.min(e.calendar.getMonthsInYear(e),e.month)),e.day=Math.max(1,Math.min(e.calendar.getDaysInMonth(e),e.day))}function sn(e){e.calendar.constrainDate&&e.calendar.constrainDate(e),e.year=Math.max(1,Math.min(e.calendar.getYearsInEra(e),e.year)),on(e)}function cn(e){let t={};for(let n in e)typeof e[n]==`number`&&(t[n]=-e[n]);return t}function ln(e,t){return tn(e,cn(t))}function un(e,t){let n=e.copy();return t.era!=null&&(n.era=t.era),t.year!=null&&(n.year=t.year),t.month!=null&&(n.month=t.month),t.day!=null&&(n.day=t.day),sn(n),n}function dn(e,t){let n=e.copy();return t.hour!=null&&(n.hour=t.hour),t.minute!=null&&(n.minute=t.minute),t.second!=null&&(n.second=t.second),t.millisecond!=null&&(n.millisecond=t.millisecond),pn(n),n}function fn(e){e.second+=Math.floor(e.millisecond/1e3),e.millisecond=mn(e.millisecond,1e3),e.minute+=Math.floor(e.second/60),e.second=mn(e.second,60),e.hour+=Math.floor(e.minute/60),e.minute=mn(e.minute,60);let t=Math.floor(e.hour/24);return e.hour=mn(e.hour,24),t}function pn(e){e.millisecond=Math.max(0,Math.min(e.millisecond,999)),e.second=Math.max(0,Math.min(e.second,59)),e.minute=Math.max(0,Math.min(e.minute,59)),e.hour=Math.max(0,Math.min(e.hour,23))}function mn(e,t){let n=e%t;return n<0&&(n+=t),n}function hn(e,t){return e.hour+=t.hours||0,e.minute+=t.minutes||0,e.second+=t.seconds||0,e.millisecond+=t.milliseconds||0,fn(e)}function gn(e,t){let n=e.copy();return hn(n,t),n}function _n(e,t){return gn(e,cn(t))}function vn(e,t,n,r){let i=e.copy();switch(t){case`era`:{let t=e.calendar.getEras(),a=t.indexOf(e.era);if(a<0)throw Error(`Invalid era: `+e.era);a=G(a,n,0,t.length-1,r?.round),i.era=t[a],sn(i);break}case`year`:i.calendar.isInverseEra?.(i)&&(n=-n),i.year=G(e.year,n,-1/0,9999,r?.round),i.year===-1/0&&(i.year=1),i.calendar.balanceYearMonth&&i.calendar.balanceYearMonth(i,e);break;case`month`:i.month=G(e.month,n,1,e.calendar.getMonthsInYear(e),r?.round);break;case`day`:i.day=G(e.day,n,1,e.calendar.getDaysInMonth(e),r?.round);break;default:throw Error(`Unsupported field `+t)}return e.calendar.balanceDate&&e.calendar.balanceDate(i),sn(i),i}function yn(e,t,n,r){let i=e.copy();switch(t){case`hour`:{let t=e.hour,a=0,o=23;if(r?.hourCycle===12){let e=t>=12;a=e?12:0,o=e?23:11}i.hour=G(t,n,a,o,r?.round);break}case`minute`:i.minute=G(e.minute,n,0,59,r?.round);break;case`second`:i.second=G(e.second,n,0,59,r?.round);break;case`millisecond`:i.millisecond=G(e.millisecond,n,0,999,r?.round);break;default:throw Error(`Unsupported field `+t)}return i}function G(e,t,n,r,i=!1){if(i){e+=Math.sign(t),e0?Math.ceil(e/i)*i:Math.floor(e/i)*i,e>r&&(e=n)}else e+=t,er&&(e=n+(e-r-1));return e}function bn(e,t){let n;return n=t.years!=null&&t.years!==0||t.months!=null&&t.months!==0||t.weeks!=null&&t.weeks!==0||t.days!=null&&t.days!==0?Kt(tn(U(e),{years:t.years,months:t.months,weeks:t.weeks,days:t.days}),e.timeZone):Rt(e)-e.offset,n+=t.milliseconds||0,n+=(t.seconds||0)*1e3,n+=(t.minutes||0)*6e4,n+=(t.hours||0)*36e5,W(Jt(n,e.timeZone),e.calendar)}function xn(e,t){return bn(e,cn(t))}function Sn(e,t,n,r){switch(t){case`hour`:{let t=0,i=23;if(r?.hourCycle===12){let n=e.hour>=12;t=n?12:0,i=n?23:11}let a=U(e),o=W(dn(a,{hour:t}),new B),s=[Kt(o,e.timeZone,`earlier`),Kt(o,e.timeZone,`later`)].filter(t=>Jt(t,e.timeZone).day===o.day)[0],c=W(dn(a,{hour:i}),new B),l=[Kt(c,e.timeZone,`earlier`),Kt(c,e.timeZone,`later`)].filter(t=>Jt(t,e.timeZone).day===c.day).pop(),u=Rt(e)-e.offset,d=Math.floor(u/en),f=u%en;return u=G(d,n,Math.floor(s/en),Math.floor(l/en),r?.round)*en+f,W(Jt(u,e.timeZone),e.calendar)}case`minute`:case`second`:case`millisecond`:return yn(e,t,n,r);case`era`:case`year`:case`month`:case`day`:return W(Jt(Kt(vn(U(e),t,n,r),e.timeZone),e.timeZone),e.calendar);default:throw Error(`Unsupported field `+t)}}function Cn(e,t,n){let r=U(e),i=dn(un(r,t),t);return i.compare(r)===0?e:W(Jt(Kt(i,e.timeZone,n),e.timeZone),e.calendar)}var wn=/^([+-]\d{6}|\d{4})-(\d{2})-(\d{2})$/,Tn=/^([+-]\d{6}|\d{4})-(\d{2})-(\d{2})(?:T(\d{2}))?(?::(\d{2}))?(?::(\d{2}))?(\.\d+)?$/,En=/^([+-]\d{6}|\d{4})-(\d{2})-(\d{2})(?:T(\d{2}))?(?::(\d{2}))?(?::(\d{2}))?(\.\d+)?(?:(?:([+-]\d{2})(?::?(\d{2}))?)|Z)$/;function Dn(e){let t=e.match(wn);if(!t)throw En.test(e)?Error(`Invalid ISO 8601 date string: ${e}. Use parseAbsolute() instead.`):Error(`Invalid ISO 8601 date string: `+e);let n=new q(K(t[1],0,9999),K(t[2],1,12),1);return n.day=K(t[3],1,n.calendar.getDaysInMonth(n)),n}function On(e){let t=e.match(Tn);if(!t)throw En.test(e)?Error(`Invalid ISO 8601 date time string: ${e}. Use parseAbsolute() instead.`):Error(`Invalid ISO 8601 date time string: `+e);let n=K(t[1],-9999,9999),r=new Rn(n<1?`BC`:`AD`,n<1?-n+1:n,K(t[2],1,12),1,t[4]?K(t[4],0,23):0,t[5]?K(t[5],0,59):0,t[6]?K(t[6],0,59):0,t[7]?K(t[7],0,1/0)*1e3:0);return r.day=K(t[3],0,r.calendar.getDaysInMonth(r)),r}function kn(e,t){let n=e.match(En);if(!n)throw Error(`Invalid ISO 8601 date time string: `+e);let r=K(n[1],-9999,9999),i=new zn(r<1?`BC`:`AD`,r<1?-r+1:r,K(n[2],1,12),1,t,0,n[4]?K(n[4],0,23):0,n[5]?K(n[5],0,59):0,n[6]?K(n[6],0,59):0,n[7]?K(n[7],0,1/0)*1e3:0);return i.day=K(n[3],0,i.calendar.getDaysInMonth(i)),n[8]&&(i.offset=K(n[8],-23,23)*36e5+K(n[9]??`0`,0,59)*6e4),Qt(i,t)}function An(e){return kn(e,wt())}function K(e,t,n){let r=Number(e);if(rn)throw RangeError(`Value out of range: ${t} <= ${r} <= ${n}`);return r}function jn(e){return`${String(e.hour).padStart(2,`0`)}:${String(e.minute).padStart(2,`0`)}:${String(e.second).padStart(2,`0`)}${e.millisecond?String(e.millisecond/1e3).slice(1):``}`}function Mn(e){let t=W(e,new B),n;return n=t.era===`BC`?t.year===1?`0000`:`-`+String(Math.abs(1-t.year)).padStart(6,`00`):String(t.year).padStart(4,`0`),`${n}-${String(t.month).padStart(2,`0`)}-${String(t.day).padStart(2,`0`)}`}function Nn(e){return`${Mn(e)}T${jn(e)}`}function Pn(e){let t=Math.sign(e)<0?`-`:`+`;e=Math.abs(e);let n=Math.floor(e/36e5),r=Math.floor(e%36e5/6e4),i=Math.floor(e%36e5%6e4/1e3),a=`${t}${String(n).padStart(2,`0`)}:${String(r).padStart(2,`0`)}`;return i!==0&&(a+=`:${String(i).padStart(2,`0`)}`),a}function Fn(e){return`${Nn(e)}${Pn(e.offset)}[${e.timeZone}]`}function In(e){let t=typeof e[0]==`object`?e.shift():new B,n;if(typeof e[0]==`string`)n=e.shift();else{let e=t.getEras();n=e[e.length-1]}let r=e.shift(),i=e.shift(),a=e.shift();return[t,n,r,i,a]}var q=class e{constructor(...e){let[t,n,r,i,a]=In(e);this.calendar=t,this.era=n,this.year=r,this.month=i,this.day=a,sn(this)}copy(){return this.era?new e(this.calendar,this.era,this.year,this.month,this.day):new e(this.calendar,this.year,this.month,this.day)}add(e){return tn(this,e)}subtract(e){return ln(this,e)}set(e){return un(this,e)}cycle(e,t,n){return vn(this,e,t,n)}toDate(e){return qt(this,e)}toString(){return Mn(this)}compare(e){return yt(this,e)}},Ln=class e{constructor(e=0,t=0,n=0,r=0){this.hour=e,this.minute=t,this.second=n,this.millisecond=r,pn(this)}copy(){return new e(this.hour,this.minute,this.second,this.millisecond)}add(e){return gn(this,e)}subtract(e){return _n(this,e)}set(e){return dn(this,e)}cycle(e,t,n){return yn(this,e,t,n)}toString(){return jn(this)}compare(e){return bt(this,e)}},Rn=class e{constructor(...e){let[t,n,r,i,a]=In(e);this.calendar=t,this.era=n,this.year=r,this.month=i,this.day=a,this.hour=e.shift()||0,this.minute=e.shift()||0,this.second=e.shift()||0,this.millisecond=e.shift()||0,sn(this)}copy(){return this.era?new e(this.calendar,this.era,this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond):new e(this.calendar,this.year,this.month,this.day,this.hour,this.minute,this.second,this.millisecond)}add(e){return tn(this,e)}subtract(e){return ln(this,e)}set(e){return un(dn(this,e),e)}cycle(e,t,n){switch(e){case`era`:case`year`:case`month`:case`day`:return vn(this,e,t,n);default:return yn(this,e,t,n)}}toDate(e,t){return qt(this,e,t)}toString(){return Nn(this)}compare(e){let t=yt(this,e);return t===0?bt(this,U(e)):t}},zn=class e{constructor(...e){let[t,n,r,i,a]=In(e),o=e.shift(),s=e.shift();this.calendar=t,this.era=n,this.year=r,this.month=i,this.day=a,this.timeZone=o,this.offset=s,this.hour=e.shift()||0,this.minute=e.shift()||0,this.second=e.shift()||0,this.millisecond=e.shift()||0,sn(this)}copy(){return this.era?new e(this.calendar,this.era,this.year,this.month,this.day,this.timeZone,this.offset,this.hour,this.minute,this.second,this.millisecond):new e(this.calendar,this.year,this.month,this.day,this.timeZone,this.offset,this.hour,this.minute,this.second,this.millisecond)}add(e){return bn(this,e)}subtract(e){return xn(this,e)}set(e,t){return Cn(this,e,t)}cycle(e,t,n){return Sn(this,e,t,n)}toDate(){return Zt(this)}toString(){return Fn(this)}toAbsoluteString(){return this.toDate().toISOString()}compare(e){return this.toDate().getTime()-Xt(e,this.timeZone).toDate().getTime()}},Bn=[[1868,9,8],[1912,7,30],[1926,12,25],[1989,1,8],[2019,5,1]],Vn=[[1912,7,29],[1926,12,24],[1989,1,7],[2019,4,30]],Hn=[1867,1911,1925,1988,2018],Un=[`meiji`,`taisho`,`showa`,`heisei`,`reiwa`];function Wn(e){let t=Bn.findIndex(([t,n,r])=>e.year=0){let[,n,r]=Bn[t];e.month=Math.max(n,e.month),e.month===n&&(e.day=Math.max(r,e.day))}}getEras(){return Un}getYearsInEra(e){let t=Un.indexOf(e.era),n=Bn[t],r=Bn[t+1];if(r==null)return 9999-n[0]+1;let i=r[0]-n[0];return(e.month0?[`minguo`,t]:[`before_minguo`,1-t]}var er=class extends B{fromJulianDay(e){let t=super.fromJulianDay(e),[n,r]=$n(ot(t.era,t.year));return new q(this,n,r,t.month,t.day)}toJulianDay(e){return super.toJulianDay(tr(e))}getEras(){return[`before_minguo`,`minguo`]}balanceDate(e){let[t,n]=$n(Qn(e));e.era=t,e.year=n}isInverseEra(e){return e.era===`before_minguo`}getDaysInMonth(e){return super.getDaysInMonth(tr(e))}getYearsInEra(e){return e.era===`before_minguo`?9999:8088}constructor(...e){super(...e),this.identifier=`roc`}};function tr(e){let[t,n]=st(Qn(e));return new q(t,n,e.month,e.day)}var nr=1948320,rr=[0,31,62,93,124,155,186,216,246,276,306,336],ir=class{fromJulianDay(e){let t=e-nr,n=1+Math.floor((33*t+3)/12053),r=t-(365*(n-1)+Math.floor((8*n+21)/33)),i=Math.floor(r<216?r/31:(r-6)/30),a=r-rr[i]+1;return new q(this,n,i+1,a)}toJulianDay(e){let t=1948319+365*(e.year-1)+Math.floor((8*e.year+21)/33);return t+=rr[e.month-1],t+=e.day,t}getMonthsInYear(){return 12}getDaysInMonth(e){return e.month<=6?31:e.month<=11||nt(25*e.year+11,33)<8?30:29}getMaximumMonthsInYear(){return 12}getMaximumDaysInMonth(){return 31}getEras(){return[`AP`]}getYearsInEra(){return 9377}constructor(){this.identifier=`persian`}},ar=78,or=80,sr=class extends B{fromJulianDay(e){let t=super.fromJulianDay(e),n=t.year-ar,r=e-it(t.era,t.year,1,1),i;r=8&&(i+=(e.month-7)*30),i+=e.day-1,i)}getDaysInMonth(e){return e.month===1&&at(e.year+ar)||e.month>=2&&e.month<=6?31:30}getYearsInEra(){return 9919}getEras(){return[`saka`]}balanceDate(){}constructor(...e){super(...e),this.identifier=`indian`}},cr=1948440,lr=1948439,J=1300,ur=1600,dr=460322;function fr(e,t,n,r){return r+Math.ceil(29.5*(n-1))+(t-1)*354+Math.floor((3+11*t)/30)+e-1}function pr(e,t,n){let r=Math.floor((30*(n-t)+10646)/10631),i=Math.min(12,Math.ceil((n-(29+fr(t,r,1,1)))/29.5)+1);return new q(e,r,i,n-fr(t,r,i,1)+1)}function mr(e){return(14+11*e)%30<11}var hr=class{fromJulianDay(e){return pr(this,cr,e)}toJulianDay(e){return fr(cr,e.year,e.month,e.day)}getDaysInMonth(e){let t=29+e.month%2;return e.month===12&&mr(e.year)&&t++,t}getMonthsInYear(){return 12}getDaysInYear(e){return mr(e.year)?355:354}getMaximumMonthsInYear(){return 12}getMaximumDaysInMonth(){return 30}getYearsInEra(){return 9665}getEras(){return[`AH`]}constructor(){this.identifier=`islamic-civil`}},gr=class extends hr{fromJulianDay(e){return pr(this,lr,e)}toJulianDay(e){return fr(lr,e.year,e.month,e.day)}constructor(...e){super(...e),this.identifier=`islamic-tbla`}},_r=`qgpUDckO1AbqBmwDrQpVBakGkgepC9QF2gpcBS0NlQZKB1QLagutBa4ETwoXBYsGpQbVCtYCWwmdBE0KJg2VDawFtgm6AlsKKwWVCsoG6Qr0AnYJtgJWCcoKpAvSC9kF3AJtCU0FpQpSC6ULtAW2CVcFlwJLBaMGUgdlC2oFqworBZUMSg2lDcoF1gpXCasESwmlClILagt1BXYCtwhbBFUFqQW0BdoJ3QRuAjYJqgpUDbIN1QXaAlsJqwRVCkkLZAtxC7QFtQpVCiUNkg7JDtQG6QprCasEkwpJDaQNsg25CroEWworBZUKKgtVC1wFvQQ9Ah0JlQpKC1oLbQW2AjsJmwRVBqkGVAdqC2wFrQpVBSkLkgupC9QF2gpaBasKlQVJB2QHqgu1BbYCVgpNDiULUgtqC60FrgIvCZcESwalBqwG1gpdBZ0ETQoWDZUNqgW1BdoCWwmtBJUFygbkBuoK9QS2AlYJqgpUC9IL2QXqAm0JrQSVCkoLpQuyBbUJ1gSXCkcFkwZJB1ULagVrCisFiwpGDaMNygXWCtsEawJLCaUKUgtpC3UFdgG3CFsCKwVlBbQF2gntBG0BtgimClINqQ3UBdoKWwmrBFMGKQdiB6kLsgW1ClUFJQuSDckO0gbpCmsFqwRVCikNVA2qDbUJugQ7CpsETQqqCtUK2gJdCV4ELgqaDFUNsga5BroEXQotBZUKUguoC7QLuQXaAloJSgukDdEO6AZqC20FNQWVBkoNqA3UDdoGWwWdAisGFQtKC5ULqgWuCi4JjwwnBZUGqgbWCl0FnQI=`,vr,yr;function br(e){return dr+yr[e-J]}function xr(e,t){let n=e-J,r=1<<11-(t-1);return(vr[n]&r)===0?29:30}function Sr(e,t){let n=br(e);for(let r=1;re.charCodeAt(0)).buffer),!yr){yr=new Uint32Array(301);let e=0;for(let t=J;t<=ur;t++){yr[t-J]=e;for(let n=1;n<=12;n++)e+=xr(t,n)}}}fromJulianDay(e){let t=e-cr,n=br(J),r=br(ur);if(tr)return super.fromJulianDay(e);{let e=1299,n=1,r=1;for(;r>0;){e++,r=t-br(e)+1;let i=Cr(e);if(r===i){n=12;break}if(rt;)r-=t,n++,t=xr(e,n);break}}return new q(this,e,n,t-Sr(e,n)+1)}}toJulianDay(e){return e.yearur?super.toJulianDay(e):cr+Sr(e.year,e.month)+(e.day-1)}getDaysInMonth(e){return e.yearur?super.getDaysInMonth(e):xr(e.year,e.month)}getDaysInYear(e){return e.yearur?super.getDaysInYear(e):Cr(e.year)}},Tr=347997,Er=25920,Dr=765433;function Or(e){return nt(e*7+1,19)<7}function kr(e){let t=Math.floor((235*e-234)/19),n=12084+13753*t,r=t*29+Math.floor(n/25920);return nt(3*(r+1),7)<3&&(r+=1),r}function Ar(e){let t=kr(e-1),n=kr(e);return kr(e+1)-n===356?2:+(n-t===382)}function jr(e){return kr(e)+Ar(e)}function Mr(e){return jr(e+1)-jr(e)}function Nr(e){let t=Mr(e);switch(t>380&&(t-=30),t){case 353:return 0;case 354:return 1;case 355:return 2}}function Pr(e,t){if(t>=6&&!Or(e)&&t++,t===4||t===7||t===9||t===11||t===13)return 29;let n=Nr(e);return t===2?n===2?30:29:t===3?n===0?29:30:t===6?Or(e)?30:0:30}var Fr=class{fromJulianDay(e){let t=e-Tr,n=t*Er/Dr,r=Math.floor((19*n+234)/235)+1,i=jr(r),a=Math.floor(t-i);for(;a<1;)r--,i=jr(r),a=Math.floor(t-i);let o=1,s=0;for(;s6?e.month--:!Or(t.year)&&Or(e.year)&&t.month>6&&e.month++)}constructor(){this.identifier=`hebrew`}},Ir=1723856,Lr=1824665,Rr=5500;function zr(e,t,n,r){return e+365*t+Math.floor(t/4)+30*(n-1)+r-1}function Br(e,t){let n=Math.floor(4*(t-e)/1461),r=1+Math.floor((t-zr(e,n,1,1))/30);return[n,r,t+1-zr(e,n,r,1)]}function Vr(e){return Math.floor(e%4/3)}function Hr(e,t){return t%13==0?Vr(e)+5:30}var Ur=class{fromJulianDay(e){let[t,n,r]=Br(Ir,e),i=`AM`;return t<=0&&(i=`AA`,t+=Rr),new q(this,i,t,n,r)}toJulianDay(e){let t=e.year;return e.era===`AA`&&(t-=Rr),zr(Ir,t,e.month,e.day)}getDaysInMonth(e){return Hr(e.year,e.month)}getMonthsInYear(){return 13}getDaysInYear(e){return 365+Vr(e.year)}getMaximumMonthsInYear(){return 13}getMaximumDaysInMonth(){return 30}getYearsInEra(e){return e.era===`AA`?9999:9991}getEras(){return[`AA`,`AM`]}constructor(){this.identifier=`ethiopic`}},Wr=class extends Ur{fromJulianDay(e){let[t,n,r]=Br(Ir,e);return t+=Rr,new q(this,`AA`,t,n,r)}getEras(){return[`AA`]}getYearsInEra(){return 9999}constructor(...e){super(...e),this.identifier=`ethioaa`}},Gr=class extends Ur{fromJulianDay(e){let[t,n,r]=Br(Lr,e),i=`CE`;return t<=0&&(i=`BCE`,t=1-t),new q(this,i,t,n,r)}toJulianDay(e){let t=e.year;return e.era===`BCE`&&(t=1-t),zr(Lr,t,e.month,e.day)}getDaysInMonth(e){let t=e.year;return e.era===`BCE`&&(t=1-t),Hr(t,e.month)}isInverseEra(e){return e.era===`BCE`}balanceDate(e){e.year<=0&&(e.era=e.era===`BCE`?`CE`:`BCE`,e.year=1-e.year)}getEras(){return[`BCE`,`CE`]}getYearsInEra(e){return e.era===`BCE`?9999:9715}constructor(...e){super(...e),this.identifier=`coptic`}};function Kr(e){switch(e){case`buddhist`:return new Yn;case`ethiopic`:return new Ur;case`ethioaa`:return new Wr;case`coptic`:return new Gr;case`hebrew`:return new Fr;case`indian`:return new sr;case`islamic-civil`:return new hr;case`islamic-tbla`:return new gr;case`islamic-umalqura`:return new wr;case`japanese`:return new Kn;case`persian`:return new ir;case`roc`:return new er;default:return new B}}var qr=new Map,Y=class{constructor(e,t={}){this.formatter=Yr(e,t),this.options=t}format(e){return this.formatter.format(e)}formatToParts(e){return this.formatter.formatToParts(e)}formatRange(e,t){if(typeof this.formatter.formatRange==`function`)return this.formatter.formatRange(e,t);if(t= start date`);return`${this.formatter.format(e)} \u{2013} ${this.formatter.format(t)}`}formatRangeToParts(e,t){if(typeof this.formatter.formatRangeToParts==`function`)return this.formatter.formatRangeToParts(e,t);if(t= start date`);let n=this.formatter.formatToParts(e),r=this.formatter.formatToParts(t);return[...n.map(e=>({...e,source:`startRange`})),{type:`literal`,value:` – `,source:`shared`},...r.map(e=>({...e,source:`endRange`}))]}resolvedOptions(){let e=this.formatter.resolvedOptions();return $r()&&(this.resolvedHourCycle||=ei(e.locale,this.options),e.hourCycle=this.resolvedHourCycle,e.hour12=this.resolvedHourCycle===`h11`||this.resolvedHourCycle===`h12`),e.calendar===`ethiopic-amete-alem`&&(e.calendar=`ethioaa`),e}},Jr={true:{ja:`h11`},false:{}};function Yr(e,t={}){if(typeof t.hour12==`boolean`&&Zr()){t={...t};let n=Jr[String(t.hour12)][e.split(`-`)[0]],r=t.hour12?`h12`:`h23`;t.hourCycle=n??r,delete t.hour12}let n=e+(t?Object.entries(t).sort((e,t)=>e[0]e.type===`hour`).value,10),i=parseInt(n.formatToParts(new Date(2020,2,3,23)).find(e=>e.type===`hour`).value,10);if(r===0&&i===23)return`h23`;if(r===24&&i===23)return`h24`;if(r===0&&i===11)return`h11`;if(r===12&&i===11)return`h12`;throw Error(`Unexpected hour cycle result`)}var X=n(),ti=[`day`,`month`,`year`],ni={hour:1,minute:2,second:3};function ri(e,t){let{autoComplete:n,isDisabled:r,name:i}=e,{visuallyHiddenProps:a}=ze({style:{position:`fixed`,top:0,left:0}}),o=60;t.granularity===`second`?o=1:t.granularity===`hour`&&(o=3600);let s=``;t.value&&(s=t.granularity===`day`?H(t.value).toString():U(`timeZone`in t.value?$t(t.value):t.value).toString());let c=t.granularity===`day`?`date`:`datetime-local`,l=[`hour`,`minute`,`second`],u=0;return l.includes(t.granularity)&&(u=ni[t.granularity],l=l.slice(0,u)),{containerProps:{...a,"aria-hidden":!0,"data-react-aria-prevent-focus":!0,"data-a11y-ignore":`aria-hidden-focus`},inputProps:{tabIndex:-1,autoComplete:n,disabled:r,type:c,form:``,name:i,step:o,value:s,onChange:e=>{let n=le(e).value.toString();if(n)try{let e=On(n);if(t.granularity===`day`&&(e=Dn(n)),`setSegment`in t)for(let n in e)ti.includes(n)&&t.setSegment(n,e[n]),l.includes(n)&&t.setSegment(n,e[n]);t.setValue(e)}catch{}}}}}function ii(e){let{state:t}=e,{containerProps:n,inputProps:r}=ri({...e},t);return z.createElement(`div`,{...n,"data-testid":`hidden-dateinput-container`},z.createElement(`input`,r))}var ai={};ai={calendar:`التقويم`,day:`يوم`,dayPeriod:`ص/م`,endDate:`تاريخ الانتهاء`,era:`العصر`,hour:`الساعات`,minute:`الدقائق`,month:`الشهر`,second:`الثواني`,selectedDateDescription:e=>`\u{62A}\u{627}\u{631}\u{64A}\u{62E} \u{645}\u{62D}\u{62F}\u{62F}: ${e.date}`,selectedRangeDescription:e=>`\u{627}\u{644}\u{645}\u{62F}\u{649} \u{627}\u{644}\u{632}\u{645}\u{646}\u{64A} \u{627}\u{644}\u{645}\u{62D}\u{62F}\u{62F}: ${e.startDate} \u{625}\u{644}\u{649} ${e.endDate}`,selectedTimeDescription:e=>`\u{627}\u{644}\u{648}\u{642}\u{62A} \u{627}\u{644}\u{645}\u{62D}\u{62F}\u{62F}: ${e.time}`,startDate:`تاريخ البدء`,timeZoneName:`التوقيت`,weekday:`اليوم`,year:`السنة`};var oi={};oi={calendar:`Календар`,day:`ден`,dayPeriod:`пр.об./сл.об.`,endDate:`Крайна дата`,era:`ера`,hour:`час`,minute:`минута`,month:`месец`,second:`секунда`,selectedDateDescription:e=>`\u{418}\u{437}\u{431}\u{440}\u{430}\u{43D}\u{430} \u{434}\u{430}\u{442}\u{430}: ${e.date}`,selectedRangeDescription:e=>`\u{418}\u{437}\u{431}\u{440}\u{430}\u{43D} \u{434}\u{438}\u{430}\u{43F}\u{430}\u{437}\u{43E}\u{43D}: ${e.startDate} \u{434}\u{43E} ${e.endDate}`,selectedTimeDescription:e=>`\u{418}\u{437}\u{431}\u{440}\u{430}\u{43D}\u{43E} \u{432}\u{440}\u{435}\u{43C}\u{435}: ${e.time}`,startDate:`Начална дата`,timeZoneName:`часова зона`,weekday:`ден от седмицата`,year:`година`};var si={};si={calendar:`Kalendář`,day:`den`,dayPeriod:`část dne`,endDate:`Konečné datum`,era:`letopočet`,hour:`hodina`,minute:`minuta`,month:`měsíc`,second:`sekunda`,selectedDateDescription:e=>`Vybran\xe9 datum: ${e.date}`,selectedRangeDescription:e=>`Vybran\xe9 obdob\xed: ${e.startDate} a\u{17E} ${e.endDate}`,selectedTimeDescription:e=>`Vybran\xfd \u{10D}as: ${e.time}`,startDate:`Počáteční datum`,timeZoneName:`časové pásmo`,weekday:`den v týdnu`,year:`rok`};var ci={};ci={calendar:`Kalender`,day:`dag`,dayPeriod:`AM/PM`,endDate:`Slutdato`,era:`æra`,hour:`time`,minute:`minut`,month:`måned`,second:`sekund`,selectedDateDescription:e=>`Valgt dato: ${e.date}`,selectedRangeDescription:e=>`Valgt interval: ${e.startDate} til ${e.endDate}`,selectedTimeDescription:e=>`Valgt tidspunkt: ${e.time}`,startDate:`Startdato`,timeZoneName:`tidszone`,weekday:`ugedag`,year:`år`};var li={};li={calendar:`Kalender`,day:`Tag`,dayPeriod:`Tageshälfte`,endDate:`Enddatum`,era:`Epoche`,hour:`Stunde`,minute:`Minute`,month:`Monat`,second:`Sekunde`,selectedDateDescription:e=>`Ausgew\xe4hltes Datum: ${e.date}`,selectedRangeDescription:e=>`Ausgew\xe4hlter Bereich: ${e.startDate} bis ${e.endDate}`,selectedTimeDescription:e=>`Ausgew\xe4hlte Zeit: ${e.time}`,startDate:`Startdatum`,timeZoneName:`Zeitzone`,weekday:`Wochentag`,year:`Jahr`};var ui={};ui={calendar:`Ημερολόγιο`,day:`ημέρα`,dayPeriod:`π.μ./μ.μ.`,endDate:`Ημερομηνία λήξης`,era:`περίοδος`,hour:`ώρα`,minute:`λεπτό`,month:`μήνας`,second:`δευτερόλεπτο`,selectedDateDescription:e=>`\u{395}\u{3C0}\u{3B9}\u{3BB}\u{3B5}\u{3B3}\u{3BC}\u{3AD}\u{3BD}\u{3B7} \u{3B7}\u{3BC}\u{3B5}\u{3C1}\u{3BF}\u{3BC}\u{3B7}\u{3BD}\u{3AF}\u{3B1}: ${e.date}`,selectedRangeDescription:e=>`\u{395}\u{3C0}\u{3B9}\u{3BB}\u{3B5}\u{3B3}\u{3BC}\u{3AD}\u{3BD}\u{3BF} \u{3B5}\u{3CD}\u{3C1}\u{3BF}\u{3C2}: ${e.startDate} \u{3AD}\u{3C9}\u{3C2} ${e.endDate}`,selectedTimeDescription:e=>`\u{395}\u{3C0}\u{3B9}\u{3BB}\u{3B5}\u{3B3}\u{3BC}\u{3AD}\u{3BD}\u{3B7} \u{3CE}\u{3C1}\u{3B1}: ${e.time}`,startDate:`Ημερομηνία έναρξης`,timeZoneName:`ζώνη ώρας`,weekday:`καθημερινή`,year:`έτος`};var di={};di={era:`era`,year:`year`,month:`month`,day:`day`,hour:`hour`,minute:`minute`,second:`second`,dayPeriod:`AM/PM`,calendar:`Calendar`,startDate:`Start Date`,endDate:`End Date`,weekday:`day of the week`,timeZoneName:`time zone`,selectedDateDescription:e=>`Selected Date: ${e.date}`,selectedRangeDescription:e=>`Selected Range: ${e.startDate} to ${e.endDate}`,selectedTimeDescription:e=>`Selected Time: ${e.time}`};var fi={};fi={calendar:`Calendario`,day:`día`,dayPeriod:`a.\xA0m./p.\xA0m.`,endDate:`Fecha final`,era:`era`,hour:`hora`,minute:`minuto`,month:`mes`,second:`segundo`,selectedDateDescription:e=>`Fecha seleccionada: ${e.date}`,selectedRangeDescription:e=>`Rango seleccionado: ${e.startDate} a ${e.endDate}`,selectedTimeDescription:e=>`Hora seleccionada: ${e.time}`,startDate:`Fecha de inicio`,timeZoneName:`zona horaria`,weekday:`día de la semana`,year:`año`};var pi={};pi={calendar:`Kalender`,day:`päev`,dayPeriod:`enne/pärast lõunat`,endDate:`Lõppkuupäev`,era:`ajastu`,hour:`tund`,minute:`minut`,month:`kuu`,second:`sekund`,selectedDateDescription:e=>`Valitud kuup\xe4ev: ${e.date}`,selectedRangeDescription:e=>`Valitud vahemik: ${e.startDate} kuni ${e.endDate}`,selectedTimeDescription:e=>`Valitud aeg: ${e.time}`,startDate:`Alguskuupäev`,timeZoneName:`ajavöönd`,weekday:`nädalapäev`,year:`aasta`};var mi={};mi={calendar:`Kalenteri`,day:`päivä`,dayPeriod:`vuorokaudenaika`,endDate:`Päättymispäivä`,era:`aikakausi`,hour:`tunti`,minute:`minuutti`,month:`kuukausi`,second:`sekunti`,selectedDateDescription:e=>`Valittu p\xe4iv\xe4m\xe4\xe4r\xe4: ${e.date}`,selectedRangeDescription:e=>`Valittu aikav\xe4li: ${e.startDate} \u{2013} ${e.endDate}`,selectedTimeDescription:e=>`Valittu aika: ${e.time}`,startDate:`Alkamispäivä`,timeZoneName:`aikavyöhyke`,weekday:`viikonpäivä`,year:`vuosi`};var hi={};hi={calendar:`Calendrier`,day:`jour`,dayPeriod:`cadran`,endDate:`Date de fin`,era:`ère`,hour:`heure`,minute:`minute`,month:`mois`,second:`seconde`,selectedDateDescription:e=>`Date s\xe9lectionn\xe9e\xa0: ${e.date}`,selectedRangeDescription:e=>`Plage s\xe9lectionn\xe9e\xa0: ${e.startDate} au ${e.endDate}`,selectedTimeDescription:e=>`Heure choisie\xa0: ${e.time}`,startDate:`Date de début`,timeZoneName:`fuseau horaire`,weekday:`jour de la semaine`,year:`année`};var gi={};gi={calendar:`לוח שנה`,day:`יום`,dayPeriod:`לפנה״צ/אחה״צ`,endDate:`תאריך סיום`,era:`תקופה`,hour:`שעה`,minute:`דקה`,month:`חודש`,second:`שנייה`,selectedDateDescription:e=>`\u{5EA}\u{5D0}\u{5E8}\u{5D9}\u{5DA} \u{5E0}\u{5D1}\u{5D7}\u{5E8}: ${e.date}`,selectedRangeDescription:e=>`\u{5D8}\u{5D5}\u{5D5}\u{5D7} \u{5E0}\u{5D1}\u{5D7}\u{5E8}: ${e.startDate} \u{5E2}\u{5D3} ${e.endDate}`,selectedTimeDescription:e=>`\u{5D6}\u{5DE}\u{5DF} \u{5E0}\u{5D1}\u{5D7}\u{5E8}: ${e.time}`,startDate:`תאריך התחלה`,timeZoneName:`אזור זמן`,weekday:`יום בשבוע`,year:`שנה`};var _i={};_i={calendar:`Kalendar`,day:`dan`,dayPeriod:`AM/PM`,endDate:`Datum završetka`,era:`era`,hour:`sat`,minute:`minuta`,month:`mjesec`,second:`sekunda`,selectedDateDescription:e=>`Odabrani datum: ${e.date}`,selectedRangeDescription:e=>`Odabrani raspon: ${e.startDate} do ${e.endDate}`,selectedTimeDescription:e=>`Odabrano vrijeme: ${e.time}`,startDate:`Datum početka`,timeZoneName:`vremenska zona`,weekday:`dan u tjednu`,year:`godina`};var vi={};vi={calendar:`Naptár`,day:`nap`,dayPeriod:`napszak`,endDate:`Befejező dátum`,era:`éra`,hour:`óra`,minute:`perc`,month:`hónap`,second:`másodperc`,selectedDateDescription:e=>`Kijel\xf6lt d\xe1tum: ${e.date}`,selectedRangeDescription:e=>`Kijel\xf6lt tartom\xe1ny: ${e.startDate}\u{2013}${e.endDate}`,selectedTimeDescription:e=>`Kijel\xf6lt id\u{151}: ${e.time}`,startDate:`Kezdő dátum`,timeZoneName:`időzóna`,weekday:`hét napja`,year:`év`};var yi={};yi={calendar:`Calendario`,day:`giorno`,dayPeriod:`AM/PM`,endDate:`Data finale`,era:`era`,hour:`ora`,minute:`minuto`,month:`mese`,second:`secondo`,selectedDateDescription:e=>`Data selezionata: ${e.date}`,selectedRangeDescription:e=>`Intervallo selezionato: da ${e.startDate} a ${e.endDate}`,selectedTimeDescription:e=>`Ora selezionata: ${e.time}`,startDate:`Data iniziale`,timeZoneName:`fuso orario`,weekday:`giorno della settimana`,year:`anno`};var bi={};bi={calendar:`カレンダー`,day:`日`,dayPeriod:`午前/午後`,endDate:`終了日`,era:`時代`,hour:`時`,minute:`分`,month:`月`,second:`秒`,selectedDateDescription:e=>`\u{9078}\u{629E}\u{3057}\u{305F}\u{65E5}\u{4ED8} : ${e.date}`,selectedRangeDescription:e=>`\u{9078}\u{629E}\u{7BC4}\u{56F2} : ${e.startDate} \u{304B}\u{3089} ${e.endDate}`,selectedTimeDescription:e=>`\u{9078}\u{629E}\u{3057}\u{305F}\u{6642}\u{9593} : ${e.time}`,startDate:`開始日`,timeZoneName:`タイムゾーン`,weekday:`曜日`,year:`年`};var xi={};xi={calendar:`달력`,day:`일`,dayPeriod:`오전/오후`,endDate:`종료일`,era:`연호`,hour:`시`,minute:`분`,month:`월`,second:`초`,selectedDateDescription:e=>`\u{C120}\u{D0DD} \u{C77C}\u{C790}: ${e.date}`,selectedRangeDescription:e=>`\u{C120}\u{D0DD} \u{BC94}\u{C704}: ${e.startDate} ~ ${e.endDate}`,selectedTimeDescription:e=>`\u{C120}\u{D0DD} \u{C2DC}\u{AC04}: ${e.time}`,startDate:`시작일`,timeZoneName:`시간대`,weekday:`요일`,year:`년`};var Si={};Si={calendar:`Kalendorius`,day:`diena`,dayPeriod:`iki pietų / po pietų`,endDate:`Pabaigos data`,era:`era`,hour:`valanda`,minute:`minutė`,month:`mėnuo`,second:`sekundė`,selectedDateDescription:e=>`Pasirinkta data: ${e.date}`,selectedRangeDescription:e=>`Pasirinktas intervalas: nuo ${e.startDate} iki ${e.endDate}`,selectedTimeDescription:e=>`Pasirinktas laikas: ${e.time}`,startDate:`Pradžios data`,timeZoneName:`laiko juosta`,weekday:`savaitės diena`,year:`metai`};var Ci={};Ci={calendar:`Kalendārs`,day:`diena`,dayPeriod:`priekšpusdienā/pēcpusdienā`,endDate:`Beigu datums`,era:`ēra`,hour:`stundas`,minute:`minūtes`,month:`mēnesis`,second:`sekundes`,selectedDateDescription:e=>`Atlas\u{12B}tais datums: ${e.date}`,selectedRangeDescription:e=>`Atlas\u{12B}tais diapazons: no ${e.startDate} l\u{12B}dz ${e.endDate}`,selectedTimeDescription:e=>`Atlas\u{12B}tais laiks: ${e.time}`,startDate:`Sākuma datums`,timeZoneName:`laika josla`,weekday:`nedēļas diena`,year:`gads`};var wi={};wi={calendar:`Kalender`,day:`dag`,dayPeriod:`a.m./p.m.`,endDate:`Sluttdato`,era:`tidsalder`,hour:`time`,minute:`minutt`,month:`måned`,second:`sekund`,selectedDateDescription:e=>`Valgt dato: ${e.date}`,selectedRangeDescription:e=>`Valgt omr\xe5de: ${e.startDate} til ${e.endDate}`,selectedTimeDescription:e=>`Valgt tid: ${e.time}`,startDate:`Startdato`,timeZoneName:`tidssone`,weekday:`ukedag`,year:`år`};var Ti={};Ti={calendar:`Kalender`,day:`dag`,dayPeriod:`a.m./p.m.`,endDate:`Einddatum`,era:`tijdperk`,hour:`uur`,minute:`minuut`,month:`maand`,second:`seconde`,selectedDateDescription:e=>`Geselecteerde datum: ${e.date}`,selectedRangeDescription:e=>`Geselecteerd bereik: ${e.startDate} tot ${e.endDate}`,selectedTimeDescription:e=>`Geselecteerde tijd: ${e.time}`,startDate:`Startdatum`,timeZoneName:`tijdzone`,weekday:`dag van de week`,year:`jaar`};var Ei={};Ei={calendar:`Kalendarz`,day:`dzień`,dayPeriod:`rano / po południu / wieczorem`,endDate:`Data końcowa`,era:`era`,hour:`godzina`,minute:`minuta`,month:`miesiąc`,second:`sekunda`,selectedDateDescription:e=>`Wybrana data: ${e.date}`,selectedRangeDescription:e=>`Wybrany zakres: ${e.startDate} do ${e.endDate}`,selectedTimeDescription:e=>`Wybrany czas: ${e.time}`,startDate:`Data początkowa`,timeZoneName:`strefa czasowa`,weekday:`dzień tygodnia`,year:`rok`};var Di={};Di={calendar:`Calendário`,day:`dia`,dayPeriod:`AM/PM`,endDate:`Data final`,era:`era`,hour:`hora`,minute:`minuto`,month:`mês`,second:`segundo`,selectedDateDescription:e=>`Data selecionada: ${e.date}`,selectedRangeDescription:e=>`Intervalo selecionado: ${e.startDate} a ${e.endDate}`,selectedTimeDescription:e=>`Hora selecionada: ${e.time}`,startDate:`Data inicial`,timeZoneName:`fuso horário`,weekday:`dia da semana`,year:`ano`};var Oi={};Oi={calendar:`Calendário`,day:`dia`,dayPeriod:`am/pm`,endDate:`Data de Término`,era:`era`,hour:`hora`,minute:`minuto`,month:`mês`,second:`segundo`,selectedDateDescription:e=>`Data selecionada: ${e.date}`,selectedRangeDescription:e=>`Intervalo selecionado: ${e.startDate} a ${e.endDate}`,selectedTimeDescription:e=>`Hora selecionada: ${e.time}`,startDate:`Data de Início`,timeZoneName:`fuso horário`,weekday:`dia da semana`,year:`ano`};var ki={};ki={calendar:`Calendar`,day:`zi`,dayPeriod:`a.m/p.m.`,endDate:`Dată final`,era:`eră`,hour:`oră`,minute:`minut`,month:`lună`,second:`secundă`,selectedDateDescription:e=>`Dat\u{103} selectat\u{103}: ${e.date}`,selectedRangeDescription:e=>`Interval selectat: de la ${e.startDate} p\xe2n\u{103} la ${e.endDate}`,selectedTimeDescription:e=>`Ora selectat\u{103}: ${e.time}`,startDate:`Dată început`,timeZoneName:`fus orar`,weekday:`ziua din săptămână`,year:`an`};var Ai={};Ai={calendar:`Календарь`,day:`день`,dayPeriod:`AM/PM`,endDate:`Дата окончания`,era:`эра`,hour:`час`,minute:`минута`,month:`месяц`,second:`секунда`,selectedDateDescription:e=>`\u{412}\u{44B}\u{431}\u{440}\u{430}\u{43D}\u{43D}\u{430}\u{44F} \u{434}\u{430}\u{442}\u{430}: ${e.date}`,selectedRangeDescription:e=>`\u{412}\u{44B}\u{431}\u{440}\u{430}\u{43D}\u{43D}\u{44B}\u{439} \u{434}\u{438}\u{430}\u{43F}\u{430}\u{437}\u{43E}\u{43D}: \u{441} ${e.startDate} \u{43F}\u{43E} ${e.endDate}`,selectedTimeDescription:e=>`\u{412}\u{44B}\u{431}\u{440}\u{430}\u{43D}\u{43D}\u{43E}\u{435} \u{432}\u{440}\u{435}\u{43C}\u{44F}: ${e.time}`,startDate:`Дата начала`,timeZoneName:`часовой пояс`,weekday:`день недели`,year:`год`};var ji={};ji={calendar:`Kalendár`,day:`deň`,dayPeriod:`AM/PM`,endDate:`Dátum ukončenia`,era:`letopočet`,hour:`hodina`,minute:`minúta`,month:`mesiac`,second:`sekunda`,selectedDateDescription:e=>`Vybrat\xfd d\xe1tum: ${e.date}`,selectedRangeDescription:e=>`Vybrat\xfd rozsah: od ${e.startDate} do ${e.endDate}`,selectedTimeDescription:e=>`Vybrat\xfd \u{10D}as: ${e.time}`,startDate:`Dátum začatia`,timeZoneName:`časové pásmo`,weekday:`deň týždňa`,year:`rok`};var Mi={};Mi={calendar:`Koledar`,day:`dan`,dayPeriod:`dop/pop`,endDate:`Datum konca`,era:`doba`,hour:`ura`,minute:`minuta`,month:`mesec`,second:`sekunda`,selectedDateDescription:e=>`Izbrani datum: ${e.date}`,selectedRangeDescription:e=>`Izbrano obmo\u{10D}je: ${e.startDate} do ${e.endDate}`,selectedTimeDescription:e=>`Izbrani \u{10D}as: ${e.time}`,startDate:`Datum začetka`,timeZoneName:`časovni pas`,weekday:`dan v tednu`,year:`leto`};var Ni={};Ni={calendar:`Kalendar`,day:`дан`,dayPeriod:`пре подне/по подне`,endDate:`Datum završetka`,era:`ера`,hour:`сат`,minute:`минут`,month:`месец`,second:`секунд`,selectedDateDescription:e=>`Izabrani datum: ${e.date}`,selectedRangeDescription:e=>`Izabrani opseg: od ${e.startDate} do ${e.endDate}`,selectedTimeDescription:e=>`Izabrano vreme: ${e.time}`,startDate:`Datum početka`,timeZoneName:`временска зона`,weekday:`дан у недељи`,year:`година`};var Pi={};Pi={calendar:`Kalender`,day:`dag`,dayPeriod:`fm/em`,endDate:`Slutdatum`,era:`era`,hour:`timme`,minute:`minut`,month:`månad`,second:`sekund`,selectedDateDescription:e=>`Valt datum: ${e.date}`,selectedRangeDescription:e=>`Valt intervall: ${e.startDate} till ${e.endDate}`,selectedTimeDescription:e=>`Vald tid: ${e.time}`,startDate:`Startdatum`,timeZoneName:`tidszon`,weekday:`veckodag`,year:`år`};var Fi={};Fi={calendar:`Takvim`,day:`gün`,dayPeriod:`ÖÖ/ÖS`,endDate:`Bitiş Tarihi`,era:`çağ`,hour:`saat`,minute:`dakika`,month:`ay`,second:`saniye`,selectedDateDescription:e=>`Se\xe7ilen Tarih: ${e.date}`,selectedRangeDescription:e=>`Se\xe7ilen Aral\u{131}k: ${e.startDate} - ${e.endDate}`,selectedTimeDescription:e=>`Se\xe7ilen Zaman: ${e.time}`,startDate:`Başlangıç Tarihi`,timeZoneName:`saat dilimi`,weekday:`haftanın günü`,year:`yıl`};var Ii={};Ii={calendar:`Календар`,day:`день`,dayPeriod:`дп/пп`,endDate:`Дата завершення`,era:`ера`,hour:`година`,minute:`хвилина`,month:`місяць`,second:`секунда`,selectedDateDescription:e=>`\u{412}\u{438}\u{431}\u{440}\u{430}\u{43D}\u{430} \u{434}\u{430}\u{442}\u{430}: ${e.date}`,selectedRangeDescription:e=>`\u{412}\u{438}\u{431}\u{440}\u{430}\u{43D}\u{438}\u{439} \u{434}\u{456}\u{430}\u{43F}\u{430}\u{437}\u{43E}\u{43D}: ${e.startDate} \u{2014} ${e.endDate}`,selectedTimeDescription:e=>`\u{412}\u{438}\u{431}\u{440}\u{430}\u{43D}\u{438}\u{439} \u{447}\u{430}\u{441}: ${e.time}`,startDate:`Дата початку`,timeZoneName:`часовий пояс`,weekday:`день тижня`,year:`рік`};var Li={};Li={calendar:`日历`,day:`日`,dayPeriod:`上午/下午`,endDate:`结束日期`,era:`纪元`,hour:`小时`,minute:`分钟`,month:`月`,second:`秒`,selectedDateDescription:e=>`\u{9009}\u{5B9A}\u{7684}\u{65E5}\u{671F}\u{FF1A}${e.date}`,selectedRangeDescription:e=>`\u{9009}\u{5B9A}\u{7684}\u{8303}\u{56F4}\u{FF1A}${e.startDate} \u{81F3} ${e.endDate}`,selectedTimeDescription:e=>`\u{9009}\u{5B9A}\u{7684}\u{65F6}\u{95F4}\u{FF1A}${e.time}`,startDate:`开始日期`,timeZoneName:`时区`,weekday:`工作日`,year:`年`};var Ri={};Ri={calendar:`日曆`,day:`日`,dayPeriod:`上午/下午`,endDate:`結束日期`,era:`纪元`,hour:`小时`,minute:`分钟`,month:`月`,second:`秒`,selectedDateDescription:e=>`\u{9078}\u{5B9A}\u{7684}\u{65E5}\u{671F}\u{FF1A}${e.date}`,selectedRangeDescription:e=>`\u{9078}\u{5B9A}\u{7684}\u{7BC4}\u{570D}\u{FF1A}${e.startDate} \u{81F3} ${e.endDate}`,selectedTimeDescription:e=>`\u{9078}\u{5B9A}\u{7684}\u{6642}\u{9593}\u{FF1A}${e.time}`,startDate:`開始日期`,timeZoneName:`时区`,weekday:`工作日`,year:`年`};var zi={};zi={"ar-AE":ai,"bg-BG":oi,"cs-CZ":si,"da-DK":ci,"de-DE":li,"el-GR":ui,"en-US":di,"es-ES":fi,"et-EE":pi,"fi-FI":mi,"fr-FR":hi,"he-IL":gi,"hr-HR":_i,"hu-HU":vi,"it-IT":yi,"ja-JP":bi,"ko-KR":xi,"lt-LT":Si,"lv-LV":Ci,"nb-NO":wi,"nl-NL":Ti,"pl-PL":Ei,"pt-BR":Di,"pt-PT":Oi,"ro-RO":ki,"ru-RU":Ai,"sk-SK":ji,"sl-SI":Mi,"sr-SP":Ni,"sv-SE":Pi,"tr-TR":Fi,"uk-UA":Ii,"zh-CN":Li,"zh-TW":Ri};function Bi(e,t,n){let{direction:r}=F(),i=(0,z.useMemo)(()=>ce(t),[t]),{keyboardProps:a}=fe({shortcuts:{"Alt+ArrowDown":()=>{if(`setOpen`in e){e.setOpen(!0);return}return!1},"Alt+ArrowUp":()=>{if(`setOpen`in e){e.setOpen(!0);return}return!1},ArrowLeft:e=>{if(n)return!1;if(r===`rtl`){if(t.current){let n=le(e),r=Vi(t.current,n.getBoundingClientRect().left,-1);if(r){r.focus();return}}}else{i.focusPrevious();return}return!1},ArrowRight:e=>{if(n)return!1;if(r===`rtl`){if(t.current){let n=le(e),r=Vi(t.current,n.getBoundingClientRect().left,1);if(r){r.focus();return}}}else{i.focusNext();return}return!1}},allowRepeats:!0}),o=()=>{if(!t.current)return;let e=window.event?le(window.event):null,n=ne(t.current,{tabbable:!0});if(e&&=(n.currentNode=e,n.previousNode()),!e){let t;do t=n.lastChild(),t&&(e=t);while(t)}for(;e?.hasAttribute(`data-placeholder`);){let t=n.previousNode();if(t&&t.hasAttribute(`data-placeholder`))e=t;else break}e&&e.focus()},{pressProps:s}=se({preventFocusOnPress:!0,allowTextSelectionOnPress:!0,onPressStart(e){e.pointerType===`mouse`&&o()},onPress(e){(e.pointerType===`touch`||e.pointerType===`pen`)&&o()}});return T(s,a)}function Vi(e,t,n){let r=ne(e,{tabbable:!0}),i=r.nextNode(),a=null,o=1/0;for(;i;){let e=i.getBoundingClientRect().left-t,s=Math.abs(e);Math.sign(e)===n&&s{t.confirmPlaceholder(),t.value!==d.current&&t.commitValidation(),e.onBlur?.(n)},onFocusWithinChange:e.onFocusChange}),p=i(Hi(zi),`@react-aria/datepicker`),m=t.maxGranularity===`hour`?`selectedTimeDescription`:`selectedDateDescription`,h=t.maxGranularity===`hour`?`time`:`date`,g=t.value?p.format(m,{[h]:t.formatValue({month:`long`})}):``,_=Re(g),v=e.__reactAriaDateFieldRole===`presentation`?c[`aria-describedby`]:[_[`aria-describedby`],c[`aria-describedby`]].filter(Boolean).join(` `)||void 0,y=e[Gi],b=(0,z.useMemo)(()=>y||ce(n),[y,n]),x=Bi(t,n,e[Wi]===`presentation`);Ui.set(t,{ariaLabel:e[`aria-label`],ariaLabelledBy:[s.id,e[`aria-labelledby`]].filter(Boolean).join(` `)||void 0,ariaDescribedBy:v,focusManager:b});let S=(0,z.useRef)(e.autoFocus),C;C=e.__reactAriaDateFieldRole===`presentation`?{role:`presentation`}:T(c,{role:`group`,"aria-disabled":e.isDisabled||void 0,"aria-describedby":v}),(0,z.useEffect)(()=>{S.current&&b.focusFirst(),S.current=!1},[b]),Ae(e.inputRef,t.defaultValue,t.setValue),xe({...e,focus(){b.focusFirst()}},t,e.inputRef);let w={type:`hidden`,name:e.name,form:e.form,value:t.value?.toString()||``,disabled:e.isDisabled};e.validationBehavior===`native`&&(w.type=`text`,w.hidden=!0,w.required=e.isRequired,w.onChange=()=>{});let E=L(e);return{labelProps:{...s,onClick:()=>{b.focusFirst()}},fieldProps:T(E,C,x,f,{onKeyDown:e.onKeyDown,onKeyUp:e.onKeyUp,style:{unicodeBidi:`isolate`}}),inputProps:w,descriptionProps:l,errorMessageProps:u,isInvalid:r,validationErrors:a,validationDetails:o}}function qi(e,t,n){let r=Ki(e,t,n);return r.inputProps.value=t.timeValue?.toString()||``,r}function Z(e){e=Je(e??{},Ji);let{locale:t}=F();return(0,z.useMemo)(()=>new Y(t,e),[t,e])}function Ji(e,t){if(e===t)return!0;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(t[r]!==e[r])return!1;return!0}function Yi(e){return e&&e.__esModule?e.default:e}function Xi(){let{locale:e}=F(),t=a(Yi(zi),`@react-aria/datepicker`);return(0,z.useMemo)(()=>{try{return new Intl.DisplayNames(e,{type:`dateTimeField`})}catch{return new Zi(e,t)}},[e,t])}var Zi=class{constructor(e,t){this.locale=e,this.dictionary=t}of(e){return this.dictionary.getStringForLocale(e,this.locale)}};function Qi(e,t,n){let r=(0,z.useRef)(``),{locale:i,direction:a}=F(),o=Xi(),{ariaLabel:s,ariaLabelledBy:c,ariaDescribedBy:l,focusManager:u}=Ui.get(t),d=e.isPlaceholder?``:e.text,f=(0,z.useMemo)(()=>t.dateFormatter.resolvedOptions(),[t.dateFormatter]),h=Z({month:`long`,timeZone:f.timeZone}),g=Z({hour:`numeric`,hour12:f.hour12,timeZone:f.timeZone});if(e.type===`month`&&!e.isPlaceholder){let e=h.format(t.dateValue);d=e===d?e:`${d} \u{2013} ${e}`}else e.type===`hour`&&!e.isPlaceholder&&(d=g.format(t.dateValue));let{spinButtonProps:_}=Ne({value:e.value??void 0,textValue:d,minValue:e.minValue,maxValue:e.maxValue,isDisabled:t.isDisabled,isReadOnly:t.isReadOnly||!e.isEditable,isRequired:t.isRequired,onIncrement:()=>{r.current=``,t.increment(e.type)},onDecrement:()=>{r.current=``,t.decrement(e.type)},onIncrementPage:()=>{r.current=``,t.incrementPage(e.type)},onDecrementPage:()=>{r.current=``,t.decrementPage(e.type)},onIncrementToMax:()=>{r.current=``,t.incrementToMax(e.type)},onDecrementToMin:()=>{r.current=``,t.decrementToMin(e.type)}}),y=(0,z.useMemo)(()=>new je(i,{maximumFractionDigits:0}),[i]),b=()=>{if(e.text===e.placeholder&&u.focusPrevious(),y.isValidPartialNumber(e.text)&&!t.isReadOnly&&!e.isPlaceholder){let n=e.text.slice(0,-1),i=y.parse(n);n=i===0?``:n,n.length===0||i===0?t.clearSegment(e.type):t.setSegment(e.type,i),r.current=n}else(e.type===`dayPeriod`||e.type===`era`)&&t.clearSegment(e.type)},{keyboardProps:S}=fe({shortcuts:{Backspace:()=>{b()},Delete:()=>{b()},"Mod+a":()=>{}},allowRepeats:!0}),{startsWith:C}=tt({sensitivity:`base`}),w=Z({hour:`numeric`,hour12:!0}),E=(0,z.useMemo)(()=>{let e=new Date;return e.setHours(0),w.formatToParts(e).find(e=>e.type===`dayPeriod`).value},[w]),D=(0,z.useMemo)(()=>{let e=new Date;return e.setHours(12),w.formatToParts(e).find(e=>e.type===`dayPeriod`).value},[w]),O=Z({year:`numeric`,era:`narrow`,timeZone:`UTC`}),k=(0,z.useMemo)(()=>{if(e.type!==`era`)return[];let n=W(new q(1,1,1),t.calendar),r=t.calendar.getEras().map(e=>{let t=n.set({year:1,month:1,day:1,era:e}).toDate(`UTC`);return{era:e,formatted:O.formatToParts(t).find(e=>e.type===`era`).value}}),i=$i(r.map(e=>e.formatted));if(i)for(let e of r)e.formatted=e.formatted.slice(i);return r},[O,t.calendar,e.type]),A=n=>{if(t.isDisabled||t.isReadOnly)return;let i=r.current+n;switch(e.type){case`dayPeriod`:if(C(E,n))t.setSegment(`dayPeriod`,0);else if(C(D,n))t.setSegment(`dayPeriod`,1);else break;u.focusNext();break;case`era`:{let e=k.find(e=>C(e.formatted,n));e&&(t.setSegment(`era`,e.era),u.focusNext());break}case`day`:case`hour`:case`minute`:case`second`:case`month`:case`year`:{if(!y.isValidPartialNumber(i))return;let a=y.parse(i),o=a;if(e.maxValue!==void 0&&a>e.maxValue&&(o=y.parse(n)),isNaN(a))return;t.setSegment(e.type,o),e.maxValue!==void 0&&(Number(a+`0`)>e.maxValue||i.length>=String(e.maxValue).length)?(r.current=``,u.focusNext()):r.current=i;break}}},ee=()=>{r.current=``,n.current&&Be(n.current,{containingElement:Le(n.current)}),window.getSelection()?.collapse(n.current)},j=(0,z.useRef)(typeof document<`u`?document:null);m(j,`selectionchange`,()=>{let e=window.getSelection();e?.anchorNode&&te(n.current,e?.anchorNode)&&v()===n.current&&e.collapse(n.current)});let ne=(0,z.useRef)(``);m(n,`beforeinput`,r=>{if(n.current)switch(r.preventDefault(),r.inputType){case`deleteContentBackward`:case`deleteContentForward`:y.isValidPartialNumber(e.text)&&!t.isReadOnly&&b();break;case`insertCompositionText`:ne.current=n.current.textContent,n.current.textContent=n.current.textContent;break;default:r.data!=null&&A(r.data)}}),m(n,`input`,e=>{let{inputType:t,data:r}=e;t===`insertCompositionText`&&(n.current&&(n.current.textContent=ne.current),r!=null&&(C(E,r)||C(D,r))&&A(r))}),ie(()=>{let e=n.current;return()=>{v()===e&&(u.focusPrevious()||u.focusNext())}},[n,u]);let M=x()||e.type===`timeZoneName`?{role:`textbox`,"aria-valuemax":null,"aria-valuemin":null,"aria-valuetext":null,"aria-valuenow":null}:{};e!==(0,z.useMemo)(()=>t.segments.find(e=>e.isEditable),[t.segments])&&!t.isInvalid&&(l=void 0);let re=oe(),N=!t.isDisabled&&!t.isReadOnly&&e.isEditable,P=e.type===`literal`?``:o.of(e.type),ae=p({"aria-label":`${P}${s?`, ${s}`:``}${c?`, `:``}`,"aria-labelledby":c});if(e.type===`literal`)return{segmentProps:{"aria-hidden":!0}};let I={caretColor:`transparent`};if(a===`rtl`){I.unicodeBidi=`embed`;let t=f[e.type];(t===`numeric`||t===`2-digit`)&&(I.direction=`ltr`)}return{segmentProps:T(_,ae,{id:re,...M,...S,"aria-invalid":t.isInvalid?`true`:void 0,"aria-describedby":l,"aria-readonly":t.isReadOnly||!e.isEditable?`true`:void 0,"data-placeholder":e.isPlaceholder||void 0,contentEditable:N,suppressContentEditableWarning:N,spellCheck:N?`false`:void 0,autoCorrect:N?`off`:void 0,enterKeyHint:N?`next`:void 0,inputMode:t.isDisabled||e.type===`dayPeriod`||e.type===`era`||!N?void 0:`numeric`,tabIndex:t.isDisabled?void 0:0,onFocus:ee,style:I,onPointerDown(e){e.stopPropagation()},onMouseDown(e){e.stopPropagation()}})}}function $i(e){e.sort();let t=e[0],n=e[e.length-1];for(let e=0;e`\u{64A}\u{62C}\u{628} \u{623}\u{646} \u{62A}\u{643}\u{648}\u{646} \u{627}\u{644}\u{642}\u{64A}\u{645}\u{629} ${e.maxValue} \u{623}\u{648} \u{642}\u{628}\u{644} \u{630}\u{644}\u{643}.`,rangeReversed:`تاريخ البدء يجب أن يكون قبل تاريخ الانتهاء.`,rangeUnderflow:e=>`\u{64A}\u{62C}\u{628} \u{623}\u{646} \u{62A}\u{643}\u{648}\u{646} \u{627}\u{644}\u{642}\u{64A}\u{645}\u{629} ${e.minValue} \u{623}\u{648} \u{628}\u{639}\u{62F} \u{630}\u{644}\u{643}.`,unavailableDate:`البيانات المحددة غير متاحة.`};var ta={};ta={rangeOverflow:e=>`\u{421}\u{442}\u{43E}\u{439}\u{43D}\u{43E}\u{441}\u{442}\u{442}\u{430} \u{442}\u{440}\u{44F}\u{431}\u{432}\u{430} \u{434}\u{430} \u{435} ${e.maxValue} \u{438}\u{43B}\u{438} \u{43F}\u{43E}-\u{440}\u{430}\u{43D}\u{43D}\u{430}.`,rangeReversed:`Началната дата трябва да е преди крайната.`,rangeUnderflow:e=>`\u{421}\u{442}\u{43E}\u{439}\u{43D}\u{43E}\u{441}\u{442}\u{442}\u{430} \u{442}\u{440}\u{44F}\u{431}\u{432}\u{430} \u{434}\u{430} \u{435} ${e.minValue} \u{438}\u{43B}\u{438} \u{43F}\u{43E}-\u{43A}\u{44A}\u{441}\u{43D}\u{43E}.`,unavailableDate:`Избраната дата не е налична.`};var na={};na={rangeOverflow:e=>`Hodnota mus\xed b\xfdt ${e.maxValue} nebo d\u{159}\xedv\u{11B}j\u{161}\xed.`,rangeReversed:`Datum zahájení musí předcházet datu ukončení.`,rangeUnderflow:e=>`Hodnota mus\xed b\xfdt ${e.minValue} nebo pozd\u{11B}j\u{161}\xed.`,unavailableDate:`Vybrané datum není k dispozici.`};var ra={};ra={rangeOverflow:e=>`V\xe6rdien skal v\xe6re ${e.maxValue} eller tidligere.`,rangeReversed:`Startdatoen skal være før slutdatoen.`,rangeUnderflow:e=>`V\xe6rdien skal v\xe6re ${e.minValue} eller nyere.`,unavailableDate:`Den valgte dato er ikke tilgængelig.`};var ia={};ia={rangeOverflow:e=>`Der Wert muss ${e.maxValue} oder fr\xfcher sein.`,rangeReversed:`Das Startdatum muss vor dem Enddatum liegen.`,rangeUnderflow:e=>`Der Wert muss ${e.minValue} oder sp\xe4ter sein.`,unavailableDate:`Das ausgewählte Datum ist nicht verfügbar.`};var aa={};aa={rangeOverflow:e=>`\u{397} \u{3C4}\u{3B9}\u{3BC}\u{3AE} \u{3C0}\u{3C1}\u{3AD}\u{3C0}\u{3B5}\u{3B9} \u{3BD}\u{3B1} \u{3B5}\u{3AF}\u{3BD}\u{3B1}\u{3B9} ${e.maxValue} \u{3AE} \u{3C0}\u{3B1}\u{3BB}\u{3B1}\u{3B9}\u{3CC}\u{3C4}\u{3B5}\u{3C1}\u{3B7}.`,rangeReversed:`Η ημερομηνία έναρξης πρέπει να είναι πριν από την ημερομηνία λήξης.`,rangeUnderflow:e=>`\u{397} \u{3C4}\u{3B9}\u{3BC}\u{3AE} \u{3C0}\u{3C1}\u{3AD}\u{3C0}\u{3B5}\u{3B9} \u{3BD}\u{3B1} \u{3B5}\u{3AF}\u{3BD}\u{3B1}\u{3B9} ${e.minValue} \u{3AE} \u{3BC}\u{3B5}\u{3C4}\u{3B1}\u{3B3}\u{3B5}\u{3BD}\u{3AD}\u{3C3}\u{3C4}\u{3B5}\u{3C1}\u{3B7}.`,unavailableDate:`Η επιλεγμένη ημερομηνία δεν είναι διαθέσιμη.`};var oa={};oa={rangeUnderflow:e=>`Value must be ${e.minValue} or later.`,rangeOverflow:e=>`Value must be ${e.maxValue} or earlier.`,rangeReversed:`Start date must be before end date.`,unavailableDate:`Selected date unavailable.`};var sa={};sa={rangeOverflow:e=>`El valor debe ser ${e.maxValue} o anterior.`,rangeReversed:`La fecha de inicio debe ser anterior a la fecha de finalización.`,rangeUnderflow:e=>`El valor debe ser ${e.minValue} o posterior.`,unavailableDate:`Fecha seleccionada no disponible.`};var ca={};ca={rangeOverflow:e=>`V\xe4\xe4rtus peab olema ${e.maxValue} v\xf5i varasem.`,rangeReversed:`Alguskuupäev peab olema enne lõppkuupäeva.`,rangeUnderflow:e=>`V\xe4\xe4rtus peab olema ${e.minValue} v\xf5i hilisem.`,unavailableDate:`Valitud kuupäev pole saadaval.`};var la={};la={rangeOverflow:e=>`Arvon on oltava ${e.maxValue} tai sit\xe4 aikaisempi.`,rangeReversed:`Aloituspäivän on oltava ennen lopetuspäivää.`,rangeUnderflow:e=>`Arvon on oltava ${e.minValue} tai sit\xe4 my\xf6h\xe4isempi.`,unavailableDate:`Valittu päivämäärä ei ole käytettävissä.`};var ua={};ua={rangeOverflow:e=>`La valeur doit \xeatre ${e.maxValue} ou ant\xe9rieure.`,rangeReversed:`La date de début doit être antérieure à la date de fin.`,rangeUnderflow:e=>`La valeur doit \xeatre ${e.minValue} ou ult\xe9rieure.`,unavailableDate:`La date sélectionnée n’est pas disponible.`};var da={};da={rangeOverflow:e=>`\u{5D4}\u{5E2}\u{5E8}\u{5DA} \u{5D7}\u{5D9}\u{5D9}\u{5D1} \u{5DC}\u{5D4}\u{5D9}\u{5D5}\u{5EA} ${e.maxValue} \u{5D0}\u{5D5} \u{5DE}\u{5D5}\u{5E7}\u{5D3}\u{5DD} \u{5D9}\u{5D5}\u{5EA}\u{5E8}.`,rangeReversed:`תאריך ההתחלה חייב להיות לפני תאריך הסיום.`,rangeUnderflow:e=>`\u{5D4}\u{5E2}\u{5E8}\u{5DA} \u{5D7}\u{5D9}\u{5D9}\u{5D1} \u{5DC}\u{5D4}\u{5D9}\u{5D5}\u{5EA} ${e.minValue} \u{5D0}\u{5D5} \u{5DE}\u{5D0}\u{5D5}\u{5D7}\u{5E8} \u{5D9}\u{5D5}\u{5EA}\u{5E8}.`,unavailableDate:`התאריך הנבחר אינו זמין.`};var fa={};fa={rangeOverflow:e=>`Vrijednost mora biti ${e.maxValue} ili ranije.`,rangeReversed:`Datum početka mora biti prije datuma završetka.`,rangeUnderflow:e=>`Vrijednost mora biti ${e.minValue} ili kasnije.`,unavailableDate:`Odabrani datum nije dostupan.`};var pa={};pa={rangeOverflow:e=>`Az \xe9rt\xe9knek ${e.maxValue} vagy kor\xe1bbinak kell lennie.`,rangeReversed:`A kezdő dátumnak a befejező dátumnál korábbinak kell lennie.`,rangeUnderflow:e=>`Az \xe9rt\xe9knek ${e.minValue} vagy k\xe9s\u{151}bbinek kell lennie.`,unavailableDate:`A kiválasztott dátum nem érhető el.`};var ma={};ma={rangeOverflow:e=>`Il valore deve essere ${e.maxValue} o precedente.`,rangeReversed:`La data di inizio deve essere antecedente alla data di fine.`,rangeUnderflow:e=>`Il valore deve essere ${e.minValue} o successivo.`,unavailableDate:`Data selezionata non disponibile.`};var ha={};ha={rangeOverflow:e=>`\u{5024}\u{306F} ${e.maxValue} \u{4EE5}\u{4E0B}\u{306B}\u{3059}\u{308B}\u{5FC5}\u{8981}\u{304C}\u{3042}\u{308A}\u{307E}\u{3059}\u{3002}`,rangeReversed:`開始日は終了日より前にする必要があります。`,rangeUnderflow:e=>`\u{5024}\u{306F} ${e.minValue} \u{4EE5}\u{4E0A}\u{306B}\u{3059}\u{308B}\u{5FC5}\u{8981}\u{304C}\u{3042}\u{308A}\u{307E}\u{3059}\u{3002}`,unavailableDate:`選択した日付は使用できません。`};var ga={};ga={rangeOverflow:e=>`\u{AC12}\u{C740} ${e.maxValue} \u{C774}\u{C804}\u{C774}\u{C5B4}\u{C57C} \u{D569}\u{B2C8}\u{B2E4}.`,rangeReversed:`시작일은 종료일 이전이어야 합니다.`,rangeUnderflow:e=>`\u{AC12}\u{C740} ${e.minValue} \u{C774}\u{D6C4}\u{C5EC}\u{C57C} \u{D569}\u{B2C8}\u{B2E4}.`,unavailableDate:`선택한 날짜를 사용할 수 없습니다.`};var _a={};_a={rangeOverflow:e=>`Reik\u{161}m\u{117} turi b\u{16B}ti ${e.maxValue} arba ankstesn\u{117}.`,rangeReversed:`Pradžios data turi būti ankstesnė nei pabaigos data.`,rangeUnderflow:e=>`Reik\u{161}m\u{117} turi b\u{16B}ti ${e.minValue} arba naujesn\u{117}.`,unavailableDate:`Pasirinkta data nepasiekiama.`};var va={};va={rangeOverflow:e=>`V\u{113}rt\u{12B}bai ir j\u{101}b\u{16B}t ${e.maxValue} vai agr\u{101}kai.`,rangeReversed:`Sākuma datumam ir jābūt pirms beigu datuma.`,rangeUnderflow:e=>`V\u{113}rt\u{12B}bai ir j\u{101}b\u{16B}t ${e.minValue} vai v\u{113}l\u{101}kai.`,unavailableDate:`Atlasītais datums nav pieejams.`};var ya={};ya={rangeOverflow:e=>`Verdien m\xe5 v\xe6re ${e.maxValue} eller tidligere.`,rangeReversed:`Startdatoen må være før sluttdatoen.`,rangeUnderflow:e=>`Verdien m\xe5 v\xe6re ${e.minValue} eller senere.`,unavailableDate:`Valgt dato utilgjengelig.`};var ba={};ba={rangeOverflow:e=>`Waarde moet ${e.maxValue} of eerder zijn.`,rangeReversed:`De startdatum moet voor de einddatum liggen.`,rangeUnderflow:e=>`Waarde moet ${e.minValue} of later zijn.`,unavailableDate:`Geselecteerde datum niet beschikbaar.`};var xa={};xa={rangeOverflow:e=>`Warto\u{15B}\u{107} musi mie\u{107} warto\u{15B}\u{107} ${e.maxValue} lub wcze\u{15B}niejsz\u{105}.`,rangeReversed:`Data rozpoczęcia musi być wcześniejsza niż data zakończenia.`,rangeUnderflow:e=>`Warto\u{15B}\u{107} musi mie\u{107} warto\u{15B}\u{107} ${e.minValue} lub p\xf3\u{17A}niejsz\u{105}.`,unavailableDate:`Wybrana data jest niedostępna.`};var Sa={};Sa={rangeOverflow:e=>`O valor deve ser ${e.maxValue} ou anterior.`,rangeReversed:`A data inicial deve ser anterior à data final.`,rangeUnderflow:e=>`O valor deve ser ${e.minValue} ou posterior.`,unavailableDate:`Data selecionada indisponível.`};var Ca={};Ca={rangeOverflow:e=>`O valor tem de ser ${e.maxValue} ou anterior.`,rangeReversed:`A data de início deve ser anterior à data de fim.`,rangeUnderflow:e=>`O valor tem de ser ${e.minValue} ou posterior.`,unavailableDate:`Data selecionada indisponível.`};var wa={};wa={rangeOverflow:e=>`Valoarea trebuie s\u{103} fie ${e.maxValue} sau anterioar\u{103}.`,rangeReversed:`Data de început trebuie să fie anterioară datei de sfârșit.`,rangeUnderflow:e=>`Valoarea trebuie s\u{103} fie ${e.minValue} sau ulterioar\u{103}.`,unavailableDate:`Data selectată nu este disponibilă.`};var Ta={};Ta={rangeOverflow:e=>`\u{417}\u{43D}\u{430}\u{447}\u{435}\u{43D}\u{438}\u{435} \u{434}\u{43E}\u{43B}\u{436}\u{43D}\u{43E} \u{431}\u{44B}\u{442}\u{44C} \u{43D}\u{435} \u{43F}\u{43E}\u{437}\u{436}\u{435} ${e.maxValue}.`,rangeReversed:`Дата начала должна предшествовать дате окончания.`,rangeUnderflow:e=>`\u{417}\u{43D}\u{430}\u{447}\u{435}\u{43D}\u{438}\u{435} \u{434}\u{43E}\u{43B}\u{436}\u{43D}\u{43E} \u{431}\u{44B}\u{442}\u{44C} \u{43D}\u{435} \u{440}\u{430}\u{43D}\u{44C}\u{448}\u{435} ${e.minValue}.`,unavailableDate:`Выбранная дата недоступна.`};var Ea={};Ea={rangeOverflow:e=>`Hodnota mus\xed by\u{165} ${e.maxValue} alebo skor\u{161}ia.`,rangeReversed:`Dátum začiatku musí byť skorší ako dátum konca.`,rangeUnderflow:e=>`Hodnota mus\xed by\u{165} ${e.minValue} alebo neskor\u{161}ia.`,unavailableDate:`Vybratý dátum je nedostupný.`};var Da={};Da={rangeOverflow:e=>`Vrednost mora biti ${e.maxValue} ali starej\u{161}a.`,rangeReversed:`Začetni datum mora biti pred končnim datumom.`,rangeUnderflow:e=>`Vrednost mora biti ${e.minValue} ali novej\u{161}a.`,unavailableDate:`Izbrani datum ni na voljo.`};var Oa={};Oa={rangeOverflow:e=>`Vrednost mora da bude ${e.maxValue} ili starija.`,rangeReversed:`Datum početka mora biti pre datuma završetka.`,rangeUnderflow:e=>`Vrednost mora da bude ${e.minValue} ili novija.`,unavailableDate:`Izabrani datum nije dostupan.`};var ka={};ka={rangeOverflow:e=>`V\xe4rdet m\xe5ste vara ${e.maxValue} eller tidigare.`,rangeReversed:`Startdatumet måste vara före slutdatumet.`,rangeUnderflow:e=>`V\xe4rdet m\xe5ste vara ${e.minValue} eller senare.`,unavailableDate:`Det valda datumet är inte tillgängligt.`};var Aa={};Aa={rangeOverflow:e=>`De\u{11F}er, ${e.maxValue} veya \xf6ncesi olmal\u{131}d\u{131}r.`,rangeReversed:`Başlangıç tarihi bitiş tarihinden önce olmalıdır.`,rangeUnderflow:e=>`De\u{11F}er, ${e.minValue} veya sonras\u{131} olmal\u{131}d\u{131}r.`,unavailableDate:`Seçilen tarih kullanılamıyor.`};var ja={};ja={rangeOverflow:e=>`\u{417}\u{43D}\u{430}\u{447}\u{435}\u{43D}\u{43D}\u{44F} \u{43C}\u{430}\u{454} \u{431}\u{443}\u{442}\u{438} \u{43D}\u{435} \u{43F}\u{456}\u{437}\u{43D}\u{456}\u{448}\u{435} ${e.maxValue}.`,rangeReversed:`Дата початку має передувати даті завершення.`,rangeUnderflow:e=>`\u{417}\u{43D}\u{430}\u{447}\u{435}\u{43D}\u{43D}\u{44F} \u{43C}\u{430}\u{454} \u{431}\u{443}\u{442}\u{438} \u{43D}\u{435} \u{440}\u{430}\u{43D}\u{456}\u{448}\u{435} ${e.minValue}.`,unavailableDate:`Вибрана дата недоступна.`};var Ma={};Ma={rangeOverflow:e=>`\u{503C}\u{5FC5}\u{987B}\u{662F} ${e.maxValue} \u{6216}\u{66F4}\u{65E9}\u{65E5}\u{671F}\u{3002}`,rangeReversed:`开始日期必须早于结束日期。`,rangeUnderflow:e=>`\u{503C}\u{5FC5}\u{987B}\u{662F} ${e.minValue} \u{6216}\u{66F4}\u{665A}\u{65E5}\u{671F}\u{3002}`,unavailableDate:`所选日期不可用。`};var Na={};Na={rangeOverflow:e=>`\u{503C}\u{5FC5}\u{9808}\u{662F} ${e.maxValue} \u{6216}\u{66F4}\u{65E9}\u{3002}`,rangeReversed:`開始日期必須在結束日期之前。`,rangeUnderflow:e=>`\u{503C}\u{5FC5}\u{9808}\u{662F} ${e.minValue} \u{6216}\u{66F4}\u{665A}\u{3002}`,unavailableDate:`所選日期無法使用。`};var Pa={};Pa={"ar-AE":ea,"bg-BG":ta,"cs-CZ":na,"da-DK":ra,"de-DE":ia,"el-GR":aa,"en-US":oa,"es-ES":sa,"et-EE":ca,"fi-FI":la,"fr-FR":ua,"he-IL":da,"hr-HR":fa,"hu-HU":pa,"it-IT":ma,"ja-JP":ha,"ko-KR":ga,"lt-LT":_a,"lv-LV":va,"nb-NO":ya,"nl-NL":ba,"pl-PL":xa,"pt-BR":Sa,"pt-PT":Ca,"ro-RO":wa,"ru-RU":Ta,"sk-SK":Ea,"sl-SI":Da,"sr-SP":Oa,"sv-SE":ka,"tr-TR":Aa,"uk-UA":ja,"zh-CN":Ma,"zh-TW":Na};function Fa(e){return e&&e.__esModule?e.default:e}var Ia=new h(Fa(Pa));function La(){let e=typeof navigator<`u`&&(navigator.language||navigator.userLanguage)||`en-US`;try{Intl.DateTimeFormat.supportedLocalesOf([e])}catch{e=`en-US`}return e}function Ra(e,t,n,r,i){let a=e!=null&&n!=null&&e.compare(n)>0,o=e!=null&&t!=null&&e.compare(t)<0,s=e!=null&&r?.(e)||!1,l=a||o||s,u=[];if(l){let e=La(),r=h.getGlobalDictionaryForPackage(`@react-stately/datepicker`)||Ia,l=new c(e,r),d=new Y(e,Ha({},i)),f=d.resolvedOptions().timeZone;o&&t!=null&&u.push(l.format(`rangeUnderflow`,{minValue:d.format(t.toDate(f))})),a&&n!=null&&u.push(l.format(`rangeOverflow`,{maxValue:d.format(n.toDate(f))})),s&&u.push(l.format(`unavailableDate`))}return{isInvalid:l,validationErrors:u,validationDetails:{badInput:s,customError:!1,patternMismatch:!1,rangeOverflow:a,rangeUnderflow:o,stepMismatch:!1,tooLong:!1,tooShort:!1,typeMismatch:!1,valueMissing:!1,valid:!l}}}function za(e,t,n,r,i){let a=Ra(e?.start??null,t,n,r,i),o=Ra(e?.end??null,t,n,r,i),s=_e(a,o);if(e?.end!=null&&e.start!=null&&e.end.compare(e.start)<0){let e=h.getGlobalDictionaryForPackage(`@react-stately/datepicker`)||Ia;s=_e(s,{isInvalid:!0,validationErrors:[e.getStringForLocale(`rangeReversed`,La())],validationDetails:{...ke,rangeUnderflow:!0,rangeOverflow:!0,valid:!1}})}return s}var Ba={year:`numeric`,month:`numeric`,day:`numeric`,hour:`numeric`,minute:`2-digit`,second:`2-digit`},Va={year:`numeric`,month:`2-digit`,day:`2-digit`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`};function Ha(e,t){e={...t.shouldForceLeadingZeros?Va:Ba,...e};let n=t.granularity||`minute`,r=Object.keys(e),i=r.indexOf(t.maxGranularity??`year`);i<0&&(i=0);let a=r.indexOf(n);if(a<0&&(a=2),i>a)throw Error(`maxGranularity must be greater than granularity`);let o=r.slice(i,a+1).reduce((t,n)=>(t[n]=e[n],t),{});return t.hourCycle!=null&&(o.hour12=t.hourCycle===12),o.timeZone=t.timeZone||`UTC`,(n===`hour`||n===`minute`||n===`second`)&&t.timeZone&&!t.hideTimeZone&&(o.timeZoneName=`short`),t.showEra&&i===0&&(o.era=`short`),o}function Ua(e){return e&&`hour`in e?e:new Ln}function Wa(e,t){if(e===null)return null;if(e)return W(e,t)}function Ga(e,t,n,r){if(e)return Wa(e,n);let i=W(_t(r??wt()).set({hour:0,minute:0,second:0,millisecond:0}),n);return t===`year`||t===`month`||t===`day`?H(i):r?i:U(i)}function Ka(e,t){let n=e&&`timeZone`in e?e.timeZone:void 0,r=e&&`minute`in e?`minute`:`day`;if(e&&t&&!(t in e))throw Error(`Invalid granularity `+t+` for value `+e.toString());let[i,a]=(0,z.useState)([r,n]);e&&(i[0]!==r||i[1]!==n)&&a([r,n]),t||=e?r:i[0];let o=e?n:i[1];return[t,o]}var qa=new h({ach:{year:`mwaka`,month:`dwe`,day:`nino`},af:{year:`jjjj`,month:`mm`,day:`dd`},am:{year:`ዓዓዓዓ`,month:`ሚሜ`,day:`ቀቀ`},an:{year:`aaaa`,month:`mm`,day:`dd`},ar:{year:`سنة`,month:`شهر`,day:`يوم`},ast:{year:`aaaa`,month:`mm`,day:`dd`},az:{year:`iiii`,month:`aa`,day:`gg`},be:{year:`гггг`,month:`мм`,day:`дд`},bg:{year:`гггг`,month:`мм`,day:`дд`},bn:{year:`yyyy`,month:`মিমি`,day:`dd`},br:{year:`bbbb`,month:`mm`,day:`dd`},bs:{year:`gggg`,month:`mm`,day:`dd`},ca:{year:`aaaa`,month:`mm`,day:`dd`},cak:{year:`jjjj`,month:`ii`,day:`q'q'`},ckb:{year:`ساڵ`,month:`مانگ`,day:`ڕۆژ`},cs:{year:`rrrr`,month:`mm`,day:`dd`},cy:{year:`bbbb`,month:`mm`,day:`dd`},da:{year:`åååå`,month:`mm`,day:`dd`},de:{year:`jjjj`,month:`mm`,day:`tt`},dsb:{year:`llll`,month:`mm`,day:`źź`},el:{year:`εεεε`,month:`μμ`,day:`ηη`},en:{year:`yyyy`,month:`mm`,day:`dd`},eo:{year:`jjjj`,month:`mm`,day:`tt`},es:{year:`aaaa`,month:`mm`,day:`dd`},et:{year:`aaaa`,month:`kk`,day:`pp`},eu:{year:`uuuu`,month:`hh`,day:`ee`},fa:{year:`سال`,month:`ماه`,day:`روز`},ff:{year:`hhhh`,month:`ll`,day:`ññ`},fi:{year:`vvvv`,month:`kk`,day:`pp`},fr:{year:`aaaa`,month:`mm`,day:`jj`},fy:{year:`jjjj`,month:`mm`,day:`dd`},ga:{year:`bbbb`,month:`mm`,day:`ll`},gd:{year:`bbbb`,month:`mm`,day:`ll`},gl:{year:`aaaa`,month:`mm`,day:`dd`},he:{year:`שנה`,month:`חודש`,day:`יום`},hr:{year:`gggg`,month:`mm`,day:`dd`},hsb:{year:`llll`,month:`mm`,day:`dd`},hu:{year:`éééé`,month:`hh`,day:`nn`},ia:{year:`aaaa`,month:`mm`,day:`dd`},id:{year:`tttt`,month:`bb`,day:`hh`},is:{year:`áááá`,month:`mm`,day:`dd`},it:{year:`aaaa`,month:`mm`,day:`gg`},ja:{year:`年`,month:`月`,day:`日`},ka:{year:`წწწწ`,month:`თთ`,day:`რრ`},kk:{year:`жжжж`,month:`аа`,day:`кк`},kn:{year:`ವವವವ`,month:`ಮಿಮೀ`,day:`ದಿದಿ`},ko:{year:`연도`,month:`월`,day:`일`},lb:{year:`jjjj`,month:`mm`,day:`dd`},lo:{year:`ປປປປ`,month:`ດດ`,day:`ວວ`},lt:{year:`mmmm`,month:`mm`,day:`dd`},lv:{year:`gggg`,month:`mm`,day:`dd`},meh:{year:`aaaa`,month:`mm`,day:`dd`},ml:{year:`വർഷം`,month:`മാസം`,day:`തീയതി`},ms:{year:`tttt`,month:`mm`,day:`hh`},nb:{year:`åååå`,month:`mm`,day:`dd`},nl:{year:`jjjj`,month:`mm`,day:`dd`},nn:{year:`åååå`,month:`mm`,day:`dd`},no:{year:`åååå`,month:`mm`,day:`dd`},oc:{year:`aaaa`,month:`mm`,day:`jj`},pl:{year:`rrrr`,month:`mm`,day:`dd`},pt:{year:`aaaa`,month:`mm`,day:`dd`},rm:{year:`oooo`,month:`mm`,day:`dd`},ro:{year:`aaaa`,month:`ll`,day:`zz`},ru:{year:`гггг`,month:`мм`,day:`дд`},sc:{year:`aaaa`,month:`mm`,day:`dd`},scn:{year:`aaaa`,month:`mm`,day:`jj`},sk:{year:`rrrr`,month:`mm`,day:`dd`},sl:{year:`llll`,month:`mm`,day:`dd`},sr:{year:`гггг`,month:`мм`,day:`дд`},"sr-Latn":{year:`gggg`,month:`mm`,day:`dd`},sv:{year:`åååå`,month:`mm`,day:`dd`},szl:{year:`rrrr`,month:`mm`,day:`dd`},tg:{year:`сссс`,month:`мм`,day:`рр`},th:{year:`ปปปป`,month:`ดด`,day:`วว`},tr:{year:`yyyy`,month:`aa`,day:`gg`},uk:{year:`рррр`,month:`мм`,day:`дд`},"zh-CN":{year:`年`,month:`月`,day:`日`},"zh-TW":{year:`年`,month:`月`,day:`日`}},`en`);function Ja(e,t,n){return e===`era`||e===`dayPeriod`?t:e===`year`||e===`month`||e===`day`?qa.getStringForLocale(e,n):`––`}var Ya=class e{constructor(e,t,n){if(this.era=n?.era??null,this.calendar=e,this.year=n?.year??null,this.month=n?.month??null,this.day=n?.day??null,this.hour=n?.hour??null,this.hourCycle=t,this.dayPeriod=null,this.minute=n?.minute??null,this.second=n?.second??null,this.millisecond=n?.millisecond??null,this.offset=`offset`in(n??{})?n.offset:null,this.hour!=null){let[e,n]=Za(this.hour,t);this.dayPeriod=e,this.hour=n}}copy(){let t=new e(this.calendar,this.hourCycle);return t.era=this.era,t.year=this.year,t.month=this.month,t.day=this.day,t.hour=this.hour,t.dayPeriod=this.dayPeriod,t.minute=this.minute,t.second=this.second,t.millisecond=this.millisecond,t.offset=this.offset,t}isComplete(e){return e.every(e=>this[e]!=null)}validate(e,t){return t.every(t=>{if((t===`hour`||t===`dayPeriod`)&&`hour`in e){let[t,n]=Za(e.hour,this.hourCycle);return this.dayPeriod===t&&this.hour===n}return this[t]===e[t]})}isCleared(e){return e.every(e=>this[e]===null)}set(e,t,n){let r=this.copy();return r[e]=t,e===`hour`&&r.dayPeriod==null&&`hour`in n&&(r.dayPeriod=Za(n.hour,this.hourCycle)[0]),e===`year`&&r.era==null&&(r.era=n.era),e!==`second`&&e!==`literal`&&e!==`timeZoneName`&&(r.offset=null),r}clear(e){let t=this.copy();return t[e]=null,e===`year`&&(t.era=null),t.offset=null,t}cycle(e,t,n,r){let i=this.copy();if(i[e]==null&&e!==`dayPeriod`&&e!==`era`){if(e===`hour`&&`hour`in n){let[e,t]=Za(n.hour,this.hourCycle);i.dayPeriod=e,i.hour=t}else i[e]=n[e];return e===`year`&&i.era==null&&(i.era=n.era),i}switch(e){case`era`:{let e=this.calendar.getEras(),n=e.indexOf(i.era);n=Xa(n,t,0,e.length-1),i.era=e[n];break}case`year`:{let r=new q(this.calendar,this.era??n.era,this.year??n.year,this.month??1,this.day??1);r=r.cycle(e,t,{round:e===`year`}),i.era=r.era,i.year=r.year;break}case`month`:i.month=Xa(i.month??1,t,1,this.calendar.getMaximumMonthsInYear());break;case`day`:i.day=Xa(i.day??1,t,1,this.calendar.getMaximumDaysInMonth());break;case`hour`:{let e=r.some(e=>[`year`,`month`,`day`].includes(e));if(`timeZone`in n&&(!e||i.year!=null&&i.month!=null&&i.day!=null)){let e=this.toValue(n);e=e.cycle(`hour`,t,{hourCycle:this.hourCycle===`h12`?12:24,round:!1});let[r,a]=Za(e.hour,this.hourCycle);i.hour=a,i.dayPeriod=r,i.offset=e.offset}else{let e=i.hour??0,r=this.getSegmentLimits(`hour`);i.hour=Xa(e,t,r.minValue,r.maxValue),i.dayPeriod==null&&`hour`in n&&(i.dayPeriod=Za(n.hour,this.hourCycle)[0])}break}case`dayPeriod`:i.dayPeriod=Xa(i.dayPeriod??0,t,0,1);break;case`minute`:i.minute=Xa(i.minute??0,t,0,59,!0);break;case`second`:i.second=Xa(i.second??0,t,0,59,!0)}return i}toValue(e){if(`hour`in e){let t=this.hour;t==null?(this.hourCycle===`h12`||this.hourCycle===`h11`)&&(t=this.dayPeriod===1?12:0):t=Qa(t,this.dayPeriod??0,this.hourCycle);let n=e.set({era:this.era??e.era,year:this.year??e.year,month:this.month??e.month,day:this.day??e.day,hour:t??e.hour,minute:this.minute??e.minute,second:this.second??e.second,millisecond:this.millisecond??e.millisecond});return`offset`in n&&this.offset!=null&&n.offset!==this.offset&&(n=n.add({milliseconds:n.offset-this.offset})),n}return e.set({era:this.era??e.era,year:this.year??e.year,month:this.month??e.month,day:this.day??e.day})}getSegmentLimits(e){switch(e){case`era`:{let e=this.calendar.getEras();return{value:this.era==null?e.length-1:e.indexOf(this.era),minValue:0,maxValue:e.length-1}}case`year`:return{value:this.year,minValue:1,maxValue:9999};case`month`:return{value:this.month,minValue:1,maxValue:this.calendar.getMaximumMonthsInYear()};case`day`:return{value:this.day,minValue:1,maxValue:this.calendar.getMaximumDaysInMonth()};case`dayPeriod`:return{value:this.dayPeriod,minValue:0,maxValue:1};case`hour`:{let e=0,t=23;return this.hourCycle===`h12`?(e=1,t=12):this.hourCycle===`h11`&&(e=0,t=11),{value:this.hour,minValue:e,maxValue:t}}case`minute`:return{value:this.minute,minValue:0,maxValue:59};case`second`:return{value:this.second,minValue:0,maxValue:59}}}};function Xa(e,t,n,r,i=!1){if(i){e+=Math.sign(t),e0?Math.ceil(e/i)*i:Math.floor(e/i)*i,e>r&&(e=n)}else e+=t,er&&(e=n+(e-r-1));return e}function Za(e,t){let n=+(e>=12);switch(t){case`h11`:e>=12&&(e-=12);break;case`h12`:e===0?e=12:e>12&&(e-=12);break;case`h23`:n=null;break;case`h24`:e+=1,n=null}return[n,e]}function Qa(e,t,n){switch(n){case`h11`:t===1&&(e+=12);break;case`h12`:e===12&&(e=0),t===1&&(e+=12);break;case`h24`:--e}return e}var $a={year:!0,month:!0,day:!0,hour:!0,minute:!0,second:!0,dayPeriod:!0,era:!0},eo={year:5,month:2,day:7,hour:2,minute:15,second:15},to={dayperiod:`dayPeriod`,relatedYear:`year`,yearName:`literal`,unknown:`literal`};function no(e){let{locale:t,createCalendar:n,hideTimeZone:r,isDisabled:i=!1,isReadOnly:a=!1,isRequired:o=!1,minValue:s,maxValue:c,isDateUnavailable:l}=e,u=e.value||e.defaultValue||e.placeholderValue||null,[d,f]=Ka(u,e.granularity),p=f||`UTC`;if(u&&!(d in u))throw Error(`Invalid granularity `+d+` for value `+u.toString());let[m,h]=(0,z.useMemo)(()=>{let r=new Y(t,{dateStyle:`short`,timeStyle:`short`,hour12:e.hourCycle==null?void 0:e.hourCycle===12}).resolvedOptions();return[n(r.calendar),r.hourCycle]},[t,e.hourCycle,n]),[g,_]=I(e.value,e.defaultValue??null,e.onChange),[v]=(0,z.useState)(g),y=(0,z.useMemo)(()=>Wa(g,m)??null,[g,m]),[b,x]=(0,z.useState)(()=>new Ya(m,h,y)),S=m.identifier===`gregory`&&b.era===`BC`,C=(0,z.useMemo)(()=>({granularity:d,maxGranularity:e.maxGranularity??`year`,timeZone:f,hideTimeZone:r,hourCycle:e.hourCycle,showEra:S,shouldForceLeadingZeros:e.shouldForceLeadingZeros}),[e.maxGranularity,d,e.hourCycle,e.shouldForceLeadingZeros,f,r,S]),w=(0,z.useMemo)(()=>Ha({},C),[C]),T=(0,z.useMemo)(()=>new Y(t,w),[t,w]),E=(0,z.useMemo)(()=>T.resolvedOptions(),[T]),D=(0,z.useMemo)(()=>Ga(e.placeholderValue,d,m,f),[e.placeholderValue,d,m,f]),O=(0,z.useMemo)(()=>{let t=h===`h11`||h===`h12`,n=[`era`,`year`,`month`,`day`,`hour`,...t?[`dayPeriod`]:[],`minute`,`second`],r=n.indexOf(e.maxGranularity||`era`),i=n.indexOf(d===`hour`&&t?`dayPeriod`:d);return n.slice(r,i+1)},[e.maxGranularity,d,h]),[k,A]=(0,z.useState)(y),[ee,te]=(0,z.useState)(m),[j,ne]=(0,z.useState)(h);(y!==k||h!==j||!pt(m,ee))&&(b=new Ya(m,h,y),A(y),te(m),ne(h),x(b));let M=t=>{if(!(e.isDisabled||e.isReadOnly)){if(t==null||t instanceof Ya&&t.isCleared(O))x(new Ya(m,h,y)),_(null);else if(!(t instanceof Ya))t=W(t,u?.calendar||new B),x(new Ya(m,h,y)),_(t);else{if(t.isComplete(O)){let e=t.toValue(y??D);if(t.validate(e,O)){let t=W(e,u?.calendar||new B);if(!g||t.compare(g)!==0){x(new Ya(m,h,y)),_(t);return}}}x(t)}}},re=(0,z.useMemo)(()=>b.toValue(y??D).toDate(p),[b,p,y,D]),N=(0,z.useMemo)(()=>ro(re,b,T,E,m,t,d),[re,T,E,b,m,t,d]),ie=(e,t)=>{M(b.cycle(e,t,D,O))},P=(0,z.useMemo)(()=>Ra(g,s,c,l,C),[g,s,c,l,C]),ae=ye({...e,value:g,builtinValidation:P}),F=ae.displayValidation.isInvalid,oe=e.validationState||(F?`invalid`:null);return{...ae,value:y,defaultValue:e.defaultValue??v,dateValue:re,calendar:m,setValue:M,segments:N,dateFormatter:T,validationState:oe,isInvalid:F,granularity:d,maxGranularity:e.maxGranularity??`year`,isDisabled:i,isReadOnly:a,isRequired:o,increment(e){ie(e,1)},decrement(e){ie(e,-1)},incrementPage(e){ie(e,eo[e]||1)},decrementPage(e){ie(e,-(eo[e]||1))},incrementToMax(e){let t=e===`hour`&&h===`h12`?11:b.getSegmentLimits(e).maxValue;M(b.set(e,t,D))},decrementToMin(e){let t=e===`hour`&&h===`h12`?12:b.getSegmentLimits(e).minValue;M(b.set(e,t,D))},setSegment(e,t){M(b.set(e,t,D))},confirmPlaceholder(){if(!(e.isDisabled||e.isReadOnly)&&b.isComplete(O)){let e=W(b.toValue(y??D),u?.calendar||new B);(!g||e.compare(g)!==0)&&_(e),x(new Ya(m,h,y))}},clearSegment(e){let t=b;e!==`timeZoneName`&&e!==`literal`&&(t=b.clear(e)),M(t)},formatValue(e){if(!y)return``;let n=Ha(e,C);return new Y(t,n).format(re)},getDateFormatter(e,t){return new Y(e,Ha({},{...C,...t}))}}}function ro(e,t,n,r,i,a,o){let s=[`hour`,`minute`,`second`],c=n.formatToParts(e),l=new Me(a,{useGrouping:!1}),u=new Me(a,{useGrouping:!1,minimumIntegerDigits:2});for(let e of c)if(e.type===`year`||e.type===`month`||e.type===`day`||e.type===`hour`){let n=t[e.type]??0;e.value=r[e.type]===`2-digit`?u.format(n):l.format(n)}let d=[];for(let e of c){let n=to[e.type]||e.type,r=$a[n];n===`era`&&i.getEras().length===1&&(r=!1);let c=$a[n]&&t[e.type]==null,l=$a[n]?Ja(n,e.value,a):null,u={type:n,text:c?l:e.value,...t.getSegmentLimits(n),isPlaceholder:c,placeholder:l,isEditable:r};n===`hour`?(d.push({type:`literal`,text:`⁦`,isPlaceholder:!1,placeholder:``,isEditable:!1}),d.push(u),n===o&&d.push({type:`literal`,text:`⁩`,isPlaceholder:!1,placeholder:``,isEditable:!1})):s.includes(n)&&n===o?(d.push(u),d.push({type:`literal`,text:`⁩`,isPlaceholder:!1,placeholder:``,isEditable:!1})):d.push(u)}return d}function io(e){let{placeholderValue:t=new Ln,minValue:n,maxValue:r,defaultValue:i,granularity:a,validate:o}=e,[s,c]=I(e.value,i??null,e.onChange),l=s||t,u=l&&`day`in l?l:void 0,d=i&&`timeZone`in i?i.timeZone:void 0,f=(0,z.useMemo)(()=>{let e=l&&`timeZone`in l?l.timeZone:void 0;return(e||d)&&t?Xt(ao(t),e||d):ao(t)},[t,l,d]),p=(0,z.useMemo)(()=>ao(n,u),[n,u]),m=(0,z.useMemo)(()=>ao(r,u),[r,u]),h=(0,z.useMemo)(()=>s&&`day`in s?Yt(s):s,[s]),g=(0,z.useMemo)(()=>s==null?null:ao(s),[s]),_=(0,z.useMemo)(()=>i==null?null:ao(i),[i]),v=e=>{c(u||d?e:e&&Yt(e))};return{...no({...e,value:g,defaultValue:_,minValue:p,maxValue:m,onChange:v,granularity:a||`minute`,maxGranularity:`hour`,placeholderValue:f??void 0,createCalendar:()=>new B,validate:(0,z.useCallback)(()=>o?.(s),[o,s])}),timeValue:h}}function ao(e,t=vt(wt())){return e?`day`in e?e:U(t,e):null}var oo=(0,z.createContext)(null),so=(0,z.createContext)(null),co=(0,z.createContext)(null),lo=(0,z.createContext)(null),uo=(0,z.forwardRef)(function(e,t){[e,t]=ae(e,t,oo);let{validationBehavior:n}=E(De)||{},r=e.validationBehavior??n??`native`,{locale:i}=F(),a=no({...e,locale:i,createCalendar:Kr,validationBehavior:r}),o=(0,z.useRef)(null),[s,c]=O(!e[`aria-label`]&&!e[`aria-labelledby`]),l=(0,z.useRef)(null),{labelProps:u,fieldProps:d,inputProps:p,descriptionProps:m,errorMessageProps:h,...g}=Ki({...w(e),label:c,inputRef:l,validationBehavior:r},a,o),_=D({...w(e),values:{state:a,isInvalid:a.isInvalid,isDisabled:a.isDisabled,isReadOnly:a.isReadOnly,isRequired:e.isRequired||!1},defaultClassName:`react-aria-DateField`}),v=L(e,{global:!0});return delete v.id,z.createElement(y,{values:[[co,a],[be,{...d,ref:o,isInvalid:a.isInvalid,isDisabled:a.isDisabled}],[we,{...p,ref:l}],[he,{...u,ref:s,elementType:`span`}],[f,{slots:{description:m,errorMessage:h}}],[Te,g]]},z.createElement(S.div,{...v,..._,ref:t,slot:e.slot||void 0,"data-invalid":a.isInvalid||void 0,"data-disabled":a.isDisabled||void 0,"data-readonly":a.isReadOnly||void 0,"data-required":e.isRequired||void 0}),z.createElement(ii,{autoComplete:e.autoComplete,name:e.name,isDisabled:e.isDisabled,state:a}))}),fo=(0,z.forwardRef)(function(e,t){[e,t]=ae(e,t,so);let{validationBehavior:n}=E(De)||{},r=e.validationBehavior??n??`native`,{locale:i}=F(),a=io({...e,locale:i,validationBehavior:r}),o=(0,z.useRef)(null),[s,c]=O(!e[`aria-label`]&&!e[`aria-labelledby`]),l=(0,z.useRef)(null),{labelProps:u,fieldProps:d,inputProps:p,descriptionProps:m,errorMessageProps:h,...g}=qi({...w(e),label:c,inputRef:l,validationBehavior:r},a,o),_=D({...e,values:{state:a,isInvalid:a.isInvalid,isDisabled:a.isDisabled,isReadOnly:a.isReadOnly,isRequired:e.isRequired||!1},defaultClassName:`react-aria-TimeField`}),v=L(e,{global:!0});return delete v.id,z.createElement(y,{values:[[lo,a],[be,{...d,ref:o,isInvalid:a.isInvalid,isDisabled:a.isDisabled}],[we,{...p,ref:l}],[he,{...u,ref:s,elementType:`span`}],[f,{slots:{description:m,errorMessage:h}}],[Te,g]]},z.createElement(S.div,{...v,..._,ref:t,slot:e.slot||void 0,"data-invalid":a.isInvalid||void 0,"data-disabled":a.isDisabled||void 0,"data-readonly":a.isReadOnly||void 0,"data-required":e.isRequired||void 0}))}),po=(0,z.forwardRef)(function(e,t){let n=(0,z.useContext)(co),r=(0,z.useContext)(lo);return n||r?z.createElement(ho,{...e,ref:t}):z.createElement(mo,{...e,ref:t})}),mo=(0,z.forwardRef)((e,t)=>{let[n,r]=ae({slot:e.slot},t,oo),{locale:i}=F(),a=no({...n,locale:i,createCalendar:Kr}),o=(0,z.useRef)(null),{fieldProps:s,inputProps:c}=Ki({...n,inputRef:o},a,r);return z.createElement(y,{values:[[co,a],[we,{...c,ref:o}],[be,{...s,ref:r,isInvalid:a.isInvalid,isDisabled:a.isDisabled}]]},z.createElement(ho,e))}),ho=(0,z.forwardRef)((e,t)=>{let{className:n,children:r}=e,i=(0,z.useContext)(co),a=(0,z.useContext)(lo),o=i??a;return z.createElement(z.Fragment,null,z.createElement(Ce,{...e,ref:t,slot:e.slot||void 0,className:n??`react-aria-DateInput`,isReadOnly:o.isReadOnly,isInvalid:o.isInvalid,isDisabled:o.isDisabled},o.segments.map((e,t)=>(0,z.cloneElement)(r(e),{key:t}))),z.createElement(Ee,{className:``}))}),go=(0,z.forwardRef)(function({segment:e,...t},n){let r=(0,z.useContext)(co),i=(0,z.useContext)(lo),a=r??i,o=C(n),{segmentProps:s}=Qi(e,a,o),{focusProps:c,isFocused:l,isFocusVisible:u}=N(),{hoverProps:d,isHovered:f}=ue({...t,isDisabled:a.isDisabled||e.type===`literal`}),p=D({...t,values:{...e,isReadOnly:a.isReadOnly,isInvalid:a.isInvalid,isDisabled:a.isDisabled,isHovered:f,isFocused:l,isFocusVisible:u},defaultChildren:e.text,defaultClassName:`react-aria-DateSegment`});return z.createElement(S.span,{...T(L(t,{global:!0}),s,c,d),...p,style:s.style,ref:o,"data-placeholder":e.isPlaceholder||void 0,"data-invalid":a.isInvalid||void 0,"data-readonly":a.isReadOnly||void 0,"data-disabled":a.isDisabled||void 0,"data-type":e.type,"data-hovered":f||void 0,"data-focused":l||void 0,"data-focus-visible":u||void 0})}),_o=(0,z.createContext)({}),vo=({children:e,className:t,fullWidth:n,variant:r,...i})=>{let a=z.useMemo(()=>$e({fullWidth:n,variant:r}),[n,r]);return(0,X.jsx)(_o,{value:{slots:a},children:(0,X.jsx)(Ce,{className:M(t,a?.base()),"data-slot":`date-input-group`,...i,children:t=>(0,X.jsx)(X.Fragment,{children:typeof e==`function`?e(t):e})})})},yo=({children:e,className:t,...n})=>{let{slots:r}=(0,z.use)(_o);return(0,X.jsx)(b.div,{className:R(r?.prefix,t),"data-slot":`date-input-group-prefix`,...n,children:e})},bo=({className:e,...t})=>{let{slots:n}=(0,z.use)(_o);return(0,X.jsx)(po,{className:M(e,n?.input()),"data-slot":`date-input-group-input`,...t})},xo=({className:e,segment:t,...n})=>{let{slots:r}=(0,z.use)(_o);return(0,X.jsx)(go,{className:R(r?.segment,e),"data-slot":`date-input-group-segment`,segment:t,...n})},So=({children:e,className:t,...n})=>{let{slots:r}=(0,z.use)(_o);return(0,X.jsx)(b.div,{className:R(r?.inputContainer,t),"data-slot":`date-input-group-input-container`,...n,children:e})},Co=({children:e,className:t,...n})=>{let{slots:r}=(0,z.use)(_o);return(0,X.jsx)(b.div,{className:R(r?.suffix,t),"data-slot":`date-input-group-suffix`,...n,children:e})};function wo({children:e,className:t,fullWidth:n,...r}){let i=z.useMemo(()=>Ze({fullWidth:n}),[n]);return(0,X.jsx)(uo,{"data-required":Pe(r.isRequired),"data-slot":`date-field`,...r,className:M(t,i),children:t=>(0,X.jsx)(X.Fragment,{children:typeof e==`function`?e(t):e})})}var To=Object.assign(wo,{Root:wo,Group:vo,Input:bo,InputContainer:So,Segment:xo,Prefix:yo,Suffix:Co}),Eo={};Eo={dateRange:e=>`${e.startDate} \u{625}\u{644}\u{649} ${e.endDate}`,dateSelected:e=>`${e.date} \u{627}\u{644}\u{645}\u{62D}\u{62F}\u{62F}`,finishRangeSelectionPrompt:`انقر لإنهاء عملية تحديد نطاق التاريخ`,maximumDate:`آخر تاريخ متاح`,minimumDate:`أول تاريخ متاح`,next:`التالي`,previous:`السابق`,selectedDateDescription:e=>`\u{62A}\u{627}\u{631}\u{64A}\u{62E} \u{645}\u{62D}\u{62F}\u{62F}: ${e.date}`,selectedRangeDescription:e=>`\u{627}\u{644}\u{645}\u{62F}\u{649} \u{627}\u{644}\u{632}\u{645}\u{646}\u{64A} \u{627}\u{644}\u{645}\u{62D}\u{62F}\u{62F}: ${e.dateRange}`,startRangeSelectionPrompt:`انقر لبدء عملية تحديد نطاق التاريخ`,todayDate:e=>`\u{627}\u{644}\u{64A}\u{648}\u{645}\u{60C} ${e.date}`,todayDateSelected:e=>`\u{627}\u{644}\u{64A}\u{648}\u{645}\u{60C} ${e.date} \u{645}\u{62D}\u{62F}\u{62F}`};var Do={};Do={dateRange:e=>`${e.startDate} \u{434}\u{43E} ${e.endDate}`,dateSelected:e=>`\u{418}\u{437}\u{431}\u{440}\u{430}\u{43D}\u{43E} \u{435} ${e.date}`,finishRangeSelectionPrompt:`Натиснете, за да довършите избора на времеви интервал`,maximumDate:`Последна налична дата`,minimumDate:`Първа налична дата`,next:`Напред`,previous:`Назад`,selectedDateDescription:e=>`\u{418}\u{437}\u{431}\u{440}\u{430}\u{43D}\u{430} \u{434}\u{430}\u{442}\u{430}: ${e.date}`,selectedRangeDescription:e=>`\u{418}\u{437}\u{431}\u{440}\u{430}\u{43D} \u{434}\u{438}\u{430}\u{43F}\u{430}\u{437}\u{43E}\u{43D}: ${e.dateRange}`,startRangeSelectionPrompt:`Натиснете, за да пристъпите към избора на времеви интервал`,todayDate:e=>`\u{414}\u{43D}\u{435}\u{441}, ${e.date}`,todayDateSelected:e=>`\u{414}\u{43D}\u{435}\u{441}, ${e.date} \u{441}\u{430} \u{438}\u{437}\u{431}\u{440}\u{430}\u{43D}\u{438}`};var Oo={};Oo={dateRange:e=>`${e.startDate} a\u{17E} ${e.endDate}`,dateSelected:e=>`Vybr\xe1no ${e.date}`,finishRangeSelectionPrompt:`Kliknutím dokončíte výběr rozsahu dat`,maximumDate:`Poslední dostupné datum`,minimumDate:`První dostupné datum`,next:`Další`,previous:`Předchozí`,selectedDateDescription:e=>`Vybran\xe9 datum: ${e.date}`,selectedRangeDescription:e=>`Vybran\xe9 obdob\xed: ${e.dateRange}`,startRangeSelectionPrompt:`Kliknutím zahájíte výběr rozsahu dat`,todayDate:e=>`Dnes, ${e.date}`,todayDateSelected:e=>`Dnes, vybr\xe1no ${e.date}`};var ko={};ko={dateRange:e=>`${e.startDate} til ${e.endDate}`,dateSelected:e=>`${e.date} valgt`,finishRangeSelectionPrompt:`Klik for at fuldføre valg af datoområde`,maximumDate:`Sidste ledige dato`,minimumDate:`Første ledige dato`,next:`Næste`,previous:`Forrige`,selectedDateDescription:e=>`Valgt dato: ${e.date}`,selectedRangeDescription:e=>`Valgt interval: ${e.dateRange}`,startRangeSelectionPrompt:`Klik for at starte valg af datoområde`,todayDate:e=>`I dag, ${e.date}`,todayDateSelected:e=>`I dag, ${e.date} valgt`};var Ao={};Ao={dateRange:e=>`${e.startDate} bis ${e.endDate}`,dateSelected:e=>`${e.date} ausgew\xe4hlt`,finishRangeSelectionPrompt:`Klicken, um die Auswahl des Datumsbereichs zu beenden`,maximumDate:`Letztes verfügbares Datum`,minimumDate:`Erstes verfügbares Datum`,next:`Weiter`,previous:`Zurück`,selectedDateDescription:e=>`Ausgew\xe4hltes Datum: ${e.date}`,selectedRangeDescription:e=>`Ausgew\xe4hlter Bereich: ${e.dateRange}`,startRangeSelectionPrompt:`Klicken, um die Auswahl des Datumsbereichs zu beginnen`,todayDate:e=>`Heute, ${e.date}`,todayDateSelected:e=>`Heute, ${e.date} ausgew\xe4hlt`};var jo={};jo={dateRange:e=>`${e.startDate} \u{3AD}\u{3C9}\u{3C2} ${e.endDate}`,dateSelected:e=>`\u{395}\u{3C0}\u{3B9}\u{3BB}\u{3AD}\u{3C7}\u{3B8}\u{3B7}\u{3BA}\u{3B5} ${e.date}`,finishRangeSelectionPrompt:`Κάντε κλικ για να ολοκληρώσετε την επιλογή εύρους ημερομηνιών`,maximumDate:`Τελευταία διαθέσιμη ημερομηνία`,minimumDate:`Πρώτη διαθέσιμη ημερομηνία`,next:`Επόμενο`,previous:`Προηγούμενο`,selectedDateDescription:e=>`\u{395}\u{3C0}\u{3B9}\u{3BB}\u{3B5}\u{3B3}\u{3BC}\u{3AD}\u{3BD}\u{3B7} \u{3B7}\u{3BC}\u{3B5}\u{3C1}\u{3BF}\u{3BC}\u{3B7}\u{3BD}\u{3AF}\u{3B1}: ${e.date}`,selectedRangeDescription:e=>`\u{395}\u{3C0}\u{3B9}\u{3BB}\u{3B5}\u{3B3}\u{3BC}\u{3AD}\u{3BD}\u{3BF} \u{3B5}\u{3CD}\u{3C1}\u{3BF}\u{3C2}: ${e.dateRange}`,startRangeSelectionPrompt:`Κάντε κλικ για να ξεκινήσετε την επιλογή εύρους ημερομηνιών`,todayDate:e=>`\u{3A3}\u{3AE}\u{3BC}\u{3B5}\u{3C1}\u{3B1}, ${e.date}`,todayDateSelected:e=>`\u{3A3}\u{3AE}\u{3BC}\u{3B5}\u{3C1}\u{3B1}, \u{3B5}\u{3C0}\u{3B9}\u{3BB}\u{3AD}\u{3C7}\u{3C4}\u{3B7}\u{3BA}\u{3B5} ${e.date}`};var Mo={};Mo={previous:`Previous`,next:`Next`,selectedDateDescription:e=>`Selected Date: ${e.date}`,selectedRangeDescription:e=>`Selected Range: ${e.dateRange}`,todayDate:e=>`Today, ${e.date}`,todayDateSelected:e=>`Today, ${e.date} selected`,dateSelected:e=>`${e.date} selected`,startRangeSelectionPrompt:`Click to start selecting date range`,finishRangeSelectionPrompt:`Click to finish selecting date range`,minimumDate:`First available date`,maximumDate:`Last available date`,dateRange:e=>`${e.startDate} to ${e.endDate}`};var No={};No={dateRange:e=>`${e.startDate} a ${e.endDate}`,dateSelected:e=>`${e.date} seleccionado`,finishRangeSelectionPrompt:`Haga clic para terminar de seleccionar rango de fechas`,maximumDate:`Última fecha disponible`,minimumDate:`Primera fecha disponible`,next:`Siguiente`,previous:`Anterior`,selectedDateDescription:e=>`Fecha seleccionada: ${e.date}`,selectedRangeDescription:e=>`Intervalo seleccionado: ${e.dateRange}`,startRangeSelectionPrompt:`Haga clic para comenzar a seleccionar un rango de fechas`,todayDate:e=>`Hoy, ${e.date}`,todayDateSelected:e=>`Hoy, ${e.date} seleccionado`};var Po={};Po={dateRange:e=>`${e.startDate} kuni ${e.endDate}`,dateSelected:e=>`${e.date} valitud`,finishRangeSelectionPrompt:`Klõpsake kuupäevavahemiku valimise lõpetamiseks`,maximumDate:`Viimane saadaolev kuupäev`,minimumDate:`Esimene saadaolev kuupäev`,next:`Järgmine`,previous:`Eelmine`,selectedDateDescription:e=>`Valitud kuup\xe4ev: ${e.date}`,selectedRangeDescription:e=>`Valitud vahemik: ${e.dateRange}`,startRangeSelectionPrompt:`Klõpsake kuupäevavahemiku valimiseks`,todayDate:e=>`T\xe4na, ${e.date}`,todayDateSelected:e=>`T\xe4na, ${e.date} valitud`};var Fo={};Fo={dateRange:e=>`${e.startDate} \u{2013} ${e.endDate}`,dateSelected:e=>`${e.date} valittu`,finishRangeSelectionPrompt:`Lopeta päivämääräalueen valinta napsauttamalla tätä.`,maximumDate:`Viimeinen varattavissa oleva päivämäärä`,minimumDate:`Ensimmäinen varattavissa oleva päivämäärä`,next:`Seuraava`,previous:`Edellinen`,selectedDateDescription:e=>`Valittu p\xe4iv\xe4m\xe4\xe4r\xe4: ${e.date}`,selectedRangeDescription:e=>`Valittu aikav\xe4li: ${e.dateRange}`,startRangeSelectionPrompt:`Aloita päivämääräalueen valinta napsauttamalla tätä.`,todayDate:e=>`T\xe4n\xe4\xe4n, ${e.date}`,todayDateSelected:e=>`T\xe4n\xe4\xe4n, ${e.date} valittu`};var Io={};Io={dateRange:e=>`${e.startDate} \xe0 ${e.endDate}`,dateSelected:e=>`${e.date} s\xe9lectionn\xe9`,finishRangeSelectionPrompt:`Cliquer pour finir de sélectionner la plage de dates`,maximumDate:`Dernière date disponible`,minimumDate:`Première date disponible`,next:`Suivant`,previous:`Précédent`,selectedDateDescription:e=>`Date s\xe9lectionn\xe9e\xa0: ${e.date}`,selectedRangeDescription:e=>`Plage s\xe9lectionn\xe9e\xa0: ${e.dateRange}`,startRangeSelectionPrompt:`Cliquer pour commencer à sélectionner la plage de dates`,todayDate:e=>`Aujourd'hui, ${e.date}`,todayDateSelected:e=>`Aujourd\u{2019}hui, ${e.date} s\xe9lectionn\xe9`};var Lo={};Lo={dateRange:e=>`${e.startDate} \u{5E2}\u{5D3} ${e.endDate}`,dateSelected:e=>`${e.date} \u{5E0}\u{5D1}\u{5D7}\u{5E8}`,finishRangeSelectionPrompt:`חץ כדי לסיים את בחירת טווח התאריכים`,maximumDate:`תאריך פנוי אחרון`,minimumDate:`תאריך פנוי ראשון`,next:`הבא`,previous:`הקודם`,selectedDateDescription:e=>`\u{5EA}\u{5D0}\u{5E8}\u{5D9}\u{5DA} \u{5E0}\u{5D1}\u{5D7}\u{5E8}: ${e.date}`,selectedRangeDescription:e=>`\u{5D8}\u{5D5}\u{5D5}\u{5D7} \u{5E0}\u{5D1}\u{5D7}\u{5E8}: ${e.dateRange}`,startRangeSelectionPrompt:`לחץ כדי להתחיל בבחירת טווח התאריכים`,todayDate:e=>`\u{5D4}\u{5D9}\u{5D5}\u{5DD}, ${e.date}`,todayDateSelected:e=>`\u{5D4}\u{5D9}\u{5D5}\u{5DD}, ${e.date} \u{5E0}\u{5D1}\u{5D7}\u{5E8}`};var Ro={};Ro={dateRange:e=>`${e.startDate} do ${e.endDate}`,dateSelected:e=>`${e.date} odabran`,finishRangeSelectionPrompt:`Kliknite da dovršite raspon odabranih datuma`,maximumDate:`Posljednji raspoloživi datum`,minimumDate:`Prvi raspoloživi datum`,next:`Sljedeći`,previous:`Prethodni`,selectedDateDescription:e=>`Odabrani datum: ${e.date}`,selectedRangeDescription:e=>`Odabrani raspon: ${e.dateRange}`,startRangeSelectionPrompt:`Kliknite da započnete raspon odabranih datuma`,todayDate:e=>`Danas, ${e.date}`,todayDateSelected:e=>`Danas, odabran ${e.date}`};var zo={};zo={dateRange:e=>`${e.startDate}\u{2013}${e.endDate}`,dateSelected:e=>`${e.date} kiv\xe1lasztva`,finishRangeSelectionPrompt:`Kattintson a dátumtartomány kijelölésének befejezéséhez`,maximumDate:`Utolsó elérhető dátum`,minimumDate:`Az első elérhető dátum`,next:`Következő`,previous:`Előző`,selectedDateDescription:e=>`Kijel\xf6lt d\xe1tum: ${e.date}`,selectedRangeDescription:e=>`Kijel\xf6lt tartom\xe1ny: ${e.dateRange}`,startRangeSelectionPrompt:`Kattintson a dátumtartomány kijelölésének indításához`,todayDate:e=>`Ma, ${e.date}`,todayDateSelected:e=>`Ma, ${e.date} kijel\xf6lve`};var Bo={};Bo={dateRange:e=>`Da ${e.startDate} a ${e.endDate}`,dateSelected:e=>`${e.date} selezionata`,finishRangeSelectionPrompt:`Fai clic per completare la selezione dell’intervallo di date`,maximumDate:`Ultima data disponibile`,minimumDate:`Prima data disponibile`,next:`Successivo`,previous:`Precedente`,selectedDateDescription:e=>`Data selezionata: ${e.date}`,selectedRangeDescription:e=>`Intervallo selezionato: ${e.dateRange}`,startRangeSelectionPrompt:`Fai clic per selezionare l’intervallo di date`,todayDate:e=>`Oggi, ${e.date}`,todayDateSelected:e=>`Oggi, ${e.date} selezionata`};var Vo={};Vo={dateRange:e=>`${e.startDate} \u{304B}\u{3089} ${e.endDate}`,dateSelected:e=>`${e.date} \u{3092}\u{9078}\u{629E}`,finishRangeSelectionPrompt:`クリックして日付範囲の選択を終了`,maximumDate:`最終利用可能日`,minimumDate:`最初の利用可能日`,next:`次へ`,previous:`前へ`,selectedDateDescription:e=>`\u{9078}\u{629E}\u{3057}\u{305F}\u{65E5}\u{4ED8} : ${e.date}`,selectedRangeDescription:e=>`\u{9078}\u{629E}\u{7BC4}\u{56F2} : ${e.dateRange}`,startRangeSelectionPrompt:`クリックして日付範囲の選択を開始`,todayDate:e=>`\u{672C}\u{65E5}\u{3001}${e.date}`,todayDateSelected:e=>`\u{672C}\u{65E5}\u{3001}${e.date} \u{3092}\u{9078}\u{629E}`};var Ho={};Ho={dateRange:e=>`${e.startDate} ~ ${e.endDate}`,dateSelected:e=>`${e.date} \u{C120}\u{D0DD}\u{B428}`,finishRangeSelectionPrompt:`날짜 범위 선택을 완료하려면 클릭하십시오.`,maximumDate:`마지막으로 사용 가능한 일자`,minimumDate:`처음으로 사용 가능한 일자`,next:`다음`,previous:`이전`,selectedDateDescription:e=>`\u{C120}\u{D0DD} \u{C77C}\u{C790}: ${e.date}`,selectedRangeDescription:e=>`\u{C120}\u{D0DD} \u{BC94}\u{C704}: ${e.dateRange}`,startRangeSelectionPrompt:`날짜 범위 선택을 시작하려면 클릭하십시오.`,todayDate:e=>`\u{C624}\u{B298}, ${e.date}`,todayDateSelected:e=>`\u{C624}\u{B298}, ${e.date} \u{C120}\u{D0DD}\u{B428}`};var Uo={};Uo={dateRange:e=>`Nuo ${e.startDate} iki ${e.endDate}`,dateSelected:e=>`Pasirinkta ${e.date}`,finishRangeSelectionPrompt:`Spustelėkite, kad baigtumėte pasirinkti datų intervalą`,maximumDate:`Paskutinė galima data`,minimumDate:`Pirmoji galima data`,next:`Paskesnis`,previous:`Ankstesnis`,selectedDateDescription:e=>`Pasirinkta data: ${e.date}`,selectedRangeDescription:e=>`Pasirinktas intervalas: ${e.dateRange}`,startRangeSelectionPrompt:`Spustelėkite, kad pradėtumėte pasirinkti datų intervalą`,todayDate:e=>`\u{160}iandien, ${e.date}`,todayDateSelected:e=>`\u{160}iandien, pasirinkta ${e.date}`};var Wo={};Wo={dateRange:e=>`No ${e.startDate} l\u{12B}dz ${e.endDate}`,dateSelected:e=>`Atlas\u{12B}ts: ${e.date}`,finishRangeSelectionPrompt:`Noklikšķiniet, lai pabeigtu datumu diapazona atlasi`,maximumDate:`Pēdējais pieejamais datums`,minimumDate:`Pirmais pieejamais datums`,next:`Tālāk`,previous:`Atpakaļ`,selectedDateDescription:e=>`Atlas\u{12B}tais datums: ${e.date}`,selectedRangeDescription:e=>`Atlas\u{12B}tais diapazons: ${e.dateRange}`,startRangeSelectionPrompt:`Noklikšķiniet, lai sāktu datumu diapazona atlasi`,todayDate:e=>`\u{160}odien, ${e.date}`,todayDateSelected:e=>`Atlas\u{12B}ta \u{161}odiena, ${e.date}`};var Go={};Go={dateRange:e=>`${e.startDate} til ${e.endDate}`,dateSelected:e=>`${e.date} valgt`,finishRangeSelectionPrompt:`Klikk for å fullføre valg av datoområde`,maximumDate:`Siste tilgjengelige dato`,minimumDate:`Første tilgjengelige dato`,next:`Neste`,previous:`Forrige`,selectedDateDescription:e=>`Valgt dato: ${e.date}`,selectedRangeDescription:e=>`Valgt omr\xe5de: ${e.dateRange}`,startRangeSelectionPrompt:`Klikk for å starte valg av datoområde`,todayDate:e=>`I dag, ${e.date}`,todayDateSelected:e=>`I dag, ${e.date} valgt`};var Ko={};Ko={dateRange:e=>`${e.startDate} tot ${e.endDate}`,dateSelected:e=>`${e.date} geselecteerd`,finishRangeSelectionPrompt:`Klik om de selectie van het datumbereik te voltooien`,maximumDate:`Laatste beschikbare datum`,minimumDate:`Eerste beschikbare datum`,next:`Volgende`,previous:`Vorige`,selectedDateDescription:e=>`Geselecteerde datum: ${e.date}`,selectedRangeDescription:e=>`Geselecteerd bereik: ${e.dateRange}`,startRangeSelectionPrompt:`Klik om het datumbereik te selecteren`,todayDate:e=>`Vandaag, ${e.date}`,todayDateSelected:e=>`Vandaag, ${e.date} geselecteerd`};var qo={};qo={dateRange:e=>`${e.startDate} do ${e.endDate}`,dateSelected:e=>`Wybrano ${e.date}`,finishRangeSelectionPrompt:`Kliknij, aby zakończyć wybór zakresu dat`,maximumDate:`Ostatnia dostępna data`,minimumDate:`Pierwsza dostępna data`,next:`Dalej`,previous:`Wstecz`,selectedDateDescription:e=>`Wybrana data: ${e.date}`,selectedRangeDescription:e=>`Wybrany zakres: ${e.dateRange}`,startRangeSelectionPrompt:`Kliknij, aby rozpocząć wybór zakresu dat`,todayDate:e=>`Dzisiaj, ${e.date}`,todayDateSelected:e=>`Dzisiaj wybrano ${e.date}`};var Jo={};Jo={dateRange:e=>`${e.startDate} a ${e.endDate}`,dateSelected:e=>`${e.date} selecionado`,finishRangeSelectionPrompt:`Clique para concluir a seleção do intervalo de datas`,maximumDate:`Última data disponível`,minimumDate:`Primeira data disponível`,next:`Próximo`,previous:`Anterior`,selectedDateDescription:e=>`Data selecionada: ${e.date}`,selectedRangeDescription:e=>`Intervalo selecionado: ${e.dateRange}`,startRangeSelectionPrompt:`Clique para iniciar a seleção do intervalo de datas`,todayDate:e=>`Hoje, ${e.date}`,todayDateSelected:e=>`Hoje, ${e.date} selecionado`};var Yo={};Yo={dateRange:e=>`${e.startDate} a ${e.endDate}`,dateSelected:e=>`${e.date} selecionado`,finishRangeSelectionPrompt:`Clique para terminar de selecionar o intervalo de datas`,maximumDate:`Última data disponível`,minimumDate:`Primeira data disponível`,next:`Próximo`,previous:`Anterior`,selectedDateDescription:e=>`Data selecionada: ${e.date}`,selectedRangeDescription:e=>`Intervalo selecionado: ${e.dateRange}`,startRangeSelectionPrompt:`Clique para começar a selecionar o intervalo de datas`,todayDate:e=>`Hoje, ${e.date}`,todayDateSelected:e=>`Hoje, ${e.date} selecionado`};var Xo={};Xo={dateRange:e=>`De la ${e.startDate} p\xe2n\u{103} la ${e.endDate}`,dateSelected:e=>`${e.date} selectat\u{103}`,finishRangeSelectionPrompt:`Apăsaţi pentru a finaliza selecţia razei pentru dată`,maximumDate:`Ultima dată disponibilă`,minimumDate:`Prima dată disponibilă`,next:`Următorul`,previous:`Înainte`,selectedDateDescription:e=>`Dat\u{103} selectat\u{103}: ${e.date}`,selectedRangeDescription:e=>`Interval selectat: ${e.dateRange}`,startRangeSelectionPrompt:`Apăsaţi pentru a începe selecţia razei pentru dată`,todayDate:e=>`Ast\u{103}zi, ${e.date}`,todayDateSelected:e=>`Azi, ${e.date} selectat\u{103}`};var Zo={};Zo={dateRange:e=>`\u{421} ${e.startDate} \u{43F}\u{43E} ${e.endDate}`,dateSelected:e=>`\u{412}\u{44B}\u{431}\u{440}\u{430}\u{43D}\u{43E} ${e.date}`,finishRangeSelectionPrompt:`Щелкните, чтобы завершить выбор диапазона дат`,maximumDate:`Последняя доступная дата`,minimumDate:`Первая доступная дата`,next:`Далее`,previous:`Назад`,selectedDateDescription:e=>`\u{412}\u{44B}\u{431}\u{440}\u{430}\u{43D}\u{43D}\u{430}\u{44F} \u{434}\u{430}\u{442}\u{430}: ${e.date}`,selectedRangeDescription:e=>`\u{412}\u{44B}\u{431}\u{440}\u{430}\u{43D}\u{43D}\u{44B}\u{439} \u{434}\u{438}\u{430}\u{43F}\u{430}\u{437}\u{43E}\u{43D}: ${e.dateRange}`,startRangeSelectionPrompt:`Щелкните, чтобы начать выбор диапазона дат`,todayDate:e=>`\u{421}\u{435}\u{433}\u{43E}\u{434}\u{43D}\u{44F}, ${e.date}`,todayDateSelected:e=>`\u{421}\u{435}\u{433}\u{43E}\u{434}\u{43D}\u{44F}, \u{432}\u{44B}\u{431}\u{440}\u{430}\u{43D}\u{43E} ${e.date}`};var Qo={};Qo={dateRange:e=>`Od ${e.startDate} do ${e.endDate}`,dateSelected:e=>`Vybrat\xfd d\xe1tum ${e.date}`,finishRangeSelectionPrompt:`Kliknutím dokončíte výber rozsahu dátumov`,maximumDate:`Posledný dostupný dátum`,minimumDate:`Prvý dostupný dátum`,next:`Nasledujúce`,previous:`Predchádzajúce`,selectedDateDescription:e=>`Vybrat\xfd d\xe1tum: ${e.date}`,selectedRangeDescription:e=>`Vybrat\xfd rozsah: ${e.dateRange}`,startRangeSelectionPrompt:`Kliknutím spustíte výber rozsahu dátumov`,todayDate:e=>`Dnes ${e.date}`,todayDateSelected:e=>`Vybrat\xfd dne\u{161}n\xfd d\xe1tum ${e.date}`};var $o={};$o={dateRange:e=>`${e.startDate} do ${e.endDate}`,dateSelected:e=>`${e.date} izbrano`,finishRangeSelectionPrompt:`Kliknite za dokončanje izbire datumskega obsega`,maximumDate:`Zadnji razpoložljivi datum`,minimumDate:`Prvi razpoložljivi datum`,next:`Naprej`,previous:`Nazaj`,selectedDateDescription:e=>`Izbrani datum: ${e.date}`,selectedRangeDescription:e=>`Izbrano obmo\u{10D}je: ${e.dateRange}`,startRangeSelectionPrompt:`Kliknite za začetek izbire datumskega obsega`,todayDate:e=>`Danes, ${e.date}`,todayDateSelected:e=>`Danes, ${e.date} izbrano`};var es={};es={dateRange:e=>`${e.startDate} do ${e.endDate}`,dateSelected:e=>`${e.date} izabran`,finishRangeSelectionPrompt:`Kliknite da dovršite opseg izabranih datuma`,maximumDate:`Zadnji raspoloživi datum`,minimumDate:`Prvi raspoloživi datum`,next:`Sledeći`,previous:`Prethodni`,selectedDateDescription:e=>`Izabrani datum: ${e.date}`,selectedRangeDescription:e=>`Izabrani period: ${e.dateRange}`,startRangeSelectionPrompt:`Kliknite da započnete opseg izabranih datuma`,todayDate:e=>`Danas, ${e.date}`,todayDateSelected:e=>`Danas, izabran ${e.date}`};var ts={};ts={dateRange:e=>`${e.startDate} till ${e.endDate}`,dateSelected:e=>`${e.date} har valts`,finishRangeSelectionPrompt:`Klicka för att avsluta val av datumintervall`,maximumDate:`Sista tillgängliga datum`,minimumDate:`Första tillgängliga datum`,next:`Nästa`,previous:`Föregående`,selectedDateDescription:e=>`Valt datum: ${e.date}`,selectedRangeDescription:e=>`Valt intervall: ${e.dateRange}`,startRangeSelectionPrompt:`Klicka för att välja datumintervall`,todayDate:e=>`Idag, ${e.date}`,todayDateSelected:e=>`Idag, ${e.date} har valts`};var ns={};ns={dateRange:e=>`${e.startDate} - ${e.endDate}`,dateSelected:e=>`${e.date} se\xe7ildi`,finishRangeSelectionPrompt:`Tarih aralığı seçimini tamamlamak için tıklayın`,maximumDate:`Son müsait tarih`,minimumDate:`İlk müsait tarih`,next:`Sonraki`,previous:`Önceki`,selectedDateDescription:e=>`Se\xe7ilen Tarih: ${e.date}`,selectedRangeDescription:e=>`Se\xe7ilen Aral\u{131}k: ${e.dateRange}`,startRangeSelectionPrompt:`Tarih aralığı seçimini başlatmak için tıklayın`,todayDate:e=>`Bug\xfcn, ${e.date}`,todayDateSelected:e=>`Bug\xfcn, ${e.date} se\xe7ildi`};var rs={};rs={dateRange:e=>`${e.startDate} \u{2014} ${e.endDate}`,dateSelected:e=>`\u{412}\u{438}\u{431}\u{440}\u{430}\u{43D}\u{43E} ${e.date}`,finishRangeSelectionPrompt:`Натисніть, щоб завершити вибір діапазону дат`,maximumDate:`Остання доступна дата`,minimumDate:`Перша доступна дата`,next:`Наступний`,previous:`Попередній`,selectedDateDescription:e=>`\u{412}\u{438}\u{431}\u{440}\u{430}\u{43D}\u{430} \u{434}\u{430}\u{442}\u{430}: ${e.date}`,selectedRangeDescription:e=>`\u{412}\u{438}\u{431}\u{440}\u{430}\u{43D}\u{438}\u{439} \u{434}\u{456}\u{430}\u{43F}\u{430}\u{437}\u{43E}\u{43D}: ${e.dateRange}`,startRangeSelectionPrompt:`Натисніть, щоб почати вибір діапазону дат`,todayDate:e=>`\u{421}\u{44C}\u{43E}\u{433}\u{43E}\u{434}\u{43D}\u{456}, ${e.date}`,todayDateSelected:e=>`\u{421}\u{44C}\u{43E}\u{433}\u{43E}\u{434}\u{43D}\u{456}, \u{432}\u{438}\u{431}\u{440}\u{430}\u{43D}\u{43E} ${e.date}`};var is={};is={dateRange:e=>`${e.startDate} \u{81F3} ${e.endDate}`,dateSelected:e=>`\u{5DF2}\u{9009}\u{62E9} ${e.date}`,finishRangeSelectionPrompt:`单击以完成选择日期范围`,maximumDate:`最后一个可用日期`,minimumDate:`第一个可用日期`,next:`下一页`,previous:`上一页`,selectedDateDescription:e=>`\u{9009}\u{5B9A}\u{7684}\u{65E5}\u{671F}\u{FF1A}${e.date}`,selectedRangeDescription:e=>`\u{9009}\u{5B9A}\u{7684}\u{8303}\u{56F4}\u{FF1A}${e.dateRange}`,startRangeSelectionPrompt:`单击以开始选择日期范围`,todayDate:e=>`\u{4ECA}\u{5929}\u{FF0C}\u{5373} ${e.date}`,todayDateSelected:e=>`\u{5DF2}\u{9009}\u{62E9}\u{4ECA}\u{5929}\u{FF0C}\u{5373} ${e.date}`};var as={};as={dateRange:e=>`${e.startDate} \u{81F3} ${e.endDate}`,dateSelected:e=>`\u{5DF2}\u{9078}\u{53D6} ${e.date}`,finishRangeSelectionPrompt:`按一下以完成選取日期範圍`,maximumDate:`最後一個可用日期`,minimumDate:`第一個可用日期`,next:`下一頁`,previous:`上一頁`,selectedDateDescription:e=>`\u{9078}\u{5B9A}\u{7684}\u{65E5}\u{671F}\u{FF1A}${e.date}`,selectedRangeDescription:e=>`\u{9078}\u{5B9A}\u{7684}\u{7BC4}\u{570D}\u{FF1A}${e.dateRange}`,startRangeSelectionPrompt:`按一下以開始選取日期範圍`,todayDate:e=>`\u{4ECA}\u{5929}\u{FF0C}${e.date}`,todayDateSelected:e=>`\u{5DF2}\u{9078}\u{53D6}\u{4ECA}\u{5929}\u{FF0C}${e.date}`};var os={};os={"ar-AE":Eo,"bg-BG":Do,"cs-CZ":Oo,"da-DK":ko,"de-DE":Ao,"el-GR":jo,"en-US":Mo,"es-ES":No,"et-EE":Po,"fi-FI":Fo,"fr-FR":Io,"he-IL":Lo,"hr-HR":Ro,"hu-HU":zo,"it-IT":Bo,"ja-JP":Vo,"ko-KR":Ho,"lt-LT":Uo,"lv-LV":Wo,"nb-NO":Go,"nl-NL":Ko,"pl-PL":qo,"pt-BR":Jo,"pt-PT":Yo,"ro-RO":Xo,"ru-RU":Zo,"sk-SK":Qo,"sl-SI":$o,"sr-SP":es,"sv-SE":ts,"tr-TR":ns,"uk-UA":rs,"zh-CN":is,"zh-TW":as};function ss(e){return e&&e.__esModule?e.default:e}var cs=new WeakMap;function ls(e){return e?.calendar.identifier===`gregory`&&e.era===`BC`?`short`:void 0}function us(e){let t=i(ss(os),`@react-aria/calendar`),n,r;`highlightedRange`in e?{start:n,end:r}=e.highlightedRange||{}:(n=Array.isArray(e.value)?e.value[0]:e.value??void 0,r=Array.isArray(e.value)?e.value.at(-1):e.value??void 0);let a=Z({weekday:`long`,month:`long`,year:`numeric`,day:`numeric`,era:ls(n)||ls(r),timeZone:e.timeZone}),{locale:o}=F(),s=(0,z.useMemo)(()=>new Intl.ListFormat(o),[o]),c=`anchorDate`in e?e.anchorDate:null;return(0,z.useMemo)(()=>{if(!c&&n&&r){if(V(n,r)){let r=a.format(n.toDate(e.timeZone));return t.format(`selectedDateDescription`,{date:r})}if(`highlightedRange`in e){let i=fs(a,t,n,r,e.timeZone);return t.format(`selectedRangeDescription`,{dateRange:i})}if(Array.isArray(e.value)){let n=e.value.map(t=>a.format(t.toDate(e.timeZone))),r=s.format(n);return t.format(`selectedDateDescription`,{date:r})}}return``},[n,r,c,e,t,a,s])}function ds(e,t,n,r){let a=i(ss(os),`@react-aria/calendar`),o=ls(e)||ls(t),s=Z({month:`long`,year:`numeric`,era:o,calendar:e.calendar.identifier,timeZone:n}),c=Z({month:`long`,year:`numeric`,day:`numeric`,era:o,calendar:e.calendar.identifier,timeZone:n});return(0,z.useMemo)(()=>{if(V(e,Et(e))){let i=e,o=t;if(e.calendar.getFormattableMonth&&(i=e.calendar.getFormattableMonth(e)),t.calendar.getFormattableMonth&&(o=t.calendar.getFormattableMonth(t)),V(t,Dt(e)))return s.format(i.toDate(n));if(V(t,Dt(t)))return r?fs(s,a,i,o,n):s.formatRange(i.toDate(n),o.toDate(n))}return r?fs(c,a,e,t,n):c.formatRange(e.toDate(n),t.toDate(n))},[e,t,s,c,a,n,r])}function fs(e,t,n,r,i){let a=e.formatRangeToParts(n.toDate(i),r.toDate(i)),o=-1;for(let e=0;eo&&(c+=a[e].value);return t.format(`dateRange`,{startDate:s,endDate:c})}function ps(e){return e&&e.__esModule?e.default:e}function ms(e,t){let n=i(ps(os),`@react-aria/calendar`),r=L(e),a=ds(t.visibleRange.start,t.visibleRange.end,t.timeZone,!1),o=ds(t.visibleRange.start,t.visibleRange.end,t.timeZone,!0);me(()=>{t.isFocused||u(o)},[o]);let s=us(t);me(()=>{s&&u(s,`polite`,4e3)},[s]);let c=re([!!e.errorMessage,e.isInvalid,e.validationState]);cs.set(t,{ariaLabel:e[`aria-label`],ariaLabelledBy:e[`aria-labelledby`],errorMessageId:c,selectedDateDescription:s});let[l,d]=(0,z.useState)(!1),f=e.isDisabled||t.isNextVisibleRangeInvalid();f&&l&&(d(!1),t.setFocused(!0));let[m,h]=(0,z.useState)(!1),g=e.isDisabled||t.isPreviousVisibleRangeInvalid();g&&m&&(h(!1),t.setFocused(!0));let _=p({id:e.id,"aria-label":[e[`aria-label`],o].filter(Boolean).join(`, `),"aria-labelledby":e[`aria-labelledby`]});return{calendarProps:T(r,_,{role:`application`,"aria-details":e[`aria-details`]||void 0,"aria-describedby":e[`aria-describedby`]||void 0}),nextButtonProps:{onPress:()=>t.focusNextPage(),"aria-label":n.format(`next`),isDisabled:f,onFocusChange:d},prevButtonProps:{onPress:()=>t.focusPreviousPage(),"aria-label":n.format(`previous`),isDisabled:g,onFocusChange:h},errorMessageProps:{id:c},title:a}}function hs(e,t){let{startDate:n=t.visibleRange.start,endDate:r=t.visibleRange.end,firstDayOfWeek:i}=e,{direction:a}=F(),{keyboardProps:o}=fe({shortcuts:{End:()=>{t.focusSectionEnd()},Home:()=>{t.focusSectionStart()},Escape:()=>(`setAnchorDate`in t&&t.setAnchorDate(null),!1)}}),{keyboardProps:s}=fe({shortcuts:{Enter:()=>{t.selectFocusedDate()}," ":()=>{t.selectFocusedDate()},PageUp:()=>{t.focusPreviousSection()},"Shift+PageUp":()=>{t.focusPreviousSection(!0)},PageDown:()=>{t.focusNextSection()},"Shift+PageDown":()=>{t.focusNextSection(!0)},ArrowLeft:()=>{a===`rtl`?t.focusNextDay():t.focusPreviousDay()},ArrowUp:()=>{t.focusPreviousRow()},ArrowRight:()=>{a===`rtl`?t.focusPreviousDay():t.focusNextDay()},ArrowDown:()=>{t.focusNextRow()}},allowRepeats:!0}),c=ds(n,r,t.timeZone,!0),{ariaLabel:l,ariaLabelledBy:u}=cs.get(t),d=p({"aria-label":[l,c].filter(Boolean).join(`, `),"aria-labelledby":u}),f=Z({weekday:e.weekdayStyle||`narrow`,timeZone:t.timeZone}),{locale:m}=F(),h=(0,z.useMemo)(()=>{let e=t.visibleDuration.days&&t.visibleDuration.days<7,r=e?n:kt(vt(t.timeZone),m,i),a=e?t.visibleDuration.days:7;return[...Array(a).keys()].map(e=>{let n=r.add({days:e}).toDate(t.timeZone);return f.format(n)})},[m,t.timeZone,f,i,n,t.visibleDuration.days]),g=t.getWeeksInMonth(n);return{gridProps:T(d,{role:`grid`,"aria-readonly":t.isReadOnly||void 0,"aria-disabled":t.isDisabled||void 0,"aria-multiselectable":`highlightedRange`in t||t.selectionMode===`multiple`||void 0,onFocus:()=>t.setFocused(!0),onBlur:()=>t.setFocused(!1)},o,s),headerProps:{"aria-hidden":!0},weekDays:h,weeksInMonth:g}}function gs(e){return e&&e.__esModule?e.default:e}function _s(e,t,n){let{date:r,isDisabled:a}=e,{errorMessageId:o,selectedDateDescription:s}=cs.get(t),c=i(gs(os),`@react-aria/calendar`),l=Z({weekday:`long`,day:`numeric`,month:`long`,year:`numeric`,era:ls(r),timeZone:t.timeZone}),u=t.isCellFocused(r)&&!e.isOutsideMonth;a=a||t.isCellDisabled(r)||!!e.isOutsideMonth;let d=t.isCellUnavailable(r),f=!a&&!d,p=t.isSelected(r)&&f,m=!1;t.isValueInvalid&&(`highlightedRange`in t?m=!t.anchorDate&&t.highlightedRange!=null&&r.compare(t.highlightedRange.start)>=0&&r.compare(t.highlightedRange.end)<=0:Array.isArray(t.value)?m=t.value.some(e=>V(e,r)):t.value&&(m=V(t.value,r))),m&&!a&&(p=!0),r=Je(r,ft);let h=(0,z.useMemo)(()=>r.toDate(t.timeZone),[r,t.timeZone]),g=mt(r,t.timeZone),_=(0,z.useMemo)(()=>{let e=``;return`highlightedRange`in t&&t.value&&!t.anchorDate&&(V(r,t.value.start)||V(r,t.value.end))&&(e=s+`, `),e+=l.format(h),g?e=c.format(p?`todayDateSelected`:`todayDate`,{date:e}):p&&(e=c.format(`dateSelected`,{date:e})),t.minValue&&V(r,t.minValue)?e+=`, `+c.format(`minimumDate`):t.maxValue&&V(r,t.maxValue)&&(e+=`, `+c.format(`maximumDate`)),e},[l,h,c,p,g,r,t,s]),y=``;`anchorDate`in t&&u&&!t.isReadOnly&&f&&(y=t.anchorDate?c.format(`finishRangeSelectionPrompt`):c.format(`startRangeSelectionPrompt`));let b=Re(y),x=(0,z.useRef)(!1),S=(0,z.useRef)(!1),C=(0,z.useRef)(void 0),{pressProps:w,isPressed:E}=se({shouldCancelOnPointerExit:`anchorDate`in t&&!!t.anchorDate,preventFocusOnPress:!0,isDisabled:!f||t.isReadOnly,onPressStart(e){if(t.isReadOnly){t.setFocusedDate(r),t.setFocused(!0);return}if(`highlightedRange`in t&&!t.anchorDate&&(e.pointerType===`mouse`||e.pointerType===`touch`)){if(t.highlightedRange&&!m){if(V(r,t.highlightedRange.start)){t.setAnchorDate(t.highlightedRange.end),t.setFocusedDate(r),t.setFocused(!0),t.setDragging(!0),S.current=!0;return}if(V(r,t.highlightedRange.end)){t.setAnchorDate(t.highlightedRange.start),t.setFocusedDate(r),t.setFocused(!0),t.setDragging(!0),S.current=!0;return}}let n=()=>{t.setDragging(!0),C.current=void 0,t.selectDate(r),t.setFocusedDate(r),t.setFocused(!0),x.current=!0};e.pointerType===`touch`?C.current=setTimeout(n,200):n()}},onPressEnd(){S.current=!1,x.current=!1,clearTimeout(C.current),C.current=void 0},onPress(){!(`anchorDate`in t)&&!t.isReadOnly&&(t.selectDate(r),t.setFocusedDate(r),t.setFocused(!0))},onPressUp(e){t.isReadOnly||(`anchorDate`in t&&C.current&&(t.selectDate(r),t.setFocusedDate(r),t.setFocused(!0)),`anchorDate`in t&&(S.current?t.setAnchorDate(r):t.anchorDate&&!x.current?(t.selectDate(r),t.setFocusedDate(r),t.setFocused(!0)):e.pointerType===`keyboard`&&!t.anchorDate?(t.selectDate(r),t.focusNearestAvailableDate(r)):e.pointerType===`virtual`&&(t.selectDate(r),t.setFocusedDate(r),t.setFocused(!0))))}}),D;a||(D=V(r,t.focusedDate)?0:-1),(0,z.useEffect)(()=>{u&&n.current&&(j(n.current),de()!==`pointer`&&v()===n.current&&Be(n.current,{containingElement:Le(n.current)}))},[u,n]);let O=Z({day:`numeric`,timeZone:t.timeZone,calendar:r.calendar.identifier}),k=(0,z.useMemo)(()=>O.formatToParts(h).find(e=>e.type===`day`).value,[O,h]);return{cellProps:{role:`gridcell`,"aria-disabled":!f||void 0,"aria-selected":p||void 0,"aria-invalid":m||void 0},buttonProps:T(w,{onFocus(){a||(t.setFocusedDate(r),t.setFocused(!0))},tabIndex:D,role:`button`,"aria-disabled":!f||void 0,"aria-label":_,"aria-invalid":m||void 0,"aria-describedby":[m?o:void 0,b[`aria-describedby`]].filter(Boolean).join(` `)||void 0,onPointerEnter(e){`highlightDate`in t&&(e.pointerType!==`touch`||t.isDragging)&&f&&t.highlightDate(r)},onPointerDown(e){let t=le(e);t instanceof HTMLElement&&`releasePointerCapture`in t&&(`hasPointerCapture`in t?t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId):t.releasePointerCapture(e.pointerId))},onContextMenu(e){e.preventDefault()}}),isPressed:E,isFocused:u,isSelected:p,isDisabled:a,isUnavailable:d,isOutsideVisibleRange:r.compare(t.visibleRange.start)<0||r.compare(t.visibleRange.end)>0,isInvalid:m,formattedDate:k}}function vs(e,t){let n=Z({year:e.format?.year||`numeric`,era:e.format?.era||(t.focusedDate.calendar.identifier===`gregory`&&t.focusedDate.era===`BC`?`short`:void 0),calendar:t.focusedDate.calendar.identifier,timeZone:t.timeZone}),r=e.visibleYears||20,i=t.focusedDate.subtract({years:Math.floor(r/2)}),a=t.focusedDate.add({years:Math.ceil(r/2)-1});t.maxValue&&a.compare(t.maxValue)>0&&(a=H(t.maxValue),i=a.subtract({years:r-1})),t.minValue&&i.compare(t.minValue)<0&&(i=H(t.minValue),a=i.add({years:r-1}),t.maxValue&&a.compare(t.maxValue)>0&&(a=H(t.maxValue)));let o=[],s=i,c=0;for(;s.compare(a)<=0;)dt(s,t.focusedDate)&&(c=o.length),o.push({id:o.length,date:s,formatted:n.format(s.toDate(t.timeZone))}),s=s.add({years:1});let{locale:l}=F();return{"aria-label":(0,z.useMemo)(()=>new Intl.DisplayNames(l,{type:`dateTimeField`}).of(`year`),[l]),value:c,onChange:e=>{e!=null&&t.setFocusedDate(o[e].date)},items:o}}function ys(e,t){let n=(0,z.useMemo)(()=>{let n=t.visibleRange.start;return e.offset&&(n=n.add(e.offset)),n},[t.visibleRange.start,e.offset]),r=t.visibleDuration.days||t.visibleDuration.weeks,i=Z({day:e.format?.day||(r?`numeric`:void 0),month:e.format?.month||`long`,year:e.format?.year||`numeric`,era:e.format?.era||n&&n.calendar.identifier===`gregory`&&n.era===`BC`?`short`:void 0,calendar:t.visibleRange?.start.calendar.identifier,timeZone:t.timeZone});return(0,z.useMemo)(()=>{if(r)return i.formatRange(n.toDate(t.timeZone),t.visibleRange.end.toDate(t.timeZone));let e=n.calendar.getFormattableMonth?n.calendar.getFormattableMonth(n):n;return i.format(e.toDate(t.timeZone))},[i,r,n,t.timeZone,t.visibleRange.end])}function bs(e,t,n){let{commitBehavior:r=`select`,...i}=e,a=ms(i,t),o=(0,z.useRef)(!1),s=(0,z.useRef)(typeof window<`u`?window:null);m(s,`pointerdown`,e=>{o.current=e.width===0&&e.height===0});let c={clear:()=>t.clearSelection(),reset:()=>t.setAnchorDate(null),select:()=>t.commitSelection()};return m(s,`pointerup`,e=>{if(o.current){o.current=!1;return}if(t.setDragging(!1),!t.anchorDate)return;let i=e.target;n.current&&k(n.current)&&(!te(n.current,i)||!i.closest(`button, [role="button"]`))&&c[r]()}),a.calendarProps.onBlur=e=>{n.current&&(!e.relatedTarget||!te(n.current,e.relatedTarget))&&t.anchorDate&&c[r]()},m(n,`touchmove`,e=>{t.isDragging&&e.preventDefault()},{passive:!1,capture:!0}),a}function xs(e,t,n){return t!=null&&e.compare(t)<0||n!=null&&e.compare(n)>0}function Ss(e,t,n,r,i){let a={};for(let e in t)a[e]=Math.floor(t[e]/2),a[e]>0&&t[e]%2==0&&a[e]--;return Ts(e,Cs(e,t,n).subtract(a),t,n,r,i)}function Cs(e,t,n,r,i){let a=e;return t.years?a=Ot(e):t.months?a=Et(e):(t.weeks||t.days&&t.days>7)&&(a=kt(e,n)),Ts(e,a,t,n,r,i)}function ws(e,t,n,r,i){let a={...t};return a.days?a.days--:a.weeks?a.weeks--:a.months?a.months--:a.years&&a.years--,Ts(e,Cs(e,t,n).subtract(a),t,n,r,i)}function Ts(e,t,n,r,i,a){if(i&&e.compare(i)>=0){let e=Lt(t,Cs(H(i),n,r));e&&(t=e)}if(a&&e.compare(a)<=0){let e=It(t,ws(H(a),n,r));e&&(t=e)}return t}function Es(e,t,n){if(t){let n=Lt(e,H(t));n&&(e=n)}if(n){let t=It(e,H(n));t&&(e=t)}return e}function Ds(e,t,n){if(!n)return e;for(;e.compare(t)>=0&&n(e);)e=e.subtract({days:1});return e.compare(t)>=0?e:null}function Os(e,t){return e===t||e.days===t.days&&e.weeks===t.weeks&&e.months===t.months&&e.years===t.years}function ks(e){let t=(0,z.useMemo)(()=>new Y(e.locale),[e.locale]),n=(0,z.useMemo)(()=>t.resolvedOptions(),[t]),{locale:r,createCalendar:i,visibleDuration:a={months:1},minValue:o,maxValue:s,selectionAlignment:c,isDateUnavailable:l,pageBehavior:u=`visible`,selectionMode:d=`single`,firstDayOfWeek:f,weeksInMonth:p}=e,m=(0,z.useMemo)(()=>i(n.calendar),[i,n.calendar]),[h,g]=I(e.value,e.defaultValue??null,e.onChange),_=(0,z.useMemo)(()=>Array.isArray(h)?h.map(e=>W(H(e),m)):h?W(H(h),m):null,[h,m]),v=(0,z.useMemo)(()=>{let e=Array.isArray(h)?h[0]:h;return e&&`timeZone`in e?e.timeZone:n.timeZone},[h,n.timeZone]),y=(0,z.useMemo)(()=>e.focusedValue?Es(W(H(e.focusedValue),m),o,s):void 0,[e.focusedValue,m,o,s]),b=(0,z.useMemo)(()=>e.defaultFocusedValue?Es(W(H(e.defaultFocusedValue),m),o,s):Es(_?Array.isArray(_)?_[0]:_:W(vt(v),m),o,s),[e.defaultFocusedValue,_,v,m,o,s]),[x,S]=I(y,b,e.onFocusChange),C=()=>{switch(c){case`start`:return Cs(x,a,r,o,s);case`end`:return ws(x,a,r,o,s);default:return Ss(x,a,r,o,s)}},[w,T]=(0,z.useState)(C),[E,D]=(0,z.useState)(e.autoFocus||!1),[O,k]=(0,z.useState)(a);Os(a,O)||(k(a),T(C()));let A=(0,z.useMemo)(()=>{let e={...a};return e.days?e.days--:e.days=-1,w.add(e)},[w,a]),[ee,te]=(0,z.useState)(m);if(!pt(m,ee)){let e=W(x,m);T(Ss(e,a,r,o,s)),S(e),te(m)}xs(x,o,s)?S(Es(x,o,s)):x.compare(w)<0?T(ws(x,a,r,o,s)):x.compare(A)>0&&T(Cs(x,a,r,o,s));function j(e){e=Es(e,o,s),S(e)}function ne(e){let t=Ds(Es(e,o,s),w,l);if(!t)return null;let n=Array.isArray(h)?h[0]:h,r=W(t,n?.calendar||new B);return n&&`hour`in n?n.set(r):r}function M(t){if(!e.isDisabled&&!e.isReadOnly){if(t===null){g(d===`multiple`?[]:null);return}if(Array.isArray(t))g(t.map(ne).filter(Boolean));else{let e=ne(t);e&&g(e)}}}let re=(0,z.useMemo)(()=>_?Array.isArray(_)?_.some(e=>l?.(e)||xs(e,o,s)):l?.(_)||xs(_,o,s):!1,[_,l,o,s]),N=e.isInvalid||e.validationState===`invalid`||re,ie=N?`invalid`:null,P=(0,z.useMemo)(()=>u===`visible`?a:As(a),[u,a]);return{isDisabled:e.isDisabled??!1,isReadOnly:e.isReadOnly??!1,value:_,setValue:M,selectionMode:d,visibleDuration:a,visibleRange:{start:w,end:A},minValue:o,maxValue:s,focusedDate:x,timeZone:v,validationState:ie,isValueInvalid:N,setFocusedDate(e){j(e)},focusNextDay(){j(x.add({days:1}))},focusPreviousDay(){j(x.subtract({days:1}))},focusNextRow(){a.days?this.focusNextPage():(a.weeks||a.months||a.years)&&j(x.add({weeks:1}))},focusPreviousRow(){a.days?this.focusPreviousPage():(a.weeks||a.months||a.years)&&j(x.subtract({weeks:1}))},focusNextPage(){let e=w.add(P);S(Es(x.add(P),o,s)),T(Cs(Ts(x,e,P,r,o,s),P,r))},focusPreviousPage(){let e=w.subtract(P);S(Es(x.subtract(P),o,s)),T(Cs(Ts(x,e,P,r,o,s),P,r))},focusSectionStart(){a.days?j(w):a.weeks?j(kt(x,r)):(a.months||a.years)&&j(Et(x))},focusSectionEnd(){a.days?j(A):a.weeks?j(At(x,r)):(a.months||a.years)&&j(Dt(x))},focusNextSection(e){if(!e&&!a.days){j(x.add(As(a)));return}a.days?this.focusNextPage():a.weeks?j(x.add({months:1})):(a.months||a.years)&&j(x.add({years:1}))},focusPreviousSection(e){if(!e&&!a.days){j(x.subtract(As(a)));return}a.days?this.focusPreviousPage():a.weeks?j(x.subtract({months:1})):(a.months||a.years)&&j(x.subtract({years:1}))},selectFocusedDate(){l&&l(x)||this.selectDate(x)},selectDate(t){if(!(e.isDisabled||e.isReadOnly)){if(d===`multiple`&&t!=null){let e=ne(t);if(!e)return;let n=[];Array.isArray(h)?n=h:h!=null&&(n=[h]);let r=n.findIndex(t=>V(t,e)),i=r>=0?n.slice(0,r).concat(n.slice(r+1)):[...n,e];g(i)}else M(t)}},isFocused:E,setFocused:D,isInvalid(e){return xs(e,o,s)},isSelected(e){return!_||this.isCellDisabled(e)||this.isCellUnavailable(e)?!1:Array.isArray(_)?_.some(t=>V(t,e)):V(e,_)},isCellFocused(e){return E&&x&&V(e,x)},isCellDisabled(t){return e.isDisabled||t.compare(w)<0||t.compare(A)>0||this.isInvalid(t)},isCellUnavailable(t){return e.isDateUnavailable?e.isDateUnavailable(t):!1},isPreviousVisibleRangeInvalid(){let e=w.subtract({days:1});return V(e,w)||this.isInvalid(e)},isNextVisibleRangeInvalid(){let e=A.add({days:1});return V(e,A)||this.isInvalid(e)},getDatesInWeek(e,t=w){let n=t.add({weeks:e}),i=[],o=a.days&&a.days<7?a.days:7;if(o===7){n=kt(n,r,f);let e=gt(n,r,f);for(let t=0;t0&&(m=`start`)}let h=(0,z.useMemo)(()=>{let t=e.isDateUnavailable;if(t)return e=>t(e,f)},[e.isDateUnavailable,f]),g=(0,z.useCallback)(t=>t&&h&&!e.allowsNonContiguousRanges?{start:Ps(t,h,o,-1),end:Ps(t,h,o,1)}:null,[h,o,e.allowsNonContiguousRanges]),_=(0,z.useMemo)(()=>g(f),[g,f]),v=(0,z.useMemo)(()=>Lt(s,_?.start),[s,_]),y=(0,z.useMemo)(()=>It(c,_?.end),[c,_]),b=ks({...l,value:u&&u.start,createCalendar:i,locale:a,visibleDuration:o,minValue:v,maxValue:y,selectionAlignment:e.selectionAlignment||m,isDateUnavailable:h}),x=f?Ms(f,b.focusedDate):u&&Ms(u.start,u.end),S=t=>{if(e.isReadOnly)return;let n=Ds(Es(t,v,y),b.visibleRange.start,h);if(n){if(!f)p(n);else{let e=Ms(f,n);e&&d({start:Ns(e.start,u?.start),end:Ns(e.end,u?.end)}),p(null)}}},[C,w]=(0,z.useState)(!1),T=(0,z.useMemo)(()=>!u||f?!1:h&&(h(u.start)||h(u.end))?!0:xs(u.start,s,c)||xs(u.end,s,c),[h,u,f,s,c]),E=e.isInvalid||e.validationState===`invalid`||T,D=E?`invalid`:null;return{...b,value:u,setValue:d,anchorDate:f,setAnchorDate:p,highlightedRange:x,validationState:D,isValueInvalid:E,selectFocusedDate(){b.isCellUnavailable(b.focusedDate)||S(b.focusedDate)},commitSelection(){S(b.focusedDate)},selectDate:S,highlightDate(e){f&&b.setFocusedDate(e)},isSelected(e){return!!(x&&e.compare(x.start)>=0&&e.compare(x.end)<=0&&!b.isCellDisabled(e)&&!b.isCellUnavailable(e))},isInvalid(e){return b.isInvalid(e)||xs(e,_?.start,_?.end)},isDragging:C,setDragging:w,clearSelection(){p(null),d(null)},focusNearestAvailableDate(e){let t=g(e),n=e=>this.isInvalid(e)||xs(e,t?.start,t?.end),r=e.add({days:1});n(r)&&(r=e.subtract({days:1})),n(r)||(this.setFocusedDate(r),this.setFocused(!0))}}}function Ms(e,t){return!e||!t?null:(t.compare(e)<0&&([e,t]=[t,e]),{start:H(e),end:H(t)})}function Ns(e,t){return e=W(e,t?.calendar||new B),t&&`hour`in t?t.set(e):e}function Ps(e,t,n,r){let i=e.add({days:r}),a=e.subtract(n),o=e.add(n);for(;(r<0?i.compare(a)>=0:i.compare(o)<=0)&&!t(i);)i=i.add({days:r});if(t(i))return i.add({days:-r})}var Fs=(0,z.createContext)(null),Is=(0,z.createContext)(null),Ls=(0,z.createContext)(null),Rs=(0,z.createContext)(null),zs=(0,z.forwardRef)(function(e,t){[e,t]=ae(e,t,Is);let{locale:n}=F(),r=js({...e,locale:n,createCalendar:e.createCalendar||Kr}),{calendarProps:i,prevButtonProps:a,nextButtonProps:s,errorMessageProps:c,title:l}=bs(e,r,t),u=D({...e,values:{state:r,isDisabled:e.isDisabled||!1,isInvalid:r.isValueInvalid},defaultClassName:`react-aria-RangeCalendar`}),d=L(e,{global:!0});return z.createElement(S.div,{...T(u,d,i),ref:t,slot:e.slot||void 0,"data-disabled":e.isDisabled||void 0,"data-invalid":r.isValueInvalid||void 0},z.createElement(y,{values:[[o,{slots:{previous:a,next:s}}],[Ge,{"aria-hidden":!0,level:2,children:l}],[Rs,r],[Is,e],[f,{slots:{errorMessage:c}}]]},z.createElement(Ke,null,z.createElement(`h2`,null,i[`aria-label`])),u.children,z.createElement(Ke,null,z.createElement(`button`,{"aria-label":s[`aria-label`],disabled:s.isDisabled,onClick:()=>r.focusNextPage(),tabIndex:-1}))))}),Bs=(0,z.createContext)(null),Vs=(0,z.forwardRef)(function(e,t){let n=(0,z.useContext)(Ls),r=(0,z.useContext)(Rs),i=E(Fs),a=E(Is),o=n??r,s=o.visibleRange.start;e.offset&&(s=s.add(e.offset));let c=i?.firstDayOfWeek??a?.firstDayOfWeek,{gridProps:l,headerProps:u,weekDays:d,weeksInMonth:f}=hs({startDate:s,endDate:Dt(s),weekdayStyle:e.weekdayStyle,firstDayOfWeek:c},o),p=L(e,{global:!0});return z.createElement(Bs.Provider,{value:{headerProps:u,weekDays:d,startDate:s,weeksInMonth:f}},z.createElement(S.table,{render:e.render,...T(p,l),ref:t,style:e.style,cellPadding:0,className:e.className??`react-aria-CalendarGrid`},typeof e.children==`function`?z.createElement(z.Fragment,null,z.createElement(Us,null,e=>z.createElement(Gs,null,e)),z.createElement(qs,null,e.children)):e.children))});function Hs(e,t){let{children:n,style:r,className:i}=e,{headerProps:a,weekDays:o}=(0,z.useContext)(Bs),s=L(e,{global:!0});return z.createElement(S.thead,{render:e.render,...T(s,a),ref:t,style:r,className:i??`react-aria-CalendarGridHeader`},z.createElement(`tr`,null,o.map((e,t)=>z.cloneElement(n(e),{key:t}))))}var Us=(0,z.forwardRef)(Hs);function Ws(e,t){let{children:n,style:r,className:i}=e,a=L(e,{global:!0});return z.createElement(S.th,{render:e.render,...a,ref:t,style:r,className:i||`react-aria-CalendarHeaderCell`},n)}var Gs=(0,z.forwardRef)(Ws);function Ks(e,t){let{children:n,style:r,className:i}=e,a=(0,z.useContext)(Ls),o=(0,z.useContext)(Rs),s=a??o,{startDate:c,weeksInMonth:l}=(0,z.useContext)(Bs),u=L(e,{global:!0});return z.createElement(S.tbody,{render:e.render,...u,ref:t,style:r,className:i??`react-aria-CalendarGridBody`},[...Array(l).keys()].map(e=>z.createElement(`tr`,{key:e},s.getDatesInWeek(e,c).map((e,t)=>e?z.cloneElement(n(e),{key:t}):z.createElement(`td`,{key:t})))))}var qs=(0,z.forwardRef)(Ks),Js=(0,z.forwardRef)(function({date:e,...t},n){let r=(0,z.useContext)(Ls),i=(0,z.useContext)(Rs),a=r??i,{startDate:o}=(0,z.useContext)(Bs)??{startDate:a.visibleRange.start},s=a.visibleDuration.days||a.visibleDuration.weeks?!1:!ut(o,e),c=mt(e,a.timeZone),l=(0,z.useRef)(null),{cellProps:u,buttonProps:d,...f}=_s({date:e,isOutsideMonth:s},a,l),{hoverProps:p,isHovered:m}=ue({...t,isDisabled:f.isDisabled||f.isUnavailable}),{focusProps:h,isFocusVisible:g}=N();g&&=f.isFocused;let _=!1,v=!1;`highlightedRange`in a&&a.highlightedRange&&(_=V(e,a.highlightedRange.start),v=V(e,a.highlightedRange.end));let y=D({...t,defaultChildren:f.formattedDate,defaultClassName:`react-aria-CalendarCell`,values:{date:e,isHovered:m,isOutsideMonth:s,isFocusVisible:g,isSelectionStart:_,isSelectionEnd:v,isToday:c,...f}}),b={"data-focused":f.isFocused||void 0,"data-hovered":m||void 0,"data-pressed":f.isPressed||void 0,"data-unavailable":f.isUnavailable||void 0,"data-disabled":f.isDisabled||void 0,"data-focus-visible":g||void 0,"data-outside-visible-range":f.isOutsideVisibleRange||void 0,"data-outside-month":s||void 0,"data-selected":f.isSelected||void 0,"data-selection-start":_||void 0,"data-selection-end":v||void 0,"data-invalid":f.isInvalid||void 0,"data-today":c||void 0},x=L(t,{global:!0});return z.createElement(`td`,{...u,ref:n},z.createElement(S.div,{...T(x,d,h,p,b,y),ref:l}))}),Ys=(0,z.forwardRef)(function(e,t){let{offset:n,format:r,className:i=`react-aria-CalendarHeading`,...a}=e,o=z.useContext(Ls),s=z.useContext(Rs),c=ys({offset:n,format:r},o||s);return z.createElement(Ie,{...a,className:i,ref:t},c)});function Xs(e){return e&&e.__esModule?e.default:e}function Zs(e,t,n){let r=i(Xs(zi),`@react-aria/datepicker`),{isInvalid:a,validationErrors:o,validationDetails:s}=t.displayValidation,{labelProps:c,fieldProps:l,descriptionProps:u,errorMessageProps:d}=ge({...e,labelElementType:`span`,isInvalid:a,errorMessage:e.errorMessage||o}),f=l[`aria-labelledby`]||l.id,{locale:p}=F(),m=t.formatValue(p,{month:`long`}),h=m?r.format(`selectedRangeDescription`,{startDate:m.start,endDate:m.end}):``,g=Re(h),_={"aria-label":r.format(`startDate`),"aria-labelledby":f},v={"aria-label":r.format(`endDate`),"aria-labelledby":f},y=oe(),b=oe(),x=Bi(t,n),S=[g[`aria-describedby`],l[`aria-describedby`]].filter(Boolean).join(` `)||void 0,C=(0,z.useMemo)(()=>ce(n,{accept:e=>e.id!==y}),[n,y]),w={[Gi]:C,[Wi]:`presentation`,"aria-describedby":S,placeholderValue:e.placeholderValue,hideTimeZone:e.hideTimeZone,hourCycle:e.hourCycle,granularity:e.granularity,shouldForceLeadingZeros:e.shouldForceLeadingZeros,isDisabled:e.isDisabled,isReadOnly:e.isReadOnly,isRequired:e.isRequired,validationBehavior:e.validationBehavior},E=L(e),D=(0,z.useRef)(!1),{focusWithinProps:O}=P({...e,isDisabled:t.isOpen,onBlurWithin:t=>{let n=document.getElementById(b);te(n,t.relatedTarget)||(D.current=!1,e.onBlur?.(t),e.onFocusChange?.(!1))},onFocusWithin:t=>{D.current||(D.current=!0,e.onFocus?.(t),e.onFocusChange?.(!0))}}),k=(0,z.useRef)(ve),A=(0,z.useRef)(ve);return{groupProps:T(E,x,l,g,O,{role:`group`,"aria-disabled":e.isDisabled||null,"aria-describedby":S,onKeyDown(n){t.isOpen||e.onKeyDown&&e.onKeyDown(n)},onKeyUp(n){t.isOpen||e.onKeyUp&&e.onKeyUp(n)}}),labelProps:{...c,onClick:()=>{C.focusFirst()}},buttonProps:{...g,id:y,"aria-haspopup":`dialog`,"aria-label":r.format(`calendar`),"aria-labelledby":`${y} ${f}`,"aria-describedby":S,"aria-expanded":t.isOpen,isDisabled:e.isDisabled||e.isReadOnly,onPress:()=>t.setOpen(!0)},dialogProps:{id:b,"aria-labelledby":`${y} ${f}`},startFieldProps:{..._,...w,value:t.value?.start??null,defaultValue:t.defaultValue?.start,onChange:e=>t.setDateTime(`start`,e),autoFocus:e.autoFocus,name:e.startName,form:e.form,[Se]:{realtimeValidation:t.realtimeValidation,displayValidation:t.displayValidation,updateValidation(e){k.current=e,t.updateValidation(_e(e,A.current))},resetValidation:t.resetValidation,commitValidation:t.commitValidation}},endFieldProps:{...v,...w,value:t.value?.end??null,defaultValue:t.defaultValue?.end,onChange:e=>t.setDateTime(`end`,e),name:e.endName,form:e.form,[Se]:{realtimeValidation:t.realtimeValidation,displayValidation:t.displayValidation,updateValidation(e){A.current=e,t.updateValidation(_e(k.current,e))},resetValidation:t.resetValidation,commitValidation:t.commitValidation}},descriptionProps:u,errorMessageProps:d,calendarProps:{autoFocus:!0,value:t.dateRange?.start&&t.dateRange.end?t.dateRange:null,onChange:t.setDateRange,minValue:e.minValue,maxValue:e.maxValue,isDisabled:e.isDisabled,isReadOnly:e.isReadOnly,isDateUnavailable:e.isDateUnavailable,allowsNonContiguousRanges:e.allowsNonContiguousRanges,defaultFocusedValue:t.dateRange?void 0:e.placeholderValue,isInvalid:t.isInvalid,errorMessage:typeof e.errorMessage==`function`?e.errorMessage(t.displayValidation):e.errorMessage||t.displayValidation.validationErrors.join(` `),firstDayOfWeek:e.firstDayOfWeek,pageBehavior:e.pageBehavior},isInvalid:a,validationErrors:o,validationDetails:s}}function Qs(e){let t=g(e),[n,r]=I(e.value,e.defaultValue||null,e.onChange),[i]=(0,z.useState)(n),[a,o]=(0,z.useState)(()=>n||{start:null,end:null});n==null&&a.start&&a.end&&(a={start:null,end:null},o(a));let s=n||a,c=e=>{s=e||{start:null,end:null},o(s),$s(s)?r(s):r(null)},[l,u]=Ka(s?.start||s?.end||e.placeholderValue||null,e.granularity),d=l===`hour`||l===`minute`||l===`second`,f=e.shouldCloseOnSelect??!0,[p,m]=(0,z.useState)(null),[h,_]=(0,z.useState)(null);s&&$s(s)&&(p=s,`hour`in s.start&&(h=s));let v=(e,t)=>{c({start:`timeZone`in t.start?t.start.set(H(e.start)):U(e.start,t.start),end:`timeZone`in t.end?t.end.set(H(e.end)):U(e.end,t.end)}),m(null),_(null),D.commitValidation()},y=n=>{let r=typeof f==`function`?f():f;d?$s(n)&&(r||h?.start&&h?.end)?v(n,{start:h?.start||Ua(e.placeholderValue),end:h?.end||Ua(e.placeholderValue)}):m(n):$s(n)?(c(n),D.commitValidation()):m(n),r&&t.setOpen(!1)},b=e=>{$s(p)&&$s(e)?v(p,e):_(e)},x=s?.start?.calendar.identifier===`gregory`&&s.start.era===`BC`||s?.end?.calendar.identifier===`gregory`&&s.end.era===`BC`,S=(0,z.useMemo)(()=>({granularity:l,timeZone:u,hideTimeZone:e.hideTimeZone,hourCycle:e.hourCycle,shouldForceLeadingZeros:e.shouldForceLeadingZeros,showEra:x}),[l,e.hourCycle,e.shouldForceLeadingZeros,u,e.hideTimeZone,x]),{minValue:C,maxValue:w,isDateUnavailable:T}=e,E=(0,z.useMemo)(()=>za(s,C,w,T?e=>T(e,null):void 0,S),[s,C,w,T,S]),D=ye({...e,value:n,name:(0,z.useMemo)(()=>[e.startName,e.endName].filter(e=>e!=null),[e.startName,e.endName]),builtinValidation:E}),O=D.displayValidation.isInvalid,k=e.validationState||(O?`invalid`:null);return{...D,value:s,defaultValue:e.defaultValue??i,setValue:c,dateRange:p,timeRange:h,granularity:l,hasTime:d,setDate(e,t){y(e===`start`?{start:t,end:p?.end??null}:{start:p?.start??null,end:t})},setTime(e,t){b(e===`start`?{start:t,end:h?.end??null}:{start:h?.start??null,end:t})},setDateTime(e,t){c(e===`start`?{start:t,end:s?.end??null}:{start:s?.start??null,end:t})},setDateRange:y,setTimeRange:b,...t,setOpen(n){!n&&!(s?.start&&s?.end)&&$s(p)&&d&&v(p,{start:h?.start||Ua(e.placeholderValue),end:h?.end||Ua(e.placeholderValue)}),t.setOpen(n)},validationState:k,isInvalid:O,formatValue(t,n){if(!s||!s.start||!s.end)return null;let r=`timeZone`in s.start?s.start.timeZone:void 0,i=e.granularity||(s.start&&`minute`in s.start?`minute`:`day`),a=`timeZone`in s.end?s.end.timeZone:void 0,o=e.granularity||(s.end&&`minute`in s.end?`minute`:`day`),c=Ha(n,{granularity:i,timeZone:r,hideTimeZone:e.hideTimeZone,hourCycle:e.hourCycle,showEra:s.start.calendar.identifier===`gregory`&&s.start.era===`BC`||s.end.calendar.identifier===`gregory`&&s.end.era===`BC`}),l=s.start.toDate(r||`UTC`),u=s.end.toDate(a||`UTC`),d=new Y(t,c),f;if(r===a&&i===o&&s.start.compare(s.end)!==0){try{let e=d.formatRangeToParts(l,u),t=-1;for(let n=0;nt&&(r+=e[i].value);return{start:n,end:r}}catch{}f=d}else f=new Y(t,Ha(n,{granularity:o,timeZone:a,hideTimeZone:e.hideTimeZone,hourCycle:e.hourCycle}));return{start:d.format(l),end:f.format(u)}},getDateFormatter(e,t){return new Y(e,Ha({},{...S,...t}))}}}function $s(e){return e?.start!=null&&e.end!=null}var ec=(0,z.createContext)(null),tc=(0,z.createContext)(null),nc=[be,o,he,f],rc=(0,z.forwardRef)(function(e,t){[e,t]=ae(e,t,ec);let{validationBehavior:n}=E(De)||{},r=e.validationBehavior??n??`native`,i=Qs({...e,validationBehavior:r}),a=(0,z.useRef)(null),[s,c]=O(!e[`aria-label`]&&!e[`aria-labelledby`]),{groupProps:l,labelProps:u,startFieldProps:d,endFieldProps:p,buttonProps:m,dialogProps:h,calendarProps:g,descriptionProps:_,errorMessageProps:v,...b}=Zs({...w(e),label:c,validationBehavior:r},i,a),{focusProps:x,isFocused:C,isFocusVisible:k}=N({within:!0}),A=D({...e,values:{state:i,isFocusWithin:C,isFocusVisible:k,isDisabled:e.isDisabled||!1,isInvalid:i.isInvalid,isOpen:i.isOpen,isReadOnly:e.isReadOnly||!1,isRequired:e.isRequired||!1},defaultClassName:`react-aria-DateRangePicker`}),ee=L(e,{global:!0});return delete ee.id,z.createElement(y,{values:[[tc,i],[be,{...l,ref:a,isInvalid:i.isInvalid}],[o,{...m,isPressed:i.isOpen}],[he,{...u,ref:s,elementType:`span`}],[Is,g],[He,i],[Ue,{trigger:`DateRangePicker`,triggerRef:a,placement:`bottom start`,clearContexts:nc}],[Ve,h],[oo,{slots:{start:d,end:p}}],[f,{slots:{description:_,errorMessage:v}}],[Te,b]]},z.createElement(S.div,{...T(ee,A,x),ref:t,slot:e.slot||void 0,"data-focus-within":C||void 0,"data-invalid":i.isInvalid||void 0,"data-focus-visible":k||void 0,"data-disabled":e.isDisabled||void 0,"data-readonly":e.isReadOnly||void 0,"data-required":e.isRequired||void 0,"data-open":i.isOpen||void 0}))}),ic=(0,z.createContext)({triggerRef:{current:null}}),ac=({children:e,className:t,onOpenChange:n,...r})=>{let i=z.useMemo(()=>Qe(),[]),a=(0,z.useRef)(null),[o,s]=z.useState(!1),c=(0,z.useRef)(!1);(0,z.useEffect)(()=>{if(!o)return;let e=e=>{!e.metaKey&&!e.ctrlKey&&!e.altKey&&(c.current=!0)};return window.addEventListener(`keydown`,e,!0),()=>{window.removeEventListener(`keydown`,e,!0)}},[o]);let l=e=>{s(e),!e&&c.current&&window.requestAnimationFrame(()=>{a.current?.focus()}),c.current=!1,n?.(e)};return(0,X.jsx)(ic,{value:{slots:i,triggerRef:a},children:(0,X.jsx)(rc,{"data-required":Pe(r.isRequired),"data-slot":`date-range-picker`,...r,className:M(t,i?.base()),onOpenChange:l,children:t=>(0,X.jsx)(X.Fragment,{children:typeof e==`function`?e(t):e})})})};ac.displayName=`HeroUI.DateRangePicker`;var oc=({children:e,className:t,ref:n,...r})=>{let{slots:i,triggerRef:a}=(0,z.use)(ic),o=z.useCallback(e=>{a.current=e},[a]),s=ee(o,n);return(0,X.jsx)(d,{ref:s,className:M(t,i?.trigger()),"data-slot":`date-range-picker-trigger`,...r,children:t=>(0,X.jsx)(X.Fragment,{children:typeof e==`function`?e(t):e})})};oc.displayName=`HeroUI.DateRangePicker.Trigger`;var sc=({children:e,className:t,...n})=>{let{slots:r}=(0,z.use)(ic);return(0,X.jsx)(b.span,{"aria-hidden":`true`,className:R(r?.triggerIndicator,t),"data-slot":`date-range-picker-trigger-indicator`,...n,children:e||(0,X.jsx)(s,{})})};sc.displayName=`HeroUI.DateRangePicker.TriggerIndicator`;var cc=({children:e=` - `,className:t,...n})=>{let{slots:r}=(0,z.use)(ic);return(0,X.jsx)(b.span,{"aria-hidden":`true`,className:R(r?.rangeSeparator,t),"data-slot":`date-range-picker-range-separator`,...n,children:e})};cc.displayName=`HeroUI.DateRangePicker.RangeSeparator`;var lc=({children:e,className:t,placement:n=`bottom`,...r})=>{let{slots:i}=(0,z.use)(ic);return(0,X.jsx)(l,{value:{variant:`default`},children:(0,X.jsx)(qe,{...r,className:M(t,i?.popover()),"data-slot":`date-range-picker-popover`,placement:n,children:e})})};lc.displayName=`HeroUI.DateRangePicker.Popover`;var uc=Object.assign(ac,{Root:ac,Trigger:oc,TriggerIndicator:sc,RangeSeparator:cc,Popover:lc});function dc({children:e,className:t,fullWidth:n,...r}){let i=z.useMemo(()=>et({fullWidth:n}),[n]);return(0,X.jsx)(fo,{"data-required":Pe(r.isRequired),"data-slot":`time-field`,...r,className:M(t,i),children:t=>(0,X.jsx)(X.Fragment,{children:typeof e==`function`?e(t):e})})}var fc=Object.assign(dc,{Root:dc,Group:vo,Input:bo,InputContainer:So,Segment:xo,Prefix:yo,Suffix:Co}),pc=(0,z.createContext)(null);function mc(){let e=(0,z.use)(pc);if(!e)throw Error(`useYearPicker must be used within a or component.`);return e}function hc(){let e=(0,z.use)(Ls),t=(0,z.use)(Rs),n=e??t;if(!n)throw Error(`useCalendarOrRangeState must be used within a or component.`);return n}function gc(e){switch(e){case`buddhist`:return 543;case`ethiopic`:case`ethioaa`:return-8;case`coptic`:return-284;case`hebrew`:return 3760;case`indian`:return-78;case`islamic-civil`:case`islamic-tbla`:case`islamic-umalqura`:return-579;case`persian`:return-600;default:return 0}}function _c(e,t){let n=[];if(!e||!t)return n;let r=Ot(e);for(;r.compare(t)<=0;)n.push(r),r=Ot(r.add({years:1}));return n}function vc(e,t,n,r=`short`,i=`UTC`){let a=new Intl.DateTimeFormat(t,{weekday:r,timeZone:i}),o=kt(e,t,n),s=[],c=o;for(let e=0;e<7;e++){s.push(a.format(c.toDate(i)));let e=c.add({days:1});if(V(c,e))break;c=e}for(;s.length<7;)s.push(``);return s}function yc(e,t){let n=[],r=e;for(let e=0;e<7;e++){n.push(r.compare(t)>0?null:r);let e=r.add({days:1});if(V(r,e)){for(;n.length<7;)n.push(null);return n}r=e}return n}function bc(e,t,n,r){let i=[],a=kt(e,n,r);for(i.push(yc(a,t)),a=a.add({weeks:1});a.compare(t)<=0;){i.push(yc(a,t));let e=a.add({weeks:1});if(V(a,e))break;a=e}return i}var xc=z.createContext(null);function Sc(){let e=z.use(xc);if(!e)throw Error(`CalendarYearPicker trigger components must be used within .`);return e}var Cc=({children:e,className:t,onKeyDown:n,onPress:r,...i})=>{let{isYearPickerOpen:a,setIsYearPickerOpen:o}=mc(),s=ys({},hc()),c=z.useMemo(()=>Ye(),[]),l=z.useCallback(()=>{o(!a)},[a,o]),u=e=>{n?.(e),!e.defaultPrevented&&e.key===`Escape`&&a&&(e.preventDefault(),o(!1))},f=z.useMemo(()=>({isOpen:a,monthYear:s,toggle:l}),[l,a,s]),p=z.useMemo(()=>({...f,slots:c}),[c,f]);return(0,X.jsx)(xc,{value:p,children:(0,X.jsx)(d,{"aria-expanded":a,"aria-label":`${s}, year selector`,className:M(t,c.trigger()),"data-open":a||void 0,"data-slot":`calendar-year-picker-trigger`,slot:null,onKeyDown:u,onPress:e=>{r?.(e),l()},...i,children:typeof e==`function`?e(f):e})})};Cc.displayName=`HeroUI.CalendarYearPicker.Trigger`;var wc=({children:e,className:t,format:n,offset:r,...i})=>{let{monthYear:a,slots:o,...s}=Sc(),c=hc(),l=ys({format:n,offset:r},c);return(0,X.jsx)(b.span,{className:R(o.triggerHeading,t),"data-slot":`calendar-year-picker-trigger-heading`,...i,children:typeof e==`function`?e({monthYear:a,...s}):e||l})};wc.displayName=`HeroUI.CalendarYearPicker.TriggerHeading`;var Tc=({children:e,className:t,...n})=>{let{monthYear:i,slots:a,...o}=Sc();return(0,X.jsx)(b.span,{"aria-hidden":`true`,className:R(a.triggerIndicator,t),"data-slot":`calendar-year-picker-trigger-indicator`,...n,children:typeof e==`function`?e({monthYear:i,...o}):e||(0,X.jsx)(r,{height:`1em`,width:`1em`})})};Tc.displayName=`HeroUI.CalendarYearPicker.TriggerIndicator`;var Ec=z.createContext(null);function Dc(){let e=z.use(Ec);if(!e)throw Error(`CalendarYearPicker components must be used within .`);return e}var Oc=({children:e,className:t,format:n,onKeyDown:r,visibleYears:i,...a})=>{let{calendarGridSlot:o,calendarRef:s,isYearPickerOpen:c,setIsYearPickerOpen:l}=mc(),u=hc(),d=z.useRef(null),f=z.useMemo(()=>Ye(),[]),{"aria-label":p,items:m,onChange:h,value:g}=vs({format:n,visibleYears:z.useMemo(()=>i??(!u.minValue||!u.maxValue?20:_c(u.minValue,u.maxValue).length),[u.maxValue,u.minValue,i])},u),_=m.map(e=>`${e.id}:${e.date.year}`).join(`|`),v=m.map(e=>e.date.year),y=new Map(m.map(e=>[e.date.year,e])),x=m[g]?.date.year??u.focusedDate.year,S=z.useCallback(e=>y.get(e)?.formatted??String(e),[y]),[C,w]=z.useState(x),T=z.useRef(!1);z.useEffect(()=>{let e=d.current;if(!e)return;let t=s.current?.querySelector(`[data-slot='${o}']`);t&&(e.style.top=`${t.offsetTop}px`,e.style.height=`${t.offsetHeight}px`)},[o,s,u.focusedDate]);let E=z.useCallback(e=>{let t=d.current;if(!t)return;let n=t.querySelector(`[data-year='${e}']`);n&&n.focus()},[]);z.useEffect(()=>{let e=c&&!T.current;if(T.current=c,!e||v.length===0)return;let[t]=v;if(t==null)return;let n=v.includes(x)?x:t;w(n);let r=requestAnimationFrame(()=>{E(n)});return()=>{cancelAnimationFrame(r)}},[E,x,c,_,v.length]),z.useEffect(()=>{if(!c||v.length===0)return;let[e]=v;e!=null&&(v.includes(C)||w(e))},[C,c,_,v]);let D=z.useCallback(e=>{let t=y.get(e);t!=null&&(l(!1),h(t.id))},[y,h,l]),O=e=>{if(r?.(e),e.defaultPrevented)return;if(e.key===`Escape`&&c){e.preventDefault(),l(!1);return}if(!c||v.length===0)return;let t=v.indexOf(C);if(t===-1)return;let n=t;switch(e.key){case`ArrowRight`:n=Math.min(t+1,v.length-1);break;case`ArrowLeft`:n=Math.max(t-1,0);break;case`ArrowDown`:n=Math.min(t+3,v.length-1);break;case`ArrowUp`:n=Math.max(t-3,0);break;case`Home`:n=0;break;case`End`:n=v.length-1;break;default:return}if(n!==t){let t=v[n];if(t==null)return;e.preventDefault(),w(t),E(t)}},k=z.useMemo(()=>({activeYear:C,focusedYear:x,getFormattedYear:S,isYearPickerOpen:c,selectYear:D,setActiveYear:w,slots:f,years:v}),[C,x,S,D,c,f,v]);return(0,X.jsx)(Ec,{value:k,children:(0,X.jsx)(b.div,{ref:d,"aria-hidden":!c,"aria-label":p,className:R(f.yearGrid,t),"data-open":c||void 0,"data-slot":`calendar-year-picker-grid`,role:`listbox`,tabIndex:-1,onKeyDown:O,...a,children:e})})};Oc.displayName=`HeroUI.CalendarYearPicker.Grid`;var kc=({children:e})=>{let{focusedYear:t,getFormattedYear:n,isYearPickerOpen:r,selectYear:i,years:a}=Dc(),o=new Date().getFullYear();return(0,X.jsx)(X.Fragment,{children:a.map(a=>{let s=a===t,c={formattedYear:n(a),isCurrentYear:a===o,isOpen:r,isSelected:s,selectYear:()=>i(a),year:a};return(0,X.jsx)(z.Fragment,{children:typeof e==`function`?e(c):(0,X.jsx)(Ac,{year:a})},a)})})};kc.displayName=`HeroUI.CalendarYearPicker.GridBody`;var Ac=({children:e,className:t,excludeFromTabOrder:n,onFocus:r,onPress:i,year:a,...o})=>{let{activeYear:s,focusedYear:c,getFormattedYear:l,isYearPickerOpen:u,selectYear:f,setActiveYear:p,slots:m}=Dc(),h=a===c,g=a===s,_=l(a),v={formattedYear:_,isCurrentYear:a===new Date().getFullYear(),isOpen:u,isSelected:h,selectYear:()=>f(a),year:a};return(0,X.jsx)(d,{"aria-label":_,"aria-selected":h,className:M(t,m.yearCell()),"data-selected":h||void 0,"data-slot":`calendar-year-picker-year-cell`,"data-year":a,excludeFromTabOrder:n??!(u&&g),slot:null,onFocus:e=>{r?.(e),p(a)},onPress:e=>{i?.(e),f(a)},...o,children:typeof e==`function`?e(v):e||_})};Ac.displayName=`HeroUI.CalendarYearPicker.Cell`;function jc({children:e,className:t,"data-slot":n=`calendar-grid-body`,firstDayOfWeek:r,visibleRange:i}){let{locale:a}=F(),o=z.useMemo(()=>bc(i.start,i.end,a,r),[r,a,i.end,i.start]);return(0,X.jsx)(b.tbody,{className:t,"data-slot":n,children:o.map((t,n)=>(0,X.jsx)(`tr`,{children:t.map((t,n)=>t?z.cloneElement(e(t),{key:n}):(0,X.jsx)(`td`,{},n))},n))})}function Mc({children:e,className:t,"data-slot":n=`calendar-grid-header`,firstDayOfWeek:r,timeZone:i=`UTC`,visibleRange:a,weekdayStyle:o=`short`}){let{locale:s}=F(),c=z.useMemo(()=>vc(a.start,s,r,o,i),[r,s,i,a.start,o]);return(0,X.jsx)(b.thead,{"aria-hidden":!0,className:t,"data-slot":n,children:(0,X.jsx)(`tr`,{children:c.map((t,n)=>z.cloneElement(e(t),{key:n}))})})}var Q=(0,z.createContext)({});function Nc({children:e,className:t,defaultYearPickerOpen:n=!1,firstDayOfWeek:r,isYearPickerOpen:i,maxValue:a,minValue:o,onYearPickerOpenChange:s,visibleDuration:c,...l}){let u=c?.weeks!=null,d=c?.days!=null,f=c?.days,{locale:p}=F(),m=z.useMemo(()=>Xe(),[]),h=z.useRef(null),[g,_]=I(i,n,s),v=z.useMemo(()=>{let e=new Y(p).resolvedOptions().calendar;return Kr(e)},[p]),y=z.useMemo(()=>gc(v.identifier),[v.identifier]),b=o??new q(v,1900+y,1,1),x=a??new q(v,2099+y,12,31);return(0,X.jsx)(pc,{value:{calendarGridSlot:`range-calendar-grid`,isYearPickerOpen:g,setIsYearPickerOpen:_,calendarRef:h},children:(0,X.jsx)(zs,{ref:h,"data-slot":`range-calendar`,firstDayOfWeek:r,maxValue:x,minValue:b,visibleDuration:c,...l,className:M(t,A(m.base(),u&&`range-calendar--week-view`,d&&`range-calendar--day-view`)),children:t=>(0,X.jsx)(Q,{value:{dayView:d&&f!=null?{days:f,firstDayOfWeek:r,timeZone:t.state.timeZone,visibleRange:t.state.visibleRange}:void 0,slots:m},children:typeof e==`function`?e(t):e})})})}Nc.displayName=`HeroUI.RangeCalendar`;var Pc=({children:e,className:t,...n})=>{let{slots:r}=(0,z.use)(Q);return(0,X.jsx)(b.header,{className:R(r?.header,t),"data-slot":`range-calendar-header`,...n,children:e})};Pc.displayName=`HeroUI.RangeCalendar.Header`;var Fc=({className:e,...t})=>{let{slots:n}=(0,z.use)(Q);return(0,X.jsx)(Ys,{"data-slot":`range-calendar-heading`,...t,className:R(n?.heading,e)})};Fc.displayName=`HeroUI.RangeCalendar.Heading`;var Ic=({children:e,className:t,slot:n,...i})=>{let{slots:a}=(0,z.use)(Q);return(0,X.jsx)(d,{"data-slot":`range-calendar-nav-button`,slot:n,...i,className:M(t,a?.navButton()),children:e||(n===`previous`?(0,X.jsx)(_,{className:a?.navButtonIcon(),"data-slot":`range-calendar-nav-button-icon`}):(0,X.jsx)(r,{className:a?.navButtonIcon(),"data-slot":`range-calendar-nav-button-icon`}))})};Ic.displayName=`HeroUI.RangeCalendar.NavButton`;var Lc=({children:e,className:t,weekdayStyle:n=`short`,...r})=>{let i=(0,z.use)(Q),{dayView:a,slots:o}=i,s=z.useMemo(()=>({...i,dayView:a?{...a,weekdayStyle:n}:void 0}),[a,i,n]);return(0,X.jsx)(Q,{value:s,children:(0,X.jsx)(Vs,{"data-slot":`range-calendar-grid`,weekdayStyle:n,...r,className:R(o?.grid,t),children:e})})};Lc.displayName=`HeroUI.RangeCalendar.Grid`;var Rc=({children:e,className:t,...n})=>{let{dayView:r,slots:i}=(0,z.use)(Q);return r&&r.days>=7&&typeof e==`function`?(0,X.jsx)(Mc,{className:R(i?.gridHeader,t),"data-slot":`range-calendar-grid-header`,firstDayOfWeek:r.firstDayOfWeek,timeZone:r.timeZone,visibleRange:r.visibleRange,weekdayStyle:r.weekdayStyle,children:e}):(0,X.jsx)(Us,{"data-slot":`range-calendar-grid-header`,...n,className:R(i?.gridHeader,t),children:e})};Rc.displayName=`HeroUI.RangeCalendar.GridHeader`;var zc=({children:e,className:t,...n})=>{let{dayView:r,slots:i}=(0,z.use)(Q);return r&&r.days>=7&&typeof e==`function`?(0,X.jsx)(jc,{className:R(i?.gridBody,t),"data-slot":`range-calendar-grid-body`,firstDayOfWeek:r.firstDayOfWeek,visibleRange:r.visibleRange,children:e}):(0,X.jsx)(qs,{"data-slot":`range-calendar-grid-body`,...n,className:R(i?.gridBody,t),children:e})};zc.displayName=`HeroUI.RangeCalendar.GridBody`;var Bc=({className:e,...t})=>{let{slots:n}=(0,z.use)(Q);return(0,X.jsx)(Gs,{"data-slot":`range-calendar-header-cell`,...t,className:R(n?.headerCell,e)})};Bc.displayName=`HeroUI.RangeCalendar.HeaderCell`;var Vc=({children:e,className:t,...n})=>{let{slots:r}=(0,z.use)(Q);return(0,X.jsx)(Js,{"data-slot":`range-calendar-cell`,...n,className:M(t,r?.cell()),children:t=>{let{formattedDate:n,isDisabled:r,isHovered:i,isPressed:a,isSelectionEnd:o,isSelectionStart:s}=t,c=typeof e==`function`?e(t):e||n;return(0,X.jsx)(`span`,{className:`range-calendar__cell-button`,"data-disabled":Pe(r),"data-hovered":Pe(i),"data-pressed":Pe(a),"data-selected":Pe(s||o),"data-slot":`range-calendar-cell-button`,children:c})}})};Vc.displayName=`HeroUI.RangeCalendar.Cell`;var Hc=({className:e,...t})=>{let{slots:n}=(0,z.use)(Q);return(0,X.jsx)(b.span,{"aria-hidden":`true`,className:R(n?.cellIndicator,e),"data-slot":`range-calendar-cell-indicator`,...t})};Hc.displayName=`HeroUI.RangeCalendar.CellIndicator`;var $=Object.assign(Nc,{Root:Nc,Header:Pc,Heading:Fc,NavButton:Ic,Grid:Lc,GridHeader:Rc,GridBody:zc,HeaderCell:Bc,Cell:Vc,CellIndicator:Hc,YearPickerTrigger:Cc,YearPickerTriggerHeading:wc,YearPickerTriggerIndicator:Tc,YearPickerGrid:Oc,YearPickerGridBody:kc,YearPickerCell:Ac});function Uc(e={}){let t=new URLSearchParams;e.dim?.length&&t.set(`dim`,e.dim.join(`,`)),e.limit!=null&&t.set(`limit`,String(e.limit)),e.hours!=null&&t.set(`hours`,String(e.hours)),e.from&&t.set(`from`,e.from),e.to&&t.set(`to`,e.to),e.api_key&&t.set(`api_key`,e.api_key);let n=t.toString()?`?${t}`:``;return Fe(`/api/logs/stats${n}`)}function Wc(e={}){let t=new URLSearchParams;e.account&&t.set(`account`,e.account),e.api_key&&t.set(`api_key`,e.api_key),e.status&&t.set(`status`,e.status),e.stream!=null&&t.set(`stream`,e.stream?`1`:`0`),e.error_kind&&t.set(`error_kind`,e.error_kind),e.model&&t.set(`model`,e.model),e.provider&&t.set(`provider`,e.provider),e.id&&t.set(`id`,e.id),e.q&&t.set(`q`,e.q),e.from&&t.set(`from`,e.from),e.to&&t.set(`to`,e.to),e.limit!=null&&t.set(`limit`,String(e.limit)),e.offset!=null&&t.set(`offset`,String(e.offset));let n=t.toString()?`?${t}`:``;return Fe(`/api/logs/requests${n}`)}function Gc(e){return Fe(`/api/logs/requests/${encodeURIComponent(e)}`)}function Kc(){return Fe(`/api/logs/requests`,{method:`DELETE`})}function qc(e={}){let t=new URLSearchParams;e.after!=null&&t.set(`after`,String(e.after)),e.limit!=null&&t.set(`limit`,String(e.limit)),e.offset!=null&&t.set(`offset`,String(e.offset)),e.level&&t.set(`level`,e.level),e.q&&t.set(`q`,e.q),e.account&&t.set(`account`,e.account);let n=t.toString()?`?${t}`:``;return Fe(`/api/logs/runtime${n}`)}function Jc(e,t=!1){if(!e)return;let n=e.toDate(wt());if(Number.isFinite(n.getTime()))return t&&n.setSeconds(59,999),n.toISOString()}function Yc(e){if(!e)return null;let t=Date.parse(e);if(!Number.isFinite(t))return null;try{return U(An(new Date(t).toISOString()))}catch{return null}}function Xc({value:e,onChange:t,ariaLabel:n,fromLabel:r,toLabel:i,className:a}){return(0,X.jsx)(uc,{className:a,granularity:`minute`,hourCycle:24,shouldForceLeadingZeros:!0,value:e,onChange:e=>t(e),"aria-label":n,children:({state:e})=>(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(To.Group,{className:`w-full min-w-0`,variant:`secondary`,children:[(0,X.jsx)(To.Input,{className:`min-w-0`,slot:`start`,"aria-label":r,children:e=>(0,X.jsx)(To.Segment,{segment:e})}),(0,X.jsx)(uc.RangeSeparator,{}),(0,X.jsx)(To.Input,{className:`min-w-0`,slot:`end`,"aria-label":i,children:e=>(0,X.jsx)(To.Segment,{segment:e})}),(0,X.jsx)(To.Suffix,{children:(0,X.jsx)(uc.Trigger,{children:(0,X.jsx)(uc.TriggerIndicator,{})})})]}),(0,X.jsxs)(uc.Popover,{className:`flex w-[20.5rem] max-w-[calc(100vw-2rem)] flex-col gap-3 p-3`,children:[(0,X.jsxs)($,{"aria-label":n,children:[(0,X.jsxs)($.Header,{children:[(0,X.jsxs)($.YearPickerTrigger,{children:[(0,X.jsx)($.YearPickerTriggerHeading,{}),(0,X.jsx)($.YearPickerTriggerIndicator,{})]}),(0,X.jsx)($.NavButton,{slot:`previous`}),(0,X.jsx)($.NavButton,{slot:`next`})]}),(0,X.jsxs)($.Grid,{children:[(0,X.jsx)($.GridHeader,{children:e=>(0,X.jsx)($.HeaderCell,{children:e})}),(0,X.jsx)($.GridBody,{children:e=>(0,X.jsx)($.Cell,{date:e})})]}),(0,X.jsx)($.YearPickerGrid,{children:(0,X.jsx)($.YearPickerGridBody,{children:({year:e})=>(0,X.jsx)($.YearPickerCell,{year:e})})})]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,X.jsx)(Oe,{className:`text-xs`,children:r}),(0,X.jsx)(fc,{"aria-label":r,granularity:`minute`,hourCycle:24,value:e.timeRange?.start??null,onChange:t=>e.setTimeRange({start:t,end:e.timeRange?.end}),children:(0,X.jsx)(fc.Group,{className:`w-[7.5rem]`,variant:`secondary`,children:(0,X.jsx)(fc.Input,{children:e=>(0,X.jsx)(fc.Segment,{segment:e})})})})]}),(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,X.jsx)(Oe,{className:`text-xs`,children:i}),(0,X.jsx)(fc,{"aria-label":i,granularity:`minute`,hourCycle:24,value:e.timeRange?.end??null,onChange:t=>e.setTimeRange({start:e.timeRange?.start,end:t}),children:(0,X.jsx)(fc.Group,{className:`w-[7.5rem]`,variant:`secondary`,children:(0,X.jsx)(fc.Input,{children:e=>(0,X.jsx)(fc.Segment,{segment:e})})})})]})]})]})]})})}export{Gc as a,qc as c,Kc as i,Jc as n,Wc as o,Yc as r,Uc as s,Xc as t}; \ No newline at end of file diff --git a/internal/webui/static/assets/TrafficChart-CJw8f4Wi.js b/internal/webui/static/assets/TrafficChart-CJw8f4Wi.js new file mode 100644 index 00000000..cede08a7 --- /dev/null +++ b/internal/webui/static/assets/TrafficChart-CJw8f4Wi.js @@ -0,0 +1 @@ +import{a as e,c as t,n,r}from"./shim-mfK0Rmj6.js";import{i,s as a}from"./format-kRpr2wxA.js";import{r as o}from"./gsap-C3sDxib7.js";import{A as s,An as c,At as l,Bt as u,Ct as d,D as f,E as p,En as m,Et as h,F as g,Ft as _,I as v,Kt as y,Ln as b,M as x,Mt as S,N as C,O as w,P as T,Pt as E,Rn as D,Rt as O,Sn as k,St as A,T as j,Tn as M,U as N,V as P,Wt as F,a as ee,b as I,c as te,it as L,j as ne,jn as re,k as ie,mt as ae,n as oe,nt as R,o as se,ot as ce,pt as le,r as ue,s as de,y as fe,yt as pe,zn as me,zt as z}from"./AreaChart-B0YOdVBx.js";import{n as he,t as ge}from"./CartesianGrid-BJyfpdDb.js";import{t as _e}from"./XAxis-DLQkFqxC.js";import{t as ve}from"./ReferenceArea-CiIBWWEY.js";import{t as ye}from"./FilterToggle-AieL1mQy.js";import{t as be}from"./OverviewPage-BbcGKR4s.js";var B=t(e()),xe=[`animationElapsedTime`,`isAnimating`,`isEntrance`,`visibleLength`,`strokeDasharray`,`connectNulls`];function V(){return V=Object.assign?Object.assign.bind():function(e){for(var t=1;te+t,0);if(!i)return H(t,e);for(var a=Math.floor(e/i),o=e%i,s=[],c=0,l=0;co){s=[...r.slice(0,c),o-l];break}}var f=s.length%2==0?[0,t]:[t];return[...Ee(r,a),...s,...f].map(e=>`${e}px`).join(`, `)}function Oe(e,t,n){return e?De(n,t,`${e}`.split(/[,\s]+/gim).map(e=>parseFloat(e))):H(t,n)}function ke(e){e.animationElapsedTime,e.isAnimating,e.isEntrance;var t=e.visibleLength,n=e.strokeDasharray,r=e.connectNulls,i=Se(e,xe),a=r??!1,o;if(t!=null){var s=i.pathRef;o=Oe(n,we(s?.current??null),t)}else n!=null&&(o=String(n));return B.createElement(pe,V({},i,{connectNulls:a,strokeDasharray:o}))}function Ae(e){var t=(0,B.useRef)(0),n=(0,B.useRef)(0),r=(0,B.useRef)(!1),i=(0,B.useRef)(e);return i.current!==e&&(t.current=n.current,i.current=e),(0,B.useCallback)((e,i)=>{if(r.current)return null;var a=Math.min(re(t.current+e*i),i);return e>0&&i>0&&(n.current=Math.max(n.current,a),a>=i)?(r.current=!0,null):a},[])}var je=[`children`];function Me(e,t){if(e==null)return{};var n,r,i=Ne(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r({x:0,y:0,value:0}),errorBarOffset:0});function Fe(e){var t=e.children,n=Me(e,je);return B.createElement(Pe.Provider,{value:n},t)}var U=(e,t,n,r)=>R(e,`xAxis`,t,r),W=(e,t,n,r)=>L(e,`xAxis`,t,r),G=(e,t,n,r)=>R(e,`yAxis`,n,r),K=(e,t,n,r)=>L(e,`yAxis`,n,r),Ie=F([d,U,G,W,K],(e,t,n,r,i)=>u(e,`xAxis`)?E(t,r,!1):E(n,i,!1)),Le=(e,t,n,r,i)=>i;function Re(e){return e.type===`line`}var ze=F([ce,Le],(e,t)=>e.filter(Re).find(e=>e.id===t)),Be=F([d,U,G,W,K,ze,Ie,ae],(e,t,n,r,i,a,o,s)=>{var c=s.chartData,l=s.dataStartIndex,u=s.dataEndIndex;if(!(a==null||t==null||n==null||r==null||i==null||r.length===0||i.length===0||o==null||e!==`horizontal`&&e!==`vertical`)){var d=a.dataKey,f=a.data,p=f!=null&&f.length>0?f:c?.slice(l,u+1);if(p!=null)return ot({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataKey:d,bandSize:o,displayedData:p})}}),Ve=[`id`],He=[`type`,`layout`,`connectNulls`,`needClip`,`shape`,`strokeDasharray`],Ue=[`activeDot`,`animateNewValues`,`animationBegin`,`animationDuration`,`animationEasing`,`connectNulls`,`dot`,`hide`,`isAnimationActive`,`label`,`legendType`,`xAxisId`,`yAxisId`,`id`];function q(){return q=Object.assign?Object.assign.bind():function(e){for(var t=1;t0?t/n:0}var Z={activeDot:!0,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:`ease`,animationInterpolateFn:(e,t)=>{if(e==null)return[];if(t===1)return e.flatMap(e=>e.status===`removed`?[]:[e.next]);var n=Ye(e),r=[];for(var i of e)if(i.status===`matched`)r.push(X(X({},i.next),{},{x:M(i.prev.x,i.next.x,t),y:M(i.prev.y,i.next.y,t)}));else if(i.status===`added`){if(i.next.x!=null){var a=i.next.x-n;r.push(X(X({},i.next),{},{x:M(a,i.next.x,t),y:i.next.y}))}else r.push(i.next)}else if(i.status===`removed`&&i.prev.x!=null){var o=i.prev.x+n;r.push(X(X({},i.prev),{},{x:M(i.prev.x,o,t),y:i.prev.y}))}return r},animationMatchBy:s,connectNulls:!1,dot:!0,fill:`#fff`,hide:!1,isAnimationActive:`auto`,label:!1,legendType:`line`,shape:ke,stroke:`#3182bd`,strokeWidth:1,xAxisId:0,yAxisId:0,zIndex:le.line,type:`linear`},Xe=e=>{var t=e.dataKey,n=e.name,r=e.stroke,i=e.legendType;return[{inactive:e.hide,dataKey:t,type:i,color:r,value:O(n,t),payload:e}]},Ze=B.memo(e=>{var t=e.dataKey,n=e.data,r=e.stroke,i=e.strokeWidth,a=e.fill,o=e.name,s=e.hide,l=e.unit,u=e.formatter,d=e.tooltipType,f=e.id,p={dataDefinedOnItem:n,getPosition:c,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:t,nameKey:void 0,name:O(o,t),hide:s,type:d,color:r,unit:l,formatter:u,graphicalItemId:f}};return B.createElement(x,{tooltipEntrySettings:p})});function Qe(e){var t=e.clipPathId,n=e.points,r=e.props,i=r.dot,a=r.dataKey,o=r.needClip;r.id;var s=J(r,Ve),c=me(s);return B.createElement(j,{points:n,dot:i,className:`recharts-line-dots`,dotClassName:`recharts-line-dot`,dataKey:a,baseProps:c,needClip:o,clipPathId:t})}function $e(e){var t=e.showLabels,n=e.children,r=e.points,i=(0,B.useMemo)(()=>r?.map(e=>{var t={x:e.x??0,y:e.y??0,width:0,lowerWidth:0,upperWidth:0,height:0};return X(X({},t),{},{value:e.value,payload:e.payload,viewBox:t,parentViewBox:void 0,fill:void 0})}),[r]);return B.createElement(g,{value:t?i:void 0},n)}function et(e){var t=e.clipPathId,n=e.pathRef,r=e.points,i=e.props,a=e.animationElapsedTime,o=e.isAnimating,s=e.isEntrance,c=e.visibleLength,l=i.type,u=i.layout,d=i.connectNulls,f=i.needClip,p=i.shape,m=i.strokeDasharray,h=J(i,He),g=X(X({},D(h)),{},{fill:`none`,className:`recharts-line-curve`,clipPath:f?`url(#clipPath-${t})`:void 0,points:r,type:l,layout:u,connectNulls:d,strokeDasharray:m??i.strokeDasharray,pathRef:n,animationElapsedTime:a,isAnimating:o,isEntrance:i.animateNewValues?s:!1,visibleLength:c});return B.createElement(B.Fragment,null,r?.length>1&&B.createElement(C,{option:p,DefaultShape:Z.shape,shapeProps:g}),B.createElement(Qe,{points:r,clipPathId:t,props:i}))}function tt(e){var t=e.clipPathId,n=e.props,r=e.pathRef,i=e.previousPointsRef,a=n.points,o=n.isAnimationActive,s=n.animationBegin,c=n.animationDuration,l=n.animationEasing,u=n.animationMatchBy,d=n.animationInterpolateFn,f=n.layout,p=Je(r.current),m=ie(n.onAnimationStart,n.onAnimationEnd),h=m.isAnimating,g=m.handleAnimationStart,_=m.handleAnimationEnd,y=!h,b=Ae(a),x=(0,B.useCallback)(e=>e>0&&p>0,[p]);return B.createElement($e,{points:a,showLabels:y},n.children,B.createElement(w,{animationInput:a,animationIdPrefix:`recharts-line-`,items:a,previousItemsRef:i,isAnimationActive:o,animationBegin:s,animationDuration:c,animationEasing:l,onAnimationStart:g,onAnimationEnd:_,animationInterpolateFn:d,animationMatchBy:u,shouldUpdatePreviousRef:x,layout:f},(e,i,a)=>{var o=h||i<1,s=o?b(i,p):null;return B.createElement(et,{props:n,points:e,clipPathId:t,pathRef:r,animationElapsedTime:i,isAnimating:o,isEntrance:a,visibleLength:s})}),B.createElement(v,{label:n.label}))}function nt(e){var t=e.clipPathId,n=e.props,r=(0,B.useRef)(null),i=(0,B.useRef)(null);return B.createElement(tt,{props:n,clipPathId:t,previousPointsRef:r,pathRef:i})}var rt=(e,t)=>({x:e.x??void 0,y:e.y??void 0,value:e.value,errorVal:z(e.payload,t)}),it=class extends B.Component{render(){var e=this.props,t=e.hide,n=e.dot,i=e.points,a=e.className,o=e.xAxisId,s=e.yAxisId,c=e.top,l=e.left,u=e.width,d=e.height,f=e.id,p=e.needClip,m=e.zIndex;if(t)return null;var h=r(`recharts-line`,a),g=f,_=se(n),v=_.r,y=_.strokeWidth,x=T(n),S=v*2+y,C=p?`url(#clipPath-${x?``:`dots-`}${g})`:void 0;return B.createElement(N,{zIndex:m},B.createElement(b,{className:h},p&&B.createElement(`defs`,null,B.createElement(de,{clipPathId:g,xAxisId:o,yAxisId:s}),!x&&B.createElement(`clipPath`,{id:`clipPath-dots-${g}`},B.createElement(`rect`,{x:l-S/2,y:c-S/2,width:u+S,height:d+S}))),B.createElement(Fe,{xAxisId:o,yAxisId:s,data:i,dataPointFormatter:rt,errorBarOffset:0},B.createElement(nt,{props:this.props,clipPathId:g}))),B.createElement(fe,{activeDot:this.props.activeDot,points:i,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:C}))}};function at(e){var t=k(e,Z),n=t.activeDot,r=t.animateNewValues,i=t.animationBegin,a=t.animationDuration,o=t.animationEasing,s=t.connectNulls,c=t.dot,l=t.hide,u=t.isAnimationActive,d=t.label,f=t.legendType,p=t.xAxisId,m=t.yAxisId,g=t.id,_=J(t,Ue),v=te(p,m).needClip,b=I(),x=h(),C=S(),w=y(e=>Be(e,p,m,C,g));if(x!==`horizontal`&&x!==`vertical`||w==null||b==null)return null;var T=b.height,E=b.width,D=b.x,O=b.y;return B.createElement(it,q({},_,{id:g,connectNulls:s,dot:c,activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:o,isAnimationActive:u,hide:l,label:d,legendType:f,xAxisId:p,yAxisId:m,points:w,layout:x,height:T,width:E,left:D,top:O,needClip:v}))}function ot(e){var t=e.layout,n=e.xAxis,r=e.yAxis,i=e.xAxisTicks,a=e.yAxisTicks,o=e.dataKey,s=e.bandSize;return e.displayedData.map((e,c)=>{var l=z(e,o);if(t===`horizontal`)return{x:_({axis:n,ticks:i,bandSize:s,entry:e,index:c}),y:(m(l)?null:r.scale.map(l))??null,value:l,payload:e};var u=m(l)?null:n.scale.map(l),d=_({axis:r,ticks:a,bandSize:s,entry:e,index:c});return u==null||d==null?null:{x:u,y:d,value:l,payload:e}}).filter(Boolean)}function st(e){var t=k(e,Z),n=S();return B.createElement(f,{id:t.id,type:`line`},e=>B.createElement(B.Fragment,null,B.createElement(ne,{legendPayload:Xe(t)}),B.createElement(Ze,{dataKey:t.dataKey,data:t.data,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,formatter:t.formatter,tooltipType:t.tooltipType,id:e}),B.createElement(p,{type:`line`,id:e,data:t.data,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,dataKey:t.dataKey,hide:t.hide,isPanorama:n}),B.createElement(at,q({},t,{id:e}))))}var Q=B.memo(st,A);Q.displayName=`Line`;var ct=[`axis`],lt=(0,B.forwardRef)((e,t)=>B.createElement(oe,{chartName:`ComposedChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:ct,tooltipPayloadSearcher:P,categoricalChartProps:e,ref:t})),ut={metric:24,title:18,section:15,body:13,xs:12,caption:12},$=n();function dt(e,t,n){let r=new Date(e);return Number.isFinite(r.getTime())?new Intl.DateTimeFormat(n===`zh`?`zh-CN`:`en-US`,t?{month:`short`,day:`numeric`}:{hour:`2-digit`,minute:`2-digit`,hour12:!1}).format(r):``}function ft(e){if(e<=1)return 1;let t=10**Math.floor(Math.log10(e)),n=e/t;return(n<=1?1:n<=2?2:n<=5?5:10)*t}function pt(e){let t=Math.max(0,e.ok??e.requests-e.error),n=Math.min(Math.max(0,e.requests-t),Math.max(0,e.requests));return{...e,okCount:t,errorCount:n,inputTokens:e.prompt_tokens??0,outputTokens:e.completion_tokens??0,cacheTokens:e.cache_read_tokens??0,p50:e.latency_p50_ms??null,p95:e.latency_p95_ms??null}}function mt({active:e,payload:t,daily:n,lang:r,specs:i,format:a,totalLabel:o,total:s}){if(!e||!t?.[0])return null;let c=t[0].payload;return(0,$.jsxs)(`div`,{className:`rounded-xl bg-overlay px-3 py-2 text-caption text-overlay-foreground shadow-overlay`,children:[(0,$.jsx)(`div`,{className:`mono text-muted`,children:dt(c.at,n,r)}),(0,$.jsxs)(`div`,{className:`mt-1.5 grid gap-1`,children:[i.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-6`,children:[(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`size-1.5 rounded-full`,style:{background:e.color}}),e.label]}),(0,$.jsx)(`span`,{className:`mono font-medium`,children:a(c[e.key])})]},String(e.key))),s&&o?(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-6 pt-1`,children:[(0,$.jsx)(`span`,{className:`text-muted`,children:o}),(0,$.jsx)(`span`,{className:`mono font-medium`,children:a(s(c))})]}):null]})]})}var ht=(0,B.memo)(function({series:e,lang:t,emptyLabel:n,okLabel:r,errorLabel:s,onSelectRange:c,selectHint:u,labels:d,initialMetric:f=`requests`}){let[p,m]=(0,B.useState)(f),[h,g]=(0,B.useState)(null),[_,v]=(0,B.useState)(null),y=(0,B.useRef)(!1),b=(0,B.useRef)(null),x=(0,B.useMemo)(()=>e.map(pt),[e]),S=x[0],C=x[x.length-1],w=(S&&C?Date.parse(C.at)-Date.parse(S.at):0)>1728e5,T=d??{requests:`Requests`,tokens:`Tokens`,latency:`p95 latency`,input:`input`,output:`output`,cacheRead:`cache read`,p50:`p50`,p95:`p95`,total:`total`},E=p===`tokens`?[{key:`inputTokens`,label:T.input,color:`var(--foreground)`,area:!0,width:1.5,opacity:.75},{key:`outputTokens`,label:T.output,color:`var(--success)`,area:!0,width:1.5},{key:`cacheTokens`,label:T.cacheRead,color:`var(--muted)`,width:1.25,opacity:.8}]:p===`latency`?[{key:`p95`,label:T.p95,color:`var(--warning)`,area:!0,width:1.75},{key:`p50`,label:T.p50,color:`var(--muted)`,width:1.25,opacity:.85}]:[{key:`okCount`,label:r,color:`var(--success)`,area:!0,width:1.75},{key:`errorCount`,label:s,color:`var(--danger)`,area:!0,width:1.25,opacity:.7}],D=e=>e==null?`—`:p===`latency`?a(e):i(e),O=p===`requests`?e=>e.requests:p===`tokens`?e=>e.inputTokens+e.outputTokens:void 0,k=x.flatMap(e=>E.map(t=>Number(e[t.key]??0))),A=p===`requests`?Math.max(0,...x.map(e=>e.requests)):Math.max(0,...k),j=ft(A),M=x.some(e=>e.requests>0),N=x.map(e=>`${e.at}:${e.requests}:${e.error}`).join(`|`);(0,B.useLayoutEffect)(()=>{let e=b.current;if(!e||!M||y.current)return;let t=!1,n=null,r=o.context(()=>{let r=o.matchMedia(),i=()=>{let t=o.utils.toArray(`.recharts-area-area`,e),n=o.utils.toArray(`.recharts-line-curve`,e);return!t.length&&!n.length?!1:(r.add(`(prefers-reduced-motion: reduce)`,()=>{o.set(n,{clearProps:`strokeDashoffset,strokeDasharray`}),o.set(t,{clearProps:`autoAlpha`})}),r.add(`(prefers-reduced-motion: no-preference)`,()=>{o.fromTo(t,{autoAlpha:0},{autoAlpha:1,duration:.45,ease:`power2.out`,stagger:.05}),n.forEach((e,t)=>{let n=e.getTotalLength();o.fromTo(e,{strokeDasharray:n,strokeDashoffset:n},{strokeDashoffset:0,duration:.7,delay:t*.05,ease:`power2.out`})})}),!0)};if(i()){t=!0,y.current=!0;return}n=new MutationObserver(()=>{t||i()&&(t=!0,y.current=!0,n?.disconnect())}),n.observe(e,{childList:!0,subtree:!0})},e);return()=>{n?.disconnect(),r.revert()}},[M,N]);let P=x.length>1?Date.parse(x[1].at)-Date.parse(x[0].at):36e5,F=()=>{if(h&&_&&c){let e=Date.parse(h),t=Date.parse(_);if(Number.isFinite(e)&&Number.isFinite(t)){let n=Math.min(e,t),r=Math.max(e,t)+P;c(new Date(n).toISOString(),new Date(r).toISOString())}}g(null),v(null)},I=e=>{let t=e?.activeLabel;return t==null?null:String(t)};return!e.length||!M?(0,$.jsx)(be,{emptyLabel:n}):(0,$.jsxs)(`div`,{ref:b,className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:`mb-3 flex justify-end`,children:(0,$.jsx)(ye,{value:p,onChange:e=>m(e),ariaLabel:T.requests,options:[{id:`requests`,label:T.requests},{id:`tokens`,label:T.tokens},{id:`latency`,label:T.latency}]})}),(0,$.jsx)(`div`,{className:`h-56 w-full`,children:(0,$.jsx)(l,{width:`100%`,height:`100%`,children:(0,$.jsxs)(lt,{data:x,margin:{top:8,right:8,bottom:0,left:0},style:c?{cursor:`crosshair`,userSelect:`none`}:void 0,onMouseDown:c?e=>{let t=I(e);t&&(g(t),v(t))}:void 0,onMouseMove:c?e=>{if(!h)return;let t=I(e);t&&v(t)}:void 0,onMouseUp:c?F:void 0,onMouseLeave:c?()=>{g(null),v(null)}:void 0,children:[(0,$.jsx)(`defs`,{children:E.filter(e=>e.area).map(e=>(0,$.jsxs)(`linearGradient`,{id:`traffic-fill-${String(e.key)}`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,$.jsx)(`stop`,{offset:`0%`,stopColor:e.color,stopOpacity:.22}),(0,$.jsx)(`stop`,{offset:`100%`,stopColor:e.color,stopOpacity:.02})]},String(e.key)))}),(0,$.jsx)(ge,{vertical:!1,stroke:`var(--separator)`,strokeDasharray:`3 6`}),(0,$.jsx)(_e,{dataKey:`at`,tickLine:!1,axisLine:!1,minTickGap:28,tick:{fill:`var(--muted)`,fontSize:ut.caption,fontFamily:`var(--font-mono)`},tickFormatter:e=>dt(e,w,t)}),(0,$.jsx)(ue,{width:p===`latency`?44:36,domain:[0,j],tickLine:!1,axisLine:!1,allowDecimals:!1,tick:{fill:`var(--muted)`,fontSize:ut.caption,fontFamily:`var(--font-mono)`},tickFormatter:e=>p===`latency`?a(e):i(e)}),(0,$.jsx)(he,{cursor:{stroke:`var(--border)`,strokeDasharray:`3 3`},content:(0,$.jsx)(mt,{daily:w,lang:t,specs:E,format:D,totalLabel:T.total,total:O})}),E.filter(e=>e.area).map(e=>(0,$.jsx)(ee,{type:`monotone`,dataKey:e.key,stroke:`none`,fill:`url(#traffic-fill-${String(e.key)})`,isAnimationActive:!1,activeDot:!1,dot:!1,connectNulls:!0},`area-${String(e.key)}`)),E.map(e=>(0,$.jsx)(Q,{type:`monotone`,dataKey:e.key,stroke:e.color,strokeWidth:e.width??1.5,strokeOpacity:e.opacity??1,dot:!1,isAnimationActive:!1,connectNulls:!0,activeDot:{r:4,fill:`var(--surface)`,stroke:e.color,strokeWidth:1.5}},`line-${String(e.key)}`)),h&&_?(0,$.jsx)(ve,{x1:h,x2:_,fill:`var(--foreground)`,fillOpacity:.06,stroke:`none`,ifOverflow:`visible`}):null]})})}),(0,$.jsxs)(`div`,{className:`mt-2 flex min-h-5 items-center justify-between gap-3 text-caption text-muted`,children:[(0,$.jsx)(`div`,{className:`flex items-center gap-3`,children:E.map(e=>(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`size-1.5 rounded-full`,style:{background:e.color}}),e.label]},String(e.key)))}),(0,$.jsxs)(`span`,{className:`flex items-center gap-3`,children:[c&&u?(0,$.jsx)(`span`,{children:u}):null,(0,$.jsxs)(`span`,{className:`mono`,children:[D(A),` peak`]})]})]})]})});export{ht as TrafficChart}; \ No newline at end of file diff --git a/internal/webui/static/assets/TrafficChart-ROSzf7de.js b/internal/webui/static/assets/TrafficChart-ROSzf7de.js deleted file mode 100644 index 5e526e4d..00000000 --- a/internal/webui/static/assets/TrafficChart-ROSzf7de.js +++ /dev/null @@ -1 +0,0 @@ -import{a as e,c as t,n,r}from"./shim-mfK0Rmj6.js";import{r as i}from"./gsap-C3sDxib7.js";import{A as a,An as o,At as s,Bt as c,Ct as l,D as u,E as d,En as f,Et as p,F as m,Ft as h,I as g,Kt as _,Ln as v,M as y,Mt as b,N as x,O as S,P as C,Pt as w,Rn as T,Rt as E,Sn as D,St as O,T as k,Tn as A,U as j,V as M,Wt as N,a as ee,b as P,c as te,it as F,j as ne,jn as re,k as ie,mt as ae,n as oe,nt as I,o as se,ot as ce,pt as le,r as ue,s as de,y as fe,yt as pe,zn as me,zt as L}from"./AreaChart-B0YOdVBx.js";import{n as he,t as ge}from"./CartesianGrid-BJyfpdDb.js";import{t as _e}from"./XAxis-DLQkFqxC.js";import{t as ve}from"./ReferenceArea-CiIBWWEY.js";import{t as ye}from"./FilterToggle-16Av-HiR.js";import{i as R,s as z}from"./format-B6SmebW-.js";import{t as be}from"./OverviewPage-BAlBmY5L.js";var B=t(e()),xe=[`animationElapsedTime`,`isAnimating`,`isEntrance`,`visibleLength`,`strokeDasharray`,`connectNulls`];function V(){return V=Object.assign?Object.assign.bind():function(e){for(var t=1;te+t,0);if(!i)return H(t,e);for(var a=Math.floor(e/i),o=e%i,s=[],c=0,l=0;co){s=[...r.slice(0,c),o-l];break}}var f=s.length%2==0?[0,t]:[t];return[...Ee(r,a),...s,...f].map(e=>`${e}px`).join(`, `)}function Oe(e,t,n){return e?De(n,t,`${e}`.split(/[,\s]+/gim).map(e=>parseFloat(e))):H(t,n)}function ke(e){e.animationElapsedTime,e.isAnimating,e.isEntrance;var t=e.visibleLength,n=e.strokeDasharray,r=e.connectNulls,i=Se(e,xe),a=r??!1,o;if(t!=null){var s=i.pathRef;o=Oe(n,we(s?.current??null),t)}else n!=null&&(o=String(n));return B.createElement(pe,V({},i,{connectNulls:a,strokeDasharray:o}))}function Ae(e){var t=(0,B.useRef)(0),n=(0,B.useRef)(0),r=(0,B.useRef)(!1),i=(0,B.useRef)(e);return i.current!==e&&(t.current=n.current,i.current=e),(0,B.useCallback)((e,i)=>{if(r.current)return null;var a=Math.min(re(t.current+e*i),i);return e>0&&i>0&&(n.current=Math.max(n.current,a),a>=i)?(r.current=!0,null):a},[])}var je=[`children`];function Me(e,t){if(e==null)return{};var n,r,i=Ne(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r({x:0,y:0,value:0}),errorBarOffset:0});function Fe(e){var t=e.children,n=Me(e,je);return B.createElement(Pe.Provider,{value:n},t)}var U=(e,t,n,r)=>I(e,`xAxis`,t,r),W=(e,t,n,r)=>F(e,`xAxis`,t,r),G=(e,t,n,r)=>I(e,`yAxis`,n,r),K=(e,t,n,r)=>F(e,`yAxis`,n,r),Ie=N([l,U,G,W,K],(e,t,n,r,i)=>c(e,`xAxis`)?w(t,r,!1):w(n,i,!1)),Le=(e,t,n,r,i)=>i;function Re(e){return e.type===`line`}var ze=N([ce,Le],(e,t)=>e.filter(Re).find(e=>e.id===t)),Be=N([l,U,G,W,K,ze,Ie,ae],(e,t,n,r,i,a,o,s)=>{var c=s.chartData,l=s.dataStartIndex,u=s.dataEndIndex;if(!(a==null||t==null||n==null||r==null||i==null||r.length===0||i.length===0||o==null||e!==`horizontal`&&e!==`vertical`)){var d=a.dataKey,f=a.data,p=f!=null&&f.length>0?f:c?.slice(l,u+1);if(p!=null)return ot({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataKey:d,bandSize:o,displayedData:p})}}),Ve=[`id`],He=[`type`,`layout`,`connectNulls`,`needClip`,`shape`,`strokeDasharray`],Ue=[`activeDot`,`animateNewValues`,`animationBegin`,`animationDuration`,`animationEasing`,`connectNulls`,`dot`,`hide`,`isAnimationActive`,`label`,`legendType`,`xAxisId`,`yAxisId`,`id`];function q(){return q=Object.assign?Object.assign.bind():function(e){for(var t=1;t0?t/n:0}var Z={activeDot:!0,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:`ease`,animationInterpolateFn:(e,t)=>{if(e==null)return[];if(t===1)return e.flatMap(e=>e.status===`removed`?[]:[e.next]);var n=Ye(e),r=[];for(var i of e)if(i.status===`matched`)r.push(X(X({},i.next),{},{x:A(i.prev.x,i.next.x,t),y:A(i.prev.y,i.next.y,t)}));else if(i.status===`added`){if(i.next.x!=null){var a=i.next.x-n;r.push(X(X({},i.next),{},{x:A(a,i.next.x,t),y:i.next.y}))}else r.push(i.next)}else if(i.status===`removed`&&i.prev.x!=null){var o=i.prev.x+n;r.push(X(X({},i.prev),{},{x:A(i.prev.x,o,t),y:i.prev.y}))}return r},animationMatchBy:a,connectNulls:!1,dot:!0,fill:`#fff`,hide:!1,isAnimationActive:`auto`,label:!1,legendType:`line`,shape:ke,stroke:`#3182bd`,strokeWidth:1,xAxisId:0,yAxisId:0,zIndex:le.line,type:`linear`},Xe=e=>{var t=e.dataKey,n=e.name,r=e.stroke,i=e.legendType;return[{inactive:e.hide,dataKey:t,type:i,color:r,value:E(n,t),payload:e}]},Ze=B.memo(e=>{var t=e.dataKey,n=e.data,r=e.stroke,i=e.strokeWidth,a=e.fill,s=e.name,c=e.hide,l=e.unit,u=e.formatter,d=e.tooltipType,f=e.id,p={dataDefinedOnItem:n,getPosition:o,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:t,nameKey:void 0,name:E(s,t),hide:c,type:d,color:r,unit:l,formatter:u,graphicalItemId:f}};return B.createElement(y,{tooltipEntrySettings:p})});function Qe(e){var t=e.clipPathId,n=e.points,r=e.props,i=r.dot,a=r.dataKey,o=r.needClip;r.id;var s=J(r,Ve),c=me(s);return B.createElement(k,{points:n,dot:i,className:`recharts-line-dots`,dotClassName:`recharts-line-dot`,dataKey:a,baseProps:c,needClip:o,clipPathId:t})}function $e(e){var t=e.showLabels,n=e.children,r=e.points,i=(0,B.useMemo)(()=>r?.map(e=>{var t={x:e.x??0,y:e.y??0,width:0,lowerWidth:0,upperWidth:0,height:0};return X(X({},t),{},{value:e.value,payload:e.payload,viewBox:t,parentViewBox:void 0,fill:void 0})}),[r]);return B.createElement(m,{value:t?i:void 0},n)}function et(e){var t=e.clipPathId,n=e.pathRef,r=e.points,i=e.props,a=e.animationElapsedTime,o=e.isAnimating,s=e.isEntrance,c=e.visibleLength,l=i.type,u=i.layout,d=i.connectNulls,f=i.needClip,p=i.shape,m=i.strokeDasharray,h=J(i,He),g=X(X({},T(h)),{},{fill:`none`,className:`recharts-line-curve`,clipPath:f?`url(#clipPath-${t})`:void 0,points:r,type:l,layout:u,connectNulls:d,strokeDasharray:m??i.strokeDasharray,pathRef:n,animationElapsedTime:a,isAnimating:o,isEntrance:i.animateNewValues?s:!1,visibleLength:c});return B.createElement(B.Fragment,null,r?.length>1&&B.createElement(x,{option:p,DefaultShape:Z.shape,shapeProps:g}),B.createElement(Qe,{points:r,clipPathId:t,props:i}))}function tt(e){var t=e.clipPathId,n=e.props,r=e.pathRef,i=e.previousPointsRef,a=n.points,o=n.isAnimationActive,s=n.animationBegin,c=n.animationDuration,l=n.animationEasing,u=n.animationMatchBy,d=n.animationInterpolateFn,f=n.layout,p=Je(r.current),m=ie(n.onAnimationStart,n.onAnimationEnd),h=m.isAnimating,_=m.handleAnimationStart,v=m.handleAnimationEnd,y=!h,b=Ae(a),x=(0,B.useCallback)(e=>e>0&&p>0,[p]);return B.createElement($e,{points:a,showLabels:y},n.children,B.createElement(S,{animationInput:a,animationIdPrefix:`recharts-line-`,items:a,previousItemsRef:i,isAnimationActive:o,animationBegin:s,animationDuration:c,animationEasing:l,onAnimationStart:_,onAnimationEnd:v,animationInterpolateFn:d,animationMatchBy:u,shouldUpdatePreviousRef:x,layout:f},(e,i,a)=>{var o=h||i<1,s=o?b(i,p):null;return B.createElement(et,{props:n,points:e,clipPathId:t,pathRef:r,animationElapsedTime:i,isAnimating:o,isEntrance:a,visibleLength:s})}),B.createElement(g,{label:n.label}))}function nt(e){var t=e.clipPathId,n=e.props,r=(0,B.useRef)(null),i=(0,B.useRef)(null);return B.createElement(tt,{props:n,clipPathId:t,previousPointsRef:r,pathRef:i})}var rt=(e,t)=>({x:e.x??void 0,y:e.y??void 0,value:e.value,errorVal:L(e.payload,t)}),it=class extends B.Component{render(){var e=this.props,t=e.hide,n=e.dot,i=e.points,a=e.className,o=e.xAxisId,s=e.yAxisId,c=e.top,l=e.left,u=e.width,d=e.height,f=e.id,p=e.needClip,m=e.zIndex;if(t)return null;var h=r(`recharts-line`,a),g=f,_=se(n),y=_.r,b=_.strokeWidth,x=C(n),S=y*2+b,w=p?`url(#clipPath-${x?``:`dots-`}${g})`:void 0;return B.createElement(j,{zIndex:m},B.createElement(v,{className:h},p&&B.createElement(`defs`,null,B.createElement(de,{clipPathId:g,xAxisId:o,yAxisId:s}),!x&&B.createElement(`clipPath`,{id:`clipPath-dots-${g}`},B.createElement(`rect`,{x:l-S/2,y:c-S/2,width:u+S,height:d+S}))),B.createElement(Fe,{xAxisId:o,yAxisId:s,data:i,dataPointFormatter:rt,errorBarOffset:0},B.createElement(nt,{props:this.props,clipPathId:g}))),B.createElement(fe,{activeDot:this.props.activeDot,points:i,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:w}))}};function at(e){var t=D(e,Z),n=t.activeDot,r=t.animateNewValues,i=t.animationBegin,a=t.animationDuration,o=t.animationEasing,s=t.connectNulls,c=t.dot,l=t.hide,u=t.isAnimationActive,d=t.label,f=t.legendType,m=t.xAxisId,h=t.yAxisId,g=t.id,v=J(t,Ue),y=te(m,h).needClip,x=P(),S=p(),C=b(),w=_(e=>Be(e,m,h,C,g));if(S!==`horizontal`&&S!==`vertical`||w==null||x==null)return null;var T=x.height,E=x.width,O=x.x,k=x.y;return B.createElement(it,q({},v,{id:g,connectNulls:s,dot:c,activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:o,isAnimationActive:u,hide:l,label:d,legendType:f,xAxisId:m,yAxisId:h,points:w,layout:S,height:T,width:E,left:O,top:k,needClip:y}))}function ot(e){var t=e.layout,n=e.xAxis,r=e.yAxis,i=e.xAxisTicks,a=e.yAxisTicks,o=e.dataKey,s=e.bandSize;return e.displayedData.map((e,c)=>{var l=L(e,o);if(t===`horizontal`)return{x:h({axis:n,ticks:i,bandSize:s,entry:e,index:c}),y:(f(l)?null:r.scale.map(l))??null,value:l,payload:e};var u=f(l)?null:n.scale.map(l),d=h({axis:r,ticks:a,bandSize:s,entry:e,index:c});return u==null||d==null?null:{x:u,y:d,value:l,payload:e}}).filter(Boolean)}function st(e){var t=D(e,Z),n=b();return B.createElement(u,{id:t.id,type:`line`},e=>B.createElement(B.Fragment,null,B.createElement(ne,{legendPayload:Xe(t)}),B.createElement(Ze,{dataKey:t.dataKey,data:t.data,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,formatter:t.formatter,tooltipType:t.tooltipType,id:e}),B.createElement(d,{type:`line`,id:e,data:t.data,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,dataKey:t.dataKey,hide:t.hide,isPanorama:n}),B.createElement(at,q({},t,{id:e}))))}var Q=B.memo(st,O);Q.displayName=`Line`;var ct=[`axis`],lt=(0,B.forwardRef)((e,t)=>B.createElement(oe,{chartName:`ComposedChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:ct,tooltipPayloadSearcher:M,categoricalChartProps:e,ref:t})),ut={metric:24,title:18,section:15,body:13,xs:12,caption:12},$=n();function dt(e,t,n){let r=new Date(e);return Number.isFinite(r.getTime())?new Intl.DateTimeFormat(n===`zh`?`zh-CN`:`en-US`,t?{month:`short`,day:`numeric`}:{hour:`2-digit`,minute:`2-digit`,hour12:!1}).format(r):``}function ft(e){if(e<=1)return 1;let t=10**Math.floor(Math.log10(e)),n=e/t;return(n<=1?1:n<=2?2:n<=5?5:10)*t}function pt(e){let t=Math.max(0,e.ok??e.requests-e.error),n=Math.min(Math.max(0,e.requests-t),Math.max(0,e.requests));return{...e,okCount:t,errorCount:n,inputTokens:e.prompt_tokens??0,outputTokens:e.completion_tokens??0,cacheTokens:e.cache_read_tokens??0,p50:e.latency_p50_ms??null,p95:e.latency_p95_ms??null}}function mt({active:e,payload:t,daily:n,lang:r,specs:i,format:a,totalLabel:o,total:s}){if(!e||!t?.[0])return null;let c=t[0].payload;return(0,$.jsxs)(`div`,{className:`rounded-xl bg-overlay px-3 py-2 text-caption text-overlay-foreground shadow-overlay`,children:[(0,$.jsx)(`div`,{className:`mono text-muted`,children:dt(c.at,n,r)}),(0,$.jsxs)(`div`,{className:`mt-1.5 grid gap-1`,children:[i.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-6`,children:[(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`size-1.5 rounded-full`,style:{background:e.color}}),e.label]}),(0,$.jsx)(`span`,{className:`mono font-medium`,children:a(c[e.key])})]},String(e.key))),s&&o?(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-6 pt-1`,children:[(0,$.jsx)(`span`,{className:`text-muted`,children:o}),(0,$.jsx)(`span`,{className:`mono font-medium`,children:a(s(c))})]}):null]})]})}var ht=(0,B.memo)(function({series:e,lang:t,emptyLabel:n,okLabel:r,errorLabel:a,onSelectRange:o,selectHint:c,labels:l,initialMetric:u=`requests`}){let[d,f]=(0,B.useState)(u),[p,m]=(0,B.useState)(null),[h,g]=(0,B.useState)(null),_=(0,B.useRef)(!1),v=(0,B.useRef)(null),y=(0,B.useMemo)(()=>e.map(pt),[e]),b=y[0],x=y[y.length-1],S=(b&&x?Date.parse(x.at)-Date.parse(b.at):0)>1728e5,C=l??{requests:`Requests`,tokens:`Tokens`,latency:`p95 latency`,input:`input`,output:`output`,cacheRead:`cache read`,p50:`p50`,p95:`p95`,total:`total`},w=d===`tokens`?[{key:`inputTokens`,label:C.input,color:`var(--foreground)`,area:!0,width:1.5,opacity:.75},{key:`outputTokens`,label:C.output,color:`var(--success)`,area:!0,width:1.5},{key:`cacheTokens`,label:C.cacheRead,color:`var(--muted)`,width:1.25,opacity:.8}]:d===`latency`?[{key:`p95`,label:C.p95,color:`var(--warning)`,area:!0,width:1.75},{key:`p50`,label:C.p50,color:`var(--muted)`,width:1.25,opacity:.85}]:[{key:`okCount`,label:r,color:`var(--success)`,area:!0,width:1.75},{key:`errorCount`,label:a,color:`var(--danger)`,area:!0,width:1.25,opacity:.7}],T=e=>e==null?`—`:d===`latency`?z(e):R(e),E=d===`requests`?e=>e.requests:d===`tokens`?e=>e.inputTokens+e.outputTokens:void 0,D=y.flatMap(e=>w.map(t=>Number(e[t.key]??0))),O=d===`requests`?Math.max(0,...y.map(e=>e.requests)):Math.max(0,...D),k=ft(O),A=y.some(e=>e.requests>0),j=y.map(e=>`${e.at}:${e.requests}:${e.error}`).join(`|`);(0,B.useLayoutEffect)(()=>{let e=v.current;if(!e||!A||_.current)return;let t=!1,n=null,r=i.context(()=>{let r=i.matchMedia(),a=()=>{let t=i.utils.toArray(`.recharts-area-area`,e),n=i.utils.toArray(`.recharts-line-curve`,e);return!t.length&&!n.length?!1:(r.add(`(prefers-reduced-motion: reduce)`,()=>{i.set(n,{clearProps:`strokeDashoffset,strokeDasharray`}),i.set(t,{clearProps:`autoAlpha`})}),r.add(`(prefers-reduced-motion: no-preference)`,()=>{i.fromTo(t,{autoAlpha:0},{autoAlpha:1,duration:.45,ease:`power2.out`,stagger:.05}),n.forEach((e,t)=>{let n=e.getTotalLength();i.fromTo(e,{strokeDasharray:n,strokeDashoffset:n},{strokeDashoffset:0,duration:.7,delay:t*.05,ease:`power2.out`})})}),!0)};if(a()){t=!0,_.current=!0;return}n=new MutationObserver(()=>{t||a()&&(t=!0,_.current=!0,n?.disconnect())}),n.observe(e,{childList:!0,subtree:!0})},e);return()=>{n?.disconnect(),r.revert()}},[A,j]);let M=y.length>1?Date.parse(y[1].at)-Date.parse(y[0].at):36e5,N=()=>{if(p&&h&&o){let e=Date.parse(p),t=Date.parse(h);if(Number.isFinite(e)&&Number.isFinite(t)){let n=Math.min(e,t),r=Math.max(e,t)+M;o(new Date(n).toISOString(),new Date(r).toISOString())}}m(null),g(null)},P=e=>{let t=e?.activeLabel;return t==null?null:String(t)};return!e.length||!A?(0,$.jsx)(be,{emptyLabel:n}):(0,$.jsxs)(`div`,{ref:v,className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:`mb-3 flex justify-end`,children:(0,$.jsx)(ye,{value:d,onChange:e=>f(e),ariaLabel:C.requests,options:[{id:`requests`,label:C.requests},{id:`tokens`,label:C.tokens},{id:`latency`,label:C.latency}]})}),(0,$.jsx)(`div`,{className:`h-56 w-full`,children:(0,$.jsx)(s,{width:`100%`,height:`100%`,children:(0,$.jsxs)(lt,{data:y,margin:{top:8,right:8,bottom:0,left:0},style:o?{cursor:`crosshair`,userSelect:`none`}:void 0,onMouseDown:o?e=>{let t=P(e);t&&(m(t),g(t))}:void 0,onMouseMove:o?e=>{if(!p)return;let t=P(e);t&&g(t)}:void 0,onMouseUp:o?N:void 0,onMouseLeave:o?()=>{m(null),g(null)}:void 0,children:[(0,$.jsx)(`defs`,{children:w.filter(e=>e.area).map(e=>(0,$.jsxs)(`linearGradient`,{id:`traffic-fill-${String(e.key)}`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,$.jsx)(`stop`,{offset:`0%`,stopColor:e.color,stopOpacity:.22}),(0,$.jsx)(`stop`,{offset:`100%`,stopColor:e.color,stopOpacity:.02})]},String(e.key)))}),(0,$.jsx)(ge,{vertical:!1,stroke:`var(--separator)`,strokeDasharray:`3 6`}),(0,$.jsx)(_e,{dataKey:`at`,tickLine:!1,axisLine:!1,minTickGap:28,tick:{fill:`var(--muted)`,fontSize:ut.caption,fontFamily:`var(--font-mono)`},tickFormatter:e=>dt(e,S,t)}),(0,$.jsx)(ue,{width:d===`latency`?44:36,domain:[0,k],tickLine:!1,axisLine:!1,allowDecimals:!1,tick:{fill:`var(--muted)`,fontSize:ut.caption,fontFamily:`var(--font-mono)`},tickFormatter:e=>d===`latency`?z(e):R(e)}),(0,$.jsx)(he,{cursor:{stroke:`var(--border)`,strokeDasharray:`3 3`},content:(0,$.jsx)(mt,{daily:S,lang:t,specs:w,format:T,totalLabel:C.total,total:E})}),w.filter(e=>e.area).map(e=>(0,$.jsx)(ee,{type:`monotone`,dataKey:e.key,stroke:`none`,fill:`url(#traffic-fill-${String(e.key)})`,isAnimationActive:!1,activeDot:!1,dot:!1,connectNulls:!0},`area-${String(e.key)}`)),w.map(e=>(0,$.jsx)(Q,{type:`monotone`,dataKey:e.key,stroke:e.color,strokeWidth:e.width??1.5,strokeOpacity:e.opacity??1,dot:!1,isAnimationActive:!1,connectNulls:!0,activeDot:{r:4,fill:`var(--surface)`,stroke:e.color,strokeWidth:1.5}},`line-${String(e.key)}`)),p&&h?(0,$.jsx)(ve,{x1:p,x2:h,fill:`var(--foreground)`,fillOpacity:.06,stroke:`none`,ifOverflow:`visible`}):null]})})}),(0,$.jsxs)(`div`,{className:`mt-2 flex min-h-5 items-center justify-between gap-3 text-caption text-muted`,children:[(0,$.jsx)(`div`,{className:`flex items-center gap-3`,children:w.map(e=>(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,$.jsx)(`span`,{className:`size-1.5 rounded-full`,style:{background:e.color}}),e.label]},String(e.key)))}),(0,$.jsxs)(`span`,{className:`flex items-center gap-3`,children:[o&&c?(0,$.jsx)(`span`,{children:c}):null,(0,$.jsxs)(`span`,{className:`mono`,children:[T(O),` peak`]})]})]})]})});export{ht as TrafficChart}; \ No newline at end of file diff --git a/internal/webui/static/assets/TrashSimple.es-BiXnQzNp.js b/internal/webui/static/assets/TrashSimple.es-51cVgQMz.js similarity index 93% rename from internal/webui/static/assets/TrashSimple.es-BiXnQzNp.js rename to internal/webui/static/assets/TrashSimple.es-51cVgQMz.js index b870c52c..17a79842 100644 --- a/internal/webui/static/assets/TrashSimple.es-BiXnQzNp.js +++ b/internal/webui/static/assets/TrashSimple.es-51cVgQMz.js @@ -1 +1 @@ -import{a as e,c as t}from"./shim-mfK0Rmj6.js";import{pt as n}from"./useI18n-BSw4X3mq.js";var r=t(e(),1),i=new Map([[`bold`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M216,48H40a12,12,0,0,0,0,24h4V208a20,20,0,0,0,20,20H192a20,20,0,0,0,20-20V72h4a12,12,0,0,0,0-24ZM188,204H68V72H188ZM76,20A12,12,0,0,1,88,8h80a12,12,0,0,1,0,24H88A12,12,0,0,1,76,20Z`}))],[`duotone`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M200,56V208a8,8,0,0,1-8,8H64a8,8,0,0,1-8-8V56Z`,opacity:`0.2`}),r.createElement(`path`,{d:`M216,48H40a8,8,0,0,0,0,16h8V208a16,16,0,0,0,16,16H192a16,16,0,0,0,16-16V64h8a8,8,0,0,0,0-16ZM192,208H64V64H192ZM80,24a8,8,0,0,1,8-8h80a8,8,0,0,1,0,16H88A8,8,0,0,1,80,24Z`}))],[`fill`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M224,56a8,8,0,0,1-8,8h-8V208a16,16,0,0,1-16,16H64a16,16,0,0,1-16-16V64H40a8,8,0,0,1,0-16H216A8,8,0,0,1,224,56ZM88,32h80a8,8,0,0,0,0-16H88a8,8,0,0,0,0,16Z`}))],[`light`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M216,50H40a6,6,0,0,0,0,12H50V208a14,14,0,0,0,14,14H192a14,14,0,0,0,14-14V62h10a6,6,0,0,0,0-12ZM194,208a2,2,0,0,1-2,2H64a2,2,0,0,1-2-2V62H194ZM82,24a6,6,0,0,1,6-6h80a6,6,0,0,1,0,12H88A6,6,0,0,1,82,24Z`}))],[`regular`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M216,48H40a8,8,0,0,0,0,16h8V208a16,16,0,0,0,16,16H192a16,16,0,0,0,16-16V64h8a8,8,0,0,0,0-16ZM192,208H64V64H192ZM80,24a8,8,0,0,1,8-8h80a8,8,0,0,1,0,16H88A8,8,0,0,1,80,24Z`}))],[`thin`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M216,52H40a4,4,0,0,0,0,8H52V208a12,12,0,0,0,12,12H192a12,12,0,0,0,12-12V60h12a4,4,0,0,0,0-8ZM196,208a4,4,0,0,1-4,4H64a4,4,0,0,1-4-4V60H196ZM84,24a4,4,0,0,1,4-4h80a4,4,0,0,1,0,8H88A4,4,0,0,1,84,24Z`}))]]),a=r.forwardRef((e,t)=>r.createElement(n,{ref:t,...e,weights:i}));a.displayName=`TrashSimpleIcon`;var o=a;export{o as t}; \ No newline at end of file +import{a as e,c as t}from"./shim-mfK0Rmj6.js";import{dt as n}from"./useI18n-BBOAnu2u.js";var r=t(e(),1),i=new Map([[`bold`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M216,48H40a12,12,0,0,0,0,24h4V208a20,20,0,0,0,20,20H192a20,20,0,0,0,20-20V72h4a12,12,0,0,0,0-24ZM188,204H68V72H188ZM76,20A12,12,0,0,1,88,8h80a12,12,0,0,1,0,24H88A12,12,0,0,1,76,20Z`}))],[`duotone`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M200,56V208a8,8,0,0,1-8,8H64a8,8,0,0,1-8-8V56Z`,opacity:`0.2`}),r.createElement(`path`,{d:`M216,48H40a8,8,0,0,0,0,16h8V208a16,16,0,0,0,16,16H192a16,16,0,0,0,16-16V64h8a8,8,0,0,0,0-16ZM192,208H64V64H192ZM80,24a8,8,0,0,1,8-8h80a8,8,0,0,1,0,16H88A8,8,0,0,1,80,24Z`}))],[`fill`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M224,56a8,8,0,0,1-8,8h-8V208a16,16,0,0,1-16,16H64a16,16,0,0,1-16-16V64H40a8,8,0,0,1,0-16H216A8,8,0,0,1,224,56ZM88,32h80a8,8,0,0,0,0-16H88a8,8,0,0,0,0,16Z`}))],[`light`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M216,50H40a6,6,0,0,0,0,12H50V208a14,14,0,0,0,14,14H192a14,14,0,0,0,14-14V62h10a6,6,0,0,0,0-12ZM194,208a2,2,0,0,1-2,2H64a2,2,0,0,1-2-2V62H194ZM82,24a6,6,0,0,1,6-6h80a6,6,0,0,1,0,12H88A6,6,0,0,1,82,24Z`}))],[`regular`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M216,48H40a8,8,0,0,0,0,16h8V208a16,16,0,0,0,16,16H192a16,16,0,0,0,16-16V64h8a8,8,0,0,0,0-16ZM192,208H64V64H192ZM80,24a8,8,0,0,1,8-8h80a8,8,0,0,1,0,16H88A8,8,0,0,1,80,24Z`}))],[`thin`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M216,52H40a4,4,0,0,0,0,8H52V208a12,12,0,0,0,12,12H192a12,12,0,0,0,12-12V60h12a4,4,0,0,0,0-8ZM196,208a4,4,0,0,1-4,4H64a4,4,0,0,1-4-4V60H196ZM84,24a4,4,0,0,1,4-4h80a4,4,0,0,1,0,8H88A4,4,0,0,1,84,24Z`}))]]),a=r.forwardRef((e,t)=>r.createElement(n,{ref:t,...e,weights:i}));a.displayName=`TrashSimpleIcon`;var o=a;export{o as t}; \ No newline at end of file diff --git a/internal/webui/static/assets/UpdateControls-exMtCvDY.js b/internal/webui/static/assets/UpdateControls-BMVq7AGm.js similarity index 68% rename from internal/webui/static/assets/UpdateControls-exMtCvDY.js rename to internal/webui/static/assets/UpdateControls-BMVq7AGm.js index 90daf322..622a3ea7 100644 --- a/internal/webui/static/assets/UpdateControls-exMtCvDY.js +++ b/internal/webui/static/assets/UpdateControls-BMVq7AGm.js @@ -1,4 +1,4 @@ -import{a as e,c as t,n}from"./shim-mfK0Rmj6.js";import{n as r,r as i}from"./useI18n-BSw4X3mq.js";import{Gt as a}from"./index-C8_qeOs_.js";var o=t(e(),1),s=/^(#{1,3})\s+(english|en|中文|chinese|zh|zh-cn|zh-hans)\s*$/i,c=/`([^`]+)`|\*\*([^*]+)\*\*|\[([^\]]+)\]\((https?:\/\/[^)\s]+)\)/g,l=new Set([`中文`,`chinese`,`zh`,`zh-cn`,`zh-hans`]),u=new Set([`english`,`en`]);function d(e,t){let n=e.trim().toLowerCase();return t===`zh`?l.has(n):u.has(n)}function f(e){let t=e.split(/\r?\n/),n=[];return t.forEach((e,t)=>{let r=s.exec(e.trim());r&&n.push({index:t,title:r[2]})}),n.length?n.map((e,r)=>{let i=e.index+1,a=r+1{let r=s.exec(e.trim());r&&n.push({index:t,title:r[2]})}),n.length?n.map((e,r)=>{let i=e.index+1,a=r+1d(e,t));return i?i[1].trim():r[0]?.[1]?.trim()||n}function m(e){let t=[],n=0;for(let r of e.matchAll(c)){let i=r.index??0;i>n&&t.push({type:`text`,value:e.slice(n,i)}),r[1]==null?r[2]==null?r[3]!=null&&r[4]!=null&&t.push({type:`link`,value:r[3],href:r[4]}):t.push({type:`strong`,value:r[2]}):t.push({type:`code`,value:r[1]}),n=i+r[0].length}return nm(e),[e]);return(0,_.jsx)(_.Fragment,{children:t.map((e,t)=>(0,_.jsx)(y,{node:e},`${e.type}-${t}`))})}function y({node:e}){return e.type===`code`?(0,_.jsx)(`code`,{children:e.value}):e.type===`strong`?(0,_.jsx)(`strong`,{children:e.value}):e.type===`link`?(0,_.jsx)(`a`,{href:e.href,target:`_blank`,rel:`noreferrer`,children:e.value}):e.value}function b({markdown:e,emptyLabel:t}){let n=(0,o.useMemo)(()=>g(e),[e]);return!e.trim()||!n.length?(0,_.jsx)(`p`,{className:`release-notes__empty`,children:t}):(0,_.jsx)(`div`,{className:`release-notes`,children:n.map((e,t)=>{if(e.type===`heading`){let n=e.level===2?`h3`:`h4`;return(0,_.jsx)(n,{children:(0,_.jsx)(v,{text:e.text})},`h-${t}`)}return e.type===`list`?(0,_.jsx)(`ul`,{children:e.items.map((e,n)=>(0,_.jsx)(`li`,{children:(0,_.jsx)(v,{text:e})},`i-${t}-${n}`))},`l-${t}`):(0,_.jsx)(`p`,{children:(0,_.jsx)(v,{text:e.text})},`p-${t}`)})})}function x({update:e}){let{t}=r(),{info:n,submitting:o,reloadIn:s,elapsed:c,readyToApply:l,busy:u,justUpdated:d,targetVersion:f,newerThanPrepared:p,updateStateText:m,canPrepare:h,canApply:g,canCancel:v,primaryLabel:y,statusHint:b,prepareUpdate:x,confirmUpdate:S,cancelPreparedUpdate:C}=e;return(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(`div`,{className:`grid overflow-hidden rounded-lg bg-surface-secondary sm:grid-cols-[1fr_auto_1fr]`,children:[(0,_.jsxs)(`div`,{className:`p-4`,children:[(0,_.jsx)(`div`,{className:`text-caption font-medium text-muted`,children:t(`currentVersion`)}),(0,_.jsx)(`div`,{className:`mono mt-2 text-section font-semibold`,children:n?.current_version||`—`})]}),(0,_.jsx)(`div`,{className:`hidden items-center border-x border-separator px-4 text-muted sm:flex`,children:(0,_.jsx)(a,{size:18})}),(0,_.jsxs)(`div`,{className:`border-t border-separator p-4 sm:border-t-0`,children:[(0,_.jsx)(`div`,{className:`text-caption font-medium text-muted`,children:t(`latestVersion`)}),(0,_.jsx)(`div`,{className:`mono mt-2 text-section font-semibold`,children:n?.next_version||`—`})]})]}),(0,_.jsxs)(`div`,{className:`mt-5 flex flex-wrap items-center justify-end gap-3`,children:[v?(0,_.jsx)(i,{size:`sm`,variant:`ghost`,isDisabled:o,onPress:()=>void C(),children:t(l?`discardPreparedImage`:`cancelUpdate`)}):null,(0,_.jsxs)(i,{isDisabled:!h&&!g||s!=null,isPending:o||u||s!=null,onPress:()=>void(g?S():x()),children:[(0,_.jsx)(a,{size:16}),y]})]}),!n?.agent?.available&&!u?(0,_.jsx)(`p`,{className:`mt-3 text-right text-caption text-muted`,children:t(`updateUnavailableHint`)}):null,n?.agent?.available&&!n.agent.staged_update&&!u?(0,_.jsx)(`p`,{className:`mt-3 text-right text-caption text-muted`,children:t(`updateLegacyOneShotHint`)}):null,l||u||s!=null||d?(0,_.jsxs)(`div`,{className:`mt-4 rounded-lg border px-3 py-3 border-separator bg-surface-secondary`,role:`status`,"aria-live":`polite`,children:[m?(0,_.jsxs)(`p`,{className:`text-caption font-medium text-foreground`,children:[m,f?` · ${f}`:``,c?` · ${t(`updateElapsed`,{seconds:c})}`:``]}):null,(0,_.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:b}),p?(0,_.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-warning`,children:t(`updateNewerReleaseHint`,{latest:n?.next_version||``})}):null,n?.update?.error||n?.agent?.error?(0,_.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-danger`,children:n?.update?.error||n?.agent?.error}):null]}):null]})}export{b as n,p as r,x as t}; \ No newline at end of file +`),n=[],r=0;for(;rm(e),[e]);return(0,_.jsx)(_.Fragment,{children:t.map((e,t)=>(0,_.jsx)(y,{node:e},`${e.type}-${t}`))})}function y({node:e}){return e.type===`code`?(0,_.jsx)(`code`,{children:e.value}):e.type===`strong`?(0,_.jsx)(`strong`,{children:e.value}):e.type===`link`?(0,_.jsx)(`a`,{href:e.href,target:`_blank`,rel:`noreferrer`,children:e.value}):e.value}function b({markdown:e,emptyLabel:t}){let n=(0,o.useMemo)(()=>g(e),[e]);return!e.trim()||!n.length?(0,_.jsx)(`p`,{className:`release-notes__empty`,children:t}):(0,_.jsx)(`div`,{className:`release-notes`,children:n.map((e,t)=>{if(e.type===`heading`){let n=e.level===2?`h3`:`h4`;return(0,_.jsx)(n,{children:(0,_.jsx)(v,{text:e.text})},`h-${t}`)}return e.type===`list`?(0,_.jsx)(`ul`,{children:e.items.map((e,n)=>(0,_.jsx)(`li`,{children:(0,_.jsx)(v,{text:e})},`i-${t}-${n}`))},`l-${t}`):(0,_.jsx)(`p`,{children:(0,_.jsx)(v,{text:e.text})},`p-${t}`)})})}function x({update:e}){let{t}=r(),{info:n,submitting:o,reloadIn:s,elapsed:c,readyToApply:l,busy:u,justUpdated:d,targetVersion:f,newerThanPrepared:p,updateStateText:m,canPrepare:h,canApply:g,canCancel:v,primaryLabel:y,statusHint:b,prepareUpdate:x,confirmUpdate:S,cancelPreparedUpdate:C}=e;return(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(`div`,{className:`grid overflow-hidden rounded-lg bg-surface-secondary sm:grid-cols-[1fr_auto_1fr]`,children:[(0,_.jsxs)(`div`,{className:`p-4`,children:[(0,_.jsx)(`div`,{className:`text-caption font-medium text-muted`,children:t(`currentVersion`)}),(0,_.jsx)(`div`,{className:`mono mt-2 text-section font-semibold`,children:n?.current_version||`—`})]}),(0,_.jsx)(`div`,{className:`hidden items-center border-x border-separator px-4 text-muted sm:flex`,children:(0,_.jsx)(a,{size:18})}),(0,_.jsxs)(`div`,{className:`border-t border-separator p-4 sm:border-t-0`,children:[(0,_.jsx)(`div`,{className:`text-caption font-medium text-muted`,children:t(`latestVersion`)}),(0,_.jsx)(`div`,{className:`mono mt-2 text-section font-semibold`,children:n?.next_version||(n?.has_update?`—`:n?.current_version)||`—`}),n?.managed&&!n?.has_update&&!u?(0,_.jsx)(`div`,{className:`mt-1 text-caption text-muted`,children:t(`upToDate`)}):null]})]}),(0,_.jsxs)(`div`,{className:`mt-5 flex flex-wrap items-center justify-end gap-3`,children:[v?(0,_.jsx)(i,{size:`sm`,variant:`ghost`,isDisabled:o,onPress:()=>void C(),children:t(l?`discardPreparedImage`:`cancelUpdate`)}):null,(0,_.jsxs)(i,{isDisabled:!h&&!g||s!=null,isPending:o||u||s!=null,onPress:()=>void(g?S():x()),children:[(0,_.jsx)(a,{size:16}),y]})]}),n?.source?(0,_.jsx)(`p`,{className:`mt-3 text-right text-caption text-muted`,children:t(`updateSourceHint`,{repo:n.source})}):null,!n?.agent?.available&&!u?(0,_.jsx)(`p`,{className:`mt-3 text-right text-caption text-muted`,children:t(`updateAgentMissingHint`)}):null,n?.agent?.available&&!n.agent.staged_update&&!u?(0,_.jsx)(`p`,{className:`mt-3 text-right text-caption text-muted`,children:t(`updateLegacyOneShotHint`)}):null,l||u||s!=null||d?(0,_.jsxs)(`div`,{className:`mt-4 rounded-lg border px-3 py-3 border-separator bg-surface-secondary`,role:`status`,"aria-live":`polite`,children:[m?(0,_.jsxs)(`p`,{className:`text-caption font-medium text-foreground`,children:[m,f?` · ${f}`:``,c?` · ${t(`updateElapsed`,{seconds:c})}`:``]}):null,(0,_.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:b}),p?(0,_.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-warning`,children:t(`updateNewerReleaseHint`,{latest:n?.next_version||``})}):null,n?.update?.error||n?.agent?.error?(0,_.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-danger`,children:n?.update?.error||n?.agent?.error}):null]}):null]})}export{b as n,p as r,x as t}; \ No newline at end of file diff --git a/internal/webui/static/assets/UsagePage-BgIYSNHT.js b/internal/webui/static/assets/UsagePage-BgIYSNHT.js new file mode 100644 index 00000000..9a078ecf --- /dev/null +++ b/internal/webui/static/assets/UsagePage-BgIYSNHT.js @@ -0,0 +1,2 @@ +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/CostChart-DOuzu6PW.js","assets/shim-mfK0Rmj6.js","assets/format-kRpr2wxA.js","assets/SharedElementTransition-BlCsXfb1.js","assets/useToggleState-DpzdeNPF.js","assets/index-B9eWF6SH.js","assets/useI18n-BBOAnu2u.js","assets/overview-CJvUvgoD.js","assets/gsap-C3sDxib7.js","assets/index-i4CFf7iO.css","assets/AreaChart-B0YOdVBx.js","assets/CartesianGrid-BJyfpdDb.js","assets/XAxis-DLQkFqxC.js"])))=>i.map(i=>d[i]); +import{a as e,c as t,n}from"./shim-mfK0Rmj6.js";import{dt as r,n as i,r as a}from"./useI18n-BBOAnu2u.js";import{s as o}from"./TimeRangePicker-CLtIDMZF.js";import{t as s}from"./accordion-B-CD5Nsb.js";import{t as c}from"./PageAlert-DZC7IhXp.js";import{n as l,t as u}from"./useApiKeyOptions-D6h0C_rA.js";import{t as d}from"./card-QlCdtlk0.js";import{t as f}from"./EmptyPanel-Bs-jQMvG.js";import{n as p,t as m}from"./tabs-CQ7Gr_Df.js";import{t as h}from"./table-D-oKYYsp.js";import{c as g,i as _,o as v,r as y,s as b,u as x}from"./format-kRpr2wxA.js";import{A as S,u as C}from"./overview-CJvUvgoD.js";import{$t as w,Ht as T,Kt as E,M as D,Qt as O,Wt as k,Zt as A,jt as ee,m as j}from"./index-B9eWF6SH.js";import{t as M}from"./FilterToggle-AieL1mQy.js";import{t as N}from"./ProviderMark-IiAZTaQS.js";import{t as P}from"./provider-gHnttGKq.js";import{a as F}from"./account-BJHim5bc.js";import{i as te,n as ne,r as re,t as ie}from"./logsLink-CEEottPg.js";var I=t(e(),1),ae=new Map([[`bold`,I.createElement(I.Fragment,null,I.createElement(`path`,{d:`M234.36,170A12,12,0,0,1,230,186.37l-96,56a12,12,0,0,1-12.1,0l-96-56a12,12,0,0,1,12.09-20.74l90,52.48L218,165.63A12,12,0,0,1,234.36,170ZM218,117.63,128,170.11,38.05,117.63A12,12,0,0,0,26,138.37l96,56a12,12,0,0,0,12.1,0l96-56A12,12,0,0,0,218,117.63ZM20,80a12,12,0,0,1,6-10.37l96-56a12.06,12.06,0,0,1,12.1,0l96,56a12,12,0,0,1,0,20.74l-96,56a12,12,0,0,1-12.1,0l-96-56A12,12,0,0,1,20,80Zm35.82,0L128,122.11,200.18,80,128,37.89Z`}))],[`duotone`,I.createElement(I.Fragment,null,I.createElement(`path`,{d:`M224,80l-96,56L32,80l96-56Z`,opacity:`0.2`}),I.createElement(`path`,{d:`M230.91,172A8,8,0,0,1,228,182.91l-96,56a8,8,0,0,1-8.06,0l-96-56A8,8,0,0,1,36,169.09l92,53.65,92-53.65A8,8,0,0,1,230.91,172ZM220,121.09l-92,53.65L36,121.09A8,8,0,0,0,28,134.91l96,56a8,8,0,0,0,8.06,0l96-56A8,8,0,1,0,220,121.09ZM24,80a8,8,0,0,1,4-6.91l96-56a8,8,0,0,1,8.06,0l96,56a8,8,0,0,1,0,13.82l-96,56a8,8,0,0,1-8.06,0l-96-56A8,8,0,0,1,24,80Zm23.88,0L128,126.74,208.12,80,128,33.26Z`}))],[`fill`,I.createElement(I.Fragment,null,I.createElement(`path`,{d:`M220,169.09l-92,53.65L36,169.09A8,8,0,0,0,28,182.91l96,56a8,8,0,0,0,8.06,0l96-56A8,8,0,1,0,220,169.09Z`}),I.createElement(`path`,{d:`M220,121.09l-92,53.65L36,121.09A8,8,0,0,0,28,134.91l96,56a8,8,0,0,0,8.06,0l96-56A8,8,0,1,0,220,121.09Z`}),I.createElement(`path`,{d:`M28,86.91l96,56a8,8,0,0,0,8.06,0l96-56a8,8,0,0,0,0-13.82l-96-56a8,8,0,0,0-8.06,0l-96,56a8,8,0,0,0,0,13.82Z`}))],[`light`,I.createElement(I.Fragment,null,I.createElement(`path`,{d:`M229.18,173a6,6,0,0,1-2.16,8.2l-96,56a6,6,0,0,1-6,0l-96-56a6,6,0,0,1,6-10.36l93,54.23,93-54.23A6,6,0,0,1,229.18,173ZM221,122.82l-93,54.23L35,122.82a6,6,0,0,0-6,10.36l96,56a6,6,0,0,0,6,0l96-56a6,6,0,0,0-6-10.36ZM26,80a6,6,0,0,1,3-5.18l96-56a6,6,0,0,1,6,0l96,56a6,6,0,0,1,0,10.36l-96,56a6,6,0,0,1-6,0l-96-56A6,6,0,0,1,26,80Zm17.91,0L128,129.05,212.09,80,128,31Z`}))],[`regular`,I.createElement(I.Fragment,null,I.createElement(`path`,{d:`M230.91,172A8,8,0,0,1,228,182.91l-96,56a8,8,0,0,1-8.06,0l-96-56A8,8,0,0,1,36,169.09l92,53.65,92-53.65A8,8,0,0,1,230.91,172ZM220,121.09l-92,53.65L36,121.09A8,8,0,0,0,28,134.91l96,56a8,8,0,0,0,8.06,0l96-56A8,8,0,1,0,220,121.09ZM24,80a8,8,0,0,1,4-6.91l96-56a8,8,0,0,1,8.06,0l96,56a8,8,0,0,1,0,13.82l-96,56a8,8,0,0,1-8.06,0l-96-56A8,8,0,0,1,24,80Zm23.88,0L128,126.74,208.12,80,128,33.26Z`}))],[`thin`,I.createElement(I.Fragment,null,I.createElement(`path`,{d:`M227.45,174a4,4,0,0,1-1.44,5.48l-96,56a4,4,0,0,1-4,0l-96-56a4,4,0,0,1,4-6.92l94,54.83,94-54.83A4,4,0,0,1,227.45,174ZM222,124.54l-94,54.83L34,124.54a4,4,0,0,0-4,6.92l96,56a4,4,0,0,0,4,0l96-56a4,4,0,0,0-4-6.92ZM28,80a4,4,0,0,1,2-3.46l96-56a4,4,0,0,1,4,0l96,56a4,4,0,0,1,0,6.92l-96,56a4,4,0,0,1-4,0l-96-56A4,4,0,0,1,28,80Zm11.94,0L128,131.37,216.06,80,128,28.63Z`}))]]),L=I.forwardRef((e,t)=>I.createElement(r,{ref:t,...e,weights:ae}));L.displayName=`StackIcon`;var oe=L,R=n(),z=864e5,se=8;function B(e){return`var(--chart-${e%se+1})`}function V(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime()}function H(e){return e<10?`0${e}`:String(e)}function U(e){let t=new Date(e);return`${t.getFullYear()}-${H(t.getMonth()+1)}-${H(t.getDate())}`}function ce({accounts:e,t}){let[n,r]=(0,I.useState)(!1),{buckets:i,rows:o,todayStart:s,maxTotal:c}=(0,I.useMemo)(()=>{let t=V(new Date),n=new Map;e.forEach((e,t)=>n.set(e.id,B(t)));let r=new Map,i=[];for(let a of e){let e=a.quota?.packages??[],o=n.get(a.id)||B(0),s=a.name||a.id,c=e.filter(e=>(e.remain??0)>0&&(e.ends_at??0)>0),l=0,u=0,d=0,f=0;for(let e of c){let n=e.ends_at*1e3,i=e.remain??0;d+=i;let c=V(new Date(n)),u=c{let e=new Date(c);return{day:p,label:`${e.getMonth()+1}/${e.getDate()}`,ts:c,segments:[],total:0}})(),r.set(p,m));let h=m.segments.find(e=>e.id===a.id);h?h.remain+=i:m.segments.push({id:a.id,name:s,color:o,remain:i}),m.total+=i}if(l){let e=U(V(new Date(l)));for(let t of c)U(V(new Date(t.ends_at*1e3)))===e&&(u+=t.remain??0)}let p=l?Math.max(0,Math.round((V(new Date(l))-t)/z)):-1;i.push({id:a.id,name:s,color:o,remain:d,expiredRemain:f,soonest:l?Math.floor(l/1e3):0,soonestRemain:u,daysLeft:p,dailyBurn:l?u/Math.max(p,1):0,packs:c.length})}i.sort((e,t)=>e.soonest&&t.soonest?e.soonest-t.soonest:e.soonest?-1:t.soonest?1:t.remain-e.remain);let a=[...r.values()].sort((e,t)=>e.ts-t.ts);return{buckets:a,rows:i,todayStart:t,maxTotal:a.reduce((e,t)=>Math.max(e,t.total),0)}},[e]);if(!o.some(e=>e.packs>0))return null;let l=n?i:i.slice(0,8);return(0,R.jsxs)(d,{className:`overflow-hidden p-0`,"data-gsap-reveal":!0,children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-3 border-b border-separator px-4 py-4 sm:flex-row sm:flex-wrap sm:items-center sm:justify-between sm:px-5`,children:[(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`h3`,{className:`font-semibold`,children:t(`expiryDistTitle`)}),(0,R.jsx)(`p`,{className:`mt-0.5 text-xs text-muted`,children:t(`expiryDistHint`)})]}),i.length>8?(0,R.jsx)(a,{size:`sm`,variant:`ghost`,onPress:()=>r(e=>!e),children:n?t(`expiryDistCollapse`):t(`expiryDistExpand`,{n:i.length})}):null]}),(0,R.jsxs)(`div`,{className:`space-y-4 p-4 sm:space-y-3 sm:p-5`,children:[(0,R.jsx)(`div`,{className:`space-y-2.5 sm:space-y-1.5`,children:l.map(e=>{let n=e.ts===s,r=c>0?e.total/c*100:0;return(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:grid sm:grid-cols-[52px_minmax(0,1fr)_auto] sm:items-center sm:gap-2`,children:[(0,R.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 sm:contents`,children:[(0,R.jsx)(`span`,{className:`mono text-caption ${e.day===`__expired__`?`font-semibold text-danger`:n?`font-semibold text-foreground`:`text-muted`}`,children:e.day===`__expired__`?t(`expiryDistExpired`):e.label}),(0,R.jsx)(`span`,{className:`mono text-caption text-foreground sm:hidden`,children:F(e.total)})]}),(0,R.jsx)(`div`,{className:`h-2.5 w-full rounded-full bg-surface-tertiary`,role:`img`,"aria-label":`${e.day} ${t(`expiryDistDayTotal`,{n:F(e.total)})}`,title:e.day,children:(0,R.jsx)(`div`,{className:`flex h-full items-stretch overflow-hidden rounded-full`,style:{width:`${r}%`},children:e.segments.map(t=>(0,R.jsx)(`span`,{style:{width:`${t.remain/e.total*100}%`,backgroundColor:t.color},title:`${t.name} · ${F(t.remain)}`},t.id))})}),(0,R.jsx)(`span`,{className:`mono hidden text-caption text-foreground sm:inline`,children:F(e.total)})]},e.day)})}),(0,R.jsx)(`div`,{className:`flex flex-wrap gap-x-3 gap-y-1.5 pt-1`,children:o.filter(e=>e.remain>0).map(e=>(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-caption text-muted`,children:[(0,R.jsx)(`i`,{className:`size-2 rounded-[3px]`,style:{backgroundColor:e.color}}),(0,R.jsx)(`span`,{className:`max-w-[120px] truncate`,children:e.name})]},e.id))}),(0,R.jsx)(`div`,{className:`divide-y divide-separator md:hidden`,children:o.filter(e=>e.packs>0).map(e=>{let n=e.daysLeft>=0&&e.daysLeft<=2,r=e.daysLeft>=0&&e.daysLeft<=7,i=e.soonest?new Date(e.soonest*1e3):null,a=e.expiredRemain>0&&e.daysLeft<0||n?`font-semibold text-danger`:r?`text-warning`:`text-muted`,o=e.daysLeft>=0?t(`expiryDistDays`,{n:e.daysLeft}):e.expiredRemain>0?t(`expiryDistExpired`):`—`;return(0,R.jsxs)(`article`,{className:`space-y-3 py-3.5`,children:[(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,R.jsx)(`i`,{className:`size-2 shrink-0 rounded-[3px]`,style:{backgroundColor:e.color}}),(0,R.jsx)(`span`,{className:`truncate text-body font-medium text-foreground`,children:e.name})]}),(0,R.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-4 gap-y-3`,children:[(0,R.jsxs)(`div`,{className:`space-y-1`,children:[(0,R.jsx)(`div`,{className:`text-caption text-muted`,children:t(`expiryDistColSoonest`)}),(0,R.jsx)(`div`,{className:`mono text-body text-muted`,children:i?`${i.getMonth()+1}/${i.getDate()}`:`—`})]}),(0,R.jsxs)(`div`,{className:`space-y-1`,children:[(0,R.jsx)(`div`,{className:`text-caption text-muted`,children:t(`expiryDistColDaysLeft`)}),(0,R.jsx)(`div`,{className:`mono text-body ${a}`,children:o})]}),(0,R.jsxs)(`div`,{className:`space-y-1`,children:[(0,R.jsx)(`div`,{className:`text-caption text-muted`,children:t(`expiryDistColBatch`)}),(0,R.jsx)(`div`,{className:`mono text-body text-foreground`,children:F(e.soonestRemain)})]}),(0,R.jsxs)(`div`,{className:`space-y-1`,children:[(0,R.jsx)(`div`,{className:`text-caption text-muted`,children:t(`expiryDistColDaily`)}),(0,R.jsx)(`div`,{className:`mono text-body text-foreground`,children:e.soonest?F(e.dailyBurn):`—`})]})]})]},e.id)})}),(0,R.jsx)(h,{"aria-label":t(`expiryDistTitle`),className:`hidden md:block`,children:(0,R.jsx)(h.ScrollContainer,{className:`min-w-0 overflow-x-auto`,children:(0,R.jsxs)(h.Content,{className:`min-w-[32rem]`,children:[(0,R.jsxs)(h.Header,{children:[(0,R.jsx)(h.Column,{isRowHeader:!0,children:t(`expiryDistColAccount`)}),(0,R.jsx)(h.Column,{children:(0,R.jsx)(`div`,{className:`text-center`,children:t(`expiryDistColSoonest`)})}),(0,R.jsx)(h.Column,{children:(0,R.jsx)(`div`,{className:`text-center`,children:t(`expiryDistColDaysLeft`)})}),(0,R.jsx)(h.Column,{children:(0,R.jsx)(`div`,{className:`text-center`,children:t(`expiryDistColBatch`)})}),(0,R.jsx)(h.Column,{children:(0,R.jsx)(`div`,{className:`text-center`,children:t(`expiryDistColDaily`)})})]}),(0,R.jsx)(h.Body,{children:o.filter(e=>e.packs>0).map(e=>{let n=e.daysLeft>=0&&e.daysLeft<=2,r=e.daysLeft>=0&&e.daysLeft<=7,i=e.soonest?new Date(e.soonest*1e3):null;return(0,R.jsxs)(h.Row,{children:[(0,R.jsx)(h.Cell,{children:(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,R.jsx)(`i`,{className:`size-2 shrink-0 rounded-[3px]`,style:{backgroundColor:e.color}}),(0,R.jsx)(`span`,{className:`max-w-[150px] truncate text-foreground`,children:e.name})]})}),(0,R.jsx)(h.Cell,{children:(0,R.jsx)(`div`,{className:`mono text-center text-muted`,children:i?`${i.getMonth()+1}/${i.getDate()}`:`—`})}),(0,R.jsx)(h.Cell,{children:(0,R.jsx)(`div`,{className:`mono text-center ${e.expiredRemain>0&&e.daysLeft<0||n?`font-semibold text-danger`:r?`text-warning`:`text-muted`}`,children:e.daysLeft>=0?t(`expiryDistDays`,{n:e.daysLeft}):e.expiredRemain>0?t(`expiryDistExpired`):`—`})}),(0,R.jsx)(h.Cell,{children:(0,R.jsx)(`div`,{className:`mono text-center text-foreground`,children:F(e.soonestRemain)})}),(0,R.jsx)(h.Cell,{children:(0,R.jsx)(`div`,{className:`mono text-center text-foreground`,children:e.soonest?F(e.dailyBurn):`—`})})]},e.id)})})]})})}),(0,R.jsx)(`p`,{className:`text-caption text-muted`,children:t(`expiryDistFoot`)})]})]})}function W(){return S(`/api/usage/pricing`)}function G(e={}){let t=new URLSearchParams;e.from&&t.set(`from`,e.from),e.to&&t.set(`to`,e.to),e.api_key&&t.set(`api_key`,e.api_key);let n=t.toString()?`?${t}`:``;return S(`/api/usage/cost${n}`)}var K=(0,I.lazy)(()=>w(()=>import(`./CostChart-DOuzu6PW.js`).then(e=>({default:e.CostChart})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12])));function q(){let e=new Date;return e.setHours(0,0,0,0),e.toISOString()}var J={window:{from:``,to:``,hours:24},currency:`CNY`,models:[],totals:{id:`total`,label:``,vendor:``,currency:`CNY`,requests:0,cache_hit:0,cache_miss:0,output:0,total_tokens:0,cost:0,cost_off_peak:0,cost_peak:0,peak_requests:0,credits:0,priced:!1},series:[]};function Y(e,t){if(!t)return`0%`;let n=e/t*100;return`${n>=10?n.toFixed(0):n.toFixed(1)}%`}function le({apiKeyFilter:e=``}){let{t,lang:n}=i(),[r,o]=(0,I.useState)(`today`),[l,u]=(0,I.useState)(`credits`),[p,m]=(0,I.useState)(null),[g,b]=(0,I.useState)(null),[S,C]=(0,I.useState)(!0),[w,T]=(0,I.useState)(``);(0,I.useEffect)(()=>{let e=!1;return W().then(t=>{e||b(t)}).catch(()=>{}),()=>{e=!0}},[]);let O=(0,I.useCallback)(async()=>{C(!0);try{let t=await G({...r===`all`?{}:r===`today`?{from:q()}:{from:new Date(Date.now()-Number(r)*3600*1e3).toISOString(),to:new Date().toISOString()},api_key:e||void 0});m(t),T(``)}catch(e){m(null),T(e instanceof Error?e.message:String(e))}finally{C(!1)}},[r,e]);(0,I.useEffect)(()=>{O()},[O]);let k=p??J,A=k.totals,ee=A.requests>0&&k.models.length>0,N=k.models.filter(e=>e.priced),P=A.cost>0,F=[{label:t(`usageCredits`),value:v(A.credits),detail:t(`usageCreditsHint`)},{label:t(`usageTotalTokens`),value:_(A.total_tokens),detail:`${_(A.cache_hit)} / ${_(A.cache_miss)} / ${_(A.output)} ${t(`usageTokenSplitNote`)}`},{label:t(`usageRequests`),value:String(A.requests),detail:t(`usageModelCount`,{count:k.models.length})},{label:t(`usageCacheHitRate`),value:Y(A.cache_hit,A.cache_hit+A.cache_miss),detail:_(A.cache_hit)}],te=l===`credits`?v(A.credits):l===`tokens`?_(A.total_tokens):y(A.cost);return(0,R.jsxs)(`div`,{className:`space-y-6`,children:[(0,R.jsxs)(`section`,{className:`flex flex-wrap items-center justify-end gap-3 pb-2`,children:[(0,R.jsx)(M,{value:r,onChange:e=>o(e),ariaLabel:t(`usageWindow`),options:[{id:`today`,label:t(`statsWindowToday`)},{id:`24`,label:t(`usageWindow24h`)},{id:`168`,label:t(`usageWindow7d`)},{id:`all`,label:t(`usageWindowTotal`)}]}),(0,R.jsxs)(a,{size:`sm`,variant:`secondary`,onPress:()=>void O(),isDisabled:S,children:[(0,R.jsx)(E,{size:14}),t(`refresh`)]})]}),w?(0,R.jsx)(c,{title:t(`failedStats`,{msg:w})}):null,(0,R.jsx)(`section`,{className:`grid gap-3 sm:grid-cols-2 sm:gap-4 xl:grid-cols-4`,children:F.map(e=>(0,R.jsxs)(d,{className:`gap-0 p-4`,children:[(0,R.jsx)(`div`,{className:`text-body text-muted`,children:e.label}),(0,R.jsx)(`div`,{className:`tabular mt-1.5 text-section font-semibold`,children:S?(0,R.jsx)(j,{className:`h-5 w-16`}):e.value}),(0,R.jsx)(`div`,{className:`mono mt-1 truncate text-caption text-muted`,children:S?(0,R.jsx)(j,{className:`h-3 w-24`}):e.detail||`\xA0`})]},e.label))}),(0,R.jsxs)(d,{className:`overflow-hidden p-0`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-b border-separator px-5 py-4`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h3`,{className:`font-semibold tracking-[-0.015em]`,children:t(`usageChartTitle`)}),(0,R.jsx)(`p`,{className:`mt-0.5 text-xs text-muted`,children:t(`usageChartHint`)})]}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,R.jsx)(M,{value:l,onChange:e=>u(e),ariaLabel:t(`usageChartMetric`),options:[{id:`credits`,label:t(`usageColCredits`)},{id:`tokens`,label:t(`usageColTokens`)}]}),(0,R.jsx)(D,{size:`sm`,variant:`soft`,color:`default`,children:te})]})]}),(0,R.jsx)(`div`,{className:`p-5`,children:S?(0,R.jsx)(`div`,{className:`grid h-72 place-items-center`,children:(0,R.jsx)(j,{className:`h-56 w-full`})}):ee?(0,R.jsx)(I.Suspense,{fallback:(0,R.jsx)(`div`,{className:`grid h-72 place-items-center`,children:(0,R.jsx)(j,{className:`h-56 w-full`})}),children:(0,R.jsx)(K,{series:k.series,models:k.models,lang:n,emptyLabel:t(`usageChartEmpty`),totalLabel:t(`usageTotals`),metric:l})}):(0,R.jsx)(f,{title:t(`usageEmpty`),hint:t(`usageRetentionHint`)})})]}),(0,R.jsxs)(d,{className:`overflow-hidden p-0`,children:[(0,R.jsx)(`div`,{className:`flex items-center justify-between gap-3 border-b border-separator px-5 py-4`,children:(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h3`,{className:`font-semibold tracking-[-0.015em]`,children:t(`usageBreakdownTitle`)}),(0,R.jsx)(`p`,{className:`mt-0.5 text-xs text-muted`,children:t(`usageBreakdownHint`)})]})}),S?(0,R.jsx)(`div`,{className:`space-y-3 p-5`,children:[0,1,2].map(e=>(0,R.jsx)(j,{className:`h-9 w-full`},e))}):ee?(0,R.jsx)(h,{children:(0,R.jsx)(h.ScrollContainer,{children:(0,R.jsxs)(h.Content,{"aria-label":t(`usageBreakdownTitle`),children:[(0,R.jsxs)(h.Header,{children:[(0,R.jsx)(h.Column,{isRowHeader:!0,children:t(`usageColModel`)}),(0,R.jsx)(h.Column,{children:t(`usageColRequests`)}),(0,R.jsx)(h.Column,{children:t(`usageColInputHit`)}),(0,R.jsx)(h.Column,{children:t(`usageColInputMiss`)}),(0,R.jsx)(h.Column,{children:t(`usageColOutput`)}),(0,R.jsx)(h.Column,{children:t(`usageColTokens`)}),(0,R.jsx)(h.Column,{children:t(`usageColCredits`)})]}),(0,R.jsxs)(h.Body,{children:[k.models.map(e=>(0,R.jsxs)(h.Row,{children:[(0,R.jsxs)(h.Cell,{children:[(0,R.jsx)(`div`,{className:`text-sm font-medium`,children:e.label}),(0,R.jsx)(`div`,{className:`mono mt-0.5 text-[10px] text-muted`,children:e.id})]}),(0,R.jsx)(h.Cell,{children:(0,R.jsx)(`span`,{className:`mono text-xs`,children:e.requests})}),(0,R.jsx)(h.Cell,{children:(0,R.jsx)(`span`,{className:`mono text-xs`,children:_(e.cache_hit)})}),(0,R.jsx)(h.Cell,{children:(0,R.jsx)(`span`,{className:`mono text-xs`,children:_(e.cache_miss)})}),(0,R.jsx)(h.Cell,{children:(0,R.jsx)(`span`,{className:`mono text-xs`,children:_(e.output)})}),(0,R.jsx)(h.Cell,{children:(0,R.jsx)(`span`,{className:`mono text-xs`,children:_(e.total_tokens)})}),(0,R.jsx)(h.Cell,{children:(0,R.jsx)(`span`,{className:`mono text-xs font-semibold`,children:v(e.credits)})})]},e.id)),(0,R.jsxs)(h.Row,{children:[(0,R.jsx)(h.Cell,{children:(0,R.jsx)(`span`,{className:`text-sm font-semibold`,children:t(`usageTotals`)})}),(0,R.jsx)(h.Cell,{children:(0,R.jsx)(`span`,{className:`mono text-xs font-semibold`,children:A.requests})}),(0,R.jsx)(h.Cell,{children:(0,R.jsx)(`span`,{className:`mono text-xs font-semibold`,children:_(A.cache_hit)})}),(0,R.jsx)(h.Cell,{children:(0,R.jsx)(`span`,{className:`mono text-xs font-semibold`,children:_(A.cache_miss)})}),(0,R.jsx)(h.Cell,{children:(0,R.jsx)(`span`,{className:`mono text-xs font-semibold`,children:_(A.output)})}),(0,R.jsx)(h.Cell,{children:(0,R.jsx)(`span`,{className:`mono text-xs font-semibold`,children:_(A.total_tokens)})}),(0,R.jsx)(h.Cell,{children:(0,R.jsx)(`span`,{className:`mono text-xs font-semibold`,children:v(A.credits)})})]})]})]})})}):(0,R.jsx)(f,{title:t(`usageEmpty`),hint:t(`usageRetentionHint`)})]}),(0,R.jsx)(s,{className:`rounded-xl bg-surface-secondary`,hideSeparator:!0,defaultExpandedKeys:[],children:(0,R.jsxs)(s.Item,{id:`deepseek-estimate`,children:[(0,R.jsx)(s.Heading,{children:(0,R.jsxs)(s.Trigger,{className:`items-center gap-3 px-5 py-4 text-left`,children:[(0,R.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(`span`,{className:`block font-semibold tracking-[-0.015em]`,children:t(`usageEstimateTitle`)}),(0,R.jsx)(`span`,{className:`mt-0.5 block text-xs text-muted`,children:t(`usageEstimateHint`)})]}),P?(0,R.jsx)(D,{size:`sm`,variant:`soft`,color:`default`,children:y(A.cost)}):null,(0,R.jsx)(s.Indicator,{})]})}),(0,R.jsx)(s.Panel,{children:(0,R.jsxs)(s.Body,{className:`space-y-5 px-5 pb-5`,children:[(0,R.jsx)(`p`,{className:`text-xs leading-6 text-muted`,children:t(`usageRenderNote`)}),P?(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,R.jsx)(`h4`,{className:`text-sm font-medium`,children:t(`usageEstimateChartTitle`)}),(0,R.jsx)(D,{size:`sm`,variant:`soft`,color:`default`,children:y(A.cost)})]}),(0,R.jsx)(I.Suspense,{fallback:(0,R.jsx)(j,{className:`h-56 w-full`}),children:(0,R.jsx)(K,{series:k.series,models:N.length?N:k.models,lang:n,emptyLabel:t(`usageEstimateChartEmpty`),totalLabel:t(`usageTotals`),metric:`cost`})})]}):null,N.length?(0,R.jsx)(h,{children:(0,R.jsx)(h.ScrollContainer,{children:(0,R.jsxs)(h.Content,{"aria-label":t(`usageEstimateTitle`),children:[(0,R.jsxs)(h.Header,{children:[(0,R.jsx)(h.Column,{isRowHeader:!0,children:t(`usageColModel`)}),(0,R.jsx)(h.Column,{children:t(`usageColSplit`)}),(0,R.jsx)(h.Column,{children:t(`usageColCost`)})]}),(0,R.jsxs)(h.Body,{children:[N.map(e=>(0,R.jsxs)(h.Row,{children:[(0,R.jsxs)(h.Cell,{children:[(0,R.jsx)(`div`,{className:`text-sm font-medium`,children:e.label}),(0,R.jsx)(`div`,{className:`mono mt-0.5 text-[10px] text-muted`,children:e.id})]}),(0,R.jsx)(h.Cell,{children:(0,R.jsxs)(`span`,{className:`mono text-xs text-muted`,children:[y(e.cost_peak),` / `,y(e.cost_off_peak)]})}),(0,R.jsx)(h.Cell,{children:(0,R.jsx)(`span`,{className:`mono text-sm font-semibold`,children:y(e.cost)})})]},e.id)),(0,R.jsxs)(h.Row,{children:[(0,R.jsx)(h.Cell,{children:(0,R.jsx)(`span`,{className:`text-sm font-semibold`,children:t(`usageTotals`)})}),(0,R.jsx)(h.Cell,{children:(0,R.jsxs)(`span`,{className:`mono text-xs text-muted`,children:[y(A.cost_peak),` / `,y(A.cost_off_peak)]})}),(0,R.jsx)(h.Cell,{children:(0,R.jsx)(`span`,{className:`mono text-sm font-semibold`,children:y(A.cost)})})]})]})]})})}):(0,R.jsx)(`p`,{className:`text-xs text-muted`,children:t(`usageEstimateChartEmpty`)}),(0,R.jsxs)(`div`,{className:`grid gap-5 xl:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h4`,{className:`mb-2 text-sm font-medium`,children:t(`usagePriceTitle`)}),(0,R.jsx)(`p`,{className:`mb-3 text-xs text-muted`,children:t(`usagePeakNote`)}),(0,R.jsxs)(`div`,{className:`divide-y divide-separator rounded-lg bg-background`,children:[(g?.models??[]).map(e=>(0,R.jsxs)(`div`,{className:`px-4 py-3`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,R.jsx)(`div`,{className:`text-sm font-medium`,children:e.label}),(0,R.jsx)(`span`,{className:`mono text-[10px] text-muted`,children:e.currency})]}),(0,R.jsx)(`div`,{className:`mono mt-1 text-[10px] text-muted`,children:e.id}),(0,R.jsxs)(`div`,{className:`mt-2 grid grid-cols-2 gap-2 text-[11px]`,children:[(0,R.jsxs)(`div`,{className:`rounded-lg bg-surface-secondary px-2.5 py-2`,children:[(0,R.jsx)(`div`,{className:`text-[10px] text-muted`,children:t(`usagePriceBandOff`)}),(0,R.jsxs)(`div`,{className:`mono mt-0.5`,children:[x(e.off_peak.cache_hit),` · `,x(e.off_peak.cache_miss),` · `,x(e.off_peak.output)]}),(0,R.jsxs)(`div`,{className:`mt-1 text-[9px] text-muted`,children:[t(`usagePriceHit`),` · `,t(`usagePriceMiss`),` · `,t(`usagePriceOutput`)]})]}),(0,R.jsxs)(`div`,{className:`rounded-lg bg-surface-secondary px-2.5 py-2`,children:[(0,R.jsx)(`div`,{className:`text-[10px] text-muted`,children:t(`usagePriceBandPeak`)}),(0,R.jsxs)(`div`,{className:`mono mt-0.5`,children:[x(e.peak.cache_hit),` · `,x(e.peak.cache_miss),` · `,x(e.peak.output)]}),(0,R.jsxs)(`div`,{className:`mt-1 text-[9px] text-muted`,children:[t(`usagePriceHit`),` · `,t(`usagePriceMiss`),` · `,t(`usagePriceOutput`)]})]})]})]},e.id)),g?.models?.length?null:(0,R.jsx)(`div`,{className:`px-4 py-6 text-sm text-muted`,children:t(`usageEmpty`)})]})]}),(0,R.jsxs)(`div`,{className:`space-y-3 text-xs leading-6 text-muted`,children:[(0,R.jsx)(`h4`,{className:`text-sm font-medium text-foreground`,children:t(`usageNoteTitle`)}),(0,R.jsx)(`p`,{children:t(`usageRetentionHint`)}),(0,R.jsx)(`p`,{children:t(`usagePeakNote`)}),k.unpriced?.length?(0,R.jsx)(`p`,{children:t(`usageUnpricedHint`,{models:k.unpriced.join(`, `)})}):null,g?.note?(0,R.jsx)(`p`,{className:`mono text-[10px]`,children:g.note}):null]})]})]})})]})})]})}var ue=500,X={model:`model`,account:`account`,provider:`provider`};function de(e,t,n){let r=e.prompt_tokens??0,i=e.completion_tokens??0,a=e.key===`(unknown)`||e.key===`(unassigned)`||!e.key;return{key:e.key,label:n,count:e.count,success:e.count?e.ok/e.count:0,p95:e.latency_p95_ms??null,tokens:r+i,prompt:r,completion:i,credits:e.credits??0,cache_write:e.cache_write_tokens??0,cache_read:e.cache_read_tokens??0,filter:a?void 0:{[X[t]]:e.key}}}function fe(e,t,n){let r=n===`ascending`?1:-1;return[...e].sort((e,n)=>{if(t===`label`)return r*e.label.localeCompare(n.label);let i=e[t],a=n[t];return i==null&&a==null?0:i==null?1:a==null?-1:r*(i-a)||e.label.localeCompare(n.label)})}function pe(e){return e?e>=1e3?_(e):String(Math.round(e*100)/100):`0`}function me(){let{t:e}=i(),t=A(),[n,r]=O(),[a,s]=(0,I.useState)(`stats`),[f,v]=(0,I.useState)(`model`),[y,x]=(0,I.useState)(`today`),[S,w]=(0,I.useState)(null),[E,D]=(0,I.useState)(null),[M,F]=(0,I.useState)(!0),[ae,L]=(0,I.useState)(``),[z,se]=(0,I.useState)([]),[B,V]=(0,I.useState)(`count`),[H,U]=(0,I.useState)(`descending`),[W,G]=(0,I.useState)(()=>new URLSearchParams(window.location.search).get(`api_key`)??``),{options:K}=u(),q=(0,I.useRef)(0),J=n.toString(),Y=(0,I.useRef)(J);(0,I.useEffect)(()=>{J!==Y.current&&(Y.current=J,G(new URLSearchParams(J).get(`api_key`)??``))},[J]);let X=W?`api_key=${encodeURIComponent(W)}`:``;(0,I.useEffect)(()=>{X!==Y.current&&(Y.current=X,r(X,{replace:!0}))},[X,r]),(0,I.useEffect)(()=>{let e=!1;return C(!1).then(t=>{e||se(t.data||[])}).catch(()=>{}),()=>{e=!0}},[]);let me=S?.start?.toString()??``,he=S?.end?.toString()??``;(0,I.useEffect)(()=>{let e=te(y,S);if(!e){F(!1);return}let t=++q.current;o({...e,dim:[f],limit:ue,api_key:W||void 0}).then(e=>{t===q.current&&(D(e),L(``))}).catch(e=>{t===q.current&&(D(null),L(e instanceof Error?e.message:String(e)))}).finally(()=>{t===q.current&&F(!1)})},[f,y,me,he,W]);let Z=(0,I.useMemo)(()=>{let t=new Map(z.map(e=>[e.id,e.name||e.id]));return fe(((f===`model`?E?.models:f===`account`?E?.accounts:E?.providers)??[]).map(n=>{let r=n.key===`(unknown)`?e(`statsUnknown`):n.key===`(unassigned)`?e(`statsUnassigned`):f===`account`?t.get(n.key)||n.key:f===`provider`?P(n.key,e):n.key;return de(n,f,r)}),B,H)},[E,f,z,B,H,e]),Q=E?.totals,$=E?.tokens;function ge(e){if(!E||!e.filter)return;let n={...e.filter,api_key:W||void 0};t(ie(n,E.window.from,E.window.to))}let _e=[{id:`label`,label:e(f===`model`?`logsColModel`:f===`account`?`logsColAccount`:`logsColProvider`)},{id:`count`,label:e(`usageColRequests`),numeric:!0},{id:`success`,label:e(`usageColSuccess`),numeric:!0},{id:`p95`,label:e(`statsLatencyP95`),numeric:!0},{id:`tokens`,label:e(`usageColTokens`),numeric:!0},{id:`cache_write`,label:e(`usageColCacheWrite`),numeric:!0},{id:`credits`,label:e(`usageColCredits`),numeric:!0}],ve=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`section`,{className:`flex flex-wrap items-center justify-end gap-3 pb-1`,children:(0,R.jsx)(ne,{value:y,onChange:x,custom:S,onCustomChange:w,onBusy:()=>F(!0),t:e})}),ae?(0,R.jsx)(c,{title:e(`failedStats`,{msg:ae})}):null,(0,R.jsx)(`section`,{className:`grid gap-3 sm:grid-cols-2 sm:gap-4 xl:grid-cols-5`,children:[[e(`usageColRequests`),Q?_(Q.requests):`—`,e(`statsWindowHint`,{window:e(re[y])})],[e(`usageColSuccess`),Q?g(Q.success_rate):`—`,Q?`${Q.ok} / ${Q.requests}`:``],[e(`usageColTokens`),$?_($.total):`—`,$?`${_($.prompt)} / ${_($.completion)}`:``],[e(`usageColCacheWrite`),$?_($.cache_write??0):`—`,$?`${e(`chartCacheRead`)} ${_($.cache_read)}`:``],[e(`usageColCredits`),Q?pe(Q.credits??0):`—`,``]].map(([e,t,n])=>(0,R.jsxs)(d,{className:`gap-0 p-4`,children:[(0,R.jsx)(`div`,{className:`text-body text-muted`,children:e}),(0,R.jsx)(`div`,{className:`tabular mt-1.5 text-section font-semibold`,children:M?(0,R.jsx)(j,{className:`h-5 w-16`}):t}),(0,R.jsx)(`div`,{className:`mono mt-1 truncate text-caption text-muted`,children:M?(0,R.jsx)(j,{className:`h-3 w-24`}):n||`\xA0`})]},e))}),(0,R.jsxs)(d,{className:`overflow-hidden p-0`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col gap-3 border-b border-separator px-5 py-3 sm:flex-row sm:flex-wrap sm:items-center sm:justify-between`,children:[(0,R.jsx)(m,{selectedKey:f,onSelectionChange:e=>{F(!0),v(String(e))},children:(0,R.jsx)(m.ListContainer,{className:`w-fit`,children:(0,R.jsxs)(m.List,{"aria-label":e(`usageTitle`),children:[(0,R.jsxs)(p,{id:`model`,className:`gap-1.5 whitespace-nowrap`,children:[(0,R.jsx)(m.Indicator,{className:`transition-none`}),(0,R.jsx)(T,{size:14}),e(`usageByModel`)]}),(0,R.jsxs)(p,{id:`account`,className:`gap-1.5 whitespace-nowrap`,children:[(0,R.jsx)(m.Indicator,{className:`transition-none`}),(0,R.jsx)(ee,{size:14}),e(`usageByAccount`)]}),(0,R.jsxs)(p,{id:`provider`,className:`gap-1.5 whitespace-nowrap`,children:[(0,R.jsx)(m.Indicator,{className:`transition-none`}),(0,R.jsx)(oe,{size:14}),e(`usageByProvider`)]})]})})}),(0,R.jsx)(`span`,{className:`mono text-caption text-muted`,children:M?``:e(`usageRowCount`,{count:Z.length})})]}),M?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`div`,{className:`divide-y divide-separator md:hidden`,"aria-busy":`true`,children:Array.from({length:4},(e,t)=>(0,R.jsxs)(`div`,{className:`space-y-3 px-5 py-4`,children:[(0,R.jsx)(j,{className:`h-4 w-40`}),(0,R.jsx)(`div`,{className:`grid grid-cols-2 gap-x-4 gap-y-3`,children:Array.from({length:4},(e,t)=>(0,R.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,R.jsx)(j,{className:`h-3 w-12`}),(0,R.jsx)(j,{className:`h-4 w-16`})]},t))})]},t))}),(0,R.jsx)(`div`,{className:`hidden divide-y divide-separator md:block`,"aria-busy":`true`,children:Array.from({length:6},(e,t)=>(0,R.jsxs)(`div`,{className:`flex items-center gap-6 px-5 py-3.5`,children:[(0,R.jsx)(j,{className:`h-4 w-40`}),(0,R.jsx)(`div`,{className:`flex-1`}),Array.from({length:6},(e,t)=>(0,R.jsx)(j,{className:`h-4 w-14`},t))]},t))})]}):Z.length===0?(0,R.jsxs)(`div`,{className:`flex items-center gap-2 px-5 py-10 text-body text-muted`,children:[(0,R.jsx)(k,{size:16}),e(`usageEmpty`)]}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`div`,{className:`divide-y divide-separator md:hidden`,children:Z.map(t=>{let n=!!(t.filter&&E),r=[{label:e(`usageColRequests`),value:String(t.count)},{label:e(`usageColSuccess`),value:g(t.success),tone:t.success<.9?`text-warning`:void 0},{label:e(`statsLatencyP95`),value:b(t.p95)},{label:e(`usageColTokens`),value:_(t.tokens),sub:`${_(t.prompt)} / ${_(t.completion)}`},{label:e(`usageColCacheWrite`),value:_(t.cache_write)},{label:e(`usageColCredits`),value:pe(t.credits)}];return(0,R.jsxs)(`article`,{className:`space-y-3 px-5 py-4 ${n?`cursor-pointer`:``}`,onClick:n?()=>ge(t):void 0,onKeyDown:n?e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),ge(t))}:void 0,role:n?`button`:void 0,tabIndex:n?0:void 0,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[f===`provider`&&t.filter?(0,R.jsx)(N,{provider:t.key,size:14}):null,(0,R.jsx)(`span`,{className:`truncate text-body font-medium`,children:t.label})]}),f===`account`&&t.label!==t.key?(0,R.jsx)(`div`,{className:`mono truncate text-caption text-muted`,children:t.key}):null,(0,R.jsx)(`div`,{className:`grid grid-cols-2 gap-x-4 gap-y-3`,children:r.map(e=>(0,R.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,R.jsx)(`div`,{className:`text-caption text-muted`,children:e.label}),(0,R.jsx)(`div`,{className:`mono text-body ${e.tone??`text-foreground`}`,children:e.value}),`sub`in e&&e.sub?(0,R.jsx)(`div`,{className:`mono text-caption text-muted`,children:e.sub}):null]},e.label))})]},t.key)})}),(0,R.jsx)(h,{className:`usage-table hidden md:block`,children:(0,R.jsx)(h.ScrollContainer,{className:`min-w-0 overflow-x-auto`,children:(0,R.jsxs)(h.Content,{"aria-label":e(`usageTitle`),className:`min-w-[48rem]`,sortDescriptor:{column:B,direction:H},onSortChange:e=>{V(String(e.column)),U(e.direction)},children:[(0,R.jsx)(h.Header,{children:_e.map(e=>(0,R.jsx)(h.Column,{id:e.id,allowsSorting:!0,isRowHeader:e.id===`label`,className:e.numeric?`text-right`:void 0,children:({sortDirection:t})=>(0,R.jsx)(h.SortableColumnHeader,{sortDirection:t,className:e.numeric?`justify-end`:void 0,children:e.label})},e.id))}),(0,R.jsx)(h.Body,{children:Z.map(e=>(0,R.jsxs)(h.Row,{id:e.key,className:e.filter&&E?`cursor-pointer`:void 0,onAction:e.filter&&E?()=>ge(e):void 0,children:[(0,R.jsx)(h.Cell,{children:(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[f===`provider`&&e.filter?(0,R.jsx)(N,{provider:e.key,size:14}):null,(0,R.jsx)(`span`,{className:`truncate text-body font-medium`,children:e.label}),f===`account`&&e.label!==e.key?(0,R.jsx)(`span`,{className:`mono truncate text-caption text-muted`,children:e.key}):null]})}),(0,R.jsx)(h.Cell,{className:`mono text-right text-body`,children:e.count}),(0,R.jsx)(h.Cell,{className:`mono text-right text-body`,children:(0,R.jsx)(`span`,{className:e.success<.9?`text-warning`:void 0,children:g(e.success)})}),(0,R.jsx)(h.Cell,{className:`mono text-right text-body`,children:b(e.p95)}),(0,R.jsxs)(h.Cell,{className:`text-right`,children:[(0,R.jsx)(`div`,{className:`mono text-body`,children:_(e.tokens)}),(0,R.jsxs)(`div`,{className:`mono text-caption text-muted`,children:[_(e.prompt),` / `,_(e.completion)]})]}),(0,R.jsx)(h.Cell,{className:`mono text-right text-body`,children:_(e.cache_write)}),(0,R.jsx)(h.Cell,{className:`mono text-right text-body`,children:pe(e.credits)})]},e.key))})]})})})]})]}),(0,R.jsx)(ce,{accounts:z,t:e})]});return(0,R.jsxs)(`div`,{className:`space-y-6 sm:space-y-6`,children:[(0,R.jsxs)(`section`,{className:`flex flex-wrap items-end justify-between gap-3 pb-1`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h2`,{className:`text-title font-semibold`,children:e(`usageTitle`)}),(0,R.jsx)(`p`,{className:`mt-1 max-w-2xl text-body leading-6 text-muted`,children:e(a===`cost`?`usageCostLead`:`usageLead`)})]}),(0,R.jsx)(l,{ariaLabel:e(`logsColApiKey`),value:W,onChange:e=>{F(!0),G(e)},options:K,allLabel:e(`logsFilterApiKeyAll`),searchPlaceholder:e(`logsSearchApiKey`),emptyLabel:e(`logsNoFilterOptions`)})]}),(0,R.jsxs)(m,{selectedKey:a,onSelectionChange:e=>s(String(e)),children:[(0,R.jsx)(m.ListContainer,{className:`w-fit`,children:(0,R.jsxs)(m.List,{"aria-label":e(`usageTitle`),children:[(0,R.jsxs)(p,{id:`stats`,className:`gap-1.5 whitespace-nowrap`,children:[(0,R.jsx)(m.Indicator,{className:`transition-none`}),e(`usageStatsTab`)]}),(0,R.jsxs)(p,{id:`cost`,className:`gap-1.5 whitespace-nowrap`,children:[(0,R.jsx)(m.Indicator,{className:`transition-none`}),e(`usageCostTab`)]})]})}),(0,R.jsx)(m.Panel,{id:`stats`,className:`space-y-6 pt-5`,children:ve}),(0,R.jsx)(m.Panel,{id:`cost`,className:`pt-5`,children:(0,R.jsx)(le,{apiKeyFilter:W})})]})]})}export{me as UsagePage}; \ No newline at end of file diff --git a/internal/webui/static/assets/UsagePage-CcoF9H7_.js b/internal/webui/static/assets/UsagePage-CcoF9H7_.js deleted file mode 100644 index e04768c0..00000000 --- a/internal/webui/static/assets/UsagePage-CcoF9H7_.js +++ /dev/null @@ -1,2 +0,0 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/CostChart-DMfp1L5p.js","assets/shim-mfK0Rmj6.js","assets/AreaChart-B0YOdVBx.js","assets/CartesianGrid-BJyfpdDb.js","assets/XAxis-DLQkFqxC.js","assets/format-B6SmebW-.js"])))=>i.map(i=>d[i]); -import{a as e,c as t,n}from"./shim-mfK0Rmj6.js";import{n as r,pt as i,r as a}from"./useI18n-BSw4X3mq.js";import{s as o}from"./TimeRangePicker-C118rt0G.js";import{t as s}from"./accordion-Bi_Adwlu.js";import{t as c}from"./PageAlert-CaDjxveS.js";import{n as l,t as u}from"./useApiKeyOptions-BUxE7IB2.js";import{n as d}from"./useToggle-HDaAPzVy.js";import{t as f}from"./EmptyPanel-Bs-jQMvG.js";import{n as p,t as m}from"./tabs-Cm-IDu6Q.js";import{t as h}from"./table-BE40Giyo.js";import{O as g,u as ee}from"./overview-m01k08K8.js";import{Bt as _,Ht as v,M as y,Wt as te,Xt as b,Yt as x,Zt as S,kt as C,m as w}from"./index-C8_qeOs_.js";import{t as T}from"./FilterToggle-16Av-HiR.js";import{c as E,i as D,o as O,r as k,s as A,u as j}from"./format-B6SmebW-.js";import{t as M}from"./ProviderMark-IiAZTaQS.js";import{t as N}from"./provider-gHnttGKq.js";import{a as P}from"./account-BJHim5bc.js";import{i as ne,n as re,r as ie,t as ae}from"./logsLink-iPK79PD2.js";var F=t(e(),1),oe=new Map([[`bold`,F.createElement(F.Fragment,null,F.createElement(`path`,{d:`M234.36,170A12,12,0,0,1,230,186.37l-96,56a12,12,0,0,1-12.1,0l-96-56a12,12,0,0,1,12.09-20.74l90,52.48L218,165.63A12,12,0,0,1,234.36,170ZM218,117.63,128,170.11,38.05,117.63A12,12,0,0,0,26,138.37l96,56a12,12,0,0,0,12.1,0l96-56A12,12,0,0,0,218,117.63ZM20,80a12,12,0,0,1,6-10.37l96-56a12.06,12.06,0,0,1,12.1,0l96,56a12,12,0,0,1,0,20.74l-96,56a12,12,0,0,1-12.1,0l-96-56A12,12,0,0,1,20,80Zm35.82,0L128,122.11,200.18,80,128,37.89Z`}))],[`duotone`,F.createElement(F.Fragment,null,F.createElement(`path`,{d:`M224,80l-96,56L32,80l96-56Z`,opacity:`0.2`}),F.createElement(`path`,{d:`M230.91,172A8,8,0,0,1,228,182.91l-96,56a8,8,0,0,1-8.06,0l-96-56A8,8,0,0,1,36,169.09l92,53.65,92-53.65A8,8,0,0,1,230.91,172ZM220,121.09l-92,53.65L36,121.09A8,8,0,0,0,28,134.91l96,56a8,8,0,0,0,8.06,0l96-56A8,8,0,1,0,220,121.09ZM24,80a8,8,0,0,1,4-6.91l96-56a8,8,0,0,1,8.06,0l96,56a8,8,0,0,1,0,13.82l-96,56a8,8,0,0,1-8.06,0l-96-56A8,8,0,0,1,24,80Zm23.88,0L128,126.74,208.12,80,128,33.26Z`}))],[`fill`,F.createElement(F.Fragment,null,F.createElement(`path`,{d:`M220,169.09l-92,53.65L36,169.09A8,8,0,0,0,28,182.91l96,56a8,8,0,0,0,8.06,0l96-56A8,8,0,1,0,220,169.09Z`}),F.createElement(`path`,{d:`M220,121.09l-92,53.65L36,121.09A8,8,0,0,0,28,134.91l96,56a8,8,0,0,0,8.06,0l96-56A8,8,0,1,0,220,121.09Z`}),F.createElement(`path`,{d:`M28,86.91l96,56a8,8,0,0,0,8.06,0l96-56a8,8,0,0,0,0-13.82l-96-56a8,8,0,0,0-8.06,0l-96,56a8,8,0,0,0,0,13.82Z`}))],[`light`,F.createElement(F.Fragment,null,F.createElement(`path`,{d:`M229.18,173a6,6,0,0,1-2.16,8.2l-96,56a6,6,0,0,1-6,0l-96-56a6,6,0,0,1,6-10.36l93,54.23,93-54.23A6,6,0,0,1,229.18,173ZM221,122.82l-93,54.23L35,122.82a6,6,0,0,0-6,10.36l96,56a6,6,0,0,0,6,0l96-56a6,6,0,0,0-6-10.36ZM26,80a6,6,0,0,1,3-5.18l96-56a6,6,0,0,1,6,0l96,56a6,6,0,0,1,0,10.36l-96,56a6,6,0,0,1-6,0l-96-56A6,6,0,0,1,26,80Zm17.91,0L128,129.05,212.09,80,128,31Z`}))],[`regular`,F.createElement(F.Fragment,null,F.createElement(`path`,{d:`M230.91,172A8,8,0,0,1,228,182.91l-96,56a8,8,0,0,1-8.06,0l-96-56A8,8,0,0,1,36,169.09l92,53.65,92-53.65A8,8,0,0,1,230.91,172ZM220,121.09l-92,53.65L36,121.09A8,8,0,0,0,28,134.91l96,56a8,8,0,0,0,8.06,0l96-56A8,8,0,1,0,220,121.09ZM24,80a8,8,0,0,1,4-6.91l96-56a8,8,0,0,1,8.06,0l96,56a8,8,0,0,1,0,13.82l-96,56a8,8,0,0,1-8.06,0l-96-56A8,8,0,0,1,24,80Zm23.88,0L128,126.74,208.12,80,128,33.26Z`}))],[`thin`,F.createElement(F.Fragment,null,F.createElement(`path`,{d:`M227.45,174a4,4,0,0,1-1.44,5.48l-96,56a4,4,0,0,1-4,0l-96-56a4,4,0,0,1,4-6.92l94,54.83,94-54.83A4,4,0,0,1,227.45,174ZM222,124.54l-94,54.83L34,124.54a4,4,0,0,0-4,6.92l96,56a4,4,0,0,0,4,0l96-56a4,4,0,0,0-4-6.92ZM28,80a4,4,0,0,1,2-3.46l96-56a4,4,0,0,1,4,0l96,56a4,4,0,0,1,0,6.92l-96,56a4,4,0,0,1-4,0l-96-56A4,4,0,0,1,28,80Zm11.94,0L128,131.37,216.06,80,128,28.63Z`}))]]),I=F.forwardRef((e,t)=>F.createElement(i,{ref:t,...e,weights:oe}));I.displayName=`StackIcon`;var se=I,L=n(),R=864e5,ce=8;function z(e){return`var(--chart-${e%ce+1})`}function B(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime()}function V(e){return e<10?`0${e}`:String(e)}function H(e){let t=new Date(e);return`${t.getFullYear()}-${V(t.getMonth()+1)}-${V(t.getDate())}`}function le({accounts:e,t}){let[n,r]=(0,F.useState)(!1),{buckets:i,rows:o,todayStart:s,maxTotal:c}=(0,F.useMemo)(()=>{let t=B(new Date),n=new Map;e.forEach((e,t)=>n.set(e.id,z(t)));let r=new Map,i=[];for(let a of e){let e=a.quota?.packages??[],o=n.get(a.id)||z(0),s=a.name||a.id,c=e.filter(e=>(e.remain??0)>0&&(e.ends_at??0)>0),l=0,u=0,d=0,f=0;for(let e of c){let n=e.ends_at*1e3,i=e.remain??0;d+=i;let c=B(new Date(n)),u=c{let e=new Date(c);return{day:p,label:`${e.getMonth()+1}/${e.getDate()}`,ts:c,segments:[],total:0}})(),r.set(p,m));let h=m.segments.find(e=>e.id===a.id);h?h.remain+=i:m.segments.push({id:a.id,name:s,color:o,remain:i}),m.total+=i}if(l){let e=H(B(new Date(l)));for(let t of c)H(B(new Date(t.ends_at*1e3)))===e&&(u+=t.remain??0)}let p=l?Math.max(0,Math.round((B(new Date(l))-t)/R)):-1;i.push({id:a.id,name:s,color:o,remain:d,expiredRemain:f,soonest:l?Math.floor(l/1e3):0,soonestRemain:u,daysLeft:p,dailyBurn:l?u/Math.max(p,1):0,packs:c.length})}i.sort((e,t)=>e.soonest&&t.soonest?e.soonest-t.soonest:e.soonest?-1:t.soonest?1:t.remain-e.remain);let a=[...r.values()].sort((e,t)=>e.ts-t.ts);return{buckets:a,rows:i,todayStart:t,maxTotal:a.reduce((e,t)=>Math.max(e,t.total),0)}},[e]);if(!o.some(e=>e.packs>0))return null;let l=n?i:i.slice(0,8);return(0,L.jsxs)(d,{className:`overflow-hidden p-0`,"data-gsap-reveal":!0,children:[(0,L.jsxs)(`div`,{className:`flex flex-col gap-3 border-b border-separator px-4 py-4 sm:flex-row sm:flex-wrap sm:items-center sm:justify-between sm:px-5`,children:[(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsx)(`h3`,{className:`font-semibold`,children:t(`expiryDistTitle`)}),(0,L.jsx)(`p`,{className:`mt-0.5 text-xs text-muted`,children:t(`expiryDistHint`)})]}),i.length>8?(0,L.jsx)(a,{size:`sm`,variant:`ghost`,onPress:()=>r(e=>!e),children:n?t(`expiryDistCollapse`):t(`expiryDistExpand`,{n:i.length})}):null]}),(0,L.jsxs)(`div`,{className:`space-y-4 p-4 sm:space-y-3 sm:p-5`,children:[(0,L.jsx)(`div`,{className:`space-y-2.5 sm:space-y-1.5`,children:l.map(e=>{let n=e.ts===s,r=c>0?e.total/c*100:0;return(0,L.jsxs)(`div`,{className:`flex flex-col gap-1.5 sm:grid sm:grid-cols-[52px_minmax(0,1fr)_auto] sm:items-center sm:gap-2`,children:[(0,L.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 sm:contents`,children:[(0,L.jsx)(`span`,{className:`mono text-caption ${e.day===`__expired__`?`font-semibold text-danger`:n?`font-semibold text-foreground`:`text-muted`}`,children:e.day===`__expired__`?t(`expiryDistExpired`):e.label}),(0,L.jsx)(`span`,{className:`mono text-caption text-foreground sm:hidden`,children:P(e.total)})]}),(0,L.jsx)(`div`,{className:`h-2.5 w-full rounded-full bg-surface-tertiary`,role:`img`,"aria-label":`${e.day} ${t(`expiryDistDayTotal`,{n:P(e.total)})}`,title:e.day,children:(0,L.jsx)(`div`,{className:`flex h-full items-stretch overflow-hidden rounded-full`,style:{width:`${r}%`},children:e.segments.map(t=>(0,L.jsx)(`span`,{style:{width:`${t.remain/e.total*100}%`,backgroundColor:t.color},title:`${t.name} · ${P(t.remain)}`},t.id))})}),(0,L.jsx)(`span`,{className:`mono hidden text-caption text-foreground sm:inline`,children:P(e.total)})]},e.day)})}),(0,L.jsx)(`div`,{className:`flex flex-wrap gap-x-3 gap-y-1.5 pt-1`,children:o.filter(e=>e.remain>0).map(e=>(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-caption text-muted`,children:[(0,L.jsx)(`i`,{className:`size-2 rounded-[3px]`,style:{backgroundColor:e.color}}),(0,L.jsx)(`span`,{className:`max-w-[120px] truncate`,children:e.name})]},e.id))}),(0,L.jsx)(`div`,{className:`divide-y divide-separator md:hidden`,children:o.filter(e=>e.packs>0).map(e=>{let n=e.daysLeft>=0&&e.daysLeft<=2,r=e.daysLeft>=0&&e.daysLeft<=7,i=e.soonest?new Date(e.soonest*1e3):null,a=e.expiredRemain>0&&e.daysLeft<0||n?`font-semibold text-danger`:r?`text-warning`:`text-muted`,o=e.daysLeft>=0?t(`expiryDistDays`,{n:e.daysLeft}):e.expiredRemain>0?t(`expiryDistExpired`):`—`;return(0,L.jsxs)(`article`,{className:`space-y-3 py-3.5`,children:[(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,L.jsx)(`i`,{className:`size-2 shrink-0 rounded-[3px]`,style:{backgroundColor:e.color}}),(0,L.jsx)(`span`,{className:`truncate text-body font-medium text-foreground`,children:e.name})]}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-4 gap-y-3`,children:[(0,L.jsxs)(`div`,{className:`space-y-1`,children:[(0,L.jsx)(`div`,{className:`text-caption text-muted`,children:t(`expiryDistColSoonest`)}),(0,L.jsx)(`div`,{className:`mono text-body text-muted`,children:i?`${i.getMonth()+1}/${i.getDate()}`:`—`})]}),(0,L.jsxs)(`div`,{className:`space-y-1`,children:[(0,L.jsx)(`div`,{className:`text-caption text-muted`,children:t(`expiryDistColDaysLeft`)}),(0,L.jsx)(`div`,{className:`mono text-body ${a}`,children:o})]}),(0,L.jsxs)(`div`,{className:`space-y-1`,children:[(0,L.jsx)(`div`,{className:`text-caption text-muted`,children:t(`expiryDistColBatch`)}),(0,L.jsx)(`div`,{className:`mono text-body text-foreground`,children:P(e.soonestRemain)})]}),(0,L.jsxs)(`div`,{className:`space-y-1`,children:[(0,L.jsx)(`div`,{className:`text-caption text-muted`,children:t(`expiryDistColDaily`)}),(0,L.jsx)(`div`,{className:`mono text-body text-foreground`,children:e.soonest?P(e.dailyBurn):`—`})]})]})]},e.id)})}),(0,L.jsx)(h,{"aria-label":t(`expiryDistTitle`),className:`hidden md:block`,children:(0,L.jsx)(h.ScrollContainer,{className:`min-w-0 overflow-x-auto`,children:(0,L.jsxs)(h.Content,{className:`min-w-[32rem]`,children:[(0,L.jsxs)(h.Header,{children:[(0,L.jsx)(h.Column,{isRowHeader:!0,children:t(`expiryDistColAccount`)}),(0,L.jsx)(h.Column,{children:(0,L.jsx)(`div`,{className:`text-center`,children:t(`expiryDistColSoonest`)})}),(0,L.jsx)(h.Column,{children:(0,L.jsx)(`div`,{className:`text-center`,children:t(`expiryDistColDaysLeft`)})}),(0,L.jsx)(h.Column,{children:(0,L.jsx)(`div`,{className:`text-center`,children:t(`expiryDistColBatch`)})}),(0,L.jsx)(h.Column,{children:(0,L.jsx)(`div`,{className:`text-center`,children:t(`expiryDistColDaily`)})})]}),(0,L.jsx)(h.Body,{children:o.filter(e=>e.packs>0).map(e=>{let n=e.daysLeft>=0&&e.daysLeft<=2,r=e.daysLeft>=0&&e.daysLeft<=7,i=e.soonest?new Date(e.soonest*1e3):null;return(0,L.jsxs)(h.Row,{children:[(0,L.jsx)(h.Cell,{children:(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,L.jsx)(`i`,{className:`size-2 shrink-0 rounded-[3px]`,style:{backgroundColor:e.color}}),(0,L.jsx)(`span`,{className:`max-w-[150px] truncate text-foreground`,children:e.name})]})}),(0,L.jsx)(h.Cell,{children:(0,L.jsx)(`div`,{className:`mono text-center text-muted`,children:i?`${i.getMonth()+1}/${i.getDate()}`:`—`})}),(0,L.jsx)(h.Cell,{children:(0,L.jsx)(`div`,{className:`mono text-center ${e.expiredRemain>0&&e.daysLeft<0||n?`font-semibold text-danger`:r?`text-warning`:`text-muted`}`,children:e.daysLeft>=0?t(`expiryDistDays`,{n:e.daysLeft}):e.expiredRemain>0?t(`expiryDistExpired`):`—`})}),(0,L.jsx)(h.Cell,{children:(0,L.jsx)(`div`,{className:`mono text-center text-foreground`,children:P(e.soonestRemain)})}),(0,L.jsx)(h.Cell,{children:(0,L.jsx)(`div`,{className:`mono text-center text-foreground`,children:e.soonest?P(e.dailyBurn):`—`})})]},e.id)})})]})})}),(0,L.jsx)(`p`,{className:`text-caption text-muted`,children:t(`expiryDistFoot`)})]})]})}function U(){return g(`/api/usage/pricing`)}function W(e={}){let t=new URLSearchParams;e.from&&t.set(`from`,e.from),e.to&&t.set(`to`,e.to),e.api_key&&t.set(`api_key`,e.api_key);let n=t.toString()?`?${t}`:``;return g(`/api/usage/cost${n}`)}var G=(0,F.lazy)(()=>S(()=>import(`./CostChart-DMfp1L5p.js`).then(e=>({default:e.CostChart})),__vite__mapDeps([0,1,2,3,4,5])));function K(){let e=new Date;return e.setHours(0,0,0,0),e.toISOString()}var q={window:{from:``,to:``,hours:24},currency:`CNY`,models:[],totals:{id:`total`,label:``,vendor:``,currency:`CNY`,requests:0,cache_hit:0,cache_miss:0,output:0,total_tokens:0,cost:0,cost_off_peak:0,cost_peak:0,peak_requests:0,credits:0,priced:!1},series:[]};function J(e,t){if(!t)return`0%`;let n=e/t*100;return`${n>=10?n.toFixed(0):n.toFixed(1)}%`}function ue({apiKeyFilter:e=``}){let{t,lang:n}=r(),[i,o]=(0,F.useState)(`today`),[l,u]=(0,F.useState)(`credits`),[p,m]=(0,F.useState)(null),[g,ee]=(0,F.useState)(null),[_,v]=(0,F.useState)(!0),[b,x]=(0,F.useState)(``);(0,F.useEffect)(()=>{let e=!1;return U().then(t=>{e||ee(t)}).catch(()=>{}),()=>{e=!0}},[]);let S=(0,F.useCallback)(async()=>{v(!0);try{let t=await W({...i===`all`?{}:i===`today`?{from:K()}:{from:new Date(Date.now()-Number(i)*3600*1e3).toISOString(),to:new Date().toISOString()},api_key:e||void 0});m(t),x(``)}catch(e){m(null),x(e instanceof Error?e.message:String(e))}finally{v(!1)}},[i,e]);(0,F.useEffect)(()=>{S()},[S]);let C=p??q,E=C.totals,A=E.requests>0&&C.models.length>0,M=C.models.filter(e=>e.priced),N=E.cost>0,P=[{label:t(`usageCredits`),value:O(E.credits),detail:t(`usageCreditsHint`)},{label:t(`usageTotalTokens`),value:D(E.total_tokens),detail:`${D(E.cache_hit)} / ${D(E.cache_miss)} / ${D(E.output)} ${t(`usageTokenSplitNote`)}`},{label:t(`usageRequests`),value:String(E.requests),detail:t(`usageModelCount`,{count:C.models.length})},{label:t(`usageCacheHitRate`),value:J(E.cache_hit,E.cache_hit+E.cache_miss),detail:D(E.cache_hit)}],ne=l===`credits`?O(E.credits):l===`tokens`?D(E.total_tokens):k(E.cost);return(0,L.jsxs)(`div`,{className:`space-y-6`,children:[(0,L.jsxs)(`section`,{className:`flex flex-wrap items-center justify-end gap-3 pb-2`,children:[(0,L.jsx)(T,{value:i,onChange:e=>o(e),ariaLabel:t(`usageWindow`),options:[{id:`today`,label:t(`statsWindowToday`)},{id:`24`,label:t(`usageWindow24h`)},{id:`168`,label:t(`usageWindow7d`)},{id:`all`,label:t(`usageWindowTotal`)}]}),(0,L.jsxs)(a,{size:`sm`,variant:`secondary`,onPress:()=>void S(),isDisabled:_,children:[(0,L.jsx)(te,{size:14}),t(`refresh`)]})]}),b?(0,L.jsx)(c,{title:t(`failedStats`,{msg:b})}):null,(0,L.jsx)(`section`,{className:`grid gap-3 sm:grid-cols-2 sm:gap-4 xl:grid-cols-4`,children:P.map(e=>(0,L.jsxs)(d,{className:`gap-0 p-4`,children:[(0,L.jsx)(`div`,{className:`text-body text-muted`,children:e.label}),(0,L.jsx)(`div`,{className:`tabular mt-1.5 text-section font-semibold`,children:_?(0,L.jsx)(w,{className:`h-5 w-16`}):e.value}),(0,L.jsx)(`div`,{className:`mono mt-1 truncate text-caption text-muted`,children:_?(0,L.jsx)(w,{className:`h-3 w-24`}):e.detail||`\xA0`})]},e.label))}),(0,L.jsxs)(d,{className:`overflow-hidden p-0`,children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-b border-separator px-5 py-4`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h3`,{className:`font-semibold tracking-[-0.015em]`,children:t(`usageChartTitle`)}),(0,L.jsx)(`p`,{className:`mt-0.5 text-xs text-muted`,children:t(`usageChartHint`)})]}),(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,L.jsx)(T,{value:l,onChange:e=>u(e),ariaLabel:t(`usageChartMetric`),options:[{id:`credits`,label:t(`usageColCredits`)},{id:`tokens`,label:t(`usageColTokens`)}]}),(0,L.jsx)(y,{size:`sm`,variant:`soft`,color:`default`,children:ne})]})]}),(0,L.jsx)(`div`,{className:`p-5`,children:_?(0,L.jsx)(`div`,{className:`grid h-72 place-items-center`,children:(0,L.jsx)(w,{className:`h-56 w-full`})}):A?(0,L.jsx)(F.Suspense,{fallback:(0,L.jsx)(`div`,{className:`grid h-72 place-items-center`,children:(0,L.jsx)(w,{className:`h-56 w-full`})}),children:(0,L.jsx)(G,{series:C.series,models:C.models,lang:n,emptyLabel:t(`usageChartEmpty`),totalLabel:t(`usageTotals`),metric:l})}):(0,L.jsx)(f,{title:t(`usageEmpty`),hint:t(`usageRetentionHint`)})})]}),(0,L.jsxs)(d,{className:`overflow-hidden p-0`,children:[(0,L.jsx)(`div`,{className:`flex items-center justify-between gap-3 border-b border-separator px-5 py-4`,children:(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h3`,{className:`font-semibold tracking-[-0.015em]`,children:t(`usageBreakdownTitle`)}),(0,L.jsx)(`p`,{className:`mt-0.5 text-xs text-muted`,children:t(`usageBreakdownHint`)})]})}),_?(0,L.jsx)(`div`,{className:`space-y-3 p-5`,children:[0,1,2].map(e=>(0,L.jsx)(w,{className:`h-9 w-full`},e))}):A?(0,L.jsx)(h,{children:(0,L.jsx)(h.ScrollContainer,{children:(0,L.jsxs)(h.Content,{"aria-label":t(`usageBreakdownTitle`),children:[(0,L.jsxs)(h.Header,{children:[(0,L.jsx)(h.Column,{isRowHeader:!0,children:t(`usageColModel`)}),(0,L.jsx)(h.Column,{children:t(`usageColRequests`)}),(0,L.jsx)(h.Column,{children:t(`usageColInputHit`)}),(0,L.jsx)(h.Column,{children:t(`usageColInputMiss`)}),(0,L.jsx)(h.Column,{children:t(`usageColOutput`)}),(0,L.jsx)(h.Column,{children:t(`usageColTokens`)}),(0,L.jsx)(h.Column,{children:t(`usageColCredits`)})]}),(0,L.jsxs)(h.Body,{children:[C.models.map(e=>(0,L.jsxs)(h.Row,{children:[(0,L.jsxs)(h.Cell,{children:[(0,L.jsx)(`div`,{className:`text-sm font-medium`,children:e.label}),(0,L.jsx)(`div`,{className:`mono mt-0.5 text-[10px] text-muted`,children:e.id})]}),(0,L.jsx)(h.Cell,{children:(0,L.jsx)(`span`,{className:`mono text-xs`,children:e.requests})}),(0,L.jsx)(h.Cell,{children:(0,L.jsx)(`span`,{className:`mono text-xs`,children:D(e.cache_hit)})}),(0,L.jsx)(h.Cell,{children:(0,L.jsx)(`span`,{className:`mono text-xs`,children:D(e.cache_miss)})}),(0,L.jsx)(h.Cell,{children:(0,L.jsx)(`span`,{className:`mono text-xs`,children:D(e.output)})}),(0,L.jsx)(h.Cell,{children:(0,L.jsx)(`span`,{className:`mono text-xs`,children:D(e.total_tokens)})}),(0,L.jsx)(h.Cell,{children:(0,L.jsx)(`span`,{className:`mono text-xs font-semibold`,children:O(e.credits)})})]},e.id)),(0,L.jsxs)(h.Row,{children:[(0,L.jsx)(h.Cell,{children:(0,L.jsx)(`span`,{className:`text-sm font-semibold`,children:t(`usageTotals`)})}),(0,L.jsx)(h.Cell,{children:(0,L.jsx)(`span`,{className:`mono text-xs font-semibold`,children:E.requests})}),(0,L.jsx)(h.Cell,{children:(0,L.jsx)(`span`,{className:`mono text-xs font-semibold`,children:D(E.cache_hit)})}),(0,L.jsx)(h.Cell,{children:(0,L.jsx)(`span`,{className:`mono text-xs font-semibold`,children:D(E.cache_miss)})}),(0,L.jsx)(h.Cell,{children:(0,L.jsx)(`span`,{className:`mono text-xs font-semibold`,children:D(E.output)})}),(0,L.jsx)(h.Cell,{children:(0,L.jsx)(`span`,{className:`mono text-xs font-semibold`,children:D(E.total_tokens)})}),(0,L.jsx)(h.Cell,{children:(0,L.jsx)(`span`,{className:`mono text-xs font-semibold`,children:O(E.credits)})})]})]})]})})}):(0,L.jsx)(f,{title:t(`usageEmpty`),hint:t(`usageRetentionHint`)})]}),(0,L.jsx)(s,{className:`rounded-xl bg-surface-secondary`,hideSeparator:!0,defaultExpandedKeys:[],children:(0,L.jsxs)(s.Item,{id:`deepseek-estimate`,children:[(0,L.jsx)(s.Heading,{children:(0,L.jsxs)(s.Trigger,{className:`items-center gap-3 px-5 py-4 text-left`,children:[(0,L.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(`span`,{className:`block font-semibold tracking-[-0.015em]`,children:t(`usageEstimateTitle`)}),(0,L.jsx)(`span`,{className:`mt-0.5 block text-xs text-muted`,children:t(`usageEstimateHint`)})]}),N?(0,L.jsx)(y,{size:`sm`,variant:`soft`,color:`default`,children:k(E.cost)}):null,(0,L.jsx)(s.Indicator,{})]})}),(0,L.jsx)(s.Panel,{children:(0,L.jsxs)(s.Body,{className:`space-y-5 px-5 pb-5`,children:[(0,L.jsx)(`p`,{className:`text-xs leading-6 text-muted`,children:t(`usageRenderNote`)}),N?(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,L.jsx)(`h4`,{className:`text-sm font-medium`,children:t(`usageEstimateChartTitle`)}),(0,L.jsx)(y,{size:`sm`,variant:`soft`,color:`default`,children:k(E.cost)})]}),(0,L.jsx)(F.Suspense,{fallback:(0,L.jsx)(w,{className:`h-56 w-full`}),children:(0,L.jsx)(G,{series:C.series,models:M.length?M:C.models,lang:n,emptyLabel:t(`usageEstimateChartEmpty`),totalLabel:t(`usageTotals`),metric:`cost`})})]}):null,M.length?(0,L.jsx)(h,{children:(0,L.jsx)(h.ScrollContainer,{children:(0,L.jsxs)(h.Content,{"aria-label":t(`usageEstimateTitle`),children:[(0,L.jsxs)(h.Header,{children:[(0,L.jsx)(h.Column,{isRowHeader:!0,children:t(`usageColModel`)}),(0,L.jsx)(h.Column,{children:t(`usageColSplit`)}),(0,L.jsx)(h.Column,{children:t(`usageColCost`)})]}),(0,L.jsxs)(h.Body,{children:[M.map(e=>(0,L.jsxs)(h.Row,{children:[(0,L.jsxs)(h.Cell,{children:[(0,L.jsx)(`div`,{className:`text-sm font-medium`,children:e.label}),(0,L.jsx)(`div`,{className:`mono mt-0.5 text-[10px] text-muted`,children:e.id})]}),(0,L.jsx)(h.Cell,{children:(0,L.jsxs)(`span`,{className:`mono text-xs text-muted`,children:[k(e.cost_peak),` / `,k(e.cost_off_peak)]})}),(0,L.jsx)(h.Cell,{children:(0,L.jsx)(`span`,{className:`mono text-sm font-semibold`,children:k(e.cost)})})]},e.id)),(0,L.jsxs)(h.Row,{children:[(0,L.jsx)(h.Cell,{children:(0,L.jsx)(`span`,{className:`text-sm font-semibold`,children:t(`usageTotals`)})}),(0,L.jsx)(h.Cell,{children:(0,L.jsxs)(`span`,{className:`mono text-xs text-muted`,children:[k(E.cost_peak),` / `,k(E.cost_off_peak)]})}),(0,L.jsx)(h.Cell,{children:(0,L.jsx)(`span`,{className:`mono text-sm font-semibold`,children:k(E.cost)})})]})]})]})})}):(0,L.jsx)(`p`,{className:`text-xs text-muted`,children:t(`usageEstimateChartEmpty`)}),(0,L.jsxs)(`div`,{className:`grid gap-5 xl:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h4`,{className:`mb-2 text-sm font-medium`,children:t(`usagePriceTitle`)}),(0,L.jsx)(`p`,{className:`mb-3 text-xs text-muted`,children:t(`usagePeakNote`)}),(0,L.jsxs)(`div`,{className:`divide-y divide-separator rounded-lg bg-background`,children:[(g?.models??[]).map(e=>(0,L.jsxs)(`div`,{className:`px-4 py-3`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,L.jsx)(`div`,{className:`text-sm font-medium`,children:e.label}),(0,L.jsx)(`span`,{className:`mono text-[10px] text-muted`,children:e.currency})]}),(0,L.jsx)(`div`,{className:`mono mt-1 text-[10px] text-muted`,children:e.id}),(0,L.jsxs)(`div`,{className:`mt-2 grid grid-cols-2 gap-2 text-[11px]`,children:[(0,L.jsxs)(`div`,{className:`rounded-lg bg-surface-secondary px-2.5 py-2`,children:[(0,L.jsx)(`div`,{className:`text-[10px] text-muted`,children:t(`usagePriceBandOff`)}),(0,L.jsxs)(`div`,{className:`mono mt-0.5`,children:[j(e.off_peak.cache_hit),` · `,j(e.off_peak.cache_miss),` · `,j(e.off_peak.output)]}),(0,L.jsxs)(`div`,{className:`mt-1 text-[9px] text-muted`,children:[t(`usagePriceHit`),` · `,t(`usagePriceMiss`),` · `,t(`usagePriceOutput`)]})]}),(0,L.jsxs)(`div`,{className:`rounded-lg bg-surface-secondary px-2.5 py-2`,children:[(0,L.jsx)(`div`,{className:`text-[10px] text-muted`,children:t(`usagePriceBandPeak`)}),(0,L.jsxs)(`div`,{className:`mono mt-0.5`,children:[j(e.peak.cache_hit),` · `,j(e.peak.cache_miss),` · `,j(e.peak.output)]}),(0,L.jsxs)(`div`,{className:`mt-1 text-[9px] text-muted`,children:[t(`usagePriceHit`),` · `,t(`usagePriceMiss`),` · `,t(`usagePriceOutput`)]})]})]})]},e.id)),g?.models?.length?null:(0,L.jsx)(`div`,{className:`px-4 py-6 text-sm text-muted`,children:t(`usageEmpty`)})]})]}),(0,L.jsxs)(`div`,{className:`space-y-3 text-xs leading-6 text-muted`,children:[(0,L.jsx)(`h4`,{className:`text-sm font-medium text-foreground`,children:t(`usageNoteTitle`)}),(0,L.jsx)(`p`,{children:t(`usageRetentionHint`)}),(0,L.jsx)(`p`,{children:t(`usagePeakNote`)}),C.unpriced?.length?(0,L.jsx)(`p`,{children:t(`usageUnpricedHint`,{models:C.unpriced.join(`, `)})}):null,g?.note?(0,L.jsx)(`p`,{className:`mono text-[10px]`,children:g.note}):null]})]})]})})]})})]})}var de=500,Y={model:`model`,account:`account`,provider:`provider`};function fe(e,t,n){let r=e.prompt_tokens??0,i=e.completion_tokens??0,a=e.key===`(unknown)`||e.key===`(unassigned)`||!e.key;return{key:e.key,label:n,count:e.count,success:e.count?e.ok/e.count:0,p95:e.latency_p95_ms??null,tokens:r+i,prompt:r,completion:i,credits:e.credits??0,cache_write:e.cache_write_tokens??0,cache_read:e.cache_read_tokens??0,filter:a?void 0:{[Y[t]]:e.key}}}function pe(e,t,n){let r=n===`ascending`?1:-1;return[...e].sort((e,n)=>{if(t===`label`)return r*e.label.localeCompare(n.label);let i=e[t],a=n[t];return i==null&&a==null?0:i==null?1:a==null?-1:r*(i-a)||e.label.localeCompare(n.label)})}function X(e){return e?e>=1e3?D(e):String(Math.round(e*100)/100):`0`}function me(){let{t:e}=r(),t=x(),[n,i]=b(),[a,s]=(0,F.useState)(`stats`),[f,g]=(0,F.useState)(`model`),[y,te]=(0,F.useState)(`today`),[S,T]=(0,F.useState)(null),[O,k]=(0,F.useState)(null),[j,P]=(0,F.useState)(!0),[oe,I]=(0,F.useState)(``),[R,ce]=(0,F.useState)([]),[z,B]=(0,F.useState)(`count`),[V,H]=(0,F.useState)(`descending`),[U,W]=(0,F.useState)(()=>new URLSearchParams(window.location.search).get(`api_key`)??``),{options:G}=u(),K=(0,F.useRef)(0),q=n.toString(),J=(0,F.useRef)(q);(0,F.useEffect)(()=>{q!==J.current&&(J.current=q,W(new URLSearchParams(q).get(`api_key`)??``))},[q]);let Y=U?`api_key=${encodeURIComponent(U)}`:``;(0,F.useEffect)(()=>{Y!==J.current&&(J.current=Y,i(Y,{replace:!0}))},[Y,i]),(0,F.useEffect)(()=>{let e=!1;return ee(!1).then(t=>{e||ce(t.data||[])}).catch(()=>{}),()=>{e=!0}},[]);let me=S?.start?.toString()??``,he=S?.end?.toString()??``;(0,F.useEffect)(()=>{let e=ne(y,S);if(!e){P(!1);return}let t=++K.current;o({...e,dim:[f],limit:de,api_key:U||void 0}).then(e=>{t===K.current&&(k(e),I(``))}).catch(e=>{t===K.current&&(k(null),I(e instanceof Error?e.message:String(e)))}).finally(()=>{t===K.current&&P(!1)})},[f,y,me,he,U]);let Z=(0,F.useMemo)(()=>{let t=new Map(R.map(e=>[e.id,e.name||e.id]));return pe(((f===`model`?O?.models:f===`account`?O?.accounts:O?.providers)??[]).map(n=>{let r=n.key===`(unknown)`?e(`statsUnknown`):n.key===`(unassigned)`?e(`statsUnassigned`):f===`account`?t.get(n.key)||n.key:f===`provider`?N(n.key,e):n.key;return fe(n,f,r)}),z,V)},[O,f,R,z,V,e]),Q=O?.totals,$=O?.tokens;function ge(e){if(!O||!e.filter)return;let n={...e.filter,api_key:U||void 0};t(ae(n,O.window.from,O.window.to))}let _e=[{id:`label`,label:e(f===`model`?`logsColModel`:f===`account`?`logsColAccount`:`logsColProvider`)},{id:`count`,label:e(`usageColRequests`),numeric:!0},{id:`success`,label:e(`usageColSuccess`),numeric:!0},{id:`p95`,label:e(`statsLatencyP95`),numeric:!0},{id:`tokens`,label:e(`usageColTokens`),numeric:!0},{id:`cache_write`,label:e(`usageColCacheWrite`),numeric:!0},{id:`credits`,label:e(`usageColCredits`),numeric:!0}],ve=(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`section`,{className:`flex flex-wrap items-center justify-end gap-3 pb-1`,children:(0,L.jsx)(re,{value:y,onChange:te,custom:S,onCustomChange:T,onBusy:()=>P(!0),t:e})}),oe?(0,L.jsx)(c,{title:e(`failedStats`,{msg:oe})}):null,(0,L.jsx)(`section`,{className:`grid gap-3 sm:grid-cols-2 sm:gap-4 xl:grid-cols-5`,children:[[e(`usageColRequests`),Q?D(Q.requests):`—`,e(`statsWindowHint`,{window:e(ie[y])})],[e(`usageColSuccess`),Q?E(Q.success_rate):`—`,Q?`${Q.ok} / ${Q.requests}`:``],[e(`usageColTokens`),$?D($.total):`—`,$?`${D($.prompt)} / ${D($.completion)}`:``],[e(`usageColCacheWrite`),$?D($.cache_write??0):`—`,$?`${e(`chartCacheRead`)} ${D($.cache_read)}`:``],[e(`usageColCredits`),Q?X(Q.credits??0):`—`,``]].map(([e,t,n])=>(0,L.jsxs)(d,{className:`gap-0 p-4`,children:[(0,L.jsx)(`div`,{className:`text-body text-muted`,children:e}),(0,L.jsx)(`div`,{className:`tabular mt-1.5 text-section font-semibold`,children:j?(0,L.jsx)(w,{className:`h-5 w-16`}):t}),(0,L.jsx)(`div`,{className:`mono mt-1 truncate text-caption text-muted`,children:j?(0,L.jsx)(w,{className:`h-3 w-24`}):n||`\xA0`})]},e))}),(0,L.jsxs)(d,{className:`overflow-hidden p-0`,children:[(0,L.jsxs)(`div`,{className:`flex flex-col gap-3 border-b border-separator px-5 py-3 sm:flex-row sm:flex-wrap sm:items-center sm:justify-between`,children:[(0,L.jsx)(m,{selectedKey:f,onSelectionChange:e=>{P(!0),g(String(e))},children:(0,L.jsx)(m.ListContainer,{className:`w-fit`,children:(0,L.jsxs)(m.List,{"aria-label":e(`usageTitle`),children:[(0,L.jsxs)(p,{id:`model`,className:`gap-1.5 whitespace-nowrap`,children:[(0,L.jsx)(m.Indicator,{className:`transition-none`}),(0,L.jsx)(_,{size:14}),e(`usageByModel`)]}),(0,L.jsxs)(p,{id:`account`,className:`gap-1.5 whitespace-nowrap`,children:[(0,L.jsx)(m.Indicator,{className:`transition-none`}),(0,L.jsx)(C,{size:14}),e(`usageByAccount`)]}),(0,L.jsxs)(p,{id:`provider`,className:`gap-1.5 whitespace-nowrap`,children:[(0,L.jsx)(m.Indicator,{className:`transition-none`}),(0,L.jsx)(se,{size:14}),e(`usageByProvider`)]})]})})}),(0,L.jsx)(`span`,{className:`mono text-caption text-muted`,children:j?``:e(`usageRowCount`,{count:Z.length})})]}),j?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`div`,{className:`divide-y divide-separator md:hidden`,"aria-busy":`true`,children:Array.from({length:4},(e,t)=>(0,L.jsxs)(`div`,{className:`space-y-3 px-5 py-4`,children:[(0,L.jsx)(w,{className:`h-4 w-40`}),(0,L.jsx)(`div`,{className:`grid grid-cols-2 gap-x-4 gap-y-3`,children:Array.from({length:4},(e,t)=>(0,L.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,L.jsx)(w,{className:`h-3 w-12`}),(0,L.jsx)(w,{className:`h-4 w-16`})]},t))})]},t))}),(0,L.jsx)(`div`,{className:`hidden divide-y divide-separator md:block`,"aria-busy":`true`,children:Array.from({length:6},(e,t)=>(0,L.jsxs)(`div`,{className:`flex items-center gap-6 px-5 py-3.5`,children:[(0,L.jsx)(w,{className:`h-4 w-40`}),(0,L.jsx)(`div`,{className:`flex-1`}),Array.from({length:6},(e,t)=>(0,L.jsx)(w,{className:`h-4 w-14`},t))]},t))})]}):Z.length===0?(0,L.jsxs)(`div`,{className:`flex items-center gap-2 px-5 py-10 text-body text-muted`,children:[(0,L.jsx)(v,{size:16}),e(`usageEmpty`)]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`div`,{className:`divide-y divide-separator md:hidden`,children:Z.map(t=>{let n=!!(t.filter&&O),r=[{label:e(`usageColRequests`),value:String(t.count)},{label:e(`usageColSuccess`),value:E(t.success),tone:t.success<.9?`text-warning`:void 0},{label:e(`statsLatencyP95`),value:A(t.p95)},{label:e(`usageColTokens`),value:D(t.tokens),sub:`${D(t.prompt)} / ${D(t.completion)}`},{label:e(`usageColCacheWrite`),value:D(t.cache_write)},{label:e(`usageColCredits`),value:X(t.credits)}];return(0,L.jsxs)(`article`,{className:`space-y-3 px-5 py-4 ${n?`cursor-pointer`:``}`,onClick:n?()=>ge(t):void 0,onKeyDown:n?e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),ge(t))}:void 0,role:n?`button`:void 0,tabIndex:n?0:void 0,children:[(0,L.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[f===`provider`&&t.filter?(0,L.jsx)(M,{provider:t.key,size:14}):null,(0,L.jsx)(`span`,{className:`truncate text-body font-medium`,children:t.label})]}),f===`account`&&t.label!==t.key?(0,L.jsx)(`div`,{className:`mono truncate text-caption text-muted`,children:t.key}):null,(0,L.jsx)(`div`,{className:`grid grid-cols-2 gap-x-4 gap-y-3`,children:r.map(e=>(0,L.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,L.jsx)(`div`,{className:`text-caption text-muted`,children:e.label}),(0,L.jsx)(`div`,{className:`mono text-body ${e.tone??`text-foreground`}`,children:e.value}),`sub`in e&&e.sub?(0,L.jsx)(`div`,{className:`mono text-caption text-muted`,children:e.sub}):null]},e.label))})]},t.key)})}),(0,L.jsx)(h,{className:`usage-table hidden md:block`,children:(0,L.jsx)(h.ScrollContainer,{className:`min-w-0 overflow-x-auto`,children:(0,L.jsxs)(h.Content,{"aria-label":e(`usageTitle`),className:`min-w-[48rem]`,sortDescriptor:{column:z,direction:V},onSortChange:e=>{B(String(e.column)),H(e.direction)},children:[(0,L.jsx)(h.Header,{children:_e.map(e=>(0,L.jsx)(h.Column,{id:e.id,allowsSorting:!0,isRowHeader:e.id===`label`,className:e.numeric?`text-right`:void 0,children:({sortDirection:t})=>(0,L.jsx)(h.SortableColumnHeader,{sortDirection:t,className:e.numeric?`justify-end`:void 0,children:e.label})},e.id))}),(0,L.jsx)(h.Body,{children:Z.map(e=>(0,L.jsxs)(h.Row,{id:e.key,className:e.filter&&O?`cursor-pointer`:void 0,onAction:e.filter&&O?()=>ge(e):void 0,children:[(0,L.jsx)(h.Cell,{children:(0,L.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[f===`provider`&&e.filter?(0,L.jsx)(M,{provider:e.key,size:14}):null,(0,L.jsx)(`span`,{className:`truncate text-body font-medium`,children:e.label}),f===`account`&&e.label!==e.key?(0,L.jsx)(`span`,{className:`mono truncate text-caption text-muted`,children:e.key}):null]})}),(0,L.jsx)(h.Cell,{className:`mono text-right text-body`,children:e.count}),(0,L.jsx)(h.Cell,{className:`mono text-right text-body`,children:(0,L.jsx)(`span`,{className:e.success<.9?`text-warning`:void 0,children:E(e.success)})}),(0,L.jsx)(h.Cell,{className:`mono text-right text-body`,children:A(e.p95)}),(0,L.jsxs)(h.Cell,{className:`text-right`,children:[(0,L.jsx)(`div`,{className:`mono text-body`,children:D(e.tokens)}),(0,L.jsxs)(`div`,{className:`mono text-caption text-muted`,children:[D(e.prompt),` / `,D(e.completion)]})]}),(0,L.jsx)(h.Cell,{className:`mono text-right text-body`,children:D(e.cache_write)}),(0,L.jsx)(h.Cell,{className:`mono text-right text-body`,children:X(e.credits)})]},e.key))})]})})})]})]}),(0,L.jsx)(le,{accounts:R,t:e})]});return(0,L.jsxs)(`div`,{className:`space-y-6 sm:space-y-6`,children:[(0,L.jsxs)(`section`,{className:`flex flex-wrap items-end justify-between gap-3 pb-1`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h2`,{className:`text-title font-semibold`,children:e(`usageTitle`)}),(0,L.jsx)(`p`,{className:`mt-1 max-w-2xl text-body leading-6 text-muted`,children:e(a===`cost`?`usageCostLead`:`usageLead`)})]}),(0,L.jsx)(l,{ariaLabel:e(`logsColApiKey`),value:U,onChange:e=>{P(!0),W(e)},options:G,allLabel:e(`logsFilterApiKeyAll`),searchPlaceholder:e(`logsSearchApiKey`),emptyLabel:e(`logsNoFilterOptions`)})]}),(0,L.jsxs)(m,{selectedKey:a,onSelectionChange:e=>s(String(e)),children:[(0,L.jsx)(m.ListContainer,{className:`w-fit`,children:(0,L.jsxs)(m.List,{"aria-label":e(`usageTitle`),children:[(0,L.jsxs)(p,{id:`stats`,className:`gap-1.5 whitespace-nowrap`,children:[(0,L.jsx)(m.Indicator,{className:`transition-none`}),e(`usageStatsTab`)]}),(0,L.jsxs)(p,{id:`cost`,className:`gap-1.5 whitespace-nowrap`,children:[(0,L.jsx)(m.Indicator,{className:`transition-none`}),e(`usageCostTab`)]})]})}),(0,L.jsx)(m.Panel,{id:`stats`,className:`space-y-6 pt-5`,children:ve}),(0,L.jsx)(m.Panel,{id:`cost`,className:`pt-5`,children:(0,L.jsx)(ue,{apiKeyFilter:U})})]})]})}export{me as UsagePage}; \ No newline at end of file diff --git a/internal/webui/static/assets/accordion-Bi_Adwlu.js b/internal/webui/static/assets/accordion-B-CD5Nsb.js similarity index 86% rename from internal/webui/static/assets/accordion-Bi_Adwlu.js rename to internal/webui/static/assets/accordion-B-CD5Nsb.js index e934b4c9..c9987cfc 100644 --- a/internal/webui/static/assets/accordion-Bi_Adwlu.js +++ b/internal/webui/static/assets/accordion-B-CD5Nsb.js @@ -1 +1 @@ -import{a as e,c as t,i as n,n as r}from"./shim-mfK0Rmj6.js";import{B as i,I as a,X as o,Z as s,ot as c}from"./useI18n-BSw4X3mq.js";import{A as l,B as u,F as d,J as f,M as p,P as m,Y as h,c as g,d as _,dt as v,j as y,l as b,lt as x,q as S,s as C,ut as w,z as T}from"./SharedElementTransition-BlCsXfb1.js";import{t as E}from"./assertion-BLQtDfw6.js";import{xt as D}from"./index-C8_qeOs_.js";var O=T({slots:{base:`accordion`,body:`accordion__body`,bodyInner:`accordion__body-inner`,heading:`accordion__heading`,indicator:`accordion__indicator`,item:`accordion__item`,panel:`accordion__panel`,trigger:`accordion__trigger`},variants:{variant:{default:{},surface:{base:`accordion--surface`}}}}),k=t(n(),1),A=t(e(),1);function j(e,t,n){let{isDisabled:r}=e,i=x(),a=x(),o=w(),s=(0,A.useRef)(null),l=(0,A.useCallback)(()=>{s.current=requestAnimationFrame(()=>{n.current&&n.current.setAttribute(`hidden`,`until-found`)}),(0,k.flushSync)(()=>{t.toggle()})},[n,t]);c(n,`beforematch`,l);let u=(0,A.useRef)(null);return v(()=>{if(s.current&&cancelAnimationFrame(s.current),n.current&&!o){let e=n.current;u.current==null||typeof e.getAnimations!=`function`?t.isExpanded?(e.removeAttribute(`hidden`),e.style.setProperty(`--disclosure-panel-width`,`auto`),e.style.setProperty(`--disclosure-panel-height`,`auto`)):(e.setAttribute(`hidden`,`until-found`),e.style.setProperty(`--disclosure-panel-width`,`0px`),e.style.setProperty(`--disclosure-panel-height`,`0px`)):t.isExpanded!==u.current&&(t.isExpanded?(e.removeAttribute(`hidden`),e.style.setProperty(`--disclosure-panel-width`,e.scrollWidth+`px`),e.style.setProperty(`--disclosure-panel-height`,e.scrollHeight+`px`),Promise.all(e.getAnimations().map(e=>e.finished)).then(()=>{e.style.setProperty(`--disclosure-panel-width`,`auto`),e.style.setProperty(`--disclosure-panel-height`,`auto`)}).catch(()=>{})):(e.style.setProperty(`--disclosure-panel-width`,e.scrollWidth+`px`),e.style.setProperty(`--disclosure-panel-height`,e.scrollHeight+`px`),window.getComputedStyle(e).height,e.style.setProperty(`--disclosure-panel-width`,`0px`),e.style.setProperty(`--disclosure-panel-height`,`0px`),Promise.all(e.getAnimations().map(e=>e.finished)).then(()=>e.setAttribute(`hidden`,`until-found`)).catch(()=>{}))),u.current=t.isExpanded}},[r,n,t.isExpanded,o]),(0,A.useEffect)(()=>()=>{s.current&&cancelAnimationFrame(s.current)},[]),{buttonProps:{id:i,"aria-expanded":t.isExpanded,"aria-controls":a,onPress:e=>{!r&&e.pointerType!==`keyboard`&&t.toggle()},isDisabled:r,onPressStart(e){e.pointerType===`keyboard`&&!r&&t.toggle()}},panelProps:{id:a,role:`group`,"aria-labelledby":i,"aria-hidden":!t.isExpanded,hidden:o?!t.isExpanded:void 0}}}function M(e){let{allowsMultipleExpanded:t=!1,isDisabled:n=!1}=e,[r,i]=b((0,A.useMemo)(()=>e.expandedKeys?new Set(e.expandedKeys):void 0,[e.expandedKeys]),(0,A.useMemo)(()=>e.defaultExpandedKeys?new Set(e.defaultExpandedKeys):new Set,[e.defaultExpandedKeys]),e.onExpandedChange);return(0,A.useEffect)(()=>{if(!t&&r.size>1){let e=r.values().next().value;e!=null&&i(new Set([e]))}}),{allowsMultipleExpanded:t,isDisabled:n,expandedKeys:r,setExpandedKeys:i,toggleKey(e){let n;t?(n=new Set(r),n.has(e)?n.delete(e):n.add(e)):n=new Set(r.has(e)?[]:[e]),i(n)}}}function N(e){let[t,n]=b(e.isExpanded,e.defaultExpanded||!1,e.onExpandedChange);return{isExpanded:t,setExpanded:n,expand:(0,A.useCallback)(()=>{n(!0)},[n]),collapse:(0,A.useCallback)(()=>{n(!1)},[n]),toggle:(0,A.useCallback)(()=>{n(!t)},[n,t])}}var P=(0,A.createContext)(null),F=(0,A.forwardRef)(function(e,t){let n=M(e),r=p({...e,defaultClassName:`react-aria-DisclosureGroup`,values:{isDisabled:n.isDisabled,state:n}}),i=S(e,{global:!0});return A.createElement(d.div,{...i,...r,ref:t,"data-disabled":e.isDisabled||void 0},A.createElement(P.Provider,{value:n},r.children))}),I=(0,A.createContext)(null),L=(0,A.createContext)(null),R=(0,A.createContext)(null),z=(0,A.forwardRef)(function(e,t){[e,t]=y(e,t,I);let n=(0,A.useContext)(P),{id:r,...i}=e,a=x();r||=a;let s=n?n.expandedKeys.has(r):e.isExpanded,c=N({...e,isExpanded:s,onExpandedChange(t){n&&n.toggleKey(r),e.onExpandedChange?.(t)}}),u=A.useRef(null),h=e.isDisabled||n?.isDisabled||!1,{buttonProps:g,panelProps:v}=j({...e,isExpanded:s,isDisabled:h},c,u),{isFocusVisible:b,focusProps:C}=_({within:!0}),w=p({...e,id:void 0,defaultClassName:`react-aria-Disclosure`,values:{isExpanded:c.isExpanded,isDisabled:h,isFocusVisibleWithin:b,state:c}}),T=S(i,{global:!0});return A.createElement(l,{values:[[o,{slots:{[m]:{},trigger:g}}],[R,{panelProps:v,panelRef:u}],[L,c]]},A.createElement(d.div,{...f(T,w,C),ref:t,"data-expanded":c.isExpanded||void 0,"data-disabled":h||void 0,"data-focus-visible-within":b||void 0},w.children))}),B=(0,A.forwardRef)(function(e,t){let{role:n=`group`}=e,{panelProps:r,panelRef:i}=(0,A.useContext)(R),{isFocusVisible:a,focusProps:s}=_({within:!0}),c=p({...e,defaultClassName:`react-aria-DisclosurePanel`,values:{isFocusVisibleWithin:a}}),u=S(e,{global:!0,labelable:!0});return A.createElement(d.div,{...f(u,c,r,s),ref:h(t,i),role:n,"data-focus-visible-within":a||void 0},A.createElement(l,{values:[[o,null]]},e.children))}),V=r(),H=(0,A.createContext)({}),U=({children:e,className:t,hideSeparator:n=!1,variant:r,...i})=>{let o=A.useMemo(()=>O({variant:r}),[r]),s=(0,V.jsx)(F,{className:g(t,o.base()),"data-slot":`accordion`,...i,children:t=>(0,V.jsx)(V.Fragment,{children:typeof e==`function`?e(t):e})});return(0,V.jsx)(H,{value:{slots:o,hideSeparator:n},children:r===`surface`?(0,V.jsx)(a,{value:{variant:`default`},children:s}):s})},W=Object.assign(U,{Root:U,Item:({className:e,...t})=>{let{hideSeparator:n,slots:r}=(0,A.use)(H);return(0,V.jsx)(z,{className:g(e,r?.item()),"data-hide-separator":n?`true`:void 0,"data-slot":`accordion-item`,...t,children:t.children})},Heading:({className:e,...t})=>{let{slots:n}=(0,A.use)(H);return(0,V.jsx)(D,{className:C(n?.heading,e),"data-slot":`accordion-heading`,...t})},Trigger:({className:e,...t})=>{let{slots:n}=(0,A.use)(H);return(0,V.jsx)(s,{className:g(e,n?.trigger()),"data-slot":`accordion-trigger`,slot:`trigger`,...t,children:e=>(0,V.jsx)(V.Fragment,{children:typeof t.children==`function`?t.children(e):t.children})})},Panel:({children:e,className:t,...n})=>{let{slots:r}=(0,A.use)(H),{isExpanded:i}=(0,A.use)(L);return(0,V.jsx)(B,{className:g(t,r?.panel()),"data-expanded":E(i),"data-slot":`accordion-panel`,...n,children:e})},Indicator:({children:e,className:t,...n})=>{let{slots:r}=(0,A.use)(H),{isExpanded:a}=(0,A.use)(L);return e&&A.isValidElement(e)?A.cloneElement(e,{...n,"data-expanded":E(a),className:C(r?.indicator,t),"data-slot":`accordion-indicator`}):(0,V.jsx)(i,{className:C(r?.indicator,t),"data-expanded":E(a),"data-slot":`accordion-indicator`,...n})},Body:({children:e,className:t,...n})=>{let{slots:r}=(0,A.use)(H);return(0,V.jsx)(u.div,{className:r?.body({}),"data-slot":`accordion-body`,...n,children:(0,V.jsx)(`div`,{className:C(r?.bodyInner,t),children:e})})}});export{W as t}; \ No newline at end of file +import{a as e,c as t,i as n,n as r}from"./shim-mfK0Rmj6.js";import{J as i,P as a,R as o,Y as s,it as c}from"./useI18n-BBOAnu2u.js";import{A as l,B as u,F as d,J as f,M as p,P as m,Y as h,c as g,d as _,dt as v,j as y,l as b,lt as x,q as S,s as C,ut as w,z as T}from"./SharedElementTransition-BlCsXfb1.js";import{t as E}from"./assertion-BLQtDfw6.js";import{Ct as D}from"./index-B9eWF6SH.js";var O=T({slots:{base:`accordion`,body:`accordion__body`,bodyInner:`accordion__body-inner`,heading:`accordion__heading`,indicator:`accordion__indicator`,item:`accordion__item`,panel:`accordion__panel`,trigger:`accordion__trigger`},variants:{variant:{default:{},surface:{base:`accordion--surface`}}}}),k=t(n(),1),A=t(e(),1);function j(e,t,n){let{isDisabled:r}=e,i=x(),a=x(),o=w(),s=(0,A.useRef)(null),l=(0,A.useCallback)(()=>{s.current=requestAnimationFrame(()=>{n.current&&n.current.setAttribute(`hidden`,`until-found`)}),(0,k.flushSync)(()=>{t.toggle()})},[n,t]);c(n,`beforematch`,l);let u=(0,A.useRef)(null);return v(()=>{if(s.current&&cancelAnimationFrame(s.current),n.current&&!o){let e=n.current;u.current==null||typeof e.getAnimations!=`function`?t.isExpanded?(e.removeAttribute(`hidden`),e.style.setProperty(`--disclosure-panel-width`,`auto`),e.style.setProperty(`--disclosure-panel-height`,`auto`)):(e.setAttribute(`hidden`,`until-found`),e.style.setProperty(`--disclosure-panel-width`,`0px`),e.style.setProperty(`--disclosure-panel-height`,`0px`)):t.isExpanded!==u.current&&(t.isExpanded?(e.removeAttribute(`hidden`),e.style.setProperty(`--disclosure-panel-width`,e.scrollWidth+`px`),e.style.setProperty(`--disclosure-panel-height`,e.scrollHeight+`px`),Promise.all(e.getAnimations().map(e=>e.finished)).then(()=>{e.style.setProperty(`--disclosure-panel-width`,`auto`),e.style.setProperty(`--disclosure-panel-height`,`auto`)}).catch(()=>{})):(e.style.setProperty(`--disclosure-panel-width`,e.scrollWidth+`px`),e.style.setProperty(`--disclosure-panel-height`,e.scrollHeight+`px`),window.getComputedStyle(e).height,e.style.setProperty(`--disclosure-panel-width`,`0px`),e.style.setProperty(`--disclosure-panel-height`,`0px`),Promise.all(e.getAnimations().map(e=>e.finished)).then(()=>e.setAttribute(`hidden`,`until-found`)).catch(()=>{}))),u.current=t.isExpanded}},[r,n,t.isExpanded,o]),(0,A.useEffect)(()=>()=>{s.current&&cancelAnimationFrame(s.current)},[]),{buttonProps:{id:i,"aria-expanded":t.isExpanded,"aria-controls":a,onPress:e=>{!r&&e.pointerType!==`keyboard`&&t.toggle()},isDisabled:r,onPressStart(e){e.pointerType===`keyboard`&&!r&&t.toggle()}},panelProps:{id:a,role:`group`,"aria-labelledby":i,"aria-hidden":!t.isExpanded,hidden:o?!t.isExpanded:void 0}}}function M(e){let{allowsMultipleExpanded:t=!1,isDisabled:n=!1}=e,[r,i]=b((0,A.useMemo)(()=>e.expandedKeys?new Set(e.expandedKeys):void 0,[e.expandedKeys]),(0,A.useMemo)(()=>e.defaultExpandedKeys?new Set(e.defaultExpandedKeys):new Set,[e.defaultExpandedKeys]),e.onExpandedChange);return(0,A.useEffect)(()=>{if(!t&&r.size>1){let e=r.values().next().value;e!=null&&i(new Set([e]))}}),{allowsMultipleExpanded:t,isDisabled:n,expandedKeys:r,setExpandedKeys:i,toggleKey(e){let n;t?(n=new Set(r),n.has(e)?n.delete(e):n.add(e)):n=new Set(r.has(e)?[]:[e]),i(n)}}}function N(e){let[t,n]=b(e.isExpanded,e.defaultExpanded||!1,e.onExpandedChange);return{isExpanded:t,setExpanded:n,expand:(0,A.useCallback)(()=>{n(!0)},[n]),collapse:(0,A.useCallback)(()=>{n(!1)},[n]),toggle:(0,A.useCallback)(()=>{n(!t)},[n,t])}}var P=(0,A.createContext)(null),F=(0,A.forwardRef)(function(e,t){let n=M(e),r=p({...e,defaultClassName:`react-aria-DisclosureGroup`,values:{isDisabled:n.isDisabled,state:n}}),i=S(e,{global:!0});return A.createElement(d.div,{...i,...r,ref:t,"data-disabled":e.isDisabled||void 0},A.createElement(P.Provider,{value:n},r.children))}),I=(0,A.createContext)(null),L=(0,A.createContext)(null),R=(0,A.createContext)(null),z=(0,A.forwardRef)(function(e,t){[e,t]=y(e,t,I);let n=(0,A.useContext)(P),{id:r,...a}=e,o=x();r||=o;let s=n?n.expandedKeys.has(r):e.isExpanded,c=N({...e,isExpanded:s,onExpandedChange(t){n&&n.toggleKey(r),e.onExpandedChange?.(t)}}),u=A.useRef(null),h=e.isDisabled||n?.isDisabled||!1,{buttonProps:g,panelProps:v}=j({...e,isExpanded:s,isDisabled:h},c,u),{isFocusVisible:b,focusProps:C}=_({within:!0}),w=p({...e,id:void 0,defaultClassName:`react-aria-Disclosure`,values:{isExpanded:c.isExpanded,isDisabled:h,isFocusVisibleWithin:b,state:c}}),T=S(a,{global:!0});return A.createElement(l,{values:[[i,{slots:{[m]:{},trigger:g}}],[R,{panelProps:v,panelRef:u}],[L,c]]},A.createElement(d.div,{...f(T,w,C),ref:t,"data-expanded":c.isExpanded||void 0,"data-disabled":h||void 0,"data-focus-visible-within":b||void 0},w.children))}),B=(0,A.forwardRef)(function(e,t){let{role:n=`group`}=e,{panelProps:r,panelRef:a}=(0,A.useContext)(R),{isFocusVisible:o,focusProps:s}=_({within:!0}),c=p({...e,defaultClassName:`react-aria-DisclosurePanel`,values:{isFocusVisibleWithin:o}}),u=S(e,{global:!0,labelable:!0});return A.createElement(d.div,{...f(u,c,r,s),ref:h(t,a),role:n,"data-focus-visible-within":o||void 0},A.createElement(l,{values:[[i,null]]},e.children))}),V=r(),H=(0,A.createContext)({}),U=({children:e,className:t,hideSeparator:n=!1,variant:r,...i})=>{let o=A.useMemo(()=>O({variant:r}),[r]),s=(0,V.jsx)(F,{className:g(t,o.base()),"data-slot":`accordion`,...i,children:t=>(0,V.jsx)(V.Fragment,{children:typeof e==`function`?e(t):e})});return(0,V.jsx)(H,{value:{slots:o,hideSeparator:n},children:r===`surface`?(0,V.jsx)(a,{value:{variant:`default`},children:s}):s})},W=Object.assign(U,{Root:U,Item:({className:e,...t})=>{let{hideSeparator:n,slots:r}=(0,A.use)(H);return(0,V.jsx)(z,{className:g(e,r?.item()),"data-hide-separator":n?`true`:void 0,"data-slot":`accordion-item`,...t,children:t.children})},Heading:({className:e,...t})=>{let{slots:n}=(0,A.use)(H);return(0,V.jsx)(D,{className:C(n?.heading,e),"data-slot":`accordion-heading`,...t})},Trigger:({className:e,...t})=>{let{slots:n}=(0,A.use)(H);return(0,V.jsx)(s,{className:g(e,n?.trigger()),"data-slot":`accordion-trigger`,slot:`trigger`,...t,children:e=>(0,V.jsx)(V.Fragment,{children:typeof t.children==`function`?t.children(e):t.children})})},Panel:({children:e,className:t,...n})=>{let{slots:r}=(0,A.use)(H),{isExpanded:i}=(0,A.use)(L);return(0,V.jsx)(B,{className:g(t,r?.panel()),"data-expanded":E(i),"data-slot":`accordion-panel`,...n,children:e})},Indicator:({children:e,className:t,...n})=>{let{slots:r}=(0,A.use)(H),{isExpanded:i}=(0,A.use)(L);return e&&A.isValidElement(e)?A.cloneElement(e,{...n,"data-expanded":E(i),className:C(r?.indicator,t),"data-slot":`accordion-indicator`}):(0,V.jsx)(o,{className:C(r?.indicator,t),"data-expanded":E(i),"data-slot":`accordion-indicator`,...n})},Body:({children:e,className:t,...n})=>{let{slots:r}=(0,A.use)(H);return(0,V.jsx)(u.div,{className:r?.body({}),"data-slot":`accordion-body`,...n,children:(0,V.jsx)(`div`,{className:C(r?.bodyInner,t),children:e})})}});export{W as t}; \ No newline at end of file diff --git a/internal/webui/static/assets/card-QlCdtlk0.js b/internal/webui/static/assets/card-QlCdtlk0.js new file mode 100644 index 00000000..2e8e5b39 --- /dev/null +++ b/internal/webui/static/assets/card-QlCdtlk0.js @@ -0,0 +1 @@ +import{a as e,c as t,n}from"./shim-mfK0Rmj6.js";import{P as r}from"./useI18n-BBOAnu2u.js";import{B as i,s as a,z as o}from"./SharedElementTransition-BlCsXfb1.js";var s=o({defaultVariants:{variant:`default`},slots:{base:`card`,content:`card__content`,description:`card__description`,footer:`card__footer`,header:`card__header`,title:`card__title`},variants:{variant:{default:{base:`card--default`},secondary:{base:`card--secondary`},tertiary:{base:`card--tertiary`},transparent:{base:`card--transparent`}}}}),c=t(e(),1),l=n(),u=(0,c.createContext)({}),d=({children:e,className:t,variant:n=`default`,...a})=>{let o=c.useMemo(()=>s({variant:n}),[n]),d=(0,l.jsx)(i.div,{className:o.base({className:t}),"data-slot":`card`,...a,children:e});return(0,l.jsx)(u,{value:{slots:o},children:n===`transparent`?d:(0,l.jsx)(r,{value:{variant:n},children:d})})},f=Object.assign(d,{Root:d,Header:({className:e,...t})=>{let{slots:n}=(0,c.use)(u);return(0,l.jsx)(i.div,{className:a(n?.header,e),"data-slot":`card-header`,...t})},Title:({children:e,className:t,...n})=>{let{slots:r}=(0,c.use)(u);return(0,l.jsx)(i.h3,{className:a(r?.title,t),"data-slot":`card-title`,...n,children:e})},Description:({children:e,className:t,...n})=>{let{slots:r}=(0,c.use)(u);return(0,l.jsx)(i.p,{className:a(r?.description,t),"data-slot":`card-description`,...n,children:e})},Content:({className:e,...t})=>{let{slots:n}=(0,c.use)(u);return(0,l.jsx)(i.div,{className:a(n?.content,e),"data-slot":`card-content`,...t})},Footer:({className:e,...t})=>{let{slots:n}=(0,c.use)(u);return(0,l.jsx)(i.div,{className:a(n?.footer,e),"data-slot":`card-footer`,...t})}});export{f as t}; \ No newline at end of file diff --git a/internal/webui/static/assets/checkbox-Dkk25tsQ.js b/internal/webui/static/assets/checkbox-Dkk25tsQ.js deleted file mode 100644 index 1186f008..00000000 --- a/internal/webui/static/assets/checkbox-Dkk25tsQ.js +++ /dev/null @@ -1 +0,0 @@ -import{a as e,c as t,n}from"./shim-mfK0Rmj6.js";import{B as r,c as i,s as a,z as o}from"./SharedElementTransition-BlCsXfb1.js";import{n as s,t as c}from"./Checkbox-DbM57zbg.js";var l=o({defaultVariants:{variant:`primary`},slots:{base:`checkbox`,content:`checkbox__content`,control:`checkbox__control`,indicator:`checkbox__indicator`},variants:{variant:{primary:{base:`checkbox--primary`},secondary:{base:`checkbox--secondary`}}}}),u=t(e(),1),d=n(),f=(0,u.createContext)({}),p=(0,u.createContext)({}),m=({children:e,className:t,variant:n,...r})=>{let a=(0,u.use)(f),o=n??a.variant,c=u.useMemo(()=>l({variant:o}),[o]);return(0,d.jsx)(s,{"data-slot":`checkbox`,...r,className:i(t,c.base()),children:t=>(0,d.jsx)(p,{value:{slots:c,state:t},children:typeof e==`function`?e(t):e})})};m.displayName=`HeroUI.Checkbox`;var h=({children:e,className:t,...n})=>{let{slots:r}=(0,u.use)(p);return(0,d.jsx)(c,{"data-slot":`checkbox-content`,...n,className:i(t,r?.content()),children:e})};h.displayName=`HeroUI.Checkbox.Content`;var g=({children:e,className:t,...n})=>{let{slots:i}=(0,u.use)(p);return(0,d.jsx)(r.span,{className:a(i?.control,t),"data-slot":`checkbox-control`,...n,children:e})};g.displayName=`HeroUI.Checkbox.Control`;var _=({children:e,className:t,...n})=>{let{slots:i,state:o}=(0,u.use)(p),s=o?.isSelected,c=o?.isIndeterminate,l=typeof e==`function`?e(o??{}):e||(c?(0,d.jsx)(`svg`,{"aria-hidden":`true`,"data-slot":`checkbox-default-indicator--indeterminate`,fill:`none`,role:`presentation`,stroke:`currentColor`,strokeLinecap:`round`,strokeWidth:3,viewBox:`0 0 24 24`,children:(0,d.jsx)(`line`,{x1:`21`,x2:`3`,y1:`12`,y2:`12`})}):(0,d.jsx)(`svg`,{"aria-hidden":`true`,"data-slot":`checkbox-default-indicator--checkmark`,fill:`none`,role:`presentation`,stroke:`currentColor`,strokeDasharray:22,strokeDashoffset:s?44:66,strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,viewBox:`0 0 17 18`,children:(0,d.jsx)(`polyline`,{points:`1 9 7 14 15 4`})}));return(0,d.jsx)(r.span,{"aria-hidden":`true`,className:a(i?.indicator,t),"data-slot":`checkbox-indicator`,...n,children:l})};_.displayName=`HeroUI.Checkbox.Indicator`;var v=Object.assign(m,{Root:m,Content:h,Control:g,Indicator:_});export{v as t}; \ No newline at end of file diff --git a/internal/webui/static/assets/clipboard-BMEt1jHG.js b/internal/webui/static/assets/clipboard-BWzpPXn-.js similarity index 94% rename from internal/webui/static/assets/clipboard-BMEt1jHG.js rename to internal/webui/static/assets/clipboard-BWzpPXn-.js index e673fa10..8ff9126c 100644 --- a/internal/webui/static/assets/clipboard-BMEt1jHG.js +++ b/internal/webui/static/assets/clipboard-BWzpPXn-.js @@ -1 +1 @@ -import{a as e,c as t}from"./shim-mfK0Rmj6.js";import{pt as n}from"./useI18n-BSw4X3mq.js";var r=t(e(),1),i=new Map([[`bold`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M216,28H88A12,12,0,0,0,76,40V76H40A12,12,0,0,0,28,88V216a12,12,0,0,0,12,12H168a12,12,0,0,0,12-12V180h36a12,12,0,0,0,12-12V40A12,12,0,0,0,216,28ZM156,204H52V100H156Zm48-48H180V88a12,12,0,0,0-12-12H100V52H204Z`}))],[`duotone`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M216,40V168H168V88H88V40Z`,opacity:`0.2`}),r.createElement(`path`,{d:`M216,32H88a8,8,0,0,0-8,8V80H40a8,8,0,0,0-8,8V216a8,8,0,0,0,8,8H168a8,8,0,0,0,8-8V176h40a8,8,0,0,0,8-8V40A8,8,0,0,0,216,32ZM160,208H48V96H160Zm48-48H176V88a8,8,0,0,0-8-8H96V48H208Z`}))],[`fill`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M216,32H88a8,8,0,0,0-8,8V80H40a8,8,0,0,0-8,8V216a8,8,0,0,0,8,8H168a8,8,0,0,0,8-8V176h40a8,8,0,0,0,8-8V40A8,8,0,0,0,216,32Zm-8,128H176V88a8,8,0,0,0-8-8H96V48H208Z`}))],[`light`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M216,34H88a6,6,0,0,0-6,6V82H40a6,6,0,0,0-6,6V216a6,6,0,0,0,6,6H168a6,6,0,0,0,6-6V174h42a6,6,0,0,0,6-6V40A6,6,0,0,0,216,34ZM162,210H46V94H162Zm48-48H174V88a6,6,0,0,0-6-6H94V46H210Z`}))],[`regular`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M216,32H88a8,8,0,0,0-8,8V80H40a8,8,0,0,0-8,8V216a8,8,0,0,0,8,8H168a8,8,0,0,0,8-8V176h40a8,8,0,0,0,8-8V40A8,8,0,0,0,216,32ZM160,208H48V96H160Zm48-48H176V88a8,8,0,0,0-8-8H96V48H208Z`}))],[`thin`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M216,36H88a4,4,0,0,0-4,4V84H40a4,4,0,0,0-4,4V216a4,4,0,0,0,4,4H168a4,4,0,0,0,4-4V172h44a4,4,0,0,0,4-4V40A4,4,0,0,0,216,36ZM164,212H44V92H164Zm48-48H172V88a4,4,0,0,0-4-4H92V44H212Z`}))]]),a=r.forwardRef((e,t)=>r.createElement(n,{ref:t,...e,weights:i}));a.displayName=`CopyIcon`;var o=a;async function s(e){if(!e)return!1;try{if(typeof navigator<`u`&&navigator.clipboard&&window.isSecureContext)return await navigator.clipboard.writeText(e),!0}catch{}try{let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,``),t.style.position=`fixed`,t.style.top=`-1000px`,t.style.opacity=`0`,document.body.appendChild(t),t.focus(),t.select();let n=document.execCommand(`copy`);return document.body.removeChild(t),n}catch{return!1}}export{o as n,s as t}; \ No newline at end of file +import{a as e,c as t}from"./shim-mfK0Rmj6.js";import{dt as n}from"./useI18n-BBOAnu2u.js";var r=t(e(),1),i=new Map([[`bold`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M216,28H88A12,12,0,0,0,76,40V76H40A12,12,0,0,0,28,88V216a12,12,0,0,0,12,12H168a12,12,0,0,0,12-12V180h36a12,12,0,0,0,12-12V40A12,12,0,0,0,216,28ZM156,204H52V100H156Zm48-48H180V88a12,12,0,0,0-12-12H100V52H204Z`}))],[`duotone`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M216,40V168H168V88H88V40Z`,opacity:`0.2`}),r.createElement(`path`,{d:`M216,32H88a8,8,0,0,0-8,8V80H40a8,8,0,0,0-8,8V216a8,8,0,0,0,8,8H168a8,8,0,0,0,8-8V176h40a8,8,0,0,0,8-8V40A8,8,0,0,0,216,32ZM160,208H48V96H160Zm48-48H176V88a8,8,0,0,0-8-8H96V48H208Z`}))],[`fill`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M216,32H88a8,8,0,0,0-8,8V80H40a8,8,0,0,0-8,8V216a8,8,0,0,0,8,8H168a8,8,0,0,0,8-8V176h40a8,8,0,0,0,8-8V40A8,8,0,0,0,216,32Zm-8,128H176V88a8,8,0,0,0-8-8H96V48H208Z`}))],[`light`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M216,34H88a6,6,0,0,0-6,6V82H40a6,6,0,0,0-6,6V216a6,6,0,0,0,6,6H168a6,6,0,0,0,6-6V174h42a6,6,0,0,0,6-6V40A6,6,0,0,0,216,34ZM162,210H46V94H162Zm48-48H174V88a6,6,0,0,0-6-6H94V46H210Z`}))],[`regular`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M216,32H88a8,8,0,0,0-8,8V80H40a8,8,0,0,0-8,8V216a8,8,0,0,0,8,8H168a8,8,0,0,0,8-8V176h40a8,8,0,0,0,8-8V40A8,8,0,0,0,216,32ZM160,208H48V96H160Zm48-48H176V88a8,8,0,0,0-8-8H96V48H208Z`}))],[`thin`,r.createElement(r.Fragment,null,r.createElement(`path`,{d:`M216,36H88a4,4,0,0,0-4,4V84H40a4,4,0,0,0-4,4V216a4,4,0,0,0,4,4H168a4,4,0,0,0,4-4V172h44a4,4,0,0,0,4-4V40A4,4,0,0,0,216,36ZM164,212H44V92H164Zm48-48H172V88a4,4,0,0,0-4-4H92V44H212Z`}))]]),a=r.forwardRef((e,t)=>r.createElement(n,{ref:t,...e,weights:i}));a.displayName=`CopyIcon`;var o=a;async function s(e){if(!e)return!1;try{if(typeof navigator<`u`&&navigator.clipboard&&window.isSecureContext)return await navigator.clipboard.writeText(e),!0}catch{}try{let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,``),t.style.position=`fixed`,t.style.top=`-1000px`,t.style.opacity=`0`,document.body.appendChild(t),t.focus(),t.select();let n=document.execCommand(`copy`);return document.body.removeChild(t),n}catch{return!1}}export{o as n,s as t}; \ No newline at end of file diff --git a/internal/webui/static/assets/collection-prop-injection-ChD21sys.js b/internal/webui/static/assets/collection-prop-injection-CF1SevF_.js similarity index 97% rename from internal/webui/static/assets/collection-prop-injection-ChD21sys.js rename to internal/webui/static/assets/collection-prop-injection-CF1SevF_.js index d7faef7f..25f27508 100644 --- a/internal/webui/static/assets/collection-prop-injection-ChD21sys.js +++ b/internal/webui/static/assets/collection-prop-injection-CF1SevF_.js @@ -1 +1 @@ -import{a as e,c as t,n}from"./shim-mfK0Rmj6.js";import{a as r}from"./useI18n-BSw4X3mq.js";var i=t(e(),1),a=(0,i.createContext)(!1),o=e=>{let t=(0,i.use)(a),n=(0,i.use)(r);return!t||n?.slots?.[e]!=null},s={blue:`\x1B[34m`,green:`\x1B[32m`,magenta:`\x1B[35m`,red:`\x1B[31m`,reset:`\x1B[0m`,yellow:`\x1B[33m`},c={debug:s.magenta,error:s.red,info:s.blue,success:s.green,warn:s.yellow},l={debug:`🔍`,error:`❌`,info:`ℹ️`,success:`✅`,warn:`⚠️`},u=class{constructor(e={}){this.enabled=e.enabled??!0,this.prefix=e.prefix??`HeroUI`}formatMessage(e,t){let n=c[e],r=l[e];return`${n}[${this.prefix}]${s.reset} ${r} ${t}`}log(e,t,...n){if(!this.enabled)return;let r=this.formatMessage(e,t);switch(e){case`error`:console.error(r,...n);break;case`warn`:console.warn(r,...n);break;default:console.log(r,...n)}}info(e,...t){this.log(`info`,e,...t)}success(e,...t){this.log(`success`,e,...t)}warn(e,...t){this.log(`warn`,e,...t)}error(e,...t){this.log(`error`,e,...t)}debug(e,...t){this.log(`debug`,e,...t)}divider(e=`=`,t=80){this.enabled&&console.log(e.repeat(t))}newline(){this.enabled&&console.log()}},d=n(),f=new u({prefix:`HeroUI`}),p,m=typeof process<`u`&&!1,h=e=>{m&&(p??=new Set,p.has(e)&&f.warn(`Duplicate collection slot "${e}". Use a unique, namespaced name (e.g. "tabs.listContainer", "menu.popover").`),p.add(e));let t=`$$heroui.collection.${e}`,n=(0,i.createContext)(void 0),r=(e,n)=>i.Children.map(e,e=>(0,i.isValidElement)(e)?i.cloneElement(e,{[t]:n}):e),a=e=>{let{[t]:n,...r}=e;return[n,r]},o=e=>{let[t,r]=a(e),o=(0,i.useContext)(n);return[t??o,r]},s=({children:e,...t})=>(0,d.jsx)(n.Provider,{value:t,children:r(e,t)});return s.displayName=`HeroUI.CollectionSlot(${e})`,{key:t,inject:r,consume:a,useSlot:o,Injector:s,withSlot:(t,n)=>{let r=(0,i.forwardRef)(function(r,i){let[a,s]=o(r),{children:c,...l}=s;if(!a)return(0,d.jsx)(t,{...l,ref:i,children:c});if(n)return n({...l,children:c},a,i);let{className:u,render:f,...p}=a;return(0,d.jsx)(t,{...l,ref:i,children:f?f({children:c,className:u,...p}):(0,d.jsx)(`div`,{className:u,"data-slot":`${e}-container`,...p,children:c})})});return r.displayName=`HeroUI.withCollectionSlot(${t.displayName||t.name||e})`,r},Context:n}};export{a as n,o as r,h as t}; \ No newline at end of file +import{a as e,c as t,n}from"./shim-mfK0Rmj6.js";import{a as r}from"./useI18n-BBOAnu2u.js";var i=t(e(),1),a=(0,i.createContext)(!1),o=e=>{let t=(0,i.use)(a),n=(0,i.use)(r);return!t||n?.slots?.[e]!=null},s={blue:`\x1B[34m`,green:`\x1B[32m`,magenta:`\x1B[35m`,red:`\x1B[31m`,reset:`\x1B[0m`,yellow:`\x1B[33m`},c={debug:s.magenta,error:s.red,info:s.blue,success:s.green,warn:s.yellow},l={debug:`🔍`,error:`❌`,info:`ℹ️`,success:`✅`,warn:`⚠️`},u=class{constructor(e={}){this.enabled=e.enabled??!0,this.prefix=e.prefix??`HeroUI`}formatMessage(e,t){let n=c[e],r=l[e];return`${n}[${this.prefix}]${s.reset} ${r} ${t}`}log(e,t,...n){if(!this.enabled)return;let r=this.formatMessage(e,t);switch(e){case`error`:console.error(r,...n);break;case`warn`:console.warn(r,...n);break;default:console.log(r,...n)}}info(e,...t){this.log(`info`,e,...t)}success(e,...t){this.log(`success`,e,...t)}warn(e,...t){this.log(`warn`,e,...t)}error(e,...t){this.log(`error`,e,...t)}debug(e,...t){this.log(`debug`,e,...t)}divider(e=`=`,t=80){this.enabled&&console.log(e.repeat(t))}newline(){this.enabled&&console.log()}},d=n(),f=new u({prefix:`HeroUI`}),p,m=typeof process<`u`&&!1,h=e=>{m&&(p??=new Set,p.has(e)&&f.warn(`Duplicate collection slot "${e}". Use a unique, namespaced name (e.g. "tabs.listContainer", "menu.popover").`),p.add(e));let t=`$$heroui.collection.${e}`,n=(0,i.createContext)(void 0),r=(e,n)=>i.Children.map(e,e=>(0,i.isValidElement)(e)?i.cloneElement(e,{[t]:n}):e),a=e=>{let{[t]:n,...r}=e;return[n,r]},o=e=>{let[t,r]=a(e),o=(0,i.useContext)(n);return[t??o,r]},s=({children:e,...t})=>(0,d.jsx)(n.Provider,{value:t,children:r(e,t)});return s.displayName=`HeroUI.CollectionSlot(${e})`,{key:t,inject:r,consume:a,useSlot:o,Injector:s,withSlot:(t,n)=>{let r=(0,i.forwardRef)(function(r,i){let[a,s]=o(r),{children:c,...l}=s;if(!a)return(0,d.jsx)(t,{...l,ref:i,children:c});if(n)return n({...l,children:c},a,i);let{className:u,render:f,...p}=a;return(0,d.jsx)(t,{...l,ref:i,children:f?f({children:c,className:u,...p}):(0,d.jsx)(`div`,{className:u,"data-slot":`${e}-container`,...p,children:c})})});return r.displayName=`HeroUI.withCollectionSlot(${t.displayName||t.name||e})`,r},Context:n}};export{a as n,o as r,h as t}; \ No newline at end of file diff --git a/internal/webui/static/assets/description-0cu8nG7R.js b/internal/webui/static/assets/description-CNxrVc-S.js similarity index 70% rename from internal/webui/static/assets/description-0cu8nG7R.js rename to internal/webui/static/assets/description-CNxrVc-S.js index a6a1157b..2348bf64 100644 --- a/internal/webui/static/assets/description-0cu8nG7R.js +++ b/internal/webui/static/assets/description-CNxrVc-S.js @@ -1 +1 @@ -import{n as e}from"./shim-mfK0Rmj6.js";import{i as t}from"./useI18n-BSw4X3mq.js";import{z as n}from"./SharedElementTransition-BlCsXfb1.js";import{r}from"./collection-prop-injection-ChD21sys.js";var i=n({base:`description`}),a=e(),o=({children:e,className:n,...o})=>r(`description`)?(0,a.jsx)(t,{className:i({className:n}),"data-slot":`description`,slot:`description`,...o,children:e}):null,s=Object.assign(o,{Root:o});export{s as t}; \ No newline at end of file +import{n as e}from"./shim-mfK0Rmj6.js";import{i as t}from"./useI18n-BBOAnu2u.js";import{z as n}from"./SharedElementTransition-BlCsXfb1.js";import{r}from"./collection-prop-injection-CF1SevF_.js";var i=n({base:`description`}),a=e(),o=({children:e,className:n,...o})=>r(`description`)?(0,a.jsx)(t,{className:i({className:n}),"data-slot":`description`,slot:`description`,...o,children:e}):null,s=Object.assign(o,{Root:o});export{s as t}; \ No newline at end of file diff --git a/internal/webui/static/assets/format-B6SmebW-.js b/internal/webui/static/assets/format-B6SmebW-.js deleted file mode 100644 index 7cb8b81a..00000000 --- a/internal/webui/static/assets/format-B6SmebW-.js +++ /dev/null @@ -1 +0,0 @@ -function e(e){if(!Number.isFinite(e))return`—`;let t=Math.abs(e);return t>=1e6?`${s(e/1e6)}M`:t>=1e3?`${s(e/1e3)}k`:String(Math.round(e))}function t(e){return e==null||!Number.isFinite(e)?`—`:e>=1e3?`${s(e/1e3)}s`:`${Math.round(e)}ms`}function n(e){if(e==null||!Number.isFinite(e)||e<0)return`—`;let t=[`B`,`KB`,`MB`,`GB`,`TB`],n=e,r=0;for(;n>=1024&&r=10?t.toFixed(0):t.toFixed(1)}%`}function i(n,i){return i===`compact`?e(n):i===`percent`?r(n):i===`ms`?t(n):String(Math.round(n))}function a(e){return(e.credits||``).trim()||``}function o(e){if(e.free)return!0;let t=a(e).toLowerCase();if(!t)return!1;let n=t.match(/(\d+(?:\.\d+)?)/);return!!(n&&Number(n[1])===0)}function s(e){let t=Math.abs(e)>=10?0:1;return Number(e.toFixed(t)).toString()}function c(e){return e==null||!Number.isFinite(e)?`—`:`¥${e.toLocaleString(`zh-CN`,{minimumFractionDigits:2,maximumFractionDigits:2})}`}function l(e){return e==null||!Number.isFinite(e)?`—`:`¥${Number(e.toFixed(4))}`}function u(t){return t==null||!Number.isFinite(t)?`—`:t>=1e4?e(t):t.toLocaleString(`zh-CN`,{minimumFractionDigits:t<100?2:0,maximumFractionDigits:2})}function d(e){let t=e.completionTokens,n=e.latencyMs,r=e.ttfbMs;if(t==null||!Number.isFinite(t)||t<=0||n==null||!Number.isFinite(n)||n<=0)return null;let i=e.stream===!0&&r!=null&&Number.isFinite(r)&&r>=0&&n-r>0?(n-r)/1e3:n/1e3;if(!(i>0))return null;let a=t/i;return Number.isFinite(a)&&a>0?a:null}function f(e){return e==null||!Number.isFinite(e)||e<=0?`—`:`${e>=100?String(Math.round(e)):Number(e.toFixed(1)).toString()} tok/s`}export{i as a,r as c,a as d,o as f,e as i,f as l,n,u as o,c as r,t as s,d as t,l as u}; \ No newline at end of file diff --git a/internal/webui/static/assets/format-kRpr2wxA.js b/internal/webui/static/assets/format-kRpr2wxA.js new file mode 100644 index 00000000..c1d09a2e --- /dev/null +++ b/internal/webui/static/assets/format-kRpr2wxA.js @@ -0,0 +1 @@ +import{a as e,c as t,n}from"./shim-mfK0Rmj6.js";import{B as r,F as i,J as a,L as o,M as s,c,d as l,j as u,q as d,s as f,u as p,z as m}from"./SharedElementTransition-BlCsXfb1.js";import{t as h}from"./useToggleState-DpzdeNPF.js";import{F as g,I as _,L as v,N as y,P as b,pt as x}from"./index-B9eWF6SH.js";var S=m({base:`toggle-button`,defaultVariants:{isIconOnly:!1,size:`md`,variant:`default`},variants:{isIconOnly:{true:`toggle-button--icon-only`},size:{lg:`toggle-button--lg`,md:`toggle-button--md`,sm:`toggle-button--sm`},variant:{default:`toggle-button--default`,ghost:`toggle-button--ghost`}}}),C=m({defaultVariants:{fullWidth:!1,isDetached:!1,orientation:`horizontal`},slots:{base:`toggle-button-group`,separator:`toggle-button-group__separator`},variants:{fullWidth:{false:{},true:{base:`toggle-button-group--full-width`}},isDetached:{false:{},true:{base:`toggle-button-group--detached`}},orientation:{horizontal:{base:`toggle-button-group--horizontal`},vertical:{base:`toggle-button-group--vertical`}}}}),w=t(e(),1),T=(0,w.createContext)({}),E=(0,w.forwardRef)(function(e,t){[e,t]=u(e,t,T);let n=(0,w.useContext)(g),r=h(n&&e.id!=null?{isSelected:n.selectedKeys.has(e.id),onChange(t){n.setSelected(e.id,t)}}:e),{buttonProps:o,isPressed:c,isSelected:f,isDisabled:m}=n&&e.id!=null?_({...e,id:e.id},n,t):v({...e,id:e.id==null?void 0:String(e.id)},r,t),{focusProps:y,isFocused:b,isFocusVisible:S}=l(e),{hoverProps:C,isHovered:E}=p({...e,isDisabled:m}),D=s({...e,id:void 0,values:{isHovered:E,isPressed:c,isFocused:b,isSelected:r.isSelected,isFocusVisible:S,isDisabled:m,state:r},defaultClassName:`react-aria-ToggleButton`}),O=d(e,{global:!0});return delete O.id,delete O.onClick,w.createElement(i.button,{...a(O,D,o,y,C),ref:t,slot:e.slot||void 0,"data-focused":b||void 0,"data-disabled":m||void 0,"data-pressed":c||void 0,"data-selected":f||void 0,"data-hovered":E||void 0,"data-focus-visible":S||void 0},w.createElement(x.Provider,{value:{isSelected:f}},D.children))}),D=n(),O=(0,w.createContext)({}),k=({children:e,className:t,fullWidth:n,isDetached:r=!1,isDisabled:i,orientation:a,size:s,...l})=>{let u=o(y),d=a??u?.orientation??`horizontal`,f=w.useMemo(()=>C({fullWidth:n,isDetached:r,orientation:d}),[n,r,d]);return(0,D.jsx)(O,{value:{slots:f,size:s,isDisabled:i},children:(0,D.jsx)(b,{className:c(t,f.base()),"data-slot":`toggle-button-group`,isDisabled:i,orientation:d,...l,children:e})})},A=({className:e,...t})=>{let{slots:n}=(0,w.use)(O);return(0,D.jsx)(r.span,{"aria-hidden":`true`,className:f(n?.separator,e),"data-slot":`toggle-button-group-separator`,...t})},j=({children:e,className:t,isIconOnly:n,size:r,style:i,variant:a,...o})=>{let s=(0,w.use)(O),l=S({isIconOnly:n,size:r??s?.size,variant:a});return(0,D.jsx)(E,{className:c(t,l),"data-slot":`toggle-button`,style:i,...o,children:t=>typeof e==`function`?e(t):e})},M=Object.assign(j,{Root:j}),N=Object.assign(k,{Root:k,Separator:A});function P(e){if(!Number.isFinite(e))return`—`;let t=Math.abs(e);return t>=1e6?`${V(e/1e6)}M`:t>=1e3?`${V(e/1e3)}k`:String(Math.round(e))}function F(e){return e==null||!Number.isFinite(e)?`—`:e>=1e3?`${V(e/1e3)}s`:`${Math.round(e)}ms`}function I(e){if(e==null||!Number.isFinite(e)||e<0)return`—`;let t=[`B`,`KB`,`MB`,`GB`,`TB`],n=e,r=0;for(;n>=1024&&r=10?t.toFixed(0):t.toFixed(1)}%`}function R(e,t){return t===`compact`?P(e):t===`percent`?L(e):t===`ms`?F(e):String(Math.round(e))}function z(e){return(e.credits||``).trim()||``}function B(e){if(e.free)return!0;let t=z(e).toLowerCase();if(!t)return!1;let n=t.match(/(\d+(?:\.\d+)?)/);return!!(n&&Number(n[1])===0)}function V(e){let t=Math.abs(e)>=10?0:1;return Number(e.toFixed(t)).toString()}function H(e){return e==null||!Number.isFinite(e)?`—`:`¥${e.toLocaleString(`zh-CN`,{minimumFractionDigits:2,maximumFractionDigits:2})}`}function U(e){return e==null||!Number.isFinite(e)?`—`:`¥${Number(e.toFixed(4))}`}function W(e){return e==null||!Number.isFinite(e)?`—`:e>=1e4?P(e):e.toLocaleString(`zh-CN`,{minimumFractionDigits:e<100?2:0,maximumFractionDigits:2})}function G(e){let t=e.completionTokens,n=e.latencyMs,r=e.ttfbMs;if(t==null||!Number.isFinite(t)||t<=0||n==null||!Number.isFinite(n)||n<=0)return null;let i=e.stream===!0&&r!=null&&Number.isFinite(r)&&r>=0&&n-r>0?(n-r)/1e3:n/1e3;if(!(i>0))return null;let a=t/i;return Number.isFinite(a)&&a>0?a:null}function K(e){return e==null||!Number.isFinite(e)||e<=0?`—`:`${e>=100?String(Math.round(e)):Number(e.toFixed(1)).toString()} tok/s`}export{R as a,L as c,z as d,B as f,P as i,K as l,M as m,I as n,W as o,N as p,H as r,F as s,G as t,U as u}; \ No newline at end of file diff --git a/internal/webui/static/assets/index-B9eWF6SH.js b/internal/webui/static/assets/index-B9eWF6SH.js new file mode 100644 index 00000000..7f9af9dc --- /dev/null +++ b/internal/webui/static/assets/index-B9eWF6SH.js @@ -0,0 +1,16 @@ +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/SidebarUpdateDialog-BBhlV1LN.js","assets/shim-mfK0Rmj6.js","assets/useI18n-BBOAnu2u.js","assets/SharedElementTransition-BlCsXfb1.js","assets/PageAlert-DZC7IhXp.js","assets/modal-DHeFzFnN.js","assets/UpdateControls-BMVq7AGm.js","assets/LoginPage-BE11SySg.js","assets/label-BVCjtfNQ.js","assets/card-QlCdtlk0.js","assets/textfield-DczGuWn0.js","assets/useTextField-D7fuLL3e.js","assets/overview-CJvUvgoD.js","assets/textfield-BJXzgJRr.js","assets/OverviewPage-BbcGKR4s.js","assets/CaretRight.es-DGKxUxz5.js","assets/Check.es-PrgGvQWD.js","assets/TimeRangePicker-CLtIDMZF.js","assets/useUpdateEffect-DR9d7F-l.js","assets/useSpinButton-D63Afzx1.js","assets/assertion-BLQtDfw6.js","assets/format-kRpr2wxA.js","assets/useToggleState-DpzdeNPF.js","assets/gsap-C3sDxib7.js","assets/AreaChart-B0YOdVBx.js","assets/ProviderMark-IiAZTaQS.js","assets/provider-gHnttGKq.js","assets/useAccountEvents-CCHBF_7j.js","assets/logsLink-CEEottPg.js","assets/FilterToggle-AieL1mQy.js","assets/ProvidersPage-CNL-F1kI.js","assets/SearchBar-DXjI_cjB.js","assets/search-field-Daz5dML3.js","assets/number-field-nGZCb975.js","assets/Checkbox-5_DFnahA.js","assets/useToggle-BkQ49Unj.js","assets/EmptyPanel-Bs-jQMvG.js","assets/FormRow-Bhp_wPvH.js","assets/collection-prop-injection-CF1SevF_.js","assets/table-D-oKYYsp.js","assets/list-box-1t_n3N3P.js","assets/useHasTabbableChild-8WJt7azf.js","assets/FilterSelect-GGHAJGuF.js","assets/select-BYBzHj05.js","assets/ModelPoolPage-ARfxpk1G.js","assets/Plus.es-CSLpU0CT.js","assets/TrashSimple.es-51cVgQMz.js","assets/ConfirmDialog-D6gNei8x.js","assets/description-CNxrVc-S.js","assets/AccessPage-Drab69vZ.js","assets/CaiaiSoftLink-6tjwsEDV.js","assets/clipboard-BWzpPXn-.js","assets/tabs-CQ7Gr_Df.js","assets/LatencyStats-lecg2Ory.js","assets/AccountsPage-C7wtKWtS.js","assets/ShieldCheck.es-DReH26Zt.js","assets/account-BJHim5bc.js","assets/SystemPage-PP9VvzOw.js","assets/accordion-B-CD5Nsb.js","assets/keys-Kp99scw1.js","assets/LogsPage-BnUmENGj.js","assets/useApiKeyOptions-D6h0C_rA.js","assets/UsagePage-BgIYSNHT.js","assets/KeysPage-CzYDs0oe.js"])))=>i.map(i=>d[i]); +import{a as e,c as t,i as n,n as r,o as i}from"./shim-mfK0Rmj6.js";import{$ as a,A as o,C as s,D as c,F as l,J as u,M as d,N as f,P as p,S as m,T as h,Y as g,_,a as v,at as y,ct as b,d as x,dt as S,f as C,g as ee,h as te,it as w,j as T,l as E,lt as ne,m as re,n as D,nt as ie,o as ae,ot as oe,p as O,r as k,rt as se,s as ce,st as le,t as ue,u as A,ut as j,w as M,y as de}from"./useI18n-BBOAnu2u.js";import{$ as fe,A as pe,B as me,C as he,Ct as ge,D as _e,F as ve,G as ye,H as be,J as N,K as xe,L as Se,M as Ce,N as we,O as Te,P as Ee,Q as De,St as Oe,T as ke,U as Ae,V as je,W as Me,X as Ne,Y as Pe,Z as Fe,_t as Ie,a as Le,at as Re,b as ze,bt as Be,c as Ve,ct as He,dt as Ue,f as We,ft as Ge,h as Ke,ht as qe,i as Je,it as Ye,j as Xe,k as Ze,l as Qe,lt as $e,m as et,mt as tt,n as nt,nt as rt,o as it,p as at,pt as ot,q as st,r as ct,rt as lt,s as P,st as ut,t as dt,tt as F,u as ft,ut as pt,v as mt,w as ht,x as gt,y as _t,yt as vt,z as yt}from"./SharedElementTransition-BlCsXfb1.js";import{A as bt,F as xt,M as St,P as Ct,h as wt,j as Tt}from"./overview-CJvUvgoD.js";import{r as Et}from"./gsap-C3sDxib7.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var Dt=i((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0>>1,a=e[r];if(0>>1;ri(c,n))li(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(li(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,S||(S=!0,E());else{var t=n(l);t!==null&&D(x,t.startTime-e)}}}var S=!1,C=-1,ee=5,te=-1;function w(){return g?!0:!(e.unstable_now()-tet&&w());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&D(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?E():S=!1}}}var E;if(typeof y==`function`)E=function(){y(T)};else if(typeof MessageChannel<`u`){var ne=new MessageChannel,re=ne.port2;ne.port1.onmessage=T,E=function(){re.postMessage(null)}}else E=function(){_(T,0)};function D(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,D(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,E()))),r},e.unstable_shouldYield=w,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),Ot=i(((e,t)=>{t.exports=Dt()})),kt=i((t=>{var r=Ot(),i=e(),a=n();function o(e){var t=`https://react.dev/errors/`+e;if(1le||(e.current=ce[le],ce[le]=null,le--)}function j(e,t){le++,ce[le]=e.current,e.current=t}var M=ue(null),de=ue(null),fe=ue(null),pe=ue(null);function me(e,t){switch(j(fe,t),j(de,e),j(M,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Vd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Vd(t),e=Hd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}A(M),j(M,e)}function he(){A(M),A(de),A(fe)}function ge(e){e.memoizedState!==null&&j(pe,e);var t=M.current,n=Hd(t,e.type);t!==n&&(j(de,e),j(M,n))}function _e(e){de.current===e&&(A(M),A(de)),pe.current===e&&(A(pe),Qf._currentValue=se)}var ve,ye;function be(e){if(ve===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);ve=t&&t[1]||``,ye=-1)`:-1i||c[r]!==l[i]){var u=` +`+c[r].replace(` at new `,` at `);return e.displayName&&u.includes(``)&&(u=u.replace(``,e.displayName)),u}while(1<=r&&0<=i);break}}}finally{N=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?be(n):``}function Se(e,t){switch(e.tag){case 26:case 27:case 5:return be(e.type);case 16:return be(`Lazy`);case 13:return e.child!==t&&t!==null?be(`Suspense Fallback`):be(`Suspense`);case 19:return be(`SuspenseList`);case 0:case 15:return xe(e.type,!1);case 11:return xe(e.type.render,!1);case 1:return xe(e.type,!0);case 31:return be(`Activity`);default:return``}}function Ce(e){try{var t=``,n=null;do t+=Se(e,n),n=e,e=e.return;while(e);return t}catch(e){return` +Error generating stack: `+e.message+` +`+e.stack}}var we=Object.prototype.hasOwnProperty,Te=r.unstable_scheduleCallback,Ee=r.unstable_cancelCallback,De=r.unstable_shouldYield,Oe=r.unstable_requestPaint,ke=r.unstable_now,Ae=r.unstable_getCurrentPriorityLevel,je=r.unstable_ImmediatePriority,Me=r.unstable_UserBlockingPriority,Ne=r.unstable_NormalPriority,Pe=r.unstable_LowPriority,Fe=r.unstable_IdlePriority,Ie=r.log,Le=r.unstable_setDisableYieldValue,Re=null,ze=null;function Be(e){if(typeof Ie==`function`&&Le(e),ze&&typeof ze.setStrictMode==`function`)try{ze.setStrictMode(Re,e)}catch{}}var Ve=Math.clz32?Math.clz32:We,He=Math.log,Ue=Math.LN2;function We(e){return e>>>=0,e===0?32:31-(He(e)/Ue|0)|0}var Ge=256,Ke=262144,qe=4194304;function Je(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&261888;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function Ye(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=Je(n))):i=Je(o):i=Je(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=Je(n))):i=Je(o)):i=Je(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function Xe(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function Ze(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Qe(){var e=qe;return qe<<=1,!(qe&62914560)&&(qe=4194304),e}function $e(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function et(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function tt(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0`u`||window.document===void 0||window.document.createElement===void 0),dn=!1;if(un)try{var fn={};Object.defineProperty(fn,"passive",{get:function(){dn=!0}}),window.addEventListener(`test`,fn,fn),window.removeEventListener(`test`,fn,fn)}catch{dn=!1}var pn=null,mn=null,hn=null;function gn(){if(hn)return hn;var e,t=mn,n=t.length,r,i=`value`in pn?pn.value:pn.textContent,a=i.length;for(e=0;e=Jn),Zn=` `,Qn=!1;function $n(e,t){switch(e){case`keyup`:return Kn.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function er(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var tr=!1;function nr(e,t){switch(e){case`compositionend`:return er(t);case`keypress`:return t.which===32?(Qn=!0,Zn):null;case`textInput`:return e=t.data,e===Zn&&Qn?null:e;default:return null}}function rr(e,t){if(tr)return e===`compositionend`||!qn&&$n(e,t)?(e=gn(),hn=mn=pn=null,tr=!1,e):null;switch(e){case`paste`:return null;case`keypress`:if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1=t)return{node:n,offset:t-e};e=r}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=Tr(n)}}function Dr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Dr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Or(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Rt(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=Rt(e.document)}return t}function kr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t===`input`&&(e.type===`text`||e.type===`search`||e.type===`tel`||e.type===`url`||e.type===`password`)||t===`textarea`||e.contentEditable===`true`)}var Ar=un&&`documentMode`in document&&11>=document.documentMode,jr=null,Mr=null,Nr=null,Pr=!1;function Fr(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Pr||jr==null||jr!==Rt(r)||(r=jr,`selectionStart`in r&&kr(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Nr&&wr(Nr,r)||(Nr=r,r=Dd(Mr,`onSelect`),0>=o,i-=o,Di=1<<32-Ve(t)+i|n<h?(g=d,d=null):g=d.sibling;var _=p(i,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(i,d),o=a(_,o,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(i,d),z&&ki(i,h),l;if(d===null){for(;hg?(_=h,h=null):_=h.sibling;var y=p(i,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(i,h),s=a(y,s,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(i,h),z&&ki(i,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(i,v.value,l),v!==null&&(s=a(v,s,g),d===null?u=v:d.sibling=v,d=v);return z&&ki(i,g),u}for(h=r(h);!v.done;g++,v=c.next())v=m(h,i,g,v.value,l),v!==null&&(e&&v.alternate!==null&&h.delete(v.key===null?g:v.key),s=a(v,s,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(i,e)}),z&&ki(i,g),u}function b(e,r,a,c){if(typeof a==`object`&&a&&a.type===v&&a.key===null&&(a=a.props.children),typeof a==`object`&&a){switch(a.$$typeof){case g:a:{for(var l=a.key;r!==null;){if(r.key===l){if(l=a.type,l===v){if(r.tag===7){n(e,r.sibling),c=i(r,a.props.children),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===T&&Oa(l)===r.type){n(e,r.sibling),c=i(r,a.props),Fa(c,a),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}a.type===v?(c=mi(a.props.children,e.mode,c,a.key),c.return=e,e=c):(c=pi(a.type,a.key,a.props,null,e.mode,c),Fa(c,a),c.return=e,e=c)}return s(e);case _:a:{for(l=a.key;r!==null;){if(r.key===l){if(r.tag===4&&r.stateNode.containerInfo===a.containerInfo&&r.stateNode.implementation===a.implementation){n(e,r.sibling),c=i(r,a.children||[]),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}c=_i(a,e.mode,c),c.return=e,e=c}return s(e);case T:return a=Oa(a),b(e,r,a,c)}if(oe(a))return h(e,r,a,c);if(D(a)){if(l=D(a),typeof l!=`function`)throw Error(o(150));return a=l.call(a),y(e,r,a,c)}if(typeof a.then==`function`)return b(e,r,Pa(a),c);if(a.$$typeof===S)return b(e,r,na(e,a),c);Ia(e,a)}return typeof a==`string`&&a!==``||typeof a==`number`||typeof a==`bigint`?(a=``+a,r!==null&&r.tag===6?(n(e,r.sibling),c=i(r,a),c.return=e,e=c):(n(e,r),c=hi(a,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{Na=0;var i=b(e,t,n,r);return Ma=null,i}catch(t){if(t===Sa||t===wa)throw t;var a=li(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var Ra=La(!0),za=La(!1),Ba=!1;function Va(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function Ha(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function Ua(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function Wa(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,W&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=oi(e),ai(e,null,n),t}return ni(e,r,t,n),oi(e)}function Ga(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194048)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,rt(e,n)}}function Ka(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,callbacks:r.callbacks},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var qa=!1;function Ja(){if(qa){var e=pa;if(e!==null)throw e}}function Ya(e,t,n,r){qa=!1;var i=e.updateQueue;Ba=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var f=s.lane&-536870913,p=f!==s.lane;if(p?(q&f)===f:(r&f)===f){f!==0&&f===fa&&(qa=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});a:{var h=e,g=s;f=t;var _=n;switch(g.tag){case 1:if(h=g.payload,typeof h==`function`){d=h.call(_,d,f);break a}d=h;break a;case 3:h.flags=h.flags&-65537|128;case 0:if(h=g.payload,f=typeof h==`function`?h.call(_,d,f):h,f==null)break a;d=m({},d,f);break a;case 2:Ba=!0}}f=s.callback,f!==null&&(e.flags|=64,p&&(e.flags|=8192),p=i.callbacks,p===null?i.callbacks=[f]:p.push(f))}else p={lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=p,c=d):u=u.next=p,o|=f;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;p=s,s=p.next,p.next=null,i.lastBaseUpdate=p,i.shared.pending=null}}while(1);u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,a===null&&(i.shared.lanes=0),Kl|=o,e.lanes=o,e.memoizedState=d}}function Xa(e,t){if(typeof e!=`function`)throw Error(o(191,e));e.call(t)}function Za(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;ea?a:8;var o=O.T,s={};O.T=s,Is(e,!1,t,n);try{var c=i(),l=O.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?Fs(e,t,ga(c,r),mu(e)):Fs(e,t,r,mu(e))}catch(n){Fs(e,t,{then:function(){},status:`rejected`,reason:n},mu())}finally{k.p=a,o!==null&&s.types!==null&&(o.types=s.types),O.T=o}}function Ts(){}function Es(e,t,n,r){if(e.tag!==5)throw Error(o(476));var i=Ds(e).queue;ws(e,i,t,se,n===null?Ts:function(){return Os(e),n(r)})}function Ds(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:se,baseState:se,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Lo,lastRenderedState:se},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:Lo,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function Os(e){var t=Ds(e);t.next===null&&(t=e.alternate.memoizedState),Fs(e,t.next.queue,{},mu())}function ks(){return ta(Qf)}function As(){return Mo().memoizedState}function js(){return Mo().memoizedState}function Ms(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=mu();e=Ua(n);var r=Wa(t,e,n);r!==null&&(gu(r,t,n),Ga(r,t,n)),t={cache:ca()},e.payload=t;return}t=t.return}}function Ns(e,t,n){var r=mu();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},Ls(e)?Rs(t,n):(n=ri(e,t,n,r),n!==null&&(gu(n,e,r),zs(n,t,r)))}function Ps(e,t,n){Fs(e,t,n,mu())}function Fs(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(Ls(e))Rs(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,Cr(s,o))return ni(e,t,i,0),G===null&&ti(),!1}catch{}if(n=ri(e,t,i,r),n!==null)return gu(n,e,r),zs(n,t,r),!0}return!1}function Is(e,t,n,r){if(r={lane:2,revertLane:fd(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},Ls(e)){if(t)throw Error(o(479))}else t=ri(e,n,r,2),t!==null&&gu(t,e,2)}function Ls(e){var t=e.alternate;return e===B||t!==null&&t===B}function Rs(e,t){go=ho=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function zs(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,rt(e,n)}}var Bs={readContext:ta,use:Fo,useCallback:So,useContext:So,useEffect:So,useImperativeHandle:So,useLayoutEffect:So,useInsertionEffect:So,useMemo:So,useReducer:So,useRef:So,useState:So,useDebugValue:So,useDeferredValue:So,useTransition:So,useSyncExternalStore:So,useId:So,useHostTransitionStatus:So,useFormState:So,useActionState:So,useOptimistic:So,useMemoCache:So,useCacheRefresh:So};Bs.useEffectEvent=So;var Vs={readContext:ta,use:Fo,useCallback:function(e,t){return jo().memoizedState=[e,t===void 0?null:t],e},useContext:ta,useEffect:ds,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),ls(4194308,4,_s.bind(null,t,e),n)},useLayoutEffect:function(e,t){return ls(4194308,4,e,t)},useInsertionEffect:function(e,t){ls(4,2,e,t)},useMemo:function(e,t){var n=jo();t=t===void 0?null:t;var r=e();if(_o){Be(!0);try{e()}finally{Be(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=jo();if(n!==void 0){var i=n(t);if(_o){Be(!0);try{n(t)}finally{Be(!1)}}}else i=t;return r.memoizedState=r.baseState=i,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},r.queue=e,e=e.dispatch=Ns.bind(null,B,e),[r.memoizedState,e]},useRef:function(e){var t=jo();return e={current:e},t.memoizedState=e},useState:function(e){e=qo(e);var t=e.queue,n=Ps.bind(null,B,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:ys,useDeferredValue:function(e,t){return Ss(jo(),e,t)},useTransition:function(){var e=qo(!1);return e=ws.bind(null,B,e.queue,!0,!1),jo().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=B,i=jo();if(z){if(n===void 0)throw Error(o(407));n=n()}else{if(n=t(),G===null)throw Error(o(349));q&127||Ho(r,t,n)}i.memoizedState=n;var a={value:n,getSnapshot:t};return i.queue=a,ds(Wo.bind(null,r,a,e),[e]),r.flags|=2048,ss(9,{destroy:void 0},Uo.bind(null,r,a,n,t),null),n},useId:function(){var e=jo(),t=G.identifierPrefix;if(z){var n=Oi,r=Di;n=(r&~(1<<32-Ve(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=vo++,0<\/script>`,a=a.removeChild(a.firstChild);break;case`select`:a=typeof r.is==`string`?s.createElement(`select`,{is:r.is}):s.createElement(`select`),r.multiple?a.multiple=!0:r.size&&(a.size=r.size);break;default:a=typeof r.is==`string`?s.createElement(i,{is:r.is}):s.createElement(i)}}a[P]=t,a[ut]=r;a:for(s=t.child;s!==null;){if(s.tag===5||s.tag===6)a.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break a;for(;s.sibling===null;){if(s.return===null||s.return===t)break a;s=s.return}s.sibling.return=s.return,s=s.sibling}t.stateNode=a;a:switch(Pd(a,i,r),i){case`button`:case`input`:case`select`:case`textarea`:r=!!r.autoFocus;break a;case`img`:r=!0;break a;default:r=!1}r&&Fc(t)}}return H(t),Ic(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&Fc(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(o(166));if(e=fe.current,Vi(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,i=Pi,i!==null)switch(i.tag){case 27:case 5:r=i.memoizedProps}e[P]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||Q(e.nodeValue,n)),e||Ri(t,!0)}else e=Bd(e).createTextNode(r),e[P]=t,t.stateNode=e}return H(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=Vi(t),n!==null){if(e===null){if(!r)throw Error(o(318));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(o(557));e[P]=t}else Hi(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;H(t),e=!1}else n=Ui(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(lo(t),t):(lo(t),null);if(t.flags&128)throw Error(o(558))}return H(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(i=Vi(t),r!==null&&r.dehydrated!==null){if(e===null){if(!i)throw Error(o(318));if(i=t.memoizedState,i=i===null?null:i.dehydrated,!i)throw Error(o(317));i[P]=t}else Hi(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;H(t),i=!1}else i=Ui(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=i),i=!0;if(!i)return t.flags&256?(lo(t),t):(lo(t),null)}return lo(t),t.flags&128?(t.lanes=n,t):(n=r!==null,e=e!==null&&e.memoizedState!==null,n&&(r=t.child,i=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(i=r.alternate.memoizedState.cachePool.pool),a=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(a=r.memoizedState.cachePool.pool),a!==i&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),Rc(t,t.updateQueue),H(t),null);case 4:return he(),e===null&&Cd(t.stateNode.containerInfo),H(t),null;case 10:return Yi(t.type),H(t),null;case 19:if(A(uo),r=t.memoizedState,r===null)return H(t),null;if(i=!!(t.flags&128),a=r.rendering,a===null){if(i)zc(r,!1);else{if(Gl!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(a=fo(e),a!==null){for(t.flags|=128,zc(r,!1),e=a.updateQueue,t.updateQueue=e,Rc(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)fi(n,e),n=n.sibling;return j(uo,uo.current&1|2),z&&ki(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&ke()>nu&&(t.flags|=128,i=!0,zc(r,!1),t.lanes=4194304)}}else{if(!i){if(e=fo(a),e!==null){if(t.flags|=128,i=!0,e=e.updateQueue,t.updateQueue=e,Rc(t,e),zc(r,!0),r.tail===null&&r.tailMode===`hidden`&&!a.alternate&&!z)return H(t),null}else 2*ke()-r.renderingStartTime>nu&&n!==536870912&&(t.flags|=128,i=!0,zc(r,!1),t.lanes=4194304)}r.isBackwards?(a.sibling=t.child,t.child=a):(e=r.last,e===null?t.child=a:e.sibling=a,r.last=a)}return r.tail===null?(H(t),null):(e=r.tail,r.rendering=e,r.tail=e.sibling,r.renderingStartTime=ke(),e.sibling=null,n=uo.current,j(uo,i?n&1|2:n&1),z&&ki(t,r.treeForkCount),e);case 22:case 23:return lo(t),no(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(H(t),t.subtreeFlags&6&&(t.flags|=8192)):H(t),n=t.updateQueue,n!==null&&Rc(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),r=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),e!==null&&A(va),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),Yi(sa),H(t),null;case 25:return null;case 30:return null}throw Error(o(156,t.tag))}function Vc(e,t){switch(Mi(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Yi(sa),he(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return _e(t),null;case 31:if(t.memoizedState!==null){if(lo(t),t.alternate===null)throw Error(o(340));Hi()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(lo(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(o(340));Hi()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return A(uo),null;case 4:return he(),null;case 10:return Yi(t.type),null;case 22:case 23:return lo(t),no(),e!==null&&A(va),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return Yi(sa),null;case 25:return null;default:return null}}function Hc(e,t){switch(Mi(t),t.tag){case 3:Yi(sa),he();break;case 26:case 27:case 5:_e(t);break;case 4:he();break;case 31:t.memoizedState!==null&&lo(t);break;case 13:lo(t);break;case 19:A(uo);break;case 10:Yi(t.type);break;case 22:case 23:lo(t),no(),e!==null&&A(va);break;case 24:Yi(sa)}}function Uc(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){X(t,t.return,e)}}function Wc(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){X(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){X(t,t.return,e)}}function Gc(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{Za(t,n)}catch(t){X(e,e.return,t)}}}function Kc(e,t,n){n.props=Js(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){X(e,t,n)}}function qc(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;case 30:r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){X(e,t,n)}}function Jc(e,t){var n=e.ref,r=e.refCleanup;if(n!==null){if(typeof r==`function`)try{r()}catch(n){X(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){X(e,t,n)}else n.current=null}}function Yc(e){var t=e.type,n=e.memoizedProps,r=e.stateNode;try{a:switch(t){case`button`:case`input`:case`select`:case`textarea`:n.autoFocus&&r.focus();break a;case`img`:n.src?r.src=n.src:n.srcSet&&(r.srcset=n.srcSet)}}catch(t){X(e,e.return,t)}}function Xc(e,t,n){try{var r=e.stateNode;Fd(r,e.type,n,t),r[ut]=t}catch(t){X(e,e.return,t)}}function Zc(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Zd(e.type)||e.tag===4}function Qc(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||Zc(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&Zd(e.type)||e.flags&2||e.child===null||e.tag===4)continue a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function $c(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?(n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n).insertBefore(e,t):(t=n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n,t.appendChild(e),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=en));else if(r!==4&&(r===27&&Zd(e.type)&&(n=e.stateNode,t=null),e=e.child,e!==null))for($c(e,t,n),e=e.sibling;e!==null;)$c(e,t,n),e=e.sibling}function el(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(r===27&&Zd(e.type)&&(n=e.stateNode),e=e.child,e!==null))for(el(e,t,n),e=e.sibling;e!==null;)el(e,t,n),e=e.sibling}function tl(e){var t=e.stateNode,n=e.memoizedProps;try{for(var r=e.type,i=t.attributes;i.length;)t.removeAttributeNode(i[0]);Pd(t,r,n),t[P]=e,t[ut]=n}catch(t){X(e,e.return,t)}}var nl=!1,rl=!1,il=!1,al=typeof WeakSet==`function`?WeakSet:Set,ol=null;function sl(e,t){if(e=e.containerInfo,Rd=sp,e=Or(e),kr(e)){if(`selectionStart`in e)var n={start:e.selectionStart,end:e.selectionEnd};else a:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var i=r.anchorOffset,a=r.focusNode;r=r.focusOffset;try{n.nodeType,a.nodeType}catch{n=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==n||i!==0&&f.nodeType!==3||(c=s+i),f!==a||r!==0&&f.nodeType!==3||(l=s+r),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===n&&++u===i&&(c=s),p===a&&++d===r&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}n=c===-1||l===-1?null:{start:c,end:l}}else n=null}n||={start:0,end:0}}else n=null;for(zd={focusedElem:e,selectionRange:n},sp=!1,ol=t;ol!==null;)if(t=ol,e=t.child,t.subtreeFlags&1028&&e!==null)e.return=t,ol=e;else for(;ol!==null;){switch(t=ol,a=t.alternate,e=t.flags,t.tag){case 0:if(e&4&&(e=t.updateQueue,e=e===null?null:e.events,e!==null))for(n=0;n title`))),Pd(a,r,n),a[P]=e,xt(a),r=a;break a;case`link`:var s=Vf(`link`,`href`,i).get(r+(n.href||``));if(s){for(var c=0;cg&&(o=g,g=h,h=o);var _=Er(s,h),v=Er(s,g);if(_&&v&&(p.rangeCount!==1||p.anchorNode!==_.node||p.anchorOffset!==_.offset||p.focusNode!==v.node||p.focusOffset!==v.offset)){var y=d.createRange();y.setStart(_.node,_.offset),p.removeAllRanges(),h>g?(p.addRange(y),p.extend(v.node,v.offset)):(y.setEnd(v.node,v.offset),p.addRange(y))}}}}for(d=[],p=s;p=p.parentNode;)p.nodeType===1&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof s.focus==`function`&&s.focus(),s=0;sn?32:n,O.T=null,n=uu,uu=null;var a=ou,s=cu;if(au=0,su=ou=null,cu=0,W&6)throw Error(o(331));var c=W;if(W|=4,Il(a.current),Ol(a,a.current,s,n),W=c,ad(0,!1),ze&&typeof ze.onPostCommitFiberRoot==`function`)try{ze.onPostCommitFiberRoot(Re,a)}catch{}return!0}finally{k.p=i,O.T=r,Hu(e,t)}}function Gu(e,t,n){t=yi(n,t),t=ec(e.stateNode,t,2),e=Wa(e,t,2),e!==null&&(et(e,2),id(e))}function X(e,t,n){if(e.tag===3)Gu(e,e,n);else for(;t!==null;){if(t.tag===3){Gu(t,e,n);break}if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(iu===null||!iu.has(r))){e=yi(n,e),n=tc(2),r=Wa(t,n,2),r!==null&&(nc(n,r,t,e),et(r,2),id(r));break}}t=t.return}}function Ku(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new Bl;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(Y=!0,i.add(n),e=qu.bind(null,e,t,n),t.then(e,e))}function qu(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,G===e&&(q&n)===n&&(Gl===4||Gl===3&&(q&62914560)===q&&300>ke()-eu?!(W&2)&&Cu(e,0):Jl|=n,Xl===q&&(Xl=0)),id(e)}function Ju(e,t){t===0&&(t=Qe()),e=ii(e,t),e!==null&&(et(e,t),id(e))}function Yu(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Ju(e,n)}function Xu(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,i=e.memoizedState;i!==null&&(n=i.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(o(314))}r!==null&&r.delete(t),Ju(e,n)}function Zu(e,t){return Te(e,t)}var Qu=null,$u=null,ed=!1,td=!1,nd=!1,rd=0;function id(e){e!==$u&&e.next===null&&($u===null?Qu=$u=e:$u=$u.next=e),td=!0,ed||(ed=!0,dd())}function ad(e,t){if(!nd&&td){nd=!0;do for(var n=!1,r=Qu;r!==null;){if(!t){if(e!==0){var i=r.pendingLanes;if(i===0)var a=0;else{var o=r.suspendedLanes,s=r.pingedLanes;a=(1<<31-Ve(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,ud(r,a))}else a=q,a=Ye(r,r===G?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||Xe(r,a)||(n=!0,ud(r,a))}r=r.next}while(n);nd=!1}}function od(){sd()}function sd(){td=ed=!1;var e=0;rd!==0&&Gd()&&(e=rd);for(var t=ke(),n=null,r=Qu;r!==null;){var i=r.next,a=cd(r,t);a===0?(r.next=null,n===null?Qu=i:n.next=i,i===null&&($u=n)):(n=r,(e!==0||a&3)&&(td=!0)),r=i}au!==0&&au!==5||ad(e,!1),rd!==0&&(rd=0)}function cd(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0s)break;var u=c.transferSize,d=c.initiatorType;u&&Id(d)&&(c=c.responseEnd,o+=u*(c`u`?null:document;function xf(e,t,n){var r=bf;if(r&&typeof t==`string`&&t){var i=Bt(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),hf.has(i)||(hf.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),Pd(t,`link`,e),xt(t),r.head.appendChild(t)))}}function Sf(e){_f.D(e),xf(`dns-prefetch`,e,null)}function Cf(e,t){_f.C(e,t),xf(`preconnect`,e,t)}function wf(e,t,n){_f.L(e,t,n);var r=bf;if(r&&e&&t){var i=`link[rel="preload"][as="`+Bt(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+Bt(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+Bt(n.imageSizes)+`"]`)):i+=`[href="`+Bt(e)+`"]`;var a=i;switch(t){case`style`:a=Af(e);break;case`script`:a=Pf(e)}mf.has(a)||(e=m({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),mf.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(jf(a))||t===`script`&&r.querySelector(Ff(a))||(t=r.createElement(`link`),Pd(t,`link`,e),xt(t),r.head.appendChild(t)))}}function Tf(e,t){_f.m(e,t);var n=bf;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+Bt(r)+`"][href="`+Bt(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Pf(e)}if(!mf.has(a)&&(e=m({rel:`modulepreload`,href:e},t),mf.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(Ff(a)))return}r=n.createElement(`link`),Pd(r,`link`,e),xt(r),n.head.appendChild(r)}}}function Ef(e,t,n){_f.S(e,t,n);var r=bf;if(r&&e){var i=bt(r).hoistableStyles,a=Af(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(jf(a)))s.loading=5;else{e=m({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=mf.get(a))&&Rf(e,n);var c=o=r.createElement(`link`);xt(c),Pd(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Lf(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function Df(e,t){_f.X(e,t);var n=bf;if(n&&e){var r=bt(n).hoistableScripts,i=Pf(e),a=r.get(i);a||(a=n.querySelector(Ff(i)),a||(e=m({src:e,async:!0},t),(t=mf.get(i))&&zf(e,t),a=n.createElement(`script`),xt(a),Pd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Of(e,t){_f.M(e,t);var n=bf;if(n&&e){var r=bt(n).hoistableScripts,i=Pf(e),a=r.get(i);a||(a=n.querySelector(Ff(i)),a||(e=m({src:e,async:!0,type:`module`},t),(t=mf.get(i))&&zf(e,t),a=n.createElement(`script`),xt(a),Pd(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function kf(e,t,n,r){var i=(i=fe.current)?gf(i):null;if(!i)throw Error(o(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(t=Af(n.href),n=bt(i).hoistableStyles,r=n.get(t),r||(r={type:`style`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Af(n.href);var a=bt(i).hoistableStyles,s=a.get(e);if(s||(i=i.ownerDocument||i,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},a.set(e,s),(a=i.querySelector(jf(e)))&&!a._p&&(s.instance=a,s.state.loading=5),mf.has(e)||(n={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},mf.set(e,n),a||Nf(i,e,n,s.state))),t&&r===null)throw Error(o(528,``));return s}if(t&&r!==null)throw Error(o(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(t=Pf(n),n=bt(i).hoistableScripts,r=n.get(t),r||(r={type:`script`,instance:null,count:0,state:null},n.set(t,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(o(444,e))}}function Af(e){return`href="`+Bt(e)+`"`}function jf(e){return`link[rel="stylesheet"][`+e+`]`}function Mf(e){return m({},e,{"data-precedence":e.precedence,precedence:null})}function Nf(e,t,n,r){e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)?r.loading=1:(t=e.createElement(`link`),r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2}),Pd(t,`link`,n),xt(t),e.head.appendChild(t))}function Pf(e){return`[src="`+Bt(e)+`"]`}function Ff(e){return`script[async]`+e}function If(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+Bt(n.href)+`"]`);if(r)return t.instance=r,xt(r),r;var i=m({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),xt(r),Pd(r,`style`,i),Lf(r,n.precedence,e),t.instance=r;case`stylesheet`:i=Af(n.href);var a=e.querySelector(jf(i));if(a)return t.state.loading|=4,t.instance=a,xt(a),a;r=Mf(n),(i=mf.get(i))&&Rf(r,i),a=(e.ownerDocument||e).createElement(`link`),xt(a);var s=a;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),Pd(a,`link`,r),t.state.loading|=4,Lf(a,n.precedence,e),t.instance=a;case`script`:return a=Pf(n.src),(i=e.querySelector(Ff(a)))?(t.instance=i,xt(i),i):(r=n,(i=mf.get(a))&&(r=m({},n),zf(r,i)),e=e.ownerDocument||e,i=e.createElement(`script`),xt(i),Pd(i,`link`,r),e.head.appendChild(i),t.instance=i);case`void`:return null;default:throw Error(o(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Lf(r,n.precedence,e));return t.instance}function Lf(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o title`):null)}function Uf(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function Wf(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function Gf(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Af(r.href),a=t.querySelector(jf(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=Jf.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,xt(a);return}a=t.ownerDocument||t,r=Mf(r),(i=mf.get(i))&&Rf(r,i),a=a.createElement(`link`),xt(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),Pd(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=Jf.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var Kf=0;function qf(e,t){return e.stylesheets&&e.count===0&&Xf(e,e.stylesheets),0Kf?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function Jf(){if(this.count--,this.count===0&&(this.imgCount===0||!this.waitingForImages)){if(this.stylesheets)Xf(this,this.stylesheets);else if(this.unsuspend){var e=this.unsuspend;this.unsuspend=null,e()}}}var Yf=null;function Xf(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,Yf=new Map,t.forEach(Zf,e),Yf=null,Jf.call(e))}function Zf(e,t){if(!(t.state.loading&4)){var n=Yf.get(e);if(n)var r=n.get(null);else{n=new Map,Yf.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=kt()})),I=t(e(),1),jt=At(),Mt=`modulepreload`,Nt=function(e){return`/`+e},Pt={},Ft=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e=document.getElementsByTagName(`link`),i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?import.meta.resolve(e):new URL(e,import.meta.url).href}r=o(t.map(t=>{if(t=Nt(t,n),t=s(t),t in Pt)return;Pt[t]=!0;let r=t.endsWith(`.css`);for(let n=e.length-1;n>=0;n--){let i=e[n];if(i.href===t&&(!r||i.rel===`stylesheet`))return}let i=document.createElement(`link`);if(i.rel=r?`stylesheet`:Mt,r||(i.as=`script`),i.crossOrigin=``,i.href=t,a&&i.setAttribute(`nonce`,a),document.head.appendChild(i),r)return new Promise((e,n)=>{i.addEventListener(`load`,e),i.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${t}`)))})}))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})},It=/^(?:[a-z][a-z0-9+.-]*:|[\\/]{2})/i,Lt=/^[\\/]{2}/;function Rt(e,t){return t+e.replace(/\\/g,`/`)}var zt=`popstate`;function Bt(e){return typeof e==`object`&&!!e&&`pathname`in e&&`search`in e&&`hash`in e&&`state`in e&&`key`in e}function Vt(e={}){function t(e,t){let n=t.state?.masked,{pathname:r,search:i,hash:a}=n||e.location;return Gt(``,{pathname:r,search:i,hash:a},t.state&&t.state.usr||null,t.state&&t.state.key||`default`,n?{pathname:e.location.pathname,search:e.location.search,hash:e.location.hash}:void 0)}function n(e,t){return typeof t==`string`?t:Kt(t)}return Jt(t,n,null,e)}function L(e,t){if(e===!1||e==null)throw Error(t)}function Ht(e,t){if(!e){typeof console<`u`&&console.warn(t);try{throw Error(t)}catch{}}}function Ut(){return Math.random().toString(36).substring(2,10)}function Wt(e,t){return{usr:e.state,key:e.key,idx:t,masked:e.mask?{pathname:e.pathname,search:e.search,hash:e.hash}:void 0}}function Gt(e,t,n=null,r,i){return{pathname:typeof e==`string`?e:e.pathname,search:``,hash:``,...typeof t==`string`?qt(t):t,state:n,key:t&&t.key||r||Ut(),mask:i}}function Kt({pathname:e=`/`,search:t=``,hash:n=``}){return t&&t!==`?`&&(e+=t.charAt(0)===`?`?t:`?`+t),n&&n!==`#`&&(e+=n.charAt(0)===`#`?n:`#`+n),e}function qt(e){let t={};if(e){let n=e.indexOf(`#`);n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf(`?`);r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function Jt(e,t,n,r={}){let{window:i=document.defaultView,v5Compat:a=!1}=r,o=i.history,s=`POP`,c=null,l=u();l??(l=0,o.replaceState({...o.state,idx:l},``));function u(){return(o.state||{idx:null}).idx}function d(){s=`POP`;let e=u(),t=e==null?null:e-l;l=e,c&&c({action:s,location:h.location,delta:t})}function f(e,t){s=`PUSH`;let r=Bt(e)?e:Gt(h.location,e,t);n&&n(r,e),l=u()+1;let d=Wt(r,l),f=h.createHref(r.mask||r);try{o.pushState(d,``,f)}catch(e){if(e instanceof DOMException&&e.name===`DataCloneError`)throw e;i.location.assign(f)}a&&c&&c({action:s,location:h.location,delta:1})}function p(e,t){s=`REPLACE`;let r=Bt(e)?e:Gt(h.location,e,t);n&&n(r,e),l=u();let i=Wt(r,l),d=h.createHref(r.mask||r);o.replaceState(i,``,d),a&&c&&c({action:s,location:h.location,delta:0})}function m(e){return Yt(i,e)}let h={get action(){return s},get location(){return e(i,o)},listen(e){if(c)throw Error(`A history only accepts one active listener`);return i.addEventListener(zt,d),c=e,()=>{i.removeEventListener(zt,d),c=null}},createHref(e){return t(i,e)},createURL:m,encodeLocation(e){let t=m(e);return{pathname:t.pathname,search:t.search,hash:t.hash}},push:f,replace:p,go(e){return o.go(e)}};return h}function Yt(e,t,n=!1){let r=`http://localhost`;e&&(r=e.location.origin===`null`?e.location.href:e.location.origin),L(r,`No window.location.(origin|href) available to create URL`);let i=typeof t==`string`?t:Kt(t);return i=i.replace(/ $/,`%20`),!n&&Lt.test(i)&&(i=r+i),new URL(i,r)}function Xt(e,t,n=`/`){return Zt(e,t,n,!1)}function Zt(e,t,n,r,i){let a=_n((typeof t==`string`?qt(t):t).pathname||`/`,n);if(a==null)return null;let o=i??Qt(e),s=null,c=gn(a);for(let e=0;s==null&&e{let c={relativePath:s===void 0?e.path||``:s,caseSensitive:e.caseSensitive===!0,childrenIndex:a,route:e};if(c.relativePath.startsWith(`/`)){if(!c.relativePath.startsWith(r)&&o)return;L(c.relativePath.startsWith(r),`Absolute route path "${c.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),c.relativePath=c.relativePath.slice(r.length)}let l=Tn([r,c.relativePath]),u=n.concat(c);e.children&&e.children.length>0&&(L(e.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${l}".`),$t(e.children,t,u,l,o)),!(e.path==null&&!e.index)&&t.push({path:l,score:un(l,e.index),routesMeta:u.map((e,t)=>{let[n,r]=hn(e.relativePath,e.caseSensitive,t===u.length-1);return{...e,matcher:n,compiledParams:r}})})};return e.forEach((e,t)=>{if(e.path===``||!e.path?.includes(`?`))a(e,t);else for(let n of en(e.path))a(e,t,!0,n)}),t}function en(e){let t=e.split(`/`);if(t.length===0)return[];let[n,...r]=t,i=n.endsWith(`?`),a=n.replace(/\?$/,``);if(r.length===0)return i?[a,``]:[a];let o=en(r.join(`/`)),s=[];return s.push(...o.map(e=>e===``?a:[a,e].join(`/`))),i&&s.push(...o),s.map(t=>e.startsWith(`/`)&&t===``?`/`:t)}function tn(e){e.sort((e,t)=>e.score===t.score?dn(e.routesMeta.map(e=>e.childrenIndex),t.routesMeta.map(e=>e.childrenIndex)):t.score-e.score)}var nn=/^:[\w-]+$/,rn=3,an=2,on=1,sn=10,cn=-2,ln=e=>e===`*`;function un(e,t){let n=e.split(`/`),r=n.length;return n.some(ln)&&(r+=cn),t&&(r+=an),n.filter(e=>!ln(e)).reduce((e,t)=>e+(nn.test(t)?rn:t===``?on:sn),r)}function dn(e,t){return e.length===t.length&&e.slice(0,-1).every((e,n)=>e===t[n])?e[e.length-1]-t[t.length-1]:0}function fn(e,t,n=!1){let{routesMeta:r}=e,i={},a=`/`,o=[];for(let e=0;e{if(t===`*`){let e=s[r]||``;o=a.slice(0,a.length-e.length).replace(/(.)\/+$/,`$1`)}let i=s[r];return e[t]=n&&!i?void 0:(i||``).replace(/%2F/g,`/`),e},{}),pathname:a,pathnameBase:o,pattern:e}}function hn(e,t=!1,n=!0){Ht(e===`*`||!e.endsWith(`*`)||e.endsWith(`/*`),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,`/*`)}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,`/*`)}".`);let r=[],i=`^`+e.replace(/\/*\*?$/,``).replace(/^\/*/,`/`).replace(/[\\.*+^${}|()[\]]/g,`\\$&`).replace(/\/:([\w-]+)(\?)?/g,(e,t,n,i,a)=>{if(r.push({paramName:t,isOptional:n!=null}),n){let t=a.charAt(i+e.length);return t&&t!==`/`?`/([^\\/]*)`:`(?:/([^\\/]*))?`}return`/([^\\/]+)`}).replace(/\/([\w-]+)\?(\/|$)/g,`(/$1)?$2`);return e.endsWith(`*`)?(r.push({paramName:`*`}),i+=e===`*`||e===`/*`?`(.*)$`:`(?:\\/(.+)|\\/*)$`):n?i+=`\\/*$`:e!==``&&e!==`/`&&(i+=`(?:(?=\\/|$))`),[new RegExp(i,t?void 0:`i`),r]}function gn(e){try{return e.split(`/`).map(e=>decodeURIComponent(e).replace(/\//g,`%2F`)).join(`/`)}catch(t){return Ht(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function _n(e,t){if(t===`/`)return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith(`/`)?t.length-1:t.length,r=e.charAt(n);return r&&r!==`/`?null:e.slice(n)||`/`}function vn(e,t=`/`){let{pathname:n,search:r=``,hash:i=``}=typeof e==`string`?qt(e):e,a;return n?(n=wn(n),a=n.startsWith(`/`)?yn(n.substring(1),`/`):yn(n,t)):a=t,{pathname:a,search:On(r),hash:kn(i)}}function yn(e,t){let n=En(t).split(`/`);return e.split(`/`).forEach(e=>{e===`..`?n.length>1&&n.pop():e!==`.`&&n.push(e)}),n.length>1?n.join(`/`):`/`}function bn(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in and the router will parse it for you.`}function xn(e){return e.filter((e,t)=>t===0||e.route.path&&e.route.path.length>0)}function Sn(e){let t=xn(e);return t.map((e,n)=>n===t.length-1?e.pathname:e.pathnameBase)}function Cn(e,t,n,r=!1){let i;typeof e==`string`?i=qt(e):(i={...e},L(!i.pathname||!i.pathname.includes(`?`),bn(`?`,`pathname`,`search`,i)),L(!i.pathname||!i.pathname.includes(`#`),bn(`#`,`pathname`,`hash`,i)),L(!i.search||!i.search.includes(`#`),bn(`#`,`search`,`hash`,i)));let a=e===``||i.pathname===``,o=a?`/`:i.pathname,s;if(o==null)s=n;else{let e=t.length-1;if(!r&&o.startsWith(`..`)){let t=o.split(`/`);for(;t[0]===`..`;)t.shift(),--e;i.pathname=t.join(`/`)}s=e>=0?t[e]:`/`}let c=vn(i,s),l=o&&o!==`/`&&o.endsWith(`/`),u=(a||o===`.`)&&n.endsWith(`/`);return!c.pathname.endsWith(`/`)&&(l||u)&&(c.pathname+=`/`),c}var wn=e=>e.replace(/[\\/]{2,}/g,`/`),Tn=e=>wn(e.join(`/`)),En=e=>e.replace(/\/+$/,``),Dn=e=>En(e).replace(/^\/*/,`/`),On=e=>!e||e===`?`?``:e.startsWith(`?`)?e:`?`+e,kn=e=>!e||e===`#`?``:e.startsWith(`#`)?e:`#`+e,An=class{constructor(e,t,n,r=!1){this.status=e,this.statusText=t||``,this.internal=r,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function jn(e){return e!=null&&typeof e.status==`number`&&typeof e.statusText==`string`&&typeof e.internal==`boolean`&&`data`in e}function Mn(e){return Tn(e.map(e=>e.route.path).filter(Boolean))||`/`}var Nn=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function Pn(e,t){let n=e;if(typeof n!=`string`||!It.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,i=!1;if(Nn)try{let e=new URL(window.location.href),r=Lt.test(n)?new URL(Rt(n,e.protocol)):new URL(n),a=_n(r.pathname,t);r.origin===e.origin&&a!=null?n=a+r.search+r.hash:i=!0}catch{Ht(!1,` contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:i,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join(`\0`);var Fn=[`POST`,`PUT`,`PATCH`,`DELETE`];new Set(Fn);var In=[`GET`,...Fn];new Set(In);var Ln=[`about:`,`blob:`,`chrome:`,`chrome-untrusted:`,`content:`,`data:`,`devtools:`,`file:`,`filesystem:`,`javascript:`];function Rn(e){try{return Ln.includes(new URL(e).protocol)}catch{return!1}}var zn=I.createContext(null);zn.displayName=`DataRouter`;var Bn=I.createContext(null);Bn.displayName=`DataRouterState`;var Vn=I.createContext(!1);function Hn(){return I.useContext(Vn)}var Un=I.createContext({isTransitioning:!1});Un.displayName=`ViewTransition`;var Wn=I.createContext(new Map);Wn.displayName=`Fetchers`;var Gn=I.createContext(null);Gn.displayName=`Await`;var Kn=I.createContext(null);Kn.displayName=`Navigation`;var qn=I.createContext(null);qn.displayName=`Location`;var Jn=I.createContext({outlet:null,matches:[],isDataRoute:!1});Jn.displayName=`Route`;var Yn=I.createContext(null);Yn.displayName=`RouteError`;var Xn=`REACT_ROUTER_ERROR`,Zn=`REDIRECT`,Qn=`ROUTE_ERROR_RESPONSE`;function $n(e){if(e.startsWith(`${Xn}:${Zn}:{`))try{let t=JSON.parse(e.slice(28));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`&&typeof t.location==`string`&&typeof t.reloadDocument==`boolean`&&typeof t.replace==`boolean`)return t}catch{}}function er(e){if(e.startsWith(`${Xn}:${Qn}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t==`object`&&t&&typeof t.status==`number`&&typeof t.statusText==`string`)return new An(t.status,t.statusText,t.data)}catch{}}function tr(e,{relative:t}={}){L(nr(),`useHref() may be used only in the context of a component.`);let{basename:n,navigator:r}=I.useContext(Kn),{hash:i,pathname:a,search:o}=ur(e,{relative:t}),s=a;return n!==`/`&&(s=a===`/`?n:Tn([n,a])),r.createHref({pathname:s,search:o,hash:i})}function nr(){return I.useContext(qn)!=null}function rr(){return L(nr(),`useLocation() may be used only in the context of a component.`),I.useContext(qn).location}var ir=`You should call navigate() in a React.useEffect(), not when your component is first rendered.`;function ar(e){I.useContext(Kn).static||I.useLayoutEffect(e)}function or(){let{isDataRoute:e}=I.useContext(Jn);return e?Dr():sr()}function sr(){L(nr(),`useNavigate() may be used only in the context of a component.`);let e=I.useContext(zn),{basename:t,navigator:n}=I.useContext(Kn),{matches:r}=I.useContext(Jn),{pathname:i}=rr(),a=JSON.stringify(Sn(r)),o=I.useRef(!1);return ar(()=>{o.current=!0}),I.useCallback((r,s={})=>{if(Ht(o.current,ir),!o.current)return;if(typeof r==`number`){n.go(r);return}let c=Cn(r,JSON.parse(a),i,s.relative===`path`);e==null&&t!==`/`&&(c.pathname=c.pathname===`/`?t:Tn([t,c.pathname])),(s.replace?n.replace:n.push)(c,s.state,s)},[t,n,a,i,e])}var cr=I.createContext(null);function lr(e){let t=I.useContext(Jn).outlet;return I.useMemo(()=>t&&I.createElement(cr.Provider,{value:e},t),[t,e])}function ur(e,{relative:t}={}){let{matches:n}=I.useContext(Jn),{pathname:r}=rr(),i=JSON.stringify(Sn(n));return I.useMemo(()=>Cn(e,JSON.parse(i),r,t===`path`),[e,i,r,t])}function dr(e,t){return fr(e,t)}function fr(e,t,n){L(nr(),`useRoutes() may be used only in the context of a component.`);let{navigator:r}=I.useContext(Kn),{matches:i}=I.useContext(Jn),a=i[i.length-1],o=a?a.params:{},s=a?a.pathname:`/`,c=a?a.pathnameBase:`/`,l=a&&a.route;{let e=l&&l.path||``;kr(s,!l||e.endsWith(`*`)||e.endsWith(`*?`),`You rendered descendant (or called \`useRoutes()\`) at "${s}" (under ) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render. + +Please change the parent to .`)}let u=rr(),d;if(t){let e=typeof t==`string`?qt(t):t;L(c===`/`||e.pathname?.startsWith(c),`When overriding the location using \`\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${c}" but pathname "${e.pathname}" was given in the \`location\` prop.`),d=e}else d=u;let f=d.pathname||`/`,p=f;if(c!==`/`){let e=c.replace(/^\//,``).split(`/`);p=`/`+f.replace(/^\//,``).split(`/`).slice(e.length).join(`/`)}let m=n&&n.state.matches.length?n.state.matches.map(e=>Object.assign(e,{route:n.manifest[e.route.id]||e.route})):Xt(e,{pathname:p});Ht(l||m!=null,`No routes matched location "${d.pathname}${d.search}${d.hash}" `),Ht(m==null||m[m.length-1].route.element!==void 0||m[m.length-1].route.Component!==void 0||m[m.length-1].route.lazy!==void 0,`Matched leaf route at location "${d.pathname}${d.search}${d.hash}" does not have an element or Component. This means it will render an with a null value by default resulting in an "empty" page.`);let h=yr(m&&m.map(e=>Object.assign({},e,{params:Object.assign({},o,e.params),pathname:Tn([c,r.encodeLocation?r.encodeLocation(e.pathname.replace(/%/g,`%25`).replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathname]),pathnameBase:e.pathnameBase===`/`?c:Tn([c,r.encodeLocation?r.encodeLocation(e.pathnameBase.replace(/%/g,`%25`).replace(/\?/g,`%3F`).replace(/#/g,`%23`)).pathname:e.pathnameBase])})),i,n);return t&&h?I.createElement(qn.Provider,{value:{location:{pathname:`/`,search:``,hash:``,state:null,key:`default`,mask:void 0,...d},navigationType:`POP`}},h):h}function pr(){let e=Er(),t=jn(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,r=`rgba(200,200,200, 0.5)`,i={padding:`0.5rem`,backgroundColor:r},a={padding:`2px 4px`,backgroundColor:r},o=null;return console.error(`Error handled by React Router default ErrorBoundary:`,e),o=I.createElement(I.Fragment,null,I.createElement(`p`,null,`💿 Hey developer 👋`),I.createElement(`p`,null,`You can provide a way better UX than this when your app throws errors by providing your own `,I.createElement(`code`,{style:a},`ErrorBoundary`),` or`,` `,I.createElement(`code`,{style:a},`errorElement`),` prop on your route.`)),I.createElement(I.Fragment,null,I.createElement(`h2`,null,`Unexpected Application Error!`),I.createElement(`h3`,{style:{fontStyle:`italic`}},t),n?I.createElement(`pre`,{style:i},n):null,o)}var mr=I.createElement(pr,null),hr=class extends I.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!==`idle`&&e.revalidation===`idle`?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error===void 0?t.error:e.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.onError?this.props.onError(e,t):console.error(`React Router caught the following error during render`,e)}render(){let e=this.state.error;if(this.context&&typeof e==`object`&&e&&`digest`in e&&typeof e.digest==`string`){let t=er(e.digest);t&&(e=t)}let t=e===void 0?this.props.children:I.createElement(Jn.Provider,{value:this.props.routeContext},I.createElement(Yn.Provider,{value:e,children:this.props.component}));return this.context?I.createElement(_r,{error:e},t):t}};hr.contextType=Vn;var gr=new WeakMap;function _r({children:e,error:t}){let{basename:n}=I.useContext(Kn);if(typeof t==`object`&&t&&`digest`in t&&typeof t.digest==`string`){let e=$n(t.digest);if(e){let r=gr.get(t);if(r)throw r;let i=Pn(e.location,n),a=i.absoluteURL||i.to;if(Rn(a))throw Error(`Invalid redirect location`);if(Nn&&!gr.get(t)){if(i.isExternal||e.reloadDocument)window.location.href=a;else{let n=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(i.to,{replace:e.replace}));throw gr.set(t,n),n}}return I.createElement(`meta`,{httpEquiv:`refresh`,content:`0;url=${a}`})}}return e}function vr({routeContext:e,match:t,children:n}){let r=I.useContext(zn);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),I.createElement(Jn.Provider,{value:e},n)}function yr(e,t=[],n){let r=n?.state;if(e==null){if(!r)return null;if(r.errors)e=r.matches;else if(t.length===0&&!r.initialized&&r.matches.length>0)e=r.matches;else return null}let i=e,a=r?.errors;if(a!=null){let e=i.findIndex(e=>e.route.id&&a?.[e.route.id]!==void 0);L(e>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(a).join(`,`)}`),i=i.slice(0,Math.min(i.length,e+1))}let o=!1,s=-1;if(n&&r){o=r.renderFallback;for(let e=0;e=0?i.slice(0,s+1):[i[0]];break}}}}let c=n?.onError,l=r&&c?(e,t)=>{c(e,{location:r.location,params:r.matches?.[0]?.params??{},pattern:Mn(r.matches),errorInfo:t})}:void 0;return i.reduceRight((e,n,c)=>{let u,d=!1,f=null,p=null;r&&(u=a&&n.route.id?a[n.route.id]:void 0,f=n.route.errorElement||mr,o&&(s<0&&c===0?(kr(`route-fallback`,!1,"No `HydrateFallback` element provided to render during initial hydration"),d=!0,p=null):s===c&&(d=!0,p=n.route.hydrateFallbackElement||null)));let m=t.concat(i.slice(0,c+1)),h=()=>{let t;return t=u?f:d?p:n.route.Component?I.createElement(n.route.Component,null):n.route.element?n.route.element:e,I.createElement(vr,{match:n,routeContext:{outlet:e,matches:m,isDataRoute:r!=null},children:t})};return r&&(n.route.ErrorBoundary||n.route.errorElement||c===0)?I.createElement(hr,{location:r.location,revalidation:r.revalidation,component:f,error:u,children:h(),routeContext:{outlet:null,matches:m,isDataRoute:!0},onError:l}):h()},null)}function br(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function xr(e){let t=I.useContext(zn);return L(t,br(e)),t}function Sr(e){let t=I.useContext(Bn);return L(t,br(e)),t}function Cr(e){let t=I.useContext(Jn);return L(t,br(e)),t}function wr(e){let t=Cr(e),n=t.matches[t.matches.length-1];return L(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function Tr(){return wr(`useRouteId`)}function Er(){let e=I.useContext(Yn),t=Sr(`useRouteError`),n=wr(`useRouteError`);return e===void 0?t.errors?.[n]:e}function Dr(){let{router:e}=xr(`useNavigate`),t=wr(`useNavigate`),n=I.useRef(!1);return ar(()=>{n.current=!0}),I.useCallback(async(r,i={})=>{Ht(n.current,ir),n.current&&(typeof r==`number`?await e.navigate(r):await e.navigate(r,{fromRouteId:t,...i}))},[e,t])}var Or={};function kr(e,t,n){!t&&!Or[e]&&(Or[e]=!0,Ht(!1,n))}I.memo(Ar);function Ar({routes:e,manifest:t,future:n,state:r,isStatic:i,onError:a}){return fr(e,void 0,{manifest:t,state:r,isStatic:i,onError:a,future:n})}function jr({to:e,replace:t,state:n,relative:r}){L(nr(),` may be used only in the context of a component.`);let{static:i}=I.useContext(Kn);Ht(!i,` must not be used on the initial render in a . This is a no-op, but you should modify your code so the is only ever rendered in response to some user interaction or state change.`);let{matches:a}=I.useContext(Jn),{pathname:o}=rr(),s=or(),c=Cn(e,Sn(a),o,r===`path`),l=JSON.stringify(c);return I.useEffect(()=>{s(JSON.parse(l),{replace:t,state:n,relative:r})},[s,l,r,t,n]),null}function Mr(e){return lr(e.context)}function Nr(e){L(!1,`A is only ever to be used as the child of element, never rendered directly. Please wrap your in a .`)}function Pr({basename:e=`/`,children:t=null,location:n,navigationType:r=`POP`,navigator:i,static:a=!1,useTransitions:o}){L(!nr(),`You cannot render a inside another . You should never have more than one in your app.`);let s=e.replace(/^\/*/,`/`),c=I.useMemo(()=>({basename:s,navigator:i,static:a,useTransitions:o,future:{}}),[s,i,a,o]);typeof n==`string`&&(n=qt(n));let{pathname:l=`/`,search:u=``,hash:d=``,state:f=null,key:p=`default`,mask:m}=n,h=I.useMemo(()=>{let e=_n(l,s);return e==null?null:{location:{pathname:e,search:u,hash:d,state:f,key:p,mask:m},navigationType:r}},[s,l,u,d,f,p,r,m]);return Ht(h!=null,` is not able to match the URL "${l}${u}${d}" because it does not start with the basename, so the won't render anything.`),h==null?null:I.createElement(Kn.Provider,{value:c},I.createElement(qn.Provider,{children:t,value:h}))}function Fr({children:e,location:t}){return dr(Ir(e),t)}I.Component;function Ir(e,t=[]){let n=[];return I.Children.forEach(e,(e,r)=>{if(!I.isValidElement(e))return;let i=[...t,r];if(e.type===I.Fragment){n.push.apply(n,Ir(e.props.children,i));return}L(e.type===Nr,`[${typeof e.type==`string`?e.type:e.type.name}] is not a component. All component children of must be a or `),L(!e.props.index||!e.props.children,`An index route cannot have child routes.`);let a={id:e.props.id||i.join(`-`),caseSensitive:e.props.caseSensitive,element:e.props.element,Component:e.props.Component,index:e.props.index,path:e.props.path,middleware:e.props.middleware,loader:e.props.loader,action:e.props.action,hydrateFallbackElement:e.props.hydrateFallbackElement,HydrateFallback:e.props.HydrateFallback,errorElement:e.props.errorElement,ErrorBoundary:e.props.ErrorBoundary,hasErrorBoundary:e.props.hasErrorBoundary===!0||e.props.ErrorBoundary!=null||e.props.errorElement!=null,shouldRevalidate:e.props.shouldRevalidate,handle:e.props.handle,lazy:e.props.lazy};e.props.children&&(a.children=Ir(e.props.children,i)),n.push(a)}),n}var Lr=`get`,Rr=`application/x-www-form-urlencoded`;function zr(e){return typeof HTMLElement<`u`&&e instanceof HTMLElement}function Br(e){return zr(e)&&e.tagName.toLowerCase()===`button`}function Vr(e){return zr(e)&&e.tagName.toLowerCase()===`form`}function Hr(e){return zr(e)&&e.tagName.toLowerCase()===`input`}function Ur(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function Wr(e,t){return e.button===0&&(!t||t===`_self`)&&!Ur(e)}function Gr(e=``){return new URLSearchParams(typeof e==`string`||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,n)=>{let r=e[n];return t.concat(Array.isArray(r)?r.map(e=>[n,e]):[[n,r]])},[]))}function Kr(e,t){let n=Gr(e);return t&&t.forEach((e,r)=>{n.has(r)||t.getAll(r).forEach(e=>{n.append(r,e)})}),n}var qr=null;function Jr(){if(qr===null)try{new FormData(document.createElement(`form`),0),qr=!1}catch{qr=!0}return qr}var Yr=new Set([`application/x-www-form-urlencoded`,`multipart/form-data`,`text/plain`]);function Xr(e){return e!=null&&!Yr.has(e)?(Ht(!1,`"${e}" is not a valid \`encType\` for \`
\`/\`\` and will default to "${Rr}"`),null):e}function Zr(e,t){let n,r,i,a,o;if(Vr(e)){let o=e.getAttribute(`action`);r=o?_n(o,t):null,n=e.getAttribute(`method`)||Lr,i=Xr(e.getAttribute(`enctype`))||Rr,a=new FormData(e)}else if(Br(e)||Hr(e)&&(e.type===`submit`||e.type===`image`)){let o=e.form;if(o==null)throw Error(`Cannot submit a