From 99a45f86e0561059460dec6b9f8ac3922ee0ac83 Mon Sep 17 00:00:00 2001 From: caigee-cmd <210803857+caigee-cmd@users.noreply.github.com> Date: Thu, 29 Oct 2026 18:47:11 +0800 Subject: [PATCH] feat(live): expose selecting queue on /api/live for InflightLiveCard MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reuse RequestRecorder + existing RequestStatus* (started/streaming/ok/ incomplete/error/canceled): Prepare Start opens, Acquire BindAccount, Release UnbindAccount, terminal Finish clears. No new state machine or /api/inflight*. Also sort worker rail busy→available→cooldown and format rate-limit remain with hours. --- changelog/unreleased/live-selecting-queue.md | 9 + frontend/scripts/mockInflight.test.ts | 47 +++++ frontend/src/api/live.ts | 15 ++ .../components/overview/InflightLiveCard.tsx | 13 +- frontend/src/lib/mockInflight.ts | 50 +++++- internal/app/app.go | 2 + internal/console/live.go | 47 ++++- internal/console/live_test.go | 6 + internal/executor/chat.go | 40 +++-- internal/logs/recent_completions_test.go | 51 ++++++ internal/logs/recorder.go | 163 ++++++++++++++++++ ...-BLRH4M4a.js => CartesianGrid-BMNtov-j.js} | 2 +- ...hart-HjooRbfZ.js => CostChart-PEvxXQD1.js} | 2 +- ...-C40ZJRGg.js => LiveSparkline-C2h2mKvg.js} | 2 +- ...t-DME0-Hqp.js => TrafficChart-CsxXsi2g.js} | 2 +- .../{index-CZG9DLai.js => index-DHWWlsS6.js} | 10 +- internal/webui/static/index.html | 2 +- 17 files changed, 423 insertions(+), 40 deletions(-) create mode 100644 changelog/unreleased/live-selecting-queue.md rename internal/webui/static/assets/{CartesianGrid-BLRH4M4a.js => CartesianGrid-BMNtov-j.js} (99%) rename internal/webui/static/assets/{CostChart-HjooRbfZ.js => CostChart-PEvxXQD1.js} (96%) rename internal/webui/static/assets/{LiveSparkline-C40ZJRGg.js => LiveSparkline-C2h2mKvg.js} (80%) rename internal/webui/static/assets/{TrafficChart-DME0-Hqp.js => TrafficChart-CsxXsi2g.js} (99%) rename internal/webui/static/assets/{index-CZG9DLai.js => index-DHWWlsS6.js} (98%) diff --git a/changelog/unreleased/live-selecting-queue.md b/changelog/unreleased/live-selecting-queue.md new file mode 100644 index 00000000..47bbc7a5 --- /dev/null +++ b/changelog/unreleased/live-selecting-queue.md @@ -0,0 +1,9 @@ +### English + +- Overview InflightLiveCard waiting rail now shows real selecting requests from `/api/live` `queue` (Prepare → pool Acquire), reusing existing `request_logs` statuses (`started` / `streaming` / terminal) instead of a parallel inflight API. +- Worker rail order is busy → available → cooldown, and rate-limit remaining time formats with hours when the window is long enough (`Nh Nm`). + +### 中文 + +- Overview「实时进行中」等待队列改为读取 `/api/live` 的 `queue`(Prepare → 选号 → Acquire),复用现有 `request_logs` 状态(`started` / `streaming` / 终态),不另开 `/api/inflight*`。 +- 账号槽排序为忙碌 → 空闲 → 冷却,限流剩余时间在足够长时按小时显示(`Nh Nm`)。 diff --git a/frontend/scripts/mockInflight.test.ts b/frontend/scripts/mockInflight.test.ts index dd169c6a..2b3ce553 100644 --- a/frontend/scripts/mockInflight.test.ts +++ b/frontend/scripts/mockInflight.test.ts @@ -3,6 +3,7 @@ import { applyLiveProjection, cloneMockInflight, getMockInflightSnapshot, + liveHasSignal, MOCK_INFLIGHT, } from '../src/lib/mockInflight.ts' @@ -281,3 +282,49 @@ run('applyLiveProjection maps max_inflight / in_flight to slot cells', () => { }) console.log('all mockInflight tests passed') + +run('applyLiveProjection maps queue onto queued MockJobStatus', () => { + const started = new Date(Date.now() - 5_000).toISOString() + const snap = applyLiveProjection(getMockInflightSnapshot(), { + in_flight: 1, + rpm: 2, + workers: [ + { + id: 'acc-1', + name: 'wb-a1', + provider: 'workbuddy', + busy: true, + progress: 0.4, + rate_limited: false, + }, + ], + rate_limits: [], + sticky: { bindings: 0, hits: 0, misses: 0, capacity: 64, ttl_seconds: 600 }, + queue: [ + { id: 'req-1', name: 'chat · wait', status: 'started', started_at: started }, + { id: 'req-2', name: 'embed · docs', status: 'started' }, + ], + }) + const queued = snap.jobs.filter((j) => j.status === 'queued') + const running = snap.jobs.filter((j) => j.status === 'running') + assert.equal(running.length, 1) + assert.equal(queued.length, 2) + assert.equal(queued[0].id, 'req-1') + assert.equal(queued[0].name, 'chat · wait') + assert.ok(queued[0].elapsedMs >= 4_000 && queued[0].elapsedMs < 15_000) + assert.equal(queued[1].id, 'req-2') +}) + +run('liveHasSignal true when only queue present', () => { + assert.equal( + liveHasSignal({ + in_flight: 0, + rpm: 0, + workers: [], + rate_limits: [], + sticky: { bindings: 0, hits: 0, misses: 0, capacity: 0, ttl_seconds: 0 }, + queue: [{ id: 'r1', name: 'm', status: 'started' }], + }), + true, + ) +}) diff --git a/frontend/src/api/live.ts b/frontend/src/api/live.ts index ac163ba4..e4100c1f 100644 --- a/frontend/src/api/live.ts +++ b/frontend/src/api/live.ts @@ -26,6 +26,19 @@ export type LiveCompletion = { status: string } +/** + * Selecting (选号) request for the InflightLiveCard waiting rail. + * status reuses request_logs RequestStatus* (typically started) — not a new machine. + */ +export type LiveJob = { + id: string + name: string + /** RequestStatus* from recorder (started while selecting). */ + status: string + /** RFC3339 Prepare/Start time. */ + started_at?: string +} + /** Active cooldown window from AccountView.DownUntil / model_cooldowns. */ export type LiveRateLimit = { id: string @@ -62,6 +75,8 @@ export type LiveSnapshot = { sticky: LiveSticky /** Terminal finishes since last poll — InflightLiveCard routes fly-outs. */ recent_completions?: LiveCompletion[] + /** Prepare→Acquire 选号 (RequestStatusStarted, no pool bind). */ + queue?: LiveJob[] } export function fetchLive() { diff --git a/frontend/src/components/overview/InflightLiveCard.tsx b/frontend/src/components/overview/InflightLiveCard.tsx index f1fd5528..ac5ebf68 100644 --- a/frontend/src/components/overview/InflightLiveCard.tsx +++ b/frontend/src/components/overview/InflightLiveCard.tsx @@ -43,8 +43,10 @@ type T = (key: string, vars?: Record) => string function formatRemain(ms: number) { const sec = Math.max(0, Math.round(ms / 1000)) - const m = Math.floor(sec / 60) + const h = Math.floor(sec / 3600) + const m = Math.floor((sec % 3600) / 60) const s = sec % 60 + if (h) return `${h}h ${m}m` if (m) return `${m}m ${String(s).padStart(2, '0')}s` return `${s}s` } @@ -401,13 +403,14 @@ export function InflightLiveCard({ const waiting = snap.jobs.filter((j) => j.status === 'queued') const queuePills = waiting.slice(0, QUEUE_PILL_MAX) const queueOverflow = waiting.slice(QUEUE_PILL_MAX) - // AffectUI: short worker rail — busy / rate-limited first, cap at N (not every account). + // AffectUI: short worker rail — busy → available → cooldown, cap at N. const visibleWorkers = useMemo(() => { - const preferred = snap.workers.filter((w) => w.busy || w.rateLimited) - const rest = snap.workers.filter((w) => !w.busy && !w.rateLimited) + const busy = snap.workers.filter((w) => w.busy) + const available = snap.workers.filter((w) => !w.busy && !w.rateLimited) + const cooling = snap.workers.filter((w) => !w.busy && w.rateLimited) const out: typeof snap.workers = [] const seen = new Set() - for (const w of [...preferred, ...rest]) { + for (const w of [...busy, ...available, ...cooling]) { if (seen.has(w.id)) continue seen.add(w.id) out.push(w) diff --git a/frontend/src/lib/mockInflight.ts b/frontend/src/lib/mockInflight.ts index 77b579eb..b915c8e3 100644 --- a/frontend/src/lib/mockInflight.ts +++ b/frontend/src/lib/mockInflight.ts @@ -6,9 +6,9 @@ * rateLimits≈ cooldown / provider rate-limit windows * depth ≈ recent waiting + concurrency approx * totals ≈ recent request_logs Done/Failed (mock until Phase 2) - * Stage-3 swaps workers/rateLimits/sticky onto /api/live (LiveWorker, - * LiveRateLimit, LiveSticky); keep jobs/depth mock-only until request-level - * inflight lands. Do not invent a parallel /api/inflight*. + * 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*. * * Live loop (`tickMockInflight`) mirrors public AffectUI Motion prose: * progress fill, queue→worker handoff, DONE/FAILED stack, depth scroll — @@ -409,6 +409,14 @@ export type LiveStickyLike = { escapes?: number } +export type LiveQueueJobLike = { + id: string + name: string + /** RequestStatus* — UI maps selecting onto MockJobStatus queued. */ + status: string + started_at?: string +} + export type LiveProjectionInput = { in_flight: number rpm: number @@ -416,6 +424,8 @@ export type LiveProjectionInput = { rate_limits: LiveRateLimitLike[] sticky: LiveStickyLike recent_completions?: LiveCompletionLike[] + /** Selecting requests (started, unbound) from /api/live queue. */ + queue?: LiveQueueJobLike[] } /** @@ -471,7 +481,7 @@ export function applyLiveProjection( } }) - const jobs: MockInflightJob[] = workers + const runningJobs: MockInflightJob[] = workers .filter((w) => w.busy && w.jobId) .map((w) => { const id = w.jobId! @@ -501,6 +511,37 @@ export function applyLiveProjection( } }) + // Selecting queue: RequestStatusStarted (etc.) → UI MockJobStatus queued. + // Do not invent parallel statuses — only map existing request_logs values. + const queuedJobs: MockInflightJob[] = (live.queue ?? []).map((q) => { + const id = (q.id || '').trim() + const prev = prevById.get(id) + let startedAtMs: number | undefined + const raw = q.started_at?.trim() + if (raw) { + const parsed = Date.parse(raw) + if (!Number.isNaN(parsed)) startedAtMs = parsed + } + if (startedAtMs == null && prev?.startedAtMs != null) { + startedAtMs = prev.startedAtMs + } + if (startedAtMs == null) { + startedAtMs = now + } + const name = (q.name || '').trim() || id + return { + id, + name, + kind: 'chat' as const, + status: 'queued' as const, + progress: 0, + startedAtMs, + elapsedMs: Math.max(0, now - startedAtMs), + } + }) + + const jobs: MockInflightJob[] = [...runningJobs, ...queuedJobs] + // Continue rolling depth only after a prior live projection (cleared p95 + // zero totals). Mock seed/tick always leaves waitP95Ms > 0 — start zeros. const priorIsLive = base.waitP95Ms === 0 && base.totals.done === 0 && base.totals.failed === 0 @@ -565,6 +606,7 @@ export function liveHasSignal(live: LiveProjectionInput): boolean { live.workers.length > 0 || live.rate_limits.length > 0 || live.in_flight > 0 || + (live.queue?.length ?? 0) > 0 || (live.sticky?.bindings ?? 0) > 0 ) } diff --git a/internal/app/app.go b/internal/app/app.go index d4888dd6..e5c5747a 100644 --- a/internal/app/app.go +++ b/internal/app/app.go @@ -157,6 +157,8 @@ func New(cfg config.Config) *App { chatExecutor.MaxAttempts = cfg.MaxRetryAccounts chatExecutor.Providers = providerReg chatExecutor.OnAttempt = recorder.Attempt + chatExecutor.OnInFlightAcquire = recorder.BindAccount + chatExecutor.OnInFlightRelease = recorder.UnbindAccount a := &App{ Cfg: cfg, Auth: auth.NewVerifier(proxyAPIKey, store), diff --git a/internal/console/live.go b/internal/console/live.go index bcfbf78f..5ce445d5 100644 --- a/internal/console/live.go +++ b/internal/console/live.go @@ -66,16 +66,28 @@ type LiveCompletion struct { Status string `json:"status"` } +// LiveJob is one selecting (选号) request for the InflightLiveCard waiting +// queue. Status reuses accounts.RequestStatus* (started) — not a new state +// machine. Running occupancy stays on Workers via Pool InFlight. +type LiveJob struct { + ID string `json:"id"` + Name string `json:"name"` + Status string `json:"status"` + StartedAt string `json:"started_at,omitempty"` +} + type LiveSnapshot struct { - Time string `json:"time"` - InFlight int `json:"in_flight"` - Capacity int `json:"capacity"` - RPM int `json:"rpm"` - Accounts []LiveAccount `json:"accounts"` - Workers []LiveWorker `json:"workers"` - RateLimits []LiveRateLimit `json:"rate_limits"` - Sticky executor.SessionAffinityStats `json:"sticky"` - RecentCompletions []LiveCompletion `json:"recent_completions,omitempty"` + Time string `json:"time"` + InFlight int `json:"in_flight"` + Capacity int `json:"capacity"` + RPM int `json:"rpm"` + Accounts []LiveAccount `json:"accounts"` + Workers []LiveWorker `json:"workers"` + RateLimits []LiveRateLimit `json:"rate_limits"` + Sticky executor.SessionAffinityStats `json:"sticky"` + RecentCompletions []LiveCompletion `json:"recent_completions,omitempty"` + // Queue is Prepare→Acquire 选号 (RequestStatusStarted, no pool bind). + Queue []LiveJob `json:"queue,omitempty"` } // buildLiveSnapshot sums in-flight over all accounts and capacity (the @@ -89,6 +101,7 @@ func buildLiveSnapshot(views []accounts.AccountView, rpm int, sticky executor.Se Accounts: make([]LiveAccount, 0, len(views)), Workers: make([]LiveWorker, 0, len(views)), RateLimits: make([]LiveRateLimit, 0), + Queue: make([]LiveJob, 0), Sticky: sticky, } for _, v := range views { @@ -205,6 +218,22 @@ func (h *Handler) HandleLive(w http.ResponseWriter, r *http.Request) { Status: c.Status, }) } + for _, q := range h.Recorder.SelectingRequests() { + name := strings.TrimSpace(q.RequestedModel) + if name == "" { + name = q.ID + } + status := strings.TrimSpace(q.Status) + if status == "" { + status = accounts.RequestStatusStarted + } + snap.Queue = append(snap.Queue, LiveJob{ + ID: q.ID, + Name: name, + Status: status, + StartedAt: q.StartedAt.UTC().Format(time.RFC3339), + }) + } } writeJSON(w, http.StatusOK, snap) } diff --git a/internal/console/live_test.go b/internal/console/live_test.go index 2394bc16..bcf18916 100644 --- a/internal/console/live_test.go +++ b/internal/console/live_test.go @@ -78,6 +78,12 @@ func TestBuildLiveSnapshot(t *testing.T) { if got.RateLimits[0].Label != "wb-a2" || got.RateLimits[1].Label != "wb-a2 · glm-5" { t.Fatalf("labels = %q / %q", got.RateLimits[0].Label, got.RateLimits[1].Label) } + if got.Queue == nil { + t.Fatalf("queue must be non-nil empty slice") + } + if len(got.Queue) != 0 { + t.Fatalf("queue = %+v", got.Queue) + } } func TestBuildLiveSnapshotEmpty(t *testing.T) { diff --git a/internal/executor/chat.go b/internal/executor/chat.go index fe0b2e07..06718e9d 100644 --- a/internal/executor/chat.go +++ b/internal/executor/chat.go @@ -33,6 +33,10 @@ type ChatExecutor struct { OnAttempt AttemptHook MaxAttempts int SessionAffinity *SessionAffinity + // OnInFlightAcquire/Release mirror Pool.Acquire/Release onto RequestRecorder + // open-request tracking (same plane as recent_completions). Optional. + OnInFlightAcquire func(requestID, accountID string) + OnInFlightRelease func(requestID, accountID string) } type ChatResult struct { @@ -851,27 +855,39 @@ func (c *releaseCloser) Close() error { return err } -func (e ChatExecutor) acquireInFlight(id string) bool { +func (e ChatExecutor) acquireInFlight(requestID, id string) bool { if e.Pool == nil { + if e.OnInFlightAcquire != nil && requestID != "" && id != "" { + e.OnInFlightAcquire(requestID, id) + } return true } - return e.Pool.Acquire(id) + if !e.Pool.Acquire(id) { + return false + } + if e.OnInFlightAcquire != nil && requestID != "" { + e.OnInFlightAcquire(requestID, id) + } + return true } -func (e ChatExecutor) releaseInFlight(id string) { +func (e ChatExecutor) releaseInFlight(requestID, id string) { if e.Pool != nil { e.Pool.Release(id) } + if e.OnInFlightRelease != nil && requestID != "" { + e.OnInFlightRelease(requestID, id) + } } // attachInFlightRelease transfers an acquired slot to the response body. // Close releases the pool id that was Acquired (not a rewritten account id). -func (e ChatExecutor) attachInFlightRelease(resp *http.Response, poolID string) *http.Response { +func (e ChatExecutor) attachInFlightRelease(resp *http.Response, requestID, poolID string) *http.Response { if resp == nil || resp.Body == nil { - e.releaseInFlight(poolID) + e.releaseInFlight(requestID, poolID) return resp } - resp.Body = &releaseCloser{ReadCloser: resp.Body, release: func() { e.releaseInFlight(poolID) }} + resp.Body = &releaseCloser{ReadCloser: resp.Body, release: func() { e.releaseInFlight(requestID, poolID) }} return resp } @@ -889,11 +905,11 @@ func (e ChatExecutor) ChatNonStream(ctx context.Context, req translate.ChatReque } // Acquire with the pool id before any rewrite of item.ID (X-Qoder-Account). poolID := item.ID - if !e.acquireInFlight(poolID) { + if !e.acquireInFlight(loop.requestID, poolID) { loop.exclude(item) continue } - release := func() { e.releaseInFlight(poolID) } + release := func() { e.releaseInFlight(loop.requestID, poolID) } if isInProcessItem(item) || e.qoderDirect(item) { result, classified, err := e.chatInProcessNonStreamAttempt(ctx, item, req, i) if err == nil { @@ -1337,18 +1353,18 @@ func (e ChatExecutor) chatStreamProxy(ctx context.Context, req translate.ChatReq return StreamResult{}, pickErr } poolID := item.ID - if !e.acquireInFlight(poolID) { + if !e.acquireInFlight(loop.requestID, poolID) { loop.exclude(item) continue } - release := func() { e.releaseInFlight(poolID) } + release := func() { e.releaseInFlight(loop.requestID, poolID) } if isInProcessItem(item) || (e.qoderDirect(item) && !(preferNativeResponses && native != nil)) { result, classified, err := e.chatInProcessStreamAttempt(ctx, item, req, native, i, preferNativeResponses) if err == nil { result.AttemptCount = i + 1 e.observeRouting(&loop.routing, result.AccountID) - result.Response = e.attachInFlightRelease(result.Response, poolID) + result.Response = e.attachInFlightRelease(result.Response, loop.requestID, poolID) return result, nil } loop.lastErr = err @@ -1446,7 +1462,7 @@ func (e ChatExecutor) chatStreamProxy(ctx context.Context, req translate.ChatReq if resolved != "" { logResolvedReasoning(ctx, "chat_stream", item, req.Model, resolved) } - resp = e.attachInFlightRelease(resp, poolID) + resp = e.attachInFlightRelease(resp, loop.requestID, poolID) return StreamResult{ Response: resp, AccountID: item.ID, diff --git a/internal/logs/recent_completions_test.go b/internal/logs/recent_completions_test.go index 0ae3fb29..563d72de 100644 --- a/internal/logs/recent_completions_test.go +++ b/internal/logs/recent_completions_test.go @@ -29,3 +29,54 @@ func TestDrainRecentCompletions(t *testing.T) { t.Fatalf("second drain must be empty, got %+v", again) } } + +func TestSelectingRequestsFIFOAndBind(t *testing.T) { + r := NewRequestRecorder(persistOnly{}) + defer r.Close() + + r.Start(accounts.RequestLog{ID: "r1", RequestedModel: "m1", Status: accounts.RequestStatusStarted}) + r.Start(accounts.RequestLog{ID: "r2", RequestedModel: "m2", Status: accounts.RequestStatusStarted}) + r.Start(accounts.RequestLog{ID: "r3", RequestedModel: "m3", Status: accounts.RequestStatusStarted}) + + got := r.SelectingRequests() + if len(got) != 3 { + t.Fatalf("want 3 selecting, got %+v", got) + } + if got[0].ID != "r1" || got[1].ID != "r2" || got[2].ID != "r3" { + t.Fatalf("FIFO order = %+v", got) + } + + r.BindAccount("r2", "acc-b") + got = r.SelectingRequests() + if len(got) != 2 || got[0].ID != "r1" || got[1].ID != "r3" { + t.Fatalf("after bind r2 = %+v", got) + } + + r.UnbindAccount("r2", "acc-b") + got = r.SelectingRequests() + if len(got) != 3 { + t.Fatalf("after unbind want 3, got %+v", got) + } + + r.Finish(accounts.RequestLog{ID: "r1", Status: accounts.RequestStatusStreaming, AccountID: "acc-a"}) + got = r.SelectingRequests() + // streaming is non-terminal — still open; AccountID on Finish does not Bind. + // r1 still selecting (empty AccountID on open map unless Bind was called). + ids := map[string]bool{} + for _, o := range got { + ids[o.ID] = true + } + if !ids["r1"] || !ids["r2"] || !ids["r3"] { + t.Fatalf("streaming finish must not clearOpen, got %+v", got) + } + + r.Finish(accounts.RequestLog{ID: "r1", Status: accounts.RequestStatusOK, AccountID: "acc-a"}) + got = r.SelectingRequests() + ids = map[string]bool{} + for _, o := range got { + ids[o.ID] = true + } + if ids["r1"] || !ids["r2"] || !ids["r3"] { + t.Fatalf("terminal ok must clear r1, got %+v", got) + } +} diff --git a/internal/logs/recorder.go b/internal/logs/recorder.go index c4370c32..d6f08197 100644 --- a/internal/logs/recorder.go +++ b/internal/logs/recorder.go @@ -5,6 +5,7 @@ import ( "fmt" "log" "os" + "sort" "strconv" "strings" "sync" @@ -113,6 +114,21 @@ type RecentCompletion struct { At time.Time } +// OpenRequest is an in-memory handle for /api/live waiting-queue projection. +// Same telemetry plane as RecentCompletion (RequestRecorder), not a second +// control plane. Status reuses accounts.RequestStatus* only — typically +// RequestStatusStarted from Prepare/Logs.Start until a terminal Finish. +// AccountID empty ⇒ still selecting (pre-Acquire); set by BindAccount on +// Pool.Acquire; cleared by UnbindAccount on Release; entry removed on +// terminal Finish. +type OpenRequest struct { + ID string + RequestedModel string + AccountID string + Status string + StartedAt time.Time +} + type RequestRecorder struct { store RequestPersister queue chan func() @@ -127,6 +143,8 @@ type RequestRecorder struct { rate *RateCounter recentMu sync.Mutex recent []RecentCompletion + openMu sync.Mutex + open map[string]*OpenRequest } func NewRequestRecorder(store RequestPersister) *RequestRecorder { @@ -177,6 +195,7 @@ func (r *RequestRecorder) Close() { func (r *RequestRecorder) Start(log accounts.RequestLog) { r.rateCounter().Add() + r.noteOpen(log) r.enqueue(func() { if err := r.store.InsertRequestLog(context.Background(), log); err != nil { logf("insert request log: %v", err) @@ -197,6 +216,9 @@ func (r *RequestRecorder) RecentRequests() int { return r.rateCounter().Count() func (r *RequestRecorder) Finish(log accounts.RequestLog) { r.noteCompletion(log) + if terminalRequestStatus(log.Status) { + r.clearOpen(log.ID) + } r.enqueue(func() { if err := r.store.UpdateRequestLog(context.Background(), log); err != nil { logf("update request log: %v", err) @@ -247,6 +269,147 @@ func (r *RequestRecorder) DrainRecentCompletions() []RecentCompletion { return out } +const openRequestCap = 512 + +func (r *RequestRecorder) noteOpen(log accounts.RequestLog) { + if r == nil { + return + } + id := strings.TrimSpace(log.ID) + if id == "" { + return + } + started := log.CreatedAt + if started.IsZero() { + started = time.Now().UTC() + } else { + started = started.UTC() + } + status := strings.TrimSpace(log.Status) + if status == "" { + status = accounts.RequestStatusStarted + } + r.openMu.Lock() + defer r.openMu.Unlock() + if r.open == nil { + r.open = make(map[string]*OpenRequest) + } + r.open[id] = &OpenRequest{ + ID: id, + RequestedModel: strings.TrimSpace(log.RequestedModel), + AccountID: strings.TrimSpace(log.AccountID), + Status: status, + StartedAt: started, + } + r.trimOpenLocked() +} + +// BindAccount records Pool.Acquire onto an open request (选号 → running slot). +// No-op when the request was never Start-registered. +func (r *RequestRecorder) BindAccount(requestID, accountID string) { + if r == nil { + return + } + requestID = strings.TrimSpace(requestID) + accountID = strings.TrimSpace(accountID) + if requestID == "" || accountID == "" { + return + } + r.openMu.Lock() + defer r.openMu.Unlock() + if o, ok := r.open[requestID]; ok { + o.AccountID = accountID + } +} + +// UnbindAccount clears the pool bind on Release (failover returns to 选号; +// terminal Finish still deletes via clearOpen). +func (r *RequestRecorder) UnbindAccount(requestID, accountID string) { + if r == nil { + return + } + requestID = strings.TrimSpace(requestID) + accountID = strings.TrimSpace(accountID) + if requestID == "" { + return + } + r.openMu.Lock() + defer r.openMu.Unlock() + o, ok := r.open[requestID] + if !ok { + return + } + if accountID == "" || o.AccountID == "" || o.AccountID == accountID { + o.AccountID = "" + } +} + +func (r *RequestRecorder) clearOpen(requestID string) { + if r == nil { + return + } + requestID = strings.TrimSpace(requestID) + if requestID == "" { + return + } + r.openMu.Lock() + defer r.openMu.Unlock() + delete(r.open, requestID) +} + +// SelectingRequests returns open requests still in 选号 (started, no account +// bind). FIFO by StartedAt for the InflightLiveCard waiting queue. +func (r *RequestRecorder) SelectingRequests() []OpenRequest { + if r == nil { + return nil + } + r.openMu.Lock() + defer r.openMu.Unlock() + out := make([]OpenRequest, 0, len(r.open)) + for _, o := range r.open { + if o == nil || strings.TrimSpace(o.AccountID) != "" { + continue + } + out = append(out, *o) + } + sort.SliceStable(out, func(i, j int) bool { + if !out[i].StartedAt.Equal(out[j].StartedAt) { + return out[i].StartedAt.Before(out[j].StartedAt) + } + return out[i].ID < out[j].ID + }) + return out +} + +func (r *RequestRecorder) trimOpenLocked() { + if len(r.open) <= openRequestCap { + return + } + // Prefer dropping unbound selecting entries first, then oldest overall. + type ranked struct { + id string + started time.Time + bound bool + } + all := make([]ranked, 0, len(r.open)) + for id, o := range r.open { + all = append(all, ranked{id: id, started: o.StartedAt, bound: strings.TrimSpace(o.AccountID) != ""}) + } + sort.SliceStable(all, func(i, j int) bool { + if all[i].bound != all[j].bound { + return !all[i].bound && all[j].bound // unbound first + } + if !all[i].started.Equal(all[j].started) { + return all[i].started.Before(all[j].started) + } + return all[i].id < all[j].id + }) + for len(r.open) > openRequestCap && len(all) > 0 { + delete(r.open, all[0].id) + all = all[1:] + } +} + func (r *RequestRecorder) Attempt(attempt accounts.RequestAttempt) { r.enqueue(func() { if err := r.store.InsertRequestAttempt(context.Background(), attempt); err != nil { diff --git a/internal/webui/static/assets/CartesianGrid-BLRH4M4a.js b/internal/webui/static/assets/CartesianGrid-BMNtov-j.js similarity index 99% rename from internal/webui/static/assets/CartesianGrid-BLRH4M4a.js rename to internal/webui/static/assets/CartesianGrid-BMNtov-j.js index 737c5a0a..39254223 100644 --- a/internal/webui/static/assets/CartesianGrid-BLRH4M4a.js +++ b/internal/webui/static/assets/CartesianGrid-BMNtov-j.js @@ -1,4 +1,4 @@ -import{$t as e,A as t,At as n,Bt as r,Cn as i,Ct as a,Dt as o,E as s,Et as c,F as l,Ft as u,Gt as d,H as f,Ht as p,I as m,It as h,J as g,Jt as _,K as v,Kt as y,L as b,Lt as x,M as S,Mt as C,N as w,Nt as T,O as E,Ot as D,P as O,Pt as k,R as ee,Rt as te,Sn as A,St as j,Tn as M,Tt as ne,Ut as re,Vt as ie,W as N,Wt as ae,X as oe,Xt as se,Y as P,Yt as ce,Z as le,Zt as ue,an as F,bt as de,cn as fe,ct as I,dn as pe,dt as me,en as L,et as he,fn as ge,gt as _e,ht as ve,it as ye,j as be,jt as xe,k as Se,kt as Ce,l as we,ln as Te,nn as Ee,nt as De,on as Oe,ot as ke,pn as Ae,q as R,qt as je,rt as Me,sn as Ne,st as Pe,tn as z,tt as Fe,u as Ie,ut as Le,vt as Re,wn as ze,wt as Be,xt as Ve,yt as B,z as He,zt as Ue}from"./index-CZG9DLai.js";function We(e,t){let n=new Map;for(let r=0;rvoid 0)}function et(e,t,n,r,i=!1){if(t===e)return!0;switch(typeof t){case`object`:return tt(e,t,n,r,i);case`function`:return Object.keys(t).length>0?et(e,{...t},n,r,i):j(e,t);default:return Ve(e)&&i?typeof t!=`string`||t===``:j(e,t)}}function tt(e,t,n,r,i=!1){if(t==null)return!0;if(Array.isArray(t))return rt(e,t,n,r);if(t instanceof Map)return nt(e,t,n,r);if(t instanceof Set)return it(e,t,n,r);let a=Object.keys(t);if(e==null)return i&&a.length===0;if(i)Je(e)&&(e=Object(e));else{let t=y(e);if(t!==`[object Object]`&&t!==`[object Arguments]`)return!1}if(a.length===0)return!0;if(r?.has(t))return r.get(t)===e;r?.set(t,e);try{for(let i=0;ivoid 0)}function ot(e){return e=Qe(e),t=>at(t,e)}function st(e,t){return Xe(e,(n,i,a,s)=>{let c=t?.(n,i,a,s);if(c!==void 0)return c;if(typeof e==`object`){if(y(e)===`[object Object]`&&typeof e.constructor!=`function`){let t={};return s.set(e,t),H(t,e,a,s),t}switch(Object.prototype.toString.call(e)){case h:case r:case o:{let t=new e.constructor(e?.valueOf());return H(t,e),t}case Be:{let t={};return H(t,e),t.length=e.length,t[Symbol.iterator]=e[Symbol.iterator],t}default:return}}})}function ct(e){return st(e)}function lt(e){return typeof e==`object`&&!!e&&y(e)===`[object Arguments]`}function ut(e,t){let n;if(n=Array.isArray(t)?t:typeof t==`string`&&Te(t)&&!(t in Object(e))?Ne(t):[t],n.length===0)return!1;let r=e;for(let e=0;evoid 0)}function et(e,t,n,r,i=!1){if(t===e)return!0;switch(typeof t){case`object`:return tt(e,t,n,r,i);case`function`:return Object.keys(t).length>0?et(e,{...t},n,r,i):j(e,t);default:return Ve(e)&&i?typeof t!=`string`||t===``:j(e,t)}}function tt(e,t,n,r,i=!1){if(t==null)return!0;if(Array.isArray(t))return rt(e,t,n,r);if(t instanceof Map)return nt(e,t,n,r);if(t instanceof Set)return it(e,t,n,r);let a=Object.keys(t);if(e==null)return i&&a.length===0;if(i)Je(e)&&(e=Object(e));else{let t=y(e);if(t!==`[object Object]`&&t!==`[object Arguments]`)return!1}if(a.length===0)return!0;if(r?.has(t))return r.get(t)===e;r?.set(t,e);try{for(let i=0;ivoid 0)}function ot(e){return e=Qe(e),t=>at(t,e)}function st(e,t){return Xe(e,(n,i,a,s)=>{let c=t?.(n,i,a,s);if(c!==void 0)return c;if(typeof e==`object`){if(y(e)===`[object Object]`&&typeof e.constructor!=`function`){let t={};return s.set(e,t),H(t,e,a,s),t}switch(Object.prototype.toString.call(e)){case h:case r:case o:{let t=new e.constructor(e?.valueOf());return H(t,e),t}case Be:{let t={};return H(t,e),t.length=e.length,t[Symbol.iterator]=e[Symbol.iterator],t}default:return}}})}function ct(e){return st(e)}function lt(e){return typeof e==`object`&&!!e&&y(e)===`[object Arguments]`}function ut(e,t){let n;if(n=Array.isArray(t)?t:typeof t==`string`&&Te(t)&&!(t in Object(e))?Ne(t):[t],n.length===0)return!1;let r=e;for(let e=0;ee.length)&&(t=e.length);for(var n=0,r=Array(t);nW||Math.abs(e.left-t.left)>W||Math.abs(e.top-t.top)>W||Math.abs(e.width-t.width)>W}function wt(e){var t=e.getBoundingClientRect();return{height:t.height,left:t.left,top:t.top,width:t.width}}function Tt(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=_t((0,U.useState)({height:0,left:0,top:0,width:0}),2),n=t[0],r=t[1],i=(0,U.useRef)(null),a=(0,U.useRef)(n);a.current=n;var o=(0,U.useCallback)(e=>{if(i.current!=null&&(i.current.disconnect(),i.current=null),e!=null){var t=wt(e);if(Ct(t,a.current)&&r(t),typeof ResizeObserver<`u`){var n=new ResizeObserver(()=>{var t=wt(e);Ct(t,a.current)&&r(t)});n.observe(e),i.current=n}}},[...e]);return(0,U.useEffect)(()=>()=>{var e;(e=i.current)==null||e.disconnect()},[]),[n,o]}function Et(){return Et=Object.assign?Object.assign.bind():function(e){for(var t=1;te.length)&&(t=e.length);for(var n=0,r=Array(t);n{var n=t.separator,r=n===void 0?K.separator:n,i=t.contentStyle,a=t.itemStyle,o=t.labelStyle,s=o===void 0?K.labelStyle:o,c=t.payload,l=t.formatter,u=t.itemSorter,d=t.wrapperClassName,f=t.labelClassName,p=t.label,m=t.labelFormatter,h=t.accessibilityLayer,g=h===void 0?K.accessibilityLayer:h,_=()=>{if(c&&c.length){var e={padding:0,margin:0},t=Rt(c,u).map((e,t)=>{if(!e||e.type===`none`)return null;var n=e.formatter||l||Lt,i=e.value,o=e.name,s=i,u=o;if(n){var d=n(i,o,e,t,c);if(Array.isArray(d)){var f=jt(d,2);s=f[0],u=f[1]}else if(d!=null)s=d;else return null}var p=G(G({},K.itemStyle),{},{color:e.color||K.itemStyle.color},a);return U.createElement(`li`,{className:`recharts-tooltip-item`,key:`tooltip-item-${t}`,style:p},L(u)?U.createElement(`span`,{className:`recharts-tooltip-item-name`},u):null,L(u)?U.createElement(`span`,{className:`recharts-tooltip-item-separator`},r):null,U.createElement(`span`,{className:`recharts-tooltip-item-value`},s),U.createElement(`span`,{className:`recharts-tooltip-item-unit`},e.unit||``))});return U.createElement(`ul`,{className:`recharts-tooltip-item-list`,style:e},t)}return null},v=G(G({},K.contentStyle),i),y=G({margin:0},s),b=!e(p),x=b?p:``,S=A(`recharts-default-tooltip`,d),C=A(`recharts-tooltip-label`,f);b&&m&&c!=null&&(x=m(p,c));var w=g?{role:`status`,"aria-live":`assertive`}:{};return U.createElement(`div`,Et({className:S,style:v},w),U.createElement(`p`,{className:C,style:y},U.isValidElement(x)?x:`${x}`),_())},q=`recharts-tooltip-wrapper`,Bt={visibility:`hidden`};function Vt(e){var t=e.coordinate,n=e.translateX,r=e.translateY;return A(q,{[`${q}-right`]:z(n)&&t&&z(t.x)&&n>=t.x,[`${q}-left`]:z(n)&&t&&z(t.x)&&n=t.y,[`${q}-top`]:z(r)&&t&&z(t.y)&&r0?i:0),d=n[r]+i;if(t[r])return o[r]?u:d;var f=c[r];return f==null?0:o[r]?Math.max(uf+l?Math.max(u,f):Math.max(d,f)}function Ut(e){var t=e.translateX,n=e.translateY;return{transform:e.useTranslate3d?`translate3d(${t}px, ${n}px, 0)`:`translate(${t}px, ${n}px)`}}function Wt(e){var t=e.allowEscapeViewBox,n=e.coordinate,r=e.offsetTop,i=e.offsetLeft,a=e.position,o=e.reverseDirection,s=e.tooltipBox,c=e.useTranslate3d,l=e.viewBox,u,d,f;return s&&s.height>0&&s.width>0&&n?(d=Ht({allowEscapeViewBox:t,coordinate:n,key:`x`,offset:i,position:a,reverseDirection:o,tooltipDimension:s.width,viewBox:l,viewBoxDimension:l.width}),f=Ht({allowEscapeViewBox:t,coordinate:n,key:`y`,offset:r,position:a,reverseDirection:o,tooltipDimension:s.height,viewBox:l,viewBoxDimension:l.height}),u=Ut({translateX:d,translateY:f,useTranslate3d:c})):u=Bt,{cssProperties:u,cssClasses:Vt({translateX:d,translateY:f,coordinate:n})}}function Gt(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 J(e){for(var t=1;te.length)&&(t=e.length);for(var n=0,r=Array(t);n({dismissed:!1,dismissedAtCoordinate:{x:0,y:0}})),2),r=n[0],i=n[1];U.useEffect(()=>{var t=t=>{t.key===`Escape`&&i({dismissed:!0,dismissedAtCoordinate:{x:e.coordinate?.x??0,y:e.coordinate?.y??0}})};return document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`keydown`,t)}},[e.coordinate?.x,e.coordinate?.y]),r.dismissed&&((e.coordinate?.x??0)!==r.dismissedAtCoordinate.x||(e.coordinate?.y??0)!==r.dismissedAtCoordinate.y)&&i(J(J({},r),{},{dismissed:!1}));var a=Wt({allowEscapeViewBox:e.allowEscapeViewBox,coordinate:e.coordinate,offsetLeft:typeof e.offset==`number`?e.offset:e.offset.x,offsetTop:typeof e.offset==`number`?e.offset:e.offset.y,position:e.position,reverseDirection:e.reverseDirection,tooltipBox:e.lastBoundingBox,useTranslate3d:e.useTranslate3d,viewBox:e.viewBox}),o=a.cssClasses,s=a.cssProperties,c=J(J({},e.hasPortalFromProps?{}:J(J({transition:tn({prefersReducedMotion:t,isAnimationActive:e.isAnimationActive,active:e.active,animationDuration:e.animationDuration,animationEasing:e.animationEasing})},s),{},{pointerEvents:`none`,position:`absolute`,top:0,left:0})),{},{visibility:!r.dismissed&&e.active&&e.hasPayload?`visible`:`hidden`},e.wrapperStyle);return U.createElement(`div`,{xmlns:`http://www.w3.org/1999/xhtml`,tabIndex:-1,className:o,style:c,ref:e.innerRef},e.children)}var rn=U.memo(nn),an=[`x`,`y`,`top`,`left`,`width`,`height`,`className`];function on(){return on=Object.assign?Object.assign.bind():function(e){for(var t=1;t`M${e},${i}v${r}M${a},${t}h${n}`,hn=e=>{var t=e.x,n=t===void 0?0:t,r=e.y,i=r===void 0?0:r,a=e.top,o=a===void 0?0:a,s=e.left,c=s===void 0?0:s,l=e.width,u=l===void 0?0:l,d=e.height,f=d===void 0?0:d,p=e.className,m=fn(e,an),h=cn({x:n,y:i,top:o,left:c,width:u,height:f},m);return!z(n)||!z(i)||!z(u)||!z(f)||!z(o)||!z(c)?null:U.createElement(`path`,on({},pe(h),{className:A(`recharts-cross`,p),d:mn(n,i,u,f,o,c)}))};function gn(e,t,n,r){var i=r/2;return{stroke:`none`,fill:`#ccc`,x:e===`horizontal`?t.x-i:n.left+.5,y:e===`horizontal`?n.top+.5:t.y-i,width:e===`horizontal`?r:n.width-1,height:e===`horizontal`?n.height-1:r}}function _n(e){var t=e.cx,n=e.cy,r=e.radius,i=e.startAngle,a=e.endAngle;return{points:[R(t,n,r,i),R(t,n,r,a)],cx:t,cy:n,radius:r,startAngle:i,endAngle:a}}var vn,yn,bn,xn,Sn,Cn,wn;function Tn(){return Tn=Object.assign?Object.assign.bind():function(e){for(var t=1;tEe(t-e)*Math.min(Math.abs(t-e),359.999),X=e=>{var t=e.cx,n=e.cy,r=e.radius,i=e.angle,a=e.sign,o=e.isExternal,s=e.cornerRadius,c=e.cornerIsExternal,l=s*(o?1:-1)+r,u=Math.asin(s/l)/v,d=c?i:i+a*u,f=R(t,n,l,d),p=R(t,n,r,d),m=c?i-a*u:i;return{center:f,circleTangency:p,lineTangency:R(t,n,l*Math.cos(u*v),m),theta:u}},Dn=e=>{var t=e.cx,n=e.cy,r=e.innerRadius,i=e.outerRadius,a=e.startAngle,o=e.endAngle,s=En(a,o),c=a+s,l=R(t,n,i,a),u=R(t,n,i,c),d=F(vn||=Y([`M `,`,`,` diff --git a/internal/webui/static/assets/CostChart-HjooRbfZ.js b/internal/webui/static/assets/CostChart-PEvxXQD1.js similarity index 96% rename from internal/webui/static/assets/CostChart-HjooRbfZ.js rename to internal/webui/static/assets/CostChart-PEvxXQD1.js index 47bde5ab..56e051b1 100644 --- a/internal/webui/static/assets/CostChart-HjooRbfZ.js +++ b/internal/webui/static/assets/CostChart-PEvxXQD1.js @@ -1 +1 @@ -import{n as e,t}from"./CartesianGrid-BLRH4M4a.js";import{Tn as n,_n as r,a as i,at as a,gn as o,i as s,r as c,t as l,vn as u,wn as d,xn as f}from"./index-CZG9DLai.js";var p=n(d(),1),m=f(),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`?o(e):t===`tokens`?r(e):u(e)}function y(e,t){return t===`cost`?`¥${e>=10?Math.round(e):Number(e.toFixed(1))}`:t===`tokens`?r(e):u(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:n,models:r,lang:o,emptyLabel:u,totalLabel:d,metric:f=`credits`}){let v=(0,p.useMemo)(()=>r.map(e=>e.id),[r]),x=(0,p.useMemo)(()=>n.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}),[n,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!n.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)(a,{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-${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)(t,{vertical:!1,stroke:`var(--separator)`,strokeDasharray:`3 6`}),(0,m.jsx)(s,{dataKey:`at`,tickLine:!1,axisLine:!1,minTickGap:28,tick:{fill:`var(--muted)`,fontSize:10,fontFamily:`var(--font-mono)`},tickFormatter:e=>g(e,C,o)}),(0,m.jsx)(c,{width:52,tickLine:!1,axisLine:!1,tick:{fill:`var(--muted)`,fontSize:10,fontFamily:`var(--font-mono)`},tickFormatter:e=>y(e,f)}),(0,m.jsx)(e,{cursor:{stroke:`var(--border)`,strokeDasharray:`3 3`},content:(0,m.jsx)(b,{daily:C,lang:o,models:r,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:r.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{n as e,t}from"./CartesianGrid-BMNtov-j.js";import{Tn as n,_n as r,a as i,at as a,gn as o,i as s,r as c,t as l,vn as u,wn as d,xn as f}from"./index-DHWWlsS6.js";var p=n(d(),1),m=f(),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`?o(e):t===`tokens`?r(e):u(e)}function y(e,t){return t===`cost`?`¥${e>=10?Math.round(e):Number(e.toFixed(1))}`:t===`tokens`?r(e):u(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:n,models:r,lang:o,emptyLabel:u,totalLabel:d,metric:f=`credits`}){let v=(0,p.useMemo)(()=>r.map(e=>e.id),[r]),x=(0,p.useMemo)(()=>n.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}),[n,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!n.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)(a,{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-${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)(t,{vertical:!1,stroke:`var(--separator)`,strokeDasharray:`3 6`}),(0,m.jsx)(s,{dataKey:`at`,tickLine:!1,axisLine:!1,minTickGap:28,tick:{fill:`var(--muted)`,fontSize:10,fontFamily:`var(--font-mono)`},tickFormatter:e=>g(e,C,o)}),(0,m.jsx)(c,{width:52,tickLine:!1,axisLine:!1,tick:{fill:`var(--muted)`,fontSize:10,fontFamily:`var(--font-mono)`},tickFormatter:e=>y(e,f)}),(0,m.jsx)(e,{cursor:{stroke:`var(--border)`,strokeDasharray:`3 3`},content:(0,m.jsx)(b,{daily:C,lang:o,models:r,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:r.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/LiveSparkline-C40ZJRGg.js b/internal/webui/static/assets/LiveSparkline-C2h2mKvg.js similarity index 80% rename from internal/webui/static/assets/LiveSparkline-C40ZJRGg.js rename to internal/webui/static/assets/LiveSparkline-C2h2mKvg.js index e6c584e5..f68761b7 100644 --- a/internal/webui/static/assets/LiveSparkline-C40ZJRGg.js +++ b/internal/webui/static/assets/LiveSparkline-C2h2mKvg.js @@ -1 +1 @@ -import{a as e,at as t,r as n,t as r,xn as i}from"./index-CZG9DLai.js";var a=i();function o({samples:i,capacity:o,label:s}){let c=i.length?i:[{at:0,value:0}],l=Math.max(1,o,...c.map(e=>e.value));return(0,a.jsx)(`div`,{className:`h-6 w-[120px] shrink-0`,role:`img`,"aria-label":s,children:(0,a.jsx)(t,{width:`100%`,height:`100%`,children:(0,a.jsxs)(r,{data:c,margin:{top:1,right:0,bottom:1,left:0},children:[(0,a.jsx)(n,{hide:!0,domain:[0,l]}),(0,a.jsx)(e,{type:`monotone`,dataKey:`value`,stroke:`var(--foreground)`,strokeOpacity:.7,strokeWidth:1.25,fill:`var(--foreground)`,fillOpacity:.08,isAnimationActive:!1,dot:!1})]})})})}export{o as LiveSparkline}; \ No newline at end of file +import{a as e,at as t,r as n,t as r,xn as i}from"./index-DHWWlsS6.js";var a=i();function o({samples:i,capacity:o,label:s}){let c=i.length?i:[{at:0,value:0}],l=Math.max(1,o,...c.map(e=>e.value));return(0,a.jsx)(`div`,{className:`h-6 w-[120px] shrink-0`,role:`img`,"aria-label":s,children:(0,a.jsx)(t,{width:`100%`,height:`100%`,children:(0,a.jsxs)(r,{data:c,margin:{top:1,right:0,bottom:1,left:0},children:[(0,a.jsx)(n,{hide:!0,domain:[0,l]}),(0,a.jsx)(e,{type:`monotone`,dataKey:`value`,stroke:`var(--foreground)`,strokeOpacity:.7,strokeWidth:1.25,fill:`var(--foreground)`,fillOpacity:.08,isAnimationActive:!1,dot:!1})]})})})}export{o as LiveSparkline}; \ No newline at end of file diff --git a/internal/webui/static/assets/TrafficChart-DME0-Hqp.js b/internal/webui/static/assets/TrafficChart-CsxXsi2g.js similarity index 99% rename from internal/webui/static/assets/TrafficChart-DME0-Hqp.js rename to internal/webui/static/assets/TrafficChart-CsxXsi2g.js index 55c675bb..1c533601 100644 --- a/internal/webui/static/assets/TrafficChart-DME0-Hqp.js +++ b/internal/webui/static/assets/TrafficChart-CsxXsi2g.js @@ -1 +1 @@ -import{n as e,t}from"./CartesianGrid-BLRH4M4a.js";import{$ as n,$t as r,B as i,C as a,D as o,G as s,Q as c,Qt as l,S as u,Sn as d,T as f,Tn as p,U as m,V as h,W as g,Y as _,Yt as v,_ as y,_n as b,_t as x,a as S,at as C,b as w,bn as T,c as E,ct as D,d as ee,dn as O,f as k,fn as A,ft as j,g as M,h as te,hn as ne,i as re,in as N,k as P,lt as F,m as I,mn as ie,mt as L,n as ae,o as oe,p as se,pt as R,r as ce,rn as le,s as ue,st as z,tt as de,un as fe,v as pe,w as me,wn as he,x as ge,xn as _e,y as ve,yn as B,yt as ye}from"./index-CZG9DLai.js";var V=p(he()),be=[`animationElapsedTime`,`isAnimating`,`isEntrance`,`visibleLength`,`strokeDasharray`,`connectNulls`];function H(){return H=Object.assign?Object.assign.bind():function(e){for(var t=1;te+t,0);if(!i)return U(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[...Te(r,a),...s,...f].map(e=>`${e}px`).join(`, `)}function De(e,t,n){return e?Ee(n,t,`${e}`.split(/[,\s]+/gim).map(e=>parseFloat(e))):U(t,n)}function Oe(e){e.animationElapsedTime,e.isAnimating,e.isEntrance;var t=e.visibleLength,n=e.strokeDasharray,r=e.connectNulls,i=xe(e,be),a=r??!1,o;if(t!=null){var s=i.pathRef;o=De(n,Ce(s?.current??null),t)}else n!=null&&(o=String(n));return V.createElement(_,H({},i,{connectNulls:a,strokeDasharray:o}))}function ke(e){var t=(0,V.useRef)(0),n=(0,V.useRef)(0),r=(0,V.useRef)(!1),i=(0,V.useRef)(e);return i.current!==e&&(t.current=n.current,i.current=e),(0,V.useCallback)((e,i)=>{if(r.current)return null;var a=Math.min(N(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 Ae=[`children`];function je(e,t){if(e==null)return{};var n,r,i=Me(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r({x:0,y:0,value:0}),errorBarOffset:0});function Pe(e){var t=e.children,n=je(e,Ae);return V.createElement(Ne.Provider,{value:n},t)}var W=(e,t,n,r)=>i(e,`xAxis`,t,r),G=(e,t,n,r)=>h(e,`xAxis`,t,r),K=(e,t,n,r)=>i(e,`yAxis`,n,r),q=(e,t,n,r)=>h(e,`yAxis`,n,r),Fe=x([n,W,K,G,q],(e,t,n,r,i)=>L(e,`xAxis`)?D(t,r,!1):D(n,i,!1)),Ie=(e,t,n,r,i)=>i;function Le(e){return e.type===`line`}var Re=x([m,Ie],(e,t)=>e.filter(Le).find(e=>e.id===t)),ze=x([n,W,K,G,q,Re,Fe,s],(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 at({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataKey:d,bandSize:o,displayedData:p})}}),Be=[`id`],Ve=[`type`,`layout`,`connectNulls`,`needClip`,`shape`,`strokeDasharray`],He=[`activeDot`,`animateNewValues`,`animationBegin`,`animationDuration`,`animationEasing`,`connectNulls`,`dot`,`hide`,`isAnimationActive`,`label`,`legendType`,`xAxisId`,`yAxisId`,`id`];function J(){return J=Object.assign?Object.assign.bind():function(e){for(var t=1;t0?t/n:0}var Q={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=Je(e),r=[];for(var i of e)if(i.status===`matched`)r.push(Z(Z({},i.next),{},{x:l(i.prev.x,i.next.x,t),y:l(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(Z(Z({},i.next),{},{x:l(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(Z(Z({},i.prev),{},{x:l(i.prev.x,o,t),y:i.prev.y}))}return r},animationMatchBy:ve,connectNulls:!1,dot:!0,fill:`#fff`,hide:!1,isAnimationActive:`auto`,label:!1,legendType:`line`,shape:Oe,stroke:`#3182bd`,strokeWidth:1,xAxisId:0,yAxisId:0,zIndex:g.line,type:`linear`},Ye=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:j(n,t),payload:e}]},Xe=V.memo(e=>{var t=e.dataKey,n=e.data,r=e.stroke,i=e.strokeWidth,a=e.fill,o=e.name,s=e.hide,c=e.unit,l=e.formatter,u=e.tooltipType,d=e.id,f={dataDefinedOnItem:n,getPosition:le,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:t,nameKey:void 0,name:j(o,t),hide:s,type:u,color:r,unit:c,formatter:l,graphicalItemId:d}};return V.createElement(ge,{tooltipEntrySettings:f})});function Ze(e){var t=e.clipPathId,n=e.points,r=e.props,i=r.dot,a=r.dataKey,o=r.needClip;r.id;var s=Y(r,Be),c=A(s);return V.createElement(I,{points:n,dot:i,className:`recharts-line-dots`,dotClassName:`recharts-line-dot`,dataKey:a,baseProps:c,needClip:o,clipPathId:t})}function Qe(e){var t=e.showLabels,n=e.children,r=e.points,i=(0,V.useMemo)(()=>r?.map(e=>{var t={x:e.x??0,y:e.y??0,width:0,lowerWidth:0,upperWidth:0,height:0};return Z(Z({},t),{},{value:e.value,payload:e.payload,viewBox:t,parentViewBox:void 0,fill:void 0})}),[r]);return V.createElement(me,{value:t?i:void 0},n)}function $e(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,d=i.layout,f=i.connectNulls,p=i.needClip,m=i.shape,h=i.strokeDasharray,g=Y(i,Ve),_=Z(Z({},O(g)),{},{fill:`none`,className:`recharts-line-curve`,clipPath:p?`url(#clipPath-${t})`:void 0,points:r,type:l,layout:d,connectNulls:f,strokeDasharray:h??i.strokeDasharray,pathRef:n,animationElapsedTime:a,isAnimating:o,isEntrance:i.animateNewValues?s:!1,visibleLength:c});return V.createElement(V.Fragment,null,r?.length>1&&V.createElement(u,{option:m,DefaultShape:Q.shape,shapeProps:_}),V.createElement(Ze,{points:r,clipPathId:t,props:i}))}function et(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,p=n.layout,m=qe(r.current),h=pe(n.onAnimationStart,n.onAnimationEnd),g=h.isAnimating,_=h.handleAnimationStart,v=h.handleAnimationEnd,b=!g,x=ke(a),S=(0,V.useCallback)(e=>e>0&&m>0,[m]);return V.createElement(Qe,{points:a,showLabels:b},n.children,V.createElement(y,{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:S,layout:p},(e,i,a)=>{var o=g||i<1,s=o?x(i,m):null;return V.createElement($e,{props:n,points:e,clipPathId:t,pathRef:r,animationElapsedTime:i,isAnimating:o,isEntrance:a,visibleLength:s})}),V.createElement(f,{label:n.label}))}function tt(e){var t=e.clipPathId,n=e.props,r=(0,V.useRef)(null),i=(0,V.useRef)(null);return V.createElement(et,{props:n,clipPathId:t,previousPointsRef:r,pathRef:i})}var nt=(e,t)=>({x:e.x??void 0,y:e.y??void 0,value:e.value,errorVal:R(e.payload,t)}),rt=class extends V.Component{render(){var e=this.props,t=e.hide,n=e.dot,r=e.points,i=e.className,o=e.xAxisId,s=e.yAxisId,c=e.top,l=e.left,u=e.width,f=e.height,p=e.id,m=e.needClip,h=e.zIndex;if(t)return null;var g=d(`recharts-line`,i),_=p,v=oe(n),y=v.r,b=v.strokeWidth,x=a(n),S=y*2+b,C=m?`url(#clipPath-${x?``:`dots-`}${_})`:void 0;return V.createElement(P,{zIndex:h},V.createElement(fe,{className:g},m&&V.createElement(`defs`,null,V.createElement(ue,{clipPathId:_,xAxisId:o,yAxisId:s}),!x&&V.createElement(`clipPath`,{id:`clipPath-dots-${_}`},V.createElement(`rect`,{x:l-S/2,y:c-S/2,width:u+S,height:f+S}))),V.createElement(Pe,{xAxisId:o,yAxisId:s,data:r,dataPointFormatter:nt,errorBarOffset:0},V.createElement(tt,{props:this.props,clipPathId:_}))),V.createElement(k,{activeDot:this.props.activeDot,points:r,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:C}))}};function it(e){var t=v(e,Q),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,h=t.id,g=Y(t,He),_=E(p,m).needClip,y=se(),b=de(),x=z(),S=ye(e=>ze(e,p,m,x,h));if(b!==`horizontal`&&b!==`vertical`||S==null||y==null)return null;var C=y.height,w=y.width,T=y.x,D=y.y;return V.createElement(rt,J({},g,{id:h,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:S,layout:b,height:C,width:w,left:T,top:D,needClip:_}))}function at(e){var t=e.layout,n=e.xAxis,i=e.yAxis,a=e.xAxisTicks,o=e.yAxisTicks,s=e.dataKey,c=e.bandSize;return e.displayedData.map((e,l)=>{var u=R(e,s);if(t===`horizontal`)return{x:F({axis:n,ticks:a,bandSize:c,entry:e,index:l}),y:(r(u)?null:i.scale.map(u))??null,value:u,payload:e};var d=r(u)?null:n.scale.map(u),f=F({axis:i,ticks:o,bandSize:c,entry:e,index:l});return d==null||f==null?null:{x:d,y:f,value:u,payload:e}}).filter(Boolean)}function ot(e){var t=v(e,Q),n=z();return V.createElement(M,{id:t.id,type:`line`},e=>V.createElement(V.Fragment,null,V.createElement(w,{legendPayload:Ye(t)}),V.createElement(Xe,{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}),V.createElement(te,{type:`line`,id:e,data:t.data,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,dataKey:t.dataKey,hide:t.hide,isPanorama:n}),V.createElement(it,J({},t,{id:e}))))}var st=V.memo(ot,c);st.displayName=`Line`;var ct=[`axis`],lt=(0,V.forwardRef)((e,t)=>V.createElement(ae,{chartName:`ComposedChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:ct,tooltipPayloadSearcher:o,categoricalChartProps:e,ref:t})),ut={metric:24,title:18,section:15,body:13,xs:12,caption:12},$=_e();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]})]})}function ht({series:n,lang:r,emptyLabel:i,okLabel:a,errorLabel:o,onSelectRange:s,selectHint:c,labels:l,initialMetric:u=`requests`}){let[d,f]=(0,V.useState)(u),[p,m]=(0,V.useState)(null),[h,g]=(0,V.useState)(null),_=(0,V.useRef)(!1),v=(0,V.useRef)(null),y=(0,V.useMemo)(()=>n.map(pt),[n]),x=y[0],w=y[y.length-1],E=(x&&w?Date.parse(w.at)-Date.parse(x.at):0)>1728e5,D=l??{requests:`Requests`,tokens:`Tokens`,latency:`p95 latency`,input:`input`,output:`output`,cacheRead:`cache read`,p50:`p50`,p95:`p95`,total:`total`},O=d===`tokens`?[{key:`inputTokens`,label:D.input,color:`var(--foreground)`,area:!0,width:1.5,opacity:.75},{key:`outputTokens`,label:D.output,color:`var(--success)`,area:!0,width:1.5},{key:`cacheTokens`,label:D.cacheRead,color:`var(--muted)`,width:1.25,opacity:.8}]:d===`latency`?[{key:`p95`,label:D.p95,color:`var(--warning)`,area:!0,width:1.75},{key:`p50`,label:D.p50,color:`var(--muted)`,width:1.25,opacity:.85}]:[{key:`okCount`,label:a,color:`var(--success)`,area:!0,width:1.75},{key:`errorCount`,label:o,color:`var(--danger)`,area:!0,width:1.25,opacity:.7}],k=e=>e==null?`—`:d===`latency`?B(e):b(e),A=d===`requests`?e=>e.requests:d===`tokens`?e=>e.inputTokens+e.outputTokens:void 0,j=y.flatMap(e=>O.map(t=>Number(e[t.key]??0))),M=d===`requests`?Math.max(0,...y.map(e=>e.requests)):Math.max(0,...j),te=ft(M),N=y.some(e=>e.requests>0),P=y.map(e=>`${e.at}:${e.requests}:${e.error}`).join(`|`);(0,V.useLayoutEffect)(()=>{let e=v.current;if(!e||!N||_.current)return;let t=!1,n=null,r=T.context(()=>{let r=T.matchMedia(),i=()=>{let t=T.utils.toArray(`.recharts-area-area`,e),n=T.utils.toArray(`.recharts-line-curve`,e);return!t.length&&!n.length?!1:(r.add(`(prefers-reduced-motion: reduce)`,()=>{T.set(n,{clearProps:`strokeDashoffset,strokeDasharray`}),T.set(t,{clearProps:`autoAlpha`})}),r.add(`(prefers-reduced-motion: no-preference)`,()=>{T.fromTo(t,{autoAlpha:0},{autoAlpha:1,duration:.45,ease:`power2.out`,stagger:.05}),n.forEach((e,t)=>{let n=e.getTotalLength();T.fromTo(e,{strokeDasharray:n,strokeDashoffset:n},{strokeDashoffset:0,duration:.7,delay:t*.05,ease:`power2.out`})})}),!0)};if(i()){t=!0,_.current=!0;return}n=new MutationObserver(()=>{t||i()&&(t=!0,_.current=!0,n?.disconnect())}),n.observe(e,{childList:!0,subtree:!0})},e);return()=>{n?.disconnect(),r.revert()}},[N,P]);let F=y.length>1?Date.parse(y[1].at)-Date.parse(y[0].at):36e5,I=()=>{if(p&&h&&s){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)+F;s(new Date(n).toISOString(),new Date(r).toISOString())}}m(null),g(null)},L=e=>{let t=e?.activeLabel;return t==null?null:String(t)};return!n.length||!N?(0,$.jsx)(ne,{emptyLabel:i}):(0,$.jsxs)(`div`,{ref:v,className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:`mb-3 flex justify-end`,children:(0,$.jsx)(ie,{value:d,onChange:e=>f(e),ariaLabel:D.requests,options:[{id:`requests`,label:D.requests},{id:`tokens`,label:D.tokens},{id:`latency`,label:D.latency}]})}),(0,$.jsx)(`div`,{className:`h-56 w-full`,children:(0,$.jsx)(C,{width:`100%`,height:`100%`,children:(0,$.jsxs)(lt,{data:y,margin:{top:8,right:8,bottom:0,left:0},style:s?{cursor:`crosshair`,userSelect:`none`}:void 0,onMouseDown:s?e=>{let t=L(e);t&&(m(t),g(t))}:void 0,onMouseMove:s?e=>{if(!p)return;let t=L(e);t&&g(t)}:void 0,onMouseUp:s?I:void 0,onMouseLeave:s?()=>{m(null),g(null)}:void 0,children:[(0,$.jsx)(`defs`,{children:O.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)(t,{vertical:!1,stroke:`var(--separator)`,strokeDasharray:`3 6`}),(0,$.jsx)(re,{dataKey:`at`,tickLine:!1,axisLine:!1,minTickGap:28,tick:{fill:`var(--muted)`,fontSize:ut.caption,fontFamily:`var(--font-mono)`},tickFormatter:e=>dt(e,E,r)}),(0,$.jsx)(ce,{width:d===`latency`?44:36,domain:[0,te],tickLine:!1,axisLine:!1,allowDecimals:!1,tick:{fill:`var(--muted)`,fontSize:ut.caption,fontFamily:`var(--font-mono)`},tickFormatter:e=>d===`latency`?B(e):b(e)}),(0,$.jsx)(e,{cursor:{stroke:`var(--border)`,strokeDasharray:`3 3`},content:(0,$.jsx)(mt,{daily:E,lang:r,specs:O,format:k,totalLabel:D.total,total:A})}),O.filter(e=>e.area).map(e=>(0,$.jsx)(S,{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)}`)),O.map(e=>(0,$.jsx)(st,{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)(ee,{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:O.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:[s&&c?(0,$.jsx)(`span`,{children:c}):null,(0,$.jsxs)(`span`,{className:`mono`,children:[k(M),` peak`]})]})]})]})}export{ht as TrafficChart}; \ No newline at end of file +import{n as e,t}from"./CartesianGrid-BMNtov-j.js";import{$ as n,$t as r,B as i,C as a,D as o,G as s,Q as c,Qt as l,S as u,Sn as d,T as f,Tn as p,U as m,V as h,W as g,Y as _,Yt as v,_ as y,_n as b,_t as x,a as S,at as C,b as w,bn as T,c as E,ct as D,d as ee,dn as O,f as k,fn as A,ft as j,g as M,h as te,hn as ne,i as re,in as N,k as P,lt as F,m as I,mn as ie,mt as L,n as ae,o as oe,p as se,pt as R,r as ce,rn as le,s as ue,st as z,tt as de,un as fe,v as pe,w as me,wn as he,x as ge,xn as _e,y as ve,yn as B,yt as ye}from"./index-DHWWlsS6.js";var V=p(he()),be=[`animationElapsedTime`,`isAnimating`,`isEntrance`,`visibleLength`,`strokeDasharray`,`connectNulls`];function H(){return H=Object.assign?Object.assign.bind():function(e){for(var t=1;te+t,0);if(!i)return U(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[...Te(r,a),...s,...f].map(e=>`${e}px`).join(`, `)}function De(e,t,n){return e?Ee(n,t,`${e}`.split(/[,\s]+/gim).map(e=>parseFloat(e))):U(t,n)}function Oe(e){e.animationElapsedTime,e.isAnimating,e.isEntrance;var t=e.visibleLength,n=e.strokeDasharray,r=e.connectNulls,i=xe(e,be),a=r??!1,o;if(t!=null){var s=i.pathRef;o=De(n,Ce(s?.current??null),t)}else n!=null&&(o=String(n));return V.createElement(_,H({},i,{connectNulls:a,strokeDasharray:o}))}function ke(e){var t=(0,V.useRef)(0),n=(0,V.useRef)(0),r=(0,V.useRef)(!1),i=(0,V.useRef)(e);return i.current!==e&&(t.current=n.current,i.current=e),(0,V.useCallback)((e,i)=>{if(r.current)return null;var a=Math.min(N(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 Ae=[`children`];function je(e,t){if(e==null)return{};var n,r,i=Me(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r({x:0,y:0,value:0}),errorBarOffset:0});function Pe(e){var t=e.children,n=je(e,Ae);return V.createElement(Ne.Provider,{value:n},t)}var W=(e,t,n,r)=>i(e,`xAxis`,t,r),G=(e,t,n,r)=>h(e,`xAxis`,t,r),K=(e,t,n,r)=>i(e,`yAxis`,n,r),q=(e,t,n,r)=>h(e,`yAxis`,n,r),Fe=x([n,W,K,G,q],(e,t,n,r,i)=>L(e,`xAxis`)?D(t,r,!1):D(n,i,!1)),Ie=(e,t,n,r,i)=>i;function Le(e){return e.type===`line`}var Re=x([m,Ie],(e,t)=>e.filter(Le).find(e=>e.id===t)),ze=x([n,W,K,G,q,Re,Fe,s],(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 at({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataKey:d,bandSize:o,displayedData:p})}}),Be=[`id`],Ve=[`type`,`layout`,`connectNulls`,`needClip`,`shape`,`strokeDasharray`],He=[`activeDot`,`animateNewValues`,`animationBegin`,`animationDuration`,`animationEasing`,`connectNulls`,`dot`,`hide`,`isAnimationActive`,`label`,`legendType`,`xAxisId`,`yAxisId`,`id`];function J(){return J=Object.assign?Object.assign.bind():function(e){for(var t=1;t0?t/n:0}var Q={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=Je(e),r=[];for(var i of e)if(i.status===`matched`)r.push(Z(Z({},i.next),{},{x:l(i.prev.x,i.next.x,t),y:l(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(Z(Z({},i.next),{},{x:l(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(Z(Z({},i.prev),{},{x:l(i.prev.x,o,t),y:i.prev.y}))}return r},animationMatchBy:ve,connectNulls:!1,dot:!0,fill:`#fff`,hide:!1,isAnimationActive:`auto`,label:!1,legendType:`line`,shape:Oe,stroke:`#3182bd`,strokeWidth:1,xAxisId:0,yAxisId:0,zIndex:g.line,type:`linear`},Ye=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:j(n,t),payload:e}]},Xe=V.memo(e=>{var t=e.dataKey,n=e.data,r=e.stroke,i=e.strokeWidth,a=e.fill,o=e.name,s=e.hide,c=e.unit,l=e.formatter,u=e.tooltipType,d=e.id,f={dataDefinedOnItem:n,getPosition:le,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:t,nameKey:void 0,name:j(o,t),hide:s,type:u,color:r,unit:c,formatter:l,graphicalItemId:d}};return V.createElement(ge,{tooltipEntrySettings:f})});function Ze(e){var t=e.clipPathId,n=e.points,r=e.props,i=r.dot,a=r.dataKey,o=r.needClip;r.id;var s=Y(r,Be),c=A(s);return V.createElement(I,{points:n,dot:i,className:`recharts-line-dots`,dotClassName:`recharts-line-dot`,dataKey:a,baseProps:c,needClip:o,clipPathId:t})}function Qe(e){var t=e.showLabels,n=e.children,r=e.points,i=(0,V.useMemo)(()=>r?.map(e=>{var t={x:e.x??0,y:e.y??0,width:0,lowerWidth:0,upperWidth:0,height:0};return Z(Z({},t),{},{value:e.value,payload:e.payload,viewBox:t,parentViewBox:void 0,fill:void 0})}),[r]);return V.createElement(me,{value:t?i:void 0},n)}function $e(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,d=i.layout,f=i.connectNulls,p=i.needClip,m=i.shape,h=i.strokeDasharray,g=Y(i,Ve),_=Z(Z({},O(g)),{},{fill:`none`,className:`recharts-line-curve`,clipPath:p?`url(#clipPath-${t})`:void 0,points:r,type:l,layout:d,connectNulls:f,strokeDasharray:h??i.strokeDasharray,pathRef:n,animationElapsedTime:a,isAnimating:o,isEntrance:i.animateNewValues?s:!1,visibleLength:c});return V.createElement(V.Fragment,null,r?.length>1&&V.createElement(u,{option:m,DefaultShape:Q.shape,shapeProps:_}),V.createElement(Ze,{points:r,clipPathId:t,props:i}))}function et(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,p=n.layout,m=qe(r.current),h=pe(n.onAnimationStart,n.onAnimationEnd),g=h.isAnimating,_=h.handleAnimationStart,v=h.handleAnimationEnd,b=!g,x=ke(a),S=(0,V.useCallback)(e=>e>0&&m>0,[m]);return V.createElement(Qe,{points:a,showLabels:b},n.children,V.createElement(y,{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:S,layout:p},(e,i,a)=>{var o=g||i<1,s=o?x(i,m):null;return V.createElement($e,{props:n,points:e,clipPathId:t,pathRef:r,animationElapsedTime:i,isAnimating:o,isEntrance:a,visibleLength:s})}),V.createElement(f,{label:n.label}))}function tt(e){var t=e.clipPathId,n=e.props,r=(0,V.useRef)(null),i=(0,V.useRef)(null);return V.createElement(et,{props:n,clipPathId:t,previousPointsRef:r,pathRef:i})}var nt=(e,t)=>({x:e.x??void 0,y:e.y??void 0,value:e.value,errorVal:R(e.payload,t)}),rt=class extends V.Component{render(){var e=this.props,t=e.hide,n=e.dot,r=e.points,i=e.className,o=e.xAxisId,s=e.yAxisId,c=e.top,l=e.left,u=e.width,f=e.height,p=e.id,m=e.needClip,h=e.zIndex;if(t)return null;var g=d(`recharts-line`,i),_=p,v=oe(n),y=v.r,b=v.strokeWidth,x=a(n),S=y*2+b,C=m?`url(#clipPath-${x?``:`dots-`}${_})`:void 0;return V.createElement(P,{zIndex:h},V.createElement(fe,{className:g},m&&V.createElement(`defs`,null,V.createElement(ue,{clipPathId:_,xAxisId:o,yAxisId:s}),!x&&V.createElement(`clipPath`,{id:`clipPath-dots-${_}`},V.createElement(`rect`,{x:l-S/2,y:c-S/2,width:u+S,height:f+S}))),V.createElement(Pe,{xAxisId:o,yAxisId:s,data:r,dataPointFormatter:nt,errorBarOffset:0},V.createElement(tt,{props:this.props,clipPathId:_}))),V.createElement(k,{activeDot:this.props.activeDot,points:r,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:C}))}};function it(e){var t=v(e,Q),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,h=t.id,g=Y(t,He),_=E(p,m).needClip,y=se(),b=de(),x=z(),S=ye(e=>ze(e,p,m,x,h));if(b!==`horizontal`&&b!==`vertical`||S==null||y==null)return null;var C=y.height,w=y.width,T=y.x,D=y.y;return V.createElement(rt,J({},g,{id:h,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:S,layout:b,height:C,width:w,left:T,top:D,needClip:_}))}function at(e){var t=e.layout,n=e.xAxis,i=e.yAxis,a=e.xAxisTicks,o=e.yAxisTicks,s=e.dataKey,c=e.bandSize;return e.displayedData.map((e,l)=>{var u=R(e,s);if(t===`horizontal`)return{x:F({axis:n,ticks:a,bandSize:c,entry:e,index:l}),y:(r(u)?null:i.scale.map(u))??null,value:u,payload:e};var d=r(u)?null:n.scale.map(u),f=F({axis:i,ticks:o,bandSize:c,entry:e,index:l});return d==null||f==null?null:{x:d,y:f,value:u,payload:e}}).filter(Boolean)}function ot(e){var t=v(e,Q),n=z();return V.createElement(M,{id:t.id,type:`line`},e=>V.createElement(V.Fragment,null,V.createElement(w,{legendPayload:Ye(t)}),V.createElement(Xe,{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}),V.createElement(te,{type:`line`,id:e,data:t.data,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,dataKey:t.dataKey,hide:t.hide,isPanorama:n}),V.createElement(it,J({},t,{id:e}))))}var st=V.memo(ot,c);st.displayName=`Line`;var ct=[`axis`],lt=(0,V.forwardRef)((e,t)=>V.createElement(ae,{chartName:`ComposedChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:ct,tooltipPayloadSearcher:o,categoricalChartProps:e,ref:t})),ut={metric:24,title:18,section:15,body:13,xs:12,caption:12},$=_e();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]})]})}function ht({series:n,lang:r,emptyLabel:i,okLabel:a,errorLabel:o,onSelectRange:s,selectHint:c,labels:l,initialMetric:u=`requests`}){let[d,f]=(0,V.useState)(u),[p,m]=(0,V.useState)(null),[h,g]=(0,V.useState)(null),_=(0,V.useRef)(!1),v=(0,V.useRef)(null),y=(0,V.useMemo)(()=>n.map(pt),[n]),x=y[0],w=y[y.length-1],E=(x&&w?Date.parse(w.at)-Date.parse(x.at):0)>1728e5,D=l??{requests:`Requests`,tokens:`Tokens`,latency:`p95 latency`,input:`input`,output:`output`,cacheRead:`cache read`,p50:`p50`,p95:`p95`,total:`total`},O=d===`tokens`?[{key:`inputTokens`,label:D.input,color:`var(--foreground)`,area:!0,width:1.5,opacity:.75},{key:`outputTokens`,label:D.output,color:`var(--success)`,area:!0,width:1.5},{key:`cacheTokens`,label:D.cacheRead,color:`var(--muted)`,width:1.25,opacity:.8}]:d===`latency`?[{key:`p95`,label:D.p95,color:`var(--warning)`,area:!0,width:1.75},{key:`p50`,label:D.p50,color:`var(--muted)`,width:1.25,opacity:.85}]:[{key:`okCount`,label:a,color:`var(--success)`,area:!0,width:1.75},{key:`errorCount`,label:o,color:`var(--danger)`,area:!0,width:1.25,opacity:.7}],k=e=>e==null?`—`:d===`latency`?B(e):b(e),A=d===`requests`?e=>e.requests:d===`tokens`?e=>e.inputTokens+e.outputTokens:void 0,j=y.flatMap(e=>O.map(t=>Number(e[t.key]??0))),M=d===`requests`?Math.max(0,...y.map(e=>e.requests)):Math.max(0,...j),te=ft(M),N=y.some(e=>e.requests>0),P=y.map(e=>`${e.at}:${e.requests}:${e.error}`).join(`|`);(0,V.useLayoutEffect)(()=>{let e=v.current;if(!e||!N||_.current)return;let t=!1,n=null,r=T.context(()=>{let r=T.matchMedia(),i=()=>{let t=T.utils.toArray(`.recharts-area-area`,e),n=T.utils.toArray(`.recharts-line-curve`,e);return!t.length&&!n.length?!1:(r.add(`(prefers-reduced-motion: reduce)`,()=>{T.set(n,{clearProps:`strokeDashoffset,strokeDasharray`}),T.set(t,{clearProps:`autoAlpha`})}),r.add(`(prefers-reduced-motion: no-preference)`,()=>{T.fromTo(t,{autoAlpha:0},{autoAlpha:1,duration:.45,ease:`power2.out`,stagger:.05}),n.forEach((e,t)=>{let n=e.getTotalLength();T.fromTo(e,{strokeDasharray:n,strokeDashoffset:n},{strokeDashoffset:0,duration:.7,delay:t*.05,ease:`power2.out`})})}),!0)};if(i()){t=!0,_.current=!0;return}n=new MutationObserver(()=>{t||i()&&(t=!0,_.current=!0,n?.disconnect())}),n.observe(e,{childList:!0,subtree:!0})},e);return()=>{n?.disconnect(),r.revert()}},[N,P]);let F=y.length>1?Date.parse(y[1].at)-Date.parse(y[0].at):36e5,I=()=>{if(p&&h&&s){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)+F;s(new Date(n).toISOString(),new Date(r).toISOString())}}m(null),g(null)},L=e=>{let t=e?.activeLabel;return t==null?null:String(t)};return!n.length||!N?(0,$.jsx)(ne,{emptyLabel:i}):(0,$.jsxs)(`div`,{ref:v,className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:`mb-3 flex justify-end`,children:(0,$.jsx)(ie,{value:d,onChange:e=>f(e),ariaLabel:D.requests,options:[{id:`requests`,label:D.requests},{id:`tokens`,label:D.tokens},{id:`latency`,label:D.latency}]})}),(0,$.jsx)(`div`,{className:`h-56 w-full`,children:(0,$.jsx)(C,{width:`100%`,height:`100%`,children:(0,$.jsxs)(lt,{data:y,margin:{top:8,right:8,bottom:0,left:0},style:s?{cursor:`crosshair`,userSelect:`none`}:void 0,onMouseDown:s?e=>{let t=L(e);t&&(m(t),g(t))}:void 0,onMouseMove:s?e=>{if(!p)return;let t=L(e);t&&g(t)}:void 0,onMouseUp:s?I:void 0,onMouseLeave:s?()=>{m(null),g(null)}:void 0,children:[(0,$.jsx)(`defs`,{children:O.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)(t,{vertical:!1,stroke:`var(--separator)`,strokeDasharray:`3 6`}),(0,$.jsx)(re,{dataKey:`at`,tickLine:!1,axisLine:!1,minTickGap:28,tick:{fill:`var(--muted)`,fontSize:ut.caption,fontFamily:`var(--font-mono)`},tickFormatter:e=>dt(e,E,r)}),(0,$.jsx)(ce,{width:d===`latency`?44:36,domain:[0,te],tickLine:!1,axisLine:!1,allowDecimals:!1,tick:{fill:`var(--muted)`,fontSize:ut.caption,fontFamily:`var(--font-mono)`},tickFormatter:e=>d===`latency`?B(e):b(e)}),(0,$.jsx)(e,{cursor:{stroke:`var(--border)`,strokeDasharray:`3 3`},content:(0,$.jsx)(mt,{daily:E,lang:r,specs:O,format:k,totalLabel:D.total,total:A})}),O.filter(e=>e.area).map(e=>(0,$.jsx)(S,{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)}`)),O.map(e=>(0,$.jsx)(st,{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)(ee,{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:O.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:[s&&c?(0,$.jsx)(`span`,{children:c}):null,(0,$.jsxs)(`span`,{className:`mono`,children:[k(M),` peak`]})]})]})]})}export{ht as TrafficChart}; \ No newline at end of file diff --git a/internal/webui/static/assets/index-CZG9DLai.js b/internal/webui/static/assets/index-DHWWlsS6.js similarity index 98% rename from internal/webui/static/assets/index-CZG9DLai.js rename to internal/webui/static/assets/index-DHWWlsS6.js index 80adbdcd..1e0d0d8d 100644 --- a/internal/webui/static/assets/index-CZG9DLai.js +++ b/internal/webui/static/assets/index-DHWWlsS6.js @@ -1,4 +1,4 @@ -const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TrafficChart-DME0-Hqp.js","assets/CartesianGrid-BLRH4M4a.js","assets/CostChart-HjooRbfZ.js"])))=>i.map(i=>d[i]); +const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TrafficChart-CsxXsi2g.js","assets/CartesianGrid-BMNtov-j.js","assets/CostChart-PEvxXQD1.js"])))=>i.map(i=>d[i]); var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},c=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;li[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},l=(n,r,o)=>(o=n==null?{}:e(i(n)),c(r||!n||!n.__esModule||!a.call(n,`default`)?t(o,`default`,{value:n,enumerable:!0}):o,n));(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 u=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.iterator;function m(e){return typeof e!=`object`||!e?null:(e=p&&e[p]||e[`@@iterator`],typeof e==`function`?e:null)}var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},g=Object.assign,_={};function v(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}v.prototype.isReactComponent={},v.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},v.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function y(){}y.prototype=v.prototype;function b(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}var x=b.prototype=new y;x.constructor=b,g(x,v.prototype),x.isPureReactComponent=!0;var S=Array.isArray;function C(){}var w={H:null,A:null,T:null,S:null},T=Object.prototype.hasOwnProperty;function E(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function D(e,t){return E(e.type,t,e.props)}function O(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function k(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var A=/\/+/g;function j(e,t){return typeof e==`object`&&e&&e.key!=null?k(``+e.key):t.toString(36)}function M(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(C,C):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function N(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,N(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+j(e,0):a,S(o)?(i=``,c!=null&&(i=c.replace(A,`$&/`)+`/`),N(o,r,i,``,function(e){return e})):o!=null&&(O(o)&&(o=D(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(A,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(S(e))for(var u=0;u{t.exports=u()})),f=o((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,O());else{var t=n(l);t!==null&&j(x,t.startTime-e)}}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-Tt&&E());){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&&j(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(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,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),p=o(((e,t)=>{t.exports=f()})),m=o((e=>{var t=d();function n(e){var t=`https://react.dev/errors/`+e;if(1{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=m()})),g=o((e=>{var t=p(),n=d(),r=h();function i(e){var t=`https://react.dev/errors/`+e;if(1B||(e.current=z[B],z[B]=null,B--)}function ee(e,t){B++,z[B]=e.current,e.current=t}var te=V(null),ne=V(null),re=V(null),ie=V(null);function ae(e,t){switch(ee(re,t),ee(ne,e),ee(te,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Yd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Yd(t),e=Xd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}H(te),ee(te,e)}function oe(){H(te),H(ne),H(re)}function se(e){e.memoizedState!==null&&ee(ie,e);var t=te.current,n=Xd(t,e.type);t!==n&&(ee(ne,e),ee(te,n))}function ce(e){ne.current===e&&(H(te),H(ne)),ie.current===e&&(H(ie),op._currentValue=R)}var le,ue;function de(e){if(le===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);le=t&&t[1]||``,ue=-1)`:-1 to {let e=a.current,t=o.current;if(!e||!t)return;let n=n=>{let r=e.querySelector(`[data-selected="true"]`);if(!r){Z.set(t,{autoAlpha:0});return}let i=e.getBoundingClientRect(),a=r.getBoundingClientRect();Z.to(t,{x:a.left-i.left,y:a.top-i.top,width:a.width,height:a.height,autoAlpha:1,duration:n?MV(kV.base):0,ease:AV.out,overwrite:!0})};n(s.current),s.current=!0;let r=new ResizeObserver(()=>n(!1));return r.observe(e),()=>{r.disconnect(),Z.killTweensOf(t)}},[e,n]),(0,G.jsxs)(`div`,{ref:a,className:`filter-toggle relative inline-flex ${i??``}`,children:[(0,G.jsx)(`span`,{ref:o,"aria-hidden":!0,className:`filter-toggle__pill pointer-events-none absolute left-0 top-0 opacity-0`}),(0,G.jsx)(iM,{"aria-label":r,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,G.jsxs)(qA,{id:e.id,className:`relative z-[1]`,style:hce,children:[e.icon,e.label]},e.id))})]})}function mH(e,t=!1){if(!e)return;let n=e.toDate(Qw());if(Number.isFinite(n.getTime()))return t&&n.setSeconds(59,999),n.toISOString()}function hH(e){if(!e)return null;let t=Date.parse(e);if(!Number.isFinite(t))return null;try{return vT(Gne(new Date(t).toISOString()))}catch{return null}}function gH({value:e,onChange:t,ariaLabel:n,fromLabel:r,toLabel:i,className:a}){return(0,G.jsx)(SA,{className:a,granularity:`minute`,hourCycle:24,shouldForceLeadingZeros:!0,value:e,onChange:e=>t(e),"aria-label":n,children:({state:e})=>(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(lk.Group,{className:`w-full min-w-0`,variant:`secondary`,children:[(0,G.jsx)(lk.Input,{className:`min-w-0`,slot:`start`,"aria-label":r,children:e=>(0,G.jsx)(lk.Segment,{segment:e})}),(0,G.jsx)(SA.RangeSeparator,{}),(0,G.jsx)(lk.Input,{className:`min-w-0`,slot:`end`,"aria-label":i,children:e=>(0,G.jsx)(lk.Segment,{segment:e})}),(0,G.jsx)(lk.Suffix,{children:(0,G.jsx)(SA.Trigger,{children:(0,G.jsx)(SA.TriggerIndicator,{})})})]}),(0,G.jsxs)(SA.Popover,{className:`flex w-[20.5rem] max-w-[calc(100vw-2rem)] flex-col gap-3 p-3`,children:[(0,G.jsxs)(CI,{"aria-label":n,children:[(0,G.jsxs)(CI.Header,{children:[(0,G.jsxs)(CI.YearPickerTrigger,{children:[(0,G.jsx)(CI.YearPickerTriggerHeading,{}),(0,G.jsx)(CI.YearPickerTriggerIndicator,{})]}),(0,G.jsx)(CI.NavButton,{slot:`previous`}),(0,G.jsx)(CI.NavButton,{slot:`next`})]}),(0,G.jsxs)(CI.Grid,{children:[(0,G.jsx)(CI.GridHeader,{children:e=>(0,G.jsx)(CI.HeaderCell,{children:e})}),(0,G.jsx)(CI.GridBody,{children:e=>(0,G.jsx)(CI.Cell,{date:e})})]}),(0,G.jsx)(CI.YearPickerGrid,{children:(0,G.jsx)(CI.YearPickerGridBody,{children:({year:e})=>(0,G.jsx)(CI.YearPickerCell,{year:e})})})]}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,G.jsx)(IN,{className:`text-xs`,children:r}),(0,G.jsx)(LA,{"aria-label":r,granularity:`minute`,hourCycle:24,value:e.timeRange?.start??null,onChange:t=>e.setTimeRange({start:t,end:e.timeRange?.end}),children:(0,G.jsx)(LA.Group,{className:`w-[7.5rem]`,variant:`secondary`,children:(0,G.jsx)(LA.Input,{children:e=>(0,G.jsx)(LA.Segment,{segment:e})})})})]}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,G.jsx)(IN,{className:`text-xs`,children:i}),(0,G.jsx)(LA,{"aria-label":i,granularity:`minute`,hourCycle:24,value:e.timeRange?.end??null,onChange:t=>e.setTimeRange({start:e.timeRange?.start,end:t}),children:(0,G.jsx)(LA.Group,{className:`w-[7.5rem]`,variant:`secondary`,children:(0,G.jsx)(LA.Input,{children:e=>(0,G.jsx)(LA.Segment,{segment:e})})})})]})]})]})]})})}var _H={today:`statsWindowToday`,1:`statsWindow1h`,24:`statsWindow24h`,168:`statsWindow7d`,720:`statsWindow30d`,custom:`statsWindowCustom`};function vH(e,t){if(e===`today`){let e=new Date;return e.setHours(0,0,0,0),{from:e.toISOString()}}if(e===`custom`){let e=mH(t?.start),n=mH(t?.end,!0);return e&&n?{from:e,to:n}:null}if(e===`720`){let e=new Date;return{from:new Date(e.getTime()-2592e6).toISOString(),to:e.toISOString()}}return{hours:Number(e)}}function yH({value:e,onChange:t,custom:n,onCustomChange:r,onBusy:i,t:a}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(pH,{value:e,onChange:r=>{let a=r;e!==a&&((a!==`custom`||n)&&i?.(),t(a))},ariaLabel:a(`statsTraffic`),options:Object.keys(_H).map(e=>({id:e,label:a(_H[e])}))}),e===`custom`?(0,G.jsx)(gH,{className:`w-[min(100%,24rem)]`,value:n,onChange:e=>{e&&i?.(),r(e)},ariaLabel:a(`statsWindowCustom`),fromLabel:a(`logsTimeFrom`),toLabel:a(`logsTimeTo`)}):null]})}function bH(e,t,n){let r=new URLSearchParams;for(let[t,n]of Object.entries(e))n&&r.set(t,n);let i=Date.parse(t),a=Date.parse(n);return Number.isFinite(i)&&Number.isFinite(a)&&(r.set(`from`,new Date(Math.floor(i/6e4)*6e4).toISOString()),r.set(`to`,new Date(Math.ceil(a/6e4)*6e4-6e4).toISOString())),`/logs?${r}`}function xH(e){let t=String(e||``).toLowerCase();return!t||t===`qoder`||t===`qoder-global`||t===`qoder-cn`}function SH(e){return String(e||``).toLowerCase()===`workbuddy`}function CH(e){return String(e||``).toLowerCase()===`trae`}function wH(e){return String(e||``).toLowerCase()===`devin`}function TH(e){return String(e||``).toLowerCase()===`command`}function EH(e){return String(e||``).toLowerCase()===`zhipu`}function DH(e){return String(e||``).toLowerCase()===`qwenwork`}function OH(e){return String(e||``).toLowerCase()===`kimi`}function kH(e){let t=String(e||``).toLowerCase();return t===`meta`||t===`muse`}function AH(e,t){let n=String(e||``).toLowerCase();return SH(n)?`WorkBuddy`:CH(n)?`Trae`:wH(n)?`Devin`:TH(n)?`Command Code`:EH(n)?`Zhipu GLM`:DH(n)?`QwenWork`:OH(n)?`Kimi Code`:kH(n)?`Muse (Meta)`:xH(n)?`Qoder`:e||t(`account`)}function jH(e,t,n){let r=String(e||``).toLowerCase(),i=String(t||``).toLowerCase();return SH(r)?n(i===`global`?`accountTypeWorkBuddyGlobal`:`accountTypeWorkBuddyCN`):CH(r)?n(`accountTypeTraeCN`):wH(r)?n(`accountTypeDevinGlobal`):TH(r)?n(`accountTypeCommandGlobal`):EH(r)?n(`accountTypeZhipuCN`):DH(r)?n(i===`cn`?`accountTypeQwenworkCN`:`accountTypeQwenworkGlobal`):OH(r)?n(`accountTypeKimiCN`):kH(r)?n(`accountTypeMetaGlobal`):xH(r)?n(i===`cn`?`accountTypeQoderCN`:`accountTypeQoderGlobal`):e||n(`account`)}function gce(e,t){let n=t??!!e.max_mode,r=e.catalog_context_length||e.default_context_length||e.context_length||0,i=e.catalog_context_length_max||0;return n&&i>0?{context_length:i,prompt_max_tokens:e.prompt_max_tokens_max||e.prompt_max_tokens,max_output_tokens:e.max_output_tokens_max||e.max_output_tokens}:{context_length:r,prompt_max_tokens:e.prompt_max_tokens,max_output_tokens:e.max_output_tokens}}function _ce({size:e=16,className:t=``}){return(0,G.jsx)(`span`,{className:`inline-flex shrink-0 items-center justify-center rounded-[22%] bg-[#0a84ff] text-white ${t}`.trim(),style:{width:e,height:e,fontSize:Math.max(9,Math.round(e*.55)),fontWeight:650,lineHeight:1},"aria-hidden":`true`,children:`C`})}function vce({size:e=16,className:t=``}){return(0,G.jsx)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,className:`block shrink-0 text-foreground ${t}`.trim(),"aria-hidden":`true`,children:(0,G.jsx)(`path`,{fill:`currentColor`,fillRule:`evenodd`,clipRule:`evenodd`,d:`M8.086.457a6.1 6.1 0 0 1 3.046-.415q2 .23 3.564 1.7a.12.12 0 0 0 .107.029q2.112-.519 4.061.366l.063.03l.154.076q2.036 1.055 2.918 3.198a5.6 5.6 0 0 1 .421 2.126 5.7 5.7 0 0 1-.18 1.631.17.17 0 0 0 .04.155 6 6 0 0 1 1.578 2.891q.577 2.852-1.183 5.14l-.182.22a6.06 6.06 0 0 1-2.934 1.851.16.16 0 0 0-.108.102c-.255.736-.511 1.364-.987 1.992-1.199 1.582-2.962 2.462-4.948 2.451q-2.374-.012-4.21-1.736a.14.14 0 0 0-.14-.032 5.9 5.9 0 0 1-1.604-.185 5.9 5.9 0 0 1-2.595-.622 6.06 6.06 0 0 1-2.146-1.781c-.203-.269-.404-.522-.551-.821a8 8 0 0 1-.495-1.283 6.1 6.1 0 0 1-.017-3.064.2.2 0 0 0 .008-.074.1.1 0 0 0-.037-.064 6 6 0 0 1-1.38-2.202 5.2 5.2 0 0 1-.333-1.589 6.9 6.9 0 0 1 .188-2.132q.675-2.226 2.577-3.493.424-.282.802-.438.429-.179.861-.304a.13.13 0 0 0 .087-.087A6 6 0 0 1 5.635 2.31Q6.655 1.04 8.086.457m-.804 7.85a.848.848 0 0 0-1.473.842l1.694 2.965-1.688 2.848a.849.849 0 0 0 1.46.864l1.94-3.272a.85.85 0 0 0 .007-.854zm5.446 6.24a.849.849 0 0 0 0 1.695h4.848a.849.849 0 0 0 0-1.696z`})})}function yce({size:e=16,className:t=``}){return(0,G.jsx)(`span`,{className:`inline-flex shrink-0 items-center justify-center rounded-[22%] bg-[#1a1a1a] text-white ${t}`.trim(),style:{width:e,height:e,fontSize:Math.max(9,Math.round(e*.55)),fontWeight:650,lineHeight:1},"aria-hidden":`true`,children:`D`})}function bce({size:e=16,className:t=``}){return(0,G.jsx)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,className:`block shrink-0 text-foreground ${t}`.trim(),"aria-hidden":`true`,children:(0,G.jsx)(`path`,{fill:`currentColor`,d:`M21 12.79A9 9 0 1 1 11.21 3a7 7 0 0 0 9.79 9.79Z`})})}function xce({size:e=16,className:t=``}){return(0,G.jsx)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,className:`block shrink-0 text-foreground ${t}`.trim(),"aria-hidden":`true`,children:(0,G.jsx)(`path`,{fill:`currentColor`,fillRule:`evenodd`,d:`M8 6a4 4 0 0 0 0 8c.9 0 1.7-.3 2.4-.8L14 16.8A4 4 0 1 0 16 8a3.9 3.9 0 0 0-2.4.8L10 5.2A4 4 0 0 0 8 6Zm0 2a2 2 0 1 1 0 4 2 2 0 0 1 0-4Zm8 4a2 2 0 1 1 0 4 2 2 0 0 1 0-4Z`,clipRule:`evenodd`})})}var Sce=`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAALQAAAC0CAYAAAA9zQYyAAAJ5ElEQVR42u2dXUxUZxrH/wKDDDCM4CJBZJZNxMpGDMGYXsAWeikapF6Jqc02kUhWTWsTIQHjNk22yWCyN5INrk22rbsc71ZNpXfb0sJ+Gcxmma2mNpt1XMsaLd2ZoY7D5164btfiBx8zzDnv+f1uiWeG9/x8eN7neT9WFRaunROAIWQwBIDQAAgNgNAACA0IDYDQAAgNgNAACA0IDYDQAAgNgNAACA0IDYDQAAgNgNAACA0IDYDQAAgNgNAACA0IDYDQAAgNgNAA35LFEDyZ6uotKi8PqL6+ToFAuQoK/PL7/fL7CyRJ4fBNRaMRhcM3FQ6HFQqFNDoaUiQSYfDSxCqO031U4Lq6OjU1Nam6eov8fv+inxGJRDQ6GtLAwIAs6xxyI/TK0tTUpJ07d6iurk6BQCCpz45EIurrO62+vtOIjdCpIxAIqLPzWEokRmyEXjHq6+vU0dGh+vq6tHw+YiN00iJyb++ptImM2Aid1NSitbXVlt8vEomoq+u4LMvCRIR+Oq2trersPLYiOfJyCYfD6u4+rkuXBjASoZ0VlZ/G0NCwenp6NDQ0jJkI/aCOfPbs+46IyogtWt9Po739oAYHP3a8zNKDaszFixd08eIF20xkidArSGdnhzo7O4x9SZZlKRg8qXA4jLGmC/322z9Te/tBV7ysvr7TCgZ7KPWZKnRv7ynt29fqqhdGDdtQod0oM2IbKrSb0gzEXhyZXm/um06bAL7++muY/F9ycnJUX1+nPXteUiQSVSgUIkI75cvu29eq3t5TWKyndx0PHz7i2hq2Y4QOBAIaHPxoSYvu3YhbmzOOENrv92tw8CMjmiaILTqFnZ0dyKzldx2rq7cQoe3yQkB0HZ0uNKlG6ggGe4ws9dlaaOrNSyM2e0+3pu4oOntPX07dnffzzasDKvMUazY2ZVwN27ZCV1dv0eDgx9i5AK4lbuhy/Joux6/q1vRdXUvcWNC/K8sq1nbvZpXeX6N/9X+m3/zyrOPFtq3QLJ18egT+c/yqfjcx8j+Jk8GmyfWaOPOFRt4bRGgmgqnnfPRTnY99osvxayn9nJmxuKI/v6r7g7cRmuicXG5N3dEvxn+b1Ei8UCZHxvXvt/6qmbE4QhOdkyPy+dinaf0ec7Fpxd65rm+sf4jDGpdAR0eH3L4Ww7LO6Z2KQWVvK0p/xPNlqeBolTLyPYqduS46hVpc3dnNqYZlWWpublEw2GO775bftlFrTmwlQmuRG13dGpWDwZO2P3DGu6tMM2NxW0dqhE4zo6Mh7d//imNa0fltGyXJtlJn2Gky6LalocFgjxoaGh23riK/baMt8ntbC93U1OQqmbu6um2ZKy+UNSe2KsPnQWg98Sy6vXLLHsD9+19RX99pR/8emaVe5R/YiNB6wm4UN6QbkUhEzc27jTmUMa+1QpmlXoSen27scI3Mo6NmbWL1tVUitB6zss50TJRZelDKs1OUtoXQdXVmN1MOHz5ipMwPyWksQWj9X3fQ5B0pwWCP+vvNPqE/b28FQn87ISw39kX391uOLs1pERUPz6YChJak8vKAse3s7u7jcgvZtUUIbWqEflhrdtNZczkNJQj9MIc2MW82eRL4OEg5DBV6aGjY8V1ALXHddOZ6L0L7/QUyrUTnVrJKcxHatFTDzfeg2KHBgtBJPng8aS/GhivZENpl0TmZVY1VviwGFaGVtpqzGyeCRGiZe91a0l9MvoeBRej05M6WdS65L8XnIeVA6PRF52R3BO22aB6hSTdkQtcNoeW++0tSsV4ja5OPwUVopeGko3MyeV0EQrtsMjgwkJrNrp5KhEboFWZ4ODXpRva2IiocCJ2e/DkVrK5dy+Ai9MozMPBhSp5r1yO2EFpmt7pTsaouw+exzVYmhHYRoVDI+N3TCE3+LFP25SG061KOmynJnWmoILQxKYfdzohDaLmrqaIkL0ZiMojQxghNdDZI6Egk6riSXbKjs3dXGSaaI3TE1S9gzU+3YiFCm0H2tiJyZ9OETkUJzEkX74BhQkej7ozQvrZKtlqZKLTbDjWUHizgf3iBJRiYQ7tJ6gyfR/4T1Zhnch06FBp1zYDnt21ki5XpQg8N/d4Vg+3dVcaKOjcIPTw8LDfkzf6jP8Q4NwgdDodTtuFUNjnzrfBkLXsF3bSW49KlD42VeW3f85To3Ca0ZVnGHRaOzC5fbRcMnkRmMEdoU6I0MiO0MVEamRF6XpS2LGfejZ3XWqHiX9cjM0LPj9JOSz0K3qhSwdEqSnMIrcfWpZubWxyxVjqz1Kt1FxrpACL0QqTebWupfW2VWnehkRQDobXgpaXd3cdtJ3Xurg1ad6GRJaAIvXj6+y01N++2TU6dWeqV/0Q1URmhlxepm5tbUnYEFyB02nLqrq5u1+8UB4MOmunrO62amtqkX0UMCK10btsKBnvSInZBZh7WIHRqxW5oeHHFuou+jFysQejU59eHDh1RTU3tikwcN6/+PuYg9MpNHJubd6dU7LKs72EOQmtFT9hPpdjPrQ5gDkKbI/Z2bxXmIHT6xT506EhSOo5V5NAILZusta6pqV12c8aXkavt3s3Yg9AypjnT4nsBexBaxjRniNAI7QixF0qZp1gtvh9hEELbX+yFdh1/UvQSA4fQckTXsaGh8ZmlPqI0QjuGB2uwn13DJkojtExqzpR5ipEaoZ0t9nebM4eK9rC+Q9LMWByhnSh2TU3tvK7jr8q6XC+1HYTO9Hpz30RTLekCe8s6p0QioerqLSrOLdJ2b5U+nPijJuembP3d52LTWrU6I+nPjAT/prnJWYR2KolEQsPDw3r33feUSCT0Yk29NuSV6HL8qm2ljn9wS18f/4vuf3JbWaW5ylyfnN3r37z/dyX+cCftv9+qwsK1c6iZHPx+v9rbD6rx1R16baJXsdl7tkoHIm+NKjHylb57m63vQKWytxUt69l3Xx7WbGwKoU0V++U3XtVnLfd1LXEj7SJPnPlC9z745zPPG8ndtUF5eysWdT7fzFhcXx+7oqnPo7YYe4ROIYUb1ir/QKWmmwpX/LMnR8YVv3TrmSI/7h7FvL0VCxJ7Ziyur9r/ZIvJIEKvID94/jlFf7xmWX/WFxotJ0fGFTtzfdmSZfg88u4sU05DiTybCh6Re6n/WRDaMLK3FSmnoUS5Ozck7djdyZFx3R+8rckr4yn9s/9w8jjzZdzWY4zQSs/1yFmbfMppKFHOCyULrjTMxaY19XlUU9ejmhwZ1+SVcVtMxBAa5gmeWepVZqlXGT7PIz+bjU1pbmJa02P3bB8dERqA1jcAQgNCAyA0AEIDIDQAQgNCAyA0AEIDIDQAQgNCAyA0AEIDIDQAQgNCAyA0AEIDIDQgNABCAyA0AEIDIDQgNABCAyA0AEIDLIj/ABWOKFxbGBRBAAAAAElFTkSuQmCC`;function Cce({size:e=16,className:t=``}){return(0,G.jsx)(`img`,{src:Sce,alt:``,width:e,height:e,className:`block shrink-0 rounded-[22%] ${t}`.trim(),draggable:!1})}function wce({size:e=16,className:t=``}){let n=Math.max(2,Math.round(e*.14));return(0,G.jsxs)(`span`,{className:`inline-flex shrink-0 items-baseline justify-center rounded-[22%] bg-[#18181B] text-white ${t}`.trim(),style:{width:e,height:e,fontSize:Math.max(9,Math.round(e*.5)),fontWeight:650,lineHeight:1},"aria-hidden":`true`,children:[(0,G.jsx)(`span`,{style:{alignSelf:`center`},children:`Q`}),(0,G.jsx)(`span`,{style:{alignSelf:`center`,width:n,height:n,marginLeft:Math.max(0,Math.round(e*.03)),borderRadius:`50%`,background:`#22D3EE`}})]})}function Tce({size:e=16,className:t=``}){return(0,G.jsx)(`span`,{className:`inline-flex shrink-0 items-center justify-center rounded-[22%] bg-[#1a1a1a] text-white ${t}`.trim(),style:{width:e,height:e,fontSize:Math.max(9,Math.round(e*.55)),fontWeight:650,lineHeight:1},"aria-hidden":`true`,children:`T`})}var Ece=`/assets/workbuddy-mark-D1Gu2IKl.svg`;function Dce({size:e=16,className:t=``}){return(0,G.jsx)(`img`,{src:Ece,alt:``,width:e,height:e,className:`block shrink-0 ${t}`.trim(),draggable:!1})}function Oce({size:e=16,className:t=``}){return(0,G.jsx)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,className:`block shrink-0 text-foreground ${t}`.trim(),"aria-hidden":`true`,children:(0,G.jsx)(`path`,{fill:`currentColor`,fillRule:`evenodd`,d:`M11.991 23.503a.24.24 0 0 0-.244.248a.24.24 0 0 0 .244.249a.24.24 0 0 0 .245-.249a.24.24 0 0 0-.22-.247zM9.671 5.365a1.697 1.697 0 0 1 1.099 2.132l-.071.172l-.016.04l-.018.054c-.07.16-.104.32-.104.498c-.035.71.47 1.279 1.186 1.314h.366c1.309.053 2.338 1.173 2.286 2.523c-.052 1.332-1.152 2.38-2.478 2.327h-.174c-.715.018-1.274.64-1.239 1.368c0 .124.018.23.053.337c.209.373.54.658.96.8c.75.23 1.517-.125 1.9-.782l.018-.035c.402-.64 1.17-.96 1.92-.711c.854.284 1.378 1.226 1.099 2.167a1.66 1.66 0 0 1-2.077 1.102a1.7 1.7 0 0 1-.907-.711l-.017-.035c-.2-.323-.463-.58-.851-.711l-.056-.018a1.646 1.646 0 0 0-1.954.746a1.66 1.66 0 0 1-1.065.764a1.677 1.677 0 0 1-1.989-1.279c-.209-.906.332-1.83 1.257-2.043a1.5 1.5 0 0 1 .296-.035h.018c.68-.071 1.151-.622 1.116-1.333a1.3 1.3 0 0 0-.227-.693a2.5 2.5 0 0 1-.366-1.403a2.4 2.4 0 0 1 .366-1.208c.14-.195.21-.444.227-.693c.018-.71-.506-1.261-1.186-1.332l-.07-.018a1.4 1.4 0 0 1-.299-.07l-.05-.019a1.7 1.7 0 0 1-1.047-2.114a1.68 1.68 0 0 1 2.094-1.101m-5.575 10.11c.26-.264.639-.367.994-.27s.633.379.728.74c.095.362-.007.748-.267 1.013c-.402.41-1.053.41-1.455 0a1.06 1.06 0 0 1 0-1.482zm14.845-.294c.359-.09.738.024.992.297c.254.274.344.665.237 1.025s-.396.634-.756.718c-.551.128-1.1-.22-1.23-.781a1.05 1.05 0 0 1 .757-1.26zm-.064-4.39c.314.32.49.753.49 1.206s-.176.886-.49 1.206c-.315.32-.74.5-1.185.5c-.444 0-.87-.18-1.184-.5a1.727 1.727 0 0 1 0-2.412a1.654 1.654 0 0 1 2.369 0m-11.243.163c.364.484.447 1.128.218 1.691a1.665 1.665 0 0 1-2.188.923c-.855-.36-1.26-1.358-.907-2.228a1.68 1.68 0 0 1 1.33-1.038a1.66 1.66 0 0 1 1.547.652m11.545-4.221c.368 0 .708.2.892.524s.184.724 0 1.048a1.03 1.03 0 0 1-.892.524a1.04 1.04 0 0 1-1.03-1.048a1.04 1.04 0 0 1 1.03-1.048m-14.358 0c.368 0 .707.2.891.524s.184.724 0 1.048a1.03 1.03 0 0 1-.891.524a1.04 1.04 0 0 1-1.03-1.048c0-.579.461-1.048 1.03-1.048m10.031-1.475c.925 0 1.675.764 1.675 1.706s-.75 1.705-1.675 1.705s-1.674-.763-1.674-1.705s.75-1.706 1.674-1.706m-2.626-.684c.362-.082.653-.356.761-.718a1.06 1.06 0 0 0-.238-1.028a1.02 1.02 0 0 0-.996-.294c-.547.14-.881.7-.752 1.257c.13.558.675.907 1.225.783m0 16.876c.359-.087.644-.36.75-.72a1.06 1.06 0 0 0-.237-1.019a1.02 1.02 0 0 0-.985-.301a1.04 1.04 0 0 0-.762.717c-.108.361-.017.754.239 1.028c.245.263.606.377.953.305zM17.19 3.5a.63.63 0 0 0 .628-.64a.63.63 0 0 0-.628-.64a.63.63 0 0 0-.628.64c0 .355.28.64.628.64m-10.38 0a.63.63 0 0 0 .628-.64c0-.355-.28-.64-.628-.64a.63.63 0 0 0-.628.64c0 .355.279.64.628.64m-5.182 7.852a.63.63 0 0 0-.628.64c0 .354.28.639.628.639a.63.63 0 0 0 .627-.606l.001-.034a.62.62 0 0 0-.628-.64zm5.182 9.13a.63.63 0 0 0-.628.64c0 .355.279.64.628.64a.63.63 0 0 0 .628-.64c0-.355-.28-.64-.628-.64m10.38.018a.63.63 0 0 0-.628.64c0 .355.28.64.628.64a.63.63 0 0 0 .628-.64a.63.63 0 0 0-.628-.64m5.182-9.148a.63.63 0 0 0-.628.64c0 .354.279.639.628.639a.63.63 0 0 0 .628-.64c0-.355-.28-.64-.628-.64zm-.384-4.992a.24.24 0 0 0 .244-.249a.24.24 0 0 0-.244-.249a.24.24 0 0 0-.244.249c0 .142.122.249.244.249M11.991.497a.24.24 0 0 0 .245-.248A.24.24 0 0 0 11.99 0a.24.24 0 0 0-.244.249c0 .133.108.236.223.247zM2.011 6.36a.24.24 0 0 0 .245-.249a.24.24 0 0 0-.244-.249a.24.24 0 0 0-.244.249a.24.24 0 0 0 .244.249zm0 11.263a.24.24 0 0 0-.243.248a.24.24 0 0 0 .244.249a.24.24 0 0 0 .244-.249a.25.25 0 0 0-.244-.248zm19.995-.018a.24.24 0 0 0-.245.248a.24.24 0 0 0 .245.25a.24.24 0 0 0 .244-.25a.25.25 0 0 0-.244-.248z`})})}function MH({provider:e,size:t=16,className:n=``}){let r=String(e||``).toLowerCase();return r===`workbuddy`?(0,G.jsx)(Dce,{size:t,className:n}):r===`trae`?(0,G.jsx)(Tce,{size:t,className:n}):r===`devin`?(0,G.jsx)(yce,{size:t,className:n}):r===`command`?(0,G.jsx)(_ce,{size:t,className:n}):r===`codex`?(0,G.jsx)(vce,{size:t,className:n}):r===`zhipu`?(0,G.jsx)(Oce,{size:t,className:n}):r===`qwenwork`?(0,G.jsx)(wce,{size:t,className:n}):r===`kimi`?(0,G.jsx)(bce,{size:t,className:n}):r===`meta`||r===`muse`?(0,G.jsx)(xce,{size:t,className:n}):(0,G.jsx)(Cce,{size:t,className:n})}var kce=(0,v.lazy)(()=>C(()=>import(`./LiveSparkline-C40ZJRGg.js`).then(e=>({default:e.LiveSparkline})),[]));function Ace({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,G.jsxs)(G.Fragment,{children:[n(`liveConcurrency`),(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,G.jsxs)(`span`,{className:`mono tabular text-body font-semibold ${s?`text-warning`:`text-foreground`}`,children:[i??`—`,(0,G.jsxs)(`span`,{className:`font-normal text-muted`,children:[`/`,e?a:`—`]})]}),(0,G.jsx)(`span`,{className:`inline-block h-[3px] w-12 overflow-hidden rounded-[2px] bg-separator`,children:(0,G.jsx)(`span`,{className:`block h-full ${s?`bg-warning`:`bg-foreground/60`}`,style:{width:`${Math.min(100,o*100)}%`}})})]})]});return(0,G.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,G.jsx)(`span`,{className:`inline-flex items-center`,children:(0,G.jsx)(`span`,{className:`status-dot`,"data-state":i==null?``:s?`warn`:i>0?`ok`:``})}),r?(0,G.jsx)(`button`,{type:`button`,"data-testid":`live-strip-concurrency`,onClick:r,className:`inline-flex flex-col gap-1 rounded-md 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,G.jsx)(`span`,{className:`inline-flex flex-col gap-1 sm:flex-row sm:items-center sm:gap-2`,children:c}),(0,G.jsxs)(`span`,{className:`inline-flex flex-col gap-1 sm:flex-row sm:items-center sm:gap-2`,children:[n(`liveRpm`),(0,G.jsx)(`span`,{className:`mono tabular text-body font-semibold text-foreground`,children:e?.rpm??`—`})]}),(0,G.jsxs)(`span`,{className:`inline-flex flex-col gap-1 sm:flex-row sm:items-center sm:gap-2`,children:[n(`liveTrace`),(0,G.jsx)(v.Suspense,{fallback:(0,G.jsx)(`span`,{className:`inline-block h-6 w-[120px]`}),children:(0,G.jsx)(kce,{samples:t,capacity:a,label:n(`liveTrace`)})})]})]})}var jce=/[achlmqstvz]|(-?\d*\.?\d*(?:e[\-+]?\d+)?)[0-9]/gi,Mce=/[\+\-]?\d*\.?\d+e[\+\-]?\d+/gi,Nce=Math.PI/180;180/Math.PI;var NH=Math.sin,PH=Math.cos,FH=Math.abs,IH=Math.sqrt,Pce=function(e){return typeof e==`number`},LH=1e5,RH=function(e){return Math.round(e*LH)/LH||0},zH=function(e){return e.closed=Math.abs(e[0]-e[e.length-2])<.001&&Math.abs(e[1]-e[e.length-1])<.001};function Fce(e,t,n,r,i,a,o){for(var s=e.length,c,l,u,d,f;--s>-1;)for(c=e[s],l=c.length,u=0;u1&&(n=IH(b)*n,r=IH(b)*r);var x=n*n,S=r*r,C=(x*S-x*y-S*v)/(x*y+S*v);C<0&&(C=0);var w=(a===o?-1:1)*IH(C),T=w*(n*_/r),E=w*-(r*g/n),D=(e+s)/2,O=(t+c)/2,k=D+(u*T-d*E),A=O+(d*T+u*E),j=(g-T)/n,M=(_-E)/r,N=(-g-T)/n,P=(-_-E)/r,F=j*j+M*M,I=(M<0?-1:1)*Math.acos(j/IH(F)),L=(j*P-M*N<0?-1:1)*Math.acos((j*N+M*P)/IH(F*(N*N+P*P)));isNaN(L)&&(L=f),!o&&L>0?L-=p:o&&L<0&&(L+=p),I%=p,L%=p;var R=Math.ceil(FH(L)/(p/4)),z=[],B=L/R,V=4/3*NH(B/2)/(1+PH(B/2)),H=u*n,ee=d*n,te=d*-r,ne=u*r,re;for(re=0;re-1e-4?0:t}).match(jce)||[],n=[],r=0,i=0,a=2/3,o=t.length,s=0,c=`ERROR: malformed path: `+e,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w=function(e,t,n,r){v=(n-e)/3,y=(r-t)/3,h.push(e+v,t+y,n-v,r-y,n,r)};if(!e||!isNaN(t[0])||isNaN(t[1]))return console.log(c),n;for(l=0;l.5||FH(i-f)>.5)&&(w(r,i,d,f),p===`L`&&(l+=2)),r=d,i=f;else if(p===`A`){if(S=t[l+4],C=t[l+5],v=t[l+6],y=t[l+7],u=7,S.length>1&&(S.length<3?(y=v,v=C,u--):(y=C,v=S.substr(2),u-=2),C=S.charAt(1),S=S.charAt(0)),b=Ice(r,i,+t[l+1],+t[l+2],+t[l+3],+S,+C,(m?r:0)+v*1,(m?i:0)+y*1),l+=u,b)for(u=0;ul*(w*w+T*T)&&(O=u.length,e(t,n,f,p,v,y,S,C,l,u,d),e(S,C,b,x,g,_,s,c,l,u,d+1+(u.length-O))),u},GH=function(){function e(e,t,n){VH||UH(),this.id=e,Bce&&this.setData(t,n)}var t=e.prototype;return t.setData=function(e,t){t||={},e||=`0,0,1,1`;var n=e.match(Vce),r=1,i=[],a=[],o=t.precision||1,s=o<=1,c,l,u,d,f,p,m,h,g;if(this.data=e,(Hce.test(e)||~e.indexOf(`M`)&&e.indexOf(`C`)<0)&&(n=Lce(e)[0]),c=n.length,c===4)n.unshift(0,0),n.push(1,1),c=8;else if((c-2)%6)throw`Invalid CustomEase`;for((+n[0]!=0||+n[c-2]!=1)&&Wce(n,t.height,t.originY),this.segment=n,d=2;dh.x||h.y!==m.y&&h.x===m.x||m===h)&&m.x<=1?(h.cx=m.x-h.x,h.cy=m.y-h.y,h.n=m,h.nx=m.x,s&&d>1&&Math.abs(h.cy/h.cx-i[d-2].cy/i[d-2].cx)>2&&(s=0),h.cxh||u===m-1)&&(c.push(g,_),l=(p-_)/(f-g)),g=f,_=p;c=`M`+c.join(`,`)}return s&&s.setAttribute(`d`,c),c},e}();GH.version=`3.15.0`,GH.headless=!0,HH()&&BH.registerPlugin(GH);var Kce=`dangerouslySetInnerHTML.onCopy.onCopyCapture.onCut.onCutCapture.onPaste.onPasteCapture.onCompositionEnd.onCompositionEndCapture.onCompositionStart.onCompositionStartCapture.onCompositionUpdate.onCompositionUpdateCapture.onFocus.onFocusCapture.onBlur.onBlurCapture.onChange.onChangeCapture.onBeforeInput.onBeforeInputCapture.onInput.onInputCapture.onReset.onResetCapture.onSubmit.onSubmitCapture.onInvalid.onInvalidCapture.onLoad.onLoadCapture.onError.onErrorCapture.onKeyDown.onKeyDownCapture.onKeyPress.onKeyPressCapture.onKeyUp.onKeyUpCapture.onAbort.onAbortCapture.onCanPlay.onCanPlayCapture.onCanPlayThrough.onCanPlayThroughCapture.onDurationChange.onDurationChangeCapture.onEmptied.onEmptiedCapture.onEncrypted.onEncryptedCapture.onEnded.onEndedCapture.onLoadedData.onLoadedDataCapture.onLoadedMetadata.onLoadedMetadataCapture.onLoadStart.onLoadStartCapture.onPause.onPauseCapture.onPlay.onPlayCapture.onPlaying.onPlayingCapture.onProgress.onProgressCapture.onRateChange.onRateChangeCapture.onSeeked.onSeekedCapture.onSeeking.onSeekingCapture.onStalled.onStalledCapture.onSuspend.onSuspendCapture.onTimeUpdate.onTimeUpdateCapture.onVolumeChange.onVolumeChangeCapture.onWaiting.onWaitingCapture.onAuxClick.onAuxClickCapture.onClick.onClickCapture.onContextMenu.onContextMenuCapture.onDoubleClick.onDoubleClickCapture.onDrag.onDragCapture.onDragEnd.onDragEndCapture.onDragEnter.onDragEnterCapture.onDragExit.onDragExitCapture.onDragLeave.onDragLeaveCapture.onDragOver.onDragOverCapture.onDragStart.onDragStartCapture.onDrop.onDropCapture.onMouseDown.onMouseDownCapture.onMouseEnter.onMouseLeave.onMouseMove.onMouseMoveCapture.onMouseOut.onMouseOutCapture.onMouseOver.onMouseOverCapture.onMouseUp.onMouseUpCapture.onSelect.onSelectCapture.onTouchCancel.onTouchCancelCapture.onTouchEnd.onTouchEndCapture.onTouchMove.onTouchMoveCapture.onTouchStart.onTouchStartCapture.onPointerDown.onPointerDownCapture.onPointerMove.onPointerMoveCapture.onPointerUp.onPointerUpCapture.onPointerCancel.onPointerCancelCapture.onPointerEnter.onPointerEnterCapture.onPointerLeave.onPointerLeaveCapture.onPointerOver.onPointerOverCapture.onPointerOut.onPointerOutCapture.onGotPointerCapture.onGotPointerCaptureCapture.onLostPointerCapture.onLostPointerCaptureCapture.onScroll.onScrollCapture.onWheel.onWheelCapture.onAnimationStart.onAnimationStartCapture.onAnimationEnd.onAnimationEndCapture.onAnimationIteration.onAnimationIterationCapture.onTransitionEnd.onTransitionEndCapture`.split(`.`);function KH(e){return typeof e==`string`&&Kce.includes(e)}var qce=new Set(`aria-activedescendant.aria-atomic.aria-autocomplete.aria-busy.aria-checked.aria-colcount.aria-colindex.aria-colspan.aria-controls.aria-current.aria-describedby.aria-details.aria-disabled.aria-errormessage.aria-expanded.aria-flowto.aria-haspopup.aria-hidden.aria-invalid.aria-keyshortcuts.aria-label.aria-labelledby.aria-level.aria-live.aria-modal.aria-multiline.aria-multiselectable.aria-orientation.aria-owns.aria-placeholder.aria-posinset.aria-pressed.aria-readonly.aria-relevant.aria-required.aria-roledescription.aria-rowcount.aria-rowindex.aria-rowspan.aria-selected.aria-setsize.aria-sort.aria-valuemax.aria-valuemin.aria-valuenow.aria-valuetext.className.color.height.id.lang.max.media.method.min.name.style.target.width.role.tabIndex.accentHeight.accumulate.additive.alignmentBaseline.allowReorder.alphabetic.amplitude.arabicForm.ascent.attributeName.attributeType.autoReverse.azimuth.baseFrequency.baselineShift.baseProfile.bbox.begin.bias.by.calcMode.capHeight.clip.clipPath.clipPathUnits.clipRule.colorInterpolation.colorInterpolationFilters.colorProfile.colorRendering.contentScriptType.contentStyleType.cursor.cx.cy.d.decelerate.descent.diffuseConstant.direction.display.divisor.dominantBaseline.dur.dx.dy.edgeMode.elevation.enableBackground.end.exponent.externalResourcesRequired.fill.fillOpacity.fillRule.filter.filterRes.filterUnits.floodColor.floodOpacity.focusable.fontFamily.fontSize.fontSizeAdjust.fontStretch.fontStyle.fontVariant.fontWeight.format.from.fx.fy.g1.g2.glyphName.glyphOrientationHorizontal.glyphOrientationVertical.glyphRef.gradientTransform.gradientUnits.hanging.horizAdvX.horizOriginX.href.ideographic.imageRendering.in2.in.intercept.k1.k2.k3.k4.k.kernelMatrix.kernelUnitLength.kerning.keyPoints.keySplines.keyTimes.lengthAdjust.letterSpacing.lightingColor.limitingConeAngle.local.markerEnd.markerHeight.markerMid.markerStart.markerUnits.markerWidth.mask.maskContentUnits.maskUnits.mathematical.mode.numOctaves.offset.opacity.operator.order.orient.orientation.origin.overflow.overlinePosition.overlineThickness.paintOrder.panose1.pathLength.patternContentUnits.patternTransform.patternUnits.pointerEvents.pointsAtX.pointsAtY.pointsAtZ.preserveAlpha.preserveAspectRatio.primitiveUnits.r.radius.refX.refY.renderingIntent.repeatCount.repeatDur.requiredExtensions.requiredFeatures.restart.result.rotate.rx.ry.seed.shapeRendering.slope.spacing.specularConstant.specularExponent.speed.spreadMethod.startOffset.stdDeviation.stemh.stemv.stitchTiles.stopColor.stopOpacity.strikethroughPosition.strikethroughThickness.string.stroke.strokeDasharray.strokeDashoffset.strokeLinecap.strokeLinejoin.strokeMiterlimit.strokeOpacity.strokeWidth.surfaceScale.systemLanguage.tableValues.targetX.targetY.textAnchor.textDecoration.textLength.textRendering.to.transform.u1.u2.underlinePosition.underlineThickness.unicode.unicodeBidi.unicodeRange.unitsPerEm.vAlphabetic.values.vectorEffect.version.vertAdvY.vertOriginX.vertOriginY.vHanging.vIdeographic.viewTarget.visibility.vMathematical.widths.wordSpacing.writingMode.x1.x2.x.xChannelSelector.xHeight.xlinkActuate.xlinkArcrole.xlinkHref.xlinkRole.xlinkShow.xlinkTitle.xlinkType.xmlBase.xmlLang.xmlns.xmlnsXlink.xmlSpace.y1.y2.y.yChannelSelector.z.zoomAndPan.ref.key.angle`.split(`.`));function qH(e){return typeof e==`string`&&qce.has(e)}function JH(e){return typeof e==`string`&&e.startsWith(`data-`)}function YH(e){if(typeof e!=`object`||!e)return{};var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(qH(n)||JH(n))&&(t[n]=e[n]);return t}function XH(e){if(e==null)return null;if((0,v.isValidElement)(e)&&typeof e.props==`object`&&e.props!==null){var t=e.props;return YH(t)}return typeof e==`object`&&!Array.isArray(e)?YH(e):null}function ZH(e){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(qH(n)||JH(n)||KH(n))&&(t[n]=e[n]);return t}function Jce(e){return e==null?null:(0,v.isValidElement)(e)?ZH(e.props):typeof e==`object`&&!Array.isArray(e)?ZH(e):null}var Yce=[`children`,`width`,`height`,`viewBox`,`className`,`style`,`title`,`desc`];function QH(){return QH=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var n=e.children,r=e.width,i=e.height,a=e.viewBox,o=e.className,s=e.style,c=e.title,l=e.desc,u=Xce(e,Yce),d=a||{width:r,height:i,x:0,y:0},f=xs(`recharts-surface`,o);return v.createElement(`svg`,QH({},ZH(u),{className:f,width:r,height:i,style:s,viewBox:`${d.x} ${d.y} ${d.width} ${d.height}`,ref:t}),v.createElement(`title`,null,c),v.createElement(`desc`,null,l),n)}),Qce=[`children`,`className`];function eU(){return eU=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var n=e.children,r=e.className,i=$ce(e,Qce),a=xs(`recharts-layer`,r);return v.createElement(`g`,eU({className:a},ZH(i),{ref:t}),n)});function nU(e){return e===`__proto__`}var tle=/\.|(\[(?:[^[\]]*|(["'])(?:(?!\2)[^\\]|\\.)*?\2)\])/;function rU(e){switch(typeof e){case`number`:case`symbol`:return!1;case`string`:return e===``||e.startsWith(`.`)||e.endsWith(`.`)?!1:tle.test(e);default:return!1}}function iU(e){return typeof e==`string`||typeof e==`symbol`?e:Object.is(e?.valueOf?.(),-0)?`-0`:String(e)}function aU(e){return typeof e==`symbol`||e instanceof Symbol}function nle(e){return e==null?``:oU(e)}function oU(e){if(typeof e==`string`)return e;if(Array.isArray(e))return e.map(oU).join(`,`);if(aU(e))return e.toString();let t=e+``;return t===`0`&&Object.is(Number(e),-0)?`-0`:t}function sU(e){if(Array.isArray(e))return e.map(iU);if(typeof e==`symbol`)return[e];e=nle(e);let t=[],n=e.length;if(n===0)return t;let r=0,i=``,a=``,o=!1,s=!1,c=/^-?\d+(?:\.\d+)?$/;for(e.charCodeAt(0)===46&&t.push(``);r1&&arguments[1]!==void 0?arguments[1]:ile),n=Math.round(e*t)/t;return Object.is(n,-0)?0:n}function uU(e){var t=[...arguments].slice(1);return e.reduce((e,n,r)=>{var i=t[r-1];return typeof i==`string`?e+i+n:i===void 0?e+n:e+lU(i)+n},``)}var dU=e=>e===0?0:e>0?1:-1,fU=e=>typeof e==`number`&&e!=+e,pU=e=>typeof e==`string`&&e.length>1&&e.indexOf(`%`)===e.length-1,mU=e=>(typeof e==`number`||e instanceof Number)&&!fU(e),hU=e=>mU(e)||typeof e==`string`,ale=0,gU=e=>{var t=++ale;return`${e||``}${t}`},_U=function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,r=arguments.length>3&&arguments[3]!==void 0&&arguments[3];if(!mU(e)&&typeof e!=`string`)return n;var i;if(pU(e)){if(t==null)return n;var a=e.indexOf(`%`);i=t*parseFloat(e.slice(0,a))/100}else i=+e;return fU(i)&&(i=n),r&&t!=null&&i>t&&(i=t),i},vU=e=>{if(!Array.isArray(e))return!1;for(var t=e.length,n={},r=0;re&&(typeof t==`function`?t(e):cU(e,t))===n)}var xU=e=>e==null,SU=e=>xU(e)?e:`${e.charAt(0).toUpperCase()}${e.slice(1)}`;function CU(e){return e!=null}function wU(){}function TU(e){if(e)return{x:e.x,y:e.y,upperWidth:`upperWidth`in e?e.upperWidth:e.width,lowerWidth:`lowerWidth`in e?e.lowerWidth:e.width,width:e.width,height:e.height}}function EU(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 DU(e){for(var t=1;t{var t=e.viewBox,n=e.position,r=e.offset,i=r===void 0?0:r,a=e.parentViewBox,o=e.clamp,s=TU(t),c=s.x,l=s.y,u=s.height,d=s.upperWidth,f=s.lowerWidth,p=c,m=c+(d-f)/2,h=(p+m)/2,g=(d+f)/2,_=p+d/2,v=u>=0?1:-1,y=v*i,b=v>0?`end`:`start`,x=v>0?`start`:`end`,S=d>=0?1:-1,C=S*i,w=S>0?`end`:`start`,T=S>0?`start`:`end`,E=a;if(n===`top`){var D={x:p+d/2,y:l-y,horizontalAnchor:`middle`,verticalAnchor:b};return o&&E&&(D.height=Math.max(l-E.y,0),D.width=d),D}if(n===`bottom`){var O={x:m+f/2,y:l+u+y,horizontalAnchor:`middle`,verticalAnchor:x};return o&&E&&(O.height=Math.max(E.y+E.height-(l+u),0),O.width=f),O}if(n===`left`){var k={x:h-C,y:l+u/2,horizontalAnchor:w,verticalAnchor:`middle`};return o&&E&&(k.width=Math.max(k.x-E.x,0),k.height=u),k}if(n===`right`){var A={x:h+g+C,y:l+u/2,horizontalAnchor:T,verticalAnchor:`middle`};return o&&E&&(A.width=Math.max(E.x+E.width-A.x,0),A.height=u),A}var j=o&&E?{width:g,height:u}:{};return n===`insideLeft`?DU({x:h+C,y:l+u/2,horizontalAnchor:T,verticalAnchor:`middle`},j):n===`insideRight`?DU({x:h+g-C,y:l+u/2,horizontalAnchor:w,verticalAnchor:`middle`},j):n===`insideTop`?DU({x:p+d/2,y:l+y,horizontalAnchor:`middle`,verticalAnchor:x},j):n===`insideBottom`?DU({x:m+f/2,y:l+u-y,horizontalAnchor:`middle`,verticalAnchor:b},j):n===`insideTopLeft`?DU({x:p+C,y:l+y,horizontalAnchor:T,verticalAnchor:x},j):n===`insideTopRight`?DU({x:p+d-C,y:l+y,horizontalAnchor:w,verticalAnchor:x},j):n===`insideBottomLeft`?DU({x:m+C,y:l+u-y,horizontalAnchor:T,verticalAnchor:b},j):n===`insideBottomRight`?DU({x:m+f-C,y:l+u-y,horizontalAnchor:w,verticalAnchor:b},j):n&&typeof n==`object`&&(mU(n.x)||pU(n.x))&&(mU(n.y)||pU(n.y))?DU({x:c+_U(n.x,g),y:l+_U(n.y,u),horizontalAnchor:`end`,verticalAnchor:`end`},j):DU({x:_,y:l+u/2,horizontalAnchor:`middle`,verticalAnchor:`middle`},j)},ule=[`top`,`left`,`right`,`bottom`];function dle(e){return e==null?!1:typeof e==`object`||ule.includes(e)}var fle=(0,v.createContext)(null);function OU(e){return function(){return e}}var kU=Math.PI,AU=2*kU,jU=1e-6,ple=AU-jU;function MU(e){this._+=e[0];for(let t=1,n=e.length;t=0))throw Error(`invalid digits: ${e}`);if(t>15)return MU;let n=10**t;return function(e){this._+=e[0];for(let t=1,r=e.length;tjU){if(!(Math.abs(u*s-c*l)>jU)||!i)this._append`L${this._x1=e},${this._y1=t}`;else{let f=n-a,p=r-o,m=s*s+c*c,h=f*f+p*p,g=Math.sqrt(m),_=Math.sqrt(d),v=i*Math.tan((kU-Math.acos((m+d-h)/(2*g*_)))/2),y=v/_,b=v/g;Math.abs(y-1)>jU&&this._append`L${e+y*l},${t+y*u}`,this._append`A${i},${i},0,0,${+(u*f>l*p)},${this._x1=e+b*s},${this._y1=t+b*c}`}}}arc(e,t,n,r,i,a){if(e=+e,t=+t,n=+n,a=!!a,n<0)throw Error(`negative radius: ${n}`);let o=n*Math.cos(r),s=n*Math.sin(r),c=e+o,l=t+s,u=1^a,d=a?r-i:i-r;this._x1===null?this._append`M${c},${l}`:(Math.abs(this._x1-c)>jU||Math.abs(this._y1-l)>jU)&&this._append`L${c},${l}`,n&&(d<0&&(d=d%AU+AU),d>ple?this._append`A${n},${n},0,1,${u},${e-o},${t-s}A${n},${n},0,1,${u},${this._x1=c},${this._y1=l}`:d>jU&&this._append`A${n},${n},0,${+(d>=kU)},${u},${this._x1=e+n*Math.cos(i)},${this._y1=t+n*Math.sin(i)}`)}rect(e,t,n,r){this._append`M${this._x0=this._x1=+e},${this._y0=this._y1=+t}h${n=+n}v${+r}h${-n}Z`}toString(){return this._}};NU.prototype;function PU(e){let t=3;return e.digits=function(n){if(!arguments.length)return t;if(n==null)t=null;else{let e=Math.floor(n);if(!(e>=0))throw RangeError(`invalid digits: ${n}`);t=e}return e},()=>new NU(t)}Array.prototype.slice;function FU(e){return typeof e==`object`&&`length`in e?e:Array.from(e)}function IU(e){this._context=e}IU.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:this._context.lineTo(e,t)}}};function LU(e){return new IU(e)}function RU(e){return e[0]}function zU(e){return e[1]}function BU(e,t){var n=OU(!0),r=null,i=LU,a=null,o=PU(s);e=typeof e==`function`?e:e===void 0?RU:OU(e),t=typeof t==`function`?t:t===void 0?zU:OU(t);function s(s){var c,l=(s=FU(s)).length,u,d=!1,f;for(r??(a=i(f=o())),c=0;c<=l;++c)!(c=d;--f)s.point(_[f],v[f]);s.lineEnd(),s.areaEnd()}}h&&(_[u]=+e(m,u,l),v[u]=+t(m,u,l),s.point(r?+r(m,u,l):_[u],n?+n(m,u,l):v[u]))}if(g)return s=null,g+``||null}function u(){return BU().defined(i).curve(o).context(a)}return l.x=function(t){return arguments.length?(e=typeof t==`function`?t:OU(+t),r=null,l):e},l.x0=function(t){return arguments.length?(e=typeof t==`function`?t:OU(+t),l):e},l.x1=function(e){return arguments.length?(r=e==null?null:typeof e==`function`?e:OU(+e),l):r},l.y=function(e){return arguments.length?(t=typeof e==`function`?e:OU(+e),n=null,l):t},l.y0=function(e){return arguments.length?(t=typeof e==`function`?e:OU(+e),l):t},l.y1=function(e){return arguments.length?(n=e==null?null:typeof e==`function`?e:OU(+e),l):n},l.lineX0=l.lineY0=function(){return u().x(e).y(t)},l.lineY1=function(){return u().x(e).y(n)},l.lineX1=function(){return u().x(r).y(t)},l.defined=function(e){return arguments.length?(i=typeof e==`function`?e:OU(!!e),l):i},l.curve=function(e){return arguments.length?(o=e,a!=null&&(s=o(a)),l):o},l.context=function(e){return arguments.length?(e==null?a=s=null:s=o(a=e),l):a},l}var HU=class{constructor(e,t){this._context=e,this._x=t}areaStart(){this._line=0}areaEnd(){this._line=NaN}lineStart(){this._point=0}lineEnd(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line}point(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:this._x?this._context.bezierCurveTo(this._x0=(this._x0+e)/2,this._y0,this._x0,t,e,t):this._context.bezierCurveTo(this._x0,this._y0=(this._y0+t)/2,e,this._y0,e,t)}this._x0=e,this._y0=t}};function hle(e){return new HU(e,!0)}function gle(e){return new HU(e,!1)}function UU(){}function WU(e,t,n){e._context.bezierCurveTo((2*e._x0+e._x1)/3,(2*e._y0+e._y1)/3,(e._x0+2*e._x1)/3,(e._y0+2*e._y1)/3,(e._x0+4*e._x1+t)/6,(e._y0+4*e._y1+n)/6)}function GU(e){this._context=e}GU.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){switch(this._point){case 3:WU(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1)}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:WU(this,e,t)}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function _le(e){return new GU(e)}function KU(e){this._context=e}KU.prototype={areaStart:UU,areaEnd:UU,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._y0=this._y1=this._y2=this._y3=this._y4=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:this._context.moveTo(this._x2,this._y2),this._context.closePath();break;case 2:this._context.moveTo((this._x2+2*this._x3)/3,(this._y2+2*this._y3)/3),this._context.lineTo((this._x3+2*this._x2)/3,(this._y3+2*this._y2)/3),this._context.closePath();break;case 3:this.point(this._x2,this._y2),this.point(this._x3,this._y3),this.point(this._x4,this._y4)}},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._x2=e,this._y2=t;break;case 1:this._point=2,this._x3=e,this._y3=t;break;case 2:this._point=3,this._x4=e,this._y4=t,this._context.moveTo((this._x0+4*this._x1+e)/6,(this._y0+4*this._y1+t)/6);break;default:WU(this,e,t)}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function vle(e){return new KU(e)}function qU(e){this._context=e}qU.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===3)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3;var n=(this._x0+4*this._x1+e)/6,r=(this._y0+4*this._y1+t)/6;this._line?this._context.lineTo(n,r):this._context.moveTo(n,r);break;case 3:this._point=4;default:WU(this,e,t)}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function yle(e){return new qU(e)}function JU(e){this._context=e}JU.prototype={areaStart:UU,areaEnd:UU,lineStart:function(){this._point=0},lineEnd:function(){this._point&&this._context.closePath()},point:function(e,t){e=+e,t=+t,this._point?this._context.lineTo(e,t):(this._point=1,this._context.moveTo(e,t))}};function ble(e){return new JU(e)}function YU(e){return e<0?-1:1}function XU(e,t,n){var r=e._x1-e._x0,i=t-e._x1,a=(e._y1-e._y0)/(r||i<0&&-0),o=(n-e._y1)/(i||r<0&&-0),s=(a*i+o*r)/(r+i);return(YU(a)+YU(o))*Math.min(Math.abs(a),Math.abs(o),.5*Math.abs(s))||0}function ZU(e,t){var n=e._x1-e._x0;return n?(3*(e._y1-e._y0)/n-t)/2:t}function QU(e,t,n){var r=e._x0,i=e._y0,a=e._x1,o=e._y1,s=(a-r)/3;e._context.bezierCurveTo(r+s,i+s*t,a-s,o-s*n,a,o)}function $U(e){this._context=e}$U.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:QU(this,this._t0,ZU(this,this._t0))}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){var n=NaN;if(e=+e,t=+t,e!==this._x1||t!==this._y1){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,QU(this,ZU(this,n=XU(this,e,t)),n);break;default:QU(this,this._t0,n=XU(this,e,t))}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t,this._t0=n}}};function eW(e){this._context=new tW(e)}(eW.prototype=Object.create($U.prototype)).point=function(e,t){$U.prototype.point.call(this,t,e)};function tW(e){this._context=e}tW.prototype={moveTo:function(e,t){this._context.moveTo(t,e)},closePath:function(){this._context.closePath()},lineTo:function(e,t){this._context.lineTo(t,e)},bezierCurveTo:function(e,t,n,r,i,a){this._context.bezierCurveTo(t,e,r,n,a,i)}};function xle(e){return new $U(e)}function Sle(e){return new eW(e)}function nW(e){this._context=e}nW.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=[],this._y=[]},lineEnd:function(){var e=this._x,t=this._y,n=e.length;if(n){if(this._line?this._context.lineTo(e[0],t[0]):this._context.moveTo(e[0],t[0]),n===2)this._context.lineTo(e[1],t[1]);else for(var r=rW(e),i=rW(t),a=0,o=1;o=0;--t)i[t]=(o[t]-i[t+1])/a[t];for(a[n-1]=(e[n]+i[n-1])/2,t=0;t=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:if(this._t<=0)this._context.lineTo(this._x,t),this._context.lineTo(e,t);else{var n=this._x*(1-this._t)+e*this._t;this._context.lineTo(n,this._y),this._context.lineTo(n,t)}}this._x=e,this._y=t}};function wle(e){return new iW(e,.5)}function Tle(e){return new iW(e,0)}function Ele(e){return new iW(e,1)}function aW(e,t){if((o=e.length)>1)for(var n=1,r,i,a=e[t[0]],o,s=a.length;n=0;)n[t]=t;return n}function Dle(e,t){return e[t]}function Ole(e){let t=[];return t.key=e,t}function kle(){var e=OU([]),t=oW,n=aW,r=Dle;function i(i){var a=Array.from(e.apply(this,arguments),Ole),o,s=a.length,c=-1,l;for(let e of i)for(o=0,++c;o0){for(var n,r,i=0,a=e[0].length,o;i0){for(var n=0,r=e[t[0]],i,a=r.length;n0)||!((a=(i=e[t[0]]).length)>0))){for(var n=0,r=1,i,a,o;r`radius`in e&&`startAngle`in e&&`endAngle`in e,sW=(e,t)=>{if(!e||typeof e==`function`||typeof e==`boolean`)return null;var n=e;if((0,v.isValidElement)(e)&&(n=e.props),typeof n!=`object`&&typeof n!=`function`)return null;var r={};return Object.keys(n).forEach(e=>{KH(e)&&typeof n[e]==`function`&&(r[e]=t||(t=>n[e](n,t)))}),r},Ple=(e,t,n)=>r=>(e(t,n,r),null),Fle=(e,t,n)=>{if(e===null||typeof e!=`object`&&typeof e!=`function`)return null;var r=null;return Object.keys(e).forEach(i=>{var a=e[i];KH(i)&&typeof a==`function`&&(r||={},r[i]=Ple(a,t,n))}),r};function cW(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 Ile(e){for(var t=1;t(e[t]===void 0&&r[t]!==void 0&&(e[t]=r[t]),e),n)}function Ble(e){return Number.isSafeInteger(e)&&e>=0}function uW(e){return e!=null&&typeof e!=`function`&&Ble(e.length)}function dW(e){return Object.getOwnPropertySymbols(e).filter(t=>Object.prototype.propertyIsEnumerable.call(e,t))}function fW(e){return e==null?e===void 0?`[object Undefined]`:`[object Null]`:Object.prototype.toString.call(e)}var pW=`[object RegExp]`,mW=`[object String]`,hW=`[object Number]`,gW=`[object Boolean]`,Vle=`[object Arguments]`,_W=`[object Symbol]`,vW=`[object Date]`,yW=`[object Map]`,bW=`[object Set]`,xW=`[object Array]`,Hle=`[object Function]`,SW=`[object ArrayBuffer]`,CW=`[object Object]`,Ule=`[object Error]`,wW=`[object DataView]`,TW=`[object Uint8Array]`,EW=`[object Uint8ClampedArray]`,DW=`[object Uint16Array]`,OW=`[object Uint32Array]`,Wle=`[object BigUint64Array]`,kW=`[object Int8Array]`,AW=`[object Int16Array]`,jW=`[object Int32Array]`,Gle=`[object BigInt64Array]`,MW=`[object Float32Array]`,NW=`[object Float64Array]`,PW=typeof globalThis==`object`&&globalThis||typeof window==`object`&&window||typeof self==`object`&&self||typeof global==`object`&&global||(function(){return this})();function FW(e){return PW.Buffer!==void 0&&PW.Buffer.isBuffer(e)}function IW(e,t){return e===t||Number.isNaN(e)&&Number.isNaN(t)}function LW(e){return e!==null&&(typeof e==`object`||typeof e==`function`)}var Kle=/^(?:0|[1-9]\d*)$/;function RW(e,t=2**53-1){switch(typeof e){case`number`:return Number.isInteger(e)&&e>=0&&e{var t=d(),n=K_();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:r,a=n.useSyncExternalStore,o=t.useRef,s=t.useEffect,c=t.useMemo,l=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,u){var d=o(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=c(function(){function e(e){if(!a){if(a=!0,o=e,e=r(e),u!==void 0&&f.hasValue){var t=f.value;if(u(t,e))return s=t}return s=e}if(t=s,i(o,e))return t;var n=r(e);return u!==void 0&&u(t,n)?(o=e,t):(o=e,s=n)}var a=!1,o,s,c=n===void 0?null:n;return[function(){return e(t())},c===null?void 0:function(){return e(c())}]},[t,n,r,u]);var p=a(e,d[0],d[1]);return s(function(){f.hasValue=!0,f.value=p},[p]),l(p),p}})),Jle=o(((e,t)=>{t.exports=qle()})),zW=(0,v.createContext)(null),Yle=Jle(),Xle=e=>e,BW=()=>{var e=(0,v.useContext)(zW);return e?e.store.dispatch:Xle},VW=()=>{},Zle=()=>VW,Qle=(e,t)=>e===t;function HW(e){var t=(0,v.useContext)(zW),n=(0,v.useMemo)(()=>t?t=>{if(t!=null)return e(t)}:VW,[t,e]);return(0,Yle.useSyncExternalStoreWithSelector)(t?t.subscription.addNestedSub:Zle,t?t.store.getState:VW,t?t.store.getState:VW,n,Qle)}function $le(e,t=`expected a function, instead received ${typeof e}`){if(typeof e!=`function`)throw TypeError(t)}function eue(e,t=`expected all items to be functions, instead received the following types: `){if(!e.every(e=>typeof e==`function`)){let n=e.map(e=>typeof e==`function`?`function ${e.name||`unnamed`}()`:typeof e).join(`, `);throw TypeError(`${t}[${n}]`)}}var UW=e=>Array.isArray(e)?e:[e];function tue(e){let t=Array.isArray(e[0])?e[0]:e;return eue(t,`createSelector expects all input-selectors to be functions, but received the following types: `),t}function nue(e,t){let n=[],{length:r}=e;for(let i=0;i`u`?rue:WeakRef,iue=0,GW=1;function KW(){return{s:iue,v:void 0,o:null,p:null}}function aue(e){return e instanceof WW?e.deref():e}function qW(e,t={}){let n=KW(),{resultEqualityCheck:r}=t,i,a=0;function o(){let t=n,{length:o}=arguments;for(let e=0,n=o;e{n=KW(),o.resetResultsCount()},o.resultsCount=()=>a,o.resetResultsCount=()=>{a=0},o}function oue(e,...t){let n=typeof e==`function`?{memoize:e,memoizeOptions:t}:e,r=(...e)=>{let t=0,r=0,i,a={},o=e.pop();typeof o==`object`&&(a=o,o=e.pop()),$le(o,`createSelector expects an output function after the inputs, but received: [${typeof o}]`);let{memoize:s,memoizeOptions:c=[],argsMemoize:l=qW,argsMemoizeOptions:u=[]}={...n,...a},d=UW(c),f=UW(u),p=tue(e),m=s(function(){return t++,o.apply(null,arguments)},...d),h=l(function(){r++;let e=nue(p,arguments);return i=m.apply(null,e),i},...f);return Object.assign(h,{resultFunc:o,memoizedResultFunc:m,dependencies:p,dependencyRecomputations:()=>r,resetDependencyRecomputations:()=>{r=0},lastResult:()=>i,recomputations:()=>t,resetRecomputations:()=>{t=0},memoize:s,argsMemoize:l})};return Object.assign(r,{withTypes:()=>r}),r}var $=oue(qW);function sue(e,t=1){let n=[],r=Math.floor(t),i=(e,t)=>{for(let a=0;a{if(e!==t){let r=YW(e),i=YW(t);if(r===i&&r===0){if(et)return n===`desc`?-1:1}return n===`desc`?i-r:r-i}return 0},lue=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,uue=/^\w*$/;function due(e,t){return Array.isArray(e)?!1:typeof e==`number`||typeof e==`boolean`||e==null||aU(e)?!0:typeof e==`string`&&(uue.test(e)||!lue.test(e))||t!=null&&Object.hasOwn(t,e)}function fue(e,t,n,r){if(e==null)return[];n=r?void 0:n,Array.isArray(e)||(e=uW(e)?Array.from(e):Object.values(e)),Array.isArray(t)||(t=t==null?[null]:[t]),t.length===0&&(t=[null]),Array.isArray(n)||(n=n==null?[]:[n]),n=n.map(e=>String(e));let i=(e,t)=>{let n=e,r=0;for(;r0&&r===t.length?n:void 0},a=(e,t)=>{if(e==null)return t;if(t!=null)return typeof e==`object`&&`key`in e?Object.hasOwn(t,e.key)?t[e.key]:i(t,e.path):typeof e==`function`?e(t):Array.isArray(e)?i(t,e):t[e]},o=t.map(e=>(Array.isArray(e)&&e.length===1&&(e=e[0]),e==null||typeof e==`function`||Array.isArray(e)||due(e)?e:{key:e,path:sU(e)}));return e.map(e=>({original:e,criteria:o.map(t=>a(t,e))})).slice().sort((e,t)=>{for(let r=0;re.original)}function XW(e,...t){let n=t.length;return n>1&&JW(e,t[0],t[1])?t=[]:n>2&&JW(t[0],t[1],t[2])&&(t=[t[0]]),fue(e,sue(t),[`asc`])}var ZW=e=>e.legend.settings,pue=e=>e.legend.size;$([e=>e.legend.payload,ZW],(e,t)=>{var n=t.itemSorter,r=e.flat(1);return n?XW(r,n):r});function QW(e){return`Minified Redux error #${e}; visit https://redux.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var $W=typeof Symbol==`function`&&Symbol.observable||`@@observable`,eG=()=>Math.random().toString(36).substring(7).split(``).join(`.`),tG={INIT:`@@redux/INIT${eG()}`,REPLACE:`@@redux/REPLACE${eG()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${eG()}`};function nG(e){if(typeof e!=`object`||!e)return!1;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t||Object.getPrototypeOf(e)===null}function rG(e,t,n){if(typeof e!=`function`)throw Error(QW(2));if(typeof t==`function`&&typeof n==`function`||typeof n==`function`&&typeof arguments[3]==`function`)throw Error(QW(0));if(typeof t==`function`&&n===void 0&&(n=t,t=void 0),n!==void 0){if(typeof n!=`function`)throw Error(QW(1));return n(rG)(e,t)}let r=e,i=t,a=new Map,o=a,s=0,c=!1;function l(){o===a&&(o=new Map,a.forEach((e,t)=>{o.set(t,e)}))}function u(){if(c)throw Error(QW(3));return i}function d(e){if(typeof e!=`function`)throw Error(QW(4));if(c)throw Error(QW(5));let t=!0;l();let n=s++;return o.set(n,e),function(){if(t){if(c)throw Error(QW(6));t=!1,l(),o.delete(n),a=null}}}function f(e){if(!nG(e))throw Error(QW(7));if(e.type===void 0)throw Error(QW(8));if(typeof e.type!=`string`)throw Error(QW(17));if(c)throw Error(QW(9));try{c=!0,i=r(i,e)}finally{c=!1}return(a=o).forEach(e=>{e()}),e}function p(e){if(typeof e!=`function`)throw Error(QW(10));r=e,f({type:tG.REPLACE})}function m(){let e=d;return{subscribe(t){if(typeof t!=`object`||!t)throw Error(QW(11));function n(){let e=t;e.next&&e.next(u())}return n(),{unsubscribe:e(n)}},[$W](){return this}}}return f({type:tG.INIT}),{dispatch:f,subscribe:d,getState:u,replaceReducer:p,[$W]:m}}function mue(e){Object.keys(e).forEach(t=>{let n=e[t];if(n(void 0,{type:tG.INIT})===void 0)throw Error(QW(12));if(n(void 0,{type:tG.PROBE_UNKNOWN_ACTION()})===void 0)throw Error(QW(13))})}function iG(e){let t=Object.keys(e),n={};for(let r=0;re:e.length===1?e[0]:e.reduce((e,t)=>(...n)=>e(t(...n)))}function hue(...e){return t=>(n,r)=>{let i=t(n,r),a=()=>{throw Error(QW(15))},o={getState:i.getState,dispatch:(e,...t)=>a(e,...t)};return a=aG(...e.map(e=>e(o)))(i.dispatch),{...i,dispatch:a}}}function oG(e){return nG(e)&&`type`in e&&typeof e.type==`string`}var sG=Symbol.for(`immer-nothing`),cG=Symbol.for(`immer-draftable`),lG=Symbol.for(`immer-state`);function uG(e,...t){throw Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var dG=Object,fG=dG.getPrototypeOf,pG=`constructor`,mG=`prototype`,hG=`configurable`,gG=`enumerable`,_G=`writable`,vG=`value`,yG=e=>!!e&&!!e[lG];function bG(e){return e?SG(e)||OG(e)||!!e[cG]||!!e[pG]?.[cG]||kG(e)||AG(e):!1}var gue=dG[mG][pG].toString(),xG=new WeakMap;function SG(e){if(!e||!jG(e))return!1;let t=fG(e);if(t===null||t===dG[mG])return!0;let n=dG.hasOwnProperty.call(t,pG)&&t[pG];if(n===Object)return!0;if(!MG(n))return!1;let r=xG.get(n);return r===void 0&&(r=Function.toString.call(n),xG.set(n,r)),r===gue}function CG(e,t,n=!0){wG(e)===0?(n?Reflect.ownKeys(e):dG.keys(e)).forEach(n=>{t(n,e[n],e)}):e.forEach((n,r)=>t(r,n,e))}function wG(e){let t=e[lG];return t?t.type_:OG(e)?1:kG(e)?2:AG(e)?3:0}var TG=(e,t,n=wG(e))=>n===2?e.has(t):dG[mG].hasOwnProperty.call(e,t),EG=(e,t,n=wG(e))=>n===2?e.get(t):e[t],DG=(e,t,n,r=wG(e))=>{r===2?e.set(t,n):r===3?e.add(n):e[t]=n};function _ue(e,t){return e===t?e!==0||1/e==1/t:e!==e&&t!==t}var OG=Array.isArray,kG=e=>e instanceof Map,AG=e=>e instanceof Set,jG=e=>typeof e==`object`,MG=e=>typeof e==`function`,NG=e=>typeof e==`boolean`;function vue(e){let t=+e;return Number.isInteger(t)&&String(t)===e}var PG=e=>e.copy_||e.base_,FG=e=>e.modified_?e.copy_:e.base_;function IG(e,t){if(kG(e))return new Map(e);if(AG(e))return new Set(e);if(OG(e))return Array[mG].slice.call(e);let n=SG(e);if(t===!0||t===`class_only`&&!n){let t=dG.getOwnPropertyDescriptors(e);delete t[lG];let n=Reflect.ownKeys(t);for(let r=0;r1&&dG.defineProperties(e,{set:RG,add:RG,clear:RG,delete:RG}),dG.freeze(e),t&&CG(e,(e,t)=>{LG(t,!0)},!1),e)}function yue(){uG(2)}var RG={[vG]:yue};function zG(e){return e===null||!jG(e)||dG.isFrozen(e)}var BG=`MapSet`,VG=`Patches`,HG=`ArrayMethods`,UG={};function WG(e){let t=UG[e];return t||uG(0,e),t}var GG=e=>!!UG[e],KG,qG=()=>KG,bue=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:GG(BG)?WG(BG):void 0,arrayMethodsPlugin_:GG(HG)?WG(HG):void 0});function JG(e,t){t&&(e.patchPlugin_=WG(VG),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function YG(e){XG(e),e.drafts_.forEach(xue),e.drafts_=null}function XG(e){e===KG&&(KG=e.parent_)}var ZG=e=>KG=bue(KG,e);function xue(e){let t=e[lG];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function QG(e,t){t.unfinalizedDrafts_=t.drafts_.length;let n=t.drafts_[0];if(e!==void 0&&e!==n){n[lG].modified_&&(YG(t),uG(4)),bG(e)&&(e=$G(t,e));let{patchPlugin_:r}=t;r&&r.generateReplacementPatches_(n[lG].base_,e,t)}else e=$G(t,n);return Sue(t,e,!0),YG(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e===sG?void 0:e}function $G(e,t){if(zG(t))return t;let n=t[lG];if(!n)return iK(t,e.handledSet_,e);if(!tK(n,e))return t;if(!n.modified_)return n.base_;if(!n.finalized_){let{callbacks_:t}=n;if(t)for(;t.length>0;)t.pop()(e);rK(n,e)}return n.copy_}function Sue(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&LG(t,n)}function eK(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var tK=(e,t)=>e.scope_===t,Cue=[];function nK(e,t,n,r){let i=PG(e),a=e.type_;if(r!==void 0&&EG(i,r,a)===t){DG(i,r,n,a);return}if(!e.draftLocations_){let t=e.draftLocations_=new Map;CG(i,(e,n)=>{if(yG(n)){let r=t.get(n)||[];r.push(e),t.set(n,r)}})}let o=e.draftLocations_.get(t)??Cue;for(let e of o)DG(i,e,n,a)}function wue(e,t,n){e.callbacks_.push(function(r){let i=t;if(!i||!tK(i,r))return;r.mapSetPlugin_?.fixSetContents(i);let a=FG(i);nK(e,i.draft_??i,a,n),rK(i,r)})}function rK(e,t){if(e.modified_&&!e.finalized_&&(e.type_===3||e.type_===1&&e.allIndicesReassigned_||(e.assigned_?.size??0)>0)){let{patchPlugin_:n}=t;if(n){let r=n.getPath(e);r&&n.generatePatches_(e,r,t)}eK(e)}}function Tue(e,t,n){let{scope_:r}=e;if(yG(n)){let i=n[lG];tK(i,r)&&i.callbacks_.push(function(){uK(e),nK(e,n,FG(i),t)})}else bG(n)&&e.callbacks_.push(function(){let i=PG(e);e.type_===3?i.has(n)&&iK(n,r.handledSet_,r):EG(i,t,e.type_)===n&&r.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&iK(EG(e.copy_,t,e.type_),r.handledSet_,r)})}function iK(e,t,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||yG(e)||t.has(e)||!bG(e)||zG(e)?e:(t.add(e),CG(e,(r,i)=>{if(yG(i)){let t=i[lG];tK(t,n)&&(DG(e,r,FG(t),e.type_),eK(t))}else bG(i)&&iK(i,t,n)}),e)}function Eue(e,t){let n=OG(e),r={type_:+!!n,scope_:t?t.scope_:qG(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0},i=r,a=aK;n&&(i=[r],a=oK);let{revoke:o,proxy:s}=Proxy.revocable(i,a);return r.draft_=s,r.revoke_=o,[s,r]}var aK={get(e,t){if(t===lG)return e;let n=e.scope_.arrayMethodsPlugin_,r=e.type_===1&&typeof t==`string`;if(r&&n?.isArrayOperationMethod(t))return n.createMethodInterceptor(e,t);let i=PG(e);if(!TG(i,t,e.type_))return Oue(e,i,t);let a=i[t];if(e.finalized_||!bG(a)||r&&e.operationMethod&&n?.isMutatingArrayMethod(e.operationMethod)&&vue(t))return a;if(a===sK(e.base_,t)||Due(e,t,a)){uK(e);let n=e.type_===1?+t:t,r=dK(e.scope_,a,e,n);return e.copy_[n]=r}return a},has(e,t){return t in PG(e)},ownKeys(e){return Reflect.ownKeys(PG(e))},set(e,t,n){let r=cK(PG(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){let r=sK(PG(e),t),i=r?.[lG];if(i&&i.base_===n)return e.copy_[t]=n,e.assigned_.set(t,!1),!0;if(_ue(n,r)&&(n!==void 0||TG(e.base_,t,e.type_)))return!0;uK(e),lK(e)}return e.copy_[t]===n&&(n!==void 0||TG(e.copy_,t,e.type_))||Number.isNaN(n)&&Number.isNaN(e.copy_[t])?!0:(e.copy_[t]=n,e.assigned_.set(t,!0),Tue(e,t,n),!0)},deleteProperty(e,t){return uK(e),sK(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),lK(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){let n=PG(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{[_G]:!0,[hG]:e.type_!==1||t!==`length`,[gG]:r[gG],[vG]:n[t]}},defineProperty(){uG(11)},getPrototypeOf(e){return fG(e.base_)},setPrototypeOf(){uG(12)}},oK={};for(let e in aK){let t=aK[e];oK[e]=function(){let e=arguments;return e[0]=e[0][0],t.apply(this,e)}}oK.deleteProperty=function(e,t){return oK.set.call(this,e,t,void 0)},oK.set=function(e,t,n){return aK.set.call(this,e[0],t,n,e[0])};function sK(e,t){let n=e[lG];return(n?PG(n):e)[t]}function Due(e,t,n){return e.type_!==1||!e.allIndicesReassigned_||e.assigned_?.get(t)||!bG(n)||n[lG]?!1:e.baseRefs_.has(n)}function Oue(e,t,n){let r=cK(t,n);return r?vG in r?r[vG]:r.get?.call(e.draft_):void 0}function cK(e,t){if(!(t in e))return;let n=fG(e);for(;n;){let e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=fG(n)}}function lK(e){e.modified_||(e.modified_=!0,e.parent_&&lK(e.parent_))}function uK(e){e.copy_||=(e.assigned_=new Map,IG(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var kue=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(e,t,n)=>{if(MG(e)&&!MG(t)){let n=t;t=e;let r=this;return function(e=n,...i){return r.produce(e,e=>t.call(this,e,...i))}}MG(t)||uG(6),n!==void 0&&!MG(n)&&uG(7);let r;if(bG(e)){let i=ZG(this),a=dK(i,e,void 0),o=!0;try{r=t(a),o=!1}finally{o?YG(i):XG(i)}return JG(i,n),QG(r,i)}if(!e||!jG(e)){if(r=t(e),r===void 0&&(r=e),r===sG&&(r=void 0),this.autoFreeze_&&LG(r,!0),n){let t=[],i=[];WG(VG).generateReplacementPatches_(e,r,{patches_:t,inversePatches_:i}),n(t,i)}return r}uG(1,e)},this.produceWithPatches=(e,t)=>{if(MG(e))return(t,...n)=>this.produceWithPatches(t,t=>e(t,...n));let n,r;return[this.produce(e,t,(e,t)=>{n=e,r=t}),n,r]},NG(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),NG(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),NG(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){bG(e)||uG(8),yG(e)&&(e=fK(e));let t=ZG(this),n=dK(t,e,void 0);return n[lG].isManual_=!0,XG(t),n}finishDraft(e,t){let n=e&&e[lG];(!n||!n.isManual_)&&uG(9);let{scope_:r}=n;return JG(r,t),QG(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){let r=t[n];if(r.path.length===0&&r.op===`replace`){e=r.value;break}}n>-1&&(t=t.slice(n+1));let r=WG(VG).applyPatches_;return yG(e)?r(e,t):this.produce(e,e=>r(e,t))}};function dK(e,t,n,r){let[i,a]=kG(t)?WG(BG).proxyMap_(t,n):AG(t)?WG(BG).proxySet_(t,n):Eue(t,n);return(n?.scope_??qG()).drafts_.push(i),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&r!==void 0?wue(n,a,r):a.callbacks_.push(function(e){e.mapSetPlugin_?.fixSetContents(a);let{patchPlugin_:t}=e;a.modified_&&t&&t.generatePatches_(a,[],e)}),i}function fK(e){return yG(e)||uG(10,e),pK(e)}function pK(e){if(!bG(e)||zG(e))return e;let t=e[lG],n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=IG(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=IG(e,!0);return CG(n,(e,t)=>{DG(n,e,pK(t))},r),t&&(t.finalized_=!1),n}globalThis.Iterator?.from;var mK=new kue().produce,hK=e=>e;function gK(e){return({dispatch:t,getState:n})=>r=>i=>typeof i==`function`?i(t,n,e):r(i)}var Aue=gK(),jue=gK,Mue=typeof window<`u`&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]==`object`?aG:aG.apply(null,arguments)};typeof window<`u`&&window.__REDUX_DEVTOOLS_EXTENSION__&&window.__REDUX_DEVTOOLS_EXTENSION__;function _K(e,t){function n(...n){if(t){let r=t(...n);if(!r)throw Error(QK(0));return{type:e,payload:r.payload,...`meta`in r&&{meta:r.meta},...`error`in r&&{error:r.error}}}return{type:e,payload:n[0]}}return n.toString=()=>`${e}`,n.type=e,n.match=t=>oG(t)&&t.type===e,n}var vK=class e extends Array{constructor(...t){super(...t),Object.setPrototypeOf(this,e.prototype)}static get[Symbol.species](){return e}concat(...e){return super.concat.apply(this,e)}prepend(...t){return t.length===1&&Array.isArray(t[0])?new e(...t[0].concat(this)):new e(...t.concat(this))}};function yK(e){return bG(e)?mK(e,()=>{}):e}function bK(e,t,n){return e.has(t)?e.get(t):e.set(t,n(t)).get(t)}function Nue(e){return typeof e==`boolean`}var Pue=()=>function(e){let{thunk:t=!0,immutableCheck:n=!0,serializableCheck:r=!0,actionCreatorCheck:i=!0}=e??{},a=new vK;return t&&(Nue(t)?a.push(Aue):a.push(jue(t.extraArgument))),a},xK=`RTK_autoBatch`,SK=()=>e=>({payload:e,meta:{[xK]:!0}}),CK=e=>t=>{setTimeout(t,e)},Fue=(e,t)=>n=>{let r=!1,i=()=>{r||(r=!0,cancelAnimationFrame(a),clearTimeout(o),n())},a=e(i),o=setTimeout(i,t)},wK=(e={type:`raf`})=>t=>(...n)=>{let r=t(...n),i=!0,a=!1,o=!1,s=new Set,c=e.type===`tick`?queueMicrotask:e.type===`raf`?typeof window<`u`&&window.requestAnimationFrame?Fue(window.requestAnimationFrame,100):CK(10):e.type===`callback`?e.queueNotification:CK(e.timeout),l=()=>{o=!1,a&&(a=!1,s.forEach(e=>e()))};return Object.assign({},r,{subscribe(e){let t=r.subscribe(()=>i&&e());return s.add(e),()=>{t(),s.delete(e)}},dispatch(e){try{return i=!e?.meta?.[xK],a=!i,a&&(o||(o=!0,c(l))),r.dispatch(e)}finally{i=!0}}})},Iue=e=>function(t){let{autoBatch:n=!0}=t??{},r=new vK(e);return n&&r.push(wK(typeof n==`object`?n:void 0)),r};function Lue(e){let t=Pue(),{reducer:n=void 0,middleware:r,devTools:i=!0,duplicateMiddlewareCheck:a=!0,preloadedState:o=void 0,enhancers:s=void 0}=e||{},c;if(typeof n==`function`)c=n;else if(nG(n))c=iG(n);else throw Error(QK(1));let l;l=typeof r==`function`?r(t):t();let u=aG;i&&(u=Mue({trace:!1,...typeof i==`object`&&i}));let d=Iue(hue(...l)),f=typeof s==`function`?s(d):d(),p=u(...f);return rG(c,o,p)}function TK(e){let t={},n=[],r,i={addCase(e,n){let r=typeof e==`string`?e:e.type;if(!r)throw Error(QK(28));if(r in t)throw Error(QK(29));return t[r]=n,i},addAsyncThunk(e,r){return r.pending&&(t[e.pending.type]=r.pending),r.rejected&&(t[e.rejected.type]=r.rejected),r.fulfilled&&(t[e.fulfilled.type]=r.fulfilled),r.settled&&n.push({matcher:e.settled,reducer:r.settled}),i},addMatcher(e,t){return n.push({matcher:e,reducer:t}),i},addDefaultCase(e){return r=e,i}};return e(i),[t,n,r]}function Rue(e){return typeof e==`function`}function zue(e,t){let[n,r,i]=TK(t),a;if(Rue(e))a=()=>yK(e());else{let t=yK(e);a=()=>t}function o(e=a(),t){let o=[n[t.type],...r.filter(({matcher:e})=>e(t)).map(({reducer:e})=>e)];return o.filter(e=>!!e).length===0&&(o=[i]),o.reduce((e,n)=>{if(n){if(yG(e)){let r=n(e,t);return r===void 0?e:r}if(bG(e))return mK(e,e=>n(e,t));{let r=n(e,t);if(r===void 0){if(e===null)return e;throw Error(`A case reducer on a non-draftable value must not return undefined`)}return r}}return e},e)}return o.getInitialState=a,o}var Bue=`ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW`,Vue=(e=21)=>{let t=``,n=e;for(;n--;)t+=Bue[Math.random()*64|0];return t},Hue=Symbol.for(`rtk-slice-createasyncthunk`);function Uue(e,t){return`${e}/${t}`}function Wue({creators:e}={}){let t=e?.asyncThunk?.[Hue];return function(e){let{name:n,reducerPath:r=n}=e;if(!n)throw Error(QK(11));let i=(typeof e.reducers==`function`?e.reducers(Kue()):e.reducers)||{},a=Object.keys(i),o={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},s={addCase(e,t){let n=typeof e==`string`?e:e.type;if(!n)throw Error(QK(12));if(n in o.sliceCaseReducersByType)throw Error(QK(13));return o.sliceCaseReducersByType[n]=t,s},addMatcher(e,t){return o.sliceMatchers.push({matcher:e,reducer:t}),s},exposeAction(e,t){return o.actionCreators[e]=t,s},exposeCaseReducer(e,t){return o.sliceCaseReducersByName[e]=t,s}};a.forEach(r=>{let a=i[r],o={reducerName:r,type:Uue(n,r),createNotation:typeof e.reducers==`function`};Jue(a)?Xue(o,a,s,t):que(o,a,s)});function c(){let[t={},n=[],r=void 0]=typeof e.extraReducers==`function`?TK(e.extraReducers):[e.extraReducers],i={...t,...o.sliceCaseReducersByType};return zue(e.initialState,e=>{for(let t in i)e.addCase(t,i[t]);for(let t of o.sliceMatchers)e.addMatcher(t.matcher,t.reducer);for(let t of n)e.addMatcher(t.matcher,t.reducer);r&&e.addDefaultCase(r)})}let l=e=>e,u=new Map,d=new WeakMap,f;function p(e,t){return f||=c(),f(e,t)}function m(){return f||=c(),f.getInitialState()}function h(t,n=!1){function r(e){let i=e[t];return i===void 0&&n&&(i=bK(d,r,m)),i}function i(t=l){return bK(bK(u,n,()=>new WeakMap),t,()=>{let r={};for(let[i,a]of Object.entries(e.selectors??{}))r[i]=Gue(a,t,()=>bK(d,t,m),n);return r})}return{reducerPath:t,getSelectors:i,get selectors(){return i(r)},selectSlice:r}}let g={name:n,reducer:p,actions:o.actionCreators,caseReducers:o.sliceCaseReducersByName,getInitialState:m,...h(r),injectInto(e,{reducerPath:t,...n}={}){let i=t??r;return e.inject({reducerPath:i,reducer:p},n),{...g,...h(i,!0)}}};return g}}function Gue(e,t,n,r){function i(i,...a){let o=t(i);return o===void 0&&r&&(o=n()),e(o,...a)}return i.unwrapped=e,i}var EK=Wue();function Kue(){function e(e,t){return{_reducerDefinitionType:`asyncThunk`,payloadCreator:e,...t}}return e.withTypes=()=>e,{reducer(e){return Object.assign({[e.name](...t){return e(...t)}}[e.name],{_reducerDefinitionType:`reducer`})},preparedReducer(e,t){return{_reducerDefinitionType:`reducerWithPrepare`,prepare:e,reducer:t}},asyncThunk:e}}function que({type:e,reducerName:t,createNotation:n},r,i){let a,o;if(`reducer`in r){if(n&&!Yue(r))throw Error(QK(17));a=r.reducer,o=r.prepare}else a=r;i.addCase(e,a).exposeCaseReducer(t,a).exposeAction(t,o?_K(e,o):_K(e))}function Jue(e){return e._reducerDefinitionType===`asyncThunk`}function Yue(e){return e._reducerDefinitionType===`reducerWithPrepare`}function Xue({type:e,reducerName:t},n,r,i){if(!i)throw Error(QK(18));let{payloadCreator:a,fulfilled:o,pending:s,rejected:c,settled:l,options:u}=n,d=i(e,a,u);r.exposeAction(t,d),o&&r.addCase(d.fulfilled,o),s&&r.addCase(d.pending,s),c&&r.addCase(d.rejected,c),l&&r.addMatcher(d.settled,l),r.exposeCaseReducer(t,{fulfilled:o||DK,pending:s||DK,rejected:c||DK,settled:l||DK})}function DK(){}var Zue=`task`,OK=`listener`,kK=`completed`,AK=`cancelled`,Que=`task-${AK}`,$ue=`task-${kK}`,jK=`${OK}-${AK}`,ede=`${OK}-${kK}`,MK=class{constructor(e){this.code=e,this.message=`${Zue} ${AK} (reason: ${e})`}code;name=`TaskAbortError`;message},NK=(e,t)=>{if(typeof e!=`function`)throw TypeError(QK(32))},PK=()=>{},FK=(e,t=PK)=>(e.catch(t),e),IK=(e,t)=>(e.addEventListener(`abort`,t,{once:!0}),()=>e.removeEventListener(`abort`,t)),LK=e=>{if(e.aborted)throw new MK(e.reason)};function RK(e,t){let n=PK;return new Promise((r,i)=>{let a=()=>i(new MK(e.reason));if(e.aborted){a();return}n=IK(e,a),t.finally(()=>n()).then(r,i)}).finally(()=>{n=PK})}var tde=async(e,t)=>{try{return await Promise.resolve(),{status:`ok`,value:await e()}}catch(e){return{status:e instanceof MK?`cancelled`:`rejected`,error:e}}finally{t?.()}},zK=e=>t=>FK(RK(e,t).then(t=>(LK(e),t))),BK=e=>{let t=zK(e);return e=>t(new Promise(t=>setTimeout(t,e)))},{assign:VK}=Object,HK={},UK=`listenerMiddleware`,nde=(e,t)=>{let n=t=>IK(e,()=>t.abort(e.reason));return(r,i)=>{NK(r,`taskExecutor`);let a=new AbortController;n(a);let o=tde(async()=>{LK(e),LK(a.signal);let t=await r({pause:zK(a.signal),delay:BK(a.signal),signal:a.signal});return LK(a.signal),t},()=>a.abort($ue));return i?.autoJoin&&t.push(o.catch(PK)),{result:zK(e)(o),cancel(){a.abort(Que)}}}},rde=(e,t)=>{let n=async(n,r)=>{LK(t);let i=()=>{},a=[new Promise((t,r)=>{let a=e({predicate:n,effect:(e,n)=>{n.unsubscribe(),t([e,n.getState(),n.getOriginalState()])}});i=()=>{a(),r()}})];r!=null&&a.push(new Promise(e=>setTimeout(e,r,null)));try{let e=await RK(t,Promise.race(a));return LK(t),e}finally{i()}};return((e,t)=>FK(n(e,t)))},WK=e=>{let{type:t,actionCreator:n,matcher:r,predicate:i,effect:a}=e;if(t)i=_K(t).match;else if(n)t=n.type,i=n.match;else if(r)i=r;else if(!i)throw Error(QK(21));return NK(a,`options.listener`),{predicate:i,type:t,effect:a}},GK=VK(e=>{let{type:t,predicate:n,effect:r}=WK(e);return{id:Vue(),effect:r,type:t,predicate:n,pending:new Set,unsubscribe:()=>{throw Error(QK(22))}}},{withTypes:()=>GK}),KK=(e,t)=>{let{type:n,effect:r,predicate:i}=WK(t);return Array.from(e.values()).find(e=>(typeof n==`string`?e.type===n:e.predicate===i)&&e.effect===r)},qK=e=>{e.pending.forEach(e=>{e.abort(jK)})},ide=(e,t)=>()=>{for(let e of t.keys())qK(e);e.clear()},JK=(e,t,n)=>{try{e(t,n)}catch(e){setTimeout(()=>{throw e},0)}},YK=VK(_K(`${UK}/add`),{withTypes:()=>YK}),ade=_K(`${UK}/removeAll`),XK=VK(_K(`${UK}/remove`),{withTypes:()=>XK}),ode=(...e)=>{console.error(`${UK}/error`,...e)},ZK=(e={})=>{let t=new Map,n=new Map,r=e=>{let t=n.get(e)??0;n.set(e,t+1)},i=e=>{let t=n.get(e)??1;t===1?n.delete(e):n.set(e,t-1)},{extra:a,onError:o=ode}=e;NK(o,`onError`);let s=e=>(e.unsubscribe=()=>t.delete(e.id),t.set(e.id,e),t=>{e.unsubscribe(),t?.cancelActive&&qK(e)}),c=(e=>{let n=KK(t,e)??GK(e);return s(n)});VK(c,{withTypes:()=>c});let l=e=>{let n=KK(t,e);return n&&(n.unsubscribe(),e.cancelActive&&qK(n)),!!n};VK(l,{withTypes:()=>l});let u=async(e,n,s,l)=>{let u=new AbortController,d=rde(c,u.signal),f=[];try{e.pending.add(u),r(e),await Promise.resolve(e.effect(n,VK({},s,{getOriginalState:l,condition:(e,t)=>d(e,t).then(Boolean),take:d,delay:BK(u.signal),pause:zK(u.signal),extra:a,signal:u.signal,fork:nde(u.signal,f),unsubscribe:e.unsubscribe,subscribe:()=>{t.set(e.id,e)},cancelActiveListeners:()=>{e.pending.forEach((e,t,n)=>{e!==u&&(e.abort(jK),n.delete(e))})},cancel:()=>{u.abort(jK),e.pending.delete(u)},throwIfCancelled:()=>{LK(u.signal)}})))}catch(e){e instanceof MK||JK(o,e,{raisedBy:`effect`})}finally{await Promise.all(f),u.abort(ede),i(e),e.pending.delete(u)}},d=ide(t,n);return{middleware:e=>n=>r=>{if(!oG(r))return n(r);if(YK.match(r))return c(r.payload);if(ade.match(r)){d();return}if(XK.match(r))return l(r.payload);let i=e.getState(),a=()=>{if(i===HK)throw Error(QK(23));return i},s;try{if(s=n(r),t.size>0){let n=e.getState(),s=Array.from(t.values());for(let t of s){let s=!1;try{s=t.predicate(r,n,i)}catch(e){s=!1,JK(o,e,{raisedBy:`predicate`})}s&&u(t,r,e,a)}}}finally{i=HK}return s},startListening:c,stopListening:l,clearListeners:d}};function QK(e){return`Minified Redux Toolkit error #${e}; visit https://redux-toolkit.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var $K=EK({name:`chartLayout`,initialState:{layoutType:`horizontal`,width:0,height:0,margin:{top:5,right:5,bottom:5,left:5},scale:1},reducers:{setLayout(e,t){e.layoutType=t.payload},setChartSize(e,t){e.width=t.payload.width,e.height=t.payload.height},setMargin(e,t){e.margin.top=t.payload.top??0,e.margin.right=t.payload.right??0,e.margin.bottom=t.payload.bottom??0,e.margin.left=t.payload.left??0},setScale(e,t){e.scale=t.payload}}}),eq=$K.actions,sde=eq.setMargin,cde=eq.setLayout,lde=eq.setChartSize,ude=eq.setScale,dde=$K.reducer;function tq(e,t,n){return Array.isArray(e)&&e&&t+n!==0?e.slice(t,n+1):e}function nq(e){return Number.isFinite(e)}function rq(e){return typeof e==`number`&&e>0&&Number.isFinite(e)}function iq(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 aq(e){for(var t=1;t{if(t&&n){var r=n.width,i=n.height,a=t.align,o=t.verticalAlign,s=t.layout,c=t.position,l=t.offset,u=l===void 0?0:l;if(c!=null){if(dle(c)){if(c===`top`&&mU(e.top))return aq(aq({},e),{},{top:e.top+(i||0)+u});if(c===`bottom`&&mU(e.bottom))return aq(aq({},e),{},{bottom:e.bottom+(i||0)+u});if(c===`left`&&mU(e.left))return aq(aq({},e),{},{left:e.left+(r||0)+u});if(c===`right`&&mU(e.right))return aq(aq({},e),{},{right:e.right+(r||0)+u})}return e}if((s===`vertical`||s===`horizontal`&&o===`middle`)&&a!==`center`&&mU(e[a]))return aq(aq({},e),{},{[a]:e[a]+(r||0)});if((s===`horizontal`||s===`vertical`&&a===`center`)&&o!==`middle`&&mU(e[o]))return aq(aq({},e),{},{[o]:e[o]+(i||0)})}return e},sq=(e,t)=>e===`horizontal`&&t===`xAxis`||e===`vertical`&&t===`yAxis`||e===`centric`&&t===`angleAxis`||e===`radial`&&t===`radiusAxis`,gde=(e,t,n,r)=>{if(r)return e.map(e=>e.coordinate);var i,a,o=e.map(e=>(e.coordinate===t&&(i=!0),e.coordinate===n&&(a=!0),e.coordinate));return i||o.push(t),a||o.push(n),o},cq=(e,t,n)=>{if(!e)return null;var r=e.duplicateDomain,i=e.type,a=e.range,o=e.scale,s=e.realScaleType,c=e.isCategorical,l=e.categoricalDomain,u=e.tickCount,d=e.ticks,f=e.niceTicks,p=e.axisType;if(!o)return null;var m=s===`scaleBand`&&o.bandwidth?o.bandwidth()/2:2,h=(t||n)&&i===`category`&&o.bandwidth?o.bandwidth()/m:0;return h=p===`angleAxis`&&a&&a.length>=2?dU(a[0]-a[1])*2*h:h,t&&(d||f)?(d||f||[]).map((e,t)=>{var n=r?r.indexOf(e):e,i=o.map(n);return nq(i)?{coordinate:i+h,value:e,offset:h,index:t}:null}).filter(CU):c&&l?l.map((e,t)=>{var n=o.map(e);return nq(n)?{coordinate:n+h,value:e,index:t,offset:h}:null}).filter(CU):o.ticks&&!n&&u!=null?o.ticks(u).map((e,t)=>{var n=o.map(e);return nq(n)?{coordinate:n+h,value:e,index:t,offset:h}:null}).filter(CU):o.domain().map((e,t)=>{var n=o.map(e);return nq(n)?{coordinate:n+h,value:r?r[e]:e,index:t,offset:h}:null}).filter(CU)},lq={sign:e=>{var t=e.length;if(!(t<=0)){var n=e[0]?.length;if(!(n==null||n<=0))for(var r=0;r=0?(s[0]=i,i+=u,s[1]=i):(s[0]=a,a+=u,s[1]=a)}}}},expand:Ale,none:aW,silhouette:jle,wiggle:Mle,positive:e=>{var t=e.length;if(!(t<=0)){var n=e[0]?.length;if(!(n==null||n<=0))for(var r=0;r=0?(o[0]=i,i+=s,o[1]=i):(o[0]=0,o[1]=0)}}}}},uq=(e,t,n)=>{var r=lq[n]??aW,i=kle().keys(t).value((e,t)=>Number(oq(e,t,0))).order(oW).offset(r)(e);return i.forEach((n,r)=>{n.forEach((n,i)=>{var a=oq(e[i],t[r],0);Array.isArray(a)&&a.length===2&&mU(a[0])&&mU(a[1])&&(n[0]=a[0],n[1]=a[1])})}),i};function dq(e){return e==null?void 0:String(e)}function fq(e){var t=e.axis,n=e.ticks,r=e.bandSize,i=e.entry,a=e.index,o=e.dataKey;if(t.type===`category`){if(!t.allowDuplicatedCategory&&t.dataKey&&!xU(i[t.dataKey])){var s=bU(n,`value`,i[t.dataKey]);if(s)return s.coordinate+r/2}return n!=null&&n[a]?n[a].coordinate+r/2:null}var c=oq(i,xU(o)?t.dataKey:o),l=t.scale.map(c);return mU(l)?l:null}var pq=e=>{var t=e.flat(2).filter(mU);return[Math.min(...t),Math.max(...t)]},mq=e=>[e[0]===1/0?0:e[0],e[1]===-1/0?0:e[1]],hq=(e,t,n)=>{if(e!=null&&Object.keys(e).length!==0)return mq(Object.keys(e).reduce((r,i)=>{var a=e[i];if(!a)return r;var o=a.stackedData.reduce((e,r)=>{var i=pq(tq(r,t,n));return!nq(i[0])||!nq(i[1])?e:[Math.min(e[0],i[0]),Math.max(e[1],i[1])]},[1/0,-1/0]);return[Math.min(o[0],r[0]),Math.max(o[1],r[1])]},[1/0,-1/0]))},gq=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,_q=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,vq=(e,t,n)=>{if(e&&e.scale&&e.scale.bandwidth){var r=e.scale.bandwidth();if(!n||r>0)return r}if(e&&t&&t.length>=2){for(var i=XW(t,e=>e.coordinate),a=[],o=0,s=1,c=i.length;su&&(d=Math.min(f,d));return d===1/0?0:d}return n?void 0:0};function yq(e){var t=e.tooltipEntrySettings,n=e.dataKey,r=e.payload,i=e.value,a=e.name;return aq(aq({},t),{},{dataKey:n,payload:r,value:i,name:a})}function bq(e,t){if(e!=null)return String(e);if(typeof t==`string`)return t}var xq=(e,t)=>{if(t===`horizontal`)return e.relativeX;if(t===`vertical`)return e.relativeY},Sq=(e,t)=>t===`centric`?e.angle:e.radius,Cq=e=>e.layout.width,wq=e=>e.layout.height,Tq=e=>e.layout.scale,Eq=e=>e.layout.margin,Dq=$(e=>e.cartesianAxis.xAxis,e=>Object.values(e)),Oq=$(e=>e.cartesianAxis.yAxis,e=>Object.values(e)),kq=`data-recharts-item-index`;function Aq(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 jq(e){for(var t=1;te.brush.height;function Iq(e){return Oq(e).reduce((e,t)=>t.orientation===`left`&&!t.mirror&&!t.hide?e+(typeof t.width==`number`?t.width:60):e,0)}function Lq(e){return Oq(e).reduce((e,t)=>t.orientation===`right`&&!t.mirror&&!t.hide?e+(typeof t.width==`number`?t.width:60):e,0)}function Rq(e){return Dq(e).reduce((e,t)=>t.orientation===`top`&&!t.mirror&&!t.hide?e+(typeof t.height==`number`?t.height:30):e,0)}function zq(e){return Dq(e).reduce((e,t)=>t.orientation===`bottom`&&!t.mirror&&!t.hide?e+(typeof t.height==`number`?t.height:30):e,0)}var Bq=$([Cq,wq,Eq,Fq,Iq,Lq,Rq,zq,ZW,pue],(e,t,n,r,i,a,o,s,c,l)=>{var u={left:(n.left||0)+i,right:(n.right||0)+a},d=jq(jq({},{top:(n.top||0)+o,bottom:(n.bottom||0)+s}),u),f=d.bottom;d.bottom+=r,d=hde(d,c,l);var p=e-d.left-d.right,m=t-d.top-d.bottom;return jq(jq({brushBottom:f},d),{},{width:Math.max(p,0),height:Math.max(m,0)})}),Vq=$(Bq,e=>({x:e.left,y:e.top,width:e.width,height:e.height})),Hq=$(Cq,wq,(e,t)=>({x:0,y:0,width:e,height:t})),Uq=(0,v.createContext)(null),Wq=()=>(0,v.useContext)(Uq)!=null,Gq=e=>e.brush,Kq=$([Gq,Bq,Eq],(e,t,n)=>({height:e.height,x:mU(e.x)?e.x:t.left,y:mU(e.y)?e.y:t.top+t.height+t.brushBottom-(n?.bottom||0),width:mU(e.width)?e.width:t.width}));function qq(e,t,{signal:n,edges:r}={}){let i,a=null,o=r!=null&&r.includes(`leading`),s=r==null||r.includes(`trailing`),c=()=>{a!==null&&(e.apply(i,a),i=void 0,a=null)},l=()=>{s&&c(),p()},u=null,d=()=>{u!=null&&clearTimeout(u),u=setTimeout(()=>{u=null,l()},t)},f=()=>{u!==null&&(clearTimeout(u),u=null)},p=()=>{f(),i=void 0,a=null},m=()=>{c()},h=function(...e){if(n?.aborted)return;i=this,a=e;let t=u==null;d(),o&&t&&c()};return h.schedule=d,h.cancel=p,h.flush=m,n?.addEventListener(`abort`,p,{once:!0}),h}function Jq(e,t=0,n={}){typeof n!=`object`&&(n={});let{leading:r=!1,trailing:i=!0,maxWait:a}=n,o=[,,];r&&(o[0]=`leading`),i&&(o[1]=`trailing`);let s,c=null,l=qq(function(...t){s=e.apply(this,t),c=null},t,{edges:o}),u=function(...t){return a!=null&&(c===null&&(c=Date.now()),Date.now()-c>=a)?((r||i)&&(s=e.apply(this,t)),c=Date.now(),l.cancel(),l.schedule(),s):(l.apply(this,t),s)};return u.cancel=l.cancel,u.flush=()=>(l.flush(),s),u}function Yq(e,t=0,n={}){let{leading:r=!0,trailing:i=!0}=n;return Jq(e,t,{leading:r,maxWait:t,trailing:i})}var Xq=function(e,t){var n=[...arguments].slice(2);if(typeof console<`u`&&console.warn&&(t===void 0&&console.warn(`LogUtils requires an error message argument`),!e)){if(t===void 0)console.warn(`Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.`);else{var r=0;console.warn(t.replace(/%s/g,()=>n[r++]))}}},Zq={width:`100%`,height:`100%`,debounce:0,minWidth:0,initialDimension:{width:-1,height:-1}},Qq=(e,t,n)=>{var r=n.width,i=r===void 0?Zq.width:r,a=n.height,o=a===void 0?Zq.height:a,s=n.aspect,c=n.maxHeight,l=pU(i)?e:Number(i),u=pU(o)?t:Number(o);return s&&s>0&&(l?u=l/s:u&&(l=u*s),c&&u!=null&&u>c&&(u=c)),{calculatedWidth:l,calculatedHeight:u}},$q={width:0,height:0,overflow:`visible`},eJ={width:0,overflowX:`visible`},tJ={height:0,overflowY:`visible`},nJ={},rJ=e=>{var t=e.width,n=e.height,r=pU(t),i=pU(n);return r&&i?$q:r?eJ:i?tJ:nJ};function iJ(e){var t=e.width,n=e.height,r=e.aspect,i=t,a=n;return i===void 0&&a===void 0?(i=Zq.width,a=Zq.height):i===void 0?i=r&&r>0?void 0:Zq.width:a===void 0&&(a=r&&r>0?void 0:Zq.height),{width:i,height:a}}var aJ=[`aspect`,`initialDimension`,`width`,`height`,`minWidth`,`minHeight`,`maxHeight`,`children`,`debounce`,`id`,`className`,`onResize`,`style`];function oJ(){return oJ=Object.assign?Object.assign.bind():function(e){for(var t=1;t{let e=a.current,t=o.current;if(!e||!t)return;let n=n=>{let r=e.querySelector(`[data-selected="true"]`);if(!r){Z.set(t,{autoAlpha:0});return}let i=e.getBoundingClientRect(),a=r.getBoundingClientRect();Z.to(t,{x:a.left-i.left,y:a.top-i.top,width:a.width,height:a.height,autoAlpha:1,duration:n?MV(kV.base):0,ease:AV.out,overwrite:!0})};n(s.current),s.current=!0;let r=new ResizeObserver(()=>n(!1));return r.observe(e),()=>{r.disconnect(),Z.killTweensOf(t)}},[e,n]),(0,G.jsxs)(`div`,{ref:a,className:`filter-toggle relative inline-flex ${i??``}`,children:[(0,G.jsx)(`span`,{ref:o,"aria-hidden":!0,className:`filter-toggle__pill pointer-events-none absolute left-0 top-0 opacity-0`}),(0,G.jsx)(iM,{"aria-label":r,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,G.jsxs)(qA,{id:e.id,className:`relative z-[1]`,style:hce,children:[e.icon,e.label]},e.id))})]})}function mH(e,t=!1){if(!e)return;let n=e.toDate(Qw());if(Number.isFinite(n.getTime()))return t&&n.setSeconds(59,999),n.toISOString()}function hH(e){if(!e)return null;let t=Date.parse(e);if(!Number.isFinite(t))return null;try{return vT(Gne(new Date(t).toISOString()))}catch{return null}}function gH({value:e,onChange:t,ariaLabel:n,fromLabel:r,toLabel:i,className:a}){return(0,G.jsx)(SA,{className:a,granularity:`minute`,hourCycle:24,shouldForceLeadingZeros:!0,value:e,onChange:e=>t(e),"aria-label":n,children:({state:e})=>(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(lk.Group,{className:`w-full min-w-0`,variant:`secondary`,children:[(0,G.jsx)(lk.Input,{className:`min-w-0`,slot:`start`,"aria-label":r,children:e=>(0,G.jsx)(lk.Segment,{segment:e})}),(0,G.jsx)(SA.RangeSeparator,{}),(0,G.jsx)(lk.Input,{className:`min-w-0`,slot:`end`,"aria-label":i,children:e=>(0,G.jsx)(lk.Segment,{segment:e})}),(0,G.jsx)(lk.Suffix,{children:(0,G.jsx)(SA.Trigger,{children:(0,G.jsx)(SA.TriggerIndicator,{})})})]}),(0,G.jsxs)(SA.Popover,{className:`flex w-[20.5rem] max-w-[calc(100vw-2rem)] flex-col gap-3 p-3`,children:[(0,G.jsxs)(CI,{"aria-label":n,children:[(0,G.jsxs)(CI.Header,{children:[(0,G.jsxs)(CI.YearPickerTrigger,{children:[(0,G.jsx)(CI.YearPickerTriggerHeading,{}),(0,G.jsx)(CI.YearPickerTriggerIndicator,{})]}),(0,G.jsx)(CI.NavButton,{slot:`previous`}),(0,G.jsx)(CI.NavButton,{slot:`next`})]}),(0,G.jsxs)(CI.Grid,{children:[(0,G.jsx)(CI.GridHeader,{children:e=>(0,G.jsx)(CI.HeaderCell,{children:e})}),(0,G.jsx)(CI.GridBody,{children:e=>(0,G.jsx)(CI.Cell,{date:e})})]}),(0,G.jsx)(CI.YearPickerGrid,{children:(0,G.jsx)(CI.YearPickerGridBody,{children:({year:e})=>(0,G.jsx)(CI.YearPickerCell,{year:e})})})]}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,G.jsx)(IN,{className:`text-xs`,children:r}),(0,G.jsx)(LA,{"aria-label":r,granularity:`minute`,hourCycle:24,value:e.timeRange?.start??null,onChange:t=>e.setTimeRange({start:t,end:e.timeRange?.end}),children:(0,G.jsx)(LA.Group,{className:`w-[7.5rem]`,variant:`secondary`,children:(0,G.jsx)(LA.Input,{children:e=>(0,G.jsx)(LA.Segment,{segment:e})})})})]}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,G.jsx)(IN,{className:`text-xs`,children:i}),(0,G.jsx)(LA,{"aria-label":i,granularity:`minute`,hourCycle:24,value:e.timeRange?.end??null,onChange:t=>e.setTimeRange({start:e.timeRange?.start,end:t}),children:(0,G.jsx)(LA.Group,{className:`w-[7.5rem]`,variant:`secondary`,children:(0,G.jsx)(LA.Input,{children:e=>(0,G.jsx)(LA.Segment,{segment:e})})})})]})]})]})]})})}var _H={today:`statsWindowToday`,1:`statsWindow1h`,24:`statsWindow24h`,168:`statsWindow7d`,720:`statsWindow30d`,custom:`statsWindowCustom`};function vH(e,t){if(e===`today`){let e=new Date;return e.setHours(0,0,0,0),{from:e.toISOString()}}if(e===`custom`){let e=mH(t?.start),n=mH(t?.end,!0);return e&&n?{from:e,to:n}:null}if(e===`720`){let e=new Date;return{from:new Date(e.getTime()-2592e6).toISOString(),to:e.toISOString()}}return{hours:Number(e)}}function yH({value:e,onChange:t,custom:n,onCustomChange:r,onBusy:i,t:a}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(pH,{value:e,onChange:r=>{let a=r;e!==a&&((a!==`custom`||n)&&i?.(),t(a))},ariaLabel:a(`statsTraffic`),options:Object.keys(_H).map(e=>({id:e,label:a(_H[e])}))}),e===`custom`?(0,G.jsx)(gH,{className:`w-[min(100%,24rem)]`,value:n,onChange:e=>{e&&i?.(),r(e)},ariaLabel:a(`statsWindowCustom`),fromLabel:a(`logsTimeFrom`),toLabel:a(`logsTimeTo`)}):null]})}function bH(e,t,n){let r=new URLSearchParams;for(let[t,n]of Object.entries(e))n&&r.set(t,n);let i=Date.parse(t),a=Date.parse(n);return Number.isFinite(i)&&Number.isFinite(a)&&(r.set(`from`,new Date(Math.floor(i/6e4)*6e4).toISOString()),r.set(`to`,new Date(Math.ceil(a/6e4)*6e4-6e4).toISOString())),`/logs?${r}`}function xH(e){let t=String(e||``).toLowerCase();return!t||t===`qoder`||t===`qoder-global`||t===`qoder-cn`}function SH(e){return String(e||``).toLowerCase()===`workbuddy`}function CH(e){return String(e||``).toLowerCase()===`trae`}function wH(e){return String(e||``).toLowerCase()===`devin`}function TH(e){return String(e||``).toLowerCase()===`command`}function EH(e){return String(e||``).toLowerCase()===`zhipu`}function DH(e){return String(e||``).toLowerCase()===`qwenwork`}function OH(e){return String(e||``).toLowerCase()===`kimi`}function kH(e){let t=String(e||``).toLowerCase();return t===`meta`||t===`muse`}function AH(e,t){let n=String(e||``).toLowerCase();return SH(n)?`WorkBuddy`:CH(n)?`Trae`:wH(n)?`Devin`:TH(n)?`Command Code`:EH(n)?`Zhipu GLM`:DH(n)?`QwenWork`:OH(n)?`Kimi Code`:kH(n)?`Muse (Meta)`:xH(n)?`Qoder`:e||t(`account`)}function jH(e,t,n){let r=String(e||``).toLowerCase(),i=String(t||``).toLowerCase();return SH(r)?n(i===`global`?`accountTypeWorkBuddyGlobal`:`accountTypeWorkBuddyCN`):CH(r)?n(`accountTypeTraeCN`):wH(r)?n(`accountTypeDevinGlobal`):TH(r)?n(`accountTypeCommandGlobal`):EH(r)?n(`accountTypeZhipuCN`):DH(r)?n(i===`cn`?`accountTypeQwenworkCN`:`accountTypeQwenworkGlobal`):OH(r)?n(`accountTypeKimiCN`):kH(r)?n(`accountTypeMetaGlobal`):xH(r)?n(i===`cn`?`accountTypeQoderCN`:`accountTypeQoderGlobal`):e||n(`account`)}function gce(e,t){let n=t??!!e.max_mode,r=e.catalog_context_length||e.default_context_length||e.context_length||0,i=e.catalog_context_length_max||0;return n&&i>0?{context_length:i,prompt_max_tokens:e.prompt_max_tokens_max||e.prompt_max_tokens,max_output_tokens:e.max_output_tokens_max||e.max_output_tokens}:{context_length:r,prompt_max_tokens:e.prompt_max_tokens,max_output_tokens:e.max_output_tokens}}function _ce({size:e=16,className:t=``}){return(0,G.jsx)(`span`,{className:`inline-flex shrink-0 items-center justify-center rounded-[22%] bg-[#0a84ff] text-white ${t}`.trim(),style:{width:e,height:e,fontSize:Math.max(9,Math.round(e*.55)),fontWeight:650,lineHeight:1},"aria-hidden":`true`,children:`C`})}function vce({size:e=16,className:t=``}){return(0,G.jsx)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,className:`block shrink-0 text-foreground ${t}`.trim(),"aria-hidden":`true`,children:(0,G.jsx)(`path`,{fill:`currentColor`,fillRule:`evenodd`,clipRule:`evenodd`,d:`M8.086.457a6.1 6.1 0 0 1 3.046-.415q2 .23 3.564 1.7a.12.12 0 0 0 .107.029q2.112-.519 4.061.366l.063.03l.154.076q2.036 1.055 2.918 3.198a5.6 5.6 0 0 1 .421 2.126 5.7 5.7 0 0 1-.18 1.631.17.17 0 0 0 .04.155 6 6 0 0 1 1.578 2.891q.577 2.852-1.183 5.14l-.182.22a6.06 6.06 0 0 1-2.934 1.851.16.16 0 0 0-.108.102c-.255.736-.511 1.364-.987 1.992-1.199 1.582-2.962 2.462-4.948 2.451q-2.374-.012-4.21-1.736a.14.14 0 0 0-.14-.032 5.9 5.9 0 0 1-1.604-.185 5.9 5.9 0 0 1-2.595-.622 6.06 6.06 0 0 1-2.146-1.781c-.203-.269-.404-.522-.551-.821a8 8 0 0 1-.495-1.283 6.1 6.1 0 0 1-.017-3.064.2.2 0 0 0 .008-.074.1.1 0 0 0-.037-.064 6 6 0 0 1-1.38-2.202 5.2 5.2 0 0 1-.333-1.589 6.9 6.9 0 0 1 .188-2.132q.675-2.226 2.577-3.493.424-.282.802-.438.429-.179.861-.304a.13.13 0 0 0 .087-.087A6 6 0 0 1 5.635 2.31Q6.655 1.04 8.086.457m-.804 7.85a.848.848 0 0 0-1.473.842l1.694 2.965-1.688 2.848a.849.849 0 0 0 1.46.864l1.94-3.272a.85.85 0 0 0 .007-.854zm5.446 6.24a.849.849 0 0 0 0 1.695h4.848a.849.849 0 0 0 0-1.696z`})})}function yce({size:e=16,className:t=``}){return(0,G.jsx)(`span`,{className:`inline-flex shrink-0 items-center justify-center rounded-[22%] bg-[#1a1a1a] text-white ${t}`.trim(),style:{width:e,height:e,fontSize:Math.max(9,Math.round(e*.55)),fontWeight:650,lineHeight:1},"aria-hidden":`true`,children:`D`})}function bce({size:e=16,className:t=``}){return(0,G.jsx)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,className:`block shrink-0 text-foreground ${t}`.trim(),"aria-hidden":`true`,children:(0,G.jsx)(`path`,{fill:`currentColor`,d:`M21 12.79A9 9 0 1 1 11.21 3a7 7 0 0 0 9.79 9.79Z`})})}function xce({size:e=16,className:t=``}){return(0,G.jsx)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,className:`block shrink-0 text-foreground ${t}`.trim(),"aria-hidden":`true`,children:(0,G.jsx)(`path`,{fill:`currentColor`,fillRule:`evenodd`,d:`M8 6a4 4 0 0 0 0 8c.9 0 1.7-.3 2.4-.8L14 16.8A4 4 0 1 0 16 8a3.9 3.9 0 0 0-2.4.8L10 5.2A4 4 0 0 0 8 6Zm0 2a2 2 0 1 1 0 4 2 2 0 0 1 0-4Zm8 4a2 2 0 1 1 0 4 2 2 0 0 1 0-4Z`,clipRule:`evenodd`})})}var Sce=`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAALQAAAC0CAYAAAA9zQYyAAAJ5ElEQVR42u2dXUxUZxrH/wKDDDCM4CJBZJZNxMpGDMGYXsAWeikapF6Jqc02kUhWTWsTIQHjNk22yWCyN5INrk22rbsc71ZNpXfb0sJ+Gcxmma2mNpt1XMsaLd2ZoY7D5164btfiBx8zzDnv+f1uiWeG9/x8eN7neT9WFRaunROAIWQwBIDQAAgNgNAACA0IDYDQAAgNgNAACA0IDYDQAAgNgNAACA0IDYDQAAgNgNAACA0IDYDQAAgNgNAACA0IDYDQAAgNgNAA35LFEDyZ6uotKi8PqL6+ToFAuQoK/PL7/fL7CyRJ4fBNRaMRhcM3FQ6HFQqFNDoaUiQSYfDSxCqO031U4Lq6OjU1Nam6eov8fv+inxGJRDQ6GtLAwIAs6xxyI/TK0tTUpJ07d6iurk6BQCCpz45EIurrO62+vtOIjdCpIxAIqLPzWEokRmyEXjHq6+vU0dGh+vq6tHw+YiN00iJyb++ptImM2Aid1NSitbXVlt8vEomoq+u4LMvCRIR+Oq2trersPLYiOfJyCYfD6u4+rkuXBjASoZ0VlZ/G0NCwenp6NDQ0jJkI/aCOfPbs+46IyogtWt9Po739oAYHP3a8zNKDaszFixd08eIF20xkidArSGdnhzo7O4x9SZZlKRg8qXA4jLGmC/322z9Te/tBV7ysvr7TCgZ7KPWZKnRv7ynt29fqqhdGDdtQod0oM2IbKrSb0gzEXhyZXm/um06bAL7++muY/F9ycnJUX1+nPXteUiQSVSgUIkI75cvu29eq3t5TWKyndx0PHz7i2hq2Y4QOBAIaHPxoSYvu3YhbmzOOENrv92tw8CMjmiaILTqFnZ0dyKzldx2rq7cQoe3yQkB0HZ0uNKlG6ggGe4ws9dlaaOrNSyM2e0+3pu4oOntPX07dnffzzasDKvMUazY2ZVwN27ZCV1dv0eDgx9i5AK4lbuhy/Joux6/q1vRdXUvcWNC/K8sq1nbvZpXeX6N/9X+m3/zyrOPFtq3QLJ18egT+c/yqfjcx8j+Jk8GmyfWaOPOFRt4bRGgmgqnnfPRTnY99osvxayn9nJmxuKI/v6r7g7cRmuicXG5N3dEvxn+b1Ei8UCZHxvXvt/6qmbE4QhOdkyPy+dinaf0ec7Fpxd65rm+sf4jDGpdAR0eH3L4Ww7LO6Z2KQWVvK0p/xPNlqeBolTLyPYqduS46hVpc3dnNqYZlWWpublEw2GO775bftlFrTmwlQmuRG13dGpWDwZO2P3DGu6tMM2NxW0dqhE4zo6Mh7d//imNa0fltGyXJtlJn2Gky6LalocFgjxoaGh23riK/baMt8ntbC93U1OQqmbu6um2ZKy+UNSe2KsPnQWg98Sy6vXLLHsD9+19RX99pR/8emaVe5R/YiNB6wm4UN6QbkUhEzc27jTmUMa+1QpmlXoSen27scI3Mo6NmbWL1tVUitB6zss50TJRZelDKs1OUtoXQdXVmN1MOHz5ipMwPyWksQWj9X3fQ5B0pwWCP+vvNPqE/b28FQn87ISw39kX391uOLs1pERUPz6YChJak8vKAse3s7u7jcgvZtUUIbWqEflhrdtNZczkNJQj9MIc2MW82eRL4OEg5DBV6aGjY8V1ALXHddOZ6L0L7/QUyrUTnVrJKcxHatFTDzfeg2KHBgtBJPng8aS/GhivZENpl0TmZVY1VviwGFaGVtpqzGyeCRGiZe91a0l9MvoeBRej05M6WdS65L8XnIeVA6PRF52R3BO22aB6hSTdkQtcNoeW++0tSsV4ja5OPwUVopeGko3MyeV0EQrtsMjgwkJrNrp5KhEboFWZ4ODXpRva2IiocCJ2e/DkVrK5dy+Ai9MozMPBhSp5r1yO2EFpmt7pTsaouw+exzVYmhHYRoVDI+N3TCE3+LFP25SG061KOmynJnWmoILQxKYfdzohDaLmrqaIkL0ZiMojQxghNdDZI6Egk6riSXbKjs3dXGSaaI3TE1S9gzU+3YiFCm0H2tiJyZ9OETkUJzEkX74BhQkej7ozQvrZKtlqZKLTbDjWUHizgf3iBJRiYQ7tJ6gyfR/4T1Zhnch06FBp1zYDnt21ki5XpQg8N/d4Vg+3dVcaKOjcIPTw8LDfkzf6jP8Q4NwgdDodTtuFUNjnzrfBkLXsF3bSW49KlD42VeW3f85To3Ca0ZVnGHRaOzC5fbRcMnkRmMEdoU6I0MiO0MVEamRF6XpS2LGfejZ3XWqHiX9cjM0LPj9JOSz0K3qhSwdEqSnMIrcfWpZubWxyxVjqz1Kt1FxrpACL0QqTebWupfW2VWnehkRQDobXgpaXd3cdtJ3Xurg1ad6GRJaAIvXj6+y01N++2TU6dWeqV/0Q1URmhlxepm5tbUnYEFyB02nLqrq5u1+8UB4MOmunrO62amtqkX0UMCK10btsKBnvSInZBZh7WIHRqxW5oeHHFuou+jFysQejU59eHDh1RTU3tikwcN6/+PuYg9MpNHJubd6dU7LKs72EOQmtFT9hPpdjPrQ5gDkKbI/Z2bxXmIHT6xT506EhSOo5V5NAILZusta6pqV12c8aXkavt3s3Yg9AypjnT4nsBexBaxjRniNAI7QixF0qZp1gtvh9hEELbX+yFdh1/UvQSA4fQckTXsaGh8ZmlPqI0QjuGB2uwn13DJkojtExqzpR5ipEaoZ0t9nebM4eK9rC+Q9LMWByhnSh2TU3tvK7jr8q6XC+1HYTO9Hpz30RTLekCe8s6p0QioerqLSrOLdJ2b5U+nPijJuembP3d52LTWrU6I+nPjAT/prnJWYR2KolEQsPDw3r33feUSCT0Yk29NuSV6HL8qm2ljn9wS18f/4vuf3JbWaW5ylyfnN3r37z/dyX+cCftv9+qwsK1c6iZHPx+v9rbD6rx1R16baJXsdl7tkoHIm+NKjHylb57m63vQKWytxUt69l3Xx7WbGwKoU0V++U3XtVnLfd1LXEj7SJPnPlC9z745zPPG8ndtUF5eysWdT7fzFhcXx+7oqnPo7YYe4ROIYUb1ir/QKWmmwpX/LMnR8YVv3TrmSI/7h7FvL0VCxJ7Ziyur9r/ZIvJIEKvID94/jlFf7xmWX/WFxotJ0fGFTtzfdmSZfg88u4sU05DiTybCh6Re6n/WRDaMLK3FSmnoUS5Ozck7djdyZFx3R+8rckr4yn9s/9w8jjzZdzWY4zQSs/1yFmbfMppKFHOCyULrjTMxaY19XlUU9ejmhwZ1+SVcVtMxBAa5gmeWepVZqlXGT7PIz+bjU1pbmJa02P3bB8dERqA1jcAQgNCAyA0AEIDIDQAQgNCAyA0AEIDIDQAQgNCAyA0AEIDIDQAQgNCAyA0AEIDIDQgNABCAyA0AEIDIDQgNABCAyA0AEIDLIj/ABWOKFxbGBRBAAAAAElFTkSuQmCC`;function Cce({size:e=16,className:t=``}){return(0,G.jsx)(`img`,{src:Sce,alt:``,width:e,height:e,className:`block shrink-0 rounded-[22%] ${t}`.trim(),draggable:!1})}function wce({size:e=16,className:t=``}){let n=Math.max(2,Math.round(e*.14));return(0,G.jsxs)(`span`,{className:`inline-flex shrink-0 items-baseline justify-center rounded-[22%] bg-[#18181B] text-white ${t}`.trim(),style:{width:e,height:e,fontSize:Math.max(9,Math.round(e*.5)),fontWeight:650,lineHeight:1},"aria-hidden":`true`,children:[(0,G.jsx)(`span`,{style:{alignSelf:`center`},children:`Q`}),(0,G.jsx)(`span`,{style:{alignSelf:`center`,width:n,height:n,marginLeft:Math.max(0,Math.round(e*.03)),borderRadius:`50%`,background:`#22D3EE`}})]})}function Tce({size:e=16,className:t=``}){return(0,G.jsx)(`span`,{className:`inline-flex shrink-0 items-center justify-center rounded-[22%] bg-[#1a1a1a] text-white ${t}`.trim(),style:{width:e,height:e,fontSize:Math.max(9,Math.round(e*.55)),fontWeight:650,lineHeight:1},"aria-hidden":`true`,children:`T`})}var Ece=`/assets/workbuddy-mark-D1Gu2IKl.svg`;function Dce({size:e=16,className:t=``}){return(0,G.jsx)(`img`,{src:Ece,alt:``,width:e,height:e,className:`block shrink-0 ${t}`.trim(),draggable:!1})}function Oce({size:e=16,className:t=``}){return(0,G.jsx)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,className:`block shrink-0 text-foreground ${t}`.trim(),"aria-hidden":`true`,children:(0,G.jsx)(`path`,{fill:`currentColor`,fillRule:`evenodd`,d:`M11.991 23.503a.24.24 0 0 0-.244.248a.24.24 0 0 0 .244.249a.24.24 0 0 0 .245-.249a.24.24 0 0 0-.22-.247zM9.671 5.365a1.697 1.697 0 0 1 1.099 2.132l-.071.172l-.016.04l-.018.054c-.07.16-.104.32-.104.498c-.035.71.47 1.279 1.186 1.314h.366c1.309.053 2.338 1.173 2.286 2.523c-.052 1.332-1.152 2.38-2.478 2.327h-.174c-.715.018-1.274.64-1.239 1.368c0 .124.018.23.053.337c.209.373.54.658.96.8c.75.23 1.517-.125 1.9-.782l.018-.035c.402-.64 1.17-.96 1.92-.711c.854.284 1.378 1.226 1.099 2.167a1.66 1.66 0 0 1-2.077 1.102a1.7 1.7 0 0 1-.907-.711l-.017-.035c-.2-.323-.463-.58-.851-.711l-.056-.018a1.646 1.646 0 0 0-1.954.746a1.66 1.66 0 0 1-1.065.764a1.677 1.677 0 0 1-1.989-1.279c-.209-.906.332-1.83 1.257-2.043a1.5 1.5 0 0 1 .296-.035h.018c.68-.071 1.151-.622 1.116-1.333a1.3 1.3 0 0 0-.227-.693a2.5 2.5 0 0 1-.366-1.403a2.4 2.4 0 0 1 .366-1.208c.14-.195.21-.444.227-.693c.018-.71-.506-1.261-1.186-1.332l-.07-.018a1.4 1.4 0 0 1-.299-.07l-.05-.019a1.7 1.7 0 0 1-1.047-2.114a1.68 1.68 0 0 1 2.094-1.101m-5.575 10.11c.26-.264.639-.367.994-.27s.633.379.728.74c.095.362-.007.748-.267 1.013c-.402.41-1.053.41-1.455 0a1.06 1.06 0 0 1 0-1.482zm14.845-.294c.359-.09.738.024.992.297c.254.274.344.665.237 1.025s-.396.634-.756.718c-.551.128-1.1-.22-1.23-.781a1.05 1.05 0 0 1 .757-1.26zm-.064-4.39c.314.32.49.753.49 1.206s-.176.886-.49 1.206c-.315.32-.74.5-1.185.5c-.444 0-.87-.18-1.184-.5a1.727 1.727 0 0 1 0-2.412a1.654 1.654 0 0 1 2.369 0m-11.243.163c.364.484.447 1.128.218 1.691a1.665 1.665 0 0 1-2.188.923c-.855-.36-1.26-1.358-.907-2.228a1.68 1.68 0 0 1 1.33-1.038a1.66 1.66 0 0 1 1.547.652m11.545-4.221c.368 0 .708.2.892.524s.184.724 0 1.048a1.03 1.03 0 0 1-.892.524a1.04 1.04 0 0 1-1.03-1.048a1.04 1.04 0 0 1 1.03-1.048m-14.358 0c.368 0 .707.2.891.524s.184.724 0 1.048a1.03 1.03 0 0 1-.891.524a1.04 1.04 0 0 1-1.03-1.048c0-.579.461-1.048 1.03-1.048m10.031-1.475c.925 0 1.675.764 1.675 1.706s-.75 1.705-1.675 1.705s-1.674-.763-1.674-1.705s.75-1.706 1.674-1.706m-2.626-.684c.362-.082.653-.356.761-.718a1.06 1.06 0 0 0-.238-1.028a1.02 1.02 0 0 0-.996-.294c-.547.14-.881.7-.752 1.257c.13.558.675.907 1.225.783m0 16.876c.359-.087.644-.36.75-.72a1.06 1.06 0 0 0-.237-1.019a1.02 1.02 0 0 0-.985-.301a1.04 1.04 0 0 0-.762.717c-.108.361-.017.754.239 1.028c.245.263.606.377.953.305zM17.19 3.5a.63.63 0 0 0 .628-.64a.63.63 0 0 0-.628-.64a.63.63 0 0 0-.628.64c0 .355.28.64.628.64m-10.38 0a.63.63 0 0 0 .628-.64c0-.355-.28-.64-.628-.64a.63.63 0 0 0-.628.64c0 .355.279.64.628.64m-5.182 7.852a.63.63 0 0 0-.628.64c0 .354.28.639.628.639a.63.63 0 0 0 .627-.606l.001-.034a.62.62 0 0 0-.628-.64zm5.182 9.13a.63.63 0 0 0-.628.64c0 .355.279.64.628.64a.63.63 0 0 0 .628-.64c0-.355-.28-.64-.628-.64m10.38.018a.63.63 0 0 0-.628.64c0 .355.28.64.628.64a.63.63 0 0 0 .628-.64a.63.63 0 0 0-.628-.64m5.182-9.148a.63.63 0 0 0-.628.64c0 .354.279.639.628.639a.63.63 0 0 0 .628-.64c0-.355-.28-.64-.628-.64zm-.384-4.992a.24.24 0 0 0 .244-.249a.24.24 0 0 0-.244-.249a.24.24 0 0 0-.244.249c0 .142.122.249.244.249M11.991.497a.24.24 0 0 0 .245-.248A.24.24 0 0 0 11.99 0a.24.24 0 0 0-.244.249c0 .133.108.236.223.247zM2.011 6.36a.24.24 0 0 0 .245-.249a.24.24 0 0 0-.244-.249a.24.24 0 0 0-.244.249a.24.24 0 0 0 .244.249zm0 11.263a.24.24 0 0 0-.243.248a.24.24 0 0 0 .244.249a.24.24 0 0 0 .244-.249a.25.25 0 0 0-.244-.248zm19.995-.018a.24.24 0 0 0-.245.248a.24.24 0 0 0 .245.25a.24.24 0 0 0 .244-.25a.25.25 0 0 0-.244-.248z`})})}function MH({provider:e,size:t=16,className:n=``}){let r=String(e||``).toLowerCase();return r===`workbuddy`?(0,G.jsx)(Dce,{size:t,className:n}):r===`trae`?(0,G.jsx)(Tce,{size:t,className:n}):r===`devin`?(0,G.jsx)(yce,{size:t,className:n}):r===`command`?(0,G.jsx)(_ce,{size:t,className:n}):r===`codex`?(0,G.jsx)(vce,{size:t,className:n}):r===`zhipu`?(0,G.jsx)(Oce,{size:t,className:n}):r===`qwenwork`?(0,G.jsx)(wce,{size:t,className:n}):r===`kimi`?(0,G.jsx)(bce,{size:t,className:n}):r===`meta`||r===`muse`?(0,G.jsx)(xce,{size:t,className:n}):(0,G.jsx)(Cce,{size:t,className:n})}var kce=(0,v.lazy)(()=>C(()=>import(`./LiveSparkline-C2h2mKvg.js`).then(e=>({default:e.LiveSparkline})),[]));function Ace({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,G.jsxs)(G.Fragment,{children:[n(`liveConcurrency`),(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-2`,children:[(0,G.jsxs)(`span`,{className:`mono tabular text-body font-semibold ${s?`text-warning`:`text-foreground`}`,children:[i??`—`,(0,G.jsxs)(`span`,{className:`font-normal text-muted`,children:[`/`,e?a:`—`]})]}),(0,G.jsx)(`span`,{className:`inline-block h-[3px] w-12 overflow-hidden rounded-[2px] bg-separator`,children:(0,G.jsx)(`span`,{className:`block h-full ${s?`bg-warning`:`bg-foreground/60`}`,style:{width:`${Math.min(100,o*100)}%`}})})]})]});return(0,G.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,G.jsx)(`span`,{className:`inline-flex items-center`,children:(0,G.jsx)(`span`,{className:`status-dot`,"data-state":i==null?``:s?`warn`:i>0?`ok`:``})}),r?(0,G.jsx)(`button`,{type:`button`,"data-testid":`live-strip-concurrency`,onClick:r,className:`inline-flex flex-col gap-1 rounded-md 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,G.jsx)(`span`,{className:`inline-flex flex-col gap-1 sm:flex-row sm:items-center sm:gap-2`,children:c}),(0,G.jsxs)(`span`,{className:`inline-flex flex-col gap-1 sm:flex-row sm:items-center sm:gap-2`,children:[n(`liveRpm`),(0,G.jsx)(`span`,{className:`mono tabular text-body font-semibold text-foreground`,children:e?.rpm??`—`})]}),(0,G.jsxs)(`span`,{className:`inline-flex flex-col gap-1 sm:flex-row sm:items-center sm:gap-2`,children:[n(`liveTrace`),(0,G.jsx)(v.Suspense,{fallback:(0,G.jsx)(`span`,{className:`inline-block h-6 w-[120px]`}),children:(0,G.jsx)(kce,{samples:t,capacity:a,label:n(`liveTrace`)})})]})]})}var jce=/[achlmqstvz]|(-?\d*\.?\d*(?:e[\-+]?\d+)?)[0-9]/gi,Mce=/[\+\-]?\d*\.?\d+e[\+\-]?\d+/gi,Nce=Math.PI/180;180/Math.PI;var NH=Math.sin,PH=Math.cos,FH=Math.abs,IH=Math.sqrt,Pce=function(e){return typeof e==`number`},LH=1e5,RH=function(e){return Math.round(e*LH)/LH||0},zH=function(e){return e.closed=Math.abs(e[0]-e[e.length-2])<.001&&Math.abs(e[1]-e[e.length-1])<.001};function Fce(e,t,n,r,i,a,o){for(var s=e.length,c,l,u,d,f;--s>-1;)for(c=e[s],l=c.length,u=0;u1&&(n=IH(b)*n,r=IH(b)*r);var x=n*n,S=r*r,C=(x*S-x*y-S*v)/(x*y+S*v);C<0&&(C=0);var w=(a===o?-1:1)*IH(C),T=w*(n*_/r),E=w*-(r*g/n),D=(e+s)/2,O=(t+c)/2,k=D+(u*T-d*E),A=O+(d*T+u*E),j=(g-T)/n,M=(_-E)/r,N=(-g-T)/n,P=(-_-E)/r,F=j*j+M*M,I=(M<0?-1:1)*Math.acos(j/IH(F)),L=(j*P-M*N<0?-1:1)*Math.acos((j*N+M*P)/IH(F*(N*N+P*P)));isNaN(L)&&(L=f),!o&&L>0?L-=p:o&&L<0&&(L+=p),I%=p,L%=p;var R=Math.ceil(FH(L)/(p/4)),z=[],B=L/R,V=4/3*NH(B/2)/(1+PH(B/2)),H=u*n,ee=d*n,te=d*-r,ne=u*r,re;for(re=0;re-1e-4?0:t}).match(jce)||[],n=[],r=0,i=0,a=2/3,o=t.length,s=0,c=`ERROR: malformed path: `+e,l,u,d,f,p,m,h,g,_,v,y,b,x,S,C,w=function(e,t,n,r){v=(n-e)/3,y=(r-t)/3,h.push(e+v,t+y,n-v,r-y,n,r)};if(!e||!isNaN(t[0])||isNaN(t[1]))return console.log(c),n;for(l=0;l.5||FH(i-f)>.5)&&(w(r,i,d,f),p===`L`&&(l+=2)),r=d,i=f;else if(p===`A`){if(S=t[l+4],C=t[l+5],v=t[l+6],y=t[l+7],u=7,S.length>1&&(S.length<3?(y=v,v=C,u--):(y=C,v=S.substr(2),u-=2),C=S.charAt(1),S=S.charAt(0)),b=Ice(r,i,+t[l+1],+t[l+2],+t[l+3],+S,+C,(m?r:0)+v*1,(m?i:0)+y*1),l+=u,b)for(u=0;ul*(w*w+T*T)&&(O=u.length,e(t,n,f,p,v,y,S,C,l,u,d),e(S,C,b,x,g,_,s,c,l,u,d+1+(u.length-O))),u},GH=function(){function e(e,t,n){VH||UH(),this.id=e,Bce&&this.setData(t,n)}var t=e.prototype;return t.setData=function(e,t){t||={},e||=`0,0,1,1`;var n=e.match(Vce),r=1,i=[],a=[],o=t.precision||1,s=o<=1,c,l,u,d,f,p,m,h,g;if(this.data=e,(Hce.test(e)||~e.indexOf(`M`)&&e.indexOf(`C`)<0)&&(n=Lce(e)[0]),c=n.length,c===4)n.unshift(0,0),n.push(1,1),c=8;else if((c-2)%6)throw`Invalid CustomEase`;for((+n[0]!=0||+n[c-2]!=1)&&Wce(n,t.height,t.originY),this.segment=n,d=2;dh.x||h.y!==m.y&&h.x===m.x||m===h)&&m.x<=1?(h.cx=m.x-h.x,h.cy=m.y-h.y,h.n=m,h.nx=m.x,s&&d>1&&Math.abs(h.cy/h.cx-i[d-2].cy/i[d-2].cx)>2&&(s=0),h.cxh||u===m-1)&&(c.push(g,_),l=(p-_)/(f-g)),g=f,_=p;c=`M`+c.join(`,`)}return s&&s.setAttribute(`d`,c),c},e}();GH.version=`3.15.0`,GH.headless=!0,HH()&&BH.registerPlugin(GH);var Kce=`dangerouslySetInnerHTML.onCopy.onCopyCapture.onCut.onCutCapture.onPaste.onPasteCapture.onCompositionEnd.onCompositionEndCapture.onCompositionStart.onCompositionStartCapture.onCompositionUpdate.onCompositionUpdateCapture.onFocus.onFocusCapture.onBlur.onBlurCapture.onChange.onChangeCapture.onBeforeInput.onBeforeInputCapture.onInput.onInputCapture.onReset.onResetCapture.onSubmit.onSubmitCapture.onInvalid.onInvalidCapture.onLoad.onLoadCapture.onError.onErrorCapture.onKeyDown.onKeyDownCapture.onKeyPress.onKeyPressCapture.onKeyUp.onKeyUpCapture.onAbort.onAbortCapture.onCanPlay.onCanPlayCapture.onCanPlayThrough.onCanPlayThroughCapture.onDurationChange.onDurationChangeCapture.onEmptied.onEmptiedCapture.onEncrypted.onEncryptedCapture.onEnded.onEndedCapture.onLoadedData.onLoadedDataCapture.onLoadedMetadata.onLoadedMetadataCapture.onLoadStart.onLoadStartCapture.onPause.onPauseCapture.onPlay.onPlayCapture.onPlaying.onPlayingCapture.onProgress.onProgressCapture.onRateChange.onRateChangeCapture.onSeeked.onSeekedCapture.onSeeking.onSeekingCapture.onStalled.onStalledCapture.onSuspend.onSuspendCapture.onTimeUpdate.onTimeUpdateCapture.onVolumeChange.onVolumeChangeCapture.onWaiting.onWaitingCapture.onAuxClick.onAuxClickCapture.onClick.onClickCapture.onContextMenu.onContextMenuCapture.onDoubleClick.onDoubleClickCapture.onDrag.onDragCapture.onDragEnd.onDragEndCapture.onDragEnter.onDragEnterCapture.onDragExit.onDragExitCapture.onDragLeave.onDragLeaveCapture.onDragOver.onDragOverCapture.onDragStart.onDragStartCapture.onDrop.onDropCapture.onMouseDown.onMouseDownCapture.onMouseEnter.onMouseLeave.onMouseMove.onMouseMoveCapture.onMouseOut.onMouseOutCapture.onMouseOver.onMouseOverCapture.onMouseUp.onMouseUpCapture.onSelect.onSelectCapture.onTouchCancel.onTouchCancelCapture.onTouchEnd.onTouchEndCapture.onTouchMove.onTouchMoveCapture.onTouchStart.onTouchStartCapture.onPointerDown.onPointerDownCapture.onPointerMove.onPointerMoveCapture.onPointerUp.onPointerUpCapture.onPointerCancel.onPointerCancelCapture.onPointerEnter.onPointerEnterCapture.onPointerLeave.onPointerLeaveCapture.onPointerOver.onPointerOverCapture.onPointerOut.onPointerOutCapture.onGotPointerCapture.onGotPointerCaptureCapture.onLostPointerCapture.onLostPointerCaptureCapture.onScroll.onScrollCapture.onWheel.onWheelCapture.onAnimationStart.onAnimationStartCapture.onAnimationEnd.onAnimationEndCapture.onAnimationIteration.onAnimationIterationCapture.onTransitionEnd.onTransitionEndCapture`.split(`.`);function KH(e){return typeof e==`string`&&Kce.includes(e)}var qce=new Set(`aria-activedescendant.aria-atomic.aria-autocomplete.aria-busy.aria-checked.aria-colcount.aria-colindex.aria-colspan.aria-controls.aria-current.aria-describedby.aria-details.aria-disabled.aria-errormessage.aria-expanded.aria-flowto.aria-haspopup.aria-hidden.aria-invalid.aria-keyshortcuts.aria-label.aria-labelledby.aria-level.aria-live.aria-modal.aria-multiline.aria-multiselectable.aria-orientation.aria-owns.aria-placeholder.aria-posinset.aria-pressed.aria-readonly.aria-relevant.aria-required.aria-roledescription.aria-rowcount.aria-rowindex.aria-rowspan.aria-selected.aria-setsize.aria-sort.aria-valuemax.aria-valuemin.aria-valuenow.aria-valuetext.className.color.height.id.lang.max.media.method.min.name.style.target.width.role.tabIndex.accentHeight.accumulate.additive.alignmentBaseline.allowReorder.alphabetic.amplitude.arabicForm.ascent.attributeName.attributeType.autoReverse.azimuth.baseFrequency.baselineShift.baseProfile.bbox.begin.bias.by.calcMode.capHeight.clip.clipPath.clipPathUnits.clipRule.colorInterpolation.colorInterpolationFilters.colorProfile.colorRendering.contentScriptType.contentStyleType.cursor.cx.cy.d.decelerate.descent.diffuseConstant.direction.display.divisor.dominantBaseline.dur.dx.dy.edgeMode.elevation.enableBackground.end.exponent.externalResourcesRequired.fill.fillOpacity.fillRule.filter.filterRes.filterUnits.floodColor.floodOpacity.focusable.fontFamily.fontSize.fontSizeAdjust.fontStretch.fontStyle.fontVariant.fontWeight.format.from.fx.fy.g1.g2.glyphName.glyphOrientationHorizontal.glyphOrientationVertical.glyphRef.gradientTransform.gradientUnits.hanging.horizAdvX.horizOriginX.href.ideographic.imageRendering.in2.in.intercept.k1.k2.k3.k4.k.kernelMatrix.kernelUnitLength.kerning.keyPoints.keySplines.keyTimes.lengthAdjust.letterSpacing.lightingColor.limitingConeAngle.local.markerEnd.markerHeight.markerMid.markerStart.markerUnits.markerWidth.mask.maskContentUnits.maskUnits.mathematical.mode.numOctaves.offset.opacity.operator.order.orient.orientation.origin.overflow.overlinePosition.overlineThickness.paintOrder.panose1.pathLength.patternContentUnits.patternTransform.patternUnits.pointerEvents.pointsAtX.pointsAtY.pointsAtZ.preserveAlpha.preserveAspectRatio.primitiveUnits.r.radius.refX.refY.renderingIntent.repeatCount.repeatDur.requiredExtensions.requiredFeatures.restart.result.rotate.rx.ry.seed.shapeRendering.slope.spacing.specularConstant.specularExponent.speed.spreadMethod.startOffset.stdDeviation.stemh.stemv.stitchTiles.stopColor.stopOpacity.strikethroughPosition.strikethroughThickness.string.stroke.strokeDasharray.strokeDashoffset.strokeLinecap.strokeLinejoin.strokeMiterlimit.strokeOpacity.strokeWidth.surfaceScale.systemLanguage.tableValues.targetX.targetY.textAnchor.textDecoration.textLength.textRendering.to.transform.u1.u2.underlinePosition.underlineThickness.unicode.unicodeBidi.unicodeRange.unitsPerEm.vAlphabetic.values.vectorEffect.version.vertAdvY.vertOriginX.vertOriginY.vHanging.vIdeographic.viewTarget.visibility.vMathematical.widths.wordSpacing.writingMode.x1.x2.x.xChannelSelector.xHeight.xlinkActuate.xlinkArcrole.xlinkHref.xlinkRole.xlinkShow.xlinkTitle.xlinkType.xmlBase.xmlLang.xmlns.xmlnsXlink.xmlSpace.y1.y2.y.yChannelSelector.z.zoomAndPan.ref.key.angle`.split(`.`));function qH(e){return typeof e==`string`&&qce.has(e)}function JH(e){return typeof e==`string`&&e.startsWith(`data-`)}function YH(e){if(typeof e!=`object`||!e)return{};var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(qH(n)||JH(n))&&(t[n]=e[n]);return t}function XH(e){if(e==null)return null;if((0,v.isValidElement)(e)&&typeof e.props==`object`&&e.props!==null){var t=e.props;return YH(t)}return typeof e==`object`&&!Array.isArray(e)?YH(e):null}function ZH(e){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(qH(n)||JH(n)||KH(n))&&(t[n]=e[n]);return t}function Jce(e){return e==null?null:(0,v.isValidElement)(e)?ZH(e.props):typeof e==`object`&&!Array.isArray(e)?ZH(e):null}var Yce=[`children`,`width`,`height`,`viewBox`,`className`,`style`,`title`,`desc`];function QH(){return QH=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var n=e.children,r=e.width,i=e.height,a=e.viewBox,o=e.className,s=e.style,c=e.title,l=e.desc,u=Xce(e,Yce),d=a||{width:r,height:i,x:0,y:0},f=xs(`recharts-surface`,o);return v.createElement(`svg`,QH({},ZH(u),{className:f,width:r,height:i,style:s,viewBox:`${d.x} ${d.y} ${d.width} ${d.height}`,ref:t}),v.createElement(`title`,null,c),v.createElement(`desc`,null,l),n)}),Qce=[`children`,`className`];function eU(){return eU=Object.assign?Object.assign.bind():function(e){for(var t=1;t{var n=e.children,r=e.className,i=$ce(e,Qce),a=xs(`recharts-layer`,r);return v.createElement(`g`,eU({className:a},ZH(i),{ref:t}),n)});function nU(e){return e===`__proto__`}var tle=/\.|(\[(?:[^[\]]*|(["'])(?:(?!\2)[^\\]|\\.)*?\2)\])/;function rU(e){switch(typeof e){case`number`:case`symbol`:return!1;case`string`:return e===``||e.startsWith(`.`)||e.endsWith(`.`)?!1:tle.test(e);default:return!1}}function iU(e){return typeof e==`string`||typeof e==`symbol`?e:Object.is(e?.valueOf?.(),-0)?`-0`:String(e)}function aU(e){return typeof e==`symbol`||e instanceof Symbol}function nle(e){return e==null?``:oU(e)}function oU(e){if(typeof e==`string`)return e;if(Array.isArray(e))return e.map(oU).join(`,`);if(aU(e))return e.toString();let t=e+``;return t===`0`&&Object.is(Number(e),-0)?`-0`:t}function sU(e){if(Array.isArray(e))return e.map(iU);if(typeof e==`symbol`)return[e];e=nle(e);let t=[],n=e.length;if(n===0)return t;let r=0,i=``,a=``,o=!1,s=!1,c=/^-?\d+(?:\.\d+)?$/;for(e.charCodeAt(0)===46&&t.push(``);r1&&arguments[1]!==void 0?arguments[1]:ile),n=Math.round(e*t)/t;return Object.is(n,-0)?0:n}function uU(e){var t=[...arguments].slice(1);return e.reduce((e,n,r)=>{var i=t[r-1];return typeof i==`string`?e+i+n:i===void 0?e+n:e+lU(i)+n},``)}var dU=e=>e===0?0:e>0?1:-1,fU=e=>typeof e==`number`&&e!=+e,pU=e=>typeof e==`string`&&e.length>1&&e.indexOf(`%`)===e.length-1,mU=e=>(typeof e==`number`||e instanceof Number)&&!fU(e),hU=e=>mU(e)||typeof e==`string`,ale=0,gU=e=>{var t=++ale;return`${e||``}${t}`},_U=function(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0,r=arguments.length>3&&arguments[3]!==void 0&&arguments[3];if(!mU(e)&&typeof e!=`string`)return n;var i;if(pU(e)){if(t==null)return n;var a=e.indexOf(`%`);i=t*parseFloat(e.slice(0,a))/100}else i=+e;return fU(i)&&(i=n),r&&t!=null&&i>t&&(i=t),i},vU=e=>{if(!Array.isArray(e))return!1;for(var t=e.length,n={},r=0;re&&(typeof t==`function`?t(e):cU(e,t))===n)}var xU=e=>e==null,SU=e=>xU(e)?e:`${e.charAt(0).toUpperCase()}${e.slice(1)}`;function CU(e){return e!=null}function wU(){}function TU(e){if(e)return{x:e.x,y:e.y,upperWidth:`upperWidth`in e?e.upperWidth:e.width,lowerWidth:`lowerWidth`in e?e.lowerWidth:e.width,width:e.width,height:e.height}}function EU(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 DU(e){for(var t=1;t{var t=e.viewBox,n=e.position,r=e.offset,i=r===void 0?0:r,a=e.parentViewBox,o=e.clamp,s=TU(t),c=s.x,l=s.y,u=s.height,d=s.upperWidth,f=s.lowerWidth,p=c,m=c+(d-f)/2,h=(p+m)/2,g=(d+f)/2,_=p+d/2,v=u>=0?1:-1,y=v*i,b=v>0?`end`:`start`,x=v>0?`start`:`end`,S=d>=0?1:-1,C=S*i,w=S>0?`end`:`start`,T=S>0?`start`:`end`,E=a;if(n===`top`){var D={x:p+d/2,y:l-y,horizontalAnchor:`middle`,verticalAnchor:b};return o&&E&&(D.height=Math.max(l-E.y,0),D.width=d),D}if(n===`bottom`){var O={x:m+f/2,y:l+u+y,horizontalAnchor:`middle`,verticalAnchor:x};return o&&E&&(O.height=Math.max(E.y+E.height-(l+u),0),O.width=f),O}if(n===`left`){var k={x:h-C,y:l+u/2,horizontalAnchor:w,verticalAnchor:`middle`};return o&&E&&(k.width=Math.max(k.x-E.x,0),k.height=u),k}if(n===`right`){var A={x:h+g+C,y:l+u/2,horizontalAnchor:T,verticalAnchor:`middle`};return o&&E&&(A.width=Math.max(E.x+E.width-A.x,0),A.height=u),A}var j=o&&E?{width:g,height:u}:{};return n===`insideLeft`?DU({x:h+C,y:l+u/2,horizontalAnchor:T,verticalAnchor:`middle`},j):n===`insideRight`?DU({x:h+g-C,y:l+u/2,horizontalAnchor:w,verticalAnchor:`middle`},j):n===`insideTop`?DU({x:p+d/2,y:l+y,horizontalAnchor:`middle`,verticalAnchor:x},j):n===`insideBottom`?DU({x:m+f/2,y:l+u-y,horizontalAnchor:`middle`,verticalAnchor:b},j):n===`insideTopLeft`?DU({x:p+C,y:l+y,horizontalAnchor:T,verticalAnchor:x},j):n===`insideTopRight`?DU({x:p+d-C,y:l+y,horizontalAnchor:w,verticalAnchor:x},j):n===`insideBottomLeft`?DU({x:m+C,y:l+u-y,horizontalAnchor:T,verticalAnchor:b},j):n===`insideBottomRight`?DU({x:m+f-C,y:l+u-y,horizontalAnchor:w,verticalAnchor:b},j):n&&typeof n==`object`&&(mU(n.x)||pU(n.x))&&(mU(n.y)||pU(n.y))?DU({x:c+_U(n.x,g),y:l+_U(n.y,u),horizontalAnchor:`end`,verticalAnchor:`end`},j):DU({x:_,y:l+u/2,horizontalAnchor:`middle`,verticalAnchor:`middle`},j)},ule=[`top`,`left`,`right`,`bottom`];function dle(e){return e==null?!1:typeof e==`object`||ule.includes(e)}var fle=(0,v.createContext)(null);function OU(e){return function(){return e}}var kU=Math.PI,AU=2*kU,jU=1e-6,ple=AU-jU;function MU(e){this._+=e[0];for(let t=1,n=e.length;t=0))throw Error(`invalid digits: ${e}`);if(t>15)return MU;let n=10**t;return function(e){this._+=e[0];for(let t=1,r=e.length;tjU){if(!(Math.abs(u*s-c*l)>jU)||!i)this._append`L${this._x1=e},${this._y1=t}`;else{let f=n-a,p=r-o,m=s*s+c*c,h=f*f+p*p,g=Math.sqrt(m),_=Math.sqrt(d),v=i*Math.tan((kU-Math.acos((m+d-h)/(2*g*_)))/2),y=v/_,b=v/g;Math.abs(y-1)>jU&&this._append`L${e+y*l},${t+y*u}`,this._append`A${i},${i},0,0,${+(u*f>l*p)},${this._x1=e+b*s},${this._y1=t+b*c}`}}}arc(e,t,n,r,i,a){if(e=+e,t=+t,n=+n,a=!!a,n<0)throw Error(`negative radius: ${n}`);let o=n*Math.cos(r),s=n*Math.sin(r),c=e+o,l=t+s,u=1^a,d=a?r-i:i-r;this._x1===null?this._append`M${c},${l}`:(Math.abs(this._x1-c)>jU||Math.abs(this._y1-l)>jU)&&this._append`L${c},${l}`,n&&(d<0&&(d=d%AU+AU),d>ple?this._append`A${n},${n},0,1,${u},${e-o},${t-s}A${n},${n},0,1,${u},${this._x1=c},${this._y1=l}`:d>jU&&this._append`A${n},${n},0,${+(d>=kU)},${u},${this._x1=e+n*Math.cos(i)},${this._y1=t+n*Math.sin(i)}`)}rect(e,t,n,r){this._append`M${this._x0=this._x1=+e},${this._y0=this._y1=+t}h${n=+n}v${+r}h${-n}Z`}toString(){return this._}};NU.prototype;function PU(e){let t=3;return e.digits=function(n){if(!arguments.length)return t;if(n==null)t=null;else{let e=Math.floor(n);if(!(e>=0))throw RangeError(`invalid digits: ${n}`);t=e}return e},()=>new NU(t)}Array.prototype.slice;function FU(e){return typeof e==`object`&&`length`in e?e:Array.from(e)}function IU(e){this._context=e}IU.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:this._context.lineTo(e,t)}}};function LU(e){return new IU(e)}function RU(e){return e[0]}function zU(e){return e[1]}function BU(e,t){var n=OU(!0),r=null,i=LU,a=null,o=PU(s);e=typeof e==`function`?e:e===void 0?RU:OU(e),t=typeof t==`function`?t:t===void 0?zU:OU(t);function s(s){var c,l=(s=FU(s)).length,u,d=!1,f;for(r??(a=i(f=o())),c=0;c<=l;++c)!(c=d;--f)s.point(_[f],v[f]);s.lineEnd(),s.areaEnd()}}h&&(_[u]=+e(m,u,l),v[u]=+t(m,u,l),s.point(r?+r(m,u,l):_[u],n?+n(m,u,l):v[u]))}if(g)return s=null,g+``||null}function u(){return BU().defined(i).curve(o).context(a)}return l.x=function(t){return arguments.length?(e=typeof t==`function`?t:OU(+t),r=null,l):e},l.x0=function(t){return arguments.length?(e=typeof t==`function`?t:OU(+t),l):e},l.x1=function(e){return arguments.length?(r=e==null?null:typeof e==`function`?e:OU(+e),l):r},l.y=function(e){return arguments.length?(t=typeof e==`function`?e:OU(+e),n=null,l):t},l.y0=function(e){return arguments.length?(t=typeof e==`function`?e:OU(+e),l):t},l.y1=function(e){return arguments.length?(n=e==null?null:typeof e==`function`?e:OU(+e),l):n},l.lineX0=l.lineY0=function(){return u().x(e).y(t)},l.lineY1=function(){return u().x(e).y(n)},l.lineX1=function(){return u().x(r).y(t)},l.defined=function(e){return arguments.length?(i=typeof e==`function`?e:OU(!!e),l):i},l.curve=function(e){return arguments.length?(o=e,a!=null&&(s=o(a)),l):o},l.context=function(e){return arguments.length?(e==null?a=s=null:s=o(a=e),l):a},l}var HU=class{constructor(e,t){this._context=e,this._x=t}areaStart(){this._line=0}areaEnd(){this._line=NaN}lineStart(){this._point=0}lineEnd(){(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line}point(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:this._x?this._context.bezierCurveTo(this._x0=(this._x0+e)/2,this._y0,this._x0,t,e,t):this._context.bezierCurveTo(this._x0,this._y0=(this._y0+t)/2,e,this._y0,e,t)}this._x0=e,this._y0=t}};function hle(e){return new HU(e,!0)}function gle(e){return new HU(e,!1)}function UU(){}function WU(e,t,n){e._context.bezierCurveTo((2*e._x0+e._x1)/3,(2*e._y0+e._y1)/3,(e._x0+2*e._x1)/3,(e._y0+2*e._y1)/3,(e._x0+4*e._x1+t)/6,(e._y0+4*e._y1+n)/6)}function GU(e){this._context=e}GU.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){switch(this._point){case 3:WU(this,this._x1,this._y1);case 2:this._context.lineTo(this._x1,this._y1)}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,this._context.lineTo((5*this._x0+this._x1)/6,(5*this._y0+this._y1)/6);default:WU(this,e,t)}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function _le(e){return new GU(e)}function KU(e){this._context=e}KU.prototype={areaStart:UU,areaEnd:UU,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._y0=this._y1=this._y2=this._y3=this._y4=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:this._context.moveTo(this._x2,this._y2),this._context.closePath();break;case 2:this._context.moveTo((this._x2+2*this._x3)/3,(this._y2+2*this._y3)/3),this._context.lineTo((this._x3+2*this._x2)/3,(this._y3+2*this._y2)/3),this._context.closePath();break;case 3:this.point(this._x2,this._y2),this.point(this._x3,this._y3),this.point(this._x4,this._y4)}},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._x2=e,this._y2=t;break;case 1:this._point=2,this._x3=e,this._y3=t;break;case 2:this._point=3,this._x4=e,this._y4=t,this._context.moveTo((this._x0+4*this._x1+e)/6,(this._y0+4*this._y1+t)/6);break;default:WU(this,e,t)}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function vle(e){return new KU(e)}function qU(e){this._context=e}qU.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=NaN,this._point=0},lineEnd:function(){(this._line||this._line!==0&&this._point===3)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3;var n=(this._x0+4*this._x1+e)/6,r=(this._y0+4*this._y1+t)/6;this._line?this._context.lineTo(n,r):this._context.moveTo(n,r);break;case 3:this._point=4;default:WU(this,e,t)}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t}};function yle(e){return new qU(e)}function JU(e){this._context=e}JU.prototype={areaStart:UU,areaEnd:UU,lineStart:function(){this._point=0},lineEnd:function(){this._point&&this._context.closePath()},point:function(e,t){e=+e,t=+t,this._point?this._context.lineTo(e,t):(this._point=1,this._context.moveTo(e,t))}};function ble(e){return new JU(e)}function YU(e){return e<0?-1:1}function XU(e,t,n){var r=e._x1-e._x0,i=t-e._x1,a=(e._y1-e._y0)/(r||i<0&&-0),o=(n-e._y1)/(i||r<0&&-0),s=(a*i+o*r)/(r+i);return(YU(a)+YU(o))*Math.min(Math.abs(a),Math.abs(o),.5*Math.abs(s))||0}function ZU(e,t){var n=e._x1-e._x0;return n?(3*(e._y1-e._y0)/n-t)/2:t}function QU(e,t,n){var r=e._x0,i=e._y0,a=e._x1,o=e._y1,s=(a-r)/3;e._context.bezierCurveTo(r+s,i+s*t,a-s,o-s*n,a,o)}function $U(e){this._context=e}$U.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:QU(this,this._t0,ZU(this,this._t0))}(this._line||this._line!==0&&this._point===1)&&this._context.closePath(),this._line=1-this._line},point:function(e,t){var n=NaN;if(e=+e,t=+t,e!==this._x1||t!==this._y1){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;break;case 2:this._point=3,QU(this,ZU(this,n=XU(this,e,t)),n);break;default:QU(this,this._t0,n=XU(this,e,t))}this._x0=this._x1,this._x1=e,this._y0=this._y1,this._y1=t,this._t0=n}}};function eW(e){this._context=new tW(e)}(eW.prototype=Object.create($U.prototype)).point=function(e,t){$U.prototype.point.call(this,t,e)};function tW(e){this._context=e}tW.prototype={moveTo:function(e,t){this._context.moveTo(t,e)},closePath:function(){this._context.closePath()},lineTo:function(e,t){this._context.lineTo(t,e)},bezierCurveTo:function(e,t,n,r,i,a){this._context.bezierCurveTo(t,e,r,n,a,i)}};function xle(e){return new $U(e)}function Sle(e){return new eW(e)}function nW(e){this._context=e}nW.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x=[],this._y=[]},lineEnd:function(){var e=this._x,t=this._y,n=e.length;if(n){if(this._line?this._context.lineTo(e[0],t[0]):this._context.moveTo(e[0],t[0]),n===2)this._context.lineTo(e[1],t[1]);else for(var r=rW(e),i=rW(t),a=0,o=1;o=0;--t)i[t]=(o[t]-i[t+1])/a[t];for(a[n-1]=(e[n]+i[n-1])/2,t=0;t=0&&(this._t=1-this._t,this._line=1-this._line)},point:function(e,t){switch(e=+e,t=+t,this._point){case 0:this._point=1,this._line?this._context.lineTo(e,t):this._context.moveTo(e,t);break;case 1:this._point=2;default:if(this._t<=0)this._context.lineTo(this._x,t),this._context.lineTo(e,t);else{var n=this._x*(1-this._t)+e*this._t;this._context.lineTo(n,this._y),this._context.lineTo(n,t)}}this._x=e,this._y=t}};function wle(e){return new iW(e,.5)}function Tle(e){return new iW(e,0)}function Ele(e){return new iW(e,1)}function aW(e,t){if((o=e.length)>1)for(var n=1,r,i,a=e[t[0]],o,s=a.length;n=0;)n[t]=t;return n}function Dle(e,t){return e[t]}function Ole(e){let t=[];return t.key=e,t}function kle(){var e=OU([]),t=oW,n=aW,r=Dle;function i(i){var a=Array.from(e.apply(this,arguments),Ole),o,s=a.length,c=-1,l;for(let e of i)for(o=0,++c;o0){for(var n,r,i=0,a=e[0].length,o;i0){for(var n=0,r=e[t[0]],i,a=r.length;n0)||!((a=(i=e[t[0]]).length)>0))){for(var n=0,r=1,i,a,o;r`radius`in e&&`startAngle`in e&&`endAngle`in e,sW=(e,t)=>{if(!e||typeof e==`function`||typeof e==`boolean`)return null;var n=e;if((0,v.isValidElement)(e)&&(n=e.props),typeof n!=`object`&&typeof n!=`function`)return null;var r={};return Object.keys(n).forEach(e=>{KH(e)&&typeof n[e]==`function`&&(r[e]=t||(t=>n[e](n,t)))}),r},Ple=(e,t,n)=>r=>(e(t,n,r),null),Fle=(e,t,n)=>{if(e===null||typeof e!=`object`&&typeof e!=`function`)return null;var r=null;return Object.keys(e).forEach(i=>{var a=e[i];KH(i)&&typeof a==`function`&&(r||={},r[i]=Ple(a,t,n))}),r};function cW(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 Ile(e){for(var t=1;t(e[t]===void 0&&r[t]!==void 0&&(e[t]=r[t]),e),n)}function Ble(e){return Number.isSafeInteger(e)&&e>=0}function uW(e){return e!=null&&typeof e!=`function`&&Ble(e.length)}function dW(e){return Object.getOwnPropertySymbols(e).filter(t=>Object.prototype.propertyIsEnumerable.call(e,t))}function fW(e){return e==null?e===void 0?`[object Undefined]`:`[object Null]`:Object.prototype.toString.call(e)}var pW=`[object RegExp]`,mW=`[object String]`,hW=`[object Number]`,gW=`[object Boolean]`,Vle=`[object Arguments]`,_W=`[object Symbol]`,vW=`[object Date]`,yW=`[object Map]`,bW=`[object Set]`,xW=`[object Array]`,Hle=`[object Function]`,SW=`[object ArrayBuffer]`,CW=`[object Object]`,Ule=`[object Error]`,wW=`[object DataView]`,TW=`[object Uint8Array]`,EW=`[object Uint8ClampedArray]`,DW=`[object Uint16Array]`,OW=`[object Uint32Array]`,Wle=`[object BigUint64Array]`,kW=`[object Int8Array]`,AW=`[object Int16Array]`,jW=`[object Int32Array]`,Gle=`[object BigInt64Array]`,MW=`[object Float32Array]`,NW=`[object Float64Array]`,PW=typeof globalThis==`object`&&globalThis||typeof window==`object`&&window||typeof self==`object`&&self||typeof global==`object`&&global||(function(){return this})();function FW(e){return PW.Buffer!==void 0&&PW.Buffer.isBuffer(e)}function IW(e,t){return e===t||Number.isNaN(e)&&Number.isNaN(t)}function LW(e){return e!==null&&(typeof e==`object`||typeof e==`function`)}var Kle=/^(?:0|[1-9]\d*)$/;function RW(e,t=2**53-1){switch(typeof e){case`number`:return Number.isInteger(e)&&e>=0&&e{var t=d(),n=K_();function r(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var i=typeof Object.is==`function`?Object.is:r,a=n.useSyncExternalStore,o=t.useRef,s=t.useEffect,c=t.useMemo,l=t.useDebugValue;e.useSyncExternalStoreWithSelector=function(e,t,n,r,u){var d=o(null);if(d.current===null){var f={hasValue:!1,value:null};d.current=f}else f=d.current;d=c(function(){function e(e){if(!a){if(a=!0,o=e,e=r(e),u!==void 0&&f.hasValue){var t=f.value;if(u(t,e))return s=t}return s=e}if(t=s,i(o,e))return t;var n=r(e);return u!==void 0&&u(t,n)?(o=e,t):(o=e,s=n)}var a=!1,o,s,c=n===void 0?null:n;return[function(){return e(t())},c===null?void 0:function(){return e(c())}]},[t,n,r,u]);var p=a(e,d[0],d[1]);return s(function(){f.hasValue=!0,f.value=p},[p]),l(p),p}})),Jle=o(((e,t)=>{t.exports=qle()})),zW=(0,v.createContext)(null),Yle=Jle(),Xle=e=>e,BW=()=>{var e=(0,v.useContext)(zW);return e?e.store.dispatch:Xle},VW=()=>{},Zle=()=>VW,Qle=(e,t)=>e===t;function HW(e){var t=(0,v.useContext)(zW),n=(0,v.useMemo)(()=>t?t=>{if(t!=null)return e(t)}:VW,[t,e]);return(0,Yle.useSyncExternalStoreWithSelector)(t?t.subscription.addNestedSub:Zle,t?t.store.getState:VW,t?t.store.getState:VW,n,Qle)}function $le(e,t=`expected a function, instead received ${typeof e}`){if(typeof e!=`function`)throw TypeError(t)}function eue(e,t=`expected all items to be functions, instead received the following types: `){if(!e.every(e=>typeof e==`function`)){let n=e.map(e=>typeof e==`function`?`function ${e.name||`unnamed`}()`:typeof e).join(`, `);throw TypeError(`${t}[${n}]`)}}var UW=e=>Array.isArray(e)?e:[e];function tue(e){let t=Array.isArray(e[0])?e[0]:e;return eue(t,`createSelector expects all input-selectors to be functions, but received the following types: `),t}function nue(e,t){let n=[],{length:r}=e;for(let i=0;i`u`?rue:WeakRef,iue=0,GW=1;function KW(){return{s:iue,v:void 0,o:null,p:null}}function aue(e){return e instanceof WW?e.deref():e}function qW(e,t={}){let n=KW(),{resultEqualityCheck:r}=t,i,a=0;function o(){let t=n,{length:o}=arguments;for(let e=0,n=o;e{n=KW(),o.resetResultsCount()},o.resultsCount=()=>a,o.resetResultsCount=()=>{a=0},o}function oue(e,...t){let n=typeof e==`function`?{memoize:e,memoizeOptions:t}:e,r=(...e)=>{let t=0,r=0,i,a={},o=e.pop();typeof o==`object`&&(a=o,o=e.pop()),$le(o,`createSelector expects an output function after the inputs, but received: [${typeof o}]`);let{memoize:s,memoizeOptions:c=[],argsMemoize:l=qW,argsMemoizeOptions:u=[]}={...n,...a},d=UW(c),f=UW(u),p=tue(e),m=s(function(){return t++,o.apply(null,arguments)},...d),h=l(function(){r++;let e=nue(p,arguments);return i=m.apply(null,e),i},...f);return Object.assign(h,{resultFunc:o,memoizedResultFunc:m,dependencies:p,dependencyRecomputations:()=>r,resetDependencyRecomputations:()=>{r=0},lastResult:()=>i,recomputations:()=>t,resetRecomputations:()=>{t=0},memoize:s,argsMemoize:l})};return Object.assign(r,{withTypes:()=>r}),r}var $=oue(qW);function sue(e,t=1){let n=[],r=Math.floor(t),i=(e,t)=>{for(let a=0;a{if(e!==t){let r=YW(e),i=YW(t);if(r===i&&r===0){if(et)return n===`desc`?-1:1}return n===`desc`?i-r:r-i}return 0},lue=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,uue=/^\w*$/;function due(e,t){return Array.isArray(e)?!1:typeof e==`number`||typeof e==`boolean`||e==null||aU(e)?!0:typeof e==`string`&&(uue.test(e)||!lue.test(e))||t!=null&&Object.hasOwn(t,e)}function fue(e,t,n,r){if(e==null)return[];n=r?void 0:n,Array.isArray(e)||(e=uW(e)?Array.from(e):Object.values(e)),Array.isArray(t)||(t=t==null?[null]:[t]),t.length===0&&(t=[null]),Array.isArray(n)||(n=n==null?[]:[n]),n=n.map(e=>String(e));let i=(e,t)=>{let n=e,r=0;for(;r0&&r===t.length?n:void 0},a=(e,t)=>{if(e==null)return t;if(t!=null)return typeof e==`object`&&`key`in e?Object.hasOwn(t,e.key)?t[e.key]:i(t,e.path):typeof e==`function`?e(t):Array.isArray(e)?i(t,e):t[e]},o=t.map(e=>(Array.isArray(e)&&e.length===1&&(e=e[0]),e==null||typeof e==`function`||Array.isArray(e)||due(e)?e:{key:e,path:sU(e)}));return e.map(e=>({original:e,criteria:o.map(t=>a(t,e))})).slice().sort((e,t)=>{for(let r=0;re.original)}function XW(e,...t){let n=t.length;return n>1&&JW(e,t[0],t[1])?t=[]:n>2&&JW(t[0],t[1],t[2])&&(t=[t[0]]),fue(e,sue(t),[`asc`])}var ZW=e=>e.legend.settings,pue=e=>e.legend.size;$([e=>e.legend.payload,ZW],(e,t)=>{var n=t.itemSorter,r=e.flat(1);return n?XW(r,n):r});function QW(e){return`Minified Redux error #${e}; visit https://redux.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var $W=typeof Symbol==`function`&&Symbol.observable||`@@observable`,eG=()=>Math.random().toString(36).substring(7).split(``).join(`.`),tG={INIT:`@@redux/INIT${eG()}`,REPLACE:`@@redux/REPLACE${eG()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${eG()}`};function nG(e){if(typeof e!=`object`||!e)return!1;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t||Object.getPrototypeOf(e)===null}function rG(e,t,n){if(typeof e!=`function`)throw Error(QW(2));if(typeof t==`function`&&typeof n==`function`||typeof n==`function`&&typeof arguments[3]==`function`)throw Error(QW(0));if(typeof t==`function`&&n===void 0&&(n=t,t=void 0),n!==void 0){if(typeof n!=`function`)throw Error(QW(1));return n(rG)(e,t)}let r=e,i=t,a=new Map,o=a,s=0,c=!1;function l(){o===a&&(o=new Map,a.forEach((e,t)=>{o.set(t,e)}))}function u(){if(c)throw Error(QW(3));return i}function d(e){if(typeof e!=`function`)throw Error(QW(4));if(c)throw Error(QW(5));let t=!0;l();let n=s++;return o.set(n,e),function(){if(t){if(c)throw Error(QW(6));t=!1,l(),o.delete(n),a=null}}}function f(e){if(!nG(e))throw Error(QW(7));if(e.type===void 0)throw Error(QW(8));if(typeof e.type!=`string`)throw Error(QW(17));if(c)throw Error(QW(9));try{c=!0,i=r(i,e)}finally{c=!1}return(a=o).forEach(e=>{e()}),e}function p(e){if(typeof e!=`function`)throw Error(QW(10));r=e,f({type:tG.REPLACE})}function m(){let e=d;return{subscribe(t){if(typeof t!=`object`||!t)throw Error(QW(11));function n(){let e=t;e.next&&e.next(u())}return n(),{unsubscribe:e(n)}},[$W](){return this}}}return f({type:tG.INIT}),{dispatch:f,subscribe:d,getState:u,replaceReducer:p,[$W]:m}}function mue(e){Object.keys(e).forEach(t=>{let n=e[t];if(n(void 0,{type:tG.INIT})===void 0)throw Error(QW(12));if(n(void 0,{type:tG.PROBE_UNKNOWN_ACTION()})===void 0)throw Error(QW(13))})}function iG(e){let t=Object.keys(e),n={};for(let r=0;re:e.length===1?e[0]:e.reduce((e,t)=>(...n)=>e(t(...n)))}function hue(...e){return t=>(n,r)=>{let i=t(n,r),a=()=>{throw Error(QW(15))},o={getState:i.getState,dispatch:(e,...t)=>a(e,...t)};return a=aG(...e.map(e=>e(o)))(i.dispatch),{...i,dispatch:a}}}function oG(e){return nG(e)&&`type`in e&&typeof e.type==`string`}var sG=Symbol.for(`immer-nothing`),cG=Symbol.for(`immer-draftable`),lG=Symbol.for(`immer-state`);function uG(e,...t){throw Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`)}var dG=Object,fG=dG.getPrototypeOf,pG=`constructor`,mG=`prototype`,hG=`configurable`,gG=`enumerable`,_G=`writable`,vG=`value`,yG=e=>!!e&&!!e[lG];function bG(e){return e?SG(e)||OG(e)||!!e[cG]||!!e[pG]?.[cG]||kG(e)||AG(e):!1}var gue=dG[mG][pG].toString(),xG=new WeakMap;function SG(e){if(!e||!jG(e))return!1;let t=fG(e);if(t===null||t===dG[mG])return!0;let n=dG.hasOwnProperty.call(t,pG)&&t[pG];if(n===Object)return!0;if(!MG(n))return!1;let r=xG.get(n);return r===void 0&&(r=Function.toString.call(n),xG.set(n,r)),r===gue}function CG(e,t,n=!0){wG(e)===0?(n?Reflect.ownKeys(e):dG.keys(e)).forEach(n=>{t(n,e[n],e)}):e.forEach((n,r)=>t(r,n,e))}function wG(e){let t=e[lG];return t?t.type_:OG(e)?1:kG(e)?2:AG(e)?3:0}var TG=(e,t,n=wG(e))=>n===2?e.has(t):dG[mG].hasOwnProperty.call(e,t),EG=(e,t,n=wG(e))=>n===2?e.get(t):e[t],DG=(e,t,n,r=wG(e))=>{r===2?e.set(t,n):r===3?e.add(n):e[t]=n};function _ue(e,t){return e===t?e!==0||1/e==1/t:e!==e&&t!==t}var OG=Array.isArray,kG=e=>e instanceof Map,AG=e=>e instanceof Set,jG=e=>typeof e==`object`,MG=e=>typeof e==`function`,NG=e=>typeof e==`boolean`;function vue(e){let t=+e;return Number.isInteger(t)&&String(t)===e}var PG=e=>e.copy_||e.base_,FG=e=>e.modified_?e.copy_:e.base_;function IG(e,t){if(kG(e))return new Map(e);if(AG(e))return new Set(e);if(OG(e))return Array[mG].slice.call(e);let n=SG(e);if(t===!0||t===`class_only`&&!n){let t=dG.getOwnPropertyDescriptors(e);delete t[lG];let n=Reflect.ownKeys(t);for(let r=0;r1&&dG.defineProperties(e,{set:RG,add:RG,clear:RG,delete:RG}),dG.freeze(e),t&&CG(e,(e,t)=>{LG(t,!0)},!1),e)}function yue(){uG(2)}var RG={[vG]:yue};function zG(e){return e===null||!jG(e)||dG.isFrozen(e)}var BG=`MapSet`,VG=`Patches`,HG=`ArrayMethods`,UG={};function WG(e){let t=UG[e];return t||uG(0,e),t}var GG=e=>!!UG[e],KG,qG=()=>KG,bue=(e,t)=>({drafts_:[],parent_:e,immer_:t,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:GG(BG)?WG(BG):void 0,arrayMethodsPlugin_:GG(HG)?WG(HG):void 0});function JG(e,t){t&&(e.patchPlugin_=WG(VG),e.patches_=[],e.inversePatches_=[],e.patchListener_=t)}function YG(e){XG(e),e.drafts_.forEach(xue),e.drafts_=null}function XG(e){e===KG&&(KG=e.parent_)}var ZG=e=>KG=bue(KG,e);function xue(e){let t=e[lG];t.type_===0||t.type_===1?t.revoke_():t.revoked_=!0}function QG(e,t){t.unfinalizedDrafts_=t.drafts_.length;let n=t.drafts_[0];if(e!==void 0&&e!==n){n[lG].modified_&&(YG(t),uG(4)),bG(e)&&(e=$G(t,e));let{patchPlugin_:r}=t;r&&r.generateReplacementPatches_(n[lG].base_,e,t)}else e=$G(t,n);return Sue(t,e,!0),YG(t),t.patches_&&t.patchListener_(t.patches_,t.inversePatches_),e===sG?void 0:e}function $G(e,t){if(zG(t))return t;let n=t[lG];if(!n)return iK(t,e.handledSet_,e);if(!tK(n,e))return t;if(!n.modified_)return n.base_;if(!n.finalized_){let{callbacks_:t}=n;if(t)for(;t.length>0;)t.pop()(e);rK(n,e)}return n.copy_}function Sue(e,t,n=!1){!e.parent_&&e.immer_.autoFreeze_&&e.canAutoFreeze_&&LG(t,n)}function eK(e){e.finalized_=!0,e.scope_.unfinalizedDrafts_--}var tK=(e,t)=>e.scope_===t,Cue=[];function nK(e,t,n,r){let i=PG(e),a=e.type_;if(r!==void 0&&EG(i,r,a)===t){DG(i,r,n,a);return}if(!e.draftLocations_){let t=e.draftLocations_=new Map;CG(i,(e,n)=>{if(yG(n)){let r=t.get(n)||[];r.push(e),t.set(n,r)}})}let o=e.draftLocations_.get(t)??Cue;for(let e of o)DG(i,e,n,a)}function wue(e,t,n){e.callbacks_.push(function(r){let i=t;if(!i||!tK(i,r))return;r.mapSetPlugin_?.fixSetContents(i);let a=FG(i);nK(e,i.draft_??i,a,n),rK(i,r)})}function rK(e,t){if(e.modified_&&!e.finalized_&&(e.type_===3||e.type_===1&&e.allIndicesReassigned_||(e.assigned_?.size??0)>0)){let{patchPlugin_:n}=t;if(n){let r=n.getPath(e);r&&n.generatePatches_(e,r,t)}eK(e)}}function Tue(e,t,n){let{scope_:r}=e;if(yG(n)){let i=n[lG];tK(i,r)&&i.callbacks_.push(function(){uK(e),nK(e,n,FG(i),t)})}else bG(n)&&e.callbacks_.push(function(){let i=PG(e);e.type_===3?i.has(n)&&iK(n,r.handledSet_,r):EG(i,t,e.type_)===n&&r.drafts_.length>1&&(e.assigned_.get(t)??!1)===!0&&e.copy_&&iK(EG(e.copy_,t,e.type_),r.handledSet_,r)})}function iK(e,t,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||yG(e)||t.has(e)||!bG(e)||zG(e)?e:(t.add(e),CG(e,(r,i)=>{if(yG(i)){let t=i[lG];tK(t,n)&&(DG(e,r,FG(t),e.type_),eK(t))}else bG(i)&&iK(i,t,n)}),e)}function Eue(e,t){let n=OG(e),r={type_:+!!n,scope_:t?t.scope_:qG(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:t,base_:e,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0},i=r,a=aK;n&&(i=[r],a=oK);let{revoke:o,proxy:s}=Proxy.revocable(i,a);return r.draft_=s,r.revoke_=o,[s,r]}var aK={get(e,t){if(t===lG)return e;let n=e.scope_.arrayMethodsPlugin_,r=e.type_===1&&typeof t==`string`;if(r&&n?.isArrayOperationMethod(t))return n.createMethodInterceptor(e,t);let i=PG(e);if(!TG(i,t,e.type_))return Oue(e,i,t);let a=i[t];if(e.finalized_||!bG(a)||r&&e.operationMethod&&n?.isMutatingArrayMethod(e.operationMethod)&&vue(t))return a;if(a===sK(e.base_,t)||Due(e,t,a)){uK(e);let n=e.type_===1?+t:t,r=dK(e.scope_,a,e,n);return e.copy_[n]=r}return a},has(e,t){return t in PG(e)},ownKeys(e){return Reflect.ownKeys(PG(e))},set(e,t,n){let r=cK(PG(e),t);if(r?.set)return r.set.call(e.draft_,n),!0;if(!e.modified_){let r=sK(PG(e),t),i=r?.[lG];if(i&&i.base_===n)return e.copy_[t]=n,e.assigned_.set(t,!1),!0;if(_ue(n,r)&&(n!==void 0||TG(e.base_,t,e.type_)))return!0;uK(e),lK(e)}return e.copy_[t]===n&&(n!==void 0||TG(e.copy_,t,e.type_))||Number.isNaN(n)&&Number.isNaN(e.copy_[t])?!0:(e.copy_[t]=n,e.assigned_.set(t,!0),Tue(e,t,n),!0)},deleteProperty(e,t){return uK(e),sK(e.base_,t)!==void 0||t in e.base_?(e.assigned_.set(t,!1),lK(e)):e.assigned_.delete(t),e.copy_&&delete e.copy_[t],!0},getOwnPropertyDescriptor(e,t){let n=PG(e),r=Reflect.getOwnPropertyDescriptor(n,t);return r&&{[_G]:!0,[hG]:e.type_!==1||t!==`length`,[gG]:r[gG],[vG]:n[t]}},defineProperty(){uG(11)},getPrototypeOf(e){return fG(e.base_)},setPrototypeOf(){uG(12)}},oK={};for(let e in aK){let t=aK[e];oK[e]=function(){let e=arguments;return e[0]=e[0][0],t.apply(this,e)}}oK.deleteProperty=function(e,t){return oK.set.call(this,e,t,void 0)},oK.set=function(e,t,n){return aK.set.call(this,e[0],t,n,e[0])};function sK(e,t){let n=e[lG];return(n?PG(n):e)[t]}function Due(e,t,n){return e.type_!==1||!e.allIndicesReassigned_||e.assigned_?.get(t)||!bG(n)||n[lG]?!1:e.baseRefs_.has(n)}function Oue(e,t,n){let r=cK(t,n);return r?vG in r?r[vG]:r.get?.call(e.draft_):void 0}function cK(e,t){if(!(t in e))return;let n=fG(e);for(;n;){let e=Object.getOwnPropertyDescriptor(n,t);if(e)return e;n=fG(n)}}function lK(e){e.modified_||(e.modified_=!0,e.parent_&&lK(e.parent_))}function uK(e){e.copy_||=(e.assigned_=new Map,IG(e.base_,e.scope_.immer_.useStrictShallowCopy_))}var kue=class{constructor(e){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(e,t,n)=>{if(MG(e)&&!MG(t)){let n=t;t=e;let r=this;return function(e=n,...i){return r.produce(e,e=>t.call(this,e,...i))}}MG(t)||uG(6),n!==void 0&&!MG(n)&&uG(7);let r;if(bG(e)){let i=ZG(this),a=dK(i,e,void 0),o=!0;try{r=t(a),o=!1}finally{o?YG(i):XG(i)}return JG(i,n),QG(r,i)}if(!e||!jG(e)){if(r=t(e),r===void 0&&(r=e),r===sG&&(r=void 0),this.autoFreeze_&&LG(r,!0),n){let t=[],i=[];WG(VG).generateReplacementPatches_(e,r,{patches_:t,inversePatches_:i}),n(t,i)}return r}uG(1,e)},this.produceWithPatches=(e,t)=>{if(MG(e))return(t,...n)=>this.produceWithPatches(t,t=>e(t,...n));let n,r;return[this.produce(e,t,(e,t)=>{n=e,r=t}),n,r]},NG(e?.autoFreeze)&&this.setAutoFreeze(e.autoFreeze),NG(e?.useStrictShallowCopy)&&this.setUseStrictShallowCopy(e.useStrictShallowCopy),NG(e?.useStrictIteration)&&this.setUseStrictIteration(e.useStrictIteration)}createDraft(e){bG(e)||uG(8),yG(e)&&(e=fK(e));let t=ZG(this),n=dK(t,e,void 0);return n[lG].isManual_=!0,XG(t),n}finishDraft(e,t){let n=e&&e[lG];(!n||!n.isManual_)&&uG(9);let{scope_:r}=n;return JG(r,t),QG(void 0,r)}setAutoFreeze(e){this.autoFreeze_=e}setUseStrictShallowCopy(e){this.useStrictShallowCopy_=e}setUseStrictIteration(e){this.useStrictIteration_=e}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(e,t){let n;for(n=t.length-1;n>=0;n--){let r=t[n];if(r.path.length===0&&r.op===`replace`){e=r.value;break}}n>-1&&(t=t.slice(n+1));let r=WG(VG).applyPatches_;return yG(e)?r(e,t):this.produce(e,e=>r(e,t))}};function dK(e,t,n,r){let[i,a]=kG(t)?WG(BG).proxyMap_(t,n):AG(t)?WG(BG).proxySet_(t,n):Eue(t,n);return(n?.scope_??qG()).drafts_.push(i),a.callbacks_=n?.callbacks_??[],a.key_=r,n&&r!==void 0?wue(n,a,r):a.callbacks_.push(function(e){e.mapSetPlugin_?.fixSetContents(a);let{patchPlugin_:t}=e;a.modified_&&t&&t.generatePatches_(a,[],e)}),i}function fK(e){return yG(e)||uG(10,e),pK(e)}function pK(e){if(!bG(e)||zG(e))return e;let t=e[lG],n,r=!0;if(t){if(!t.modified_)return t.base_;t.finalized_=!0,n=IG(e,t.scope_.immer_.useStrictShallowCopy_),r=t.scope_.immer_.shouldUseStrictIteration()}else n=IG(e,!0);return CG(n,(e,t)=>{DG(n,e,pK(t))},r),t&&(t.finalized_=!1),n}globalThis.Iterator?.from;var mK=new kue().produce,hK=e=>e;function gK(e){return({dispatch:t,getState:n})=>r=>i=>typeof i==`function`?i(t,n,e):r(i)}var Aue=gK(),jue=gK,Mue=typeof window<`u`&&window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__?window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__:function(){if(arguments.length!==0)return typeof arguments[0]==`object`?aG:aG.apply(null,arguments)};typeof window<`u`&&window.__REDUX_DEVTOOLS_EXTENSION__&&window.__REDUX_DEVTOOLS_EXTENSION__;function _K(e,t){function n(...n){if(t){let r=t(...n);if(!r)throw Error(QK(0));return{type:e,payload:r.payload,...`meta`in r&&{meta:r.meta},...`error`in r&&{error:r.error}}}return{type:e,payload:n[0]}}return n.toString=()=>`${e}`,n.type=e,n.match=t=>oG(t)&&t.type===e,n}var vK=class e extends Array{constructor(...t){super(...t),Object.setPrototypeOf(this,e.prototype)}static get[Symbol.species](){return e}concat(...e){return super.concat.apply(this,e)}prepend(...t){return t.length===1&&Array.isArray(t[0])?new e(...t[0].concat(this)):new e(...t.concat(this))}};function yK(e){return bG(e)?mK(e,()=>{}):e}function bK(e,t,n){return e.has(t)?e.get(t):e.set(t,n(t)).get(t)}function Nue(e){return typeof e==`boolean`}var Pue=()=>function(e){let{thunk:t=!0,immutableCheck:n=!0,serializableCheck:r=!0,actionCreatorCheck:i=!0}=e??{},a=new vK;return t&&(Nue(t)?a.push(Aue):a.push(jue(t.extraArgument))),a},xK=`RTK_autoBatch`,SK=()=>e=>({payload:e,meta:{[xK]:!0}}),CK=e=>t=>{setTimeout(t,e)},Fue=(e,t)=>n=>{let r=!1,i=()=>{r||(r=!0,cancelAnimationFrame(a),clearTimeout(o),n())},a=e(i),o=setTimeout(i,t)},wK=(e={type:`raf`})=>t=>(...n)=>{let r=t(...n),i=!0,a=!1,o=!1,s=new Set,c=e.type===`tick`?queueMicrotask:e.type===`raf`?typeof window<`u`&&window.requestAnimationFrame?Fue(window.requestAnimationFrame,100):CK(10):e.type===`callback`?e.queueNotification:CK(e.timeout),l=()=>{o=!1,a&&(a=!1,s.forEach(e=>e()))};return Object.assign({},r,{subscribe(e){let t=r.subscribe(()=>i&&e());return s.add(e),()=>{t(),s.delete(e)}},dispatch(e){try{return i=!e?.meta?.[xK],a=!i,a&&(o||(o=!0,c(l))),r.dispatch(e)}finally{i=!0}}})},Iue=e=>function(t){let{autoBatch:n=!0}=t??{},r=new vK(e);return n&&r.push(wK(typeof n==`object`?n:void 0)),r};function Lue(e){let t=Pue(),{reducer:n=void 0,middleware:r,devTools:i=!0,duplicateMiddlewareCheck:a=!0,preloadedState:o=void 0,enhancers:s=void 0}=e||{},c;if(typeof n==`function`)c=n;else if(nG(n))c=iG(n);else throw Error(QK(1));let l;l=typeof r==`function`?r(t):t();let u=aG;i&&(u=Mue({trace:!1,...typeof i==`object`&&i}));let d=Iue(hue(...l)),f=typeof s==`function`?s(d):d(),p=u(...f);return rG(c,o,p)}function TK(e){let t={},n=[],r,i={addCase(e,n){let r=typeof e==`string`?e:e.type;if(!r)throw Error(QK(28));if(r in t)throw Error(QK(29));return t[r]=n,i},addAsyncThunk(e,r){return r.pending&&(t[e.pending.type]=r.pending),r.rejected&&(t[e.rejected.type]=r.rejected),r.fulfilled&&(t[e.fulfilled.type]=r.fulfilled),r.settled&&n.push({matcher:e.settled,reducer:r.settled}),i},addMatcher(e,t){return n.push({matcher:e,reducer:t}),i},addDefaultCase(e){return r=e,i}};return e(i),[t,n,r]}function Rue(e){return typeof e==`function`}function zue(e,t){let[n,r,i]=TK(t),a;if(Rue(e))a=()=>yK(e());else{let t=yK(e);a=()=>t}function o(e=a(),t){let o=[n[t.type],...r.filter(({matcher:e})=>e(t)).map(({reducer:e})=>e)];return o.filter(e=>!!e).length===0&&(o=[i]),o.reduce((e,n)=>{if(n){if(yG(e)){let r=n(e,t);return r===void 0?e:r}if(bG(e))return mK(e,e=>n(e,t));{let r=n(e,t);if(r===void 0){if(e===null)return e;throw Error(`A case reducer on a non-draftable value must not return undefined`)}return r}}return e},e)}return o.getInitialState=a,o}var Bue=`ModuleSymbhasOwnPr-0123456789ABCDEFGHNRVfgctiUvz_KqYTJkLxpZXIjQW`,Vue=(e=21)=>{let t=``,n=e;for(;n--;)t+=Bue[Math.random()*64|0];return t},Hue=Symbol.for(`rtk-slice-createasyncthunk`);function Uue(e,t){return`${e}/${t}`}function Wue({creators:e}={}){let t=e?.asyncThunk?.[Hue];return function(e){let{name:n,reducerPath:r=n}=e;if(!n)throw Error(QK(11));let i=(typeof e.reducers==`function`?e.reducers(Kue()):e.reducers)||{},a=Object.keys(i),o={sliceCaseReducersByName:{},sliceCaseReducersByType:{},actionCreators:{},sliceMatchers:[]},s={addCase(e,t){let n=typeof e==`string`?e:e.type;if(!n)throw Error(QK(12));if(n in o.sliceCaseReducersByType)throw Error(QK(13));return o.sliceCaseReducersByType[n]=t,s},addMatcher(e,t){return o.sliceMatchers.push({matcher:e,reducer:t}),s},exposeAction(e,t){return o.actionCreators[e]=t,s},exposeCaseReducer(e,t){return o.sliceCaseReducersByName[e]=t,s}};a.forEach(r=>{let a=i[r],o={reducerName:r,type:Uue(n,r),createNotation:typeof e.reducers==`function`};Jue(a)?Xue(o,a,s,t):que(o,a,s)});function c(){let[t={},n=[],r=void 0]=typeof e.extraReducers==`function`?TK(e.extraReducers):[e.extraReducers],i={...t,...o.sliceCaseReducersByType};return zue(e.initialState,e=>{for(let t in i)e.addCase(t,i[t]);for(let t of o.sliceMatchers)e.addMatcher(t.matcher,t.reducer);for(let t of n)e.addMatcher(t.matcher,t.reducer);r&&e.addDefaultCase(r)})}let l=e=>e,u=new Map,d=new WeakMap,f;function p(e,t){return f||=c(),f(e,t)}function m(){return f||=c(),f.getInitialState()}function h(t,n=!1){function r(e){let i=e[t];return i===void 0&&n&&(i=bK(d,r,m)),i}function i(t=l){return bK(bK(u,n,()=>new WeakMap),t,()=>{let r={};for(let[i,a]of Object.entries(e.selectors??{}))r[i]=Gue(a,t,()=>bK(d,t,m),n);return r})}return{reducerPath:t,getSelectors:i,get selectors(){return i(r)},selectSlice:r}}let g={name:n,reducer:p,actions:o.actionCreators,caseReducers:o.sliceCaseReducersByName,getInitialState:m,...h(r),injectInto(e,{reducerPath:t,...n}={}){let i=t??r;return e.inject({reducerPath:i,reducer:p},n),{...g,...h(i,!0)}}};return g}}function Gue(e,t,n,r){function i(i,...a){let o=t(i);return o===void 0&&r&&(o=n()),e(o,...a)}return i.unwrapped=e,i}var EK=Wue();function Kue(){function e(e,t){return{_reducerDefinitionType:`asyncThunk`,payloadCreator:e,...t}}return e.withTypes=()=>e,{reducer(e){return Object.assign({[e.name](...t){return e(...t)}}[e.name],{_reducerDefinitionType:`reducer`})},preparedReducer(e,t){return{_reducerDefinitionType:`reducerWithPrepare`,prepare:e,reducer:t}},asyncThunk:e}}function que({type:e,reducerName:t,createNotation:n},r,i){let a,o;if(`reducer`in r){if(n&&!Yue(r))throw Error(QK(17));a=r.reducer,o=r.prepare}else a=r;i.addCase(e,a).exposeCaseReducer(t,a).exposeAction(t,o?_K(e,o):_K(e))}function Jue(e){return e._reducerDefinitionType===`asyncThunk`}function Yue(e){return e._reducerDefinitionType===`reducerWithPrepare`}function Xue({type:e,reducerName:t},n,r,i){if(!i)throw Error(QK(18));let{payloadCreator:a,fulfilled:o,pending:s,rejected:c,settled:l,options:u}=n,d=i(e,a,u);r.exposeAction(t,d),o&&r.addCase(d.fulfilled,o),s&&r.addCase(d.pending,s),c&&r.addCase(d.rejected,c),l&&r.addMatcher(d.settled,l),r.exposeCaseReducer(t,{fulfilled:o||DK,pending:s||DK,rejected:c||DK,settled:l||DK})}function DK(){}var Zue=`task`,OK=`listener`,kK=`completed`,AK=`cancelled`,Que=`task-${AK}`,$ue=`task-${kK}`,jK=`${OK}-${AK}`,ede=`${OK}-${kK}`,MK=class{constructor(e){this.code=e,this.message=`${Zue} ${AK} (reason: ${e})`}code;name=`TaskAbortError`;message},NK=(e,t)=>{if(typeof e!=`function`)throw TypeError(QK(32))},PK=()=>{},FK=(e,t=PK)=>(e.catch(t),e),IK=(e,t)=>(e.addEventListener(`abort`,t,{once:!0}),()=>e.removeEventListener(`abort`,t)),LK=e=>{if(e.aborted)throw new MK(e.reason)};function RK(e,t){let n=PK;return new Promise((r,i)=>{let a=()=>i(new MK(e.reason));if(e.aborted){a();return}n=IK(e,a),t.finally(()=>n()).then(r,i)}).finally(()=>{n=PK})}var tde=async(e,t)=>{try{return await Promise.resolve(),{status:`ok`,value:await e()}}catch(e){return{status:e instanceof MK?`cancelled`:`rejected`,error:e}}finally{t?.()}},zK=e=>t=>FK(RK(e,t).then(t=>(LK(e),t))),BK=e=>{let t=zK(e);return e=>t(new Promise(t=>setTimeout(t,e)))},{assign:VK}=Object,HK={},UK=`listenerMiddleware`,nde=(e,t)=>{let n=t=>IK(e,()=>t.abort(e.reason));return(r,i)=>{NK(r,`taskExecutor`);let a=new AbortController;n(a);let o=tde(async()=>{LK(e),LK(a.signal);let t=await r({pause:zK(a.signal),delay:BK(a.signal),signal:a.signal});return LK(a.signal),t},()=>a.abort($ue));return i?.autoJoin&&t.push(o.catch(PK)),{result:zK(e)(o),cancel(){a.abort(Que)}}}},rde=(e,t)=>{let n=async(n,r)=>{LK(t);let i=()=>{},a=[new Promise((t,r)=>{let a=e({predicate:n,effect:(e,n)=>{n.unsubscribe(),t([e,n.getState(),n.getOriginalState()])}});i=()=>{a(),r()}})];r!=null&&a.push(new Promise(e=>setTimeout(e,r,null)));try{let e=await RK(t,Promise.race(a));return LK(t),e}finally{i()}};return((e,t)=>FK(n(e,t)))},WK=e=>{let{type:t,actionCreator:n,matcher:r,predicate:i,effect:a}=e;if(t)i=_K(t).match;else if(n)t=n.type,i=n.match;else if(r)i=r;else if(!i)throw Error(QK(21));return NK(a,`options.listener`),{predicate:i,type:t,effect:a}},GK=VK(e=>{let{type:t,predicate:n,effect:r}=WK(e);return{id:Vue(),effect:r,type:t,predicate:n,pending:new Set,unsubscribe:()=>{throw Error(QK(22))}}},{withTypes:()=>GK}),KK=(e,t)=>{let{type:n,effect:r,predicate:i}=WK(t);return Array.from(e.values()).find(e=>(typeof n==`string`?e.type===n:e.predicate===i)&&e.effect===r)},qK=e=>{e.pending.forEach(e=>{e.abort(jK)})},ide=(e,t)=>()=>{for(let e of t.keys())qK(e);e.clear()},JK=(e,t,n)=>{try{e(t,n)}catch(e){setTimeout(()=>{throw e},0)}},YK=VK(_K(`${UK}/add`),{withTypes:()=>YK}),ade=_K(`${UK}/removeAll`),XK=VK(_K(`${UK}/remove`),{withTypes:()=>XK}),ode=(...e)=>{console.error(`${UK}/error`,...e)},ZK=(e={})=>{let t=new Map,n=new Map,r=e=>{let t=n.get(e)??0;n.set(e,t+1)},i=e=>{let t=n.get(e)??1;t===1?n.delete(e):n.set(e,t-1)},{extra:a,onError:o=ode}=e;NK(o,`onError`);let s=e=>(e.unsubscribe=()=>t.delete(e.id),t.set(e.id,e),t=>{e.unsubscribe(),t?.cancelActive&&qK(e)}),c=(e=>{let n=KK(t,e)??GK(e);return s(n)});VK(c,{withTypes:()=>c});let l=e=>{let n=KK(t,e);return n&&(n.unsubscribe(),e.cancelActive&&qK(n)),!!n};VK(l,{withTypes:()=>l});let u=async(e,n,s,l)=>{let u=new AbortController,d=rde(c,u.signal),f=[];try{e.pending.add(u),r(e),await Promise.resolve(e.effect(n,VK({},s,{getOriginalState:l,condition:(e,t)=>d(e,t).then(Boolean),take:d,delay:BK(u.signal),pause:zK(u.signal),extra:a,signal:u.signal,fork:nde(u.signal,f),unsubscribe:e.unsubscribe,subscribe:()=>{t.set(e.id,e)},cancelActiveListeners:()=>{e.pending.forEach((e,t,n)=>{e!==u&&(e.abort(jK),n.delete(e))})},cancel:()=>{u.abort(jK),e.pending.delete(u)},throwIfCancelled:()=>{LK(u.signal)}})))}catch(e){e instanceof MK||JK(o,e,{raisedBy:`effect`})}finally{await Promise.all(f),u.abort(ede),i(e),e.pending.delete(u)}},d=ide(t,n);return{middleware:e=>n=>r=>{if(!oG(r))return n(r);if(YK.match(r))return c(r.payload);if(ade.match(r)){d();return}if(XK.match(r))return l(r.payload);let i=e.getState(),a=()=>{if(i===HK)throw Error(QK(23));return i},s;try{if(s=n(r),t.size>0){let n=e.getState(),s=Array.from(t.values());for(let t of s){let s=!1;try{s=t.predicate(r,n,i)}catch(e){s=!1,JK(o,e,{raisedBy:`predicate`})}s&&u(t,r,e,a)}}}finally{i=HK}return s},startListening:c,stopListening:l,clearListeners:d}};function QK(e){return`Minified Redux Toolkit error #${e}; visit https://redux-toolkit.js.org/Errors?code=${e} for the full message or use the non-minified dev environment for full errors. `}var $K=EK({name:`chartLayout`,initialState:{layoutType:`horizontal`,width:0,height:0,margin:{top:5,right:5,bottom:5,left:5},scale:1},reducers:{setLayout(e,t){e.layoutType=t.payload},setChartSize(e,t){e.width=t.payload.width,e.height=t.payload.height},setMargin(e,t){e.margin.top=t.payload.top??0,e.margin.right=t.payload.right??0,e.margin.bottom=t.payload.bottom??0,e.margin.left=t.payload.left??0},setScale(e,t){e.scale=t.payload}}}),eq=$K.actions,sde=eq.setMargin,cde=eq.setLayout,lde=eq.setChartSize,ude=eq.setScale,dde=$K.reducer;function tq(e,t,n){return Array.isArray(e)&&e&&t+n!==0?e.slice(t,n+1):e}function nq(e){return Number.isFinite(e)}function rq(e){return typeof e==`number`&&e>0&&Number.isFinite(e)}function iq(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 aq(e){for(var t=1;t{if(t&&n){var r=n.width,i=n.height,a=t.align,o=t.verticalAlign,s=t.layout,c=t.position,l=t.offset,u=l===void 0?0:l;if(c!=null){if(dle(c)){if(c===`top`&&mU(e.top))return aq(aq({},e),{},{top:e.top+(i||0)+u});if(c===`bottom`&&mU(e.bottom))return aq(aq({},e),{},{bottom:e.bottom+(i||0)+u});if(c===`left`&&mU(e.left))return aq(aq({},e),{},{left:e.left+(r||0)+u});if(c===`right`&&mU(e.right))return aq(aq({},e),{},{right:e.right+(r||0)+u})}return e}if((s===`vertical`||s===`horizontal`&&o===`middle`)&&a!==`center`&&mU(e[a]))return aq(aq({},e),{},{[a]:e[a]+(r||0)});if((s===`horizontal`||s===`vertical`&&a===`center`)&&o!==`middle`&&mU(e[o]))return aq(aq({},e),{},{[o]:e[o]+(i||0)})}return e},sq=(e,t)=>e===`horizontal`&&t===`xAxis`||e===`vertical`&&t===`yAxis`||e===`centric`&&t===`angleAxis`||e===`radial`&&t===`radiusAxis`,gde=(e,t,n,r)=>{if(r)return e.map(e=>e.coordinate);var i,a,o=e.map(e=>(e.coordinate===t&&(i=!0),e.coordinate===n&&(a=!0),e.coordinate));return i||o.push(t),a||o.push(n),o},cq=(e,t,n)=>{if(!e)return null;var r=e.duplicateDomain,i=e.type,a=e.range,o=e.scale,s=e.realScaleType,c=e.isCategorical,l=e.categoricalDomain,u=e.tickCount,d=e.ticks,f=e.niceTicks,p=e.axisType;if(!o)return null;var m=s===`scaleBand`&&o.bandwidth?o.bandwidth()/2:2,h=(t||n)&&i===`category`&&o.bandwidth?o.bandwidth()/m:0;return h=p===`angleAxis`&&a&&a.length>=2?dU(a[0]-a[1])*2*h:h,t&&(d||f)?(d||f||[]).map((e,t)=>{var n=r?r.indexOf(e):e,i=o.map(n);return nq(i)?{coordinate:i+h,value:e,offset:h,index:t}:null}).filter(CU):c&&l?l.map((e,t)=>{var n=o.map(e);return nq(n)?{coordinate:n+h,value:e,index:t,offset:h}:null}).filter(CU):o.ticks&&!n&&u!=null?o.ticks(u).map((e,t)=>{var n=o.map(e);return nq(n)?{coordinate:n+h,value:e,index:t,offset:h}:null}).filter(CU):o.domain().map((e,t)=>{var n=o.map(e);return nq(n)?{coordinate:n+h,value:r?r[e]:e,index:t,offset:h}:null}).filter(CU)},lq={sign:e=>{var t=e.length;if(!(t<=0)){var n=e[0]?.length;if(!(n==null||n<=0))for(var r=0;r=0?(s[0]=i,i+=u,s[1]=i):(s[0]=a,a+=u,s[1]=a)}}}},expand:Ale,none:aW,silhouette:jle,wiggle:Mle,positive:e=>{var t=e.length;if(!(t<=0)){var n=e[0]?.length;if(!(n==null||n<=0))for(var r=0;r=0?(o[0]=i,i+=s,o[1]=i):(o[0]=0,o[1]=0)}}}}},uq=(e,t,n)=>{var r=lq[n]??aW,i=kle().keys(t).value((e,t)=>Number(oq(e,t,0))).order(oW).offset(r)(e);return i.forEach((n,r)=>{n.forEach((n,i)=>{var a=oq(e[i],t[r],0);Array.isArray(a)&&a.length===2&&mU(a[0])&&mU(a[1])&&(n[0]=a[0],n[1]=a[1])})}),i};function dq(e){return e==null?void 0:String(e)}function fq(e){var t=e.axis,n=e.ticks,r=e.bandSize,i=e.entry,a=e.index,o=e.dataKey;if(t.type===`category`){if(!t.allowDuplicatedCategory&&t.dataKey&&!xU(i[t.dataKey])){var s=bU(n,`value`,i[t.dataKey]);if(s)return s.coordinate+r/2}return n!=null&&n[a]?n[a].coordinate+r/2:null}var c=oq(i,xU(o)?t.dataKey:o),l=t.scale.map(c);return mU(l)?l:null}var pq=e=>{var t=e.flat(2).filter(mU);return[Math.min(...t),Math.max(...t)]},mq=e=>[e[0]===1/0?0:e[0],e[1]===-1/0?0:e[1]],hq=(e,t,n)=>{if(e!=null&&Object.keys(e).length!==0)return mq(Object.keys(e).reduce((r,i)=>{var a=e[i];if(!a)return r;var o=a.stackedData.reduce((e,r)=>{var i=pq(tq(r,t,n));return!nq(i[0])||!nq(i[1])?e:[Math.min(e[0],i[0]),Math.max(e[1],i[1])]},[1/0,-1/0]);return[Math.min(o[0],r[0]),Math.max(o[1],r[1])]},[1/0,-1/0]))},gq=/^dataMin[\s]*-[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,_q=/^dataMax[\s]*\+[\s]*([0-9]+([.]{1}[0-9]+){0,1})$/,vq=(e,t,n)=>{if(e&&e.scale&&e.scale.bandwidth){var r=e.scale.bandwidth();if(!n||r>0)return r}if(e&&t&&t.length>=2){for(var i=XW(t,e=>e.coordinate),a=[],o=0,s=1,c=i.length;su&&(d=Math.min(f,d));return d===1/0?0:d}return n?void 0:0};function yq(e){var t=e.tooltipEntrySettings,n=e.dataKey,r=e.payload,i=e.value,a=e.name;return aq(aq({},t),{},{dataKey:n,payload:r,value:i,name:a})}function bq(e,t){if(e!=null)return String(e);if(typeof t==`string`)return t}var xq=(e,t)=>{if(t===`horizontal`)return e.relativeX;if(t===`vertical`)return e.relativeY},Sq=(e,t)=>t===`centric`?e.angle:e.radius,Cq=e=>e.layout.width,wq=e=>e.layout.height,Tq=e=>e.layout.scale,Eq=e=>e.layout.margin,Dq=$(e=>e.cartesianAxis.xAxis,e=>Object.values(e)),Oq=$(e=>e.cartesianAxis.yAxis,e=>Object.values(e)),kq=`data-recharts-item-index`;function Aq(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 jq(e){for(var t=1;te.brush.height;function Iq(e){return Oq(e).reduce((e,t)=>t.orientation===`left`&&!t.mirror&&!t.hide?e+(typeof t.width==`number`?t.width:60):e,0)}function Lq(e){return Oq(e).reduce((e,t)=>t.orientation===`right`&&!t.mirror&&!t.hide?e+(typeof t.width==`number`?t.width:60):e,0)}function Rq(e){return Dq(e).reduce((e,t)=>t.orientation===`top`&&!t.mirror&&!t.hide?e+(typeof t.height==`number`?t.height:30):e,0)}function zq(e){return Dq(e).reduce((e,t)=>t.orientation===`bottom`&&!t.mirror&&!t.hide?e+(typeof t.height==`number`?t.height:30):e,0)}var Bq=$([Cq,wq,Eq,Fq,Iq,Lq,Rq,zq,ZW,pue],(e,t,n,r,i,a,o,s,c,l)=>{var u={left:(n.left||0)+i,right:(n.right||0)+a},d=jq(jq({},{top:(n.top||0)+o,bottom:(n.bottom||0)+s}),u),f=d.bottom;d.bottom+=r,d=hde(d,c,l);var p=e-d.left-d.right,m=t-d.top-d.bottom;return jq(jq({brushBottom:f},d),{},{width:Math.max(p,0),height:Math.max(m,0)})}),Vq=$(Bq,e=>({x:e.left,y:e.top,width:e.width,height:e.height})),Hq=$(Cq,wq,(e,t)=>({x:0,y:0,width:e,height:t})),Uq=(0,v.createContext)(null),Wq=()=>(0,v.useContext)(Uq)!=null,Gq=e=>e.brush,Kq=$([Gq,Bq,Eq],(e,t,n)=>({height:e.height,x:mU(e.x)?e.x:t.left,y:mU(e.y)?e.y:t.top+t.height+t.brushBottom-(n?.bottom||0),width:mU(e.width)?e.width:t.width}));function qq(e,t,{signal:n,edges:r}={}){let i,a=null,o=r!=null&&r.includes(`leading`),s=r==null||r.includes(`trailing`),c=()=>{a!==null&&(e.apply(i,a),i=void 0,a=null)},l=()=>{s&&c(),p()},u=null,d=()=>{u!=null&&clearTimeout(u),u=setTimeout(()=>{u=null,l()},t)},f=()=>{u!==null&&(clearTimeout(u),u=null)},p=()=>{f(),i=void 0,a=null},m=()=>{c()},h=function(...e){if(n?.aborted)return;i=this,a=e;let t=u==null;d(),o&&t&&c()};return h.schedule=d,h.cancel=p,h.flush=m,n?.addEventListener(`abort`,p,{once:!0}),h}function Jq(e,t=0,n={}){typeof n!=`object`&&(n={});let{leading:r=!1,trailing:i=!0,maxWait:a}=n,o=[,,];r&&(o[0]=`leading`),i&&(o[1]=`trailing`);let s,c=null,l=qq(function(...t){s=e.apply(this,t),c=null},t,{edges:o}),u=function(...t){return a!=null&&(c===null&&(c=Date.now()),Date.now()-c>=a)?((r||i)&&(s=e.apply(this,t)),c=Date.now(),l.cancel(),l.schedule(),s):(l.apply(this,t),s)};return u.cancel=l.cancel,u.flush=()=>(l.flush(),s),u}function Yq(e,t=0,n={}){let{leading:r=!0,trailing:i=!0}=n;return Jq(e,t,{leading:r,maxWait:t,trailing:i})}var Xq=function(e,t){var n=[...arguments].slice(2);if(typeof console<`u`&&console.warn&&(t===void 0&&console.warn(`LogUtils requires an error message argument`),!e)){if(t===void 0)console.warn(`Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.`);else{var r=0;console.warn(t.replace(/%s/g,()=>n[r++]))}}},Zq={width:`100%`,height:`100%`,debounce:0,minWidth:0,initialDimension:{width:-1,height:-1}},Qq=(e,t,n)=>{var r=n.width,i=r===void 0?Zq.width:r,a=n.height,o=a===void 0?Zq.height:a,s=n.aspect,c=n.maxHeight,l=pU(i)?e:Number(i),u=pU(o)?t:Number(o);return s&&s>0&&(l?u=l/s:u&&(l=u*s),c&&u!=null&&u>c&&(u=c)),{calculatedWidth:l,calculatedHeight:u}},$q={width:0,height:0,overflow:`visible`},eJ={width:0,overflowX:`visible`},tJ={height:0,overflowY:`visible`},nJ={},rJ=e=>{var t=e.width,n=e.height,r=pU(t),i=pU(n);return r&&i?$q:r?eJ:i?tJ:nJ};function iJ(e){var t=e.width,n=e.height,r=e.aspect,i=t,a=n;return i===void 0&&a===void 0?(i=Zq.width,a=Zq.height):i===void 0?i=r&&r>0?void 0:Zq.width:a===void 0&&(a=r&&r>0?void 0:Zq.height),{width:i,height:a}}var aJ=[`aspect`,`initialDimension`,`width`,`height`,`minWidth`,`minHeight`,`maxHeight`,`children`,`debounce`,`id`,`className`,`onResize`,`style`];function oJ(){return oJ=Object.assign?Object.assign.bind():function(e){for(var t=1;te.length)&&(t=e.length);for(var n=0,r=Array(t);n({width:n,height:r}),[n,r]);return xJ(i)?v.createElement(bJ.Provider,{value:i},t):null}var CJ=()=>(0,v.useContext)(bJ),wJ=(0,v.forwardRef)((e,t)=>{var n=e.aspect,r=e.initialDimension,i=r===void 0?Zq.initialDimension:r,a=e.width,o=e.height,s=e.minWidth,c=s===void 0?Zq.minWidth:s,l=e.minHeight,u=e.maxHeight,d=e.children,f=e.debounce,p=f===void 0?Zq.debounce:f,m=e.id,h=e.className,g=e.onResize,_=e.style,y=_===void 0?{}:_,b=vJ(e,aJ),x=(0,v.useRef)(null),S=(0,v.useRef)();S.current=g,(0,v.useImperativeHandle)(t,()=>x.current);var C=fJ((0,v.useState)({containerWidth:i.width,containerHeight:i.height}),2),w=C[0],T=C[1],E=(0,v.useCallback)((e,t)=>{T(n=>{var r=Math.round(e),i=Math.round(t);return n.containerWidth===r&&n.containerHeight===i?n:{containerWidth:r,containerHeight:i}})},[]);(0,v.useEffect)(()=>{if(x.current==null||typeof ResizeObserver>`u`)return wU;var e=e=>{var t,n=e[0];if(n!=null){var r=n.contentRect,i=r.width,a=r.height;E(i,a),(t=S.current)==null||t.call(S,i,a)}};p>0&&(e=Yq(e,p,{trailing:!0,leading:!1}));var t=new ResizeObserver(e),n=x.current.getBoundingClientRect(),r=n.width,i=n.height;return E(r,i),t.observe(x.current),()=>{t.disconnect()}},[E,p]);var D=w.containerWidth,O=w.containerHeight;Xq(!n||n>0,`The aspect(%s) must be greater than zero.`,n);var k=Qq(D,O,{width:a,height:o,aspect:n,maxHeight:u}),A=k.calculatedWidth,j=k.calculatedHeight;return Xq(D<0||O<0||A!=null&&A>0||j!=null&&j>0,`The width(%s) and height(%s) of chart should be greater than 0, please check the style of container, or the props width(%s) and height(%s), or add a minWidth(%s) or minHeight(%s) or use aspect(%s) to control the @@ -115,7 +115,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Rve(e,t){if(e){if(typeof e==`string`)return s8(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?s8(e,t):void 0}}function s8(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n{var t=e.children,n=Ive((0,v.useState)(`${gU(`recharts`)}-clip`),1)[0],r=Q6();if(r==null)return null;var i=r.x,a=r.y,o=r.width,s=r.height;return v.createElement(c8.Provider,{value:n},v.createElement(`defs`,null,v.createElement(`clipPath`,{id:n},v.createElement(`rect`,{x:i,y:a,height:s,width:o}))),t)},l8=()=>(0,v.useContext)(c8),u8=class{constructor(e){var t=e.x,n=e.y;this.xAxisScale=t,this.yAxisScale=n}map(e,t){var n=t.position;return{x:this.xAxisScale.map(e.x,{position:n})??0,y:this.yAxisScale.map(e.y,{position:n})??0}}mapWithFallback(e,t){var n=t.position,r=t.fallback,i=r===`rangeMin`?this.yAxisScale.rangeMin():r===`rangeMax`?this.yAxisScale.rangeMax():0,a=r===`rangeMin`?this.xAxisScale.rangeMin():r===`rangeMax`?this.xAxisScale.rangeMax():0;return{x:this.xAxisScale.map(e.x,{position:n})??a,y:this.yAxisScale.map(e.y,{position:n})??i}}isInRange(e){var t=e.x,n=e.y,r=t==null||this.xAxisScale.isInRange(t),i=n==null||this.yAxisScale.isInRange(n);return r&&i}};function d8(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 f8(e){for(var t=1;t{var n;if(v.isValidElement(e))n=v.cloneElement(e,t);else if(typeof e==`function`)n=e(t);else{if(!nq(t.x1)||!nq(t.y1)||!nq(t.x2)||!nq(t.y2))return null;n=v.createElement(`line`,p8({},t,{className:`recharts-reference-line-line`}))}return n},Kve=(e,t,n,r,i,a)=>{var o=a.x,s=a.width,c=i.map(e,{position:n});if(!nq(c)||t===`discard`&&!i.isInRange(c))return null;var l=[{x:o+s,y:c},{x:o,y:c}];return r===`left`?l.reverse():l},qve=(e,t,n,r,i,a)=>{var o=a.y,s=a.height,c=i.map(e,{position:n});if(!nq(c)||t===`discard`&&!i.isInRange(c))return null;var l=[{x:c,y:o+s},{x:c,y:o}];return r===`top`?l.reverse():l},Jve=(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},Yve=(e,t,n,r,i,a,o)=>{var s=o.x,c=o.y,l=o.segment,u=o.ifOverflow,d=hU(s);return hU(c)?Kve(c,u,r,a,t,n):d?qve(s,u,r,i,e,n):l!=null&&l.length===2?Jve(l,u,r,new u8({x:e,y:t})):null};function Xve(e){var t=BW();return(0,v.useEffect)(()=>(t(Nve(e)),()=>{t(Pve(e))})),null}function Zve(e){var t=e.xAxisId,n=e.yAxisId,r=e.shape,i=e.className,a=e.ifOverflow,o=Wq(),s=l8(),c=HW(e=>Y0(e,t)),l=HW(e=>Q0(e,n)),u=HW(e=>Q2(e,`xAxis`,t,o)),d=HW(e=>Q2(e,`yAxis`,n,o)),f=EJ();if(!s||!f||c==null||l==null||u==null||d==null)return null;var p=Yve(u,d,f,e.position,c.orientation,l.orientation,e);if(!p)return null;var m=p[0],h=p[1];if(m==null||h==null)return null;var g=m.x,_=m.y,y=h.x,b=h.y,x=f8(f8({clipPath:a===`hidden`?`url(#${s})`:void 0},ZH(e)),{},{x1:g,y1:_,x2:y,y2:b}),S=Ove({x1:g,y1:_,x2:y,y2:b});return v.createElement(m3,{zIndex:e.zIndex},v.createElement(tU,{className:xs(`recharts-reference-line`,i)},Gve(r,x),v.createElement(o6,p8({},S,{lowerWidth:S.width,upperWidth:S.width}),v.createElement(d6,{label:e.label}),e.children)))}var Qve={ifOverflow:`discard`,xAxisId:0,yAxisId:0,fill:`none`,label:!1,stroke:`#ccc`,fillOpacity:1,strokeWidth:1,position:`middle`,zIndex:qZ.line};function m8(e){var t=lW(e,Qve);return v.createElement(v.Fragment,null,v.createElement(Xve,{yAxisId:t.yAxisId,xAxisId:t.xAxisId,ifOverflow:t.ifOverflow,x:t.x,y:t.y,segment:t.segment}),v.createElement(Zve,t))}m8.displayName=`ReferenceLine`;function h8(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 g8(e){for(var t=1;t{var s=o.x1,c=o.x2,l=o.y1,u=o.y2;if(i==null||a==null)return null;var d=new u8({x:i,y:a}),f={x:e?i.map(s,{position:`start`})??null:i.rangeMin(),y:n?a.map(l,{position:`start`})??null:a.rangeMin()},p={x:t?i.map(c,{position:`end`})??null:i.rangeMax(),y:r?a.map(u,{position:`end`})??null:a.rangeMax()};return o.ifOverflow===`discard`&&(!d.isInRange(f)||!d.isInRange(p))?null:i8(f,p)},rye=(e,t)=>v.isValidElement(e)?v.cloneElement(e,t):typeof e==`function`?e(t):v.createElement(UX,_8({},t,{className:`recharts-reference-area-rect`}));function iye(e){var t=BW();return(0,v.useEffect)(()=>(t(jve(e)),()=>{t(Mve(e))})),null}function aye(e){var t=e.x1,n=e.x2,r=e.y1,i=e.y2,a=e.className,o=e.shape,s=e.xAxisId,c=e.yAxisId,l=l8(),u=Wq(),d=HW(e=>Q2(e,`xAxis`,s,u)),f=HW(e=>Q2(e,`yAxis`,c,u));if(d==null||f==null)return null;var p=hU(t),m=hU(n),h=hU(r),g=hU(i);if(!p&&!m&&!h&&!g&&!o)return null;var _=nye(p,m,h,g,d,f,e);if(!_&&!o)return null;var y=e.ifOverflow===`hidden`?`url(#${l})`:void 0;return v.createElement(m3,{zIndex:e.zIndex},v.createElement(tU,{className:xs(`recharts-reference-area`,a)},rye(o,g8(g8({clipPath:y},ZH(e)),_)),_!=null&&v.createElement(o6,_8({},_,{lowerWidth:_.width,upperWidth:_.width}),v.createElement(d6,{label:e.label}),e.children)))}var oye={ifOverflow:`discard`,xAxisId:0,yAxisId:0,radius:0,fill:`#ccc`,label:!1,fillOpacity:.5,stroke:`none`,strokeWidth:1,zIndex:qZ.area};function v8(e){var t=lW(e,oye);return v.createElement(v.Fragment,null,v.createElement(iye,{yAxisId:t.yAxisId,xAxisId:t.xAxisId,ifOverflow:t.ifOverflow,x1:t.x1,x2:t.x2,y1:t.y1,y2:t.y2}),v.createElement(aye,t))}v8.displayName=`ReferenceArea`;function sye(){}function y8(e){if(!e||typeof e!=`object`)return!1;let t=Object.getPrototypeOf(e);return t!==null&&t!==Object.prototype&&Object.getPrototypeOf(t)!==null?!1:Object.prototype.toString.call(e)===`[object Object]`}function cye(e,t,n){return b8(e,t,void 0,void 0,void 0,void 0,n)}function b8(e,t,n,r,i,a,o){let s=o(e,t,n,r,i,a);if(s!==void 0)return s;if(typeof e==typeof t)switch(typeof e){case`bigint`:case`string`:case`boolean`:case`symbol`:case`undefined`:return e===t;case`number`:return e===t||Object.is(e,t);case`function`:return e===t;case`object`:return x8(e,t,a,o)}return x8(e,t,a,o)}function x8(e,t,n,r){if(Object.is(e,t))return!0;let i=fW(e),a=fW(t);if(i===`[object Arguments]`&&(i=CW),a===`[object Arguments]`&&(a=CW),i!==a)return!1;switch(i){case mW:return e.toString()===t.toString();case hW:return IW(e.valueOf(),t.valueOf());case gW:case vW:case _W:return Object.is(e.valueOf(),t.valueOf());case pW:return e.source===t.source&&e.flags===t.flags;case Hle:return e===t}n??=new Map;let o=n.get(e),s=n.get(t);if(o!=null&&s!=null)return o===t;n.set(e,t),n.set(t,e);try{switch(i){case yW:if(e.size!==t.size)return!1;for(let[i,a]of e.entries())if(!t.has(i)||!b8(a,t.get(i),i,e,t,n,r))return!1;return!0;case bW:{if(e.size!==t.size)return!1;let i=Array.from(e.values()),a=Array.from(t.values());for(let o=0;ob8(s,i,void 0,e,t,n,r));if(c===-1)return!1;a.splice(c,1)}return!0}case xW:case TW:case EW:case DW:case OW:case Wle:case kW:case AW:case jW:case Gle:case MW:case NW:if(FW(e)!==FW(t)||e.length!==t.length)return!1;for(let i=0;ie*i)return!1;var a=n();return e*(t-e*a/2-r)>=0&&e*(t+e*a/2-i)<=0}function fye(e,t){return S8(e,t+1)}function pye(e,t,n,r,i){for(var a=(r||[]).slice(),o=t.start,s=t.end,c=0,l=1,u=o,d=function(){var t=r?.[c];if(t===void 0)return{v:S8(r,l)};var a=c,d,f=()=>(d===void 0&&(d=n(t,a)),d),p=t.coordinate,m=c===0||C8(e,p,f,u,s);m||(c=0,u=o,l+=1),m&&(u=p+e*(f()/2+i),c+=l)},f;l<=a.length;)if(f=d(),f)return f.v;return[]}function mye(e,t,n,r,i){var a=(r||[]).slice().length;if(a===0)return[];for(var o=t.start,s=t.end,c=1;c<=a;c++){for(var l=(a-1)%c,u=o,d=!0,f=function(){var t=r[m];if(t==null)return 0;var a=m,o,c=()=>(o===void 0&&(o=n(t,a)),o),f=t.coordinate,p=m===l||C8(e,f,c,u,s);if(!p)return d=!1,1;p&&(u=f+e*(c()/2+i))},p,m=l;m(u===void 0&&(u=n(r,t)),u);if(t===o-1){var f=e*(l.coordinate+e*d()/2-c);a[t]=l=T8(T8({},l),{},{tickCoord:f>0?l.coordinate-f*e:l.coordinate})}else a[t]=l=T8(T8({},l),{},{tickCoord:l.coordinate});l.tickCoord!=null&&C8(e,l.tickCoord,d,s,c)&&(c=l.tickCoord-e*(d()/2+i),a[t]=T8(T8({},l),{},{isShow:!0}))},u=o-1;u>=0;u--)if(l(u))continue;return a}function yye(e,t,n,r,i,a){var o=(r||[]).slice(),s=o.length,c=t.start,l=t.end;if(a){var u=r[s-1];if(u!=null){var d=n(u,s-1),f=e*(u.coordinate+e*d/2-l);o[s-1]=u=T8(T8({},u),{},{tickCoord:f>0?u.coordinate-f*e:u.coordinate}),u.tickCoord!=null&&C8(e,u.tickCoord,()=>d,c,l)&&(l=u.tickCoord-e*(d/2+i),o[s-1]=T8(T8({},u),{},{isShow:!0}))}}for(var p=a?s-1:s,m=function(t){var r=o[t];if(r==null)return 1;var a=r,s,u=()=>(s===void 0&&(s=n(r,t)),s);if(t===0){var d=e*(a.coordinate-e*u()/2-c);o[t]=a=T8(T8({},a),{},{tickCoord:d<0?a.coordinate-d*e:a.coordinate})}else o[t]=a=T8(T8({},a),{},{tickCoord:a.coordinate});a.tickCoord!=null&&C8(e,a.tickCoord,u,c,l)&&(c=a.tickCoord+e*(u()/2+i),o[t]=T8(T8({},a),{},{isShow:!0}))},h=0;h{var i=typeof l==`function`?l(e.value,r):e.value;return p===`width`?uye(j3(i,{fontSize:t,letterSpacing:n}),m,d):j3(i,{fontSize:t,letterSpacing:n})[p]},g=i[0],_=i[1],v=i.length>=2&&g!=null&&_!=null?dU(_.coordinate-g.coordinate):1,y=dye(a,v,p);return c===`equidistantPreserveStart`?pye(v,y,h,i,o):c===`equidistantPreserveEnd`?mye(v,y,h,i,o):(f=c===`preserveStart`||c===`preserveStartEnd`?yye(v,y,h,i,o,c===`preserveStartEnd`):vye(v,y,h,i,o),f.filter(e=>e.isShow))}var bye=e=>{var t=e.ticks,n=e.label,r=e.labelGapWithTick,i=r===void 0?5:r,a=e.tickSize,o=a===void 0?0:a,s=e.tickMargin,c=s===void 0?0:s,l=0;if(t){Array.from(t).forEach(e=>{if(e){var t=e.getBoundingClientRect();t.width>l&&(l=t.width)}});var u=n?n.getBoundingClientRect().width:0,d=o+c,f=l+d+u+(n?i:0);return Math.round(f)}return 0},xye=e=>{var t=e.ticks,n=e.label,r=e.labelGapWithTick,i=r===void 0?5:r,a=e.tickSize,o=a===void 0?0:a,s=e.tickMargin,c=s===void 0?0:s,l=0;if(t){Array.from(t).forEach(e=>{if(e){var t=e.getBoundingClientRect();t.height>l&&(l=t.height)}});var u=n?n.getBoundingClientRect().height:0,d=o+c,f=l+d+u+(n?i:0);return Math.round(f)}return 0},D8=EK({name:`renderedTicks`,initialState:{xAxis:{},yAxis:{}},reducers:{setRenderedTicks:(e,t)=>{var n=t.payload,r=n.axisType,i=n.axisId,a=n.ticks;e[r][i]=hK(a)},removeRenderedTicks:(e,t)=>{var n=t.payload,r=n.axisType,i=n.axisId;delete e[r][i]}}}),O8=D8.actions,Sye=O8.setRenderedTicks,Cye=O8.removeRenderedTicks,wye=D8.reducer,Tye=[`axisLine`,`width`,`height`,`className`,`hide`,`ticks`,`axisType`,`axisId`];function k8(e,t){return kye(e)||Oye(e,t)||Dye(e,t)||Eye()}function Eye(){throw TypeError(`Invalid attempt to destructure non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Dye(e,t){if(e){if(typeof e==`string`)return A8(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?A8(e,t):void 0}}function A8(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n{if(r!=null&&n!=null){var e=t.map(e=>({value:e.value,coordinate:e.coordinate,offset:e.offset,index:e.index})),o=a.current;o!=null&&o.axisId===r&&o.axisType===n&&lye(o.ticks,e)||(a.current={ticks:e,axisId:r,axisType:n},i(Sye({ticks:e,axisId:r,axisType:n})))}},[i,t,r,n]),(0,v.useEffect)(()=>r==null||n==null?wU:()=>{i(Cye({axisId:r,axisType:n}))},[i,r,n]),null}var Vye=(0,v.forwardRef)((e,t)=>{var n=e.ticks,r=n===void 0?[]:n,i=e.tick,a=e.tickLine,o=e.stroke,s=e.tickFormatter,c=e.unit,l=e.padding,u=e.tickTextProps,d=e.orientation,f=e.mirror,p=e.x,m=e.y,h=e.width,g=e.height,_=e.tickSize,y=e.tickMargin,b=e.fontSize,x=e.letterSpacing,S=e.getTicksConfig,C=e.events,w=e.axisType,T=e.axisId,E=E8(N8(N8({},S),{},{ticks:r}),b,x),D=YH(S),O=XH(i),k=J3(D.textAnchor)?D.textAnchor:Lye(d,f),A=Rye(d,f),j={};typeof a==`object`&&(j=a);var M=N8(N8({},D),{},{fill:`none`},j),N=E.map(e=>N8({entry:e},Iye(e,p,m,h,g,d,_,f,y))),P=N.map(e=>{var t=e.entry,n=e.line;return v.createElement(tU,{className:`recharts-cartesian-axis-tick`,key:`tick-${t.value}-${t.coordinate}-${t.tickCoord}`},a&&v.createElement(`line`,j8({},M,n,{className:xs(`recharts-cartesian-axis-tick-line`,cU(a,`className`))})))}),F=N.map((e,t)=>{var n=e.entry,r=e.tick,a=N8(N8({},N8(N8(N8(N8({verticalAnchor:A},D),{},{textAnchor:k,stroke:`none`,fill:o},r),{},{index:t,payload:n,visibleTicksCount:E.length,tickFormatter:s,padding:l},u),{},{angle:u?.angle??D.angle??0})),O);return v.createElement(tU,j8({className:`recharts-cartesian-axis-tick-label`,key:`tick-label-${n.value}-${n.coordinate}-${n.tickCoord}`},Fle(C,n,t)),i&&v.createElement(zye,{option:i,tickProps:a,value:`${typeof s==`function`?s(n.value,t):n.value}${c||``}`}))});return v.createElement(`g`,{className:`recharts-cartesian-axis-ticks recharts-${w}-ticks`},v.createElement(Bye,{ticks:E,axisId:T,axisType:w}),F.length>0&&v.createElement(m3,{zIndex:qZ.label},v.createElement(`g`,{className:`recharts-cartesian-axis-tick-labels recharts-${w}-tick-labels`,ref:t},F)),P.length>0&&v.createElement(`g`,{className:`recharts-cartesian-axis-tick-lines recharts-${w}-tick-lines`},P))}),Hye=(0,v.forwardRef)((e,t)=>{var n=e.axisLine,r=e.width,i=e.height,a=e.className,o=e.hide,s=e.ticks,c=e.axisType,l=e.axisId,u=Aye(e,Tye),d=k8((0,v.useState)(``),2),f=d[0],p=d[1],m=k8((0,v.useState)(``),2),h=m[0],g=m[1],_=(0,v.useRef)(null);(0,v.useImperativeHandle)(t,()=>({getCalculatedWidth:()=>bye({ticks:_.current,label:e.labelRef?.current,labelGapWithTick:5,tickSize:e.tickSize,tickMargin:e.tickMargin}),getCalculatedHeight:()=>xye({ticks:_.current,label:e.labelRef?.current,labelGapWithTick:5,tickSize:e.tickSize,tickMargin:e.tickMargin})}));var y=(0,v.useCallback)(e=>{if(e){var t=e.getElementsByClassName(`recharts-cartesian-axis-tick-value`);_.current=t;var n=t[0];if(n){var r=window.getComputedStyle(n),i=r.fontSize,a=r.letterSpacing;(i!==f||a!==h)&&(p(i),g(a))}}},[f,h]);return o||r!=null&&r<=0||i!=null&&i<=0?null:v.createElement(m3,{zIndex:e.zIndex},v.createElement(tU,{className:xs(`recharts-cartesian-axis`,a)},v.createElement(Fye,{x:e.x,y:e.y,width:r,height:i,orientation:e.orientation,mirror:e.mirror,axisLine:n,otherSvgProps:YH(e)}),v.createElement(Vye,{ref:y,axisType:c,events:u,fontSize:f,getTicksConfig:e,height:e.height,letterSpacing:h,mirror:e.mirror,orientation:e.orientation,padding:e.padding,stroke:e.stroke,tick:e.tick,tickFormatter:e.tickFormatter,tickLine:e.tickLine,tickMargin:e.tickMargin,tickSize:e.tickSize,tickTextProps:e.tickTextProps,ticks:s,unit:e.unit,width:e.width,x:e.x,y:e.y,axisId:l}),v.createElement(o6,{x:e.x,y:e.y,width:e.width,height:e.height,lowerWidth:e.width,upperWidth:e.width},v.createElement(d6,{label:e.label,labelRef:e.labelRef}),e.children)))}),F8=v.forwardRef((e,t)=>{var n=lW(e,P8);return v.createElement(Hye,j8({},n,{ref:t}))});F8.displayName=`CartesianAxis`;var I8=EK({name:`errorBars`,initialState:{},reducers:{addErrorBar:(e,t)=>{var n=t.payload,r=n.itemId,i=n.errorBar;e[r]||(e[r]=[]),e[r].push(i)},replaceErrorBar:(e,t)=>{var n=t.payload,r=n.itemId,i=n.prev,a=n.next;e[r]&&(e[r]=e[r].map(e=>e.dataKey===i.dataKey&&e.direction===i.direction?a:e))},removeErrorBar:(e,t)=>{var n=t.payload,r=n.itemId,i=n.errorBar;e[r]&&(e[r]=e[r].filter(e=>e.dataKey!==i.dataKey||e.direction!==i.direction))}}}),L8=I8.actions;L8.addErrorBar,L8.replaceErrorBar,L8.removeErrorBar;var Uye=I8.reducer;function R8(e,t){var n=HW(t=>Y0(t,e)),r=HW(e=>Q0(e,t)),i=n?.allowDataOverflow??q0.allowDataOverflow,a=r?.allowDataOverflow??X0.allowDataOverflow;return{needClip:i||a,needClipX:i,needClipY:a}}function z8(e){var t=e.xAxisId,n=e.yAxisId,r=e.clipPathId,i=Q6(),a=R8(t,n),o=a.needClipX,s=a.needClipY,c=a.needClip,l=HW(e=>G2(e,t,!1)),u=HW(e=>K2(e,n,!1));if(!c||!i)return null;var d=i.x,f=i.y,p=i.width,m=i.height,h=o&&l?Math.min(l[0],l[1]):d-p/2,g=s&&u?Math.min(u[0],u[1]):f-m/2,_=o&&l?Math.abs(l[1]-l[0]):p*2,y=s&&u?Math.abs(u[1]-u[0]):m*2;return v.createElement(`clipPath`,{id:`clipPath-${r}`},v.createElement(`rect`,{x:h,y:g,width:_,height:y}))}function B8(e){var t=XH(e),n=3,r=2;if(t!=null){var i=t.r,a=t.strokeWidth,o=Number(i),s=Number(a);return(Number.isNaN(o)||o<0)&&(o=n),(Number.isNaN(s)||s<0)&&(s=r),{r:o,strokeWidth:s}}return{r:n,strokeWidth:r}}function V8(e,t){return e.graphicalItems.cartesianItems.find(e=>e.id===t)?.xAxisId??0}function H8(e,t){return e.graphicalItems.cartesianItems.find(e=>e.id===t)?.yAxisId??0}var U8=(e,t,n)=>s4(e,`xAxis`,V8(e,t),n),W8=(e,t,n)=>o4(e,`xAxis`,V8(e,t),n),G8=(e,t,n)=>s4(e,`yAxis`,H8(e,t),n),K8=(e,t,n)=>o4(e,`yAxis`,H8(e,t),n),Wye=$([jJ,U8,G8,W8,K8],(e,t,n,r,i)=>sq(e,`xAxis`)?vq(t,r,!1):vq(n,i,!1)),q8=$([i2,(e,t)=>t],(e,t)=>e.filter(e=>e.type===`area`).find(e=>e.id===t)),J8=e=>sq(jJ(e),`xAxis`)?`yAxis`:`xAxis`,Gye=(e,t)=>J8(e)===`yAxis`?H8(e,t):V8(e,t),Y8=(e,t,n)=>S2(e,J8(e),Gye(e,t),n),Kye=$([jJ,U8,G8,W8,K8,$([q8,Y8],(e,t)=>{if(e!=null&&t!=null){var n=e.stackId,r=gQ(e);if(n!=null&&r!=null){var i=(t[n]?.stackedData)?.find(e=>e.key===r);if(i!=null)return i.map(e=>[e[0],e[1]])}}}),uZ,Wye,q8,KZ,$([q8,Y8],(e,t)=>{if(e!=null&&e.stackId!=null&&t!=null){var n=t[e.stackId];if(n!=null)return n.graphicalItems.map(e=>e.dataKey).filter(CU)}})],(e,t,n,r,i,a,o,s,c,l,u)=>{var d=o.chartData,f=o.dataStartIndex,p=o.dataEndIndex;if(!(c==null||e!==`horizontal`&&e!==`vertical`||t==null||n==null||r==null||i==null||r.length===0||i.length===0||s==null)){var m=c.data,h=m&&m.length>0?m:d?.slice(f,p+1);if(h!=null)return _be({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataStartIndex:f,areaSettings:c,stackedData:a,displayedData:h,chartBaseValue:l,bandSize:s,stackDataKeys:u})}}),qye=[`animationElapsedTime`,`isAnimating`,`isEntrance`,`layout`,`isRange`,`stroke`,`connectNulls`],Jye=[`id`,`baseLine`];function X8(){return X8=Object.assign?Object.assign.bind():function(e){for(var t=1;te.y||0));return mU(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(e=>e.y||0),c)),mU(c)?v.createElement(`rect`,{x:ae.x||0));return mU(n)?c=Math.max(n,c):n&&Array.isArray(n)&&n.length&&(c=Math.max(...n.map(e=>e.x||0),c)),mU(c)?v.createElement(`rect`,{x:0,y:ae==null?[]:t===1?e.flatMap(e=>e.status===`removed`?[]:[e.next]):e.flatMap(e=>e.status===`matched`?[t5(t5({},e.next),{},{x:yU(e.prev.x,e.next.x,t),y:yU(e.prev.y,e.next.y,t)})]:e.status===`added`?[e.next]:[]),connectNulls:!1,dot:!1,fill:`#3182bd`,fillOpacity:.6,hide:!1,isAnimationActive:`auto`,legendType:`line`,stroke:`#3182bd`,strokeWidth:1,type:`linear`,label:!1,shape:$ye,xAxisId:0,yAxisId:0,zIndex:qZ.area};function r5(e,t){return e&&e!==`none`?e:t}var obe=e=>{var t=e.dataKey,n=e.name,r=e.stroke,i=e.fill,a=e.legendType;return[{inactive:e.hide,dataKey:t,type:a,color:r5(r,i),value:bq(n,t),payload:e}]},sbe=v.memo(e=>{var t=e.dataKey,n=e.data,r=e.stroke,i=e.strokeWidth,a=e.fill,o=e.name,s=e.hide,c=e.unit,l=e.formatter,u=e.tooltipType,d=e.id,f={dataDefinedOnItem:n,getPosition:wU,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:t,nameKey:void 0,name:bq(o,t),hide:s,type:u,color:r5(r,a),unit:c,formatter:l,graphicalItemId:d}};return v.createElement(O6,{tooltipEntrySettings:f})});function cbe(e){var t=e.clipPathId,n=e.points,r=e.props,i=r.needClip,a=r.dot,o=r.dataKey,s=YH(r);return v.createElement(q6,{points:n,dot:a,className:`recharts-area-dots`,dotClassName:`recharts-area-dot`,dataKey:o,baseProps:s,needClip:i,clipPathId:t})}function lbe(e){var t=e.showLabels,n=e.children,r=e.points.map(e=>{var t={x:e.x??0,y:e.y??0,width:0,lowerWidth:0,upperWidth:0,height:0};return t5(t5({},t),{},{value:e.value,payload:e.payload,parentViewBox:void 0,viewBox:t,fill:void 0})});return v.createElement(h6,{value:t?r:void 0},n)}function ube(e){var t=e.points,n=e.baseLine,r=e.needClip,i=e.clipPathId,a=e.props,o=e.animationElapsedTime,s=e.isAnimating,c=e.isEntrance,l=a.layout,u=a.type,d=a.stroke,f=a.connectNulls,p=a.isRange,m=a.shape,h=a.id,g=$8(a,ebe),_=t5(t5({},ZH(g)),{},{id:h,points:t,connectNulls:f,type:u,baseLine:n,layout:l,stroke:d,isRange:p,animationElapsedTime:o,isAnimating:s,isEntrance:c});return v.createElement(v.Fragment,null,t?.length>1&&v.createElement(tU,{clipPath:r?`url(#clipPath-${i})`:void 0},v.createElement(D6,{option:m,DefaultShape:n5.shape,shapeProps:_})),v.createElement(cbe,{points:t,props:g,clipPathId:i}))}function dbe(e,t,n){return mU(e)?yU(mU(t)?t:void 0,e,n):xU(e)||fU(e)?yU(mU(t)?t:void 0,0,n):e}function fbe(e){var t=e.needClip,n=e.clipPathId,r=e.props,i=e.previousPointsRef,a=e.previousBaselineRef,o=r.points,s=r.baseLine,c=r.isAnimationActive,l=r.animationBegin,u=r.animationDuration,d=r.animationEasing,f=r.animationMatchBy,p=r.animationInterpolateFn,m=(0,v.useMemo)(()=>({points:o,baseLine:s}),[o,s]),h=P6(m,a),g=NJ(),_=I6(r.onAnimationStart,r.onAnimationEnd),y=_.isAnimating,b=_.handleAnimationStart,x=_.handleAnimationEnd,S=h.startValue;if(g==null)return null;var C=Array.isArray(s)&&Array.isArray(S)?N6(S,s,f):Array.isArray(s)?N6(null,s,f):null;return v.createElement(L6,{animationInput:m,animationIdPrefix:`recharts-area-`,items:o,previousItemsRef:i,isAnimationActive:c,animationBegin:l,animationDuration:u,animationEasing:d,onAnimationStart:b,onAnimationEnd:x,animationInterpolateFn:p,animationMatchBy:f,layout:g},(e,i,a)=>{var c=i===1?s:Array.isArray(s)?p(C,i,g):a?s:dbe(s,S,i);return h.syncStepValue(c,i),v.createElement(lbe,{showLabels:!y,points:o},r.children,v.createElement(ube,{points:e,baseLine:c,needClip:t,clipPathId:n,props:r,animationElapsedTime:i,isAnimating:y||i<1,isEntrance:a}),v.createElement(v6,{label:r.label}))})}function pbe(e){var t=e.needClip,n=e.clipPathId,r=e.props,i=(0,v.useRef)(null),a=(0,v.useRef)();return v.createElement(fbe,{needClip:t,clipPathId:n,props:r,previousPointsRef:i,previousBaselineRef:a})}var mbe=class extends v.PureComponent{render(){var e=this.props,t=e.hide,n=e.dot,r=e.points,i=e.className,a=e.top,o=e.left,s=e.needClip,c=e.xAxisId,l=e.yAxisId,u=e.width,d=e.height,f=e.id,p=e.baseLine,m=e.zIndex;if(t)return null;var h=xs(`recharts-area`,i),g=f,_=B8(n),y=_.r,b=_.strokeWidth,x=C6(n),S=y*2+b,C=s?`url(#clipPath-${x?``:`dots-`}${g})`:void 0;return v.createElement(m3,{zIndex:m},v.createElement(tU,{className:h},s&&v.createElement(`defs`,null,v.createElement(z8,{clipPathId:g,xAxisId:c,yAxisId:l}),!x&&v.createElement(`clipPath`,{id:`clipPath-dots-${g}`},v.createElement(`rect`,{x:o-S/2,y:a-S/2,width:u+S,height:d+S}))),v.createElement(pbe,{needClip:s,clipPathId:g,props:this.props})),v.createElement(t8,{points:r,mainColor:r5(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:C}),this.props.isRange&&Array.isArray(p)&&v.createElement(t8,{points:p,mainColor:r5(this.props.stroke,this.props.fill),itemDataKey:this.props.dataKey,activeDot:this.props.activeDot,clipPath:C}))}};function hbe(e){var t=e.activeDot,n=e.animationBegin,r=e.animationDuration,i=e.animationEasing,a=e.connectNulls,o=e.dot,s=e.fill,c=e.fillOpacity,l=e.hide,u=e.isAnimationActive,d=e.legendType,f=e.stroke,p=e.xAxisId,m=e.yAxisId,h=$8(e,tbe),g=MJ(),_=e3(),y=R8(p,m).needClip,b=Wq(),x=HW(t=>Kye(t,e.id,b))??{},S=x.points,C=x.isRange,w=x.baseLine,T=Q6();if(g!==`horizontal`&&g!==`vertical`||T==null||_!==`AreaChart`&&_!==`ComposedChart`)return null;var E=T.height,D=T.width,O=T.x,k=T.y;return!S||!S.length?null:v.createElement(mbe,Q8({},h,{activeDot:t,animationBegin:n,animationDuration:r,animationEasing:i,baseLine:w,connectNulls:a,dot:o,fill:s,fillOpacity:c,height:E,hide:l,layout:g,isAnimationActive:u,isRange:C,legendType:d,needClip:y,points:S,stroke:f,width:D,left:O,top:k,xAxisId:p,yAxisId:m}))}var gbe=(e,t,n,r,i)=>{var a=n??t;if(mU(a))return a;var o=e===`horizontal`?i:r,s=o.scale.domain();if(o.type===`number`){var c=Math.max(s[0],s[1]),l=Math.min(s[0],s[1]);return a===`dataMin`?l:a===`dataMax`||c<0?c:Math.max(Math.min(s[0],s[1]),0)}return a===`dataMin`?s[0]:a===`dataMax`?s[1]:s[0]};function _be(e){var t=e.areaSettings,n=t.connectNulls,r=t.baseValue,i=t.dataKey,a=e.stackedData,o=e.layout,s=e.chartBaseValue,c=e.xAxis,l=e.yAxis,u=e.displayedData,d=e.dataStartIndex,f=e.xAxisTicks,p=e.yAxisTicks,m=e.bandSize,h=e.stackDataKeys,g=a&&a.length,_=gbe(o,s,r,c,l),v=o===`horizontal`,y=!1,b=u.map((e,t)=>{var r;if(g)r=a[d+t];else{var o=oq(e,i);Array.isArray(o)?(r=o,y=!0):r=[_,o]}var s=r?.[1]??null,u=oq(e,i),b=g&&u==null&&h!=null&&h.length>0&&h.every(t=>oq(e,t)==null),x=s==null||g&&!n&&u==null||b;return v?{x:fq({axis:c,ticks:f,bandSize:m,entry:e,index:t}),y:x?null:l.scale.map(s)??null,value:r,payload:e}:{x:x?null:c.scale.map(s)??null,y:fq({axis:l,ticks:p,bandSize:m,entry:e,index:t}),value:r,payload:e}});return{points:b,baseLine:(g||y?b.map(e=>{var t=Array.isArray(e.value)?e.value[0]:null;return v?{x:e.x,y:t!=null&&e.y!=null?l.scale.map(t)??null:null,payload:e.payload}:{x:t==null?null:c.scale.map(t)??null,y:e.y,payload:e.payload}}):v?l.scale.map(_):c.scale.map(_))??0,isRange:y}}function vbe(e){var t=lW(e,n5),n=Wq();return v.createElement(B6,{id:t.id,type:`area`},e=>v.createElement(v.Fragment,null,v.createElement(k6,{legendPayload:obe(t)}),v.createElement(sbe,{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}),v.createElement(U6,{type:`area`,id:e,data:t.data,dataKey:t.dataKey,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,stackId:dq(t.stackId),hide:t.hide,barSize:void 0,baseValue:t.baseValue,isPanorama:n,connectNulls:t.connectNulls}),v.createElement(hbe,Q8({},t,{id:e}))))}var i5=v.memo(vbe,sY);i5.displayName=`Area`;var ybe=[`domain`,`range`],bbe=[`domain`,`range`];function a5(e,t){if(e==null)return{};var n,r,i=xbe(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r{if(o!=null)return u5(u5({},a),{},{type:o})},[a,o]);return(0,v.useLayoutEffect)(()=>{s!=null&&(n.current===null?t(dve(s)):n.current!==s&&t(fve({prev:n.current,next:s})),n.current=s)},[s,t]),(0,v.useLayoutEffect)(()=>()=>{n.current&&=(t(pve(n.current)),null)},[t]),null}var Abe=e=>{var t=e.xAxisId,n=e.className,r=e.height,i=e.label,a=(0,v.useRef)(null),o=(0,v.useRef)(null),s=HW(Hq),c=Wq(),l=BW(),u=`xAxis`,d=HW(e=>a4(e,u,t,c)),f=HW(e=>jme(e,t)),p=HW(e=>Ime(e,t)),m=HW(e=>J0(e,t));if((0,v.useLayoutEffect)(()=>{if(!(r!==`auto`||!f||c6(i)||(0,v.isValidElement)(i)||m==null)){var e=a.current;if(e){var n=e.getCalculatedHeight();Math.round(f.height)!==Math.round(n)&&l(vve({id:t,height:n}))}}},[d,f,l,i,t,r,m]),f==null||p==null||m==null)return null;e.dangerouslySetInnerHTML,e.ticks,e.scale;var h=d5(e,Cbe);m.id,m.scale;var g=d5(m,wbe);return v.createElement(F8,c5({},h,g,{ref:a,labelRef:o,x:p.x,y:p.y,width:f.width,height:f.height,className:xs(`recharts-${u} ${u}`,n),viewBox:s,ticks:d,axisType:u,axisId:t}))},jbe={allowDataOverflow:q0.allowDataOverflow,allowDecimals:q0.allowDecimals,allowDuplicatedCategory:q0.allowDuplicatedCategory,angle:q0.angle,axisLine:P8.axisLine,height:q0.height,hide:!1,includeHidden:q0.includeHidden,interval:q0.interval,label:!1,minTickGap:q0.minTickGap,mirror:q0.mirror,orientation:q0.orientation,padding:q0.padding,reversed:q0.reversed,scale:q0.scale,tick:q0.tick,tickCount:q0.tickCount,tickLine:P8.tickLine,tickSize:P8.tickSize,type:q0.type,niceTicks:q0.niceTicks,xAxisId:0},f5=v.memo(e=>{var t=lW(e,jbe);return v.createElement(v.Fragment,null,v.createElement(kbe,{allowDataOverflow:t.allowDataOverflow,allowDecimals:t.allowDecimals,allowDuplicatedCategory:t.allowDuplicatedCategory,angle:t.angle,dataKey:t.dataKey,domain:t.domain,height:t.height,hide:t.hide,id:t.xAxisId,includeHidden:t.includeHidden,interval:t.interval,minTickGap:t.minTickGap,mirror:t.mirror,name:t.name,orientation:t.orientation,padding:t.padding,reversed:t.reversed,scale:t.scale,tick:t.tick,tickCount:t.tickCount,tickFormatter:t.tickFormatter,ticks:t.ticks,type:t.type,unit:t.unit,niceTicks:t.niceTicks}),v.createElement(Abe,t))},s5);f5.displayName=`XAxis`;var Mbe=[`type`],Nbe=[`dangerouslySetInnerHTML`,`ticks`,`scale`],Pbe=[`id`,`scale`];function p5(){return p5=Object.assign?Object.assign.bind():function(e){for(var t=1;t{if(o!=null)return h5(h5({},a),{},{type:o})},[o,a]);return(0,v.useLayoutEffect)(()=>{s!=null&&(n.current===null?t(mve(s)):n.current!==s&&t(hve({prev:n.current,next:s})),n.current=s)},[s,t]),(0,v.useLayoutEffect)(()=>()=>{n.current&&=(t(gve(n.current)),null)},[t]),null}function Bbe(e){var t=e.yAxisId,n=e.className,r=e.width,i=e.label,a=(0,v.useRef)(null),o=(0,v.useRef)(null),s=HW(Hq),c=Wq(),l=BW(),u=`yAxis`,d=HW(e=>Rme(e,t)),f=HW(e=>Lme(e,t)),p=HW(e=>a4(e,u,t,c)),m=HW(e=>Z0(e,t));if((0,v.useLayoutEffect)(()=>{if(!(r!==`auto`||!d||c6(i)||(0,v.isValidElement)(i)||m==null)){var e=a.current;if(e){var n=e.getCalculatedWidth();Math.round(d.width)!==Math.round(n)&&l(_ve({id:t,width:n}))}}},[p,d,l,i,t,r,m]),d==null||f==null||m==null)return null;e.dangerouslySetInnerHTML,e.ticks,e.scale;var h=g5(e,Nbe);m.id,m.scale;var g=g5(m,Pbe);return v.createElement(F8,p5({},h,g,{ref:a,labelRef:o,x:f.x,y:f.y,tickTextProps:r===`auto`?{width:void 0}:{width:r},width:d.width,height:d.height,className:xs(`recharts-${u} ${u}`,n),viewBox:s,ticks:p,axisType:u,axisId:t}))}var Vbe={allowDataOverflow:X0.allowDataOverflow,allowDecimals:X0.allowDecimals,allowDuplicatedCategory:X0.allowDuplicatedCategory,angle:X0.angle,axisLine:P8.axisLine,hide:!1,includeHidden:X0.includeHidden,interval:X0.interval,label:!1,minTickGap:X0.minTickGap,mirror:X0.mirror,orientation:X0.orientation,padding:X0.padding,reversed:X0.reversed,scale:X0.scale,tick:X0.tick,tickCount:X0.tickCount,tickLine:P8.tickLine,tickSize:P8.tickSize,type:X0.type,niceTicks:X0.niceTicks,width:X0.width,yAxisId:0},_5=v.memo(e=>{var t=lW(e,Vbe);return v.createElement(v.Fragment,null,v.createElement(zbe,{interval:t.interval,id:t.yAxisId,scale:t.scale,type:t.type,domain:t.domain,allowDataOverflow:t.allowDataOverflow,dataKey:t.dataKey,allowDuplicatedCategory:t.allowDuplicatedCategory,allowDecimals:t.allowDecimals,tickCount:t.tickCount,padding:t.padding,includeHidden:t.includeHidden,reversed:t.reversed,ticks:t.ticks,width:t.width,orientation:t.orientation,mirror:t.mirror,hide:t.hide,unit:t.unit,name:t.name,angle:t.angle,minTickGap:t.minTickGap,tick:t.tick,tickFormatter:t.tickFormatter,niceTicks:t.niceTicks}),v.createElement(Bbe,t))},s5);_5.displayName=`YAxis`;var v5=$([(e,t)=>t,jJ,pQ,SQ,V4,U4,jhe,Bq],Rhe);function Hbe(e){return`getBBox`in e.currentTarget&&typeof e.currentTarget.getBBox==`function`}function y5(e){var t=e.currentTarget.getBoundingClientRect(),n,r;if(Hbe(e)){var i=e.currentTarget.getBBox();n=i.width>0?t.width/i.width:1,r=i.height>0?t.height/i.height:1}else{var a=e.currentTarget;n=a.offsetWidth>0?t.width/a.offsetWidth:1,r=a.offsetHeight>0?t.height/a.offsetHeight:1}var o=(e,i)=>({relativeX:Math.round((e-t.left)/n),relativeY:Math.round((i-t.top)/r)});return`touches`in e?Array.from(e.touches).map(e=>o(e.clientX,e.clientY)):o(e.clientX,e.clientY)}var b5=_K(`mouseClick`),x5=ZK();x5.startListening({actionCreator:b5,effect:(e,t)=>{var n=e.payload,r=v5(t.getState(),y5(n));r?.activeIndex!=null&&t.dispatch(Jme({activeIndex:r.activeIndex,activeDataKey:void 0,activeCoordinate:r.activeCoordinate}))}});var S5=_K(`mouseMove`),C5=ZK(),w5=null,T5=null,E5=null;C5.startListening({actionCreator:S5,effect:(e,t)=>{var n=e.payload,r=t.getState().eventSettings,i=r.throttleDelay,a=r.throttledEvents,o=a===`all`||a?.includes(`mousemove`);w5!==null&&(cancelAnimationFrame(w5),w5=null),T5!==null&&(typeof i!=`number`||!o)&&(clearTimeout(T5),T5=null),E5=y5(n);var s=()=>{var e=t.getState(),n=d4(e,e.tooltip.settings.shared);if(!E5){w5=null,T5=null;return}if(n===`axis`){var r=v5(e,E5);r?.activeIndex==null?t.dispatch(g4()):t.dispatch(_4({activeIndex:r.activeIndex,activeDataKey:void 0,activeCoordinate:r.activeCoordinate}))}w5=null,T5=null};if(!o){s();return}i===`raf`?w5=requestAnimationFrame(s):typeof i==`number`&&T5===null&&(T5=setTimeout(s,i))}});function Ube(e,t){return t instanceof HTMLElement?`HTMLElement <${t.tagName} class="${t.className}">`:t===window?`global.window`:e===`children`&&typeof t==`object`&&t?`<>`:t}var D5={accessibilityLayer:!0,barCategoryGap:`10%`,barGap:4,barSize:void 0,className:void 0,maxBarSize:void 0,stackOffset:`none`,syncId:void 0,syncMethod:`index`,baseValue:void 0,reverseStackOrder:!1},O5=EK({name:`rootProps`,initialState:D5,reducers:{updateOptions:(e,t)=>{e.accessibilityLayer=t.payload.accessibilityLayer,e.barCategoryGap=t.payload.barCategoryGap,e.barGap=t.payload.barGap??D5.barGap,e.barSize=t.payload.barSize,e.maxBarSize=t.payload.maxBarSize,e.stackOffset=t.payload.stackOffset,e.syncId=t.payload.syncId,e.syncMethod=t.payload.syncMethod,e.className=t.payload.className,e.baseValue=t.payload.baseValue,e.reverseStackOrder=t.payload.reverseStackOrder}}}),Wbe=O5.reducer,Gbe=O5.actions.updateOptions,k5=EK({name:`polarOptions`,initialState:null,reducers:{updatePolarOptions:(e,t)=>e===null?t.payload:(e.startAngle=t.payload.startAngle,e.endAngle=t.payload.endAngle,e.cx=t.payload.cx,e.cy=t.payload.cy,e.innerRadius=t.payload.innerRadius,e.outerRadius=t.payload.outerRadius,e)}});k5.actions.updatePolarOptions;var Kbe=k5.reducer,A5=_K(`keyDown`),j5=_K(`focus`),M5=_K(`blur`),N5=ZK(),P5=null,F5=null,I5=null;N5.startListening({actionCreator:A5,effect:(e,t)=>{I5=e.payload,P5!==null&&(cancelAnimationFrame(P5),P5=null);var n=t.getState().eventSettings,r=n.throttleDelay,i=n.throttledEvents,a=i===`all`||i.includes(`keydown`);F5!==null&&(typeof r!=`number`||!a)&&(clearTimeout(F5),F5=null);var o=()=>{try{var e=t.getState();if(e.rootProps.accessibilityLayer===!1)return;var n=e.tooltip.keyboardInteraction,r=I5;if(r!==`ArrowRight`&&r!==`ArrowLeft`&&r!==`Enter`)return;var i=C4(n,F4(e),b2(e),z4(e)),a=i==null?-1:Number(i),o=!Number.isFinite(a)||a<0,s=U4(e),c=F4(e),l=d4(e,e.tooltip.settings.shared);if(r===`Enter`){if(o)return;var u=s3(e,l,`hover`,String(n.index));t.dispatch(y4({active:!n.active,activeIndex:n.index,activeCoordinate:u}));return}var d=Bme(e)===`left-to-right`?1:-1,f=r===`ArrowRight`?1:-1,p;if(o){var m=b2(e),h=z4(e),g=f*d,_=e=>({active:!1,index:String(e),dataKey:void 0,graphicalItemId:void 0,coordinate:void 0});if(p=-1,g>0){for(var v=0;v=0;y--)if(C4(_(y),c,m,h)!=null){p=y;break}if(p<0)return}else{p=a+f*d;var b=s?.length||c.length;if(b===0||p>=b||p<0)return}var x=s3(e,l,`hover`,String(p));t.dispatch(y4({active:!0,activeIndex:p.toString(),activeCoordinate:x}))}finally{P5=null,F5=null}};if(!a){o();return}r===`raf`?P5=requestAnimationFrame(o):typeof r==`number`&&F5===null&&(o(),I5=null,F5=setTimeout(()=>{I5?o():(F5=null,P5=null)},r))}}),N5.startListening({actionCreator:j5,effect:(e,t)=>{var n=t.getState();if(n.rootProps.accessibilityLayer!==!1){var r=n.tooltip.keyboardInteraction;if(!r.active&&r.index==null){var i=`0`,a=s3(n,d4(n,n.tooltip.settings.shared),`hover`,String(i));t.dispatch(y4({active:!0,activeIndex:i,activeCoordinate:a}))}}}}),N5.startListening({actionCreator:M5,effect:(e,t)=>{var n=t.getState();if(n.rootProps.accessibilityLayer!==!1){var r=n.tooltip.keyboardInteraction;r.active&&t.dispatch(y4({active:!1,activeIndex:r.index,activeCoordinate:r.coordinate}))}}});function L5(e){e.persist();var t=e.currentTarget;return new Proxy(e,{get:(e,n)=>{if(n===`currentTarget`)return t;var r=Reflect.get(e,n);return typeof r==`function`?r.bind(e):r}})}var R5=_K(`externalEvent`),z5=ZK(),B5=new Map,V5=new Map,H5=new Map;z5.startListening({actionCreator:R5,effect:(e,t)=>{var n=e.payload,r=n.handler,i=n.reactEvent;if(r!=null){var a=i.type,o=L5(i);H5.set(a,{handler:r,reactEvent:o});var s=B5.get(a);s!==void 0&&(cancelAnimationFrame(s),B5.delete(a));var c=t.getState().eventSettings,l=c.throttleDelay,u=c.throttledEvents,d=u===`all`||u?.includes(a),f=V5.get(a);f!==void 0&&(typeof l!=`number`||!d)&&(clearTimeout(f),V5.delete(a));var p=()=>{var e=H5.get(a);try{if(!e)return;var n=e.handler,r=e.reactEvent,i=t.getState(),o={activeCoordinate:She(i),activeDataKey:bhe(i),activeIndex:J4(i),activeLabel:Y4(i),activeTooltipIndex:J4(i),isTooltipActive:Che(i)};n&&n(o,r)}finally{B5.delete(a),V5.delete(a),H5.delete(a)}};if(!d){p();return}if(l===`raf`){var m=requestAnimationFrame(p);B5.set(a,m)}else if(typeof l==`number`){if(!V5.has(a)){p();var h=setTimeout(p,l);V5.set(a,h)}}else p()}}});var qbe=$([$([D4],e=>e.tooltipItemPayloads),(e,t)=>t,(e,t,n)=>n],(e,t,n)=>{if(t!=null){var r=e.find(e=>e.settings.graphicalItemId===n);if(r!=null){var i=r.getPosition;if(i!=null)return i(t)}}}),U5=_K(`touchMove`),W5=ZK(),G5=null,K5=null,q5=null,J5=null;W5.startListening({actionCreator:U5,effect:(e,t)=>{var n=e.payload;if(n.touches!=null&&n.touches.length!==0){J5=L5(n);var r=t.getState().eventSettings,i=r.throttleDelay,a=r.throttledEvents,o=a===`all`||a.includes(`touchmove`);G5!==null&&(cancelAnimationFrame(G5),G5=null),K5!==null&&(typeof i!=`number`||!o)&&(clearTimeout(K5),K5=null),q5=Array.from(n.touches).map(e=>y5({clientX:e.clientX,clientY:e.clientY,currentTarget:n.currentTarget}));var s=()=>{if(J5!=null){var e=t.getState(),n=d4(e,e.tooltip.settings.shared);if(n===`axis`){var r=q5?.[0];if(r==null){G5=null,K5=null;return}var i=v5(e,r);i?.activeIndex!=null&&t.dispatch(_4({activeIndex:i.activeIndex,activeDataKey:void 0,activeCoordinate:i.activeCoordinate}))}else if(n===`item`){var a=J5.touches[0];if(document.elementFromPoint==null||a==null)return;var o=document.elementFromPoint(a.clientX,a.clientY);if(!o||!o.getAttribute)return;var s=o.getAttribute(kq),c=o.getAttribute(`data-recharts-item-id`)??void 0,l=N4(e).find(e=>e.id===c);if(s==null||l==null||c==null)return;var u=l.dataKey,d=qbe(e,s,c);t.dispatch(qme({activeDataKey:u,activeIndex:s,activeCoordinate:d,activeGraphicalItemId:c}))}G5=null,K5=null}};if(!o){s();return}i===`raf`?G5=requestAnimationFrame(s):typeof i==`number`&&K5===null&&(s(),J5=null,K5=setTimeout(()=>{J5?s():(K5=null,G5=null)},i))}}});var Y5={throttleDelay:`raf`,throttledEvents:[`mousemove`,`touchmove`,`pointermove`,`scroll`,`wheel`]},X5=EK({name:`eventSettings`,initialState:Y5,reducers:{setEventSettings:(e,t)=>{t.payload.throttleDelay!=null&&(e.throttleDelay=t.payload.throttleDelay),t.payload.throttledEvents!=null&&(e.throttledEvents=hK(t.payload.throttledEvents))}}}),Jbe=X5.actions.setEventSettings,Ybe=X5.reducer,Xbe=iG({brush:Dve,cartesianAxis:yve,chartData:rge,errorBars:Uye,eventSettings:Ybe,graphicalItems:$_e,layout:dde,legend:HJ,options:$he,polarAxis:y_e,polarOptions:Kbe,referenceElements:Fve,renderedTicks:wye,rootProps:Wbe,tooltip:Yme,zIndex:Xhe}),Zbe=function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:`Chart`;return Lue({reducer:Xbe,preloadedState:e,middleware:e=>e({serializableCheck:!1,immutableCheck:![`commonjs`,`es6`,`production`].includes(`es6`)}).concat([x5.middleware,C5.middleware,N5.middleware,z5.middleware,W5.middleware]),enhancers:e=>{var t=e;return typeof e==`function`&&(t=e()),t.concat(wK({type:`raf`}))},devTools:cY.devToolsEnabled&&{serialize:{replacer:Ube},name:`recharts-${t}`}})};function Qbe(e){var t=e.preloadedState,n=e.children,r=e.reduxStoreName,i=Wq(),a=(0,v.useRef)(null);if(i)return n;a.current??=Zbe(t,r);var o=zW;return v.createElement(iY,{context:o,store:a.current},n)}function $be(e){var t=e.layout,n=e.margin,r=BW(),i=Wq();return(0,v.useEffect)(()=>{i||(r(cde(t)),r(sde(n)))},[r,i,t,n]),null}var exe=(0,v.memo)($be,sY);function txe(e){var t=BW();return(0,v.useEffect)(()=>{t(Gbe(e))},[t,e]),null}var nxe=(0,v.memo)(e=>{var t=BW();return(0,v.useEffect)(()=>{t(Jbe(e))},[t,e]),null},sY);function Z5(e){var t=e.zIndex,n=e.isPanorama,r=(0,v.useRef)(null),i=BW();return(0,v.useLayoutEffect)(()=>(r.current&&i(Jhe({zIndex:t,element:r.current,isPanorama:n})),()=>{i(Yhe({zIndex:t,isPanorama:n}))}),[i,t,n]),v.createElement(`g`,{tabIndex:-1,ref:r,className:`recharts-zIndex-layer_${t}`})}function Q5(e){var t=e.children,n=e.isPanorama,r=HW(Bhe);if(!r||r.length===0)return t;var i=r.filter(e=>e<0),a=r.filter(e=>e>0);return v.createElement(v.Fragment,null,i.map(e=>v.createElement(Z5,{key:e,zIndex:e,isPanorama:n})),t,a.map(e=>v.createElement(Z5,{key:e,zIndex:e,isPanorama:n})))}var rxe=[`children`];function ixe(e,t){if(e==null)return{};var n,r,i=axe(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r{var n=kJ(),r=AJ(),i=gY();if(!rq(n)||!rq(r))return null;var a=e.children,o=e.otherAttributes,s=e.title,c=e.desc,l,u;return o!=null&&(l=typeof o.tabIndex==`number`?o.tabIndex:i?0:void 0,u=typeof o.role==`string`?o.role:i?`application`:void 0),v.createElement($H,$5({},o,{title:s,desc:c,role:u,tabIndex:l,width:n,height:r,style:oxe,ref:t}),a)}),cxe=e=>{var t=e.children,n=HW(Kq);if(!n)return null;var r=n.width,i=n.height,a=n.y,o=n.x;return v.createElement($H,{width:r,height:i,x:o,y:a},t)},e7=(0,v.forwardRef)((e,t)=>{var n=e.children,r=ixe(e,rxe);return Wq()?v.createElement(cxe,null,v.createElement(Q5,{isPanorama:!0},n)):v.createElement(sxe,$5({ref:t},r),v.createElement(Q5,{isPanorama:!1},n))});function lxe(e,t){return pxe(e)||fxe(e,t)||dxe(e,t)||uxe()}function uxe(){throw TypeError(`Invalid attempt to destructure non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function dxe(e,t){if(e){if(typeof e==`string`)return t7(e,t);var n={}.toString.call(e).slice(8,-1);return n===`Object`&&e.constructor&&(n=e.constructor.name),n===`Map`||n===`Set`?Array.from(e):n===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?t7(e,t):void 0}}function t7(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n{if(n!=null){var t=n.getBoundingClientRect().width/n.offsetWidth;nq(t)&&t!==i&&e(ude(t))}},[n,e,i]),r}function n7(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 hxe(e){for(var t=1;te.length)&&(t=e.length);for(var n=0,r=Array(t);n(fge(),null);function o7(e){if(typeof e==`number`)return e;if(typeof e==`string`){var t=parseFloat(e);if(!Number.isNaN(t))return t}return 0}var wxe=(0,v.forwardRef)((e,t)=>{var n=(0,v.useRef)(null),r=i7((0,v.useState)({containerWidth:o7(e.style?.width),containerHeight:o7(e.style?.height)}),2),i=r[0],a=r[1],o=(0,v.useCallback)((e,t)=>{a(n=>{var r=Math.round(e),i=Math.round(t);return n.containerWidth===r&&n.containerHeight===i?n:{containerWidth:r,containerHeight:i}})},[]),s=(0,v.useCallback)(e=>{if(typeof t==`function`&&t(e),n.current!=null&&(n.current.disconnect(),n.current=null),e!=null&&typeof ResizeObserver<`u`){var r=e.getBoundingClientRect(),i=r.width,a=r.height;o(i,a);var s=new ResizeObserver(e=>{var t=e[0];if(t!=null){var n=t.contentRect,r=n.width,i=n.height;o(r,i)}});s.observe(e),n.current=s}},[t,o]);return(0,v.useEffect)(()=>()=>{n.current?.disconnect()},[o]),v.createElement(v.Fragment,null,v.createElement(IJ,{width:i.containerWidth,height:i.containerHeight}),v.createElement(`div`,r7({ref:s},e)))}),Txe=(0,v.forwardRef)((e,t)=>{var n=e.width,r=e.height,i=i7((0,v.useState)({containerWidth:o7(n),containerHeight:o7(r)}),2),a=i[0],o=i[1],s=(0,v.useCallback)((e,t)=>{o(n=>{var r=Math.round(e),i=Math.round(t);return n.containerWidth===r&&n.containerHeight===i?n:{containerWidth:r,containerHeight:i}})},[]),c=(0,v.useCallback)(e=>{if(typeof t==`function`&&t(e),e!=null){var n=e.getBoundingClientRect(),r=n.width,i=n.height;s(r,i)}},[t,s]);return v.createElement(v.Fragment,null,v.createElement(IJ,{width:a.containerWidth,height:a.containerHeight}),v.createElement(`div`,r7({ref:c},e)))}),Exe=(0,v.forwardRef)((e,t)=>{var n=e.width,r=e.height;return v.createElement(v.Fragment,null,v.createElement(IJ,{width:n,height:r}),v.createElement(`div`,r7({ref:t},e)))}),Dxe=(0,v.forwardRef)((e,t)=>{var n=e.width,r=e.height;return typeof n==`string`||typeof r==`string`?v.createElement(Txe,r7({},e,{ref:t})):typeof n==`number`&&typeof r==`number`?v.createElement(Exe,r7({},e,{width:n,height:r,ref:t})):v.createElement(v.Fragment,null,v.createElement(IJ,{width:n,height:r}),v.createElement(`div`,r7({ref:t},e)))});function s7(e){return e?wxe:Dxe}var Oxe=(0,v.forwardRef)((e,t)=>{var n=e.children,r=e.className,i=e.height,a=e.onClick,o=e.onContextMenu,s=e.onDoubleClick,c=e.onMouseDown,l=e.onMouseEnter,u=e.onMouseLeave,d=e.onMouseMove,f=e.onMouseUp,p=e.onTouchEnd,m=e.onTouchMove,h=e.onTouchStart,g=e.style,_=e.width,y=e.responsive,b=e.dispatchTouchEvents,x=b===void 0||b,S=(0,v.useRef)(null),C=BW(),w=i7((0,v.useState)(null),2),T=w[0],E=w[1],D=i7((0,v.useState)(null),2),O=D[0],k=D[1],A=mxe(),j=CJ(),M=j?.width>0?j.width:_,N=j?.height>0?j.height:i,P=(0,v.useCallback)(e=>{A(e),typeof t==`function`&&t(e),E(e),k(e),e!=null&&(S.current=e)},[A,t,E,k]),F=(0,v.useCallback)(e=>{C(b5(e)),C(R5({handler:a,reactEvent:e}))},[C,a]),I=(0,v.useCallback)(e=>{C(S5(e)),C(R5({handler:l,reactEvent:e}))},[C,l]),L=(0,v.useCallback)(e=>{C(g4()),C(R5({handler:u,reactEvent:e}))},[C,u]),R=(0,v.useCallback)(e=>{C(S5(e)),C(R5({handler:d,reactEvent:e}))},[C,d]),z=(0,v.useCallback)(()=>{C(j5())},[C]),B=(0,v.useCallback)(()=>{C(M5())},[C]),V=(0,v.useCallback)(e=>{C(A5(e.key))},[C]),H=(0,v.useCallback)(e=>{C(R5({handler:o,reactEvent:e}))},[C,o]),ee=(0,v.useCallback)(e=>{C(R5({handler:s,reactEvent:e}))},[C,s]),te=(0,v.useCallback)(e=>{C(R5({handler:c,reactEvent:e}))},[C,c]),ne=(0,v.useCallback)(e=>{C(R5({handler:f,reactEvent:e}))},[C,f]),re=(0,v.useCallback)(e=>{C(R5({handler:h,reactEvent:e}))},[C,h]),ie=(0,v.useCallback)(e=>{x&&C(U5(e)),C(R5({handler:m,reactEvent:e}))},[C,x,m]),ae=(0,v.useCallback)(e=>{C(R5({handler:p,reactEvent:e}))},[C,p]),oe=s7(y);return v.createElement(h3.Provider,{value:T},v.createElement(fle.Provider,{value:O},v.createElement(oe,{width:M??g?.width,height:N??g?.height,className:xs(`recharts-wrapper`,r),style:hxe({position:`relative`,cursor:`default`,width:M,height:N},g),onClick:F,onContextMenu:H,onDoubleClick:ee,onFocus:z,onBlur:B,onKeyDown:V,onMouseDown:te,onMouseEnter:I,onMouseLeave:L,onMouseMove:R,onMouseUp:ne,onTouchEnd:ae,onTouchMove:ie,onTouchStart:re,ref:P},v.createElement(Cxe,null),n)))}),kxe=[`width`,`height`,`responsive`,`children`,`className`,`style`,`compact`,`title`,`desc`];function Axe(e,t){if(e==null)return{};var n,r,i=jxe(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r{var n=e.width,r=e.height,i=e.responsive,a=e.children,o=e.className,s=e.style,c=e.compact,l=e.title,u=e.desc,d=YH(Axe(e,kxe));return c?v.createElement(v.Fragment,null,v.createElement(IJ,{width:n,height:r}),v.createElement(e7,{otherAttributes:d,title:l,desc:u},a)):v.createElement(Oxe,{className:o,style:s,width:n,height:r,responsive:i??!1,onClick:e.onClick,onMouseLeave:e.onMouseLeave,onMouseEnter:e.onMouseEnter,onMouseMove:e.onMouseMove,onMouseDown:e.onMouseDown,onMouseUp:e.onMouseUp,onContextMenu:e.onContextMenu,onDoubleClick:e.onDoubleClick,onTouchStart:e.onTouchStart,onTouchMove:e.onTouchMove,onTouchEnd:e.onTouchEnd},v.createElement(e7,{otherAttributes:d,title:l,desc:u,ref:t},v.createElement(Vve,null,a)))});function c7(){return c7=Object.assign?Object.assign.bind():function(e){for(var t=1;tv.createElement(u7,{chartName:`AreaChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:Rxe,tooltipPayloadSearcher:y3,categoricalChartProps:e,ref:t})),f7={generatedAt:0,backpressure:6,throughputPerMin:42,waitP95Ms:2800,totals:{done:186,failed:4},workers:[{id:`acc-wb-a1`,name:`wb-a1`,provider:`workbuddy`,busy:!0,progress:.72,jobId:`j1`,concurrency:4,inFlight:3},{id:`acc-wb-a2`,name:`wb-a2`,provider:`workbuddy`,busy:!0,progress:.41,jobId:`j2`,rateLimited:!0,concurrency:2,inFlight:1},{id:`acc-qd-b1`,name:`qd-b1`,provider:`qoder`,busy:!0,progress:.88,jobId:`j3`,concurrency:1,inFlight:1},{id:`acc-qd-b2`,name:`qd-b2`,provider:`qoder`,busy:!1,progress:0,concurrency:4,inFlight:0},{id:`acc-trae-c1`,name:`trae-c1`,provider:`trae`,busy:!0,progress:.23,jobId:`j4`,concurrency:3,inFlight:2},{id:`acc-codex-d1`,name:`codex-d1`,provider:`codex`,busy:!1,progress:0,rateLimited:!0,concurrency:2,inFlight:0}],jobs:[{id:`j1`,name:`chat · sonnet`,kind:`chat`,status:`running`,accountId:`acc-wb-a1`,progress:.72,elapsedMs:11200,sticky:!0},{id:`j2`,name:`embed · batch`,kind:`embed`,status:`running`,accountId:`acc-wb-a2`,progress:.41,elapsedMs:9400},{id:`j3`,name:`chat · gpt`,kind:`chat`,status:`running`,accountId:`acc-qd-b1`,progress:.88,elapsedMs:6200},{id:`j4`,name:`tools · patch`,kind:`tools`,status:`running`,accountId:`acc-trae-c1`,progress:.23,elapsedMs:3100},{id:`j5`,name:`chat · wait`,kind:`chat`,status:`queued`,progress:0,elapsedMs:7200},{id:`j6`,name:`retry · cool`,kind:`chat`,status:`queued`,progress:0,elapsedMs:5100},{id:`j7`,name:`chat · sticky`,kind:`chat`,status:`queued`,progress:0,elapsedMs:2800,sticky:!0,priority:`high`},{id:`j8`,name:`embed · docs`,kind:`embed`,status:`queued`,progress:0,elapsedMs:1400},{id:`j9`,name:`tools · apply`,kind:`tools`,status:`queued`,progress:0,elapsedMs:900},{id:`j10`,name:`chat · flash`,kind:`chat`,status:`queued`,progress:0,elapsedMs:600},{id:`j11`,name:`embed · idx`,kind:`embed`,status:`queued`,progress:0,elapsedMs:400},{id:`j12`,name:`chat · opus`,kind:`chat`,status:`queued`,progress:0,elapsedMs:200,priority:`high`}],rateLimits:[{id:`rl1`,label:`wb-a2 限流`,remainingMs:97e3,from:.55,until:.72},{id:`rl2`,label:`codex-d1 冷却`,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]},p7=[{name:`chat · opus`,kind:`chat`},{name:`embed · idx`,kind:`embed`},{name:`tools · apply`,kind:`tools`},{name:`chat · flash`,kind:`chat`,sticky:!0},{name:`chat · wait`,kind:`chat`},{name:`embed · docs`,kind:`embed`}],m7=100;function h7(e=f7){return{...e,workers:e.workers.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 zxe(){return h7()}function Bxe(e,t){let n=Math.max(16,Math.min(500,t)),r=h7(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(`wb-a2`)):e.id===`acc-codex-d1`&&(e.rateLimited=r.rateLimits.some(e=>e.label.includes(`codex-d1`)));let i=new Map(r.jobs.map(e=>[e.id,e]));for(let e of r.workers){if(!e.busy||!e.jobId)continue;let t=i.get(e.jobId);if(!t||t.status!==`running`||(t.elapsedMs+=n,e.rateLimited))continue;let r=.045+e.id.charCodeAt(e.id.length-1)%5*.008;e.progress=Math.min(1,e.progress+n/1e3*r),t.progress=e.progress}let a=[];for(let e of r.workers){if(!e.busy||!e.jobId||e.rateLimited||e.progress<.995)continue;let t=(e.jobId.charCodeAt(1)+Math.floor(r.generatedAt/1e3))%9!=0;a.push({jobId:e.jobId,workerId:e.id,ok:t})}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.busy=!1,n.progress=0,n.jobId=void 0,n.inFlight=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.busy||e.rateLimited)continue;let t=s.shift();if(!t)break;t.status=`running`,t.accountId=e.id,t.progress=.04,t.elapsedMs=0,e.busy=!0,e.progress=.04,e.jobId=t.id;let n=g7(e.concurrency??1);e.inFlight=Math.min(n,Math.max(1,e.inFlight??1))}if(r.jobs.filter(e=>e.status===`queued`).length<6&&r.generatedAt%2800e.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+(m7%3-1))),r.waitP95Ms=Math.max(900,Math.min(5200,r.waitP95Ms+(l>4?40:-20))),r}function g7(e){return e==null||!Number.isFinite(e)?1:Math.max(1,Math.min(16,Math.floor(e)))}function Vxe(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=g7(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 Hxe(e,t){let n=Date.now(),r=new Map(e.jobs.map(e=>[e.id,e])),i=t.workers.map(e=>{let t=g7(e.max_inflight??4),n=e.in_flight!=null&&Number.isFinite(e.in_flight)?Math.max(0,Math.floor(e.in_flight)):+!!e.busy,r=Math.min(t,n);return{id:e.id,name:e.name,provider:e.provider,busy:e.busy||r>0,progress:e.busy||r>0?Math.max(.04,Math.min(1,e.progress||0)):0,rateLimited:e.rate_limited,jobId:e.busy||r>0?`live-${e.id}`:void 0,concurrency:t,inFlight:r}}),a=Math.max(1,f7.depthSeries.length),o=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)}}),s=i.filter(e=>e.busy&&e.jobId).map(e=>{let i=e.jobId,a=r.get(i),o=t.workers.find(t=>t.id===e.id),s,c=o?.started_at?.trim();if(c){let e=Date.parse(c);Number.isNaN(e)||(s=e)}return s==null&&a?.startedAtMs!=null&&(s=a.startedAtMs),s??=n,{id:i,name:e.name,kind:`chat`,status:`running`,accountId:e.id,progress:e.progress,startedAtMs:s,elapsedMs:Math.max(0,n-s)}}),c=e.waitP95Ms===0&&e.totals.done===0&&e.totals.failed===0?e.depthSeries.slice(1):Array.from({length:Math.max(0,a-1)},()=>0);for(c.push(Math.max(0,t.in_flight));c.lengthe.id)),d=[];for(let n of e.jobs){if(n.status!==`running`||u.has(n.id))continue;let e=(n.accountId||n.id.replace(/^live-/,``)).trim(),r=l.get(e),i=!0;if(r&&r.length>0)i=r.shift();else{let n=t.workers.find(t=>t.id===e);n?.last_error_kind&&n.last_error_kind.trim()!==``&&(i=!1)}d.push({id:n.id,name:n.name,kind:n.kind,ok:i})}return{generatedAt:n,backpressure:e.backpressure,throughputPerMin:Math.max(0,t.rpm),waitP95Ms:0,totals:{done:0,failed:0},workers:i,rateLimits:o,jobs:s,depthSeries:c.slice(-a),completions:d.length>0?d:void 0}}Z.registerPlugin(GH);var _7=GH.get(`inflightQueue`)||GH.create(`inflightQueue`,`0.22, 1, 0.36, 1`),v7=3,Uxe=4;function y7(e){let t=Math.max(0,Math.round(e/1e3)),n=Math.floor(t/60),r=t%60;return n?`${n}m ${String(r).padStart(2,`0`)}s`:`${r}s`}function b7(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 x7(e,t){return e?e.startedAtMs==null?Math.max(0,e.elapsedMs):Math.max(0,t-e.startedAtMs):0}function S7(e){switch(e){case`chat`:return`bg-[var(--chart-1)]`;case`embed`:return`bg-[var(--chart-6)]`;case`tools`:return`bg-[color-mix(in_oklab,var(--chart-5)_92%,var(--surface))]`;default:return`bg-foreground/40`}}function C7(e){switch(e){case`chat`:return`bg-[color-mix(in_oklab,var(--chart-1)_30%,var(--surface))] text-foreground/94`;case`embed`:return`bg-[color-mix(in_oklab,var(--chart-6)_30%,var(--surface))] text-foreground/94`;case`tools`:return`bg-[color-mix(in_oklab,var(--chart-5)_24%,var(--surface))] text-foreground/90`;default:return`bg-[color-mix(in_oklab,var(--foreground)_6%,var(--surface))] text-foreground/80`}}function Wxe({series:e,bands:t,backpressure:n,label:r}){let i=Math.max(n,...e,1),a=(0,v.useRef)(i),[o,s]=(0,v.useState)(i);(0,v.useEffect)(()=>{if(jV()){a.current=i,s(i);return}let e=a.current,t=i;if(Math.abs(t-e)<.01)return;let n=0,r=performance.now(),o=MV(.56)*1e3,c=i=>{let l=Math.min(1,(i-r)/o),u=1-(1-l)**3,d=e+(t-e)*u;a.current=d,s(d),l<1&&(n=requestAnimationFrame(c))};return n=requestAnimationFrame(c),()=>cancelAnimationFrame(n)},[i]);let c=(0,v.useMemo)(()=>e.map((e,t)=>({i:t,v:e,bp:n})),[e,n]),l=(0,v.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]),u=Math.max(o,n,1);return(0,G.jsx)(`div`,{className:`h-11 w-full overflow-hidden`,role:`img`,"aria-label":r,"data-depth-chart":!0,children:(0,G.jsx)(TJ,{width:`100%`,height:`100%`,children:(0,G.jsxs)(d7,{data:c,margin:{top:4,right:2,bottom:2,left:2},children:[(0,G.jsx)(_5,{hide:!0,domain:[0,u],allowDataOverflow:!0}),(0,G.jsx)(f5,{hide:!0,dataKey:`i`,type:`number`,domain:[0,Math.max(0,e.length-1)]}),l.map(e=>(0,G.jsx)(v8,{x1:e.x1,x2:e.x2,y1:0,y2:u,fill:`var(--il-warn, var(--warning))`,fillOpacity:.14,ifOverflow:`extendDomain`},e.key)),(0,G.jsx)(m8,{y:n,stroke:`var(--il-faint, var(--foreground))`,strokeOpacity:.35,strokeDasharray:`3 3`,ifOverflow:`extendDomain`}),(0,G.jsx)(`defs`,{children:(0,G.jsxs)(`linearGradient`,{id:`il-depth-fill`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,G.jsx)(`stop`,{offset:`0%`,stopColor:`var(--il-depth, var(--chart-1))`,stopOpacity:.28}),(0,G.jsx)(`stop`,{offset:`100%`,stopColor:`var(--il-depth, var(--chart-1))`,stopOpacity:.04})]})}),(0,G.jsx)(i5,{type:`monotone`,dataKey:`v`,stroke:`var(--il-depth, var(--chart-1))`,strokeOpacity:.95,strokeWidth:1.85,fill:`url(#il-depth-fill)`,fillOpacity:1,isAnimationActive:!jV(),animationDuration:Math.round(MV(.56)*1e3),animationEasing:`linear`,dot:!1,activeDot:!1})]})})})}function Gxe({slot:e,job:t,clockMs:n,idleLabel:r,pausedLabel:i}){let a=!!e.rateLimited,o=g7(e.concurrency??1),s=e.inFlight==null?+!!e.busy:Math.max(0,Math.floor(e.inFlight)),c=Math.min(o,s),l=c>0&&!a,u=t?.name??(a?i:r),d=x7(t,n),f=Array.from({length:o},(e,t)=>t(0,G.jsx)(`div`,{"data-slot-cell":``,"data-slot-fill":e?``:void 0,className:`relative min-w-0 flex-1 overflow-hidden rounded-[2px] ${a&&e?`bg-[var(--il-warn)]`:e?`bg-[var(--il-busy-fill)]`:`bg-[var(--il-track)] opacity-55`}`,children:l&&e?(0,G.jsxs)(G.Fragment,{children:[(0,G.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(--surface)_92%,transparent)] to-transparent motion-safe:animate-[inflight-shimmer_1.35s_linear_infinite]`}),(0,G.jsx)(`span`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-y-0 w-[42%] bg-gradient-to-r from-transparent via-[color-mix(in_oklab,var(--chart-1)_58%,transparent)] to-transparent motion-safe:animate-[inflight-shimmer_1.9s_linear_infinite]`,style:{animationDelay:`-0.55s`}}),(0,G.jsx)(`span`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-y-0 w-[28%] bg-gradient-to-r from-transparent via-[color-mix(in_oklab,var(--chart-1)_34%,var(--foreground))] to-transparent opacity-70 motion-safe:animate-[inflight-shimmer_1.55s_linear_infinite]`,style:{animationDelay:`-1.05s`}})]}):null},t))}),(0,G.jsx)(`span`,{className:`relative z-[1] mono w-[3.6rem] shrink-0 text-right text-[11px] leading-none tabular text-muted`,children:a?(0,G.jsx)(`span`,{className:`font-medium text-[var(--il-warn-fg)]`,children:i}):t||c>0?b7(d):(0,G.jsx)(`span`,{className:`text-muted/45`,children:`—`})})]})}function Kxe({t:e,snapshot:t,live:n=null,expanded:r,onExpandedChange:i,defaultExpanded:a=!1}){let o=t!==void 0,[s,c]=(0,v.useState)(a),l=r??s,u=e=>{i?.(e),r===void 0&&c(e)},[d,f]=(0,v.useState)(()=>h7(t??zxe())),[p,m]=(0,v.useState)(!1),[h,g]=(0,v.useState)(null),[_,y]=(0,v.useState)(()=>Date.now()),b=o?t:d,x=(0,v.useMemo)(()=>Vxe(b),[b]),S=(0,v.useRef)(null),C=(0,v.useRef)(!1),w=(0,v.useRef)(b),T=(0,v.useRef)({wait:{},slot:{},outcome:{}}),E=(0,v.useMemo)(()=>new Map(b.jobs.map(e=>[e.id,e])),[b.jobs]),D=b.jobs.filter(e=>e.status===`queued`),O=D.slice(0,v7),k=D.slice(v7),A=(0,v.useMemo)(()=>{let e=b.workers.filter(e=>e.busy||e.rateLimited),t=b.workers.filter(e=>!e.busy&&!e.rateLimited),n=[],r=new Set;for(let i of[...e,...t])if(!r.has(i.id)&&(r.add(i.id),n.push(i),n.length>=Uxe))break;return n},[b.workers]),j=b.rateLimits[0],M=x.waiting>=b.backpressure;(0,v.useLayoutEffect)(()=>{if(o){f(h7(t)),m(!1),g(null);return}if(!l){m(!1);return}if(n!==null){m(!1),g(n.sticky),y(Date.now()),f(e=>Hxe(e,n));return}g(null),m(!0)},[o,t,l,n]),(0,v.useEffect)(()=>{if(o||!l||!p||n!==null||jV())return;let e=0,t=performance.now(),r=!0,i=n=>{if(!r)return;let a=n-t;!document.hidden&&a>=260&&(t=n,f(e=>Bxe(e,a))),e=requestAnimationFrame(i)};return e=requestAnimationFrame(i),()=>{r=!1,cancelAnimationFrame(e)}},[o,l,p,n]),(0,v.useEffect)(()=>{if(!l)return;if(jV()){y(Date.now());return}let e=0,t=0,n=!0,r=i=>{n&&(!document.hidden&&i-t>=150&&(t=i,y(Date.now())),e=requestAnimationFrame(r))};return y(Date.now()),e=requestAnimationFrame(r),()=>{n=!1,cancelAnimationFrame(e)}},[l]),(0,v.useEffect)(()=>{l||(C.current=!1)},[l]),(0,v.useLayoutEffect)(()=>{let e=S.current;if(!e||jV()||C.current)return;C.current=!0;let t=Z.context(()=>{let t=e.querySelectorAll(`[data-wait-pill]`),n=e.querySelectorAll(`[data-wait-token]`),r=e.querySelectorAll(`[data-slot]`),i=e.querySelectorAll(`[data-slot-fill]`),a=e.querySelectorAll(`[data-depth]`);t.length&&Z.fromTo(t,{opacity:0,y:-10,scale:.6},{opacity:1,y:0,scale:1,duration:MV(.52),ease:_7,stagger:.045,force3D:!0}),n.length&&Z.fromTo(n,{opacity:0,scale:.6},{opacity:1,scale:1,duration:MV(.42),ease:AV.soft,stagger:.02,delay:MV(.18)}),r.length&&Z.fromTo(r,{opacity:0,x:-8},{opacity:1,x:0,duration:MV(.42),ease:_7,stagger:.05,delay:MV(.06),force3D:!0}),i.length&&i.forEach((e,t)=>{Z.fromTo(e,{opacity:0,scaleX:.35},{opacity:1,scaleX:1,duration:MV(.56),ease:_7,delay:MV(.18+t*.03),transformOrigin:`left center`})});let o=e.querySelector(`[data-outcome="ok"]`),s=e.querySelector(`[data-outcome="danger"]`);o&&Z.fromTo(o,{opacity:0,y:8,scale:.92,filter:`brightness(1.6)`},{opacity:1,y:0,scale:1,filter:`brightness(1)`,duration:MV(.48),ease:AV.soft,delay:MV(.42)}),s&&Z.fromTo(s,{opacity:0,x:0},{opacity:1,duration:MV(.28),delay:MV(.5),onComplete:()=>{jV()||Z.fromTo(s,{x:-3},{x:3,duration:MV(.07),yoyo:!0,repeat:5,ease:`power1.inOut`,onComplete:()=>{Z.set(s,{x:0})}})}}),a.length&&Z.fromTo(a,{opacity:0,y:6},{opacity:1,y:0,duration:MV(kV.base),ease:_7,delay:MV(.35),force3D:!0})},e);return()=>t.revert()},[l]),(0,v.useLayoutEffect)(()=>{let e=S.current,t=w.current;w.current=b;let n=()=>{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())}),T.current={wait:t,slot:n,outcome:{ok:e.querySelector(`[data-outcome="ok"]`)?.getBoundingClientRect(),danger:e.querySelector(`[data-outcome="danger"]`)?.getBoundingClientRect()}}};if(!e||jV()||!C.current){n();return}if(t===b){n();return}let r=new Map(t.jobs.map(e=>[e.id,e])),i=new Map(b.jobs.map(e=>[e.id,e])),a=new Map(t.workers.filter(e=>e.jobId).map(e=>[e.jobId,e.id])),o=new Map(b.workers.filter(e=>e.jobId).map(e=>[e.jobId,e.id])),s=(e,t,n,r,i,a,o)=>{let s=e instanceof HTMLElement?e.getBoundingClientRect():e,c=t instanceof HTMLElement?t.getBoundingClientRect():t;if(!s||!c||s.width<2||c.width<2)return;let l=r===`chat`?`var(--chart-1)`:r===`embed`?`var(--chart-6)`:r===`tools`?`var(--chart-5)`:`var(--foreground)`,u=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)`,d=i===`ok`?`var(--success)`:i===`danger`?`var(--danger)`:i===`retry`?`var(--warning)`:`var(--foreground)`,f=i===`ok`?`var(--success)`:i===`danger`?`var(--danger)`:i===`retry`?`var(--warning)`:l,p=l,m=`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, ${f} 28%, transparent), 0 6px 18px color-mix(in oklab, ${f} 36%, transparent), 0 12px 32px color-mix(in oklab, var(--foreground) 16%, transparent)`,h=`inset 0 1px 0 var(--surface-rim), 0 0 14px color-mix(in oklab, ${f} 48%, transparent), 0 0 28px color-mix(in oklab, ${f} 28%, transparent)`,g=Math.max(s.width,88),_=Math.max(s.height,26),v=c.left+Math.max(0,(c.width-g*.92)/2),y=c.top+Math.max(0,(c.height-_)/2),b=i===`ok`||i===`danger`?.86:1,x=s.left+(v-s.left)*b,S=s.top+(y-s.top)*b,C=MV(.72),w=MV(.16),T=MV(.14),E=e=>{let t=document.createElement(`div`);t.setAttribute(`aria-hidden`,`true`),Object.assign(t.style,{position:`fixed`,left:`${s.left}px`,top:`${s.top}px`,width:`${g}px`,height:`${_}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:d,background:u,boxShadow:e.asTrail?h:m,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:p});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},D=E({opacity:1});[.72,.46,.26].map((e,t)=>{let n=E({opacity:e,asTrail:!0});return Z.to(n,{left:x,top:S,width:g*.92,scaleX:1.28+t*.1,opacity:0,duration:C,delay:MV(.04+t*.045),ease:_7,force3D:!0,onComplete:()=>n.remove()}),n}),Z.to(D,{left:x,top:S,width:g*.92,scale:i===`run`||i===`retry`?.96:.88,opacity:1,duration:C,ease:_7,force3D:!0,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 8px color-mix(in oklab, var(--success) 16%, transparent)`:`inset 0 0 0 1.5px color-mix(in oklab, var(--danger) 52%, transparent), 0 0 8px color-mix(in oklab, var(--danger) 16%, transparent)`;Z.fromTo(e,{boxShadow:t},{boxShadow:n,duration:MV(.22),ease:`power1.inOut`,yoyo:!0,repeat:3,onComplete:()=>{Z.set(e,{clearProps:`boxShadow`})}})}o?.(),Z.to(D,{opacity:0,scale:i===`run`||i===`retry`?.9:.82,duration:T,delay:w,ease:`power1.out`,onComplete:()=>D.remove()})}})},c=T.current,l=new Set;for(let[t,n]of i){let i=r.get(t);if(!i||i.status!==`queued`||n.status!==`running`)continue;let a=o.get(t);if(!a)continue;l.add(t);let u=c.wait[t],d=e.querySelector(`[data-slot-id="${CSS.escape(a)}"]`),f=d?.getBoundingClientRect()??c.slot[a],p=d?.querySelector(`[data-slot-job-pill]`)??null,m=d?Array.from(d.querySelectorAll(`[data-slot-fill]`)):[];p&&Z.set(p,{opacity:0,scale:.85}),m.forEach(e=>Z.set(e,{opacity:0,scaleX:.35,transformOrigin:`left center`})),s(u,f,n.name,n.kind,`run`,null,()=>{d&&(Z.fromTo(d,{filter:`brightness(1.35)`},{filter:`brightness(1)`,duration:MV(.42),ease:AV.soft}),p&&Z.to(p,{opacity:1,scale:1,duration:MV(.42),ease:_7}),m.forEach((e,t)=>{Z.to(e,{opacity:1,scaleX:1,duration:MV(.56),ease:_7,delay:MV(t*.03)})}))})}l.size&&(e.querySelectorAll(`[data-wait-pill][data-wait-id]`).forEach(e=>{let t=e.dataset.waitId;if(!t||l.has(t))return;let n=c.wait[t];if(!n)return;let r=e.getBoundingClientRect(),i=n.left-r.left,a=n.top-r.top;Math.abs(i)<.5&&Math.abs(a)<.5||Z.fromTo(e,{x:i,y:a},{x:0,y:0,duration:MV(.56),ease:_7,force3D:!0})}),e.querySelectorAll(`[data-wait-token][data-wait-id]`).forEach(e=>{let t=e.dataset.waitId;if(!t)return;let n=c.wait[t];if(!n)return;let r=e.getBoundingClientRect(),i=n.left-r.left,a=n.top-r.top;Math.abs(i)<.5&&Math.abs(a)<.5||Z.fromTo(e,{x:i,y:a,scale:1.15},{x:0,y:0,scale:1,duration:MV(.56),ease:_7})}));for(let[n,o]of r){if(o.status!==`running`)continue;let r=i.get(n),l=a.get(n),u=l?c.slot[l]:void 0;if(r&&r.status===`queued`){let t=(e.querySelector(`[data-wait-id="${CSS.escape(n)}"]`)??e.querySelector(`[data-queue-col]`))?.getBoundingClientRect();s(u,t,o.name,o.kind,`retry`,null,()=>{let t=e.querySelector(`[data-wait-id="${CSS.escape(n)}"]`);t&&Z.fromTo(t,{opacity:.4,scale:.85},{opacity:1,scale:1,duration:MV(.42),ease:_7})});continue}if(r&&r.status===`running`)continue;let d=b.completions?.find(e=>e.id===n),f;if(d)f=d.ok?`ok`:`danger`;else if(r?.status===`failed`)f=`danger`;else if(r?.status===`done`)f=`ok`;else{let e=b.totals.done>t.totals.done;f=b.totals.failed>t.totals.failed&&!e?`danger`:`ok`}let p=e.querySelector(f===`ok`?`[data-outcome="ok"]`:`[data-outcome="danger"]`);s(u,p?.getBoundingClientRect()??c.outcome[f],o.name,o.kind,f,p)}for(let[t,n]of i){if(n.status!==`queued`||r.has(t))continue;let i=e.querySelector(`[data-wait-id="${CSS.escape(t)}"]`);i&&Z.fromTo(i,{opacity:0,y:-10,scale:.6},{opacity:1,y:0,scale:1,duration:MV(.52),ease:_7})}{let n=t.jobs.filter(e=>e.status===`queued`).map(e=>e.id),r=b.jobs.filter(e=>e.status===`queued`).map(e=>e.id);if(n.length===r.length&&n.some((e,t)=>e!==r[t]))for(let t of r){let n=e.querySelector(`[data-wait-id="${CSS.escape(t)}"]`);if(!n)continue;let r=c.wait[t];if(!r)continue;let i=n.getBoundingClientRect(),a=r.left-i.left,o=r.top-i.top;Math.abs(a)<.5&&Math.abs(o)<.5||Z.fromTo(n,{x:a,y:o},{x:0,y:0,duration:MV(.56),ease:_7,force3D:!0})}}{let n=t.jobs.filter(e=>e.status===`queued`).map(e=>e.id),r=b.jobs.filter(e=>e.status===`queued`).map(e=>e.id);for(let t=0;te.length)&&(t=e.length);for(var n=0,r=Array(t);n(fge(),null);function o7(e){if(typeof e==`number`)return e;if(typeof e==`string`){var t=parseFloat(e);if(!Number.isNaN(t))return t}return 0}var wxe=(0,v.forwardRef)((e,t)=>{var n=(0,v.useRef)(null),r=i7((0,v.useState)({containerWidth:o7(e.style?.width),containerHeight:o7(e.style?.height)}),2),i=r[0],a=r[1],o=(0,v.useCallback)((e,t)=>{a(n=>{var r=Math.round(e),i=Math.round(t);return n.containerWidth===r&&n.containerHeight===i?n:{containerWidth:r,containerHeight:i}})},[]),s=(0,v.useCallback)(e=>{if(typeof t==`function`&&t(e),n.current!=null&&(n.current.disconnect(),n.current=null),e!=null&&typeof ResizeObserver<`u`){var r=e.getBoundingClientRect(),i=r.width,a=r.height;o(i,a);var s=new ResizeObserver(e=>{var t=e[0];if(t!=null){var n=t.contentRect,r=n.width,i=n.height;o(r,i)}});s.observe(e),n.current=s}},[t,o]);return(0,v.useEffect)(()=>()=>{n.current?.disconnect()},[o]),v.createElement(v.Fragment,null,v.createElement(IJ,{width:i.containerWidth,height:i.containerHeight}),v.createElement(`div`,r7({ref:s},e)))}),Txe=(0,v.forwardRef)((e,t)=>{var n=e.width,r=e.height,i=i7((0,v.useState)({containerWidth:o7(n),containerHeight:o7(r)}),2),a=i[0],o=i[1],s=(0,v.useCallback)((e,t)=>{o(n=>{var r=Math.round(e),i=Math.round(t);return n.containerWidth===r&&n.containerHeight===i?n:{containerWidth:r,containerHeight:i}})},[]),c=(0,v.useCallback)(e=>{if(typeof t==`function`&&t(e),e!=null){var n=e.getBoundingClientRect(),r=n.width,i=n.height;s(r,i)}},[t,s]);return v.createElement(v.Fragment,null,v.createElement(IJ,{width:a.containerWidth,height:a.containerHeight}),v.createElement(`div`,r7({ref:c},e)))}),Exe=(0,v.forwardRef)((e,t)=>{var n=e.width,r=e.height;return v.createElement(v.Fragment,null,v.createElement(IJ,{width:n,height:r}),v.createElement(`div`,r7({ref:t},e)))}),Dxe=(0,v.forwardRef)((e,t)=>{var n=e.width,r=e.height;return typeof n==`string`||typeof r==`string`?v.createElement(Txe,r7({},e,{ref:t})):typeof n==`number`&&typeof r==`number`?v.createElement(Exe,r7({},e,{width:n,height:r,ref:t})):v.createElement(v.Fragment,null,v.createElement(IJ,{width:n,height:r}),v.createElement(`div`,r7({ref:t},e)))});function s7(e){return e?wxe:Dxe}var Oxe=(0,v.forwardRef)((e,t)=>{var n=e.children,r=e.className,i=e.height,a=e.onClick,o=e.onContextMenu,s=e.onDoubleClick,c=e.onMouseDown,l=e.onMouseEnter,u=e.onMouseLeave,d=e.onMouseMove,f=e.onMouseUp,p=e.onTouchEnd,m=e.onTouchMove,h=e.onTouchStart,g=e.style,_=e.width,y=e.responsive,b=e.dispatchTouchEvents,x=b===void 0||b,S=(0,v.useRef)(null),C=BW(),w=i7((0,v.useState)(null),2),T=w[0],E=w[1],D=i7((0,v.useState)(null),2),O=D[0],k=D[1],A=mxe(),j=CJ(),M=j?.width>0?j.width:_,N=j?.height>0?j.height:i,P=(0,v.useCallback)(e=>{A(e),typeof t==`function`&&t(e),E(e),k(e),e!=null&&(S.current=e)},[A,t,E,k]),F=(0,v.useCallback)(e=>{C(b5(e)),C(R5({handler:a,reactEvent:e}))},[C,a]),I=(0,v.useCallback)(e=>{C(S5(e)),C(R5({handler:l,reactEvent:e}))},[C,l]),L=(0,v.useCallback)(e=>{C(g4()),C(R5({handler:u,reactEvent:e}))},[C,u]),R=(0,v.useCallback)(e=>{C(S5(e)),C(R5({handler:d,reactEvent:e}))},[C,d]),z=(0,v.useCallback)(()=>{C(j5())},[C]),B=(0,v.useCallback)(()=>{C(M5())},[C]),V=(0,v.useCallback)(e=>{C(A5(e.key))},[C]),H=(0,v.useCallback)(e=>{C(R5({handler:o,reactEvent:e}))},[C,o]),ee=(0,v.useCallback)(e=>{C(R5({handler:s,reactEvent:e}))},[C,s]),te=(0,v.useCallback)(e=>{C(R5({handler:c,reactEvent:e}))},[C,c]),ne=(0,v.useCallback)(e=>{C(R5({handler:f,reactEvent:e}))},[C,f]),re=(0,v.useCallback)(e=>{C(R5({handler:h,reactEvent:e}))},[C,h]),ie=(0,v.useCallback)(e=>{x&&C(U5(e)),C(R5({handler:m,reactEvent:e}))},[C,x,m]),ae=(0,v.useCallback)(e=>{C(R5({handler:p,reactEvent:e}))},[C,p]),oe=s7(y);return v.createElement(h3.Provider,{value:T},v.createElement(fle.Provider,{value:O},v.createElement(oe,{width:M??g?.width,height:N??g?.height,className:xs(`recharts-wrapper`,r),style:hxe({position:`relative`,cursor:`default`,width:M,height:N},g),onClick:F,onContextMenu:H,onDoubleClick:ee,onFocus:z,onBlur:B,onKeyDown:V,onMouseDown:te,onMouseEnter:I,onMouseLeave:L,onMouseMove:R,onMouseUp:ne,onTouchEnd:ae,onTouchMove:ie,onTouchStart:re,ref:P},v.createElement(Cxe,null),n)))}),kxe=[`width`,`height`,`responsive`,`children`,`className`,`style`,`compact`,`title`,`desc`];function Axe(e,t){if(e==null)return{};var n,r,i=jxe(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r{var n=e.width,r=e.height,i=e.responsive,a=e.children,o=e.className,s=e.style,c=e.compact,l=e.title,u=e.desc,d=YH(Axe(e,kxe));return c?v.createElement(v.Fragment,null,v.createElement(IJ,{width:n,height:r}),v.createElement(e7,{otherAttributes:d,title:l,desc:u},a)):v.createElement(Oxe,{className:o,style:s,width:n,height:r,responsive:i??!1,onClick:e.onClick,onMouseLeave:e.onMouseLeave,onMouseEnter:e.onMouseEnter,onMouseMove:e.onMouseMove,onMouseDown:e.onMouseDown,onMouseUp:e.onMouseUp,onContextMenu:e.onContextMenu,onDoubleClick:e.onDoubleClick,onTouchStart:e.onTouchStart,onTouchMove:e.onTouchMove,onTouchEnd:e.onTouchEnd},v.createElement(e7,{otherAttributes:d,title:l,desc:u,ref:t},v.createElement(Vve,null,a)))});function c7(){return c7=Object.assign?Object.assign.bind():function(e){for(var t=1;tv.createElement(u7,{chartName:`AreaChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:Rxe,tooltipPayloadSearcher:y3,categoricalChartProps:e,ref:t})),f7={generatedAt:0,backpressure:6,throughputPerMin:42,waitP95Ms:2800,totals:{done:186,failed:4},workers:[{id:`acc-wb-a1`,name:`wb-a1`,provider:`workbuddy`,busy:!0,progress:.72,jobId:`j1`,concurrency:4,inFlight:3},{id:`acc-wb-a2`,name:`wb-a2`,provider:`workbuddy`,busy:!0,progress:.41,jobId:`j2`,rateLimited:!0,concurrency:2,inFlight:1},{id:`acc-qd-b1`,name:`qd-b1`,provider:`qoder`,busy:!0,progress:.88,jobId:`j3`,concurrency:1,inFlight:1},{id:`acc-qd-b2`,name:`qd-b2`,provider:`qoder`,busy:!1,progress:0,concurrency:4,inFlight:0},{id:`acc-trae-c1`,name:`trae-c1`,provider:`trae`,busy:!0,progress:.23,jobId:`j4`,concurrency:3,inFlight:2},{id:`acc-codex-d1`,name:`codex-d1`,provider:`codex`,busy:!1,progress:0,rateLimited:!0,concurrency:2,inFlight:0}],jobs:[{id:`j1`,name:`chat · sonnet`,kind:`chat`,status:`running`,accountId:`acc-wb-a1`,progress:.72,elapsedMs:11200,sticky:!0},{id:`j2`,name:`embed · batch`,kind:`embed`,status:`running`,accountId:`acc-wb-a2`,progress:.41,elapsedMs:9400},{id:`j3`,name:`chat · gpt`,kind:`chat`,status:`running`,accountId:`acc-qd-b1`,progress:.88,elapsedMs:6200},{id:`j4`,name:`tools · patch`,kind:`tools`,status:`running`,accountId:`acc-trae-c1`,progress:.23,elapsedMs:3100},{id:`j5`,name:`chat · wait`,kind:`chat`,status:`queued`,progress:0,elapsedMs:7200},{id:`j6`,name:`retry · cool`,kind:`chat`,status:`queued`,progress:0,elapsedMs:5100},{id:`j7`,name:`chat · sticky`,kind:`chat`,status:`queued`,progress:0,elapsedMs:2800,sticky:!0,priority:`high`},{id:`j8`,name:`embed · docs`,kind:`embed`,status:`queued`,progress:0,elapsedMs:1400},{id:`j9`,name:`tools · apply`,kind:`tools`,status:`queued`,progress:0,elapsedMs:900},{id:`j10`,name:`chat · flash`,kind:`chat`,status:`queued`,progress:0,elapsedMs:600},{id:`j11`,name:`embed · idx`,kind:`embed`,status:`queued`,progress:0,elapsedMs:400},{id:`j12`,name:`chat · opus`,kind:`chat`,status:`queued`,progress:0,elapsedMs:200,priority:`high`}],rateLimits:[{id:`rl1`,label:`wb-a2 限流`,remainingMs:97e3,from:.55,until:.72},{id:`rl2`,label:`codex-d1 冷却`,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]},p7=[{name:`chat · opus`,kind:`chat`},{name:`embed · idx`,kind:`embed`},{name:`tools · apply`,kind:`tools`},{name:`chat · flash`,kind:`chat`,sticky:!0},{name:`chat · wait`,kind:`chat`},{name:`embed · docs`,kind:`embed`}],m7=100;function h7(e=f7){return{...e,workers:e.workers.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 zxe(){return h7()}function Bxe(e,t){let n=Math.max(16,Math.min(500,t)),r=h7(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(`wb-a2`)):e.id===`acc-codex-d1`&&(e.rateLimited=r.rateLimits.some(e=>e.label.includes(`codex-d1`)));let i=new Map(r.jobs.map(e=>[e.id,e]));for(let e of r.workers){if(!e.busy||!e.jobId)continue;let t=i.get(e.jobId);if(!t||t.status!==`running`||(t.elapsedMs+=n,e.rateLimited))continue;let r=.045+e.id.charCodeAt(e.id.length-1)%5*.008;e.progress=Math.min(1,e.progress+n/1e3*r),t.progress=e.progress}let a=[];for(let e of r.workers){if(!e.busy||!e.jobId||e.rateLimited||e.progress<.995)continue;let t=(e.jobId.charCodeAt(1)+Math.floor(r.generatedAt/1e3))%9!=0;a.push({jobId:e.jobId,workerId:e.id,ok:t})}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.busy=!1,n.progress=0,n.jobId=void 0,n.inFlight=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.busy||e.rateLimited)continue;let t=s.shift();if(!t)break;t.status=`running`,t.accountId=e.id,t.progress=.04,t.elapsedMs=0,e.busy=!0,e.progress=.04,e.jobId=t.id;let n=g7(e.concurrency??1);e.inFlight=Math.min(n,Math.max(1,e.inFlight??1))}if(r.jobs.filter(e=>e.status===`queued`).length<6&&r.generatedAt%2800e.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+(m7%3-1))),r.waitP95Ms=Math.max(900,Math.min(5200,r.waitP95Ms+(l>4?40:-20))),r}function g7(e){return e==null||!Number.isFinite(e)?1:Math.max(1,Math.min(16,Math.floor(e)))}function Vxe(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=g7(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 Hxe(e,t){let n=Date.now(),r=new Map(e.jobs.map(e=>[e.id,e])),i=t.workers.map(e=>{let t=g7(e.max_inflight??4),n=e.in_flight!=null&&Number.isFinite(e.in_flight)?Math.max(0,Math.floor(e.in_flight)):+!!e.busy,r=Math.min(t,n);return{id:e.id,name:e.name,provider:e.provider,busy:e.busy||r>0,progress:e.busy||r>0?Math.max(.04,Math.min(1,e.progress||0)):0,rateLimited:e.rate_limited,jobId:e.busy||r>0?`live-${e.id}`:void 0,concurrency:t,inFlight:r}}),a=Math.max(1,f7.depthSeries.length),o=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)}}),s=i.filter(e=>e.busy&&e.jobId).map(e=>{let i=e.jobId,a=r.get(i),o=t.workers.find(t=>t.id===e.id),s,c=o?.started_at?.trim();if(c){let e=Date.parse(c);Number.isNaN(e)||(s=e)}return s==null&&a?.startedAtMs!=null&&(s=a.startedAtMs),s??=n,{id:i,name:e.name,kind:`chat`,status:`running`,accountId:e.id,progress:e.progress,startedAtMs:s,elapsedMs:Math.max(0,n-s)}}),c=(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`,progress:0,startedAtMs:a,elapsedMs:Math.max(0,n-a)}}),l=[...s,...c],u=e.waitP95Ms===0&&e.totals.done===0&&e.totals.failed===0?e.depthSeries.slice(1):Array.from({length:Math.max(0,a-1)},()=>0);for(u.push(Math.max(0,t.in_flight));u.lengthe.id)),p=[];for(let n of e.jobs){if(n.status!==`running`||f.has(n.id))continue;let e=(n.accountId||n.id.replace(/^live-/,``)).trim(),r=d.get(e),i=!0;if(r&&r.length>0)i=r.shift();else{let n=t.workers.find(t=>t.id===e);n?.last_error_kind&&n.last_error_kind.trim()!==``&&(i=!1)}p.push({id:n.id,name:n.name,kind:n.kind,ok:i})}return{generatedAt:n,backpressure:e.backpressure,throughputPerMin:Math.max(0,t.rpm),waitP95Ms:0,totals:{done:0,failed:0},workers:i,rateLimits:o,jobs:l,depthSeries:u.slice(-a),completions:p.length>0?p:void 0}}Z.registerPlugin(GH);var _7=GH.get(`inflightQueue`)||GH.create(`inflightQueue`,`0.22, 1, 0.36, 1`),v7=3,Uxe=4;function y7(e){let t=Math.max(0,Math.round(e/1e3)),n=Math.floor(t/3600),r=Math.floor(t%3600/60),i=t%60;return n?`${n}h ${r}m`:r?`${r}m ${String(i).padStart(2,`0`)}s`:`${i}s`}function b7(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 x7(e,t){return e?e.startedAtMs==null?Math.max(0,e.elapsedMs):Math.max(0,t-e.startedAtMs):0}function S7(e){switch(e){case`chat`:return`bg-[var(--chart-1)]`;case`embed`:return`bg-[var(--chart-6)]`;case`tools`:return`bg-[color-mix(in_oklab,var(--chart-5)_92%,var(--surface))]`;default:return`bg-foreground/40`}}function C7(e){switch(e){case`chat`:return`bg-[color-mix(in_oklab,var(--chart-1)_30%,var(--surface))] text-foreground/94`;case`embed`:return`bg-[color-mix(in_oklab,var(--chart-6)_30%,var(--surface))] text-foreground/94`;case`tools`:return`bg-[color-mix(in_oklab,var(--chart-5)_24%,var(--surface))] text-foreground/90`;default:return`bg-[color-mix(in_oklab,var(--foreground)_6%,var(--surface))] text-foreground/80`}}function Wxe({series:e,bands:t,backpressure:n,label:r}){let i=Math.max(n,...e,1),a=(0,v.useRef)(i),[o,s]=(0,v.useState)(i);(0,v.useEffect)(()=>{if(jV()){a.current=i,s(i);return}let e=a.current,t=i;if(Math.abs(t-e)<.01)return;let n=0,r=performance.now(),o=MV(.56)*1e3,c=i=>{let l=Math.min(1,(i-r)/o),u=1-(1-l)**3,d=e+(t-e)*u;a.current=d,s(d),l<1&&(n=requestAnimationFrame(c))};return n=requestAnimationFrame(c),()=>cancelAnimationFrame(n)},[i]);let c=(0,v.useMemo)(()=>e.map((e,t)=>({i:t,v:e,bp:n})),[e,n]),l=(0,v.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]),u=Math.max(o,n,1);return(0,G.jsx)(`div`,{className:`h-11 w-full overflow-hidden`,role:`img`,"aria-label":r,"data-depth-chart":!0,children:(0,G.jsx)(TJ,{width:`100%`,height:`100%`,children:(0,G.jsxs)(d7,{data:c,margin:{top:4,right:2,bottom:2,left:2},children:[(0,G.jsx)(_5,{hide:!0,domain:[0,u],allowDataOverflow:!0}),(0,G.jsx)(f5,{hide:!0,dataKey:`i`,type:`number`,domain:[0,Math.max(0,e.length-1)]}),l.map(e=>(0,G.jsx)(v8,{x1:e.x1,x2:e.x2,y1:0,y2:u,fill:`var(--il-warn, var(--warning))`,fillOpacity:.14,ifOverflow:`extendDomain`},e.key)),(0,G.jsx)(m8,{y:n,stroke:`var(--il-faint, var(--foreground))`,strokeOpacity:.35,strokeDasharray:`3 3`,ifOverflow:`extendDomain`}),(0,G.jsx)(`defs`,{children:(0,G.jsxs)(`linearGradient`,{id:`il-depth-fill`,x1:`0`,y1:`0`,x2:`0`,y2:`1`,children:[(0,G.jsx)(`stop`,{offset:`0%`,stopColor:`var(--il-depth, var(--chart-1))`,stopOpacity:.28}),(0,G.jsx)(`stop`,{offset:`100%`,stopColor:`var(--il-depth, var(--chart-1))`,stopOpacity:.04})]})}),(0,G.jsx)(i5,{type:`monotone`,dataKey:`v`,stroke:`var(--il-depth, var(--chart-1))`,strokeOpacity:.95,strokeWidth:1.85,fill:`url(#il-depth-fill)`,fillOpacity:1,isAnimationActive:!jV(),animationDuration:Math.round(MV(.56)*1e3),animationEasing:`linear`,dot:!1,activeDot:!1})]})})})}function Gxe({slot:e,job:t,clockMs:n,idleLabel:r,pausedLabel:i}){let a=!!e.rateLimited,o=g7(e.concurrency??1),s=e.inFlight==null?+!!e.busy:Math.max(0,Math.floor(e.inFlight)),c=Math.min(o,s),l=c>0&&!a,u=t?.name??(a?i:r),d=x7(t,n),f=Array.from({length:o},(e,t)=>t(0,G.jsx)(`div`,{"data-slot-cell":``,"data-slot-fill":e?``:void 0,className:`relative min-w-0 flex-1 overflow-hidden rounded-[2px] ${a&&e?`bg-[var(--il-warn)]`:e?`bg-[var(--il-busy-fill)]`:`bg-[var(--il-track)] opacity-55`}`,children:l&&e?(0,G.jsxs)(G.Fragment,{children:[(0,G.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(--surface)_92%,transparent)] to-transparent motion-safe:animate-[inflight-shimmer_1.35s_linear_infinite]`}),(0,G.jsx)(`span`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-y-0 w-[42%] bg-gradient-to-r from-transparent via-[color-mix(in_oklab,var(--chart-1)_58%,transparent)] to-transparent motion-safe:animate-[inflight-shimmer_1.9s_linear_infinite]`,style:{animationDelay:`-0.55s`}}),(0,G.jsx)(`span`,{"aria-hidden":!0,className:`pointer-events-none absolute inset-y-0 w-[28%] bg-gradient-to-r from-transparent via-[color-mix(in_oklab,var(--chart-1)_34%,var(--foreground))] to-transparent opacity-70 motion-safe:animate-[inflight-shimmer_1.55s_linear_infinite]`,style:{animationDelay:`-1.05s`}})]}):null},t))}),(0,G.jsx)(`span`,{className:`relative z-[1] mono w-[3.6rem] shrink-0 text-right text-[11px] leading-none tabular text-muted`,children:a?(0,G.jsx)(`span`,{className:`font-medium text-[var(--il-warn-fg)]`,children:i}):t||c>0?b7(d):(0,G.jsx)(`span`,{className:`text-muted/45`,children:`—`})})]})}function Kxe({t:e,snapshot:t,live:n=null,expanded:r,onExpandedChange:i,defaultExpanded:a=!1}){let o=t!==void 0,[s,c]=(0,v.useState)(a),l=r??s,u=e=>{i?.(e),r===void 0&&c(e)},[d,f]=(0,v.useState)(()=>h7(t??zxe())),[p,m]=(0,v.useState)(!1),[h,g]=(0,v.useState)(null),[_,y]=(0,v.useState)(()=>Date.now()),b=o?t:d,x=(0,v.useMemo)(()=>Vxe(b),[b]),S=(0,v.useRef)(null),C=(0,v.useRef)(!1),w=(0,v.useRef)(b),T=(0,v.useRef)({wait:{},slot:{},outcome:{}}),E=(0,v.useMemo)(()=>new Map(b.jobs.map(e=>[e.id,e])),[b.jobs]),D=b.jobs.filter(e=>e.status===`queued`),O=D.slice(0,v7),k=D.slice(v7),A=(0,v.useMemo)(()=>{let e=b.workers.filter(e=>e.busy),t=b.workers.filter(e=>!e.busy&&!e.rateLimited),n=b.workers.filter(e=>!e.busy&&e.rateLimited),r=[],i=new Set;for(let a of[...e,...t,...n])if(!i.has(a.id)&&(i.add(a.id),r.push(a),r.length>=Uxe))break;return r},[b.workers]),j=b.rateLimits[0],M=x.waiting>=b.backpressure;(0,v.useLayoutEffect)(()=>{if(o){f(h7(t)),m(!1),g(null);return}if(!l){m(!1);return}if(n!==null){m(!1),g(n.sticky),y(Date.now()),f(e=>Hxe(e,n));return}g(null),m(!0)},[o,t,l,n]),(0,v.useEffect)(()=>{if(o||!l||!p||n!==null||jV())return;let e=0,t=performance.now(),r=!0,i=n=>{if(!r)return;let a=n-t;!document.hidden&&a>=260&&(t=n,f(e=>Bxe(e,a))),e=requestAnimationFrame(i)};return e=requestAnimationFrame(i),()=>{r=!1,cancelAnimationFrame(e)}},[o,l,p,n]),(0,v.useEffect)(()=>{if(!l)return;if(jV()){y(Date.now());return}let e=0,t=0,n=!0,r=i=>{n&&(!document.hidden&&i-t>=150&&(t=i,y(Date.now())),e=requestAnimationFrame(r))};return y(Date.now()),e=requestAnimationFrame(r),()=>{n=!1,cancelAnimationFrame(e)}},[l]),(0,v.useEffect)(()=>{l||(C.current=!1)},[l]),(0,v.useLayoutEffect)(()=>{let e=S.current;if(!e||jV()||C.current)return;C.current=!0;let t=Z.context(()=>{let t=e.querySelectorAll(`[data-wait-pill]`),n=e.querySelectorAll(`[data-wait-token]`),r=e.querySelectorAll(`[data-slot]`),i=e.querySelectorAll(`[data-slot-fill]`),a=e.querySelectorAll(`[data-depth]`);t.length&&Z.fromTo(t,{opacity:0,y:-10,scale:.6},{opacity:1,y:0,scale:1,duration:MV(.52),ease:_7,stagger:.045,force3D:!0}),n.length&&Z.fromTo(n,{opacity:0,scale:.6},{opacity:1,scale:1,duration:MV(.42),ease:AV.soft,stagger:.02,delay:MV(.18)}),r.length&&Z.fromTo(r,{opacity:0,x:-8},{opacity:1,x:0,duration:MV(.42),ease:_7,stagger:.05,delay:MV(.06),force3D:!0}),i.length&&i.forEach((e,t)=>{Z.fromTo(e,{opacity:0,scaleX:.35},{opacity:1,scaleX:1,duration:MV(.56),ease:_7,delay:MV(.18+t*.03),transformOrigin:`left center`})});let o=e.querySelector(`[data-outcome="ok"]`),s=e.querySelector(`[data-outcome="danger"]`);o&&Z.fromTo(o,{opacity:0,y:8,scale:.92,filter:`brightness(1.6)`},{opacity:1,y:0,scale:1,filter:`brightness(1)`,duration:MV(.48),ease:AV.soft,delay:MV(.42)}),s&&Z.fromTo(s,{opacity:0,x:0},{opacity:1,duration:MV(.28),delay:MV(.5),onComplete:()=>{jV()||Z.fromTo(s,{x:-3},{x:3,duration:MV(.07),yoyo:!0,repeat:5,ease:`power1.inOut`,onComplete:()=>{Z.set(s,{x:0})}})}}),a.length&&Z.fromTo(a,{opacity:0,y:6},{opacity:1,y:0,duration:MV(kV.base),ease:_7,delay:MV(.35),force3D:!0})},e);return()=>t.revert()},[l]),(0,v.useLayoutEffect)(()=>{let e=S.current,t=w.current;w.current=b;let n=()=>{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())}),T.current={wait:t,slot:n,outcome:{ok:e.querySelector(`[data-outcome="ok"]`)?.getBoundingClientRect(),danger:e.querySelector(`[data-outcome="danger"]`)?.getBoundingClientRect()}}};if(!e||jV()||!C.current){n();return}if(t===b){n();return}let r=new Map(t.jobs.map(e=>[e.id,e])),i=new Map(b.jobs.map(e=>[e.id,e])),a=new Map(t.workers.filter(e=>e.jobId).map(e=>[e.jobId,e.id])),o=new Map(b.workers.filter(e=>e.jobId).map(e=>[e.jobId,e.id])),s=(e,t,n,r,i,a,o)=>{let s=e instanceof HTMLElement?e.getBoundingClientRect():e,c=t instanceof HTMLElement?t.getBoundingClientRect():t;if(!s||!c||s.width<2||c.width<2)return;let l=r===`chat`?`var(--chart-1)`:r===`embed`?`var(--chart-6)`:r===`tools`?`var(--chart-5)`:`var(--foreground)`,u=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)`,d=i===`ok`?`var(--success)`:i===`danger`?`var(--danger)`:i===`retry`?`var(--warning)`:`var(--foreground)`,f=i===`ok`?`var(--success)`:i===`danger`?`var(--danger)`:i===`retry`?`var(--warning)`:l,p=l,m=`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, ${f} 28%, transparent), 0 6px 18px color-mix(in oklab, ${f} 36%, transparent), 0 12px 32px color-mix(in oklab, var(--foreground) 16%, transparent)`,h=`inset 0 1px 0 var(--surface-rim), 0 0 14px color-mix(in oklab, ${f} 48%, transparent), 0 0 28px color-mix(in oklab, ${f} 28%, transparent)`,g=Math.max(s.width,88),_=Math.max(s.height,26),v=c.left+Math.max(0,(c.width-g*.92)/2),y=c.top+Math.max(0,(c.height-_)/2),b=i===`ok`||i===`danger`?.86:1,x=s.left+(v-s.left)*b,S=s.top+(y-s.top)*b,C=MV(.72),w=MV(.16),T=MV(.14),E=e=>{let t=document.createElement(`div`);t.setAttribute(`aria-hidden`,`true`),Object.assign(t.style,{position:`fixed`,left:`${s.left}px`,top:`${s.top}px`,width:`${g}px`,height:`${_}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:d,background:u,boxShadow:e.asTrail?h:m,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:p});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},D=E({opacity:1});[.72,.46,.26].map((e,t)=>{let n=E({opacity:e,asTrail:!0});return Z.to(n,{left:x,top:S,width:g*.92,scaleX:1.28+t*.1,opacity:0,duration:C,delay:MV(.04+t*.045),ease:_7,force3D:!0,onComplete:()=>n.remove()}),n}),Z.to(D,{left:x,top:S,width:g*.92,scale:i===`run`||i===`retry`?.96:.88,opacity:1,duration:C,ease:_7,force3D:!0,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 8px color-mix(in oklab, var(--success) 16%, transparent)`:`inset 0 0 0 1.5px color-mix(in oklab, var(--danger) 52%, transparent), 0 0 8px color-mix(in oklab, var(--danger) 16%, transparent)`;Z.fromTo(e,{boxShadow:t},{boxShadow:n,duration:MV(.22),ease:`power1.inOut`,yoyo:!0,repeat:3,onComplete:()=>{Z.set(e,{clearProps:`boxShadow`})}})}o?.(),Z.to(D,{opacity:0,scale:i===`run`||i===`retry`?.9:.82,duration:T,delay:w,ease:`power1.out`,onComplete:()=>D.remove()})}})},c=T.current,l=new Set;for(let[t,n]of i){let i=r.get(t);if(!i||i.status!==`queued`||n.status!==`running`)continue;let a=o.get(t);if(!a)continue;l.add(t);let u=c.wait[t],d=e.querySelector(`[data-slot-id="${CSS.escape(a)}"]`),f=d?.getBoundingClientRect()??c.slot[a],p=d?.querySelector(`[data-slot-job-pill]`)??null,m=d?Array.from(d.querySelectorAll(`[data-slot-fill]`)):[];p&&Z.set(p,{opacity:0,scale:.85}),m.forEach(e=>Z.set(e,{opacity:0,scaleX:.35,transformOrigin:`left center`})),s(u,f,n.name,n.kind,`run`,null,()=>{d&&(Z.fromTo(d,{filter:`brightness(1.35)`},{filter:`brightness(1)`,duration:MV(.42),ease:AV.soft}),p&&Z.to(p,{opacity:1,scale:1,duration:MV(.42),ease:_7}),m.forEach((e,t)=>{Z.to(e,{opacity:1,scaleX:1,duration:MV(.56),ease:_7,delay:MV(t*.03)})}))})}l.size&&(e.querySelectorAll(`[data-wait-pill][data-wait-id]`).forEach(e=>{let t=e.dataset.waitId;if(!t||l.has(t))return;let n=c.wait[t];if(!n)return;let r=e.getBoundingClientRect(),i=n.left-r.left,a=n.top-r.top;Math.abs(i)<.5&&Math.abs(a)<.5||Z.fromTo(e,{x:i,y:a},{x:0,y:0,duration:MV(.56),ease:_7,force3D:!0})}),e.querySelectorAll(`[data-wait-token][data-wait-id]`).forEach(e=>{let t=e.dataset.waitId;if(!t)return;let n=c.wait[t];if(!n)return;let r=e.getBoundingClientRect(),i=n.left-r.left,a=n.top-r.top;Math.abs(i)<.5&&Math.abs(a)<.5||Z.fromTo(e,{x:i,y:a,scale:1.15},{x:0,y:0,scale:1,duration:MV(.56),ease:_7})}));for(let[n,o]of r){if(o.status!==`running`)continue;let r=i.get(n),l=a.get(n),u=l?c.slot[l]:void 0;if(r&&r.status===`queued`){let t=(e.querySelector(`[data-wait-id="${CSS.escape(n)}"]`)??e.querySelector(`[data-queue-col]`))?.getBoundingClientRect();s(u,t,o.name,o.kind,`retry`,null,()=>{let t=e.querySelector(`[data-wait-id="${CSS.escape(n)}"]`);t&&Z.fromTo(t,{opacity:.4,scale:.85},{opacity:1,scale:1,duration:MV(.42),ease:_7})});continue}if(r&&r.status===`running`)continue;let d=b.completions?.find(e=>e.id===n),f;if(d)f=d.ok?`ok`:`danger`;else if(r?.status===`failed`)f=`danger`;else if(r?.status===`done`)f=`ok`;else{let e=b.totals.done>t.totals.done;f=b.totals.failed>t.totals.failed&&!e?`danger`:`ok`}let p=e.querySelector(f===`ok`?`[data-outcome="ok"]`:`[data-outcome="danger"]`);s(u,p?.getBoundingClientRect()??c.outcome[f],o.name,o.kind,f,p)}for(let[t,n]of i){if(n.status!==`queued`||r.has(t))continue;let i=e.querySelector(`[data-wait-id="${CSS.escape(t)}"]`);i&&Z.fromTo(i,{opacity:0,y:-10,scale:.6},{opacity:1,y:0,scale:1,duration:MV(.52),ease:_7})}{let n=t.jobs.filter(e=>e.status===`queued`).map(e=>e.id),r=b.jobs.filter(e=>e.status===`queued`).map(e=>e.id);if(n.length===r.length&&n.some((e,t)=>e!==r[t]))for(let t of r){let n=e.querySelector(`[data-wait-id="${CSS.escape(t)}"]`);if(!n)continue;let r=c.wait[t];if(!r)continue;let i=n.getBoundingClientRect(),a=r.left-i.left,o=r.top-i.top;Math.abs(a)<.5&&Math.abs(o)<.5||Z.fromTo(n,{x:a,y:o},{x:0,y:0,duration:MV(.56),ease:_7,force3D:!0})}}{let n=t.jobs.filter(e=>e.status===`queued`).map(e=>e.id),r=b.jobs.filter(e=>e.status===`queued`).map(e=>e.id);for(let t=0;tu(!l),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,G.jsx)(di,{size:14,"aria-hidden":!0,className:`mt-1 shrink-0 text-muted transition-transform duration-200 ${l?`rotate-90`:``}`}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`h3`,{className:`font-semibold`,children:e(`inflightTitle`)}),(0,G.jsxs)(`span`,{className:`mono inline-flex items-center gap-1 rounded-[3px] px-1.5 py-0.5 text-caption ${j&&l?`bg-[var(--il-warn-bg)] font-medium text-[var(--il-warn-fg)] shadow-[var(--il-hair-warn)]`:`text-muted`}`,children:[(0,G.jsx)(`span`,{className:`status-dot`,"data-state":j&&l?`warn`:P?`ok`:``}),l&&j?e(`inflightRatePill`,{remain:y7(j.remainingMs)}):e(P?`inflightLiveBadge`:`inflightMockBadge`)]}),l&&F>0?(0,G.jsx)(`span`,{className:`mono text-caption text-muted`,children:e(`inflightStickyBindings`,{n:F})}):null]}),(0,G.jsx)(`p`,{className:`mt-0.5 text-caption text-muted`,children:e(`inflightHint`)})]})]}),l?(0,G.jsxs)(Sn,{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,G.jsx)($r,{size:14,"aria-hidden":!0})]}):(0,G.jsxs)(`button`,{type:`button`,className:`inline-flex shrink-0 items-center gap-1 text-caption text-muted transition-colors hover:text-foreground`,onClick:()=>u(!0),children:[e(`inflightExpand`),(0,G.jsx)(di,{size:14,"aria-hidden":!0})]})]}),l?(0,G.jsxs)(`div`,{id:`inflight-live-body`,ref:S,children:[(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 border-b border-separator px-4 py-3 sm:grid-cols-4`,children:[(0,G.jsx)(w7,{label:e(`inflightWaiting`),value:x.waiting,warn:M||!!j}),(0,G.jsx)(w7,{label:e(`inflightRunning`),value:x.occupiedSlots,suffix:`/${x.workerSlots}`}),(0,G.jsx)(w7,{label:e(`inflightThroughput`),value:b.throughputPerMin,suffix:`/min`}),(0,G.jsx)(w7,{label:e(`inflightWaitP95`),value:b.waitP95Ms,kind:`ms`})]}),(0,G.jsxs)(`div`,{className:`grid gap-3 border-b border-separator px-4 py-3 lg:grid-cols-[minmax(0,0.95fr)_minmax(0,1.55fr)_auto]`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,"data-queue-col":!0,children:[(0,G.jsxs)(`div`,{className:`mb-1.5 flex items-baseline justify-between gap-2`,children:[(0,G.jsx)(`span`,{className:`text-caption uppercase tracking-wide text-muted`,children:e(`inflightQueue`)}),(0,G.jsx)(`span`,{className:`mono text-[10px] tabular ${M?`text-[var(--il-warn-fg)]`:`text-muted`}`,children:x.waiting})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[O.map(t=>(0,G.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 shadow-[var(--il-hair)] ${C7(t.kind)}`,children:[(0,G.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(--chart-1)_28%,transparent)] to-transparent motion-safe:animate-[inflight-queue-shimmer_2.8s_linear_infinite]`}),(0,G.jsxs)(`span`,{className:`relative z-[1] flex min-w-0 items-center gap-1.5 truncate text-[11px] font-medium text-foreground/92`,children:[(0,G.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-[2px] ${S7(t.kind)}`,"aria-hidden":!0}),(0,G.jsxs)(`span`,{className:`truncate`,children:[t.name,t.priority===`high`?(0,G.jsx)(`span`,{className:`mono ml-1 text-[10px] text-muted`,children:`↑`}):null,t.sticky?(0,G.jsx)(`span`,{className:`mono ml-1 text-[10px] text-muted`,children:e(`inflightSticky`)}):null]})]}),(0,G.jsx)(`span`,{className:`relative z-[1] mono shrink-0 text-[10px] text-muted`,children:b7(x7(t,_))})]},t.id)),k.length?(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 pt-1`,"data-queue-overflow":!0,children:[k.map(e=>(0,G.jsx)(`span`,{"data-wait-token":!0,"data-wait-id":e.id,"data-priority":e.priority??`normal`,className:`size-2 rounded-[2px] ${S7(e.kind)} ${e.priority===`high`?`ring-1 ring-foreground/20`:``}`,title:e.name},e.id)),(0,G.jsxs)(`span`,{className:`mono text-[10px] text-muted`,children:[`+`,k.length]})]}):O.length===0?(0,G.jsx)(`div`,{className:`text-caption text-muted`,children:e(`inflightQueueEmpty`)}):null]})]}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsxs)(`div`,{className:`mb-1.5 flex items-baseline justify-between gap-2`,children:[(0,G.jsx)(`span`,{className:`text-caption uppercase tracking-wide text-muted`,children:e(`inflightSlots`)}),(0,G.jsxs)(`span`,{className:`mono text-[10px] tabular text-muted`,children:[x.occupiedSlots,`/`,x.workerSlots]})]}),(0,G.jsx)(`div`,{className:`flex flex-col gap-2`,children:A.map(t=>(0,G.jsx)(Gxe,{slot:t,job:t.jobId?E.get(t.jobId):void 0,clockMs:_,idleLabel:e(`inflightSlotIdle`),pausedLabel:e(`inflightSlotPaused`)},t.id))})]}),(0,G.jsxs)(`div`,{className:`flex gap-2 lg:w-[3.75rem] lg:flex-col`,children:[(0,G.jsx)(T7,{label:e(`inflightDone`),value:b.totals.done,tone:`ok`,icon:(0,G.jsx)(_i,{size:14,weight:`bold`,"aria-hidden":!0})}),(0,G.jsx)(T7,{label:e(`inflightFailed`),value:b.totals.failed,tone:`danger`,icon:(0,G.jsx)(ao,{size:14,weight:`bold`,"aria-hidden":!0})})]})]}),(0,G.jsxs)(`div`,{"data-depth":!0,className:`px-4 py-3`,children:[(0,G.jsxs)(`div`,{className:`mb-1 flex items-baseline justify-between gap-2`,children:[(0,G.jsx)(`span`,{className:`text-caption uppercase tracking-wide text-muted`,children:e(`inflightDepth`)}),(0,G.jsx)(`span`,{className:`mono text-caption tabular text-muted`,children:N})]}),(0,G.jsx)(`div`,{className:`rounded-lg bg-[var(--il-item-bg)] px-1.5 pt-1.5 pb-1`,children:(0,G.jsx)(Wxe,{series:b.depthSeries,bands:b.rateLimits.map(e=>({from:e.from,until:e.until})),backpressure:b.backpressure,label:N})}),j?(0,G.jsx)(`div`,{className:`mono mt-1.5 text-[10px] font-medium text-[var(--il-warn-fg)]`,children:e(`inflightRateBand`,{label:j.label,remain:y7(j.remainingMs)})}):null]})]}):null]})}function w7({label:e,value:t,suffix:n,kind:r=`int`,warn:i}){return(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`div`,{className:`text-caption uppercase tracking-wide text-muted`,children:e}),(0,G.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,G.jsx)(dH,{value:t,kind:r,duration:560}),n?(0,G.jsx)(`span`,{className:`text-[0.92em] opacity-80`,children:n}):null]})]})}function T7({label:e,value:t,tone:n,icon:r}){let i=n===`ok`;return(0,G.jsxs)(`div`,{"data-outcome":n,role:`group`,"aria-label":`${e}: ${t}`,title:`${e}: ${t}`,className:`flex min-w-[3.25rem] flex-1 flex-col items-center justify-center gap-1 rounded-xl px-2 py-2.5 ${i?`bg-[var(--il-ok-bg)] shadow-[var(--il-hair-ok)]`:`bg-[var(--il-err-bg)] shadow-[var(--il-hair-err)]`}`,children:[(0,G.jsx)(`span`,{className:`inline-flex size-6 items-center justify-center ${i?`text-[var(--il-ok-fg)]`:`text-[var(--il-err-fg)]`}`,"aria-hidden":!0,children:r}),(0,G.jsx)(`div`,{className:`mono text-section font-semibold tabular leading-none ${i?`text-[var(--il-ok-fg)]`:`text-[var(--il-err-fg)]`}`,children:(0,G.jsx)(dH,{value:t,kind:`int`,duration:560})}),(0,G.jsx)(`span`,{className:`sr-only`,children:e})]})}var E7=2500;Math.round(6e4/E7);function qxe(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)([]);return(0,v.useEffect)(()=>{let e=!1,n=null,i=()=>{document.hidden||zV().then(n=>{e||(t(n),r(e=>[...e,{at:Date.now(),value:n.in_flight}].slice(-24)))}).catch(()=>{})},a=()=>{n||document.hidden||(i(),n=setInterval(i,E7))},o=()=>{n&&clearInterval(n),n=null},s=()=>document.hidden?o():a();return a(),document.addEventListener(`visibilitychange`,s),()=>{e=!0,o(),document.removeEventListener(`visibilitychange`,s)}},[]),{live:e,samples:n}}var Jxe=(0,v.lazy)(()=>C(()=>import(`./TrafficChart-DME0-Hqp.js`).then(e=>({default:e.TrafficChart})),__vite__mapDeps([0,1]))),D7=3e4,Yxe={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 Xxe(e,t){return!e||e===`(unknown)`?t(`statsUnknown`):AH(e,t)}function Zxe(e,t,n){return!t||t===`(unassigned)`?n:e.find(e=>e.id===t)?.name||t}var Qxe=new Set([`quota`,`rate_limit`,`auth`,`not_ready`,`unavailable`,`invalid_request`,`model_not_available`]);function O7(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 $xe=[`ok`,`incomplete`,`error`,`canceled`],k7={ok:`bg-success`,incomplete:`bg-warning`,error:`bg-danger`,canceled:`bg-muted`},A7={ok:`logsFilterOk`,incomplete:`logsFilterIncomplete`,error:`logsFilterError`,canceled:`logsFilterCanceled`};function j7(e,t){return t>0?e/t:null}function eSe(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 tSe(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 nSe(e,t){return t?`danger`:(e??0)>=80?`warning`:`ok`}function rSe(){let{lang:e,t}=EI(),{overview:n,loading:r,error:i}=qI(),[a,o]=(0,v.useState)(`today`),[s,c]=(0,v.useState)(null),[l,u]=(0,v.useState)(!1),d=at(),[f,p]=(0,v.useState)(null),[m,h]=(0,v.useState)(``),[g,_]=(0,v.useState)(!0),[y,b]=(0,v.useState)([]),[x,S]=(0,v.useState)(!0),[C,w]=(0,v.useState)(0),[T,E]=(0,v.useState)(null),[D,O]=(0,v.useState)(()=>Date.now()),{live:k,samples:A}=qxe(),[j,M]=(0,v.useState)(!1),N=new Map((k?.accounts??[]).map(e=>[e.id,e])),P=!!n?.proxy?.ok,F=!!n?.worker?.ok,I=n?.worker?.ready_count??0,L=n?.worker?.hot_count??0,R=n?.worker?.cooling_count??0,z=k?.in_flight??n?.worker?.in_flight??0,B=f??Yxe,V=n?.routing?.session_affinity,H=(V?.hits??0)+(V?.misses??0),ee=j7(V?.hits??0,H),te=y.map(e=>({account:e,until:tSe(e,D)})).filter(e=>e.until!=null),ne=te.length>0;(0,v.useEffect)(()=>{if(!ne)return;let e=setInterval(()=>O(Date.now()),1e3);return()=>clearInterval(e)},[ne]),(0,v.useEffect)(()=>{let e=!1;return Promise.allSettled([PI(!1),VI()]).then(([t,n])=>{e||(t.status===`fulfilled`&&b(t.value.data||[]),n.status===`fulfilled`&&w((n.value.data||[]).length))}).finally(()=>{e||S(!1)}),()=>{e=!0}},[]);let re=s?.start?.toString()??``,ie=s?.end?.toString()??``,ae=(0,v.useRef)(0),oe=(0,v.useCallback)(e=>{let t=vH(a,s);if(!t){_(!1);return}let n=++ae.current;ZV(t).then(e=>{n===ae.current&&(p(e),h(``))}).catch(t=>{n!==ae.current||e||(p(null),h(t instanceof Error?t.message:String(t)))}).finally(()=>{n===ae.current&&_(!1)})},[a,re,ie]);(0,v.useEffect)(()=>(oe(!1),()=>{ae.current++}),[oe]),(0,v.useEffect)(()=>{if(l)return;let e=Date.now(),t=()=>{document.hidden||(e=Date.now(),oe(!0))},n=setInterval(t,D7),r=()=>{!document.hidden&&Date.now()-e>=D7&&t()};return document.addEventListener(`visibilitychange`,r),()=>{clearInterval(n),document.removeEventListener(`visibilitychange`,r)}},[l,oe]),(0,v.useEffect)(()=>{let e=!1,t=()=>{Aoe().then(t=>{e||E(t)}).catch(()=>{})};t();let n=setInterval(t,5e3);return()=>{e=!0,clearInterval(n)}},[]);let se=Math.floor(B.series.length/2),ce=(e,t)=>e.reduce((e,n)=>e+n[t],0),le=B.series.slice(0,se),ue=B.series.slice(se),de=((e,t)=>e>0?(t-e)/e:null)(ce(le,`requests`),ce(ue,`requests`)),fe=ce(le,`requests`)?ce(le,`ok`)/ce(le,`requests`):null,pe=ce(ue,`requests`)?ce(ue,`ok`)/ce(ue,`requests`):null,me=fe!=null&&pe!=null?pe-fe:null,he=[{label:t(`metricRequests`),value:B.totals.requests,kind:`compact`,detail:t(`statsWindowHint`,{window:t(_H[a])}),ok:B.totals.requests>0,trend:de},{label:t(`metricSuccess`),value:B.totals.success_rate,kind:`percent`,detail:`${B.totals.ok} ${t(`logsFilterOk`)} · ${B.totals.incomplete} ${t(`logsFilterIncomplete`)} · ${B.totals.error} ${t(`logsFilterError`)}`,ok:B.totals.requests===0||B.totals.success_rate>=.9,trend:me},{label:t(`metricLatency`),value:B.latency.p95_ms??B.latency.avg_ms,kind:`ms`,detail:`p50 ${eH(B.latency.p50_ms)} · avg ${eH(B.latency.avg_ms)}`,ok:B.latency.p95_ms==null||B.latency.p95_ms<8e3,trend:null},{label:t(`metricTokens`),value:B.tokens.total,kind:`compact`,detail:`${$V(B.tokens.prompt)} / ${$V(B.tokens.completion)}`,ok:!0,trend:null}],ge=j7(B.tokens.cache_read,B.tokens.prompt),_e=j7(B.totals.streaming,B.totals.requests),ve=[{label:t(`metricCacheHit`),value:ge,kind:`percent`,detail:t(`metricCacheHitDetail`,{read:$V(B.tokens.cache_read),prompt:$V(B.tokens.prompt)})},{label:t(`metricStreaming`),value:_e,kind:`percent`,detail:t(`metricStreamingDetail`,{count:B.totals.streaming,total:B.totals.requests})},{label:t(`metricCanceled`),value:B.totals.canceled,kind:`int`,detail:t(`metricCanceledDetail`,{rate:nH(j7(B.totals.canceled,B.totals.requests)??0)})}],ye=$xe.map(e=>({key:e,count:B.status.find(t=>t.key===e)?.count??B.totals[e]??0})),be=e=>bH(e,B.window.from,B.window.to);return r&&!n?(0,G.jsx)(Mse,{}):(0,G.jsxs)(`div`,{className:`space-y-5 sm:space-y-4`,children:[(0,G.jsxs)(`section`,{className:`grid gap-3 pb-1 lg:grid-cols-[minmax(0,1fr)_auto] lg:items-end`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h2`,{"data-gsap-reveal":!0,className:`text-title font-semibold`,children:t(`homeDisplay`)}),(0,G.jsx)(`p`,{className:`mt-1 max-w-2xl text-body leading-6 text-muted`,children:t(`homeLead`)})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,G.jsx)(yH,{value:a,onChange:o,custom:s,onCustomChange:c,onBusy:()=>_(!0),t}),(0,G.jsxs)(PM,{delay:300,children:[(0,G.jsx)(J,{isIconOnly:!0,size:`sm`,variant:`ghost`,"aria-label":t(l?`statsRefreshResume`:`statsRefreshPause`),"aria-pressed":l,onPress:()=>u(e=>!e),children:l?(0,G.jsx)(xa,{size:14}):(0,G.jsx)(_a,{size:14})}),(0,G.jsx)(PM.Content,{children:t(l?`statsRefreshPaused`:`statsRefreshAuto`)})]}),(0,G.jsxs)(`div`,{className:`text-left sm:text-right`,children:[(0,G.jsx)(`div`,{className:`mono text-caption text-muted`,children:n?.time||`—`}),(0,G.jsxs)(`div`,{className:`mt-1 inline-flex items-center gap-2 text-body font-medium`,children:[(0,G.jsx)(`span`,{className:`status-dot`,"data-state":P&&F?`ok`:`danger`}),t(P&&F?`running`:`degraded`)]})]})]})]}),i?(0,G.jsx)(QI,{title:t(`failedOverview`,{msg:i})}):null,(0,G.jsx)(Ace,{live:k,samples:A,t,onConcurrencyClick:()=>M(!0)}),(0,G.jsx)(Kxe,{t,expanded:j,onExpandedChange:M,live:j?k:null}),(0,G.jsx)(`section`,{"data-gsap-reveal":!0,className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-4`,children:he.map(e=>(0,G.jsxs)(HS,{className:`gap-0 p-3.5`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,G.jsx)(`div`,{className:`text-body text-muted`,children:e.label}),(0,G.jsx)(`span`,{className:`status-dot`,"data-state":e.ok?`ok`:`danger`})]}),(0,G.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`div`,{className:`tabular text-metric font-medium leading-none`,children:g?(0,G.jsx)(Q,{className:`h-7 w-24`}):e.value==null?`—`:(0,G.jsx)(dH,{value:e.value,kind:e.kind})}),!g&&e.trend!=null?(0,G.jsx)(aSe,{value:e.trend,hint:t(`trendHalfHint`)}):null]}),(0,G.jsx)(`div`,{className:`mono mt-2 truncate text-caption text-muted`,children:g?(0,G.jsx)(Q,{className:`h-3 w-28`}):e.detail})]},e.label))}),(0,G.jsx)(`section`,{className:`grid gap-3 sm:grid-cols-3`,children:ve.map(e=>(0,G.jsx)(HS,{className:`gap-0 p-3.5`,children:(0,G.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:gap-3`,children:[(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`div`,{className:`text-body text-muted`,children:e.label}),(0,G.jsx)(`div`,{className:`mono mt-0.5 truncate text-caption text-muted`,children:g?(0,G.jsx)(Q,{className:`h-3 w-28`}):e.detail})]}),(0,G.jsx)(`div`,{className:`tabular text-section font-semibold sm:shrink-0`,children:g?(0,G.jsx)(Q,{className:`h-5 w-12`}):e.value==null?`—`:(0,G.jsx)(dH,{value:e.value,kind:e.kind})})]})},e.label))}),(0,G.jsx)(`section`,{className:`grid gap-3`,children:(0,G.jsxs)(HS,{"data-gsap-reveal":!0,className:`overflow-hidden p-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-separator px-4 py-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`font-semibold`,children:t(`statsTraffic`)}),(0,G.jsx)(`p`,{className:`mt-0.5 text-caption text-muted`,children:t(`statsTrafficHint`)})]}),(0,G.jsx)(aC,{size:`sm`,variant:`soft`,color:B.totals.error?`warning`:`success`,children:nH(B.totals.success_rate)})]}),(0,G.jsxs)(`div`,{className:`space-y-4 p-4`,children:[m?(0,G.jsx)(`div`,{className:`text-body text-danger`,children:t(`failedStats`,{msg:m})}):g?(0,G.jsx)(IV,{}):B.series.some(e=>e.requests>0)?(0,G.jsx)(v.Suspense,{fallback:(0,G.jsx)(IV,{}),children:(0,G.jsx)(Jxe,{series:B.series,lang:e,emptyLabel:t(`statsEmptyTraffic`),okLabel:t(`logsFilterOk`),errorLabel:t(`logsFilterError`),selectHint:t(`statsDragHint`),labels:{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`)},onSelectRange:(e,t)=>d(bH({},e,t))})}):(0,G.jsx)(fH,{emptyLabel:t(`statsEmptyTraffic`)}),(0,G.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`),eH(B.latency.p50_ms)],[t(`statsLatencyP95`),eH(B.latency.p95_ms)],[t(`statsLatencyAvg`),eH(B.latency.avg_ms)],[t(`statsTTFB`),eH(B.latency.ttfb_avg_ms)]].map(([e,t])=>(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-caption text-muted`,children:e}),(0,G.jsx)(`div`,{className:`mono mt-1 text-body font-medium`,children:g?(0,G.jsx)(Q,{className:`h-4 w-16`}):t})]},String(e)))})]})]})}),(0,G.jsxs)(`section`,{className:`grid gap-3 xl:grid-cols-[minmax(0,1.15fr)_minmax(0,.85fr)]`,children:[(0,G.jsxs)(HS,{"data-gsap-reveal":!0,className:`overflow-hidden p-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-separator px-4 py-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`font-semibold`,children:t(`statsPool`)}),(0,G.jsx)(`p`,{className:`mt-0.5 text-caption text-muted`,children:t(`statsPoolHint`)})]}),(0,G.jsxs)(Sn,{to:`/accounts`,className:`inline-flex items-center gap-1 text-caption font-medium text-muted hover:text-foreground`,children:[t(`navAccounts`),(0,G.jsx)($r,{size:12})]})]}),(0,G.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`),I,`ok`],[t(`hot`),L,L?`ok`:``],[t(`inFlight`),z,z?`ok`:``],[t(`statsAffinityHit`),ee==null?`—`:nH(ee),``,V?t(`statsAffinityHint`,{hits:V.hits??0,misses:V.misses??0,bindings:V.bindings??0}):``]].map(([e,t,n,r])=>(0,G.jsxs)(`div`,{className:`px-4 py-3 sm:py-2.5`,title:r?String(r):void 0,children:[(0,G.jsx)(`div`,{className:`text-caption text-muted`,children:e}),(0,G.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-2 sm:mt-1`,children:[(0,G.jsx)(`span`,{className:`mono text-section font-semibold`,children:t}),n?(0,G.jsx)(`span`,{className:`status-dot`,"data-state":n}):null]})]},String(e)))}),!x&&te.length?(0,G.jsxs)(`div`,{className:`border-b border-separator px-4 py-2.5`,children:[(0,G.jsx)(`div`,{className:`text-caption font-medium text-muted`,children:t(`statsCoolingDetails`)}),(0,G.jsx)(`div`,{className:`mt-2 space-y-1.5`,children:te.map(({account:e,until:n})=>(0,G.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-caption sm:flex-row sm:items-center sm:gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`status-dot shrink-0`,"data-state":`warn`}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium`,children:e.name||e.id})]}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3 pl-4 sm:contents sm:pl-0`,children:[(0,G.jsx)(`span`,{className:`mono shrink-0 text-muted`,children:e.last_error_kind?O7(e.last_error_kind,t):t(`statsUnknown`)}),(0,G.jsx)(`span`,{className:`mono shrink-0 tabular sm:w-16 sm:text-right`,children:eSe(n,D)??`—`}),(0,G.jsx)(`span`,{className:`mono shrink-0 text-muted sm:w-12 sm:text-right`,title:t(`statsBackoffLevel`),children:e.restart_backoff_level?`L${e.restart_backoff_level}`:`—`})]})]},e.id))})]}):null,(0,G.jsx)(`div`,{className:`divide-y divide-separator`,children:x?(0,G.jsx)(FV,{}):y.length===0?(0,G.jsx)(`div`,{className:`px-4 py-6 text-body text-muted`,children:t(`noAccounts`)}):y.slice(0,6).map(e=>{let n=e.quota,r=nSe(n?.percentage,n?.exceeded),i=N.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,G.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,G.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-3 sm:items-center`,children:[(0,G.jsx)(`span`,{className:`status-dot mt-1.5 shrink-0 sm:mt-0`,"data-state":e.ready?`ok`:`danger`}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,G.jsx)(MH,{provider:e.provider,size:14}),(0,G.jsx)(`div`,{className:`truncate text-body font-medium`,children:e.name||e.id})]}),(0,G.jsxs)(`div`,{className:`mono mt-0.5 text-caption text-muted`,children:[jH(e.provider,e.region,t),` · `,e.hot?t(`hot`):e.ready?t(`ready`):t(`degraded`)]})]})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2 pl-6 sm:shrink-0 sm:pl-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5`,title:t(s?`liveSaturated`:`inFlight`),"data-testid":`account-inflight`,children:[(0,G.jsx)(`span`,{className:`text-caption text-muted sm:hidden`,children:t(`inFlight`)}),(0,G.jsxs)(`span`,{className:`mono text-caption tabular ${s?`text-warning`:`text-muted`}`,children:[a,`/`,o]}),(0,G.jsx)(`span`,{className:`inline-block h-[2px] w-10 overflow-hidden rounded-[1px] bg-separator`,children:(0,G.jsx)(`span`,{className:`block h-full ${s?`bg-warning`:`bg-foreground/50`}`,style:{width:`${Math.min(100,a/o*100)}%`}})})]}),n?(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5`,title:t(`quota`),children:[(0,G.jsx)(`span`,{className:`text-caption text-muted sm:hidden`,children:t(`quota`)}),(0,G.jsxs)(`span`,{className:`mono text-caption tabular text-muted`,children:[Math.round(n.percentage??0),`%`]}),(0,G.jsx)(`span`,{className:`inline-block h-[2px] w-10 overflow-hidden rounded-[1px] bg-separator`,children:(0,G.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,G.jsxs)(`div`,{className:`flex items-center justify-between border-t border-separator px-4 py-2.5 text-caption text-muted`,children:[(0,G.jsxs)(`span`,{children:[t(`metricModels`),` `,C]}),(0,G.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=y.filter(t=>String(t.provider||`qoder`).toLowerCase()===e).length;return t?(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,G.jsx)(MH,{provider:e,size:11}),t]},e):null}),(0,G.jsx)(`span`,{children:R?`${R} ${t(`statsCooling`)}`:`${y.length} ${t(`accountCount`)}`})]})]})]}),(0,G.jsx)(iSe,{resources:T,t})]}),(0,G.jsxs)(`section`,{className:`grid gap-3 xl:grid-cols-2 2xl:grid-cols-3`,children:[(0,G.jsxs)(HS,{"data-gsap-reveal":!0,className:`overflow-hidden p-0`,children:[(0,G.jsx)(`div`,{className:`flex items-center justify-between gap-3 border-b border-separator px-4 py-3`,children:(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`font-semibold`,children:t(`statsTopProviders`)}),(0,G.jsx)(`p`,{className:`mt-0.5 text-caption text-muted`,children:t(`statsTopProvidersHint`)})]})}),g?(0,G.jsx)(FV,{}):(0,G.jsx)(N7,{empty:t(`statsNoProviders`),items:(B.providers||[]).map(e=>({key:e.key,label:Xxe(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:be({provider:e.key})}))})]}),(0,G.jsxs)(HS,{"data-gsap-reveal":!0,className:`overflow-hidden p-0`,children:[(0,G.jsx)(`div`,{className:`flex items-center justify-between gap-3 border-b border-separator px-4 py-3`,children:(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`font-semibold`,children:t(`statsTopModels`)}),(0,G.jsx)(`p`,{className:`mt-0.5 text-caption text-muted`,children:t(`providerCatalog`)})]})}),g?(0,G.jsx)(FV,{rows:4}):(0,G.jsx)(N7,{empty:t(`statsNoModels`),items:B.models.map(e=>({key:e.key,label:e.key===`(unknown)`?t(`statsUnknown`):e.key,count:e.count,href:e.key===`(unknown)`?void 0:be({model:e.key}),meta:e.latency_avg_ms==null?`${e.ok}/${e.count}`:eH(e.latency_avg_ms)}))})]}),(0,G.jsxs)(HS,{"data-gsap-reveal":!0,className:`overflow-hidden p-0`,children:[(0,G.jsx)(`div`,{className:`flex items-center justify-between gap-3 border-b border-separator px-4 py-3`,children:(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`font-semibold`,children:t(`statsStatusMix`)}),(0,G.jsx)(`p`,{className:`mt-0.5 text-caption text-muted`,children:t(`statsStatusMixHint`)})]})}),g?(0,G.jsx)(FV,{rows:4}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(oSe,{items:ye,t}),(0,G.jsx)(`div`,{className:`border-t border-separator px-4 pt-2.5 text-caption font-medium text-muted`,children:t(`statsErrorMix`)}),(0,G.jsx)(N7,{empty:t(`statsNoErrors`),danger:!0,items:B.errors.map(e=>({key:e.key,label:O7(e.key,t),count:e.count,href:Qxe.has(e.key)?be({error_kind:e.key}):void 0}))}),(0,G.jsx)(`div`,{className:`border-t border-separator px-4 pt-2.5 text-caption font-medium text-muted`,children:t(`statsTopAccounts`)}),(0,G.jsx)(N7,{empty:t(`statsNoAccounts`),items:B.accounts.slice(0,5).map(e=>({key:e.key,label:Zxe(y,e.key,t(`statsUnassigned`)),count:e.count,href:!e.key||e.key===`(unassigned)`?void 0:be({account:e.key}),meta:`${e.ok}/${e.count}`}))})]})]})]})]})}function M7(e,t){return e>=2147483648||t>=200?`danger`:e>=1073741824||t>=100?`warning`:`ok`}function iSe({resources:e,t}){let n=[...e?.workers??[]].sort((e,t)=>t.rss_bytes-e.rss_bytes),r=e?.server;return(0,G.jsxs)(HS,{"data-gsap-reveal":!0,className:`overflow-hidden p-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-separator px-4 py-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`font-semibold`,children:t(`resTitle`)}),(0,G.jsx)(`p`,{className:`mt-0.5 text-caption text-muted`,children:t(`resHint`)})]}),(0,G.jsx)(aC,{size:`sm`,variant:`soft`,color:e?`success`:`default`,children:e?tH(e.total_rss_bytes):`—`})]}),(0,G.jsx)(`div`,{className:`divide-y divide-separator`,children:e?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`px-4 py-2.5`,children:(0,G.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`status-dot shrink-0`,"data-state":M7(r?.rss_bytes??0,r?.cpu_percent??0)}),(0,G.jsx)(`div`,{className:`truncate text-body font-medium`,children:t(`resServer`)}),(0,G.jsxs)(`span`,{className:`mono text-caption text-muted`,children:[`pid `,r?.pid]})]}),(0,G.jsxs)(`div`,{className:`mono shrink-0 text-caption text-muted`,children:[tH(r?.rss_bytes),` · `,(r?.cpu_percent??0).toFixed(1),`%`]})]})}),n.length===0?(0,G.jsx)(`div`,{className:`px-4 py-3 text-body text-muted`,children:t(`resEmpty`)}):n.map(e=>(0,G.jsx)(`div`,{className:`px-4 py-2.5`,children:(0,G.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`status-dot shrink-0`,"data-state":M7(e.rss_bytes,e.cpu_percent)}),(0,G.jsx)(`div`,{className:`truncate text-body font-medium`,children:e.label||e.account_id}),(0,G.jsxs)(`span`,{className:`mono text-caption text-muted`,children:[`pid `,e.pid]})]}),(0,G.jsxs)(`div`,{className:`mono shrink-0 text-caption text-muted`,children:[tH(e.rss_bytes),` · `,e.cpu_percent.toFixed(1),`%`]})]})},e.pid))]}):(0,G.jsx)(FV,{rows:3})}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between border-t border-separator px-4 py-2.5 text-caption text-muted`,children:[(0,G.jsxs)(`span`,{className:`mono`,children:[r?.goroutines??0,` `,t(`resGoroutines`)]}),(0,G.jsx)(`span`,{className:`mono`,children:e?.sampled_at?new Date(e.sampled_at).toLocaleTimeString():`—`})]})]})}function N7({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=Z.context(()=>{let e=Z.matchMedia();e.add(`(prefers-reduced-motion: reduce)`,()=>{Z.set(`[data-rank-fill]`,{clearProps:`transform`})}),e.add(`(prefers-reduced-motion: no-preference)`,()=>{let e=Z.utils.toArray(`[data-rank-fill]`);e.length&&Z.fromTo(e,{scaleX:0},{scaleX:1,duration:.38,ease:`power2.out`,stagger:.05,transformOrigin:`0% 50%`})})},e);return()=>t.revert()},[a]),e.length?(0,G.jsx)(`div`,{ref:r,className:`divide-y divide-separator`,children:e.map(e=>{let t=(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[e.mark?(0,G.jsx)(MH,{provider:e.mark,size:14}):null,(0,G.jsx)(`div`,{className:`truncate text-body font-medium`,children:e.label})]}),(0,G.jsx)(`div`,{className:`mono shrink-0 text-caption text-muted`,children:e.meta?`${e.count} · ${e.meta}`:e.count})]}),(0,G.jsx)(`div`,{className:`mt-2 h-1 overflow-hidden rounded-[2px] bg-separator`,children:(0,G.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,G.jsx)(Sn,{to:e.href,className:`rank-row block px-4 py-2.5`,title:e.label,children:t},e.key):(0,G.jsx)(`div`,{className:`px-4 py-2.5`,children:t},e.key)})}):(0,G.jsx)(`div`,{className:`px-4 py-6 text-body text-muted`,children:t})}function aSe({value:e,hint:t}){let n=Math.abs(e)<.005?`flat`:e>0?`up`:`down`;return(0,G.jsxs)(`span`,{className:`trend-chip`,"data-tone":n,title:t,children:[(0,G.jsx)(n===`down`?Ya:n===`up`?Za:hi,{size:12,weight:`bold`}),e>0?`+`:``,(e*100).toFixed(1),`%`]})}function oSe({items:e,t}){let n=e.reduce((e,t)=>e+t.count,0);return n?(0,G.jsxs)(`div`,{className:`px-4 py-3`,children:[(0,G.jsx)(`div`,{className:`flex h-2 gap-px overflow-hidden rounded-[3px] bg-separator`,role:`img`,"aria-label":e.map(e=>`${t(A7[e.key])} ${e.count}`).join(`, `),children:e.filter(e=>e.count>0).map(e=>(0,G.jsx)(`div`,{className:k7[e.key],style:{width:`${e.count/n*100}%`,minWidth:2}},e.key))}),(0,G.jsx)(`div`,{className:`mt-3 grid grid-cols-2 gap-x-4 gap-y-1.5`,children:e.map(e=>(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-caption`,children:[(0,G.jsx)(`span`,{className:`inline-block size-2 shrink-0 rounded-[2px] ${k7[e.key]}`}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-muted`,children:t(A7[e.key])}),(0,G.jsx)(`span`,{className:`mono tabular`,children:e.count}),(0,G.jsx)(`span`,{className:`mono w-10 text-right tabular text-muted`,children:nH(e.count/n)})]},e.key))})]}):(0,G.jsx)(`div`,{className:`px-4 py-3 text-body text-muted`,children:t(`statsEmptyTraffic`)})}function P7(e){return e?e>=1e6?`${(e/1e6).toString().replace(/\.0$/,``)}M`:e>=1e3?`${Math.round(e/1e3)}k`:String(e):`—`}function sSe({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=rH(e),s=iH(e),c=String(e.provider||e.owned_by||`qoder`).trim().toLowerCase(),l=jH(c,String(e.region||e.regions?.[0]||``).trim().toLowerCase()||void 0,t),u=c===`trae`?gce(e):void 0;return(0,G.jsx)(Y.Root,{isOpen:!0,onOpenChange:e=>{e||n()},children:(0,G.jsx)(Y.Backdrop,{variant:`blur`,children:(0,G.jsx)(Y.Container,{size:`md`,scroll:`inside`,children:(0,G.jsxs)(Y.Dialog,{children:[(0,G.jsxs)(Y.Header,{className:`items-start justify-between gap-4 px-5 pt-5`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`div`,{className:`text-section`,children:e.display_name||e.id}),s?(0,G.jsx)(aC,{size:`sm`,variant:`soft`,color:`success`,children:t(`modelFree`)}):null]}),(0,G.jsx)(`div`,{className:`mono mt-1 text-caption text-muted`,children:e.id}),(0,G.jsxs)(`div`,{className:`mt-1 text-caption text-muted`,children:[l,o?` · ${o}`:``]})]}),(0,G.jsx)(Y.CloseTrigger,{"aria-label":t(`close`),className:`grid size-8 place-items-center rounded-lg text-muted hover:bg-surface-secondary`,children:(0,G.jsx)(ao,{size:16})})]}),(0,G.jsxs)(Y.Body,{className:`space-y-4 px-5 pb-5`,children:[(0,G.jsxs)(`section`,{children:[(0,G.jsx)(`div`,{className:`text-caption font-medium text-muted`,children:t(`contextWindowCol`)}),(0,G.jsxs)(`div`,{className:`mt-1 text-body`,children:[P7(i),a&&a!==i?` → ${P7(a)}`:``]}),e.supports_max_mode?(0,G.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:t(c===`qoder`?`qoderMaxModeHint`:`maxModeHint`)}):null,!e.supports_max_mode&&a&&a!==i?(0,G.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:t(`workbuddyContextHint`)}):null,u?u.prompt_max_tokens?(0,G.jsxs)(`div`,{className:`mt-1 text-caption text-muted`,children:[t(`promptMaxTokens`),`: `,P7(u.prompt_max_tokens)]}):null:e.prompt_max_tokens?(0,G.jsxs)(`div`,{className:`mt-1 text-caption text-muted`,children:[t(`promptMaxTokens`),`: `,P7(e.prompt_max_tokens)]}):null,u?u.max_output_tokens?(0,G.jsxs)(`div`,{className:`text-caption text-muted`,children:[t(`maxOutputTokens`),`: `,P7(u.max_output_tokens)]}):null:e.max_output_tokens?(0,G.jsxs)(`div`,{className:`text-caption text-muted`,children:[t(`maxOutputTokens`),`: `,P7(e.max_output_tokens)]}):null]}),(0,G.jsxs)(`section`,{children:[(0,G.jsx)(`div`,{className:`text-caption font-medium text-muted`,children:t(`reasoningLevels`)}),r.length?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:t(`reasoningHint`)}),(0,G.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:r.map(n=>{let r=`reasoningLevel_${n}`,i=t(r);return(0,G.jsxs)(aC,{size:`sm`,variant:`soft`,color:n===(e.reasoning_effort||e.reasoning_default)?`success`:`default`,children:[i===r?n:i,n===e.reasoning_default?` · ${t(`defaultValue`)}`:``,n===e.reasoning_effort&&n!==e.reasoning_default?` · ${t(`custom`)}`:``]},n)})})]}):(0,G.jsx)(`div`,{className:`mt-1 text-body text-muted`,children:e.reasoning_type?t(`reasoningFixed`,{type:e.reasoning_type}):t(`noReasoningLevels`)})]})]})]})})})})}function F7({isSelected:e,isDisabled:t,ariaLabel:n,label:r,size:i=`sm`,onChange:a}){return(0,G.jsx)(nj,{size:i,isSelected:e,isDisabled:t,onChange:a,children:(0,G.jsxs)(nj.Content,{children:[(0,G.jsx)(nj.Control,{children:(0,G.jsx)(nj.Thumb,{})}),r?(0,G.jsx)(IN,{children:r}):(0,G.jsx)(`span`,{className:`sr-only`,children:n})]})})}function I7({title:e,hint:t,action:n,icon:r,className:i}){return(0,G.jsx)(`div`,{className:`grid min-h-56 place-items-center px-6 py-12 text-center ${i||``}`,children:(0,G.jsxs)(`div`,{className:`max-w-sm`,children:[r?(0,G.jsx)(`div`,{className:`mb-3 flex justify-center text-muted`,children:r}):null,(0,G.jsx)(Die,{className:`p-0 text-body font-medium text-foreground`,children:e}),t?(0,G.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:t}):null,n?(0,G.jsx)(`div`,{className:`mt-5 flex justify-center`,children:n}):null]})})}var L7=`__all__`;function R7({value:e,onChange:t,ariaLabel:n,options:r,className:i}){let a=r.map(e=>({id:e.id||L7,label:e.label})),o=e||L7,s=a.find(e=>e.id===o);return(0,G.jsxs)(AF,{className:i??`w-fit min-w-36`,"aria-label":n,value:o,onChange:e=>{typeof e==`string`&&t(e===L7?``:e)},children:[(0,G.jsxs)(AF.Trigger,{className:`min-w-0 w-full items-center`,children:[(0,G.jsx)(AF.Value,{className:`min-w-0 truncate`,children:({defaultChildren:e,isPlaceholder:t})=>t||!s?e:(0,G.jsx)(`span`,{className:`truncate`,children:s.label})}),(0,G.jsx)(AF.Indicator,{})]}),(0,G.jsx)(AF.Popover,{className:`max-h-72 min-w-36`,children:(0,G.jsx)(oF,{children:a.map(e=>(0,G.jsxs)(oF.Item,{id:e.id,textValue:e.label,children:[(0,G.jsx)(IN,{className:`block truncate`,children:e.label}),(0,G.jsx)(oF.ItemIndicator,{})]},e.id))})})]})}var cSe=[20,50,100],lSe=[20,50,100];function uSe(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,G.jsx)(qA,{id:String(e),children:e},e))})]}),(0,G.jsxs)(DF,{size:`sm`,className:`w-fit`,children:[(0,G.jsx)(DF.Summary,{className:`mono text-caption`,children:o}),(0,G.jsxs)(DF.Content,{children:[(0,G.jsx)(DF.Item,{children:(0,G.jsx)(DF.Previous,{isDisabled:i||t<=1,onPress:()=>l(Math.max(1,t-1)),"aria-label":s,children:(0,G.jsx)(DF.PreviousIcon,{})})}),f.map((e,n)=>e===`gap`?(0,G.jsx)(DF.Item,{children:(0,G.jsx)(DF.Ellipsis,{})},`gap-${n}`):(0,G.jsx)(DF.Item,{children:(0,G.jsx)(DF.Link,{isActive:e===t,isDisabled:i,onPress:()=>l(e),children:e})},e)),(0,G.jsx)(DF.Item,{children:(0,G.jsx)(DF.Next,{isDisabled:i||t>=n,onPress:()=>l(Math.min(n,t+1)),"aria-label":c,children:(0,G.jsx)(DF.NextIcon,{})})})]})]})]})}function B7({value:e,onChange:t,placeholder:n,ariaLabel:r,className:i}){return(0,G.jsx)(PN,{"aria-label":r,value:e,onChange:t,className:i,children:(0,G.jsxs)(PN.Group,{children:[(0,G.jsx)(PN.SearchIcon,{}),(0,G.jsx)(PN.Input,{placeholder:n}),(0,G.jsx)(PN.ClearButton,{})]})})}function dSe(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 V7(e){return e.settings_key||e.id}function H7(e){return String(e.provider||e.owned_by||`qoder`).trim().toLowerCase()}function U7(e){let t=String(e.region||``).trim().toLowerCase();if(t)return t;let n=e.regions||[];return String(n[0]||``).trim().toLowerCase()}function W7(e){return`${H7(e)}:${U7(e)||`any`}:${e.settings_key||e.id}:${e.native_model||e.mapped_key||``}`}function G7(e){let t=e.route_display_name||``;return t&&t!==(e.display_name||e.id)?t:``}function K7(e,t){let n=`reasoningLevel_${t}`,r=e(n);return r===n?t:r}function q7({label:e,hint:t}){return(0,G.jsxs)(PM,{children:[(0,G.jsx)(PM.Trigger,{children:(0,G.jsx)(`span`,{className:`cursor-help text-caption text-muted`,children:e})}),(0,G.jsx)(PM.Content,{children:(0,G.jsx)(`p`,{className:`max-w-xs text-caption leading-5`,children:t})})]})}function J7({model:e,saving:t,t:n,variant:r=`table`,onToggleTraeMax:i,onReasoningChange:a}){let o=H7(e),s=r===`card`,c=s?`w-full min-w-0`:`w-full max-w-[7.5rem] min-w-0`;return(0,G.jsxs)(`div`,{className:s?`flex min-w-0 flex-col gap-3`:`flex min-w-0 flex-col gap-1.5`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,G.jsxs)(`span`,{className:`mono text-caption text-muted`,children:[P7(e.catalog_context_length||e.context_length),e.catalog_context_length_max&&e.catalog_context_length_max!==(e.catalog_context_length||e.context_length)?` → ${P7(e.catalog_context_length_max)}`:``]}),o===`workbuddy`&&e.catalog_context_length_max&&e.catalog_context_length_max!==(e.catalog_context_length||e.context_length)?(0,G.jsx)(q7,{label:n(`catalogWindow`),hint:n(`workbuddyContextHint`)}):null]}),(o===`trae`||o===`qoder`)&&e.supports_max_mode?(0,G.jsxs)(`div`,{className:s?`flex flex-col gap-1.5`:`flex items-center gap-2`,children:[s?(0,G.jsx)(q7,{label:`${n(`maxMode`)}${e.catalog_context_length_max?` ${P7(e.catalog_context_length_max)}`:``}`,hint:n(o===`qoder`?`qoderMaxModeHint`:`maxModeHint`)}):null,(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(F7,{isSelected:!!e.max_mode,isDisabled:t,ariaLabel:`${e.id} ${n(`maxMode`)}`,onChange:t=>i(e,t)}),s?null:(0,G.jsx)(q7,{label:`${n(`maxMode`)}${e.catalog_context_length_max?` ${P7(e.catalog_context_length_max)}`:``}`,hint:n(o===`qoder`?`qoderMaxModeHint`:`maxModeHint`)})]})]}):null,(e.reasoning_options||[]).length>1?(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1.5`,children:[(0,G.jsx)(q7,{label:n(`reasoningLevels`),hint:n(`reasoningHint`)}),(0,G.jsx)(R7,{className:c,ariaLabel:`${e.id} ${n(`reasoningLevels`)}`,value:e.reasoning_effort||e.reasoning_default||e.reasoning_options?.[0]||``,onChange:t=>{t&&a(e,t)},options:(e.reasoning_options||[]).map(e=>({id:e,label:K7(n,e)}))})]}):(e.reasoning_options||[]).length===1?(0,G.jsx)(q7,{label:`${n(`reasoningLevels`)} ${K7(n,e.reasoning_options[0])}`,hint:n(`reasoningHint`)}):e.reasoning_type?(0,G.jsx)(`span`,{className:`text-caption text-muted`,children:n(`reasoningFixed`,{type:e.reasoning_type})}):o===`trae`&&!e.supports_max_mode?(0,G.jsx)(q7,{label:n(`catalogWindow`),hint:n(`catalogWindowHint`)}):null]})}function Y7({model:e,t,onDetails:n}){return(0,G.jsxs)(J,{size:`sm`,variant:`ghost`,onPress:()=>n(e),children:[(0,G.jsx)($i,{size:14}),t(`modelDetails`)]})}function fSe(){let{t:e}=EI(),{overview:t,loading:n}=qI(),[r,i]=(0,v.useState)(``),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)([]),[l,u]=(0,v.useState)(1),[d,f]=(0,v.useState)(50),[p,m]=(0,v.useState)(!1),[h,g]=(0,v.useState)(``),[_,y]=(0,v.useState)(``),[b,x]=(0,v.useState)(!1),[S,C]=(0,v.useState)(null),[w,T]=(0,v.useState)([]),[E,D]=(0,v.useState)(!0);(0,v.useEffect)(()=>{let e=!1;return ooe(void 0,`regional`).then(t=>{e||T(t.data||[])}).catch(()=>void 0).finally(()=>{e||D(!1)}),UI().then(t=>{e||c(dSe(t.data||[]))}).catch(()=>void 0),()=>{e=!0}},[]);let O=(0,v.useMemo)(()=>{let t=r.trim().toLowerCase(),[n,i]=a.includes(`:`)?a.split(`:`,2):[a,``];return w.filter(r=>{let a=H7(r),o=U7(r);if(n&&a!==n||i&&o!==i)return!1;if(!t)return!0;let s=jH(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,a,e]),k=[r,a,d].join(`\0`),[A,j]=(0,v.useState)(k);A!==k&&(j(k),u(1));let M=Math.max(1,Math.ceil(O.length/d)),N=Math.min(A===k?Math.max(1,l):1,M);l!==N&&u(N);let P=(0,v.useMemo)(()=>{let e=(N-1)*d;return O.slice(e,e+d)},[N,O,d]),F=O.length===0?0:(N-1)*d+1,I=Math.min(O.length,N*d),L=O.length?e(`logsShownTotal`,{shown:`${F}–${I}`,total:O.length}):e(`shownTotal`,{shown:0,total:w.length});if(n&&!t||E)return(0,G.jsx)(Ise,{});function R(e,t){let n=V7(e),r=H7(e),i=w.map(e=>{if(V7(e)!==n||H7(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)}});T(i)}function z(e,t){let n=V7(e),r=H7(e),i=w.map(e=>V7(e)!==n||H7(e)!==r?e:{...e,reasoning_effort:t,context_custom:!!e.max_mode||!!(t&&t!==e.reasoning_default)});T(i)}async function B(){m(!0),y(``),x(!1);try{let e=await HI(void 0,`regional`);T(e.data||[])}catch(e){x(!0),y(e instanceof Error?e.message:String(e))}finally{m(!1)}}async function V(t,n){let r=H7(t);if(r!==`trae`&&r!==`workbuddy`&&r!==`kimi`)return;let i=V7(t);g(i),y(``),x(!1);try{await coe(r,i,n),z(t,n),y(e(`reasoningSaved`,{model:t.id,level:K7(e,n)}))}catch(e){x(!0),y(e instanceof Error?e.message:String(e))}finally{g(``)}}async function H(t,n){if(!t.supports_max_mode){x(!0),y(e(`contextMaxUnavailable`));return}let r=V7(t),i=H7(t);g(r),y(``),x(!1);try{await soe(i,r,n,t.catalog_context_length_max),R(t,n),y(e(n?`contextMaxOn`:`contextMaxOff`,{model:t.id}))}catch(e){x(!0),y(e instanceof Error?e.message:String(e))}finally{g(``)}}return(0,G.jsxs)(`div`,{className:`space-y-6`,children:[(0,G.jsxs)(`section`,{className:`grid gap-5 pb-6 lg:grid-cols-[minmax(0,1fr)_auto] lg:items-end`,children:[(0,G.jsxs)(`div`,{"data-gsap-reveal":!0,children:[(0,G.jsx)(`h2`,{className:`text-title font-semibold`,children:e(`availableModels`)}),(0,G.jsx)(`p`,{className:`mt-1 text-body text-muted`,children:w.length?L:e(`noModelsYet`)})]}),(0,G.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,G.jsx)(B7,{className:`w-full min-w-0 sm:w-72`,value:r,onChange:i,placeholder:e(`filterPh`),ariaLabel:e(`filter`)}),(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,G.jsx)(R7,{ariaLabel:e(`providerCol`),value:a,onChange:o,options:[{id:``,label:e(`providerFilterAll`)},...s.map(t=>({id:t.value,label:jH(t.provider,t.region,e)}))]}),(0,G.jsxs)(J,{size:`sm`,variant:`secondary`,isPending:p,onPress:()=>void B(),children:[(0,G.jsx)(qr,{size:14}),e(p?`refreshing`:`refresh`)]})]})]})]}),_?(0,G.jsx)(QI,{status:b?`danger`:`success`,title:_}):null,(0,G.jsxs)(HS,{"data-gsap-reveal":!0,className:`overflow-hidden p-0`,children:[(0,G.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,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,G.jsx)(`div`,{className:`grid size-9 shrink-0 place-items-center rounded-lg bg-surface-secondary text-muted`,children:(0,G.jsx)(ji,{size:16})}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`div`,{className:`text-body font-semibold`,children:e(`providerCatalog`)}),(0,G.jsx)(`div`,{className:`mt-0.5 text-caption leading-5 text-muted`,children:e(`contextConfigHint`)})]})]}),(0,G.jsx)(aC,{size:`sm`,variant:`soft`,className:`shrink-0`,children:O.length})]}),p||n?(0,G.jsx)(LV,{}):O.length===0?(0,G.jsx)(I7,{icon:(0,G.jsx)(la,{size:22}),title:w.length?e(`noModelsMatch`):e(`noProviders`),hint:w.length?r||a||e(`noModelsMatch`):e(`noModelsYet`)}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`divide-y divide-separator lg:hidden`,children:P.map(t=>{let n=V7(t),r=h===n,i=H7(t),a=jH(i,U7(t)||void 0,e),o=rH(t),s=iH(t);return(0,G.jsxs)(`article`,{className:`space-y-3 px-4 py-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,G.jsx)(`span`,{className:`status-dot mt-1.5`,"data-state":t.stale?void 0:`ok`}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`div`,{className:`truncate font-medium`,children:t.display_name||t.id}),s?(0,G.jsx)(aC,{size:`sm`,variant:`soft`,color:`success`,children:e(`modelFree`)}):null,o?(0,G.jsx)(`span`,{className:`mono text-caption text-muted`,children:o}):null]}),(0,G.jsx)(`div`,{className:`mono mt-0.5 truncate text-caption text-muted`,children:t.id}),G7(t)?(0,G.jsx)(`div`,{className:`mt-0.5 text-caption text-muted`,children:e(`routedTo`,{model:G7(t)})}):null]})]}),(0,G.jsx)(aC,{size:`sm`,variant:`soft`,color:t.context_custom||t.stale?`warning`:`success`,children:t.context_custom?e(`custom`):e(`defaultValue`)})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-caption`,children:[(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,G.jsx)(MH,{provider:i,size:14}),(0,G.jsx)(`span`,{className:`font-medium`,children:a})]}),(0,G.jsx)(`span`,{className:`mono break-all text-muted`,children:t.mapped_key||t.native_model||t.id})]}),(0,G.jsx)(J7,{model:t,saving:r,t:e,variant:`card`,onToggleTraeMax:(e,t)=>void H(e,t),onReasoningChange:(e,t)=>void V(e,t)}),(0,G.jsx)(Y7,{model:t,t:e,onDetails:C})]},W7(t))})}),(0,G.jsx)(X,{className:`hidden min-w-0 lg:block`,children:(0,G.jsx)(X.ScrollContainer,{className:`min-w-0 overflow-x-auto`,children:(0,G.jsxs)(X.Content,{"aria-label":e(`availableModels`),className:`min-w-[68rem]`,children:[(0,G.jsxs)(X.Header,{children:[(0,G.jsx)(X.Column,{isRowHeader:!0,children:e(`modelCol`)}),(0,G.jsx)(X.Column,{children:e(`requestIdCol`)}),(0,G.jsx)(X.Column,{children:e(`providerCol`)}),(0,G.jsx)(X.Column,{children:e(`qoderKeyCol`)}),(0,G.jsx)(X.Column,{children:e(`modelDefaultsCol`)}),(0,G.jsx)(X.Column,{children:e(`stateCol`)}),(0,G.jsx)(X.Column,{children:e(`actions`)})]}),(0,G.jsx)(X.Body,{children:P.map(t=>{let n=V7(t),r=h===n,i=H7(t),a=jH(i,U7(t)||void 0,e),o=rH(t),s=iH(t);return(0,G.jsxs)(X.Row,{children:[(0,G.jsx)(X.Cell,{children:(0,G.jsxs)(`div`,{className:`flex items-center gap-3 py-1`,children:[(0,G.jsx)(`span`,{className:`status-dot`,"data-state":t.stale?void 0:`ok`}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`div`,{className:`font-medium`,children:t.display_name||t.id}),s?(0,G.jsx)(aC,{size:`sm`,variant:`soft`,color:`success`,children:e(`modelFree`)}):null,o?(0,G.jsx)(`span`,{className:`mono text-caption text-muted`,children:o}):null]}),G7(t)?(0,G.jsx)(`div`,{className:`mt-0.5 text-caption text-muted`,children:e(`routedTo`,{model:G7(t)})}):null]})]})}),(0,G.jsx)(X.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-caption font-medium`,children:t.id})}),(0,G.jsx)(X.Cell,{children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(MH,{provider:i,size:14}),(0,G.jsx)(`span`,{className:`text-caption font-medium`,children:a})]})}),(0,G.jsx)(X.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-caption text-muted`,children:t.mapped_key||t.native_model||t.id})}),(0,G.jsx)(X.Cell,{children:(0,G.jsx)(J7,{model:t,saving:r,t:e,variant:`table`,onToggleTraeMax:(e,t)=>void H(e,t),onReasoningChange:(e,t)=>void V(e,t)})}),(0,G.jsx)(X.Cell,{children:(0,G.jsx)(aC,{size:`sm`,variant:`soft`,color:t.context_custom||t.stale?`warning`:`success`,children:t.context_custom?e(`custom`):e(`defaultValue`)})}),(0,G.jsx)(X.Cell,{children:(0,G.jsx)(Y7,{model:t,t:e,onDetails:C})})]},W7(t))})})]})})})]})]}),(0,G.jsx)(sSe,{model:S?w.find(e=>V7(e)===V7(S))||S:null,t:e,onClose:()=>C(null)}),(0,G.jsx)(z7,{total:O.length,page:N,pageCount:M,pageSize:d,loading:p,pageSizeLabel:e(`logsPageSize`),pageLabel:e(`logsPage`,{page:N,pages:M}),prevLabel:e(`logsPrevPage`),nextLabel:e(`logsNextPage`),onPage:u,onPageSize:f})]})}function X7({copied:e,size:t=14,className:n}){let r=(0,v.useRef)(null),i=(0,v.useRef)(null),a=(0,v.useRef)(!0);return(0,v.useLayoutEffect)(()=>{let t=e?i.current:r.current,n=e?r.current:i.current;if(!t||!n)return;let o={autoAlpha:1,scale:1,filter:`blur(0px)`},s={autoAlpha:0,scale:.5,filter:`blur(4px)`};if(a.current||jV()){a.current=!1,Z.set(t,o),Z.set(n,s);return}Z.to(n,{...s,duration:kV.fast,ease:AV.out,overwrite:!0}),Z.fromTo(t,s,{...o,duration:kV.base,ease:AV.soft,delay:kV.instant/2,overwrite:!0})},[e]),(0,G.jsxs)(`span`,{className:`relative inline-grid place-items-center ${n??``}`,style:{width:t,height:t},children:[(0,G.jsx)(`span`,{ref:r,className:`col-start-1 row-start-1 inline-flex`,children:(0,G.jsx)(Di,{size:t})}),(0,G.jsx)(`span`,{ref:i,className:`col-start-1 row-start-1 inline-flex text-success`,children:(0,G.jsx)(_i,{size:t})})]})}async function Z7(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}}function Q7(){return`${location.protocol}//${location.host}`}function $7(e){return e?/^https?:\/\//i.test(e)?e:e.startsWith(`/`)?`${Q7()}${e}`:`${Q7()}/${e}`:Q7()}function pSe({access:e}){let{t}=EI(),[n,r]=(0,v.useState)(``),i=$7(e?.openai_base_url||`/v1`),a=(0,v.useMemo)(()=>[{name:t(`endpointOpenAI`),url:i,method:`BASE`,hint:t(`endpointBaseHint`),icon:(0,G.jsx)(ai,{size:15})},{name:t(`endpointChat`),url:$7(e?.chat_completions||`${i}/chat/completions`),method:`POST`,hint:t(`endpointChatHint`),icon:(0,G.jsx)(ha,{size:15})},{name:t(`endpointMessages`),url:$7(e?.messages||`${i}/messages`),method:`POST`,hint:t(`endpointMessagesHint`),icon:(0,G.jsx)(ha,{size:15})},{name:t(`endpointResponses`),url:$7(e?.responses||`${i}/responses`),method:`POST`,hint:t(`endpointResponsesHint`),icon:(0,G.jsx)(ha,{size:15})},{name:t(`endpointModels`),url:$7(e?.models||`${i}/models`),method:`GET`,hint:t(`endpointModelsHint`),icon:(0,G.jsx)(sa,{size:15})},{name:t(`endpointHealth`),url:$7(e?.health||`/health`),method:`GET`,hint:t(`endpointHealthHint`),icon:(0,G.jsx)(Zi,{size:15})}],[e,i,t]);return(0,G.jsxs)(`section`,{className:`overflow-hidden rounded-3xl bg-surface shadow-surface`,children:[(0,G.jsx)(`div`,{className:`flex items-start justify-between gap-4 px-5 py-4 sm:px-6`,children:(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`h3`,{className:`font-semibold`,children:t(`endpoints`)}),(0,G.jsx)(aC,{size:`sm`,variant:`soft`,children:t(`endpointCount`,{count:a.length-1})})]}),(0,G.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:t(`routesHint`)})]})}),(0,G.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:a.map(e=>(0,G.jsxs)(`div`,{className:`group min-w-0 rounded-xl bg-surface-secondary/40 p-3 transition-colors hover:bg-surface-secondary/70`,children:[(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-2.5`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,G.jsx)(`span`,{className:`grid size-7 shrink-0 place-items-center rounded-lg bg-surface text-muted`,children:e.icon}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`div`,{className:`truncate text-body font-semibold`,children:e.name}),(0,G.jsx)(`code`,{className:`mono mt-0.5 block truncate text-caption text-muted`,children:e.url})]})]}),(0,G.jsx)(aC,{size:`sm`,variant:`soft`,children:e.method})]}),(0,G.jsx)(`p`,{className:`mt-2 text-caption leading-5 text-muted`,children:e.hint}),(0,G.jsxs)(`div`,{className:`mt-2 flex items-center justify-between gap-2`,children:[(0,G.jsx)(`span`,{className:`text-caption font-medium text-muted`,children:e.method===`BASE`?t(`endpointBaseLabel`):t(`endpointAuthLabel`)}),(0,G.jsxs)(`div`,{className:`flex gap-1`,children:[(0,G.jsx)(J,{isIconOnly:!0,size:`sm`,variant:`ghost`,"aria-label":t(`copy`),onPress:()=>{Z7(e.url),r(e.name),window.setTimeout(()=>r(``),1100)},children:(0,G.jsx)(X7,{copied:n===e.name})}),(0,G.jsx)(J,{isIconOnly:!0,size:`sm`,variant:`ghost`,"aria-label":t(`open`),onPress:()=>window.open(e.url,`_blank`,`noopener,noreferrer`),children:(0,G.jsx)(Zr,{size:14})})]})]})]},e.name))})]})}var mSe=`https://caiaiu.com`;function e9({className:e=``}){let{t}=EI();return(0,G.jsx)(`p`,{className:`text-caption leading-5 text-muted ${e}`.trim(),children:(0,G.jsx)(`a`,{href:mSe,target:`_blank`,rel:`noopener noreferrer`,className:`underline-offset-2 transition-colors hover:text-foreground hover:underline`,children:t(`caiaiSoftLink`)})})}var hSe=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(`.`)),gSe=new Set([`image/png`,`image/jpeg`,`image/jpg`,`image/gif`,`image/webp`]);function _Se(e){let t=e.lastIndexOf(`.`);return t>=0?e.slice(t+1).toLowerCase():``}function vSe(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}async function ySe(e){let t=_Se(e.name),n=e.type||`application/octet-stream`,r=`${e.name}-${e.size}-${e.lastModified}-${Math.random().toString(36).slice(2,8)}`;if(gSe.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(hSe.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 t9({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,G.jsxs)(AF,{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,G.jsxs)(AF.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,G.jsx)(AF.Value,{className:`min-w-0 truncate text-caption font-medium`,children:({defaultChildren:e,isPlaceholder:t})=>t||!c?e:(0,G.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1`,children:[c.icon?(0,G.jsx)(`span`,{className:`grid size-3.5 shrink-0 place-items-center opacity-80`,children:c.icon}):null,(0,G.jsx)(`span`,{className:`truncate`,children:c.label})]})}),(0,G.jsx)(AF.Indicator,{className:`size-2.5 opacity-50`})]}),(0,G.jsx)(AF.Popover,{placement:`top end`,className:`max-h-72 min-w-48`,children:(0,G.jsx)(oF,{children:a.map(e=>(0,G.jsxs)(oF.Item,{id:e.id,textValue:e.textValue,className:`gap-2`,children:[e.icon?(0,G.jsx)(`span`,{className:`grid size-5 shrink-0 place-items-center`,children:e.icon}):null,(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(IN,{className:`block truncate text-caption`,children:e.label}),e.hint?(0,G.jsx)(`span`,{className:`block truncate text-caption text-muted`,children:e.hint}):null]}),(0,G.jsx)(oF.ItemIndicator,{})]},e.id))})})]})}function bSe({value:e,onChange:t,attachments:n,onAttachmentsChange:r,disabled:i,streaming:a,canSend:o,onSend:s,onStop:c,accountValue:l,onAccountChange:u,accountOptions:d,modelValue:f,onModelChange:p,modelOptions:m,modelsLoading:h}){let{t:g}=EI(),_=(0,v.useRef)(null);async function y(e){if(!e?.length)return;let t=[],i=[];for(let n of Array.from(e))try{let e=await ySe(n);e?t.push(e):i.push(n.name)}catch{i.push(n.name)}t.length&&r([...n,...t]),i.length&&window.alert(g(`chatAttachUnsupported`,{names:i.join(`, `)})),_.current&&(_.current.value=``)}function b(e){e.key!==`Enter`||e.shiftKey||e.nativeEvent.isComposing||(e.preventDefault(),!a&&o&&s())}return(0,G.jsxs)(`div`,{className:`access-composer px-3 pb-3 pt-2.5 sm:px-4 sm:pb-3.5 sm:pt-3`,children:[(0,G.jsxs)(`div`,{className:`access-composer-well overflow-hidden rounded-2xl`,children:[n.length?(0,G.jsx)(`div`,{className:`flex flex-wrap gap-2 px-3 pt-3`,children:n.map(e=>(0,G.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,G.jsx)(`img`,{src:e.dataUrl,alt:``,className:`size-8 shrink-0 rounded-lg object-cover`}):(0,G.jsx)(`span`,{className:`grid size-8 shrink-0 place-items-center rounded-lg bg-surface-secondary text-muted`,children:(0,G.jsx)(Ui,{size:14})}),(0,G.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`span`,{className:`block truncate font-medium`,children:e.name}),(0,G.jsx)(`span`,{className:`mono text-muted`,children:vSe(e.size)})]}),(0,G.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":g(`chatAttachRemove`),onClick:()=>r(n.filter(t=>t.id!==e.id)),children:(0,G.jsx)(ao,{size:12})})]},e.id))}):null,(0,G.jsx)(JM,{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:b,placeholder:g(`promptPlaceholder`),"aria-label":g(`prompt`),disabled:i||a}),(0,G.jsxs)(`div`,{className:`flex items-center gap-0.5 px-2 pb-2 pt-0.5`,children:[(0,G.jsx)(`input`,{ref:_,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 y(e.target.files)}),(0,G.jsx)(J,{isIconOnly:!0,size:`sm`,variant:`ghost`,className:`size-8 min-w-8 shrink-0 rounded-[10px]`,"aria-label":g(`chatAttach`),isDisabled:i||a,onPress:()=>_.current?.click(),children:(0,G.jsx)(Ca,{size:15})}),(0,G.jsx)(`div`,{className:`min-w-0 flex-1`}),(0,G.jsx)(t9,{ariaLabel:g(`account`),value:l,onChange:u,options:d,isDisabled:i||a,tone:`muted`,className:`w-auto max-w-[8.5rem] min-w-0`}),(0,G.jsx)(t9,{ariaLabel:g(`model`),value:f,onChange:p,placeholder:g(h?`requesting`:`model`),options:m,isDisabled:i||a||h||!m.length,className:`w-auto max-w-[10.5rem] min-w-0`}),(0,G.jsxs)(`div`,{className:`relative size-8 shrink-0`,children:[(0,G.jsx)(J,{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":g(`chatTryStop`),onPress:c,children:(0,G.jsx)(Va,{size:14,weight:`fill`})}),(0,G.jsx)(J,{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":g(`chatTrySend`),isDisabled:!o||i||a,onPress:s,children:(0,G.jsx)(ha,{size:14,weight:`fill`})})]})]})]}),(0,G.jsx)(`p`,{className:`mt-1 px-1 text-caption leading-4 text-muted/65`,children:g(`chatTryHelper`)})]})}function xSe({collapsed:e,onCollapsedChange:t,items:n,activeId:r,onSelect:i,onNew:a}){let{t:o}=EI(),s=(0,v.useRef)(null);return(0,v.useEffect)(()=>{let t=s.current;!t||jV()||e||Z.fromTo(t,{autoAlpha:0},{autoAlpha:1,duration:kV.fast,ease:`power2.out`})},[e]),e?(0,G.jsxs)(`div`,{className:`access-hist-rail flex w-9 shrink-0 flex-col items-center gap-1 border-r py-2`,children:[(0,G.jsx)(J,{isIconOnly:!0,size:`sm`,variant:`ghost`,className:`size-8 min-w-8 rounded-[10px] text-muted`,"aria-label":o(`chatHistoryExpand`),onPress:()=>t(!1),children:(0,G.jsx)(ka,{size:15})}),(0,G.jsx)(J,{isIconOnly:!0,size:`sm`,variant:`ghost`,className:`size-8 min-w-8 rounded-[10px] text-muted`,"aria-label":o(`chatHistoryNew`),onPress:a,children:(0,G.jsx)(Ca,{size:14})})]}):(0,G.jsxs)(`aside`,{ref:s,className:`access-hist-rail flex w-[13rem] shrink-0 flex-col border-r`,"aria-label":o(`chatHistoryTitle`),children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1 px-2 py-2`,children:[(0,G.jsx)(`div`,{className:`min-w-0 flex-1 truncate px-1.5 text-caption font-medium text-muted`,children:o(`chatHistoryTitle`)}),(0,G.jsx)(J,{isIconOnly:!0,size:`sm`,variant:`ghost`,className:`size-8 min-w-8 rounded-[10px] text-muted`,"aria-label":o(`chatHistoryCollapse`),onPress:()=>t(!0),children:(0,G.jsx)(li,{size:14})})]}),(0,G.jsx)(`div`,{className:`px-2 pb-1.5`,children:(0,G.jsxs)(J,{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:a,children:[(0,G.jsx)(Ca,{size:13}),o(`chatHistoryNew`)]})}),(0,G.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===r;return(0,G.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:()=>i(e.id),children:(0,G.jsx)(`span`,{className:`line-clamp-1 tracking-tight`,children:e.title||o(`chatHistoryUntitled`)})},e.id)}):(0,G.jsx)(`p`,{className:`px-2.5 py-6 text-center text-caption leading-5 text-muted/70`,children:o(`chatHistoryEmpty`)})})]})}function n9({latencyMs:e,ttfbMs:t,completionTokens:n,stream:r,labels:i,className:a=``,variant:o=`block`}){let s=dce(uce({completionTokens:n,latencyMs:e,ttfbMs:t,stream:r})),c=eH(t),l=eH(e);if(o===`inline`)return(0,G.jsxs)(`div`,{className:`mono text-caption leading-4 text-muted ${a}`.trim(),children:[(0,G.jsxs)(`span`,{children:[i.ttft,` `,c]}),(0,G.jsx)(`span`,{className:`mx-1.5 text-separator`,children:`·`}),(0,G.jsxs)(`span`,{children:[i.total,` `,l]}),(0,G.jsx)(`span`,{className:`mx-1.5 text-separator`,children:`·`}),(0,G.jsx)(`span`,{children:s})]});let u=[[i.ttft,c],[i.total,l],[i.tps,s]];return(0,G.jsxs)(`div`,{className:a,children:[i.heading?(0,G.jsx)(`div`,{className:`mb-1 text-caption font-medium text-muted`,children:i.heading}):null,(0,G.jsx)(`div`,{className:`border-l border-separator pl-2 leading-4`,children:u.map(([e,t])=>(0,G.jsxs)(`div`,{className:`flex items-baseline gap-2 py-px`,children:[(0,G.jsx)(`span`,{className:`shrink-0 text-caption text-muted`,children:e}),(0,G.jsx)(`span`,{className:`mono text-xs text-foreground`,children:t})]},e))})]})}function SSe({text:e,streaming:t,defaultOpen:n}){let{t:r}=EI(),[i,a]=(0,v.useState)(!!n),[o,s]=(0,v.useState)(0),c=(0,v.useRef)(0),l=(0,v.useRef)(null),u=(0,v.useRef)(null);if((0,v.useEffect)(()=>{t?a(!1):n!=null&&a(!!n)},[t,n]),(0,v.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,v.useEffect)(()=>{!t&&o===0&&c.current>0&&s(c.current)},[t,o]),(0,v.useEffect)(()=>{let t=l.current,n=u.current;if(!t)return;let r=jV();if(!i||!e){if(r){t.style.height=`0px`,t.style.opacity=`0`;return}Z.to(t,{height:0,opacity:0,duration:kV.fast,ease:AV.inOut,overwrite:!0});return}let a=n?.scrollHeight??0;if(r){t.style.height=`auto`,t.style.opacity=`1`;return}Z.fromTo(t,{height:0,opacity:0},{height:a,opacity:1,duration:kV.base,ease:AV.out,overwrite:!0,onComplete:()=>{t.style.height=`auto`}})},[i,e]),!e&&!t)return null;let d=jV(),f=t?o:o||c.current;return(0,G.jsxs)(`div`,{className:`overflow-hidden rounded-xl`,children:[(0,G.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,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Ci,{size:12,className:`shrink-0 text-muted ${d?``:`animate-spin`}`}),(0,G.jsx)(`span`,{className:d?``:`access-thinking-shimmer`,children:r(`thinkingWorking`)}),(0,G.jsxs)(`span`,{className:`mono text-muted/80`,children:[o,`s`]})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(di,{size:11,className:`shrink-0 transition-transform duration-200 ease-out ${i?`rotate-90`:``}`}),(0,G.jsx)(`span`,{children:r(`thinkingDone`)}),f>0?(0,G.jsx)(`span`,{className:`mono text-muted/80`,children:r(`thinkingElapsed`,{n:f})}):null,!f&&e?(0,G.jsx)(`span`,{className:`mono text-muted/80`,children:r(`thinkingChars`,{count:e.length})}):null]})}),(0,G.jsx)(`div`,{ref:l,className:`overflow-hidden`,style:{height:0,opacity:0},children:e?(0,G.jsx)(`pre`,{ref:u,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 CSe(e,t){return t(e===`running`?`toolCallRunning`:e===`error`?`toolCallError`:`toolCallSuccess`)}function wSe({status:e}){return e===`running`?(0,G.jsx)(Fa,{size:12,className:`animate-spin text-muted`}):e===`error`?(0,G.jsx)(ro,{size:12,weight:`fill`,className:`text-danger`}):(0,G.jsx)(yi,{size:12,weight:`fill`,className:`text-success`})}function TSe(e){if(!e.trim())return``;try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function r9({call:e,forceOpen:t}){let{t:n}=EI(),[r,i]=(0,v.useState)(e.status===`error`||!!t),[a,o]=(0,v.useState)(!1),s=(0,v.useMemo)(()=>TSe(e.arguments||``),[e.arguments]);(0,v.useEffect)(()=>{e.status===`error`&&i(!0)},[e.status]),(0,v.useEffect)(()=>{t&&i(!0)},[t]);async function c(){s&&(await Z7(s),o(!0),window.setTimeout(()=>o(!1),1200))}return(0,G.jsxs)(`div`,{className:`overflow-hidden rounded-lg`,children:[(0,G.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,G.jsx)(di,{size:11,className:`shrink-0 text-muted transition-transform ${r?`rotate-90`:``}`}),(0,G.jsx)(`span`,{className:`mono min-w-0 flex-1 truncate text-caption font-medium text-foreground`,children:e.name||n(`toolCallUntitled`)}),(0,G.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 text-caption text-muted`,children:[(0,G.jsx)(wSe,{status:e.status}),CSe(e.status,n)]})]}),r?(0,G.jsxs)(`div`,{className:`space-y-1.5 px-2 pb-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,G.jsx)(`div`,{className:`text-caption font-medium text-muted`,children:n(`toolCallArgs`)}),(0,G.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,G.jsx)(ki,{size:12}),n(a?`copied`:`copy`)]})]}),(0,G.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 ESe({calls:e}){let{t}=EI(),n=e.some(e=>e.status===`error`),r=e.some(e=>e.status===`running`),[i,a]=(0,v.useState)(n||r||e.length===1);return(0,v.useEffect)(()=>{(n||r)&&a(!0)},[n,r]),e.length?e.length===1?(0,G.jsx)(`div`,{className:`rounded-xl bg-surface-secondary/70`,children:(0,G.jsx)(r9,{call:e[0],forceOpen:e[0].status===`error`})}):(0,G.jsxs)(`div`,{className:`overflow-hidden rounded-xl bg-surface-secondary/70`,children:[(0,G.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,G.jsx)(di,{size:11,className:`shrink-0 transition-transform ${i?`rotate-90`:``}`}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium text-foreground`,children:t(`toolCallGroup`,{n:e.length})}),r?(0,G.jsx)(Fa,{size:12,className:`animate-spin`}):null]}),i?(0,G.jsx)(`div`,{className:`space-y-0.5 border-t border-separator/40 px-0.5 py-1`,children:e.map(e=>(0,G.jsx)(r9,{call:e},`${e.index}-${e.id||e.name}`))}):null]}):null}function DSe({message:e}){return e.attachments?.length?(0,G.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:e.attachments.map(e=>(0,G.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,G.jsx)(`img`,{src:e.dataUrl,alt:``,className:`size-7 shrink-0 rounded-lg object-cover`}):(0,G.jsx)(`span`,{className:`grid size-7 shrink-0 place-items-center rounded-lg bg-surface`,children:(0,G.jsx)(Ui,{size:12})}),(0,G.jsx)(`span`,{className:`truncate`,children:e.name})]},e.id))}):null}function OSe({message:e}){let{t}=EI(),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:$V(r??0),completion:$V(i??0)}):``;return(0,G.jsx)(`span`,{className:`mono text-caption text-muted`,children:a?t(`chatTryUsageFoot`,{tokens:a,amount:cH(n.credits)}):t(`chatTryCreditsUsed`,{amount:cH(n.credits)})})}function kSe({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,G.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,G.jsx)(`span`,{children:e},`s-${n}`):(0,G.jsx)(`span`,{className:t&&n===r?`access-stream-seg`:void 0,children:e},`p-${n}`):null)})}function ASe(){let e=(0,v.useRef)(null);return(0,v.useEffect)(()=>{let t=e.current;!t||jV()||Z.from(t,{autoAlpha:0,duration:kV.fast,ease:`power2.out`})},[]),e}function jSe({message:e}){let{t}=EI(),[n,r]=(0,v.useState)(!1),i=e.role===`user`,a=ASe();if(i)return(0,G.jsx)(`div`,{ref:a,className:`ml-auto max-w-[92%] sm:max-w-[78%]`,children:(0,G.jsxs)(`div`,{className:`access-bubble access-bubble--user rounded-2xl rounded-br-md px-3.5 py-2.5`,children:[e.content?(0,G.jsx)(`div`,{className:`whitespace-pre-wrap break-words text-body leading-[1.65] text-foreground`,children:e.content}):null,(0,G.jsx)(DSe,{message:e})]})});let o=e.status===`streaming`&&!e.content&&!e.reasoning&&!e.toolCalls?.length,s=!!e.content&&e.status===`done`,c=e.status===`streaming`,l=!!(e.usage&&e.usage.credits!=null),u=e.status===`done`&&(e.latency_ms!=null||e.ttfb_ms!=null||typeof e.usage?.completion_tokens==`number`);async function d(){e.content&&(await Z7(e.content),r(!0),window.setTimeout(()=>r(!1),1200))}return(0,G.jsxs)(`div`,{className:`group/access-msg max-w-[96%] space-y-1.5 sm:max-w-[88%]`,children:[e.reasoning||c?(0,G.jsx)(SSe,{text:e.reasoning||``,streaming:c&&(!e.content||!!e.reasoning),defaultOpen:e.reasoningOpen}):null,e.toolCalls?.length?(0,G.jsx)(ESe,{calls:e.toolCalls}):null,e.status===`error`?(0,G.jsx)(QI,{status:`danger`,title:t(`requestFailed`),description:e.error||``}):o?(0,G.jsxs)(`div`,{className:`space-y-2 pt-0.5`,children:[(0,G.jsx)(UA,{className:`h-3 w-28 rounded-md`}),(0,G.jsx)(UA,{className:`h-3 w-full rounded-md`}),(0,G.jsx)(UA,{className:`h-3 w-[86%] rounded-md`}),(0,G.jsx)(UA,{className:`h-3 w-[68%] rounded-md`})]}):e.content?(0,G.jsx)(`div`,{className:`access-bubble access-bubble--assistant px-0.5 py-0`,children:(0,G.jsx)(kSe,{text:e.content,streaming:c})}):null,s||l||u?(0,G.jsxs)(`div`,{className:`access-msg-foot space-y-1 px-0.5 pt-0.5`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[s?(0,G.jsxs)(`button`,{type:`button`,className:`inline-flex h-5 items-center gap-1 text-caption text-muted/80 opacity-70 transition-opacity hover:text-foreground hover:opacity-100`,onClick:()=>void d(),children:[(0,G.jsx)(ki,{size:12}),t(n?`copied`:`copy`)]}):null,(0,G.jsx)(OSe,{message:e})]}),u?(0,G.jsx)(n9,{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 MSe({messages:e,busy:t,onLoadDemo:n}){let{t:r}=EI(),i=(0,v.useRef)(null);(0,v.useEffect)(()=>{i.current?.scrollIntoView({block:`end`})},[e,t]);let a=!e.length;return(0,G.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,G.jsx)(I7,{className:`min-h-56`,title:r(`chatTryEmptyTitle`),hint:r(`chatTryEmptyHint`),action:n?(0,G.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,G.jsx)(`div`,{className:`space-y-4`,children:e.map(e=>(0,G.jsx)(jSe,{message:e},e.id))}),(0,G.jsx)(`div`,{ref:i})]})}function NSe({format:e,onFormatChange:t,requestPath:n,prompt:r,onPromptChange:i,onTest:a,requestState:o,elapsedMs:s,output:c,responseStatus:l,curl:u,copiedCurl:d,onCopyCurl:f,canSend:p,accountValue:m,onAccountChange:h,accountOptions:g,modelValue:_,onModelChange:v,modelOptions:y,modelsLoading:b,disabled:x}){let{t:S}=EI();return(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsx)(`p`,{className:`px-1 text-caption leading-5 text-muted`,children:S(`rawFormatHint`)}),(0,G.jsx)(`div`,{className:`access-raw-panel overflow-hidden rounded-2xl`,children:(0,G.jsxs)(`div`,{className:`grid xl:grid-cols-[minmax(420px,.92fr)_minmax(0,1.08fr)]`,children:[(0,G.jsxs)(`div`,{className:`xl:border-r xl:border-[color-mix(in_oklab,var(--foreground)_6%,transparent)]`,children:[(0,G.jsxs)(`div`,{className:`px-4 py-3.5 sm:px-5`,children:[(0,G.jsx)(`h3`,{className:`text-body font-semibold`,children:S(`requestBuilder`)}),(0,G.jsxs)(`p`,{className:`mt-0.5 text-caption text-muted`,children:[`POST `,n]})]}),(0,G.jsxs)(`div`,{className:`space-y-4 px-4 pb-4 sm:px-5 sm:pb-5`,children:[(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(`div`,{className:`text-caption font-medium text-muted`,children:S(`rawFormatLabel`)}),(0,G.jsx)(pH,{className:`access-format-chips`,ariaLabel:S(`rawFormatLabel`),value:e,onChange:e=>t(e),options:[{id:`chat`,label:S(`rawFormatChat`)},{id:`messages`,label:S(`rawFormatMessages`)},{id:`responses`,label:S(`rawFormatResponses`)}]})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(0,G.jsx)(t9,{ariaLabel:S(`account`),value:m,onChange:h,options:g,isDisabled:x||o===`loading`,tone:`muted`,className:`w-auto max-w-[8.5rem] min-w-0`}),(0,G.jsx)(t9,{ariaLabel:S(`model`),value:_,onChange:v,placeholder:S(b?`requesting`:`model`),options:y,isDisabled:x||o===`loading`||b||!y.length,className:`w-auto max-w-[10.5rem] min-w-0`})]}),(0,G.jsxs)(`div`,{className:`space-y-2.5`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,G.jsx)(`div`,{className:`text-caption font-medium text-muted`,children:S(`prompt`)}),(0,G.jsx)(`span`,{className:`mono text-caption text-muted`,children:r.length})]}),(0,G.jsx)(JM,{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:S(`promptPlaceholder`),"aria-label":S(`prompt`),disabled:x||o===`loading`}),(0,G.jsx)(`p`,{className:`text-caption leading-5 text-muted/70`,children:S(`promptHelper`)})]}),(0,G.jsxs)(J,{fullWidth:!0,isPending:o===`loading`,isDisabled:!p||x,onPress:a,children:[(0,G.jsx)(ha,{size:15}),S(o===`loading`?`requesting`:`sendRequest`)]})]})]}),(0,G.jsxs)(`div`,{className:`access-raw-panel__inspector flex min-h-[440px] min-w-0 flex-col`,"aria-live":`polite`,"aria-busy":o===`loading`,children:[(0,G.jsxs)(`div`,{className:`flex min-h-12 items-center justify-between gap-4 px-4 py-3 sm:px-5`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`text-body font-semibold`,children:S(`responseInspector`)}),(0,G.jsx)(`p`,{className:`mt-0.5 text-caption text-muted`,children:S(`responseInspectorHint`)})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[s===null?null:(0,G.jsxs)(`span`,{className:`mono flex items-center gap-1.5 text-caption text-muted`,children:[(0,G.jsx)(Ti,{size:12}),s,` ms`]}),(0,G.jsx)(aC,{size:`sm`,variant:`soft`,color:o===`success`?`success`:o===`error`?`danger`:void 0,children:l})]})]}),(0,G.jsx)(`div`,{className:`min-h-0 flex-1 px-4 pb-4 sm:px-5 sm:pb-5`,children:o===`idle`?(0,G.jsx)(I7,{className:`min-h-64`,title:S(`responseEmptyTitle`),hint:S(`responseEmptyHint`)}):o===`loading`?(0,G.jsxs)(`div`,{className:`space-y-3 pt-1`,children:[(0,G.jsx)(UA,{className:`h-3 w-32 rounded-lg`}),(0,G.jsx)(UA,{className:`h-3 w-full rounded-lg`}),(0,G.jsx)(UA,{className:`h-3 w-[88%] rounded-lg`}),(0,G.jsx)(UA,{className:`h-3 w-[72%] rounded-lg`}),(0,G.jsx)(UA,{className:`mt-7 h-3 w-[92%] rounded-lg`}),(0,G.jsx)(UA,{className:`h-3 w-[64%] rounded-lg`})]}):o===`error`?(0,G.jsx)(`div`,{className:`space-y-3`,children:(0,G.jsx)(QI,{status:`danger`,title:S(`requestFailed`),description:c})}):(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 text-caption font-medium text-success`,children:[(0,G.jsx)(yi,{size:14,weight:`fill`}),S(`responseReceived`)]}),(0,G.jsx)(`pre`,{className:`mono overflow-x-auto whitespace-pre-wrap break-words text-caption leading-6 text-muted`,children:c})]})})]})]})}),(0,G.jsxs)(`section`,{className:`access-raw-panel overflow-hidden rounded-2xl`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-4 px-4 py-3 sm:px-5`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`div`,{className:`text-body font-semibold`,children:S(`curlExample`)}),(0,G.jsx)(`div`,{className:`mt-0.5 truncate text-caption text-muted`,children:S(`curlGeneratedHint`)})]}),(0,G.jsxs)(J,{size:`sm`,variant:`ghost`,onPress:f,children:[(0,G.jsx)(X7,{copied:d}),S(d?`copied`:`copy`)]})]}),(0,G.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:u})]})]})}function i9(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?` + `}),(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-3 border-b border-separator px-4 py-3`,children:[(0,G.jsxs)(`button`,{type:`button`,"data-testid":`inflight-live-toggle`,"aria-expanded":l,"aria-controls":`inflight-live-body`,onClick:()=>u(!l),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,G.jsx)(di,{size:14,"aria-hidden":!0,className:`mt-1 shrink-0 text-muted transition-transform duration-200 ${l?`rotate-90`:``}`}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`h3`,{className:`font-semibold`,children:e(`inflightTitle`)}),(0,G.jsxs)(`span`,{className:`mono inline-flex items-center gap-1 rounded-[3px] px-1.5 py-0.5 text-caption ${j&&l?`bg-[var(--il-warn-bg)] font-medium text-[var(--il-warn-fg)] shadow-[var(--il-hair-warn)]`:`text-muted`}`,children:[(0,G.jsx)(`span`,{className:`status-dot`,"data-state":j&&l?`warn`:P?`ok`:``}),l&&j?e(`inflightRatePill`,{remain:y7(j.remainingMs)}):e(P?`inflightLiveBadge`:`inflightMockBadge`)]}),l&&F>0?(0,G.jsx)(`span`,{className:`mono text-caption text-muted`,children:e(`inflightStickyBindings`,{n:F})}):null]}),(0,G.jsx)(`p`,{className:`mt-0.5 text-caption text-muted`,children:e(`inflightHint`)})]})]}),l?(0,G.jsxs)(Sn,{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,G.jsx)($r,{size:14,"aria-hidden":!0})]}):(0,G.jsxs)(`button`,{type:`button`,className:`inline-flex shrink-0 items-center gap-1 text-caption text-muted transition-colors hover:text-foreground`,onClick:()=>u(!0),children:[e(`inflightExpand`),(0,G.jsx)(di,{size:14,"aria-hidden":!0})]})]}),l?(0,G.jsxs)(`div`,{id:`inflight-live-body`,ref:S,children:[(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 border-b border-separator px-4 py-3 sm:grid-cols-4`,children:[(0,G.jsx)(w7,{label:e(`inflightWaiting`),value:x.waiting,warn:M||!!j}),(0,G.jsx)(w7,{label:e(`inflightRunning`),value:x.occupiedSlots,suffix:`/${x.workerSlots}`}),(0,G.jsx)(w7,{label:e(`inflightThroughput`),value:b.throughputPerMin,suffix:`/min`}),(0,G.jsx)(w7,{label:e(`inflightWaitP95`),value:b.waitP95Ms,kind:`ms`})]}),(0,G.jsxs)(`div`,{className:`grid gap-3 border-b border-separator px-4 py-3 lg:grid-cols-[minmax(0,0.95fr)_minmax(0,1.55fr)_auto]`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,"data-queue-col":!0,children:[(0,G.jsxs)(`div`,{className:`mb-1.5 flex items-baseline justify-between gap-2`,children:[(0,G.jsx)(`span`,{className:`text-caption uppercase tracking-wide text-muted`,children:e(`inflightQueue`)}),(0,G.jsx)(`span`,{className:`mono text-[10px] tabular ${M?`text-[var(--il-warn-fg)]`:`text-muted`}`,children:x.waiting})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[O.map(t=>(0,G.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 shadow-[var(--il-hair)] ${C7(t.kind)}`,children:[(0,G.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(--chart-1)_28%,transparent)] to-transparent motion-safe:animate-[inflight-queue-shimmer_2.8s_linear_infinite]`}),(0,G.jsxs)(`span`,{className:`relative z-[1] flex min-w-0 items-center gap-1.5 truncate text-[11px] font-medium text-foreground/92`,children:[(0,G.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-[2px] ${S7(t.kind)}`,"aria-hidden":!0}),(0,G.jsxs)(`span`,{className:`truncate`,children:[t.name,t.priority===`high`?(0,G.jsx)(`span`,{className:`mono ml-1 text-[10px] text-muted`,children:`↑`}):null,t.sticky?(0,G.jsx)(`span`,{className:`mono ml-1 text-[10px] text-muted`,children:e(`inflightSticky`)}):null]})]}),(0,G.jsx)(`span`,{className:`relative z-[1] mono shrink-0 text-[10px] text-muted`,children:b7(x7(t,_))})]},t.id)),k.length?(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 pt-1`,"data-queue-overflow":!0,children:[k.map(e=>(0,G.jsx)(`span`,{"data-wait-token":!0,"data-wait-id":e.id,"data-priority":e.priority??`normal`,className:`size-2 rounded-[2px] ${S7(e.kind)} ${e.priority===`high`?`ring-1 ring-foreground/20`:``}`,title:e.name},e.id)),(0,G.jsxs)(`span`,{className:`mono text-[10px] text-muted`,children:[`+`,k.length]})]}):O.length===0?(0,G.jsx)(`div`,{className:`text-caption text-muted`,children:e(`inflightQueueEmpty`)}):null]})]}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsxs)(`div`,{className:`mb-1.5 flex items-baseline justify-between gap-2`,children:[(0,G.jsx)(`span`,{className:`text-caption uppercase tracking-wide text-muted`,children:e(`inflightSlots`)}),(0,G.jsxs)(`span`,{className:`mono text-[10px] tabular text-muted`,children:[x.occupiedSlots,`/`,x.workerSlots]})]}),(0,G.jsx)(`div`,{className:`flex flex-col gap-2`,children:A.map(t=>(0,G.jsx)(Gxe,{slot:t,job:t.jobId?E.get(t.jobId):void 0,clockMs:_,idleLabel:e(`inflightSlotIdle`),pausedLabel:e(`inflightSlotPaused`)},t.id))})]}),(0,G.jsxs)(`div`,{className:`flex gap-2 lg:w-[3.75rem] lg:flex-col`,children:[(0,G.jsx)(T7,{label:e(`inflightDone`),value:b.totals.done,tone:`ok`,icon:(0,G.jsx)(_i,{size:14,weight:`bold`,"aria-hidden":!0})}),(0,G.jsx)(T7,{label:e(`inflightFailed`),value:b.totals.failed,tone:`danger`,icon:(0,G.jsx)(ao,{size:14,weight:`bold`,"aria-hidden":!0})})]})]}),(0,G.jsxs)(`div`,{"data-depth":!0,className:`px-4 py-3`,children:[(0,G.jsxs)(`div`,{className:`mb-1 flex items-baseline justify-between gap-2`,children:[(0,G.jsx)(`span`,{className:`text-caption uppercase tracking-wide text-muted`,children:e(`inflightDepth`)}),(0,G.jsx)(`span`,{className:`mono text-caption tabular text-muted`,children:N})]}),(0,G.jsx)(`div`,{className:`rounded-lg bg-[var(--il-item-bg)] px-1.5 pt-1.5 pb-1`,children:(0,G.jsx)(Wxe,{series:b.depthSeries,bands:b.rateLimits.map(e=>({from:e.from,until:e.until})),backpressure:b.backpressure,label:N})}),j?(0,G.jsx)(`div`,{className:`mono mt-1.5 text-[10px] font-medium text-[var(--il-warn-fg)]`,children:e(`inflightRateBand`,{label:j.label,remain:y7(j.remainingMs)})}):null]})]}):null]})}function w7({label:e,value:t,suffix:n,kind:r=`int`,warn:i}){return(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`div`,{className:`text-caption uppercase tracking-wide text-muted`,children:e}),(0,G.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,G.jsx)(dH,{value:t,kind:r,duration:560}),n?(0,G.jsx)(`span`,{className:`text-[0.92em] opacity-80`,children:n}):null]})]})}function T7({label:e,value:t,tone:n,icon:r}){let i=n===`ok`;return(0,G.jsxs)(`div`,{"data-outcome":n,role:`group`,"aria-label":`${e}: ${t}`,title:`${e}: ${t}`,className:`flex min-w-[3.25rem] flex-1 flex-col items-center justify-center gap-1 rounded-xl px-2 py-2.5 ${i?`bg-[var(--il-ok-bg)] shadow-[var(--il-hair-ok)]`:`bg-[var(--il-err-bg)] shadow-[var(--il-hair-err)]`}`,children:[(0,G.jsx)(`span`,{className:`inline-flex size-6 items-center justify-center ${i?`text-[var(--il-ok-fg)]`:`text-[var(--il-err-fg)]`}`,"aria-hidden":!0,children:r}),(0,G.jsx)(`div`,{className:`mono text-section font-semibold tabular leading-none ${i?`text-[var(--il-ok-fg)]`:`text-[var(--il-err-fg)]`}`,children:(0,G.jsx)(dH,{value:t,kind:`int`,duration:560})}),(0,G.jsx)(`span`,{className:`sr-only`,children:e})]})}var E7=2500;Math.round(6e4/E7);function qxe(){let[e,t]=(0,v.useState)(null),[n,r]=(0,v.useState)([]);return(0,v.useEffect)(()=>{let e=!1,n=null,i=()=>{document.hidden||zV().then(n=>{e||(t(n),r(e=>[...e,{at:Date.now(),value:n.in_flight}].slice(-24)))}).catch(()=>{})},a=()=>{n||document.hidden||(i(),n=setInterval(i,E7))},o=()=>{n&&clearInterval(n),n=null},s=()=>document.hidden?o():a();return a(),document.addEventListener(`visibilitychange`,s),()=>{e=!0,o(),document.removeEventListener(`visibilitychange`,s)}},[]),{live:e,samples:n}}var Jxe=(0,v.lazy)(()=>C(()=>import(`./TrafficChart-CsxXsi2g.js`).then(e=>({default:e.TrafficChart})),__vite__mapDeps([0,1]))),D7=3e4,Yxe={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 Xxe(e,t){return!e||e===`(unknown)`?t(`statsUnknown`):AH(e,t)}function Zxe(e,t,n){return!t||t===`(unassigned)`?n:e.find(e=>e.id===t)?.name||t}var Qxe=new Set([`quota`,`rate_limit`,`auth`,`not_ready`,`unavailable`,`invalid_request`,`model_not_available`]);function O7(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 $xe=[`ok`,`incomplete`,`error`,`canceled`],k7={ok:`bg-success`,incomplete:`bg-warning`,error:`bg-danger`,canceled:`bg-muted`},A7={ok:`logsFilterOk`,incomplete:`logsFilterIncomplete`,error:`logsFilterError`,canceled:`logsFilterCanceled`};function j7(e,t){return t>0?e/t:null}function eSe(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 tSe(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 nSe(e,t){return t?`danger`:(e??0)>=80?`warning`:`ok`}function rSe(){let{lang:e,t}=EI(),{overview:n,loading:r,error:i}=qI(),[a,o]=(0,v.useState)(`today`),[s,c]=(0,v.useState)(null),[l,u]=(0,v.useState)(!1),d=at(),[f,p]=(0,v.useState)(null),[m,h]=(0,v.useState)(``),[g,_]=(0,v.useState)(!0),[y,b]=(0,v.useState)([]),[x,S]=(0,v.useState)(!0),[C,w]=(0,v.useState)(0),[T,E]=(0,v.useState)(null),[D,O]=(0,v.useState)(()=>Date.now()),{live:k,samples:A}=qxe(),[j,M]=(0,v.useState)(!1),N=new Map((k?.accounts??[]).map(e=>[e.id,e])),P=!!n?.proxy?.ok,F=!!n?.worker?.ok,I=n?.worker?.ready_count??0,L=n?.worker?.hot_count??0,R=n?.worker?.cooling_count??0,z=k?.in_flight??n?.worker?.in_flight??0,B=f??Yxe,V=n?.routing?.session_affinity,H=(V?.hits??0)+(V?.misses??0),ee=j7(V?.hits??0,H),te=y.map(e=>({account:e,until:tSe(e,D)})).filter(e=>e.until!=null),ne=te.length>0;(0,v.useEffect)(()=>{if(!ne)return;let e=setInterval(()=>O(Date.now()),1e3);return()=>clearInterval(e)},[ne]),(0,v.useEffect)(()=>{let e=!1;return Promise.allSettled([PI(!1),VI()]).then(([t,n])=>{e||(t.status===`fulfilled`&&b(t.value.data||[]),n.status===`fulfilled`&&w((n.value.data||[]).length))}).finally(()=>{e||S(!1)}),()=>{e=!0}},[]);let re=s?.start?.toString()??``,ie=s?.end?.toString()??``,ae=(0,v.useRef)(0),oe=(0,v.useCallback)(e=>{let t=vH(a,s);if(!t){_(!1);return}let n=++ae.current;ZV(t).then(e=>{n===ae.current&&(p(e),h(``))}).catch(t=>{n!==ae.current||e||(p(null),h(t instanceof Error?t.message:String(t)))}).finally(()=>{n===ae.current&&_(!1)})},[a,re,ie]);(0,v.useEffect)(()=>(oe(!1),()=>{ae.current++}),[oe]),(0,v.useEffect)(()=>{if(l)return;let e=Date.now(),t=()=>{document.hidden||(e=Date.now(),oe(!0))},n=setInterval(t,D7),r=()=>{!document.hidden&&Date.now()-e>=D7&&t()};return document.addEventListener(`visibilitychange`,r),()=>{clearInterval(n),document.removeEventListener(`visibilitychange`,r)}},[l,oe]),(0,v.useEffect)(()=>{let e=!1,t=()=>{Aoe().then(t=>{e||E(t)}).catch(()=>{})};t();let n=setInterval(t,5e3);return()=>{e=!0,clearInterval(n)}},[]);let se=Math.floor(B.series.length/2),ce=(e,t)=>e.reduce((e,n)=>e+n[t],0),le=B.series.slice(0,se),ue=B.series.slice(se),de=((e,t)=>e>0?(t-e)/e:null)(ce(le,`requests`),ce(ue,`requests`)),fe=ce(le,`requests`)?ce(le,`ok`)/ce(le,`requests`):null,pe=ce(ue,`requests`)?ce(ue,`ok`)/ce(ue,`requests`):null,me=fe!=null&&pe!=null?pe-fe:null,he=[{label:t(`metricRequests`),value:B.totals.requests,kind:`compact`,detail:t(`statsWindowHint`,{window:t(_H[a])}),ok:B.totals.requests>0,trend:de},{label:t(`metricSuccess`),value:B.totals.success_rate,kind:`percent`,detail:`${B.totals.ok} ${t(`logsFilterOk`)} · ${B.totals.incomplete} ${t(`logsFilterIncomplete`)} · ${B.totals.error} ${t(`logsFilterError`)}`,ok:B.totals.requests===0||B.totals.success_rate>=.9,trend:me},{label:t(`metricLatency`),value:B.latency.p95_ms??B.latency.avg_ms,kind:`ms`,detail:`p50 ${eH(B.latency.p50_ms)} · avg ${eH(B.latency.avg_ms)}`,ok:B.latency.p95_ms==null||B.latency.p95_ms<8e3,trend:null},{label:t(`metricTokens`),value:B.tokens.total,kind:`compact`,detail:`${$V(B.tokens.prompt)} / ${$V(B.tokens.completion)}`,ok:!0,trend:null}],ge=j7(B.tokens.cache_read,B.tokens.prompt),_e=j7(B.totals.streaming,B.totals.requests),ve=[{label:t(`metricCacheHit`),value:ge,kind:`percent`,detail:t(`metricCacheHitDetail`,{read:$V(B.tokens.cache_read),prompt:$V(B.tokens.prompt)})},{label:t(`metricStreaming`),value:_e,kind:`percent`,detail:t(`metricStreamingDetail`,{count:B.totals.streaming,total:B.totals.requests})},{label:t(`metricCanceled`),value:B.totals.canceled,kind:`int`,detail:t(`metricCanceledDetail`,{rate:nH(j7(B.totals.canceled,B.totals.requests)??0)})}],ye=$xe.map(e=>({key:e,count:B.status.find(t=>t.key===e)?.count??B.totals[e]??0})),be=e=>bH(e,B.window.from,B.window.to);return r&&!n?(0,G.jsx)(Mse,{}):(0,G.jsxs)(`div`,{className:`space-y-5 sm:space-y-4`,children:[(0,G.jsxs)(`section`,{className:`grid gap-3 pb-1 lg:grid-cols-[minmax(0,1fr)_auto] lg:items-end`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h2`,{"data-gsap-reveal":!0,className:`text-title font-semibold`,children:t(`homeDisplay`)}),(0,G.jsx)(`p`,{className:`mt-1 max-w-2xl text-body leading-6 text-muted`,children:t(`homeLead`)})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,G.jsx)(yH,{value:a,onChange:o,custom:s,onCustomChange:c,onBusy:()=>_(!0),t}),(0,G.jsxs)(PM,{delay:300,children:[(0,G.jsx)(J,{isIconOnly:!0,size:`sm`,variant:`ghost`,"aria-label":t(l?`statsRefreshResume`:`statsRefreshPause`),"aria-pressed":l,onPress:()=>u(e=>!e),children:l?(0,G.jsx)(xa,{size:14}):(0,G.jsx)(_a,{size:14})}),(0,G.jsx)(PM.Content,{children:t(l?`statsRefreshPaused`:`statsRefreshAuto`)})]}),(0,G.jsxs)(`div`,{className:`text-left sm:text-right`,children:[(0,G.jsx)(`div`,{className:`mono text-caption text-muted`,children:n?.time||`—`}),(0,G.jsxs)(`div`,{className:`mt-1 inline-flex items-center gap-2 text-body font-medium`,children:[(0,G.jsx)(`span`,{className:`status-dot`,"data-state":P&&F?`ok`:`danger`}),t(P&&F?`running`:`degraded`)]})]})]})]}),i?(0,G.jsx)(QI,{title:t(`failedOverview`,{msg:i})}):null,(0,G.jsx)(Ace,{live:k,samples:A,t,onConcurrencyClick:()=>M(!0)}),(0,G.jsx)(Kxe,{t,expanded:j,onExpandedChange:M,live:j?k:null}),(0,G.jsx)(`section`,{"data-gsap-reveal":!0,className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-4`,children:he.map(e=>(0,G.jsxs)(HS,{className:`gap-0 p-3.5`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,G.jsx)(`div`,{className:`text-body text-muted`,children:e.label}),(0,G.jsx)(`span`,{className:`status-dot`,"data-state":e.ok?`ok`:`danger`})]}),(0,G.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`div`,{className:`tabular text-metric font-medium leading-none`,children:g?(0,G.jsx)(Q,{className:`h-7 w-24`}):e.value==null?`—`:(0,G.jsx)(dH,{value:e.value,kind:e.kind})}),!g&&e.trend!=null?(0,G.jsx)(aSe,{value:e.trend,hint:t(`trendHalfHint`)}):null]}),(0,G.jsx)(`div`,{className:`mono mt-2 truncate text-caption text-muted`,children:g?(0,G.jsx)(Q,{className:`h-3 w-28`}):e.detail})]},e.label))}),(0,G.jsx)(`section`,{className:`grid gap-3 sm:grid-cols-3`,children:ve.map(e=>(0,G.jsx)(HS,{className:`gap-0 p-3.5`,children:(0,G.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center sm:gap-3`,children:[(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`div`,{className:`text-body text-muted`,children:e.label}),(0,G.jsx)(`div`,{className:`mono mt-0.5 truncate text-caption text-muted`,children:g?(0,G.jsx)(Q,{className:`h-3 w-28`}):e.detail})]}),(0,G.jsx)(`div`,{className:`tabular text-section font-semibold sm:shrink-0`,children:g?(0,G.jsx)(Q,{className:`h-5 w-12`}):e.value==null?`—`:(0,G.jsx)(dH,{value:e.value,kind:e.kind})})]})},e.label))}),(0,G.jsx)(`section`,{className:`grid gap-3`,children:(0,G.jsxs)(HS,{"data-gsap-reveal":!0,className:`overflow-hidden p-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-separator px-4 py-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`font-semibold`,children:t(`statsTraffic`)}),(0,G.jsx)(`p`,{className:`mt-0.5 text-caption text-muted`,children:t(`statsTrafficHint`)})]}),(0,G.jsx)(aC,{size:`sm`,variant:`soft`,color:B.totals.error?`warning`:`success`,children:nH(B.totals.success_rate)})]}),(0,G.jsxs)(`div`,{className:`space-y-4 p-4`,children:[m?(0,G.jsx)(`div`,{className:`text-body text-danger`,children:t(`failedStats`,{msg:m})}):g?(0,G.jsx)(IV,{}):B.series.some(e=>e.requests>0)?(0,G.jsx)(v.Suspense,{fallback:(0,G.jsx)(IV,{}),children:(0,G.jsx)(Jxe,{series:B.series,lang:e,emptyLabel:t(`statsEmptyTraffic`),okLabel:t(`logsFilterOk`),errorLabel:t(`logsFilterError`),selectHint:t(`statsDragHint`),labels:{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`)},onSelectRange:(e,t)=>d(bH({},e,t))})}):(0,G.jsx)(fH,{emptyLabel:t(`statsEmptyTraffic`)}),(0,G.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`),eH(B.latency.p50_ms)],[t(`statsLatencyP95`),eH(B.latency.p95_ms)],[t(`statsLatencyAvg`),eH(B.latency.avg_ms)],[t(`statsTTFB`),eH(B.latency.ttfb_avg_ms)]].map(([e,t])=>(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-caption text-muted`,children:e}),(0,G.jsx)(`div`,{className:`mono mt-1 text-body font-medium`,children:g?(0,G.jsx)(Q,{className:`h-4 w-16`}):t})]},String(e)))})]})]})}),(0,G.jsxs)(`section`,{className:`grid gap-3 xl:grid-cols-[minmax(0,1.15fr)_minmax(0,.85fr)]`,children:[(0,G.jsxs)(HS,{"data-gsap-reveal":!0,className:`overflow-hidden p-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-separator px-4 py-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`font-semibold`,children:t(`statsPool`)}),(0,G.jsx)(`p`,{className:`mt-0.5 text-caption text-muted`,children:t(`statsPoolHint`)})]}),(0,G.jsxs)(Sn,{to:`/accounts`,className:`inline-flex items-center gap-1 text-caption font-medium text-muted hover:text-foreground`,children:[t(`navAccounts`),(0,G.jsx)($r,{size:12})]})]}),(0,G.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`),I,`ok`],[t(`hot`),L,L?`ok`:``],[t(`inFlight`),z,z?`ok`:``],[t(`statsAffinityHit`),ee==null?`—`:nH(ee),``,V?t(`statsAffinityHint`,{hits:V.hits??0,misses:V.misses??0,bindings:V.bindings??0}):``]].map(([e,t,n,r])=>(0,G.jsxs)(`div`,{className:`px-4 py-3 sm:py-2.5`,title:r?String(r):void 0,children:[(0,G.jsx)(`div`,{className:`text-caption text-muted`,children:e}),(0,G.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-2 sm:mt-1`,children:[(0,G.jsx)(`span`,{className:`mono text-section font-semibold`,children:t}),n?(0,G.jsx)(`span`,{className:`status-dot`,"data-state":n}):null]})]},String(e)))}),!x&&te.length?(0,G.jsxs)(`div`,{className:`border-b border-separator px-4 py-2.5`,children:[(0,G.jsx)(`div`,{className:`text-caption font-medium text-muted`,children:t(`statsCoolingDetails`)}),(0,G.jsx)(`div`,{className:`mt-2 space-y-1.5`,children:te.map(({account:e,until:n})=>(0,G.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-caption sm:flex-row sm:items-center sm:gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`status-dot shrink-0`,"data-state":`warn`}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium`,children:e.name||e.id})]}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3 pl-4 sm:contents sm:pl-0`,children:[(0,G.jsx)(`span`,{className:`mono shrink-0 text-muted`,children:e.last_error_kind?O7(e.last_error_kind,t):t(`statsUnknown`)}),(0,G.jsx)(`span`,{className:`mono shrink-0 tabular sm:w-16 sm:text-right`,children:eSe(n,D)??`—`}),(0,G.jsx)(`span`,{className:`mono shrink-0 text-muted sm:w-12 sm:text-right`,title:t(`statsBackoffLevel`),children:e.restart_backoff_level?`L${e.restart_backoff_level}`:`—`})]})]},e.id))})]}):null,(0,G.jsx)(`div`,{className:`divide-y divide-separator`,children:x?(0,G.jsx)(FV,{}):y.length===0?(0,G.jsx)(`div`,{className:`px-4 py-6 text-body text-muted`,children:t(`noAccounts`)}):y.slice(0,6).map(e=>{let n=e.quota,r=nSe(n?.percentage,n?.exceeded),i=N.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,G.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,G.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-3 sm:items-center`,children:[(0,G.jsx)(`span`,{className:`status-dot mt-1.5 shrink-0 sm:mt-0`,"data-state":e.ready?`ok`:`danger`}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,G.jsx)(MH,{provider:e.provider,size:14}),(0,G.jsx)(`div`,{className:`truncate text-body font-medium`,children:e.name||e.id})]}),(0,G.jsxs)(`div`,{className:`mono mt-0.5 text-caption text-muted`,children:[jH(e.provider,e.region,t),` · `,e.hot?t(`hot`):e.ready?t(`ready`):t(`degraded`)]})]})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-4 gap-y-2 pl-6 sm:shrink-0 sm:pl-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5`,title:t(s?`liveSaturated`:`inFlight`),"data-testid":`account-inflight`,children:[(0,G.jsx)(`span`,{className:`text-caption text-muted sm:hidden`,children:t(`inFlight`)}),(0,G.jsxs)(`span`,{className:`mono text-caption tabular ${s?`text-warning`:`text-muted`}`,children:[a,`/`,o]}),(0,G.jsx)(`span`,{className:`inline-block h-[2px] w-10 overflow-hidden rounded-[1px] bg-separator`,children:(0,G.jsx)(`span`,{className:`block h-full ${s?`bg-warning`:`bg-foreground/50`}`,style:{width:`${Math.min(100,a/o*100)}%`}})})]}),n?(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5`,title:t(`quota`),children:[(0,G.jsx)(`span`,{className:`text-caption text-muted sm:hidden`,children:t(`quota`)}),(0,G.jsxs)(`span`,{className:`mono text-caption tabular text-muted`,children:[Math.round(n.percentage??0),`%`]}),(0,G.jsx)(`span`,{className:`inline-block h-[2px] w-10 overflow-hidden rounded-[1px] bg-separator`,children:(0,G.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,G.jsxs)(`div`,{className:`flex items-center justify-between border-t border-separator px-4 py-2.5 text-caption text-muted`,children:[(0,G.jsxs)(`span`,{children:[t(`metricModels`),` `,C]}),(0,G.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=y.filter(t=>String(t.provider||`qoder`).toLowerCase()===e).length;return t?(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,G.jsx)(MH,{provider:e,size:11}),t]},e):null}),(0,G.jsx)(`span`,{children:R?`${R} ${t(`statsCooling`)}`:`${y.length} ${t(`accountCount`)}`})]})]})]}),(0,G.jsx)(iSe,{resources:T,t})]}),(0,G.jsxs)(`section`,{className:`grid gap-3 xl:grid-cols-2 2xl:grid-cols-3`,children:[(0,G.jsxs)(HS,{"data-gsap-reveal":!0,className:`overflow-hidden p-0`,children:[(0,G.jsx)(`div`,{className:`flex items-center justify-between gap-3 border-b border-separator px-4 py-3`,children:(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`font-semibold`,children:t(`statsTopProviders`)}),(0,G.jsx)(`p`,{className:`mt-0.5 text-caption text-muted`,children:t(`statsTopProvidersHint`)})]})}),g?(0,G.jsx)(FV,{}):(0,G.jsx)(N7,{empty:t(`statsNoProviders`),items:(B.providers||[]).map(e=>({key:e.key,label:Xxe(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:be({provider:e.key})}))})]}),(0,G.jsxs)(HS,{"data-gsap-reveal":!0,className:`overflow-hidden p-0`,children:[(0,G.jsx)(`div`,{className:`flex items-center justify-between gap-3 border-b border-separator px-4 py-3`,children:(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`font-semibold`,children:t(`statsTopModels`)}),(0,G.jsx)(`p`,{className:`mt-0.5 text-caption text-muted`,children:t(`providerCatalog`)})]})}),g?(0,G.jsx)(FV,{rows:4}):(0,G.jsx)(N7,{empty:t(`statsNoModels`),items:B.models.map(e=>({key:e.key,label:e.key===`(unknown)`?t(`statsUnknown`):e.key,count:e.count,href:e.key===`(unknown)`?void 0:be({model:e.key}),meta:e.latency_avg_ms==null?`${e.ok}/${e.count}`:eH(e.latency_avg_ms)}))})]}),(0,G.jsxs)(HS,{"data-gsap-reveal":!0,className:`overflow-hidden p-0`,children:[(0,G.jsx)(`div`,{className:`flex items-center justify-between gap-3 border-b border-separator px-4 py-3`,children:(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`font-semibold`,children:t(`statsStatusMix`)}),(0,G.jsx)(`p`,{className:`mt-0.5 text-caption text-muted`,children:t(`statsStatusMixHint`)})]})}),g?(0,G.jsx)(FV,{rows:4}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(oSe,{items:ye,t}),(0,G.jsx)(`div`,{className:`border-t border-separator px-4 pt-2.5 text-caption font-medium text-muted`,children:t(`statsErrorMix`)}),(0,G.jsx)(N7,{empty:t(`statsNoErrors`),danger:!0,items:B.errors.map(e=>({key:e.key,label:O7(e.key,t),count:e.count,href:Qxe.has(e.key)?be({error_kind:e.key}):void 0}))}),(0,G.jsx)(`div`,{className:`border-t border-separator px-4 pt-2.5 text-caption font-medium text-muted`,children:t(`statsTopAccounts`)}),(0,G.jsx)(N7,{empty:t(`statsNoAccounts`),items:B.accounts.slice(0,5).map(e=>({key:e.key,label:Zxe(y,e.key,t(`statsUnassigned`)),count:e.count,href:!e.key||e.key===`(unassigned)`?void 0:be({account:e.key}),meta:`${e.ok}/${e.count}`}))})]})]})]})]})}function M7(e,t){return e>=2147483648||t>=200?`danger`:e>=1073741824||t>=100?`warning`:`ok`}function iSe({resources:e,t}){let n=[...e?.workers??[]].sort((e,t)=>t.rss_bytes-e.rss_bytes),r=e?.server;return(0,G.jsxs)(HS,{"data-gsap-reveal":!0,className:`overflow-hidden p-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-separator px-4 py-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`font-semibold`,children:t(`resTitle`)}),(0,G.jsx)(`p`,{className:`mt-0.5 text-caption text-muted`,children:t(`resHint`)})]}),(0,G.jsx)(aC,{size:`sm`,variant:`soft`,color:e?`success`:`default`,children:e?tH(e.total_rss_bytes):`—`})]}),(0,G.jsx)(`div`,{className:`divide-y divide-separator`,children:e?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`px-4 py-2.5`,children:(0,G.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`status-dot shrink-0`,"data-state":M7(r?.rss_bytes??0,r?.cpu_percent??0)}),(0,G.jsx)(`div`,{className:`truncate text-body font-medium`,children:t(`resServer`)}),(0,G.jsxs)(`span`,{className:`mono text-caption text-muted`,children:[`pid `,r?.pid]})]}),(0,G.jsxs)(`div`,{className:`mono shrink-0 text-caption text-muted`,children:[tH(r?.rss_bytes),` · `,(r?.cpu_percent??0).toFixed(1),`%`]})]})}),n.length===0?(0,G.jsx)(`div`,{className:`px-4 py-3 text-body text-muted`,children:t(`resEmpty`)}):n.map(e=>(0,G.jsx)(`div`,{className:`px-4 py-2.5`,children:(0,G.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`status-dot shrink-0`,"data-state":M7(e.rss_bytes,e.cpu_percent)}),(0,G.jsx)(`div`,{className:`truncate text-body font-medium`,children:e.label||e.account_id}),(0,G.jsxs)(`span`,{className:`mono text-caption text-muted`,children:[`pid `,e.pid]})]}),(0,G.jsxs)(`div`,{className:`mono shrink-0 text-caption text-muted`,children:[tH(e.rss_bytes),` · `,e.cpu_percent.toFixed(1),`%`]})]})},e.pid))]}):(0,G.jsx)(FV,{rows:3})}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between border-t border-separator px-4 py-2.5 text-caption text-muted`,children:[(0,G.jsxs)(`span`,{className:`mono`,children:[r?.goroutines??0,` `,t(`resGoroutines`)]}),(0,G.jsx)(`span`,{className:`mono`,children:e?.sampled_at?new Date(e.sampled_at).toLocaleTimeString():`—`})]})]})}function N7({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=Z.context(()=>{let e=Z.matchMedia();e.add(`(prefers-reduced-motion: reduce)`,()=>{Z.set(`[data-rank-fill]`,{clearProps:`transform`})}),e.add(`(prefers-reduced-motion: no-preference)`,()=>{let e=Z.utils.toArray(`[data-rank-fill]`);e.length&&Z.fromTo(e,{scaleX:0},{scaleX:1,duration:.38,ease:`power2.out`,stagger:.05,transformOrigin:`0% 50%`})})},e);return()=>t.revert()},[a]),e.length?(0,G.jsx)(`div`,{ref:r,className:`divide-y divide-separator`,children:e.map(e=>{let t=(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[e.mark?(0,G.jsx)(MH,{provider:e.mark,size:14}):null,(0,G.jsx)(`div`,{className:`truncate text-body font-medium`,children:e.label})]}),(0,G.jsx)(`div`,{className:`mono shrink-0 text-caption text-muted`,children:e.meta?`${e.count} · ${e.meta}`:e.count})]}),(0,G.jsx)(`div`,{className:`mt-2 h-1 overflow-hidden rounded-[2px] bg-separator`,children:(0,G.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,G.jsx)(Sn,{to:e.href,className:`rank-row block px-4 py-2.5`,title:e.label,children:t},e.key):(0,G.jsx)(`div`,{className:`px-4 py-2.5`,children:t},e.key)})}):(0,G.jsx)(`div`,{className:`px-4 py-6 text-body text-muted`,children:t})}function aSe({value:e,hint:t}){let n=Math.abs(e)<.005?`flat`:e>0?`up`:`down`;return(0,G.jsxs)(`span`,{className:`trend-chip`,"data-tone":n,title:t,children:[(0,G.jsx)(n===`down`?Ya:n===`up`?Za:hi,{size:12,weight:`bold`}),e>0?`+`:``,(e*100).toFixed(1),`%`]})}function oSe({items:e,t}){let n=e.reduce((e,t)=>e+t.count,0);return n?(0,G.jsxs)(`div`,{className:`px-4 py-3`,children:[(0,G.jsx)(`div`,{className:`flex h-2 gap-px overflow-hidden rounded-[3px] bg-separator`,role:`img`,"aria-label":e.map(e=>`${t(A7[e.key])} ${e.count}`).join(`, `),children:e.filter(e=>e.count>0).map(e=>(0,G.jsx)(`div`,{className:k7[e.key],style:{width:`${e.count/n*100}%`,minWidth:2}},e.key))}),(0,G.jsx)(`div`,{className:`mt-3 grid grid-cols-2 gap-x-4 gap-y-1.5`,children:e.map(e=>(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-caption`,children:[(0,G.jsx)(`span`,{className:`inline-block size-2 shrink-0 rounded-[2px] ${k7[e.key]}`}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-muted`,children:t(A7[e.key])}),(0,G.jsx)(`span`,{className:`mono tabular`,children:e.count}),(0,G.jsx)(`span`,{className:`mono w-10 text-right tabular text-muted`,children:nH(e.count/n)})]},e.key))})]}):(0,G.jsx)(`div`,{className:`px-4 py-3 text-body text-muted`,children:t(`statsEmptyTraffic`)})}function P7(e){return e?e>=1e6?`${(e/1e6).toString().replace(/\.0$/,``)}M`:e>=1e3?`${Math.round(e/1e3)}k`:String(e):`—`}function sSe({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=rH(e),s=iH(e),c=String(e.provider||e.owned_by||`qoder`).trim().toLowerCase(),l=jH(c,String(e.region||e.regions?.[0]||``).trim().toLowerCase()||void 0,t),u=c===`trae`?gce(e):void 0;return(0,G.jsx)(Y.Root,{isOpen:!0,onOpenChange:e=>{e||n()},children:(0,G.jsx)(Y.Backdrop,{variant:`blur`,children:(0,G.jsx)(Y.Container,{size:`md`,scroll:`inside`,children:(0,G.jsxs)(Y.Dialog,{children:[(0,G.jsxs)(Y.Header,{className:`items-start justify-between gap-4 px-5 pt-5`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`div`,{className:`text-section`,children:e.display_name||e.id}),s?(0,G.jsx)(aC,{size:`sm`,variant:`soft`,color:`success`,children:t(`modelFree`)}):null]}),(0,G.jsx)(`div`,{className:`mono mt-1 text-caption text-muted`,children:e.id}),(0,G.jsxs)(`div`,{className:`mt-1 text-caption text-muted`,children:[l,o?` · ${o}`:``]})]}),(0,G.jsx)(Y.CloseTrigger,{"aria-label":t(`close`),className:`grid size-8 place-items-center rounded-lg text-muted hover:bg-surface-secondary`,children:(0,G.jsx)(ao,{size:16})})]}),(0,G.jsxs)(Y.Body,{className:`space-y-4 px-5 pb-5`,children:[(0,G.jsxs)(`section`,{children:[(0,G.jsx)(`div`,{className:`text-caption font-medium text-muted`,children:t(`contextWindowCol`)}),(0,G.jsxs)(`div`,{className:`mt-1 text-body`,children:[P7(i),a&&a!==i?` → ${P7(a)}`:``]}),e.supports_max_mode?(0,G.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:t(c===`qoder`?`qoderMaxModeHint`:`maxModeHint`)}):null,!e.supports_max_mode&&a&&a!==i?(0,G.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:t(`workbuddyContextHint`)}):null,u?u.prompt_max_tokens?(0,G.jsxs)(`div`,{className:`mt-1 text-caption text-muted`,children:[t(`promptMaxTokens`),`: `,P7(u.prompt_max_tokens)]}):null:e.prompt_max_tokens?(0,G.jsxs)(`div`,{className:`mt-1 text-caption text-muted`,children:[t(`promptMaxTokens`),`: `,P7(e.prompt_max_tokens)]}):null,u?u.max_output_tokens?(0,G.jsxs)(`div`,{className:`text-caption text-muted`,children:[t(`maxOutputTokens`),`: `,P7(u.max_output_tokens)]}):null:e.max_output_tokens?(0,G.jsxs)(`div`,{className:`text-caption text-muted`,children:[t(`maxOutputTokens`),`: `,P7(e.max_output_tokens)]}):null]}),(0,G.jsxs)(`section`,{children:[(0,G.jsx)(`div`,{className:`text-caption font-medium text-muted`,children:t(`reasoningLevels`)}),r.length?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:t(`reasoningHint`)}),(0,G.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:r.map(n=>{let r=`reasoningLevel_${n}`,i=t(r);return(0,G.jsxs)(aC,{size:`sm`,variant:`soft`,color:n===(e.reasoning_effort||e.reasoning_default)?`success`:`default`,children:[i===r?n:i,n===e.reasoning_default?` · ${t(`defaultValue`)}`:``,n===e.reasoning_effort&&n!==e.reasoning_default?` · ${t(`custom`)}`:``]},n)})})]}):(0,G.jsx)(`div`,{className:`mt-1 text-body text-muted`,children:e.reasoning_type?t(`reasoningFixed`,{type:e.reasoning_type}):t(`noReasoningLevels`)})]})]})]})})})})}function F7({isSelected:e,isDisabled:t,ariaLabel:n,label:r,size:i=`sm`,onChange:a}){return(0,G.jsx)(nj,{size:i,isSelected:e,isDisabled:t,onChange:a,children:(0,G.jsxs)(nj.Content,{children:[(0,G.jsx)(nj.Control,{children:(0,G.jsx)(nj.Thumb,{})}),r?(0,G.jsx)(IN,{children:r}):(0,G.jsx)(`span`,{className:`sr-only`,children:n})]})})}function I7({title:e,hint:t,action:n,icon:r,className:i}){return(0,G.jsx)(`div`,{className:`grid min-h-56 place-items-center px-6 py-12 text-center ${i||``}`,children:(0,G.jsxs)(`div`,{className:`max-w-sm`,children:[r?(0,G.jsx)(`div`,{className:`mb-3 flex justify-center text-muted`,children:r}):null,(0,G.jsx)(Die,{className:`p-0 text-body font-medium text-foreground`,children:e}),t?(0,G.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:t}):null,n?(0,G.jsx)(`div`,{className:`mt-5 flex justify-center`,children:n}):null]})})}var L7=`__all__`;function R7({value:e,onChange:t,ariaLabel:n,options:r,className:i}){let a=r.map(e=>({id:e.id||L7,label:e.label})),o=e||L7,s=a.find(e=>e.id===o);return(0,G.jsxs)(AF,{className:i??`w-fit min-w-36`,"aria-label":n,value:o,onChange:e=>{typeof e==`string`&&t(e===L7?``:e)},children:[(0,G.jsxs)(AF.Trigger,{className:`min-w-0 w-full items-center`,children:[(0,G.jsx)(AF.Value,{className:`min-w-0 truncate`,children:({defaultChildren:e,isPlaceholder:t})=>t||!s?e:(0,G.jsx)(`span`,{className:`truncate`,children:s.label})}),(0,G.jsx)(AF.Indicator,{})]}),(0,G.jsx)(AF.Popover,{className:`max-h-72 min-w-36`,children:(0,G.jsx)(oF,{children:a.map(e=>(0,G.jsxs)(oF.Item,{id:e.id,textValue:e.label,children:[(0,G.jsx)(IN,{className:`block truncate`,children:e.label}),(0,G.jsx)(oF.ItemIndicator,{})]},e.id))})})]})}var cSe=[20,50,100],lSe=[20,50,100];function uSe(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,G.jsx)(qA,{id:String(e),children:e},e))})]}),(0,G.jsxs)(DF,{size:`sm`,className:`w-fit`,children:[(0,G.jsx)(DF.Summary,{className:`mono text-caption`,children:o}),(0,G.jsxs)(DF.Content,{children:[(0,G.jsx)(DF.Item,{children:(0,G.jsx)(DF.Previous,{isDisabled:i||t<=1,onPress:()=>l(Math.max(1,t-1)),"aria-label":s,children:(0,G.jsx)(DF.PreviousIcon,{})})}),f.map((e,n)=>e===`gap`?(0,G.jsx)(DF.Item,{children:(0,G.jsx)(DF.Ellipsis,{})},`gap-${n}`):(0,G.jsx)(DF.Item,{children:(0,G.jsx)(DF.Link,{isActive:e===t,isDisabled:i,onPress:()=>l(e),children:e})},e)),(0,G.jsx)(DF.Item,{children:(0,G.jsx)(DF.Next,{isDisabled:i||t>=n,onPress:()=>l(Math.min(n,t+1)),"aria-label":c,children:(0,G.jsx)(DF.NextIcon,{})})})]})]})]})}function B7({value:e,onChange:t,placeholder:n,ariaLabel:r,className:i}){return(0,G.jsx)(PN,{"aria-label":r,value:e,onChange:t,className:i,children:(0,G.jsxs)(PN.Group,{children:[(0,G.jsx)(PN.SearchIcon,{}),(0,G.jsx)(PN.Input,{placeholder:n}),(0,G.jsx)(PN.ClearButton,{})]})})}function dSe(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 V7(e){return e.settings_key||e.id}function H7(e){return String(e.provider||e.owned_by||`qoder`).trim().toLowerCase()}function U7(e){let t=String(e.region||``).trim().toLowerCase();if(t)return t;let n=e.regions||[];return String(n[0]||``).trim().toLowerCase()}function W7(e){return`${H7(e)}:${U7(e)||`any`}:${e.settings_key||e.id}:${e.native_model||e.mapped_key||``}`}function G7(e){let t=e.route_display_name||``;return t&&t!==(e.display_name||e.id)?t:``}function K7(e,t){let n=`reasoningLevel_${t}`,r=e(n);return r===n?t:r}function q7({label:e,hint:t}){return(0,G.jsxs)(PM,{children:[(0,G.jsx)(PM.Trigger,{children:(0,G.jsx)(`span`,{className:`cursor-help text-caption text-muted`,children:e})}),(0,G.jsx)(PM.Content,{children:(0,G.jsx)(`p`,{className:`max-w-xs text-caption leading-5`,children:t})})]})}function J7({model:e,saving:t,t:n,variant:r=`table`,onToggleTraeMax:i,onReasoningChange:a}){let o=H7(e),s=r===`card`,c=s?`w-full min-w-0`:`w-full max-w-[7.5rem] min-w-0`;return(0,G.jsxs)(`div`,{className:s?`flex min-w-0 flex-col gap-3`:`flex min-w-0 flex-col gap-1.5`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,G.jsxs)(`span`,{className:`mono text-caption text-muted`,children:[P7(e.catalog_context_length||e.context_length),e.catalog_context_length_max&&e.catalog_context_length_max!==(e.catalog_context_length||e.context_length)?` → ${P7(e.catalog_context_length_max)}`:``]}),o===`workbuddy`&&e.catalog_context_length_max&&e.catalog_context_length_max!==(e.catalog_context_length||e.context_length)?(0,G.jsx)(q7,{label:n(`catalogWindow`),hint:n(`workbuddyContextHint`)}):null]}),(o===`trae`||o===`qoder`)&&e.supports_max_mode?(0,G.jsxs)(`div`,{className:s?`flex flex-col gap-1.5`:`flex items-center gap-2`,children:[s?(0,G.jsx)(q7,{label:`${n(`maxMode`)}${e.catalog_context_length_max?` ${P7(e.catalog_context_length_max)}`:``}`,hint:n(o===`qoder`?`qoderMaxModeHint`:`maxModeHint`)}):null,(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(F7,{isSelected:!!e.max_mode,isDisabled:t,ariaLabel:`${e.id} ${n(`maxMode`)}`,onChange:t=>i(e,t)}),s?null:(0,G.jsx)(q7,{label:`${n(`maxMode`)}${e.catalog_context_length_max?` ${P7(e.catalog_context_length_max)}`:``}`,hint:n(o===`qoder`?`qoderMaxModeHint`:`maxModeHint`)})]})]}):null,(e.reasoning_options||[]).length>1?(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1.5`,children:[(0,G.jsx)(q7,{label:n(`reasoningLevels`),hint:n(`reasoningHint`)}),(0,G.jsx)(R7,{className:c,ariaLabel:`${e.id} ${n(`reasoningLevels`)}`,value:e.reasoning_effort||e.reasoning_default||e.reasoning_options?.[0]||``,onChange:t=>{t&&a(e,t)},options:(e.reasoning_options||[]).map(e=>({id:e,label:K7(n,e)}))})]}):(e.reasoning_options||[]).length===1?(0,G.jsx)(q7,{label:`${n(`reasoningLevels`)} ${K7(n,e.reasoning_options[0])}`,hint:n(`reasoningHint`)}):e.reasoning_type?(0,G.jsx)(`span`,{className:`text-caption text-muted`,children:n(`reasoningFixed`,{type:e.reasoning_type})}):o===`trae`&&!e.supports_max_mode?(0,G.jsx)(q7,{label:n(`catalogWindow`),hint:n(`catalogWindowHint`)}):null]})}function Y7({model:e,t,onDetails:n}){return(0,G.jsxs)(J,{size:`sm`,variant:`ghost`,onPress:()=>n(e),children:[(0,G.jsx)($i,{size:14}),t(`modelDetails`)]})}function fSe(){let{t:e}=EI(),{overview:t,loading:n}=qI(),[r,i]=(0,v.useState)(``),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)([]),[l,u]=(0,v.useState)(1),[d,f]=(0,v.useState)(50),[p,m]=(0,v.useState)(!1),[h,g]=(0,v.useState)(``),[_,y]=(0,v.useState)(``),[b,x]=(0,v.useState)(!1),[S,C]=(0,v.useState)(null),[w,T]=(0,v.useState)([]),[E,D]=(0,v.useState)(!0);(0,v.useEffect)(()=>{let e=!1;return ooe(void 0,`regional`).then(t=>{e||T(t.data||[])}).catch(()=>void 0).finally(()=>{e||D(!1)}),UI().then(t=>{e||c(dSe(t.data||[]))}).catch(()=>void 0),()=>{e=!0}},[]);let O=(0,v.useMemo)(()=>{let t=r.trim().toLowerCase(),[n,i]=a.includes(`:`)?a.split(`:`,2):[a,``];return w.filter(r=>{let a=H7(r),o=U7(r);if(n&&a!==n||i&&o!==i)return!1;if(!t)return!0;let s=jH(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,a,e]),k=[r,a,d].join(`\0`),[A,j]=(0,v.useState)(k);A!==k&&(j(k),u(1));let M=Math.max(1,Math.ceil(O.length/d)),N=Math.min(A===k?Math.max(1,l):1,M);l!==N&&u(N);let P=(0,v.useMemo)(()=>{let e=(N-1)*d;return O.slice(e,e+d)},[N,O,d]),F=O.length===0?0:(N-1)*d+1,I=Math.min(O.length,N*d),L=O.length?e(`logsShownTotal`,{shown:`${F}–${I}`,total:O.length}):e(`shownTotal`,{shown:0,total:w.length});if(n&&!t||E)return(0,G.jsx)(Ise,{});function R(e,t){let n=V7(e),r=H7(e),i=w.map(e=>{if(V7(e)!==n||H7(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)}});T(i)}function z(e,t){let n=V7(e),r=H7(e),i=w.map(e=>V7(e)!==n||H7(e)!==r?e:{...e,reasoning_effort:t,context_custom:!!e.max_mode||!!(t&&t!==e.reasoning_default)});T(i)}async function B(){m(!0),y(``),x(!1);try{let e=await HI(void 0,`regional`);T(e.data||[])}catch(e){x(!0),y(e instanceof Error?e.message:String(e))}finally{m(!1)}}async function V(t,n){let r=H7(t);if(r!==`trae`&&r!==`workbuddy`&&r!==`kimi`)return;let i=V7(t);g(i),y(``),x(!1);try{await coe(r,i,n),z(t,n),y(e(`reasoningSaved`,{model:t.id,level:K7(e,n)}))}catch(e){x(!0),y(e instanceof Error?e.message:String(e))}finally{g(``)}}async function H(t,n){if(!t.supports_max_mode){x(!0),y(e(`contextMaxUnavailable`));return}let r=V7(t),i=H7(t);g(r),y(``),x(!1);try{await soe(i,r,n,t.catalog_context_length_max),R(t,n),y(e(n?`contextMaxOn`:`contextMaxOff`,{model:t.id}))}catch(e){x(!0),y(e instanceof Error?e.message:String(e))}finally{g(``)}}return(0,G.jsxs)(`div`,{className:`space-y-6`,children:[(0,G.jsxs)(`section`,{className:`grid gap-5 pb-6 lg:grid-cols-[minmax(0,1fr)_auto] lg:items-end`,children:[(0,G.jsxs)(`div`,{"data-gsap-reveal":!0,children:[(0,G.jsx)(`h2`,{className:`text-title font-semibold`,children:e(`availableModels`)}),(0,G.jsx)(`p`,{className:`mt-1 text-body text-muted`,children:w.length?L:e(`noModelsYet`)})]}),(0,G.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,G.jsx)(B7,{className:`w-full min-w-0 sm:w-72`,value:r,onChange:i,placeholder:e(`filterPh`),ariaLabel:e(`filter`)}),(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,G.jsx)(R7,{ariaLabel:e(`providerCol`),value:a,onChange:o,options:[{id:``,label:e(`providerFilterAll`)},...s.map(t=>({id:t.value,label:jH(t.provider,t.region,e)}))]}),(0,G.jsxs)(J,{size:`sm`,variant:`secondary`,isPending:p,onPress:()=>void B(),children:[(0,G.jsx)(qr,{size:14}),e(p?`refreshing`:`refresh`)]})]})]})]}),_?(0,G.jsx)(QI,{status:b?`danger`:`success`,title:_}):null,(0,G.jsxs)(HS,{"data-gsap-reveal":!0,className:`overflow-hidden p-0`,children:[(0,G.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,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,G.jsx)(`div`,{className:`grid size-9 shrink-0 place-items-center rounded-lg bg-surface-secondary text-muted`,children:(0,G.jsx)(ji,{size:16})}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`div`,{className:`text-body font-semibold`,children:e(`providerCatalog`)}),(0,G.jsx)(`div`,{className:`mt-0.5 text-caption leading-5 text-muted`,children:e(`contextConfigHint`)})]})]}),(0,G.jsx)(aC,{size:`sm`,variant:`soft`,className:`shrink-0`,children:O.length})]}),p||n?(0,G.jsx)(LV,{}):O.length===0?(0,G.jsx)(I7,{icon:(0,G.jsx)(la,{size:22}),title:w.length?e(`noModelsMatch`):e(`noProviders`),hint:w.length?r||a||e(`noModelsMatch`):e(`noModelsYet`)}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`divide-y divide-separator lg:hidden`,children:P.map(t=>{let n=V7(t),r=h===n,i=H7(t),a=jH(i,U7(t)||void 0,e),o=rH(t),s=iH(t);return(0,G.jsxs)(`article`,{className:`space-y-3 px-4 py-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,G.jsx)(`span`,{className:`status-dot mt-1.5`,"data-state":t.stale?void 0:`ok`}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`div`,{className:`truncate font-medium`,children:t.display_name||t.id}),s?(0,G.jsx)(aC,{size:`sm`,variant:`soft`,color:`success`,children:e(`modelFree`)}):null,o?(0,G.jsx)(`span`,{className:`mono text-caption text-muted`,children:o}):null]}),(0,G.jsx)(`div`,{className:`mono mt-0.5 truncate text-caption text-muted`,children:t.id}),G7(t)?(0,G.jsx)(`div`,{className:`mt-0.5 text-caption text-muted`,children:e(`routedTo`,{model:G7(t)})}):null]})]}),(0,G.jsx)(aC,{size:`sm`,variant:`soft`,color:t.context_custom||t.stale?`warning`:`success`,children:t.context_custom?e(`custom`):e(`defaultValue`)})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-caption`,children:[(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,G.jsx)(MH,{provider:i,size:14}),(0,G.jsx)(`span`,{className:`font-medium`,children:a})]}),(0,G.jsx)(`span`,{className:`mono break-all text-muted`,children:t.mapped_key||t.native_model||t.id})]}),(0,G.jsx)(J7,{model:t,saving:r,t:e,variant:`card`,onToggleTraeMax:(e,t)=>void H(e,t),onReasoningChange:(e,t)=>void V(e,t)}),(0,G.jsx)(Y7,{model:t,t:e,onDetails:C})]},W7(t))})}),(0,G.jsx)(X,{className:`hidden min-w-0 lg:block`,children:(0,G.jsx)(X.ScrollContainer,{className:`min-w-0 overflow-x-auto`,children:(0,G.jsxs)(X.Content,{"aria-label":e(`availableModels`),className:`min-w-[68rem]`,children:[(0,G.jsxs)(X.Header,{children:[(0,G.jsx)(X.Column,{isRowHeader:!0,children:e(`modelCol`)}),(0,G.jsx)(X.Column,{children:e(`requestIdCol`)}),(0,G.jsx)(X.Column,{children:e(`providerCol`)}),(0,G.jsx)(X.Column,{children:e(`qoderKeyCol`)}),(0,G.jsx)(X.Column,{children:e(`modelDefaultsCol`)}),(0,G.jsx)(X.Column,{children:e(`stateCol`)}),(0,G.jsx)(X.Column,{children:e(`actions`)})]}),(0,G.jsx)(X.Body,{children:P.map(t=>{let n=V7(t),r=h===n,i=H7(t),a=jH(i,U7(t)||void 0,e),o=rH(t),s=iH(t);return(0,G.jsxs)(X.Row,{children:[(0,G.jsx)(X.Cell,{children:(0,G.jsxs)(`div`,{className:`flex items-center gap-3 py-1`,children:[(0,G.jsx)(`span`,{className:`status-dot`,"data-state":t.stale?void 0:`ok`}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`div`,{className:`font-medium`,children:t.display_name||t.id}),s?(0,G.jsx)(aC,{size:`sm`,variant:`soft`,color:`success`,children:e(`modelFree`)}):null,o?(0,G.jsx)(`span`,{className:`mono text-caption text-muted`,children:o}):null]}),G7(t)?(0,G.jsx)(`div`,{className:`mt-0.5 text-caption text-muted`,children:e(`routedTo`,{model:G7(t)})}):null]})]})}),(0,G.jsx)(X.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-caption font-medium`,children:t.id})}),(0,G.jsx)(X.Cell,{children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(MH,{provider:i,size:14}),(0,G.jsx)(`span`,{className:`text-caption font-medium`,children:a})]})}),(0,G.jsx)(X.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-caption text-muted`,children:t.mapped_key||t.native_model||t.id})}),(0,G.jsx)(X.Cell,{children:(0,G.jsx)(J7,{model:t,saving:r,t:e,variant:`table`,onToggleTraeMax:(e,t)=>void H(e,t),onReasoningChange:(e,t)=>void V(e,t)})}),(0,G.jsx)(X.Cell,{children:(0,G.jsx)(aC,{size:`sm`,variant:`soft`,color:t.context_custom||t.stale?`warning`:`success`,children:t.context_custom?e(`custom`):e(`defaultValue`)})}),(0,G.jsx)(X.Cell,{children:(0,G.jsx)(Y7,{model:t,t:e,onDetails:C})})]},W7(t))})})]})})})]})]}),(0,G.jsx)(sSe,{model:S?w.find(e=>V7(e)===V7(S))||S:null,t:e,onClose:()=>C(null)}),(0,G.jsx)(z7,{total:O.length,page:N,pageCount:M,pageSize:d,loading:p,pageSizeLabel:e(`logsPageSize`),pageLabel:e(`logsPage`,{page:N,pages:M}),prevLabel:e(`logsPrevPage`),nextLabel:e(`logsNextPage`),onPage:u,onPageSize:f})]})}function X7({copied:e,size:t=14,className:n}){let r=(0,v.useRef)(null),i=(0,v.useRef)(null),a=(0,v.useRef)(!0);return(0,v.useLayoutEffect)(()=>{let t=e?i.current:r.current,n=e?r.current:i.current;if(!t||!n)return;let o={autoAlpha:1,scale:1,filter:`blur(0px)`},s={autoAlpha:0,scale:.5,filter:`blur(4px)`};if(a.current||jV()){a.current=!1,Z.set(t,o),Z.set(n,s);return}Z.to(n,{...s,duration:kV.fast,ease:AV.out,overwrite:!0}),Z.fromTo(t,s,{...o,duration:kV.base,ease:AV.soft,delay:kV.instant/2,overwrite:!0})},[e]),(0,G.jsxs)(`span`,{className:`relative inline-grid place-items-center ${n??``}`,style:{width:t,height:t},children:[(0,G.jsx)(`span`,{ref:r,className:`col-start-1 row-start-1 inline-flex`,children:(0,G.jsx)(Di,{size:t})}),(0,G.jsx)(`span`,{ref:i,className:`col-start-1 row-start-1 inline-flex text-success`,children:(0,G.jsx)(_i,{size:t})})]})}async function Z7(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}}function Q7(){return`${location.protocol}//${location.host}`}function $7(e){return e?/^https?:\/\//i.test(e)?e:e.startsWith(`/`)?`${Q7()}${e}`:`${Q7()}/${e}`:Q7()}function pSe({access:e}){let{t}=EI(),[n,r]=(0,v.useState)(``),i=$7(e?.openai_base_url||`/v1`),a=(0,v.useMemo)(()=>[{name:t(`endpointOpenAI`),url:i,method:`BASE`,hint:t(`endpointBaseHint`),icon:(0,G.jsx)(ai,{size:15})},{name:t(`endpointChat`),url:$7(e?.chat_completions||`${i}/chat/completions`),method:`POST`,hint:t(`endpointChatHint`),icon:(0,G.jsx)(ha,{size:15})},{name:t(`endpointMessages`),url:$7(e?.messages||`${i}/messages`),method:`POST`,hint:t(`endpointMessagesHint`),icon:(0,G.jsx)(ha,{size:15})},{name:t(`endpointResponses`),url:$7(e?.responses||`${i}/responses`),method:`POST`,hint:t(`endpointResponsesHint`),icon:(0,G.jsx)(ha,{size:15})},{name:t(`endpointModels`),url:$7(e?.models||`${i}/models`),method:`GET`,hint:t(`endpointModelsHint`),icon:(0,G.jsx)(sa,{size:15})},{name:t(`endpointHealth`),url:$7(e?.health||`/health`),method:`GET`,hint:t(`endpointHealthHint`),icon:(0,G.jsx)(Zi,{size:15})}],[e,i,t]);return(0,G.jsxs)(`section`,{className:`overflow-hidden rounded-3xl bg-surface shadow-surface`,children:[(0,G.jsx)(`div`,{className:`flex items-start justify-between gap-4 px-5 py-4 sm:px-6`,children:(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`h3`,{className:`font-semibold`,children:t(`endpoints`)}),(0,G.jsx)(aC,{size:`sm`,variant:`soft`,children:t(`endpointCount`,{count:a.length-1})})]}),(0,G.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:t(`routesHint`)})]})}),(0,G.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:a.map(e=>(0,G.jsxs)(`div`,{className:`group min-w-0 rounded-xl bg-surface-secondary/40 p-3 transition-colors hover:bg-surface-secondary/70`,children:[(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-2.5`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,G.jsx)(`span`,{className:`grid size-7 shrink-0 place-items-center rounded-lg bg-surface text-muted`,children:e.icon}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`div`,{className:`truncate text-body font-semibold`,children:e.name}),(0,G.jsx)(`code`,{className:`mono mt-0.5 block truncate text-caption text-muted`,children:e.url})]})]}),(0,G.jsx)(aC,{size:`sm`,variant:`soft`,children:e.method})]}),(0,G.jsx)(`p`,{className:`mt-2 text-caption leading-5 text-muted`,children:e.hint}),(0,G.jsxs)(`div`,{className:`mt-2 flex items-center justify-between gap-2`,children:[(0,G.jsx)(`span`,{className:`text-caption font-medium text-muted`,children:e.method===`BASE`?t(`endpointBaseLabel`):t(`endpointAuthLabel`)}),(0,G.jsxs)(`div`,{className:`flex gap-1`,children:[(0,G.jsx)(J,{isIconOnly:!0,size:`sm`,variant:`ghost`,"aria-label":t(`copy`),onPress:()=>{Z7(e.url),r(e.name),window.setTimeout(()=>r(``),1100)},children:(0,G.jsx)(X7,{copied:n===e.name})}),(0,G.jsx)(J,{isIconOnly:!0,size:`sm`,variant:`ghost`,"aria-label":t(`open`),onPress:()=>window.open(e.url,`_blank`,`noopener,noreferrer`),children:(0,G.jsx)(Zr,{size:14})})]})]})]},e.name))})]})}var mSe=`https://caiaiu.com`;function e9({className:e=``}){let{t}=EI();return(0,G.jsx)(`p`,{className:`text-caption leading-5 text-muted ${e}`.trim(),children:(0,G.jsx)(`a`,{href:mSe,target:`_blank`,rel:`noopener noreferrer`,className:`underline-offset-2 transition-colors hover:text-foreground hover:underline`,children:t(`caiaiSoftLink`)})})}var hSe=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(`.`)),gSe=new Set([`image/png`,`image/jpeg`,`image/jpg`,`image/gif`,`image/webp`]);function _Se(e){let t=e.lastIndexOf(`.`);return t>=0?e.slice(t+1).toLowerCase():``}function vSe(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}async function ySe(e){let t=_Se(e.name),n=e.type||`application/octet-stream`,r=`${e.name}-${e.size}-${e.lastModified}-${Math.random().toString(36).slice(2,8)}`;if(gSe.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(hSe.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 t9({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,G.jsxs)(AF,{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,G.jsxs)(AF.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,G.jsx)(AF.Value,{className:`min-w-0 truncate text-caption font-medium`,children:({defaultChildren:e,isPlaceholder:t})=>t||!c?e:(0,G.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1`,children:[c.icon?(0,G.jsx)(`span`,{className:`grid size-3.5 shrink-0 place-items-center opacity-80`,children:c.icon}):null,(0,G.jsx)(`span`,{className:`truncate`,children:c.label})]})}),(0,G.jsx)(AF.Indicator,{className:`size-2.5 opacity-50`})]}),(0,G.jsx)(AF.Popover,{placement:`top end`,className:`max-h-72 min-w-48`,children:(0,G.jsx)(oF,{children:a.map(e=>(0,G.jsxs)(oF.Item,{id:e.id,textValue:e.textValue,className:`gap-2`,children:[e.icon?(0,G.jsx)(`span`,{className:`grid size-5 shrink-0 place-items-center`,children:e.icon}):null,(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(IN,{className:`block truncate text-caption`,children:e.label}),e.hint?(0,G.jsx)(`span`,{className:`block truncate text-caption text-muted`,children:e.hint}):null]}),(0,G.jsx)(oF.ItemIndicator,{})]},e.id))})})]})}function bSe({value:e,onChange:t,attachments:n,onAttachmentsChange:r,disabled:i,streaming:a,canSend:o,onSend:s,onStop:c,accountValue:l,onAccountChange:u,accountOptions:d,modelValue:f,onModelChange:p,modelOptions:m,modelsLoading:h}){let{t:g}=EI(),_=(0,v.useRef)(null);async function y(e){if(!e?.length)return;let t=[],i=[];for(let n of Array.from(e))try{let e=await ySe(n);e?t.push(e):i.push(n.name)}catch{i.push(n.name)}t.length&&r([...n,...t]),i.length&&window.alert(g(`chatAttachUnsupported`,{names:i.join(`, `)})),_.current&&(_.current.value=``)}function b(e){e.key!==`Enter`||e.shiftKey||e.nativeEvent.isComposing||(e.preventDefault(),!a&&o&&s())}return(0,G.jsxs)(`div`,{className:`access-composer px-3 pb-3 pt-2.5 sm:px-4 sm:pb-3.5 sm:pt-3`,children:[(0,G.jsxs)(`div`,{className:`access-composer-well overflow-hidden rounded-2xl`,children:[n.length?(0,G.jsx)(`div`,{className:`flex flex-wrap gap-2 px-3 pt-3`,children:n.map(e=>(0,G.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,G.jsx)(`img`,{src:e.dataUrl,alt:``,className:`size-8 shrink-0 rounded-lg object-cover`}):(0,G.jsx)(`span`,{className:`grid size-8 shrink-0 place-items-center rounded-lg bg-surface-secondary text-muted`,children:(0,G.jsx)(Ui,{size:14})}),(0,G.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`span`,{className:`block truncate font-medium`,children:e.name}),(0,G.jsx)(`span`,{className:`mono text-muted`,children:vSe(e.size)})]}),(0,G.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":g(`chatAttachRemove`),onClick:()=>r(n.filter(t=>t.id!==e.id)),children:(0,G.jsx)(ao,{size:12})})]},e.id))}):null,(0,G.jsx)(JM,{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:b,placeholder:g(`promptPlaceholder`),"aria-label":g(`prompt`),disabled:i||a}),(0,G.jsxs)(`div`,{className:`flex items-center gap-0.5 px-2 pb-2 pt-0.5`,children:[(0,G.jsx)(`input`,{ref:_,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 y(e.target.files)}),(0,G.jsx)(J,{isIconOnly:!0,size:`sm`,variant:`ghost`,className:`size-8 min-w-8 shrink-0 rounded-[10px]`,"aria-label":g(`chatAttach`),isDisabled:i||a,onPress:()=>_.current?.click(),children:(0,G.jsx)(Ca,{size:15})}),(0,G.jsx)(`div`,{className:`min-w-0 flex-1`}),(0,G.jsx)(t9,{ariaLabel:g(`account`),value:l,onChange:u,options:d,isDisabled:i||a,tone:`muted`,className:`w-auto max-w-[8.5rem] min-w-0`}),(0,G.jsx)(t9,{ariaLabel:g(`model`),value:f,onChange:p,placeholder:g(h?`requesting`:`model`),options:m,isDisabled:i||a||h||!m.length,className:`w-auto max-w-[10.5rem] min-w-0`}),(0,G.jsxs)(`div`,{className:`relative size-8 shrink-0`,children:[(0,G.jsx)(J,{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":g(`chatTryStop`),onPress:c,children:(0,G.jsx)(Va,{size:14,weight:`fill`})}),(0,G.jsx)(J,{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":g(`chatTrySend`),isDisabled:!o||i||a,onPress:s,children:(0,G.jsx)(ha,{size:14,weight:`fill`})})]})]})]}),(0,G.jsx)(`p`,{className:`mt-1 px-1 text-caption leading-4 text-muted/65`,children:g(`chatTryHelper`)})]})}function xSe({collapsed:e,onCollapsedChange:t,items:n,activeId:r,onSelect:i,onNew:a}){let{t:o}=EI(),s=(0,v.useRef)(null);return(0,v.useEffect)(()=>{let t=s.current;!t||jV()||e||Z.fromTo(t,{autoAlpha:0},{autoAlpha:1,duration:kV.fast,ease:`power2.out`})},[e]),e?(0,G.jsxs)(`div`,{className:`access-hist-rail flex w-9 shrink-0 flex-col items-center gap-1 border-r py-2`,children:[(0,G.jsx)(J,{isIconOnly:!0,size:`sm`,variant:`ghost`,className:`size-8 min-w-8 rounded-[10px] text-muted`,"aria-label":o(`chatHistoryExpand`),onPress:()=>t(!1),children:(0,G.jsx)(ka,{size:15})}),(0,G.jsx)(J,{isIconOnly:!0,size:`sm`,variant:`ghost`,className:`size-8 min-w-8 rounded-[10px] text-muted`,"aria-label":o(`chatHistoryNew`),onPress:a,children:(0,G.jsx)(Ca,{size:14})})]}):(0,G.jsxs)(`aside`,{ref:s,className:`access-hist-rail flex w-[13rem] shrink-0 flex-col border-r`,"aria-label":o(`chatHistoryTitle`),children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1 px-2 py-2`,children:[(0,G.jsx)(`div`,{className:`min-w-0 flex-1 truncate px-1.5 text-caption font-medium text-muted`,children:o(`chatHistoryTitle`)}),(0,G.jsx)(J,{isIconOnly:!0,size:`sm`,variant:`ghost`,className:`size-8 min-w-8 rounded-[10px] text-muted`,"aria-label":o(`chatHistoryCollapse`),onPress:()=>t(!0),children:(0,G.jsx)(li,{size:14})})]}),(0,G.jsx)(`div`,{className:`px-2 pb-1.5`,children:(0,G.jsxs)(J,{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:a,children:[(0,G.jsx)(Ca,{size:13}),o(`chatHistoryNew`)]})}),(0,G.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===r;return(0,G.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:()=>i(e.id),children:(0,G.jsx)(`span`,{className:`line-clamp-1 tracking-tight`,children:e.title||o(`chatHistoryUntitled`)})},e.id)}):(0,G.jsx)(`p`,{className:`px-2.5 py-6 text-center text-caption leading-5 text-muted/70`,children:o(`chatHistoryEmpty`)})})]})}function n9({latencyMs:e,ttfbMs:t,completionTokens:n,stream:r,labels:i,className:a=``,variant:o=`block`}){let s=dce(uce({completionTokens:n,latencyMs:e,ttfbMs:t,stream:r})),c=eH(t),l=eH(e);if(o===`inline`)return(0,G.jsxs)(`div`,{className:`mono text-caption leading-4 text-muted ${a}`.trim(),children:[(0,G.jsxs)(`span`,{children:[i.ttft,` `,c]}),(0,G.jsx)(`span`,{className:`mx-1.5 text-separator`,children:`·`}),(0,G.jsxs)(`span`,{children:[i.total,` `,l]}),(0,G.jsx)(`span`,{className:`mx-1.5 text-separator`,children:`·`}),(0,G.jsx)(`span`,{children:s})]});let u=[[i.ttft,c],[i.total,l],[i.tps,s]];return(0,G.jsxs)(`div`,{className:a,children:[i.heading?(0,G.jsx)(`div`,{className:`mb-1 text-caption font-medium text-muted`,children:i.heading}):null,(0,G.jsx)(`div`,{className:`border-l border-separator pl-2 leading-4`,children:u.map(([e,t])=>(0,G.jsxs)(`div`,{className:`flex items-baseline gap-2 py-px`,children:[(0,G.jsx)(`span`,{className:`shrink-0 text-caption text-muted`,children:e}),(0,G.jsx)(`span`,{className:`mono text-xs text-foreground`,children:t})]},e))})]})}function SSe({text:e,streaming:t,defaultOpen:n}){let{t:r}=EI(),[i,a]=(0,v.useState)(!!n),[o,s]=(0,v.useState)(0),c=(0,v.useRef)(0),l=(0,v.useRef)(null),u=(0,v.useRef)(null);if((0,v.useEffect)(()=>{t?a(!1):n!=null&&a(!!n)},[t,n]),(0,v.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,v.useEffect)(()=>{!t&&o===0&&c.current>0&&s(c.current)},[t,o]),(0,v.useEffect)(()=>{let t=l.current,n=u.current;if(!t)return;let r=jV();if(!i||!e){if(r){t.style.height=`0px`,t.style.opacity=`0`;return}Z.to(t,{height:0,opacity:0,duration:kV.fast,ease:AV.inOut,overwrite:!0});return}let a=n?.scrollHeight??0;if(r){t.style.height=`auto`,t.style.opacity=`1`;return}Z.fromTo(t,{height:0,opacity:0},{height:a,opacity:1,duration:kV.base,ease:AV.out,overwrite:!0,onComplete:()=>{t.style.height=`auto`}})},[i,e]),!e&&!t)return null;let d=jV(),f=t?o:o||c.current;return(0,G.jsxs)(`div`,{className:`overflow-hidden rounded-xl`,children:[(0,G.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,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Ci,{size:12,className:`shrink-0 text-muted ${d?``:`animate-spin`}`}),(0,G.jsx)(`span`,{className:d?``:`access-thinking-shimmer`,children:r(`thinkingWorking`)}),(0,G.jsxs)(`span`,{className:`mono text-muted/80`,children:[o,`s`]})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(di,{size:11,className:`shrink-0 transition-transform duration-200 ease-out ${i?`rotate-90`:``}`}),(0,G.jsx)(`span`,{children:r(`thinkingDone`)}),f>0?(0,G.jsx)(`span`,{className:`mono text-muted/80`,children:r(`thinkingElapsed`,{n:f})}):null,!f&&e?(0,G.jsx)(`span`,{className:`mono text-muted/80`,children:r(`thinkingChars`,{count:e.length})}):null]})}),(0,G.jsx)(`div`,{ref:l,className:`overflow-hidden`,style:{height:0,opacity:0},children:e?(0,G.jsx)(`pre`,{ref:u,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 CSe(e,t){return t(e===`running`?`toolCallRunning`:e===`error`?`toolCallError`:`toolCallSuccess`)}function wSe({status:e}){return e===`running`?(0,G.jsx)(Fa,{size:12,className:`animate-spin text-muted`}):e===`error`?(0,G.jsx)(ro,{size:12,weight:`fill`,className:`text-danger`}):(0,G.jsx)(yi,{size:12,weight:`fill`,className:`text-success`})}function TSe(e){if(!e.trim())return``;try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function r9({call:e,forceOpen:t}){let{t:n}=EI(),[r,i]=(0,v.useState)(e.status===`error`||!!t),[a,o]=(0,v.useState)(!1),s=(0,v.useMemo)(()=>TSe(e.arguments||``),[e.arguments]);(0,v.useEffect)(()=>{e.status===`error`&&i(!0)},[e.status]),(0,v.useEffect)(()=>{t&&i(!0)},[t]);async function c(){s&&(await Z7(s),o(!0),window.setTimeout(()=>o(!1),1200))}return(0,G.jsxs)(`div`,{className:`overflow-hidden rounded-lg`,children:[(0,G.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,G.jsx)(di,{size:11,className:`shrink-0 text-muted transition-transform ${r?`rotate-90`:``}`}),(0,G.jsx)(`span`,{className:`mono min-w-0 flex-1 truncate text-caption font-medium text-foreground`,children:e.name||n(`toolCallUntitled`)}),(0,G.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 text-caption text-muted`,children:[(0,G.jsx)(wSe,{status:e.status}),CSe(e.status,n)]})]}),r?(0,G.jsxs)(`div`,{className:`space-y-1.5 px-2 pb-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,G.jsx)(`div`,{className:`text-caption font-medium text-muted`,children:n(`toolCallArgs`)}),(0,G.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,G.jsx)(ki,{size:12}),n(a?`copied`:`copy`)]})]}),(0,G.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 ESe({calls:e}){let{t}=EI(),n=e.some(e=>e.status===`error`),r=e.some(e=>e.status===`running`),[i,a]=(0,v.useState)(n||r||e.length===1);return(0,v.useEffect)(()=>{(n||r)&&a(!0)},[n,r]),e.length?e.length===1?(0,G.jsx)(`div`,{className:`rounded-xl bg-surface-secondary/70`,children:(0,G.jsx)(r9,{call:e[0],forceOpen:e[0].status===`error`})}):(0,G.jsxs)(`div`,{className:`overflow-hidden rounded-xl bg-surface-secondary/70`,children:[(0,G.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,G.jsx)(di,{size:11,className:`shrink-0 transition-transform ${i?`rotate-90`:``}`}),(0,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium text-foreground`,children:t(`toolCallGroup`,{n:e.length})}),r?(0,G.jsx)(Fa,{size:12,className:`animate-spin`}):null]}),i?(0,G.jsx)(`div`,{className:`space-y-0.5 border-t border-separator/40 px-0.5 py-1`,children:e.map(e=>(0,G.jsx)(r9,{call:e},`${e.index}-${e.id||e.name}`))}):null]}):null}function DSe({message:e}){return e.attachments?.length?(0,G.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:e.attachments.map(e=>(0,G.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,G.jsx)(`img`,{src:e.dataUrl,alt:``,className:`size-7 shrink-0 rounded-lg object-cover`}):(0,G.jsx)(`span`,{className:`grid size-7 shrink-0 place-items-center rounded-lg bg-surface`,children:(0,G.jsx)(Ui,{size:12})}),(0,G.jsx)(`span`,{className:`truncate`,children:e.name})]},e.id))}):null}function OSe({message:e}){let{t}=EI(),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:$V(r??0),completion:$V(i??0)}):``;return(0,G.jsx)(`span`,{className:`mono text-caption text-muted`,children:a?t(`chatTryUsageFoot`,{tokens:a,amount:cH(n.credits)}):t(`chatTryCreditsUsed`,{amount:cH(n.credits)})})}function kSe({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,G.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,G.jsx)(`span`,{children:e},`s-${n}`):(0,G.jsx)(`span`,{className:t&&n===r?`access-stream-seg`:void 0,children:e},`p-${n}`):null)})}function ASe(){let e=(0,v.useRef)(null);return(0,v.useEffect)(()=>{let t=e.current;!t||jV()||Z.from(t,{autoAlpha:0,duration:kV.fast,ease:`power2.out`})},[]),e}function jSe({message:e}){let{t}=EI(),[n,r]=(0,v.useState)(!1),i=e.role===`user`,a=ASe();if(i)return(0,G.jsx)(`div`,{ref:a,className:`ml-auto max-w-[92%] sm:max-w-[78%]`,children:(0,G.jsxs)(`div`,{className:`access-bubble access-bubble--user rounded-2xl rounded-br-md px-3.5 py-2.5`,children:[e.content?(0,G.jsx)(`div`,{className:`whitespace-pre-wrap break-words text-body leading-[1.65] text-foreground`,children:e.content}):null,(0,G.jsx)(DSe,{message:e})]})});let o=e.status===`streaming`&&!e.content&&!e.reasoning&&!e.toolCalls?.length,s=!!e.content&&e.status===`done`,c=e.status===`streaming`,l=!!(e.usage&&e.usage.credits!=null),u=e.status===`done`&&(e.latency_ms!=null||e.ttfb_ms!=null||typeof e.usage?.completion_tokens==`number`);async function d(){e.content&&(await Z7(e.content),r(!0),window.setTimeout(()=>r(!1),1200))}return(0,G.jsxs)(`div`,{className:`group/access-msg max-w-[96%] space-y-1.5 sm:max-w-[88%]`,children:[e.reasoning||c?(0,G.jsx)(SSe,{text:e.reasoning||``,streaming:c&&(!e.content||!!e.reasoning),defaultOpen:e.reasoningOpen}):null,e.toolCalls?.length?(0,G.jsx)(ESe,{calls:e.toolCalls}):null,e.status===`error`?(0,G.jsx)(QI,{status:`danger`,title:t(`requestFailed`),description:e.error||``}):o?(0,G.jsxs)(`div`,{className:`space-y-2 pt-0.5`,children:[(0,G.jsx)(UA,{className:`h-3 w-28 rounded-md`}),(0,G.jsx)(UA,{className:`h-3 w-full rounded-md`}),(0,G.jsx)(UA,{className:`h-3 w-[86%] rounded-md`}),(0,G.jsx)(UA,{className:`h-3 w-[68%] rounded-md`})]}):e.content?(0,G.jsx)(`div`,{className:`access-bubble access-bubble--assistant px-0.5 py-0`,children:(0,G.jsx)(kSe,{text:e.content,streaming:c})}):null,s||l||u?(0,G.jsxs)(`div`,{className:`access-msg-foot space-y-1 px-0.5 pt-0.5`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[s?(0,G.jsxs)(`button`,{type:`button`,className:`inline-flex h-5 items-center gap-1 text-caption text-muted/80 opacity-70 transition-opacity hover:text-foreground hover:opacity-100`,onClick:()=>void d(),children:[(0,G.jsx)(ki,{size:12}),t(n?`copied`:`copy`)]}):null,(0,G.jsx)(OSe,{message:e})]}),u?(0,G.jsx)(n9,{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 MSe({messages:e,busy:t,onLoadDemo:n}){let{t:r}=EI(),i=(0,v.useRef)(null);(0,v.useEffect)(()=>{i.current?.scrollIntoView({block:`end`})},[e,t]);let a=!e.length;return(0,G.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,G.jsx)(I7,{className:`min-h-56`,title:r(`chatTryEmptyTitle`),hint:r(`chatTryEmptyHint`),action:n?(0,G.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,G.jsx)(`div`,{className:`space-y-4`,children:e.map(e=>(0,G.jsx)(jSe,{message:e},e.id))}),(0,G.jsx)(`div`,{ref:i})]})}function NSe({format:e,onFormatChange:t,requestPath:n,prompt:r,onPromptChange:i,onTest:a,requestState:o,elapsedMs:s,output:c,responseStatus:l,curl:u,copiedCurl:d,onCopyCurl:f,canSend:p,accountValue:m,onAccountChange:h,accountOptions:g,modelValue:_,onModelChange:v,modelOptions:y,modelsLoading:b,disabled:x}){let{t:S}=EI();return(0,G.jsxs)(`div`,{className:`space-y-4`,children:[(0,G.jsx)(`p`,{className:`px-1 text-caption leading-5 text-muted`,children:S(`rawFormatHint`)}),(0,G.jsx)(`div`,{className:`access-raw-panel overflow-hidden rounded-2xl`,children:(0,G.jsxs)(`div`,{className:`grid xl:grid-cols-[minmax(420px,.92fr)_minmax(0,1.08fr)]`,children:[(0,G.jsxs)(`div`,{className:`xl:border-r xl:border-[color-mix(in_oklab,var(--foreground)_6%,transparent)]`,children:[(0,G.jsxs)(`div`,{className:`px-4 py-3.5 sm:px-5`,children:[(0,G.jsx)(`h3`,{className:`text-body font-semibold`,children:S(`requestBuilder`)}),(0,G.jsxs)(`p`,{className:`mt-0.5 text-caption text-muted`,children:[`POST `,n]})]}),(0,G.jsxs)(`div`,{className:`space-y-4 px-4 pb-4 sm:px-5 sm:pb-5`,children:[(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(`div`,{className:`text-caption font-medium text-muted`,children:S(`rawFormatLabel`)}),(0,G.jsx)(pH,{className:`access-format-chips`,ariaLabel:S(`rawFormatLabel`),value:e,onChange:e=>t(e),options:[{id:`chat`,label:S(`rawFormatChat`)},{id:`messages`,label:S(`rawFormatMessages`)},{id:`responses`,label:S(`rawFormatResponses`)}]})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(0,G.jsx)(t9,{ariaLabel:S(`account`),value:m,onChange:h,options:g,isDisabled:x||o===`loading`,tone:`muted`,className:`w-auto max-w-[8.5rem] min-w-0`}),(0,G.jsx)(t9,{ariaLabel:S(`model`),value:_,onChange:v,placeholder:S(b?`requesting`:`model`),options:y,isDisabled:x||o===`loading`||b||!y.length,className:`w-auto max-w-[10.5rem] min-w-0`})]}),(0,G.jsxs)(`div`,{className:`space-y-2.5`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,G.jsx)(`div`,{className:`text-caption font-medium text-muted`,children:S(`prompt`)}),(0,G.jsx)(`span`,{className:`mono text-caption text-muted`,children:r.length})]}),(0,G.jsx)(JM,{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:S(`promptPlaceholder`),"aria-label":S(`prompt`),disabled:x||o===`loading`}),(0,G.jsx)(`p`,{className:`text-caption leading-5 text-muted/70`,children:S(`promptHelper`)})]}),(0,G.jsxs)(J,{fullWidth:!0,isPending:o===`loading`,isDisabled:!p||x,onPress:a,children:[(0,G.jsx)(ha,{size:15}),S(o===`loading`?`requesting`:`sendRequest`)]})]})]}),(0,G.jsxs)(`div`,{className:`access-raw-panel__inspector flex min-h-[440px] min-w-0 flex-col`,"aria-live":`polite`,"aria-busy":o===`loading`,children:[(0,G.jsxs)(`div`,{className:`flex min-h-12 items-center justify-between gap-4 px-4 py-3 sm:px-5`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`text-body font-semibold`,children:S(`responseInspector`)}),(0,G.jsx)(`p`,{className:`mt-0.5 text-caption text-muted`,children:S(`responseInspectorHint`)})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[s===null?null:(0,G.jsxs)(`span`,{className:`mono flex items-center gap-1.5 text-caption text-muted`,children:[(0,G.jsx)(Ti,{size:12}),s,` ms`]}),(0,G.jsx)(aC,{size:`sm`,variant:`soft`,color:o===`success`?`success`:o===`error`?`danger`:void 0,children:l})]})]}),(0,G.jsx)(`div`,{className:`min-h-0 flex-1 px-4 pb-4 sm:px-5 sm:pb-5`,children:o===`idle`?(0,G.jsx)(I7,{className:`min-h-64`,title:S(`responseEmptyTitle`),hint:S(`responseEmptyHint`)}):o===`loading`?(0,G.jsxs)(`div`,{className:`space-y-3 pt-1`,children:[(0,G.jsx)(UA,{className:`h-3 w-32 rounded-lg`}),(0,G.jsx)(UA,{className:`h-3 w-full rounded-lg`}),(0,G.jsx)(UA,{className:`h-3 w-[88%] rounded-lg`}),(0,G.jsx)(UA,{className:`h-3 w-[72%] rounded-lg`}),(0,G.jsx)(UA,{className:`mt-7 h-3 w-[92%] rounded-lg`}),(0,G.jsx)(UA,{className:`h-3 w-[64%] rounded-lg`})]}):o===`error`?(0,G.jsx)(`div`,{className:`space-y-3`,children:(0,G.jsx)(QI,{status:`danger`,title:S(`requestFailed`),description:c})}):(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 text-caption font-medium text-success`,children:[(0,G.jsx)(yi,{size:14,weight:`fill`}),S(`responseReceived`)]}),(0,G.jsx)(`pre`,{className:`mono overflow-x-auto whitespace-pre-wrap break-words text-caption leading-6 text-muted`,children:c})]})})]})]})}),(0,G.jsxs)(`section`,{className:`access-raw-panel overflow-hidden rounded-2xl`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-4 px-4 py-3 sm:px-5`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`div`,{className:`text-body font-semibold`,children:S(`curlExample`)}),(0,G.jsx)(`div`,{className:`mt-0.5 truncate text-caption text-muted`,children:S(`curlGeneratedHint`)})]}),(0,G.jsxs)(J,{size:`sm`,variant:`ghost`,onPress:f,children:[(0,G.jsx)(X7,{copied:d}),S(d?`copied`:`copy`)]})]}),(0,G.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:u})]})]})}function i9(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 PSe(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:i9(t.content,t.attachments||[])});continue}t.content&&n.push({role:`assistant`,content:t.content})}return[...n,t]}var FSe=`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAFUlEQVR42mNkYPhfz0AEYBxVSF+FABJADveWkH6aAAAAAElFTkSuQmCC`;function a9(){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:FSe,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`,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. @@ -172,4 +172,4 @@ Keep the reply short and ops-console toned.`,toolCalls:[{index:0,id:`call_demo_l -H "Authorization: Bearer $CLI2API_API_KEY" \\ -H ${o9(`Content-Type: application/json`)}${oe?` \\ -H ${o9(`X-Qoder-Account: ${oe}`)}`:``} \\ - -d ${o9(JSON.stringify(me))}`,[me,T,oe]);if(n&&!t)return(0,G.jsx)(Rse,{});async function ge(e,t){await Z7(e),ae(t),window.setTimeout(()=>ae(``),1100)}async function _e(){let e=performance.now();te(`loading`),re(null),H(``);try{let e=await doe(w,me,oe||void 0);H(JSON.stringify(e,null,2)),te(`success`)}catch(e){H(e instanceof Error?e.message:String(e)),te(`error`)}finally{re(Math.round(performance.now()-e))}}function ve(){B.current?.abort(),B.current=null}function ye(e){let t=p;u(n=>n.map(n=>{if(n.id!==t)return n;let r=typeof e==`function`?e(n.messages):e;return{...n,messages:r,title:l9(r)||n.title,updatedAt:Date.now()}}))}function be(e,t){ye(n=>n.map(n=>{if(n.id!==e)return n;let r=typeof t==`function`?t(n):t;return{...n,...r}}))}async function xe(){let e=P.trim();if(!e&&!I.length||!fe||le||R===`loading`)return;ve();let t=new AbortController;B.current=t;let n=I,r={id:s9(`user`),role:`user`,content:e,attachments:n,status:`done`},i=s9(`assistant`),a={id:i,role:`assistant`,content:``,status:`streaming`},o=m;ye([...o,r,a]),F(``),L([]),z(`loading`);let s=PSe(o,{role:`user`,content:i9(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 moe(fe,s,oe||void 0,{signal:t.signal,onContent:(e,t)=>{e&&u(),be(i,{content:t})},onReasoning:(e,t)=>{e&&u(),be(i,{reasoning:t})},onToolCalls:e=>{u(),be(i,{toolCalls:LSe(e,!0)})},onUsage:e=>be(i,{usage:e})}),be(i,e=>({status:`done`,...d(),toolCalls:e.toolCalls?.map(e=>({...e,status:`success`}))})),z(`success`)}catch(e){if(t.signal.aborted){be(i,e=>({status:`done`,...d(),toolCalls:e.toolCalls?.map(e=>({...e,status:`success`}))})),z(`success`);return}be(i,{status:`error`,error:e instanceof Error?e.message:String(e),...d()}),z(`error`)}finally{B.current===t&&(B.current=null)}}let Se=e(ee===`success`?`requestComplete`:ee===`error`?`requestFailed`:ee===`loading`?`requesting`:`requestIdle`),Ce=c9()!=null,we=[{id:`auto`,textValue:e(`autoAccount`),label:e(`autoAccount`),icon:(0,G.jsx)(ti,{size:14,className:`text-muted`})},..._.map(t=>({id:t.id,textValue:`${t.name||t.id} ${jH(t.provider,t.region,e)}`,label:t.name||t.id,hint:jH(t.provider,t.region,e),icon:(0,G.jsx)(MH,{provider:t.provider,size:14})}))],Te=_.length||!Ce?we:[{id:`auto`,textValue:e(`autoAccount`),label:e(`autoAccount`),icon:(0,G.jsx)(ti,{size:14,className:`text-muted`})},{id:`demo-wb`,textValue:`wb-demo WorkBuddy`,label:`wb-demo`,hint:`WorkBuddy`}],Ee=ce.map(t=>{let n=rH(t),r=iH(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(` · `)}}),De=Ee.length||!Ce?Ee:d9.map(t=>{let n=rH(t),r=iH(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(` · `)}}),Oe=!!((P.trim()||I.length)&&fe&&!le&&(_.length||Ce));function ke(){ye(a9()),z(`idle`)}function Ae(){ve(),z(`idle`),F(``),L([]);let e=u9([]);u(t=>[e,...t]),f(e.id)}function je(e){e!==p&&(ve(),z(`idle`),F(``),L([]),f(e))}let Me=l.slice().sort((e,t)=>t.updatedAt-e.updatedAt).map(t=>({id:t.id,title:t.title||e(`chatHistoryUntitled`),updatedAt:t.updatedAt}));return(0,G.jsxs)(`div`,{className:`access-page space-y-4`,children:[(0,G.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,G.jsx)(`h2`,{className:`shrink-0 text-body font-semibold text-foreground`,children:e(`apiPlayground`)}),(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5 text-caption text-muted`,children:[(0,G.jsx)(`span`,{className:`shrink-0`,children:e(`baseUrl`)}),(0,G.jsx)(`code`,{className:`mono min-w-0 truncate font-medium text-foreground`,children:b}),(0,G.jsx)(J,{isIconOnly:!0,size:`sm`,variant:`ghost`,className:`size-6 min-w-6 shrink-0`,"aria-label":e(`copyBaseUrl`),onPress:()=>void ge(b,`base`),children:(0,G.jsx)(X7,{copied:ie===`base`,size:13})})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-caption text-muted`,children:[(0,G.jsx)(`span`,{className:`status-dot`,"data-state":pe.length?`ok`:void 0}),(0,G.jsx)(`span`,{children:e(`readyAccounts`,{ready:pe.length,total:_.length})}),(0,G.jsx)(aC,{size:`sm`,variant:`soft`,color:pe.length?`success`:`warning`,children:pe.length?e(`endpointReady`):e(`degraded`)})]})]}),_.length?null:(0,G.jsxs)(`div`,{className:`space-y-1 px-1`,children:[(0,G.jsx)(`p`,{className:`text-caption text-muted`,children:e(`noAccountsForTest`)}),(0,G.jsx)(e9,{})]}),ue?(0,G.jsx)(`p`,{className:`px-1 text-caption text-danger`,children:ue}):null,(0,G.jsxs)(_j,{selectedKey:r,onSelectionChange:e=>i(String(e)),children:[(0,G.jsx)(_j.ListContainer,{className:`w-fit`,children:(0,G.jsxs)(_j.List,{"aria-label":e(`accessTabsLabel`),children:[(0,G.jsxs)(gj,{id:`chat`,className:`gap-1.5 whitespace-nowrap`,children:[(0,G.jsx)(_j.Indicator,{className:`transition-none`}),e(`accessTabChat`)]}),(0,G.jsxs)(gj,{id:`raw`,className:`gap-1.5 whitespace-nowrap`,children:[(0,G.jsx)(_j.Indicator,{className:`transition-none`}),e(`accessTabApi`)]})]})}),(0,G.jsx)(_j.Panel,{id:`chat`,className:`pt-4`,children:(0,G.jsxs)(`div`,{className:`flex min-h-[640px] md:min-h-[72vh]`,children:[(0,G.jsx)(xSe,{collapsed:s,onCollapsedChange:c,items:Me,activeId:p,onSelect:je,onNew:Ae}),(0,G.jsxs)(`div`,{className:`access-chat-stage flex min-w-0 flex-1 flex-col`,children:[(0,G.jsx)(MSe,{messages:m,busy:R===`loading`,onLoadDemo:ke}),(0,G.jsx)(bSe,{value:P,onChange:F,attachments:I,onAttachmentsChange:L,disabled:!_.length&&c9()==null,streaming:R===`loading`,canSend:Oe,onSend:()=>void xe(),onStop:ve,accountValue:oe||`auto`,onAccountChange:e=>k(e===`auto`?``:e),accountOptions:Te,modelValue:fe,onModelChange:D,modelOptions:De,modelsLoading:le})]})]})}),(0,G.jsxs)(_j.Panel,{id:`raw`,className:`space-y-4 pt-4`,children:[(0,G.jsx)(NSe,{format:a,onFormatChange:o,requestPath:w,prompt:M,onPromptChange:N,onTest:()=>void _e(),requestState:ee,elapsedMs:ne,output:V,responseStatus:Se,curl:he,copiedCurl:ie===`curl`,onCopyCurl:()=>void ge(he,`curl`),canSend:!!(M.trim()&&fe&&!le),accountValue:oe||`auto`,onAccountChange:e=>k(e===`auto`?``:e),accountOptions:Te,modelValue:fe,onModelChange:D,modelOptions:De,modelsLoading:le,disabled:!_.length&&c9()==null}),(0,G.jsx)(pSe,{access:t?.access})]})]})]})}function BSe(e){(0,v.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let n=Z.context(()=>{Z.matchMedia().add(`(prefers-reduced-motion: no-preference)`,()=>{let e=Z.utils.toArray(`.meter__fill`);e.length&&Z.from(e,{scaleX:0,transformOrigin:`left center`,duration:kV.calm,ease:AV.emphasized,stagger:Ose.base,clearProps:`transform,transformOrigin`})})},t);return()=>n.revert()},[e])}function f9(e){if(!e)return``;let t=Date.parse(e)-Date.now();if(!Number.isFinite(t)||t<=0)return``;let n=Math.ceil(t/1e3);return n<60?`${n}s`:`${Math.ceil(n/60)}m`}function VSe(e){return Object.entries(e.model_cooldowns??{}).filter(([,e])=>!!f9(e)).sort(([e],[t])=>e.localeCompare(t))}function p9(e){return e.enabled?e.status===`quota_exhausted`||e.quota?.exceeded?`quota_exhausted`:e.status===`cooling`||f9(e.down_until||e.cooldown_until)?`cooling`:e.status===`dead`||e.runtime_state===`dead`?`dead`:e.status===`auth_failed`||e.runtime_state===`auth_failed`?`auth_failed`:e.status===`login_required`?`login`:(e.status===`starting`||e.runtime_state===`starting`)&&!e.hot&&!e.ready?e.quota?`starting`:`loading`:e.status===`ready`?e.hot?`hot`:`ready`:e.hot?`hot`:e.ready?`ready`:(e.status===`error`||e.status,`unavailable`):`disabled`}function HSe(e){return e===`hot`?12:e===`ready`?9:e===`cooling`?5:e===`login`?3:e===`loading`||e===`starting`?6:e===`unavailable`?2:e===`auth_failed`?3:e===`dead`?2:1}function USe(e){return e===`hot`||e===`ready`?`ok`:e===`cooling`||e===`quota_exhausted`||e===`loading`||e===`starting`?`warn`:e===`auth_failed`||e===`unavailable`||e===`dead`||e===`login`?`danger`:`muted`}function m9(e){return e==null||!Number.isFinite(e)?`—`:Math.abs(e)>=1e3?`${(e/1e3).toFixed(e%1e3==0?0:1)}k`:String(Math.round(e*100)/100)}function h9(e){let t=e.percentage??0;return Number.isFinite(t)?Math.min(1,Math.max(0,t/100)):0}function g9(e){let t=e.percentage??0;return e.exceeded?`danger`:t>=80?`warn`:`ok`}function WSe(e){return(e.windows??[]).filter(e=>!!e.id)}var GSe={free:`Free`,go:`Go`,plus:`Plus`,pro:`Pro`,prolite:`Pro Lite`,promax:`Pro Max`,team:`Team`,business:`Business`,enterprise:`Enterprise`,edu:`Edu`,edu_plus:`Edu Plus`,edu_pro:`Edu Pro`,education:`Education`};function KSe(e){let t=e?.trim().toLowerCase()??``;return!t||t===`unknown`||t===`guest`?``:GSe[t]??t.replace(/[_-]+/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function qSe(e,t){return e.id===`daily`?t(`quotaDaily`):e.id===`weekly`?t(`quotaWeekly`):e.id===`monthly`?t(`quotaMonthly`):e.id===`fiveHour`?t(`quotaFiveHour`):e.id===`weeklyLimit`?t(`quotaWeeklyLimit`):e.id===`monthlyLimit`?t(`quotaMonthlyLimit`):e.label||t(`quota`)}function JSe(e,t){if(!e)return``;let n=Date.parse(e)-Date.now();if(!Number.isFinite(n)||n<=0)return t(`quotaResetsSoon`);let r=Math.max(1,Math.ceil(n/6e4));return r<60?t(`quotaResetsInMinutes`,{n:r}):t(`quotaResetsInHours`,{n:Math.round(r/60)})}function YSe(e,t){if(!e.expires_at||e.expires_at<=0||!Number.isFinite(e.expires_at))return``;let n=new Date(e.expires_at*1e3);if(Number.isNaN(n.getTime()))return``;let r=`${n.getFullYear()}/${n.getMonth()+1}/${n.getDate()}`;return t(`quotaExpiresOn`,{amount:e.expiring_remain&&e.expiring_remain>0?`${m9(e.expiring_remain)} `:``,unit:e.unit||`credits`,date:r})}function XSe(e,t,n,r,i,a){return[e.has_add_on&&e.add_on_available!==!1?`${n} ${m9(e.add_on_used)} / ${m9(e.add_on_total)} ${e.add_on_unit||`credits`}`:``,e.has_resource_package&&e.resource_package_available!==!1?`${r} ${t} ${m9(e.resource_package_remaining)} ${e.resource_package_unit||`credits`}`:``,a===`workbuddy`?YSe(e,i):``].filter(Boolean)}function ZSe({window:e,t,extra:n}){let r=Math.round(e.percentage??0),i=qSe(e,t),a=t(`quotaUsedPercent`,{n:r}),o=JSe(e.reset_at,t),s=`${i} · ${a}${o?` · ${o}`:``}`,c=h9(e),l=g9(e),u=l===`danger`?`danger`:l===`warn`?`warning`:`success`;return(0,G.jsxs)(PM,{children:[(0,G.jsx)(PM.Trigger,{className:`block w-full min-w-0`,children:(0,G.jsxs)(`div`,{className:`w-full min-w-0 cursor-help`,children:[(0,G.jsxs)(IF,{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,G.jsxs)(IF.Output,{className:`flex w-full items-baseline justify-between gap-3 text-caption`,children:[(0,G.jsx)(`span`,{className:`min-w-0 truncate font-medium text-foreground`,children:i}),(0,G.jsx)(`span`,{className:`mono shrink-0 text-foreground/70`,children:a})]}),(0,G.jsx)(IF.Track,{children:(0,G.jsx)(IF.Fill,{})})]}),o?(0,G.jsx)(`div`,{className:`mt-1 text-caption leading-4 text-muted`,children:o}):null]})}),(0,G.jsx)(PM.Content,{children:(0,G.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,G.jsx)(`div`,{children:s}),n?.map(e=>(0,G.jsx)(`div`,{children:e},e))]})})]})}function QSe({quota:e,t,label:n,usedLabel:r,remainingLabel:i,addOnLabel:a,resourcePackageLabel:o,exceededLabel:s,provider:c}){let l=e.unit||`credits`,u=`${m9(e.used)} / ${m9(e.total)}`,d=`${m9(e.remaining)}`,f=XSe(e,i,a,o,t,c),p=WSe(e),m=c===`codex`?KSe(e.plan):``,h=h9(e),g=g9(e),_=g===`danger`?`danger`:g===`warn`?`warning`:`success`,y=(0,v.useRef)(null);BSe(y);let b=`${r} ${u} ${l} · ${i} ${d} ${l}${f.length?` · ${f.join(` · `)}`:``}`;return p.length>0?(0,G.jsxs)(`div`,{ref:y,className:`account-quota-windows flex w-full min-w-0 flex-col gap-3`,children:[m?(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-caption`,children:[(0,G.jsx)(`span`,{className:`text-muted`,children:t(`quotaPlan`)}),(0,G.jsx)(`span`,{className:`font-medium text-foreground`,children:m})]}):null,p.map((e,n)=>(0,G.jsx)(`div`,{className:`w-full min-w-0`,children:(0,G.jsx)(ZSe,{window:e,t,extra:n===0?f:void 0})},e.id||String(n)))]}):(0,G.jsxs)(PM,{children:[(0,G.jsx)(PM.Trigger,{children:(0,G.jsx)(`div`,{ref:y,className:`w-full cursor-help`,children:(0,G.jsxs)(IF,{className:`account-meter w-full`,color:_,size:`md`,minValue:0,maxValue:100,value:Math.round(h*100),"aria-label":n,valueLabel:b,children:[(0,G.jsxs)(IF.Output,{className:`flex w-full items-baseline justify-between text-caption`,children:[(0,G.jsxs)(`span`,{className:`text-body font-semibold leading-5 text-foreground tabular-nums`,children:[e.exceeded?(0,G.jsx)(`span`,{className:`mr-1.5 text-danger`,children:s}):null,d,(0,G.jsx)(`span`,{className:`ml-1 text-caption font-normal text-foreground/60`,children:l})]}),(0,G.jsxs)(`span`,{className:`mono text-foreground/55`,children:[r,` `,u]})]}),(0,G.jsx)(IF.Track,{children:(0,G.jsx)(IF.Fill,{})})]})})}),(0,G.jsx)(PM.Content,{children:(0,G.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,G.jsxs)(`div`,{children:[r,` `,u,` `,l]}),(0,G.jsxs)(`div`,{children:[i,` `,d,` `,l]}),f.map(e=>(0,G.jsx)(`div`,{children:e},e))]})})]})}function $Se({state:e,stateCopy:t,t:n}){let r=(0,v.useRef)(null),i=HSe(e),a=USe(e);return(0,v.useLayoutEffect)(()=>{let e=r.current;if(!e)return;let t=Z.context(()=>{let e=Z.utils.toArray(`[data-runtime-seg]`),t=e.filter((e,t)=>tt>=i),r=Z.matchMedia();r.add(`(prefers-reduced-motion: reduce)`,()=>{Z.set(t,{scaleY:1,autoAlpha:1}),Z.set(n,{scaleY:.32,autoAlpha:.45})}),r.add(`(prefers-reduced-motion: no-preference)`,()=>{Z.set(e,{transformOrigin:`center bottom`}),Z.to(n,{scaleY:.32,autoAlpha:.45,duration:kV.fast,ease:AV.out,overwrite:!0}),Z.to(t,{scaleY:1,autoAlpha:1,duration:kV.base,ease:AV.out,stagger:{amount:.08,from:`start`},overwrite:!0})})},e);return()=>t.revert()},[i,e]),(0,G.jsxs)(`div`,{ref:r,className:`flex items-center gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 text-caption font-medium text-foreground/75`,children:[(0,G.jsx)(`span`,{className:`status-dot`,"data-state":a===`muted`?void 0:a===`warn`?`warn`:a}),(0,G.jsx)(`span`,{children:n(`runtimeState`)})]}),(0,G.jsx)(`div`,{className:`runtime-meter min-w-[80px] flex-1`,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,G.jsx)(`span`,{"data-runtime-seg":!0,"data-on":t{if(!M&&!N&&P.length===0)return;let e=window.setInterval(()=>A(e=>e+1),1e3);return()=>window.clearInterval(e)},[M,N,P.length]);let F=eCe(j,j===`dead`?N:M,o),I=j===`hot`||j===`ready`?`success`:j===`cooling`?`warning`:j===`quota_exhausted`||j===`login`||j===`unavailable`||j===`dead`||j===`auth_failed`?`danger`:void 0,L=e.last_error||e.lastError,R=e.last_error_kind||e.kind,z=jH(e.provider,e.region,o),B=e.last_checkin_status,V=B===`success`?`checkinRecordSuccess`:B===`already`?`checkinRecordAlready`:B===`skipped`?`checkinRecordSkipped`:B===`error`?`checkinRecordFailed`:`lastCheckinNone`;return(0,v.useLayoutEffect)(()=>{let e=T.current;if(!e)return;let t=k.current;if(k.current=j,!t||t===j)return;let n=Z.context(()=>{let t=Z.matchMedia();t.add(`(prefers-reduced-motion: reduce)`,()=>{Z.set(e,{scale:1,autoAlpha:1})}),t.add(`(prefers-reduced-motion: no-preference)`,()=>{Z.fromTo(e,{scale:.94,autoAlpha:.65},{scale:1,autoAlpha:1,duration:.2,ease:`power2.out`,overwrite:!0})})},e);return()=>n.revert()},[j]),(0,v.useLayoutEffect)(()=>{let e=E.current;if(!e||!n)return;let t=Z.context(()=>{let t=Z.matchMedia();t.add(`(prefers-reduced-motion: reduce)`,()=>{Z.set(e,{autoAlpha:1,y:0})}),t.add(`(prefers-reduced-motion: no-preference)`,()=>{Z.fromTo(e,{autoAlpha:0,y:-6},{autoAlpha:1,y:0,duration:.2,ease:`power3.out`,overwrite:!0})})},e);return()=>t.revert()},[n]),(0,G.jsxs)(HS,{"data-gsap-reveal":!0,"data-state":j,className:`account-card overflow-hidden p-0`,children:[(0,G.jsxs)(HS.Header,{className:`flex-row items-start justify-between gap-2.5 px-4 pt-3.5 pb-2`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,G.jsx)(`div`,{className:`flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-tertiary`,children:(0,G.jsx)(MH,{provider:e.provider,size:20})}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,G.jsx)(HS.Title,{className:`truncate text-body leading-5`,children:e.name||e.id}),(0,G.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-secondary px-1.5 py-px text-caption text-muted`,children:z})]}),(0,G.jsx)(HS.Description,{className:`mono truncate text-caption leading-4 text-foreground/60`,title:`${e.id}${e.remote_uid?` · UID ${e.remote_uid}`:``}`,children:e.remote_uid?`UID ${e.remote_uid}`:e.id})]})]}),(0,G.jsxs)(`div`,{className:`flex max-w-[48%] shrink-0 flex-wrap justify-end gap-1.5`,children:[(0,G.jsx)(`span`,{ref:T,children:P.length&&j===`cooling`?(0,G.jsxs)(PM,{children:[(0,G.jsx)(PM.Trigger,{children:(0,G.jsx)(`span`,{className:`inline-flex cursor-help`,children:(0,G.jsx)(aC,{size:`sm`,variant:`soft`,color:I,children:F})})}),(0,G.jsx)(PM.Content,{children:(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`div`,{className:`font-medium`,children:o(`partialCooling`)}),P.map(([e,t])=>(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-4 text-caption`,children:[(0,G.jsx)(`span`,{children:e}),(0,G.jsx)(`span`,{className:`mono text-foreground/65`,children:f9(t)})]},e))]})})]}):(0,G.jsx)(aC,{size:`sm`,variant:`soft`,color:I,children:F})}),P.length&&j!==`cooling`?(0,G.jsxs)(PM,{children:[(0,G.jsx)(PM.Trigger,{children:(0,G.jsx)(`span`,{className:`inline-flex cursor-help`,children:(0,G.jsx)(aC,{size:`sm`,variant:`soft`,color:`warning`,children:o(`partialCooling`)})})}),(0,G.jsx)(PM.Content,{children:(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`div`,{className:`font-medium`,children:o(`partialCooling`)}),P.map(([e,t])=>(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-4 text-caption`,children:[(0,G.jsx)(`span`,{children:e}),(0,G.jsx)(`span`,{className:`mono text-foreground/65`,children:f9(t)})]},e))]})})]}):null]})]}),(0,G.jsxs)(HS.Content,{className:`gap-1.5 px-4 pb-3`,children:[(0,G.jsx)($Se,{state:j,stateCopy:F,t:o}),e.quota?(0,G.jsx)(QSe,{quota:e.quota,t:o,label:o(`quota`),usedLabel:o(`quotaUsed`),remainingLabel:o(`quotaRemaining`),addOnLabel:o(`quotaAddOn`),resourcePackageLabel:o(`quotaResourcePackage`),exceededLabel:o(`quotaExceeded`),provider:e.provider}):(0,G.jsx)(`span`,{className:`text-caption text-foreground/65`,children:o(j===`hot`||j===`ready`||j===`loading`||j===`starting`?`quotaLoading`:`quotaUnavailable`)}),L?(0,G.jsxs)(PM,{children:[(0,G.jsx)(PM.Trigger,{children:(0,G.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,G.jsx)(ro,{size:14,className:`mt-0.5 shrink-0 text-danger`}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[R?(0,G.jsx)(`div`,{className:`mono mb-0.5 truncate text-caption opacity-75`,children:R}):null,(0,G.jsx)(`p`,{className:`break-words line-clamp-3`,children:L})]})]})}),(0,G.jsx)(PM.Content,{children:(0,G.jsxs)(`div`,{className:`max-w-md whitespace-pre-wrap break-words`,children:[R?(0,G.jsx)(`div`,{className:`mono mb-1 text-caption opacity-75`,children:R}):null,L]})})]}):null]}),n&&e.enabled?(0,G.jsxs)(`section`,{ref:E,className:`grid gap-3 bg-surface-secondary/55 px-3 py-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-caption font-medium text-muted`,children:o(`oauthDeviceFlow`)}),(0,G.jsx)(`p`,{className:`mt-1.5 text-caption leading-5 text-muted`,children:e.provider===`codex`?o(`wizardCodexBrowserLead`):o(`qoderLoginHint`)}),(0,G.jsx)(`div`,{className:`mt-2.5 flex flex-wrap gap-2`,children:e.provider===`codex`?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(J,{size:`sm`,isPending:t===`device`,onPress:()=>c(`cli`),children:[(0,G.jsx)(Da,{size:14}),o(`startCodexCliLogin`)]}),(0,G.jsxs)(J,{size:`sm`,variant:`secondary`,isPending:t===`device`,onPress:()=>c(`chatgpt`),children:[(0,G.jsx)(Da,{size:14}),o(`startCodexChatGPTLogin`)]})]}):(0,G.jsxs)(J,{size:`sm`,isPending:t===`device`,onPress:()=>c(),children:[(0,G.jsx)(Da,{size:14}),o(`startBrowserLogin`)]})}),(e.provider===`trae`||e.provider===`codex`||e.provider===`devin`)&&f&&d?(0,G.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[(0,G.jsx)(`p`,{className:`text-caption leading-4 text-muted`,children:o(`wizardCallbackLead`)}),(0,G.jsx)(JM,{className:`h-24 w-full resize-none font-mono text-caption leading-5`,value:u||``,onChange:e=>d(e.target.value),placeholder:o(`wizardCallbackPh`),"aria-label":o(`wizardCallbackPh`)}),(0,G.jsx)(J,{size:`sm`,variant:`secondary`,isPending:t===`callback`,onPress:f,children:o(`wizardSubmitCallback`)})]}):null]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-caption font-medium text-muted`,children:o(`patFallback`)}),(0,G.jsxs)(`div`,{className:`mt-2.5 flex flex-col gap-2 sm:flex-row`,children:[(0,G.jsxs)(YM,{className:`flex-1`,type:`password`,value:a,onChange:s,children:[(0,G.jsx)(IN,{className:`sr-only`,children:o(`pat`)}),(0,G.jsx)(UM,{placeholder:o(`pasteToken`),"aria-label":o(`pat`)})]}),(0,G.jsxs)(J,{size:`sm`,variant:`secondary`,isPending:t===`pat`,onPress:l,children:[(0,G.jsx)(ta,{size:14}),o(`usePat`)]})]})]}),r||i?(0,G.jsxs)(`div`,{className:`text-caption`,children:[r?(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`mb-1 text-caption font-medium text-muted`,children:o(`authUrl`)}),(0,G.jsx)(`code`,{className:`mono block break-all text-foreground`,children:r}),(0,G.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:[(0,G.jsxs)(J,{size:`sm`,variant:`secondary`,onPress:()=>window.open(r,`_blank`,`noopener,noreferrer`),children:[(0,G.jsx)(Zr,{size:14}),o(`openAuthUrl`)]}),(0,G.jsxs)(J,{size:`sm`,variant:`ghost`,onPress:()=>{Z7(r).then(e=>{e&&(O(!0),window.setTimeout(()=>O(!1),1100))})},children:[(0,G.jsx)(X7,{copied:D}),o(D?`copied`:`copy`)]})]})]}):null,i?(0,G.jsx)(`p`,{className:`mt-1 text-muted`,children:i}):null]}):null]}):null,b?(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-3 border-t border-separator px-4 py-2 text-caption text-muted`,children:[(0,G.jsxs)(PM,{children:[(0,G.jsx)(PM.Trigger,{children:(0,G.jsxs)(`span`,{className:`flex cursor-help items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`font-medium`,children:o(`lastCheckin`)}),(0,G.jsx)(`span`,{className:B===`error`?`text-danger`:``,children:o(V)})]})}),(0,G.jsxs)(PM.Content,{children:[e.last_checkin_at?new Date(e.last_checkin_at).toLocaleString():o(`lastCheckinNone`),e.last_checkin_msg?` · ${e.last_checkin_msg}`:``]})]}),(0,G.jsxs)(PM,{children:[(0,G.jsx)(PM.Trigger,{children:(0,G.jsxs)(`span`,{className:`flex cursor-help items-center gap-1.5`,children:[(0,G.jsx)(`span`,{className:`font-medium`,children:o(`autoCheckin`)}),(0,G.jsx)(`span`,{className:`mono text-caption text-foreground/55`,children:e.checkin_time||_}),(0,G.jsx)(F7,{isSelected:!!e.auto_checkin,isDisabled:!!t,ariaLabel:o(`autoCheckin`),onChange:e=>y?.(e)})]})}),(0,G.jsx)(PM.Content,{children:e.checkin_time?o(`checkinCustom`):o(`checkinInherit`)})]})]}):null,(0,G.jsxs)(HS.Footer,{className:`flex flex-wrap items-center gap-1.5 bg-surface-secondary px-4 py-2`,children:[m?(0,G.jsxs)(PM,{children:[(0,G.jsx)(PM.Trigger,{children:(0,G.jsx)(J,{isIconOnly:!0,size:`sm`,variant:`secondary`,isPending:t===`refresh`,onPress:m,"aria-label":o(`refreshAccount`),children:(0,G.jsx)(qr,{size:15})})}),(0,G.jsx)(PM.Content,{children:o(`refreshAccount`)})]}):null,(0,G.jsxs)(PM,{children:[(0,G.jsx)(PM.Trigger,{children:(0,G.jsx)(J,{isIconOnly:!0,size:`sm`,variant:n?`secondary`:`ghost`,isDisabled:!e.enabled,onPress:C,"aria-label":o(`authentication`),children:(0,G.jsx)(ta,{size:15})})}),(0,G.jsx)(PM.Content,{children:o(`authentication`)})]}),(0,G.jsxs)(PM,{children:[(0,G.jsx)(PM.Trigger,{children:(0,G.jsx)(J,{isIconOnly:!0,size:`sm`,variant:`ghost`,onPress:w,"aria-label":o(`accountModels`),children:(0,G.jsx)(ji,{size:15})})}),(0,G.jsx)(PM.Content,{children:o(`accountModels`)})]}),(0,G.jsxs)(PM,{children:[(0,G.jsx)(PM.Trigger,{children:(0,G.jsx)(J,{isIconOnly:!0,size:`sm`,variant:`ghost`,onPress:S,"aria-label":o(`editAccount`),children:(0,G.jsx)(ya,{size:15})})}),(0,G.jsx)(PM.Content,{children:o(`editAccount`)})]}),b?(0,G.jsxs)(PM,{children:[(0,G.jsx)(PM.Trigger,{children:(0,G.jsx)(J,{isIconOnly:!0,size:`sm`,variant:`ghost`,isDisabled:!e.enabled||!!t,isPending:t===`checkin`,onPress:b,"aria-label":o(`checkinNow`),children:(0,G.jsx)(si,{size:15})})}),(0,G.jsx)(PM.Content,{children:o(`checkinNow`)})]}):null,(0,G.jsxs)(uF,{children:[(0,G.jsx)(uF.Trigger,{children:(0,G.jsx)(J,{isIconOnly:!0,size:`sm`,variant:`secondary`,"aria-label":o(`more`),children:(0,G.jsx)(Fi,{size:16})})}),(0,G.jsx)(uF.Popover,{placement:`bottom end`,children:(0,G.jsxs)(uF.Menu,{"aria-label":o(`more`),onAction:e=>{e===`export`&&p(),e===`checkin-records`&&x?.(),e===`delete`&&h()},children:[e.auth_type===`none`?null:(0,G.jsxs)(uF.Item,{id:`export`,textValue:o(`export`),children:[(0,G.jsx)(Di,{size:15}),o(`export`)]}),x?(0,G.jsxs)(uF.Item,{id:`checkin-records`,textValue:o(`checkinRecords`),children:[(0,G.jsx)(sa,{size:15}),o(`checkinRecords`)]}):null,(0,G.jsxs)(uF.Item,{id:`delete`,textValue:o(`delete`),className:`text-danger`,children:[(0,G.jsx)(qa,{size:15}),o(`delete`)]})]})})]}),(0,G.jsx)(`div`,{className:`ml-auto flex shrink-0 flex-nowrap items-center gap-3 whitespace-nowrap`,children:(0,G.jsx)(F7,{isSelected:!!e.enabled,isDisabled:t===`toggle`,ariaLabel:e.enabled?o(`disable`):o(`enable`),label:e.enabled?o(`enabledState`):o(`disabled`),onChange:g})})]})]})}function nCe(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 rCe(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}function iCe({account:e,t,onClose:n}){let[r,i]=(0,v.useState)([]),[a,o]=(0,v.useState)(!!e?.id),[s,c]=(0,v.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,v.useEffect)(()=>{l&&d()},[l]),(0,G.jsx)(Y.Root,{isOpen:!!e,onOpenChange:e=>{e||n()},children:(0,G.jsx)(Y.Backdrop,{variant:`blur`,children:(0,G.jsx)(Y.Container,{size:`lg`,scroll:`inside`,children:(0,G.jsxs)(Y.Dialog,{children:[(0,G.jsxs)(Y.Header,{className:`items-start justify-between gap-4 px-5 pt-5`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(Y.Heading,{className:`text-section font-semibold`,children:u}),(0,G.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:t(`checkinRecordsHint`)})]}),(0,G.jsx)(Y.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,G.jsx)(ao,{size:16})})]}),(0,G.jsxs)(Y.Body,{className:`px-5 pb-2`,children:[s?(0,G.jsx)(`div`,{className:`mb-3`,children:(0,G.jsx)(QI,{title:s})}):null,a?(0,G.jsxs)(`div`,{className:`space-y-2 py-1`,children:[(0,G.jsx)(Q,{className:`h-16 w-full`}),(0,G.jsx)(Q,{className:`h-16 w-full`}),(0,G.jsx)(Q,{className:`h-16 w-full`})]}):r.length?(0,G.jsx)(`div`,{className:`divide-y divide-separator overflow-hidden rounded-lg bg-surface-secondary`,children:r.map(e=>{let n=nCe(e,t);return(0,G.jsxs)(`div`,{className:`flex items-start gap-3 px-3 py-3`,children:[(0,G.jsx)(`span`,{className:`status-dot mt-1.5 shrink-0`,"data-state":e.status===`error`?`warn`:`ok`}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(aC,{size:`sm`,variant:`soft`,color:n.color,children:n.label}),(0,G.jsx)(`span`,{className:`mono text-caption text-muted`,children:rCe(e.created_at)})]}),(0,G.jsx)(`p`,{className:`mt-1 break-words text-caption leading-5 text-foreground/75`,children:e.message||`—`})]})]},e.id)})}):(0,G.jsx)(I7,{className:`min-h-44 rounded-3xl bg-surface-secondary`,title:t(`checkinRecordsEmpty`),hint:t(`checkinRecordsHint`)})]}),(0,G.jsxs)(Y.Footer,{className:`justify-between px-5 pb-5`,children:[(0,G.jsx)(`span`,{className:`mono text-caption text-muted`,children:t(`checkinRecordsCount`,{count:r.length})}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(J,{size:`sm`,variant:`ghost`,onPress:n,children:t(`close`)}),(0,G.jsxs)(J,{size:`sm`,variant:`secondary`,isPending:a,onPress:()=>void d(),children:[(0,G.jsx)(qr,{size:14}),t(`refresh`)]})]})]})]})})})})}function aCe(e){let t=e.route_display_name||``;return t&&t!==(e.display_name||e.id)?t:``}function oCe({account:e,t,onClose:n}){let[r,i]=(0,v.useState)([]),[a,o]=(0,v.useState)(!!e?.id),[s,c]=(0,v.useState)(!1),[l,u]=(0,v.useState)(``),d=e?.id||``,f=t(`accountModelsTitle`,{name:e?.name||e?.id||``}),p=e?jH(e.provider,e.region,t):``;async function m(e=!1){if(d){e?c(!0):(o(!0),i([])),u(``);try{let t=await(e?HI(d):VI(d));i(t.data||[])}catch(e){i([]),u(e instanceof Error?e.message:String(e))}finally{o(!1),c(!1)}}}return(0,v.useEffect)(()=>{if(!d)return;let e=!1;return VI(d).then(t=>{e||(i(t.data||[]),u(``),o(!1))}).catch(t=>{e||(i([]),u(t instanceof Error?t.message:String(t)),o(!1))}),()=>{e=!0}},[d]),(0,G.jsx)(Y.Root,{isOpen:!!e,onOpenChange:e=>{e||n()},children:(0,G.jsx)(Y.Backdrop,{variant:`blur`,children:(0,G.jsx)(Y.Container,{size:`lg`,scroll:`inside`,children:(0,G.jsxs)(Y.Dialog,{children:[(0,G.jsxs)(Y.Header,{className:`items-start justify-between gap-4 px-5 pt-5`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(Y.Heading,{className:`text-section font-semibold`,children:f}),(0,G.jsx)(`p`,{className:`mt-1 text-caption font-normal leading-5 text-muted`,children:t(`accountModelsHint`)}),e?(0,G.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-caption text-muted`,children:[(0,G.jsx)(MH,{provider:e.provider,size:14}),(0,G.jsx)(`span`,{children:p}),(0,G.jsx)(`span`,{className:`text-border`,children:`·`}),(0,G.jsx)(`span`,{className:`mono`,children:e.id})]}):null]}),(0,G.jsx)(Y.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,G.jsx)(ao,{size:16})})]}),(0,G.jsxs)(Y.Body,{className:`px-5 pb-2`,children:[l?(0,G.jsx)(`div`,{className:`mb-3`,children:(0,G.jsx)(QI,{title:t(`accountModelsError`,{msg:l})})}):null,a||s?(0,G.jsxs)(`div`,{className:`space-y-2 py-1`,children:[(0,G.jsx)(Q,{className:`h-14 w-full`}),(0,G.jsx)(Q,{className:`h-14 w-full`}),(0,G.jsx)(Q,{className:`h-14 w-full`})]}):r.length?(0,G.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=aCe(n),a=rH(n),o=iH(n);return(0,G.jsxs)(`li`,{className:`flex items-start gap-3 px-3 py-2.5`,children:[(0,G.jsx)(`span`,{className:`status-dot mt-1.5`,"data-state":n.stale?void 0:`ok`}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`truncate text-body font-medium`,children:n.display_name||n.id}),o?(0,G.jsx)(aC,{size:`sm`,variant:`soft`,color:`success`,children:t(`modelFree`)}):null,a?(0,G.jsx)(`span`,{className:`mono text-caption text-muted`,children:a}):null,n.stale?(0,G.jsx)(aC,{size:`sm`,variant:`soft`,color:`warning`,children:t(`fallback`)}):null]}),(0,G.jsx)(`div`,{className:`mono mt-0.5 truncate text-caption text-muted`,children:n.id}),i?(0,G.jsx)(`div`,{className:`mt-0.5 text-caption text-muted`,children:t(`routedTo`,{model:i})}):null]}),(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5 pt-0.5 text-caption text-muted`,children:[(0,G.jsx)(MH,{provider:r,size:12}),(0,G.jsx)(`span`,{children:r})]})]},n.id)})}):(0,G.jsx)(I7,{className:`min-h-48 rounded-3xl bg-surface-secondary`,icon:(0,G.jsx)(ji,{size:22}),title:t(`accountModelsEmpty`),hint:t(`noModelsYet`)})]}),(0,G.jsxs)(Y.Footer,{className:`justify-between px-5 pb-5`,children:[(0,G.jsx)(`span`,{className:`mono text-caption text-muted`,children:a?t(`refreshing`):t(`shownTotal`,{shown:r.length,total:r.length})}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(J,{size:`sm`,variant:`ghost`,onPress:n,children:t(`close`)}),(0,G.jsxs)(J,{size:`sm`,variant:`secondary`,isPending:s,onPress:()=>void m(!0),children:[(0,G.jsx)(qr,{size:14}),t(s?`refreshing`:`refresh`)]})]})]})]})})})})}var sCe=`w-28`;function _9({label:e,hint:t,labelWidthClass:n=sCe,htmlFor:r,align:i=`center`,children:a}){return(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex gap-3 ${i===`start`?`items-start`:`items-center`}`,children:[(0,G.jsx)(IN,{htmlFor:r,className:`${n} shrink-0 ${i===`start`?`pt-2`:``} text-body font-medium text-foreground`,children:e}),(0,G.jsx)(`div`,{className:`min-w-0 flex-1 [&_[data-slot=input]]:w-full [&_[data-slot=textarea]]:w-full`,children:a})]}),t?(0,G.jsx)(`p`,{className:`mt-1.5 pl-[7.75rem] text-caption leading-5 text-muted`,children:t}):null]})}function cCe({catalog:e,selected:t,onChange:n,isDisabled:r,t:i}){let[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(t),l=(0,v.useMemo)(()=>new Set(t),[t]),u=(0,v.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]),d=(0,v.useMemo)(()=>{if(!e)return[];let n=new Set(e);return t.filter(e=>!n.has(e))},[e,t]),f=e?.length??0,p=t.filter(e=>!d.includes(e)).length;function m(e){o(e),c(t)}function h(e,r){n(r?[...t,e]:t.filter(t=>t!==e))}function g(){let e=new Set(t);u.forEach(t=>e.add(t)),n([...e])}function _(){let e=new Set(u);n(t.filter(t=>!e.has(t)))}return(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(PN,{"aria-label":i(`modelPickerSearch`),value:a,onChange:m,isDisabled:r,className:`min-w-0 flex-1 basis-48`,children:(0,G.jsxs)(PN.Group,{children:[(0,G.jsx)(PN.SearchIcon,{}),(0,G.jsx)(PN.Input,{placeholder:i(`modelPickerSearch`)}),(0,G.jsx)(PN.ClearButton,{})]})}),(0,G.jsx)(`span`,{className:`mono shrink-0 text-caption text-muted`,children:i(`modelPickerCount`,{selected:p,total:f})}),(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,G.jsxs)(J,{size:`sm`,variant:`ghost`,isDisabled:r||u.length===0,onPress:g,children:[(0,G.jsx)(xi,{size:14}),i(`modelPickerSelectAll`)]}),(0,G.jsxs)(J,{size:`sm`,variant:`ghost`,isDisabled:r||t.length===0,onPress:_,children:[(0,G.jsx)(La,{size:14}),i(`modelPickerClear`)]})]})]}),(0,G.jsxs)(`div`,{className:`max-h-[300px] overflow-y-auto overscroll-contain rounded-lg bg-surface-secondary p-1`,children:[e===null?(0,G.jsx)(`p`,{className:`px-2.5 py-2 text-caption text-muted`,children:i(`refreshing`)}):null,d.map(e=>(0,G.jsxs)(`div`,{className:`flex items-center gap-2.5 rounded-md px-2.5 py-1.5`,children:[(0,G.jsx)(`span`,{className:`mono min-w-0 flex-1 truncate text-body text-muted line-through`,children:e}),(0,G.jsx)(`span`,{className:`shrink-0 text-caption text-warning`,children:i(`modelPickerOffline`)}),(0,G.jsx)(J,{isIconOnly:!0,size:`sm`,variant:`ghost`,isDisabled:r,"aria-label":i(`modelPickerRemove`,{model:e}),onPress:()=>h(e,!1),children:(0,G.jsx)(ao,{size:14})})]},`offline-${e}`)),u.map(e=>(0,G.jsx)(tC,{isSelected:l.has(e),isDisabled:r,onChange:t=>h(e,t),className:`flex w-full cursor-pointer rounded-md px-2.5 py-1.5 transition-colors hover:bg-default`,children:(0,G.jsxs)(tC.Content,{className:`flex min-w-0 flex-1 items-center gap-2.5`,children:[(0,G.jsx)(tC.Control,{children:(0,G.jsx)(tC.Indicator,{})}),(0,G.jsx)(`span`,{className:`mono min-w-0 truncate text-body text-foreground`,children:e})]})},e)),e!==null&&u.length===0?(0,G.jsx)(`p`,{className:`px-2.5 py-2 text-caption text-muted`,children:i(f===0?`noAccountModels`:`modelPickerNoMatch`)}):null]})]})}function lCe(e){let[t,n]=(0,v.useState)(e);e&&!t&&n(!0);let r=(0,v.useRef)(null),i=(0,v.useRef)(null),a=(0,v.useRef)(e);return(0,v.useLayoutEffect)(()=>{let t=r.current,o=i.current;if(!t||!o)return;if(a.current){a.current=!1;return}Z.killTweensOf([t,o]);let s=t.getBoundingClientRect().height;if(e){Z.set(t,{overflow:`hidden`});let e=t.scrollHeight;Z.fromTo(t,{height:s===e?0:s},{height:e,duration:MV(kV.base),ease:AV.out,onComplete:()=>Z.set(t,{clearProps:`height,overflow`})}),Z.fromTo(o,{autoAlpha:0,y:-6},{autoAlpha:1,y:0,duration:MV(kV.base),ease:AV.out})}else Z.set(t,{overflow:`hidden`,height:s}),Z.to(o,{autoAlpha:0,y:-4,duration:MV(kV.fast),ease:AV.inOut}),Z.to(t,{height:0,duration:MV(kV.fast+.04),ease:AV.inOut,onComplete:()=>n(!1)});return()=>{Z.killTweensOf([t,o])}},[e,t]),{mounted:t,outerRef:r,innerRef:i}}function uCe({account:e,checkinDefaultTime:t,checkinTimezone:n,busy:r,t:i,onClose:a,onSave:o}){let[s,c]=(0,v.useState)(e?.name||``),[l,u]=(0,v.useState)(e?.max_inflight??4),[d,f]=(0,v.useState)(e?.priority??50),[p,m]=(0,v.useState)(e?.proxy_url||``),[h,g]=(0,v.useState)(!!e?.drop_system_prompt),[_,y]=(0,v.useState)(Object.entries(e?.model_aliases||{}).map(([e,t])=>({alias:e,model:t}))),[b,x]=(0,v.useState)({alias:``,model:``}),[S,C]=(0,v.useState)(!!e?.models_restricted),[w,T]=(0,v.useState)(e?.enabled_models||[]),{mounted:E,outerRef:D,innerRef:O}=lCe(S),[k,A]=(0,v.useState)(null),[j,M]=(0,v.useState)(!e?.checkin_time),[N,P]=(0,v.useState)(e?.checkin_time||null),[F,I]=(0,v.useState)(``);(0,v.useEffect)(()=>{if(!e?.id)return;let t=!1;return VI(e.id).then(e=>{t||A(e.data||[])}).catch(()=>{t||A([])}),()=>{t=!0}},[e?.id]);let L=i(`editAccountTitle`,{name:e?.name||e?.id||``}),R=e?jH(e.provider,e.region,i):``;async function z(n){n?.preventDefault();let r=s.trim();if(!r){I(i(`accountNameRequired`));return}if(!Number.isInteger(l)||l<1||l>32){I(i(`maxInflightInvalid`));return}if(!Number.isInteger(d)||d<1||d>100){I(i(`priorityInvalid`));return}if(t!==void 0&&!j&&!/^([01]\d|2[0-3]):[0-5]\d$/.test(N??t)){I(i(`checkinTimeInvalid`));return}I(``);try{await o({name:r,max_inflight:l,priority:d,proxy_url:p.trim(),checkin_time:t===void 0?void 0:j?``:N??t,drop_system_prompt:e?.provider===`workbuddy`||e?.provider===`trae`?h:void 0,model_aliases:Object.fromEntries(_.filter(e=>e.alias.trim()&&e.model.trim()).map(e=>[e.alias.trim(),e.model.trim()])),enabled_models:S?w:[],set_model_routing:!0}),a()}catch(e){I(e instanceof Error?e.message:String(e))}}return(0,G.jsx)(Y.Root,{isOpen:!!e,onOpenChange:e=>{!e&&!r&&a()},children:(0,G.jsx)(Y.Backdrop,{variant:`blur`,children:(0,G.jsx)(Y.Container,{placement:`center`,size:`lg`,scroll:`inside`,children:(0,G.jsxs)(Y.Dialog,{className:`w-full sm:w-[42rem] sm:max-w-[calc(100vw-2rem)]`,children:[(0,G.jsxs)(Y.Header,{className:`items-start justify-between gap-4 px-6 pt-6`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(Y.Heading,{className:`text-section font-semibold`,children:L}),(0,G.jsx)(`p`,{className:`mt-1.5 text-body font-normal leading-6 text-muted`,children:i(`editAccountHint`)}),e?(0,G.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(aC,{size:`sm`,variant:`soft`,children:(0,G.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(MH,{provider:e.provider,size:14}),(0,G.jsx)(`span`,{children:R})]})}),(0,G.jsx)(`span`,{className:`mono text-caption text-muted`,children:e.id})]}):null]}),(0,G.jsx)(Y.CloseTrigger,{isDisabled:r,"aria-label":i(`close`),className:`grid size-9 shrink-0 place-items-center rounded-lg text-muted hover:bg-surface-secondary`,children:(0,G.jsx)(ao,{size:18})})]}),(0,G.jsxs)(Y.Body,{className:`px-6 pb-2 pt-1`,children:[F?(0,G.jsxs)(tF,{status:`danger`,className:`mb-4`,children:[(0,G.jsx)(tF.Indicator,{}),(0,G.jsx)(tF.Content,{children:(0,G.jsx)(tF.Title,{children:F})})]}):null,(0,G.jsxs)(QP,{className:`space-y-4`,onSubmit:e=>void z(e),children:[(0,G.jsx)(_9,{label:i(`accountName`),children:(0,G.jsx)(UM,{value:s,onChange:e=>c(e.target.value),placeholder:i(`wizardNamePh`),"aria-label":i(`accountName`),disabled:r,autoFocus:!0})}),(0,G.jsx)(_9,{label:i(`maxInflight`),hint:i(`maxInflightHint`),children:(0,G.jsx)(hF,{value:l,onChange:e=>u(e??4),minValue:1,maxValue:32,isDisabled:r,isRequired:!0,children:(0,G.jsxs)(hF.Group,{children:[(0,G.jsx)(hF.DecrementButton,{}),(0,G.jsx)(hF.Input,{"aria-label":i(`maxInflight`)}),(0,G.jsx)(hF.IncrementButton,{})]})})}),(0,G.jsx)(_9,{label:i(`priority`),hint:i(`priorityHint`),children:(0,G.jsx)(hF,{value:d,onChange:e=>f(e??50),minValue:1,maxValue:100,isDisabled:r,isRequired:!0,children:(0,G.jsxs)(hF.Group,{children:[(0,G.jsx)(hF.DecrementButton,{}),(0,G.jsx)(hF.Input,{"aria-label":i(`priority`)}),(0,G.jsx)(hF.IncrementButton,{})]})})}),(0,G.jsx)(_9,{label:i(`proxyUrl`),hint:i(`proxyUrlHint`),children:(0,G.jsx)(UM,{value:p,onChange:e=>m(e.target.value),placeholder:i(`proxyUrlPlaceholder`),"aria-label":i(`proxyUrl`),disabled:r})}),e?.provider===`workbuddy`||e?.provider===`trae`?(0,G.jsx)(_9,{label:i(`dropSystemPrompt`),hint:i(e?.provider===`trae`?`dropSystemPromptTraeHint`:`dropSystemPromptHint`),children:(0,G.jsx)(F7,{isSelected:h,isDisabled:r,ariaLabel:i(`dropSystemPrompt`),onChange:g})}):null,(0,G.jsx)(_9,{align:`start`,label:i(`accountModelAliases`),hint:i(`accountModelAliasesHint`),children:(0,G.jsxs)(`div`,{className:`space-y-2`,children:[_.map(e=>(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,G.jsxs)(`span`,{className:`mono min-w-0 truncate text-body`,children:[e.alias,` → `,e.model]}),(0,G.jsx)(J,{size:`sm`,variant:`ghost`,isDisabled:r,onPress:()=>y(t=>t.filter(t=>t.alias!==e.alias)),children:i(`modelAliasRemove`)})]},e.alias)),(0,G.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-[1fr_1fr_auto]`,children:[(0,G.jsx)(UM,{"aria-label":i(`modelAliasName`),value:b.alias,onChange:e=>x(t=>({...t,alias:e.target.value})),placeholder:i(`modelAliasPlaceholder`),disabled:r}),(0,G.jsx)(UM,{"aria-label":i(`modelAliasTarget`),value:b.model,onChange:e=>x(t=>({...t,model:e.target.value})),placeholder:i(`accountModelAliasTargetPlaceholder`),disabled:r}),(0,G.jsx)(J,{size:`sm`,variant:`secondary`,isDisabled:r||!b.alias.trim()||!b.model.trim(),onPress:()=>{y(e=>[...e.filter(e=>e.alias!==b.alias.trim()),{alias:b.alias.trim(),model:b.model.trim()}]),x({alias:``,model:``})},children:i(`modelAliasAdd`)})]})]})}),(0,G.jsxs)(`section`,{className:`space-y-3 pt-1`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`div`,{className:`text-body font-medium text-foreground`,children:i(`enabledModels`)}),(0,G.jsx)(`p`,{className:`mt-0.5 text-caption leading-5 text-muted`,children:i(`enabledModelsHint`)})]}),(0,G.jsx)(F7,{isSelected:S,isDisabled:r,ariaLabel:i(`restrictModels`),label:i(S?`restrictModels`:`allModels`),onChange:C})]}),E?(0,G.jsx)(`div`,{ref:D,children:(0,G.jsx)(`div`,{ref:O,children:(0,G.jsx)(cCe,{catalog:k?k.map(e=>e.id):null,selected:w,onChange:T,isDisabled:r,t:i})})}):null]}),t===void 0?null:(0,G.jsx)(_9,{label:i(`autoCheckinTime`),hint:i(`checkinScheduleHint`),children:(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsx)(F7,{isSelected:j,isDisabled:r,onChange:M,ariaLabel:i(`checkinInherit`),label:i(`checkinInherit`)}),(0,G.jsxs)(`p`,{className:`text-caption text-muted`,children:[i(`checkinDefaultValue`,{time:t}),` · `,(0,G.jsx)(`span`,{className:`mono`,children:n})]}),j?null:(0,G.jsx)(UM,{type:`time`,value:N??t,onChange:e=>P(e.target.value),"aria-label":i(`autoCheckinTime`),disabled:r,required:!0})]})})]})]}),(0,G.jsxs)(Y.Footer,{className:`justify-end gap-2 px-6 pb-6`,children:[(0,G.jsx)(J,{variant:`ghost`,isDisabled:r,onPress:a,children:i(`cancel`)}),(0,G.jsx)(J,{isPending:r,onPress:()=>void z(),children:i(`save`)})]})]})})})})}var dCe={1:`grid-cols-1`,2:`grid-cols-1 sm:grid-cols-2`,3:`grid-cols-1 sm:grid-cols-3`};function v9({options:e,value:t,onChange:n,ariaLabel:r,columns:i=2,className:a=``}){let o=(0,v.useRef)(null);return(0,v.useLayoutEffect)(()=>{let e=o.current;if(!e)return;let t=Z.context(()=>{let e=Z.matchMedia();e.add(`(prefers-reduced-motion: reduce)`,()=>{Z.set(`[data-option-tile]`,{autoAlpha:1,y:0})}),e.add(`(prefers-reduced-motion: no-preference)`,()=>{Z.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,G.jsx)(`div`,{ref:o,role:`radiogroup`,"aria-label":r,className:`grid gap-3 ${dCe[i]} ${a}`.trim(),children:e.map(e=>{let r=e.value===t;return(0,G.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,G.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,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-body font-medium leading-5 text-foreground`,children:e.label})]},e.value)})})}var y9=new Set([`qoder-global`,`qoder-cn`,`workbuddy-global`,`workbuddy-cn`,`trae-cn`]),fCe=[`qoder-global`,`qoder-cn`,`workbuddy-global`,`workbuddy-cn`,`trae-cn`];function pCe(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 b9(e,t){return!t||`${e.label} ${e.subtitle||``} ${e.hint||``} ${e.provider} ${e.id}`.toLowerCase().includes(t)}function mCe({ariaLabel:e}){return(0,G.jsx)(`div`,{className:`space-y-8`,"aria-busy":`true`,"aria-label":e,children:Array.from({length:2},(e,t)=>(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(UA,{className:`h-3 w-24 rounded-lg`}),(0,G.jsx)(UA,{className:`h-3 w-40 rounded-lg`})]}),(0,G.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:Array.from({length:t===0?5:6},(e,t)=>(0,G.jsxs)(`div`,{className:`card flex flex-row items-center gap-3.5 rounded-xl bg-surface px-4 py-3.5`,children:[(0,G.jsx)(UA,{className:`size-10 shrink-0 rounded-lg`}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1.5`,children:[(0,G.jsx)(UA,{className:`h-3.5 w-28 rounded-lg`}),(0,G.jsx)(UA,{className:`h-3 w-36 rounded-lg`})]})]},t))})]},t))})}function hCe({tile:e,disabled:t,onSelect:n}){return(0,G.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,G.jsx)(`span`,{className:`grid size-9 shrink-0 place-items-center rounded-lg text-foreground [&_svg]:size-[18px]`,children:(0,G.jsx)(MH,{provider:e.provider,size:18})}),(0,G.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`span`,{className:`block truncate text-body font-medium leading-5 text-foreground`,children:e.label}),e.subtitle?(0,G.jsx)(`span`,{className:`mt-0.5 block truncate text-caption leading-4 text-muted`,children:e.subtitle}):null]})]})}function gCe({title:e,subtitle:t,tiles:n,disabled:r,onSelect:i}){return n.length?(0,G.jsxs)(`section`,{className:`space-y-3.5`,children:[(0,G.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,G.jsx)(`h3`,{className:`text-[10px] font-semibold tracking-[0.12em] uppercase text-muted`,children:e}),t?(0,G.jsx)(`p`,{className:`text-caption leading-5 text-muted`,children:t}):null]}),(0,G.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:n.map(e=>(0,G.jsx)(hCe,{tile:e,disabled:r,onSelect:i},e.id))})]}):null}function _Ce({options:e,onSelect:t,disabled:n,empty:r,ariaLabel:i}){let{t:a}=EI(),[o,s]=(0,v.useState)(``),c=o.trim().toLowerCase(),l=(0,v.useMemo)(()=>{let t=pCe(e.filter(e=>y9.has(e.id)),fCe),n=e.filter(e=>!y9.has(e.id)).sort((e,t)=>e.label.localeCompare(t.label));return[{id:`subscriptions`,titleKey:`providerGroupSubscriptions`,subtitleKey:`providerGroupSubscriptionsHint`,tiles:t.filter(e=>b9(e,c))},{id:`experimental`,titleKey:`providerGroupExperimental`,subtitleKey:`providerGroupExperimentalHint`,tiles:n.filter(e=>b9(e,c))}]},[c,e]),u=l.reduce((e,t)=>e+t.tiles.length,0);return(0,G.jsxs)(`div`,{className:`space-y-8`,role:`listbox`,"aria-label":i,children:[(0,G.jsx)(B7,{value:o,onChange:s,placeholder:a(`providerFindPlaceholder`),ariaLabel:a(`providerFindPlaceholder`),className:`max-w-sm`}),u===0?r||(0,G.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,G.jsx)(gCe,{title:a(e.titleKey),subtitle:a(e.subtitleKey),tiles:e.tiles,disabled:n,onSelect:t},e.id))]})}function x9(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 S9(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 vCe(e,t){return GI(x9(e,t))}var C9={global:`Global`,cn:`CN`},yCe={"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`,"meta-global":`accountTypeMetaGlobal`},bCe={"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`,"meta-global":`accountTypeMetaGlobalHint`};async function xCe(){let e=(await UI().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 w9(e,t){let n=yCe[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||C9[e.region]||``,i=e.descriptor.regions.length>1&&r?` ${r}`:``;return`${e.descriptor.label}${i}`.trim()}function T9(e,t){if(!e)return``;let n=bCe[e.id];if(!n)return``;let r=t(n);return r===n?``:r}function SCe({phase:e,busy:t,tab:n,forTab:r}){return e===`done`?(0,G.jsx)(yi,{size:16,className:`text-success`}):t&&n===r?(0,G.jsx)(PV,{size:16,loading:!0}):null}var CCe=90,wCe=2e3;function TCe({isOpen:e,onClose:t,onAdded:n}){let{t:r}=EI(),[i,a]=(0,v.useState)(`method`),[o,s]=(0,v.useState)(`browser`),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)([]),[f,p]=(0,v.useState)(!1),[m,h]=(0,v.useState)(!1),[g,_]=(0,v.useState)(``),[y,b]=(0,v.useState)(4),[x,S]=(0,v.useState)(50),[C,w]=(0,v.useState)(!0),[T,E]=(0,v.useState)(``),[D,O]=(0,v.useState)(``),[k,A]=(0,v.useState)(``),[j,M]=(0,v.useState)(`payg`),[N,P]=(0,v.useState)(``),[F,I]=(0,v.useState)(``),[L,R]=(0,v.useState)(``),[z,B]=(0,v.useState)(`idle`),[V,H]=(0,v.useState)(``),[ee,te]=(0,v.useState)(``),[ne,re]=(0,v.useState)(!1),[ie,ae]=(0,v.useState)(``),[oe,se]=(0,v.useState)(`cli`),ce=(0,v.useRef)(null),le=(0,v.useRef)(null),ue=(0,v.useRef)(null),de=(0,v.useRef)(``),fe=(0,v.useRef)(null),pe=(0,v.useRef)(null);function me(){fe.current!==null&&(window.clearTimeout(fe.current),fe.current=null)}(0,v.useEffect)(()=>()=>me(),[]),(0,v.useEffect)(()=>{if(!e)return;let t=!1;return p(!0),d([]),l(``),xCe().then(e=>{t||(d(e),l(``),s(`browser`))}).finally(()=>{t||p(!1)}),()=>{t=!0}},[e]);let he=u.find(e=>e.id===c),ge=!f&&u.length>0,_e=he?.descriptor.capabilities?.pat_login!==!1,ve=he?.descriptor.capabilities?.import_export!==!1,ye=he?.descriptor.capabilities?.browser_login!==!1,be=he?.provider===`workbuddy`||he?.provider===`trae`,xe=he?.provider===`trae`||he?.provider===`devin`||he?.provider===`codex`,Se=z===`busy`||z===`polling`,Ce=!!de.current||Se,we=z===`done`,Te=T9(he,r);(0,v.useEffect)(()=>{o===`pat`&&!_e&&s(`browser`),o===`import`&&!ve&&s(`browser`)},[ve,_e,o]),(0,v.useEffect)(()=>{ye||(_e?s(`pat`):ve&&s(`import`))},[ye,ve,_e]);function Ee(){return!Number.isInteger(y)||y<1||y>32?4:y}function De(){return!Number.isInteger(x)||x<1||x>100?50:x}function Oe(){return{max_inflight:Ee(),priority:De(),drop_system_prompt:be?C:he?.provider!==`kimi`,proxy_url:T.trim()}}function ke(){me(),a(`method`),s(`browser`),l(``),d([]),p(!1),_(``),b(4),S(50),w(!0),E(``),O(``),A(``),M(`payg`),P(``),I(``),R(``),h(!1),B(`idle`),H(``),te(``),re(!1),ae(``),se(`cli`),de.current=``}function Ae(){Se||(ke(),t())}function je(){ke(),t()}(0,v.useLayoutEffect)(()=>{let t=ce.current;if(e||(ue.current=null),!t||!e)return;let n=Z.context(()=>{let e=Z.matchMedia();e.add(`(prefers-reduced-motion: reduce)`,()=>{Z.set(t,{autoAlpha:1,x:0,y:0})}),e.add(`(prefers-reduced-motion: no-preference)`,()=>{let e=ue.current,n=e&&e!==i?i===`login`?1:-1:0;Z.fromTo(t,{autoAlpha:0,x:20*n,y:n?0:12},{autoAlpha:1,x:0,y:0,duration:kV.slow,ease:AV.out,overwrite:!0}),n&&le.current&&Z.fromTo(le.current,{autoAlpha:0,y:6},{autoAlpha:1,y:0,duration:kV.base,ease:AV.out,overwrite:!0})})},t);return ue.current=i,()=>n.revert()},[e,i]);function Me(e){if(Se||!ge)return;let t=u.find(t=>t.id===e);l(e),s(t?.provider===`zhipu`?`pat`:`browser`),w(t?.provider!==`trae`&&t?.provider!==`kimi`),H(``),a(`login`)}async function Ne(){if(de.current)return de.current;if(!he)throw Error(r(`accountTypeHint`));let e=Oe(),t=await hoe(g.trim()||r(`account`),he.provider,he.region,e),n=t?.id||t?.data?.id;if(!n)throw Error(`create account returned no id`);return de.current=n,n}async function Pe(){H(``),te(``);try{B(`busy`);let e=await Ne();H(r(`wizardStartingSession`)),B(`polling`);let t=await FI(e,he?.provider===`codex`?oe:void 0);t.authUrl&&te(t.authUrl),H(r(`wizardWaitingBrowser`));for(let t=0;t{fe.current=window.setTimeout(e,wCe)});let n=(await II(e)).login||{};if(n.message&&H(n.message),n.status===`ok`)break;if(n.status===`error`)throw Error(n.message||`login failed`);if(t===89)throw Error(r(`wizardLoginTimeout`))}B(`done`),H(r(`wizardAccountReady`)),n(),window.setTimeout(je,900)}catch(e){B(`idle`),H(e instanceof Error?e.message:String(e))}}async function Fe(){let e=ie.trim();if(!e){H(r(`wizardCallbackPh`));return}try{B(`busy`);let t=await Ne();me(),await LI(t,e),B(`done`),H(r(`wizardAccountReady`)),n(),window.setTimeout(je,900)}catch(e){B(`polling`),H(e instanceof Error?e.message:String(e))}}async function Ie(){let e=N.trim();if(!e){H(r(`zhipuKeyRequired`));return}if(!he){H(r(`accountTypeHint`));return}H(``);try{B(`busy`);let t=Oe();await GI({format:`zhipu-key-v1`,api_key:e,mode:j,organization:j===`coding`?F.trim():``,project:j===`coding`?L.trim():``,name:g.trim()||r(`accountTypeZhipuCN`),enabled:!0,provider:he.provider,region:he.region,max_inflight:t.max_inflight,priority:t.priority,drop_system_prompt:t.drop_system_prompt,proxy_url:t.proxy_url}),B(`done`),H(r(`wizardAccountReady`)),n(),window.setTimeout(je,700)}catch(e){B(`idle`),H(e instanceof Error?e.message:String(e))}}async function Le(){let e=D.trim();if(!e){H(r(`pastePatFirst`));return}H(``);try{B(`busy`);let t=await Ne();H(r(`wizardStartingSession`)),await RI(e,t),B(`done`),H(r(`patDone`)),n(),window.setTimeout(je,700)}catch(e){B(`idle`),H(e instanceof Error?e.message:String(e))}}async function Re(){H(``);let e;try{e=JSON.parse(k)}catch{H(r(`wizardBadJson`));return}if(!e||typeof e!=`object`){H(r(`wizardBadJson`));return}if(!he){H(r(`accountTypeHint`));return}if(he.provider===`qoder`&&(typeof e.user_blob!=`string`||typeof e.machine_id!=`string`)){H(r(`wizardBadJson`));return}let t=Oe(),i;he.provider===`workbuddy`?i=x9(e,{region:he.region===`global`?`global`:`cn`,name:g.trim()||void 0,enabled:!0,max_inflight:t.max_inflight,priority:t.priority,drop_system_prompt:t.drop_system_prompt,proxy_url:t.proxy_url}):(e.format||(he.descriptor.id===`trae`?e.format=`trae-oauth-v1`:he.descriptor.id===`devin`?e.format=`devin-session-v1`:he.descriptor.id===`command`?e.format=`command-key-v1`:he.descriptor.id===`qwenwork`?e.format=`qwenwork-oauth-v1`:e.format=`qoder-native-v1`),i={...e,name:g.trim()||e.name,enabled:!0,provider:he.provider,region:he.region,max_inflight:t.max_inflight,priority:t.priority,drop_system_prompt:t.drop_system_prompt});try{B(`busy`);let{failed:e,message:t}=S9(await GI(i),r);B(`done`),H(t),n(),window.setTimeout(je,e>0?1600:700)}catch(e){B(`idle`),H(e instanceof Error?e.message:String(e))}}function ze(){pe.current?.click()}function Be(e){let t=e.target.files?.[0];if(!t)return;let n=new FileReader;n.onload=()=>A(String(n.result||``)),n.readAsText(t),e.target.value=``}let Ve=e=>Se&&o===e,He=he?.provider===`zhipu`,Ue=[he?.descriptor.capabilities?.browser_login===!1?null:{value:`browser`,label:r(`tabBrowser`)},_e?{value:`pat`,label:r(`tabPat`)}:null,ve?{value:`import`,label:r(`tabImport`)}:null].filter(Boolean),We=r(o===`browser`?he?.provider===`codex`?`wizardCodexBrowserLead`:`wizardBrowserLead`:o===`pat`?he?.provider===`command`?`wizardPatLeadCommand`:he?.region===`cn`&&he?.provider===`qoder`?`wizardPatLeadCN`:`wizardPatLead`:`wizardImportLead`);return(0,G.jsx)(Y.Root,{isOpen:e,onOpenChange:e=>{e||Ae()},children:(0,G.jsx)(Y.Backdrop,{variant:`blur`,isDismissable:!Se,children:(0,G.jsx)(Y.Container,{size:`lg`,scroll:`inside`,children:(0,G.jsxs)(Y.Dialog,{className:`w-full sm:w-[36rem] sm:max-w-[calc(100vw-2rem)] sm:min-h-[36rem]`,children:[(0,G.jsxs)(Y.Header,{className:`relative items-center justify-center px-12 pt-5 text-center`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(Y.Heading,{className:`text-section font-semibold`,children:r(`addAccountTitle`)}),(0,G.jsx)(`p`,{ref:le,className:`mt-1 text-caption font-normal leading-5 text-muted`,children:i===`method`?r(`addAccountDesc`):Te||r(`addAccountDesc`)})]}),(0,G.jsx)(Y.CloseTrigger,{"aria-label":r(`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,G.jsx)(ao,{size:16})})]}),(0,G.jsx)(Y.Body,{className:i===`method`?`px-8 pb-5 sm:px-10`:`px-6 pb-2`,children:(0,G.jsx)(`div`,{ref:ce,children:i===`method`?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`section`,{className:`space-y-2.5`,children:f?(0,G.jsx)(mCe,{ariaLabel:r(`accountType`)}):ge?(0,G.jsx)(_Ce,{ariaLabel:r(`accountType`),options:u.map(e=>{let t=e.descriptor.regions.find(t=>t.id===e.region)?.label||C9[e.region]||``;return{id:e.id,provider:e.provider,label:w9(e,r),subtitle:t,hint:T9(e,r)}}),onSelect:Me,disabled:Ce}):(0,G.jsx)(`p`,{className:`rounded-lg bg-surface-secondary/45 px-3.5 py-3 text-caption leading-5 text-muted`,children:r(`accountTypeHint`)})}),(0,G.jsx)(`div`,{className:`mt-4 text-center`,children:(0,G.jsx)(e9,{className:`text-xs`})})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`card flex flex-row items-center gap-3 rounded-xl bg-surface px-3 py-2.5`,children:[(0,G.jsx)(`span`,{className:`shrink-0`,children:(0,G.jsx)(MH,{provider:he?.provider,size:18})}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`div`,{className:`truncate text-body font-medium text-foreground`,children:he?w9(he,r):r(`accountType`)}),(0,G.jsx)(`div`,{className:`truncate text-caption text-muted`,children:Te})]}),(0,G.jsxs)(J,{size:`sm`,variant:`ghost`,onPress:()=>a(`method`),isDisabled:Se||!!de.current,children:[(0,G.jsx)(li,{size:12}),r(`wizardBack`)]})]}),(0,G.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,G.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,G.jsx)(IN,{className:`text-body font-medium text-muted`,children:r(`accountName`)}),(0,G.jsx)(UM,{fullWidth:!0,value:g,onChange:e=>_(e.target.value),"aria-label":r(`accountName`),disabled:Ce,autoFocus:!0})]}),(0,G.jsxs)(`button`,{type:`button`,onClick:()=>h(e=>!e),"aria-expanded":m,className:`inline-flex items-center gap-1 text-caption font-medium text-muted transition-colors hover:text-foreground`,children:[(0,G.jsx)(di,{size:12,className:`transition-transform duration-200 ${m?`rotate-90`:``}`}),r(`wizardAdvanced`)]}),m?(0,G.jsxs)(`div`,{className:`card gap-3 rounded-xl bg-surface px-3.5 py-3.5`,children:[(0,G.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:[(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(IN,{className:`text-body font-medium text-muted`,children:r(`maxInflight`)}),(0,G.jsx)(hF,{value:y,onChange:e=>b(e??4),minValue:1,maxValue:32,isDisabled:Ce,isRequired:!0,children:(0,G.jsxs)(hF.Group,{className:`w-full`,children:[(0,G.jsx)(hF.DecrementButton,{}),(0,G.jsx)(hF.Input,{"aria-label":r(`maxInflight`)}),(0,G.jsx)(hF.IncrementButton,{})]})}),(0,G.jsx)(RN,{className:`text-caption leading-5 text-muted`,children:r(`maxInflightHint`)})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(IN,{className:`text-body font-medium text-muted`,children:r(`priority`)}),(0,G.jsx)(hF,{value:x,onChange:e=>S(e??50),minValue:1,maxValue:100,isDisabled:Ce,isRequired:!0,children:(0,G.jsxs)(hF.Group,{className:`w-full`,children:[(0,G.jsx)(hF.DecrementButton,{}),(0,G.jsx)(hF.Input,{"aria-label":r(`priority`)}),(0,G.jsx)(hF.IncrementButton,{})]})}),(0,G.jsx)(RN,{className:`text-caption leading-5 text-muted`,children:r(`priorityHint`)})]})]}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,G.jsx)(IN,{className:`text-body font-medium text-muted`,children:r(`proxyUrl`)}),(0,G.jsx)(UM,{fullWidth:!0,value:T,onChange:e=>E(e.target.value),placeholder:r(`proxyUrlPlaceholder`),"aria-label":r(`proxyUrl`),disabled:Ce}),(0,G.jsx)(RN,{className:`text-caption leading-5 text-muted`,children:r(`proxyUrlHint`)})]}),be?(0,G.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,G.jsx)(IN,{className:`text-body font-medium text-muted`,children:r(`dropSystemPrompt`)}),(0,G.jsx)(RN,{className:`text-caption leading-5 text-muted`,children:r(he?.provider===`trae`?`dropSystemPromptTraeHint`:`dropSystemPromptCreateHint`)}),(0,G.jsx)(F7,{isSelected:C,isDisabled:Ce,ariaLabel:r(`dropSystemPrompt`),onChange:w})]}):null]}):null]}),He?(0,G.jsxs)(`div`,{className:`mt-4 flex flex-col gap-4`,children:[(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(`span`,{className:`text-body font-medium text-muted`,children:r(`zhipuAccountMode`)}),(0,G.jsx)(v9,{ariaLabel:r(`zhipuAccountMode`),columns:2,value:j,onChange:e=>{Se||M(e)},options:[{value:`payg`,label:r(`zhipuModePayg`),hint:r(`zhipuModePaygHint`),disabled:Se},{value:`coding`,label:r(`zhipuModeCoding`),hint:r(`zhipuModeCodingHint`),disabled:Se}]})]}),(0,G.jsx)(_9,{label:r(`zhipuApiKey`),children:(0,G.jsx)(UM,{type:`password`,value:N,onChange:e=>P(e.target.value),placeholder:r(`zhipuApiKeyPh`),"aria-label":r(`zhipuApiKey`),disabled:Se})}),j===`coding`?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(_9,{label:r(`zhipuOrganization`),children:(0,G.jsx)(UM,{value:F,onChange:e=>I(e.target.value),placeholder:r(`zhipuOrganizationPh`),"aria-label":r(`zhipuOrganization`),disabled:Se})}),(0,G.jsx)(_9,{label:r(`zhipuProject`),children:(0,G.jsx)(UM,{value:L,onChange:e=>R(e.target.value),placeholder:r(`zhipuProjectPh`),"aria-label":r(`zhipuProject`),disabled:Se})})]}):null,V?(0,G.jsxs)(`p`,{className:`flex items-center gap-2 rounded-lg bg-surface-secondary px-3 py-2 text-caption`,children:[we?(0,G.jsx)(yi,{size:14,className:`shrink-0 text-success`}):null,(0,G.jsx)(`span`,{className:we?`font-medium text-foreground`:`text-muted`,children:V})]}):null]}):null,He?null:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(pH,{className:`mt-3`,value:o,onChange:e=>{!Se&&e!==o&&(s(e),H(``),te(``),re(!1))},ariaLabel:r(`authentication`),options:Ue.map(e=>({id:e.value,label:e.label}))}),(0,G.jsx)(`p`,{className:`mt-2 min-h-5 text-caption leading-5 text-muted`,children:We}),(0,G.jsx)(`div`,{className:`mt-3 flex flex-col gap-4`,children:o===`browser`?(0,G.jsxs)(G.Fragment,{children:[he?.provider===`codex`?(0,G.jsx)(v9,{ariaLabel:r(`codexLoginMethod`),columns:2,value:oe,onChange:e=>{Se||se(e)},options:[{value:`cli`,label:r(`codexLoginCli`),hint:r(`codexLoginCliHint`),disabled:Se||!!de.current},{value:`chatgpt`,label:r(`codexLoginChatGPT`),hint:r(`codexLoginChatGPTHint`),disabled:Se||!!de.current}]}):null,ee?(0,G.jsxs)(`div`,{className:`card rounded-xl bg-surface px-3 py-2.5`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-caption`,children:[(0,G.jsx)(SCe,{phase:z,busy:Se,tab:o,forTab:`browser`}),(0,G.jsx)(`span`,{className:`text-muted`,children:V||r(`loginOpenMsg`)})]}),(0,G.jsx)(`code`,{className:`mono mt-2 block break-all text-caption leading-5 text-foreground`,children:ee}),(0,G.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:[(0,G.jsxs)(J,{size:`sm`,variant:`secondary`,onPress:()=>window.open(ee,`_blank`,`noopener,noreferrer`),children:[(0,G.jsx)(Zr,{size:14}),r(`openAuthUrl`)]}),(0,G.jsxs)(J,{size:`sm`,variant:`ghost`,onPress:()=>{Z7(ee).then(e=>{e&&(re(!0),window.setTimeout(()=>re(!1),1100))})},children:[(0,G.jsx)(X7,{copied:ne}),r(ne?`copied`:`copy`)]})]})]}):null,V&&!ee?(0,G.jsxs)(`p`,{className:`flex items-center gap-2 rounded-lg bg-surface-secondary px-3 py-2 text-caption`,children:[we?(0,G.jsx)(yi,{size:14,className:`shrink-0 text-success`}):null,(0,G.jsx)(`span`,{className:we?`font-medium text-foreground`:`text-muted`,children:V})]}):null,xe?(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(`p`,{className:`text-caption leading-4 text-muted`,children:r(`wizardCallbackLead`)}),(0,G.jsx)(JM,{className:`h-28 w-full resize-none font-mono text-caption leading-5`,value:ie,onChange:e=>ae(e.target.value),placeholder:r(`wizardCallbackPh`),"aria-label":r(`wizardCallbackPh`),disabled:we}),(0,G.jsx)(J,{size:`sm`,variant:`secondary`,isPending:z===`busy`&&!!ie.trim(),onPress:()=>void Fe(),isDisabled:we,children:r(`wizardSubmitCallback`)})]}):null]}):o===`pat`?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(_9,{label:r(`tabPat`),children:(0,G.jsx)(UM,{type:`password`,value:D,onChange:e=>O(e.target.value),placeholder:r(`wizardPatPh`),"aria-label":r(`wizardPatPh`),disabled:Se})}),V?(0,G.jsxs)(`p`,{className:`flex items-center gap-2 rounded-lg bg-surface-secondary px-3 py-2 text-caption`,children:[we?(0,G.jsx)(yi,{size:14,className:`shrink-0 text-success`}):null,(0,G.jsx)(`span`,{className:we?`font-medium text-foreground`:`text-muted`,children:V})]}):null]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,G.jsx)(`span`,{className:`text-caption font-medium text-muted`,children:`JSON`}),(0,G.jsxs)(J,{size:`sm`,variant:`secondary`,onPress:ze,isDisabled:Se,children:[(0,G.jsx)(Vi,{size:13}),r(`wizardChooseFile`)]}),(0,G.jsx)(`input`,{ref:pe,type:`file`,accept:`application/json,.json`,className:`hidden`,onChange:Be})]}),(0,G.jsx)(JM,{className:`min-h-32 font-mono text-caption`,value:k,onChange:e=>A(e.target.value),placeholder:r(`wizardImportPh`),"aria-label":r(`tabImport`),disabled:Se}),V?(0,G.jsxs)(`p`,{className:`flex items-center gap-2 rounded-lg bg-surface-secondary px-3 py-2 text-caption`,children:[we?(0,G.jsx)(yi,{size:14,className:`shrink-0 text-success`}):null,(0,G.jsx)(`span`,{className:we?`font-medium text-foreground`:`text-muted`,children:V})]}):null]})})]})]})})}),(0,G.jsxs)(Y.Footer,{className:`justify-end gap-2 px-5 pb-5`,children:[(0,G.jsx)(J,{variant:`ghost`,onPress:Ae,isDisabled:Se,children:r(`cancel`)}),i===`login`&&He?(0,G.jsx)(J,{isPending:z===`busy`,onPress:()=>void Ie(),isDisabled:we,children:we?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(yi,{size:15}),r(`wizardAccountReady`)]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(ta,{size:15}),r(`zhipuCreate`)]})}):null,i===`login`&&!He&&o===`browser`?(0,G.jsx)(J,{isPending:Ve(`browser`),onPress:()=>void Pe(),isDisabled:we,children:we?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(yi,{size:15}),r(`wizardAccountReady`)]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Da,{size:15}),r(`wizardStartBrowser`)]})}):null,i===`login`&&!He&&o===`pat`?(0,G.jsx)(J,{isPending:Ve(`pat`),onPress:()=>void Le(),isDisabled:we,children:we?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(yi,{size:15}),r(`patDone`)]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(ta,{size:15}),r(`wizardCreateAndLogin`)]})}):null,i===`login`&&!He&&o===`import`?(0,G.jsx)(J,{isPending:Ve(`import`),onPress:()=>void Re(),isDisabled:we,children:we?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(yi,{size:15}),r(`accountImported`)]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Vi,{size:15}),r(`importCredential`)]})}):null]})]})})})})}function E9({isOpen:e,title:t,description:n,confirmLabel:r,cancelLabel:i,closeLabel:a,isPending:o,status:s=`danger`,confirmVariant:c=`danger`,onClose:l,onConfirm:u}){return(0,G.jsx)(cx.Root,{isOpen:e,onOpenChange:e=>{!e&&!o&&l()},children:(0,G.jsx)(cx.Backdrop,{variant:`blur`,isDismissable:!o,children:(0,G.jsx)(cx.Container,{placement:`center`,size:`sm`,children:(0,G.jsxs)(cx.Dialog,{children:[(0,G.jsxs)(cx.Header,{className:`items-start justify-between gap-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,G.jsx)(cx.Icon,{status:s}),(0,G.jsx)(`div`,{children:(0,G.jsx)(cx.Heading,{children:t})})]}),(0,G.jsx)(cx.CloseTrigger,{isDisabled:o,"aria-label":a})]}),(0,G.jsx)(cx.Body,{children:(0,G.jsx)(`p`,{className:`text-body leading-6 text-muted`,children:n})}),(0,G.jsxs)(cx.Footer,{children:[(0,G.jsx)(J,{size:`sm`,variant:`ghost`,isDisabled:o,onPress:l,children:i}),(0,G.jsx)(J,{size:`sm`,variant:c,isPending:o,onPress:u,children:r})]})]})})})})}function ECe(e,t){return e===`region_mixed`?t(`batchImportRegionMixed`):e===`region_unknown`?t(`batchImportRegionUnknown`):e===`unknown_format`?t(`batchImportUnknownFormat`):``}function DCe({isOpen:e,detection:t,fileName:n,isPending:r,t:i,onClose:a,onConfirm:o}){let[s,c]=(0,v.useState)(`cn`);(0,v.useEffect)(()=>{t&&(t.region===`cn`||t.region===`global`?c(t.region):c(`cn`))},[t]);let l=!!t?.batchImportSupported,u=t?.provider,d=t?.format||i(`batchImportFormatUnknown`),f=u?AH(u,i):i(`batchImportProviderUnknown`),p=(t?.warnings||[]).map(e=>ECe(e,i)).filter(Boolean);return(0,G.jsx)(Y.Root,{isOpen:e,onOpenChange:e=>{!e&&!r&&a()},children:(0,G.jsx)(Y.Backdrop,{variant:`blur`,isDismissable:!r,children:(0,G.jsx)(Y.Container,{placement:`center`,size:`sm`,scroll:`inside`,className:`mx-3 w-full max-w-[min(100%,24rem)] sm:mx-0`,children:(0,G.jsxs)(Y.Dialog,{children:[(0,G.jsxs)(Y.Header,{className:`items-start justify-between gap-4 px-5 pt-5`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(Y.Heading,{className:`text-section font-semibold`,children:i(`batchImportConfirmTitle`)}),(0,G.jsx)(`p`,{className:`mt-1 break-all text-caption leading-5 text-muted`,children:n?i(`batchImportConfirmHint`,{file:n}):i(`batchImportConfirmHintNoFile`)})]}),(0,G.jsx)(Y.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,G.jsx)(ao,{size:16})})]}),(0,G.jsxs)(Y.Body,{className:`space-y-4 px-5 pb-2`,children:[(0,G.jsx)(`div`,{className:`rounded-xl bg-surface-secondary px-3.5 py-3`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[u?(0,G.jsx)(MH,{provider:u,size:18}):null,(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`div`,{className:`text-body font-medium text-foreground`,children:f}),(0,G.jsx)(`div`,{className:`mono mt-0.5 truncate text-caption text-muted`,children:d})]})]})}),l?(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(`div`,{className:`text-body font-medium text-muted`,children:i(`batchImportRegion`)}),(0,G.jsx)(pH,{value:s,onChange:e=>{(e===`cn`||e===`global`)&&c(e)},ariaLabel:i(`batchImportRegion`),options:[{id:`cn`,label:i(`accountTypeWorkBuddyCN`)},{id:`global`,label:i(`accountTypeWorkBuddyGlobal`)}]}),t?.regionAmbiguous?(0,G.jsx)(`p`,{className:`text-caption leading-5 text-muted`,children:i(`batchImportRegionPickHint`)}):null]}):(0,G.jsx)(`p`,{className:`text-body leading-6 text-muted`,children:i(`batchImportProviderUnsupported`)}),p.length?(0,G.jsx)(`ul`,{className:`space-y-1 text-caption leading-5 text-muted`,children:p.map(e=>(0,G.jsx)(`li`,{children:e},e))}):null]}),(0,G.jsxs)(Y.Footer,{className:`flex-col-reverse gap-2 px-5 pb-5 sm:flex-row sm:justify-end`,children:[(0,G.jsx)(J,{size:`sm`,variant:`ghost`,className:`w-full sm:w-auto`,isDisabled:r,onPress:a,children:i(l?`cancel`:`close`)}),l?(0,G.jsx)(J,{size:`sm`,className:`w-full sm:w-auto`,isPending:r,onPress:()=>o(s),children:i(`batchImportConfirmAction`)}):null]})]})})})})}var D9={"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`},OCe=[`codebuddy.cn`,`workbuddy.cn`],kCe=[`workbuddy.ai`,`workbuddy.com`];function O9(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function k9(e){let t=e.trim();if(!t)return``;let n=t.toLowerCase();return n===`workbuddy-accounts`?`workbuddy-accounts`:n}function ACe(e){return typeof e.format==`string`&&e.format.trim()?k9(e.format):typeof e.exportType==`string`&&e.exportType.trim()?k9(e.exportType):``}function jCe(e){let t=[],n=e=>{typeof e==`string`&&e.trim()&&t.push(e.trim().toLowerCase())};if(n(e.domain),O9(e.account)&&n(e.account.domain),O9(e.auth)&&n(e.auth.domain),Array.isArray(e.accounts))for(let t of e.accounts)O9(t)&&(n(t.domain),O9(t.account)&&n(t.account.domain),O9(t.auth)&&n(t.auth.domain));return t}function MCe(e){return OCe.some(t=>e.includes(t))}function NCe(e){return kCe.some(t=>e.includes(t))}function A9(e){return typeof e.accessToken==`string`||typeof e.access_token==`string`||typeof e.refreshToken==`string`||typeof e.refresh_token==`string`}function PCe(e){if(!O9(e))return!1;if(A9(e)||typeof e.domain==`string`||typeof e.uid==`string`)return!0;if(O9(e.account)||O9(e.auth)){let t=O9(e.account)?e.account:null,n=O9(e.auth)?e.auth:null;if(n&&(A9(n)||typeof n.domain==`string`)||t&&(typeof t.uid==`string`||typeof t.domain==`string`))return!0}return!1}function FCe(e){let t=jCe(e);if(t.length===0)return{region:`cn`,ambiguous:!0,warning:`region_unknown`};let n=t.some(MCe),r=t.some(NCe);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 ICe(e){return Array.isArray(e.accounts)&&e.accounts.some(PCe)?{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`}:A9(e)||O9(e.account)&&A9(e.account)||O9(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 LCe(e){if(!O9(e))return{format:null,provider:null,region:null,regionAmbiguous:!0,confidence:`low`,warnings:[`not_object`],batchImportSupported:!1};let t=[],n=ACe(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?D9[o]??null:null,c=o&&s?`high`:`low`;if(!s){let r=ICe(e);o||=r.format,s=r.provider,c=n&&!D9[n]?`low`:r.confidence,a&&!D9[n]&&t.push(`unknown_format`)}s===`workbuddy`&&Array.isArray(e.accounts)&&(o=`workbuddy-accounts`);let l=null,u=!1;if(s===`workbuddy`){let n=FCe(e);l=n.region,u=n.ambiguous,n.warning&&t.push(n.warning)}return{format:o,provider:s,region:l,regionAmbiguous:u,confidence:c,warnings:t,batchImportSupported:s===`workbuddy`}}function RCe(e){let t;try{t=JSON.parse(e)}catch{throw Error(`bad_json`)}if(!O9(t))throw Error(`bad_json`);return t}var j9=`__all__`,zCe=[],M9=2;function BCe(){let{t:e}=EI(),[t,n]=(0,v.useState)([]),[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)([]),[l,u]=(0,v.useState)(!0),d=s,f=d.length>0,[p,m]=(0,v.useState)(!1),[h,g]=(0,v.useState)(!1),[_,y]=(0,v.useState)(!1),[b,x]=(0,v.useState)(null),[S,C]=(0,v.useState)(null),[w,T]=(0,v.useState)(``),[E,D]=(0,v.useState)(null),[O,k]=(0,v.useState)({}),[A,j]=(0,v.useState)({}),[M,N]=(0,v.useState)({}),[P,F]=(0,v.useState)({}),[I,L]=(0,v.useState)(null),[R,z]=(0,v.useState)(null),[B,V]=(0,v.useState)(null),[H,ee]=(0,v.useState)(null),[te,ne]=(0,v.useState)(null),[re,ie]=(0,v.useState)(``),[ae,oe]=(0,v.useState)(`all`),[se,ce]=(0,v.useState)(``),[le,ue]=(0,v.useState)(1),[de,fe]=(0,v.useState)(20),[pe,me]=(0,v.useState)({}),[he,ge]=(0,v.useState)({}),[_e,ve]=(0,v.useState)({}),[ye,be]=(0,v.useState)({}),[xe,Se]=(0,v.useState)(!1),Ce=(0,v.useCallback)(async(e=!1)=>{try{let t=(await PI(e)).data||zCe;return c(t),t}finally{u(!1)}},[]),we=(0,v.useCallback)(async(e,t=!0)=>{let n=[...new Set(e)];if(n.length)for(let e=0;e{try{let n=await loe(e,{quota:t});c(t=>t.map(t=>t.id===e?n:t))}catch(t){N(n=>({...n,[e]:t instanceof Error?t.message:String(t)}))}}))}},[]);(0,v.useEffect)(()=>{Ce(!1).catch(()=>void 0)},[Ce]),(0,v.useEffect)(()=>{let e=!0;return Promise.all([UI(),$I()]).then(([t,r])=>{e&&(n(t.data||[]),i(r))}).catch(t=>{e&&o(t instanceof Error?t.message:String(t))}),()=>{e=!1}},[]);function Te(e){return t.find(t=>t.id===e.provider)?.regions.find(t=>t.id===e.region)?.checkin}function Ee(e){let t=Te(e)?.timezone;return t===`Local`?r?.timezone:t}let De=(0,v.useMemo)(()=>d.map(e=>{let t=pe[e.id],n=he[e.id],r=_e[e.id],i=ye[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}),[pe,_e,he,ye,d]),Oe=(0,v.useMemo)(()=>{let e={all:De.length,available:0,attention:0,disabled:0};for(let t of De){let n=p9(t);n===`hot`||n===`ready`?e.available+=1:n===`disabled`&&(e.disabled+=1),t.enabled&&n!==`hot`&&n!==`ready`&&(e.attention+=1)}return e},[De]),ke=(0,v.useMemo)(()=>{let e=new Map;for(let t of De){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]))},[De]),Ae=De.find(e=>e.id===I),je=De.find(e=>e.id===R)||null,Me=De.find(e=>e.id===B)||null,Ne=De.find(e=>e.id===H)||null,Pe=(0,v.useMemo)(()=>{let e=re.trim().toLowerCase();return De.filter(t=>{let n=p9(t);return!(ae===`all`||ae===`available`&&(n===`hot`||n===`ready`)||ae===`attention`&&t.enabled&&n!==`hot`&&n!==`ready`||ae===`disabled`&&n===`disabled`)||se&&String(t.provider||`qoder`).toLowerCase()!==se?!1:!e||[t.name,t.id,t.remote_uid,t.provider,t.auth_type].some(t=>String(t||``).toLowerCase().includes(e))})},[De,ae,se,re]),Fe=[re,ae,se,de].join(`\0`),[Ie,Le]=(0,v.useState)(Fe);Ie!==Fe&&(Le(Fe),ue(1));let Re=Math.max(1,Math.ceil(Pe.length/de)),ze=Math.min(Ie===Fe?Math.max(1,le):1,Re);le!==ze&&ue(ze);let Be=(0,v.useMemo)(()=>{let e=(ze-1)*de;return Pe.slice(e,e+de)},[ze,Pe,de]);if(l&&!f)return(0,G.jsx)(Fse,{});async function Ve(e,t,n){D({id:e,kind:t}),N(t=>({...t,[e]:``}));try{return await n(),!0}catch(t){return N(n=>({...n,[e]:t instanceof Error?t.message:String(t)})),!1}finally{D(null)}}async function He(t,n){ne(t),await Ve(t,`device`,async()=>{N(n=>({...n,[t]:e(`wizardStartingSession`)}));let r=await FI(t,n);r.authUrl&&F(e=>({...e,[t]:r.authUrl||``}));for(let n=0;n<60;n++){await new Promise(e=>window.setTimeout(e,2e3));let n=(await II(t)).login||{};if(N(r=>({...r,[t]:n.message||e(`waitingQoderLogin`)})),n.status===`ok`||n.status===`error`)break}await Ce(!1),await we([t])})}async function Ue(t){let n=(A[t]||``).trim();if(!n){N(n=>({...n,[t]:e(`wizardCallbackPh`)}));return}await Ve(t,`callback`,async()=>{N(n=>({...n,[t]:e(`wizardStartingSession`)})),await LI(t,n),j(e=>({...e,[t]:``})),await Ce(!1),await we([t])})&&(ne(e=>e===t?null:e),N(e=>({...e,[t]:``})))}async function We(t){let n=(O[t]||``).trim();if(!n){N(n=>({...n,[t]:e(`pastePatFirst`)}));return}await Ve(t,`pat`,async()=>{N(n=>({...n,[t]:e(`wizardStartingSession`)})),await RI(n,t),k(e=>({...e,[t]:``})),await Ce(!1),await we([t])})}async function Ge(t){await Ve(t,`export`,async()=>{let n=await yoe(t);await Z7(JSON.stringify(n,null,2)),N(n=>({...n,[t]:e(`credentialCopied`)}))})}async function Ke(e,t){me(n=>({...n,[e]:t})),await Ve(e,`toggle`,async()=>{await WI(e,{enabled:t}),await Ce(!1)}),me(t=>{let n={...t};return delete n[e],n})}async function qe(t){XV({id:`refresh-${t}`,type:`loading`,title:e(`toastRefreshingAccount`)}),D({id:t,kind:`refresh`}),N(e=>{let n={...e};return delete n[t],n});try{await we([t]),XV({id:`refresh-${t}`,type:`success`,title:e(`toastAccountRefreshed`)})}catch(n){throw XV({id:`refresh-${t}`,type:`error`,title:e(`toastFailed`),description:n instanceof Error?n.message:String(n)}),n}finally{D(null)}}async function Je(){Se(!0),XV({id:`refresh-credits`,type:`loading`,title:e(`toastRefreshingCredits`)});try{await we(s.map(e=>e.id)),XV({id:`refresh-credits`,type:`success`,title:e(`toastCreditsRefreshed`)})}catch(t){throw XV({id:`refresh-credits`,type:`error`,title:e(`toastFailed`),description:t instanceof Error?t.message:String(t)}),t}finally{Se(!1)}}function Ye(){h||(y(!1),x(null),C(null),T(``))}async function Xe(t){let n=t.target.files?.[0];if(t.target.value=``,n)try{let t=RCe(await n.text()),r=LCe(t);if(!r.provider){XV({type:`error`,title:e(`batchImportUnrecognized`)});return}C(t),x(r),T(n.name),y(!0)}catch(t){let n=t instanceof Error?t.message:String(t);XV({type:`error`,title:e(n===`bad_json`?`wizardBadJson`:`batchImportUnrecognized`),description:n===`bad_json`?void 0:n})}}async function Ze(t){if(!S||!b?.batchImportSupported||h)return;g(!0);let n=`batch-import-accounts`;XV({id:n,type:`loading`,title:e(`batchImportLoading`)});try{let{succeeded:r,failed:i,message:a}=S9(await vCe(S,{region:t}),e);XV({id:n,type:i>0&&r===0?`error`:i>0?`info`:`success`,title:a}),y(!1),x(null),C(null),T(``),r>0&&await Ce(!1)}catch(t){XV({id:n,type:`error`,title:e(`toastFailed`),description:t instanceof Error?t.message:String(t)})}finally{g(!1)}}async function Qe(e,t){await Ve(e,`toggle`,async()=>{await WI(e,{auto_checkin:t}),await Ce(!1)})}async function $e(e){await Ve(e,`checkin`,async()=>{try{await goe(e)}finally{await Ce(!1)}})}async function et(t,n){if(!t)throw Error(e(`accountNameRequired`));ge(e=>({...e,[t]:n.name})),ve(e=>({...e,[t]:n.max_inflight})),be(e=>({...e,[t]:n.priority})),D({id:t,kind:`settings`});try{await WI(t,n),await Ce(!1)}catch(e){throw e instanceof Error?e:Error(String(e))}finally{D(null),ge(e=>{let n={...e};return delete n[t],n}),ve(e=>{let n={...e};return delete n[t],n}),be(e=>{let n={...e};return delete n[t],n})}}return(0,G.jsxs)(`div`,{className:`space-y-4`,children:[a?(0,G.jsx)(QI,{title:a}):null,(0,G.jsxs)(`section`,{"data-gsap-reveal":!0,className:`flex flex-wrap items-center gap-2`,children:[d.length?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(pH,{value:ae,onChange:e=>oe(e),ariaLabel:e(`accountStatusFilter`),options:[{id:`all`,label:(0,G.jsxs)(G.Fragment,{children:[e(`filterAll`),(0,G.jsx)(`span`,{className:`mono text-muted`,children:Oe.all})]})},{id:`available`,label:(0,G.jsxs)(G.Fragment,{children:[e(`availableAccounts`),(0,G.jsx)(`span`,{className:`mono text-muted`,children:Oe.available})]})},{id:`attention`,label:(0,G.jsxs)(G.Fragment,{children:[e(`needsAttention`),(0,G.jsx)(`span`,{className:`mono ${Oe.attention?`text-danger`:`text-muted`}`,children:Oe.attention})]})},{id:`disabled`,label:(0,G.jsxs)(G.Fragment,{children:[e(`disabled`),(0,G.jsx)(`span`,{className:`mono text-muted`,children:Oe.disabled})]})}]}),(0,G.jsxs)(AF,{className:`w-48`,"aria-label":e(`providerFilterAll`),value:se||j9,onChange:e=>{typeof e==`string`&&ce(e===j9?``:e)},children:[(0,G.jsxs)(AF.Trigger,{className:`items-center`,children:[(0,G.jsx)(AF.Value,{className:`min-w-0 truncate`}),(0,G.jsx)(AF.Indicator,{})]}),(0,G.jsx)(AF.Popover,{children:(0,G.jsxs)(oF,{children:[(0,G.jsxs)(oF.Item,{id:j9,textValue:e(`providerFilterAll`),children:[(0,G.jsxs)(IN,{className:`flex items-center gap-2`,children:[e(`providerFilterAll`),(0,G.jsx)(`span`,{className:`mono text-muted`,children:d.length})]}),(0,G.jsx)(oF.ItemIndicator,{})]}),ke.map(([t,n])=>(0,G.jsxs)(oF.Item,{id:t,textValue:AH(t,e),children:[(0,G.jsxs)(IN,{className:`flex items-center gap-2`,children:[(0,G.jsx)(MH,{provider:t,size:13}),AH(t,e),(0,G.jsx)(`span`,{className:`mono text-muted`,children:n})]}),(0,G.jsx)(oF.ItemIndicator,{})]},t))]})})]}),(0,G.jsx)(B7,{className:`w-full sm:w-60`,value:re,onChange:ie,placeholder:e(`searchAccounts`),ariaLabel:e(`searchAccounts`)})]}):null,(0,G.jsxs)(`div`,{className:`flex w-full flex-wrap items-center justify-end gap-2 sm:ml-auto sm:w-auto`,children:[(0,G.jsxs)(J,{size:`sm`,variant:`secondary`,isPending:xe,onPress:()=>void Je(),children:[(0,G.jsx)(ti,{size:14}),e(`refreshCredits`)]}),(0,G.jsxs)(`label`,{htmlFor:`accounts-batch-import-file`,className:`button button--sm button--secondary inline-flex items-center gap-1.5 ${h||_?`pointer-events-none opacity-60`:`cursor-pointer`}`,children:[h?(0,G.jsx)(PV,{size:14,loading:!0}):(0,G.jsx)($a,{size:14}),e(`batchImport`)]}),(0,G.jsx)(`input`,{id:`accounts-batch-import-file`,type:`file`,accept:`.json,application/json,text/json`,disabled:h||_,className:`sr-only`,onChange:e=>void Xe(e)}),(0,G.jsxs)(J,{size:`sm`,onPress:()=>m(!0),children:[(0,G.jsx)(Ca,{size:14}),e(`addAccount`)]})]})]}),(0,G.jsx)(TCe,{isOpen:p,onClose:()=>m(!1),onAdded:()=>{XV({type:`success`,title:e(`toastAccountAdded`)}),Ce(!1)}}),(0,G.jsx)(DCe,{isOpen:_,detection:b,fileName:w,isPending:h,t:e,onClose:Ye,onConfirm:e=>{Ze(e)}}),(0,G.jsx)(oCe,{account:je,t:e,onClose:()=>z(null)},R??`closed`),(0,G.jsx)(iCe,{account:Me,t:e,onClose:()=>V(null)},B??`closed`),(0,G.jsx)(uCe,{account:Ne,checkinDefaultTime:Ne&&Te(Ne)?r?.checkin_times[Ne.provider||``]:void 0,checkinTimezone:Ne?Ee(Ne):void 0,busy:!!(E&&E.id===H&&E.kind===`settings`),t:e,onClose:()=>ee(null),onSave:e=>et(H||``,e)},H??`closed`),(0,G.jsx)(E9,{isOpen:!!Ae,title:e(`delete`),description:e(`deleteAccountConfirm`,{name:Ae?.name||Ae?.id||``}),confirmLabel:e(`delete`),cancelLabel:e(`cancel`),closeLabel:e(`close`),isPending:E?.id===I&&E.kind===`delete`,onClose:()=>L(null),onConfirm:()=>{if(!Ae)return;let t=Ae.id;L(null),Ve(t,`delete`,async()=>{await voe(t),await Ce(!1)}).then(t=>{t&&XV({type:`success`,title:e(`toastAccountDeleted`)})})}}),f?null:(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsx)(I7,{className:`rounded-3xl bg-surface-secondary`,icon:(0,G.jsx)(PV,{size:28}),title:e(`noAccounts`),hint:e(`accountEmptyHint`),action:(0,G.jsxs)(J,{size:`sm`,onPress:()=>m(!0),children:[(0,G.jsx)(Ca,{size:14}),e(`addAccount`)]})}),(0,G.jsx)(`div`,{className:`text-center`,children:(0,G.jsx)(e9,{})})]}),f&&!Pe.length?(0,G.jsx)(I7,{className:`rounded-3xl bg-surface-secondary`,icon:(0,G.jsx)(la,{size:22}),title:e(`noAccountsMatch`),action:(0,G.jsx)(J,{size:`sm`,variant:`ghost`,onPress:()=>{ie(``),oe(`all`),ce(``)},children:e(`clearFilters`)})}):null,(0,G.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:Be.map(t=>(0,G.jsx)(tCe,{account:t,busyKind:E?.id===t.id?E.kind:``,authPanelOpen:te===t.id,authUrl:P[t.id],note:M[t.id],pat:O[t.id]||``,t:e,onPatChange:e=>k(n=>({...n,[t.id]:e})),callbackUrl:A[t.id]||``,onCallbackChange:e=>j(n=>({...n,[t.id]:e})),onSubmitCallback:()=>void Ue(t.id),onDeviceLogin:e=>void He(t.id,e),onPatLogin:()=>void We(t.id),onExport:()=>void Ge(t.id),onRefresh:()=>void qe(t.id),onDelete:()=>L(t.id),onToggle:e=>void Ke(t.id,e),checkinDefaultTime:r?.checkin_times[t.provider||``],onToggleAutoCheckin:Te(t)?e=>void Qe(t.id,e):void 0,onCheckin:Te(t)?()=>void $e(t.id):void 0,onViewCheckins:Te(t)?()=>V(t.id):void 0,onEdit:()=>ee(t.id),onToggleAuthPanel:()=>ne(e=>e===t.id?null:t.id),onViewModels:()=>z(t.id)},t.id))}),Pe.length?(0,G.jsx)(z7,{total:Pe.length,page:ze,pageCount:Re,pageSize:de,pageSizes:lSe,loading:!1,pageSizeLabel:e(`logsPageSize`),pageLabel:e(`logsPage`,{page:ze,pages:Re}),prevLabel:e(`logsPrevPage`),nextLabel:e(`logsNextPage`),onPage:ue,onPageSize:fe}):null]})}function VCe(){let{t:e,lang:t,setLang:n}=EI(),{setApiKey:r}=kI(),{overview:i,refresh:a}=qI(),{theme:o,toggleTheme:s}=XI(),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(!1),[m,h]=(0,v.useState)(``),g=at(),_=nt().state?.from||`/`,y=(0,v.useRef)(null);if(Use(y,`login`),i)return(0,G.jsx)(At,{to:_===`/login`?`/`:_,replace:!0});async function b(t){t.preventDefault();let n=c.trim();if(!n){h(e(`loginNeedKey`));return}p(!0),h(``);try{r(n),await a(n),g(_===`/login`?`/`:_,{replace:!0})}catch(t){h(MI(t)?e(`loginBadKey`):t instanceof Error?t.message:String(t))}finally{p(!1)}}return(0,G.jsxs)(`div`,{className:`relative min-h-dvh overflow-hidden bg-background text-foreground`,children:[(0,G.jsx)(`div`,{className:`absolute inset-x-0 top-0 h-px bg-border`}),(0,G.jsxs)(`main`,{ref:y,className:`relative z-10 mx-auto grid min-h-dvh w-full max-w-[1480px] lg:grid-cols-[minmax(0,1fr)_minmax(480px,45%)]`,children:[(0,G.jsxs)(`section`,{className:`flex min-h-[52vh] flex-col border-separator px-5 py-6 sm:px-10 sm:py-8 lg:min-h-dvh lg:border-r lg:px-14 lg:py-10 xl:px-20`,children:[(0,G.jsxs)(`header`,{className:`flex items-center justify-between gap-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsx)(PV,{size:36}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`font-semibold`,children:`CLI2API`}),(0,G.jsx)(`div`,{className:`text-caption text-muted`,children:e(`controlPlane`)})]})]}),(0,G.jsxs)(cM,{isAttached:!0,children:[(0,G.jsxs)(PM,{children:[(0,G.jsx)(PM.Trigger,{children:(0,G.jsx)(J,{isIconOnly:!0,size:`sm`,variant:`ghost`,onPress:()=>n(t===`zh`?`en`:`zh`),"aria-label":t===`zh`?`English`:`中文`,children:(0,G.jsx)(Yi,{size:15})})}),(0,G.jsx)(PM.Content,{children:t===`zh`?`English`:`中文`})]}),(0,G.jsxs)(PM,{children:[(0,G.jsx)(PM.Trigger,{children:(0,G.jsx)(J,{isIconOnly:!0,size:`sm`,variant:`ghost`,onPress:s,"aria-label":o===`dark`?`Light mode`:`Dark mode`,children:o===`dark`?(0,G.jsx)(Ua,{size:15}):(0,G.jsx)(da,{size:15})})}),(0,G.jsx)(PM.Content,{children:o===`dark`?`Light mode`:`Dark mode`})]})]})]}),(0,G.jsxs)(`div`,{className:`my-auto max-w-3xl py-16 lg:py-24`,children:[(0,G.jsx)(`p`,{"data-gsap-reveal":!0,className:`mb-5 mono text-caption text-muted`,children:`:3010`}),(0,G.jsx)(`h1`,{"data-gsap-reveal":!0,className:`max-w-3xl text-[clamp(2.25rem,4vw,3.6rem)] font-semibold leading-[0.98] tracking-[-0.045em] text-balance`,children:e(`loginTitle`)}),(0,G.jsx)(`p`,{"data-gsap-reveal":!0,className:`mt-6 max-w-xl text-section font-normal text-muted sm:text-title sm:font-normal`,children:e(`loginLead`)}),(0,G.jsx)(`p`,{"data-gsap-reveal":!0,className:`mt-10 max-w-xl pt-5 text-body leading-6 text-muted`,children:e(`loginHint`)})]}),(0,G.jsxs)(`footer`,{className:`hidden items-center justify-between text-caption text-muted lg:flex`,children:[(0,G.jsx)(`span`,{children:e(`loginHint`)}),(0,G.jsx)(`span`,{children:e(`routesHint`)})]})]}),(0,G.jsx)(`section`,{className:`flex items-center px-5 py-10 sm:px-10 lg:px-12 xl:px-16`,children:(0,G.jsx)(HS,{"data-gsap-reveal":!0,className:`w-full p-0`,children:(0,G.jsxs)(`form`,{onSubmit:e=>void b(e),children:[(0,G.jsx)(HS.Header,{className:`border-b border-separator px-6 py-6 sm:px-8`,children:(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,G.jsx)(PV,{size:28,loading:f}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(HS.Title,{className:`text-title`,children:e(`loginFormTitle`)}),(0,G.jsx)(HS.Description,{className:`mt-1`,children:e(`loginDesc`)})]})]})}),(0,G.jsxs)(HS.Content,{className:`space-y-5 px-6 py-7 sm:px-8 sm:py-8`,children:[(0,G.jsxs)(YM,{name:`console-password`,className:`w-full`,isInvalid:!!m,children:[(0,G.jsx)(IN,{children:e(`loginPassword`)}),(0,G.jsxs)(KM,{children:[(0,G.jsx)(KM.Input,{id:`console-password`,type:u?`text`:`password`,value:c,onChange:e=>l(e.target.value),placeholder:e(`loginPasswordPh`),autoComplete:`current-password`,autoFocus:!0,"aria-label":e(`loginPassword`),spellCheck:!1}),(0,G.jsx)(KM.Suffix,{children:(0,G.jsx)(J,{isIconOnly:!0,size:`sm`,variant:`ghost`,type:`button`,"aria-label":e(u?`hidePassword`:`showPassword`),onPress:()=>d(e=>!e),children:u?(0,G.jsx)(zi,{size:16}):(0,G.jsx)(Li,{size:16})})})]})]}),m?(0,G.jsx)(QI,{title:m}):(0,G.jsx)(`p`,{className:`text-caption text-muted`,children:e(`loginHint`)}),(0,G.jsxs)(J,{type:`submit`,fullWidth:!0,size:`lg`,isPending:f,children:[e(f?`loggingInConsole`:`loginSubmit`),f?null:(0,G.jsx)(Yr,{size:17})]})]})]})})})]})]})}function N9(){return NI(`/api/keys`)}function HCe(e){return NI(`/api/keys`,{method:`POST`,body:JSON.stringify(e)})}function P9(e,t){return NI(`/api/keys/${encodeURIComponent(e)}`,{method:`PATCH`,body:JSON.stringify(t)})}function UCe(e){return NI(`/api/keys/${encodeURIComponent(e)}`,{method:`DELETE`})}function WCe(){return NI(`/api/system/console-key`)}function GCe(){return NI(`/api/system/console-key`,{method:`POST`,body:JSON.stringify({rotate:!0})})}function KCe({settings:e,onSaved:t}){let{t:n}=EI(),r=at(),[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)({}),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(``);(0,v.useEffect)(()=>{let e=!0;return UI().then(t=>{e&&a((t.data||[]).filter(e=>e.regions.some(e=>e.checkin)))}).catch(t=>{e&&d(String(t))}),()=>{e=!1}},[]);async function f(n,r){if(!(!e||r===e.checkin_times[n])){l(!0),d(``);try{t(await eL({checkin_times:{[n]:r}}))}catch(e){d(e instanceof Error?e.message:String(e))}finally{s(e=>{let t={...e};return delete t[n],t}),l(!1)}}}return(0,G.jsxs)(HS,{"data-gsap-reveal":!0,children:[(0,G.jsxs)(HS.Header,{children:[(0,G.jsx)(HS.Title,{children:n(`checkinDefaultsTitle`)}),(0,G.jsx)(HS.Description,{children:n(`checkinDefaultsHint`)})]}),(0,G.jsxs)(HS.Content,{className:`space-y-4`,children:[u?(0,G.jsx)(QI,{title:u}):null,!e||!i?(0,G.jsx)(Q,{className:`h-24 w-full`}):i.map(t=>(0,G.jsx)(_9,{label:t.label,hint:t.regions.filter(e=>e.checkin).map(t=>`${t.label} · ${t.checkin?.timezone===`Local`?e.timezone:t.checkin?.timezone}`).join(` / `),children:(0,G.jsx)(UM,{type:`time`,value:o[t.id]??e.checkin_times[t.id]??``,disabled:c,"aria-label":`${t.label} ${n(`autoCheckinTime`)}`,onChange:e=>s(n=>({...n,[t.id]:e.target.value})),onBlur:e=>void f(t.id,e.target.value)})},t.id))]}),(0,G.jsx)(HS.Footer,{children:(0,G.jsx)(J,{variant:`secondary`,onPress:()=>r(`/accounts`),children:n(`navAccounts`)})})]})}function qCe(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 JCe({releases:e,currentVersion:t,nextVersion:n,rollbackTags:r,canRollback:i,submitting:a,onRestore:o}){let{t:s,lang:c}=EI();if(!e.length)return null;let l=n&&n!==t?n:t,u=e.some(e=>e.tag_name===l)?l:e[0]?.tag_name,d=new Set(r);return(0,G.jsxs)(`div`,{className:`mt-5`,children:[(0,G.jsx)(`div`,{className:`mb-2`,children:(0,G.jsx)(`p`,{className:`text-caption font-medium text-foreground`,children:s(`versionHistory`)})}),(0,G.jsx)(vh,{className:`rounded-lg bg-surface-secondary`,hideSeparator:!0,defaultExpandedKeys:u?[u]:[],children:e.map(e=>{let r=e.tag_name,l=r===t,u=!!(n&&r===n&&n!==t),f=i&&d.has(r)&&!l,p=qCe(e.published_at,c);return(0,G.jsxs)(vh.Item,{id:r,children:[(0,G.jsx)(vh.Heading,{children:(0,G.jsxs)(vh.Trigger,{className:`items-center gap-3 px-3 py-2.5 text-left`,children:[(0,G.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`mono text-body font-semibold`,children:r}),l?(0,G.jsx)(aC,{size:`sm`,variant:`soft`,color:`success`,children:s(`versionCurrentBadge`)}):null,u?(0,G.jsx)(aC,{size:`sm`,variant:`soft`,color:`warning`,children:s(`versionLatestBadge`)}):null,p?(0,G.jsx)(`span`,{className:`truncate text-caption text-muted`,children:p}):null]}),(0,G.jsx)(vh.Indicator,{})]})}),(0,G.jsx)(vh.Panel,{children:(0,G.jsxs)(vh.Body,{className:`px-3 pb-3`,children:[(0,G.jsx)(`div`,{className:`release-notes-box release-notes-box--compact`,children:(0,G.jsx)(aL,{markdown:rL(e.body,c),emptyLabel:s(`updateNoNotes`)})}),f?(0,G.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,G.jsx)(J,{size:`sm`,variant:`ghost`,isDisabled:a,onPress:()=>o(r),children:s(`restoreThisVersion`)})}):null]})})]},r)})})]})}function F9(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 YCe(e,t,n,r,i){return r?.length?F9(r):F9([...n?[n]:t?[{tag_name:t}]:[],...e?[{tag_name:e}]:[],...i||[]])}var XCe=[`general`,`routing`,`security`,`updates`];function ZCe(){let{t:e}=EI(),[t,n]=On(),r=t.get(`tab`),i=r&&XCe.includes(r)?r:`general`,a=e=>n(e===`general`?{}:{tab:e},{replace:!0}),{setApiKey:o}=kI(),[s,c]=(0,v.useState)(null),[l,u]=(0,v.useState)(null),[d,f]=(0,v.useState)(``),[p,m]=(0,v.useState)(!1),[h,g]=(0,v.useState)(!1),[_,y]=(0,v.useState)(!1),[b,x]=(0,v.useState)(``),[S,C]=(0,v.useState)(!1),[w,T]=(0,v.useState)(``),E=nL(),{info:D,loading:O,checking:k,submitting:A,error:j,setError:M,load:N,canRollback:P,rollbackTo:F}=E,I=(0,v.useMemo)(()=>YCe(D?.current_version||``,D?.next_version,D?.release,D?.recent_releases,D?.rollback_versions),[D?.current_version,D?.next_version,D?.release,D?.recent_releases,D?.rollback_versions]),L=(0,v.useMemo)(()=>(D?.rollback_versions||[]).map(e=>e.tag_name),[D?.rollback_versions]);(0,v.useEffect)(()=>{let e=window.setTimeout(()=>{WCe().then(c).catch(()=>void 0),$I().then(e=>{u(e),f(e.proxy_url||``)}).catch(e=>M(e instanceof Error?e.message:String(e)))},0);return()=>window.clearTimeout(e)},[M]);async function R(e){let t=l?.cross_provider_model_pool??!0;u(t=>t&&{...t,cross_provider_model_pool:e}),m(!0),M(``);try{u(await eL({cross_provider_model_pool:e}))}catch(e){u(e=>e&&{...e,cross_provider_model_pool:t}),M(e instanceof Error?e.message:String(e))}finally{m(!1)}}async function z(e){let t=l?.checkin_disabled_accounts??!1;u(t=>t&&{...t,checkin_disabled_accounts:e}),m(!0),M(``);try{u(await eL({checkin_disabled_accounts:e}))}catch(e){u(e=>e&&{...e,checkin_disabled_accounts:t}),M(e instanceof Error?e.message:String(e))}finally{m(!1)}}async function B(e){let t=l?.proxy_url||``;if(e===t){f(t);return}let n=d;f(e),u(t=>t&&{...t,proxy_url:e}),m(!0),M(``);try{let t=await eL({proxy_url:e});u(t),f(t.proxy_url||``)}catch(e){f(n),u(e=>e&&{...e,proxy_url:t}),M(e instanceof Error?e.message:String(e))}finally{m(!1)}}async function V(e){let t=l?.routing_strategy||`round-robin`;u(t=>t&&{...t,routing_strategy:e}),m(!0),M(``);try{u(await eL({routing_strategy:e}))}catch(e){u(e=>e&&{...e,routing_strategy:t}),M(e instanceof Error?e.message:String(e))}finally{m(!1)}}return O&&!D?(0,G.jsx)(Hse,{}):(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)(`h2`,{"data-gsap-reveal":!0,className:`text-title font-semibold`,children:e(`systemSettingsTitle`)}),(0,G.jsx)(`p`,{className:`mt-1 max-w-2xl text-body leading-6 text-muted`,children:e(`systemSettingsLead`)})]}),(0,G.jsxs)(J,{size:`sm`,variant:`secondary`,isPending:k,onPress:()=>void N(!0),children:[(0,G.jsx)(qr,{size:15}),e(`checkUpdates`)]})]}),j?(0,G.jsx)(QI,{title:j}):null,(0,G.jsxs)(_j,{selectedKey:i,onSelectionChange:e=>a(String(e)),children:[(0,G.jsx)(_j.ListContainer,{className:`w-fit max-w-full overflow-x-auto`,children:(0,G.jsxs)(_j.List,{"aria-label":e(`systemSettingsTitle`),children:[(0,G.jsxs)(gj,{id:`general`,className:`gap-1.5 whitespace-nowrap`,children:[(0,G.jsx)(_j.Indicator,{}),(0,G.jsx)(qi,{size:13}),e(`settingsTabGeneral`)]}),(0,G.jsxs)(gj,{id:`routing`,className:`gap-1.5 whitespace-nowrap`,children:[(0,G.jsx)(_j.Indicator,{}),(0,G.jsx)(ri,{size:13}),e(`settingsTabRouting`)]}),(0,G.jsxs)(gj,{id:`security`,className:`gap-1.5 whitespace-nowrap`,children:[(0,G.jsx)(_j.Indicator,{}),(0,G.jsx)(Da,{size:13}),e(`settingsTabSecurity`)]}),(0,G.jsxs)(gj,{id:`updates`,className:`gap-1.5 whitespace-nowrap`,children:[(0,G.jsx)(_j.Indicator,{}),(0,G.jsx)(Gr,{size:13}),e(`settingsTabUpdates`)]})]})}),(0,G.jsx)(_j.Panel,{id:`general`,className:`pt-5`,children:(0,G.jsxs)(`div`,{className:`grid gap-5 xl:grid-cols-2 items-start`,children:[(0,G.jsxs)(HS,{"data-gsap-reveal":!0,children:[(0,G.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,G.jsx)(`div`,{className:`grid size-8 shrink-0 place-items-center rounded-lg bg-surface-secondary text-foreground`,children:(0,G.jsx)(Na,{size:15})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`font-semibold`,children:e(`proxySettingsTitle`)}),(0,G.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:e(`proxySettingsHint`)})]})]}),(0,G.jsxs)(`div`,{className:`mt-4 space-y-1.5`,children:[(0,G.jsx)(IN,{className:`text-body font-medium text-muted`,children:e(`proxyUrl`)}),(0,G.jsx)(UM,{value:d,onChange:e=>f(e.target.value),onBlur:e=>void B(e.target.value.trim()),placeholder:e(`proxyUrlPlaceholder`),disabled:p||!l}),(0,G.jsx)(RN,{className:`text-caption leading-5 text-muted`,children:e(`proxyUrlHint`)})]})]}),(0,G.jsxs)(HS,{"data-gsap-reveal":!0,children:[(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,G.jsx)(`div`,{className:`grid size-8 shrink-0 place-items-center rounded-lg bg-surface-secondary text-foreground`,children:(0,G.jsx)(yi,{size:15})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`font-semibold`,children:e(`checkinDisabledAccountsTitle`)}),(0,G.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:e(`checkinDisabledAccountsHint`)})]})]}),(0,G.jsx)(F7,{isSelected:l?.checkin_disabled_accounts??!1,isDisabled:p||!l,ariaLabel:e(`checkinDisabledAccountsAriaLabel`),onChange:e=>void z(e)})]}),(0,G.jsxs)(`div`,{className:`mt-4 flex items-center justify-between pt-3 text-caption text-muted`,children:[(0,G.jsx)(`span`,{children:e(`checkinDisabledAccountsStatus`)}),(0,G.jsx)(`span`,{className:`font-medium text-foreground`,children:l?.checkin_disabled_accounts?e(`enabled`):e(`disabled`)})]})]}),(0,G.jsx)(KCe,{settings:l,onSaved:u})]})}),(0,G.jsx)(_j.Panel,{id:`routing`,className:`pt-5`,children:(0,G.jsxs)(`div`,{className:`grid gap-5 xl:grid-cols-2 items-start`,children:[(0,G.jsxs)(HS,{"data-gsap-reveal":!0,children:[(0,G.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,G.jsx)(`div`,{className:`grid size-8 shrink-0 place-items-center rounded-lg bg-surface-secondary text-foreground`,children:(0,G.jsx)(Na,{size:15})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`font-semibold`,children:e(`routingStrategyTitle`)}),(0,G.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:e(`routingStrategyHint`)})]})]}),(0,G.jsx)(`div`,{className:`mt-4 pt-4`,children:(0,G.jsx)(_9,{label:e(`routingStrategy`),children:(0,G.jsxs)(AF,{fullWidth:!0,"aria-label":e(`routingStrategy`),value:l?.routing_strategy||`round-robin`,isDisabled:p||!l,onChange:e=>{typeof e==`string`&&e&&V(e)},children:[(0,G.jsxs)(AF.Trigger,{className:`items-center`,children:[(0,G.jsx)(AF.Value,{className:`min-w-0 truncate`}),(0,G.jsx)(AF.Indicator,{})]}),(0,G.jsx)(AF.Popover,{children:(0,G.jsxs)(oF,{children:[(0,G.jsxs)(oF.Item,{id:`round-robin`,textValue:`round-robin`,children:[(0,G.jsx)(IN,{children:e(`routingRoundRobin`)}),(0,G.jsx)(oF.ItemIndicator,{})]}),(0,G.jsxs)(oF.Item,{id:`weighted-round-robin`,textValue:`weighted-round-robin`,children:[(0,G.jsx)(IN,{children:e(`routingWeightedRoundRobin`)}),(0,G.jsx)(oF.ItemIndicator,{})]}),(0,G.jsxs)(oF.Item,{id:`fill-first`,textValue:`fill-first`,children:[(0,G.jsx)(IN,{children:e(`routingFillFirst`)}),(0,G.jsx)(oF.ItemIndicator,{})]}),(0,G.jsxs)(oF.Item,{id:`fefo`,textValue:`fefo`,children:[(0,G.jsx)(IN,{children:e(`routingFEFO`)}),(0,G.jsx)(oF.ItemIndicator,{})]})]})})]})})}),(0,G.jsxs)(`div`,{className:`mt-4 grid grid-cols-2 gap-2 pt-3 text-caption text-muted sm:grid-cols-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`mono block text-body font-medium text-foreground`,children:l?.session_affinity?.ttl_seconds?`${Math.round(l.session_affinity.ttl_seconds/60)}m`:`—`}),e(`sessionAffinityTTL`)]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`mono block text-body font-medium text-foreground`,children:l?.session_affinity?.hits??0}),e(`sessionAffinityHits`)]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`mono block text-body font-medium text-foreground`,children:l?.session_affinity?.misses??0}),e(`sessionAffinityMisses`)]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`mono block text-body font-medium text-foreground`,children:l?.session_affinity?.escapes??0}),e(`sessionAffinityEscapes`)]})]}),l?.session_affinity?.last_escape_reason?(0,G.jsxs)(RN,{className:`mt-3 text-caption`,children:[e(`lastSessionEscape`),`: `,l.session_affinity.last_escape_reason]}):null,l?.session_affinity?.last_miss_reason?(0,G.jsxs)(RN,{className:`mt-1 text-caption`,children:[e(`lastSessionMiss`),`: `,l.session_affinity.last_miss_reason]}):null]}),(0,G.jsxs)(HS,{"data-gsap-reveal":!0,children:[(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,G.jsx)(`div`,{className:`grid size-8 shrink-0 place-items-center rounded-lg bg-surface-secondary text-foreground`,children:(0,G.jsx)(Na,{size:15})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`font-semibold`,children:e(`crossProviderModelPoolTitle`)}),(0,G.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:e(`crossProviderModelPoolHint`)})]})]}),(0,G.jsx)(F7,{isSelected:l?.cross_provider_model_pool??!0,isDisabled:p||!l,ariaLabel:e(`crossProviderModelPoolAriaLabel`),onChange:e=>void R(e)})]}),(0,G.jsxs)(`div`,{className:`mt-4 flex items-center justify-between pt-3 text-caption text-muted`,children:[(0,G.jsx)(`span`,{children:e(`crossProviderModelPoolStatus`)}),(0,G.jsx)(`span`,{className:`font-medium text-foreground`,children:l?.cross_provider_model_pool?e(`enabled`):e(`disabled`)})]})]})]})}),(0,G.jsx)(_j.Panel,{id:`security`,className:`pt-5`,children:(0,G.jsxs)(`div`,{className:`grid gap-5 xl:grid-cols-2 items-start`,children:[(0,G.jsxs)(HS,{"data-gsap-reveal":!0,children:[(0,G.jsx)(`div`,{className:`flex items-start justify-between gap-4`,children:(0,G.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,G.jsx)(`div`,{className:`grid size-8 shrink-0 place-items-center rounded-lg bg-surface-secondary text-foreground`,children:(0,G.jsx)(ta,{size:15})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`font-semibold`,children:e(`consoleKeyTitle`)}),(0,G.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:e(`consoleKeyHint`)})]})]})}),(0,G.jsx)(`code`,{className:`mono mt-4 block rounded-lg bg-surface-secondary px-3 py-2 text-caption text-muted`,children:s?.prefix||`—`}),(0,G.jsx)(`p`,{className:`mt-3 text-caption leading-5 text-muted`,children:e(`consoleKeyLead`)}),(0,G.jsx)(`div`,{className:`mt-4 flex justify-end`,children:(0,G.jsx)(J,{size:`sm`,variant:`ghost`,isPending:h,onPress:()=>y(!0),children:e(`consoleKeyRotate`)})})]}),(0,G.jsxs)(HS,{"data-gsap-reveal":!0,children:[(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,G.jsx)(`div`,{className:`grid size-8 shrink-0 place-items-center rounded-lg bg-surface-secondary text-foreground`,children:(0,G.jsx)(Ni,{size:15})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`font-semibold`,children:e(`sqliteProtection`)}),(0,G.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:e(`sqliteProtectionHint`)})]})]}),(0,G.jsx)(Da,{size:18,className:`text-success`})]}),(0,G.jsx)(`div`,{className:`mono mt-4 rounded-lg bg-surface-secondary px-3 py-2 text-caption text-muted`,children:`/data`}),(0,G.jsxs)(`div`,{className:`mt-3 grid gap-2 text-caption text-muted`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(yi,{size:14,className:`text-muted`}),e(`sqliteBackupBeforeUpdate`)]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(yi,{size:14,className:`text-muted`}),e(`sqliteKeepFive`)]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(yi,{size:14,className:`text-muted`}),e(`sqliteRollbackTogether`)]})]})]})]})}),(0,G.jsx)(_j.Panel,{id:`updates`,className:`pt-5`,children:(0,G.jsx)(`div`,{className:`grid gap-5`,children:(0,G.jsxs)(HS,{"data-gsap-reveal":!0,className:`overflow-hidden p-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-separator px-5 py-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`font-semibold`,children:e(`versionUpdate`)}),(0,G.jsx)(`p`,{className:`mt-0.5 text-caption text-muted`,children:e(`latestVersionHint`)})]}),(0,G.jsx)(aC,{size:`sm`,variant:`soft`,color:D?.has_update?`warning`:`success`,children:D?.has_update?e(`updateAvailable`):e(`upToDate`)})]}),(0,G.jsxs)(`div`,{className:`px-5 py-5`,children:[(0,G.jsx)(ZI,{update:E}),(0,G.jsx)(JCe,{releases:I,currentVersion:D?.current_version||``,nextVersion:D?.next_version,rollbackTags:L,canRollback:P,submitting:A,onRestore:T})]})]})})})]}),(0,G.jsx)(E9,{isOpen:!!w,title:e(`restoreVersionTitle`,{version:w}),description:e(`restoreVersionHint`),confirmLabel:e(`restoreThisVersion`),cancelLabel:e(`cancel`),closeLabel:e(`close`),isPending:A,status:`warning`,confirmVariant:`primary`,onClose:()=>{A||T(``)},onConfirm:()=>{let e=w;T(``),F(e)}}),(0,G.jsx)(Y.Root,{isOpen:_,onOpenChange:e=>{!e&&!h&&y(!1)},children:(0,G.jsx)(Y.Backdrop,{variant:`blur`,isDismissable:!h,children:(0,G.jsx)(Y.Container,{placement:`center`,size:`sm`,children:(0,G.jsxs)(Y.Dialog,{children:[(0,G.jsxs)(Y.Header,{className:`items-start justify-between gap-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(Y.Heading,{className:`text-section font-semibold`,children:e(`consoleKeyRotate`)}),(0,G.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:e(`consoleKeyRotateHint`)})]}),(0,G.jsx)(Y.CloseTrigger,{isDisabled:h,"aria-label":e(`close`),className:`grid size-8 place-items-center rounded-lg text-muted hover:bg-surface-secondary`,children:(0,G.jsx)(ao,{size:16})})]}),(0,G.jsxs)(Y.Footer,{className:`justify-end`,children:[(0,G.jsx)(J,{variant:`ghost`,isDisabled:h,onPress:()=>y(!1),children:e(`cancel`)}),(0,G.jsx)(J,{variant:`danger`,isPending:h,onPress:()=>{g(!0),GCe().then(e=>{c(e),x(e.secret||``),e.secret&&o(e.secret),y(!1)}).catch(e=>{M(e instanceof Error?e.message:String(e))}).finally(()=>g(!1))},children:e(`consoleKeyRotateNow`)})]})]})})})}),(0,G.jsx)(Y.Root,{isOpen:!!b,onOpenChange:e=>{e||x(``)},children:(0,G.jsx)(Y.Backdrop,{variant:`blur`,children:(0,G.jsx)(Y.Container,{placement:`center`,size:`lg`,children:(0,G.jsxs)(Y.Dialog,{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:e(`consoleKeySecretTitle`)}),(0,G.jsx)(`p`,{className:`mt-1.5 text-body leading-6 text-muted`,children:e(`consoleKeySecretHint`)})]}),(0,G.jsx)(Y.CloseTrigger,{"aria-label":e(`close`),className:`grid size-9 place-items-center rounded-lg text-muted hover:bg-surface-secondary`,children:(0,G.jsx)(ao,{size:18})})]}),(0,G.jsx)(Y.Body,{className:`px-6 pb-2`,children:(0,G.jsx)(`code`,{className:`mono block break-all rounded-lg bg-surface-secondary px-3 py-3 text-body`,children:b})}),(0,G.jsxs)(Y.Footer,{className:`justify-end`,children:[(0,G.jsx)(J,{variant:`ghost`,onPress:()=>x(``),children:e(`close`)}),(0,G.jsxs)(J,{onPress:()=>{Z7(b),C(!0),window.setTimeout(()=>C(!1),1200)},children:[(0,G.jsx)(Di,{size:14}),e(S?`copied`:`copy`)]})]})]})})})})]})}var I9=`__all__`;function QCe(e,t){let n=t.trim().toLowerCase();return!n||e.label.toLowerCase().includes(n)||e.id.toLowerCase().includes(n)}function L9({value:e,onChange:t,ariaLabel:n,options:r,allLabel:i,searchPlaceholder:a,emptyLabel:o,loadOptions:s,className:c}){let[l,u]=(0,v.useState)(``),[d,f]=(0,v.useState)([]),[p,m]=(0,v.useState)(!1);(0,v.useEffect)(()=>{if(!s)return;let e=!1,t=window.setTimeout(()=>{m(!0),s(l.trim()).then(t=>{e||f(t)}).catch(()=>{e||f([])}).finally(()=>{e||m(!1)})},l.trim()?280:0);return()=>{e=!0,window.clearTimeout(t)}},[s,l]);let h=e||I9,g=(0,v.useMemo)(()=>{let t=s?d:r.filter(e=>QCe(e,l)),n=new Map;l.trim()||n.set(I9,{id:I9,label:i});for(let e of t)!e.id||e.id===I9||n.set(e.id,e);if(e){let t=r.find(t=>t.id===e)||d.find(t=>t.id===e)||{id:e,label:e};n.set(e,t)}return[...n.values()]},[i,s,r,l,d,e]),_=g.find(e=>e.id===h)||(e?{id:e,label:e}:{id:I9,label:i});return(0,G.jsxs)(NS,{className:[`w-fit`,c].filter(Boolean).join(` `),"aria-label":n,value:h,onChange:e=>{typeof e==`string`&&(t(e===I9?``:e),u(``))},onClear:()=>{t(``),u(``)},children:[(0,G.jsxs)(NS.Trigger,{className:`min-w-44 items-center`,children:[(0,G.jsx)(NS.Value,{className:`min-w-0 truncate`,children:({defaultChildren:e,isPlaceholder:t})=>t?e:(0,G.jsx)(`span`,{className:`truncate`,children:_.label})}),e?(0,G.jsx)(NS.ClearButton,{}):null,(0,G.jsx)(NS.Indicator,{})]}),(0,G.jsx)(NS.Popover,{className:`min-w-56`,children:(0,G.jsxs)(NS.Filter,{inputValue:l,onInputChange:u,filter:()=>!0,children:[(0,G.jsx)(PN,{"aria-label":a,className:`px-2 pt-2`,autoFocus:!0,children:(0,G.jsxs)(PN.Group,{children:[(0,G.jsx)(PN.SearchIcon,{}),(0,G.jsx)(PN.Input,{placeholder:a}),(0,G.jsx)(PN.ClearButton,{})]})}),(0,G.jsx)(oF,{children:g.length===0?(0,G.jsx)(oF.Item,{id:`__empty__`,textValue:o,isDisabled:!0,children:(0,G.jsx)(IN,{className:`block truncate text-muted`,children:p?a:o})}):g.map(e=>(0,G.jsxs)(oF.Item,{id:e.id,textValue:e.label,children:[(0,G.jsx)(IN,{className:`block truncate`,children:e.label}),e.id!==I9&&e.id!==e.label?(0,G.jsx)(`span`,{className:`mono mt-0.5 block truncate text-caption text-muted`,children:e.id}):null,(0,G.jsx)(oF.ItemIndicator,{})]},e.id))})]})})]})}function R9(){let[e,t]=(0,v.useState)([]);return(0,v.useEffect)(()=>{let e=!1;return N9().then(n=>{e||t(n.data||[])}).catch(()=>{}),()=>{e=!0}},[]),{keys:e,nameById:(0,v.useMemo)(()=>{let t=new Map;for(let n of e)t.set(n.id,n.name||n.id);return t},[e]),options:(0,v.useMemo)(()=>e.map(e=>({id:e.id,label:e.name||e.id})),[e])}}function z9(e){return e===`ok`?`success`:e===`streaming`||e===`started`||e===`incomplete`?`warning`:e===`error`||e===`canceled`?`danger`:`default`}function $Ce(e){if(e===`error`)return`danger`;if(e!==`warn`)return`ok`}function ewe(e){return e===`error`?`danger`:e===`warn`?`warning`:e===`info`?`success`:`default`}function B9(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 V9(e){let t=e.requested_reasoning?.trim()||``,n=e.resolved_reasoning?.trim()||``;return!t&&!n?``:t&&n&&t!==n?`${t} → ${n}`:n||t}function H9({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)?U9(o):null;return i==null&&a==null&&s==null?(0,G.jsx)(`span`,{className:`mono text-xs text-muted`,children:`—`}):(0,G.jsxs)(`div`,{className:`leading-4`,children:[i!=null||a!=null?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`mono text-xs`,children:[i??0,` / `,a??0]}),(0,G.jsxs)(`div`,{className:`mt-0.5 text-caption text-muted`,children:[t,` / `,n]})]}):null,s==null?null:(0,G.jsx)(`div`,{className:`mono text-caption text-success ${i!=null||a!=null?`mt-0.5`:``}`,children:r?r(s):s})]})}function twe(){return(0,G.jsxs)(`div`,{className:`space-y-5`,"aria-busy":`true`,"aria-live":`polite`,children:[(0,G.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:Array.from({length:8},(e,t)=>(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(Q,{className:`h-3 w-20`}),(0,G.jsx)(Q,{className:`h-5 w-36 max-w-full`})]},t))}),(0,G.jsxs)(`div`,{className:`space-y-3 rounded-lg bg-surface-secondary px-3 py-3`,children:[(0,G.jsx)(Q,{className:`h-3 w-24`}),(0,G.jsx)(Q,{className:`h-4 w-full`}),(0,G.jsx)(Q,{className:`h-4 w-4/5`})]}),(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsx)(Q,{className:`h-3 w-20`}),(0,G.jsx)(Q,{className:`h-16 w-full`})]})]})}function U9(e){return e==null||!Number.isFinite(e)?`—`:String(Math.round(e*1e4)/1e4)}var nwe=[`all`,`ok`,`incomplete`,`error`,`canceled`],rwe=[`all`,`quota`,`rate_limit`,`auth`,`not_ready`,`unavailable`,`invalid_request`,`model_not_available`],iwe=[`all`,`1h`,`24h`,`7d`,`custom`];function W9(e){let t=(e,t,n)=>t.includes(e??``)?e:n,n=hH(e.get(`from`)),r=hH(e.get(`to`)),i=n&&r?{start:n,end:r}:null,a=e.get(`stream`);return{requestFilter:t(e.get(`status`),nwe,`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`),rwe,`all`),timeRange:i?`custom`:t(e.get(`range`),iwe,`1h`),customRange:i}}function awe(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`?mH(e.customRange?.start):void 0,r=e.timeRange===`custom`?mH(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 owe(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 swe(){let{t:e,lang:t}=EI(),[n,r]=On(),[i]=(0,v.useState)(()=>W9(new URLSearchParams(window.location.search))),[a,o]=(0,v.useState)([]),[s,c]=(0,v.useState)([]),[l,u]=(0,v.useState)(`requests`),[d,f]=(0,v.useState)(!0),[p,m]=(0,v.useState)(!1),[h,g]=(0,v.useState)(``),[_,y]=(0,v.useState)(i.requestFilter),[b,x]=(0,v.useState)(`all`),[S,C]=(0,v.useState)(i.requestId),[w,T]=(0,v.useState)(``),[E,D]=(0,v.useState)(i.accountFilter),[O,k]=(0,v.useState)(i.apiKeyFilter),[A,j]=(0,v.useState)(``),[M,N]=(0,v.useState)(i.modelFilter),[P,F]=(0,v.useState)(i.providerFilter),[I,L]=(0,v.useState)(i.streamFilter),[R,z]=(0,v.useState)(i.errorKind),[B,V]=(0,v.useState)(i.timeRange),[H,ee]=(0,v.useState)(i.customRange),[te,ne]=(0,v.useState)(1),[re,ie]=(0,v.useState)(50),[ae,oe]=(0,v.useState)(1),[se,ce]=(0,v.useState)(50),[le,ue]=(0,v.useState)([]),[de,fe]=(0,v.useState)(0),[pe,me]=(0,v.useState)([]),[he,ge]=(0,v.useState)(0),[_e,ve]=(0,v.useState)(null),[ye,be]=(0,v.useState)(!1),[xe,Se]=(0,v.useState)(null),[Ce,we]=(0,v.useState)(!1),[Te,Ee]=(0,v.useState)(!1),[De,Oe]=(0,v.useState)(``),ke=(0,v.useRef)(0),[Ae,je]=(0,v.useState)(!1),[Me,Ne]=(0,v.useState)(!1),Pe=n.toString(),Fe=awe({requestFilter:_,requestId:S,accountFilter:E,apiKeyFilter:O,modelFilter:M,providerFilter:P,streamFilter:I,errorKind:R,timeRange:B,customRange:H}),Ie=(0,v.useRef)(Pe);(0,v.useEffect)(()=>{if(Pe===Ie.current)return;Ie.current=Pe;let e=W9(new URLSearchParams(Pe));y(e.requestFilter),C(e.requestId),D(e.accountFilter),k(e.apiKeyFilter),N(e.modelFilter),F(e.providerFilter),L(e.streamFilter),z(e.errorKind),V(e.timeRange),ee(e.customRange)},[Pe]),(0,v.useEffect)(()=>{Fe!==Ie.current&&(Ie.current=Fe,r(Fe,{replace:!0}))},[Fe,r]),(0,v.useEffect)(()=>{let e=!1;return Promise.allSettled([PI(!1),VI()]).then(([t,n])=>{e||(t.status===`fulfilled`&&o(t.value.data||[]),n.status===`fulfilled`&&c(n.value.data||[]))}),()=>{e=!0}},[]);let Le=(0,v.useMemo)(()=>{let e=new Map;for(let t of a||[])e.set(t.id,t.name||t.id);return e},[a]),Re=(0,v.useMemo)(()=>{let e=new Map;for(let t of a||[])e.set(t.id,{provider:t.provider,region:t.region});return e},[a]);function ze(t){let n=t.account_id?Re.get(t.account_id):void 0,r=t.provider||n?.provider;return r?jH(r,n?.region,e):`—`}function Be(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 Ve=(0,v.useMemo)(()=>(a||[]).map(e=>({id:e.id,label:e.name||e.id})),[a]),{nameById:He,options:Ue}=R9();function We(e){let t=e.api_key_id?.trim();return t?He.get(t)||t:`—`}let Ge=(0,v.useMemo)(()=>{let t=new Set;for(let e of a||[])e.provider&&t.add(e.provider);return P&&t.add(P),[{id:``,label:e(`logsFilterProviderAll`)},...[...t].sort().map(t=>({id:t,label:AH(t,e)}))]},[a,P,e]),Ke=(0,v.useMemo)(()=>{let e=new Map;for(let t of s||[])e.has(t.id)||e.set(t.id,{id:t.id,label:t.display_name||t.id});return[...e.values()]},[s]),qe=(0,v.useCallback)(async e=>((await QV({q:e||void 0,limit:20,offset:0})).items||[]).map(e=>({id:e.id,label:e.id})),[]),Je=!!(S||_!==`all`||E||O||M||P||I!==`all`||R!==`all`||B!==`1h`),Ye=[_,S,E,O,M,P,I,R,B,H?.start?.toString()??``,H?.end?.toString()??``,re].join(`\0`),Xe=[b,w,A,se].join(`\0`),[Ze,Qe]=(0,v.useState)(Ye),[$e,et]=(0,v.useState)(Xe);Ze!==Ye&&(Qe(Ye),ne(1)),$e!==Xe&&(et(Xe),oe(1));let tt=Math.max(1,Math.ceil(de/re)),nt=Math.min(Ze===Ye?Math.max(1,te):1,tt);te!==nt&&ne(nt);let rt=Math.max(1,Math.ceil(he/se)),it=Math.min($e===Xe?Math.max(1,ae):1,rt);ae!==it&&oe(it);let at=(0,v.useCallback)(async(e=!1)=>{e||f(!0);try{let e=S?{from:void 0,to:void 0}:B===`custom`?{from:mH(H?.start),to:mH(H?.end,!0)}:owe(B),t=await QV({status:_===`all`?void 0:_,id:S||void 0,account:E||void 0,api_key:O||void 0,model:M||void 0,provider:P||void 0,stream:I===`all`?void 0:I===`stream`,error_kind:R===`all`?void 0:R,from:e.from,to:e.to,limit:re,offset:(nt-1)*re});ue(t.items||[]),fe(t.total||0),g(``)}catch(t){e||g(t instanceof Error?t.message:String(t))}finally{e||(f(!1),m(!0))}},[_,S,E,O,M,P,I,R,B,H,nt,re]),ot=(0,v.useCallback)(async(e=!1)=>{e||f(!0);try{let e=await cce({level:b===`all`?void 0:b,q:w.trim()||void 0,account:A||void 0,limit:se,offset:(it-1)*se});me(e.items||[]),ge(e.total??0),g(``)}catch(t){e||g(t instanceof Error?t.message:String(t))}finally{e||(f(!1),m(!0))}},[b,w,A,it,se]),st=(0,v.useCallback)(async(e=!1)=>{l===`requests`?await at(e):await ot(e)},[l,at,ot]);(0,v.useEffect)(()=>{f(!0);let e=l===`runtime`&&w.trim()?280:0,t=window.setTimeout(()=>void st(!1),e);return()=>window.clearTimeout(t)},[st,l,w]),(0,v.useEffect)(()=>{if(l!==`runtime`||it!==1)return;let e=window.setInterval(()=>void ot(!0),3e3);return()=>window.clearInterval(e)},[l,it,ot]);let ct=de===0?0:(nt-1)*re+1,lt=Math.min(de,nt*re),ut=he===0?0:(it-1)*se+1,dt=Math.min(he,it*se),ft=(0,v.useMemo)(()=>l===`requests`?e(`logsShownTotal`,{shown:le.length?`${ct}–${lt}`:0,total:de}):e(`logsShownTotal`,{shown:pe.length?`${ut}–${dt}`:0,total:he}),[l,le.length,pe.length,ct,lt,de,ut,dt,he,e]);function pt(){C(``),y(`all`),D(``),k(``),N(``),F(``),L(`all`),z(`all`),V(`1h`),ee(null),ne(1)}async function mt(e){let t=++ke.current;Se(e),Oe(``),Ee(!0),we(!0);try{let n=await oce(e.id);if(ke.current!==t)return;Se(n)}catch(e){if(ke.current!==t)return;Oe(e instanceof Error?e.message:String(e))}finally{ke.current===t&&Ee(!1)}}function ht(e){ve(e),be(!0)}async function gt(){Ne(!0),XV({id:`logs-clear`,type:`loading`,title:e(`toastClearingLogs`)});try{await sce(),je(!1),await at(!1),XV({id:`logs-clear`,type:`success`,title:e(`toastLogsCleared`)})}catch(t){g(t instanceof Error?t.message:String(t)),XV({id:`logs-clear`,type:`error`,title:e(`toastFailed`),description:t instanceof Error?t.message:String(t)})}finally{Ne(!1)}}let _t=d&&(l===`requests`?le.length===0:pe.length===0);return d&&!p?(0,G.jsx)(Bse,{}):(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)(`h2`,{className:`text-title font-semibold`,children:e(`navLogs`)}),(0,G.jsx)(`p`,{className:`mt-1 max-w-2xl text-body leading-6 text-muted`,children:e(`logsLead`)})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[l===`requests`?(0,G.jsxs)(J,{size:`sm`,variant:`ghost`,onPress:()=>je(!0),isDisabled:Me||de===0,children:[(0,G.jsx)(qa,{size:14}),e(`logsClear`)]}):null,(0,G.jsxs)(J,{size:`sm`,variant:`secondary`,isPending:d,onPress:()=>void st(!1),children:[(0,G.jsx)(qr,{size:15}),e(`refresh`)]})]})]}),h?(0,G.jsx)(QI,{title:e(`failedLogs`,{msg:h})}):null,(0,G.jsxs)(_j,{selectedKey:l,onSelectionChange:e=>u(String(e)),children:[(0,G.jsx)(_j.ListContainer,{className:`w-fit`,children:(0,G.jsxs)(_j.List,{children:[(0,G.jsxs)(gj,{id:`requests`,className:`gap-1.5`,children:[(0,G.jsx)(_j.Indicator,{className:`transition-none`}),(0,G.jsx)(Ta,{size:13}),e(`logsRequests`)]}),(0,G.jsxs)(gj,{id:`runtime`,className:`gap-1.5`,children:[(0,G.jsx)(_j.Indicator,{className:`transition-none`}),(0,G.jsx)(Ga,{size:13}),e(`logsRuntime`)]})]})}),(0,G.jsxs)(_j.Panel,{id:`requests`,"data-tab-panel":`requests`,className:`space-y-4 pt-5`,children:[(0,G.jsxs)(`div`,{className:`data-toolbar flex flex-col gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,G.jsx)(pH,{value:_,onChange:e=>y(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,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[Je?(0,G.jsx)(J,{size:`sm`,variant:`ghost`,onPress:pt,children:e(`clearFilters`)}):null,(0,G.jsx)(`div`,{className:`mono text-caption text-muted`,children:ft})]})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(L9,{ariaLabel:e(`logsColAccount`),value:E,onChange:D,options:Ve,allLabel:e(`logsFilterAccountAll`),searchPlaceholder:e(`logsSearchAccount`),emptyLabel:e(`logsNoFilterOptions`)}),(0,G.jsx)(L9,{ariaLabel:e(`logsColApiKey`),value:O,onChange:k,options:Ue,allLabel:e(`logsFilterApiKeyAll`),searchPlaceholder:e(`logsSearchApiKey`),emptyLabel:e(`logsNoFilterOptions`)}),(0,G.jsx)(L9,{ariaLabel:e(`logsColModel`),value:M,onChange:N,options:Ke,allLabel:e(`logsFilterModelAll`),searchPlaceholder:e(`logsSearchModel`),emptyLabel:e(`logsNoFilterOptions`)}),(0,G.jsx)(R7,{ariaLabel:e(`logsColProvider`),value:P,onChange:F,options:Ge}),(0,G.jsx)(L9,{ariaLabel:e(`logsSearchRequestId`),value:S,onChange:C,options:S?[{id:S,label:S}]:[],allLabel:e(`logsFilterIdAll`),searchPlaceholder:e(`logsSearchRequestId`),emptyLabel:e(`logsNoFilterOptions`),loadOptions:qe,className:`min-w-56`}),(0,G.jsx)(pH,{value:I,onChange:e=>L(e),ariaLabel:e(`logsFilterStreamAll`),options:[{id:`all`,label:e(`logsFilterStreamAll`)},{id:`stream`,label:e(`logsStreamYes`)},{id:`sync`,label:e(`logsStreamNo`)}]}),(0,G.jsx)(R7,{ariaLabel:e(`errorKind`),value:R===`all`?``:R,onChange:e=>z(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,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`text-xs font-medium text-muted`,children:e(`logsTimeRange`)}),(0,G.jsx)(pH,{value:B,onChange:e=>V(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`)}]}),B===`custom`?(0,G.jsx)(gH,{className:`w-[min(100%,42rem)]`,value:H,onChange:ee,ariaLabel:e(`logsTimeRange`),fromLabel:e(`logsTimeFrom`),toLabel:e(`logsTimeTo`)}):null]})]}),(0,G.jsx)(HS,{className:`overflow-hidden p-0`,"aria-busy":d,children:_t?(0,G.jsx)(RV,{}):le.length===0?(0,G.jsx)(I7,{icon:(0,G.jsx)(la,{size:22}),title:e(Je?`logsNoMatch`:`logsEmptyRequests`),action:Je?(0,G.jsx)(J,{size:`sm`,variant:`ghost`,onPress:pt,children:e(`clearFilters`)}):null}):(0,G.jsx)(X,{children:(0,G.jsx)(X.ScrollContainer,{children:(0,G.jsxs)(X.Content,{"aria-label":e(`logsRequests`),children:[(0,G.jsxs)(X.Header,{children:[(0,G.jsx)(X.Column,{isRowHeader:!0,children:e(`logsColTime`)}),(0,G.jsx)(X.Column,{children:e(`logsColModel`)}),(0,G.jsx)(X.Column,{children:e(`logsColReasoning`)}),(0,G.jsx)(X.Column,{children:e(`logsColProvider`)}),(0,G.jsx)(X.Column,{children:e(`logsColAccount`)}),(0,G.jsx)(X.Column,{children:e(`logsColApiKey`)}),(0,G.jsx)(X.Column,{children:e(`logsColStatus`)}),(0,G.jsx)(X.Column,{children:e(`logsColStream`)}),(0,G.jsx)(X.Column,{children:e(`logsColLatency`)}),(0,G.jsx)(X.Column,{children:e(`logsColTokens`)})]}),(0,G.jsx)(X.Body,{children:le.map(n=>(0,G.jsxs)(X.Row,{className:`cursor-pointer`,onAction:()=>void mt(n),children:[(0,G.jsx)(X.Cell,{children:(0,G.jsxs)(`div`,{className:`py-1`,children:[(0,G.jsx)(`div`,{className:`mono text-xs`,children:B9(n.created_at,t)}),(0,G.jsx)(`div`,{className:`mono mt-0.5 text-caption text-muted`,children:n.id})]})}),(0,G.jsxs)(X.Cell,{children:[(0,G.jsx)(`div`,{className:`text-body font-medium`,children:n.requested_model||`—`}),n.mapped_model&&n.mapped_model!==n.requested_model?(0,G.jsx)(`div`,{className:`mono mt-0.5 text-caption text-muted`,children:n.mapped_model}):null]}),(0,G.jsx)(X.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-xs`,children:V9(n)||`—`})}),(0,G.jsx)(X.Cell,{children:(0,G.jsx)(`span`,{className:`text-xs`,children:ze(n)})}),(0,G.jsxs)(X.Cell,{children:[(0,G.jsx)(`span`,{className:`text-xs`,children:n.account_id?Le.get(n.account_id)||n.account_id:`—`}),n.account_id&&Le.get(n.account_id)&&Le.get(n.account_id)!==n.account_id?(0,G.jsx)(`div`,{className:`mono mt-0.5 text-caption text-muted`,children:n.account_id}):null]}),(0,G.jsx)(X.Cell,{children:(0,G.jsx)(`span`,{className:`text-xs`,children:We(n)})}),(0,G.jsxs)(X.Cell,{children:[(0,G.jsx)(aC,{size:`sm`,variant:`soft`,color:z9(n.status),children:n.status}),n.error_kind?(0,G.jsx)(`div`,{className:`mono mt-1 text-caption text-muted`,children:n.error_kind}):null]}),(0,G.jsx)(X.Cell,{children:(0,G.jsx)(`span`,{className:`text-xs text-muted`,children:n.stream?e(`logsStreamYes`):e(`logsStreamNo`)})}),(0,G.jsx)(X.Cell,{children:(0,G.jsx)(n9,{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,G.jsx)(X.Cell,{children:(0,G.jsx)(H9,{log:n,inLabel:e(`logsTokensIn`),outLabel:e(`logsTokensOut`),pointsLabel:t=>e(`logsTokensPoints`,{value:t})})})]},n.id))})]})})})}),(0,G.jsx)(z7,{total:de,page:nt,pageCount:tt,pageSize:re,loading:d,pageSizeLabel:e(`logsPageSize`),pageLabel:e(`logsPage`,{page:nt,pages:tt}),prevLabel:e(`logsPrevPage`),nextLabel:e(`logsNextPage`),onPage:ne,onPageSize:ie})]}),(0,G.jsxs)(_j.Panel,{id:`runtime`,"data-tab-panel":`runtime`,className:`space-y-4 pt-5`,children:[(0,G.jsxs)(`div`,{className:`data-toolbar flex flex-wrap items-center justify-between gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(B7,{className:`sm:w-72`,value:w,onChange:T,placeholder:e(`logsSearchRuntime`),ariaLabel:e(`logsSearchRuntime`)}),(0,G.jsx)(L9,{ariaLabel:e(`logsColAccount`),value:A,onChange:j,options:Ve,allLabel:e(`logsFilterAccountAll`),searchPlaceholder:e(`logsSearchAccount`),emptyLabel:e(`logsNoFilterOptions`)}),(0,G.jsx)(pH,{value:b,onChange:e=>x(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,G.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted`,children:[it===1?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`status-dot`,"data-state":`ok`}),e(`logsAutoRefresh`)]}):null,(0,G.jsx)(`span`,{className:`mono`,children:ft})]})]}),(0,G.jsx)(HS,{className:`overflow-hidden p-0`,"aria-busy":d,children:_t?(0,G.jsx)(zse,{}):pe.length===0?(0,G.jsx)(I7,{icon:(0,G.jsx)(Ga,{size:22}),title:e(`logsEmptyRuntime`)}):(0,G.jsx)(`div`,{className:`divide-y divide-separator`,children:pe.map(e=>(0,G.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:()=>ht(e),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),ht(e))},children:[(0,G.jsx)(`div`,{className:`mono text-caption text-muted`,children:B9(e.time,t)}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,G.jsx)(`span`,{className:`status-dot`,"data-state":$Ce(e.level)}),(0,G.jsx)(`span`,{className:`font-medium text-muted`,children:e.level})]}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[e.account_id?(0,G.jsx)(`div`,{className:`mono mb-1 text-caption text-muted`,children:e.account_id}):null,(0,G.jsx)(`div`,{className:`mono break-all text-xs leading-5 text-foreground`,children:e.message})]})]},e.id))})}),(0,G.jsx)(z7,{total:he,page:it,pageCount:rt,pageSize:se,loading:d,pageSizeLabel:e(`logsPageSize`),pageLabel:e(`logsPage`,{page:it,pages:rt}),prevLabel:e(`logsPrevPage`),nextLabel:e(`logsNextPage`),onPage:oe,onPageSize:ce})]})]}),(0,G.jsx)(Y.Root,{isOpen:ye,onOpenChange:e=>{be(e),e||ve(null)},children:(0,G.jsx)(Y.Backdrop,{variant:`blur`,children:(0,G.jsx)(Y.Container,{size:`lg`,scroll:`inside`,children:(0,G.jsxs)(Y.Dialog,{className:`w-full max-w-4xl`,children:[(0,G.jsxs)(Y.Header,{className:`items-start justify-between gap-4 px-5 pt-5`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(Y.Heading,{className:`text-section font-semibold`,children:e(`logsRuntimeDetailTitle`)}),(0,G.jsx)(`p`,{className:`mono mt-1 text-caption text-muted`,children:_e?`#${_e.id}`:`—`})]}),(0,G.jsx)(Y.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,G.jsx)(ao,{size:16})})]}),(0,G.jsxs)(Y.Body,{className:`space-y-5 px-5 pb-5`,children:[(0,G.jsx)(`dl`,{className:`grid gap-3 sm:grid-cols-2`,children:[[e(`logsColTime`),_e?B9(_e.time,t):`—`],[e(`logsRuntimeLevel`),_e?.level||`—`],[e(`logsRuntimeSource`),_e?.source||`—`],[e(`logsColAccount`),_e?.account_id||`—`]].map(([t,n])=>(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{className:`text-caption text-muted`,children:t}),(0,G.jsx)(`dd`,{className:`mt-1 break-all text-body font-medium`,children:t===e(`logsRuntimeLevel`)&&_e?(0,G.jsx)(aC,{size:`sm`,variant:`soft`,color:ewe(_e.level),children:_e.level}):n})]},String(t)))}),(0,G.jsxs)(`section`,{className:`space-y-2`,children:[(0,G.jsx)(`div`,{className:`text-xs font-medium text-muted`,children:e(`logsRuntimeMessage`)}),(0,G.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:_e?.message||`—`})]})]})]})})})}),(0,G.jsx)(Y.Root,{isOpen:Ce,onOpenChange:e=>{we(e),e||(ke.current+=1,Ee(!1),Oe(``),Se(null))},children:(0,G.jsx)(Y.Backdrop,{variant:`blur`,children:(0,G.jsx)(Y.Container,{size:`lg`,scroll:`inside`,children:(0,G.jsxs)(Y.Dialog,{className:`w-full max-w-4xl`,children:[(0,G.jsxs)(Y.Header,{className:`items-start justify-between gap-4 px-5 pt-5`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(Y.Heading,{className:`text-section font-semibold`,children:e(`logsDetailTitle`)}),(0,G.jsx)(`p`,{className:`mono mt-1 text-caption text-muted`,children:xe?.id})]}),(0,G.jsx)(Y.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,G.jsx)(ao,{size:16})})]}),(0,G.jsx)(Y.Body,{className:`space-y-4 px-5 pb-5`,children:Te?(0,G.jsx)(twe,{}):De?(0,G.jsx)(QI,{title:e(`requestFailed`),description:De}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`dl`,{className:`grid gap-3 sm:grid-cols-2`,children:[[[e(`logsColStatus`),xe?.status||`—`],[e(`logsColModel`),xe?.requested_model||`—`],[e(`logsColReasoning`),xe&&V9(xe)||`—`],[e(`logsColProvider`),xe?ze(xe):`—`],[e(`logsColAccount`),xe?.account_id?Le.get(xe.account_id)||xe.account_id:`—`],[e(`logsColApiKey`),xe?We(xe):`—`],[e(`logsColStream`),xe?.stream?e(`logsStreamYes`):e(`logsStreamNo`)],[e(`logsRouting`),xe?Be(xe.routing):`—`]].map(([e,t])=>(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{className:`text-caption text-muted`,children:e}),(0,G.jsx)(`dd`,{className:`mt-1 break-all text-body font-medium`,children:t})]},String(e))),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{className:`text-caption text-muted`,children:e(`logsColTokens`)}),(0,G.jsx)(`dd`,{className:`mt-1`,children:xe?(0,G.jsx)(H9,{log:xe,inLabel:e(`logsTokensIn`),outLabel:e(`logsTokensOut`),pointsLabel:t=>e(`logsTokensPoints`,{value:t})}):`—`})]}),(0,G.jsx)(`div`,{className:`sm:col-span-2`,children:(0,G.jsx)(n9,{latencyMs:xe?.latency_ms,ttfbMs:xe?.ttfb_ms,completionTokens:xe?.completion_tokens,stream:xe?.stream,labels:{heading:e(`logsColLatency`),ttft:e(`logsColTTFT`),total:e(`logsLatencyTotal`),tps:e(`logsOutputTPS`)}})})]}),xe&&xe.message_count?(0,G.jsxs)(`div`,{className:`rounded-lg bg-surface-secondary px-3 py-3 text-xs`,children:[(0,G.jsx)(`div`,{className:`font-medium text-muted`,children:e(`logsMessageShape`)}),(0,G.jsxs)(`dl`,{className:`mt-2 grid gap-2 sm:grid-cols-2`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{className:`text-caption text-muted`,children:e(`logsMessageCount`)}),(0,G.jsx)(`dd`,{className:`mono mt-0.5`,children:xe.message_count})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{className:`text-caption text-muted`,children:e(`logsEmptyMessageIndexes`)}),(0,G.jsx)(`dd`,{className:`mono mt-0.5 break-all`,children:xe.empty_message_indexes?.length?xe.empty_message_indexes.join(`, `):`—`})]}),(0,G.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,G.jsx)(`dt`,{className:`text-caption text-muted`,children:e(`logsMessageRoles`)}),(0,G.jsx)(`dd`,{className:`mono mt-0.5 break-all`,children:xe.message_roles?.join(` → `)||`—`})]})]})]}):null,xe?.error_message?(0,G.jsxs)(`div`,{className:`rounded-lg bg-surface-secondary px-3 py-2 text-xs leading-5 text-muted`,children:[xe.error_kind?(0,G.jsx)(`span`,{className:`mono mr-2 text-muted`,children:xe.error_kind}):null,xe.error_message]}):null,xe?.stream_diagnostic?(0,G.jsxs)(`div`,{className:`rounded-lg bg-surface-secondary px-3 py-3 text-xs`,children:[(0,G.jsx)(`div`,{className:`font-medium text-muted`,children:e(`logsStreamDiagnostics`)}),(0,G.jsx)(`dl`,{className:`mt-2 grid gap-2 sm:grid-cols-2`,children:[[e(`logsCancellationSource`),xe.stream_diagnostic.cancellation_source||`—`],[e(`logsUpstreamStatus`),xe.stream_diagnostic.upstream_status??`—`],[e(`logsSSEEvents`),xe.stream_diagnostic.sse_event_count],[e(`logsBytesRead`),xe.stream_diagnostic.bytes_read],[e(`logsLastEvent`),xe.stream_diagnostic.last_event||`—`],[e(`logsStreamComplete`),xe.stream_diagnostic.saw_done?`yes`:`no`]].map(([e,t])=>(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{className:`text-caption text-muted`,children:e}),(0,G.jsx)(`dd`,{className:`mono mt-0.5 break-all`,children:t})]},String(e)))}),xe.stream_diagnostic.context_err||xe.stream_diagnostic.relay_error?(0,G.jsxs)(`div`,{className:`mt-2 space-y-1 break-all text-muted`,children:[xe.stream_diagnostic.context_err?(0,G.jsxs)(`div`,{children:[`context: `,xe.stream_diagnostic.context_err]}):null,xe.stream_diagnostic.relay_error?(0,G.jsxs)(`div`,{children:[`relay: `,xe.stream_diagnostic.relay_error]}):null]}):null]}):null,xe?.usage_detail?(0,G.jsxs)(`div`,{className:`rounded-lg bg-surface-secondary px-3 py-3 text-xs`,children:[(0,G.jsx)(`div`,{className:`font-medium text-muted`,children:e(`logsUsageDetail`)}),(0,G.jsx)(`dl`,{className:`mt-2 grid gap-2 sm:grid-cols-2`,children:[[e(`logsCreditConsumed`),`${U9(xe.usage_detail.credit)} ${xe.usage_detail.unit||`credits`}`],[e(`logsColProvider`),xe.usage_detail.provider||`—`]].map(([e,t])=>(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{className:`text-caption text-muted`,children:e}),(0,G.jsx)(`dd`,{className:`mono mt-0.5 break-all`,children:t})]},String(e)))})]}):null,(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-xs font-medium text-muted`,children:e(`logsAttempts`)}),xe?.attempts?.length?(0,G.jsx)(`div`,{className:`mt-2 divide-y divide-separator overflow-hidden rounded-lg bg-surface-secondary`,children:xe.attempts.map(e=>(0,G.jsxs)(`div`,{className:`grid gap-1 px-3 py-2.5 text-xs sm:grid-cols-[48px_minmax(0,1fr)_auto]`,children:[(0,G.jsxs)(`div`,{className:`mono text-muted`,children:[`#`,e.attempt_index]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`font-medium`,children:e.account_id||`—`}),(0,G.jsx)(`div`,{className:`mt-0.5 text-muted`,children:e.error_message||e.status})]}),(0,G.jsx)(aC,{size:`sm`,variant:`soft`,color:z9(e.status===`failover`?`canceled`:e.status),children:e.status})]},e.id))}):(0,G.jsx)(`p`,{className:`mt-2 text-xs text-muted`,children:e(`logsNoAttempts`)})]})]})})]})})})}),(0,G.jsx)(E9,{isOpen:Ae,title:e(`logsClear`),description:e(`logsClearConfirm`),confirmLabel:e(`logsClear`),cancelLabel:e(`close`),closeLabel:e(`close`),isPending:Me,onClose:()=>je(!1),onConfirm:()=>void gt()})]})}var G9=864e5,cwe=8;function K9(e){return`var(--chart-${e%cwe+1})`}function q9(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime()}function J9(e){return e<10?`0${e}`:String(e)}function Y9(e){let t=new Date(e);return`${t.getFullYear()}-${J9(t.getMonth()+1)}-${J9(t.getDate())}`}function lwe({accounts:e,t}){let[n,r]=(0,v.useState)(!1),{buckets:i,rows:a,todayStart:o,maxTotal:s}=(0,v.useMemo)(()=>{let t=q9(new Date),n=new Map;e.forEach((e,t)=>n.set(e.id,K9(t)));let r=new Map,i=[];for(let a of e){let e=a.quota?.packages??[],o=n.get(a.id)||K9(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=q9(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=Y9(q9(new Date(l)));for(let t of c)Y9(q9(new Date(t.ends_at*1e3)))===e&&(u+=t.remain??0)}let p=l?Math.max(0,Math.round((q9(new Date(l))-t)/G9)):-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(!a.some(e=>e.packs>0))return null;let c=n?i:i.slice(0,8);return(0,G.jsxs)(HS,{className:`overflow-hidden p-0`,"data-gsap-reveal":!0,children:[(0,G.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,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`h3`,{className:`font-semibold`,children:t(`expiryDistTitle`)}),(0,G.jsx)(`p`,{className:`mt-0.5 text-xs text-muted`,children:t(`expiryDistHint`)})]}),i.length>8?(0,G.jsx)(J,{size:`sm`,variant:`ghost`,onPress:()=>r(e=>!e),children:n?t(`expiryDistCollapse`):t(`expiryDistExpand`,{n:i.length})}):null]}),(0,G.jsxs)(`div`,{className:`space-y-4 p-4 sm:space-y-3 sm:p-5`,children:[(0,G.jsx)(`div`,{className:`space-y-2.5 sm:space-y-1.5`,children:c.map(e=>{let n=e.ts===o,r=s>0?e.total/s*100:0;return(0,G.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,G.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 sm:contents`,children:[(0,G.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,G.jsx)(`span`,{className:`mono text-caption text-foreground sm:hidden`,children:m9(e.total)})]}),(0,G.jsx)(`div`,{className:`h-2.5 w-full rounded-full bg-surface-tertiary`,role:`img`,"aria-label":`${e.day} ${t(`expiryDistDayTotal`,{n:m9(e.total)})}`,title:e.day,children:(0,G.jsx)(`div`,{className:`flex h-full items-stretch overflow-hidden rounded-full`,style:{width:`${r}%`},children:e.segments.map(t=>(0,G.jsx)(`span`,{style:{width:`${t.remain/e.total*100}%`,backgroundColor:t.color},title:`${t.name} · ${m9(t.remain)}`},t.id))})}),(0,G.jsx)(`span`,{className:`mono hidden text-caption text-foreground sm:inline`,children:m9(e.total)})]},e.day)})}),(0,G.jsx)(`div`,{className:`flex flex-wrap gap-x-3 gap-y-1.5 pt-1`,children:a.filter(e=>e.remain>0).map(e=>(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-caption text-muted`,children:[(0,G.jsx)(`i`,{className:`size-2 rounded-[3px]`,style:{backgroundColor:e.color}}),(0,G.jsx)(`span`,{className:`max-w-[120px] truncate`,children:e.name})]},e.id))}),(0,G.jsx)(`div`,{className:`divide-y divide-separator md:hidden`,children:a.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,G.jsxs)(`article`,{className:`space-y-3 py-3.5`,children:[(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,G.jsx)(`i`,{className:`size-2 shrink-0 rounded-[3px]`,style:{backgroundColor:e.color}}),(0,G.jsx)(`span`,{className:`truncate text-body font-medium text-foreground`,children:e.name})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-4 gap-y-3`,children:[(0,G.jsxs)(`div`,{className:`space-y-1`,children:[(0,G.jsx)(`div`,{className:`text-caption text-muted`,children:t(`expiryDistColSoonest`)}),(0,G.jsx)(`div`,{className:`mono text-body text-muted`,children:i?`${i.getMonth()+1}/${i.getDate()}`:`—`})]}),(0,G.jsxs)(`div`,{className:`space-y-1`,children:[(0,G.jsx)(`div`,{className:`text-caption text-muted`,children:t(`expiryDistColDaysLeft`)}),(0,G.jsx)(`div`,{className:`mono text-body ${a}`,children:o})]}),(0,G.jsxs)(`div`,{className:`space-y-1`,children:[(0,G.jsx)(`div`,{className:`text-caption text-muted`,children:t(`expiryDistColBatch`)}),(0,G.jsx)(`div`,{className:`mono text-body text-foreground`,children:m9(e.soonestRemain)})]}),(0,G.jsxs)(`div`,{className:`space-y-1`,children:[(0,G.jsx)(`div`,{className:`text-caption text-muted`,children:t(`expiryDistColDaily`)}),(0,G.jsx)(`div`,{className:`mono text-body text-foreground`,children:e.soonest?m9(e.dailyBurn):`—`})]})]})]},e.id)})}),(0,G.jsx)(X,{"aria-label":t(`expiryDistTitle`),className:`hidden md:block`,children:(0,G.jsx)(X.ScrollContainer,{className:`min-w-0 overflow-x-auto`,children:(0,G.jsxs)(X.Content,{className:`min-w-[32rem]`,children:[(0,G.jsxs)(X.Header,{children:[(0,G.jsx)(X.Column,{isRowHeader:!0,children:t(`expiryDistColAccount`)}),(0,G.jsx)(X.Column,{children:(0,G.jsx)(`div`,{className:`text-center`,children:t(`expiryDistColSoonest`)})}),(0,G.jsx)(X.Column,{children:(0,G.jsx)(`div`,{className:`text-center`,children:t(`expiryDistColDaysLeft`)})}),(0,G.jsx)(X.Column,{children:(0,G.jsx)(`div`,{className:`text-center`,children:t(`expiryDistColBatch`)})}),(0,G.jsx)(X.Column,{children:(0,G.jsx)(`div`,{className:`text-center`,children:t(`expiryDistColDaily`)})})]}),(0,G.jsx)(X.Body,{children:a.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,G.jsxs)(X.Row,{children:[(0,G.jsx)(X.Cell,{children:(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,G.jsx)(`i`,{className:`size-2 shrink-0 rounded-[3px]`,style:{backgroundColor:e.color}}),(0,G.jsx)(`span`,{className:`max-w-[150px] truncate text-foreground`,children:e.name})]})}),(0,G.jsx)(X.Cell,{children:(0,G.jsx)(`div`,{className:`mono text-center text-muted`,children:i?`${i.getMonth()+1}/${i.getDate()}`:`—`})}),(0,G.jsx)(X.Cell,{children:(0,G.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,G.jsx)(X.Cell,{children:(0,G.jsx)(`div`,{className:`mono text-center text-foreground`,children:m9(e.soonestRemain)})}),(0,G.jsx)(X.Cell,{children:(0,G.jsx)(`div`,{className:`mono text-center text-foreground`,children:e.soonest?m9(e.dailyBurn):`—`})})]},e.id)})})]})})}),(0,G.jsx)(`p`,{className:`text-caption text-muted`,children:t(`expiryDistFoot`)})]})]})}function uwe(){return NI(`/api/usage/pricing`)}function dwe(e={}){let t=new URLSearchParams;return e.from&&t.set(`from`,e.from),e.to&&t.set(`to`,e.to),e.api_key&&t.set(`api_key`,e.api_key),NI(`/api/usage/cost${t.toString()?`?${t}`:``}`)}var X9=(0,v.lazy)(()=>C(()=>import(`./CostChart-HjooRbfZ.js`).then(e=>({default:e.CostChart})),__vite__mapDeps([2,1])));function fwe(){let e=new Date;return e.setHours(0,0,0,0),e.toISOString()}var pwe={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 mwe(e,t){if(!t)return`0%`;let n=e/t*100;return`${n>=10?n.toFixed(0):n.toFixed(1)}%`}function hwe({apiKeyFilter:e=``}){let{t,lang:n}=EI(),[r,i]=(0,v.useState)(`today`),[a,o]=(0,v.useState)(`credits`),[s,c]=(0,v.useState)(null),[l,u]=(0,v.useState)(null),[d,f]=(0,v.useState)(!0),[p,m]=(0,v.useState)(``);(0,v.useEffect)(()=>{let e=!1;return uwe().then(t=>{e||u(t)}).catch(()=>{}),()=>{e=!0}},[]);let h=(0,v.useCallback)(async()=>{f(!0);try{let t=await dwe({...r===`all`?{}:r===`today`?{from:fwe()}:{from:new Date(Date.now()-Number(r)*3600*1e3).toISOString(),to:new Date().toISOString()},api_key:e||void 0});c(t),m(``)}catch(e){c(null),m(e instanceof Error?e.message:String(e))}finally{f(!1)}},[r,e]);(0,v.useEffect)(()=>{h()},[h]);let g=s??pwe,_=g.totals,y=_.requests>0&&g.models.length>0,b=g.models.filter(e=>e.priced),x=_.cost>0,S=[{label:t(`usageCredits`),value:cH(_.credits),detail:t(`usageCreditsHint`)},{label:t(`usageTotalTokens`),value:$V(_.total_tokens),detail:`${$V(_.cache_hit)} / ${$V(_.cache_miss)} / ${$V(_.output)} ${t(`usageTokenSplitNote`)}`},{label:t(`usageRequests`),value:String(_.requests),detail:t(`usageModelCount`,{count:g.models.length})},{label:t(`usageCacheHitRate`),value:mwe(_.cache_hit,_.cache_hit+_.cache_miss),detail:$V(_.cache_hit)}],C=a===`credits`?cH(_.credits):a===`tokens`?$V(_.total_tokens):oH(_.cost);return(0,G.jsxs)(`div`,{className:`space-y-6`,children:[(0,G.jsxs)(`section`,{className:`flex flex-wrap items-center justify-end gap-3 pb-2`,children:[(0,G.jsx)(pH,{value:r,onChange:e=>i(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,G.jsxs)(J,{size:`sm`,variant:`secondary`,onPress:()=>void h(),isDisabled:d,children:[(0,G.jsx)(qr,{size:14}),t(`refresh`)]})]}),p?(0,G.jsx)(QI,{title:t(`failedStats`,{msg:p})}):null,(0,G.jsx)(`section`,{className:`grid gap-3 sm:grid-cols-2 sm:gap-4 xl:grid-cols-4`,children:S.map(e=>(0,G.jsxs)(HS,{className:`gap-0 p-4`,children:[(0,G.jsx)(`div`,{className:`text-body text-muted`,children:e.label}),(0,G.jsx)(`div`,{className:`tabular mt-1.5 text-section font-semibold`,children:d?(0,G.jsx)(Q,{className:`h-5 w-16`}):e.value}),(0,G.jsx)(`div`,{className:`mono mt-1 truncate text-caption text-muted`,children:d?(0,G.jsx)(Q,{className:`h-3 w-24`}):e.detail||`\xA0`})]},e.label))}),(0,G.jsxs)(HS,{className:`overflow-hidden p-0`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-b border-separator px-5 py-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`font-semibold tracking-[-0.015em]`,children:t(`usageChartTitle`)}),(0,G.jsx)(`p`,{className:`mt-0.5 text-xs text-muted`,children:t(`usageChartHint`)})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,G.jsx)(pH,{value:a,onChange:e=>o(e),ariaLabel:t(`usageChartMetric`),options:[{id:`credits`,label:t(`usageColCredits`)},{id:`tokens`,label:t(`usageColTokens`)}]}),(0,G.jsx)(aC,{size:`sm`,variant:`soft`,color:`default`,children:C})]})]}),(0,G.jsx)(`div`,{className:`p-5`,children:d?(0,G.jsx)(`div`,{className:`grid h-72 place-items-center`,children:(0,G.jsx)(Q,{className:`h-56 w-full`})}):y?(0,G.jsx)(v.Suspense,{fallback:(0,G.jsx)(`div`,{className:`grid h-72 place-items-center`,children:(0,G.jsx)(Q,{className:`h-56 w-full`})}),children:(0,G.jsx)(X9,{series:g.series,models:g.models,lang:n,emptyLabel:t(`usageChartEmpty`),totalLabel:t(`usageTotals`),metric:a})}):(0,G.jsx)(I7,{title:t(`usageEmpty`),hint:t(`usageRetentionHint`)})})]}),(0,G.jsxs)(HS,{className:`overflow-hidden p-0`,children:[(0,G.jsx)(`div`,{className:`flex items-center justify-between gap-3 border-b border-separator px-5 py-4`,children:(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`font-semibold tracking-[-0.015em]`,children:t(`usageBreakdownTitle`)}),(0,G.jsx)(`p`,{className:`mt-0.5 text-xs text-muted`,children:t(`usageBreakdownHint`)})]})}),d?(0,G.jsx)(`div`,{className:`space-y-3 p-5`,children:[0,1,2].map(e=>(0,G.jsx)(Q,{className:`h-9 w-full`},e))}):y?(0,G.jsx)(X,{children:(0,G.jsx)(X.ScrollContainer,{children:(0,G.jsxs)(X.Content,{"aria-label":t(`usageBreakdownTitle`),children:[(0,G.jsxs)(X.Header,{children:[(0,G.jsx)(X.Column,{isRowHeader:!0,children:t(`usageColModel`)}),(0,G.jsx)(X.Column,{children:t(`usageColRequests`)}),(0,G.jsx)(X.Column,{children:t(`usageColInputHit`)}),(0,G.jsx)(X.Column,{children:t(`usageColInputMiss`)}),(0,G.jsx)(X.Column,{children:t(`usageColOutput`)}),(0,G.jsx)(X.Column,{children:t(`usageColTokens`)}),(0,G.jsx)(X.Column,{children:t(`usageColCredits`)})]}),(0,G.jsxs)(X.Body,{children:[g.models.map(e=>(0,G.jsxs)(X.Row,{children:[(0,G.jsxs)(X.Cell,{children:[(0,G.jsx)(`div`,{className:`text-sm font-medium`,children:e.label}),(0,G.jsx)(`div`,{className:`mono mt-0.5 text-[10px] text-muted`,children:e.id})]}),(0,G.jsx)(X.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-xs`,children:e.requests})}),(0,G.jsx)(X.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-xs`,children:$V(e.cache_hit)})}),(0,G.jsx)(X.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-xs`,children:$V(e.cache_miss)})}),(0,G.jsx)(X.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-xs`,children:$V(e.output)})}),(0,G.jsx)(X.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-xs`,children:$V(e.total_tokens)})}),(0,G.jsx)(X.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-xs font-semibold`,children:cH(e.credits)})})]},e.id)),(0,G.jsxs)(X.Row,{children:[(0,G.jsx)(X.Cell,{children:(0,G.jsx)(`span`,{className:`text-sm font-semibold`,children:t(`usageTotals`)})}),(0,G.jsx)(X.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-xs font-semibold`,children:_.requests})}),(0,G.jsx)(X.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-xs font-semibold`,children:$V(_.cache_hit)})}),(0,G.jsx)(X.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-xs font-semibold`,children:$V(_.cache_miss)})}),(0,G.jsx)(X.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-xs font-semibold`,children:$V(_.output)})}),(0,G.jsx)(X.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-xs font-semibold`,children:$V(_.total_tokens)})}),(0,G.jsx)(X.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-xs font-semibold`,children:cH(_.credits)})})]})]})]})})}):(0,G.jsx)(I7,{title:t(`usageEmpty`),hint:t(`usageRetentionHint`)})]}),(0,G.jsx)(vh,{className:`rounded-xl bg-surface-secondary`,hideSeparator:!0,defaultExpandedKeys:[],children:(0,G.jsxs)(vh.Item,{id:`deepseek-estimate`,children:[(0,G.jsx)(vh.Heading,{children:(0,G.jsxs)(vh.Trigger,{className:`items-center gap-3 px-5 py-4 text-left`,children:[(0,G.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`span`,{className:`block font-semibold tracking-[-0.015em]`,children:t(`usageEstimateTitle`)}),(0,G.jsx)(`span`,{className:`mt-0.5 block text-xs text-muted`,children:t(`usageEstimateHint`)})]}),x?(0,G.jsx)(aC,{size:`sm`,variant:`soft`,color:`default`,children:oH(_.cost)}):null,(0,G.jsx)(vh.Indicator,{})]})}),(0,G.jsx)(vh.Panel,{children:(0,G.jsxs)(vh.Body,{className:`space-y-5 px-5 pb-5`,children:[(0,G.jsx)(`p`,{className:`text-xs leading-6 text-muted`,children:t(`usageRenderNote`)}),x?(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,G.jsx)(`h4`,{className:`text-sm font-medium`,children:t(`usageEstimateChartTitle`)}),(0,G.jsx)(aC,{size:`sm`,variant:`soft`,color:`default`,children:oH(_.cost)})]}),(0,G.jsx)(v.Suspense,{fallback:(0,G.jsx)(Q,{className:`h-56 w-full`}),children:(0,G.jsx)(X9,{series:g.series,models:b.length?b:g.models,lang:n,emptyLabel:t(`usageEstimateChartEmpty`),totalLabel:t(`usageTotals`),metric:`cost`})})]}):null,b.length?(0,G.jsx)(X,{children:(0,G.jsx)(X.ScrollContainer,{children:(0,G.jsxs)(X.Content,{"aria-label":t(`usageEstimateTitle`),children:[(0,G.jsxs)(X.Header,{children:[(0,G.jsx)(X.Column,{isRowHeader:!0,children:t(`usageColModel`)}),(0,G.jsx)(X.Column,{children:t(`usageColSplit`)}),(0,G.jsx)(X.Column,{children:t(`usageColCost`)})]}),(0,G.jsxs)(X.Body,{children:[b.map(e=>(0,G.jsxs)(X.Row,{children:[(0,G.jsxs)(X.Cell,{children:[(0,G.jsx)(`div`,{className:`text-sm font-medium`,children:e.label}),(0,G.jsx)(`div`,{className:`mono mt-0.5 text-[10px] text-muted`,children:e.id})]}),(0,G.jsx)(X.Cell,{children:(0,G.jsxs)(`span`,{className:`mono text-xs text-muted`,children:[oH(e.cost_peak),` / `,oH(e.cost_off_peak)]})}),(0,G.jsx)(X.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-sm font-semibold`,children:oH(e.cost)})})]},e.id)),(0,G.jsxs)(X.Row,{children:[(0,G.jsx)(X.Cell,{children:(0,G.jsx)(`span`,{className:`text-sm font-semibold`,children:t(`usageTotals`)})}),(0,G.jsx)(X.Cell,{children:(0,G.jsxs)(`span`,{className:`mono text-xs text-muted`,children:[oH(_.cost_peak),` / `,oH(_.cost_off_peak)]})}),(0,G.jsx)(X.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-sm font-semibold`,children:oH(_.cost)})})]})]})]})})}):(0,G.jsx)(`p`,{className:`text-xs text-muted`,children:t(`usageEstimateChartEmpty`)}),(0,G.jsxs)(`div`,{className:`grid gap-5 xl:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h4`,{className:`mb-2 text-sm font-medium`,children:t(`usagePriceTitle`)}),(0,G.jsx)(`p`,{className:`mb-3 text-xs text-muted`,children:t(`usagePeakNote`)}),(0,G.jsxs)(`div`,{className:`divide-y divide-separator rounded-lg bg-background`,children:[(l?.models??[]).map(e=>(0,G.jsxs)(`div`,{className:`px-4 py-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,G.jsx)(`div`,{className:`text-sm font-medium`,children:e.label}),(0,G.jsx)(`span`,{className:`mono text-[10px] text-muted`,children:e.currency})]}),(0,G.jsx)(`div`,{className:`mono mt-1 text-[10px] text-muted`,children:e.id}),(0,G.jsxs)(`div`,{className:`mt-2 grid grid-cols-2 gap-2 text-[11px]`,children:[(0,G.jsxs)(`div`,{className:`rounded-lg bg-surface-secondary px-2.5 py-2`,children:[(0,G.jsx)(`div`,{className:`text-[10px] text-muted`,children:t(`usagePriceBandOff`)}),(0,G.jsxs)(`div`,{className:`mono mt-0.5`,children:[sH(e.off_peak.cache_hit),` · `,sH(e.off_peak.cache_miss),` · `,sH(e.off_peak.output)]}),(0,G.jsxs)(`div`,{className:`mt-1 text-[9px] text-muted`,children:[t(`usagePriceHit`),` · `,t(`usagePriceMiss`),` · `,t(`usagePriceOutput`)]})]}),(0,G.jsxs)(`div`,{className:`rounded-lg bg-surface-secondary px-2.5 py-2`,children:[(0,G.jsx)(`div`,{className:`text-[10px] text-muted`,children:t(`usagePriceBandPeak`)}),(0,G.jsxs)(`div`,{className:`mono mt-0.5`,children:[sH(e.peak.cache_hit),` · `,sH(e.peak.cache_miss),` · `,sH(e.peak.output)]}),(0,G.jsxs)(`div`,{className:`mt-1 text-[9px] text-muted`,children:[t(`usagePriceHit`),` · `,t(`usagePriceMiss`),` · `,t(`usagePriceOutput`)]})]})]})]},e.id)),l?.models?.length?null:(0,G.jsx)(`div`,{className:`px-4 py-6 text-sm text-muted`,children:t(`usageEmpty`)})]})]}),(0,G.jsxs)(`div`,{className:`space-y-3 text-xs leading-6 text-muted`,children:[(0,G.jsx)(`h4`,{className:`text-sm font-medium text-foreground`,children:t(`usageNoteTitle`)}),(0,G.jsx)(`p`,{children:t(`usageRetentionHint`)}),(0,G.jsx)(`p`,{children:t(`usagePeakNote`)}),g.unpriced?.length?(0,G.jsx)(`p`,{children:t(`usageUnpricedHint`,{models:g.unpriced.join(`, `)})}):null,l?.note?(0,G.jsx)(`p`,{className:`mono text-[10px]`,children:l.note}):null]})]})]})})]})})]})}var gwe=500,_we={model:`model`,account:`account`,provider:`provider`};function vwe(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:{[_we[t]]:e.key}}}function ywe(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 Z9(e){return e?e>=1e3?$V(e):String(Math.round(e*100)/100):`0`}function bwe(){let{t:e}=EI(),t=at(),[n,r]=On(),[i,a]=(0,v.useState)(`stats`),[o,s]=(0,v.useState)(`model`),[c,l]=(0,v.useState)(`today`),[u,d]=(0,v.useState)(null),[f,p]=(0,v.useState)(null),[m,h]=(0,v.useState)(!0),[g,_]=(0,v.useState)(``),[y,b]=(0,v.useState)([]),[x,S]=(0,v.useState)(`count`),[C,w]=(0,v.useState)(`descending`),[T,E]=(0,v.useState)(()=>new URLSearchParams(window.location.search).get(`api_key`)??``),{options:D}=R9(),O=(0,v.useRef)(0),k=n.toString(),A=(0,v.useRef)(k);(0,v.useEffect)(()=>{k!==A.current&&(A.current=k,E(new URLSearchParams(k).get(`api_key`)??``))},[k]);let j=T?`api_key=${encodeURIComponent(T)}`:``;(0,v.useEffect)(()=>{j!==A.current&&(A.current=j,r(j,{replace:!0}))},[j,r]),(0,v.useEffect)(()=>{let e=!1;return PI(!1).then(t=>{e||b(t.data||[])}).catch(()=>{}),()=>{e=!0}},[]);let M=u?.start?.toString()??``,N=u?.end?.toString()??``;(0,v.useEffect)(()=>{let e=vH(c,u);if(!e){h(!1);return}let t=++O.current;ZV({...e,dim:[o],limit:gwe,api_key:T||void 0}).then(e=>{t===O.current&&(p(e),_(``))}).catch(e=>{t===O.current&&(p(null),_(e instanceof Error?e.message:String(e)))}).finally(()=>{t===O.current&&h(!1)})},[o,c,M,N,T]);let P=(0,v.useMemo)(()=>{let t=new Map(y.map(e=>[e.id,e.name||e.id]));return ywe(((o===`model`?f?.models:o===`account`?f?.accounts:f?.providers)??[]).map(n=>{let r=n.key===`(unknown)`?e(`statsUnknown`):n.key===`(unassigned)`?e(`statsUnassigned`):o===`account`?t.get(n.key)||n.key:o===`provider`?AH(n.key,e):n.key;return vwe(n,o,r)}),x,C)},[f,o,y,x,C,e]),F=f?.totals,I=f?.tokens;function L(e){if(!f||!e.filter)return;let n={...e.filter,api_key:T||void 0};t(bH(n,f.window.from,f.window.to))}let R=[{id:`label`,label:e(o===`model`?`logsColModel`:o===`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}],z=(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`section`,{className:`flex flex-wrap items-center justify-end gap-3 pb-1`,children:(0,G.jsx)(yH,{value:c,onChange:l,custom:u,onCustomChange:d,onBusy:()=>h(!0),t:e})}),g?(0,G.jsx)(QI,{title:e(`failedStats`,{msg:g})}):null,(0,G.jsx)(`section`,{className:`grid gap-3 sm:grid-cols-2 sm:gap-4 xl:grid-cols-5`,children:[[e(`usageColRequests`),F?$V(F.requests):`—`,e(`statsWindowHint`,{window:e(_H[c])})],[e(`usageColSuccess`),F?nH(F.success_rate):`—`,F?`${F.ok} / ${F.requests}`:``],[e(`usageColTokens`),I?$V(I.total):`—`,I?`${$V(I.prompt)} / ${$V(I.completion)}`:``],[e(`usageColCacheWrite`),I?$V(I.cache_write??0):`—`,I?`${e(`chartCacheRead`)} ${$V(I.cache_read)}`:``],[e(`usageColCredits`),F?Z9(F.credits??0):`—`,``]].map(([e,t,n])=>(0,G.jsxs)(HS,{className:`gap-0 p-4`,children:[(0,G.jsx)(`div`,{className:`text-body text-muted`,children:e}),(0,G.jsx)(`div`,{className:`tabular mt-1.5 text-section font-semibold`,children:m?(0,G.jsx)(Q,{className:`h-5 w-16`}):t}),(0,G.jsx)(`div`,{className:`mono mt-1 truncate text-caption text-muted`,children:m?(0,G.jsx)(Q,{className:`h-3 w-24`}):n||`\xA0`})]},e))}),(0,G.jsxs)(HS,{className:`overflow-hidden p-0`,children:[(0,G.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,G.jsx)(_j,{selectedKey:o,onSelectionChange:e=>{h(!0),s(String(e))},children:(0,G.jsx)(_j.ListContainer,{className:`w-fit`,children:(0,G.jsxs)(_j.List,{"aria-label":e(`usageTitle`),children:[(0,G.jsxs)(gj,{id:`model`,className:`gap-1.5 whitespace-nowrap`,children:[(0,G.jsx)(_j.Indicator,{className:`transition-none`}),(0,G.jsx)(ji,{size:14}),e(`usageByModel`)]}),(0,G.jsxs)(gj,{id:`account`,className:`gap-1.5 whitespace-nowrap`,children:[(0,G.jsx)(_j.Indicator,{className:`transition-none`}),(0,G.jsx)(to,{size:14}),e(`usageByAccount`)]}),(0,G.jsxs)(gj,{id:`provider`,className:`gap-1.5 whitespace-nowrap`,children:[(0,G.jsx)(_j.Indicator,{className:`transition-none`}),(0,G.jsx)(za,{size:14}),e(`usageByProvider`)]})]})})}),(0,G.jsx)(`span`,{className:`mono text-caption text-muted`,children:m?``:e(`usageRowCount`,{count:P.length})})]}),m?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`divide-y divide-separator md:hidden`,"aria-busy":`true`,children:Array.from({length:4},(e,t)=>(0,G.jsxs)(`div`,{className:`space-y-3 px-5 py-4`,children:[(0,G.jsx)(Q,{className:`h-4 w-40`}),(0,G.jsx)(`div`,{className:`grid grid-cols-2 gap-x-4 gap-y-3`,children:Array.from({length:4},(e,t)=>(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(Q,{className:`h-3 w-12`}),(0,G.jsx)(Q,{className:`h-4 w-16`})]},t))})]},t))}),(0,G.jsx)(`div`,{className:`hidden divide-y divide-separator md:block`,"aria-busy":`true`,children:Array.from({length:6},(e,t)=>(0,G.jsxs)(`div`,{className:`flex items-center gap-6 px-5 py-3.5`,children:[(0,G.jsx)(Q,{className:`h-4 w-40`}),(0,G.jsx)(`div`,{className:`flex-1`}),Array.from({length:6},(e,t)=>(0,G.jsx)(Q,{className:`h-4 w-14`},t))]},t))})]}):P.length===0?(0,G.jsxs)(`div`,{className:`flex items-center gap-2 px-5 py-10 text-body text-muted`,children:[(0,G.jsx)(pi,{size:16}),e(`usageEmpty`)]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`divide-y divide-separator md:hidden`,children:P.map(t=>{let n=!!(t.filter&&f),r=[{label:e(`usageColRequests`),value:String(t.count)},{label:e(`usageColSuccess`),value:nH(t.success),tone:t.success<.9?`text-warning`:void 0},{label:e(`statsLatencyP95`),value:eH(t.p95)},{label:e(`usageColTokens`),value:$V(t.tokens),sub:`${$V(t.prompt)} / ${$V(t.completion)}`},{label:e(`usageColCacheWrite`),value:$V(t.cache_write)},{label:e(`usageColCredits`),value:Z9(t.credits)}];return(0,G.jsxs)(`article`,{className:`space-y-3 px-5 py-4 ${n?`cursor-pointer`:``}`,onClick:n?()=>L(t):void 0,onKeyDown:n?e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),L(t))}:void 0,role:n?`button`:void 0,tabIndex:n?0:void 0,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[o===`provider`&&t.filter?(0,G.jsx)(MH,{provider:t.key,size:14}):null,(0,G.jsx)(`span`,{className:`truncate text-body font-medium`,children:t.label})]}),o===`account`&&t.label!==t.key?(0,G.jsx)(`div`,{className:`mono truncate text-caption text-muted`,children:t.key}):null,(0,G.jsx)(`div`,{className:`grid grid-cols-2 gap-x-4 gap-y-3`,children:r.map(e=>(0,G.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,G.jsx)(`div`,{className:`text-caption text-muted`,children:e.label}),(0,G.jsx)(`div`,{className:`mono text-body ${e.tone??`text-foreground`}`,children:e.value}),`sub`in e&&e.sub?(0,G.jsx)(`div`,{className:`mono text-caption text-muted`,children:e.sub}):null]},e.label))})]},t.key)})}),(0,G.jsx)(X,{className:`usage-table hidden md:block`,children:(0,G.jsx)(X.ScrollContainer,{className:`min-w-0 overflow-x-auto`,children:(0,G.jsxs)(X.Content,{"aria-label":e(`usageTitle`),className:`min-w-[48rem]`,sortDescriptor:{column:x,direction:C},onSortChange:e=>{S(String(e.column)),w(e.direction)},children:[(0,G.jsx)(X.Header,{children:R.map(e=>(0,G.jsx)(X.Column,{id:e.id,allowsSorting:!0,isRowHeader:e.id===`label`,className:e.numeric?`text-right`:void 0,children:({sortDirection:t})=>(0,G.jsx)(X.SortableColumnHeader,{sortDirection:t,className:e.numeric?`justify-end`:void 0,children:e.label})},e.id))}),(0,G.jsx)(X.Body,{children:P.map(e=>(0,G.jsxs)(X.Row,{id:e.key,className:e.filter&&f?`cursor-pointer`:void 0,onAction:e.filter&&f?()=>L(e):void 0,children:[(0,G.jsx)(X.Cell,{children:(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[o===`provider`&&e.filter?(0,G.jsx)(MH,{provider:e.key,size:14}):null,(0,G.jsx)(`span`,{className:`truncate text-body font-medium`,children:e.label}),o===`account`&&e.label!==e.key?(0,G.jsx)(`span`,{className:`mono truncate text-caption text-muted`,children:e.key}):null]})}),(0,G.jsx)(X.Cell,{className:`mono text-right text-body`,children:e.count}),(0,G.jsx)(X.Cell,{className:`mono text-right text-body`,children:(0,G.jsx)(`span`,{className:e.success<.9?`text-warning`:void 0,children:nH(e.success)})}),(0,G.jsx)(X.Cell,{className:`mono text-right text-body`,children:eH(e.p95)}),(0,G.jsxs)(X.Cell,{className:`text-right`,children:[(0,G.jsx)(`div`,{className:`mono text-body`,children:$V(e.tokens)}),(0,G.jsxs)(`div`,{className:`mono text-caption text-muted`,children:[$V(e.prompt),` / `,$V(e.completion)]})]}),(0,G.jsx)(X.Cell,{className:`mono text-right text-body`,children:$V(e.cache_write)}),(0,G.jsx)(X.Cell,{className:`mono text-right text-body`,children:Z9(e.credits)})]},e.key))})]})})})]})]}),(0,G.jsx)(lwe,{accounts:y,t:e})]});return(0,G.jsxs)(`div`,{className:`space-y-6 sm:space-y-6`,children:[(0,G.jsxs)(`section`,{className:`flex flex-wrap items-end justify-between gap-3 pb-1`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h2`,{className:`text-title font-semibold`,children:e(`usageTitle`)}),(0,G.jsx)(`p`,{className:`mt-1 max-w-2xl text-body leading-6 text-muted`,children:e(i===`cost`?`usageCostLead`:`usageLead`)})]}),(0,G.jsx)(L9,{ariaLabel:e(`logsColApiKey`),value:T,onChange:e=>{h(!0),E(e)},options:D,allLabel:e(`logsFilterApiKeyAll`),searchPlaceholder:e(`logsSearchApiKey`),emptyLabel:e(`logsNoFilterOptions`)})]}),(0,G.jsxs)(_j,{selectedKey:i,onSelectionChange:e=>a(String(e)),children:[(0,G.jsx)(_j.ListContainer,{className:`w-fit`,children:(0,G.jsxs)(_j.List,{"aria-label":e(`usageTitle`),children:[(0,G.jsxs)(gj,{id:`stats`,className:`gap-1.5 whitespace-nowrap`,children:[(0,G.jsx)(_j.Indicator,{className:`transition-none`}),e(`usageStatsTab`)]}),(0,G.jsxs)(gj,{id:`cost`,className:`gap-1.5 whitespace-nowrap`,children:[(0,G.jsx)(_j.Indicator,{className:`transition-none`}),e(`usageCostTab`)]})]})}),(0,G.jsx)(_j.Panel,{id:`stats`,className:`space-y-6 pt-5`,children:z}),(0,G.jsx)(_j.Panel,{id:`cost`,className:`pt-5`,children:(0,G.jsx)(hwe,{apiKeyFilter:T})})]})]})}var xwe=1.1;function Swe({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,G.jsxs)(PM,{delay:300,children:[(0,G.jsx)(PM.Trigger,{children:(0,G.jsxs)(J,{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=Z.to(e,{scaleX:1,duration:xwe*(1-Number(Z.getProperty(e,`scaleX`))),ease:AV.linear,onComplete:()=>{a.current=null,Z.to(e,{scaleX:0,duration:jV()?0:kV.base,ease:AV.out,delay:kV.fast}),t()}}))},onPressEnd:()=>{let e=i.current;!e||!a.current||(a.current.kill(),a.current=null,Z.to(e,{scaleX:0,duration:jV()?0:kV.base,ease:AV.soft}))},children:[(0,G.jsx)(`span`,{ref:i,"aria-hidden":!0,className:`pointer-events-none absolute inset-0 origin-left scale-x-0 bg-danger/20`}),(0,G.jsx)(`span`,{className:`relative inline-flex`,children:r})]})}),(0,G.jsx)(PM.Content,{children:e})]})}function Cwe(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 Q9(e,t){let n=e.indexOf(`:`),r=n===-1?e:e.slice(0,n),i=n===-1?``:e.slice(n+1);return i?jH(r,i,t):AH(r,t)}function wwe(e){let t=e.indexOf(`:`);return t===-1?e:e.slice(0,t)}function Twe(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 Ewe(e,t){return e.length?e.map(e=>Q9(e,t)).join(` · `):t(`keysAllProviders`)}function Dwe(e){if(!e)return``;let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}function Owe(){let{t:e}=EI(),[t,n]=(0,v.useState)([]),[r,i]=(0,v.useState)(!1),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)([]),[l,u]=(0,v.useState)(!0),[d,f]=(0,v.useState)(``),[p,m]=(0,v.useState)(``),[h,g]=(0,v.useState)(!1),[_,y]=(0,v.useState)(null),[b,x]=(0,v.useState)(null),[S,C]=(0,v.useState)(!1);(0,v.useEffect)(()=>{UI().then(e=>{let t=Cwe(e.data||[]);n(t),i(t.length>0),o(``)}).catch(e=>{o(e instanceof Error?e.message:String(e))})},[]);async function w(){u(!0);try{let e=await N9();c(e.data||[]),m(``)}catch(e){m(e instanceof Error?e.message:String(e))}finally{u(!1)}}(0,v.useEffect)(()=>{let e=window.setTimeout(()=>void w(),0);return()=>window.clearTimeout(e)},[]);async function T(e){await Z7(e),C(!0),window.setTimeout(()=>C(!1),1200)}async function E(e,t){f(e.id),c(n=>n.map(n=>n.id===e.id?{...n,enabled:t}:n));try{let n=await P9(e.id,{enabled:t});c(t=>t.map(t=>t.id===e.id?{...t,...n,secret:void 0}:t))}catch(e){m(e instanceof Error?e.message:String(e)),await w()}finally{f(``)}}async function D(t){f(t.id);try{await UCe(t.id),c(e=>e.filter(e=>e.id!==t.id)),XV({type:`success`,title:e(`toastKeyDeleted`)})}catch(e){m(e instanceof Error?e.message:String(e))}finally{f(``)}}return l&&!s.length?(0,G.jsx)(Lse,{}):(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)(`h2`,{"data-gsap-reveal":!0,className:`text-title font-semibold`,children:e(`navKeys`)}),(0,G.jsx)(`p`,{className:`mt-1 max-w-2xl text-body leading-6 text-muted`,children:e(`keysLead`)})]}),(0,G.jsxs)(J,{size:`sm`,isDisabled:!r,onPress:()=>g(!0),children:[(0,G.jsx)(Ca,{size:14}),e(`keysCreate`)]})]}),p?(0,G.jsx)(QI,{title:p}):null,a?(0,G.jsx)(QI,{title:e(`keysProvidersLoadFailed`,{message:a})}):null,l?(0,G.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,s.length)},(e,t)=>(0,G.jsxs)(`div`,{className:`overflow-hidden rounded-3xl bg-surface shadow-surface p-3`,children:[(0,G.jsx)(Q,{className:`h-4 w-28`}),(0,G.jsx)(Q,{className:`mt-2 h-3 w-40`}),(0,G.jsx)(Q,{className:`mt-4 h-6 w-24`}),(0,G.jsx)(Q,{className:`mt-6 h-8 w-full`})]},t))}):s.length?(0,G.jsx)(`section`,{className:`grid gap-2.5 lg:grid-cols-2 xl:grid-cols-3`,children:s.map(t=>(0,G.jsxs)(HS,{className:`overflow-hidden p-0`,children:[(0,G.jsxs)(HS.Header,{className:`flex-row items-start justify-between gap-3 px-3 pt-3 pb-2.5`,children:[(0,G.jsx)(`div`,{className:`min-w-0`,children:(0,G.jsx)(HS.Title,{className:`truncate text-body`,children:t.name})}),(0,G.jsx)(aC,{size:`sm`,variant:`soft`,color:t.enabled?`success`:`default`,children:t.enabled?e(`enabled`):e(`disabled`)})]}),(0,G.jsxs)(HS.Content,{className:`space-y-2.5 px-3 pb-2.5`,children:[(0,G.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,G.jsx)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:(t.providers.length?t.providers:[`all`]).map(t=>(0,G.jsx)(aC,{size:`sm`,variant:`soft`,children:(0,G.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[t===`all`?(0,G.jsx)(ta,{size:12}):(0,G.jsx)(MH,{provider:wwe(t),size:12}),(0,G.jsx)(`span`,{children:t===`all`?e(`keysAllProviders`):Q9(t,e)})]})},t))}),(0,G.jsx)(`p`,{className:`text-caption leading-5 text-muted`,children:t.last_used_at?e(`keysLastUsed`,{time:Dwe(t.last_used_at)}):e(`keysNeverUsed`)})]}),(0,G.jsxs)(HS.Footer,{className:`gap-1.5 bg-surface-secondary px-3 py-2`,children:[(0,G.jsx)(J,{size:`sm`,variant:`ghost`,isDisabled:!r,onPress:()=>y(t),children:e(`edit`)}),(0,G.jsx)(Swe,{label:e(`holdToDelete`),isPending:d===t.id,onConfirm:()=>void D(t),children:(0,G.jsx)(qa,{size:14})}),(0,G.jsx)(`div`,{className:`ml-auto`,children:(0,G.jsx)(F7,{isSelected:t.enabled,isDisabled:d===t.id,ariaLabel:e(`enable`),onChange:e=>void E(t,e)})})]})]},t.id))}):(0,G.jsx)(I7,{className:`rounded-3xl bg-surface-secondary`,icon:(0,G.jsx)(PV,{size:28}),title:e(`keysEmpty`),hint:e(`keysEmptyHint`),action:(0,G.jsxs)(J,{size:`sm`,isDisabled:!r,onPress:()=>g(!0),children:[(0,G.jsx)(Ca,{size:14}),e(`keysCreate`)]})}),(0,G.jsx)($9,{isOpen:h,title:e(`keysCreateTitle`),hint:e(`keysCreateHint`),options:t,t:e,onClose:()=>g(!1),onSave:async e=>{let t=await HCe(e);c(e=>[t,...e.map(e=>({...e,secret:void 0}))]),g(!1),x(t)}}),(0,G.jsx)($9,{isOpen:!!_,title:e(`keysEditTitle`),hint:e(`keysEditHint`),initial:_,options:t,t:e,onClose:()=>y(null),onSave:async e=>{if(!_)return;let t=await P9(_.id,e);c(e=>e.map(e=>e.id===_.id?{...e,...t,secret:void 0}:e)),y(null)}}),(0,G.jsx)(Y.Root,{isOpen:!!b?.secret,onOpenChange:e=>{e||x(null)},children:(0,G.jsx)(Y.Backdrop,{variant:`blur`,children:(0,G.jsx)(Y.Container,{placement:`center`,size:`lg`,children:(0,G.jsxs)(Y.Dialog,{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:e(`keysSecretTitle`)}),(0,G.jsx)(`p`,{className:`mt-1.5 text-body leading-6 text-muted`,children:e(`keysSecretHint`)})]}),(0,G.jsx)(Y.CloseTrigger,{"aria-label":e(`close`),className:`grid size-9 place-items-center rounded-lg text-muted hover:bg-surface-secondary`,children:(0,G.jsx)(ao,{size:18})})]}),(0,G.jsxs)(Y.Body,{className:`px-6 pb-2`,children:[(0,G.jsxs)(tF,{status:`warning`,className:`mb-4`,children:[(0,G.jsx)(tF.Indicator,{}),(0,G.jsx)(tF.Content,{children:(0,G.jsx)(tF.Title,{children:e(`keysSecretOnce`)})})]}),(0,G.jsx)(`code`,{className:`mono block break-all rounded-lg bg-surface-secondary px-3 py-3 text-body`,children:b?.secret})]}),(0,G.jsxs)(Y.Footer,{className:`justify-end`,children:[(0,G.jsx)(J,{variant:`ghost`,onPress:()=>x(null),children:e(`close`)}),(0,G.jsxs)(J,{onPress:()=>{b?.secret&&T(b.secret)},children:[(0,G.jsx)(Di,{size:14}),e(S?`copied`:`copy`)]})]})]})})})})]})}function $9({isOpen:e,title:t,hint:n,initial:r,options:i,t:a,onClose:o,onSave:s}){let[c,l]=(0,v.useState)(r?.name||``),[u,d]=(0,v.useState)([]),[f,p]=(0,v.useState)(new Set),[m,h]=(0,v.useState)(!0),[g,_]=(0,v.useState)(``),[y,b]=(0,v.useState)(!1);(0,v.useEffect)(()=>{if(!e)return;l(r?.name||``),d(Twe(r?.providers||[],i));let t=new Set((r?.providers||[]).filter(e=>!e.includes(`:`)).map(e=>e.toLowerCase()));p(t),h(!0),_(``)},[r,e,i]);function x(e){let t=i.find(t=>t.value===e);h(!1),d(n=>n.includes(e)?(t&&p(e=>{let n=new Set(e);return n.delete(t.provider),n}),n.filter(t=>t!==e)):[...n,e])}async function S(e){e?.preventDefault();let t=c.trim();if(!t){_(a(`keysNameRequired`));return}if(!i.length){_(a(`keysProvidersNotLoaded`));return}b(!0),_(``);try{await s({name:t,providers:m?r?.providers||[]:u})}catch(e){_(e instanceof Error?e.message:String(e))}finally{b(!1)}}return(0,G.jsx)(Y.Root,{isOpen:e,onOpenChange:e=>{!e&&!y&&o()},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-[32rem]`,children:(0,G.jsxs)(QP,{onSubmit:S,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:t}),(0,G.jsx)(`p`,{className:`mt-1.5 text-body leading-6 text-muted`,children:n})]}),(0,G.jsx)(Y.CloseTrigger,{isDisabled:y,"aria-label":a(`close`),className:`grid size-9 place-items-center rounded-lg text-muted hover:bg-surface-secondary`,children:(0,G.jsx)(ao,{size:18})})]}),(0,G.jsxs)(Y.Body,{className:`space-y-5 px-6 pb-2 pt-1`,children:[g?(0,G.jsxs)(tF,{status:`danger`,children:[(0,G.jsx)(tF.Indicator,{}),(0,G.jsx)(tF.Content,{children:(0,G.jsx)(tF.Title,{children:g})})]}):null,(0,G.jsx)(_9,{label:a(`keysName`),children:(0,G.jsx)(UM,{value:c,onChange:e=>l(e.target.value),placeholder:a(`keysNamePh`),"aria-label":a(`keysName`)})}),(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(IN,{className:`text-body font-medium text-muted`,children:a(`keysProviders`)}),(0,G.jsx)(RN,{className:`text-caption leading-5 text-muted`,children:a(`keysProvidersHint`)}),i.length?(0,G.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:i.map(e=>{let t=u.includes(e.value),n=f.has(e.provider);return(0,G.jsx)(tC,{isSelected:t,onChange:()=>x(e.value),className:`rounded-xl bg-surface-secondary px-3 py-2.5 data-selected:border-accent data-selected:bg-accent-soft`,children:(0,G.jsxs)(tC.Content,{className:`flex items-center gap-2.5`,children:[(0,G.jsx)(tC.Control,{children:(0,G.jsx)(tC.Indicator,{})}),(0,G.jsx)(MH,{provider:e.provider,size:16}),(0,G.jsx)(`span`,{className:`text-body font-medium`,children:jH(e.provider,e.region,a)}),n?(0,G.jsx)(`span`,{className:`rounded-md bg-surface-secondary px-1.5 py-0.5 text-caption font-medium text-muted`,children:a(`keysAllRegions`)}):null]})},e.value)})}):(0,G.jsx)(`p`,{className:`rounded-lg bg-surface-secondary px-3 py-2.5 text-caption leading-5 text-muted`,children:a(`keysProvidersNotLoaded`)}),(0,G.jsx)(`p`,{className:`text-caption text-muted`,children:Ewe(u,a)})]})]}),(0,G.jsxs)(Y.Footer,{className:`justify-end`,children:[(0,G.jsx)(J,{variant:`ghost`,isDisabled:y,onPress:o,children:a(`cancel`)}),(0,G.jsx)(J,{type:`submit`,isPending:y,isDisabled:!i.length,children:a(r?`save`:`create`)})]})]})})})})})}function kwe(){return(0,G.jsx)(Soe,{children:(0,G.jsx)(noe,{children:(0,G.jsx)(roe,{children:(0,G.jsx)(boe,{children:(0,G.jsx)(xn,{children:(0,G.jsxs)(Pt,{children:[(0,G.jsx)(Mt,{path:`/login`,element:(0,G.jsx)(VCe,{})}),(0,G.jsx)(Mt,{element:(0,G.jsx)(ace,{}),children:(0,G.jsxs)(Mt,{element:(0,G.jsx)(ice,{}),children:[(0,G.jsx)(Mt,{path:`/`,element:(0,G.jsx)(rSe,{})}),(0,G.jsx)(Mt,{path:`/auth`,element:(0,G.jsx)(At,{to:`/accounts`,replace:!0})}),(0,G.jsx)(Mt,{path:`/providers`,element:(0,G.jsx)(fSe,{})}),(0,G.jsx)(Mt,{path:`/access`,element:(0,G.jsx)(zSe,{})}),(0,G.jsx)(Mt,{path:`/accounts`,element:(0,G.jsx)(BCe,{})}),(0,G.jsx)(Mt,{path:`/checkins`,element:(0,G.jsx)(At,{to:`/accounts`,replace:!0})}),(0,G.jsx)(Mt,{path:`/usage`,element:(0,G.jsx)(bwe,{})}),(0,G.jsx)(Mt,{path:`/logs`,element:(0,G.jsx)(swe,{})}),(0,G.jsx)(Mt,{path:`/keys`,element:(0,G.jsx)(Owe,{})}),(0,G.jsx)(Mt,{path:`/system`,element:(0,G.jsx)(ZCe,{})}),(0,G.jsx)(Mt,{path:`*`,element:(0,G.jsx)(At,{to:`/`,replace:!0})})]})})]})})})})})})}(0,y.createRoot)(document.getElementById(`root`)).render((0,G.jsx)(v.StrictMode,{children:(0,G.jsx)(kwe,{})}));export{jJ as $,xU as $t,Nhe as A,MW as At,s4 as B,mW as Bt,C6 as C,h as Cn,FW as Ct,y3 as D,gW as Dt,pge as E,xW as Et,H4 as F,yW as Ft,lZ as G,EW as Gt,y2 as H,DW as Ht,U4 as I,hW as It,UX as J,uW as Jt,YX as K,fW as Kt,Kme as L,CW as Lt,Fhe as M,AW as Mt,Phe as N,jW as Nt,Zhe as O,wW as Ot,e3 as P,kW as Pt,sY as Q,yU as Qt,Vme as R,pW as Rt,D6 as S,xs as Sn,IW as St,v6 as T,l as Tn,SW as Tt,i2 as U,OW as Ut,o4 as V,_W as Vt,qZ as W,TW as Wt,gY as X,Nle as Xt,jY as Y,lW as Yt,hY as Z,_U as Zt,L6 as _,$V as _n,$ as _t,i5 as a,uU as an,TJ as at,k6 as b,Z as bn,RW as bt,R8 as c,iU as cn,vq as ct,v8 as d,ZH as dn,cq as dt,hU as en,AJ as et,t8 as f,YH as fn,bq as ft,B6 as g,oH as gn,XW as gt,U6 as h,fH as hn,rq as ht,f5 as i,lU as in,EJ as it,c3 as j,NW as jt,m3 as k,vW as kt,P8 as l,rU as ln,fq as lt,q6 as m,pH as mn,sq as mt,u7 as n,dU as nn,kJ as nt,B8 as o,cU as on,Xq as ot,Q6 as p,XH as pn,oq as pt,ZX as q,dW as qt,_5 as r,wU as rn,OJ as rt,z8 as s,sU as sn,Wq as st,d7 as t,mU as tn,MJ as tt,E8 as u,tU as un,gde as ut,I6 as v,cH as vn,BW as vt,h6 as w,d as wn,Vle as wt,O6 as x,Mc as xn,LW as xt,j6 as y,eH as yn,HW as yt,zme as z,bW as zt}; \ No newline at end of file + -d ${o9(JSON.stringify(me))}`,[me,T,oe]);if(n&&!t)return(0,G.jsx)(Rse,{});async function ge(e,t){await Z7(e),ae(t),window.setTimeout(()=>ae(``),1100)}async function _e(){let e=performance.now();te(`loading`),re(null),H(``);try{let e=await doe(w,me,oe||void 0);H(JSON.stringify(e,null,2)),te(`success`)}catch(e){H(e instanceof Error?e.message:String(e)),te(`error`)}finally{re(Math.round(performance.now()-e))}}function ve(){B.current?.abort(),B.current=null}function ye(e){let t=p;u(n=>n.map(n=>{if(n.id!==t)return n;let r=typeof e==`function`?e(n.messages):e;return{...n,messages:r,title:l9(r)||n.title,updatedAt:Date.now()}}))}function be(e,t){ye(n=>n.map(n=>{if(n.id!==e)return n;let r=typeof t==`function`?t(n):t;return{...n,...r}}))}async function xe(){let e=P.trim();if(!e&&!I.length||!fe||le||R===`loading`)return;ve();let t=new AbortController;B.current=t;let n=I,r={id:s9(`user`),role:`user`,content:e,attachments:n,status:`done`},i=s9(`assistant`),a={id:i,role:`assistant`,content:``,status:`streaming`},o=m;ye([...o,r,a]),F(``),L([]),z(`loading`);let s=PSe(o,{role:`user`,content:i9(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 moe(fe,s,oe||void 0,{signal:t.signal,onContent:(e,t)=>{e&&u(),be(i,{content:t})},onReasoning:(e,t)=>{e&&u(),be(i,{reasoning:t})},onToolCalls:e=>{u(),be(i,{toolCalls:LSe(e,!0)})},onUsage:e=>be(i,{usage:e})}),be(i,e=>({status:`done`,...d(),toolCalls:e.toolCalls?.map(e=>({...e,status:`success`}))})),z(`success`)}catch(e){if(t.signal.aborted){be(i,e=>({status:`done`,...d(),toolCalls:e.toolCalls?.map(e=>({...e,status:`success`}))})),z(`success`);return}be(i,{status:`error`,error:e instanceof Error?e.message:String(e),...d()}),z(`error`)}finally{B.current===t&&(B.current=null)}}let Se=e(ee===`success`?`requestComplete`:ee===`error`?`requestFailed`:ee===`loading`?`requesting`:`requestIdle`),Ce=c9()!=null,we=[{id:`auto`,textValue:e(`autoAccount`),label:e(`autoAccount`),icon:(0,G.jsx)(ti,{size:14,className:`text-muted`})},..._.map(t=>({id:t.id,textValue:`${t.name||t.id} ${jH(t.provider,t.region,e)}`,label:t.name||t.id,hint:jH(t.provider,t.region,e),icon:(0,G.jsx)(MH,{provider:t.provider,size:14})}))],Te=_.length||!Ce?we:[{id:`auto`,textValue:e(`autoAccount`),label:e(`autoAccount`),icon:(0,G.jsx)(ti,{size:14,className:`text-muted`})},{id:`demo-wb`,textValue:`wb-demo WorkBuddy`,label:`wb-demo`,hint:`WorkBuddy`}],Ee=ce.map(t=>{let n=rH(t),r=iH(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(` · `)}}),De=Ee.length||!Ce?Ee:d9.map(t=>{let n=rH(t),r=iH(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(` · `)}}),Oe=!!((P.trim()||I.length)&&fe&&!le&&(_.length||Ce));function ke(){ye(a9()),z(`idle`)}function Ae(){ve(),z(`idle`),F(``),L([]);let e=u9([]);u(t=>[e,...t]),f(e.id)}function je(e){e!==p&&(ve(),z(`idle`),F(``),L([]),f(e))}let Me=l.slice().sort((e,t)=>t.updatedAt-e.updatedAt).map(t=>({id:t.id,title:t.title||e(`chatHistoryUntitled`),updatedAt:t.updatedAt}));return(0,G.jsxs)(`div`,{className:`access-page space-y-4`,children:[(0,G.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,G.jsx)(`h2`,{className:`shrink-0 text-body font-semibold text-foreground`,children:e(`apiPlayground`)}),(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-1.5 text-caption text-muted`,children:[(0,G.jsx)(`span`,{className:`shrink-0`,children:e(`baseUrl`)}),(0,G.jsx)(`code`,{className:`mono min-w-0 truncate font-medium text-foreground`,children:b}),(0,G.jsx)(J,{isIconOnly:!0,size:`sm`,variant:`ghost`,className:`size-6 min-w-6 shrink-0`,"aria-label":e(`copyBaseUrl`),onPress:()=>void ge(b,`base`),children:(0,G.jsx)(X7,{copied:ie===`base`,size:13})})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-caption text-muted`,children:[(0,G.jsx)(`span`,{className:`status-dot`,"data-state":pe.length?`ok`:void 0}),(0,G.jsx)(`span`,{children:e(`readyAccounts`,{ready:pe.length,total:_.length})}),(0,G.jsx)(aC,{size:`sm`,variant:`soft`,color:pe.length?`success`:`warning`,children:pe.length?e(`endpointReady`):e(`degraded`)})]})]}),_.length?null:(0,G.jsxs)(`div`,{className:`space-y-1 px-1`,children:[(0,G.jsx)(`p`,{className:`text-caption text-muted`,children:e(`noAccountsForTest`)}),(0,G.jsx)(e9,{})]}),ue?(0,G.jsx)(`p`,{className:`px-1 text-caption text-danger`,children:ue}):null,(0,G.jsxs)(_j,{selectedKey:r,onSelectionChange:e=>i(String(e)),children:[(0,G.jsx)(_j.ListContainer,{className:`w-fit`,children:(0,G.jsxs)(_j.List,{"aria-label":e(`accessTabsLabel`),children:[(0,G.jsxs)(gj,{id:`chat`,className:`gap-1.5 whitespace-nowrap`,children:[(0,G.jsx)(_j.Indicator,{className:`transition-none`}),e(`accessTabChat`)]}),(0,G.jsxs)(gj,{id:`raw`,className:`gap-1.5 whitespace-nowrap`,children:[(0,G.jsx)(_j.Indicator,{className:`transition-none`}),e(`accessTabApi`)]})]})}),(0,G.jsx)(_j.Panel,{id:`chat`,className:`pt-4`,children:(0,G.jsxs)(`div`,{className:`flex min-h-[640px] md:min-h-[72vh]`,children:[(0,G.jsx)(xSe,{collapsed:s,onCollapsedChange:c,items:Me,activeId:p,onSelect:je,onNew:Ae}),(0,G.jsxs)(`div`,{className:`access-chat-stage flex min-w-0 flex-1 flex-col`,children:[(0,G.jsx)(MSe,{messages:m,busy:R===`loading`,onLoadDemo:ke}),(0,G.jsx)(bSe,{value:P,onChange:F,attachments:I,onAttachmentsChange:L,disabled:!_.length&&c9()==null,streaming:R===`loading`,canSend:Oe,onSend:()=>void xe(),onStop:ve,accountValue:oe||`auto`,onAccountChange:e=>k(e===`auto`?``:e),accountOptions:Te,modelValue:fe,onModelChange:D,modelOptions:De,modelsLoading:le})]})]})}),(0,G.jsxs)(_j.Panel,{id:`raw`,className:`space-y-4 pt-4`,children:[(0,G.jsx)(NSe,{format:a,onFormatChange:o,requestPath:w,prompt:M,onPromptChange:N,onTest:()=>void _e(),requestState:ee,elapsedMs:ne,output:V,responseStatus:Se,curl:he,copiedCurl:ie===`curl`,onCopyCurl:()=>void ge(he,`curl`),canSend:!!(M.trim()&&fe&&!le),accountValue:oe||`auto`,onAccountChange:e=>k(e===`auto`?``:e),accountOptions:Te,modelValue:fe,onModelChange:D,modelOptions:De,modelsLoading:le,disabled:!_.length&&c9()==null}),(0,G.jsx)(pSe,{access:t?.access})]})]})]})}function BSe(e){(0,v.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let n=Z.context(()=>{Z.matchMedia().add(`(prefers-reduced-motion: no-preference)`,()=>{let e=Z.utils.toArray(`.meter__fill`);e.length&&Z.from(e,{scaleX:0,transformOrigin:`left center`,duration:kV.calm,ease:AV.emphasized,stagger:Ose.base,clearProps:`transform,transformOrigin`})})},t);return()=>n.revert()},[e])}function f9(e){if(!e)return``;let t=Date.parse(e)-Date.now();if(!Number.isFinite(t)||t<=0)return``;let n=Math.ceil(t/1e3);return n<60?`${n}s`:`${Math.ceil(n/60)}m`}function VSe(e){return Object.entries(e.model_cooldowns??{}).filter(([,e])=>!!f9(e)).sort(([e],[t])=>e.localeCompare(t))}function p9(e){return e.enabled?e.status===`quota_exhausted`||e.quota?.exceeded?`quota_exhausted`:e.status===`cooling`||f9(e.down_until||e.cooldown_until)?`cooling`:e.status===`dead`||e.runtime_state===`dead`?`dead`:e.status===`auth_failed`||e.runtime_state===`auth_failed`?`auth_failed`:e.status===`login_required`?`login`:(e.status===`starting`||e.runtime_state===`starting`)&&!e.hot&&!e.ready?e.quota?`starting`:`loading`:e.status===`ready`?e.hot?`hot`:`ready`:e.hot?`hot`:e.ready?`ready`:(e.status===`error`||e.status,`unavailable`):`disabled`}function HSe(e){return e===`hot`?12:e===`ready`?9:e===`cooling`?5:e===`login`?3:e===`loading`||e===`starting`?6:e===`unavailable`?2:e===`auth_failed`?3:e===`dead`?2:1}function USe(e){return e===`hot`||e===`ready`?`ok`:e===`cooling`||e===`quota_exhausted`||e===`loading`||e===`starting`?`warn`:e===`auth_failed`||e===`unavailable`||e===`dead`||e===`login`?`danger`:`muted`}function m9(e){return e==null||!Number.isFinite(e)?`—`:Math.abs(e)>=1e3?`${(e/1e3).toFixed(e%1e3==0?0:1)}k`:String(Math.round(e*100)/100)}function h9(e){let t=e.percentage??0;return Number.isFinite(t)?Math.min(1,Math.max(0,t/100)):0}function g9(e){let t=e.percentage??0;return e.exceeded?`danger`:t>=80?`warn`:`ok`}function WSe(e){return(e.windows??[]).filter(e=>!!e.id)}var GSe={free:`Free`,go:`Go`,plus:`Plus`,pro:`Pro`,prolite:`Pro Lite`,promax:`Pro Max`,team:`Team`,business:`Business`,enterprise:`Enterprise`,edu:`Edu`,edu_plus:`Edu Plus`,edu_pro:`Edu Pro`,education:`Education`};function KSe(e){let t=e?.trim().toLowerCase()??``;return!t||t===`unknown`||t===`guest`?``:GSe[t]??t.replace(/[_-]+/g,` `).replace(/\b\w/g,e=>e.toUpperCase())}function qSe(e,t){return e.id===`daily`?t(`quotaDaily`):e.id===`weekly`?t(`quotaWeekly`):e.id===`monthly`?t(`quotaMonthly`):e.id===`fiveHour`?t(`quotaFiveHour`):e.id===`weeklyLimit`?t(`quotaWeeklyLimit`):e.id===`monthlyLimit`?t(`quotaMonthlyLimit`):e.label||t(`quota`)}function JSe(e,t){if(!e)return``;let n=Date.parse(e)-Date.now();if(!Number.isFinite(n)||n<=0)return t(`quotaResetsSoon`);let r=Math.max(1,Math.ceil(n/6e4));return r<60?t(`quotaResetsInMinutes`,{n:r}):t(`quotaResetsInHours`,{n:Math.round(r/60)})}function YSe(e,t){if(!e.expires_at||e.expires_at<=0||!Number.isFinite(e.expires_at))return``;let n=new Date(e.expires_at*1e3);if(Number.isNaN(n.getTime()))return``;let r=`${n.getFullYear()}/${n.getMonth()+1}/${n.getDate()}`;return t(`quotaExpiresOn`,{amount:e.expiring_remain&&e.expiring_remain>0?`${m9(e.expiring_remain)} `:``,unit:e.unit||`credits`,date:r})}function XSe(e,t,n,r,i,a){return[e.has_add_on&&e.add_on_available!==!1?`${n} ${m9(e.add_on_used)} / ${m9(e.add_on_total)} ${e.add_on_unit||`credits`}`:``,e.has_resource_package&&e.resource_package_available!==!1?`${r} ${t} ${m9(e.resource_package_remaining)} ${e.resource_package_unit||`credits`}`:``,a===`workbuddy`?YSe(e,i):``].filter(Boolean)}function ZSe({window:e,t,extra:n}){let r=Math.round(e.percentage??0),i=qSe(e,t),a=t(`quotaUsedPercent`,{n:r}),o=JSe(e.reset_at,t),s=`${i} · ${a}${o?` · ${o}`:``}`,c=h9(e),l=g9(e),u=l===`danger`?`danger`:l===`warn`?`warning`:`success`;return(0,G.jsxs)(PM,{children:[(0,G.jsx)(PM.Trigger,{className:`block w-full min-w-0`,children:(0,G.jsxs)(`div`,{className:`w-full min-w-0 cursor-help`,children:[(0,G.jsxs)(IF,{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,G.jsxs)(IF.Output,{className:`flex w-full items-baseline justify-between gap-3 text-caption`,children:[(0,G.jsx)(`span`,{className:`min-w-0 truncate font-medium text-foreground`,children:i}),(0,G.jsx)(`span`,{className:`mono shrink-0 text-foreground/70`,children:a})]}),(0,G.jsx)(IF.Track,{children:(0,G.jsx)(IF.Fill,{})})]}),o?(0,G.jsx)(`div`,{className:`mt-1 text-caption leading-4 text-muted`,children:o}):null]})}),(0,G.jsx)(PM.Content,{children:(0,G.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,G.jsx)(`div`,{children:s}),n?.map(e=>(0,G.jsx)(`div`,{children:e},e))]})})]})}function QSe({quota:e,t,label:n,usedLabel:r,remainingLabel:i,addOnLabel:a,resourcePackageLabel:o,exceededLabel:s,provider:c}){let l=e.unit||`credits`,u=`${m9(e.used)} / ${m9(e.total)}`,d=`${m9(e.remaining)}`,f=XSe(e,i,a,o,t,c),p=WSe(e),m=c===`codex`?KSe(e.plan):``,h=h9(e),g=g9(e),_=g===`danger`?`danger`:g===`warn`?`warning`:`success`,y=(0,v.useRef)(null);BSe(y);let b=`${r} ${u} ${l} · ${i} ${d} ${l}${f.length?` · ${f.join(` · `)}`:``}`;return p.length>0?(0,G.jsxs)(`div`,{ref:y,className:`account-quota-windows flex w-full min-w-0 flex-col gap-3`,children:[m?(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-caption`,children:[(0,G.jsx)(`span`,{className:`text-muted`,children:t(`quotaPlan`)}),(0,G.jsx)(`span`,{className:`font-medium text-foreground`,children:m})]}):null,p.map((e,n)=>(0,G.jsx)(`div`,{className:`w-full min-w-0`,children:(0,G.jsx)(ZSe,{window:e,t,extra:n===0?f:void 0})},e.id||String(n)))]}):(0,G.jsxs)(PM,{children:[(0,G.jsx)(PM.Trigger,{children:(0,G.jsx)(`div`,{ref:y,className:`w-full cursor-help`,children:(0,G.jsxs)(IF,{className:`account-meter w-full`,color:_,size:`md`,minValue:0,maxValue:100,value:Math.round(h*100),"aria-label":n,valueLabel:b,children:[(0,G.jsxs)(IF.Output,{className:`flex w-full items-baseline justify-between text-caption`,children:[(0,G.jsxs)(`span`,{className:`text-body font-semibold leading-5 text-foreground tabular-nums`,children:[e.exceeded?(0,G.jsx)(`span`,{className:`mr-1.5 text-danger`,children:s}):null,d,(0,G.jsx)(`span`,{className:`ml-1 text-caption font-normal text-foreground/60`,children:l})]}),(0,G.jsxs)(`span`,{className:`mono text-foreground/55`,children:[r,` `,u]})]}),(0,G.jsx)(IF.Track,{children:(0,G.jsx)(IF.Fill,{})})]})})}),(0,G.jsx)(PM.Content,{children:(0,G.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,G.jsxs)(`div`,{children:[r,` `,u,` `,l]}),(0,G.jsxs)(`div`,{children:[i,` `,d,` `,l]}),f.map(e=>(0,G.jsx)(`div`,{children:e},e))]})})]})}function $Se({state:e,stateCopy:t,t:n}){let r=(0,v.useRef)(null),i=HSe(e),a=USe(e);return(0,v.useLayoutEffect)(()=>{let e=r.current;if(!e)return;let t=Z.context(()=>{let e=Z.utils.toArray(`[data-runtime-seg]`),t=e.filter((e,t)=>tt>=i),r=Z.matchMedia();r.add(`(prefers-reduced-motion: reduce)`,()=>{Z.set(t,{scaleY:1,autoAlpha:1}),Z.set(n,{scaleY:.32,autoAlpha:.45})}),r.add(`(prefers-reduced-motion: no-preference)`,()=>{Z.set(e,{transformOrigin:`center bottom`}),Z.to(n,{scaleY:.32,autoAlpha:.45,duration:kV.fast,ease:AV.out,overwrite:!0}),Z.to(t,{scaleY:1,autoAlpha:1,duration:kV.base,ease:AV.out,stagger:{amount:.08,from:`start`},overwrite:!0})})},e);return()=>t.revert()},[i,e]),(0,G.jsxs)(`div`,{ref:r,className:`flex items-center gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 text-caption font-medium text-foreground/75`,children:[(0,G.jsx)(`span`,{className:`status-dot`,"data-state":a===`muted`?void 0:a===`warn`?`warn`:a}),(0,G.jsx)(`span`,{children:n(`runtimeState`)})]}),(0,G.jsx)(`div`,{className:`runtime-meter min-w-[80px] flex-1`,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,G.jsx)(`span`,{"data-runtime-seg":!0,"data-on":t{if(!M&&!N&&P.length===0)return;let e=window.setInterval(()=>A(e=>e+1),1e3);return()=>window.clearInterval(e)},[M,N,P.length]);let F=eCe(j,j===`dead`?N:M,o),I=j===`hot`||j===`ready`?`success`:j===`cooling`?`warning`:j===`quota_exhausted`||j===`login`||j===`unavailable`||j===`dead`||j===`auth_failed`?`danger`:void 0,L=e.last_error||e.lastError,R=e.last_error_kind||e.kind,z=jH(e.provider,e.region,o),B=e.last_checkin_status,V=B===`success`?`checkinRecordSuccess`:B===`already`?`checkinRecordAlready`:B===`skipped`?`checkinRecordSkipped`:B===`error`?`checkinRecordFailed`:`lastCheckinNone`;return(0,v.useLayoutEffect)(()=>{let e=T.current;if(!e)return;let t=k.current;if(k.current=j,!t||t===j)return;let n=Z.context(()=>{let t=Z.matchMedia();t.add(`(prefers-reduced-motion: reduce)`,()=>{Z.set(e,{scale:1,autoAlpha:1})}),t.add(`(prefers-reduced-motion: no-preference)`,()=>{Z.fromTo(e,{scale:.94,autoAlpha:.65},{scale:1,autoAlpha:1,duration:.2,ease:`power2.out`,overwrite:!0})})},e);return()=>n.revert()},[j]),(0,v.useLayoutEffect)(()=>{let e=E.current;if(!e||!n)return;let t=Z.context(()=>{let t=Z.matchMedia();t.add(`(prefers-reduced-motion: reduce)`,()=>{Z.set(e,{autoAlpha:1,y:0})}),t.add(`(prefers-reduced-motion: no-preference)`,()=>{Z.fromTo(e,{autoAlpha:0,y:-6},{autoAlpha:1,y:0,duration:.2,ease:`power3.out`,overwrite:!0})})},e);return()=>t.revert()},[n]),(0,G.jsxs)(HS,{"data-gsap-reveal":!0,"data-state":j,className:`account-card overflow-hidden p-0`,children:[(0,G.jsxs)(HS.Header,{className:`flex-row items-start justify-between gap-2.5 px-4 pt-3.5 pb-2`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2.5`,children:[(0,G.jsx)(`div`,{className:`flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-tertiary`,children:(0,G.jsx)(MH,{provider:e.provider,size:20})}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,G.jsx)(HS.Title,{className:`truncate text-body leading-5`,children:e.name||e.id}),(0,G.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-secondary px-1.5 py-px text-caption text-muted`,children:z})]}),(0,G.jsx)(HS.Description,{className:`mono truncate text-caption leading-4 text-foreground/60`,title:`${e.id}${e.remote_uid?` · UID ${e.remote_uid}`:``}`,children:e.remote_uid?`UID ${e.remote_uid}`:e.id})]})]}),(0,G.jsxs)(`div`,{className:`flex max-w-[48%] shrink-0 flex-wrap justify-end gap-1.5`,children:[(0,G.jsx)(`span`,{ref:T,children:P.length&&j===`cooling`?(0,G.jsxs)(PM,{children:[(0,G.jsx)(PM.Trigger,{children:(0,G.jsx)(`span`,{className:`inline-flex cursor-help`,children:(0,G.jsx)(aC,{size:`sm`,variant:`soft`,color:I,children:F})})}),(0,G.jsx)(PM.Content,{children:(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`div`,{className:`font-medium`,children:o(`partialCooling`)}),P.map(([e,t])=>(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-4 text-caption`,children:[(0,G.jsx)(`span`,{children:e}),(0,G.jsx)(`span`,{className:`mono text-foreground/65`,children:f9(t)})]},e))]})})]}):(0,G.jsx)(aC,{size:`sm`,variant:`soft`,color:I,children:F})}),P.length&&j!==`cooling`?(0,G.jsxs)(PM,{children:[(0,G.jsx)(PM.Trigger,{children:(0,G.jsx)(`span`,{className:`inline-flex cursor-help`,children:(0,G.jsx)(aC,{size:`sm`,variant:`soft`,color:`warning`,children:o(`partialCooling`)})})}),(0,G.jsx)(PM.Content,{children:(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(`div`,{className:`font-medium`,children:o(`partialCooling`)}),P.map(([e,t])=>(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-4 text-caption`,children:[(0,G.jsx)(`span`,{children:e}),(0,G.jsx)(`span`,{className:`mono text-foreground/65`,children:f9(t)})]},e))]})})]}):null]})]}),(0,G.jsxs)(HS.Content,{className:`gap-1.5 px-4 pb-3`,children:[(0,G.jsx)($Se,{state:j,stateCopy:F,t:o}),e.quota?(0,G.jsx)(QSe,{quota:e.quota,t:o,label:o(`quota`),usedLabel:o(`quotaUsed`),remainingLabel:o(`quotaRemaining`),addOnLabel:o(`quotaAddOn`),resourcePackageLabel:o(`quotaResourcePackage`),exceededLabel:o(`quotaExceeded`),provider:e.provider}):(0,G.jsx)(`span`,{className:`text-caption text-foreground/65`,children:o(j===`hot`||j===`ready`||j===`loading`||j===`starting`?`quotaLoading`:`quotaUnavailable`)}),L?(0,G.jsxs)(PM,{children:[(0,G.jsx)(PM.Trigger,{children:(0,G.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,G.jsx)(ro,{size:14,className:`mt-0.5 shrink-0 text-danger`}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[R?(0,G.jsx)(`div`,{className:`mono mb-0.5 truncate text-caption opacity-75`,children:R}):null,(0,G.jsx)(`p`,{className:`break-words line-clamp-3`,children:L})]})]})}),(0,G.jsx)(PM.Content,{children:(0,G.jsxs)(`div`,{className:`max-w-md whitespace-pre-wrap break-words`,children:[R?(0,G.jsx)(`div`,{className:`mono mb-1 text-caption opacity-75`,children:R}):null,L]})})]}):null]}),n&&e.enabled?(0,G.jsxs)(`section`,{ref:E,className:`grid gap-3 bg-surface-secondary/55 px-3 py-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-caption font-medium text-muted`,children:o(`oauthDeviceFlow`)}),(0,G.jsx)(`p`,{className:`mt-1.5 text-caption leading-5 text-muted`,children:e.provider===`codex`?o(`wizardCodexBrowserLead`):o(`qoderLoginHint`)}),(0,G.jsx)(`div`,{className:`mt-2.5 flex flex-wrap gap-2`,children:e.provider===`codex`?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(J,{size:`sm`,isPending:t===`device`,onPress:()=>c(`cli`),children:[(0,G.jsx)(Da,{size:14}),o(`startCodexCliLogin`)]}),(0,G.jsxs)(J,{size:`sm`,variant:`secondary`,isPending:t===`device`,onPress:()=>c(`chatgpt`),children:[(0,G.jsx)(Da,{size:14}),o(`startCodexChatGPTLogin`)]})]}):(0,G.jsxs)(J,{size:`sm`,isPending:t===`device`,onPress:()=>c(),children:[(0,G.jsx)(Da,{size:14}),o(`startBrowserLogin`)]})}),(e.provider===`trae`||e.provider===`codex`||e.provider===`devin`)&&f&&d?(0,G.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[(0,G.jsx)(`p`,{className:`text-caption leading-4 text-muted`,children:o(`wizardCallbackLead`)}),(0,G.jsx)(JM,{className:`h-24 w-full resize-none font-mono text-caption leading-5`,value:u||``,onChange:e=>d(e.target.value),placeholder:o(`wizardCallbackPh`),"aria-label":o(`wizardCallbackPh`)}),(0,G.jsx)(J,{size:`sm`,variant:`secondary`,isPending:t===`callback`,onPress:f,children:o(`wizardSubmitCallback`)})]}):null]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-caption font-medium text-muted`,children:o(`patFallback`)}),(0,G.jsxs)(`div`,{className:`mt-2.5 flex flex-col gap-2 sm:flex-row`,children:[(0,G.jsxs)(YM,{className:`flex-1`,type:`password`,value:a,onChange:s,children:[(0,G.jsx)(IN,{className:`sr-only`,children:o(`pat`)}),(0,G.jsx)(UM,{placeholder:o(`pasteToken`),"aria-label":o(`pat`)})]}),(0,G.jsxs)(J,{size:`sm`,variant:`secondary`,isPending:t===`pat`,onPress:l,children:[(0,G.jsx)(ta,{size:14}),o(`usePat`)]})]})]}),r||i?(0,G.jsxs)(`div`,{className:`text-caption`,children:[r?(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`mb-1 text-caption font-medium text-muted`,children:o(`authUrl`)}),(0,G.jsx)(`code`,{className:`mono block break-all text-foreground`,children:r}),(0,G.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:[(0,G.jsxs)(J,{size:`sm`,variant:`secondary`,onPress:()=>window.open(r,`_blank`,`noopener,noreferrer`),children:[(0,G.jsx)(Zr,{size:14}),o(`openAuthUrl`)]}),(0,G.jsxs)(J,{size:`sm`,variant:`ghost`,onPress:()=>{Z7(r).then(e=>{e&&(O(!0),window.setTimeout(()=>O(!1),1100))})},children:[(0,G.jsx)(X7,{copied:D}),o(D?`copied`:`copy`)]})]})]}):null,i?(0,G.jsx)(`p`,{className:`mt-1 text-muted`,children:i}):null]}):null]}):null,b?(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-3 border-t border-separator px-4 py-2 text-caption text-muted`,children:[(0,G.jsxs)(PM,{children:[(0,G.jsx)(PM.Trigger,{children:(0,G.jsxs)(`span`,{className:`flex cursor-help items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`font-medium`,children:o(`lastCheckin`)}),(0,G.jsx)(`span`,{className:B===`error`?`text-danger`:``,children:o(V)})]})}),(0,G.jsxs)(PM.Content,{children:[e.last_checkin_at?new Date(e.last_checkin_at).toLocaleString():o(`lastCheckinNone`),e.last_checkin_msg?` · ${e.last_checkin_msg}`:``]})]}),(0,G.jsxs)(PM,{children:[(0,G.jsx)(PM.Trigger,{children:(0,G.jsxs)(`span`,{className:`flex cursor-help items-center gap-1.5`,children:[(0,G.jsx)(`span`,{className:`font-medium`,children:o(`autoCheckin`)}),(0,G.jsx)(`span`,{className:`mono text-caption text-foreground/55`,children:e.checkin_time||_}),(0,G.jsx)(F7,{isSelected:!!e.auto_checkin,isDisabled:!!t,ariaLabel:o(`autoCheckin`),onChange:e=>y?.(e)})]})}),(0,G.jsx)(PM.Content,{children:e.checkin_time?o(`checkinCustom`):o(`checkinInherit`)})]})]}):null,(0,G.jsxs)(HS.Footer,{className:`flex flex-wrap items-center gap-1.5 bg-surface-secondary px-4 py-2`,children:[m?(0,G.jsxs)(PM,{children:[(0,G.jsx)(PM.Trigger,{children:(0,G.jsx)(J,{isIconOnly:!0,size:`sm`,variant:`secondary`,isPending:t===`refresh`,onPress:m,"aria-label":o(`refreshAccount`),children:(0,G.jsx)(qr,{size:15})})}),(0,G.jsx)(PM.Content,{children:o(`refreshAccount`)})]}):null,(0,G.jsxs)(PM,{children:[(0,G.jsx)(PM.Trigger,{children:(0,G.jsx)(J,{isIconOnly:!0,size:`sm`,variant:n?`secondary`:`ghost`,isDisabled:!e.enabled,onPress:C,"aria-label":o(`authentication`),children:(0,G.jsx)(ta,{size:15})})}),(0,G.jsx)(PM.Content,{children:o(`authentication`)})]}),(0,G.jsxs)(PM,{children:[(0,G.jsx)(PM.Trigger,{children:(0,G.jsx)(J,{isIconOnly:!0,size:`sm`,variant:`ghost`,onPress:w,"aria-label":o(`accountModels`),children:(0,G.jsx)(ji,{size:15})})}),(0,G.jsx)(PM.Content,{children:o(`accountModels`)})]}),(0,G.jsxs)(PM,{children:[(0,G.jsx)(PM.Trigger,{children:(0,G.jsx)(J,{isIconOnly:!0,size:`sm`,variant:`ghost`,onPress:S,"aria-label":o(`editAccount`),children:(0,G.jsx)(ya,{size:15})})}),(0,G.jsx)(PM.Content,{children:o(`editAccount`)})]}),b?(0,G.jsxs)(PM,{children:[(0,G.jsx)(PM.Trigger,{children:(0,G.jsx)(J,{isIconOnly:!0,size:`sm`,variant:`ghost`,isDisabled:!e.enabled||!!t,isPending:t===`checkin`,onPress:b,"aria-label":o(`checkinNow`),children:(0,G.jsx)(si,{size:15})})}),(0,G.jsx)(PM.Content,{children:o(`checkinNow`)})]}):null,(0,G.jsxs)(uF,{children:[(0,G.jsx)(uF.Trigger,{children:(0,G.jsx)(J,{isIconOnly:!0,size:`sm`,variant:`secondary`,"aria-label":o(`more`),children:(0,G.jsx)(Fi,{size:16})})}),(0,G.jsx)(uF.Popover,{placement:`bottom end`,children:(0,G.jsxs)(uF.Menu,{"aria-label":o(`more`),onAction:e=>{e===`export`&&p(),e===`checkin-records`&&x?.(),e===`delete`&&h()},children:[e.auth_type===`none`?null:(0,G.jsxs)(uF.Item,{id:`export`,textValue:o(`export`),children:[(0,G.jsx)(Di,{size:15}),o(`export`)]}),x?(0,G.jsxs)(uF.Item,{id:`checkin-records`,textValue:o(`checkinRecords`),children:[(0,G.jsx)(sa,{size:15}),o(`checkinRecords`)]}):null,(0,G.jsxs)(uF.Item,{id:`delete`,textValue:o(`delete`),className:`text-danger`,children:[(0,G.jsx)(qa,{size:15}),o(`delete`)]})]})})]}),(0,G.jsx)(`div`,{className:`ml-auto flex shrink-0 flex-nowrap items-center gap-3 whitespace-nowrap`,children:(0,G.jsx)(F7,{isSelected:!!e.enabled,isDisabled:t===`toggle`,ariaLabel:e.enabled?o(`disable`):o(`enable`),label:e.enabled?o(`enabledState`):o(`disabled`),onChange:g})})]})]})}function nCe(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 rCe(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}function iCe({account:e,t,onClose:n}){let[r,i]=(0,v.useState)([]),[a,o]=(0,v.useState)(!!e?.id),[s,c]=(0,v.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,v.useEffect)(()=>{l&&d()},[l]),(0,G.jsx)(Y.Root,{isOpen:!!e,onOpenChange:e=>{e||n()},children:(0,G.jsx)(Y.Backdrop,{variant:`blur`,children:(0,G.jsx)(Y.Container,{size:`lg`,scroll:`inside`,children:(0,G.jsxs)(Y.Dialog,{children:[(0,G.jsxs)(Y.Header,{className:`items-start justify-between gap-4 px-5 pt-5`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(Y.Heading,{className:`text-section font-semibold`,children:u}),(0,G.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:t(`checkinRecordsHint`)})]}),(0,G.jsx)(Y.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,G.jsx)(ao,{size:16})})]}),(0,G.jsxs)(Y.Body,{className:`px-5 pb-2`,children:[s?(0,G.jsx)(`div`,{className:`mb-3`,children:(0,G.jsx)(QI,{title:s})}):null,a?(0,G.jsxs)(`div`,{className:`space-y-2 py-1`,children:[(0,G.jsx)(Q,{className:`h-16 w-full`}),(0,G.jsx)(Q,{className:`h-16 w-full`}),(0,G.jsx)(Q,{className:`h-16 w-full`})]}):r.length?(0,G.jsx)(`div`,{className:`divide-y divide-separator overflow-hidden rounded-lg bg-surface-secondary`,children:r.map(e=>{let n=nCe(e,t);return(0,G.jsxs)(`div`,{className:`flex items-start gap-3 px-3 py-3`,children:[(0,G.jsx)(`span`,{className:`status-dot mt-1.5 shrink-0`,"data-state":e.status===`error`?`warn`:`ok`}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(aC,{size:`sm`,variant:`soft`,color:n.color,children:n.label}),(0,G.jsx)(`span`,{className:`mono text-caption text-muted`,children:rCe(e.created_at)})]}),(0,G.jsx)(`p`,{className:`mt-1 break-words text-caption leading-5 text-foreground/75`,children:e.message||`—`})]})]},e.id)})}):(0,G.jsx)(I7,{className:`min-h-44 rounded-3xl bg-surface-secondary`,title:t(`checkinRecordsEmpty`),hint:t(`checkinRecordsHint`)})]}),(0,G.jsxs)(Y.Footer,{className:`justify-between px-5 pb-5`,children:[(0,G.jsx)(`span`,{className:`mono text-caption text-muted`,children:t(`checkinRecordsCount`,{count:r.length})}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(J,{size:`sm`,variant:`ghost`,onPress:n,children:t(`close`)}),(0,G.jsxs)(J,{size:`sm`,variant:`secondary`,isPending:a,onPress:()=>void d(),children:[(0,G.jsx)(qr,{size:14}),t(`refresh`)]})]})]})]})})})})}function aCe(e){let t=e.route_display_name||``;return t&&t!==(e.display_name||e.id)?t:``}function oCe({account:e,t,onClose:n}){let[r,i]=(0,v.useState)([]),[a,o]=(0,v.useState)(!!e?.id),[s,c]=(0,v.useState)(!1),[l,u]=(0,v.useState)(``),d=e?.id||``,f=t(`accountModelsTitle`,{name:e?.name||e?.id||``}),p=e?jH(e.provider,e.region,t):``;async function m(e=!1){if(d){e?c(!0):(o(!0),i([])),u(``);try{let t=await(e?HI(d):VI(d));i(t.data||[])}catch(e){i([]),u(e instanceof Error?e.message:String(e))}finally{o(!1),c(!1)}}}return(0,v.useEffect)(()=>{if(!d)return;let e=!1;return VI(d).then(t=>{e||(i(t.data||[]),u(``),o(!1))}).catch(t=>{e||(i([]),u(t instanceof Error?t.message:String(t)),o(!1))}),()=>{e=!0}},[d]),(0,G.jsx)(Y.Root,{isOpen:!!e,onOpenChange:e=>{e||n()},children:(0,G.jsx)(Y.Backdrop,{variant:`blur`,children:(0,G.jsx)(Y.Container,{size:`lg`,scroll:`inside`,children:(0,G.jsxs)(Y.Dialog,{children:[(0,G.jsxs)(Y.Header,{className:`items-start justify-between gap-4 px-5 pt-5`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(Y.Heading,{className:`text-section font-semibold`,children:f}),(0,G.jsx)(`p`,{className:`mt-1 text-caption font-normal leading-5 text-muted`,children:t(`accountModelsHint`)}),e?(0,G.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-caption text-muted`,children:[(0,G.jsx)(MH,{provider:e.provider,size:14}),(0,G.jsx)(`span`,{children:p}),(0,G.jsx)(`span`,{className:`text-border`,children:`·`}),(0,G.jsx)(`span`,{className:`mono`,children:e.id})]}):null]}),(0,G.jsx)(Y.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,G.jsx)(ao,{size:16})})]}),(0,G.jsxs)(Y.Body,{className:`px-5 pb-2`,children:[l?(0,G.jsx)(`div`,{className:`mb-3`,children:(0,G.jsx)(QI,{title:t(`accountModelsError`,{msg:l})})}):null,a||s?(0,G.jsxs)(`div`,{className:`space-y-2 py-1`,children:[(0,G.jsx)(Q,{className:`h-14 w-full`}),(0,G.jsx)(Q,{className:`h-14 w-full`}),(0,G.jsx)(Q,{className:`h-14 w-full`})]}):r.length?(0,G.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=aCe(n),a=rH(n),o=iH(n);return(0,G.jsxs)(`li`,{className:`flex items-start gap-3 px-3 py-2.5`,children:[(0,G.jsx)(`span`,{className:`status-dot mt-1.5`,"data-state":n.stale?void 0:`ok`}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`truncate text-body font-medium`,children:n.display_name||n.id}),o?(0,G.jsx)(aC,{size:`sm`,variant:`soft`,color:`success`,children:t(`modelFree`)}):null,a?(0,G.jsx)(`span`,{className:`mono text-caption text-muted`,children:a}):null,n.stale?(0,G.jsx)(aC,{size:`sm`,variant:`soft`,color:`warning`,children:t(`fallback`)}):null]}),(0,G.jsx)(`div`,{className:`mono mt-0.5 truncate text-caption text-muted`,children:n.id}),i?(0,G.jsx)(`div`,{className:`mt-0.5 text-caption text-muted`,children:t(`routedTo`,{model:i})}):null]}),(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5 pt-0.5 text-caption text-muted`,children:[(0,G.jsx)(MH,{provider:r,size:12}),(0,G.jsx)(`span`,{children:r})]})]},n.id)})}):(0,G.jsx)(I7,{className:`min-h-48 rounded-3xl bg-surface-secondary`,icon:(0,G.jsx)(ji,{size:22}),title:t(`accountModelsEmpty`),hint:t(`noModelsYet`)})]}),(0,G.jsxs)(Y.Footer,{className:`justify-between px-5 pb-5`,children:[(0,G.jsx)(`span`,{className:`mono text-caption text-muted`,children:a?t(`refreshing`):t(`shownTotal`,{shown:r.length,total:r.length})}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(J,{size:`sm`,variant:`ghost`,onPress:n,children:t(`close`)}),(0,G.jsxs)(J,{size:`sm`,variant:`secondary`,isPending:s,onPress:()=>void m(!0),children:[(0,G.jsx)(qr,{size:14}),t(s?`refreshing`:`refresh`)]})]})]})]})})})})}var sCe=`w-28`;function _9({label:e,hint:t,labelWidthClass:n=sCe,htmlFor:r,align:i=`center`,children:a}){return(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex gap-3 ${i===`start`?`items-start`:`items-center`}`,children:[(0,G.jsx)(IN,{htmlFor:r,className:`${n} shrink-0 ${i===`start`?`pt-2`:``} text-body font-medium text-foreground`,children:e}),(0,G.jsx)(`div`,{className:`min-w-0 flex-1 [&_[data-slot=input]]:w-full [&_[data-slot=textarea]]:w-full`,children:a})]}),t?(0,G.jsx)(`p`,{className:`mt-1.5 pl-[7.75rem] text-caption leading-5 text-muted`,children:t}):null]})}function cCe({catalog:e,selected:t,onChange:n,isDisabled:r,t:i}){let[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)(t),l=(0,v.useMemo)(()=>new Set(t),[t]),u=(0,v.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]),d=(0,v.useMemo)(()=>{if(!e)return[];let n=new Set(e);return t.filter(e=>!n.has(e))},[e,t]),f=e?.length??0,p=t.filter(e=>!d.includes(e)).length;function m(e){o(e),c(t)}function h(e,r){n(r?[...t,e]:t.filter(t=>t!==e))}function g(){let e=new Set(t);u.forEach(t=>e.add(t)),n([...e])}function _(){let e=new Set(u);n(t.filter(t=>!e.has(t)))}return(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(PN,{"aria-label":i(`modelPickerSearch`),value:a,onChange:m,isDisabled:r,className:`min-w-0 flex-1 basis-48`,children:(0,G.jsxs)(PN.Group,{children:[(0,G.jsx)(PN.SearchIcon,{}),(0,G.jsx)(PN.Input,{placeholder:i(`modelPickerSearch`)}),(0,G.jsx)(PN.ClearButton,{})]})}),(0,G.jsx)(`span`,{className:`mono shrink-0 text-caption text-muted`,children:i(`modelPickerCount`,{selected:p,total:f})}),(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,G.jsxs)(J,{size:`sm`,variant:`ghost`,isDisabled:r||u.length===0,onPress:g,children:[(0,G.jsx)(xi,{size:14}),i(`modelPickerSelectAll`)]}),(0,G.jsxs)(J,{size:`sm`,variant:`ghost`,isDisabled:r||t.length===0,onPress:_,children:[(0,G.jsx)(La,{size:14}),i(`modelPickerClear`)]})]})]}),(0,G.jsxs)(`div`,{className:`max-h-[300px] overflow-y-auto overscroll-contain rounded-lg bg-surface-secondary p-1`,children:[e===null?(0,G.jsx)(`p`,{className:`px-2.5 py-2 text-caption text-muted`,children:i(`refreshing`)}):null,d.map(e=>(0,G.jsxs)(`div`,{className:`flex items-center gap-2.5 rounded-md px-2.5 py-1.5`,children:[(0,G.jsx)(`span`,{className:`mono min-w-0 flex-1 truncate text-body text-muted line-through`,children:e}),(0,G.jsx)(`span`,{className:`shrink-0 text-caption text-warning`,children:i(`modelPickerOffline`)}),(0,G.jsx)(J,{isIconOnly:!0,size:`sm`,variant:`ghost`,isDisabled:r,"aria-label":i(`modelPickerRemove`,{model:e}),onPress:()=>h(e,!1),children:(0,G.jsx)(ao,{size:14})})]},`offline-${e}`)),u.map(e=>(0,G.jsx)(tC,{isSelected:l.has(e),isDisabled:r,onChange:t=>h(e,t),className:`flex w-full cursor-pointer rounded-md px-2.5 py-1.5 transition-colors hover:bg-default`,children:(0,G.jsxs)(tC.Content,{className:`flex min-w-0 flex-1 items-center gap-2.5`,children:[(0,G.jsx)(tC.Control,{children:(0,G.jsx)(tC.Indicator,{})}),(0,G.jsx)(`span`,{className:`mono min-w-0 truncate text-body text-foreground`,children:e})]})},e)),e!==null&&u.length===0?(0,G.jsx)(`p`,{className:`px-2.5 py-2 text-caption text-muted`,children:i(f===0?`noAccountModels`:`modelPickerNoMatch`)}):null]})]})}function lCe(e){let[t,n]=(0,v.useState)(e);e&&!t&&n(!0);let r=(0,v.useRef)(null),i=(0,v.useRef)(null),a=(0,v.useRef)(e);return(0,v.useLayoutEffect)(()=>{let t=r.current,o=i.current;if(!t||!o)return;if(a.current){a.current=!1;return}Z.killTweensOf([t,o]);let s=t.getBoundingClientRect().height;if(e){Z.set(t,{overflow:`hidden`});let e=t.scrollHeight;Z.fromTo(t,{height:s===e?0:s},{height:e,duration:MV(kV.base),ease:AV.out,onComplete:()=>Z.set(t,{clearProps:`height,overflow`})}),Z.fromTo(o,{autoAlpha:0,y:-6},{autoAlpha:1,y:0,duration:MV(kV.base),ease:AV.out})}else Z.set(t,{overflow:`hidden`,height:s}),Z.to(o,{autoAlpha:0,y:-4,duration:MV(kV.fast),ease:AV.inOut}),Z.to(t,{height:0,duration:MV(kV.fast+.04),ease:AV.inOut,onComplete:()=>n(!1)});return()=>{Z.killTweensOf([t,o])}},[e,t]),{mounted:t,outerRef:r,innerRef:i}}function uCe({account:e,checkinDefaultTime:t,checkinTimezone:n,busy:r,t:i,onClose:a,onSave:o}){let[s,c]=(0,v.useState)(e?.name||``),[l,u]=(0,v.useState)(e?.max_inflight??4),[d,f]=(0,v.useState)(e?.priority??50),[p,m]=(0,v.useState)(e?.proxy_url||``),[h,g]=(0,v.useState)(!!e?.drop_system_prompt),[_,y]=(0,v.useState)(Object.entries(e?.model_aliases||{}).map(([e,t])=>({alias:e,model:t}))),[b,x]=(0,v.useState)({alias:``,model:``}),[S,C]=(0,v.useState)(!!e?.models_restricted),[w,T]=(0,v.useState)(e?.enabled_models||[]),{mounted:E,outerRef:D,innerRef:O}=lCe(S),[k,A]=(0,v.useState)(null),[j,M]=(0,v.useState)(!e?.checkin_time),[N,P]=(0,v.useState)(e?.checkin_time||null),[F,I]=(0,v.useState)(``);(0,v.useEffect)(()=>{if(!e?.id)return;let t=!1;return VI(e.id).then(e=>{t||A(e.data||[])}).catch(()=>{t||A([])}),()=>{t=!0}},[e?.id]);let L=i(`editAccountTitle`,{name:e?.name||e?.id||``}),R=e?jH(e.provider,e.region,i):``;async function z(n){n?.preventDefault();let r=s.trim();if(!r){I(i(`accountNameRequired`));return}if(!Number.isInteger(l)||l<1||l>32){I(i(`maxInflightInvalid`));return}if(!Number.isInteger(d)||d<1||d>100){I(i(`priorityInvalid`));return}if(t!==void 0&&!j&&!/^([01]\d|2[0-3]):[0-5]\d$/.test(N??t)){I(i(`checkinTimeInvalid`));return}I(``);try{await o({name:r,max_inflight:l,priority:d,proxy_url:p.trim(),checkin_time:t===void 0?void 0:j?``:N??t,drop_system_prompt:e?.provider===`workbuddy`||e?.provider===`trae`?h:void 0,model_aliases:Object.fromEntries(_.filter(e=>e.alias.trim()&&e.model.trim()).map(e=>[e.alias.trim(),e.model.trim()])),enabled_models:S?w:[],set_model_routing:!0}),a()}catch(e){I(e instanceof Error?e.message:String(e))}}return(0,G.jsx)(Y.Root,{isOpen:!!e,onOpenChange:e=>{!e&&!r&&a()},children:(0,G.jsx)(Y.Backdrop,{variant:`blur`,children:(0,G.jsx)(Y.Container,{placement:`center`,size:`lg`,scroll:`inside`,children:(0,G.jsxs)(Y.Dialog,{className:`w-full sm:w-[42rem] sm:max-w-[calc(100vw-2rem)]`,children:[(0,G.jsxs)(Y.Header,{className:`items-start justify-between gap-4 px-6 pt-6`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(Y.Heading,{className:`text-section font-semibold`,children:L}),(0,G.jsx)(`p`,{className:`mt-1.5 text-body font-normal leading-6 text-muted`,children:i(`editAccountHint`)}),e?(0,G.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(aC,{size:`sm`,variant:`soft`,children:(0,G.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,G.jsx)(MH,{provider:e.provider,size:14}),(0,G.jsx)(`span`,{children:R})]})}),(0,G.jsx)(`span`,{className:`mono text-caption text-muted`,children:e.id})]}):null]}),(0,G.jsx)(Y.CloseTrigger,{isDisabled:r,"aria-label":i(`close`),className:`grid size-9 shrink-0 place-items-center rounded-lg text-muted hover:bg-surface-secondary`,children:(0,G.jsx)(ao,{size:18})})]}),(0,G.jsxs)(Y.Body,{className:`px-6 pb-2 pt-1`,children:[F?(0,G.jsxs)(tF,{status:`danger`,className:`mb-4`,children:[(0,G.jsx)(tF.Indicator,{}),(0,G.jsx)(tF.Content,{children:(0,G.jsx)(tF.Title,{children:F})})]}):null,(0,G.jsxs)(QP,{className:`space-y-4`,onSubmit:e=>void z(e),children:[(0,G.jsx)(_9,{label:i(`accountName`),children:(0,G.jsx)(UM,{value:s,onChange:e=>c(e.target.value),placeholder:i(`wizardNamePh`),"aria-label":i(`accountName`),disabled:r,autoFocus:!0})}),(0,G.jsx)(_9,{label:i(`maxInflight`),hint:i(`maxInflightHint`),children:(0,G.jsx)(hF,{value:l,onChange:e=>u(e??4),minValue:1,maxValue:32,isDisabled:r,isRequired:!0,children:(0,G.jsxs)(hF.Group,{children:[(0,G.jsx)(hF.DecrementButton,{}),(0,G.jsx)(hF.Input,{"aria-label":i(`maxInflight`)}),(0,G.jsx)(hF.IncrementButton,{})]})})}),(0,G.jsx)(_9,{label:i(`priority`),hint:i(`priorityHint`),children:(0,G.jsx)(hF,{value:d,onChange:e=>f(e??50),minValue:1,maxValue:100,isDisabled:r,isRequired:!0,children:(0,G.jsxs)(hF.Group,{children:[(0,G.jsx)(hF.DecrementButton,{}),(0,G.jsx)(hF.Input,{"aria-label":i(`priority`)}),(0,G.jsx)(hF.IncrementButton,{})]})})}),(0,G.jsx)(_9,{label:i(`proxyUrl`),hint:i(`proxyUrlHint`),children:(0,G.jsx)(UM,{value:p,onChange:e=>m(e.target.value),placeholder:i(`proxyUrlPlaceholder`),"aria-label":i(`proxyUrl`),disabled:r})}),e?.provider===`workbuddy`||e?.provider===`trae`?(0,G.jsx)(_9,{label:i(`dropSystemPrompt`),hint:i(e?.provider===`trae`?`dropSystemPromptTraeHint`:`dropSystemPromptHint`),children:(0,G.jsx)(F7,{isSelected:h,isDisabled:r,ariaLabel:i(`dropSystemPrompt`),onChange:g})}):null,(0,G.jsx)(_9,{align:`start`,label:i(`accountModelAliases`),hint:i(`accountModelAliasesHint`),children:(0,G.jsxs)(`div`,{className:`space-y-2`,children:[_.map(e=>(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,G.jsxs)(`span`,{className:`mono min-w-0 truncate text-body`,children:[e.alias,` → `,e.model]}),(0,G.jsx)(J,{size:`sm`,variant:`ghost`,isDisabled:r,onPress:()=>y(t=>t.filter(t=>t.alias!==e.alias)),children:i(`modelAliasRemove`)})]},e.alias)),(0,G.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-[1fr_1fr_auto]`,children:[(0,G.jsx)(UM,{"aria-label":i(`modelAliasName`),value:b.alias,onChange:e=>x(t=>({...t,alias:e.target.value})),placeholder:i(`modelAliasPlaceholder`),disabled:r}),(0,G.jsx)(UM,{"aria-label":i(`modelAliasTarget`),value:b.model,onChange:e=>x(t=>({...t,model:e.target.value})),placeholder:i(`accountModelAliasTargetPlaceholder`),disabled:r}),(0,G.jsx)(J,{size:`sm`,variant:`secondary`,isDisabled:r||!b.alias.trim()||!b.model.trim(),onPress:()=>{y(e=>[...e.filter(e=>e.alias!==b.alias.trim()),{alias:b.alias.trim(),model:b.model.trim()}]),x({alias:``,model:``})},children:i(`modelAliasAdd`)})]})]})}),(0,G.jsxs)(`section`,{className:`space-y-3 pt-1`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`div`,{className:`text-body font-medium text-foreground`,children:i(`enabledModels`)}),(0,G.jsx)(`p`,{className:`mt-0.5 text-caption leading-5 text-muted`,children:i(`enabledModelsHint`)})]}),(0,G.jsx)(F7,{isSelected:S,isDisabled:r,ariaLabel:i(`restrictModels`),label:i(S?`restrictModels`:`allModels`),onChange:C})]}),E?(0,G.jsx)(`div`,{ref:D,children:(0,G.jsx)(`div`,{ref:O,children:(0,G.jsx)(cCe,{catalog:k?k.map(e=>e.id):null,selected:w,onChange:T,isDisabled:r,t:i})})}):null]}),t===void 0?null:(0,G.jsx)(_9,{label:i(`autoCheckinTime`),hint:i(`checkinScheduleHint`),children:(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsx)(F7,{isSelected:j,isDisabled:r,onChange:M,ariaLabel:i(`checkinInherit`),label:i(`checkinInherit`)}),(0,G.jsxs)(`p`,{className:`text-caption text-muted`,children:[i(`checkinDefaultValue`,{time:t}),` · `,(0,G.jsx)(`span`,{className:`mono`,children:n})]}),j?null:(0,G.jsx)(UM,{type:`time`,value:N??t,onChange:e=>P(e.target.value),"aria-label":i(`autoCheckinTime`),disabled:r,required:!0})]})})]})]}),(0,G.jsxs)(Y.Footer,{className:`justify-end gap-2 px-6 pb-6`,children:[(0,G.jsx)(J,{variant:`ghost`,isDisabled:r,onPress:a,children:i(`cancel`)}),(0,G.jsx)(J,{isPending:r,onPress:()=>void z(),children:i(`save`)})]})]})})})})}var dCe={1:`grid-cols-1`,2:`grid-cols-1 sm:grid-cols-2`,3:`grid-cols-1 sm:grid-cols-3`};function v9({options:e,value:t,onChange:n,ariaLabel:r,columns:i=2,className:a=``}){let o=(0,v.useRef)(null);return(0,v.useLayoutEffect)(()=>{let e=o.current;if(!e)return;let t=Z.context(()=>{let e=Z.matchMedia();e.add(`(prefers-reduced-motion: reduce)`,()=>{Z.set(`[data-option-tile]`,{autoAlpha:1,y:0})}),e.add(`(prefers-reduced-motion: no-preference)`,()=>{Z.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,G.jsx)(`div`,{ref:o,role:`radiogroup`,"aria-label":r,className:`grid gap-3 ${dCe[i]} ${a}`.trim(),children:e.map(e=>{let r=e.value===t;return(0,G.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,G.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,G.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-body font-medium leading-5 text-foreground`,children:e.label})]},e.value)})})}var y9=new Set([`qoder-global`,`qoder-cn`,`workbuddy-global`,`workbuddy-cn`,`trae-cn`]),fCe=[`qoder-global`,`qoder-cn`,`workbuddy-global`,`workbuddy-cn`,`trae-cn`];function pCe(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 b9(e,t){return!t||`${e.label} ${e.subtitle||``} ${e.hint||``} ${e.provider} ${e.id}`.toLowerCase().includes(t)}function mCe({ariaLabel:e}){return(0,G.jsx)(`div`,{className:`space-y-8`,"aria-busy":`true`,"aria-label":e,children:Array.from({length:2},(e,t)=>(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(UA,{className:`h-3 w-24 rounded-lg`}),(0,G.jsx)(UA,{className:`h-3 w-40 rounded-lg`})]}),(0,G.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:Array.from({length:t===0?5:6},(e,t)=>(0,G.jsxs)(`div`,{className:`card flex flex-row items-center gap-3.5 rounded-xl bg-surface px-4 py-3.5`,children:[(0,G.jsx)(UA,{className:`size-10 shrink-0 rounded-lg`}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-1.5`,children:[(0,G.jsx)(UA,{className:`h-3.5 w-28 rounded-lg`}),(0,G.jsx)(UA,{className:`h-3 w-36 rounded-lg`})]})]},t))})]},t))})}function hCe({tile:e,disabled:t,onSelect:n}){return(0,G.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,G.jsx)(`span`,{className:`grid size-9 shrink-0 place-items-center rounded-lg text-foreground [&_svg]:size-[18px]`,children:(0,G.jsx)(MH,{provider:e.provider,size:18})}),(0,G.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`span`,{className:`block truncate text-body font-medium leading-5 text-foreground`,children:e.label}),e.subtitle?(0,G.jsx)(`span`,{className:`mt-0.5 block truncate text-caption leading-4 text-muted`,children:e.subtitle}):null]})]})}function gCe({title:e,subtitle:t,tiles:n,disabled:r,onSelect:i}){return n.length?(0,G.jsxs)(`section`,{className:`space-y-3.5`,children:[(0,G.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,G.jsx)(`h3`,{className:`text-[10px] font-semibold tracking-[0.12em] uppercase text-muted`,children:e}),t?(0,G.jsx)(`p`,{className:`text-caption leading-5 text-muted`,children:t}):null]}),(0,G.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:n.map(e=>(0,G.jsx)(hCe,{tile:e,disabled:r,onSelect:i},e.id))})]}):null}function _Ce({options:e,onSelect:t,disabled:n,empty:r,ariaLabel:i}){let{t:a}=EI(),[o,s]=(0,v.useState)(``),c=o.trim().toLowerCase(),l=(0,v.useMemo)(()=>{let t=pCe(e.filter(e=>y9.has(e.id)),fCe),n=e.filter(e=>!y9.has(e.id)).sort((e,t)=>e.label.localeCompare(t.label));return[{id:`subscriptions`,titleKey:`providerGroupSubscriptions`,subtitleKey:`providerGroupSubscriptionsHint`,tiles:t.filter(e=>b9(e,c))},{id:`experimental`,titleKey:`providerGroupExperimental`,subtitleKey:`providerGroupExperimentalHint`,tiles:n.filter(e=>b9(e,c))}]},[c,e]),u=l.reduce((e,t)=>e+t.tiles.length,0);return(0,G.jsxs)(`div`,{className:`space-y-8`,role:`listbox`,"aria-label":i,children:[(0,G.jsx)(B7,{value:o,onChange:s,placeholder:a(`providerFindPlaceholder`),ariaLabel:a(`providerFindPlaceholder`),className:`max-w-sm`}),u===0?r||(0,G.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,G.jsx)(gCe,{title:a(e.titleKey),subtitle:a(e.subtitleKey),tiles:e.tiles,disabled:n,onSelect:t},e.id))]})}function x9(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 S9(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 vCe(e,t){return GI(x9(e,t))}var C9={global:`Global`,cn:`CN`},yCe={"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`,"meta-global":`accountTypeMetaGlobal`},bCe={"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`,"meta-global":`accountTypeMetaGlobalHint`};async function xCe(){let e=(await UI().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 w9(e,t){let n=yCe[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||C9[e.region]||``,i=e.descriptor.regions.length>1&&r?` ${r}`:``;return`${e.descriptor.label}${i}`.trim()}function T9(e,t){if(!e)return``;let n=bCe[e.id];if(!n)return``;let r=t(n);return r===n?``:r}function SCe({phase:e,busy:t,tab:n,forTab:r}){return e===`done`?(0,G.jsx)(yi,{size:16,className:`text-success`}):t&&n===r?(0,G.jsx)(PV,{size:16,loading:!0}):null}var CCe=90,wCe=2e3;function TCe({isOpen:e,onClose:t,onAdded:n}){let{t:r}=EI(),[i,a]=(0,v.useState)(`method`),[o,s]=(0,v.useState)(`browser`),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)([]),[f,p]=(0,v.useState)(!1),[m,h]=(0,v.useState)(!1),[g,_]=(0,v.useState)(``),[y,b]=(0,v.useState)(4),[x,S]=(0,v.useState)(50),[C,w]=(0,v.useState)(!0),[T,E]=(0,v.useState)(``),[D,O]=(0,v.useState)(``),[k,A]=(0,v.useState)(``),[j,M]=(0,v.useState)(`payg`),[N,P]=(0,v.useState)(``),[F,I]=(0,v.useState)(``),[L,R]=(0,v.useState)(``),[z,B]=(0,v.useState)(`idle`),[V,H]=(0,v.useState)(``),[ee,te]=(0,v.useState)(``),[ne,re]=(0,v.useState)(!1),[ie,ae]=(0,v.useState)(``),[oe,se]=(0,v.useState)(`cli`),ce=(0,v.useRef)(null),le=(0,v.useRef)(null),ue=(0,v.useRef)(null),de=(0,v.useRef)(``),fe=(0,v.useRef)(null),pe=(0,v.useRef)(null);function me(){fe.current!==null&&(window.clearTimeout(fe.current),fe.current=null)}(0,v.useEffect)(()=>()=>me(),[]),(0,v.useEffect)(()=>{if(!e)return;let t=!1;return p(!0),d([]),l(``),xCe().then(e=>{t||(d(e),l(``),s(`browser`))}).finally(()=>{t||p(!1)}),()=>{t=!0}},[e]);let he=u.find(e=>e.id===c),ge=!f&&u.length>0,_e=he?.descriptor.capabilities?.pat_login!==!1,ve=he?.descriptor.capabilities?.import_export!==!1,ye=he?.descriptor.capabilities?.browser_login!==!1,be=he?.provider===`workbuddy`||he?.provider===`trae`,xe=he?.provider===`trae`||he?.provider===`devin`||he?.provider===`codex`,Se=z===`busy`||z===`polling`,Ce=!!de.current||Se,we=z===`done`,Te=T9(he,r);(0,v.useEffect)(()=>{o===`pat`&&!_e&&s(`browser`),o===`import`&&!ve&&s(`browser`)},[ve,_e,o]),(0,v.useEffect)(()=>{ye||(_e?s(`pat`):ve&&s(`import`))},[ye,ve,_e]);function Ee(){return!Number.isInteger(y)||y<1||y>32?4:y}function De(){return!Number.isInteger(x)||x<1||x>100?50:x}function Oe(){return{max_inflight:Ee(),priority:De(),drop_system_prompt:be?C:he?.provider!==`kimi`,proxy_url:T.trim()}}function ke(){me(),a(`method`),s(`browser`),l(``),d([]),p(!1),_(``),b(4),S(50),w(!0),E(``),O(``),A(``),M(`payg`),P(``),I(``),R(``),h(!1),B(`idle`),H(``),te(``),re(!1),ae(``),se(`cli`),de.current=``}function Ae(){Se||(ke(),t())}function je(){ke(),t()}(0,v.useLayoutEffect)(()=>{let t=ce.current;if(e||(ue.current=null),!t||!e)return;let n=Z.context(()=>{let e=Z.matchMedia();e.add(`(prefers-reduced-motion: reduce)`,()=>{Z.set(t,{autoAlpha:1,x:0,y:0})}),e.add(`(prefers-reduced-motion: no-preference)`,()=>{let e=ue.current,n=e&&e!==i?i===`login`?1:-1:0;Z.fromTo(t,{autoAlpha:0,x:20*n,y:n?0:12},{autoAlpha:1,x:0,y:0,duration:kV.slow,ease:AV.out,overwrite:!0}),n&&le.current&&Z.fromTo(le.current,{autoAlpha:0,y:6},{autoAlpha:1,y:0,duration:kV.base,ease:AV.out,overwrite:!0})})},t);return ue.current=i,()=>n.revert()},[e,i]);function Me(e){if(Se||!ge)return;let t=u.find(t=>t.id===e);l(e),s(t?.provider===`zhipu`?`pat`:`browser`),w(t?.provider!==`trae`&&t?.provider!==`kimi`),H(``),a(`login`)}async function Ne(){if(de.current)return de.current;if(!he)throw Error(r(`accountTypeHint`));let e=Oe(),t=await hoe(g.trim()||r(`account`),he.provider,he.region,e),n=t?.id||t?.data?.id;if(!n)throw Error(`create account returned no id`);return de.current=n,n}async function Pe(){H(``),te(``);try{B(`busy`);let e=await Ne();H(r(`wizardStartingSession`)),B(`polling`);let t=await FI(e,he?.provider===`codex`?oe:void 0);t.authUrl&&te(t.authUrl),H(r(`wizardWaitingBrowser`));for(let t=0;t{fe.current=window.setTimeout(e,wCe)});let n=(await II(e)).login||{};if(n.message&&H(n.message),n.status===`ok`)break;if(n.status===`error`)throw Error(n.message||`login failed`);if(t===89)throw Error(r(`wizardLoginTimeout`))}B(`done`),H(r(`wizardAccountReady`)),n(),window.setTimeout(je,900)}catch(e){B(`idle`),H(e instanceof Error?e.message:String(e))}}async function Fe(){let e=ie.trim();if(!e){H(r(`wizardCallbackPh`));return}try{B(`busy`);let t=await Ne();me(),await LI(t,e),B(`done`),H(r(`wizardAccountReady`)),n(),window.setTimeout(je,900)}catch(e){B(`polling`),H(e instanceof Error?e.message:String(e))}}async function Ie(){let e=N.trim();if(!e){H(r(`zhipuKeyRequired`));return}if(!he){H(r(`accountTypeHint`));return}H(``);try{B(`busy`);let t=Oe();await GI({format:`zhipu-key-v1`,api_key:e,mode:j,organization:j===`coding`?F.trim():``,project:j===`coding`?L.trim():``,name:g.trim()||r(`accountTypeZhipuCN`),enabled:!0,provider:he.provider,region:he.region,max_inflight:t.max_inflight,priority:t.priority,drop_system_prompt:t.drop_system_prompt,proxy_url:t.proxy_url}),B(`done`),H(r(`wizardAccountReady`)),n(),window.setTimeout(je,700)}catch(e){B(`idle`),H(e instanceof Error?e.message:String(e))}}async function Le(){let e=D.trim();if(!e){H(r(`pastePatFirst`));return}H(``);try{B(`busy`);let t=await Ne();H(r(`wizardStartingSession`)),await RI(e,t),B(`done`),H(r(`patDone`)),n(),window.setTimeout(je,700)}catch(e){B(`idle`),H(e instanceof Error?e.message:String(e))}}async function Re(){H(``);let e;try{e=JSON.parse(k)}catch{H(r(`wizardBadJson`));return}if(!e||typeof e!=`object`){H(r(`wizardBadJson`));return}if(!he){H(r(`accountTypeHint`));return}if(he.provider===`qoder`&&(typeof e.user_blob!=`string`||typeof e.machine_id!=`string`)){H(r(`wizardBadJson`));return}let t=Oe(),i;he.provider===`workbuddy`?i=x9(e,{region:he.region===`global`?`global`:`cn`,name:g.trim()||void 0,enabled:!0,max_inflight:t.max_inflight,priority:t.priority,drop_system_prompt:t.drop_system_prompt,proxy_url:t.proxy_url}):(e.format||(he.descriptor.id===`trae`?e.format=`trae-oauth-v1`:he.descriptor.id===`devin`?e.format=`devin-session-v1`:he.descriptor.id===`command`?e.format=`command-key-v1`:he.descriptor.id===`qwenwork`?e.format=`qwenwork-oauth-v1`:e.format=`qoder-native-v1`),i={...e,name:g.trim()||e.name,enabled:!0,provider:he.provider,region:he.region,max_inflight:t.max_inflight,priority:t.priority,drop_system_prompt:t.drop_system_prompt});try{B(`busy`);let{failed:e,message:t}=S9(await GI(i),r);B(`done`),H(t),n(),window.setTimeout(je,e>0?1600:700)}catch(e){B(`idle`),H(e instanceof Error?e.message:String(e))}}function ze(){pe.current?.click()}function Be(e){let t=e.target.files?.[0];if(!t)return;let n=new FileReader;n.onload=()=>A(String(n.result||``)),n.readAsText(t),e.target.value=``}let Ve=e=>Se&&o===e,He=he?.provider===`zhipu`,Ue=[he?.descriptor.capabilities?.browser_login===!1?null:{value:`browser`,label:r(`tabBrowser`)},_e?{value:`pat`,label:r(`tabPat`)}:null,ve?{value:`import`,label:r(`tabImport`)}:null].filter(Boolean),We=r(o===`browser`?he?.provider===`codex`?`wizardCodexBrowserLead`:`wizardBrowserLead`:o===`pat`?he?.provider===`command`?`wizardPatLeadCommand`:he?.region===`cn`&&he?.provider===`qoder`?`wizardPatLeadCN`:`wizardPatLead`:`wizardImportLead`);return(0,G.jsx)(Y.Root,{isOpen:e,onOpenChange:e=>{e||Ae()},children:(0,G.jsx)(Y.Backdrop,{variant:`blur`,isDismissable:!Se,children:(0,G.jsx)(Y.Container,{size:`lg`,scroll:`inside`,children:(0,G.jsxs)(Y.Dialog,{className:`w-full sm:w-[36rem] sm:max-w-[calc(100vw-2rem)] sm:min-h-[36rem]`,children:[(0,G.jsxs)(Y.Header,{className:`relative items-center justify-center px-12 pt-5 text-center`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(Y.Heading,{className:`text-section font-semibold`,children:r(`addAccountTitle`)}),(0,G.jsx)(`p`,{ref:le,className:`mt-1 text-caption font-normal leading-5 text-muted`,children:i===`method`?r(`addAccountDesc`):Te||r(`addAccountDesc`)})]}),(0,G.jsx)(Y.CloseTrigger,{"aria-label":r(`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,G.jsx)(ao,{size:16})})]}),(0,G.jsx)(Y.Body,{className:i===`method`?`px-8 pb-5 sm:px-10`:`px-6 pb-2`,children:(0,G.jsx)(`div`,{ref:ce,children:i===`method`?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`section`,{className:`space-y-2.5`,children:f?(0,G.jsx)(mCe,{ariaLabel:r(`accountType`)}):ge?(0,G.jsx)(_Ce,{ariaLabel:r(`accountType`),options:u.map(e=>{let t=e.descriptor.regions.find(t=>t.id===e.region)?.label||C9[e.region]||``;return{id:e.id,provider:e.provider,label:w9(e,r),subtitle:t,hint:T9(e,r)}}),onSelect:Me,disabled:Ce}):(0,G.jsx)(`p`,{className:`rounded-lg bg-surface-secondary/45 px-3.5 py-3 text-caption leading-5 text-muted`,children:r(`accountTypeHint`)})}),(0,G.jsx)(`div`,{className:`mt-4 text-center`,children:(0,G.jsx)(e9,{className:`text-xs`})})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`card flex flex-row items-center gap-3 rounded-xl bg-surface px-3 py-2.5`,children:[(0,G.jsx)(`span`,{className:`shrink-0`,children:(0,G.jsx)(MH,{provider:he?.provider,size:18})}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`div`,{className:`truncate text-body font-medium text-foreground`,children:he?w9(he,r):r(`accountType`)}),(0,G.jsx)(`div`,{className:`truncate text-caption text-muted`,children:Te})]}),(0,G.jsxs)(J,{size:`sm`,variant:`ghost`,onPress:()=>a(`method`),isDisabled:Se||!!de.current,children:[(0,G.jsx)(li,{size:12}),r(`wizardBack`)]})]}),(0,G.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,G.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,G.jsx)(IN,{className:`text-body font-medium text-muted`,children:r(`accountName`)}),(0,G.jsx)(UM,{fullWidth:!0,value:g,onChange:e=>_(e.target.value),"aria-label":r(`accountName`),disabled:Ce,autoFocus:!0})]}),(0,G.jsxs)(`button`,{type:`button`,onClick:()=>h(e=>!e),"aria-expanded":m,className:`inline-flex items-center gap-1 text-caption font-medium text-muted transition-colors hover:text-foreground`,children:[(0,G.jsx)(di,{size:12,className:`transition-transform duration-200 ${m?`rotate-90`:``}`}),r(`wizardAdvanced`)]}),m?(0,G.jsxs)(`div`,{className:`card gap-3 rounded-xl bg-surface px-3.5 py-3.5`,children:[(0,G.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:[(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(IN,{className:`text-body font-medium text-muted`,children:r(`maxInflight`)}),(0,G.jsx)(hF,{value:y,onChange:e=>b(e??4),minValue:1,maxValue:32,isDisabled:Ce,isRequired:!0,children:(0,G.jsxs)(hF.Group,{className:`w-full`,children:[(0,G.jsx)(hF.DecrementButton,{}),(0,G.jsx)(hF.Input,{"aria-label":r(`maxInflight`)}),(0,G.jsx)(hF.IncrementButton,{})]})}),(0,G.jsx)(RN,{className:`text-caption leading-5 text-muted`,children:r(`maxInflightHint`)})]}),(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(IN,{className:`text-body font-medium text-muted`,children:r(`priority`)}),(0,G.jsx)(hF,{value:x,onChange:e=>S(e??50),minValue:1,maxValue:100,isDisabled:Ce,isRequired:!0,children:(0,G.jsxs)(hF.Group,{className:`w-full`,children:[(0,G.jsx)(hF.DecrementButton,{}),(0,G.jsx)(hF.Input,{"aria-label":r(`priority`)}),(0,G.jsx)(hF.IncrementButton,{})]})}),(0,G.jsx)(RN,{className:`text-caption leading-5 text-muted`,children:r(`priorityHint`)})]})]}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,G.jsx)(IN,{className:`text-body font-medium text-muted`,children:r(`proxyUrl`)}),(0,G.jsx)(UM,{fullWidth:!0,value:T,onChange:e=>E(e.target.value),placeholder:r(`proxyUrlPlaceholder`),"aria-label":r(`proxyUrl`),disabled:Ce}),(0,G.jsx)(RN,{className:`text-caption leading-5 text-muted`,children:r(`proxyUrlHint`)})]}),be?(0,G.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,G.jsx)(IN,{className:`text-body font-medium text-muted`,children:r(`dropSystemPrompt`)}),(0,G.jsx)(RN,{className:`text-caption leading-5 text-muted`,children:r(he?.provider===`trae`?`dropSystemPromptTraeHint`:`dropSystemPromptCreateHint`)}),(0,G.jsx)(F7,{isSelected:C,isDisabled:Ce,ariaLabel:r(`dropSystemPrompt`),onChange:w})]}):null]}):null]}),He?(0,G.jsxs)(`div`,{className:`mt-4 flex flex-col gap-4`,children:[(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(`span`,{className:`text-body font-medium text-muted`,children:r(`zhipuAccountMode`)}),(0,G.jsx)(v9,{ariaLabel:r(`zhipuAccountMode`),columns:2,value:j,onChange:e=>{Se||M(e)},options:[{value:`payg`,label:r(`zhipuModePayg`),hint:r(`zhipuModePaygHint`),disabled:Se},{value:`coding`,label:r(`zhipuModeCoding`),hint:r(`zhipuModeCodingHint`),disabled:Se}]})]}),(0,G.jsx)(_9,{label:r(`zhipuApiKey`),children:(0,G.jsx)(UM,{type:`password`,value:N,onChange:e=>P(e.target.value),placeholder:r(`zhipuApiKeyPh`),"aria-label":r(`zhipuApiKey`),disabled:Se})}),j===`coding`?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(_9,{label:r(`zhipuOrganization`),children:(0,G.jsx)(UM,{value:F,onChange:e=>I(e.target.value),placeholder:r(`zhipuOrganizationPh`),"aria-label":r(`zhipuOrganization`),disabled:Se})}),(0,G.jsx)(_9,{label:r(`zhipuProject`),children:(0,G.jsx)(UM,{value:L,onChange:e=>R(e.target.value),placeholder:r(`zhipuProjectPh`),"aria-label":r(`zhipuProject`),disabled:Se})})]}):null,V?(0,G.jsxs)(`p`,{className:`flex items-center gap-2 rounded-lg bg-surface-secondary px-3 py-2 text-caption`,children:[we?(0,G.jsx)(yi,{size:14,className:`shrink-0 text-success`}):null,(0,G.jsx)(`span`,{className:we?`font-medium text-foreground`:`text-muted`,children:V})]}):null]}):null,He?null:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(pH,{className:`mt-3`,value:o,onChange:e=>{!Se&&e!==o&&(s(e),H(``),te(``),re(!1))},ariaLabel:r(`authentication`),options:Ue.map(e=>({id:e.value,label:e.label}))}),(0,G.jsx)(`p`,{className:`mt-2 min-h-5 text-caption leading-5 text-muted`,children:We}),(0,G.jsx)(`div`,{className:`mt-3 flex flex-col gap-4`,children:o===`browser`?(0,G.jsxs)(G.Fragment,{children:[he?.provider===`codex`?(0,G.jsx)(v9,{ariaLabel:r(`codexLoginMethod`),columns:2,value:oe,onChange:e=>{Se||se(e)},options:[{value:`cli`,label:r(`codexLoginCli`),hint:r(`codexLoginCliHint`),disabled:Se||!!de.current},{value:`chatgpt`,label:r(`codexLoginChatGPT`),hint:r(`codexLoginChatGPTHint`),disabled:Se||!!de.current}]}):null,ee?(0,G.jsxs)(`div`,{className:`card rounded-xl bg-surface px-3 py-2.5`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-caption`,children:[(0,G.jsx)(SCe,{phase:z,busy:Se,tab:o,forTab:`browser`}),(0,G.jsx)(`span`,{className:`text-muted`,children:V||r(`loginOpenMsg`)})]}),(0,G.jsx)(`code`,{className:`mono mt-2 block break-all text-caption leading-5 text-foreground`,children:ee}),(0,G.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:[(0,G.jsxs)(J,{size:`sm`,variant:`secondary`,onPress:()=>window.open(ee,`_blank`,`noopener,noreferrer`),children:[(0,G.jsx)(Zr,{size:14}),r(`openAuthUrl`)]}),(0,G.jsxs)(J,{size:`sm`,variant:`ghost`,onPress:()=>{Z7(ee).then(e=>{e&&(re(!0),window.setTimeout(()=>re(!1),1100))})},children:[(0,G.jsx)(X7,{copied:ne}),r(ne?`copied`:`copy`)]})]})]}):null,V&&!ee?(0,G.jsxs)(`p`,{className:`flex items-center gap-2 rounded-lg bg-surface-secondary px-3 py-2 text-caption`,children:[we?(0,G.jsx)(yi,{size:14,className:`shrink-0 text-success`}):null,(0,G.jsx)(`span`,{className:we?`font-medium text-foreground`:`text-muted`,children:V})]}):null,xe?(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(`p`,{className:`text-caption leading-4 text-muted`,children:r(`wizardCallbackLead`)}),(0,G.jsx)(JM,{className:`h-28 w-full resize-none font-mono text-caption leading-5`,value:ie,onChange:e=>ae(e.target.value),placeholder:r(`wizardCallbackPh`),"aria-label":r(`wizardCallbackPh`),disabled:we}),(0,G.jsx)(J,{size:`sm`,variant:`secondary`,isPending:z===`busy`&&!!ie.trim(),onPress:()=>void Fe(),isDisabled:we,children:r(`wizardSubmitCallback`)})]}):null]}):o===`pat`?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(_9,{label:r(`tabPat`),children:(0,G.jsx)(UM,{type:`password`,value:D,onChange:e=>O(e.target.value),placeholder:r(`wizardPatPh`),"aria-label":r(`wizardPatPh`),disabled:Se})}),V?(0,G.jsxs)(`p`,{className:`flex items-center gap-2 rounded-lg bg-surface-secondary px-3 py-2 text-caption`,children:[we?(0,G.jsx)(yi,{size:14,className:`shrink-0 text-success`}):null,(0,G.jsx)(`span`,{className:we?`font-medium text-foreground`:`text-muted`,children:V})]}):null]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,G.jsx)(`span`,{className:`text-caption font-medium text-muted`,children:`JSON`}),(0,G.jsxs)(J,{size:`sm`,variant:`secondary`,onPress:ze,isDisabled:Se,children:[(0,G.jsx)(Vi,{size:13}),r(`wizardChooseFile`)]}),(0,G.jsx)(`input`,{ref:pe,type:`file`,accept:`application/json,.json`,className:`hidden`,onChange:Be})]}),(0,G.jsx)(JM,{className:`min-h-32 font-mono text-caption`,value:k,onChange:e=>A(e.target.value),placeholder:r(`wizardImportPh`),"aria-label":r(`tabImport`),disabled:Se}),V?(0,G.jsxs)(`p`,{className:`flex items-center gap-2 rounded-lg bg-surface-secondary px-3 py-2 text-caption`,children:[we?(0,G.jsx)(yi,{size:14,className:`shrink-0 text-success`}):null,(0,G.jsx)(`span`,{className:we?`font-medium text-foreground`:`text-muted`,children:V})]}):null]})})]})]})})}),(0,G.jsxs)(Y.Footer,{className:`justify-end gap-2 px-5 pb-5`,children:[(0,G.jsx)(J,{variant:`ghost`,onPress:Ae,isDisabled:Se,children:r(`cancel`)}),i===`login`&&He?(0,G.jsx)(J,{isPending:z===`busy`,onPress:()=>void Ie(),isDisabled:we,children:we?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(yi,{size:15}),r(`wizardAccountReady`)]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(ta,{size:15}),r(`zhipuCreate`)]})}):null,i===`login`&&!He&&o===`browser`?(0,G.jsx)(J,{isPending:Ve(`browser`),onPress:()=>void Pe(),isDisabled:we,children:we?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(yi,{size:15}),r(`wizardAccountReady`)]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Da,{size:15}),r(`wizardStartBrowser`)]})}):null,i===`login`&&!He&&o===`pat`?(0,G.jsx)(J,{isPending:Ve(`pat`),onPress:()=>void Le(),isDisabled:we,children:we?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(yi,{size:15}),r(`patDone`)]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(ta,{size:15}),r(`wizardCreateAndLogin`)]})}):null,i===`login`&&!He&&o===`import`?(0,G.jsx)(J,{isPending:Ve(`import`),onPress:()=>void Re(),isDisabled:we,children:we?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(yi,{size:15}),r(`accountImported`)]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Vi,{size:15}),r(`importCredential`)]})}):null]})]})})})})}function E9({isOpen:e,title:t,description:n,confirmLabel:r,cancelLabel:i,closeLabel:a,isPending:o,status:s=`danger`,confirmVariant:c=`danger`,onClose:l,onConfirm:u}){return(0,G.jsx)(cx.Root,{isOpen:e,onOpenChange:e=>{!e&&!o&&l()},children:(0,G.jsx)(cx.Backdrop,{variant:`blur`,isDismissable:!o,children:(0,G.jsx)(cx.Container,{placement:`center`,size:`sm`,children:(0,G.jsxs)(cx.Dialog,{children:[(0,G.jsxs)(cx.Header,{className:`items-start justify-between gap-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,G.jsx)(cx.Icon,{status:s}),(0,G.jsx)(`div`,{children:(0,G.jsx)(cx.Heading,{children:t})})]}),(0,G.jsx)(cx.CloseTrigger,{isDisabled:o,"aria-label":a})]}),(0,G.jsx)(cx.Body,{children:(0,G.jsx)(`p`,{className:`text-body leading-6 text-muted`,children:n})}),(0,G.jsxs)(cx.Footer,{children:[(0,G.jsx)(J,{size:`sm`,variant:`ghost`,isDisabled:o,onPress:l,children:i}),(0,G.jsx)(J,{size:`sm`,variant:c,isPending:o,onPress:u,children:r})]})]})})})})}function ECe(e,t){return e===`region_mixed`?t(`batchImportRegionMixed`):e===`region_unknown`?t(`batchImportRegionUnknown`):e===`unknown_format`?t(`batchImportUnknownFormat`):``}function DCe({isOpen:e,detection:t,fileName:n,isPending:r,t:i,onClose:a,onConfirm:o}){let[s,c]=(0,v.useState)(`cn`);(0,v.useEffect)(()=>{t&&(t.region===`cn`||t.region===`global`?c(t.region):c(`cn`))},[t]);let l=!!t?.batchImportSupported,u=t?.provider,d=t?.format||i(`batchImportFormatUnknown`),f=u?AH(u,i):i(`batchImportProviderUnknown`),p=(t?.warnings||[]).map(e=>ECe(e,i)).filter(Boolean);return(0,G.jsx)(Y.Root,{isOpen:e,onOpenChange:e=>{!e&&!r&&a()},children:(0,G.jsx)(Y.Backdrop,{variant:`blur`,isDismissable:!r,children:(0,G.jsx)(Y.Container,{placement:`center`,size:`sm`,scroll:`inside`,className:`mx-3 w-full max-w-[min(100%,24rem)] sm:mx-0`,children:(0,G.jsxs)(Y.Dialog,{children:[(0,G.jsxs)(Y.Header,{className:`items-start justify-between gap-4 px-5 pt-5`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(Y.Heading,{className:`text-section font-semibold`,children:i(`batchImportConfirmTitle`)}),(0,G.jsx)(`p`,{className:`mt-1 break-all text-caption leading-5 text-muted`,children:n?i(`batchImportConfirmHint`,{file:n}):i(`batchImportConfirmHintNoFile`)})]}),(0,G.jsx)(Y.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,G.jsx)(ao,{size:16})})]}),(0,G.jsxs)(Y.Body,{className:`space-y-4 px-5 pb-2`,children:[(0,G.jsx)(`div`,{className:`rounded-xl bg-surface-secondary px-3.5 py-3`,children:(0,G.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[u?(0,G.jsx)(MH,{provider:u,size:18}):null,(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`div`,{className:`text-body font-medium text-foreground`,children:f}),(0,G.jsx)(`div`,{className:`mono mt-0.5 truncate text-caption text-muted`,children:d})]})]})}),l?(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(`div`,{className:`text-body font-medium text-muted`,children:i(`batchImportRegion`)}),(0,G.jsx)(pH,{value:s,onChange:e=>{(e===`cn`||e===`global`)&&c(e)},ariaLabel:i(`batchImportRegion`),options:[{id:`cn`,label:i(`accountTypeWorkBuddyCN`)},{id:`global`,label:i(`accountTypeWorkBuddyGlobal`)}]}),t?.regionAmbiguous?(0,G.jsx)(`p`,{className:`text-caption leading-5 text-muted`,children:i(`batchImportRegionPickHint`)}):null]}):(0,G.jsx)(`p`,{className:`text-body leading-6 text-muted`,children:i(`batchImportProviderUnsupported`)}),p.length?(0,G.jsx)(`ul`,{className:`space-y-1 text-caption leading-5 text-muted`,children:p.map(e=>(0,G.jsx)(`li`,{children:e},e))}):null]}),(0,G.jsxs)(Y.Footer,{className:`flex-col-reverse gap-2 px-5 pb-5 sm:flex-row sm:justify-end`,children:[(0,G.jsx)(J,{size:`sm`,variant:`ghost`,className:`w-full sm:w-auto`,isDisabled:r,onPress:a,children:i(l?`cancel`:`close`)}),l?(0,G.jsx)(J,{size:`sm`,className:`w-full sm:w-auto`,isPending:r,onPress:()=>o(s),children:i(`batchImportConfirmAction`)}):null]})]})})})})}var D9={"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`},OCe=[`codebuddy.cn`,`workbuddy.cn`],kCe=[`workbuddy.ai`,`workbuddy.com`];function O9(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function k9(e){let t=e.trim();if(!t)return``;let n=t.toLowerCase();return n===`workbuddy-accounts`?`workbuddy-accounts`:n}function ACe(e){return typeof e.format==`string`&&e.format.trim()?k9(e.format):typeof e.exportType==`string`&&e.exportType.trim()?k9(e.exportType):``}function jCe(e){let t=[],n=e=>{typeof e==`string`&&e.trim()&&t.push(e.trim().toLowerCase())};if(n(e.domain),O9(e.account)&&n(e.account.domain),O9(e.auth)&&n(e.auth.domain),Array.isArray(e.accounts))for(let t of e.accounts)O9(t)&&(n(t.domain),O9(t.account)&&n(t.account.domain),O9(t.auth)&&n(t.auth.domain));return t}function MCe(e){return OCe.some(t=>e.includes(t))}function NCe(e){return kCe.some(t=>e.includes(t))}function A9(e){return typeof e.accessToken==`string`||typeof e.access_token==`string`||typeof e.refreshToken==`string`||typeof e.refresh_token==`string`}function PCe(e){if(!O9(e))return!1;if(A9(e)||typeof e.domain==`string`||typeof e.uid==`string`)return!0;if(O9(e.account)||O9(e.auth)){let t=O9(e.account)?e.account:null,n=O9(e.auth)?e.auth:null;if(n&&(A9(n)||typeof n.domain==`string`)||t&&(typeof t.uid==`string`||typeof t.domain==`string`))return!0}return!1}function FCe(e){let t=jCe(e);if(t.length===0)return{region:`cn`,ambiguous:!0,warning:`region_unknown`};let n=t.some(MCe),r=t.some(NCe);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 ICe(e){return Array.isArray(e.accounts)&&e.accounts.some(PCe)?{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`}:A9(e)||O9(e.account)&&A9(e.account)||O9(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 LCe(e){if(!O9(e))return{format:null,provider:null,region:null,regionAmbiguous:!0,confidence:`low`,warnings:[`not_object`],batchImportSupported:!1};let t=[],n=ACe(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?D9[o]??null:null,c=o&&s?`high`:`low`;if(!s){let r=ICe(e);o||=r.format,s=r.provider,c=n&&!D9[n]?`low`:r.confidence,a&&!D9[n]&&t.push(`unknown_format`)}s===`workbuddy`&&Array.isArray(e.accounts)&&(o=`workbuddy-accounts`);let l=null,u=!1;if(s===`workbuddy`){let n=FCe(e);l=n.region,u=n.ambiguous,n.warning&&t.push(n.warning)}return{format:o,provider:s,region:l,regionAmbiguous:u,confidence:c,warnings:t,batchImportSupported:s===`workbuddy`}}function RCe(e){let t;try{t=JSON.parse(e)}catch{throw Error(`bad_json`)}if(!O9(t))throw Error(`bad_json`);return t}var j9=`__all__`,zCe=[],M9=2;function BCe(){let{t:e}=EI(),[t,n]=(0,v.useState)([]),[r,i]=(0,v.useState)(null),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)([]),[l,u]=(0,v.useState)(!0),d=s,f=d.length>0,[p,m]=(0,v.useState)(!1),[h,g]=(0,v.useState)(!1),[_,y]=(0,v.useState)(!1),[b,x]=(0,v.useState)(null),[S,C]=(0,v.useState)(null),[w,T]=(0,v.useState)(``),[E,D]=(0,v.useState)(null),[O,k]=(0,v.useState)({}),[A,j]=(0,v.useState)({}),[M,N]=(0,v.useState)({}),[P,F]=(0,v.useState)({}),[I,L]=(0,v.useState)(null),[R,z]=(0,v.useState)(null),[B,V]=(0,v.useState)(null),[H,ee]=(0,v.useState)(null),[te,ne]=(0,v.useState)(null),[re,ie]=(0,v.useState)(``),[ae,oe]=(0,v.useState)(`all`),[se,ce]=(0,v.useState)(``),[le,ue]=(0,v.useState)(1),[de,fe]=(0,v.useState)(20),[pe,me]=(0,v.useState)({}),[he,ge]=(0,v.useState)({}),[_e,ve]=(0,v.useState)({}),[ye,be]=(0,v.useState)({}),[xe,Se]=(0,v.useState)(!1),Ce=(0,v.useCallback)(async(e=!1)=>{try{let t=(await PI(e)).data||zCe;return c(t),t}finally{u(!1)}},[]),we=(0,v.useCallback)(async(e,t=!0)=>{let n=[...new Set(e)];if(n.length)for(let e=0;e{try{let n=await loe(e,{quota:t});c(t=>t.map(t=>t.id===e?n:t))}catch(t){N(n=>({...n,[e]:t instanceof Error?t.message:String(t)}))}}))}},[]);(0,v.useEffect)(()=>{Ce(!1).catch(()=>void 0)},[Ce]),(0,v.useEffect)(()=>{let e=!0;return Promise.all([UI(),$I()]).then(([t,r])=>{e&&(n(t.data||[]),i(r))}).catch(t=>{e&&o(t instanceof Error?t.message:String(t))}),()=>{e=!1}},[]);function Te(e){return t.find(t=>t.id===e.provider)?.regions.find(t=>t.id===e.region)?.checkin}function Ee(e){let t=Te(e)?.timezone;return t===`Local`?r?.timezone:t}let De=(0,v.useMemo)(()=>d.map(e=>{let t=pe[e.id],n=he[e.id],r=_e[e.id],i=ye[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}),[pe,_e,he,ye,d]),Oe=(0,v.useMemo)(()=>{let e={all:De.length,available:0,attention:0,disabled:0};for(let t of De){let n=p9(t);n===`hot`||n===`ready`?e.available+=1:n===`disabled`&&(e.disabled+=1),t.enabled&&n!==`hot`&&n!==`ready`&&(e.attention+=1)}return e},[De]),ke=(0,v.useMemo)(()=>{let e=new Map;for(let t of De){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]))},[De]),Ae=De.find(e=>e.id===I),je=De.find(e=>e.id===R)||null,Me=De.find(e=>e.id===B)||null,Ne=De.find(e=>e.id===H)||null,Pe=(0,v.useMemo)(()=>{let e=re.trim().toLowerCase();return De.filter(t=>{let n=p9(t);return!(ae===`all`||ae===`available`&&(n===`hot`||n===`ready`)||ae===`attention`&&t.enabled&&n!==`hot`&&n!==`ready`||ae===`disabled`&&n===`disabled`)||se&&String(t.provider||`qoder`).toLowerCase()!==se?!1:!e||[t.name,t.id,t.remote_uid,t.provider,t.auth_type].some(t=>String(t||``).toLowerCase().includes(e))})},[De,ae,se,re]),Fe=[re,ae,se,de].join(`\0`),[Ie,Le]=(0,v.useState)(Fe);Ie!==Fe&&(Le(Fe),ue(1));let Re=Math.max(1,Math.ceil(Pe.length/de)),ze=Math.min(Ie===Fe?Math.max(1,le):1,Re);le!==ze&&ue(ze);let Be=(0,v.useMemo)(()=>{let e=(ze-1)*de;return Pe.slice(e,e+de)},[ze,Pe,de]);if(l&&!f)return(0,G.jsx)(Fse,{});async function Ve(e,t,n){D({id:e,kind:t}),N(t=>({...t,[e]:``}));try{return await n(),!0}catch(t){return N(n=>({...n,[e]:t instanceof Error?t.message:String(t)})),!1}finally{D(null)}}async function He(t,n){ne(t),await Ve(t,`device`,async()=>{N(n=>({...n,[t]:e(`wizardStartingSession`)}));let r=await FI(t,n);r.authUrl&&F(e=>({...e,[t]:r.authUrl||``}));for(let n=0;n<60;n++){await new Promise(e=>window.setTimeout(e,2e3));let n=(await II(t)).login||{};if(N(r=>({...r,[t]:n.message||e(`waitingQoderLogin`)})),n.status===`ok`||n.status===`error`)break}await Ce(!1),await we([t])})}async function Ue(t){let n=(A[t]||``).trim();if(!n){N(n=>({...n,[t]:e(`wizardCallbackPh`)}));return}await Ve(t,`callback`,async()=>{N(n=>({...n,[t]:e(`wizardStartingSession`)})),await LI(t,n),j(e=>({...e,[t]:``})),await Ce(!1),await we([t])})&&(ne(e=>e===t?null:e),N(e=>({...e,[t]:``})))}async function We(t){let n=(O[t]||``).trim();if(!n){N(n=>({...n,[t]:e(`pastePatFirst`)}));return}await Ve(t,`pat`,async()=>{N(n=>({...n,[t]:e(`wizardStartingSession`)})),await RI(n,t),k(e=>({...e,[t]:``})),await Ce(!1),await we([t])})}async function Ge(t){await Ve(t,`export`,async()=>{let n=await yoe(t);await Z7(JSON.stringify(n,null,2)),N(n=>({...n,[t]:e(`credentialCopied`)}))})}async function Ke(e,t){me(n=>({...n,[e]:t})),await Ve(e,`toggle`,async()=>{await WI(e,{enabled:t}),await Ce(!1)}),me(t=>{let n={...t};return delete n[e],n})}async function qe(t){XV({id:`refresh-${t}`,type:`loading`,title:e(`toastRefreshingAccount`)}),D({id:t,kind:`refresh`}),N(e=>{let n={...e};return delete n[t],n});try{await we([t]),XV({id:`refresh-${t}`,type:`success`,title:e(`toastAccountRefreshed`)})}catch(n){throw XV({id:`refresh-${t}`,type:`error`,title:e(`toastFailed`),description:n instanceof Error?n.message:String(n)}),n}finally{D(null)}}async function Je(){Se(!0),XV({id:`refresh-credits`,type:`loading`,title:e(`toastRefreshingCredits`)});try{await we(s.map(e=>e.id)),XV({id:`refresh-credits`,type:`success`,title:e(`toastCreditsRefreshed`)})}catch(t){throw XV({id:`refresh-credits`,type:`error`,title:e(`toastFailed`),description:t instanceof Error?t.message:String(t)}),t}finally{Se(!1)}}function Ye(){h||(y(!1),x(null),C(null),T(``))}async function Xe(t){let n=t.target.files?.[0];if(t.target.value=``,n)try{let t=RCe(await n.text()),r=LCe(t);if(!r.provider){XV({type:`error`,title:e(`batchImportUnrecognized`)});return}C(t),x(r),T(n.name),y(!0)}catch(t){let n=t instanceof Error?t.message:String(t);XV({type:`error`,title:e(n===`bad_json`?`wizardBadJson`:`batchImportUnrecognized`),description:n===`bad_json`?void 0:n})}}async function Ze(t){if(!S||!b?.batchImportSupported||h)return;g(!0);let n=`batch-import-accounts`;XV({id:n,type:`loading`,title:e(`batchImportLoading`)});try{let{succeeded:r,failed:i,message:a}=S9(await vCe(S,{region:t}),e);XV({id:n,type:i>0&&r===0?`error`:i>0?`info`:`success`,title:a}),y(!1),x(null),C(null),T(``),r>0&&await Ce(!1)}catch(t){XV({id:n,type:`error`,title:e(`toastFailed`),description:t instanceof Error?t.message:String(t)})}finally{g(!1)}}async function Qe(e,t){await Ve(e,`toggle`,async()=>{await WI(e,{auto_checkin:t}),await Ce(!1)})}async function $e(e){await Ve(e,`checkin`,async()=>{try{await goe(e)}finally{await Ce(!1)}})}async function et(t,n){if(!t)throw Error(e(`accountNameRequired`));ge(e=>({...e,[t]:n.name})),ve(e=>({...e,[t]:n.max_inflight})),be(e=>({...e,[t]:n.priority})),D({id:t,kind:`settings`});try{await WI(t,n),await Ce(!1)}catch(e){throw e instanceof Error?e:Error(String(e))}finally{D(null),ge(e=>{let n={...e};return delete n[t],n}),ve(e=>{let n={...e};return delete n[t],n}),be(e=>{let n={...e};return delete n[t],n})}}return(0,G.jsxs)(`div`,{className:`space-y-4`,children:[a?(0,G.jsx)(QI,{title:a}):null,(0,G.jsxs)(`section`,{"data-gsap-reveal":!0,className:`flex flex-wrap items-center gap-2`,children:[d.length?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(pH,{value:ae,onChange:e=>oe(e),ariaLabel:e(`accountStatusFilter`),options:[{id:`all`,label:(0,G.jsxs)(G.Fragment,{children:[e(`filterAll`),(0,G.jsx)(`span`,{className:`mono text-muted`,children:Oe.all})]})},{id:`available`,label:(0,G.jsxs)(G.Fragment,{children:[e(`availableAccounts`),(0,G.jsx)(`span`,{className:`mono text-muted`,children:Oe.available})]})},{id:`attention`,label:(0,G.jsxs)(G.Fragment,{children:[e(`needsAttention`),(0,G.jsx)(`span`,{className:`mono ${Oe.attention?`text-danger`:`text-muted`}`,children:Oe.attention})]})},{id:`disabled`,label:(0,G.jsxs)(G.Fragment,{children:[e(`disabled`),(0,G.jsx)(`span`,{className:`mono text-muted`,children:Oe.disabled})]})}]}),(0,G.jsxs)(AF,{className:`w-48`,"aria-label":e(`providerFilterAll`),value:se||j9,onChange:e=>{typeof e==`string`&&ce(e===j9?``:e)},children:[(0,G.jsxs)(AF.Trigger,{className:`items-center`,children:[(0,G.jsx)(AF.Value,{className:`min-w-0 truncate`}),(0,G.jsx)(AF.Indicator,{})]}),(0,G.jsx)(AF.Popover,{children:(0,G.jsxs)(oF,{children:[(0,G.jsxs)(oF.Item,{id:j9,textValue:e(`providerFilterAll`),children:[(0,G.jsxs)(IN,{className:`flex items-center gap-2`,children:[e(`providerFilterAll`),(0,G.jsx)(`span`,{className:`mono text-muted`,children:d.length})]}),(0,G.jsx)(oF.ItemIndicator,{})]}),ke.map(([t,n])=>(0,G.jsxs)(oF.Item,{id:t,textValue:AH(t,e),children:[(0,G.jsxs)(IN,{className:`flex items-center gap-2`,children:[(0,G.jsx)(MH,{provider:t,size:13}),AH(t,e),(0,G.jsx)(`span`,{className:`mono text-muted`,children:n})]}),(0,G.jsx)(oF.ItemIndicator,{})]},t))]})})]}),(0,G.jsx)(B7,{className:`w-full sm:w-60`,value:re,onChange:ie,placeholder:e(`searchAccounts`),ariaLabel:e(`searchAccounts`)})]}):null,(0,G.jsxs)(`div`,{className:`flex w-full flex-wrap items-center justify-end gap-2 sm:ml-auto sm:w-auto`,children:[(0,G.jsxs)(J,{size:`sm`,variant:`secondary`,isPending:xe,onPress:()=>void Je(),children:[(0,G.jsx)(ti,{size:14}),e(`refreshCredits`)]}),(0,G.jsxs)(`label`,{htmlFor:`accounts-batch-import-file`,className:`button button--sm button--secondary inline-flex items-center gap-1.5 ${h||_?`pointer-events-none opacity-60`:`cursor-pointer`}`,children:[h?(0,G.jsx)(PV,{size:14,loading:!0}):(0,G.jsx)($a,{size:14}),e(`batchImport`)]}),(0,G.jsx)(`input`,{id:`accounts-batch-import-file`,type:`file`,accept:`.json,application/json,text/json`,disabled:h||_,className:`sr-only`,onChange:e=>void Xe(e)}),(0,G.jsxs)(J,{size:`sm`,onPress:()=>m(!0),children:[(0,G.jsx)(Ca,{size:14}),e(`addAccount`)]})]})]}),(0,G.jsx)(TCe,{isOpen:p,onClose:()=>m(!1),onAdded:()=>{XV({type:`success`,title:e(`toastAccountAdded`)}),Ce(!1)}}),(0,G.jsx)(DCe,{isOpen:_,detection:b,fileName:w,isPending:h,t:e,onClose:Ye,onConfirm:e=>{Ze(e)}}),(0,G.jsx)(oCe,{account:je,t:e,onClose:()=>z(null)},R??`closed`),(0,G.jsx)(iCe,{account:Me,t:e,onClose:()=>V(null)},B??`closed`),(0,G.jsx)(uCe,{account:Ne,checkinDefaultTime:Ne&&Te(Ne)?r?.checkin_times[Ne.provider||``]:void 0,checkinTimezone:Ne?Ee(Ne):void 0,busy:!!(E&&E.id===H&&E.kind===`settings`),t:e,onClose:()=>ee(null),onSave:e=>et(H||``,e)},H??`closed`),(0,G.jsx)(E9,{isOpen:!!Ae,title:e(`delete`),description:e(`deleteAccountConfirm`,{name:Ae?.name||Ae?.id||``}),confirmLabel:e(`delete`),cancelLabel:e(`cancel`),closeLabel:e(`close`),isPending:E?.id===I&&E.kind===`delete`,onClose:()=>L(null),onConfirm:()=>{if(!Ae)return;let t=Ae.id;L(null),Ve(t,`delete`,async()=>{await voe(t),await Ce(!1)}).then(t=>{t&&XV({type:`success`,title:e(`toastAccountDeleted`)})})}}),f?null:(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsx)(I7,{className:`rounded-3xl bg-surface-secondary`,icon:(0,G.jsx)(PV,{size:28}),title:e(`noAccounts`),hint:e(`accountEmptyHint`),action:(0,G.jsxs)(J,{size:`sm`,onPress:()=>m(!0),children:[(0,G.jsx)(Ca,{size:14}),e(`addAccount`)]})}),(0,G.jsx)(`div`,{className:`text-center`,children:(0,G.jsx)(e9,{})})]}),f&&!Pe.length?(0,G.jsx)(I7,{className:`rounded-3xl bg-surface-secondary`,icon:(0,G.jsx)(la,{size:22}),title:e(`noAccountsMatch`),action:(0,G.jsx)(J,{size:`sm`,variant:`ghost`,onPress:()=>{ie(``),oe(`all`),ce(``)},children:e(`clearFilters`)})}):null,(0,G.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:Be.map(t=>(0,G.jsx)(tCe,{account:t,busyKind:E?.id===t.id?E.kind:``,authPanelOpen:te===t.id,authUrl:P[t.id],note:M[t.id],pat:O[t.id]||``,t:e,onPatChange:e=>k(n=>({...n,[t.id]:e})),callbackUrl:A[t.id]||``,onCallbackChange:e=>j(n=>({...n,[t.id]:e})),onSubmitCallback:()=>void Ue(t.id),onDeviceLogin:e=>void He(t.id,e),onPatLogin:()=>void We(t.id),onExport:()=>void Ge(t.id),onRefresh:()=>void qe(t.id),onDelete:()=>L(t.id),onToggle:e=>void Ke(t.id,e),checkinDefaultTime:r?.checkin_times[t.provider||``],onToggleAutoCheckin:Te(t)?e=>void Qe(t.id,e):void 0,onCheckin:Te(t)?()=>void $e(t.id):void 0,onViewCheckins:Te(t)?()=>V(t.id):void 0,onEdit:()=>ee(t.id),onToggleAuthPanel:()=>ne(e=>e===t.id?null:t.id),onViewModels:()=>z(t.id)},t.id))}),Pe.length?(0,G.jsx)(z7,{total:Pe.length,page:ze,pageCount:Re,pageSize:de,pageSizes:lSe,loading:!1,pageSizeLabel:e(`logsPageSize`),pageLabel:e(`logsPage`,{page:ze,pages:Re}),prevLabel:e(`logsPrevPage`),nextLabel:e(`logsNextPage`),onPage:ue,onPageSize:fe}):null]})}function VCe(){let{t:e,lang:t,setLang:n}=EI(),{setApiKey:r}=kI(),{overview:i,refresh:a}=qI(),{theme:o,toggleTheme:s}=XI(),[c,l]=(0,v.useState)(``),[u,d]=(0,v.useState)(!1),[f,p]=(0,v.useState)(!1),[m,h]=(0,v.useState)(``),g=at(),_=nt().state?.from||`/`,y=(0,v.useRef)(null);if(Use(y,`login`),i)return(0,G.jsx)(At,{to:_===`/login`?`/`:_,replace:!0});async function b(t){t.preventDefault();let n=c.trim();if(!n){h(e(`loginNeedKey`));return}p(!0),h(``);try{r(n),await a(n),g(_===`/login`?`/`:_,{replace:!0})}catch(t){h(MI(t)?e(`loginBadKey`):t instanceof Error?t.message:String(t))}finally{p(!1)}}return(0,G.jsxs)(`div`,{className:`relative min-h-dvh overflow-hidden bg-background text-foreground`,children:[(0,G.jsx)(`div`,{className:`absolute inset-x-0 top-0 h-px bg-border`}),(0,G.jsxs)(`main`,{ref:y,className:`relative z-10 mx-auto grid min-h-dvh w-full max-w-[1480px] lg:grid-cols-[minmax(0,1fr)_minmax(480px,45%)]`,children:[(0,G.jsxs)(`section`,{className:`flex min-h-[52vh] flex-col border-separator px-5 py-6 sm:px-10 sm:py-8 lg:min-h-dvh lg:border-r lg:px-14 lg:py-10 xl:px-20`,children:[(0,G.jsxs)(`header`,{className:`flex items-center justify-between gap-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsx)(PV,{size:36}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`font-semibold`,children:`CLI2API`}),(0,G.jsx)(`div`,{className:`text-caption text-muted`,children:e(`controlPlane`)})]})]}),(0,G.jsxs)(cM,{isAttached:!0,children:[(0,G.jsxs)(PM,{children:[(0,G.jsx)(PM.Trigger,{children:(0,G.jsx)(J,{isIconOnly:!0,size:`sm`,variant:`ghost`,onPress:()=>n(t===`zh`?`en`:`zh`),"aria-label":t===`zh`?`English`:`中文`,children:(0,G.jsx)(Yi,{size:15})})}),(0,G.jsx)(PM.Content,{children:t===`zh`?`English`:`中文`})]}),(0,G.jsxs)(PM,{children:[(0,G.jsx)(PM.Trigger,{children:(0,G.jsx)(J,{isIconOnly:!0,size:`sm`,variant:`ghost`,onPress:s,"aria-label":o===`dark`?`Light mode`:`Dark mode`,children:o===`dark`?(0,G.jsx)(Ua,{size:15}):(0,G.jsx)(da,{size:15})})}),(0,G.jsx)(PM.Content,{children:o===`dark`?`Light mode`:`Dark mode`})]})]})]}),(0,G.jsxs)(`div`,{className:`my-auto max-w-3xl py-16 lg:py-24`,children:[(0,G.jsx)(`p`,{"data-gsap-reveal":!0,className:`mb-5 mono text-caption text-muted`,children:`:3010`}),(0,G.jsx)(`h1`,{"data-gsap-reveal":!0,className:`max-w-3xl text-[clamp(2.25rem,4vw,3.6rem)] font-semibold leading-[0.98] tracking-[-0.045em] text-balance`,children:e(`loginTitle`)}),(0,G.jsx)(`p`,{"data-gsap-reveal":!0,className:`mt-6 max-w-xl text-section font-normal text-muted sm:text-title sm:font-normal`,children:e(`loginLead`)}),(0,G.jsx)(`p`,{"data-gsap-reveal":!0,className:`mt-10 max-w-xl pt-5 text-body leading-6 text-muted`,children:e(`loginHint`)})]}),(0,G.jsxs)(`footer`,{className:`hidden items-center justify-between text-caption text-muted lg:flex`,children:[(0,G.jsx)(`span`,{children:e(`loginHint`)}),(0,G.jsx)(`span`,{children:e(`routesHint`)})]})]}),(0,G.jsx)(`section`,{className:`flex items-center px-5 py-10 sm:px-10 lg:px-12 xl:px-16`,children:(0,G.jsx)(HS,{"data-gsap-reveal":!0,className:`w-full p-0`,children:(0,G.jsxs)(`form`,{onSubmit:e=>void b(e),children:[(0,G.jsx)(HS.Header,{className:`border-b border-separator px-6 py-6 sm:px-8`,children:(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3`,children:[(0,G.jsx)(PV,{size:28,loading:f}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(HS.Title,{className:`text-title`,children:e(`loginFormTitle`)}),(0,G.jsx)(HS.Description,{className:`mt-1`,children:e(`loginDesc`)})]})]})}),(0,G.jsxs)(HS.Content,{className:`space-y-5 px-6 py-7 sm:px-8 sm:py-8`,children:[(0,G.jsxs)(YM,{name:`console-password`,className:`w-full`,isInvalid:!!m,children:[(0,G.jsx)(IN,{children:e(`loginPassword`)}),(0,G.jsxs)(KM,{children:[(0,G.jsx)(KM.Input,{id:`console-password`,type:u?`text`:`password`,value:c,onChange:e=>l(e.target.value),placeholder:e(`loginPasswordPh`),autoComplete:`current-password`,autoFocus:!0,"aria-label":e(`loginPassword`),spellCheck:!1}),(0,G.jsx)(KM.Suffix,{children:(0,G.jsx)(J,{isIconOnly:!0,size:`sm`,variant:`ghost`,type:`button`,"aria-label":e(u?`hidePassword`:`showPassword`),onPress:()=>d(e=>!e),children:u?(0,G.jsx)(zi,{size:16}):(0,G.jsx)(Li,{size:16})})})]})]}),m?(0,G.jsx)(QI,{title:m}):(0,G.jsx)(`p`,{className:`text-caption text-muted`,children:e(`loginHint`)}),(0,G.jsxs)(J,{type:`submit`,fullWidth:!0,size:`lg`,isPending:f,children:[e(f?`loggingInConsole`:`loginSubmit`),f?null:(0,G.jsx)(Yr,{size:17})]})]})]})})})]})]})}function N9(){return NI(`/api/keys`)}function HCe(e){return NI(`/api/keys`,{method:`POST`,body:JSON.stringify(e)})}function P9(e,t){return NI(`/api/keys/${encodeURIComponent(e)}`,{method:`PATCH`,body:JSON.stringify(t)})}function UCe(e){return NI(`/api/keys/${encodeURIComponent(e)}`,{method:`DELETE`})}function WCe(){return NI(`/api/system/console-key`)}function GCe(){return NI(`/api/system/console-key`,{method:`POST`,body:JSON.stringify({rotate:!0})})}function KCe({settings:e,onSaved:t}){let{t:n}=EI(),r=at(),[i,a]=(0,v.useState)(null),[o,s]=(0,v.useState)({}),[c,l]=(0,v.useState)(!1),[u,d]=(0,v.useState)(``);(0,v.useEffect)(()=>{let e=!0;return UI().then(t=>{e&&a((t.data||[]).filter(e=>e.regions.some(e=>e.checkin)))}).catch(t=>{e&&d(String(t))}),()=>{e=!1}},[]);async function f(n,r){if(!(!e||r===e.checkin_times[n])){l(!0),d(``);try{t(await eL({checkin_times:{[n]:r}}))}catch(e){d(e instanceof Error?e.message:String(e))}finally{s(e=>{let t={...e};return delete t[n],t}),l(!1)}}}return(0,G.jsxs)(HS,{"data-gsap-reveal":!0,children:[(0,G.jsxs)(HS.Header,{children:[(0,G.jsx)(HS.Title,{children:n(`checkinDefaultsTitle`)}),(0,G.jsx)(HS.Description,{children:n(`checkinDefaultsHint`)})]}),(0,G.jsxs)(HS.Content,{className:`space-y-4`,children:[u?(0,G.jsx)(QI,{title:u}):null,!e||!i?(0,G.jsx)(Q,{className:`h-24 w-full`}):i.map(t=>(0,G.jsx)(_9,{label:t.label,hint:t.regions.filter(e=>e.checkin).map(t=>`${t.label} · ${t.checkin?.timezone===`Local`?e.timezone:t.checkin?.timezone}`).join(` / `),children:(0,G.jsx)(UM,{type:`time`,value:o[t.id]??e.checkin_times[t.id]??``,disabled:c,"aria-label":`${t.label} ${n(`autoCheckinTime`)}`,onChange:e=>s(n=>({...n,[t.id]:e.target.value})),onBlur:e=>void f(t.id,e.target.value)})},t.id))]}),(0,G.jsx)(HS.Footer,{children:(0,G.jsx)(J,{variant:`secondary`,onPress:()=>r(`/accounts`),children:n(`navAccounts`)})})]})}function qCe(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 JCe({releases:e,currentVersion:t,nextVersion:n,rollbackTags:r,canRollback:i,submitting:a,onRestore:o}){let{t:s,lang:c}=EI();if(!e.length)return null;let l=n&&n!==t?n:t,u=e.some(e=>e.tag_name===l)?l:e[0]?.tag_name,d=new Set(r);return(0,G.jsxs)(`div`,{className:`mt-5`,children:[(0,G.jsx)(`div`,{className:`mb-2`,children:(0,G.jsx)(`p`,{className:`text-caption font-medium text-foreground`,children:s(`versionHistory`)})}),(0,G.jsx)(vh,{className:`rounded-lg bg-surface-secondary`,hideSeparator:!0,defaultExpandedKeys:u?[u]:[],children:e.map(e=>{let r=e.tag_name,l=r===t,u=!!(n&&r===n&&n!==t),f=i&&d.has(r)&&!l,p=qCe(e.published_at,c);return(0,G.jsxs)(vh.Item,{id:r,children:[(0,G.jsx)(vh.Heading,{children:(0,G.jsxs)(vh.Trigger,{className:`items-center gap-3 px-3 py-2.5 text-left`,children:[(0,G.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`mono text-body font-semibold`,children:r}),l?(0,G.jsx)(aC,{size:`sm`,variant:`soft`,color:`success`,children:s(`versionCurrentBadge`)}):null,u?(0,G.jsx)(aC,{size:`sm`,variant:`soft`,color:`warning`,children:s(`versionLatestBadge`)}):null,p?(0,G.jsx)(`span`,{className:`truncate text-caption text-muted`,children:p}):null]}),(0,G.jsx)(vh.Indicator,{})]})}),(0,G.jsx)(vh.Panel,{children:(0,G.jsxs)(vh.Body,{className:`px-3 pb-3`,children:[(0,G.jsx)(`div`,{className:`release-notes-box release-notes-box--compact`,children:(0,G.jsx)(aL,{markdown:rL(e.body,c),emptyLabel:s(`updateNoNotes`)})}),f?(0,G.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,G.jsx)(J,{size:`sm`,variant:`ghost`,isDisabled:a,onPress:()=>o(r),children:s(`restoreThisVersion`)})}):null]})})]},r)})})]})}function F9(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 YCe(e,t,n,r,i){return r?.length?F9(r):F9([...n?[n]:t?[{tag_name:t}]:[],...e?[{tag_name:e}]:[],...i||[]])}var XCe=[`general`,`routing`,`security`,`updates`];function ZCe(){let{t:e}=EI(),[t,n]=On(),r=t.get(`tab`),i=r&&XCe.includes(r)?r:`general`,a=e=>n(e===`general`?{}:{tab:e},{replace:!0}),{setApiKey:o}=kI(),[s,c]=(0,v.useState)(null),[l,u]=(0,v.useState)(null),[d,f]=(0,v.useState)(``),[p,m]=(0,v.useState)(!1),[h,g]=(0,v.useState)(!1),[_,y]=(0,v.useState)(!1),[b,x]=(0,v.useState)(``),[S,C]=(0,v.useState)(!1),[w,T]=(0,v.useState)(``),E=nL(),{info:D,loading:O,checking:k,submitting:A,error:j,setError:M,load:N,canRollback:P,rollbackTo:F}=E,I=(0,v.useMemo)(()=>YCe(D?.current_version||``,D?.next_version,D?.release,D?.recent_releases,D?.rollback_versions),[D?.current_version,D?.next_version,D?.release,D?.recent_releases,D?.rollback_versions]),L=(0,v.useMemo)(()=>(D?.rollback_versions||[]).map(e=>e.tag_name),[D?.rollback_versions]);(0,v.useEffect)(()=>{let e=window.setTimeout(()=>{WCe().then(c).catch(()=>void 0),$I().then(e=>{u(e),f(e.proxy_url||``)}).catch(e=>M(e instanceof Error?e.message:String(e)))},0);return()=>window.clearTimeout(e)},[M]);async function R(e){let t=l?.cross_provider_model_pool??!0;u(t=>t&&{...t,cross_provider_model_pool:e}),m(!0),M(``);try{u(await eL({cross_provider_model_pool:e}))}catch(e){u(e=>e&&{...e,cross_provider_model_pool:t}),M(e instanceof Error?e.message:String(e))}finally{m(!1)}}async function z(e){let t=l?.checkin_disabled_accounts??!1;u(t=>t&&{...t,checkin_disabled_accounts:e}),m(!0),M(``);try{u(await eL({checkin_disabled_accounts:e}))}catch(e){u(e=>e&&{...e,checkin_disabled_accounts:t}),M(e instanceof Error?e.message:String(e))}finally{m(!1)}}async function B(e){let t=l?.proxy_url||``;if(e===t){f(t);return}let n=d;f(e),u(t=>t&&{...t,proxy_url:e}),m(!0),M(``);try{let t=await eL({proxy_url:e});u(t),f(t.proxy_url||``)}catch(e){f(n),u(e=>e&&{...e,proxy_url:t}),M(e instanceof Error?e.message:String(e))}finally{m(!1)}}async function V(e){let t=l?.routing_strategy||`round-robin`;u(t=>t&&{...t,routing_strategy:e}),m(!0),M(``);try{u(await eL({routing_strategy:e}))}catch(e){u(e=>e&&{...e,routing_strategy:t}),M(e instanceof Error?e.message:String(e))}finally{m(!1)}}return O&&!D?(0,G.jsx)(Hse,{}):(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)(`h2`,{"data-gsap-reveal":!0,className:`text-title font-semibold`,children:e(`systemSettingsTitle`)}),(0,G.jsx)(`p`,{className:`mt-1 max-w-2xl text-body leading-6 text-muted`,children:e(`systemSettingsLead`)})]}),(0,G.jsxs)(J,{size:`sm`,variant:`secondary`,isPending:k,onPress:()=>void N(!0),children:[(0,G.jsx)(qr,{size:15}),e(`checkUpdates`)]})]}),j?(0,G.jsx)(QI,{title:j}):null,(0,G.jsxs)(_j,{selectedKey:i,onSelectionChange:e=>a(String(e)),children:[(0,G.jsx)(_j.ListContainer,{className:`w-fit max-w-full overflow-x-auto`,children:(0,G.jsxs)(_j.List,{"aria-label":e(`systemSettingsTitle`),children:[(0,G.jsxs)(gj,{id:`general`,className:`gap-1.5 whitespace-nowrap`,children:[(0,G.jsx)(_j.Indicator,{}),(0,G.jsx)(qi,{size:13}),e(`settingsTabGeneral`)]}),(0,G.jsxs)(gj,{id:`routing`,className:`gap-1.5 whitespace-nowrap`,children:[(0,G.jsx)(_j.Indicator,{}),(0,G.jsx)(ri,{size:13}),e(`settingsTabRouting`)]}),(0,G.jsxs)(gj,{id:`security`,className:`gap-1.5 whitespace-nowrap`,children:[(0,G.jsx)(_j.Indicator,{}),(0,G.jsx)(Da,{size:13}),e(`settingsTabSecurity`)]}),(0,G.jsxs)(gj,{id:`updates`,className:`gap-1.5 whitespace-nowrap`,children:[(0,G.jsx)(_j.Indicator,{}),(0,G.jsx)(Gr,{size:13}),e(`settingsTabUpdates`)]})]})}),(0,G.jsx)(_j.Panel,{id:`general`,className:`pt-5`,children:(0,G.jsxs)(`div`,{className:`grid gap-5 xl:grid-cols-2 items-start`,children:[(0,G.jsxs)(HS,{"data-gsap-reveal":!0,children:[(0,G.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,G.jsx)(`div`,{className:`grid size-8 shrink-0 place-items-center rounded-lg bg-surface-secondary text-foreground`,children:(0,G.jsx)(Na,{size:15})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`font-semibold`,children:e(`proxySettingsTitle`)}),(0,G.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:e(`proxySettingsHint`)})]})]}),(0,G.jsxs)(`div`,{className:`mt-4 space-y-1.5`,children:[(0,G.jsx)(IN,{className:`text-body font-medium text-muted`,children:e(`proxyUrl`)}),(0,G.jsx)(UM,{value:d,onChange:e=>f(e.target.value),onBlur:e=>void B(e.target.value.trim()),placeholder:e(`proxyUrlPlaceholder`),disabled:p||!l}),(0,G.jsx)(RN,{className:`text-caption leading-5 text-muted`,children:e(`proxyUrlHint`)})]})]}),(0,G.jsxs)(HS,{"data-gsap-reveal":!0,children:[(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,G.jsx)(`div`,{className:`grid size-8 shrink-0 place-items-center rounded-lg bg-surface-secondary text-foreground`,children:(0,G.jsx)(yi,{size:15})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`font-semibold`,children:e(`checkinDisabledAccountsTitle`)}),(0,G.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:e(`checkinDisabledAccountsHint`)})]})]}),(0,G.jsx)(F7,{isSelected:l?.checkin_disabled_accounts??!1,isDisabled:p||!l,ariaLabel:e(`checkinDisabledAccountsAriaLabel`),onChange:e=>void z(e)})]}),(0,G.jsxs)(`div`,{className:`mt-4 flex items-center justify-between pt-3 text-caption text-muted`,children:[(0,G.jsx)(`span`,{children:e(`checkinDisabledAccountsStatus`)}),(0,G.jsx)(`span`,{className:`font-medium text-foreground`,children:l?.checkin_disabled_accounts?e(`enabled`):e(`disabled`)})]})]}),(0,G.jsx)(KCe,{settings:l,onSaved:u})]})}),(0,G.jsx)(_j.Panel,{id:`routing`,className:`pt-5`,children:(0,G.jsxs)(`div`,{className:`grid gap-5 xl:grid-cols-2 items-start`,children:[(0,G.jsxs)(HS,{"data-gsap-reveal":!0,children:[(0,G.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,G.jsx)(`div`,{className:`grid size-8 shrink-0 place-items-center rounded-lg bg-surface-secondary text-foreground`,children:(0,G.jsx)(Na,{size:15})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`font-semibold`,children:e(`routingStrategyTitle`)}),(0,G.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:e(`routingStrategyHint`)})]})]}),(0,G.jsx)(`div`,{className:`mt-4 pt-4`,children:(0,G.jsx)(_9,{label:e(`routingStrategy`),children:(0,G.jsxs)(AF,{fullWidth:!0,"aria-label":e(`routingStrategy`),value:l?.routing_strategy||`round-robin`,isDisabled:p||!l,onChange:e=>{typeof e==`string`&&e&&V(e)},children:[(0,G.jsxs)(AF.Trigger,{className:`items-center`,children:[(0,G.jsx)(AF.Value,{className:`min-w-0 truncate`}),(0,G.jsx)(AF.Indicator,{})]}),(0,G.jsx)(AF.Popover,{children:(0,G.jsxs)(oF,{children:[(0,G.jsxs)(oF.Item,{id:`round-robin`,textValue:`round-robin`,children:[(0,G.jsx)(IN,{children:e(`routingRoundRobin`)}),(0,G.jsx)(oF.ItemIndicator,{})]}),(0,G.jsxs)(oF.Item,{id:`weighted-round-robin`,textValue:`weighted-round-robin`,children:[(0,G.jsx)(IN,{children:e(`routingWeightedRoundRobin`)}),(0,G.jsx)(oF.ItemIndicator,{})]}),(0,G.jsxs)(oF.Item,{id:`fill-first`,textValue:`fill-first`,children:[(0,G.jsx)(IN,{children:e(`routingFillFirst`)}),(0,G.jsx)(oF.ItemIndicator,{})]}),(0,G.jsxs)(oF.Item,{id:`fefo`,textValue:`fefo`,children:[(0,G.jsx)(IN,{children:e(`routingFEFO`)}),(0,G.jsx)(oF.ItemIndicator,{})]})]})})]})})}),(0,G.jsxs)(`div`,{className:`mt-4 grid grid-cols-2 gap-2 pt-3 text-caption text-muted sm:grid-cols-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`mono block text-body font-medium text-foreground`,children:l?.session_affinity?.ttl_seconds?`${Math.round(l.session_affinity.ttl_seconds/60)}m`:`—`}),e(`sessionAffinityTTL`)]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`mono block text-body font-medium text-foreground`,children:l?.session_affinity?.hits??0}),e(`sessionAffinityHits`)]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`mono block text-body font-medium text-foreground`,children:l?.session_affinity?.misses??0}),e(`sessionAffinityMisses`)]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`span`,{className:`mono block text-body font-medium text-foreground`,children:l?.session_affinity?.escapes??0}),e(`sessionAffinityEscapes`)]})]}),l?.session_affinity?.last_escape_reason?(0,G.jsxs)(RN,{className:`mt-3 text-caption`,children:[e(`lastSessionEscape`),`: `,l.session_affinity.last_escape_reason]}):null,l?.session_affinity?.last_miss_reason?(0,G.jsxs)(RN,{className:`mt-1 text-caption`,children:[e(`lastSessionMiss`),`: `,l.session_affinity.last_miss_reason]}):null]}),(0,G.jsxs)(HS,{"data-gsap-reveal":!0,children:[(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,G.jsx)(`div`,{className:`grid size-8 shrink-0 place-items-center rounded-lg bg-surface-secondary text-foreground`,children:(0,G.jsx)(Na,{size:15})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`font-semibold`,children:e(`crossProviderModelPoolTitle`)}),(0,G.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:e(`crossProviderModelPoolHint`)})]})]}),(0,G.jsx)(F7,{isSelected:l?.cross_provider_model_pool??!0,isDisabled:p||!l,ariaLabel:e(`crossProviderModelPoolAriaLabel`),onChange:e=>void R(e)})]}),(0,G.jsxs)(`div`,{className:`mt-4 flex items-center justify-between pt-3 text-caption text-muted`,children:[(0,G.jsx)(`span`,{children:e(`crossProviderModelPoolStatus`)}),(0,G.jsx)(`span`,{className:`font-medium text-foreground`,children:l?.cross_provider_model_pool?e(`enabled`):e(`disabled`)})]})]})]})}),(0,G.jsx)(_j.Panel,{id:`security`,className:`pt-5`,children:(0,G.jsxs)(`div`,{className:`grid gap-5 xl:grid-cols-2 items-start`,children:[(0,G.jsxs)(HS,{"data-gsap-reveal":!0,children:[(0,G.jsx)(`div`,{className:`flex items-start justify-between gap-4`,children:(0,G.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,G.jsx)(`div`,{className:`grid size-8 shrink-0 place-items-center rounded-lg bg-surface-secondary text-foreground`,children:(0,G.jsx)(ta,{size:15})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`font-semibold`,children:e(`consoleKeyTitle`)}),(0,G.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:e(`consoleKeyHint`)})]})]})}),(0,G.jsx)(`code`,{className:`mono mt-4 block rounded-lg bg-surface-secondary px-3 py-2 text-caption text-muted`,children:s?.prefix||`—`}),(0,G.jsx)(`p`,{className:`mt-3 text-caption leading-5 text-muted`,children:e(`consoleKeyLead`)}),(0,G.jsx)(`div`,{className:`mt-4 flex justify-end`,children:(0,G.jsx)(J,{size:`sm`,variant:`ghost`,isPending:h,onPress:()=>y(!0),children:e(`consoleKeyRotate`)})})]}),(0,G.jsxs)(HS,{"data-gsap-reveal":!0,children:[(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,G.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,G.jsx)(`div`,{className:`grid size-8 shrink-0 place-items-center rounded-lg bg-surface-secondary text-foreground`,children:(0,G.jsx)(Ni,{size:15})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`font-semibold`,children:e(`sqliteProtection`)}),(0,G.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:e(`sqliteProtectionHint`)})]})]}),(0,G.jsx)(Da,{size:18,className:`text-success`})]}),(0,G.jsx)(`div`,{className:`mono mt-4 rounded-lg bg-surface-secondary px-3 py-2 text-caption text-muted`,children:`/data`}),(0,G.jsxs)(`div`,{className:`mt-3 grid gap-2 text-caption text-muted`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(yi,{size:14,className:`text-muted`}),e(`sqliteBackupBeforeUpdate`)]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(yi,{size:14,className:`text-muted`}),e(`sqliteKeepFive`)]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(yi,{size:14,className:`text-muted`}),e(`sqliteRollbackTogether`)]})]})]})]})}),(0,G.jsx)(_j.Panel,{id:`updates`,className:`pt-5`,children:(0,G.jsx)(`div`,{className:`grid gap-5`,children:(0,G.jsxs)(HS,{"data-gsap-reveal":!0,className:`overflow-hidden p-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b border-separator px-5 py-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`font-semibold`,children:e(`versionUpdate`)}),(0,G.jsx)(`p`,{className:`mt-0.5 text-caption text-muted`,children:e(`latestVersionHint`)})]}),(0,G.jsx)(aC,{size:`sm`,variant:`soft`,color:D?.has_update?`warning`:`success`,children:D?.has_update?e(`updateAvailable`):e(`upToDate`)})]}),(0,G.jsxs)(`div`,{className:`px-5 py-5`,children:[(0,G.jsx)(ZI,{update:E}),(0,G.jsx)(JCe,{releases:I,currentVersion:D?.current_version||``,nextVersion:D?.next_version,rollbackTags:L,canRollback:P,submitting:A,onRestore:T})]})]})})})]}),(0,G.jsx)(E9,{isOpen:!!w,title:e(`restoreVersionTitle`,{version:w}),description:e(`restoreVersionHint`),confirmLabel:e(`restoreThisVersion`),cancelLabel:e(`cancel`),closeLabel:e(`close`),isPending:A,status:`warning`,confirmVariant:`primary`,onClose:()=>{A||T(``)},onConfirm:()=>{let e=w;T(``),F(e)}}),(0,G.jsx)(Y.Root,{isOpen:_,onOpenChange:e=>{!e&&!h&&y(!1)},children:(0,G.jsx)(Y.Backdrop,{variant:`blur`,isDismissable:!h,children:(0,G.jsx)(Y.Container,{placement:`center`,size:`sm`,children:(0,G.jsxs)(Y.Dialog,{children:[(0,G.jsxs)(Y.Header,{className:`items-start justify-between gap-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(Y.Heading,{className:`text-section font-semibold`,children:e(`consoleKeyRotate`)}),(0,G.jsx)(`p`,{className:`mt-1 text-caption leading-5 text-muted`,children:e(`consoleKeyRotateHint`)})]}),(0,G.jsx)(Y.CloseTrigger,{isDisabled:h,"aria-label":e(`close`),className:`grid size-8 place-items-center rounded-lg text-muted hover:bg-surface-secondary`,children:(0,G.jsx)(ao,{size:16})})]}),(0,G.jsxs)(Y.Footer,{className:`justify-end`,children:[(0,G.jsx)(J,{variant:`ghost`,isDisabled:h,onPress:()=>y(!1),children:e(`cancel`)}),(0,G.jsx)(J,{variant:`danger`,isPending:h,onPress:()=>{g(!0),GCe().then(e=>{c(e),x(e.secret||``),e.secret&&o(e.secret),y(!1)}).catch(e=>{M(e instanceof Error?e.message:String(e))}).finally(()=>g(!1))},children:e(`consoleKeyRotateNow`)})]})]})})})}),(0,G.jsx)(Y.Root,{isOpen:!!b,onOpenChange:e=>{e||x(``)},children:(0,G.jsx)(Y.Backdrop,{variant:`blur`,children:(0,G.jsx)(Y.Container,{placement:`center`,size:`lg`,children:(0,G.jsxs)(Y.Dialog,{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:e(`consoleKeySecretTitle`)}),(0,G.jsx)(`p`,{className:`mt-1.5 text-body leading-6 text-muted`,children:e(`consoleKeySecretHint`)})]}),(0,G.jsx)(Y.CloseTrigger,{"aria-label":e(`close`),className:`grid size-9 place-items-center rounded-lg text-muted hover:bg-surface-secondary`,children:(0,G.jsx)(ao,{size:18})})]}),(0,G.jsx)(Y.Body,{className:`px-6 pb-2`,children:(0,G.jsx)(`code`,{className:`mono block break-all rounded-lg bg-surface-secondary px-3 py-3 text-body`,children:b})}),(0,G.jsxs)(Y.Footer,{className:`justify-end`,children:[(0,G.jsx)(J,{variant:`ghost`,onPress:()=>x(``),children:e(`close`)}),(0,G.jsxs)(J,{onPress:()=>{Z7(b),C(!0),window.setTimeout(()=>C(!1),1200)},children:[(0,G.jsx)(Di,{size:14}),e(S?`copied`:`copy`)]})]})]})})})})]})}var I9=`__all__`;function QCe(e,t){let n=t.trim().toLowerCase();return!n||e.label.toLowerCase().includes(n)||e.id.toLowerCase().includes(n)}function L9({value:e,onChange:t,ariaLabel:n,options:r,allLabel:i,searchPlaceholder:a,emptyLabel:o,loadOptions:s,className:c}){let[l,u]=(0,v.useState)(``),[d,f]=(0,v.useState)([]),[p,m]=(0,v.useState)(!1);(0,v.useEffect)(()=>{if(!s)return;let e=!1,t=window.setTimeout(()=>{m(!0),s(l.trim()).then(t=>{e||f(t)}).catch(()=>{e||f([])}).finally(()=>{e||m(!1)})},l.trim()?280:0);return()=>{e=!0,window.clearTimeout(t)}},[s,l]);let h=e||I9,g=(0,v.useMemo)(()=>{let t=s?d:r.filter(e=>QCe(e,l)),n=new Map;l.trim()||n.set(I9,{id:I9,label:i});for(let e of t)!e.id||e.id===I9||n.set(e.id,e);if(e){let t=r.find(t=>t.id===e)||d.find(t=>t.id===e)||{id:e,label:e};n.set(e,t)}return[...n.values()]},[i,s,r,l,d,e]),_=g.find(e=>e.id===h)||(e?{id:e,label:e}:{id:I9,label:i});return(0,G.jsxs)(NS,{className:[`w-fit`,c].filter(Boolean).join(` `),"aria-label":n,value:h,onChange:e=>{typeof e==`string`&&(t(e===I9?``:e),u(``))},onClear:()=>{t(``),u(``)},children:[(0,G.jsxs)(NS.Trigger,{className:`min-w-44 items-center`,children:[(0,G.jsx)(NS.Value,{className:`min-w-0 truncate`,children:({defaultChildren:e,isPlaceholder:t})=>t?e:(0,G.jsx)(`span`,{className:`truncate`,children:_.label})}),e?(0,G.jsx)(NS.ClearButton,{}):null,(0,G.jsx)(NS.Indicator,{})]}),(0,G.jsx)(NS.Popover,{className:`min-w-56`,children:(0,G.jsxs)(NS.Filter,{inputValue:l,onInputChange:u,filter:()=>!0,children:[(0,G.jsx)(PN,{"aria-label":a,className:`px-2 pt-2`,autoFocus:!0,children:(0,G.jsxs)(PN.Group,{children:[(0,G.jsx)(PN.SearchIcon,{}),(0,G.jsx)(PN.Input,{placeholder:a}),(0,G.jsx)(PN.ClearButton,{})]})}),(0,G.jsx)(oF,{children:g.length===0?(0,G.jsx)(oF.Item,{id:`__empty__`,textValue:o,isDisabled:!0,children:(0,G.jsx)(IN,{className:`block truncate text-muted`,children:p?a:o})}):g.map(e=>(0,G.jsxs)(oF.Item,{id:e.id,textValue:e.label,children:[(0,G.jsx)(IN,{className:`block truncate`,children:e.label}),e.id!==I9&&e.id!==e.label?(0,G.jsx)(`span`,{className:`mono mt-0.5 block truncate text-caption text-muted`,children:e.id}):null,(0,G.jsx)(oF.ItemIndicator,{})]},e.id))})]})})]})}function R9(){let[e,t]=(0,v.useState)([]);return(0,v.useEffect)(()=>{let e=!1;return N9().then(n=>{e||t(n.data||[])}).catch(()=>{}),()=>{e=!0}},[]),{keys:e,nameById:(0,v.useMemo)(()=>{let t=new Map;for(let n of e)t.set(n.id,n.name||n.id);return t},[e]),options:(0,v.useMemo)(()=>e.map(e=>({id:e.id,label:e.name||e.id})),[e])}}function z9(e){return e===`ok`?`success`:e===`streaming`||e===`started`||e===`incomplete`?`warning`:e===`error`||e===`canceled`?`danger`:`default`}function $Ce(e){if(e===`error`)return`danger`;if(e!==`warn`)return`ok`}function ewe(e){return e===`error`?`danger`:e===`warn`?`warning`:e===`info`?`success`:`default`}function B9(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 V9(e){let t=e.requested_reasoning?.trim()||``,n=e.resolved_reasoning?.trim()||``;return!t&&!n?``:t&&n&&t!==n?`${t} → ${n}`:n||t}function H9({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)?U9(o):null;return i==null&&a==null&&s==null?(0,G.jsx)(`span`,{className:`mono text-xs text-muted`,children:`—`}):(0,G.jsxs)(`div`,{className:`leading-4`,children:[i!=null||a!=null?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`mono text-xs`,children:[i??0,` / `,a??0]}),(0,G.jsxs)(`div`,{className:`mt-0.5 text-caption text-muted`,children:[t,` / `,n]})]}):null,s==null?null:(0,G.jsx)(`div`,{className:`mono text-caption text-success ${i!=null||a!=null?`mt-0.5`:``}`,children:r?r(s):s})]})}function twe(){return(0,G.jsxs)(`div`,{className:`space-y-5`,"aria-busy":`true`,"aria-live":`polite`,children:[(0,G.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:Array.from({length:8},(e,t)=>(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(Q,{className:`h-3 w-20`}),(0,G.jsx)(Q,{className:`h-5 w-36 max-w-full`})]},t))}),(0,G.jsxs)(`div`,{className:`space-y-3 rounded-lg bg-surface-secondary px-3 py-3`,children:[(0,G.jsx)(Q,{className:`h-3 w-24`}),(0,G.jsx)(Q,{className:`h-4 w-full`}),(0,G.jsx)(Q,{className:`h-4 w-4/5`})]}),(0,G.jsxs)(`div`,{className:`space-y-3`,children:[(0,G.jsx)(Q,{className:`h-3 w-20`}),(0,G.jsx)(Q,{className:`h-16 w-full`})]})]})}function U9(e){return e==null||!Number.isFinite(e)?`—`:String(Math.round(e*1e4)/1e4)}var nwe=[`all`,`ok`,`incomplete`,`error`,`canceled`],rwe=[`all`,`quota`,`rate_limit`,`auth`,`not_ready`,`unavailable`,`invalid_request`,`model_not_available`],iwe=[`all`,`1h`,`24h`,`7d`,`custom`];function W9(e){let t=(e,t,n)=>t.includes(e??``)?e:n,n=hH(e.get(`from`)),r=hH(e.get(`to`)),i=n&&r?{start:n,end:r}:null,a=e.get(`stream`);return{requestFilter:t(e.get(`status`),nwe,`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`),rwe,`all`),timeRange:i?`custom`:t(e.get(`range`),iwe,`1h`),customRange:i}}function awe(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`?mH(e.customRange?.start):void 0,r=e.timeRange===`custom`?mH(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 owe(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 swe(){let{t:e,lang:t}=EI(),[n,r]=On(),[i]=(0,v.useState)(()=>W9(new URLSearchParams(window.location.search))),[a,o]=(0,v.useState)([]),[s,c]=(0,v.useState)([]),[l,u]=(0,v.useState)(`requests`),[d,f]=(0,v.useState)(!0),[p,m]=(0,v.useState)(!1),[h,g]=(0,v.useState)(``),[_,y]=(0,v.useState)(i.requestFilter),[b,x]=(0,v.useState)(`all`),[S,C]=(0,v.useState)(i.requestId),[w,T]=(0,v.useState)(``),[E,D]=(0,v.useState)(i.accountFilter),[O,k]=(0,v.useState)(i.apiKeyFilter),[A,j]=(0,v.useState)(``),[M,N]=(0,v.useState)(i.modelFilter),[P,F]=(0,v.useState)(i.providerFilter),[I,L]=(0,v.useState)(i.streamFilter),[R,z]=(0,v.useState)(i.errorKind),[B,V]=(0,v.useState)(i.timeRange),[H,ee]=(0,v.useState)(i.customRange),[te,ne]=(0,v.useState)(1),[re,ie]=(0,v.useState)(50),[ae,oe]=(0,v.useState)(1),[se,ce]=(0,v.useState)(50),[le,ue]=(0,v.useState)([]),[de,fe]=(0,v.useState)(0),[pe,me]=(0,v.useState)([]),[he,ge]=(0,v.useState)(0),[_e,ve]=(0,v.useState)(null),[ye,be]=(0,v.useState)(!1),[xe,Se]=(0,v.useState)(null),[Ce,we]=(0,v.useState)(!1),[Te,Ee]=(0,v.useState)(!1),[De,Oe]=(0,v.useState)(``),ke=(0,v.useRef)(0),[Ae,je]=(0,v.useState)(!1),[Me,Ne]=(0,v.useState)(!1),Pe=n.toString(),Fe=awe({requestFilter:_,requestId:S,accountFilter:E,apiKeyFilter:O,modelFilter:M,providerFilter:P,streamFilter:I,errorKind:R,timeRange:B,customRange:H}),Ie=(0,v.useRef)(Pe);(0,v.useEffect)(()=>{if(Pe===Ie.current)return;Ie.current=Pe;let e=W9(new URLSearchParams(Pe));y(e.requestFilter),C(e.requestId),D(e.accountFilter),k(e.apiKeyFilter),N(e.modelFilter),F(e.providerFilter),L(e.streamFilter),z(e.errorKind),V(e.timeRange),ee(e.customRange)},[Pe]),(0,v.useEffect)(()=>{Fe!==Ie.current&&(Ie.current=Fe,r(Fe,{replace:!0}))},[Fe,r]),(0,v.useEffect)(()=>{let e=!1;return Promise.allSettled([PI(!1),VI()]).then(([t,n])=>{e||(t.status===`fulfilled`&&o(t.value.data||[]),n.status===`fulfilled`&&c(n.value.data||[]))}),()=>{e=!0}},[]);let Le=(0,v.useMemo)(()=>{let e=new Map;for(let t of a||[])e.set(t.id,t.name||t.id);return e},[a]),Re=(0,v.useMemo)(()=>{let e=new Map;for(let t of a||[])e.set(t.id,{provider:t.provider,region:t.region});return e},[a]);function ze(t){let n=t.account_id?Re.get(t.account_id):void 0,r=t.provider||n?.provider;return r?jH(r,n?.region,e):`—`}function Be(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 Ve=(0,v.useMemo)(()=>(a||[]).map(e=>({id:e.id,label:e.name||e.id})),[a]),{nameById:He,options:Ue}=R9();function We(e){let t=e.api_key_id?.trim();return t?He.get(t)||t:`—`}let Ge=(0,v.useMemo)(()=>{let t=new Set;for(let e of a||[])e.provider&&t.add(e.provider);return P&&t.add(P),[{id:``,label:e(`logsFilterProviderAll`)},...[...t].sort().map(t=>({id:t,label:AH(t,e)}))]},[a,P,e]),Ke=(0,v.useMemo)(()=>{let e=new Map;for(let t of s||[])e.has(t.id)||e.set(t.id,{id:t.id,label:t.display_name||t.id});return[...e.values()]},[s]),qe=(0,v.useCallback)(async e=>((await QV({q:e||void 0,limit:20,offset:0})).items||[]).map(e=>({id:e.id,label:e.id})),[]),Je=!!(S||_!==`all`||E||O||M||P||I!==`all`||R!==`all`||B!==`1h`),Ye=[_,S,E,O,M,P,I,R,B,H?.start?.toString()??``,H?.end?.toString()??``,re].join(`\0`),Xe=[b,w,A,se].join(`\0`),[Ze,Qe]=(0,v.useState)(Ye),[$e,et]=(0,v.useState)(Xe);Ze!==Ye&&(Qe(Ye),ne(1)),$e!==Xe&&(et(Xe),oe(1));let tt=Math.max(1,Math.ceil(de/re)),nt=Math.min(Ze===Ye?Math.max(1,te):1,tt);te!==nt&&ne(nt);let rt=Math.max(1,Math.ceil(he/se)),it=Math.min($e===Xe?Math.max(1,ae):1,rt);ae!==it&&oe(it);let at=(0,v.useCallback)(async(e=!1)=>{e||f(!0);try{let e=S?{from:void 0,to:void 0}:B===`custom`?{from:mH(H?.start),to:mH(H?.end,!0)}:owe(B),t=await QV({status:_===`all`?void 0:_,id:S||void 0,account:E||void 0,api_key:O||void 0,model:M||void 0,provider:P||void 0,stream:I===`all`?void 0:I===`stream`,error_kind:R===`all`?void 0:R,from:e.from,to:e.to,limit:re,offset:(nt-1)*re});ue(t.items||[]),fe(t.total||0),g(``)}catch(t){e||g(t instanceof Error?t.message:String(t))}finally{e||(f(!1),m(!0))}},[_,S,E,O,M,P,I,R,B,H,nt,re]),ot=(0,v.useCallback)(async(e=!1)=>{e||f(!0);try{let e=await cce({level:b===`all`?void 0:b,q:w.trim()||void 0,account:A||void 0,limit:se,offset:(it-1)*se});me(e.items||[]),ge(e.total??0),g(``)}catch(t){e||g(t instanceof Error?t.message:String(t))}finally{e||(f(!1),m(!0))}},[b,w,A,it,se]),st=(0,v.useCallback)(async(e=!1)=>{l===`requests`?await at(e):await ot(e)},[l,at,ot]);(0,v.useEffect)(()=>{f(!0);let e=l===`runtime`&&w.trim()?280:0,t=window.setTimeout(()=>void st(!1),e);return()=>window.clearTimeout(t)},[st,l,w]),(0,v.useEffect)(()=>{if(l!==`runtime`||it!==1)return;let e=window.setInterval(()=>void ot(!0),3e3);return()=>window.clearInterval(e)},[l,it,ot]);let ct=de===0?0:(nt-1)*re+1,lt=Math.min(de,nt*re),ut=he===0?0:(it-1)*se+1,dt=Math.min(he,it*se),ft=(0,v.useMemo)(()=>l===`requests`?e(`logsShownTotal`,{shown:le.length?`${ct}–${lt}`:0,total:de}):e(`logsShownTotal`,{shown:pe.length?`${ut}–${dt}`:0,total:he}),[l,le.length,pe.length,ct,lt,de,ut,dt,he,e]);function pt(){C(``),y(`all`),D(``),k(``),N(``),F(``),L(`all`),z(`all`),V(`1h`),ee(null),ne(1)}async function mt(e){let t=++ke.current;Se(e),Oe(``),Ee(!0),we(!0);try{let n=await oce(e.id);if(ke.current!==t)return;Se(n)}catch(e){if(ke.current!==t)return;Oe(e instanceof Error?e.message:String(e))}finally{ke.current===t&&Ee(!1)}}function ht(e){ve(e),be(!0)}async function gt(){Ne(!0),XV({id:`logs-clear`,type:`loading`,title:e(`toastClearingLogs`)});try{await sce(),je(!1),await at(!1),XV({id:`logs-clear`,type:`success`,title:e(`toastLogsCleared`)})}catch(t){g(t instanceof Error?t.message:String(t)),XV({id:`logs-clear`,type:`error`,title:e(`toastFailed`),description:t instanceof Error?t.message:String(t)})}finally{Ne(!1)}}let _t=d&&(l===`requests`?le.length===0:pe.length===0);return d&&!p?(0,G.jsx)(Bse,{}):(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)(`h2`,{className:`text-title font-semibold`,children:e(`navLogs`)}),(0,G.jsx)(`p`,{className:`mt-1 max-w-2xl text-body leading-6 text-muted`,children:e(`logsLead`)})]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[l===`requests`?(0,G.jsxs)(J,{size:`sm`,variant:`ghost`,onPress:()=>je(!0),isDisabled:Me||de===0,children:[(0,G.jsx)(qa,{size:14}),e(`logsClear`)]}):null,(0,G.jsxs)(J,{size:`sm`,variant:`secondary`,isPending:d,onPress:()=>void st(!1),children:[(0,G.jsx)(qr,{size:15}),e(`refresh`)]})]})]}),h?(0,G.jsx)(QI,{title:e(`failedLogs`,{msg:h})}):null,(0,G.jsxs)(_j,{selectedKey:l,onSelectionChange:e=>u(String(e)),children:[(0,G.jsx)(_j.ListContainer,{className:`w-fit`,children:(0,G.jsxs)(_j.List,{children:[(0,G.jsxs)(gj,{id:`requests`,className:`gap-1.5`,children:[(0,G.jsx)(_j.Indicator,{className:`transition-none`}),(0,G.jsx)(Ta,{size:13}),e(`logsRequests`)]}),(0,G.jsxs)(gj,{id:`runtime`,className:`gap-1.5`,children:[(0,G.jsx)(_j.Indicator,{className:`transition-none`}),(0,G.jsx)(Ga,{size:13}),e(`logsRuntime`)]})]})}),(0,G.jsxs)(_j.Panel,{id:`requests`,"data-tab-panel":`requests`,className:`space-y-4 pt-5`,children:[(0,G.jsxs)(`div`,{className:`data-toolbar flex flex-col gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,G.jsx)(pH,{value:_,onChange:e=>y(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,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[Je?(0,G.jsx)(J,{size:`sm`,variant:`ghost`,onPress:pt,children:e(`clearFilters`)}):null,(0,G.jsx)(`div`,{className:`mono text-caption text-muted`,children:ft})]})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(L9,{ariaLabel:e(`logsColAccount`),value:E,onChange:D,options:Ve,allLabel:e(`logsFilterAccountAll`),searchPlaceholder:e(`logsSearchAccount`),emptyLabel:e(`logsNoFilterOptions`)}),(0,G.jsx)(L9,{ariaLabel:e(`logsColApiKey`),value:O,onChange:k,options:Ue,allLabel:e(`logsFilterApiKeyAll`),searchPlaceholder:e(`logsSearchApiKey`),emptyLabel:e(`logsNoFilterOptions`)}),(0,G.jsx)(L9,{ariaLabel:e(`logsColModel`),value:M,onChange:N,options:Ke,allLabel:e(`logsFilterModelAll`),searchPlaceholder:e(`logsSearchModel`),emptyLabel:e(`logsNoFilterOptions`)}),(0,G.jsx)(R7,{ariaLabel:e(`logsColProvider`),value:P,onChange:F,options:Ge}),(0,G.jsx)(L9,{ariaLabel:e(`logsSearchRequestId`),value:S,onChange:C,options:S?[{id:S,label:S}]:[],allLabel:e(`logsFilterIdAll`),searchPlaceholder:e(`logsSearchRequestId`),emptyLabel:e(`logsNoFilterOptions`),loadOptions:qe,className:`min-w-56`}),(0,G.jsx)(pH,{value:I,onChange:e=>L(e),ariaLabel:e(`logsFilterStreamAll`),options:[{id:`all`,label:e(`logsFilterStreamAll`)},{id:`stream`,label:e(`logsStreamYes`)},{id:`sync`,label:e(`logsStreamNo`)}]}),(0,G.jsx)(R7,{ariaLabel:e(`errorKind`),value:R===`all`?``:R,onChange:e=>z(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,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`text-xs font-medium text-muted`,children:e(`logsTimeRange`)}),(0,G.jsx)(pH,{value:B,onChange:e=>V(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`)}]}),B===`custom`?(0,G.jsx)(gH,{className:`w-[min(100%,42rem)]`,value:H,onChange:ee,ariaLabel:e(`logsTimeRange`),fromLabel:e(`logsTimeFrom`),toLabel:e(`logsTimeTo`)}):null]})]}),(0,G.jsx)(HS,{className:`overflow-hidden p-0`,"aria-busy":d,children:_t?(0,G.jsx)(RV,{}):le.length===0?(0,G.jsx)(I7,{icon:(0,G.jsx)(la,{size:22}),title:e(Je?`logsNoMatch`:`logsEmptyRequests`),action:Je?(0,G.jsx)(J,{size:`sm`,variant:`ghost`,onPress:pt,children:e(`clearFilters`)}):null}):(0,G.jsx)(X,{children:(0,G.jsx)(X.ScrollContainer,{children:(0,G.jsxs)(X.Content,{"aria-label":e(`logsRequests`),children:[(0,G.jsxs)(X.Header,{children:[(0,G.jsx)(X.Column,{isRowHeader:!0,children:e(`logsColTime`)}),(0,G.jsx)(X.Column,{children:e(`logsColModel`)}),(0,G.jsx)(X.Column,{children:e(`logsColReasoning`)}),(0,G.jsx)(X.Column,{children:e(`logsColProvider`)}),(0,G.jsx)(X.Column,{children:e(`logsColAccount`)}),(0,G.jsx)(X.Column,{children:e(`logsColApiKey`)}),(0,G.jsx)(X.Column,{children:e(`logsColStatus`)}),(0,G.jsx)(X.Column,{children:e(`logsColStream`)}),(0,G.jsx)(X.Column,{children:e(`logsColLatency`)}),(0,G.jsx)(X.Column,{children:e(`logsColTokens`)})]}),(0,G.jsx)(X.Body,{children:le.map(n=>(0,G.jsxs)(X.Row,{className:`cursor-pointer`,onAction:()=>void mt(n),children:[(0,G.jsx)(X.Cell,{children:(0,G.jsxs)(`div`,{className:`py-1`,children:[(0,G.jsx)(`div`,{className:`mono text-xs`,children:B9(n.created_at,t)}),(0,G.jsx)(`div`,{className:`mono mt-0.5 text-caption text-muted`,children:n.id})]})}),(0,G.jsxs)(X.Cell,{children:[(0,G.jsx)(`div`,{className:`text-body font-medium`,children:n.requested_model||`—`}),n.mapped_model&&n.mapped_model!==n.requested_model?(0,G.jsx)(`div`,{className:`mono mt-0.5 text-caption text-muted`,children:n.mapped_model}):null]}),(0,G.jsx)(X.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-xs`,children:V9(n)||`—`})}),(0,G.jsx)(X.Cell,{children:(0,G.jsx)(`span`,{className:`text-xs`,children:ze(n)})}),(0,G.jsxs)(X.Cell,{children:[(0,G.jsx)(`span`,{className:`text-xs`,children:n.account_id?Le.get(n.account_id)||n.account_id:`—`}),n.account_id&&Le.get(n.account_id)&&Le.get(n.account_id)!==n.account_id?(0,G.jsx)(`div`,{className:`mono mt-0.5 text-caption text-muted`,children:n.account_id}):null]}),(0,G.jsx)(X.Cell,{children:(0,G.jsx)(`span`,{className:`text-xs`,children:We(n)})}),(0,G.jsxs)(X.Cell,{children:[(0,G.jsx)(aC,{size:`sm`,variant:`soft`,color:z9(n.status),children:n.status}),n.error_kind?(0,G.jsx)(`div`,{className:`mono mt-1 text-caption text-muted`,children:n.error_kind}):null]}),(0,G.jsx)(X.Cell,{children:(0,G.jsx)(`span`,{className:`text-xs text-muted`,children:n.stream?e(`logsStreamYes`):e(`logsStreamNo`)})}),(0,G.jsx)(X.Cell,{children:(0,G.jsx)(n9,{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,G.jsx)(X.Cell,{children:(0,G.jsx)(H9,{log:n,inLabel:e(`logsTokensIn`),outLabel:e(`logsTokensOut`),pointsLabel:t=>e(`logsTokensPoints`,{value:t})})})]},n.id))})]})})})}),(0,G.jsx)(z7,{total:de,page:nt,pageCount:tt,pageSize:re,loading:d,pageSizeLabel:e(`logsPageSize`),pageLabel:e(`logsPage`,{page:nt,pages:tt}),prevLabel:e(`logsPrevPage`),nextLabel:e(`logsNextPage`),onPage:ne,onPageSize:ie})]}),(0,G.jsxs)(_j.Panel,{id:`runtime`,"data-tab-panel":`runtime`,className:`space-y-4 pt-5`,children:[(0,G.jsxs)(`div`,{className:`data-toolbar flex flex-wrap items-center justify-between gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(B7,{className:`sm:w-72`,value:w,onChange:T,placeholder:e(`logsSearchRuntime`),ariaLabel:e(`logsSearchRuntime`)}),(0,G.jsx)(L9,{ariaLabel:e(`logsColAccount`),value:A,onChange:j,options:Ve,allLabel:e(`logsFilterAccountAll`),searchPlaceholder:e(`logsSearchAccount`),emptyLabel:e(`logsNoFilterOptions`)}),(0,G.jsx)(pH,{value:b,onChange:e=>x(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,G.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted`,children:[it===1?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`status-dot`,"data-state":`ok`}),e(`logsAutoRefresh`)]}):null,(0,G.jsx)(`span`,{className:`mono`,children:ft})]})]}),(0,G.jsx)(HS,{className:`overflow-hidden p-0`,"aria-busy":d,children:_t?(0,G.jsx)(zse,{}):pe.length===0?(0,G.jsx)(I7,{icon:(0,G.jsx)(Ga,{size:22}),title:e(`logsEmptyRuntime`)}):(0,G.jsx)(`div`,{className:`divide-y divide-separator`,children:pe.map(e=>(0,G.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:()=>ht(e),onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),ht(e))},children:[(0,G.jsx)(`div`,{className:`mono text-caption text-muted`,children:B9(e.time,t)}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[(0,G.jsx)(`span`,{className:`status-dot`,"data-state":$Ce(e.level)}),(0,G.jsx)(`span`,{className:`font-medium text-muted`,children:e.level})]}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[e.account_id?(0,G.jsx)(`div`,{className:`mono mb-1 text-caption text-muted`,children:e.account_id}):null,(0,G.jsx)(`div`,{className:`mono break-all text-xs leading-5 text-foreground`,children:e.message})]})]},e.id))})}),(0,G.jsx)(z7,{total:he,page:it,pageCount:rt,pageSize:se,loading:d,pageSizeLabel:e(`logsPageSize`),pageLabel:e(`logsPage`,{page:it,pages:rt}),prevLabel:e(`logsPrevPage`),nextLabel:e(`logsNextPage`),onPage:oe,onPageSize:ce})]})]}),(0,G.jsx)(Y.Root,{isOpen:ye,onOpenChange:e=>{be(e),e||ve(null)},children:(0,G.jsx)(Y.Backdrop,{variant:`blur`,children:(0,G.jsx)(Y.Container,{size:`lg`,scroll:`inside`,children:(0,G.jsxs)(Y.Dialog,{className:`w-full max-w-4xl`,children:[(0,G.jsxs)(Y.Header,{className:`items-start justify-between gap-4 px-5 pt-5`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(Y.Heading,{className:`text-section font-semibold`,children:e(`logsRuntimeDetailTitle`)}),(0,G.jsx)(`p`,{className:`mono mt-1 text-caption text-muted`,children:_e?`#${_e.id}`:`—`})]}),(0,G.jsx)(Y.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,G.jsx)(ao,{size:16})})]}),(0,G.jsxs)(Y.Body,{className:`space-y-5 px-5 pb-5`,children:[(0,G.jsx)(`dl`,{className:`grid gap-3 sm:grid-cols-2`,children:[[e(`logsColTime`),_e?B9(_e.time,t):`—`],[e(`logsRuntimeLevel`),_e?.level||`—`],[e(`logsRuntimeSource`),_e?.source||`—`],[e(`logsColAccount`),_e?.account_id||`—`]].map(([t,n])=>(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{className:`text-caption text-muted`,children:t}),(0,G.jsx)(`dd`,{className:`mt-1 break-all text-body font-medium`,children:t===e(`logsRuntimeLevel`)&&_e?(0,G.jsx)(aC,{size:`sm`,variant:`soft`,color:ewe(_e.level),children:_e.level}):n})]},String(t)))}),(0,G.jsxs)(`section`,{className:`space-y-2`,children:[(0,G.jsx)(`div`,{className:`text-xs font-medium text-muted`,children:e(`logsRuntimeMessage`)}),(0,G.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:_e?.message||`—`})]})]})]})})})}),(0,G.jsx)(Y.Root,{isOpen:Ce,onOpenChange:e=>{we(e),e||(ke.current+=1,Ee(!1),Oe(``),Se(null))},children:(0,G.jsx)(Y.Backdrop,{variant:`blur`,children:(0,G.jsx)(Y.Container,{size:`lg`,scroll:`inside`,children:(0,G.jsxs)(Y.Dialog,{className:`w-full max-w-4xl`,children:[(0,G.jsxs)(Y.Header,{className:`items-start justify-between gap-4 px-5 pt-5`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(Y.Heading,{className:`text-section font-semibold`,children:e(`logsDetailTitle`)}),(0,G.jsx)(`p`,{className:`mono mt-1 text-caption text-muted`,children:xe?.id})]}),(0,G.jsx)(Y.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,G.jsx)(ao,{size:16})})]}),(0,G.jsx)(Y.Body,{className:`space-y-4 px-5 pb-5`,children:Te?(0,G.jsx)(twe,{}):De?(0,G.jsx)(QI,{title:e(`requestFailed`),description:De}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`dl`,{className:`grid gap-3 sm:grid-cols-2`,children:[[[e(`logsColStatus`),xe?.status||`—`],[e(`logsColModel`),xe?.requested_model||`—`],[e(`logsColReasoning`),xe&&V9(xe)||`—`],[e(`logsColProvider`),xe?ze(xe):`—`],[e(`logsColAccount`),xe?.account_id?Le.get(xe.account_id)||xe.account_id:`—`],[e(`logsColApiKey`),xe?We(xe):`—`],[e(`logsColStream`),xe?.stream?e(`logsStreamYes`):e(`logsStreamNo`)],[e(`logsRouting`),xe?Be(xe.routing):`—`]].map(([e,t])=>(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{className:`text-caption text-muted`,children:e}),(0,G.jsx)(`dd`,{className:`mt-1 break-all text-body font-medium`,children:t})]},String(e))),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{className:`text-caption text-muted`,children:e(`logsColTokens`)}),(0,G.jsx)(`dd`,{className:`mt-1`,children:xe?(0,G.jsx)(H9,{log:xe,inLabel:e(`logsTokensIn`),outLabel:e(`logsTokensOut`),pointsLabel:t=>e(`logsTokensPoints`,{value:t})}):`—`})]}),(0,G.jsx)(`div`,{className:`sm:col-span-2`,children:(0,G.jsx)(n9,{latencyMs:xe?.latency_ms,ttfbMs:xe?.ttfb_ms,completionTokens:xe?.completion_tokens,stream:xe?.stream,labels:{heading:e(`logsColLatency`),ttft:e(`logsColTTFT`),total:e(`logsLatencyTotal`),tps:e(`logsOutputTPS`)}})})]}),xe&&xe.message_count?(0,G.jsxs)(`div`,{className:`rounded-lg bg-surface-secondary px-3 py-3 text-xs`,children:[(0,G.jsx)(`div`,{className:`font-medium text-muted`,children:e(`logsMessageShape`)}),(0,G.jsxs)(`dl`,{className:`mt-2 grid gap-2 sm:grid-cols-2`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{className:`text-caption text-muted`,children:e(`logsMessageCount`)}),(0,G.jsx)(`dd`,{className:`mono mt-0.5`,children:xe.message_count})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{className:`text-caption text-muted`,children:e(`logsEmptyMessageIndexes`)}),(0,G.jsx)(`dd`,{className:`mono mt-0.5 break-all`,children:xe.empty_message_indexes?.length?xe.empty_message_indexes.join(`, `):`—`})]}),(0,G.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,G.jsx)(`dt`,{className:`text-caption text-muted`,children:e(`logsMessageRoles`)}),(0,G.jsx)(`dd`,{className:`mono mt-0.5 break-all`,children:xe.message_roles?.join(` → `)||`—`})]})]})]}):null,xe?.error_message?(0,G.jsxs)(`div`,{className:`rounded-lg bg-surface-secondary px-3 py-2 text-xs leading-5 text-muted`,children:[xe.error_kind?(0,G.jsx)(`span`,{className:`mono mr-2 text-muted`,children:xe.error_kind}):null,xe.error_message]}):null,xe?.stream_diagnostic?(0,G.jsxs)(`div`,{className:`rounded-lg bg-surface-secondary px-3 py-3 text-xs`,children:[(0,G.jsx)(`div`,{className:`font-medium text-muted`,children:e(`logsStreamDiagnostics`)}),(0,G.jsx)(`dl`,{className:`mt-2 grid gap-2 sm:grid-cols-2`,children:[[e(`logsCancellationSource`),xe.stream_diagnostic.cancellation_source||`—`],[e(`logsUpstreamStatus`),xe.stream_diagnostic.upstream_status??`—`],[e(`logsSSEEvents`),xe.stream_diagnostic.sse_event_count],[e(`logsBytesRead`),xe.stream_diagnostic.bytes_read],[e(`logsLastEvent`),xe.stream_diagnostic.last_event||`—`],[e(`logsStreamComplete`),xe.stream_diagnostic.saw_done?`yes`:`no`]].map(([e,t])=>(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{className:`text-caption text-muted`,children:e}),(0,G.jsx)(`dd`,{className:`mono mt-0.5 break-all`,children:t})]},String(e)))}),xe.stream_diagnostic.context_err||xe.stream_diagnostic.relay_error?(0,G.jsxs)(`div`,{className:`mt-2 space-y-1 break-all text-muted`,children:[xe.stream_diagnostic.context_err?(0,G.jsxs)(`div`,{children:[`context: `,xe.stream_diagnostic.context_err]}):null,xe.stream_diagnostic.relay_error?(0,G.jsxs)(`div`,{children:[`relay: `,xe.stream_diagnostic.relay_error]}):null]}):null]}):null,xe?.usage_detail?(0,G.jsxs)(`div`,{className:`rounded-lg bg-surface-secondary px-3 py-3 text-xs`,children:[(0,G.jsx)(`div`,{className:`font-medium text-muted`,children:e(`logsUsageDetail`)}),(0,G.jsx)(`dl`,{className:`mt-2 grid gap-2 sm:grid-cols-2`,children:[[e(`logsCreditConsumed`),`${U9(xe.usage_detail.credit)} ${xe.usage_detail.unit||`credits`}`],[e(`logsColProvider`),xe.usage_detail.provider||`—`]].map(([e,t])=>(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{className:`text-caption text-muted`,children:e}),(0,G.jsx)(`dd`,{className:`mono mt-0.5 break-all`,children:t})]},String(e)))})]}):null,(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`text-xs font-medium text-muted`,children:e(`logsAttempts`)}),xe?.attempts?.length?(0,G.jsx)(`div`,{className:`mt-2 divide-y divide-separator overflow-hidden rounded-lg bg-surface-secondary`,children:xe.attempts.map(e=>(0,G.jsxs)(`div`,{className:`grid gap-1 px-3 py-2.5 text-xs sm:grid-cols-[48px_minmax(0,1fr)_auto]`,children:[(0,G.jsxs)(`div`,{className:`mono text-muted`,children:[`#`,e.attempt_index]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`font-medium`,children:e.account_id||`—`}),(0,G.jsx)(`div`,{className:`mt-0.5 text-muted`,children:e.error_message||e.status})]}),(0,G.jsx)(aC,{size:`sm`,variant:`soft`,color:z9(e.status===`failover`?`canceled`:e.status),children:e.status})]},e.id))}):(0,G.jsx)(`p`,{className:`mt-2 text-xs text-muted`,children:e(`logsNoAttempts`)})]})]})})]})})})}),(0,G.jsx)(E9,{isOpen:Ae,title:e(`logsClear`),description:e(`logsClearConfirm`),confirmLabel:e(`logsClear`),cancelLabel:e(`close`),closeLabel:e(`close`),isPending:Me,onClose:()=>je(!1),onConfirm:()=>void gt()})]})}var G9=864e5,cwe=8;function K9(e){return`var(--chart-${e%cwe+1})`}function q9(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime()}function J9(e){return e<10?`0${e}`:String(e)}function Y9(e){let t=new Date(e);return`${t.getFullYear()}-${J9(t.getMonth()+1)}-${J9(t.getDate())}`}function lwe({accounts:e,t}){let[n,r]=(0,v.useState)(!1),{buckets:i,rows:a,todayStart:o,maxTotal:s}=(0,v.useMemo)(()=>{let t=q9(new Date),n=new Map;e.forEach((e,t)=>n.set(e.id,K9(t)));let r=new Map,i=[];for(let a of e){let e=a.quota?.packages??[],o=n.get(a.id)||K9(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=q9(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=Y9(q9(new Date(l)));for(let t of c)Y9(q9(new Date(t.ends_at*1e3)))===e&&(u+=t.remain??0)}let p=l?Math.max(0,Math.round((q9(new Date(l))-t)/G9)):-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(!a.some(e=>e.packs>0))return null;let c=n?i:i.slice(0,8);return(0,G.jsxs)(HS,{className:`overflow-hidden p-0`,"data-gsap-reveal":!0,children:[(0,G.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,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`h3`,{className:`font-semibold`,children:t(`expiryDistTitle`)}),(0,G.jsx)(`p`,{className:`mt-0.5 text-xs text-muted`,children:t(`expiryDistHint`)})]}),i.length>8?(0,G.jsx)(J,{size:`sm`,variant:`ghost`,onPress:()=>r(e=>!e),children:n?t(`expiryDistCollapse`):t(`expiryDistExpand`,{n:i.length})}):null]}),(0,G.jsxs)(`div`,{className:`space-y-4 p-4 sm:space-y-3 sm:p-5`,children:[(0,G.jsx)(`div`,{className:`space-y-2.5 sm:space-y-1.5`,children:c.map(e=>{let n=e.ts===o,r=s>0?e.total/s*100:0;return(0,G.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,G.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 sm:contents`,children:[(0,G.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,G.jsx)(`span`,{className:`mono text-caption text-foreground sm:hidden`,children:m9(e.total)})]}),(0,G.jsx)(`div`,{className:`h-2.5 w-full rounded-full bg-surface-tertiary`,role:`img`,"aria-label":`${e.day} ${t(`expiryDistDayTotal`,{n:m9(e.total)})}`,title:e.day,children:(0,G.jsx)(`div`,{className:`flex h-full items-stretch overflow-hidden rounded-full`,style:{width:`${r}%`},children:e.segments.map(t=>(0,G.jsx)(`span`,{style:{width:`${t.remain/e.total*100}%`,backgroundColor:t.color},title:`${t.name} · ${m9(t.remain)}`},t.id))})}),(0,G.jsx)(`span`,{className:`mono hidden text-caption text-foreground sm:inline`,children:m9(e.total)})]},e.day)})}),(0,G.jsx)(`div`,{className:`flex flex-wrap gap-x-3 gap-y-1.5 pt-1`,children:a.filter(e=>e.remain>0).map(e=>(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-caption text-muted`,children:[(0,G.jsx)(`i`,{className:`size-2 rounded-[3px]`,style:{backgroundColor:e.color}}),(0,G.jsx)(`span`,{className:`max-w-[120px] truncate`,children:e.name})]},e.id))}),(0,G.jsx)(`div`,{className:`divide-y divide-separator md:hidden`,children:a.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,G.jsxs)(`article`,{className:`space-y-3 py-3.5`,children:[(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,G.jsx)(`i`,{className:`size-2 shrink-0 rounded-[3px]`,style:{backgroundColor:e.color}}),(0,G.jsx)(`span`,{className:`truncate text-body font-medium text-foreground`,children:e.name})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-4 gap-y-3`,children:[(0,G.jsxs)(`div`,{className:`space-y-1`,children:[(0,G.jsx)(`div`,{className:`text-caption text-muted`,children:t(`expiryDistColSoonest`)}),(0,G.jsx)(`div`,{className:`mono text-body text-muted`,children:i?`${i.getMonth()+1}/${i.getDate()}`:`—`})]}),(0,G.jsxs)(`div`,{className:`space-y-1`,children:[(0,G.jsx)(`div`,{className:`text-caption text-muted`,children:t(`expiryDistColDaysLeft`)}),(0,G.jsx)(`div`,{className:`mono text-body ${a}`,children:o})]}),(0,G.jsxs)(`div`,{className:`space-y-1`,children:[(0,G.jsx)(`div`,{className:`text-caption text-muted`,children:t(`expiryDistColBatch`)}),(0,G.jsx)(`div`,{className:`mono text-body text-foreground`,children:m9(e.soonestRemain)})]}),(0,G.jsxs)(`div`,{className:`space-y-1`,children:[(0,G.jsx)(`div`,{className:`text-caption text-muted`,children:t(`expiryDistColDaily`)}),(0,G.jsx)(`div`,{className:`mono text-body text-foreground`,children:e.soonest?m9(e.dailyBurn):`—`})]})]})]},e.id)})}),(0,G.jsx)(X,{"aria-label":t(`expiryDistTitle`),className:`hidden md:block`,children:(0,G.jsx)(X.ScrollContainer,{className:`min-w-0 overflow-x-auto`,children:(0,G.jsxs)(X.Content,{className:`min-w-[32rem]`,children:[(0,G.jsxs)(X.Header,{children:[(0,G.jsx)(X.Column,{isRowHeader:!0,children:t(`expiryDistColAccount`)}),(0,G.jsx)(X.Column,{children:(0,G.jsx)(`div`,{className:`text-center`,children:t(`expiryDistColSoonest`)})}),(0,G.jsx)(X.Column,{children:(0,G.jsx)(`div`,{className:`text-center`,children:t(`expiryDistColDaysLeft`)})}),(0,G.jsx)(X.Column,{children:(0,G.jsx)(`div`,{className:`text-center`,children:t(`expiryDistColBatch`)})}),(0,G.jsx)(X.Column,{children:(0,G.jsx)(`div`,{className:`text-center`,children:t(`expiryDistColDaily`)})})]}),(0,G.jsx)(X.Body,{children:a.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,G.jsxs)(X.Row,{children:[(0,G.jsx)(X.Cell,{children:(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,G.jsx)(`i`,{className:`size-2 shrink-0 rounded-[3px]`,style:{backgroundColor:e.color}}),(0,G.jsx)(`span`,{className:`max-w-[150px] truncate text-foreground`,children:e.name})]})}),(0,G.jsx)(X.Cell,{children:(0,G.jsx)(`div`,{className:`mono text-center text-muted`,children:i?`${i.getMonth()+1}/${i.getDate()}`:`—`})}),(0,G.jsx)(X.Cell,{children:(0,G.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,G.jsx)(X.Cell,{children:(0,G.jsx)(`div`,{className:`mono text-center text-foreground`,children:m9(e.soonestRemain)})}),(0,G.jsx)(X.Cell,{children:(0,G.jsx)(`div`,{className:`mono text-center text-foreground`,children:e.soonest?m9(e.dailyBurn):`—`})})]},e.id)})})]})})}),(0,G.jsx)(`p`,{className:`text-caption text-muted`,children:t(`expiryDistFoot`)})]})]})}function uwe(){return NI(`/api/usage/pricing`)}function dwe(e={}){let t=new URLSearchParams;return e.from&&t.set(`from`,e.from),e.to&&t.set(`to`,e.to),e.api_key&&t.set(`api_key`,e.api_key),NI(`/api/usage/cost${t.toString()?`?${t}`:``}`)}var X9=(0,v.lazy)(()=>C(()=>import(`./CostChart-PEvxXQD1.js`).then(e=>({default:e.CostChart})),__vite__mapDeps([2,1])));function fwe(){let e=new Date;return e.setHours(0,0,0,0),e.toISOString()}var pwe={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 mwe(e,t){if(!t)return`0%`;let n=e/t*100;return`${n>=10?n.toFixed(0):n.toFixed(1)}%`}function hwe({apiKeyFilter:e=``}){let{t,lang:n}=EI(),[r,i]=(0,v.useState)(`today`),[a,o]=(0,v.useState)(`credits`),[s,c]=(0,v.useState)(null),[l,u]=(0,v.useState)(null),[d,f]=(0,v.useState)(!0),[p,m]=(0,v.useState)(``);(0,v.useEffect)(()=>{let e=!1;return uwe().then(t=>{e||u(t)}).catch(()=>{}),()=>{e=!0}},[]);let h=(0,v.useCallback)(async()=>{f(!0);try{let t=await dwe({...r===`all`?{}:r===`today`?{from:fwe()}:{from:new Date(Date.now()-Number(r)*3600*1e3).toISOString(),to:new Date().toISOString()},api_key:e||void 0});c(t),m(``)}catch(e){c(null),m(e instanceof Error?e.message:String(e))}finally{f(!1)}},[r,e]);(0,v.useEffect)(()=>{h()},[h]);let g=s??pwe,_=g.totals,y=_.requests>0&&g.models.length>0,b=g.models.filter(e=>e.priced),x=_.cost>0,S=[{label:t(`usageCredits`),value:cH(_.credits),detail:t(`usageCreditsHint`)},{label:t(`usageTotalTokens`),value:$V(_.total_tokens),detail:`${$V(_.cache_hit)} / ${$V(_.cache_miss)} / ${$V(_.output)} ${t(`usageTokenSplitNote`)}`},{label:t(`usageRequests`),value:String(_.requests),detail:t(`usageModelCount`,{count:g.models.length})},{label:t(`usageCacheHitRate`),value:mwe(_.cache_hit,_.cache_hit+_.cache_miss),detail:$V(_.cache_hit)}],C=a===`credits`?cH(_.credits):a===`tokens`?$V(_.total_tokens):oH(_.cost);return(0,G.jsxs)(`div`,{className:`space-y-6`,children:[(0,G.jsxs)(`section`,{className:`flex flex-wrap items-center justify-end gap-3 pb-2`,children:[(0,G.jsx)(pH,{value:r,onChange:e=>i(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,G.jsxs)(J,{size:`sm`,variant:`secondary`,onPress:()=>void h(),isDisabled:d,children:[(0,G.jsx)(qr,{size:14}),t(`refresh`)]})]}),p?(0,G.jsx)(QI,{title:t(`failedStats`,{msg:p})}):null,(0,G.jsx)(`section`,{className:`grid gap-3 sm:grid-cols-2 sm:gap-4 xl:grid-cols-4`,children:S.map(e=>(0,G.jsxs)(HS,{className:`gap-0 p-4`,children:[(0,G.jsx)(`div`,{className:`text-body text-muted`,children:e.label}),(0,G.jsx)(`div`,{className:`tabular mt-1.5 text-section font-semibold`,children:d?(0,G.jsx)(Q,{className:`h-5 w-16`}):e.value}),(0,G.jsx)(`div`,{className:`mono mt-1 truncate text-caption text-muted`,children:d?(0,G.jsx)(Q,{className:`h-3 w-24`}):e.detail||`\xA0`})]},e.label))}),(0,G.jsxs)(HS,{className:`overflow-hidden p-0`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 border-b border-separator px-5 py-4`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`font-semibold tracking-[-0.015em]`,children:t(`usageChartTitle`)}),(0,G.jsx)(`p`,{className:`mt-0.5 text-xs text-muted`,children:t(`usageChartHint`)})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,G.jsx)(pH,{value:a,onChange:e=>o(e),ariaLabel:t(`usageChartMetric`),options:[{id:`credits`,label:t(`usageColCredits`)},{id:`tokens`,label:t(`usageColTokens`)}]}),(0,G.jsx)(aC,{size:`sm`,variant:`soft`,color:`default`,children:C})]})]}),(0,G.jsx)(`div`,{className:`p-5`,children:d?(0,G.jsx)(`div`,{className:`grid h-72 place-items-center`,children:(0,G.jsx)(Q,{className:`h-56 w-full`})}):y?(0,G.jsx)(v.Suspense,{fallback:(0,G.jsx)(`div`,{className:`grid h-72 place-items-center`,children:(0,G.jsx)(Q,{className:`h-56 w-full`})}),children:(0,G.jsx)(X9,{series:g.series,models:g.models,lang:n,emptyLabel:t(`usageChartEmpty`),totalLabel:t(`usageTotals`),metric:a})}):(0,G.jsx)(I7,{title:t(`usageEmpty`),hint:t(`usageRetentionHint`)})})]}),(0,G.jsxs)(HS,{className:`overflow-hidden p-0`,children:[(0,G.jsx)(`div`,{className:`flex items-center justify-between gap-3 border-b border-separator px-5 py-4`,children:(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h3`,{className:`font-semibold tracking-[-0.015em]`,children:t(`usageBreakdownTitle`)}),(0,G.jsx)(`p`,{className:`mt-0.5 text-xs text-muted`,children:t(`usageBreakdownHint`)})]})}),d?(0,G.jsx)(`div`,{className:`space-y-3 p-5`,children:[0,1,2].map(e=>(0,G.jsx)(Q,{className:`h-9 w-full`},e))}):y?(0,G.jsx)(X,{children:(0,G.jsx)(X.ScrollContainer,{children:(0,G.jsxs)(X.Content,{"aria-label":t(`usageBreakdownTitle`),children:[(0,G.jsxs)(X.Header,{children:[(0,G.jsx)(X.Column,{isRowHeader:!0,children:t(`usageColModel`)}),(0,G.jsx)(X.Column,{children:t(`usageColRequests`)}),(0,G.jsx)(X.Column,{children:t(`usageColInputHit`)}),(0,G.jsx)(X.Column,{children:t(`usageColInputMiss`)}),(0,G.jsx)(X.Column,{children:t(`usageColOutput`)}),(0,G.jsx)(X.Column,{children:t(`usageColTokens`)}),(0,G.jsx)(X.Column,{children:t(`usageColCredits`)})]}),(0,G.jsxs)(X.Body,{children:[g.models.map(e=>(0,G.jsxs)(X.Row,{children:[(0,G.jsxs)(X.Cell,{children:[(0,G.jsx)(`div`,{className:`text-sm font-medium`,children:e.label}),(0,G.jsx)(`div`,{className:`mono mt-0.5 text-[10px] text-muted`,children:e.id})]}),(0,G.jsx)(X.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-xs`,children:e.requests})}),(0,G.jsx)(X.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-xs`,children:$V(e.cache_hit)})}),(0,G.jsx)(X.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-xs`,children:$V(e.cache_miss)})}),(0,G.jsx)(X.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-xs`,children:$V(e.output)})}),(0,G.jsx)(X.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-xs`,children:$V(e.total_tokens)})}),(0,G.jsx)(X.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-xs font-semibold`,children:cH(e.credits)})})]},e.id)),(0,G.jsxs)(X.Row,{children:[(0,G.jsx)(X.Cell,{children:(0,G.jsx)(`span`,{className:`text-sm font-semibold`,children:t(`usageTotals`)})}),(0,G.jsx)(X.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-xs font-semibold`,children:_.requests})}),(0,G.jsx)(X.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-xs font-semibold`,children:$V(_.cache_hit)})}),(0,G.jsx)(X.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-xs font-semibold`,children:$V(_.cache_miss)})}),(0,G.jsx)(X.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-xs font-semibold`,children:$V(_.output)})}),(0,G.jsx)(X.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-xs font-semibold`,children:$V(_.total_tokens)})}),(0,G.jsx)(X.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-xs font-semibold`,children:cH(_.credits)})})]})]})]})})}):(0,G.jsx)(I7,{title:t(`usageEmpty`),hint:t(`usageRetentionHint`)})]}),(0,G.jsx)(vh,{className:`rounded-xl bg-surface-secondary`,hideSeparator:!0,defaultExpandedKeys:[],children:(0,G.jsxs)(vh.Item,{id:`deepseek-estimate`,children:[(0,G.jsx)(vh.Heading,{children:(0,G.jsxs)(vh.Trigger,{className:`items-center gap-3 px-5 py-4 text-left`,children:[(0,G.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`span`,{className:`block font-semibold tracking-[-0.015em]`,children:t(`usageEstimateTitle`)}),(0,G.jsx)(`span`,{className:`mt-0.5 block text-xs text-muted`,children:t(`usageEstimateHint`)})]}),x?(0,G.jsx)(aC,{size:`sm`,variant:`soft`,color:`default`,children:oH(_.cost)}):null,(0,G.jsx)(vh.Indicator,{})]})}),(0,G.jsx)(vh.Panel,{children:(0,G.jsxs)(vh.Body,{className:`space-y-5 px-5 pb-5`,children:[(0,G.jsx)(`p`,{className:`text-xs leading-6 text-muted`,children:t(`usageRenderNote`)}),x?(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,G.jsx)(`h4`,{className:`text-sm font-medium`,children:t(`usageEstimateChartTitle`)}),(0,G.jsx)(aC,{size:`sm`,variant:`soft`,color:`default`,children:oH(_.cost)})]}),(0,G.jsx)(v.Suspense,{fallback:(0,G.jsx)(Q,{className:`h-56 w-full`}),children:(0,G.jsx)(X9,{series:g.series,models:b.length?b:g.models,lang:n,emptyLabel:t(`usageEstimateChartEmpty`),totalLabel:t(`usageTotals`),metric:`cost`})})]}):null,b.length?(0,G.jsx)(X,{children:(0,G.jsx)(X.ScrollContainer,{children:(0,G.jsxs)(X.Content,{"aria-label":t(`usageEstimateTitle`),children:[(0,G.jsxs)(X.Header,{children:[(0,G.jsx)(X.Column,{isRowHeader:!0,children:t(`usageColModel`)}),(0,G.jsx)(X.Column,{children:t(`usageColSplit`)}),(0,G.jsx)(X.Column,{children:t(`usageColCost`)})]}),(0,G.jsxs)(X.Body,{children:[b.map(e=>(0,G.jsxs)(X.Row,{children:[(0,G.jsxs)(X.Cell,{children:[(0,G.jsx)(`div`,{className:`text-sm font-medium`,children:e.label}),(0,G.jsx)(`div`,{className:`mono mt-0.5 text-[10px] text-muted`,children:e.id})]}),(0,G.jsx)(X.Cell,{children:(0,G.jsxs)(`span`,{className:`mono text-xs text-muted`,children:[oH(e.cost_peak),` / `,oH(e.cost_off_peak)]})}),(0,G.jsx)(X.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-sm font-semibold`,children:oH(e.cost)})})]},e.id)),(0,G.jsxs)(X.Row,{children:[(0,G.jsx)(X.Cell,{children:(0,G.jsx)(`span`,{className:`text-sm font-semibold`,children:t(`usageTotals`)})}),(0,G.jsx)(X.Cell,{children:(0,G.jsxs)(`span`,{className:`mono text-xs text-muted`,children:[oH(_.cost_peak),` / `,oH(_.cost_off_peak)]})}),(0,G.jsx)(X.Cell,{children:(0,G.jsx)(`span`,{className:`mono text-sm font-semibold`,children:oH(_.cost)})})]})]})]})})}):(0,G.jsx)(`p`,{className:`text-xs text-muted`,children:t(`usageEstimateChartEmpty`)}),(0,G.jsxs)(`div`,{className:`grid gap-5 xl:grid-cols-[minmax(0,1fr)_minmax(0,1fr)]`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h4`,{className:`mb-2 text-sm font-medium`,children:t(`usagePriceTitle`)}),(0,G.jsx)(`p`,{className:`mb-3 text-xs text-muted`,children:t(`usagePeakNote`)}),(0,G.jsxs)(`div`,{className:`divide-y divide-separator rounded-lg bg-background`,children:[(l?.models??[]).map(e=>(0,G.jsxs)(`div`,{className:`px-4 py-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,G.jsx)(`div`,{className:`text-sm font-medium`,children:e.label}),(0,G.jsx)(`span`,{className:`mono text-[10px] text-muted`,children:e.currency})]}),(0,G.jsx)(`div`,{className:`mono mt-1 text-[10px] text-muted`,children:e.id}),(0,G.jsxs)(`div`,{className:`mt-2 grid grid-cols-2 gap-2 text-[11px]`,children:[(0,G.jsxs)(`div`,{className:`rounded-lg bg-surface-secondary px-2.5 py-2`,children:[(0,G.jsx)(`div`,{className:`text-[10px] text-muted`,children:t(`usagePriceBandOff`)}),(0,G.jsxs)(`div`,{className:`mono mt-0.5`,children:[sH(e.off_peak.cache_hit),` · `,sH(e.off_peak.cache_miss),` · `,sH(e.off_peak.output)]}),(0,G.jsxs)(`div`,{className:`mt-1 text-[9px] text-muted`,children:[t(`usagePriceHit`),` · `,t(`usagePriceMiss`),` · `,t(`usagePriceOutput`)]})]}),(0,G.jsxs)(`div`,{className:`rounded-lg bg-surface-secondary px-2.5 py-2`,children:[(0,G.jsx)(`div`,{className:`text-[10px] text-muted`,children:t(`usagePriceBandPeak`)}),(0,G.jsxs)(`div`,{className:`mono mt-0.5`,children:[sH(e.peak.cache_hit),` · `,sH(e.peak.cache_miss),` · `,sH(e.peak.output)]}),(0,G.jsxs)(`div`,{className:`mt-1 text-[9px] text-muted`,children:[t(`usagePriceHit`),` · `,t(`usagePriceMiss`),` · `,t(`usagePriceOutput`)]})]})]})]},e.id)),l?.models?.length?null:(0,G.jsx)(`div`,{className:`px-4 py-6 text-sm text-muted`,children:t(`usageEmpty`)})]})]}),(0,G.jsxs)(`div`,{className:`space-y-3 text-xs leading-6 text-muted`,children:[(0,G.jsx)(`h4`,{className:`text-sm font-medium text-foreground`,children:t(`usageNoteTitle`)}),(0,G.jsx)(`p`,{children:t(`usageRetentionHint`)}),(0,G.jsx)(`p`,{children:t(`usagePeakNote`)}),g.unpriced?.length?(0,G.jsx)(`p`,{children:t(`usageUnpricedHint`,{models:g.unpriced.join(`, `)})}):null,l?.note?(0,G.jsx)(`p`,{className:`mono text-[10px]`,children:l.note}):null]})]})]})})]})})]})}var gwe=500,_we={model:`model`,account:`account`,provider:`provider`};function vwe(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:{[_we[t]]:e.key}}}function ywe(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 Z9(e){return e?e>=1e3?$V(e):String(Math.round(e*100)/100):`0`}function bwe(){let{t:e}=EI(),t=at(),[n,r]=On(),[i,a]=(0,v.useState)(`stats`),[o,s]=(0,v.useState)(`model`),[c,l]=(0,v.useState)(`today`),[u,d]=(0,v.useState)(null),[f,p]=(0,v.useState)(null),[m,h]=(0,v.useState)(!0),[g,_]=(0,v.useState)(``),[y,b]=(0,v.useState)([]),[x,S]=(0,v.useState)(`count`),[C,w]=(0,v.useState)(`descending`),[T,E]=(0,v.useState)(()=>new URLSearchParams(window.location.search).get(`api_key`)??``),{options:D}=R9(),O=(0,v.useRef)(0),k=n.toString(),A=(0,v.useRef)(k);(0,v.useEffect)(()=>{k!==A.current&&(A.current=k,E(new URLSearchParams(k).get(`api_key`)??``))},[k]);let j=T?`api_key=${encodeURIComponent(T)}`:``;(0,v.useEffect)(()=>{j!==A.current&&(A.current=j,r(j,{replace:!0}))},[j,r]),(0,v.useEffect)(()=>{let e=!1;return PI(!1).then(t=>{e||b(t.data||[])}).catch(()=>{}),()=>{e=!0}},[]);let M=u?.start?.toString()??``,N=u?.end?.toString()??``;(0,v.useEffect)(()=>{let e=vH(c,u);if(!e){h(!1);return}let t=++O.current;ZV({...e,dim:[o],limit:gwe,api_key:T||void 0}).then(e=>{t===O.current&&(p(e),_(``))}).catch(e=>{t===O.current&&(p(null),_(e instanceof Error?e.message:String(e)))}).finally(()=>{t===O.current&&h(!1)})},[o,c,M,N,T]);let P=(0,v.useMemo)(()=>{let t=new Map(y.map(e=>[e.id,e.name||e.id]));return ywe(((o===`model`?f?.models:o===`account`?f?.accounts:f?.providers)??[]).map(n=>{let r=n.key===`(unknown)`?e(`statsUnknown`):n.key===`(unassigned)`?e(`statsUnassigned`):o===`account`?t.get(n.key)||n.key:o===`provider`?AH(n.key,e):n.key;return vwe(n,o,r)}),x,C)},[f,o,y,x,C,e]),F=f?.totals,I=f?.tokens;function L(e){if(!f||!e.filter)return;let n={...e.filter,api_key:T||void 0};t(bH(n,f.window.from,f.window.to))}let R=[{id:`label`,label:e(o===`model`?`logsColModel`:o===`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}],z=(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`section`,{className:`flex flex-wrap items-center justify-end gap-3 pb-1`,children:(0,G.jsx)(yH,{value:c,onChange:l,custom:u,onCustomChange:d,onBusy:()=>h(!0),t:e})}),g?(0,G.jsx)(QI,{title:e(`failedStats`,{msg:g})}):null,(0,G.jsx)(`section`,{className:`grid gap-3 sm:grid-cols-2 sm:gap-4 xl:grid-cols-5`,children:[[e(`usageColRequests`),F?$V(F.requests):`—`,e(`statsWindowHint`,{window:e(_H[c])})],[e(`usageColSuccess`),F?nH(F.success_rate):`—`,F?`${F.ok} / ${F.requests}`:``],[e(`usageColTokens`),I?$V(I.total):`—`,I?`${$V(I.prompt)} / ${$V(I.completion)}`:``],[e(`usageColCacheWrite`),I?$V(I.cache_write??0):`—`,I?`${e(`chartCacheRead`)} ${$V(I.cache_read)}`:``],[e(`usageColCredits`),F?Z9(F.credits??0):`—`,``]].map(([e,t,n])=>(0,G.jsxs)(HS,{className:`gap-0 p-4`,children:[(0,G.jsx)(`div`,{className:`text-body text-muted`,children:e}),(0,G.jsx)(`div`,{className:`tabular mt-1.5 text-section font-semibold`,children:m?(0,G.jsx)(Q,{className:`h-5 w-16`}):t}),(0,G.jsx)(`div`,{className:`mono mt-1 truncate text-caption text-muted`,children:m?(0,G.jsx)(Q,{className:`h-3 w-24`}):n||`\xA0`})]},e))}),(0,G.jsxs)(HS,{className:`overflow-hidden p-0`,children:[(0,G.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,G.jsx)(_j,{selectedKey:o,onSelectionChange:e=>{h(!0),s(String(e))},children:(0,G.jsx)(_j.ListContainer,{className:`w-fit`,children:(0,G.jsxs)(_j.List,{"aria-label":e(`usageTitle`),children:[(0,G.jsxs)(gj,{id:`model`,className:`gap-1.5 whitespace-nowrap`,children:[(0,G.jsx)(_j.Indicator,{className:`transition-none`}),(0,G.jsx)(ji,{size:14}),e(`usageByModel`)]}),(0,G.jsxs)(gj,{id:`account`,className:`gap-1.5 whitespace-nowrap`,children:[(0,G.jsx)(_j.Indicator,{className:`transition-none`}),(0,G.jsx)(to,{size:14}),e(`usageByAccount`)]}),(0,G.jsxs)(gj,{id:`provider`,className:`gap-1.5 whitespace-nowrap`,children:[(0,G.jsx)(_j.Indicator,{className:`transition-none`}),(0,G.jsx)(za,{size:14}),e(`usageByProvider`)]})]})})}),(0,G.jsx)(`span`,{className:`mono text-caption text-muted`,children:m?``:e(`usageRowCount`,{count:P.length})})]}),m?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`divide-y divide-separator md:hidden`,"aria-busy":`true`,children:Array.from({length:4},(e,t)=>(0,G.jsxs)(`div`,{className:`space-y-3 px-5 py-4`,children:[(0,G.jsx)(Q,{className:`h-4 w-40`}),(0,G.jsx)(`div`,{className:`grid grid-cols-2 gap-x-4 gap-y-3`,children:Array.from({length:4},(e,t)=>(0,G.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,G.jsx)(Q,{className:`h-3 w-12`}),(0,G.jsx)(Q,{className:`h-4 w-16`})]},t))})]},t))}),(0,G.jsx)(`div`,{className:`hidden divide-y divide-separator md:block`,"aria-busy":`true`,children:Array.from({length:6},(e,t)=>(0,G.jsxs)(`div`,{className:`flex items-center gap-6 px-5 py-3.5`,children:[(0,G.jsx)(Q,{className:`h-4 w-40`}),(0,G.jsx)(`div`,{className:`flex-1`}),Array.from({length:6},(e,t)=>(0,G.jsx)(Q,{className:`h-4 w-14`},t))]},t))})]}):P.length===0?(0,G.jsxs)(`div`,{className:`flex items-center gap-2 px-5 py-10 text-body text-muted`,children:[(0,G.jsx)(pi,{size:16}),e(`usageEmpty`)]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`divide-y divide-separator md:hidden`,children:P.map(t=>{let n=!!(t.filter&&f),r=[{label:e(`usageColRequests`),value:String(t.count)},{label:e(`usageColSuccess`),value:nH(t.success),tone:t.success<.9?`text-warning`:void 0},{label:e(`statsLatencyP95`),value:eH(t.p95)},{label:e(`usageColTokens`),value:$V(t.tokens),sub:`${$V(t.prompt)} / ${$V(t.completion)}`},{label:e(`usageColCacheWrite`),value:$V(t.cache_write)},{label:e(`usageColCredits`),value:Z9(t.credits)}];return(0,G.jsxs)(`article`,{className:`space-y-3 px-5 py-4 ${n?`cursor-pointer`:``}`,onClick:n?()=>L(t):void 0,onKeyDown:n?e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),L(t))}:void 0,role:n?`button`:void 0,tabIndex:n?0:void 0,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[o===`provider`&&t.filter?(0,G.jsx)(MH,{provider:t.key,size:14}):null,(0,G.jsx)(`span`,{className:`truncate text-body font-medium`,children:t.label})]}),o===`account`&&t.label!==t.key?(0,G.jsx)(`div`,{className:`mono truncate text-caption text-muted`,children:t.key}):null,(0,G.jsx)(`div`,{className:`grid grid-cols-2 gap-x-4 gap-y-3`,children:r.map(e=>(0,G.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,G.jsx)(`div`,{className:`text-caption text-muted`,children:e.label}),(0,G.jsx)(`div`,{className:`mono text-body ${e.tone??`text-foreground`}`,children:e.value}),`sub`in e&&e.sub?(0,G.jsx)(`div`,{className:`mono text-caption text-muted`,children:e.sub}):null]},e.label))})]},t.key)})}),(0,G.jsx)(X,{className:`usage-table hidden md:block`,children:(0,G.jsx)(X.ScrollContainer,{className:`min-w-0 overflow-x-auto`,children:(0,G.jsxs)(X.Content,{"aria-label":e(`usageTitle`),className:`min-w-[48rem]`,sortDescriptor:{column:x,direction:C},onSortChange:e=>{S(String(e.column)),w(e.direction)},children:[(0,G.jsx)(X.Header,{children:R.map(e=>(0,G.jsx)(X.Column,{id:e.id,allowsSorting:!0,isRowHeader:e.id===`label`,className:e.numeric?`text-right`:void 0,children:({sortDirection:t})=>(0,G.jsx)(X.SortableColumnHeader,{sortDirection:t,className:e.numeric?`justify-end`:void 0,children:e.label})},e.id))}),(0,G.jsx)(X.Body,{children:P.map(e=>(0,G.jsxs)(X.Row,{id:e.key,className:e.filter&&f?`cursor-pointer`:void 0,onAction:e.filter&&f?()=>L(e):void 0,children:[(0,G.jsx)(X.Cell,{children:(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[o===`provider`&&e.filter?(0,G.jsx)(MH,{provider:e.key,size:14}):null,(0,G.jsx)(`span`,{className:`truncate text-body font-medium`,children:e.label}),o===`account`&&e.label!==e.key?(0,G.jsx)(`span`,{className:`mono truncate text-caption text-muted`,children:e.key}):null]})}),(0,G.jsx)(X.Cell,{className:`mono text-right text-body`,children:e.count}),(0,G.jsx)(X.Cell,{className:`mono text-right text-body`,children:(0,G.jsx)(`span`,{className:e.success<.9?`text-warning`:void 0,children:nH(e.success)})}),(0,G.jsx)(X.Cell,{className:`mono text-right text-body`,children:eH(e.p95)}),(0,G.jsxs)(X.Cell,{className:`text-right`,children:[(0,G.jsx)(`div`,{className:`mono text-body`,children:$V(e.tokens)}),(0,G.jsxs)(`div`,{className:`mono text-caption text-muted`,children:[$V(e.prompt),` / `,$V(e.completion)]})]}),(0,G.jsx)(X.Cell,{className:`mono text-right text-body`,children:$V(e.cache_write)}),(0,G.jsx)(X.Cell,{className:`mono text-right text-body`,children:Z9(e.credits)})]},e.key))})]})})})]})]}),(0,G.jsx)(lwe,{accounts:y,t:e})]});return(0,G.jsxs)(`div`,{className:`space-y-6 sm:space-y-6`,children:[(0,G.jsxs)(`section`,{className:`flex flex-wrap items-end justify-between gap-3 pb-1`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h2`,{className:`text-title font-semibold`,children:e(`usageTitle`)}),(0,G.jsx)(`p`,{className:`mt-1 max-w-2xl text-body leading-6 text-muted`,children:e(i===`cost`?`usageCostLead`:`usageLead`)})]}),(0,G.jsx)(L9,{ariaLabel:e(`logsColApiKey`),value:T,onChange:e=>{h(!0),E(e)},options:D,allLabel:e(`logsFilterApiKeyAll`),searchPlaceholder:e(`logsSearchApiKey`),emptyLabel:e(`logsNoFilterOptions`)})]}),(0,G.jsxs)(_j,{selectedKey:i,onSelectionChange:e=>a(String(e)),children:[(0,G.jsx)(_j.ListContainer,{className:`w-fit`,children:(0,G.jsxs)(_j.List,{"aria-label":e(`usageTitle`),children:[(0,G.jsxs)(gj,{id:`stats`,className:`gap-1.5 whitespace-nowrap`,children:[(0,G.jsx)(_j.Indicator,{className:`transition-none`}),e(`usageStatsTab`)]}),(0,G.jsxs)(gj,{id:`cost`,className:`gap-1.5 whitespace-nowrap`,children:[(0,G.jsx)(_j.Indicator,{className:`transition-none`}),e(`usageCostTab`)]})]})}),(0,G.jsx)(_j.Panel,{id:`stats`,className:`space-y-6 pt-5`,children:z}),(0,G.jsx)(_j.Panel,{id:`cost`,className:`pt-5`,children:(0,G.jsx)(hwe,{apiKeyFilter:T})})]})]})}var xwe=1.1;function Swe({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,G.jsxs)(PM,{delay:300,children:[(0,G.jsx)(PM.Trigger,{children:(0,G.jsxs)(J,{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=Z.to(e,{scaleX:1,duration:xwe*(1-Number(Z.getProperty(e,`scaleX`))),ease:AV.linear,onComplete:()=>{a.current=null,Z.to(e,{scaleX:0,duration:jV()?0:kV.base,ease:AV.out,delay:kV.fast}),t()}}))},onPressEnd:()=>{let e=i.current;!e||!a.current||(a.current.kill(),a.current=null,Z.to(e,{scaleX:0,duration:jV()?0:kV.base,ease:AV.soft}))},children:[(0,G.jsx)(`span`,{ref:i,"aria-hidden":!0,className:`pointer-events-none absolute inset-0 origin-left scale-x-0 bg-danger/20`}),(0,G.jsx)(`span`,{className:`relative inline-flex`,children:r})]})}),(0,G.jsx)(PM.Content,{children:e})]})}function Cwe(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 Q9(e,t){let n=e.indexOf(`:`),r=n===-1?e:e.slice(0,n),i=n===-1?``:e.slice(n+1);return i?jH(r,i,t):AH(r,t)}function wwe(e){let t=e.indexOf(`:`);return t===-1?e:e.slice(0,t)}function Twe(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 Ewe(e,t){return e.length?e.map(e=>Q9(e,t)).join(` · `):t(`keysAllProviders`)}function Dwe(e){if(!e)return``;let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}function Owe(){let{t:e}=EI(),[t,n]=(0,v.useState)([]),[r,i]=(0,v.useState)(!1),[a,o]=(0,v.useState)(``),[s,c]=(0,v.useState)([]),[l,u]=(0,v.useState)(!0),[d,f]=(0,v.useState)(``),[p,m]=(0,v.useState)(``),[h,g]=(0,v.useState)(!1),[_,y]=(0,v.useState)(null),[b,x]=(0,v.useState)(null),[S,C]=(0,v.useState)(!1);(0,v.useEffect)(()=>{UI().then(e=>{let t=Cwe(e.data||[]);n(t),i(t.length>0),o(``)}).catch(e=>{o(e instanceof Error?e.message:String(e))})},[]);async function w(){u(!0);try{let e=await N9();c(e.data||[]),m(``)}catch(e){m(e instanceof Error?e.message:String(e))}finally{u(!1)}}(0,v.useEffect)(()=>{let e=window.setTimeout(()=>void w(),0);return()=>window.clearTimeout(e)},[]);async function T(e){await Z7(e),C(!0),window.setTimeout(()=>C(!1),1200)}async function E(e,t){f(e.id),c(n=>n.map(n=>n.id===e.id?{...n,enabled:t}:n));try{let n=await P9(e.id,{enabled:t});c(t=>t.map(t=>t.id===e.id?{...t,...n,secret:void 0}:t))}catch(e){m(e instanceof Error?e.message:String(e)),await w()}finally{f(``)}}async function D(t){f(t.id);try{await UCe(t.id),c(e=>e.filter(e=>e.id!==t.id)),XV({type:`success`,title:e(`toastKeyDeleted`)})}catch(e){m(e instanceof Error?e.message:String(e))}finally{f(``)}}return l&&!s.length?(0,G.jsx)(Lse,{}):(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)(`h2`,{"data-gsap-reveal":!0,className:`text-title font-semibold`,children:e(`navKeys`)}),(0,G.jsx)(`p`,{className:`mt-1 max-w-2xl text-body leading-6 text-muted`,children:e(`keysLead`)})]}),(0,G.jsxs)(J,{size:`sm`,isDisabled:!r,onPress:()=>g(!0),children:[(0,G.jsx)(Ca,{size:14}),e(`keysCreate`)]})]}),p?(0,G.jsx)(QI,{title:p}):null,a?(0,G.jsx)(QI,{title:e(`keysProvidersLoadFailed`,{message:a})}):null,l?(0,G.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,s.length)},(e,t)=>(0,G.jsxs)(`div`,{className:`overflow-hidden rounded-3xl bg-surface shadow-surface p-3`,children:[(0,G.jsx)(Q,{className:`h-4 w-28`}),(0,G.jsx)(Q,{className:`mt-2 h-3 w-40`}),(0,G.jsx)(Q,{className:`mt-4 h-6 w-24`}),(0,G.jsx)(Q,{className:`mt-6 h-8 w-full`})]},t))}):s.length?(0,G.jsx)(`section`,{className:`grid gap-2.5 lg:grid-cols-2 xl:grid-cols-3`,children:s.map(t=>(0,G.jsxs)(HS,{className:`overflow-hidden p-0`,children:[(0,G.jsxs)(HS.Header,{className:`flex-row items-start justify-between gap-3 px-3 pt-3 pb-2.5`,children:[(0,G.jsx)(`div`,{className:`min-w-0`,children:(0,G.jsx)(HS.Title,{className:`truncate text-body`,children:t.name})}),(0,G.jsx)(aC,{size:`sm`,variant:`soft`,color:t.enabled?`success`:`default`,children:t.enabled?e(`enabled`):e(`disabled`)})]}),(0,G.jsxs)(HS.Content,{className:`space-y-2.5 px-3 pb-2.5`,children:[(0,G.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,G.jsx)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:(t.providers.length?t.providers:[`all`]).map(t=>(0,G.jsx)(aC,{size:`sm`,variant:`soft`,children:(0,G.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[t===`all`?(0,G.jsx)(ta,{size:12}):(0,G.jsx)(MH,{provider:wwe(t),size:12}),(0,G.jsx)(`span`,{children:t===`all`?e(`keysAllProviders`):Q9(t,e)})]})},t))}),(0,G.jsx)(`p`,{className:`text-caption leading-5 text-muted`,children:t.last_used_at?e(`keysLastUsed`,{time:Dwe(t.last_used_at)}):e(`keysNeverUsed`)})]}),(0,G.jsxs)(HS.Footer,{className:`gap-1.5 bg-surface-secondary px-3 py-2`,children:[(0,G.jsx)(J,{size:`sm`,variant:`ghost`,isDisabled:!r,onPress:()=>y(t),children:e(`edit`)}),(0,G.jsx)(Swe,{label:e(`holdToDelete`),isPending:d===t.id,onConfirm:()=>void D(t),children:(0,G.jsx)(qa,{size:14})}),(0,G.jsx)(`div`,{className:`ml-auto`,children:(0,G.jsx)(F7,{isSelected:t.enabled,isDisabled:d===t.id,ariaLabel:e(`enable`),onChange:e=>void E(t,e)})})]})]},t.id))}):(0,G.jsx)(I7,{className:`rounded-3xl bg-surface-secondary`,icon:(0,G.jsx)(PV,{size:28}),title:e(`keysEmpty`),hint:e(`keysEmptyHint`),action:(0,G.jsxs)(J,{size:`sm`,isDisabled:!r,onPress:()=>g(!0),children:[(0,G.jsx)(Ca,{size:14}),e(`keysCreate`)]})}),(0,G.jsx)($9,{isOpen:h,title:e(`keysCreateTitle`),hint:e(`keysCreateHint`),options:t,t:e,onClose:()=>g(!1),onSave:async e=>{let t=await HCe(e);c(e=>[t,...e.map(e=>({...e,secret:void 0}))]),g(!1),x(t)}}),(0,G.jsx)($9,{isOpen:!!_,title:e(`keysEditTitle`),hint:e(`keysEditHint`),initial:_,options:t,t:e,onClose:()=>y(null),onSave:async e=>{if(!_)return;let t=await P9(_.id,e);c(e=>e.map(e=>e.id===_.id?{...e,...t,secret:void 0}:e)),y(null)}}),(0,G.jsx)(Y.Root,{isOpen:!!b?.secret,onOpenChange:e=>{e||x(null)},children:(0,G.jsx)(Y.Backdrop,{variant:`blur`,children:(0,G.jsx)(Y.Container,{placement:`center`,size:`lg`,children:(0,G.jsxs)(Y.Dialog,{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:e(`keysSecretTitle`)}),(0,G.jsx)(`p`,{className:`mt-1.5 text-body leading-6 text-muted`,children:e(`keysSecretHint`)})]}),(0,G.jsx)(Y.CloseTrigger,{"aria-label":e(`close`),className:`grid size-9 place-items-center rounded-lg text-muted hover:bg-surface-secondary`,children:(0,G.jsx)(ao,{size:18})})]}),(0,G.jsxs)(Y.Body,{className:`px-6 pb-2`,children:[(0,G.jsxs)(tF,{status:`warning`,className:`mb-4`,children:[(0,G.jsx)(tF.Indicator,{}),(0,G.jsx)(tF.Content,{children:(0,G.jsx)(tF.Title,{children:e(`keysSecretOnce`)})})]}),(0,G.jsx)(`code`,{className:`mono block break-all rounded-lg bg-surface-secondary px-3 py-3 text-body`,children:b?.secret})]}),(0,G.jsxs)(Y.Footer,{className:`justify-end`,children:[(0,G.jsx)(J,{variant:`ghost`,onPress:()=>x(null),children:e(`close`)}),(0,G.jsxs)(J,{onPress:()=>{b?.secret&&T(b.secret)},children:[(0,G.jsx)(Di,{size:14}),e(S?`copied`:`copy`)]})]})]})})})})]})}function $9({isOpen:e,title:t,hint:n,initial:r,options:i,t:a,onClose:o,onSave:s}){let[c,l]=(0,v.useState)(r?.name||``),[u,d]=(0,v.useState)([]),[f,p]=(0,v.useState)(new Set),[m,h]=(0,v.useState)(!0),[g,_]=(0,v.useState)(``),[y,b]=(0,v.useState)(!1);(0,v.useEffect)(()=>{if(!e)return;l(r?.name||``),d(Twe(r?.providers||[],i));let t=new Set((r?.providers||[]).filter(e=>!e.includes(`:`)).map(e=>e.toLowerCase()));p(t),h(!0),_(``)},[r,e,i]);function x(e){let t=i.find(t=>t.value===e);h(!1),d(n=>n.includes(e)?(t&&p(e=>{let n=new Set(e);return n.delete(t.provider),n}),n.filter(t=>t!==e)):[...n,e])}async function S(e){e?.preventDefault();let t=c.trim();if(!t){_(a(`keysNameRequired`));return}if(!i.length){_(a(`keysProvidersNotLoaded`));return}b(!0),_(``);try{await s({name:t,providers:m?r?.providers||[]:u})}catch(e){_(e instanceof Error?e.message:String(e))}finally{b(!1)}}return(0,G.jsx)(Y.Root,{isOpen:e,onOpenChange:e=>{!e&&!y&&o()},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-[32rem]`,children:(0,G.jsxs)(QP,{onSubmit:S,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:t}),(0,G.jsx)(`p`,{className:`mt-1.5 text-body leading-6 text-muted`,children:n})]}),(0,G.jsx)(Y.CloseTrigger,{isDisabled:y,"aria-label":a(`close`),className:`grid size-9 place-items-center rounded-lg text-muted hover:bg-surface-secondary`,children:(0,G.jsx)(ao,{size:18})})]}),(0,G.jsxs)(Y.Body,{className:`space-y-5 px-6 pb-2 pt-1`,children:[g?(0,G.jsxs)(tF,{status:`danger`,children:[(0,G.jsx)(tF.Indicator,{}),(0,G.jsx)(tF.Content,{children:(0,G.jsx)(tF.Title,{children:g})})]}):null,(0,G.jsx)(_9,{label:a(`keysName`),children:(0,G.jsx)(UM,{value:c,onChange:e=>l(e.target.value),placeholder:a(`keysNamePh`),"aria-label":a(`keysName`)})}),(0,G.jsxs)(`div`,{className:`space-y-2`,children:[(0,G.jsx)(IN,{className:`text-body font-medium text-muted`,children:a(`keysProviders`)}),(0,G.jsx)(RN,{className:`text-caption leading-5 text-muted`,children:a(`keysProvidersHint`)}),i.length?(0,G.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:i.map(e=>{let t=u.includes(e.value),n=f.has(e.provider);return(0,G.jsx)(tC,{isSelected:t,onChange:()=>x(e.value),className:`rounded-xl bg-surface-secondary px-3 py-2.5 data-selected:border-accent data-selected:bg-accent-soft`,children:(0,G.jsxs)(tC.Content,{className:`flex items-center gap-2.5`,children:[(0,G.jsx)(tC.Control,{children:(0,G.jsx)(tC.Indicator,{})}),(0,G.jsx)(MH,{provider:e.provider,size:16}),(0,G.jsx)(`span`,{className:`text-body font-medium`,children:jH(e.provider,e.region,a)}),n?(0,G.jsx)(`span`,{className:`rounded-md bg-surface-secondary px-1.5 py-0.5 text-caption font-medium text-muted`,children:a(`keysAllRegions`)}):null]})},e.value)})}):(0,G.jsx)(`p`,{className:`rounded-lg bg-surface-secondary px-3 py-2.5 text-caption leading-5 text-muted`,children:a(`keysProvidersNotLoaded`)}),(0,G.jsx)(`p`,{className:`text-caption text-muted`,children:Ewe(u,a)})]})]}),(0,G.jsxs)(Y.Footer,{className:`justify-end`,children:[(0,G.jsx)(J,{variant:`ghost`,isDisabled:y,onPress:o,children:a(`cancel`)}),(0,G.jsx)(J,{type:`submit`,isPending:y,isDisabled:!i.length,children:a(r?`save`:`create`)})]})]})})})})})}function kwe(){return(0,G.jsx)(Soe,{children:(0,G.jsx)(noe,{children:(0,G.jsx)(roe,{children:(0,G.jsx)(boe,{children:(0,G.jsx)(xn,{children:(0,G.jsxs)(Pt,{children:[(0,G.jsx)(Mt,{path:`/login`,element:(0,G.jsx)(VCe,{})}),(0,G.jsx)(Mt,{element:(0,G.jsx)(ace,{}),children:(0,G.jsxs)(Mt,{element:(0,G.jsx)(ice,{}),children:[(0,G.jsx)(Mt,{path:`/`,element:(0,G.jsx)(rSe,{})}),(0,G.jsx)(Mt,{path:`/auth`,element:(0,G.jsx)(At,{to:`/accounts`,replace:!0})}),(0,G.jsx)(Mt,{path:`/providers`,element:(0,G.jsx)(fSe,{})}),(0,G.jsx)(Mt,{path:`/access`,element:(0,G.jsx)(zSe,{})}),(0,G.jsx)(Mt,{path:`/accounts`,element:(0,G.jsx)(BCe,{})}),(0,G.jsx)(Mt,{path:`/checkins`,element:(0,G.jsx)(At,{to:`/accounts`,replace:!0})}),(0,G.jsx)(Mt,{path:`/usage`,element:(0,G.jsx)(bwe,{})}),(0,G.jsx)(Mt,{path:`/logs`,element:(0,G.jsx)(swe,{})}),(0,G.jsx)(Mt,{path:`/keys`,element:(0,G.jsx)(Owe,{})}),(0,G.jsx)(Mt,{path:`/system`,element:(0,G.jsx)(ZCe,{})}),(0,G.jsx)(Mt,{path:`*`,element:(0,G.jsx)(At,{to:`/`,replace:!0})})]})})]})})})})})})}(0,y.createRoot)(document.getElementById(`root`)).render((0,G.jsx)(v.StrictMode,{children:(0,G.jsx)(kwe,{})}));export{jJ as $,xU as $t,Nhe as A,MW as At,s4 as B,mW as Bt,C6 as C,h as Cn,FW as Ct,y3 as D,gW as Dt,pge as E,xW as Et,H4 as F,yW as Ft,lZ as G,EW as Gt,y2 as H,DW as Ht,U4 as I,hW as It,UX as J,uW as Jt,YX as K,fW as Kt,Kme as L,CW as Lt,Fhe as M,AW as Mt,Phe as N,jW as Nt,Zhe as O,wW as Ot,e3 as P,kW as Pt,sY as Q,yU as Qt,Vme as R,pW as Rt,D6 as S,xs as Sn,IW as St,v6 as T,l as Tn,SW as Tt,i2 as U,OW as Ut,o4 as V,_W as Vt,qZ as W,TW as Wt,gY as X,Nle as Xt,jY as Y,lW as Yt,hY as Z,_U as Zt,L6 as _,$V as _n,$ as _t,i5 as a,uU as an,TJ as at,k6 as b,Z as bn,RW as bt,R8 as c,iU as cn,vq as ct,v8 as d,ZH as dn,cq as dt,hU as en,AJ as et,t8 as f,YH as fn,bq as ft,B6 as g,oH as gn,XW as gt,U6 as h,fH as hn,rq as ht,f5 as i,lU as in,EJ as it,c3 as j,NW as jt,m3 as k,vW as kt,P8 as l,rU as ln,fq as lt,q6 as m,pH as mn,sq as mt,u7 as n,dU as nn,kJ as nt,B8 as o,cU as on,Xq as ot,Q6 as p,XH as pn,oq as pt,ZX as q,dW as qt,_5 as r,wU as rn,OJ as rt,z8 as s,sU as sn,Wq as st,d7 as t,mU as tn,MJ as tt,E8 as u,tU as un,gde as ut,I6 as v,cH as vn,BW as vt,h6 as w,d as wn,Vle as wt,O6 as x,Mc as xn,LW as xt,j6 as y,eH as yn,HW as yt,zme as z,bW as zt}; \ No newline at end of file diff --git a/internal/webui/static/index.html b/internal/webui/static/index.html index fda19c8b..5fd7f2d1 100644 --- a/internal/webui/static/index.html +++ b/internal/webui/static/index.html @@ -19,7 +19,7 @@ - +