@cortex-agent/server 2026.7.30 → 2026.8.3-2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/defaults/CORTEX.md +1 -0
- package/defaults/config/CORTEX.md +2 -1
- package/defaults/config/hooks/13-status-md-guard.json +11 -0
- package/defaults/config/hooks/CORTEX.md +1 -0
- package/defaults/config/mcp-config-empty.json +3 -0
- package/defaults/config/thread-templates/agents/benchmark-coder.json +22 -0
- package/defaults/config/thread-templates/agents/benchmark-reviewer.json +22 -0
- package/defaults/config/thread-templates/agents/coder-reviewer.json +4 -9
- package/defaults/config/thread-templates/agents/coder.json +4 -14
- package/defaults/config/thread-templates/templates/benchmark-coder-review.json +37 -0
- package/defaults/config/thread-templates/templates/coder-review.json +3 -27
- package/defaults/context/projects/CORTEX.md +1 -1
- package/defaults/data/schedules.json +12 -0
- package/defaults/hooks/CORTEX.md +1 -0
- package/defaults/hooks/new-session-hook.mjs +2 -2
- package/defaults/hooks/status-md-guard.mjs +193 -0
- package/defaults/plugins/cortex-coder/.claude-plugin/plugin.json +1 -1
- package/defaults/plugins/cortex-coder/skills/develop/SKILL.md +28 -2
- package/defaults/plugins/cortex-common/.claude-plugin/plugin.json +1 -1
- package/defaults/plugins/cortex-common/skills/compound/SKILL.md +1 -1
- package/defaults/plugins/cortex-common/skills/compound-simple/SKILL.md +4 -2
- package/defaults/plugins/cortex-common/skills/postmortem/SKILL.md +1 -1
- package/defaults/plugins/cortex-stage-gate/.claude-plugin/plugin.json +1 -1
- package/defaults/plugins/cortex-stage-gate/skills/director-method/SKILL.md +1 -1
- package/defaults/plugins/cortex-stage-gate/skills/need-approval/SKILL.md +1 -0
- package/defaults/plugins/cortex-stage-gate/skills/reorient/SKILL.md +2 -2
- package/defaults/plugins/cortex-stage-gate/skills/task/SKILL.md +11 -8
- package/defaults/plugins/cortex-system/skills/feedback/SKILL.md +1 -1
- package/defaults/plugins/cortex-system/skills/project-init/SKILL.md +13 -16
- package/defaults/prompts/directives/coder-reviewer.md +24 -20
- package/defaults/prompts/directives/coder.md +4 -5
- package/defaults/prompts/directives/director.md +4 -10
- package/defaults/prompts/directives/manager.md +9 -10
- package/defaults/prompts/systemPrompts/worker.md +2 -2
- package/defaults/rules/cortex-md.md +31 -0
- package/defaults/rules/experiment-format.md +8 -1
- package/defaults/rules/issues-md.md +10 -9
- package/defaults/rules/meta-conventions.md +5 -4
- package/defaults/rules/mission-md.md +2 -1
- package/defaults/rules/status-md.md +39 -21
- package/dist/agent-adapter/bg-wait.d.ts +10 -12
- package/dist/agent-adapter/bg-wait.js +209 -129
- package/dist/agent-adapter/claude/adapter-tui.d.ts +3 -1
- package/dist/agent-adapter/claude/adapter-tui.js +8 -5
- package/dist/agent-adapter/claude/adapter.d.ts +43 -14
- package/dist/agent-adapter/claude/adapter.js +276 -161
- package/dist/agent-adapter/claude/defaults.d.ts +2 -0
- package/dist/agent-adapter/claude/defaults.js +5 -5
- package/dist/agent-adapter/claude/event-parser.d.ts +3 -8
- package/dist/agent-adapter/claude/event-parser.js +28 -31
- package/dist/agent-adapter/claude/hooks-builder.js +4 -3
- package/dist/agent-adapter/claude/jsonl-tail.js +54 -35
- package/dist/agent-adapter/claude/spawn-args.d.ts +15 -12
- package/dist/agent-adapter/claude/spawn-args.js +44 -38
- package/dist/agent-adapter/claude/tmux-control.d.ts +4 -17
- package/dist/agent-adapter/claude/tmux-control.js +39 -32
- package/dist/agent-adapter/event-tee.d.ts +19 -0
- package/dist/agent-adapter/event-tee.js +145 -0
- package/dist/agent-adapter/index.d.ts +1 -0
- package/dist/agent-adapter/index.js +7 -3
- package/dist/agent-adapter/normalize/event-types.d.ts +17 -9
- package/dist/agent-adapter/normalize/event-types.js +4 -4
- package/dist/agent-adapter/pi/adapter.d.ts +16 -4
- package/dist/agent-adapter/pi/adapter.js +69 -36
- package/dist/agent-adapter/pi/discovery.d.ts +19 -3
- package/dist/agent-adapter/pi/discovery.js +81 -43
- package/dist/agent-adapter/pi/event-parser.js +4 -2
- package/dist/agent-adapter/pi/spawn-args.d.ts +2 -4
- package/dist/agent-adapter/pi/spawn-args.js +6 -5
- package/dist/agent-adapter/types.d.ts +43 -2
- package/dist/agent-adapter/types.js +8 -4
- package/dist/core/atomic-write.d.ts +6 -1
- package/dist/core/atomic-write.js +183 -7
- package/dist/core/cli-utils.d.ts +15 -2
- package/dist/core/cli-utils.js +46 -41
- package/dist/core/config-generator.d.ts +4 -0
- package/dist/core/config-generator.js +34 -21
- package/dist/core/json-repository.d.ts +4 -0
- package/dist/core/json-repository.js +6 -3
- package/dist/core/locales/en.d.ts +94 -0
- package/dist/core/locales/slices/commands.d.ts +76 -0
- package/dist/core/locales/slices/commands.js +155 -1
- package/dist/core/locales/slices/status.d.ts +18 -0
- package/dist/core/locales/slices/status.js +43 -2
- package/dist/core/log.d.ts +5 -0
- package/dist/core/log.js +25 -23
- package/dist/core/pi-session-filename.d.ts +2 -0
- package/dist/core/pi-session-filename.js +18 -0
- package/dist/core/resume-reminder.d.ts +5 -0
- package/dist/core/resume-reminder.js +18 -0
- package/dist/core/runtime-env.d.ts +1 -0
- package/dist/core/runtime-env.js +15 -0
- package/dist/core/settings-migration.d.ts +5 -0
- package/dist/core/settings-migration.js +128 -0
- package/dist/core/settings-spec.d.ts +174 -0
- package/dist/core/settings-spec.js +150 -0
- package/dist/core/settings.d.ts +10 -0
- package/dist/core/settings.js +235 -0
- package/dist/core/task-parser.d.ts +11 -1
- package/dist/core/task-parser.js +34 -3
- package/dist/core/types/agent-types.d.ts +19 -0
- package/dist/core/types/agent-types.js +1 -1
- package/dist/core/types/thread-types.d.ts +48 -3
- package/dist/core/types/thread-types.js +2 -2
- package/dist/core/utils.d.ts +21 -1
- package/dist/core/utils.js +37 -1
- package/dist/domain/agent-run/access-probe-cli.d.ts +7 -0
- package/dist/domain/agent-run/access-probe-cli.js +139 -0
- package/dist/domain/agent-run/access-probe-policy.d.ts +61 -0
- package/dist/domain/agent-run/access-probe-policy.js +614 -0
- package/dist/domain/agent-run/access-probe.d.ts +21 -0
- package/dist/domain/agent-run/access-probe.js +194 -0
- package/dist/domain/agent-run/agent-run-cli.d.ts +19 -0
- package/dist/domain/agent-run/agent-run-cli.js +171 -0
- package/dist/domain/agent-run/atif.d.ts +54 -0
- package/dist/domain/agent-run/atif.js +211 -0
- package/dist/domain/agent-run/benchmark-local-thread-orchestrator.d.ts +32 -0
- package/dist/domain/agent-run/benchmark-local-thread-orchestrator.js +616 -0
- package/dist/domain/agent-run/benchmark-thread-identity.d.ts +34 -0
- package/dist/domain/agent-run/benchmark-thread-identity.js +106 -0
- package/dist/domain/agent-run/identity.d.ts +62 -0
- package/dist/domain/agent-run/identity.js +118 -0
- package/dist/domain/agent-run/journal.d.ts +51 -0
- package/dist/domain/agent-run/journal.js +259 -0
- package/dist/domain/agent-run/manifest-contract.d.ts +44 -0
- package/dist/domain/agent-run/manifest-contract.js +134 -0
- package/dist/domain/agent-run/manifest.d.ts +51 -0
- package/dist/domain/agent-run/manifest.js +801 -0
- package/dist/domain/agent-run/pinned-node-process.d.ts +35 -0
- package/dist/domain/agent-run/pinned-node-process.js +206 -0
- package/dist/domain/agent-run/role-surface.d.ts +4 -0
- package/dist/domain/agent-run/role-surface.js +99 -0
- package/dist/domain/agent-run/run-config.d.ts +22 -0
- package/dist/domain/agent-run/run-config.js +135 -0
- package/dist/domain/agent-run/runner.d.ts +7 -0
- package/dist/domain/agent-run/runner.js +518 -0
- package/dist/domain/agent-run/supervisor.d.ts +78 -0
- package/dist/domain/agent-run/supervisor.js +425 -0
- package/dist/domain/agent-run/trajectory-merge-cli.d.ts +11 -0
- package/dist/domain/agent-run/trajectory-merge-cli.js +111 -0
- package/dist/domain/agent-run/trajectory-merge.d.ts +39 -0
- package/dist/domain/agent-run/trajectory-merge.js +505 -0
- package/dist/domain/agents/config.d.ts +10 -0
- package/dist/domain/agents/config.js +149 -44
- package/dist/domain/agents/facade.d.ts +42 -7
- package/dist/domain/agents/facade.js +174 -170
- package/dist/domain/agents/provider-run-lifecycle.d.ts +18 -0
- package/dist/domain/agents/provider-run-lifecycle.js +60 -0
- package/dist/domain/auth/auth-events.d.ts +18 -0
- package/dist/domain/auth/auth-events.js +38 -0
- package/dist/domain/auth/auth-format.d.ts +2 -0
- package/dist/domain/auth/auth-format.js +58 -0
- package/dist/domain/auth/auth-status.d.ts +61 -0
- package/dist/domain/auth/auth-status.js +304 -0
- package/dist/domain/auth/auth-watch.d.ts +16 -0
- package/dist/domain/auth/auth-watch.js +125 -0
- package/dist/domain/auth/cc-login.d.ts +7 -0
- package/dist/domain/auth/cc-login.js +16 -0
- package/dist/domain/auth/cc-subscription.d.ts +38 -0
- package/dist/domain/auth/cc-subscription.js +204 -0
- package/dist/domain/auth/index.d.ts +12 -0
- package/dist/domain/auth/index.js +16 -0
- package/dist/domain/auth/login-flow.d.ts +120 -0
- package/dist/domain/auth/login-flow.js +253 -0
- package/dist/domain/auth/login-service.d.ts +32 -0
- package/dist/domain/auth/login-service.js +97 -0
- package/dist/domain/auth/logout.d.ts +32 -0
- package/dist/domain/auth/logout.js +123 -0
- package/dist/domain/auth/pi-login.d.ts +36 -0
- package/dist/domain/auth/pi-login.js +72 -0
- package/dist/domain/auth/pi-oauth.d.ts +36 -0
- package/dist/domain/auth/pi-oauth.js +84 -0
- package/dist/domain/auth/pi-runtime.d.ts +72 -0
- package/dist/domain/auth/pi-runtime.js +86 -0
- package/dist/domain/mcp/benchmark-thread-server.d.ts +1 -0
- package/dist/domain/mcp/benchmark-thread-server.js +26 -0
- package/dist/domain/mcp/tools/benchmark-thread-run.d.ts +23 -0
- package/dist/domain/mcp/tools/benchmark-thread-run.js +146 -0
- package/dist/domain/memory/user-context.js +6 -8
- package/dist/domain/monitor/disk-monitor.js +47 -16
- package/dist/domain/projects/project-store.js +23 -6
- package/dist/domain/remote/client-hot-reload.d.ts +9 -1
- package/dist/domain/remote/client-hot-reload.js +60 -12
- package/dist/domain/remote/client-manager.js +12 -6
- package/dist/domain/scheduling/jobs/auth-expiry-scan.d.ts +14 -0
- package/dist/domain/scheduling/jobs/auth-expiry-scan.js +86 -0
- package/dist/domain/scheduling/jobs/task-dispatch.js +36 -40
- package/dist/domain/scheduling/runner.d.ts +2 -0
- package/dist/domain/scheduling/runner.js +7 -4
- package/dist/domain/sessions/session-backup.d.ts +14 -20
- package/dist/domain/sessions/session-backup.js +57 -68
- package/dist/domain/system/doctor.d.ts +4 -0
- package/dist/domain/system/doctor.js +113 -28
- package/dist/domain/system/install-cli.js +8 -3
- package/dist/domain/system/server-update-check.js +7 -5
- package/dist/domain/system/system-notice.d.ts +3 -1
- package/dist/domain/system/system-notice.js +6 -11
- package/dist/domain/tasks/archiver.d.ts +1 -0
- package/dist/domain/tasks/archiver.js +13 -7
- package/dist/domain/tasks/claim-recovery.d.ts +3 -3
- package/dist/domain/tasks/claim-recovery.js +12 -8
- package/dist/domain/tasks/dispatch-utils.d.ts +15 -14
- package/dist/domain/tasks/dispatch-utils.js +22 -18
- package/dist/domain/tasks/dispatcher.d.ts +1 -0
- package/dist/domain/tasks/dispatcher.js +9 -5
- package/dist/domain/tasks/mutator.d.ts +21 -11
- package/dist/domain/tasks/mutator.js +30 -24
- package/dist/domain/tasks/pending-tracker.d.ts +5 -2
- package/dist/domain/tasks/pending-tracker.js +11 -5
- package/dist/domain/tasks/system/cortex-run.d.ts +2 -1
- package/dist/domain/tasks/system/cortex-run.js +24 -4
- package/dist/domain/tasks/system/task-cli.d.ts +1 -0
- package/dist/domain/tasks/system/task-cli.js +72 -22
- package/dist/domain/tasks/system/task-completion.d.ts +19 -2
- package/dist/domain/tasks/system/task-completion.js +31 -17
- package/dist/domain/tasks/system/task-file-input.d.ts +10 -0
- package/dist/domain/tasks/system/task-file-input.js +57 -0
- package/dist/domain/tasks/system/task-id-utils.d.ts +9 -9
- package/dist/domain/tasks/system/task-id-utils.js +13 -4
- package/dist/domain/tasks/system/task-lifecycle-edit.d.ts +6 -2
- package/dist/domain/tasks/system/task-lifecycle-edit.js +200 -6
- package/dist/domain/tasks/system/task-lock.js +19 -5
- package/dist/domain/tasks/system/task-mutations.d.ts +22 -12
- package/dist/domain/tasks/system/task-mutations.js +28 -4
- package/dist/domain/tasks/system/task-process.js +10 -8
- package/dist/domain/tasks/system/task-state.d.ts +65 -11
- package/dist/domain/tasks/system/task-state.js +86 -13
- package/dist/domain/threads/local-runtime-deps.d.ts +32 -0
- package/dist/domain/threads/local-runtime-deps.js +91 -0
- package/dist/domain/threads/local-runtime-scope.d.ts +6 -0
- package/dist/domain/threads/local-runtime-scope.js +12 -0
- package/dist/domain/threads/pending-user-inputs.d.ts +3 -0
- package/dist/domain/threads/pending-user-inputs.js +37 -0
- package/dist/domain/threads/prompt-builder.d.ts +12 -1
- package/dist/domain/threads/prompt-builder.js +73 -26
- package/dist/domain/threads/runner.d.ts +15 -3
- package/dist/domain/threads/runner.js +261 -105
- package/dist/domain/threads/state-machine.d.ts +1 -1
- package/dist/domain/threads/state-machine.js +17 -8
- package/dist/domain/ui-service/app-router.d.ts +86 -6
- package/dist/domain/ui-service/app-router.js +171 -133
- package/dist/domain/ui-service/input-schemas.d.ts +132 -10
- package/dist/domain/ui-service/input-schemas.js +59 -5
- package/dist/domain/ui-service/mutate/approvals.d.ts +2 -1
- package/dist/domain/ui-service/mutate/approvals.js +2 -1
- package/dist/domain/ui-service/mutate/auth.d.ts +6 -0
- package/dist/domain/ui-service/mutate/auth.js +83 -0
- package/dist/domain/ui-service/mutate/config.js +11 -10
- package/dist/domain/ui-service/query/approvals.js +3 -0
- package/dist/domain/ui-service/query/auth.d.ts +6 -0
- package/dist/domain/ui-service/query/auth.js +12 -0
- package/dist/domain/ui-service/query/config.d.ts +5 -5
- package/dist/domain/ui-service/query/config.js +27 -17
- package/dist/domain/ui-service/query/tasks.d.ts +1 -1
- package/dist/domain/ui-service/query/tasks.js +69 -30
- package/dist/domain/ui-service/query/threads.js +3 -3
- package/dist/domain/ui-service/types.d.ts +67 -8
- package/dist/domain/ui-service/types.js +2 -2
- package/dist/domain/ui-service/ui-service.js +16 -2
- package/dist/entry/admin-channel-hot-reload.d.ts +4 -0
- package/dist/entry/admin-channel-hot-reload.js +22 -0
- package/dist/entry/app.js +38 -38
- package/dist/entry/auth-cli.d.ts +10 -0
- package/dist/entry/auth-cli.js +52 -0
- package/dist/entry/cli-help.d.ts +5 -0
- package/dist/entry/cli-help.js +130 -0
- package/dist/entry/cli.d.ts +5 -5
- package/dist/entry/cli.js +174 -248
- package/dist/entry/daemon.d.ts +11 -0
- package/dist/entry/daemon.js +204 -103
- package/dist/entry/draft-attachments.d.ts +8 -0
- package/dist/entry/draft-attachments.js +83 -0
- package/dist/entry/feishu-login.d.ts +2 -6
- package/dist/entry/feishu-login.js +16 -21
- package/dist/entry/init.js +6 -4
- package/dist/entry/start-ui-http.d.ts +2 -8
- package/dist/entry/start-ui-http.js +7 -34
- package/dist/events/event-logger.js +11 -13
- package/dist/events/event-types.d.ts +19 -1
- package/dist/events/event-types.js +3 -3
- package/dist/events/index.d.ts +1 -1
- package/dist/events/index.js +3 -3
- package/dist/hooks/new-session-hook.mjs +2 -2
- package/dist/hooks/status-md-guard.mjs +193 -0
- package/dist/orchestration/agent-file-send.js +44 -14
- package/dist/orchestration/agent-runner.d.ts +7 -3
- package/dist/orchestration/agent-runner.js +65 -41
- package/dist/orchestration/conversation-runner.d.ts +5 -1
- package/dist/orchestration/conversation-runner.js +16 -7
- package/dist/orchestration/lifecycle.d.ts +23 -1
- package/dist/orchestration/lifecycle.js +103 -40
- package/dist/orchestration/mid-turn-inject.d.ts +2 -0
- package/dist/orchestration/mid-turn-inject.js +29 -13
- package/dist/orchestration/resume-dispatcher.d.ts +3 -5
- package/dist/orchestration/resume-dispatcher.js +9 -17
- package/dist/orchestration/routing/commands/index.d.ts +4 -1
- package/dist/orchestration/routing/commands/index.js +83 -61
- package/dist/orchestration/routing/commands/login-notice.d.ts +21 -0
- package/dist/orchestration/routing/commands/login-notice.js +97 -0
- package/dist/orchestration/routing/commands/login.d.ts +12 -0
- package/dist/orchestration/routing/commands/login.js +555 -0
- package/dist/orchestration/routing/commands/status.js +45 -59
- package/dist/orchestration/routing/edit-handler.d.ts +5 -0
- package/dist/orchestration/routing/edit-handler.js +127 -73
- package/dist/orchestration/routing/webhook.js +5 -4
- package/dist/orchestration/session-rewind.d.ts +5 -1
- package/dist/orchestration/session-rewind.js +106 -62
- package/dist/orchestration/session-send.d.ts +2 -0
- package/dist/orchestration/session-send.js +5 -6
- package/dist/orchestration/status-helpers.d.ts +1 -2
- package/dist/orchestration/status-helpers.js +7 -10
- package/dist/orchestration/thread-callback.d.ts +19 -11
- package/dist/orchestration/thread-callback.js +132 -61
- package/dist/orchestration/thread-executor.js +37 -27
- package/dist/orchestration/turn-mutation-lock.d.ts +3 -0
- package/dist/orchestration/turn-mutation-lock.js +36 -0
- package/dist/orchestration/turn-notify.d.ts +2 -5
- package/dist/orchestration/turn-notify.js +9 -21
- package/dist/platform/adapter.d.ts +1 -0
- package/dist/platform/adapter.js +2 -2
- package/dist/platform/adapters/composite-adapter.d.ts +2 -0
- package/dist/platform/adapters/composite-adapter.js +13 -3
- package/dist/platform/adapters/feishu.d.ts +2 -4
- package/dist/platform/adapters/feishu.js +38 -59
- package/dist/platform/adapters/index.d.ts +1 -1
- package/dist/platform/adapters/index.js +13 -12
- package/dist/platform/adapters/slack.d.ts +1 -1
- package/dist/platform/adapters/slack.js +12 -35
- package/dist/platform/index.d.ts +2 -1
- package/dist/platform/index.js +3 -3
- package/dist/platform/testing.d.ts +1 -0
- package/dist/platform/testing.js +13 -4
- package/dist/platform/tool-trace.js +6 -11
- package/dist/platform/ui-http/ui-http-server.d.ts +1 -1
- package/dist/platform/ui-http/ui-http-server.js +6 -18
- package/dist/store/execution-repo.d.ts +17 -1
- package/dist/store/execution-repo.js +55 -4
- package/dist/store/prompt-migration-replacements.d.ts +4 -0
- package/dist/store/prompt-migration-replacements.js +149 -0
- package/dist/store/thread-repo.d.ts +15 -4
- package/dist/store/thread-repo.js +61 -24
- package/dist/store/version-migrations.js +36 -1
- package/native/cortex-supervisor/dist/build-manifest.json +22 -0
- package/native/cortex-supervisor/dist/cortex-supervisor +0 -0
- package/package.json +5 -2
- package/web/dist/assets/index-XqBCYtkw.js +139 -0
- package/web/dist/assets/index-zpf3OSKC.css +1 -0
- package/web/dist/index.html +2 -2
- package/dist/domain/scheduling/jobs/failed-dispatch-reconciliation.d.ts +0 -1
- package/dist/domain/scheduling/jobs/failed-dispatch-reconciliation.js +0 -78
- package/web/dist/assets/index-B19jLgji.js +0 -138
- package/web/dist/assets/index-BuFyPyRW.css +0 -1
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
var Rv=e=>{throw TypeError(e)};var Df=(e,t,n)=>t.has(e)||Rv("Cannot "+n);var M=(e,t,n)=>(Df(e,t,"read from private field"),n?n.call(e):t.get(e)),ge=(e,t,n)=>t.has(e)?Rv("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),ae=(e,t,n,r)=>(Df(e,t,"write to private field"),r?r.call(e,n):t.set(e,n),n),ke=(e,t,n)=>(Df(e,t,"access private method"),n);var kd=(e,t,n,r)=>({set _(i){ae(e,t,i,n)},get _(){return M(e,t,r)}});function fw(e,t){for(var n=0;n<t.length;n++){const r=t[n];if(typeof r!="string"&&!Array.isArray(r)){for(const i in r)if(i!=="default"&&!(i in e)){const s=Object.getOwnPropertyDescriptor(r,i);s&&Object.defineProperty(e,i,s.get?s:{enumerable:!0,get:()=>r[i]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const s of i)if(s.type==="childList")for(const a of s.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&r(a)}).observe(document,{childList:!0,subtree:!0});function n(i){const s={};return i.integrity&&(s.integrity=i.integrity),i.referrerPolicy&&(s.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?s.credentials="include":i.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(i){if(i.ep)return;i.ep=!0;const s=n(i);fetch(i.href,s)}})();function hw(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var gw={exports:{}},Mp={},xw={exports:{}},Pe={};/**
|
|
2
|
+
* @license React
|
|
3
|
+
* react.production.min.js
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/var qc=Symbol.for("react.element"),oE=Symbol.for("react.portal"),iE=Symbol.for("react.fragment"),sE=Symbol.for("react.strict_mode"),aE=Symbol.for("react.profiler"),lE=Symbol.for("react.provider"),cE=Symbol.for("react.context"),dE=Symbol.for("react.forward_ref"),uE=Symbol.for("react.suspense"),pE=Symbol.for("react.memo"),fE=Symbol.for("react.lazy"),Iv=Symbol.iterator;function hE(e){return e===null||typeof e!="object"?null:(e=Iv&&e[Iv]||e["@@iterator"],typeof e=="function"?e:null)}var mw={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},vw=Object.assign,yw={};function ol(e,t,n){this.props=e,this.context=t,this.refs=yw,this.updater=n||mw}ol.prototype.isReactComponent={};ol.prototype.setState=function(e,t){if(typeof e!="object"&&typeof e!="function"&&e!=null)throw Error("setState(...): 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")};ol.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function bw(){}bw.prototype=ol.prototype;function nm(e,t,n){this.props=e,this.context=t,this.refs=yw,this.updater=n||mw}var rm=nm.prototype=new bw;rm.constructor=nm;vw(rm,ol.prototype);rm.isPureReactComponent=!0;var Mv=Array.isArray,jw=Object.prototype.hasOwnProperty,om={current:null},ww={key:!0,ref:!0,__self:!0,__source:!0};function kw(e,t,n){var r,i={},s=null,a=null;if(t!=null)for(r in t.ref!==void 0&&(a=t.ref),t.key!==void 0&&(s=""+t.key),t)jw.call(t,r)&&!ww.hasOwnProperty(r)&&(i[r]=t[r]);var l=arguments.length-2;if(l===1)i.children=n;else if(1<l){for(var c=Array(l),d=0;d<l;d++)c[d]=arguments[d+2];i.children=c}if(e&&e.defaultProps)for(r in l=e.defaultProps,l)i[r]===void 0&&(i[r]=l[r]);return{$$typeof:qc,type:e,key:s,ref:a,props:i,_owner:om.current}}function gE(e,t){return{$$typeof:qc,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function im(e){return typeof e=="object"&&e!==null&&e.$$typeof===qc}function xE(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(n){return t[n]})}var Lv=/\/+/g;function Nf(e,t){return typeof e=="object"&&e!==null&&e.key!=null?xE(""+e.key):t.toString(36)}function hu(e,t,n,r,i){var s=typeof e;(s==="undefined"||s==="boolean")&&(e=null);var a=!1;if(e===null)a=!0;else switch(s){case"string":case"number":a=!0;break;case"object":switch(e.$$typeof){case qc:case oE:a=!0}}if(a)return a=e,i=i(a),e=r===""?"."+Nf(a,0):r,Mv(i)?(n="",e!=null&&(n=e.replace(Lv,"$&/")+"/"),hu(i,t,n,"",function(d){return d})):i!=null&&(im(i)&&(i=gE(i,n+(!i.key||a&&a.key===i.key?"":(""+i.key).replace(Lv,"$&/")+"/")+e)),t.push(i)),1;if(a=0,r=r===""?".":r+":",Mv(e))for(var l=0;l<e.length;l++){s=e[l];var c=r+Nf(s,l);a+=hu(s,t,n,c,i)}else if(c=hE(e),typeof c=="function")for(e=c.call(e),l=0;!(s=e.next()).done;)s=s.value,c=r+Nf(s,l++),a+=hu(s,t,n,c,i);else if(s==="object")throw t=String(e),Error("Objects are not valid as a React child (found: "+(t==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.");return a}function Sd(e,t,n){if(e==null)return e;var r=[],i=0;return hu(e,r,"","",function(s){return t.call(n,s,i++)}),r}function mE(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(n){(e._status===0||e._status===-1)&&(e._status=1,e._result=n)},function(n){(e._status===0||e._status===-1)&&(e._status=2,e._result=n)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var tn={current:null},gu={transition:null},vE={ReactCurrentDispatcher:tn,ReactCurrentBatchConfig:gu,ReactCurrentOwner:om};function Sw(){throw Error("act(...) is not supported in production builds of React.")}Pe.Children={map:Sd,forEach:function(e,t,n){Sd(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return Sd(e,function(){t++}),t},toArray:function(e){return Sd(e,function(t){return t})||[]},only:function(e){if(!im(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};Pe.Component=ol;Pe.Fragment=iE;Pe.Profiler=aE;Pe.PureComponent=nm;Pe.StrictMode=sE;Pe.Suspense=uE;Pe.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=vE;Pe.act=Sw;Pe.cloneElement=function(e,t,n){if(e==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var r=vw({},e.props),i=e.key,s=e.ref,a=e._owner;if(t!=null){if(t.ref!==void 0&&(s=t.ref,a=om.current),t.key!==void 0&&(i=""+t.key),e.type&&e.type.defaultProps)var l=e.type.defaultProps;for(c in t)jw.call(t,c)&&!ww.hasOwnProperty(c)&&(r[c]=t[c]===void 0&&l!==void 0?l[c]:t[c])}var c=arguments.length-2;if(c===1)r.children=n;else if(1<c){l=Array(c);for(var d=0;d<c;d++)l[d]=arguments[d+2];r.children=l}return{$$typeof:qc,type:e.type,key:i,ref:s,props:r,_owner:a}};Pe.createContext=function(e){return e={$$typeof:cE,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:lE,_context:e},e.Consumer=e};Pe.createElement=kw;Pe.createFactory=function(e){var t=kw.bind(null,e);return t.type=e,t};Pe.createRef=function(){return{current:null}};Pe.forwardRef=function(e){return{$$typeof:dE,render:e}};Pe.isValidElement=im;Pe.lazy=function(e){return{$$typeof:fE,_payload:{_status:-1,_result:e},_init:mE}};Pe.memo=function(e,t){return{$$typeof:pE,type:e,compare:t===void 0?null:t}};Pe.startTransition=function(e){var t=gu.transition;gu.transition={};try{e()}finally{gu.transition=t}};Pe.unstable_act=Sw;Pe.useCallback=function(e,t){return tn.current.useCallback(e,t)};Pe.useContext=function(e){return tn.current.useContext(e)};Pe.useDebugValue=function(){};Pe.useDeferredValue=function(e){return tn.current.useDeferredValue(e)};Pe.useEffect=function(e,t){return tn.current.useEffect(e,t)};Pe.useId=function(){return tn.current.useId()};Pe.useImperativeHandle=function(e,t,n){return tn.current.useImperativeHandle(e,t,n)};Pe.useInsertionEffect=function(e,t){return tn.current.useInsertionEffect(e,t)};Pe.useLayoutEffect=function(e,t){return tn.current.useLayoutEffect(e,t)};Pe.useMemo=function(e,t){return tn.current.useMemo(e,t)};Pe.useReducer=function(e,t,n){return tn.current.useReducer(e,t,n)};Pe.useRef=function(e){return tn.current.useRef(e)};Pe.useState=function(e){return tn.current.useState(e)};Pe.useSyncExternalStore=function(e,t,n){return tn.current.useSyncExternalStore(e,t,n)};Pe.useTransition=function(){return tn.current.useTransition()};Pe.version="18.3.1";xw.exports=Pe;var p=xw.exports;const yE=hw(p),il=fw({__proto__:null,default:yE},[p]);/**
|
|
10
|
+
* @license React
|
|
11
|
+
* react-jsx-runtime.production.min.js
|
|
12
|
+
*
|
|
13
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
14
|
+
*
|
|
15
|
+
* This source code is licensed under the MIT license found in the
|
|
16
|
+
* LICENSE file in the root directory of this source tree.
|
|
17
|
+
*/var bE=p,jE=Symbol.for("react.element"),wE=Symbol.for("react.fragment"),kE=Object.prototype.hasOwnProperty,SE=bE.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,CE={key:!0,ref:!0,__self:!0,__source:!0};function Cw(e,t,n){var r,i={},s=null,a=null;n!==void 0&&(s=""+n),t.key!==void 0&&(s=""+t.key),t.ref!==void 0&&(a=t.ref);for(r in t)kE.call(t,r)&&!CE.hasOwnProperty(r)&&(i[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps,t)i[r]===void 0&&(i[r]=t[r]);return{$$typeof:jE,type:e,key:s,ref:a,props:i,_owner:SE.current}}Mp.Fragment=wE;Mp.jsx=Cw;Mp.jsxs=Cw;gw.exports=Mp;var o=gw.exports,Ew={exports:{}},Tn={},Tw={exports:{}},Pw={};/**
|
|
18
|
+
* @license React
|
|
19
|
+
* scheduler.production.min.js
|
|
20
|
+
*
|
|
21
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
22
|
+
*
|
|
23
|
+
* This source code is licensed under the MIT license found in the
|
|
24
|
+
* LICENSE file in the root directory of this source tree.
|
|
25
|
+
*/(function(e){function t(_,F){var W=_.length;_.push(F);e:for(;0<W;){var te=W-1>>>1,A=_[te];if(0<i(A,F))_[te]=F,_[W]=A,W=te;else break e}}function n(_){return _.length===0?null:_[0]}function r(_){if(_.length===0)return null;var F=_[0],W=_.pop();if(W!==F){_[0]=W;e:for(var te=0,A=_.length,V=A>>>1;te<V;){var oe=2*(te+1)-1,Z=_[oe],ie=oe+1,he=_[ie];if(0>i(Z,W))ie<A&&0>i(he,Z)?(_[te]=he,_[ie]=W,te=ie):(_[te]=Z,_[oe]=W,te=oe);else if(ie<A&&0>i(he,W))_[te]=he,_[ie]=W,te=ie;else break e}}return F}function i(_,F){var W=_.sortIndex-F.sortIndex;return W!==0?W:_.id-F.id}if(typeof performance=="object"&&typeof performance.now=="function"){var s=performance;e.unstable_now=function(){return s.now()}}else{var a=Date,l=a.now();e.unstable_now=function(){return a.now()-l}}var c=[],d=[],u=1,f=null,h=3,g=!1,v=!1,x=!1,b=typeof setTimeout=="function"?setTimeout:null,j=typeof clearTimeout=="function"?clearTimeout:null,y=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function w(_){for(var F=n(d);F!==null;){if(F.callback===null)r(d);else if(F.startTime<=_)r(d),F.sortIndex=F.expirationTime,t(c,F);else break;F=n(d)}}function k(_){if(x=!1,w(_),!v)if(n(c)!==null)v=!0,Q(S);else{var F=n(d);F!==null&&J(k,F.startTime-_)}}function S(_,F){v=!1,x&&(x=!1,j(P),P=-1),g=!0;var W=h;try{for(w(F),f=n(c);f!==null&&(!(f.expirationTime>F)||_&&!z());){var te=f.callback;if(typeof te=="function"){f.callback=null,h=f.priorityLevel;var A=te(f.expirationTime<=F);F=e.unstable_now(),typeof A=="function"?f.callback=A:f===n(c)&&r(c),w(F)}else r(c);f=n(c)}if(f!==null)var V=!0;else{var oe=n(d);oe!==null&&J(k,oe.startTime-F),V=!1}return V}finally{f=null,h=W,g=!1}}var T=!1,C=null,P=-1,I=5,L=-1;function z(){return!(e.unstable_now()-L<I)}function q(){if(C!==null){var _=e.unstable_now();L=_;var F=!0;try{F=C(!0,_)}finally{F?X():(T=!1,C=null)}}else T=!1}var X;if(typeof y=="function")X=function(){y(q)};else if(typeof MessageChannel<"u"){var D=new MessageChannel,U=D.port2;D.port1.onmessage=q,X=function(){U.postMessage(null)}}else X=function(){b(q,0)};function Q(_){C=_,T||(T=!0,X())}function J(_,F){P=b(function(){_(e.unstable_now())},F)}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(_){_.callback=null},e.unstable_continueExecution=function(){v||g||(v=!0,Q(S))},e.unstable_forceFrameRate=function(_){0>_||125<_?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):I=0<_?Math.floor(1e3/_):5},e.unstable_getCurrentPriorityLevel=function(){return h},e.unstable_getFirstCallbackNode=function(){return n(c)},e.unstable_next=function(_){switch(h){case 1:case 2:case 3:var F=3;break;default:F=h}var W=h;h=F;try{return _()}finally{h=W}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(_,F){switch(_){case 1:case 2:case 3:case 4:case 5:break;default:_=3}var W=h;h=_;try{return F()}finally{h=W}},e.unstable_scheduleCallback=function(_,F,W){var te=e.unstable_now();switch(typeof W=="object"&&W!==null?(W=W.delay,W=typeof W=="number"&&0<W?te+W:te):W=te,_){case 1:var A=-1;break;case 2:A=250;break;case 5:A=1073741823;break;case 4:A=1e4;break;default:A=5e3}return A=W+A,_={id:u++,callback:F,priorityLevel:_,startTime:W,expirationTime:A,sortIndex:-1},W>te?(_.sortIndex=W,t(d,_),n(c)===null&&_===n(d)&&(x?(j(P),P=-1):x=!0,J(k,W-te))):(_.sortIndex=A,t(c,_),v||g||(v=!0,Q(S))),_},e.unstable_shouldYield=z,e.unstable_wrapCallback=function(_){var F=h;return function(){var W=h;h=F;try{return _.apply(this,arguments)}finally{h=W}}}})(Pw);Tw.exports=Pw;var EE=Tw.exports;/**
|
|
26
|
+
* @license React
|
|
27
|
+
* react-dom.production.min.js
|
|
28
|
+
*
|
|
29
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
30
|
+
*
|
|
31
|
+
* This source code is licensed under the MIT license found in the
|
|
32
|
+
* LICENSE file in the root directory of this source tree.
|
|
33
|
+
*/var TE=p,Cn=EE;function G(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n<arguments.length;n++)t+="&args[]="+encodeURIComponent(arguments[n]);return"Minified React error #"+e+"; visit "+t+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var Rw=new Set,uc={};function xs(e,t){_a(e,t),_a(e+"Capture",t)}function _a(e,t){for(uc[e]=t,e=0;e<t.length;e++)Rw.add(t[e])}var no=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Zh=Object.prototype.hasOwnProperty,PE=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,Ov={},Av={};function RE(e){return Zh.call(Av,e)?!0:Zh.call(Ov,e)?!1:PE.test(e)?Av[e]=!0:(Ov[e]=!0,!1)}function IE(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function ME(e,t,n,r){if(t===null||typeof t>"u"||IE(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function nn(e,t,n,r,i,s,a){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=i,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=s,this.removeEmptyString=a}var $t={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){$t[e]=new nn(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];$t[t]=new nn(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){$t[e]=new nn(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){$t[e]=new nn(e,2,!1,e,null,!1,!1)});"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(e){$t[e]=new nn(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){$t[e]=new nn(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){$t[e]=new nn(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){$t[e]=new nn(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){$t[e]=new nn(e,5,!1,e.toLowerCase(),null,!1,!1)});var sm=/[\-:]([a-z])/g;function am(e){return e[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(e){var t=e.replace(sm,am);$t[t]=new nn(t,1,!1,e,null,!1,!1)});"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(e){var t=e.replace(sm,am);$t[t]=new nn(t,1,!1,e,"http://www.w3.org/1999/xlink",!1,!1)});["xml:base","xml:lang","xml:space"].forEach(function(e){var t=e.replace(sm,am);$t[t]=new nn(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){$t[e]=new nn(e,1,!1,e.toLowerCase(),null,!1,!1)});$t.xlinkHref=new nn("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){$t[e]=new nn(e,1,!1,e.toLowerCase(),null,!0,!0)});function lm(e,t,n,r){var i=$t.hasOwnProperty(t)?$t[t]:null;(i!==null?i.type!==0:r||!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N")&&(ME(t,n,i,r)&&(n=null),r||i===null?RE(t)&&(n===null?e.removeAttribute(t):e.setAttribute(t,""+n)):i.mustUseProperty?e[i.propertyName]=n===null?i.type===3?!1:"":n:(t=i.attributeName,r=i.attributeNamespace,n===null?e.removeAttribute(t):(i=i.type,n=i===3||i===4&&n===!0?"":""+n,r?e.setAttributeNS(r,t,n):e.setAttribute(t,n))))}var co=TE.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Cd=Symbol.for("react.element"),Js=Symbol.for("react.portal"),Zs=Symbol.for("react.fragment"),cm=Symbol.for("react.strict_mode"),eg=Symbol.for("react.profiler"),Iw=Symbol.for("react.provider"),Mw=Symbol.for("react.context"),dm=Symbol.for("react.forward_ref"),tg=Symbol.for("react.suspense"),ng=Symbol.for("react.suspense_list"),um=Symbol.for("react.memo"),Lo=Symbol.for("react.lazy"),Lw=Symbol.for("react.offscreen"),Dv=Symbol.iterator;function wl(e){return e===null||typeof e!="object"?null:(e=Dv&&e[Dv]||e["@@iterator"],typeof e=="function"?e:null)}var dt=Object.assign,_f;function Nl(e){if(_f===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);_f=t&&t[1]||""}return`
|
|
34
|
+
`+_f+e}var $f=!1;function Ff(e,t){if(!e||$f)return"";$f=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(t)if(t=function(){throw Error()},Object.defineProperty(t.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(t,[])}catch(d){var r=d}Reflect.construct(e,[],t)}else{try{t.call()}catch(d){r=d}e.call(t.prototype)}else{try{throw Error()}catch(d){r=d}e()}}catch(d){if(d&&r&&typeof d.stack=="string"){for(var i=d.stack.split(`
|
|
35
|
+
`),s=r.stack.split(`
|
|
36
|
+
`),a=i.length-1,l=s.length-1;1<=a&&0<=l&&i[a]!==s[l];)l--;for(;1<=a&&0<=l;a--,l--)if(i[a]!==s[l]){if(a!==1||l!==1)do if(a--,l--,0>l||i[a]!==s[l]){var c=`
|
|
37
|
+
`+i[a].replace(" at new "," at ");return e.displayName&&c.includes("<anonymous>")&&(c=c.replace("<anonymous>",e.displayName)),c}while(1<=a&&0<=l);break}}}finally{$f=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?Nl(e):""}function LE(e){switch(e.tag){case 5:return Nl(e.type);case 16:return Nl("Lazy");case 13:return Nl("Suspense");case 19:return Nl("SuspenseList");case 0:case 2:case 15:return e=Ff(e.type,!1),e;case 11:return e=Ff(e.type.render,!1),e;case 1:return e=Ff(e.type,!0),e;default:return""}}function rg(e){if(e==null)return null;if(typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case Zs:return"Fragment";case Js:return"Portal";case eg:return"Profiler";case cm:return"StrictMode";case tg:return"Suspense";case ng:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case Mw:return(e.displayName||"Context")+".Consumer";case Iw:return(e._context.displayName||"Context")+".Provider";case dm:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case um:return t=e.displayName||null,t!==null?t:rg(e.type)||"Memo";case Lo:t=e._payload,e=e._init;try{return rg(e(t))}catch{}}return null}function OE(e){var t=e.type;switch(e.tag){case 24:return"Cache";case 9:return(t.displayName||"Context")+".Consumer";case 10:return(t._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return e=t.render,e=e.displayName||e.name||"",t.displayName||(e!==""?"ForwardRef("+e+")":"ForwardRef");case 7:return"Fragment";case 5:return t;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return rg(t);case 8:return t===cm?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof t=="function")return t.displayName||t.name||null;if(typeof t=="string")return t}return null}function ci(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function Ow(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function AE(e){var t=Ow(e)?"checked":"value",n=Object.getOwnPropertyDescriptor(e.constructor.prototype,t),r=""+e[t];if(!e.hasOwnProperty(t)&&typeof n<"u"&&typeof n.get=="function"&&typeof n.set=="function"){var i=n.get,s=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(a){r=""+a,s.call(this,a)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(a){r=""+a},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Ed(e){e._valueTracker||(e._valueTracker=AE(e))}function Aw(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=Ow(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function $u(e){if(e=e||(typeof document<"u"?document:void 0),typeof e>"u")return null;try{return e.activeElement||e.body}catch{return e.body}}function og(e,t){var n=t.checked;return dt({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function Nv(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=ci(t.value!=null?t.value:n),e._wrapperState={initialChecked:r,initialValue:n,controlled:t.type==="checkbox"||t.type==="radio"?t.checked!=null:t.value!=null}}function Dw(e,t){t=t.checked,t!=null&&lm(e,"checked",t,!1)}function ig(e,t){Dw(e,t);var n=ci(t.value),r=t.type;if(n!=null)r==="number"?(n===0&&e.value===""||e.value!=n)&&(e.value=""+n):e.value!==""+n&&(e.value=""+n);else if(r==="submit"||r==="reset"){e.removeAttribute("value");return}t.hasOwnProperty("value")?sg(e,t.type,n):t.hasOwnProperty("defaultValue")&&sg(e,t.type,ci(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function _v(e,t,n){if(t.hasOwnProperty("value")||t.hasOwnProperty("defaultValue")){var r=t.type;if(!(r!=="submit"&&r!=="reset"||t.value!==void 0&&t.value!==null))return;t=""+e._wrapperState.initialValue,n||t===e.value||(e.value=t),e.defaultValue=t}n=e.name,n!==""&&(e.name=""),e.defaultChecked=!!e._wrapperState.initialChecked,n!==""&&(e.name=n)}function sg(e,t,n){(t!=="number"||$u(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var _l=Array.isArray;function pa(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i<n.length;i++)t["$"+n[i]]=!0;for(n=0;n<e.length;n++)i=t.hasOwnProperty("$"+e[n].value),e[n].selected!==i&&(e[n].selected=i),i&&r&&(e[n].defaultSelected=!0)}else{for(n=""+ci(n),t=null,i=0;i<e.length;i++){if(e[i].value===n){e[i].selected=!0,r&&(e[i].defaultSelected=!0);return}t!==null||e[i].disabled||(t=e[i])}t!==null&&(t.selected=!0)}}function ag(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(G(91));return dt({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function $v(e,t){var n=t.value;if(n==null){if(n=t.children,t=t.defaultValue,n!=null){if(t!=null)throw Error(G(92));if(_l(n)){if(1<n.length)throw Error(G(93));n=n[0]}t=n}t==null&&(t=""),n=t}e._wrapperState={initialValue:ci(n)}}function Nw(e,t){var n=ci(t.value),r=ci(t.defaultValue);n!=null&&(n=""+n,n!==e.value&&(e.value=n),t.defaultValue==null&&e.defaultValue!==n&&(e.defaultValue=n)),r!=null&&(e.defaultValue=""+r)}function Fv(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function _w(e){switch(e){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function lg(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?_w(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var Td,$w=function(e){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(t,n,r,i){MSApp.execUnsafeLocalFunction(function(){return e(t,n,r,i)})}:e}(function(e,t){if(e.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in e)e.innerHTML=t;else{for(Td=Td||document.createElement("div"),Td.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=Td.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function pc(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Kl={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},DE=["Webkit","ms","Moz","O"];Object.keys(Kl).forEach(function(e){DE.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Kl[t]=Kl[e]})});function Fw(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Kl.hasOwnProperty(e)&&Kl[e]?(""+t).trim():t+"px"}function zw(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,i=Fw(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,i):e[n]=i}}var NE=dt({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function cg(e,t){if(t){if(NE[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(G(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(G(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(G(61))}if(t.style!=null&&typeof t.style!="object")throw Error(G(62))}}function dg(e,t){if(e.indexOf("-")===-1)return typeof t.is=="string";switch(e){case"annotation-xml":case"color-profile":case"font-face":case"font-face-src":case"font-face-uri":case"font-face-format":case"font-face-name":case"missing-glyph":return!1;default:return!0}}var ug=null;function pm(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var pg=null,fa=null,ha=null;function zv(e){if(e=Yc(e)){if(typeof pg!="function")throw Error(G(280));var t=e.stateNode;t&&(t=Np(t),pg(e.stateNode,e.type,t))}}function Bw(e){fa?ha?ha.push(e):ha=[e]:fa=e}function Ww(){if(fa){var e=fa,t=ha;if(ha=fa=null,zv(e),t)for(e=0;e<t.length;e++)zv(t[e])}}function Uw(e,t){return e(t)}function Hw(){}var zf=!1;function Vw(e,t,n){if(zf)return e(t,n);zf=!0;try{return Uw(e,t,n)}finally{zf=!1,(fa!==null||ha!==null)&&(Hw(),Ww())}}function fc(e,t){var n=e.stateNode;if(n===null)return null;var r=Np(n);if(r===null)return null;n=r[t];e:switch(t){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(r=!r.disabled)||(e=e.type,r=!(e==="button"||e==="input"||e==="select"||e==="textarea")),e=!r;break e;default:e=!1}if(e)return null;if(n&&typeof n!="function")throw Error(G(231,t,typeof n));return n}var fg=!1;if(no)try{var kl={};Object.defineProperty(kl,"passive",{get:function(){fg=!0}}),window.addEventListener("test",kl,kl),window.removeEventListener("test",kl,kl)}catch{fg=!1}function _E(e,t,n,r,i,s,a,l,c){var d=Array.prototype.slice.call(arguments,3);try{t.apply(n,d)}catch(u){this.onError(u)}}var Ql=!1,Fu=null,zu=!1,hg=null,$E={onError:function(e){Ql=!0,Fu=e}};function FE(e,t,n,r,i,s,a,l,c){Ql=!1,Fu=null,_E.apply($E,arguments)}function zE(e,t,n,r,i,s,a,l,c){if(FE.apply(this,arguments),Ql){if(Ql){var d=Fu;Ql=!1,Fu=null}else throw Error(G(198));zu||(zu=!0,hg=d)}}function ms(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function qw(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function Bv(e){if(ms(e)!==e)throw Error(G(188))}function BE(e){var t=e.alternate;if(!t){if(t=ms(e),t===null)throw Error(G(188));return t!==e?null:e}for(var n=e,r=t;;){var i=n.return;if(i===null)break;var s=i.alternate;if(s===null){if(r=i.return,r!==null){n=r;continue}break}if(i.child===s.child){for(s=i.child;s;){if(s===n)return Bv(i),e;if(s===r)return Bv(i),t;s=s.sibling}throw Error(G(188))}if(n.return!==r.return)n=i,r=s;else{for(var a=!1,l=i.child;l;){if(l===n){a=!0,n=i,r=s;break}if(l===r){a=!0,r=i,n=s;break}l=l.sibling}if(!a){for(l=s.child;l;){if(l===n){a=!0,n=s,r=i;break}if(l===r){a=!0,r=s,n=i;break}l=l.sibling}if(!a)throw Error(G(189))}}if(n.alternate!==r)throw Error(G(190))}if(n.tag!==3)throw Error(G(188));return n.stateNode.current===n?e:t}function Kw(e){return e=BE(e),e!==null?Qw(e):null}function Qw(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=Qw(e);if(t!==null)return t;e=e.sibling}return null}var Yw=Cn.unstable_scheduleCallback,Wv=Cn.unstable_cancelCallback,WE=Cn.unstable_shouldYield,UE=Cn.unstable_requestPaint,vt=Cn.unstable_now,HE=Cn.unstable_getCurrentPriorityLevel,fm=Cn.unstable_ImmediatePriority,Gw=Cn.unstable_UserBlockingPriority,Bu=Cn.unstable_NormalPriority,VE=Cn.unstable_LowPriority,Xw=Cn.unstable_IdlePriority,Lp=null,Tr=null;function qE(e){if(Tr&&typeof Tr.onCommitFiberRoot=="function")try{Tr.onCommitFiberRoot(Lp,e,void 0,(e.current.flags&128)===128)}catch{}}var tr=Math.clz32?Math.clz32:YE,KE=Math.log,QE=Math.LN2;function YE(e){return e>>>=0,e===0?32:31-(KE(e)/QE|0)|0}var Pd=64,Rd=4194304;function $l(e){switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return e&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return e&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return e}}function Wu(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,i=e.suspendedLanes,s=e.pingedLanes,a=n&268435455;if(a!==0){var l=a&~i;l!==0?r=$l(l):(s&=a,s!==0&&(r=$l(s)))}else a=n&~i,a!==0?r=$l(a):s!==0&&(r=$l(s));if(r===0)return 0;if(t!==0&&t!==r&&!(t&i)&&(i=r&-r,s=t&-t,i>=s||i===16&&(s&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0<t;)n=31-tr(t),i=1<<n,r|=e[n],t&=~i;return r}function GE(e,t){switch(e){case 1:case 2:case 4:return t+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function XE(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,s=e.pendingLanes;0<s;){var a=31-tr(s),l=1<<a,c=i[a];c===-1?(!(l&n)||l&r)&&(i[a]=GE(l,t)):c<=t&&(e.expiredLanes|=l),s&=~l}}function gg(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function Jw(){var e=Pd;return Pd<<=1,!(Pd&4194240)&&(Pd=64),e}function Bf(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function Kc(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-tr(t),e[t]=n}function JE(e,t){var n=e.pendingLanes&~t;e.pendingLanes=t,e.suspendedLanes=0,e.pingedLanes=0,e.expiredLanes&=t,e.mutableReadLanes&=t,e.entangledLanes&=t,t=e.entanglements;var r=e.eventTimes;for(e=e.expirationTimes;0<n;){var i=31-tr(n),s=1<<i;t[i]=0,r[i]=-1,e[i]=-1,n&=~s}}function hm(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-tr(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}var We=0;function Zw(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var e2,gm,t2,n2,r2,xg=!1,Id=[],Xo=null,Jo=null,Zo=null,hc=new Map,gc=new Map,Do=[],ZE="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function Uv(e,t){switch(e){case"focusin":case"focusout":Xo=null;break;case"dragenter":case"dragleave":Jo=null;break;case"mouseover":case"mouseout":Zo=null;break;case"pointerover":case"pointerout":hc.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":gc.delete(t.pointerId)}}function Sl(e,t,n,r,i,s){return e===null||e.nativeEvent!==s?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:s,targetContainers:[i]},t!==null&&(t=Yc(t),t!==null&&gm(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function eT(e,t,n,r,i){switch(t){case"focusin":return Xo=Sl(Xo,e,t,n,r,i),!0;case"dragenter":return Jo=Sl(Jo,e,t,n,r,i),!0;case"mouseover":return Zo=Sl(Zo,e,t,n,r,i),!0;case"pointerover":var s=i.pointerId;return hc.set(s,Sl(hc.get(s)||null,e,t,n,r,i)),!0;case"gotpointercapture":return s=i.pointerId,gc.set(s,Sl(gc.get(s)||null,e,t,n,r,i)),!0}return!1}function o2(e){var t=Wi(e.target);if(t!==null){var n=ms(t);if(n!==null){if(t=n.tag,t===13){if(t=qw(n),t!==null){e.blockedOn=t,r2(e.priority,function(){t2(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function xu(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=mg(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);ug=r,n.target.dispatchEvent(r),ug=null}else return t=Yc(n),t!==null&&gm(t),e.blockedOn=n,!1;t.shift()}return!0}function Hv(e,t,n){xu(e)&&n.delete(t)}function tT(){xg=!1,Xo!==null&&xu(Xo)&&(Xo=null),Jo!==null&&xu(Jo)&&(Jo=null),Zo!==null&&xu(Zo)&&(Zo=null),hc.forEach(Hv),gc.forEach(Hv)}function Cl(e,t){e.blockedOn===t&&(e.blockedOn=null,xg||(xg=!0,Cn.unstable_scheduleCallback(Cn.unstable_NormalPriority,tT)))}function xc(e){function t(i){return Cl(i,e)}if(0<Id.length){Cl(Id[0],e);for(var n=1;n<Id.length;n++){var r=Id[n];r.blockedOn===e&&(r.blockedOn=null)}}for(Xo!==null&&Cl(Xo,e),Jo!==null&&Cl(Jo,e),Zo!==null&&Cl(Zo,e),hc.forEach(t),gc.forEach(t),n=0;n<Do.length;n++)r=Do[n],r.blockedOn===e&&(r.blockedOn=null);for(;0<Do.length&&(n=Do[0],n.blockedOn===null);)o2(n),n.blockedOn===null&&Do.shift()}var ga=co.ReactCurrentBatchConfig,Uu=!0;function nT(e,t,n,r){var i=We,s=ga.transition;ga.transition=null;try{We=1,xm(e,t,n,r)}finally{We=i,ga.transition=s}}function rT(e,t,n,r){var i=We,s=ga.transition;ga.transition=null;try{We=4,xm(e,t,n,r)}finally{We=i,ga.transition=s}}function xm(e,t,n,r){if(Uu){var i=mg(e,t,n,r);if(i===null)Xf(e,t,r,Hu,n),Uv(e,r);else if(eT(i,e,t,n,r))r.stopPropagation();else if(Uv(e,r),t&4&&-1<ZE.indexOf(e)){for(;i!==null;){var s=Yc(i);if(s!==null&&e2(s),s=mg(e,t,n,r),s===null&&Xf(e,t,r,Hu,n),s===i)break;i=s}i!==null&&r.stopPropagation()}else Xf(e,t,r,null,n)}}var Hu=null;function mg(e,t,n,r){if(Hu=null,e=pm(r),e=Wi(e),e!==null)if(t=ms(e),t===null)e=null;else if(n=t.tag,n===13){if(e=qw(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null);return Hu=e,null}function i2(e){switch(e){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(HE()){case fm:return 1;case Gw:return 4;case Bu:case VE:return 16;case Xw:return 536870912;default:return 16}default:return 16}}var Ko=null,mm=null,mu=null;function s2(){if(mu)return mu;var e,t=mm,n=t.length,r,i="value"in Ko?Ko.value:Ko.textContent,s=i.length;for(e=0;e<n&&t[e]===i[e];e++);var a=n-e;for(r=1;r<=a&&t[n-r]===i[s-r];r++);return mu=i.slice(e,1<r?1-r:void 0)}function vu(e){var t=e.keyCode;return"charCode"in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function Md(){return!0}function Vv(){return!1}function Pn(e){function t(n,r,i,s,a){this._reactName=n,this._targetInst=i,this.type=r,this.nativeEvent=s,this.target=a,this.currentTarget=null;for(var l in e)e.hasOwnProperty(l)&&(n=e[l],this[l]=n?n(s):s[l]);return this.isDefaultPrevented=(s.defaultPrevented!=null?s.defaultPrevented:s.returnValue===!1)?Md:Vv,this.isPropagationStopped=Vv,this}return dt(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var n=this.nativeEvent;n&&(n.preventDefault?n.preventDefault():typeof n.returnValue!="unknown"&&(n.returnValue=!1),this.isDefaultPrevented=Md)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=Md)},persist:function(){},isPersistent:Md}),t}var sl={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},vm=Pn(sl),Qc=dt({},sl,{view:0,detail:0}),oT=Pn(Qc),Wf,Uf,El,Op=dt({},Qc,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:ym,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return"movementX"in e?e.movementX:(e!==El&&(El&&e.type==="mousemove"?(Wf=e.screenX-El.screenX,Uf=e.screenY-El.screenY):Uf=Wf=0,El=e),Wf)},movementY:function(e){return"movementY"in e?e.movementY:Uf}}),qv=Pn(Op),iT=dt({},Op,{dataTransfer:0}),sT=Pn(iT),aT=dt({},Qc,{relatedTarget:0}),Hf=Pn(aT),lT=dt({},sl,{animationName:0,elapsedTime:0,pseudoElement:0}),cT=Pn(lT),dT=dt({},sl,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),uT=Pn(dT),pT=dt({},sl,{data:0}),Kv=Pn(pT),fT={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},hT={8:"Backspace",9:"Tab",12:"Clear",13:"Enter",16:"Shift",17:"Control",18:"Alt",19:"Pause",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",45:"Insert",46:"Delete",112:"F1",113:"F2",114:"F3",115:"F4",116:"F5",117:"F6",118:"F7",119:"F8",120:"F9",121:"F10",122:"F11",123:"F12",144:"NumLock",145:"ScrollLock",224:"Meta"},gT={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function xT(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=gT[e])?!!t[e]:!1}function ym(){return xT}var mT=dt({},Qc,{key:function(e){if(e.key){var t=fT[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=vu(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?hT[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:ym,charCode:function(e){return e.type==="keypress"?vu(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?vu(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),vT=Pn(mT),yT=dt({},Op,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Qv=Pn(yT),bT=dt({},Qc,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:ym}),jT=Pn(bT),wT=dt({},sl,{propertyName:0,elapsedTime:0,pseudoElement:0}),kT=Pn(wT),ST=dt({},Op,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),CT=Pn(ST),ET=[9,13,27,32],bm=no&&"CompositionEvent"in window,Yl=null;no&&"documentMode"in document&&(Yl=document.documentMode);var TT=no&&"TextEvent"in window&&!Yl,a2=no&&(!bm||Yl&&8<Yl&&11>=Yl),Yv=" ",Gv=!1;function l2(e,t){switch(e){case"keyup":return ET.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function c2(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var ea=!1;function PT(e,t){switch(e){case"compositionend":return c2(t);case"keypress":return t.which!==32?null:(Gv=!0,Yv);case"textInput":return e=t.data,e===Yv&&Gv?null:e;default:return null}}function RT(e,t){if(ea)return e==="compositionend"||!bm&&l2(e,t)?(e=s2(),mu=mm=Ko=null,ea=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return a2&&t.locale!=="ko"?null:t.data;default:return null}}var IT={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function Xv(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!IT[e.type]:t==="textarea"}function d2(e,t,n,r){Bw(r),t=Vu(t,"onChange"),0<t.length&&(n=new vm("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var Gl=null,mc=null;function MT(e){j2(e,0)}function Ap(e){var t=ra(e);if(Aw(t))return e}function LT(e,t){if(e==="change")return t}var u2=!1;if(no){var Vf;if(no){var qf="oninput"in document;if(!qf){var Jv=document.createElement("div");Jv.setAttribute("oninput","return;"),qf=typeof Jv.oninput=="function"}Vf=qf}else Vf=!1;u2=Vf&&(!document.documentMode||9<document.documentMode)}function Zv(){Gl&&(Gl.detachEvent("onpropertychange",p2),mc=Gl=null)}function p2(e){if(e.propertyName==="value"&&Ap(mc)){var t=[];d2(t,mc,e,pm(e)),Vw(MT,t)}}function OT(e,t,n){e==="focusin"?(Zv(),Gl=t,mc=n,Gl.attachEvent("onpropertychange",p2)):e==="focusout"&&Zv()}function AT(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Ap(mc)}function DT(e,t){if(e==="click")return Ap(t)}function NT(e,t){if(e==="input"||e==="change")return Ap(t)}function _T(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var or=typeof Object.is=="function"?Object.is:_T;function vc(e,t){if(or(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var i=n[r];if(!Zh.call(t,i)||!or(e[i],t[i]))return!1}return!0}function ey(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function ty(e,t){var n=ey(e);e=0;for(var r;n;){if(n.nodeType===3){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}e:{for(;n;){if(n.nextSibling){n=n.nextSibling;break e}n=n.parentNode}n=void 0}n=ey(n)}}function f2(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?f2(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function h2(){for(var e=window,t=$u();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=$u(e.document)}return t}function jm(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t==="input"&&(e.type==="text"||e.type==="search"||e.type==="tel"||e.type==="url"||e.type==="password")||t==="textarea"||e.contentEditable==="true")}function $T(e){var t=h2(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&f2(n.ownerDocument.documentElement,n)){if(r!==null&&jm(n)){if(t=r.start,e=r.end,e===void 0&&(e=t),"selectionStart"in n)n.selectionStart=t,n.selectionEnd=Math.min(e,n.value.length);else if(e=(t=n.ownerDocument||document)&&t.defaultView||window,e.getSelection){e=e.getSelection();var i=n.textContent.length,s=Math.min(r.start,i);r=r.end===void 0?s:Math.min(r.end,i),!e.extend&&s>r&&(i=r,r=s,s=i),i=ty(n,s);var a=ty(n,r);i&&a&&(e.rangeCount!==1||e.anchorNode!==i.node||e.anchorOffset!==i.offset||e.focusNode!==a.node||e.focusOffset!==a.offset)&&(t=t.createRange(),t.setStart(i.node,i.offset),e.removeAllRanges(),s>r?(e.addRange(t),e.extend(a.node,a.offset)):(t.setEnd(a.node,a.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n<t.length;n++)e=t[n],e.element.scrollLeft=e.left,e.element.scrollTop=e.top}}var FT=no&&"documentMode"in document&&11>=document.documentMode,ta=null,vg=null,Xl=null,yg=!1;function ny(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;yg||ta==null||ta!==$u(r)||(r=ta,"selectionStart"in r&&jm(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Xl&&vc(Xl,r)||(Xl=r,r=Vu(vg,"onSelect"),0<r.length&&(t=new vm("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=ta)))}function Ld(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var na={animationend:Ld("Animation","AnimationEnd"),animationiteration:Ld("Animation","AnimationIteration"),animationstart:Ld("Animation","AnimationStart"),transitionend:Ld("Transition","TransitionEnd")},Kf={},g2={};no&&(g2=document.createElement("div").style,"AnimationEvent"in window||(delete na.animationend.animation,delete na.animationiteration.animation,delete na.animationstart.animation),"TransitionEvent"in window||delete na.transitionend.transition);function Dp(e){if(Kf[e])return Kf[e];if(!na[e])return e;var t=na[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in g2)return Kf[e]=t[n];return e}var x2=Dp("animationend"),m2=Dp("animationiteration"),v2=Dp("animationstart"),y2=Dp("transitionend"),b2=new Map,ry="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function xi(e,t){b2.set(e,t),xs(t,[e])}for(var Qf=0;Qf<ry.length;Qf++){var Yf=ry[Qf],zT=Yf.toLowerCase(),BT=Yf[0].toUpperCase()+Yf.slice(1);xi(zT,"on"+BT)}xi(x2,"onAnimationEnd");xi(m2,"onAnimationIteration");xi(v2,"onAnimationStart");xi("dblclick","onDoubleClick");xi("focusin","onFocus");xi("focusout","onBlur");xi(y2,"onTransitionEnd");_a("onMouseEnter",["mouseout","mouseover"]);_a("onMouseLeave",["mouseout","mouseover"]);_a("onPointerEnter",["pointerout","pointerover"]);_a("onPointerLeave",["pointerout","pointerover"]);xs("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));xs("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));xs("onBeforeInput",["compositionend","keypress","textInput","paste"]);xs("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));xs("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));xs("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Fl="abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting".split(" "),WT=new Set("cancel close invalid load scroll toggle".split(" ").concat(Fl));function oy(e,t,n){var r=e.type||"unknown-event";e.currentTarget=n,zE(r,t,void 0,e),e.currentTarget=null}function j2(e,t){t=(t&4)!==0;for(var n=0;n<e.length;n++){var r=e[n],i=r.event;r=r.listeners;e:{var s=void 0;if(t)for(var a=r.length-1;0<=a;a--){var l=r[a],c=l.instance,d=l.currentTarget;if(l=l.listener,c!==s&&i.isPropagationStopped())break e;oy(i,l,d),s=c}else for(a=0;a<r.length;a++){if(l=r[a],c=l.instance,d=l.currentTarget,l=l.listener,c!==s&&i.isPropagationStopped())break e;oy(i,l,d),s=c}}}if(zu)throw e=hg,zu=!1,hg=null,e}function Je(e,t){var n=t[Sg];n===void 0&&(n=t[Sg]=new Set);var r=e+"__bubble";n.has(r)||(w2(t,e,2,!1),n.add(r))}function Gf(e,t,n){var r=0;t&&(r|=4),w2(n,e,r,t)}var Od="_reactListening"+Math.random().toString(36).slice(2);function yc(e){if(!e[Od]){e[Od]=!0,Rw.forEach(function(n){n!=="selectionchange"&&(WT.has(n)||Gf(n,!1,e),Gf(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Od]||(t[Od]=!0,Gf("selectionchange",!1,t))}}function w2(e,t,n,r){switch(i2(t)){case 1:var i=nT;break;case 4:i=rT;break;default:i=xm}n=i.bind(null,t,n,e),i=void 0,!fg||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(i=!0),r?i!==void 0?e.addEventListener(t,n,{capture:!0,passive:i}):e.addEventListener(t,n,!0):i!==void 0?e.addEventListener(t,n,{passive:i}):e.addEventListener(t,n,!1)}function Xf(e,t,n,r,i){var s=r;if(!(t&1)&&!(t&2)&&r!==null)e:for(;;){if(r===null)return;var a=r.tag;if(a===3||a===4){var l=r.stateNode.containerInfo;if(l===i||l.nodeType===8&&l.parentNode===i)break;if(a===4)for(a=r.return;a!==null;){var c=a.tag;if((c===3||c===4)&&(c=a.stateNode.containerInfo,c===i||c.nodeType===8&&c.parentNode===i))return;a=a.return}for(;l!==null;){if(a=Wi(l),a===null)return;if(c=a.tag,c===5||c===6){r=s=a;continue e}l=l.parentNode}}r=r.return}Vw(function(){var d=s,u=pm(n),f=[];e:{var h=b2.get(e);if(h!==void 0){var g=vm,v=e;switch(e){case"keypress":if(vu(n)===0)break e;case"keydown":case"keyup":g=vT;break;case"focusin":v="focus",g=Hf;break;case"focusout":v="blur",g=Hf;break;case"beforeblur":case"afterblur":g=Hf;break;case"click":if(n.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":g=qv;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":g=sT;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":g=jT;break;case x2:case m2:case v2:g=cT;break;case y2:g=kT;break;case"scroll":g=oT;break;case"wheel":g=CT;break;case"copy":case"cut":case"paste":g=uT;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":g=Qv}var x=(t&4)!==0,b=!x&&e==="scroll",j=x?h!==null?h+"Capture":null:h;x=[];for(var y=d,w;y!==null;){w=y;var k=w.stateNode;if(w.tag===5&&k!==null&&(w=k,j!==null&&(k=fc(y,j),k!=null&&x.push(bc(y,k,w)))),b)break;y=y.return}0<x.length&&(h=new g(h,v,null,n,u),f.push({event:h,listeners:x}))}}if(!(t&7)){e:{if(h=e==="mouseover"||e==="pointerover",g=e==="mouseout"||e==="pointerout",h&&n!==ug&&(v=n.relatedTarget||n.fromElement)&&(Wi(v)||v[ro]))break e;if((g||h)&&(h=u.window===u?u:(h=u.ownerDocument)?h.defaultView||h.parentWindow:window,g?(v=n.relatedTarget||n.toElement,g=d,v=v?Wi(v):null,v!==null&&(b=ms(v),v!==b||v.tag!==5&&v.tag!==6)&&(v=null)):(g=null,v=d),g!==v)){if(x=qv,k="onMouseLeave",j="onMouseEnter",y="mouse",(e==="pointerout"||e==="pointerover")&&(x=Qv,k="onPointerLeave",j="onPointerEnter",y="pointer"),b=g==null?h:ra(g),w=v==null?h:ra(v),h=new x(k,y+"leave",g,n,u),h.target=b,h.relatedTarget=w,k=null,Wi(u)===d&&(x=new x(j,y+"enter",v,n,u),x.target=w,x.relatedTarget=b,k=x),b=k,g&&v)t:{for(x=g,j=v,y=0,w=x;w;w=Ts(w))y++;for(w=0,k=j;k;k=Ts(k))w++;for(;0<y-w;)x=Ts(x),y--;for(;0<w-y;)j=Ts(j),w--;for(;y--;){if(x===j||j!==null&&x===j.alternate)break t;x=Ts(x),j=Ts(j)}x=null}else x=null;g!==null&&iy(f,h,g,x,!1),v!==null&&b!==null&&iy(f,b,v,x,!0)}}e:{if(h=d?ra(d):window,g=h.nodeName&&h.nodeName.toLowerCase(),g==="select"||g==="input"&&h.type==="file")var S=LT;else if(Xv(h))if(u2)S=NT;else{S=AT;var T=OT}else(g=h.nodeName)&&g.toLowerCase()==="input"&&(h.type==="checkbox"||h.type==="radio")&&(S=DT);if(S&&(S=S(e,d))){d2(f,S,n,u);break e}T&&T(e,h,d),e==="focusout"&&(T=h._wrapperState)&&T.controlled&&h.type==="number"&&sg(h,"number",h.value)}switch(T=d?ra(d):window,e){case"focusin":(Xv(T)||T.contentEditable==="true")&&(ta=T,vg=d,Xl=null);break;case"focusout":Xl=vg=ta=null;break;case"mousedown":yg=!0;break;case"contextmenu":case"mouseup":case"dragend":yg=!1,ny(f,n,u);break;case"selectionchange":if(FT)break;case"keydown":case"keyup":ny(f,n,u)}var C;if(bm)e:{switch(e){case"compositionstart":var P="onCompositionStart";break e;case"compositionend":P="onCompositionEnd";break e;case"compositionupdate":P="onCompositionUpdate";break e}P=void 0}else ea?l2(e,n)&&(P="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(P="onCompositionStart");P&&(a2&&n.locale!=="ko"&&(ea||P!=="onCompositionStart"?P==="onCompositionEnd"&&ea&&(C=s2()):(Ko=u,mm="value"in Ko?Ko.value:Ko.textContent,ea=!0)),T=Vu(d,P),0<T.length&&(P=new Kv(P,e,null,n,u),f.push({event:P,listeners:T}),C?P.data=C:(C=c2(n),C!==null&&(P.data=C)))),(C=TT?PT(e,n):RT(e,n))&&(d=Vu(d,"onBeforeInput"),0<d.length&&(u=new Kv("onBeforeInput","beforeinput",null,n,u),f.push({event:u,listeners:d}),u.data=C))}j2(f,t)})}function bc(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Vu(e,t){for(var n=t+"Capture",r=[];e!==null;){var i=e,s=i.stateNode;i.tag===5&&s!==null&&(i=s,s=fc(e,n),s!=null&&r.unshift(bc(e,s,i)),s=fc(e,t),s!=null&&r.push(bc(e,s,i))),e=e.return}return r}function Ts(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function iy(e,t,n,r,i){for(var s=t._reactName,a=[];n!==null&&n!==r;){var l=n,c=l.alternate,d=l.stateNode;if(c!==null&&c===r)break;l.tag===5&&d!==null&&(l=d,i?(c=fc(n,s),c!=null&&a.unshift(bc(n,c,l))):i||(c=fc(n,s),c!=null&&a.push(bc(n,c,l)))),n=n.return}a.length!==0&&e.push({event:t,listeners:a})}var UT=/\r\n?/g,HT=/\u0000|\uFFFD/g;function sy(e){return(typeof e=="string"?e:""+e).replace(UT,`
|
|
38
|
+
`).replace(HT,"")}function Ad(e,t,n){if(t=sy(t),sy(e)!==t&&n)throw Error(G(425))}function qu(){}var bg=null,jg=null;function wg(e,t){return e==="textarea"||e==="noscript"||typeof t.children=="string"||typeof t.children=="number"||typeof t.dangerouslySetInnerHTML=="object"&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var kg=typeof setTimeout=="function"?setTimeout:void 0,VT=typeof clearTimeout=="function"?clearTimeout:void 0,ay=typeof Promise=="function"?Promise:void 0,qT=typeof queueMicrotask=="function"?queueMicrotask:typeof ay<"u"?function(e){return ay.resolve(null).then(e).catch(KT)}:kg;function KT(e){setTimeout(function(){throw e})}function Jf(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8)if(n=i.data,n==="/$"){if(r===0){e.removeChild(i),xc(t);return}r--}else n!=="$"&&n!=="$?"&&n!=="$!"||r++;n=i}while(n);xc(t)}function ei(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t==="$"||t==="$!"||t==="$?")break;if(t==="/$")return null}}return e}function ly(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="$"||n==="$!"||n==="$?"){if(t===0)return e;t--}else n==="/$"&&t++}e=e.previousSibling}return null}var al=Math.random().toString(36).slice(2),Sr="__reactFiber$"+al,jc="__reactProps$"+al,ro="__reactContainer$"+al,Sg="__reactEvents$"+al,QT="__reactListeners$"+al,YT="__reactHandles$"+al;function Wi(e){var t=e[Sr];if(t)return t;for(var n=e.parentNode;n;){if(t=n[ro]||n[Sr]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=ly(e);e!==null;){if(n=e[Sr])return n;e=ly(e)}return t}e=n,n=e.parentNode}return null}function Yc(e){return e=e[Sr]||e[ro],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function ra(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(G(33))}function Np(e){return e[jc]||null}var Cg=[],oa=-1;function mi(e){return{current:e}}function et(e){0>oa||(e.current=Cg[oa],Cg[oa]=null,oa--)}function Qe(e,t){oa++,Cg[oa]=e.current,e.current=t}var di={},qt=mi(di),pn=mi(!1),is=di;function $a(e,t){var n=e.type.contextTypes;if(!n)return di;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var i={},s;for(s in n)i[s]=t[s];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=i),i}function fn(e){return e=e.childContextTypes,e!=null}function Ku(){et(pn),et(qt)}function cy(e,t,n){if(qt.current!==di)throw Error(G(168));Qe(qt,t),Qe(pn,n)}function k2(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var i in r)if(!(i in t))throw Error(G(108,OE(e)||"Unknown",i));return dt({},n,r)}function Qu(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||di,is=qt.current,Qe(qt,e),Qe(pn,pn.current),!0}function dy(e,t,n){var r=e.stateNode;if(!r)throw Error(G(169));n?(e=k2(e,t,is),r.__reactInternalMemoizedMergedChildContext=e,et(pn),et(qt),Qe(qt,e)):et(pn),Qe(pn,n)}var Vr=null,_p=!1,Zf=!1;function S2(e){Vr===null?Vr=[e]:Vr.push(e)}function GT(e){_p=!0,S2(e)}function vi(){if(!Zf&&Vr!==null){Zf=!0;var e=0,t=We;try{var n=Vr;for(We=1;e<n.length;e++){var r=n[e];do r=r(!0);while(r!==null)}Vr=null,_p=!1}catch(i){throw Vr!==null&&(Vr=Vr.slice(e+1)),Yw(fm,vi),i}finally{We=t,Zf=!1}}return null}var ia=[],sa=0,Yu=null,Gu=0,An=[],Dn=0,ss=null,Jr=1,Zr="";function Di(e,t){ia[sa++]=Gu,ia[sa++]=Yu,Yu=e,Gu=t}function C2(e,t,n){An[Dn++]=Jr,An[Dn++]=Zr,An[Dn++]=ss,ss=e;var r=Jr;e=Zr;var i=32-tr(r)-1;r&=~(1<<i),n+=1;var s=32-tr(t)+i;if(30<s){var a=i-i%5;s=(r&(1<<a)-1).toString(32),r>>=a,i-=a,Jr=1<<32-tr(t)+i|n<<i|r,Zr=s+e}else Jr=1<<s|n<<i|r,Zr=e}function wm(e){e.return!==null&&(Di(e,1),C2(e,1,0))}function km(e){for(;e===Yu;)Yu=ia[--sa],ia[sa]=null,Gu=ia[--sa],ia[sa]=null;for(;e===ss;)ss=An[--Dn],An[Dn]=null,Zr=An[--Dn],An[Dn]=null,Jr=An[--Dn],An[Dn]=null}var wn=null,jn=null,rt=!1,Zn=null;function E2(e,t){var n=Nn(5,null,null,0);n.elementType="DELETED",n.stateNode=t,n.return=e,t=e.deletions,t===null?(e.deletions=[n],e.flags|=16):t.push(n)}function uy(e,t){switch(e.tag){case 5:var n=e.type;return t=t.nodeType!==1||n.toLowerCase()!==t.nodeName.toLowerCase()?null:t,t!==null?(e.stateNode=t,wn=e,jn=ei(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,wn=e,jn=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(n=ss!==null?{id:Jr,overflow:Zr}:null,e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},n=Nn(18,null,null,0),n.stateNode=t,n.return=e,e.child=n,wn=e,jn=null,!0):!1;default:return!1}}function Eg(e){return(e.mode&1)!==0&&(e.flags&128)===0}function Tg(e){if(rt){var t=jn;if(t){var n=t;if(!uy(e,t)){if(Eg(e))throw Error(G(418));t=ei(n.nextSibling);var r=wn;t&&uy(e,t)?E2(r,n):(e.flags=e.flags&-4097|2,rt=!1,wn=e)}}else{if(Eg(e))throw Error(G(418));e.flags=e.flags&-4097|2,rt=!1,wn=e}}}function py(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;wn=e}function Dd(e){if(e!==wn)return!1;if(!rt)return py(e),rt=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!wg(e.type,e.memoizedProps)),t&&(t=jn)){if(Eg(e))throw T2(),Error(G(418));for(;t;)E2(e,t),t=ei(t.nextSibling)}if(py(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(G(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"){if(t===0){jn=ei(e.nextSibling);break e}t--}else n!=="$"&&n!=="$!"&&n!=="$?"||t++}e=e.nextSibling}jn=null}}else jn=wn?ei(e.stateNode.nextSibling):null;return!0}function T2(){for(var e=jn;e;)e=ei(e.nextSibling)}function Fa(){jn=wn=null,rt=!1}function Sm(e){Zn===null?Zn=[e]:Zn.push(e)}var XT=co.ReactCurrentBatchConfig;function Tl(e,t,n){if(e=n.ref,e!==null&&typeof e!="function"&&typeof e!="object"){if(n._owner){if(n=n._owner,n){if(n.tag!==1)throw Error(G(309));var r=n.stateNode}if(!r)throw Error(G(147,e));var i=r,s=""+e;return t!==null&&t.ref!==null&&typeof t.ref=="function"&&t.ref._stringRef===s?t.ref:(t=function(a){var l=i.refs;a===null?delete l[s]:l[s]=a},t._stringRef=s,t)}if(typeof e!="string")throw Error(G(284));if(!n._owner)throw Error(G(290,e))}return e}function Nd(e,t){throw e=Object.prototype.toString.call(t),Error(G(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function fy(e){var t=e._init;return t(e._payload)}function P2(e){function t(j,y){if(e){var w=j.deletions;w===null?(j.deletions=[y],j.flags|=16):w.push(y)}}function n(j,y){if(!e)return null;for(;y!==null;)t(j,y),y=y.sibling;return null}function r(j,y){for(j=new Map;y!==null;)y.key!==null?j.set(y.key,y):j.set(y.index,y),y=y.sibling;return j}function i(j,y){return j=oi(j,y),j.index=0,j.sibling=null,j}function s(j,y,w){return j.index=w,e?(w=j.alternate,w!==null?(w=w.index,w<y?(j.flags|=2,y):w):(j.flags|=2,y)):(j.flags|=1048576,y)}function a(j){return e&&j.alternate===null&&(j.flags|=2),j}function l(j,y,w,k){return y===null||y.tag!==6?(y=sh(w,j.mode,k),y.return=j,y):(y=i(y,w),y.return=j,y)}function c(j,y,w,k){var S=w.type;return S===Zs?u(j,y,w.props.children,k,w.key):y!==null&&(y.elementType===S||typeof S=="object"&&S!==null&&S.$$typeof===Lo&&fy(S)===y.type)?(k=i(y,w.props),k.ref=Tl(j,y,w),k.return=j,k):(k=Cu(w.type,w.key,w.props,null,j.mode,k),k.ref=Tl(j,y,w),k.return=j,k)}function d(j,y,w,k){return y===null||y.tag!==4||y.stateNode.containerInfo!==w.containerInfo||y.stateNode.implementation!==w.implementation?(y=ah(w,j.mode,k),y.return=j,y):(y=i(y,w.children||[]),y.return=j,y)}function u(j,y,w,k,S){return y===null||y.tag!==7?(y=rs(w,j.mode,k,S),y.return=j,y):(y=i(y,w),y.return=j,y)}function f(j,y,w){if(typeof y=="string"&&y!==""||typeof y=="number")return y=sh(""+y,j.mode,w),y.return=j,y;if(typeof y=="object"&&y!==null){switch(y.$$typeof){case Cd:return w=Cu(y.type,y.key,y.props,null,j.mode,w),w.ref=Tl(j,null,y),w.return=j,w;case Js:return y=ah(y,j.mode,w),y.return=j,y;case Lo:var k=y._init;return f(j,k(y._payload),w)}if(_l(y)||wl(y))return y=rs(y,j.mode,w,null),y.return=j,y;Nd(j,y)}return null}function h(j,y,w,k){var S=y!==null?y.key:null;if(typeof w=="string"&&w!==""||typeof w=="number")return S!==null?null:l(j,y,""+w,k);if(typeof w=="object"&&w!==null){switch(w.$$typeof){case Cd:return w.key===S?c(j,y,w,k):null;case Js:return w.key===S?d(j,y,w,k):null;case Lo:return S=w._init,h(j,y,S(w._payload),k)}if(_l(w)||wl(w))return S!==null?null:u(j,y,w,k,null);Nd(j,w)}return null}function g(j,y,w,k,S){if(typeof k=="string"&&k!==""||typeof k=="number")return j=j.get(w)||null,l(y,j,""+k,S);if(typeof k=="object"&&k!==null){switch(k.$$typeof){case Cd:return j=j.get(k.key===null?w:k.key)||null,c(y,j,k,S);case Js:return j=j.get(k.key===null?w:k.key)||null,d(y,j,k,S);case Lo:var T=k._init;return g(j,y,w,T(k._payload),S)}if(_l(k)||wl(k))return j=j.get(w)||null,u(y,j,k,S,null);Nd(y,k)}return null}function v(j,y,w,k){for(var S=null,T=null,C=y,P=y=0,I=null;C!==null&&P<w.length;P++){C.index>P?(I=C,C=null):I=C.sibling;var L=h(j,C,w[P],k);if(L===null){C===null&&(C=I);break}e&&C&&L.alternate===null&&t(j,C),y=s(L,y,P),T===null?S=L:T.sibling=L,T=L,C=I}if(P===w.length)return n(j,C),rt&&Di(j,P),S;if(C===null){for(;P<w.length;P++)C=f(j,w[P],k),C!==null&&(y=s(C,y,P),T===null?S=C:T.sibling=C,T=C);return rt&&Di(j,P),S}for(C=r(j,C);P<w.length;P++)I=g(C,j,P,w[P],k),I!==null&&(e&&I.alternate!==null&&C.delete(I.key===null?P:I.key),y=s(I,y,P),T===null?S=I:T.sibling=I,T=I);return e&&C.forEach(function(z){return t(j,z)}),rt&&Di(j,P),S}function x(j,y,w,k){var S=wl(w);if(typeof S!="function")throw Error(G(150));if(w=S.call(w),w==null)throw Error(G(151));for(var T=S=null,C=y,P=y=0,I=null,L=w.next();C!==null&&!L.done;P++,L=w.next()){C.index>P?(I=C,C=null):I=C.sibling;var z=h(j,C,L.value,k);if(z===null){C===null&&(C=I);break}e&&C&&z.alternate===null&&t(j,C),y=s(z,y,P),T===null?S=z:T.sibling=z,T=z,C=I}if(L.done)return n(j,C),rt&&Di(j,P),S;if(C===null){for(;!L.done;P++,L=w.next())L=f(j,L.value,k),L!==null&&(y=s(L,y,P),T===null?S=L:T.sibling=L,T=L);return rt&&Di(j,P),S}for(C=r(j,C);!L.done;P++,L=w.next())L=g(C,j,P,L.value,k),L!==null&&(e&&L.alternate!==null&&C.delete(L.key===null?P:L.key),y=s(L,y,P),T===null?S=L:T.sibling=L,T=L);return e&&C.forEach(function(q){return t(j,q)}),rt&&Di(j,P),S}function b(j,y,w,k){if(typeof w=="object"&&w!==null&&w.type===Zs&&w.key===null&&(w=w.props.children),typeof w=="object"&&w!==null){switch(w.$$typeof){case Cd:e:{for(var S=w.key,T=y;T!==null;){if(T.key===S){if(S=w.type,S===Zs){if(T.tag===7){n(j,T.sibling),y=i(T,w.props.children),y.return=j,j=y;break e}}else if(T.elementType===S||typeof S=="object"&&S!==null&&S.$$typeof===Lo&&fy(S)===T.type){n(j,T.sibling),y=i(T,w.props),y.ref=Tl(j,T,w),y.return=j,j=y;break e}n(j,T);break}else t(j,T);T=T.sibling}w.type===Zs?(y=rs(w.props.children,j.mode,k,w.key),y.return=j,j=y):(k=Cu(w.type,w.key,w.props,null,j.mode,k),k.ref=Tl(j,y,w),k.return=j,j=k)}return a(j);case Js:e:{for(T=w.key;y!==null;){if(y.key===T)if(y.tag===4&&y.stateNode.containerInfo===w.containerInfo&&y.stateNode.implementation===w.implementation){n(j,y.sibling),y=i(y,w.children||[]),y.return=j,j=y;break e}else{n(j,y);break}else t(j,y);y=y.sibling}y=ah(w,j.mode,k),y.return=j,j=y}return a(j);case Lo:return T=w._init,b(j,y,T(w._payload),k)}if(_l(w))return v(j,y,w,k);if(wl(w))return x(j,y,w,k);Nd(j,w)}return typeof w=="string"&&w!==""||typeof w=="number"?(w=""+w,y!==null&&y.tag===6?(n(j,y.sibling),y=i(y,w),y.return=j,j=y):(n(j,y),y=sh(w,j.mode,k),y.return=j,j=y),a(j)):n(j,y)}return b}var za=P2(!0),R2=P2(!1),Xu=mi(null),Ju=null,aa=null,Cm=null;function Em(){Cm=aa=Ju=null}function Tm(e){var t=Xu.current;et(Xu),e._currentValue=t}function Pg(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)!==t?(e.childLanes|=t,r!==null&&(r.childLanes|=t)):r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t),e===n)break;e=e.return}}function xa(e,t){Ju=e,Cm=aa=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(un=!0),e.firstContext=null)}function Fn(e){var t=e._currentValue;if(Cm!==e)if(e={context:e,memoizedValue:t,next:null},aa===null){if(Ju===null)throw Error(G(308));aa=e,Ju.dependencies={lanes:0,firstContext:e}}else aa=aa.next=e;return t}var Ui=null;function Pm(e){Ui===null?Ui=[e]:Ui.push(e)}function I2(e,t,n,r){var i=t.interleaved;return i===null?(n.next=n,Pm(t)):(n.next=i.next,i.next=n),t.interleaved=n,oo(e,r)}function oo(e,t){e.lanes|=t;var n=e.alternate;for(n!==null&&(n.lanes|=t),n=e,e=e.return;e!==null;)e.childLanes|=t,n=e.alternate,n!==null&&(n.childLanes|=t),n=e,e=e.return;return n.tag===3?n.stateNode:null}var Oo=!1;function Rm(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function M2(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,effects:e.effects})}function eo(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function ti(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,_e&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,oo(e,n)}return i=r.interleaved,i===null?(t.next=t,Pm(r)):(t.next=i.next,i.next=t),r.interleaved=t,oo(e,n)}function yu(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,(n&4194240)!==0)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,hm(e,n)}}function hy(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,s=null;if(n=n.firstBaseUpdate,n!==null){do{var a={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};s===null?i=s=a:s=s.next=a,n=n.next}while(n!==null);s===null?i=s=t:s=s.next=t}else i=s=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:s,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function Zu(e,t,n,r){var i=e.updateQueue;Oo=!1;var s=i.firstBaseUpdate,a=i.lastBaseUpdate,l=i.shared.pending;if(l!==null){i.shared.pending=null;var c=l,d=c.next;c.next=null,a===null?s=d:a.next=d,a=c;var u=e.alternate;u!==null&&(u=u.updateQueue,l=u.lastBaseUpdate,l!==a&&(l===null?u.firstBaseUpdate=d:l.next=d,u.lastBaseUpdate=c))}if(s!==null){var f=i.baseState;a=0,u=d=c=null,l=s;do{var h=l.lane,g=l.eventTime;if((r&h)===h){u!==null&&(u=u.next={eventTime:g,lane:0,tag:l.tag,payload:l.payload,callback:l.callback,next:null});e:{var v=e,x=l;switch(h=t,g=n,x.tag){case 1:if(v=x.payload,typeof v=="function"){f=v.call(g,f,h);break e}f=v;break e;case 3:v.flags=v.flags&-65537|128;case 0:if(v=x.payload,h=typeof v=="function"?v.call(g,f,h):v,h==null)break e;f=dt({},f,h);break e;case 2:Oo=!0}}l.callback!==null&&l.lane!==0&&(e.flags|=64,h=i.effects,h===null?i.effects=[l]:h.push(l))}else g={eventTime:g,lane:h,tag:l.tag,payload:l.payload,callback:l.callback,next:null},u===null?(d=u=g,c=f):u=u.next=g,a|=h;if(l=l.next,l===null){if(l=i.shared.pending,l===null)break;h=l,l=h.next,h.next=null,i.lastBaseUpdate=h,i.shared.pending=null}}while(!0);if(u===null&&(c=f),i.baseState=c,i.firstBaseUpdate=d,i.lastBaseUpdate=u,t=i.shared.interleaved,t!==null){i=t;do a|=i.lane,i=i.next;while(i!==t)}else s===null&&(i.shared.lanes=0);ls|=a,e.lanes=a,e.memoizedState=f}}function gy(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;t<e.length;t++){var r=e[t],i=r.callback;if(i!==null){if(r.callback=null,r=n,typeof i!="function")throw Error(G(191,i));i.call(r)}}}var Gc={},Pr=mi(Gc),wc=mi(Gc),kc=mi(Gc);function Hi(e){if(e===Gc)throw Error(G(174));return e}function Im(e,t){switch(Qe(kc,t),Qe(wc,e),Qe(Pr,Gc),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:lg(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=lg(t,e)}et(Pr),Qe(Pr,t)}function Ba(){et(Pr),et(wc),et(kc)}function L2(e){Hi(kc.current);var t=Hi(Pr.current),n=lg(t,e.type);t!==n&&(Qe(wc,e),Qe(Pr,n))}function Mm(e){wc.current===e&&(et(Pr),et(wc))}var lt=mi(0);function ep(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||n.data==="$?"||n.data==="$!"))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==void 0){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var eh=[];function Lm(){for(var e=0;e<eh.length;e++)eh[e]._workInProgressVersionPrimary=null;eh.length=0}var bu=co.ReactCurrentDispatcher,th=co.ReactCurrentBatchConfig,as=0,ct=null,Et=null,It=null,tp=!1,Jl=!1,Sc=0,JT=0;function zt(){throw Error(G(321))}function Om(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!or(e[n],t[n]))return!1;return!0}function Am(e,t,n,r,i,s){if(as=s,ct=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,bu.current=e===null||e.memoizedState===null?nP:rP,e=n(r,i),Jl){s=0;do{if(Jl=!1,Sc=0,25<=s)throw Error(G(301));s+=1,It=Et=null,t.updateQueue=null,bu.current=oP,e=n(r,i)}while(Jl)}if(bu.current=np,t=Et!==null&&Et.next!==null,as=0,It=Et=ct=null,tp=!1,t)throw Error(G(300));return e}function Dm(){var e=Sc!==0;return Sc=0,e}function yr(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return It===null?ct.memoizedState=It=e:It=It.next=e,It}function zn(){if(Et===null){var e=ct.alternate;e=e!==null?e.memoizedState:null}else e=Et.next;var t=It===null?ct.memoizedState:It.next;if(t!==null)It=t,Et=e;else{if(e===null)throw Error(G(310));Et=e,e={memoizedState:Et.memoizedState,baseState:Et.baseState,baseQueue:Et.baseQueue,queue:Et.queue,next:null},It===null?ct.memoizedState=It=e:It=It.next=e}return It}function Cc(e,t){return typeof t=="function"?t(e):t}function nh(e){var t=zn(),n=t.queue;if(n===null)throw Error(G(311));n.lastRenderedReducer=e;var r=Et,i=r.baseQueue,s=n.pending;if(s!==null){if(i!==null){var a=i.next;i.next=s.next,s.next=a}r.baseQueue=i=s,n.pending=null}if(i!==null){s=i.next,r=r.baseState;var l=a=null,c=null,d=s;do{var u=d.lane;if((as&u)===u)c!==null&&(c=c.next={lane:0,action:d.action,hasEagerState:d.hasEagerState,eagerState:d.eagerState,next:null}),r=d.hasEagerState?d.eagerState:e(r,d.action);else{var f={lane:u,action:d.action,hasEagerState:d.hasEagerState,eagerState:d.eagerState,next:null};c===null?(l=c=f,a=r):c=c.next=f,ct.lanes|=u,ls|=u}d=d.next}while(d!==null&&d!==s);c===null?a=r:c.next=l,or(r,t.memoizedState)||(un=!0),t.memoizedState=r,t.baseState=a,t.baseQueue=c,n.lastRenderedState=r}if(e=n.interleaved,e!==null){i=e;do s=i.lane,ct.lanes|=s,ls|=s,i=i.next;while(i!==e)}else i===null&&(n.lanes=0);return[t.memoizedState,n.dispatch]}function rh(e){var t=zn(),n=t.queue;if(n===null)throw Error(G(311));n.lastRenderedReducer=e;var r=n.dispatch,i=n.pending,s=t.memoizedState;if(i!==null){n.pending=null;var a=i=i.next;do s=e(s,a.action),a=a.next;while(a!==i);or(s,t.memoizedState)||(un=!0),t.memoizedState=s,t.baseQueue===null&&(t.baseState=s),n.lastRenderedState=s}return[s,r]}function O2(){}function A2(e,t){var n=ct,r=zn(),i=t(),s=!or(r.memoizedState,i);if(s&&(r.memoizedState=i,un=!0),r=r.queue,Nm(_2.bind(null,n,r,e),[e]),r.getSnapshot!==t||s||It!==null&&It.memoizedState.tag&1){if(n.flags|=2048,Ec(9,N2.bind(null,n,r,i,t),void 0,null),Mt===null)throw Error(G(349));as&30||D2(n,t,i)}return i}function D2(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=ct.updateQueue,t===null?(t={lastEffect:null,stores:null},ct.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function N2(e,t,n,r){t.value=n,t.getSnapshot=r,$2(t)&&F2(e)}function _2(e,t,n){return n(function(){$2(t)&&F2(e)})}function $2(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!or(e,n)}catch{return!0}}function F2(e){var t=oo(e,1);t!==null&&nr(t,e,1,-1)}function xy(e){var t=yr();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Cc,lastRenderedState:e},t.queue=e,e=e.dispatch=tP.bind(null,ct,e),[t.memoizedState,e]}function Ec(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},t=ct.updateQueue,t===null?(t={lastEffect:null,stores:null},ct.updateQueue=t,t.lastEffect=e.next=e):(n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e)),e}function z2(){return zn().memoizedState}function ju(e,t,n,r){var i=yr();ct.flags|=e,i.memoizedState=Ec(1|t,n,void 0,r===void 0?null:r)}function $p(e,t,n,r){var i=zn();r=r===void 0?null:r;var s=void 0;if(Et!==null){var a=Et.memoizedState;if(s=a.destroy,r!==null&&Om(r,a.deps)){i.memoizedState=Ec(t,n,s,r);return}}ct.flags|=e,i.memoizedState=Ec(1|t,n,s,r)}function my(e,t){return ju(8390656,8,e,t)}function Nm(e,t){return $p(2048,8,e,t)}function B2(e,t){return $p(4,2,e,t)}function W2(e,t){return $p(4,4,e,t)}function U2(e,t){if(typeof t=="function")return e=e(),t(e),function(){t(null)};if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function H2(e,t,n){return n=n!=null?n.concat([e]):null,$p(4,4,U2.bind(null,t,e),n)}function _m(){}function V2(e,t){var n=zn();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&Om(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function q2(e,t){var n=zn();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&Om(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function K2(e,t,n){return as&21?(or(n,t)||(n=Jw(),ct.lanes|=n,ls|=n,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,un=!0),e.memoizedState=n)}function ZT(e,t){var n=We;We=n!==0&&4>n?n:4,e(!0);var r=th.transition;th.transition={};try{e(!1),t()}finally{We=n,th.transition=r}}function Q2(){return zn().memoizedState}function eP(e,t,n){var r=ri(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},Y2(e))G2(t,n);else if(n=I2(e,t,n,r),n!==null){var i=Zt();nr(n,e,r,i),X2(n,t,r)}}function tP(e,t,n){var r=ri(e),i={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(Y2(e))G2(t,i);else{var s=e.alternate;if(e.lanes===0&&(s===null||s.lanes===0)&&(s=t.lastRenderedReducer,s!==null))try{var a=t.lastRenderedState,l=s(a,n);if(i.hasEagerState=!0,i.eagerState=l,or(l,a)){var c=t.interleaved;c===null?(i.next=i,Pm(t)):(i.next=c.next,c.next=i),t.interleaved=i;return}}catch{}finally{}n=I2(e,t,i,r),n!==null&&(i=Zt(),nr(n,e,r,i),X2(n,t,r))}}function Y2(e){var t=e.alternate;return e===ct||t!==null&&t===ct}function G2(e,t){Jl=tp=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function X2(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,hm(e,n)}}var np={readContext:Fn,useCallback:zt,useContext:zt,useEffect:zt,useImperativeHandle:zt,useInsertionEffect:zt,useLayoutEffect:zt,useMemo:zt,useReducer:zt,useRef:zt,useState:zt,useDebugValue:zt,useDeferredValue:zt,useTransition:zt,useMutableSource:zt,useSyncExternalStore:zt,useId:zt,unstable_isNewReconciler:!1},nP={readContext:Fn,useCallback:function(e,t){return yr().memoizedState=[e,t===void 0?null:t],e},useContext:Fn,useEffect:my,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,ju(4194308,4,U2.bind(null,t,e),n)},useLayoutEffect:function(e,t){return ju(4194308,4,e,t)},useInsertionEffect:function(e,t){return ju(4,2,e,t)},useMemo:function(e,t){var n=yr();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=yr();return t=n!==void 0?n(t):t,r.memoizedState=r.baseState=t,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:t},r.queue=e,e=e.dispatch=eP.bind(null,ct,e),[r.memoizedState,e]},useRef:function(e){var t=yr();return e={current:e},t.memoizedState=e},useState:xy,useDebugValue:_m,useDeferredValue:function(e){return yr().memoizedState=e},useTransition:function(){var e=xy(!1),t=e[0];return e=ZT.bind(null,e[1]),yr().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=ct,i=yr();if(rt){if(n===void 0)throw Error(G(407));n=n()}else{if(n=t(),Mt===null)throw Error(G(349));as&30||D2(r,t,n)}i.memoizedState=n;var s={value:n,getSnapshot:t};return i.queue=s,my(_2.bind(null,r,s,e),[e]),r.flags|=2048,Ec(9,N2.bind(null,r,s,n,t),void 0,null),n},useId:function(){var e=yr(),t=Mt.identifierPrefix;if(rt){var n=Zr,r=Jr;n=(r&~(1<<32-tr(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=Sc++,0<n&&(t+="H"+n.toString(32)),t+=":"}else n=JT++,t=":"+t+"r"+n.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},rP={readContext:Fn,useCallback:V2,useContext:Fn,useEffect:Nm,useImperativeHandle:H2,useInsertionEffect:B2,useLayoutEffect:W2,useMemo:q2,useReducer:nh,useRef:z2,useState:function(){return nh(Cc)},useDebugValue:_m,useDeferredValue:function(e){var t=zn();return K2(t,Et.memoizedState,e)},useTransition:function(){var e=nh(Cc)[0],t=zn().memoizedState;return[e,t]},useMutableSource:O2,useSyncExternalStore:A2,useId:Q2,unstable_isNewReconciler:!1},oP={readContext:Fn,useCallback:V2,useContext:Fn,useEffect:Nm,useImperativeHandle:H2,useInsertionEffect:B2,useLayoutEffect:W2,useMemo:q2,useReducer:rh,useRef:z2,useState:function(){return rh(Cc)},useDebugValue:_m,useDeferredValue:function(e){var t=zn();return Et===null?t.memoizedState=e:K2(t,Et.memoizedState,e)},useTransition:function(){var e=rh(Cc)[0],t=zn().memoizedState;return[e,t]},useMutableSource:O2,useSyncExternalStore:A2,useId:Q2,unstable_isNewReconciler:!1};function Qn(e,t){if(e&&e.defaultProps){t=dt({},t),e=e.defaultProps;for(var n in e)t[n]===void 0&&(t[n]=e[n]);return t}return t}function Rg(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:dt({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var Fp={isMounted:function(e){return(e=e._reactInternals)?ms(e)===e:!1},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=Zt(),i=ri(e),s=eo(r,i);s.payload=t,n!=null&&(s.callback=n),t=ti(e,s,i),t!==null&&(nr(t,e,i,r),yu(t,e,i))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=Zt(),i=ri(e),s=eo(r,i);s.tag=1,s.payload=t,n!=null&&(s.callback=n),t=ti(e,s,i),t!==null&&(nr(t,e,i,r),yu(t,e,i))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Zt(),r=ri(e),i=eo(n,r);i.tag=2,t!=null&&(i.callback=t),t=ti(e,i,r),t!==null&&(nr(t,e,r,n),yu(t,e,r))}};function vy(e,t,n,r,i,s,a){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(r,s,a):t.prototype&&t.prototype.isPureReactComponent?!vc(n,r)||!vc(i,s):!0}function J2(e,t,n){var r=!1,i=di,s=t.contextType;return typeof s=="object"&&s!==null?s=Fn(s):(i=fn(t)?is:qt.current,r=t.contextTypes,s=(r=r!=null)?$a(e,i):di),t=new t(n,s),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=Fp,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=i,e.__reactInternalMemoizedMaskedChildContext=s),t}function yy(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps=="function"&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps=="function"&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&Fp.enqueueReplaceState(t,t.state,null)}function Ig(e,t,n,r){var i=e.stateNode;i.props=n,i.state=e.memoizedState,i.refs={},Rm(e);var s=t.contextType;typeof s=="object"&&s!==null?i.context=Fn(s):(s=fn(t)?is:qt.current,i.context=$a(e,s)),i.state=e.memoizedState,s=t.getDerivedStateFromProps,typeof s=="function"&&(Rg(e,t,s,n),i.state=e.memoizedState),typeof t.getDerivedStateFromProps=="function"||typeof i.getSnapshotBeforeUpdate=="function"||typeof i.UNSAFE_componentWillMount!="function"&&typeof i.componentWillMount!="function"||(t=i.state,typeof i.componentWillMount=="function"&&i.componentWillMount(),typeof i.UNSAFE_componentWillMount=="function"&&i.UNSAFE_componentWillMount(),t!==i.state&&Fp.enqueueReplaceState(i,i.state,null),Zu(e,n,i,r),i.state=e.memoizedState),typeof i.componentDidMount=="function"&&(e.flags|=4194308)}function Wa(e,t){try{var n="",r=t;do n+=LE(r),r=r.return;while(r);var i=n}catch(s){i=`
|
|
39
|
+
Error generating stack: `+s.message+`
|
|
40
|
+
`+s.stack}return{value:e,source:t,stack:i,digest:null}}function oh(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function Mg(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var iP=typeof WeakMap=="function"?WeakMap:Map;function Z2(e,t,n){n=eo(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){op||(op=!0,Bg=r),Mg(e,t)},n}function ek(e,t,n){n=eo(-1,n),n.tag=3;var r=e.type.getDerivedStateFromError;if(typeof r=="function"){var i=t.value;n.payload=function(){return r(i)},n.callback=function(){Mg(e,t)}}var s=e.stateNode;return s!==null&&typeof s.componentDidCatch=="function"&&(n.callback=function(){Mg(e,t),typeof r!="function"&&(ni===null?ni=new Set([this]):ni.add(this));var a=t.stack;this.componentDidCatch(t.value,{componentStack:a!==null?a:""})}),n}function by(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new iP;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(i.add(n),e=yP.bind(null,e,t,n),t.then(e,e))}function jy(e){do{var t;if((t=e.tag===13)&&(t=e.memoizedState,t=t!==null?t.dehydrated!==null:!0),t)return e;e=e.return}while(e!==null);return null}function wy(e,t,n,r,i){return e.mode&1?(e.flags|=65536,e.lanes=i,e):(e===t?e.flags|=65536:(e.flags|=128,n.flags|=131072,n.flags&=-52805,n.tag===1&&(n.alternate===null?n.tag=17:(t=eo(-1,1),t.tag=2,ti(n,t,1))),n.lanes|=1),e)}var sP=co.ReactCurrentOwner,un=!1;function Gt(e,t,n,r){t.child=e===null?R2(t,null,n,r):za(t,e.child,n,r)}function ky(e,t,n,r,i){n=n.render;var s=t.ref;return xa(t,i),r=Am(e,t,n,r,s,i),n=Dm(),e!==null&&!un?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i,io(e,t,i)):(rt&&n&&wm(t),t.flags|=1,Gt(e,t,r,i),t.child)}function Sy(e,t,n,r,i){if(e===null){var s=n.type;return typeof s=="function"&&!Vm(s)&&s.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=s,tk(e,t,s,r,i)):(e=Cu(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(s=e.child,!(e.lanes&i)){var a=s.memoizedProps;if(n=n.compare,n=n!==null?n:vc,n(a,r)&&e.ref===t.ref)return io(e,t,i)}return t.flags|=1,e=oi(s,r),e.ref=t.ref,e.return=t,t.child=e}function tk(e,t,n,r,i){if(e!==null){var s=e.memoizedProps;if(vc(s,r)&&e.ref===t.ref)if(un=!1,t.pendingProps=r=s,(e.lanes&i)!==0)e.flags&131072&&(un=!0);else return t.lanes=e.lanes,io(e,t,i)}return Lg(e,t,n,r,i)}function nk(e,t,n){var r=t.pendingProps,i=r.children,s=e!==null?e.memoizedState:null;if(r.mode==="hidden")if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},Qe(ca,xn),xn|=n;else{if(!(n&1073741824))return e=s!==null?s.baseLanes|n:n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,Qe(ca,xn),xn|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=s!==null?s.baseLanes:n,Qe(ca,xn),xn|=r}else s!==null?(r=s.baseLanes|n,t.memoizedState=null):r=n,Qe(ca,xn),xn|=r;return Gt(e,t,i,n),t.child}function rk(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function Lg(e,t,n,r,i){var s=fn(n)?is:qt.current;return s=$a(t,s),xa(t,i),n=Am(e,t,n,r,s,i),r=Dm(),e!==null&&!un?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i,io(e,t,i)):(rt&&r&&wm(t),t.flags|=1,Gt(e,t,n,i),t.child)}function Cy(e,t,n,r,i){if(fn(n)){var s=!0;Qu(t)}else s=!1;if(xa(t,i),t.stateNode===null)wu(e,t),J2(t,n,r),Ig(t,n,r,i),r=!0;else if(e===null){var a=t.stateNode,l=t.memoizedProps;a.props=l;var c=a.context,d=n.contextType;typeof d=="object"&&d!==null?d=Fn(d):(d=fn(n)?is:qt.current,d=$a(t,d));var u=n.getDerivedStateFromProps,f=typeof u=="function"||typeof a.getSnapshotBeforeUpdate=="function";f||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(l!==r||c!==d)&&yy(t,a,r,d),Oo=!1;var h=t.memoizedState;a.state=h,Zu(t,r,a,i),c=t.memoizedState,l!==r||h!==c||pn.current||Oo?(typeof u=="function"&&(Rg(t,n,u,r),c=t.memoizedState),(l=Oo||vy(t,n,l,r,h,c,d))?(f||typeof a.UNSAFE_componentWillMount!="function"&&typeof a.componentWillMount!="function"||(typeof a.componentWillMount=="function"&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount=="function"&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount=="function"&&(t.flags|=4194308)):(typeof a.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=c),a.props=r,a.state=c,a.context=d,r=l):(typeof a.componentDidMount=="function"&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,M2(e,t),l=t.memoizedProps,d=t.type===t.elementType?l:Qn(t.type,l),a.props=d,f=t.pendingProps,h=a.context,c=n.contextType,typeof c=="object"&&c!==null?c=Fn(c):(c=fn(n)?is:qt.current,c=$a(t,c));var g=n.getDerivedStateFromProps;(u=typeof g=="function"||typeof a.getSnapshotBeforeUpdate=="function")||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(l!==f||h!==c)&&yy(t,a,r,c),Oo=!1,h=t.memoizedState,a.state=h,Zu(t,r,a,i);var v=t.memoizedState;l!==f||h!==v||pn.current||Oo?(typeof g=="function"&&(Rg(t,n,g,r),v=t.memoizedState),(d=Oo||vy(t,n,d,r,h,v,c)||!1)?(u||typeof a.UNSAFE_componentWillUpdate!="function"&&typeof a.componentWillUpdate!="function"||(typeof a.componentWillUpdate=="function"&&a.componentWillUpdate(r,v,c),typeof a.UNSAFE_componentWillUpdate=="function"&&a.UNSAFE_componentWillUpdate(r,v,c)),typeof a.componentDidUpdate=="function"&&(t.flags|=4),typeof a.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof a.componentDidUpdate!="function"||l===e.memoizedProps&&h===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!="function"||l===e.memoizedProps&&h===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=v),a.props=r,a.state=v,a.context=c,r=d):(typeof a.componentDidUpdate!="function"||l===e.memoizedProps&&h===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!="function"||l===e.memoizedProps&&h===e.memoizedState||(t.flags|=1024),r=!1)}return Og(e,t,n,r,s,i)}function Og(e,t,n,r,i,s){rk(e,t);var a=(t.flags&128)!==0;if(!r&&!a)return i&&dy(t,n,!1),io(e,t,s);r=t.stateNode,sP.current=t;var l=a&&typeof n.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&a?(t.child=za(t,e.child,null,s),t.child=za(t,null,l,s)):Gt(e,t,l,s),t.memoizedState=r.state,i&&dy(t,n,!0),t.child}function ok(e){var t=e.stateNode;t.pendingContext?cy(e,t.pendingContext,t.pendingContext!==t.context):t.context&&cy(e,t.context,!1),Im(e,t.containerInfo)}function Ey(e,t,n,r,i){return Fa(),Sm(i),t.flags|=256,Gt(e,t,n,r),t.child}var Ag={dehydrated:null,treeContext:null,retryLane:0};function Dg(e){return{baseLanes:e,cachePool:null,transitions:null}}function ik(e,t,n){var r=t.pendingProps,i=lt.current,s=!1,a=(t.flags&128)!==0,l;if((l=a)||(l=e!==null&&e.memoizedState===null?!1:(i&2)!==0),l?(s=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(i|=1),Qe(lt,i&1),e===null)return Tg(t),e=t.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?(t.mode&1?e.data==="$!"?t.lanes=8:t.lanes=1073741824:t.lanes=1,null):(a=r.children,e=r.fallback,s?(r=t.mode,s=t.child,a={mode:"hidden",children:a},!(r&1)&&s!==null?(s.childLanes=0,s.pendingProps=a):s=Wp(a,r,0,null),e=rs(e,r,n,null),s.return=t,e.return=t,s.sibling=e,t.child=s,t.child.memoizedState=Dg(n),t.memoizedState=Ag,e):$m(t,a));if(i=e.memoizedState,i!==null&&(l=i.dehydrated,l!==null))return aP(e,t,a,r,l,i,n);if(s){s=r.fallback,a=t.mode,i=e.child,l=i.sibling;var c={mode:"hidden",children:r.children};return!(a&1)&&t.child!==i?(r=t.child,r.childLanes=0,r.pendingProps=c,t.deletions=null):(r=oi(i,c),r.subtreeFlags=i.subtreeFlags&14680064),l!==null?s=oi(l,s):(s=rs(s,a,n,null),s.flags|=2),s.return=t,r.return=t,r.sibling=s,t.child=r,r=s,s=t.child,a=e.child.memoizedState,a=a===null?Dg(n):{baseLanes:a.baseLanes|n,cachePool:null,transitions:a.transitions},s.memoizedState=a,s.childLanes=e.childLanes&~n,t.memoizedState=Ag,r}return s=e.child,e=s.sibling,r=oi(s,{mode:"visible",children:r.children}),!(t.mode&1)&&(r.lanes=n),r.return=t,r.sibling=null,e!==null&&(n=t.deletions,n===null?(t.deletions=[e],t.flags|=16):n.push(e)),t.child=r,t.memoizedState=null,r}function $m(e,t){return t=Wp({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function _d(e,t,n,r){return r!==null&&Sm(r),za(t,e.child,null,n),e=$m(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function aP(e,t,n,r,i,s,a){if(n)return t.flags&256?(t.flags&=-257,r=oh(Error(G(422))),_d(e,t,a,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(s=r.fallback,i=t.mode,r=Wp({mode:"visible",children:r.children},i,0,null),s=rs(s,i,a,null),s.flags|=2,r.return=t,s.return=t,r.sibling=s,t.child=r,t.mode&1&&za(t,e.child,null,a),t.child.memoizedState=Dg(a),t.memoizedState=Ag,s);if(!(t.mode&1))return _d(e,t,a,null);if(i.data==="$!"){if(r=i.nextSibling&&i.nextSibling.dataset,r)var l=r.dgst;return r=l,s=Error(G(419)),r=oh(s,r,void 0),_d(e,t,a,r)}if(l=(a&e.childLanes)!==0,un||l){if(r=Mt,r!==null){switch(a&-a){case 4:i=2;break;case 16:i=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:i=32;break;case 536870912:i=268435456;break;default:i=0}i=i&(r.suspendedLanes|a)?0:i,i!==0&&i!==s.retryLane&&(s.retryLane=i,oo(e,i),nr(r,e,i,-1))}return Hm(),r=oh(Error(G(421))),_d(e,t,a,r)}return i.data==="$?"?(t.flags|=128,t.child=e.child,t=bP.bind(null,e),i._reactRetry=t,null):(e=s.treeContext,jn=ei(i.nextSibling),wn=t,rt=!0,Zn=null,e!==null&&(An[Dn++]=Jr,An[Dn++]=Zr,An[Dn++]=ss,Jr=e.id,Zr=e.overflow,ss=t),t=$m(t,r.children),t.flags|=4096,t)}function Ty(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),Pg(e.return,t,n)}function ih(e,t,n,r,i){var s=e.memoizedState;s===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i}:(s.isBackwards=t,s.rendering=null,s.renderingStartTime=0,s.last=r,s.tail=n,s.tailMode=i)}function sk(e,t,n){var r=t.pendingProps,i=r.revealOrder,s=r.tail;if(Gt(e,t,r.children,n),r=lt.current,r&2)r=r&1|2,t.flags|=128;else{if(e!==null&&e.flags&128)e:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&Ty(e,n,t);else if(e.tag===19)Ty(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break e;for(;e.sibling===null;){if(e.return===null||e.return===t)break e;e=e.return}e.sibling.return=e.return,e=e.sibling}r&=1}if(Qe(lt,r),!(t.mode&1))t.memoizedState=null;else switch(i){case"forwards":for(n=t.child,i=null;n!==null;)e=n.alternate,e!==null&&ep(e)===null&&(i=n),n=n.sibling;n=i,n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),ih(t,!1,i,n,s);break;case"backwards":for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&ep(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}ih(t,!0,n,null,s);break;case"together":ih(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function wu(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function io(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),ls|=t.lanes,!(n&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(G(153));if(t.child!==null){for(e=t.child,n=oi(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=oi(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function lP(e,t,n){switch(t.tag){case 3:ok(t),Fa();break;case 5:L2(t);break;case 1:fn(t.type)&&Qu(t);break;case 4:Im(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,i=t.memoizedProps.value;Qe(Xu,r._currentValue),r._currentValue=i;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(Qe(lt,lt.current&1),t.flags|=128,null):n&t.child.childLanes?ik(e,t,n):(Qe(lt,lt.current&1),e=io(e,t,n),e!==null?e.sibling:null);Qe(lt,lt.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return sk(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),Qe(lt,lt.current),r)break;return null;case 22:case 23:return t.lanes=0,nk(e,t,n)}return io(e,t,n)}var ak,Ng,lk,ck;ak=function(e,t){for(var n=t.child;n!==null;){if(n.tag===5||n.tag===6)e.appendChild(n.stateNode);else if(n.tag!==4&&n.child!==null){n.child.return=n,n=n.child;continue}if(n===t)break;for(;n.sibling===null;){if(n.return===null||n.return===t)return;n=n.return}n.sibling.return=n.return,n=n.sibling}};Ng=function(){};lk=function(e,t,n,r){var i=e.memoizedProps;if(i!==r){e=t.stateNode,Hi(Pr.current);var s=null;switch(n){case"input":i=og(e,i),r=og(e,r),s=[];break;case"select":i=dt({},i,{value:void 0}),r=dt({},r,{value:void 0}),s=[];break;case"textarea":i=ag(e,i),r=ag(e,r),s=[];break;default:typeof i.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=qu)}cg(n,r);var a;n=null;for(d in i)if(!r.hasOwnProperty(d)&&i.hasOwnProperty(d)&&i[d]!=null)if(d==="style"){var l=i[d];for(a in l)l.hasOwnProperty(a)&&(n||(n={}),n[a]="")}else d!=="dangerouslySetInnerHTML"&&d!=="children"&&d!=="suppressContentEditableWarning"&&d!=="suppressHydrationWarning"&&d!=="autoFocus"&&(uc.hasOwnProperty(d)?s||(s=[]):(s=s||[]).push(d,null));for(d in r){var c=r[d];if(l=i!=null?i[d]:void 0,r.hasOwnProperty(d)&&c!==l&&(c!=null||l!=null))if(d==="style")if(l){for(a in l)!l.hasOwnProperty(a)||c&&c.hasOwnProperty(a)||(n||(n={}),n[a]="");for(a in c)c.hasOwnProperty(a)&&l[a]!==c[a]&&(n||(n={}),n[a]=c[a])}else n||(s||(s=[]),s.push(d,n)),n=c;else d==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,l=l?l.__html:void 0,c!=null&&l!==c&&(s=s||[]).push(d,c)):d==="children"?typeof c!="string"&&typeof c!="number"||(s=s||[]).push(d,""+c):d!=="suppressContentEditableWarning"&&d!=="suppressHydrationWarning"&&(uc.hasOwnProperty(d)?(c!=null&&d==="onScroll"&&Je("scroll",e),s||l===c||(s=[])):(s=s||[]).push(d,c))}n&&(s=s||[]).push("style",n);var d=s;(t.updateQueue=d)&&(t.flags|=4)}};ck=function(e,t,n,r){n!==r&&(t.flags|=4)};function Pl(e,t){if(!rt)switch(e.tailMode){case"hidden":t=e.tail;for(var n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null;break;case"collapsed":n=e.tail;for(var r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null}}function Bt(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&14680064,r|=i.flags&14680064,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function cP(e,t,n){var r=t.pendingProps;switch(km(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Bt(t),null;case 1:return fn(t.type)&&Ku(),Bt(t),null;case 3:return r=t.stateNode,Ba(),et(pn),et(qt),Lm(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(Dd(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Zn!==null&&(Hg(Zn),Zn=null))),Ng(e,t),Bt(t),null;case 5:Mm(t);var i=Hi(kc.current);if(n=t.type,e!==null&&t.stateNode!=null)lk(e,t,n,r,i),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error(G(166));return Bt(t),null}if(e=Hi(Pr.current),Dd(t)){r=t.stateNode,n=t.type;var s=t.memoizedProps;switch(r[Sr]=t,r[jc]=s,e=(t.mode&1)!==0,n){case"dialog":Je("cancel",r),Je("close",r);break;case"iframe":case"object":case"embed":Je("load",r);break;case"video":case"audio":for(i=0;i<Fl.length;i++)Je(Fl[i],r);break;case"source":Je("error",r);break;case"img":case"image":case"link":Je("error",r),Je("load",r);break;case"details":Je("toggle",r);break;case"input":Nv(r,s),Je("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!s.multiple},Je("invalid",r);break;case"textarea":$v(r,s),Je("invalid",r)}cg(n,s),i=null;for(var a in s)if(s.hasOwnProperty(a)){var l=s[a];a==="children"?typeof l=="string"?r.textContent!==l&&(s.suppressHydrationWarning!==!0&&Ad(r.textContent,l,e),i=["children",l]):typeof l=="number"&&r.textContent!==""+l&&(s.suppressHydrationWarning!==!0&&Ad(r.textContent,l,e),i=["children",""+l]):uc.hasOwnProperty(a)&&l!=null&&a==="onScroll"&&Je("scroll",r)}switch(n){case"input":Ed(r),_v(r,s,!0);break;case"textarea":Ed(r),Fv(r);break;case"select":case"option":break;default:typeof s.onClick=="function"&&(r.onclick=qu)}r=i,t.updateQueue=r,r!==null&&(t.flags|=4)}else{a=i.nodeType===9?i:i.ownerDocument,e==="http://www.w3.org/1999/xhtml"&&(e=_w(n)),e==="http://www.w3.org/1999/xhtml"?n==="script"?(e=a.createElement("div"),e.innerHTML="<script><\/script>",e=e.removeChild(e.firstChild)):typeof r.is=="string"?e=a.createElement(n,{is:r.is}):(e=a.createElement(n),n==="select"&&(a=e,r.multiple?a.multiple=!0:r.size&&(a.size=r.size))):e=a.createElementNS(e,n),e[Sr]=t,e[jc]=r,ak(e,t,!1,!1),t.stateNode=e;e:{switch(a=dg(n,r),n){case"dialog":Je("cancel",e),Je("close",e),i=r;break;case"iframe":case"object":case"embed":Je("load",e),i=r;break;case"video":case"audio":for(i=0;i<Fl.length;i++)Je(Fl[i],e);i=r;break;case"source":Je("error",e),i=r;break;case"img":case"image":case"link":Je("error",e),Je("load",e),i=r;break;case"details":Je("toggle",e),i=r;break;case"input":Nv(e,r),i=og(e,r),Je("invalid",e);break;case"option":i=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},i=dt({},r,{value:void 0}),Je("invalid",e);break;case"textarea":$v(e,r),i=ag(e,r),Je("invalid",e);break;default:i=r}cg(n,i),l=i;for(s in l)if(l.hasOwnProperty(s)){var c=l[s];s==="style"?zw(e,c):s==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,c!=null&&$w(e,c)):s==="children"?typeof c=="string"?(n!=="textarea"||c!=="")&&pc(e,c):typeof c=="number"&&pc(e,""+c):s!=="suppressContentEditableWarning"&&s!=="suppressHydrationWarning"&&s!=="autoFocus"&&(uc.hasOwnProperty(s)?c!=null&&s==="onScroll"&&Je("scroll",e):c!=null&&lm(e,s,c,a))}switch(n){case"input":Ed(e),_v(e,r,!1);break;case"textarea":Ed(e),Fv(e);break;case"option":r.value!=null&&e.setAttribute("value",""+ci(r.value));break;case"select":e.multiple=!!r.multiple,s=r.value,s!=null?pa(e,!!r.multiple,s,!1):r.defaultValue!=null&&pa(e,!!r.multiple,r.defaultValue,!0);break;default:typeof i.onClick=="function"&&(e.onclick=qu)}switch(n){case"button":case"input":case"select":case"textarea":r=!!r.autoFocus;break e;case"img":r=!0;break e;default:r=!1}}r&&(t.flags|=4)}t.ref!==null&&(t.flags|=512,t.flags|=2097152)}return Bt(t),null;case 6:if(e&&t.stateNode!=null)ck(e,t,e.memoizedProps,r);else{if(typeof r!="string"&&t.stateNode===null)throw Error(G(166));if(n=Hi(kc.current),Hi(Pr.current),Dd(t)){if(r=t.stateNode,n=t.memoizedProps,r[Sr]=t,(s=r.nodeValue!==n)&&(e=wn,e!==null))switch(e.tag){case 3:Ad(r.nodeValue,n,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&Ad(r.nodeValue,n,(e.mode&1)!==0)}s&&(t.flags|=4)}else r=(n.nodeType===9?n:n.ownerDocument).createTextNode(r),r[Sr]=t,t.stateNode=r}return Bt(t),null;case 13:if(et(lt),r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(rt&&jn!==null&&t.mode&1&&!(t.flags&128))T2(),Fa(),t.flags|=98560,s=!1;else if(s=Dd(t),r!==null&&r.dehydrated!==null){if(e===null){if(!s)throw Error(G(318));if(s=t.memoizedState,s=s!==null?s.dehydrated:null,!s)throw Error(G(317));s[Sr]=t}else Fa(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Bt(t),s=!1}else Zn!==null&&(Hg(Zn),Zn=null),s=!0;if(!s)return t.flags&65536?t:null}return t.flags&128?(t.lanes=n,t):(r=r!==null,r!==(e!==null&&e.memoizedState!==null)&&r&&(t.child.flags|=8192,t.mode&1&&(e===null||lt.current&1?Pt===0&&(Pt=3):Hm())),t.updateQueue!==null&&(t.flags|=4),Bt(t),null);case 4:return Ba(),Ng(e,t),e===null&&yc(t.stateNode.containerInfo),Bt(t),null;case 10:return Tm(t.type._context),Bt(t),null;case 17:return fn(t.type)&&Ku(),Bt(t),null;case 19:if(et(lt),s=t.memoizedState,s===null)return Bt(t),null;if(r=(t.flags&128)!==0,a=s.rendering,a===null)if(r)Pl(s,!1);else{if(Pt!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(a=ep(e),a!==null){for(t.flags|=128,Pl(s,!1),r=a.updateQueue,r!==null&&(t.updateQueue=r,t.flags|=4),t.subtreeFlags=0,r=n,n=t.child;n!==null;)s=n,e=r,s.flags&=14680066,a=s.alternate,a===null?(s.childLanes=0,s.lanes=e,s.child=null,s.subtreeFlags=0,s.memoizedProps=null,s.memoizedState=null,s.updateQueue=null,s.dependencies=null,s.stateNode=null):(s.childLanes=a.childLanes,s.lanes=a.lanes,s.child=a.child,s.subtreeFlags=0,s.deletions=null,s.memoizedProps=a.memoizedProps,s.memoizedState=a.memoizedState,s.updateQueue=a.updateQueue,s.type=a.type,e=a.dependencies,s.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),n=n.sibling;return Qe(lt,lt.current&1|2),t.child}e=e.sibling}s.tail!==null&&vt()>Ua&&(t.flags|=128,r=!0,Pl(s,!1),t.lanes=4194304)}else{if(!r)if(e=ep(a),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Pl(s,!0),s.tail===null&&s.tailMode==="hidden"&&!a.alternate&&!rt)return Bt(t),null}else 2*vt()-s.renderingStartTime>Ua&&n!==1073741824&&(t.flags|=128,r=!0,Pl(s,!1),t.lanes=4194304);s.isBackwards?(a.sibling=t.child,t.child=a):(n=s.last,n!==null?n.sibling=a:t.child=a,s.last=a)}return s.tail!==null?(t=s.tail,s.rendering=t,s.tail=t.sibling,s.renderingStartTime=vt(),t.sibling=null,n=lt.current,Qe(lt,r?n&1|2:n&1),t):(Bt(t),null);case 22:case 23:return Um(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?xn&1073741824&&(Bt(t),t.subtreeFlags&6&&(t.flags|=8192)):Bt(t),null;case 24:return null;case 25:return null}throw Error(G(156,t.tag))}function dP(e,t){switch(km(t),t.tag){case 1:return fn(t.type)&&Ku(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Ba(),et(pn),et(qt),Lm(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return Mm(t),null;case 13:if(et(lt),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(G(340));Fa()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return et(lt),null;case 4:return Ba(),null;case 10:return Tm(t.type._context),null;case 22:case 23:return Um(),null;case 24:return null;default:return null}}var $d=!1,Vt=!1,uP=typeof WeakSet=="function"?WeakSet:Set,ue=null;function la(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){ht(e,t,r)}else n.current=null}function _g(e,t,n){try{n()}catch(r){ht(e,t,r)}}var Py=!1;function pP(e,t){if(bg=Uu,e=h2(),jm(e)){if("selectionStart"in e)var n={start:e.selectionStart,end:e.selectionEnd};else e:{n=(n=e.ownerDocument)&&n.defaultView||window;var r=n.getSelection&&n.getSelection();if(r&&r.rangeCount!==0){n=r.anchorNode;var i=r.anchorOffset,s=r.focusNode;r=r.focusOffset;try{n.nodeType,s.nodeType}catch{n=null;break e}var a=0,l=-1,c=-1,d=0,u=0,f=e,h=null;t:for(;;){for(var g;f!==n||i!==0&&f.nodeType!==3||(l=a+i),f!==s||r!==0&&f.nodeType!==3||(c=a+r),f.nodeType===3&&(a+=f.nodeValue.length),(g=f.firstChild)!==null;)h=f,f=g;for(;;){if(f===e)break t;if(h===n&&++d===i&&(l=a),h===s&&++u===r&&(c=a),(g=f.nextSibling)!==null)break;f=h,h=f.parentNode}f=g}n=l===-1||c===-1?null:{start:l,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(jg={focusedElem:e,selectionRange:n},Uu=!1,ue=t;ue!==null;)if(t=ue,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,ue=e;else for(;ue!==null;){t=ue;try{var v=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(v!==null){var x=v.memoizedProps,b=v.memoizedState,j=t.stateNode,y=j.getSnapshotBeforeUpdate(t.elementType===t.type?x:Qn(t.type,x),b);j.__reactInternalSnapshotBeforeUpdate=y}break;case 3:var w=t.stateNode.containerInfo;w.nodeType===1?w.textContent="":w.nodeType===9&&w.documentElement&&w.removeChild(w.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(G(163))}}catch(k){ht(t,t.return,k)}if(e=t.sibling,e!==null){e.return=t.return,ue=e;break}ue=t.return}return v=Py,Py=!1,v}function Zl(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var i=r=r.next;do{if((i.tag&e)===e){var s=i.destroy;i.destroy=void 0,s!==void 0&&_g(t,n,s)}i=i.next}while(i!==r)}}function zp(e,t){if(t=t.updateQueue,t=t!==null?t.lastEffect:null,t!==null){var n=t=t.next;do{if((n.tag&e)===e){var r=n.create;n.destroy=r()}n=n.next}while(n!==t)}}function $g(e){var t=e.ref;if(t!==null){var n=e.stateNode;switch(e.tag){case 5:e=n;break;default:e=n}typeof t=="function"?t(e):t.current=e}}function dk(e){var t=e.alternate;t!==null&&(e.alternate=null,dk(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Sr],delete t[jc],delete t[Sg],delete t[QT],delete t[YT])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function uk(e){return e.tag===5||e.tag===3||e.tag===4}function Ry(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||uk(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.flags&2||e.child===null||e.tag===4)continue e;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Fg(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.nodeType===8?n.parentNode.insertBefore(e,t):n.insertBefore(e,t):(n.nodeType===8?(t=n.parentNode,t.insertBefore(e,n)):(t=n,t.appendChild(e)),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=qu));else if(r!==4&&(e=e.child,e!==null))for(Fg(e,t,n),e=e.sibling;e!==null;)Fg(e,t,n),e=e.sibling}function zg(e,t,n){var r=e.tag;if(r===5||r===6)e=e.stateNode,t?n.insertBefore(e,t):n.appendChild(e);else if(r!==4&&(e=e.child,e!==null))for(zg(e,t,n),e=e.sibling;e!==null;)zg(e,t,n),e=e.sibling}var Nt=null,Xn=!1;function Co(e,t,n){for(n=n.child;n!==null;)pk(e,t,n),n=n.sibling}function pk(e,t,n){if(Tr&&typeof Tr.onCommitFiberUnmount=="function")try{Tr.onCommitFiberUnmount(Lp,n)}catch{}switch(n.tag){case 5:Vt||la(n,t);case 6:var r=Nt,i=Xn;Nt=null,Co(e,t,n),Nt=r,Xn=i,Nt!==null&&(Xn?(e=Nt,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Nt.removeChild(n.stateNode));break;case 18:Nt!==null&&(Xn?(e=Nt,n=n.stateNode,e.nodeType===8?Jf(e.parentNode,n):e.nodeType===1&&Jf(e,n),xc(e)):Jf(Nt,n.stateNode));break;case 4:r=Nt,i=Xn,Nt=n.stateNode.containerInfo,Xn=!0,Co(e,t,n),Nt=r,Xn=i;break;case 0:case 11:case 14:case 15:if(!Vt&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var s=i,a=s.destroy;s=s.tag,a!==void 0&&(s&2||s&4)&&_g(n,t,a),i=i.next}while(i!==r)}Co(e,t,n);break;case 1:if(!Vt&&(la(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(l){ht(n,t,l)}Co(e,t,n);break;case 21:Co(e,t,n);break;case 22:n.mode&1?(Vt=(r=Vt)||n.memoizedState!==null,Co(e,t,n),Vt=r):Co(e,t,n);break;default:Co(e,t,n)}}function Iy(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new uP),t.forEach(function(r){var i=jP.bind(null,e,r);n.has(r)||(n.add(r),r.then(i,i))})}}function qn(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var i=n[r];try{var s=e,a=t,l=a;e:for(;l!==null;){switch(l.tag){case 5:Nt=l.stateNode,Xn=!1;break e;case 3:Nt=l.stateNode.containerInfo,Xn=!0;break e;case 4:Nt=l.stateNode.containerInfo,Xn=!0;break e}l=l.return}if(Nt===null)throw Error(G(160));pk(s,a,i),Nt=null,Xn=!1;var c=i.alternate;c!==null&&(c.return=null),i.return=null}catch(d){ht(i,t,d)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)fk(t,e),t=t.sibling}function fk(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(qn(t,e),mr(e),r&4){try{Zl(3,e,e.return),zp(3,e)}catch(x){ht(e,e.return,x)}try{Zl(5,e,e.return)}catch(x){ht(e,e.return,x)}}break;case 1:qn(t,e),mr(e),r&512&&n!==null&&la(n,n.return);break;case 5:if(qn(t,e),mr(e),r&512&&n!==null&&la(n,n.return),e.flags&32){var i=e.stateNode;try{pc(i,"")}catch(x){ht(e,e.return,x)}}if(r&4&&(i=e.stateNode,i!=null)){var s=e.memoizedProps,a=n!==null?n.memoizedProps:s,l=e.type,c=e.updateQueue;if(e.updateQueue=null,c!==null)try{l==="input"&&s.type==="radio"&&s.name!=null&&Dw(i,s),dg(l,a);var d=dg(l,s);for(a=0;a<c.length;a+=2){var u=c[a],f=c[a+1];u==="style"?zw(i,f):u==="dangerouslySetInnerHTML"?$w(i,f):u==="children"?pc(i,f):lm(i,u,f,d)}switch(l){case"input":ig(i,s);break;case"textarea":Nw(i,s);break;case"select":var h=i._wrapperState.wasMultiple;i._wrapperState.wasMultiple=!!s.multiple;var g=s.value;g!=null?pa(i,!!s.multiple,g,!1):h!==!!s.multiple&&(s.defaultValue!=null?pa(i,!!s.multiple,s.defaultValue,!0):pa(i,!!s.multiple,s.multiple?[]:"",!1))}i[jc]=s}catch(x){ht(e,e.return,x)}}break;case 6:if(qn(t,e),mr(e),r&4){if(e.stateNode===null)throw Error(G(162));i=e.stateNode,s=e.memoizedProps;try{i.nodeValue=s}catch(x){ht(e,e.return,x)}}break;case 3:if(qn(t,e),mr(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{xc(t.containerInfo)}catch(x){ht(e,e.return,x)}break;case 4:qn(t,e),mr(e);break;case 13:qn(t,e),mr(e),i=e.child,i.flags&8192&&(s=i.memoizedState!==null,i.stateNode.isHidden=s,!s||i.alternate!==null&&i.alternate.memoizedState!==null||(Bm=vt())),r&4&&Iy(e);break;case 22:if(u=n!==null&&n.memoizedState!==null,e.mode&1?(Vt=(d=Vt)||u,qn(t,e),Vt=d):qn(t,e),mr(e),r&8192){if(d=e.memoizedState!==null,(e.stateNode.isHidden=d)&&!u&&e.mode&1)for(ue=e,u=e.child;u!==null;){for(f=ue=u;ue!==null;){switch(h=ue,g=h.child,h.tag){case 0:case 11:case 14:case 15:Zl(4,h,h.return);break;case 1:la(h,h.return);var v=h.stateNode;if(typeof v.componentWillUnmount=="function"){r=h,n=h.return;try{t=r,v.props=t.memoizedProps,v.state=t.memoizedState,v.componentWillUnmount()}catch(x){ht(r,n,x)}}break;case 5:la(h,h.return);break;case 22:if(h.memoizedState!==null){Ly(f);continue}}g!==null?(g.return=h,ue=g):Ly(f)}u=u.sibling}e:for(u=null,f=e;;){if(f.tag===5){if(u===null){u=f;try{i=f.stateNode,d?(s=i.style,typeof s.setProperty=="function"?s.setProperty("display","none","important"):s.display="none"):(l=f.stateNode,c=f.memoizedProps.style,a=c!=null&&c.hasOwnProperty("display")?c.display:null,l.style.display=Fw("display",a))}catch(x){ht(e,e.return,x)}}}else if(f.tag===6){if(u===null)try{f.stateNode.nodeValue=d?"":f.memoizedProps}catch(x){ht(e,e.return,x)}}else if((f.tag!==22&&f.tag!==23||f.memoizedState===null||f===e)&&f.child!==null){f.child.return=f,f=f.child;continue}if(f===e)break e;for(;f.sibling===null;){if(f.return===null||f.return===e)break e;u===f&&(u=null),f=f.return}u===f&&(u=null),f.sibling.return=f.return,f=f.sibling}}break;case 19:qn(t,e),mr(e),r&4&&Iy(e);break;case 21:break;default:qn(t,e),mr(e)}}function mr(e){var t=e.flags;if(t&2){try{e:{for(var n=e.return;n!==null;){if(uk(n)){var r=n;break e}n=n.return}throw Error(G(160))}switch(r.tag){case 5:var i=r.stateNode;r.flags&32&&(pc(i,""),r.flags&=-33);var s=Ry(e);zg(e,s,i);break;case 3:case 4:var a=r.stateNode.containerInfo,l=Ry(e);Fg(e,l,a);break;default:throw Error(G(161))}}catch(c){ht(e,e.return,c)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function fP(e,t,n){ue=e,hk(e)}function hk(e,t,n){for(var r=(e.mode&1)!==0;ue!==null;){var i=ue,s=i.child;if(i.tag===22&&r){var a=i.memoizedState!==null||$d;if(!a){var l=i.alternate,c=l!==null&&l.memoizedState!==null||Vt;l=$d;var d=Vt;if($d=a,(Vt=c)&&!d)for(ue=i;ue!==null;)a=ue,c=a.child,a.tag===22&&a.memoizedState!==null?Oy(i):c!==null?(c.return=a,ue=c):Oy(i);for(;s!==null;)ue=s,hk(s),s=s.sibling;ue=i,$d=l,Vt=d}My(e)}else i.subtreeFlags&8772&&s!==null?(s.return=i,ue=s):My(e)}}function My(e){for(;ue!==null;){var t=ue;if(t.flags&8772){var n=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:Vt||zp(5,t);break;case 1:var r=t.stateNode;if(t.flags&4&&!Vt)if(n===null)r.componentDidMount();else{var i=t.elementType===t.type?n.memoizedProps:Qn(t.type,n.memoizedProps);r.componentDidUpdate(i,n.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var s=t.updateQueue;s!==null&&gy(t,s,r);break;case 3:var a=t.updateQueue;if(a!==null){if(n=null,t.child!==null)switch(t.child.tag){case 5:n=t.child.stateNode;break;case 1:n=t.child.stateNode}gy(t,a,n)}break;case 5:var l=t.stateNode;if(n===null&&t.flags&4){n=l;var c=t.memoizedProps;switch(t.type){case"button":case"input":case"select":case"textarea":c.autoFocus&&n.focus();break;case"img":c.src&&(n.src=c.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(t.memoizedState===null){var d=t.alternate;if(d!==null){var u=d.memoizedState;if(u!==null){var f=u.dehydrated;f!==null&&xc(f)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(G(163))}Vt||t.flags&512&&$g(t)}catch(h){ht(t,t.return,h)}}if(t===e){ue=null;break}if(n=t.sibling,n!==null){n.return=t.return,ue=n;break}ue=t.return}}function Ly(e){for(;ue!==null;){var t=ue;if(t===e){ue=null;break}var n=t.sibling;if(n!==null){n.return=t.return,ue=n;break}ue=t.return}}function Oy(e){for(;ue!==null;){var t=ue;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{zp(4,t)}catch(c){ht(t,n,c)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount=="function"){var i=t.return;try{r.componentDidMount()}catch(c){ht(t,i,c)}}var s=t.return;try{$g(t)}catch(c){ht(t,s,c)}break;case 5:var a=t.return;try{$g(t)}catch(c){ht(t,a,c)}}}catch(c){ht(t,t.return,c)}if(t===e){ue=null;break}var l=t.sibling;if(l!==null){l.return=t.return,ue=l;break}ue=t.return}}var hP=Math.ceil,rp=co.ReactCurrentDispatcher,Fm=co.ReactCurrentOwner,_n=co.ReactCurrentBatchConfig,_e=0,Mt=null,St=null,_t=0,xn=0,ca=mi(0),Pt=0,Tc=null,ls=0,Bp=0,zm=0,ec=null,dn=null,Bm=0,Ua=1/0,Hr=null,op=!1,Bg=null,ni=null,Fd=!1,Qo=null,ip=0,tc=0,Wg=null,ku=-1,Su=0;function Zt(){return _e&6?vt():ku!==-1?ku:ku=vt()}function ri(e){return e.mode&1?_e&2&&_t!==0?_t&-_t:XT.transition!==null?(Su===0&&(Su=Jw()),Su):(e=We,e!==0||(e=window.event,e=e===void 0?16:i2(e.type)),e):1}function nr(e,t,n,r){if(50<tc)throw tc=0,Wg=null,Error(G(185));Kc(e,n,r),(!(_e&2)||e!==Mt)&&(e===Mt&&(!(_e&2)&&(Bp|=n),Pt===4&&No(e,_t)),hn(e,r),n===1&&_e===0&&!(t.mode&1)&&(Ua=vt()+500,_p&&vi()))}function hn(e,t){var n=e.callbackNode;XE(e,t);var r=Wu(e,e===Mt?_t:0);if(r===0)n!==null&&Wv(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(n!=null&&Wv(n),t===1)e.tag===0?GT(Ay.bind(null,e)):S2(Ay.bind(null,e)),qT(function(){!(_e&6)&&vi()}),n=null;else{switch(Zw(r)){case 1:n=fm;break;case 4:n=Gw;break;case 16:n=Bu;break;case 536870912:n=Xw;break;default:n=Bu}n=wk(n,gk.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function gk(e,t){if(ku=-1,Su=0,_e&6)throw Error(G(327));var n=e.callbackNode;if(ma()&&e.callbackNode!==n)return null;var r=Wu(e,e===Mt?_t:0);if(r===0)return null;if(r&30||r&e.expiredLanes||t)t=sp(e,r);else{t=r;var i=_e;_e|=2;var s=mk();(Mt!==e||_t!==t)&&(Hr=null,Ua=vt()+500,ns(e,t));do try{mP();break}catch(l){xk(e,l)}while(!0);Em(),rp.current=s,_e=i,St!==null?t=0:(Mt=null,_t=0,t=Pt)}if(t!==0){if(t===2&&(i=gg(e),i!==0&&(r=i,t=Ug(e,i))),t===1)throw n=Tc,ns(e,0),No(e,r),hn(e,vt()),n;if(t===6)No(e,r);else{if(i=e.current.alternate,!(r&30)&&!gP(i)&&(t=sp(e,r),t===2&&(s=gg(e),s!==0&&(r=s,t=Ug(e,s))),t===1))throw n=Tc,ns(e,0),No(e,r),hn(e,vt()),n;switch(e.finishedWork=i,e.finishedLanes=r,t){case 0:case 1:throw Error(G(345));case 2:Ni(e,dn,Hr);break;case 3:if(No(e,r),(r&130023424)===r&&(t=Bm+500-vt(),10<t)){if(Wu(e,0)!==0)break;if(i=e.suspendedLanes,(i&r)!==r){Zt(),e.pingedLanes|=e.suspendedLanes&i;break}e.timeoutHandle=kg(Ni.bind(null,e,dn,Hr),t);break}Ni(e,dn,Hr);break;case 4:if(No(e,r),(r&4194240)===r)break;for(t=e.eventTimes,i=-1;0<r;){var a=31-tr(r);s=1<<a,a=t[a],a>i&&(i=a),r&=~s}if(r=i,r=vt()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*hP(r/1960))-r,10<r){e.timeoutHandle=kg(Ni.bind(null,e,dn,Hr),r);break}Ni(e,dn,Hr);break;case 5:Ni(e,dn,Hr);break;default:throw Error(G(329))}}}return hn(e,vt()),e.callbackNode===n?gk.bind(null,e):null}function Ug(e,t){var n=ec;return e.current.memoizedState.isDehydrated&&(ns(e,t).flags|=256),e=sp(e,t),e!==2&&(t=dn,dn=n,t!==null&&Hg(t)),e}function Hg(e){dn===null?dn=e:dn.push.apply(dn,e)}function gP(e){for(var t=e;;){if(t.flags&16384){var n=t.updateQueue;if(n!==null&&(n=n.stores,n!==null))for(var r=0;r<n.length;r++){var i=n[r],s=i.getSnapshot;i=i.value;try{if(!or(s(),i))return!1}catch{return!1}}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function No(e,t){for(t&=~zm,t&=~Bp,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-tr(t),r=1<<n;e[n]=-1,t&=~r}}function Ay(e){if(_e&6)throw Error(G(327));ma();var t=Wu(e,0);if(!(t&1))return hn(e,vt()),null;var n=sp(e,t);if(e.tag!==0&&n===2){var r=gg(e);r!==0&&(t=r,n=Ug(e,r))}if(n===1)throw n=Tc,ns(e,0),No(e,t),hn(e,vt()),n;if(n===6)throw Error(G(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,Ni(e,dn,Hr),hn(e,vt()),null}function Wm(e,t){var n=_e;_e|=1;try{return e(t)}finally{_e=n,_e===0&&(Ua=vt()+500,_p&&vi())}}function cs(e){Qo!==null&&Qo.tag===0&&!(_e&6)&&ma();var t=_e;_e|=1;var n=_n.transition,r=We;try{if(_n.transition=null,We=1,e)return e()}finally{We=r,_n.transition=n,_e=t,!(_e&6)&&vi()}}function Um(){xn=ca.current,et(ca)}function ns(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(n!==-1&&(e.timeoutHandle=-1,VT(n)),St!==null)for(n=St.return;n!==null;){var r=n;switch(km(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&Ku();break;case 3:Ba(),et(pn),et(qt),Lm();break;case 5:Mm(r);break;case 4:Ba();break;case 13:et(lt);break;case 19:et(lt);break;case 10:Tm(r.type._context);break;case 22:case 23:Um()}n=n.return}if(Mt=e,St=e=oi(e.current,null),_t=xn=t,Pt=0,Tc=null,zm=Bp=ls=0,dn=ec=null,Ui!==null){for(t=0;t<Ui.length;t++)if(n=Ui[t],r=n.interleaved,r!==null){n.interleaved=null;var i=r.next,s=n.pending;if(s!==null){var a=s.next;s.next=i,r.next=a}n.pending=r}Ui=null}return e}function xk(e,t){do{var n=St;try{if(Em(),bu.current=np,tp){for(var r=ct.memoizedState;r!==null;){var i=r.queue;i!==null&&(i.pending=null),r=r.next}tp=!1}if(as=0,It=Et=ct=null,Jl=!1,Sc=0,Fm.current=null,n===null||n.return===null){Pt=1,Tc=t,St=null;break}e:{var s=e,a=n.return,l=n,c=t;if(t=_t,l.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){var d=c,u=l,f=u.tag;if(!(u.mode&1)&&(f===0||f===11||f===15)){var h=u.alternate;h?(u.updateQueue=h.updateQueue,u.memoizedState=h.memoizedState,u.lanes=h.lanes):(u.updateQueue=null,u.memoizedState=null)}var g=jy(a);if(g!==null){g.flags&=-257,wy(g,a,l,s,t),g.mode&1&&by(s,d,t),t=g,c=d;var v=t.updateQueue;if(v===null){var x=new Set;x.add(c),t.updateQueue=x}else v.add(c);break e}else{if(!(t&1)){by(s,d,t),Hm();break e}c=Error(G(426))}}else if(rt&&l.mode&1){var b=jy(a);if(b!==null){!(b.flags&65536)&&(b.flags|=256),wy(b,a,l,s,t),Sm(Wa(c,l));break e}}s=c=Wa(c,l),Pt!==4&&(Pt=2),ec===null?ec=[s]:ec.push(s),s=a;do{switch(s.tag){case 3:s.flags|=65536,t&=-t,s.lanes|=t;var j=Z2(s,c,t);hy(s,j);break e;case 1:l=c;var y=s.type,w=s.stateNode;if(!(s.flags&128)&&(typeof y.getDerivedStateFromError=="function"||w!==null&&typeof w.componentDidCatch=="function"&&(ni===null||!ni.has(w)))){s.flags|=65536,t&=-t,s.lanes|=t;var k=ek(s,l,t);hy(s,k);break e}}s=s.return}while(s!==null)}yk(n)}catch(S){t=S,St===n&&n!==null&&(St=n=n.return);continue}break}while(!0)}function mk(){var e=rp.current;return rp.current=np,e===null?np:e}function Hm(){(Pt===0||Pt===3||Pt===2)&&(Pt=4),Mt===null||!(ls&268435455)&&!(Bp&268435455)||No(Mt,_t)}function sp(e,t){var n=_e;_e|=2;var r=mk();(Mt!==e||_t!==t)&&(Hr=null,ns(e,t));do try{xP();break}catch(i){xk(e,i)}while(!0);if(Em(),_e=n,rp.current=r,St!==null)throw Error(G(261));return Mt=null,_t=0,Pt}function xP(){for(;St!==null;)vk(St)}function mP(){for(;St!==null&&!WE();)vk(St)}function vk(e){var t=jk(e.alternate,e,xn);e.memoizedProps=e.pendingProps,t===null?yk(e):St=t,Fm.current=null}function yk(e){var t=e;do{var n=t.alternate;if(e=t.return,t.flags&32768){if(n=dP(n,t),n!==null){n.flags&=32767,St=n;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{Pt=6,St=null;return}}else if(n=cP(n,t,xn),n!==null){St=n;return}if(t=t.sibling,t!==null){St=t;return}St=t=e}while(t!==null);Pt===0&&(Pt=5)}function Ni(e,t,n){var r=We,i=_n.transition;try{_n.transition=null,We=1,vP(e,t,n,r)}finally{_n.transition=i,We=r}return null}function vP(e,t,n,r){do ma();while(Qo!==null);if(_e&6)throw Error(G(327));n=e.finishedWork;var i=e.finishedLanes;if(n===null)return null;if(e.finishedWork=null,e.finishedLanes=0,n===e.current)throw Error(G(177));e.callbackNode=null,e.callbackPriority=0;var s=n.lanes|n.childLanes;if(JE(e,s),e===Mt&&(St=Mt=null,_t=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||Fd||(Fd=!0,wk(Bu,function(){return ma(),null})),s=(n.flags&15990)!==0,n.subtreeFlags&15990||s){s=_n.transition,_n.transition=null;var a=We;We=1;var l=_e;_e|=4,Fm.current=null,pP(e,n),fk(n,e),$T(jg),Uu=!!bg,jg=bg=null,e.current=n,fP(n),UE(),_e=l,We=a,_n.transition=s}else e.current=n;if(Fd&&(Fd=!1,Qo=e,ip=i),s=e.pendingLanes,s===0&&(ni=null),qE(n.stateNode),hn(e,vt()),t!==null)for(r=e.onRecoverableError,n=0;n<t.length;n++)i=t[n],r(i.value,{componentStack:i.stack,digest:i.digest});if(op)throw op=!1,e=Bg,Bg=null,e;return ip&1&&e.tag!==0&&ma(),s=e.pendingLanes,s&1?e===Wg?tc++:(tc=0,Wg=e):tc=0,vi(),null}function ma(){if(Qo!==null){var e=Zw(ip),t=_n.transition,n=We;try{if(_n.transition=null,We=16>e?16:e,Qo===null)var r=!1;else{if(e=Qo,Qo=null,ip=0,_e&6)throw Error(G(331));var i=_e;for(_e|=4,ue=e.current;ue!==null;){var s=ue,a=s.child;if(ue.flags&16){var l=s.deletions;if(l!==null){for(var c=0;c<l.length;c++){var d=l[c];for(ue=d;ue!==null;){var u=ue;switch(u.tag){case 0:case 11:case 15:Zl(8,u,s)}var f=u.child;if(f!==null)f.return=u,ue=f;else for(;ue!==null;){u=ue;var h=u.sibling,g=u.return;if(dk(u),u===d){ue=null;break}if(h!==null){h.return=g,ue=h;break}ue=g}}}var v=s.alternate;if(v!==null){var x=v.child;if(x!==null){v.child=null;do{var b=x.sibling;x.sibling=null,x=b}while(x!==null)}}ue=s}}if(s.subtreeFlags&2064&&a!==null)a.return=s,ue=a;else e:for(;ue!==null;){if(s=ue,s.flags&2048)switch(s.tag){case 0:case 11:case 15:Zl(9,s,s.return)}var j=s.sibling;if(j!==null){j.return=s.return,ue=j;break e}ue=s.return}}var y=e.current;for(ue=y;ue!==null;){a=ue;var w=a.child;if(a.subtreeFlags&2064&&w!==null)w.return=a,ue=w;else e:for(a=y;ue!==null;){if(l=ue,l.flags&2048)try{switch(l.tag){case 0:case 11:case 15:zp(9,l)}}catch(S){ht(l,l.return,S)}if(l===a){ue=null;break e}var k=l.sibling;if(k!==null){k.return=l.return,ue=k;break e}ue=l.return}}if(_e=i,vi(),Tr&&typeof Tr.onPostCommitFiberRoot=="function")try{Tr.onPostCommitFiberRoot(Lp,e)}catch{}r=!0}return r}finally{We=n,_n.transition=t}}return!1}function Dy(e,t,n){t=Wa(n,t),t=Z2(e,t,1),e=ti(e,t,1),t=Zt(),e!==null&&(Kc(e,1,t),hn(e,t))}function ht(e,t,n){if(e.tag===3)Dy(e,e,n);else for(;t!==null;){if(t.tag===3){Dy(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(ni===null||!ni.has(r))){e=Wa(n,e),e=ek(t,e,1),t=ti(t,e,1),e=Zt(),t!==null&&(Kc(t,1,e),hn(t,e));break}}t=t.return}}function yP(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),t=Zt(),e.pingedLanes|=e.suspendedLanes&n,Mt===e&&(_t&n)===n&&(Pt===4||Pt===3&&(_t&130023424)===_t&&500>vt()-Bm?ns(e,0):zm|=n),hn(e,t)}function bk(e,t){t===0&&(e.mode&1?(t=Rd,Rd<<=1,!(Rd&130023424)&&(Rd=4194304)):t=1);var n=Zt();e=oo(e,t),e!==null&&(Kc(e,t,n),hn(e,n))}function bP(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),bk(e,n)}function jP(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,i=e.memoizedState;i!==null&&(n=i.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(G(314))}r!==null&&r.delete(t),bk(e,n)}var jk;jk=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||pn.current)un=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return un=!1,lP(e,t,n);un=!!(e.flags&131072)}else un=!1,rt&&t.flags&1048576&&C2(t,Gu,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;wu(e,t),e=t.pendingProps;var i=$a(t,qt.current);xa(t,n),i=Am(null,t,r,e,i,n);var s=Dm();return t.flags|=1,typeof i=="object"&&i!==null&&typeof i.render=="function"&&i.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,fn(r)?(s=!0,Qu(t)):s=!1,t.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,Rm(t),i.updater=Fp,t.stateNode=i,i._reactInternals=t,Ig(t,r,e,n),t=Og(null,t,r,!0,s,n)):(t.tag=0,rt&&s&&wm(t),Gt(null,t,i,n),t=t.child),t;case 16:r=t.elementType;e:{switch(wu(e,t),e=t.pendingProps,i=r._init,r=i(r._payload),t.type=r,i=t.tag=kP(r),e=Qn(r,e),i){case 0:t=Lg(null,t,r,e,n);break e;case 1:t=Cy(null,t,r,e,n);break e;case 11:t=ky(null,t,r,e,n);break e;case 14:t=Sy(null,t,r,Qn(r.type,e),n);break e}throw Error(G(306,r,""))}return t;case 0:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:Qn(r,i),Lg(e,t,r,i,n);case 1:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:Qn(r,i),Cy(e,t,r,i,n);case 3:e:{if(ok(t),e===null)throw Error(G(387));r=t.pendingProps,s=t.memoizedState,i=s.element,M2(e,t),Zu(t,r,null,n);var a=t.memoizedState;if(r=a.element,s.isDehydrated)if(s={element:r,isDehydrated:!1,cache:a.cache,pendingSuspenseBoundaries:a.pendingSuspenseBoundaries,transitions:a.transitions},t.updateQueue.baseState=s,t.memoizedState=s,t.flags&256){i=Wa(Error(G(423)),t),t=Ey(e,t,r,n,i);break e}else if(r!==i){i=Wa(Error(G(424)),t),t=Ey(e,t,r,n,i);break e}else for(jn=ei(t.stateNode.containerInfo.firstChild),wn=t,rt=!0,Zn=null,n=R2(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Fa(),r===i){t=io(e,t,n);break e}Gt(e,t,r,n)}t=t.child}return t;case 5:return L2(t),e===null&&Tg(t),r=t.type,i=t.pendingProps,s=e!==null?e.memoizedProps:null,a=i.children,wg(r,i)?a=null:s!==null&&wg(r,s)&&(t.flags|=32),rk(e,t),Gt(e,t,a,n),t.child;case 6:return e===null&&Tg(t),null;case 13:return ik(e,t,n);case 4:return Im(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=za(t,null,r,n):Gt(e,t,r,n),t.child;case 11:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:Qn(r,i),ky(e,t,r,i,n);case 7:return Gt(e,t,t.pendingProps,n),t.child;case 8:return Gt(e,t,t.pendingProps.children,n),t.child;case 12:return Gt(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,i=t.pendingProps,s=t.memoizedProps,a=i.value,Qe(Xu,r._currentValue),r._currentValue=a,s!==null)if(or(s.value,a)){if(s.children===i.children&&!pn.current){t=io(e,t,n);break e}}else for(s=t.child,s!==null&&(s.return=t);s!==null;){var l=s.dependencies;if(l!==null){a=s.child;for(var c=l.firstContext;c!==null;){if(c.context===r){if(s.tag===1){c=eo(-1,n&-n),c.tag=2;var d=s.updateQueue;if(d!==null){d=d.shared;var u=d.pending;u===null?c.next=c:(c.next=u.next,u.next=c),d.pending=c}}s.lanes|=n,c=s.alternate,c!==null&&(c.lanes|=n),Pg(s.return,n,t),l.lanes|=n;break}c=c.next}}else if(s.tag===10)a=s.type===t.type?null:s.child;else if(s.tag===18){if(a=s.return,a===null)throw Error(G(341));a.lanes|=n,l=a.alternate,l!==null&&(l.lanes|=n),Pg(a,n,t),a=s.sibling}else a=s.child;if(a!==null)a.return=s;else for(a=s;a!==null;){if(a===t){a=null;break}if(s=a.sibling,s!==null){s.return=a.return,a=s;break}a=a.return}s=a}Gt(e,t,i.children,n),t=t.child}return t;case 9:return i=t.type,r=t.pendingProps.children,xa(t,n),i=Fn(i),r=r(i),t.flags|=1,Gt(e,t,r,n),t.child;case 14:return r=t.type,i=Qn(r,t.pendingProps),i=Qn(r.type,i),Sy(e,t,r,i,n);case 15:return tk(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:Qn(r,i),wu(e,t),t.tag=1,fn(r)?(e=!0,Qu(t)):e=!1,xa(t,n),J2(t,r,i),Ig(t,r,i,n),Og(null,t,r,!0,e,n);case 19:return sk(e,t,n);case 22:return nk(e,t,n)}throw Error(G(156,t.tag))};function wk(e,t){return Yw(e,t)}function wP(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Nn(e,t,n,r){return new wP(e,t,n,r)}function Vm(e){return e=e.prototype,!(!e||!e.isReactComponent)}function kP(e){if(typeof e=="function")return Vm(e)?1:0;if(e!=null){if(e=e.$$typeof,e===dm)return 11;if(e===um)return 14}return 2}function oi(e,t){var n=e.alternate;return n===null?(n=Nn(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&14680064,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n}function Cu(e,t,n,r,i,s){var a=2;if(r=e,typeof e=="function")Vm(e)&&(a=1);else if(typeof e=="string")a=5;else e:switch(e){case Zs:return rs(n.children,i,s,t);case cm:a=8,i|=8;break;case eg:return e=Nn(12,n,t,i|2),e.elementType=eg,e.lanes=s,e;case tg:return e=Nn(13,n,t,i),e.elementType=tg,e.lanes=s,e;case ng:return e=Nn(19,n,t,i),e.elementType=ng,e.lanes=s,e;case Lw:return Wp(n,i,s,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case Iw:a=10;break e;case Mw:a=9;break e;case dm:a=11;break e;case um:a=14;break e;case Lo:a=16,r=null;break e}throw Error(G(130,e==null?e:typeof e,""))}return t=Nn(a,n,t,i),t.elementType=e,t.type=r,t.lanes=s,t}function rs(e,t,n,r){return e=Nn(7,e,r,t),e.lanes=n,e}function Wp(e,t,n,r){return e=Nn(22,e,r,t),e.elementType=Lw,e.lanes=n,e.stateNode={isHidden:!1},e}function sh(e,t,n){return e=Nn(6,e,null,t),e.lanes=n,e}function ah(e,t,n){return t=Nn(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function SP(e,t,n,r,i){this.tag=t,this.containerInfo=e,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Bf(0),this.expirationTimes=Bf(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Bf(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function qm(e,t,n,r,i,s,a,l,c){return e=new SP(e,t,n,l,c),t===1?(t=1,s===!0&&(t|=8)):t=0,s=Nn(3,null,null,t),e.current=s,s.stateNode=e,s.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Rm(s),e}function CP(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:Js,key:r==null?null:""+r,children:e,containerInfo:t,implementation:n}}function kk(e){if(!e)return di;e=e._reactInternals;e:{if(ms(e)!==e||e.tag!==1)throw Error(G(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(fn(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(G(171))}if(e.tag===1){var n=e.type;if(fn(n))return k2(e,n,t)}return t}function Sk(e,t,n,r,i,s,a,l,c){return e=qm(n,r,!0,e,i,s,a,l,c),e.context=kk(null),n=e.current,r=Zt(),i=ri(n),s=eo(r,i),s.callback=t??null,ti(n,s,i),e.current.lanes=i,Kc(e,i,r),hn(e,r),e}function Up(e,t,n,r){var i=t.current,s=Zt(),a=ri(i);return n=kk(n),t.context===null?t.context=n:t.pendingContext=n,t=eo(s,a),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=ti(i,t,a),e!==null&&(nr(e,i,a,s),yu(e,i,a)),a}function ap(e){if(e=e.current,!e.child)return null;switch(e.child.tag){case 5:return e.child.stateNode;default:return e.child.stateNode}}function Ny(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function Km(e,t){Ny(e,t),(e=e.alternate)&&Ny(e,t)}function EP(){return null}var Ck=typeof reportError=="function"?reportError:function(e){console.error(e)};function Qm(e){this._internalRoot=e}Hp.prototype.render=Qm.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(G(409));Up(e,t,null,null)};Hp.prototype.unmount=Qm.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;cs(function(){Up(null,e,null,null)}),t[ro]=null}};function Hp(e){this._internalRoot=e}Hp.prototype.unstable_scheduleHydration=function(e){if(e){var t=n2();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Do.length&&t!==0&&t<Do[n].priority;n++);Do.splice(n,0,e),n===0&&o2(e)}};function Ym(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function Vp(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function _y(){}function TP(e,t,n,r,i){if(i){if(typeof r=="function"){var s=r;r=function(){var d=ap(a);s.call(d)}}var a=Sk(t,r,e,0,null,!1,!1,"",_y);return e._reactRootContainer=a,e[ro]=a.current,yc(e.nodeType===8?e.parentNode:e),cs(),a}for(;i=e.lastChild;)e.removeChild(i);if(typeof r=="function"){var l=r;r=function(){var d=ap(c);l.call(d)}}var c=qm(e,0,!1,null,null,!1,!1,"",_y);return e._reactRootContainer=c,e[ro]=c.current,yc(e.nodeType===8?e.parentNode:e),cs(function(){Up(t,c,n,r)}),c}function qp(e,t,n,r,i){var s=n._reactRootContainer;if(s){var a=s;if(typeof i=="function"){var l=i;i=function(){var c=ap(a);l.call(c)}}Up(t,a,e,i)}else a=TP(n,t,e,i,r);return ap(a)}e2=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=$l(t.pendingLanes);n!==0&&(hm(t,n|1),hn(t,vt()),!(_e&6)&&(Ua=vt()+500,vi()))}break;case 13:cs(function(){var r=oo(e,1);if(r!==null){var i=Zt();nr(r,e,1,i)}}),Km(e,1)}};gm=function(e){if(e.tag===13){var t=oo(e,134217728);if(t!==null){var n=Zt();nr(t,e,134217728,n)}Km(e,134217728)}};t2=function(e){if(e.tag===13){var t=ri(e),n=oo(e,t);if(n!==null){var r=Zt();nr(n,e,t,r)}Km(e,t)}};n2=function(){return We};r2=function(e,t){var n=We;try{return We=e,t()}finally{We=n}};pg=function(e,t,n){switch(t){case"input":if(ig(e,n),t=n.name,n.type==="radio"&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll("input[name="+JSON.stringify(""+t)+'][type="radio"]'),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var i=Np(r);if(!i)throw Error(G(90));Aw(r),ig(r,i)}}}break;case"textarea":Nw(e,n);break;case"select":t=n.value,t!=null&&pa(e,!!n.multiple,t,!1)}};Uw=Wm;Hw=cs;var PP={usingClientEntryPoint:!1,Events:[Yc,ra,Np,Bw,Ww,Wm]},Rl={findFiberByHostInstance:Wi,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},RP={bundleType:Rl.bundleType,version:Rl.version,rendererPackageName:Rl.rendererPackageName,rendererConfig:Rl.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:co.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=Kw(e),e===null?null:e.stateNode},findFiberByHostInstance:Rl.findFiberByHostInstance||EP,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var zd=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!zd.isDisabled&&zd.supportsFiber)try{Lp=zd.inject(RP),Tr=zd}catch{}}Tn.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=PP;Tn.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Ym(t))throw Error(G(200));return CP(e,t,null,n)};Tn.createRoot=function(e,t){if(!Ym(e))throw Error(G(299));var n=!1,r="",i=Ck;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onRecoverableError!==void 0&&(i=t.onRecoverableError)),t=qm(e,1,!1,null,null,n,!1,r,i),e[ro]=t.current,yc(e.nodeType===8?e.parentNode:e),new Qm(t)};Tn.findDOMNode=function(e){if(e==null)return null;if(e.nodeType===1)return e;var t=e._reactInternals;if(t===void 0)throw typeof e.render=="function"?Error(G(188)):(e=Object.keys(e).join(","),Error(G(268,e)));return e=Kw(t),e=e===null?null:e.stateNode,e};Tn.flushSync=function(e){return cs(e)};Tn.hydrate=function(e,t,n){if(!Vp(t))throw Error(G(200));return qp(null,e,t,!0,n)};Tn.hydrateRoot=function(e,t,n){if(!Ym(e))throw Error(G(405));var r=n!=null&&n.hydratedSources||null,i=!1,s="",a=Ck;if(n!=null&&(n.unstable_strictMode===!0&&(i=!0),n.identifierPrefix!==void 0&&(s=n.identifierPrefix),n.onRecoverableError!==void 0&&(a=n.onRecoverableError)),t=Sk(t,null,e,1,n??null,i,!1,s,a),e[ro]=t.current,yc(e),r)for(e=0;e<r.length;e++)n=r[e],i=n._getVersion,i=i(n._source),t.mutableSourceEagerHydrationData==null?t.mutableSourceEagerHydrationData=[n,i]:t.mutableSourceEagerHydrationData.push(n,i);return new Hp(t)};Tn.render=function(e,t,n){if(!Vp(t))throw Error(G(200));return qp(null,e,t,!1,n)};Tn.unmountComponentAtNode=function(e){if(!Vp(e))throw Error(G(40));return e._reactRootContainer?(cs(function(){qp(null,null,e,!1,function(){e._reactRootContainer=null,e[ro]=null})}),!0):!1};Tn.unstable_batchedUpdates=Wm;Tn.unstable_renderSubtreeIntoContainer=function(e,t,n,r){if(!Vp(n))throw Error(G(200));if(e==null||e._reactInternals===void 0)throw Error(G(38));return qp(e,t,n,!1,r)};Tn.version="18.3.1-next-f1338f8080-20240426";function Ek(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(Ek)}catch(e){console.error(e)}}Ek(),Ew.exports=Tn;var vs=Ew.exports;const IP=hw(vs),MP=fw({__proto__:null,default:IP},[vs]);var Tk,$y=vs;Tk=$y.createRoot,$y.hydrateRoot;var ll=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(e){return this.listeners.add(e),this.onSubscribe(),()=>{this.listeners.delete(e),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},Ki,$o,Sa,nw,LP=(nw=class extends ll{constructor(){super();ge(this,Ki);ge(this,$o);ge(this,Sa);ae(this,Sa,t=>{if(typeof window<"u"&&window.addEventListener){const n=()=>t();return window.addEventListener("visibilitychange",n,!1),()=>{window.removeEventListener("visibilitychange",n)}}})}onSubscribe(){M(this,$o)||this.setEventListener(M(this,Sa))}onUnsubscribe(){var t;this.hasListeners()||((t=M(this,$o))==null||t.call(this),ae(this,$o,void 0))}setEventListener(t){var n;ae(this,Sa,t),(n=M(this,$o))==null||n.call(this),ae(this,$o,t(r=>{typeof r=="boolean"?this.setFocused(r):this.onFocus()}))}setFocused(t){M(this,Ki)!==t&&(ae(this,Ki,t),this.onFocus())}onFocus(){const t=this.isFocused();this.listeners.forEach(n=>{n(t)})}isFocused(){var t;return typeof M(this,Ki)=="boolean"?M(this,Ki):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},Ki=new WeakMap,$o=new WeakMap,Sa=new WeakMap,nw),Gm=new LP,OP={setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),setInterval:(e,t)=>setInterval(e,t),clearInterval:e=>clearInterval(e)},Fo,tm,rw,AP=(rw=class{constructor(){ge(this,Fo,OP);ge(this,tm,!1)}setTimeoutProvider(e){ae(this,Fo,e)}setTimeout(e,t){return M(this,Fo).setTimeout(e,t)}clearTimeout(e){M(this,Fo).clearTimeout(e)}setInterval(e,t){return M(this,Fo).setInterval(e,t)}clearInterval(e){M(this,Fo).clearInterval(e)}},Fo=new WeakMap,tm=new WeakMap,rw),Vi=new AP;function DP(e){setTimeout(e,0)}var NP=typeof window>"u"||"Deno"in globalThis;function Jt(){}function _P(e,t){return typeof e=="function"?e(t):e}function Vg(e){return typeof e=="number"&&e>=0&&e!==1/0}function Pk(e,t){return Math.max(e+(t||0)-Date.now(),0)}function ii(e,t){return typeof e=="function"?e(t):e}function vn(e,t){return typeof e=="function"?e(t):e}function Fy(e,t){const{type:n="all",exact:r,fetchStatus:i,predicate:s,queryKey:a,stale:l}=e;if(a){if(r){if(t.queryHash!==Xm(a,t.options))return!1}else if(!Pc(t.queryKey,a))return!1}if(n!=="all"){const c=t.isActive();if(n==="active"&&!c||n==="inactive"&&c)return!1}return!(typeof l=="boolean"&&t.isStale()!==l||i&&i!==t.state.fetchStatus||s&&!s(t))}function zy(e,t){const{exact:n,status:r,predicate:i,mutationKey:s}=e;if(s){if(!t.options.mutationKey)return!1;if(n){if(ds(t.options.mutationKey)!==ds(s))return!1}else if(!Pc(t.options.mutationKey,s))return!1}return!(r&&t.state.status!==r||i&&!i(t))}function Xm(e,t){return((t==null?void 0:t.queryKeyHashFn)||ds)(e)}function ds(e){return JSON.stringify(e,(t,n)=>qg(n)?Object.keys(n).sort().reduce((r,i)=>(r[i]=n[i],r),{}):n)}function Pc(e,t){return e===t?!0:typeof e!=typeof t?!1:e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(t).every(n=>Pc(e[n],t[n])):!1}var $P=Object.prototype.hasOwnProperty;function Rk(e,t,n=0){if(e===t)return e;if(n>500)return t;const r=By(e)&&By(t);if(!r&&!(qg(e)&&qg(t)))return t;const s=(r?e:Object.keys(e)).length,a=r?t:Object.keys(t),l=a.length,c=r?new Array(l):{};let d=0;for(let u=0;u<l;u++){const f=r?u:a[u],h=e[f],g=t[f];if(h===g){c[f]=h,(r?u<s:$P.call(e,f))&&d++;continue}if(h===null||g===null||typeof h!="object"||typeof g!="object"){c[f]=g;continue}const v=Rk(h,g,n+1);c[f]=v,v===h&&d++}return s===l&&d===s?e:c}function lp(e,t){if(!t||Object.keys(e).length!==Object.keys(t).length)return!1;for(const n in e)if(e[n]!==t[n])return!1;return!0}function By(e){return Array.isArray(e)&&e.length===Object.keys(e).length}function qg(e){if(!Wy(e))return!1;const t=e.constructor;if(t===void 0)return!0;const n=t.prototype;return!(!Wy(n)||!n.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(e)!==Object.prototype)}function Wy(e){return Object.prototype.toString.call(e)==="[object Object]"}function FP(e){return new Promise(t=>{Vi.setTimeout(t,e)})}function Kg(e,t,n){return typeof n.structuralSharing=="function"?n.structuralSharing(e,t):n.structuralSharing!==!1?Rk(e,t):t}function zP(e,t,n=0){const r=[...e,t];return n&&r.length>n?r.slice(1):r}function BP(e,t,n=0){const r=[t,...e];return n&&r.length>n?r.slice(0,-1):r}var so=Symbol();function Ik(e,t){return!e.queryFn&&(t!=null&&t.initialPromise)?()=>t.initialPromise:!e.queryFn||e.queryFn===so?()=>Promise.reject(new Error(`Missing queryFn: '${e.queryHash}'`)):e.queryFn}function Jm(e,t){return typeof e=="function"?e(...t):!!e}function WP(e,t,n){let r=!1,i;return Object.defineProperty(e,"signal",{enumerable:!0,get:()=>(i??(i=t()),r||(r=!0,i.aborted?n():i.addEventListener("abort",n,{once:!0})),i)}),e}var Rc=(()=>{let e=()=>NP;return{isServer(){return e()},setIsServer(t){e=t}}})();function Qg(){let e,t;const n=new Promise((i,s)=>{e=i,t=s});n.status="pending",n.catch(()=>{});function r(i){Object.assign(n,i),delete n.resolve,delete n.reject}return n.resolve=i=>{r({status:"fulfilled",value:i}),e(i)},n.reject=i=>{r({status:"rejected",reason:i}),t(i)},n}var UP=DP;function HP(){let e=[],t=0,n=l=>{l()},r=l=>{l()},i=UP;const s=l=>{t?e.push(l):i(()=>{n(l)})},a=()=>{const l=e;e=[],l.length&&i(()=>{r(()=>{l.forEach(c=>{n(c)})})})};return{batch:l=>{let c;t++;try{c=l()}finally{t--,t||a()}return c},batchCalls:l=>(...c)=>{s(()=>{l(...c)})},schedule:s,setNotifyFunction:l=>{n=l},setBatchNotifyFunction:l=>{r=l},setScheduler:l=>{i=l}}}var Tt=HP(),Ca,zo,Ea,ow,VP=(ow=class extends ll{constructor(){super();ge(this,Ca,!0);ge(this,zo);ge(this,Ea);ae(this,Ea,t=>{if(typeof window<"u"&&window.addEventListener){const n=()=>t(!0),r=()=>t(!1);return window.addEventListener("online",n,!1),window.addEventListener("offline",r,!1),()=>{window.removeEventListener("online",n),window.removeEventListener("offline",r)}}})}onSubscribe(){M(this,zo)||this.setEventListener(M(this,Ea))}onUnsubscribe(){var t;this.hasListeners()||((t=M(this,zo))==null||t.call(this),ae(this,zo,void 0))}setEventListener(t){var n;ae(this,Ea,t),(n=M(this,zo))==null||n.call(this),ae(this,zo,t(this.setOnline.bind(this)))}setOnline(t){M(this,Ca)!==t&&(ae(this,Ca,t),this.listeners.forEach(r=>{r(t)}))}isOnline(){return M(this,Ca)}},Ca=new WeakMap,zo=new WeakMap,Ea=new WeakMap,ow),cp=new VP;function qP(e){return Math.min(1e3*2**e,3e4)}function Mk(e){return(e??"online")==="online"?cp.isOnline():!0}var Yg=class extends Error{constructor(e){super("CancelledError"),this.revert=e==null?void 0:e.revert,this.silent=e==null?void 0:e.silent}};function Lk(e){let t=!1,n=0,r;const i=Qg(),s=()=>i.status!=="pending",a=x=>{var b;if(!s()){const j=new Yg(x);h(j),(b=e.onCancel)==null||b.call(e,j)}},l=()=>{t=!0},c=()=>{t=!1},d=()=>Gm.isFocused()&&(e.networkMode==="always"||cp.isOnline())&&e.canRun(),u=()=>Mk(e.networkMode)&&e.canRun(),f=x=>{s()||(r==null||r(),i.resolve(x))},h=x=>{s()||(r==null||r(),i.reject(x))},g=()=>new Promise(x=>{var b;r=j=>{(s()||d())&&x(j)},(b=e.onPause)==null||b.call(e)}).then(()=>{var x;r=void 0,s()||(x=e.onContinue)==null||x.call(e)}),v=()=>{if(s())return;let x;const b=n===0?e.initialPromise:void 0;try{x=b??e.fn()}catch(j){x=Promise.reject(j)}Promise.resolve(x).then(f).catch(j=>{var T;if(s())return;const y=e.retry??(Rc.isServer()?0:3),w=e.retryDelay??qP,k=typeof w=="function"?w(n,j):w,S=y===!0||typeof y=="number"&&n<y||typeof y=="function"&&y(n,j);if(t||!S){h(j);return}n++,(T=e.onFail)==null||T.call(e,n,j),FP(k).then(()=>d()?void 0:g()).then(()=>{t?h(j):v()})})};return{promise:i,status:()=>i.status,cancel:a,continue:()=>(r==null||r(),i),cancelRetry:l,continueRetry:c,canStart:u,start:()=>(u()?v():g().then(v),i)}}var Qi,iw,Ok=(iw=class{constructor(){ge(this,Qi)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Vg(this.gcTime)&&ae(this,Qi,Vi.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(e){this.gcTime=Math.max(this.gcTime||0,e??(Rc.isServer()?1/0:5*60*1e3))}clearGcTimeout(){M(this,Qi)!==void 0&&(Vi.clearTimeout(M(this,Qi)),ae(this,Qi,void 0))}},Qi=new WeakMap,iw);function KP(e){return{onFetch:(t,n)=>{var u,f,h,g,v;const r=t.options,i=(h=(f=(u=t.fetchOptions)==null?void 0:u.meta)==null?void 0:f.fetchMore)==null?void 0:h.direction,s=((g=t.state.data)==null?void 0:g.pages)||[],a=((v=t.state.data)==null?void 0:v.pageParams)||[];let l={pages:[],pageParams:[]},c=0;const d=async()=>{let x=!1;const b=w=>{WP(w,()=>t.signal,()=>x=!0)},j=Ik(t.options,t.fetchOptions),y=async(w,k,S)=>{if(x)return Promise.reject(t.signal.reason);if(k==null&&w.pages.length)return Promise.resolve(w);const C=(()=>{const z={client:t.client,queryKey:t.queryKey,pageParam:k,direction:S?"backward":"forward",meta:t.options.meta};return b(z),z})(),P=await j(C),{maxPages:I}=t.options,L=S?BP:zP;return{pages:L(w.pages,P,I),pageParams:L(w.pageParams,k,I)}};if(i&&s.length){const w=i==="backward",k=w?QP:Uy,S={pages:s,pageParams:a},T=k(r,S);l=await y(S,T,w)}else{const w=e??s.length;do{const k=c===0?a[0]??r.initialPageParam:Uy(r,l);if(c>0&&k==null)break;l=await y(l,k),c++}while(c<w)}return l};t.options.persister?t.fetchFn=()=>{var x,b;return(b=(x=t.options).persister)==null?void 0:b.call(x,d,{client:t.client,queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},n)}:t.fetchFn=d}}}function Uy(e,{pages:t,pageParams:n}){const r=t.length-1;return t.length>0?e.getNextPageParam(t[r],t,n[r],n):void 0}function QP(e,{pages:t,pageParams:n}){var r;return t.length>0?(r=e.getPreviousPageParam)==null?void 0:r.call(e,t[0],t,n[0],n):void 0}var Ta,Yi,Pa,On,Gi,Rt,Bc,Xi,mn,Ak,Wr,sw,YP=(sw=class extends Ok{constructor(t){super();ge(this,mn);ge(this,Ta);ge(this,Yi);ge(this,Pa);ge(this,On);ge(this,Gi);ge(this,Rt);ge(this,Bc);ge(this,Xi);ae(this,Xi,!1),ae(this,Bc,t.defaultOptions),this.setOptions(t.options),this.observers=[],ae(this,Gi,t.client),ae(this,On,M(this,Gi).getQueryCache()),this.queryKey=t.queryKey,this.queryHash=t.queryHash,ae(this,Yi,Vy(this.options)),this.state=t.state??M(this,Yi),this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return M(this,Ta)}get promise(){var t;return(t=M(this,Rt))==null?void 0:t.promise}setOptions(t){if(this.options={...M(this,Bc),...t},t!=null&&t._type&&ae(this,Ta,t._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){const n=Vy(this.options);n.data!==void 0&&(this.setState(Hy(n.data,n.dataUpdatedAt)),ae(this,Yi,n))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&M(this,On).remove(this)}setData(t,n){const r=Kg(this.state.data,t,this.options);return ke(this,mn,Wr).call(this,{data:r,type:"success",dataUpdatedAt:n==null?void 0:n.updatedAt,manual:n==null?void 0:n.manual}),r}setState(t){ke(this,mn,Wr).call(this,{type:"setState",state:t})}cancel(t){var r,i;const n=(r=M(this,Rt))==null?void 0:r.promise;return(i=M(this,Rt))==null||i.cancel(t),n?n.then(Jt).catch(Jt):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return M(this,Yi)}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(t=>vn(t.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===so||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(t=>ii(t.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(t=>t.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(t=0){return this.state.data===void 0?!0:t==="static"?!1:this.state.isInvalidated?!0:!Pk(this.state.dataUpdatedAt,t)}onFocus(){var n;const t=this.observers.find(r=>r.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(n=M(this,Rt))==null||n.continue()}onOnline(){var n;const t=this.observers.find(r=>r.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(n=M(this,Rt))==null||n.continue()}addObserver(t){this.observers.includes(t)||(this.observers.push(t),this.clearGcTimeout(),M(this,On).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){this.observers.includes(t)&&(this.observers=this.observers.filter(n=>n!==t),this.observers.length||(M(this,Rt)&&(M(this,Xi)||ke(this,mn,Ak).call(this)?M(this,Rt).cancel({revert:!0}):M(this,Rt).cancelRetry()),this.scheduleGc()),M(this,On).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||ke(this,mn,Wr).call(this,{type:"invalidate"})}async fetch(t,n){var d,u,f,h,g,v,x,b,j,y,w;if(this.state.fetchStatus!=="idle"&&((d=M(this,Rt))==null?void 0:d.status())!=="rejected"){if(this.state.data!==void 0&&(n!=null&&n.cancelRefetch))this.cancel({silent:!0});else if(M(this,Rt))return M(this,Rt).continueRetry(),M(this,Rt).promise}if(t&&this.setOptions(t),!this.options.queryFn){const k=this.observers.find(S=>S.options.queryFn);k&&this.setOptions(k.options)}const r=new AbortController,i=k=>{Object.defineProperty(k,"signal",{enumerable:!0,get:()=>(ae(this,Xi,!0),r.signal)})},s=()=>{const k=Ik(this.options,n),T=(()=>{const C={client:M(this,Gi),queryKey:this.queryKey,meta:this.meta};return i(C),C})();return ae(this,Xi,!1),this.options.persister?this.options.persister(k,T,this):k(T)},l=(()=>{const k={fetchOptions:n,options:this.options,queryKey:this.queryKey,client:M(this,Gi),state:this.state,fetchFn:s};return i(k),k})(),c=M(this,Ta)==="infinite"?KP(this.options.pages):this.options.behavior;c==null||c.onFetch(l,this),ae(this,Pa,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((u=l.fetchOptions)==null?void 0:u.meta))&&ke(this,mn,Wr).call(this,{type:"fetch",meta:(f=l.fetchOptions)==null?void 0:f.meta}),ae(this,Rt,Lk({initialPromise:n==null?void 0:n.initialPromise,fn:l.fetchFn,onCancel:k=>{k instanceof Yg&&k.revert&&this.setState({...M(this,Pa),fetchStatus:"idle"}),r.abort()},onFail:(k,S)=>{ke(this,mn,Wr).call(this,{type:"failed",failureCount:k,error:S})},onPause:()=>{ke(this,mn,Wr).call(this,{type:"pause"})},onContinue:()=>{ke(this,mn,Wr).call(this,{type:"continue"})},retry:l.options.retry,retryDelay:l.options.retryDelay,networkMode:l.options.networkMode,canRun:()=>!0}));try{const k=await M(this,Rt).start();if(k===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(k),(g=(h=M(this,On).config).onSuccess)==null||g.call(h,k,this),(x=(v=M(this,On).config).onSettled)==null||x.call(v,k,this.state.error,this),k}catch(k){if(k instanceof Yg){if(k.silent)return M(this,Rt).promise;if(k.revert){if(this.state.data===void 0)throw k;return this.state.data}}throw ke(this,mn,Wr).call(this,{type:"error",error:k}),(j=(b=M(this,On).config).onError)==null||j.call(b,k,this),(w=(y=M(this,On).config).onSettled)==null||w.call(y,this.state.data,k,this),k}finally{this.scheduleGc()}}},Ta=new WeakMap,Yi=new WeakMap,Pa=new WeakMap,On=new WeakMap,Gi=new WeakMap,Rt=new WeakMap,Bc=new WeakMap,Xi=new WeakMap,mn=new WeakSet,Ak=function(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"},Wr=function(t){const n=r=>{switch(t.type){case"failed":return{...r,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...r,fetchStatus:"paused"};case"continue":return{...r,fetchStatus:"fetching"};case"fetch":return{...r,...Dk(r.data,this.options),fetchMeta:t.meta??null};case"success":const i={...r,...Hy(t.data,t.dataUpdatedAt),dataUpdateCount:r.dataUpdateCount+1,...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return ae(this,Pa,t.manual?i:void 0),i;case"error":const s=t.error;return{...r,error:s,errorUpdateCount:r.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:r.fetchFailureCount+1,fetchFailureReason:s,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...r,isInvalidated:!0};case"setState":return{...r,...t.state}}};this.state=n(this.state),Tt.batch(()=>{this.observers.forEach(r=>{r.onQueryUpdate()}),M(this,On).notify({query:this,type:"updated",action:t})})},sw);function Dk(e,t){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Mk(t.networkMode)?"fetching":"paused",...e===void 0&&{error:null,status:"pending"}}}function Hy(e,t){return{data:e,dataUpdatedAt:t??Date.now(),error:null,isInvalidated:!1,status:"success"}}function Vy(e){const t=typeof e.initialData=="function"?e.initialData():e.initialData,n=t!==void 0,r=n?typeof e.initialDataUpdatedAt=="function"?e.initialDataUpdatedAt():e.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:n?r??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:n?"success":"pending",fetchStatus:"idle"}}var on,Ae,Wc,Yt,Ji,Ra,Kr,Bo,Uc,Ia,Ma,Zi,es,Wo,La,Fe,zl,Gg,Xg,Jg,Zg,ex,tx,nx,Nk,aw,GP=(aw=class extends ll{constructor(t,n){super();ge(this,Fe);ge(this,on);ge(this,Ae);ge(this,Wc);ge(this,Yt);ge(this,Ji);ge(this,Ra);ge(this,Kr);ge(this,Bo);ge(this,Uc);ge(this,Ia);ge(this,Ma);ge(this,Zi);ge(this,es);ge(this,Wo);ge(this,La,new Set);this.options=n,ae(this,on,t),ae(this,Bo,null),ae(this,Kr,Qg()),this.bindMethods(),this.setOptions(n)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(M(this,Ae).addObserver(this),qy(M(this,Ae),this.options)?ke(this,Fe,zl).call(this):this.updateResult(),ke(this,Fe,Zg).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return rx(M(this,Ae),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return rx(M(this,Ae),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,ke(this,Fe,ex).call(this),ke(this,Fe,tx).call(this),M(this,Ae).removeObserver(this)}setOptions(t){const n=this.options,r=M(this,Ae);if(this.options=M(this,on).defaultQueryOptions(t),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof vn(this.options.enabled,M(this,Ae))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");ke(this,Fe,nx).call(this),M(this,Ae).setOptions(this.options),n._defaulted&&!lp(this.options,n)&&M(this,on).getQueryCache().notify({type:"observerOptionsUpdated",query:M(this,Ae),observer:this});const i=this.hasListeners();i&&Ky(M(this,Ae),r,this.options,n)&&ke(this,Fe,zl).call(this),this.updateResult(),i&&(M(this,Ae)!==r||vn(this.options.enabled,M(this,Ae))!==vn(n.enabled,M(this,Ae))||ii(this.options.staleTime,M(this,Ae))!==ii(n.staleTime,M(this,Ae)))&&ke(this,Fe,Gg).call(this);const s=ke(this,Fe,Xg).call(this);i&&(M(this,Ae)!==r||vn(this.options.enabled,M(this,Ae))!==vn(n.enabled,M(this,Ae))||s!==M(this,Wo))&&ke(this,Fe,Jg).call(this,s)}getOptimisticResult(t){const n=M(this,on).getQueryCache().build(M(this,on),t),r=this.createResult(n,t);return JP(this,r)&&(ae(this,Yt,r),ae(this,Ra,this.options),ae(this,Ji,M(this,Ae).state)),r}getCurrentResult(){return M(this,Yt)}trackResult(t,n){return new Proxy(t,{get:(r,i)=>(this.trackProp(i),n==null||n(i),i==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&M(this,Kr).status==="pending"&&M(this,Kr).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(r,i))})}trackProp(t){M(this,La).add(t)}getCurrentQuery(){return M(this,Ae)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const n=M(this,on).defaultQueryOptions(t),r=M(this,on).getQueryCache().build(M(this,on),n);return r.fetch().then(()=>this.createResult(r,n))}fetch(t){return ke(this,Fe,zl).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),M(this,Yt)))}createResult(t,n){var I;const r=M(this,Ae),i=this.options,s=M(this,Yt),a=M(this,Ji),l=M(this,Ra),d=t!==r?t.state:M(this,Wc),{state:u}=t;let f={...u},h=!1,g;if(n._optimisticResults){const L=this.hasListeners(),z=!L&&qy(t,n),q=L&&Ky(t,r,n,i);(z||q)&&(f={...f,...Dk(u.data,t.options)}),n._optimisticResults==="isRestoring"&&(f.fetchStatus="idle")}let{error:v,errorUpdatedAt:x,status:b}=f;g=f.data;let j=!1;if(n.placeholderData!==void 0&&g===void 0&&b==="pending"){let L;s!=null&&s.isPlaceholderData&&n.placeholderData===(l==null?void 0:l.placeholderData)?(L=s.data,j=!0):L=typeof n.placeholderData=="function"?n.placeholderData((I=M(this,Ma))==null?void 0:I.state.data,M(this,Ma)):n.placeholderData,L!==void 0&&(b="success",g=Kg(s==null?void 0:s.data,L,n),h=!0)}if(n.select&&g!==void 0&&!j)if(s&&g===(a==null?void 0:a.data)&&n.select===M(this,Uc))g=M(this,Ia);else try{ae(this,Uc,n.select),g=n.select(g),g=Kg(s==null?void 0:s.data,g,n),ae(this,Ia,g),ae(this,Bo,null)}catch(L){ae(this,Bo,L)}M(this,Bo)&&(v=M(this,Bo),g=M(this,Ia),x=Date.now(),b="error");const y=f.fetchStatus==="fetching",w=b==="pending",k=b==="error",S=w&&y,T=g!==void 0,P={status:b,fetchStatus:f.fetchStatus,isPending:w,isSuccess:b==="success",isError:k,isInitialLoading:S,isLoading:S,data:g,dataUpdatedAt:f.dataUpdatedAt,error:v,errorUpdatedAt:x,failureCount:f.fetchFailureCount,failureReason:f.fetchFailureReason,errorUpdateCount:f.errorUpdateCount,isFetched:t.isFetched(),isFetchedAfterMount:f.dataUpdateCount>d.dataUpdateCount||f.errorUpdateCount>d.errorUpdateCount,isFetching:y,isRefetching:y&&!w,isLoadingError:k&&!T,isPaused:f.fetchStatus==="paused",isPlaceholderData:h,isRefetchError:k&&T,isStale:Zm(t,n),refetch:this.refetch,promise:M(this,Kr),isEnabled:vn(n.enabled,t)!==!1};if(this.options.experimental_prefetchInRender){const L=P.data!==void 0,z=P.status==="error"&&!L,q=U=>{z?U.reject(P.error):L&&U.resolve(P.data)},X=()=>{const U=ae(this,Kr,P.promise=Qg());q(U)},D=M(this,Kr);switch(D.status){case"pending":t.queryHash===r.queryHash&&q(D);break;case"fulfilled":(z||P.data!==D.value)&&X();break;case"rejected":(!z||P.error!==D.reason)&&X();break}}return P}updateResult(){const t=M(this,Yt),n=this.createResult(M(this,Ae),this.options);if(ae(this,Ji,M(this,Ae).state),ae(this,Ra,this.options),M(this,Ji).data!==void 0&&ae(this,Ma,M(this,Ae)),lp(n,t))return;ae(this,Yt,n);const r=()=>{if(!t)return!0;const{notifyOnChangeProps:i}=this.options,s=typeof i=="function"?i():i;if(s==="all"||!s&&!M(this,La).size)return!0;const a=new Set(s??M(this,La));return this.options.throwOnError&&a.add("error"),Object.keys(M(this,Yt)).some(l=>{const c=l;return M(this,Yt)[c]!==t[c]&&a.has(c)})};ke(this,Fe,Nk).call(this,{listeners:r()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&ke(this,Fe,Zg).call(this)}},on=new WeakMap,Ae=new WeakMap,Wc=new WeakMap,Yt=new WeakMap,Ji=new WeakMap,Ra=new WeakMap,Kr=new WeakMap,Bo=new WeakMap,Uc=new WeakMap,Ia=new WeakMap,Ma=new WeakMap,Zi=new WeakMap,es=new WeakMap,Wo=new WeakMap,La=new WeakMap,Fe=new WeakSet,zl=function(t){ke(this,Fe,nx).call(this);let n=M(this,Ae).fetch(this.options,t);return t!=null&&t.throwOnError||(n=n.catch(Jt)),n},Gg=function(){ke(this,Fe,ex).call(this);const t=ii(this.options.staleTime,M(this,Ae));if(Rc.isServer()||M(this,Yt).isStale||!Vg(t))return;const r=Pk(M(this,Yt).dataUpdatedAt,t)+1;ae(this,Zi,Vi.setTimeout(()=>{M(this,Yt).isStale||this.updateResult()},r))},Xg=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(M(this,Ae)):this.options.refetchInterval)??!1},Jg=function(t){ke(this,Fe,tx).call(this),ae(this,Wo,t),!(Rc.isServer()||vn(this.options.enabled,M(this,Ae))===!1||!Vg(M(this,Wo))||M(this,Wo)===0)&&ae(this,es,Vi.setInterval(()=>{(this.options.refetchIntervalInBackground||Gm.isFocused())&&ke(this,Fe,zl).call(this)},M(this,Wo)))},Zg=function(){ke(this,Fe,Gg).call(this),ke(this,Fe,Jg).call(this,ke(this,Fe,Xg).call(this))},ex=function(){M(this,Zi)!==void 0&&(Vi.clearTimeout(M(this,Zi)),ae(this,Zi,void 0))},tx=function(){M(this,es)!==void 0&&(Vi.clearInterval(M(this,es)),ae(this,es,void 0))},nx=function(){const t=M(this,on).getQueryCache().build(M(this,on),this.options);if(t===M(this,Ae))return;const n=M(this,Ae);ae(this,Ae,t),ae(this,Wc,t.state),this.hasListeners()&&(n==null||n.removeObserver(this),t.addObserver(this))},Nk=function(t){Tt.batch(()=>{t.listeners&&this.listeners.forEach(n=>{n(M(this,Yt))}),M(this,on).getQueryCache().notify({query:M(this,Ae),type:"observerResultsUpdated"})})},aw);function XP(e,t){return vn(t.enabled,e)!==!1&&e.state.data===void 0&&!(e.state.status==="error"&&vn(t.retryOnMount,e)===!1)}function qy(e,t){return XP(e,t)||e.state.data!==void 0&&rx(e,t,t.refetchOnMount)}function rx(e,t,n){if(vn(t.enabled,e)!==!1&&ii(t.staleTime,e)!=="static"){const r=typeof n=="function"?n(e):n;return r==="always"||r!==!1&&Zm(e,t)}return!1}function Ky(e,t,n,r){return(e!==t||vn(r.enabled,e)===!1)&&(!n.suspense||e.state.status!=="error")&&Zm(e,n)}function Zm(e,t){return vn(t.enabled,e)!==!1&&e.isStaleByTime(ii(t.staleTime,e))}function JP(e,t){return!lp(e.getCurrentResult(),t)}var Hc,br,Ut,ts,jr,Po,lw,ZP=(lw=class extends Ok{constructor(t){super();ge(this,jr);ge(this,Hc);ge(this,br);ge(this,Ut);ge(this,ts);ae(this,Hc,t.client),this.mutationId=t.mutationId,ae(this,Ut,t.mutationCache),ae(this,br,[]),this.state=t.state||_k(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){M(this,br).includes(t)||(M(this,br).push(t),this.clearGcTimeout(),M(this,Ut).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){ae(this,br,M(this,br).filter(n=>n!==t)),this.scheduleGc(),M(this,Ut).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){M(this,br).length||(this.state.status==="pending"?this.scheduleGc():M(this,Ut).remove(this))}continue(){var t;return((t=M(this,ts))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var a,l,c,d,u,f,h,g,v,x,b,j,y,w,k,S,T,C;const n=()=>{ke(this,jr,Po).call(this,{type:"continue"})},r={client:M(this,Hc),meta:this.options.meta,mutationKey:this.options.mutationKey};ae(this,ts,Lk({fn:()=>this.options.mutationFn?this.options.mutationFn(t,r):Promise.reject(new Error("No mutationFn found")),onFail:(P,I)=>{ke(this,jr,Po).call(this,{type:"failed",failureCount:P,error:I})},onPause:()=>{ke(this,jr,Po).call(this,{type:"pause"})},onContinue:n,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>M(this,Ut).canRun(this)}));const i=this.state.status==="pending",s=!M(this,ts).canStart();try{if(i)n();else{ke(this,jr,Po).call(this,{type:"pending",variables:t,isPaused:s}),M(this,Ut).config.onMutate&&await M(this,Ut).config.onMutate(t,this,r);const I=await((l=(a=this.options).onMutate)==null?void 0:l.call(a,t,r));I!==this.state.context&&ke(this,jr,Po).call(this,{type:"pending",context:I,variables:t,isPaused:s})}const P=await M(this,ts).start();return await((d=(c=M(this,Ut).config).onSuccess)==null?void 0:d.call(c,P,t,this.state.context,this,r)),await((f=(u=this.options).onSuccess)==null?void 0:f.call(u,P,t,this.state.context,r)),await((g=(h=M(this,Ut).config).onSettled)==null?void 0:g.call(h,P,null,this.state.variables,this.state.context,this,r)),await((x=(v=this.options).onSettled)==null?void 0:x.call(v,P,null,t,this.state.context,r)),ke(this,jr,Po).call(this,{type:"success",data:P}),P}catch(P){try{await((j=(b=M(this,Ut).config).onError)==null?void 0:j.call(b,P,t,this.state.context,this,r))}catch(I){Promise.reject(I)}try{await((w=(y=this.options).onError)==null?void 0:w.call(y,P,t,this.state.context,r))}catch(I){Promise.reject(I)}try{await((S=(k=M(this,Ut).config).onSettled)==null?void 0:S.call(k,void 0,P,this.state.variables,this.state.context,this,r))}catch(I){Promise.reject(I)}try{await((C=(T=this.options).onSettled)==null?void 0:C.call(T,void 0,P,t,this.state.context,r))}catch(I){Promise.reject(I)}throw ke(this,jr,Po).call(this,{type:"error",error:P}),P}finally{M(this,Ut).runNext(this)}}},Hc=new WeakMap,br=new WeakMap,Ut=new WeakMap,ts=new WeakMap,jr=new WeakSet,Po=function(t){const n=r=>{switch(t.type){case"failed":return{...r,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...r,isPaused:!0};case"continue":return{...r,isPaused:!1};case"pending":return{...r,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...r,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...r,data:void 0,error:t.error,failureCount:r.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=n(this.state),Tt.batch(()=>{M(this,br).forEach(r=>{r.onMutationUpdate(t)}),M(this,Ut).notify({mutation:this,type:"updated",action:t})})},lw);function _k(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Qr,Gn,Vc,cw,eR=(cw=class extends ll{constructor(t={}){super();ge(this,Qr);ge(this,Gn);ge(this,Vc);this.config=t,ae(this,Qr,new Set),ae(this,Gn,new Map),ae(this,Vc,0)}build(t,n,r){const i=new ZP({client:t,mutationCache:this,mutationId:++kd(this,Vc)._,options:t.defaultMutationOptions(n),state:r});return this.add(i),i}add(t){M(this,Qr).add(t);const n=Bd(t);if(typeof n=="string"){const r=M(this,Gn).get(n);r?r.push(t):M(this,Gn).set(n,[t])}this.notify({type:"added",mutation:t})}remove(t){if(M(this,Qr).delete(t)){const n=Bd(t);if(typeof n=="string"){const r=M(this,Gn).get(n);if(r)if(r.length>1){const i=r.indexOf(t);i!==-1&&r.splice(i,1)}else r[0]===t&&M(this,Gn).delete(n)}}this.notify({type:"removed",mutation:t})}canRun(t){const n=Bd(t);if(typeof n=="string"){const r=M(this,Gn).get(n),i=r==null?void 0:r.find(s=>s.state.status==="pending");return!i||i===t}else return!0}runNext(t){var r;const n=Bd(t);if(typeof n=="string"){const i=(r=M(this,Gn).get(n))==null?void 0:r.find(s=>s!==t&&s.state.isPaused);return(i==null?void 0:i.continue())??Promise.resolve()}else return Promise.resolve()}clear(){Tt.batch(()=>{M(this,Qr).forEach(t=>{this.notify({type:"removed",mutation:t})}),M(this,Qr).clear(),M(this,Gn).clear()})}getAll(){return Array.from(M(this,Qr))}find(t){const n={exact:!0,...t};return this.getAll().find(r=>zy(n,r))}findAll(t={}){return this.getAll().filter(n=>zy(t,n))}notify(t){Tt.batch(()=>{this.listeners.forEach(n=>{n(t)})})}resumePausedMutations(){const t=this.getAll().filter(n=>n.state.isPaused);return Tt.batch(()=>Promise.all(t.map(n=>n.continue().catch(Jt))))}},Qr=new WeakMap,Gn=new WeakMap,Vc=new WeakMap,cw);function Bd(e){var t;return(t=e.options.scope)==null?void 0:t.id}var Yr,Uo,sn,Gr,to,Eu,ox,dw,tR=(dw=class extends ll{constructor(n,r){super();ge(this,to);ge(this,Yr);ge(this,Uo);ge(this,sn);ge(this,Gr);ae(this,Yr,n),this.setOptions(r),this.bindMethods(),ke(this,to,Eu).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(n){var i;const r=this.options;this.options=M(this,Yr).defaultMutationOptions(n),lp(this.options,r)||M(this,Yr).getMutationCache().notify({type:"observerOptionsUpdated",mutation:M(this,sn),observer:this}),r!=null&&r.mutationKey&&this.options.mutationKey&&ds(r.mutationKey)!==ds(this.options.mutationKey)?this.reset():((i=M(this,sn))==null?void 0:i.state.status)==="pending"&&M(this,sn).setOptions(this.options)}onUnsubscribe(){var n;this.hasListeners()||(n=M(this,sn))==null||n.removeObserver(this)}onMutationUpdate(n){ke(this,to,Eu).call(this),ke(this,to,ox).call(this,n)}getCurrentResult(){return M(this,Uo)}reset(){var n;(n=M(this,sn))==null||n.removeObserver(this),ae(this,sn,void 0),ke(this,to,Eu).call(this),ke(this,to,ox).call(this)}mutate(n,r){var i;return ae(this,Gr,r),(i=M(this,sn))==null||i.removeObserver(this),ae(this,sn,M(this,Yr).getMutationCache().build(M(this,Yr),this.options)),M(this,sn).addObserver(this),M(this,sn).execute(n)}},Yr=new WeakMap,Uo=new WeakMap,sn=new WeakMap,Gr=new WeakMap,to=new WeakSet,Eu=function(){var r;const n=((r=M(this,sn))==null?void 0:r.state)??_k();ae(this,Uo,{...n,isPending:n.status==="pending",isSuccess:n.status==="success",isError:n.status==="error",isIdle:n.status==="idle",mutate:this.mutate,reset:this.reset})},ox=function(n){Tt.batch(()=>{var r,i,s,a,l,c,d,u;if(M(this,Gr)&&this.hasListeners()){const f=M(this,Uo).variables,h=M(this,Uo).context,g={client:M(this,Yr),meta:this.options.meta,mutationKey:this.options.mutationKey};if((n==null?void 0:n.type)==="success"){try{(i=(r=M(this,Gr)).onSuccess)==null||i.call(r,n.data,f,h,g)}catch(v){Promise.reject(v)}try{(a=(s=M(this,Gr)).onSettled)==null||a.call(s,n.data,null,f,h,g)}catch(v){Promise.reject(v)}}else if((n==null?void 0:n.type)==="error"){try{(c=(l=M(this,Gr)).onError)==null||c.call(l,n.error,f,h,g)}catch(v){Promise.reject(v)}try{(u=(d=M(this,Gr)).onSettled)==null||u.call(d,void 0,n.error,f,h,g)}catch(v){Promise.reject(v)}}}this.listeners.forEach(f=>{f(M(this,Uo))})})},dw),wr,uw,nR=(uw=class extends ll{constructor(t={}){super();ge(this,wr);this.config=t,ae(this,wr,new Map)}build(t,n,r){const i=n.queryKey,s=n.queryHash??Xm(i,n);let a=this.get(s);return a||(a=new YP({client:t,queryKey:i,queryHash:s,options:t.defaultQueryOptions(n),state:r,defaultOptions:t.getQueryDefaults(i)}),this.add(a)),a}add(t){M(this,wr).has(t.queryHash)||(M(this,wr).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const n=M(this,wr).get(t.queryHash);n&&(t.destroy(),n===t&&M(this,wr).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){Tt.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return M(this,wr).get(t)}getAll(){return[...M(this,wr).values()]}find(t){const n={exact:!0,...t};return this.getAll().find(r=>Fy(n,r))}findAll(t={}){const n=this.getAll();return Object.keys(t).length>0?n.filter(r=>Fy(t,r)):n}notify(t){Tt.batch(()=>{this.listeners.forEach(n=>{n(t)})})}onFocus(){Tt.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){Tt.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},wr=new WeakMap,uw),ft,Ho,Vo,Oa,Aa,qo,Da,Na,pw,rR=(pw=class{constructor(e={}){ge(this,ft);ge(this,Ho);ge(this,Vo);ge(this,Oa);ge(this,Aa);ge(this,qo);ge(this,Da);ge(this,Na);ae(this,ft,e.queryCache||new nR),ae(this,Ho,e.mutationCache||new eR),ae(this,Vo,e.defaultOptions||{}),ae(this,Oa,new Map),ae(this,Aa,new Map),ae(this,qo,0)}mount(){kd(this,qo)._++,M(this,qo)===1&&(ae(this,Da,Gm.subscribe(async e=>{e&&(await this.resumePausedMutations(),M(this,ft).onFocus())})),ae(this,Na,cp.subscribe(async e=>{e&&(await this.resumePausedMutations(),M(this,ft).onOnline())})))}unmount(){var e,t;kd(this,qo)._--,M(this,qo)===0&&((e=M(this,Da))==null||e.call(this),ae(this,Da,void 0),(t=M(this,Na))==null||t.call(this),ae(this,Na,void 0))}isFetching(e){return M(this,ft).findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return M(this,Ho).findAll({...e,status:"pending"}).length}getQueryData(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=M(this,ft).get(t.queryHash))==null?void 0:n.state.data}ensureQueryData(e){const t=this.defaultQueryOptions(e),n=M(this,ft).build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(ii(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return M(this,ft).findAll(e).map(({queryKey:t,state:n})=>{const r=n.data;return[t,r]})}setQueryData(e,t,n){const r=this.defaultQueryOptions({queryKey:e}),i=M(this,ft).get(r.queryHash),s=i==null?void 0:i.state.data,a=_P(t,s);if(a!==void 0)return M(this,ft).build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return Tt.batch(()=>M(this,ft).findAll(e).map(({queryKey:r})=>[r,this.setQueryData(r,t,n)]))}getQueryState(e){var n;const t=this.defaultQueryOptions({queryKey:e});return(n=M(this,ft).get(t.queryHash))==null?void 0:n.state}removeQueries(e){const t=M(this,ft);Tt.batch(()=>{t.findAll(e).forEach(n=>{t.remove(n)})})}resetQueries(e,t){const n=M(this,ft);return Tt.batch(()=>(n.findAll(e).forEach(r=>{r.reset()}),this.refetchQueries({type:"active",...e},t)))}cancelQueries(e,t={}){const n={revert:!0,...t},r=Tt.batch(()=>M(this,ft).findAll(e).map(i=>i.cancel(n)));return Promise.all(r).then(Jt).catch(Jt)}invalidateQueries(e,t={}){return Tt.batch(()=>(M(this,ft).findAll(e).forEach(n=>{n.invalidate()}),(e==null?void 0:e.refetchType)==="none"?Promise.resolve():this.refetchQueries({...e,type:(e==null?void 0:e.refetchType)??(e==null?void 0:e.type)??"active"},t)))}refetchQueries(e,t={}){const n={...t,cancelRefetch:t.cancelRefetch??!0},r=Tt.batch(()=>M(this,ft).findAll(e).filter(i=>!i.isDisabled()&&!i.isStatic()).map(i=>{let s=i.fetch(void 0,n);return n.throwOnError||(s=s.catch(Jt)),i.state.fetchStatus==="paused"?Promise.resolve():s}));return Promise.all(r).then(Jt)}fetchQuery(e){const t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);const n=M(this,ft).build(this,t);return n.isStaleByTime(ii(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Jt).catch(Jt)}fetchInfiniteQuery(e){return e._type="infinite",this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Jt).catch(Jt)}ensureInfiniteQueryData(e){return e._type="infinite",this.ensureQueryData(e)}resumePausedMutations(){return cp.isOnline()?M(this,Ho).resumePausedMutations():Promise.resolve()}getQueryCache(){return M(this,ft)}getMutationCache(){return M(this,Ho)}getDefaultOptions(){return M(this,Vo)}setDefaultOptions(e){ae(this,Vo,e)}setQueryDefaults(e,t){M(this,Oa).set(ds(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){const t=[...M(this,Oa).values()],n={};return t.forEach(r=>{Pc(e,r.queryKey)&&Object.assign(n,r.defaultOptions)}),n}setMutationDefaults(e,t){M(this,Aa).set(ds(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){const t=[...M(this,Aa).values()],n={};return t.forEach(r=>{Pc(e,r.mutationKey)&&Object.assign(n,r.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;const t={...M(this,Vo).queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=Xm(t.queryKey,t)),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!=="always"),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===so&&(t.enabled=!1),t}defaultMutationOptions(e){return e!=null&&e._defaulted?e:{...M(this,Vo).mutations,...(e==null?void 0:e.mutationKey)&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){M(this,ft).clear(),M(this,Ho).clear()}},ft=new WeakMap,Ho=new WeakMap,Vo=new WeakMap,Oa=new WeakMap,Aa=new WeakMap,qo=new WeakMap,Da=new WeakMap,Na=new WeakMap,pw),$k=p.createContext(void 0),je=e=>{const t=p.useContext($k);if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},oR=({client:e,children:t})=>(p.useEffect(()=>(e.mount(),()=>{e.unmount()}),[e]),o.jsx($k.Provider,{value:e,children:t})),Fk=p.createContext(!1),iR=()=>p.useContext(Fk);Fk.Provider;function sR(){let e=!1;return{clearReset:()=>{e=!1},reset:()=>{e=!0},isReset:()=>e}}var aR=p.createContext(sR()),lR=()=>p.useContext(aR),cR=(e,t,n)=>{const r=n!=null&&n.state.error&&typeof e.throwOnError=="function"?Jm(e.throwOnError,[n.state.error,n]):e.throwOnError;(e.suspense||e.experimental_prefetchInRender||r)&&(t.isReset()||(e.retryOnMount=!1))},dR=e=>{p.useEffect(()=>{e.clearReset()},[e])},uR=({result:e,errorResetBoundary:t,throwOnError:n,query:r,suspense:i})=>e.isError&&!t.isReset()&&!e.isFetching&&r&&(i&&e.data===void 0||Jm(n,[e.error,r])),pR=e=>{if(e.suspense){const n=i=>i==="static"?i:Math.max(i??1e3,1e3),r=e.staleTime;e.staleTime=typeof r=="function"?(...i)=>n(r(...i)):n(r),typeof e.gcTime=="number"&&(e.gcTime=Math.max(e.gcTime,1e3))}},fR=(e,t)=>e.isLoading&&e.isFetching&&!t,hR=(e,t)=>(e==null?void 0:e.suspense)&&t.isPending,Qy=(e,t,n)=>t.fetchOptimistic(e).catch(()=>{n.clearReset()});function gR(e,t,n){var g,v,x,b;const r=iR(),i=lR(),s=je(),a=s.defaultQueryOptions(e);(v=(g=s.getDefaultOptions().queries)==null?void 0:g._experimental_beforeQuery)==null||v.call(g,a);const l=s.getQueryCache().get(a.queryHash),c=e.subscribed!==!1;a._optimisticResults=r?"isRestoring":c?"optimistic":void 0,pR(a),cR(a,i,l),dR(i);const d=!s.getQueryCache().get(a.queryHash),[u]=p.useState(()=>new t(s,a)),f=u.getOptimisticResult(a),h=!r&&c;if(p.useSyncExternalStore(p.useCallback(j=>{const y=h?u.subscribe(Tt.batchCalls(j)):Jt;return u.updateResult(),y},[u,h]),()=>u.getCurrentResult(),()=>u.getCurrentResult()),p.useEffect(()=>{u.setOptions(a)},[a,u]),hR(a,f))throw Qy(a,u,i);if(uR({result:f,errorResetBoundary:i,throwOnError:a.throwOnError,query:l,suspense:a.suspense}))throw f.error;if((b=(x=s.getDefaultOptions().queries)==null?void 0:x._experimental_afterQuery)==null||b.call(x,a,f),a.experimental_prefetchInRender&&!Rc.isServer()&&fR(f,r)){const j=d?Qy(a,u,i):l==null?void 0:l.promise;j==null||j.catch(Jt).finally(()=>{u.updateResult()})}return a.notifyOnChangeProps?f:u.trackResult(f)}function Y(e,t){return gR(e,GP)}function xe(e,t){const n=je(),[r]=p.useState(()=>new tR(n,e));p.useEffect(()=>{r.setOptions(e)},[r,e]);const i=p.useSyncExternalStore(p.useCallback(a=>r.subscribe(Tt.batchCalls(a)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),s=p.useCallback((a,l)=>{r.mutate(a,l).catch(Jt)},[r]);if(i.error&&Jm(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:s,mutateAsync:i.mutate}}var xR=Object.create,zk=Object.defineProperty,mR=Object.getOwnPropertyDescriptor,Bk=Object.getOwnPropertyNames,vR=Object.getPrototypeOf,yR=Object.prototype.hasOwnProperty,Lr=(e,t)=>function(){return t||(0,e[Bk(e)[0]])((t={exports:{}}).exports,t),t.exports},bR=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(var i=Bk(t),s=0,a=i.length,l;s<a;s++)l=i[s],!yR.call(e,l)&&l!==n&&zk(e,l,{get:(c=>t[c]).bind(null,l),enumerable:!(r=mR(t,l))||r.enumerable});return e},bt=(e,t,n)=>(n=e!=null?xR(vR(e)):{},bR(t||!e||!e.__esModule?zk(n,"default",{value:e,enumerable:!0}):n,e)),Wk=Lr({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/typeof.js"(e,t){function n(r){"@babel/helpers - typeof";return t.exports=n=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(i){return typeof i}:function(i){return i&&typeof Symbol=="function"&&i.constructor===Symbol&&i!==Symbol.prototype?"symbol":typeof i},t.exports.__esModule=!0,t.exports.default=t.exports,n(r)}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports}}),jR=Lr({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js"(e,t){var n=Wk().default;function r(i,s){if(n(i)!="object"||!i)return i;var a=i[Symbol.toPrimitive];if(a!==void 0){var l=a.call(i,s||"default");if(n(l)!="object")return l;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(i)}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports}}),wR=Lr({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js"(e,t){var n=Wk().default,r=jR();function i(s){var a=r(s,"string");return n(a)=="symbol"?a:a+""}t.exports=i,t.exports.__esModule=!0,t.exports.default=t.exports}}),ys=Lr({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/defineProperty.js"(e,t){var n=wR();function r(i,s,a){return(s=n(s))in i?Object.defineProperty(i,s,{value:a,enumerable:!0,configurable:!0,writable:!0}):i[s]=a,i}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports}}),ar=Lr({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectSpread2.js"(e,t){var n=ys();function r(s,a){var l=Object.keys(s);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(s);a&&(c=c.filter(function(d){return Object.getOwnPropertyDescriptor(s,d).enumerable})),l.push.apply(l,c)}return l}function i(s){for(var a=1;a<arguments.length;a++){var l=arguments[a]!=null?arguments[a]:{};a%2?r(Object(l),!0).forEach(function(c){n(s,c,l[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(l)):r(Object(l)).forEach(function(c){Object.defineProperty(s,c,Object.getOwnPropertyDescriptor(l,c))})}return s}t.exports=i,t.exports.__esModule=!0,t.exports.default=t.exports}});function cl(e){const t={subscribe(n){let r=null,i=!1,s=!1,a=!1;function l(){if(r===null){a=!0;return}s||(s=!0,typeof r=="function"?r():r&&r.unsubscribe())}return r=e({next(c){var d;i||(d=n.next)===null||d===void 0||d.call(n,c)},error(c){var d;i||(i=!0,(d=n.error)===null||d===void 0||d.call(n,c),l())},complete(){var c;i||(i=!0,(c=n.complete)===null||c===void 0||c.call(n),l())}}),a&&l(),{unsubscribe:l}},pipe(...n){return n.reduce(kR,t)}};return t}function kR(e,t){return t(e)}function SR(e){const t=new AbortController;return new Promise((r,i)=>{let s=!1;function a(){s||(s=!0,l.unsubscribe())}t.signal.addEventListener("abort",()=>{i(t.signal.reason)});const l=e.subscribe({next(c){s=!0,r(c),a()},error(c){i(c)},complete(){t.abort(),a()}})})}function CR(e){return t=>{let n=0,r=null;const i=[];function s(){r||(r=t.subscribe({next(l){for(const d of i){var c;(c=d.next)===null||c===void 0||c.call(d,l)}},error(l){for(const d of i){var c;(c=d.error)===null||c===void 0||c.call(d,l)}},complete(){for(const c of i){var l;(l=c.complete)===null||l===void 0||l.call(c)}}}))}function a(){if(n===0&&r){const l=r;r=null,l.unsubscribe()}}return cl(l=>(n++,i.push(l),s(),{unsubscribe(){n--,a();const c=i.findIndex(d=>d===l);c>-1&&i.splice(c,1)}}))}}function Uk(e){let t=e;const n=[],r=a=>{t!==void 0&&a.next(t),n.push(a)},i=a=>{n.splice(n.indexOf(a),1)},s=cl(a=>(r(a),()=>{i(a)}));return s.next=a=>{if(t!==a){t=a;for(const l of n)l.next(a)}},s.get=()=>t,s}function Hk(e){return cl(t=>{function n(i=0,s=e.op){const a=e.links[i];if(!a)throw new Error("No more links to execute - did you forget to add an ending link?");return a({op:s,next(c){return n(i+1,c)}})}return n().subscribe(t)})}function Yy(e){return Array.isArray(e)?e:[e]}function ER(e){return t=>{const n=Yy(e.true).map(i=>i(t)),r=Yy(e.false).map(i=>i(t));return i=>cl(s=>{const a=e.condition(i.op)?n:r;return Hk({op:i.op,links:a}).subscribe(s)})}}function ui(e){return!!e&&!Array.isArray(e)&&typeof e=="object"}function TR(e){return typeof e=="function"}function Vk(){return Object.create(null)}const PR=typeof Symbol=="function"&&!!Symbol.asyncIterator;function RR(e){return PR&&ui(e)&&Symbol.asyncIterator in e}const e0=e=>e(),Wd={INTERNAL_SERVER_ERROR:-32603,BAD_GATEWAY:-32603,SERVICE_UNAVAILABLE:-32603,GATEWAY_TIMEOUT:-32603},IR=[Wd.BAD_GATEWAY,Wd.SERVICE_UNAVAILABLE,Wd.GATEWAY_TIMEOUT,Wd.INTERNAL_SERVER_ERROR];var MR=Object.create,qk=Object.defineProperty,LR=Object.getOwnPropertyDescriptor,Kk=Object.getOwnPropertyNames,OR=Object.getPrototypeOf,AR=Object.prototype.hasOwnProperty,lr=(e,t)=>function(){return t||(0,e[Kk(e)[0]])((t={exports:{}}).exports,t),t.exports},DR=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(var i=Kk(t),s=0,a=i.length,l;s<a;s++)l=i[s],!AR.call(e,l)&&l!==n&&qk(e,l,{get:(c=>t[c]).bind(null,l),enumerable:!(r=LR(t,l))||r.enumerable});return e},Ge=(e,t,n)=>(n=e!=null?MR(OR(e)):{},DR(qk(n,"default",{value:e,enumerable:!0}),e));const Qk=()=>{},Gy=e=>{Object.freeze&&Object.freeze(e)};function Yk(e,t,n){var r;const i=t.join(".");return(r=n[i])!==null&&r!==void 0||(n[i]=new Proxy(Qk,{get(s,a){if(!(typeof a!="string"||a==="then"))return Yk(e,[...t,a],n)},apply(s,a,l){const c=t[t.length-1];if(c==="valueOf"||c==="toString"||c==="toJSON")return`tRPC.proxy(${t.slice(0,-1).join(".")})`;let d={args:l,path:t};return c==="call"?d={args:l.length>=2?[l[1]]:[],path:t.slice(0,-1)}:c==="apply"&&(d={args:l.length>=2?l[1]:[],path:t.slice(0,-1)}),Gy(d.args),Gy(d.path),e(d)}})),n[i]}const Gk=e=>Yk(e,[],Vk()),NR=e=>new Proxy(Qk,{get(t,n){if(n!=="then")return e(n)}});var Xk=lr({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/typeof.js"(e,t){function n(r){"@babel/helpers - typeof";return t.exports=n=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(i){return typeof i}:function(i){return i&&typeof Symbol=="function"&&i.constructor===Symbol&&i!==Symbol.prototype?"symbol":typeof i},t.exports.__esModule=!0,t.exports.default=t.exports,n(r)}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports}}),_R=lr({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js"(e,t){var n=Xk().default;function r(i,s){if(n(i)!="object"||!i)return i;var a=i[Symbol.toPrimitive];if(a!==void 0){var l=a.call(i,s||"default");if(n(l)!="object")return l;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(i)}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports}}),$R=lr({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js"(e,t){var n=Xk().default,r=_R();function i(s){var a=r(s,"string");return n(a)=="symbol"?a:a+""}t.exports=i,t.exports.__esModule=!0,t.exports.default=t.exports}}),t0=lr({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/defineProperty.js"(e,t){var n=$R();function r(i,s,a){return(s=n(s))in i?Object.defineProperty(i,s,{value:a,enumerable:!0,configurable:!0,writable:!0}):i[s]=a,i}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports}}),Xc=lr({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectSpread2.js"(e,t){var n=t0();function r(s,a){var l=Object.keys(s);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(s);a&&(c=c.filter(function(d){return Object.getOwnPropertyDescriptor(s,d).enumerable})),l.push.apply(l,c)}return l}function i(s){for(var a=1;a<arguments.length;a++){var l=arguments[a]!=null?arguments[a]:{};a%2?r(Object(l),!0).forEach(function(c){n(s,c,l[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(l)):r(Object(l)).forEach(function(c){Object.defineProperty(s,c,Object.getOwnPropertyDescriptor(l,c))})}return s}t.exports=i,t.exports.__esModule=!0,t.exports.default=t.exports}});Ge(Xc());var Xy=Ge(t0()),FR=class extends Error{constructor(e){super(zR(e)),Object.assign(this,e)}};function zR(e){if("message"in e)return String(e.message)}function BR(e){if(e instanceof Error)return e;const t=typeof e;if(!(t==="undefined"||t==="function"||e===null)){if(t!=="object")return new Error(String(e));if(ui(e))return new FR(e)}}var Jy=class extends Error{constructor(e){var t,n,r;const i=BR(e.cause),s=(t=(n=e.message)!==null&&n!==void 0?n:i==null?void 0:i.message)!==null&&t!==void 0?t:e.code;super(s,{cause:i}),(0,Xy.default)(this,"cause",void 0),(0,Xy.default)(this,"code",void 0),this.code=e.code,this.name="TRPCError",(r=this.cause)!==null&&r!==void 0||(this.cause=i)}},Ud=Ge(Xc());function WR(e,t){if("error"in e){const r=t.deserialize(e.error);return{ok:!1,error:(0,Ud.default)((0,Ud.default)({},e),{},{error:r})}}return{ok:!0,result:(0,Ud.default)((0,Ud.default)({},e.result),(!e.result.type||e.result.type==="data")&&{type:"data",data:t.deserialize(e.result.data)})}}var lh=class extends Error{constructor(){super("Unable to transform response from server")}};function UR(e,t){let n;try{n=WR(e,t)}catch{throw new lh}if(!n.ok&&(!ui(n.error.error)||typeof n.error.error.code!="number"))throw new lh;if(n.ok&&!ui(n.result))throw new lh;return n}Ge(Xc());function HR(e){return typeof e=="function"}async function VR(e,t){const{_def:n}=e;let r=n.procedures[t];for(;!r;){const i=Object.keys(n.lazy).find(a=>t.startsWith(a));if(!i)return null;await n.lazy[i].load(),r=n.procedures[t]}return r}async function qR(e){const{type:t,path:n}=e,r=await VR(e.router,n);if(!r||!HR(r)||r._def.type!==t&&!e.allowMethodOverride)throw new Jy({code:"NOT_FOUND",message:`No "${t}"-procedure on path "${n}"`});/* istanbul ignore if -- @preserve */if(r._def.type!==t&&e.allowMethodOverride&&r._def.type==="subscription")throw new Jy({code:"METHOD_NOT_SUPPORTED",message:"Method override is not supported for subscriptions"});return r(e)}Ge(Xc());var Hd=Ge(t0());let Jk;const ch=new WeakMap,KR=()=>{};Jk=Symbol.toStringTag;var Zk=class _i{constructor(t){(0,Hd.default)(this,"promise",void 0),(0,Hd.default)(this,"subscribers",[]),(0,Hd.default)(this,"settlement",null),(0,Hd.default)(this,Jk,"Unpromise"),typeof t=="function"?this.promise=new Promise(t):this.promise=t;const n=this.promise.then(r=>{const{subscribers:i}=this;this.subscribers=null,this.settlement={status:"fulfilled",value:r},i==null||i.forEach(({resolve:s})=>{s(r)})});"catch"in n&&n.catch(r=>{const{subscribers:i}=this;this.subscribers=null,this.settlement={status:"rejected",reason:r},i==null||i.forEach(({reject:s})=>{s(r)})})}subscribe(){let t,n;const{settlement:r}=this;if(r===null){if(this.subscribers===null)throw new Error("Unpromise settled but still has subscribers");const i=YR();this.subscribers=GR(this.subscribers,i),t=i.promise,n=()=>{this.subscribers!==null&&(this.subscribers=JR(this.subscribers,i))}}else{const{status:i}=r;i==="fulfilled"?t=Promise.resolve(r.value):t=Promise.reject(r.reason),n=KR}return Object.assign(t,{unsubscribe:n})}then(t,n){const r=this.subscribe(),{unsubscribe:i}=r;return Object.assign(r.then(t,n),{unsubscribe:i})}catch(t){const n=this.subscribe(),{unsubscribe:r}=n;return Object.assign(n.catch(t),{unsubscribe:r})}finally(t){const n=this.subscribe(),{unsubscribe:r}=n;return Object.assign(n.finally(t),{unsubscribe:r})}static proxy(t){const n=_i.getSubscribablePromise(t);return typeof n<"u"?n:_i.createSubscribablePromise(t)}static createSubscribablePromise(t){const n=new _i(t);return ch.set(t,n),ch.set(n,n),n}static getSubscribablePromise(t){return ch.get(t)}static resolve(t){const n=typeof t=="object"&&t!==null&&"then"in t&&typeof t.then=="function"?t:Promise.resolve(t);return _i.proxy(n).subscribe()}static async any(t){const r=(Array.isArray(t)?t:[...t]).map(_i.resolve);try{return await Promise.any(r)}finally{r.forEach(({unsubscribe:i})=>{i()})}}static async race(t){const r=(Array.isArray(t)?t:[...t]).map(_i.resolve);try{return await Promise.race(r)}finally{r.forEach(({unsubscribe:i})=>{i()})}}static async raceReferences(t){const n=t.map(QR);try{return await Promise.race(n)}finally{for(const r of n)r.unsubscribe()}}};function QR(e){return Zk.proxy(e).then(()=>[e])}function YR(){let e,t;return{promise:new Promise((r,i)=>{e=r,t=i}),resolve:e,reject:t}}function GR(e,t){return[...e,t]}function XR(e,t){return[...e.slice(0,t),...e.slice(t+1)]}function JR(e,t){const n=e.indexOf(t);return n!==-1?XR(e,n):e}var Zy,e1,t1,n1;(e1=(Zy=Symbol).dispose)!==null&&e1!==void 0||(Zy.dispose=Symbol());(n1=(t1=Symbol).asyncDispose)!==null&&n1!==void 0||(t1.asyncDispose=Symbol());function ZR(e,t){const n=e,r=n[Symbol.dispose];return n[Symbol.dispose]=()=>{t(),r==null||r()},n}function e8(e,t){const n=e,r=n[Symbol.asyncDispose];return n[Symbol.asyncDispose]=async()=>{await t(),await(r==null?void 0:r())},n}const eS=Symbol();function t8(e){let t=null;return ZR({start(){if(t)throw new Error("Timer already started");return new Promise(r=>{t=setTimeout(()=>r(eS),e)})}},()=>{t&&clearTimeout(t)})}var Jc=lr({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/usingCtx.js"(e,t){function n(){var r=typeof SuppressedError=="function"?SuppressedError:function(l,c){var d=Error();return d.name="SuppressedError",d.error=l,d.suppressed=c,d},i={},s=[];function a(l,c){if(c!=null){if(Object(c)!==c)throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");if(l)var d=c[Symbol.asyncDispose||Symbol.for("Symbol.asyncDispose")];if(d===void 0&&(d=c[Symbol.dispose||Symbol.for("Symbol.dispose")],l))var u=d;if(typeof d!="function")throw new TypeError("Object is not disposable.");u&&(d=function(){try{u.call(c)}catch(h){return Promise.reject(h)}}),s.push({v:c,d,a:l})}else l&&s.push({d:c,a:l});return c}return{e:i,u:a.bind(null,!1),a:a.bind(null,!0),d:function(){var c,d=this.e,u=0;function f(){for(;c=s.pop();)try{if(!c.a&&u===1)return u=0,s.push(c),Promise.resolve().then(f);if(c.d){var g=c.d.call(c.v);if(c.a)return u|=2,Promise.resolve(g).then(f,h)}else u|=1}catch(v){return h(v)}if(u===1)return d!==i?Promise.reject(d):Promise.resolve();if(d!==i)throw d}function h(g){return d=d!==i?new r(g,d):g,f()}return f()}}}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports}}),n0=lr({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/OverloadYield.js"(e,t){function n(r,i){this.v=r,this.k=i}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports}}),Zc=lr({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/awaitAsyncGenerator.js"(e,t){var n=n0();function r(i){return new n(i,0)}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports}}),dl=lr({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/wrapAsyncGenerator.js"(e,t){var n=n0();function r(s){return function(){return new i(s.apply(this,arguments))}}function i(s){var a,l;function c(u,f){try{var h=s[u](f),g=h.value,v=g instanceof n;Promise.resolve(v?g.v:g).then(function(x){if(v){var b=u==="return"?"return":"next";if(!g.k||x.done)return c(b,x);x=s[b](x).value}d(h.done?"return":"normal",x)},function(x){c("throw",x)})}catch(x){d("throw",x)}}function d(u,f){switch(u){case"return":a.resolve({value:f,done:!0});break;case"throw":a.reject(f);break;default:a.resolve({value:f,done:!1})}(a=a.next)?c(a.key,a.arg):l=null}this._invoke=function(u,f){return new Promise(function(h,g){var v={key:u,arg:f,resolve:h,reject:g,next:null};l?l=l.next=v:(a=l=v,c(u,f))})},typeof s.return!="function"&&(this.return=void 0)}i.prototype[typeof Symbol=="function"&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},i.prototype.next=function(s){return this._invoke("next",s)},i.prototype.throw=function(s){return this._invoke("throw",s)},i.prototype.return=function(s){return this._invoke("return",s)},t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports}});Ge(Jc());Ge(Zc());Ge(dl());Ge(Jc());Ge(Zc());Ge(dl());Ge(Jc());Ge(Zc());Ge(dl());var tS=lr({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/asyncIterator.js"(e,t){function n(i){var s,a,l,c=2;for(typeof Symbol<"u"&&(a=Symbol.asyncIterator,l=Symbol.iterator);c--;){if(a&&(s=i[a])!=null)return s.call(i);if(l&&(s=i[l])!=null)return new r(s.call(i));a="@@asyncIterator",l="@@iterator"}throw new TypeError("Object is not async iterable")}function r(i){function s(a){if(Object(a)!==a)return Promise.reject(new TypeError(a+" is not an object."));var l=a.done;return Promise.resolve(a.value).then(function(c){return{value:c,done:l}})}return r=function(l){this.s=l,this.n=l.next},r.prototype={s:null,n:null,next:function(){return s(this.n.apply(this.s,arguments))},return:function(l){var c=this.s.return;return c===void 0?Promise.resolve({value:l,done:!0}):s(c.apply(this.s,arguments))},throw:function(l){var c=this.s.return;return c===void 0?Promise.reject(l):s(c.apply(this.s,arguments))}},new r(i)}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports}});Ge(Zc());Ge(dl());Ge(Jc());Ge(tS());var n8=lr({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/asyncGeneratorDelegate.js"(e,t){var n=n0();function r(i){var s={},a=!1;function l(c,d){return a=!0,d=new Promise(function(u){u(i[c](d))}),{done:!1,value:new n(d,1)}}return s[typeof Symbol<"u"&&Symbol.iterator||"@@iterator"]=function(){return this},s.next=function(c){return a?(a=!1,c):l("next",c)},typeof i.throw=="function"&&(s.throw=function(c){if(a)throw a=!1,c;return l("throw",c)}),typeof i.return=="function"&&(s.return=function(c){return a?(a=!1,c):l("return",c)}),s}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports}});Ge(tS());var r1=Ge(Zc()),r8=Ge(dl());Ge(n8());var nS=Ge(Jc());const o8="ping",i8="serialized-error",s8="connected",a8="return";async function l8(e){try{var t=(0,nS.default)();const n=t.u(t8(e.timeoutMs)),r=await Zk.race([e.promise,n.start()]);return r===eS?await e.onTimeout():r}catch(n){t.e=n}finally{t.d()}}function c8(e){const{deserialize:t=l=>l}=e;let n=Vk();const r=e.signal;let i=null;const s=()=>new ReadableStream({async start(l){const[c,d]=await Promise.all([e.url(),e.init()]),u=i=new e.EventSource(c,d);l.enqueue({type:"connecting",eventSource:i,event:null}),u.addEventListener(s8,h=>{const v=JSON.parse(h.data);n=v,l.enqueue({type:"connected",options:v,eventSource:u})}),u.addEventListener(i8,h=>{const g=h;l.enqueue({type:"serialized-error",error:t(JSON.parse(g.data)),eventSource:u})}),u.addEventListener(o8,()=>{l.enqueue({type:"ping",eventSource:u})}),u.addEventListener(a8,()=>{u.close(),l.close(),i=null}),u.addEventListener("error",h=>{u.readyState===u.CLOSED?l.error(h):l.enqueue({type:"connecting",eventSource:u,event:h})}),u.addEventListener("message",h=>{const g=h,x={data:t(JSON.parse(g.data))};g.lastEventId&&(x.id=g.lastEventId),l.enqueue({type:"data",data:x,eventSource:u})});const f=()=>{try{u.close(),l.close()}catch{}};r.aborted?f():r.addEventListener("abort",f)},cancel(){i==null||i.close()}}),a=()=>{let l=s(),c=l.getReader();async function d(){await c.cancel(),i=null}return e8({read(){return c.read()},async recreate(){await d(),l=s(),c=l.getReader()}},d)};return e0((0,r8.default)(function*(){try{var l=(0,nS.default)();const c=l.a(a());for(;;){let d=c.read();const u=n.reconnectAfterInactivityMs;u&&(d=l8({promise:d,timeoutMs:u,onTimeout:async()=>{const h={value:{type:"timeout",ms:u,eventSource:i},done:!1};return await c.recreate(),h}}));const f=yield(0,r1.default)(d);if(f.done)return f.value;yield f.value}}catch(c){l.e=c}finally{yield(0,r1.default)(l.d())}}))}Ge(dl());Ge(Xc());var Vd=bt(ys(),1),Ps=bt(ar(),1);function d8(e){return e instanceof Yo}function u8(e){return ui(e)&&ui(e.error)&&typeof e.error.code=="number"&&typeof e.error.message=="string"}function p8(e,t){return typeof e=="string"?e:ui(e)&&typeof e.message=="string"?e.message:t}var Yo=class Tu extends Error{constructor(t,n){var r,i;const s=n==null?void 0:n.cause;super(t,{cause:s}),(0,Vd.default)(this,"cause",void 0),(0,Vd.default)(this,"shape",void 0),(0,Vd.default)(this,"data",void 0),(0,Vd.default)(this,"meta",void 0),this.meta=n==null?void 0:n.meta,this.cause=s,this.shape=n==null||(r=n.result)===null||r===void 0?void 0:r.error,this.data=n==null||(i=n.result)===null||i===void 0?void 0:i.error.data,this.name="TRPCClientError",Object.setPrototypeOf(this,Tu.prototype)}static from(t,n={}){const r=t;return d8(r)?(n.meta&&(r.meta=(0,Ps.default)((0,Ps.default)({},r.meta),n.meta)),r):u8(r)?new Tu(r.error.message,(0,Ps.default)((0,Ps.default)({},n),{},{result:r,cause:n.cause})):new Tu(p8(r,"Unknown error"),(0,Ps.default)((0,Ps.default)({},n),{},{cause:r}))}};function rS(e){const t=e;return t?"input"in t?t:{input:t,output:t}:{input:{serialize:n=>n,deserialize:n=>n},output:{serialize:n=>n,deserialize:n=>n}}}const o1=e=>typeof e=="function";function f8(e){if(e)return e;if(typeof window<"u"&&o1(window.fetch))return window.fetch;if(typeof globalThis<"u"&&o1(globalThis.fetch))return globalThis.fetch;throw new Error("No fetch implementation found")}var nc=bt(ar());function h8(e){return{url:e.url.toString(),fetch:e.fetch,transformer:rS(e.transformer),methodOverride:e.methodOverride}}function g8(e){const t={};for(let n=0;n<e.length;n++){const r=e[n];t[n]=r}return t}const x8={query:"GET",mutation:"POST",subscription:"PATCH"};function oS(e){return"input"in e?e.transformer.input.serialize(e.input):g8(e.inputs.map(t=>e.transformer.input.serialize(t)))}const r0=e=>{const t=e.url.split("?");let r=t[0].replace(/\/$/,"")+"/"+e.path;const i=[];if(t[1]&&i.push(t[1]),"inputs"in e&&i.push("batch=1"),e.type==="query"||e.type==="subscription"){const s=oS(e);s!==void 0&&e.methodOverride!=="POST"&&i.push(`input=${encodeURIComponent(JSON.stringify(s))}`)}return i.length&&(r+="?"+i.join("&")),r},m8=e=>{if(e.type==="query"&&e.methodOverride!=="POST")return;const t=oS(e);return t!==void 0?JSON.stringify(t):void 0},v8=e=>w8((0,nc.default)((0,nc.default)({},e),{},{contentTypeHeader:"application/json",getUrl:r0,getBody:m8}));var y8=class extends Error{constructor(){const e="AbortError";super(e),this.name=e,this.message=e}};const b8=e=>{var t;if(e!=null&&e.aborted)throw(t=e.throwIfAborted)===null||t===void 0||t.call(e),typeof DOMException<"u"?new DOMException("AbortError","AbortError"):new y8};async function j8(e){var t,n;b8(e.signal);const r=e.getUrl(e),i=e.getBody(e),s=(t=e.methodOverride)!==null&&t!==void 0?t:x8[e.type],a=await(async()=>{const c=await e.headers();return Symbol.iterator in c?Object.fromEntries(c):c})(),l=(0,nc.default)((0,nc.default)((0,nc.default)({},e.contentTypeHeader&&s!=="GET"?{"content-type":e.contentTypeHeader}:{}),e.trpcAcceptHeader?{[(n=e.trpcAcceptHeaderKey)!==null&&n!==void 0?n:"trpc-accept"]:e.trpcAcceptHeader}:void 0),a);return f8(e.fetch)(r,{method:s,signal:e.signal,body:i,headers:l})}async function w8(e){const t={},n=await j8(e);t.response=n;const r=await n.json();return t.responseJSON=r,{json:r,meta:t}}bt(ar(),1);const i1=()=>{throw new Error("Something went wrong. Please submit an issue at https://github.com/trpc/trpc/issues/new")};function s1(e){let t=null,n=null;const r=()=>{clearTimeout(n),n=null,t=null};function i(l){const c=[[]];let d=0;for(;;){const h=l[d];if(!h)break;const g=c[c.length-1];if(h.aborted){var u;(u=h.reject)===null||u===void 0||u.call(h,new Error("Aborted")),d++;continue}if(e.validate(g.concat(h).map(x=>x.key))){g.push(h),d++;continue}if(g.length===0){var f;(f=h.reject)===null||f===void 0||f.call(h,new Error("Input is too big for a single dispatch")),d++;continue}c.push([])}return c}function s(){const l=i(t);r();for(const c of l){if(!c.length)continue;const d={items:c};for(const f of c)f.batch=d;e.fetch(d.items.map(f=>f.key)).then(async f=>{await Promise.all(f.map(async(g,v)=>{const x=d.items[v];try{var b;const y=await Promise.resolve(g);(b=x.resolve)===null||b===void 0||b.call(x,y)}catch(y){var j;(j=x.reject)===null||j===void 0||j.call(x,y)}x.batch=null,x.reject=null,x.resolve=null}));for(const g of d.items){var h;(h=g.reject)===null||h===void 0||h.call(g,new Error("Missing result")),g.batch=null}}).catch(f=>{for(const g of d.items){var h;(h=g.reject)===null||h===void 0||h.call(g,f),g.batch=null}})}}function a(l){var c;const d={aborted:!1,key:l,batch:null,resolve:i1,reject:i1},u=new Promise((f,h)=>{var g;d.reject=h,d.resolve=f,(g=t)!==null&&g!==void 0||(t=[]),t.push(d)});return(c=n)!==null&&c!==void 0||(n=setTimeout(s)),u}return{load:a}}function k8(...e){const t=new AbortController,n=e.length;let r=0;const i=()=>{++r===n&&t.abort()};for(const s of e)s!=null&&s.aborted?i():s==null||s.addEventListener("abort",i,{once:!0});return t.signal}function S8(...e){const t=new AbortController;for(const n of e)n!=null&&n.aborted?t.abort():n==null||n.addEventListener("abort",()=>t.abort(),{once:!0});return t.signal}var qd=bt(ar(),1);function C8(e){var t,n;const r=h8(e),i=(t=e.maxURLLength)!==null&&t!==void 0?t:1/0,s=(n=e.maxItems)!==null&&n!==void 0?n:1/0;return()=>{const a=u=>({validate(f){if(i===1/0&&s===1/0)return!0;if(f.length>s)return!1;const h=f.map(x=>x.path).join(","),g=f.map(x=>x.input);return r0((0,qd.default)((0,qd.default)({},r),{},{type:u,path:h,inputs:g,signal:null})).length<=i},async fetch(f){const h=f.map(y=>y.path).join(","),g=f.map(y=>y.input),v=k8(...f.map(y=>y.signal)),x=await v8((0,qd.default)((0,qd.default)({},r),{},{path:h,inputs:g,type:u,headers(){return e.headers?typeof e.headers=="function"?e.headers({opList:f}):e.headers:{}},signal:v}));return(Array.isArray(x.json)?x.json:f.map(()=>x.json)).map(y=>({meta:x.meta,json:y}))}}),l=s1(a("query")),c=s1(a("mutation")),d={query:l,mutation:c};return({op:u})=>cl(f=>{/* istanbul ignore if -- @preserve */if(u.type==="subscription")throw new Error("Subscriptions are unsupported by `httpLink` - use `httpSubscriptionLink` or `wsLink`");const g=d[u.type].load(u);let v;return g.then(x=>{v=x;const b=UR(x.json,r.transformer.output);if(!b.ok){f.error(Yo.from(b.error,{meta:x.meta}));return}f.next({context:x.meta,result:b.result}),f.complete()}).catch(x=>{f.error(Yo.from(x,{meta:v==null?void 0:v.meta}))}),()=>{}})}}bt(ar(),1);const Ic=(e,...t)=>typeof e=="function"?e(...t):e;bt(ys(),1);function E8(){let e,t;return{promise:new Promise((r,i)=>{e=r,t=i}),resolve:e,reject:t}}async function T8(e){const t=await Ic(e.url);if(!e.connectionParams)return t;const r=`${t.includes("?")?"&":"?"}connectionParams=1`;return t+r}async function P8(e,t){const n={method:"connectionParams",data:await Ic(e)};return t.encode(n)}bt(ys(),1);var Ro=bt(ys(),1);function R8(e){const{promise:t,resolve:n,reject:r}=E8();return e.addEventListener("open",()=>{e.removeEventListener("error",r),n()}),e.addEventListener("error",r),t}function I8(e,{intervalMs:t,pongTimeoutMs:n}){let r,i;function s(){r=setTimeout(()=>{e.send("PING"),i=setTimeout(()=>{e.close()},n)},t)}function a(){clearTimeout(r),s()}function l(){clearTimeout(i),a()}e.addEventListener("open",s),e.addEventListener("message",({data:c})=>{clearTimeout(r),s(),c==="PONG"&&l()}),e.addEventListener("close",()=>{clearTimeout(r),clearTimeout(i)})}var M8=class ix{constructor(t){var n;if((0,Ro.default)(this,"id",++ix.connectCount),(0,Ro.default)(this,"WebSocketPonyfill",void 0),(0,Ro.default)(this,"urlOptions",void 0),(0,Ro.default)(this,"keepAliveOpts",void 0),(0,Ro.default)(this,"encoder",void 0),(0,Ro.default)(this,"wsObservable",Uk(null)),(0,Ro.default)(this,"openPromise",null),this.WebSocketPonyfill=(n=t.WebSocketPonyfill)!==null&&n!==void 0?n:WebSocket,!this.WebSocketPonyfill)throw new Error("No WebSocket implementation found - you probably don't want to use this on the server, but if you do you need to pass a `WebSocket`-ponyfill");this.urlOptions=t.urlOptions,this.keepAliveOpts=t.keepAlive,this.encoder=t.encoder}get ws(){return this.wsObservable.get()}set ws(t){this.wsObservable.next(t)}isOpen(){return!!this.ws&&this.ws.readyState===this.WebSocketPonyfill.OPEN&&!this.openPromise}isClosed(){return!!this.ws&&(this.ws.readyState===this.WebSocketPonyfill.CLOSING||this.ws.readyState===this.WebSocketPonyfill.CLOSED)}async open(){var t=this;if(t.openPromise)return t.openPromise;t.id=++ix.connectCount;const n=T8(t.urlOptions).then(r=>new t.WebSocketPonyfill(r));t.openPromise=n.then(async r=>{t.ws=r,r.binaryType="arraybuffer",r.addEventListener("message",function({data:i}){i==="PING"&&this.send("PONG")}),t.keepAliveOpts.enabled&&I8(r,t.keepAliveOpts),r.addEventListener("close",()=>{t.ws===r&&(t.ws=null)}),await R8(r),t.urlOptions.connectionParams&&r.send(await P8(t.urlOptions.connectionParams,t.encoder))});try{await t.openPromise}finally{t.openPromise=null}}async close(){var t=this;try{await t.openPromise}finally{var n;(n=t.ws)===null||n===void 0||n.close()}}};(0,Ro.default)(M8,"connectCount",0);bt(ys(),1);bt(ar(),1);var dh=bt(ys(),1),a1=bt(ar(),1),iS=class{constructor(e){(0,dh.default)(this,"links",void 0),(0,dh.default)(this,"runtime",void 0),(0,dh.default)(this,"requestId",void 0),this.requestId=0,this.runtime={},this.links=e.links.map(t=>t(this.runtime))}$request(e){var t;return Hk({links:this.links,op:(0,a1.default)((0,a1.default)({},e),{},{context:(t=e.context)!==null&&t!==void 0?t:{},id:++this.requestId})}).pipe(CR())}async requestAsPromise(e){var t=this;try{const n=t.$request(e);return(await SR(n)).result.data}catch(n){throw Yo.from(n)}}query(e,t,n){return this.requestAsPromise({type:"query",path:e,input:t,context:n==null?void 0:n.context,signal:n==null?void 0:n.signal})}mutation(e,t,n){return this.requestAsPromise({type:"mutation",path:e,input:t,context:n==null?void 0:n.context,signal:n==null?void 0:n.signal})}subscription(e,t,n){return this.$request({type:"subscription",path:e,input:t,context:n.context,signal:n.signal}).subscribe({next(i){switch(i.result.type){case"state":{var s;(s=n.onConnectionStateChange)===null||s===void 0||s.call(n,i.result);break}case"started":{var a;(a=n.onStarted)===null||a===void 0||a.call(n,{context:i.context});break}case"stopped":{var l;(l=n.onStopped)===null||l===void 0||l.call(n);break}case"data":case void 0:{var c;(c=n.onData)===null||c===void 0||c.call(n,i.result.data);break}}},error(i){var s;(s=n.onError)===null||s===void 0||s.call(n,i)},complete(){var i;(i=n.onComplete)===null||i===void 0||i.call(n)}})}};const sS=Symbol.for("trpc_untypedClient"),L8={query:"query",mutate:"mutation",subscribe:"subscription"},O8=e=>L8[e];function A8(e){const t=Gk(({path:n,args:r})=>{const i=[...n],s=O8(i.pop()),a=i.join(".");return e[s](a,...r)});return NR(n=>n===sS?e:t[n])}function D8(e){const t=new iS(e);return A8(t)}function N8(e){return e[sS]}bt(ar(),1);var l1=bt(ar(),1);function _8(e,t){return!t||e!=null&&typeof e!="object"?e:(0,l1.default)((0,l1.default)({},e??{}),{},{lastEventId:t})}var $8=Lr({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/asyncIterator.js"(e,t){function n(i){var s,a,l,c=2;for(typeof Symbol<"u"&&(a=Symbol.asyncIterator,l=Symbol.iterator);c--;){if(a&&(s=i[a])!=null)return s.call(i);if(l&&(s=i[l])!=null)return new r(s.call(i));a="@@asyncIterator",l="@@iterator"}throw new TypeError("Object is not async iterable")}function r(i){function s(a){if(Object(a)!==a)return Promise.reject(new TypeError(a+" is not an object."));var l=a.done;return Promise.resolve(a.value).then(function(c){return{value:c,done:l}})}return r=function(l){this.s=l,this.n=l.next},r.prototype={s:null,n:null,next:function(){return s(this.n.apply(this.s,arguments))},return:function(l){var c=this.s.return;return c===void 0?Promise.resolve({value:l,done:!0}):s(c.apply(this.s,arguments))},throw:function(l){var c=this.s.return;return c===void 0?Promise.reject(l):s(c.apply(this.s,arguments))}},new r(i)}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports}}),F8=bt($8(),1);async function z8(e){let t=await Ic(e.url);if(e.connectionParams){const n=await Ic(e.connectionParams),r=t.includes("?")?"&":"?";t+=r+"connectionParams="+encodeURIComponent(JSON.stringify(n))}return t}function c1(e){const t=rS(e.transformer);return()=>({op:n})=>cl(r=>{var i;const{type:s,path:a,input:l}=n;/* istanbul ignore if -- @preserve */if(s!=="subscription")throw new Error("httpSubscriptionLink only supports subscriptions");let c;const d=new AbortController,u=S8(n.signal,d.signal),f=c8({url:async()=>r0({transformer:t,url:await z8(e),input:_8(l,c),path:a,type:s,signal:null}),init:()=>Ic(e.eventSourceOptions,{op:n}),signal:u,deserialize:v=>t.output.deserialize(v),EventSource:(i=e.EventSource)!==null&&i!==void 0?i:globalThis.EventSource}),h=Uk({type:"state",state:"connecting",error:null}),g=h.subscribe({next(v){r.next({result:v})}});return e0(async()=>{var v=!1,x=!1,b;try{for(var j=(0,F8.default)(f),y;v=!(y=await j.next()).done;v=!1){const w=y.value;switch(w.type){case"ping":break;case"data":const k=w.data;let S;k.id?(c=k.id,S={id:k.id,data:k}):S={data:k.data},r.next({result:S,context:{eventSource:w.eventSource}});break;case"connected":{r.next({result:{type:"started"},context:{eventSource:w.eventSource}}),h.next({type:"state",state:"pending",error:null});break}case"serialized-error":{const T=Yo.from({error:w.error});if(IR.includes(w.error.code)){h.next({type:"state",state:"connecting",error:T});break}throw T}case"connecting":{const T=h.get(),C=w.event&&Yo.from(w.event);if(!C&&T.state==="connecting")break;h.next({type:"state",state:"connecting",error:C});break}case"timeout":h.next({type:"state",state:"connecting",error:new Yo(`Timeout of ${w.ms}ms reached while waiting for a response`)})}}}catch(w){x=!0,b=w}finally{try{v&&j.return!=null&&await j.return()}finally{if(x)throw b}}r.next({result:{type:"stopped"}}),h.next({type:"state",state:"idle",error:null}),r.complete()}).catch(v=>{r.error(Yo.from(v))}),()=>{r.complete(),d.abort(),g.unsubscribe()}})}bt(ar(),1);var B8=Lr({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/usingCtx.js"(e,t){function n(){var r=typeof SuppressedError=="function"?SuppressedError:function(l,c){var d=Error();return d.name="SuppressedError",d.error=l,d.suppressed=c,d},i={},s=[];function a(l,c){if(c!=null){if(Object(c)!==c)throw new TypeError("using declarations can only be used with objects, functions, null, or undefined.");if(l)var d=c[Symbol.asyncDispose||Symbol.for("Symbol.asyncDispose")];if(d===void 0&&(d=c[Symbol.dispose||Symbol.for("Symbol.dispose")],l))var u=d;if(typeof d!="function")throw new TypeError("Object is not disposable.");u&&(d=function(){try{u.call(c)}catch(h){return Promise.reject(h)}}),s.push({v:c,d,a:l})}else l&&s.push({d:c,a:l});return c}return{e:i,u:a.bind(null,!1),a:a.bind(null,!0),d:function(){var c,d=this.e,u=0;function f(){for(;c=s.pop();)try{if(!c.a&&u===1)return u=0,s.push(c),Promise.resolve().then(f);if(c.d){var g=c.d.call(c.v);if(c.a)return u|=2,Promise.resolve(g).then(f,h)}else u|=1}catch(v){return h(v)}if(u===1)return d!==i?Promise.reject(d):Promise.resolve();if(d!==i)throw d}function h(g){return d=d!==i?new r(g,d):g,f()}return f()}}}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports}}),aS=Lr({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/OverloadYield.js"(e,t){function n(r,i){this.v=r,this.k=i}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports}}),W8=Lr({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/awaitAsyncGenerator.js"(e,t){var n=aS();function r(i){return new n(i,0)}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports}}),U8=Lr({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/wrapAsyncGenerator.js"(e,t){var n=aS();function r(s){return function(){return new i(s.apply(this,arguments))}}function i(s){var a,l;function c(u,f){try{var h=s[u](f),g=h.value,v=g instanceof n;Promise.resolve(v?g.v:g).then(function(x){if(v){var b=u==="return"?"return":"next";if(!g.k||x.done)return c(b,x);x=s[b](x).value}d(h.done?"return":"normal",x)},function(x){c("throw",x)})}catch(x){d("throw",x)}}function d(u,f){switch(u){case"return":a.resolve({value:f,done:!0});break;case"throw":a.reject(f);break;default:a.resolve({value:f,done:!1})}(a=a.next)?c(a.key,a.arg):l=null}this._invoke=function(u,f){return new Promise(function(h,g){var v={key:u,arg:f,resolve:h,reject:g,next:null};l?l=l.next=v:(a=l=v,c(u,f))})},typeof s.return!="function"&&(this.return=void 0)}i.prototype[typeof Symbol=="function"&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},i.prototype.next=function(s){return this._invoke("next",s)},i.prototype.throw=function(s){return this._invoke("throw",s)},i.prototype.return=function(s){return this._invoke("return",s)},t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports}});bt(B8(),1);bt(W8(),1);bt(U8(),1);bt(ar(),1);var H8=Object.create,lS=Object.defineProperty,V8=Object.getOwnPropertyDescriptor,cS=Object.getOwnPropertyNames,q8=Object.getPrototypeOf,K8=Object.prototype.hasOwnProperty,yi=(e,t)=>function(){return t||(0,e[cS(e)[0]])((t={exports:{}}).exports,t),t.exports},Q8=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(var i=cS(t),s=0,a=i.length,l;s<a;s++)l=i[s],!K8.call(e,l)&&l!==n&&lS(e,l,{get:(c=>t[c]).bind(null,l),enumerable:!(r=V8(t,l))||r.enumerable});return e},bi=(e,t,n)=>(n=e!=null?H8(q8(e)):{},Q8(t||!e||!e.__esModule?lS(n,"default",{value:e,enumerable:!0}):n,e)),dS=yi({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/typeof.js"(e,t){function n(r){"@babel/helpers - typeof";return t.exports=n=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(i){return typeof i}:function(i){return i&&typeof Symbol=="function"&&i.constructor===Symbol&&i!==Symbol.prototype?"symbol":typeof i},t.exports.__esModule=!0,t.exports.default=t.exports,n(r)}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports}}),Y8=yi({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPrimitive.js"(e,t){var n=dS().default;function r(i,s){if(n(i)!="object"||!i)return i;var a=i[Symbol.toPrimitive];if(a!==void 0){var l=a.call(i,s||"default");if(n(l)!="object")return l;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(i)}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports}}),G8=yi({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/toPropertyKey.js"(e,t){var n=dS().default,r=Y8();function i(s){var a=r(s,"string");return n(a)=="symbol"?a:a+""}t.exports=i,t.exports.__esModule=!0,t.exports.default=t.exports}}),X8=yi({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/defineProperty.js"(e,t){var n=G8();function r(i,s,a){return(s=n(s))in i?Object.defineProperty(i,s,{value:a,enumerable:!0,configurable:!0,writable:!0}):i[s]=a,i}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports}}),ul=yi({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectSpread2.js"(e,t){var n=X8();function r(s,a){var l=Object.keys(s);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(s);a&&(c=c.filter(function(d){return Object.getOwnPropertyDescriptor(s,d).enumerable})),l.push.apply(l,c)}return l}function i(s){for(var a=1;a<arguments.length;a++){var l=arguments[a]!=null?arguments[a]:{};a%2?r(Object(l),!0).forEach(function(c){n(s,c,l[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(l)):r(Object(l)).forEach(function(c){Object.defineProperty(s,c,Object.getOwnPropertyDescriptor(l,c))})}return s}t.exports=i,t.exports.__esModule=!0,t.exports.default=t.exports}}),J8=yi({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/asyncIterator.js"(e,t){function n(i){var s,a,l,c=2;for(typeof Symbol<"u"&&(a=Symbol.asyncIterator,l=Symbol.iterator);c--;){if(a&&(s=i[a])!=null)return s.call(i);if(l&&(s=i[l])!=null)return new r(s.call(i));a="@@asyncIterator",l="@@iterator"}throw new TypeError("Object is not async iterable")}function r(i){function s(a){if(Object(a)!==a)return Promise.reject(new TypeError(a+" is not an object."));var l=a.done;return Promise.resolve(a.value).then(function(c){return{value:c,done:l}})}return r=function(l){this.s=l,this.n=l.next},r.prototype={s:null,n:null,next:function(){return s(this.n.apply(this.s,arguments))},return:function(l){var c=this.s.return;return c===void 0?Promise.resolve({value:l,done:!0}):s(c.apply(this.s,arguments))},throw:function(l){var c=this.s.return;return c===void 0?Promise.reject(l):s(c.apply(this.s,arguments))}},new r(i)}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports}}),Z8=yi({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectWithoutPropertiesLoose.js"(e,t){function n(r,i){if(r==null)return{};var s={};for(var a in r)if({}.hasOwnProperty.call(r,a)){if(i.includes(a))continue;s[a]=r[a]}return s}t.exports=n,t.exports.__esModule=!0,t.exports.default=t.exports}}),e9=yi({"../../node_modules/.pnpm/@oxc-project+runtime@0.72.2/node_modules/@oxc-project/runtime/src/helpers/objectWithoutProperties.js"(e,t){var n=Z8();function r(i,s){if(i==null)return{};var a,l,c=n(i,s);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(i);for(l=0;l<d.length;l++)a=d[l],s.includes(a)||{}.propertyIsEnumerable.call(i,a)&&(c[a]=i[a])}return c}t.exports=r,t.exports.__esModule=!0,t.exports.default=t.exports}}),rc=bi(ul(),1),t9=bi(J8(),1),n9=bi(e9(),1);const r9=["cursor","direction"];function Kp(e){return{path:e.path.join(".")}}function o9(e){return e.length>=3}function uS(e){return o9(e)?{type:"prefixed",prefix:e[0],path:e[1],args:e[2]}:{type:"unprefixed",prefix:void 0,path:e[0],args:e[1]}}function o0(e,t,n){var r;const i=uS(e);let s=(r=i.args)===null||r===void 0?void 0:r.input;if(n){var a,l;s=(0,rc.default)((0,rc.default)((0,rc.default)({},(a=(l=i.args)===null||l===void 0?void 0:l.input)!==null&&a!==void 0?a:{}),n.pageParam!==void 0?{cursor:n.pageParam}:{}),{},{direction:n.direction})}return[i.path.join("."),s,t==null?void 0:t.trpc]}async function i9(e,t,n){const i=t.getQueryCache().build(t,{queryKey:n});i.setState({data:[],status:"success"});const s=[];var a=!1,l=!1,c;try{for(var d=(0,t9.default)(e),u;a=!(u=await d.next()).done;a=!1){const f=u.value;s.push(f),i.setState({data:[...s]})}}catch(f){l=!0,c=f}finally{try{a&&d.return!=null&&await d.return()}finally{if(l)throw c}}return s}function zr(e){const t=e0(()=>{const{input:n,type:r}=e,i=e.path.flatMap(s=>s.split("."));if(!n&&r==="any")return i.length?[i]:[];if(r==="infinite"&&ui(n)&&("direction"in n||"cursor"in n)){const{cursor:s,direction:a}=n,l=(0,n9.default)(n,r9);return[i,{input:l,type:"infinite"}]}return[i,(0,rc.default)((0,rc.default)({},typeof n<"u"&&n!==so&&{input:n}),r&&r!=="any"&&{type:r})]});return e.prefix&&t.unshift([e.prefix]),t}function pS(e){const t=[e.path.flatMap(n=>n.split("."))];return e.prefix&&t.unshift([e.prefix]),t}function i0(e){return TR(e)?e():e}var Rs=bi(ul());function s9(e){var t;const{input:n,query:r,path:i,queryKey:s,opts:a}=e,l=n===so,c=async d=>{var u;const f=(0,Rs.default)((0,Rs.default)({},a),{},{trpc:(0,Rs.default)((0,Rs.default)({},a==null?void 0:a.trpc),!(a==null||(u=a.trpc)===null||u===void 0)&&u.abortOnUnmount?{signal:d.signal}:{signal:null})});return await r(...o0(s,f,{direction:d.direction,pageParam:d.pageParam}))};return Object.assign((0,Rs.default)((0,Rs.default)({},a??{}),{},{queryKey:s,queryFn:l?so:c,initialPageParam:(t=a==null?void 0:a.initialCursor)!==null&&t!==void 0?t:n==null?void 0:n.cursor}),{trpc:Kp({path:i})})}var d1=bi(ul());function a9(e){var t,n;const{mutate:r,path:i,prefix:s,opts:a,overrides:l}=e,c=i0(e.queryClient),d=pS({path:i,prefix:(t=a==null?void 0:a.keyPrefix)!==null&&t!==void 0?t:s}),u=c.defaultMutationOptions(c.getMutationDefaults(d)),f=(n=l==null?void 0:l.onSuccess)!==null&&n!==void 0?n:g=>g.originalFn(),h=async g=>await r(...o0([...d,{input:g}],a));return(0,d1.default)((0,d1.default)({},a),{},{mutationKey:d,mutationFn:h,onSuccess(...g){var v,x;return f({originalFn:()=>{var j,y,w;return(j=a==null||(y=a.onSuccess)===null||y===void 0?void 0:y.call(a,...g))!==null&&j!==void 0?j:u==null||(w=u.onSuccess)===null||w===void 0?void 0:w.call(u,...g)},queryClient:c,meta:(v=(x=a==null?void 0:a.meta)!==null&&x!==void 0?x:u==null?void 0:u.meta)!==null&&v!==void 0?v:{}})},trpc:Kp({path:i})})}var Is=bi(ul());function l9(e){const{input:t,query:n,path:r,queryKey:i,opts:s}=e,a=i0(e.queryClient),l=t===so,c=async d=>{var u;const f=(0,Is.default)((0,Is.default)({},s),{},{trpc:(0,Is.default)((0,Is.default)({},s==null?void 0:s.trpc),!(s==null||(u=s.trpc)===null||u===void 0)&&u.abortOnUnmount?{signal:d.signal}:{signal:null})}),h=d.queryKey,g=await n(...o0(h,f));return RR(g)?i9(g,a,h):g};return Object.assign((0,Is.default)((0,Is.default)({},s),{},{queryKey:i,queryFn:l?so:c}),{trpc:Kp({path:r})})}var u1=bi(ul(),1);const c9=e=>{var t;const{subscribe:n,path:r,queryKey:i,opts:s={}}=e,a=(t=uS(i))===null||t===void 0||(t=t.args)===null||t===void 0?void 0:t.input,l="enabled"in s?!!s.enabled:a!==so,c=d=>n(r.join("."),a??void 0,d);return(0,u1.default)((0,u1.default)({},s),{},{enabled:l,subscribe:c,queryKey:i,trpc:Kp({path:r})})};var Ms=bi(ul(),1);function d9(e){const t=e.keyPrefix,n=r=>(i,s,a)=>"router"in e?Promise.resolve(i0(e.ctx)).then(c=>qR({router:e.router,path:i,getRawInput:async()=>s,ctx:c,type:r,signal:void 0,batchIndex:0})):(e.client instanceof iS?e.client:N8(e.client))[r](i,s,a);return Gk(({args:r,path:i})=>{const s=[...i],a=s.pop(),[l,c]=r;return{"~types":void 0,pathKey:()=>zr({path:s,type:"any",prefix:t}),pathFilter:()=>(0,Ms.default)((0,Ms.default)({},l),{},{queryKey:zr({path:s,type:"any",prefix:t})}),queryOptions:()=>l9({input:l,opts:c,path:s,queryClient:e.queryClient,queryKey:zr({path:s,input:l,type:"query",prefix:t}),query:n("query")}),queryKey:()=>zr({path:s,input:l,type:"query",prefix:t}),queryFilter:()=>(0,Ms.default)((0,Ms.default)({},c),{},{queryKey:zr({path:s,input:l,type:"query",prefix:t})}),infiniteQueryOptions:()=>s9({input:l,opts:c,path:s,queryKey:zr({path:s,input:l,type:"infinite",prefix:t}),query:n("query")}),infiniteQueryKey:()=>zr({path:s,input:l,type:"infinite",prefix:t}),infiniteQueryFilter:()=>(0,Ms.default)((0,Ms.default)({},c),{},{queryKey:zr({path:s,input:l,type:"infinite",prefix:t})}),mutationOptions:()=>{var u;return a9({opts:l,path:s,prefix:t,queryClient:e.queryClient,mutate:n("mutation"),overrides:(u=e.overrides)===null||u===void 0?void 0:u.mutations})},mutationKey:()=>pS({path:s,prefix:t}),subscriptionOptions:()=>c9({opts:c,path:s,queryKey:zr({path:s,input:l,type:"any",prefix:t}),subscribe:n("subscription")})}[a]()})}function u9(){const e=p.createContext(null),t=p.createContext(null),n=s=>{const a=p.useMemo(()=>d9({client:s.trpcClient,queryClient:s.queryClient,keyPrefix:s.keyPrefix}),[s.trpcClient,s.queryClient,s.keyPrefix]);return o.jsx(e.Provider,{value:s.trpcClient,children:o.jsx(t.Provider,{value:a,children:s.children})})};n.displayName="TRPCProvider";function r(){const s=p.useContext(t);if(!s)throw new Error("useTRPC() can only be used inside of a <TRPCProvider>");return s}function i(){const s=p.useContext(e);if(!s)throw new Error("useTRPCClient() can only be used inside of a <TRPCProvider>");return s}return{TRPCProvider:n,useTRPC:r,useTRPCClient:i}}class uh extends Error{constructor(t,n){super(t),this.name="ParseError",this.type=n.type,this.field=n.field,this.value=n.value,this.line=n.line}}const p1=10,p9=13,Li=32;function ph(e){}function f9(e){if(typeof e=="function")throw new TypeError("`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?");const{onEvent:t=ph,onError:n=ph,onRetry:r=ph,onComment:i,maxBufferSize:s}=e,a=[];let l=0,c=!0,d,u="",f=0,h,g=!1;function v(S){if(g)throw new Error("Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing.");if(c&&(c=!1,S.charCodeAt(0)===239&&S.charCodeAt(1)===187&&S.charCodeAt(2)===191&&(S=S.slice(3))),a.length===0){const P=b(S);P!==""&&(a.push(P),l=P.length),x();return}if(S.indexOf(`
|
|
41
|
+
`)===-1&&S.indexOf("\r")===-1){a.push(S),l+=S.length,x();return}a.push(S);const T=a.join("");a.length=0,l=0;const C=b(T);C!==""&&(a.push(C),l=C.length),x()}function x(){s!==void 0&&(l+u.length<=s||(g=!0,a.length=0,l=0,d=void 0,u="",f=0,h=void 0,n(new uh(`Buffered data exceeded max buffer size of ${s} characters`,{type:"max-buffer-size-exceeded"}))))}function b(S){let T=0;if(S.indexOf("\r")===-1){let C=S.indexOf(`
|
|
42
|
+
`,T);for(;C!==-1;){if(T===C){f>0&&t({id:d,event:h,data:u}),d=void 0,u="",f=0,h=void 0,T=C+1,C=S.indexOf(`
|
|
43
|
+
`,T);continue}const P=S.charCodeAt(T);if(f1(S,T,P)){const I=S.charCodeAt(T+5)===Li?T+6:T+5,L=S.slice(I,C);if(f===0&&S.charCodeAt(C+1)===p1){t({id:d,event:h,data:L}),d=void 0,u="",h=void 0,T=C+2,C=S.indexOf(`
|
|
44
|
+
`,T);continue}u=f===0?L:`${u}
|
|
45
|
+
${L}`,f++}else h1(S,T,P)?h=S.slice(S.charCodeAt(T+6)===Li?T+7:T+6,C)||void 0:j(S,T,C);T=C+1,C=S.indexOf(`
|
|
46
|
+
`,T)}return S.slice(T)}for(;T<S.length;){const C=S.indexOf("\r",T),P=S.indexOf(`
|
|
47
|
+
`,T);let I=-1;if(C!==-1&&P!==-1?I=C<P?C:P:C!==-1?C===S.length-1?I=-1:I=C:P!==-1&&(I=P),I===-1)break;j(S,T,I),T=I+1,S.charCodeAt(T-1)===p9&&S.charCodeAt(T)===p1&&T++}return S.slice(T)}function j(S,T,C){if(T===C){w();return}const P=S.charCodeAt(T);if(f1(S,T,P)){const D=S.charCodeAt(T+5)===Li?T+6:T+5,U=S.slice(D,C);u=f===0?U:`${u}
|
|
48
|
+
${U}`,f++;return}if(h1(S,T,P)){h=S.slice(S.charCodeAt(T+6)===Li?T+7:T+6,C)||void 0;return}if(P===105&&S.charCodeAt(T+1)===100&&S.charCodeAt(T+2)===58){const D=S.slice(S.charCodeAt(T+3)===Li?T+4:T+3,C);d=D.includes("\0")?void 0:D;return}if(P===58){if(i){const D=S.slice(T,C);i(D.slice(S.charCodeAt(T+1)===Li?2:1))}return}const I=S.slice(T,C),L=I.indexOf(":");if(L===-1){y(I,"",I);return}const z=I.slice(0,L),q=I.charCodeAt(L+1)===Li?2:1,X=I.slice(L+q);y(z,X,I)}function y(S,T,C){switch(S){case"event":h=T||void 0;break;case"data":u=f===0?T:`${u}
|
|
49
|
+
${T}`,f++;break;case"id":d=T.includes("\0")?void 0:T;break;case"retry":/^\d+$/.test(T)?r(parseInt(T,10)):n(new uh(`Invalid \`retry\` value: "${T}"`,{type:"invalid-retry",value:T,line:C}));break;default:n(new uh(`Unknown field "${S.length>20?`${S.slice(0,20)}…`:S}"`,{type:"unknown-field",field:S,value:T,line:C}));break}}function w(){f>0&&t({id:d,event:h,data:u}),d=void 0,u="",f=0,h=void 0}function k(S={}){if(S.consume&&a.length>0){const T=a.join("");j(T,0,T.length)}c=!0,d=void 0,u="",f=0,h=void 0,a.length=0,l=0,g=!1}return{feed:v,reset:k}}function f1(e,t,n){return n===100&&e.charCodeAt(t+1)===97&&e.charCodeAt(t+2)===116&&e.charCodeAt(t+3)===97&&e.charCodeAt(t+4)===58}function h1(e,t,n){return n===101&&e.charCodeAt(t+1)===118&&e.charCodeAt(t+2)===101&&e.charCodeAt(t+3)===110&&e.charCodeAt(t+4)===116&&e.charCodeAt(t+5)===58}class g1 extends Event{constructor(t,n){var r,i;super(t),this.code=(r=n==null?void 0:n.code)!=null?r:void 0,this.message=(i=n==null?void 0:n.message)!=null?i:void 0}[Symbol.for("nodejs.util.inspect.custom")](t,n,r){return r(x1(this),n)}[Symbol.for("Deno.customInspect")](t,n){return t(x1(this),n)}}function h9(e){const t=globalThis.DOMException;return typeof t=="function"?new t(e,"SyntaxError"):new SyntaxError(e)}function sx(e){return e instanceof Error?"errors"in e&&Array.isArray(e.errors)?e.errors.map(sx).join(", "):"cause"in e&&e.cause instanceof Error?`${e}: ${sx(e.cause)}`:e.message:`${e}`}function x1(e){return{type:e.type,message:e.message,code:e.code,defaultPrevented:e.defaultPrevented,cancelable:e.cancelable,timeStamp:e.timeStamp}}var fS=e=>{throw TypeError(e)},s0=(e,t,n)=>t.has(e)||fS("Cannot "+n),Te=(e,t,n)=>(s0(e,t,"read from private field"),n?n.call(e):t.get(e)),Ct=(e,t,n)=>t.has(e)?fS("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),tt=(e,t,n,r)=>(s0(e,t,"write to private field"),t.set(e,n),n),Ur=(e,t,n)=>(s0(e,t,"access private method"),n),ln,Fi,Vs,Pu,dp,oc,da,ic,_o,qs,va,Ks,Bl,Kn,ax,lx,cx,m1,dx,ux,Wl,px,fx;class Ru extends EventTarget{constructor(t,n){var r,i;super(),Ct(this,Kn),this.CONNECTING=0,this.OPEN=1,this.CLOSED=2,Ct(this,ln),Ct(this,Fi),Ct(this,Vs),Ct(this,Pu),Ct(this,dp),Ct(this,oc),Ct(this,da),Ct(this,ic,null),Ct(this,_o),Ct(this,qs),Ct(this,va,null),Ct(this,Ks,null),Ct(this,Bl,null),Ct(this,lx,async s=>{var a;Te(this,qs).reset();const{body:l,redirected:c,status:d,headers:u}=s;if(d===204){Ur(this,Kn,Wl).call(this,"Server sent HTTP 204, not reconnecting",204),this.close();return}if(c?tt(this,Vs,new URL(s.url)):tt(this,Vs,void 0),d!==200){Ur(this,Kn,Wl).call(this,`Non-200 status code (${d})`,d);return}if(!(u.get("content-type")||"").startsWith("text/event-stream")){Ur(this,Kn,Wl).call(this,'Invalid content type, expected "text/event-stream"',d);return}if(Te(this,ln)===this.CLOSED)return;tt(this,ln,this.OPEN);const f=new Event("open");if((a=Te(this,Bl))==null||a.call(this,f),this.dispatchEvent(f),typeof l!="object"||!l||!("getReader"in l)){Ur(this,Kn,Wl).call(this,"Invalid response body, expected a web ReadableStream",d),this.close();return}const h=new TextDecoder,g=l.getReader();let v=!0;do{const{done:x,value:b}=await g.read();b&&Te(this,qs).feed(h.decode(b,{stream:!x})),x&&(v=!1,Te(this,qs).reset(),Ur(this,Kn,px).call(this))}while(v)}),Ct(this,cx,s=>{tt(this,_o,void 0),!(s.name==="AbortError"||s.type==="aborted")&&Ur(this,Kn,px).call(this,sx(s))}),Ct(this,dx,s=>{typeof s.id=="string"&&tt(this,ic,s.id);const a=new MessageEvent(s.event||"message",{data:s.data,origin:Te(this,Vs)?Te(this,Vs).origin:Te(this,Fi).origin,lastEventId:s.id||""});Te(this,Ks)&&(!s.event||s.event==="message")&&Te(this,Ks).call(this,a),this.dispatchEvent(a)}),Ct(this,ux,s=>{tt(this,oc,s)}),Ct(this,fx,()=>{tt(this,da,void 0),Te(this,ln)===this.CONNECTING&&Ur(this,Kn,ax).call(this)});try{if(t instanceof URL)tt(this,Fi,t);else if(typeof t=="string")tt(this,Fi,new URL(t,g9()));else throw new Error("Invalid URL")}catch{throw h9("An invalid or illegal string was specified")}tt(this,qs,f9({onEvent:Te(this,dx),onRetry:Te(this,ux)})),tt(this,ln,this.CONNECTING),tt(this,oc,3e3),tt(this,dp,(r=n==null?void 0:n.fetch)!=null?r:globalThis.fetch),tt(this,Pu,(i=n==null?void 0:n.withCredentials)!=null?i:!1),Ur(this,Kn,ax).call(this)}get readyState(){return Te(this,ln)}get url(){return Te(this,Fi).href}get withCredentials(){return Te(this,Pu)}get onerror(){return Te(this,va)}set onerror(t){tt(this,va,t)}get onmessage(){return Te(this,Ks)}set onmessage(t){tt(this,Ks,t)}get onopen(){return Te(this,Bl)}set onopen(t){tt(this,Bl,t)}addEventListener(t,n,r){const i=n;super.addEventListener(t,i,r)}removeEventListener(t,n,r){const i=n;super.removeEventListener(t,i,r)}close(){Te(this,da)&&clearTimeout(Te(this,da)),Te(this,ln)!==this.CLOSED&&(Te(this,_o)&&Te(this,_o).abort(),tt(this,ln,this.CLOSED),tt(this,_o,void 0))}}ln=new WeakMap,Fi=new WeakMap,Vs=new WeakMap,Pu=new WeakMap,dp=new WeakMap,oc=new WeakMap,da=new WeakMap,ic=new WeakMap,_o=new WeakMap,qs=new WeakMap,va=new WeakMap,Ks=new WeakMap,Bl=new WeakMap,Kn=new WeakSet,ax=function(){tt(this,ln,this.CONNECTING),tt(this,_o,new AbortController),Te(this,dp)(Te(this,Fi),Ur(this,Kn,m1).call(this)).then(Te(this,lx)).catch(Te(this,cx))},lx=new WeakMap,cx=new WeakMap,m1=function(){var e;const t={mode:"cors",redirect:"follow",headers:{Accept:"text/event-stream",...Te(this,ic)?{"Last-Event-ID":Te(this,ic)}:void 0},cache:"no-store",signal:(e=Te(this,_o))==null?void 0:e.signal};return"window"in globalThis&&(t.credentials=this.withCredentials?"include":"same-origin"),t},dx=new WeakMap,ux=new WeakMap,Wl=function(e,t){var n;Te(this,ln)!==this.CLOSED&&tt(this,ln,this.CLOSED);const r=new g1("error",{code:t,message:e});(n=Te(this,va))==null||n.call(this,r),this.dispatchEvent(r)},px=function(e,t){var n;if(Te(this,ln)===this.CLOSED)return;tt(this,ln,this.CONNECTING);const r=new g1("error",{code:t,message:e});(n=Te(this,va))==null||n.call(this,r),this.dispatchEvent(r),tt(this,da,setTimeout(Te(this,fx),Te(this,oc)))},fx=new WeakMap,Ru.CONNECTING=0,Ru.OPEN=1,Ru.CLOSED=2;function g9(){const e="document"in globalThis?globalThis.document:void 0;return e&&typeof e=="object"&&"baseURI"in e&&typeof e.baseURI=="string"?e.baseURI:void 0}const{TRPCProvider:x9,useTRPC:le,useTRPCClient:Qp}=u9();function m9(e){return e?`${e.serverUrl}/trpc`:"/trpc"}function v9(e){return e?{"x-cortex-token":e.token}:{}}function y9(e){return(t,n)=>fetch(t,{signal:n.signal,headers:{...n.headers,"x-cortex-token":e},mode:n.mode,credentials:n.credentials,cache:n.cache,redirect:n.redirect})}function b9(e){const t=m9(e),n=v9(e);return D8({links:[ER({condition:r=>r.type==="subscription",true:c1(e?{url:t,EventSource:Ru,eventSourceOptions:()=>({fetch:y9(e.token)})}:{url:t}),false:C8({url:t,headers:()=>n})})]})}function up(){const e=globalThis.__CORTEX_DESKTOP_CONFIG;if(e!=null&&e.serverUrl&&(e!=null&&e.token))return{serverUrl:e.serverUrl,token:e.token}}function a0(){var e;return((e=up())==null?void 0:e.serverUrl)??""}function us(){const e=up();return e?{"x-cortex-token":e.token}:{}}function j9(){return globalThis.__CORTEX_DESKTOP__===!0}function Yp(){return globalThis.__CORTEX_MOBILE__===!0}function Kt(){return j9()||Yp()}const w9=["running","waiting","done","failed","cancelled"],k9={running:"running",open:"running",waiting:"waiting",completed:"done",done:"done",failed:"failed",aborted:"failed",cancelled:"cancelled",stale:"cancelled"};function S9(e){return k9[e.toLowerCase()]??"cancelled"}const C9={running:"bg-pill-running-bg text-pill-running-fg",waiting:"bg-pill-waiting-bg text-pill-waiting-fg",done:"bg-pill-done-bg text-pill-done-fg",failed:"bg-pill-failed-bg text-pill-failed-fg",cancelled:"bg-pill-cancelled-bg text-pill-cancelled-fg"},E9="inline-flex items-center rounded-card px-1g py-0.5g font-mono text-ui leading-none";function pp({tone:e,status:t,label:n,className:r}){const i=e??(t?S9(t):"cancelled"),s=n??t??i;return o.jsx("span",{className:[E9,C9[i],r].filter(Boolean).join(" "),children:s})}function cn({children:e,className:t,muted:n,as:r="span"}){return o.jsx(r,{className:["font-mono text-ui",n?"text-state-ink/60":"",t].filter(Boolean).join(" "),children:e})}function hx({value:e,copyable:t,className:n}){const[r,i]=p.useState(!1),s=p.useCallback(()=>{var l;const a=(l=navigator.clipboard)==null?void 0:l.writeText(e);a&&a.then(()=>{i(!0),setTimeout(()=>i(!1),1200)}).catch(()=>{})},[e]);return t?o.jsxs("button",{type:"button",onClick:s,title:r?"Copied":"Copy",className:["group inline-flex items-center gap-0.5g rounded-card px-0.5g font-mono text-ui","text-state-ink/60 transition-colors hover:bg-surface-canvas-alt hover:text-state-ink","focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-state-run/40",n].filter(Boolean).join(" "),children:[e,o.jsx("span",{className:"text-state-ink/40 group-hover:text-state-ink/70",children:r?"✓":"⧉"})]}):o.jsx(cn,{muted:!0,className:n,children:e})}function gx({children:e,className:t,padded:n}){return o.jsx("div",{className:["rounded-card border border-card bg-surface-card shadow-card",n?"p-2g":"",t].filter(Boolean).join(" "),children:e})}function T9({children:e,className:t}){return o.jsx("div",{className:["border-b border-card px-2g py-1.5g",t].filter(Boolean).join(" "),children:e})}function P9({children:e,className:t}){return o.jsx("div",{className:["p-2g",t].filter(Boolean).join(" "),children:e})}function Qs({title:e,count:t,description:n,actions:r,className:i}){return o.jsxs("div",{className:["flex flex-col gap-0.5g",i].filter(Boolean).join(" "),children:[o.jsxs("div",{className:"flex items-center gap-1g",children:[o.jsx("h2",{className:"text-body font-medium text-state-ink",children:e}),t!==void 0&&o.jsx(cn,{muted:!0,className:"rounded-card bg-surface-canvas-alt px-1g py-0.5g",children:t}),r&&o.jsx("div",{className:"ml-auto flex items-center gap-1g",children:r})]}),n&&o.jsx("p",{className:"text-ui text-state-ink/60",children:n})]})}const R9={primary:"bg-state-run text-surface-card hover:bg-state-run/90",secondary:"border border-card bg-surface-card text-state-ink hover:bg-surface-canvas-alt",ghost:"text-state-ink/80 hover:bg-surface-canvas-alt",danger:"bg-state-fail text-surface-card hover:bg-state-fail/90"},I9={sm:"px-1g py-0.5g text-ui",md:"px-2g py-1g text-ui"},M9="inline-flex items-center justify-center gap-1g rounded-card font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-state-run/40 disabled:cursor-not-allowed disabled:opacity-50",yt=p.forwardRef(function({variant:t="secondary",size:n="md",className:r,type:i="button",...s},a){return o.jsx("button",{ref:a,type:i,className:[M9,R9[t],I9[n],r].filter(Boolean).join(" "),...s})});function Ee(e,t,{checkForDefaultPrevented:n=!0}={}){return function(i){if(e==null||e(i),n===!1||!i.defaultPrevented)return t==null?void 0:t(i)}}function ji(e,t=[]){let n=[];function r(s,a){const l=p.createContext(a);l.displayName=s+"Context";const c=n.length;n=[...n,a];const d=f=>{var j;const{scope:h,children:g,...v}=f,x=((j=h==null?void 0:h[e])==null?void 0:j[c])||l,b=p.useMemo(()=>v,Object.values(v));return o.jsx(x.Provider,{value:b,children:g})};d.displayName=s+"Provider";function u(f,h){var x;const g=((x=h==null?void 0:h[e])==null?void 0:x[c])||l,v=p.useContext(g);if(v)return v;if(a!==void 0)return a;throw new Error(`\`${f}\` must be used within \`${s}\``)}return[d,u]}const i=()=>{const s=n.map(a=>p.createContext(a));return function(l){const c=(l==null?void 0:l[e])||s;return p.useMemo(()=>({[`__scope${e}`]:{...l,[e]:c}}),[l,c])}};return i.scopeName=e,[r,L9(i,...t)]}function L9(...e){const t=e[0];if(e.length===1)return t;const n=()=>{const r=e.map(i=>({useScope:i(),scopeName:i.scopeName}));return function(s){const a=r.reduce((l,{useScope:c,scopeName:d})=>{const f=c(s)[`__scope${d}`];return{...l,...f}},{});return p.useMemo(()=>({[`__scope${t.scopeName}`]:a}),[a])}};return n.scopeName=t.scopeName,n}function v1(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function Ha(...e){return t=>{let n=!1;const r=e.map(i=>{const s=v1(i,t);return!n&&typeof s=="function"&&(n=!0),s});if(n)return()=>{for(let i=0;i<r.length;i++){const s=r[i];typeof s=="function"?s():v1(e[i],null)}}}}function Ot(...e){return p.useCallback(Ha(...e),e)}function Mc(e){const t=p.forwardRef((n,r)=>{let{children:i,...s}=n,a=null,l=!1;const c=[];y1(i)&&typeof Kd=="function"&&(i=Kd(i._payload)),p.Children.forEach(i,h=>{var g;if(_9(h)){l=!0;const v=h;let x="child"in v.props?v.props.child:v.props.children;y1(x)&&typeof Kd=="function"&&(x=Kd(x._payload)),a=A9(v,x),c.push((g=a==null?void 0:a.props)==null?void 0:g.children)}else c.push(h)}),a?a=p.cloneElement(a,void 0,c):!l&&p.Children.count(i)===1&&p.isValidElement(i)&&(a=i);const d=a?N9(a):void 0,u=Ot(r,d);if(!a){if(i||i===0)throw new Error(l?B9(e):z9(e));return i}const f=D9(s,a.props??{});return a.type!==p.Fragment&&(f.ref=r?u:d),p.cloneElement(a,f)});return t.displayName=`${e}.Slot`,t}var hS=Symbol.for("radix.slottable");function O9(e){const t=n=>"child"in n?n.children(n.child):n.children;return t.displayName=`${e}.Slottable`,t.__radixId=hS,t}var A9=(e,t)=>{if("child"in e.props){const n=e.props.child;return p.isValidElement(n)?p.cloneElement(n,void 0,e.props.children(n.props.children)):null}return p.isValidElement(t)?t:null};function D9(e,t){const n={...t};for(const r in t){const i=e[r],s=t[r];/^on[A-Z]/.test(r)?i&&s?n[r]=(...l)=>{const c=s(...l);return i(...l),c}:i&&(n[r]=i):r==="style"?n[r]={...i,...s}:r==="className"&&(n[r]=[i,s].filter(Boolean).join(" "))}return{...e,...n}}function N9(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function _9(e){return p.isValidElement(e)&&typeof e.type=="function"&&"__radixId"in e.type&&e.type.__radixId===hS}var $9=Symbol.for("react.lazy");function y1(e){return e!=null&&typeof e=="object"&&"$$typeof"in e&&e.$$typeof===$9&&"_payload"in e&&F9(e._payload)}function F9(e){return typeof e=="object"&&e!==null&&"then"in e}var z9=e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,B9=e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,Kd=il[" use ".trim().toString()];function gS(e){const t=e+"CollectionProvider",[n,r]=ji(t),[i,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),a=x=>{const{scope:b,children:j}=x,y=p.useRef(null),w=p.useRef(new Map).current;return o.jsx(i,{scope:b,itemMap:w,collectionRef:y,children:j})};a.displayName=t;const l=e+"CollectionSlot",c=Mc(l),d=p.forwardRef((x,b)=>{const{scope:j,children:y}=x,w=s(l,j),k=Ot(b,w.collectionRef);return o.jsx(c,{ref:k,children:y})});d.displayName=l;const u=e+"CollectionItemSlot",f="data-radix-collection-item",h=Mc(u),g=p.forwardRef((x,b)=>{const{scope:j,children:y,...w}=x,k=p.useRef(null),S=Ot(b,k),T=s(u,j);return p.useEffect(()=>(T.itemMap.set(k,{ref:k,...w}),()=>void T.itemMap.delete(k))),o.jsx(h,{[f]:"",ref:S,children:y})});g.displayName=u;function v(x){const b=s(e+"CollectionConsumer",x);return p.useCallback(()=>{const y=b.collectionRef.current;if(!y)return[];const w=Array.from(y.querySelectorAll(`[${f}]`));return Array.from(b.itemMap.values()).sort((T,C)=>w.indexOf(T.ref.current)-w.indexOf(C.ref.current))},[b.collectionRef,b.itemMap])}return[{Provider:a,Slot:d,ItemSlot:g},v,r]}var rr=globalThis!=null&&globalThis.document?p.useLayoutEffect:()=>{},W9=il[" useId ".trim().toString()]||(()=>{}),U9=0;function kn(e){const[t,n]=p.useState(W9());return rr(()=>{n(r=>r??String(U9++))},[e]),e||(t?`radix-${t}`:"")}var H9=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","select","span","svg","ul"],Le=H9.reduce((e,t)=>{const n=Mc(`Primitive.${t}`),r=p.forwardRef((i,s)=>{const{asChild:a,...l}=i,c=a?n:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),o.jsx(c,{...l,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function xS(e,t){e&&vs.flushSync(()=>e.dispatchEvent(t))}function Ir(e){const t=p.useRef(e);return p.useEffect(()=>{t.current=e}),p.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}var b1=il[" useEffectEvent ".trim().toString()],j1=il[" useInsertionEffect ".trim().toString()];function V9(e){if(typeof b1=="function")return b1(e);const t=p.useRef(()=>{throw new Error("Cannot call an event handler while rendering.")});return typeof j1=="function"?j1(()=>{t.current=e}):rr(()=>{t.current=e}),p.useMemo(()=>(...n)=>{var r;return(r=t.current)==null?void 0:r.call(t,...n)},[])}var q9=il[" useInsertionEffect ".trim().toString()]||rr;function pl({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){const[i,s,a]=K9({defaultProp:t,onChange:n}),l=e!==void 0,c=l?e:i;{const u=p.useRef(e!==void 0);p.useEffect(()=>{const f=u.current;f!==l&&console.warn(`${r} is changing from ${f?"controlled":"uncontrolled"} to ${l?"controlled":"uncontrolled"}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),u.current=l},[l,r])}const d=p.useCallback(u=>{var f;if(l){const h=Q9(u)?u(e):u;h!==e&&((f=a.current)==null||f.call(a,h))}else s(u)},[l,e,s,a]);return[c,d]}function K9({defaultProp:e,onChange:t}){const[n,r]=p.useState(e),i=p.useRef(n),s=p.useRef(t);return q9(()=>{s.current=t},[t]),p.useEffect(()=>{var a;i.current!==n&&((a=s.current)==null||a.call(s,n),i.current=n)},[n,i]),[n,r,s]}function Q9(e){return typeof e=="function"}var Y9=p.createContext(void 0);function mS(e){const t=p.useContext(Y9);return e||t||"ltr"}var fh="rovingFocusGroup.onEntryFocus",G9={bubbles:!1,cancelable:!0},ed="RovingFocusGroup",[xx,vS,X9]=gS(ed),[J9,yS]=ji(ed,[X9]),[Z9,eI]=J9(ed),bS=p.forwardRef((e,t)=>o.jsx(xx.Provider,{scope:e.__scopeRovingFocusGroup,children:o.jsx(xx.Slot,{scope:e.__scopeRovingFocusGroup,children:o.jsx(tI,{...e,ref:t})})}));bS.displayName=ed;var tI=p.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:s,currentTabStopId:a,defaultCurrentTabStopId:l,onCurrentTabStopIdChange:c,onEntryFocus:d,preventScrollOnEntryFocus:u=!1,...f}=e,h=p.useRef(null),g=Ot(t,h),v=mS(s),[x,b]=pl({prop:a,defaultProp:l??null,onChange:c,caller:ed}),[j,y]=p.useState(!1),w=Ir(d),k=vS(n),S=p.useRef(!1),[T,C]=p.useState(0);return p.useEffect(()=>{const P=h.current;if(P)return P.addEventListener(fh,w),()=>P.removeEventListener(fh,w)},[w]),o.jsx(Z9,{scope:n,orientation:r,dir:v,loop:i,currentTabStopId:x,onItemFocus:p.useCallback(P=>b(P),[b]),onItemShiftTab:p.useCallback(()=>y(!0),[]),onFocusableItemAdd:p.useCallback(()=>C(P=>P+1),[]),onFocusableItemRemove:p.useCallback(()=>C(P=>P-1),[]),children:o.jsx(Le.div,{tabIndex:j||T===0?-1:0,"data-orientation":r,...f,ref:g,style:{outline:"none",...e.style},onMouseDown:Ee(e.onMouseDown,()=>{S.current=!0}),onFocus:Ee(e.onFocus,P=>{const I=!S.current;if(P.target===P.currentTarget&&I&&!j){const L=new CustomEvent(fh,G9);if(P.currentTarget.dispatchEvent(L),!L.defaultPrevented){const z=k().filter(Q=>Q.focusable),q=z.find(Q=>Q.active),X=z.find(Q=>Q.id===x),U=[q,X,...z].filter(Boolean).map(Q=>Q.ref.current);kS(U,u)}}S.current=!1}),onBlur:Ee(e.onBlur,()=>y(!1))})})}),jS="RovingFocusGroupItem",wS=p.forwardRef((e,t)=>{const{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:s,children:a,...l}=e,c=kn(),d=s||c,u=eI(jS,n),f=u.currentTabStopId===d,h=vS(n),{onFocusableItemAdd:g,onFocusableItemRemove:v,currentTabStopId:x}=u;return p.useEffect(()=>{if(r)return g(),()=>v()},[r,g,v]),o.jsx(xx.ItemSlot,{scope:n,id:d,focusable:r,active:i,children:o.jsx(Le.span,{tabIndex:f?0:-1,"data-orientation":u.orientation,...l,ref:t,onMouseDown:Ee(e.onMouseDown,b=>{r?u.onItemFocus(d):b.preventDefault()}),onFocus:Ee(e.onFocus,()=>u.onItemFocus(d)),onKeyDown:Ee(e.onKeyDown,b=>{if(b.key==="Tab"&&b.shiftKey){u.onItemShiftTab();return}if(b.target!==b.currentTarget)return;const j=oI(b,u.orientation,u.dir);if(j!==void 0){if(b.metaKey||b.ctrlKey||b.altKey||b.shiftKey)return;b.preventDefault();let w=h().filter(k=>k.focusable).map(k=>k.ref.current);if(j==="last")w.reverse();else if(j==="prev"||j==="next"){j==="prev"&&w.reverse();const k=w.indexOf(b.currentTarget);w=u.loop?iI(w,k+1):w.slice(k+1)}setTimeout(()=>kS(w))}}),children:typeof a=="function"?a({isCurrentTabStop:f,hasTabStop:x!=null}):a})})});wS.displayName=jS;var nI={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function rI(e,t){return t!=="rtl"?e:e==="ArrowLeft"?"ArrowRight":e==="ArrowRight"?"ArrowLeft":e}function oI(e,t,n){const r=rI(e.key,n);if(!(t==="vertical"&&["ArrowLeft","ArrowRight"].includes(r))&&!(t==="horizontal"&&["ArrowUp","ArrowDown"].includes(r)))return nI[r]}function kS(e,t=!1){const n=document.activeElement;for(const r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function iI(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var sI=bS,aI=wS;function lI(e,t){return p.useReducer((n,r)=>t[n][r]??n,e)}var Or=e=>{const{present:t,children:n}=e,r=cI(t),i=typeof n=="function"?n({present:r.isPresent}):p.Children.only(n),s=dI(r.ref,uI(i));return typeof n=="function"||r.isPresent?p.cloneElement(i,{ref:s}):null};Or.displayName="Presence";function cI(e){const[t,n]=p.useState(),r=p.useRef(null),i=p.useRef(e),s=p.useRef("none"),a=e?"mounted":"unmounted",[l,c]=lI(a,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return p.useEffect(()=>{const d=Qd(r.current);s.current=l==="mounted"?d:"none"},[l]),rr(()=>{const d=r.current,u=i.current;if(u!==e){const h=s.current,g=Qd(d);e?c("MOUNT"):g==="none"||(d==null?void 0:d.display)==="none"?c("UNMOUNT"):c(u&&h!==g?"ANIMATION_OUT":"UNMOUNT"),i.current=e}},[e,c]),rr(()=>{if(t){let d;const u=t.ownerDocument.defaultView??window,f=g=>{const x=Qd(r.current).includes(CSS.escape(g.animationName));if(g.target===t&&x&&(c("ANIMATION_END"),!i.current)){const b=t.style.animationFillMode;t.style.animationFillMode="forwards",d=u.setTimeout(()=>{t.style.animationFillMode==="forwards"&&(t.style.animationFillMode=b)})}},h=g=>{g.target===t&&(s.current=Qd(r.current))};return t.addEventListener("animationstart",h),t.addEventListener("animationcancel",f),t.addEventListener("animationend",f),()=>{u.clearTimeout(d),t.removeEventListener("animationstart",h),t.removeEventListener("animationcancel",f),t.removeEventListener("animationend",f)}}else c("ANIMATION_END")},[t,c]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:p.useCallback(d=>{r.current=d?getComputedStyle(d):null,n(d)},[])}}function w1(e,t){if(typeof e=="function")return e(t);e!=null&&(e.current=t)}function dI(...e){const t=p.useRef(e);return t.current=e,p.useCallback(n=>{const r=t.current;let i=!1;const s=r.map(a=>{const l=w1(a,n);return!i&&typeof l=="function"&&(i=!0),l});if(i)return()=>{for(let a=0;a<s.length;a++){const l=s[a];typeof l=="function"?l():w1(r[a],null)}}},[])}function Qd(e){return(e==null?void 0:e.animationName)||"none"}function uI(e){var r,i;let t=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,n=t&&"isReactWarning"in t&&t.isReactWarning;return n?e.ref:(t=(i=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:i.get,n=t&&"isReactWarning"in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var Gp="Tabs",[pI]=ji(Gp,[yS]),SS=yS(),[fI,l0]=pI(Gp),CS=p.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,onValueChange:i,defaultValue:s,orientation:a="horizontal",dir:l,activationMode:c="automatic",...d}=e,u=mS(l),[f,h]=pl({prop:r,onChange:i,defaultProp:s??"",caller:Gp});return o.jsx(fI,{scope:n,baseId:kn(),value:f,onValueChange:h,orientation:a,dir:u,activationMode:c,children:o.jsx(Le.div,{dir:u,"data-orientation":a,...d,ref:t})})});CS.displayName=Gp;var ES="TabsList",TS=p.forwardRef((e,t)=>{const{__scopeTabs:n,loop:r=!0,...i}=e,s=l0(ES,n),a=SS(n);return o.jsx(sI,{asChild:!0,...a,orientation:s.orientation,dir:s.dir,loop:r,children:o.jsx(Le.div,{role:"tablist","aria-orientation":s.orientation,...i,ref:t})})});TS.displayName=ES;var PS="TabsTrigger",RS=p.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,disabled:i=!1,...s}=e,a=l0(PS,n),l=SS(n),c=LS(a.baseId,r),d=OS(a.baseId,r),u=r===a.value;return o.jsx(aI,{asChild:!0,...l,focusable:!i,active:u,children:o.jsx(Le.button,{type:"button",role:"tab","aria-selected":u,"aria-controls":d,"data-state":u?"active":"inactive","data-disabled":i?"":void 0,disabled:i,id:c,...s,ref:t,onMouseDown:Ee(e.onMouseDown,f=>{!i&&f.button===0&&f.ctrlKey===!1?a.onValueChange(r):f.preventDefault()}),onKeyDown:Ee(e.onKeyDown,f=>{[" ","Enter"].includes(f.key)&&a.onValueChange(r)}),onFocus:Ee(e.onFocus,()=>{const f=a.activationMode!=="manual";!u&&!i&&f&&a.onValueChange(r)})})})});RS.displayName=PS;var IS="TabsContent",MS=p.forwardRef((e,t)=>{const{__scopeTabs:n,value:r,forceMount:i,children:s,...a}=e,l=l0(IS,n),c=LS(l.baseId,r),d=OS(l.baseId,r),u=r===l.value,f=p.useRef(u);return p.useEffect(()=>{const h=requestAnimationFrame(()=>f.current=!1);return()=>cancelAnimationFrame(h)},[]),o.jsx(Or,{present:i||u,children:({present:h})=>o.jsx(Le.div,{"data-state":u?"active":"inactive","data-orientation":l.orientation,role:"tabpanel","aria-labelledby":c,hidden:!h,id:d,tabIndex:0,...a,ref:t,style:{...e.style,animationDuration:f.current?"0s":void 0},children:h&&s})})});MS.displayName=IS;function LS(e,t){return`${e}-trigger-${t}`}function OS(e,t){return`${e}-content-${t}`}var hI=CS,gI=TS,xI=RS,mI=MS;const vI="flex items-center gap-0.5g border-b border-card",yI="rounded-t-card px-2g py-1g text-ui font-medium text-state-ink/60 transition-colors hover:text-state-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-state-run/40 data-[state=active]:bg-pill-running-bg data-[state=active]:text-pill-running-fg";function bI({items:e,defaultValue:t,className:n}){var r;return o.jsxs(hI,{defaultValue:t??((r=e[0])==null?void 0:r.value),className:n,children:[o.jsx(gI,{className:vI,children:e.map(i=>o.jsx(xI,{value:i.value,className:yI,children:i.label},i.value))}),e.map(i=>o.jsx(mI,{value:i.value,className:"pt-2g",children:i.content},i.value))]})}var jI="DismissableLayer",mx="dismissableLayer.update",wI="dismissableLayer.pointerDownOutside",kI="dismissableLayer.focusOutside",k1,c0=p.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),td=p.forwardRef((e,t)=>{const{disableOutsidePointerEvents:n=!1,deferPointerDownOutside:r=!1,onEscapeKeyDown:i,onPointerDownOutside:s,onFocusOutside:a,onInteractOutside:l,onDismiss:c,...d}=e,u=p.useContext(c0),[f,h]=p.useState(null),g=(f==null?void 0:f.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,v]=p.useState({}),x=Ot(t,h),b=Array.from(u.layers),[j]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),y=b.indexOf(j),w=f?b.indexOf(f):-1,k=u.layersWithOutsidePointerEventsDisabled.size>0,S=w>=y,T=p.useRef(!1),C=EI(z=>{const q=z.target;if(!(q instanceof Node))return;const X=[...u.branches].some(D=>D.contains(q));!S||X||(s==null||s(z),l==null||l(z),z.defaultPrevented||c==null||c())},{ownerDocument:g,deferPointerDownOutside:r,isDeferredPointerDownOutsideRef:T,dismissableSurfaces:u.dismissableSurfaces}),P=TI(z=>{if(r&&T.current)return;const q=z.target;[...u.branches].some(D=>D.contains(q))||(a==null||a(z),l==null||l(z),z.defaultPrevented||c==null||c())},g),I=f?w===b.length-1:!1,L=V9(z=>{z.key==="Escape"&&(i==null||i(z),!z.defaultPrevented&&c&&(z.preventDefault(),c()))});return p.useEffect(()=>{if(I)return g.addEventListener("keydown",L,{capture:!0}),()=>g.removeEventListener("keydown",L,{capture:!0})},[g,I]),p.useEffect(()=>{if(f)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(k1=g.body.style.pointerEvents,g.body.style.pointerEvents="none"),u.layersWithOutsidePointerEventsDisabled.add(f)),u.layers.add(f),S1(),()=>{n&&(u.layersWithOutsidePointerEventsDisabled.delete(f),u.layersWithOutsidePointerEventsDisabled.size===0&&(g.body.style.pointerEvents=k1))}},[f,g,n,u]),p.useEffect(()=>()=>{f&&(u.layers.delete(f),u.layersWithOutsidePointerEventsDisabled.delete(f),S1())},[f,u]),p.useEffect(()=>{const z=()=>v({});return document.addEventListener(mx,z),()=>document.removeEventListener(mx,z)},[]),o.jsx(Le.div,{...d,ref:x,style:{pointerEvents:k?S?"auto":"none":void 0,...e.style},onFocusCapture:Ee(e.onFocusCapture,P.onFocusCapture),onBlurCapture:Ee(e.onBlurCapture,P.onBlurCapture),onPointerDownCapture:Ee(e.onPointerDownCapture,C.onPointerDownCapture)})});td.displayName=jI;var SI="DismissableLayerBranch",AS=p.forwardRef((e,t)=>{const n=p.useContext(c0),r=p.useRef(null),i=Ot(t,r);return p.useEffect(()=>{const s=r.current;if(s)return n.branches.add(s),()=>{n.branches.delete(s)}},[n.branches]),o.jsx(Le.div,{...e,ref:i})});AS.displayName=SI;function CI(){const e=p.useContext(c0),[t,n]=p.useState(null);return p.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}function EI(e,t){const{ownerDocument:n=globalThis==null?void 0:globalThis.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:i,dismissableSurfaces:s}=t,a=Ir(e),l=p.useRef(!1),c=p.useRef(!1),d=p.useRef(new Map),u=p.useRef(()=>{});return p.useEffect(()=>{function f(){c.current=!1,i.current=!1,d.current.clear()}function h(){return Array.from(d.current.values()).some(Boolean)}function g(y){if(!c.current)return;const w=y.target;w instanceof Node&&[...s].some(S=>S.contains(w))||d.current.set(y.type,!0),y.type==="click"&&window.setTimeout(()=>{c.current&&u.current()},0)}function v(y){c.current&&d.current.set(y.type,!1)}const x=y=>{if(y.target&&!l.current){let w=function(){n.removeEventListener("click",u.current);const S=h();f(),S||DS(wI,a,k,{discrete:!0})};const k={originalEvent:y};c.current=!0,i.current=r&&y.button===0,d.current.clear(),!r||y.button!==0?w():(n.removeEventListener("click",u.current),u.current=w,n.addEventListener("click",u.current,{once:!0}))}else n.removeEventListener("click",u.current),f();l.current=!1},b=["pointerup","mousedown","mouseup","touchstart","touchend","click"];for(const y of b)n.addEventListener(y,g,!0),n.addEventListener(y,v);const j=window.setTimeout(()=>{n.addEventListener("pointerdown",x)},0);return()=>{window.clearTimeout(j),n.removeEventListener("pointerdown",x),n.removeEventListener("click",u.current);for(const y of b)n.removeEventListener(y,g,!0),n.removeEventListener(y,v)}},[n,a,r,i,s]),{onPointerDownCapture:()=>l.current=!0}}function TI(e,t=globalThis==null?void 0:globalThis.document){const n=Ir(e),r=p.useRef(!1);return p.useEffect(()=>{const i=s=>{s.target&&!r.current&&DS(kI,n,{originalEvent:s},{discrete:!1})};return t.addEventListener("focusin",i),()=>t.removeEventListener("focusin",i)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function S1(){const e=new CustomEvent(mx);document.dispatchEvent(e)}function DS(e,t,n,{discrete:r}){const i=n.originalEvent.target,s=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?xS(i,s):i.dispatchEvent(s)}var PI=td,RI=AS;const II=["top","right","bottom","left"],pi=Math.min,bn=Math.max,fp=Math.round,Yd=Math.floor,Rr=e=>({x:e,y:e}),MI={left:"right",right:"left",bottom:"top",top:"bottom"};function vx(e,t,n){return bn(e,pi(t,n))}function ao(e,t){return typeof e=="function"?e(t):e}function lo(e){return e.split("-")[0]}function fl(e){return e.split("-")[1]}function d0(e){return e==="x"?"y":"x"}function u0(e){return e==="y"?"height":"width"}function Er(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function p0(e){return d0(Er(e))}function LI(e,t,n){n===void 0&&(n=!1);const r=fl(e),i=p0(e),s=u0(i);let a=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[s]>t.floating[s]&&(a=hp(a)),[a,hp(a)]}function OI(e){const t=hp(e);return[yx(e),t,yx(t)]}function yx(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const C1=["left","right"],E1=["right","left"],AI=["top","bottom"],DI=["bottom","top"];function NI(e,t,n){switch(e){case"top":case"bottom":return n?t?E1:C1:t?C1:E1;case"left":case"right":return t?AI:DI;default:return[]}}function _I(e,t,n,r){const i=fl(e);let s=NI(lo(e),n==="start",r);return i&&(s=s.map(a=>a+"-"+i),t&&(s=s.concat(s.map(yx)))),s}function hp(e){const t=lo(e);return MI[t]+e.slice(t.length)}function $I(e){return{top:0,right:0,bottom:0,left:0,...e}}function NS(e){return typeof e!="number"?$I(e):{top:e,right:e,bottom:e,left:e}}function gp(e){const{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function T1(e,t,n){let{reference:r,floating:i}=e;const s=Er(t),a=p0(t),l=u0(a),c=lo(t),d=s==="y",u=r.x+r.width/2-i.width/2,f=r.y+r.height/2-i.height/2,h=r[l]/2-i[l]/2;let g;switch(c){case"top":g={x:u,y:r.y-i.height};break;case"bottom":g={x:u,y:r.y+r.height};break;case"right":g={x:r.x+r.width,y:f};break;case"left":g={x:r.x-i.width,y:f};break;default:g={x:r.x,y:r.y}}switch(fl(t)){case"start":g[a]-=h*(n&&d?-1:1);break;case"end":g[a]+=h*(n&&d?-1:1);break}return g}async function FI(e,t){var n;t===void 0&&(t={});const{x:r,y:i,platform:s,rects:a,elements:l,strategy:c}=e,{boundary:d="clippingAncestors",rootBoundary:u="viewport",elementContext:f="floating",altBoundary:h=!1,padding:g=0}=ao(t,e),v=NS(g),b=l[h?f==="floating"?"reference":"floating":f],j=gp(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(b)))==null||n?b:b.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(l.floating)),boundary:d,rootBoundary:u,strategy:c})),y=f==="floating"?{x:r,y:i,width:a.floating.width,height:a.floating.height}:a.reference,w=await(s.getOffsetParent==null?void 0:s.getOffsetParent(l.floating)),k=await(s.isElement==null?void 0:s.isElement(w))?await(s.getScale==null?void 0:s.getScale(w))||{x:1,y:1}:{x:1,y:1},S=gp(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:y,offsetParent:w,strategy:c}):y);return{top:(j.top-S.top+v.top)/k.y,bottom:(S.bottom-j.bottom+v.bottom)/k.y,left:(j.left-S.left+v.left)/k.x,right:(S.right-j.right+v.right)/k.x}}const zI=50,BI=async(e,t,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:s=[],platform:a}=n,l=a.detectOverflow?a:{...a,detectOverflow:FI},c=await(a.isRTL==null?void 0:a.isRTL(t));let d=await a.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:f}=T1(d,r,c),h=r,g=0;const v={};for(let x=0;x<s.length;x++){const b=s[x];if(!b)continue;const{name:j,fn:y}=b,{x:w,y:k,data:S,reset:T}=await y({x:u,y:f,initialPlacement:r,placement:h,strategy:i,middlewareData:v,rects:d,platform:l,elements:{reference:e,floating:t}});u=w??u,f=k??f,v[j]={...v[j],...S},T&&g<zI&&(g++,typeof T=="object"&&(T.placement&&(h=T.placement),T.rects&&(d=T.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:i}):T.rects),{x:u,y:f}=T1(d,h,c)),x=-1)}return{x:u,y:f,placement:h,strategy:i,middlewareData:v}},WI=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:i,rects:s,platform:a,elements:l,middlewareData:c}=t,{element:d,padding:u=0}=ao(e,t)||{};if(d==null)return{};const f=NS(u),h={x:n,y:r},g=p0(i),v=u0(g),x=await a.getDimensions(d),b=g==="y",j=b?"top":"left",y=b?"bottom":"right",w=b?"clientHeight":"clientWidth",k=s.reference[v]+s.reference[g]-h[g]-s.floating[v],S=h[g]-s.reference[g],T=await(a.getOffsetParent==null?void 0:a.getOffsetParent(d));let C=T?T[w]:0;(!C||!await(a.isElement==null?void 0:a.isElement(T)))&&(C=l.floating[w]||s.floating[v]);const P=k/2-S/2,I=C/2-x[v]/2-1,L=pi(f[j],I),z=pi(f[y],I),q=L,X=C-x[v]-z,D=C/2-x[v]/2+P,U=vx(q,D,X),Q=!c.arrow&&fl(i)!=null&&D!==U&&s.reference[v]/2-(D<q?L:z)-x[v]/2<0,J=Q?D<q?D-q:D-X:0;return{[g]:h[g]+J,data:{[g]:U,centerOffset:D-U-J,...Q&&{alignmentOffset:J}},reset:Q}}}),UI=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:i,middlewareData:s,rects:a,initialPlacement:l,platform:c,elements:d}=t,{mainAxis:u=!0,crossAxis:f=!0,fallbackPlacements:h,fallbackStrategy:g="bestFit",fallbackAxisSideDirection:v="none",flipAlignment:x=!0,...b}=ao(e,t);if((n=s.arrow)!=null&&n.alignmentOffset)return{};const j=lo(i),y=Er(l),w=lo(l)===l,k=await(c.isRTL==null?void 0:c.isRTL(d.floating)),S=h||(w||!x?[hp(l)]:OI(l)),T=v!=="none";!h&&T&&S.push(..._I(l,x,v,k));const C=[l,...S],P=await c.detectOverflow(t,b),I=[];let L=((r=s.flip)==null?void 0:r.overflows)||[];if(u&&I.push(P[j]),f){const D=LI(i,a,k);I.push(P[D[0]],P[D[1]])}if(L=[...L,{placement:i,overflows:I}],!I.every(D=>D<=0)){var z,q;const D=(((z=s.flip)==null?void 0:z.index)||0)+1,U=C[D];if(U&&(!(f==="alignment"?y!==Er(U):!1)||L.every(_=>Er(_.placement)===y?_.overflows[0]>0:!0)))return{data:{index:D,overflows:L},reset:{placement:U}};let Q=(q=L.filter(J=>J.overflows[0]<=0).sort((J,_)=>J.overflows[1]-_.overflows[1])[0])==null?void 0:q.placement;if(!Q)switch(g){case"bestFit":{var X;const J=(X=L.filter(_=>{if(T){const F=Er(_.placement);return F===y||F==="y"}return!0}).map(_=>[_.placement,_.overflows.filter(F=>F>0).reduce((F,W)=>F+W,0)]).sort((_,F)=>_[1]-F[1])[0])==null?void 0:X[0];J&&(Q=J);break}case"initialPlacement":Q=l;break}if(i!==Q)return{reset:{placement:Q}}}return{}}}};function P1(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function R1(e){return II.some(t=>e[t]>=0)}const HI=function(e){return e===void 0&&(e={}),{name:"hide",options:e,async fn(t){const{rects:n,platform:r}=t,{strategy:i="referenceHidden",...s}=ao(e,t);switch(i){case"referenceHidden":{const a=await r.detectOverflow(t,{...s,elementContext:"reference"}),l=P1(a,n.reference);return{data:{referenceHiddenOffsets:l,referenceHidden:R1(l)}}}case"escaped":{const a=await r.detectOverflow(t,{...s,altBoundary:!0}),l=P1(a,n.floating);return{data:{escapedOffsets:l,escaped:R1(l)}}}default:return{}}}}},_S=new Set(["left","top"]);async function VI(e,t){const{placement:n,platform:r,elements:i}=e,s=await(r.isRTL==null?void 0:r.isRTL(i.floating)),a=lo(n),l=fl(n),c=Er(n)==="y",d=_S.has(a)?-1:1,u=s&&c?-1:1,f=ao(t,e);let{mainAxis:h,crossAxis:g,alignmentAxis:v}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return l&&typeof v=="number"&&(g=l==="end"?v*-1:v),c?{x:g*u,y:h*d}:{x:h*d,y:g*u}}const qI=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:i,y:s,placement:a,middlewareData:l}=t,c=await VI(t,e);return a===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:i+c.x,y:s+c.y,data:{...c,placement:a}}}}},KI=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:i,platform:s}=t,{mainAxis:a=!0,crossAxis:l=!1,limiter:c={fn:j=>{let{x:y,y:w}=j;return{x:y,y:w}}},...d}=ao(e,t),u={x:n,y:r},f=await s.detectOverflow(t,d),h=Er(lo(i)),g=d0(h);let v=u[g],x=u[h];if(a){const j=g==="y"?"top":"left",y=g==="y"?"bottom":"right",w=v+f[j],k=v-f[y];v=vx(w,v,k)}if(l){const j=h==="y"?"top":"left",y=h==="y"?"bottom":"right",w=x+f[j],k=x-f[y];x=vx(w,x,k)}const b=c.fn({...t,[g]:v,[h]:x});return{...b,data:{x:b.x-n,y:b.y-r,enabled:{[g]:a,[h]:l}}}}}},QI=function(e){return e===void 0&&(e={}),{options:e,fn(t){const{x:n,y:r,placement:i,rects:s,middlewareData:a}=t,{offset:l=0,mainAxis:c=!0,crossAxis:d=!0}=ao(e,t),u={x:n,y:r},f=Er(i),h=d0(f);let g=u[h],v=u[f];const x=ao(l,t),b=typeof x=="number"?{mainAxis:x,crossAxis:0}:{mainAxis:0,crossAxis:0,...x};if(c){const w=h==="y"?"height":"width",k=s.reference[h]-s.floating[w]+b.mainAxis,S=s.reference[h]+s.reference[w]-b.mainAxis;g<k?g=k:g>S&&(g=S)}if(d){var j,y;const w=h==="y"?"width":"height",k=_S.has(lo(i)),S=s.reference[f]-s.floating[w]+(k&&((j=a.offset)==null?void 0:j[f])||0)+(k?0:b.crossAxis),T=s.reference[f]+s.reference[w]+(k?0:((y=a.offset)==null?void 0:y[f])||0)-(k?b.crossAxis:0);v<S?v=S:v>T&&(v=T)}return{[h]:g,[f]:v}}}},YI=function(e){return e===void 0&&(e={}),{name:"size",options:e,async fn(t){var n,r;const{placement:i,rects:s,platform:a,elements:l}=t,{apply:c=()=>{},...d}=ao(e,t),u=await a.detectOverflow(t,d),f=lo(i),h=fl(i),g=Er(i)==="y",{width:v,height:x}=s.floating;let b,j;f==="top"||f==="bottom"?(b=f,j=h===(await(a.isRTL==null?void 0:a.isRTL(l.floating))?"start":"end")?"left":"right"):(j=f,b=h==="end"?"top":"bottom");const y=x-u.top-u.bottom,w=v-u.left-u.right,k=pi(x-u[b],y),S=pi(v-u[j],w),T=!t.middlewareData.shift;let C=k,P=S;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(P=w),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(C=y),T&&!h){const L=bn(u.left,0),z=bn(u.right,0),q=bn(u.top,0),X=bn(u.bottom,0);g?P=v-2*(L!==0||z!==0?L+z:bn(u.left,u.right)):C=x-2*(q!==0||X!==0?q+X:bn(u.top,u.bottom))}await c({...t,availableWidth:P,availableHeight:C});const I=await a.getDimensions(l.floating);return v!==I.width||x!==I.height?{reset:{rects:!0}}:{}}}};function Xp(){return typeof window<"u"}function hl(e){return $S(e)?(e.nodeName||"").toLowerCase():"#document"}function Sn(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Ar(e){var t;return(t=($S(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function $S(e){return Xp()?e instanceof Node||e instanceof Sn(e).Node:!1}function ir(e){return Xp()?e instanceof Element||e instanceof Sn(e).Element:!1}function uo(e){return Xp()?e instanceof HTMLElement||e instanceof Sn(e).HTMLElement:!1}function I1(e){return!Xp()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof Sn(e).ShadowRoot}function nd(e){const{overflow:t,overflowX:n,overflowY:r,display:i}=sr(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!=="inline"&&i!=="contents"}function GI(e){return/^(table|td|th)$/.test(hl(e))}function Jp(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const XI=/transform|translate|scale|rotate|perspective|filter/,JI=/paint|layout|strict|content/,Oi=e=>!!e&&e!=="none";let hh;function f0(e){const t=ir(e)?sr(e):e;return Oi(t.transform)||Oi(t.translate)||Oi(t.scale)||Oi(t.rotate)||Oi(t.perspective)||!h0()&&(Oi(t.backdropFilter)||Oi(t.filter))||XI.test(t.willChange||"")||JI.test(t.contain||"")}function ZI(e){let t=fi(e);for(;uo(t)&&!Va(t);){if(f0(t))return t;if(Jp(t))return null;t=fi(t)}return null}function h0(){return hh==null&&(hh=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),hh}function Va(e){return/^(html|body|#document)$/.test(hl(e))}function sr(e){return Sn(e).getComputedStyle(e)}function Zp(e){return ir(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function fi(e){if(hl(e)==="html")return e;const t=e.assignedSlot||e.parentNode||I1(e)&&e.host||Ar(e);return I1(t)?t.host:t}function FS(e){const t=fi(e);return Va(t)?e.ownerDocument?e.ownerDocument.body:e.body:uo(t)&&nd(t)?t:FS(t)}function Lc(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const i=FS(e),s=i===((r=e.ownerDocument)==null?void 0:r.body),a=Sn(i);if(s){const l=bx(a);return t.concat(a,a.visualViewport||[],nd(i)?i:[],l&&n?Lc(l):[])}else return t.concat(i,Lc(i,[],n))}function bx(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function zS(e){const t=sr(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const i=uo(e),s=i?e.offsetWidth:n,a=i?e.offsetHeight:r,l=fp(n)!==s||fp(r)!==a;return l&&(n=s,r=a),{width:n,height:r,$:l}}function g0(e){return ir(e)?e:e.contextElement}function ya(e){const t=g0(e);if(!uo(t))return Rr(1);const n=t.getBoundingClientRect(),{width:r,height:i,$:s}=zS(t);let a=(s?fp(n.width):n.width)/r,l=(s?fp(n.height):n.height)/i;return(!a||!Number.isFinite(a))&&(a=1),(!l||!Number.isFinite(l))&&(l=1),{x:a,y:l}}const e7=Rr(0);function BS(e){const t=Sn(e);return!h0()||!t.visualViewport?e7:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function t7(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Sn(e)?!1:t}function ps(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const i=e.getBoundingClientRect(),s=g0(e);let a=Rr(1);t&&(r?ir(r)&&(a=ya(r)):a=ya(e));const l=t7(s,n,r)?BS(s):Rr(0);let c=(i.left+l.x)/a.x,d=(i.top+l.y)/a.y,u=i.width/a.x,f=i.height/a.y;if(s){const h=Sn(s),g=r&&ir(r)?Sn(r):r;let v=h,x=bx(v);for(;x&&r&&g!==v;){const b=ya(x),j=x.getBoundingClientRect(),y=sr(x),w=j.left+(x.clientLeft+parseFloat(y.paddingLeft))*b.x,k=j.top+(x.clientTop+parseFloat(y.paddingTop))*b.y;c*=b.x,d*=b.y,u*=b.x,f*=b.y,c+=w,d+=k,v=Sn(x),x=bx(v)}}return gp({width:u,height:f,x:c,y:d})}function ef(e,t){const n=Zp(e).scrollLeft;return t?t.left+n:ps(Ar(e)).left+n}function WS(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-ef(e,n),i=n.top+t.scrollTop;return{x:r,y:i}}function n7(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e;const s=i==="fixed",a=Ar(r),l=t?Jp(t.floating):!1;if(r===a||l&&s)return n;let c={scrollLeft:0,scrollTop:0},d=Rr(1);const u=Rr(0),f=uo(r);if((f||!f&&!s)&&((hl(r)!=="body"||nd(a))&&(c=Zp(r)),f)){const g=ps(r);d=ya(r),u.x=g.x+r.clientLeft,u.y=g.y+r.clientTop}const h=a&&!f&&!s?WS(a,c):Rr(0);return{width:n.width*d.x,height:n.height*d.y,x:n.x*d.x-c.scrollLeft*d.x+u.x+h.x,y:n.y*d.y-c.scrollTop*d.y+u.y+h.y}}function r7(e){return Array.from(e.getClientRects())}function o7(e){const t=Ar(e),n=Zp(e),r=e.ownerDocument.body,i=bn(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),s=bn(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let a=-n.scrollLeft+ef(e);const l=-n.scrollTop;return sr(r).direction==="rtl"&&(a+=bn(t.clientWidth,r.clientWidth)-i),{width:i,height:s,x:a,y:l}}const M1=25;function i7(e,t){const n=Sn(e),r=Ar(e),i=n.visualViewport;let s=r.clientWidth,a=r.clientHeight,l=0,c=0;if(i){s=i.width,a=i.height;const u=h0();(!u||u&&t==="fixed")&&(l=i.offsetLeft,c=i.offsetTop)}const d=ef(r);if(d<=0){const u=r.ownerDocument,f=u.body,h=getComputedStyle(f),g=u.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,v=Math.abs(r.clientWidth-f.clientWidth-g);v<=M1&&(s-=v)}else d<=M1&&(s+=d);return{width:s,height:a,x:l,y:c}}function s7(e,t){const n=ps(e,!0,t==="fixed"),r=n.top+e.clientTop,i=n.left+e.clientLeft,s=uo(e)?ya(e):Rr(1),a=e.clientWidth*s.x,l=e.clientHeight*s.y,c=i*s.x,d=r*s.y;return{width:a,height:l,x:c,y:d}}function L1(e,t,n){let r;if(t==="viewport")r=i7(e,n);else if(t==="document")r=o7(Ar(e));else if(ir(t))r=s7(t,n);else{const i=BS(e);r={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return gp(r)}function US(e,t){const n=fi(e);return n===t||!ir(n)||Va(n)?!1:sr(n).position==="fixed"||US(n,t)}function a7(e,t){const n=t.get(e);if(n)return n;let r=Lc(e,[],!1).filter(l=>ir(l)&&hl(l)!=="body"),i=null;const s=sr(e).position==="fixed";let a=s?fi(e):e;for(;ir(a)&&!Va(a);){const l=sr(a),c=f0(a);!c&&l.position==="fixed"&&(i=null),(s?!c&&!i:!c&&l.position==="static"&&!!i&&(i.position==="absolute"||i.position==="fixed")||nd(a)&&!c&&US(e,a))?r=r.filter(u=>u!==a):i=l,a=fi(a)}return t.set(e,r),r}function l7(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e;const a=[...n==="clippingAncestors"?Jp(t)?[]:a7(t,this._c):[].concat(n),r],l=L1(t,a[0],i);let c=l.top,d=l.right,u=l.bottom,f=l.left;for(let h=1;h<a.length;h++){const g=L1(t,a[h],i);c=bn(g.top,c),d=pi(g.right,d),u=pi(g.bottom,u),f=bn(g.left,f)}return{width:d-f,height:u-c,x:f,y:c}}function c7(e){const{width:t,height:n}=zS(e);return{width:t,height:n}}function d7(e,t,n){const r=uo(t),i=Ar(t),s=n==="fixed",a=ps(e,!0,s,t);let l={scrollLeft:0,scrollTop:0};const c=Rr(0);function d(){c.x=ef(i)}if(r||!r&&!s)if((hl(t)!=="body"||nd(i))&&(l=Zp(t)),r){const g=ps(t,!0,s,t);c.x=g.x+t.clientLeft,c.y=g.y+t.clientTop}else i&&d();s&&!r&&i&&d();const u=i&&!r&&!s?WS(i,l):Rr(0),f=a.left+l.scrollLeft-c.x-u.x,h=a.top+l.scrollTop-c.y-u.y;return{x:f,y:h,width:a.width,height:a.height}}function gh(e){return sr(e).position==="static"}function O1(e,t){if(!uo(e)||sr(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Ar(e)===n&&(n=n.ownerDocument.body),n}function HS(e,t){const n=Sn(e);if(Jp(e))return n;if(!uo(e)){let i=fi(e);for(;i&&!Va(i);){if(ir(i)&&!gh(i))return i;i=fi(i)}return n}let r=O1(e,t);for(;r&&GI(r)&&gh(r);)r=O1(r,t);return r&&Va(r)&&gh(r)&&!f0(r)?n:r||ZI(e)||n}const u7=async function(e){const t=this.getOffsetParent||HS,n=this.getDimensions,r=await n(e.floating);return{reference:d7(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function p7(e){return sr(e).direction==="rtl"}const f7={convertOffsetParentRelativeRectToViewportRelativeRect:n7,getDocumentElement:Ar,getClippingRect:l7,getOffsetParent:HS,getElementRects:u7,getClientRects:r7,getDimensions:c7,getScale:ya,isElement:ir,isRTL:p7};function VS(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function h7(e,t){let n=null,r;const i=Ar(e);function s(){var l;clearTimeout(r),(l=n)==null||l.disconnect(),n=null}function a(l,c){l===void 0&&(l=!1),c===void 0&&(c=1),s();const d=e.getBoundingClientRect(),{left:u,top:f,width:h,height:g}=d;if(l||t(),!h||!g)return;const v=Yd(f),x=Yd(i.clientWidth-(u+h)),b=Yd(i.clientHeight-(f+g)),j=Yd(u),w={rootMargin:-v+"px "+-x+"px "+-b+"px "+-j+"px",threshold:bn(0,pi(1,c))||1};let k=!0;function S(T){const C=T[0].intersectionRatio;if(C!==c){if(!k)return a();C?a(!1,C):r=setTimeout(()=>{a(!1,1e-7)},1e3)}C===1&&!VS(d,e.getBoundingClientRect())&&a(),k=!1}try{n=new IntersectionObserver(S,{...w,root:i.ownerDocument})}catch{n=new IntersectionObserver(S,w)}n.observe(e)}return a(!0),s}function g7(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:s=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:c=!1}=r,d=g0(e),u=i||s?[...d?Lc(d):[],...t?Lc(t):[]]:[];u.forEach(j=>{i&&j.addEventListener("scroll",n,{passive:!0}),s&&j.addEventListener("resize",n)});const f=d&&l?h7(d,n):null;let h=-1,g=null;a&&(g=new ResizeObserver(j=>{let[y]=j;y&&y.target===d&&g&&t&&(g.unobserve(t),cancelAnimationFrame(h),h=requestAnimationFrame(()=>{var w;(w=g)==null||w.observe(t)})),n()}),d&&!c&&g.observe(d),t&&g.observe(t));let v,x=c?ps(e):null;c&&b();function b(){const j=ps(e);x&&!VS(x,j)&&n(),x=j,v=requestAnimationFrame(b)}return n(),()=>{var j;u.forEach(y=>{i&&y.removeEventListener("scroll",n),s&&y.removeEventListener("resize",n)}),f==null||f(),(j=g)==null||j.disconnect(),g=null,c&&cancelAnimationFrame(v)}}const x7=qI,m7=KI,v7=UI,y7=YI,b7=HI,A1=WI,j7=QI,w7=(e,t,n)=>{const r=new Map,i={platform:f7,...n},s={...i.platform,_c:r};return BI(e,t,{...i,platform:s})};var k7=typeof document<"u",S7=function(){},Iu=k7?p.useLayoutEffect:S7;function xp(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!xp(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){const s=i[r];if(!(s==="_owner"&&e.$$typeof)&&!xp(e[s],t[s]))return!1}return!0}return e!==e&&t!==t}function qS(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function D1(e,t){const n=qS(e);return Math.round(t*n)/n}function xh(e){const t=p.useRef(e);return Iu(()=>{t.current=e}),t}function C7(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:i,elements:{reference:s,floating:a}={},transform:l=!0,whileElementsMounted:c,open:d}=e,[u,f]=p.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[h,g]=p.useState(r);xp(h,r)||g(r);const[v,x]=p.useState(null),[b,j]=p.useState(null),y=p.useCallback(_=>{_!==T.current&&(T.current=_,x(_))},[]),w=p.useCallback(_=>{_!==C.current&&(C.current=_,j(_))},[]),k=s||v,S=a||b,T=p.useRef(null),C=p.useRef(null),P=p.useRef(u),I=c!=null,L=xh(c),z=xh(i),q=xh(d),X=p.useCallback(()=>{if(!T.current||!C.current)return;const _={placement:t,strategy:n,middleware:h};z.current&&(_.platform=z.current),w7(T.current,C.current,_).then(F=>{const W={...F,isPositioned:q.current!==!1};D.current&&!xp(P.current,W)&&(P.current=W,vs.flushSync(()=>{f(W)}))})},[h,t,n,z,q]);Iu(()=>{d===!1&&P.current.isPositioned&&(P.current.isPositioned=!1,f(_=>({..._,isPositioned:!1})))},[d]);const D=p.useRef(!1);Iu(()=>(D.current=!0,()=>{D.current=!1}),[]),Iu(()=>{if(k&&(T.current=k),S&&(C.current=S),k&&S){if(L.current)return L.current(k,S,X);X()}},[k,S,X,L,I]);const U=p.useMemo(()=>({reference:T,floating:C,setReference:y,setFloating:w}),[y,w]),Q=p.useMemo(()=>({reference:k,floating:S}),[k,S]),J=p.useMemo(()=>{const _={position:n,left:0,top:0};if(!Q.floating)return _;const F=D1(Q.floating,u.x),W=D1(Q.floating,u.y);return l?{..._,transform:"translate("+F+"px, "+W+"px)",...qS(Q.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:F,top:W}},[n,l,Q.floating,u.x,u.y]);return p.useMemo(()=>({...u,update:X,refs:U,elements:Q,floatingStyles:J}),[u,X,U,Q,J])}const E7=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:i}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?A1({element:r.current,padding:i}).fn(n):{}:r?A1({element:r,padding:i}).fn(n):{}}}},T7=(e,t)=>{const n=x7(e);return{name:n.name,fn:n.fn,options:[e,t]}},P7=(e,t)=>{const n=m7(e);return{name:n.name,fn:n.fn,options:[e,t]}},R7=(e,t)=>({fn:j7(e).fn,options:[e,t]}),I7=(e,t)=>{const n=v7(e);return{name:n.name,fn:n.fn,options:[e,t]}},M7=(e,t)=>{const n=y7(e);return{name:n.name,fn:n.fn,options:[e,t]}},L7=(e,t)=>{const n=b7(e);return{name:n.name,fn:n.fn,options:[e,t]}},O7=(e,t)=>{const n=E7(e);return{name:n.name,fn:n.fn,options:[e,t]}};var A7="Arrow",KS=p.forwardRef((e,t)=>{const{children:n,width:r=10,height:i=5,...s}=e;return o.jsx(Le.svg,{...s,ref:t,width:r,height:i,viewBox:"0 0 30 10",preserveAspectRatio:"none",children:e.asChild?n:o.jsx("polygon",{points:"0,0 30,0 15,10"})})});KS.displayName=A7;var D7=KS;function N7(e){const[t,n]=p.useState(void 0);return rr(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});const r=new ResizeObserver(i=>{if(!Array.isArray(i)||!i.length)return;const s=i[0];let a,l;if("borderBoxSize"in s){const c=s.borderBoxSize,d=Array.isArray(c)?c[0]:c;a=d.inlineSize,l=d.blockSize}else a=e.offsetWidth,l=e.offsetHeight;n({width:a,height:l})});return r.observe(e,{box:"border-box"}),()=>r.unobserve(e)}else n(void 0)},[e]),t}var x0="Popper",[QS,tf]=ji(x0),[_7,YS]=QS(x0),GS=e=>{const{__scopePopper:t,children:n}=e,[r,i]=p.useState(null),[s,a]=p.useState(void 0);return o.jsx(_7,{scope:t,anchor:r,onAnchorChange:i,placementState:s,setPlacementState:a,children:n})};GS.displayName=x0;var XS="PopperAnchor",JS=p.forwardRef((e,t)=>{const{__scopePopper:n,virtualRef:r,...i}=e,s=YS(XS,n),a=p.useRef(null),l=s.onAnchorChange,c=p.useCallback(v=>{a.current=v,v&&l(v)},[l]),d=Ot(t,c),u=p.useRef(null);p.useEffect(()=>{if(!r)return;const v=u.current;u.current=r.current,v!==u.current&&l(u.current)});const f=s.placementState&&v0(s.placementState),h=f==null?void 0:f[0],g=f==null?void 0:f[1];return r?null:o.jsx(Le.div,{"data-radix-popper-side":h,"data-radix-popper-align":g,...i,ref:d})});JS.displayName=XS;var m0="PopperContent",[$7,F7]=QS(m0),ZS=p.forwardRef((e,t)=>{var ve,be,jt,At,Re,xt;const{__scopePopper:n,side:r="bottom",sideOffset:i=0,align:s="center",alignOffset:a=0,arrowPadding:l=0,avoidCollisions:c=!0,collisionBoundary:d=[],collisionPadding:u=0,sticky:f="partial",hideWhenDetached:h=!1,updatePositionStrategy:g="optimized",onPlaced:v,...x}=e,b=YS(m0,n),[j,y]=p.useState(null),w=Ot(t,y),[k,S]=p.useState(null),T=N7(k),C=(T==null?void 0:T.width)??0,P=(T==null?void 0:T.height)??0,I=r+(s!=="center"?"-"+s:""),L=typeof u=="number"?u:{top:0,right:0,bottom:0,left:0,...u},z=Array.isArray(d)?d:[d],q=z.length>0,X={padding:L,boundary:z.filter(B7),altBoundary:q},{refs:D,floatingStyles:U,placement:Q,isPositioned:J,middlewareData:_}=C7({strategy:"fixed",placement:I,whileElementsMounted:(...we)=>g7(...we,{animationFrame:g==="always"}),elements:{reference:b.anchor},middleware:[T7({mainAxis:i+P,alignmentAxis:a}),c&&P7({mainAxis:!0,crossAxis:!1,limiter:f==="partial"?R7():void 0,...X}),c&&I7({...X}),M7({...X,apply:({elements:we,rects:Ie,availableWidth:De,availableHeight:Wn})=>{const{width:it,height:qe}=Ie.reference,Ve=we.floating.style;Ve.setProperty("--radix-popper-available-width",`${De}px`),Ve.setProperty("--radix-popper-available-height",`${Wn}px`),Ve.setProperty("--radix-popper-anchor-width",`${it}px`),Ve.setProperty("--radix-popper-anchor-height",`${qe}px`)}}),k&&O7({element:k,padding:l}),W7({arrowWidth:C,arrowHeight:P}),h&&L7({strategy:"referenceHidden",...X,boundary:q?X.boundary:void 0})]}),F=b.setPlacementState;rr(()=>(F(Q),()=>{F(void 0)}),[Q,F]);const[W,te]=v0(Q),A=Ir(v);rr(()=>{J&&(A==null||A())},[J,A]);const V=(ve=_.arrow)==null?void 0:ve.x,oe=(be=_.arrow)==null?void 0:be.y,Z=((jt=_.arrow)==null?void 0:jt.centerOffset)!==0,[ie,he]=p.useState();return rr(()=>{j&&he(window.getComputedStyle(j).zIndex)},[j]),o.jsx("div",{ref:D.setFloating,"data-radix-popper-content-wrapper":"",style:{...U,transform:J?U.transform:"translate(0, -200%)",minWidth:"max-content",zIndex:ie,"--radix-popper-transform-origin":[(At=_.transformOrigin)==null?void 0:At.x,(Re=_.transformOrigin)==null?void 0:Re.y].join(" "),...((xt=_.hide)==null?void 0:xt.referenceHidden)&&{visibility:"hidden",pointerEvents:"none"}},dir:e.dir,children:o.jsx($7,{scope:n,placedSide:W,placedAlign:te,onArrowChange:S,arrowX:V,arrowY:oe,shouldHideArrow:Z,children:o.jsx(Le.div,{"data-side":W,"data-align":te,...x,ref:w,style:{...x.style,animation:J?void 0:"none"}})})})});ZS.displayName=m0;var e5="PopperArrow",z7={top:"bottom",right:"left",bottom:"top",left:"right"},t5=p.forwardRef(function(t,n){const{__scopePopper:r,...i}=t,s=F7(e5,r),a=z7[s.placedSide];return o.jsx("span",{ref:s.onArrowChange,style:{position:"absolute",left:s.arrowX,top:s.arrowY,[a]:0,transformOrigin:{top:"",right:"0 0",bottom:"center 0",left:"100% 0"}[s.placedSide],transform:{top:"translateY(100%)",right:"translateY(50%) rotate(90deg) translateX(-50%)",bottom:"rotate(180deg)",left:"translateY(50%) rotate(-90deg) translateX(50%)"}[s.placedSide],visibility:s.shouldHideArrow?"hidden":void 0},children:o.jsx(D7,{...i,ref:n,style:{...i.style,display:"block"}})})});t5.displayName=e5;function B7(e){return e!==null}var W7=e=>({name:"transformOrigin",options:e,fn(t){var b,j,y;const{placement:n,rects:r,middlewareData:i}=t,a=((b=i.arrow)==null?void 0:b.centerOffset)!==0,l=a?0:e.arrowWidth,c=a?0:e.arrowHeight,[d,u]=v0(n),f={start:"0%",center:"50%",end:"100%"}[u],h=(((j=i.arrow)==null?void 0:j.x)??0)+l/2,g=(((y=i.arrow)==null?void 0:y.y)??0)+c/2;let v="",x="";return d==="bottom"?(v=a?f:`${h}px`,x=`${-c}px`):d==="top"?(v=a?f:`${h}px`,x=`${r.floating.height+c}px`):d==="right"?(v=`${-c}px`,x=a?f:`${g}px`):d==="left"&&(v=`${r.floating.width+c}px`,x=a?f:`${g}px`),{data:{x:v,y:x}}}});function v0(e){const[t,n="center"]=e.split("-");return[t,n]}var n5=GS,y0=JS,r5=ZS,o5=t5,U7="Portal",rd=p.forwardRef((e,t)=>{var l;const{container:n,...r}=e,[i,s]=p.useState(!1);rr(()=>s(!0),[]);const a=n||i&&((l=globalThis==null?void 0:globalThis.document)==null?void 0:l.body);return a?vs.createPortal(o.jsx(Le.div,{...r,ref:t}),a):null});rd.displayName=U7;var H7=Object.freeze({position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal"}),V7="VisuallyHidden",nf=p.forwardRef((e,t)=>o.jsx(Le.span,{...e,ref:t,style:{...H7,...e.style}}));nf.displayName=V7;var q7=nf,[rf]=ji("Tooltip",[tf]),of=tf(),i5="TooltipProvider",K7=700,jx="tooltip.open",[Q7,b0]=rf(i5),s5=e=>{const{__scopeTooltip:t,delayDuration:n=K7,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:s}=e,a=p.useRef(!0),l=p.useRef(!1),c=p.useRef(0);return p.useEffect(()=>{const d=c.current;return()=>window.clearTimeout(d)},[]),o.jsx(Q7,{scope:t,isOpenDelayedRef:a,delayDuration:n,onOpen:p.useCallback(()=>{r<=0||(window.clearTimeout(c.current),a.current=!1)},[r]),onClose:p.useCallback(()=>{r<=0||(window.clearTimeout(c.current),c.current=window.setTimeout(()=>a.current=!0,r))},[r]),isPointerInTransitRef:l,onPointerInTransitChange:p.useCallback(d=>{l.current=d},[]),disableHoverableContent:i,children:s})};s5.displayName=i5;var Oc="Tooltip",[Y7,od]=rf(Oc),a5=e=>{const{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:s,disableHoverableContent:a,delayDuration:l}=e,c=b0(Oc,e.__scopeTooltip),d=of(t),[u,f]=p.useState(null),h=kn(),g=p.useRef(0),v=a??c.disableHoverableContent,x=l??c.delayDuration,b=p.useRef(!1),[j,y]=pl({prop:r,defaultProp:i??!1,onChange:C=>{C?(c.onOpen(),document.dispatchEvent(new CustomEvent(jx))):c.onClose(),s==null||s(C)},caller:Oc}),w=p.useMemo(()=>j?b.current?"delayed-open":"instant-open":"closed",[j]),k=p.useCallback(()=>{window.clearTimeout(g.current),g.current=0,b.current=!1,y(!0)},[y]),S=p.useCallback(()=>{window.clearTimeout(g.current),g.current=0,y(!1)},[y]),T=p.useCallback(()=>{window.clearTimeout(g.current),g.current=window.setTimeout(()=>{b.current=!0,y(!0),g.current=0},x)},[x,y]);return p.useEffect(()=>()=>{g.current&&(window.clearTimeout(g.current),g.current=0)},[]),o.jsx(n5,{...d,children:o.jsx(Y7,{scope:t,contentId:h,open:j,stateAttribute:w,trigger:u,onTriggerChange:f,onTriggerEnter:p.useCallback(()=>{c.isOpenDelayedRef.current?T():k()},[c.isOpenDelayedRef,T,k]),onTriggerLeave:p.useCallback(()=>{v?S():(window.clearTimeout(g.current),g.current=0)},[S,v]),onOpen:k,onClose:S,disableHoverableContent:v,children:n})})};a5.displayName=Oc;var wx="TooltipTrigger",l5=p.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=od(wx,n),s=b0(wx,n),a=of(n),l=p.useRef(null),c=Ot(t,l,i.onTriggerChange),d=p.useRef(!1),u=p.useRef(!1),f=p.useCallback(()=>d.current=!1,[]);return p.useEffect(()=>()=>document.removeEventListener("pointerup",f),[f]),o.jsx(y0,{asChild:!0,...a,children:o.jsx(Le.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:c,onPointerMove:Ee(e.onPointerMove,h=>{h.pointerType!=="touch"&&!u.current&&!s.isPointerInTransitRef.current&&(i.onTriggerEnter(),u.current=!0)}),onPointerLeave:Ee(e.onPointerLeave,()=>{i.onTriggerLeave(),u.current=!1}),onPointerDown:Ee(e.onPointerDown,()=>{i.open&&i.onClose(),d.current=!0,document.addEventListener("pointerup",f,{once:!0})}),onFocus:Ee(e.onFocus,()=>{d.current||i.onOpen()}),onBlur:Ee(e.onBlur,i.onClose),onClick:Ee(e.onClick,i.onClose)})})});l5.displayName=wx;var j0="TooltipPortal",[G7,X7]=rf(j0,{forceMount:void 0}),c5=e=>{const{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,s=od(j0,t);return o.jsx(G7,{scope:t,forceMount:n,children:o.jsx(Or,{present:n||s.open,children:o.jsx(rd,{asChild:!0,container:i,children:r})})})};c5.displayName=j0;var qa="TooltipContent",d5=p.forwardRef((e,t)=>{const n=X7(qa,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i="top",...s}=e,a=od(qa,e.__scopeTooltip);return o.jsx(Or,{present:r||a.open,children:a.disableHoverableContent?o.jsx(u5,{side:i,...s,ref:t}):o.jsx(J7,{side:i,...s,ref:t})})}),J7=p.forwardRef((e,t)=>{const n=od(qa,e.__scopeTooltip),r=b0(qa,e.__scopeTooltip),i=p.useRef(null),s=Ot(t,i),[a,l]=p.useState(null),{trigger:c,onClose:d}=n,u=i.current,{onPointerInTransitChange:f}=r,h=p.useCallback(()=>{l(null),f(!1)},[f]),g=p.useCallback((v,x)=>{const b=v.currentTarget,j={x:v.clientX,y:v.clientY},y=nM(j,b.getBoundingClientRect()),w=rM(j,y),k=oM(x.getBoundingClientRect()),S=sM([...w,...k]);l(S),f(!0)},[f]);return p.useEffect(()=>()=>h(),[h]),p.useEffect(()=>{if(c&&u){const v=b=>g(b,u),x=b=>g(b,c);return c.addEventListener("pointerleave",v),u.addEventListener("pointerleave",x),()=>{c.removeEventListener("pointerleave",v),u.removeEventListener("pointerleave",x)}}},[c,u,g,h]),p.useEffect(()=>{if(a){const v=x=>{const b=x.target,j={x:x.clientX,y:x.clientY},y=(c==null?void 0:c.contains(b))||(u==null?void 0:u.contains(b)),w=!iM(j,a);y?h():w&&(h(),d())};return document.addEventListener("pointermove",v),()=>document.removeEventListener("pointermove",v)}},[c,u,a,d,h]),o.jsx(u5,{...e,ref:s})}),[Z7,eM]=rf(Oc,{isInside:!1}),tM=O9("TooltipContent"),u5=p.forwardRef((e,t)=>{const{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:s,onPointerDownOutside:a,...l}=e,c=od(qa,n),d=of(n),{onClose:u}=c;return p.useEffect(()=>(document.addEventListener(jx,u),()=>document.removeEventListener(jx,u)),[u]),p.useEffect(()=>{if(c.trigger){const f=h=>{h.target instanceof Node&&h.target.contains(c.trigger)&&u()};return window.addEventListener("scroll",f,{capture:!0}),()=>window.removeEventListener("scroll",f,{capture:!0})}},[c.trigger,u]),o.jsx(td,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:s,onPointerDownOutside:a,onFocusOutside:f=>f.preventDefault(),onDismiss:u,children:o.jsxs(r5,{"data-state":c.stateAttribute,...d,...l,ref:t,style:{...l.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[o.jsx(tM,{children:r}),o.jsx(Z7,{scope:n,isInside:!0,children:o.jsx(q7,{id:c.contentId,role:"tooltip",children:i||r})})]})})});d5.displayName=qa;var p5="TooltipArrow",f5=p.forwardRef((e,t)=>{const{__scopeTooltip:n,...r}=e,i=of(n);return eM(p5,n).isInside?null:o.jsx(o5,{...i,...r,ref:t})});f5.displayName=p5;function nM(e,t){const n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),s=Math.abs(t.left-e.x);switch(Math.min(n,r,i,s)){case s:return"left";case i:return"right";case n:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function rM(e,t,n=5){const r=[];switch(t){case"top":r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case"bottom":r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case"left":r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case"right":r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function oM(e){const{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function iM(e,t){const{x:n,y:r}=e;let i=!1;for(let s=0,a=t.length-1;s<t.length;a=s++){const l=t[s],c=t[a],d=l.x,u=l.y,f=c.x,h=c.y;u>r!=h>r&&n<(f-d)*(r-u)/(h-u)+d&&(i=!i)}return i}function sM(e){const t=e.slice();return t.sort((n,r)=>n.x<r.x?-1:n.x>r.x?1:n.y<r.y?-1:n.y>r.y?1:0),aM(t)}function aM(e){if(e.length<=1)return e.slice();const t=[];for(let r=0;r<e.length;r++){const i=e[r];for(;t.length>=2;){const s=t[t.length-1],a=t[t.length-2];if((s.x-a.x)*(i.y-a.y)>=(s.y-a.y)*(i.x-a.x))t.pop();else break}t.push(i)}t.pop();const n=[];for(let r=e.length-1;r>=0;r--){const i=e[r];for(;n.length>=2;){const s=n[n.length-1],a=n[n.length-2];if((s.x-a.x)*(i.y-a.y)>=(s.y-a.y)*(i.x-a.x))n.pop();else break}n.push(i)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var lM=s5,cM=a5,dM=l5,uM=c5,pM=d5,fM=f5;const hM=lM;function gM({content:e,children:t,side:n="top",delayDuration:r}){return o.jsxs(cM,{delayDuration:r,children:[o.jsx(dM,{asChild:!0,children:t}),o.jsx(uM,{children:o.jsxs(pM,{side:n,sideOffset:4,className:"z-50 rounded-card bg-state-ink px-1g py-0.5g font-sans text-ui text-surface-card shadow-card",children:[e,o.jsx(fM,{className:"fill-state-ink"})]})})]})}function Mu({title:e,description:t,icon:n,action:r,className:i}){return o.jsxs("div",{className:["flex flex-col items-center justify-center gap-1g rounded-card border border-card","bg-surface-card p-6g text-center shadow-card",i].filter(Boolean).join(" "),children:[n&&o.jsx("div",{className:"text-state-ink/40",children:n}),o.jsx("div",{className:"text-body font-medium text-state-ink/70",children:e}),t&&o.jsx("p",{className:"max-w-md text-ui text-state-ink/50",children:t}),r&&o.jsx("div",{className:"mt-1g",children:r})]})}const xM={waiting:"bg-pill-waiting-bg text-pill-waiting-fg",human:"bg-pill-failed-bg text-pill-failed-fg",info:"bg-pill-running-bg text-pill-running-fg"},mM={waiting:"bg-state-wait",human:"bg-state-fail",info:"bg-state-run"};function sf({severity:e,title:t,meta:n,detail:r,actions:i,children:s,pulse:a,className:l}){const c=r||i||s;return o.jsxs("div",{className:["overflow-hidden rounded-card border border-card bg-surface-card shadow-card",l].filter(Boolean).join(" "),children:[o.jsxs("div",{className:["flex items-center gap-1g px-1.5g py-1g",xM[e]].join(" "),children:[o.jsx("span",{className:["h-1g w-1g flex-none rounded-full",mM[e],a?"animate-pulse":""].filter(Boolean).join(" ")}),o.jsx("span",{className:"text-ui font-medium",children:t}),n&&o.jsx("span",{className:"ml-auto font-mono text-ui opacity-80",children:n})]}),c&&o.jsxs("div",{className:"flex flex-col gap-1g p-1.5g",children:[r&&o.jsx("div",{className:"text-ui text-state-ink/80",children:r}),s,i&&o.jsx("div",{className:"flex flex-wrap gap-1g",children:i})]})]})}var mh="focusScope.autoFocusOnMount",vh="focusScope.autoFocusOnUnmount",N1={bubbles:!1,cancelable:!0},vM="FocusScope",w0=p.forwardRef((e,t)=>{const{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:s,...a}=e,[l,c]=p.useState(null),d=Ir(i),u=Ir(s),f=p.useRef(null),h=Ot(t,c),g=p.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;p.useEffect(()=>{if(r){let x=function(w){if(g.paused||!l)return;const k=w.target;l.contains(k)?f.current=k:Io(f.current,{select:!0})},b=function(w){if(g.paused||!l)return;const k=w.relatedTarget;k!==null&&(l.contains(k)||Io(f.current,{select:!0}))},j=function(w){if(document.activeElement===document.body)for(const S of w)S.removedNodes.length>0&&Io(l)};document.addEventListener("focusin",x),document.addEventListener("focusout",b);const y=new MutationObserver(j);return l&&y.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",x),document.removeEventListener("focusout",b),y.disconnect()}}},[r,l,g.paused]),p.useEffect(()=>{if(l){$1.add(g);const x=document.activeElement;if(!l.contains(x)){const j=new CustomEvent(mh,N1);l.addEventListener(mh,d),l.dispatchEvent(j),j.defaultPrevented||(yM(SM(h5(l)),{select:!0}),document.activeElement===x&&Io(l))}return()=>{l.removeEventListener(mh,d),setTimeout(()=>{const j=new CustomEvent(vh,N1);l.addEventListener(vh,u),l.dispatchEvent(j),j.defaultPrevented||Io(x??document.body,{select:!0}),l.removeEventListener(vh,u),$1.remove(g)},0)}}},[l,d,u,g]);const v=p.useCallback(x=>{if(!n&&!r||g.paused)return;const b=x.key==="Tab"&&!x.altKey&&!x.ctrlKey&&!x.metaKey,j=document.activeElement;if(b&&j){const y=x.currentTarget,[w,k]=bM(y);w&&k?!x.shiftKey&&j===k?(x.preventDefault(),n&&Io(w,{select:!0})):x.shiftKey&&j===w&&(x.preventDefault(),n&&Io(k,{select:!0})):j===y&&x.preventDefault()}},[n,r,g.paused]);return o.jsx(Le.div,{tabIndex:-1,...a,ref:h,onKeyDown:v})});w0.displayName=vM;function yM(e,{select:t=!1}={}){const n=document.activeElement;for(const r of e)if(Io(r,{select:t}),document.activeElement!==n)return}function bM(e){const t=h5(e),n=_1(t,e),r=_1(t.reverse(),e);return[n,r]}function h5(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const i=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||i?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function _1(e,t){for(const n of e)if(!jM(n,{upTo:t}))return n}function jM(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function wM(e){return e instanceof HTMLInputElement&&"select"in e}function Io(e,{select:t=!1}={}){if(e&&e.focus){const n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&wM(e)&&t&&e.select()}}var $1=kM();function kM(){let e=[];return{add(t){const n=e[0];t!==n&&(n==null||n.pause()),e=F1(e,t),e.unshift(t)},remove(t){var n;e=F1(e,t),(n=e[0])==null||n.resume()}}}function F1(e,t){const n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function SM(e){return e.filter(t=>t.tagName!=="A")}var Gd=0,vr=null;function g5(){p.useEffect(()=>{vr||(vr={start:z1(),end:z1()});const{start:e,end:t}=vr;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement("afterbegin",e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement("beforeend",t),Gd++,()=>{Gd===1&&(vr==null||vr.start.remove(),vr==null||vr.end.remove(),vr=null),Gd=Math.max(0,Gd-1)}},[])}function z1(){const e=document.createElement("span");return e.setAttribute("data-radix-focus-guard",""),e.tabIndex=0,e.style.outline="none",e.style.opacity="0",e.style.position="fixed",e.style.pointerEvents="none",e}var Cr=function(){return Cr=Object.assign||function(t){for(var n,r=1,i=arguments.length;r<i;r++){n=arguments[r];for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(t[s]=n[s])}return t},Cr.apply(this,arguments)};function x5(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function CM(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,s;r<i;r++)(s||!(r in t))&&(s||(s=Array.prototype.slice.call(t,0,r)),s[r]=t[r]);return e.concat(s||Array.prototype.slice.call(t))}var Lu="right-scroll-bar-position",Ou="width-before-scroll-bar",EM="with-scroll-bars-hidden",TM="--removed-body-scroll-bar-size";function yh(e,t){return typeof e=="function"?e(t):e&&(e.current=t),e}function PM(e,t){var n=p.useState(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(r){var i=n.value;i!==r&&(n.value=r,n.callback(r,i))}}}})[0];return n.callback=t,n.facade}var RM=typeof window<"u"?p.useLayoutEffect:p.useEffect,B1=new WeakMap;function IM(e,t){var n=PM(null,function(r){return e.forEach(function(i){return yh(i,r)})});return RM(function(){var r=B1.get(n);if(r){var i=new Set(r),s=new Set(e),a=n.current;i.forEach(function(l){s.has(l)||yh(l,null)}),s.forEach(function(l){i.has(l)||yh(l,a)})}B1.set(n,e)},[e]),n}function MM(e){return e}function LM(e,t){t===void 0&&(t=MM);var n=[],r=!1,i={read:function(){if(r)throw new Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(s){var a=t(s,r);return n.push(a),function(){n=n.filter(function(l){return l!==a})}},assignSyncMedium:function(s){for(r=!0;n.length;){var a=n;n=[],a.forEach(s)}n={push:function(l){return s(l)},filter:function(){return n}}},assignMedium:function(s){r=!0;var a=[];if(n.length){var l=n;n=[],l.forEach(s),a=n}var c=function(){var u=a;a=[],u.forEach(s)},d=function(){return Promise.resolve().then(c)};d(),n={push:function(u){a.push(u),d()},filter:function(u){return a=a.filter(u),n}}}};return i}function OM(e){e===void 0&&(e={});var t=LM(null);return t.options=Cr({async:!0,ssr:!1},e),t}var m5=function(e){var t=e.sideCar,n=x5(e,["sideCar"]);if(!t)throw new Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw new Error("Sidecar medium not found");return p.createElement(r,Cr({},n))};m5.isSideCarExport=!0;function AM(e,t){return e.useMedium(t),m5}var v5=OM(),bh=function(){},af=p.forwardRef(function(e,t){var n=p.useRef(null),r=p.useState({onScrollCapture:bh,onWheelCapture:bh,onTouchMoveCapture:bh}),i=r[0],s=r[1],a=e.forwardProps,l=e.children,c=e.className,d=e.removeScrollBar,u=e.enabled,f=e.shards,h=e.sideCar,g=e.noRelative,v=e.noIsolation,x=e.inert,b=e.allowPinchZoom,j=e.as,y=j===void 0?"div":j,w=e.gapMode,k=x5(e,["forwardProps","children","className","removeScrollBar","enabled","shards","sideCar","noRelative","noIsolation","inert","allowPinchZoom","as","gapMode"]),S=h,T=IM([n,t]),C=Cr(Cr({},k),i);return p.createElement(p.Fragment,null,u&&p.createElement(S,{sideCar:v5,removeScrollBar:d,shards:f,noRelative:g,noIsolation:v,inert:x,setCallbacks:s,allowPinchZoom:!!b,lockRef:n,gapMode:w}),a?p.cloneElement(p.Children.only(l),Cr(Cr({},C),{ref:T})):p.createElement(y,Cr({},C,{className:c,ref:T}),l))});af.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1};af.classNames={fullWidth:Ou,zeroRight:Lu};var DM=function(){if(typeof __webpack_nonce__<"u")return __webpack_nonce__};function NM(){if(!document)return null;var e=document.createElement("style");e.type="text/css";var t=DM();return t&&e.setAttribute("nonce",t),e}function _M(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function $M(e){var t=document.head||document.getElementsByTagName("head")[0];t.appendChild(e)}var FM=function(){var e=0,t=null;return{add:function(n){e==0&&(t=NM())&&(_M(t,n),$M(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},zM=function(){var e=FM();return function(t,n){p.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},y5=function(){var e=zM(),t=function(n){var r=n.styles,i=n.dynamic;return e(r,i),null};return t},BM={left:0,top:0,right:0,gap:0},jh=function(e){return parseInt(e||"",10)||0},WM=function(e){var t=window.getComputedStyle(document.body),n=t[e==="padding"?"paddingLeft":"marginLeft"],r=t[e==="padding"?"paddingTop":"marginTop"],i=t[e==="padding"?"paddingRight":"marginRight"];return[jh(n),jh(r),jh(i)]},UM=function(e){if(e===void 0&&(e="margin"),typeof window>"u")return BM;var t=WM(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},HM=y5(),ba="data-scroll-locked",VM=function(e,t,n,r){var i=e.left,s=e.top,a=e.right,l=e.gap;return n===void 0&&(n="margin"),`
|
|
50
|
+
.`.concat(EM,` {
|
|
51
|
+
overflow: hidden `).concat(r,`;
|
|
52
|
+
padding-right: `).concat(l,"px ").concat(r,`;
|
|
53
|
+
}
|
|
54
|
+
body[`).concat(ba,`] {
|
|
55
|
+
overflow: hidden `).concat(r,`;
|
|
56
|
+
overscroll-behavior: contain;
|
|
57
|
+
`).concat([t&&"position: relative ".concat(r,";"),n==="margin"&&`
|
|
58
|
+
padding-left: `.concat(i,`px;
|
|
59
|
+
padding-top: `).concat(s,`px;
|
|
60
|
+
padding-right: `).concat(a,`px;
|
|
61
|
+
margin-left:0;
|
|
62
|
+
margin-top:0;
|
|
63
|
+
margin-right: `).concat(l,"px ").concat(r,`;
|
|
64
|
+
`),n==="padding"&&"padding-right: ".concat(l,"px ").concat(r,";")].filter(Boolean).join(""),`
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.`).concat(Lu,` {
|
|
68
|
+
right: `).concat(l,"px ").concat(r,`;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.`).concat(Ou,` {
|
|
72
|
+
margin-right: `).concat(l,"px ").concat(r,`;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.`).concat(Lu," .").concat(Lu,` {
|
|
76
|
+
right: 0 `).concat(r,`;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.`).concat(Ou," .").concat(Ou,` {
|
|
80
|
+
margin-right: 0 `).concat(r,`;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
body[`).concat(ba,`] {
|
|
84
|
+
`).concat(TM,": ").concat(l,`px;
|
|
85
|
+
}
|
|
86
|
+
`)},W1=function(){var e=parseInt(document.body.getAttribute(ba)||"0",10);return isFinite(e)?e:0},qM=function(){p.useEffect(function(){return document.body.setAttribute(ba,(W1()+1).toString()),function(){var e=W1()-1;e<=0?document.body.removeAttribute(ba):document.body.setAttribute(ba,e.toString())}},[])},KM=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?"margin":r;qM();var s=p.useMemo(function(){return UM(i)},[i]);return p.createElement(HM,{styles:VM(s,!t,i,n?"":"!important")})},kx=!1;if(typeof window<"u")try{var Xd=Object.defineProperty({},"passive",{get:function(){return kx=!0,!0}});window.addEventListener("test",Xd,Xd),window.removeEventListener("test",Xd,Xd)}catch{kx=!1}var Ls=kx?{passive:!1}:!1,QM=function(e){return e.tagName==="TEXTAREA"},b5=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!=="hidden"&&!(n.overflowY===n.overflowX&&!QM(e)&&n[t]==="visible")},YM=function(e){return b5(e,"overflowY")},GM=function(e){return b5(e,"overflowX")},U1=function(e,t){var n=t.ownerDocument,r=t;do{typeof ShadowRoot<"u"&&r instanceof ShadowRoot&&(r=r.host);var i=j5(e,r);if(i){var s=w5(e,r),a=s[1],l=s[2];if(a>l)return!0}r=r.parentNode}while(r&&r!==n.body);return!1},XM=function(e){var t=e.scrollTop,n=e.scrollHeight,r=e.clientHeight;return[t,n,r]},JM=function(e){var t=e.scrollLeft,n=e.scrollWidth,r=e.clientWidth;return[t,n,r]},j5=function(e,t){return e==="v"?YM(t):GM(t)},w5=function(e,t){return e==="v"?XM(t):JM(t)},ZM=function(e,t){return e==="h"&&t==="rtl"?-1:1},eL=function(e,t,n,r,i){var s=ZM(e,window.getComputedStyle(t).direction),a=s*r,l=n.target,c=t.contains(l),d=!1,u=a>0,f=0,h=0;do{if(!l)break;var g=w5(e,l),v=g[0],x=g[1],b=g[2],j=x-b-s*v;(v||j)&&j5(e,l)&&(f+=j,h+=v);var y=l.parentNode;l=y&&y.nodeType===Node.DOCUMENT_FRAGMENT_NODE?y.host:y}while(!c&&l!==document.body||c&&(t.contains(l)||t===l));return(u&&Math.abs(f)<1||!u&&Math.abs(h)<1)&&(d=!0),d},Jd=function(e){return"changedTouches"in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},H1=function(e){return[e.deltaX,e.deltaY]},V1=function(e){return e&&"current"in e?e.current:e},tL=function(e,t){return e[0]===t[0]&&e[1]===t[1]},nL=function(e){return`
|
|
87
|
+
.block-interactivity-`.concat(e,` {pointer-events: none;}
|
|
88
|
+
.allow-interactivity-`).concat(e,` {pointer-events: all;}
|
|
89
|
+
`)},rL=0,Os=[];function oL(e){var t=p.useRef([]),n=p.useRef([0,0]),r=p.useRef(),i=p.useState(rL++)[0],s=p.useState(y5)[0],a=p.useRef(e);p.useEffect(function(){a.current=e},[e]),p.useEffect(function(){if(e.inert){document.body.classList.add("block-interactivity-".concat(i));var x=CM([e.lockRef.current],(e.shards||[]).map(V1),!0).filter(Boolean);return x.forEach(function(b){return b.classList.add("allow-interactivity-".concat(i))}),function(){document.body.classList.remove("block-interactivity-".concat(i)),x.forEach(function(b){return b.classList.remove("allow-interactivity-".concat(i))})}}},[e.inert,e.lockRef.current,e.shards]);var l=p.useCallback(function(x,b){if("touches"in x&&x.touches.length===2||x.type==="wheel"&&x.ctrlKey)return!a.current.allowPinchZoom;var j=Jd(x),y=n.current,w="deltaX"in x?x.deltaX:y[0]-j[0],k="deltaY"in x?x.deltaY:y[1]-j[1],S,T=x.target,C=Math.abs(w)>Math.abs(k)?"h":"v";if("touches"in x&&C==="h"&&T.type==="range")return!1;var P=window.getSelection(),I=P&&P.anchorNode,L=I?I===T||I.contains(T):!1;if(L)return!1;var z=U1(C,T);if(!z)return!0;if(z?S=C:(S=C==="v"?"h":"v",z=U1(C,T)),!z)return!1;if(!r.current&&"changedTouches"in x&&(w||k)&&(r.current=S),!S)return!0;var q=r.current||S;return eL(q,b,x,q==="h"?w:k)},[]),c=p.useCallback(function(x){var b=x;if(!(!Os.length||Os[Os.length-1]!==s)){var j="deltaY"in b?H1(b):Jd(b),y=t.current.filter(function(S){return S.name===b.type&&(S.target===b.target||b.target===S.shadowParent)&&tL(S.delta,j)})[0];if(y&&y.should){b.cancelable&&b.preventDefault();return}if(!y){var w=(a.current.shards||[]).map(V1).filter(Boolean).filter(function(S){return S.contains(b.target)}),k=w.length>0?l(b,w[0]):!a.current.noIsolation;k&&b.cancelable&&b.preventDefault()}}},[]),d=p.useCallback(function(x,b,j,y){var w={name:x,delta:b,target:j,should:y,shadowParent:iL(j)};t.current.push(w),setTimeout(function(){t.current=t.current.filter(function(k){return k!==w})},1)},[]),u=p.useCallback(function(x){n.current=Jd(x),r.current=void 0},[]),f=p.useCallback(function(x){d(x.type,H1(x),x.target,l(x,e.lockRef.current))},[]),h=p.useCallback(function(x){d(x.type,Jd(x),x.target,l(x,e.lockRef.current))},[]);p.useEffect(function(){return Os.push(s),e.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:h}),document.addEventListener("wheel",c,Ls),document.addEventListener("touchmove",c,Ls),document.addEventListener("touchstart",u,Ls),function(){Os=Os.filter(function(x){return x!==s}),document.removeEventListener("wheel",c,Ls),document.removeEventListener("touchmove",c,Ls),document.removeEventListener("touchstart",u,Ls)}},[]);var g=e.removeScrollBar,v=e.inert;return p.createElement(p.Fragment,null,v?p.createElement(s,{styles:nL(i)}):null,g?p.createElement(KM,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function iL(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}const sL=AM(v5,oL);var k0=p.forwardRef(function(e,t){return p.createElement(af,Cr({},e,{ref:t,sideCar:sL}))});k0.classNames=af.classNames;var aL=function(e){if(typeof document>"u")return null;var t=Array.isArray(e)?e[0]:e;return t.ownerDocument.body},As=new WeakMap,Zd=new WeakMap,eu={},wh=0,k5=function(e){return e&&(e.host||k5(e.parentNode))},lL=function(e,t){return t.map(function(n){if(e.contains(n))return n;var r=k5(n);return r&&e.contains(r)?r:(console.error("aria-hidden",n,"in not contained inside",e,". Doing nothing"),null)}).filter(function(n){return!!n})},cL=function(e,t,n,r){var i=lL(t,Array.isArray(e)?e:[e]);eu[n]||(eu[n]=new WeakMap);var s=eu[n],a=[],l=new Set,c=new Set(i),d=function(f){!f||l.has(f)||(l.add(f),d(f.parentNode))};i.forEach(d);var u=function(f){!f||c.has(f)||Array.prototype.forEach.call(f.children,function(h){if(l.has(h))u(h);else try{var g=h.getAttribute(r),v=g!==null&&g!=="false",x=(As.get(h)||0)+1,b=(s.get(h)||0)+1;As.set(h,x),s.set(h,b),a.push(h),x===1&&v&&Zd.set(h,!0),b===1&&h.setAttribute(n,"true"),v||h.setAttribute(r,"true")}catch(j){console.error("aria-hidden: cannot operate on ",h,j)}})};return u(t),l.clear(),wh++,function(){a.forEach(function(f){var h=As.get(f)-1,g=s.get(f)-1;As.set(f,h),s.set(f,g),h||(Zd.has(f)||f.removeAttribute(r),Zd.delete(f)),g||f.removeAttribute(n)}),wh--,wh||(As=new WeakMap,As=new WeakMap,Zd=new WeakMap,eu={})}},S5=function(e,t,n){n===void 0&&(n="data-aria-hidden");var r=Array.from(Array.isArray(e)?e:[e]),i=aL(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll("[aria-live], script"))),cL(r,i,n,"aria-hidden")):function(){return null}},lf="Dialog",[C5]=ji(lf),[dL,cr]=C5(lf),po=e=>{const{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:s,modal:a=!0}=e,l=p.useRef(null),c=p.useRef(null),[d,u]=pl({prop:r,defaultProp:i??!1,onChange:s,caller:lf});return o.jsx(dL,{scope:t,triggerRef:l,contentRef:c,contentId:kn(),titleId:kn(),descriptionId:kn(),open:d,onOpenChange:u,onOpenToggle:p.useCallback(()=>u(f=>!f),[u]),modal:a,children:n})};po.displayName=lf;var E5="DialogTrigger",S0=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=cr(E5,n),s=Ot(t,i.triggerRef);return o.jsx(Le.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":E0(i.open),...r,ref:s,onClick:Ee(e.onClick,i.onOpenToggle)})});S0.displayName=E5;var C0="DialogPortal",[uL,T5]=C5(C0,{forceMount:void 0}),fo=e=>{const{__scopeDialog:t,forceMount:n,children:r,container:i}=e,s=cr(C0,t);return o.jsx(uL,{scope:t,forceMount:n,children:p.Children.map(r,a=>o.jsx(Or,{present:n||s.open,children:o.jsx(rd,{asChild:!0,container:i,children:a})}))})};fo.displayName=C0;var mp="DialogOverlay",ho=p.forwardRef((e,t)=>{const n=T5(mp,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,s=cr(mp,e.__scopeDialog);return s.modal?o.jsx(Or,{present:r||s.open,children:o.jsx(fL,{...i,ref:t})}):null});ho.displayName=mp;var pL=Mc("DialogOverlay.RemoveScroll"),fL=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=cr(mp,n),s=CI(),a=Ot(t,s);return o.jsx(k0,{as:pL,allowPinchZoom:!0,shards:[i.contentRef],children:o.jsx(Le.div,{"data-state":E0(i.open),...r,ref:a,style:{pointerEvents:"auto",...r.style}})})}),Ka="DialogContent",go=p.forwardRef((e,t)=>{const n=T5(Ka,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,s=cr(Ka,e.__scopeDialog);return o.jsx(Or,{present:r||s.open,children:s.modal?o.jsx(hL,{...i,ref:t}):o.jsx(gL,{...i,ref:t})})});go.displayName=Ka;var hL=p.forwardRef((e,t)=>{const n=cr(Ka,e.__scopeDialog),r=p.useRef(null),i=Ot(t,n.contentRef,r);return p.useEffect(()=>{const s=r.current;if(s)return S5(s)},[]),o.jsx(P5,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:Ee(e.onCloseAutoFocus,s=>{var a;s.preventDefault(),(a=n.triggerRef.current)==null||a.focus()}),onPointerDownOutside:Ee(e.onPointerDownOutside,s=>{const a=s.detail.originalEvent,l=a.button===0&&a.ctrlKey===!0;(a.button===2||l)&&s.preventDefault()}),onFocusOutside:Ee(e.onFocusOutside,s=>s.preventDefault())})}),gL=p.forwardRef((e,t)=>{const n=cr(Ka,e.__scopeDialog),r=p.useRef(!1),i=p.useRef(!1);return o.jsx(P5,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var a,l;(a=e.onCloseAutoFocus)==null||a.call(e,s),s.defaultPrevented||(r.current||(l=n.triggerRef.current)==null||l.focus(),s.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:s=>{var c,d;(c=e.onInteractOutside)==null||c.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const a=s.target;((d=n.triggerRef.current)==null?void 0:d.contains(a))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&i.current&&s.preventDefault()}})}),P5=p.forwardRef((e,t)=>{const{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:s,...a}=e,l=cr(Ka,n);return g5(),o.jsx(o.Fragment,{children:o.jsx(w0,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:s,children:o.jsx(td,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":E0(l.open),...a,ref:t,deferPointerDownOutside:!0,onDismiss:()=>l.onOpenChange(!1)})})})}),R5="DialogTitle",wi=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=cr(R5,n);return o.jsx(Le.h2,{id:i.titleId,...r,ref:t})});wi.displayName=R5;var I5="DialogDescription",id=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=cr(I5,n);return o.jsx(Le.p,{id:i.descriptionId,...r,ref:t})});id.displayName=I5;var M5="DialogClose",sd=p.forwardRef((e,t)=>{const{__scopeDialog:n,...r}=e,i=cr(M5,n);return o.jsx(Le.button,{type:"button",...r,ref:t,onClick:Ee(e.onClick,()=>i.onOpenChange(!1))})});sd.displayName=M5;function E0(e){return e?"open":"closed"}const xL="fixed inset-0 bg-state-ink/40 data-[state=open]:animate-fade-in data-[state=closed]:animate-fade-out motion-reduce:animate-none ",mL="fixed left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 flex max-h-[85vh] w-[90vw] flex-col gap-2g rounded-card border border-card bg-surface-card p-3g shadow-overlay focus:outline-none data-[state=open]:animate-zoom-in data-[state=closed]:animate-zoom-out motion-reduce:animate-none ",vL={default:"max-w-lg",wide:"max-w-3xl"},L5={default:{overlay:"z-40",content:"z-50"},nested:{overlay:"z-[80]",content:"z-[90]"}};function yL(e="default"){return xL+L5[e].overlay}function bL(e="default",t="default"){return`${mL}${vL[e]} ${L5[t].content}`}function jL({title:e,hideTitle:t}){return o.jsxs("div",{className:"flex items-start justify-between gap-2g",children:[o.jsx(wi,{className:t?"sr-only":"text-body font-medium text-state-ink",children:e}),o.jsx(sd,{"aria-label":"Close",className:"-mr-1g -mt-1g rounded-card p-0.5g text-ui text-state-ink/60 transition-colors hover:bg-surface-canvas-alt hover:text-state-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-state-run/40",children:"✕"})]})}function wL({title:e,description:t,hideTitle:n,children:r,footer:i,size:s="default",layer:a="default"}){return o.jsxs(go,{className:bL(s,a),children:[o.jsx(jL,{title:e,hideTitle:n}),t?o.jsx(id,{className:"text-ui text-state-ink/70",children:t}):null,r?o.jsx("div",{className:"overflow-y-auto text-ui text-state-ink/80",children:r}):null,i?o.jsx("div",{className:"flex items-center justify-end gap-1g pt-1g",children:i}):null]})}function cf({trigger:e,open:t,onOpenChange:n,...r}){return o.jsxs(po,{open:t,onOpenChange:n,children:[e?o.jsx(S0,{asChild:!0,children:e}):null,o.jsxs(fo,{children:[o.jsx(ho,{className:yL(r.layer)}),o.jsx(wL,{...r})]})]})}const kL=sd,SL="fixed inset-0 z-40 bg-state-ink/40 data-[state=open]:animate-fade-in data-[state=closed]:animate-fade-out motion-reduce:animate-none",CL={right:"right-0 border-l data-[state=open]:animate-slide-in-right data-[state=closed]:animate-slide-out-right",left:"left-0 border-r data-[state=open]:animate-slide-in-left data-[state=closed]:animate-slide-out-left"};function EL({title:e,description:t,hideTitle:n,side:r="right",children:i,footer:s,trigger:a,open:l,onOpenChange:c}){const d="fixed inset-y-0 z-50 flex h-full w-[92vw] max-w-md flex-col gap-2g border-card bg-surface-card p-3g shadow-overlay focus:outline-none motion-reduce:animate-none "+CL[r];return o.jsxs(po,{open:l,onOpenChange:c,children:[a?o.jsx(S0,{asChild:!0,children:a}):null,o.jsxs(fo,{children:[o.jsx(ho,{className:SL}),o.jsxs(go,{className:d,children:[o.jsxs("div",{className:"flex items-start justify-between gap-2g",children:[o.jsx(wi,{className:n?"sr-only":"text-body font-medium text-state-ink",children:e}),o.jsx(sd,{"aria-label":"Close",className:"-mr-1g -mt-1g rounded-card p-0.5g text-ui text-state-ink/60 transition-colors hover:bg-surface-canvas-alt hover:text-state-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-state-run/40",children:"✕"})]}),t?o.jsx(id,{className:"text-ui text-state-ink/70",children:t}):null,i?o.jsx("div",{className:"flex-1 overflow-y-auto text-ui text-state-ink/80",children:i}):null,s?o.jsx("div",{className:"flex items-center justify-end gap-1g pt-1g",children:s}):null]})]})]})}const TL=sd;var df="Popover",[O5]=ji(df,[tf]),ad=tf(),[PL,ki]=O5(df),A5=e=>{const{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:s,modal:a=!1}=e,l=ad(t),c=p.useRef(null),[d,u]=p.useState(!1),[f,h]=pl({prop:r,defaultProp:i??!1,onChange:s,caller:df});return o.jsx(n5,{...l,children:o.jsx(PL,{scope:t,contentId:kn(),triggerRef:c,open:f,onOpenChange:h,onOpenToggle:p.useCallback(()=>h(g=>!g),[h]),hasCustomAnchor:d,onCustomAnchorAdd:p.useCallback(()=>u(!0),[]),onCustomAnchorRemove:p.useCallback(()=>u(!1),[]),modal:a,children:n})})};A5.displayName=df;var D5="PopoverAnchor",RL=p.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,i=ki(D5,n),s=ad(n),{onCustomAnchorAdd:a,onCustomAnchorRemove:l}=i;return p.useEffect(()=>(a(),()=>l()),[a,l]),o.jsx(y0,{...s,...r,ref:t})});RL.displayName=D5;var N5="PopoverTrigger",_5=p.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,i=ki(N5,n),s=ad(n),a=Ot(t,i.triggerRef),l=o.jsx(Le.button,{type:"button","aria-haspopup":"dialog","aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":U5(i.open),...r,ref:a,onClick:Ee(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?l:o.jsx(y0,{asChild:!0,...s,children:l})});_5.displayName=N5;var T0="PopoverPortal",[IL,ML]=O5(T0,{forceMount:void 0}),$5=e=>{const{__scopePopover:t,forceMount:n,children:r,container:i}=e,s=ki(T0,t);return o.jsx(IL,{scope:t,forceMount:n,children:o.jsx(Or,{present:n||s.open,children:o.jsx(rd,{asChild:!0,container:i,children:r})})})};$5.displayName=T0;var Qa="PopoverContent",F5=p.forwardRef((e,t)=>{const n=ML(Qa,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,s=ki(Qa,e.__scopePopover);return o.jsx(Or,{present:r||s.open,children:s.modal?o.jsx(OL,{...i,ref:t}):o.jsx(AL,{...i,ref:t})})});F5.displayName=Qa;var LL=Mc("PopoverContent.RemoveScroll"),OL=p.forwardRef((e,t)=>{const n=ki(Qa,e.__scopePopover),r=p.useRef(null),i=Ot(t,r),s=p.useRef(!1);return p.useEffect(()=>{const a=r.current;if(a)return S5(a)},[]),o.jsx(k0,{as:LL,allowPinchZoom:!0,children:o.jsx(z5,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Ee(e.onCloseAutoFocus,a=>{var l;a.preventDefault(),s.current||(l=n.triggerRef.current)==null||l.focus()}),onPointerDownOutside:Ee(e.onPointerDownOutside,a=>{const l=a.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0,d=l.button===2||c;s.current=d},{checkForDefaultPrevented:!1}),onFocusOutside:Ee(e.onFocusOutside,a=>a.preventDefault(),{checkForDefaultPrevented:!1})})})}),AL=p.forwardRef((e,t)=>{const n=ki(Qa,e.__scopePopover),r=p.useRef(!1),i=p.useRef(!1);return o.jsx(z5,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:s=>{var a,l;(a=e.onCloseAutoFocus)==null||a.call(e,s),s.defaultPrevented||(r.current||(l=n.triggerRef.current)==null||l.focus(),s.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:s=>{var c,d;(c=e.onInteractOutside)==null||c.call(e,s),s.defaultPrevented||(r.current=!0,s.detail.originalEvent.type==="pointerdown"&&(i.current=!0));const a=s.target;((d=n.triggerRef.current)==null?void 0:d.contains(a))&&s.preventDefault(),s.detail.originalEvent.type==="focusin"&&i.current&&s.preventDefault()}})}),z5=p.forwardRef((e,t)=>{const{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:s,disableOutsidePointerEvents:a,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:d,onInteractOutside:u,...f}=e,h=ki(Qa,n),g=ad(n);return g5(),o.jsx(w0,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:s,children:o.jsx(td,{asChild:!0,disableOutsidePointerEvents:a,onInteractOutside:u,onEscapeKeyDown:l,onPointerDownOutside:c,onFocusOutside:d,onDismiss:()=>h.onOpenChange(!1),deferPointerDownOutside:!0,children:o.jsx(r5,{"data-state":U5(h.open),role:"dialog",id:h.contentId,...g,...f,ref:t,style:{...f.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}})})})}),B5="PopoverClose",DL=p.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,i=ki(B5,n);return o.jsx(Le.button,{type:"button",...r,ref:t,onClick:Ee(e.onClick,()=>i.onOpenChange(!1))})});DL.displayName=B5;var NL="PopoverArrow",W5=p.forwardRef((e,t)=>{const{__scopePopover:n,...r}=e,i=ad(n);return o.jsx(o5,{...i,...r,ref:t})});W5.displayName=NL;function U5(e){return e?"open":"closed"}var _L=A5,$L=_5,FL=$5,zL=F5,BL=W5;const WL="z-50 min-w-[12rem] rounded-card border border-card bg-surface-card p-2g text-ui text-state-ink shadow-overlay focus:outline-none data-[state=open]:animate-popover-in data-[state=closed]:animate-popover-out motion-reduce:animate-none";function H5({trigger:e,children:t,side:n="bottom",align:r="center",open:i,onOpenChange:s}){return o.jsxs(_L,{open:i,onOpenChange:s,children:[o.jsx($L,{asChild:!0,children:e}),o.jsx(FL,{children:o.jsxs(zL,{className:WL,side:n,align:r,sideOffset:6,children:[t,o.jsx(BL,{className:"fill-surface-card"})]})})]})}var P0="ToastProvider",[R0,UL,HL]=gS("Toast"),[V5]=ji("Toast",[HL]),[VL,uf]=V5(P0),q5=e=>{const{__scopeToast:t,label:n="Notification",duration:r=5e3,swipeDirection:i="right",swipeThreshold:s=50,announcerContainer:a,children:l}=e,[c,d]=p.useState(null),[u,f]=p.useState(0),h=p.useRef(!1),g=p.useRef(!1);return n.trim()||console.error(`Invalid prop \`label\` supplied to \`${P0}\`. Expected non-empty \`string\`.`),o.jsx(R0.Provider,{scope:t,children:o.jsx(VL,{scope:t,label:n,duration:r,swipeDirection:i,swipeThreshold:s,toastCount:u,viewport:c,onViewportChange:d,onToastAdd:p.useCallback(()=>f(v=>v+1),[]),onToastRemove:p.useCallback(()=>f(v=>v-1),[]),isFocusedToastEscapeKeyDownRef:h,isClosePausedRef:g,announcerContainer:a,children:l})})};q5.displayName=P0;var K5="ToastViewport",qL=["F8"],Sx="toast.viewportPause",Cx="toast.viewportResume",Q5=p.forwardRef((e,t)=>{const{__scopeToast:n,hotkey:r=qL,label:i="Notifications ({hotkey})",...s}=e,a=uf(K5,n),l=UL(n),c=p.useRef(null),d=p.useRef(null),u=p.useRef(null),f=p.useRef(null),h=Ot(t,f,a.onViewportChange),g=r.join("+").replace(/Key/g,"").replace(/Digit/g,""),v=a.toastCount>0;p.useEffect(()=>{const b=j=>{var w;r.length!==0&&r.every(k=>j[k]||j.code===k)&&((w=f.current)==null||w.focus())};return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[r]),p.useEffect(()=>{const b=c.current,j=f.current;if(v&&b&&j){const y=()=>{if(!a.isClosePausedRef.current){const T=new CustomEvent(Sx);j.dispatchEvent(T),a.isClosePausedRef.current=!0}},w=()=>{if(a.isClosePausedRef.current){const T=new CustomEvent(Cx);j.dispatchEvent(T),a.isClosePausedRef.current=!1}},k=T=>{!b.contains(T.relatedTarget)&&w()},S=()=>{b.contains(document.activeElement)||w()};return b.addEventListener("focusin",y),b.addEventListener("focusout",k),b.addEventListener("pointermove",y),b.addEventListener("pointerleave",S),window.addEventListener("blur",y),window.addEventListener("focus",w),()=>{b.removeEventListener("focusin",y),b.removeEventListener("focusout",k),b.removeEventListener("pointermove",y),b.removeEventListener("pointerleave",S),window.removeEventListener("blur",y),window.removeEventListener("focus",w)}}},[v,a.isClosePausedRef]);const x=p.useCallback(({tabbingDirection:b})=>{const y=l().map(w=>{const k=w.ref.current,S=[k,...iO(k)];return b==="forwards"?S:S.reverse()});return(b==="forwards"?y.reverse():y).flat()},[l]);return p.useEffect(()=>{const b=f.current;if(b){const j=y=>{var S,T,C;const w=y.altKey||y.ctrlKey||y.metaKey;if(y.key==="Tab"&&!w){const P=document.activeElement,I=y.shiftKey;if(y.target===b&&I){(S=d.current)==null||S.focus();return}const q=x({tabbingDirection:I?"backwards":"forwards"}),X=q.findIndex(D=>D===P);kh(q.slice(X+1))?y.preventDefault():I?(T=d.current)==null||T.focus():(C=u.current)==null||C.focus()}};return b.addEventListener("keydown",j),()=>b.removeEventListener("keydown",j)}},[l,x]),o.jsxs(RI,{ref:c,role:"region","aria-label":i.replace("{hotkey}",g),tabIndex:-1,style:{pointerEvents:v?void 0:"none"},children:[v&&o.jsx(Ex,{ref:d,onFocusFromOutsideViewport:()=>{const b=x({tabbingDirection:"forwards"});kh(b)}}),o.jsx(R0.Slot,{scope:n,children:o.jsx(Le.ol,{tabIndex:-1,...s,ref:h})}),v&&o.jsx(Ex,{ref:u,onFocusFromOutsideViewport:()=>{const b=x({tabbingDirection:"backwards"});kh(b)}})]})});Q5.displayName=K5;var Y5="ToastFocusProxy",Ex=p.forwardRef((e,t)=>{const{__scopeToast:n,onFocusFromOutsideViewport:r,...i}=e,s=uf(Y5,n);return o.jsx(nf,{tabIndex:0,...i,ref:t,style:{position:"fixed"},onFocus:a=>{var d;const l=a.relatedTarget;!((d=s.viewport)!=null&&d.contains(l))&&r()}})});Ex.displayName=Y5;var ld="Toast",KL="toast.swipeStart",QL="toast.swipeMove",YL="toast.swipeCancel",GL="toast.swipeEnd",G5=p.forwardRef((e,t)=>{const{forceMount:n,open:r,defaultOpen:i,onOpenChange:s,...a}=e,[l,c]=pl({prop:r,defaultProp:i??!0,onChange:s,caller:ld});return o.jsx(Or,{present:n||l,children:o.jsx(ZL,{open:l,...a,ref:t,onClose:()=>c(!1),onPause:Ir(e.onPause),onResume:Ir(e.onResume),onSwipeStart:Ee(e.onSwipeStart,d=>{d.currentTarget.setAttribute("data-swipe","start")}),onSwipeMove:Ee(e.onSwipeMove,d=>{const{x:u,y:f}=d.detail.delta;d.currentTarget.setAttribute("data-swipe","move"),d.currentTarget.style.setProperty("--radix-toast-swipe-move-x",`${u}px`),d.currentTarget.style.setProperty("--radix-toast-swipe-move-y",`${f}px`)}),onSwipeCancel:Ee(e.onSwipeCancel,d=>{d.currentTarget.setAttribute("data-swipe","cancel"),d.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),d.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),d.currentTarget.style.removeProperty("--radix-toast-swipe-end-x"),d.currentTarget.style.removeProperty("--radix-toast-swipe-end-y")}),onSwipeEnd:Ee(e.onSwipeEnd,d=>{const{x:u,y:f}=d.detail.delta;d.currentTarget.setAttribute("data-swipe","end"),d.currentTarget.style.removeProperty("--radix-toast-swipe-move-x"),d.currentTarget.style.removeProperty("--radix-toast-swipe-move-y"),d.currentTarget.style.setProperty("--radix-toast-swipe-end-x",`${u}px`),d.currentTarget.style.setProperty("--radix-toast-swipe-end-y",`${f}px`),c(!1)})})})});G5.displayName=ld;var[XL,JL]=V5(ld,{onClose(){}}),ZL=p.forwardRef((e,t)=>{const{__scopeToast:n,type:r="foreground",duration:i,open:s,onClose:a,onEscapeKeyDown:l,onPause:c,onResume:d,onSwipeStart:u,onSwipeMove:f,onSwipeCancel:h,onSwipeEnd:g,...v}=e,x=uf(ld,n),[b,j]=p.useState(null),y=Ot(t,j),w=p.useRef(null),k=p.useRef(null),S=i||x.duration,T=p.useRef(0),C=p.useRef(S),P=p.useRef(0),{onToastAdd:I,onToastRemove:L}=x,z=Ir(()=>{var U;(b==null?void 0:b.contains(document.activeElement))&&((U=x.viewport)==null||U.focus()),a()}),q=p.useCallback(D=>{!D||D===1/0||(window.clearTimeout(P.current),T.current=new Date().getTime(),P.current=window.setTimeout(z,D))},[z]);p.useEffect(()=>{const D=x.viewport;if(D){const U=()=>{q(C.current),d==null||d()},Q=()=>{const J=new Date().getTime()-T.current;C.current=C.current-J,window.clearTimeout(P.current),c==null||c()};return D.addEventListener(Sx,Q),D.addEventListener(Cx,U),()=>{D.removeEventListener(Sx,Q),D.removeEventListener(Cx,U)}}},[x.viewport,S,c,d,q]),p.useEffect(()=>{s&&!x.isClosePausedRef.current&&q(S)},[s,S,x.isClosePausedRef,q]),p.useEffect(()=>()=>{window.clearTimeout(P.current)},[]),p.useEffect(()=>(I(),()=>L()),[I,L]);const X=p.useMemo(()=>b?r4(b):null,[b]);return x.viewport?o.jsxs(o.Fragment,{children:[X&&o.jsx(eO,{__scopeToast:n,role:"status","aria-live":r==="foreground"?"assertive":"polite",children:X}),o.jsx(XL,{scope:n,onClose:z,children:vs.createPortal(o.jsx(R0.ItemSlot,{scope:n,children:o.jsx(PI,{asChild:!0,onEscapeKeyDown:Ee(l,()=>{x.isFocusedToastEscapeKeyDownRef.current||z(),x.isFocusedToastEscapeKeyDownRef.current=!1}),children:o.jsx(Le.li,{tabIndex:0,"data-state":s?"open":"closed","data-swipe-direction":x.swipeDirection,...v,ref:y,style:{userSelect:"none",touchAction:"none",...e.style},onKeyDown:Ee(e.onKeyDown,D=>{D.key==="Escape"&&(l==null||l(D.nativeEvent),D.nativeEvent.defaultPrevented||(x.isFocusedToastEscapeKeyDownRef.current=!0,z()))}),onPointerDown:Ee(e.onPointerDown,D=>{D.button===0&&(w.current={x:D.clientX,y:D.clientY})}),onPointerMove:Ee(e.onPointerMove,D=>{if(!w.current)return;const U=D.clientX-w.current.x,Q=D.clientY-w.current.y,J=!!k.current,_=["left","right"].includes(x.swipeDirection),F=["left","up"].includes(x.swipeDirection)?Math.min:Math.max,W=_?F(0,U):0,te=_?0:F(0,Q),A=D.pointerType==="touch"?10:2,V={x:W,y:te},oe={originalEvent:D,delta:V};J?(k.current=V,tu(QL,f,oe,{discrete:!1})):q1(V,x.swipeDirection,A)?(k.current=V,tu(KL,u,oe,{discrete:!1}),D.target.setPointerCapture(D.pointerId)):(Math.abs(U)>A||Math.abs(Q)>A)&&(w.current=null)}),onPointerUp:Ee(e.onPointerUp,D=>{const U=k.current,Q=D.target;if(Q.hasPointerCapture(D.pointerId)&&Q.releasePointerCapture(D.pointerId),k.current=null,w.current=null,U){const J=D.currentTarget,_={originalEvent:D,delta:U};q1(U,x.swipeDirection,x.swipeThreshold)?tu(GL,g,_,{discrete:!0}):tu(YL,h,_,{discrete:!0}),J.addEventListener("click",F=>F.preventDefault(),{once:!0})}})})})}),x.viewport)})]}):null}),eO=e=>{const{__scopeToast:t,children:n,...r}=e,i=uf(ld,t),[s,a]=p.useState(!1),[l,c]=p.useState(!1);return rO(()=>a(!0)),p.useEffect(()=>{const d=window.setTimeout(()=>c(!0),1e3);return()=>window.clearTimeout(d)},[]),l?null:o.jsx(rd,{asChild:!0,container:i.announcerContainer||void 0,children:o.jsx(nf,{...r,children:s&&o.jsxs(o.Fragment,{children:[i.label," ",n]})})})},tO="ToastTitle",X5=p.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return o.jsx(Le.div,{...r,ref:t})});X5.displayName=tO;var nO="ToastDescription",J5=p.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e;return o.jsx(Le.div,{...r,ref:t})});J5.displayName=nO;var Z5="ToastAction",e4=p.forwardRef((e,t)=>{const{altText:n,...r}=e;return n.trim()?o.jsx(n4,{altText:n,asChild:!0,children:o.jsx(I0,{...r,ref:t})}):(console.error(`Invalid prop \`altText\` supplied to \`${Z5}\`. Expected non-empty \`string\`.`),null)});e4.displayName=Z5;var t4="ToastClose",I0=p.forwardRef((e,t)=>{const{__scopeToast:n,...r}=e,i=JL(t4,n);return o.jsx(n4,{asChild:!0,children:o.jsx(Le.button,{type:"button",...r,ref:t,onClick:Ee(e.onClick,i.onClose)})})});I0.displayName=t4;var n4=p.forwardRef((e,t)=>{const{__scopeToast:n,altText:r,...i}=e;return o.jsx(Le.div,{"data-radix-toast-announce-exclude":"","data-radix-toast-announce-alt":r||void 0,...i,ref:t})});function r4(e){const t=[];return Array.from(e.childNodes).forEach(r=>{if(r.nodeType===r.TEXT_NODE&&r.textContent&&t.push(r.textContent),oO(r)){const i=r.ariaHidden||r.hidden||r.style.display==="none",s=r.dataset.radixToastAnnounceExclude==="";if(!i)if(s){const a=r.dataset.radixToastAnnounceAlt;a&&t.push(a)}else t.push(...r4(r))}}),t}function tu(e,t,n,{discrete:r}){const i=n.originalEvent.currentTarget,s=new CustomEvent(e,{bubbles:!0,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?xS(i,s):i.dispatchEvent(s)}var q1=(e,t,n=0)=>{const r=Math.abs(e.x),i=Math.abs(e.y),s=r>i;return t==="left"||t==="right"?s&&r>n:!s&&i>n};function rO(e=()=>{}){const t=Ir(e);rr(()=>{let n=0,r=0;return n=window.requestAnimationFrame(()=>r=window.requestAnimationFrame(t)),()=>{window.cancelAnimationFrame(n),window.cancelAnimationFrame(r)}},[t])}function oO(e){return e.nodeType===e.ELEMENT_NODE}function iO(e){const t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:r=>{const i=r.tagName==="INPUT"&&r.type==="hidden";return r.disabled||r.hidden||i?NodeFilter.FILTER_SKIP:r.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function kh(e){const t=document.activeElement;return e.some(n=>n===t?!0:(n.focus(),document.activeElement!==t))}var sO=q5,aO=Q5,lO=G5,cO=X5,dO=J5,uO=e4,pO=I0;const fO=4;function hO(e,t,n=fO){const r=[...e,t];return r.length>n?r.slice(r.length-n):r}function gO(e,t){return e.filter(n=>n.id!==t)}const xO={running:"border-l-pill-running-fg",waiting:"border-l-pill-waiting-fg",done:"border-l-pill-done-fg",failed:"border-l-pill-failed-fg",cancelled:"border-l-pill-cancelled-fg"},mO="relative flex flex-col gap-0.5g rounded-card border border-card border-l-4 bg-surface-card p-2g pr-4g shadow-overlay data-[state=open]:animate-toast-in data-[state=closed]:animate-toast-out data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=cancel]:translate-x-0 data-[swipe=end]:animate-toast-out motion-reduce:animate-none",M0=p.createContext(null);function vO({children:e}){const[t,n]=p.useState([]),r=p.useRef(0),i=p.useCallback(l=>{n(c=>gO(c,l))},[]),s=p.useCallback(l=>{const c=`toast-${r.current++}`,d={id:c,title:l.title,description:l.description,tone:l.tone??"running",duration:l.duration??5e3,actions:l.actions};return n(u=>hO(u,d)),c},[]),a=p.useMemo(()=>({toast:s,dismiss:i}),[s,i]);return o.jsx(M0.Provider,{value:a,children:o.jsxs(sO,{swipeDirection:"right",children:[e,t.map(l=>o.jsxs(lO,{duration:l.duration,onOpenChange:c=>{c||i(l.id)},className:[mO,xO[l.tone]].join(" "),children:[o.jsx(cO,{className:"text-ui font-medium text-state-ink",children:l.title}),l.description?o.jsx(dO,{className:"text-ui text-state-ink/70",children:l.description}):null,l.actions&&l.actions.length>0?o.jsx("div",{className:"mt-1g flex flex-wrap gap-1g",children:l.actions.map((c,d)=>o.jsx(uO,{altText:c.altText??c.label,asChild:!0,children:o.jsx("button",{type:"button",onClick:c.onClick,className:"rounded-card border border-card bg-surface-canvas-alt px-1.5g py-0.5g text-ui text-state-ink transition-colors hover:bg-surface-card focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-state-run/40",children:c.label})},d))}):null,o.jsx(pO,{"aria-label":"Dismiss",className:"absolute right-1g top-1g rounded-card p-0.5g text-ui text-state-ink/50 transition-colors hover:bg-surface-canvas-alt hover:text-state-ink focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-state-run/40",children:"✕"})]},l.id)),o.jsx(aO,{className:"fixed bottom-0 right-0 z-50 m-2g flex w-[24rem] max-w-[calc(100vw-2rem)] flex-col gap-1g outline-none"})]})})}function dr(){const e=p.useContext(M0);if(!e)throw new Error("useToast must be used within a ToastProvider");return e}function yO(){return p.useContext(M0)}const bO={newSession:"New session",settings:"Settings",threads:"Threads",tasks:"Tasks",machines:"Machines",today:"Today",active:"Active",recentDay:"Last 1 day",history:"History",open:"Open",pause:"Pause",resume:"Resume",cancel:"Cancel",approve:"Approve",deny:"Deny",stop:"Stop",commands:"commands",composerPh:"Message Cortex — type / for commands",adjustBudget:"Adjust budget",approvals:"Approvals",cmdkPh:"Jump to session / thread / task / file…",openOverview:"Open project overview",switchProject:"SWITCH PROJECT",newProject:"New project",synced:"synced 2s ago",emptyHistory:"No finished threads yet in this demo — cancel or commit one.",approvalPending:"approval pending",approvalsPending:"approvals pending",autoAttached:"auto-attached",tuiDesc:"adds a local terminal gateway on top of the platforms",warnNote:"one warning to the admin channel",obNote:"checked against the estimate before dispatch",default:"default",month:"this month",obExample:"Over-estimate → approval card in chat & approval center (e.g. APR-0007)",mHeartbeat:"heartbeat",mRecover:"recovery",mFirewall:"strict firewall",tplList:"Templates",mcpCore:"cross-machine execution surface",mcpSlack:"Slack conversation tools — enabled with CORTEX_PLATFORM",mcpFoot:"core variant keeps only remote_* tools; tui variant serves terminal-gateway sessions",hkAuto:"dispatch auto-adds",hkBridge:"Blocking interactions (questions / plan approvals) surface as chat messages via the hook-bridge (30-min TTL); the PI backend reuses the same scripts through a bridge.",advConc:"Task dispatch concurrency",advConcNote:"hot-read from settings.json",advMock:"test-only mock JSON, overrides nvidia-smi",aprEmptyTitle:"All clear",aprEmptyDesc:"New approvals appear here and as cards in chat",issuesTitle:"Issues",issuesStat:"issues",isListLabel:"ISSUES",isRecorded:"recorded",isEmptyTitle:"No issues",isEmptyDesc:"Issues agents register during runs appear here",isNoStatusNote:"No status column — listed = pending; handle / delete to leave",isFootNote:"Handle → new session carrying the issue full text, then removed. Delete → removed. Both land in the events log",isDescLabel:"Description",isDelete:"Delete",isConfirmDelete:"Confirm delete",isHandle:"Handle",isViewAll:"View all",isToastHandled:"Session created for this issue",isToastDeleted:"Issue deleted",whyApproval:"Why approval",rejectFeedback:"Reject — feedback",denyConfirm:"Confirm reject",rename:"Rename",delete:"Delete",profNote:"read on every spawn",pillRunning:"Running",pillGated:"Gated",pillPaused:"Paused",pillWaiting:"Waiting",pillBackground:"Background",pillDone:"Done",pillFailed:"Failed",pillCancelled:"Cancelled",sessions:"Sessions",workbench:"Workbench",overview:"Overview",back:"Back",search:"Search",more:"More",project:"Project",toProcess:"to process",weekProcessed:"Processed this week",slackSynced:"Slack sync available",toolCallsUnit:"tool calls",toolCallUnit:"tool call",needsApproval:"Approval required",subthreads:"subthreads",dayToday:"Today",dayYesterday:"Yesterday",mExecutable:"Executable",mAll:"All",mInProgress:"In progress",mClaimable:"Claimable",mWaitingDeps:"Waiting",mBlocked:"Blocked",mDoneWhen:"DONE WHEN",mDoneWhenGap:"Done-when detail not available here yet",mUnblock:"Unblock",mClaim:"Claimed",mDependsOn:"needs",mAutoUnlock:"auto-unlocks",mBlockedPill:"Blocked",mNoTasks:"No tasks",step:"step",depth:"depth",pendingApproval:"Pending",budgetPerDay:"budget",perDay:"/day",thisWeek:"this week",forecastToday:"forecast today",projectMemory:"Project memory",viewAll:"All",scheduleCard:"Schedules",newSchedule:"New",execFlow:"Executions",paused:"Paused",execCountUnit:"today",mOnline:"online",mOffline:"offline",mNoMachines:"No machines configured",mLiveRuns:"live",mGpu:"GPU",wbToday:"today",wbDaemon:"daemon",connConnected:"connected",connConnecting:"connecting",connReconnecting:"reconnecting",connDisconnected:"disconnected",wbProfile:"profile",wbIdle:"idle",wbSwitchTo:"Switch to",wbNeedsNewSession:"needs a new session (this conversation runs on a different backend)",wbEscToStop:"esc to stop",wbNewConversation:"New conversation",wbSend:"send",wbSendFailed:"Send failed",wbDraftRestored:"message restored",wbNewline:"newline",wbNavigate:"navigate",wbRun:"run",wbEscDismiss:"esc dismiss",wbTurnsUnit:"turns",wbEmptyTitle:"Start with one message",wbEmptyBody:"This project is empty. Just chat — describe the mission and the agent runs project_init (mission.md · TASKS.yaml · memory scaffold · git).",wbEmptyHint:"Everything else — tasks, threads, cross-machine runs — starts from this chat",wbDebugInspect:"Inspect DEBUG data",wbDebugAgentMessage:"AGENT MESSAGE",wbDebugParameters:"PARAMETERS",wbDebugResult:"RESULT",wbDebugCharacters:"CHARACTERS",wbDebugSuccess:"SUCCESS",wbDebugError:"ERROR",wbDebugPending:"PENDING",wbAttach:"+ attach",wbAttachPlaceholder:"Add a message or drop more files",wbAttachHint:"paste or drop files",wbDropFilesSingular:"Drop file to attach",wbDropFilesPlural:"Drop {n} files to attach",wbAttachPath:"→ workspace/attachments/",wbFileDownload:"Download",wbFileCopyPath:"Copy path",wbFileOpen:"open",wbFileDownloadAll:"download all",wbFileFiles:"files",wbFileDownloadDone:"Download complete",wbFileDownloadFailed:"Download failed",wbFileSavedTo:"Saved to {path}",wbFileOpenFile:"Open file",wbFileOpenFolder:"Open folder",wbDragOverCount:"{n} → {m} attachments",wbDropAddMore:"Drop to add more",wbDropAddMoreN:"Drop to add {n} more",wbSessionToday:"TODAY",wbSessionYesterday:"YESTERDAY",wbSessionEarlier:"EARLIER",wbFromSchedule:"from schedule",wbProjects:"PROJECTS",wbSessions:"SESSIONS",wbNewShort:"New",wbCost:"Cost",wbSessionId:"Session ID",wbCortexId:"Cortex ID",wbBackendUuid:"Backend UUID",wbCopy:"Copy",wbCopied:"Copied",dmDaemon:"Daemon status",dmEsc:"esc",dmUp:"up",dmPid:"pid",dmPort:"port",dmLastRestart:"last restart",dmReason:"reason",dmSoftRestart:"Soft restart",dmSoftRestartDesc:"Drain and restart when idle — running agents are not interrupted",dmHardRestart:"Hard restart",dmHardRestartDesc:"Terminate all processes immediately and restart — running agents will be interrupted",dmHardConfirm:"Hard restart — confirm",dmHardConfirmDetail:"This will immediately kill all running agents. Active threads and sessions will be lost.",dmConfirmCancel:"Cancel",dmConfirmProceed:"Hard restart",dmRestartSent:"Restart signal sent",dmRestartFailed:"Restart failed",dmDisconnect:"Disconnect",dmDisconnectDesc:"Clear the saved server & token and return to the login screen",rpNoActiveThreads:"No active threads",rpNoActiveThreadsHint:"Running and waiting threads will appear here.",rpNoRecentThreads:"No threads finished in the last day.",rpNoFinishedThreads:"No finished threads yet.",rpOpen:"Open",rpStep:"step",rpDepth:"depth",rpLoadingThread:"Loading thread…",rpFailedLoadThread:"Failed to load thread.",rpNoMachinesHint:"Connected machines (atlas, nimbus…) appear here once registered in machines.json.",rpLoadingMachines:"Loading machines…",rpFailedLoadMachines:"Failed to load machines.",tkNone:"None",tkLoading:"Loading tasks…",tkLoadFailed:"Failed to load tasks",tkDone:"Done",tkPriHigh:"high",tkPriMed:"medium",tkPriLow:"low",tkOpen:"Open",tkActionable:"Actionable",tkAll:"All",tkInProgress:"In progress",tkApprovalNeeded:"Approval needed",tkWaitingDeps:"Waiting",tkWhy:"WHY",tkNoWhy:"no `why` recorded on this task",tkDoneWhen:"DONE-WHEN",tkNoDoneWhen:"no done-when recorded on this task",tkDispatchHistory:"Dispatch history",tkLoadingDispatch:"loading dispatch history…",tkDispatchFailed:"failed to load dispatch history",tkNoDispatches:"no dispatches recorded for this task",tkFields:"Fields",tkDependencies:"Dependencies",tkNoDependencies:"No dependencies",ovLast14Days:"Last 14 days",ovAvg:"avg",ovGitBacked:"git-backed",ovOpenMemoryViewer:"Open memory viewer",ovMemoryDesc:"Mission · roadmap · STATUS · TASKS + experiments / knowledge / patterns / decisions.",ovWhereItGoes:"Where it goes",ovNoSpend:"No spend recorded this week.",ovNoSchedules:"No schedules for this project.",ovExecSubtitle:"every cortex-run, auditable",ovColId:"ID",ovColSummary:"SUMMARY",ovColMachine:"MACHINE",ovColDur:"DUR",ovColCost:"COST",ovColStatus:"STATUS",ovNoExecutions:"No executions for this project.",ovLogs:"Logs",stConfigured:"configured",stNotConfigured:"not configured",stReconnect:"Reconnect",stMessagingPlatforms:"Messaging platforms",stTuiGateway:"TUI gateway",stApi:"API",stDaemonNetwork:"Daemon & network",stDefaultProfile:"default profile",stProfReadNote:"read at every agent start — no restart",stColName:"NAME",stColModel:"MODEL",stColBackend:"BACKEND",stColMode:"MODE",stColThinking:"THINKING",stNoProfiles:"No profiles in profiles.json",stColCortexPath:"CORTEX PATH",stColSsh:"SSH",stColOs:"OS",stNoMachinesFile:"No machines in machines.json",stMachineLocal:"— local",stLogs:"Logs",stAddMachine:"+ Add machine",stClientLifecycle:"Client lifecycle",stConnectivity:"Connectivity",stMachinesFootNote:"SSH is a presence flag only (the raw user@host is never returned). Live CLIENT version / STATUS / heartbeat are runtime state the config.get contract does not carry — omitted rather than fabricated. The two cards above are static architecture notes.",stEntry:"entry",stEntries:"entries",stOpenEditor:"Open editor ↗",stColKind:"KIND",stColDescription:"DESCRIPTION",stColKeys:"KEYS",stNoTemplates:"No templates in thread-templates/",stTemplatesFootNote1:"Real content from thread-templates/. KEYS = top-level body keys. Template body shown as-read; no fabricated structure.",stGrpTemplates:"templates",stGrpAgents:"agents",stGrpShells:"shells",stNone:"none",stTemplatesFootNote2:"Names are the real thread-templates/ basenames. Per-template step chips / hook bindings are not in the config.get contract (no fabricated metadata).",stServers:"Servers",stNoServers:"No servers in mcp-config.json",stMcpFootNote:"core variant keeps only remote_* tools; tui variant serves terminal-gateway sessions. Per-server tool lists are not in the config.get contract (server names are the real mcp-config.json keys).",stNotifyTurnTitle:"Post a new message after a long task finishes",stNotifyTurnDesc:"Stay quiet on short turns · current threshold",stNotifyResumeTitle:"Auto-resume and notify after the rate-limit window resets",stNotifyResumeDesc:"Interrupted sessions and threads pick up automatically",stNotifyCompactionTitle:"Context compaction notice",stNotifyCompactionDesc:"Post a note in the conversation when compaction happens",stNotifyRoutingTitle:"System notification routing",stNotifyRoutingRight:"fanned out to each platform",stApprovalReminderNote:"Approval reminders are always on — re-reminds every 30 min while a thread is blocked",stRecentNotifications:"Recent notifications",stRecentNotifRight:"runtime only · no history scope",stRecentNotifNote:"Notification activity is held in the TUI client's in-memory ring buffer (cap 50, no file persistence) — not exposed via any tRPC read scope. Real-time history is not available in the web UI; use the TUI terminal interface to view live notifications.",stAgentHooks:"Mounted hooks",stNoHooks:"No mounted hooks",stHookEnabled:"Enabled",stHookDisabled:"Disabled",stHooksFootNote:"Mounted state comes from config/hooks declarations and thread-template lifecycle hooks, using the same source classification as cortex-hook list.",hkFilterAll:"All",hkFilterAgent:"Agent",hkFilterClaude:"Claude",hkFilterPi:"PI",hkFilterServer:"Server",hkFilterTemplate:"Template",hkSearchPh:"Search id, event, script…",hkNoMatch:"No hook matches this filter",hkSelectHint:"Select a hook to read its declaration",hkLoading:"Loading hooks…",hkLoadFailed:"Failed to load hooks:",hkCreate:"New hook",hkSecTrigger:"Trigger",hkSecAction:"Action",hkSecScope:"Scope",hkSecAdvanced:"Advanced",hkSecDeclaration:"Declaration",hkSecRegistry:"Registry",hkOrderNote:"order = run order within one event",hkFieldId:"id",hkFieldEvent:"event",hkFieldMatcher:"matcher",hkFieldFilters:"filters",hkFieldRun:"run",hkFieldTemplate:"template",hkFieldScript:"script",hkFieldCommand:"command",hkFieldTimeout:"timeout",hkFieldBackends:"backends",hkFieldRequiresTool:"requires tool",hkFieldResult:"result",hkFieldSource:"source",hkFieldFile:"file",hkFieldOrder:"order",hkFieldBlocking:"blocking",hkFieldVersion:"version",hkFieldMountsOn:"mounts on",hkFieldAppliesAt:"applies at",hkSeconds:"seconds",hkUnscoped:"both — derived from the event prefix",hkNoMatcher:"empty — matches everything",hkMatcherRegexHint:"Regular expression tested against the tool name",hkMatcherFiltersHint:"Every key must be present in the payload with exactly this value",hkMatcherInvalid:"Invalid regular expression",hkAddFilter:"Add filter",hkRemoveFilter:"Remove",hkFilterKeyPh:"key",hkFilterValuePh:"value",hkResultLocked:"This event cannot return a result — the loader only accepts none.",hkAppliesNextAgent:"Takes effect on the next agent spawn.",hkAppliesRestart:"The event bus snapshots the registry at startup — this takes effect after a server restart.",hkNoteManaged:"Managed entry, shipped with Cortex. Only the enabled switch is writable here, and a future hook sync will restore the shipped enabled state.",hkNoteTemplate:"Owned by a thread template file. Edit it in the Thread templates section — this panel keeps it read-only.",hkClaudeGap:"No Claude mount point for this agent:* event — it reaches PI only. To hook Claude, declare it natively as:",hkScriptMissing:"Script not found in the hooks directory — this hook fails silently.",hkBroken:"broken",hkDirty:"Unsaved changes",hkSave:"Save",hkRevert:"Revert",hkDelete:"Delete",hkConfirmDelete:"Confirm delete",hkCancelCreate:"Discard",hkTest:"Test",hkTestTitle:"Test run",hkTestPayload:"Payload — JSON delivered on stdin",hkTestRun:"Run",hkTestClose:"Close",hkTestReset:"Reset to sample",hkTestNoOutput:"no output",hkTestBlockingWarn:"This hook blocks on a webhook round trip and posts a card to the message platform. The test run is capped at 15s, but it can park for that whole cap.",hkPayloadInvalid:"Payload is not valid JSON",hkErrIdRequired:"An id is required",hkErrIdTaken:"That id is already claimed by another declaration",hkErrEventRequired:"An event is required",hkErrRunRequired:"Exactly one of script or command is required",hkErrTimeout:"Timeout must be a positive number of seconds",hkErrFiltersEmptyKey:"Filter keys cannot be empty",hkErrFiltersDuplicate:"Filter keys must be unique",hkErrResult:"That result mode is not legal for this event",hkToastSaved:"Hook saved",hkToastCreated:"Hook created",hkToastDeleted:"Hook deleted",hkToastEnabled:"Hook enabled",hkToastDisabled:"Hook disabled",hkToastWriteFailed:"Hook write failed",hkToastTestFailed:"Test run failed",stAdvConcNote:"auto = max(4, cpus − 2) · hot-read from settings.json",stSet:"set",stAuto:"auto",stGpuMock:"GPU mock",stLoadingConfig:"Loading config…",stFailedLoadConfig:"Failed to load config:",stPolicyPauseTitle:"Pause & request approval",stPolicyPauseDesc:"over-estimate → approval (class: over-budget compute); continues once approved",stPolicyWarnTitle:"Warn only, keep going",stPolicyWarnDesc:"posts a warning to the admin channel, never blocks",stPolicyStopTitle:"Hard stop",stPolicyStopDesc:"no new dispatches today; running work unaffected",stLimits:"Limits",stDaily:"DAILY",stWarnAt:"WARN AT",stOverBudgetBehavior:"Over-budget behavior",stCurrentSpend:"Current spend",stObNote:"Over-estimate → approval card in chat & approval center",stBudgetFootNote:"today / month are real (cost.summary); the daily/monthly denominators are real (budget.json). Forecast is not in the contract — omitted.",stNavAppearance:"Appearance",stNavPlatform:"Platform",stNavAccounts:"Accounts",stNavProfiles:"Profiles",stNavBudget:"Budget",stNavMachines:"Machines",stNavTemplates:"Thread templates",stNavMcp:"MCP servers",stNavNotifications:"Notifications",stNavHooks:"Hooks",stNavAdvanced:"Advanced",stMetaAppearanceSub:"Language & theme — interface language and light/dark. Applies instantly and is remembered on this device.",stMetaPlatformSub:"config/.env — loaded once at daemon startup; the only restart-required config",stMetaAccountsSub:"Claude Code credentials and every PI provider reported by auth.status",stMetaProfilesSub:"config/profiles.json — read on every agent spawn, no restart needed",stMetaBudgetSub:"config/budget.json — hot-read, applies immediately; upgrades never overwrite (only --force)",stMetaMachinesSub:"config/machines.json — fs.watch hot-reload; clients auto-launched over SSH at startup",stMetaTemplatesSub:"config/thread-templates.json — read fresh on every thread launch",stMetaMcpSub:"config/mcp-config.json — full / core / tui variants picked per runtime mode",stMetaNotificationsSub:"config/settings.json — live notification controls and per-platform routing",stMetaHooksSub:"mounted registry and template-scoped hooks — current event, enabled state, and source",stMetaAdvancedSub:"runtime flags in settings.json; DEBUG remains read-only from the process environment",stThemeLabel:"Theme",stThemeLight:"Light",stThemeDark:"Dark",stThemeHint:"Colors follow the Cortex design system in both modes; the choice is saved on this device.",stLangLabel:"Language",stLangHint:"Interface language for the workbench. Applies instantly and is saved on this device.",stLangEnglish:"English",stLangChinese:"中文",stBudgetWriteError:"Cannot write budget — monthly_usd must be set (positive) in budget.json first",stCostsJsonlLabel:"costs.jsonl · 90d",stEsc:"esc",stWinOs:"windows",stUnixOs:"unix",stAddMachinePrompt:"Machine name to request (queued for approval, not added directly):",stMachineFieldsHint:"name · cortexPath · gpuCount · ssh · win · clientCommand",stToastQueuedApproval:"Queued for approval — review in the Approval Center",stToastWriteFailed:"Write failed",stToastCouldNotQueue:"Could not queue request",stToastBudgetWritten:"budget.json written",stToastDefaultProfile:"profiles.json written",stReconnectApprovalTitle:"Queues a reconnect request for approval — never runs directly from the browser",stReconnectInertTitle:"No reconnect backend op — inert",stAddMachineApprovalTitle:"Queues an add-machine request for approval — never writes machines.json directly",stAddMachineInertTitle:"Writes machines.json — no add-machine backend op (form out of scope)",stTemplateEditorInertTitle:"Template editor out of scope — inert",stAdvDebugTitle:"Debug logging",stAdvDebugDesc:"verbose output to daemon.log",stAdvEventLogTitle:"Event-bus log",stAdvEventLogDesc:"records every event-bus message",stAdvDiskMonitorTitle:"Disk-space monitor",stAdvDiskMonitorDesc:"checks the Cortex data filesystem and warns below 500 MB",stAdvToolCallsTitle:"Inline tool-call rendering",stAdvToolCallsDesc:"renders tool calls in message tails",stAdvDisableUserTitle:"Disable USER.md injection",stAdvDisableUserDesc:"direct turns inject by default; thread steps never do",stAdvDisableUpdateTitle:"Disable auto-update check",stAdvDisableUpdateDesc:"update check is on by default",npProjectName:"PROJECT NAME",npHint:"Becomes context/projects/<name>/ — the agent handles everything else",npCreate:"Create →",cpNoResults:"No results.",cpFooterHint:"↑↓ navigate · ⏎ open · esc dismiss",cpSubOverview:"project dashboard",cpSubWorkbench:"session chat",cpSubTasks:"task queue",cpSubThreads:"thread runs",cpSubSettings:"platform · profiles · budget · machines…",skTitle:"Skills",skScanning:"Scanning…",skLoadError:"Could not load skills",skLoadingBody:"Loading skills…",skFailedBody:"Failed to load skills. Is agent-server running?",skEmpty:"No skills found. Add skill directories under DATA_DIR/.claude/skills/ or plugins/.",skUserSkills:"user skills",shNothingHere:"Nothing here yet",apPending:"PENDING",apFrom:"from",apTask:"task",apProject:"project",apOperation:"OPERATION",apReason:"REASON",apImpact:"IMPACT",apCommand:"COMMAND",apFeedbackLabel:"Feedback",apFeedbackPh:"Reason — sent back to the agent…",apFootNote:"On decision → PENDING_APPROVALS.md flips · the chat card stays in sync",apToastApproved:"Approved — PENDING_APPROVALS.md updated",apToastRejected:"Rejected — reason sent back to the agent",scNewSchedule:"New schedule",scType:"TYPE",scTypeInterval:"interval",scTypeDaily:"daily",scTypeWeekly:"weekly",scTypeOnce:"once",scTime:"TIME",scEvery:"EVERY",scIn:"IN",scDay:"DAY",scProfile:"PROFILE",scMessage:"MESSAGE",scMessagePh:"Check GPU status on all machines and post a one-line summary.",scTarget:"TARGET",scFallback:"FALLBACK",scNextRun:"next run",scFooterIn:"in",scCreateSchedule:"Create schedule",scDaySun:"Sun",scDayMon:"Mon",scDayTue:"Tue",scDayWed:"Wed",scDayThu:"Thu",scDayFri:"Fri",scDaySat:"Sat",scToastCreated:"Schedule created",scToastCreateFailed:"Could not create schedule",memMemory:"Memory",memLoading:"Loading…",memNoFiles:"No memory files.",memDiffUnavailable:"diff metadata unavailable",memLinesChanged:"lines changed vs HEAD (git numstat).",memBlameNote:"Each line below is annotated with its real last-touch commit hash and task ref (git blame); a task ref is blank when that commit carries no task tag.",memBlameUnavailable:"Per-line blame is unavailable — this project directory is not a git work tree (or git is unavailable), so commit hashes / task refs are not shown. The file below is the current content.",memLoadingFile:"Loading file…",memReadError:"Could not read this file.",memSelectFile:"Select a file to view.",memSummary:"summary",thArtifact:"THREAD ARTIFACT",thLive:"live",thNoArtifact:"No artifact",thOwner:"owner",thReferences:"REFERENCES",thWrittenBy:"WRITTEN BY",thWorkspace:"workspace",thTask:"task",thProject:"project",thFailedLoadThread:"Failed to load thread",thTemplate:"template",thStarted:"started",thElapsed:"elapsed",thCostInclChildren:"cost incl. children",thPipeline:"PIPELINE",thOpenSub:"open",thAgentLabel:"agent",thAgentSection:"AGENT",thSubThreads:"SUB-THREADS",thStepNoSession:"not started — no session yet",thStepLoading:"loading transcript…",thStepEmpty:"no messages yet",exLogTitle:"Execution log",exAlreadyFinished:"already finished",exKilled:"killed",exWaitingOutput:"waiting for output…",exNoLiveLog:"no live log — this execution is not a cortex-run launch",exNoLogOutput:"no log output",exLinesDropped:"lines dropped",exFooterHeartbeat:"heartbeat 30s · missed 0 · → costs.jsonl",exKillRun:"Kill run",authLoginTitle:"Backend login",authLoginIntro:"Choose a backend, provider, and authentication type.",authLoginBackend:"Backend",authLoginType:"Authentication type",authLoginApiKey:"API key",authLoginOAuth:"OAuth",authLoginSubscription:"Subscription (OAuth)",authLoginProvider:"Provider",authLoginStart:"Start login",authLoginAgain:"Log in again",authLoginSubmit:"Submit",authLoginClose:"Close",authLoginRunning:"Starting login…",authLoginSecretPrompt:"Enter the API key. It will not be stored in chat or transcripts.",authLoginOpenLink:"Open link",authLoginOpenAuthorization:"Open authorization page",authLoginOpenVerification:"Open verification page",authLoginExpiresIn:"Expires in {seconds} seconds.",authLoginDone:"Login complete",authLoginDoneSummary:"Logged in to {provider}.",authLoginFailed:"Login failed",authLoginUnknownFailure:"The login flow failed.",authLoginExpired:"This login flow expired or is no longer available.",authLoginAlreadyActive:"A login flow is already active on another surface.",authLoginCancelled:"Login cancelled",authLoginCancelledSummary:"No credential was submitted.",accountsTitle:"Accounts",accountsSource:"Source",accountsExpires:"Expires",accountsInUse:"In use",accountsPiProviders:"PI providers",accountsLogin:"Log in",accountsLogout:"Log out",accountsFilter:"Filter providers",accountsFilterPlaceholder:"Filter by provider name…",accountsNoProviders:"No providers match this filter.",accountsStatusLoggedIn:"Logged in",accountsStatusExpiring:"Expiring soon",accountsStatusLoggedOut:"Not logged in",accountsStatusInvalid:"Invalid",accountsGroupInUse:"In use",accountsGroupLoggedIn:"Logged in",accountsGroupOther:"Other",accountsConnectedMark:"✓",accountsDisconnected:"not logged in",accountsPiSummary:"PI logged in {count}",accountsLoading:"Loading accounts…",accountsLoadFailed:"Could not load account status.",accountsLogoutDone:"Logged out",accountsLogoutFailed:"Logout failed"},jO={newSession:"新会话",settings:"设置",threads:"线程",tasks:"任务",machines:"机器",today:"今日",active:"活跃",recentDay:"近 1 天",history:"历史",open:"打开",pause:"暂停",resume:"恢复",cancel:"取消",approve:"批准",deny:"拒绝",stop:"停止",commands:"命令",composerPh:"输入消息,/ 调用命令",adjustBudget:"调整预算",approvals:"审批",cmdkPh:"跳转到会话 / 线程 / 任务 / 文件…",openOverview:"打开项目 Overview",switchProject:"切换项目",newProject:"新建项目",synced:"2 秒前同步",emptyHistory:"演示里还没有已结束的线程——试试取消或提交一个。",approvalPending:"项待审批",approvalsPending:"项待审批",autoAttached:"自动附带",tuiDesc:"在消息平台之上附加本机终端入口",warnNote:"到线向 admin 频道发一次警告",obNote:"dispatch 前按预估成本判定",default:"默认",month:"本月",obExample:"预估超限 → chat 审批卡 + 审批中心(如 APR-0007)",mHeartbeat:"心跳",mRecover:"断连恢复",mFirewall:"严格防火墙",tplList:"模板",mcpCore:"跨机执行入口",mcpSlack:"Slack 会话工具 — 随 CORTEX_PLATFORM 启用",mcpFoot:"core 变体仅保留 remote_* 工具;tui 变体供终端网关会话使用",hkAuto:"dispatch 自动追加",hkBridge:"阻塞式交互(提问 / 计划审批)经 hook-bridge 变成 chat 里的交互消息(30 分钟 TTL);PI 后端通过桥复用同一批脚本。",advConc:"任务派发并发上限",advConcNote:"从 settings.json 热读取",advMock:"测试用 mock JSON,覆盖真实 nvidia-smi",aprEmptyTitle:"队列已清空",aprEmptyDesc:"新审批会出现在这里,并同步为 chat 里的审批卡",issuesTitle:"Issues",issuesStat:"issues",isListLabel:"ISSUES",isRecorded:"记录于",isEmptyTitle:"没有 issue",isEmptyDesc:"agent 运行中登记的 issue 会出现在这里",isNoStatusNote:"无状态列 — 在列表即待处理;处理 / 删除 即离场",isFootNote:"处理 → 新建会话携带 issue 全文,处理后移除;删除 → 直接移除 · 两者均落 events log",isDescLabel:"描述",isDelete:"删除",isConfirmDelete:"确认删除",isHandle:"处理",isViewAll:"查看全部",isToastHandled:"已创建处理会话",isToastDeleted:"已删除 issue",whyApproval:"为什么需要审批",rejectFeedback:"拒绝并反馈",denyConfirm:"确认拒绝",rename:"重命名",delete:"删除",profNote:"每次启动现读",pillRunning:"运行中",pillGated:"等审批",pillPaused:"已暂停",pillWaiting:"等待中",pillBackground:"后台运行",pillDone:"完成",pillFailed:"失败",pillCancelled:"已取消",sessions:"会话",workbench:"工作台",overview:"概览",back:"返回",search:"搜索",more:"更多",project:"项目",toProcess:"待处理",weekProcessed:"本周已处理",slackSynced:"Slack 同步可用",toolCallsUnit:"次工具调用",toolCallUnit:"次工具调用",needsApproval:"需要审批",subthreads:"子线程",dayToday:"今天",dayYesterday:"昨天",mExecutable:"可执行",mAll:"全部",mInProgress:"进行中",mClaimable:"可认领",mWaitingDeps:"等依赖",mBlocked:"已阻塞",mDoneWhen:"完成标准(DONE WHEN)",mDoneWhenGap:"done-when 明细暂无法在此展示",mUnblock:"解除",mClaim:"认领",mDependsOn:"依赖",mAutoUnlock:"自动解锁",mBlockedPill:"阻塞",mNoTasks:"暂无任务",step:"步骤",depth:"深度",pendingApproval:"待审批",budgetPerDay:"预算",perDay:"/日",thisWeek:"本周",forecastToday:"预测今日",projectMemory:"项目记忆",viewAll:"全部",scheduleCard:"调度",newSchedule:"新建",execFlow:"执行流水",paused:"已暂停",execCountUnit:"今日",mOnline:"在线",mOffline:"离线",mNoMachines:"暂无机器",mLiveRuns:"运行",mGpu:"GPU",wbToday:"今日",wbDaemon:"守护进程",connConnected:"已连接",connConnecting:"连接中",connReconnecting:"正在重连",connDisconnected:"已断开",wbProfile:"配置",wbIdle:"空闲",wbSwitchTo:"切换到",wbNeedsNewSession:"需要新建会话(当前对话运行在不同的后端上)",wbEscToStop:"esc 停止",wbNewConversation:"新对话",wbSend:"发送",wbSendFailed:"发送失败",wbDraftRestored:"消息已恢复",wbNewline:"换行",wbNavigate:"导航",wbRun:"执行",wbEscDismiss:"esc 关闭",wbTurnsUnit:"轮",wbEmptyTitle:"从一条消息开始",wbEmptyBody:"这个项目还是空的。直接聊——描述目标,agent 会运行 project_init(mission.md · TASKS.yaml · 记忆脚手架 · git)。",wbEmptyHint:"其余的一切——任务、线程、跨机运行——都从这个对话开始",wbDebugInspect:"查看 DEBUG 数据",wbDebugAgentMessage:"实际 AGENT 消息",wbDebugParameters:"完整参数",wbDebugResult:"完整结果",wbDebugCharacters:"字符",wbDebugSuccess:"成功",wbDebugError:"错误",wbDebugPending:"等待中",wbAttach:"+ 附件",wbAttachPlaceholder:"输入消息或拖入更多文件",wbAttachHint:"粘贴或拖入文件",wbDropFilesSingular:"拖入文件以添加附件",wbDropFilesPlural:"拖入 {n} 个文件以添加附件",wbAttachPath:"→ workspace/attachments/",wbFileDownload:"下载",wbFileCopyPath:"复制路径",wbFileOpen:"打开",wbFileDownloadAll:"全部下载",wbFileFiles:"个文件",wbFileDownloadDone:"下载完成",wbFileDownloadFailed:"下载失败",wbFileSavedTo:"已保存到 {path}",wbFileOpenFile:"打开文件",wbFileOpenFolder:"打开文件夹",wbDragOverCount:"{n} → {m} 个附件",wbDropAddMore:"拖入以添加更多",wbDropAddMoreN:"拖入以添加 {n} 个更多",wbSessionToday:"今天",wbSessionYesterday:"昨天",wbSessionEarlier:"更早",wbFromSchedule:"来自调度",wbProjects:"项目",wbSessions:"会话",wbNewShort:"新建",wbCost:"成本",wbSessionId:"会话 ID",wbCortexId:"Cortex ID",wbBackendUuid:"后端 UUID",wbCopy:"复制",wbCopied:"已复制",dmDaemon:"守护进程状态",dmEsc:"esc",dmUp:"运行",dmPid:"pid",dmPort:"端口",dmLastRestart:"上次重启",dmReason:"原因",dmSoftRestart:"软重启",dmSoftRestartDesc:"等待空闲时重启,运行中的 Agent 不中断",dmHardRestart:"硬重启",dmHardRestartDesc:"立即终止全部进程再拉起,运行中的 Agent 会被打断",dmHardConfirm:"硬重启 — 确认",dmHardConfirmDetail:"这将立即终止所有运行中的 Agent。活跃的线程和会话将会丢失。",dmConfirmCancel:"取消",dmConfirmProceed:"硬重启",dmRestartSent:"重启信号已发送",dmRestartFailed:"重启失败",dmDisconnect:"断开连接",dmDisconnectDesc:"清除已保存的服务器与令牌,返回登录页",rpNoActiveThreads:"暂无活跃线程",rpNoActiveThreadsHint:"运行中和等待中的线程将显示在此处。",rpNoRecentThreads:"近 1 天没有结束的线程。",rpNoFinishedThreads:"暂无已完成的线程。",rpOpen:"打开",rpStep:"步骤",rpDepth:"深度",rpLoadingThread:"正在加载线程…",rpFailedLoadThread:"加载线程失败。",rpNoMachinesHint:"已连接的机器(atlas、nimbus…)在 machines.json 中注册后将显示在此处。",rpLoadingMachines:"正在加载机器…",rpFailedLoadMachines:"加载机器失败。",tkNone:"无",tkLoading:"正在加载任务…",tkLoadFailed:"加载任务失败",tkDone:"已完成",tkPriHigh:"高",tkPriMed:"中",tkPriLow:"低",tkOpen:"未完成",tkActionable:"可执行",tkAll:"全部",tkInProgress:"进行中",tkApprovalNeeded:"需要审批",tkWaitingDeps:"等待",tkWhy:"为什么",tkNoWhy:"该任务未记录 `why`",tkDoneWhen:"完成标准",tkNoDoneWhen:"该任务未记录完成标准",tkDispatchHistory:"派发历史",tkLoadingDispatch:"正在加载派发历史…",tkDispatchFailed:"加载派发历史失败",tkNoDispatches:"该任务未记录派发",tkFields:"字段",tkDependencies:"依赖",tkNoDependencies:"无依赖",ovLast14Days:"最近 14 天",ovAvg:"平均",ovGitBacked:"Git 托管",ovOpenMemoryViewer:"打开记忆查看器",ovMemoryDesc:"使命 · 路线图 · STATUS · TASKS + 实验 / 知识 / 模式 / 决策",ovWhereItGoes:"花在哪里",ovNoSpend:"本周暂无支出记录",ovNoSchedules:"本项目暂无调度",ovExecSubtitle:"每次 cortex-run 均可审计",ovColId:"ID",ovColSummary:"摘要",ovColMachine:"机器",ovColDur:"时长",ovColCost:"成本",ovColStatus:"状态",ovNoExecutions:"本项目暂无执行记录",ovLogs:"日志",stConfigured:"已配置",stNotConfigured:"未配置",stReconnect:"重新连接",stMessagingPlatforms:"消息平台",stTuiGateway:"TUI 网关",stApi:"API",stDaemonNetwork:"守护进程与网络",stDefaultProfile:"默认配置",stProfReadNote:"读取于每次 agent 启动 — 免重启",stColName:"名称",stColModel:"模型",stColBackend:"后端",stColMode:"模式",stColThinking:"思考",stNoProfiles:"profiles.json 中暂无配置",stColCortexPath:"CORTEX 路径",stColSsh:"SSH",stColOs:"系统",stNoMachinesFile:"machines.json 中暂无机器",stMachineLocal:"— 本地",stLogs:"日志",stAddMachine:"+ 添加机器",stClientLifecycle:"客户端生命周期",stConnectivity:"连通性",stMachinesFootNote:"SSH 仅为存在标记(绝不返回原始 user@host)。实时 CLIENT 版本 / STATUS / 心跳属于运行时状态,config.get 契约不携带——宁可省略也不编造。上方两张卡片为静态架构说明。",stEntry:"条",stEntries:"条",stOpenEditor:"打开编辑器 ↗",stColKind:"类型",stColDescription:"描述",stColKeys:"键数",stNoTemplates:"thread-templates/ 中暂无模板",stTemplatesFootNote1:"真实内容来自 thread-templates/。KEYS = 顶层 body 键数。模板 body 按读取原样展示;不编造结构。",stGrpTemplates:"模板",stGrpAgents:"智能体",stGrpShells:"Shell",stNone:"无",stTemplatesFootNote2:"名称为 thread-templates/ 的真实文件名。单模板的步骤标签 / 钩子绑定不在 config.get 契约中(不编造元数据)。",stServers:"服务器",stNoServers:"mcp-config.json 中暂无服务器",stMcpFootNote:"core 变体仅保留 remote_* 工具;tui 变体供终端网关会话使用。单服务器的工具列表不在 config.get 契约中(服务器名称为 mcp-config.json 的真实键)。",stNotifyTurnTitle:"长任务完成后发新消息",stNotifyTurnDesc:"短回合保持安静 · 当前阈值",stNotifyResumeTitle:"限额窗口重置后自动续跑并通知",stNotifyResumeDesc:"中断的会话与线程自动接着跑",stNotifyCompactionTitle:"上下文压缩(compaction)提示",stNotifyCompactionDesc:"压缩时在对话里发一条说明",stNotifyRoutingTitle:"系统通知去向",stNotifyRoutingRight:"多平台逐个分发",stApprovalReminderNote:"审批提醒固定开启 — 阻塞线程时每 30 分钟重新提醒",stRecentNotifications:"最近通知",stRecentNotifRight:"仅运行时 · 无历史范围",stRecentNotifNote:"通知活动保存在 TUI 客户端的内存环形缓冲区中(上限 50,无文件持久化)——不经由任何 tRPC 读取范围暴露。Web UI 中无法查看实时历史;请使用 TUI 终端界面查看实时通知。",stAgentHooks:"已挂载钩子",stNoHooks:"暂无已挂载钩子",stHookEnabled:"已启用",stHookDisabled:"已停用",stHooksFootNote:"挂载状态来自 config/hooks 声明与线程模板生命周期钩子,来源分类与 cortex-hook list 完全一致。",hkFilterAll:"全部",hkFilterAgent:"智能体",hkFilterClaude:"Claude",hkFilterPi:"PI",hkFilterServer:"服务端",hkFilterTemplate:"模板",hkSearchPh:"搜索 id、事件、脚本…",hkNoMatch:"没有钩子符合当前筛选",hkSelectHint:"选择一个钩子以查看其声明",hkLoading:"正在加载钩子…",hkLoadFailed:"加载钩子失败:",hkCreate:"新建钩子",hkSecTrigger:"触发",hkSecAction:"动作",hkSecScope:"作用域",hkSecAdvanced:"高级",hkSecDeclaration:"声明",hkSecRegistry:"注册表",hkOrderNote:"order = 同一事件内的执行顺序",hkFieldId:"id",hkFieldEvent:"事件",hkFieldMatcher:"匹配式",hkFieldFilters:"过滤条件",hkFieldRun:"执行",hkFieldTemplate:"模板",hkFieldScript:"脚本",hkFieldCommand:"命令",hkFieldTimeout:"超时",hkFieldBackends:"后端",hkFieldRequiresTool:"需要工具",hkFieldResult:"结果",hkFieldSource:"来源",hkFieldFile:"文件",hkFieldOrder:"顺序",hkFieldBlocking:"阻塞",hkFieldVersion:"版本",hkFieldMountsOn:"挂载于",hkFieldAppliesAt:"生效时机",hkSeconds:"秒",hkUnscoped:"两者 — 由事件前缀推导",hkNoMatcher:"留空 — 匹配全部",hkMatcherRegexHint:"与工具名进行匹配的正则表达式",hkMatcherFiltersHint:"每个键都必须在负载中存在,且值完全相等",hkMatcherInvalid:"正则表达式无效",hkAddFilter:"添加过滤条件",hkRemoveFilter:"移除",hkFilterKeyPh:"键",hkFilterValuePh:"值",hkResultLocked:"该事件无法返回结果 — 加载器只接受 none。",hkAppliesNextAgent:"下次智能体启动时生效。",hkAppliesRestart:"事件总线在启动时快照注册表 — 需重启服务端后才会生效。",hkNoteManaged:"受管条目,随 Cortex 一同分发。此处只有启用开关可写,且后续的 hook sync 会把启用状态恢复为随附值。",hkNoteTemplate:"由线程模板文件拥有。请在「线程模板」区域编辑 — 本面板保持只读。",hkClaudeGap:"该 agent:* 事件在 Claude 侧没有挂载点,只会到达 PI。要挂到 Claude,请改用原生声明:",hkScriptMissing:"钩子目录中找不到该脚本 — 此钩子会静默失败。",hkBroken:"失效",hkDirty:"有未保存的更改",hkSave:"保存",hkRevert:"还原",hkDelete:"删除",hkConfirmDelete:"确认删除",hkCancelCreate:"放弃",hkTest:"测试",hkTestTitle:"测试运行",hkTestPayload:"负载 — 通过 stdin 传入的 JSON",hkTestRun:"运行",hkTestClose:"关闭",hkTestReset:"重置为样例",hkTestNoOutput:"无输出",hkTestBlockingWarn:"该钩子会阻塞等待 webhook 往返,并向消息平台发送卡片。测试运行上限为 15 秒,但可能会一直占满该上限。",hkPayloadInvalid:"负载不是合法 JSON",hkErrIdRequired:"必须填写 id",hkErrIdTaken:"该 id 已被其他声明占用",hkErrEventRequired:"必须填写事件",hkErrRunRequired:"脚本与命令必须且只能填写一个",hkErrTimeout:"超时必须是正数秒",hkErrFiltersEmptyKey:"过滤键不能为空",hkErrFiltersDuplicate:"过滤键必须唯一",hkErrResult:"该结果模式对此事件不合法",hkToastSaved:"钩子已保存",hkToastCreated:"钩子已创建",hkToastDeleted:"钩子已删除",hkToastEnabled:"钩子已启用",hkToastDisabled:"钩子已停用",hkToastWriteFailed:"钩子写入失败",hkToastTestFailed:"测试运行失败",stAdvConcNote:"自动 = max(4, cpus − 2) · 从 settings.json 热读取",stSet:"已设置",stAuto:"自动",stGpuMock:"GPU 模拟",stLoadingConfig:"正在加载配置…",stFailedLoadConfig:"加载配置失败:",stPolicyPauseTitle:"暂停并申请审批",stPolicyPauseDesc:"预估超限 → 审批(类别:超预算算力);批准后继续",stPolicyWarnTitle:"仅警告,继续运行",stPolicyWarnDesc:"向 admin 频道发一条警告,绝不阻塞",stPolicyStopTitle:"硬性停止",stPolicyStopDesc:"今日不再派发新任务;运行中的工作不受影响",stLimits:"限额",stDaily:"每日",stWarnAt:"警告阈值",stOverBudgetBehavior:"超预算行为",stCurrentSpend:"当前支出",stObNote:"预估超限 → chat 审批卡 + 审批中心",stBudgetFootNote:"今日 / 本月为真实值(cost.summary);每日/每月的分母为真实值(budget.json)。预测不在契约中——已省略。",stNavAppearance:"外观",stNavPlatform:"平台",stNavAccounts:"账号",stNavProfiles:"配置",stNavBudget:"预算",stNavMachines:"机器",stNavTemplates:"线程模板",stNavMcp:"MCP 服务器",stNavNotifications:"通知",stNavHooks:"钩子",stNavAdvanced:"高级",stMetaAppearanceSub:"语言与主题 — 界面语言与浅色/深色。即时生效,并记住在本设备上。",stMetaPlatformSub:"config/.env — 守护进程启动时加载一次;唯一需要重启的配置",stMetaAccountsSub:"Claude Code 凭据与 auth.status 返回的全部 PI provider",stMetaProfilesSub:"config/profiles.json — 每次 agent 启动时读取,无需重启",stMetaBudgetSub:"config/budget.json — 热读取,即时生效;升级永不覆盖(仅 --force)",stMetaMachinesSub:"config/machines.json — fs.watch 热重载;启动时通过 SSH 自动拉起客户端",stMetaTemplatesSub:"config/thread-templates.json — 每次线程启动时重新读取",stMetaMcpSub:"config/mcp-config.json — 根据运行时模式选择 full / core / tui 变体",stMetaNotificationsSub:"config/settings.json — 实时通知控制与多平台路由",stMetaHooksSub:"注册表与模板作用域的已挂载钩子 — 当前事件、启用状态与来源",stMetaAdvancedSub:"settings.json 运行时开关;DEBUG 仍只读显示进程环境状态",stThemeLabel:"主题",stThemeLight:"浅色",stThemeDark:"深色",stThemeHint:"两种模式的配色都遵循 Cortex 设计系统;选择保存在本设备上。",stLangLabel:"语言",stLangHint:"工作台的界面语言。即时生效,并保存在本设备上。",stLangEnglish:"English",stLangChinese:"中文",stBudgetWriteError:"无法写入预算 — 必须先在 budget.json 中设置 monthly_usd(正数)",stCostsJsonlLabel:"costs.jsonl · 90天",stEsc:"esc",stWinOs:"windows",stUnixOs:"unix",stAddMachinePrompt:"要请求添加的机器名称(排队审批,不会直接添加):",stMachineFieldsHint:"name · cortexPath · gpuCount · ssh · win · clientCommand",stToastQueuedApproval:"已排队等待审批 — 请在审批中心查看",stToastWriteFailed:"写入失败",stToastCouldNotQueue:"无法排队请求",stToastBudgetWritten:"budget.json 已写入",stToastDefaultProfile:"profiles.json 已写入",stReconnectApprovalTitle:"将重连请求排队等待审批 — 绝不直接从浏览器执行",stReconnectInertTitle:"无重连后端操作 — 占位",stAddMachineApprovalTitle:"将添加机器请求排队等待审批 — 绝不直接写入 machines.json",stAddMachineInertTitle:"写入 machines.json — 无 add-machine 后端操作(表单不在范围内)",stTemplateEditorInertTitle:"模板编辑器不在范围内 — 占位",stAdvDebugTitle:"调试日志",stAdvDebugDesc:"详细输出写入 daemon.log",stAdvEventLogTitle:"事件总线日志",stAdvEventLogDesc:"记录每条事件总线消息",stAdvDiskMonitorTitle:"磁盘空间监控",stAdvDiskMonitorDesc:"检查 Cortex 数据目录所在文件系统,低于 500 MB 时告警",stAdvToolCallsTitle:"内联工具调用渲染",stAdvToolCallsDesc:"在消息尾部渲染工具调用",stAdvDisableUserTitle:"禁用 USER.md 注入",stAdvDisableUserDesc:"直接对话默认注入;线程步骤始终不注入",stAdvDisableUpdateTitle:"禁用自动更新检查",stAdvDisableUpdateDesc:"更新检查默认开启",npProjectName:"项目名称",npHint:"将创建 context/projects/<name>/ —— 其余交给 agent 处理",npCreate:"创建 →",cpNoResults:"无结果",cpFooterHint:"↑↓ 导航 · ⏎ 打开 · esc 关闭",cpSubOverview:"项目仪表盘",cpSubWorkbench:"会话对话",cpSubTasks:"任务队列",cpSubThreads:"线程运行",cpSubSettings:"平台 · 配置 · 预算 · 机器…",skTitle:"技能",skScanning:"扫描中…",skLoadError:"无法加载技能",skLoadingBody:"正在加载技能…",skFailedBody:"加载技能失败。agent-server 在运行吗?",skEmpty:"未找到技能。请在 DATA_DIR/.claude/skills/ 或 plugins/ 下添加技能目录。",skUserSkills:"用户技能",shNothingHere:"这里还什么都没有",apPending:"待审批",apFrom:"来自",apTask:"任务",apProject:"项目",apOperation:"操作",apReason:"原因",apImpact:"影响",apCommand:"命令",apFeedbackLabel:"反馈",apFeedbackPh:"原因 — 将回传给 agent…",apFootNote:"决定后 → PENDING_APPROVALS.md 翻转 · chat 卡片保持同步",apToastApproved:"已批准 — PENDING_APPROVALS.md 已更新",apToastRejected:"已拒绝 — 原因已回传给 agent",scNewSchedule:"新建调度",scType:"类型",scTypeInterval:"间隔",scTypeDaily:"每日",scTypeWeekly:"每周",scTypeOnce:"单次",scTime:"时间",scEvery:"每",scIn:"延迟",scDay:"星期",scProfile:"配置",scMessage:"消息",scMessagePh:"检查所有机器的 GPU 状态并发一句话摘要。",scTarget:"目标",scFallback:"回退",scNextRun:"下次运行",scFooterIn:"还有",scCreateSchedule:"创建调度",scDaySun:"周日",scDayMon:"周一",scDayTue:"周二",scDayWed:"周三",scDayThu:"周四",scDayFri:"周五",scDaySat:"周六",scToastCreated:"调度已创建",scToastCreateFailed:"无法创建调度",memMemory:"记忆",memLoading:"加载中…",memNoFiles:"暂无记忆文件。",memDiffUnavailable:"差异元数据不可用",memLinesChanged:"行相较 HEAD 变更(git numstat)。",memBlameNote:"下方每一行都标注了其真实的最后改动提交哈希与任务引用(git blame);当该提交不携带任务标签时,任务引用为空。",memBlameUnavailable:"逐行 blame 不可用——该项目目录不是 git 工作树(或 git 不可用),因此不显示提交哈希 / 任务引用。下方为文件当前内容。",memLoadingFile:"正在加载文件…",memReadError:"无法读取此文件。",memSelectFile:"选择一个文件查看。",memSummary:"摘要",thArtifact:"线程产物",thLive:"实时",thNoArtifact:"暂无产物",thOwner:"归属",thReferences:"引用",thWrittenBy:"编写者",thWorkspace:"工作区",thTask:"任务",thProject:"项目",thFailedLoadThread:"加载线程失败",thTemplate:"模板",thStarted:"开始于",thElapsed:"已用时",thCostInclChildren:"成本(含子线程)",thPipeline:"流水线",thOpenSub:"打开",thAgentLabel:"智能体",thAgentSection:"智能体",thSubThreads:"子线程",thStepNoSession:"尚未开始 · 无会话",thStepLoading:"加载对话中…",thStepEmpty:"暂无消息",exLogTitle:"执行日志",exAlreadyFinished:"已结束",exKilled:"已终止",exWaitingOutput:"等待输出…",exNoLiveLog:"无实时日志——该执行不是 cortex-run 启动",exNoLogOutput:"无日志输出",exLinesDropped:"行日志被丢弃",exFooterHeartbeat:"心跳 30s · 丢失 0 · → costs.jsonl",exKillRun:"终止运行",authLoginTitle:"Backend 登录",authLoginIntro:"选择 backend、provider 与认证类型。",authLoginBackend:"Backend",authLoginType:"认证类型",authLoginApiKey:"API key",authLoginOAuth:"OAuth",authLoginSubscription:"订阅(OAuth)",authLoginProvider:"Provider",authLoginStart:"开始登录",authLoginAgain:"重新登录",authLoginSubmit:"提交",authLoginClose:"关闭",authLoginRunning:"正在启动登录…",authLoginSecretPrompt:"输入 API key。它不会进入聊天消息或 transcript。",authLoginOpenLink:"打开链接",authLoginOpenAuthorization:"打开授权页面",authLoginOpenVerification:"打开验证页面",authLoginExpiresIn:"{seconds} 秒后过期。",authLoginDone:"登录完成",authLoginDoneSummary:"已登录 {provider}。",authLoginFailed:"登录失败",authLoginUnknownFailure:"登录流程失败。",authLoginExpired:"此登录流程已过期或不再可用。",authLoginAlreadyActive:"另一个界面已有进行中的登录流程。",authLoginCancelled:"登录已取消",authLoginCancelledSummary:"未提交凭据。",accountsTitle:"账号",accountsSource:"来源",accountsExpires:"过期时间",accountsInUse:"使用中",accountsPiProviders:"PI Provider",accountsLogin:"登录",accountsLogout:"登出",accountsFilter:"筛选 Provider",accountsFilterPlaceholder:"按 Provider 名称筛选…",accountsNoProviders:"没有符合筛选条件的 Provider。",accountsStatusLoggedIn:"已登录",accountsStatusExpiring:"快过期",accountsStatusLoggedOut:"未登录",accountsStatusInvalid:"失效",accountsGroupInUse:"使用中",accountsGroupLoggedIn:"已登录",accountsGroupOther:"其他",accountsConnectedMark:"✓",accountsDisconnected:"未登录",accountsPiSummary:"PI 已登录 {count}",accountsLoading:"正在加载账号…",accountsLoadFailed:"无法加载账号状态。",accountsLogoutDone:"已登出",accountsLogoutFailed:"登出失败"};function o4(e){return e==="zh"?jO:bO}const i4="cortex.lang",s4="en";function wO(e,t){return e==="en"||e==="zh"?e:t&&t.toLowerCase().startsWith("zh")?"zh":s4}function a4(){if(typeof window>"u")return s4;let e=null;try{e=window.localStorage.getItem(i4)}catch{}return wO(e,typeof navigator<"u"?navigator.language:void 0)}function kO(e){if(!(typeof window>"u"))try{window.localStorage.setItem(i4,e)}catch{}}const L0=p.createContext(null);function SO({children:e}){const[t,n]=p.useState(a4),r=Yp(),i=p.useCallback(a=>{n(a),kO(a)},[]),s=p.useMemo(()=>({lang:t,vocab:o4(t),isMobile:r,setLang:i}),[t,r,i]);return o.jsx(L0.Provider,{value:s,children:e})}function pf(){const e=p.useContext(L0);if(!e)throw new Error("useLang must be used within <LangProvider>");return e}function ut(){return pf().lang}function l4(){return pf().setLang}function H(){return pf().vocab}function CO(){const e=p.useContext(L0);return(e==null?void 0:e.vocab)??o4(a4())}function EO(){return pf().isMobile}const c4="cortex.theme",d4="light";function TO(e,t){return e==="light"||e==="dark"?e:t?"dark":d4}function PO(){if(typeof window>"u"||typeof window.matchMedia!="function")return!1;try{return window.matchMedia("(prefers-color-scheme: dark)").matches}catch{return!1}}function RO(){if(typeof window>"u")return d4;let e=null;try{e=window.localStorage.getItem(c4)}catch{}return TO(e,PO())}function K1(e){if(!(typeof window>"u"))try{window.localStorage.setItem(c4,e)}catch{}}function Sh(e){if(typeof document>"u")return;const t=document.documentElement;e==="dark"?t.setAttribute("data-theme","dark"):t.removeAttribute("data-theme"),t.style.colorScheme=e}const u4=p.createContext(null);function IO({children:e}){const[t,n]=p.useState(RO);p.useEffect(()=>{Sh(t)},[t]);const r=p.useCallback(a=>{n(a),K1(a),Sh(a)},[]),i=p.useCallback(()=>{n(a=>{const l=a==="dark"?"light":"dark";return K1(l),Sh(l),l})},[]),s=p.useMemo(()=>({theme:t,setTheme:r,toggleTheme:i}),[t,r,i]);return o.jsx(u4.Provider,{value:s,children:e})}function p4(){const e=p.useContext(u4);if(!e)throw new Error("useTheme must be used within <ThemeProvider>");return e}function O0(){return p4().theme}function A0(){return p4().setTheme}function MO(e){return e==="secret"||e==="manual_code"?"password":e==="select"?"select":"text"}function LO(e,t){const n=e.pendingPrompt,r=n.kind==="secret"?t.authLoginSecretPrompt:n.message;return{kind:"prompt",title:t.authLoginTitle,message:r,inputType:MO(n.kind),options:n.options??[],notice:e.notice,terminal:!1}}function OO(e){return e.kind==="auth_url"?e.instructions??e.url:e.kind==="device_code"?e.userCode:e.message}function AO(e,t){var r;const n=((r=e.outcome)==null?void 0:r.provider)??e.provider??"";if(e.step==="done")return{kind:"done",title:t.authLoginDone,message:t.authLoginDoneSummary.replace("{provider}",n),inputType:null,options:[],notice:e.notice,terminal:!0};if(e.step==="failed"){const i=e.errorCode==="flow_not_found"?t.authLoginExpired:t.authLoginUnknownFailure;return{kind:"failed",title:t.authLoginFailed,message:e.error??i,inputType:null,options:[],notice:e.notice,terminal:!0}}return{kind:"cancelled",title:t.authLoginCancelled,message:t.authLoginCancelledSummary,inputType:null,options:[],notice:e.notice,terminal:!0}}function DO(e,t){return e?e.step==="prompt"&&e.pendingPrompt?LO(e,t):e.step==="done"||e.step==="failed"||e.step==="cancelled"?AO(e,t):e.notice?{kind:"notice",title:t.authLoginTitle,message:OO(e.notice),inputType:null,options:[],notice:e.notice,terminal:!1}:{kind:"running",title:t.authLoginTitle,message:t.authLoginRunning,inputType:null,options:[],notice:null,terminal:!1}:{kind:"selection",title:t.authLoginTitle,message:t.authLoginIntro,inputType:null,options:[],notice:null,terminal:!1}}const NO=500,_O=new Set(["done","failed","cancelled"]);function vp(e){return!!e&&_O.has(e.step)}function $O(e){return{...e,step:"failed",pendingPrompt:null,notice:null,outcome:null,error:null,errorCode:"flow_not_found"}}function FO(e,t,n){return e?vp(e)&&!vp(t)?!0:n&&e.step==="running"&&t.step==="prompt":!1}function D0({href:e,children:t}){return o.jsx("a",{href:e,target:"_blank",rel:"noreferrer",className:"text-state-run underline",children:t})}function zO({notice:e,L:t}){return o.jsxs("div",{"data-auth-notice":"info",className:"space-y-1g",children:[o.jsx("p",{children:e.message}),(e.links??[]).map(n=>o.jsx(D0,{href:n.url,children:n.label??t.authLoginOpenLink},n.url))]})}function BO({notice:e,L:t}){return o.jsxs("div",{"data-auth-notice":"auth_url",className:"space-y-1g",children:[e.instructions?o.jsx("p",{children:e.instructions}):null,o.jsx(D0,{href:e.url,children:t.authLoginOpenAuthorization})]})}function WO({notice:e,L:t}){const n=e.expiresInSeconds===void 0?null:t.authLoginExpiresIn.replace("{seconds}",String(e.expiresInSeconds));return o.jsxs("div",{"data-auth-notice":"device_code",className:"space-y-1g",children:[o.jsx("div",{"data-auth-device-code":!0,className:"font-mono text-xl font-semibold tracking-wider text-state-ink",children:e.userCode}),o.jsxs("div",{className:"space-y-1g",children:[o.jsx("p",{children:t.authLoginOpenVerification}),o.jsx(D0,{href:e.verificationUri,children:e.verificationUri})]}),n?o.jsx("p",{className:"text-caption text-state-muted",children:n}):null]})}function UO({state:e}){const t=H(),n=e.notice;return n?n.kind==="info"?o.jsx(zO,{notice:n,L:t}):n.kind==="auth_url"?o.jsx(BO,{notice:n,L:t}):n.kind==="device_code"?o.jsx(WO,{notice:n,L:t}):o.jsx("div",{"data-auth-notice":"progress","data-auth-progress":!0,className:"text-state-run",role:"status",children:n.message}):null}function HO({state:e,value:t,onChange:n}){var r;return o.jsxs("select",{"data-auth-secret":!0,"aria-labelledby":"auth-login-prompt-label",value:t,onChange:i=>n(i.target.value),className:"w-full rounded-card border border-card bg-surface-card px-2g py-1g text-ui",children:[o.jsx("option",{value:""}),(((r=e.pendingPrompt)==null?void 0:r.options)??[]).map(i=>o.jsx("option",{value:i.id,children:i.label},i.id))]})}function VO({state:e,value:t,onChange:n}){const r=e.pendingPrompt;if(!r)return null;if(r.kind==="select")return o.jsx(HO,{state:e,value:t,onChange:n});const i=r.kind==="secret"||r.kind==="manual_code"?"password":"text";return o.jsx("input",{"data-auth-secret":!0,"aria-labelledby":"auth-login-prompt-label",type:i,value:t,autoComplete:"off",onChange:s=>n(s.target.value),className:"w-full rounded-card border border-card bg-surface-card px-2g py-1g text-ui"})}function qO({controller:e}){const t=H();return o.jsxs("div",{className:"space-y-2g",children:[o.jsxs("label",{className:"block space-y-1g text-ui",children:[o.jsx("span",{children:t.authLoginBackend}),o.jsxs("select",{"data-auth-backend":!0,value:e.backend,onChange:n=>e.chooseBackend(n.target.value),className:"w-full rounded-card border border-card bg-surface-card px-2g py-1g",children:[o.jsx("option",{value:"claude",children:"Claude Code"}),o.jsx("option",{value:"pi",children:"PI"})]})]}),e.backend==="pi"?o.jsx(QO,{controller:e}):null,e.authTypes.length>1?o.jsx(KO,{controller:e}):null]})}function KO({controller:e}){const t=H();return o.jsxs("label",{className:"block space-y-1g text-ui",children:[o.jsx("span",{children:t.authLoginType}),o.jsx("select",{"data-auth-type":!0,value:e.authType,onChange:n=>e.chooseAuthType(n.target.value),className:"w-full rounded-card border border-card bg-surface-card px-2g py-1g",children:e.authTypes.map(n=>o.jsx("option",{value:n,children:n==="api_key"?t.authLoginApiKey:e.backend==="claude"?t.authLoginSubscription:t.authLoginOAuth},n))})]})}function QO({controller:e}){const t=H();return o.jsxs("label",{className:"block space-y-1g text-ui",children:[o.jsx("span",{children:t.authLoginProvider}),o.jsx("select",{"data-auth-provider":!0,value:e.provider,onChange:n=>e.chooseProvider(n.target.value),className:"w-full rounded-card border border-card bg-surface-card px-2g py-1g",children:e.providers.map(n=>o.jsx("option",{value:n.provider,children:n.label},n.provider))})]})}function YO(e){return e.filter(t=>t.backend==="pi"&&t.capabilities.length>0).map(t=>({provider:t.provider,label:t.label,capabilities:t.capabilities}))}function GO(e,t,n,r){const i=n==="claude"?e.find(s=>s.backend==="claude"&&s.provider===r):t.find(s=>s.provider===r);return(i==null?void 0:i.capabilities)??[]}function XO(e,t,n,r,i){p.useEffect(()=>{!e||!t||(n(t.backend),r(t.provider),i(t.authType))},[e,t,n,r,i])}function JO(e,t,n,r,i,s,a){p.useEffect(()=>{var l;e==="pi"&&n.length>0&&!n.some(c=>c.provider===t)&&s(((l=n[0])==null?void 0:l.provider)??"")},[e,t,n,s]),p.useEffect(()=>{!i.includes(r)&&i[0]&&a(i[0])},[r,i,a])}function ZO(e,t){var v;const n=le(),[r,i]=p.useState("claude"),[s,a]=p.useState("api_key"),[l,c]=p.useState("anthropic"),u=((v=Y({...n.auth.status.queryOptions({}),enabled:e}).data)==null?void 0:v.accounts)??[],f=p.useMemo(()=>YO(u),[u]),h=GO(u,f,r,l);return XO(e,t,i,c,a),JO(r,l,f,s,h,c,a),{backend:r,authType:s,authTypes:h,provider:l,providers:f,chooseBackend:x=>{var b;i(x),c(x==="claude"?"anthropic":((b=f[0])==null?void 0:b.provider)??"")},chooseProvider:c,chooseAuthType:a,...t?{noticeId:t.noticeId}:{}}}function eA(e,t,n,r,i){const s=le(),a=je(),l=Y({...s.auth.flowState.queryOptions({flowId:t??""}),enabled:e&&!!t,refetchInterval:e&&t&&!vp(n)?NO:!1});p.useEffect(()=>{l.data&&!FO(n,l.data,r)?i(l.data):!l.data&&l.isSuccess&&t&&n&&!vp(n)&&i($O(n))},[l.data,l.isSuccess,t,n,r,i]),p.useEffect(()=>{(n==null?void 0:n.step)==="done"&&a.invalidateQueries(s.auth.status.queryFilter({}))},[n==null?void 0:n.step,a,s.auth.status])}function N0(e,t,n){const r=e instanceof Error?e.message:String(e);return r==="Login flow not found or expired."?t:r.includes("active on another surface")?n:r}function Ya(e,t){return e.generation.current===t}async function tA(e,t){const n=++t.generation.current;t.setError(null),t.setResponseSent(!1);try{const r=await e.auth.startLogin.mutate({backend:t.selection.backend,provider:t.selection.provider,authType:t.selection.authType,...t.selection.noticeId?{noticeId:t.selection.noticeId}:{}});if(!Ya(t,n))return;t.setFlowId(r.flowId),t.setLatest(r),t.setResponse("")}catch(r){Ya(t,n)&&t.setError(N0(r,t.expiredMessage,t.conflictMessage))}}async function nA(e,t){if(!t.flowId||!t.response)return;const n=t.generation.current,r=t.response;t.setResponse(""),t.setResponseSent(!0),t.setError(null);try{const i=await e.auth.respondPrompt.mutate({flowId:t.flowId,value:r});Ya(t,n)&&t.setLatest(i)}catch(i){Ya(t,n)&&t.setError(N0(i,t.expiredMessage,t.conflictMessage))}}async function rA(e,t){if(!t.flowId)return;const n=++t.generation.current;try{const r=await e.auth.cancelFlow.mutate({flowId:t.flowId});Ya(t,n)&&t.setLatest(r)}catch(r){Ya(t,n)&&t.setError(N0(r,t.expiredMessage,t.conflictMessage))}}function oA(e){const t=Qp();return{start:()=>tA(t,e),submit:()=>nA(t,e),cancel:()=>rA(t,e)}}function iA(e,t){return e.backend===t.backend&&e.provider===t.provider&&e.authType===t.authType}function f4(e){return e.noticeId??`settings:${e.backend}:${e.provider}:${e.authType}`}function sA(e,t,n,r){p.useEffect(()=>{r.generation.current+=1,r.setFlowId(e&&n?n.flowId:null),r.setLatest(e?n??null:null),r.setResponse(""),r.setResponseSent(!1),r.setError(null),r.autoStarted.current=n&&t?f4(t):null},[e,t,n])}function aA(e,t,n,r,i,s){p.useEffect(()=>{if(!e||!t||n||!r.canStart||!i)return;const a=f4(t);s.current!==a&&(s.current=a,r.start())},[e,t,n,r.canStart,r.start,i,s])}function lA(e,t,n,r){const i=H(),s=ZO(e,t),[a,l]=p.useState(null),[c,d]=p.useState(null),[u,f]=p.useState(""),[h,g]=p.useState(!1),[v,x]=p.useState(null),b=p.useRef(0),j=p.useRef(null);eA(e,a,c,h,d);const y=oA({selection:s,flowId:a,response:u,generation:b,setFlowId:l,setLatest:d,setResponse:f,setResponseSent:g,setError:x,expiredMessage:i.authLoginExpired,conflictMessage:i.authLoginAlreadyActive}),w=!!s.provider&&s.authTypes.includes(s.authType);return sA(e,t,n,{generation:b,autoStarted:j,setFlowId:l,setLatest:d,setResponse:f,setResponseSent:g,setError:x}),aA(e,t,n,{canStart:w,start:y.start},!!t&&iA(s,t),j),p.useEffect(()=>{c&&(r==null||r(c))},[c,r]),{...s,latest:c,response:u,error:v,canCancel:!h,canStart:w,setResponse:f,...y}}function cA(e,t){return t.kind==="selection"?o.jsxs("div",{className:"space-y-2g",children:[o.jsx(qO,{controller:e}),e.error?o.jsx("p",{role:"alert",className:"text-state-fail",children:e.error}):null]}):o.jsxs("div",{className:"space-y-2g","data-auth-flow-step":t.kind,children:[t.kind==="notice"?null:o.jsx("p",{id:t.kind==="prompt"?"auth-login-prompt-label":void 0,children:t.message}),e.error?o.jsx("p",{role:"alert",className:"text-state-fail",children:e.error}):null,e.latest?o.jsx(UO,{state:e.latest}):null,e.latest?o.jsx(VO,{state:e.latest,value:e.response,onChange:e.setResponse}):null]})}function dA(e,t,n,r){return t.kind==="selection"?o.jsx(yt,{"data-action":"auth-start",variant:"primary",disabled:!e.canStart,onClick:e.start,children:r.authLoginStart}):t.kind==="prompt"?o.jsxs(o.Fragment,{children:[e.canCancel?o.jsx(yt,{"data-action":"auth-cancel",onClick:e.cancel,children:r.cancel}):null,o.jsx(yt,{"data-action":"auth-submit",variant:"primary",disabled:!e.response,onClick:e.submit,children:r.authLoginSubmit})]}):t.terminal?o.jsx(yt,{"data-action":"auth-close",onClick:n,children:r.authLoginClose}):e.canCancel?o.jsx(yt,{"data-action":"auth-cancel",onClick:e.cancel,children:r.cancel}):null}function uA({open:e,onClose:t,target:n,initialState:r,onFlowStateChange:i}){const s=H(),a=lA(e,n,r,i),l=DO(a.latest,s);return o.jsx(cf,{open:e,onOpenChange:c=>{c||t()},title:l.title,description:l.message,footer:dA(a,l,t,s),children:cA(a,l)})}const h4=p.createContext(null);function pA({children:e}){const[t,n]=p.useState(!1),[r,i]=p.useState({target:null,initialState:null}),s=p.useRef(new Map),a=p.useCallback(u=>{i({target:u??null,initialState:u!=null&&u.noticeId?s.current.get(u.noticeId)??null:null}),n(!0)},[]),l=p.useCallback(()=>n(!1),[]),c=p.useCallback(u=>{var f;(f=r.target)!=null&&f.noticeId&&s.current.set(r.target.noticeId,u)},[r.target]),d=p.useMemo(()=>({openLogin:a,closeLogin:l}),[a,l]);return o.jsxs(h4.Provider,{value:d,children:[e,o.jsx(uA,{open:t,onClose:l,target:r.target,initialState:r.initialState,onFlowStateChange:c})]})}function g4(){return p.useContext(h4)}function _0(){const e=g4();if(!e)throw new Error("useLoginFlow must be used within LoginFlowProvider");return e}const fA=2e3,hA=20;function gA(){const[e,t]=p.useState(()=>{const n=up();return{config:n,done:!!n||!Kt()}});return p.useEffect(()=>{if(e.done)return;let n=!1;const r=Date.now(),i=setInterval(()=>{const s=up();s?(n||t({config:s,done:!0}),clearInterval(i)):Date.now()-r>=fA&&(n||t({config:void 0,done:!0}),clearInterval(i))},hA);return()=>{n=!0,clearInterval(i)}},[e.done]),e}function xA({children:e}){const[t]=p.useState(()=>new rR),{config:n,done:r}=gA(),i=p.useMemo(()=>b9(n),[n]);return r?o.jsx(oR,{client:t,children:o.jsx(x9,{trpcClient:i,queryClient:t,children:o.jsx(IO,{children:o.jsx(hM,{children:o.jsx(vO,{children:o.jsx(SO,{children:o.jsx(pA,{children:e})})})})})})}):null}/**
|
|
90
|
+
* @remix-run/router v1.23.3
|
|
91
|
+
*
|
|
92
|
+
* Copyright (c) Remix Software Inc.
|
|
93
|
+
*
|
|
94
|
+
* This source code is licensed under the MIT license found in the
|
|
95
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
96
|
+
*
|
|
97
|
+
* @license MIT
|
|
98
|
+
*/function nt(){return nt=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},nt.apply(null,arguments)}var kt;(function(e){e.Pop="POP",e.Push="PUSH",e.Replace="REPLACE"})(kt||(kt={}));const Q1="popstate";function mA(e){e===void 0&&(e={});function t(r,i){let{pathname:s,search:a,hash:l}=r.location;return Ga("",{pathname:s,search:a,hash:l},i.state&&i.state.usr||null,i.state&&i.state.key||"default")}function n(r,i){return typeof i=="string"?i:gl(i)}return x4(t,n,null,e)}function vA(e){e===void 0&&(e={});function t(i,s){let{pathname:a="/",search:l="",hash:c=""}=xo(i.location.hash.substr(1));return!a.startsWith("/")&&!a.startsWith(".")&&(a="/"+a),Ga("",{pathname:a,search:l,hash:c},s.state&&s.state.usr||null,s.state&&s.state.key||"default")}function n(i,s){let a=i.document.querySelector("base"),l="";if(a&&a.getAttribute("href")){let c=i.location.href,d=c.indexOf("#");l=d===-1?c:c.slice(0,d)}return l+"#"+(typeof s=="string"?s:gl(s))}function r(i,s){hi(i.pathname.charAt(0)==="/","relative pathnames are not supported in hash history.push("+JSON.stringify(s)+")")}return x4(t,n,r,e)}function Me(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function hi(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function yA(){return Math.random().toString(36).substr(2,8)}function Y1(e,t){return{usr:e.state,key:e.key,idx:t}}function Ga(e,t,n,r){return n===void 0&&(n=null),nt({pathname:typeof e=="string"?e:e.pathname,search:"",hash:""},typeof t=="string"?xo(t):t,{state:n,key:t&&t.key||r||yA()})}function gl(e){let{pathname:t="/",search:n="",hash:r=""}=e;return n&&n!=="?"&&(t+=n.charAt(0)==="?"?n:"?"+n),r&&r!=="#"&&(t+=r.charAt(0)==="#"?r:"#"+r),t}function xo(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substr(n),e=e.substr(0,n));let r=e.indexOf("?");r>=0&&(t.search=e.substr(r),e=e.substr(0,r)),e&&(t.pathname=e)}return t}function x4(e,t,n,r){r===void 0&&(r={});let{window:i=document.defaultView,v5Compat:s=!1}=r,a=i.history,l=kt.Pop,c=null,d=u();d==null&&(d=0,a.replaceState(nt({},a.state,{idx:d}),""));function u(){return(a.state||{idx:null}).idx}function f(){l=kt.Pop;let b=u(),j=b==null?null:b-d;d=b,c&&c({action:l,location:x.location,delta:j})}function h(b,j){l=kt.Push;let y=Ga(x.location,b,j);n&&n(y,b),d=u()+1;let w=Y1(y,d),k=x.createHref(y);try{a.pushState(w,"",k)}catch(S){if(S instanceof DOMException&&S.name==="DataCloneError")throw S;i.location.assign(k)}s&&c&&c({action:l,location:x.location,delta:1})}function g(b,j){l=kt.Replace;let y=Ga(x.location,b,j);n&&n(y,b),d=u();let w=Y1(y,d),k=x.createHref(y);a.replaceState(w,"",k),s&&c&&c({action:l,location:x.location,delta:0})}function v(b){let j=i.location.origin!=="null"?i.location.origin:i.location.href,y=typeof b=="string"?b:gl(b);return y=y.replace(/ $/,"%20"),Me(j,"No window.location.(origin|href) available to create URL for href: "+y),new URL(y,j)}let x={get action(){return l},get location(){return e(i,a)},listen(b){if(c)throw new Error("A history only accepts one active listener");return i.addEventListener(Q1,f),c=b,()=>{i.removeEventListener(Q1,f),c=null}},createHref(b){return t(i,b)},createURL:v,encodeLocation(b){let j=v(b);return{pathname:j.pathname,search:j.search,hash:j.hash}},push:h,replace:g,go(b){return a.go(b)}};return x}var Be;(function(e){e.data="data",e.deferred="deferred",e.redirect="redirect",e.error="error"})(Be||(Be={}));const bA=new Set(["lazy","caseSensitive","path","id","index","children"]);function jA(e){return e.index===!0}function yp(e,t,n,r){return n===void 0&&(n=[]),r===void 0&&(r={}),e.map((i,s)=>{let a=[...n,String(s)],l=typeof i.id=="string"?i.id:a.join("-");if(Me(i.index!==!0||!i.children,"Cannot specify children on an index route"),Me(!r[l],'Found a route id collision on id "'+l+`". Route id's must be globally unique within Data Router usages`),jA(i)){let c=nt({},i,t(i),{id:l});return r[l]=c,c}else{let c=nt({},i,t(i),{id:l,children:void 0});return r[l]=c,i.children&&(c.children=yp(i.children,t,a,r)),c}})}function zi(e,t,n){return n===void 0&&(n="/"),Au(e,t,n,!1)}function Au(e,t,n,r){let i=typeof t=="string"?xo(t):t,s=cd(i.pathname||"/",n);if(s==null)return null;let a=m4(e);kA(a);let l=null,c=AA(s);for(let d=0;l==null&&d<a.length;++d)l=LA(a[d],c,r);return l}function wA(e,t){let{route:n,pathname:r,params:i}=e;return{id:n.id,pathname:r,params:i,data:t[n.id],handle:n.handle}}function m4(e,t,n,r){t===void 0&&(t=[]),n===void 0&&(n=[]),r===void 0&&(r="");let i=(s,a,l)=>{let c={relativePath:l===void 0?s.path||"":l,caseSensitive:s.caseSensitive===!0,childrenIndex:a,route:s};c.relativePath.startsWith("/")&&(Me(c.relativePath.startsWith(r),'Absolute route path "'+c.relativePath+'" nested under path '+('"'+r+'" is not valid. An absolute child route path ')+"must start with the combined path of all its parent routes."),c.relativePath=c.relativePath.slice(r.length));let d=si([r,c.relativePath]),u=n.concat(c);s.children&&s.children.length>0&&(Me(s.index!==!0,"Index routes must not have child routes. Please remove "+('all child routes from route path "'+d+'".')),m4(s.children,t,u,d)),!(s.path==null&&!s.index)&&t.push({path:d,score:IA(d,s.index),routesMeta:u})};return e.forEach((s,a)=>{var l;if(s.path===""||!((l=s.path)!=null&&l.includes("?")))i(s,a);else for(let c of v4(s.path))i(s,a,c)}),t}function v4(e){let t=e.split("/");if(t.length===0)return[];let[n,...r]=t,i=n.endsWith("?"),s=n.replace(/\?$/,"");if(r.length===0)return i?[s,""]:[s];let a=v4(r.join("/")),l=[];return l.push(...a.map(c=>c===""?s:[s,c].join("/"))),i&&l.push(...a),l.map(c=>e.startsWith("/")&&c===""?"/":c)}function kA(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:MA(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}const SA=/^:[\w-]+$/,CA=3,EA=2,TA=1,PA=10,RA=-2,G1=e=>e==="*";function IA(e,t){let n=e.split("/"),r=n.length;return n.some(G1)&&(r+=RA),t&&(r+=EA),n.filter(i=>!G1(i)).reduce((i,s)=>i+(SA.test(s)?CA:s===""?TA:PA),r)}function MA(e,t){return e.length===t.length&&e.slice(0,-1).every((r,i)=>r===t[i])?e[e.length-1]-t[t.length-1]:0}function LA(e,t,n){n===void 0&&(n=!1);let{routesMeta:r}=e,i={},s="/",a=[];for(let l=0;l<r.length;++l){let c=r[l],d=l===r.length-1,u=s==="/"?t:t.slice(s.length)||"/",f=X1({path:c.relativePath,caseSensitive:c.caseSensitive,end:d},u),h=c.route;if(!f&&d&&n&&!r[r.length-1].route.index&&(f=X1({path:c.relativePath,caseSensitive:c.caseSensitive,end:!1},u)),!f)return null;Object.assign(i,f.params),a.push({params:i,pathname:si([s,f.pathname]),pathnameBase:$A(si([s,f.pathnameBase])),route:h}),f.pathnameBase!=="/"&&(s=si([s,f.pathnameBase]))}return a}function X1(e,t){typeof e=="string"&&(e={path:e,caseSensitive:!1,end:!0});let[n,r]=OA(e.path,e.caseSensitive,e.end),i=t.match(n);if(!i)return null;let s=i[0],a=s.replace(/(.)\/+$/,"$1"),l=i.slice(1);return{params:r.reduce((d,u,f)=>{let{paramName:h,isOptional:g}=u;if(h==="*"){let x=l[f]||"";a=s.slice(0,s.length-x.length).replace(/(.)\/+$/,"$1")}const v=l[f];return g&&!v?d[h]=void 0:d[h]=(v||"").replace(/%2F/g,"/"),d},{}),pathname:s,pathnameBase:a,pattern:e}}function OA(e,t,n){t===void 0&&(t=!1),n===void 0&&(n=!0),hi(e==="*"||!e.endsWith("*")||e.endsWith("/*"),'Route path "'+e+'" will be treated as if it were '+('"'+e.replace(/\*$/,"/*")+'" because the `*` character must ')+"always follow a `/` in the pattern. To get rid of this warning, "+('please change the route path to "'+e.replace(/\*$/,"/*")+'".'));let r=[],i="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(a,l,c)=>(r.push({paramName:l,isOptional:c!=null}),c?"/?([^\\/]+)?":"/([^\\/]+)"));return e.endsWith("*")?(r.push({paramName:"*"}),i+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?i+="\\/*$":e!==""&&e!=="/"&&(i+="(?:(?=\\/|$))"),[new RegExp(i,t?void 0:"i"),r]}function AA(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return hi(!1,'The URL path "'+e+'" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent '+("encoding ("+t+").")),e}}function cd(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,r=e.charAt(n);return r&&r!=="/"?null:e.slice(n)||"/"}const DA=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,NA=e=>DA.test(e);function _A(e,t){t===void 0&&(t="/");let{pathname:n,search:r="",hash:i=""}=typeof e=="string"?xo(e):e,s;if(n)if(NA(n))s=n;else{if(n.includes("//")){let a=n;n=z0(n),hi(!1,"Pathnames cannot have embedded double slashes - normalizing "+(a+" -> "+n))}n.startsWith("/")?s=J1(n.substring(1),"/"):s=J1(n,t)}else s=t;return{pathname:s,search:FA(r),hash:zA(i)}}function J1(e,t){let n=t.replace(/\/+$/,"").split("/");return e.split("/").forEach(i=>{i===".."?n.length>1&&n.pop():i!=="."&&n.push(i)}),n.length>1?n.join("/"):"/"}function Ch(e,t,n,r){return"Cannot include a '"+e+"' character in a manually specified "+("`to."+t+"` field ["+JSON.stringify(r)+"]. Please separate it out to the ")+("`to."+n+"` field. Alternatively you may provide the full path as ")+'a string in <Link to="..."> and the router will parse it for you.'}function y4(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function $0(e,t){let n=y4(e);return t?n.map((r,i)=>i===n.length-1?r.pathname:r.pathnameBase):n.map(r=>r.pathnameBase)}function F0(e,t,n,r){r===void 0&&(r=!1);let i;typeof e=="string"?i=xo(e):(i=nt({},e),Me(!i.pathname||!i.pathname.includes("?"),Ch("?","pathname","search",i)),Me(!i.pathname||!i.pathname.includes("#"),Ch("#","pathname","hash",i)),Me(!i.search||!i.search.includes("#"),Ch("#","search","hash",i)));let s=e===""||i.pathname==="",a=s?"/":i.pathname,l;if(a==null)l=n;else{let f=t.length-1;if(!r&&a.startsWith("..")){let h=a.split("/");for(;h[0]==="..";)h.shift(),f-=1;i.pathname=h.join("/")}l=f>=0?t[f]:"/"}let c=_A(i,l),d=a&&a!=="/"&&a.endsWith("/"),u=(s||a===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(d||u)&&(c.pathname+="/"),c}const z0=e=>e.replace(/\/\/+/g,"/"),si=e=>z0(e.join("/")),$A=e=>e.replace(/\/+$/,"").replace(/^\/*/,"/"),FA=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,zA=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e;class bp{constructor(t,n,r,i){i===void 0&&(i=!1),this.status=t,this.statusText=n||"",this.internal=i,r instanceof Error?(this.data=r.toString(),this.error=r):this.data=r}}function Ac(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}const b4=["post","put","patch","delete"],BA=new Set(b4),WA=["get",...b4],UA=new Set(WA),HA=new Set([301,302,303,307,308]),VA=new Set([307,308]),Eh={state:"idle",location:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0},qA={state:"idle",data:void 0,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0},Il={state:"unblocked",proceed:void 0,reset:void 0,location:void 0},B0=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,KA=e=>({hasErrorBoundary:!!e.hasErrorBoundary}),j4="remix-router-transitions";function w4(e){const t=e.window?e.window:typeof window<"u"?window:void 0,n=typeof t<"u"&&typeof t.document<"u"&&typeof t.document.createElement<"u",r=!n;Me(e.routes.length>0,"You must provide a non-empty routes array to createRouter");let i;if(e.mapRouteProperties)i=e.mapRouteProperties;else if(e.detectErrorBoundary){let E=e.detectErrorBoundary;i=R=>({hasErrorBoundary:E(R)})}else i=KA;let s={},a=yp(e.routes,i,void 0,s),l,c=e.basename||"/",d=e.dataStrategy||XA,u=e.patchRoutesOnNavigation,f=nt({v7_fetcherPersist:!1,v7_normalizeFormMethod:!1,v7_partialHydration:!1,v7_prependBasename:!1,v7_relativeSplatPath:!1,v7_skipActionErrorRevalidation:!1},e.future),h=null,g=new Set,v=null,x=null,b=null,j=e.hydrationData!=null,y=zi(a,e.history.location,c),w=!1,k=null;if(y==null&&!u){let E=an(404,{pathname:e.history.location.pathname}),{matches:R,route:O}=cb(a);y=R,k={[O.id]:E}}y&&!e.hydrationData&&_r(y,a,e.history.location.pathname).active&&(y=null);let S;if(y)if(y.some(E=>E.route.lazy))S=!1;else if(!y.some(E=>E.route.loader))S=!0;else if(f.v7_partialHydration){let E=e.hydrationData?e.hydrationData.loaderData:null,R=e.hydrationData?e.hydrationData.errors:null;if(R){let O=y.findIndex(B=>R[B.route.id]!==void 0);S=y.slice(0,O+1).every(B=>!Px(B.route,E,R))}else S=y.every(O=>!Px(O.route,E,R))}else S=e.hydrationData!=null;else if(S=!1,y=[],f.v7_partialHydration){let E=_r(null,a,e.history.location.pathname);E.active&&E.matches&&(w=!0,y=E.matches)}let T,C={historyAction:e.history.action,location:e.history.location,matches:y,initialized:S,navigation:Eh,restoreScrollPosition:e.hydrationData!=null?!1:null,preventScrollReset:!1,revalidation:"idle",loaderData:e.hydrationData&&e.hydrationData.loaderData||{},actionData:e.hydrationData&&e.hydrationData.actionData||null,errors:e.hydrationData&&e.hydrationData.errors||k,fetchers:new Map,blockers:new Map},P=kt.Pop,I=!1,L,z=!1,q=new Map,X=null,D=!1,U=!1,Q=[],J=new Set,_=new Map,F=0,W=-1,te=new Map,A=new Set,V=new Map,oe=new Map,Z=new Set,ie=new Map,he=new Map,ve;function be(){if(h=e.history.listen(E=>{let{action:R,location:O,delta:B}=E;if(ve){ve(),ve=void 0;return}hi(he.size===0||B!=null,"You are trying to use a blocker on a POP navigation to a location that was not created by @remix-run/router. This will fail silently in production. This can happen if you are navigating outside the router via `window.history.pushState`/`window.location.hash` instead of using router navigation APIs. This can also happen if you are using createHashRouter and the user manually changes the URL.");let K=Cs({currentLocation:C.location,nextLocation:O,historyAction:R});if(K&&B!=null){let re=new Promise(ce=>{ve=ce});e.history.go(B*-1),Nr(K,{state:"blocked",location:O,proceed(){Nr(K,{state:"proceeding",proceed:void 0,reset:void 0,location:O}),re.then(()=>e.history.go(B))},reset(){let ce=new Map(C.blockers);ce.set(K,Il),Re({blockers:ce})}});return}return De(R,O)}),n){uD(t,q);let E=()=>pD(t,q);t.addEventListener("pagehide",E),X=()=>t.removeEventListener("pagehide",E)}return C.initialized||De(kt.Pop,C.location,{initialHydration:!0}),T}function jt(){h&&h(),X&&X(),g.clear(),L&&L.abort(),C.fetchers.forEach((E,R)=>Dr(R)),C.blockers.forEach((E,R)=>Ss(R))}function At(E){return g.add(E),()=>g.delete(E)}function Re(E,R){R===void 0&&(R={}),C=nt({},C,E);let O=[],B=[];f.v7_fetcherPersist&&C.fetchers.forEach((K,re)=>{K.state==="idle"&&(Z.has(re)?B.push(re):O.push(re))}),Z.forEach(K=>{!C.fetchers.has(K)&&!_.has(K)&&B.push(K)}),[...g].forEach(K=>K(C,{deletedFetchers:B,viewTransitionOpts:R.viewTransitionOpts,flushSync:R.flushSync===!0})),f.v7_fetcherPersist?(O.forEach(K=>C.fetchers.delete(K)),B.forEach(K=>Dr(K))):B.forEach(K=>Z.delete(K))}function xt(E,R,O){var B,K;let{flushSync:re}=O===void 0?{}:O,ce=C.actionData!=null&&C.navigation.formMethod!=null&&Jn(C.navigation.formMethod)&&C.navigation.state==="loading"&&((B=E.state)==null?void 0:B._isRedirect)!==!0,de;R.actionData?Object.keys(R.actionData).length>0?de=R.actionData:de=null:ce?de=C.actionData:de=null;let ne=R.loaderData?ab(C.loaderData,R.loaderData,R.matches||[],R.errors):C.loaderData,se=C.blockers;se.size>0&&(se=new Map(se),se.forEach((Ce,Xe)=>se.set(Xe,Il)));let fe=I===!0||C.navigation.formMethod!=null&&Jn(C.navigation.formMethod)&&((K=E.state)==null?void 0:K._isRedirect)!==!0;l&&(a=l,l=void 0),D||P===kt.Pop||(P===kt.Push?e.history.push(E,E.state):P===kt.Replace&&e.history.replace(E,E.state));let ye;if(P===kt.Pop){let Ce=q.get(C.location.pathname);Ce&&Ce.has(E.pathname)?ye={currentLocation:C.location,nextLocation:E}:q.has(E.pathname)&&(ye={currentLocation:E,nextLocation:C.location})}else if(z){let Ce=q.get(C.location.pathname);Ce?Ce.add(E.pathname):(Ce=new Set([E.pathname]),q.set(C.location.pathname,Ce)),ye={currentLocation:C.location,nextLocation:E}}Re(nt({},R,{actionData:de,loaderData:ne,historyAction:P,location:E,initialized:!0,navigation:Eh,revalidation:"idle",restoreScrollPosition:jo(E,R.matches||C.matches),preventScrollReset:fe,blockers:se}),{viewTransitionOpts:ye,flushSync:re===!0}),P=kt.Pop,I=!1,z=!1,D=!1,U=!1,Q=[]}async function we(E,R){if(typeof E=="number"){e.history.go(E);return}let O=Tx(C.location,C.matches,c,f.v7_prependBasename,E,f.v7_relativeSplatPath,R==null?void 0:R.fromRouteId,R==null?void 0:R.relative),{path:B,submission:K,error:re}=Z1(f.v7_normalizeFormMethod,!1,O,R),ce=C.location,de=Ga(C.location,B,R&&R.state);de=nt({},de,e.history.encodeLocation(de));let ne=R&&R.replace!=null?R.replace:void 0,se=kt.Push;ne===!0?se=kt.Replace:ne===!1||K!=null&&Jn(K.formMethod)&&K.formAction===C.location.pathname+C.location.search&&(se=kt.Replace);let fe=R&&"preventScrollReset"in R?R.preventScrollReset===!0:void 0,ye=(R&&R.flushSync)===!0,Ce=Cs({currentLocation:ce,nextLocation:de,historyAction:se});if(Ce){Nr(Ce,{state:"blocked",location:de,proceed(){Nr(Ce,{state:"proceeding",proceed:void 0,reset:void 0,location:de}),we(E,R)},reset(){let Xe=new Map(C.blockers);Xe.set(Ce,Il),Re({blockers:Xe})}});return}return await De(se,de,{submission:K,pendingError:re,preventScrollReset:fe,replace:R&&R.replace,enableViewTransition:R&&R.viewTransition,flushSync:ye})}function Ie(){if(wt(),Re({revalidation:"loading"}),C.navigation.state!=="submitting"){if(C.navigation.state==="idle"){De(C.historyAction,C.location,{startUninterruptedRevalidation:!0});return}De(P||C.historyAction,C.navigation.location,{overrideNavigation:C.navigation,enableViewTransition:z===!0})}}async function De(E,R,O){L&&L.abort(),L=null,P=E,D=(O&&O.startUninterruptedRevalidation)===!0,Un(C.location,C.matches),I=(O&&O.preventScrollReset)===!0,z=(O&&O.enableViewTransition)===!0;let B=l||a,K=O&&O.overrideNavigation,re=O!=null&&O.initialHydration&&C.matches&&C.matches.length>0&&!w?C.matches:zi(B,R,c),ce=(O&&O.flushSync)===!0;if(re&&C.initialized&&!U&&rD(C.location,R)&&!(O&&O.submission&&Jn(O.submission.formMethod))){xt(R,{matches:re},{flushSync:ce});return}let de=_r(re,B,R.pathname);if(de.active&&de.matches&&(re=de.matches),!re){let{error:Ue,notFoundMatches:Ne,route:at}=yo(R.pathname);xt(R,{matches:Ne,loaderData:{},errors:{[at.id]:Ue}},{flushSync:ce});return}L=new AbortController;let ne=Ds(e.history,R,L.signal,O&&O.submission),se;if(O&&O.pendingError)se=[Bi(re).route.id,{type:Be.error,error:O.pendingError}];else if(O&&O.submission&&Jn(O.submission.formMethod)){let Ue=await Wn(ne,R,O.submission,re,de.active,{replace:O.replace,flushSync:ce});if(Ue.shortCircuited)return;if(Ue.pendingActionResult){let[Ne,at]=Ue.pendingActionResult;if(yn(at)&&Ac(at.error)&&at.error.status===404){L=null,xt(R,{matches:Ue.matches,loaderData:{},errors:{[Ne]:at.error}});return}}re=Ue.matches||re,se=Ue.pendingActionResult,K=Th(R,O.submission),ce=!1,de.active=!1,ne=Ds(e.history,ne.url,ne.signal)}let{shortCircuited:fe,matches:ye,loaderData:Ce,errors:Xe}=await it(ne,R,re,de.active,K,O&&O.submission,O&&O.fetcherSubmission,O&&O.replace,O&&O.initialHydration===!0,ce,se);fe||(L=null,xt(R,nt({matches:ye||re},lb(se),{loaderData:Ce,errors:Xe})))}async function Wn(E,R,O,B,K,re){re===void 0&&(re={}),wt();let ce=cD(R,O);if(Re({navigation:ce},{flushSync:re.flushSync===!0}),K){let se=await Hn(B,R.pathname,E.signal);if(se.type==="aborted")return{shortCircuited:!0};if(se.type==="error"){let fe=Bi(se.partialMatches).route.id;return{matches:se.partialMatches,pendingActionResult:[fe,{type:Be.error,error:se.error}]}}else if(se.matches)B=se.matches;else{let{notFoundMatches:fe,error:ye,route:Ce}=yo(R.pathname);return{matches:fe,pendingActionResult:[Ce.id,{type:Be.error,error:ye}]}}}let de,ne=Ul(B,R);if(!ne.route.action&&!ne.route.lazy)de={type:Be.error,error:an(405,{method:E.method,pathname:R.pathname,routeId:ne.route.id})};else if(de=(await Se("action",C,E,[ne],B,null))[ne.route.id],E.signal.aborted)return{shortCircuited:!0};if(qi(de)){let se;return re&&re.replace!=null?se=re.replace:se=ob(de.response.headers.get("Location"),new URL(E.url),c,e.history)===C.location.pathname+C.location.search,await Oe(E,de,!0,{submission:O,replace:se}),{shortCircuited:!0}}if(Go(de))throw an(400,{type:"defer-action"});if(yn(de)){let se=Bi(B,ne.route.id);return(re&&re.replace)!==!0&&(P=kt.Push),{matches:B,pendingActionResult:[se.route.id,de]}}return{matches:B,pendingActionResult:[ne.route.id,de]}}async function it(E,R,O,B,K,re,ce,de,ne,se,fe){let ye=K||Th(R,re),Ce=re||ce||ub(ye),Xe=!D&&(!f.v7_partialHydration||!ne);if(B){if(Xe){let ee=qe(fe);Re(nt({navigation:ye},ee!==void 0?{actionData:ee}:{}),{flushSync:se})}let $=await Hn(O,R.pathname,E.signal);if($.type==="aborted")return{shortCircuited:!0};if($.type==="error"){let ee=Bi($.partialMatches).route.id;return{matches:$.partialMatches,loaderData:{},errors:{[ee]:$.error}}}else if($.matches)O=$.matches;else{let{error:ee,notFoundMatches:me,route:Ke}=yo(R.pathname);return{matches:me,loaderData:{},errors:{[Ke.id]:ee}}}}let Ue=l||a,[Ne,at]=tb(e.history,C,O,Ce,R,f.v7_partialHydration&&ne===!0,f.v7_skipActionErrorRevalidation,U,Q,J,Z,V,A,Ue,c,fe);if(bo($=>!(O&&O.some(ee=>ee.route.id===$))||Ne&&Ne.some(ee=>ee.route.id===$)),W=++F,Ne.length===0&&at.length===0){let $=fr();return xt(R,nt({matches:O,loaderData:{},errors:fe&&yn(fe[1])?{[fe[0]]:fe[1].error}:null},lb(fe),$?{fetchers:new Map(C.fetchers)}:{}),{flushSync:se}),{shortCircuited:!0}}if(Xe){let $={};if(!B){$.navigation=ye;let ee=qe(fe);ee!==void 0&&($.actionData=ee)}at.length>0&&($.fetchers=Ve(at)),Re($,{flushSync:se})}at.forEach($=>{Dt($.key),$.controller&&_.set($.key,$.controller)});let wo=()=>at.forEach($=>Dt($.key));L&&L.signal.addEventListener("abort",wo);let{loaderResults:Pi,fetcherResults:Vn}=await pt(C,O,Ne,at,E);if(E.signal.aborted)return{shortCircuited:!0};L&&L.signal.removeEventListener("abort",wo),at.forEach($=>_.delete($.key));let In=nu(Pi);if(In)return await Oe(E,In.result,!0,{replace:de}),{shortCircuited:!0};if(In=nu(Vn),In)return A.add(In.key),await Oe(E,In.result,!0,{replace:de}),{shortCircuited:!0};let{loaderData:jl,errors:ko}=sb(C,O,Pi,fe,at,Vn,ie);ie.forEach(($,ee)=>{$.subscribe(me=>{(me||$.done)&&ie.delete(ee)})}),f.v7_partialHydration&&ne&&C.errors&&(ko=nt({},C.errors,ko));let gr=fr(),Ri=hr(W),Ii=gr||Ri||at.length>0;return nt({matches:O,loaderData:jl,errors:ko},Ii?{fetchers:new Map(C.fetchers)}:{})}function qe(E){if(E&&!yn(E[1]))return{[E[0]]:E[1].data};if(C.actionData)return Object.keys(C.actionData).length===0?null:C.actionData}function Ve(E){return E.forEach(R=>{let O=C.fetchers.get(R.key),B=Ml(void 0,O?O.data:void 0);C.fetchers.set(R.key,B)}),new Map(C.fetchers)}function Qt(E,R,O,B){if(r)throw new Error("router.fetch() was called during the server render, but it shouldn't be. You are likely calling a useFetcher() method in the body of your component. Try moving it to a useEffect or a callback.");Dt(E);let K=(B&&B.flushSync)===!0,re=l||a,ce=Tx(C.location,C.matches,c,f.v7_prependBasename,O,f.v7_relativeSplatPath,R,B==null?void 0:B.relative),de=zi(re,ce,c),ne=_r(de,re,ce);if(ne.active&&ne.matches&&(de=ne.matches),!de){st(E,R,an(404,{pathname:ce}),{flushSync:K});return}let{path:se,submission:fe,error:ye}=Z1(f.v7_normalizeFormMethod,!0,ce,B);if(ye){st(E,R,ye,{flushSync:K});return}let Ce=Ul(de,se),Xe=(B&&B.preventScrollReset)===!0;if(fe&&Jn(fe.formMethod)){mt(E,R,se,Ce,de,ne.active,K,Xe,fe);return}V.set(E,{routeId:R,path:se}),pe(E,R,se,Ce,de,ne.active,K,Xe,fe)}async function mt(E,R,O,B,K,re,ce,de,ne){wt(),V.delete(E);function se(He){if(!He.route.action&&!He.route.lazy){let So=an(405,{method:ne.formMethod,pathname:O,routeId:R});return st(E,R,So,{flushSync:ce}),!0}return!1}if(!re&&se(B))return;let fe=C.fetchers.get(E);Ft(E,dD(ne,fe),{flushSync:ce});let ye=new AbortController,Ce=Ds(e.history,O,ye.signal,ne);if(re){let He=await Hn(K,new URL(Ce.url).pathname,Ce.signal,E);if(He.type==="aborted")return;if(He.type==="error"){st(E,R,He.error,{flushSync:ce});return}else if(He.matches){if(K=He.matches,B=Ul(K,O),se(B))return}else{st(E,R,an(404,{pathname:O}),{flushSync:ce});return}}_.set(E,ye);let Xe=F,Ne=(await Se("action",C,Ce,[B],K,E))[B.route.id];if(Ce.signal.aborted){_.get(E)===ye&&_.delete(E);return}if(f.v7_fetcherPersist&&Z.has(E)){if(qi(Ne)||yn(Ne)){Ft(E,Mo(void 0));return}}else{if(qi(Ne))if(_.delete(E),W>Xe){Ft(E,Mo(void 0));return}else return A.add(E),Ft(E,Ml(ne)),Oe(Ce,Ne,!1,{fetcherSubmission:ne,preventScrollReset:de});if(yn(Ne)){st(E,R,Ne.error);return}}if(Go(Ne))throw an(400,{type:"defer-action"});let at=C.navigation.location||C.location,wo=Ds(e.history,at,ye.signal),Pi=l||a,Vn=C.navigation.state!=="idle"?zi(Pi,C.navigation.location,c):C.matches;Me(Vn,"Didn't find any matches after fetcher action");let In=++F;te.set(E,In);let jl=Ml(ne,Ne.data);C.fetchers.set(E,jl);let[ko,gr]=tb(e.history,C,Vn,ne,at,!1,f.v7_skipActionErrorRevalidation,U,Q,J,Z,V,A,Pi,c,[B.route.id,Ne]);gr.filter(He=>He.key!==E).forEach(He=>{let So=He.key,xr=C.fetchers.get(So),Fr=Ml(void 0,xr?xr.data:void 0);C.fetchers.set(So,Fr),Dt(So),He.controller&&_.set(So,He.controller)}),Re({fetchers:new Map(C.fetchers)});let Ri=()=>gr.forEach(He=>Dt(He.key));ye.signal.addEventListener("abort",Ri);let{loaderResults:Ii,fetcherResults:$}=await pt(C,Vn,ko,gr,wo);if(ye.signal.aborted)return;ye.signal.removeEventListener("abort",Ri),te.delete(E),_.delete(E),gr.forEach(He=>_.delete(He.key));let ee=nu(Ii);if(ee)return Oe(wo,ee.result,!1,{preventScrollReset:de});if(ee=nu($),ee)return A.add(ee.key),Oe(wo,ee.result,!1,{preventScrollReset:de});let{loaderData:me,errors:Ke}=sb(C,Vn,Ii,void 0,gr,$,ie);if(C.fetchers.has(E)){let He=Mo(Ne.data);C.fetchers.set(E,He)}hr(In),C.navigation.state==="loading"&&In>W?(Me(P,"Expected pending action"),L&&L.abort(),xt(C.navigation.location,{matches:Vn,loaderData:me,errors:Ke,fetchers:new Map(C.fetchers)})):(Re({errors:Ke,loaderData:ab(C.loaderData,me,Vn,Ke),fetchers:new Map(C.fetchers)}),U=!1)}async function pe(E,R,O,B,K,re,ce,de,ne){let se=C.fetchers.get(E);Ft(E,Ml(ne,se?se.data:void 0),{flushSync:ce});let fe=new AbortController,ye=Ds(e.history,O,fe.signal);if(re){let Ne=await Hn(K,new URL(ye.url).pathname,ye.signal,E);if(Ne.type==="aborted")return;if(Ne.type==="error"){st(E,R,Ne.error,{flushSync:ce});return}else if(Ne.matches)K=Ne.matches,B=Ul(K,O);else{st(E,R,an(404,{pathname:O}),{flushSync:ce});return}}_.set(E,fe);let Ce=F,Ue=(await Se("loader",C,ye,[B],K,E))[B.route.id];if(Go(Ue)&&(Ue=await W0(Ue,ye.signal,!0)||Ue),_.get(E)===fe&&_.delete(E),!ye.signal.aborted){if(Z.has(E)){Ft(E,Mo(void 0));return}if(qi(Ue))if(W>Ce){Ft(E,Mo(void 0));return}else{A.add(E),await Oe(ye,Ue,!1,{preventScrollReset:de});return}if(yn(Ue)){st(E,R,Ue.error);return}Me(!Go(Ue),"Unhandled fetcher deferred data"),Ft(E,Mo(Ue.data))}}async function Oe(E,R,O,B){let{submission:K,fetcherSubmission:re,preventScrollReset:ce,replace:de}=B===void 0?{}:B;R.response.headers.has("X-Remix-Revalidate")&&(U=!0);let ne=R.response.headers.get("Location");Me(ne,"Expected a Location header on the redirect Response"),ne=ob(ne,new URL(E.url),c,e.history);let se=Ga(C.location,ne,{_isRedirect:!0});if(n){let Ne=!1;if(R.response.headers.has("X-Remix-Reload-Document"))Ne=!0;else if(B0.test(ne)){const at=e.history.createURL(ne);Ne=at.origin!==t.location.origin||cd(at.pathname,c)==null}if(Ne){de?t.location.replace(ne):t.location.assign(ne);return}}L=null;let fe=de===!0||R.response.headers.has("X-Remix-Replace")?kt.Replace:kt.Push,{formMethod:ye,formAction:Ce,formEncType:Xe}=C.navigation;!K&&!re&&ye&&Ce&&Xe&&(K=ub(C.navigation));let Ue=K||re;if(VA.has(R.response.status)&&Ue&&Jn(Ue.formMethod))await De(fe,se,{submission:nt({},Ue,{formAction:ne}),preventScrollReset:ce||I,enableViewTransition:O?z:void 0});else{let Ne=Th(se,K);await De(fe,se,{overrideNavigation:Ne,fetcherSubmission:re,preventScrollReset:ce||I,enableViewTransition:O?z:void 0})}}async function Se(E,R,O,B,K,re){let ce,de={};try{ce=await JA(d,E,R,O,B,K,re,s,i)}catch(ne){return B.forEach(se=>{de[se.route.id]={type:Be.error,error:ne}}),de}for(let[ne,se]of Object.entries(ce))if(oD(se)){let fe=se.result;de[ne]={type:Be.redirect,response:tD(fe,O,ne,K,c,f.v7_relativeSplatPath)}}else de[ne]=await eD(se);return de}async function pt(E,R,O,B,K){let re=E.matches,ce=Se("loader",E,K,O,R,null),de=Promise.all(B.map(async fe=>{if(fe.matches&&fe.match&&fe.controller){let Ce=(await Se("loader",E,Ds(e.history,fe.path,fe.controller.signal),[fe.match],fe.matches,fe.key))[fe.match.route.id];return{[fe.key]:Ce}}else return Promise.resolve({[fe.key]:{type:Be.error,error:an(404,{pathname:fe.path})}})})),ne=await ce,se=(await de).reduce((fe,ye)=>Object.assign(fe,ye),{});return await Promise.all([aD(R,ne,K.signal,re,E.loaderData),lD(R,se,B)]),{loaderResults:ne,fetcherResults:se}}function wt(){U=!0,Q.push(...bo()),V.forEach((E,R)=>{_.has(R)&&J.add(R),Dt(R)})}function Ft(E,R,O){O===void 0&&(O={}),C.fetchers.set(E,R),Re({fetchers:new Map(C.fetchers)},{flushSync:(O&&O.flushSync)===!0})}function st(E,R,O,B){B===void 0&&(B={});let K=Bi(C.matches,R);Dr(E),Re({errors:{[K.route.id]:O},fetchers:new Map(C.fetchers)},{flushSync:(B&&B.flushSync)===!0})}function pr(E){return oe.set(E,(oe.get(E)||0)+1),Z.has(E)&&Z.delete(E),C.fetchers.get(E)||qA}function Dr(E){let R=C.fetchers.get(E);_.has(E)&&!(R&&R.state==="loading"&&te.has(E))&&Dt(E),V.delete(E),te.delete(E),A.delete(E),f.v7_fetcherPersist&&Z.delete(E),J.delete(E),C.fetchers.delete(E)}function ws(E){let R=(oe.get(E)||0)-1;R<=0?(oe.delete(E),Z.add(E),f.v7_fetcherPersist||Dr(E)):oe.set(E,R),Re({fetchers:new Map(C.fetchers)})}function Dt(E){let R=_.get(E);R&&(R.abort(),_.delete(E))}function ks(E){for(let R of E){let O=pr(R),B=Mo(O.data);C.fetchers.set(R,B)}}function fr(){let E=[],R=!1;for(let O of A){let B=C.fetchers.get(O);Me(B,"Expected fetcher: "+O),B.state==="loading"&&(A.delete(O),E.push(O),R=!0)}return ks(E),R}function hr(E){let R=[];for(let[O,B]of te)if(B<E){let K=C.fetchers.get(O);Me(K,"Expected fetcher: "+O),K.state==="loading"&&(Dt(O),te.delete(O),R.push(O))}return ks(R),R.length>0}function vo(E,R){let O=C.blockers.get(E)||Il;return he.get(E)!==R&&he.set(E,R),O}function Ss(E){C.blockers.delete(E),he.delete(E)}function Nr(E,R){let O=C.blockers.get(E)||Il;Me(O.state==="unblocked"&&R.state==="blocked"||O.state==="blocked"&&R.state==="blocked"||O.state==="blocked"&&R.state==="proceeding"||O.state==="blocked"&&R.state==="unblocked"||O.state==="proceeding"&&R.state==="unblocked","Invalid blocker state transition: "+O.state+" -> "+R.state);let B=new Map(C.blockers);B.set(E,R),Re({blockers:B})}function Cs(E){let{currentLocation:R,nextLocation:O,historyAction:B}=E;if(he.size===0)return;he.size>1&&hi(!1,"A router only supports one blocker at a time");let K=Array.from(he.entries()),[re,ce]=K[K.length-1],de=C.blockers.get(re);if(!(de&&de.state==="proceeding")&&ce({currentLocation:R,nextLocation:O,historyAction:B}))return re}function yo(E){let R=an(404,{pathname:E}),O=l||a,{matches:B,route:K}=cb(O);return bo(),{notFoundMatches:B,route:K,error:R}}function bo(E){let R=[];return ie.forEach((O,B)=>{(!E||E(B))&&(O.cancel(),R.push(B),ie.delete(B))}),R}function Rn(E,R,O){if(v=E,b=R,x=O||null,!j&&C.navigation===Eh){j=!0;let B=jo(C.location,C.matches);B!=null&&Re({restoreScrollPosition:B})}return()=>{v=null,b=null,x=null}}function Es(E,R){return x&&x(E,R.map(B=>wA(B,C.loaderData)))||E.key}function Un(E,R){if(v&&b){let O=Es(E,R);v[O]=b()}}function jo(E,R){if(v){let O=Es(E,R),B=v[O];if(typeof B=="number")return B}return null}function _r(E,R,O){if(u)if(E){if(Object.keys(E[0].params).length>0)return{active:!0,matches:Au(R,O,c,!0)}}else return{active:!0,matches:Au(R,O,c,!0)||[]};return{active:!1,matches:null}}async function Hn(E,R,O,B){if(!u)return{type:"success",matches:E};let K=E;for(;;){let re=l==null,ce=l||a,de=s;try{await u({signal:O,path:R,matches:K,fetcherKey:B,patch:(fe,ye)=>{O.aborted||rb(fe,ye,ce,de,i)}})}catch(fe){return{type:"error",error:fe,partialMatches:K}}finally{re&&!O.aborted&&(a=[...a])}if(O.aborted)return{type:"aborted"};let ne=zi(ce,R,c);if(ne)return{type:"success",matches:ne};let se=Au(ce,R,c,!0);if(!se||K.length===se.length&&K.every((fe,ye)=>fe.route.id===se[ye].route.id))return{type:"success",matches:null};K=se}}function $r(E){s={},l=yp(E,i,void 0,s)}function bl(E,R){let O=l==null;rb(E,R,l||a,s,i),O&&(a=[...a],Re({}))}return T={get basename(){return c},get future(){return f},get state(){return C},get routes(){return a},get window(){return t},initialize:be,subscribe:At,enableScrollRestoration:Rn,navigate:we,fetch:Qt,revalidate:Ie,createHref:E=>e.history.createHref(E),encodeLocation:E=>e.history.encodeLocation(E),getFetcher:pr,deleteFetcher:ws,dispose:jt,getBlocker:vo,deleteBlocker:Ss,patchRoutes:bl,_internalFetchControllers:_,_internalActiveDeferreds:ie,_internalSetRoutes:$r},T}function QA(e){return e!=null&&("formData"in e&&e.formData!=null||"body"in e&&e.body!==void 0)}function Tx(e,t,n,r,i,s,a,l){let c,d;if(a){c=[];for(let f of t)if(c.push(f),f.route.id===a){d=f;break}}else c=t,d=t[t.length-1];let u=F0(i||".",$0(c,s),cd(e.pathname,n)||e.pathname,l==="path");if(i==null&&(u.search=e.search,u.hash=e.hash),(i==null||i===""||i===".")&&d){let f=U0(u.search);if(d.route.index&&!f)u.search=u.search?u.search.replace(/^\?/,"?index&"):"?index";else if(!d.route.index&&f){let h=new URLSearchParams(u.search),g=h.getAll("index");h.delete("index"),g.filter(x=>x).forEach(x=>h.append("index",x));let v=h.toString();u.search=v?"?"+v:""}}return r&&n!=="/"&&(u.pathname=u.pathname==="/"?n:si([n,u.pathname])),gl(u)}function Z1(e,t,n,r){if(!r||!QA(r))return{path:n};if(r.formMethod&&!sD(r.formMethod))return{path:n,error:an(405,{method:r.formMethod})};let i=()=>({path:n,error:an(400,{type:"invalid-body"})}),s=r.formMethod||"get",a=e?s.toUpperCase():s.toLowerCase(),l=C4(n);if(r.body!==void 0){if(r.formEncType==="text/plain"){if(!Jn(a))return i();let h=typeof r.body=="string"?r.body:r.body instanceof FormData||r.body instanceof URLSearchParams?Array.from(r.body.entries()).reduce((g,v)=>{let[x,b]=v;return""+g+x+"="+b+`
|
|
99
|
+
`},""):String(r.body);return{path:n,submission:{formMethod:a,formAction:l,formEncType:r.formEncType,formData:void 0,json:void 0,text:h}}}else if(r.formEncType==="application/json"){if(!Jn(a))return i();try{let h=typeof r.body=="string"?JSON.parse(r.body):r.body;return{path:n,submission:{formMethod:a,formAction:l,formEncType:r.formEncType,formData:void 0,json:h,text:void 0}}}catch{return i()}}}Me(typeof FormData=="function","FormData is not available in this environment");let c,d;if(r.formData)c=Rx(r.formData),d=r.formData;else if(r.body instanceof FormData)c=Rx(r.body),d=r.body;else if(r.body instanceof URLSearchParams)c=r.body,d=ib(c);else if(r.body==null)c=new URLSearchParams,d=new FormData;else try{c=new URLSearchParams(r.body),d=ib(c)}catch{return i()}let u={formMethod:a,formAction:l,formEncType:r&&r.formEncType||"application/x-www-form-urlencoded",formData:d,json:void 0,text:void 0};if(Jn(u.formMethod))return{path:n,submission:u};let f=xo(n);return t&&f.search&&U0(f.search)&&c.append("index",""),f.search="?"+c,{path:gl(f),submission:u}}function eb(e,t,n){n===void 0&&(n=!1);let r=e.findIndex(i=>i.route.id===t);return r>=0?e.slice(0,n?r+1:r):e}function tb(e,t,n,r,i,s,a,l,c,d,u,f,h,g,v,x){let b=x?yn(x[1])?x[1].error:x[1].data:void 0,j=e.createURL(t.location),y=e.createURL(i),w=n;s&&t.errors?w=eb(n,Object.keys(t.errors)[0],!0):x&&yn(x[1])&&(w=eb(n,x[0]));let k=x?x[1].statusCode:void 0,S=a&&k&&k>=400,T=w.filter((P,I)=>{let{route:L}=P;if(L.lazy)return!0;if(L.loader==null)return!1;if(s)return Px(L,t.loaderData,t.errors);if(YA(t.loaderData,t.matches[I],P)||c.some(X=>X===P.route.id))return!0;let z=t.matches[I],q=P;return nb(P,nt({currentUrl:j,currentParams:z.params,nextUrl:y,nextParams:q.params},r,{actionResult:b,actionStatus:k,defaultShouldRevalidate:S?!1:l||j.pathname+j.search===y.pathname+y.search||j.search!==y.search||k4(z,q)}))}),C=[];return f.forEach((P,I)=>{if(s||!n.some(D=>D.route.id===P.routeId)||u.has(I))return;let L=zi(g,P.path,v);if(!L){C.push({key:I,routeId:P.routeId,path:P.path,matches:null,match:null,controller:null});return}let z=t.fetchers.get(I),q=Ul(L,P.path),X=!1;h.has(I)?X=!1:d.has(I)?(d.delete(I),X=!0):z&&z.state!=="idle"&&z.data===void 0?X=l:X=nb(q,nt({currentUrl:j,currentParams:t.matches[t.matches.length-1].params,nextUrl:y,nextParams:n[n.length-1].params},r,{actionResult:b,actionStatus:k,defaultShouldRevalidate:S?!1:l})),X&&C.push({key:I,routeId:P.routeId,path:P.path,matches:L,match:q,controller:new AbortController})}),[T,C]}function Px(e,t,n){if(e.lazy)return!0;if(!e.loader)return!1;let r=t!=null&&t[e.id]!==void 0,i=n!=null&&n[e.id]!==void 0;return!r&&i?!1:typeof e.loader=="function"&&e.loader.hydrate===!0?!0:!r&&!i}function YA(e,t,n){let r=!t||n.route.id!==t.route.id,i=e[n.route.id]===void 0;return r||i}function k4(e,t){let n=e.route.path;return e.pathname!==t.pathname||n!=null&&n.endsWith("*")&&e.params["*"]!==t.params["*"]}function nb(e,t){if(e.route.shouldRevalidate){let n=e.route.shouldRevalidate(t);if(typeof n=="boolean")return n}return t.defaultShouldRevalidate}function rb(e,t,n,r,i){var s;let a;if(e){let d=r[e];Me(d,"No route found to patch children into: routeId = "+e),d.children||(d.children=[]),a=d.children}else a=n;let l=t.filter(d=>!a.some(u=>S4(d,u))),c=yp(l,i,[e||"_","patch",String(((s=a)==null?void 0:s.length)||"0")],r);a.push(...c)}function S4(e,t){return"id"in e&&"id"in t&&e.id===t.id?!0:e.index===t.index&&e.path===t.path&&e.caseSensitive===t.caseSensitive?(!e.children||e.children.length===0)&&(!t.children||t.children.length===0)?!0:e.children.every((n,r)=>{var i;return(i=t.children)==null?void 0:i.some(s=>S4(n,s))}):!1}async function GA(e,t,n){if(!e.lazy)return;let r=await e.lazy();if(!e.lazy)return;let i=n[e.id];Me(i,"No route found in manifest");let s={};for(let a in r){let c=i[a]!==void 0&&a!=="hasErrorBoundary";hi(!c,'Route "'+i.id+'" has a static property "'+a+'" defined but its lazy function is also returning a value for this property. '+('The lazy route property "'+a+'" will be ignored.')),!c&&!bA.has(a)&&(s[a]=r[a])}Object.assign(i,s),Object.assign(i,nt({},t(i),{lazy:void 0}))}async function XA(e){let{matches:t}=e,n=t.filter(i=>i.shouldLoad);return(await Promise.all(n.map(i=>i.resolve()))).reduce((i,s,a)=>Object.assign(i,{[n[a].route.id]:s}),{})}async function JA(e,t,n,r,i,s,a,l,c,d){let u=s.map(g=>g.route.lazy?GA(g.route,c,l):void 0),f=s.map((g,v)=>{let x=u[v],b=i.some(y=>y.route.id===g.route.id);return nt({},g,{shouldLoad:b,resolve:async y=>(y&&r.method==="GET"&&(g.route.lazy||g.route.loader)&&(b=!0),b?ZA(t,r,g,x,y,d):Promise.resolve({type:Be.data,result:void 0}))})}),h=await e({matches:f,request:r,params:s[0].params,fetcherKey:a,context:d});try{await Promise.all(u)}catch{}return h}async function ZA(e,t,n,r,i,s){let a,l,c=d=>{let u,f=new Promise((v,x)=>u=x);l=()=>u(),t.signal.addEventListener("abort",l);let h=v=>typeof d!="function"?Promise.reject(new Error("You cannot call the handler for a route which defines a boolean "+('"'+e+'" [routeId: '+n.route.id+"]"))):d({request:t,params:n.params,context:s},...v!==void 0?[v]:[]),g=(async()=>{try{return{type:"data",result:await(i?i(x=>h(x)):h())}}catch(v){return{type:"error",result:v}}})();return Promise.race([g,f])};try{let d=n.route[e];if(r)if(d){let u,[f]=await Promise.all([c(d).catch(h=>{u=h}),r]);if(u!==void 0)throw u;a=f}else if(await r,d=n.route[e],d)a=await c(d);else if(e==="action"){let u=new URL(t.url),f=u.pathname+u.search;throw an(405,{method:t.method,pathname:f,routeId:n.route.id})}else return{type:Be.data,result:void 0};else if(d)a=await c(d);else{let u=new URL(t.url),f=u.pathname+u.search;throw an(404,{pathname:f})}Me(a.result!==void 0,"You defined "+(e==="action"?"an action":"a loader")+" for route "+('"'+n.route.id+"\" but didn't return anything from your `"+e+"` ")+"function. Please return a value or `null`.")}catch(d){return{type:Be.error,result:d}}finally{l&&t.signal.removeEventListener("abort",l)}return a}async function eD(e){let{result:t,type:n}=e;if(E4(t)){let f;try{let h=t.headers.get("Content-Type");h&&/\bapplication\/json\b/.test(h)?t.body==null?f=null:f=await t.json():f=await t.text()}catch(h){return{type:Be.error,error:h}}return n===Be.error?{type:Be.error,error:new bp(t.status,t.statusText,f),statusCode:t.status,headers:t.headers}:{type:Be.data,data:f,statusCode:t.status,headers:t.headers}}if(n===Be.error){if(db(t)){var r,i;if(t.data instanceof Error){var s,a;return{type:Be.error,error:t.data,statusCode:(s=t.init)==null?void 0:s.status,headers:(a=t.init)!=null&&a.headers?new Headers(t.init.headers):void 0}}return{type:Be.error,error:new bp(((r=t.init)==null?void 0:r.status)||500,void 0,t.data),statusCode:Ac(t)?t.status:void 0,headers:(i=t.init)!=null&&i.headers?new Headers(t.init.headers):void 0}}return{type:Be.error,error:t,statusCode:Ac(t)?t.status:void 0}}if(iD(t)){var l,c;return{type:Be.deferred,deferredData:t,statusCode:(l=t.init)==null?void 0:l.status,headers:((c=t.init)==null?void 0:c.headers)&&new Headers(t.init.headers)}}if(db(t)){var d,u;return{type:Be.data,data:t.data,statusCode:(d=t.init)==null?void 0:d.status,headers:(u=t.init)!=null&&u.headers?new Headers(t.init.headers):void 0}}return{type:Be.data,data:t}}function tD(e,t,n,r,i,s){let a=e.headers.get("Location");if(Me(a,"Redirects returned/thrown from loaders/actions must have a Location header"),!B0.test(a)){let l=r.slice(0,r.findIndex(c=>c.route.id===n)+1);a=Tx(new URL(t.url),l,i,!0,a,s),e.headers.set("Location",a)}return e}function ob(e,t,n,r){let i=["about:","blob:","chrome:","chrome-untrusted:","content:","data:","devtools:","file:","filesystem:","javascript:"];if(B0.test(e)){let s=e,a=s.startsWith("//")?new URL(t.protocol+s):new URL(s);if(i.includes(a.protocol))throw new Error("Invalid redirect location");let l=cd(a.pathname,n)!=null;if(a.origin===t.origin&&l)return z0(a.pathname)+a.search+a.hash}try{let s=r.createURL(e);if(i.includes(s.protocol))throw new Error("Invalid redirect location")}catch{}return e}function Ds(e,t,n,r){let i=e.createURL(C4(t)).toString(),s={signal:n};if(r&&Jn(r.formMethod)){let{formMethod:a,formEncType:l}=r;s.method=a.toUpperCase(),l==="application/json"?(s.headers=new Headers({"Content-Type":l}),s.body=JSON.stringify(r.json)):l==="text/plain"?s.body=r.text:l==="application/x-www-form-urlencoded"&&r.formData?s.body=Rx(r.formData):s.body=r.formData}return new Request(i,s)}function Rx(e){let t=new URLSearchParams;for(let[n,r]of e.entries())t.append(n,typeof r=="string"?r:r.name);return t}function ib(e){let t=new FormData;for(let[n,r]of e.entries())t.append(n,r);return t}function nD(e,t,n,r,i){let s={},a=null,l,c=!1,d={},u=n&&yn(n[1])?n[1].error:void 0;return e.forEach(f=>{if(!(f.route.id in t))return;let h=f.route.id,g=t[h];if(Me(!qi(g),"Cannot handle redirect results in processLoaderData"),yn(g)){let v=g.error;u!==void 0&&(v=u,u=void 0),a=a||{};{let x=Bi(e,h);a[x.route.id]==null&&(a[x.route.id]=v)}s[h]=void 0,c||(c=!0,l=Ac(g.error)?g.error.status:500),g.headers&&(d[h]=g.headers)}else Go(g)?(r.set(h,g.deferredData),s[h]=g.deferredData.data,g.statusCode!=null&&g.statusCode!==200&&!c&&(l=g.statusCode),g.headers&&(d[h]=g.headers)):(s[h]=g.data,g.statusCode&&g.statusCode!==200&&!c&&(l=g.statusCode),g.headers&&(d[h]=g.headers))}),u!==void 0&&n&&(a={[n[0]]:u},s[n[0]]=void 0),{loaderData:s,errors:a,statusCode:l||200,loaderHeaders:d}}function sb(e,t,n,r,i,s,a){let{loaderData:l,errors:c}=nD(t,n,r,a);return i.forEach(d=>{let{key:u,match:f,controller:h}=d,g=s[u];if(Me(g,"Did not find corresponding fetcher result"),!(h&&h.signal.aborted))if(yn(g)){let v=Bi(e.matches,f==null?void 0:f.route.id);c&&c[v.route.id]||(c=nt({},c,{[v.route.id]:g.error})),e.fetchers.delete(u)}else if(qi(g))Me(!1,"Unhandled fetcher revalidation redirect");else if(Go(g))Me(!1,"Unhandled fetcher deferred data");else{let v=Mo(g.data);e.fetchers.set(u,v)}}),{loaderData:l,errors:c}}function ab(e,t,n,r){let i=nt({},t);for(let s of n){let a=s.route.id;if(t.hasOwnProperty(a)?t[a]!==void 0&&(i[a]=t[a]):e[a]!==void 0&&s.route.loader&&(i[a]=e[a]),r&&r.hasOwnProperty(a))break}return i}function lb(e){return e?yn(e[1])?{actionData:{}}:{actionData:{[e[0]]:e[1].data}}:{}}function Bi(e,t){return(t?e.slice(0,e.findIndex(r=>r.route.id===t)+1):[...e]).reverse().find(r=>r.route.hasErrorBoundary===!0)||e[0]}function cb(e){let t=e.length===1?e[0]:e.find(n=>n.index||!n.path||n.path==="/")||{id:"__shim-error-route__"};return{matches:[{params:{},pathname:"",pathnameBase:"",route:t}],route:t}}function an(e,t){let{pathname:n,routeId:r,method:i,type:s,message:a}=t===void 0?{}:t,l="Unknown Server Error",c="Unknown @remix-run/router error";return e===400?(l="Bad Request",i&&n&&r?c="You made a "+i+' request to "'+n+'" but '+('did not provide a `loader` for route "'+r+'", ')+"so there is no way to handle the request.":s==="defer-action"?c="defer() is not supported in actions":s==="invalid-body"&&(c="Unable to encode submission body")):e===403?(l="Forbidden",c='Route "'+r+'" does not match URL "'+n+'"'):e===404?(l="Not Found",c='No route matches URL "'+n+'"'):e===405&&(l="Method Not Allowed",i&&n&&r?c="You made a "+i.toUpperCase()+' request to "'+n+'" but '+('did not provide an `action` for route "'+r+'", ')+"so there is no way to handle the request.":i&&(c='Invalid request method "'+i.toUpperCase()+'"')),new bp(e||500,l,new Error(c),!0)}function nu(e){let t=Object.entries(e);for(let n=t.length-1;n>=0;n--){let[r,i]=t[n];if(qi(i))return{key:r,result:i}}}function C4(e){let t=typeof e=="string"?xo(e):e;return gl(nt({},t,{hash:""}))}function rD(e,t){return e.pathname!==t.pathname||e.search!==t.search?!1:e.hash===""?t.hash!=="":e.hash===t.hash?!0:t.hash!==""}function oD(e){return E4(e.result)&&HA.has(e.result.status)}function Go(e){return e.type===Be.deferred}function yn(e){return e.type===Be.error}function qi(e){return(e&&e.type)===Be.redirect}function db(e){return typeof e=="object"&&e!=null&&"type"in e&&"data"in e&&"init"in e&&e.type==="DataWithResponseInit"}function iD(e){let t=e;return t&&typeof t=="object"&&typeof t.data=="object"&&typeof t.subscribe=="function"&&typeof t.cancel=="function"&&typeof t.resolveData=="function"}function E4(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.headers=="object"&&typeof e.body<"u"}function sD(e){return UA.has(e.toLowerCase())}function Jn(e){return BA.has(e.toLowerCase())}async function aD(e,t,n,r,i){let s=Object.entries(t);for(let a=0;a<s.length;a++){let[l,c]=s[a],d=e.find(h=>(h==null?void 0:h.route.id)===l);if(!d)continue;let u=r.find(h=>h.route.id===d.route.id),f=u!=null&&!k4(u,d)&&(i&&i[d.route.id])!==void 0;Go(c)&&f&&await W0(c,n,!1).then(h=>{h&&(t[l]=h)})}}async function lD(e,t,n){for(let r=0;r<n.length;r++){let{key:i,routeId:s,controller:a}=n[r],l=t[i];e.find(d=>(d==null?void 0:d.route.id)===s)&&Go(l)&&(Me(a,"Expected an AbortController for revalidating fetcher deferred result"),await W0(l,a.signal,!0).then(d=>{d&&(t[i]=d)}))}}async function W0(e,t,n){if(n===void 0&&(n=!1),!await e.deferredData.resolveData(t)){if(n)try{return{type:Be.data,data:e.deferredData.unwrappedData}}catch(i){return{type:Be.error,error:i}}return{type:Be.data,data:e.deferredData.data}}}function U0(e){return new URLSearchParams(e).getAll("index").some(t=>t==="")}function Ul(e,t){let n=typeof t=="string"?xo(t).search:t.search;if(e[e.length-1].route.index&&U0(n||""))return e[e.length-1];let r=y4(e);return r[r.length-1]}function ub(e){let{formMethod:t,formAction:n,formEncType:r,text:i,formData:s,json:a}=e;if(!(!t||!n||!r)){if(i!=null)return{formMethod:t,formAction:n,formEncType:r,formData:void 0,json:void 0,text:i};if(s!=null)return{formMethod:t,formAction:n,formEncType:r,formData:s,json:void 0,text:void 0};if(a!==void 0)return{formMethod:t,formAction:n,formEncType:r,formData:void 0,json:a,text:void 0}}}function Th(e,t){return t?{state:"loading",location:e,formMethod:t.formMethod,formAction:t.formAction,formEncType:t.formEncType,formData:t.formData,json:t.json,text:t.text}:{state:"loading",location:e,formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0}}function cD(e,t){return{state:"submitting",location:e,formMethod:t.formMethod,formAction:t.formAction,formEncType:t.formEncType,formData:t.formData,json:t.json,text:t.text}}function Ml(e,t){return e?{state:"loading",formMethod:e.formMethod,formAction:e.formAction,formEncType:e.formEncType,formData:e.formData,json:e.json,text:e.text,data:t}:{state:"loading",formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0,data:t}}function dD(e,t){return{state:"submitting",formMethod:e.formMethod,formAction:e.formAction,formEncType:e.formEncType,formData:e.formData,json:e.json,text:e.text,data:t?t.data:void 0}}function Mo(e){return{state:"idle",formMethod:void 0,formAction:void 0,formEncType:void 0,formData:void 0,json:void 0,text:void 0,data:e}}function uD(e,t){try{let n=e.sessionStorage.getItem(j4);if(n){let r=JSON.parse(n);for(let[i,s]of Object.entries(r||{}))s&&Array.isArray(s)&&t.set(i,new Set(s||[]))}}catch{}}function pD(e,t){if(t.size>0){let n={};for(let[r,i]of t)n[r]=[...i];try{e.sessionStorage.setItem(j4,JSON.stringify(n))}catch(r){hi(!1,"Failed to save applied view transitions in sessionStorage ("+r+").")}}}/**
|
|
100
|
+
* React Router v6.30.4
|
|
101
|
+
*
|
|
102
|
+
* Copyright (c) Remix Software Inc.
|
|
103
|
+
*
|
|
104
|
+
* This source code is licensed under the MIT license found in the
|
|
105
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
106
|
+
*
|
|
107
|
+
* @license MIT
|
|
108
|
+
*/function jp(){return jp=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},jp.apply(null,arguments)}const ff=p.createContext(null),T4=p.createContext(null),dd=p.createContext(null),hf=p.createContext(null),mo=p.createContext({outlet:null,matches:[],isDataRoute:!1}),P4=p.createContext(null);function ud(){return p.useContext(hf)!=null}function ur(){return ud()||Me(!1),p.useContext(hf).location}function fD(){return p.useContext(hf).navigationType}function R4(e){p.useContext(dd).static||p.useLayoutEffect(e)}function ze(){let{isDataRoute:e}=p.useContext(mo);return e?ED():hD()}function hD(){ud()||Me(!1);let e=p.useContext(ff),{basename:t,future:n,navigator:r}=p.useContext(dd),{matches:i}=p.useContext(mo),{pathname:s}=ur(),a=JSON.stringify($0(i,n.v7_relativeSplatPath)),l=p.useRef(!1);return R4(()=>{l.current=!0}),p.useCallback(function(d,u){if(u===void 0&&(u={}),!l.current)return;if(typeof d=="number"){r.go(d);return}let f=F0(d,JSON.parse(a),s,u.relative==="path");e==null&&t!=="/"&&(f.pathname=f.pathname==="/"?t:si([t,f.pathname])),(u.replace?r.replace:r.push)(f,u.state,u)},[t,r,a,s,e])}const gD=p.createContext(null);function I4(e){let t=p.useContext(mo).outlet;return t&&p.createElement(gD.Provider,{value:e},t)}function gf(){let{matches:e}=p.useContext(mo),t=e[e.length-1];return t?t.params:{}}function xD(e,t,n,r){ud()||Me(!1);let{navigator:i}=p.useContext(dd),{matches:s}=p.useContext(mo),a=s[s.length-1],l=a?a.params:{};a&&a.pathname;let c=a?a.pathnameBase:"/";a&&a.route;let d=ur(),u;u=d;let f=u.pathname||"/",h=f;if(c!=="/"){let x=c.replace(/^\//,"").split("/");h="/"+f.replace(/^\//,"").split("/").slice(x.length).join("/")}let g=zi(e,{pathname:h});return jD(g&&g.map(x=>Object.assign({},x,{params:Object.assign({},l,x.params),pathname:si([c,i.encodeLocation?i.encodeLocation(x.pathname).pathname:x.pathname]),pathnameBase:x.pathnameBase==="/"?c:si([c,i.encodeLocation?i.encodeLocation(x.pathnameBase).pathname:x.pathnameBase])})),s,n,r)}function mD(){let e=CD(),t=Ac(e)?e.status+" "+e.statusText:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,i={padding:"0.5rem",backgroundColor:"rgba(200,200,200, 0.5)"};return p.createElement(p.Fragment,null,p.createElement("h2",null,"Unexpected Application Error!"),p.createElement("h3",{style:{fontStyle:"italic"}},t),n?p.createElement("pre",{style:i},n):null,null)}const vD=p.createElement(mD,null);class yD extends p.Component{constructor(t){super(t),this.state={location:t.location,revalidation:t.revalidation,error:t.error}}static getDerivedStateFromError(t){return{error:t}}static getDerivedStateFromProps(t,n){return n.location!==t.location||n.revalidation!=="idle"&&t.revalidation==="idle"?{error:t.error,location:t.location,revalidation:t.revalidation}:{error:t.error!==void 0?t.error:n.error,location:n.location,revalidation:t.revalidation||n.revalidation}}componentDidCatch(t,n){console.error("React Router caught the following error during render",t,n)}render(){return this.state.error!==void 0?p.createElement(mo.Provider,{value:this.props.routeContext},p.createElement(P4.Provider,{value:this.state.error,children:this.props.component})):this.props.children}}function bD(e){let{routeContext:t,match:n,children:r}=e,i=p.useContext(ff);return i&&i.static&&i.staticContext&&(n.route.errorElement||n.route.ErrorBoundary)&&(i.staticContext._deepestRenderedBoundaryId=n.route.id),p.createElement(mo.Provider,{value:t},r)}function jD(e,t,n,r){var i;if(t===void 0&&(t=[]),n===void 0&&(n=null),r===void 0&&(r=null),e==null){var s;if(!n)return null;if(n.errors)e=n.matches;else if((s=r)!=null&&s.v7_partialHydration&&t.length===0&&!n.initialized&&n.matches.length>0)e=n.matches;else return null}let a=e,l=(i=n)==null?void 0:i.errors;if(l!=null){let u=a.findIndex(f=>f.route.id&&(l==null?void 0:l[f.route.id])!==void 0);u>=0||Me(!1),a=a.slice(0,Math.min(a.length,u+1))}let c=!1,d=-1;if(n&&r&&r.v7_partialHydration)for(let u=0;u<a.length;u++){let f=a[u];if((f.route.HydrateFallback||f.route.hydrateFallbackElement)&&(d=u),f.route.id){let{loaderData:h,errors:g}=n,v=f.route.loader&&h[f.route.id]===void 0&&(!g||g[f.route.id]===void 0);if(f.route.lazy||v){c=!0,d>=0?a=a.slice(0,d+1):a=[a[0]];break}}}return a.reduceRight((u,f,h)=>{let g,v=!1,x=null,b=null;n&&(g=l&&f.route.id?l[f.route.id]:void 0,x=f.route.errorElement||vD,c&&(d<0&&h===0?(TD("route-fallback"),v=!0,b=null):d===h&&(v=!0,b=f.route.hydrateFallbackElement||null)));let j=t.concat(a.slice(0,h+1)),y=()=>{let w;return g?w=x:v?w=b:f.route.Component?w=p.createElement(f.route.Component,null):f.route.element?w=f.route.element:w=u,p.createElement(bD,{match:f,routeContext:{outlet:u,matches:j,isDataRoute:n!=null},children:w})};return n&&(f.route.ErrorBoundary||f.route.errorElement||h===0)?p.createElement(yD,{location:n.location,revalidation:n.revalidation,component:x,error:g,children:y(),routeContext:{outlet:null,matches:j,isDataRoute:!0}}):y()},null)}var M4=function(e){return e.UseBlocker="useBlocker",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e}(M4||{}),L4=function(e){return e.UseBlocker="useBlocker",e.UseLoaderData="useLoaderData",e.UseActionData="useActionData",e.UseRouteError="useRouteError",e.UseNavigation="useNavigation",e.UseRouteLoaderData="useRouteLoaderData",e.UseMatches="useMatches",e.UseRevalidator="useRevalidator",e.UseNavigateStable="useNavigate",e.UseRouteId="useRouteId",e}(L4||{});function wD(e){let t=p.useContext(ff);return t||Me(!1),t}function kD(e){let t=p.useContext(T4);return t||Me(!1),t}function SD(e){let t=p.useContext(mo);return t||Me(!1),t}function O4(e){let t=SD(),n=t.matches[t.matches.length-1];return n.route.id||Me(!1),n.route.id}function CD(){var e;let t=p.useContext(P4),n=kD(L4.UseRouteError),r=O4();return t!==void 0?t:(e=n.errors)==null?void 0:e[r]}function ED(){let{router:e}=wD(M4.UseNavigateStable),t=O4(),n=p.useRef(!1);return R4(()=>{n.current=!0}),p.useCallback(function(i,s){s===void 0&&(s={}),n.current&&(typeof i=="number"?e.navigate(i):e.navigate(i,jp({fromRouteId:t},s)))},[e,t])}const pb={};function TD(e,t,n){pb[e]||(pb[e]=!0)}function PD(e,t){e==null||e.v7_startTransition,(e==null?void 0:e.v7_relativeSplatPath)===void 0&&(!t||t.v7_relativeSplatPath),t&&(t.v7_fetcherPersist,t.v7_normalizeFormMethod,t.v7_partialHydration,t.v7_skipActionErrorRevalidation)}function Ix(e){let{to:t,replace:n,state:r,relative:i}=e;ud()||Me(!1);let{future:s,static:a}=p.useContext(dd),{matches:l}=p.useContext(mo),{pathname:c}=ur(),d=ze(),u=F0(t,$0(l,s.v7_relativeSplatPath),c,i==="path"),f=JSON.stringify(u);return p.useEffect(()=>d(JSON.parse(f),{replace:n,state:r,relative:i}),[d,f,i,n,r]),null}function RD(e){return I4(e.context)}function ID(e){let{basename:t="/",children:n=null,location:r,navigationType:i=kt.Pop,navigator:s,static:a=!1,future:l}=e;ud()&&Me(!1);let c=t.replace(/^\/*/,"/"),d=p.useMemo(()=>({basename:c,navigator:s,static:a,future:jp({v7_relativeSplatPath:!1},l)}),[c,l,s,a]);typeof r=="string"&&(r=xo(r));let{pathname:u="/",search:f="",hash:h="",state:g=null,key:v="default"}=r,x=p.useMemo(()=>{let b=cd(u,c);return b==null?null:{location:{pathname:b,search:f,hash:h,state:g,key:v},navigationType:i}},[c,u,f,h,g,v,i]);return x==null?null:p.createElement(dd.Provider,{value:d},p.createElement(hf.Provider,{children:n,value:x}))}new Promise(()=>{});function A4(e){let t={hasErrorBoundary:e.ErrorBoundary!=null||e.errorElement!=null};return e.Component&&Object.assign(t,{element:p.createElement(e.Component),Component:void 0}),e.HydrateFallback&&Object.assign(t,{hydrateFallbackElement:p.createElement(e.HydrateFallback),HydrateFallback:void 0}),e.ErrorBoundary&&Object.assign(t,{errorElement:p.createElement(e.ErrorBoundary),ErrorBoundary:void 0}),t}/**
|
|
109
|
+
* React Router DOM v6.30.4
|
|
110
|
+
*
|
|
111
|
+
* Copyright (c) Remix Software Inc.
|
|
112
|
+
*
|
|
113
|
+
* This source code is licensed under the MIT license found in the
|
|
114
|
+
* LICENSE.md file in the root directory of this source tree.
|
|
115
|
+
*
|
|
116
|
+
* @license MIT
|
|
117
|
+
*/function Dc(){return Dc=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Dc.apply(null,arguments)}function Mx(e){return e===void 0&&(e=""),new URLSearchParams(typeof e=="string"||Array.isArray(e)||e instanceof URLSearchParams?e:Object.keys(e).reduce((t,n)=>{let r=e[n];return t.concat(Array.isArray(r)?r.map(i=>[n,i]):[[n,r]])},[]))}function MD(e,t){let n=Mx(e);return t&&t.forEach((r,i)=>{n.has(i)||t.getAll(i).forEach(s=>{n.append(i,s)})}),n}const LD="6";try{window.__reactRouterVersion=LD}catch{}function D4(e,t){return w4({basename:t==null?void 0:t.basename,future:Dc({},t==null?void 0:t.future,{v7_prependBasename:!0}),history:mA({window:t==null?void 0:t.window}),hydrationData:(t==null?void 0:t.hydrationData)||_4(),routes:e,mapRouteProperties:A4,dataStrategy:t==null?void 0:t.dataStrategy,patchRoutesOnNavigation:t==null?void 0:t.patchRoutesOnNavigation,window:t==null?void 0:t.window}).initialize()}function N4(e,t){return w4({basename:t==null?void 0:t.basename,future:Dc({},t==null?void 0:t.future,{v7_prependBasename:!0}),history:vA({window:t==null?void 0:t.window}),hydrationData:(t==null?void 0:t.hydrationData)||_4(),routes:e,mapRouteProperties:A4,dataStrategy:t==null?void 0:t.dataStrategy,patchRoutesOnNavigation:t==null?void 0:t.patchRoutesOnNavigation,window:t==null?void 0:t.window}).initialize()}function _4(){var e;let t=(e=window)==null?void 0:e.__staticRouterHydrationData;return t&&t.errors&&(t=Dc({},t,{errors:OD(t.errors)})),t}function OD(e){if(!e)return null;let t=Object.entries(e),n={};for(let[r,i]of t)if(i&&i.__type==="RouteErrorResponse")n[r]=new bp(i.status,i.statusText,i.data,i.internal===!0);else if(i&&i.__type==="Error"){if(i.__subType){let s=window[i.__subType];if(typeof s=="function")try{let a=new s(i.message);a.stack="",n[r]=a}catch{}}if(n[r]==null){let s=new Error(i.message);s.stack="",n[r]=s}}else n[r]=i;return n}const AD=p.createContext({isTransitioning:!1}),DD=p.createContext(new Map),ND="startTransition",fb=il[ND],_D="flushSync",hb=MP[_D];function $D(e){fb?fb(e):e()}function Ll(e){hb?hb(e):e()}class FD{constructor(){this.status="pending",this.promise=new Promise((t,n)=>{this.resolve=r=>{this.status==="pending"&&(this.status="resolved",t(r))},this.reject=r=>{this.status==="pending"&&(this.status="rejected",n(r))}})}}function zD(e){let{fallbackElement:t,router:n,future:r}=e,[i,s]=p.useState(n.state),[a,l]=p.useState(),[c,d]=p.useState({isTransitioning:!1}),[u,f]=p.useState(),[h,g]=p.useState(),[v,x]=p.useState(),b=p.useRef(new Map),{v7_startTransition:j}=r||{},y=p.useCallback(P=>{j?$D(P):P()},[j]),w=p.useCallback((P,I)=>{let{deletedFetchers:L,flushSync:z,viewTransitionOpts:q}=I;P.fetchers.forEach((D,U)=>{D.data!==void 0&&b.current.set(U,D.data)}),L.forEach(D=>b.current.delete(D));let X=n.window==null||n.window.document==null||typeof n.window.document.startViewTransition!="function";if(!q||X){z?Ll(()=>s(P)):y(()=>s(P));return}if(z){Ll(()=>{h&&(u&&u.resolve(),h.skipTransition()),d({isTransitioning:!0,flushSync:!0,currentLocation:q.currentLocation,nextLocation:q.nextLocation})});let D=n.window.document.startViewTransition(()=>{Ll(()=>s(P))});D.finished.finally(()=>{Ll(()=>{f(void 0),g(void 0),l(void 0),d({isTransitioning:!1})})}),Ll(()=>g(D));return}h?(u&&u.resolve(),h.skipTransition(),x({state:P,currentLocation:q.currentLocation,nextLocation:q.nextLocation})):(l(P),d({isTransitioning:!0,flushSync:!1,currentLocation:q.currentLocation,nextLocation:q.nextLocation}))},[n.window,h,u,b,y]);p.useLayoutEffect(()=>n.subscribe(w),[n,w]),p.useEffect(()=>{c.isTransitioning&&!c.flushSync&&f(new FD)},[c]),p.useEffect(()=>{if(u&&a&&n.window){let P=a,I=u.promise,L=n.window.document.startViewTransition(async()=>{y(()=>s(P)),await I});L.finished.finally(()=>{f(void 0),g(void 0),l(void 0),d({isTransitioning:!1})}),g(L)}},[y,a,u,n.window]),p.useEffect(()=>{u&&a&&i.location.key===a.location.key&&u.resolve()},[u,h,i.location,a]),p.useEffect(()=>{!c.isTransitioning&&v&&(l(v.state),d({isTransitioning:!0,flushSync:!1,currentLocation:v.currentLocation,nextLocation:v.nextLocation}),x(void 0))},[c.isTransitioning,v]),p.useEffect(()=>{},[]);let k=p.useMemo(()=>({createHref:n.createHref,encodeLocation:n.encodeLocation,go:P=>n.navigate(P),push:(P,I,L)=>n.navigate(P,{state:I,preventScrollReset:L==null?void 0:L.preventScrollReset}),replace:(P,I,L)=>n.navigate(P,{replace:!0,state:I,preventScrollReset:L==null?void 0:L.preventScrollReset})}),[n]),S=n.basename||"/",T=p.useMemo(()=>({router:n,navigator:k,static:!1,basename:S}),[n,k,S]),C=p.useMemo(()=>({v7_relativeSplatPath:n.future.v7_relativeSplatPath}),[n.future.v7_relativeSplatPath]);return p.useEffect(()=>PD(r,n.future),[r,n.future]),p.createElement(p.Fragment,null,p.createElement(ff.Provider,{value:T},p.createElement(T4.Provider,{value:i},p.createElement(DD.Provider,{value:b.current},p.createElement(AD.Provider,{value:c},p.createElement(ID,{basename:S,location:i.location,navigationType:i.historyAction,navigator:k,future:C},i.initialized||n.future.v7_partialHydration?p.createElement(BD,{routes:n.routes,future:n.future,state:i}):t))))),null)}const BD=p.memo(WD);function WD(e){let{routes:t,future:n,state:r}=e;return xD(t,void 0,r,n)}var gb;(function(e){e.UseScrollRestoration="useScrollRestoration",e.UseSubmit="useSubmit",e.UseSubmitFetcher="useSubmitFetcher",e.UseFetcher="useFetcher",e.useViewTransitionState="useViewTransitionState"})(gb||(gb={}));var xb;(function(e){e.UseFetcher="useFetcher",e.UseFetchers="useFetchers",e.UseScrollRestoration="useScrollRestoration"})(xb||(xb={}));function UD(e){let t=p.useRef(Mx(e)),n=p.useRef(!1),r=ur(),i=p.useMemo(()=>MD(r.search,n.current?null:t.current),[r.search]),s=ze(),a=p.useCallback((l,c)=>{const d=Mx(typeof l=="function"?l(i):l);n.current=!0,s("?"+d,c)},[s,i]);return[i,a]}var mb=1,HD=.9,VD=.8,qD=.17,Ph=.1,Rh=.999,KD=.9999,QD=.99,YD=/[\\\/_+.#"@\[\(\{&]/,GD=/[\\\/_+.#"@\[\(\{&]/g,XD=/[\s-]/,$4=/[\s-]/g;function Lx(e,t,n,r,i,s,a){if(s===t.length)return i===e.length?mb:QD;var l=`${i},${s}`;if(a[l]!==void 0)return a[l];for(var c=r.charAt(s),d=n.indexOf(c,i),u=0,f,h,g,v;d>=0;)f=Lx(e,t,n,r,d+1,s+1,a),f>u&&(d===i?f*=mb:YD.test(e.charAt(d-1))?(f*=VD,g=e.slice(i,d-1).match(GD),g&&i>0&&(f*=Math.pow(Rh,g.length))):XD.test(e.charAt(d-1))?(f*=HD,v=e.slice(i,d-1).match($4),v&&i>0&&(f*=Math.pow(Rh,v.length))):(f*=qD,i>0&&(f*=Math.pow(Rh,d-i))),e.charAt(d)!==t.charAt(s)&&(f*=KD)),(f<Ph&&n.charAt(d-1)===r.charAt(s+1)||r.charAt(s+1)===r.charAt(s)&&n.charAt(d-1)!==r.charAt(s))&&(h=Lx(e,t,n,r,d+1,s+2,a),h*Ph>f&&(f=h*Ph)),f>u&&(u=f),d=n.indexOf(c,d+1);return a[l]=u,u}function vb(e){return e.toLowerCase().replace($4," ")}function JD(e,t,n){return e=n&&n.length>0?`${e+" "+n.join(" ")}`:e,Lx(e,t,vb(e),vb(t),0,0,{})}var Ol='[cmdk-group=""]',Ih='[cmdk-group-items=""]',ZD='[cmdk-group-heading=""]',F4='[cmdk-item=""]',yb=`${F4}:not([aria-disabled="true"])`,Ox="cmdk-item-select",Ys="data-value",eN=(e,t,n)=>JD(e,t,n),z4=p.createContext(void 0),pd=()=>p.useContext(z4),B4=p.createContext(void 0),H0=()=>p.useContext(B4),W4=p.createContext(void 0),U4=p.forwardRef((e,t)=>{let n=Gs(()=>{var A,V;return{search:"",value:(V=(A=e.value)!=null?A:e.defaultValue)!=null?V:"",selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}}}),r=Gs(()=>new Set),i=Gs(()=>new Map),s=Gs(()=>new Map),a=Gs(()=>new Set),l=H4(e),{label:c,children:d,value:u,onValueChange:f,filter:h,shouldFilter:g,loop:v,disablePointerSelection:x=!1,vimBindings:b=!0,...j}=e,y=kn(),w=kn(),k=kn(),S=p.useRef(null),T=uN();fs(()=>{if(u!==void 0){let A=u.trim();n.current.value=A,C.emit()}},[u]),fs(()=>{T(6,X)},[]);let C=p.useMemo(()=>({subscribe:A=>(a.current.add(A),()=>a.current.delete(A)),snapshot:()=>n.current,setState:(A,V,oe)=>{var Z,ie,he,ve;if(!Object.is(n.current[A],V)){if(n.current[A]=V,A==="search")q(),L(),T(1,z);else if(A==="value"){if(document.activeElement.hasAttribute("cmdk-input")||document.activeElement.hasAttribute("cmdk-root")){let be=document.getElementById(k);be?be.focus():(Z=document.getElementById(y))==null||Z.focus()}if(T(7,()=>{var be;n.current.selectedItemId=(be=D())==null?void 0:be.id,C.emit()}),oe||T(5,X),((ie=l.current)==null?void 0:ie.value)!==void 0){let be=V??"";(ve=(he=l.current).onValueChange)==null||ve.call(he,be);return}}C.emit()}},emit:()=>{a.current.forEach(A=>A())}}),[]),P=p.useMemo(()=>({value:(A,V,oe)=>{var Z;V!==((Z=s.current.get(A))==null?void 0:Z.value)&&(s.current.set(A,{value:V,keywords:oe}),n.current.filtered.items.set(A,I(V,oe)),T(2,()=>{L(),C.emit()}))},item:(A,V)=>(r.current.add(A),V&&(i.current.has(V)?i.current.get(V).add(A):i.current.set(V,new Set([A]))),T(3,()=>{q(),L(),n.current.value||z(),C.emit()}),()=>{s.current.delete(A),r.current.delete(A),n.current.filtered.items.delete(A);let oe=D();T(4,()=>{q(),(oe==null?void 0:oe.getAttribute("id"))===A&&z(),C.emit()})}),group:A=>(i.current.has(A)||i.current.set(A,new Set),()=>{s.current.delete(A),i.current.delete(A)}),filter:()=>l.current.shouldFilter,label:c||e["aria-label"],getDisablePointerSelection:()=>l.current.disablePointerSelection,listId:y,inputId:k,labelId:w,listInnerRef:S}),[]);function I(A,V){var oe,Z;let ie=(Z=(oe=l.current)==null?void 0:oe.filter)!=null?Z:eN;return A?ie(A,n.current.search,V):0}function L(){if(!n.current.search||l.current.shouldFilter===!1)return;let A=n.current.filtered.items,V=[];n.current.filtered.groups.forEach(Z=>{let ie=i.current.get(Z),he=0;ie.forEach(ve=>{let be=A.get(ve);he=Math.max(be,he)}),V.push([Z,he])});let oe=S.current;U().sort((Z,ie)=>{var he,ve;let be=Z.getAttribute("id"),jt=ie.getAttribute("id");return((he=A.get(jt))!=null?he:0)-((ve=A.get(be))!=null?ve:0)}).forEach(Z=>{let ie=Z.closest(Ih);ie?ie.appendChild(Z.parentElement===ie?Z:Z.closest(`${Ih} > *`)):oe.appendChild(Z.parentElement===oe?Z:Z.closest(`${Ih} > *`))}),V.sort((Z,ie)=>ie[1]-Z[1]).forEach(Z=>{var ie;let he=(ie=S.current)==null?void 0:ie.querySelector(`${Ol}[${Ys}="${encodeURIComponent(Z[0])}"]`);he==null||he.parentElement.appendChild(he)})}function z(){let A=U().find(oe=>oe.getAttribute("aria-disabled")!=="true"),V=A==null?void 0:A.getAttribute(Ys);C.setState("value",V||void 0)}function q(){var A,V,oe,Z;if(!n.current.search||l.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let ie=0;for(let he of r.current){let ve=(V=(A=s.current.get(he))==null?void 0:A.value)!=null?V:"",be=(Z=(oe=s.current.get(he))==null?void 0:oe.keywords)!=null?Z:[],jt=I(ve,be);n.current.filtered.items.set(he,jt),jt>0&&ie++}for(let[he,ve]of i.current)for(let be of ve)if(n.current.filtered.items.get(be)>0){n.current.filtered.groups.add(he);break}n.current.filtered.count=ie}function X(){var A,V,oe;let Z=D();Z&&(((A=Z.parentElement)==null?void 0:A.firstChild)===Z&&((oe=(V=Z.closest(Ol))==null?void 0:V.querySelector(ZD))==null||oe.scrollIntoView({block:"nearest"})),Z.scrollIntoView({block:"nearest"}))}function D(){var A;return(A=S.current)==null?void 0:A.querySelector(`${F4}[aria-selected="true"]`)}function U(){var A;return Array.from(((A=S.current)==null?void 0:A.querySelectorAll(yb))||[])}function Q(A){let V=U()[A];V&&C.setState("value",V.getAttribute(Ys))}function J(A){var V;let oe=D(),Z=U(),ie=Z.findIndex(ve=>ve===oe),he=Z[ie+A];(V=l.current)!=null&&V.loop&&(he=ie+A<0?Z[Z.length-1]:ie+A===Z.length?Z[0]:Z[ie+A]),he&&C.setState("value",he.getAttribute(Ys))}function _(A){let V=D(),oe=V==null?void 0:V.closest(Ol),Z;for(;oe&&!Z;)oe=A>0?cN(oe,Ol):dN(oe,Ol),Z=oe==null?void 0:oe.querySelector(yb);Z?C.setState("value",Z.getAttribute(Ys)):J(A)}let F=()=>Q(U().length-1),W=A=>{A.preventDefault(),A.metaKey?F():A.altKey?_(1):J(1)},te=A=>{A.preventDefault(),A.metaKey?Q(0):A.altKey?_(-1):J(-1)};return p.createElement(Le.div,{ref:t,tabIndex:-1,...j,"cmdk-root":"",onKeyDown:A=>{var V;(V=j.onKeyDown)==null||V.call(j,A);let oe=A.nativeEvent.isComposing||A.keyCode===229;if(!(A.defaultPrevented||oe))switch(A.key){case"n":case"j":{b&&A.ctrlKey&&W(A);break}case"ArrowDown":{W(A);break}case"p":case"k":{b&&A.ctrlKey&&te(A);break}case"ArrowUp":{te(A);break}case"Home":{A.preventDefault(),Q(0);break}case"End":{A.preventDefault(),F();break}case"Enter":{A.preventDefault();let Z=D();if(Z){let ie=new Event(Ox);Z.dispatchEvent(ie)}}}}},p.createElement("label",{"cmdk-label":"",htmlFor:P.inputId,id:P.labelId,style:fN},c),xf(e,A=>p.createElement(B4.Provider,{value:C},p.createElement(z4.Provider,{value:P},A))))}),tN=p.forwardRef((e,t)=>{var n,r;let i=kn(),s=p.useRef(null),a=p.useContext(W4),l=pd(),c=H4(e),d=(r=(n=c.current)==null?void 0:n.forceMount)!=null?r:a==null?void 0:a.forceMount;fs(()=>{if(!d)return l.item(i,a==null?void 0:a.id)},[d]);let u=V4(i,s,[e.value,e.children,s],e.keywords),f=H0(),h=gi(T=>T.value&&T.value===u.current),g=gi(T=>d||l.filter()===!1?!0:T.search?T.filtered.items.get(i)>0:!0);p.useEffect(()=>{let T=s.current;if(!(!T||e.disabled))return T.addEventListener(Ox,v),()=>T.removeEventListener(Ox,v)},[g,e.onSelect,e.disabled]);function v(){var T,C;x(),(C=(T=c.current).onSelect)==null||C.call(T,u.current)}function x(){f.setState("value",u.current,!0)}if(!g)return null;let{disabled:b,value:j,onSelect:y,forceMount:w,keywords:k,...S}=e;return p.createElement(Le.div,{ref:Ha(s,t),...S,id:i,"cmdk-item":"",role:"option","aria-disabled":!!b,"aria-selected":!!h,"data-disabled":!!b,"data-selected":!!h,onPointerMove:b||l.getDisablePointerSelection()?void 0:x,onClick:b?void 0:v},e.children)}),nN=p.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...s}=e,a=kn(),l=p.useRef(null),c=p.useRef(null),d=kn(),u=pd(),f=gi(g=>i||u.filter()===!1?!0:g.search?g.filtered.groups.has(a):!0);fs(()=>u.group(a),[]),V4(a,l,[e.value,e.heading,c]);let h=p.useMemo(()=>({id:a,forceMount:i}),[i]);return p.createElement(Le.div,{ref:Ha(l,t),...s,"cmdk-group":"",role:"presentation",hidden:f?void 0:!0},n&&p.createElement("div",{ref:c,"cmdk-group-heading":"","aria-hidden":!0,id:d},n),xf(e,g=>p.createElement("div",{"cmdk-group-items":"",role:"group","aria-labelledby":n?d:void 0},p.createElement(W4.Provider,{value:h},g))))}),rN=p.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=p.useRef(null),s=gi(a=>!a.search);return!n&&!s?null:p.createElement(Le.div,{ref:Ha(i,t),...r,"cmdk-separator":"",role:"separator"})}),oN=p.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,s=H0(),a=gi(d=>d.search),l=gi(d=>d.selectedItemId),c=pd();return p.useEffect(()=>{e.value!=null&&s.setState("search",e.value)},[e.value]),p.createElement(Le.input,{ref:t,...r,"cmdk-input":"",autoComplete:"off",autoCorrect:"off",spellCheck:!1,"aria-autocomplete":"list",role:"combobox","aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":l,id:c.inputId,type:"text",value:i?e.value:a,onChange:d=>{i||s.setState("search",d.target.value),n==null||n(d.target.value)}})}),iN=p.forwardRef((e,t)=>{let{children:n,label:r="Suggestions",...i}=e,s=p.useRef(null),a=p.useRef(null),l=gi(d=>d.selectedItemId),c=pd();return p.useEffect(()=>{if(a.current&&s.current){let d=a.current,u=s.current,f,h=new ResizeObserver(()=>{f=requestAnimationFrame(()=>{let g=d.offsetHeight;u.style.setProperty("--cmdk-list-height",g.toFixed(1)+"px")})});return h.observe(d),()=>{cancelAnimationFrame(f),h.unobserve(d)}}},[]),p.createElement(Le.div,{ref:Ha(s,t),...i,"cmdk-list":"",role:"listbox",tabIndex:-1,"aria-activedescendant":l,"aria-label":r,id:c.listId},xf(e,d=>p.createElement("div",{ref:Ha(a,c.listInnerRef),"cmdk-list-sizer":""},d)))}),sN=p.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:s,container:a,...l}=e;return p.createElement(po,{open:n,onOpenChange:r},p.createElement(fo,{container:a},p.createElement(ho,{"cmdk-overlay":"",className:i}),p.createElement(go,{"aria-label":e.label,"cmdk-dialog":"",className:s},p.createElement(U4,{ref:t,...l}))))}),aN=p.forwardRef((e,t)=>gi(n=>n.filtered.count===0)?p.createElement(Le.div,{ref:t,...e,"cmdk-empty":"",role:"presentation"}):null),lN=p.forwardRef((e,t)=>{let{progress:n,children:r,label:i="Loading...",...s}=e;return p.createElement(Le.div,{ref:t,...s,"cmdk-loading":"",role:"progressbar","aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},xf(e,a=>p.createElement("div",{"aria-hidden":!0},a)))}),Nc=Object.assign(U4,{List:iN,Item:tN,Input:oN,Group:nN,Separator:rN,Dialog:sN,Empty:aN,Loading:lN});function cN(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function dN(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function H4(e){let t=p.useRef(e);return fs(()=>{t.current=e}),t}var fs=typeof window>"u"?p.useEffect:p.useLayoutEffect;function Gs(e){let t=p.useRef();return t.current===void 0&&(t.current=e()),t}function gi(e){let t=H0(),n=()=>e(t.snapshot());return p.useSyncExternalStore(t.subscribe,n,n)}function V4(e,t,n,r=[]){let i=p.useRef(),s=pd();return fs(()=>{var a;let l=(()=>{var d;for(let u of n){if(typeof u=="string")return u.trim();if(typeof u=="object"&&"current"in u)return u.current?(d=u.current.textContent)==null?void 0:d.trim():i.current}})(),c=r.map(d=>d.trim());s.value(e,l,c),(a=t.current)==null||a.setAttribute(Ys,l),i.current=l}),i}var uN=()=>{let[e,t]=p.useState(),n=Gs(()=>new Map);return fs(()=>{n.current.forEach(r=>r()),n.current=new Map},[e]),(r,i)=>{n.current.set(r,i),t({})}};function pN(e){let t=e.type;return typeof t=="function"?t(e.props):"render"in t?t.render(e.props):e}function xf({asChild:e,children:t},n){return e&&p.isValidElement(t)?p.cloneElement(pN(t),{ref:t.ref},n(t.props.children)):n(t)}var fN={position:"absolute",width:"1px",height:"1px",padding:"0",margin:"-1px",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",borderWidth:"0"};const q4={appearance:"stNavAppearance",platform:"stNavPlatform",accounts:"stNavAccounts",profiles:"stNavProfiles",budget:"stNavBudget",machines:"stNavMachines",templates:"stNavTemplates",mcp:"stNavMcp",notifications:"stNavNotifications",hooks:"stNavHooks",advanced:"stNavAdvanced"},hN={appearance:"stMetaAppearanceSub",platform:"stMetaPlatformSub",accounts:"stMetaAccountsSub",profiles:"stMetaProfilesSub",budget:"stMetaBudgetSub",machines:"stMetaMachinesSub",templates:"stMetaTemplatesSub",mcp:"stMetaMcpSub",notifications:"stMetaNotificationsSub",hooks:"stMetaHooksSub",advanced:"stMetaAdvancedSub"},gN=["appearance","platform","accounts","profiles","budget","machines","templates","mcp","notifications","hooks","advanced"];function xN(e){return gN.map(t=>({key:t,label:e[q4[t]]}))}function mN(e,t){return{title:e[q4[t]],sub:e[hN[t]]}}const V0="'IBM Plex Mono',monospace",vN={background:"var(--proto-card)",border:"1px solid var(--proto-line)",borderRadius:10,boxShadow:"0 1px 2px rgba(16,24,40,.03)"};function Ye({children:e,style:t}){return o.jsx("div",{style:{...vN,...t},children:e})}function $n({title:e,right:t}){return o.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"10px 14px",borderBottom:"1px solid var(--proto-line-2)"},children:[o.jsx("span",{style:{fontSize:12,fontWeight:650,color:"var(--proto-ink)"},children:e}),t!=null?o.jsx("span",{style:{marginLeft:"auto",font:`400 9.5px ${V0}`,color:"var(--proto-muted-3)"},children:t}):null]})}function kr({k:e,value:t,valueColor:n}){return o.jsxs("div",{style:{display:"flex"},children:[o.jsx("span",{style:{color:"var(--proto-muted-3)"},children:e}),o.jsx("span",{style:{marginLeft:"auto",color:n},children:t})]})}function mf({on:e,onClick:t,inert:n}){return o.jsx("div",{onClick:t,role:t?"button":void 0,style:{width:32,height:19,borderRadius:999,background:e?"var(--proto-accent)":"var(--proto-line)",display:"flex",alignItems:"center",justifyContent:e?"flex-end":"flex-start",padding:2,boxSizing:"border-box",cursor:t?"pointer":n?"not-allowed":"default",flex:"none",opacity:n?.85:1},children:o.jsx("span",{style:{width:15,height:15,borderRadius:"50%",background:"var(--proto-card)"}})})}function K4({selected:e}){return o.jsx("span",{style:{width:14,height:14,borderRadius:"50%",border:e?"4.5px solid var(--proto-accent)":"1.5px solid var(--proto-line-3)",boxSizing:"border-box",flex:"none",marginTop:1}})}function ua({children:e}){return o.jsx("div",{style:{fontSize:9.5,fontWeight:700,letterSpacing:".06em",color:"var(--proto-muted-3)",textTransform:"uppercase",margin:"14px 0 7px"},children:e})}function Mn({label:e,children:t,hint:n,hintTone:r}){return o.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:10,padding:"4px 0"},children:[o.jsx("span",{style:{width:92,flex:"none",font:`400 10px ${V0}`,color:"var(--proto-muted-3)",paddingTop:6},children:e}),o.jsxs("div",{style:{flex:1,minWidth:0},children:[t,n!=null?o.jsx("div",{style:{fontSize:9.5,lineHeight:1.6,marginTop:3,color:r==="danger"?"var(--proto-danger)":"var(--proto-faint)"},children:n}):null]})]})}const Xt={width:"100%",boxSizing:"border-box",font:`400 11px ${V0}`,color:"var(--proto-ink)",background:"var(--proto-card)",border:"1px solid var(--proto-line)",borderRadius:7,padding:"5px 9px",outline:"none"},yN={...Xt,background:"var(--proto-alt)",color:"var(--proto-muted-2)",cursor:"not-allowed"},bN={accent:{base:{color:"var(--ink-solid-fg)",background:"var(--proto-accent)",border:"1px solid transparent"},hover:{background:"var(--proto-accent-strong)"}},danger:{base:{color:"var(--proto-danger)",background:"var(--proto-card)",border:"1px solid var(--proto-danger-bg)"},hover:{background:"var(--proto-danger-bg)"}},neutral:{base:{color:"var(--proto-ink)",background:"var(--proto-card)",border:"1px solid var(--proto-line-3)"},hover:{background:"var(--proto-alt)"}}};function Yn({tone:e,disabled:t,onClick:n,children:r,...i}){const[s,a]=p.useState(!1),l=bN[e],c={fontSize:11.5,fontWeight:600,borderRadius:8,padding:"6px 14px",flex:"none",cursor:t?"not-allowed":"pointer",opacity:t?.45:1,...l.base};return o.jsx("span",{...i,onClick:t?void 0:n,role:t?void 0:"button",onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),style:s&&!t?{...c,...l.hover}:c,children:r})}const jN="••••••••";function q0(e){const t={};for(const n of e)t[n.key]=n;return t}function Ax(e,t){const n=e[t],r=(n==null?void 0:n.present)===!0;return{key:t,present:r,display:r?jN:"—"}}function Xa(e,t){return e.some(n=>n.key.startsWith(t)&&n.present)}function Q4(e){const t={};for(const n of e??[])t[n.key]=n;return t}function Ja(e,t){return e[t]}const wN=["SLACK_BOT_TOKEN","SLACK_SIGNING_SECRET","SLACK_APP_TOKEN"],kN=["FEISHU_APP_ID","FEISHU_APP_SECRET","FEISHU_DOMAIN"],SN=["ANTHROPIC_API_KEY","ANTHROPIC_BASE_URL"],CN=["CORTEX_MACHINE","CORTEX_HOME","WEBHOOK_PORT","CORTEX_CLIENT_PORT","CORTEX_REPO"],EN=[{setting:"turnNotify",titleKey:"stNotifyTurnTitle",descKey:"stNotifyTurnDesc"},{setting:"autoResume",titleKey:"stNotifyResumeTitle",descKey:"stNotifyResumeDesc"},{setting:"notifyCompaction",titleKey:"stNotifyCompactionTitle",descKey:"stNotifyCompactionDesc"}],TN=[{kind:"env",env:"DEBUG",titleKey:"stAdvDebugTitle",descKey:"stAdvDebugDesc"},{kind:"setting",setting:"eventLog",titleKey:"stAdvEventLogTitle",descKey:"stAdvEventLogDesc"},{kind:"setting",setting:"diskMonitor",titleKey:"stAdvDiskMonitorTitle",descKey:"stAdvDiskMonitorDesc"},{kind:"setting",setting:"showToolCalls",titleKey:"stAdvToolCallsTitle",descKey:"stAdvToolCallsDesc"},{kind:"setting",setting:"disableUserContext",titleKey:"stAdvDisableUserTitle",descKey:"stAdvDisableUserDesc"},{kind:"setting",setting:"serverUpdateDisable",titleKey:"stAdvDisableUpdateTitle",descKey:"stAdvDisableUpdateDesc"}],Ze="'IBM Plex Mono',monospace";function Dx({present:e}){const t=H();return o.jsx("span",{style:{fontSize:9,fontWeight:600,padding:"1px 6px",borderRadius:999,background:e?"var(--proto-success-bg)":"var(--proto-gray)",color:e?"var(--proto-success)":"var(--proto-muted-2)"},children:e?t.stConfigured:t.stNotConfigured})}function Nx({glyph:e}){return o.jsx("span",{style:{width:22,height:22,borderRadius:6,background:"var(--proto-gray)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:9,fontWeight:700,color:"var(--proto-muted)",flex:"none"},children:e})}function bb({platform:e,onReconnect:t}){const n=H(),r=!!t;return o.jsx("span",{onClick:r?()=>t(e):void 0,role:r?"button":void 0,"data-reconnect":e,title:r?n.stReconnectApprovalTitle:n.stReconnectInertTitle,style:{marginLeft:"auto",fontSize:10.5,fontWeight:600,color:r?"var(--proto-accent)":"var(--proto-faint)",cursor:r?"pointer":"not-allowed"},children:n.stReconnect})}function jb({index:e,keys:t}){return o.jsx("div",{style:{font:`400 10px/2 ${Ze}`,color:"var(--proto-muted)",marginTop:5,paddingLeft:31},children:t.map(n=>{const r=Ax(e,n);return o.jsx(kr,{k:n,valueColor:r.present?void 0:"var(--proto-faint)",value:r.present?o.jsxs(o.Fragment,{children:[r.display," ",o.jsx("span",{style:{color:"var(--proto-success)"},children:"✓"})]}):"—"},n)})})}function PN({snapshot:e,onReconnect:t}){var l;const n=H(),r=q0(e.env),i=Xa(e.env,"SLACK_"),s=Xa(e.env,"FEISHU_"),a=((l=r.CORTEX_TUI)==null?void 0:l.present)===!0;return o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1.2fr 1fr",gap:12,marginTop:12,alignItems:"start",maxWidth:980},children:[o.jsxs(Ye,{children:[o.jsx($n,{title:n.stMessagingPlatforms,right:"CORTEX_PLATFORM"}),o.jsxs("div",{style:{padding:"11px 14px",borderBottom:"1px solid var(--proto-alt)"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9},children:[o.jsx(Nx,{glyph:"S"}),o.jsx("span",{style:{fontSize:12,fontWeight:600,color:"var(--proto-ink)"},children:"Slack"}),o.jsx(Dx,{present:i}),o.jsx(bb,{platform:"slack",onReconnect:t})]}),o.jsx(jb,{index:r,keys:wN})]}),o.jsxs("div",{style:{padding:"11px 14px",borderBottom:"1px solid var(--proto-alt)"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9},children:[o.jsx(Nx,{glyph:"飞"}),o.jsx("span",{style:{fontSize:12,fontWeight:600,color:"var(--proto-ink)"},children:"飞书"}),o.jsx(Dx,{present:s}),o.jsx(bb,{platform:"feishu",onReconnect:t})]}),o.jsx(jb,{index:r,keys:kN})]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"10px 14px"},children:[o.jsx(mf,{on:a,inert:!0}),o.jsxs("div",{style:{flex:1,minWidth:0},children:[o.jsx("div",{style:{fontSize:12,fontWeight:600,color:"var(--proto-ink)"},children:n.stTuiGateway}),o.jsx("div",{style:{fontSize:10.5,color:"var(--proto-muted-2)",marginTop:1},children:n.tuiDesc})]}),o.jsx("span",{style:{font:`400 9px ${Ze}`,color:"var(--proto-faint)",flex:"none"},children:"CORTEX_TUI"})]})]}),o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[o.jsxs(Ye,{children:[o.jsx($n,{title:n.stApi}),o.jsx("div",{style:{padding:"8px 14px",font:`400 10px/2.1 ${Ze}`,color:"var(--proto-muted)"},children:SN.map(c=>{const d=Ax(r,c);return o.jsx(kr,{k:c,valueColor:d.present?void 0:"var(--proto-faint)",value:d.present?o.jsxs(o.Fragment,{children:[d.display," ",o.jsx("span",{style:{color:"var(--proto-success)"},children:"✓"})]}):"—"},c)})})]}),o.jsxs(Ye,{children:[o.jsx($n,{title:n.stDaemonNetwork}),o.jsx("div",{style:{padding:"8px 14px",font:`400 10px/2.1 ${Ze}`,color:"var(--proto-muted)"},children:CN.map(c=>{const d=Ax(r,c);return o.jsx(kr,{k:c,valueColor:d.present?"var(--proto-ink)":"var(--proto-faint)",value:d.present?d.display:"—"},c)})})]})]})]})}const wp={fontSize:9.5,fontWeight:700,letterSpacing:".05em",color:"var(--proto-muted-3)"};function RN({snapshot:e,onSetDefaultProfile:t}){const n=H(),r=e.profiles,i=(r==null?void 0:r.profiles)??[],s="84px 1fr 74px 52px 64px",a=!!t&&i.length>0;return o.jsxs(o.Fragment,{children:[o.jsxs(Ye,{style:{padding:"10px 14px",display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[o.jsx("span",{style:{fontSize:11,color:"var(--proto-muted)"},children:n.stDefaultProfile}),a?o.jsx("select",{"data-default-profile-select":!0,value:(r==null?void 0:r.defaultProfile)??"",onChange:l=>t(l.target.value),style:{font:`600 11px ${Ze}`,color:"var(--proto-ink)",border:"1px solid var(--proto-line)",borderRadius:7,padding:"4px 10px",background:"var(--proto-card)",cursor:"pointer"},children:i.map(l=>o.jsx("option",{value:l.name,children:l.name},l.name))}):o.jsxs("span",{title:"Select a profile to write profiles.json defaultProfile",style:{display:"flex",alignItems:"center",gap:7,border:"1px solid var(--proto-line)",borderRadius:7,padding:"4px 10px"},children:[o.jsx("span",{style:{font:`600 11px ${Ze}`,color:"var(--proto-ink)"},children:(r==null?void 0:r.defaultProfile)??"—"}),o.jsx("span",{style:{color:"var(--proto-muted-3)",fontSize:8},children:"▾"})]}),o.jsx("span",{style:{marginLeft:"auto",font:`400 9.5px ${Ze}`,color:"var(--proto-faint)"},children:n.stProfReadNote})]}),o.jsxs(Ye,{style:{marginTop:12,overflow:"hidden"},children:[o.jsxs("div",{style:{display:"grid",gridTemplateColumns:s,padding:"7px 14px",borderBottom:"1px solid var(--proto-line-soft)",...wp},children:[o.jsx("span",{children:n.stColName}),o.jsx("span",{children:n.stColModel}),o.jsx("span",{children:n.stColBackend}),o.jsx("span",{children:n.stColMode}),o.jsx("span",{children:n.stColThinking})]}),i.length===0?o.jsx("div",{style:{padding:"12px 14px",fontSize:11,color:"var(--proto-muted-3)"},children:n.stNoProfiles}):i.map((l,c)=>o.jsxs("div",{style:{display:"grid",gridTemplateColumns:s,padding:"9px 14px",borderBottom:c<i.length-1?"1px solid var(--proto-alt)":void 0,alignItems:"center"},children:[o.jsxs("span",{style:{display:"flex",alignItems:"center",gap:5},children:[o.jsx("span",{style:{font:`600 10.5px ${Ze}`,color:"var(--proto-ink-2)"},children:l.name}),l.name===(r==null?void 0:r.defaultProfile)?o.jsx("span",{style:{fontSize:8,fontWeight:600,padding:"1px 4px",borderRadius:999,background:"var(--proto-accent-bg)",color:"var(--proto-accent)"},children:n.default}):null]}),o.jsx("span",{style:{font:`400 10px ${Ze}`,color:"var(--proto-muted)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",paddingRight:8},children:l.model??"—"}),o.jsx("span",{style:{font:`400 10px ${Ze}`,color:"var(--proto-muted)",whiteSpace:"nowrap"},children:l.backend??"—"}),o.jsx("span",{style:{font:`400 10px ${Ze}`,color:l.mode?"var(--proto-ink)":"var(--proto-faint)"},children:l.mode??"—"}),o.jsx("span",{style:{font:`400 10px ${Ze}`,color:l.thinking?"var(--proto-ink)":"var(--proto-faint)"},children:l.thinking??"—"})]},l.name))]})]})}function IN({snapshot:e,onAddMachine:t}){const n=H(),r=e.machines,i="110px 1fr 44px 120px 90px 96px",s=!!t;return o.jsxs("div",{style:{marginTop:12,maxWidth:980},children:[o.jsxs(Ye,{style:{overflow:"hidden"},children:[o.jsxs("div",{style:{display:"grid",gridTemplateColumns:i,padding:"7px 14px",borderBottom:"1px solid var(--proto-line-soft)",...wp},children:[o.jsx("span",{children:n.stColName}),o.jsx("span",{children:n.stColCortexPath}),o.jsx("span",{children:n.mGpu}),o.jsx("span",{children:n.stColSsh}),o.jsx("span",{children:n.stColOs}),o.jsx("span",{})]}),r.length===0?o.jsx("div",{style:{padding:"12px 14px",fontSize:11,color:"var(--proto-muted-3)"},children:n.stNoMachinesFile}):r.map(a=>o.jsxs("div",{style:{display:"grid",gridTemplateColumns:i,padding:"9px 14px",borderBottom:"1px solid var(--proto-alt)",alignItems:"center"},children:[o.jsx("span",{style:{font:`600 10.5px ${Ze}`,color:"var(--proto-ink)"},children:a.name}),o.jsx("span",{style:{font:`400 9.5px ${Ze}`,color:"var(--proto-muted)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",paddingRight:8},children:a.cortexPath??"—"}),o.jsx("span",{style:{font:`400 10px ${Ze}`,color:"var(--proto-ink-2)"},children:a.gpuCount??"—"}),o.jsx("span",{style:{font:`400 9.5px ${Ze}`,color:a.ssh?"var(--proto-muted)":"var(--proto-faint)"},children:a.ssh?n.stConfigured:n.stMachineLocal}),o.jsx("span",{style:{font:`400 9.5px ${Ze}`,color:"var(--proto-muted)"},children:a.win?n.stWinOs:n.stUnixOs}),o.jsx("span",{title:"No machine logs/registry backend op — inert",style:{fontSize:10,fontWeight:600,color:"var(--proto-faint)",textAlign:"right",cursor:"not-allowed"},children:n.stLogs})]},a.name)),o.jsxs("div",{onClick:s?()=>{const a=window.prompt(n.stAddMachinePrompt),l=a==null?void 0:a.trim();l&&t(l)}:void 0,role:s?"button":void 0,"data-add-machine":s?"":void 0,title:s?n.stAddMachineApprovalTitle:n.stAddMachineInertTitle,style:{display:"flex",alignItems:"center",gap:7,padding:"9px 14px",cursor:s?"pointer":"not-allowed"},children:[o.jsx("span",{style:{fontSize:11,fontWeight:600,color:s?"var(--proto-accent)":"var(--proto-faint)"},children:n.stAddMachine}),o.jsx("span",{style:{font:`400 9px ${Ze}`,color:"var(--proto-faint)"},children:n.stMachineFieldsHint})]})]}),o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12,marginTop:12,alignItems:"start"},children:[o.jsxs(Ye,{children:[o.jsx($n,{title:n.stClientLifecycle,right:"client-manager"}),o.jsxs("div",{style:{padding:"8px 14px",fontSize:10.5,lineHeight:2,color:"var(--proto-muted)"},children:[o.jsx(Eo,{k:n.mHeartbeat,v:"5s · 15s timeout"}),o.jsx(Eo,{k:n.mRecover,v:"SSH restart · 60s backoff"}),o.jsx(Eo,{k:"PID",v:"data/client-pids.json"}),o.jsx(Eo,{k:"WebSocket",v:":3002 · CORTEX_CLIENT_TOKEN"})]})]}),o.jsxs(Ye,{children:[o.jsx($n,{title:n.stConnectivity,right:"cortex-client.json"}),o.jsxs("div",{style:{padding:"8px 14px",fontSize:10.5,lineHeight:2,color:"var(--proto-muted)"},children:[o.jsx(Eo,{k:"LAN",v:"serverHost = LAN IP"}),o.jsx(Eo,{k:"Tailscale",v:"100.x.y.z"}),o.jsx(Eo,{k:"CF Tunnel",v:"serverUrl = wss://…"}),o.jsx(Eo,{k:n.mFirewall,v:"STCP"})]})]})]}),o.jsx(Ye,{style:{marginTop:12,padding:"10px 14px"},children:o.jsx("div",{style:{fontSize:10.5,color:"var(--proto-muted-2)"},children:n.stMachinesFootNote})})]})}function Eo({k:e,v:t}){return o.jsxs("div",{style:{display:"flex"},children:[o.jsx("span",{children:e}),o.jsx("span",{style:{marginLeft:"auto",font:`400 9.5px ${Ze}`,color:"var(--proto-ink)"},children:t})]})}const MN={template:{bg:"var(--proto-accent-bg)",color:"var(--proto-accent)"},agent:{bg:"var(--proto-success-bg)",color:"var(--proto-success)"},shell:{bg:"var(--proto-amber-bg)",color:"var(--proto-amber)"}};function LN({kind:e}){const t=MN[e];return o.jsx("span",{style:{fontSize:9,fontWeight:700,padding:"1px 6px",borderRadius:999,background:t.bg,color:t.color,flex:"none",letterSpacing:".02em"},children:e})}function ON({snapshot:e,entries:t}){const n=H();if(t){const s="76px 140px 1fr 52px";return o.jsxs(Ye,{style:{marginTop:12,maxWidth:860,overflow:"hidden"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"11px 14px",borderBottom:"1px solid var(--proto-line-2)"},children:[o.jsx("span",{style:{fontSize:12,fontWeight:650,color:"var(--proto-ink)"},children:n.tplList}),o.jsxs("span",{style:{marginLeft:10,font:`400 9.5px ${Ze}`,color:"var(--proto-faint)"},children:[t.length," ",t.length===1?n.stEntry:n.stEntries]}),o.jsx("span",{title:n.stTemplateEditorInertTitle,style:{marginLeft:"auto",fontSize:11,fontWeight:600,color:"var(--proto-faint)",cursor:"not-allowed"},children:n.stOpenEditor})]}),o.jsxs("div",{style:{display:"grid",gridTemplateColumns:s,padding:"6px 14px",borderBottom:"1px solid var(--proto-line-soft)",...wp},children:[o.jsx("span",{children:n.stColKind}),o.jsx("span",{children:n.stColName}),o.jsx("span",{children:n.stColDescription}),o.jsx("span",{style:{textAlign:"right"},children:n.stColKeys})]}),t.length===0?o.jsx("div",{style:{padding:"12px 14px",fontSize:11,color:"var(--proto-muted-3)"},children:n.stNoTemplates}):t.map((a,l)=>{const c=a.body?Object.keys(a.body).length:null;return o.jsxs("div",{style:{display:"grid",gridTemplateColumns:s,padding:"8px 14px",borderBottom:l<t.length-1?"1px solid var(--proto-alt)":void 0,alignItems:"center"},children:[o.jsx(LN,{kind:a.kind}),o.jsx("span",{style:{font:`600 10.5px ${Ze}`,color:"var(--proto-ink-2)"},children:a.name}),o.jsx("span",{style:{fontSize:10.5,color:a.description?"var(--proto-muted)":"var(--proto-faint)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",paddingRight:8},children:a.description??"—"}),o.jsx("span",{style:{font:`400 10px ${Ze}`,color:c!=null?"var(--proto-muted)":"var(--proto-faint)",textAlign:"right"},children:c??"—"})]},`${a.kind}:${a.name}`)}),o.jsx("div",{style:{borderTop:"1px solid var(--proto-line-2)",padding:"8px 14px",fontSize:10,color:"var(--proto-faint)"},children:n.stTemplatesFootNote1})]})}const r=e.threadTemplates,i=[{label:n.stGrpTemplates,items:r.templates},{label:n.stGrpAgents,items:r.agents},{label:n.stGrpShells,items:r.shells}];return o.jsxs(Ye,{style:{marginTop:12,maxWidth:760},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"11px 14px",borderBottom:"1px solid var(--proto-line-2)"},children:[o.jsx("span",{style:{fontSize:12,fontWeight:650,color:"var(--proto-ink)"},children:n.tplList}),o.jsx("span",{title:n.stTemplateEditorInertTitle,style:{marginLeft:"auto",fontSize:11,fontWeight:600,color:"var(--proto-faint)",cursor:"not-allowed"},children:n.stOpenEditor})]}),i.map(s=>o.jsxs("div",{style:{borderBottom:"1px solid var(--proto-alt)",padding:"8px 14px 10px"},children:[o.jsx("div",{style:{...wp,marginBottom:6},children:s.label.toUpperCase()}),s.items.length===0?o.jsx("div",{style:{fontSize:10.5,color:"var(--proto-faint)"},children:n.stNone}):o.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:s.items.map(a=>o.jsx("span",{style:{font:`500 10px ${Ze}`,color:"var(--proto-muted)",background:"var(--proto-alt)",border:"1px solid var(--proto-line-2)",padding:"2px 8px",borderRadius:6},children:a},a))})]},s.label)),o.jsx("div",{style:{padding:"9px 14px",fontSize:10,color:"var(--proto-faint)"},children:n.stTemplatesFootNote2})]})}function AN({snapshot:e}){var r;const t=H(),n=((r=e.mcp)==null?void 0:r.servers)??[];return o.jsxs(Ye,{style:{marginTop:12,maxWidth:760},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"11px 14px",borderBottom:"1px solid var(--proto-line-2)"},children:[o.jsx("span",{style:{fontSize:12,fontWeight:650,color:"var(--proto-ink)"},children:t.stServers}),o.jsx("div",{title:"full / core / tui variant is a runtime-mode selection — no config.set for it (inert)",style:{marginLeft:"auto",display:"flex",background:"var(--proto-line-2)",borderRadius:7,padding:2},children:["full","core","tui"].map(i=>o.jsx("span",{style:{font:`500 10px ${Ze}`,color:i==="full"?"var(--proto-ink)":"var(--proto-muted-2)",background:i==="full"?"var(--proto-card)":"transparent",borderRadius:5,padding:"3px 10px",boxShadow:i==="full"?"0 1px 2px rgba(16,24,40,.06)":"none",cursor:"not-allowed"},children:i},i))})]}),n.length===0?o.jsx("div",{style:{padding:"12px 14px",fontSize:11,color:"var(--proto-muted-3)"},children:t.stNoServers}):n.map((i,s)=>o.jsx("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"10px 14px",borderBottom:s<n.length-1?"1px solid var(--proto-alt)":void 0},children:o.jsx("span",{style:{font:`600 11.5px ${Ze}`,color:"var(--proto-ink)"},children:i})},i)),o.jsx("div",{style:{borderTop:"1px solid var(--proto-line-2)",padding:"8px 14px",fontSize:10,color:"var(--proto-faint)"},children:t.stMcpFootNote})]})}async function DN(e,t,n){var r,i;(r=e.onPending)==null||r.call(e,!0);try{await e.set({section:"settings",value:{[t]:n}}),await e.refresh()}catch(s){e.onError(s instanceof Error?s.message:String(s))}finally{(i=e.onPending)==null||i.call(e,!1)}}const vf="'IBM Plex Mono',monospace",Za={display:"flex",alignItems:"center",gap:12,padding:"10px 14px",borderBottom:"1px solid var(--proto-alt)"},yf={fontSize:12,fontWeight:600,color:"var(--proto-ink)"},bf={fontSize:10.5,color:"var(--proto-muted-2)",marginTop:1},jf={font:`400 9px ${vf}`,color:"var(--proto-faint)",flex:"none"};function Y4(){const e=H(),t=le(),n=je(),{toast:r}=dr(),[i,s]=p.useState(!1),a=p.useRef(!1),l=xe(t.config.set.mutationOptions()),c=i||l.isPending,d=f=>{a.current=f,s(f)};return{pending:c,onToggle:(f,h)=>{a.current||l.isPending||DN({set:g=>l.mutateAsync(g),refresh:()=>n.invalidateQueries(t.config.get.queryFilter({})),onError:g=>r({title:`${e.stToastWriteFailed}: ${g}`,tone:"failed"}),onPending:d},f,h)}}}function G4(e){const t=e.source&&!e.pending?()=>e.onToggle(e.settingKey,!e.value):void 0;return o.jsxs("div",{"data-setting-key":e.settingKey,"data-setting-value":e.source?String(e.value):"missing","data-setting-source":e.source??"missing",style:Za,children:[o.jsx(mf,{on:e.value,onClick:t,inert:!t}),o.jsxs("div",{style:{flex:1,minWidth:0},children:[o.jsx("div",{style:yf,children:e.title}),o.jsx("div",{style:bf,children:e.desc})]}),o.jsx("span",{style:jf,children:`settings.${e.settingKey} · ${e.source??"—"}`})]})}function NN({descriptors:e,settings:t,pending:n,onToggle:r,threshold:i}){const s=H();return e.map(a=>{const l=Ja(t,a.setting),c=typeof(l==null?void 0:l.value)=="boolean"?l.value:!1,d=a.setting==="turnNotify"&&i!==void 0?` · ${i}s`:"";return o.jsx(G4,{settingKey:a.setting,value:c,source:typeof(l==null?void 0:l.value)=="boolean"?l.source:null,title:s[a.titleKey],desc:`${s[a.descKey]}${d}`,pending:n,onToggle:r},a.setting)})}function _N({snapshot:e,settings:t}){var s,a;const n=H(),r=(s=Ja(t,"adminChannel"))==null?void 0:s.value,i=(a=Ja(t,"feishuAdminChannel"))==null?void 0:a.value;return o.jsxs(Ye,{style:{marginTop:12},children:[o.jsx($n,{title:n.stNotifyRoutingTitle,right:n.stNotifyRoutingRight}),o.jsx(wb,{platform:"Slack",glyph:"S",present:Xa(e.env,"SLACK_"),setting:"adminChannel",channel:typeof r=="string"?r:null}),o.jsx(wb,{platform:"飞书",glyph:"飞",present:Xa(e.env,"FEISHU_"),setting:"feishuAdminChannel",channel:typeof i=="string"?i:null,last:!0})]})}function wb(e){return o.jsxs("div",{style:{...Za,gap:10,borderBottom:e.last?void 0:Za.borderBottom},children:[o.jsx(Nx,{glyph:e.glyph}),o.jsx("span",{style:{fontSize:11.5,fontWeight:600,color:"var(--proto-ink)"},children:e.platform}),o.jsx(Dx,{present:e.present}),o.jsxs("span",{style:{marginLeft:"auto",font:`400 9.5px ${vf}`,color:"var(--proto-muted-2)"},children:[`settings.${e.setting}: `,o.jsx("span",{style:{color:e.channel?"var(--proto-muted)":"var(--proto-faint)"},children:e.channel??"—"})]})]})}function $N(){const e=H();return o.jsxs("div",{style:{marginTop:12,display:"flex",alignItems:"center",gap:8,padding:"9px 12px",background:"var(--proto-amber-bg)",border:"1px solid var(--proto-amber-border)",borderRadius:9,maxWidth:760,boxSizing:"border-box"},children:[o.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:"var(--proto-amber)",flex:"none"}}),o.jsx("span",{style:{fontSize:10.5,color:"var(--proto-amber-fg)"},children:e.stApprovalReminderNote})]})}function FN(){const e=H();return o.jsxs(Ye,{style:{marginTop:12,maxWidth:760},children:[o.jsx($n,{title:e.stRecentNotifications,right:e.stRecentNotifRight}),o.jsxs("div",{style:{padding:"10px 14px",display:"flex",alignItems:"flex-start",gap:8},children:[o.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:"var(--proto-line-3)",flex:"none",marginTop:5}}),o.jsx("span",{style:{fontSize:10.5,color:"var(--proto-muted-3)",lineHeight:1.6},children:e.stRecentNotifNote})]})]})}function zN({snapshot:e,pending:t,onToggle:n}){const r=Q4(e.settings),i=Ja(r,"turnNotifyThresholdS"),s=typeof(i==null?void 0:i.value)=="number"?i.value:void 0;return o.jsxs(o.Fragment,{children:[o.jsx(Ye,{children:o.jsx(NN,{descriptors:EN,settings:r,pending:t,onToggle:n,threshold:s})}),o.jsx(_N,{snapshot:e,settings:r}),o.jsx($N,{}),o.jsx(FN,{})]})}function BN({snapshot:e}){const t=Y4();return o.jsx(zN,{snapshot:e,pending:t.pending,onToggle:t.onToggle})}function WN({snapshot:e,title:t,desc:n}){var i;const r=((i=q0(e.env).DEBUG)==null?void 0:i.present)===!0;return o.jsxs("div",{"data-env-key":"DEBUG","data-env-present":String(r),"data-writable":"false",style:Za,children:[o.jsx(mf,{on:r,inert:!0}),o.jsxs("div",{style:{flex:1,minWidth:0},children:[o.jsx("div",{style:yf,children:t}),o.jsx("div",{style:bf,children:n})]}),o.jsx("span",{style:jf,children:"DEBUG"})]})}function UN(e){const t=H();return TN.map(n=>{if(n.kind==="env")return o.jsx(WN,{snapshot:e.snapshot,title:t[n.titleKey],desc:t[n.descKey]},n.env);const r=Ja(e.settings,n.setting);return o.jsx(G4,{settingKey:n.setting,value:typeof(r==null?void 0:r.value)=="boolean"?r.value:!1,source:typeof(r==null?void 0:r.value)=="boolean"?r.source:null,title:t[n.titleKey],desc:t[n.descKey],pending:e.pending,onToggle:e.onToggle},n.setting)})}function HN({settings:e}){const t=H(),n=Ja(e,"taskDispatchMaxConcurrent"),r=typeof(n==null?void 0:n.value)=="number"?n.value:(n==null?void 0:n.value)===null?null:void 0;return o.jsxs("div",{"data-setting-key":"taskDispatchMaxConcurrent","data-setting-value":r===void 0?"missing":String(r),style:Za,children:[o.jsxs("div",{style:{flex:1,minWidth:0},children:[o.jsx("div",{style:yf,children:t.advConc}),o.jsx("div",{style:bf,children:t.stAdvConcNote})]}),o.jsx("span",{style:{font:`500 10.5px ${vf}`,color:r===void 0?"var(--proto-faint)":"var(--proto-ink)",border:"1px solid var(--proto-line)",borderRadius:7,padding:"4px 11px"},children:typeof r=="number"?r:r===null?t.stAuto:"—"}),o.jsx("span",{style:jf,children:`settings.taskDispatchMaxConcurrent · ${(n==null?void 0:n.source)??"—"}`})]})}function VN({snapshot:e}){var r;const t=H(),n=((r=q0(e.env).CORTEX_GPU_MONITOR_MOCK)==null?void 0:r.present)===!0;return o.jsxs("div",{style:{...Za,borderBottom:void 0},children:[o.jsxs("div",{style:{flex:1,minWidth:0},children:[o.jsx("div",{style:yf,children:t.stGpuMock}),o.jsx("div",{style:bf,children:t.advMock})]}),o.jsx("span",{style:{font:`400 10.5px ${vf}`,color:"var(--proto-faint)",border:"1px dashed var(--proto-line-3)",borderRadius:7,padding:"4px 11px"},children:n?t.stSet:"—"}),o.jsx("span",{style:jf,children:"CORTEX_GPU_MONITOR_MOCK"})]})}function qN({snapshot:e,pending:t,onToggle:n}){const r=Q4(e.settings);return o.jsxs(Ye,{style:{marginTop:12,maxWidth:760},children:[o.jsx(UN,{snapshot:e,settings:r,pending:t,onToggle:n}),o.jsx(HN,{settings:r}),o.jsx(VN,{snapshot:e})]})}function KN({snapshot:e}){const t=Y4();return o.jsx(qN,{snapshot:e,pending:t.pending,onToggle:t.onToggle})}const QN=[5,10,20,50],YN=[60,80,90];function GN(e,t){return(e==null?void 0:e.daily_usd)===t}function XN(e,t){const n=e==null?void 0:e.monthly_usd;return!Number.isFinite(t)||t<=0||n==null||!Number.isFinite(n)||n<=0?null:{daily_usd:t,monthly_usd:n}}function Ns(e){return e==null||!Number.isFinite(e)?"—":Number.isInteger(e)?"$"+e:"$"+e.toFixed(2)}function _x(e,t){if(t==null||!Number.isFinite(t)||t<=0)return"0%";const n=Math.max(0,Math.min(100,e/t*100));return Math.round(n)+"%"}const Hl="'IBM Plex Mono',monospace",JN={font:`500 10.5px ${Hl}`,borderRadius:7,padding:"4px 11px"};function kb(e){return{...JN,fontWeight:e?600:500,color:e?"var(--proto-accent)":"var(--proto-muted)",background:e?"var(--proto-accent-bg)":"var(--proto-card)",border:"1px solid "+(e?"var(--proto-accent-border)":"var(--proto-line)"),cursor:"pointer"}}const Sb=[{titleKey:"stPolicyPauseTitle",descKey:"stPolicyPauseDesc",def:!0},{titleKey:"stPolicyWarnTitle",descKey:"stPolicyWarnDesc",def:!1},{titleKey:"stPolicyStopTitle",descKey:"stPolicyStopDesc",def:!1}];function ZN({snapshot:e,cost:t}){const n=H(),r=le(),i=je(),{toast:s}=dr(),a=e.budget,l=(a==null?void 0:a.daily_usd)??null,c=(a==null?void 0:a.monthly_usd)??null,d=(t==null?void 0:t.today)??0,u=(t==null?void 0:t.month)??0,f=xe(r.config.set.mutationOptions({onSuccess:()=>{i.invalidateQueries(r.config.get.queryFilter({}))}})),h=g=>{const v=XN(a,g);if(!v){s({title:n.stBudgetWriteError,tone:"waiting"});return}f.mutate({section:"budget",value:v},{onSuccess:()=>s({title:`Daily budget → ${Ns(g)} · ${n.stToastBudgetWritten}`,tone:"done"}),onError:x=>s({title:`${n.stToastWriteFailed}: ${x.message}`,tone:"failed"})})};return o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1.2fr 1fr",gap:12,marginTop:12,alignItems:"start",maxWidth:980},"data-settings-panel":"budget",children:[o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[o.jsxs(Ye,{children:[o.jsx($n,{title:n.stLimits}),o.jsxs("div",{style:{padding:"12px 14px",borderBottom:"1px solid var(--proto-alt)",display:"flex",alignItems:"center",gap:12},children:[o.jsxs("div",{style:{width:104,flex:"none"},children:[o.jsx("div",{style:{fontSize:9.5,fontWeight:700,letterSpacing:".05em",color:"var(--proto-muted-3)"},children:n.stDaily}),o.jsx("div",{style:{font:`600 19px ${Hl}`,color:"var(--proto-ink)",letterSpacing:"-.02em",marginTop:2},"data-budget-daily":!0,children:Ns(l)})]}),o.jsx("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:QN.map(g=>o.jsx("span",{onClick:()=>h(g),role:"button","data-budget-chip":g,style:{...kb(GN(a,g)),opacity:f.isPending?.6:1},children:"$"+g},g))})]}),o.jsxs("div",{style:{padding:"12px 14px",display:"flex",alignItems:"center",gap:12},children:[o.jsxs("div",{style:{width:104,flex:"none"},children:[o.jsx("div",{style:{fontSize:9.5,fontWeight:700,letterSpacing:".05em",color:"var(--proto-muted-3)"},children:n.stWarnAt}),o.jsx("div",{style:{font:`600 19px ${Hl}`,color:"var(--proto-faint)",letterSpacing:"-.02em",marginTop:2},children:"—"})]}),o.jsx("div",{style:{display:"flex",gap:6},children:YN.map(g=>o.jsx("span",{title:"No warn-threshold field in budget.json — inert",style:{...kb(!1),cursor:"not-allowed",color:"var(--proto-faint)"},children:g+"%"},g))}),o.jsx("span",{style:{marginLeft:"auto",fontSize:10.5,color:"var(--proto-muted-2)"},children:n.warnNote})]})]}),o.jsxs(Ye,{children:[o.jsx($n,{title:n.stOverBudgetBehavior,right:n.obNote}),o.jsx("div",{style:{padding:"4px 14px 8px"},children:Sb.map((g,v)=>o.jsxs("div",{title:"No over-budget-policy field in budget.json — inert",style:{display:"flex",alignItems:"flex-start",gap:10,padding:"9px 0",borderBottom:v<Sb.length-1?"1px solid var(--proto-alt)":void 0,cursor:"not-allowed"},children:[o.jsx(K4,{selected:!1}),o.jsxs("div",{style:{flex:1},children:[o.jsxs("div",{style:{fontSize:12,fontWeight:600,color:"var(--proto-muted)"},children:[n[g.titleKey],g.def?o.jsx("span",{style:{fontSize:9,fontWeight:600,padding:"1px 6px",borderRadius:999,background:"var(--proto-accent-bg)",color:"var(--proto-accent)",marginLeft:4},children:n.default}):null]}),o.jsx("div",{style:{fontSize:10.5,color:"var(--proto-muted-2)",marginTop:2},children:n[g.descKey]})]})]},g.titleKey))})]})]}),o.jsxs(Ye,{children:[o.jsx($n,{title:n.stCurrentSpend,right:n.stCostsJsonlLabel}),o.jsxs("div",{style:{padding:"12px 14px"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:8},children:[o.jsx("span",{style:{font:`600 21px ${Hl}`,color:"var(--proto-ink)",letterSpacing:"-.02em"},children:Ns(d)}),o.jsxs("span",{style:{fontSize:11,color:"var(--proto-muted-3)"},children:["/ ",Ns(l)]})]}),o.jsx("div",{style:{height:5,borderRadius:999,background:"var(--proto-line-2)",overflow:"hidden",marginTop:8,position:"relative"},children:o.jsx("div",{style:{width:_x(d,l),height:"100%",background:"var(--proto-accent)"}})}),o.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:8,marginTop:14},children:[o.jsx("span",{style:{font:`600 14px ${Hl}`,color:"var(--proto-ink-2)"},children:Ns(u)}),o.jsxs("span",{style:{fontSize:10.5,color:"var(--proto-muted-3)"},children:[n.month," / ",Ns(c)]})]}),o.jsx("div",{style:{height:5,borderRadius:999,background:"var(--proto-line-2)",overflow:"hidden",marginTop:7},children:o.jsx("div",{style:{width:_x(u,c),height:"100%",background:"var(--proto-accent-2)"}})}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,background:"var(--proto-amber-bg)",border:"1px solid var(--proto-amber-border)",borderRadius:8,padding:"7px 10px",marginTop:13},children:[o.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:"var(--proto-amber)",flex:"none"}}),o.jsx("span",{style:{fontSize:10.5,color:"var(--proto-amber-fg)"},children:n.stObNote})]}),o.jsx("div",{style:{fontSize:10,color:"var(--proto-faint)",marginTop:10},children:n.stBudgetFootNote})]})]})]})}const X4=["all","agent","claude","pi","server","template"];function e_(e,t){switch(t){case"all":return!0;case"agent":return e.event.startsWith("agent:");case"claude":return e.mountsOn.includes("claude");case"pi":return e.mountsOn.includes("pi");case"server":return e.mountsOn.includes("server");case"template":return e.source==="template-scoped"}}function t_(e){return[e.id,e.event,e.fileName??"",e.run.script??"",e.run.command??"",e.matcher??"",e.template??"",e.source].join(`
|
|
118
|
+
`).toLowerCase()}function K0(e,t,n){const r=n.trim().toLowerCase();return e.filter(i=>e_(i,t)&&(r===""||t_(i).includes(r)))}function n_(e,t){const n={};for(const r of X4)n[r]=K0(e,r,t).length;return n}const r_=["agent","cc","pi","cortex","template"];function o_(e){return e.source==="template-scoped"?"template":e.event.startsWith("agent:")?"agent":e.event.startsWith("cc:")?"cc":e.event.startsWith("pi:")?"pi":"cortex"}function i_(e){const t=new Map;for(const r of e){const i=o_(r),s=t.get(i);s?s.push(r):t.set(i,[r])}const n=[];for(const r of r_){const i=t.get(r);!i||i.length===0||n.push({key:r,hooks:[...i].sort((s,a)=>s.order-a.order||s.id.localeCompare(a.id))})}return n}function s_(e,t,n){var r,i;return n!==null&&e.some(s=>s.id===n)?n:((r=t[0])==null?void 0:r.id)??((i=e[0])==null?void 0:i.id)??null}function a_(e){if(e.source==="template-scoped")return{canToggle:!1,canEdit:!1,canDelete:!1,canTest:!0,note:"template-scoped"};if(e.source==="managed")return{canToggle:!0,canEdit:!1,canDelete:!1,canTest:!0,note:"managed"};const t=e.editable;return{canToggle:!0,canEdit:t,canDelete:t,canTest:!0,note:null}}const l_={"agent:session-end":"cc:SessionEnd","agent:pre-compact":"cc:PreCompact","agent:user-prompt":"cc:UserPromptSubmit","agent:turn-end":"cc:Stop"};function c_(e){return e.event.startsWith("agent:")&&!e.mountsOn.includes("claude")}function d_(e){return l_[e]??null}const u_={"cortex:thread.start":"hook-result","cortex:thread.transition":"hook-result","cortex:thread.end":"hook-result","cortex:session.new":"stdout-as-prompt","cortex:session.messageEnd":"stdout-as-prompt"};function fd(e){const t=u_[e];return t?["none",t]:["none"]}function p_(e){return fd(e).length===1}function f_(e,t){return fd(t).includes(e)?e:"none"}function wf(e){return e.startsWith("cortex:")?"filters":"regex"}function J4(e){if(e.trim()==="")return null;try{return new RegExp(e),null}catch(t){return t instanceof Error?t.message:String(t)}}function Z4(e){const t=e.trim();if(t==="")return"";try{const n=JSON.parse(t);if(n===null||typeof n=="string"||typeof n=="number"||typeof n=="boolean")return n}catch{}return e}function h_(e){return typeof e=="string"&&Z4(e)===e?e:JSON.stringify(e)}function g_(e){const t={};let n=!1;for(const r of e){const i=r.key.trim();i!==""&&(t[i]=Z4(r.value),n=!0)}return n?t:null}function eC(e){var t,n;return{id:e.id,event:e.event,matcher:e.matcher??"",filters:e.matcherFilters?Object.entries(e.matcherFilters).map(([r,i])=>({key:r,value:h_(i)})):[],runKind:e.run.command!==null?"command":"script",script:e.run.script??"",command:e.run.command??"",timeoutSec:e.run.timeoutSec==null?"":String(e.run.timeoutSec),backends:(t=e.scope)!=null&&t.backends?[...e.scope.backends]:[],requiresTool:((n=e.scope)==null?void 0:n.requiresTool)??"",result:e.result??"none",enabled:e.enabled}}function ru(){return{id:"",event:"agent:pre-tool",matcher:"",filters:[],runKind:"script",script:"",command:"",timeoutSec:"",backends:[],requiresTool:"",result:"none",enabled:!0}}function Cb(e){return JSON.stringify({id:e.id.trim(),event:e.event.trim(),matcher:e.matcher,filters:e.filters.map(t=>[t.key,t.value]),runKind:e.runKind,script:e.script,command:e.command,timeoutSec:e.timeoutSec,backends:[...e.backends].sort(),requiresTool:e.requiresTool,result:e.result,enabled:e.enabled})}function x_(e,t){return Cb(e)!==Cb(eC(t))}function m_(e,t){const n={};if(t.mode==="create"){const a=e.id.trim();a===""?n.id="id-required":(t.existingIds??[]).includes(a)&&(n.id="id-taken")}const r=e.event.trim();if(r===""&&(n.event="event-required"),wf(r)==="regex")J4(e.matcher)!==null&&(n.matcher="matcher-invalid");else{const a=e.filters.map(l=>l.key.trim());a.some(l=>l==="")?n.filters="filters-empty-key":new Set(a).size!==a.length&&(n.filters="filters-duplicate-key")}(e.runKind==="script"?e.script.trim():e.command.trim())===""&&(n.run="run-required");const s=e.timeoutSec.trim();if(s!==""){const a=Number(s);(!Number.isFinite(a)||a<=0)&&(n.timeoutSec="timeout-invalid")}return fd(r).includes(e.result)||(n.result="result-illegal"),n}function v_(e){return Object.keys(e).length===0}function tC(e){const t=e.event.trim(),n={event:t};if(wf(t)==="regex"){const s=e.matcher.trim();s!==""&&(n.matcher=s)}else{const s=g_(e.filters);s!==null&&(n.matcherFilters=s)}if(e.runKind==="script"){const s=e.script.trim();s!==""&&(n.script=s)}else{const s=e.command.trim();s!==""&&(n.command=s)}const r=e.timeoutSec.trim();if(r!==""){const s=Number(r);Number.isFinite(s)&&s>0&&(n.timeoutSec=s)}e.backends.length>0&&(n.backends=[...e.backends]);const i=e.requiresTool.trim();return i!==""&&(n.requiresTool=i),e.result!=="none"&&fd(t).includes(e.result)&&(n.result=e.result),n.enabled=e.enabled,n}function y_(e){return{id:e.id.trim(),...tC(e)}}function b_(e){return{id:e.id.trim(),...tC(e)}}const Eb=["agent:pre-tool","agent:post-tool","agent:session-start","agent:session-end","agent:pre-compact","agent:user-prompt","agent:turn-end","cc:PreToolUse","cc:PostToolUse","cc:SessionStart","cc:SessionEnd","cc:PreCompact","cc:UserPromptSubmit","cc:Stop","cc:PermissionRequest","pi:tool_call","pi:tool_result","pi:session_start","pi:session_shutdown","pi:before_provider_headers","cortex:server.start","cortex:server.shutdown","cortex:thread.start","cortex:thread.transition","cortex:thread.end","cortex:dispatch.started","cortex:schedule.fired","cortex:task.completed","cortex:task.blocked","cortex:client.connected","cortex:client.disconnected","cortex:session.new","cortex:session.messageEnd"];function j_(e){const t=new Set(Eb),n=new Set(e.map(r=>r.event).filter(r=>!t.has(r)));return[...Eb,...n]}const Tb={channel:"C0000000",sessionId:"sess_example",sessionName:"cortex-0000",executionId:"exec_example",profile:"default",timestampIso:"2026-01-01T00:00:00.000Z"},Mh={threadId:"thr_example",templateName:"example",source:"task-dispatch",project:"my-project",projectId:"my-project",taskId:"0000",currentStepIndex:0,activeAgent:"executor"},ou={hook_event_name:"PreToolUse",session_id:"sess_example",cwd:"/tmp",tool_name:"Edit",tool_input:{file_path:"/tmp/example.txt",new_string:"example"}},w_={"agent:pre-tool":ou,"cc:PreToolUse":ou,"pi:tool_call":ou,"agent:post-tool":{...ou,hook_event_name:"PostToolUse",tool_response:{success:!0},is_error:!1},"agent:session-start":{hook_event_name:"SessionStart",session_id:"sess_example",cwd:"/tmp",source:"startup"},"agent:session-end":{hook_event_name:"SessionEnd",session_id:"sess_example",cwd:"/tmp"},"agent:pre-compact":{hook_event_name:"PreCompact",session_id:"sess_example",cwd:"/tmp"},"agent:user-prompt":{hook_event_name:"UserPromptSubmit",session_id:"sess_example",cwd:"/tmp",prompt:"example prompt"},"agent:turn-end":{hook_event_name:"Stop",session_id:"sess_example",cwd:"/tmp"},"cortex:server.start":{version:"0.0.0",pid:0},"cortex:server.shutdown":{version:"0.0.0",pid:0,reason:"SIGTERM"},"cortex:thread.start":{...Mh,phase:"start"},"cortex:thread.transition":{...Mh,phase:"transition"},"cortex:thread.end":{...Mh,phase:"end"},"cortex:dispatch.started":{taskId:"0000",project:"my-project",source:"task-dispatch",templateName:"example"},"cortex:schedule.fired":{scheduleId:"sch_example",name:"example",project:"my-project"},"cortex:task.completed":{taskId:"0000",project:"my-project"},"cortex:task.blocked":{taskId:"0000",project:"my-project",reason:"example reason"},"cortex:client.connected":{device:"workstation"},"cortex:client.disconnected":{device:"workstation",reason:"socket closed"},"cortex:session.new":{...Tb,trigger:"new"},"cortex:session.messageEnd":{...Tb,trigger:"messageEnd"}};function nC(e){const t=w_[e];return t!==void 0?JSON.stringify(t,null,2):e.startsWith("cc:")?JSON.stringify({hook_event_name:e.slice(3),session_id:"sess_example",cwd:"/tmp"},null,2):e.startsWith("pi:")?JSON.stringify({event:e.slice(3),session_id:"sess_example"},null,2):JSON.stringify({hook_event_name:e},null,2)}function Pb(e){if(e.trim()==="")return!1;try{return JSON.parse(e),!0}catch{return!1}}const ot="'IBM Plex Mono',monospace",k_=288,S_={claude:{bg:"var(--proto-accent-bg)",fg:"var(--proto-accent)"},pi:{bg:"var(--proto-success-bg)",fg:"var(--proto-success)"},server:{bg:"var(--proto-amber-bg)",fg:"var(--proto-amber)"}},C_={all:"hkFilterAll",agent:"hkFilterAgent",claude:"hkFilterClaude",pi:"hkFilterPi",server:"hkFilterServer",template:"hkFilterTemplate"},E_={"id-required":"hkErrIdRequired","id-taken":"hkErrIdTaken","event-required":"hkErrEventRequired","matcher-invalid":"hkMatcherInvalid","filters-empty-key":"hkErrFiltersEmptyKey","filters-duplicate-key":"hkErrFiltersDuplicate","run-required":"hkErrRunRequired","timeout-invalid":"hkErrTimeout","result-illegal":"hkErrResult"},Rb="cortex-hook-scripts",Ib="cortex-hook-events";function rC({target:e}){const t=S_[e];return o.jsx("span",{"data-hook-mount":e,style:{font:`600 8.5px ${ot}`,padding:"1px 5px",borderRadius:999,background:t.bg,color:t.fg,flex:"none"},children:e})}function T_({source:e}){const t=e==="managed";return o.jsx("span",{"data-hook-source":e,style:{font:`600 9px ${ot}`,padding:"1px 6px",borderRadius:999,background:t?"var(--proto-line-2)":"var(--proto-alt)",color:"var(--proto-muted)",flex:"none"},children:e})}function Vl({tone:e,children:t,...n}){const r={amber:{bg:"var(--proto-amber-bg)",border:"var(--proto-amber-border)",fg:"var(--proto-amber-fg)"},accent:{bg:"var(--proto-accent-bg)",border:"var(--proto-accent-border)",fg:"var(--proto-accent)"},danger:{bg:"var(--proto-danger-bg)",border:"var(--proto-danger-bg)",fg:"var(--proto-danger)"}}[e];return o.jsxs("div",{...n,style:{display:"flex",alignItems:"flex-start",gap:7,padding:"7px 10px",borderRadius:8,background:r.bg,border:`1px solid ${r.border}`,marginTop:10},children:[o.jsx("span",{style:{width:5,height:5,borderRadius:"50%",background:r.fg,flex:"none",marginTop:5}}),o.jsx("span",{style:{fontSize:10.5,lineHeight:1.6,color:r.fg,minWidth:0},children:t})]})}function Mb({children:e}){return o.jsx("span",{style:{font:`500 10px ${ot}`,color:"var(--proto-ink-2)"},children:e})}function P_({hook:e,selected:t,onSelect:n}){const r=H(),i=e.scriptExists===!1;return o.jsxs("div",{"data-hook-row":e.id,"data-hook-active":t?"":void 0,onClick:()=>n(e.id),role:"button",style:{display:"flex",alignItems:"flex-start",gap:7,padding:"7px 9px",borderRadius:8,background:t?"var(--proto-accent-bg)":"transparent",cursor:"pointer"},children:[o.jsx("span",{"data-hook-order":e.order,style:{font:`500 9.5px ${ot}`,color:"var(--proto-faint)",flex:"none",paddingTop:1},children:String(e.order).padStart(2,"0")}),o.jsxs("div",{style:{flex:1,minWidth:0},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5},children:[o.jsx("span",{style:{font:`600 10.5px ${ot}`,color:t?"var(--proto-accent)":"var(--proto-ink-2)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.id}),i?o.jsx("span",{"data-hook-broken":"",title:r.hkScriptMissing,style:{font:`600 8.5px ${ot}`,padding:"0 5px",borderRadius:999,background:"var(--proto-danger-bg)",color:"var(--proto-danger)",flex:"none"},children:r.hkBroken}):null]}),o.jsx("div",{style:{font:`400 9.5px ${ot}`,color:"var(--proto-muted-2)",marginTop:2,overflowWrap:"anywhere"},children:e.event}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,marginTop:4},children:[e.mountsOn.map(s=>o.jsx(rC,{target:s},s)),o.jsx("span",{style:{marginLeft:"auto",fontSize:9,fontWeight:650,color:e.enabled?"var(--proto-success)":"var(--proto-muted-2)",flex:"none"},children:e.enabled?r.stHookEnabled:r.stHookDisabled})]})]})]})}function R_({hooks:e,visible:t,filter:n,search:r,selectedId:i,onFilter:s,onSearch:a,onSelect:l,onStartCreate:c}){const d=H(),u=n_(e,r),f=i_(t);return o.jsxs(Ye,{style:{width:k_,flex:"none",display:"flex",flexDirection:"column",overflow:"hidden"},children:[o.jsxs("div",{style:{padding:"9px 10px 7px",borderBottom:"1px solid var(--proto-line-2)",flex:"none"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:6},children:[o.jsx("span",{style:{fontSize:11.5,fontWeight:650,color:"var(--proto-ink)"},children:d.stAgentHooks}),o.jsx("span",{style:{font:`400 9.5px ${ot}`,color:"var(--proto-faint)"},children:e.length})]}),o.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:X4.map(h=>{const g=h===n;return o.jsxs("span",{onClick:()=>s(h),role:"button","data-hook-filter":h,"data-active":g?"":void 0,style:{font:`500 9.5px ${ot}`,padding:"2px 7px",borderRadius:6,cursor:"pointer",color:g?"var(--proto-accent)":"var(--proto-muted-2)",background:g?"var(--proto-accent-bg)":"transparent",border:`1px solid ${g?"var(--proto-accent-border)":"var(--proto-line-2)"}`},children:[d[C_[h]],o.jsx("span",{style:{color:"var(--proto-faint)",marginLeft:4},children:u[h]})]},h)})}),o.jsx("input",{"data-hook-search":"",value:r,onChange:h=>a(h.target.value),placeholder:d.hkSearchPh,style:{...Xt,marginTop:7,padding:"4px 8px"}})]}),o.jsx("div",{style:{flex:1,minHeight:0,overflow:"auto",padding:"4px 6px"},children:e.length===0||t.length===0?o.jsx("div",{"data-hooks-empty":"",style:{padding:"14px 8px",fontSize:10.5,color:"var(--proto-faint)",lineHeight:1.7},children:e.length===0?d.stNoHooks:d.hkNoMatch}):f.map(h=>o.jsxs("div",{style:{marginBottom:4},children:[o.jsx("div",{"data-hook-group":h.key,style:{font:`600 9px ${ot}`,letterSpacing:".05em",color:"var(--proto-muted-3)",padding:"7px 9px 3px"},children:h.key==="template"?"template":`${h.key}:`}),h.hooks.map(g=>o.jsx(P_,{hook:g,selected:g.id===i,onSelect:l},g.id))]},h.key))}),o.jsxs("div",{style:{flex:"none",borderTop:"1px solid var(--proto-line-2)",padding:"8px 10px",display:"flex",alignItems:"center",gap:8},children:[o.jsxs("span",{"data-action":"create",onClick:c,role:"button",style:{fontSize:11,fontWeight:600,color:"var(--proto-accent)",cursor:"pointer",flex:"none"},children:["+ ",d.hkCreate]}),o.jsx("span",{style:{marginLeft:"auto",font:`400 9px ${ot}`,color:"var(--proto-faint)"},children:d.hkOrderNote})]})]})}function I_({hook:e}){var r,i,s;const t=H(),n=[{k:t.hkFieldEvent,v:e.event},{k:wf(e.event)==="filters"?t.hkFieldFilters:t.hkFieldMatcher,v:e.matcherFilters?JSON.stringify(e.matcherFilters):e.matcher??t.hkNoMatcher},{k:e.run.command!==null?t.hkFieldCommand:t.hkFieldScript,v:e.run.command??e.run.script??"—"},{k:t.hkFieldTimeout,v:e.run.timeoutSec==null?"—":`${e.run.timeoutSec}s`},{k:t.hkFieldBackends,v:((i=(r=e.scope)==null?void 0:r.backends)==null?void 0:i.join(" · "))??t.hkUnscoped},{k:t.hkFieldRequiresTool,v:((s=e.scope)==null?void 0:s.requiresTool)??"—"},{k:t.hkFieldResult,v:e.result??"none"}];return e.template!==null&&n.push({k:t.hkFieldTemplate,v:`${e.template} · ${e.phase??"—"}`}),o.jsx("div",{style:{font:`400 10px/2 ${ot}`,color:"var(--proto-muted)",marginTop:4},children:n.map(a=>o.jsx(kr,{k:a.k,value:a.v},a.k))})}function M_({draft:e,onDraftChange:t}){const n=H(),r=e.filters,i=s=>t({...e,filters:s});return o.jsxs("div",{"data-hook-filters-editor":"",children:[r.map((s,a)=>o.jsxs("div",{style:{display:"flex",gap:5,marginBottom:4},children:[o.jsx("input",{"data-hook-filter-key":a,value:s.key,placeholder:n.hkFilterKeyPh,onChange:l=>i(r.map((c,d)=>a===d?{...c,key:l.target.value}:c)),style:{...Xt,flex:1}}),o.jsx("input",{"data-hook-filter-value":a,value:s.value,placeholder:n.hkFilterValuePh,onChange:l=>i(r.map((c,d)=>a===d?{...c,value:l.target.value}:c)),style:{...Xt,flex:1}}),o.jsx("span",{"data-hook-filter-remove":a,onClick:()=>i(r.filter((l,c)=>c!==a)),role:"button",title:n.hkRemoveFilter,style:{font:`500 11px ${ot}`,color:"var(--proto-muted-3)",cursor:"pointer",padding:"5px 6px",flex:"none"},children:"×"})]},a)),o.jsxs("span",{"data-action":"add-filter",onClick:()=>i([...r,{key:"",value:""}]),role:"button",style:{fontSize:10.5,fontWeight:600,color:"var(--proto-accent)",cursor:"pointer"},children:["+ ",n.hkAddFilter]})]})}function L_({draft:e,creating:t,errors:n,scripts:r,eventOptions:i,onDraftChange:s}){const a=H(),l=h=>h?a[E_[h]]:void 0,c=wf(e.event),d=c==="regex"?J4(e.matcher):null,u=fd(e.event),f=p_(e.event);return o.jsxs(o.Fragment,{children:[o.jsx(ua,{children:a.hkSecTrigger}),t?o.jsx(Mn,{label:a.hkFieldId,hint:l(n.id),hintTone:"danger",children:o.jsx("input",{"data-hook-field":"id",value:e.id,onChange:h=>s({...e,id:h.target.value}),style:Xt})}):null,o.jsxs(Mn,{label:a.hkFieldEvent,hint:l(n.event),hintTone:"danger",children:[o.jsx("input",{"data-hook-field":"event",list:Ib,value:e.event,onChange:h=>{const g=h.target.value;s({...e,event:g,result:f_(e.result,g)})},style:Xt}),o.jsx("datalist",{id:Ib,children:i.map(h=>o.jsx("option",{value:h},h))})]}),c==="regex"?o.jsx(Mn,{label:a.hkFieldMatcher,hint:d?`${a.hkMatcherInvalid} — ${d}`:a.hkMatcherRegexHint,hintTone:d?"danger":"muted",children:o.jsx("input",{"data-hook-field":"matcher","data-hook-matcher-error":d?"":void 0,value:e.matcher,placeholder:a.hkNoMatcher,onChange:h=>s({...e,matcher:h.target.value}),style:d?{...Xt,borderColor:"var(--proto-danger)"}:Xt})}):o.jsx(Mn,{label:a.hkFieldFilters,hint:l(n.filters)??a.hkMatcherFiltersHint,hintTone:n.filters?"danger":"muted",children:o.jsx(M_,{draft:e,onDraftChange:s})}),o.jsx(ua,{children:a.hkSecAction}),o.jsx(Mn,{label:a.hkFieldRun,hint:l(n.run),hintTone:"danger",children:o.jsx("div",{style:{display:"flex",alignItems:"center",gap:14,paddingTop:3},children:["script","command"].map(h=>o.jsxs("span",{"data-hook-run-kind":h,onClick:()=>s({...e,runKind:h}),role:"button",style:{display:"flex",alignItems:"center",gap:6,cursor:"pointer"},children:[o.jsx(K4,{selected:e.runKind===h}),o.jsx("span",{style:{font:`500 10.5px ${ot}`,color:"var(--proto-ink-2)"},children:h==="script"?a.hkFieldScript:a.hkFieldCommand})]},h))})}),e.runKind==="script"?o.jsxs(Mn,{label:a.hkFieldScript,children:[o.jsx("input",{"data-hook-field":"script",list:Rb,value:e.script,onChange:h=>s({...e,script:h.target.value}),style:Xt}),o.jsx("datalist",{id:Rb,children:r.map(h=>o.jsx("option",{value:h.name},h.name))})]}):o.jsx(Mn,{label:a.hkFieldCommand,children:o.jsx("input",{"data-hook-field":"command",value:e.command,onChange:h=>s({...e,command:h.target.value}),style:Xt})}),o.jsx(Mn,{label:a.hkFieldTimeout,hint:l(n.timeoutSec),hintTone:"danger",children:o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7},children:[o.jsx("input",{"data-hook-field":"timeout",value:e.timeoutSec,placeholder:"30",onChange:h=>s({...e,timeoutSec:h.target.value}),style:{...Xt,width:92}}),o.jsx("span",{style:{fontSize:10,color:"var(--proto-faint)"},children:a.hkSeconds})]})}),o.jsx(ua,{children:a.hkSecScope}),o.jsx(Mn,{label:a.hkFieldBackends,hint:e.backends.length===0?a.hkUnscoped:void 0,children:o.jsx("div",{"data-hook-field":"backends",style:{display:"flex",gap:5,paddingTop:2},children:["claude","pi"].map(h=>{const g=e.backends.includes(h);return o.jsx("span",{"data-hook-backend":h,"data-active":g?"":void 0,onClick:()=>s({...e,backends:g?e.backends.filter(v=>v!==h):[...e.backends,h]}),role:"button",style:{font:`500 10px ${ot}`,padding:"3px 9px",borderRadius:6,cursor:"pointer",color:g?"var(--proto-accent)":"var(--proto-muted-2)",background:g?"var(--proto-accent-bg)":"var(--proto-card)",border:`1px solid ${g?"var(--proto-accent-border)":"var(--proto-line)"}`},children:h},h)})})}),o.jsx(Mn,{label:a.hkFieldRequiresTool,children:o.jsx("input",{"data-hook-field":"requiresTool",value:e.requiresTool,placeholder:"—",onChange:h=>s({...e,requiresTool:h.target.value}),style:Xt})}),o.jsx(ua,{children:a.hkSecAdvanced}),o.jsx(Mn,{label:a.hkFieldResult,hint:f?a.hkResultLocked:l(n.result),hintTone:n.result?"danger":"muted",children:o.jsx("select",{"data-hook-field":"result","data-hook-result-locked":f?"":void 0,disabled:f,value:e.result,onChange:h=>s({...e,result:h.target.value}),style:f?yN:Xt,children:u.map(h=>o.jsx("option",{value:h,children:h},h))})})]})}function O_({hook:e,payload:t,result:n,pending:r,onPayloadChange:i,onRun:s,onClose:a,onReset:l}){const c=H(),d=t.trim()!==""&&!Pb(t),u=!r&&Pb(t);return o.jsxs("div",{style:{marginTop:12,borderTop:"1px solid var(--proto-line-2)",paddingTop:10},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[o.jsx("span",{style:{fontSize:11.5,fontWeight:650,color:"var(--proto-ink)"},children:c.hkTestTitle}),o.jsx("span",{"data-action":"reset-test-payload",onClick:l,role:"button",style:{font:`400 9.5px ${ot}`,color:"var(--proto-accent)",cursor:"pointer",marginLeft:6},children:c.hkTestReset}),o.jsx("span",{"data-action":"close-test",onClick:a,role:"button",style:{marginLeft:"auto",font:`400 9.5px ${ot}`,color:"var(--proto-muted-3)",cursor:"pointer"},children:c.hkTestClose})]}),e.blocking!==null?o.jsx(Vl,{"data-hook-blocking-warning":"",tone:"amber",children:c.hkTestBlockingWarn}):null,o.jsx("div",{style:{fontSize:10,color:"var(--proto-faint)",margin:"8px 0 4px"},children:c.hkTestPayload}),o.jsx("textarea",{"data-hook-test-payload":"",value:t,onChange:f=>i(f.target.value),rows:6,style:{...Xt,resize:"vertical",lineHeight:1.6,borderColor:d?"var(--proto-danger)":"var(--proto-line)"}}),d?o.jsx("div",{"data-hook-payload-error":"",style:{fontSize:9.5,color:"var(--proto-danger)",marginTop:3},children:c.hkPayloadInvalid}):null,o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:8},children:[o.jsx(Yn,{"data-action":"run-test",tone:"accent",disabled:!u,onClick:s,children:c.hkTestRun}),o.jsx("span",{style:{font:`400 9px ${ot}`,color:"var(--proto-faint)"},children:e.run.command??e.run.script??"—"})]}),n!==null?o.jsxs("div",{"data-hook-test-result":"",style:{marginTop:9,border:"1px solid var(--proto-line-2)",borderRadius:8,overflow:"hidden"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 10px",background:"var(--proto-alt)",font:`500 9.5px ${ot}`,color:"var(--proto-muted)"},children:[o.jsxs("span",{"data-hook-test-exit":n.exitCode===null?"":String(n.exitCode),style:{color:n.ok?"var(--proto-success)":"var(--proto-danger)",fontWeight:700},children:["exit ",n.exitCode??"—"]}),n.error!==null?o.jsx("span",{style:{color:"var(--proto-danger)"},children:n.error}):null]}),o.jsx(Lb,{label:"stdout",text:n.stdout}),o.jsx(Lb,{label:"stderr",text:n.stderr,tone:"danger"})]}):null]})}function Lb({label:e,text:t,tone:n}){const r=H(),i=t.trim()==="";return o.jsxs("div",{style:{borderTop:"1px solid var(--proto-line-2)",padding:"6px 10px"},children:[o.jsx("div",{style:{font:`600 9px ${ot}`,color:"var(--proto-muted-3)",marginBottom:3},children:e}),o.jsx("pre",{style:{margin:0,font:`400 10px/1.65 ${ot}`,color:i?"var(--proto-faint)":n==="danger"?"var(--proto-danger)":"var(--proto-ink-2)",whiteSpace:"pre-wrap",wordBreak:"break-word",maxHeight:130,overflow:"auto"},children:i?r.hkTestNoOutput:t})]})}const A_={flex:"none",borderTop:"1px solid var(--proto-line-2)",padding:"9px 14px",display:"flex",alignItems:"center",gap:8};function D_(e){const t=H(),{hook:n,draft:r,creating:i}=e;if(r===null||n===null&&!i)return o.jsx(Ye,{style:{flex:1,minWidth:0,display:"flex",alignItems:"center",justifyContent:"center"},children:o.jsx("span",{style:{fontSize:11.5,color:"var(--proto-muted-3)"},children:t.hkSelectHint})});const s=n?a_(n):null,a=i||((s==null?void 0:s.canEdit)??!1),l=m_(r,{mode:i?"create":"update",existingIds:e.hooks.map(g=>g.id)}),c=i?!0:n!==null&&x_(r,n),d=a&&c&&v_(l)&&!e.saving,u=n!==null&&c_(n),f=n?d_(n.event):null,h=(n==null?void 0:n.appliesAt)??null;return o.jsxs(Ye,{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",overflow:"hidden"},children:[o.jsxs("div",{style:{flex:"none",display:"flex",alignItems:"center",gap:8,padding:"10px 14px",borderBottom:"1px solid var(--proto-line-2)"},children:[o.jsx("span",{style:{font:`600 12px ${ot}`,color:"var(--proto-ink)",minWidth:0,overflowWrap:"anywhere"},children:i?r.id||t.hkCreate:n==null?void 0:n.id}),n?o.jsx(T_,{source:n.source}):null,n==null?void 0:n.mountsOn.map(g=>o.jsx(rC,{target:g},g)),c&&!i?o.jsx("span",{style:{fontSize:9.5,fontWeight:600,color:"var(--proto-amber)"},children:t.hkDirty}):null,n&&(s!=null&&s.canToggle)?o.jsxs("span",{"data-hook-toggle":"","data-hook-enabled":n.enabled?"":void 0,style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:7,flex:"none"},children:[o.jsx("span",{style:{fontSize:10,color:"var(--proto-muted-2)"},children:n.enabled?t.stHookEnabled:t.stHookDisabled}),o.jsx(mf,{on:n.enabled,onClick:e.saving?void 0:()=>e.onToggleEnabled(n,!n.enabled)})]}):null]}),o.jsxs("div",{style:{flex:1,minHeight:0,overflow:"auto",padding:"4px 14px 12px"},children:[(s==null?void 0:s.note)==="managed"?o.jsx(Vl,{"data-hook-note":"managed",tone:"amber",children:t.hkNoteManaged}):null,(s==null?void 0:s.note)==="template-scoped"?o.jsxs(Vl,{"data-hook-note":"template-scoped",tone:"accent",children:[t.hkNoteTemplate,n!=null&&n.template?o.jsxs(Mb,{children:[" · ",n.template]}):null]}):null,u?o.jsxs(Vl,{"data-hook-claude-gap":"",tone:"amber",children:[t.hkClaudeGap," ",f?o.jsx(Mb,{children:f}):null]}):null,(n==null?void 0:n.scriptExists)===!1?o.jsx(Vl,{"data-hook-script-missing":"",tone:"danger",children:t.hkScriptMissing}):null,a?o.jsx(L_,{draft:r,creating:i,errors:l,scripts:e.scripts,eventOptions:j_(e.hooks),onDraftChange:e.onDraftChange}):n?o.jsxs(o.Fragment,{children:[o.jsx(ua,{children:t.hkSecDeclaration}),o.jsx(I_,{hook:n})]}):null,n?o.jsxs(o.Fragment,{children:[o.jsx(ua,{children:t.hkSecRegistry}),o.jsxs("div",{style:{font:`400 10px/2 ${ot}`,color:"var(--proto-muted)"},children:[o.jsx(kr,{k:t.hkFieldSource,value:n.source}),o.jsx(kr,{k:t.hkFieldFile,value:n.fileName??"—"}),o.jsx(kr,{k:t.hkFieldOrder,value:String(n.order)}),o.jsx(kr,{k:t.hkFieldVersion,value:n.version??"—"}),o.jsx(kr,{k:t.hkFieldBlocking,value:n.blocking===null?"—":`${n.blocking.mode} · ${n.blocking.ttlMin} min`}),o.jsx(kr,{k:t.hkFieldMountsOn,value:n.mountsOn.join(" · ")||"—"})]}),h!==null?o.jsx("div",{"data-hook-applies-at":h,style:{fontSize:10,lineHeight:1.7,color:"var(--proto-muted-2)",marginTop:7},children:h==="server-restart"?t.hkAppliesRestart:t.hkAppliesNextAgent}):null]}):null,e.testOpen&&n!==null?o.jsx(O_,{hook:n,payload:e.testPayload,result:e.testResult,pending:e.testPending,onPayloadChange:e.onTestPayloadChange,onRun:e.onRunTest,onClose:e.onCloseTest,onReset:()=>e.onTestPayloadChange(nC(n.event))}):null]}),o.jsxs("div",{style:A_,children:[o.jsx("span",{style:{font:`400 9px ${ot}`,color:"var(--proto-faint)",flex:1,minWidth:0},children:e.hooksDir}),n!==null&&!e.testOpen?o.jsx(Yn,{"data-action":"open-test",tone:"neutral",onClick:e.onOpenTest,children:t.hkTest}):null,i?o.jsxs(o.Fragment,{children:[o.jsx(Yn,{"data-action":"cancel-create",tone:"neutral",onClick:e.onCancelCreate,children:t.hkCancelCreate}),o.jsx(Yn,{"data-action":"save",tone:"accent",disabled:!d,onClick:e.onSave,children:t.hkSave})]}):a?o.jsxs(o.Fragment,{children:[o.jsx(Yn,{"data-action":"revert",tone:"neutral",disabled:!c,onClick:e.onRevert,children:t.hkRevert}),o.jsx(Yn,{"data-action":"save",tone:"accent",disabled:!d,onClick:e.onSave,children:t.hkSave}),e.armedDelete?o.jsxs(o.Fragment,{children:[o.jsx(Yn,{"data-action":"cancel-delete",tone:"neutral",onClick:e.onCancelDelete,children:t.cancel}),o.jsx(Yn,{"data-action":"confirm-delete",tone:"danger",disabled:e.saving,onClick:e.onConfirmDelete,children:t.hkConfirmDelete})]}):o.jsx(Yn,{"data-action":"arm-delete",tone:"danger",disabled:e.saving,onClick:e.onArmDelete,children:t.hkDelete})]}):null]})]})}function N_(e){const t=K0(e.hooks,e.filter,e.search),n=e.hooks.find(r=>r.id===e.selectedId)??null;return o.jsx("div",{"data-settings-panel":"hooks",style:{marginTop:12,flex:1,minHeight:0,display:"flex",flexDirection:"column"},children:o.jsxs("div",{"data-hook-cards":"",style:{display:"flex",gap:12,flex:1,minHeight:0,alignItems:"stretch"},children:[o.jsx(R_,{hooks:e.hooks,visible:t,filter:e.filter,search:e.search,selectedId:e.selectedId,onFilter:e.onFilter,onSearch:e.onSearch,onSelect:e.onSelect,onStartCreate:e.onStartCreate}),o.jsx(D_,{...e,hook:n})]})})}function __(){var te,A;const e=H(),t=le(),n=je(),{toast:r}=dr(),i=Y(t.hooks.list.queryOptions({})),s=p.useMemo(()=>{var V;return((V=i.data)==null?void 0:V.hooks)??[]},[i.data]),[a,l]=p.useState("all"),[c,d]=p.useState(""),[u,f]=p.useState(null),[h,g]=p.useState(!1),[v,x]=p.useState(ru),[b,j]=p.useState(null),[y,w]=p.useState(!1),[k,S]=p.useState(!1),[T,C]=p.useState(""),[P,I]=p.useState(null),L=p.useMemo(()=>K0(s,a,c),[s,a,c]),z=h?null:s_(s,L,u),q=s.find(V=>V.id===z)??null;p.useEffect(()=>{j(null),w(!1),S(!1),I(null)},[z]);const X=()=>n.invalidateQueries(t.hooks.list.queryFilter({})),D=V=>r({title:`${e.hkToastWriteFailed}: ${V.message}`,tone:"failed"}),U=xe(t.hooks.setEnabled.mutationOptions({onSuccess:(V,oe)=>{X(),r({title:oe.enabled?e.hkToastEnabled:e.hkToastDisabled,tone:"done"}),V.warning!==null&&r({title:V.warning,tone:"waiting"})},onError:D})),Q=xe(t.hooks.create.mutationOptions({onSuccess:V=>{X(),r({title:`${e.hkToastCreated} · ${V.fileName}`,tone:"done"}),g(!1),x(ru()),f(V.id)},onError:D})),J=xe(t.hooks.update.mutationOptions({onSuccess:()=>{X(),r({title:e.hkToastSaved,tone:"done"}),j(null)},onError:D})),_=xe(t.hooks.remove.mutationOptions({onSuccess:()=>{X(),r({title:e.hkToastDeleted,tone:"done"}),w(!1),f(null)},onError:D})),F=xe(t.hooks.test.mutationOptions({onSuccess:V=>I(V),onError:V=>{I(null),r({title:`${e.hkToastTestFailed}: ${V.message}`,tone:"failed"})}}));if(i.isLoading)return o.jsx("div",{style:{marginTop:16,fontSize:12,color:"var(--proto-muted-3)"},children:e.hkLoading});if(i.isError)return o.jsxs("div",{style:{marginTop:16,fontSize:12,color:"var(--proto-danger)"},children:[e.hkLoadFailed," ",i.error.message]});const W=h?v:b??(q?eC(q):null);return o.jsx(N_,{hooks:s,scripts:((te=i.data)==null?void 0:te.scripts)??[],hooksDir:((A=i.data)==null?void 0:A.hooksDir)??"",filter:a,search:c,selectedId:z,draft:W,creating:h,armedDelete:y,saving:Q.isPending||J.isPending||_.isPending||U.isPending,testOpen:k,testPayload:T,testResult:P,testPending:F.isPending,onFilter:l,onSearch:d,onSelect:V=>{g(!1),f(V)},onStartCreate:()=>{g(!0),x(ru()),S(!1),w(!1)},onCancelCreate:()=>{g(!1),x(ru())},onDraftChange:V=>h?x(V):j(V),onToggleEnabled:(V,oe)=>U.mutate({id:V.id,enabled:oe}),onSave:()=>{W!==null&&(h?Q.mutate(y_(W)):J.mutate(b_(W)))},onRevert:()=>j(null),onArmDelete:()=>w(!0),onCancelDelete:()=>w(!1),onConfirmDelete:()=>{q!==null&&_.mutate({id:q.id})},onOpenTest:()=>{S(!0),I(null),q!==null&&C(nC(q.event))},onCloseTest:()=>{S(!1),I(null)},onTestPayloadChange:C,onRunTest:()=>{q!==null&&F.mutate({id:q.id,payload:T})}})}const $_="'IBM Plex Mono',monospace";function Ob({value:e,options:t,onChange:n,dataAttr:r}){return o.jsx("div",{style:{display:"flex",gap:2,padding:2,borderRadius:8,background:"var(--proto-gray)",border:"1px solid var(--proto-line)",flex:"none"},children:t.map(i=>{const s=e===i.id;return o.jsx("button",{type:"button","aria-pressed":s,[r]:i.id,onClick:()=>n(i.id),style:{border:"none",cursor:"pointer",fontSize:11.5,fontWeight:600,padding:"4px 16px",borderRadius:6,background:s?"var(--ink-solid-bg)":"transparent",color:s?"var(--ink-solid-fg)":"var(--proto-muted-2)",transition:"background .12s, color .12s"},children:i.label},i.id)})})}function Ab({title:e,hint:t,control:n}){return o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[o.jsxs("div",{style:{flex:1,minWidth:0},children:[o.jsx("div",{style:{fontSize:13,fontWeight:600,color:"var(--proto-ink)"},children:e}),o.jsx("div",{style:{fontSize:10.5,color:"var(--proto-muted-2)",marginTop:3,lineHeight:1.5},children:t})]}),n]})}function F_(){const e=H(),t=O0(),n=A0(),r=ut(),i=l4();return o.jsxs("div",{style:{marginTop:12,maxWidth:760},children:[o.jsx(Ye,{style:{padding:"14px 16px"},children:o.jsx(Ab,{title:e.stLangLabel,hint:e.stLangHint,control:o.jsx(Ob,{value:r,options:[{id:"en",label:e.stLangEnglish},{id:"zh",label:e.stLangChinese}],onChange:i,dataAttr:"data-lang-option"})})}),o.jsx(Ye,{style:{marginTop:12,padding:"14px 16px"},children:o.jsx(Ab,{title:e.stThemeLabel,hint:e.stThemeHint,control:o.jsx(Ob,{value:t,options:[{id:"light",label:e.stThemeLight},{id:"dark",label:e.stThemeDark}],onChange:n,dataAttr:"data-theme-option"})})}),o.jsx("div",{style:{marginTop:10,font:`400 9.5px ${$_}`,color:"var(--proto-faint)",paddingLeft:2},children:"localStorage · cortex.lang · cortex.theme"})]})}const z_={anthropic:'<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M13.827 3.52h3.603L24 20h-3.603l-6.57-16.48zm-7.258 0h3.767L16.906 20h-3.674l-1.343-3.461H5.017l-1.344 3.46H0L6.57 3.522zm4.132 9.959L8.453 7.687 6.205 13.48H10.7z"></path></svg>',antgroup:'<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M15.984 1.383c-.259.593-.877.914-1.334 1.348-.702.669-.998 1.726-1.218 2.682 3.37.775 5.995 3.532 6.486 7.025.566 4.016-1.85 7.859-5.744 9.134-3.894 1.276-8.153-.38-10.126-3.935A8.339 8.339 0 016.457 6.833a18.703 18.703 0 01-.376-.802l-.174-.408a8.698 8.698 0 01-.618-1.987 7.523 7.523 0 01-.051-.37 3.717 3.717 0 01-.024-.34 2.506 2.506 0 01.132-.872 1.26 1.26 0 01.384-.594.842.842 0 011.165.11c.694.82.169 2.078.142 3.02.009.575.111 1.144.301 1.684l-.103.052a8.404 8.404 0 001.318-.79c.28-.243.45-.742.781-.864.33-.121.682.146.946.297.278.145.587.219.901.214l.462.007c.076.002.152.005.226.011.212.01.422.026.63.05l.196-1.08c.04-.216.082-.43.126-.645l.141-.641c.14-.7.42-1.367.823-1.96.305-.431.75-.746 1.262-.89.877-.217 1.24.629.937 1.348zm-2.244 5.44c-2.841.002-4.898 2.532-4.628 5.64.27 3.11 2.781 5.642 5.613 5.666 2.832.024 4.932-2.512 4.658-5.644-.273-3.133-2.802-5.666-5.643-5.663zm.357.57a4.707 4.707 0 013.304 1.445 5.703 5.703 0 011.643 3.49 4.841 4.841 0 01-1.141 3.705v.015a3.923 3.923 0 01-2.808 1.303 4.664 4.664 0 01-3.367-1.387 5.678 5.678 0 01-1.71-3.518 4.832 4.832 0 011.14-3.753 3.923 3.923 0 012.813-1.3h.126z"></path></svg>',azure:'<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M18.397 15.296H7.4a.51.51 0 00-.347.882l7.066 6.595c.206.192.477.298.758.298h6.226l-2.706-7.775z" fill-opacity=".75"></path><path d="M8.295.857c-.477 0-.9.304-1.053.756L.495 21.605a1.11 1.11 0 001.052 1.466h5.43c.477 0 .9-.304 1.053-.755l1.341-3.975-2.318-2.163a.51.51 0 01.347-.882h3L15.271.857H8.295z" fill-opacity=".5"></path><path d="M17.193 1.613a1.11 1.11 0 00-1.052-.756h-7.81.035c.477 0 .9.304 1.052.756l6.748 19.992a1.11 1.11 0 01-1.052 1.466h-.12 7.895a1.11 1.11 0 001.052-1.466L17.193 1.613z"></path></svg>',bedrock:'<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M13.05 15.513h3.08c.214 0 .389.177.389.394v1.82a1.704 1.704 0 011.296 1.661c0 .943-.755 1.708-1.685 1.708-.931 0-1.686-.765-1.686-1.708 0-.807.554-1.484 1.297-1.662v-1.425h-2.69v4.663a.395.395 0 01-.188.338l-2.69 1.641a.385.385 0 01-.405-.002l-4.926-3.086a.395.395 0 01-.185-.336V16.3L2.196 14.87A.395.395 0 012 14.555L2 14.528V9.406c0-.14.073-.27.192-.34l2.465-1.462V4.448c0-.129.062-.249.165-.322l.021-.014L9.77 1.058a.385.385 0 01.407 0l2.69 1.675a.395.395 0 01.185.336V7.6h3.856V5.683a1.704 1.704 0 01-1.296-1.662c0-.943.755-1.708 1.685-1.708.931 0 1.685.765 1.685 1.708 0 .807-.553 1.484-1.296 1.662v2.311a.391.391 0 01-.389.394h-4.245v1.806h6.624a1.69 1.69 0 011.64-1.313c.93 0 1.685.764 1.685 1.707 0 .943-.754 1.708-1.685 1.708a1.69 1.69 0 01-1.64-1.314H13.05v1.937h4.953l.915 1.18a1.66 1.66 0 01.84-.227c.931 0 1.685.764 1.685 1.707 0 .943-.754 1.708-1.685 1.708-.93 0-1.685-.765-1.685-1.708 0-.346.102-.668.276-.937l-.724-.935H13.05v1.806zM9.973 1.856L7.93 3.122V6.09h-.778V3.604L5.435 4.669v2.945l2.11 1.36L9.712 7.61V5.334h.778V7.83c0 .136-.07.263-.184.335L7.963 9.638v2.081l1.422 1.009-.446.646-1.406-.998-1.53 1.005-.423-.66 1.605-1.055v-1.99L5.038 8.29l-2.26 1.34v1.676l1.972-1.189.398.677-2.37 1.429V14.3l2.166 1.258 2.27-1.368.397.677-2.176 1.311V19.3l1.876 1.175 2.365-1.426.398.678-2.017 1.216 1.918 1.201 2.298-1.403v-5.78l-4.758 2.893-.4-.675 5.158-3.136V3.289L9.972 1.856zM16.13 18.47a.913.913 0 00-.908.92c0 .507.406.918.908.918a.913.913 0 00.907-.919.913.913 0 00-.907-.92zm3.63-3.81a.913.913 0 00-.908.92c0 .508.406.92.907.92a.913.913 0 00.908-.92.913.913 0 00-.908-.92zm1.555-4.99a.913.913 0 00-.908.92c0 .507.407.918.908.918a.913.913 0 00.907-.919.913.913 0 00-.907-.92zM17.296 3.1a.913.913 0 00-.907.92c0 .508.406.92.907.92a.913.913 0 00.908-.92.913.913 0 00-.908-.92z"></path></svg>',cerebras:'<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><path clip-rule="evenodd" d="M14.121 2.701a9.299 9.299 0 000 18.598V22.7c-5.91 0-10.7-4.791-10.7-10.701S8.21 1.299 14.12 1.299V2.7zm4.752 3.677A7.353 7.353 0 109.42 17.643l-.901 1.074a8.754 8.754 0 01-1.08-12.334 8.755 8.755 0 0112.335-1.08l-.901 1.075zm-2.255.844a5.407 5.407 0 00-5.048 9.563l-.656 1.24a6.81 6.81 0 016.358-12.043l-.654 1.24zM14.12 8.539a3.46 3.46 0 100 6.922v1.402a4.863 4.863 0 010-9.726v1.402z"></path><path d="M15.407 10.836a2.24 2.24 0 00-.51-.409 1.084 1.084 0 00-.544-.152c-.255 0-.483.047-.684.14a1.58 1.58 0 00-.84.912c-.074.203-.11.416-.11.631 0 .218.036.43.11.631a1.594 1.594 0 00.84.913c.2.093.43.14.684.14.216 0 .417-.046.602-.135.188-.09.35-.225.475-.392l.928 1.006c-.14.14-.3.261-.482.363a3.367 3.367 0 01-1.083.38c-.17.026-.317.04-.44.04a3.315 3.315 0 01-1.182-.21 2.825 2.825 0 01-.961-.597 2.816 2.816 0 01-.644-.929 2.987 2.987 0 01-.238-1.21c0-.444.08-.847.238-1.21.15-.35.368-.666.643-.929.278-.261.605-.464.962-.596a3.315 3.315 0 011.182-.21c.355 0 .712.068 1.072.204.361.138.685.36.944.649l-.962.97z"></path></svg>',claude:'<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M4.709 15.955l4.72-2.647.08-.23-.08-.128H9.2l-.79-.048-2.698-.073-2.339-.097-2.266-.122-.571-.121L0 11.784l.055-.352.48-.321.686.06 1.52.103 2.278.158 1.652.097 2.449.255h.389l.055-.157-.134-.098-.103-.097-2.358-1.596-2.552-1.688-1.336-.972-.724-.491-.364-.462-.158-1.008.656-.722.881.06.225.061.893.686 1.908 1.476 2.491 1.833.365.304.145-.103.019-.073-.164-.274-1.355-2.446-1.446-2.49-.644-1.032-.17-.619a2.97 2.97 0 01-.104-.729L6.283.134 6.696 0l.996.134.42.364.62 1.414 1.002 2.229 1.555 3.03.456.898.243.832.091.255h.158V9.01l.128-1.706.237-2.095.23-2.695.08-.76.376-.91.747-.492.584.28.48.685-.067.444-.286 1.851-.559 2.903-.364 1.942h.212l.243-.242.985-1.306 1.652-2.064.73-.82.85-.904.547-.431h1.033l.76 1.129-.34 1.166-1.064 1.347-.881 1.142-1.264 1.7-.79 1.36.073.11.188-.02 2.856-.606 1.543-.28 1.841-.315.833.388.091.395-.328.807-1.969.486-2.309.462-3.439.813-.042.03.049.061 1.549.146.662.036h1.622l3.02.225.79.522.474.638-.079.485-1.215.62-1.64-.389-3.829-.91-1.312-.329h-.182v.11l1.093 1.068 2.006 1.81 2.509 2.33.127.578-.322.455-.34-.049-2.205-1.657-.851-.747-1.926-1.62h-.128v.17l.444.649 2.345 3.521.122 1.08-.17.353-.608.213-.668-.122-1.374-1.925-1.415-2.167-1.143-1.943-.14.08-.674 7.254-.316.37-.729.28-.607-.461-.322-.747.322-1.476.389-1.924.315-1.53.286-1.9.17-.632-.012-.042-.14.018-1.434 1.967-2.18 2.945-1.726 1.845-.414.164-.717-.37.067-.662.401-.589 2.388-3.036 1.44-1.882.93-1.086-.006-.158h-.055L4.132 18.56l-1.13.146-.487-.456.061-.746.231-.243 1.908-1.312-.006.006z"></path></svg>',cloudflare:'<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M16.493 17.4c.135-.52.08-.983-.161-1.338-.215-.328-.592-.519-1.05-.519l-8.663-.109a.148.148 0 01-.135-.082c-.027-.054-.027-.109-.027-.163.027-.082.108-.164.189-.164l8.744-.11c1.05-.054 2.153-.9 2.556-1.937l.511-1.31c.027-.055.027-.11.027-.164C17.92 8.91 15.66 7 12.942 7c-2.503 0-4.628 1.638-5.381 3.903a2.432 2.432 0 00-1.803-.491c-1.21.109-2.153 1.092-2.287 2.32-.027.328 0 .628.054.9C1.56 13.688 0 15.326 0 17.319c0 .19.027.355.027.545 0 .082.08.137.161.137h15.983c.08 0 .188-.055.215-.164l.107-.437"></path><path d="M19.238 11.75h-.242c-.054 0-.108.054-.135.109l-.35 1.2c-.134.52-.08.983.162 1.338.215.328.592.518 1.05.518l1.855.11c.054 0 .108.027.135.082.027.054.027.109.027.163-.027.082-.108.164-.188.164l-1.91.11c-1.05.054-2.153.9-2.557 1.937l-.134.355c-.027.055.026.137.107.137h6.592c.081 0 .162-.055.162-.137.107-.41.188-.846.188-1.31-.027-2.62-2.153-4.777-4.762-4.777"></path></svg>',codex:'<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><path clip-rule="evenodd" d="M8.086.457a6.105 6.105 0 013.046-.415c1.333.153 2.521.72 3.564 1.7a.117.117 0 00.107.029c1.408-.346 2.762-.224 4.061.366l.063.03.154.076c1.357.703 2.33 1.77 2.918 3.198.278.679.418 1.388.421 2.126a5.655 5.655 0 01-.18 1.631.167.167 0 00.04.155 5.982 5.982 0 011.578 2.891c.385 1.901-.01 3.615-1.183 5.14l-.182.22a6.063 6.063 0 01-2.934 1.851.162.162 0 00-.108.102c-.255.736-.511 1.364-.987 1.992-1.199 1.582-2.962 2.462-4.948 2.451-1.583-.008-2.986-.587-4.21-1.736a.145.145 0 00-.14-.032c-.518.167-1.04.191-1.604.185a5.924 5.924 0 01-2.595-.622 6.058 6.058 0 01-2.146-1.781c-.203-.269-.404-.522-.551-.821a7.74 7.74 0 01-.495-1.283 6.11 6.11 0 01-.017-3.064.166.166 0 00.008-.074.115.115 0 00-.037-.064 5.958 5.958 0 01-1.38-2.202 5.196 5.196 0 01-.333-1.589 6.915 6.915 0 01.188-2.132c.45-1.484 1.309-2.648 2.577-3.493.282-.188.55-.334.802-.438.286-.12.573-.22.861-.304a.129.129 0 00.087-.087A6.016 6.016 0 015.635 2.31C6.315 1.464 7.132.846 8.086.457zm-.804 7.85a.848.848 0 00-1.473.842l1.694 2.965-1.688 2.848a.849.849 0 001.46.864l1.94-3.272a.849.849 0 00.007-.854l-1.94-3.393zm5.446 6.24a.849.849 0 000 1.695h4.848a.849.849 0 000-1.696h-4.848z"></path></svg>',deepseek:'<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M23.748 4.482c-.254-.124-.364.113-.512.234-.051.039-.094.09-.137.136-.372.397-.806.657-1.373.626-.829-.046-1.537.214-2.163.848-.133-.782-.575-1.248-1.247-1.548-.352-.156-.708-.311-.955-.65-.172-.241-.219-.51-.305-.774-.055-.16-.11-.323-.293-.35-.2-.031-.278.136-.356.276-.313.572-.434 1.202-.422 1.84.027 1.436.633 2.58 1.838 3.393.137.093.172.187.129.323-.082.28-.18.552-.266.833-.055.179-.137.217-.329.14a5.526 5.526 0 01-1.736-1.18c-.857-.828-1.631-1.742-2.597-2.458a11.365 11.365 0 00-.689-.471c-.985-.957.13-1.743.388-1.836.27-.098.093-.432-.779-.428-.872.004-1.67.295-2.687.684a3.055 3.055 0 01-.465.137 9.597 9.597 0 00-2.883-.102c-1.885.21-3.39 1.102-4.497 2.623C.082 8.606-.231 10.684.152 12.85c.403 2.284 1.569 4.175 3.36 5.653 1.858 1.533 3.997 2.284 6.438 2.14 1.482-.085 3.133-.284 4.994-1.86.47.234.962.327 1.78.397.63.059 1.236-.03 1.705-.128.735-.156.684-.837.419-.961-2.155-1.004-1.682-.595-2.113-.926 1.096-1.296 2.746-2.642 3.392-7.003.05-.347.007-.565 0-.845-.004-.17.035-.237.23-.256a4.173 4.173 0 001.545-.475c1.396-.763 1.96-2.015 2.093-3.517.02-.23-.004-.467-.247-.588zM11.581 18c-2.089-1.642-3.102-2.183-3.52-2.16-.392.024-.321.471-.235.763.09.288.207.486.371.739.114.167.192.416-.113.603-.673.416-1.842-.14-1.897-.167-1.361-.802-2.5-1.86-3.301-3.307-.774-1.393-1.224-2.887-1.298-4.482-.02-.386.093-.522.477-.592a4.696 4.696 0 011.529-.039c2.132.312 3.946 1.265 5.468 2.774.868.86 1.525 1.887 2.202 2.891.72 1.066 1.494 2.082 2.48 2.914.348.292.625.514.891.677-.802.09-2.14.11-3.054-.614zm1-6.44a.306.306 0 01.415-.287.302.302 0 01.2.288.306.306 0 01-.31.307.303.303 0 01-.304-.308zm3.11 1.596c-.2.081-.399.151-.59.16a1.245 1.245 0 01-.798-.254c-.274-.23-.47-.358-.552-.758a1.73 1.73 0 01.016-.588c.07-.327-.008-.537-.239-.727-.187-.156-.426-.199-.688-.199a.559.559 0 01-.254-.078c-.11-.054-.2-.19-.114-.358.028-.054.16-.186.192-.21.356-.202.767-.136 1.146.016.352.144.618.408 1.001.782.391.451.462.576.685.914.176.265.336.537.445.848.067.195-.019.354-.25.452z"></path></svg>',fireworks:'<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><path clip-rule="evenodd" d="M14.8 5l-2.801 6.795L9.195 5H7.397l3.072 7.428a1.64 1.64 0 003.038.002L16.598 5H14.8zm1.196 10.352l5.124-5.244-.699-1.669-5.596 5.739a1.664 1.664 0 00-.343 1.807 1.642 1.642 0 001.516 1.012L16 17l8-.02-.699-1.669-7.303.041h-.002zM2.88 10.104l.699-1.669 5.596 5.739c.468.479.603 1.189.343 1.807a1.643 1.643 0 01-1.516 1.012l-8-.018-.002.002.699-1.669 7.303.042-5.122-5.246z"></path></svg>',gemini:'<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M20.616 10.835a14.147 14.147 0 01-4.45-3.001 14.111 14.111 0 01-3.678-6.452.503.503 0 00-.975 0 14.134 14.134 0 01-3.679 6.452 14.155 14.155 0 01-4.45 3.001c-.65.28-1.318.505-2.002.678a.502.502 0 000 .975c.684.172 1.35.397 2.002.677a14.147 14.147 0 014.45 3.001 14.112 14.112 0 013.679 6.453.502.502 0 00.975 0c.172-.685.397-1.351.677-2.003a14.145 14.145 0 013.001-4.45 14.113 14.113 0 016.453-3.678.503.503 0 000-.975 13.245 13.245 0 01-2.003-.678z"></path></svg>',githubcopilot:'<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M19.245 5.364c1.322 1.36 1.877 3.216 2.11 5.817.622 0 1.2.135 1.592.654l.73.964c.21.278.323.61.323.955v2.62c0 .339-.173.669-.453.868C20.239 19.602 16.157 21.5 12 21.5c-4.6 0-9.205-2.583-11.547-4.258-.28-.2-.452-.53-.453-.868v-2.62c0-.345.113-.679.321-.956l.73-.963c.392-.517.974-.654 1.593-.654l.029-.297c.25-2.446.81-4.213 2.082-5.52 2.461-2.54 5.71-2.851 7.146-2.864h.198c1.436.013 4.685.323 7.146 2.864zm-7.244 4.328c-.284 0-.613.016-.962.05-.123.447-.305.85-.57 1.108-1.05 1.023-2.316 1.18-2.994 1.18-.638 0-1.306-.13-1.851-.464-.516.165-1.012.403-1.044.996a65.882 65.882 0 00-.063 2.884l-.002.48c-.002.563-.005 1.126-.013 1.69.002.326.204.63.51.765 2.482 1.102 4.83 1.657 6.99 1.657 2.156 0 4.504-.555 6.985-1.657a.854.854 0 00.51-.766c.03-1.682.006-3.372-.076-5.053-.031-.596-.528-.83-1.046-.996-.546.333-1.212.464-1.85.464-.677 0-1.942-.157-2.993-1.18-.266-.258-.447-.661-.57-1.108-.32-.032-.64-.049-.96-.05zm-2.525 4.013c.539 0 .976.426.976.95v1.753c0 .525-.437.95-.976.95a.964.964 0 01-.976-.95v-1.752c0-.525.437-.951.976-.951zm5 0c.539 0 .976.426.976.95v1.753c0 .525-.437.95-.976.95a.964.964 0 01-.976-.95v-1.752c0-.525.437-.951.976-.951zM7.635 5.087c-1.05.102-1.935.438-2.385.906-.975 1.037-.765 3.668-.21 4.224.405.394 1.17.657 1.995.657h.09c.649-.013 1.785-.176 2.73-1.11.435-.41.705-1.433.675-2.47-.03-.834-.27-1.52-.63-1.813-.39-.336-1.275-.482-2.265-.394zm6.465.394c-.36.292-.6.98-.63 1.813-.03 1.037.24 2.06.675 2.47.968.957 2.136 1.104 2.776 1.11h.044c.825 0 1.59-.263 1.995-.657.555-.556.765-3.187-.21-4.224-.45-.468-1.335-.804-2.385-.906-.99-.088-1.875.058-2.265.394zM12 7.615c-.24 0-.525.015-.84.044.03.16.045.336.06.526l-.001.159a2.94 2.94 0 01-.014.25c.225-.022.425-.027.612-.028h.366c.187 0 .387.006.612.028-.015-.146-.015-.277-.015-.409.015-.19.03-.365.06-.526a9.29 9.29 0 00-.84-.044z"></path></svg>',groq:'<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M12.036 2c-3.853-.035-7 3-7.036 6.781-.035 3.782 3.055 6.872 6.908 6.907h2.42v-2.566h-2.292c-2.407.028-4.38-1.866-4.408-4.23-.029-2.362 1.901-4.298 4.308-4.326h.1c2.407 0 4.358 1.915 4.365 4.278v6.305c0 2.342-1.944 4.25-4.323 4.279a4.375 4.375 0 01-3.033-1.252l-1.851 1.818A7 7 0 0012.029 22h.092c3.803-.056 6.858-3.083 6.879-6.816v-6.5C18.907 4.963 15.817 2 12.036 2z"></path></svg>',huggingface:'<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M16.781 3.277c2.997 1.704 4.844 4.851 4.844 8.258 0 .995-.155 1.955-.443 2.857a1.332 1.332 0 011.125.4 1.41 1.41 0 01.2 1.723c.204.165.352.385.428.632l.017.062c.06.222.12.69-.2 1.166.244.37.279.836.093 1.236-.255.57-.893 1.018-2.128 1.5l-.202.078-.131.048c-.478.173-.89.295-1.061.345l-.086.024c-.89.243-1.808.375-2.732.394-1.32 0-2.3-.36-2.923-1.067a9.852 9.852 0 01-3.18.018C9.778 21.647 8.802 22 7.494 22a11.249 11.249 0 01-2.541-.343l-.221-.06-.273-.08a16.574 16.574 0 01-1.175-.405c-1.237-.483-1.875-.93-2.13-1.501-.186-.4-.151-.867.093-1.236a1.42 1.42 0 01-.2-1.166c.069-.273.226-.516.447-.694a1.41 1.41 0 01.2-1.722c.233-.248.557-.391.917-.407l.078-.001a9.385 9.385 0 01-.44-2.85c0-3.407 1.847-6.554 4.844-8.258a9.822 9.822 0 019.687 0zM4.188 14.758c.125.687 2.357 2.35 2.14 2.707-.19.315-.796-.239-.948-.386l-.041-.04-.168-.147c-.561-.479-2.304-1.9-2.74-1.432-.43.46.119.859 1.055 1.42l.784.467.136.083c1.045.643 1.12.84.95 1.113-.188.295-3.07-2.1-3.34-1.083-.27 1.011 2.942 1.304 2.744 2.006-.2.7-2.265-1.324-2.685-.537-.425.79 2.913 1.718 2.94 1.725l.16.04.175.042c1.227.284 3.565.65 4.435-.604.673-.973.64-1.709-.248-2.61l-.057-.057c-.945-.928-1.495-2.288-1.495-2.288l-.017-.058-.025-.072c-.082-.22-.284-.639-.63-.584-.46.073-.798 1.21.12 1.933l.05.038c.977.721-.195 1.21-.573.534l-.058-.104-.143-.25c-.463-.799-1.282-2.111-1.739-2.397-.532-.332-.907-.148-.782.541zm14.842-.541c-.533.335-1.563 2.074-1.94 2.751a.613.613 0 01-.687.302.436.436 0 01-.176-.098.303.303 0 01-.049-.06l-.014-.028-.008-.02-.007-.019-.003-.013-.003-.017a.289.289 0 01-.004-.048c0-.12.071-.266.25-.427.026-.024.054-.047.084-.07l.047-.036c.022-.016.043-.032.063-.049.883-.71.573-1.81.131-1.917l-.031-.006-.056-.004a.368.368 0 00-.062.006l-.028.005-.042.014-.039.017-.028.015-.028.019-.036.027-.023.02c-.173.158-.273.428-.31.542l-.016.054s-.53 1.309-1.439 2.234l-.054.054c-.365.358-.596.69-.702 1.018-.143.437-.066.868.21 1.353.055.097.117.195.187.296.882 1.275 3.282.876 4.494.59l.286-.07.25-.074c.276-.084.736-.233 1.2-.42l.188-.077.065-.028.064-.028.124-.056.081-.038c.529-.252.964-.543.994-.827l.001-.036a.299.299 0 00-.037-.139c-.094-.176-.271-.212-.491-.168l-.045.01c-.044.01-.09.024-.136.04l-.097.035-.054.022c-.559.23-1.238.705-1.607.745h.006a.452.452 0 01-.05.003h-.024l-.024-.003-.023-.005c-.068-.016-.116-.06-.14-.142a.22.22 0 01-.005-.1c.062-.345.958-.595 1.713-.91l.066-.028c.528-.224.97-.483.985-.832v-.04a.47.47 0 00-.016-.098c-.048-.18-.175-.251-.36-.251-.785 0-2.55 1.36-2.92 1.36-.025 0-.048-.007-.058-.024a.6.6 0 01-.046-.088c-.1-.238.068-.462 1.06-1.066l.209-.126c.538-.32 1.01-.588 1.341-.831.29-.212.475-.406.503-.6l.003-.028c.008-.113-.038-.227-.147-.344a.266.266 0 00-.07-.054l-.034-.015-.013-.005a.403.403 0 00-.13-.02c-.162 0-.369.07-.595.18-.637.313-1.431.952-1.826 1.285l-.249.215-.033.033c-.08.078-.288.27-.493.386l-.071.037-.041.019a.535.535 0 01-.122.036h.005a.346.346 0 01-.031.003l.01-.001-.013.001c-.079.005-.145-.021-.19-.095a.113.113 0 01-.014-.065c.027-.465 2.034-1.991 2.152-2.642l.009-.048c.1-.65-.271-.817-.791-.493zM11.938 2.984c-4.798 0-8.688 3.829-8.688 8.55 0 .692.083 1.364.24 2.008l.008-.009c.252-.298.612-.46 1.017-.46.355.008.699.117.993.312.22.14.465.384.715.694.261-.372.69-.598 1.15-.605.852 0 1.367.728 1.562 1.383l.047.105.06.127c.192.396.595 1.139 1.143 1.68 1.06 1.04 1.324 2.115.8 3.266a8.865 8.865 0 002.024-.014c-.505-1.12-.26-2.17.74-3.186l.066-.066c.695-.684 1.157-1.69 1.252-1.912.195-.655.708-1.383 1.56-1.383.46.007.889.233 1.15.605.25-.31.495-.553.718-.694a1.87 1.87 0 01.99-.312c.357 0 .682.126.925.36.14-.61.215-1.245.215-1.898 0-4.722-3.89-8.55-8.687-8.55zm1.857 8.926l.439-.212c.553-.264.89-.383.89.152 0 1.093-.771 3.208-3.155 3.262h-.184c-2.325-.052-3.116-2.06-3.156-3.175l-.001-.087c0-1.107 1.452.586 3.25.586.716 0 1.379-.272 1.917-.526zm4.017-3.143c.45 0 .813.358.813.8 0 .441-.364.8-.813.8a.806.806 0 01-.812-.8c0-.442.364-.8.812-.8zm-11.624 0c.448 0 .812.358.812.8 0 .441-.364.8-.812.8a.806.806 0 01-.813-.8c0-.442.364-.8.813-.8zm7.79-.841c.32-.384.846-.54 1.33-.394.483.146.83.564.878 1.06.048.495-.212.97-.659 1.203-.322.168-.447-.477-.767-.585l.002-.003c-.287-.098-.772.362-.925.079a1.215 1.215 0 01.14-1.36zm-4.323 0c.322.384.377.92.14 1.36-.152.283-.64-.177-.925-.079l.003.003c-.108.036-.194.134-.273.24l-.118.165c-.11.15-.22.262-.377.18a1.226 1.226 0 01-.658-1.204c.048-.495.395-.913.878-1.059a1.262 1.262 0 011.33.394z"></path></svg>',kimi:'<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M21.846 0a1.923 1.923 0 110 3.846H20.15a.226.226 0 01-.227-.226V1.923C19.923.861 20.784 0 21.846 0z"></path><path d="M11.065 11.199l7.257-7.2c.137-.136.06-.41-.116-.41H14.3a.164.164 0 00-.117.051l-7.82 7.756c-.122.12-.302.013-.302-.179V3.82c0-.127-.083-.23-.185-.23H3.186c-.103 0-.186.103-.186.23V19.77c0 .128.083.23.186.23h2.69c.103 0 .186-.102.186-.23v-3.25c0-.069.025-.135.069-.178l2.424-2.406a.158.158 0 01.205-.023l6.484 4.772a7.677 7.677 0 003.453 1.283c.108.012.2-.095.2-.23v-3.06c0-.117-.07-.212-.164-.227a5.028 5.028 0 01-2.027-.807l-5.613-4.064c-.117-.078-.132-.279-.028-.381z"></path></svg>',minimax:'<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M16.278 2c1.156 0 2.093.927 2.093 2.07v12.501a.74.74 0 00.744.709.74.74 0 00.743-.709V9.099a2.06 2.06 0 012.071-2.049A2.06 2.06 0 0124 9.1v6.561a.649.649 0 01-.652.645.649.649 0 01-.653-.645V9.1a.762.762 0 00-.766-.758.762.762 0 00-.766.758v7.472a2.037 2.037 0 01-2.048 2.026 2.037 2.037 0 01-2.048-2.026v-12.5a.785.785 0 00-.788-.753.785.785 0 00-.789.752l-.001 15.904A2.037 2.037 0 0113.441 22a2.037 2.037 0 01-2.048-2.026V18.04c0-.356.292-.645.652-.645.36 0 .652.289.652.645v1.934c0 .263.142.506.372.638.23.131.514.131.744 0a.734.734 0 00.372-.638V4.07c0-1.143.937-2.07 2.093-2.07zm-5.674 0c1.156 0 2.093.927 2.093 2.07v11.523a.648.648 0 01-.652.645.648.648 0 01-.652-.645V4.07a.785.785 0 00-.789-.78.785.785 0 00-.789.78v14.013a2.06 2.06 0 01-2.07 2.048 2.06 2.06 0 01-2.071-2.048V9.1a.762.762 0 00-.766-.758.762.762 0 00-.766.758v3.8a2.06 2.06 0 01-2.071 2.049A2.06 2.06 0 010 12.9v-1.378c0-.357.292-.646.652-.646.36 0 .653.29.653.646V12.9c0 .418.343.757.766.757s.766-.339.766-.757V9.099a2.06 2.06 0 012.07-2.048 2.06 2.06 0 012.071 2.048v8.984c0 .419.343.758.767.758.423 0 .766-.339.766-.758V4.07c0-1.143.937-2.07 2.093-2.07z"></path></svg>',mistral:'<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><path clip-rule="evenodd" d="M3.428 3.4h3.429v3.428h3.429v3.429h-.002 3.431V6.828h3.427V3.4h3.43v13.714H24v3.429H13.714v-3.428h-3.428v-3.429h-3.43v3.428h3.43v3.429H0v-3.429h3.428V3.4zm10.286 13.715h3.428v-3.429h-3.427v3.429z"></path></svg>',moonshot:'<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M1.052 16.916l9.539 2.552a21.007 21.007 0 00.06 2.033l5.956 1.593a11.997 11.997 0 01-5.586.865l-.18-.016-.044-.004-.084-.009-.094-.01a11.605 11.605 0 01-.157-.02l-.107-.014-.11-.016a11.962 11.962 0 01-.32-.051l-.042-.008-.075-.013-.107-.02-.07-.015-.093-.019-.075-.016-.095-.02-.097-.023-.094-.022-.068-.017-.088-.022-.09-.024-.095-.025-.082-.023-.109-.03-.062-.02-.084-.025-.093-.028-.105-.034-.058-.019-.08-.026-.09-.031-.066-.024a6.293 6.293 0 01-.044-.015l-.068-.025-.101-.037-.057-.022-.08-.03-.087-.035-.088-.035-.079-.032-.095-.04-.063-.028-.063-.027a5.655 5.655 0 01-.041-.018l-.066-.03-.103-.047-.052-.024-.096-.046-.062-.03-.084-.04-.086-.044-.093-.047-.052-.027-.103-.055-.057-.03-.058-.032a6.49 6.49 0 01-.046-.026l-.094-.053-.06-.034-.051-.03-.072-.041-.082-.05-.093-.056-.052-.032-.084-.053-.061-.039-.079-.05-.07-.047-.053-.035a7.785 7.785 0 01-.054-.036l-.044-.03-.044-.03a6.066 6.066 0 01-.04-.028l-.057-.04-.076-.054-.069-.05-.074-.054-.056-.042-.076-.057-.076-.059-.086-.067-.045-.035-.064-.052-.074-.06-.089-.073-.046-.039-.046-.039a7.516 7.516 0 01-.043-.037l-.045-.04-.061-.053-.07-.062-.068-.06-.062-.058-.067-.062-.053-.05-.088-.084a13.28 13.28 0 01-.099-.097l-.029-.028-.041-.042-.069-.07-.05-.051-.05-.053a6.457 6.457 0 01-.168-.179l-.08-.088-.062-.07-.071-.08-.042-.049-.053-.062-.058-.068-.046-.056a7.175 7.175 0 01-.027-.033l-.045-.055-.066-.082-.041-.052-.05-.064-.02-.025a11.99 11.99 0 01-1.44-2.402zm-1.02-5.794l11.353 3.037a20.468 20.468 0 00-.469 2.011l10.817 2.894a12.076 12.076 0 01-1.845 2.005L.657 15.923l-.016-.046-.035-.104a11.965 11.965 0 01-.05-.153l-.007-.023a11.896 11.896 0 01-.207-.741l-.03-.126-.018-.08-.021-.097-.018-.081-.018-.09-.017-.084-.018-.094c-.026-.141-.05-.283-.071-.426l-.017-.118-.011-.083-.013-.102a12.01 12.01 0 01-.019-.161l-.005-.047a12.12 12.12 0 01-.034-2.145zm1.593-5.15l11.948 3.196c-.368.605-.705 1.231-1.01 1.875l11.295 3.022c-.142.82-.368 1.612-.668 2.365l-11.55-3.09L.124 10.26l.015-.1.008-.049.01-.067.015-.087.018-.098c.026-.148.056-.295.088-.442l.028-.124.02-.085.024-.097c.022-.09.045-.18.07-.268l.028-.102.023-.083.03-.1.025-.082.03-.096.026-.082.031-.095a11.896 11.896 0 011.01-2.232zm4.442-4.4L17.352 4.59a20.77 20.77 0 00-1.688 1.721l7.823 2.093c.267.852.442 1.744.513 2.665L2.106 5.213l.045-.065.027-.04.04-.055.046-.065.055-.076.054-.072.064-.086.05-.065.057-.073.055-.07.06-.074.055-.069.065-.077.054-.066.066-.077.053-.06.072-.082.053-.06.067-.074.054-.058.073-.078.058-.06.063-.067.168-.17.1-.098.059-.056.076-.071a12.084 12.084 0 012.272-1.677zM12.017 0h.097l.082.001.069.001.054.002.068.002.046.001.076.003.047.002.06.003.054.002.087.005.105.007.144.011.088.007.044.004.077.008.082.008.047.005.102.012.05.006.108.014.081.01.042.006.065.01.207.032.07.012.065.011.14.026.092.018.11.022.046.01.075.016.041.01L14.7.3l.042.01.065.015.049.012.071.017.096.024.112.03.113.03.113.032.05.015.07.02.078.024.073.023.05.016.05.016.076.025.099.033.102.036.048.017.064.023.093.034.11.041.116.045.1.04.047.02.06.024.041.018.063.026.04.018.057.025.11.048.1.046.074.035.075.036.06.028.092.046.091.045.102.052.053.028.049.026.046.024.06.033.041.022.052.029.088.05.106.06.087.051.057.034.053.032.096.059.088.055.098.062.036.024.064.041.084.056.04.027.062.042.062.043.023.017c.054.037.108.075.161.114l.083.06.065.048.056.043.086.065.082.064.04.03.05.041.086.069.079.065.085.071c.712.6 1.353 1.283 1.909 2.031L7.222.994l.062-.027.065-.028.081-.034.086-.035c.113-.045.227-.09.341-.131l.096-.035.093-.033.084-.03.096-.031c.087-.03.176-.058.264-.085l.091-.027.086-.025.102-.03.085-.023.1-.026L9.04.37l.09-.023.091-.022.095-.022.09-.02.098-.021.091-.02.095-.018.092-.018.1-.018.091-.016.098-.017.092-.014.097-.015.092-.013.102-.013.091-.012.105-.012.09-.01.105-.01c.093-.01.186-.018.28-.024l.106-.008.09-.005.11-.006.093-.004.1-.004.097-.002.099-.002.197-.002z"></path></svg>',nvidia:'<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M10.212 8.976V7.62c.127-.01.256-.017.388-.021 3.596-.117 5.957 3.184 5.957 3.184s-2.548 3.647-5.282 3.647a3.227 3.227 0 01-1.063-.175v-4.109c1.4.174 1.681.812 2.523 2.258l1.873-1.627a4.905 4.905 0 00-3.67-1.846 6.594 6.594 0 00-.729.044m0-4.476v2.025c.13-.01.259-.019.388-.024 5.002-.174 8.261 4.226 8.261 4.226s-3.743 4.69-7.643 4.69c-.338 0-.675-.031-1.007-.092v1.25c.278.038.558.057.838.057 3.629 0 6.253-1.91 8.794-4.169.421.347 2.146 1.193 2.501 1.564-2.416 2.083-8.048 3.763-11.24 3.763-.308 0-.603-.02-.894-.048V19.5H24v-15H10.21zm0 9.756v1.068c-3.356-.616-4.287-4.21-4.287-4.21a7.173 7.173 0 014.287-2.138v1.172h-.005a3.182 3.182 0 00-2.502 1.178s.615 2.276 2.507 2.931m-5.961-3.3c1.436-1.935 3.604-3.148 5.961-3.336V6.523C5.81 6.887 2 10.723 2 10.723s2.158 6.427 8.21 7.015v-1.166C5.77 16 4.25 10.958 4.25 10.958h-.002z"></path></svg>',openai:'<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M9.205 8.658v-2.26c0-.19.072-.333.238-.428l4.543-2.616c.619-.357 1.356-.523 2.117-.523 2.854 0 4.662 2.212 4.662 4.566 0 .167 0 .357-.024.547l-4.71-2.759a.797.797 0 00-.856 0l-5.97 3.473zm10.609 8.8V12.06c0-.333-.143-.57-.429-.737l-5.97-3.473 1.95-1.118a.433.433 0 01.476 0l4.543 2.617c1.309.76 2.189 2.378 2.189 3.948 0 1.808-1.07 3.473-2.76 4.163zM7.802 12.703l-1.95-1.142c-.167-.095-.239-.238-.239-.428V5.899c0-2.545 1.95-4.472 4.591-4.472 1 0 1.927.333 2.712.928L8.23 5.067c-.285.166-.428.404-.428.737v6.898zM12 15.128l-2.795-1.57v-3.33L12 8.658l2.795 1.57v3.33L12 15.128zm1.796 7.23c-1 0-1.927-.332-2.712-.927l4.686-2.712c.285-.166.428-.404.428-.737v-6.898l1.974 1.142c.167.095.238.238.238.428v5.233c0 2.545-1.974 4.472-4.614 4.472zm-5.637-5.303l-4.544-2.617c-1.308-.761-2.188-2.378-2.188-3.948A4.482 4.482 0 014.21 6.327v5.423c0 .333.143.571.428.738l5.947 3.449-1.95 1.118a.432.432 0 01-.476 0zm-.262 3.9c-2.688 0-4.662-2.021-4.662-4.519 0-.19.024-.38.047-.57l4.686 2.71c.286.167.571.167.856 0l5.97-3.448v2.26c0 .19-.07.333-.237.428l-4.543 2.616c-.619.357-1.356.523-2.117.523zm5.899 2.83a5.947 5.947 0 005.827-4.756C22.287 18.339 24 15.84 24 13.296c0-1.665-.713-3.282-1.998-4.448.119-.5.19-.999.19-1.498 0-3.401-2.759-5.947-5.946-5.947-.642 0-1.26.095-1.88.31A5.962 5.962 0 0010.205 0a5.947 5.947 0 00-5.827 4.757C1.713 5.447 0 7.945 0 10.49c0 1.666.713 3.283 1.998 4.448-.119.5-.19 1-.19 1.499 0 3.401 2.759 5.946 5.946 5.946.642 0 1.26-.095 1.88-.309a5.96 5.96 0 004.162 1.713z"></path></svg>',opencode:'<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M16 6H8v12h8V6zm4 16H4V2h16v20z"></path></svg>',openrouter:'<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M18.654 3.87a5.087 5.087 0 110 10.174L23.7 19.09c.64.641.187 1.737-.72 1.737H8.48a8.479 8.479 0 010-16.958h10.175zM8.479 7.26a5.087 5.087 0 100 10.176 5.087 5.087 0 000-10.175z"></path></svg>',qwen:'<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M12.604 1.34c.393.69.784 1.382 1.174 2.075a.18.18 0 00.157.091h5.552c.174 0 .322.11.446.327l1.454 2.57c.19.337.24.478.024.837-.26.43-.513.864-.76 1.3l-.367.658c-.106.196-.223.28-.04.512l2.652 4.637c.172.301.111.494-.043.77-.437.785-.882 1.564-1.335 2.34-.159.272-.352.375-.68.37-.777-.016-1.552-.01-2.327.016a.099.099 0 00-.081.05 575.097 575.097 0 01-2.705 4.74c-.169.293-.38.363-.725.364-.997.003-2.002.004-3.017.002a.537.537 0 01-.465-.271l-1.335-2.323a.09.09 0 00-.083-.049H4.982c-.285.03-.553-.001-.805-.092l-1.603-2.77a.543.543 0 01-.002-.54l1.207-2.12a.198.198 0 000-.197 550.951 550.951 0 01-1.875-3.272l-.79-1.395c-.16-.31-.173-.496.095-.965.465-.813.927-1.625 1.387-2.436.132-.234.304-.334.584-.335a338.3 338.3 0 012.589-.001.124.124 0 00.107-.063l2.806-4.895a.488.488 0 01.422-.246c.524-.001 1.053 0 1.583-.006L11.704 1c.341-.003.724.032.9.34zm-3.432.403a.06.06 0 00-.052.03L6.254 6.788a.157.157 0 01-.135.078H3.253c-.056 0-.07.025-.041.074l5.81 10.156c.025.042.013.062-.034.063l-2.795.015a.218.218 0 00-.2.116l-1.32 2.31c-.044.078-.021.118.068.118l5.716.008c.046 0 .08.02.104.061l1.403 2.454c.046.081.092.082.139 0l5.006-8.76.783-1.382a.055.055 0 01.096 0l1.424 2.53a.122.122 0 00.107.062l2.763-.02a.04.04 0 00.035-.02.041.041 0 000-.04l-2.9-5.086a.108.108 0 010-.113l.293-.507 1.12-1.977c.024-.041.012-.062-.035-.062H9.2c-.059 0-.073-.026-.043-.077l1.434-2.505a.107.107 0 000-.114L9.225 1.774a.06.06 0 00-.053-.031zm6.29 8.02c.046 0 .058.02.034.06l-.832 1.465-2.613 4.585a.056.056 0 01-.05.029.058.058 0 01-.05-.029L8.498 9.841c-.02-.034-.01-.052.028-.054l.216-.012 6.722-.012z"></path></svg>',together:'<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M23.197 4.503A6 6 0 0015 2.307a5.973 5.973 0 00-2.995 4.933l5.996.008v.515h-5.996c.039.937.298 1.87.8 2.74a6 6 0 1010.39-6z"></path><path d="M.805 4.5A6 6 0 003 12.697a5.972 5.972 0 005.77.127L5.779 7.627l.446-.257 2.997 5.192A6 6 0 10.804 4.5z"></path><path d="M12 23.894a6 6 0 005.999-6c0-2.13-1.1-3.996-2.775-5.06l-3.005 5.189-.444-.258 2.997-5.192A6 6 0 1012 23.894z"></path></svg>',vercel:'<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M12 0l12 20.785H0L12 0z"></path></svg>',vertexai:'<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M11.995 20.216a1.892 1.892 0 100 3.785 1.892 1.892 0 000-3.785zm0 2.806a.927.927 0 11.927-.914.914.914 0 01-.927.914z"></path><path clip-rule="evenodd" d="M21.687 14.144c.237.038.452.16.605.344a.978.978 0 01-.18 1.3l-8.24 6.082a1.892 1.892 0 00-1.147-1.508l8.28-6.08a.991.991 0 01.682-.138z"></path><path clip-rule="evenodd" d="M10.122 21.842l-8.217-6.066a.952.952 0 01-.206-1.287.978.978 0 011.287-.206l8.28 6.08a1.893 1.893 0 00-1.144 1.479z"></path><path d="M4.273 4.475a.978.978 0 01-.965-.965V1.09a.978.978 0 111.943 0v2.42a.978.978 0 01-.978.965zM4.247 13.034a.978.978 0 100-1.956.978.978 0 000 1.956zM4.247 10.19a.978.978 0 100-1.956.978.978 0 000 1.956zM4.247 7.332a.978.978 0 100-1.956.978.978 0 000 1.956z"></path><path d="M19.718 7.307a.978.978 0 01-.965-.979v-2.42a.965.965 0 011.93 0v2.42a.964.964 0 01-.965.979zM19.743 13.047a.978.978 0 100-1.956.978.978 0 000 1.956zM19.743 10.151a.978.978 0 100-1.956.978.978 0 000 1.956zM19.743 2.068a.978.978 0 100-1.956.978.978 0 000 1.956z"></path><path d="M11.995 15.917a.978.978 0 01-.965-.965v-2.459a.978.978 0 011.943 0v2.433a.976.976 0 01-.978.991zM11.995 18.762a.978.978 0 100-1.956.978.978 0 000 1.956zM11.995 10.64a.978.978 0 100-1.956.978.978 0 000 1.956zM11.995 7.783a.978.978 0 100-1.956.978.978 0 000 1.956z"></path><path d="M15.856 10.177a.978.978 0 01-.965-.965v-2.42a.977.977 0 011.702-.763.979.979 0 01.241.763v2.42a.978.978 0 01-.978.965zM15.869 4.913a.978.978 0 100-1.956.978.978 0 000 1.956zM15.869 15.853a.978.978 0 100-1.956.978.978 0 000 1.956zM15.869 12.996a.978.978 0 100-1.956.978.978 0 000 1.956z"></path><path d="M8.121 15.853a.978.978 0 100-1.956.978.978 0 000 1.956zM8.121 7.783a.978.978 0 100-1.956.978.978 0 000 1.956zM8.121 4.913a.978.978 0 100-1.957.978.978 0 000 1.957zM8.134 12.996a.978.978 0 01-.978-.94V9.611a.965.965 0 011.93 0v2.445a.966.966 0 01-.952.94z"></path></svg>',xai:'<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M6.469 8.776L16.512 23h-4.464L2.005 8.776H6.47zm-.004 7.9l2.233 3.164L6.467 23H2l4.465-6.324zM22 2.582V23h-3.659V7.764L22 2.582zM22 1l-9.952 14.095-2.233-3.163L17.533 1H22z"></path></svg>',xiaomimimo:'<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M.958 15.936a.459.459 0 01.459.44v2.729a.46.46 0 01-.918 0v-2.729a.459.459 0 01.459-.44zm4.814-2.035a.46.46 0 01.553.45v4.754a.458.458 0 11-.918 0V15.48L3.74 17.202a.462.462 0 01-.655.016.462.462 0 01-.065-.082L.628 14.67a.459.459 0 01.658-.637l2.124 2.187 2.127-2.188a.46.46 0 01.235-.13zm2.068.004a.46.46 0 01.458.445v4.755a.46.46 0 01-.458.458.459.459 0 01-.458-.458V14.35a.459.459 0 01.458-.445zm1.973 2.014a.46.46 0 01.46.457v2.729a.46.46 0 01-.784.324.46.46 0 01-.134-.324v-2.729a.46.46 0 01.458-.458zm.002-2.045a.458.458 0 01.328.157l2.127 2.19 2.125-2.19a.459.459 0 01.784.318v4.756a.46.46 0 01-.455.458.46.46 0 01-.458-.458V15.48l-1.667 1.723a.46.46 0 01-.65.008l-.005-.005c0-.002-.002-.002-.004-.003l-2.455-2.534a.46.46 0 01-.008-.667.461.461 0 01.338-.128zm6.797 1.206a.46.46 0 01.53.651A1.966 1.966 0 0019.81 18.4a.462.462 0 01.623.18.46.46 0 01-.181.624 2.863 2.863 0 01-1.38.353l-.142-.004a2.88 2.88 0 01-2.393-4.263.461.461 0 01.274-.21zm.864-.931a2.884 2.884 0 013.915 3.914.46.46 0 01-.402.24l-.057-.004a.458.458 0 01-.164-.055.46.46 0 01-.182-.622 1.967 1.967 0 00-2.669-2.67.459.459 0 11-.441-.803zM9.59 6.368c1.481 0 1.696 1.202 1.696 1.654v2.648h-.917v-.432c-.26.346-.792.535-1.36.535-.133 0-1.289-.03-1.384-1.136-.082-.932.675-1.61 2.053-1.61h.691c0-.563-.367-.886-.983-.886-.44.013-.864.174-1.2.458l-.36-.664c.484-.379 1.012-.567 1.764-.567zm4.427.1c1.263 0 2.082.97 2.083 2.15 0 1.181-.824 2.154-2.083 2.154-1.26 0-2.084-.972-2.084-2.152 0-1.18.82-2.153 2.084-2.153zm6.801.015c.68 0 1.202.465 1.197 1.548v2.642H21.1V8.29c0-.312-.002-.98-.63-.98s-.628.667-.628.838v2.524h-.89V8.148c0-.17-.001-.838-.63-.838-.628 0-.628.668-.628.98v2.383h-.917v-4.03h.917V7a1.22 1.22 0 01.947-.516c.398 0 .76.193.982.686a1.321 1.321 0 011.195-.686zm-18.093.872l1.457-1.772H5.32L3.311 8.07l2.14 2.602H4.24L2.725 8.796 1.21 10.672H0L2.138 8.07.13 5.583h1.138l1.458 1.772zm4.149 3.317h-.916V6.644h.916v4.028zm16.99 0h-.916V6.644h.916v4.028zM9.925 8.71c-1.055 0-1.359.412-1.326.742.032.329.324.537.757.537a1.013 1.013 0 001.014-.968l.002-.31h-.447zM14.018 7.3c-.663 0-1.184.487-1.184 1.32 0 .832.52 1.32 1.184 1.32.662 0 1.182-.49 1.182-1.32 0-.832-.52-1.32-1.182-1.32zM6.417 5.001a.568.568 0 01.587.582.588.588 0 01-1.175 0A.57.57 0 016.417 5zm16.991 0a.57.57 0 01.592.582.588.588 0 01-1.174 0 .57.57 0 01.357-.542.572.572 0 01.225-.04z"></path></svg>',zai:'<svg fill="currentColor" fill-rule="evenodd" height="1em" style="flex:none;line-height:1" viewBox="0 0 24 24" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M12.105 2L9.927 4.953H.653L2.83 2h9.276zM23.254 19.048L21.078 22h-9.242l2.174-2.952h9.244zM24 2L9.264 22H0L14.736 2H24z"></path></svg>'},Db={"amazon-bedrock":"bedrock","ant-ling":"antgroup",anthropic:"anthropic",azure:"azure","azure-openai-responses":"azure",cerebras:"cerebras",claude:"claude","claude-code":"claude",cloudflare:"cloudflare","cloudflare-ai-gateway":"cloudflare","cloudflare-workers-ai":"cloudflare",deepseek:"deepseek",fireworks:"fireworks",gemini:"gemini","github-copilot":"githubcopilot",google:"gemini","google-vertex":"vertexai",groq:"groq",huggingface:"huggingface",kimi:"kimi","kimi-coding":"kimi",minimax:"minimax","minimax-cn":"minimax",mistral:"mistral",moonshotai:"moonshot","moonshotai-cn":"moonshot",nvidia:"nvidia",openai:"openai","openai-codex":"codex",opencode:"opencode","opencode-go":"opencode",openrouter:"openrouter",qwen:"qwen","qwen-token-plan":"qwen","qwen-token-plan-cn":"qwen",together:"together","vercel-ai-gateway":"vercel",xai:"xai",xiaomi:"xiaomimimo","xiaomi-token-plan-ams":"xiaomimimo","xiaomi-token-plan-cn":"xiaomimimo","xiaomi-token-plan-sgp":"xiaomimimo",zai:"zai","zai-coding-cn":"zai"};function B_(e){const t=Db[e]??Db[e.split("-",1)[0]??""];return t?z_[t]??null:null}function kf({provider:e,label:t,size:n=16}){const r=B_(e);return r?o.jsx("span",{"aria-hidden":!0,"data-provider-icon":e,style:{fontSize:n,lineHeight:0,display:"inline-flex",flex:"none"},dangerouslySetInnerHTML:{__html:r}}):o.jsx("span",{"aria-hidden":!0,"data-provider-icon":e,style:{width:n,height:n,borderRadius:"50%",flex:"none",boxSizing:"border-box",display:"inline-flex",alignItems:"center",justifyContent:"center",background:"var(--proto-alt)",border:"1px solid var(--proto-line)",fontSize:Math.round(n*.55),fontWeight:700,color:"var(--proto-muted-2)",lineHeight:1},children:(t.trim()[0]??"?").toUpperCase()})}const Q0={"logged-in":{kind:"logged-in",tone:"done",labelKey:"accountsStatusLoggedIn"},expiring:{kind:"expiring",tone:"waiting",labelKey:"accountsStatusExpiring"},"logged-out":{kind:"logged-out",tone:"cancelled",labelKey:"accountsStatusLoggedOut"},expired:{kind:"invalid",tone:"failed",labelKey:"accountsStatusInvalid"},unknown:{kind:"invalid",tone:"failed",labelKey:"accountsStatusInvalid"}},W_=["oauth","api_key"];function U_(e){return{...Q0[e.state],source:e.source,expiresAt:e.expiresAt}}function H_(){return{...Q0["logged-out"],source:null,expiresAt:null}}function V_(e,t){const n=e.credentials.filter(r=>r.authType===t);return{authType:t,credentials:n.length>0?n.map(U_):[H_()],canLogin:e.capabilities.includes(t),canLogout:n.some(r=>r.manageable)}}function q_(e){return e?{provider:e.provider,label:e.label,inUse:e.inUse,slots:W_.map(t=>V_(e,t))}:null}function K_(e,t){const n=e.credentials.filter(r=>r.authType===t);return e.authType!==t?n[0]:n.find(r=>r.source===e.source)??n[0]}function Q_(e){return[...new Set(e.credentials.map(n=>n.authType))].filter(n=>{var r;return(r=K_(e,n))==null?void 0:r.manageable})}function Y_(e){return{backend:"pi",provider:e.provider,label:e.label,inUse:e.inUse,loginTypes:[...e.capabilities],logoutTypes:Q_(e),status:Q0[e.state],source:e.source,expiresAt:e.expiresAt}}function G_(e,t){return Number(t.inUse)-Number(e.inUse)||e.label.localeCompare(t.label)}function Lh(e){return e==="logged-in"||e==="expiring"}function X_(e){return[["in-use","accountsGroupInUse",n=>n.inUse],["logged-in","accountsGroupLoggedIn",n=>!n.inUse&&(n.status.kind==="logged-in"||n.status.kind==="expiring")],["other","accountsGroupOther",n=>!n.inUse&&n.status.kind!=="logged-in"&&n.status.kind!=="expiring"]].map(([n,r,i])=>({key:n,labelKey:r,providers:e.filter(i)})).filter(n=>n.providers.length>0)}function J_(e,t){const n=t.trim().toLocaleLowerCase();return!n||e.provider.toLocaleLowerCase().includes(n)||e.label.toLocaleLowerCase().includes(n)}function Z_(e){const t=e.find(i=>i.backend==="claude"),n=!!t&&(Lh(t.state)||t.credentials.some(i=>Lh(i.state))),r=e.filter(i=>i.backend==="pi"&&Lh(i.state)).length;return{claudeLoggedIn:n,piLoggedInCount:r}}function Y0(e,t=""){const n=e.accounts.find(i=>i.backend==="claude"),r=e.accounts.filter(i=>i.backend==="pi"&&J_(i,t)).map(Y_).sort(G_);return{claude:q_(n),piProviders:r,groups:X_(r),summary:Z_(e.accounts)}}const _c="'IBM Plex Mono',monospace",e$={done:"var(--proto-success)",waiting:"var(--proto-amber-fg)",failed:"var(--proto-danger)",cancelled:"var(--proto-muted-2)"};function t$({value:e}){const t=H();return o.jsxs("span",{"data-account-state":e.kind,style:{display:"inline-flex",alignItems:"center",gap:5,font:`600 10px ${_c}`,color:e$[e.tone]},children:[o.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:"currentColor",flex:"none"}}),t[e.labelKey]]})}function ql(e,t,n){return t==="api_key"?e.authLoginApiKey:n==="claude"?e.authLoginSubscription:e.authLoginOAuth}function oC({value:e}){const t=H();return o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[o.jsx(t$,{value:e}),o.jsxs("span",{style:{font:`400 9.5px ${_c}`,color:"var(--proto-muted-2)"},children:[t.accountsSource,": ",e.source??"—"]}),e.expiresAt?o.jsxs("span",{style:{font:`400 9.5px ${_c}`,color:"var(--proto-muted-2)"},children:[t.accountsExpires,": ",e.expiresAt]}):null]})}function n$({authType:e}){const t=H();return o.jsx("span",{style:{font:`600 9px ${_c}`,color:"var(--proto-accent)",background:"var(--proto-accent-bg)",borderRadius:999,padding:"2px 7px"},children:e==="api_key"?t.authLoginApiKey:t.authLoginOAuth})}function iC(e){const t=H(),n=r=>({backend:e.backend,provider:e.provider,authType:r});return o.jsxs("div",{style:{display:"flex",gap:6,flexWrap:"wrap",justifyContent:"flex-end"},children:[e.loginTypes.map(r=>o.jsxs(Yn,{tone:"accent",disabled:e.disabled,"data-auth-action":"login","data-backend":e.backend,"data-provider":e.provider,"data-auth-type":r,"aria-label":`${t.accountsLogin} ${ql(t,r,e.backend)}`,onClick:()=>e.onLogin(n(r)),children:[t.accountsLogin," ",ql(t,r,e.backend)]},`login:${r}`)),e.logoutTypes.map(r=>o.jsxs(Yn,{tone:"danger",disabled:e.disabled,"data-auth-action":"logout","data-backend":e.backend,"data-provider":e.provider,"data-auth-type":r,"aria-label":`${t.accountsLogout} ${ql(t,r,e.backend)}`,onClick:()=>e.onLogout(n(r)),children:[t.accountsLogout," ",ql(t,r,e.backend)]},`logout:${r}`))]})}function r$({account:e,actions:t}){const n=H();return o.jsxs(Ye,{style:{marginTop:12,maxWidth:980},children:[o.jsx($n,{title:o.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:7},children:[o.jsx(kf,{provider:"claude-code",label:"Claude Code",size:15}),"Claude Code"]}),right:e.inUse?n.accountsInUse:void 0}),o.jsx("div",{style:{padding:"8px 14px"},children:e.slots.map(r=>o.jsx(Mn,{label:ql(n,r.authType,"claude"),children:o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:7},children:[r.credentials.map((i,s)=>o.jsx(oC,{value:i},`${i.source??"none"}:${s}`)),o.jsx(iC,{...t,backend:"claude",provider:e.provider,loginTypes:r.canLogin?[r.authType]:[],logoutTypes:r.canLogout?[r.authType]:[]})]})},r.authType))})]})}function o$({provider:e,actions:t}){const n=H(),r={...e.status,source:e.source,expiresAt:e.expiresAt};return o.jsxs("div",{style:{padding:"11px 14px",borderBottom:"1px solid var(--proto-alt)"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,flexWrap:"wrap"},children:[o.jsx(kf,{provider:e.provider,label:e.label,size:16}),o.jsx("span",{style:{fontSize:12,fontWeight:650,color:"var(--proto-ink)"},children:e.label}),o.jsx("span",{style:{font:`400 9px ${_c}`,color:"var(--proto-muted-3)"},children:e.provider}),e.inUse?o.jsx("span",{style:{fontSize:9,fontWeight:650,color:"var(--proto-success)",background:"var(--proto-success-bg)",borderRadius:999,padding:"2px 7px"},children:n.accountsInUse}):null,e.loginTypes.map(i=>o.jsx(n$,{authType:i},i))]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginTop:8,flexWrap:"wrap"},children:[o.jsx(oC,{value:r}),o.jsx("span",{style:{marginLeft:"auto"},children:o.jsx(iC,{...t,backend:"pi",provider:e.provider,loginTypes:e.loginTypes,logoutTypes:e.logoutTypes})})]})]})}function i$({providers:e,filter:t,onFilter:n,actions:r}){const i=H();return o.jsxs(Ye,{style:{marginTop:12,maxWidth:980,overflow:"hidden"},children:[o.jsx($n,{title:i.accountsPiProviders,right:`${e.length}`}),o.jsx("div",{style:{padding:"10px 14px",borderBottom:"1px solid var(--proto-line-2)"},children:o.jsx("input",{"data-accounts-filter":!0,"aria-label":i.accountsFilter,value:t,onChange:s=>n(s.target.value),placeholder:i.accountsFilterPlaceholder,style:Xt})}),e.length>0?e.map(s=>o.jsx(o$,{provider:s,actions:r},s.provider)):o.jsx("div",{style:{padding:"12px 14px",color:"var(--proto-muted-3)",fontSize:11},children:i.accountsNoProviders})]})}function s$({onLogin:e}){const t=H(),n=le(),r=je(),{toast:i}=dr(),{openLogin:s}=_0(),[a,l]=p.useState(""),c=Y(n.auth.status.queryOptions({})),d=xe(n.auth.logout.mutationOptions({onSuccess:()=>{r.invalidateQueries(n.auth.status.queryFilter({})),i({title:t.accountsLogoutDone,tone:"done"})},onError:h=>i({title:`${t.accountsLogoutFailed}: ${h.message}`,tone:"failed"})}));if(c.isLoading)return o.jsx("div",{style:{marginTop:16},children:t.accountsLoading});if(c.isError||!c.data)return o.jsx("div",{style:{marginTop:16,color:"var(--proto-danger)"},children:t.accountsLoadFailed});const u=Y0(c.data,a),f={disabled:d.isPending,onLogin:e??s,onLogout:h=>d.mutate(h)};return o.jsxs(o.Fragment,{children:[u.claude?o.jsx(r$,{account:u.claude,actions:f}):null,o.jsx(i$,{providers:u.piProviders,filter:a,onFilter:l,actions:f})]})}const a$="'IBM Plex Mono',monospace",l$={position:"fixed",inset:0,background:"rgba(25,28,34,.34)",zIndex:60},c$={position:"fixed",left:"50%",top:"50%",transform:"translate(-50%,-50%)",width:1080,maxWidth:"94vw",height:680,maxHeight:"90vh",background:"var(--proto-card)",borderRadius:14,boxShadow:"0 24px 64px rgba(16,24,40,.3)",zIndex:61,overflow:"hidden",display:"flex",flexDirection:"column"},d$={position:"absolute",width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0 0 0 0)",whiteSpace:"nowrap",border:0};function u$({open:e,onClose:t}){const n=H();return o.jsx(po,{open:e,onOpenChange:r=>{r||t()},children:o.jsxs(fo,{children:[o.jsx(ho,{style:l$,className:"animate-cxfade motion-reduce:animate-none"}),o.jsxs(go,{"aria-describedby":void 0,style:c$,className:"animate-cxmodal focus:outline-none motion-reduce:animate-none",children:[o.jsx(wi,{style:d$,children:n.settings}),e?o.jsx(p$,{onClose:t}):null]})]})})}function p$({onClose:e}){const t=H(),n=le(),r=je(),{toast:i}=dr(),{openLogin:s}=_0(),[a,l]=p.useState("appearance"),c=Y(n.config.get.queryOptions({})),d=Y(n.cost.summary.queryOptions({})),u=Y(n.threadTemplates.get.queryOptions({})),f=c.data,h=mN(t,a),g=xe(n.config.set.mutationOptions({onSuccess:(y,w)=>{r.invalidateQueries(n.config.get.queryFilter({}));const k=w.section==="profiles"?w.value.defaultProfile:"";i({title:`Default profile → ${k} · ${t.stToastDefaultProfile}`,tone:"done"})},onError:y=>i({title:`${t.stToastWriteFailed}: ${y.message}`,tone:"failed"})})),v=xe(n.approvals.request.mutationOptions({onSuccess:()=>i({title:t.stToastQueuedApproval,tone:"waiting"}),onError:y=>i({title:`${t.stToastCouldNotQueue}: ${y.message}`,tone:"failed"})})),x=y=>g.mutate({section:"profiles",value:{defaultProfile:y}}),b=y=>v.mutate({kind:"reconnect-platform",platform:y}),j=y=>v.mutate({kind:"add-machine",machineName:y});return o.jsxs(o.Fragment,{children:[o.jsxs("div",{style:{height:48,flex:"none",borderBottom:"1px solid var(--proto-line)",display:"flex",alignItems:"center",gap:9,padding:"0 18px",background:"var(--proto-card)"},children:[o.jsx("span",{style:{fontSize:13,fontWeight:650,color:"var(--proto-ink)"},children:t.settings}),o.jsx("span",{onClick:e,role:"button",style:{marginLeft:"auto",font:`500 9.5px ${a$}`,color:"var(--proto-muted-3)",border:"1px solid var(--proto-line)",borderRadius:5,padding:"2px 6px",cursor:"pointer"},children:t.stEsc})]}),o.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden",minHeight:0},children:[o.jsx("div",{style:{width:210,flex:"none",borderRight:"1px solid var(--proto-line)",background:"var(--proto-rail)",padding:"10px 8px",overflow:"auto"},children:xN(t).map(y=>{const w=y.key===a;return o.jsx("div",{onClick:()=>l(y.key),role:"button","data-settings-nav":y.key,style:{display:"flex",alignItems:"center",gap:8,padding:"7px 10px",background:w?"var(--proto-accent-bg)":"transparent",borderRadius:8,cursor:"pointer"},children:o.jsx("span",{style:{fontSize:12,fontWeight:600,color:w?"var(--proto-accent)":"var(--proto-ink-2)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:y.label})},y.key)})}),o.jsxs("div",{style:{flex:1,minWidth:0,overflow:"auto",padding:"16px 22px",background:"var(--proto-alt)",display:a==="hooks"?"flex":void 0,flexDirection:a==="hooks"?"column":void 0},children:[o.jsx("div",{style:{fontSize:15,fontWeight:650,color:"var(--proto-ink)"},children:h.title}),o.jsx("div",{style:{fontSize:11,color:"var(--proto-muted-2)",marginTop:2},children:h.sub}),a==="appearance"?o.jsx(F_,{}):a==="accounts"?o.jsx(s$,{onLogin:y=>{e(),s(y)}}):c.isLoading?o.jsx("div",{style:{marginTop:16,fontSize:12,color:"var(--proto-muted-3)"},children:t.stLoadingConfig}):c.isError?o.jsxs("div",{style:{marginTop:16,fontSize:12,color:"var(--proto-danger)"},children:[t.stFailedLoadConfig," ",c.error.message]}):f?o.jsx(f$,{section:a,snapshot:f,cost:d.data,templateEntries:u.data,onSetDefaultProfile:x,onReconnect:b,onAddMachine:j}):null]})]})]})}function f$({section:e,snapshot:t,cost:n,templateEntries:r,onSetDefaultProfile:i,onReconnect:s,onAddMachine:a}){switch(e){case"platform":return o.jsx(PN,{snapshot:t,onReconnect:s});case"profiles":return o.jsx(RN,{snapshot:t,onSetDefaultProfile:i});case"budget":return o.jsx(ZN,{snapshot:t,cost:n});case"machines":return o.jsx(IN,{snapshot:t,onAddMachine:a});case"templates":return o.jsx(ON,{snapshot:t,entries:r});case"mcp":return o.jsx(AN,{snapshot:t});case"notifications":return o.jsx(BN,{snapshot:t});case"hooks":return o.jsx(__,{});case"advanced":return o.jsx(KN,{snapshot:t});default:return null}}const sC=p.createContext(null);function h$({children:e}){const[t,n]=p.useState(!1),r=p.useCallback(()=>n(!0),[]),i=p.useCallback(()=>n(!1),[]),s=p.useMemo(()=>({open:r,close:i}),[r,i]);return o.jsxs(sC.Provider,{value:s,children:[e,o.jsx(u$,{open:t,onClose:i})]})}function aC(){const e=p.useContext(sC);if(!e)throw new Error("useSettings must be used within a SettingsProvider");return e}function G0(e,t){return e.dispatches.filter(n=>n.stepIndex===t.stepIndex)}const hs=5;function kp(e){return e.depth+2}function X0(e){let t=1;const n=r=>{for(const i of r)kp(i)>t&&(t=kp(i)),n(i.children)};return n(e),Math.min(t,hs)}const g$=new Set(["running","waiting"]);function lC(e){switch(e){case"running":return{bg:"#EEF0FA",fg:"#4655D4",text:"Running"};case"waiting":return{bg:"#F7ECCE",fg:"#8A5B06",text:"Waiting"};case"completed":return{bg:"#E9F4EE",fg:"#23854F",text:"Done"};case"failed":return{bg:"#FBEDEB",fg:"#C03D33",text:"Failed"};default:return{bg:"#F1F2F5",fg:"#8A93A2",text:"Cancelled"}}}function x$(e){const t=Math.max(0,Math.floor(e)),n=Math.floor(t/60),r=t%60,i=s=>String(s).padStart(2,"0");return`${i(n)}:${i(r)}`}function m$(e){const t=new Date(e),n=r=>String(r).padStart(2,"0");return`${n(t.getHours())}:${n(t.getMinutes())}`}function v$(e){const t=Math.round(e);if(t<60)return`${t}s`;const n=Math.floor(t/60),r=t%60;return r===0?`${n}m`:`${n}m ${r}s`}function Nb(e){const t=[];return e.durationS!=null&&t.push(v$(e.durationS)),e.costUsd!=null&&t.push("$"+e.costUsd.toFixed(2)),t.join(" · ")}function y$(e,t){if(!e)return"";const n=Math.max(0,Math.round((t-Date.parse(e))/1e3));if(n<60)return"just now";const r=Math.floor(n/60);if(r<60)return`${r}m ago`;const i=Math.floor(r/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}function b$(e){return`${e.stepIndex+1} · ${e.stage??"step"}`}function j$(e){const t=lC(e.status);return{id:e.id,name:e.templateName??e.id,level:"L"+kp(e),pill:t,hasLine:!!e.activeAgent,line:e.activeAgent??"",isMax:kp(e)>=hs||e.truncated,drillable:e.children.length>0||e.truncated}}function w$(e){return e.map(t=>{const n=t.stage??`step ${t.stepIndex+1}`,r=t.status==="completed"?"done":t.status==="running"?"editing":"queued";return{label:`${t.stepIndex+1} ${n} · ${r}`,active:t.status==="running"}})}function k$(e){return e.status==="completed"?"done":e.status==="running"?"running":"pending"}function S$(e,t,n){var s,a;const r=G0(e,t)[0],i=[t.executionId??(r==null?void 0:r.executionId),(r==null?void 0:r.machine)??"local"].filter(Boolean).join(" · ");return{profile:((s=e.agentFlow)==null?void 0:s.profile)??e.activeAgent??"agent",execInfo:i,lastOutput:((a=e.agentFlow)==null?void 0:a.lastOutput)??t.outputSummary,streaming:!0,live:n}}function C$(e,t,n,r){var l;const i=k$(t),s=i==="running",a=s?e.children.map(j$):[];return{kind:i,title:b$(t),note:t.outputSummary??"",meta:s?Nb(t)||"running":i==="done"?Nb(t):"gated",hasConnector:n>0,agent:s?S$(e,t,r):void 0,subs:a,subCount:a.length,stepIndex:t.stepIndex,sessionId:t.sessionId,sessionName:t.sessionName,profile:s?((l=e.agentFlow)==null?void 0:l.profile)??e.activeAgent??t.agentSlotId:t.agentSlotId}}function E$(e,t,n){return{path:e.artifacts.artifactPath,live:t,updated:y$(e.updatedAt,n),taskId:e.artifacts.taskId,taskProject:e.artifacts.taskProject,workspacePath:e.artifacts.workspacePath,writtenBy:w$(e.steps),content:e.artifacts.content??null}}function T$(e,t){const n=g$.has(e.status),r=e.endedAt?Date.parse(e.endedAt):t,i=Math.max(0,(r-Date.parse(e.createdAt))/1e3),s=X0(e.children),a=Array.from({length:hs},(l,c)=>({filled:c<s}));return{name:e.templateName,tid:e.id,pill:lC(e.status),template:e.templateName,started:m$(e.createdAt),elapsed:x$(i),cost:"Σ $"+e.totalCostUsd.toFixed(2),task:e.artifacts.taskId??"—",depthDots:a,depthText:`${s}/${hs}`,live:n,steps:e.steps.map((l,c)=>C$(e,l,c,n)),artifact:E$(e,n,t)}}const P$="wide";function Oh(e){return Array.from(e).length}function R$(e){if(typeof e=="string")return e;try{const t=JSON.stringify(e,null,2);return t===void 0?String(e):t}catch{return String(e)}}function Ah({label:e,status:t,count:n,children:r}){const i=H();return o.jsxs("section",{className:"flex flex-col gap-1g",children:[o.jsxs("div",{className:"flex items-center gap-1g font-mono text-[10px] font-semibold tracking-[.06em] text-proto-muted",children:[o.jsx("span",{children:e}),t?o.jsx("span",{className:"rounded border border-proto-line-2 bg-proto-alt px-1g py-[1px] text-[9px]",children:t}):null,n!==void 0?o.jsxs("span",{className:"ml-auto font-normal tracking-normal text-proto-faint",children:[n," ",i.wbDebugCharacters]}):null]}),o.jsx("pre",{className:"max-h-[38vh] overflow-auto whitespace-pre-wrap break-words rounded-card border border-proto-line-2 bg-proto-alt p-2g font-mono text-[11px] leading-relaxed text-proto-ink-2",children:r})]})}function I$({detail:e}){var i;const t=H();if(e.kind==="user")return o.jsx(Ah,{label:t.wbDebugAgentMessage,count:Oh(e.agentMessage),children:e.agentMessage});const n=R$(e.toolInput),r=e.toolResult?e.toolResult.isError?t.wbDebugError:t.wbDebugSuccess:t.wbDebugPending;return o.jsxs("div",{className:"flex flex-col gap-2g",children:[o.jsx(Ah,{label:t.wbDebugParameters,count:Oh(n),children:n}),o.jsx(Ah,{label:t.wbDebugResult,status:r,count:e.toolResult?Oh(e.toolResult.content):void 0,children:((i=e.toolResult)==null?void 0:i.content)??t.wbDebugPending})]})}function cC({onClick:e,compact:t=!1,className:n=""}){const i=H().wbDebugInspect,s=t?"h-[18px] min-w-[22px] px-[4px] text-[8px]":"h-[24px] min-w-[28px] px-[5px] text-[9px]";return o.jsx("button",{type:"button","aria-label":i,title:i,onClick:e,className:`pointer-events-none ${s} rounded border border-proto-line-2 bg-proto-card font-mono text-proto-muted opacity-0 shadow-sm transition-opacity group-hover:pointer-events-auto group-hover:opacity-100 focus-visible:pointer-events-auto focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-proto-accent/30 ${n}`,children:"{ }"})}function dC({detail:e,onClose:t}){const n=H(),r=(e==null?void 0:e.kind)==="tool"?`DEBUG · ${e.toolName}`:`DEBUG · ${n.wbDebugAgentMessage}`;return o.jsx(cf,{title:r,open:e!==null,size:P$,layer:"nested",onOpenChange:i=>{i||t()},children:e?o.jsx(I$,{detail:e}):null})}function M$(e,t){return e.length===0?0:e.reduce((n,r)=>n+r,0)+t*(e.length-1)}function L$(e){const{availableWidth:t,chipWidths:n,overflowWidth:r,gap:i}=e;if(M$(n,i)<=t)return{visibleCount:n.length,hiddenCount:0};let s=0,a=0;for(const l of n){const c=s+(a>0?i:0)+l;if(c+i+r>t)break;s=c,a+=1}return{visibleCount:a,hiddenCount:n.length-a}}function O$(e){return e>0?`+${e}`:null}function A$(e,t){var r;const n=Array.from(e.children);return{chipWidths:n.slice(0,t).map(i=>i.getBoundingClientRect().width),overflowWidth:((r=n[t])==null?void 0:r.getBoundingClientRect().width)??0}}function D$(e,t){return e.visibleCount===t.visibleCount&&e.hiddenCount===t.hiddenCount}function N$(e,t){var s;let n=!0;const r=()=>{n&&t()};r();const i=typeof ResizeObserver>"u"?null:new ResizeObserver(r);return i==null||i.observe(e),(s=document.fonts)==null||s.ready.then(r),()=>{n=!1,i==null||i.disconnect()}}function uC(e,t){const n=p.useRef(null),r=p.useRef(null),[i,s]=p.useState({visibleCount:e.length,hiddenCount:0}),a=e.join("\0");return p.useLayoutEffect(()=>{const l=n.current,c=r.current;if(!(!l||!c))return N$(l,()=>{const d=A$(c,e.length),u=L$({availableWidth:l.clientWidth,...d,gap:t});s(f=>D$(f,u)?f:u)})},[t,e.length,a]),{containerRef:n,measureRef:r,layout:i}}const Sf="'IBM Plex Mono',monospace",J0=7,_$={font:`400 10.5px ${Sf}`,background:"var(--proto-alt)",border:"1px solid var(--proto-line-2)",padding:"1px 6px",borderRadius:4,flex:"none"},_b={font:`500 10.5px ${Sf}`,color:"var(--proto-muted)",flex:"none"},pC={display:"flex",alignItems:"center",gap:J0,flex:1,minWidth:0,overflow:"hidden",position:"relative"},$$={...pC,position:"absolute",visibility:"hidden",pointerEvents:"none",width:"max-content",overflow:"visible"},F$={display:"flex",alignItems:"center",gap:7,fontSize:11,color:"var(--proto-muted-3)",padding:"6px 13px"},z$={display:"flex",alignItems:"center",gap:8,padding:"5.5px 13px",borderTop:"1px solid var(--proto-line-soft)"},B$={font:`600 9px ${Sf}`,color:"var(--proto-muted)",background:"var(--proto-gray)",padding:"1.5px 7px",borderRadius:5,flex:"none"},W$={font:`400 10.5px ${Sf}`,color:"var(--proto-ink-2)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"};function fC(e){return e?{background:"var(--proto-amber-bg)",border:"1px solid var(--proto-amber-border)",color:"var(--proto-amber-fg)"}:{}}function U$(e){return e.debug?{kind:"tool",toolName:e.kind,toolInput:e.debug.toolInput,...e.debug.toolResult!==void 0?{toolResult:e.debug.toolResult}:{}}:null}function H$(e){return{display:"flex",alignItems:"center",gap:J0,fontSize:11.5,color:e?"var(--proto-muted)":"var(--proto-muted-3)",flexWrap:"nowrap",whiteSpace:"nowrap",overflow:"hidden",cursor:"pointer"}}function V$(e){return{background:"var(--proto-rail)",border:"1px solid "+(e?"var(--proto-line-3)":"var(--proto-line-2)"),borderRadius:8,padding:"2px 0",cursor:"pointer"}}function $b({call:e}){var t;return o.jsx("span",{style:{..._$,...fC(((t=e.debug)==null?void 0:t.overCharacterThreshold)===!0)},children:e.label})}function q$({calls:e,text:t,hover:n,onExpand:r,onHover:i}){const{containerRef:s,measureRef:a,layout:l}=uC(e.map(d=>d.label),J0),c=O$(l.hiddenCount);return o.jsx("div",{style:{margin:"-8px 0"},children:o.jsxs("div",{onClick:r,onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),style:H$(n),children:[o.jsx("span",{style:{fontSize:9,color:"var(--proto-faint)",flex:"none"},children:"▸"}),o.jsx("span",{style:{flex:"none"},children:t}),o.jsxs("span",{ref:s,style:pC,children:[e.slice(0,l.visibleCount).map((d,u)=>o.jsx($b,{call:d},u)),c?o.jsx("span",{style:_b,children:c}):null,o.jsxs("span",{ref:a,"aria-hidden":"true",style:$$,children:[e.map((d,u)=>o.jsx($b,{call:d},u)),o.jsxs("span",{style:_b,children:["+",e.length]})]})]})]})})}function K$({call:e,onInspect:t}){var n;return o.jsxs("div",{className:e.debug?"group":void 0,style:z$,children:[o.jsx("span",{style:{...B$,...fC(((n=e.debug)==null?void 0:n.overCharacterThreshold)===!0)},children:e.kind}),o.jsx("span",{style:{...W$,...e.debug?{minWidth:0,flex:1}:{}},children:e.input}),e.debug?o.jsx(cC,{compact:!0,onClick:r=>t(r,e)}):null]})}function Q$({calls:e,text:t,hover:n,selected:r,onCollapse:i,onHover:s,onInspect:a,onClose:l}){return o.jsxs(o.Fragment,{children:[o.jsxs("div",{onClick:i,onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),style:V$(n),children:[o.jsxs("div",{style:F$,children:[o.jsx("span",{style:{fontSize:9,color:"var(--proto-faint)"},children:"▾"}),o.jsx("span",{children:t})]}),e.map((c,d)=>o.jsx(K$,{call:c,onInspect:a},d))]}),o.jsx(dC,{detail:r,onClose:l})]})}function Y$({calls:e}){const t=H(),[n,r]=p.useState(!1),[i,s]=p.useState(!1),[a,l]=p.useState(null),c=e.length>1?`${e.length} ${t.toolCallsUnit}`:`1 ${t.toolCallUnit}`,d=(u,f)=>{u.stopPropagation(),l(U$(f))};return n?o.jsx(Q$,{calls:e,text:c,hover:i,selected:a,onCollapse:()=>r(!1),onHover:s,onInspect:d,onClose:()=>l(null)}):o.jsx(q$,{calls:e,text:c,hover:i,onExpand:()=>r(!0),onHover:s})}function G$(e){return e.length>=2&&(e[0]==='"'&&e.endsWith('"')||e[0]==="'"&&e.endsWith("'"))?e.slice(1,-1):e}function X$(e){const t=e.replace(/\r\n/g,`
|
|
119
|
+
`);if(!t.startsWith(`---
|
|
120
|
+
`))return{frontmatter:null,body:e};const n=t.slice(4),r=n.search(/\n---[ \t]*(\n|$)/);if(r===-1)return{frontmatter:null,body:e};const i=n.slice(0,r),s=n.slice(r+1),a=s.indexOf(`
|
|
121
|
+
`),l=a===-1?"":s.slice(a+1),c=[];let d=null;for(const u of i.split(`
|
|
122
|
+
`)){const f=u.trimEnd();if(!f.trim())continue;const h=/^([A-Za-z0-9_-]+):\s?(.*)$/.exec(f);if(!h)continue;const g=h[1],v=G$(h[2].trim());if(g==="summary"){d=v;continue}c.push({key:g,value:v})}return{frontmatter:{entries:c,summary:d},body:l}}const J$=/(\*\*([^*]+)\*\*)|(`([^`]+)`)|(\[([^\]]+)\]\(([^)]+)\))|(\*([^*]+)\*)|(_([^_]+)_)/;function _s(e){const t=[];let n=e;for(;n.length;){const r=J$.exec(n);if(!r){t.push({type:"text",text:n});break}r.index>0&&t.push({type:"text",text:n.slice(0,r.index)}),r[2]!=null?t.push({type:"bold",text:r[2]}):r[4]!=null?t.push({type:"code",text:r[4]}):r[6]!=null?t.push({type:"link",text:r[6],href:r[7]}):r[9]!=null?t.push({type:"italic",text:r[9]}):r[11]!=null&&t.push({type:"italic",text:r[11]}),n=n.slice(r.index+r[0].length)}return t.length?t:[{type:"text",text:""}]}function Fb(e){let t=e.trim();return t.startsWith("|")&&(t=t.slice(1)),t.endsWith("|")&&(t=t.slice(0,-1)),t.split("|").map(n=>n.trim())}function zb(e){return/^\s*\|?\s*:?-{1,}:?\s*(\|\s*:?-{1,}:?\s*)*\|?\s*$/.test(e)&&e.includes("-")}function hC(e){const t=e.replace(/\r\n/g,`
|
|
123
|
+
`).split(`
|
|
124
|
+
`),n=[];let r=0;const i=s=>/^\s*([-*+]|\d+\.)\s+/.test(s);for(;r<t.length;){const s=t[r];if(!s.trim()){r++;continue}const a=/^```(\w*)\s*$/.exec(s);if(a){const d=a[1]||null,u=[];for(r++;r<t.length&&!/^```\s*$/.test(t[r]);)u.push(t[r]),r++;r++,n.push({type:"code",lang:d,text:u.join(`
|
|
125
|
+
`)});continue}const l=/^(#{1,6})\s+(.*)$/.exec(s);if(l){n.push({type:"heading",level:l[1].length,inline:_s(l[2].trim())}),r++;continue}if(/^(-{3,}|\*{3,}|_{3,})\s*$/.test(s)){n.push({type:"hr"}),r++;continue}if(s.includes("|")&&r+1<t.length&&zb(t[r+1])){const d=Fb(s).map(_s);r+=2;const u=[];for(;r<t.length&&t[r].includes("|")&&t[r].trim();)u.push(Fb(t[r]).map(_s)),r++;n.push({type:"table",header:d,rows:u});continue}if(/^>\s?/.test(s)){const d=[];for(;r<t.length&&/^>\s?/.test(t[r]);)d.push(t[r].replace(/^>\s?/,"")),r++;n.push({type:"blockquote",inline:_s(d.join(" ").trim())});continue}if(i(s)){const d=/^\s*\d+\.\s+/.test(s),u=[];for(;r<t.length&&i(t[r]);){const f=t[r].replace(/^\s*([-*+]|\d+\.)\s+/,"");u.push(_s(f.trim())),r++}n.push({type:"list",ordered:d,items:u});continue}const c=[];for(;r<t.length&&t[r].trim()&&!/^(#{1,6})\s+/.test(t[r])&&!/^```/.test(t[r])&&!/^>\s?/.test(t[r])&&!i(t[r])&&!/^(-{3,}|\*{3,}|_{3,})\s*$/.test(t[r])&&!(t[r].includes("|")&&r+1<t.length&&zb(t[r+1]));)c.push(t[r].trim()),r++;n.push({type:"paragraph",inline:_s(c.join(" "))})}return n}const gC="'IBM Plex Mono',monospace";function $s({nodes:e}){return o.jsx(o.Fragment,{children:e.map((t,n)=>{switch(t.type){case"bold":return o.jsx("strong",{style:{fontWeight:650},children:t.text},n);case"italic":return o.jsx("em",{children:t.text},n);case"code":return o.jsx("code",{style:{font:`500 12.5px ${gC}`,background:"var(--proto-gray)",borderRadius:4,padding:"1px 5px"},children:t.text},n);case"link":return o.jsx("a",{href:t.href,target:"_blank",rel:"noreferrer",style:{color:"var(--proto-accent)",textDecoration:"underline"},children:t.text},n);default:return o.jsx(p.Fragment,{children:t.text},n)}})})}function Z$({block:e}){switch(e.type){case"heading":{const t=e.level<=1?17:e.level===2?15.5:14.5;return o.jsx("div",{style:{fontSize:t,fontWeight:650,color:"var(--proto-ink)",margin:"2px 0"},children:o.jsx($s,{nodes:e.inline})})}case"paragraph":return o.jsx("div",{style:{whiteSpace:"pre-wrap",overflowWrap:"break-word"},children:o.jsx($s,{nodes:e.inline})});case"list":{const t=e.ordered?"ol":"ul";return o.jsx(t,{style:{margin:"2px 0",paddingLeft:22,display:"flex",flexDirection:"column",gap:3},children:e.items.map((n,r)=>o.jsx("li",{children:o.jsx($s,{nodes:n})},r))})}case"code":return o.jsx("pre",{style:{font:`500 12.5px ${gC}`,background:"var(--proto-alt)",border:"1px solid var(--proto-line)",borderRadius:8,padding:"10px 12px",overflow:"auto",margin:"2px 0"},children:o.jsx("code",{children:e.text})});case"blockquote":return o.jsx("div",{style:{borderLeft:"3px solid var(--proto-line)",paddingLeft:12,color:"var(--proto-muted)"},children:o.jsx($s,{nodes:e.inline})});case"table":return o.jsx("div",{style:{overflowX:"auto",maxWidth:"100%"},children:o.jsxs("table",{style:{borderCollapse:"collapse",fontSize:13},children:[o.jsx("thead",{children:o.jsx("tr",{children:e.header.map((t,n)=>o.jsx("th",{style:{border:"1px solid var(--proto-line)",padding:"4px 8px",textAlign:"left",fontWeight:650,whiteSpace:"nowrap"},children:o.jsx($s,{nodes:t})},n))})}),o.jsx("tbody",{children:e.rows.map((t,n)=>o.jsx("tr",{children:t.map((r,i)=>o.jsx("td",{style:{border:"1px solid var(--proto-line)",padding:"4px 8px",whiteSpace:"nowrap"},children:o.jsx($s,{nodes:r})},i))},n))})]})});case"hr":return o.jsx("div",{style:{height:1,background:"var(--proto-line-2)",margin:"4px 0"}});default:return null}}function Si({text:e,dropTrailingHr:t=!1}){let n=hC(e);if(t){let r=n.length;for(;r>0&&n[r-1].type==="hr";)r--;r!==n.length&&(n=n.slice(0,r))}return o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:n.map((r,i)=>o.jsx(Z$,{block:r},i))})}const eF="/api/files/download";function Z0(){var e;return(e=globalThis.__TAURI__)==null?void 0:e.core}function $c(e,t="attachment"){const n=new URLSearchParams({path:e,disposition:t});return`${a0()}${eF}?${n.toString()}`}async function hd(e,t="inline"){const n=await fetch($c(e,t),{headers:us()});if(!n.ok)throw new Error(`download failed: ${n.status}`);const r=await n.blob();return URL.createObjectURL(r)}async function $x(e,t){const n=t??e.split("/").pop()??"download",r=Kt()?Z0():void 0;if(r){if(Yp())return await r.invoke("plugin:cortex-download|download",{url:$c(e,"attachment"),fileName:n,token:us()["x-cortex-token"]}),{};const a=await fetch($c(e,"attachment"),{headers:us()});if(!a.ok)throw new Error(`download failed: ${a.status}`);const l=Array.from(new Uint8Array(await a.arrayBuffer()));return{savedPath:await r.invoke("save_download",{name:n,bytes:l})}}const i=await hd(e,"attachment"),s=document.createElement("a");return s.href=i,s.download=n,document.body.appendChild(s),s.click(),s.remove(),setTimeout(()=>URL.revokeObjectURL(i),1e4),{}}async function tF(e){const t=Kt()?Z0():void 0;t&&await t.invoke("open_path",{path:e})}async function nF(e){const t=Kt()?Z0():void 0;t&&await t.invoke("reveal_path",{path:e})}function xl(){const e=yO(),t=CO();return p.useCallback((n,r)=>{(async()=>{if(Yp()){await $x(n,r).catch(()=>{});return}const i=r??n.split("/").pop()??n;try{const{savedPath:s}=await $x(n,r),a=s?[{label:t.wbFileOpenFile,onClick:()=>void tF(s)},{label:t.wbFileOpenFolder,onClick:()=>void nF(s)}]:void 0;e==null||e.toast({title:t.wbFileDownloadDone,description:s?t.wbFileSavedTo.replace("{path}",s):i,tone:"done",duration:a?1e4:void 0,actions:a})}catch(s){e==null||e.toast({title:t.wbFileDownloadFailed,description:s instanceof Error?s.message:String(s),tone:"failed"})}})()},[e,t])}function rF(e,t){let n=!1;const r=()=>{n||(n=!0,t())};return e.pushSentinel(),e.addPopListener(r),()=>{e.removePopListener(r),n||e.popSentinel()}}function oF(){return{pushSentinel:()=>{window.history.pushState({...window.history.state,__cortexOverlay:!0},"")},popSentinel:()=>window.history.back(),addPopListener:e=>window.addEventListener("popstate",e),removePopListener:e=>window.removeEventListener("popstate",e)}}function ev(e){const t=p.useRef(e);t.current=e,p.useEffect(()=>rF(oF(),()=>t.current()),[])}const Fx="cortex.previewPinned",xC="cortex.previewSplit",el=.5,zx=.25,Bx=.75;function mC(e){return Number.isFinite(e)?Math.min(Bx,Math.max(zx,e)):el}function iF(e){return e===null||e.trim()===""?el:mC(Number(e))}function sF(e){return e==="1"}const Bb=260,Wb=380;function aF(e,t,n){if(!(t>0))return el;const r=(e+t-n)/t;let i=zx,s=Bx;return t>=Bb+Wb&&(i=Math.max(i,Bb/t),s=Math.min(s,1-Wb/t),i>s&&([i,s]=[zx,Bx])),Number.isFinite(r)?Math.min(s,Math.max(i,r)):el}function Ub(e){return e.kind==="pdf"||e.kind==="text"}function vC(e){return e.path??null}const yC=p.createContext({canPin:!1,active:!1,pinned:!1,item:null,split:el,pin:()=>{},show:()=>{},unpin:()=>{},setSplit:()=>{},registerHost:()=>()=>{}});function lF(){try{return sF(window.localStorage.getItem(Fx))}catch{return!1}}function cF(){try{return iF(window.localStorage.getItem(xC))}catch{return el}}function Dh(e,t){try{window.localStorage.setItem(e,t)}catch{}}function dF({children:e}){const[t,n]=p.useState(lF),[r,i]=p.useState(null),[s,a]=p.useState(cF),[l,c]=p.useState(0),d=p.useCallback(()=>(c(x=>x+1),()=>c(x=>Math.max(0,x-1))),[]),u=p.useCallback(x=>{n(!0),Dh(Fx,"1"),x&&i(x)},[]),f=p.useCallback(x=>i(x),[]),h=p.useCallback(()=>{n(!1),Dh(Fx,"0"),i(null)},[]),g=p.useCallback((x,b=!1)=>{const j=mC(x);a(j),b&&Dh(xC,String(j))},[]),v=p.useMemo(()=>({canPin:l>0,active:t&&l>0,pinned:t,item:r,split:s,pin:u,show:f,unpin:h,setSplit:g,registerHost:d}),[l,t,r,s,u,f,h,g,d]);return o.jsx(yC.Provider,{value:v,children:e})}function Cf(){return p.useContext(yC)}function bC(e){const[t,n]=p.useState(e.url??null),[r,i]=p.useState(!1);return p.useEffect(()=>{if(e.url){n(e.url),i(!1);return}if(!e.path)return;let s=!0,a=null;return n(null),i(!1),hd(e.path,"inline").then(l=>{s?(a=l,n(l)):URL.revokeObjectURL(l)}).catch(()=>{s&&i(!0)}),()=>{s=!1,a&&URL.revokeObjectURL(a)}},[e.path,e.url]),{src:t,failed:r}}const Hb=.4;function uF(e,t){return e==="transform"?!0:t.ctrlKey||t.metaKey}function Vb(e,t,n,r){if(t<=1)return{scale:1,x:0,y:0};const i=t/e.scale;return{scale:t,x:e.x+(1-i)*(n.x-r.x),y:e.y+(1-i)*(n.y-r.y)}}function pF(e,t,n,r,i,s){if(i<=1)return{scale:1,x:0,y:0};const a=i/e;return{scale:i,x:t.x+(r.x-n.x)+(n.x-s.x)*(1-a),y:t.y+(r.y-n.y)+(n.y-s.y)*(1-a)}}function tv(e={}){const{minScale:t=1,maxScale:n=5,mode:r="transform"}=e,[i,s]=p.useState({scale:1,x:0,y:0}),[a,l]=p.useState(null),c=p.useRef(null),d=p.useRef(i);d.current=i;const u=p.useRef(null),f=p.useRef(null),h=p.useRef(null),g=p.useCallback(S=>Math.min(n,Math.max(t,S)),[t,n]),v=p.useCallback(()=>{!a||r!=="css-zoom"||(u.current={ox:a.clientWidth/2,oy:a.clientHeight/2,scrollLeft:a.scrollLeft,scrollTop:a.scrollTop,prevScale:d.current.scale})},[a,r]),x=p.useCallback(()=>{v(),s(S=>({...S,scale:Math.min(n,S.scale+Hb)}))},[n,v]),b=p.useCallback(()=>{v(),s(S=>{const T=Math.max(t,S.scale-Hb);return T<=1?{scale:1,x:0,y:0}:{...S,scale:T}})},[t,v]),j=p.useCallback(()=>{v(),s({scale:1,x:0,y:0})},[v]),y=p.useCallback(S=>{l(S)},[]),w=p.useCallback(S=>{c.current=S},[]);p.useLayoutEffect(()=>{if(!a||r!=="css-zoom"||!u.current)return;const{ox:S,oy:T,scrollLeft:C,scrollTop:P,prevScale:I}=u.current,L=i.scale;if(u.current=null,I===L)return;const z=L/I;a.scrollLeft=(C+S)*z-S,a.scrollTop=(P+T)*z-T},[i.scale,a,r]),p.useEffect(()=>{if(!a)return;const S=D=>{var _;if(!uF(r,D))return;D.preventDefault();const U=a.getBoundingClientRect();if(r==="css-zoom"){u.current={ox:D.clientX-U.left,oy:D.clientY-U.top,scrollLeft:a.scrollLeft,scrollTop:a.scrollTop,prevScale:d.current.scale},s(F=>{const te=1+(D.deltaY<0?1:-1)*.12;return{...F,scale:g(F.scale*te)}});return}const Q=(_=c.current)==null?void 0:_.getBoundingClientRect(),J={x:(Q==null?void 0:Q.left)??U.left,y:(Q==null?void 0:Q.top)??U.top};s(F=>{const te=1+(D.deltaY<0?1:-1)*.12,A=g(F.scale*te);return Vb(F,A,{x:D.clientX,y:D.clientY},J)})},T=D=>{var U;if(D.touches.length===2){D.preventDefault();const[Q,J]=[D.touches[0],D.touches[1]],_=Math.hypot(J.clientX-Q.clientX,J.clientY-Q.clientY),F={x:(Q.clientX+J.clientX)/2,y:(Q.clientY+J.clientY)/2},W=d.current,te=(U=c.current)==null?void 0:U.getBoundingClientRect();f.current={initialDist:_,initialScale:W.scale,initialMid:F,initialTranslate:{x:W.x,y:W.y},startTopLeft:{x:(te==null?void 0:te.left)??0,y:(te==null?void 0:te.top)??0}}}},C=D=>{if(D.touches.length===2&&f.current){D.preventDefault();const[U,Q]=[D.touches[0],D.touches[1]],J=Math.hypot(Q.clientX-U.clientX,Q.clientY-U.clientY),_={x:(U.clientX+Q.clientX)/2,y:(U.clientY+Q.clientY)/2},F=J/f.current.initialDist,W=g(f.current.initialScale*F);if(r==="css-zoom"){const te=a.getBoundingClientRect();u.current={ox:_.x-te.left,oy:_.y-te.top,scrollLeft:a.scrollLeft,scrollTop:a.scrollTop,prevScale:d.current.scale},s(A=>({...A,scale:W}))}else{const te=f.current;s(pF(te.initialScale,te.initialTranslate,te.initialMid,_,W,te.startTopLeft))}}},P=D=>{D.touches.length<2&&(f.current=null)};let I=0;const L=D=>{var Q;if(D.touches.length!==1)return;const U=Date.now();if(U-I<300){D.preventDefault();const J=d.current;if(J.scale>1)r==="css-zoom"&&(u.current={ox:a.clientWidth/2,oy:a.clientHeight/2,scrollLeft:a.scrollLeft,scrollTop:a.scrollTop,prevScale:J.scale}),s({scale:1,x:0,y:0});else if(r==="css-zoom"){const _=a.getBoundingClientRect();u.current={ox:D.touches[0].clientX-_.left,oy:D.touches[0].clientY-_.top,scrollLeft:a.scrollLeft,scrollTop:a.scrollTop,prevScale:J.scale},s({scale:2,x:0,y:0})}else{const _=a.getBoundingClientRect(),F=(Q=c.current)==null?void 0:Q.getBoundingClientRect(),W={x:(F==null?void 0:F.left)??_.left,y:(F==null?void 0:F.top)??_.top};s(Vb({scale:1,x:0,y:0},2,{x:D.touches[0].clientX,y:D.touches[0].clientY},W))}}I=U},z=D=>{if(r!=="transform"||D.touches.length!==1)return;const U=d.current;U.scale<=1||(h.current={startX:D.touches[0].clientX,startY:D.touches[0].clientY,startTranslateX:U.x,startTranslateY:U.y})},q=D=>{if(!h.current||D.touches.length!==1)return;D.preventDefault();const U=D.touches[0].clientX-h.current.startX,Q=D.touches[0].clientY-h.current.startY;s(J=>({...J,x:h.current.startTranslateX+U,y:h.current.startTranslateY+Q}))},X=()=>{h.current=null};return a.addEventListener("wheel",S,{passive:!1}),a.addEventListener("touchstart",T,{passive:!1}),a.addEventListener("touchstart",L,{passive:!1}),a.addEventListener("touchstart",z,{passive:!1}),a.addEventListener("touchmove",C,{passive:!1}),a.addEventListener("touchmove",q,{passive:!1}),a.addEventListener("touchend",P),a.addEventListener("touchend",X),()=>{a.removeEventListener("wheel",S),a.removeEventListener("touchstart",T),a.removeEventListener("touchstart",L),a.removeEventListener("touchstart",z),a.removeEventListener("touchmove",C),a.removeEventListener("touchmove",q),a.removeEventListener("touchend",P),a.removeEventListener("touchend",X)}},[a,g,r]);const k=r==="transform"?{transform:`translate(${i.x}px, ${i.y}px) scale(${i.scale})`,transformOrigin:"0 0",touchAction:"none"}:{transform:`scale(${i.scale})`,transformOrigin:"top left"};return{containerRef:y,contentRef:w,zoom:i,style:k,zoomIn:x,zoomOut:b,resetZoom:j,isZoomed:i.scale>1}}const jC=p.createContext({openMedia:()=>{},close:()=>{}}),Nh="'IBM Plex Mono',monospace";function fF({item:e,onClose:t,onPin:n}){const{src:r,failed:i}=bC(e),s=xl(),{containerRef:a,contentRef:l,style:c,isZoomed:d,resetZoom:u}=tv({mode:"transform",minScale:1,maxScale:8});ev(t),p.useEffect(()=>{const h=v=>{v.key==="Escape"&&t()};window.addEventListener("keydown",h);const g=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{window.removeEventListener("keydown",h),document.body.style.overflow=g}},[t]);const f=()=>{if(e.path)s(e.path,e.name);else if(e.url){const h=document.createElement("a");h.href=e.url,h.download=e.name,document.body.appendChild(h),h.click(),h.remove()}};return o.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":e.name,onClick:()=>{d?u():t()},style:{position:"fixed",inset:0,zIndex:4e3,background:"rgba(10,12,16,.88)",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"max(24px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom))",boxSizing:"border-box",animation:"cxfade .18s ease both"},children:[o.jsxs("div",{onClick:h=>h.stopPropagation(),style:{position:"absolute",top:"max(14px, env(safe-area-inset-top))",right:14,display:"flex",gap:10,zIndex:2},children:[n&&o.jsx("span",{role:"button",title:"Pin preview beside the chat",onClick:n,style:{width:38,height:38,borderRadius:10,background:"rgba(255,255,255,.12)",color:"var(--ink-solid-fg)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:15,cursor:"pointer"},children:"◧"}),o.jsx("span",{role:"button",title:"Download",onClick:f,style:{width:38,height:38,borderRadius:10,background:"rgba(255,255,255,.12)",color:"var(--ink-solid-fg)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:16,cursor:"pointer"},children:"↓"}),o.jsx("span",{role:"button",title:"Close",onClick:t,style:{width:38,height:38,borderRadius:10,background:"rgba(255,255,255,.12)",color:"var(--ink-solid-fg)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:18,cursor:"pointer"},children:"×"})]}),o.jsx("div",{ref:a,onClick:h=>{h.stopPropagation()},style:{maxWidth:"94vw",maxHeight:"84vh",width:"94vw",height:"84vh",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden"},children:i?o.jsxs("div",{style:{color:"var(--proto-faint)",font:`500 12px ${Nh}`},children:["Failed to load ",e.name]}):r?e.kind==="video"?o.jsx("video",{src:r,controls:!0,autoPlay:!0,playsInline:!0,style:{maxWidth:"94vw",maxHeight:"84vh",borderRadius:10,background:"#000"}}):o.jsx("div",{ref:l,style:{...c,display:"inline-block"},children:o.jsx("img",{src:r,alt:e.name,draggable:!1,style:{maxWidth:"94vw",maxHeight:"84vh",objectFit:"contain",display:"block"}})}):o.jsx("div",{style:{color:"var(--proto-muted-2)",font:`500 12px ${Nh}`},children:"Loading…"})}),o.jsx("div",{onClick:h=>h.stopPropagation(),style:{position:"absolute",bottom:"max(16px, env(safe-area-inset-bottom))",left:0,right:0,textAlign:"center",color:"rgba(255,255,255,.72)",font:`500 11px ${Nh}`,padding:"0 20px",pointerEvents:"none"},children:e.name})]})}function wC({children:e}){const[t,n]=p.useState(null),r=Cf(),i=p.useCallback(c=>{if(r.active){r.show(c);return}n(c)},[r]),s=p.useCallback(()=>n(null),[]),a=p.useMemo(()=>({openMedia:i,close:s}),[i,s]),l=r.canPin?()=>{r.pin(t),n(null)}:void 0;return o.jsxs(jC.Provider,{value:a,children:[e,t&&o.jsx(fF,{item:t,onClose:s,onPin:l})]})}function gd(){return p.useContext(jC)}const hF="modulepreload",gF=function(e){return"/"+e},qb={},Ef=function(t,n,r){let i=Promise.resolve();if(n&&n.length>0){document.getElementsByTagName("link");const a=document.querySelector("meta[property=csp-nonce]"),l=(a==null?void 0:a.nonce)||(a==null?void 0:a.getAttribute("nonce"));i=Promise.allSettled(n.map(c=>{if(c=gF(c),c in qb)return;qb[c]=!0;const d=c.endsWith(".css"),u=d?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${u}`))return;const f=document.createElement("link");if(f.rel=d?"stylesheet":hF,d||(f.as="script"),f.crossOrigin="",f.href=c,l&&f.setAttribute("nonce",l),document.head.appendChild(f),d)return new Promise((h,g)=>{f.addEventListener("load",h),f.addEventListener("error",()=>g(new Error(`Unable to preload CSS for ${c}`)))})}))}function s(a){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=a,window.dispatchEvent(l),!l.defaultPrevented)throw a}return i.then(a=>{for(const l of a||[])l.status==="rejected"&&s(l.reason);return t().catch(s)})},xF=new Set(["md","markdown","txt","text","log","json","jsonl","ndjson","csv","tsv","yaml","yml","toml","ini","env","xml","html","htm","css","scss","js","mjs","cjs","jsx","ts","tsx","py","rs","go","java","kt","c","h","cpp","cc","hpp","cs","rb","php","swift","sh","bash","zsh","sql","r","lua","pl","tex","diff","patch","gitignore","dockerfile","conf","cfg","properties"]);function mF(e){const t=kC(e);return t==="md"||t==="markdown"}function kC(e){const t=e.split("/").pop()??e,n=t.lastIndexOf(".");return n<=0?t.startsWith(".")&&t.length>1?t.slice(1).toLowerCase():"":t.slice(n+1).toLowerCase()}function xd(e,t){const n=kC(e),r=(t??"").toLowerCase();return n==="pdf"||r==="application/pdf"?"pdf":xF.has(n)||r.startsWith("text/")||r==="application/json"||r==="application/xml"||r==="application/x-yaml"?"text":null}function SC(e,t){return t<=0||!Number.isFinite(e)?1:Math.min(Math.max(1,Math.floor(e)),t)}function vF(e,t,n){if(e.length===0)return 1;const r=t+n/2;for(let i=0;i<e.length;i++){const s=e[i];if(r<s.top+s.height)return i+1}return e.length}function yF(e,t){const n=parseInt(e,10);return Number.isFinite(n)?SC(n,t):null}const bF=2*1024*1024,ja="'IBM Plex Mono',monospace",CC=p.createContext({openDoc:()=>{},close:()=>{}});function EC({item:e}){const[t,n]=p.useState(null),[r,i]=p.useState("loading");return p.useEffect(()=>{let s=!0;return i("loading"),n(null),(async()=>{const a=await fetch($c(e.path,"inline"),{headers:us()});if(!a.ok)throw new Error(`download failed: ${a.status}`);const l=await a.blob();if(l.size>bF){s&&i("toolarge");return}const c=await l.text();s&&(n(c),i("ok"))})().catch(()=>{s&&i("failed")}),()=>{s=!1}},[e.path]),r==="loading"?o.jsx(sc,{children:"Loading…"}):r==="failed"?o.jsxs(sc,{failed:!0,children:["Failed to load ",e.name]}):r==="toolarge"?o.jsx(sc,{children:"File too large to preview — download to view."}):mF(e.name)?o.jsx("div",{style:{padding:"22px 26px",color:"var(--proto-ink)",fontSize:13.5,lineHeight:1.6},children:o.jsx(Si,{text:t??""})}):o.jsx("pre",{style:{margin:0,padding:"20px 22px",font:`500 12px/1.6 ${ja}`,color:"var(--proto-ink)",whiteSpace:"pre",overflowX:"auto"},children:t})}function TC({item:e}){const t=p.useRef(null),n=p.useRef(null),r=p.useRef([]),[i,s]=p.useState("loading"),[a,l]=p.useState(0),[c,d]=p.useState(1),{containerRef:u,style:f,zoom:h,zoomIn:g,zoomOut:v,resetZoom:x}=tv({mode:"css-zoom",minScale:1,maxScale:5});p.useEffect(()=>{let w=!0,k=!1;const S=n.current;return S&&(S.innerHTML=""),r.current=[],s("loading"),l(0),d(1),(async()=>{const[{getPdfjs:T},C]=await Promise.all([Ef(()=>import("./pdf-worker-DIEXcFxP.js"),[]),fetch($c(e.path,"inline"),{headers:us()})]);if(!C.ok)throw new Error(`download failed: ${C.status}`);const P=await C.arrayBuffer();if(k)return;const L=await T().getDocument({data:P}).promise;if(k)return;w&&l(L.numPages);const z=n.current;if(!z)return;const q=Math.min(window.devicePixelRatio||1,2);for(let X=1;X<=L.numPages;X++){if(k)return;const D=await L.getPage(X),U=D.getViewport({scale:1.5}),Q=document.createElement("div");Q.style.maxWidth=`${Math.floor(U.width)}px`,Q.style.margin="0 auto 12px";const J=document.createElement("canvas"),_=J.getContext("2d");_&&(J.width=Math.floor(U.width*q),J.height=Math.floor(U.height*q),J.style.width="100%",J.style.height="auto",J.style.display="block",J.style.borderRadius="6px",J.style.background="#fff",J.style.boxShadow="0 2px 10px rgba(0,0,0,.25)",_.scale(q,q),Q.appendChild(J),z.appendChild(Q),r.current.push(Q),await D.render({canvas:J,canvasContext:_,viewport:U}).promise)}w&&!k&&s("ok")})().catch(()=>{w&&!k&&s("failed")}),()=>{w=!1,k=!0}},[e.path]);const b=p.useCallback(()=>{const w=t.current;if(!w)return[];const k=w.getBoundingClientRect().top-w.scrollTop;return r.current.map(S=>({top:S.getBoundingClientRect().top-k,height:S.offsetHeight}))},[]),j=p.useCallback(()=>{const w=t.current;if(!w)return;const k=vF(b(),w.scrollTop,w.clientHeight);d(S=>S===k?S:k)},[b]),y=p.useCallback(w=>{const k=t.current,S=r.current[SC(w,a)-1];if(!k||!S)return;const T=S.getBoundingClientRect().top-k.getBoundingClientRect().top+k.scrollTop;k.scrollTo({top:Math.max(0,T-12),behavior:"smooth"})},[a]);return o.jsxs("div",{style:{display:"flex",flexDirection:"column",width:"100%",height:"100%"},children:[a>0&&i!=="failed"&&o.jsx(jF,{current:c,total:a,onJump:y,scale:h.scale,onZoomIn:g,onZoomOut:v,onZoomReset:x}),o.jsxs("div",{ref:w=>{t.current=w,u(w)},onScroll:j,style:{flex:1,minHeight:0,overflow:"auto",padding:"20px 16px",boxSizing:"border-box"},children:[i==="loading"&&o.jsx(sc,{children:"Loading PDF…"}),i==="failed"&&o.jsxs(sc,{failed:!0,children:["Failed to render ",e.name]}),o.jsx("div",{ref:n,style:{...f,maxWidth:900,margin:"0 auto"}})]})]})}function jF({current:e,total:t,onJump:n,scale:r,onZoomIn:i,onZoomOut:s,onZoomReset:a}){const[l,c]=p.useState(String(e));p.useEffect(()=>{c(String(e))},[e]);const d=()=>{const u=yF(l,t);u===null?c(String(e)):n(u)};return o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:8,padding:"7px 10px",borderBottom:"1px solid var(--proto-line)",background:"var(--proto-rail)",flex:"none"},children:[o.jsx("span",{role:"button",title:"Previous page","aria-disabled":e<=1,onClick:()=>{e>1&&n(e-1)},style:iu(e<=1),children:"↑"}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,font:`600 11.5px ${ja}`,color:"var(--proto-ink)"},children:[o.jsx("input",{value:l,inputMode:"numeric","aria-label":"Page number",onChange:u=>c(u.target.value.replace(/[^0-9]/g,"")),onFocus:u=>u.currentTarget.select(),onKeyDown:u=>{u.key==="Enter"&&(d(),u.currentTarget.blur())},onBlur:d,style:{width:44,textAlign:"center",padding:"3px 4px",borderRadius:6,border:"1px solid var(--proto-line)",background:"var(--proto-card)",color:"var(--proto-ink)",font:`600 11.5px ${ja}`}}),o.jsxs("span",{style:{color:"var(--proto-muted)"},children:["/ ",t]})]}),o.jsx("span",{role:"button",title:"Next page","aria-disabled":e>=t,onClick:()=>{e<t&&n(e+1)},style:iu(e>=t),children:"↓"}),o.jsxs("div",{style:{marginLeft:12,display:"flex",alignItems:"center",gap:4},children:[o.jsx("span",{role:"button",title:"Zoom out",onClick:s,style:iu(r<=1),children:"−"}),o.jsxs("span",{role:"button",title:"Reset zoom",onClick:a,style:{font:`600 10.5px ${ja}`,color:"var(--proto-muted)",cursor:"pointer",padding:"0 4px",userSelect:"none",minWidth:36,textAlign:"center"},children:[Math.round(r*100),"%"]}),o.jsx("span",{role:"button",title:"Zoom in",onClick:i,style:iu(r>=5),children:"+"})]})]})}function iu(e){return{width:28,height:28,borderRadius:8,border:"1px solid var(--proto-line)",background:"var(--proto-card)",color:"var(--proto-muted)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:14,cursor:e?"default":"pointer",opacity:e?.4:1,flex:"none",userSelect:"none"}}function sc({children:e,failed:t}){return o.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"48px 20px",color:t?"var(--proto-faint)":"var(--proto-muted-2)",font:`500 12px ${ja}`},children:e})}function wF({item:e,onClose:t,onPin:n}){const r=xl();return ev(t),p.useEffect(()=>{const i=a=>{a.key==="Escape"&&t()};window.addEventListener("keydown",i);const s=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{window.removeEventListener("keydown",i),document.body.style.overflow=s}},[t]),o.jsx("div",{role:"dialog","aria-modal":"true","aria-label":e.name,onClick:t,style:{position:"fixed",inset:0,zIndex:4e3,background:"rgba(10,12,16,.72)",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"max(24px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom))",boxSizing:"border-box",animation:"cxfade .18s ease both"},children:o.jsxs("div",{onClick:i=>i.stopPropagation(),style:{width:"min(920px, 96vw)",height:"min(88vh, 100%)",background:"var(--proto-card)",border:"1px solid var(--proto-line)",borderRadius:14,display:"flex",flexDirection:"column",overflow:"hidden",boxShadow:"0 12px 48px rgba(0,0,0,.35)"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"10px 12px",borderBottom:"1px solid var(--proto-line)",flex:"none",background:"var(--proto-rail)"},children:[o.jsx("span",{style:{font:`600 11.5px ${ja}`,color:"var(--proto-ink)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1},children:e.name}),n&&o.jsx("span",{role:"button",title:"Pin preview beside the chat",onClick:n,style:_h,children:"◧"}),o.jsx("span",{role:"button",title:"Download",onClick:()=>r(e.path,e.name),style:_h,children:"↓"}),o.jsx("span",{role:"button",title:"Close",onClick:t,style:{..._h,fontSize:16},children:"×"})]}),o.jsx("div",{style:{flex:1,minHeight:0,overflow:"auto",background:e.kind==="pdf"?"var(--proto-gray)":"var(--proto-card)"},children:e.kind==="pdf"?o.jsx(TC,{item:e}):o.jsx(EC,{item:e})})]})})}const _h={width:30,height:30,borderRadius:8,border:"1px solid var(--proto-line)",background:"var(--proto-card)",color:"var(--proto-muted)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:14,cursor:"pointer",flex:"none"};function PC({children:e}){const[t,n]=p.useState(null),r=Cf(),i=p.useCallback(c=>{if(r.active){r.show(c);return}n(c)},[r]),s=p.useCallback(()=>n(null),[]),a=p.useMemo(()=>({openDoc:i,close:s}),[i,s]),l=r.canPin?()=>{r.pin(t),n(null)}:void 0;return o.jsxs(CC.Provider,{value:a,children:[e,t&&o.jsx(wF,{item:t,onClose:s,onPin:l})]})}function md(){return p.useContext(CC)}function nv(e,t=!0){const[n,r]=p.useState(null);return p.useEffect(()=>{if(!e||!t){r(null);return}let i=!0,s=null;return hd(e,"inline").then(a=>{i?(s=a,r(a)):URL.revokeObjectURL(a)}).catch(()=>{i&&r(null)}),()=>{i=!1,s&&URL.revokeObjectURL(s)}},[e,t]),n}function gs(e){return e==="image"?"image":e==="video"?"video":null}function kF(e,t,n=360){if(e<=0||t<=0)return{w:0,h:0};const r=Math.min(1,n/Math.max(e,t));return{w:Math.round(e*r),h:Math.round(t*r)}}function SF(e,t=.1){return!Number.isFinite(e)||e<=0?t:Math.min(t,e/2)}function CF(e){const[t,n]=p.useState(null);return p.useEffect(()=>{if(n(null),!e||typeof document>"u")return;let r=!0;const i=document.createElement("video");i.muted=!0,i.playsInline=!0,i.preload="auto",i.src=e;const s=()=>{i.removeAttribute("src");try{i.load()}catch{}},a=()=>{try{const{w:u,h:f}=kF(i.videoWidth,i.videoHeight);if(!u||!f)return;const h=document.createElement("canvas");h.width=u,h.height=f;const g=h.getContext("2d");if(!g)return;g.drawImage(i,0,0,u,f);const v=h.toDataURL("image/jpeg",.72);r&&v.startsWith("data:image/jpeg")&&n(v)}catch{}finally{s()}},l=()=>{try{i.currentTime=SF(i.duration)}catch{a()}},c=()=>a(),d=()=>s();return i.addEventListener("loadeddata",l),i.addEventListener("seeked",c),i.addEventListener("error",d),()=>{r=!1,i.removeEventListener("loadeddata",l),i.removeEventListener("seeked",c),i.removeEventListener("error",d),s()}},[e]),t}function vd({src:e,style:t}){const n=CF(e);return n?o.jsx("img",{src:n,alt:"",style:t}):o.jsx("video",{src:e,muted:!0,playsInline:!0,preload:"metadata",style:t})}const EF=30*60*1e3;function TF(e,t){if(!e)return null;const n=Date.parse(e);return Number.isNaN(n)?null:Math.max(0,n+EF-t)}function rv(e){const t=Math.max(0,Math.floor(e)),n=String(Math.floor(t/60)).padStart(2,"0"),r=String(t%60).padStart(2,"0");return`${n}:${r}`}function RC(e){if(!e)return null;const t=Date.parse(e);if(Number.isNaN(t))return null;const n=new Date(t);return`${String(n.getHours()).padStart(2,"0")}:${String(n.getMinutes()).padStart(2,"0")}`}function IC(e,t){var s;const n=e.payload.questions??[];if(!n.length)return null;const r=((s=e.result)==null?void 0:s.answers)??{},i=e.payload;return{requestId:e.id,shortId:e.id.slice(0,8),status:e.status,level:i.level??null,questions:n.map(a=>({question:a.question,options:(a.options??[]).map(l=>({label:l.label,description:l.description??null})),multiSelect:!!a.multiSelect,answer:r[a.question]??null})),ts:t??null,timeLabel:RC(t)}}const MC={answers:{},selected:[]};function Ao(e,t){const n=e.questions.findIndex(r=>r.answer==null&&t.answers[r.question]===void 0);return n===-1?e.questions.length:n}function Wx(e,t,n){return{answers:{...e.answers,[t]:n},selected:[]}}function PF(e,t){const n=e.selected.includes(t);return{...e,selected:n?e.selected.filter(r=>r!==t):[...e.selected,t]}}function RF(e,t){return Wx(e,t,e.selected.join(", "))}function IF(e,t){return Ao(e,t)>=e.questions.length}function MF(e,t){const n={};for(const r of e.questions){const i=r.answer??t.answers[r.question];i!=null&&(n[r.question]=i)}return n}const LF={picks:{},otherText:{},otherOn:{}};function OF(e,t,n,r){const i=e.picks[t]??[];let s;r?s=i.includes(n)?i.filter(l=>l!==n):[...i,n]:s=i.includes(n)?[]:[n];const a=r?e.otherOn:{...e.otherOn,[t]:!1};return{...e,picks:{...e.picks,[t]:s},otherOn:a}}function AF(e,t,n){const r=!(e.otherOn[t]??!1),i=r&&!n?{...e.picks,[t]:[]}:e.picks;return{...e,otherOn:{...e.otherOn,[t]:r},picks:i}}function DF(e,t,n){return{...e,otherText:{...e.otherText,[t]:n}}}function LC(e,t){const n=[...e.picks[t]??[]];if(e.otherOn[t]){const r=(e.otherText[t]??"").trim();r&&n.push(r)}return n.join(", ")}function NF(e,t){return e.questions.every((n,r)=>LC(t,r)!=="")}function _F(e,t){const n={};return e.questions.forEach((r,i)=>{n[r.question]=LC(t,i)}),n}function $F(e,t){for(const n of e.split(`
|
|
126
|
+
`)){const r=n.trim();if(!r)continue;const i=/^#{1,6}\s+(.+)$/.exec(r);return i?i[1].trim():r}if(t){const n=t.split("/").pop();if(n)return n}return"Plan"}function ov(e,t){var i;const n=e.payload.planContent??"",r=e.payload.planFilePath??null;return{requestId:e.id,status:e.status,title:$F(n,r),filePath:r,lineCount:n?n.split(`
|
|
127
|
+
`).length:0,planContent:n,feedback:((i=e.result)==null?void 0:i.feedback)??null,ts:t??null,timeLabel:RC(t)}}function Kb(e,t){switch(e){case"approved":return{tone:"done",label:"Plan approved"};case"rejected":return{tone:"rejected",label:"Plan rejected"};case"answered":return{tone:"done",label:"Answered"};case"cancelled":return{tone:"inactive",label:"Cancelled"};default:return{tone:"inactive",label:t==="plan-approval"?"Plan expired":"Expired"}}}function FF(e){const t=e.subtype==="plan-rejected"?"rejected":"done",n=e.subtype==="plan-approved"?"Plan approved":e.subtype==="plan-rejected"?"Plan rejected":"Answered";return{kind:"summary",tone:t,label:n,text:e.text}}function OC(e){const t=e.detail;if(!t)return FF(e);if(t.status==="expired"||t.status==="cancelled"){const{tone:n,label:r}=Kb(t.status,t.kind);return{kind:"summary",tone:n,label:r,text:e.text}}if(t.kind==="ask-user"){const n=IC(t,e.ts);if(n)return{kind:"ask",model:n};const{tone:r,label:i}=Kb(t.status,t.kind);return{kind:"summary",tone:r,label:i,text:e.text}}return{kind:"plan",model:ov(t,e.ts)}}function zF(e,t){var n;if(!e)return null;for(const r of e.turns)for(const i of r.messages)if(i.type==="interaction"&&((n=i.interaction)==null?void 0:n.id)===t)return{detail:i.interaction,ts:i.ts??null};return null}const Sp={info:{bg:"var(--proto-accent-bg)",border:"var(--proto-accent-border)",fg:"var(--proto-accent)",icon:"i"},warning:{bg:"var(--proto-amber-bg)",border:"var(--proto-amber-border)",fg:"var(--proto-amber-fg)",icon:"!"},error:{bg:"var(--proto-danger-bg)",border:"var(--proto-danger)",fg:"var(--proto-danger)",icon:"×"}};function AC(e){return Sp[e]}function BF({action:e,label:t,onAction:n}){const r=H(),i=g4(),s=n??(i==null?void 0:i.openLogin);return s?o.jsx("button",{type:"button","data-auth-notice-action":!0,onClick:()=>s(e),style:{border:`1px solid ${Sp.error.fg}`,borderRadius:7,background:"transparent",color:Sp.error.fg,padding:"5px 9px",fontSize:12,fontWeight:650,cursor:"pointer",flex:"none",alignSelf:"center"},children:t??r.authLoginAgain}):null}function DC({level:e,text:t,authAction:n,authActionLabel:r,onAuthAction:i}){const s=Sp[e],a={display:"flex",alignItems:"flex-start",gap:9,width:"100%",margin:"0 auto",padding:"9px 12px",boxSizing:"border-box",borderRadius:9,border:`1px solid ${s.border}`,background:s.bg,color:s.fg,fontSize:12.5,lineHeight:1.55,overflowWrap:"anywhere"};return o.jsxs("div",{"data-chat-notice":e,role:e==="info"?"status":"alert",style:a,children:[o.jsx("span",{"aria-hidden":"true",style:{width:17,height:17,borderRadius:"50%",border:`1px solid ${s.fg}`,display:"inline-flex",alignItems:"center",justifyContent:"center",flex:"none",marginTop:1,font:"700 10px 'IBM Plex Mono',monospace"},children:s.icon}),o.jsx("span",{style:{flex:1},children:t}),n?o.jsx(BF,{action:n,label:r,onAction:i}):null]})}function iv(e,t){const[n,r]=p.useState(()=>Date.now()),i=t?TF(e,n):null,s=t&&i!=null&&i>0;return p.useEffect(()=>{if(!s)return;const a=setInterval(()=>r(Date.now()),1e3);return()=>clearInterval(a)},[s]),i==null?null:Math.floor(i/1e3)}const er="'IBM Plex Mono',monospace",Qb={zh:{askPill:"需要你拍板",askAnsweredPill:"已回答",askTag:e=>e?"多选":"单选",otherChip:"其他…",otherPlaceholder:"补充你的答案…",askFootnote:"Agent 暂停中 · 提交后继续",submit:"提交回答",ttlPrefix:"阻塞中 · TTL",planPendingPill:"PLAN · 等待批准",planApprovedPill:"✓ 计划已批准",planRejectedPill:"已驳回",planTtl:"Agent 暂停中 · TTL",approvedBy:"由你批准",fileSub:"已写入 · 批准前建议通读全文",readLink:"阅读 ›",approveHint:"",requestChanges:"请求修改",approvePlan:"批准计划",feedbackHint:"反馈必填 · 确认后退回重新规划",feedbackPlaceholder:"说明需要修改什么…",cancel:"取消",confirmReturn:"确认退回",approvedFoot:"· Agent 继续执行",rejectedFoot:"",viewPlan:"查看计划 ›",viewOriginalPlan:"查看原计划 ›"},en:{askPill:"Your call",askAnsweredPill:"Answered",askTag:e=>e?"multi":"single",otherChip:"Other…",otherPlaceholder:"Type your answer…",askFootnote:"Agent paused · continues after submit",submit:"Submit answers",ttlPrefix:"Blocking · TTL",planPendingPill:"PLAN · awaiting approval",planApprovedPill:"✓ Plan approved",planRejectedPill:"Rejected",planTtl:"Agent paused · TTL",approvedBy:"approved by you",fileSub:"written · read the full plan before approving",readLink:"Read ›",approveHint:"",requestChanges:"Request changes",approvePlan:"Approve plan",feedbackHint:"Feedback required · confirming returns it for replanning",feedbackPlaceholder:"What needs to change…",cancel:"Cancel",confirmReturn:"Confirm return",approvedFoot:"· agent continues",rejectedFoot:"",viewPlan:"View plan ›",viewOriginalPlan:"View original plan ›"}};function WF({model:e,state:t,copy:n,onState:r,onSubmit:i,busy:s}){const a=e.status==="pending",l=iv(e.ts,a),c=a&&!s&&NF(e,t);if(!a)return o.jsxs("div",{style:{border:"1px solid var(--proto-line)",background:"var(--proto-rail)",borderRadius:10,padding:"13px 16px"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9},children:[o.jsx("span",{style:{width:18,height:18,borderRadius:"50%",background:"var(--proto-accent-bg)",color:"var(--proto-accent)",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:10,fontWeight:700,flex:"none"},children:"?"}),o.jsx("span",{style:{fontSize:10.5,fontWeight:700,padding:"2.5px 9px",borderRadius:999,background:"var(--proto-gray)",color:"var(--proto-muted-2)"},children:n.askAnsweredPill}),o.jsx("span",{style:{font:`400 10px ${er}`,color:"var(--proto-muted-3)"},children:"AskUserQuestion"}),e.timeLabel&&o.jsx("span",{style:{marginLeft:"auto",font:`400 9.5px ${er}`,color:"var(--proto-faint)"},children:e.timeLabel})]}),o.jsx("div",{style:{marginTop:10,display:"flex",flexDirection:"column",gap:6},children:e.questions.map(u=>o.jsxs("div",{style:{display:"flex",gap:8,fontSize:12,lineHeight:1.5,alignItems:"baseline"},children:[o.jsx("span",{style:{color:"var(--proto-success)",fontWeight:700,flex:"none"},children:"✓"}),o.jsxs("div",{style:{minWidth:0,display:"flex",flexWrap:"wrap",columnGap:8,rowGap:2},children:[o.jsx("span",{style:{color:"var(--proto-muted-2)",overflowWrap:"anywhere"},children:u.question}),o.jsx("span",{style:{color:"var(--proto-ink)",fontWeight:600,overflowWrap:"anywhere"},children:u.answer??"—"})]})]},u.question))})]});const d=e.level?AC(e.level):null;return o.jsxs("div",{...e.level?{"data-ask-level":e.level}:{},style:{border:`1px solid ${d?d.border:"var(--proto-accent-border)"}`,background:"var(--proto-rail)",borderRadius:10,padding:"13px 16px"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9},children:[o.jsx("span",{style:{width:18,height:18,borderRadius:"50%",background:d?d.bg:"var(--proto-accent-bg)",color:d?d.fg:"var(--proto-accent)",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:10,fontWeight:700,flex:"none"},children:d?d.icon:"?"}),o.jsx("span",{style:{fontSize:10.5,fontWeight:700,padding:"2.5px 9px",borderRadius:999,background:d?d.bg:"var(--proto-accent-bg)",color:d?d.fg:"var(--proto-accent)"},children:n.askPill}),o.jsx("span",{style:{font:`400 10px ${er}`,color:"var(--proto-muted-3)"},children:"AskUserQuestion"}),o.jsxs("span",{style:{marginLeft:"auto",font:`400 9.5px ${er}`,color:"var(--proto-faint)"},children:[n.ttlPrefix," ",l!=null?rv(l):"30m"]})]}),e.questions.map((u,f)=>{const h=t.picks[f]??[],g=t.otherOn[f]??!1;return o.jsxs("div",{style:{marginTop:f===0?10:13},children:[o.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:7},children:[o.jsx("span",{style:{fontSize:13,fontWeight:600,color:"var(--proto-ink)"},children:u.question}),o.jsx("span",{style:{font:`500 9px ${er}`,color:"var(--proto-muted-3)",background:"var(--proto-gray)",padding:"1px 6px",borderRadius:5},children:n.askTag(u.multiSelect)})]}),o.jsxs("div",{style:{display:"flex",gap:7,marginTop:8,flexWrap:"wrap"},children:[u.options.map(v=>{const x=h.includes(v.label),b=u.multiSelect?x?"☑":"☐":x?"●":"○";return o.jsxs("span",{role:"button",title:v.description??void 0,onClick:()=>r(OF(t,f,v.label,u.multiSelect)),style:{fontSize:12,fontWeight:x?600:500,border:`1px solid ${x?"var(--proto-accent)":"var(--proto-accent-border)"}`,background:x?"var(--proto-accent-bg)":"var(--proto-card)",color:"var(--proto-accent)",padding:"5px 12px",borderRadius:8,cursor:"pointer"},children:[b," ",v.label]},v.label)}),o.jsxs("span",{role:"button",onClick:()=>r(AF(t,f,u.multiSelect)),style:{fontSize:12,fontWeight:g?600:500,border:`1px solid ${g?"var(--proto-accent)":"var(--proto-accent-border)"}`,background:g?"var(--proto-accent-bg)":"var(--proto-card)",color:"var(--proto-accent)",padding:"5px 12px",borderRadius:8,cursor:"pointer"},children:[u.multiSelect?g?"☑":"☐":g?"●":"○"," ",n.otherChip]})]}),g&&o.jsx("input",{value:t.otherText[f]??"",onChange:v=>r(DF(t,f,v.target.value)),placeholder:n.otherPlaceholder,style:{marginTop:7,width:"100%",boxSizing:"border-box",border:"1px solid var(--proto-accent-border)",borderRadius:8,padding:"7px 11px",fontSize:12,color:"var(--proto-ink)",background:"var(--proto-card)",outline:"none"}})]},u.question)}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginTop:13},children:[o.jsx("span",{style:{fontSize:10.5,color:"var(--proto-muted-3)",flex:1,lineHeight:1.5},children:n.askFootnote}),o.jsx("span",{role:"button",onClick:c?()=>i(_F(e,t)):void 0,style:{fontSize:12,fontWeight:600,borderRadius:8,padding:"7px 16px",color:"var(--ink-solid-fg)",background:c?"var(--proto-ink)":"var(--proto-faint)",flex:"none",cursor:c?"pointer":"not-allowed"},children:n.submit})]})]})}function UF({model:e,copy:t,feedbackOpen:n,onFeedbackOpen:r,onApprove:i,onReject:s,onOpenRead:a,busy:l}){const c=e.status==="pending",d=e.status==="approved",u=e.status==="rejected",f=iv(e.ts,c),[h,g]=p.useState(""),v=h.trim().length>0&&!l,x=e.filePath||e.planContent?o.jsxs("div",{role:"button",onClick:a,style:{marginTop:10,display:"flex",alignItems:"center",gap:10,border:"1px solid var(--proto-accent-bg)",background:"var(--proto-accent-bg)",borderRadius:8,padding:"9px 12px",cursor:"pointer"},children:[o.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 14 14",fill:"none",stroke:"var(--proto-accent)",strokeWidth:"1.4",style:{flex:"none"},children:[o.jsx("path",{d:"M3 1.5h5.5L11.5 4.5V12.5H3z"}),o.jsx("path",{d:"M5 6.5h4M5 9h4"})]}),o.jsxs("div",{style:{minWidth:0,flex:1},children:[o.jsx("div",{style:{font:`500 11px ${er}`,color:"var(--proto-ink)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.filePath??`${e.lineCount} lines`}),o.jsx("div",{style:{fontSize:10,color:"var(--proto-muted-3)",marginTop:2},children:t.fileSub})]}),o.jsx("span",{style:{fontSize:12,fontWeight:600,color:"var(--proto-accent)",flex:"none"},children:t.readLink})]}):null;return c?o.jsxs("div",{style:{border:"1px solid var(--proto-accent-border)",background:"var(--proto-card)",borderRadius:10,overflow:"hidden"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9,padding:"10px 15px",borderBottom:"1px solid var(--proto-line-2)",background:"var(--proto-rail)"},children:[o.jsx("span",{style:{fontSize:10.5,fontWeight:700,padding:"2.5px 9px",borderRadius:999,background:"var(--proto-accent-bg)",color:"var(--proto-accent)"},children:t.planPendingPill}),o.jsx("span",{style:{font:`400 10px ${er}`,color:"var(--proto-muted-3)"},children:"ExitPlanMode"}),o.jsxs("span",{style:{marginLeft:"auto",font:`400 9.5px ${er}`,color:"var(--proto-faint)"},children:[t.planTtl," ",f!=null?rv(f):"30m"]})]}),o.jsxs("div",{style:{padding:"12px 16px 13px"},children:[o.jsx("div",{style:{fontSize:13.5,fontWeight:600,color:"var(--proto-ink)",overflowWrap:"break-word"},children:e.title}),x]}),n&&o.jsx("div",{style:{padding:"0 16px 11px"},children:o.jsx("textarea",{value:h,onChange:b=>g(b.target.value),placeholder:t.feedbackPlaceholder,rows:2,style:{width:"100%",boxSizing:"border-box",border:"1.5px solid var(--proto-amber)",boxShadow:"0 0 0 3px rgba(201,154,46,.08)",background:"var(--proto-card)",borderRadius:8,padding:"8px 11px",fontSize:12,lineHeight:1.55,color:"var(--proto-ink)",outline:"none",resize:"none",fontFamily:"inherit"}})}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"11px 16px",borderTop:"1px solid var(--proto-line-2)"},children:[o.jsx("span",{style:{fontSize:10.5,color:"var(--proto-muted-3)",flex:1,lineHeight:1.5},children:n?t.feedbackHint:t.approveHint}),n?o.jsxs(o.Fragment,{children:[o.jsx("span",{role:"button",onClick:()=>{r(!1),g("")},style:{fontSize:12,fontWeight:600,border:"1px solid var(--proto-line-3)",background:"var(--proto-card)",color:"var(--proto-ink)",padding:"6px 13px",borderRadius:8,flex:"none",cursor:"pointer"},children:t.cancel}),o.jsx("span",{role:"button",onClick:v?()=>s(h.trim()):void 0,style:{fontSize:12,fontWeight:600,borderRadius:8,padding:"7px 16px",color:"var(--ink-solid-fg)",background:v?"var(--proto-ink)":"var(--proto-faint)",flex:"none",cursor:v?"pointer":"not-allowed"},children:t.confirmReturn})]}):o.jsxs(o.Fragment,{children:[o.jsx("span",{role:"button",onClick:()=>r(!0),style:{fontSize:12,fontWeight:600,border:"1px solid var(--proto-line-3)",background:"var(--proto-card)",color:"var(--proto-ink)",padding:"6px 13px",borderRadius:8,flex:"none",cursor:"pointer"},children:t.requestChanges}),o.jsx("span",{role:"button",onClick:l?void 0:i,style:{fontSize:12,fontWeight:600,borderRadius:8,padding:"7px 16px",color:"var(--ink-solid-fg)",background:l?"var(--proto-faint)":"var(--proto-ink)",flex:"none",cursor:l?"not-allowed":"pointer"},children:t.approvePlan})]})]})]}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{style:{border:"1px solid var(--proto-line)",background:"var(--proto-rail)",borderRadius:10,overflow:"hidden"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9,padding:"10px 15px",borderBottom:"1px solid var(--proto-line-2)",background:"var(--proto-rail)"},children:[o.jsx("span",{style:{fontSize:10.5,fontWeight:700,padding:"2.5px 9px",borderRadius:999,background:d?"var(--proto-success-bg)":"var(--proto-gray)",color:d?"var(--proto-success)":"var(--proto-muted-2)"},children:d?t.planApprovedPill:u?t.planRejectedPill:e.status}),o.jsx("span",{style:{font:`400 10px ${er}`,color:"var(--proto-muted-3)"},children:"ExitPlanMode"}),e.timeLabel&&o.jsxs("span",{style:{marginLeft:"auto",font:`400 9.5px ${er}`,color:"var(--proto-faint)"},children:[e.timeLabel,d?` ${t.approvedBy}`:""]})]}),o.jsx("div",{style:{padding:"12px 16px 13px"},children:o.jsx("div",{style:{fontSize:13.5,fontWeight:600,color:d?"var(--proto-muted)":"var(--proto-muted-2)",overflowWrap:"break-word",...u?{textDecoration:"line-through",textDecorationColor:"var(--proto-line)"}:{}},children:e.title})}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,padding:"10px 16px",borderTop:"1px solid var(--proto-line-2)",font:`400 10px ${er}`,color:"var(--proto-muted-3)"},children:[e.filePath&&o.jsx("span",{style:{color:"var(--proto-accent)",minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.filePath}),o.jsx("span",{children:d?t.approvedFoot:u?t.rejectedFoot:""}),o.jsx("span",{role:"button",onClick:a,style:{marginLeft:"auto",color:"var(--proto-accent)",fontWeight:600,cursor:"pointer",flex:"none"},children:u?t.viewOriginalPlan:t.viewPlan})]})]}),u&&e.feedback&&o.jsx("div",{style:{alignSelf:"flex-end",maxWidth:"75%",background:"var(--proto-gray)",borderRadius:"14px 14px 4px 14px",padding:"9px 14px",fontSize:13.5,lineHeight:1.55,color:"var(--proto-ink)",whiteSpace:"pre-wrap",marginTop:10},children:e.feedback})]})}function NC(e,t,n){if(n<=t)return 100;const r=Math.round((e+t)/n*100);return Math.max(0,Math.min(100,r))}function _C(e,t){const n=t==="zh";switch(e){case"pending":return n?"待批":"pending";case"approved":return n?"已批准":"approved";case"rejected":return n?"已驳回":"rejected";case"cancelled":return n?"已取消":"cancelled";default:return n?"已过期":"expired"}}function $C(e,t,n,r){const i=r==="zh"?`${t} 行`:`${t} lines`;return[e,i,n].filter(Boolean).join(" · ")}function FC(e,t){return null}const Al="'IBM Plex Mono',monospace";function HF({model:e,copy:t,lang:n="zh",onClose:r,onApprove:i,onRequestChanges:s}){const a=e.status==="pending",[l,c]=p.useState(0),d=p.useRef(null),u=()=>{const v=d.current;if(!v)return;const x=NC(v.scrollTop,v.clientHeight,v.scrollHeight);c(b=>Math.max(b,x))};p.useEffect(()=>{const v=x=>{x.key==="Escape"&&r()};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[r]);const f=_C(e.status,n),h=FC(),g=e.status==="approved"?{text:`${t.planApprovedPill}${e.timeLabel?` · ${e.timeLabel} ${t.approvedBy}`:""}`,fg:"var(--proto-success)",bg:"var(--proto-success-bg)"}:e.status==="rejected"?{text:`${t.planRejectedPill}${e.timeLabel?` · ${e.timeLabel}`:""}`,fg:"var(--proto-muted-2)",bg:"var(--proto-gray)"}:{text:f,fg:"var(--proto-muted-2)",bg:"var(--proto-gray)"};return o.jsx("div",{onClick:r,style:{position:"fixed",inset:0,background:"rgba(16,20,28,.42)",zIndex:70,display:"flex",alignItems:"center",justifyContent:"center"},children:o.jsxs("div",{onClick:v=>v.stopPropagation(),style:{width:760,maxWidth:"calc(100vw - 64px)",height:"min(720px, calc(100vh - 80px))",background:"var(--proto-card)",borderRadius:14,boxShadow:"0 24px 64px rgba(16,24,40,.28)",display:"flex",flexDirection:"column",overflow:"hidden"},children:[o.jsxs("div",{style:{flex:"none",padding:"14px 18px 12px",borderBottom:"1px solid var(--proto-line-2)"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[o.jsxs("div",{style:{minWidth:0,flex:1},children:[o.jsx("div",{style:{fontSize:15,fontWeight:650,color:"var(--proto-ink)",letterSpacing:"-.01em",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.title}),o.jsx("div",{style:{font:`400 10px ${Al}`,color:"var(--proto-muted-2)",marginTop:2,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:$C(e.filePath,e.lineCount,f,n)})]}),a?o.jsx("span",{style:{font:`600 9.5px ${Al}`,color:"var(--proto-amber-fg)",background:"var(--pill-waiting-bg)",padding:"2.5px 9px",borderRadius:999,flex:"none"},children:t.planPendingPill}):o.jsx("span",{style:{font:`600 9.5px ${Al}`,color:g.fg,background:g.bg,padding:"2.5px 9px",borderRadius:999,flex:"none"},children:f}),o.jsx("span",{role:"button","aria-label":"Close",onClick:r,style:{width:26,height:26,borderRadius:8,border:"1px solid var(--proto-line)",background:"var(--proto-rail)",color:"var(--proto-muted)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:12,cursor:"pointer",flex:"none"},children:"✕"})]}),a&&o.jsx("div",{style:{height:3,borderRadius:999,background:"var(--proto-line)",overflow:"hidden",marginTop:10},children:o.jsx("div",{style:{width:`${l}%`,height:"100%",background:"var(--proto-accent)"}})})]}),o.jsxs("div",{style:{flex:1,minHeight:0,position:"relative"},children:[o.jsxs("div",{ref:d,onScroll:u,style:{position:"absolute",inset:0,overflow:"auto",padding:"18px 22px 28px",boxSizing:"border-box"},children:[e.timeLabel&&o.jsx("div",{style:{font:`400 10px ${Al}`,color:"var(--proto-faint)",paddingBottom:8},children:e.timeLabel}),o.jsx("div",{style:{fontSize:13.5,lineHeight:1.7,color:"var(--proto-ink-2)"},children:o.jsx(Si,{text:e.planContent})}),e.status==="rejected"&&e.feedback&&o.jsxs("div",{style:{marginTop:16,border:"1px solid var(--proto-amber-border)",background:"var(--proto-amber-bg)",borderRadius:10,padding:"10px 13px"},children:[o.jsx("div",{style:{font:`600 10px ${Al}`,color:"var(--proto-amber-text)",paddingBottom:4},children:t.feedbackHint.split(" · ")[0]}),o.jsx("div",{style:{fontSize:12.5,lineHeight:1.6,color:"var(--proto-amber-fg)",whiteSpace:"pre-wrap"},children:e.feedback})]})]}),o.jsx("div",{style:{position:"absolute",left:0,right:0,bottom:0,height:48,background:"linear-gradient(180deg,rgba(255,255,255,0),var(--proto-card))",pointerEvents:"none"}})]}),o.jsx("div",{style:{flex:"none",borderTop:"1px solid var(--proto-line-2)",padding:"12px 18px"},children:a?o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[o.jsx("span",{style:{fontSize:10.5,color:"var(--proto-muted-3)",flex:1},children:t.approveHint}),o.jsx("span",{role:"button",onClick:s,style:{fontSize:12,fontWeight:600,border:"1px solid var(--proto-line-3)",background:"var(--proto-card)",color:"var(--proto-ink)",padding:"7px 14px",borderRadius:8,cursor:"pointer",flex:"none"},children:t.requestChanges}),o.jsxs("span",{role:"button",onClick:i,style:{fontSize:12,fontWeight:600,borderRadius:8,padding:"8px 18px",color:"var(--ink-solid-fg)",background:"var(--proto-ink)",cursor:"pointer",flex:"none",display:"flex",flexDirection:"column",alignItems:"center",gap:1},children:[o.jsx("span",{children:t.approvePlan}),h]})]}):o.jsx("div",{style:{height:36,borderRadius:9,background:g.bg,color:g.fg,display:"flex",alignItems:"center",justifyContent:"center",fontSize:12.5,fontWeight:600},children:g.text})})]})})}function VF(e,t){const{blockId:n,text:r}=t;return typeof n!="string"||!n||typeof r!="string"||!r?e:!e||e.blockId!==n?{blockId:n,text:r}:{blockId:n,text:e.text+r}}function qF(e,t){return!e||!t||t===e.blockId?null:e}function Yb(){return{active:null,finalizedBlockIds:[]}}function KF(e,t){const n=t.blockId;if(!n||e.finalizedBlockIds.includes(n))return e;const r=VF(e.active,t);return r===e.active?e:{...e,active:r}}function $h(e,t){var s;const n=t??((s=e.active)==null?void 0:s.blockId),r=qF(e.active,t);if(!n||e.finalizedBlockIds.includes(n))return{...e,active:r};const i=[...e.finalizedBlockIds,n].slice(-32);return{active:r,finalizedBlockIds:i}}function QF(e,t){const{messageTs:n,pendingId:r}=t;if(!r&&!n)return{pending:e,committed:null};const i=r?e.findIndex(a=>a.id===r):e.findIndex(a=>a.ts===n);if(i===-1)return{pending:e,committed:null};const s=e[i];return{pending:e.filter((a,l)=>l!==i),committed:{sessionId:t.sessionId??"",role:"user",text:s.text,ts:t.committedTs||s.ts,attachments:s.attachments}}}function YF(e,t,n){if(!t)return e;if(t.pendingUserMessages!==void 0)return t.pendingUserMessages.filter(s=>!(n!=null&&n.has(s.id))).map(s=>({...s}));if(e.length===0)return e;const r=[];for(const s of t.turns)for(const a of s.messages)a.type==="user"&&r.push({text:a.text??"",ts:a.ts});const i=[];for(const s of e){const a=r.findIndex(l=>l.text===s.text&&l.ts>=s.ts);a===-1?i.push(s):r.splice(a,1)}return i.length===e.length?e:i}function GF(e){const t=e.role==="tool";return{type:e.role,text:t?null:e.text??"",toolName:t?e.toolName??"":null,toolInput:t?e.toolInput??"":null,ts:e.ts,elapsedMs:null,attachments:e.attachments,...e.noticeLevel?{noticeLevel:e.noticeLevel}:{},...e.authAction?{authAction:e.authAction}:{}}}function XF(e){return(e==null?void 0:e.turns.length)??0}function zC(e){if(!e||e.turns.length===0)return null;const t=e.turns[e.turns.length-1];let n=0,r=!1;for(let i=1;i<t.messages.length;i++){const s=t.messages[i].elapsedMs;s!=null&&(n+=s,r=!0)}return r?n:null}function JF(e,t,n){return e??t??n}function ZF(e,t){return e??t??!1}function BC(e,t){return e??t??null}function WC(e){if(e==null)return"—";const t=Math.floor(e/1e3);if(t<60)return`${t}s`;const n=Math.floor(t/60);return n<60?`${n}m ${t%60}s`:`${Math.floor(n/60)}h ${n%60}m`}function UC(e,t){let n=0,r=0;for(let i=t+1;i<e.length;i++){const s=e[i];s.kind==="assistant"?n++:s.kind==="tools"&&(r+=s.count)}return{replies:n,toolCalls:r}}function HC(e){const t=new Set;for(let n=0;n<e.length;n++){const r=e[n];if(!(r.kind!=="user"||!r.edited))for(let i=n+1;i<e.length;i++){const s=e[i].kind;if(s==="user")break;if(s==="assistant"){t.add(i);break}}}return t}function ez(e){var n,r;if(e.type==="interaction"&&((n=e.interaction)!=null&&n.id))return`interaction|${e.interaction.id}`;const t=((r=e.authAction)==null?void 0:r.noticeId)??"";return`${e.type}|${e.ts}|${e.text??""}|${e.toolName??""}|${e.toolInput??""}|${e.noticeLevel??""}|${t}`}function tz(e,t){const n=new Date(e),r=d=>new Date(d.getFullYear(),d.getMonth(),d.getDate()).getTime(),i=Math.round((r(t)-r(n))/864e5),s=String(n.getHours()).padStart(2,"0"),a=String(n.getMinutes()).padStart(2,"0"),l=`${s}:${a}`;return i<=0?`TODAY ${l}`:i===1?`YESTERDAY ${l}`:`${n.toLocaleString("en-US",{month:"short"}).toUpperCase()} ${n.getDate()} ${l}`}function VC(e){return(t,n)=>{const r=new Date(t),i=u=>new Date(u.getFullYear(),u.getMonth(),u.getDate()).getTime(),s=Math.round((i(n)-i(r))/864e5),a=String(r.getHours()).padStart(2,"0"),l=String(r.getMinutes()).padStart(2,"0"),c=`${a}:${l}`;return s<=0?`${e.wbSessionToday} ${c}`:s===1?`${e.wbSessionYesterday} ${c}`:`${r.toLocaleString("en-US",{month:"short"}).toUpperCase()} ${r.getDate()} ${c}`}}function nz(e){const t=new Date(e);return`${t.getFullYear()}-${t.getMonth()}-${t.getDate()}`}function sv(e,t,n={}){var f;const r=n.now??new Date,i=[],s=new Set,a=(h,g)=>{const v=ez(h);s.has(v)||(s.add(v),i.push(g!==void 0?{...h,turnIndex:g}:h))};for(const h of e.turns)for(const g of h.messages)a(g,h.turnIndex);for(const h of t)a(GF(h));const l=[];let c=null,d=[];const u=()=>{d.length!==0&&(l.push({kind:"tools",count:d.length,calls:d}),d=[])};for(const h of i){const g=nz(h.ts);if(g!==c){u();const v=n.formatDivider?n.formatDivider(h.ts,r):tz(h.ts,r);l.push({kind:"divider",text:v}),c=g}if(h.type==="tool"){const v=h.debug;d.push({kind:h.toolName??"",input:h.toolInput??"",...v&&(v.toolInput!==void 0||v.toolResult!==void 0)?{debug:{toolInput:v.toolInput,...v.toolResult!==void 0?{toolResult:v.toolResult}:{},...v.overCharacterThreshold===!0?{overCharacterThreshold:!0}:{}}}:{}});continue}u(),h.type==="interaction"?l.push({kind:"interaction",subtype:h.subtype??"",text:h.text??"",detail:h.interaction,ts:h.ts??null}):h.type==="user"?l.push({kind:"user",text:h.text??"",attachments:h.attachments,...h.turnIndex!==void 0?{turnIndex:h.turnIndex}:{},...h.ts?{ts:h.ts}:{},...h.edited!==void 0?{edited:h.edited}:{},...((f=h.debug)==null?void 0:f.agentMessage)!==void 0?{debug:{agentMessage:h.debug.agentMessage}}:{}}):h.type==="assistant"&&h.noticeLevel?l.push({kind:"notice",level:h.noticeLevel,text:h.text??"",...h.authAction?{authAction:h.authAction}:{}}):l.push({kind:"assistant",text:h.text??"",streaming:!1,attachments:h.attachments})}if(u(),n.streamingText&&l.push({kind:"assistant",text:n.streamingText,streaming:!0,preview:!0}),n.streaming)for(let h=l.length-1;h>=0;h--){const g=l[h];if(g.kind==="assistant"){l[h]={...g,streaming:!0};break}}for(const h of n.pendingUser??[])l.push({kind:"user",text:h.text,attachments:h.attachments,ts:h.ts,pending:!0});return l}const qC=92,Gb=350,Xb=2*qC,rz=8*qC,oz=120;function iz(e,t,n){if(!(n>0)||e>=t)return Math.min(e,t);const r=t-e;if(r>=rz)return t;const i=r<=Xb?Gb:Gb*Xb/r,s=Math.max(r/i,oz/1e3);return Math.min(e+s*n,t)}function sz(e,t,n){return t.startsWith(e)?Math.min(Math.max(0,n),t.length):0}function az(e,t){return e.streamKey!==t.streamKey?t.text.length:sz(e.text,t.text,e.revealed)}function lz(e,t){const n=Math.floor(t);return n>0?n>=e.length?e:e.slice(0,n):""}const cz=()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;function KC(e,t,n){const[r]=p.useState(cz),[i,s]=p.useState(()=>({streamKey:n,text:e,revealed:0})),a=i.text!==e||i.streamKey!==n,l=a?az(i,{streamKey:n,text:e}):i.revealed;a&&s({streamKey:n,text:e,revealed:l});const c=t&&!r,d=c&&l<e.length;return p.useEffect(()=>{if(!d)return;let u=0,f=0;const h=g=>{const v=f===0?0:g-f;f=g,s(x=>{const b=iz(x.revealed,x.text.length,v);return b===x.revealed?x:{streamKey:x.streamKey,text:x.text,revealed:b}}),u=requestAnimationFrame(h)};return u=requestAnimationFrame(h),()=>cancelAnimationFrame(u)},[d]),c?lz(e,l):e}const tl="'IBM Plex Mono',monospace",Jb={zh:{copy:"复制",copied:"已复制",edit:"编辑消息",editDisabled:"运行中不可编辑 — 暂停后可用",cancel:"取消",sendRewind:"发送并回退",escHint:"Esc 取消 · ⌘↩ 发送",rewindNote:(e,t)=>`发送后回退其后 ${e} 条回复 · ${t} 次工具调用作废`,willRewind:"将被回退",edited:"已编辑",original:"原消息",regenNote:"由编辑重新生成"},en:{copy:"Copy",copied:"Copied",edit:"Edit message",editDisabled:"Running — stop the turn to edit",cancel:"Cancel",sendRewind:"Send & rewind",escHint:"Esc cancel · ⌘↩ send",rewindNote:(e,t)=>`Rewinds ${e} repl${e===1?"y":"ies"} · ${t} tool call${t===1?"":"s"} discarded`,willRewind:"will rewind",edited:"edited",original:"Original",regenNote:"Regenerated from edit"}};function dz(){return o.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"var(--proto-muted)",strokeWidth:"1.4",children:[o.jsx("rect",{x:"4.5",y:"4.5",width:"8",height:"8",rx:"1.5"}),o.jsx("path",{d:"M2.5 9.5V3.5a1 1 0 0 1 1-1h6"})]})}function uz(){return o.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"var(--proto-muted)",strokeWidth:"1.4",children:[o.jsx("path",{d:"M2.5 11.5l.6-2.6 6.4-6.4a1.3 1.3 0 0 1 1.8 0l.2.2a1.3 1.3 0 0 1 0 1.8L5.1 10.9z"}),o.jsx("path",{d:"M8.6 3.4l2 2"})]})}function Zb({text:e,side:t="center"}){return o.jsx("span",{style:{position:"absolute",top:-27,...t==="center"?{left:"50%",transform:"translateX(-50%)"}:{right:-8},background:"var(--proto-ink)",color:"var(--ink-solid-fg)",fontSize:10,fontWeight:600,padding:"3px 8px",borderRadius:6,whiteSpace:"nowrap",zIndex:3,pointerEvents:"none"},children:e})}function pz({text:e,copy:t,onEdit:n,editDisabled:r,showCopy:i=!0,extraAction:s}){const[a,l]=p.useState(!1),[c,d]=p.useState(!1),u=p.useRef(null);p.useEffect(()=>()=>{u.current&&clearTimeout(u.current)},[]);const f=()=>{var h;(h=navigator.clipboard)==null||h.writeText(e).catch(()=>{}),l(!0),u.current&&clearTimeout(u.current),u.current=setTimeout(()=>l(!1),1500)};return o.jsxs("div",{style:{position:"relative",display:"flex",gap:2,background:"var(--proto-card)",border:"1px solid var(--proto-line)",borderRadius:9,padding:3,boxShadow:"0 2px 8px rgba(16,24,40,.08)",flex:"none"},children:[a&&o.jsx(Zb,{text:t.copied}),c&&r&&o.jsx(Zb,{text:t.editDisabled,side:"right"}),i&&o.jsx("span",{role:"button",title:a?void 0:t.copy,onClick:f,style:{width:26,height:26,borderRadius:7,display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",...a?{background:"var(--proto-success-bg)"}:{}},children:a?o.jsx("span",{style:{color:"var(--proto-success)",fontSize:11,fontWeight:700},children:"✓"}):o.jsx(dz,{})}),n&&o.jsx("span",{role:"button",title:r?void 0:t.edit,onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),onClick:r?void 0:n,style:{width:26,height:26,borderRadius:7,display:"flex",alignItems:"center",justifyContent:"center",cursor:r?"default":"pointer",opacity:r?.3:1},children:o.jsx(uz,{})}),s]})}function fz({initialText:e,copy:t,onCancel:n,onSubmit:r,busy:i}){const[s,a]=p.useState(e),l=p.useRef(null);p.useEffect(()=>{const u=l.current;u&&(u.focus(),u.setSelectionRange(u.value.length,u.value.length),u.style.height="auto",u.style.height=`${u.scrollHeight}px`)},[]);const c=s.trim().length>0&&!i,d=()=>{c&&r(s)};return o.jsxs("div",{style:{alignSelf:"flex-end",width:"94%",boxSizing:"border-box",border:"1.5px solid var(--proto-accent)",borderRadius:"14px 14px 4px 14px",background:"var(--proto-card)",boxShadow:"0 0 0 3px rgba(70,85,212,.08)",padding:"11px 14px 9px"},children:[o.jsx("textarea",{ref:l,value:s,onChange:u=>{a(u.target.value),u.target.style.height="auto",u.target.style.height=`${u.target.scrollHeight}px`},onKeyDown:u=>{u.key==="Escape"&&(u.preventDefault(),n()),u.key==="Enter"&&(u.metaKey||u.ctrlKey)&&(u.preventDefault(),d())},rows:1,style:{width:"100%",border:"none",outline:"none",resize:"none",background:"transparent",fontSize:13.5,lineHeight:1.55,color:"var(--proto-ink)",fontFamily:"inherit",padding:0,margin:0,display:"block",overflow:"hidden",boxSizing:"border-box"}}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:10,paddingTop:9,borderTop:"1px solid var(--proto-line-2)"},children:[o.jsx("span",{style:{font:`400 10px ${tl}`,color:"var(--proto-faint)"},children:t.escHint}),o.jsx("span",{role:"button",onClick:n,style:{marginLeft:"auto",fontSize:12,fontWeight:600,color:"var(--proto-muted)",border:"1px solid var(--proto-line-3)",borderRadius:8,padding:"5px 12px",cursor:"pointer"},children:t.cancel}),o.jsx("span",{role:"button",onClick:d,style:{fontSize:12,fontWeight:600,color:"var(--ink-solid-fg)",background:"var(--proto-ink)",borderRadius:8,padding:"6px 13px",cursor:c?"pointer":"default",opacity:c?1:.5},children:t.sendRewind})]})]})}function hz({replies:e,toolCalls:t,copy:n}){return o.jsxs("div",{style:{alignSelf:"flex-end",display:"flex",alignItems:"center",gap:6,font:`500 10.5px ${tl}`,color:"var(--proto-amber-text)"},children:[o.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:"var(--proto-amber)",flex:"none"}}),n.rewindNote(e,t)]})}function gz({children:e,copy:t}){return o.jsxs("div",{style:{position:"relative",marginTop:6},children:[o.jsx("span",{style:{position:"absolute",top:-4,right:0,font:`600 9px ${tl}`,color:"var(--proto-amber-fg)",background:"var(--pill-waiting-bg)",padding:"2px 7px",borderRadius:4,zIndex:1},children:t.willRewind}),o.jsx("div",{style:{opacity:.35,display:"flex",flexDirection:"column",gap:16,paddingTop:14,pointerEvents:"none"},children:e})]})}function ej(e){if(!e)return null;const t=new Date(e);return Number.isNaN(t.getTime())?null:`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`}function xz({edited:e,ts:t,copy:n}){const[r,i]=p.useState(!1),s=ej(t),a=ej(e.originalTs);return o.jsxs("div",{onMouseEnter:()=>i(!0),onMouseLeave:()=>i(!1),style:{position:"relative",alignSelf:"flex-end",font:`400 9.5px ${tl}`,color:"var(--proto-faint)",cursor:"default"},children:[r&&o.jsxs("div",{style:{position:"absolute",bottom:"100%",right:0,marginBottom:5,minWidth:180,maxWidth:420,background:"var(--proto-card)",border:"1px solid var(--proto-line)",borderRadius:10,boxShadow:"0 8px 24px rgba(16,24,40,.12)",padding:"9px 12px",boxSizing:"border-box",zIndex:3},children:[o.jsxs("div",{style:{font:`600 9px ${tl}`,color:"var(--proto-muted-3)",letterSpacing:".05em",paddingBottom:4},children:[n.original,a?` · ${a}`:""]}),o.jsx("div",{style:{fontSize:12,lineHeight:1.5,color:"var(--proto-muted)",whiteSpace:"pre-wrap",overflowWrap:"break-word"},children:e.originalText})]}),o.jsx("span",{style:{borderBottom:"1px dotted var(--proto-faint)"},children:n.edited}),s&&o.jsxs("span",{children:[" · ",s]})]})}function mz({copy:e}){return o.jsxs("div",{style:{font:`400 9.5px ${tl}`,color:"var(--proto-faint)",display:"flex",alignItems:"center",gap:5},children:[o.jsx("span",{style:{width:5,height:5,borderRadius:"50%",background:"var(--proto-line-3)",flex:"none"}}),e.regenNote]})}const wa="'IBM Plex Mono',monospace";function vz({text:e}){return o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[o.jsx("div",{style:{flex:1,height:1,background:"var(--proto-line-2)"}}),o.jsx("div",{style:{fontSize:10,fontWeight:600,letterSpacing:".06em",color:"var(--proto-faint)"},children:e}),o.jsx("div",{style:{flex:1,height:1,background:"var(--proto-line-2)"}})]})}function QC(e){return e==="image"?{bg:"var(--proto-accent-bg)",fg:"var(--proto-accent)"}:e==="video"?{bg:"var(--proto-danger-bg)",fg:"var(--proto-danger)"}:{bg:"var(--proto-gray)",fg:"var(--proto-muted)"}}function YC(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function GC(e){const t=e.lastIndexOf(".");return t>0?e.slice(t+1).toUpperCase().slice(0,4):"FILE"}function yz({a:e,width:t,height:n}){const r=gs(e.type),{openMedia:i}=gd(),s=nv(e.path);return o.jsxs("div",{role:"button",title:e.name,onClick:()=>i({kind:r,name:e.name,path:e.path}),style:{position:"relative",width:t,height:n,borderRadius:12,border:"1px solid var(--proto-line)",background:s?"#000":"repeating-linear-gradient(45deg,var(--proto-line),var(--proto-line) 5px,var(--proto-line) 5px,var(--proto-line) 10px)",boxSizing:"border-box",flex:"none",overflow:"hidden",cursor:"pointer"},children:[s&&r==="image"&&o.jsx("img",{src:s,alt:e.name,style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}}),s&&r==="video"&&o.jsx(vd,{src:s,style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}}),r==="video"&&o.jsx("span",{style:{position:"absolute",left:"50%",top:"50%",transform:"translate(-50%,-50%)",width:26,height:26,borderRadius:"50%",background:"rgba(25,28,34,.82)",color:"var(--ink-solid-fg)",fontSize:9,display:"flex",alignItems:"center",justifyContent:"center",paddingLeft:2,boxSizing:"border-box"},children:"▶"}),o.jsx("span",{style:{position:"absolute",left:6,bottom:5,maxWidth:t-12,font:"500 8.5px 'IBM Plex Mono',monospace",color:"var(--proto-muted-2)",background:"rgba(255,255,255,.88)",padding:"1.5px 5px",borderRadius:4,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",boxSizing:"border-box"},children:e.name})]})}function bz({a:e}){if(e.type==="image"||e.type==="video")return o.jsx(yz,{a:e,width:150,height:98});const t=QC(e.type),n=GC(e.name),{openDoc:r}=md(),i=xd(e.name,e.mimeType),s=i?()=>r({kind:i,name:e.name,path:e.path,mimeType:e.mimeType}):void 0;return o.jsxs("div",{role:s?"button":void 0,title:s?e.name:void 0,onClick:s,style:{display:"flex",alignItems:"center",gap:9,background:"var(--proto-gray)",borderRadius:10,padding:"8px 12px 8px 9px",cursor:s?"pointer":"default"},children:[o.jsx("span",{style:{width:26,height:32,borderRadius:5,background:t.bg,color:t.fg,display:"flex",alignItems:"center",justifyContent:"center",font:"700 8px 'IBM Plex Mono',monospace",flex:"none"},children:n}),o.jsxs("span",{style:{display:"flex",flexDirection:"column",gap:2},children:[o.jsx("span",{style:{font:"500 11px 'IBM Plex Mono',monospace",color:"var(--proto-ink)"},children:e.name}),o.jsxs("span",{style:{font:"400 9px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)"},children:[YC(e.size)," · ",e.path]})]})]})}function jz(e){const t=e.lastIndexOf("/");return t>=0?e.slice(0,t+1):e}function wz({title:e,onClick:t,children:n}){return o.jsx("span",{role:"button",title:e,onClick:t,style:{width:26,height:26,borderRadius:7,border:"1px solid var(--proto-line)",background:"var(--proto-rail)",color:"var(--proto-muted)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,cursor:"pointer",flex:"none"},children:n})}function kz({onClick:e,children:t}){return o.jsxs("span",{role:"button",onClick:e,style:{height:26,borderRadius:7,border:"1px solid var(--proto-accent-border)",background:"var(--proto-rail)",color:"var(--proto-accent)",display:"flex",alignItems:"center",justifyContent:"center",font:`500 9.5px ${wa}`,padding:"0 9px",cursor:"pointer",flex:"none"},children:[t," ↗"]})}function Sz({a:e}){const t=H(),n=xl(),{openDoc:r}=md(),i=QC(e.type),s=GC(e.name),a=xd(e.name,e.mimeType),l=a?()=>r({kind:a,name:e.name,path:e.path,mimeType:e.mimeType}):void 0;return o.jsxs("div",{role:l?"button":void 0,onClick:l,style:{display:"flex",alignItems:"center",gap:10,border:"1px solid var(--proto-line)",background:"var(--proto-card)",borderRadius:10,padding:"9px 10px",boxShadow:"0 1px 2px rgba(16,24,40,.03)",boxSizing:"border-box",maxWidth:"100%",cursor:l?"pointer":"default"},children:[o.jsx("span",{style:{width:28,height:34,borderRadius:5,background:i.bg,color:i.fg,display:"flex",alignItems:"center",justifyContent:"center",font:`700 8px ${wa}`,flex:"none"},children:s}),o.jsxs("span",{style:{display:"flex",flexDirection:"column",gap:2,minWidth:0,flex:1},children:[o.jsx("span",{style:{font:`500 11.5px ${wa}`,color:"var(--proto-ink)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name}),o.jsxs("span",{style:{font:`400 9px ${wa}`,color:"var(--proto-muted-3)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[YC(e.size)," · ",jz(e.path)]})]}),o.jsxs("span",{style:{display:"flex",gap:5,flex:"none"},onClick:c=>c.stopPropagation(),children:[o.jsx(wz,{title:t.wbFileDownload,onClick:()=>n(e.path,e.name),children:"↓"}),l&&o.jsx(kz,{onClick:l,children:t.wbFileOpen})]})]})}function Cz({a:e}){const t=H(),n=xl(),r=gs(e.type),{openMedia:i}=gd(),s=nv(e.path),[a,l]=p.useState(!1);return o.jsxs("div",{role:"button",title:e.name,onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),onClick:()=>i({kind:r,name:e.name,path:e.path}),style:{position:"relative",maxWidth:320,borderRadius:12,border:"1px solid var(--proto-line)",overflow:"hidden",boxSizing:"border-box",cursor:"pointer",background:s?"#000":"repeating-linear-gradient(45deg,var(--proto-line),var(--proto-line) 5px,var(--proto-line) 5px,var(--proto-line) 10px)"},children:[s&&r==="image"&&o.jsx("img",{src:s,alt:e.name,style:{display:"block",maxWidth:320,maxHeight:240,width:"auto",height:"auto"}}),s&&r==="video"&&o.jsx(vd,{src:s,style:{display:"block",maxWidth:320,maxHeight:240,width:"auto",height:"auto"}}),!s&&o.jsx("div",{style:{width:320,height:180}}),r==="video"&&o.jsx("span",{style:{position:"absolute",left:"50%",top:"50%",transform:"translate(-50%,-50%)",width:40,height:40,borderRadius:"50%",background:"rgba(25,28,34,.72)",color:"var(--ink-solid-fg)",fontSize:14,display:"flex",alignItems:"center",justifyContent:"center",paddingLeft:3,boxSizing:"border-box"},children:"▶"}),o.jsx("span",{style:{position:"absolute",left:8,bottom:7,font:`500 8.5px ${wa}`,color:"var(--proto-muted-2)",background:"rgba(255,255,255,.88)",padding:"1.5px 5px",borderRadius:4},children:e.name}),a&&o.jsx("span",{role:"button",title:t.wbFileDownload,onClick:c=>{c.stopPropagation(),n(e.path,e.name)},style:{position:"absolute",top:7,right:7,width:24,height:24,borderRadius:7,background:"rgba(25,28,34,.78)",color:"var(--ink-solid-fg)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,cursor:"pointer"},children:"↓"})]})}function Ez({attachments:e}){const t=H(),n=xl(),r=e.filter(s=>gs(s.type)!==null),i=e.filter(s=>gs(s.type)===null);return o.jsxs("div",{style:{maxWidth:"75%",display:"flex",flexDirection:"column",alignItems:"flex-start",gap:6,marginTop:10},children:[r.length>0&&o.jsx("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:r.map((s,a)=>o.jsx(Cz,{a:s},`media-${a}`))}),i.map((s,a)=>o.jsx(Sz,{a:s},`file-${a}`)),e.length>=3&&o.jsxs("div",{style:{font:`400 9.5px ${wa}`,color:"var(--proto-faint)",padding:"2px 2px 0"},children:[e.length," ",t.wbFileFiles," ·"," ",o.jsxs("span",{style:{color:"var(--proto-muted-2)",cursor:"pointer"},onClick:()=>e.forEach(s=>n(s.path,s.name)),children:[t.wbFileDownloadAll," ↓"]})]})]})}function Tz({text:e,attachments:t,ts:n,edited:r,editCopy:i,onStartEdit:s,editDisabled:a,pending:l,debug:c}){const d=t&&t.length>0,[u,f]=p.useState(null);return o.jsxs("div",{className:"group",style:{position:"relative",alignSelf:"flex-end",maxWidth:"75%",display:"flex",flexDirection:"column",alignItems:"flex-end",gap:6,animation:"cxmsg .34s cubic-bezier(.22,1,.36,1) both"},children:[i&&(e||c)&&o.jsx("div",{className:"pointer-events-none opacity-0 transition-opacity group-hover:pointer-events-auto group-hover:opacity-100 focus-within:pointer-events-auto focus-within:opacity-100",style:{position:"absolute",right:"100%",top:"50%",transform:"translateY(-50%)",paddingRight:8,display:"flex"},children:o.jsx(pz,{text:e,copy:i,showCopy:!!e,onEdit:e?s:void 0,editDisabled:a,extraAction:c?o.jsx(cC,{className:"!h-[26px] !min-w-[26px] !border-0 !bg-transparent !px-0 !shadow-none",onClick:h=>{h.stopPropagation(),f({kind:"user",agentMessage:c.agentMessage})}}):void 0})}),d&&o.jsx("div",{style:{display:"flex",gap:6,flexWrap:"wrap",justifyContent:"flex-end"},children:t.map((h,g)=>o.jsx(bz,{a:h},g))}),e&&o.jsx("div",{style:{position:"relative",display:"flex",justifyContent:"flex-end",maxWidth:"100%"},children:o.jsx("div",{style:{background:"var(--proto-gray)",borderRadius:"14px 14px 4px 14px",padding:"9px 14px",fontSize:13.5,lineHeight:1.55,color:l?"var(--proto-muted)":"var(--proto-ink)",whiteSpace:"pre-wrap",overflowWrap:"break-word",wordBreak:"break-word",minWidth:0},children:e})}),o.jsx(dC,{detail:u,onClose:()=>f(null)}),i&&r&&o.jsx(xz,{edited:r,ts:n,copy:i})]})}function Pz({text:e,attachments:t,editCopy:n,regen:r,preview:i,streamKey:s}){const a=!!t&&t.length>0,l=KC(e,!!i,s);return o.jsxs("div",{style:{position:"relative",animation:"cxmsg .34s cubic-bezier(.22,1,.36,1) both",fontSize:14,lineHeight:1.65,color:"var(--proto-ink-2)",minWidth:0,overflowWrap:"break-word",wordBreak:"break-word"},children:[n&&r&&o.jsx("div",{style:{marginBottom:4},children:o.jsx(mz,{copy:n})}),l.trim()&&o.jsx(Si,{text:l}),a&&o.jsx(Ez,{attachments:t})]})}function Rz(){const e=H();return o.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:13,padding:"88px 20px 40px",textAlign:"center"},children:[o.jsx("div",{"aria-label":"Cortex",style:{width:40,height:40,borderRadius:12,background:"var(--brand-badge-bg)",border:"1px solid var(--brand-badge-border)",display:"flex",alignItems:"center",justifyContent:"center"},children:o.jsxs("svg",{width:28,height:28,viewBox:"0 0 64 64",fill:"none","aria-hidden":"true",children:[o.jsx("circle",{cx:33,cy:32,r:5,fill:"var(--brand-badge-core)"}),o.jsx("path",{d:"M42.29 23.64A12.5 12.5 0 1 0 42.29 40.36",stroke:"var(--brand-badge-arc)",strokeWidth:5,strokeLinecap:"round"}),o.jsx("path",{d:"M48.6 17.95A21 21 0 1 0 48.6 46.05",stroke:"var(--brand-badge-arc)",strokeWidth:5,strokeLinecap:"round"})]})}),o.jsx("div",{style:{fontSize:15,fontWeight:650,color:"var(--proto-ink)"},children:e.wbEmptyTitle}),o.jsx("div",{style:{fontSize:12,color:"var(--proto-muted-2)",lineHeight:1.7,maxWidth:420},children:e.wbEmptyBody}),o.jsx("div",{style:{fontSize:10.5,color:"var(--proto-faint)",lineHeight:1.7,maxWidth:430},children:e.wbEmptyHint})]})}function Iz({tone:e,label:t,text:n}){const r=e==="rejected"?"var(--proto-danger)":e==="inactive"?"var(--proto-muted-3)":"var(--proto-success)",i=e==="rejected"?"✗":e==="inactive"?"◌":"✓";return o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 12px",background:"var(--proto-rail)",border:"1px solid var(--proto-line-2)",borderRadius:10,opacity:e==="inactive"?.6:.85},children:[o.jsxs("span",{style:{fontSize:10,fontWeight:700,color:r,flexShrink:0},children:[i," ",t]}),o.jsx("span",{style:{fontSize:12,color:"var(--proto-muted)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:n})]})}function Mz({row:e,actions:t}){const n=ut(),r=n==="zh"?Qb.zh:Qb.en,[i,s]=p.useState(LF),[a,l]=p.useState(!1),[c,d]=p.useState(!1),u=OC(e);if(u.kind==="ask"){const f=u.model;return o.jsx(WF,{model:f,state:i,copy:r,onState:s,onSubmit:h=>t==null?void 0:t.answerQuestion(f.requestId,h),busy:!!(t!=null&&t.busy)})}if(u.kind==="plan"){const f=u.model;return o.jsxs(o.Fragment,{children:[o.jsx(UF,{model:f,copy:r,feedbackOpen:a,onFeedbackOpen:l,onApprove:()=>t==null?void 0:t.approvePlan(f.requestId),onReject:h=>{t==null||t.rejectPlan(f.requestId,h),l(!1)},onOpenRead:()=>d(!0),busy:!!(t!=null&&t.busy)}),c&&o.jsx(HF,{model:f,copy:r,lang:n,onClose:()=>d(!1),onApprove:()=>{t==null||t.approvePlan(f.requestId),d(!1)},onRequestChanges:()=>{d(!1),l(!0)}})]})}return o.jsx(Iz,{tone:u.tone,label:u.label,text:u.text})}function Fh({row:e,interactionActions:t,editCopy:n,onStartEdit:r,editDisabled:i,regen:s,streamKey:a}){switch(e.kind){case"divider":return o.jsx(vz,{text:e.text});case"user":return o.jsx(Tz,{text:e.text,attachments:e.attachments,ts:e.ts,edited:e.edited,editCopy:n,onStartEdit:r,editDisabled:i,pending:e.pending,debug:e.debug});case"tools":return o.jsx(Y$,{calls:e.calls.map(l=>({label:l.kind,kind:l.kind,input:l.input,...l.debug?{debug:l.debug}:{}}))});case"assistant":return o.jsx(Pz,{text:e.text,attachments:e.attachments,editCopy:n,regen:s,preview:e.preview,streamKey:a});case"notice":return o.jsx(DC,{level:e.level,text:e.text,authAction:e.authAction});case"interaction":return o.jsx(Mz,{row:e,actions:t});default:return null}}function XC({rows:e,interactionActions:t,edit:n,streamKey:r}){const s=ut()==="zh"?Jb.zh:Jb.en,[a,l]=p.useState(null),c=HC(e),d=a!=null?e[a]:null,u=!!n&&!!d&&d.kind==="user"&&d.turnIndex!==void 0,f=u?UC(e,a):null,h=(g,v)=>g.kind==="interaction"&&g.detail?`int-${g.detail.id}`:v;if(u){const g=d,v=e.slice(0,a),x=e.slice(a+1);return o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[v.map((b,j)=>o.jsx(Fh,{row:b,interactionActions:t,streamKey:r},h(b,j))),o.jsx(fz,{initialText:g.text,copy:s,busy:n.busy,onCancel:()=>l(null),onSubmit:b=>{n.onSubmit(g.turnIndex,b),l(null)}}),f&&o.jsx(hz,{replies:f.replies,toolCalls:f.toolCalls,copy:s}),x.length>0&&o.jsx(gz,{copy:s,children:x.map((b,j)=>o.jsx(Fh,{row:b,interactionActions:t,streamKey:r},h(b,a+1+j)))})]})}return o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:16},children:e.map((g,v)=>o.jsx(Fh,{row:g,interactionActions:t,editCopy:s,regen:c.has(v),onStartEdit:n&&g.kind==="user"&&g.turnIndex!==void 0?()=>l(v):void 0,editDisabled:(n==null?void 0:n.running)||(n==null?void 0:n.busy),streamKey:r},h(g,v)))})}function Lz({rows:e,loading:t,inlineThreadCard:n,interactionActions:r,edit:i,streamKey:s}){const a=e.length>0,l=p.useRef(null),c=p.useRef(null),d=p.useRef(!0),u=()=>{const f=l.current;if(!f)return;const h=f.scrollHeight-f.scrollTop-f.clientHeight;d.current=h<40};return p.useEffect(()=>{const f=l.current;f&&d.current&&(f.scrollTop=f.scrollHeight)},[e,t]),p.useEffect(()=>{const f=l.current,h=c.current;if(!f||!h||typeof ResizeObserver>"u")return;const g=new ResizeObserver(()=>{d.current&&(f.scrollTop=f.scrollHeight)});return g.observe(h),()=>g.disconnect()},[]),o.jsx("div",{ref:l,onScroll:u,style:{flex:1,overflow:"auto",minHeight:0},children:o.jsxs("div",{ref:c,style:{width:"100%",maxWidth:756,margin:"0 auto",padding:"22px 32px 12px"},children:[!a&&!t&&o.jsx(Rz,{}),o.jsx(XC,{rows:e,interactionActions:r,edit:i,streamKey:s}),n&&o.jsx("div",{style:{marginTop:16},children:n})]})})}const JC=["session.message","session.message.delivered","session.status","session.turn","session.context-usage","session.context-compacted","session.interaction","session.rewound","session.debug.updated"],Oz=["session.message.delta"],av=["thread.created","thread.step.started","thread.step.finished","thread.completed","thread.failed"],lv=["task.claimed","task.completed","task.blocked","task.dispatched"],Az=[...lv,"thread.created"],ZC=["system.notice"],Dz=["config.changed"],e6=["rate-limit.changed"],Nz=[...JC,...av,...lv,...ZC,...Dz,...e6];function _z(e){return e.type!=="config.changed"||!e.payload||typeof e.payload!="object"?!1:e.payload.section==="profiles"}function $z(e){const t=e.payload;if(!t||typeof t!="object")return null;const n=t.sessionId;return typeof n=="string"&&n?n:null}function Fz(e,t,n){if(!t.includes(e.type))return!1;const r=n==null?void 0:n.sessionId;if(!r)return!0;const i=$z(e);return i===null||i===r}function zz(e,t){let n=0;for(const r of e)if(Fz(t,r.types,r.scope)){n++;try{r.fn(t)}catch{}}return n}function Bz(){return{hasConnected:!1,epoch:0,down:!1}}function tj(e,t){return t!=="pending"?e.hasConnected&&!e.down?{...e,down:!0}:e:e.hasConnected?e.down?{hasConnected:!0,epoch:e.epoch+1,down:!1}:e:{hasConnected:!0,epoch:e.epoch,down:!1}}const cv=p.createContext({register:()=>()=>{},connState:"connecting",hasConnected:!1,reconnectEpoch:0});function t6({children:e}){const t=Qp(),n=le(),r=je(),[i]=p.useState(()=>n.config.get.queryFilter({})),s=p.useRef(new Set),[a,l]=p.useState(()=>({state:"connecting",accum:Bz()}));p.useEffect(()=>{const u=t.subscribe.subscribe({events:[...Nz]},{onConnectionStateChange:f=>{const h=f.state;l(g=>({state:h,accum:tj(g.accum,h)}))},onData:f=>{const h=f;!h||typeof h.type!="string"||(_z(h)&&r.invalidateQueries(i),zz([...s.current],h))},onError:()=>{l(f=>({state:"idle",accum:tj(f.accum,"idle")}))}});return()=>u.unsubscribe()},[t,i,r]);const c=p.useCallback(u=>(s.current.add(u),()=>{s.current.delete(u)}),[]),d=p.useMemo(()=>({register:c,connState:a.state,hasConnected:a.accum.hasConnected,reconnectEpoch:a.accum.epoch}),[c,a]);return o.jsx(cv.Provider,{value:d,children:e})}function Ci(e,t,n){const{register:r}=p.useContext(cv),i=p.useRef(t);i.current=t;const s=e.join(","),a=n==null?void 0:n.sessionId;p.useEffect(()=>r({types:s.split(","),scope:a?{sessionId:a}:void 0,fn:l=>i.current(l)}),[r,s,a])}function dv(){const{connState:e,hasConnected:t,reconnectEpoch:n}=p.useContext(cv);return{connState:e,hasConnected:t,reconnectEpoch:n}}function Wz(e,t){return e??t??null}function nj(e){if(!e||typeof e!="object")return null;const t=e,n=rj(t.usedTokens),r=t.contextWindow,i=rj(t.percent),s=t.accuracy,a=t.updatedAt;return t.usedTokens!==null&&n===null||typeof r!="number"||!Number.isFinite(r)||r<=0||t.percent!==null&&i===null||s!=="exact"&&s!=="estimate"||typeof a!="string"?null:{usedTokens:n,contextWindow:r,percent:i,accuracy:s,updatedAt:a}}function n6(e){const t=(e==null?void 0:e.usedTokens)??null,n=(e==null?void 0:e.contextWindow)??null,r=(e==null?void 0:e.percent)??null;return{compact:`${oj(t)} / ${oj(n)}`,current:ij(t),maximum:ij(n),percentLabel:r===null?"—":`${Du(r)}%`,progress:r===null?null:Math.min(100,Math.max(0,r)),estimated:(e==null?void 0:e.accuracy)==="estimate"}}function rj(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0?e:null}function oj(e){return e===null?"—":e>=1e6?`${Du(e/1e6)}m`:e>=1e3?`${Du(e/1e3)}k`:Du(e)}function ij(e){return e===null?"—":Math.round(e).toString().replace(/\B(?=(\d{3})+(?!\d))/g,",")}function Du(e){return Number(e.toFixed(1)).toString()}function Uz(e,t,n){const r=Qp(),i=p.useRef(n);i.current=n,p.useEffect(()=>{if(!t||!e)return;const s=r.subscribe.subscribe({events:[...Oz],sessionId:e},{onData:a=>{const l=a;!l||l.type!=="session.message.delta"||!l.payload||i.current(l.payload)},onError:()=>{}});return()=>s.unsubscribe()},[r,e,t])}const su=60,Hz=2500;function Tf(e,t,n,r={}){var _;const i=le(),s=je(),[a,l]=p.useState([]),c=p.useRef([]),d=p.useCallback(F=>{const W=typeof F=="function"?F(c.current):F;c.current=W,l(W)},[]),[u,f]=p.useState(!1),[h,g]=p.useState(null),[v,x]=p.useState(null),[b,j]=p.useState(null),[y,w]=p.useState(null),[k,S]=p.useState(Yb),[T,C]=p.useState([]),P=p.useRef(null),I=p.useRef([]),L=p.useRef(new Set),z=p.useCallback(F=>{I.current=F,C(F)},[]),q=p.useCallback(()=>({liveTail:c.current,pendingUser:I.current}),[]);p.useEffect(()=>(d([]),f(!1),g(null),x(null),j(null),w(null),S(Yb()),L.current.clear(),z([]),()=>{P.current&&clearTimeout(P.current)}),[e,d,z]);const X=r.transcript;p.useEffect(()=>{if(!X||X.sessionId!==e)return;if(X.pendingUserMessages!==void 0){const W=new Set(X.pendingUserMessages.map(te=>te.id));for(const te of L.current)W.has(te)||L.current.delete(te)}const F=YF(I.current,X,L.current);F!==I.current&&z(F)},[e,X,z]),Uz(e,!!r.deltas,F=>{S(W=>KF(W,F))});const{reconnectEpoch:D}=dv();p.useEffect(()=>{D===0||!e||(s.invalidateQueries(i.sessions.list.queryFilter()),s.invalidateQueries(i.sessions.transcript.queryFilter({sessionId:e})))},[D,e,s,i]),Ci(JC,F=>{if(!e)return;if(F.type==="session.status"){const A=F.payload,V=!!(A!=null&&A.running);g(V),x(V&&!!(A!=null&&A.backgroundRunning)),V?j(null):(f(!1),S(oe=>$h(oe,void 0)),P.current&&clearTimeout(P.current)),s.invalidateQueries(i.sessions.list.queryFilter());return}if(F.type==="session.context-usage"){const A=nj(F.payload);A&&w(A);return}if(F.type==="session.context-compacted"){const A=F.payload,V=(A==null?void 0:A.contextUsage)===null?null:nj(A==null?void 0:A.contextUsage);w(V),s.invalidateQueries(i.sessions.list.queryFilter());return}if(F.type==="session.rewound"){d([]),S(A=>$h(A,void 0)),z([]),s.invalidateQueries(i.sessions.transcript.queryFilter({sessionId:e})),s.invalidateQueries(i.sessions.list.queryFilter());return}if(F.type==="session.debug.updated"){s.invalidateQueries(i.sessions.transcript.queryFilter({sessionId:e}));return}if(F.type==="session.interaction"){s.invalidateQueries(i.sessions.transcript.queryFilter({sessionId:e})),s.invalidateQueries(i.sessions.pendingInteraction.queryFilter());return}if(F.type==="session.message.delivered"){const A=F.payload;if(!A)return;A.pendingId&&L.current.add(A.pendingId);const{pending:V,committed:oe}=QF(I.current,{...A,sessionId:e});oe&&(z(V),d(Z=>{const ie=[...Z,oe];return ie.length>su?ie.slice(ie.length-su):ie})),s.invalidateQueries(i.sessions.transcript.queryFilter({sessionId:e}));return}if(F.type==="session.turn"){const A=F.payload;typeof(A==null?void 0:A.numTurns)=="number"&&j(A.numTurns);return}const W=F.payload;if(!W||W.role!=="user"&&W.role!=="assistant"&&W.role!=="tool")return;if(W.role==="user"&&W.pending){const A={id:W.pendingId,ts:W.ts??new Date().toISOString(),text:W.text??"",attachments:W.attachments};(A.id?I.current.some(oe=>oe.id===A.id):I.current.some(oe=>oe.ts===A.ts))||z([...I.current,A]),s.invalidateQueries(i.sessions.transcript.queryFilter({sessionId:e}));return}const te={sessionId:W.sessionId??e,role:W.role,text:W.text??"",toolName:W.toolName,toolInput:W.toolInput,noticeLevel:W.noticeLevel,authAction:W.authAction,ts:W.ts??new Date().toISOString(),blockId:W.blockId,attachments:W.attachments};W.role==="assistant"&&!W.noticeLevel&&S(A=>$h(A,W.blockId)),d(A=>{const V=[...A,te];return V.length>su?V.slice(V.length-su):V}),W.noticeLevel||(f(!0),P.current&&clearTimeout(P.current),P.current=setTimeout(()=>f(!1),Hz)),s.invalidateQueries(i.sessions.transcript.queryFilter({sessionId:e}))},{sessionId:e});const U=JF(h,t,u),Q=ZF(v,n),J=Wz(y,r.contextUsage);return{liveTail:a,getMessageSnapshot:q,streaming:u,running:U,backgroundRunning:Q,liveTurns:b,contextUsage:J,streamingText:((_=k.active)==null?void 0:_.text)??null,pendingUser:T}}const Vz={sessionId:"",turns:[]};function r6({sessionId:e,live:t}){const n=le(),r=H(),i=Y({...n.sessions.transcript.queryOptions({sessionId:e??""}),enabled:!!e}),{liveTail:s,streaming:a}=Tf(t&&e?e:""),l=i.data??Vz,c=p.useMemo(()=>sv(l,t?s:[],{streaming:t&&a,formatDivider:VC(r)}),[l,s,a,t,r]),d={fontSize:11.5,color:"var(--proto-muted-3)",padding:"2px 0"};return e?i.isPending?o.jsx("div",{style:d,children:r.thStepLoading}):c.length===0?o.jsx("div",{style:d,children:r.thStepEmpty}):o.jsx("div",{style:{maxHeight:460,overflow:"auto",fontSize:13.5},children:o.jsx(XC,{rows:c})}):o.jsx("div",{style:d,children:r.thStepNoSession})}function o6({children:e}){return o.jsx("span",{style:{fontSize:10,fontWeight:700,letterSpacing:".07em",color:"var(--proto-muted-3)"},children:e})}function i6({kind:e}){return e==="done"?o.jsx("span",{style:{width:15,height:15,borderRadius:"50%",background:"var(--proto-success-bg)",color:"var(--proto-success)",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:8.5,fontWeight:700,flex:"none"},children:"✓"}):e==="running"?o.jsx("span",{style:{width:15,height:15,borderRadius:"50%",background:"var(--proto-accent)",boxShadow:"0 0 0 3px var(--proto-accent-bg)",animation:"cxpulse 1.6s ease-in-out infinite",flex:"none"}}):o.jsx("span",{style:{width:15,height:15,borderRadius:"50%",border:"1.5px solid var(--proto-line-3)",boxSizing:"border-box",flex:"none"}})}function qz({step:e,onClick:t}){const[n,r]=p.useState(!1),i=e.kind==="pending";return o.jsx("div",{onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),onClick:t,"data-step-kind":e.kind,style:{background:"var(--proto-card)",border:i?"1px dashed var(--proto-line-3)":"1px solid "+(n?"var(--proto-accent-border)":"var(--proto-line)"),borderRadius:10,padding:"9px 13px",boxShadow:"0 1px 2px rgba(16,24,40,.03)",cursor:"pointer"},children:o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[o.jsx(i6,{kind:e.kind}),o.jsx("span",{style:{fontSize:12.5,fontWeight:600,color:i?"var(--proto-faint)":"var(--proto-muted)",flex:"none"},children:e.title}),o.jsx("span",{style:{fontSize:10.5,color:"var(--proto-muted-3)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.note}),o.jsx("span",{style:{marginLeft:"auto",font:"400 10px 'IBM Plex Mono',monospace",color:i?"var(--proto-line-3)":"var(--proto-faint)",flex:"none"},children:e.meta}),o.jsx("span",{style:{color:"var(--proto-line-3)",fontSize:9,flex:"none"},children:"▸"})]})})}function Kz({sub:e,onOpen:t}){const n=H(),r=e.pill.text==="Running";return o.jsxs("div",{"data-sub-thread-id":e.id,style:{border:"1px solid "+(r?"var(--proto-accent-bg)":"var(--proto-line-2)"),background:"var(--proto-rail)",borderRadius:8,padding:"8px 11px"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7},children:[o.jsx("span",{style:{font:"600 11px 'IBM Plex Mono',monospace",color:"var(--proto-ink)"},children:e.name}),o.jsx("span",{style:{font:"400 9px 'IBM Plex Mono',monospace",color:"var(--proto-faint)"},children:e.level}),o.jsx("span",{style:{marginLeft:"auto",fontSize:9.5,fontWeight:600,padding:"1.5px 7px",borderRadius:999,background:e.pill.bg,color:e.pill.fg},children:e.pill.text})]}),(e.hasLine||e.drillable)&&o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,fontSize:10,color:"var(--proto-muted)",marginTop:5},children:[e.hasLine&&e.line,e.drillable&&o.jsxs("span",{"data-drill-thread-id":e.id,onClick:t,style:{marginLeft:"auto",fontSize:10,fontWeight:600,color:"var(--proto-accent)",cursor:"pointer"},children:[n.thOpenSub," ›"]})]})]})}function Qz({step:e,onCollapse:t,onOpenSub:n,renderChat:r}){const i=H(),s=e.kind==="running",a=e.agent,l=e.profile??(a==null?void 0:a.profile),c=(a==null?void 0:a.execInfo)||e.sessionName||"";return o.jsxs("div",{"data-active-step":s?"true":void 0,"data-expanded-step":"true",style:{background:"var(--proto-card)",border:s?"1.5px solid var(--proto-accent)":"1.5px solid var(--proto-accent-border)",borderRadius:10,boxShadow:s?"0 0 0 3px var(--proto-accent-bg)":"0 1px 2px rgba(16,24,40,.04)",overflow:"hidden"},children:[o.jsxs("div",{onClick:t,style:{display:"flex",alignItems:"center",gap:8,padding:"10px 13px",cursor:"pointer"},children:[o.jsx(i6,{kind:e.kind}),o.jsx("span",{style:{fontSize:12.5,fontWeight:650,color:"var(--proto-ink)"},children:e.title}),l&&o.jsxs("span",{style:{font:"500 9px 'IBM Plex Mono',monospace",border:"1px solid var(--proto-line)",color:"var(--proto-muted-2)",padding:"1px 6px",borderRadius:5},children:[i.thAgentLabel,": ",l]}),c&&o.jsx("span",{style:{font:"400 10px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)"},children:c}),o.jsx("span",{style:{marginLeft:"auto",font:"400 10px 'IBM Plex Mono',monospace",color:s?"var(--proto-accent)":"var(--proto-faint)"},children:e.meta}),o.jsx("span",{style:{color:"var(--proto-faint)",fontSize:9,flex:"none",transform:"rotate(90deg)"},children:"▸"})]}),o.jsxs("div",{style:{borderTop:"1px solid var(--proto-line-2)",padding:"10px 13px 12px"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:8},children:[o.jsx(o6,{children:i.thAgentSection}),s&&(a==null?void 0:a.live)&&o.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:"var(--proto-accent)",animation:"cxpulse 1.6s ease-in-out infinite"}})]}),r(e.sessionId,s)]}),e.subCount>0&&o.jsxs("div",{style:{borderTop:"1px solid var(--proto-line-2)",padding:"10px 13px 12px"},children:[o.jsxs("div",{style:{fontSize:10,fontWeight:700,letterSpacing:".07em",color:"var(--proto-muted-3)",marginBottom:7},children:[i.thSubThreads," · ",e.subCount]}),o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:7},children:e.subs.map(d=>o.jsx(Kz,{sub:d,onOpen:()=>n(d)},d.id))})]})]})}function Yz({step:e,index:t,selected:n,select:r,onOpenSub:i,renderChat:s}){return o.jsxs("div",{children:[e.hasConnector&&o.jsx("div",{style:{width:1.5,height:12,background:"var(--proto-line)",marginLeft:20}}),n?o.jsx(Qz,{step:e,onCollapse:()=>r(-1),onOpenSub:i,renderChat:s}):o.jsx(qz,{step:e,onClick:()=>r(t)})]})}function Gz({vm:e,onOpenSub:t,renderStepChat:n}){const r=H(),i=n??((u,f)=>o.jsx(r6,{sessionId:u,live:f})),s=e.steps.findIndex(u=>u.kind==="running"),a=s>=0?s:e.steps.length-1,[l,c]=p.useState(null),d=l??a;return o.jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column"},"data-pipeline":"true",children:[o.jsx("div",{style:{display:"flex",alignItems:"baseline",padding:"0 2px 8px"},children:o.jsx(o6,{children:r.thPipeline})}),e.steps.map((u,f)=>o.jsx(Yz,{step:u,index:f,selected:f===d,select:c,onOpenSub:t,renderChat:i},f))]})}const Xz=o.jsxs("svg",{width:"11",height:"13",viewBox:"0 0 11 13",fill:"none",stroke:"var(--proto-muted-2)",strokeWidth:"1.4",children:[o.jsx("path",{d:"M1 1.5h6l3 3v7H1z"}),o.jsx("path",{d:"M7 1.5v3h3"})]});function Jz({label:e,value:t}){return o.jsxs("div",{style:{display:"flex",gap:8},children:[o.jsx("span",{style:{flex:"none"},children:e}),o.jsx("span",{style:{marginLeft:"auto",color:"var(--proto-ink)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t})]})}function Zz({artifact:e}){const t=H();return o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"10px 14px",borderBottom:"1px solid var(--proto-line-2)",flex:"none"},children:[Xz,o.jsx("span",{style:{minWidth:0,font:"600 11px 'IBM Plex Mono',monospace",color:"var(--proto-ink)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.path??"—"}),e.live&&o.jsx(eB,{label:t.thLive}),o.jsx("span",{style:{marginLeft:"auto",font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-faint)",flex:"none"},children:e.updated})]})}function eB({label:e}){return o.jsxs("span",{style:{fontSize:9.5,fontWeight:600,padding:"1.5px 7px",borderRadius:999,background:"var(--proto-accent-bg)",color:"var(--proto-accent)",flex:"none",whiteSpace:"nowrap"},children:[o.jsx("span",{style:{display:"inline-block",width:5,height:5,borderRadius:"50%",background:"var(--proto-accent)",marginRight:4,animation:"cxpulse 1.6s ease-in-out infinite"}}),e]})}function tB({artifact:e}){const t=H(),n=[e.workspacePath?{label:t.thWorkspace,value:e.workspacePath}:null,e.taskId?{label:t.thTask,value:e.taskId}:null,e.taskProject?{label:t.thProject,value:e.taskProject}:null].filter(r=>r!==null);return o.jsxs(o.Fragment,{children:[o.jsx("div",{style:{fontSize:9,fontWeight:700,letterSpacing:".06em",color:"var(--proto-faint)"},children:t.thReferences}),n.length>0?o.jsx("div",{style:{font:"400 10px 'IBM Plex Mono',monospace",color:"var(--proto-muted)",lineHeight:1.9,marginTop:3},children:n.map(r=>o.jsx(Jz,{...r},r.label))}):o.jsx("div",{style:{fontSize:11.5,color:"var(--proto-muted-2)",marginTop:3},children:"—"})]})}function nB({artifact:e}){var r;const t=H(),n=((r=e.path)==null?void 0:r.split("/").pop())??t.thNoArtifact;return o.jsxs("div",{style:{flex:1,minHeight:0,overflow:"auto",padding:"13px 16px"},children:[o.jsx("div",{style:{fontSize:14,fontWeight:650,color:"var(--proto-ink)",letterSpacing:"-.01em"},children:n}),o.jsxs("div",{style:{font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-muted-2)",marginTop:4},children:[t.thOwner,": ",e.taskId??"—"]}),o.jsx("div",{style:{height:1,background:"var(--proto-line-2)",margin:"10px 0"}}),o.jsx(tB,{artifact:e}),o.jsx("div",{"data-artifact-content":"true",style:{marginTop:12,color:"var(--proto-ink)",fontSize:12.5,lineHeight:1.6,overflowWrap:"anywhere"},children:e.content?o.jsx(Si,{text:e.content}):o.jsx("span",{style:{color:"var(--proto-muted-2)"},children:"—"})})]})}function rB({artifact:e}){const t=H();return e.writtenBy.length===0?null:o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flex:"none",borderTop:"1px solid var(--proto-line-2)",padding:"8px 14px",flexWrap:"wrap"},children:[o.jsx("span",{style:{fontSize:9,fontWeight:700,letterSpacing:".06em",color:"var(--proto-faint)",marginRight:2},children:t.thWrittenBy}),e.writtenBy.map((n,r)=>o.jsx(oB,{writer:n},r))]})}function oB({writer:e}){return o.jsxs("span",{style:{font:`${e.active?500:400} 9.5px 'IBM Plex Mono',monospace`,background:e.active?"var(--proto-accent-bg)":"var(--proto-rail)",border:`1px solid ${e.active?"var(--proto-accent-bg)":"var(--proto-line-2)"}`,color:e.active?"var(--proto-accent)":"var(--proto-muted-2)",padding:"2px 7px",borderRadius:5},children:[e.label,e.active&&" ●"]})}function iB({artifact:e}){const t=H();return o.jsxs("div",{style:{width:440,flex:"none",display:"flex",flexDirection:"column",minHeight:0},children:[o.jsx("div",{style:{display:"flex",alignItems:"baseline",padding:"0 2px 8px"},children:o.jsx("span",{style:{fontSize:10,fontWeight:700,letterSpacing:".07em",color:"var(--proto-muted-3)"},children:t.thArtifact})}),o.jsxs("div",{"data-thread-artifact":"true",style:{flex:1,minHeight:0,background:"var(--proto-card)",border:"1px solid var(--proto-line)",borderRadius:10,boxShadow:"0 1px 2px rgba(16,24,40,.03)",display:"flex",flexDirection:"column",overflow:"hidden"},children:[o.jsx(Zz,{artifact:e}),o.jsx(nB,{artifact:e}),o.jsx(rB,{artifact:e})]})]})}function sB({vm:e}){return o.jsx("span",{style:{fontSize:10.5,fontWeight:600,padding:"2px 8px",borderRadius:999,background:e.pill.bg,color:e.pill.fg},children:e.pill.text})}function aB({onCancel:e,pending:t}){const n=H();return o.jsxs(o.Fragment,{children:[o.jsx("span",{title:"Pause has no backend mutate op yet",style:{fontSize:11.5,fontWeight:600,border:"1px solid var(--proto-line-3)",borderRadius:7,padding:"4px 12px",color:"var(--proto-ink)",background:"var(--proto-card)",cursor:"not-allowed",opacity:.6},children:n.pause}),o.jsx("button",{type:"button",disabled:t,onClick:e,style:{fontSize:11.5,fontWeight:600,fontFamily:"inherit",border:"1px solid var(--proto-danger-bg)",borderRadius:7,padding:"4px 12px",color:"var(--proto-danger)",background:"var(--proto-card)",cursor:t?"default":"pointer",opacity:t?.6:1},children:n.cancel})]})}function lB({vm:e,onClose:t,onCancel:n,cancelPending:r}){return o.jsxs("div",{style:{height:50,flex:"none",borderBottom:"1px solid var(--proto-line)",display:"flex",alignItems:"center",gap:9,padding:"0 20px",background:"var(--proto-card)"},children:[o.jsx("span",{style:{font:"600 12.5px 'IBM Plex Mono',monospace",color:"var(--proto-ink)"},children:e.name}),o.jsx("span",{style:{font:"400 10.5px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)"},children:e.tid}),o.jsx(sB,{vm:e}),o.jsxs("div",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:8},children:[e.live&&o.jsx(aB,{onCancel:n,pending:r}),o.jsx("button",{"data-close-thread-detail":"true",type:"button","aria-label":"Close",onClick:t,style:{border:0,background:"transparent",color:"var(--proto-muted)",cursor:"pointer",fontSize:18,lineHeight:1,padding:4},children:"×"})]})]})}function Dl({label:e,value:t,accent:n}){return o.jsxs("div",{children:[o.jsx("div",{style:{fontSize:9.5,color:"var(--proto-muted-3)",marginBottom:2},children:e}),o.jsx("div",{style:{font:"600 12px 'IBM Plex Mono',monospace",color:n?"var(--proto-accent)":"var(--proto-ink)"},children:t})]})}function cB({vm:e}){const t=H();return o.jsxs("div",{style:{marginLeft:"auto",display:"inline-flex",alignItems:"center",gap:3},children:[o.jsx("span",{style:{font:"500 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)",marginRight:3},children:t.depth}),e.depthDots.map((n,r)=>o.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:n.filled?"var(--proto-accent)":"var(--proto-line)"}},r)),o.jsx("span",{style:{font:"500 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-muted)",marginLeft:3},children:e.depthText})]})}function dB({vm:e}){const t=H();return o.jsxs("div",{style:{flex:"none",background:"var(--proto-card)",borderBottom:"1px solid var(--proto-line)",display:"flex",alignItems:"center",gap:32,padding:"12px 20px 14px"},children:[o.jsx(Dl,{label:t.thTemplate,value:e.template}),o.jsx(Dl,{label:t.thStarted,value:e.started}),o.jsx(Dl,{label:t.thElapsed,value:e.elapsed,accent:!0}),o.jsx(Dl,{label:t.thCostInclChildren,value:e.cost}),o.jsx(Dl,{label:t.thTask,value:e.task,accent:e.task!=="—"}),o.jsx(cB,{vm:e})]})}function uB({vm:e,onOpenThread:t,renderStepChat:n}){const r=i=>t(i.id);return o.jsxs("div",{style:{flex:1,display:"flex",gap:16,padding:"16px 20px",minHeight:0,background:"var(--proto-alt)",overflow:"auto"},children:[o.jsx(Gz,{vm:e,onOpenSub:r,renderStepChat:n}),o.jsx(iB,{artifact:e.artifact})]})}function pB(e){const t=T$(e.detail,e.now);return o.jsxs("div",{"data-thread-detail":t.tid,style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",minHeight:0},children:[o.jsx(lB,{vm:t,onClose:e.onClose,onCancel:e.onCancel,cancelPending:!!e.cancelPending}),o.jsx(dB,{vm:t}),o.jsx(uB,{vm:t,onOpenThread:e.onOpenThread,renderStepChat:e.renderStepChat})]})}const fB=[...av,...lv];function ml(e,t=!1){const n=le(),r=je(),i=t?{threadId:e,includeArtifactContent:!0}:{threadId:e};Ci(fB,()=>{r.invalidateQueries(n.threads.get.queryFilter(i))})}function hB(e,t){return t.type==="open"?t.threadId:null}const s6=p.createContext({openThread:()=>{},closeThread:()=>{}});function gB(e){const[t,n]=p.useState(()=>Date.now());return p.useEffect(()=>{if(!e)return;const r=window.setInterval(()=>n(Date.now()),1e3);return()=>window.clearInterval(r)},[e]),t}function sj({children:e,failed:t}){return o.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",padding:24,color:t?"var(--proto-danger)":"var(--proto-muted-3)",fontSize:12.5},children:e})}const xB={position:"fixed",inset:0,zIndex:70,background:"rgba(25,28,34,.4)",animation:"cxfade .18s ease"},mB={position:"fixed",left:"50%",top:"50%",zIndex:71,transform:"translate(-50%,-50%)",width:"min(1200px,94vw)",height:"min(90vh,900px)",display:"flex",flexDirection:"column",overflow:"hidden",borderRadius:14,border:"1px solid var(--proto-line)",background:"var(--proto-alt)",boxShadow:"0 24px 64px rgba(16,24,40,.3)",outline:"none",animation:"cxmodal .26s cubic-bezier(.22,1,.36,1)"};function vB({threadId:e,onClose:t,children:n}){return o.jsx(po,{open:!0,onOpenChange:r=>{r||t()},children:o.jsxs(fo,{children:[o.jsx(ho,{style:xB}),o.jsxs(go,{"aria-describedby":void 0,"data-thread-detail-modal":e,style:mB,children:[o.jsxs(wi,{className:"sr-only",children:["Thread ",e]}),n]})]})})}function yB({detail:e,loading:t,error:n,now:r,onClose:i,onOpenThread:s,onCancel:a,cancelPending:l}){const c=H();return t?o.jsx(sj,{children:c.rpLoadingThread}):n?o.jsxs(sj,{failed:!0,children:[c.thFailedLoadThread,": ",n]}):e?o.jsx(pB,{detail:e,now:r,onClose:i,onOpenThread:s,onCancel:a,cancelPending:l}):null}function bB({threadId:e,onClose:t,onOpenThread:n}){var d;const r=le(),i=je(),s=Y(r.threads.get.queryOptions({threadId:e,includeArtifactContent:!0}));ml(e,!0);const a=s.data?["running","waiting"].includes(s.data.status):!1,l=gB(a),c=xe(r.threads.cancel.mutationOptions({onSettled:()=>{i.invalidateQueries(r.threads.list.queryFilter()),i.invalidateQueries(r.threads.get.queryFilter({threadId:e,includeArtifactContent:!0}))},onSuccess:t}));return o.jsx(vB,{threadId:e,onClose:t,children:o.jsx(yB,{detail:s.data,loading:s.isPending,error:((d=s.error)==null?void 0:d.message)??null,now:l,onClose:t,onOpenThread:n,onCancel:()=>c.mutate({threadId:e}),cancelPending:c.isPending})})}function jB({children:e}){const[t,n]=p.useReducer(hB,null),r=s=>n({type:"open",threadId:s}),i=()=>n({type:"close"});return o.jsxs(s6.Provider,{value:{openThread:r,closeThread:i},children:[e,t&&o.jsx(bB,{threadId:t,onClose:i,onOpenThread:r})]})}function uv(){return p.useContext(s6)}function pv(...e){return e.filter(t=>typeof t=="string"&&t.length>0)}function wB(e){return{id:`session:${e.sessionId}`,glyph:"SE",label:e.name||e.sessionId,sub:e.projectId,kbd:"session",route:"/workbench",focusId:e.sessionId,keywords:pv(e.sessionId,e.name,e.label,e.projectId,e.backend,e.kind)}}function kB(e){return{id:`thread:${e.id}`,glyph:"TH",label:e.templateName,sub:e.id,kbd:"thread",modal:"thread",focusId:e.id,keywords:pv(e.id,e.templateName,e.status,e.projectId)}}function SB(e){return{id:`task:${e.id}`,glyph:"TK",label:e.text,sub:`${e.id} · ${e.project}`,kbd:"task",route:"/tasks",focusId:e.id,keywords:pv(e.id,e.text,e.project,e.status,e.priority)}}function CB({sessions:e,threads:t,tasks:n}){return[...e.map(wB),...t.map(kB),...n.map(SB)]}const EB=[{id:"nav:overview",glyph:"OV",label:"Overview",labelKey:"overview",sub:"project dashboard",subKey:"cpSubOverview",kbd:"page",route:"/overview",keywords:["dashboard"]},{id:"nav:workbench",glyph:"WB",label:"Workbench",labelKey:"workbench",sub:"session chat",subKey:"cpSubWorkbench",kbd:"page",route:"/workbench",keywords:["home","chat"]},{id:"nav:tasks",glyph:"TK",label:"Tasks",labelKey:"tasks",sub:"task queue",subKey:"cpSubTasks",kbd:"page",route:"/tasks",keywords:["queue"]},{id:"nav:threads",glyph:"TH",label:"Threads",labelKey:"threads",sub:"thread runs",subKey:"cpSubThreads",kbd:"page",route:"/threads",keywords:["runs"]},{id:"nav:settings",glyph:"ST",label:"Settings",labelKey:"settings",sub:"platform · profiles · budget · machines…",subKey:"cpSubSettings",kbd:"modal",modal:"settings",keywords:["config"]}];function TB(e){return{id:e.id,glyph:e.glyph,label:e.label,sub:e.sub,kbd:e.kbd,...e.route?{route:e.route}:{},...e.modal?{modal:e.modal}:{},keywords:e.keywords,labelKey:e.labelKey,subKey:e.subKey}}function PB(e,t,n={}){const r=n.restPerKind??5,i=n.matchCap??50,s=EB.map(TB),a=CB(t),l=e.trim().toLowerCase();if(!l){const d=u=>a.filter(f=>f.glyph===u).slice(0,r);return[...s,...d("SE"),...d("TH"),...d("TK")]}const c=d=>(d.label+" "+d.sub+" "+d.keywords.join(" ")).toLowerCase().includes(l);return[...s,...a].filter(c).slice(0,i)}const RB={display:"flex",alignItems:"center",gap:10,padding:"12px 16px",borderBottom:"1px solid var(--proto-line-2)"},IB={flex:1,fontSize:13.5,color:"var(--proto-ink)",fontFamily:"inherit"},MB={font:"500 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)",border:"1px solid var(--proto-line)",borderRadius:5,padding:"2px 6px",cursor:"pointer"},LB={padding:6,maxHeight:384,overflowY:"auto"},OB={display:"flex",alignItems:"center",gap:10,padding:"8px 11px",borderRadius:8,cursor:"pointer"},AB={width:20,height:20,borderRadius:6,background:"var(--proto-gray)",display:"flex",alignItems:"center",justifyContent:"center",font:"600 9px 'IBM Plex Mono',monospace",color:"var(--proto-muted)",flex:"none"},DB={fontSize:10.5,color:"var(--proto-muted-3)",whiteSpace:"nowrap",flex:"none"},NB={marginLeft:"auto",font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-faint)",flex:"none",paddingLeft:10},_B={display:"flex",alignItems:"center",padding:"7px 16px",borderTop:"1px solid var(--proto-alt)",background:"var(--proto-rail)"},$B={font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-faint)"},FB={padding:"18px 11px",textAlign:"center",fontSize:12.5,color:"var(--proto-muted-3)"};function zB({row:e,onSelect:t}){const n=H(),r=e.labelKey?n[e.labelKey]:e.label,i=e.subKey?n[e.subKey]:e.sub;return o.jsxs(Nc.Item,{value:e.id,onSelect:t,className:"cmdk-row",style:OB,children:[o.jsx("span",{style:AB,children:e.glyph}),o.jsx("span",{className:"cmdk-row-label",children:r}),o.jsx("span",{style:DB,children:i}),o.jsx("span",{style:NB,children:e.kbd})]})}const zh=3e4;function BB(e,t){const n=le(),r=Y(n.sessions.list.queryOptions({},{enabled:e,staleTime:zh})),i=Y(n.threads.list.queryOptions({},{enabled:e,staleTime:zh})),s=Y(n.tasks.list.queryOptions({},{enabled:e,staleTime:zh}));return p.useMemo(()=>PB(t,{sessions:r.data??[],threads:i.data??[],tasks:s.data??[]}),[t,r.data,i.data,s.data])}function WB(e){const t=ze(),{open:n}=aC(),{openThread:r}=uv();return i=>{if(e(!1),i.modal==="settings")return n();if(i.modal==="thread"&&i.focusId)return r(i.focusId);i.route&&t(i.route,i.focusId?{state:{focusId:i.focusId}}:void 0)}}function UB({query:e,setQuery:t,close:n}){const r=H();return o.jsxs("div",{style:RB,children:[o.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 12 12",fill:"none",stroke:"var(--proto-muted-3)",strokeWidth:"1.5",children:[o.jsx("circle",{cx:"5",cy:"5",r:"3.8"}),o.jsx("path",{d:"M8 8l2.6 2.6"})]}),o.jsx(Nc.Input,{autoFocus:!0,value:e,onValueChange:t,placeholder:r.cmdkPh,style:IB}),o.jsx("span",{style:MB,onClick:n,children:"esc"})]})}function HB({rows:e,go:t}){const n=H();return o.jsxs(Nc.List,{style:LB,children:[o.jsx(Nc.Empty,{style:FB,children:n.cpNoResults}),e.map(r=>o.jsx(zB,{row:r,onSelect:()=>t(r)},r.id))]})}function VB({open:e,onOpenChange:t}){const n=H(),[r,i]=p.useState("");p.useEffect(()=>{e&&i("")},[e]);const s=BB(e,r),a=WB(t);return o.jsxs(Nc.Dialog,{open:e,onOpenChange:t,label:"Command palette",shouldFilter:!1,loop:!0,overlayClassName:"cmdk-backdrop",contentClassName:"cmdk-panel",children:[o.jsx(UB,{query:r,setQuery:i,close:()=>t(!1)}),o.jsx(HB,{rows:s,go:a}),o.jsx("div",{style:_B,children:o.jsx("span",{style:$B,children:n.cpFooterHint})})]})}function qB(){const[e,t]=p.useState(!1);return p.useEffect(()=>{function n(r){r.key.toLowerCase()==="k"&&(r.metaKey||r.ctrlKey)&&(r.preventDefault(),t(i=>!i))}return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[]),{open:e,setOpen:t}}const KB={flex:"none",display:"flex",alignItems:"center",gap:9,padding:"13px 18px",borderBottom:"1px solid #2A2F3A"},QB={fontSize:9,fontWeight:600,padding:"1.5px 7px",borderRadius:999,background:"#2A2F3A",color:"var(--proto-accent-2)"},YB={flex:1,overflow:"auto",minHeight:0,padding:"13px 18px",font:"400 10.5px/2 'IBM Plex Mono',monospace"},GB={flex:"none",display:"flex",alignItems:"center",gap:10,padding:"11px 18px",borderTop:"1px solid #2A2F3A"};function XB({title:e,pill:t,meta:n,now:r,lines:i,dropped:s,notice:a,killDisabled:l,onKill:c,onClose:d,scrollRef:u,onScroll:f}){const h=H();return o.jsxs(o.Fragment,{children:[o.jsxs("div",{style:KB,children:[o.jsx("span",{style:{font:"600 12px 'IBM Plex Mono',monospace",color:"var(--proto-line)"},children:e}),t?o.jsx("span",{style:QB,children:t}):null,o.jsx("span",{style:{marginLeft:"auto",font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-muted)"},children:n}),o.jsx("span",{onClick:d,"aria-label":"Close",role:"button",tabIndex:0,style:{color:"var(--proto-muted-2)",fontSize:13,cursor:"pointer",padding:"2px 4px"},children:"✕"})]}),o.jsxs("div",{ref:u,onScroll:f,"data-execution-log":!0,style:YB,children:[a?o.jsx("div",{style:{color:"var(--proto-muted)"},children:a}):null,s>0?o.jsxs("div",{style:{color:"var(--proto-amber)"},children:["… ",s," ",h.exLinesDropped]}):null,i.map((g,v)=>o.jsx("div",{style:{color:"var(--proto-accent-bg)",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:g},v)),o.jsx("div",{children:o.jsx("span",{style:{color:"var(--proto-muted)"},children:r})})]}),o.jsxs("div",{style:GB,children:[o.jsx("span",{style:{font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-muted)"},children:h.exFooterHeartbeat}),o.jsx("button",{type:"button",onClick:c,disabled:l,"data-action":"kill-run",style:{marginLeft:"auto",fontSize:11,fontWeight:600,color:"#E88",border:"1px solid var(--proto-danger)",borderRadius:7,padding:"4px 12px",cursor:l?"default":"pointer",background:"transparent"},children:h.exKillRun})]})]})}const aj={lines:[],dropped:0,lastSeq:null};function JB(e,t,n){if(e.lastSeq!==null&&t.seq<=e.lastSeq)return e;let r=e.dropped+(t.dropped??0),i=t.lines.length>0?[...e.lines,...t.lines]:e.lines;return i.length>n&&(r+=i.length-n,i=i.slice(i.length-n)),{lines:i,dropped:r,lastSeq:t.seq}}const ZB=2e3;function eW(e,t){const n=Qp(),[r,i]=p.useState(aj);return p.useEffect(()=>{if(!t)return;i(aj);const s=n.executions.log.subscribe({executionId:e},{onData:a=>{const l=a.payload;if(!l||!Array.isArray(l.lines))return;const c={lines:l.lines,seq:typeof l.seq=="number"?l.seq:0,dropped:typeof l.dropped=="number"?l.dropped:void 0};i(d=>JB(d,c,ZB))}});return()=>s.unsubscribe()},[n,e,t]),r}const ac=e=>e<10?`0${e}`:`${e}`;function tW(e){switch(e){case"running":return"● running";case"completed":return"✓ done";case"failed":return"✕ failed";case"cancelled":return"✕ cancelled";case"stale":return"◦ stale";default:return e}}function nW(e){if(!e)return"";const t=new Date(e);return`${ac(t.getUTCHours())}:${ac(t.getUTCMinutes())}`}function rW(e){const t=e.runtime.endedAt??e.runtime.updatedAt,n=new Date(t);return`${ac(n.getUTCHours())}:${ac(n.getUTCMinutes())}:${ac(n.getUTCSeconds())}`}function oW(e){var r,i;const t=e.runtime.endedAt;return[((r=e.dispatch)==null?void 0:r.machine)??null,((i=e.dispatch)==null?void 0:i.taskId)??null,t?`finished ${nW(t)}`:"running"].filter(s=>s!=null&&s!=="").join(" · ")}function iW(e){return e==="running"}function sW(e){var t;return((t=e.dispatch)==null?void 0:t.runName)!=null}const aW={position:"fixed",top:0,right:0,bottom:0,width:480,background:"var(--proto-ink)",zIndex:61,display:"flex",flexDirection:"column",boxShadow:"-16px 0 48px rgba(16,24,40,.3)"},lW={position:"fixed",inset:0,background:"rgba(25,28,34,.34)",zIndex:60},cW={position:"absolute",width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0 0 0 0)",whiteSpace:"nowrap",border:0};function dW({executionId:e,onClose:t}){const n=H(),r=e!=null;return o.jsx(po,{open:r,onOpenChange:i=>{i||t()},children:o.jsxs(fo,{children:[o.jsx(ho,{style:lW,className:"animate-cxfade motion-reduce:animate-none"}),o.jsxs(go,{"aria-describedby":void 0,style:aW,className:"animate-cxdrawer focus:outline-none motion-reduce:animate-none",children:[o.jsx(wi,{style:cW,children:e?`${n.exLogTitle} ${e}`:n.exLogTitle}),r?o.jsx(uW,{executionId:e,onClose:t}):null]})]})})}function uW({executionId:e,onClose:t}){const n=le(),r=H(),i=je(),{toast:s}=dr(),l=Y(n.executions.get.queryOptions({executionId:e},{refetchInterval:j=>{var y;return((y=j.state.data)==null?void 0:y.status)==="running"?3e3:!1}})).data,c=l?sW(l):!1,d=eW(e,c),u=xe(n.executions.cancel.mutationOptions({onSettled:()=>i.invalidateQueries(n.executions.get.queryFilter({executionId:e}))})),f=()=>{if(!l||!iW(l.status)){s({title:`${e} ${r.exAlreadyFinished}`,tone:"cancelled"});return}u.mutate({executionId:e},{onSuccess:j=>{j.cancelled&&s({title:`${e} ${r.exKilled}`,tone:"failed"})}})},h=p.useRef(null),g=p.useRef(!0);p.useEffect(()=>{const j=h.current;j&&g.current&&(j.scrollTop=j.scrollHeight)},[d.lines,d.dropped]);const v=()=>{const j=h.current;j&&(g.current=j.scrollHeight-j.scrollTop-j.clientHeight<24)},x=(l==null?void 0:l.status)==="running",b=d.lines.length>0?null:c?x?r.exWaitingOutput:r.exNoLogOutput:x?r.exWaitingOutput:r.exNoLiveLog;return o.jsx(XB,{title:(l==null?void 0:l.id)??e,pill:l?tW(l.status):null,meta:l?oW(l):"",now:l?rW(l):"",lines:d.lines,dropped:d.dropped,notice:b,killDisabled:u.isPending,onKill:f,onClose:t,scrollRef:h,onScroll:v})}const a6=p.createContext(null);function pW({children:e}){const[t,n]=p.useState(null),r=p.useCallback(a=>n(a),[]),i=p.useCallback(()=>n(null),[]),s=p.useMemo(()=>({open:r,close:i}),[r,i]);return o.jsxs(a6.Provider,{value:s,children:[e,o.jsx(dW,{executionId:t,onClose:i})]})}function l6(){const e=p.useContext(a6);if(!e)throw new Error("useExecutionLogDrawer must be used within an ExecutionLogDrawerProvider");return e}const lj=["interval","daily","weekly","once"],cj=["min","hr"],fW=["fresh","skip","wait"],hW=["current-channel","fresh","project"],gW=[{value:0,label:"Sun"},{value:1,label:"Mon"},{value:2,label:"Tue"},{value:3,label:"Wed"},{value:4,label:"Thu"},{value:5,label:"Fri"},{value:6,label:"Sat"}];function xW(e,t){const n=[];for(const r of e??[])n.includes(r)||n.push(r);return t&&!n.includes(t)&&n.push(t),n}function mW(e){return{type:"daily",message:"",profile:"claude-haiku",time:"09:00",dayOfWeek:1,intervalValue:30,intervalUnit:"min",delayValue:10,delayUnit:"min",target:"current-channel",fallback:"fresh",projectId:e}}function vW(e){return{time:e==="daily"||e==="weekly",interval:e==="interval",dayOfWeek:e==="weekly",delay:e==="once"}}function Cp(e,t){return t==="hr"?e*36e5:e*6e4}const yW=/^\d{2}:\d{2}$/;function bW(e,t){if(e==="fresh")return{kind:"fresh"};if(e==="project")return{kind:"project",projectId:t??"general"}}function jW(e){const t={type:e.type,message:e.message.trim(),fallback:e.fallback};e.projectId&&(t.projectId=e.projectId),e.profile&&(t.profile=e.profile),e.type==="interval"&&(t.intervalMs=Cp(e.intervalValue,e.intervalUnit)),(e.type==="daily"||e.type==="weekly")&&(t.time=e.time),e.type==="weekly"&&(t.dayOfWeek=e.dayOfWeek),e.type==="once"&&(t.delay=Cp(e.delayValue,e.delayUnit));const n=bW(e.target,e.projectId);return n&&(t.target=n),t}function dj(e){const t=[];return e.message.trim().length===0&&t.push("message is required"),e.type==="interval"&&!(e.intervalValue>0)&&t.push("interval must be > 0"),(e.type==="daily"||e.type==="weekly")&&!yW.test(e.time)&&t.push("time must be HH:MM"),e.type==="weekly"&&!(e.dayOfWeek>=0&&e.dayOfWeek<=6)&&t.push("dayOfWeek must be 0..6"),e.type==="once"&&!(e.delayValue>0)&&t.push("delay must be > 0"),{ok:t.length===0,errors:t}}function wW(e,t){if(e.type==="interval")return new Date(t.getTime()+Cp(e.intervalValue,e.intervalUnit));if(e.type==="once")return new Date(t.getTime()+Cp(e.delayValue,e.delayUnit));const[n,r]=e.time.split(":").map(a=>parseInt(a,10)),i=new Date(t);if(i.setHours(n,r,0,0),e.type==="daily")return i.getTime()<=t.getTime()&&i.setDate(i.getDate()+1),i;let s=(e.dayOfWeek-t.getDay()+7)%7;return s===0&&i.getTime()<=t.getTime()&&(s=7),i.setDate(i.getDate()+s),i}function uj(e){return String(e).padStart(2,"0")}function kW(e){const t=Math.max(0,Math.round(e/6e4));if(t<60)return`${t}m`;const n=Math.floor(t/60),r=t%60;return n<24?r===0?`${n}h`:`${n}h ${r}m`:`${Math.floor(n/24)}d`}function SW(e,t){const n=wW(e,t);return{clock:`${uj(n.getHours())}:${uj(n.getMinutes())}`,delta:kW(n.getTime()-t.getTime())}}const Br={fontSize:9.5,fontWeight:700,letterSpacing:".05em",color:"var(--proto-muted-3)"},Ai={display:"flex",alignItems:"center",border:"1px solid var(--proto-line)",borderRadius:8,padding:"7px 10px"},Fs={marginLeft:"auto",color:"var(--proto-muted-3)",fontSize:8};function zs(e){return{flex:1,minWidth:0,border:"none",outline:"none",background:"transparent",appearance:"none",WebkitAppearance:"none",MozAppearance:"none",cursor:"pointer",font:e,color:"var(--proto-ink)"}}function CW({form:e,onChange:t,onCancel:n,onCreate:r,valid:i,pending:s,profileOptions:a,now:l}){const c=H();p.useEffect(()=>{const b=j=>{j.key==="Escape"&&n()};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[n]);const d={interval:c.scTypeInterval,daily:c.scTypeDaily,weekly:c.scTypeWeekly,once:c.scTypeOnce},u={0:c.scDaySun,1:c.scDayMon,2:c.scDayTue,3:c.scDayWed,4:c.scDayThu,5:c.scDayFri,6:c.scDaySat},f=vW(e.type),{clock:h,delta:g}=SW(e,l??new Date),v=i&&!s,x=f.dayOfWeek?"130px 130px 1fr":"130px 1fr";return o.jsxs(o.Fragment,{children:[o.jsx("div",{onClick:n,style:{position:"fixed",inset:0,background:"rgba(25,28,34,.34)",zIndex:60,animation:"cxfade .18s ease"}}),o.jsxs("div",{"data-schedule-modal":!0,"data-sched-type":e.type,style:{position:"fixed",left:"50%",top:"50%",transform:"translate(-50%,-50%)",animation:"cxmodal .26s cubic-bezier(.22,1,.36,1)",width:560,background:"var(--proto-card)",borderRadius:14,boxShadow:"0 24px 64px rgba(16,24,40,.3)",zIndex:61,overflow:"hidden"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"14px 20px 0"},children:[o.jsx("span",{style:{fontSize:14,fontWeight:700,color:"var(--proto-ink)"},children:c.scNewSchedule}),o.jsx("span",{onClick:n,style:{marginLeft:"auto",font:"500 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)",border:"1px solid var(--proto-line)",borderRadius:5,padding:"2px 6px",cursor:"pointer"},children:"esc"})]}),o.jsxs("div",{style:{padding:"0 20px"},children:[o.jsx("div",{style:{...Br,margin:"13px 0 5px"},children:c.scType}),o.jsx("div",{style:{display:"flex",border:"1px solid var(--proto-line)",borderRadius:8,overflow:"hidden"},children:lj.map((b,j)=>{const y=e.type===b;return o.jsx("span",{"data-sched-type-opt":b,"aria-pressed":y,onClick:()=>t({type:b}),style:{flex:1,textAlign:"center",padding:"6px 0",fontSize:11.5,fontWeight:600,color:y?"var(--proto-accent)":"var(--proto-muted-2)",background:y?"var(--proto-accent-bg)":void 0,borderRight:j<lj.length-1?"1px solid var(--proto-line)":void 0,cursor:"pointer"},children:d[b]},b)})}),o.jsxs("div",{style:{display:"grid",gridTemplateColumns:x,gap:12,marginTop:12},children:[o.jsxs("div",{children:[f.time&&o.jsxs(o.Fragment,{children:[o.jsx("div",{style:{...Br,marginBottom:5},children:c.scTime}),o.jsxs("div",{style:Ai,children:[o.jsx("input",{value:e.time,onChange:b=>t({time:b.target.value}),placeholder:"09:00",style:{flex:1,minWidth:0,border:"none",outline:"none",background:"transparent",font:"600 12px 'IBM Plex Mono',monospace",color:"var(--proto-ink)"}}),o.jsx("span",{style:{marginLeft:"auto",font:"400 9px 'IBM Plex Mono',monospace",color:"var(--proto-faint)"},children:"24h"})]})]}),f.interval&&o.jsxs(o.Fragment,{children:[o.jsx("div",{style:{...Br,marginBottom:5},children:c.scEvery}),o.jsxs("div",{style:Ai,children:[o.jsx("input",{type:"number",min:1,value:e.intervalValue,onChange:b=>t({intervalValue:Number(b.target.value)}),style:{width:44,border:"none",outline:"none",background:"transparent",font:"600 12px 'IBM Plex Mono',monospace",color:"var(--proto-ink)"}}),o.jsx("select",{value:e.intervalUnit,onChange:b=>t({intervalUnit:b.target.value}),style:zs("400 10px 'IBM Plex Mono',monospace"),children:cj.map(b=>o.jsx("option",{value:b,children:b},b))}),o.jsx("span",{style:Fs,children:"▾"})]})]}),f.delay&&o.jsxs(o.Fragment,{children:[o.jsx("div",{style:{...Br,marginBottom:5},children:c.scIn}),o.jsxs("div",{style:Ai,children:[o.jsx("input",{type:"number",min:1,value:e.delayValue,onChange:b=>t({delayValue:Number(b.target.value)}),style:{width:44,border:"none",outline:"none",background:"transparent",font:"600 12px 'IBM Plex Mono',monospace",color:"var(--proto-ink)"}}),o.jsx("select",{value:e.delayUnit,onChange:b=>t({delayUnit:b.target.value}),style:zs("400 10px 'IBM Plex Mono',monospace"),children:cj.map(b=>o.jsx("option",{value:b,children:b},b))}),o.jsx("span",{style:Fs,children:"▾"})]})]})]}),f.dayOfWeek&&o.jsxs("div",{children:[o.jsx("div",{style:{...Br,marginBottom:5},children:c.scDay}),o.jsxs("div",{style:Ai,children:[o.jsx("select",{value:e.dayOfWeek,onChange:b=>t({dayOfWeek:Number(b.target.value)}),style:zs("500 11.5px 'IBM Plex Mono',monospace"),children:gW.map(b=>o.jsx("option",{value:b.value,children:u[b.value]??b.label},b.value))}),o.jsx("span",{style:Fs,children:"▾"})]})]}),o.jsxs("div",{children:[o.jsx("div",{style:{...Br,marginBottom:5},children:c.scProfile}),o.jsxs("div",{style:Ai,children:[o.jsx("select",{value:e.profile,onChange:b=>t({profile:b.target.value}),style:zs("500 11.5px 'IBM Plex Mono',monospace"),children:a.map(b=>o.jsx("option",{value:b,children:b},b))}),o.jsx("span",{style:Fs,children:"▾"})]})]})]}),o.jsx("div",{style:{...Br,margin:"12px 0 5px"},children:c.scMessage}),o.jsx("div",{style:{border:"1px solid var(--proto-line)",borderRadius:8,padding:"8px 11px",minHeight:38},children:o.jsx("textarea",{value:e.message,onChange:b=>t({message:b.target.value}),placeholder:c.scMessagePh,rows:2,style:{width:"100%",border:"none",outline:"none",resize:"none",background:"transparent",fontSize:11.5,lineHeight:1.55,color:"var(--proto-ink-2)",fontFamily:"inherit"}})}),o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12,marginTop:12},children:[o.jsxs("div",{children:[o.jsx("div",{style:{...Br,marginBottom:5},children:c.scTarget}),o.jsxs("div",{style:Ai,children:[o.jsx("select",{value:e.target,onChange:b=>t({target:b.target.value}),style:zs("11.5px system-ui, sans-serif"),children:hW.map(b=>o.jsx("option",{value:b,children:b},b))}),o.jsx("span",{style:Fs,children:"▾"})]})]}),o.jsxs("div",{children:[o.jsx("div",{style:{...Br,marginBottom:5},children:c.scFallback}),o.jsxs("div",{style:Ai,children:[o.jsx("select",{value:e.fallback,onChange:b=>t({fallback:b.target.value}),style:zs("11.5px system-ui, sans-serif"),children:fW.map(b=>o.jsx("option",{value:b,children:b},b))}),o.jsx("span",{style:Fs,children:"▾"})]})]})]})]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"16px 20px 16px"},children:[o.jsxs("span",{style:{font:"500 10px 'IBM Plex Mono',monospace",color:"var(--proto-muted)"},children:[c.scNextRun," ",o.jsx("b",{style:{color:"var(--proto-accent)"},children:h})," · ",c.scFooterIn," ",g]}),o.jsx("span",{onClick:n,style:{marginLeft:"auto",fontSize:11.5,fontWeight:600,border:"1px solid var(--proto-line-3)",borderRadius:8,padding:"6px 13px",color:"var(--proto-ink)",cursor:"pointer"},children:c.cancel}),o.jsx("span",{"data-action":"create-schedule",onClick:()=>v&&r(),style:{fontSize:11.5,fontWeight:600,borderRadius:8,padding:"7px 15px",color:"var(--ink-solid-fg)",background:"var(--proto-accent)",cursor:v?"pointer":"not-allowed",opacity:v?1:.55},children:c.scCreateSchedule})]})]})]})}const c6=p.createContext(null);function EW({children:e}){var x,b;const t=H(),n=le(),r=je(),{toast:i}=dr(),[s,a]=p.useState(null),c=(b=(x=Y(n.config.get.queryOptions({})).data)==null?void 0:x.profiles)==null?void 0:b.profiles.map(j=>j.name),d=p.useCallback(()=>a(null),[]),u=p.useCallback(j=>{a(mW((j==null?void 0:j.projectId)??null))},[]),f=xe(n.schedules.add.mutationOptions({onSuccess:()=>{r.invalidateQueries(n.schedules.list.queryFilter()),i({title:t.scToastCreated,tone:"done"}),d()},onError:j=>{i({title:t.scToastCreateFailed,description:j.message,tone:"failed"})}})),h=p.useCallback(j=>{a(y=>y&&{...y,...j})},[]),g=p.useCallback(()=>{a(j=>(j&&dj(j).ok&&f.mutate(jW(j)),j))},[f]),v=p.useMemo(()=>({open:u,close:d}),[u,d]);return o.jsxs(c6.Provider,{value:v,children:[e,s&&o.jsx(CW,{form:s,onChange:h,onCancel:d,onCreate:g,valid:dj(s).ok,pending:f.isPending,profileOptions:xW(c,s.profile)})]})}function TW(){const e=p.useContext(c6);if(!e)throw new Error("useScheduleModal must be used within a ScheduleModalProvider");return e}const Bh="—";function PW(e){switch(e){case"pending":return{text:"● pending",bg:"#F7ECCE",fg:"#8A5B06"};case"approved":return{text:"✓ approved",bg:"#E9F4EE",fg:"#23854F"};case"rejected":return{text:"✕ rejected",bg:"#FBEDEB",fg:"#C03D33"};case"failed":return{text:"failed",bg:"#FBEDEB",fg:"#C03D33"}}}function RW(e){return`${e} ${e===1?"approval pending":"approvals pending"}`}function IW(e){return{id:e.id,title:e.title,age:e.queuedAt,origin:e.provenance,project:e.projectId}}function MW(e){const t=e.command;return{id:e.id,title:e.title,project:e.projectId,pill:PW(e.status),queued:e.queuedAt?`queued ${e.queuedAt}`:null,operation:e.operation??Bh,reason:e.reason??Bh,impact:e.impact??Bh,command:t,hasCommand:t!=null&&t.trim()!=="",feedback:e.feedback,origin:e.provenance,task:e.taskRef}}function LW(e,t){var n;return t&&e.some(r=>r.id===t)?t:((n=e[0])==null?void 0:n.id)??null}const ai="'IBM Plex Mono',monospace";function OW(e){const t=H(),{entries:n,selectedId:r,armed:i,feedback:s,pending:a}=e,l=n.length,c=l>0,d=n.find(f=>f.id===r)??n[0]??null,u=d?MW(d):null;return o.jsxs(o.Fragment,{children:[o.jsx("div",{onClick:e.onClose,style:{position:"fixed",inset:0,background:"rgba(25,28,34,.34)",zIndex:60,animation:"cxfade .18s ease"}}),o.jsxs("div",{"data-approval-center":"","data-approval-selected":(d==null?void 0:d.id)??"",style:{position:"fixed",left:"50%",top:"50%",transform:"translate(-50%,-50%)",animation:"cxmodal .26s cubic-bezier(.22,1,.36,1)",width:1120,maxWidth:"94vw",height:700,maxHeight:"90vh",background:"var(--proto-card)",borderRadius:14,boxShadow:"0 24px 64px rgba(16,24,40,.3)",zIndex:61,overflow:"hidden",display:"flex",flexDirection:"column"},children:[o.jsxs("div",{style:{flex:"none",display:"flex",alignItems:"center",gap:9,padding:"12px 20px",borderBottom:"1px solid var(--proto-line)"},children:[o.jsx("span",{style:{fontSize:13,fontWeight:650,color:"var(--proto-ink)"},children:t.approvals}),c&&o.jsxs("span",{style:{display:"flex",alignItems:"center",gap:6,background:"var(--proto-amber-bg)",border:"1px solid var(--proto-amber-border)",borderRadius:999,padding:"3px 10px",marginLeft:4},children:[o.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:"var(--proto-amber)",animation:"cxpulse 2s ease-in-out infinite"}}),o.jsx("span",{style:{fontSize:10.5,fontWeight:600,color:"var(--proto-amber-fg)"},children:RW(l)})]}),o.jsx("span",{style:{marginLeft:"auto",font:`400 10px ${ai}`,color:"var(--proto-muted-3)"},children:"~/.cortex/context/PENDING_APPROVALS.md"}),o.jsx("span",{onClick:e.onClose,style:{font:`500 9.5px ${ai}`,color:"var(--proto-muted-3)",border:"1px solid var(--proto-line)",borderRadius:5,padding:"2px 6px",cursor:"pointer"},children:"esc"})]}),o.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden",minHeight:0},children:[!c&&o.jsx(AW,{}),c&&o.jsxs(o.Fragment,{children:[o.jsx(DW,{entries:n,selectedId:(d==null?void 0:d.id)??null,count:l,onSelect:e.onSelect}),u&&o.jsx(NW,{detail:u,armed:i,feedback:s,pending:a,onArm:e.onArm,onCancel:e.onCancel,onApprove:e.onApprove,onReject:e.onReject,onFeedback:e.onFeedback})]})]})]})]})}function AW(){const e=H();return o.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:9,background:"var(--proto-rail)"},children:[o.jsx("span",{style:{width:34,height:34,borderRadius:"50%",background:"var(--proto-success-bg)",color:"var(--proto-success)",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:15,fontWeight:700},children:"✓"}),o.jsx("div",{style:{fontSize:13,fontWeight:600,color:"var(--proto-ink)"},children:e.aprEmptyTitle}),o.jsx("div",{style:{fontSize:11,color:"var(--proto-muted-2)"},children:e.aprEmptyDesc})]})}function DW({entries:e,selectedId:t,count:n,onSelect:r}){const i=H();return o.jsxs("div",{style:{width:370,flex:"none",borderRight:"1px solid var(--proto-line)",background:"var(--proto-rail)",display:"flex",flexDirection:"column",overflow:"auto"},children:[o.jsxs("div",{style:{padding:"13px 16px 8px",fontSize:10,fontWeight:700,letterSpacing:".06em",color:"var(--proto-muted-3)"},children:[i.apPending," · ",n]}),o.jsx("div",{style:{padding:"0 12px 12px",display:"flex",flexDirection:"column",gap:8},children:e.map(s=>{const a=IW(s),l=s.id===t;return o.jsx("div",{"data-approval-id":s.id,onClick:()=>r(s.id),style:{background:"var(--proto-card)",border:`1px solid ${l?"var(--proto-accent-border)":"var(--proto-line-2)"}`,borderRadius:10,padding:"10px 12px",boxShadow:l?"0 1px 3px rgba(70,85,212,.08)":"none",cursor:"pointer"},children:o.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:9},children:[o.jsx("span",{style:{width:7,height:7,borderRadius:"50%",background:"var(--proto-amber)",flex:"none",marginTop:5,animation:l?"cxpulse 2s ease-in-out infinite":"none"}}),o.jsxs("div",{style:{minWidth:0,flex:1},children:[o.jsx("div",{style:{fontSize:12,fontWeight:600,color:l?"var(--proto-ink)":"var(--proto-ink-2)",lineHeight:1.4},children:a.title}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,marginTop:6,flexWrap:"wrap"},children:[a.project&&o.jsx("span",{style:{font:`600 9px ${ai}`,color:"var(--proto-muted-3)"},children:a.project}),a.origin&&o.jsx("span",{style:{font:`400 9px ${ai}`,color:"var(--proto-muted-3)"},children:a.origin}),a.age&&o.jsx("span",{style:{marginLeft:"auto",font:`400 9px ${ai}`,color:"var(--proto-faint)"},children:a.age})]})]})]})},s.id)})})]})}const Wh={fontSize:10,fontWeight:700,letterSpacing:".05em",color:"var(--proto-muted-3)",paddingTop:2};function NW({detail:e,armed:t,feedback:n,pending:r,onArm:i,onCancel:s,onApprove:a,onReject:l,onFeedback:c}){const d=H();return o.jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",overflow:"hidden"},children:[o.jsxs("div",{style:{flex:1,overflow:"auto",minHeight:0,padding:"16px 22px 0"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:12},children:[o.jsx("div",{style:{fontSize:15.5,fontWeight:650,color:"var(--proto-ink)",lineHeight:1.35,flex:1},children:e.title}),o.jsx("span",{style:{fontSize:10,fontWeight:600,padding:"2px 9px",borderRadius:999,background:e.pill.bg,color:e.pill.fg,flex:"none",marginTop:2},children:e.pill.text})]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:14,marginTop:8,font:`400 10px ${ai}`,color:"var(--proto-muted-3)",flexWrap:"wrap"},children:[e.queued&&o.jsx("span",{children:e.queued}),e.project&&o.jsxs("span",{children:[d.apProject," ",o.jsx("span",{style:{color:"var(--proto-accent)"},children:e.project})]}),e.origin&&o.jsxs("span",{children:[d.apFrom," ",o.jsx("span",{style:{color:"var(--proto-accent)"},children:e.origin})]}),e.task&&o.jsxs("span",{children:[d.apTask," ",o.jsx("span",{style:{color:"var(--proto-accent)"},children:e.task})]})]}),o.jsxs("div",{style:{marginTop:14,display:"grid",gridTemplateColumns:"76px 1fr",rowGap:9,columnGap:14,fontSize:12,lineHeight:1.55},children:[o.jsx("span",{style:Wh,children:d.apOperation}),o.jsx("span",{style:{color:"var(--proto-ink-2)"},children:e.operation}),o.jsx("span",{style:Wh,children:d.apReason}),o.jsx("span",{style:{color:"var(--proto-ink-2)"},children:e.reason}),o.jsx("span",{style:Wh,children:d.apImpact}),o.jsx("span",{style:{color:"var(--proto-ink-2)"},children:e.impact})]}),e.hasCommand&&o.jsxs("div",{style:{marginTop:13},children:[o.jsx("div",{style:{fontSize:10,fontWeight:700,letterSpacing:".05em",color:"var(--proto-muted-3)",marginBottom:6},children:d.apCommand}),o.jsx("div",{style:{background:"var(--proto-rail)",border:"1px solid var(--proto-line-2)",borderRadius:8,padding:"9px 14px",font:`400 11px/1.75 ${ai}`,color:"var(--proto-muted)",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:e.command})]}),e.feedback&&o.jsxs("div",{style:{margin:"13px 0 14px",background:"var(--proto-danger-bg)",border:"1px solid var(--proto-danger-bg)",borderRadius:8,padding:"10px 13px",fontSize:11.5,lineHeight:1.55,color:"var(--proto-danger)"},children:[o.jsx("b",{style:{color:"var(--proto-danger)"},children:d.apFeedbackLabel})," — ",e.feedback]})]}),t&&o.jsx("div",{style:{flex:"none",padding:"0 22px 11px"},children:o.jsx("div",{style:{display:"flex",alignItems:"center",gap:8,border:"1px solid var(--proto-danger-bg)",background:"var(--proto-card)",borderRadius:8,padding:"7px 12px"},children:o.jsx("input",{"data-approval-feedback":"",value:n,onChange:u=>c(u.target.value),placeholder:d.apFeedbackPh,style:{flex:1,fontSize:12,color:"var(--proto-ink)",fontFamily:"inherit"}})})}),o.jsxs("div",{style:{flex:"none",borderTop:"1px solid var(--proto-line-2)",padding:"12px 22px",display:"flex",alignItems:"center",gap:10},children:[o.jsx("span",{style:{font:`400 10px ${ai}`,color:"var(--proto-faint)",lineHeight:1.6},children:d.apFootNote}),!t&&o.jsxs(o.Fragment,{children:[o.jsx(au,{"data-action":"arm",onClick:r?void 0:()=>i(),base:{marginLeft:"auto",fontSize:12,fontWeight:600,border:"1px solid var(--proto-danger-bg)",borderRadius:8,padding:"7px 16px",color:"var(--proto-danger)",background:"var(--proto-card)",cursor:r?"not-allowed":"pointer",flex:"none",opacity:r?.6:1},hover:{background:"var(--proto-danger-bg)"},children:d.rejectFeedback}),o.jsx(au,{"data-action":"approve",onClick:r?void 0:()=>a(e.id),base:{fontSize:12,fontWeight:600,borderRadius:8,padding:"8px 20px",color:"var(--ink-solid-fg)",background:"var(--proto-accent)",cursor:r?"not-allowed":"pointer",flex:"none",opacity:r?.6:1},hover:{background:"var(--proto-accent-strong)"},children:d.approve})]}),t&&o.jsxs(o.Fragment,{children:[o.jsx(au,{"data-action":"cancel",onClick:r?void 0:()=>s(),base:{marginLeft:"auto",fontSize:12,fontWeight:600,border:"1px solid var(--proto-line-3)",borderRadius:8,padding:"7px 16px",color:"var(--proto-ink)",background:"var(--proto-card)",cursor:r?"not-allowed":"pointer",flex:"none",opacity:r?.6:1},hover:{background:"var(--proto-alt)"},children:d.cancel}),o.jsx(au,{"data-action":"reject",onClick:r?void 0:()=>l(e.id),base:{fontSize:12,fontWeight:600,borderRadius:8,padding:"8px 20px",color:"var(--ink-solid-fg)",background:"var(--proto-danger)",cursor:r?"not-allowed":"pointer",flex:"none",opacity:r?.6:1},hover:{opacity:.88},children:d.denyConfirm})]})]})]})}function au({base:e,hover:t,onClick:n,children:r,...i}){const[s,a]=p.useState(!1);return o.jsx("span",{...i,onClick:n,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),style:s?{...e,...t}:e,children:r})}function _W({open:e,onClose:t}){const n=H(),r=le(),i=je(),{toast:s}=dr(),a=Y({...r.approvals.list.queryOptions({status:"pending"}),enabled:e}),l=p.useMemo(()=>a.data??[],[a.data]),[c,d]=p.useState(null),[u,f]=p.useState(!1),[h,g]=p.useState(""),v=LW(l,c),x=()=>i.invalidateQueries(r.approvals.list.queryFilter()),b=()=>{f(!1),g("")},j=xe(r.approvals.approve.mutationOptions({onSuccess:()=>s({title:n.apToastApproved,tone:"done"}),onSettled:()=>{b(),x()}})),y=xe(r.approvals.reject.mutationOptions({onSuccess:()=>s({title:n.apToastRejected,tone:"failed"}),onSettled:()=>{b(),x()}})),w=j.isPending||y.isPending;return p.useEffect(()=>{e||b()},[e]),p.useEffect(()=>{b()},[v]),p.useEffect(()=>{if(!e)return;const k=S=>{S.key==="Escape"&&t()};return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[e,t]),e?o.jsx(OW,{entries:l,selectedId:v,armed:u,feedback:h,pending:w,onSelect:d,onClose:t,onArm:()=>f(!0),onCancel:b,onApprove:k=>j.mutate({id:k}),onReject:k=>y.mutate({id:k,feedback:h.trim()||void 0}),onFeedback:g}):null}const d6=p.createContext(null);function $W({children:e}){const[t,n]=p.useState(!1),r=p.useCallback(()=>n(!0),[]),i=p.useCallback(()=>n(!1),[]),s=p.useMemo(()=>({open:r,close:i}),[r,i]);return o.jsxs(d6.Provider,{value:s,children:[e,o.jsx(_W,{open:t,onClose:i})]})}function FW(){const e=p.useContext(d6);if(!e)throw new Error("useApprovals must be used within an ApprovalsProvider");return e}function zW(e,t){var n;if(e.length){const r=[...e].sort((i,s)=>Date.parse(s.lastUsedAt||s.createdAt)-Date.parse(i.lastUsedAt||i.createdAt))[0];if(r!=null&&r.projectId)return r.projectId}return((n=t[0])==null?void 0:n.id)??null}function u6(e,t,n){return e??zW(t,n)}const p6=p.createContext(null);function BW({children:e}){const t=le(),n=Y(t.projects.list.queryOptions({})),r=Y(t.sessions.list.queryOptions({origin:"direct"})),[i,s]=p.useState(null),a=u6(i,r.data??[],n.data??[]),l=p.useCallback(d=>s(d),[]),c=p.useMemo(()=>({currentProjectId:a,setCurrentProject:l}),[a,l]);return o.jsx(p6.Provider,{value:c,children:e})}function Ei(){const e=p.useContext(p6);if(!e)throw new Error("useCurrentProject must be used within a CurrentProjectProvider");return e}const Fc="__draft__";function WW(e){return(e.metaKey||e.ctrlKey)&&!e.shiftKey&&!e.altKey&&e.key.toLowerCase()==="n"}function UW(e){var t;return e.length?((t=[...e].sort((n,r)=>Date.parse(r.lastUsedAt||r.createdAt)-Date.parse(n.lastUsedAt||n.createdAt))[0])==null?void 0:t.sessionId)??null:null}function HW(e,t,n=null){return e===Fc?Fc:n&&e===n?n:e&&t.some(r=>r.sessionId===e)?e:UW(t)}function f6(e,t,n){return e??(!n||(t==null?void 0:t.sessionId)!==n?null:t.profileName)}const pj="cortex.composerDraft.";function yd(e){return e.isDraft?`${pj}new.${e.projectId??"general"}`:e.sessionId?`${pj}session.${e.sessionId}`:null}function h6(e){return e?e.text.trim().length===0&&e.attachments.length===0:!0}function VW(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.name=="string"&&typeof t.path=="string"&&typeof t.size=="number"&&typeof t.mimeType=="string"&&(t.type==="image"||t.type==="video"||t.type==="file")}function qW(e){if(!e)return null;let t;try{t=JSON.parse(e)}catch{return null}if(!t||typeof t!="object")return null;const n=t,r=typeof n.text=="string"?n.text:"",i=Array.isArray(n.attachments)?n.attachments.filter(VW):[],s=typeof n.draftUploadId=="string"?n.draftUploadId:void 0,a={text:r,attachments:i,...s?{draftUploadId:s}:{}};return h6(a)?null:a}function KW(e){return JSON.stringify({text:e.text,attachments:e.attachments,...e.draftUploadId?{draftUploadId:e.draftUploadId}:{}})}function fv(){if(typeof window>"u")return null;try{return window.localStorage}catch{return null}}function Ep(e){if(!e)return null;const t=fv();if(!t)return null;try{return qW(t.getItem(e))}catch{return null}}function nl(e,t){if(!e)return;const n=fv();if(n)try{if(h6(t)){n.removeItem(e);return}n.setItem(e,KW(t))}catch{}}function QW(e,t){return{text:t,attachments:(e==null?void 0:e.attachments)??[],...e!=null&&e.draftUploadId?{draftUploadId:e.draftUploadId}:{}}}function YW(e,t){const n=[t.text,e.text].filter(s=>s.length>0).join(`
|
|
128
|
+
`),r=[...t.attachments,...e.attachments].filter((s,a,l)=>l.findIndex(c=>c.path===s.path)===a),i=e.draftUploadId??t.draftUploadId;return{text:n,attachments:r,...i?{draftUploadId:i}:{}}}function g6(e,t){const n=yd({isDraft:!0,projectId:e});nl(n,QW(Ep(n),t))}function x6(e){if(!e)return;const t=fv();if(t)try{t.removeItem(e)}catch{}}const m6=p.createContext(null);function GW({children:e}){const t=le(),{currentProjectId:n}=Ei(),r=Y(t.sessions.list.queryOptions({origin:"direct",projectId:n??void 0})),i=Y(t.config.get.queryOptions({})),[s,a]=p.useState(null),[l,c]=p.useState(null),[d,u]=p.useState(0),[f,h]=p.useState(null),g=r.data??[],v=(f==null?void 0:f.sessionId)??null,x=HW(s,g,v),b=x===Fc;p.useEffect(()=>{v&&g.some(T=>T.sessionId===v)&&h(null)},[v,g]),p.useEffect(()=>{h(null)},[n]),p.useEffect(()=>{var T;if(b&&!l&&((T=i.data)!=null&&T.profiles)){const C=i.data.profiles.defaultProfile;C&&i.data.profiles.profiles.find(P=>P.name===C)&&c(C)}},[b,l,i.data]);const j=p.useCallback(T=>{h(null),a(T)},[]),y=p.useCallback(T=>{h({sessionId:T,profileName:l}),a(T)},[l]),w=p.useCallback(T=>{g6(n??"general",T),h(null),a(Fc),u(C=>C+1)},[n]),k=p.useCallback(()=>{h(null),a(null),c(null)},[]),S=p.useMemo(()=>({selectedSessionId:x,setSelectedSession:j,selectCreatedSession:y,pendingCreatedSession:f,isDraft:b,draftProfile:l,setDraftProfile:c,draftReloadToken:d,prefillDraft:w,clearDraft:k}),[x,j,y,f,b,l,d,w,k]);return o.jsx(m6.Provider,{value:S,children:e})}function bs(){const e=p.useContext(m6);if(!e)throw new Error("useSelectedSession must be used within a SelectedSessionProvider");return e}const XW=/^\s*-\s+([^::]{1,30}?)\s*[::]\s*(.*)$/;function v6(e){const t=[],n=[];let r=null;for(const i of e.split(`
|
|
129
|
+
`)){const s=i.trim();if(s==="")continue;const a=i.match(XW);if(a){r={label:a[1].trim(),text:a[2].trim()},t.push(r);continue}if(/^\s*-\s+/.test(i)){r=null,n.push(s.replace(/^-\s+/,""));continue}r?r.text+=`
|
|
130
|
+
${s}`:n.push(s)}return{fields:t,desc:n.length>0?n.join(`
|
|
131
|
+
`):null}}function JW(e){return{id:e.id,title:e.title,date:e.date}}function ZW(e){const t=v6(e.body);return{id:e.id,title:e.title,date:e.date,fields:t.fields,desc:t.desc}}function eU(e,t){var n;return t&&e.some(r=>r.id===t)?t:((n=e[0])==null?void 0:n.id)??null}function y6(e,t){const n=t.date?` (${t.date})`:"";return`处理项目 ${e} 的 ISSUES.md 中登记的 issue:
|
|
132
|
+
|
|
133
|
+
**${t.title}**${n}
|
|
134
|
+
`+(t.body?`${t.body}
|
|
135
|
+
`:"")+`
|
|
136
|
+
该条目已从 ISSUES.md 移除并交由本会话处理。请调查并解决上述问题;如需持久记录结论,写入项目上下文相应文件。`}const os="'IBM Plex Mono',monospace";function tU(e){const t=H(),{entries:n,selectedId:r,armed:i,pending:s}=e,a=n.length,l=a>0,c=n.find(u=>u.id===r)??n[0]??null,d=c?ZW(c):null;return o.jsxs(o.Fragment,{children:[o.jsx("div",{onClick:e.onClose,style:{position:"fixed",inset:0,background:"rgba(25,28,34,.32)",zIndex:60,animation:"cxfade .18s ease"}}),o.jsxs("div",{"data-issue-center":"","data-issue-selected":(c==null?void 0:c.id)??"",style:{position:"fixed",left:"50%",top:"50%",transform:"translate(-50%,-50%)",animation:"cxmodal .26s cubic-bezier(.22,1,.36,1)",width:1150,maxWidth:"94vw",height:730,maxHeight:"90vh",background:"var(--proto-card)",borderRadius:14,boxShadow:"0 24px 64px rgba(16,24,40,.28)",zIndex:61,overflow:"hidden",display:"flex",flexDirection:"column"},children:[o.jsxs("div",{style:{flex:"none",display:"flex",alignItems:"center",gap:9,padding:"12px 20px",borderBottom:"1px solid var(--proto-line)"},children:[o.jsx("span",{style:{fontSize:13,fontWeight:650,color:"var(--proto-ink)"},children:t.issuesTitle}),l&&o.jsx("span",{style:{font:`600 10.5px ${os}`,color:"var(--proto-muted)",background:"var(--proto-line-2)",padding:"2px 9px",borderRadius:999,marginLeft:2},children:a}),o.jsx("span",{style:{marginLeft:"auto",font:`400 10px ${os}`,color:"var(--proto-muted-3)"},children:e.projectId?`${e.projectId}/ISSUES.md`:"ISSUES.md"}),o.jsx("span",{onClick:e.onClose,style:{font:`500 9.5px ${os}`,color:"var(--proto-muted-3)",border:"1px solid var(--proto-line)",borderRadius:5,padding:"2px 6px",cursor:"pointer"},children:"esc"})]}),o.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden",minHeight:0},children:[!l&&o.jsx(nU,{}),l&&o.jsxs(o.Fragment,{children:[o.jsx(rU,{entries:n,selectedId:(c==null?void 0:c.id)??null,count:a,onSelect:e.onSelect}),d&&o.jsx(oU,{detail:d,armed:i,pending:s,onArm:e.onArm,onCancelArm:e.onCancelArm,onDelete:e.onDelete,onHandle:e.onHandle})]})]})]})]})}function nU(){const e=H();return o.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:9,background:"var(--proto-rail)"},children:[o.jsx("span",{style:{width:34,height:34,borderRadius:"50%",background:"var(--proto-success-bg)",color:"var(--proto-success)",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:15,fontWeight:700},children:"✓"}),o.jsx("div",{style:{fontSize:13,fontWeight:600,color:"var(--proto-ink)"},children:e.isEmptyTitle}),o.jsx("div",{style:{fontSize:11,color:"var(--proto-muted-2)"},children:e.isEmptyDesc})]})}function rU({entries:e,selectedId:t,count:n,onSelect:r}){const i=H();return o.jsxs("div",{style:{width:400,flex:"none",borderRight:"1px solid var(--proto-line)",background:"var(--proto-rail)",display:"flex",flexDirection:"column",overflow:"hidden"},children:[o.jsxs("div",{style:{padding:"14px 18px 9px",fontSize:10,fontWeight:700,letterSpacing:".06em",color:"var(--proto-muted-3)",flex:"none"},children:[i.isListLabel," · ",n]}),o.jsx("div",{style:{flex:1,overflow:"auto",minHeight:0,padding:"0 12px",display:"flex",flexDirection:"column",gap:8},children:e.map(s=>{const a=JW(s),l=s.id===t;return o.jsxs("div",{"data-issue-id":s.id,onClick:()=>r(s.id),style:{background:"var(--proto-card)",border:`1px solid ${l?"var(--proto-accent-border)":"var(--proto-line-2)"}`,borderRadius:10,padding:"11px 13px",boxShadow:l?"0 1px 3px rgba(70,85,212,.08)":"none",cursor:"pointer",flex:"none"},children:[o.jsx("div",{style:{fontSize:12.5,fontWeight:600,color:l?"var(--proto-ink)":"var(--proto-ink-2)",lineHeight:1.35},children:a.title}),a.date&&o.jsx("div",{style:{display:"flex",alignItems:"center",gap:7,marginTop:6},children:o.jsx("span",{style:{marginLeft:"auto",font:`400 9.5px ${os}`,color:"var(--proto-faint)"},children:a.date})})]},s.id)})}),o.jsx("div",{style:{marginTop:"auto",padding:"12px 18px",borderTop:"1px solid var(--proto-line-2)",font:`400 9.5px ${os}`,color:"var(--proto-faint)",lineHeight:1.7,flex:"none"},children:i.isNoStatusNote})]})}const b6={fontSize:10,fontWeight:700,letterSpacing:".05em",color:"var(--proto-muted-3)",paddingTop:2};function oU({detail:e,armed:t,pending:n,onArm:r,onCancelArm:i,onDelete:s,onHandle:a}){const l=H();return o.jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",overflow:"hidden"},children:[o.jsxs("div",{style:{flex:1,overflow:"auto",minHeight:0,padding:"18px 24px 0"},children:[o.jsx("div",{style:{fontSize:16,fontWeight:650,color:"var(--proto-ink)",lineHeight:1.35},children:e.title}),e.date&&o.jsx("div",{style:{display:"flex",alignItems:"center",gap:14,marginTop:8,font:`400 10.5px ${os}`,color:"var(--proto-muted-3)"},children:o.jsxs("span",{children:[l.isRecorded," ",e.date]})}),o.jsxs("div",{style:{margin:"16px 0 14px",display:"grid",gridTemplateColumns:"76px 1fr",rowGap:10,columnGap:14,fontSize:12,lineHeight:1.6},children:[e.desc&&o.jsxs(o.Fragment,{children:[o.jsx("span",{style:b6,children:l.isDescLabel}),o.jsx("span",{style:{color:"var(--proto-ink-2)",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:e.desc})]}),e.fields.map((c,d)=>o.jsx(iU,{label:c.label,text:c.text},`${c.label}-${d}`))]})]}),o.jsxs("div",{style:{flex:"none",borderTop:"1px solid var(--proto-line-2)",padding:"14px 22px",display:"flex",alignItems:"center",gap:10},children:[o.jsx("span",{style:{font:`400 10px ${os}`,color:"var(--proto-faint)",lineHeight:1.6,flex:1,minWidth:0},children:l.isFootNote}),!t&&o.jsxs(o.Fragment,{children:[o.jsx(lu,{"data-action":"arm-delete",onClick:n?void 0:()=>r(),base:{fontSize:12,fontWeight:600,border:"1px solid var(--proto-danger-bg)",borderRadius:8,padding:"7px 16px",color:"var(--proto-danger)",background:"var(--proto-card)",cursor:n?"not-allowed":"pointer",flex:"none",opacity:n?.6:1},hover:{background:"var(--proto-danger-bg)"},children:l.isDelete}),o.jsx(lu,{"data-action":"handle",onClick:n?void 0:()=>a(e.id),base:{fontSize:12,fontWeight:600,borderRadius:8,padding:"8px 22px",color:"var(--ink-solid-fg)",background:"var(--proto-accent)",cursor:n?"not-allowed":"pointer",flex:"none",opacity:n?.6:1},hover:{background:"var(--proto-accent-strong)"},children:l.isHandle})]}),t&&o.jsxs(o.Fragment,{children:[o.jsx(lu,{"data-action":"cancel-delete",onClick:n?void 0:()=>i(),base:{fontSize:12,fontWeight:600,border:"1px solid var(--proto-line-3)",borderRadius:8,padding:"7px 16px",color:"var(--proto-ink)",background:"var(--proto-card)",cursor:n?"not-allowed":"pointer",flex:"none",opacity:n?.6:1},hover:{background:"var(--proto-alt)"},children:l.cancel}),o.jsx(lu,{"data-action":"confirm-delete",onClick:n?void 0:()=>s(e.id),base:{fontSize:12,fontWeight:600,borderRadius:8,padding:"8px 20px",color:"var(--ink-solid-fg)",background:"var(--proto-danger)",cursor:n?"not-allowed":"pointer",flex:"none",opacity:n?.6:1},hover:{opacity:.88},children:l.isConfirmDelete})]})]})]})}function iU({label:e,text:t}){return o.jsxs(o.Fragment,{children:[o.jsx("span",{style:b6,children:e}),o.jsx("span",{style:{color:"var(--proto-ink-2)",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:t})]})}function lu({base:e,hover:t,onClick:n,children:r,...i}){const[s,a]=p.useState(!1);return o.jsx("span",{...i,onClick:n,onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),style:s?{...e,...t}:e,children:r})}function sU({open:e,initialId:t,onClose:n}){const r=H(),i=le(),s=je(),a=ze(),{toast:l}=dr(),{currentProjectId:c}=Ei(),{setSelectedSession:d}=bs(),u=Y({...i.issues.list.queryOptions({projectId:c??""}),enabled:e&&!!c}),f=p.useMemo(()=>u.data??[],[u.data]),[h,g]=p.useState(null),[v,x]=p.useState(!1),b=eU(f,h??t),j=()=>s.invalidateQueries(i.issues.list.queryFilter()),y=xe(i.issues.delete.mutationOptions({onSettled:()=>{x(!1),j()}})),w=y.isPending;return p.useEffect(()=>{e||(x(!1),g(null))},[e]),p.useEffect(()=>{x(!1)},[b]),p.useEffect(()=>{if(!e)return;const k=S=>{S.key==="Escape"&&n()};return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[e,n]),e?o.jsx(tU,{entries:f,selectedId:b,projectId:c,armed:v,pending:w,onSelect:g,onClose:n,onArm:()=>x(!0),onCancelArm:()=>x(!1),onDelete:k=>{c&&y.mutate({projectId:c,id:k},{onSuccess:()=>l({title:r.isToastDeleted,tone:"done"})})},onHandle:k=>{if(!c)return;const S=f.find(P=>P.id===k);if(!S)return;const T=y6(c,S),C=yd({isDraft:!0,projectId:c});nl(C,{text:T,attachments:[]}),d(Fc),n(),a("/workbench"),y.mutate({projectId:c,id:k},{onSuccess:()=>l({title:r.isToastHandled,tone:"done"})})}}):null}const j6=p.createContext(null);function aU({children:e}){const[t,n]=p.useState(!1),[r,i]=p.useState(null),s=p.useCallback(c=>{i(c??null),n(!0)},[]),a=p.useCallback(()=>{n(!1),i(null)},[]),l=p.useMemo(()=>({open:s,close:a}),[s,a]);return o.jsxs(j6.Provider,{value:l,children:[e,o.jsx(sU,{open:t,initialId:r,onClose:a})]})}function lU(){const e=p.useContext(j6);if(!e)throw new Error("useIssues must be used within an IssuesProvider");return e}const cU=96;function w6(e,t=cU){const n=(e??"").replace(/\s+/g," ").trim();return n.length<=t?n:n.slice(0,t-1).trimEnd()+"…"}function k6(e){const t=(e.sessionName??"").trim();return{id:e.id,level:e.level??"info",title:t||"New message",meta:w6(e.text),ts:e.ts??new Date().toISOString(),sessionId:e.sessionId,projectId:e.projectId}}function S6(e){const t=(e.title??"").trim();return{id:e.id,level:e.level??"info",title:t||"System notice",meta:w6(e.text),ts:e.ts??new Date().toISOString(),sessionId:"",projectId:null}}function dU(e){return e==="info"}const uU=3,fj=50;function pU(e,t){return e.sessionId===t.sessionId&&e.meta===t.meta}function Ux(e,t){const n=e[e.length-1];if(n&&pU(n,t))return e;const r=[...e,t];return r.length>fj?r.slice(r.length-fj):r}function Tp(e,t){return e.filter(n=>n.id!==t)}function C6(e,t=uU){return e.length<=t?{visible:e,overflow:0}:{visible:e.slice(e.length-t),overflow:e.length-t}}const fU={info:"bg-proto-accent-bg text-proto-accent",warning:"bg-pill-waiting-bg text-pill-waiting-fg",error:"bg-pill-failed-bg text-pill-failed-fg"},hU={info:"i",warning:"!",error:"✕"};function gU(e,t=Date.now()){const n=Date.parse(e);if(Number.isNaN(n))return"now";const r=Math.max(0,Math.floor((t-n)/1e3));if(r<45)return"now";const i=Math.floor(r/60);if(i<60)return`${i}m`;const s=Math.floor(i/60);return s<24?`${s}h`:`${Math.floor(s/24)}d`}function xU({item:e,onDismiss:t,onActivate:n}){const r=dU(e.level);return o.jsxs("div",{role:"status",onClick:()=>n(e),className:"group relative w-[380px] cursor-pointer overflow-hidden rounded-[11px] border border-proto-line bg-surface-card px-[13px] pb-[12px] pt-[11px] shadow-toast animate-toast-in motion-reduce:animate-none",children:[o.jsxs("div",{className:"flex items-start gap-[10px]",children:[o.jsx("span",{className:["flex h-[24px] w-[24px] flex-none items-center justify-center rounded-[7px] text-[11px] font-bold",fU[e.level]].join(" "),"aria-hidden":!0,children:hU[e.level]}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsxs("div",{className:"flex items-baseline gap-[8px]",children:[o.jsx("span",{className:"text-[12.5px] font-semibold text-proto-ink",children:e.title}),o.jsx("span",{className:"ml-auto font-mono text-[10px] text-proto-faint",children:gU(e.ts)}),o.jsx("button",{type:"button","aria-label":"Dismiss",onClick:i=>{i.stopPropagation(),t(e.id)},className:"flex-none text-[12px] leading-none text-proto-faint transition-colors hover:text-proto-muted",children:"✕"})]}),o.jsx("div",{className:"mt-[3px] truncate font-mono text-[10.5px] text-proto-muted-2",children:e.meta})]})]}),r?o.jsx("div",{className:"absolute bottom-0 left-0 h-[2px] bg-proto-accent opacity-40 animate-toastbar group-hover:[animation-play-state:paused]",onAnimationEnd:i=>{i.animationName==="toastbar"&&t(e.id)}}):null]})}function mU({items:e,onDismiss:t,onActivate:n}){const[r,i]=p.useState(!1);if(e.length===0)return null;const{visible:s,overflow:a}=C6(e),l=r?e:s;return o.jsxs("div",{className:"pointer-events-none fixed bottom-0 right-0 z-50 m-2g flex w-[380px] max-w-[calc(100vw-2rem)] flex-col items-end gap-[10px]",children:[l.map(c=>o.jsx("div",{className:"pointer-events-auto w-full",children:o.jsx(xU,{item:c,onDismiss:t,onActivate:n})},c.id)),a>0&&!r?o.jsxs("button",{type:"button",onClick:()=>i(!0),className:"pointer-events-auto flex items-center gap-[7px] rounded-full border border-proto-line bg-surface-card px-[12px] py-[5px] shadow-toast-pill",children:[o.jsxs("span",{className:"font-mono text-[10.5px] font-semibold text-proto-muted",children:["+",a]}),o.jsx("span",{className:"text-[11px] text-proto-muted-2",children:"more · click to expand"})]}):null]})}const vU=["session.message","session.status"];function E6({onMessage:e,onTurnEnd:t}){Ci(vU,n=>{if(n.type==="session.message"){const r=n.payload;if(!r||r.role!=="assistant")return;const i=(r.text??"").trim();if(!i||!r.sessionId)return;e({sessionId:r.sessionId,channel:r.channel??null,text:i,ts:r.ts??null});return}if(n.type==="session.status"){const r=n.payload;if(!r||!r.sessionId||r.running!==!1)return;t(r.sessionId)}})}function T6(e){Ci(ZC,t=>{if(t.type!=="system.notice")return;const n=t.payload,r=((n==null?void 0:n.text)??"").trim();r&&e({level:(n==null?void 0:n.level)??"info",text:r,title:(n==null?void 0:n.title)??null,ts:(n==null?void 0:n.ts)??null})})}function P6(e,t,n){e.set(t,n)}function R6(e,t){const n=e.get(t)??null;return e.delete(t),n}function yU(){const e=le(),t=ze(),n=ur(),{selectedSessionId:r,setSelectedSession:i}=bs(),{setCurrentProject:s}=Ei(),[a,l]=p.useState([]),c=p.useRef(0),d=p.useRef(new Map),u=p.useRef(r),f=p.useRef(n.pathname),h=Y(e.sessions.list.queryOptions({origin:"direct"}));p.useEffect(()=>{const w=new Map;for(const k of h.data??[])w.set(k.sessionId,{name:k.label??k.name,projectId:k.projectId});d.current=w},[h.data]),p.useEffect(()=>{u.current=r},[r]),p.useEffect(()=>{f.current=n.pathname},[n.pathname]);const g=p.useRef(new Map),v=p.useCallback(w=>{P6(g.current,w.sessionId,{text:w.text,ts:w.ts??new Date().toISOString()})},[]),x=p.useCallback(w=>{const k=R6(g.current,w);if(!k)return;const S=d.current.get(w);if(!S||f.current.startsWith("/workbench")&&u.current===w)return;const T=`dmn-${c.current++}`,C=k6({id:T,sessionId:w,sessionName:S.name,projectId:S.projectId,text:k.text,ts:k.ts});l(P=>Ux(P,C))},[]);E6({onMessage:v,onTurnEnd:x});const b=p.useCallback(w=>{const k=`sysn-${c.current++}`,S=S6({id:k,level:w.level,text:w.text,title:w.title??void 0,ts:w.ts??void 0});l(T=>Ux(T,S))},[]);T6(b);const j=p.useCallback(w=>l(k=>Tp(k,w)),[]),y=p.useCallback(w=>{w.sessionId&&(w.projectId&&s(w.projectId),i(w.sessionId),t("/workbench")),l(k=>Tp(k,w.id))},[t,s,i]);return o.jsx(mU,{items:a,onDismiss:j,onActivate:y})}const bU="frontend-update-staged";function hj(e){return e.slice(0,8)}function jU(e){const t=hj(e.version),n=e.fromVersion?hj(e.fromVersion):"";return n&&n!==t?`${n} → ${t}`:t}function I6(e){return!e||e<=0?null:e>=1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:e>=1024?`${Math.round(e/1024)} KB`:`${e} B`}function M6(e){const t=I6(e.size),n=[jU(e)];return t&&n.push(t),n.push("已下载"),n.join(" · ")}function hv(){return globalThis.__TAURI__}function L6(e){if(!e||typeof e!="object")return null;const t=e;return typeof t.version!="string"||!t.version?null:{version:t.version,fromVersion:typeof t.fromVersion=="string"&&t.fromVersion?t.fromVersion:void 0,size:typeof t.size=="number"?t.size:void 0}}async function wU(e){var n;if(!Kt())return()=>{};const t=(n=hv())==null?void 0:n.event;if(!t)return()=>{};try{const r=await t.listen(bU,i=>{const s=L6(i.payload);s&&e(s)});return()=>{try{r()}catch{}}}catch{return()=>{}}}async function kU(){var t;if(!Kt())return null;const e=(t=hv())==null?void 0:t.core;if(!e)return null;try{const n=await e.invoke("get_staged_update");return L6(n)}catch{return null}}async function SU(){var t;if(!Kt())return;const e=(t=hv())==null?void 0:t.core;if(e)try{await e.invoke("apply_frontend_update")}catch{}}const CU="app-update-available";function gj(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.version!="string"||!t.version||typeof t.kind!="string"||!t.kind)return null;const n={version:t.version,kind:t.kind};return typeof t.releaseUrl=="string"&&t.releaseUrl&&(n.releaseUrl=t.releaseUrl),typeof t.notes=="string"&&t.notes&&(n.notes=t.notes),typeof t.size=="number"&&t.size>0&&(n.size=t.size),n}function O6(e){const t=[`Cortex ${e.version}`],n=I6(e.size);return n&&t.push(n),t.push("已下载"),t.join(" · ")}function A6(e){switch(e){case"appimage":return"重启更新";case"nsis":return"运行安装程序";case"apk":return"安装";case"dmg":case"deb":case"rpm":return"打开安装包";default:return"更新"}}function D6(e){switch(e){case"appimage":return"新版本已在后台下载并校验完成,点击后自动替换并重启。运行中的线程在服务端继续执行,不受影响。";case"nsis":return"新版本已在后台下载并校验完成。点击后将退出 App 并启动安装程序,按提示完成安装后重新打开即可。";case"apk":return"新版本已在后台下载并校验完成。点击安装后按系统提示完成升级,运行中的线程在服务端继续执行。";case"dmg":return"新版本已在后台下载并校验完成。将打开磁盘映像,把 Cortex 拖入 Applications 即完成升级。";case"deb":case"rpm":return"新版本已在后台下载并校验完成。将打开安装包,用系统安装器完成升级后重新打开 App。";default:return"新版本已在后台下载并校验完成。"}}let N6=null;const Hx=new Set;function Pp(e){N6=e;for(const t of Hx)t()}function gv(e){return Hx.add(e),()=>Hx.delete(e)}function xv(){return N6}function mv(){return globalThis.__TAURI__}async function EU(){var n;if(!Kt())return()=>{};const e=mv();if(!e)return()=>{};let t=()=>{};try{if(e.event){const i=await e.event.listen(CU,s=>{const a=gj(s.payload);a&&Pp(a)});t=()=>{try{i()}catch{}}}const r=gj(await((n=e.core)==null?void 0:n.invoke("get_app_update")));r&&Pp(r)}catch{}return t}async function TU(){var t;if(!Kt())return null;const e=(t=mv())==null?void 0:t.core;if(!e)return null;try{return await e.invoke("install_app_update")??null}catch(n){if(typeof n=="string"&&n)throw new Error(n);return null}}async function PU(){var e,t;if(Pp(null),!!Kt())try{await((t=(e=mv())==null?void 0:e.core)==null?void 0:t.invoke("skip_app_update"))}catch{}}function Vx(e){if(!e)return!1;const t=e.tagName;if(t==="TEXTAREA")return!0;if(t==="INPUT"){const n=e.type;return!["button","checkbox","radio","submit","reset","file","range","color"].includes(n)}return e.isContentEditable===!0}function _6(){const[e,t]=p.useState(null),n=p.useRef(!1),r=p.useRef(null),i=p.useCallback(l=>{if(!n.current){if(Vx(typeof document<"u"?document.activeElement:null)){r.current=l;return}t(l)}},[]);p.useEffect(()=>{let l=!1,c=()=>{};return wU(d=>i(d)).then(d=>{l?d():c=d}),kU().then(d=>{d&&!l&&i(d)}),()=>{l=!0,c()}},[i]),p.useEffect(()=>{if(typeof document>"u")return;const l=()=>{window.setTimeout(()=>{n.current||!r.current||Vx(document.activeElement)||(t(r.current),r.current=null)},0)};return document.addEventListener("focusout",l),()=>document.removeEventListener("focusout",l)},[]);const s=p.useCallback(()=>{SU()},[]),a=p.useCallback(()=>{n.current=!0,r.current=null,t(null)},[]);return{staged:e,apply:s,dismiss:a}}const RU="fixed inset-0 z-40 bg-state-ink/[0.44] data-[state=open]:animate-fade-in data-[state=closed]:animate-fade-out motion-reduce:animate-none",IU="fixed left-1/2 top-1/2 z-50 -translate-x-1/2 -translate-y-1/2 w-[420px] max-w-[calc(100vw-32px)] box-border rounded-[14px] bg-surface-card p-5 pb-4 shadow-overlay-strong focus:outline-none data-[state=open]:animate-zoom-in data-[state=closed]:animate-zoom-out motion-reduce:animate-none";function MU({update:e,onApply:t,onDismiss:n}){return o.jsx(po,{open:!0,onOpenChange:r=>{r||n()},children:o.jsxs(fo,{children:[o.jsx(ho,{className:RU}),o.jsxs(go,{className:IU,"aria-describedby":"hot-update-desc",children:[o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx("div",{className:"flex h-9 w-9 flex-none items-center justify-center rounded-card bg-proto-accent-bg text-state-run",children:o.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[o.jsx("path",{d:"M10 14V4M5.5 8.5 10 4l4.5 4.5"}),o.jsx("path",{d:"M3.5 16.5h13"})]})}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsx(wi,{className:"text-body font-semibold text-state-ink",children:"新版本已就绪"}),o.jsx("div",{className:"mt-[3px] font-mono text-[10.5px] font-medium text-proto-muted-3",children:M6(e)})]})]}),o.jsx(id,{id:"hot-update-desc",className:"mb-4 mt-3 text-[12.5px] leading-[1.65] text-proto-muted",children:"热更新已在后台下载完成,重启 App 后生效。运行中的线程在服务端继续执行,不受重启影响;未发送的草稿会保留。"}),o.jsxs("div",{className:"flex justify-end gap-2",children:[o.jsx("button",{type:"button",onClick:n,className:"box-border flex h-9 items-center rounded-[9px] border border-proto-line px-4 text-[12.5px] font-semibold text-proto-muted transition-colors hover:bg-surface-canvas-alt focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-state-run/40",children:"忽略"}),o.jsx("button",{type:"button",onClick:t,className:"box-border flex h-9 items-center rounded-[9px] bg-state-ink px-4 text-[12.5px] font-semibold text-surface-card transition-opacity hover:opacity-90 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-state-run/40",children:"重启 App"})]})]})]})})}function LU(){const e=p.useSyncExternalStore(gv,xv),{staged:t,apply:n,dismiss:r}=_6();return e||!t?null:o.jsx(MU,{update:t,onApply:n,onDismiss:r})}function $6(){const e=p.useSyncExternalStore(gv,xv),[t,n]=p.useState(null),[r,i]=p.useState(!1),[s,a]=p.useState(null),l=p.useRef(null);p.useEffect(()=>{let f=!1,h=()=>{};return EU().then(g=>{f?g():h=g}),()=>{f=!0,h()}},[]),p.useEffect(()=>{if(!e||l.current===e.version){n(null);return}const f=()=>{l.current!==e.version&&(typeof document<"u"&&Vx(document.activeElement)||n(e))};if(f(),typeof document>"u")return;const h=()=>{window.setTimeout(f,0)};return document.addEventListener("focusout",h),()=>document.removeEventListener("focusout",h)},[e]);const c=p.useCallback(()=>{i(!0),a(null),TU().then(f=>{i(!1),f!==null&&Pp(null),n(null)}).catch(f=>{i(!1),a(f.message)})},[]),d=p.useCallback(()=>{PU(),n(null)},[]),u=p.useCallback(()=>{l.current=(e==null?void 0:e.version)??(t==null?void 0:t.version)??null,n(null)},[e,t]);return{update:t,busy:r,error:s,install:c,skip:d,dismiss:u}}const OU="fixed inset-0 z-40 bg-state-ink/[0.44] data-[state=open]:animate-fade-in data-[state=closed]:animate-fade-out motion-reduce:animate-none",AU="fixed left-1/2 top-1/2 z-50 -translate-x-1/2 -translate-y-1/2 w-[420px] max-w-[calc(100vw-32px)] box-border rounded-[14px] bg-surface-card p-5 pb-4 shadow-overlay-strong focus:outline-none data-[state=open]:animate-zoom-in data-[state=closed]:animate-zoom-out motion-reduce:animate-none",xj="box-border flex h-9 items-center rounded-[9px] border border-proto-line px-4 text-[12.5px] font-semibold text-proto-muted transition-colors hover:bg-surface-canvas-alt focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-state-run/40";function DU({update:e,busy:t,error:n,onInstall:r,onSkip:i,onDismiss:s}){return o.jsx(po,{open:!0,onOpenChange:a=>{a||s()},children:o.jsxs(fo,{children:[o.jsx(ho,{className:OU}),o.jsxs(go,{className:AU,"aria-describedby":"app-update-desc",children:[o.jsxs("div",{className:"flex items-start gap-3",children:[o.jsx("div",{className:"flex h-9 w-9 flex-none items-center justify-center rounded-card bg-proto-accent-bg text-state-run",children:o.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 20 20",fill:"none",stroke:"currentColor",strokeWidth:"1.8",children:[o.jsx("path",{d:"M10 14V4M5.5 8.5 10 4l4.5 4.5"}),o.jsx("path",{d:"M3.5 16.5h13"})]})}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsx(wi,{className:"text-body font-semibold text-state-ink",children:"App 新版本已就绪"}),o.jsx("div",{className:"mt-[3px] font-mono text-[10.5px] font-medium text-proto-muted-3",children:O6(e)})]})]}),o.jsx(id,{id:"app-update-desc",className:"mb-4 mt-3 text-[12.5px] leading-[1.65] text-proto-muted",children:D6(e.kind)}),n?o.jsxs("div",{className:"mb-3 text-[11.5px] leading-snug text-state-fail",children:["安装失败:",n]}):null,o.jsxs("div",{className:"flex justify-end gap-2",children:[o.jsx("button",{type:"button",onClick:i,className:xj,children:"跳过此版本"}),o.jsx("button",{type:"button",onClick:s,className:xj,children:"稍后"}),o.jsx("button",{type:"button",onClick:r,disabled:t,className:"box-border flex h-9 items-center rounded-[9px] bg-state-ink px-4 text-[12.5px] font-semibold text-surface-card transition-opacity hover:opacity-90 disabled:opacity-60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-state-run/40",children:t?"正在处理…":A6(e.kind)})]})]})]})})}function NU(){const{update:e,busy:t,error:n,install:r,skip:i,dismiss:s}=$6();return e?o.jsx(DU,{update:e,busy:t,error:n,onInstall:r,onSkip:i,onDismiss:s}):null}function _U(e,t){return e==="pending"?"connected":e==="connecting"?t?"reconnecting":"connecting":t?"disconnected":"connecting"}function $U(e){switch(e){case"connected":return{color:"var(--proto-success)",pulse:!1};case"connecting":case"reconnecting":return{color:"var(--proto-amber)",pulse:!0};case"disconnected":return{color:"var(--proto-danger)",pulse:!1}}}function FU(e){switch(e){case"connected":return"connConnected";case"connecting":return"connConnecting";case"reconnecting":return"connReconnecting";case"disconnected":return"connDisconnected"}}const F6=p.createContext("connecting");function z6({children:e}){const{connState:t,hasConnected:n}=dv(),r=_U(t,n);return o.jsx(F6.Provider,{value:r,children:e})}function B6(){return p.useContext(F6)}function bd(e){var t;return e.claimThreadId?e.claimThreadId:(t=e.claimedBy)!=null&&t.startsWith("thr_")?e.claimedBy:null}const zU=[{kind:"done",matches:e=>e.status==="done"},{kind:"blocked",matches:e=>e.blockedBy!=null},{kind:"in-progress",matches:e=>e.claimedBy!=null},{kind:"approval-needed",matches:e=>e.approvalNeeded===!0},{kind:"actionable",matches:e=>e.actionable}];function BU(e){var t;return((t=zU.find(n=>n.matches(e)))==null?void 0:t.kind)??"waiting"}const WU={done:{bg:"#E9F4EE",fg:"#23854F",text:"✓ done"},blocked:{bg:"#FBEDEB",fg:"#C03D33",text:"blocked"},"approval-needed":{bg:"#FFF6E5",fg:"#9A6700",text:"approval-needed"},actionable:{bg:"#EEF0FA",fg:"#4655D4",text:"actionable"},waiting:{bg:"#F1F2F5",fg:"#8A93A2",text:"waiting on deps"}};function UU(e){const t=BU(e);if(t!=="in-progress")return WU[t];const n=bd(e);return{bg:"#EEF0FA",fg:"#4655D4",text:`● in-progress${n?` · ${n}`:""}`}}function HU(e){return e==="high"?"#C03D33":e==="medium"?"#C99A2E":"#B6BDC9"}function mj(e){return e?e.status==="done"?"#23854F":e.blockedBy!=null?"#C03D33":"#4655D4":"#B6BDC9"}function VU(e){const t=e.approvalNeeded;return[{k:"approval-needed",v:t==null?"—":String(t),vColor:t===!0?"#9A6700":"var(--proto-ink)"},{k:"approved-at",v:e.approvedAt??"—",vColor:e.approvedAt?"#23854F":"#B6BDC9"}]}function qU(e){const t=bd(e);return[{k:"priority",v:e.priority,vColor:e.priority==="high"?"#C03D33":"#191C22"},{k:"status",v:e.status,vColor:"var(--proto-ink)"},...VU(e),{k:"template",v:e.template,vColor:"var(--proto-ink)"},{k:"gpu",v:"—",vColor:"#B6BDC9"},{k:"claimed-by",v:t??"—",vColor:t?"#4655D4":"#B6BDC9"}]}function KU(e,t){const n=new Map(t.map(s=>[s.id,s])),r=e.dependsOn.map(s=>{const a=n.get(s);return{id:s,name:(a==null?void 0:a.text)??"—",dotColor:mj(a),idColor:"#4655D4",label:(a==null?void 0:a.status)==="done"?"upstream · done":"upstream",bg:"#FBFBFC",border:"#EFF1F5"}}),i=t.filter(s=>s.id!==e.id&&s.dependsOn.includes(e.id)).map(s=>({id:s.id,name:s.text,dotColor:mj(s),idColor:"#4655D4",label:"downstream",bg:"#FBFBFC",border:"#EFF1F5"}));return[...r,...i]}function QU(e,t){const n=KU(e,t),r=e.status!=="done"&&e.blockedBy==null;return{id:e.id,title:e.text,pill:UU(e),priColor:HU(e.priority),fields:qU(e),deps:n,hasDependencies:n.length>0,canUnblock:e.blockedBy!=null,completable:r,completeBg:r?"#4655D4":"#B6BDC9",completeLabel:e.status==="done"?"Completed":"Complete"}}function YU(e){switch(e){case"completed":return"#23854F";case"failed":return"#C03D33";case"running":return"#4655D4";case"stale":return"#C99A2E";default:return"#8A93A2"}}function GU(e){if(e==null||!Number.isFinite(e)||e<0)return"—";const t=e/1e3;if(t<60)return`${t.toFixed(1)}s`;const n=Math.floor(t/60),r=Math.round(t%60);return`${n}m ${r}s`}function XU(e){return e==null||!Number.isFinite(e)?"—":`$${e.toFixed(4)}`}function JU(e){if(!e)return"—";const t=Date.parse(e);if(Number.isNaN(t))return"—";const n=new Date(t),r=i=>String(i).padStart(2,"0");return`${r(n.getMonth()+1)}-${r(n.getDate())} ${r(n.getHours())}:${r(n.getMinutes())}`}function ZU(e){const t=e.evidence,n=e.dispatches.map(i=>({executionId:i.executionId,type:i.type,status:i.status,statusColor:YU(i.status),machine:i.machine??"—",threadId:i.threadId,when:JU(i.startedAt),duration:GU(i.durationMs),cost:XU(i.cost),isCompleting:i.executionId===t.completingExecutionId})),r=t.completed&&(t.completedNote!=null||t.completingOutput!=null||t.completedAt!=null);return{completed:t.completed,doneWhen:t.doneWhen,completedAt:t.completedAt,completedNote:t.completedNote,completingExecutionId:t.completingExecutionId,completingOutput:t.completingOutput,hasEvidence:r,dispatches:n,hasDispatches:n.length>0}}const Xs={background:"var(--proto-card)",border:"1px solid var(--proto-line)",borderRadius:10,boxShadow:"0 1px 2px rgba(16,24,40,.03)"},Uh={display:"flex",alignItems:"center",padding:"10px 15px",borderBottom:"1px solid var(--proto-line-2)"},Hh={fontSize:11.5,fontWeight:650,color:"var(--proto-ink)"};function Bs({children:e}){return o.jsx("span",{style:{fontStyle:"italic",color:"var(--proto-faint)"},children:e})}function eH({label:e,reason:t}){return t==null?null:o.jsxs("div",{"data-task-blocker-card":"true",style:{...Xs,padding:"10px 15px",background:"var(--proto-danger-bg)"},children:[o.jsx("div",{style:{fontSize:9.5,fontWeight:700,letterSpacing:".05em",color:"var(--proto-danger)"},children:e}),o.jsx("div",{style:{marginTop:5,fontSize:11.5,lineHeight:1.6,color:"var(--proto-danger)",whiteSpace:"pre-wrap",overflowWrap:"anywhere"},children:t})]})}function tH({vv:e}){return o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:e.dispatches.map(t=>o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 9px",background:t.isCompleting?"var(--proto-accent-bg)":"var(--proto-rail)",border:`1px solid ${t.isCompleting?"var(--proto-accent-bg)":"var(--proto-line-2)"}`,borderRadius:7},children:[o.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:t.statusColor,flex:"none"}}),o.jsx("span",{style:{font:"600 10px 'IBM Plex Mono',monospace",color:"var(--proto-accent)"},children:t.executionId}),o.jsx("span",{style:{fontSize:9.5,color:"var(--proto-muted-2)"},children:t.machine}),o.jsxs("span",{style:{marginLeft:"auto",font:"400 9px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)",flex:"none"},children:[t.when," · ",t.duration," · ",t.cost]})]},t.executionId))})}function nH({task:e,allTasks:t,pending:n,onClose:r,onComplete:i,onUnblock:s}){const a=H(),l=QU(e,t),c=le(),d=Y(c.tasks.verification.queryOptions({projectId:e.project,taskId:e.id})),u=d.data?ZU(d.data):null;return p.useEffect(()=>{const f=h=>{h.key==="Escape"&&r()};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[r]),o.jsxs(o.Fragment,{children:[o.jsx("div",{onClick:r,style:{position:"fixed",inset:0,background:"rgba(25,28,34,.34)",zIndex:60,animation:"cxfade .18s ease"}}),o.jsxs("div",{"data-task-modal-id":e.id,style:{position:"fixed",left:"50%",top:"50%",transform:"translate(-50%,-50%)",animation:"cxmodal .26s cubic-bezier(.22,1,.36,1)",width:760,maxHeight:"84vh",background:"var(--proto-alt)",borderRadius:14,boxShadow:"0 24px 64px rgba(16,24,40,.3)",zIndex:61,overflow:"hidden",display:"flex",flexDirection:"column"},children:[o.jsxs("div",{style:{flex:"none",background:"var(--proto-card)",borderBottom:"1px solid var(--proto-line)",display:"flex",alignItems:"center",gap:9,padding:"12px 18px"},children:[o.jsx("span",{style:{font:"600 12.5px 'IBM Plex Mono',monospace",color:"var(--proto-ink)"},children:l.id}),o.jsx("span",{style:{fontSize:9.5,fontWeight:600,padding:"1.5px 8px",borderRadius:999,background:l.pill.bg,color:l.pill.fg},children:l.pill.text}),o.jsx("span",{style:{font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)",marginLeft:4},children:"TASKS.yaml"}),o.jsx("span",{onClick:r,style:{marginLeft:"auto",font:"500 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)",border:"1px solid var(--proto-line)",borderRadius:5,padding:"2px 6px",cursor:"pointer"},children:"esc"})]}),o.jsxs("div",{style:{flex:1,overflow:"auto",minHeight:0,padding:"14px 18px",display:"grid",gridTemplateColumns:"1.5fr 1fr",gap:12,alignContent:"start"},children:[o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12,minWidth:0},children:[o.jsxs("div",{style:{...Xs,padding:"13px 16px"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:8},children:[o.jsx("span",{style:{width:7,height:7,borderRadius:"50%",background:l.priColor,flex:"none",marginTop:5}}),o.jsx("div",{style:{fontSize:13.5,fontWeight:650,color:"var(--proto-ink)",lineHeight:1.4},children:l.title})]}),o.jsxs("div",{style:{fontSize:11.5,lineHeight:1.6,color:"var(--proto-muted)",marginTop:7},children:[o.jsx("span",{style:{fontSize:9.5,fontWeight:700,letterSpacing:".05em",color:"var(--proto-muted-3)",marginRight:7},children:a.tkWhy}),e.why!=null?o.jsx("span",{children:e.why}):o.jsxs(Bs,{children:["— ",a.tkNoWhy]})]}),o.jsx("div",{style:{fontSize:9.5,fontWeight:700,letterSpacing:".05em",color:"var(--proto-muted-3)",margin:"11px 0 5px"},children:a.tkDoneWhen}),o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:5},children:o.jsxs("div",{style:{display:"flex",gap:8,fontSize:11.5,lineHeight:1.5,color:"var(--proto-ink-2)",background:"var(--proto-rail)",border:"1px solid var(--proto-line-2)",borderRadius:7,padding:"6px 10px"},children:[o.jsx("span",{style:{width:12,height:12,borderRadius:4,border:"1.5px solid var(--proto-line-3)",background:"var(--proto-card)",boxSizing:"border-box",flex:"none",marginTop:1.5}}),e.doneWhen!=null?o.jsx("span",{children:e.doneWhen}):o.jsxs(Bs,{children:["— ",a.tkNoDoneWhen]})]})})]}),o.jsx(eH,{label:a.mBlockedPill,reason:e.blockedBy}),o.jsxs("div",{style:Xs,children:[o.jsxs("div",{style:Uh,children:[o.jsx("span",{style:Hh,children:a.tkDispatchHistory}),u&&u.hasDispatches&&o.jsxs("span",{style:{marginLeft:"auto",font:"400 9px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)"},children:[u.dispatches.length," run",u.dispatches.length===1?"":"s"]})]}),o.jsx("div",{style:{padding:"10px 15px",fontSize:11,lineHeight:1.55},children:d.isPending?o.jsxs(Bs,{children:["— ",a.tkLoadingDispatch]}):d.isError||!u?o.jsxs(Bs,{children:["— ",a.tkDispatchFailed]}):u.hasDispatches?o.jsx(tH,{vv:u}):o.jsxs(Bs,{children:["— ",a.tkNoDispatches]})})]})]}),o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12,minWidth:0},children:[o.jsxs("div",{style:Xs,children:[o.jsx("div",{style:Uh,children:o.jsx("span",{style:Hh,children:a.tkFields})}),o.jsx("div",{style:{padding:"8px 15px 10px",font:"400 10px/2 'IBM Plex Mono',monospace",color:"var(--proto-muted)"},children:l.fields.map(f=>o.jsxs("div",{style:{display:"flex"},children:[o.jsx("span",{style:{color:"var(--proto-muted-3)"},children:f.k}),o.jsx("span",{style:{marginLeft:"auto",color:f.vColor,textAlign:"right"},children:f.v})]},f.k))})]}),o.jsxs("div",{style:Xs,children:[o.jsx("div",{style:Uh,children:o.jsx("span",{style:Hh,children:a.tkDependencies})}),o.jsx("div",{style:{padding:"10px 15px",display:"flex",flexDirection:"column",gap:5},children:l.hasDependencies?l.deps.map(f=>o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 9px",background:f.bg,border:`1px solid ${f.border}`,borderRadius:7},children:[o.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:f.dotColor,flex:"none"}}),o.jsx("span",{style:{font:"600 10.5px 'IBM Plex Mono',monospace",color:f.idColor},children:f.id}),o.jsx("span",{style:{fontSize:10.5,color:"var(--proto-muted)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:f.name}),o.jsx("span",{style:{marginLeft:"auto",font:"400 8.5px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)",flex:"none"},children:f.label})]},`${f.label}:${f.id}`)):o.jsxs(Bs,{children:["— ",a.tkNoDependencies]})})]}),o.jsxs("div",{style:{...Xs,padding:"11px 14px",display:"flex",gap:8},children:[l.canUnblock&&o.jsx("span",{onClick:()=>!n&&s(e),style:{flex:1,textAlign:"center",fontSize:11,fontWeight:600,border:"1px solid var(--proto-line-3)",borderRadius:8,padding:"6px 0",color:"var(--proto-ink)",cursor:n?"not-allowed":"pointer",opacity:n?.5:1},children:a.mUnblock}),o.jsx("span",{"data-complete-task-id":e.id,onClick:()=>l.completable&&!n&&i(e),style:{flex:1.3,textAlign:"center",fontSize:11,fontWeight:600,borderRadius:8,padding:"7px 0",color:"var(--ink-solid-fg)",background:l.completeBg,cursor:l.completable&&!n?"pointer":"not-allowed",opacity:n?.6:1},children:l.completeLabel})]})]})]})]})]})}function rH(e,t){return t.type==="open"?{projectId:t.projectId,taskId:t.taskId}:null}const W6=p.createContext(null);function oH(e){const t=le(),n=je(),r=()=>n.invalidateQueries(t.tasks.list.queryFilter()),i=xe(t.tasks.complete.mutationOptions({onSettled:()=>{e(),r()}})),s=xe(t.tasks.unblock.mutationOptions({onSettled:()=>void r()}));return{completeTask:c=>i.mutate({projectId:c.project,taskId:c.id,note:"completed via Web UI"}),unblockTask:c=>s.mutate({projectId:c.project,taskId:c.id}),pending:i.isPending||s.isPending}}function iH({selection:e,onClose:t}){const n=le(),r=Y(n.tasks.list.queryOptions({projectId:e.projectId})),i=oH(t),s=r.data??[],a=s.find(l=>l.id===e.taskId);return a?o.jsx(nH,{task:a,allTasks:s,pending:i.pending,onClose:t,onComplete:i.completeTask,onUnblock:i.unblockTask}):null}function sH({children:e}){const[t,n]=p.useReducer(rH,null),r=p.useCallback((a,l)=>{n({type:"open",projectId:a,taskId:l})},[]),i=p.useCallback(()=>n({type:"close"}),[]),s=p.useMemo(()=>({openTask:r,closeTask:i}),[r,i]);return o.jsxs(W6.Provider,{value:s,children:[e,t&&o.jsx(iH,{selection:t,onClose:i})]})}function U6(){const e=p.useContext(W6);if(!e)throw new Error("useTaskModal must be used within a TaskModalProvider");return e}const vv={en:{title:"Notes",inputPlaceholder:"Note something to do…",quickPlaceholder:"Quick note…",todo:"TO DO",completed:"Completed",clear:"Clear",handoff:"Hand to agent",edit:"Edit",save:"Save",cancel:"Cancel",delete:"Delete",viewAll:"View all",empty:"No open notes",privateHint:"Private reminder · agents do not read this file",enter:"↵",escape:"esc"},zh:{title:"笔记",inputPlaceholder:"记一条要干什么…",quickPlaceholder:"快速记一条…",todo:"待办",completed:"已完成",clear:"清除",handoff:"交给 agent",edit:"编辑",save:"保存",cancel:"取消",delete:"删除",viewAll:"查看全部",empty:"没有未完成笔记",privateHint:"私人备忘 · agent 不读取此文件",enter:"↵",escape:"esc"}};function aH(e,t){return e===1?t==="zh"?"昨天":"yesterday":t==="zh"?`${Math.max(2,e)} 天前`:`${Math.max(2,e)}d`}function lH(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function cH(e){const t=String(e.getHours()).padStart(2,"0"),n=String(e.getMinutes()).padStart(2,"0");return`${t}:${n}`}function dH(e,t,n){const r=Date.parse(e);if(Number.isNaN(r))return"—";const i=new Date(r);if(lH(i,new Date(t)))return cH(i);const s=Math.max(1,Math.floor((t-r)/864e5));return aH(s,n)}function uH(e,t,n){return{...e,timeLabel:dH(e.createdAt,t,n)}}function H6(e,t,n){const r=e.map(a=>uH(a,t,n)),i=r.filter(a=>!a.completed),s=r.filter(a=>a.completed);return{active:i,completed:s,previews:i.slice(0,3),activeCount:i.length,completedCount:s.length}}function pH(e){return(e.metaKey||e.ctrlKey)&&e.shiftKey&&!e.altKey&&e.key.toLowerCase()==="n"}const V6=p.createContext(null);function fH(e){const[t,n]=p.useState(!1),[r,i]=p.useState(null),s=p.useCallback(l=>{i(l??null),n(!0)},[]),a=p.useCallback(()=>{n(!1),i(null)},[]);return p.useEffect(()=>a(),[e,a]),p.useEffect(()=>{const l=c=>{pH(c)&&(c.preventDefault(),i(null),n(d=>!d))};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[]),{isOpen:t,targetId:r,open:s,close:a}}function hH(e){const t=le(),n=je(),r=()=>n.invalidateQueries(t.notes.list.queryFilter({projectId:e})),i=xe(t.notes.add.mutationOptions({onSettled:r})),s=xe(t.notes.update.mutationOptions({onSettled:r})),a=xe(t.notes.setCompleted.mutationOptions({onSettled:r})),l=xe(t.notes.delete.mutationOptions({onSettled:r})),c=xe(t.notes.clearCompleted.mutationOptions({onSettled:r}));return{busy:i.isPending||s.isPending||a.isPending||l.isPending||c.isPending,add:d=>i.mutateAsync({projectId:e,text:d}),update:(d,u)=>s.mutateAsync({projectId:e,id:d,text:u}),setCompleted:(d,u)=>a.mutateAsync({projectId:e,id:d,completed:u}),remove:async d=>{await l.mutateAsync({projectId:e,id:d})},clearCompleted:async()=>{await c.mutateAsync({projectId:e})}}}function gH({children:e}){const t=le(),n=ut(),{currentProjectId:r}=Ei(),{prefillDraft:i}=bs(),s=r??"",a=fH(s),l=hH(s),c=Y({...t.notes.list.queryOptions({projectId:s}),enabled:!!s}),d=p.useMemo(()=>H6(c.data??[],Date.now(),n),[c.data,n]),u=p.useMemo(()=>({copy:vv[n],vm:d,...a,...l,handoff:f=>{i(f),a.close()}}),[n,d,a,l,i]);return o.jsx(V6.Provider,{value:u,children:e})}function Pf(){const e=p.useContext(V6);if(!e)throw new Error("useNotes must be used within NotesProvider");return e}function xH(){const{open:e,setOpen:t}=qB();return o.jsx(t6,{children:o.jsx(z6,{children:o.jsx(BW,{children:o.jsx(GW,{children:o.jsx(gH,{children:o.jsx(pW,{children:o.jsx(EW,{children:o.jsx($W,{children:o.jsx(h$,{children:o.jsx(aU,{children:o.jsx(jB,{children:o.jsx(sH,{children:o.jsx(dF,{children:o.jsx(wC,{children:o.jsxs(PC,{children:[o.jsx(RD,{}),o.jsx(VB,{open:e,onOpenChange:t}),o.jsx(yU,{}),o.jsx(LU,{}),o.jsx(NU,{})]})})})})})})})})})})})})})})})}function mH({title:e}){const t=H();return o.jsxs("section",{className:"flex h-full flex-col p-2g",children:[o.jsx("h1",{className:"mb-2g text-body font-medium text-state-ink",children:e}),o.jsx(Mu,{title:t.shNothingHere,className:"flex-1"})]})}const q6="'IBM Plex Mono',monospace",vH="Click an image or file to preview it here.";function yH({item:e}){const{src:t,failed:n}=bC(e),{containerRef:r,contentRef:i,style:s}=tv({mode:"transform",minScale:1,maxScale:8});return n?o.jsxs(qx,{failed:!0,children:["Failed to load ",e.name]}):t?o.jsx("div",{ref:r,style:{flex:1,minHeight:0,display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",padding:12,boxSizing:"border-box"},children:e.kind==="video"?o.jsx("video",{src:t,controls:!0,playsInline:!0,style:{maxWidth:"100%",maxHeight:"100%",borderRadius:8,background:"#000"}}):o.jsx("div",{ref:i,style:{...s,display:"inline-block",maxWidth:"100%",maxHeight:"100%"},children:o.jsx("img",{src:t,alt:e.name,draggable:!1,style:{maxWidth:"100%",maxHeight:"100%",objectFit:"contain",display:"block"}})})}):o.jsx(qx,{children:"Loading…"})}function qx({children:e,failed:t}){return o.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",padding:"32px 20px",textAlign:"center",color:t?"var(--proto-faint)":"var(--proto-muted-2)",font:`500 12px ${q6}`},children:e})}function bH({item:e,split:t,onClose:n,onResizeStart:r,onDownload:i,rootRef:s}){const a=!!e&&Ub(e),l=e?vC(e):null;return o.jsxs("div",{ref:s,"data-pane":"preview",style:{flexGrow:t,flexShrink:1,flexBasis:0,minWidth:0,display:"flex",flexDirection:"column",minHeight:0,background:"var(--proto-card)",borderLeft:"1px solid var(--proto-line)",position:"relative"},children:[o.jsx("div",{role:"separator","aria-orientation":"vertical",title:"Drag to resize",onMouseDown:r,style:{position:"absolute",left:-3,top:0,bottom:0,width:6,cursor:"col-resize",zIndex:3}}),o.jsxs("div",{style:{height:50,flex:"none",borderBottom:"1px solid var(--proto-line)",display:"flex",alignItems:"center",gap:8,padding:"0 12px"},children:[o.jsx("span",{title:e==null?void 0:e.name,style:{flex:1,minWidth:0,font:`600 11.5px ${q6}`,color:"var(--proto-ink)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:(e==null?void 0:e.name)??"Preview"}),l&&o.jsx("span",{role:"button",title:"Download",onClick:i,style:vj,children:"↓"}),o.jsx("span",{role:"button",title:"Unpin preview",onClick:n,style:{...vj,fontSize:16},children:"×"})]}),o.jsx("div",{style:a?{flex:1,minHeight:0,overflow:"auto",background:(e==null?void 0:e.kind)==="pdf"?"var(--proto-gray)":"var(--proto-card)"}:{flex:1,minHeight:0,display:"flex",flexDirection:"column",overflow:"hidden"},children:e?Ub(e)?e.kind==="pdf"?o.jsx(TC,{item:e}):o.jsx(EC,{item:e}):o.jsx(yH,{item:e}):o.jsx(qx,{children:vH})})]})}const vj={width:28,height:28,borderRadius:8,border:"1px solid var(--proto-line)",background:"var(--proto-card)",color:"var(--proto-muted)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:13,cursor:"pointer",flex:"none",userSelect:"none"};function jH(){const{pinned:e,item:t,split:n,unpin:r,setSplit:i,registerHost:s}=Cf(),a=p.useRef(null),l=xl();p.useEffect(()=>s(),[s]);const c=u=>{u.preventDefault();const f=a.current,h=f==null?void 0:f.previousElementSibling;if(!f||!h)return;const g=f.getBoundingClientRect(),v=h.getBoundingClientRect(),x=v.left,b=v.width+g.width;let j=n;const y=k=>{j=aF(x,b,k.clientX),i(j)},w=()=>{window.removeEventListener("mousemove",y),window.removeEventListener("mouseup",w),document.body.style.userSelect="",i(j,!0)};document.body.style.userSelect="none",window.addEventListener("mousemove",y),window.addEventListener("mouseup",w)};if(!e)return null;const d=t?vC(t):null;return o.jsx(bH,{rootRef:a,item:t,split:n,onClose:r,onResizeStart:c,onDownload:d&&t?()=>l(d,t.name):void 0})}function Nu(e){const t=Date.parse(e.lastUsedAt||e.createdAt);return Number.isNaN(t)?0:t}function yj(e){const t=new Date(e);return Math.floor(new Date(t.getFullYear(),t.getMonth(),t.getDate()).getTime()/864e5)}function K6(e,t){const n=typeof t=="number"?t:t.getTime(),r=yj(n),i={TODAY:[],YESTERDAY:[],EARLIER:[]};for(const a of e){const l=yj(Nu(a)),c=l>=r?"TODAY":l===r-1?"YESTERDAY":"EARLIER";i[c].push(a)}return["TODAY","YESTERDAY","EARLIER"].map(a=>({label:a,items:i[a].sort((l,c)=>+!!c.unread-+!!l.unread||Nu(c)-Nu(l))})).filter(a=>a.items.length>0)}function wH(e,t){switch(t){case"TODAY":return e.wbSessionToday;case"YESTERDAY":return e.wbSessionYesterday;case"EARLIER":return e.wbSessionEarlier}}function bj(e){return e<10?"0"+e:""+e}function kH(e,t){const n=new Date(Nu(t)),r=bj(n.getHours())+":"+bj(n.getMinutes());return t.kind==="scheduled"?r+" · "+e.wbFromSchedule:r}function vl(e){const t=e.split(/[-_]/).filter(Boolean);return t.length>=2?(t[0][0]+t[1][0]).toUpperCase():t.length===1?t[0].slice(0,2).toUpperCase():"?"}const SH=new Set(["running","waiting"]);function CH(e){const t={};for(const n of e)SH.has(n.status)&&(t[n.projectId]=(t[n.projectId]??0)+1);return t}function Q6(e){const t={};for(const n of e)n.unread&&(t[n.projectId]=(t[n.projectId]??0)+1);return t}function Y6(e){const t={};for(const n of e)n.awaitingInput&&(t[n.projectId]=(t[n.projectId]??0)+1);return t}function G6(e,t){const n=e+t;return{count:n,tone:t>0?"action":n>0?"unread":null}}function EH(e){switch(e){case"running":return{bg:"#EEF0FA",fg:"#4655D4",text:"Running"};case"waiting":return{bg:"#F7ECCE",fg:"#8A5B06",text:"Waiting"};case"completed":return{bg:"#E9F4EE",fg:"#23854F",text:"Done"};case"failed":return{bg:"#FBEDEB",fg:"#C03D33",text:"Failed"};default:return{bg:"#F1F2F5",fg:"#8A93A2",text:"Cancelled"}}}function TH(e){return e.status==="completed"?"done":e.status==="running"?"running":"pending"}function js(e){return"$"+e.toFixed(2)}function PH(e){const t=Math.round(e);if(t<60)return`${t}s`;const n=Math.floor(t/60),r=t%60;return r===0?`${n}m`:`${n}m ${r}s`}function RH(e){const t=[];return e.durationS!=null&&t.push(PH(e.durationS)),e.costUsd!=null&&t.push(js(e.costUsd)),t.join(" · ")}function IH(e){return e.runName?`cortex-run ${e.runName}`:"cortex-run"}function MH(e){return e==="running"?{label:"Running",tone:"running"}:e==="completed"?{label:"Done",tone:"done"}:e==="failed"||e==="cancelled"?{label:"Failed",tone:"failed"}:{label:e||"Unknown",tone:"idle"}}function LH(e){return e.status==="done"?{label:"Done",tone:"done"}:e.blockedBy?{label:"Blocked",tone:"failed"}:e.claimedBy?{label:"Running",tone:"running"}:e.actionable?{label:"Open",tone:"idle"}:{label:"Waiting",tone:"idle"}}function X6(e,t){const n=Math.max(0,Math.round((t-Date.parse(e))/1e3));if(n<60)return"just now";const r=Math.floor(n/60);if(r<60)return`${r}m`;const i=Math.floor(r/60);return i<24?`${i}h`:`${Math.floor(i/24)}d`}function OH(e,t){const n=[e.id];return e.taskId&&n.push(`task ${e.taskId}`),e.currentStep&&n.push(`step ${e.currentStep.index+1}/${e.totalSteps}`),n.push(X6(e.createdAt,t)),n.join(" · ")}function AH(e){const t=X0(e.children);return{filled:t,total:hs,text:`${t}/${hs}`}}function DH(e){return e?e.filter(t=>t.online).length:0}function NH(e){return e?{bg:"#E9F4EE",fg:"#23854F",text:"Online"}:{bg:"#F1F2F5",fg:"#8A93A2",text:"Offline"}}function _H(e,t){const n=Math.max(0,t-e);return n<6e4?"now":n<36e5?Math.floor(n/6e4)+"m":n<864e5?Math.floor(n/36e5)+"h":Math.floor(n/864e5)+"d"}function J6(e){const t={};for(const n of e){const r=Date.parse(n.lastUsedAt||n.createdAt);Number.isNaN(r)||(!(n.projectId in t)||r>t[n.projectId])&&(t[n.projectId]=r)}return t}function Z6(e,t){const n=r=>typeof t[r]=="number"?t[r]:-1/0;return[...e].sort((r,i)=>{const s=n(r.id),a=n(i.id);return s===a?0:a-s})}function $H(e){const t=e.split(/[-_]/).filter(Boolean);return t.length<=2?e:t[0]+"-"+t[1]}function FH(e){return e.length!==1||e<"1"||e>"9"?null:e.charCodeAt(0)-49}const Kx=322,zH=120,BH=560;function e3(e){return Number.isFinite(e)?Math.min(BH,Math.max(zH,e)):Kx}function WH(e,t,n,r,i,s,a={}){return e.map((l,c)=>{const d=l.id===t,u=n[l.id]??0,f=r[l.id]??0,h=a[l.id]??0,g=G6(f,h),v=u>0||g.count>0,x=i[l.id],b=!d&&!v&&typeof x=="number"?_H(x,s):null;return{id:l.id,initials:vl(l.id),active:d,running:u,unread:f,actionRequired:h,badgeCount:g.count,badgeTone:g.tone,hotkey:b===null&&c<9?"⌘"+(c+1):null,idleAge:b}})}const UH="context/projects/",HH="nimbus";function jj(e){return e.trim().length>0}function VH(e){const t=e&&typeof e=="object"&&"message"in e?e.message:void 0;return typeof t=="string"&&t.trim().length>0?t:"Could not create project."}const Vh="'IBM Plex Mono',monospace";function qH({onClose:e}){const t=le(),n=H(),r=je(),[i,s]=p.useState(""),[a,l]=p.useState(null),[c,d]=p.useState(!1),u=p.useRef(null),f=xe(t.projects.create.mutationOptions({onSuccess:()=>{r.invalidateQueries(t.projects.list.queryFilter()),e()},onError:v=>l(VH(v))})),h=()=>{!jj(i)||f.isPending||(l(null),f.mutate({name:i.trim()}))};p.useEffect(()=>{const v=x=>{x.key==="Escape"&&e()};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[e]);const g=jj(i);return o.jsxs(o.Fragment,{children:[o.jsx("div",{onClick:e,style:{position:"fixed",inset:0,background:"rgba(25,28,34,.34)",zIndex:60,animation:"cxfade .18s ease"}}),o.jsxs("div",{"data-modal":"newproj",style:{position:"fixed",left:"50%",top:"50%",transform:"translate(-50%,-50%)",animation:"cxmodal .26s cubic-bezier(.22,1,.36,1)",width:540,background:"var(--proto-card)",borderRadius:14,boxShadow:"0 24px 64px rgba(16,24,40,.3)",zIndex:61,overflow:"hidden"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"14px 20px 0"},children:[o.jsx("span",{style:{fontSize:14,fontWeight:700,color:"var(--proto-ink)"},children:n.newProject}),o.jsx("span",{style:{font:`400 10px ${Vh}`,color:"var(--proto-muted-3)",marginLeft:10},children:UH}),o.jsx("span",{onClick:e,style:{marginLeft:"auto",font:`500 9.5px ${Vh}`,color:"var(--proto-muted-3)",border:"1px solid var(--proto-line)",borderRadius:5,padding:"2px 6px",cursor:"pointer"},children:"esc"})]}),o.jsxs("div",{style:{padding:"16px 20px 0"},children:[o.jsx("div",{style:{fontSize:9.5,fontWeight:700,letterSpacing:".05em",color:"var(--proto-muted-3)",marginBottom:6},children:n.npProjectName}),o.jsx("div",{style:{display:"flex",alignItems:"center",gap:8,border:"1.5px solid var(--proto-accent-border)",borderRadius:9,padding:"9px 12px"},children:o.jsx("input",{ref:u,value:i,onChange:v=>{s(v.target.value),a&&l(null)},onKeyDown:v=>{v.key==="Enter"&&h()},autoFocus:!0,placeholder:HH,style:{flex:1,font:`500 13px ${Vh}`,color:"var(--proto-ink)"}})}),o.jsx("div",{style:{fontSize:10.5,color:a?"var(--proto-danger)":"var(--proto-muted-3)",marginTop:8,lineHeight:1.6},children:a??n.npHint})]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"16px 20px 16px",justifyContent:"flex-end"},children:[o.jsx("span",{onClick:e,onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),style:{fontSize:11.5,fontWeight:600,border:"1px solid var(--proto-line-3)",borderRadius:8,padding:"6px 13px",color:"var(--proto-ink)",cursor:"pointer",background:c?"var(--proto-alt)":"transparent"},children:n.cancel}),o.jsx("span",{onClick:h,style:{fontSize:11.5,fontWeight:600,borderRadius:8,padding:"7px 15px",color:"var(--ink-solid-fg)",background:g?"#4655D4":"#C9CFF2",cursor:g&&!f.isPending?"pointer":"default"},children:n.npCreate})]})]})]})}const KH="connect.html";function QH(){var e;return(e=globalThis.__TAURI__)==null?void 0:e.core}async function YH(e){var t;try{await((t=e.invoke)==null?void 0:t.call(e,"disconnect"))}catch{}finally{e.navigate(KH)}}async function t3(){if(!Kt())return;const e=QH();await YH({invoke:e?t=>e.invoke(t):void 0,navigate:t=>{window.location.href=t}})}function wj(e){return e==="running"?"var(--proto-success)":e==="unknown"?"var(--proto-amber)":"var(--proto-danger)"}function GH(e){return e==="running"?"var(--proto-success-bg)":e==="unknown"?"var(--pill-waiting-bg)":"var(--proto-danger-bg)"}function XH({open:e,onClose:t}){const n=le(),r=je(),i=H(),[s,a]=p.useState(!1),l=Y({...n.system.daemonStatus.queryOptions({}),enabled:e,refetchInterval:e?5e3:!1}),c=xe({...n.system.restart.mutationOptions({onSuccess:()=>{a(!1),r.invalidateQueries(n.system.daemonStatus.queryFilter())},onError:()=>{a(!1)}})}),d=l.data,u=(d==null?void 0:d.processes)??[],f=d==null?void 0:d.lastRestart,h=()=>c.mutate({kind:"soft"}),g=()=>c.mutate({kind:"hard"});return e?o.jsxs(o.Fragment,{children:[o.jsx("div",{onClick:t,style:{position:"fixed",inset:0,zIndex:40,background:"rgba(25, 28, 34, 0.40)"}}),o.jsxs("div",{style:{position:"fixed",left:"50%",top:"50%",transform:"translate(-50%, -50%)",zIndex:50,width:470,background:"var(--proto-card)",border:"1px solid var(--proto-line)",borderRadius:14,boxShadow:"0 8px 24px rgba(16,24,40,.10)",overflow:"hidden"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"16px 20px 14px",borderBottom:"1px solid var(--proto-line-2)"},children:[o.jsx("div",{style:{width:28,height:28,borderRadius:8,background:"var(--proto-ink)",color:"var(--ink-solid-fg)",display:"flex",alignItems:"center",justifyContent:"center",font:"600 12px 'IBM Plex Mono',monospace"},children:"cx"}),o.jsxs("div",{style:{minWidth:0},children:[o.jsx("div",{style:{fontSize:14,fontWeight:700,color:"var(--proto-ink)"},children:i.dmDaemon}),o.jsx("div",{style:{font:"400 10px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)",marginTop:1},children:"local"})]}),o.jsx("span",{onClick:t,style:{marginLeft:"auto",font:"500 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)",border:"1px solid var(--proto-line)",borderRadius:5,padding:"2px 6px",cursor:"pointer"},children:"esc"})]}),o.jsxs("div",{style:{padding:"14px 20px",display:"flex",flexDirection:"column",gap:10},children:[l.isLoading&&o.jsx("div",{style:{fontSize:12,color:"var(--proto-muted-3)",textAlign:"center",padding:20},children:"Loading…"}),l.isError&&o.jsx("div",{style:{fontSize:12,color:"var(--proto-danger)",textAlign:"center",padding:20},children:"Failed to load daemon status"}),u.map(v=>{const x=v.status;return o.jsxs("div",{style:{border:"1px solid var(--proto-line)",borderRadius:10,padding:"11px 14px"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[o.jsx("span",{style:{width:7,height:7,borderRadius:"50%",background:wj(x),flex:"none",...x==="unknown"?{animation:"cxpulse 2s ease-in-out infinite"}:{}}}),o.jsx("span",{style:{font:"600 12px 'IBM Plex Mono',monospace",color:"var(--proto-ink)"},children:v.name}),o.jsx("span",{style:{font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)"},children:v.label}),o.jsx("span",{style:{marginLeft:"auto",fontSize:10.5,fontWeight:600,padding:"2px 8px",borderRadius:999,background:GH(x),color:wj(x)},children:x})]}),o.jsxs("div",{style:{display:"flex",gap:14,marginTop:8,font:"400 10px 'IBM Plex Mono',monospace",color:"var(--proto-muted)",flexWrap:"wrap"},children:[v.uptime&&o.jsxs("span",{children:[o.jsxs("span",{style:{color:"var(--proto-muted-3)"},children:[i.dmUp," "]}),v.uptime]}),v.pid!=null&&o.jsxs("span",{children:[o.jsxs("span",{style:{color:"var(--proto-muted-3)"},children:[i.dmPid," "]}),v.pid]}),v.port!=null&&o.jsxs("span",{children:[o.jsxs("span",{style:{color:"var(--proto-muted-3)"},children:[i.dmPort," "]}),":",v.port]}),v.extras&&Object.entries(v.extras).map(([b,j])=>o.jsxs("span",{children:[o.jsxs("span",{style:{color:"var(--proto-muted-3)"},children:[b," "]}),j]},b))]})]},v.name)}),(f==null?void 0:f.at)&&o.jsxs("div",{style:{font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-faint)",padding:"0 2px"},children:[i.dmLastRestart," ",new Date(f.at).toLocaleDateString()," ",new Date(f.at).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),f.reason?` · ${i.dmReason}: ${f.reason}`:""]})]}),!s&&o.jsxs("div",{style:{borderTop:"1px solid var(--proto-line-2)",padding:"12px 20px",display:"flex",flexDirection:"column",gap:8},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[o.jsxs("div",{style:{minWidth:0,flex:1},children:[o.jsx("div",{style:{fontSize:12,fontWeight:600,color:"var(--proto-ink)"},children:i.dmSoftRestart}),o.jsx("div",{style:{fontSize:10.5,color:"var(--proto-muted-2)",marginTop:1},children:i.dmSoftRestartDesc})]}),o.jsx("span",{onClick:h,style:{flex:"none",fontSize:11.5,fontWeight:600,color:"var(--proto-ink)",border:"1px solid var(--proto-line-3)",background:"var(--proto-card)",borderRadius:8,padding:"6px 14px",cursor:c.isPending?"default":"pointer",opacity:c.isPending?.5:1},children:i.dmSoftRestart})]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[o.jsxs("div",{style:{minWidth:0,flex:1},children:[o.jsx("div",{style:{fontSize:12,fontWeight:600,color:"var(--proto-danger)"},children:i.dmHardRestart}),o.jsx("div",{style:{fontSize:10.5,color:"var(--proto-muted-2)",marginTop:1},children:i.dmHardRestartDesc})]}),o.jsx("span",{onClick:()=>a(!0),style:{flex:"none",fontSize:11.5,fontWeight:600,color:"var(--proto-danger)",border:"1px solid var(--proto-danger-bg)",background:"var(--proto-danger-bg)",borderRadius:8,padding:"6px 14px",cursor:"pointer"},children:i.dmHardRestart})]})]}),s&&o.jsxs("div",{style:{borderTop:"1px solid var(--proto-line-2)",padding:"12px 20px",display:"flex",flexDirection:"column",gap:10},children:[o.jsxs("div",{style:{border:"1px solid var(--proto-amber-border)",background:"var(--proto-amber-bg)",borderRadius:9,padding:"10px 14px"},children:[o.jsx("div",{style:{fontSize:12,fontWeight:600,color:"var(--proto-amber-fg)"},children:i.dmHardConfirm}),o.jsx("div",{style:{fontSize:11.5,color:"var(--proto-muted)",marginTop:4,lineHeight:1.5},children:i.dmHardConfirmDetail})]}),o.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[o.jsx("span",{onClick:()=>a(!1),style:{fontSize:11.5,fontWeight:600,color:"var(--proto-ink)",border:"1px solid var(--proto-line-3)",background:"var(--proto-card)",borderRadius:8,padding:"6px 14px",cursor:"pointer"},children:i.dmConfirmCancel}),o.jsx("span",{onClick:g,style:{fontSize:11.5,fontWeight:600,color:"var(--ink-solid-fg)",background:"var(--proto-danger)",borderRadius:8,padding:"6px 14px",cursor:c.isPending?"default":"pointer",opacity:c.isPending?.5:1},children:c.isPending?"...":i.dmConfirmProceed})]})]}),c.isSuccess&&o.jsx("div",{style:{borderTop:"1px solid var(--proto-line-2)",padding:"10px 20px",fontSize:11.5,color:"var(--proto-success)",fontWeight:600},children:i.dmRestartSent}),c.isError&&o.jsx("div",{style:{borderTop:"1px solid var(--proto-line-2)",padding:"10px 20px",fontSize:11.5,color:"var(--proto-danger)",fontWeight:600},children:i.dmRestartFailed}),Kt()&&o.jsxs("div",{style:{borderTop:"1px solid var(--proto-line-2)",padding:"12px 20px",display:"flex",alignItems:"center",gap:10},children:[o.jsxs("div",{style:{minWidth:0,flex:1},children:[o.jsx("div",{style:{fontSize:12,fontWeight:600,color:"var(--proto-ink)"},children:i.dmDisconnect}),o.jsx("div",{style:{fontSize:10.5,color:"var(--proto-muted-2)",marginTop:1},children:i.dmDisconnectDesc})]}),o.jsx("span",{onClick:()=>void t3(),style:{flex:"none",fontSize:11.5,fontWeight:600,color:"var(--proto-ink)",border:"1px solid var(--proto-line-3)",background:"var(--proto-card)",borderRadius:8,padding:"6px 14px",cursor:"pointer"},children:i.dmDisconnect})]})]})]}):null}const JH=["session.status","session.interaction","session.context-usage","session.context-compacted"];function yv(){const e=le(),t=je();Ci(JH,()=>{t.invalidateQueries(e.sessions.list.queryFilter())})}const Qx="0803-0459·a079d4f";function ZH(e){return e==="five_hour"?"5h":e==="seven_day"||e==="seven_day_overage_included"?"7d":e.replaceAll("_"," ")}function Yx(e){const t=Math.max(1,Math.ceil(e/60)),n=Math.floor(t/1440),r=Math.floor(t%1440/60),i=t%60;return n>0?r>0?`${n}d ${r}h`:`${n}d`:r>0?i>0?`${r}h ${i}m`:`${r}h`:`${i}m`}function eV(e,t,n){return n==="zh"?`${e} 个会话 · ${t} 个线程等待恢复`:`${e} ${e===1?"session":"sessions"} · ${t} ${t===1?"thread":"threads"} waiting`}function tV(e,t,n){const r=e.windows.filter(l=>l.resetsAt>t).sort((l,c)=>l.resetsAt-c.resetsAt||l.type.localeCompare(c.type)).map(l=>({type:l.type,typeLabel:ZH(l.type),utilization:l.utilization,resetsAt:l.resetsAt,countdown:Yx(l.resetsAt-t)}));if(r.length===0)return null;const i=Math.max(...r.map(l=>l.resetsAt)),s=e.waitingSessions??0,a=e.waitingThreads??0;return{provider:e.provider,displayName:e.displayName,recoveryAt:i,recoveryCountdown:Yx(i-t),waitingSessions:s,waitingThreads:a,waitingLabel:eV(s,a,n),windows:r}}function nV(e){const t=[...new Set(e.windows.map(n=>n.typeLabel))].join("+");return`${e.displayName} · ${t} · ${e.recoveryCountdown}`}function rV(e,t,n){return n==="zh"?`${e} 个 provider 限流 · 首个 ${t}`:`${e} providers limited · first ${t}`}function oV(e,t,n){const r=((e==null?void 0:e.providers)??[]).map(a=>tV(a,t,n)).filter(a=>a!==null).sort((a,l)=>a.displayName.localeCompare(l.displayName)||a.provider.localeCompare(l.provider));if(r.length===0)return null;const i=Math.min(...r.map(a=>a.recoveryAt)),s=Yx(i-t);return{lang:n,firstRecoveryAt:i,providers:r,label:r.length===1?nV(r[0]):rV(r.length,s,n)}}function qh(){return Math.floor(Date.now()/1e3)}function n3(){var d;const e=le(),t=je(),n=ut(),r=Y(e.system.rateLimitStatus.queryOptions({})),{reconnectEpoch:i}=dv(),[s,a]=p.useState(qh),l=()=>{t.invalidateQueries(e.system.rateLimitStatus.queryFilter())};Ci(e6,l),p.useEffect(()=>{i>0&&l()},[i]);const c=(((d=r.data)==null?void 0:d.providers.length)??0)>0;return p.useEffect(()=>{if(!c)return;a(qh());const u=window.setInterval(()=>a(qh()),3e4);return()=>window.clearInterval(u)},[c]),oV(r.data,s,n)}const m={canvas:"var(--m-canvas)",card:"var(--m-card)",ink:"var(--m-ink)",sub:"var(--m-sub)",body:"var(--m-body)",muted:"var(--m-muted)",faint:"var(--m-faint)",hairline:"var(--m-hairline)",divider:"var(--m-divider)",cardBorder:"var(--m-card-border)",run:"var(--m-run)",runBg:"var(--m-run-bg)",runBorder:"var(--m-run-border)",amber:"var(--m-amber)",amberInk:"var(--m-amber-ink)",amberText:"var(--m-amber-text)",amberBg:"var(--m-amber-bg)",amberBorder:"var(--m-amber-border)",amberCard:"var(--m-amber-card)",done:"var(--m-done)",doneBg:"var(--m-done-bg)",fail:"var(--m-fail)",failBg:"var(--m-fail-bg)",failBorder:"var(--m-fail-border)",gray:"var(--m-gray)",grayInk:"var(--m-gray-ink)",inkSolid:"var(--ink-solid-bg)",inkSolidFg:"var(--ink-solid-fg)",inkSolidFgDim:"var(--ink-solid-fg-dim)"},N="'IBM Plex Mono', ui-monospace, Menlo, monospace";function gt({header:e,footer:t,children:n,label:r,style:i}){return o.jsxs("div",{"data-screen-label":r,style:{height:"100%",display:"flex",flexDirection:"column",boxSizing:"border-box",background:m.canvas,...i},children:[e,o.jsx("div",{style:{flex:1,minHeight:0,overflow:"auto",background:m.canvas},children:n}),t]})}function Rf({title:e,qn:t,trailing:n,below:r}){return o.jsxs("div",{style:{flex:"none",borderBottom:`1px solid ${m.hairline}`,background:m.canvas,padding:"6px 14px 10px",paddingTop:"calc(6px + env(safe-area-inset-top))"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[o.jsx("span",{style:{fontSize:22,fontWeight:700,color:m.ink,letterSpacing:"-.02em",flex:"none"},children:e}),t&&o.jsx("span",{style:{font:`600 9.5px ${N}`,color:m.run,background:m.runBg,padding:"2px 7px",borderRadius:4,marginLeft:9,flex:"none"},children:t}),n&&o.jsx("div",{style:{marginLeft:"auto",display:"flex",alignItems:"center"},children:n})]}),r]})}function En({onBack:e,children:t,trailing:n}){return o.jsxs("div",{style:{flex:"none",display:"flex",alignItems:"center",gap:9,borderBottom:`1px solid ${m.hairline}`,background:m.canvas,padding:"8px 14px 10px",paddingTop:"calc(8px + env(safe-area-inset-top))"},children:[o.jsx("button",{type:"button","aria-label":"Back",onClick:e,style:{border:"none",background:"transparent",color:m.run,fontSize:22,lineHeight:1,padding:"0 2px",margin:0,cursor:"pointer",flex:"none",minHeight:44,minWidth:30,display:"flex",alignItems:"center"},children:"‹"}),t,n&&o.jsx("div",{style:{marginLeft:"auto",flex:"none"},children:n})]})}function r3({onClick:e}){return o.jsx("button",{type:"button","aria-label":"More",onClick:e,style:{width:34,height:34,borderRadius:"50%",background:m.card,border:`1px solid ${m.hairline}`,display:"flex",alignItems:"center",justifyContent:"center",color:m.muted,fontSize:14,letterSpacing:1,cursor:"pointer"},children:"⋯"})}function gn({children:e,gap:t=10}){return o.jsxs("div",{style:{padding:"12px 14px 0",display:"flex",flexDirection:"column",gap:t},children:[e,o.jsx("div",{style:{height:"calc(20px + env(safe-area-inset-bottom))",flex:"none"}})]})}const iV={default:m.cardBorder,blue:m.runBorder,amber:m.amberBorder,fail:m.failBorder};function $e({tone:e="default",radius:t=12,padding:n="11px 13px",onClick:r,children:i,style:s}){return o.jsx("div",{onClick:r,style:{background:m.card,border:`1px solid ${iV[e]}`,borderRadius:t,padding:n,boxSizing:"border-box",cursor:r?"pointer":void 0,...s},children:i})}const sV={running:{bg:m.runBg,fg:m.run},waiting:{bg:m.amberBg,fg:m.amberInk},done:{bg:m.doneBg,fg:m.done},failed:{bg:m.failBg,fg:m.fail},cancelled:{bg:m.gray,fg:m.grayInk}};function en({tone:e,children:t}){const n=sV[e];return o.jsx("span",{style:{fontSize:10,fontWeight:600,padding:"2px 8px",borderRadius:999,background:n.bg,color:n.fg,flex:"none",whiteSpace:"nowrap"},children:t})}function o3(e){switch(e){case"running":return"running";case"waiting":case"rate_limited":return"waiting";case"completed":case"done":return"done";case"failed":case"aborted":return"failed";case"cancelled":return"cancelled";default:return"running"}}function li({color:e,size:t=6,pulse:n=!1,style:r}){return o.jsx("span",{style:{width:t,height:t,borderRadius:"50%",background:e,flex:"none",display:"inline-block",animation:n?"cxpulse 1.6s ease-in-out infinite":void 0,...r}})}function jd({children:e,style:t}){return o.jsx("div",{style:{fontSize:9.5,fontWeight:700,letterSpacing:".07em",color:m.faint,padding:"0 2px 2px",...t},children:e})}const Kh=300,kj="cubic-bezier(.32,.72,0,1)";function aV(e,t,n){return e>t*.28||n>.55}function Ti({onClose:e,children:t,behind:n}){var k;const r=p.useRef(null),[i,s]=p.useState("enter"),[a,l]=p.useState(0),[c,d]=p.useState(!1),u=p.useRef(null),f=p.useRef(!1);p.useEffect(()=>{let S=0;const T=requestAnimationFrame(()=>{S=requestAnimationFrame(()=>s("open"))});return()=>{cancelAnimationFrame(T),cancelAnimationFrame(S)}},[]);const h=p.useCallback(()=>{f.current||(f.current=!0,d(!1),s("exit"),window.setTimeout(e,Kh))},[e]);ev(h);const g=p.useCallback(S=>{var C,P;if(f.current)return;(P=(C=S.currentTarget).setPointerCapture)==null||P.call(C,S.pointerId);const T=performance.now();u.current={startY:S.clientY,lastY:S.clientY,lastT:T,v:0},d(!0)},[]),v=p.useCallback(S=>{const T=u.current;if(!T)return;const C=performance.now(),P=Math.max(0,S.clientY-T.startY),I=C-T.lastT;I>0&&(T.v=(S.clientY-T.lastY)/I),T.lastY=S.clientY,T.lastT=C,l(P)},[]),x=p.useCallback(()=>{var C;const S=u.current;u.current=null,d(!1);const T=((C=r.current)==null?void 0:C.offsetHeight)??320;aV(a,T,(S==null?void 0:S.v)??0)?h():l(0)},[a,h]),b=i==="enter"||i==="exit",j=b?"100%":`${a}px`,y=((k=r.current)==null?void 0:k.offsetHeight)??1,w=b?0:Math.max(0,.38*(1-a/y));return o.jsxs("div",{style:{position:"absolute",inset:0,boxSizing:"border-box"},children:[n&&o.jsx("div",{style:{position:"absolute",inset:0},children:n}),o.jsx("div",{onClick:h,style:{position:"absolute",inset:0,background:"rgba(25,28,34,1)",opacity:w,transition:c?"none":`opacity ${Kh}ms ${kj}`}}),o.jsxs("div",{ref:r,style:{position:"absolute",left:0,right:0,bottom:0,background:"var(--proto-alt)",borderRadius:"18px 18px 0 0",boxShadow:"0 -14px 44px rgba(16,24,40,.28)",padding:"8px 14px 36px",paddingBottom:"calc(36px + env(safe-area-inset-bottom))",boxSizing:"border-box",transform:`translateY(${j})`,transition:c?"none":`transform ${Kh}ms ${kj}`,touchAction:"none",willChange:"transform"},children:[o.jsx("div",{onPointerDown:g,onPointerMove:v,onPointerUp:x,onPointerCancel:x,style:{margin:"-8px -14px 0",padding:"10px 14px 6px",cursor:"grab",touchAction:"none"},children:o.jsx("div",{style:{width:36,height:5,borderRadius:999,background:"var(--proto-line-3)",margin:"0 auto 12px"}})}),t]})]})}function i3(e){return e===""?1:e.split(`
|
|
137
|
+
`).length}function lV(e){return[...e].length}function cV(e,t,n){return`${i3(e)} ${t} · ${lV(e)} ${n}`}const s3=20,a3=12,l3=46,Sj=5*s3+2*a3;function dV(){return o.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:m.muted,strokeWidth:"1.5",children:o.jsx("path",{d:"M6 1h3v3M4 9H1V6M9 1 5.8 4.2M1 9l3.2-3.2"})})}function uV(){return o.jsx("svg",{width:"11",height:"11",viewBox:"0 0 10 10",fill:"none",stroke:m.muted,strokeWidth:"1.5",children:o.jsx("path",{d:"M9 1 5.8 4.2m0 0H8.6M5.8 4.2V1.4M1 9l3.2-3.2m0 0H1.4m2.8 0v2.8"})})}function c3({size:e=16}){return o.jsx("svg",{width:e,height:e,viewBox:"0 0 16 16",fill:"none",stroke:"var(--ink-solid-fg)",strokeWidth:"1.8",children:o.jsx("path",{d:"M8 13V3M3.5 7.5 8 3l4.5 4.5"})})}function pV({enabled:e,onSend:t}){return o.jsx("button",{type:"button","aria-label":"Send",disabled:!e,onClick:t,style:{flex:"none",width:38,height:38,marginBottom:4,borderRadius:12,background:m.card,border:`1.5px solid ${e?m.ink:"var(--proto-line-3)"}`,display:"flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box",opacity:e?1:.45,cursor:e?"pointer":"default"},children:o.jsx("svg",{width:15,height:15,viewBox:"0 0 16 16",fill:"none",stroke:m.ink,strokeWidth:"1.8",children:o.jsx("path",{d:"M8 13V3M3.5 7.5 8 3l4.5 4.5"})})})}function fV(e,t,n,r){p.useEffect(()=>{const i=e.current;if(!i)return;i.style.height="auto";const s=i.scrollHeight;i.style.height=`${Math.min(s,n)}px`,i.style.overflowY=s>n?"auto":"hidden",r(s>l3+2)},[e,t,n,r])}function hV({placeholder:e,above:t,leading:n,sendEnabled:r=!0,value:i,onChange:s,onSend:a,running:l=!1,onStop:c,stopEnabled:d=!0,lineUnit:u="行",charUnit:f="字",onPlus:h,tone:g="default"}){const v=p.useRef(null),[x,b]=p.useState(!1),[j,y]=p.useState(!1),[w,k]=p.useState(()=>i3(i??"")>1);fV(v,i,Sj,k);const S=w&&!j;return o.jsxs("div",{style:{flex:"none",padding:"6px 14px 34px",paddingBottom:"calc(14px + env(safe-area-inset-bottom))",background:m.canvas},children:[t,o.jsxs("div",{style:{display:"flex",alignItems:"flex-end",gap:8},children:[n,o.jsxs("div",{style:{flex:1,minWidth:0,position:"relative",display:"flex",alignItems:"center",minHeight:l3,border:`1.5px solid ${g==="amber"?m.amber:g==="accent"||x?m.run:"var(--proto-line-3)"}`,borderRadius:w?16:14,background:m.card,boxShadow:g==="amber"?"0 0 0 3px rgba(201,154,46,.10)":g==="accent"||x?"0 0 0 3px rgba(70,85,212,.08)":void 0,boxSizing:"border-box",padding:`0 ${S?34:14}px 0 14px`},children:[o.jsx("textarea",{ref:v,rows:1,value:i,onChange:T=>s==null?void 0:s(T.target.value),onFocus:()=>b(!0),onBlur:()=>b(!1),placeholder:e,style:{flex:1,minWidth:0,resize:"none",border:"none",outline:"none",background:"transparent",padding:`${a3}px 0`,margin:0,maxHeight:Sj,fontSize:13.5,lineHeight:`${s3}px`,color:m.ink,fontFamily:"inherit",boxSizing:"border-box"}}),S&&o.jsx("button",{type:"button","aria-label":"Expand",onClick:()=>y(!0),style:{position:"absolute",top:9,right:9,width:22,height:22,borderRadius:7,background:"var(--m-gray)",border:"none",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer"},children:o.jsx(dV,{})})]}),l&&o.jsx(pV,{enabled:r,onSend:a}),l?o.jsx("button",{type:"button","aria-label":"Stop",disabled:!d,onClick:c,style:{flex:"none",width:46,height:46,borderRadius:14,background:m.inkSolid,border:"none",display:"flex",alignItems:"center",justifyContent:"center",opacity:d?1:.45,cursor:d?"pointer":"default"},children:o.jsx("span",{style:{width:14,height:14,background:m.inkSolidFg,borderRadius:3}})}):o.jsx("button",{type:"button","aria-label":"Send",disabled:!r,onClick:a,style:{flex:"none",width:46,height:46,borderRadius:14,background:m.inkSolid,border:"none",display:"flex",alignItems:"center",justifyContent:"center",opacity:r?1:.45,cursor:r?"pointer":"default"},children:o.jsx(c3,{})})]}),j&&o.jsx(gV,{value:i??"",placeholder:e,onChange:s,onSend:()=>{a==null||a(),y(!1)},sendEnabled:r,running:l,onStop:c,stopEnabled:d,onCollapse:()=>y(!1),onPlus:h,lineUnit:u,charUnit:f})]})}function gV({value:e,placeholder:t,onChange:n,onSend:r,sendEnabled:i=!0,running:s=!1,onStop:a,stopEnabled:l=!0,onCollapse:c,onPlus:d,onSlash:u,lineUnit:f="行",charUnit:h="字"}){const g=p.useRef(null);p.useEffect(()=>{const b=g.current;if(!b)return;b.focus();const j=b.value.length;b.setSelectionRange(j,j)},[]);const v=u??(()=>n==null?void 0:n(e?`${e}/`:"/")),x={flex:"none",width:30,height:30,borderRadius:10,border:`1px solid ${m.hairline}`,background:m.card,display:"flex",alignItems:"center",justifyContent:"center",color:m.muted,cursor:"pointer"};return o.jsx("div",{style:{position:"absolute",inset:0,zIndex:4,background:m.canvas,padding:"8px 10px",paddingBottom:"calc(8px + env(safe-area-inset-bottom))",boxSizing:"border-box",display:"flex"},children:o.jsxs("div",{style:{flex:1,minWidth:0,position:"relative",display:"flex",flexDirection:"column",overflow:"hidden",border:`1.5px solid ${m.run}`,borderRadius:18,background:m.card,boxShadow:"0 0 0 3px rgba(70,85,212,.08),0 8px 28px rgba(25,28,34,.10)",boxSizing:"border-box"},children:[o.jsx("textarea",{ref:g,value:e,onChange:b=>n==null?void 0:n(b.target.value),placeholder:t,style:{flex:1,minHeight:0,resize:"none",border:"none",outline:"none",background:"transparent",padding:"14px 40px 8px 16px",margin:0,fontSize:14.5,lineHeight:"22px",color:m.ink,fontFamily:"inherit",boxSizing:"border-box"}}),o.jsx("button",{type:"button","aria-label":"Collapse",onClick:c,style:{position:"absolute",top:11,right:11,width:26,height:26,borderRadius:8,background:"var(--m-gray)",border:"none",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer"},children:o.jsx(uV,{})}),o.jsxs("div",{style:{flex:"none",display:"flex",alignItems:"center",gap:10,padding:"8px 10px 8px 14px",borderTop:`1px solid ${m.divider}`},children:[o.jsx("button",{type:"button","aria-label":"Attach",onClick:d,style:{...x,fontSize:15,fontWeight:400},children:"+"}),o.jsx("button",{type:"button","aria-label":"Slash command",onClick:v,style:{...x,font:`600 13px ${N}`},children:"/"}),o.jsx("span",{style:{marginLeft:"auto",flex:"none",whiteSpace:"nowrap",font:`400 10px ${N}`,color:m.faint},children:cV(e,f,h)}),s&&o.jsx("button",{type:"button","aria-label":"Send",disabled:!i,onClick:r,style:{flex:"none",width:34,height:34,borderRadius:11,background:m.card,border:`1.5px solid ${i?m.ink:"var(--proto-line-3)"}`,display:"flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box",opacity:i?1:.45,cursor:i?"pointer":"default"},children:o.jsx("svg",{width:14,height:14,viewBox:"0 0 16 16",fill:"none",stroke:m.ink,strokeWidth:"1.8",children:o.jsx("path",{d:"M8 13V3M3.5 7.5 8 3l4.5 4.5"})})}),s?o.jsx("button",{type:"button","aria-label":"Stop",disabled:!l,onClick:a,style:{flex:"none",width:38,height:38,borderRadius:12,background:m.inkSolid,border:"none",display:"flex",alignItems:"center",justifyContent:"center",opacity:l?1:.45,cursor:l?"pointer":"default"},children:o.jsx("span",{style:{width:12,height:12,background:m.inkSolidFg,borderRadius:3}})}):o.jsx("button",{type:"button","aria-label":"Send",disabled:!i,onClick:r,style:{flex:"none",width:38,height:38,borderRadius:12,background:m.inkSolid,border:"none",display:"flex",alignItems:"center",justifyContent:"center",opacity:i?1:.45,cursor:i?"pointer":"default"},children:o.jsx(c3,{size:15})})]})]})})}const xV=p.forwardRef(function({label:t,...n},r){return o.jsx("button",{ref:r,type:"button",...n,"aria-label":"Rate limit status",title:t,style:{border:"1px solid var(--pill-waiting-bg)",background:"var(--pill-waiting-bg)",color:"var(--pill-waiting-fg)",borderRadius:999,padding:"3px 7px",maxWidth:178,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",font:"600 9px 'IBM Plex Mono',monospace",cursor:"pointer"},children:t})});function mV({status:e}){return e?o.jsx(H5,{trigger:o.jsx(xV,{label:e.label}),side:"bottom",align:"end",children:o.jsx(d3,{status:e})}):null}function vV({status:e,onOpen:t}){return e?o.jsx("button",{type:"button","aria-label":"Rate limit status",title:e.label,onClick:t,style:{border:`1px solid ${m.amberBorder}`,background:m.amberBg,color:m.amberText,borderRadius:999,padding:"3px 7px",maxWidth:190,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",font:`600 8.5px ${N}`,cursor:"pointer"},children:e.label}):null}function yV(e){return e.lang==="zh"?{title:"限流详情",recovers:"后恢复"}:{title:"Rate limits",recovers:"to reset"}}function d3({status:e,mobile:t=!1}){const n=yV(e),r=t?m.ink:"var(--proto-ink)",i=t?m.muted:"var(--proto-muted-2)",s=t?m.hairline:"var(--proto-line)",a=t?m.amberText:"var(--pill-waiting-fg)";return o.jsxs("div",{style:{minWidth:t?0:230,color:r},children:[o.jsx("div",{style:{fontSize:12,fontWeight:700,marginBottom:8},children:n.title}),e.providers.map((l,c)=>o.jsxs("div",{style:{borderTop:c>0?`1px solid ${s}`:"none",paddingTop:c>0?9:0,marginTop:c>0?9:0},children:[o.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:8},children:[o.jsx("span",{style:{fontSize:11,fontWeight:700},children:l.displayName}),o.jsx("span",{style:{marginLeft:"auto",font:`600 9px ${N}`,color:a},children:l.recoveryCountdown})]}),o.jsx("div",{style:{marginTop:4,color:i,font:`500 9px ${N}`},children:l.waitingLabel}),l.windows.map(d=>o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginTop:6,color:i},children:[o.jsx("span",{style:{font:`600 9.5px ${N}`},children:d.typeLabel}),o.jsxs("span",{style:{marginLeft:"auto",font:`500 9.5px ${N}`},children:[d.countdown," ",n.recovers]})]},`${d.type}:${d.resetsAt}`))]},l.provider))]})}function bV({status:e,onClose:t}){return o.jsx(Ti,{onClose:t,children:o.jsx("div",{style:{padding:"2px 18px 24px"},children:o.jsx(d3,{status:e,mobile:!0})})})}const rn="'IBM Plex Mono',monospace",u3="cortex.railProjectsH";function jV(){try{const e=window.localStorage.getItem(u3);return e===null?Kx:e3(Number(e))}catch{return Kx}}function If(){var Qt,mt;const e=ze(),t=ur(),n=le(),r=O0(),i=A0(),{open:s}=aC(),a=H(),l=B6(),c=n3(),d=$U(l),u=a[FU(l)],f=Y(n.projects.list.queryOptions({})),{currentProjectId:h,setCurrentProject:g}=Ei(),v=Y(n.sessions.list.queryOptions({origin:"direct",projectId:h??void 0}));yv();const b=(Qt=Y({...n.cost.summary.queryOptions({projectId:h??void 0}),enabled:!!h}).data)==null?void 0:Qt.today,j=typeof b=="number"?js(b):"—",y=f.data??[],w=v.data??[],S=Y(n.threads.list.queryOptions({})).data??[],T=p.useMemo(()=>CH(S),[S]),C=Y(n.sessions.list.queryOptions({origin:"direct"})),P=p.useMemo(()=>Q6(C.data??[]),[C.data]),I=p.useMemo(()=>Y6(C.data??[]),[C.data]),L=p.useMemo(()=>J6(C.data??[]),[C.data]),z=p.useMemo(()=>Z6(y,L),[y,L]),q=p.useMemo(()=>WH(z,h,T,P,L,Date.now(),I),[z,h,T,P,L,I]),[X,D]=p.useState(!1),U=pe=>{pe!==h&&g(pe),e("/workbench")},Q=p.useRef(q);Q.current=q;const J=p.useRef(U);J.current=U,p.useEffect(()=>{const pe=Oe=>{if(!(Oe.metaKey||Oe.ctrlKey)||Oe.altKey||Oe.shiftKey)return;const Se=FH(Oe.key);if(Se===null)return;const pt=Q.current[Se];pt&&(Oe.preventDefault(),J.current(pt.id))};return window.addEventListener("keydown",pe),()=>window.removeEventListener("keydown",pe)},[]);const _=p.useRef(null);p.useEffect(()=>{var Oe;if(!h)return;const pe=(Oe=_.current)==null?void 0:Oe.querySelector(`[data-project-row="${CSS.escape(h)}"]`);pe==null||pe.scrollIntoView({block:"nearest"})},[h,q.length]);const[F,W]=p.useState(jV),te=p.useRef(null),A=pe=>{pe.preventDefault(),te.current={startY:pe.clientY,startH:F};const Oe=pt=>{const wt=te.current;wt&&W(e3(wt.startH+(pt.clientY-wt.startY)))},Se=()=>{te.current=null,window.removeEventListener("mousemove",Oe),window.removeEventListener("mouseup",Se),W(pt=>{try{window.localStorage.setItem(u3,String(pt))}catch{}return pt})};window.addEventListener("mousemove",Oe),window.addEventListener("mouseup",Se)},V=p.useMemo(()=>K6(w,Date.now()),[w]),{selectedSessionId:oe,setSelectedSession:Z}=bs(),ie=FW(),ve=((mt=Y(n.approvals.list.queryOptions({status:"pending"})).data)==null?void 0:mt.length)??0,be=ve>0,jt=ve+" "+(ve>1?a.approvalsPending:a.approvalPending),At=()=>{Z("__draft__"),e("/workbench")},Re=pe=>{Z(pe),e("/workbench")},xt=p.useRef(At);xt.current=At,p.useEffect(()=>{const pe=Oe=>{WW(Oe)&&(Oe.preventDefault(),xt.current())};return window.addEventListener("keydown",pe),()=>window.removeEventListener("keydown",pe)},[]);const we=[{key:"overview",label:a.overview,to:"/overview"}],[Ie,De]=p.useState(null),[Wn,it]=p.useState(!1),qe=pe=>({onMouseEnter:()=>De(pe),onMouseLeave:()=>De(Oe=>Oe===pe?null:Oe)}),Ve=pe=>Ie===pe;return o.jsxs("div",{"data-pane":"left",style:{width:340,flex:"none",display:"flex",flexDirection:"column",background:"var(--proto-rail)",borderRight:"1px solid var(--proto-line)",minHeight:0},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9,padding:"16px 16px 10px",flex:"none"},children:[o.jsx("div",{"aria-label":"Cortex",style:{width:26,height:26,borderRadius:7,background:"var(--brand-badge-bg)",border:"1px solid var(--brand-badge-border)",display:"flex",alignItems:"center",justifyContent:"center"},children:o.jsxs("svg",{width:19,height:19,viewBox:"0 0 64 64",fill:"none","aria-hidden":"true",children:[o.jsx("circle",{cx:33,cy:32,r:6,fill:"var(--brand-badge-core)"}),o.jsx("path",{d:"M42.29 23.64A12.5 12.5 0 1 0 42.29 40.36",stroke:"var(--brand-badge-arc)",strokeWidth:6,strokeLinecap:"round"}),o.jsx("path",{d:"M48.6 17.95A21 21 0 1 0 48.6 46.05",stroke:"var(--brand-badge-arc)",strokeWidth:6,strokeLinecap:"round"})]})}),o.jsx("div",{style:{fontWeight:650,fontSize:14,color:"var(--proto-ink)",letterSpacing:"-.01em"},children:"Cortex"}),o.jsxs("div",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:6,minWidth:0},children:[o.jsx(mV,{status:c}),o.jsxs("div",{onClick:()=>it(!0),title:a.dmDaemon,style:{display:"flex",alignItems:"center",gap:5,fontSize:10,color:d.color,fontWeight:600,cursor:"pointer",flex:"none"},children:[o.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:d.color,...d.pulse?{animation:"cxpulse 1.6s ease-in-out infinite"}:{}}}),u]})]})]}),o.jsxs("div",{"data-zone":"projects",style:{flex:"none",padding:"2px 12px 0"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"0 4px 5px"},children:[o.jsx("span",{style:{fontSize:10,fontWeight:700,letterSpacing:".07em",color:"var(--proto-faint)"},children:a.wbProjects}),o.jsx("span",{style:{font:`500 9.5px ${rn}`,color:"var(--proto-line-3)",marginLeft:5},children:y.length}),o.jsx("span",{...qe("newproj"),onClick:()=>D(!0),title:a.newProject,style:{marginLeft:"auto",fontSize:13,color:Ve("newproj")?"var(--proto-ink)":"var(--proto-muted-2)",lineHeight:1,cursor:"pointer",padding:"0 2px"},children:"+"})]}),o.jsx("div",{ref:_,style:{maxHeight:F,overflowY:"auto"},children:q.map(pe=>{const Oe="proj:"+pe.id;return pe.active?o.jsxs("div",{"data-project-row":pe.id,style:{background:"var(--proto-line-2)",borderRadius:8,padding:"7px 9px"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[o.jsx("div",{style:{width:20,height:20,borderRadius:6,background:"var(--proto-accent)",color:"var(--ink-solid-fg)",display:"flex",alignItems:"center",justifyContent:"center",font:`600 9px ${rn}`,flex:"none"},children:pe.initials}),o.jsx("span",{style:{fontSize:12.5,fontWeight:650,color:"var(--proto-ink)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:pe.id}),o.jsxs("span",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:5,flex:"none"},children:[pe.running>0&&o.jsxs("span",{style:{display:"flex",alignItems:"center",gap:3,font:`600 9.5px ${rn}`,color:"var(--proto-accent)"},children:[o.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:"var(--proto-accent)",animation:"cxpulse 1.6s ease-in-out infinite"}}),pe.running]}),pe.badgeCount>0&&o.jsx("span",{"data-project-attention-badge":pe.id,style:{minWidth:14,height:14,padding:"0 4px",borderRadius:7,background:pe.badgeTone==="action"?"var(--proto-amber)":"var(--proto-accent)",color:"var(--ink-solid-fg)",font:`600 9px ${rn}`,display:"inline-flex",alignItems:"center",justifyContent:"center"},children:pe.badgeCount})]})]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9,padding:"5px 0 1px 28px",fontSize:10.5,fontWeight:600,color:"var(--proto-muted)"},children:[we.map(Se=>{const pt=t.pathname.startsWith(Se.to),wt="sub:"+Se.key;return o.jsx("span",{...qe(wt),onClick:()=>e(Se.to),style:{color:pt?"var(--proto-accent)":Ve(wt)?"var(--proto-ink)":"var(--proto-muted)",cursor:"pointer"},children:Se.label},Se.key)}),o.jsxs("span",{style:{display:"flex",alignItems:"center",gap:4},children:[o.jsx("span",{style:{color:"var(--proto-muted-2)",fontWeight:600},children:a.today}),o.jsx("span",{style:{font:`600 10px ${rn}`,color:"var(--proto-accent)"},children:j})]}),pe.hotkey&&o.jsx("span",{style:{marginLeft:"auto",font:`500 9px ${rn}`,color:"var(--proto-faint)",fontWeight:400},children:pe.hotkey})]})]},pe.id):o.jsxs("div",{...qe(Oe),"data-project-row":pe.id,onClick:()=>U(pe.id),style:{display:"flex",alignItems:"center",gap:8,padding:"7px 9px",borderRadius:8,cursor:"pointer",background:Ve(Oe)?"var(--proto-gray)":"transparent"},children:[o.jsx("div",{style:{width:20,height:20,borderRadius:6,background:"var(--proto-accent-bg)",color:"var(--proto-accent)",display:"flex",alignItems:"center",justifyContent:"center",font:`600 9px ${rn}`,flex:"none"},children:pe.initials}),o.jsx("span",{style:{fontSize:12.5,color:pe.unread>0?"var(--proto-ink)":"var(--proto-ink-2)",fontWeight:pe.unread>0?600:400,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:pe.id}),o.jsxs("span",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:5,flex:"none"},children:[pe.running>0&&o.jsxs("span",{style:{display:"flex",alignItems:"center",gap:3,font:`600 9.5px ${rn}`,color:"var(--proto-accent)"},children:[o.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:"var(--proto-accent)",animation:"cxpulse 1.6s ease-in-out infinite"}}),pe.running]}),pe.badgeCount>0&&o.jsx("span",{"data-project-attention-badge":pe.id,style:{minWidth:14,height:14,padding:"0 4px",borderRadius:7,background:pe.badgeTone==="action"?"var(--proto-amber)":"var(--proto-accent)",color:"var(--ink-solid-fg)",font:`600 9px ${rn}`,display:"inline-flex",alignItems:"center",justifyContent:"center"},children:pe.badgeCount}),pe.idleAge!==null?o.jsx("span",{style:{font:`400 9.5px ${rn}`,color:"var(--proto-faint)"},children:pe.idleAge}):pe.hotkey&&o.jsx("span",{style:{font:`400 9px ${rn}`,color:"var(--proto-line-3)"},children:pe.hotkey})]})]},pe.id)})})]}),o.jsxs("div",{"data-divider":"rail",onMouseDown:A,title:"drag to resize",style:{flex:"none",display:"flex",alignItems:"center",gap:8,padding:"7px 12px 5px",cursor:"row-resize",userSelect:"none"},children:[o.jsx("div",{style:{flex:1,height:1,background:"var(--proto-line)"}}),o.jsxs("div",{style:{display:"flex",gap:3},children:[o.jsx("span",{style:{width:3,height:3,borderRadius:"50%",background:"var(--proto-line-3)"}}),o.jsx("span",{style:{width:3,height:3,borderRadius:"50%",background:"var(--proto-line-3)"}}),o.jsx("span",{style:{width:3,height:3,borderRadius:"50%",background:"var(--proto-line-3)"}})]}),o.jsx("div",{style:{flex:1,height:1,background:"var(--proto-line)"}})]}),o.jsxs("div",{"data-zone":"sessions",style:{flex:1,minHeight:0,overflow:"hidden",display:"flex",flexDirection:"column",padding:"0 12px"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"2px 4px 6px",flex:"none"},children:[o.jsx("span",{style:{fontSize:10,fontWeight:700,letterSpacing:".07em",color:"var(--proto-faint)"},children:a.wbSessions}),h&&o.jsx("span",{style:{font:`500 9.5px ${rn}`,color:"var(--proto-accent-border)",marginLeft:5},children:$H(h)}),o.jsxs("span",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:5},children:[o.jsxs("span",{...qe("newsess"),onClick:At,style:{fontSize:12,fontWeight:600,color:Ve("newsess")?"var(--proto-accent-strong)":"var(--proto-accent)",cursor:"pointer"},children:["+ ",a.wbNewShort]}),o.jsx("span",{style:{font:`500 9.5px ${rn}`,color:"var(--proto-faint)"},children:"⌘N"})]})]}),o.jsx("div",{style:{flex:1,overflowY:"auto"},children:V.map((pe,Oe)=>o.jsxs("div",{children:[o.jsx("div",{style:{fontSize:10,fontWeight:700,letterSpacing:".07em",color:"var(--proto-faint)",padding:Oe===0?"2px 4px 5px":"10px 4px 6px"},children:wH(a,pe.label)}),pe.items.map(Se=>{const pt=Se.sessionId===oe,wt=Se.running,Ft=Se.awaitingInput,st="sess:"+Se.sessionId,pr=pt?"var(--proto-line-2)":Ve(st)?"var(--proto-gray)":"transparent";return o.jsxs("div",{...qe(st),className:"sess-row","data-session-id":Se.sessionId,onClick:()=>Re(Se.sessionId),style:{borderRadius:8,padding:"8px 10px",cursor:"pointer",background:pr,position:"relative"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7},children:[(wt||Ft)&&o.jsx("span",{style:{width:7,height:7,borderRadius:"50%",background:Ft?"var(--proto-amber)":"var(--proto-accent)",flex:"none",animation:"cxpulse 1.6s ease-in-out infinite"}}),o.jsx("span",{style:{flex:1,minWidth:0,fontSize:12.5,fontWeight:pt||Se.unread?600:400,color:Se.unread||pt?"var(--proto-ink)":"var(--proto-muted)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:Se.label??Se.name}),o.jsx("span",{className:"sess-more",style:{flex:"none",color:"var(--proto-muted-3)",fontSize:13,letterSpacing:1,padding:"0 4px",borderRadius:5,lineHeight:1.2},children:"⋯"})]}),o.jsx("div",{style:{font:`400 10px ${rn}`,color:pt?"var(--proto-muted-2)":"var(--proto-faint)",marginTop:3,paddingLeft:wt?14:0},children:kH(a,Se)})]},Se.sessionId)})]},pe.label))})]}),be&&o.jsxs("div",{...qe("approval"),onClick:()=>ie.open(),style:{margin:"0 12px 10px",padding:"9px 12px",background:"var(--proto-amber-bg)",border:"1px solid "+(Ve("approval")?"var(--proto-amber)":"var(--proto-amber-border)"),borderRadius:9,display:"flex",alignItems:"center",gap:8,cursor:"pointer",flex:"none"},children:[o.jsx("span",{style:{width:7,height:7,borderRadius:"50%",background:"var(--proto-amber)",flex:"none",animation:"cxpulse 2s ease-in-out infinite"}}),o.jsx("div",{style:{fontSize:11.5,color:"var(--proto-amber-fg)",fontWeight:600},children:jt}),o.jsx("div",{style:{marginLeft:"auto",color:"var(--proto-amber-accent)",fontSize:11},children:"→"})]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"10px 16px 14px",borderTop:"1px solid var(--proto-line-2)",flex:"none"},children:[o.jsxs("div",{style:{display:"flex",border:"1px solid var(--proto-line)",borderRadius:6,overflow:"hidden"},children:[o.jsx("span",{onClick:()=>i("light"),title:a.stThemeLight,"aria-label":a.stThemeLight,style:{fontSize:10,fontWeight:600,padding:"2.5px 7px",cursor:"pointer",background:r==="light"?"var(--ink-solid-bg)":"transparent",color:r==="light"?"var(--ink-solid-fg)":"var(--proto-muted-2)"},children:"☀"}),o.jsx("span",{onClick:()=>i("dark"),title:a.stThemeDark,"aria-label":a.stThemeDark,style:{fontSize:10,fontWeight:600,padding:"2.5px 7px",cursor:"pointer",background:r==="dark"?"var(--ink-solid-bg)":"transparent",color:r==="dark"?"var(--ink-solid-fg)":"var(--proto-muted-2)"},children:"☾"})]}),o.jsx("span",{title:`frontend build ${Qx}`,style:{marginLeft:"auto",fontFamily:"'IBM Plex Mono',monospace",fontSize:9.5,color:"var(--proto-muted-2)",opacity:.7,userSelect:"text"},children:Qx}),o.jsx("span",{...qe("settings"),onClick:s,style:{fontSize:11.5,color:Ve("settings")?"var(--proto-ink)":"var(--proto-muted-2)",cursor:"pointer"},children:a.settings})]}),X&&o.jsx(qH,{onClose:()=>D(!1)}),o.jsx(XH,{open:Wn,onClose:()=>it(!1)})]})}function p3(e){return e.backend==null||e.backend==="claude"||e.backend==="pi"}function Rp(e){return e.backend??"claude"}function wV(e){return[e.model,e.thinking,Rp(e)].filter(Boolean).join(" · ")}function kV(e,t){const n=e.find(r=>r.name===t&&p3(r));return n?Rp(n):null}function SV(e,t,n){return e.filter(p3).map(r=>({name:r.name,sub:wV(r),active:r.name===t,backend:Rp(r),disabled:n.hasHistory&&n.currentBackend!==null&&Rp(r)!==n.currentBackend}))}const Cj="'IBM Plex Mono',monospace";function CV({options:e,onPick:t}){const n=H(),[r,i]=p.useState(null);return o.jsx("div",{"data-menu":"profile",style:{position:"absolute",left:0,top:26,background:"var(--proto-card)",border:"1px solid var(--proto-line)",borderRadius:9,boxShadow:"0 10px 28px rgba(16,24,40,.14)",zIndex:59,overflow:"hidden",minWidth:200},children:e.map(s=>o.jsxs("div",{onMouseEnter:()=>i(s.name),onMouseLeave:()=>i(a=>a===s.name?null:a),onClick:()=>{s.disabled||t(s.name)},"data-profile":s.name,"data-disabled":s.disabled?"true":void 0,title:s.disabled?`${n.wbSwitchTo} ${s.backend} ${n.wbNeedsNewSession}`:void 0,style:{display:"flex",alignItems:"center",gap:8,padding:"7.5px 12px",cursor:s.disabled?"not-allowed":"pointer",opacity:s.disabled?.42:1,background:s.disabled?"transparent":r===s.name?"var(--proto-gray)":s.active?"var(--proto-accent-bg)":"transparent"},children:[o.jsx("span",{style:{font:`600 11px ${Cj}`,color:"var(--proto-ink)"},children:s.name}),o.jsx("span",{style:{font:`400 9.5px ${Cj}`,color:"var(--proto-muted-3)"},children:s.sub}),s.active&&o.jsx("span",{style:{marginLeft:"auto",color:"var(--proto-accent)",fontSize:10,fontWeight:700},children:"✓"})]},s.name))})}const Ej="—";function f3(e){var t,n;return[{key:"cortexId",label:e.cortexIdLabel,value:((t=e.cortexId)==null?void 0:t.trim())||Ej},{key:"backendUuid",label:e.backendUuidLabel,value:((n=e.backendUuid)==null?void 0:n.trim())||Ej}]}const Qh="'IBM Plex Mono',monospace";function EV({cortexId:e,backendUuid:t,onClose:n}){const r=H(),i=f3({cortexId:e,backendUuid:t,cortexIdLabel:r.wbCortexId,backendUuidLabel:r.wbBackendUuid}),[s,a]=p.useState(null);p.useEffect(()=>{const c=d=>{d.key==="Escape"&&n()};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[n]);const l=(c,d)=>{var u;d!=="—"&&((u=navigator.clipboard)==null||u.writeText(d).catch(()=>{}),a(c),window.setTimeout(()=>a(f=>f===c?null:f),1400))};return o.jsxs(o.Fragment,{children:[o.jsx("div",{onClick:n,style:{position:"fixed",inset:0,background:"rgba(25,28,34,.34)",zIndex:60,animation:"cxfade .18s ease"}}),o.jsxs("div",{"data-modal":"session-id",style:{position:"fixed",left:"50%",top:"50%",transform:"translate(-50%,-50%)",animation:"cxmodal .26s cubic-bezier(.22,1,.36,1)",width:480,background:"var(--proto-card)",borderRadius:14,boxShadow:"0 24px 64px rgba(16,24,40,.3)",zIndex:61,overflow:"hidden"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"14px 20px 0"},children:[o.jsx("span",{style:{fontSize:14,fontWeight:700,color:"var(--proto-ink)"},children:r.wbSessionId}),o.jsx("span",{onClick:n,style:{marginLeft:"auto",font:`500 9.5px ${Qh}`,color:"var(--proto-muted-3)",border:"1px solid var(--proto-line)",borderRadius:5,padding:"2px 6px",cursor:"pointer"},children:"esc"})]}),o.jsx("div",{style:{padding:"14px 20px 18px",display:"flex",flexDirection:"column",gap:12},children:i.map(c=>o.jsxs("div",{children:[o.jsx("div",{style:{fontSize:9.5,fontWeight:700,letterSpacing:".05em",color:"var(--proto-muted-3)",marginBottom:6},children:c.label}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,border:"1px solid var(--proto-line)",borderRadius:9,padding:"9px 12px",background:"var(--proto-alt)"},children:[o.jsx("span",{style:{flex:1,font:`500 12.5px ${Qh}`,color:"var(--proto-ink)",userSelect:"all",wordBreak:"break-all"},children:c.value}),o.jsx("span",{onClick:()=>l(c.key,c.value),style:{flex:"none",font:`500 9.5px ${Qh}`,color:s===c.key?"var(--proto-accent)":"var(--proto-muted-2)",border:"1px solid var(--proto-line-3)",borderRadius:6,padding:"3px 8px",cursor:c.value==="—"?"default":"pointer",opacity:c.value==="—"?.4:1},children:s===c.key?r.wbCopied:r.wbCopy})]})]},c.key))})]})]})}function TV(e){return{display:"inline-flex",alignItems:"center",gap:6,border:e?"1.5px solid var(--proto-accent)":"1px solid var(--proto-line)",borderRadius:7,padding:"4px 9px",background:e?"var(--proto-accent-bg)":"var(--proto-card)",color:e?"var(--proto-accent)":"var(--proto-ink)",fontFamily:"inherit",cursor:"pointer"}}function PV(){return o.jsx("svg",{width:"11",height:"11",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.6",children:o.jsx("path",{d:"M9.8 1.8l2.4 2.4L4.6 11.8l-3 .6.6-3z"})})}function h3({count:e,active:t,copy:n,onClick:r}){return o.jsxs("button",{type:"button","data-notes-button":"","aria-pressed":t,onClick:r,title:`${n.title} · ⌘⇧N`,style:TV(t),children:[o.jsx(PV,{}),o.jsx("span",{style:{fontSize:10.5,fontWeight:600},children:n.title}),o.jsx("span",{style:{font:"600 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-accent)"},children:e})]})}const Tj="'IBM Plex Mono',monospace";function RV({title:e,running:t,onCmdK:n,sessionId:r,backendSessionId:i,sessionName:s,currentProfile:a,hasHistory:l,isDraft:c=!1}){var W,te,A,V,oe,Z;const d=le(),u=H(),f=je(),h=Pf(),g=Y(d.config.get.queryOptions({})),v=((te=(W=g.data)==null?void 0:W.profiles)==null?void 0:te.profiles)??[],x=((V=(A=g.data)==null?void 0:A.profiles)==null?void 0:V.defaultProfile)??null,{draftProfile:b,setDraftProfile:j,pendingCreatedSession:y}=bs(),w=f6(a,y,r),k=c?b??x??((oe=v[0])==null?void 0:oe.name)??"—":w??x??((Z=v[0])==null?void 0:Z.name)??"—",S=p.useMemo(()=>kV(v,k),[v,k]),T=p.useMemo(()=>SV(v,k,{currentBackend:S,hasHistory:c?!1:l}),[v,k,S,l,c]),C=xe(d.sessions.setProfile.mutationOptions({onSuccess:()=>{f.invalidateQueries(d.sessions.list.queryFilter())}})),[P,I]=p.useState(!1),[L,z]=p.useState(!1),[q,X]=p.useState(!1),[D,U]=p.useState(!1),[Q,J]=p.useState(!1),[_,F]=p.useState(!1);return p.useEffect(()=>{if(!D)return;const ie=ve=>{ve.key==="Escape"&&U(!1)},he=()=>U(!1);return window.addEventListener("keydown",ie),window.addEventListener("click",he),()=>{window.removeEventListener("keydown",ie),window.removeEventListener("click",he)}},[D]),p.useEffect(()=>{if(!Q)return;const ie=ve=>{ve.key==="Escape"&&J(!1)},he=()=>J(!1);return window.addEventListener("keydown",ie),window.addEventListener("click",he),()=>{window.removeEventListener("keydown",ie),window.removeEventListener("click",he)}},[Q]),o.jsxs("div",{style:{height:50,flex:"none",borderBottom:"1px solid var(--proto-line)",display:"flex",alignItems:"center",gap:10,padding:"0 20px"},children:[o.jsx("div",{style:{fontSize:13.5,fontWeight:600,color:"var(--proto-ink)",maxWidth:320,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e}),o.jsxs("span",{style:{position:"relative"},children:[o.jsxs("span",{"data-chip":"profile",onMouseEnter:()=>I(!0),onMouseLeave:()=>I(!1),onClick:ie=>{ie.stopPropagation(),U(he=>!he)},style:{font:`500 10.5px ${Tj}`,border:"1px solid "+(P?"var(--proto-accent-border)":"var(--proto-line)"),color:P?"var(--proto-accent)":"var(--proto-muted)",padding:"2px 7px",borderRadius:6,cursor:"pointer",display:"inline-flex",alignItems:"center",gap:5},children:[u.wbProfile," · ",k,o.jsx("span",{style:{fontSize:8,color:"var(--proto-faint)"},children:"▾"})]}),D&&o.jsx("span",{onClick:ie=>ie.stopPropagation(),children:o.jsx(CV,{options:T,onPick:ie=>{if(U(!1),ie===k)return;const he=T.find(ve=>ve.name===ie);if(!(!he||he.disabled))if(c)j(ie);else{if(!r)return;C.mutate({sessionId:r,profileName:ie})}}})})]}),t?o.jsxs("span",{style:{fontSize:10.5,fontWeight:600,padding:"2px 8px",borderRadius:999,background:"var(--proto-accent-bg)",color:"var(--proto-accent)"},children:[o.jsx("span",{style:{display:"inline-block",width:6,height:6,borderRadius:"50%",background:"var(--proto-accent)",marginRight:4,animation:"cxpulse 1.6s ease-in-out infinite"}}),u.pillRunning]}):o.jsx("span",{style:{fontSize:10.5,fontWeight:600,padding:"2px 8px",borderRadius:999,background:"var(--proto-gray)",color:"var(--proto-muted-2)"},children:u.wbIdle}),o.jsxs("div",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:14,color:"var(--proto-muted-2)"},children:[o.jsx("span",{onClick:n,onMouseEnter:()=>z(!0),onMouseLeave:()=>z(!1),style:{font:`500 11px ${Tj}`,cursor:"pointer",color:L?"var(--proto-ink)":void 0},children:"⌘K"}),o.jsx("span",{style:{width:1,height:18,background:"var(--proto-line)",flex:"none"}}),o.jsx(h3,{count:h.vm.activeCount,active:h.isOpen,copy:h.copy,onClick:()=>h.isOpen?h.close():h.open()}),o.jsxs("span",{style:{position:"relative",display:"inline-flex"},children:[o.jsx("span",{"data-chip":"more","aria-label":"Session menu",onMouseEnter:()=>X(!0),onMouseLeave:()=>X(!1),onClick:ie=>{ie.stopPropagation(),J(he=>!he)},style:{fontSize:15,lineHeight:1,letterSpacing:1,cursor:"pointer",color:q||Q?"var(--proto-ink)":void 0},children:"⋯"}),Q&&o.jsx("span",{onClick:ie=>ie.stopPropagation(),style:{position:"absolute",right:0,top:24,minWidth:132,background:"var(--proto-card)",border:"1px solid var(--proto-line)",borderRadius:9,boxShadow:"0 14px 40px rgba(16,24,40,.2)",overflow:"hidden",zIndex:40},children:o.jsx("div",{onClick:()=>{J(!1),F(!0)},style:{padding:"9px 13px",fontSize:12.5,color:"var(--proto-ink)",cursor:"pointer",whiteSpace:"nowrap"},children:u.wbSessionId})})]})]}),_&&o.jsx(EV,{cortexId:s,backendUuid:i,onClose:()=>F(!1)})]})}function bv(e){switch(e){case"running":return{bg:"#EEF0FA",color:"#4655D4",text:"Running"};case"waiting":return{bg:"#F7ECCE",color:"#8A5B06",text:"Waiting"};case"completed":return{bg:"#E9F4EE",color:"#23854F",text:"Done"};case"failed":return{bg:"#FBEDEB",color:"#C03D33",text:"Failed"};default:return{bg:"#F1F2F5",color:"#8A93A2",text:"Cancelled"}}}function IV(e){const t=Math.round(e);if(t<60)return`${t}s`;const n=Math.floor(t/60),r=t%60;return r===0?`${n}m`:`${n}m ${r}s`}function g3(e){return"L"+(e+2)}function Pj(e){const t=[];return e.durationS!=null&&t.push(IV(e.durationS)),e.costUsd!=null&&t.push("$"+e.costUsd.toFixed(2)),t.join(" · ")}function MV(e){const t=e.children[0];return t?{name:t.templateName??t.id,level:g3(t.depth),running:t.status==="running",meta:t.status==="running"?"running":"done"}:null}function LV(e){const t=e.status==="running",n=bv(e.status),r=MV(e);return{name:e.templateName??e.id,level:g3(e.depth),chev:t?"▾":"▸",border:t?"#E3E6F5":"#EFF1F5",bg:t?"#FBFBFE":"#FBFBFC",iconColor:t?"#4655D4":"#8A93A2",nameColor:t?"#191C22":"#5B6472",pillBg:n.bg,pillColor:n.color,pillText:t?"Running":n.text,hasLine:r!=null,line:e.activeAgent??"",meta:e.costUsd?"$"+e.costUsd.toFixed(2):"",nested:r}}function OV(e){const t=e.steps,n=t.map((s,a)=>{const l=s.status==="completed"?"done":s.status==="running"?"running":"pending",c=l==="running",d=l==="done",u=c?e.children.map(LV):[],f=a<t.length-1;return{node:l,hasTail:f,padB:f?"8px":"2px",name:s.stage??`Step ${s.stepIndex+1}`,fw:c?600:500,color:c?"#191C22":d?"#5B6472":"#B6BDC9",sub:c?e.activeStage??"":s.outputSummary??"",subColor:c?"#98A1B0":"#B6BDC9",meta:c?Pj(s)||"running":d?Pj(s):"gated",metaColor:c?"#4655D4":d?"#B6BDC9":"#D9DCE3",chev:d,expanded:c,subs:u}}),r=bv(e.status),i=e.status==="running"&&e.currentStep?`Step ${e.currentStep.index+1}/${e.totalSteps}`:r.text;return{id:e.id,name:e.templateName,pill:r,pillText:i,meta:"$"+e.totalCostUsd.toFixed(2),rows:n}}const Xr="'IBM Plex Mono',monospace";function AV({row:e}){return o.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center"},children:[e.node==="done"&&o.jsx("span",{style:{width:14,height:14,borderRadius:"50%",background:"var(--proto-success-bg)",color:"var(--proto-success)",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:8,fontWeight:700,flex:"none"},children:"✓"}),e.node==="running"&&o.jsx("span",{style:{width:14,height:14,borderRadius:"50%",background:"var(--proto-accent)",flex:"none",boxShadow:"0 0 0 3px var(--proto-accent-bg)",animation:"cxpulse 1.6s ease-in-out infinite"}}),e.node==="pending"&&o.jsx("span",{style:{width:14,height:14,borderRadius:"50%",border:"1.5px solid var(--proto-line-3)",boxSizing:"border-box",flex:"none"}}),e.hasTail&&o.jsx("span",{style:{flex:1,width:1.5,background:"var(--proto-line-2)",margin:"3px 0"}})]})}function DV({sub:e,onOpenNested:t}){return o.jsxs("div",{style:{border:"1px solid "+e.border,background:e.bg,borderRadius:8},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,padding:"7px 10px"},children:[o.jsx("span",{style:{color:"var(--proto-muted-2)",fontSize:9},children:e.chev}),o.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 14 14",fill:"none",stroke:e.iconColor,strokeWidth:"1.8",children:[o.jsx("path",{d:"M7 1.5v5M7 6.5 3.5 10M7 6.5l3.5 3.5"}),o.jsx("circle",{cx:"7",cy:"1.5",r:"1.4",fill:e.iconColor,stroke:"none"}),o.jsx("circle",{cx:"3.5",cy:"11",r:"1.4",fill:e.iconColor,stroke:"none"}),o.jsx("circle",{cx:"10.5",cy:"11",r:"1.4",fill:e.iconColor,stroke:"none"})]}),o.jsx("span",{style:{font:`600 11px ${Xr}`,color:e.nameColor},children:e.name}),o.jsx("span",{style:{font:`400 9px ${Xr}`,color:"var(--proto-faint)"},children:e.level}),o.jsx("span",{style:{marginLeft:"auto",fontSize:9.5,fontWeight:600,padding:"1.5px 7px",borderRadius:999,background:e.pillBg,color:e.pillColor},children:e.pillText})]}),e.hasLine&&o.jsxs("div",{style:{padding:"0 10px 8px 27px"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,fontSize:10,color:"var(--proto-muted)"},children:[o.jsx("span",{children:e.line}),o.jsx("span",{style:{marginLeft:"auto",font:`400 9.5px ${Xr}`,color:"var(--proto-muted-3)"},children:e.meta})]}),e.nested&&o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,border:"1px solid var(--proto-line-2)",background:"var(--proto-card)",borderRadius:7,padding:"5.5px 9px",marginTop:6},children:[o.jsx("span",{style:{color:"var(--proto-faint)",fontSize:9},children:"▸"}),o.jsx("span",{style:{font:`600 10.5px ${Xr}`,color:"var(--proto-ink-2)"},children:e.nested.name}),o.jsx("span",{style:{font:`400 9px ${Xr}`,color:"var(--proto-faint)"},children:e.nested.level}),e.nested.running&&o.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:"var(--proto-accent)",animation:"cxpulse 1.6s ease-in-out infinite"}}),o.jsx("span",{style:{fontSize:9.5,color:"var(--proto-muted-3)"},children:e.nested.meta}),o.jsx("span",{onClick:t,style:{marginLeft:"auto",fontSize:10,fontWeight:600,color:"var(--proto-accent)",cursor:"pointer"},children:"Open ›"})]})]})]})}function NV({card:e,onOpen:t}){return o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9,padding:"8px 13px",background:"var(--proto-rail)",borderBottom:"1px solid var(--proto-line-2)"},children:[o.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 14 14",fill:"none",stroke:"var(--proto-accent)",strokeWidth:"1.6",children:[o.jsx("circle",{cx:"3.5",cy:"3",r:"1.9"}),o.jsx("circle",{cx:"3.5",cy:"11",r:"1.9"}),o.jsx("circle",{cx:"10.5",cy:"7",r:"1.9"}),o.jsx("path",{d:"M3.5 5v4M5.4 3.7 8.7 6.1M5.4 10.3 8.7 7.9"})]}),o.jsx("span",{style:{font:`600 12px ${Xr}`,color:"var(--proto-ink)"},children:e.name}),o.jsx("span",{style:{font:`400 10.5px ${Xr}`,color:"var(--proto-muted-3)"},children:e.id}),o.jsx("span",{style:{fontSize:10,fontWeight:600,padding:"1.5px 7px",borderRadius:999,background:e.pill.bg,color:e.pill.color},children:e.pillText}),o.jsx("span",{style:{marginLeft:"auto",font:`400 10.5px ${Xr}`,color:"var(--proto-muted-3)"},children:e.meta}),o.jsx("span",{onClick:t,style:{fontSize:11.5,fontWeight:600,color:"var(--proto-accent)",cursor:"pointer"},children:"Open →"})]})}function _V({row:e,onOpenNested:t}){return o.jsxs(p.Fragment,{children:[o.jsx(AV,{row:e}),o.jsxs("div",{style:{paddingBottom:e.padB},children:[o.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:7},children:[o.jsx("span",{style:{fontSize:11.5,fontWeight:e.fw,color:e.color,flex:"none"},children:e.name}),o.jsx("span",{style:{fontSize:9.5,color:e.subColor,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.sub}),o.jsx("span",{style:{marginLeft:"auto",font:`400 9.5px ${Xr}`,color:e.metaColor,flex:"none"},children:e.meta}),e.chev&&o.jsx("span",{style:{color:"var(--proto-line-3)",fontSize:8,flex:"none"},children:"▸"})]}),e.expanded&&e.subs.length>0&&o.jsx("div",{style:{marginTop:7,display:"flex",flexDirection:"column",gap:6},children:e.subs.map((n,r)=>o.jsx(DV,{sub:n,onOpenNested:t},r))})]})]})}function $V({card:e,onOpen:t}){return o.jsxs("div",{"data-inline-thread-id":e.id,style:{border:"1px solid var(--proto-line)",borderRadius:10,overflow:"hidden"},children:[o.jsx(NV,{card:e,onOpen:t}),o.jsx("div",{style:{padding:"10px 14px 6px"},children:o.jsx("div",{style:{display:"grid",gridTemplateColumns:"16px 1fr",columnGap:9},children:e.rows.map((n,r)=>o.jsx(_V,{row:n,onOpenNested:t},r))})})]})}function FV({sessionId:e}){var l;const{openThread:t}=uv(),n=le(),i=Y({...n.threads.list.queryOptions({status:["running","waiting"],sessionId:e}),enabled:!!e}).data??[],s=((l=i.find(c=>c.status==="running")??i[0])==null?void 0:l.id)??"";ml(s);const a=Y({...n.threads.get.queryOptions({threadId:s}),enabled:!!s});return!s||!a.data||a.isError?null:o.jsx($V,{card:OV(a.data),onOpen:()=>t(s)})}const Rj=[{cmd:"/dispatch",desc:"Dispatch a task to a remote machine"},{cmd:"/diff",desc:"Show pending repo changes at the commit gate"},{cmd:"/devices",desc:"gpu-01 · lab-4090 · mac-m3"},{cmd:"/pause",desc:"Pause the current thread"},{cmd:"/status",desc:"Session status summary"}];function zV(e){const t=e.trim();return t.startsWith("/")?{text:t}:null}const BV="'IBM Plex Mono',monospace";function WV({running:e,text:t,accessory:n}){return o.jsxs("div",{"data-composer-status-line":"true",style:{display:"flex",alignItems:"center",gap:8,font:`500 11px ${BV}`,color:e?"var(--proto-muted-2)":"var(--proto-faint)",padding:"8px 2px 10px"},children:[o.jsxs("span",{style:{display:"flex",alignItems:"center",gap:6,minWidth:0},children:[o.jsx("span",{style:{width:7,height:7,borderRadius:"50%",background:e?"var(--proto-accent)":"var(--proto-line-3)",animation:e?"cxpulse 1.6s ease-in-out infinite":void 0,flex:"none"}}),o.jsx("span",{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t})]}),n?o.jsx("span",{"data-context-usage-position":"composer-status",style:{marginLeft:"auto",display:"inline-flex",flex:"none"},children:n}):null]})}function UV(e){return[e.name,e.size,e.mimeType,e.type].join("\0")}function Mf(e,t){return JSON.stringify([e,(t??[]).map(UV)])}function jv(e){return`${e.ts}\0${e.fingerprint}`}function HV(e,t,n){const r=jv(n),i=t.get(r);if(i!==void 0){n.allowClockSkew&&(e[i]={...e[i],allowClockSkew:!0});return}t.set(r,e.length),e.push(n)}function wv(e,t){const n=[],r=new Map,i=(s,a,l,c)=>{HV(n,r,{fingerprint:Mf(s,a),ts:l,allowClockSkew:c})};if(e.transcript.sessionId===t)for(const s of e.transcript.turns)for(const a of s.messages)a.type==="user"&&i(a.text??"",a.attachments,a.ts,!1);for(const s of e.liveTail)s.sessionId===t&&s.role==="user"&&i(s.text,s.attachments,s.ts,!0);return n}function x3(e,t){const n=Date.parse(e),r=Date.parse(t);return Number.isFinite(n)&&Number.isFinite(r)?n>=r:e>=t}const VV=5*60*1e3;function qV(e,t){const n=Date.parse(e),r=Date.parse(t);return!Number.isFinite(n)||!Number.isFinite(r)?e>=t:n>=r-VV}function m3(e,t,n){if(e.transcript.sessionId!==t)return[];const r=[...n];return e.pendingUser.filter(i=>{const s=Mf(i.text,i.attachments),a=r.findIndex(l=>l.fingerprint===s&&x3(l.ts,i.ts));return a===-1?!0:(r.splice(a,1),!1)})}function v3(e,t){const n=wv(e,t),r=m3(e,t,n).map(i=>({fingerprint:Mf(i.text,i.attachments),ts:i.ts,allowClockSkew:!0}));return[...n,...r]}function KV(e,t,n){return v3(e,t).filter(r=>r.fingerprint===n)}function QV(e,t){return e.kind!==t.kind?!1:e.kind==="session"?e.sessionId===t.sessionId:e.projectId===t.projectId}function YV(e,t,n){const r=Mf(e.text,e.attachments),i=e.target.kind==="session"?KV(n,e.target.sessionId,r):[],s=t.filter(l=>QV(l.target,e.target)&&l.fingerprint===r),a=Math.max(i.length,...s.map(l=>l.authorityOrdinal),0)+1;return{...e,fingerprint:r,authorityBaselineKeys:i.map(jv),authorityOrdinal:a,phase:"sending"}}function GV(e,t){return e==null?void 0:e.map(n=>({...n,path:`attachments/${t}/${n.path.split("/").pop()||n.name}`}))}function XV(e,t,n){return e.map(r=>r.clientId===t?{...r,target:{kind:"session",sessionId:n},phase:"accepted",attachments:GV(r.attachments,n)}:r)}function JV(e,t,n){return n&&e.target.kind==="draft"&&e.target.projectId===t}function y3(e,t){return e.map(n=>n.clientId===t?{...n,phase:"accepted"}:n)}function ZV(e,t){return e.filter(n=>n.clientId!==t)}function eq(e,t,n){return e.find(i=>i.clientId===t)?Gx(e,n,!1).includes(t)?{messages:y3(e,t),restore:!1}:{messages:ZV(e,t),restore:!0}:{messages:e,restore:!1}}function tq(e){const t=new Map;for(const n of e){const r=t.get(n.fingerprint)??[];r.push(n),t.set(n.fingerprint,r)}return t}function nq(e,t,n){const r=e.get(t);if(r)return r;const i=tq(n(t));return e.set(t,i),i}function rq(e,t,n){const r=new Set(e.authorityBaselineKeys);return t.findIndex((i,s)=>n.has(s)||r.has(jv(i))?!1:i.allowClockSkew?qV(i.ts,e.ts):x3(i.ts,e.ts))}function Gx(e,t,n){const r=new Map,i=new Map,s=[];for(const a of e){if(a.target.kind==="draft")continue;const l=a.target.sessionId,d=nq(r,l,g=>n?wv(t,g):v3(t,g)).get(a.fingerprint)??[],u=`${l}\0${a.fingerprint}`,f=i.get(u)??new Set,h=rq(a,d,f);h!==-1&&(f.add(h),i.set(u,f),s.push(a.clientId))}return s}function oq(e,t){const n=t.transcript.sessionId,r=wv(t,n),i=m3(t,n,r),s=Gx(e,t,!1),a=Gx(e,t,!0),l=new Set(s),c=e.filter(d=>!l.has(d.clientId)).map(d=>({id:d.clientId,text:d.text,ts:d.ts,attachments:d.attachments}));return{pendingUser:[...i,...c],matchedClientIds:s,settledClientIds:a}}function iq(e){return e instanceof Error?e:new Error(String(e))}async function sq(e){e.onEnqueue(e.message);try{const t=await e.mutate();return e.onAccepted(e.message,t),{ok:!0,data:t}}catch(t){const n=iq(t);return{ok:!1,error:n,restore:e.onRejected(e.message,n)}}}const Wt="'IBM Plex Mono',monospace",Ij="—",aq="/api/attachments/upload";function lq({error:e}){const t=H();return o.jsxs("div",{"data-send-error":!0,role:"alert",style:{marginTop:7,padding:"0 2px",font:`500 10.5px ${Wt}`,color:"var(--proto-danger)"},children:[t.wbSendFailed," · ",t.wbDraftRestored,": ",e]})}function b3(e){var t,n;return((t=e.file)==null?void 0:t.type)??((n=e.meta)==null?void 0:n.mimeType)??""}function cq(e){var t,n;return((t=e.file)==null?void 0:t.name)??((n=e.meta)==null?void 0:n.name)??"file"}function dq(e){var t,n;return((t=e.file)==null?void 0:t.size)??((n=e.meta)==null?void 0:n.size)??0}function uq(e){const t=b3(e);return t.startsWith("image/")?"image":t.startsWith("video/")?"video":"file"}function pq(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function fq(e){const t=e.lastIndexOf(".");return t>0?e.slice(t+1).toUpperCase().slice(0,4):"FILE"}function hq(e){return e==="image"?{bg:"var(--proto-accent-bg)",fg:"var(--proto-accent)"}:e==="video"?{bg:"var(--proto-danger-bg)",fg:"var(--proto-danger)"}:{bg:"var(--proto-gray)",fg:"var(--proto-muted)"}}async function gq(e,t,n,r){const i={"X-Session-Id":t,"X-File-Name":encodeURIComponent(e.name),"Content-Type":e.type||"application/octet-stream",...us()};return new Promise((s,a)=>{const l=new XMLHttpRequest;l.open("POST",`${a0()}${aq}`),Object.entries(i).forEach(([c,d])=>l.setRequestHeader(c,d)),l.responseType="json",r.addEventListener("abort",()=>l.abort()),l.upload.addEventListener("progress",c=>{c.lengthComputable&&n(Math.round(c.loaded/c.total*100))}),l.addEventListener("load",()=>{if(l.status>=200&&l.status<300){const c=l.response;c!=null&&c.ok&&c.data?s(c.data):a(new Error((c==null?void 0:c.message)||`Upload failed (${l.status})`))}else l.status===413?a(new Error("File too large")):a(new Error(`Upload failed (${l.status})`))}),l.addEventListener("error",()=>a(new Error("Network error"))),l.addEventListener("abort",()=>a(new Error("Upload cancelled"))),l.send(e)})}let xq=0;function Xx(){return`att_${++xq}_${Date.now()}`}function mq(e){return e.filter(t=>t.status==="done"&&t.meta).map(t=>t.meta)}function vq(e,t){const n=new Set(e.flatMap(i=>{var s;return(s=i.meta)!=null&&s.path?[i.meta.path]:[]}));return[...t.filter(i=>!n.has(i.path)).map(i=>({id:Xx(),status:"done",progress:100,meta:i})),...e]}function yq({sessionId:e,running:t,backgroundRunning:n=!1,turns:r,cost:i,elapsed:s,isDraft:a=!1,draftProfile:l=null,draftReloadToken:c=0,projectId:d="general",prepareOptimistic:u,enqueueOptimistic:f,acceptOptimistic:h,rejectOptimistic:g,statusAccessory:v}){const x=le(),b=H(),j=je(),{openMedia:y}=gd(),{openDoc:w}=md(),{selectCreatedSession:k}=bs(),S=xe(x.sessions.send.mutationOptions()),T=xe(x.sessions.cancel.mutationOptions()),C=xe(x.sessions.createAndSend.mutationOptions()),[P,I]=p.useState(""),[L,z]=p.useState(null),q=p.useRef(null),X=p.useRef(null),D=p.useRef(null),U=p.useRef(null);a&&!U.current&&(U.current=crypto.randomUUID());const Q=a?U.current??"":e,J=E=>{E&&(E.style.height="auto",E.style.height=Math.min(E.scrollHeight,160)+"px")};p.useLayoutEffect(()=>{J(q.current)},[P]);const[_,F]=p.useState(!1),[W,te]=p.useState(null),[A,V]=p.useState(!1),[oe,Z]=p.useState(!1),[ie,he]=p.useState(!1),[ve,be]=p.useState([]),jt=p.useRef(P),At=p.useRef(ve);jt.current=P,At.current=ve;const[Re,xt]=p.useState(!1),we=p.useRef(0),Ie=p.useRef(0),De=p.useRef(new Map),Wn=ve.length>0;p.useLayoutEffect(()=>{J(q.current)},[Wn]);const it=yd({isDraft:a,sessionId:e,projectId:d}),qe=`${it??""}:${a?c:0}`,Ve=p.useRef(qe);Ve.current=qe;const Qt=p.useRef(void 0);p.useEffect(()=>{if(Qt.current!==qe){if(Qt.current=qe,!it)return;const E=Ep(it);a&&(E!=null&&E.draftUploadId)&&(U.current=E.draftUploadId),I((E==null?void 0:E.text)??"");const R=((E==null?void 0:E.attachments)??[]).map(O=>({id:Xx(),status:"done",progress:100,meta:O}));be(O=>(O.forEach(B=>{B.previewUrl&&URL.revokeObjectURL(B.previewUrl)}),R));return}nl(it,{text:P,attachments:ve.filter(E=>E.status==="done"&&E.meta).map(E=>E.meta),...a&&U.current?{draftUploadId:U.current}:{}})},[it,qe,P,ve,a]),p.useEffect(()=>{let E=!1;return ve.filter(R=>!R.file&&!R.previewUrl&&R.status==="done"&&R.meta&&(R.meta.type==="image"||R.meta.type==="video")).forEach(R=>{hd(R.meta.path,"inline").then(O=>{if(E){URL.revokeObjectURL(O);return}be(B=>B.map(K=>K.id===R.id?{...K,previewUrl:O}:K))}).catch(()=>{})}),()=>{E=!0}},[ve]);const mt=ve.length>0,pe=ve.filter(E=>E.status==="done"),Se=(!!P.trim()||pe.length>0)&&(!!e||a)&&!S.isPending&&!C.isPending,pt=_||Re?"var(--proto-accent)":"var(--proto-line-3)",wt=t?`⏎ ${b.wbSend} · ${b.wbEscToStop}`:`⏎ ${b.wbSend} · ⇧⏎ ${b.wbNewline}`,Ft=Se?"var(--proto-ink)":"var(--proto-line-3)",st=r==null?Ij:`${r} ${b.wbTurnsUnit}`,pr=i==null?Ij:js(i),Dr=!a&&r!=null,ws=P.startsWith("/")?P.slice(1).toLowerCase():"",Dt=Rj.filter(E=>E.cmd.slice(1).startsWith(ws)),ks=Dt.length?Dt:Rj,fr=p.useCallback(E=>{if(!E.file)return;const R=E.file,O=new AbortController;De.current.set(E.id,O),be(B=>B.map(K=>K.id===E.id?{...K,status:"uploading",progress:0}:K)),gq(R,Q,B=>be(K=>K.map(re=>re.id===E.id?{...re,progress:B}:re)),O.signal).then(B=>{be(K=>K.map(re=>re.id===E.id?{...re,status:"done",progress:100,meta:B}:re)),De.current.delete(E.id)}).catch(B=>{B.message!=="Upload cancelled"&&(be(K=>K.map(re=>re.id===E.id?{...re,status:"error",errorMsg:B.message}:re)),De.current.delete(E.id))})},[Q]),hr=p.useCallback(E=>{const R=Array.from(E).map(O=>({id:Xx(),file:O,status:"pending",progress:0,previewUrl:O.type.startsWith("image/")||O.type.startsWith("video/")?URL.createObjectURL(O):void 0}));be(O=>[...O,...R]),R.forEach(O=>fr(O))},[fr]),vo=p.useCallback(E=>{const R=De.current.get(E);R&&R.abort(),De.current.delete(E),be(O=>{const B=O.find(K=>K.id===E);return B!=null&&B.previewUrl&&URL.revokeObjectURL(B.previewUrl),O.filter(K=>K.id!==E)})},[]),Ss=p.useCallback(E=>{be(R=>{const O=R.find(B=>B.id===E);return O&&fr({...O,status:"pending",progress:0}),R})},[fr]),Nr=p.useCallback(E=>{E.preventDefault(),E.stopPropagation(),we.current++,E.dataTransfer.types.includes("Files")&&(Ie.current=E.dataTransfer.items.length,xt(!0))},[]),Cs=p.useCallback(E=>{E.preventDefault(),E.stopPropagation(),we.current--,we.current<=0&&(we.current=0,xt(!1))},[]),yo=p.useCallback(E=>{E.preventDefault(),E.stopPropagation(),E.dataTransfer.types.includes("Files")&&E.dataTransfer.items.length>0&&(Ie.current=E.dataTransfer.items.length)},[]),bo=p.useCallback(E=>{E.preventDefault(),E.stopPropagation(),we.current=0,xt(!1),E.dataTransfer.files.length>0&&hr(E.dataTransfer.files)},[hr]),Rn=p.useCallback(E=>{var B;const R=(B=E.clipboardData)==null?void 0:B.items;if(!R)return;const O=[];for(let K=0;K<R.length;K++){const re=R[K];if(re.kind==="file"){const ce=re.getAsFile();ce&&O.push(ce)}}O.length>0&&(E.preventDefault(),hr(O))},[hr]),Es=(E,R,O,B)=>{const K=Ve.current===O,re=K?{text:jt.current,attachments:mq(At.current),...U.current?{draftUploadId:U.current}:{}}:Ep(R)??{text:"",attachments:[]},ce=YW(re,E);nl(R,ce),K&&(ce.draftUploadId&&(U.current=ce.draftUploadId),I(ce.text),be(de=>vq(de,E.attachments)),z(B.message))},Un=()=>{x6(it),I(""),be(E=>(E.forEach(R=>{R.previewUrl&&URL.revokeObjectURL(R.previewUrl)}),[])),F(!1),De.current.forEach(E=>E.abort()),De.current.clear(),q.current&&(q.current.style.height="auto")},jo=E=>{const R=E.trim(),O=pe.map(ne=>ne.meta);if(!R&&O.length===0||!a&&!e)return;const B={text:R,attachments:O,...a&&U.current?{draftUploadId:U.current}:{}},K=u(R,O),re=it,ce=qe;z(null);const de=sq({message:K,mutate:()=>a?C.mutateAsync({projectId:d,profileName:l??void 0,text:R,draftUploadId:B.draftUploadId,...O.length>0?{attachments:O}:{}}):S.mutateAsync({sessionId:e,text:R,...O.length>0?{attachments:O}:{}}),onEnqueue:f,onAccepted:(ne,se)=>{if("sessionId"in se){const fe=h(ne.clientId,se.sessionId);j.invalidateQueries(x.sessions.list.queryFilter()),fe&&(U.current=null,k(se.sessionId))}else h(ne.clientId)},onRejected:(ne,se)=>g(ne.clientId,se)});Un(),de.then(ne=>{!ne.ok&&ne.restore&&Es(B,re,ce,ne.error)})},_r=()=>{Se&&jo(P)},Hn=()=>{!e||T.isPending||T.mutate({sessionId:e})},$r=E=>{if(E.key==="Enter"&&!E.shiftKey)E.preventDefault(),_r();else if(E.key==="Escape"){if(_){F(!1);return}t&&(E.preventDefault(),Hn())}},bl=E=>{var Ce;const R=b3(E),O=R.startsWith("image/"),B=R.startsWith("video/"),K=uq(E),re=hq(K),ce=cq(E),de=fq(ce),ne=gs(K),se=!!E.previewUrl&&E.status!=="uploading"&&E.status!=="error";if(O||B)return o.jsxs("div",{style:{position:"relative",width:54,height:54,flex:"none"},children:[o.jsxs("div",{role:se?"button":void 0,title:se?ce:void 0,onClick:se&&ne?()=>y({kind:ne,name:ce,url:E.previewUrl}):void 0,style:{position:"absolute",inset:0,borderRadius:8,border:E.status==="error"?"1px solid var(--proto-danger)":"1px solid var(--proto-line)",background:E.previewUrl?"#000":"repeating-linear-gradient(45deg,var(--proto-line),var(--proto-line) 5px,var(--proto-line) 5px,var(--proto-line) 10px)",boxSizing:"border-box",overflow:"hidden",cursor:se?"pointer":"default"},children:[E.previewUrl&&O&&o.jsx("img",{src:E.previewUrl,alt:ce,style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover"}}),E.previewUrl&&B&&o.jsx(vd,{src:E.previewUrl,style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover"}}),o.jsx("span",{style:{position:"absolute",left:4,bottom:3,font:`500 8px ${Wt}`,color:"var(--proto-muted-2)",background:"rgba(255,255,255,.88)",padding:"1px 4px",borderRadius:3},children:de}),B&&E.status!=="uploading"&&o.jsx(o.Fragment,{children:o.jsx("span",{style:{position:"absolute",left:"50%",top:"50%",transform:"translate(-50%,-50%)",width:19,height:19,borderRadius:"50%",background:"rgba(25,28,34,.82)",color:"var(--ink-solid-fg)",fontSize:7,display:"flex",alignItems:"center",justifyContent:"center",paddingLeft:1.5,boxSizing:"border-box"},children:"▶"})}),E.status==="uploading"&&o.jsxs(o.Fragment,{children:[o.jsxs("span",{style:{position:"absolute",inset:0,background:"rgba(255,255,255,.65)",display:"flex",alignItems:"center",justifyContent:"center",font:`600 9px ${Wt}`,color:"var(--proto-accent)"},children:[E.progress,"%"]}),o.jsx("span",{style:{position:"absolute",left:0,bottom:0,height:3,width:`${E.progress}%`,background:"var(--proto-accent)"}})]}),E.status==="error"&&o.jsx("span",{onClick:Xe=>{Xe.stopPropagation(),Ss(E.id)},style:{position:"absolute",inset:0,background:"rgba(255,255,255,.75)",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",font:`600 8px ${Wt}`,color:"var(--proto-danger)"},children:"retry"})]}),o.jsx("span",{onClick:Xe=>{Xe.stopPropagation(),vo(E.id)},style:{position:"absolute",top:-5,right:-5,width:16,height:16,borderRadius:"50%",background:"var(--proto-ink)",color:"var(--ink-solid-fg)",fontSize:9,display:"flex",alignItems:"center",justifyContent:"center",border:"1.5px solid var(--proto-card)",boxSizing:"border-box",cursor:"pointer"},children:"×"})]},E.id);const fe=xd(ce,R),ye=fe&&E.status==="done"&&((Ce=E.meta)!=null&&Ce.path)?()=>w({kind:fe,name:ce,path:E.meta.path,mimeType:R}):void 0;return o.jsxs("div",{role:ye?"button":void 0,title:ye?ce:void 0,onClick:ye,style:{position:"relative",display:"flex",alignItems:"center",gap:8,height:54,border:E.status==="error"?"1px solid var(--proto-danger)":"1px solid var(--proto-line)",background:"var(--proto-rail)",borderRadius:8,padding:"0 12px 0 8px",flex:"none",boxSizing:"border-box",cursor:ye?"pointer":"default"},children:[o.jsx("span",{style:{width:26,height:32,borderRadius:5,background:re.bg,color:re.fg,display:"flex",alignItems:"center",justifyContent:"center",font:`700 8px ${Wt}`,flex:"none"},children:de}),o.jsxs("span",{style:{display:"flex",flexDirection:"column",gap:2},children:[o.jsx("span",{style:{font:`500 10.5px ${Wt}`,color:"var(--proto-ink)",maxWidth:140,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:ce}),o.jsx("span",{style:{font:`400 9px ${Wt}`,color:E.status==="uploading"?"var(--proto-accent)":E.status==="error"?"var(--proto-danger)":"var(--proto-muted-3)"},children:E.status==="uploading"?`${E.progress}%`:E.status==="error"?E.errorMsg||"Failed":pq(dq(E))})]}),o.jsx("span",{onClick:Xe=>{Xe.stopPropagation(),vo(E.id)},style:{position:"absolute",top:-5,right:-5,width:16,height:16,borderRadius:"50%",background:"var(--proto-ink)",color:"var(--ink-solid-fg)",fontSize:9,display:"flex",alignItems:"center",justifyContent:"center",border:"1.5px solid var(--proto-card)",boxSizing:"border-box",cursor:"pointer"},children:"×"})]},E.id)};return o.jsx("div",{style:{flex:"none"},children:o.jsxs("div",{ref:D,onDragEnter:Nr,onDragLeave:Cs,onDragOver:yo,onDrop:bo,style:{maxWidth:756,margin:"0 auto",padding:"0 32px 18px",position:"relative"},children:[_&&o.jsxs("div",{style:{position:"absolute",left:32,right:32,bottom:"100%",marginBottom:-2,border:"1px solid var(--proto-line)",borderRadius:12,boxShadow:"0 6px 24px rgba(16,24,40,.08)",background:"var(--proto-card)",overflow:"hidden",zIndex:10},children:[ks.map((E,R)=>o.jsxs("div",{onMouseEnter:()=>te(R),onMouseLeave:()=>te(O=>O===R?null:O),onClick:()=>{const O=zV(E.cmd);O&&jo(O.text)},style:{display:"flex",alignItems:"center",padding:"8px 14px",background:W===R||R===0?"var(--proto-accent-bg)":"var(--proto-card)",cursor:"pointer"},children:[o.jsx("span",{style:{font:`600 12px ${Wt}`,color:R===0?"var(--proto-accent)":"var(--proto-muted)"},children:E.cmd}),o.jsx("span",{style:{fontSize:11.5,color:"var(--proto-muted-2)",marginLeft:12},children:E.desc})]},E.cmd)),o.jsx("div",{style:{display:"flex",alignItems:"center",padding:"7px 14px",borderTop:"1px solid var(--proto-alt)",background:"var(--proto-rail)"},children:o.jsxs("span",{style:{font:`400 10px ${Wt}`,color:"var(--proto-faint)"},children:["↑↓ ",b.wbNavigate," · ⏎ ",b.wbRun," · ",b.wbEscDismiss]})})]}),o.jsx(WV,{running:t,text:t?`${n?b.pillBackground:b.pillRunning} · ${s} · ${st}`:Dr?`${b.wbIdle} · ${s} · ${st} · ${pr}`:b.wbIdle,accessory:v}),o.jsx("div",{style:{position:"relative",border:Re?"1.5px dashed var(--proto-accent)":"1.5px solid "+pt,borderRadius:12,background:Re?"var(--proto-rail)":"var(--proto-card)",boxShadow:Re?"none":"0 1px 2px rgba(16,24,40,.04)",padding:"10px 12px 10px 14px"},children:Re&&!mt?o.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:4,padding:"22px 12px"},children:[o.jsx("span",{style:{font:`600 11.5px ${Wt}`,color:"var(--proto-accent)"},children:Ie.current>0?b.wbDropFilesPlural.replace("{n}",String(Ie.current)):b.wbDropFilesSingular}),o.jsx("span",{style:{font:`400 10px ${Wt}`,color:"var(--proto-muted-3)"},children:b.wbAttachPath})]}):o.jsxs(o.Fragment,{children:[o.jsx("div",{style:{opacity:Re?.4:1,pointerEvents:Re?"none":"auto"},children:o.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:14},children:[o.jsxs("div",{style:{flex:1,minWidth:0},children:[mt&&o.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:8,padding:"2px 2px 10px",borderBottom:"1px solid var(--proto-line-2)"},children:ve.map(bl)}),o.jsx("textarea",{ref:q,"data-composer-input":!0,rows:1,value:P,onChange:E=>{const R=E.target.value;I(R),z(null),F(R.startsWith("/"))},onKeyDown:$r,onPaste:Rn,placeholder:mt?b.wbAttachPlaceholder:b.composerPh,style:{width:"100%",fontSize:13.5,lineHeight:1.5,color:"var(--proto-ink)",fontFamily:"inherit",padding:mt?"11px 2px":"2px 0",border:"none",outline:"none",resize:"none",background:"transparent",maxHeight:160,overflowY:"auto"}}),o.jsxs("div",{style:{display:"flex",alignItems:"center",marginTop:0},children:[o.jsx("span",{onClick:()=>{var E;return(E=X.current)==null?void 0:E.click()},onMouseEnter:()=>Z(!0),onMouseLeave:()=>Z(!1),style:{font:`500 10.5px ${Wt}`,border:"1px solid "+(oe?"var(--proto-accent-border)":"var(--proto-line)"),color:oe?"var(--proto-accent)":"var(--proto-muted-2)",padding:"2px 7px",borderRadius:6,cursor:"pointer"},children:b.wbAttach}),o.jsxs("span",{onClick:()=>{I("/"),F(!0)},onMouseEnter:()=>V(!0),onMouseLeave:()=>V(!1),style:{font:`500 10.5px ${Wt}`,border:"1px solid "+(A?"var(--proto-accent-border)":"var(--proto-line)"),color:A?"var(--proto-accent)":"var(--proto-muted-2)",padding:"2px 7px",borderRadius:6,cursor:"pointer",marginLeft:8},children:["/ ",b.commands]}),o.jsx("span",{style:{marginLeft:"auto",font:`400 10.5px ${Wt}`,color:"var(--proto-faint)"},children:mt?b.wbAttachHint:wt})]})]}),o.jsxs("div",{style:{flex:"none",display:"flex",alignItems:"center",gap:6,marginTop:mt?2:0},children:[o.jsx("button",{type:"button","data-action":"send","aria-label":b.wbSend,title:t?`${b.wbSend} · ⏎`:void 0,disabled:!Se,onClick:_r,style:{flex:"none",width:t?30:34,height:t?30:34,padding:0,borderRadius:t?9:10,background:t?"transparent":Ft,border:t?`1.5px solid ${Se?"var(--proto-accent-border)":"var(--proto-line)"}`:"none",boxSizing:"border-box",display:"flex",alignItems:"center",justifyContent:"center",cursor:Se?"pointer":"default"},children:o.jsx("svg",{width:t?12:14,height:t?12:14,viewBox:"0 0 14 14",fill:"none",stroke:t?Se?"var(--proto-accent)":"var(--proto-line-3)":"var(--ink-solid-fg)",strokeWidth:"1.8",children:o.jsx("path",{d:"M7 12V2M3 6l4-4 4 4"})})}),t&&o.jsx("div",{"data-action":"stop",title:`${b.stop} · esc`,onClick:Hn,onMouseEnter:()=>he(!0),onMouseLeave:()=>he(!1),style:{flex:"none",width:34,height:34,borderRadius:10,background:ie?"var(--ink-solid-hover)":"var(--proto-ink)",display:"flex",alignItems:"center",justifyContent:"center",cursor:T.isPending?"default":"pointer"},children:o.jsx("span",{style:{width:11,height:11,background:"var(--proto-card)",borderRadius:2}})})]})]})}),Re&&mt&&o.jsxs("div",{style:{position:"absolute",left:"50%",top:"50%",transform:"translate(-50%,-50%)",display:"flex",flexDirection:"column",alignItems:"center",gap:3,background:"rgba(251,251,254,.94)",border:"1px solid var(--proto-accent-border)",borderRadius:10,padding:"10px 18px",boxShadow:"0 2px 8px rgba(70,85,212,.10)",zIndex:2},children:[o.jsx("span",{style:{font:`600 11.5px ${Wt}`,color:"var(--proto-accent)"},children:Ie.current>0?b.wbDropAddMoreN.replace("{n}",String(Ie.current)):b.wbDropAddMore}),o.jsx("span",{style:{font:`400 10px ${Wt}`,color:"var(--proto-muted-3)"},children:b.wbDragOverCount.replace("{n}",String(ve.length)).replace("{m}",String(ve.length+Ie.current))})]})]})}),L&&o.jsx(lq,{error:L}),o.jsx("input",{ref:X,type:"file",multiple:!0,onChange:E=>{E.target.files&&E.target.files.length>0&&(hr(E.target.files),E.target.value="")},style:{display:"none"}})]})})}const wd={en:{title:"Context usage",current:"Current context",limit:"Context limit",usage:"Usage",tokens:"tokens",estimate:"The backend reports this value as an estimate.",waiting:"Context usage becomes available after the next turn completes.",compact:"Compact",compacting:"Compacting…",compacted:"Context compacted.",notNeeded:"Nothing to compact.",running:"Stop the current turn before compacting.",noHistory:"No conversation history to compact."},zh:{title:"上下文用量",current:"当前上下文",limit:"上下文上限",usage:"使用率",tokens:"tokens",estimate:"此数值由后端估算。",waiting:"下一次 turn 完成后将显示上下文用量。",compact:"压缩",compacting:"压缩中…",compacted:"上下文已压缩。",notNeeded:"当前没有可压缩内容。",running:"请先停止当前 turn,再压缩上下文。",noHistory:"当前没有可压缩的会话历史。"}};function j3(e){return wd[e].title}function bq({usage:e,supported:t,variant:n,lang:r,compactAction:i}){return!t&&e===null?null:o.jsx(cf,{title:j3(r),trigger:o.jsx(w3,{usage:e,variant:n,lang:r,"data-context-compact-enabled":i?"true":void 0}),footer:i?o.jsx(k3,{action:i,lang:r}):void 0,children:o.jsx(S3,{usage:e,lang:r})})}const jq={border:0,background:"transparent",padding:0,display:"inline-flex",alignItems:"center",gap:7,color:"var(--proto-muted)",cursor:"pointer",flex:"none"},wq={minWidth:26,font:"600 10px 'IBM Plex Mono', ui-monospace, Menlo, monospace",color:"var(--proto-muted)",textAlign:"right",whiteSpace:"nowrap"},w3=p.forwardRef(function({usage:t,variant:n,lang:r,style:i,...s},a){const l=wd[r],c=n6(t);return o.jsxs("button",{...s,ref:a,type:"button","data-context-usage-bar":n,"data-context-usage-presentation":n==="mobile"?"sheet-trigger":"modal-trigger","aria-label":`${l.usage}: ${c.percentLabel}`,style:{...jq,...i},children:[o.jsx("span",{"data-context-usage-track":n,role:"progressbar","aria-label":l.usage,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":c.progress??void 0,style:{display:"block",width:n==="desktop"?64:48,height:4,borderRadius:999,background:"var(--proto-line-3)",overflow:"hidden"},children:o.jsx("span",{style:{display:"block",height:"100%",width:`${c.progress??0}%`,borderRadius:999,background:"var(--proto-accent)"}})}),o.jsx("span",{style:wq,children:c.percentLabel})]})});function kq(e,t){const n=wd[t];return e.error?e.error:e.status==="compacted"?n.compacted:e.status==="not-needed"?n.notNeeded:e.disabledReason==="running"?n.running:e.disabledReason==="no-history"?n.noHistory:null}function k3({action:e,lang:t}){const n=wd[t];return o.jsxs(o.Fragment,{children:[o.jsx("span",{"aria-live":"polite",style:{marginRight:"auto",color:"var(--proto-muted)",fontSize:12},children:kq(e,t)}),o.jsx(yt,{"data-context-compact-action":!0,variant:"primary",size:"sm",disabled:e.pending||e.disabled,onClick:e.onCompact,children:e.pending?n.compacting:n.compact})]})}function S3({usage:e,lang:t}){const n=wd[t],r=n6(e),i=[[n.current,r.current==="—"?r.current:`${r.current} ${n.tokens}`],[n.limit,r.maximum==="—"?r.maximum:`${r.maximum} ${n.tokens}`],[n.usage,r.percentLabel]],s=e?r.estimated?n.estimate:null:n.waiting;return o.jsxs("div",{"data-context-usage-details":!0,style:{display:"grid",gap:10},children:[i.map(([a,l])=>o.jsxs("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:20,borderBottom:"1px solid var(--proto-line-2)",paddingBottom:8},children:[o.jsx("span",{style:{color:"var(--proto-muted)"},children:a}),o.jsx("span",{style:{font:"600 12px 'IBM Plex Mono', ui-monospace, Menlo, monospace",color:"var(--proto-ink)",textAlign:"right"},children:l})]},a)),s?o.jsx("p",{style:{margin:0,color:"var(--proto-muted)",fontSize:12,lineHeight:1.5},children:s}):null]})}function C3(e,t){const n=le(),r=je(),[i,s]=p.useState(null),[a,l]=p.useState(null),c=t.running?"running":t.hasBackendHistory?null:"no-history",d=xe(n.sessions.compact.mutationOptions({onSuccess:f=>{s(f.status),l(null),r.invalidateQueries(n.sessions.list.queryFilter())},onError:f=>{s(null),l(f.message)}}));return p.useEffect(()=>{s(null),l(null)},[e]),{onCompact:p.useCallback(()=>{!e||d.isPending||c||(s(null),l(null),d.mutate({sessionId:e}))},[c,d,e]),pending:d.isPending,disabled:!e||c!==null,status:i,error:a,disabledReason:c}}function kv(e){const t=le(),n=je(),r=xe(t.sessions.answerQuestion.mutationOptions()),i=xe(t.sessions.respondPlan.mutationOptions()),s=p.useCallback(()=>{n.invalidateQueries(t.sessions.transcript.queryFilter({sessionId:e})),n.invalidateQueries(t.sessions.pendingInteraction.queryFilter())},[n,t,e]),a=p.useCallback((d,u)=>{r.isPending||r.mutate({requestId:d,answers:u},{onSettled:s})},[r,s]),l=p.useCallback(d=>{i.isPending||i.mutate({requestId:d,approved:!0},{onSettled:s})},[i,s]),c=p.useCallback((d,u)=>{i.isPending||i.mutate({requestId:d,approved:!1,feedback:u??""},{onSettled:s})},[i,s]);return{answerQuestion:a,approvePlan:l,rejectPlan:c,busy:r.isPending||i.isPending}}const Sq=800;function E3(e,t){const n=le(),r=je(),i=xe(n.sessions.markRead.mutationOptions({onSuccess:()=>{r.invalidateQueries(n.sessions.list.queryFilter())}})),s=p.useRef(i.mutate);s.current=i.mutate;const a=p.useRef(null);p.useEffect(()=>{if(!e)return;const l=()=>{document.visibilityState==="visible"&&(a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{s.current({sessionId:e})},Sq))};l();const c=()=>{document.visibilityState==="visible"&&l()};return document.addEventListener("visibilitychange",c),()=>{document.removeEventListener("visibilitychange",c),a.current&&clearTimeout(a.current)}},[e,t])}const Cq={sessionId:"",turns:[]};function Eq({grow:e=1}={}){const t=H(),n=ut(),r=le(),{currentProjectId:i}=Ei(),{selectedSessionId:s,isDraft:a,draftProfile:l,draftReloadToken:c}=bs(),d=Y(r.sessions.list.queryOptions({origin:"direct",projectId:i??void 0})),u=p.useMemo(()=>(d.data??[]).find(Ie=>Ie.sessionId===s)??null,[d.data,s]),f=(u==null?void 0:u.sessionId)??(a?"":s??""),h=a?t.wbNewConversation:u?u.label??u.name:"No session",g=Y({...r.sessions.transcript.queryOptions({sessionId:f}),enabled:!!f}),{liveTail:v,getMessageSnapshot:x,streaming:b,running:j,backgroundRunning:y,liveTurns:w,contextUsage:k,streamingText:S,pendingUser:T}=Tf(f,u==null?void 0:u.running,u==null?void 0:u.backgroundRunning,{deltas:!0,transcript:g.data??null,contextUsage:(u==null?void 0:u.contextUsage)??null}),[C,P]=p.useState([]),I=p.useRef([]),L=p.useRef(i??"general"),z=p.useRef(a);L.current=i??"general",z.current=a;const q=p.useRef({transcript:{sessionId:f,turns:[],pendingUserMessages:[]},liveTail:[],pendingUser:[]}),X=p.useMemo(()=>({transcript:g.data??{sessionId:f,turns:[],pendingUserMessages:[]},liveTail:v,pendingUser:T}),[g.data,f,v,T]);q.current=X;const D=p.useCallback(()=>{const we=x();return{...q.current,...we}},[x]),U=p.useCallback(we=>{P(Ie=>{const De=we(Ie);return I.current=De,De})},[]),Q=p.useMemo(()=>C.filter(we=>a?we.target.kind==="draft"&&we.target.projectId===(i??"general"):we.target.kind==="session"&&we.target.sessionId===f),[C,a,i,f]),J=p.useMemo(()=>oq(Q,X),[Q,X]);p.useEffect(()=>{if(J.settledClientIds.length===0)return;const we=new Set(J.settledClientIds);U(Ie=>Ie.filter(De=>!we.has(De.clientId)))},[J.settledClientIds,U]);const _=p.useCallback((we,Ie)=>{const De=a?{kind:"draft",projectId:i??"general"}:{kind:"session",sessionId:f};return YV({clientId:crypto.randomUUID(),target:De,text:we,attachments:Ie,ts:new Date().toISOString()},I.current,D())},[a,i,f,D]),F=p.useCallback(we=>{U(Ie=>[...Ie,we])},[U]),W=p.useCallback((we,Ie)=>{const De=I.current.find(it=>it.clientId===we),Wn=!!Ie&&!!De&&JV(De,L.current,z.current);return U(it=>Ie?XV(it,we,Ie):y3(it,we)),Ie?Wn:!0},[U]),te=p.useCallback(we=>{const Ie=eq(I.current,we,D());return U(()=>Ie.messages),Ie.restore},[D,U]),A=kv(f);E3(f,`${v.length}:${j}`);const V=g.data??Cq,oe=p.useMemo(()=>sv(V,v,{streaming:b,streamingText:S,pendingUser:J.pendingUser,formatDivider:VC(t)}),[V,v,b,S,J.pendingUser,t]),Z=XF(g.data),ie=BC(w,(u==null?void 0:u.numTurns)??null),he=p.useMemo(()=>WC(zC(g.data)),[g.data]),ve=Z>0||v.length>0,be=C3(f,{running:j,hasBackendHistory:!!(u!=null&&u.backendSessionId)}),jt=je(),At=xe(r.sessions.rewind.mutationOptions({onSettled:()=>{f&&(jt.invalidateQueries(r.sessions.transcript.queryFilter({sessionId:f})),jt.invalidateQueries(r.sessions.list.queryFilter()))}})),Re=p.useMemo(()=>{if(f)return{running:j,busy:At.isPending,onSubmit:(we,Ie)=>At.mutate({sessionId:f,turnIndex:we,text:Ie})}},[f,j,At]),xt=()=>{window.dispatchEvent(new KeyboardEvent("keydown",{key:"k",metaKey:!0,bubbles:!0}))};return o.jsxs("div",{"data-pane":"center",style:{flexGrow:e,flexShrink:1,flexBasis:0,minWidth:0,display:"flex",flexDirection:"column",background:"var(--proto-card)",minHeight:0},children:[o.jsx(RV,{title:h,running:j,onCmdK:xt,sessionId:f,backendSessionId:(u==null?void 0:u.backendSessionId)??null,sessionName:(u==null?void 0:u.name)??null,currentProfile:(u==null?void 0:u.profileName)??null,hasHistory:ve,isDraft:a}),o.jsx(Lz,{rows:oe,loading:!!f&&g.isPending,inlineThreadCard:f?o.jsx(FV,{sessionId:f}):void 0,interactionActions:A,edit:Re,streamKey:f}),o.jsx(yq,{sessionId:f,running:j,backgroundRunning:y,turns:ie,cost:(u==null?void 0:u.costUsd)??null,elapsed:he,isDraft:a,draftProfile:l,draftReloadToken:c,projectId:i??"general",prepareOptimistic:_,enqueueOptimistic:F,acceptOptimistic:W,rejectOptimistic:te,statusAccessory:u!=null&&u.contextCompactionSupported||k!==null?o.jsx(bq,{usage:k,supported:!!(u!=null&&u.contextCompactionSupported),variant:"desktop",lang:n,compactAction:u!=null&&u.contextCompactionSupported?be:void 0}):void 0})]})}function Lf(e,t){return e.unmetDependencyIds!==void 0?e.unmetDependencyIds:t?e.dependsOn.filter(n=>t.get(n)==="open"):e.dependsOn}const Tq=["in-progress","actionable","approval-needed","waiting-deps","blocked","done"],Pq=[{kind:"done",matches:e=>e.status==="done"},{kind:"blocked",matches:e=>e.blockedBy!=null},{kind:"in-progress",matches:e=>e.claimedBy!=null},{kind:"approval-needed",matches:e=>e.approvalNeeded===!0},{kind:"waiting-deps",matches:(e,t)=>t},{kind:"actionable",matches:e=>e.actionable}];function Rq(e,t){var r;const n=Lf(e,t).length>0;return((r=Pq.find(i=>i.matches(e,n)))==null?void 0:r.kind)??"waiting-deps"}function Iq(e){const t=new Map(e.map(n=>[n.id,n.status]));return Tq.map(n=>({kind:n,tasks:e.filter(r=>Rq(r,t)===n)})).filter(n=>n.tasks.length>0)}function Mq(e){return e.filter(t=>t.status==="open").length}const Lq={"in-progress":"var(--proto-danger)",actionable:"var(--proto-amber)","approval-needed":"var(--proto-amber)","waiting-deps":"var(--proto-faint)",blocked:"var(--proto-amber)",done:"var(--proto-success)"},Oq={background:"var(--proto-card)",border:"1px solid var(--proto-line)",borderRadius:9,padding:"9px 12px",boxShadow:"0 1px 2px rgba(16,24,40,.03)",cursor:"pointer"},Aq={claim:{color:"var(--proto-accent)",background:"var(--proto-accent-bg)"},approval:{color:"var(--proto-amber-text)",background:"var(--proto-amber-bg)"},blocked:{color:"var(--proto-danger)",background:"var(--proto-danger-bg)"},waiting:{color:"var(--proto-muted-2)",background:"var(--proto-gray)"}},Dq={boxSizing:"border-box",maxWidth:"100%",minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"};function Nq(e,t,n){const r=bd(e),i=Lf(e);return[t==="blocked"&&e.blockedBy?{kind:"blocked",text:`${n.mBlockedPill} · ${e.blockedBy}`}:null,t==="in-progress"?{kind:"claim",text:r?`claimed · ${r}`:"claimed"}:null,t==="approval-needed"?{kind:"approval",text:n.tkApprovalNeeded}:null,t==="waiting-deps"&&i.length>0?{kind:"waiting",text:`${n.mDependsOn} ${i.join(", ")}`}:null].find(a=>a!=null)??null}function _q({task:e}){return o.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:7,minWidth:0},children:[o.jsx("span",{style:{color:"var(--proto-faint)",fontSize:8.5,flex:"none"},children:"▸"}),o.jsx("span",{style:{font:"500 10px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)"},children:e.id}),o.jsx("span",{style:{fontSize:12,color:"var(--proto-ink-2)",lineHeight:1.45,flex:1,minWidth:0,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},title:e.text,children:e.text})]})}function $q({meta:e}){return o.jsx("div",{style:{display:"flex",alignItems:"center",marginTop:5},children:o.jsx("span",{"data-task-blocker":e.kind==="blocked"?"true":void 0,style:{font:"500 9.5px 'IBM Plex Mono',monospace",padding:"1.5px 7px",borderRadius:999,...Aq[e.kind],...e.kind==="blocked"?Dq:{}},children:e.text})})}function Fq({task:e,kind:t,onOpen:n}){const r=H(),i=Nq(e,t,r);return o.jsx("div",{"data-task-id":e.id,"data-status":e.status,onClick:()=>n(e),style:Oq,children:o.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:8},children:[o.jsx("span",{style:{width:7,height:7,borderRadius:"50%",background:Lq[t],flex:"none",marginTop:5}}),o.jsxs("div",{style:{minWidth:0,flex:1},children:[o.jsx(_q,{task:e}),i&&o.jsx($q,{meta:i})]})]})})}function Sv(){const e=le(),t=je();Ci(Az,()=>{t.invalidateQueries(e.tasks.list.queryFilter())})}const zq={fontSize:11.5,fontWeight:700,letterSpacing:".06em",textTransform:"uppercase",color:"var(--proto-muted)",padding:"8px 2px 4px"},Bq={borderRadius:10,border:"1px solid var(--proto-line)",background:"var(--proto-danger-bg)",padding:"6px 10px",fontSize:12,color:"var(--proto-danger)"};function Wq({kind:e,tasks:t,onOpen:n}){const r=H(),i={"in-progress":r.tkInProgress,actionable:r.tkActionable,"approval-needed":r.tkApprovalNeeded,"waiting-deps":r.tkWaitingDeps,blocked:r.mBlocked,done:r.tkDone};return o.jsxs("section",{children:[o.jsxs("div",{style:zq,children:[i[e]," · ",t.length]}),o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:5},children:t.map(s=>o.jsx(Fq,{task:s,kind:e,onOpen:n},s.id))})]})}function Uq({groups:e,onOpen:t}){const n=H();return e.length===0?o.jsx("div",{style:{fontSize:12,color:"var(--proto-muted-2)",padding:"24px 0",textAlign:"center"},children:n.mNoTasks}):o.jsx(o.Fragment,{children:e.map(r=>o.jsx(Wq,{...r,onOpen:t},r.kind))})}function Hq({tasks:e,groups:t}){var i;const n=H(),r=((i=t.find(s=>s.kind==="done"))==null?void 0:i.tasks.length)??0;return o.jsxs("div",{style:{flex:"none",display:"flex",alignItems:"center",padding:"8px 2px 0",borderTop:"1px solid var(--proto-line-2)",font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-faint)"},children:[o.jsxs("span",{children:["TASKS.yaml · ",n.synced]}),o.jsxs("span",{style:{marginLeft:"auto"},children:[e.length," total · ",r," done"]})]})}function T3({projectId:e}){const t=H(),n=le(),{openTask:r}=U6(),i=Y(n.tasks.list.queryOptions(e?{projectId:e}:{}));Sv();const s=i.data??[],a=p.useMemo(()=>Iq(s),[s]);return i.isPending?o.jsx("div",{style:{fontSize:12,color:"var(--proto-muted-2)",padding:12},children:t.tkLoading}):i.isError?o.jsxs("div",{style:Bq,children:[t.tkLoadFailed,": ",i.error.message]}):o.jsxs("div",{style:{minHeight:0,flex:1,display:"flex",flexDirection:"column"},children:[o.jsx("div",{style:{flex:1,overflow:"auto",minHeight:0},children:o.jsx(Uq,{groups:a,onOpen:l=>r(l.project,l.id)})}),o.jsx(Hq,{tasks:s,groups:a})]})}function Vq(e){return e.artifacts.taskProject??e.projectId}const qq=o.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",strokeWidth:"1.6",children:[o.jsx("circle",{cx:"3.5",cy:"3",r:"1.9"}),o.jsx("circle",{cx:"3.5",cy:"11",r:"1.9"}),o.jsx("circle",{cx:"10.5",cy:"7",r:"1.9"}),o.jsx("path",{d:"M3.5 5v4M5.4 3.7 8.7 6.1M5.4 10.3 8.7 7.9"})]});function Kq({kind:e,hasTail:t}){return o.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center"},children:[e==="done"&&o.jsx("span",{style:{width:14,height:14,borderRadius:"50%",background:"var(--proto-success-bg)",color:"var(--proto-success)",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:8,fontWeight:700,flex:"none"},children:"✓"}),e==="running"&&o.jsx("span",{style:{width:14,height:14,borderRadius:"50%",background:"var(--proto-accent)",flex:"none",boxShadow:"0 0 0 3px var(--proto-accent-bg)",animation:"cxpulse 1.6s ease-in-out infinite"}}),e==="pending"&&o.jsx("span",{style:{width:14,height:14,borderRadius:"50%",border:"1.5px solid var(--proto-line-3)",boxSizing:"border-box",flex:"none"}}),t&&o.jsx("span",{style:{flex:1,width:1.5,background:"var(--proto-line-2)",margin:"3px 0"}})]})}const Cv={running:"var(--proto-accent)",done:"var(--proto-success)",failed:"var(--proto-danger)",idle:"var(--proto-faint)"};function P3({tone:e}){return o.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:Cv[e],flex:"none",animation:e==="running"?"cxpulse 1.6s ease-in-out infinite":void 0}})}function Qq({run:e,onOpen:t}){const n=MH(e.status),r=[e.machine,e.taskId?`task ${e.taskId}`:null].filter(Boolean).join(" · ");return o.jsxs("div",{"data-cortex-run":e.runName??"",onClick:()=>t(e.executionId),style:{display:"flex",alignItems:"center",gap:7,border:`1px solid ${n.tone==="running"?"var(--proto-accent-bg)":"var(--proto-line-2)"}`,background:"var(--proto-rail)",borderRadius:8,padding:"7px 10px",cursor:"pointer"},children:[o.jsx(P3,{tone:n.tone}),o.jsx("span",{style:{minWidth:0,font:"600 10.5px 'IBM Plex Mono',monospace",color:"var(--proto-ink-2)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:IH(e)}),r&&o.jsx("span",{style:{flex:"none",font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)"},children:r}),o.jsx("span",{style:{marginLeft:"auto",flex:"none",font:"500 9.5px 'IBM Plex Mono',monospace",color:Cv[n.tone]},children:e.cost!=null?js(e.cost):n.label})]})}function Yq({task:e,onOpen:t}){const n=LH(e);return o.jsxs("div",{"data-subtask-id":e.id,onClick:()=>t(e.id),style:{display:"flex",alignItems:"center",gap:7,border:"1px solid var(--proto-line-2)",background:"var(--proto-rail)",borderRadius:8,padding:"7px 10px",cursor:"pointer"},children:[o.jsx(P3,{tone:n.tone}),o.jsxs("span",{style:{flex:"none",font:"600 10.5px 'IBM Plex Mono',monospace",color:"var(--proto-ink-2)"},children:["task ",e.id]}),o.jsx("span",{style:{minWidth:0,fontSize:9.5,color:"var(--proto-muted-3)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.text}),o.jsx("span",{style:{marginLeft:"auto",flex:"none",fontSize:9.5,fontWeight:600,color:Cv[n.tone]},children:n.label})]})}function Gq({runs:e,subtasks:t,onOpenRun:n,onOpenTask:r}){return e.length===0&&t.length===0?null:o.jsxs("div",{style:{marginTop:7,display:"flex",flexDirection:"column",gap:6},children:[e.map(i=>o.jsx(Qq,{run:i,onOpen:n},i.executionId)),t.map(i=>o.jsx(Yq,{task:i,onOpen:r},i.id))]})}function Xq({label:e,meta:t,active:n,done:r}){const i=n?"var(--proto-ink)":r?"var(--proto-muted)":"var(--proto-faint)";return o.jsxs("div",{style:{display:"flex",alignItems:"baseline"},children:[o.jsx("span",{style:{fontSize:11.5,fontWeight:n?600:500,color:i},children:e}),o.jsx("span",{style:{marginLeft:"auto",font:"400 9.5px 'IBM Plex Mono',monospace",color:n?"var(--proto-accent)":"var(--proto-faint)"},children:t})]})}function Jq({step:e,isLast:t,detail:n,onOpenRun:r,onOpenTask:i}){const s=H(),a=TH(e),l=a==="running",c=l?G0(n,e):[],d=l?n.subtasks??[]:[],u=c.length>0||d.length>0,f=e.stage??`${s.rpStep} ${e.stepIndex+1}`;return o.jsxs(o.Fragment,{children:[o.jsx(Kq,{kind:a,hasTail:!t}),o.jsxs("div",{style:{minWidth:0,paddingBottom:t?4:9},children:[o.jsx(Xq,{label:f,meta:RH(e),active:l,done:a==="done"}),u&&o.jsx(Gq,{runs:c,subtasks:d,onOpenRun:r,onOpenTask:i})]})]})}function Zq({threadId:e,cost:t}){const n=H(),r=le(),{openThread:i}=uv(),s=je(),a=xe(r.threads.cancel.mutationOptions({onSettled:()=>{s.invalidateQueries(r.threads.list.queryFilter()),s.invalidateQueries(r.threads.get.queryFilter({threadId:e}))}}));return o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:13,padding:"8px 14px",borderTop:"1px solid var(--proto-line-2)"},children:[o.jsx("span",{title:"Pause has no backend mutate op yet",style:{fontSize:11.5,fontWeight:600,color:"var(--proto-muted)",cursor:"not-allowed",opacity:.6},children:n.pause}),o.jsx("span",{"data-cancel-thread-id":e,onClick:()=>a.mutate({threadId:e}),style:{fontSize:11.5,fontWeight:600,color:"var(--proto-danger)",cursor:"pointer"},children:n.cancel}),o.jsx("span",{onClick:()=>i(e),style:{fontSize:11.5,fontWeight:600,color:"var(--proto-accent)",cursor:"pointer"},children:n.open}),o.jsxs("span",{style:{marginLeft:"auto",font:"500 10px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)"},children:["Σ ",js(t)]})]})}function eK({detail:e,threadId:t}){const{open:n}=l6(),{openTask:r}=U6();return ml(t),o.jsxs(o.Fragment,{children:[e.steps.length>0&&o.jsx("div",{style:{padding:"10px 14px 4px"},children:o.jsx("div",{style:{display:"grid",gridTemplateColumns:"16px 1fr",columnGap:9},children:e.steps.map(i=>o.jsx(Jq,{step:i,isLast:i.stepIndex===e.steps.length-1,detail:e,onOpenRun:n,onOpenTask:s=>r(Vq(e),s)},i.stepIndex))})}),o.jsx(Zq,{threadId:t,cost:e.totalCostUsd})]})}function tK({thread:e,now:t}){const n=H(),[r,i]=p.useState(e.status==="running"),s=le(),a=Y({...s.threads.get.queryOptions({threadId:e.id}),enabled:r}),l=EH(e.status),c=e.status==="running"?"var(--proto-accent)":"var(--proto-muted-2)",d=r?a.data:void 0,u=d?AH(d):null,f=!!u&&u.filled>1;return o.jsxs("div",{style:{background:"var(--proto-card)",border:"1px solid var(--proto-line)",borderRadius:10,boxShadow:"0 1px 2px rgba(16,24,40,.03)"},children:[o.jsxs("div",{onClick:()=>i(h=>!h),style:{padding:"11px 14px 9px",cursor:"pointer",borderBottom:"1px solid "+(r?"var(--proto-line-soft)":"transparent")},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[o.jsx("span",{style:{display:"inline-flex",color:c,stroke:c},children:qq}),o.jsx("span",{style:{font:"600 12.5px 'IBM Plex Mono',monospace",color:"var(--proto-ink)"},children:e.templateName}),o.jsx("span",{style:{marginLeft:"auto",fontSize:10.5,fontWeight:600,padding:"2px 8px",borderRadius:999,background:l.bg,color:l.fg},children:l.text})]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:5},children:[o.jsx("span",{style:{font:"400 10.5px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)"},children:OH(e,t)}),f&&u&&o.jsxs("span",{style:{marginLeft:"auto",display:"inline-flex",alignItems:"center",gap:3},children:[o.jsx("span",{style:{font:"500 9px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)",marginRight:2},children:n.rpDepth}),Array.from({length:u.total}).map((h,g)=>o.jsx("span",{style:{width:5,height:5,borderRadius:"50%",background:g<u.filled?"var(--proto-accent)":"var(--proto-line)"}},g)),o.jsx("span",{style:{font:"500 9px 'IBM Plex Mono',monospace",color:"var(--proto-muted)",marginLeft:2},children:u.text})]})]})]}),r&&a.isPending&&o.jsx("div",{style:{padding:"10px 14px",fontSize:11,color:"var(--proto-muted-3)"},children:n.rpLoadingThread}),r&&a.isError&&o.jsx("div",{style:{padding:"10px 14px",fontSize:11,color:"var(--proto-danger)"},children:n.rpFailedLoadThread}),r&&d&&o.jsx(eK,{detail:d,threadId:e.id})]})}const nK=o.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",strokeWidth:"1.6",children:[o.jsx("rect",{x:"1.5",y:"2",width:"11",height:"4",rx:"1",stroke:"currentColor"}),o.jsx("rect",{x:"1.5",y:"8",width:"11",height:"4",rx:"1",stroke:"currentColor"}),o.jsx("circle",{cx:"11",cy:"4",r:"0.9",fill:"currentColor",stroke:"none"}),o.jsx("circle",{cx:"11",cy:"10",r:"0.9",fill:"currentColor",stroke:"none"})]});function rK({machine:e}){const t=H(),n=NH(e.online),r=e.online?"var(--proto-accent)":"var(--proto-muted-2)",i=[];return e.gpuCount!=null&&i.push(`${t.mGpu} ×${e.gpuCount}`),i.push(e.os),e.liveRuns>0&&i.push(`${e.liveRuns} ${t.mLiveRuns}`),o.jsxs("div",{style:{background:"var(--proto-card)",border:"1px solid var(--proto-line)",borderRadius:10,boxShadow:"0 1px 2px rgba(16,24,40,.03)",padding:"11px 14px 9px"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[o.jsx("span",{style:{display:"inline-flex",color:r},children:nK}),o.jsx("span",{style:{font:"600 12.5px 'IBM Plex Mono',monospace",color:"var(--proto-ink)"},children:e.name}),o.jsx("span",{style:{marginLeft:"auto",fontSize:10.5,fontWeight:600,padding:"2px 8px",borderRadius:999,background:n.bg,color:n.fg},children:n.text})]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:5},children:[o.jsx("span",{style:{font:"400 10.5px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)"},children:i.join(" · ")}),e.liveRuns>0&&o.jsx("span",{style:{marginLeft:"auto",width:6,height:6,borderRadius:"50%",background:"var(--proto-accent)",flexShrink:0,animation:"cxpulse 1.6s ease-in-out infinite"}})]})]})}function oK(){const e=H(),t=le(),n=Y(t.machines.list.queryOptions({})),r=n.data??[],i=n.isSuccess?String(r.length):"—";return o.jsxs(o.Fragment,{children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"10px 18px",borderBottom:"1px solid var(--proto-line-2)",flex:"none"},children:[o.jsx("span",{style:{fontSize:10.5,color:"var(--proto-muted)"},children:e.machines}),o.jsx("span",{style:{marginLeft:"auto",font:"500 10.5px 'IBM Plex Mono',monospace",color:"var(--proto-muted)"},children:i})]}),o.jsxs("div",{style:{flex:1,padding:"12px 16px",display:"flex",flexDirection:"column",gap:10,overflow:"auto",minHeight:0},children:[r.map(s=>o.jsx(rK,{machine:s},s.name)),n.isSuccess&&r.length===0&&o.jsxs("div",{style:{textAlign:"center",padding:"26px 12px",border:"1px dashed var(--proto-line)",borderRadius:10},children:[o.jsx("div",{style:{fontSize:11.5,fontWeight:600,color:"var(--proto-muted-2)"},children:e.mNoMachines}),o.jsx("div",{style:{fontSize:10.5,color:"var(--proto-faint)",marginTop:4,lineHeight:1.6},children:e.rpNoMachinesHint})]}),n.isPending&&o.jsx("div",{style:{textAlign:"center",fontSize:11,color:"var(--proto-muted-3)",padding:"24px 0"},children:e.rpLoadingMachines}),n.isError&&o.jsx("div",{style:{textAlign:"center",fontSize:11,color:"var(--proto-danger)",padding:"24px 0"},children:e.rpFailedLoadMachines})]})]})}const iK=["active","history"],sK=["running","waiting","completed","failed","cancelled","aborted"],R3={running:"active",waiting:"active",completed:"history",failed:"history",cancelled:"history",aborted:"history"};function aK(e){return sK.filter(t=>R3[t]===e)}function I3(e){return iK.map(t=>({kind:t,threads:e.filter(n=>R3[n.status]===t)})).filter(t=>t.threads.length>0)}const lK=6e4;function cK(e,t=(r,i)=>window.setInterval(r,i),n=r=>window.clearInterval(r)){const r=t(e,lK);return()=>n(r)}function M3(e){const[t,n]=p.useState(()=>Date.now());return p.useEffect(()=>{if(e)return n(Date.now()),cK(()=>n(Date.now()))},[e]),t}function Ev(){const e=le(),t=je();Ci(av,()=>{t.invalidateQueries(e.threads.list.queryFilter())})}function L3({completed:e,onClick:t,disabled:n}){return o.jsx("button",{type:"button",disabled:n,"aria-label":e?"reopen note":"complete note",onClick:r=>{r.stopPropagation(),t()},style:{width:15,height:15,borderRadius:"50%",border:e?0:"1.5px solid var(--proto-line-3)",background:e?"var(--proto-success)":"transparent",color:"white",padding:0,flex:"none",fontSize:9,cursor:"pointer"},children:e?"✓":""})}function dK({copy:e,busy:t,onAdd:n}){const[r,i]=p.useState(""),s=async a=>{a.preventDefault();const l=r.trim();!l||t||(await n(l),i(""))};return o.jsx("form",{onSubmit:s,style:{margin:"12px 16px 0"},children:o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9,border:"1.5px solid var(--proto-accent)",borderRadius:10,boxShadow:"0 0 0 3px var(--proto-accent-bg)",padding:"9px 12px"},children:[o.jsx("span",{style:{width:15,height:15,borderRadius:"50%",border:"1.5px solid var(--proto-line-3)",boxSizing:"border-box",flex:"none"}}),o.jsx("input",{value:r,onChange:a=>i(a.target.value),placeholder:e.inputPlaceholder,"aria-label":e.inputPlaceholder,style:{flex:1,minWidth:0,border:0,outline:0,background:"transparent",fontSize:12.5,color:"var(--proto-ink)"}}),o.jsx("span",{style:{font:"500 9px 'IBM Plex Mono',monospace",color:"var(--proto-faint)",border:"1px solid var(--proto-line-2)",borderRadius:4,padding:"1px 5px"},children:e.enter})]})})}function uK({row:e,copy:t,busy:n,actions:r,onCancel:i}){const[s,a]=p.useState(e.text),l=async()=>{const c=s.trim();!c||n||(await r.onUpdate(e.id,c),i())};return o.jsxs("div",{style:{border:"1px solid var(--proto-accent-border)",borderRadius:9,padding:10},children:[o.jsx("input",{value:s,onChange:c=>a(c.target.value),autoFocus:!0,style:{width:"100%",boxSizing:"border-box",border:"1px solid var(--proto-line-3)",borderRadius:7,padding:"7px 9px",fontSize:12.5,outline:0}}),o.jsxs("div",{style:{display:"flex",gap:6,marginTop:8},children:[o.jsx(lc,{label:t.save,onClick:l,primary:!0,disabled:n}),o.jsx(lc,{label:t.cancel,onClick:i,disabled:n})]})]})}function lc({label:e,onClick:t,primary:n=!1,danger:r=!1,disabled:i=!1}){const s=r?"var(--proto-danger)":n?"white":"var(--proto-muted)";return o.jsx("button",{type:"button",disabled:i,onClick:a=>{a.stopPropagation(),t()},style:{border:n?0:"1px solid var(--proto-line)",borderRadius:7,padding:"4px 10px",background:n?"var(--proto-accent)":"var(--proto-card)",color:s,fontSize:10.5,fontWeight:600,cursor:i?"not-allowed":"pointer"},children:e})}function pK({row:e,copy:t,busy:n,actions:r,targeted:i,onSelect:s}){const[a,l]=p.useState(!1);return a?o.jsx(uK,{row:e,copy:t,busy:n,actions:r,onCancel:()=>l(!1)}):o.jsxs("div",{id:`note-${e.id}`,"data-note-target":e.id,onClick:()=>s(e.id),style:{border:i?"1px solid var(--proto-accent-border)":"1px solid transparent",borderRadius:10,background:i?"var(--proto-accent-bg)":"transparent",padding:"9px 10px",cursor:"pointer"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:9},children:[o.jsx(L3,{completed:!1,disabled:n,onClick:()=>void r.onSetCompleted(e.id,!0)}),o.jsx("span",{style:{fontSize:12.5,fontWeight:600,color:"var(--proto-ink)",lineHeight:1.45,minWidth:0},children:e.text}),o.jsx("span",{style:{marginLeft:"auto",font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-faint)",flex:"none"},children:e.timeLabel})]}),i&&o.jsxs("div",{"data-note-actions":e.id,style:{display:"flex",gap:6,marginTop:8,paddingLeft:24},children:[o.jsx(lc,{label:t.handoff,onClick:()=>r.onHandoff(e.text),primary:!0,disabled:n}),o.jsx(lc,{label:t.edit,onClick:()=>l(!0),disabled:n}),o.jsx(lc,{label:t.delete,onClick:()=>void r.onDelete(e.id),danger:!0,disabled:n})]})]})}function fK({row:e,busy:t,onReopen:n}){return o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9,padding:"8px 10px",opacity:.75},children:[o.jsx(L3,{completed:!0,disabled:t,onClick:n}),o.jsx("span",{style:{fontSize:12.5,color:"var(--proto-muted-2)",textDecoration:"line-through",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.text}),o.jsx("span",{style:{marginLeft:"auto",font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-faint)",flex:"none"},children:e.timeLabel})]})}function hK(e,t){p.useEffect(()=>{var n;e&&((n=document.getElementById(`note-${e}`))==null||n.scrollIntoView({block:"center"}))},[e]),p.useEffect(()=>{const n=r=>{r.key==="Escape"&&t()};return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[t])}function gK(e){const[t,n]=p.useState(!0);hK(e.targetId,e.onClose);const r=e;return o.jsxs("aside",{"data-notes-pane":"",style:{width:400,flex:"none",background:"var(--proto-card)",borderLeft:"1px solid var(--proto-line)",boxShadow:"-8px 0 24px rgba(16,24,40,.04)",display:"flex",flexDirection:"column",minHeight:0},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"13px 16px 11px",borderBottom:"1px solid var(--proto-line-2)"},children:[o.jsx("span",{style:{fontSize:13,fontWeight:650,color:"var(--proto-ink)"},children:e.copy.title}),o.jsx("span",{style:{font:"600 10px 'IBM Plex Mono',monospace",color:"var(--proto-muted)",background:"var(--proto-line-2)",padding:"2px 8px",borderRadius:999},children:e.vm.activeCount}),o.jsx("span",{style:{marginLeft:"auto",font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)"},children:"context/NOTES.md"}),o.jsx("button",{type:"button",onClick:e.onClose,style:{font:"500 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)",border:"1px solid var(--proto-line)",borderRadius:5,padding:"2px 6px",background:"transparent",cursor:"pointer"},children:e.copy.escape})]}),o.jsx(dK,{copy:e.copy,busy:e.busy,onAdd:e.onAdd}),o.jsxs("div",{style:{flex:1,minHeight:0,overflow:"auto",padding:"10px 14px 14px"},children:[o.jsxs("div",{style:{padding:"6px 2px 7px",fontSize:10,fontWeight:700,letterSpacing:".06em",color:"var(--proto-muted-3)"},children:[e.copy.todo," · ",e.vm.activeCount]}),e.vm.active.map(i=>o.jsx(pK,{row:i,copy:e.copy,busy:e.busy,actions:r,targeted:i.id===e.targetId,onSelect:e.onSelect},i.id)),e.vm.active.length===0&&o.jsx("div",{style:{padding:"14px 10px",fontSize:11,color:"var(--proto-faint)"},children:e.copy.empty}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"12px 2px 7px",borderTop:"1px solid var(--proto-line-2)",marginTop:6},children:[o.jsxs("button",{type:"button",onClick:()=>n(i=>!i),style:{border:0,background:"transparent",padding:0,fontSize:10,fontWeight:700,letterSpacing:".06em",color:"var(--proto-muted-3)",cursor:"pointer"},children:[e.copy.completed," · ",e.vm.completedCount," ",t?"▾":"▸"]}),e.vm.completedCount>0&&o.jsx("button",{type:"button",disabled:e.busy,onClick:()=>void e.onClearCompleted(),style:{marginLeft:"auto",border:0,background:"transparent",color:"var(--proto-danger)",fontSize:10.5,fontWeight:600,cursor:"pointer"},children:e.copy.clear})]}),t&&e.vm.completed.map(i=>o.jsx(fK,{row:i,busy:e.busy,onReopen:()=>void e.onSetCompleted(i.id,!1)},i.id))]}),o.jsx("div",{style:{padding:"9px 16px",borderTop:"1px solid var(--proto-line-2)",font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-faint)"},children:e.copy.privateHint})]})}function xK(){const e=Pf(),t=ze();return o.jsx(gK,{vm:e.vm,copy:e.copy,busy:e.busy,targetId:e.targetId,onSelect:e.open,onClose:e.close,onAdd:e.add,onUpdate:e.update,onSetCompleted:e.setCompleted,onDelete:e.remove,onHandoff:n=>{e.handoff(n),t("/workbench")},onClearCompleted:e.clearCompleted})}function Yh({label:e,count:t,countColor:n,active:r,dot:i,onClick:s}){return o.jsxs("div",{onClick:s,style:{fontSize:12.5,fontWeight:r?600:500,color:r?"var(--proto-ink)":"var(--proto-muted-2)",padding:"13px 0 11px",borderBottom:"2px solid "+(r?"var(--proto-ink)":"transparent"),marginBottom:-1,cursor:"pointer",display:"inline-flex",alignItems:"center",gap:5},children:[e," ",i&&o.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:"var(--proto-accent)",display:"inline-block"}}),o.jsx("span",{style:{font:"500 10px 'IBM Plex Mono',monospace",color:n},children:t})]})}const mK={fontSize:11.5,fontWeight:700,letterSpacing:".06em",textTransform:"uppercase",color:"var(--proto-muted)",padding:"8px 2px 4px"};function vK({group:e,label:t,now:n}){return o.jsxs("section",{children:[o.jsxs("div",{style:mK,children:[t," · ",e.threads.length]}),o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12},children:e.threads.map(r=>o.jsx(tK,{thread:r,now:n},r.id))})]})}function Of(){const{isOpen:e}=Pf();return e?o.jsx(xK,{}):o.jsx(yK,{})}function yK(){var j,y;const e=H(),t=le(),[n,r]=p.useState("threads"),i=M3(n==="threads");Ev();const{currentProjectId:s}=Ei(),a=Y({...t.cost.summary.queryOptions({projectId:s??void 0}),enabled:!!s}),l=s??void 0,c=Y(t.threads.list.queryOptions({projectId:l})),d=I3(c.data??[]),u=Y(t.tasks.list.queryOptions({...l?{projectId:l}:{}})),f=Y(t.machines.list.queryOptions({})),h=((j=d.find(w=>w.kind==="active"))==null?void 0:j.threads.length)??0,g=u.data?Mq(u.data):0,v=DH(f.data),x=(y=a.data)==null?void 0:y.today,b=typeof x=="number"?js(x):"—";return o.jsxs("div",{"data-pane":"right",style:{width:400,flex:"none",background:"var(--proto-rail)",borderLeft:"1px solid var(--proto-line)",display:"flex",flexDirection:"column",minHeight:0},children:[o.jsxs("div",{style:{display:"flex",gap:16,padding:"0 18px",borderBottom:"1px solid var(--proto-line)",flex:"none"},children:[o.jsx(Yh,{label:e.threads,count:String(h),countColor:"var(--proto-accent)",active:n==="threads",onClick:()=>r("threads")}),o.jsx(Yh,{label:e.tasks,count:String(g),countColor:"var(--proto-muted-2)",active:n==="tasks",onClick:()=>r("tasks")}),o.jsx(Yh,{label:e.machines,count:String(v),countColor:"var(--proto-muted-2)",active:n==="machines",dot:!0,onClick:()=>r("machines")})]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"10px 18px",borderBottom:"1px solid var(--proto-line-2)",flex:"none"},children:[o.jsx("span",{style:{fontSize:10.5,fontWeight:600,color:"var(--proto-muted-2)"},children:e.today}),o.jsx("div",{style:{flex:1,height:4,borderRadius:999,background:"var(--proto-line-2)",overflow:"hidden"},children:o.jsx("div",{style:{width:"0%",height:"100%",borderRadius:999,background:"var(--proto-accent)"}})}),o.jsxs("span",{style:{font:"500 10.5px 'IBM Plex Mono',monospace",color:"var(--proto-ink)"},children:[b," / —"]})]}),n==="threads"&&o.jsxs("div",{style:{flex:1,padding:"12px 16px",display:"flex",flexDirection:"column",gap:6,overflow:"auto",minHeight:0},children:[d.map(w=>o.jsx(vK,{group:w,label:w.kind==="active"?e.active:e.history,now:i},w.kind)),c.isSuccess&&d.length===0&&o.jsxs("div",{style:{textAlign:"center",padding:"26px 12px",border:"1px dashed var(--proto-line)",borderRadius:10},children:[o.jsx("div",{style:{fontSize:11.5,fontWeight:600,color:"var(--proto-muted-2)"},children:e.rpNoActiveThreads}),o.jsx("div",{style:{fontSize:10.5,color:"var(--proto-faint)",marginTop:4,lineHeight:1.6},children:e.rpNoActiveThreadsHint})]})]}),n==="tasks"&&o.jsx("div",{style:{flex:1,padding:"12px 16px",display:"flex",flexDirection:"column",gap:6,overflow:"auto",minHeight:0},children:o.jsx(T3,{projectId:l})}),n==="machines"&&o.jsx(oK,{})]})}function bK(){const{active:e,split:t}=Cf();return o.jsxs("div",{style:{height:"100vh",minHeight:640,minWidth:1280,display:"flex",background:"var(--proto-card)",overflow:"hidden"},children:[o.jsx(If,{}),o.jsx(Eq,{grow:e?1-t:1}),o.jsx(jH,{}),o.jsx(Of,{})]})}function jK(){const e=H();return o.jsxs("section",{className:"flex h-full flex-col p-2g",children:[o.jsx("h1",{className:"mb-2g text-body font-medium text-state-ink",children:e.tasks}),o.jsx(T3,{})]})}function wK(){return o.jsx(sf,{severity:"waiting",pulse:!0,title:"Rate limit reached — 3 items auto-paused",meta:"resets 14:00 · 2h 08m",children:o.jsxs("div",{className:"flex flex-col gap-1g",children:[o.jsx(Gh,{label:"session morning-review — paused",note:"auto-resumes after reset"}),o.jsx(Gh,{label:"schedule inbox-sweep — paused",note:"pausedBy: rate-limit"}),o.jsx(Gh,{label:"task dispatch — held by guard, queue kept",note:"beforeRunGuard",muted:!0})]})})}function Gh({label:e,note:t,muted:n}){return o.jsxs("div",{className:"flex items-center gap-1g rounded-card border border-card px-1.5g py-1g",children:[o.jsx("span",{className:["h-0.5g w-0.5g flex-none rounded-full",n?"bg-state-gray":"bg-state-wait"].join(" ")}),o.jsx("span",{className:"text-ui text-state-ink/80",children:e}),o.jsx(cn,{muted:!0,className:"ml-auto text-ui",children:t})]})}function kK(){return o.jsxs(sf,{severity:"info",title:"step 3 · executor:analyze",meta:"fallback chain from profiles.json",children:[o.jsxs("div",{className:"flex flex-col gap-0.5g font-mono text-ui",children:[o.jsxs("div",{className:"flex gap-1g",children:[o.jsx("span",{className:"flex-none text-pill-failed-fg",children:"✕"}),o.jsx("span",{className:"text-state-ink/70",children:"claude · print — transient backend error (exit 1)"})]}),o.jsxs("div",{className:"flex gap-1g",children:[o.jsx("span",{className:"flex-none text-pill-done-fg",children:"→"}),o.jsxs("span",{className:"text-state-ink/80",children:["fallback ",o.jsx("span",{className:"text-pill-running-fg",children:"pi"})," — inherits main profile, step re-run"]})]}),o.jsxs("div",{className:"flex gap-1g",children:[o.jsx("span",{className:"flex-none text-state-ink/30",children:" "}),o.jsx("span",{className:"text-state-ink/40",children:"artifact.md untouched · completed steps not re-run"})]})]}),o.jsx("div",{className:"flex items-center gap-1g",children:o.jsx(pp,{tone:"running",label:"● retrying"})})]})}function SK(){return o.jsx(sf,{severity:"human",title:o.jsxs("span",{className:"flex items-center gap-1g",children:[o.jsx(cn,{children:"gpu-01"}),o.jsx(pp,{tone:"failed",label:"offline"})]}),meta:"last seen 09:12 · ws closed",detail:o.jsxs("div",{className:"flex flex-col gap-1g",children:[o.jsxs("div",{className:"rounded-card border border-card bg-surface-canvas-alt px-1.5g py-1g font-mono text-ui text-state-ink/70",children:["exec_31c2 → ",o.jsx("span",{className:"text-pill-failed-fg",children:"lost"})," (3 missed heartbeats) · thread notified"]}),o.jsx("div",{className:"rounded-card border border-card bg-surface-canvas-alt px-1.5g py-1g font-mono text-ui text-state-ink/70",children:"T-045 pending held · 4h no callback auto-clears tracking · reopenable"})]}),actions:o.jsxs(o.Fragment,{children:[o.jsx(yt,{variant:"primary",size:"sm",children:"Reopen task"}),o.jsx("span",{className:"self-center text-ui text-state-ink/50",children:"cortex-client auto-reconnects; run state re-read from state file"})]})})}function CK(){return o.jsx(sf,{severity:"waiting",pulse:!0,title:"Thread paused — would exceed today's budget",meta:"waiting",detail:o.jsxs("span",{children:["Next dispatch est. ",o.jsx(cn,{children:"$6.40"}),", remaining today"," ",o.jsx(cn,{className:"text-pill-failed-fg",children:"$1.10"})," — pre-check held it before dispatch; approval queued ",o.jsx(hx,{value:"APR-0008"})]}),actions:o.jsxs(o.Fragment,{children:[o.jsx(yt,{variant:"primary",size:"sm",children:"Approve once"}),o.jsx(yt,{variant:"secondary",size:"sm",children:"Reject"}),o.jsx(yt,{variant:"secondary",size:"sm",children:"Adjust budget…"})]})})}function EK(){return o.jsxs("div",{className:"grid grid-cols-1 gap-2g md:grid-cols-2",children:[o.jsx(wK,{}),o.jsx(kK,{}),o.jsx(SK,{}),o.jsx(CK,{})]})}const TK=["running","waiting","completed","failed","cancelled","aborted","stale","open","done"],Mj=["primary","secondary","ghost","danger"];function Ws({title:e,children:t}){return o.jsxs("section",{className:"flex flex-col gap-2g",children:[o.jsx(Qs,{title:e}),o.jsx(gx,{padded:!0,children:o.jsx("div",{className:"flex flex-wrap items-center gap-2g",children:t})})]})}function PK(){return o.jsxs("div",{className:"flex h-full flex-col gap-4g overflow-auto p-2g pb-6g",children:[o.jsx(Qs,{title:"Design Kit",description:"Token-driven core primitives (design §5). All colors from tailwind tokens."}),o.jsx(Ws,{title:"StatusPill — tones",children:w9.map(e=>o.jsx(pp,{tone:e,label:e},e))}),o.jsx(Ws,{title:"StatusPill — contract statuses",children:TK.map(e=>o.jsx(pp,{status:e},e))}),o.jsxs(Ws,{title:"MonoText & ID",children:[o.jsx(cn,{children:"mono-text"}),o.jsx(cn,{muted:!0,children:"mono-text muted"}),o.jsx(hx,{value:"thr_99a13064"}),o.jsx(hx,{value:"e794",copyable:!0})]}),o.jsxs(Ws,{title:"Button — variants × sizes",children:[Mj.map(e=>o.jsx(yt,{variant:e,size:"md",children:e},e)),Mj.map(e=>o.jsxs(yt,{variant:e,size:"sm",children:[e," sm"]},`${e}-sm`)),o.jsx(yt,{variant:"primary",disabled:!0,children:"disabled"})]}),o.jsx(Ws,{title:"Tooltip",children:o.jsx(gM,{content:"I am a token-styled tooltip",children:o.jsx(yt,{variant:"secondary",children:"Hover me"})})}),o.jsxs("section",{className:"flex flex-col gap-2g",children:[o.jsx(Qs,{title:"Card + header/body",count:2}),o.jsxs(gx,{children:[o.jsx(T9,{children:o.jsx(cn,{children:"card-header"})}),o.jsx(P9,{children:o.jsx("p",{className:"text-ui text-state-ink/70",children:"Card body content sits on the white surface."})})]})]}),o.jsxs("section",{className:"flex flex-col gap-2g",children:[o.jsx(Qs,{title:"Tabs"}),o.jsx(gx,{padded:!0,children:o.jsx(bI,{items:[{value:"one",label:"Overview",content:o.jsx(cn,{children:"panel one"})},{value:"two",label:"Details",content:o.jsx(cn,{children:"panel two"})},{value:"three",label:"Logs",content:o.jsx(cn,{children:"panel three"})}]})})]}),o.jsxs("section",{className:"flex flex-col gap-2g",children:[o.jsx(Qs,{title:"Degraded states (10c)",description:"Unified exception language — amber=waiting, red=needs-human, blue=transient note."}),o.jsx(EK,{})]}),o.jsxs("section",{className:"flex flex-col gap-2g",children:[o.jsx(Qs,{title:"Empty states (10d)",description:"Every empty panel points to a next action — no dead wall."}),o.jsxs("div",{className:"grid grid-cols-1 gap-2g md:grid-cols-3",children:[o.jsx(Mu,{title:"Give Cortex a mission",description:"Describe a goal and success criteria — planning, dispatch and record-keeping follow.",action:o.jsxs("div",{className:"flex w-full flex-col gap-1g",children:[o.jsx("span",{className:"rounded-card border border-card bg-surface-canvas-alt px-1.5g py-1g text-left text-ui text-state-ink/60",children:'"Scan arXiv sim2real each morning and summarize"'}),o.jsx("span",{className:"rounded-card border border-card bg-surface-canvas-alt px-1.5g py-1g text-left text-ui text-state-ink/60",children:'"Finish the σ ablation and find the seed-variance root cause"'})]})}),o.jsx(Mu,{title:"No tasks yet",description:"Set a goal in chat and Cortex decomposes a queue with priority, deps and done-when.",action:o.jsx(yt,{variant:"primary",children:"+ Add task"})}),o.jsx(Mu,{title:"No threads yet",description:"Complex work runs as multi-agent relay pipelines here — created on dispatch.",action:o.jsx(cn,{muted:!0,children:"!thread experiment-pipeline 〈goal〉"})})]})]}),o.jsx(Ws,{title:"Overlays — Modal / Drawer / Toast / Popover (esc closes, focus trapped)",children:o.jsx(RK,{})})]})}function RK(){const{toast:e}=dr();return o.jsxs(o.Fragment,{children:[o.jsx(cf,{title:"Task detail",description:"Radix Dialog: focus is trapped while open, Esc closes, focus returns to the trigger.",trigger:o.jsx(yt,{variant:"primary",children:"Open Modal"}),footer:o.jsx(kL,{asChild:!0,children:o.jsx(yt,{variant:"secondary",children:"Close"})}),children:o.jsx("p",{children:"Body content on the white token surface. Try Tab / Shift-Tab and Esc."})}),o.jsx(EL,{title:"Details drawer",description:"Side sheet on Radix Dialog — slides in from the right, Esc closes.",trigger:o.jsx(yt,{variant:"secondary",children:"Open Drawer"}),footer:o.jsx(TL,{asChild:!0,children:o.jsx(yt,{variant:"secondary",children:"Close"})}),children:o.jsx("p",{children:"Full-height drawer content. Same a11y as Modal."})}),o.jsx(yt,{variant:"secondary",onClick:()=>e({title:"Task completed",description:"c407 moved open → done",tone:"done"}),children:"Fire Toast"}),o.jsx(H5,{trigger:o.jsx(yt,{variant:"secondary",children:"Open Popover"}),children:o.jsxs("div",{className:"flex flex-col gap-1g",children:[o.jsx(cn,{children:"popover content"}),o.jsx("p",{className:"text-state-ink/70",children:"Positioned by Radix; Esc closes, focus returns."})]})})]})}const IK=[{name:"base",hex:"var(--surface-base)"},{name:"card",hex:"var(--proto-card)"},{name:"rail",hex:"var(--proto-rail)"},{name:"alt",hex:"var(--proto-alt)"},{name:"gray",hex:"var(--proto-gray)"},{name:"ink",hex:"var(--proto-ink)",dark:!0},{name:"ink-2",hex:"var(--proto-ink-2)",dark:!0},{name:"ink-3",hex:"var(--proto-ink-3)",dark:!0},{name:"muted",hex:"var(--proto-muted)",dark:!0},{name:"muted-2",hex:"var(--proto-muted-2)",dark:!0},{name:"muted-3",hex:"var(--proto-muted-3)",dark:!0},{name:"faint",hex:"var(--proto-faint)"},{name:"line",hex:"var(--proto-line)"},{name:"line-2",hex:"var(--proto-line-2)"},{name:"line-3",hex:"var(--proto-line-3)"},{name:"line-4",hex:"var(--proto-line-4)"},{name:"accent",hex:"var(--proto-accent)",dark:!0},{name:"accent-bg",hex:"var(--proto-accent-bg)"},{name:"accent-border",hex:"var(--proto-accent-border)"},{name:"accent-2",hex:"var(--proto-accent-2)",dark:!0},{name:"accent-strong",hex:"var(--proto-accent-strong)",dark:!0},{name:"amber",hex:"var(--proto-amber)",dark:!0},{name:"amber-fg",hex:"var(--proto-amber-fg)",dark:!0},{name:"amber-bg",hex:"var(--proto-amber-bg)"},{name:"amber-border",hex:"var(--proto-amber-border)"},{name:"amber-accent",hex:"var(--proto-amber-accent)",dark:!0},{name:"success",hex:"var(--proto-success)",dark:!0},{name:"success-bg",hex:"var(--proto-success-bg)"},{name:"danger",hex:"var(--proto-danger)",dark:!0},{name:"danger-bg",hex:"var(--proto-danger-bg)"}],MK=["cxblink","cxpulse","cxtoast","cxfade","cxmodal","cxcmdk","cxpop","cxpopup","cxpopover","cxdrawer","cxmodalout","cxcmdkout","cxdrawerout","cxfadeout","cxmsg","cxrise"],LK=["9px","10px","10.5px","11px","12px","15px"];function cu({children:e}){return o.jsx("div",{style:{fontSize:"10px",fontWeight:700,letterSpacing:"0.07em",color:"var(--proto-faint)",textTransform:"uppercase",margin:"28px 0 12px"},children:e})}function OK(){return o.jsxs("div",{style:{padding:"24px 28px",background:"var(--proto-card)",minHeight:"100%",overflow:"auto"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"9px"},children:[o.jsx("div",{style:{width:26,height:26,borderRadius:7,background:"var(--proto-ink)",color:"var(--ink-solid-fg)",display:"flex",alignItems:"center",justifyContent:"center",font:"600 12px 'IBM Plex Mono',monospace"},children:"cx"}),o.jsx("div",{style:{fontWeight:650,fontSize:14,color:"var(--proto-ink)",letterSpacing:"-0.01em"},children:"Cortex — base specimen"})]}),o.jsx(cu,{children:"Sans (UI)"}),o.jsxs("div",{style:{fontFamily:"inherit",color:"var(--proto-ink)"},children:[o.jsx("div",{style:{fontSize:14,fontWeight:650,letterSpacing:"-0.01em"},children:"Interface heading — 14px / 650"}),o.jsx("div",{style:{fontSize:13,fontWeight:600,marginTop:4},children:"Section label — 13px / 600"}),o.jsx("div",{style:{fontSize:12.5,fontWeight:400,color:"var(--proto-muted)",marginTop:4},children:"Body copy — 12.5px / 400 · The quick brown fox jumps over the lazy dog. 中文界面文字样张。"})]}),o.jsx(cu,{children:"Mono (data / IDs) — IBM Plex Mono"}),o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:LK.map(e=>o.jsxs("div",{style:{font:`500 ${e} 'IBM Plex Mono',monospace`,color:"var(--proto-ink)"},children:["thr_502fb888 · 6d21 · $2.64 · 3m 27s — ",e]},e))}),o.jsx(cu,{children:"Palette (audited prototype colors)"}),o.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(120px, 1fr))",gap:8},children:IK.map(e=>o.jsxs("div",{style:{border:"1px solid var(--proto-line)",borderRadius:8,overflow:"hidden"},children:[o.jsx("div",{style:{height:40,background:e.hex,display:"flex",alignItems:"flex-end",justifyContent:"flex-end",padding:5},children:o.jsx("span",{style:{font:"500 8.5px 'IBM Plex Mono',monospace",color:e.dark?"var(--proto-card)":"var(--proto-muted-3)"},children:e.hex})}),o.jsx("div",{style:{padding:"5px 7px",fontSize:11,fontWeight:600,color:"var(--proto-ink-2)",background:"var(--proto-card)"},children:e.name})]},e.name))}),o.jsx(cu,{children:"Animations — running dot · caret · enter set"}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:20,marginBottom:16},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7},children:[o.jsx("span",{style:{width:7,height:7,borderRadius:"50%",background:"var(--proto-accent)",display:"inline-block",animation:"cxpulse 1.6s ease-in-out infinite"}}),o.jsx("span",{style:{fontSize:12,color:"var(--proto-accent)",fontWeight:600},children:"running (cxpulse)"})]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7},children:[o.jsx("span",{style:{width:7,height:7,borderRadius:"50%",background:"var(--proto-amber)",display:"inline-block",animation:"cxpulse 2s ease-in-out infinite"}}),o.jsx("span",{style:{fontSize:12,color:"var(--proto-amber-fg)",fontWeight:600},children:"approval (cxpulse 2s)"})]}),o.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:2},children:[o.jsx("span",{style:{font:"500 12px 'IBM Plex Mono',monospace",color:"var(--proto-ink)"},children:"cortex"}),o.jsx("span",{style:{display:"inline-block",width:7,height:14,background:"var(--proto-ink)",animation:"cxblink 1.1s steps(1) infinite"}}),o.jsx("span",{style:{fontSize:12,color:"var(--proto-muted-3)",marginLeft:6},children:"caret (cxblink)"})]})]}),o.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(110px, 1fr))",gap:8},children:MK.map(e=>o.jsx("div",{style:{border:"1px solid var(--proto-line)",borderRadius:8,padding:"10px 8px",textAlign:"center",background:"var(--proto-rail)",animation:`${e} 1.6s ease-in-out infinite`},children:o.jsx("span",{style:{font:"500 10px 'IBM Plex Mono',monospace",color:"var(--proto-ink-2)"},children:e})},e))})]})}function AK({copy:e,onAdd:t}){const[n,r]=p.useState(""),i=async s=>{s.preventDefault(),s.stopPropagation();const a=n.trim();a&&(await t(a),r(""))};return o.jsx("form",{onSubmit:i,onClick:s=>s.stopPropagation(),style:{margin:"10px 14px 2px"},children:o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,border:"1px solid var(--proto-line-3)",borderRadius:8,padding:"7px 10px"},children:[o.jsx("span",{style:{width:14,height:14,borderRadius:"50%",border:"1.5px solid var(--proto-line-3)",boxSizing:"border-box",flex:"none"}}),o.jsx("input",{value:n,onChange:s=>r(s.target.value),placeholder:e.inputPlaceholder,"aria-label":e.inputPlaceholder,style:{flex:1,minWidth:0,border:0,outline:0,background:"transparent",fontSize:11.5,color:"var(--proto-ink)"}}),o.jsx("span",{style:{font:"500 9px 'IBM Plex Mono',monospace",color:"var(--proto-faint)",border:"1px solid var(--proto-line-2)",borderRadius:4,padding:"1px 5px"},children:e.enter})]})})}function DK({row:e,onOpen:t}){return o.jsxs("div",{onClick:n=>{n.stopPropagation(),t(e.id)},style:{display:"flex",alignItems:"center",gap:9,padding:"8px 0",borderBottom:"1px solid var(--proto-alt)",cursor:"pointer"},children:[o.jsx("span",{style:{width:14,height:14,borderRadius:"50%",border:"1.5px solid var(--proto-line-3)",boxSizing:"border-box",flex:"none"}}),o.jsx("span",{style:{fontSize:11.5,fontWeight:600,color:"var(--proto-ink-2)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",minWidth:0},children:e.text}),o.jsx("span",{style:{marginLeft:"auto",font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-faint)",flex:"none"},children:e.timeLabel})]})}function NK({vm:e,copy:t,onOpen:n,onAdd:r}){return o.jsxs("div",{"data-notes-overview-card":"",onClick:()=>n(),style:{background:"var(--proto-card)",border:"1px solid var(--proto-line)",borderRadius:10,boxShadow:"0 1px 2px rgba(16,24,40,.03)",cursor:"pointer",minWidth:0},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"10px 14px",borderBottom:"1px solid var(--proto-line-2)"},children:[o.jsx("span",{style:{fontSize:12,fontWeight:650,color:"var(--proto-ink)"},children:t.title}),o.jsx("span",{style:{marginLeft:"auto",font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)"},children:"context/NOTES.md"})]}),o.jsx(AK,{copy:t,onAdd:r}),o.jsxs("div",{style:{padding:"2px 14px 6px"},children:[e.previews.map(i=>o.jsx(DK,{row:i,onOpen:n},i.id)),e.activeCount===0&&o.jsx("div",{style:{padding:"12px 0",color:"var(--proto-faint)",fontSize:10.5},children:t.empty})]}),o.jsxs("div",{style:{borderTop:"1px solid var(--proto-line-2)",padding:"9px 14px",display:"flex",alignItems:"center",fontSize:11,fontWeight:600,color:"var(--proto-accent)"},children:[o.jsxs("span",{children:[t.viewAll," ",e.activeCount," ›"]}),o.jsxs("span",{style:{marginLeft:"auto",font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-faint)"},children:[t.completed," ",e.completedCount]})]})]})}function Ht(e){return"$"+(e??0).toFixed(2)}const _K=5;function O3(e,t){if(t==null||t<=0)return null;const n=(e??0)/t*100;return Math.max(0,Math.min(100,n))}function $K(e){return e==null||e<=0?"—":Ht(e)}function FK(e){if(!e||e.length===0)return[];const t=e.reduce((r,i)=>Math.max(r,i.cost),0),n=e.length-1;return e.map((r,i)=>({pct:t>0?r.cost/t*100:0,date:r.date,cost:r.cost,isToday:i===n}))}function zK(e){return!e||e.length===0?null:e.reduce((n,r)=>n+r.cost,0)/e.length}function BK(e,t="week"){if(!e)return[];const n=Object.entries(e).map(([i,s])=>({label:i,cost:s[t]})).filter(i=>i.cost>0).sort((i,s)=>s.cost-i.cost).slice(0,_K),r=n.reduce((i,s)=>i+s.cost,0);return n.map(i=>({label:i.label,cost:i.cost,pct:r>0?i.cost/r*100:0}))}function WK(e,t){var n;if(e.length){const r=[...e].sort((i,s)=>Date.parse(s.lastUsedAt||s.createdAt)-Date.parse(i.lastUsedAt||i.createdAt))[0];if(r!=null&&r.projectId)return r.projectId}return((n=t[0])==null?void 0:n.id)??null}function UK(e){const t=new Date(e),n=String(t.getHours()).padStart(2,"0"),r=String(t.getMinutes()).padStart(2,"0");return`${n}:${r}`}function HK(e){return(e.type==="daily"||e.type==="weekly")&&e.nextRun?`${e.type} ${UK(e.nextRun)}`:e.type}function Lj(e){return e.profile??""}function A3(e){const t=Math.round(e/6e4);if(t<1)return"<1m";if(t<60)return`${t}m`;const n=Math.round(e/36e5);return n<24?`${n}h`:`${Math.round(e/864e5)}d`}function VK(e,t){if(!e)return"—";const n=Date.parse(e)-t;return n<=0?"due":`next in ${A3(n)}`}function Oj(e,t){if(!e)return"never run";const n=t-Date.parse(e);return`last ${A3(Math.max(0,n))} ago`}function qK(e,t){return typeof e.durationMs=="number"?e.durationMs:e.startedAt?Math.max(0,t-Date.parse(e.startedAt)):null}function KK(e){if(e==null)return"—";if(e>=36e5){const t=Math.floor(e/36e5),n=Math.round(e%36e5/6e4);return`${t}h ${n}m`}return e>=6e4?`${Math.round(e/6e4)}m`:`${Math.round(e/1e3)}s`}function QK(e){return e.machine??"local"}function YK(e){return e==null?"—":"$"+e.toFixed(2)}function GK(e){switch(e){case"running":return{text:"running",bg:"#EEF0FA",color:"#4655D4",dot:!0};case"completed":return{text:"done",bg:"#E9F4EE",color:"#23854F",dot:!1};case"failed":return{text:"failed",bg:"#FBEDEB",color:"#C03D33",dot:!1};case"cancelled":return{text:"cancelled",bg:"#F1F2F5",color:"#8A93A2",dot:!1};case"stale":default:return{text:"stale",bg:"#F1F2F5",color:"#8A93A2",dot:!1}}}function XK(e){return e.taskId?`task ${e.taskId}`:e.sessionId?`session ${e.sessionId}`:`${e.type} execution`}const Us={background:"var(--proto-card)",border:"1px solid var(--proto-line)",borderRadius:10,boxShadow:"0 1px 2px rgba(16,24,40,.03)",minWidth:0};function du({title:e,right:t}){return o.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"10px 14px",borderBottom:"1px solid var(--proto-line-2)"},children:[o.jsx("span",{style:{fontSize:12,fontWeight:650,color:"var(--proto-ink)"},children:e}),t!=null&&o.jsx("span",{style:{marginLeft:"auto",font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)"},children:t})]})}function JK(){var P;const e=H(),t=ze(),n=le(),r=je(),{open:i}=l6(),{open:s}=TW(),{open:a}=lU(),l=Pf(),c=Date.now(),{currentProjectId:d}=Ei(),u=d??"—",h=Y({...n.cost.summary.queryOptions({projectId:d??void 0}),enabled:!!d}).data,g=O3(h==null?void 0:h.today,h==null?void 0:h.dailyBudget),v=p.useMemo(()=>FK(h==null?void 0:h.dailyCost),[h==null?void 0:h.dailyCost]),x=p.useMemo(()=>zK(h==null?void 0:h.dailyCost),[h==null?void 0:h.dailyCost]),b=p.useMemo(()=>BK(h==null?void 0:h.byTriggerScoped,"week"),[h==null?void 0:h.byTriggerScoped]),y=Y({...n.schedules.list.queryOptions({projectId:d??void 0}),enabled:!!d}).data??[],w=Y(n.executions.list.queryOptions({limit:50})),k=p.useMemo(()=>{const I=w.data??[];return(d?I.filter(z=>z.projectId===d):I).slice(0,6)},[w.data,d]),S=Y({...n.issues.list.queryOptions({projectId:d??""}),enabled:!!d}),T=p.useMemo(()=>S.data??[],[S.data]),C=xe(n.schedules.resume.mutationOptions({onSuccess:()=>{r.invalidateQueries(n.schedules.list.queryFilter())}}));return o.jsxs("div",{"data-pane":"center",style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",minHeight:0,background:"var(--proto-card)"},children:[o.jsxs("div",{style:{height:50,flex:"none",borderBottom:"1px solid var(--proto-line)",display:"flex",alignItems:"center",gap:9,padding:"0 20px",background:"var(--proto-card)"},children:[o.jsx("span",{onClick:()=>t("/workbench"),style:{fontSize:14,color:"var(--proto-muted)",cursor:"pointer",padding:"4px 8px 4px 0"},children:"‹"}),o.jsx("span",{style:{font:"500 12px 'IBM Plex Mono',monospace",color:"var(--proto-muted-2)"},children:u}),o.jsx("span",{style:{color:"var(--proto-line-3)"},children:"/"}),o.jsx("span",{style:{fontSize:12.5,fontWeight:600,color:"var(--proto-ink)"},children:e.overview}),o.jsxs("span",{style:{position:"relative",marginLeft:"auto",display:"inline-flex",alignItems:"center",gap:8},children:[T.length>0&&o.jsxs("span",{"data-issues-stat":"",onClick:()=>a(),style:{display:"inline-flex",alignItems:"center",gap:4,font:"500 10px 'IBM Plex Mono',monospace",color:"var(--proto-muted)",padding:"3px 8px",cursor:"pointer"},children:[o.jsx("b",{style:{color:"var(--proto-accent)"},children:T.length})," ",e.issuesStat]}),o.jsx("span",{style:{width:1,height:18,background:"var(--proto-line)",flex:"none"}}),o.jsx(h3,{count:l.vm.activeCount,active:l.isOpen,copy:l.copy,onClick:()=>l.isOpen?l.close():l.open()}),o.jsx("span",{style:{fontSize:11.5,fontWeight:600,border:"1px solid var(--proto-line-3)",borderRadius:7,padding:"4px 12px",color:"var(--proto-ink)",background:"var(--proto-card)",cursor:"pointer"},children:e.adjustBudget}),o.jsx("span",{style:{color:"var(--proto-muted-2)",fontSize:15,letterSpacing:1,padding:"2px 6px",borderRadius:6,cursor:"pointer"},children:"⋯"})]})]}),o.jsxs("div",{style:{flex:"none",borderBottom:"1px solid var(--proto-line)",display:"flex",alignItems:"center",gap:30,padding:"12px 20px 14px",background:"var(--proto-card)"},children:[o.jsxs("div",{style:{minWidth:180},children:[o.jsx("div",{style:{fontSize:10,color:"var(--proto-muted-3)",marginBottom:3},children:e.today}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[o.jsx("span",{style:{font:"600 22px 'IBM Plex Mono',monospace",color:"var(--proto-ink)",letterSpacing:"-.02em"},children:Ht(h==null?void 0:h.today)}),o.jsx("div",{style:{flex:1,height:5,borderRadius:999,background:"var(--proto-line-2)",overflow:"hidden",marginTop:2},children:o.jsx("div",{style:{width:`${g??0}%`,height:"100%",background:"var(--proto-accent)"}})})]})]}),o.jsxs("div",{children:[o.jsx("div",{style:{fontSize:10,color:"var(--proto-muted-3)",marginBottom:3},children:e.thisWeek}),o.jsx("div",{style:{font:"600 15px 'IBM Plex Mono',monospace",color:"var(--proto-ink-2)"},children:Ht(h==null?void 0:h.week)})]}),o.jsxs("div",{children:[o.jsx("div",{style:{fontSize:10,color:"var(--proto-muted-3)",marginBottom:3},children:e.month}),o.jsx("div",{style:{font:"600 15px 'IBM Plex Mono',monospace",color:"var(--proto-ink-2)"},children:Ht(h==null?void 0:h.month)})]}),o.jsxs("div",{children:[o.jsx("div",{style:{fontSize:10,color:"var(--proto-muted-3)",marginBottom:3},children:e.budgetPerDay}),o.jsxs("div",{style:{font:"600 15px 'IBM Plex Mono',monospace",color:"var(--proto-ink-2)"},children:[$K(h==null?void 0:h.dailyBudget),o.jsxs("span",{style:{fontSize:10,color:"var(--proto-muted-3)",fontWeight:400},children:[" ",e.perDay]})]})]}),o.jsxs("div",{style:{marginLeft:"auto",textAlign:"right"},children:[o.jsx("div",{style:{fontSize:10,color:"var(--proto-muted-3)",marginBottom:3},children:e.forecastToday}),o.jsx("div",{style:{font:"600 15px 'IBM Plex Mono',monospace",color:"var(--proto-amber-text)"},children:Ht(h==null?void 0:h.forecastToday)})]})]}),o.jsxs("div",{style:{flex:1,overflow:"auto",minHeight:0,padding:"14px 20px",display:"grid",gridTemplateColumns:"1fr 1fr",gridAutoRows:"min-content",gap:12,background:"var(--proto-alt)",alignContent:"start"},children:[o.jsxs("div",{style:Us,children:[o.jsx(du,{title:e.ovLast14Days,right:`${e.ovAvg} ${x==null?"—":Ht(x)}${e.perDay}`}),o.jsxs("div",{style:{padding:"14px 14px 10px"},children:[o.jsx("div",{style:{display:"flex",alignItems:"flex-end",gap:5,height:96},children:v.map(I=>I.isToday?o.jsx("div",{title:`${I.date} · ${Ht(I.cost)}`,style:{flex:1,position:"relative",background:"var(--proto-accent)",borderRadius:"3px 3px 0 0",height:`${I.pct}%`},children:o.jsx("div",{style:{position:"absolute",bottom:"100%",left:"50%",transform:"translateX(-50%)",marginBottom:5,font:"600 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-accent)",whiteSpace:"nowrap"},children:Ht(I.cost)})},I.date):o.jsx("div",{title:`${I.date} · ${Ht(I.cost)}`,style:{flex:1,background:"var(--proto-line-4)",borderRadius:"3px 3px 0 0",height:`${I.pct}%`}},I.date))}),o.jsxs("div",{style:{display:"flex",alignItems:"center",marginTop:7,font:"400 9px 'IBM Plex Mono',monospace",color:"var(--proto-faint)"},children:[o.jsx("span",{children:((P=v[0])==null?void 0:P.date)??"—"}),o.jsx("span",{style:{marginLeft:"auto",color:"var(--proto-accent)",fontWeight:600},children:e.today})]})]})]}),o.jsxs("div",{style:{...Us,cursor:"pointer"},onClick:()=>t("/memory"),children:[o.jsx(du,{title:e.projectMemory,right:e.ovGitBacked}),o.jsxs("div",{style:{padding:"18px 14px",display:"flex",flexDirection:"column",alignItems:"center",gap:4,textAlign:"center"},children:[o.jsxs("div",{style:{fontSize:11.5,fontWeight:600,color:"var(--proto-accent)"},children:[e.ovOpenMemoryViewer," ›"]}),o.jsx("div",{style:{fontSize:10.5,color:"var(--proto-faint)",lineHeight:1.5},children:e.ovMemoryDesc})]})]}),o.jsx(NK,{vm:l.vm,copy:l.copy,onOpen:l.open,onAdd:l.add}),T.length>0&&o.jsxs("div",{style:Us,"data-issues-card":"",children:[o.jsx(du,{title:e.issuesTitle,right:"ISSUES.md"}),o.jsx("div",{style:{padding:"4px 14px 6px"},children:T.slice(0,3).map((I,L)=>o.jsxs("div",{onClick:()=>a(I.id),style:{display:"flex",alignItems:"center",gap:9,padding:"8px 0",borderBottom:L<Math.min(T.length,3)-1?"1px solid var(--proto-alt)":"none",cursor:"pointer"},children:[o.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 14 14",fill:"none",stroke:"var(--proto-muted-2)",strokeWidth:"1.5",style:{flex:"none"},children:[o.jsx("circle",{cx:"7",cy:"7",r:"5.5"}),o.jsx("path",{d:"M7 4.2v3.3"}),o.jsx("circle",{cx:"7",cy:"9.8",r:".4",fill:"var(--proto-muted-2)"})]}),o.jsx("span",{style:{fontSize:11.5,fontWeight:600,color:"var(--proto-ink-2)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",flex:1,minWidth:0},children:I.title}),I.date&&o.jsx("span",{style:{font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-faint)",flex:"none"},children:I.date}),o.jsx("span",{style:{fontSize:11,fontWeight:600,color:"var(--proto-accent)",flex:"none"},children:"↗"})]},I.id))}),o.jsxs("div",{onClick:()=>a(),style:{borderTop:"1px solid var(--proto-line-2)",padding:"9px 14px",fontSize:11,fontWeight:600,color:"var(--proto-accent)",cursor:"pointer"},children:[e.isViewAll," ",T.length," ›"]})]}),o.jsxs("div",{style:Us,children:[o.jsx(du,{title:e.ovWhereItGoes,right:e.thisWeek}),o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10,padding:"13px 14px 14px"},children:[b.length===0&&o.jsx("div",{style:{fontSize:10.5,color:"var(--proto-faint)",padding:"2px 0"},children:e.ovNoSpend}),b.map((I,L)=>o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9},children:[o.jsx("span",{title:I.label,style:{fontSize:10.5,color:"var(--proto-muted)",width:56,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:I.label}),o.jsx("div",{style:{flex:1,height:6,borderRadius:999,background:"var(--proto-line-2)",overflow:"hidden"},children:o.jsx("div",{style:{width:`${I.pct}%`,height:"100%",background:["var(--proto-accent)","var(--proto-accent-2)","var(--proto-accent-bg)"][L%3]}})}),o.jsx("span",{style:{font:"500 10px 'IBM Plex Mono',monospace",color:"var(--proto-ink)",width:40,textAlign:"right"},children:Ht(I.cost)})]},I.label))]})]}),o.jsxs("div",{style:Us,children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"10px 14px",borderBottom:"1px solid var(--proto-line-2)"},children:[o.jsx("span",{style:{fontSize:12,fontWeight:650,color:"var(--proto-ink)"},children:e.scheduleCard}),o.jsxs("span",{onClick:()=>s({projectId:d}),style:{marginLeft:"auto",fontSize:11,fontWeight:600,color:"var(--proto-accent)",cursor:"pointer"},children:["+ ",e.newSchedule]})]}),o.jsxs("div",{style:{padding:"9px 14px 11px",display:"flex",flexDirection:"column",gap:9},children:[y.length===0&&o.jsx("div",{style:{fontSize:10.5,color:"var(--proto-faint)",padding:"4px 0"},children:e.ovNoSchedules}),y.map((I,L)=>o.jsxs("div",{children:[L>0&&o.jsx("div",{style:{height:1,background:"var(--proto-line-soft)",margin:"0 0 9px"}}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7},children:[o.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 14 14",fill:"none",stroke:I.paused?"var(--proto-muted-2)":"var(--proto-muted)",strokeWidth:"1.5",children:[o.jsx("circle",{cx:"7",cy:"7",r:"5.6"}),o.jsx("path",{d:"M7 4v3.2l2.2 1.3"})]}),o.jsx("span",{title:I.message,style:{flex:1,minWidth:0,fontSize:11.5,fontWeight:600,color:I.paused?"var(--proto-muted-2)":"var(--proto-ink)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:I.message}),I.paused&&o.jsx("span",{style:{fontSize:9,fontWeight:600,padding:"1px 6px",borderRadius:999,background:"var(--proto-gray)",color:"var(--proto-muted-2)"},children:e.paused}),o.jsx("span",{style:{marginLeft:"auto",font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)"},children:HK(I)})]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",fontSize:10,color:"var(--proto-muted-2)",marginTop:2,paddingLeft:18},children:[o.jsx("span",{children:I.paused?`${Oj(I.lastRun,c)}`:`${VK(I.nextRun,c)} · ${Oj(I.lastRun,c)}`}),Lj(I)&&o.jsx("span",{title:"profile",style:{marginLeft:7,font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)"},children:Lj(I)}),I.paused&&o.jsx("span",{onClick:()=>!C.isPending&&C.mutate({scheduleId:I.id}),style:{marginLeft:"auto",fontSize:10.5,fontWeight:600,color:"var(--proto-accent)",cursor:"pointer"},children:e.resume})]})]},I.id))]})]}),o.jsxs("div",{style:{...Us,gridColumn:"span 2",overflow:"hidden"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"10px 14px",borderBottom:"1px solid var(--proto-line-2)"},children:[o.jsx("span",{style:{fontSize:12,fontWeight:650,color:"var(--proto-ink)"},children:e.execFlow}),o.jsx("span",{style:{font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-muted-3)",marginLeft:8},children:e.ovExecSubtitle}),o.jsx("span",{style:{marginLeft:"auto",font:"400 9.5px 'IBM Plex Mono',monospace",color:"var(--proto-faint)"},children:"executions.json"})]}),o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"88px 1fr 76px 52px 56px 86px 46px",padding:"6px 14px",borderBottom:"1px solid var(--proto-line-soft)",fontSize:9.5,fontWeight:700,letterSpacing:".05em",color:"var(--proto-muted-3)"},children:[o.jsx("span",{children:e.ovColId}),o.jsx("span",{children:e.ovColSummary}),o.jsx("span",{children:e.ovColMachine}),o.jsx("span",{children:e.ovColDur}),o.jsx("span",{children:e.ovColCost}),o.jsx("span",{children:e.ovColStatus}),o.jsx("span",{})]}),k.length===0&&o.jsx("div",{style:{padding:"10px 14px",fontSize:10.5,color:"var(--proto-faint)"},children:e.ovNoExecutions}),k.map(I=>{const L=GK(I.status);return o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"88px 1fr 76px 52px 56px 86px 46px",padding:"7.5px 14px",borderBottom:"1px solid var(--proto-alt)",alignItems:"center",fontSize:11,color:"var(--proto-ink-2)"},children:[o.jsx("span",{title:I.id,style:{font:"400 10px 'IBM Plex Mono',monospace",color:"var(--proto-muted)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",paddingRight:8},children:I.id}),o.jsx("span",{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",paddingRight:12},children:XK(I)}),o.jsx("span",{style:{font:"400 10px 'IBM Plex Mono',monospace"},children:QK(I)}),o.jsx("span",{style:{font:"400 10px 'IBM Plex Mono',monospace"},children:KK(qK(I,c))}),o.jsx("span",{style:{font:"400 10px 'IBM Plex Mono',monospace"},children:YK(I.cost)}),o.jsx("span",{children:o.jsxs("span",{style:{fontSize:9,fontWeight:600,padding:"1.5px 7px",borderRadius:999,background:L.bg,color:L.color},children:[L.dot?"• ":"",L.text]})}),o.jsx("span",{onClick:()=>i(I.id),style:{fontSize:10.5,fontWeight:600,color:"var(--proto-accent)",cursor:"pointer"},children:e.ovLogs})]},I.id)})]})]})]})}function ZK(){return o.jsxs("div",{style:{height:"100vh",minHeight:640,minWidth:1280,display:"flex",background:"var(--proto-card)",overflow:"hidden"},children:[o.jsx(If,{}),o.jsx(JK,{}),o.jsx(Of,{})]})}function eQ(e,t){const n=e.files.map(i=>({name:i.name,kind:"file",path:i.name,selectable:!0,selected:i.name===t,right:null})),r=e.dirs.map(i=>({name:`${i.name}/`,kind:"dir",path:null,selectable:!1,selected:!1,right:String(i.entryCount)}));return[...n,...r]}function tQ(e){var t;return((t=e.files[0])==null?void 0:t.name)??null}function nQ(e,t){if(!e)return"updated —";const n=Date.parse(e);if(Number.isNaN(n))return"updated —";const r=Math.max(0,t-n),i=Math.round(r/6e4);if(i<1)return"updated <1m ago";if(i<60)return`updated ${i}m ago`;const s=Math.round(r/36e5);return s<24?`updated ${s}h ago`:`updated ${Math.round(r/864e5)}d ago`}function rQ(e){return e?{label:"Viewing diff",color:"#fff",bg:"#4655D4",border:"#4655D4"}:{label:"Diff hidden",color:"#4655D4",bg:"#fff",border:"#C9CFF2"}}function oQ(e){return e?{added:`+${e.added}`,removed:`−${e.removed}`}:null}function iQ(e,t){if(!e)return null;const n=new Map;for(const s of e)n.set(s.line,s);const r=t.split(`
|
|
138
|
+
`);r.length>1&&r[r.length-1]===""&&r.pop();let i;return r.map((s,a)=>{const l=a+1,c=n.get(l)??null,d=c?c.commit:null,u=d!==i;return i=d,{lineNo:l,text:s,commit:d,taskRef:c?c.taskRef:null,groupStart:u}})}const Ip="'IBM Plex Mono',monospace";function Hs(e){return e.map((t,n)=>{switch(t.type){case"bold":return o.jsx("span",{style:{fontWeight:650,color:"var(--proto-ink-2)"},children:t.text},n);case"italic":return o.jsx("em",{style:{fontStyle:"italic"},children:t.text},n);case"code":return o.jsx("code",{style:{font:`400 .92em ${Ip}`,background:"var(--proto-gray)",color:"var(--proto-accent-strong)",padding:"1px 4px",borderRadius:4},children:t.text},n);case"link":return o.jsx("a",{href:t.href,style:{color:"var(--proto-accent)",textDecoration:"none"},children:t.text},n);default:return o.jsx(p.Fragment,{children:t.text},n)}})}const sQ={fontSize:12.5,fontWeight:650,color:"var(--proto-ink)",margin:"15px 0 5px"},aQ={fontSize:11.5,lineHeight:1.65,color:"var(--proto-ink-3)",margin:"4px 0 0"};function lQ(e,t){switch(e.type){case"heading":return o.jsx("div",{style:{...sQ,fontSize:e.level>=3?11.5:12.5},children:Hs(e.inline)},t);case"paragraph":return o.jsx("div",{style:aQ,children:Hs(e.inline)},t);case"list":return o.jsx("div",{style:{fontSize:11.5,lineHeight:1.75,color:"var(--proto-ink-3)",margin:"4px 0 0"},children:e.items.map((n,r)=>o.jsxs("div",{style:{display:"flex",gap:9},children:[o.jsx("span",{style:{color:"var(--proto-faint)",flex:"none"},children:e.ordered?`${r+1}.`:"·"}),o.jsx("span",{children:Hs(n)})]},r))},t);case"table":{const n=Math.max(e.header.length,...e.rows.map(i=>i.length),1),r=`repeat(${n}, minmax(0,1fr))`;return o.jsxs("div",{style:{border:"1px solid var(--proto-line-2)",borderRadius:8,overflow:"hidden",fontSize:11,margin:"7px 0 0"},children:[o.jsx("div",{style:{display:"grid",gridTemplateColumns:r,padding:"6px 12px",background:"var(--proto-rail)",borderBottom:"1px solid var(--proto-line-2)",fontSize:9,fontWeight:700,letterSpacing:".05em",color:"var(--proto-muted-3)"},children:e.header.map((i,s)=>o.jsx("span",{children:Hs(i)},s))}),e.rows.map((i,s)=>o.jsx("div",{style:{display:"grid",gridTemplateColumns:r,padding:"6px 12px",borderBottom:"1px solid var(--proto-alt)",color:"var(--proto-ink-3)"},children:Array.from({length:n}).map((a,l)=>o.jsx("span",{style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",paddingRight:8},children:i[l]?Hs(i[l]):null},l))},s))]},t)}case"code":return o.jsx("pre",{style:{background:"var(--proto-rail)",border:"1px solid var(--proto-line-2)",borderRadius:8,padding:"10px 13px",font:`400 10.5px ${Ip}`,color:"var(--proto-ink-2)",overflow:"auto",margin:"7px 0 0",whiteSpace:"pre"},children:e.text},t);case"blockquote":return o.jsx("div",{style:{borderLeft:"2px solid var(--proto-line-3)",padding:"2px 0 2px 9px",margin:"7px 0 0",fontSize:11.5,lineHeight:1.65,color:"var(--proto-muted)"},children:Hs(e.inline)},t);case"hr":return o.jsx("div",{style:{height:1,background:"var(--proto-line-2)",margin:"12px 0"}},t);default:return null}}function cQ({content:e}){const t=H(),{frontmatter:n,body:r}=X$(e),i=hC(r);return o.jsxs("div",{children:[n&&(n.entries.length>0||n.summary)&&o.jsxs("div",{style:{background:"var(--proto-rail)",border:"1px solid var(--proto-line-2)",borderRadius:8,padding:"10px 13px"},children:[o.jsx("div",{style:{display:"flex",alignItems:"center",gap:13,font:`400 10px ${Ip}`,color:"var(--proto-muted)",flexWrap:"wrap"},children:n.entries.map((s,a)=>o.jsxs("span",{children:[o.jsx("span",{style:{color:"var(--proto-muted-3)"},children:s.key})," ",s.value]},a))}),n.summary&&o.jsxs("div",{style:{fontSize:11,color:"var(--proto-ink-2)",marginTop:6},children:[o.jsx("span",{style:{font:`400 10px ${Ip}`,color:"var(--proto-muted-3)"},children:t.memSummary})," ",n.summary]})]}),i.map((s,a)=>lQ(s,a))]})}const qr="'IBM Plex Mono',monospace";function dQ({rows:e}){let t=-1;return o.jsx("div",{style:{font:`400 11px ${qr}`,lineHeight:1.55},children:e.map(n=>{n.groupStart&&(t+=1);const r=t%2===0?"var(--proto-rail)":"var(--proto-accent-bg)";return o.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:10,background:r,borderLeft:n.groupStart?"2px solid var(--proto-accent)":"2px solid transparent",padding:"0 8px"},children:[o.jsx("span",{style:{width:34,flex:"none",textAlign:"right",color:"var(--proto-line)",fontSize:9.5},children:n.lineNo}),o.jsx("span",{style:{width:66,flex:"none",color:"var(--proto-muted-2)",fontSize:9.5},children:n.groupStart&&n.commit?n.commit:""}),o.jsx("span",{style:{width:52,flex:"none"},children:n.groupStart&&n.taskRef&&o.jsx("span",{style:{fontSize:9,fontWeight:600,color:"var(--proto-accent)",background:"var(--proto-accent-bg)",border:"1px solid var(--proto-accent-border)",borderRadius:999,padding:"1px 6px"},children:n.taskRef})}),o.jsx("span",{style:{flex:1,minWidth:0,color:"var(--proto-ink-2)",whiteSpace:"pre-wrap",wordBreak:"break-word"},children:n.text||" "})]},n.lineNo)})})}function uQ({row:e,onPick:t}){const[n,r]=p.useState(!1),i=e.selected?"var(--proto-accent-bg)":n&&e.selectable?"var(--proto-gray)":"transparent",s=e.selected||e.kind==="dir"?600:500,a=e.selected?"var(--proto-accent)":"var(--proto-ink-2)";return o.jsxs("div",{onClick:e.selectable&&e.path?()=>t(e.path):void 0,onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),style:{display:"flex",alignItems:"center",gap:7,padding:"5px 8px",background:i,borderRadius:7,cursor:e.selectable?"pointer":"default"},children:[o.jsx("span",{style:{font:`${s} 10.5px ${qr}`,color:a,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.name}),e.right!=null&&o.jsx("span",{style:{marginLeft:"auto",font:`400 8.5px ${qr}`,color:"var(--proto-faint)",flex:"none"},children:e.right})]})}const pQ={flex:1,minWidth:0,display:"flex",flexDirection:"column",minHeight:0,background:"var(--proto-card)"};function fQ(){const e=ze(),t=le(),n=H(),r=Date.now(),[i,s]=p.useState(null),[a,l]=p.useState(!0),c=Y(t.projects.list.queryOptions({})),d=Y(t.sessions.list.queryOptions({})),u=c.data??[],f=d.data??[],h=p.useMemo(()=>WK(f,u),[f,u]),g=h??"—",v=Y({...t.memory.tree.queryOptions({projectId:h??""}),enabled:!!h}),x=v.data,b=i??(x?tQ(x):null),j=Y({...t.memory.file.queryOptions({projectId:h??"",path:b??""}),enabled:!!h&&!!b}),y=j.data,w=x?eQ(x,b):[],k=rQ(a),S=oQ(y==null?void 0:y.lineDiff),T=iQ(y==null?void 0:y.blame,(y==null?void 0:y.content)??"");return o.jsxs("div",{"data-pane":"center",style:pQ,children:[o.jsxs("div",{style:{height:50,flex:"none",borderBottom:"1px solid var(--proto-line)",display:"flex",alignItems:"center",gap:9,padding:"0 20px",background:"var(--proto-card)"},children:[o.jsx("span",{onClick:()=>e("/overview"),style:{fontSize:14,color:"var(--proto-muted)",cursor:"pointer",padding:"4px 8px 4px 0"},children:"‹"}),o.jsx("span",{onClick:()=>e("/overview"),style:{font:`500 12px ${qr}`,color:"var(--proto-muted-2)",cursor:"pointer"},children:g}),o.jsx("span",{style:{color:"var(--proto-line-3)"},children:"/"}),o.jsx("span",{style:{fontSize:12.5,fontWeight:600,color:"var(--proto-ink)"},children:n.memMemory}),o.jsx("span",{style:{color:"var(--proto-line-3)"},children:"/"}),o.jsx("span",{style:{font:`500 12px ${qr}`,color:"var(--proto-muted)"},children:b??"—"}),o.jsx("span",{style:{marginLeft:"auto",font:`400 10px ${qr}`,color:"var(--proto-muted-3)"},children:n.ovGitBacked})]}),o.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden",minHeight:0},children:[o.jsxs("div",{style:{width:200,flex:"none",borderRight:"1px solid var(--proto-line)",background:"var(--proto-rail)",padding:"8px 6px",overflow:"auto"},children:[v.isLoading&&o.jsx("div",{style:{fontSize:10.5,color:"var(--proto-faint)",padding:"6px 8px"},children:n.memLoading}),!v.isLoading&&w.length===0&&o.jsx("div",{style:{fontSize:10.5,color:"var(--proto-faint)",padding:"6px 8px"},children:n.memNoFiles}),w.map(C=>o.jsx(uQ,{row:C,onPick:s},C.name))]}),o.jsxs("div",{style:{flex:1,minWidth:0,background:"var(--proto-card)",display:"flex",flexDirection:"column",overflow:"hidden"},children:[o.jsxs("div",{style:{flex:"none",display:"flex",alignItems:"center",gap:8,padding:"8px 20px",background:"var(--proto-accent-bg)",borderBottom:"1px solid var(--proto-accent-bg)"},children:[o.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:"var(--proto-accent)",flex:"none"}}),o.jsx("span",{style:{fontSize:11,color:"var(--proto-accent-strong)"},children:nQ(y==null?void 0:y.modifiedAt,r)}),S?o.jsxs(o.Fragment,{children:[o.jsx("span",{style:{font:`600 10px ${qr}`,color:"var(--proto-success)"},children:S.added}),o.jsx("span",{style:{font:`600 10px ${qr}`,color:"var(--proto-danger)"},children:S.removed})]}):o.jsx("span",{style:{font:`400 9.5px ${qr}`,color:"var(--proto-muted-3)"},children:n.memDiffUnavailable}),o.jsx("span",{onClick:()=>l(C=>!C),style:{marginLeft:"auto",fontSize:10,fontWeight:600,color:k.color,background:k.bg,border:`1px solid ${k.border}`,borderRadius:999,padding:"2px 10px",cursor:"pointer"},children:k.label})]}),o.jsxs("div",{style:{flex:1,overflow:"auto",minHeight:0,padding:"18px 24px 24px"},children:[a&&o.jsx("div",{style:{fontSize:10.5,color:"var(--proto-amber-fg)",background:"var(--proto-amber-bg)",border:"1px solid var(--proto-amber-border)",borderRadius:7,padding:"6px 11px",marginBottom:12,lineHeight:1.5},children:T?o.jsxs(o.Fragment,{children:[S?`${S.added} / ${S.removed} ${n.memLinesChanged} `:"",n.memBlameNote]}):o.jsx(o.Fragment,{children:n.memBlameUnavailable})}),j.isLoading&&o.jsx("div",{style:{fontSize:11.5,color:"var(--proto-faint)"},children:n.memLoadingFile}),j.isError&&o.jsx("div",{style:{fontSize:11.5,color:"var(--proto-danger)"},children:n.memReadError}),y&&a&&T?o.jsx(dQ,{rows:T}):y&&o.jsx(cQ,{content:y.content}),!j.isLoading&&!j.isError&&!y&&o.jsx("div",{style:{fontSize:11.5,color:"var(--proto-faint)"},children:n.memSelectFile})]})]})]})]})}function hQ(){return o.jsxs("div",{style:{height:"100vh",minHeight:640,minWidth:1280,display:"flex",background:"var(--proto-card)",overflow:"hidden"},children:[o.jsx(If,{}),o.jsx(fQ,{}),o.jsx(Of,{})]})}const cc="'IBM Plex Mono', monospace";function gQ({name:e}){return o.jsxs("span",{style:{display:"inline-flex",alignItems:"center",fontSize:11,fontWeight:500,color:"var(--proto-accent)",background:"var(--proto-accent-bg)",border:"1px solid var(--proto-accent-border)",borderRadius:999,padding:"2px 10px",fontFamily:cc,letterSpacing:.1},children:["/",e]})}function xQ({group:e}){const t=H(),n=e.plugin??t.skUserSkills;return o.jsxs("div",{style:{marginBottom:28},children:[o.jsxs("div",{style:{fontSize:10.5,fontWeight:700,color:"var(--proto-muted-2)",letterSpacing:.8,textTransform:"uppercase",marginBottom:10,fontFamily:cc},children:[n,o.jsxs("span",{style:{marginLeft:8,fontSize:10,fontWeight:500,color:"var(--proto-line)",letterSpacing:0,textTransform:"none"},children:[e.skills.length," ",e.skills.length===1?"skill":"skills"]})]}),o.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:7},children:e.skills.map(r=>o.jsx(gQ,{name:r},r))})]})}function mQ(){const e=le(),t=H(),{data:n,isLoading:r,isError:i}=Y(e.skills.list.queryOptions({})),s=n??[],a=s.reduce((l,c)=>l+c.skills.length,0);return o.jsxs("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",overflow:"hidden",background:"var(--proto-rail)"},children:[o.jsxs("div",{style:{padding:"20px 28px 16px",borderBottom:"1px solid var(--proto-line-2)",background:"var(--proto-card)",flex:"none"},children:[o.jsx("div",{style:{fontSize:16,fontWeight:700,color:"var(--proto-ink)",letterSpacing:-.3},children:t.skTitle}),o.jsx("div",{style:{fontSize:11.5,color:"var(--proto-muted-2)",marginTop:3},children:r?t.skScanning:i?t.skLoadError:`${a} skill${a!==1?"s":""} across ${s.length} group${s.length!==1?"s":""}`})]}),o.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"24px 28px"},children:[r&&o.jsx("div",{style:{fontSize:12,color:"var(--proto-line)",fontFamily:cc},children:t.skLoadingBody}),i&&o.jsx("div",{style:{fontSize:12,color:"var(--proto-danger)",fontFamily:cc},children:t.skFailedBody}),!r&&!i&&s.length===0&&o.jsx("div",{style:{fontSize:12,color:"var(--proto-line)",fontFamily:cc},children:t.skEmpty}),s.map(l=>o.jsx(xQ,{group:l},l.plugin??"__user__"))]})]})}function vQ(){return o.jsxs("div",{style:{height:"100vh",minHeight:640,minWidth:1280,display:"flex",background:"var(--proto-card)",overflow:"hidden"},children:[o.jsx(If,{}),o.jsx(mQ,{}),o.jsx(Of,{})]})}const yQ=Kt()?N4:D4,bQ=yQ([{path:"/",element:o.jsx(xH,{}),children:[{index:!0,element:o.jsx(Ix,{to:"/workbench",replace:!0})},{path:"workbench",element:o.jsx(bK,{})},{path:"tasks",element:o.jsx(jK,{})},{path:"threads",element:o.jsx(mH,{title:"Threads"})},{path:"overview",element:o.jsx(ZK,{})},{path:"memory",element:o.jsx(hQ,{})},{path:"skills",element:o.jsx(vQ,{})},{path:"kit",element:o.jsx(PK,{})},{path:"base",element:o.jsx(OK,{})}]}]),Af=[{id:"sessions",path:"/m/sessions",labelKey:"sessions"},{id:"threads",path:"/m/threads",labelKey:"threads"},{id:"tasks",path:"/m/tasks",labelKey:"tasks"},{id:"project",path:"/m/project",labelKey:"project"}];function rl(e){return e.length>1?e.replace(/\/+$/,""):e}const jQ=[{prefix:"/m/session/",tab:"sessions"},{prefix:"/m/thread/",tab:"threads"},{prefix:"/m/task/",tab:"tasks"},{prefix:"/m/approvals",tab:"project"},{prefix:"/m/issues",tab:"project"},{prefix:"/m/notes",tab:"project"},{prefix:"/m/memory",tab:"project"},{prefix:"/m/machines",tab:"project"},{prefix:"/m/settings",tab:"project"},{prefix:"/m/daemon",tab:"project"}];function wQ(e){const t=rl(e),n=Af.find(i=>t===i.path||t.startsWith(i.path+"/"));if(n)return n.id;const r=jQ.find(i=>t===i.prefix||t.startsWith(i.prefix));return r?r.tab:"sessions"}function ka(e){const t=rl(e);return Af.some(n=>t===n.path)}function kQ(e){const t=rl(e);return Af.some(n=>t===n.path||t.startsWith(n.path+"/"))}function SQ(e,t){return e==="project"&&t.needsYouCount>0?{count:t.needsYouCount}:{}}function CQ(e,t,n,r,i=!1){return n||r?{animate:!1}:i?{animate:!0,dir:"back"}:e==="REPLACE"?{animate:!1}:{animate:!0,dir:e==="POP"?"back":"forward"}}function D3(e,t){return rl(e)===rl(t)}function EQ(e,t,n){return t&&D3(t.key,n.key)?{current:t,retainedTab:null,returningToRetained:!0}:ka(e.key)&&!ka(n.key)?{current:n,retainedTab:e,returningToRetained:!1}:{current:n,retainedTab:ka(n.key)?null:t,returningToRetained:!1}}function TQ(e){return e==="forward"?{incoming:"animate-slide-in-right",outgoing:"animate-slide-out-left"}:{incoming:"animate-slide-in-left",outgoing:"animate-slide-out-right"}}function PQ(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}const N3={position:"absolute",inset:0,background:m.canvas},RQ={...N3,visibility:"hidden",pointerEvents:"none"};function IQ(e,t,n){const[r,i]=p.useState({key:e,element:n}),[s,a]=p.useState(null),[l,c]=p.useState(null),[d,u]=p.useState("forward");return p.useLayoutEffect(()=>{if(D3(e,r.key))return;const h=EQ(r,s,{key:e,element:n}),g=ka(r.key)&&ka(e),v=CQ(t,!1,PQ(),g,h.returningToRetained);a(h.retainedTab),c(v.animate?r:null),v.animate&&u(v.dir),i(h.current)},[e]),{current:r,retainedTab:s,previous:l,dir:d,onSettled:()=>c(null)}}function Xh({frame:e,role:t,className:n,hidden:r,onAnimationEnd:i}){return o.jsx("div",{"data-route-layer":t,"data-route-key":e.key,className:n,style:r?RQ:N3,"aria-hidden":t==="current"?void 0:!0,onAnimationEnd:i,children:e.element})}function MQ({current:e,retainedTab:t,previous:n,dir:r,onSettled:i}){const s=TQ(r),a=t&&t.key!==(n==null?void 0:n.key)&&t.key!==e.key;return o.jsxs("div",{style:{position:"relative",height:"100%",overflow:"hidden"},children:[a&&o.jsx(Xh,{frame:t,role:"retained",hidden:!0},t.key),n&&o.jsx(Xh,{frame:n,role:"previous",className:s.outgoing},n.key),o.jsx(Xh,{frame:e,role:"current",className:n?s.incoming:void 0,onAnimationEnd:n?i:void 0},e.key)]})}function LQ(){const e=ur(),t=fD(),n=I4(),r=IQ(e.pathname,t,n);return o.jsx(MQ,{...r})}const OQ="var(--proto-ink)",AQ="var(--proto-muted-3)";function DQ({id:e,color:t}){switch(e){case"sessions":return o.jsx("svg",{width:"21",height:"21",viewBox:"0 0 22 22",fill:"none",stroke:t,strokeWidth:"1.7",children:o.jsx("path",{d:"M4 4.5h14a1.5 1.5 0 0 1 1.5 1.5v8a1.5 1.5 0 0 1-1.5 1.5H9.5L5.5 19v-3.5H4A1.5 1.5 0 0 1 2.5 14V6A1.5 1.5 0 0 1 4 4.5z"})});case"threads":return o.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 14 14",fill:"none",stroke:t,strokeWidth:"1.4",children:[o.jsx("circle",{cx:"3.5",cy:"3",r:"1.9"}),o.jsx("circle",{cx:"3.5",cy:"11",r:"1.9"}),o.jsx("circle",{cx:"10.5",cy:"7",r:"1.9"}),o.jsx("path",{d:"M3.5 5v4M5.4 3.7 8.7 6.1M5.4 10.3 8.7 7.9"})]});case"tasks":return o.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",stroke:t,strokeWidth:"1.6",children:[o.jsx("path",{d:"M4 5.5l1.5 1.5L8 4.5"}),o.jsx("path",{d:"M4 12.5l1.5 1.5L8 11.5"}),o.jsx("path",{d:"M10.5 6h6M10.5 13h6"})]});case"project":return o.jsx("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",stroke:t,strokeWidth:"1.6",children:o.jsx("path",{d:"M3 5.5h5l1.5 2H17a1 1 0 0 1 1 1V15a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1z"})})}}function NQ({vocab:e,activeId:t,needsYouCount:n,onNavigate:r}){return o.jsx("div",{style:{flex:"none",borderTop:"1px solid var(--proto-line)",background:"var(--proto-rail)",display:"flex",padding:"8px 6px",paddingBottom:"calc(8px + env(safe-area-inset-bottom))"},children:Af.map(i=>{const s=i.id===t,a=s?OQ:AQ,l=SQ(i.id,{needsYouCount:n});return o.jsxs("button",{type:"button","data-tab-id":i.id,"data-active":s?"true":"false","aria-current":s?"page":void 0,onClick:()=>r(i.path),style:{flex:1,minHeight:44,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:3,border:"none",background:"transparent",padding:0,cursor:"pointer"},children:[o.jsxs("div",{style:{position:"relative"},children:[o.jsx(DQ,{id:i.id,color:a}),l.count!==void 0&&o.jsx("span",{style:{position:"absolute",top:-4,right:-9,background:"var(--proto-amber)",color:"var(--ink-solid-fg)",font:"600 8px 'IBM Plex Mono', monospace",padding:"1px 4.5px",borderRadius:999},children:l.count})]}),o.jsx("span",{style:{fontSize:10,fontWeight:600,color:a},children:e[i.labelKey]})]},i.id)})})}const _Q=[{pattern:/^\/m\/session\/([^/]+)\/plan\/[^/]+$/,parent:e=>`/m/session/${e[1]}`},{pattern:/^\/m\/session\/[^/]+$/,parent:"/m/sessions"},{pattern:/^\/m\/thread\/[^/]+$/,parent:"/m/threads"},{pattern:/^\/m\/task\/[^/]+$/,parent:"/m/tasks"},{pattern:/^\/m\/memory\/file$/,parent:"/m/memory"},{pattern:/^\/m\/settings\/(accounts|hooks)$/,parent:"/m/settings"},{pattern:/^\/m\/daemon$/,parent:"/m/settings"},{pattern:/^\/m\/(approvals|issues|notes|memory|machines|settings)$/,parent:"/m/project"}];function $Q(e){const t=rl(e);for(const n of _Q){const r=t.match(n.pattern);if(r)return typeof n.parent=="string"?n.parent:n.parent(r)}return"/m/sessions"}function FQ(e,t,n=!1){return t?{kind:"history"}:ka(e)?{kind:"exit"}:n?{kind:"history"}:{kind:"navigate",to:$Q(e)}}function zQ(e,t){return e&&typeof(t==null?void 0:t.idx)=="number"&&t.idx>0}async function BQ(e,t,n,r){const i=FQ(e,t,n);if(i.kind==="history")return r.historyBack();if(i.kind==="exit")return void await r.exit();r.navigate(i.to,{replace:!0})}function WQ(e,t){t(e,{replace:!0})}function UQ(){const e=globalThis.__TAURI__;return!(e!=null&&e.app)||!e.core?null:{listen:t=>e.app.onBackButtonPress(t),exit:()=>e.core.invoke("plugin:app|exit")}}function HQ(){const e=window.history.state;return(e==null?void 0:e.__cortexOverlay)===!0}function VQ(e,t){let n=!1,r=null;return e.listen(t).then(i=>{n?i.unregister().catch(()=>{}):r=i}).catch(()=>{}),()=>{n=!0,r&&r.unregister().catch(()=>{})}}function qQ(e,t){const n=p.useRef({pathname:e,navigate:t});n.current={pathname:e,navigate:t},p.useEffect(()=>{const r=UQ();if(r)return VQ(r,i=>{const s=n.current,a=window.history.state,l=zQ(i.canGoBack,a);BQ(s.pathname,HQ(),l,{historyBack:()=>window.history.back(),exit:r.exit,navigate:s.navigate}).catch(()=>{})})},[])}const _3=p.createContext(null);function KQ({children:e}){const t=le(),n=Y(t.projects.list.queryOptions({})),r=Y(t.sessions.list.queryOptions({origin:"direct"})),[i,s]=p.useState(null),a=u6(i,r.data??[],n.data??[]),l=p.useCallback(d=>s(d),[]),c=p.useMemo(()=>({currentProjectId:a,setCurrentProject:l}),[a,l]);return o.jsx(_3.Provider,{value:c,children:e})}function Bn(){const e=p.useContext(_3);if(!e)throw new Error("useMobileProject must be used within a MobileProjectProvider");return e}function QQ(e){return{title:e.title,body:e.meta}}function Tv(){return Kt()}let uu=null;async function $3(){if(!Tv())return!1;if(uu!==null)return uu;try{const{isPermissionGranted:e,requestPermission:t}=await Ef(async()=>{const{isPermissionGranted:r,requestPermission:i}=await import("./index-DCgngTJG.js");return{isPermissionGranted:r,requestPermission:i}},[]);let n=await e();return n||(n=await t()==="granted"),uu=n,n}catch{return uu=!1,!1}}async function YQ(e,t){if(!Tv())return!1;try{if(!await $3())return!1;const{sendNotification:r}=await Ef(async()=>{const{sendNotification:i}=await import("./index-DCgngTJG.js");return{sendNotification:i}},[]);return r({title:e.title,body:e.body,extra:t,autoCancel:!0}),!0}catch{return!1}}async function GQ(e){if(!Tv())return()=>{};try{const{onAction:t}=await Ef(async()=>{const{onAction:r}=await import("./index-DCgngTJG.js");return{onAction:r}},[]),n=await t(r=>e(r.extra));return()=>{n.unregister()}}catch{return()=>{}}}function Mr(e,t=Date.now()){if(!e)return"";const n=Date.parse(e);if(Number.isNaN(n))return"";const r=t-n;if(r<0)return"现在";const i=Math.floor(r/6e4);if(i<1)return"现在";if(i<60)return`${i} 分钟`;const s=Math.floor(i/60);if(s<24)return`${s} 小时`;const a=Math.floor(s/24);return a===1?"昨天":a<7?`${a} 天前`:`${Math.floor(a/7)} 周前`}function zc(e){return e==null||Number.isNaN(e)?"—":`$${e.toFixed(2)}`}function Lt(e,t){return e==="zh"?t.zh:t.en}function XQ({items:e,now:t=Date.now(),onDismiss:n,onActivate:r}){return e.length===0?null:o.jsx("div",{style:{position:"fixed",top:"calc(10px + env(safe-area-inset-top))",left:10,right:10,zIndex:1e3,display:"flex",flexDirection:"column",gap:8,pointerEvents:"none"},children:e.map(i=>o.jsxs("div",{role:"button",onClick:()=>r(i),style:{pointerEvents:"auto",background:"rgba(250,250,252,.98)",border:"1px solid rgba(0,0,0,.06)",borderRadius:20,boxShadow:"0 12px 36px rgba(16,24,40,.24)",padding:"11px 13px",display:"flex",gap:10,alignItems:"center",cursor:"pointer"},children:[o.jsx("div",{"aria-label":"Cortex",style:{width:36,height:36,borderRadius:9,background:"var(--brand-badge-bg)",border:"1px solid var(--brand-badge-border)",display:"flex",alignItems:"center",justifyContent:"center",flex:"none"},children:o.jsxs("svg",{width:25,height:25,viewBox:"0 0 64 64",fill:"none","aria-hidden":"true",children:[o.jsx("circle",{cx:33,cy:32,r:5,fill:"var(--brand-badge-core)"}),o.jsx("path",{d:"M42.29 23.64A12.5 12.5 0 1 0 42.29 40.36",stroke:"var(--brand-badge-arc)",strokeWidth:5,strokeLinecap:"round"}),o.jsx("path",{d:"M48.6 17.95A21 21 0 1 0 48.6 46.05",stroke:"var(--brand-badge-arc)",strokeWidth:5,strokeLinecap:"round"})]})}),o.jsxs("div",{style:{minWidth:0,flex:1},children:[o.jsx("div",{style:{fontSize:12.5,fontWeight:650,color:m.ink,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:i.title}),o.jsx("div",{style:{fontSize:11,color:m.sub,marginTop:1,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:i.meta})]}),o.jsx("span",{style:{font:`400 10px ${N}`,color:m.faint,flex:"none",alignSelf:"flex-start"},children:Mr(i.ts,t)||"现在"}),o.jsx("button",{type:"button","aria-label":"Dismiss",onClick:s=>{s.stopPropagation(),n(i.id)},style:{border:"none",background:"transparent",color:m.faint,fontSize:12,cursor:"pointer",flex:"none",padding:"0 2px"},children:"✕"})]},i.id))})}function JQ(){const e=le(),t=ze(),n=ur(),{setCurrentProject:r}=Bn(),[i,s]=p.useState([]),a=p.useRef(0),l=p.useRef(new Map),c=p.useRef(n.pathname),d=Y(e.sessions.list.queryOptions({origin:"direct"}));p.useEffect(()=>{const w=new Map;for(const k of d.data??[])w.set(k.sessionId,{name:k.label??k.name,projectId:k.projectId});l.current=w},[d.data]),p.useEffect(()=>{c.current=n.pathname},[n.pathname]),p.useEffect(()=>{$3()},[]);const u=p.useCallback((w,k)=>{w&&(k&&r(k),t(`/m/session/${w}`))},[t,r]);p.useEffect(()=>{let w=()=>{};return GQ(k=>{const S=typeof(k==null?void 0:k.sessionId)=="string"?k.sessionId:"",T=typeof(k==null?void 0:k.projectId)=="string"&&k.projectId?k.projectId:null;u(S,T)}).then(k=>{w=k}),()=>w()},[u]);const f=p.useCallback(w=>{const k=w.sessionId?{sessionId:w.sessionId,projectId:w.projectId??""}:void 0;(async()=>await YQ(QQ(w),k)||s(T=>Ux(T,w)))()},[]),h=p.useRef(new Map),g=p.useCallback(w=>{P6(h.current,w.sessionId,{text:w.text,ts:w.ts??new Date().toISOString()})},[]),v=p.useCallback(w=>{const k=R6(h.current,w);if(!k)return;const S=l.current.get(w);if(!S||c.current===`/m/session/${w}`)return;const T=`dmn-${a.current++}`,C=k6({id:T,sessionId:w,sessionName:S.name,projectId:S.projectId,text:k.text,ts:k.ts});f(C)},[f]);E6({onMessage:g,onTurnEnd:v});const x=p.useCallback(w=>{const k=`sysn-${a.current++}`,S=S6({id:k,level:w.level,text:w.text,title:w.title??void 0,ts:w.ts??void 0});f(S)},[f]);T6(x);const b=p.useCallback(w=>s(k=>Tp(k,w)),[]),j=p.useCallback(w=>{u(w.sessionId,w.projectId),s(k=>Tp(k,w.id))},[u]),{visible:y}=C6(i);return o.jsx(XQ,{items:y,onDismiss:b,onActivate:j})}const ZQ="'IBM Plex Mono', monospace";function eY({update:e,onApply:t,onDismiss:n}){return o.jsx("div",{role:"dialog","aria-modal":"true","aria-label":"新版本已就绪",style:{position:"fixed",inset:0,zIndex:60,background:"rgba(25,28,34,.44)",display:"flex",alignItems:"center",justifyContent:"center",padding:"0 36px",boxSizing:"border-box"},children:o.jsxs("div",{style:{width:"100%",background:"var(--proto-card)",borderRadius:18,boxShadow:"0 24px 64px rgba(16,24,40,.32)",padding:"24px 20px 14px",boxSizing:"border-box",display:"flex",flexDirection:"column",alignItems:"center"},children:[o.jsx("div",{style:{width:46,height:46,borderRadius:14,background:"var(--proto-accent-bg)",display:"flex",alignItems:"center",justifyContent:"center",marginBottom:14},children:o.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",stroke:"var(--proto-accent)",strokeWidth:"1.8",children:[o.jsx("path",{d:"M10 14V4M5.5 8.5 10 4l4.5 4.5"}),o.jsx("path",{d:"M3.5 16.5h13"})]})}),o.jsx("div",{style:{fontSize:17,fontWeight:700,color:"var(--proto-ink)",letterSpacing:"-.01em"},children:"新版本已就绪"}),o.jsx("div",{style:{font:`500 10.5px ${ZQ}`,color:"var(--proto-muted-3)",marginTop:6},children:M6(e)}),o.jsx("div",{style:{fontSize:13,lineHeight:1.6,color:"var(--proto-muted)",textAlign:"center",margin:"10px 0 18px"},children:"热更新已在后台下载完成,重启 App 后生效。运行中的线程在服务端继续执行,不受重启影响。"}),o.jsxs("div",{style:{width:"100%",display:"flex",flexDirection:"column",gap:2},children:[o.jsx("button",{type:"button",onClick:t,style:{height:48,border:"none",borderRadius:13,background:"var(--proto-ink)",color:"var(--ink-solid-fg)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:14.5,fontWeight:600,cursor:"pointer",width:"100%"},children:"退出 App"}),o.jsx("button",{type:"button",onClick:n,style:{height:44,border:"none",background:"transparent",display:"flex",alignItems:"center",justifyContent:"center",fontSize:13.5,fontWeight:600,color:"var(--proto-muted-2)",cursor:"pointer",width:"100%"},children:"忽略"})]})]})})}function tY(){const e=p.useSyncExternalStore(gv,xv),{staged:t,apply:n,dismiss:r}=_6();return e||!t?null:o.jsx(eY,{update:t,onApply:n,onDismiss:r})}const nY="'IBM Plex Mono', monospace";function rY({update:e,busy:t,error:n,onInstall:r,onSkip:i,onDismiss:s}){return o.jsx("div",{role:"dialog","aria-modal":"true","aria-label":"App 新版本已就绪",style:{position:"fixed",inset:0,zIndex:60,background:"rgba(25,28,34,.44)",display:"flex",alignItems:"center",justifyContent:"center",padding:"0 36px",boxSizing:"border-box"},children:o.jsxs("div",{style:{width:"100%",background:"var(--proto-card)",borderRadius:18,boxShadow:"0 24px 64px rgba(16,24,40,.32)",padding:"24px 20px 14px",boxSizing:"border-box",display:"flex",flexDirection:"column",alignItems:"center"},children:[o.jsx("div",{style:{width:46,height:46,borderRadius:14,background:"var(--proto-accent-bg)",display:"flex",alignItems:"center",justifyContent:"center",marginBottom:14},children:o.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",stroke:"var(--proto-accent)",strokeWidth:"1.8",children:[o.jsx("path",{d:"M10 14V4M5.5 8.5 10 4l4.5 4.5"}),o.jsx("path",{d:"M3.5 16.5h13"})]})}),o.jsx("div",{style:{fontSize:17,fontWeight:700,color:"var(--proto-ink)",letterSpacing:"-.01em"},children:"App 新版本已就绪"}),o.jsx("div",{style:{font:`500 10.5px ${nY}`,color:"var(--proto-muted-3)",marginTop:6},children:O6(e)}),o.jsx("div",{style:{fontSize:13,lineHeight:1.6,color:"var(--proto-muted)",textAlign:"center",margin:"10px 0 18px"},children:D6(e.kind)}),n?o.jsxs("div",{style:{fontSize:12,color:"var(--proto-danger, #d92d20)",marginBottom:10,textAlign:"center"},children:["安装失败:",n]}):null,o.jsxs("div",{style:{width:"100%",display:"flex",flexDirection:"column",gap:2},children:[o.jsx("button",{type:"button",onClick:r,disabled:t,style:{height:48,border:"none",borderRadius:13,background:"var(--proto-ink)",color:"var(--ink-solid-fg)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:14.5,fontWeight:600,cursor:"pointer",width:"100%",opacity:t?.6:1},children:t?"正在处理…":A6(e.kind)}),o.jsxs("div",{style:{display:"flex",width:"100%"},children:[o.jsx("button",{type:"button",onClick:i,style:{height:44,border:"none",background:"transparent",display:"flex",alignItems:"center",justifyContent:"center",fontSize:13.5,fontWeight:600,color:"var(--proto-muted-2)",cursor:"pointer",flex:1},children:"跳过此版本"}),o.jsx("button",{type:"button",onClick:s,style:{height:44,border:"none",background:"transparent",display:"flex",alignItems:"center",justifyContent:"center",fontSize:13.5,fontWeight:600,color:"var(--proto-muted-2)",cursor:"pointer",flex:1},children:"稍后"})]})]})]})})}function oY(){const{update:e,busy:t,error:n,install:r,skip:i,dismiss:s}=$6();return e?o.jsx(rY,{update:e,busy:t,error:n,onInstall:r,onSkip:i,onDismiss:s}):null}const Aj="--cortex-vvh",Dj="--cortex-vvt";function iY(e,t){const n=()=>{e.setProperty(Aj,`${t.height}px`),e.setProperty(Dj,`${t.offsetTop}px`)};return n(),t.addEventListener("resize",n),t.addEventListener("scroll",n),()=>{t.removeEventListener("resize",n),t.removeEventListener("scroll",n),e.removeProperty(Aj),e.removeProperty(Dj)}}function sY(){p.useEffect(()=>{const e=window.visualViewport;if(e)return iY(document.documentElement.style,e)},[])}const aY={position:"fixed",top:0,left:0,right:0,height:"var(--cortex-vvh, 100dvh)",transform:"translateY(var(--cortex-vvt, 0px))",display:"flex",flexDirection:"column",overflow:"hidden",background:"var(--proto-alt)"};function lY({pathname:e,vocab:t,needsYouCount:n,onTab:r}){return o.jsxs("div",{style:aY,children:[o.jsx("div",{style:{flex:1,minHeight:0,overflow:"hidden"},children:o.jsx(LQ,{})}),kQ(e)&&o.jsx(NQ,{vocab:t,activeId:wQ(e),needsYouCount:n,onNavigate:r})]})}function cY({children:e}){return o.jsx(t6,{children:o.jsx(z6,{children:o.jsx(KQ,{children:o.jsx(wC,{children:o.jsxs(PC,{children:[e,o.jsx(JQ,{}),o.jsx(tY,{}),o.jsx(oY,{})]})})})})})}function dY(){var a;const e=H(),t=ur(),n=ze(),r=le();sY(),qQ(t.pathname,n);const s=((a=Y(r.approvals.list.queryOptions({status:"pending"})).data)==null?void 0:a.length)??0;return o.jsx(cY,{children:o.jsx(lY,{pathname:t.pathname,vocab:e,needsYouCount:s,onTab:l=>WQ(l,n)})})}function uY(e){return e.awaitingInput?{kind:"awaiting",text:"等待操作"}:e.running&&e.backgroundRunning?{kind:"background",text:"后台运行"}:e.running?{kind:"running",text:e.numTurns!=null?`running · ${e.numTurns} turns`:"running"}:{kind:"idle",text:"空闲"}}function pY(e,t){return{id:e.sessionId,title:e.label||e.name||e.sessionId,time:Mr(e.lastUsedAt||e.createdAt,t),running:e.running,numTurns:e.numTurns,unread:e.unread}}function fY(e,t=Date.now()){return K6(e,t).map(n=>({key:n.label,rows:n.items.map(r=>pY(r,t))}))}function hY(e,t){return t==="TODAY"?e.today:t==="YESTERDAY"?e.yesterday:e.earlier}function gY({onClick:e}){return o.jsx("button",{type:"button","aria-label":"New session",onClick:e,style:{width:34,height:34,borderRadius:"50%",background:m.ink,border:"none",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--ink-solid-fg)",fontSize:17,fontWeight:400,cursor:"pointer"},children:"+"})}function xY({row:e,byId:t,onOpen:n}){const r=t.get(e.id),i=r?uY(r):{kind:"idle",text:"空闲"};return o.jsxs($e,{radius:12,padding:"12px 13px",onClick:()=>n(e.id),children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7},children:[e.unread&&o.jsx("span",{"aria-label":"unread",style:{width:7,height:7,borderRadius:"50%",background:m.run,flex:"none"}}),o.jsx("span",{style:{fontSize:14,fontWeight:e.unread?600:400,color:e.unread?m.ink:"var(--proto-muted)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.title}),o.jsx("span",{style:{marginLeft:"auto",font:`400 9.5px ${N}`,color:m.faint,flex:"none"},children:e.time})]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5,marginTop:4},children:[i.kind==="running"&&o.jsx(li,{color:m.run,pulse:!0}),i.kind==="background"&&o.jsx(li,{color:m.run,pulse:!0}),i.kind==="awaiting"&&o.jsx(li,{color:m.amber,pulse:!0}),o.jsx("span",{style:{font:`400 10px ${N}`,color:m.muted},children:i.text})]})]})}function mY({groups:e,sessions:t,scope:n,copy:r,onOpen:i,onNew:s}){const a=new Map(t.map(l=>[l.sessionId,l]));return o.jsx(gt,{label:"1a 会话列表",header:o.jsx(Rf,{title:r.title,qn:n,trailing:o.jsx(gY,{onClick:s})}),children:o.jsxs(gn,{gap:6,children:[e.length===0&&o.jsx("div",{style:{padding:"40px 0",textAlign:"center",color:m.faint,fontSize:13},children:r.empty}),e.map(l=>o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[o.jsx(jd,{style:{padding:"6px 2px 2px"},children:hY(r,l.key)}),l.rows.map(c=>o.jsx(xY,{row:c,byId:a,onOpen:i},c.id))]},l.key))]})})}const vY={en:{title:"Sessions",today:"Today",yesterday:"Yesterday",earlier:"Earlier",empty:"No sessions yet"},zh:{title:"会话",today:"今天",yesterday:"昨天",earlier:"更早",empty:"暂无会话"}};function yY(){const e=le(),t=ze(),n=ut(),r=Lt(n,vY),{currentProjectId:i}=Bn();yv();const s=Y(e.sessions.list.queryOptions({origin:"direct",projectId:i??void 0})),a=s.data??[],l=p.useMemo(()=>fY(a),[a]),c=i?vl(i):void 0;return s.isLoading?o.jsx(gt,{label:"1a 会话列表",children:o.jsx("div",{style:{padding:16,color:m.muted,fontSize:13},children:r.empty})}):o.jsx(mY,{groups:l,sessions:a,scope:c,copy:r,onOpen:d=>t(`/m/session/${d}`),onNew:()=>t("/m/session/new")})}function bY(e){return`${String(e.getHours()).padStart(2,"0")}:${String(e.getMinutes()).padStart(2,"0")}`}function jY(e,t){const n=new Date(e),r=a=>new Date(a.getFullYear(),a.getMonth(),a.getDate()).getTime(),i=Math.round((r(t)-r(n))/864e5),s=bY(n);return i<=0?`今天 ${s}`:i===1?`昨天 ${s}`:`${n.getMonth()+1}月${n.getDate()}日 ${s}`}function wY(e){return e==="completed"?"done":e==="running"?"running":"pending"}function kY(e){const t=Math.max(0,Math.round(e/6e4));if(t<60)return`${t}m`;const n=Math.floor(t/60),r=t%60;return r===0?`${n}h`:`${n}h ${r}m`}function SY(e){const t=e.steps.map((i,s)=>({label:i.stage??`Step ${i.stepIndex+1}`,state:wY(i.status),lineDone:s>0&&e.steps[s-1].status==="completed"})),n=e.status==="running"&&e.currentStep?`${e.currentStep.name} ${e.currentStep.index+1}/${e.totalSteps}`:e.status,r=new Date(e.updatedAt).getTime()-new Date(e.createdAt).getTime();return{name:e.templateName,pillText:n,nodes:t,footer:{elapsed:kY(r),cost:`$${e.totalCostUsd.toFixed(2)}`,subCount:e.children.length}}}function CY(e,t){return{names:e.slice(0,t.visibleCount).map(n=>n.kind),overflow:t.hiddenCount}}const Nj="'IBM Plex Mono',monospace";function EY({state:e}){return e==="done"?o.jsx("span",{style:{width:14,height:14,borderRadius:"50%",background:"var(--proto-success-bg)",color:"var(--proto-success)",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:8,fontWeight:700},children:"✓"}):e==="running"?o.jsx("span",{style:{width:14,height:14,borderRadius:"50%",background:"var(--proto-accent)",boxShadow:"0 0 0 3px var(--proto-accent-bg)",animation:"cxpulse 1.6s ease-in-out infinite"}}):o.jsx("span",{style:{width:14,height:14,borderRadius:"50%",border:"1.5px solid var(--proto-line-3)",boxSizing:"border-box"}})}function TY(e){return e==="running"?"var(--proto-ink)":e==="done"?"var(--proto-muted)":"var(--proto-faint)"}function PY({card:e,pill:t,subthreadsLabel:n,openLabel:r,onOpen:i}){return o.jsxs("div",{style:{border:"1px solid var(--proto-line)",borderRadius:12,overflow:"hidden",background:"var(--proto-card)"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"9px 12px",borderBottom:"1px solid var(--proto-line-2)"},children:[o.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"var(--proto-accent)",strokeWidth:"1.6",children:[o.jsx("circle",{cx:"3.5",cy:"3",r:"1.9"}),o.jsx("circle",{cx:"3.5",cy:"11",r:"1.9"}),o.jsx("circle",{cx:"10.5",cy:"7",r:"1.9"}),o.jsx("path",{d:"M3.5 5v4M5.4 3.7 8.7 6.1M5.4 10.3 8.7 7.9"})]}),o.jsx("span",{style:{font:`600 12px ${Nj}`,color:"var(--proto-ink)"},children:e.name}),o.jsx("span",{style:{marginLeft:"auto",fontSize:10,fontWeight:600,padding:"2px 8px",borderRadius:999,background:t.bg,color:t.color},children:e.pillText})]}),o.jsx("div",{style:{display:"flex",alignItems:"center",padding:"10px 12px"},children:e.nodes.map((s,a)=>o.jsxs(p.Fragment,{children:[a>0&&o.jsx("div",{style:{flex:1,height:1.5,background:s.lineDone?"var(--proto-success-bg)":"var(--proto-line)",margin:"0 6px"}}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[o.jsx(EY,{state:s.state}),o.jsx("span",{style:{fontSize:10.5,color:TY(s.state),fontWeight:s.state==="running"?600:void 0},children:s.label})]})]},a))}),o.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 12px",borderTop:"1px solid var(--proto-line-2)"},children:[o.jsxs("span",{style:{font:`400 10px ${Nj}`,color:"var(--proto-muted-3)"},children:[e.footer.elapsed," · ",e.footer.cost," · ",e.footer.subCount," ",n]}),o.jsxs("span",{onClick:i,style:{marginLeft:"auto",fontSize:11.5,fontWeight:600,color:"var(--proto-accent)",cursor:"pointer"},children:[r," →"]})]})]})}const F3={zh:{askPill:"Agent 提问",answeredPill:"✓ 已回答",defaultBadge:"默认",customOption:"自定义…",confirm:"确认",queued:"待答",multiTag:"多选",askFooter:"答一题进一题 · 全答完继续",ttlSuffix:"后按默认继续",planPendingPill:"计划待批",planApprovedPill:"✓ 计划已批准",planRejectedPill:"已驳回",approvedBy:"由你批准",readHint:"批准前建议通读全文",readLink:"阅读 ›",approve:"批准并执行",reject:"驳回并反馈",approveHint:"",viewFullPlan:"查看完整计划 ›",viewOriginalPlan:"查看原计划 ›",rewriteNote:""},en:{askPill:"Agent question",answeredPill:"✓ answered",defaultBadge:"default",customOption:"Custom…",confirm:"Confirm",queued:"queued",multiTag:"multi",askFooter:"one at a time · continues when all answered",ttlSuffix:"until defaults apply",planPendingPill:"Plan pending",planApprovedPill:"✓ Plan approved",planRejectedPill:"Rejected",approvedBy:"approved by you",readHint:"read the full plan before approving",readLink:"Read ›",approve:"Approve & run",reject:"Reject with note",approveHint:"",viewFullPlan:"View full plan ›",viewOriginalPlan:"View original plan ›",rewriteNote:""}};function dc({bg:e,fg:t,text:n}){return o.jsx("span",{style:{fontSize:10,fontWeight:700,padding:"2px 8px",borderRadius:999,background:e,color:t,flex:"none"},children:n})}function _u(e,t,n){return{border:`1px solid ${e&&!t?m.runBorder:m.hairline}`,background:"var(--proto-card)",borderRadius:14,overflow:"hidden",boxShadow:e&&!t?"0 1px 3px rgba(70,85,212,.08)":void 0,...t?{opacity:.55}:n?{opacity:.9}:{}}}const RY=o.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 14 14",fill:"none",stroke:m.run,strokeWidth:"1.4",style:{flex:"none"},children:[o.jsx("path",{d:"M3 1.5h5.5L11.5 4.5V12.5H3z"}),o.jsx("path",{d:"M5 6.5h4M5 9h4"})]});function IY({model:e,state:t,copy:n,onPick:r,onToggle:i,onConfirmMulti:s,onCustom:a}){const l=e.status==="pending",c=Ao(e,t),d=e.questions.length,u=iv(e.ts,l),[f,h]=p.useState(!1),g=x=>x.answer??t.answers[x.question]??null,v=e.level?AC(e.level):null;return o.jsxs("div",{...e.level?{"data-ask-level":e.level}:{},style:_u(l,!1,!1),onClick:l?void 0:()=>h(x=>!x),children:[o.jsx("div",{style:{padding:"12px 14px 0"},children:o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7},children:[l?o.jsx(dc,{bg:v?v.bg:m.runBg,fg:v?v.fg:m.run,text:d>1?`${n.askPill} · ${Math.min(c+1,d)}/${d}`:n.askPill}):o.jsx(dc,{bg:m.doneBg,fg:m.done,text:n.answeredPill}),o.jsx("span",{style:{font:`400 10px ${N}`,color:m.faint},children:e.shortId}),l&&u!=null?o.jsxs("span",{style:{marginLeft:"auto",font:`500 10px ${N}`,color:m.amberText},children:[rv(u)," ",n.ttlSuffix]}):e.timeLabel?o.jsx("span",{style:{marginLeft:"auto",font:`400 10px ${N}`,color:m.faint},children:e.timeLabel}):null]})}),e.questions.map((x,b)=>{const j=g(x),y=l&&b===c,w=l&&b>c,k=b===d-1;return j!=null&&!y?o.jsxs("div",{style:{padding:`10px 14px ${k?"14px":"0"}`},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9,background:"var(--proto-alt)",border:"1px solid var(--proto-line-2)",borderRadius:11,padding:"9px 13px"},children:[o.jsx("span",{style:{width:16,height:16,borderRadius:"50%",background:m.done,color:"var(--ink-solid-fg)",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:9,fontWeight:700,flex:"none"},children:"✓"}),o.jsxs("span",{style:{fontSize:12,color:m.sub,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:[x.question," → ",o.jsx("b",{style:{color:m.ink},children:j})]})]}),!l&&f&&x.options.length>0&&o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6,padding:"8px 0 0"},children:x.options.map(S=>o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,border:`1px solid ${j.includes(S.label)?m.runBorder:"var(--proto-line-2)"}`,borderRadius:9,padding:"6px 11px"},children:[o.jsx("span",{style:{fontSize:11.5,color:j.includes(S.label)?m.ink:m.muted},children:S.label}),j.includes(S.label)&&o.jsx("span",{style:{marginLeft:"auto",fontSize:10,fontWeight:700,color:m.done},children:"✓"})]},S.label))})]},x.question):y?o.jsxs("div",{style:{padding:`12px 14px ${k?"14px":"0"}`},children:[o.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:8},children:[o.jsxs("span",{style:{font:`600 10px ${N}`,color:m.run,flex:"none"},children:["Q",b+1]}),o.jsx("span",{style:{fontSize:14.5,fontWeight:600,color:m.ink,lineHeight:1.4},children:x.question}),x.multiSelect&&o.jsx("span",{style:{font:`500 9px ${N}`,color:m.muted,background:m.gray,padding:"1px 6px",borderRadius:5,flex:"none"},children:n.multiTag})]}),o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8,padding:"10px 0 0"},children:[x.options.map((S,T)=>{const C=x.multiSelect&&t.selected.includes(S.label),P=!x.multiSelect&&T===0;return o.jsxs("button",{type:"button",onClick:()=>x.multiSelect?i(S.label):r(S.label),style:{minHeight:44,border:`1.5px solid ${C||P?m.run:"var(--proto-line-3)"}`,borderRadius:11,display:"flex",alignItems:"center",gap:8,padding:"8px 13px",boxSizing:"border-box",background:"var(--proto-card)",cursor:"pointer",textAlign:"left",width:"100%"},children:[x.multiSelect&&o.jsx("span",{style:{fontSize:12,fontWeight:700,color:C?m.run:m.faint,flex:"none"},children:C?"☑":"☐"}),o.jsx("span",{style:{fontSize:13.5,fontWeight:600,color:m.ink,minWidth:0,flex:1,overflowWrap:"anywhere"},children:S.label}),P?o.jsx("span",{style:{marginLeft:"auto",fontSize:9.5,fontWeight:600,padding:"1.5px 7px",borderRadius:999,background:m.runBg,color:m.run,flex:"none"},children:n.defaultBadge}):S.description?o.jsx("span",{style:{marginLeft:"auto",minWidth:0,maxWidth:"55%",font:`400 10px ${N}`,color:"var(--proto-muted-3)",flex:"0 1 auto",textAlign:"right",lineHeight:1.35,whiteSpace:"normal",overflowWrap:"anywhere"},children:S.description}):null]},S.label)}),o.jsx("button",{type:"button",onClick:a,style:{minHeight:44,border:"1.5px solid var(--proto-line-3)",borderRadius:11,display:"flex",alignItems:"center",padding:"8px 13px",boxSizing:"border-box",background:"var(--proto-card)",cursor:"pointer",textAlign:"left",width:"100%"},children:o.jsx("span",{style:{fontSize:13.5,fontWeight:600,color:m.sub},children:n.customOption})}),x.multiSelect&&o.jsx("button",{type:"button",onClick:s,disabled:t.selected.length===0,style:{height:44,borderRadius:11,background:m.ink,color:"var(--ink-solid-fg)",border:"none",fontSize:14,fontWeight:600,cursor:"pointer",opacity:t.selected.length===0?.45:1,width:"100%"},children:n.confirm})]})]},x.question):w?o.jsx("div",{style:{padding:`12px 14px ${k?"14px":"0"}`},children:o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9,border:"1px dashed var(--proto-line-3)",borderRadius:11,padding:"9px 13px",opacity:.6},children:[o.jsxs("span",{style:{font:`600 10px ${N}`,color:"var(--proto-muted-3)",flex:"none"},children:["Q",b+1]}),o.jsx("span",{style:{fontSize:12,color:m.grayInk,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:x.question}),o.jsx("span",{style:{marginLeft:"auto",font:`400 9.5px ${N}`,color:m.faint,flex:"none"},children:n.queued})]})},x.question):null}),l&&o.jsx("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"9px 14px",borderTop:"1px solid var(--proto-line-2)",font:`400 10px ${N}`,color:"var(--proto-muted-3)",marginTop:12},children:o.jsx("span",{style:{marginLeft:"auto"},children:n.askFooter})})]})}function MY({model:e,copy:t,dimmed:n=!1,onApprove:r,onRejectStart:i,onOpenRead:s}){const a=e.status==="pending",l=e.status==="rejected",c=e.status==="approved",d=o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7},children:[c?o.jsx(dc,{bg:m.doneBg,fg:m.done,text:t.planApprovedPill}):l?o.jsx(dc,{bg:m.gray,fg:m.grayInk,text:t.planRejectedPill}):o.jsx(dc,{bg:m.runBg,fg:m.run,text:t.planPendingPill}),o.jsx("span",{style:{font:`400 10px ${N}`,color:m.faint},children:"ExitPlanMode"}),e.timeLabel&&o.jsxs("span",{style:{marginLeft:"auto",font:`400 10px ${N}`,color:m.faint},children:[e.timeLabel,c?` ${t.approvedBy}`:""]})]}),u=o.jsx("div",{style:{fontSize:a&&!n?14.5:13.5,fontWeight:600,color:c?m.sub:l?m.grayInk:m.ink,lineHeight:1.4,marginTop:8,overflowWrap:"break-word",...l?{textDecoration:"line-through",textDecorationColor:"var(--proto-line)"}:{}},children:e.title});return a&&n?o.jsx("div",{style:_u(!0,!0,!1),children:o.jsxs("div",{style:{padding:"11px 14px 12px"},children:[d,u,o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,background:"var(--proto-alt)",border:"1px solid var(--proto-line-2)",borderRadius:11,padding:"9px 13px",marginTop:9},children:[o.jsx("span",{style:{font:`500 10.5px ${N}`,color:m.sub,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.filePath??""}),o.jsx("span",{role:"button",onClick:s,style:{marginLeft:"auto",fontSize:11,fontWeight:600,color:m.run,flex:"none",cursor:"pointer"},children:t.viewFullPlan})]})]})}):a?o.jsxs("div",{style:_u(!0,!1,!1),children:[o.jsxs("div",{style:{padding:"12px 14px 0"},children:[d,u]}),o.jsx("div",{style:{padding:"11px 14px 12px"},children:o.jsxs("div",{role:"button",onClick:s,style:{minHeight:52,border:"1px solid var(--proto-accent-bg)",background:"var(--proto-accent-bg)",borderRadius:11,display:"flex",alignItems:"center",gap:10,padding:"9px 13px",boxSizing:"border-box",cursor:"pointer"},children:[RY,o.jsxs("div",{style:{minWidth:0,flex:1},children:[o.jsx("div",{style:{font:`500 11px ${N}`,color:m.ink,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.filePath??`${e.lineCount} lines`}),o.jsx("div",{style:{fontSize:10,color:"var(--proto-muted-3)",marginTop:2},children:t.readHint})]}),o.jsx("span",{style:{fontSize:12,fontWeight:600,color:m.run,flex:"none"},children:t.readLink})]})}),o.jsxs("div",{style:{display:"flex",gap:8,padding:"0 14px 12px"},children:[o.jsx("button",{type:"button",onClick:r,style:{flex:1.3,height:44,borderRadius:11,background:m.ink,color:"var(--ink-solid-fg)",border:"none",fontSize:14,fontWeight:600,cursor:"pointer"},children:t.approve}),o.jsx("button",{type:"button",onClick:i,style:{flex:1,height:44,borderRadius:11,border:"1.5px solid var(--proto-line-3)",background:"var(--proto-card)",color:m.ink,fontSize:14,fontWeight:600,boxSizing:"border-box",cursor:"pointer"},children:t.reject})]}),o.jsx("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"9px 14px",borderTop:"1px solid var(--proto-line-2)",font:`400 10px ${N}`,color:"var(--proto-muted-3)"},children:o.jsx("span",{style:{marginLeft:"auto",color:m.faint},children:t.approveHint})})]}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{style:_u(!1,!1,l),children:[o.jsxs("div",{style:{padding:"11px 14px 12px"},children:[d,u]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"9px 14px",borderTop:"1px solid var(--proto-line-2)",font:`400 10px ${N}`,color:"var(--proto-muted-3)"},children:[e.filePath&&o.jsx("span",{style:{color:m.run,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.filePath}),l&&o.jsx("span",{children:t.rewriteNote}),o.jsx("span",{role:"button",onClick:s,style:{marginLeft:"auto",color:m.run,fontWeight:600,cursor:"pointer",flex:"none"},children:l?t.viewOriginalPlan:t.viewFullPlan})]})]}),l&&e.feedback&&o.jsx("div",{style:{alignSelf:"flex-end",maxWidth:"82%",background:m.ink,color:"var(--ink-solid-fg)",borderRadius:"16px 16px 4px 16px",padding:"9px 13px",fontSize:13.5,lineHeight:1.55,whiteSpace:"pre-wrap",overflowWrap:"break-word"},children:e.feedback})]})}function LY(e){let t=null;return{onTouchStart:()=>{t=setTimeout(e,450)},onTouchEnd:()=>{t&&clearTimeout(t)},onTouchMove:()=>{t&&clearTimeout(t)},onContextMenu:n=>{n.preventDefault(),e()}}}function OY({row:e,menu:t,copy:n}){const r=e.kind==="user",i=e.kind==="user"||e.kind==="assistant"?e.text:"",s=(a,l,c,d)=>o.jsxs("div",{role:"button",onClick:c?void 0:()=>{l==null||l(),t.onClose()},style:{display:"flex",alignItems:"center",height:46,padding:"0 15px",fontSize:14.5,color:m.ink,opacity:c?.35:1,cursor:c?"default":"pointer",borderTop:d?"1px solid rgba(0,0,0,.07)":void 0},children:[a,a===n.menuCopy?o.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 14 14",fill:"none",stroke:m.muted,strokeWidth:"1.4",style:{marginLeft:"auto"},children:[o.jsx("rect",{x:"4.5",y:"4.5",width:"8",height:"8",rx:"1.5"}),o.jsx("path",{d:"M2.5 9.5V3.5a1 1 0 0 1 1-1h6"})]}):o.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 14 14",fill:"none",stroke:m.muted,strokeWidth:"1.4",style:{marginLeft:"auto"},children:[o.jsx("path",{d:"M2.5 11.5l.6-2.6 6.4-6.4a1.3 1.3 0 0 1 1.8 0l.2.2a1.3 1.3 0 0 1 0 1.8L5.1 10.9z"}),o.jsx("path",{d:"M8.6 3.4l2 2"})]})]});return o.jsxs("div",{onClick:t.onClose,style:{position:"absolute",inset:0,zIndex:8,background:"rgba(25,28,34,.38)",backdropFilter:"blur(1.5px)",WebkitBackdropFilter:"blur(1.5px)",padding:"120px 14px 0",boxSizing:"border-box",display:"flex",flexDirection:"column",alignItems:r?"flex-end":"flex-start",gap:9},children:[r?o.jsx("div",{style:{maxWidth:"82%",background:m.ink,color:"var(--ink-solid-fg)",borderRadius:"16px 16px 4px 16px",padding:"9px 13px",fontSize:13.5,lineHeight:1.55,boxShadow:"0 14px 40px rgba(0,0,0,.4)",maxHeight:"38%",overflow:"hidden",whiteSpace:"pre-wrap",overflowWrap:"break-word"},children:i}):o.jsx("div",{style:{maxWidth:"88%",background:"var(--proto-card)",color:m.body,borderRadius:14,padding:"9px 13px",fontSize:13.5,lineHeight:1.6,boxShadow:"0 14px 40px rgba(0,0,0,.4)",maxHeight:"38%",overflow:"hidden",whiteSpace:"pre-wrap",overflowWrap:"break-word"},children:i}),o.jsxs("div",{onClick:a=>a.stopPropagation(),style:{width:196,background:"rgba(250,250,252,.98)",border:"1px solid rgba(0,0,0,.06)",borderRadius:13,boxShadow:"0 14px 40px rgba(16,24,40,.25)",overflow:"hidden"},children:[s(n.menuCopy,t.onCopy),t.onEdit&&s(n.menuEdit,t.onEdit,t.editDisabled,!0)]})]})}function AY({title:e,onCancel:t}){return o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,background:"var(--proto-alt)",border:"1px solid var(--proto-accent-border)",borderRadius:11,padding:"8px 8px 8px 12px",marginBottom:7},children:[o.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:m.run,flex:"none"}}),o.jsx("span",{style:{fontSize:12,fontWeight:600,color:"var(--proto-accent-strong)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e}),o.jsx("div",{role:"button","aria-label":"Cancel edit",onClick:t,style:{marginLeft:"auto",width:26,height:26,borderRadius:8,background:"var(--proto-card)",border:"1px solid var(--proto-accent-border)",display:"flex",alignItems:"center",justifyContent:"center",color:m.run,fontSize:12,flex:"none",cursor:"pointer"},children:"×"})]})}function DY(e){return o.jsx(En,{onBack:e.onBack,trailing:o.jsx(r3,{onClick:e.onMore}),children:o.jsxs("div",{style:{minWidth:0,flex:1},children:[o.jsx("div",{style:{fontSize:15,fontWeight:650,color:m.ink,letterSpacing:"-.01em",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.title}),o.jsx(NY,{...e})]})})}function NY({status:e}){return o.jsx("div",{"data-chat-status-line":"true",style:{display:"flex",alignItems:"center",gap:8,font:`400 10px ${N}`,color:e.tone==="waiting"?m.amberText:m.muted,marginTop:1},children:o.jsxs("span",{style:{display:"flex",alignItems:"center",gap:5,minWidth:0},children:[o.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:e.tone==="waiting"?m.amber:e.running?m.run:"var(--proto-line-3)",animation:e.running?"cxpulse 1.6s ease-in-out infinite":void 0,flex:"none"}}),o.jsx("span",{style:{whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.text})]})})}function _Y({copy:e,onClose:t,onSessionId:n}){const r=[{label:e.menuSessionId,onTap:n},{label:e.menuRename,onTap:t},{label:e.menuExport,onTap:t},{label:e.menuArchive,onTap:t}];return o.jsxs(o.Fragment,{children:[o.jsx("div",{onClick:t,style:{position:"absolute",inset:0,zIndex:5}}),o.jsx("div",{style:{position:"absolute",top:"calc(52px + env(safe-area-inset-top))",right:14,width:148,background:"rgba(250,250,252,.98)",border:"1px solid rgba(0,0,0,.06)",borderRadius:13,boxShadow:"0 14px 40px rgba(16,24,40,.2)",overflow:"hidden",zIndex:6},children:r.map((i,s)=>o.jsx("div",{onClick:i.onTap,style:{padding:"11px 14px",fontSize:13,color:m.ink,borderBottom:s<r.length-1?"1px solid var(--proto-line-2)":void 0,cursor:"pointer"},children:i.label},i.label))})]})}function $Y({copy:e,cortexId:t,backendUuid:n,onClose:r}){const i=f3({cortexId:t,backendUuid:n,cortexIdLabel:e.cortexIdLabel,backendUuidLabel:e.backendUuidLabel}),[s,a]=p.useState(null),l=(c,d)=>{var u;d!=="—"&&((u=navigator.clipboard)==null||u.writeText(d).catch(()=>{}),a(c),window.setTimeout(()=>a(f=>f===c?null:f),1400))};return o.jsxs(Ti,{onClose:r,children:[o.jsx("div",{style:{fontSize:17,fontWeight:700,color:m.ink,letterSpacing:"-.01em",padding:"0 2px 12px"},children:e.sessionIdTitle}),o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:11},children:i.map(c=>o.jsxs("div",{children:[o.jsx("div",{style:{font:`600 9.5px ${N}`,letterSpacing:".05em",color:m.muted,padding:"0 2px 5px"},children:c.label}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,background:"var(--proto-card)",border:`1px solid ${m.hairline}`,borderRadius:11,padding:"10px 12px"},children:[o.jsx("span",{style:{flex:1,font:`500 12px ${N}`,color:m.ink,wordBreak:"break-all",userSelect:"all"},children:c.value}),o.jsx("span",{role:"button",onClick:()=>l(c.key,c.value),style:{flex:"none",font:`600 9.5px ${N}`,color:s===c.key?m.run:m.muted,border:`1px solid ${s===c.key?m.runBorder:"var(--proto-line-3)"}`,borderRadius:7,padding:"4px 9px",cursor:c.value==="—"?"default":"pointer",opacity:c.value==="—"?.4:1},children:s===c.key?e.copied:e.copy})]})]},c.key))})]})}const FY="repeating-linear-gradient(45deg,var(--proto-line) 0 6px,var(--proto-rail) 6px 12px)";function zY({a:e}){const t=gs(e.type),{openMedia:n}=gd(),{openDoc:r}=md(),i=xd(e.name,e.mimeType),s=nv(e.path,t!==null);if(t!==null)return o.jsxs("div",{role:"button",onClick:()=>n({kind:t,name:e.name,path:e.path}),style:{width:e.type==="video"?104:74,height:74,borderRadius:12,background:s?"#000":FY,position:"relative",overflow:"hidden",flex:"none",cursor:"pointer"},children:[s&&t==="image"&&o.jsx("img",{src:s,alt:e.name,style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover"}}),s&&t==="video"&&o.jsx(vd,{src:s,style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover"}}),t==="video"&&o.jsx("span",{style:{position:"absolute",left:"50%",top:"50%",transform:"translate(-50%,-50%)",width:26,height:26,borderRadius:"50%",background:"rgba(25,28,34,.72)",color:"var(--ink-solid-fg)",fontSize:9,display:"flex",alignItems:"center",justifyContent:"center",paddingLeft:2,boxSizing:"border-box"},children:"▶"}),o.jsx("span",{style:{position:"absolute",left:7,bottom:6,maxWidth:(e.type==="video"?104:74)-14,font:`500 8px ${N}`,color:m.muted,background:"rgba(255,255,255,.85)",padding:"1px 5px",borderRadius:4,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",boxSizing:"border-box"},children:e.name})]});const a=i?()=>r({kind:i,name:e.name,path:e.path,mimeType:e.mimeType}):()=>void $x(e.path,e.name);return o.jsxs("div",{role:"button",onClick:a,style:{display:"flex",alignItems:"center",gap:6,background:"var(--proto-card)",border:`1px solid ${m.hairline}`,borderRadius:9,padding:"6px 10px",flex:"none",cursor:"pointer"},children:[o.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 14 14",fill:"none",stroke:m.muted,strokeWidth:"1.5",children:[o.jsx("path",{d:"M3 1.5h5.5L11.5 4v8.5h-8.5z"}),o.jsx("path",{d:"M8.5 1.5V4H11"})]}),o.jsx("span",{style:{font:`500 10.5px ${N}`,color:m.body},children:e.name})]})}function _j({attachments:e,side:t="right"}){const n=t==="left"?"flex-start":"flex-end";return o.jsx("div",{style:{alignSelf:n,display:"flex",gap:6,flexWrap:"wrap",justifyContent:n},children:e.map((r,i)=>o.jsx(zY,{a:r},i))})}const Jx=6,BY={font:`400 10px ${N}`,background:"var(--proto-card)",border:"1px solid var(--proto-line-2)",padding:"1px 6px",borderRadius:4,flex:"none"},z3={display:"flex",alignItems:"center",gap:Jx,flex:1,minWidth:0,overflow:"hidden",position:"relative"},WY={...z3,position:"absolute",visibility:"hidden",pointerEvents:"none",width:"max-content",overflow:"visible"};function $j({name:e}){return o.jsx("span",{style:BY,children:e})}function UY({count:e,calls:t,unit:n,onExpand:r}){const i=t.map(d=>d.kind),{containerRef:s,measureRef:a,layout:l}=uC(i,Jx),c=CY(t,l);return o.jsxs("div",{onClick:r,style:{display:"flex",alignItems:"center",gap:Jx,fontSize:11,color:"var(--proto-muted-3)",flexWrap:"nowrap",whiteSpace:"nowrap",overflow:"hidden",cursor:"pointer"},children:[o.jsx("span",{style:{fontSize:8.5,flex:"none"},children:"▸"}),o.jsxs("span",{style:{flex:"none"},children:[e," ",n]}),o.jsxs("span",{ref:s,style:z3,children:[c.names.map((d,u)=>o.jsx($j,{name:d},u)),c.overflow>0?o.jsxs("span",{style:{flex:"none"},children:["+",c.overflow]}):null,o.jsxs("span",{ref:a,"aria-hidden":"true",style:WY,children:[i.map((d,u)=>o.jsx($j,{name:d},u)),o.jsxs("span",{style:{flex:"none"},children:["+",t.length]})]})]})]})}function HY({count:e,calls:t,unit:n,onCollapse:r}){return o.jsxs("div",{style:{background:"var(--proto-rail)",border:"1px solid var(--proto-line-2)",borderRadius:8,overflow:"hidden"},children:[o.jsxs("div",{onClick:r,style:{display:"flex",alignItems:"center",gap:6,fontSize:11,color:"var(--proto-muted-3)",padding:"6px 11px",cursor:"pointer"},children:[o.jsx("span",{style:{fontSize:8.5},children:"▾"}),o.jsxs("span",{children:[e," ",n]})]}),t.map((i,s)=>o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"5.5px 11px",borderTop:"1px solid var(--proto-line-soft)"},children:[o.jsx("span",{style:{font:`600 9px ${N}`,color:"var(--proto-muted)",background:"var(--proto-gray)",padding:"1.5px 7px",borderRadius:5,flex:"none"},children:i.kind}),o.jsx("span",{style:{font:`400 10.5px ${N}`,color:m.body,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",minWidth:0},children:i.input})]},s))]})}function VY({count:e,calls:t,unit:n}){const[r,i]=p.useState(!1);return r?o.jsx(HY,{count:e,calls:t,unit:n,onCollapse:()=>i(!1)}):o.jsx(UY,{count:e,calls:t,unit:n,onExpand:()=>i(!0)})}const Jh=()=>{};function qY({text:e,preview:t,streamKey:n}){const r=KC(e,!!t,n);return r.trim()?o.jsx(Si,{text:r,dropTrailingHr:!0}):null}function KY({row:e,interactions:t}){const n=OC(e),r=(t==null?void 0:t.copy)??F3.zh;if(n.kind==="ask"){const a=n.model;return o.jsx(IY,{model:a,state:(t==null?void 0:t.askState(a.requestId))??MC,copy:r,onPick:l=>t==null?void 0:t.onAskPick(a,l),onToggle:l=>t==null?void 0:t.onAskToggle(a,l),onConfirmMulti:()=>t==null?void 0:t.onAskConfirmMulti(a),onCustom:()=>t==null?void 0:t.onAskCustom(a)})}if(n.kind==="plan"){const a=n.model;return o.jsx(MY,{model:a,copy:r,dimmed:(t==null?void 0:t.rejectingId)===a.requestId,onApprove:t?()=>t.onApprove(a):Jh,onRejectStart:t?()=>t.onRejectStart(a):Jh,onOpenRead:t?()=>t.onOpenRead(a):Jh})}const i=n.tone==="rejected"?"var(--proto-danger)":n.tone==="inactive"?"var(--proto-muted-3)":m.done,s=n.tone==="rejected"?"✗":n.tone==="inactive"?"◌":"✓";return o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 11px",background:"var(--proto-card)",border:"1px solid var(--proto-line-2)",borderRadius:10,opacity:n.tone==="inactive"?.6:.75},children:[o.jsxs("span",{style:{fontSize:10,fontWeight:700,color:i,flexShrink:0},children:[s," ",n.label]}),o.jsx("span",{style:{fontSize:11.5,color:m.sub,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:n.text})]})}function QY({rows:e,toolCallsUnit:t,interactions:n,editCopy:r,editing:i,onLongPress:s,onShowOriginal:a,streamKey:l}){const c=r?HC(e):null,d=(i==null?void 0:i.rowIndex)??null;return o.jsx(o.Fragment,{children:e.map((u,f)=>{const h=d!=null&&f>d,g=d===f,v=!!r&&!!s&&d==null&&u.kind==="user",x=v?LY(()=>s(f)):null;return o.jsxs(p.Fragment,{children:[u.kind==="divider"&&o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,...h?{opacity:.35}:{}},children:[o.jsx("div",{style:{flex:1,height:1,background:"var(--proto-line)"}}),o.jsx("div",{style:{fontSize:9.5,fontWeight:600,letterSpacing:".06em",color:m.faint},children:u.text}),o.jsx("div",{style:{flex:1,height:1,background:"var(--proto-line)"}})]}),u.kind==="user"&&o.jsxs(o.Fragment,{children:[u.attachments&&u.attachments.length>0&&o.jsx(_j,{attachments:u.attachments}),o.jsxs("div",{style:{alignSelf:"flex-end",display:"flex",flexDirection:"column",alignItems:"flex-end",gap:5,maxWidth:"82%",...h?{opacity:.35,pointerEvents:"none"}:{}},children:[g&&r&&o.jsx("span",{style:{font:`600 9.5px ${N}`,color:m.run,background:"var(--proto-accent-bg)",padding:"2px 7px",borderRadius:4},children:r.editingBadge}),o.jsx("div",{...x??{},style:{background:m.ink,color:u.pending?m.inkSolidFgDim:m.inkSolidFg,borderRadius:"16px 16px 4px 16px",padding:"9px 13px",fontSize:13.5,lineHeight:1.55,whiteSpace:"pre-wrap",overflowWrap:"break-word",wordBreak:"break-word",WebkitUserSelect:v?"none":void 0,userSelect:v?"none":void 0,WebkitTouchCallout:v?"none":void 0,...g?{boxShadow:`0 0 0 2px ${m.canvas}, 0 0 0 3.5px ${m.run}`}:{}},children:u.text}),r&&u.edited&&!g&&o.jsx("span",{role:"button",onClick:a?()=>a(u.edited):void 0,style:{font:`400 9.5px ${N}`,color:m.faint,cursor:"pointer"},children:o.jsx("span",{style:{borderBottom:`1px dotted ${m.faint}`},children:r.edited})})]}),g&&r&&i&&o.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:o.jsx("span",{style:{font:`600 9px ${N}`,color:"var(--m-amber-ink)",background:m.amberBg,padding:"2px 7px",borderRadius:4},children:r.willRewind(i.replies,i.toolCalls)})})]}),u.kind==="tools"&&o.jsx("div",{style:h?{opacity:.35,pointerEvents:"none"}:void 0,children:o.jsx(VY,{count:u.count,calls:u.calls,unit:t})}),u.kind==="notice"&&o.jsx("div",{style:h?{opacity:.35,pointerEvents:"none"}:void 0,children:o.jsx(DC,{level:u.level,text:u.text,authAction:u.authAction})}),u.kind==="assistant"&&o.jsxs("div",{...x??{},style:{fontSize:13.5,lineHeight:1.65,color:m.body,minWidth:0,overflowWrap:"break-word",wordBreak:"break-word",...h?{opacity:.35,pointerEvents:"none"}:{},WebkitUserSelect:v?"none":void 0,userSelect:v?"none":void 0,WebkitTouchCallout:v?"none":void 0},children:[r&&(c==null?void 0:c.has(f))&&o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5,font:`400 9.5px ${N}`,color:m.faint,marginBottom:4},children:[o.jsx("span",{style:{width:5,height:5,borderRadius:"50%",background:"var(--proto-line-3)",flex:"none"}}),r.regenNote]}),o.jsx(qY,{text:u.text,preview:u.preview,streamKey:l}),u.attachments&&u.attachments.length>0&&o.jsx("div",{style:{marginTop:8},children:o.jsx(_j,{attachments:u.attachments,side:"left"})})]}),u.kind==="interaction"&&o.jsx("div",{style:{display:"flex",flexDirection:"column",...h?{opacity:.35,pointerEvents:"none"}:{}},children:o.jsx(KY,{row:u,interactions:n})})]},u.kind==="interaction"&&u.detail?`int-${u.detail.id}`:f)})})}function YY({text:e}){return o.jsxs("div",{style:{alignSelf:"center",display:"flex",alignItems:"center",gap:6,font:`400 9.5px ${N}`,color:m.faint,background:"var(--proto-card)",border:"1px solid var(--proto-line-2)",padding:"3px 10px",borderRadius:999},children:[o.jsx("span",{style:{width:5,height:5,borderRadius:"50%",background:m.run}}),e]})}function GY({copy:e,onClose:t,onCamera:n,onLibrary:r,onFile:i}){const s=(a,l,c,d)=>o.jsxs("div",{onClick:()=>{l(),t()},style:{display:"flex",alignItems:"center",gap:9,padding:"11px 14px",borderBottom:d?void 0:"1px solid var(--proto-line-2)",cursor:"pointer"},children:[c,o.jsx("span",{style:{fontSize:13,color:m.ink},children:a})]});return o.jsxs(o.Fragment,{children:[o.jsx("div",{onClick:t,style:{position:"absolute",inset:0,zIndex:5}}),o.jsxs("div",{style:{position:"absolute",left:14,bottom:90,width:196,background:"rgba(250,250,252,.98)",border:"1px solid rgba(0,0,0,.06)",borderRadius:13,boxShadow:"0 14px 40px rgba(16,24,40,.2)",overflow:"hidden",zIndex:6},children:[s(e.attachCamera,n,o.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 16 16",fill:"none",stroke:m.ink,strokeWidth:"1.5",children:[o.jsx("rect",{x:"1.5",y:"4",width:"13",height:"9.5",rx:"2"}),o.jsx("circle",{cx:"8",cy:"8.7",r:"2.6"}),o.jsx("path",{d:"M5.5 4l1-1.7h3l1 1.7"})]})),s(e.attachLibrary,r,o.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 16 16",fill:"none",stroke:m.ink,strokeWidth:"1.5",children:[o.jsx("rect",{x:"2",y:"2",width:"12",height:"12",rx:"2.5"}),o.jsx("circle",{cx:"6",cy:"6",r:"1.3"}),o.jsx("path",{d:"M2.5 11.5 6 8.5l2.5 2 3-3 2 2"})]})),s(e.attachFile,i,o.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 14 14",fill:"none",stroke:m.ink,strokeWidth:"1.4",children:[o.jsx("path",{d:"M3 1.5h5.5L11.5 4v8.5h-8.5z"}),o.jsx("path",{d:"M8.5 1.5V4H11"})]}),!0)]})]})}function XY({a:e,onRemove:t}){const n=e.status==="uploading",{openMedia:r}=gd(),i=e.type?gs(e.type):null,s=!!e.previewUrl&&i!==null;return o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:n?7:6,background:"var(--proto-card)",border:`1px solid ${n?m.runBorder:m.hairline}`,borderRadius:9,padding:"5px 9px",flex:"none"},children:[s&&o.jsxs("span",{role:"button",onClick:()=>r({kind:i,name:e.name,url:e.previewUrl}),style:{position:"relative",width:26,height:26,borderRadius:6,overflow:"hidden",background:"#000",flex:"none",cursor:"pointer"},children:[i==="image"?o.jsx("img",{src:e.previewUrl,alt:e.name,style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}}):o.jsx(vd,{src:e.previewUrl,style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}}),i==="video"&&o.jsx("span",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",color:"var(--ink-solid-fg)",fontSize:8,textShadow:"0 0 3px rgba(0,0,0,.8)"},children:"▶"})]}),o.jsx("span",{style:{font:`500 10px ${N}`,color:m.body},children:e.name}),n?o.jsxs(o.Fragment,{children:[o.jsx("div",{style:{width:34,height:4,borderRadius:999,background:"var(--proto-line-2)",overflow:"hidden"},children:o.jsx("div",{style:{width:`${e.progress}%`,height:"100%",background:m.run}})}),o.jsxs("span",{style:{font:`400 9px ${N}`,color:m.run},children:[e.progress,"%"]})]}):e.status==="done"?o.jsx("span",{style:{fontSize:10,color:m.done,fontWeight:700},children:"✓"}):e.status==="error"?o.jsx("span",{style:{fontSize:10,color:m.fail,fontWeight:700},children:"!"}):null,o.jsx("span",{onClick:t,style:{color:m.faint,fontSize:11,cursor:"pointer"},children:"✕"})]})}function JY({usage:e,lang:t,compactAction:n,onClose:r}){return o.jsx(Ti,{onClose:r,children:o.jsxs("div",{"data-mobile-context-usage-sheet":"true",children:[o.jsx("div",{style:{fontSize:17,fontWeight:700,color:m.ink,letterSpacing:"-.01em",padding:"0 2px 10px"},children:j3(t)}),o.jsx("div",{style:{background:"var(--proto-card)",border:`1px solid ${m.hairline}`,borderRadius:13,padding:"12px 13px"},children:o.jsx(S3,{usage:e,lang:t})}),n?o.jsx("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"10px 2px 0"},children:o.jsx(k3,{action:n,lang:t})}):null]})})}function ZY({items:e,copy:t,onClose:n,onPick:r}){return o.jsxs(Ti,{onClose:n,children:[o.jsxs("div",{style:{display:"flex",alignItems:"baseline",padding:"0 2px 10px"},children:[o.jsx("span",{style:{fontSize:17,fontWeight:700,color:m.ink,letterSpacing:"-.01em"},children:t.profileTitle}),o.jsx("span",{style:{marginLeft:"auto",font:`400 9.5px ${N}`,color:m.faint},children:t.profileSubtitle})]}),o.jsx("div",{style:{background:"var(--proto-card)",border:`1px solid ${m.hairline}`,borderRadius:13,overflow:"hidden"},children:e.map((i,s)=>o.jsxs("div",{onClick:()=>r(i.name),style:{display:"flex",alignItems:"center",gap:10,padding:"12px 13px",borderBottom:s<e.length-1?"1px solid var(--proto-line-soft)":void 0,cursor:"pointer"},children:[o.jsxs("div",{style:{minWidth:0,flex:1},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7},children:[o.jsx("span",{style:{font:`600 13px ${N}`,color:m.ink},children:i.name}),i.current&&o.jsx("span",{style:{fontSize:9.5,fontWeight:600,padding:"1.5px 7px",borderRadius:999,background:m.runBg,color:m.run},children:t.profileCurrent})]}),o.jsx("div",{style:{font:`400 10px ${N}`,color:m.muted,marginTop:3},children:i.sub})]}),i.current&&o.jsx("span",{style:{fontSize:15,fontWeight:700,color:m.run,flex:"none"},children:"✓"})]},i.name))}),o.jsx("div",{style:{font:`400 9.5px ${N}`,color:m.faint,padding:"9px 4px 0"},children:t.profileFooter})]})}function eG({onClick:e}){return o.jsx("button",{type:"button","aria-label":"Attach",onClick:e,style:{flex:"none",width:46,height:46,borderRadius:14,border:`1.5px solid ${m.run}`,background:"var(--proto-card)",display:"flex",alignItems:"center",justifyContent:"center",boxSizing:"border-box",color:m.run,fontSize:22,fontWeight:300,cursor:"pointer"},children:"+"})}function tG({label:e,onClick:t}){return o.jsxs("button",{type:"button",onClick:t,style:{display:"flex",alignItems:"center",gap:6,border:"1px solid var(--proto-accent-bg)",background:"var(--proto-card)",borderRadius:999,padding:"4px 10px",flex:"none",cursor:"pointer"},children:[o.jsx("span",{style:{width:5,height:5,borderRadius:"50%",background:m.run}}),o.jsx("span",{style:{font:`600 10px ${N}`,color:m.run},children:e}),o.jsx("span",{style:{fontSize:7.5,color:m.muted},children:"▾"})]})}function nG(e){var u;const{copy:t}=e,n=p.useRef(null),r=p.useRef(null),i=p.useRef(!0),s=p.useRef(0),a=()=>{const f=n.current;f&&(i.current=f.scrollHeight-f.scrollTop-f.clientHeight<40)},l=()=>{s.current=Date.now()+800};p.useEffect(()=>{const f=n.current;f&&i.current&&Date.now()>=s.current&&(f.scrollTop=f.scrollHeight)},[e.rows,e.systemLines]),p.useEffect(()=>{const f=n.current,h=r.current;if(!f||!h||typeof ResizeObserver>"u")return;const g=new ResizeObserver(()=>{i.current&&Date.now()>=s.current&&(f.scrollTop=f.scrollHeight)});return g.observe(h),()=>g.disconnect()},[]);const d=e.editing&&e.editCopy?o.jsx(AY,{title:e.editCopy.editBarTitle,onCancel:e.editing.onCancel}):e.rejectBar?o.jsxs(o.Fragment,{children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,background:m.amberCard,border:`1px solid ${m.amberBorder}`,borderRadius:11,padding:"8px 8px 8px 12px",marginBottom:7},children:[o.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:m.amber,flex:"none"}}),o.jsx("span",{style:{fontSize:12,fontWeight:600,color:"var(--proto-amber-fg)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.rejectBar.title}),o.jsx("div",{role:"button","aria-label":"Cancel reject",onClick:e.rejectBar.onCancel,style:{marginLeft:"auto",width:26,height:26,borderRadius:8,background:"var(--proto-card)",border:`1px solid ${m.amberBorder}`,display:"flex",alignItems:"center",justifyContent:"center",color:m.amberText,fontSize:11,flex:"none",cursor:"pointer"},children:"✕"})]}),o.jsx("div",{style:{display:"flex",gap:6,padding:"0 2px 8px",overflowX:"auto"},children:e.rejectBar.chips.map(f=>o.jsx("span",{role:"button",onClick:()=>e.rejectBar.onChipTap(f),style:{flex:"none",fontSize:11,fontWeight:600,color:m.sub,border:"1px solid var(--proto-line-3)",background:"var(--proto-card)",borderRadius:999,padding:"5px 11px",cursor:"pointer"},children:f},f))})]}):o.jsxs(o.Fragment,{children:[e.attachments.length>0&&o.jsx("div",{style:{display:"flex",gap:6,padding:"0 2px 7px",overflowX:"auto"},children:e.attachments.map(f=>o.jsx(XY,{a:f,onRemove:()=>e.onRemoveAttachment(f.id)},f.id))}),o.jsxs("div",{"data-mobile-composer-meta-row":"true",style:{display:"flex",alignItems:"center",gap:8,padding:"0 2px 7px"},children:[o.jsx(tG,{label:e.profileChipLabel,onClick:e.onOpenProfile}),e.contextUsageSupported||e.contextUsage!=null?o.jsx("span",{"data-context-usage-position":"composer-profile",style:{marginLeft:"auto",display:"inline-flex",flex:"none"},children:o.jsx(w3,{usage:e.contextUsage??null,variant:"mobile",lang:e.contextUsageLang??"en",onClick:e.onContextUsageOpen,"data-context-compact-enabled":e.contextCompactAction?"true":void 0})}):null]})]});return o.jsxs("div",{"data-screen-label":"1b 会话详情",style:{height:"100%",position:"relative",display:"flex",flexDirection:"column",boxSizing:"border-box",background:m.canvas},children:[o.jsx(DY,{title:e.title,status:e.status,onBack:e.onBack,onMore:e.onMoreToggle}),o.jsxs("div",{style:{position:"relative",flex:1,minHeight:0,display:"flex",flexDirection:"column"},children:[o.jsx("div",{ref:n,onScroll:a,onClick:l,style:{flex:1,minHeight:0,overflow:"auto",background:m.canvas},children:o.jsxs("div",{ref:r,style:{padding:"14px 14px 0",display:"flex",flexDirection:"column",gap:12},children:[o.jsx(QY,{rows:e.rows,toolCallsUnit:t.toolCallsUnit,interactions:e.interactions,editCopy:e.editCopy,editing:e.editing,onLongPress:e.onLongPress,onShowOriginal:e.onShowOriginal,streamKey:e.streamKey}),e.inlineThreadCard,(u=e.systemLines)==null?void 0:u.map((f,h)=>o.jsx(YY,{text:f},h)),o.jsx("div",{style:{height:"calc(8px + env(safe-area-inset-bottom))",flex:"none"}})]})}),o.jsx(hV,{placeholder:e.composerPlaceholder??(e.attachments.length>0?t.attachPlaceholder:t.composerPh),value:e.composerValue,onChange:e.onComposerChange,onSend:e.onSend,sendEnabled:e.sendEnabled,running:e.status.running,onStop:e.onStop,stopEnabled:e.stopEnabled,leading:e.editing||e.rejectBar?void 0:o.jsx(eG,{onClick:e.onPlus}),above:d,onPlus:e.onPlus,lineUnit:t.lineUnit,charUnit:t.charUnit,tone:e.editing?"accent":e.rejectBar?"amber":"default"})]}),e.moreOpen&&o.jsx(_Y,{copy:t,onClose:e.onMoreClose,onSessionId:()=>{e.onMoreClose(),e.onSessionIdOpen()}}),e.sessionIdOpen&&o.jsx($Y,{copy:t,cortexId:e.cortexId,backendUuid:e.backendUuid,onClose:e.onSessionIdClose}),e.msgMenu&&e.editCopy&&e.rows[e.msgMenu.rowIndex]&&o.jsx(OY,{row:e.rows[e.msgMenu.rowIndex],menu:e.msgMenu,copy:e.editCopy}),e.originalSheet&&e.editCopy&&o.jsxs(Ti,{onClose:e.originalSheet.onClose,children:[o.jsx("div",{style:{font:`600 10px ${N}`,color:m.muted,letterSpacing:".05em",padding:"0 2px 8px"},children:e.editCopy.original}),o.jsx("div",{style:{background:"var(--proto-card)",border:`1px solid ${m.hairline}`,borderRadius:13,padding:"11px 13px",fontSize:13,lineHeight:1.6,color:m.body,whiteSpace:"pre-wrap",overflowWrap:"break-word",maxHeight:"50vh",overflow:"auto"},children:e.originalSheet.text})]}),e.attachMenuOpen&&o.jsx(GY,{copy:t,onClose:e.onAttachClose,onCamera:e.onCamera,onLibrary:e.onLibrary,onFile:e.onFile}),e.profileSheet&&o.jsx(ZY,{items:e.profileSheet.items,copy:t,onClose:e.profileSheet.onClose,onPick:e.profileSheet.onPick}),e.contextUsageOpen&&(e.contextUsageSupported||e.contextUsage!=null)?o.jsx(JY,{usage:e.contextUsage??null,lang:e.contextUsageLang??"en",compactAction:e.contextCompactAction,onClose:e.onContextUsageClose}):null]})}function rG(e,t,n={}){return sv(e,t,{streaming:n.streaming,streamingText:n.streamingText,pendingUser:n.pendingUser,formatDivider:jY,...n.now?{now:n.now}:{}})}const Fj="—";function oG(e){return"$"+e.toFixed(2)}function iG(e,t,n,r,i){const s=t==null?Fj:`${t} turns`;if(e)return{running:!0,tone:"running",text:`running · ${n} · ${s}`};if(!i)return{running:!1,tone:"idle",text:"idle"};const a=r==null?Fj:oG(r);return{running:!1,tone:"idle",text:`idle · ${n} · ${s} · ${a}`}}function sG(e,t,n,r){const i=r==="zh";if(e==="plan-approval")return{running:!1,tone:"waiting",text:i?"计划待批 · Agent 已暂停":"plan pending · agent paused"};const s=n>1?` ${Math.min(t+1,n)}/${n}`:"";return{running:!1,tone:"waiting",text:i?`等待你的回答${s} · Agent 已暂停`:`awaiting your answer${s} · agent paused`}}function aG(e,t,n){var r;return e??n??((r=t[0])==null?void 0:r.name)??"—"}function lG(e,t){const n=t.find(i=>i.name===e),r=(n==null?void 0:n.model)??(n==null?void 0:n.backend)??null;return r?`${e} · ${r}`:e}function cG(e){return[e.model,e.thinking,e.backend].filter(Boolean).join(" · ")}function B3(e,t){return e.map(n=>({name:n.name,sub:cG(n),current:n.name===t}))}const dG={sessionId:"",turns:[]},uG="/api/attachments/upload",pG={zh:{composerPh:"输入消息,/ 调用命令",toolCallsUnit:"次工具调用",menuRename:"重命名",menuExport:"导出",menuArchive:"归档",menuSessionId:"会话 ID",sessionIdTitle:"会话 ID",cortexIdLabel:"Cortex ID",backendUuidLabel:"后端 UUID",copy:"复制",copied:"已复制",attachCamera:"拍照",attachLibrary:"照片图库",attachFile:"选择文件",attachPlaceholder:"补充说明…",profileTitle:"Profile",profileSubtitle:"仅本会话 · 热更新",profileCurrent:"当前",profileFooter:"切换仅影响本会话后续 turn · 运行中线程不受影响 · 全局默认在设置",lineUnit:"行",charUnit:"字"},en:{composerPh:"Message, / for commands",toolCallsUnit:"tool calls",menuRename:"Rename",menuExport:"Export",menuArchive:"Archive",menuSessionId:"Session ID",sessionIdTitle:"Session ID",cortexIdLabel:"Cortex ID",backendUuidLabel:"Backend UUID",copy:"Copy",copied:"Copied",attachCamera:"Take photo",attachLibrary:"Photo library",attachFile:"Choose file",attachPlaceholder:"Add a note…",profileTitle:"Profile",profileSubtitle:"This session · hot-swap",profileCurrent:"current",profileFooter:"Applies to this session’s next turns only · running threads unaffected · global default in Settings",lineUnit:"lines",charUnit:"chars"}},fG={zh:{menuCopy:"复制",menuEdit:"编辑消息",editingBadge:"编辑中",willRewind:(e,t)=>`将被回退 · ${e} 条回复 · ${t} 次工具调用`,editBarTitle:"编辑消息 — 发送将回退后续回复",edited:"已编辑",original:"原消息",regenNote:"由编辑重新生成"},en:{menuCopy:"Copy",menuEdit:"Edit message",editingBadge:"Editing",willRewind:(e,t)=>`Will rewind · ${e} repl${e===1?"y":"ies"} · ${t} tool call${t===1?"":"s"}`,editBarTitle:"Editing message — send rewinds later replies",edited:"edited",original:"Original message",regenNote:"Regenerated from edit"}};function hG({sessionId:e,subthreadsLabel:t,openLabel:n}){const r=ze(),i=le(),a=Y({...i.threads.list.queryOptions({status:["running","waiting"],sessionId:e}),enabled:!!e}).data??[],l=a.find(f=>f.status==="running")??a[0]??null,c=(l==null?void 0:l.id)??"";ml(c);const d=Y({...i.threads.get.queryOptions({threadId:c}),enabled:!!c});if(!c||d.isPending||d.isError||!d.data)return null;const u=d.data;return o.jsx(PY,{card:SY(u),pill:bv(u.status),subthreadsLabel:t,openLabel:n,onOpen:()=>r(`/m/thread/${c}`)})}function gG(e){return e.type.startsWith("image/")?"image":e.type.startsWith("video/")?"video":"file"}let xG=0;const zj=()=>`att_${++xG}_${Date.now()}`;function mG(e,t,n){return new Promise((r,i)=>{const s=new XMLHttpRequest;s.open("POST",`${a0()}${uG}`),s.setRequestHeader("X-Session-Id",t),s.setRequestHeader("X-File-Name",encodeURIComponent(e.name)),s.setRequestHeader("Content-Type",e.type||"application/octet-stream"),Object.entries(us()).forEach(([a,l])=>s.setRequestHeader(a,l)),s.responseType="json",s.upload.addEventListener("progress",a=>{a.lengthComputable&&n(Math.round(a.loaded/a.total*100))}),s.addEventListener("load",()=>{const a=s.response;s.status>=200&&s.status<300&&(a!=null&&a.ok)&&a.data?r(a.data):i(new Error((a==null?void 0:a.message)||`Upload failed (${s.status})`))}),s.addEventListener("error",()=>i(new Error("Network error"))),s.send(e)})}function vG(){var ko,gr,Ri,Ii;const e=le(),t=ze(),n=je(),r=ut(),i=Lt(r,pG),{currentProjectId:s}=Bn(),{sessionId:a}=gf(),l=a==="new",c=Y(e.sessions.list.queryOptions({origin:"direct",projectId:s??void 0})),d=p.useMemo(()=>(c.data??[]).find($=>$.sessionId===a)??null,[c.data,a]),u=l?"":(d==null?void 0:d.sessionId)??a??"",f=Y({...e.sessions.transcript.queryOptions({sessionId:u}),enabled:!!u}),{liveTail:h,streaming:g,running:v,liveTurns:x,contextUsage:b,streamingText:j,pendingUser:y}=Tf(u,d==null?void 0:d.running,d==null?void 0:d.backgroundRunning,{deltas:!0,transcript:f.data??null,contextUsage:(d==null?void 0:d.contextUsage)??null}),w=C3(u,{running:v,hasBackendHistory:!!(d!=null&&d.backendSessionId)}),k=kv(u);E3(u,`${h.length}:${v}`);const S=f.data??dG,T=p.useMemo(()=>rG(S,h,{streaming:g,streamingText:j,pendingUser:y}),[S,h,g,j,y]),C=BC(x,(d==null?void 0:d.numTurns)??null),P=p.useMemo(()=>WC(zC(f.data)),[f.data]),I=p.useMemo(()=>{var $;for(const ee of T)if(ee.kind==="interaction"&&(($=ee.detail)==null?void 0:$.status)==="pending")return{detail:ee.detail,ts:ee.ts??null};return null},[T]),L=(I==null?void 0:I.detail.kind)==="ask-user"?IC(I.detail,I.ts):null,z=(I==null?void 0:I.detail.kind)==="plan-approval"?ov(I.detail,I.ts):null,[q,X]=p.useState({}),D=$=>q[$]??MC,U=($,ee)=>{X(me=>({...me,[$.requestId]:ee})),IF($,ee)&&k.answerQuestion($.requestId,MF($,ee))},Q=($,ee)=>{const me=D($.requestId),Ke=$.questions[Ao($,me)];Ke&&U($,Wx(me,Ke.question,ee))},J=($,ee)=>{X(me=>({...me,[$.requestId]:PF(D($.requestId),ee)}))},_=$=>{const ee=D($.requestId),me=$.questions[Ao($,ee)];me&&ee.selected.length>0&&U($,RF(ee,me.question))},[F,W]=p.useState(null),te=ur();p.useEffect(()=>{const $=te.state;$!=null&&$.rejectPlan&&(W($.rejectPlan),t(te.pathname,{replace:!0}))},[te.state]);const A=(z==null?void 0:z.requestId)??null;p.useEffect(()=>{F&&F!==A&&W(null)},[F,A]);const V=$=>t(`/m/session/${u}/plan/${$.requestId}`),oe=Y(e.config.get.queryOptions({})),Z=((gr=(ko=oe.data)==null?void 0:ko.profiles)==null?void 0:gr.profiles)??[],ie=((Ii=(Ri=oe.data)==null?void 0:Ri.profiles)==null?void 0:Ii.defaultProfile)??null,[he,ve]=p.useState(null),[be,jt]=p.useState(null),At=f6(d==null?void 0:d.profileName,be,u),Re=aG(l?he:At,Z,ie);p.useEffect(()=>{if(!be)return;const $=(d==null?void 0:d.sessionId)===be.sessionId,ee=!l&&u!==be.sessionId;($||ee)&&jt(null)},[d==null?void 0:d.sessionId,l,be,u]);const xt=xe(e.sessions.send.mutationOptions()),we=xe(e.sessions.createAndSend.mutationOptions({onSuccess:$=>{jt({sessionId:$.sessionId,profileName:he}),n.invalidateQueries(e.sessions.list.queryFilter()),t(`/m/session/${$.sessionId}`,{replace:!0})}})),Ie=xe(e.sessions.setProfile.mutationOptions({onSuccess:()=>n.invalidateQueries(e.sessions.list.queryFilter())})),De=xe(e.sessions.cancel.mutationOptions()),Wn=()=>{!u||De.isPending||De.mutate({sessionId:u})},it=xe(e.sessions.rewind.mutationOptions({onSettled:()=>{u&&(n.invalidateQueries(e.sessions.transcript.queryFilter({sessionId:u})),n.invalidateQueries(e.sessions.list.queryFilter()))}})),[qe,Ve]=p.useState(""),[Qt,mt]=p.useState([]),[pe,Oe]=p.useState(!1),[Se,pt]=p.useState(!1),[wt,Ft]=p.useState(null),[st,pr]=p.useState(null),[Dr,ws]=p.useState(null),Dt=p.useRef(""),[ks,fr]=p.useState(!1),[hr,vo]=p.useState(!1),[Ss,Nr]=p.useState(!1),[Cs,yo]=p.useState([]),bo=p.useRef(null),Rn=p.useRef(null);l&&!Rn.current&&(Rn.current=crypto.randomUUID());const Es=l?Rn.current??"":u,Un=yd({isDraft:l,sessionId:u,projectId:s}),jo=p.useRef(void 0);p.useEffect(()=>{if(jo.current!==Un){if(jo.current=Un,!Un)return;const $=Ep(Un);l&&($!=null&&$.draftUploadId)&&(Rn.current=$.draftUploadId),Ve(($==null?void 0:$.text)??"");const ee=(($==null?void 0:$.attachments)??[]).map(me=>({id:zj(),status:"done",progress:100,meta:me,type:me.type}));mt(me=>(me.forEach(Ke=>{Ke.previewUrl&&URL.revokeObjectURL(Ke.previewUrl)}),ee));return}nl(Un,{text:qe,attachments:Qt.filter($=>$.status==="done"&&$.meta).map($=>$.meta),...l&&Rn.current?{draftUploadId:Rn.current}:{}})},[Un,qe,Qt,l]),p.useEffect(()=>{let $=!1;return Qt.filter(ee=>!ee.file&&!ee.previewUrl&&ee.status==="done"&&ee.meta&&(ee.type==="image"||ee.type==="video")).forEach(ee=>{hd(ee.meta.path,"inline").then(me=>{if($){URL.revokeObjectURL(me);return}mt(Ke=>Ke.map(He=>He.id===ee.id?{...He,previewUrl:me}:He))}).catch(()=>{})}),()=>{$=!0}},[Qt]);const _r=$=>{const ee=Array.from($);for(const me of ee){const Ke=zj(),He=gG(me),So=He==="image"||He==="video"?URL.createObjectURL(me):void 0;mt(xr=>[...xr,{id:Ke,file:me,status:"uploading",progress:0,type:He,previewUrl:So}]),mG(me,Es,xr=>mt(Fr=>Fr.map(Mi=>Mi.id===Ke?{...Mi,progress:xr}:Mi))).then(xr=>mt(Fr=>Fr.map(Mi=>Mi.id===Ke?{...Mi,status:"done",progress:100,meta:xr}:Mi))).catch(()=>mt(xr=>xr.map(Fr=>Fr.id===Ke?{...Fr,status:"error"}:Fr)))}},Hn=($,ee)=>{const me=bo.current;me&&(me.accept=$,ee?me.setAttribute("capture",ee):me.removeAttribute("capture"),me.click())},$r=Qt.filter($=>$.status==="done"&&$.meta).map($=>$.meta),bl=Qt.some($=>$.status==="uploading"),E=!!qe.trim(),R=st!=null?T[st]:null,O=!!R&&R.kind==="user"&&R.turnIndex!==void 0,B=()=>{pr(null),Ve(Dt.current),Dt.current=""},K=$=>{const ee=T[$];!ee||ee.kind!=="user"||ee.turnIndex===void 0||v||(Dt.current=qe,W(null),pr($),Ve(ee.text))};p.useEffect(()=>{if(st==null)return;const $=T[st];(!(!!$&&$.kind==="user"&&$.turnIndex!==void 0)||v)&&B()},[T,v,st]);const re=O?{rowIndex:st,...UC(T,st),onCancel:B}:null,ce=wt!=null?T[wt]:null,de=ce&&(ce.kind==="user"||ce.kind==="assistant")?{rowIndex:wt,onCopy:()=>{var $;($=navigator.clipboard)==null||$.writeText(ce.text).catch(()=>{})},...ce.kind==="user"&&ce.turnIndex!==void 0?{onEdit:()=>K(wt),editDisabled:v||it.isPending}:{},onClose:()=>Ft(null)}:null,ne=!O&&!!F&&F===A,fe=O?E&&!it.isPending:ne||!!L?E&&!k.busy:(E||$r.length>0)&&(!!u||l)&&!bl&&!xt.isPending&&!we.isPending,ye=()=>{const $=qe.trim();if(fe){if(O){const ee=R;it.mutate({sessionId:u,turnIndex:ee.turnIndex,text:$}),pr(null),Ve(Dt.current),Dt.current="";return}if(ne){k.rejectPlan(F,$),W(null),Ve("");return}if(L){const ee=D(L.requestId),me=L.questions[Ao(L,ee)];me&&U(L,Wx(ee,me.question,$)),Ve("");return}l?we.mutate({projectId:s??"general",profileName:he??void 0,text:$,draftUploadId:Rn.current??void 0,...$r.length>0?{attachments:$r}:{}}):xt.mutate({sessionId:u,text:$,...$r.length>0?{attachments:$r}:{}}),x6(Un),l&&(Rn.current=null),Ve(""),mt(ee=>(ee.forEach(me=>{me.previewUrl&&URL.revokeObjectURL(me.previewUrl)}),[]))}},Ce=$=>{if(vo(!1),$===Re)return;const ee=Re,me=r==="zh"?`profile 切换 ${ee} → ${$} · 下一 turn 生效`:`profile ${ee} → ${$} · takes effect next turn`;l?(ve($),yo(Ke=>[...Ke,me])):u&&Ie.mutate({sessionId:u,profileName:$},{onSuccess:()=>yo(Ke=>[...Ke,me])})},Xe=(d==null?void 0:d.costUsd)??null,Ue=!l&&C!=null,Ne=I?sG(I.detail.kind,L?Ao(L,D(L.requestId)):0,(L==null?void 0:L.questions.length)??1,r):iG(v,C,P,Xe,Ue),wo={copy:Lt(r,F3),askState:D,onAskPick:Q,onAskToggle:J,onAskConfirmMulti:_,onAskCustom:()=>{},rejectingId:ne?F:null,onApprove:$=>k.approvePlan($.requestId),onRejectStart:$=>W($.requestId),onOpenRead:V},Pi=ne&&z?{title:r==="zh"?`驳回「${z.title}」— 说明原因后发送`:`Rejecting "${z.title}" — explain, then send`,chips:r==="zh"?["范围太大","先做 dry-run","成本超预期","步骤顺序不对"]:["Scope too big","Dry-run first","Over budget","Wrong step order"],onChipTap:$=>Ve(ee=>ee?`${ee}${r==="zh"?";":"; "}${$}`:$),onCancel:()=>W(null)}:void 0,Vn=ne?r==="zh"?"说明驳回原因…":"Reason for rejecting…":L?r==="zh"?`点选项,或直接输入回答 Q${Math.min(Ao(L,D(L.requestId))+1,L.questions.length)}…`:`Tap an option, or type your answer to Q${Math.min(Ao(L,D(L.requestId))+1,L.questions.length)}…`:void 0,In=l?r==="zh"?"新会话":"New session":(d==null?void 0:d.label)??(d==null?void 0:d.name)??a??"",jl=Qt.map($=>{var ee,me;return{id:$.id,name:((ee=$.file)==null?void 0:ee.name)??((me=$.meta)==null?void 0:me.name)??"file",progress:$.progress,status:$.status,type:$.type,previewUrl:$.previewUrl}});return o.jsxs(o.Fragment,{children:[o.jsx("input",{ref:bo,type:"file",multiple:!0,style:{display:"none"},onChange:$=>{$.target.files&&$.target.files.length>0&&_r($.target.files),$.target.value=""}}),o.jsx(nG,{title:In,status:Ne,rows:T,copy:i,onBack:()=>t("/m/sessions"),moreOpen:pe,onMoreToggle:()=>Oe($=>!$),onMoreClose:()=>Oe(!1),sessionIdOpen:Se,onSessionIdOpen:()=>pt(!0),onSessionIdClose:()=>pt(!1),cortexId:(d==null?void 0:d.name)??null,backendUuid:(d==null?void 0:d.backendSessionId)??null,inlineThreadCard:u?o.jsx(hG,{sessionId:u,subthreadsLabel:r==="zh"?"子线程":"sub-threads",openLabel:r==="zh"?"打开":"Open"}):void 0,systemLines:Cs,interactions:wo,rejectBar:Pi,editCopy:Lt(r,fG),msgMenu:de,onLongPress:$=>Ft($),editing:re,onShowOriginal:$=>ws({text:$.originalText}),originalSheet:Dr?{text:Dr.text,onClose:()=>ws(null)}:null,streamKey:u,composerValue:qe,onComposerChange:Ve,onSend:ye,sendEnabled:fe,composerPlaceholder:Vn,onStop:Wn,stopEnabled:!De.isPending,profileChipLabel:lG(Re,Z),onOpenProfile:()=>vo(!0),contextUsage:b,contextUsageSupported:!!(d!=null&&d.contextCompactionSupported),contextUsageLang:r,contextCompactAction:d!=null&&d.contextCompactionSupported?w:void 0,contextUsageOpen:Ss,onContextUsageOpen:()=>Nr(!0),onContextUsageClose:()=>Nr(!1),attachments:jl,onRemoveAttachment:$=>mt(ee=>{const me=ee.find(Ke=>Ke.id===$);return me!=null&&me.previewUrl&&URL.revokeObjectURL(me.previewUrl),ee.filter(Ke=>Ke.id!==$)}),onPlus:()=>fr($=>!$),attachMenuOpen:ks,onAttachClose:()=>fr(!1),onCamera:()=>Hn("image/*","environment"),onLibrary:()=>Hn("image/*,video/*"),onFile:()=>Hn("*/*"),profileSheet:hr?{items:B3(Z,Re),onClose:()=>vo(!1),onPick:Ce}:void 0})]})}const yG={zh:{lang:"zh",pendingPill:"计划待批",approvedStamp:"✓ 计划已批准",rejectedStamp:"已驳回",cancelledStamp:"已取消",expiredStamp:"已过期",approve:"批准并执行",reject:"驳回并反馈",approvedBy:"由你批准",feedbackLabel:"驳回反馈"},en:{lang:"en",pendingPill:"Plan pending",approvedStamp:"✓ Plan approved",rejectedStamp:"Rejected",cancelledStamp:"Cancelled",expiredStamp:"Expired",approve:"Approve & run",reject:"Reject with note",approvedBy:"approved by you",feedbackLabel:"Reject feedback"}};function bG({model:e,copy:t,onBack:n,onApprove:r,onReject:i}){const s=e.status==="pending",[a,l]=p.useState(0),c=p.useRef(null),d=()=>{const g=c.current;if(!g)return;const v=NC(g.scrollTop,g.clientHeight,g.scrollHeight);l(x=>Math.max(x,v))},u=_C(e.status,t.lang),f=FC(a,t.lang),h=e.status==="approved"?{text:`${t.approvedStamp}${e.timeLabel?` · ${e.timeLabel} ${t.approvedBy}`:""}`,fg:m.done,bg:m.doneBg}:e.status==="rejected"?{text:`${t.rejectedStamp}${e.timeLabel?` · ${e.timeLabel}`:""}`,fg:m.grayInk,bg:m.gray}:e.status==="cancelled"?{text:t.cancelledStamp,fg:m.grayInk,bg:m.gray}:{text:t.expiredStamp,fg:m.grayInk,bg:m.gray};return o.jsxs("div",{"data-screen-label":"6b 计划全文阅读页",style:{height:"100%",display:"flex",flexDirection:"column",boxSizing:"border-box",position:"relative",background:m.canvas},children:[o.jsxs("div",{style:{flex:"none",padding:"8px 14px 10px",paddingTop:"calc(8px + env(safe-area-inset-top))",borderBottom:`1px solid ${m.hairline}`,background:m.canvas},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9},children:[o.jsx("button",{type:"button","aria-label":"Back",onClick:n,style:{border:"none",background:"transparent",color:m.run,fontSize:15,lineHeight:1,padding:"0 2px",margin:0,cursor:"pointer",flex:"none",minHeight:44,minWidth:30,display:"flex",alignItems:"center"},children:"‹"}),o.jsxs("div",{style:{minWidth:0},children:[o.jsx("div",{style:{fontSize:15,fontWeight:650,color:m.ink,letterSpacing:"-.01em",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.title}),o.jsx("div",{style:{font:`400 10px ${N}`,color:m.muted,marginTop:1,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:$C(e.filePath,e.lineCount,u,t.lang)})]}),s?o.jsx("span",{style:{marginLeft:"auto",font:`600 9.5px ${N}`,color:m.amberInk,background:m.amberBg,padding:"2px 8px",borderRadius:999,flex:"none"},children:t.pendingPill}):o.jsx("span",{style:{marginLeft:"auto",font:`600 9.5px ${N}`,color:h.fg,background:h.bg,padding:"2px 8px",borderRadius:999,flex:"none"},children:u})]}),s&&o.jsx("div",{style:{height:3,borderRadius:999,background:"var(--proto-line)",overflow:"hidden",marginTop:9},children:o.jsx("div",{style:{width:`${a}%`,height:"100%",background:m.run}})})]}),o.jsxs("div",{style:{flex:1,minHeight:0,position:"relative",background:"var(--proto-card)"},children:[o.jsxs("div",{ref:c,onScroll:d,style:{position:"absolute",inset:0,overflow:"auto",padding:"16px 18px 24px",boxSizing:"border-box"},children:[e.timeLabel&&o.jsx("div",{style:{font:`400 10px ${N}`,color:m.faint,paddingBottom:8},children:e.timeLabel}),o.jsx("div",{style:{fontSize:13,lineHeight:1.7,color:m.body},children:o.jsx(Si,{text:e.planContent})}),e.status==="rejected"&&e.feedback&&o.jsxs("div",{style:{marginTop:16,border:`1px solid ${m.amberBorder}`,background:m.amberCard,borderRadius:11,padding:"10px 13px"},children:[o.jsx("div",{style:{font:`600 10px ${N}`,color:m.amberText,paddingBottom:4},children:t.feedbackLabel}),o.jsx("div",{style:{fontSize:12.5,lineHeight:1.6,color:"var(--proto-amber-fg)",whiteSpace:"pre-wrap"},children:e.feedback})]})]}),o.jsx("div",{style:{position:"absolute",left:0,right:0,bottom:0,height:56,background:"linear-gradient(180deg,rgba(255,255,255,0),var(--proto-card))",pointerEvents:"none"}})]}),o.jsx("div",{style:{flex:"none",background:"var(--proto-card)",borderTop:"1px solid var(--proto-line-2)",padding:"10px 14px",paddingBottom:"calc(14px + env(safe-area-inset-bottom))"},children:s?o.jsxs("div",{style:{display:"flex",gap:8},children:[o.jsxs("button",{type:"button",onClick:r,style:{flex:1.3,height:48,borderRadius:13,background:m.ink,color:"var(--ink-solid-fg)",border:"none",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:1,cursor:"pointer"},children:[o.jsx("span",{style:{fontSize:14,fontWeight:600},children:t.approve}),f]}),o.jsx("button",{type:"button",onClick:i,style:{flex:1,height:48,borderRadius:13,border:"1.5px solid var(--proto-line-3)",background:"var(--proto-card)",color:m.ink,fontSize:14,fontWeight:600,boxSizing:"border-box",cursor:"pointer"},children:t.reject})]}):o.jsx("div",{style:{height:48,borderRadius:13,background:h.bg,color:h.fg,display:"flex",alignItems:"center",justifyContent:"center",fontSize:13.5,fontWeight:600},children:h.text})})]})}function jG(){const{sessionId:e="",requestId:t=""}=gf(),n=ze(),r=le(),i=ut(),s=Lt(i,yG),a=Y({...r.sessions.transcript.queryOptions({sessionId:e}),enabled:!!e});Tf(e,void 0);const l=kv(e),c=zF(a.data,t),d=()=>n(`/m/session/${e}`);if(!c)return o.jsxs("div",{style:{height:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:10,background:m.canvas},children:[o.jsx("div",{style:{font:`400 11px ${N}`,color:m.faint},children:a.isPending?"…":i==="zh"?"未找到该计划":"Plan not found"}),o.jsx("button",{type:"button",onClick:d,style:{border:`1px solid ${m.hairline}`,background:"var(--proto-card)",borderRadius:999,padding:"7px 16px",fontSize:12.5,fontWeight:600,color:m.ink,cursor:"pointer"},children:i==="zh"?"返回会话":"Back to chat"})]});const u=ov(c.detail,c.ts);return o.jsx(bG,{model:u,copy:s,onBack:d,onApprove:()=>{u.status==="pending"&&l.approvePlan(u.requestId)},onReject:()=>n(`/m/session/${e}`,{state:{rejectPlan:t}})})}function wG(e,t){const n=typeof t=="number"&&t>0,r=typeof e=="number"?e:0;return{numerator:zc(typeof e=="number"?e:null),denominator:n?zc(t):"—",pct:n?Math.max(0,Math.min(100,r/t*100)):0}}function kG(e){return e==="running"||e==="waiting"}function SG(e,t){var n;if(t&&t.steps.length>0)return t.steps.map((r,i)=>({label:r.stage??`#${i+1}`,state:r.status==="completed"?"done":r.status==="running"?"active":"pending"}));if(e.totalSteps>0){const r=((n=e.currentStep)==null?void 0:n.index)??-1;return Array.from({length:e.totalSteps},(i,s)=>{var a;return{label:s===r&&((a=e.currentStep)!=null&&a.name)?e.currentStep.name:`#${s+1}`,state:s<r?"done":s===r?"active":"pending"}})}return[]}function CG(e,t,n,r){const i=[e.id];if(e.taskId&&i.push(`task ${e.taskId}`),i.push(X6(e.createdAt,n)),t){i.push(js(t.totalCostUsd));const s=t.children.length;s>0&&i.push(`${s} ${r}`)}return i.join(" · ")}function EG(e,t){switch(e){case"running":return{tone:"running",label:t.running};case"waiting":return{tone:"waiting",label:t.waiting};case"completed":return{tone:"done",label:t.done};case"failed":case"aborted":return{tone:"failed",label:t.failed};case"cancelled":return{tone:"cancelled",label:t.cancelled};default:return{tone:o3(e),label:t.running}}}function TG({color:e}){return o.jsxs("svg",{width:13,height:13,viewBox:"0 0 14 14",fill:"none",stroke:e,strokeWidth:1.6,style:{flex:"none"},children:[o.jsx("circle",{cx:"3.5",cy:"3",r:"1.9"}),o.jsx("circle",{cx:"3.5",cy:"11",r:"1.9"}),o.jsx("circle",{cx:"10.5",cy:"7",r:"1.9"}),o.jsx("path",{d:"M3.5 5v4M5.4 3.7 8.7 6.1M5.4 10.3 8.7 7.9"})]})}function PG({copy:e,qn:t,band:n}){return o.jsx(Rf,{title:e.title,qn:t,below:o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:9},children:[o.jsx("span",{style:{fontSize:10,fontWeight:600,color:m.muted},children:e.today}),o.jsx("div",{style:{flex:1,height:4,borderRadius:999,background:"var(--proto-line)",overflow:"hidden"},children:o.jsx("div",{style:{width:`${n.pct}%`,height:"100%",background:m.run}})}),o.jsxs("span",{style:{font:`500 10px ${N}`,color:m.ink},children:[n.numerator," / ",n.denominator]})]})})}function RG({groups:e,copy:t,renderThread:n}){return o.jsx(o.Fragment,{children:e.map((r,i)=>o.jsxs("section",{style:{display:"flex",flexDirection:"column",gap:9},children:[o.jsxs(jd,{style:{padding:i===0?"0 2px 2px":"6px 2px 2px"},children:[t[r.kind]," · ",r.threads.length]}),r.threads.map(n)]},r.kind))})}function IG({state:e}){return e==="done"?o.jsx("span",{style:{width:14,height:14,borderRadius:"50%",background:m.doneBg,color:m.done,display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:8,fontWeight:700,flex:"none"},children:"✓"}):e==="active"?o.jsx("span",{style:{width:14,height:14,borderRadius:"50%",background:m.run,boxShadow:`0 0 0 3px ${m.runBg}`,animation:"cxpulse 1.6s ease-in-out infinite",flex:"none"}}):o.jsx("span",{style:{width:14,height:14,borderRadius:"50%",border:"1.5px solid var(--proto-line-3)",boxSizing:"border-box",flex:"none"}})}const Bj=4;function MG({step:e}){const t=e.state==="active"?m.ink:e.state==="done"?m.sub:m.faint;return o.jsx("span",{title:e.label,style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:10.5,color:t,fontWeight:e.state==="active"?600:400},children:e.label})}function LG({step:e,connected:t}){return o.jsxs("div",{style:{display:"flex",alignItems:"center",minWidth:0,overflow:"hidden"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,minWidth:0,flex:"0 1 auto"},children:[o.jsx(IG,{state:e.state}),o.jsx(MG,{step:e})]}),t&&o.jsx("div",{style:{flex:1,minWidth:2,height:1.5,margin:"0 6px",background:e.state==="done"?"var(--proto-success-bg)":m.hairline}})]})}function OG({steps:e}){const t=Math.min(Bj,e.length);return o.jsx("div",{style:{display:"grid",gridTemplateColumns:`repeat(${t}, minmax(0, 1fr))`,rowGap:8,padding:"10px 0 4px"},children:e.map((n,r)=>o.jsx(LG,{step:n,connected:r<e.length-1&&(r+1)%Bj!==0},r))})}function W3({info:e,detail:t,now:n,copy:r,onOpen:i}){const s=SG(e,t),a=EG(e.status,r),l=e.status==="running"?m.run:e.status==="waiting"?m.amber:m.muted;return o.jsxs($e,{onClick:i,children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[o.jsx(TG,{color:l}),o.jsx("span",{style:{font:`600 12.5px ${N}`,color:m.ink},children:e.templateName}),o.jsx("span",{style:{marginLeft:"auto"},children:o.jsx(en,{tone:a.tone,children:a.label})})]}),s.length>0&&o.jsx(OG,{steps:s}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:4},children:[o.jsx("span",{style:{font:`400 10px ${N}`,color:"var(--proto-muted-3)"},children:CG(e,t,n,r.subthread)}),o.jsxs("span",{style:{marginLeft:"auto",fontSize:11.5,fontWeight:600,color:m.run},children:[r.open," ›"]})]})]})}const AG={en:{title:"Threads",active:"Active",history:"History",today:"Today",open:"Open",subthread:"subthreads",empty:"No threads",running:"Running",waiting:"Waiting",done:"Done",failed:"Failed",cancelled:"Cancelled"},zh:{title:"线程",active:"活跃",history:"历史",today:"今日",open:"打开",subthread:"子线程",empty:"暂无线程",running:"运行中",waiting:"等待中",done:"已完成",failed:"失败",cancelled:"已取消"}};function DG({info:e,now:t,copy:n,onOpen:r}){const i=le();ml(e.id);const s=Y(i.threads.get.queryOptions({threadId:e.id}));return o.jsx(W3,{info:e,detail:s.data,now:t,copy:n,onOpen:r})}function NG(){var h,g;const e=le(),t=ze(),n=ut(),r=Lt(n,AG),{currentProjectId:i}=Bn(),s=M3(!0);Ev();const a=i??void 0,l=Y(e.threads.list.queryOptions({projectId:a})),c=Y(e.cost.summary.queryOptions({projectId:a})),d=I3(l.data??[]),u=p.useMemo(()=>{var v,x;return wG((v=c.data)==null?void 0:v.today,(x=c.data)==null?void 0:x.dailyBudget)},[(h=c.data)==null?void 0:h.today,(g=c.data)==null?void 0:g.dailyBudget]),f=i?vl(i):void 0;return o.jsx(gt,{label:"1c 线程",header:o.jsx(PG,{copy:r,qn:f,band:u}),children:o.jsxs(gn,{children:[l.isSuccess&&d.length===0&&o.jsx("div",{style:{padding:"40px 0",textAlign:"center",color:m.faint,fontSize:13},children:r.empty}),o.jsx(RG,{groups:d,copy:r,renderThread:v=>{const x=()=>t(`/m/thread/${v.id}`);return kG(v.status)?o.jsx(DG,{info:v,now:s,copy:r,onOpen:x},v.id):o.jsx(W3,{info:v,detail:void 0,now:s,copy:r,onOpen:x},v.id)}})]})})}function _G(e,t){return Lf(e,t).length>0}const $G=[{kind:"done",matches:e=>e.status==="done"},{kind:"blocked",matches:e=>e.blockedBy!=null},{kind:"in-progress",matches:e=>e.claimedBy!=null},{kind:"approval-needed",matches:e=>e.approvalNeeded===!0},{kind:"waiting-deps",matches:(e,t)=>t},{kind:"actionable",matches:e=>e.actionable}];function FG(e,t){var n;return((n=$G.find(r=>r.matches(e,t)))==null?void 0:n.kind)??"waiting-deps"}const zG={"in-progress":"inProgress",actionable:"actionable","approval-needed":"approvalNeeded","waiting-deps":"waitingDeps",blocked:"blocked",done:"done"};function BG(e){const t=new Map(e.map(r=>[r.id,r.status])),n={inProgress:[],actionable:[],approvalNeeded:[],waitingDeps:[],blocked:[],done:[]};for(const r of e){const i=FG(r,_G(r,t));n[zG[i]].push(r)}return n}const WG={"in-progress":"inProgress",actionable:"actionable","approval-needed":"approvalNeeded","waiting-deps":"waiting",blocked:"blocked",done:"done"},U3={flex:1,minWidth:0,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"};function yl({task:e,textColor:t=m.body}){return o.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:6,minWidth:0,flex:1},children:[o.jsx("span",{style:{font:`500 10px ${N}`,color:m.muted,flex:"none"},children:e.id}),o.jsx("span",{style:{fontSize:12.5,color:t,lineHeight:1.45,...U3},title:e.text,children:e.text})]})}function Pv({text:e,color:t,dot:n,onClick:r,singleLine:i=!1}){return o.jsxs("div",{onClick:r,style:{display:"flex",alignItems:"center",gap:5,marginTop:5,minWidth:0,cursor:r?"pointer":"default"},children:[n&&o.jsx("span",{style:{width:5,height:5,borderRadius:"50%",background:n,flex:"none"}}),o.jsx("span",{"data-task-blocker":i?"true":void 0,style:{font:`400 9.5px ${N}`,color:t,...i?U3:{}},children:e})]})}function UG({task:e,copy:t,onOpenTask:n,onOpenThread:r}){const i=bd(e),s=i,a=l=>{l.stopPropagation(),s&&r(s)};return o.jsxs($e,{radius:11,padding:"10px 13px",onClick:()=>n(e.id),children:[o.jsx(yl,{task:e}),o.jsx("div",{style:{display:"flex",alignItems:"center",gap:7,marginTop:5},children:o.jsxs("span",{onClick:a,style:{font:`500 9.5px ${N}`,color:m.run,background:m.runBg,padding:"2px 7px",borderRadius:999,cursor:s?"pointer":"default"},children:[t.claim,i?` · ${i}`:"",s?" ›":""]})})]})}function HG({task:e,copy:t,expanded:n,onToggle:r,onOpenTask:i}){return o.jsxs($e,{radius:11,padding:"10px 13px",onClick:()=>i(e.id),children:[o.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:6,minWidth:0},children:[o.jsx(yl,{task:e}),o.jsx("span",{role:"button","aria-label":"Toggle done-when","aria-expanded":n,onClick:s=>{s.stopPropagation(),r(e.id)},style:{marginLeft:"auto",color:m.faint,fontSize:8.5,flex:"none",cursor:"pointer",padding:"2px 2px 2px 8px"},children:n?"▾":"▸"})]}),n&&o.jsxs("div",{style:{marginTop:7,padding:"8px 10px",background:"var(--proto-alt)",borderRadius:8,font:`400 10px/1.6 ${N}`,color:m.sub},children:[t.doneWhen,": ",e.doneWhen??t.doneWhenGap]})]})}function VG({task:e,copy:t,onOpenTask:n,onOpenApprovals:r}){const i=s=>{s.stopPropagation(),r()};return o.jsxs($e,{radius:11,padding:"10px 13px",onClick:()=>n(e.id),children:[o.jsx(yl,{task:e}),o.jsx(Pv,{text:`${t.approvalNeeded} · ${t.openApprovals}`,color:m.amberText,dot:m.amber,onClick:i})]})}function qG({task:e,copy:t,onOpenTask:n}){const r=Lf(e),i=r.length>0?`${t.needs} ${r.join(", ")}`:t.waiting;return o.jsxs($e,{radius:11,padding:"10px 13px",onClick:()=>n(e.id),style:{opacity:.8},children:[o.jsx(yl,{task:e,textColor:m.sub}),o.jsx(Pv,{text:i,color:m.muted})]})}function KG({task:e,copy:t,onOpenTask:n}){const r=e.blockedBy?`${t.blocked} · ${e.blockedBy}`:t.blocked;return o.jsxs($e,{radius:11,padding:"10px 13px",onClick:()=>n(e.id),style:{opacity:.75},children:[o.jsx(yl,{task:e,textColor:m.sub}),o.jsx(Pv,{text:r,color:m.amberText,dot:m.amber,singleLine:!0})]})}function QG({task:e,onOpenTask:t}){return o.jsx($e,{radius:11,padding:"10px 13px",onClick:()=>t(e.id),style:{opacity:.7},children:o.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:6,minWidth:0},children:[o.jsx("span",{style:{width:5,height:5,borderRadius:"50%",background:m.done,flex:"none"}}),o.jsx(yl,{task:e,textColor:m.sub})]})})}const YG={"in-progress":UG,actionable:HG,"approval-needed":VG,"waiting-deps":qG,blocked:KG,done:QG};function GG({groups:e,scope:t,copy:n,expandedIds:r,onToggleExpand:i,onOpenTask:s,onOpenThread:a,onOpenApprovals:l}){return o.jsx(gt,{label:"1d 任务",header:o.jsx(Rf,{title:n.title,qn:t}),children:o.jsxs(gn,{gap:6,children:[e.length===0&&o.jsx("div",{style:{padding:"40px 0",textAlign:"center",color:m.faint,fontSize:13},children:n.empty}),e.map((c,d)=>{const u=YG[c.key];return o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[o.jsxs(jd,{style:{padding:d===0?"0 2px 2px":"6px 2px 2px"},children:[n[WG[c.key]]," · ",c.tasks.length]}),c.tasks.map(f=>o.jsx(u,{task:f,copy:n,expanded:r.has(f.id),onToggle:i,onOpenTask:s,onOpenThread:a,onOpenApprovals:l},f.id))]},c.key)})]})})}function XG(e){return[{key:"in-progress",tasks:e.inProgress},{key:"actionable",tasks:e.actionable},{key:"approval-needed",tasks:e.approvalNeeded},{key:"waiting-deps",tasks:e.waitingDeps},{key:"blocked",tasks:e.blocked},{key:"done",tasks:e.done}].filter(n=>n.tasks.length>0)}const JG={en:{title:"Tasks",inProgress:"In progress",actionable:"Actionable",approvalNeeded:"Approval needed",waiting:"Waiting",blocked:"Blocked",claim:"claimed",needs:"needs",doneWhen:"done-when",doneWhenGap:"no done-when recorded",openApprovals:"open approvals",done:"Done",empty:"No tasks"},zh:{title:"任务",inProgress:"进行中",actionable:"可执行",approvalNeeded:"需要审批",waiting:"等待",blocked:"阻塞",claim:"认领",needs:"依赖",doneWhen:"done-when",doneWhenGap:"done-when 未记录",openApprovals:"打开审批",done:"完成",empty:"暂无任务"}};function ZG(){const[e,t]=p.useState(()=>new Set);return{expandedIds:e,toggle:r=>t(i=>{const s=new Set(i);return s.has(r)?s.delete(r):s.add(r),s})}}function eX(e){const t=le();Sv();const n=Y(t.tasks.list.queryOptions({projectId:e??void 0})),r=n.data??[],i=p.useMemo(()=>XG(BG(r)),[r]);return{query:n,groups:i}}function tX(){const e=ze(),t=Lt(ut(),JG),{currentProjectId:n}=Bn(),{query:r,groups:i}=eX(n),s=ZG(),a=n?vl(n):void 0;return r.isLoading?o.jsx(gt,{label:"1d 任务",children:o.jsx("div",{style:{padding:16,color:m.muted,fontSize:13},children:t.empty})}):o.jsx(GG,{groups:i,scope:a,copy:t,expandedIds:s.expandedIds,onToggleExpand:s.toggle,onOpenTask:l=>e(`/m/task/${l}`),onOpenThread:l=>e(`/m/thread/${l}`),onOpenApprovals:()=>e("/m/approvals")})}function nX({copy:e,busy:t,onAdd:n}){const[r,i]=p.useState(""),s=async a=>{a.preventDefault(),a.stopPropagation();const l=r.trim();!l||t||(await n(l),i(""))};return o.jsxs("form",{onSubmit:s,onClick:a=>a.stopPropagation(),style:{display:"flex",alignItems:"center",gap:8,marginTop:9,border:`1px solid ${m.divider}`,borderRadius:9,padding:"6px 10px"},children:[o.jsx("svg",{width:"10",height:"10",viewBox:"0 0 14 14",fill:"none",stroke:m.muted,strokeWidth:"1.6",children:o.jsx("path",{d:"M9.8 1.8l2.4 2.4L4.6 11.8l-3 .6.6-3z"})}),o.jsx("input",{value:r,onChange:a=>i(a.target.value),placeholder:e.quickPlaceholder,"aria-label":e.quickPlaceholder,style:{flex:1,minWidth:0,border:0,outline:0,background:"transparent",fontSize:11,color:m.ink}})]})}function rX({vm:e,copy:t,busy:n,onOpen:r,onAdd:i}){return o.jsx("div",{"data-mobile-notes-card":"",children:o.jsxs($e,{tone:"blue",radius:14,padding:"12px 14px",onClick:r,style:{cursor:"pointer"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[o.jsx("span",{style:{fontSize:13.5,fontWeight:650,color:m.ink},children:t.title}),o.jsx("span",{style:{font:`600 10px ${N}`,color:m.sub,background:"var(--proto-line-2)",padding:"2px 8px",borderRadius:999},children:e.activeCount}),o.jsx("span",{style:{marginLeft:"auto",fontSize:13,color:m.faint},children:"›"})]}),e.previews.map(s=>o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,marginTop:5},children:[o.jsx("span",{style:{width:13,height:13,borderRadius:"50%",border:`1.5px solid ${m.hairline}`,boxSizing:"border-box",flex:"none"}}),o.jsx("span",{style:{fontSize:12,lineHeight:1.55,color:m.sub,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:s.text})]},s.id)),o.jsx(nX,{copy:t,busy:n,onAdd:i})]})})}function oX({label:e,onClick:t}){return o.jsx("button",{type:"button","aria-label":e,onClick:t,style:{display:"flex",alignItems:"center",justifyContent:"center",width:30,height:30,border:"none",background:"transparent",color:m.sub,cursor:"pointer",padding:0},children:o.jsxs("svg",{width:"19",height:"19",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[o.jsx("circle",{cx:"12",cy:"12",r:"3.2"}),o.jsx("path",{d:"M19.4 15a1.7 1.7 0 0 0 .34 1.87l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.7 1.7 0 0 0-1.87-.34 1.7 1.7 0 0 0-1 1.55V21a2 2 0 1 1-4 0v-.09a1.7 1.7 0 0 0-1-1.55 1.7 1.7 0 0 0-1.87.34l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06a1.7 1.7 0 0 0 .34-1.87 1.7 1.7 0 0 0-1.55-1H3a2 2 0 1 1 0-4h.09a1.7 1.7 0 0 0 1.55-1 1.7 1.7 0 0 0-.34-1.87l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06a1.7 1.7 0 0 0 1.87.34h.09a1.7 1.7 0 0 0 1-1.55V3a2 2 0 1 1 4 0v.09a1.7 1.7 0 0 0 1 1.55 1.7 1.7 0 0 0 1.87-.34l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06a1.7 1.7 0 0 0-.34 1.87v.09a1.7 1.7 0 0 0 1.55 1H21a2 2 0 1 1 0 4h-.09a1.7 1.7 0 0 0-1.55 1z"})]})})}function iX({current:e,copy:t}){const n=e.cost,r=n?O3(n.today,n.dailyBudget):null;return o.jsxs($e,{tone:"blue",radius:14,padding:"13px 14px",style:{boxShadow:"0 1px 3px rgba(70,85,212,.08)"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[o.jsx("div",{style:{width:36,height:36,borderRadius:9,background:m.runBg,color:m.run,display:"flex",alignItems:"center",justifyContent:"center",font:`600 12px ${N}`,flex:"none"},children:e.initials}),o.jsxs("div",{style:{minWidth:0,flex:1},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[o.jsx("span",{style:{fontSize:15,fontWeight:650,color:m.ink},children:e.id}),o.jsx("span",{style:{fontSize:9,fontWeight:700,padding:"1.5px 7px",borderRadius:999,background:m.runBg,color:m.run,flex:"none"},children:t.current})]}),o.jsxs("div",{style:{font:`400 10px ${N}`,color:m.muted,marginTop:2},children:[e.runningThreads," ",t.threadsRunning," · ",e.needsYou," ",t.needsYou]})]})]}),n&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginTop:12},children:[o.jsx("span",{style:{font:`600 20px ${N}`,color:m.ink,letterSpacing:"-.02em"},children:Ht(n.today)}),o.jsx("div",{style:{flex:1,height:6,borderRadius:999,background:"var(--proto-line-2)",overflow:"hidden"},children:o.jsx("div",{style:{width:`${r??0}%`,height:"100%",background:m.run}})}),o.jsxs("span",{style:{font:`400 10px ${N}`,color:m.faint},children:["/ ",Ht(n.dailyBudget)," ",t.perDay]})]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:14,marginTop:7,font:`400 10px ${N}`,color:m.faint},children:[o.jsxs("span",{children:[t.week," ",o.jsx("b",{style:{color:m.body},children:Ht(n.week)})]}),o.jsxs("span",{children:[t.month," ",o.jsx("b",{style:{color:m.body},children:Ht(n.month)})]}),o.jsxs("span",{style:{marginLeft:"auto",color:"var(--proto-amber-text)"},children:[t.forecastToday," ",Ht(n.forecastToday)]})]})]})]})}function sX({pending:e,globalPending:t,waitingThreads:n,copy:r,onClick:i}){return o.jsxs("div",{onClick:i,style:{display:"flex",alignItems:"center",gap:8,border:`1px solid ${m.amberBorder}`,background:m.amberCard,borderRadius:13,padding:"12px 13px",cursor:"pointer"},children:[o.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:m.amber,flex:"none"}}),o.jsxs("span",{style:{fontSize:13,fontWeight:600,color:"var(--proto-amber-fg)"},children:[r.approvals," · ",e," ",r.pending]}),o.jsxs("span",{style:{font:`400 9.5px ${N}`,color:"var(--proto-amber-accent)"},children:[t>0?`${t} ${r.globalPending} · `:"",n," ",r.threadsWaiting]}),o.jsxs("span",{style:{marginLeft:"auto",fontSize:11.5,fontWeight:600,color:m.amberInk},children:[r.handle," ›"]})]})}function aX({issues:e,copy:t,onClick:n}){const r=e.count-e.previews.length;return o.jsxs($e,{radius:14,padding:"12px 14px",onClick:n,style:{cursor:"pointer"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[o.jsx("span",{style:{fontSize:13.5,fontWeight:650,color:m.ink},children:t.issuesTitle}),o.jsx("span",{style:{font:`600 10px ${N}`,color:m.sub,background:"var(--proto-line-2)",padding:"2px 8px",borderRadius:999},children:e.count}),o.jsx("span",{style:{marginLeft:"auto",fontSize:13,color:m.faint},children:"›"})]}),e.previews.map(i=>o.jsx("div",{style:{fontSize:12,lineHeight:1.55,color:m.sub,marginTop:4,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:i},i)),r>0&&o.jsxs("div",{style:{font:`400 10px ${N}`,color:m.faint,marginTop:7},children:["+ ",r," more"]})]})}function lX({label:e,onClick:t,divider:n}){return o.jsxs("div",{onClick:t,style:{display:"flex",alignItems:"center",gap:9,padding:"11px 13px",borderBottom:n?`1px solid ${m.divider}`:void 0,cursor:"pointer"},children:[o.jsx("span",{style:{fontSize:13,color:m.sub,flex:"none"},children:e}),o.jsx("span",{style:{marginLeft:"auto",fontSize:13,color:m.faint,flex:"none"},children:"›"})]})}function cX({label:e}){return o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"4px 2px 0"},children:[o.jsx("div",{style:{flex:1,height:1,background:"var(--proto-line)"}}),o.jsx("div",{style:{fontSize:9.5,fontWeight:600,letterSpacing:".06em",color:m.faint},children:e}),o.jsx("div",{style:{flex:1,height:1,background:"var(--proto-line)"}})]})}function dX({row:e,copy:t,onSwitch:n,divider:r}){const i=e.todayCost!=null?`${t.today} ${Ht(e.todayCost)}`:null;return o.jsxs("div",{onClick:()=>n(e.id),style:{display:"flex",alignItems:"center",gap:10,padding:"12px 13px",borderBottom:r?`1px solid ${m.divider}`:void 0,cursor:"pointer"},children:[o.jsx("div",{style:{width:34,height:34,borderRadius:9,background:m.gray,color:m.sub,display:"flex",alignItems:"center",justifyContent:"center",font:`600 12px ${N}`,flex:"none"},children:e.initials}),o.jsxs("div",{style:{minWidth:0,flex:1},children:[o.jsx("div",{style:{fontSize:14,fontWeight:600,color:m.ink},children:e.id}),o.jsx("div",{style:{display:"flex",alignItems:"center",gap:5,font:`400 10px ${N}`,color:m.muted,marginTop:2},children:e.running>0?o.jsxs(o.Fragment,{children:[o.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:m.run,flex:"none"}}),o.jsxs("span",{children:[e.running," ",t.running,i?` · ${i}`:""]})]}):o.jsxs("span",{children:[t.idle,i?` · ${i}`:""]})})]}),e.badgeCount>0&&o.jsx("span",{"aria-label":"project attention",style:{minWidth:18,height:18,padding:"0 6px",borderRadius:999,background:e.badgeTone==="action"?m.amber:m.run,color:"var(--ink-solid-fg)",font:`600 10px ${N}`,display:"flex",alignItems:"center",justifyContent:"center",flex:"none"},children:e.badgeCount}),o.jsx("span",{style:{fontSize:13,color:m.faint,flex:"none"},children:"›"})]})}function uX({props:e}){const{copy:t,current:n,pendingApprovals:r,globalPendingApprovals:i,issues:s}=e;return o.jsxs(o.Fragment,{children:[n&&o.jsx(iX,{current:n,copy:t}),r>0&&o.jsx(sX,{pending:r,globalPending:i,waitingThreads:(n==null?void 0:n.waitingThreads)??0,copy:t,onClick:e.onApprovals}),s.count>0&&o.jsx(aX,{issues:s,copy:t,onClick:e.onIssues}),o.jsx(rX,{vm:e.notesVm,copy:e.notesCopy,busy:e.notesBusy,onOpen:e.onNotes,onAdd:e.onAddNote}),o.jsx($e,{radius:13,padding:0,style:{overflow:"hidden"},children:o.jsx(lX,{label:t.memory,onClick:e.onMemory,divider:!1})})]})}function pX({props:e}){return e.switchRows.length===0?null:o.jsxs(o.Fragment,{children:[o.jsx(cX,{label:e.copy.switchProject}),o.jsx($e,{radius:13,padding:0,style:{overflow:"hidden"},children:e.switchRows.map((t,n)=>o.jsx(dX,{row:t,copy:e.copy,onSwitch:e.onSwitch,divider:n<e.switchRows.length-1},t.id))})]})}const fX={display:"flex",alignItems:"center",gap:9,background:"var(--proto-card)",border:`1.5px dashed ${m.runBorder}`,borderRadius:13,padding:13,cursor:"pointer"};function hX({copy:e,onClick:t}){return o.jsxs("div",{onClick:t,style:fX,children:[o.jsx("span",{style:{fontSize:15,color:m.run,fontWeight:400},children:"+"}),o.jsx("span",{style:{fontSize:13.5,fontWeight:600,color:m.run},children:e.newProject})]})}function gX(e){const t=o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,minWidth:0},children:[o.jsx(vV,{status:e.rateLimitStatus,onOpen:e.onOpenRateLimit}),o.jsx(oX,{label:e.copy.settings,onClick:e.onSettings})]});return o.jsx(gt,{label:"1e 项目",header:o.jsx(Rf,{title:e.copy.title,trailing:t}),children:o.jsxs(gn,{gap:10,children:[o.jsx(uX,{props:e}),o.jsx(pX,{props:e}),o.jsx(hX,{copy:e.copy,onClick:e.onNewProject})]})})}const H3=new Set(["running","waiting"]);function xX(e,t){let n=0,r=0;if(!t)return{running:n,waiting:r};for(const i of e)i.projectId===t&&(H3.has(i.status)&&n++,i.status==="waiting"&&r++);return{running:n,waiting:r}}function mX(e){return e.reduce((t,n)=>t+(n.online?1:0),0)}function vX(e){const t={byProject:{},global:0,total:0};for(const n of e)n.status==="pending"&&(t.total++,n.projectId==null?t.global++:t.byProject[n.projectId]=(t.byProject[n.projectId]??0)+1);return t}function yX(e,t,n,r,i={},s={},a={},l={}){const c=e.filter(d=>d.id!==t);return Z6(c,s).map(d=>{const u=n.reduce((x,b)=>x+(b.projectId===d.id&&H3.has(b.status)?1:0),0),f=r==null?void 0:r[d.id],h=i[d.id]??0,g=(a[d.id]??0)+(l[d.id]??0),v=G6(h,g);return{id:d.id,initials:vl(d.id),running:u,todayCost:f?f.today:null,unread:h,actionRequired:g,badgeCount:v.count,badgeTone:v.tone}})}function V3(e){return e.trim().length>0}function bX({name:e,onNameChange:t,onCreate:n,onClose:r,copy:i,behind:s}){const a=V3(e);return o.jsxs(Ti,{onClose:r,behind:s,children:[o.jsxs("div",{style:{display:"flex",alignItems:"baseline",padding:"0 2px 12px"},children:[o.jsx("span",{style:{fontSize:17,fontWeight:700,color:m.ink,letterSpacing:"-.01em"},children:i.title}),o.jsx("span",{style:{marginLeft:"auto",font:`400 9.5px ${N}`,color:m.faint},children:i.tag})]}),o.jsx("input",{value:e,onChange:l=>t(l.target.value),onKeyDown:l=>{l.key==="Enter"&&a&&n()},placeholder:i.placeholder,autoFocus:!0,style:{width:"100%",height:48,border:"1.5px solid var(--proto-line-3)",borderRadius:13,background:"var(--proto-card)",padding:"0 14px",font:`400 13.5px ${N}`,color:m.ink,boxSizing:"border-box",outline:"none"}}),o.jsx("button",{type:"button",onClick:n,disabled:!a,style:{width:"100%",height:48,border:"none",borderRadius:13,background:m.ink,color:"var(--ink-solid-fg)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:14,fontWeight:600,marginTop:12,opacity:a?1:.45,cursor:a?"pointer":"default"},children:i.create})]})}function q3(e,t,n){const r=H6(e,t,n);return{...r,previews:r.active.slice(0,2)}}const jX={en:{title:"Projects",current:"Current",threadsRunning:"running",needsYou:"need you",perDay:"day",week:"Week",month:"Month",forecastToday:"Forecast",approvals:"Approvals",pending:"pending",globalPending:"global",threadsWaiting:"threads paused",handle:"Review",memory:"Project memory",settings:"Settings",switchProject:"SWITCH PROJECT",running:"running",today:"today",idle:"idle",newProject:"New project",issuesTitle:"Issues"},zh:{title:"项目",current:"当前",threadsRunning:"线程运行中",needsYou:"需要你",perDay:"日",week:"本周",month:"本月",forecastToday:"预测今日",approvals:"审批",pending:"待处理",globalPending:"全局",threadsWaiting:"线程暂停等待",handle:"处理",memory:"项目记忆",settings:"设置",switchProject:"切换项目",running:"运行中",today:"今日",idle:"空闲",newProject:"新建项目",issuesTitle:"Issues"}};function wX(e,t){const n=le(),r=je(),i=Y({...n.notes.list.queryOptions({projectId:e}),enabled:!!e}),s=xe(n.notes.add.mutationOptions({onSettled:()=>r.invalidateQueries(n.notes.list.queryFilter({projectId:e}))}));return{vm:q3(i.data??[],Date.now(),t),copy:vv[t],busy:s.isPending,add:a=>s.mutateAsync({projectId:e,text:a})}}const kX={en:{title:"New project",tag:"projects/",placeholder:"Project name, e.g. rl-locomotion",create:"Create and start a chat"},zh:{title:"新建项目",tag:"projects/",placeholder:"项目名字,如 rl-locomotion",create:"创建并开始对话"}};function SX(e){const t=le();return{projects:Y(t.projects.list.queryOptions({})).data??[],sessions:Y(t.sessions.list.queryOptions({origin:"direct"})).data??[],scopedCost:Y({...t.cost.summary.queryOptions({projectId:e||void 0}),enabled:!!e}).data??null,globalCost:Y(t.cost.summary.queryOptions({})).data,threads:Y(t.threads.list.queryOptions({})).data??[],approvals:Y(t.approvals.list.queryOptions({status:"pending"})).data??[],issues:Y({...t.issues.list.queryOptions({projectId:e}),enabled:!!e}).data??[]}}function CX(e,t,n){return p.useMemo(()=>{if(!e)return null;const r=xX(t.threads,e);return{id:e,initials:vl(e),runningThreads:r.running,waitingThreads:r.waiting,needsYou:n,cost:t.scopedCost}},[e,t.threads,n,t.scopedCost])}function EX(e,t,n){const r=p.useMemo(()=>Q6(t.sessions),[t.sessions]),i=p.useMemo(()=>Y6(t.sessions),[t.sessions]),s=p.useMemo(()=>J6(t.sessions),[t.sessions]);return p.useMemo(()=>{var a;return yX(t.projects,e,t.threads,(a=t.globalCost)==null?void 0:a.byProject,r,s,i,n)},[t.projects,e,t.threads,t.globalCost,r,s,i,n])}function TX(e,t){const n=le(),r=je(),[i,s]=p.useState(!1),[a,l]=p.useState(""),c=xe(n.projects.create.mutationOptions({onSuccess:()=>{r.invalidateQueries(n.projects.list.queryFilter()),s(!1),t("/m/session/new")}}));return{open:i,name:a,setName:l,submit:()=>{!V3(a)||c.isPending||c.mutate({name:a.trim()})},close:()=>s(!1),show:()=>{l(""),s(!0)},copy:Lt(e,kX)}}function PX({rate:e,rateOpen:t,closeRate:n,project:r}){return o.jsxs(o.Fragment,{children:[t&&e&&o.jsx(bV,{status:e,onClose:n}),r.open&&o.jsx(bX,{name:r.name,onNameChange:r.setName,onCreate:r.submit,onClose:r.close,copy:r.copy})]})}function RX(){const e=ze(),t=ut(),{currentProjectId:n,setCurrentProject:r}=Bn(),i=n??"";yv(),Ev();const s=SX(i),a=wX(i,t),l=p.useMemo(()=>vX(s.approvals),[s.approvals]),c=i?l.byProject[i]??0:0,d=CX(i,s,c),u=EX(i,s,l.byProject),f=n3(),[h,g]=p.useState(!1);p.useEffect(()=>{f||g(!1)},[f]);const v=TX(t,e),x=p.useMemo(()=>({count:s.issues.length,previews:s.issues.slice(0,2).map(y=>y.title)}),[s.issues]),b=y=>{r(y),e("/m/sessions")},j={copy:Lt(t,jX),current:d,pendingApprovals:c+l.global,globalPendingApprovals:l.global,issues:x,notesVm:a.vm,notesCopy:a.copy,notesBusy:a.busy,switchRows:u,rateLimitStatus:f,onOpenRateLimit:()=>g(!0),onIssues:()=>e("/m/issues"),onNotes:()=>e("/m/notes"),onAddNote:a.add,onApprovals:()=>e("/m/approvals"),onMemory:()=>e("/m/memory"),onSettings:()=>e("/m/settings"),onSwitch:b,onNewProject:v.show};return o.jsxs(o.Fragment,{children:[o.jsx(gX,{...j}),o.jsx(PX,{rate:f,rateOpen:h,closeRate:()=>g(!1),project:v})]})}function IX({vm:e,copy:t,expandedId:n,busy:r,onBack:i,onExpand:s,onApprove:a,onReject:l}){return o.jsx(gt,{label:"1f 审批",header:o.jsxs(En,{onBack:i,trailing:o.jsx("span",{style:{font:`400 9.5px ${N}`,color:m.faint},children:"PENDING_APPROVALS.md"}),children:[o.jsx("div",{style:{fontSize:16,fontWeight:650,color:m.ink,letterSpacing:"-.01em",flex:"none"},children:t.title}),o.jsxs(en,{tone:"waiting",children:[e.pendingCount," ",t.toProcess]})]}),children:o.jsxs(gn,{gap:10,children:[e.cards.length===0&&o.jsx("div",{style:{padding:"40px 0",textAlign:"center",color:m.faint,fontSize:13},children:t.empty}),e.groups.map(c=>o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[o.jsx(MX,{label:c.projectId??t.globalGroup}),c.cards.map(d=>d.id===n?o.jsx(LX,{card:d,copy:t,busy:r,onApprove:a,onReject:l},d.id):o.jsx(OX,{card:d,copy:t,onExpand:s},d.id))]},c.projectId??"__global__"))]})})}function MX({label:e}){return o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"2px 2px 0"},children:[o.jsx("div",{style:{fontSize:9.5,fontWeight:600,letterSpacing:".06em",color:m.faint},children:e}),o.jsx("div",{style:{flex:1,height:1,background:"var(--proto-line)"}})]})}function K3({copy:e,operation:t}){return o.jsxs("span",{style:{fontSize:10,fontWeight:700,padding:"2px 8px",borderRadius:999,background:m.amberBg,color:m.amberInk,minWidth:0,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:[e.tier," · ",t]})}function LX({card:e,copy:t,busy:n,onApprove:r,onReject:i}){return o.jsxs($e,{tone:"amber",radius:14,padding:0,style:{overflow:"hidden",boxShadow:"0 1px 3px rgba(16,24,40,.05)"},children:[o.jsxs("div",{style:{padding:"12px 14px 0"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,overflow:"hidden"},children:[e.operation&&o.jsx(K3,{copy:t,operation:e.operation}),o.jsx("span",{style:{font:`400 10px ${N}`,color:"var(--proto-amber-accent)",flex:1,minWidth:0,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.id}),e.time&&o.jsx("span",{style:{font:`400 10px ${N}`,color:m.faint,flex:"none"},children:e.time})]}),o.jsx("div",{style:{fontSize:14.5,fontWeight:600,color:m.ink,lineHeight:1.4,marginTop:8},children:e.title}),e.reason&&o.jsx("div",{style:{fontSize:12,lineHeight:1.55,color:m.sub,marginTop:4},children:e.reason}),e.impact&&o.jsx("div",{style:{fontSize:12,lineHeight:1.55,color:m.sub,marginTop:4},children:e.impact}),e.command&&o.jsx("div",{style:{marginTop:8,padding:"8px 10px",background:m.amberCard,border:`1px solid ${m.amberBg}`,borderRadius:9,font:`400 10.5px ${N}`,color:"var(--proto-amber-fg)",whiteSpace:"pre-wrap",wordBreak:"break-all"},children:e.command}),o.jsxs("div",{style:{fontSize:12,lineHeight:1.55,color:m.sub,marginTop:4},children:[e.provenance&&o.jsxs(o.Fragment,{children:[t.from," ",o.jsx("span",{style:{font:`400 11px ${N}`,color:m.run},children:e.provenance})," · "]}),t.paused]})]}),o.jsxs("div",{style:{display:"flex",gap:8,padding:"12px 14px 14px"},children:[o.jsx(Wj,{kind:"outline",busy:n,onClick:()=>i(e.id),children:t.reject}),o.jsx(Wj,{kind:"ink",busy:n,onClick:()=>r(e.id),children:t.approve})]})]})}function Wj({kind:e,busy:t,onClick:n,children:r}){const i=e==="ink";return o.jsx("button",{type:"button",disabled:t,onClick:n,style:{flex:1,height:44,borderRadius:11,background:i?m.ink:"var(--proto-card)",color:i?"var(--proto-card)":m.ink,border:i?"none":"1.5px solid var(--proto-line-3)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:14,fontWeight:600,boxSizing:"border-box",fontFamily:"inherit",cursor:t?"not-allowed":"pointer",opacity:t?.6:1},children:r})}function OX({card:e,copy:t,onExpand:n}){const r=[e.id,e.provenance?`${t.from} ${e.provenance}`:null,t.seeDiff].filter(Boolean).join(" · ");return o.jsxs($e,{radius:14,padding:"11px 14px",onClick:()=>n(e.id),children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,overflow:"hidden"},children:[e.operation&&o.jsx(K3,{copy:t,operation:e.operation}),o.jsx("span",{style:{fontSize:13,fontWeight:600,color:m.body,flex:1,minWidth:0,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.title}),e.time&&o.jsx("span",{style:{font:`400 10px ${N}`,color:m.faint,flex:"none"},children:e.time})]}),o.jsx("div",{style:{font:`400 10px ${N}`,color:m.muted,marginTop:5,paddingLeft:2},children:r})]})}function AX(e,t=Date.now(),n=null){const r=e.filter(c=>c.status==="pending"),i=c=>({id:c.id,projectId:c.projectId,operation:c.operation,title:c.title,time:Mr(c.queuedAt,t),reason:c.reason,impact:c.impact,command:c.command,provenance:c.provenance}),s=new Map;for(const c of r){const d=c.projectId??"";s.has(d)||s.set(d,[]),s.get(d).push(i(c))}const l=[...s.keys()].sort((c,d)=>{const u=f=>f===n?0:f===""?1:2;return u(c)-u(d)||c.localeCompare(d)}).map(c=>({projectId:c===""?null:c,cards:s.get(c)}));return{pendingCount:r.length,groups:l,cards:l.flatMap(c=>c.cards)}}const DX={en:{title:"Approvals",toProcess:"pending",tier:"Approval",from:"from",paused:"thread paused, waiting",approve:"Approve",reject:"Reject with feedback",seeDiff:"tap for diff ›",empty:"No pending approvals",globalGroup:"GLOBAL"},zh:{title:"审批",toProcess:"待处理",tier:"审批",from:"来自",paused:"线程已暂停等待",approve:"批准",reject:"拒绝并反馈",seeDiff:"点开看 diff ›",empty:"没有待处理的审批",globalGroup:"全局"}};function NX(){const e=le(),t=ze(),n=je(),r=ut(),i=Lt(r,DX),{currentProjectId:s}=Bn(),a=Y(e.approvals.list.queryOptions({status:"pending"})),l=p.useMemo(()=>a.data??[],[a.data]),c=p.useMemo(()=>AX(l,Date.now(),s),[l,s]),[d,u]=p.useState(null);p.useEffect(()=>{u(x=>{var b;return x&&c.cards.some(j=>j.id===x)?x:((b=c.cards[0])==null?void 0:b.id)??null})},[c.cards]);const f=()=>n.invalidateQueries(e.approvals.list.queryFilter()),h=xe(e.approvals.approve.mutationOptions({onSettled:f})),g=xe(e.approvals.reject.mutationOptions({onSettled:f})),v=h.isPending||g.isPending;return o.jsx(IX,{vm:c,copy:i,expandedId:d,busy:v,onBack:()=>t("/m/project"),onExpand:u,onApprove:x=>h.mutate({id:x}),onReject:x=>g.mutate({id:x})})}function _X({vm:e,copy:t,expandedId:n,busy:r,onBack:i,onExpand:s,onDelete:a,onHandle:l}){return o.jsx(gt,{label:"24c Issues",header:o.jsxs(En,{onBack:i,trailing:o.jsx("span",{style:{font:`400 9.5px ${N}`,color:m.faint},children:"ISSUES.md"}),children:[o.jsx("div",{style:{fontSize:16,fontWeight:650,color:m.ink,letterSpacing:"-.01em",flex:"none"},children:t.title}),e.count>0&&o.jsx("span",{style:{font:`600 10px ${N}`,color:m.sub,background:"var(--proto-line-2)",padding:"2px 8px",borderRadius:999,flex:"none"},children:e.count})]}),children:o.jsxs(gn,{gap:10,children:[e.cards.length===0&&o.jsx("div",{style:{padding:"40px 0",textAlign:"center",color:m.faint,fontSize:13},children:t.empty}),e.cards.map(c=>c.id===n?o.jsx($X,{card:c,copy:t,busy:r,onDelete:a,onHandle:l},c.id):o.jsx(FX,{card:c,onExpand:s},c.id)),e.cards.length>0&&o.jsx("div",{style:{marginTop:"auto",display:"flex",alignItems:"center",justifyContent:"center",padding:"10px 0 12px"},children:o.jsx("span",{style:{fontSize:10.5,color:m.faint},children:t.footer})})]})})}function $X({card:e,copy:t,busy:n,onDelete:r,onHandle:i}){return o.jsxs($e,{tone:"blue",radius:14,padding:0,style:{overflow:"hidden",boxShadow:"0 1px 3px rgba(16,24,40,.05)"},children:[o.jsxs("div",{style:{padding:"12px 14px 0"},children:[e.date&&o.jsx("div",{style:{display:"flex",alignItems:"center",gap:7},children:o.jsx("span",{style:{marginLeft:"auto",font:`400 10px ${N}`,color:m.faint},children:e.date})}),o.jsx("div",{style:{fontSize:14.5,fontWeight:600,color:m.ink,lineHeight:1.4,marginTop:e.date?8:0},children:e.title}),e.desc&&o.jsx("div",{style:{fontSize:12,lineHeight:1.55,color:m.sub,marginTop:4,whiteSpace:"pre-wrap"},children:e.desc}),e.fields.map((s,a)=>o.jsxs("div",{style:{fontSize:12,lineHeight:1.55,color:m.sub,marginTop:4,whiteSpace:"pre-wrap"},children:[o.jsx("b",{style:{color:m.body},children:s.label}),":",s.text]},`${s.label}-${a}`))]}),o.jsxs("div",{style:{display:"flex",gap:8,padding:"12px 14px 14px"},children:[o.jsx(Uj,{kind:"danger-outline",busy:n,onClick:()=>r(e.id),width:104,children:t.del}),o.jsx(Uj,{kind:"accent",busy:n,onClick:()=>i(e.id),children:t.handle})]})]})}function Uj({kind:e,busy:t,onClick:n,width:r,children:i}){const s=e==="accent";return o.jsx("button",{type:"button",disabled:t,onClick:n,style:{flex:r?"none":1,width:r,height:44,borderRadius:11,background:s?m.run:"var(--proto-card)",color:s?"var(--ink-solid-fg)":"var(--proto-danger)",border:s?"none":"1.5px solid var(--proto-danger-bg)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:14,fontWeight:600,boxSizing:"border-box",fontFamily:"inherit",cursor:t?"not-allowed":"pointer",opacity:t?.6:1},children:i})}function FX({card:e,onExpand:t}){return o.jsx($e,{radius:14,padding:"11px 14px",onClick:()=>t(e.id),children:o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7},children:[o.jsx("span",{style:{fontSize:13,fontWeight:600,color:m.body,flex:1,minWidth:0,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.title}),e.date&&o.jsx("span",{style:{font:`400 10px ${N}`,color:m.faint,flex:"none"},children:e.date})]})})}function zX(e){const t=e.map(n=>{const r=v6(n.body);return{id:n.id,title:n.title,date:n.date,fields:r.fields,desc:r.desc}});return{count:e.length,cards:t}}const BX={en:{title:"Issues",del:"Delete",handle:"Handle",empty:"No issues",footer:"Handle = new session carrying this issue · handle / delete removes it"},zh:{title:"Issues",del:"删除",handle:"处理",empty:"没有 issue",footer:"处理 = 新建会话携带此 issue · 处理 / 删除后即离场"}};function WX(){const e=le(),t=ze(),n=je(),r=ut(),i=Lt(r,BX),{currentProjectId:s}=Bn(),a=Y({...e.issues.list.queryOptions({projectId:s??""}),enabled:!!s}),l=p.useMemo(()=>a.data??[],[a.data]),c=p.useMemo(()=>zX(l),[l]),[d,u]=p.useState(null);p.useEffect(()=>{u(v=>{var x;return v&&c.cards.some(b=>b.id===v)?v:((x=c.cards[0])==null?void 0:x.id)??null})},[c.cards]);const f=()=>n.invalidateQueries(e.issues.list.queryFilter()),h=xe(e.issues.delete.mutationOptions({onSettled:f})),g=h.isPending;return o.jsx(_X,{vm:c,copy:i,expandedId:d,busy:g,onBack:()=>t("/m/project"),onExpand:u,onDelete:v=>s&&h.mutate({projectId:s,id:v}),onHandle:v=>{if(!s)return;const x=l.find(y=>y.id===v);if(!x)return;const b=y6(s,x),j=yd({isDraft:!0,projectId:s});nl(j,{text:b,attachments:[]}),t("/m/session/new"),h.mutate({projectId:s,id:v})}})}const Hj=8;function UX(e){return Math.max(-78,Math.min(0,e))}function HX(e){return Math.abs(e.deltaX)>Math.abs(e.deltaY)&&e.deltaX<=-48?"delete-open":"closed"}function VX(e){return Math.abs(e.deltaX)>Hj||Math.abs(e.deltaY)>Hj}function Vj(e,t){return{deltaX:t.clientX-e.x,deltaY:t.clientY-e.y}}function qX(e,t,n,r){const i=p.useRef(null),s=p.useRef(!1),[a,l]=p.useState(0);return{offset:t?-78:a,onPointerDown:g=>{var v,x;(x=(v=g.currentTarget).setPointerCapture)==null||x.call(v,g.pointerId),s.current=!1,i.current={x:g.clientX,y:g.clientY}},onPointerMove:g=>{if(!i.current)return;const v=Vj(i.current,g);Math.abs(v.deltaX)>Math.abs(v.deltaY)&&l(UX(v.deltaX))},onPointerUp:g=>{if(!i.current)return;const v=Vj(i.current,g);s.current=VX(v),HX(v)==="delete-open"?r(e):t||r(null),l(0),i.current=null},onPointerCancel:()=>{s.current=!0,l(0),i.current=null},onClick:()=>{if(s.current){s.current=!1;return}r(null),t||n()}}}function Q3({completed:e,busy:t,onClick:n}){return o.jsx("button",{type:"button",disabled:t,onClick:r=>{r.stopPropagation(),n()},style:{width:22,height:22,borderRadius:"50%",border:e?0:`2px solid ${m.hairline}`,background:e?m.done:"transparent",color:"white",padding:0,flex:"none",fontSize:10},children:e?"✓":""})}function KX({row:e,copy:t,busy:n,onSave:r,onCancel:i}){const[s,a]=p.useState(e.text),l=async()=>{const c=s.trim();!c||n||(await r(c),i())};return o.jsxs("div",{style:{border:`1px solid ${m.runBorder}`,background:m.card,borderRadius:14,padding:13},children:[o.jsx("input",{value:s,onChange:c=>a(c.target.value),autoFocus:!0,style:{width:"100%",boxSizing:"border-box",height:40,borderRadius:10,border:`1.5px solid ${m.hairline}`,padding:"0 12px",fontSize:14}}),o.jsxs("div",{style:{display:"flex",gap:8,marginTop:9},children:[o.jsx("button",{type:"button",disabled:n,onClick:()=>void l(),style:{flex:1,height:40,border:0,borderRadius:10,background:m.run,color:"white",fontSize:13,fontWeight:600},children:t.save}),o.jsx("button",{type:"button",disabled:n,onClick:i,style:{width:76,height:40,border:`1px solid ${m.hairline}`,borderRadius:10,background:m.card,color:m.ink,fontSize:13,fontWeight:600},children:t.cancel})]})]})}function QX({row:e,copy:t,busy:n,actions:r,onEdit:i}){return o.jsxs("div",{style:{display:"flex",gap:8,marginTop:11},children:[o.jsx("button",{type:"button",disabled:n,onClick:()=>r.onHandoff(e.text),style:{flex:1,height:40,border:0,borderRadius:10,background:m.run,color:"white",fontSize:13,fontWeight:600},children:t.handoff}),o.jsx("button",{type:"button",disabled:n,onClick:i,style:{width:76,height:40,borderRadius:10,border:`1.5px solid ${m.hairline}`,background:m.card,color:m.ink,fontSize:13,fontWeight:600},children:t.edit})]})}function YX({row:e,copy:t,busy:n,actionOpen:r,swipeOpen:i,actions:s,onActions:a,onSwipe:l,onEdit:c}){const{offset:d,...u}=qX(e.id,i,()=>a(e.id),l);return o.jsxs("div",{"data-note-click":e.id,"data-note-swipe":e.id,style:{borderRadius:14,overflow:"hidden",background:"var(--proto-danger)",position:"relative"},children:[o.jsx("button",{type:"button",disabled:n,onClick:()=>void s.onDelete(e.id),style:{position:"absolute",right:0,top:0,bottom:0,width:78,border:0,background:"var(--proto-danger)",color:"white",fontSize:13,fontWeight:600},children:t.delete}),o.jsxs("div",{...u,style:{transform:`translateX(${d}px)`,transition:d===0||i?"transform 180ms ease":"none",touchAction:"pan-y",border:`1px solid ${r?m.runBorder:m.divider}`,background:m.card,borderRadius:14,padding:"12px 14px",position:"relative"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:10},children:[o.jsx(Q3,{completed:!1,busy:n,onClick:()=>void s.onSetCompleted(e.id,!0)}),o.jsxs("div",{style:{minWidth:0,flex:1},children:[o.jsx("div",{style:{fontSize:14,fontWeight:600,color:m.ink,lineHeight:1.4},children:e.text}),o.jsx("div",{style:{font:`400 10px ${N}`,color:m.faint,marginTop:4},children:e.timeLabel})]})]}),r&&o.jsx(QX,{row:e,copy:t,busy:n,actions:s,onEdit:c})]})]})}function GX({row:e,busy:t,onReopen:n}){return o.jsxs("div",{style:{border:`1px solid ${m.hairline}`,background:m.card,borderRadius:14,padding:"11px 14px",display:"flex",alignItems:"center",gap:10,opacity:.7},children:[o.jsx(Q3,{completed:!0,busy:t,onClick:n}),o.jsx("span",{style:{fontSize:14,color:m.muted,textDecoration:"line-through",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.text}),o.jsx("span",{style:{marginLeft:"auto",font:`400 10px ${N}`,color:m.faint,flex:"none"},children:e.timeLabel})]})}function XX({copy:e,busy:t,onAdd:n}){const[r,i]=p.useState(""),s=async a=>{a.preventDefault();const l=r.trim();!l||t||(await n(l),i(""))};return o.jsxs("form",{"data-notes-fixed-composer":"",onSubmit:s,style:{flex:"none",borderTop:`1px solid ${m.divider}`,background:m.card,display:"flex",alignItems:"center",gap:8,padding:"10px 14px calc(10px + env(safe-area-inset-bottom))"},children:[o.jsxs("div",{style:{flex:1,height:44,borderRadius:12,border:`1.5px solid ${m.hairline}`,background:m.card,display:"flex",alignItems:"center",gap:9,padding:"0 14px",boxSizing:"border-box"},children:[o.jsx("span",{style:{width:16,height:16,borderRadius:"50%",border:`1.5px solid ${m.hairline}`,boxSizing:"border-box"}}),o.jsx("input",{value:r,onChange:a=>i(a.target.value),placeholder:e.inputPlaceholder,"aria-label":e.inputPlaceholder,style:{flex:1,minWidth:0,border:0,outline:0,background:"transparent",fontSize:14,color:m.ink}})]}),o.jsx("button",{type:"submit",disabled:t||!r.trim(),style:{width:44,height:44,borderRadius:12,border:0,background:m.run,color:"white",fontSize:17,opacity:t||!r.trim()?.45:1},children:"↑"})]})}function JX(e){const[t,n]=p.useState(null),[r,i]=p.useState(null),[s,a]=p.useState(null),[l,c]=p.useState(!0),d=e;return o.jsx(gt,{label:"26c 移动端笔记",header:o.jsxs(En,{onBack:e.onBack,trailing:o.jsx("span",{style:{font:`400 9.5px ${N}`,color:m.faint},children:"context/NOTES.md"}),children:[o.jsx("span",{style:{fontSize:16,fontWeight:650,color:m.ink},children:e.copy.title}),o.jsx("span",{style:{font:`600 10px ${N}`,color:m.sub,background:m.hairline,padding:"2px 8px",borderRadius:999},children:e.vm.activeCount})]}),footer:o.jsx(XX,{copy:e.copy,busy:e.busy,onAdd:e.onAdd}),children:o.jsxs(gn,{gap:9,children:[e.vm.active.map(u=>s===u.id?o.jsx(KX,{row:u,copy:e.copy,busy:e.busy,onSave:f=>e.onUpdate(u.id,f),onCancel:()=>a(null)},u.id):o.jsx(YX,{row:u,copy:e.copy,busy:e.busy,actionOpen:t===u.id,swipeOpen:r===u.id,actions:d,onActions:n,onSwipe:i,onEdit:()=>a(u.id)},u.id)),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"4px 4px 0"},children:[o.jsxs("button",{type:"button",onClick:()=>c(u=>!u),style:{border:0,padding:0,background:"transparent",fontSize:10,fontWeight:700,letterSpacing:".06em",color:m.muted},children:[e.copy.completed," · ",e.vm.completedCount," ",l?"▾":"▸"]}),e.vm.completedCount>0&&o.jsx("button",{type:"button",disabled:e.busy,onClick:()=>void e.onClearCompleted(),style:{marginLeft:"auto",border:0,background:"transparent",color:"var(--proto-danger)",fontSize:11,fontWeight:600},children:e.copy.clear})]}),l&&e.vm.completed.map(u=>o.jsx(GX,{row:u,busy:e.busy,onReopen:()=>void e.onSetCompleted(u.id,!1)},u.id))]})})}function ZX(e){const t=le(),n=je(),r=()=>n.invalidateQueries(t.notes.list.queryFilter({projectId:e})),i=xe(t.notes.add.mutationOptions({onSettled:r})),s=xe(t.notes.update.mutationOptions({onSettled:r})),a=xe(t.notes.setCompleted.mutationOptions({onSettled:r})),l=xe(t.notes.delete.mutationOptions({onSettled:r})),c=xe(t.notes.clearCompleted.mutationOptions({onSettled:r}));return{busy:i.isPending||s.isPending||a.isPending||l.isPending||c.isPending,add:d=>i.mutateAsync({projectId:e,text:d}),update:(d,u)=>s.mutateAsync({projectId:e,id:d,text:u}),setCompleted:(d,u)=>a.mutateAsync({projectId:e,id:d,completed:u}),remove:d=>l.mutateAsync({projectId:e,id:d}),clearCompleted:()=>c.mutateAsync({projectId:e})}}function eJ(){const e=le(),t=ze(),n=ut(),{currentProjectId:r}=Bn(),i=r??"",s=Y({...e.notes.list.queryOptions({projectId:i}),enabled:!!i}),a=ZX(i),l=p.useMemo(()=>q3(s.data??[],Date.now(),n),[s.data,n]);return o.jsx(JX,{vm:l,copy:vv[n],busy:a.busy,onBack:()=>t("/m/project"),onAdd:a.add,onUpdate:a.update,onSetCompleted:a.setCompleted,onDelete:a.remove,onClearCompleted:a.clearCompleted,onHandoff:c=>{g6(i,c),t("/m/session/new")}})}function tJ(){return o.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 14 14",fill:"none",stroke:m.muted,strokeWidth:"1.5",children:[o.jsx("path",{d:"M3 1.5h5.5L11.5 4v8.5h-8.5z"}),o.jsx("path",{d:"M8.5 1.5V4H11"})]})}function nJ({vm:e,copy:t,onBack:n,onMore:r}){const i=o3(e.status);return o.jsxs("div",{style:{flex:"none",padding:"8px 14px 0",paddingTop:"calc(8px + env(safe-area-inset-top))",borderBottom:`1px solid ${m.hairline}`,background:m.canvas},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9},children:[o.jsx("button",{type:"button","aria-label":"Back",onClick:n,style:{border:"none",background:"transparent",color:m.run,fontSize:15,lineHeight:1,padding:"0 2px",margin:0,cursor:"pointer",flex:"none",minHeight:34,display:"flex",alignItems:"center"},children:"‹"}),o.jsx("span",{style:{font:`600 15px ${N}`,color:m.ink},children:e.name}),o.jsx(en,{tone:i,children:t.status[i]}),o.jsx("div",{style:{marginLeft:"auto",flex:"none"},children:o.jsx(r3,{onClick:r})})]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,font:`400 9.5px ${N}`,color:"var(--proto-muted-3)",padding:"6px 0 9px 24px",whiteSpace:"nowrap",overflow:"hidden"},children:[e.crumbs.map((s,a)=>o.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6},children:[o.jsx("span",{style:{color:m.run},children:s.name}),o.jsx("span",{children:"›"})]},a)),o.jsx("span",{style:{color:m.ink,fontWeight:600},children:e.name}),o.jsxs("span",{children:[e.selfLevel!=null?` · L${e.selfLevel}`:""," · ",t.depth," ",e.depthText]})]})]})}function rJ({kind:e,hasConnector:t}){return o.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center"},children:[e==="done"&&o.jsx("span",{style:{width:13,height:13,borderRadius:"50%",background:m.doneBg,color:m.done,display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:7.5,fontWeight:700,flex:"none"},children:"✓"}),e==="running"&&o.jsx("span",{style:{width:13,height:13,borderRadius:"50%",background:m.run,flex:"none",boxShadow:`0 0 0 3px ${m.runBg}`,animation:"cxpulse 1.6s ease-in-out infinite"}}),e==="pending"&&o.jsx("span",{style:{width:13,height:13,borderRadius:"50%",border:"1.5px solid var(--proto-line-3)",boxSizing:"border-box",flex:"none"}}),t&&o.jsx("span",{style:{flex:1,width:1.5,background:"var(--proto-line-2)",margin:"3px 0"}})]})}function oJ({agent:e}){return o.jsxs("div",{style:{border:"1px solid var(--proto-accent-bg)",background:"var(--proto-rail)",borderRadius:9,padding:"9px 11px",marginTop:6,overflow:"hidden"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,font:`400 9px ${N}`,color:"var(--proto-muted-3)"},children:[e.live&&o.jsx(li,{color:m.run,size:5,pulse:!0}),o.jsx("span",{children:e.turnLabel}),e.cost&&o.jsx("span",{style:{marginLeft:"auto"},children:e.cost})]}),e.text&&o.jsx("div",{style:{fontSize:11,lineHeight:1.65,color:m.sub,marginTop:6,overflowWrap:"break-word",wordBreak:"break-word"},children:o.jsx(Si,{text:e.text})})]})}function iJ({step:e,copy:t,selected:n,onSelect:r}){const i=e.kind==="running",s=n&&(e.kind==="done"||e.kind==="running"),a=i?m.ink:e.kind==="done"?m.sub:m.faint,l=e.kind==="pending"?t.pending:e.time,c=e.kind!=="pending";return o.jsxs(o.Fragment,{children:[o.jsx(rJ,{kind:e.kind,hasConnector:e.hasConnector}),o.jsxs("div",{onClick:c?r:void 0,style:{paddingBottom:e.hasConnector?9:4,minWidth:0,cursor:c?"pointer":void 0},children:[o.jsxs("div",{style:{display:"flex",alignItems:"baseline"},children:[o.jsx("span",{style:{fontSize:11.5,fontWeight:i||n?600:500,color:n?m.ink:a},children:e.name}),e.note&&!s&&o.jsx("span",{style:{fontSize:9,color:"var(--proto-muted-3)",marginLeft:6,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flex:1,minWidth:0},children:e.note}),l&&o.jsx("span",{style:{marginLeft:"auto",font:`400 9px ${N}`,color:i?m.run:m.faint,flex:"none"},children:l}),c&&o.jsx("span",{style:{color:m.faint,fontSize:8,flex:"none",marginLeft:4,transform:s?"rotate(90deg)":void 0,transition:"transform .15s"},children:"▸"})]}),e.agent&&n&&o.jsx(oJ,{agent:e.agent}),e.kind==="done"&&n&&e.sessionId&&o.jsx("div",{style:{border:"1px solid var(--proto-line-2)",background:"var(--proto-rail)",borderRadius:9,padding:"9px 11px",marginTop:6,overflow:"hidden",maxHeight:400,overflowY:"auto",WebkitOverflowScrolling:"touch"},children:o.jsx(r6,{sessionId:e.sessionId,live:!1})})]})]})}function sJ({vm:e,copy:t,onArtifactClick:n}){return o.jsxs("div",{style:{background:"var(--proto-card)",border:`1px solid ${m.hairline}`,borderRadius:12,overflow:"hidden"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"9px 13px",borderBottom:"1px solid var(--proto-line-2)"},children:[o.jsx("span",{style:{fontSize:12,fontWeight:650,color:m.ink},children:t.artifacts}),o.jsx("span",{style:{font:`400 9.5px ${N}`,color:m.faint,marginLeft:7},children:e.artifactCount})]}),e.artifacts.length===0?o.jsx("div",{style:{padding:"9px 13px",font:`400 10px ${N}`,color:m.faint},children:t.noArtifacts}):e.artifacts.map((r,i)=>o.jsxs("div",{onClick:n?()=>n(r):void 0,style:{display:"flex",alignItems:"center",gap:9,padding:"9px 13px",borderBottom:i<e.artifacts.length-1?"1px solid var(--proto-alt)":void 0,cursor:n?"pointer":void 0},children:[o.jsx(tJ,{}),o.jsx("span",{style:{font:`500 12px ${N}`,color:m.body},children:r.filename}),o.jsx("span",{style:{marginLeft:"auto",font:`400 9.5px ${N}`,color:m.faint},children:r.meta}),n&&o.jsx("span",{style:{color:m.run,fontSize:8,flex:"none"},children:"▸"})]},i))]})}function aJ({vm:e,copy:t,onCancel:n}){return o.jsxs("div",{style:{flex:"none",borderTop:`1px solid ${m.hairline}`,background:"var(--proto-rail)",display:"flex",alignItems:"center",gap:8,padding:"10px 14px 34px",paddingBottom:"calc(14px + env(safe-area-inset-bottom))",minHeight:44,boxSizing:"border-box"},children:[e.live&&o.jsxs(o.Fragment,{children:[o.jsx("div",{title:"Pause has no backend op yet",style:{flex:1,height:44,borderRadius:11,border:"1.5px solid var(--proto-line-3)",background:"var(--proto-card)",color:m.ink,display:"flex",alignItems:"center",justifyContent:"center",fontSize:14,fontWeight:600,boxSizing:"border-box",cursor:"not-allowed",opacity:.6},children:t.pause}),o.jsx("button",{type:"button","data-cancel-thread-id":e.tid,onClick:n,style:{flex:1,height:44,borderRadius:11,border:"1.5px solid var(--proto-danger-bg)",background:"var(--proto-card)",color:m.fail,display:"flex",alignItems:"center",justifyContent:"center",fontSize:14,fontWeight:600,boxSizing:"border-box",cursor:"pointer"},children:t.cancel})]}),o.jsxs("span",{style:{font:`500 10.5px ${N}`,color:"var(--proto-muted-3)",flex:"none",marginLeft:"auto",paddingLeft:4},children:["Σ ",e.cost]})]})}function lJ({vm:e,copy:t,onBack:n,onMore:r,onCancel:i,onArtifactClick:s}){const a=e.steps.findIndex(f=>f.kind==="running"),l=a>=0?a:e.steps.length-1,[c,d]=p.useState(null),u=c??l;return o.jsx(gt,{label:"1g 线程详情",header:o.jsx(nJ,{vm:e,copy:t,onBack:n,onMore:r}),footer:o.jsx(aJ,{vm:e,copy:t,onCancel:i}),children:o.jsxs("div",{style:{padding:"12px 14px 0",display:"flex",flexDirection:"column",gap:10},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,font:`400 10px ${N}`,color:"var(--proto-muted-3)",padding:"0 2px"},children:[o.jsx("span",{children:e.metaParts.join(" · ")}),o.jsx("span",{style:{marginLeft:"auto",color:m.run},children:e.elapsed})]}),o.jsx("div",{style:{background:"var(--proto-card)",border:`1px solid ${m.hairline}`,borderRadius:12,padding:"11px 13px 7px"},children:o.jsx("div",{style:{display:"grid",gridTemplateColumns:"15px 1fr",columnGap:8},children:e.steps.map((f,h)=>o.jsx(iJ,{step:f,copy:t,selected:h===u,onSelect:()=>d(h===u?-1:h)},h))})}),o.jsx(sJ,{vm:e,copy:t,onArtifactClick:s}),o.jsx("div",{style:{height:4,flex:"none"}})]})})}const cJ=new Set(["running","waiting"]);function qj(e){return String(e).padStart(2,"0")}function Kj(e){const t=Math.max(0,Math.floor(e));return`${qj(Math.floor(t/60))}:${qj(t%60)}`}function dJ(e){const t=Math.round(e);if(t<60)return`${t}s`;const n=Math.floor(t/60),r=t%60;return r===0?`${n}m`:`${n}m ${r}s`}function uJ(e){const t=e.split("/").filter(Boolean);return t[t.length-1]??e}function pJ(e,t){if(t){const n=G0(e,t).map(r=>r.machine).find(Boolean);if(n)return n}return e.dispatches.map(n=>n.machine).find(Boolean)??null}function fJ(e,t,n){const r=cJ.has(e.status),i=t.map(x=>({name:x.name,accent:!0})),s=t.length>0?t.length+1:null,a=`${X0(e.children)}/${hs}`,l=e.steps.find(x=>x.status==="running"),c=pJ(e,l),d=[e.id,e.activeAgent?`agent ${e.activeAgent}`:null,c].filter(x=>!!x),u=e.endedAt?Date.parse(e.endedAt):n,f=Kj((u-Date.parse(e.createdAt))/1e3),h=e.steps.length-1,g=e.steps.map((x,b)=>{var S,T;const j=x.status==="completed"?"done":x.status==="running"?"running":"pending",y=j==="running";let w="";y?w=x.startedAt?Kj((n-Date.parse(x.startedAt))/1e3):"":j==="done"&&x.durationS!=null&&(w=dJ(x.durationS));let k;if(y){const C=((S=e.agentFlow)==null?void 0:S.profile)??e.activeAgent??x.agentSlotId,P=((T=e.agentFlow)==null?void 0:T.lastOutput)??x.outputSummary??"";k={turnLabel:x.numTurns!=null?`turn ${x.numTurns} · ${C}`:C,cost:x.costUsd!=null?`$${x.costUsd.toFixed(2)}`:"",lines:P.split(`
|
|
139
|
+
`).map(I=>I.trim()).filter(Boolean),text:P,live:r}}return{kind:j,name:x.stage??`#${x.stepIndex+1}`,note:j==="done"?x.outputSummary??"":"",time:w,hasConnector:b<h,agent:k,sessionId:x.sessionId??null}}),v=[];if(e.artifacts.artifactPath){const x=uJ(e.artifacts.artifactPath);v.push({filename:x,meta:Mr(e.updatedAt,n),wsRelPath:`workspace/threads/${e.id}/${x}`})}return{name:e.templateName,tid:e.id,status:e.status,live:r,crumbs:i,selfLevel:s,depthText:a,metaParts:d,elapsed:f,cost:`$${e.totalCostUsd.toFixed(2)}`,steps:g,artifacts:v,artifactCount:v.length}}const hJ={en:{pause:"Pause",cancel:"Cancel",artifacts:"Artifacts",noArtifacts:"No artifacts",pending:"wait",depth:"depth",status:{running:"Running",waiting:"Waiting",done:"Done",failed:"Failed",cancelled:"Cancelled"}},zh:{pause:"暂停",cancel:"取消",artifacts:"产物",noArtifacts:"暂无产物",pending:"待",depth:"深度",status:{running:"运行中",waiting:"等待",done:"完成",failed:"失败",cancelled:"已取消"}}};function gJ(e){const[t,n]=p.useState(()=>Date.now());return p.useEffect(()=>{if(!e)return;const r=window.setInterval(()=>n(Date.now()),1e3);return()=>window.clearInterval(r)},[e]),t}function xJ(){var x;const{threadId:e=""}=gf(),t=ze(),n=ur(),r=ut(),i=Lt(r,hJ),s=(((x=n.state)==null?void 0:x.trail)??[]).filter(b=>b.id!==e),a=le(),l=je(),c=Y(a.threads.get.queryOptions({threadId:e}));ml(e);const d=c.data?["running","waiting"].includes(c.data.status):!1,u=gJ(d),f=xe(a.threads.cancel.mutationOptions({onSettled:()=>{l.invalidateQueries(a.threads.get.queryFilter({threadId:e})),l.invalidateQueries(a.threads.list.queryFilter())},onSuccess:()=>t("/m/threads")})),{openDoc:h}=md(),g=p.useCallback(b=>{const j=xd(b.filename);j&&h({kind:j,name:b.filename,path:b.wsRelPath})},[h]);if(c.isPending)return o.jsx(gt,{label:"1g 线程详情",children:o.jsx("div",{style:{padding:16,color:m.muted,fontSize:13},children:"…"})});if(c.isError)return o.jsx(gt,{label:"1g 线程详情",children:o.jsxs("div",{style:{margin:14,background:m.failBg,border:`1px solid ${m.failBorder}`,borderRadius:10,padding:"10px 14px",fontSize:12.5,color:m.fail},children:[e,": ",c.error.message]})});const v=fJ(c.data,s,u);return o.jsx(lJ,{vm:v,copy:i,onBack:()=>t(-1),onMore:()=>{},onCancel:()=>f.mutate({threadId:e}),onArtifactClick:g})}const mJ={tasksTag:"tasks.json",doneWhen:"DONE-WHEN",doneWhenGap:"done-when 未记录",blockerLabel:"阻塞原因",claimPrefix:"认领",open:"打开 ›",priorityLabel:"优先级",statusLabel:"状态",approvalNeededLabel:"需要审批",approvedAtLabel:"批准时间",templateLabel:"模板",depsLabel:"依赖",depsEmpty:"无依赖",historyLabel:"历史",historyEmpty:"暂无派发历史",footer:"只读 — 编辑 / 派发 / 取消在桌面或对话内完成",notFound:"任务未找到",status:{"in-progress":"进行中","approval-needed":"approval-needed",actionable:"可执行",blocked:"阻塞",done:"完成",waiting:"等待"},priority:{high:"P高",medium:"P中",low:"P低"},dispatchStatus:{running:"运行中",completed:"完成",failed:"失败",cancelled:"已取消",stale:"停滞"},dispatchType:{local:"本地",dispatch:"派发"}},vJ={tasksTag:"tasks.json",doneWhen:"DONE-WHEN",doneWhenGap:"no done-when recorded",blockerLabel:"Blocked",claimPrefix:"claimed",open:"open ›",priorityLabel:"Priority",statusLabel:"Status",approvalNeededLabel:"Approval needed",approvedAtLabel:"Approved at",templateLabel:"Template",depsLabel:"Depends",depsEmpty:"No dependencies",historyLabel:"History",historyEmpty:"No dispatch history",footer:"Read-only — edit / dispatch / cancel on desktop or in chat",notFound:"Task not found",status:{"in-progress":"In progress","approval-needed":"approval-needed",actionable:"Executable",blocked:"Blocked",done:"Done",waiting:"Waiting"},priority:{high:"High",medium:"Med",low:"Low"},dispatchStatus:{running:"running",completed:"completed",failed:"failed",cancelled:"cancelled",stale:"stale"},dispatchType:{local:"local",dispatch:"dispatch"}},yJ={"in-progress":"running","approval-needed":"waiting",actionable:"running",blocked:"failed",done:"done",waiting:"waiting"},bJ={"in-progress":m.run,"approval-needed":m.amberText,actionable:m.run,blocked:m.fail,done:m.done,waiting:m.amberText};function jJ(){return o.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:m.run,strokeWidth:"1.6",style:{flex:"none"},children:[o.jsx("circle",{cx:"3.5",cy:"3",r:"1.9"}),o.jsx("circle",{cx:"3.5",cy:"11",r:"1.9"}),o.jsx("circle",{cx:"10.5",cy:"7",r:"1.9"}),o.jsx("path",{d:"M3.5 5v4M5.4 3.7 8.7 6.1M5.4 10.3 8.7 7.9"})]})}const wJ={display:"flex",alignItems:"center",gap:9,padding:"10px 13px"};function kJ({label:e,reason:t}){return t==null?null:o.jsx("div",{"data-task-blocker-card":"true",children:o.jsxs($e,{tone:"fail",style:{background:m.failBg},children:[o.jsx("div",{style:{fontSize:9.5,fontWeight:700,letterSpacing:".07em",color:m.fail},children:e}),o.jsx("div",{style:{font:`400 11px/1.7 ${N}`,color:m.fail,marginTop:6,whiteSpace:"pre-wrap",overflowWrap:"anywhere"},children:t})]})})}function SJ({vm:e,copy:t,onBack:n,onOpenThread:r}){if(!e.found)return o.jsx(gt,{label:"1h 任务详情",header:o.jsx(En,{onBack:n,children:o.jsx("span",{style:{font:`600 15px ${N}`,color:m.ink},children:"—"})}),children:o.jsx("div",{style:{padding:16,color:m.muted,fontSize:13},children:t.notFound})});const i=o.jsxs(En,{onBack:n,trailing:o.jsx("span",{style:{font:`400 9.5px ${N}`,color:m.faint},children:t.tasksTag}),children:[o.jsx("span",{style:{font:`600 15px ${N}`,color:m.ink,flex:"none"},children:e.displayId}),o.jsx(en,{tone:yJ[e.statusKind],children:t.status[e.statusKind]})]}),s=[{key:"priority",node:o.jsxs(o.Fragment,{children:[o.jsx("span",{style:{fontSize:12,color:m.muted,width:62,flex:"none"},children:t.priorityLabel}),o.jsx("span",{style:{fontSize:12,color:m.body,fontWeight:600},children:t.priority[e.priority]})]})},{key:"status",node:o.jsxs(o.Fragment,{children:[o.jsx("span",{style:{fontSize:12,color:m.muted,width:62,flex:"none"},children:t.statusLabel}),o.jsx("span",{style:{font:`500 11px ${N}`,color:m.body},children:e.status})]})},{key:"approval-needed",node:o.jsxs(o.Fragment,{children:[o.jsx("span",{style:{fontSize:12,color:m.muted,width:62,flex:"none"},children:t.approvalNeededLabel}),o.jsx("span",{style:{font:`500 11px ${N}`,color:m.body},children:e.approvalNeeded==null?"—":String(e.approvalNeeded)})]})},{key:"approved-at",node:o.jsxs(o.Fragment,{children:[o.jsx("span",{style:{fontSize:12,color:m.muted,width:62,flex:"none"},children:t.approvedAtLabel}),o.jsx("span",{style:{font:`500 11px ${N}`,color:m.body},children:e.approvedAt??"—"})]})},{key:"template",node:o.jsxs(o.Fragment,{children:[o.jsx("span",{style:{fontSize:12,color:m.muted,width:62,flex:"none"},children:t.templateLabel}),o.jsx("span",{style:{font:`500 11px ${N}`,color:m.body,overflowWrap:"anywhere"},children:e.template})]})},{key:"deps",node:o.jsxs(o.Fragment,{children:[o.jsx("span",{style:{fontSize:12,color:m.muted,width:62,flex:"none"},children:t.depsLabel}),o.jsx("span",{style:{display:"flex",flexDirection:"column",gap:3,minWidth:0},children:e.deps.length===0?o.jsx("span",{style:{fontSize:11,color:m.faint},children:t.depsEmpty}):e.deps.map(a=>o.jsxs("span",{style:{font:`500 11px ${N}`,color:a.known?bJ[a.statusKind]:m.faint},children:[a.displayId,a.known?` · ${t.status[a.statusKind]}`:""]},a.id))})]})}];return o.jsx(gt,{label:"1h 任务详情",header:i,children:o.jsxs(gn,{gap:10,children:[o.jsx("div",{style:{fontSize:16,fontWeight:650,color:m.ink,lineHeight:1.45,padding:"0 2px"},children:e.text}),o.jsxs($e,{children:[o.jsx("div",{style:{fontSize:9.5,fontWeight:700,letterSpacing:".07em",color:m.faint},children:t.doneWhen}),o.jsx("div",{style:{font:`400 11px/1.7 ${N}`,color:e.doneWhen?m.sub:m.faint,marginTop:6,whiteSpace:"pre-wrap"},children:e.doneWhen??t.doneWhenGap})]}),o.jsx(kJ,{label:t.blockerLabel,reason:e.blockedBy}),e.claim&&o.jsxs($e,{children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[o.jsx(jJ,{}),o.jsx("span",{style:{font:`600 12.5px ${N}`,color:m.ink},children:e.claim.template}),o.jsxs("span",{style:{font:`400 9.5px ${N}`,color:m.muted},children:[t.claimPrefix," · ",e.claim.threadId??e.claim.claimedBy]}),e.claim.threadId&&o.jsx("span",{onClick:()=>r(e.claim.threadId),style:{marginLeft:"auto",fontSize:11.5,fontWeight:600,color:m.run,cursor:"pointer",flex:"none"},children:t.open})]}),e.claim.meta&&o.jsx("div",{style:{font:`400 10px ${N}`,color:m.muted,marginTop:4},children:e.claim.meta})]}),o.jsx($e,{padding:0,style:{overflow:"hidden"},children:s.map((a,l)=>o.jsx("div",{style:{...wJ,borderBottom:l<s.length-1?`1px solid ${m.divider}`:void 0},children:a.node},a.key))}),o.jsxs($e,{padding:0,style:{overflow:"hidden"},children:[o.jsx("div",{style:{display:"flex",alignItems:"center",padding:"9px 13px",borderBottom:"1px solid var(--proto-line-2)"},children:o.jsx("span",{style:{fontSize:12,fontWeight:650,color:m.ink},children:t.historyLabel})}),e.history.length===0?o.jsx("div",{style:{padding:"10px 13px",font:`400 10px ${N}`,color:m.faint},children:t.historyEmpty}):o.jsx("div",{style:{padding:"9px 13px",display:"flex",flexDirection:"column",gap:7,font:`400 10px/1.5 ${N}`},children:e.history.map((a,l)=>o.jsx(CJ,{h:a,copy:t},l))})]}),o.jsx("div",{style:{font:`400 9.5px ${N}`,color:m.faint,padding:"0 4px"},children:t.footer})]})})}function CJ({h:e,copy:t}){const n=Mr(e.startedAt),r=`${t.dispatchType[e.type]} · ${t.dispatchStatus[e.status]}`;return o.jsxs("div",{style:{display:"flex",gap:8},children:[o.jsx("span",{style:{color:m.faint,flex:"none"},children:n}),o.jsxs("span",{style:{color:m.sub},children:[r,e.isCompleting?" ✓":""]})]})}function EJ(e){if(e==null||!Number.isFinite(e)||e<0)return null;const t=Math.round(e/1e3);if(t<60)return`${t}s`;const n=Math.floor(t/60);return n<60?`${n}m`:`${Math.floor(n/60)}h ${n%60}m`}const TJ=[{kind:"done",matches:e=>e.status==="done"},{kind:"blocked",matches:e=>e.blockedBy!=null},{kind:"in-progress",matches:e=>e.claimedBy!=null},{kind:"approval-needed",matches:e=>e.approvalNeeded===!0},{kind:"actionable",matches:e=>e.actionable}];function Y3(e){var t;return((t=TJ.find(n=>n.matches(e)))==null?void 0:t.kind)??"waiting"}const PJ={found:!1,displayId:"",text:"",status:"open",template:"",statusKind:"waiting",priority:"medium",approvalNeeded:null,approvedAt:null,doneWhen:null,blockedBy:null,claim:null,deps:[],history:[]};function RJ(e,t){if(e.claimedBy==null)return null;const n=t[0]??null,r=[],i=EJ((n==null?void 0:n.durationMs)??null);return i&&r.push(i),(n==null?void 0:n.cost)!=null&&r.push(zc(n.cost)),{template:e.template,threadId:bd(e),claimedBy:null,meta:r.length>0?r.join(" · "):null}}function IJ(e,t){return e.dependsOn.map(n=>{const r=t.get(n);return{id:n,displayId:`T-${n}`,statusKind:r?Y3(r):"waiting",known:r!=null}})}function MJ(e,t){return e.map(n=>({startedAt:n.startedAt,type:n.type,status:n.status,isCompleting:t!=null&&n.executionId===t}))}function LJ(e,t,n,r=Date.now()){const i=new Map(t.map(c=>[c.id,c])),s=i.get(e);if(!s)return PJ;const a=(n==null?void 0:n.dispatches)??[],l=(n==null?void 0:n.evidence.completingExecutionId)??null;return{found:!0,displayId:`T-${s.id}`,text:s.text,status:s.status,template:s.template,statusKind:Y3(s),priority:s.priority,approvalNeeded:s.approvalNeeded??null,approvedAt:s.approvedAt??null,doneWhen:s.doneWhen,blockedBy:s.blockedBy??null,claim:RJ(s,a),deps:IJ(s,i),history:MJ(a,l)}}function OJ(){const e=le(),t=ze(),r=ut()==="zh"?mJ:vJ,{taskId:i}=gf(),{currentProjectId:s}=Bn();Sv();const a=Y(e.tasks.list.queryOptions({projectId:s??void 0})),l=Y({...e.tasks.verification.queryOptions({projectId:s??"",taskId:i??""}),enabled:!!s&&!!i}),c=a.data??[],d=p.useMemo(()=>LJ(i??"",c,l.data??null),[i,c,l.data]);return a.isLoading?o.jsx(gt,{label:"1h 任务详情",children:o.jsx("div",{style:{padding:16,color:m.muted,fontSize:13},children:r.notFound})}):o.jsx(SJ,{vm:d,copy:r,onBack:()=>t(-1),onOpenThread:u=>t(`/m/thread/${u}`)})}function AJ(){return o.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 14 14",fill:"none",stroke:m.muted,strokeWidth:"1.5",style:{flex:"none"},children:[o.jsx("path",{d:"M3 1.5h5.5L11.5 4v8.5h-8.5z"}),o.jsx("path",{d:"M8.5 1.5V4H11"})]})}function G3({open:e=!1,color:t=m.faint}){return o.jsx("svg",{width:"9",height:"9",viewBox:"0 0 10 10",fill:"none",stroke:t,strokeWidth:"1.6",style:{flex:"none",transform:e?"rotate(90deg)":"none",transition:"transform .15s ease"},children:o.jsx("path",{d:"M3.5 1.5 7 5 3.5 8.5"})})}function X3({row:e,last:t,onOpen:n}){return o.jsxs("div",{role:"button",onClick:()=>n(e.path),style:{display:"flex",alignItems:"center",gap:9,padding:"10px 13px",borderBottom:t?void 0:"1px solid var(--proto-alt)",cursor:"pointer"},children:[o.jsx(AJ,{}),o.jsx("span",{style:{font:`500 12px ${N}`,color:m.body,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name}),o.jsx("span",{style:{marginLeft:"auto",font:`400 9.5px ${N}`,color:m.faint,flex:"none"},children:e.time}),o.jsx(G3,{color:m.faint})]})}function J3({children:e}){return o.jsx($e,{tone:"default",padding:0,style:{overflow:"hidden"},children:e})}function DJ({dir:e,copy:t,open:n,onToggle:r,onOpen:i}){return o.jsxs(J3,{children:[o.jsxs("div",{role:"button","aria-expanded":n,onClick:()=>r(e.name),style:{display:"flex",alignItems:"center",padding:"9px 13px",borderBottom:n?"1px solid var(--proto-line-2)":void 0,cursor:"pointer"},children:[o.jsxs("span",{style:{fontSize:12,fontWeight:650,color:m.ink},children:[e.name,"/"]}),o.jsx("span",{style:{font:`400 9.5px ${N}`,color:m.faint,marginLeft:7},children:e.entryCount}),o.jsx("span",{style:{marginLeft:"auto",flex:"none"},children:o.jsx(G3,{open:n})})]}),n&&(e.entries.length===0?o.jsx("div",{style:{padding:"10px 13px",font:`400 11px ${N}`,color:m.faint},children:t.emptyDir}):e.entries.map((s,a)=>o.jsx(X3,{row:s,last:a===e.entries.length-1,onOpen:i},s.path)))]})}function NJ({vm:e,copy:t,openDirs:n,onToggleDir:r,onBack:i,onOpenFile:s}){return o.jsxs(o.Fragment,{children:[o.jsx(En,{onBack:i,trailing:o.jsxs("span",{style:{font:`400 9.5px ${N}`,color:m.faint},children:["memory/ · ",e.fileCount," ",t.filesUnit]}),children:o.jsx("div",{style:{fontSize:16,fontWeight:650,color:m.ink,letterSpacing:"-.01em"},children:t.title})}),o.jsx(gn,{gap:10,children:e.isEmpty?o.jsx("div",{style:{padding:"40px 0",textAlign:"center",color:m.faint,fontSize:13},children:t.empty}):o.jsxs(o.Fragment,{children:[e.core.length>0&&o.jsxs(J3,{children:[o.jsx("div",{style:{display:"flex",alignItems:"center",padding:"9px 13px",borderBottom:"1px solid var(--proto-line-2)"},children:o.jsx("span",{style:{fontSize:12,fontWeight:650,color:m.ink},children:t.core})}),e.core.map((a,l)=>o.jsx(X3,{row:a,last:l===e.core.length-1,onOpen:s},a.path))]}),e.dirs.map(a=>o.jsx(DJ,{dir:a,copy:t,open:n.has(a.name),onToggle:r,onOpen:s},a.name)),o.jsx("div",{style:{font:`400 9.5px ${N}`,color:m.faint,padding:"0 4px"},children:t.footer})]})})]})}function _J(e,t=Date.now()){const n=(e==null?void 0:e.files)??[],r=(e==null?void 0:e.dirs)??[],i=n.map(l=>({name:l.name,path:l.name,time:Mr(l.modifiedAt,t)})),s=r.map(l=>({name:l.name,entryCount:l.entryCount,entries:(l.entries??[]).map(c=>({name:c.name,path:`${l.name}/${c.name}`,time:Mr(c.modifiedAt,t)}))}));return{fileCount:n.length+r.reduce((l,c)=>l+c.entryCount,0),core:i,dirs:s,isEmpty:i.length===0&&s.length===0}}const $J={en:{title:"Project memory",core:"Core",filesUnit:"files",emptyDir:"Empty",footer:"Tap a file for a read-only preview · agent writes to behavioral content (rules/skills) go through approval",empty:"No project memory yet"},zh:{title:"项目记忆",core:"核心",filesUnit:"个文件",emptyDir:"空",footer:"点文件只读预览 · agent 写入行为性内容(规则/技能)走审批",empty:"暂无项目记忆"}};function FJ(){const e=le(),t=ze(),n=ut(),r=Lt(n,$J),i=Date.now(),{currentProjectId:s}=Bn(),a=Y({...e.memory.tree.queryOptions({projectId:s??""}),enabled:!!s}),l=p.useMemo(()=>_J(a.data,i),[a.data,i]),[c,d]=p.useState(()=>new Set),u=p.useCallback(f=>{d(h=>{const g=new Set(h);return g.has(f)?g.delete(f):g.add(f),g})},[]);return o.jsx(gt,{label:"1j 项目记忆",children:a.isLoading?o.jsx("div",{style:{padding:16,color:m.muted,fontSize:13},children:r.empty}):o.jsx(NJ,{vm:l,copy:r,openDirs:c,onToggleDir:u,onBack:()=>t("/m/project"),onOpenFile:f=>t(`/m/memory/file?path=${encodeURIComponent(f)}`)})})}function zJ({basename:e,metaLine:t,content:n,status:r,copy:i,onBack:s}){return o.jsxs("div",{"data-screen-label":"1j 项目记忆 · 文件",style:{height:"100%",display:"flex",flexDirection:"column",boxSizing:"border-box",background:m.canvas},children:[o.jsx(En,{onBack:s,children:o.jsxs("div",{style:{minWidth:0},children:[o.jsx("div",{style:{font:`600 14px ${N}`,color:m.ink,letterSpacing:"-.01em",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e}),t&&o.jsx("div",{style:{font:`400 10px ${N}`,color:m.faint,marginTop:1,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:t})]})}),o.jsxs("div",{style:{flex:1,minHeight:0,overflow:"auto",background:"var(--proto-card)"},children:[r==="loading"&&o.jsx("div",{style:{padding:16,font:`400 12px ${N}`,color:m.faint},children:i.loading}),r==="error"&&o.jsx("div",{style:{padding:16,fontSize:12.5,color:m.fail},children:i.error}),r==="empty"&&o.jsx("div",{style:{padding:16,font:`400 12px ${N}`,color:m.faint},children:i.empty}),r==="ready"&&o.jsx("div",{style:{padding:"16px 18px calc(28px + env(safe-area-inset-bottom))",fontSize:13,lineHeight:1.7,color:m.body},children:o.jsx(Si,{text:n})})]})]})}function BJ(e){const t=e.split("/").filter(Boolean);return t.length?t[t.length-1]:e}function WJ(e){if(e==null||!Number.isFinite(e)||e<0)return"";if(e<1024)return`${e} B`;const t=e/1024;return t<1024?`${Qj(t)} KB`:`${Qj(t/1024)} MB`}function Qj(e){const t=e.toFixed(1);return t.endsWith(".0")?t.slice(0,-2):t}function UJ(e,t=Date.now()){if(!e)return"";const n=Mr(e.modifiedAt,t),r=WJ(e.sizeBytes);return[e.path,n,r].filter(i=>i&&i.length>0).join(" · ")}const HJ={en:{loading:"Loading file…",error:"Couldn't read this file",empty:"(empty file)"},zh:{loading:"正在加载文件…",error:"无法读取该文件",empty:"(空文件)"}};function VJ(){const e=le(),t=ze(),n=ut(),r=Lt(n,HJ),i=Date.now(),[s]=UD(),a=s.get("path")??"",{currentProjectId:l}=Bn(),c=Y({...e.memory.file.queryOptions({projectId:l??"",path:a}),enabled:!!l&&!!a}),d=c.data,u=BJ(a),f=p.useMemo(()=>UJ(d,i),[d,i]),h=!a||c.isError?"error":c.isLoading||!d?"loading":d.content.length===0?"empty":"ready";return o.jsx(zJ,{basename:u,metaLine:f,content:(d==null?void 0:d.content)??"",status:h,copy:r,onBack:()=>t("/m/memory")})}function qJ({vm:e,copy:t}){return o.jsxs("span",{style:{display:"flex",alignItems:"center",gap:5,fontSize:10,fontWeight:600,color:m.done},children:[o.jsx(li,{color:m.done,size:6}),t.daemon," · ",e.onlineCount,"/",e.total," ",t.onlineWord]})}function KJ({card:e,copy:t}){return o.jsxs($e,{tone:"default",padding:0,style:{overflow:"hidden"},children:[o.jsxs("div",{style:{padding:"11px 13px 9px",borderBottom:`1px solid ${m.divider}`},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[o.jsx("span",{style:{font:`600 12.5px ${N}`,color:m.ink},children:e.name}),o.jsx("span",{style:{font:`400 9.5px ${N}`,color:m.faint},children:e.os}),o.jsx("span",{style:{marginLeft:"auto",flex:"none"},children:o.jsx(en,{tone:"done",children:t.online})})]}),o.jsxs("div",{style:{font:`400 9.5px ${N}`,color:m.muted,marginTop:4},children:[t.hb," ",e.heartbeat]})]}),e.gpuCount!==null&&e.gpuCount>0&&o.jsx("div",{style:{padding:"10px 13px",borderBottom:`1px solid ${m.divider}`},children:o.jsxs("span",{style:{font:`500 10px ${N}`,color:m.sub},children:[e.gpuCount," ",t.gpu]})}),e.liveRuns>0&&o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"9px 13px"},children:[o.jsx(li,{color:m.run,size:6,pulse:!0}),o.jsxs("span",{style:{font:`500 11px ${N}`,color:m.body},children:[e.liveRuns," ",t.running]})]})]})}function Yj({children:e,onClick:t}){return o.jsx("button",{type:"button",onClick:t,style:{flex:1,height:38,borderRadius:10,border:"1.5px solid var(--proto-line-3)",background:"var(--proto-card)",color:m.ink,fontSize:12.5,fontWeight:600,boxSizing:"border-box",cursor:"pointer"},children:e})}function QJ({card:e,copy:t,onRetry:n,onLogs:r}){return o.jsxs($e,{tone:"fail",padding:"11px 13px",children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[o.jsx("span",{style:{font:`600 12.5px ${N}`,color:m.sub},children:e.name}),o.jsx("span",{style:{font:`400 9.5px ${N}`,color:m.faint},children:e.os}),o.jsx("span",{style:{marginLeft:"auto",flex:"none"},children:o.jsx(en,{tone:"failed",children:t.offline})})]}),o.jsxs("div",{style:{font:`400 9.5px ${N}`,color:m.muted,marginTop:4},children:[t.lastHb," ",e.heartbeat]}),o.jsxs("div",{style:{display:"flex",gap:8,marginTop:10},children:[o.jsx(Yj,{onClick:n?()=>n(e.name):void 0,children:t.retry}),o.jsx(Yj,{onClick:r?()=>r(e.name):void 0,children:t.logs})]})]})}function YJ({vm:e,copy:t}){return o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,padding:"2px 4px",font:`400 9.5px ${N}`,color:m.faint},children:[o.jsxs("span",{children:["machines.json · ",e.total," ",t.registered]}),o.jsx("span",{style:{marginLeft:"auto",color:m.muted},children:t.editDesktop})]})}function GJ({vm:e,copy:t,onBack:n,onRetry:r,onLogs:i}){return o.jsxs(o.Fragment,{children:[o.jsx(En,{onBack:n,trailing:o.jsx(qJ,{vm:e,copy:t}),children:o.jsx("div",{style:{fontSize:16,fontWeight:650,color:m.ink,letterSpacing:"-.01em"},children:t.title})}),o.jsxs(gn,{gap:10,children:[e.cards.length===0&&o.jsx("div",{style:{padding:"40px 0",textAlign:"center",color:m.faint,fontSize:13},children:t.empty}),e.cards.map(s=>s.online?o.jsx(KJ,{card:s,copy:t},s.name):o.jsx(QJ,{card:s,copy:t,onRetry:r,onLogs:i},s.name)),e.cards.length>0&&o.jsx(YJ,{vm:e,copy:t})]})]})}function XJ(e,t){if(!e)return"—";const n=Date.parse(e);if(Number.isNaN(n))return"—";const r=t-n;if(r<0)return"—";const i=Math.floor(r/1e3);if(i<60)return`${i}s 前`;const s=Math.floor(i/60);if(s<60)return`${s}m 前`;const a=Math.floor(s/60);return a<24?`${a}h 前`:`${Math.floor(a/24)}d 前`}function JJ(e){return{name:e.name,online:e.online,liveRuns:e.liveRuns,gpuCount:e.gpuCount,os:e.os,connectedAt:e.online?e.connectedAt:null}}function ZJ(e,t=Date.now()){const n=e.map(r=>{const i=JJ(r);return{name:i.name,online:i.online,os:i.os,gpuCount:i.gpuCount,liveRuns:i.liveRuns,heartbeat:XJ(r.lastHeartbeat,t)}});return{cards:n,onlineCount:n.filter(r=>r.online).length,total:n.length}}const eZ={en:{title:"Machines",online:"Online",offline:"Offline",hb:"HB",lastHb:"last HB",gpu:"GPU",running:"running",daemon:"daemon",onlineWord:"online",retry:"Retry",logs:"Logs",registered:"registered",editDesktop:"edit on desktop",empty:"No machines"},zh:{title:"机器",online:"在线",offline:"离线",hb:"心跳",lastHb:"上次心跳",gpu:"GPU",running:"运行中",daemon:"daemon",onlineWord:"在线",retry:"重试连接",logs:"查看日志",registered:"台注册",editDesktop:"编辑走桌面设置",empty:"暂无机器"}};function tZ(){const e=le(),t=ze(),n=ut(),r=Lt(n,eZ),i=Date.now(),s=Y(e.machines.list.queryOptions({})),a=p.useMemo(()=>s.data??[],[s.data]),l=p.useMemo(()=>ZJ(a,i),[a,i]);return o.jsx(gt,{label:"1k 机器",children:s.isLoading?o.jsx("div",{style:{padding:16,color:m.muted,fontSize:13},children:r.empty}):o.jsx(GJ,{vm:l,copy:r,onBack:()=>t("/m/settings")})})}function nZ({copy:e}){return o.jsxs("span",{style:{display:"flex",alignItems:"center",gap:5,fontSize:10,color:m.done,fontWeight:600},children:[o.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:m.done}}),e.daemonStatus]})}function pu({children:e,opacity:t}){return o.jsx("div",{style:{background:m.card,border:`1px solid ${m.hairline}`,borderRadius:13,overflow:"hidden",opacity:t},children:e})}function Ln(e){return{display:"flex",alignItems:"center",gap:10,padding:"12px 13px",borderBottom:e?`1px solid ${m.divider}`:void 0}}const To={fontSize:14,fontWeight:600,color:m.ink},fu={font:`400 10px ${N}`,color:m.muted,marginTop:2},$i={fontSize:13,color:m.faint,flex:"none"};function Gj({on:e,label:t}){return o.jsx("div",{role:"switch","aria-checked":e,"aria-readonly":!0,"aria-label":t,title:"Reflects the real env flag — read-only (no config.set for .env)",style:{width:44,height:26,borderRadius:999,background:e?m.done:"var(--proto-line-3)",position:"relative",flex:"none",cursor:"default"},children:o.jsx("span",{style:{position:"absolute",top:2,[e?"right":"left"]:2,width:22,height:22,borderRadius:"50%",background:"var(--ink-solid-bg)",boxShadow:"0 1px 3px rgba(16,24,40,.2)"}})})}function Zx({children:e}){return o.jsx("span",{style:{marginLeft:"auto",fontSize:9.5,fontWeight:600,padding:"1.5px 7px",borderRadius:999,background:m.gray,color:m.grayInk,flex:"none"},children:e})}function Z3({value:e,options:t,onChange:n,ariaLabel:r}){return o.jsx("div",{role:"group","aria-label":r,style:{display:"flex",border:`1px solid ${m.hairline}`,borderRadius:6,overflow:"hidden",flex:"none"},children:t.map(i=>{const s=e===i.id;return o.jsx("span",{role:"button","aria-pressed":s,onClick:()=>n(i.id),style:{fontSize:11,fontWeight:600,padding:"3px 10px",cursor:"pointer",background:s?"var(--ink-solid-bg)":"transparent",color:s?"var(--ink-solid-fg)":m.muted},children:i.label},i.id)})})}function rZ({lang:e,onSetLang:t}){return o.jsx(Z3,{ariaLabel:"Language",value:e,options:[{id:"en",label:"EN"},{id:"zh",label:"中"}],onChange:t})}function oZ({theme:e,onSetTheme:t,lightLabel:n,darkLabel:r}){return o.jsx(Z3,{ariaLabel:"Theme",value:e,options:[{id:"light",label:n},{id:"dark",label:r}],onChange:t})}function iZ({vm:e,copy:t,onOpenHooks:n}){return o.jsxs("div",{role:"button","aria-label":t.hooks,onClick:n,style:{...Ln(!1),gap:9,cursor:"pointer"},children:[o.jsxs("span",{style:{fontSize:13,color:m.sub},children:[t.hooks," · ",e.hooks.length]}),o.jsx(Zx,{children:t.desktopEdit}),o.jsx("span",{style:$i,children:"›"})]})}function sZ({vm:e,copy:t,lang:n,onSetLang:r,theme:i,onSetTheme:s,onBack:a,onOpenDaemon:l,onlineMachines:c,onOpenMachines:d,onOpenHooks:u,accountsSummary:f,onOpenAccounts:h,profileSheet:g,onOpenProfile:v,onCloseProfile:x,onPickProfile:b}){const j=H(),y=[e.profileName,e.profileModel,e.profileThinking].filter(Boolean).join(" · "),w=t.platform+(e.platforms.length?`(${e.platforms.join(", ")})`:"");return o.jsxs(gt,{label:"1l 设置",header:o.jsx(En,{onBack:a,trailing:o.jsx(nZ,{copy:t}),children:o.jsx("div",{style:{fontSize:16,fontWeight:650,color:m.ink,letterSpacing:"-.01em"},children:t.title})}),children:[o.jsxs(gn,{gap:10,children:[o.jsxs(pu,{children:[o.jsxs("div",{style:Ln(!0),onClick:l,children:[o.jsx("div",{style:{width:34,height:34,borderRadius:9,background:m.doneBg,display:"flex",alignItems:"center",justifyContent:"center",flex:"none"},children:o.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:m.done}})}),o.jsxs("div",{style:{minWidth:0,flex:1},children:[o.jsx("div",{style:To,children:t.daemon}),e.daemonHost&&o.jsx("div",{style:fu,children:e.daemonHost})]}),o.jsx("span",{style:{...$i,cursor:"pointer"},children:"›"})]}),o.jsxs("div",{role:"button","aria-label":t.machines,onClick:d,style:{...Ln(!0),gap:9,cursor:"pointer"},children:[o.jsxs("span",{style:{fontSize:13,color:m.sub},children:[t.machines," · ",c," ",t.machinesOk]}),o.jsx("span",{style:{marginLeft:"auto",...$i},children:"›"})]}),o.jsxs("div",{style:Ln(!1),children:[o.jsx("div",{style:{width:34,height:34,borderRadius:9,background:m.runBg,color:m.run,display:"flex",alignItems:"center",justifyContent:"center",font:`600 11px ${N}`,flex:"none"},children:"P"}),o.jsxs("div",{style:{minWidth:0,flex:1},children:[o.jsx("div",{style:To,children:t.profileTitle}),y&&o.jsx("div",{style:fu,children:y})]}),o.jsx("span",{role:"button",onClick:v,style:{font:`500 10px ${N}`,color:m.run,flex:"none",cursor:"pointer"},children:t.switchLabel})]})]}),o.jsxs(pu,{children:[o.jsxs("div",{style:{...Ln(!0),gap:0},children:[o.jsxs("div",{style:{minWidth:0,flex:1},children:[o.jsx("div",{style:To,children:t.budget}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:6},children:[o.jsx("div",{style:{flex:1,height:5,borderRadius:999,background:"var(--proto-line-2)",overflow:"hidden"},children:o.jsx("div",{style:{width:e.budgetBarPct,height:"100%",background:m.run}})}),o.jsxs("span",{style:{font:`500 10px ${N}`,color:m.ink,flex:"none"},children:[e.budgetSpendLabel," ",t.budgetUnit]})]})]}),o.jsx("span",{style:{...$i,paddingLeft:10},children:"›"})]}),o.jsxs("div",{style:Ln(!0),children:[o.jsxs("div",{style:{minWidth:0,flex:1},children:[o.jsx("div",{style:To,children:t.notify}),o.jsx("div",{style:fu,children:t.notifySub})]}),o.jsx(Gj,{on:e.notifyOn,label:t.notify})]}),o.jsxs("div",{style:Ln(!0),children:[o.jsxs("div",{style:{minWidth:0,flex:1},children:[o.jsx("div",{style:To,children:t.autoResume}),o.jsx("div",{style:fu,children:t.autoResumeSub})]}),o.jsx(Gj,{on:e.autoResumeOn,label:t.autoResume})]}),o.jsxs("div",{style:Ln(!0),children:[o.jsx("div",{style:{minWidth:0,flex:1},children:o.jsx("div",{style:To,children:t.language})}),o.jsx(rZ,{lang:n,onSetLang:r})]}),o.jsxs("div",{style:Ln(!1),children:[o.jsx("div",{style:{minWidth:0,flex:1},children:o.jsx("div",{style:To,children:t.theme})}),o.jsx(oZ,{theme:i,onSetTheme:s,lightLabel:t.themeLight,darkLabel:t.themeDark})]})]}),o.jsx(pu,{children:o.jsxs("button",{type:"button","data-accounts-entry":"mobile","aria-label":j.accountsTitle,onClick:h,style:{...Ln(!1),cursor:"pointer",width:"100%",border:0,background:"transparent",textAlign:"left",font:"inherit"},children:[o.jsx("div",{style:{minWidth:0,flex:1},children:o.jsxs("div",{style:To,children:[j.accountsTitle," · CC ",f.claudeLoggedIn?j.accountsConnectedMark:j.accountsDisconnected," · ",j.accountsPiSummary.replace("{count}",String(f.piLoggedInCount))]})}),o.jsx("span",{style:$i,children:"›"})]})}),o.jsxs(pu,{opacity:.92,children:[o.jsxs("div",{style:{...Ln(!0),gap:9},children:[o.jsx("span",{style:{fontSize:13,color:m.sub},children:w}),o.jsx(Zx,{children:t.desktopEdit}),o.jsx("span",{style:$i,children:"›"})]}),o.jsxs("div",{style:{...Ln(!0),gap:9},children:[o.jsxs("span",{style:{fontSize:13,color:m.sub},children:[t.templates," · ",e.templatesCount]}),o.jsx(Zx,{children:t.desktopEdit}),o.jsx("span",{style:$i,children:"›"})]}),o.jsx(iZ,{vm:e,copy:t,onOpenHooks:u})]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,padding:"2px 4px",font:`400 9.5px ${N}`,color:m.faint},children:[o.jsx("span",{children:t.footerBrand}),o.jsxs("span",{style:{marginLeft:"auto"},children:["build ",Qx]})]})]}),g&&o.jsxs(Ti,{onClose:x,children:[o.jsx("div",{style:{display:"flex",alignItems:"baseline",padding:"0 2px 10px"},children:o.jsx("span",{style:{fontSize:17,fontWeight:700,color:m.ink,letterSpacing:"-.01em"},children:t.profileSheetTitle})}),o.jsx("div",{style:{background:"var(--proto-card)",border:`1px solid ${m.hairline}`,borderRadius:13,overflow:"hidden"},children:g.map((k,S)=>o.jsxs("div",{onClick:()=>b(k.name),style:{display:"flex",alignItems:"center",gap:10,padding:"12px 13px",borderBottom:S<g.length-1?"1px solid var(--proto-line-soft)":void 0,cursor:"pointer"},children:[o.jsxs("div",{style:{minWidth:0,flex:1},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7},children:[o.jsx("span",{style:{font:`600 13px ${N}`,color:m.ink},children:k.name}),k.current&&o.jsx("span",{style:{fontSize:9.5,fontWeight:600,padding:"1.5px 7px",borderRadius:999,background:m.runBg,color:m.run},children:t.profileSheetCurrent})]}),o.jsx("div",{style:{font:`400 10px ${N}`,color:m.muted,marginTop:3},children:k.sub})]}),k.current&&o.jsx("span",{style:{fontSize:15,fontWeight:700,color:m.run,flex:"none"},children:"✓"})]},k.name))}),o.jsx("div",{style:{font:`400 9.5px ${N}`,color:m.faint,padding:"9px 4px 0"},children:t.profileSheetFooter})]})]})}const aZ="CORTEX_TURN_NOTIFY",lZ="CORTEX_AUTO_RESUME";function Xj(e,t){return e.some(n=>n.key===t&&n.present)}function cZ(e,t){var c;const n=e.profiles,r=(n==null?void 0:n.defaultProfile)??null,i=r?(n==null?void 0:n.profiles.find(d=>d.name===r))??null:null,s=((c=e.budget)==null?void 0:c.daily_usd)??null,a=(t==null?void 0:t.today)??0,l=[];return Xa(e.env,"SLACK_")&&l.push("slack"),Xa(e.env,"FEISHU_")&&l.push("feishu"),{daemonHost:null,profileName:r,profileModel:(i==null?void 0:i.model)??null,profileThinking:(i==null?void 0:i.thinking)??null,profiles:(n==null?void 0:n.profiles)??[],budgetSpendLabel:`${zc(a)} / ${zc(s)}`,budgetBarPct:_x(a,s),notifyOn:Xj(e.env,aZ),autoResumeOn:Xj(e.env,lZ),platforms:l,templatesCount:e.threadTemplates.templates.length,hooks:e.hooks}}const dZ={en:{title:"Settings",daemonStatus:"daemon · connected",daemon:"Daemon",machines:"Machines",machinesOk:"online",profileTitle:"Profile (global default)",switchLabel:"Switch",profileSheetTitle:"Global default profile",profileSheetCurrent:"current",profileSheetFooter:"Applies to new sessions and new threads",theme:"Theme",themeLight:"Light",themeDark:"Dark",budget:"Budget",budgetUnit:"/day",notify:"Notifications",notifySub:"push on · long task > 10m · approvals instant",autoResume:"Auto-resume on limit",autoResumeSub:"resume threads after rate-limit clears",language:"Language",platform:"Platform",desktopEdit:"Edit on desktop",templates:"Thread templates",hooks:"Hooks",footerBrand:"cortex mobile"},zh:{title:"设置",daemonStatus:"daemon · 已连接",daemon:"Daemon",machines:"机器",machinesOk:"台正常",profileTitle:"Profile(全局默认)",switchLabel:"切换",profileSheetTitle:"全局默认 Profile",profileSheetCurrent:"当前",profileSheetFooter:"切换后新会话 / 新线程使用",theme:"主题",themeLight:"浅色",themeDark:"深色",budget:"预算",budgetUnit:"日",notify:"通知",notifySub:"推送开 · 长任务 > 10m · 审批即时",autoResume:"限额自动续跑",autoResumeSub:"rate-limit 解除后自动恢复线程",language:"语言",platform:"Platform",desktopEdit:"桌面编辑",templates:"Thread templates",hooks:"钩子",footerBrand:"cortex mobile"}},uZ={budget:null,profiles:null,threadTemplates:{agents:[],templates:[],shells:[]},hooks:[],env:[]};function pZ(){const e=le(),t=je(),n=ze(),r=ut(),i=l4(),s=O0(),a=A0(),l=Lt(r,dZ),c=Y(e.config.get.queryOptions({})),d=Y(e.cost.summary.queryOptions({})),u=Y(e.auth.status.queryOptions({})),f=Y(e.machines.list.queryOptions({})),h=mX(f.data??[]),g=p.useMemo(()=>cZ(c.data??uZ,d.data),[c.data,d.data]),v=p.useMemo(()=>u.data?Y0(u.data).summary:{claudeLoggedIn:!1,piLoggedInCount:0},[u.data]),[x,b]=p.useState(!1),j=xe(e.config.set.mutationOptions({onSuccess:()=>t.invalidateQueries(e.config.get.queryFilter({}))})),y=x?B3(g.profiles,g.profileName??""):null,w=k=>{b(!1),k!==g.profileName&&j.mutate({section:"profiles",value:{defaultProfile:k}})};return c.isLoading?o.jsx(gt,{label:"1l 设置",children:o.jsx("div",{style:{padding:16,color:m.muted,fontSize:13},children:l.title})}):o.jsx(sZ,{vm:g,copy:l,lang:r,onSetLang:i,theme:s,onSetTheme:a,onBack:()=>n("/m/project"),onOpenDaemon:()=>n("/m/daemon"),onlineMachines:h,onOpenMachines:()=>n("/m/machines"),onOpenHooks:()=>n("/m/settings/hooks"),accountsSummary:v,onOpenAccounts:()=>n("/m/settings/accounts"),profileSheet:y,onOpenProfile:()=>b(!0),onCloseProfile:()=>b(!1),onPickProfile:w})}function em(e,t,n){return t==="api_key"?e.authLoginApiKey:n==="claude"?e.authLoginSubscription:e.authLoginOAuth}function eE({value:e}){const t=H();return o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4,minWidth:0},children:[o.jsx("span",{children:o.jsx(en,{tone:e.tone,children:t[e.labelKey]})}),o.jsxs("span",{style:{font:`400 9.5px ${N}`,color:m.muted,overflowWrap:"anywhere"},children:[t.accountsSource,": ",e.source??"—"]}),e.expiresAt?o.jsxs("span",{style:{font:`400 9.5px ${N}`,color:m.muted,overflowWrap:"anywhere"},children:[t.accountsExpires,": ",e.expiresAt]}):null]})}function Jj({children:e,target:t,action:n,disabled:r,onClick:i}){return o.jsx("button",{type:"button","data-auth-action":n,"data-backend":t.backend,"data-provider":t.provider,"data-auth-type":t.authType,disabled:r,onClick:()=>i(t),style:{border:`1px solid ${n==="logout"?"var(--proto-danger-bg)":m.run}`,borderRadius:8,padding:"6px 9px",background:m.card,color:n==="logout"?m.fail:m.run,fontSize:10.5,fontWeight:650,cursor:r?"not-allowed":"pointer",opacity:r?.45:1},children:e})}function tE({backend:e,provider:t,loginTypes:n,logoutTypes:r,disabled:i,onLogin:s,onLogout:a}){const l=H(),c=d=>({backend:e,provider:t,authType:d});return o.jsxs("div",{style:{display:"flex",gap:6,flexWrap:"wrap",marginTop:8},children:[n.map(d=>o.jsxs(Jj,{target:c(d),action:"login",disabled:i,onClick:s,children:[l.accountsLogin," ",em(l,d,e)]},`login:${d}`)),r.map(d=>o.jsxs(Jj,{target:c(d),action:"logout",disabled:i,onClick:a,children:[l.accountsLogout," ",em(l,d,e)]},`logout:${d}`))]})}function fZ({account:e,actionsDisabled:t,onLogin:n,onLogout:r}){const i=H();return o.jsxs($e,{children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,marginBottom:9},children:[o.jsx(kf,{provider:"claude-code",label:"Claude Code",size:16}),o.jsx("span",{style:{fontSize:14,fontWeight:700,color:m.ink},children:"Claude Code"}),e.inUse?o.jsx(en,{tone:"done",children:i.accountsInUse}):null]}),e.slots.map((s,a)=>o.jsxs("div",{style:{padding:"9px 0",borderTop:a>0?`1px solid ${m.divider}`:void 0},children:[o.jsx("div",{style:{font:`600 11px ${N}`,color:m.ink,marginBottom:7},children:em(i,s.authType,"claude")}),o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:7},children:s.credentials.map((l,c)=>o.jsx(eE,{value:l},`${l.source??"none"}:${c}`))}),o.jsx(tE,{backend:"claude",provider:e.provider,loginTypes:s.canLogin?[s.authType]:[],logoutTypes:s.canLogout?[s.authType]:[],disabled:t,onLogin:n,onLogout:r})]},s.authType))]})}function hZ({provider:e,actionsDisabled:t,onLogin:n,onLogout:r}){const i=H(),s={...e.status,source:e.source,expiresAt:e.expiresAt};return o.jsxs($e,{children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:[o.jsx(kf,{provider:e.provider,label:e.label,size:15}),o.jsx("span",{style:{fontSize:13,fontWeight:700,color:m.ink},children:e.label}),o.jsx("span",{style:{font:`400 9px ${N}`,color:m.muted},children:e.provider}),e.loginTypes.map(a=>o.jsx(en,{tone:"running",children:a==="api_key"?i.authLoginApiKey:i.authLoginOAuth},a))]}),o.jsx("div",{style:{marginTop:8},children:o.jsx(eE,{value:s})}),o.jsx(tE,{backend:"pi",provider:e.provider,loginTypes:e.loginTypes,logoutTypes:e.logoutTypes,disabled:t,onLogin:n,onLogout:r})]})}function gZ({vm:e,onBack:t,onLogin:n,onLogout:r,actionsDisabled:i}){const s=H();return o.jsxs(o.Fragment,{children:[o.jsx(En,{onBack:t,trailing:o.jsxs("span",{style:{font:`500 10px ${N}`,color:m.muted},children:[e.piProviders.length," PI"]}),children:o.jsx("div",{style:{fontSize:16,fontWeight:650,color:m.ink},children:s.accountsTitle})}),o.jsxs(gn,{gap:14,children:[e.claude?o.jsx(fZ,{account:e.claude,actionsDisabled:i,onLogin:n,onLogout:r}):null,e.groups.map(a=>o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[o.jsxs(jd,{children:[s[a.labelKey]," · ",a.providers.length]}),a.providers.map(l=>o.jsx(hZ,{provider:l,actionsDisabled:i,onLogin:n,onLogout:r},l.provider))]},a.key)),e.piProviders.length===0?o.jsx($e,{children:o.jsx("span",{style:{fontSize:12,color:m.muted},children:s.accountsNoProviders})}):null]})]})}const xZ={accounts:[]};function mZ(){const e=H(),t=le(),n=ze(),r=je(),{toast:i}=dr(),{openLogin:s}=_0(),a=Y(t.auth.status.queryOptions({})),l=p.useMemo(()=>Y0(a.data??xZ),[a.data]),c=xe(t.auth.logout.mutationOptions({onSuccess:()=>{r.invalidateQueries(t.auth.status.queryFilter({})),i({title:e.accountsLogoutDone,tone:"done"})},onError:u=>i({title:`${e.accountsLogoutFailed}: ${u.message}`,tone:"failed"})})),d=u=>c.mutate(u);return o.jsx(gt,{label:e.accountsTitle,children:a.isLoading?o.jsx("div",{style:{padding:16,color:m.muted},children:e.accountsLoading}):a.isError?o.jsx("div",{style:{padding:16,color:m.fail},children:e.accountsLoadFailed}):o.jsx(gZ,{vm:l,onBack:()=>n("/m/settings"),onLogin:s,onLogout:d,actionsDisabled:c.isPending})})}const vZ={font:`600 12.5px ${N}`,color:m.ink,overflowWrap:"anywhere"},yZ={font:`400 9.5px ${N}`,color:m.muted,marginTop:3,overflowWrap:"anywhere"};function nE({targets:e}){return o.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:5},children:e.map(t=>o.jsx(en,{tone:"running",children:t},t))})}function bZ({row:e,copy:t,onOpen:n}){return o.jsxs($e,{onClick:()=>n(e.key),children:[o.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:8},children:[o.jsxs("div",{style:{minWidth:0,flex:1},children:[o.jsx("div",{style:vZ,children:e.id}),o.jsxs("div",{style:yZ,children:[e.event," · ",e.source]})]}),o.jsx("span",{style:{flex:"none"},children:o.jsx(en,{tone:e.enabled?"done":"cancelled",children:e.enabled?t.enabled:t.disabled})})]}),(e.mountsOn.length>0||e.scriptMissing)&&o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginTop:8,flexWrap:"wrap"},children:[o.jsx(nE,{targets:e.mountsOn}),e.scriptMissing&&o.jsx("span",{style:{marginLeft:"auto",flex:"none"},children:o.jsx(en,{tone:"failed",children:t.scriptMissing})})]})]})}function jZ({group:e,copy:t,onOpenHook:n}){return o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[o.jsxs(jd,{children:[t.group[e.key]," · ",e.rows.length]}),e.rows.map(r=>o.jsx(bZ,{row:r,copy:t,onOpen:n},r.key))]})}function wZ({label:e,children:t,divider:n=!0}){return o.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:10,padding:"9px 13px",borderBottom:n?`1px solid ${m.divider}`:void 0},children:[o.jsx("span",{style:{fontSize:11,color:m.muted,flex:"none",width:92},children:e}),o.jsx("span",{style:{font:`500 10.5px ${N}`,color:m.ink,minWidth:0,flex:1,overflowWrap:"anywhere"},children:t})]})}function kZ(e,t){var r,i;const n=[{label:t.field.event,value:e.event}];return((r=e.matcher)==null?void 0:r.kind)==="regex"&&n.push({label:t.field.matcher,value:e.matcher.value}),((i=e.matcher)==null?void 0:i.kind)==="filters"&&n.push({label:t.field.filters,value:o.jsx("span",{style:{display:"flex",flexDirection:"column",gap:2},children:e.matcher.entries.map(s=>o.jsxs("span",{children:[s.key," = ",s.value]},s.key))})}),e.run.kind==="none"?n.push({label:t.field.run,value:t.none}):n.push({label:e.run.kind==="script"?t.field.script:t.field.command,value:o.jsxs(o.Fragment,{children:[e.run.value,e.run.missing&&o.jsx("span",{style:{marginLeft:6},children:o.jsx(en,{tone:"failed",children:t.scriptMissing})})]})}),e.timeoutSec!==null&&n.push({label:t.field.timeout,value:`${e.timeoutSec}${t.secondUnit}`}),e.backends!==null&&n.push({label:t.field.backends,value:e.backends.join(", ")}),e.requiresTool!==null&&n.push({label:t.field.requiresTool,value:e.requiresTool}),e.result!==null&&n.push({label:t.field.result,value:e.result}),e.blocking!==null&&n.push({label:t.field.blocking,value:`${e.blocking.mode} · ${e.blocking.ttlMin}${t.minuteUnit}`}),n.push({label:t.field.mountsOn,value:o.jsx(nE,{targets:e.mountsOn})}),n.push({label:t.field.appliesAt,value:t.applies[e.appliesAt]}),n.push({label:t.field.source,value:e.source}),e.version!==null&&n.push({label:t.field.version,value:e.version}),e.fileName!==null&&n.push({label:t.field.fileName,value:e.fileName}),e.template!==null&&n.push({label:t.field.template,value:e.template}),e.phase!==null&&n.push({label:t.field.phase,value:e.phase}),n.push({label:t.field.order,value:String(e.order)}),n}function SZ({row:e,copy:t,onClose:n}){const r=kZ(e.detail,t);return o.jsxs(Ti,{onClose:n,children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"0 2px 10px"},children:[o.jsx("span",{style:{font:`700 15px ${N}`,color:m.ink,minWidth:0,overflowWrap:"anywhere"},children:e.id}),o.jsx("span",{style:{marginLeft:"auto",flex:"none"},children:o.jsx(en,{tone:e.enabled?"done":"cancelled",children:e.enabled?t.enabled:t.disabled})})]}),o.jsx("div",{style:{background:"var(--proto-card)",border:`1px solid ${m.hairline}`,borderRadius:13,overflow:"hidden"},children:r.map((i,s)=>o.jsx(wZ,{label:i.label,divider:s<r.length-1,children:i.value},i.label))}),o.jsx("div",{style:{font:`400 9.5px ${N}`,color:m.faint,padding:"9px 4px 0"},children:t.sheetFooter})]})}function CZ({vm:e,copy:t,sheetRow:n,onBack:r,onOpenHook:i,onCloseSheet:s}){return o.jsxs(o.Fragment,{children:[o.jsx(En,{onBack:r,trailing:o.jsxs("span",{style:{font:`500 10px ${N}`,color:m.muted},children:[e.enabledCount,"/",e.total," ",t.enabledWord]}),children:o.jsx("div",{style:{fontSize:16,fontWeight:650,color:m.ink,letterSpacing:"-.01em"},children:t.title})}),o.jsxs(gn,{gap:14,children:[e.groups.length===0&&o.jsx("div",{style:{padding:"40px 0",textAlign:"center",color:m.faint,fontSize:13},children:t.empty}),e.groups.map(a=>o.jsx(jZ,{group:a,copy:t,onOpenHook:i},a.key)),e.groups.length>0&&o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,padding:"2px 4px",font:`400 9.5px ${N}`,color:m.faint},children:[o.jsxs("span",{children:[e.total," ",t.countUnit]}),o.jsx("span",{style:{marginLeft:"auto",color:m.muted},children:t.editDesktop})]})]}),n&&o.jsx(SZ,{row:n,copy:t,onClose:s})]})}const EZ=["agent","cc","pi","cortex","template","other"],TZ=[{prefix:"agent:",key:"agent"},{prefix:"cc:",key:"cc"},{prefix:"pi:",key:"pi"},{prefix:"cortex:",key:"cortex"}];function PZ(e){var t;return e.source==="template-scoped"?"template":((t=TZ.find(n=>e.event.startsWith(n.prefix)))==null?void 0:t.key)??"other"}function RZ(e){return e.matcher!==null?{kind:"regex",value:e.matcher}:e.matcherFilters===null?null:{kind:"filters",entries:Object.entries(e.matcherFilters).map(([t,n])=>({key:t,value:n===null?"null":String(n)}))}}function IZ(e){return e.run.script!==null?{kind:"script",value:e.run.script,missing:e.scriptExists===!1}:e.run.command!==null?{kind:"command",value:e.run.command,missing:!1}:{kind:"none"}}function MZ(e){var t,n;return{id:e.id,event:e.event,matcher:RZ(e),run:IZ(e),timeoutSec:e.run.timeoutSec,backends:((t=e.scope)==null?void 0:t.backends)??null,requiresTool:((n=e.scope)==null?void 0:n.requiresTool)??null,result:e.result,blocking:e.blocking,source:e.source,version:e.version,fileName:e.fileName,order:e.order,mountsOn:e.mountsOn,appliesAt:e.appliesAt,template:e.template,phase:e.phase}}function Zj(e){return{key:`${e.id}#${e.order}`,id:e.id,event:e.event,source:e.source,enabled:e.enabled,mountsOn:e.mountsOn,scriptMissing:e.scriptExists===!1,detail:MZ(e)}}function LZ(e){const t=new Map;for(const r of e.hooks){const i=PZ(r),s=t.get(i);s?s.push(Zj(r)):t.set(i,[Zj(r)])}const n=[];for(const r of EZ){const i=t.get(r);i&&n.push({key:r,rows:i.sort((s,a)=>s.detail.order-a.detail.order)})}return{groups:n,total:e.hooks.length,enabledCount:e.hooks.filter(r=>r.enabled).length,missingScriptCount:e.hooks.filter(r=>r.scriptExists===!1).length}}const OZ={en:{title:"Hooks",enabledWord:"enabled",countUnit:"hooks",group:{agent:"AGENT EVENTS",cc:"CLAUDE CODE EVENTS",pi:"PI EVENTS",cortex:"CORTEX BUS EVENTS",template:"TEMPLATE-SCOPED",other:"OTHER EVENTS"},enabled:"Enabled",disabled:"Disabled",scriptMissing:"script missing",empty:"No mounted hooks",editDesktop:"Edit on desktop",none:"—",secondUnit:"s",minuteUnit:"min",field:{event:"Event",matcher:"Matcher",filters:"Filters",script:"Script",command:"Command",run:"Run",timeout:"Timeout",backends:"Backends",requiresTool:"Requires tool",result:"Result",blocking:"Blocking",source:"Source",version:"Version",fileName:"File",order:"Load order",mountsOn:"Mounts on",appliesAt:"Applies",template:"Template",phase:"Phase"},applies:{"next-agent":"Next agent start","server-restart":"Server restart"},sheetFooter:"Read-only on mobile — edit on desktop"},zh:{title:"钩子",enabledWord:"已启用",countUnit:"条钩子",group:{agent:"AGENT 事件",cc:"CLAUDE CODE 事件",pi:"PI 事件",cortex:"CORTEX 总线事件",template:"模板内联",other:"其他事件"},enabled:"已启用",disabled:"已停用",scriptMissing:"脚本缺失",empty:"暂无已挂载钩子",editDesktop:"桌面编辑",none:"—",secondUnit:"秒",minuteUnit:"分钟",field:{event:"事件",matcher:"匹配",filters:"过滤条件",script:"脚本",command:"命令",run:"执行",timeout:"超时",backends:"后端",requiresTool:"限定工具",result:"结果",blocking:"阻塞",source:"来源",version:"版本",fileName:"文件",order:"加载顺序",mountsOn:"挂载到",appliesAt:"生效",template:"模板",phase:"阶段"},applies:{"next-agent":"下次 agent 启动","server-restart":"需重启 server"},sheetFooter:"移动端只读 — 编辑请到桌面端"}},AZ={hooks:[]};function DZ(){const e=le(),t=ze(),n=ut(),r=Lt(n,OZ),i=Y(e.hooks.list.queryOptions({})),s=p.useMemo(()=>LZ(i.data??AZ),[i.data]),[a,l]=p.useState(null),c=p.useMemo(()=>a===null?null:s.groups.flatMap(d=>d.rows).find(d=>d.key===a)??null,[a,s]);return o.jsx(gt,{label:"1l-h 钩子",children:i.isLoading?o.jsx("div",{style:{padding:16,color:m.muted,fontSize:13},children:r.title}):o.jsx(CZ,{vm:s,copy:r,sheetRow:c,onBack:()=>t("/m/settings"),onOpenHook:l,onCloseSheet:()=>l(null)})})}function NZ(e){return e==="connected"?"done":e==="disconnected"?"failed":"waiting"}function _Z(e){return e==="connecting"||e==="reconnecting"}function $Z(e){return e==="running"?m.done:e==="unknown"?m.amber:m.fail}function FZ({proc:e,copy:t,border:n}){const r=t.dash;return o.jsxs("div",{style:{padding:"11px 13px 9px",borderBottom:n?`1px solid ${m.divider}`:void 0},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[o.jsx("span",{style:{width:7,height:7,borderRadius:"50%",background:$Z(e.status),flex:"none"}}),o.jsx("span",{style:{font:`600 12.5px ${N}`,color:m.ink},children:e.name}),e.label&&o.jsx("span",{style:{font:`400 9.5px ${N}`,color:m.muted},children:e.label}),o.jsxs("span",{style:{marginLeft:"auto",font:`400 9.5px ${N}`,color:m.muted},children:["pid ",e.pid??r,e.port!=null?` · :${e.port}`:""]})]}),o.jsxs("div",{style:{font:`400 9.5px ${N}`,color:m.muted,marginTop:4,paddingLeft:15},children:[t.uptimeLabel," ",e.uptime??r,e.extras.map(i=>` · ${i.k} ${i.v}`).join("")]})]})}const ew=2e3;function zZ({label:e,hint:t,disabled:n,onConfirm:r}){const[i,s]=p.useState(0),a=p.useRef(null),l=p.useRef(null),c=p.useRef(0),d=()=>{a.current&&clearTimeout(a.current),l.current&&cancelAnimationFrame(l.current),a.current=null,l.current=null,s(0)},u=()=>{if(n)return;c.current=Date.now();const h=()=>{const g=Math.min(1,(Date.now()-c.current)/ew);s(g),g<1&&(l.current=requestAnimationFrame(h))};l.current=requestAnimationFrame(h),a.current=setTimeout(()=>{d(),r()},ew)},f=i>0;return o.jsxs("button",{type:"button",disabled:n,onPointerDown:u,onPointerUp:d,onPointerLeave:d,onPointerCancel:d,style:{position:"relative",flex:1,height:44,borderRadius:11,border:`1.5px solid ${m.failBorder}`,background:"var(--proto-card)",color:m.fail,display:"flex",alignItems:"center",justifyContent:"center",fontSize:14,fontWeight:600,boxSizing:"border-box",overflow:"hidden",cursor:n?"default":"pointer",opacity:n?.5:1,touchAction:"none",userSelect:"none"},children:[o.jsx("span",{"aria-hidden":!0,style:{position:"absolute",left:0,top:0,bottom:0,width:`${i*100}%`,background:m.failBg,transition:f?void 0:"width .15s ease"}}),o.jsx("span",{style:{position:"relative"},children:f?t:e})]})}const tw={flex:1,height:44,borderRadius:11,border:"1.5px solid var(--proto-line-3)",background:"var(--proto-card)",color:m.ink,display:"flex",alignItems:"center",justifyContent:"center",fontSize:14,fontWeight:600,boxSizing:"border-box",cursor:"pointer"};function BZ({ev:e,copy:t}){return o.jsxs("div",{style:{display:"flex",gap:8},children:[o.jsx("span",{style:{color:m.faint,flex:"none"},children:e.time}),o.jsxs("span",{style:{color:e.tone==="fail"?m.amberText:m.sub},children:[e.ref," · ",t.status[e.status]]})]})}const WZ={connected:"connConnected",connecting:"connConnecting",reconnecting:"connReconnecting",disconnected:"connDisconnected"};function UZ({vm:e,copy:t,connStatus:n,restartState:r,showDisconnect:i,onBack:s,onSoftRestart:a,onHardRestart:l,onDisconnect:c}){const d=r==="pending";return o.jsxs(gt,{label:"1r Daemon 状态",children:[o.jsx(En,{onBack:s,children:o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:9},children:[o.jsx("span",{style:{fontSize:16,fontWeight:650,color:m.ink,letterSpacing:"-.01em"},children:t.title}),o.jsxs("span",{style:{display:"flex",alignItems:"center",gap:5},children:[_Z(n)&&o.jsx(li,{color:m.amber,pulse:!0}),o.jsx(en,{tone:NZ(n),children:t[WZ[n]]})]})]})}),o.jsxs(gn,{gap:10,children:[o.jsxs($e,{padding:0,style:{overflow:"hidden"},children:[e.processes.map((u,f)=>o.jsx(FZ,{proc:u,copy:t,border:f<e.processes.length-1},u.name)),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"10px 13px",font:`400 10px ${N}`,color:m.muted,flexWrap:"wrap",borderTop:`1px solid ${m.divider}`},children:[o.jsx("span",{children:t.threadsRunning(e.threadCount)}),o.jsx("span",{children:"·"}),o.jsx("span",{children:t.schedules(e.scheduleCount)})]})]}),o.jsxs($e,{padding:0,style:{overflow:"hidden"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"10px 13px",borderBottom:`1px solid ${m.divider}`},children:[o.jsx("span",{style:{fontSize:12,fontWeight:650,color:m.ink},children:t.recentTitle}),o.jsx("span",{style:{marginLeft:"auto",font:`400 9.5px ${N}`,color:m.faint},children:"executions.list"})]}),e.lastRestart===null&&e.events.length===0?o.jsx("div",{style:{padding:"14px 13px",font:`400 10px ${N}`,color:m.faint},children:t.recentEmpty}):o.jsxs("div",{style:{padding:"9px 13px",display:"flex",flexDirection:"column",gap:7,font:`400 10px/1.5 ${N}`},children:[e.lastRestart&&o.jsxs("div",{style:{display:"flex",gap:8},children:[o.jsx("span",{style:{color:m.faint,flex:"none"},children:e.lastRestart.time}),o.jsxs("span",{style:{color:m.sub},children:[t.lastRestartLabel,e.lastRestart.reason?` · ${e.lastRestart.reason}`:""]})]}),e.events.map(u=>o.jsx(BZ,{ev:u,copy:t},u.id))]}),o.jsx("div",{style:{padding:"0 13px 10px",font:`400 9px ${N}`,color:m.faint},children:t.recentGap})]}),o.jsxs($e,{padding:"12px 13px",children:[o.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[o.jsx("span",{style:{fontSize:13,fontWeight:600,color:m.ink},children:t.softRestart}),o.jsx("span",{style:{marginLeft:"auto",font:`400 9.5px ${N}`,color:m.faint},children:t.softNote(e.threadCount)})]}),o.jsxs("div",{style:{display:"flex",gap:8,marginTop:10},children:[o.jsx("button",{type:"button",disabled:d,onClick:a,style:{...tw,opacity:d?.5:1,cursor:d?"default":"pointer"},children:t.softRestart}),o.jsx(zZ,{label:t.forceKill,hint:t.holdHint,disabled:d,onConfirm:l})]}),o.jsx("div",{style:{font:`400 9px ${N}`,color:m.faint,marginTop:8},children:t.footerNote}),r==="success"&&o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginTop:8},children:[o.jsx(li,{color:m.done}),o.jsx("span",{style:{fontSize:11,fontWeight:600,color:m.done},children:t.sent})]}),r==="error"&&o.jsx("div",{style:{marginTop:8,fontSize:11,fontWeight:600,color:m.fail},children:t.failed})]}),i&&o.jsxs($e,{padding:"12px 13px",children:[o.jsx("button",{type:"button",onClick:c,style:{...tw,width:"100%"},children:t.disconnect}),o.jsx("div",{style:{font:`400 9px ${N}`,color:m.faint,marginTop:8,textAlign:"center"},children:t.disconnectNote})]})]})]})}const HZ=5,VZ=new Set(["failed","cancelled","stale"]);function qZ(e,t){if(e&&e.processes.length>0)return e.processes.map(r=>({name:r.name,label:r.label,status:r.status,pid:r.pid,port:r.port,uptime:r.uptime,extras:r.extras?Object.entries(r.extras).map(([i,s])=>({k:i,v:s})):[]}));const n=t?"running":"unknown";return[{name:"cortex-server",label:"",status:n,pid:null,port:null,uptime:null,extras:[]},{name:"cortex-daemon",label:"",status:n,pid:null,port:null,uptime:null,extras:[]}]}function KZ(e){var s,a,l,c;const t=e.now??Date.now(),n=e.executions.slice(0,HZ).map(d=>({id:d.id,time:Mr(d.startedAt,t),ref:d.taskId?`${d.type} · ${d.taskId}`:d.type,status:d.status,tone:VZ.has(d.status)?"fail":"default"})),r=((a=(s=e.daemon)==null?void 0:s.lastRestart)==null?void 0:a.at)??null,i=r?{time:Mr(r,t),reason:((c=(l=e.daemon)==null?void 0:l.lastRestart)==null?void 0:c.reason)??null}:null;return{ok:e.ok,threadCount:e.threads.length,scheduleCount:e.schedules.length,processes:qZ(e.daemon,e.ok),lastRestart:i,events:n}}const QZ={en:{title:"Daemon",connConnected:"connected",connConnecting:"connecting",connReconnecting:"reconnecting",connDisconnected:"disconnected",threadsRunning:e=>`${e} threads running`,schedules:e=>`schedules ${e}`,uptimeLabel:"uptime",dash:"—",lastRestartLabel:"Last restart",recentTitle:"Recent events",recentGap:"daemon event log not exposed on web — showing recent executions",recentEmpty:"No recent activity",status:{running:"running",completed:"completed",failed:"failed",cancelled:"cancelled",stale:"stale"},softRestart:"Soft restart",forceKill:"Force kill",softNote:e=>`pauses ${e} running thread(s)`,holdHint:"Keep holding…",footerNote:"Soft restart keeps thread state and auto-resumes · Force kill needs a 2s long-press; running threads are marked interrupted",sent:"Restart signal sent",failed:"Restart failed",disconnect:"Disconnect",disconnectNote:"Clears the saved server & token, returns to the login screen"},zh:{title:"Daemon",connConnected:"已连接",connConnecting:"连接中",connReconnecting:"正在重连",connDisconnected:"已断开",threadsRunning:e=>`${e} 线程运行中`,schedules:e=>`schedules ${e}`,uptimeLabel:"uptime",dash:"—",lastRestartLabel:"上次重启",recentTitle:"最近事件",recentGap:"Web 未提供 daemon 事件日志,以下为最近执行",recentEmpty:"暂无最近活动",status:{running:"运行中",completed:"已完成",failed:"失败",cancelled:"已取消",stale:"过期"},softRestart:"软重启",forceKill:"强制终止",softNote:e=>`先暂停 ${e} 个运行中线程`,holdHint:"继续按住…",footerNote:"软重启不丢线程状态,恢复后自动续跑 · 强制终止需长按 2s 确认,运行中线程标记 interrupted",sent:"重启信号已发送",failed:"重启失败",disconnect:"断开连接",disconnectNote:"清除已保存的服务器与令牌,返回登录页"}};function YZ(){const e=le(),t=ze(),n=je(),r=ut(),i=Lt(r,QZ),s=Y(e.threads.list.queryOptions({status:aK("active")})),a=Y(e.schedules.list.queryOptions({})),l=Y(e.executions.list.queryOptions({limit:5})),c=Y(e.system.daemonStatus.queryOptions({})),d=!s.isError&&!a.isError,u=B6(),f=p.useMemo(()=>KZ({threads:s.data??[],schedules:a.data??[],executions:l.data??[],daemon:c.data??null,ok:d}),[s.data,a.data,l.data,c.data,d]),h=xe(e.system.restart.mutationOptions({onSuccess:()=>{n.invalidateQueries(e.threads.list.queryFilter()),n.invalidateQueries(e.system.daemonStatus.queryFilter())}})),g=h.isPending?"pending":h.isSuccess?"success":h.isError?"error":"idle";return o.jsx(UZ,{vm:f,copy:i,connStatus:u,restartState:g,showDisconnect:Kt(),onBack:()=>t("/m/settings"),onSoftRestart:()=>h.mutate({kind:"soft"}),onHardRestart:()=>h.mutate({kind:"hard"}),onDisconnect:()=>void t3()})}const GZ=[{path:"/",element:o.jsx(dY,{}),children:[{index:!0,element:o.jsx(Ix,{to:"/m/sessions",replace:!0})},{path:"/m/sessions",element:o.jsx(yY,{})},{path:"/m/threads",element:o.jsx(NG,{})},{path:"/m/tasks",element:o.jsx(tX,{})},{path:"/m/project",element:o.jsx(RX,{})},{path:"/m/session/:sessionId",element:o.jsx(vG,{})},{path:"/m/session/:sessionId/plan/:requestId",element:o.jsx(jG,{})},{path:"/m/thread/:threadId",element:o.jsx(xJ,{})},{path:"/m/task/:taskId",element:o.jsx(OJ,{})},{path:"/m/approvals",element:o.jsx(NX,{})},{path:"/m/issues",element:o.jsx(WX,{})},{path:"/m/notes",element:o.jsx(eJ,{})},{path:"/m/memory",element:o.jsx(FJ,{})},{path:"/m/memory/file",element:o.jsx(VJ,{})},{path:"/m/machines",element:o.jsx(tZ,{})},{path:"/m/settings",element:o.jsx(pZ,{})},{path:"/m/settings/accounts",element:o.jsx(mZ,{})},{path:"/m/settings/hooks",element:o.jsx(DZ,{})},{path:"/m/daemon",element:o.jsx(YZ,{})},{path:"*",element:o.jsx(Ix,{to:"/m/sessions",replace:!0})}]}],XZ=Kt()?N4:D4,JZ=XZ(GZ);function ZZ(){const e=EO();return o.jsx(zD,{router:e?JZ:bQ})}const rE=document.getElementById("root");if(!rE)throw new Error("#root element not found");Tk(rE).render(o.jsx(p.StrictMode,{children:o.jsx(xA,{children:o.jsx(ZZ,{})})}));
|