@xopcai/xopc 0.0.211 → 0.0.214
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 +39 -60
- package/README.zh-CN.md +39 -61
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{activity-store-BzjFoSr0.js → activity-store-k-mNF_Dq.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-DTfjhfVE.js → agent-avatar-dicebear-B5VyiQ_K.js} +1 -1
- package/dist/gateway/static/root/assets/agents-DM2l0hCI.js +68 -0
- package/dist/gateway/static/root/assets/{api-D269PnU9.js → api-BjN2udFQ.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-BFpfQDWc.js → app-management-settings-panel-Bbul18ij.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-DLxFdqhY.js → appearance-settings-Bvvzgp00.js} +1 -1
- package/dist/gateway/static/root/assets/apps-page-BWd2KUkp.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-DPlH4dnc.js → archive-plugin-DjGVsAgd.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-xqfLLd0I.js → attachment-load-BCuUeuuO.js} +1 -1
- package/dist/gateway/static/root/assets/automations-page-Doof8nA6.js +1 -0
- package/dist/gateway/static/root/assets/automations-workspace-B2eTpWQN.js +6 -0
- package/dist/gateway/static/root/assets/{binary-plugins-C0tuoPXk.js → binary-plugins-B7WFf-lc.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-Deyphj1o.js → block-editor-CVwIwyUT.js} +47 -47
- package/dist/gateway/static/root/assets/browser-settings-page-D6ua52QD.js +8 -0
- package/dist/gateway/static/root/assets/{browser-workflow-inputs-CYEbXyRF.js → browser-workflow-inputs-Coz8pWzP.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-workflows-page-Bf0tPbGi.js → browser-workflows-page-8a3hnSXE.js} +2 -2
- package/dist/gateway/static/root/assets/capabilities-settings-panel-DfTpgo4L.js +7 -0
- package/dist/gateway/static/root/assets/{capability-presets-api-DPkFA_-R.js → capability-presets-api-BF3G84qe.js} +1 -1
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-DkjsA_Yn.js +3 -0
- package/dist/gateway/static/root/assets/{channel-recipient-api-DqKaAcnZ.js → channel-recipient-api-8Uz95P40.js} +1 -1
- package/dist/gateway/static/root/assets/channels-settings-Cv3pT5iN.js +1 -0
- package/dist/gateway/static/root/assets/channels-status-swr-NfU9X-P5.js +1 -0
- package/dist/gateway/static/root/assets/{chat-terminal-dock-CTDRZa7e.js → chat-terminal-dock-BYds3un1.js} +2 -2
- package/dist/gateway/static/root/assets/{chunk-KS7C4IRE-BMhrPKJC.js → chunk-KS7C4IRE-BaASWQor.js} +1 -1
- package/dist/gateway/static/root/assets/{connectors-api-Buu8fif8.js → connectors-api-Cj4deNtI.js} +1 -1
- package/dist/gateway/static/root/assets/connectors-page-CL6PMerr.js +2 -0
- package/dist/gateway/static/root/assets/{cron-expression-DTLR82NB.js → cron-expression-DjBh0ZL4.js} +1 -1
- package/dist/gateway/static/root/assets/{date-picker-DyNogHQH.js → date-picker-3cIzKCZU.js} +1 -1
- package/dist/gateway/static/root/assets/{dependency-picker-BpnCuo7B.js → dependency-picker-VZFStrz_.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-CDKI4gVB.js → desktop-pet-CRNQ4CKZ.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-DjT5C2a3.js → desktop-pet-settings-CJBeLcbV.js} +1 -1
- package/dist/gateway/static/root/assets/directory-picker-path-field-Dbq9_c33.js +1 -0
- package/dist/gateway/static/root/assets/{extension-debug-page-DWf2z7q5.js → extension-debug-page-CSFZfcz5.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-Dorx0kf9.js → extension-page-W8vZ3Nl0.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-B1wU9ZOB.js → extension-settings-page-D5zYR65b.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-api-B1lG4dNr.js → gateway-config-api-BnA56bxn.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-swr-BIxuwPQi.js → gateway-config-swr-l2w9ecXl.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-DqIOqJjM.js → gateway-settings-CCOOGd8A.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-BpZgd4U-.js → gateway-startup-retry-XUzMGmLZ.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-settings-DG4Kmgkc.js → heartbeat-settings-AutxO-ec.js} +1 -1
- package/dist/gateway/static/root/assets/home-page-BMpQAeHr.js +1 -0
- package/dist/gateway/static/root/assets/{image-generation-api-PkhYohDa.js → image-generation-api-CDoOrDMq.js} +1 -1
- package/dist/gateway/static/root/assets/index-BIBAmAjw.js +108 -0
- package/dist/gateway/static/root/assets/index-DQzjgIkQ.css +2 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-6OQT3gQF.js → keyboard-shortcuts-settings-Bcc08kso.js} +1 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-ctXGGgj1.js +2 -0
- package/dist/gateway/static/root/assets/{local-apps-page-DfruRAmE.js → local-apps-page-CuwtmiCt.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-C5MK9WcP.js → locale-store-BIOMAhmR.js} +1 -1
- package/dist/gateway/static/root/assets/logs-page-Vq-wDYVv.js +2 -0
- package/dist/gateway/static/root/assets/{management-settings-L1VYkywO.js → management-settings-gQwyJgL4.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-split-oqgHbqt-.js → markdown-split-DLSvtLDY.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-view-V4rcPPH0.js → markdown-view-BMDQYc6E.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-Bb6gSX2o.js → media-plugins-DFdpMglM.js} +1 -1
- package/dist/gateway/static/root/assets/messages-CbbZKEfO.js +3 -0
- package/dist/gateway/static/root/assets/notes-api-lKPk0Voa.js +1 -0
- package/dist/gateway/static/root/assets/{notes-page-B1rOXjpT.js → notes-page-BBhONbU4.js} +1 -1
- package/dist/gateway/static/root/assets/notes-workbench-CCFrzDRT.js +4 -0
- package/dist/gateway/static/root/assets/{page-tabs-CBuCKeyy.js → page-tabs-DoQq4tt6.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-BQ0tLfPO.js → preview-open-alternatives-BtJkAYOs.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-DPeFn7Hu.js → product-open-page-ClyG8t4A.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-CVeA23NS.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-DFj-bwa5.js +1 -0
- package/dist/gateway/static/root/assets/registry-api-BFwvRxBn.js +2 -0
- package/dist/gateway/static/root/assets/remote-access-hub-BgIrBYNz.js +1 -0
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-BCfQNzjG.js → runtime-tools-settings-panel-DdTZPRU5.js} +2 -2
- package/dist/gateway/static/root/assets/{schema-form-Bo7YbHYN.js → schema-form-C3Q03Hyv.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-wfBSuhmo.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-4zV9nthi.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-B9dnKr3M.js → settings-form-section-DdrNtxul.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-loading-skeleton-CYDV2JtY.js → settings-loading-skeleton-BFvEfK7v.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-DbrIYfS9.js → settings-page-B8iNNrLN.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-DEBPLh04.js +1 -0
- package/dist/gateway/static/root/assets/{share-preview-page-olgr7LLN.js → share-preview-page-CrsscJs3.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-Cpd3s8-P.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-BrDL4HAN.js +1 -0
- package/dist/gateway/static/root/assets/{skills-page-PE16CNw5.js → skills-page-B1sTkjZH.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page.utils-nXmBcBxt.js → skills-page.utils-CIcb0h3E.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-C3qPwAdY.js → system-settings-panel-MAl91hH_.js} +1 -1
- package/dist/gateway/static/root/assets/task-detail-page-C5wgYuvF.js +1 -0
- package/dist/gateway/static/root/assets/{theme-store-KR5Otp5w.js → theme-store-BrbF9cgL.js} +1 -1
- package/dist/gateway/static/root/assets/{typed-models-lib-lMZodtDF.js → typed-models-lib-Peglr65V.js} +1 -1
- package/dist/gateway/static/root/assets/{use-autosave-CKpatP3S.js → use-autosave-C10PZ1OV.js} +1 -1
- package/dist/gateway/static/root/assets/user-context-page-DsAfqOJy.js +1 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-CDcv0Wbh.js → voice-api-key-field-bdYmX3ph.js} +1 -1
- package/dist/gateway/static/root/assets/work-discovery-overlay-BI4wbLTm.js +1 -0
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-BAHYNlQt.js → workflow-run-setup-panel-CfmwGYkr.js} +2 -2
- package/dist/gateway/static/root/assets/workflows-page-D7tjtD97.js +5 -0
- package/dist/gateway/static/root/index.html +12 -10
- package/dist/package.js +1 -1
- package/dist/src/agent/agent-manager.js +4 -4
- package/dist/src/agent/embedded/model-runtime.js +1 -1
- package/dist/src/agent/embedded/run-for-session.js +1 -1
- package/dist/src/agent/image/tool-model-config.js +1 -1
- package/dist/src/agent/ipc/inbox.js +1 -1
- package/dist/src/agent/memory/create-memory-manager.js +1 -1
- package/dist/src/agent/service.js +2 -2
- package/dist/src/agent/session/session-inspector.js +1 -1
- package/dist/src/agent/skills/hub-lock.js +1 -1
- package/dist/src/agent/tasks/task-judge-service.js +3 -3
- package/dist/src/agent-runtime/index.js +1 -1
- package/dist/src/agent-runtime/runtime-profile.js +1 -1
- package/dist/src/ai-assist/text-assist.js +1 -1
- package/dist/src/auth/credentials.js +2 -2
- package/dist/src/auth/oauth/xopc-cloud.js +1 -1
- package/dist/src/auth/profiles/store.js +1 -1
- package/dist/src/auth/sync-provider-auth.js +2 -2
- package/dist/src/browser/providers/browser-ext-install.js +1 -1
- package/dist/src/cli/commands/agent.js +2 -2
- package/dist/src/cli/commands/connectors.js +1 -1
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/cli/commands/doctor/checks/provider-auth.js +1 -1
- package/dist/src/cli/commands/gateway/lifecycle.js +1 -1
- package/dist/src/cli/commands/models.js +2 -2
- package/dist/src/cli/commands/onboard.js +1 -1
- package/dist/src/cli/commands/profile.js +1 -1
- package/dist/src/cli/commands/tunnel.js +3 -3
- package/dist/src/cli/commands/update.js +1 -1
- package/dist/src/cli/extension-cli-register.js +1 -1
- package/dist/src/config/agent-profile.js +1 -1
- package/dist/src/config/index.js +5 -5
- package/dist/src/config/loader.js +1 -1
- package/dist/src/config/models-json.js +1 -1
- package/dist/src/connectors/composio-managed-client.d.ts +60 -0
- package/dist/src/connectors/composio-managed-client.js +135 -0
- package/dist/src/connectors/composio-managed-events.d.ts +41 -0
- package/dist/src/connectors/composio-managed-events.js +105 -0
- package/dist/src/connectors/composio-session-types.d.ts +91 -0
- package/dist/src/connectors/composio-session-types.js +1 -0
- package/dist/src/connectors/composio-sessions.d.ts +3 -91
- package/dist/src/connectors/composio-sessions.js +13 -7
- package/dist/src/connectors/composio.js +2 -1
- package/dist/src/connectors/connected-source-ingestion.js +67 -25
- package/dist/src/connectors/health.js +1 -1
- package/dist/src/connectors/learning-recipes.js +2 -0
- package/dist/src/connectors/runtime-adapter-registry.js +2 -2
- package/dist/src/discussions/sealer.js +2 -2
- package/dist/src/discussions/service.js +6 -2
- package/dist/src/discussions/transcript.d.ts +2 -0
- package/dist/src/discussions/transcript.js +16 -3
- package/dist/src/extensions/install.d.ts +10 -0
- package/dist/src/extensions/install.js +111 -14
- package/dist/src/extensions/loader.js +22 -18
- package/dist/src/extensions/lockfile.js +1 -1
- package/dist/src/gateway/agents-admin.js +2 -2
- package/dist/src/gateway/file-path-classifier.js +1 -1
- package/dist/src/gateway/hono/lib/config-payload.js +2 -2
- package/dist/src/gateway/hono/middleware/auth.js +2 -2
- package/dist/src/gateway/hono/middleware/logger.js +1 -1
- package/dist/src/gateway/hono/middleware/strict-rate-limit.js +1 -1
- package/dist/src/gateway/hono/routes/config-patch/misc.js +1 -1
- package/dist/src/gateway/hono/routes/connectors.js +11 -4
- package/dist/src/gateway/hono/routes/exposure.js +1 -1
- package/dist/src/gateway/hono/routes/home.d.ts +1 -1
- package/dist/src/gateway/hono/routes/home.js +2 -2
- package/dist/src/gateway/hono/routes/mcp.js +1 -1
- package/dist/src/gateway/hono/routes/models.js +1 -1
- package/dist/src/gateway/hono/routes/session-input-handler.d.ts +2 -2
- package/dist/src/gateway/hono/routes/shares.js +1 -1
- package/dist/src/gateway/hono/routes/tunnel.js +3 -3
- package/dist/src/gateway/hono/routes/workflows.js +69 -0
- package/dist/src/gateway/index.js +2 -2
- package/dist/src/gateway/run-loop.js +1 -1
- package/dist/src/gateway/runtime-config.js +2 -2
- package/dist/src/gateway/security/audit.js +2 -2
- package/dist/src/gateway/service/config-coordinator.js +2 -2
- package/dist/src/gateway/service.d.ts +1 -0
- package/dist/src/gateway/service.js +23 -8
- package/dist/src/notes/note-attachment-sync.js +1 -1
- package/dist/src/notes/service.d.ts +1 -0
- package/dist/src/notes/service.js +2 -1
- package/dist/src/notes/types.d.ts +2 -0
- package/dist/src/providers/auth-runtime/resolve-auth.js +1 -1
- package/dist/src/providers/index.js +2 -2
- package/dist/src/providers/model-catalog-persistence.d.ts +1 -1
- package/dist/src/providers/model-catalog-store.d.ts +2 -60
- package/dist/src/providers/model-catalog-types.d.ts +60 -0
- package/dist/src/providers/model-catalog-types.js +1 -0
- package/dist/src/providers/model-registry.js +1 -1
- package/dist/src/providers/provider-disconnect-core.d.ts +11 -0
- package/dist/src/providers/provider-disconnect-core.js +35 -0
- package/dist/src/providers/provider-disconnect.d.ts +2 -10
- package/dist/src/providers/provider-disconnect.js +4 -26
- package/dist/src/providers/register-runtime-providers.js +1 -1
- package/dist/src/providers/xopc-cloud-catalog-coordinator.js +2 -2
- package/dist/src/runtime-tools/manager.js +41 -22
- package/dist/src/storage/sqlite/migrations/124_workflow_context_snapshots.sql +15 -0
- package/dist/src/storage/sqlite/migrations/125_project_workflow_presets.sql +12 -0
- package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
- package/dist/src/storage/sqlite/migrations/runner.js +3 -3
- package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
- package/dist/src/storage/sqlite/schema.js +1 -1
- package/dist/src/tasks/home-query-service.d.ts +12 -127
- package/dist/src/tasks/home-query-service.js +73 -271
- package/dist/src/tasks/index.js +2 -2
- package/dist/src/tui/tui-startup-resources.js +2 -2
- package/dist/src/tui/tui.js +1 -1
- package/dist/src/tui/xopc-tui-keybindings.d.ts +2 -2
- package/dist/src/tunnel/index.js +2 -2
- package/dist/src/voice/audio/normalize.d.ts +1 -0
- package/dist/src/voice/audio/normalize.js +24 -4
- package/dist/src/voice/local/wav.d.ts +3 -0
- package/dist/src/voice/local/wav.js +10 -4
- package/dist/src/work-discovery/analyzer.js +16 -4
- package/dist/src/work-discovery/service.js +6 -8
- package/dist/src/work-discovery/types.d.ts +3 -0
- package/dist/src/workflows/context/workflow-context-snapshot-repository.d.ts +21 -0
- package/dist/src/workflows/context/workflow-context-snapshot-repository.js +40 -0
- package/dist/src/workflows/context/workflow-context.d.ts +18 -0
- package/dist/src/workflows/context/workflow-context.js +159 -0
- package/dist/src/workflows/domain/run.d.ts +10 -1
- package/dist/src/workflows/engine/workflow-engine.d.ts +1 -0
- package/dist/src/workflows/engine/workflow-engine.js +2 -0
- package/dist/src/workflows/project-presets/project-workflow-preset-repository.d.ts +20 -0
- package/dist/src/workflows/project-presets/project-workflow-preset-repository.js +38 -0
- package/dist/src/workflows/service/workflow-run-service.d.ts +1 -0
- package/dist/src/workflows/service/workflow-run-service.js +108 -23
- package/dist/src/workflows/service/workflow-run-service.types.d.ts +1 -0
- package/dist/src/workflows/service/workflow-writeback-service.d.ts +9 -0
- package/dist/src/workflows/service/workflow-writeback-service.js +106 -0
- package/package.json +20 -20
- package/dist/gateway/static/root/assets/agents-CjhgfuVJ.js +0 -68
- package/dist/gateway/static/root/assets/apps-page-CjmlGB5V.js +0 -1
- package/dist/gateway/static/root/assets/automations-page-4m6Ey6wG.js +0 -6
- package/dist/gateway/static/root/assets/browser-settings-page-CAGCYx8U.js +0 -8
- package/dist/gateway/static/root/assets/capabilities-settings-panel-CKfLsxTI.js +0 -7
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-CpipKNqX.js +0 -3
- package/dist/gateway/static/root/assets/channels-settings-Bvq-O4pt.js +0 -1
- package/dist/gateway/static/root/assets/channels-status-swr-CrMld2l7.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-CSQRzaVn.js +0 -2
- package/dist/gateway/static/root/assets/directory-picker-path-field-DlJY90TM.js +0 -1
- package/dist/gateway/static/root/assets/home-page-BhqItS_s.js +0 -1
- package/dist/gateway/static/root/assets/index-DLhvsU9B.css +0 -2
- package/dist/gateway/static/root/assets/index-_cuTcWjB.js +0 -107
- package/dist/gateway/static/root/assets/local-app-workbench-page-DWjTmzxw.js +0 -2
- package/dist/gateway/static/root/assets/logs-page-BA5efZ8B.js +0 -2
- package/dist/gateway/static/root/assets/messages-ctG2e-ix.js +0 -3
- package/dist/gateway/static/root/assets/notes-workbench-CkHXVmKP.js +0 -4
- package/dist/gateway/static/root/assets/project-detail-page-DCqet9-L.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-D0t_AjzG.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-BUWPoBvw.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-vLhrrM3m.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-OP1y0Y8M.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-Cxc-Ejl5.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-ZOqC6-aA.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-DwvC3Iuf.js +0 -1
- package/dist/gateway/static/root/assets/task-detail-page-DCRB-5q-.js +0 -1
- package/dist/gateway/static/root/assets/user-context-page-CoiedRuA.js +0 -1
- package/dist/gateway/static/root/assets/work-discovery-overlay-CGdT22un.js +0 -1
- package/dist/gateway/static/root/assets/work-discovery-page-BwaU1RqI.js +0 -1
- package/dist/gateway/static/root/assets/workflows-page-DHYmh9G7.js +0 -5
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{f as i,t as a}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as o}from"./check-DUBLcKHA.js";import{t as s}from"./copy-Dv6d4Dvw.js";import{t as c}from"./external-link-DjqjBmc3.js";import{t as l}from"./globe-DSSGFWFn.js";import{t as u}from"./loader-circle-CifKLtgG.js";import{t as d}from"./cn-JdwAhgNB.js";import{t as f}from"./button-CSEbl4zT.js";import{t as p}from"./copy-to-clipboard-HOJ79TWv.js";import{t as m}from"./messages-ctG2e-ix.js";import{a as h,i as g,l as _,n as v,o as y,r as b,s as x}from"./locale-store-C5MK9WcP.js";import{i as S,o as C}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{a as w,i as T,o as E,r as D,s as O,t as k}from"./dist-BPoKqzeH.js";import{a as A,i as j}from"./vendor-swr-BIWyz7Rc.js";import{n as M,r as N}from"./gateway-config-swr-BIxuwPQi.js";import{$o as P,As as F,Bn as I,Bo as L,Fl as R,Gn as z,Go as ee,Hn as B,Jn as V,Kn as te,Ms as H,Nc as ne,Nl as re,Oa as U,Rn as W,Rs as G,Rt as ie,Sl as K,Un as q,Va as J,Vn as Y,Wn as X,Ws as ae,Xn as oe,Yn as se,Ys as ce,_i as le,hi as ue,ji as de,lc as fe,ms as pe,qn as me,vs as he,zn as ge}from"./index-_cuTcWjB.js";import{n as _e,r as ve,t as ye}from"./settings-page-layout-BRQNel6r.js";import{t as be}from"./settings-advanced-gate-OP1y0Y8M.js";import{n as xe,r as Se,t as Ce}from"./settings-form-section-B9dnKr3M.js";import{t as we}from"./browser-BLJWD7WI.js";import{t as Te}from"./page-tabs-CBuCKeyy.js";var Z=n(),Q=e(t(),1),$=r();function Ee(e){let t=(0,Z.c)(26),{showLabel:n,hideLabel:r,icon:i,hint:a,children:o,className:s,defaultOpen:c,advancedOnly:l}=e,u=l===void 0?!1:l,[f,p]=(0,Q.useState)(c??!1),m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=e=>p(e.currentTarget.open),t[0]=m):m=t[0];let h;t[1]===s?h=t[2]:(h=d(`group rounded-2xl bg-surface-base open:pb-1`,s),t[1]=s,t[2]=h);let g;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(R,{className:`size-4 shrink-0 text-fg-muted transition-transform group-open:rotate-180`,"aria-hidden":!0}),t[3]=g):g=t[3];let _;t[4]===i?_=t[5]:(_=i?(0,$.jsx)(i,{className:`size-4 shrink-0 text-accent`,strokeWidth:1.75,"aria-hidden":!0}):null,t[4]=i,t[5]=_);let v;t[6]===n?v=t[7]:(v=(0,$.jsx)(`span`,{className:`group-open:hidden`,children:n}),t[6]=n,t[7]=v);let y;t[8]===r?y=t[9]:(y=(0,$.jsx)(`span`,{className:`hidden group-open:inline`,children:r}),t[8]=r,t[9]=y);let b;t[10]!==_||t[11]!==v||t[12]!==y?(b=(0,$.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 rounded-2xl px-4 py-3.5 text-sm font-medium text-fg transition-colors hover:text-fg group-open:rounded-b-none [&::-webkit-details-marker]:hidden`,children:[g,_,v,y]}),t[10]=_,t[11]=v,t[12]=y,t[13]=b):b=t[13];let x;t[14]===a?x=t[15]:(x=a?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:a}):null,t[14]=a,t[15]=x);let S;t[16]!==o||t[17]!==x?(S=(0,$.jsxs)(`div`,{className:`flex flex-col gap-4 px-4 pb-4 pt-1`,children:[x,o]}),t[16]=o,t[17]=x,t[18]=S):S=t[18];let C;t[19]!==f||t[20]!==S||t[21]!==h||t[22]!==b?(C=(0,$.jsxs)(`details`,{open:f,onToggle:m,className:h,children:[b,S]}),t[19]=f,t[20]=S,t[21]=h,t[22]=b,t[23]=C):C=t[23];let w=C;if(u){let e;return t[24]===w?e=t[25]:(e=(0,$.jsx)(be,{children:w}),t[24]=w,t[25]=e),e}return w}function De(e,t){let{mutate:n}=A(),[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(null),[s,c]=(0,Q.useState)(!1),l=(0,Q.useCallback)(async()=>{await Promise.all([n(`tunnel-pair-context`),n(`tunnel-pair`),n(`tunnel-status`),M()])},[n]);return{busy:r,error:a,confirmOpen:s,setConfirmOpen:c,runEnableLanPairing:(0,Q.useCallback)(async()=>{if(!(!e||r)){i(!0),o(null);try{let n=await B();if(!n.ok)throw Error(`Failed to enable LAN pairing`);if(n.requiresRestart){let t=await W();if(!t.ok)throw Error(t.message??`Gateway restart failed`);if(!await ge(e))throw Error(`Gateway did not come back online in time`)}let r=n.requiresRestart?await I():n.context;if(!r?.pairingReady)throw Error(`LAN pairing is still not ready after restart`);return await l(),t?.(r),c(!1),r}catch(e){return o(e instanceof Error?e.message:`Enable LAN pairing failed`),null}finally{i(!1)}}},[r,e,t,l]),clearError:()=>o(null)}}function Oe(){return d(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,P,`dark:border-edge`)}function ke(e){let t=(0,Z.c)(122),{pairQr:n,gatewayToken:r,streamlined:i,lanOnly:o,onRefreshQr:s}=e,c=i===void 0?!1:i,l=o===void 0?!1:o,p=v(Me),h;t[0]===p?h=t[1]:(h=m(p),t[0]=p,t[1]=h);let g=h,_=g.tunnelSettings,y=l?g.remoteAccess.lan:null,b;t[2]!==g.clipboard.copyFailed||t[3]!==_.pairCopied||t[4]!==_.pairCopyLink?(b={copy:_.pairCopyLink,copied:_.pairCopied,copyFailed:g.clipboard.copyFailed},t[2]=g.clipboard.copyFailed,t[3]=_.pairCopied,t[4]=_.pairCopyLink,t[5]=b):b=t[5];let x=b,{tunnelActive:S,tunnelStatus:C,tunnelQr:w,pairContext:T,pairBaseUrl:E,setPairBaseUrl:D,applySuggestedPairUrl:O,applyCandidateUrl:k,resetPairBaseFromContext:A,baseOk:j,localhostWarn:M,pairingBlocked:N,deepLink:P,qrPayload:I,qrDataUrl:L,qrGenFailed:R,encoding:z}=n,ee;t[6]===A?ee=t[7]:(ee=e=>{A(e.recommended.url)},t[6]=A,t[7]=ee);let B=De(r,ee),V,te,H,ne,re;if(t[8]!==k||t[9]!==O||t[10]!==j||t[11]!==B||t[12]!==r||t[13]!==y||t[14]!==l||t[15]!==M||t[16]!==s||t[17]!==E||t[18]!==T?.candidates||t[19]!==T?.recommended||t[20]!==N||t[21]!==D||t[22]!==c||t[23]!==_.pairBaseUrlHint||t[24]!==_.pairBaseUrlLabel||t[25]!==_.pairBaseUrlPlaceholder||t[26]!==_.pairBlockedLoopbackBody||t[27]!==_.pairBlockedNextSteps||t[28]!==_.pairBlockedTitle||t[29]!==_.pairCandidatesTitle||t[30]!==_.pairEnableLanButton||t[31]!==_.pairEnableLanEnabling||t[32]!==_.pairEnableLanSecurityAuditLink||t[33]!==_.pairInvalidBaseUrl||t[34]!==_.pairLocalhostWarning||t[35]!==_.pairSelectCandidateHint||t[36]!==_.pairSelectCandidateTitle||t[37]!==_.pairSubtitle||t[38]!==_.pairSuggestedLanLabel||t[39]!==_.pairTitle||t[40]!==_.pairTunnelActive||t[41]!==_.pairTunnelLanUrl||t[42]!==_.pairTunnelPublicUrl||t[43]!==_.pairUseSuggestedUrl||t[44]!==_.pairWaitingForTunnel||t[45]!==_.refreshQr||t[46]!==S||t[47]!==w||t[48]!==C?.publicUrl){re=Symbol.for(`react.early_return_sentinel`);bb0:{let e=T?.candidates.filter(je)??[],n=l?(e.find(Ae)?.url??e[0]?.url??``).trim():T?.recommended.url?.trim()??``,i=(l||!S)&&e.length>1,o=function(t){if(e.length===0)return null;let n=t===`amber`?`text-amber-950 dark:text-amber-100`:`text-fg`,r=t===`amber`?`text-amber-950/80 dark:text-amber-200/90`:`text-fg-muted`;return(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:d(`text-xs font-medium`,r),children:i?_.pairSelectCandidateTitle:_.pairCandidatesTitle}),(0,$.jsx)(`ul`,{className:`mt-1 space-y-1`,children:e.map(e=>(0,$.jsx)(`li`,{children:(0,$.jsxs)(`button`,{type:`button`,className:d(`w-full rounded-md border px-2 py-1.5 text-left font-mono text-[11px] transition-colors`,t===`amber`?`border-amber-300/70 hover:bg-amber-100/80 dark:border-amber-800 dark:hover:bg-amber-950/50`:`border-edge hover:bg-surface-panel`,E.trim()===e.url&&`border-accent bg-accent/5`,n),onClick:()=>k(e.url),children:[e.label?`${e.label}: `:``,e.url]})},e.url))}),i?(0,$.jsx)(`p`,{className:d(`mt-1 text-[11px] leading-relaxed`,r),children:_.pairSelectCandidateHint}):null]})};if(V=c&&!l,V&&!S){let e;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(F,{className:`size-4 text-accent`,strokeWidth:1.75}),t[54]=e):e=t[54];let n;t[55]===_.pairTitle?n=t[56]:(n=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[e,_.pairTitle]}),t[55]=_.pairTitle,t[56]=n);let r;t[57]===_.pairWaitingForTunnel?r=t[58]:(r=(0,$.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:_.pairWaitingForTunnel}),t[57]=_.pairWaitingForTunnel,t[58]=r);let i;t[59]!==n||t[60]!==r?(i=(0,$.jsxs)(Ce,{children:[n,r]}),t[59]=n,t[60]=r,t[61]=i):i=t[61],re=i;break bb0}let p=y?.pairTitle??_.pairTitle,m=l?y?.pairSubtitle??_.pairSubtitle:S?_.pairTunnelActive:_.pairSubtitle,h=!!(s&&(l||c&&S)),g=V?`mb-2`:`mb-3`,v;t[62]===g?v=t[63]:(v=d(`flex flex-wrap items-start justify-between gap-2`,g),t[62]=g,t[63]=v);let b;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(F,{className:`size-4 text-accent`,strokeWidth:1.75}),t[64]=b):b=t[64];let x;t[65]===p?x=t[66]:(x=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[b,p]}),t[65]=p,t[66]=x);let A;t[67]!==V||t[68]!==m||t[69]!==_.pairSubtitle?(A=V?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:_.pairSubtitle}):(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:m}),t[67]=V,t[68]=m,t[69]=_.pairSubtitle,t[70]=A):A=t[70];let P;t[71]!==x||t[72]!==A?(P=(0,$.jsxs)(`div`,{children:[x,A]}),t[71]=x,t[72]=A,t[73]=P):P=t[73];let I;t[74]!==s||t[75]!==h||t[76]!==_.refreshQr?(I=h?(0,$.jsxs)(f,{type:`button`,variant:`ghost`,className:`shrink-0`,onClick:()=>void s(),children:[(0,$.jsx)(ae,{className:`size-4`}),_.refreshQr]}):null,t[74]=s,t[75]=h,t[76]=_.refreshQr,t[77]=I):I=t[77],t[78]!==v||t[79]!==P||t[80]!==I?(te=(0,$.jsxs)(`div`,{className:v,children:[P,I]}),t[78]=v,t[79]=P,t[80]=I,t[81]=te):te=t[81],H=N?(0,$.jsxs)(`div`,{className:`mb-3 space-y-3 rounded-lg border border-amber-200 bg-amber-50 p-3 dark:border-amber-900/50 dark:bg-amber-950/30`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-amber-950 dark:text-amber-100`,children:_.pairBlockedTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-amber-900 dark:text-amber-200`,children:_.pairBlockedLoopbackBody})]}),n?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-amber-950/80 dark:text-amber-200/90`,children:_.pairSuggestedLanLabel}),(0,$.jsx)(`div`,{className:`mt-0.5 break-all font-mono text-xs text-amber-950 dark:text-amber-100`,children:n})]}),(0,$.jsx)(f,{type:`button`,variant:`secondary`,className:`w-full sm:w-auto`,onClick:O,children:_.pairUseSuggestedUrl})]}):null,e.length>0?o(`amber`):null,(0,$.jsx)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:flex-wrap`,children:(0,$.jsxs)(f,{type:`button`,className:`w-full sm:w-auto`,disabled:B.busy||!r,onClick:()=>B.setConfirmOpen(!0),children:[B.busy?(0,$.jsx)(u,{className:`size-3.5 animate-spin`}):null,B.busy?_.pairEnableLanEnabling:_.pairEnableLanButton]})}),B.error?(0,$.jsx)(`p`,{className:`text-xs text-red-800 dark:text-red-200`,children:B.error}):null,(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-amber-900 dark:text-amber-200`,children:l?y?.pairBlockedNextSteps??_.pairBlockedNextSteps:_.pairBlockedNextSteps}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,$.jsx)(a,{to:`/settings/gateway`,className:`inline-block text-xs font-medium text-accent hover:underline`,children:_.pairEnableLanSecurityAuditLink}),l&&y?.pairPublicTabLink?(0,$.jsx)(a,{to:`/settings/remote-access?tab=public`,className:`inline-block text-xs font-medium text-accent hover:underline`,children:y.pairPublicTabLink}):null]})]}):null,ne=S&&!l?V?null:(0,$.jsxs)(`div`,{className:`mb-3 space-y-2 rounded-lg bg-surface-panel/80 p-3 shadow-surface`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:_.pairTunnelPublicUrl}),(0,$.jsx)(`div`,{className:`mt-0.5 break-all font-mono text-xs text-fg`,children:C?.publicUrl})]}),w?.lanUrl?(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:_.pairTunnelLanUrl}),(0,$.jsx)(`div`,{className:`mt-0.5 break-all font-mono text-xs text-fg`,children:w.lanUrl})]}):null]}):(0,$.jsxs)(`div`,{className:`mb-3 space-y-1.5`,children:[(0,$.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`tunnel-mobile-pair-base`,children:_.pairBaseUrlLabel}),(0,$.jsx)(`input`,{id:`tunnel-mobile-pair-base`,className:d(Oe(),`font-mono text-xs`),type:`text`,autoComplete:`off`,spellCheck:!1,placeholder:n||_.pairBaseUrlPlaceholder,value:E,onChange:e=>D(e.target.value)}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:_.pairBaseUrlHint}),!j&&E.trim()?(0,$.jsx)(`p`,{className:`text-xs text-amber-800 dark:text-amber-200`,children:_.pairInvalidBaseUrl}):null,M?(0,$.jsx)(`p`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100`,children:_.pairLocalhostWarning}):null,i?o(`neutral`):null]})}t[8]=k,t[9]=O,t[10]=j,t[11]=B,t[12]=r,t[13]=y,t[14]=l,t[15]=M,t[16]=s,t[17]=E,t[18]=T?.candidates,t[19]=T?.recommended,t[20]=N,t[21]=D,t[22]=c,t[23]=_.pairBaseUrlHint,t[24]=_.pairBaseUrlLabel,t[25]=_.pairBaseUrlPlaceholder,t[26]=_.pairBlockedLoopbackBody,t[27]=_.pairBlockedNextSteps,t[28]=_.pairBlockedTitle,t[29]=_.pairCandidatesTitle,t[30]=_.pairEnableLanButton,t[31]=_.pairEnableLanEnabling,t[32]=_.pairEnableLanSecurityAuditLink,t[33]=_.pairInvalidBaseUrl,t[34]=_.pairLocalhostWarning,t[35]=_.pairSelectCandidateHint,t[36]=_.pairSelectCandidateTitle,t[37]=_.pairSubtitle,t[38]=_.pairSuggestedLanLabel,t[39]=_.pairTitle,t[40]=_.pairTunnelActive,t[41]=_.pairTunnelLanUrl,t[42]=_.pairTunnelPublicUrl,t[43]=_.pairUseSuggestedUrl,t[44]=_.pairWaitingForTunnel,t[45]=_.refreshQr,t[46]=S,t[47]=w,t[48]=C?.publicUrl,t[49]=V,t[50]=te,t[51]=H,t[52]=ne,t[53]=re}else V=t[49],te=t[50],H=t[51],ne=t[52],re=t[53];if(re!==Symbol.for(`react.early_return_sentinel`))return re;let U;t[82]===_.pairSecurityNote?U=t[83]:(U=(0,$.jsx)(`p`,{className:`mb-3 text-xs text-fg-subtle`,children:_.pairSecurityNote}),t[82]=_.pairSecurityNote,t[83]=U);let W;t[84]!==x||t[85]!==P||t[86]!==z||t[87]!==N||t[88]!==L||t[89]!==R||t[90]!==_.pairEncoding||t[91]!==_.pairImageError||t[92]!==_.pairQrDisabled?(W=P?(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3 sm:items-start`,children:[L&&!R?(0,$.jsx)(`img`,{src:L,alt:``,className:`size-56 rounded-lg border border-edge-subtle bg-white object-contain p-3 dark:border-edge`}):null,z?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:_.pairEncoding}):null,R?(0,$.jsx)(`p`,{className:`text-center text-sm text-fg-muted sm:text-left`,children:_.pairImageError}):null,(0,$.jsx)(de,{text:P,labels:x})]}):N?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:_.pairQrDisabled}):null,t[84]=x,t[85]=P,t[86]=z,t[87]=N,t[88]=L,t[89]=R,t[90]=_.pairEncoding,t[91]=_.pairImageError,t[92]=_.pairQrDisabled,t[93]=W):W=t[93];let G;t[94]!==V||t[95]!==I||t[96]!==_.deeplinkTitle?(G=I&&!V?(0,$.jsxs)(`details`,{className:`mt-3 rounded-lg bg-surface-panel/80 px-3 py-2 shadow-surface`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-xs font-medium text-fg-muted`,children:_.deeplinkTitle}),(0,$.jsx)(`p`,{className:`mt-2 break-all font-mono text-[10px] leading-relaxed text-fg-subtle`,children:I})]}):null,t[94]=V,t[95]=I,t[96]=_.deeplinkTitle,t[97]=G):G=t[97];let ie;t[98]!==V||t[99]!==_.pairMobileProbeHint||t[100]!==_.pairSchemeHint?(ie=V?null:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`mt-3 break-all font-mono text-[10px] leading-relaxed text-fg-subtle`,children:_.pairSchemeHint}),(0,$.jsx)(`p`,{className:`mt-1 text-[10px] leading-relaxed text-fg-subtle`,children:_.pairMobileProbeHint})]}),t[98]=V,t[99]=_.pairMobileProbeHint,t[100]=_.pairSchemeHint,t[101]=ie):ie=t[101];let K,q;t[102]===B?(K=t[103],q=t[104]):(K=()=>void B.runEnableLanPairing(),q=()=>{B.busy||B.setConfirmOpen(!1)},t[102]=B,t[103]=K,t[104]=q);let J;t[105]!==B.confirmOpen||t[106]!==_.consentCancel||t[107]!==_.pairEnableLanButton||t[108]!==_.pairEnableLanConfirmBody||t[109]!==_.pairEnableLanConfirmTitle||t[110]!==K||t[111]!==q?(J=(0,$.jsx)(le,{open:B.confirmOpen,title:_.pairEnableLanConfirmTitle,description:_.pairEnableLanConfirmBody,confirmLabel:_.pairEnableLanButton,cancelLabel:_.consentCancel,onConfirm:K,onCancel:q}),t[105]=B.confirmOpen,t[106]=_.consentCancel,t[107]=_.pairEnableLanButton,t[108]=_.pairEnableLanConfirmBody,t[109]=_.pairEnableLanConfirmTitle,t[110]=K,t[111]=q,t[112]=J):J=t[112];let Y;return t[113]!==U||t[114]!==W||t[115]!==G||t[116]!==ie||t[117]!==J||t[118]!==te||t[119]!==H||t[120]!==ne?(Y=(0,$.jsx)(Ce,{children:(0,$.jsxs)($.Fragment,{children:[te,H,ne,U,W,G,ie,J]})}),t[113]=U,t[114]=W,t[115]=G,t[116]=ie,t[117]=J,t[118]=te,t[119]=H,t[120]=ne,t[121]=Y):Y=t[121],Y}function Ae(e){return e.reachable}function je(e){return e.kind===`lan`}function Me(e){return e.language}function Ne(e){let t=(0,Z.c)(40),{open:n,title:r,intro:i,bullets:a,checkboxLabel:o,confirmLabel:s,cancelLabel:c,onConfirm:l,onCancel:u}=e,[p,m]=(0,Q.useState)(!1),h;t[0]===u?h=t[1]:(h=e=>{e||(m(!1),u())},t[0]=u,t[1]=h);let g;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(w,{className:d(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,C)}),t[2]=g):g=t[2];let _;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(_=d(`fixed left-1/2 top-1/2 max-h-[min(90vh,40rem)] w-[min(100%-2rem,32rem)] -translate-x-1/2 -translate-y-1/2`,`overflow-y-auto rounded-2xl border border-edge bg-surface-panel p-6 shadow-popover outline-none dark:border-edge`,S),t[3]=_):_=t[3];let v;t[4]===r?v=t[5]:(v=(0,$.jsx)(O,{className:`text-base font-semibold text-fg`,children:r}),t[4]=r,t[5]=v);let y;t[6]===i?y=t[7]:(y=(0,$.jsx)(T,{className:`mt-2 text-sm text-fg-muted`,children:i}),t[6]=i,t[7]=y);let b;t[8]===a?b=t[9]:(b=a.map(Pe),t[8]=a,t[9]=b);let x;t[10]===b?x=t[11]:(x=(0,$.jsx)(`ul`,{className:`mt-4 list-disc space-y-2 pl-5 text-sm text-fg-muted`,children:b}),t[10]=b,t[11]=x);let A;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(A=e=>m(e.target.checked),t[12]=A):A=t[12];let j;t[13]===p?j=t[14]:(j=(0,$.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 size-4 shrink-0 rounded border-edge accent-accent`,checked:p,onChange:A}),t[13]=p,t[14]=j);let M;t[15]===o?M=t[16]:(M=(0,$.jsx)(`span`,{children:o}),t[15]=o,t[16]=M);let N;t[17]!==M||t[18]!==j?(N=(0,$.jsxs)(`label`,{className:`mt-5 flex cursor-pointer items-start gap-3 text-sm text-fg`,children:[j,M]}),t[17]=M,t[18]=j,t[19]=N):N=t[19];let P;t[20]!==c||t[21]!==u?(P=(0,$.jsx)(f,{type:`button`,variant:`secondary`,onClick:u,children:c}),t[20]=c,t[21]=u,t[22]=P):P=t[22];let F=!p,I;t[23]!==s||t[24]!==l||t[25]!==F?(I=(0,$.jsx)(f,{type:`button`,disabled:F,onClick:l,children:s}),t[23]=s,t[24]=l,t[25]=F,t[26]=I):I=t[26];let L;t[27]!==P||t[28]!==I?(L=(0,$.jsxs)(`div`,{className:`mt-6 flex justify-end gap-2`,children:[P,I]}),t[27]=P,t[28]=I,t[29]=L):L=t[29];let R;t[30]!==N||t[31]!==L||t[32]!==v||t[33]!==y||t[34]!==x?(R=(0,$.jsxs)(E,{children:[g,(0,$.jsxs)(D,{className:_,onOpenAutoFocus:Fe,children:[v,y,x,N,L]})]}),t[30]=N,t[31]=L,t[32]=v,t[33]=y,t[34]=x,t[35]=R):R=t[35];let z;return t[36]!==n||t[37]!==h||t[38]!==R?(z=(0,$.jsx)(k,{open:n,onOpenChange:h,children:R}),t[36]=n,t[37]=h,t[38]=R,t[39]=z):z=t[39],z}function Pe(e){return(0,$.jsx)(`li`,{children:e},e)}function Fe(e){return e.preventDefault()}function Ie(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}var Le=[`preparing_frpc`,`registering`,`starting_frpc`];function Re(e){return e?e===`reconnecting_frpc`?Le.indexOf(`starting_frpc`):Le.indexOf(e):-1}function ze(e,t){if(t.state===`connected`)return`done`;let n=t.startProgress?.phase,r=Le.indexOf(e),i=Re(n);return i<0?t.state===`connecting`||t.state===`reconnecting`?`active`:`pending`:r<i?`done`:r===i?`active`:`pending`}function Be(e,t,n){let r=n.startProgress;return ze(t,n)===`active`?t===`preparing_frpc`&&n.frpcDownload?n.frpcDownload.phase===`extracting`?e.frpcExtracting:n.frpcDownload.percent==null?e.frpcDownloading:e.frpcDownloadingPercent.replace(`{{percent}}`,String(n.frpcDownload.percent)):t===`registering`&&r?.publicUrl?e.stepRegisterDetail:t===`starting_frpc`?r?.phase===`reconnecting_frpc`?e.stepReconnectDetail:e.stepFrpcDetail:null:null}function Ve(e,t){switch(t){case`preparing_frpc`:return e.stepPrepareFrpc;case`registering`:return e.stepRegister;case`starting_frpc`:return e.stepFrpcLogin}}function He(e){if(!e)return null;let t=Math.max(0,Math.floor((Date.now()-new Date(e).getTime())/1e3));return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function Ue(e){let t=(0,Z.c)(31),{status:n,t:r}=e,[,i]=(0,Q.useState)(0),a;t[0]!==i||t[1]!==n.state?(a=()=>{if(n.state!==`connecting`&&n.state!==`reconnecting`)return;let e=window.setInterval(()=>i(We),1e3);return()=>window.clearInterval(e)},t[0]=i,t[1]=n.state,t[2]=a):a=t[2];let s=n.startProgress?.startedAt,c;if(t[3]!==n.state||t[4]!==s?(c=[n.state,s],t[3]=n.state,t[4]=s,t[5]=c):c=t[5],(0,Q.useEffect)(a,c),!(n.state===`connecting`||n.state===`reconnecting`||n.state===`connected`&&n.startProgress))return null;let l,f,p,m,h;if(t[6]!==n||t[7]!==r){let e=He(n.startProgress?.startedAt);l=!!n.publicUrl&&n.state!==`connected`&&n.startProgress?.phase!==`registering`,f=`mt-3 space-y-3 rounded-lg bg-surface-panel/80 p-3 shadow-surface`;let i;t[13]===r.startProgressTitle?i=t[14]:(i=(0,$.jsx)(`p`,{className:`text-xs font-medium text-fg`,children:r.startProgressTitle}),t[13]=r.startProgressTitle,t[14]=i);let a;t[15]===r.startProgressHint?a=t[16]:(a=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:r.startProgressHint}),t[15]=r.startProgressHint,t[16]=a),t[17]!==i||t[18]!==a?(p=(0,$.jsxs)(`div`,{children:[i,a]}),t[17]=i,t[18]=a,t[19]=p):p=t[19];let s=Le.map(e=>{let t=ze(e,n),i=Be(r,e,n);return(0,$.jsxs)(`li`,{className:`flex gap-2 text-xs`,children:[(0,$.jsx)(`span`,{className:`mt-0.5 shrink-0 text-fg-subtle`,"aria-hidden":!0,children:t===`done`?(0,$.jsx)(o,{className:`size-3.5 text-emerald-600 dark:text-emerald-400`}):t===`active`?(0,$.jsx)(u,{className:`size-3.5 animate-spin text-accent`}):(0,$.jsx)(K,{className:`size-3.5`})}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:d(`font-medium`,t===`active`?`text-fg`:t===`done`?`text-fg-muted`:`text-fg-subtle`),children:Ve(r,e)}),i?(0,$.jsx)(`div`,{className:`mt-0.5 text-fg-muted`,children:i}):null,e===`preparing_frpc`&&t===`active`&&n.frpcDownload&&n.frpcDownload.phase===`downloading`?(0,$.jsxs)(`div`,{className:`mt-2 space-y-1`,children:[(0,$.jsx)(`div`,{className:`h-1.5 w-full overflow-hidden rounded-full bg-surface-panel`,children:(0,$.jsx)(`div`,{className:d(`h-full rounded-full bg-accent transition-[width] duration-300`,n.frpcDownload.percent==null&&`w-1/3 animate-pulse`),style:n.frpcDownload.percent==null?void 0:{width:`${n.frpcDownload.percent}%`}})}),n.frpcDownload.bytesReceived!=null&&n.frpcDownload.totalBytes?(0,$.jsxs)(`p`,{className:`text-fg-subtle`,children:[Ie(n.frpcDownload.bytesReceived),` /`,` `,Ie(n.frpcDownload.totalBytes)]}):null]}):null,e===`preparing_frpc`&&t===`active`&&n.frpcDownload?.url?(0,$.jsxs)(`p`,{className:`mt-2 text-fg-subtle`,children:[(0,$.jsxs)(`span`,{className:`font-sans`,children:[r.frpcDownloadingUrlLabel,`: `]}),(0,$.jsx)(`a`,{href:n.frpcDownload.url,target:`_blank`,rel:`noopener noreferrer`,className:`break-all font-mono text-[11px] text-accent hover:underline`,children:n.frpcDownload.url})]}):null]})]},e)});t[20]===s?m=t[21]:(m=(0,$.jsx)(`ol`,{className:`space-y-2`,children:s}),t[20]=s,t[21]=m),h=e&&n.startProgress?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r.startProgressElapsed.replace(`{{elapsed}}`,e)}):null,t[6]=n,t[7]=r,t[8]=l,t[9]=f,t[10]=p,t[11]=m,t[12]=h}else l=t[8],f=t[9],p=t[10],m=t[11],h=t[12];let g;t[22]!==l||t[23]!==r.publicUrlPendingNotice?(g=l?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:r.publicUrlPendingNotice}):null,t[22]=l,t[23]=r.publicUrlPendingNotice,t[24]=g):g=t[24];let _;return t[25]!==f||t[26]!==p||t[27]!==m||t[28]!==h||t[29]!==g?(_=(0,$.jsxs)(`div`,{className:f,children:[p,m,h,g]}),t[25]=f,t[26]=p,t[27]=m,t[28]=h,t[29]=g,t[30]=_):_=t[30],_}function We(e){return e+1}function Ge(e,t){return t.state===`connected`?e.statusConnected:t.state===`error`?e.statusError:t.startProgress?.phase===`reconnecting_frpc`?e.statusReconnecting:t.startProgress?.phase===`starting_frpc`?e.statusStartingFrpc:t.startProgress?.phase===`registering`?e.statusRegistering:t.startProgress?.phase===`preparing_frpc`||t.frpcDownload?e.statusPreparingFrpc:t.state===`connecting`||t.state===`reconnecting`?e.statusConnecting:e.statusOff}function Ke(e){return e.state===`connected`?`connected`:e.state===`error`?`error`:e.state===`connecting`||e.state===`reconnecting`||e.startProgress||e.frpcDownload?`progress`:`off`}function qe(e){switch(e){case`connected`:return`bg-emerald-500/15 text-emerald-700 dark:text-emerald-400`;case`progress`:return`bg-amber-500/15 text-amber-700 dark:text-amber-400`;case`error`:return`bg-red-500/15 text-red-700 dark:text-red-400`;default:return`bg-surface-hover text-fg-muted`}}function Je(e){if(!e)return`—`;let t=Date.now()-new Date(e).getTime();if(t<0)return`—`;let n=Math.floor(t/6e4);return n<60?`${n}m`:`${Math.floor(n/60)}h ${n%60}m`}function Ye(e){let t=(0,Z.c)(61),{t:n,status:r,isLoading:i,statusErr:a,starting:o,stopping:s,showConsentExpired:c,copyLabels:p,startDisabled:m,startDisabledReason:h,stepLabel:g,onStart:_,onStop:v}=e,y=m===void 0?!1:m,b,x,S,C,w,T,E;t[0]!==r||t[1]!==o?(E=Ke(r),b=r.enabled||o,x=o||r.state===`connecting`||r.state===`reconnecting`||!!r.startProgress||!!r.frpcDownload,t[9]===Symbol.for(`react.memo_cache_sentinel`)?(T=d(Se(),`space-y-4`),t[9]=T):T=t[9],w=`flex flex-wrap items-start justify-between gap-3`,C=`flex items-center gap-2`,S=d(`inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-xs font-medium`,qe(E)),t[0]=r,t[1]=o,t[2]=b,t[3]=x,t[4]=S,t[5]=C,t[6]=w,t[7]=T,t[8]=E):(b=t[2],x=t[3],S=t[4],C=t[5],w=t[6],T=t[7],E=t[8]);let D=E===`connected`&&`bg-emerald-500`,O=E===`progress`&&`bg-amber-500 animate-pulse`,k=E===`error`&&`bg-red-500`,A=E===`off`&&`bg-fg-subtle`,j;t[10]!==D||t[11]!==O||t[12]!==k||t[13]!==A?(j=d(`size-1.5 rounded-full`,D,O,k,A),t[10]=D,t[11]=O,t[12]=k,t[13]=A,t[14]=j):j=t[14];let M;t[15]===j?M=t[16]:(M=(0,$.jsx)(`span`,{className:j,"aria-hidden":!0}),t[15]=j,t[16]=M);let N;t[17]!==i||t[18]!==r||t[19]!==n?(N=i&&!r.enabled?(0,$.jsx)(`span`,{"aria-hidden":`true`,className:`inline-block h-3 w-16 animate-pulse rounded-full bg-surface-hover/70 motion-reduce:animate-none`}):Ge(n,r),t[17]=i,t[18]=r,t[19]=n,t[20]=N):N=t[20];let P;t[21]!==M||t[22]!==N||t[23]!==S?(P=(0,$.jsxs)(`span`,{className:S,children:[M,N]}),t[21]=M,t[22]=N,t[23]=S,t[24]=P):P=t[24];let F;t[25]!==r.connectedSince||t[26]!==r.state||t[27]!==n.uptime?(F=r.connectedSince&&r.state===`connected`?(0,$.jsxs)(`span`,{className:`text-xs text-fg-subtle`,children:[n.uptime,` `,Je(r.connectedSince)]}):null,t[25]=r.connectedSince,t[26]=r.state,t[27]=n.uptime,t[28]=F):F=t[28];let I;t[29]!==P||t[30]!==F||t[31]!==C?(I=(0,$.jsxs)(`div`,{className:C,children:[P,F]}),t[29]=P,t[30]=F,t[31]=C,t[32]=I):I=t[32];let L;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,$.jsx)(l,{className:`size-4 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0}),t[33]=L):L=t[33];let R;t[34]!==I||t[35]!==w?(R=(0,$.jsxs)(`div`,{className:w,children:[I,L]}),t[34]=I,t[35]=w,t[36]=R):R=t[36];let z;t[37]===a?z=t[38]:(z=a?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:a instanceof Error?a.message:String(a)}):null,t[37]=a,t[38]=z);let ee;t[39]!==c||t[40]!==n.consentExpiredBanner?(ee=c?(0,$.jsx)(`p`,{className:`rounded-lg border border-amber-500/25 bg-amber-500/5 px-3 py-2 text-xs text-fg-muted`,children:n.consentExpiredBanner}):null,t[39]=c,t[40]=n.consentExpiredBanner,t[41]=ee):ee=t[41];let B;t[42]!==b||t[43]!==p||t[44]!==_||t[45]!==v||t[46]!==x||t[47]!==r||t[48]!==y||t[49]!==h||t[50]!==o||t[51]!==g||t[52]!==s||t[53]!==n?(B=b?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[r.publicUrl?(0,$.jsx)(`div`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,children:(0,$.jsx)(de,{label:n.publicUrlLabel,text:r.publicUrl,labels:p})}):null,x?(0,$.jsx)(Ue,{status:r,t:n}):null,r.lastError&&r.state===`error`?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:r.lastError}):null,(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:r.enabled?(0,$.jsxs)(f,{type:`button`,variant:`secondary`,disabled:s,onClick:v,children:[s?(0,$.jsx)(u,{className:`size-4 animate-spin`}):null,n.stop]}):(0,$.jsxs)(f,{type:`button`,disabled:o,onClick:_,children:[o?(0,$.jsx)(u,{className:`size-4 animate-spin`}):(0,$.jsx)(ce,{className:`size-4`}),n.start]})})]}):(0,$.jsxs)(`div`,{className:`space-y-4`,children:[g?(0,$.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:g}):null,(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:n.emptyStateTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:n.emptyStateBody})]}),(0,$.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-amber-500/25 bg-amber-500/5 px-3 py-2.5 text-xs text-fg-muted`,children:[(0,$.jsx)(pe,{className:`mt-0.5 size-4 shrink-0 text-amber-600 dark:text-amber-400`}),(0,$.jsx)(`p`,{children:n.riskBannerBody})]}),y&&h?(0,$.jsx)(`p`,{className:`text-sm text-amber-800 dark:text-amber-200`,children:h}):null,(0,$.jsxs)(f,{type:`button`,disabled:o||y,onClick:_,className:`w-full sm:w-auto`,children:[o?(0,$.jsx)(u,{className:`size-4 animate-spin`}):(0,$.jsx)(ce,{className:`size-4`}),n.start]})]}),t[42]=b,t[43]=p,t[44]=_,t[45]=v,t[46]=x,t[47]=r,t[48]=y,t[49]=h,t[50]=o,t[51]=g,t[52]=s,t[53]=n,t[54]=B):B=t[54];let V;return t[55]!==R||t[56]!==z||t[57]!==ee||t[58]!==B||t[59]!==T?(V=(0,$.jsxs)(`section`,{className:T,children:[R,z,ee,B]}),t[55]=R,t[56]=z,t[57]=ee,t[58]=B,t[59]=T,t[60]=V):V=t[60],V}var Xe=`https://console.xopc.ai/keys/tunnel`,Ze={reconfiguring:!1};function Qe(e){let t=(0,Z.c)(84),{t:n,brokerSecretFromEnv:r,brokerSecretMissing:i,brokerSecretConfiguredInConfig:a,brokerSecretMaskedValue:s,brokerSecretDraft:l,savingBrokerSecret:p,brokerSecretNotice:m,copyFailedLabel:h,onDraftChange:g,onSave:_,onClear:v,sectionRef:y}=e,b=(0,Q.useId)(),x=i&&!r,S=!x,[C,w]=(0,Q.useReducer)(ue,Ze),{reconfiguring:T}=C,E;t[0]!==a||t[1]!==l||t[2]!==r||t[3]!==T?(E=a&&!r&&!T&&!l.trim(),t[0]=a,t[1]=l,t[2]=r,t[3]=T,t[4]=E):E=t[4];let D=E,O;t[5]!==n.copied||t[6]!==n.copyKey||t[7]!==n.hideKey||t[8]!==n.showKey?(O={show:n.showKey,hide:n.hideKey,copy:n.copyKey,copied:n.copied},t[5]=n.copied,t[6]=n.copyKey,t[7]=n.hideKey,t[8]=n.showKey,t[9]=O):O=t[9];let k=O,A;t[10]===l?A=t[11]:(A=l.trim().length>0&&!ie(l.trim()),t[10]=l,t[11]=A);let j=A,M;t[12]===g?M=t[13]:(M=()=>{w({type:`patch`,patch:{reconfiguring:!1}}),g(``)},t[12]=g,t[13]=M);let N=M,P=x&&`ring-1 ring-amber-500/30`,F;t[14]===P?F=t[15]:(F=d(P),t[14]=P,t[15]=F);let I=S?`bg-emerald-500/10 text-emerald-600 dark:text-emerald-400`:x?`bg-amber-500/10 text-amber-700 dark:text-amber-400`:`bg-surface-hover text-fg-muted`,L;t[16]===I?L=t[17]:(L=d(`flex size-9 shrink-0 items-center justify-center rounded-lg`,I),t[16]=I,t[17]=L);let R;t[18]===S?R=t[19]:(R=S?(0,$.jsx)(o,{className:`size-4`,strokeWidth:2,"aria-hidden":!0}):(0,$.jsx)(ne,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[18]=S,t[19]=R);let z;t[20]!==L||t[21]!==R?(z=(0,$.jsx)(`span`,{className:L,children:R}),t[20]=L,t[21]=R,t[22]=z):z=t[22];let B=S?n.brokerSecretReadyTitle:n.brokerSecretStepTitle,V;t[23]===B?V=t[24]:(V=(0,$.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:B}),t[23]=B,t[24]=V);let te=S?n.brokerSecretReadyHint:n.brokerSecretHint,H;t[25]===te?H=t[26]:(H=(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:te}),t[25]=te,t[26]=H);let re;t[27]!==x||t[28]!==n.brokerSecretMissingHint?(re=x?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-amber-800 dark:text-amber-200`,children:n.brokerSecretMissingHint}):null,t[27]=x,t[28]=n.brokerSecretMissingHint,t[29]=re):re=t[29];let U;t[30]!==V||t[31]!==H||t[32]!==re?(U=(0,$.jsxs)(`div`,{children:[V,H,re]}),t[30]=V,t[31]=H,t[32]=re,t[33]=U):U=t[33];let W;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(W=(0,$.jsx)(c,{className:`size-3`,"aria-hidden":!0}),t[34]=W):W=t[34];let G;t[35]===n.brokerSecretConsoleLink?G=t[36]:(G=(0,$.jsxs)(`a`,{href:Xe,target:`_blank`,rel:`noopener noreferrer`,className:`inline-flex w-fit items-center gap-1 text-xs font-medium text-accent-fg hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[n.brokerSecretConsoleLink,W]}),t[35]=n.brokerSecretConsoleLink,t[36]=G);let K;t[37]!==r||t[38]!==n.brokerSecretEnvHint?(K=r?(0,$.jsx)(`p`,{className:`rounded-lg bg-surface-panel/80 px-3 py-2 text-xs text-fg-muted shadow-surface`,children:n.brokerSecretEnvHint}):null,t[37]=r,t[38]=n.brokerSecretEnvHint,t[39]=K):K=t[39];let q;t[40]!==a||t[41]!==l||t[42]!==r||t[43]!==s||t[44]!==j||t[45]!==N||t[46]!==h||t[47]!==b||t[48]!==x||t[49]!==v||t[50]!==g||t[51]!==_||t[52]!==T||t[53]!==p||t[54]!==k||t[55]!==D||t[56]!==n.brokerSecretCancelReconfigure||t[57]!==n.brokerSecretClear||t[58]!==n.brokerSecretMaskedHelp||t[59]!==n.brokerSecretNotInConfigFile||t[60]!==n.brokerSecretPlaceholder||t[61]!==n.brokerSecretReconfigure||t[62]!==n.brokerSecretRevealFailed||t[63]!==n.brokerSecretSave||t[64]!==n.brokerSecretSaveAndContinue||t[65]!==n.brokerSecretTitle?(q=D?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`label`,{className:`sr-only`,htmlFor:b,children:n.brokerSecretTitle}),(0,$.jsx)(ee,{id:b,value:s,labels:k,reveal:$e,loadFailedLabel:h||n.brokerSecretRevealFailed,maskedHelp:n.brokerSecretMaskedHelp,notInConfigFile:n.brokerSecretNotInConfigFile,readOnly:!0}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsx)(f,{type:`button`,variant:`secondary`,disabled:p,onClick:()=>{w({type:`patch`,patch:{reconfiguring:!0}})},children:n.brokerSecretReconfigure}),(0,$.jsx)(f,{type:`button`,variant:`ghost`,disabled:p,onClick:v,children:n.brokerSecretClear})]})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`label`,{className:`sr-only`,htmlFor:b,children:n.brokerSecretTitle}),(0,$.jsx)(ee,{id:b,value:l,onChange:g,placeholder:n.brokerSecretPlaceholder,labels:k,disabled:p}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsxs)(f,{type:`button`,disabled:p||!j,onClick:_,children:[p?(0,$.jsx)(u,{className:`size-4 animate-spin`}):null,x?n.brokerSecretSaveAndContinue:n.brokerSecretSave]}),a||r?(0,$.jsx)(f,{type:`button`,variant:`ghost`,disabled:p,onClick:v,children:n.brokerSecretClear}):null,T?(0,$.jsx)(f,{type:`button`,variant:`ghost`,disabled:p,onClick:N,children:n.brokerSecretCancelReconfigure}):null]})]}),t[40]=a,t[41]=l,t[42]=r,t[43]=s,t[44]=j,t[45]=N,t[46]=h,t[47]=b,t[48]=x,t[49]=v,t[50]=g,t[51]=_,t[52]=T,t[53]=p,t[54]=k,t[55]=D,t[56]=n.brokerSecretCancelReconfigure,t[57]=n.brokerSecretClear,t[58]=n.brokerSecretMaskedHelp,t[59]=n.brokerSecretNotInConfigFile,t[60]=n.brokerSecretPlaceholder,t[61]=n.brokerSecretReconfigure,t[62]=n.brokerSecretRevealFailed,t[63]=n.brokerSecretSave,t[64]=n.brokerSecretSaveAndContinue,t[65]=n.brokerSecretTitle,t[66]=q):q=t[66];let J;t[67]===m?J=t[68]:(J=m?(0,$.jsx)(`p`,{className:`text-xs text-emerald-700 dark:text-emerald-400`,children:m}):null,t[67]=m,t[68]=J);let Y;t[69]!==U||t[70]!==G||t[71]!==K||t[72]!==q||t[73]!==J?(Y=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-3`,children:[U,G,K,q,J]}),t[69]=U,t[70]=G,t[71]=K,t[72]=q,t[73]=J,t[74]=Y):Y=t[74];let X;t[75]!==z||t[76]!==Y?(X=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[z,Y]}),t[75]=z,t[76]=Y,t[77]=X):X=t[77];let ae;t[78]!==X||t[79]!==F?(ae=(0,$.jsx)(Ce,{className:F,children:X}),t[78]=X,t[79]=F,t[80]=ae):ae=t[80];let oe;return t[81]!==y||t[82]!==ae?(oe=(0,$.jsx)(`div`,{ref:y,id:`tunnel-broker-secret-setup`,children:ae}),t[81]=y,t[82]=ae,t[83]=oe):oe=t[83],oe}function $e(){return V().then(et)}function et(e){return e.registrationSecret??null}function tt(e){let t=(0,Z.c)(10),{language:n,label:r,section:i,className:a}=e,o;t[0]!==n||t[1]!==i?(o=L(n,i),t[0]=n,t[1]=i,t[2]=o):o=t[2];let s;t[3]===a?s=t[4]:(s=d(`inline-flex items-center gap-1 text-sm font-medium text-accent hover:underline`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,a),t[3]=a,t[4]=s);let l;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(c,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[5]=l):l=t[5];let u;return t[6]!==r||t[7]!==o||t[8]!==s?(u=(0,$.jsxs)(`a`,{href:o,target:`_blank`,rel:`noreferrer`,className:s,children:[r,l]}),t[6]=r,t[7]=o,t[8]=s,t[9]=u):u=t[9],u}var nt=e(we(),1),rt={width:216,margin:2,errorCorrectionLevel:`M`,color:{dark:`#000000ff`,light:`#ffffffff`}};async function it(e){return nt.toDataURL(e,rt)}function at(e){let t=e?.candidates??[],n=t.find(e=>e.kind===`lan`&&e.reachable),r=t.find(e=>e.kind===`lan`);return(n??r)?.url?.trim()??``}function ot(e,t){let n=t.trim();return!n||!e?!1:e.candidates.some(e=>e.kind===`tunnel`&&e.url.trim()===n)}function st(e,t){return e?t?at(e)||e.recommended.url?.trim()||``:e.recommended.url?.trim()||``:``}function ct(e,t){let n=t?.preferLan===!0,r=!!e,{mutate:i}=A(),a=(0,Q.useRef)(!1),{data:o}=j(r?`tunnel-status`:null,z,{refreshInterval:6e4}),{data:s,mutate:c}=j(r?`tunnel-pair-context`:null,q,{refreshInterval:6e4});(0,Q.useEffect)(()=>{let e=()=>{i(`tunnel-status`),i(`tunnel-qr`),i(`tunnel-pair`),i(`tunnel-pair-context`)};return window.addEventListener(`tunnel-status`,e),()=>window.removeEventListener(`tunnel-status`,e)},[i]);let l=o?.state===`connected`&&!!o.publicUrl?.trim(),u=l&&!n,{data:d,mutate:f}=j(u&&r?`tunnel-qr`:null,X,{refreshInterval:4*6e4}),{data:p,mutate:m}=j(!u&&r&&s?.pairingReady?`tunnel-pair`:null,Y,{refreshInterval:4*6e4}),[_,v]=(0,Q.useState)(``),[y,b]=(0,Q.useState)(``),[x,S]=(0,Q.useState)({pairContext:void 0,preferLan:n});if(!a.current&&(s!==x.pairContext||n!==x.preferLan)){S({pairContext:s,preferLan:n});let e=st(s,n);_!==e&&v(e)}let C=(0,Q.useCallback)(e=>{a.current=!0,v(e)},[]),w=(0,Q.useCallback)(()=>{let e=st(s,n);e&&(a.current=!0,v(e))},[s,n]),T=(0,Q.useCallback)(e=>{let t=e.trim();t&&(a.current=!0,v(t))},[]),E=(0,Q.useCallback)(e=>{a.current=!1,v(e?.trim()||st(s,n))},[s,n]),D=_.trim(),O=(0,Q.useMemo)(()=>{try{let e=new URL(D);return e.protocol===`http:`||e.protocol===`https:`}catch{return!1}},[D]),k=O&&h(D),M=!u&&!!(s&&!s.pairingReady&&s.blockReason===`GATEWAY_LOOPBACK_ONLY`),N=!u&&O&&!k&&!!p?.pairingSecret&&(s?.pairingReady===!0||!M),P=(0,Q.useMemo)(()=>{let e=at(s);return n?e||(D&&!ot(s,D)?D:``):D},[s,n,D]),F=(0,Q.useMemo)(()=>{if(!e)return``;if(y.trim())return y.trim();if(u&&d?.qrPayload?.trim())return d.qrPayload.trim();if(!N||!p?.pairingSecret)return``;let t=s?.candidates.find(e=>e.kind===`tunnel`&&e.reachable),r=s?.candidates.find(e=>e.kind===`lan`&&e.reachable),i=n?P:t?.url??D;return i?g({baseUrl:i,pairingSecret:p.pairingSecret,lanUrl:n?null:t&&r?r.url:null}):``},[e,P,p?.pairingSecret,N,y,n,D,u,d?.qrPayload,s?.candidates]),I=J(()=>it(F),[F],{enabled:!!F,initial:null,errorData:null}),L=F?I.data:null,R=!!(F&&I.error!==null&&!I.loading);return{tunnelActive:l,tunnelStatus:o,tunnelQr:d,pairContext:s,pairBaseUrl:_,setPairBaseUrl:C,applySuggestedPairUrl:w,applyCandidateUrl:T,baseOk:O,localhostWarn:k,pairingBlocked:M,deepLink:F,qrPayload:F,qrDataUrl:L,qrGenFailed:R,encoding:!!(F&&!L&&!R),refreshQr:(0,Q.useCallback)(async e=>{if(e?.trim()){b(e.trim()),f({qrPayload:e.trim(),publicUrl:o?.publicUrl??``,lanUrl:d?.lanUrl??null},!1);return}b(``),await c(),u?await f():s?.pairingReady&&await m()},[m,c,f,s?.pairingReady,d?.lanUrl,o?.publicUrl,u]),resetPairBaseFromContext:E}}var lt={actionError:null,starting:!1,stopping:!1,savingAutoStart:!1,consentOpen:!1,autoStartConfirmOpen:!1,releaseConfirmOpen:!1,releasing:!1,brokerSecretDraft:``,savingBrokerSecret:!1,brokerSecretNotice:null};function ut({embedded:e=!1}){let t=v(e=>e.language),n=m(t).tunnelSettings,r=_(e=>e.token),i=!!r,[a,o]=(0,Q.useReducer)(ue,lt),{actionError:s,starting:c,stopping:p,savingAutoStart:h,consentOpen:g,autoStartConfirmOpen:y,releaseConfirmOpen:b,releasing:x,brokerSecretDraft:S,savingBrokerSecret:C,brokerSecretNotice:w}=a,T=(0,Q.useRef)(null),E=ct(r??``),{data:D}=N(i),{data:O,error:k,isLoading:A,mutate:P}=j(i?`tunnel-status`:null,z,{refreshInterval:e=>c?1e3:e?.frpcDownload||e?.state===`connecting`||e?.state===`reconnecting`?2e3:6e4}),F=(0,Q.useMemo)(()=>{let e=D?.payload?.config;if(e&&typeof e==`object`&&!Array.isArray(e)){let t=e.tunnel;if(t&&typeof t==`object`&&!Array.isArray(t)&&t.autoStart===!0)return!0}return O?.config?.autoStart===!0},[D,O?.config?.autoStart]),I=(0,Q.useMemo)(()=>{let e=D?.payload?.config;if(e&&typeof e==`object`&&!Array.isArray(e)){let t=e.tunnel;if(t&&typeof t==`object`&&!Array.isArray(t)){let e=t.registrationSecret;if(typeof e==`string`)return e}}return``},[D]),L=ie(I),R=O?.registrationSecret?.source===`env`,ee=O?.registrationSecret?.source===`missing`,B=O?.registrationSecret?.configured===!0;(0,Q.useEffect)(()=>{let e=()=>{P()};return window.addEventListener(`tunnel-status`,e),()=>window.removeEventListener(`tunnel-status`,e)},[P]);let V=(0,Q.useMemo)(()=>[n.consentBullet1,n.consentBullet2,n.consentBullet3],[n.consentBullet1,n.consentBullet2,n.consentBullet3]),H=(0,Q.useCallback)(async()=>{o({type:`patch`,patch:{actionError:null}}),o({type:`patch`,patch:{starting:!0}});try{let e=await se();await P(),M(),await E.refreshQr(e.qrPayload)}catch(e){o({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{o({type:`patch`,patch:{starting:!1}})}},[P,E.refreshQr]),ne=(0,Q.useCallback)(()=>{if(!B){o({type:`patch`,patch:{actionError:n.brokerSecretRequiredBeforeStart}}),T.current?.scrollIntoView({behavior:`smooth`,block:`start`});return}if(O?.consentRequired){o({type:`patch`,patch:{consentOpen:!0}});return}H()},[B,O?.consentRequired,H,n.brokerSecretRequiredBeforeStart]),re=(0,Q.useCallback)(async()=>{o({type:`patch`,patch:{consentOpen:!1}}),o({type:`patch`,patch:{actionError:null}});try{await me(),await Promise.all([P(),H()])}catch(e){o({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}},[P,H]),U=(0,Q.useCallback)(async()=>{o({type:`patch`,patch:{actionError:null}}),o({type:`patch`,patch:{stopping:!0}});try{await oe(),await Promise.all([E.refreshQr(),P()]),M()}catch(e){o({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{o({type:`patch`,patch:{stopping:!1}})}},[P,E.refreshQr]),W=(0,Q.useCallback)(async e=>{o({type:`patch`,patch:{savingAutoStart:!0}}),o({type:`patch`,patch:{actionError:null}});try{await te({autoStart:e}),M()}catch(e){o({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{o({type:`patch`,patch:{savingAutoStart:!1}})}},[]),G=(0,Q.useCallback)(()=>{if(F){W(!1);return}if(O?.consentRequired){o({type:`patch`,patch:{actionError:n.consentExpiredBanner}});return}if(!O?.canAutoStart){o({type:`patch`,patch:{actionError:n.autoStartHint}});return}o({type:`patch`,patch:{autoStartConfirmOpen:!0}})},[W,O?.canAutoStart,O?.consentRequired,n,F]),K=(0,Q.useCallback)(async()=>{let e=S.trim();if(e){o({type:`patch`,patch:{savingBrokerSecret:!0,actionError:null,brokerSecretNotice:null}});try{await te({registrationSecret:e}),o({type:`patch`,patch:{brokerSecretDraft:``,brokerSecretNotice:n.brokerSecretSaved}}),M(),await P(),o({type:`patch`,patch:{actionError:null}})}catch(e){o({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{o({type:`patch`,patch:{savingBrokerSecret:!1}})}}},[S,P,n.brokerSecretSaved]),q=(0,Q.useCallback)(async()=>{o({type:`patch`,patch:{savingBrokerSecret:!0,actionError:null,brokerSecretNotice:null}});try{await te({registrationSecret:null}),o({type:`patch`,patch:{brokerSecretDraft:``,brokerSecretNotice:n.brokerSecretCleared}}),M(),await P()}catch(e){o({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{o({type:`patch`,patch:{savingBrokerSecret:!1}})}},[P,n.brokerSecretCleared]),J=(0,Q.useCallback)(async()=>{o({type:`patch`,patch:{releaseConfirmOpen:!1,actionError:null,releasing:!0}});try{await oe({release:!0}),await Promise.all([E.refreshQr(),P()]),M()}catch(e){o({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{o({type:`patch`,patch:{releasing:!1}})}},[P,E.refreshQr]),Y=(0,Q.useMemo)(()=>({copy:n.copyUrl,copied:n.copied,copyFailed:m(t).clipboard.copyFailed}),[t,n.copyUrl,n.copied]);if(!i)return(0,$.jsx)(`div`,{className:e?void 0:`w-full px-3 py-8 sm:px-5 xl:px-6`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.needToken})});let X=O??{enabled:!1,state:`disconnected`,subdomain:null,publicUrl:null,connectedSince:null,frpcPid:null,lastHeartbeatAt:null,lastError:null,consentRequired:!0,config:{autoStart:F,brokerUrl:`https://frp.xopc.ai/api`}},ae=O?.consentRequired&&(X.enabled||F||O?.consent?.acceptedAt),ce=(0,$.jsx)(Qe,{t:n,brokerSecretFromEnv:R,brokerSecretMissing:ee,brokerSecretConfiguredInConfig:L,brokerSecretMaskedValue:L?I:``,brokerSecretDraft:S,savingBrokerSecret:C,brokerSecretNotice:w,copyFailedLabel:m(t).clipboard.copyFailed,onDraftChange:e=>o({type:`patch`,patch:{brokerSecretDraft:e}}),onSave:()=>void K(),onClear:()=>void q(),sectionRef:T}),de=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Ne,{open:g,title:n.consentTitle,intro:n.consentIntro,bullets:V,checkboxLabel:n.consentCheckbox,confirmLabel:ae?n.consentReconfirm:n.consentConfirm,cancelLabel:n.consentCancel,onConfirm:()=>void re(),onCancel:()=>o({type:`patch`,patch:{consentOpen:!1}})},g?`consent-open`:`consent-closed`),(0,$.jsx)(le,{open:y,title:n.autoStartConfirmTitle,description:n.autoStartConfirmBody,confirmLabel:n.autoStartConfirmLabel,cancelLabel:n.consentCancel,onConfirm:()=>{o({type:`patch`,patch:{autoStartConfirmOpen:!1}}),W(!0)},onCancel:()=>o({type:`patch`,patch:{autoStartConfirmOpen:!1}})}),(0,$.jsx)(le,{open:b,title:n.releaseConfirmTitle,description:n.releaseConfirmBody,confirmLabel:n.releaseConfirmLabel,cancelLabel:n.consentCancel,destructive:!0,onConfirm:()=>void J(),onCancel:()=>o({type:`patch`,patch:{releaseConfirmOpen:!1}})})]});return e?(0,$.jsxs)(`div`,{className:`flex w-full flex-col gap-4`,children:[s?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:s}):null,ce,(0,$.jsx)(Ye,{t:n,status:X,isLoading:A,statusErr:k,starting:c,stopping:p,showConsentExpired:!!ae,copyLabels:Y,startDisabled:!B,startDisabledReason:B?void 0:n.brokerSecretRequiredBeforeStart,stepLabel:n.flowStepStart,onStart:ne,onStop:()=>void U()}),(0,$.jsx)(ke,{pairQr:E,gatewayToken:r??``,streamlined:!0,onRefreshQr:()=>void E.refreshQr()}),(0,$.jsxs)(Ee,{showLabel:n.showOptions,hideLabel:n.hideOptions,children:[(0,$.jsxs)(`label`,{className:d(`flex items-center gap-3 text-sm text-fg`,!F&&!O?.canAutoStart?`cursor-not-allowed opacity-60`:`cursor-pointer`),children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`size-4 rounded border-edge accent-accent`,checked:F,disabled:h||!F&&!O?.canAutoStart,onChange:G}),n.autoStart]}),!O?.canAutoStart&&!F?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.autoStartHint}):null,X.subdomain||X.publicUrl?(0,$.jsxs)(`div`,{className:`space-y-2 border-t border-edge-subtle pt-4`,children:[(0,$.jsxs)(f,{type:`button`,variant:`secondary`,disabled:x||p,className:`border-danger/40 text-danger hover:bg-danger/10`,onClick:()=>o({type:`patch`,patch:{releaseConfirmOpen:!0}}),children:[x?(0,$.jsx)(u,{className:`size-4 animate-spin`}):null,n.release]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.releaseHint})]}):null]}),(0,$.jsx)(Ee,{showLabel:n.showAdvanced,hideLabel:n.hideAdvanced,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 border-t border-edge-subtle pt-4 text-xs text-fg-subtle`,children:[(0,$.jsxs)(`p`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(l,{className:`mt-0.5 size-4 shrink-0 text-accent`}),(0,$.jsx)(`span`,{children:n.brokerNote})]}),(0,$.jsx)(tt,{language:t,label:n.brokerDocsLink,section:`public-tunnel`,className:`text-xs`})]})}),de]}):(0,$.jsxs)(`div`,{className:e?`flex w-full flex-col gap-6`:`flex w-full flex-col gap-6 px-3 py-8 sm:px-5 xl:px-6`,children:[e?null:(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:n.title}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:n.subtitle})]}),s?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:s}):null,ce,(0,$.jsx)(Ye,{t:n,status:X,isLoading:A,statusErr:k,starting:c,stopping:p,showConsentExpired:!!ae,copyLabels:Y,startDisabled:!B,startDisabledReason:B?void 0:n.brokerSecretRequiredBeforeStart,onStart:ne,onStop:()=>void U()}),(0,$.jsx)(ke,{pairQr:E,gatewayToken:r??``}),X.subdomain||X.publicUrl?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,$.jsxs)(f,{type:`button`,variant:`secondary`,disabled:x||p,className:`border-danger/40 text-danger hover:bg-danger/10`,onClick:()=>o({type:`patch`,patch:{releaseConfirmOpen:!0}}),children:[x?(0,$.jsx)(u,{className:`size-4 animate-spin`}):null,n.release]})}):null,X.subdomain||X.publicUrl?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.releaseHint}):null,(0,$.jsxs)(Ce,{children:[(0,$.jsx)(`h2`,{className:`mb-3 text-sm font-semibold text-fg`,children:n.optionsTitle}),(0,$.jsxs)(`label`,{className:d(`flex items-center gap-3 text-sm text-fg`,!F&&!O?.canAutoStart?`cursor-not-allowed opacity-60`:`cursor-pointer`),children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`size-4 rounded border-edge accent-accent`,checked:F,disabled:h||!F&&!O?.canAutoStart,onChange:G}),n.autoStart]}),!O?.canAutoStart&&!F?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:n.autoStartHint}):null]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg bg-surface-panel/80 px-3 py-2 text-xs text-fg-subtle shadow-surface`,children:[(0,$.jsxs)(`p`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(l,{className:`mt-0.5 size-4 shrink-0 text-accent`}),(0,$.jsx)(`span`,{children:n.brokerNote})]}),(0,$.jsx)(tt,{language:t,label:n.brokerDocsLink,section:`public-tunnel`,className:`text-xs`})]}),de]})}async function dt(){let e=await y(`/api/exposure/status`);if(!e.ok)throw Error(`Failed to load exposure status (${e.status})`);return await e.json()}async function ft(e=`serve`){let t=await y(`/api/exposure/tailscale/start`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({mode:e})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error??`Start failed (${t.status})`)}return await t.json()}async function pt(){let e=await y(`/api/exposure/tailscale/stop`,{method:`POST`});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error??`Stop failed (${e.status})`)}return await e.json()}var mt=`https://tailscale.com/download`;function ht(e){let t=(0,Z.c)(2),{label:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(`a`,{href:mt,target:`_blank`,rel:`noreferrer`,className:`font-medium text-accent hover:underline`,children:n}),t[0]=n,t[1]=r),r}function gt({embedded:e=!1}){let t=v(e=>e.language),n=m(t).remoteAccess.tailscale,r=(0,Q.useMemo)(()=>({copy:n.copyUrl,copied:n.copied,copyFailed:m(t).clipboard.copyFailed}),[t,n.copyUrl,n.copied]),i=!!_(e=>e.token),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(null),{data:d,mutate:p,isLoading:h}=j(i?`exposure-status`:null,dt,{refreshInterval:3e4}),g=d?.tailscale.hostname,y=d?.tailscale.active===!0,b=d?.tailscale.cliAvailable!==!1,x=g?`https://${g}/`:null,S=(0,Q.useCallback)(async()=>{o(!0),c(null);try{await ft(`serve`),await p()}catch(e){c(e instanceof Error?e.message:String(e))}finally{o(!1)}},[p]),C=(0,Q.useCallback)(async()=>{o(!0),c(null);try{await pt(),await p()}catch(e){c(e instanceof Error?e.message:String(e))}finally{o(!1)}},[p]);if(!i)return null;let w=(0,$.jsxs)(`div`,{className:e?`space-y-4`:`mt-4 space-y-3`,children:[e?(0,$.jsxs)(`ol`,{className:`space-y-3 text-sm text-fg-muted`,children:[(0,$.jsxs)(`li`,{className:`flex gap-2`,children:[(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded-full bg-surface-hover text-xs font-semibold text-fg`,children:`1`}),(0,$.jsxs)(`span`,{children:[n.stepInstallBefore,(0,$.jsx)(ht,{label:n.stepInstallLink}),n.stepInstallAfter]})]}),(0,$.jsxs)(`li`,{className:`flex gap-2`,children:[(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded-full bg-surface-hover text-xs font-semibold text-fg`,children:`2`}),(0,$.jsx)(`span`,{children:n.stepEnable})]}),(0,$.jsxs)(`li`,{className:`flex gap-2`,children:[(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center rounded-full bg-surface-hover text-xs font-semibold text-fg`,children:`3`}),(0,$.jsx)(`span`,{children:n.stepCopy})]})]}):null,e&&d?.tailscale.cliAvailable===!1?(0,$.jsxs)(`p`,{className:`rounded-lg border border-amber-500/25 bg-amber-500/5 px-3 py-2 text-sm text-fg-muted`,children:[n.cliMissingIntro,` `,(0,$.jsx)(ht,{label:n.cliMissingDownloadLink}),n.cliMissingSuffix]}):null,h&&!d?(0,$.jsxs)(`div`,{className:`grid gap-3`,"aria-busy":`true`,children:[(0,$.jsx)(U,{className:`h-20 rounded-lg`}),(0,$.jsx)(U,{className:`h-20 rounded-lg`})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(Ce,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:n.statusLabel}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:y?n.statusActive:n.statusOff}),x?(0,$.jsx)(`div`,{className:`mt-3`,children:(0,$.jsx)(de,{text:x,labels:r})}):null,s?(0,$.jsx)(`p`,{className:`mt-2 text-sm text-red-600 dark:text-red-400`,children:s}):null,(0,$.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:y?(0,$.jsxs)(f,{type:`button`,variant:`secondary`,disabled:a,onClick:()=>void C(),children:[a?(0,$.jsx)(u,{className:`mr-1 size-4 animate-spin`}):null,n.disableServe]}):(0,$.jsxs)(f,{type:`button`,disabled:a||!b,onClick:()=>void S(),children:[a?(0,$.jsx)(u,{className:`mr-1 size-4 animate-spin`}):(0,$.jsx)(ce,{className:`mr-1 size-4`}),n.enableServe]})})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.hint}),(0,$.jsx)(tt,{language:t,label:n.docsLink,section:`tailscale-serve`,className:`mt-2`})]})]});return e?w:(0,$.jsxs)(Ce,{children:[(0,$.jsx)(xe,{icon:l,title:n.title,subtitle:n.subtitle}),w]})}function _t(){let e=(0,Z.c)(26),t=v(yt),n=_(vt),r;e[0]===t?r=e[1]:(r=m(t),e[0]=t,e[1]=r);let i=r.remoteAccess.lan,o;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(o={preferLan:!0},e[2]=o):o=e[2];let s=ct(n??``,o),l;e[3]!==i.subtitle||e[4]!==i.title?(l=(0,$.jsx)(xe,{icon:G,title:i.title,subtitle:i.subtitle}),e[3]=i.subtitle,e[4]=i.title,e[5]=l):l=e[5];let u;e[6]===i.body?u=e[7]:(u=(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:i.body}),e[6]=i.body,e[7]=u);let d;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,$.jsx)(c,{className:`size-3.5`,"aria-hidden":!0}),e[8]=d):d=e[8];let f;e[9]===i.link?f=e[10]:(f=(0,$.jsxs)(a,{to:`/settings/gateway`,className:`inline-flex items-center gap-1.5 text-sm font-medium text-accent hover:underline`,children:[i.link,d]}),e[9]=i.link,e[10]=f);let p;e[11]!==u||e[12]!==f?(p=(0,$.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[u,f]}),e[11]=u,e[12]=f,e[13]=p):p=e[13];let h;e[14]!==l||e[15]!==p?(h=(0,$.jsxs)(Ce,{children:[l,p]}),e[14]=l,e[15]=p,e[16]=h):h=e[16];let g=n??``,y;e[17]===s?y=e[18]:(y=()=>void s.refreshQr(),e[17]=s,e[18]=y);let b;e[19]!==s||e[20]!==g||e[21]!==y?(b=(0,$.jsx)(ke,{pairQr:s,gatewayToken:g,lanOnly:!0,onRefreshQr:y}),e[19]=s,e[20]=g,e[21]=y,e[22]=b):b=e[22];let x;return e[23]!==b||e[24]!==h?(x=(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[h,b]}),e[23]=b,e[24]=h,e[25]=x):x=e[25],x}function vt(e){return e.token}function yt(e){return e.language}function bt(e){let t=(0,Z.c)(30),{embedded:n}=e,r=n===void 0?!1:n,i=v(xt),a;t[0]===i?a=t[1]:(a=m(i),t[0]=i,t[1]=a);let o=a.remoteAccess.ssh,[c,l]=(0,Q.useState)(!1),u;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=async()=>{await p(`xopc gateway ssh-tunnel --target user@your-host --local-port 18790 --remote-port 18790`)&&(l(!0),setTimeout(()=>l(!1),2e3))},t[2]=u):u=t[2];let d=u,h;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(`pre`,{className:`overflow-x-auto rounded-lg border border-edge bg-surface px-3 py-2 text-xs text-fg-muted`,children:`xopc gateway ssh-tunnel --target user@your-host --local-port 18790 --remote-port 18790`}),t[3]=h):h=t[3];let g,_;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(g=()=>void d(),_=(0,$.jsx)(s,{className:`mr-1 size-4`}),t[4]=g,t[5]=_):(g=t[4],_=t[5]);let y=c?o.copied:o.copy,b;t[6]===y?b=t[7]:(b=(0,$.jsx)(`div`,{className:`mt-2`,children:(0,$.jsxs)(f,{type:`button`,variant:`ghost`,onClick:g,children:[_,y]})}),t[6]=y,t[7]=b);let x;t[8]!==r||t[9]!==o.hint?(x=r?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:o.hint}):null,t[8]=r,t[9]=o.hint,t[10]=x):x=t[10];let S;t[11]!==b||t[12]!==x?(S=(0,$.jsxs)($.Fragment,{children:[h,b,x]}),t[11]=b,t[12]=x,t[13]=S):S=t[13];let C=S;if(r){let e;t[14]!==o.subtitle||t[15]!==o.title?(e=(0,$.jsx)(xe,{icon:he,title:o.title,subtitle:o.subtitle}),t[14]=o.subtitle,t[15]=o.title,t[16]=e):e=t[16];let n;t[17]===C?n=t[18]:(n=(0,$.jsx)(`div`,{className:`mt-4 space-y-2`,children:C}),t[17]=C,t[18]=n);let r;return t[19]!==e||t[20]!==n?(r=(0,$.jsxs)(Ce,{children:[e,n]}),t[19]=e,t[20]=n,t[21]=r):r=t[21],r}let w;t[22]!==o.subtitle||t[23]!==o.title?(w=(0,$.jsx)(xe,{icon:he,title:o.title,subtitle:o.subtitle}),t[22]=o.subtitle,t[23]=o.title,t[24]=w):w=t[24];let T;t[25]===C?T=t[26]:(T=(0,$.jsx)(`div`,{className:`mt-4`,children:C}),t[25]=C,t[26]=T);let E;return t[27]!==w||t[28]!==T?(E=(0,$.jsxs)(Ce,{children:[w,T]}),t[27]=w,t[28]=T,t[29]=E):E=t[29],E}function xt(e){return e.language}function St(){let e=(0,Z.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(bt,{embedded:!0}),e[0]=t):t=e[0],t}function Ct(e){switch(e){case`active`:return`bg-emerald-500/15 text-emerald-700 dark:text-emerald-400`;case`connecting`:return`bg-amber-500/15 text-amber-700 dark:text-amber-400`;default:return`bg-surface-hover text-fg-muted`}}function wt(e){let t=(0,Z.c)(5),{label:n,kind:r}=e,i;t[0]===r?i=t[1]:(i=d(`rounded-full px-2 py-0.5 text-[11px] font-medium`,Ct(r)),t[0]=r,t[1]=i);let a;return t[2]!==n||t[3]!==i?(a=(0,$.jsx)(`span`,{className:i,children:n}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a}function Tt(e){let t=(0,Z.c)(32),{onOpenTab:n}=e,r=v(Ot),i;t[0]===r?i=t[1]:(i=m(r),t[0]=r,t[1]=i);let a=i.remoteAccess.guide,o=!!_(Dt),s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s={refreshInterval:3e4},t[2]=s):s=t[2];let{data:c}=j(o?`exposure-status`:null,dt,s),u;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(u={refreshInterval:15e3},t[3]=u):u=t[3];let{data:f}=j(o?`tunnel-status`:null,z,u),p;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(p={refreshInterval:6e4},t[4]=p):p=t[4];let{data:h}=j(o?`tunnel-pair-context`:null,q,p);if(!o)return null;let g=c?.tailscale.active===!0,y=f?.state,b=f?.enabled&&y===`connected`,x=f?.enabled&&(y===`connecting`||y===`reconnecting`||!!f?.startProgress||!!f?.frpcDownload),S=(h?.candidates??[]).some(Et),C=g?`active`:`off`,w=g?a.statusActive:a.statusOff,T;t[5]!==a.tailscaleCardTitle||t[6]!==C||t[7]!==w?(T={tab:`tailscale`,icon:l,title:a.tailscaleCardTitle,kind:C,statusLabel:w},t[5]=a.tailscaleCardTitle,t[6]=C,t[7]=w,t[8]=T):T=t[8];let E=b?`active`:x?`connecting`:`off`,D=b?a.statusActive:x?a.statusConnecting:a.statusOff,O;t[9]!==a.publicCardTitle||t[10]!==E||t[11]!==D?(O={tab:`public`,icon:fe,title:a.publicCardTitle,kind:E,statusLabel:D},t[9]=a.publicCardTitle,t[10]=E,t[11]=D,t[12]=O):O=t[12];let k=S?`active`:`off`,A=S?a.statusActive:a.statusOff,M;t[13]!==a.reverseProxyCardTitle||t[14]!==k||t[15]!==A?(M={tab:`reverse-proxy`,icon:H,title:a.reverseProxyCardTitle,kind:k,statusLabel:A},t[13]=a.reverseProxyCardTitle,t[14]=k,t[15]=A,t[16]=M):M=t[16];let N;t[17]!==a.sshCardStatus||t[18]!==a.sshCardTitle?(N={tab:`ssh`,icon:he,title:a.sshCardTitle,kind:`off`,statusLabel:a.sshCardStatus},t[17]=a.sshCardStatus,t[18]=a.sshCardTitle,t[19]=N):N=t[19];let P;t[20]!==a.lanCardStatus||t[21]!==a.lanCardTitle?(P={tab:`lan`,icon:G,title:a.lanCardTitle,kind:`off`,statusLabel:a.lanCardStatus},t[20]=a.lanCardStatus,t[21]=a.lanCardTitle,t[22]=P):P=t[22];let F;t[23]!==O||t[24]!==M||t[25]!==N||t[26]!==P||t[27]!==T?(F=[T,O,M,N,P],t[23]=O,t[24]=M,t[25]=N,t[26]=P,t[27]=T,t[28]=F):F=t[28];let I=F,L;return t[29]!==I||t[30]!==n?(L=(0,$.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-5`,children:I.map(e=>{let t=e.icon;return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>n(e.tab),className:d(`flex items-start gap-3 rounded-xl bg-surface-base px-3 py-2.5 text-left shadow-surface transition-colors`,`hover:bg-surface-hover/50`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),children:[(0,$.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-hover/90 text-fg-muted`,children:(0,$.jsx)(t,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:e.title}),(0,$.jsx)(wt,{label:e.statusLabel,kind:e.kind})]})]},`${e.tab}-${e.title}`)})}),t[29]=I,t[30]=n,t[31]=L):L=t[31],L}function Et(e){return e.kind===`reverse-proxy`}function Dt(e){return e.token}function Ot(e){return e.language}function kt(e){let t=(0,Z.c)(26),{title:n,description:r,recommended:i,icon:a,onOpen:o,openLabel:s,recommendedLabel:c}=e,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=d(`group flex w-full flex-col rounded-2xl bg-surface-base p-4 text-left transition-colors`,`hover:bg-surface-hover/40`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),t[0]=l):l=t[0];let u;t[1]===a?u=t[2]:(u=(0,$.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-hover/90 text-fg-muted`,children:(0,$.jsx)(a,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}),t[1]=a,t[2]=u);let f;t[3]===n?f=t[4]:(f=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n}),t[3]=n,t[4]=f);let p;t[5]!==i||t[6]!==c?(p=i&&c?(0,$.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,children:c}):null,t[5]=i,t[6]=c,t[7]=p):p=t[7];let m;t[8]!==f||t[9]!==p?(m=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[f,p]}),t[8]=f,t[9]=p,t[10]=m):m=t[10];let h;t[11]===r?h=t[12]:(h=(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:r}),t[11]=r,t[12]=h);let g;t[13]!==m||t[14]!==h?(g=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[m,h]}),t[13]=m,t[14]=h,t[15]=g):g=t[15];let _;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(re,{className:`mt-0.5 size-4 shrink-0 text-fg-subtle transition-transform group-hover:translate-x-0.5`,"aria-hidden":!0}),t[16]=_):_=t[16];let v;t[17]!==u||t[18]!==g?(v=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[u,g,_]}),t[17]=u,t[18]=g,t[19]=v):v=t[19];let y;t[20]===s?y=t[21]:(y=(0,$.jsx)(`span`,{className:`mt-3 text-xs font-medium text-accent`,children:s}),t[20]=s,t[21]=y);let b;return t[22]!==o||t[23]!==y||t[24]!==v?(b=(0,$.jsxs)(`button`,{type:`button`,onClick:o,className:l,children:[v,y]}),t[22]=o,t[23]=y,t[24]=v,t[25]=b):b=t[25],b}function At(e){let t=(0,Z.c)(83),{onOpenTab:n}=e,r=v(Nt),i;t[0]===r?i=t[1]:(i=m(r),t[0]=r,t[1]=i);let a=i.remoteAccess,o=a.guide,s=!!_(Mt),c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c={refreshInterval:3e4},t[2]=c):c=t[2];let{data:u}=j(s?`exposure-status`:null,dt,c),d;t[3]===u?.conflicts?d=t[4]:(d=u?.conflicts??[],t[3]=u?.conflicts,t[4]=d);let f=d;if(!s){let e;return t[5]===o.needToken?e=t[6]:(e=(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:o.needToken}),t[5]=o.needToken,t[6]=e),e}let p;t[7]===n?p=t[8]:(p=(0,$.jsx)(Tt,{onOpenTab:n}),t[7]=n,t[8]=p);let h;t[9]!==f||t[10]!==o.conflictsHint||t[11]!==o.conflictsTitle?(h=f.length>0?(0,$.jsxs)(`div`,{className:`rounded-xl border border-amber-500/30 bg-amber-500/5 px-4 py-3 text-sm text-fg-muted`,children:[(0,$.jsx)(`p`,{className:`font-medium text-fg`,children:o.conflictsTitle}),(0,$.jsx)(`p`,{className:`mt-1`,children:o.conflictsHint}),(0,$.jsx)(`ul`,{className:`mt-2 list-inside list-disc text-xs`,children:f.map(jt)})]}):null,t[9]=f,t[10]=o.conflictsHint,t[11]=o.conflictsTitle,t[12]=h):h=t[12];let g;t[13]===o.pickMethod?g=t[14]:(g=(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:o.pickMethod}),t[13]=o.pickMethod,t[14]=g);let y;t[15]===n?y=t[16]:(y=()=>n(`tailscale`),t[15]=n,t[16]=y);let b;t[17]!==o.configure||t[18]!==o.recommended||t[19]!==o.tailscaleCardDesc||t[20]!==o.tailscaleCardTitle||t[21]!==y?(b=(0,$.jsx)(kt,{icon:l,title:o.tailscaleCardTitle,description:o.tailscaleCardDesc,recommended:!0,recommendedLabel:o.recommended,openLabel:o.configure,onOpen:y}),t[17]=o.configure,t[18]=o.recommended,t[19]=o.tailscaleCardDesc,t[20]=o.tailscaleCardTitle,t[21]=y,t[22]=b):b=t[22];let x;t[23]===n?x=t[24]:(x=()=>n(`public`),t[23]=n,t[24]=x);let S;t[25]!==o.configure||t[26]!==o.publicCardDesc||t[27]!==o.publicCardTitle||t[28]!==x?(S=(0,$.jsx)(kt,{icon:fe,title:o.publicCardTitle,description:o.publicCardDesc,openLabel:o.configure,onOpen:x}),t[25]=o.configure,t[26]=o.publicCardDesc,t[27]=o.publicCardTitle,t[28]=x,t[29]=S):S=t[29];let C;t[30]===n?C=t[31]:(C=()=>n(`reverse-proxy`),t[30]=n,t[31]=C);let w;t[32]!==o.configure||t[33]!==o.reverseProxyCardDesc||t[34]!==o.reverseProxyCardTitle||t[35]!==C?(w=(0,$.jsx)(kt,{icon:H,title:o.reverseProxyCardTitle,description:o.reverseProxyCardDesc,openLabel:o.configure,onOpen:C}),t[32]=o.configure,t[33]=o.reverseProxyCardDesc,t[34]=o.reverseProxyCardTitle,t[35]=C,t[36]=w):w=t[36];let T;t[37]===n?T=t[38]:(T=()=>n(`ssh`),t[37]=n,t[38]=T);let E;t[39]!==o.configure||t[40]!==o.sshCardDesc||t[41]!==o.sshCardTitle||t[42]!==T?(E=(0,$.jsx)(kt,{icon:he,title:o.sshCardTitle,description:o.sshCardDesc,openLabel:o.configure,onOpen:T}),t[39]=o.configure,t[40]=o.sshCardDesc,t[41]=o.sshCardTitle,t[42]=T,t[43]=E):E=t[43];let D;t[44]===n?D=t[45]:(D=()=>n(`lan`),t[44]=n,t[45]=D);let O;t[46]!==o.configure||t[47]!==o.lanCardDesc||t[48]!==o.lanCardTitle||t[49]!==D?(O=(0,$.jsx)(kt,{icon:G,title:o.lanCardTitle,description:o.lanCardDesc,openLabel:o.configure,onOpen:D}),t[46]=o.configure,t[47]=o.lanCardDesc,t[48]=o.lanCardTitle,t[49]=D,t[50]=O):O=t[50];let k;t[51]!==S||t[52]!==w||t[53]!==E||t[54]!==O||t[55]!==b?(k=(0,$.jsxs)(`div`,{className:`mt-3 grid gap-3 lg:grid-cols-2`,children:[b,S,w,E,O]}),t[51]=S,t[52]=w,t[53]=E,t[54]=O,t[55]=b,t[56]=k):k=t[56];let A;t[57]!==k||t[58]!==g?(A=(0,$.jsxs)(`div`,{children:[g,k]}),t[57]=k,t[58]=g,t[59]=A):A=t[59];let M;t[60]===o.oneAtATimeHint?M=t[61]:(M=(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:o.oneAtATimeHint}),t[60]=o.oneAtATimeHint,t[61]=M);let N;t[62]===a.advanced.proxyTitle?N=t[63]:(N=(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.advanced.proxyTitle}),t[62]=a.advanced.proxyTitle,t[63]=N);let P;t[64]===a.advanced.proxyBody?P=t[65]:(P=(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:a.advanced.proxyBody}),t[64]=a.advanced.proxyBody,t[65]=P);let F;t[66]!==r||t[67]!==a.advanced.proxyDocs?(F=(0,$.jsx)(tt,{language:r,label:a.advanced.proxyDocs,section:`advanced`,className:`mt-2`}),t[66]=r,t[67]=a.advanced.proxyDocs,t[68]=F):F=t[68];let I;t[69]!==N||t[70]!==P||t[71]!==F?(I=(0,$.jsxs)(`div`,{className:`rounded-xl bg-surface-base px-4 py-3`,children:[N,P,F]}),t[69]=N,t[70]=P,t[71]=F,t[72]=I):I=t[72];let L;t[73]!==o.docsLink||t[74]!==r?(L=(0,$.jsx)(tt,{language:r,label:o.docsLink}),t[73]=o.docsLink,t[74]=r,t[75]=L):L=t[75];let R;return t[76]!==A||t[77]!==M||t[78]!==I||t[79]!==L||t[80]!==p||t[81]!==h?(R=(0,$.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[p,h,A,M,I,L]}),t[76]=A,t[77]=M,t[78]=I,t[79]=L,t[80]=p,t[81]=h,t[82]=R):R=t[82],R}function jt(e){return(0,$.jsx)(`li`,{children:e.message},e.code)}function Mt(e){return e.token}function Nt(e){return e.language}async function Pt(e){let t=await y(b(`/api/tunnel/pair/probe-public`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({url:e})});if(!t.ok&&t.status!==400)throw Error(`Probe failed (${t.status})`);return await t.json()}async function Ft(e){await x(b(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{publicUrl:e??null}})})}function It(e){let t=e.split(`.`).map(e=>Number.parseInt(e,10));if(t.length!==4||t.some(e=>!Number.isFinite(e)))return!1;let[n,r]=t;return n===10||n===127||n===169&&r===254||n===172&&r>=16&&r<=31||n===192&&r===168||n===100&&r>=64&&r<=127}function Lt(){return(0,Q.useMemo)(()=>{if(typeof window>`u`)return null;let{protocol:e,hostname:t,origin:n}=window.location;if(e!==`https:`&&e!==`http:`)return null;let r=t.toLowerCase();return!r||r===`localhost`||r===`127.0.0.1`||r===`::1`||r===`[::1]`||r.endsWith(`.local`)||r.endsWith(`.localhost`)||It(r)?null:n.toLowerCase().replace(/\/+$/,``)},[])}function Rt(){return d(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,P,`dark:border-edge`)}function zt(e){return(e?.candidates.find(e=>e.kind===`reverse-proxy`))?.url?.trim()||null}function Bt(e){return(e?.candidates.find(e=>e.kind===`lan`&&e.reachable))?.url?.trim()||null}function Vt(){let e=v(e=>e.language),t=m(e).remoteAccess.reverseProxy,n=!!_(e=>e.token),r=Lt(),{mutate:i}=A(),{data:a,mutate:o}=j(n?`tunnel-pair-context`:null,q,{refreshInterval:6e4}),s=zt(a),[c,p]=(0,Q.useState)(``),[h,y]=(0,Q.useState)({busy:!1,result:null}),[b,x]=(0,Q.useState)({busy:!1,error:null});(0,Q.useEffect)(()=>{c||(s?p(s):r&&p(r))},[s,r,c]);let S=(0,Q.useMemo)(()=>c.trim()||(s??r??``),[s,r,c]),C=!s&&!!r&&S===r,w=Bt(a),{data:T,mutate:E}=j(n&&S?[`reverse-proxy-pair`,S]:null,()=>Y(),{refreshInterval:4*6e4,revalidateOnFocus:!1}),D=(0,Q.useMemo)(()=>!S||!T?.pairingSecret?``:g({baseUrl:S,pairingSecret:T.pairingSecret,lanUrl:w}),[S,w,T?.pairingSecret]),O=J(()=>it(D),[D],{enabled:!!D,initial:null,errorData:null}),k=(0,Q.useCallback)(async()=>{let e=c.trim()||S;if(e){y({busy:!0,result:null});try{y({busy:!1,result:await Pt(e)})}catch(e){y({busy:!1,result:{ok:!1,code:`NETWORK_ERROR`,message:e instanceof Error?e.message:String(e)}})}}},[c,S]),M=(0,Q.useCallback)(async()=>{let e=S.trim();if(e){x({busy:!0,error:null});try{await Ft(e),await o(),await i(`tunnel-pair-context`),x({busy:!1,error:null})}catch(e){x({busy:!1,error:e instanceof Error?e.message:String(e)})}}},[S,i,o]),N=(0,Q.useCallback)(async()=>{x({busy:!0,error:null});try{await Ft(null),await o(),await i(`tunnel-pair-context`),p(``),y({busy:!1,result:null}),x({busy:!1,error:null})}catch(e){x({busy:!1,error:e instanceof Error?e.message:String(e)})}},[i,o]),P=(0,Q.useCallback)(async()=>{await E()},[E]);return n?(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,$.jsxs)(Ce,{children:[(0,$.jsx)(xe,{icon:l,title:t.title,subtitle:t.subtitle}),(0,$.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,$.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`reverse-proxy-url`,children:t.urlLabel}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-stretch`,children:[(0,$.jsx)(`input`,{id:`reverse-proxy-url`,className:d(Rt(),`font-mono text-xs sm:flex-1 sm:min-w-0 sm:w-auto`),type:`text`,autoComplete:`off`,spellCheck:!1,placeholder:t.urlPlaceholder,value:c,onChange:e=>{p(e.target.value),y({busy:!1,result:null})}}),(0,$.jsxs)(f,{type:`button`,variant:`secondary`,className:`shrink-0 whitespace-nowrap`,onClick:()=>void k(),disabled:h.busy||!c.trim(),children:[h.busy?(0,$.jsx)(u,{className:`size-3.5 animate-spin`}):null,h.busy?t.probing:t.probeButton]})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:t.urlHint}),C&&r?(0,$.jsxs)(`div`,{className:`rounded-lg border border-accent/40 bg-accent-soft/50 px-3 py-2 text-xs leading-relaxed text-accent-fg`,children:[(0,$.jsx)(`div`,{className:`font-medium`,children:t.autoDetectedTitle}),(0,$.jsx)(`div`,{className:`mt-1 break-all font-mono text-[11px]`,children:r}),(0,$.jsx)(`p`,{className:`mt-1`,children:t.autoDetectedHint})]}):null,h.result?(0,$.jsx)(Ht,{result:h.result,labels:t.probeStatus}):null,(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:flex-wrap`,children:[S&&s!==S?(0,$.jsxs)(f,{type:`button`,onClick:()=>void M(),disabled:b.busy,children:[b.busy?(0,$.jsx)(u,{className:`size-3.5 animate-spin`}):null,b.busy?t.saving:t.saveAsDefault]}):null,s?(0,$.jsx)(f,{type:`button`,variant:`ghost`,onClick:()=>void N(),disabled:b.busy,children:t.clear}):null]}),b.error?(0,$.jsx)(`p`,{className:`text-xs text-red-800 dark:text-red-200`,children:b.error}):null,(0,$.jsx)(`div`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs leading-relaxed text-amber-950 dark:border-amber-800/60 dark:bg-amber-950/30 dark:text-amber-100`,children:t.certWarning})]})]}),(0,$.jsxs)(Ce,{children:[(0,$.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-start justify-between gap-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:t.qrTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.qrSubtitle})]}),D?(0,$.jsxs)(f,{type:`button`,variant:`ghost`,className:`shrink-0`,onClick:()=>void P(),children:[(0,$.jsx)(ae,{className:`size-4`}),t.refreshQr]}):null]}),S?T?.pairingSecret?(0,$.jsxs)(`div`,{className:`flex flex-col items-center gap-3 sm:items-start`,children:[(0,$.jsxs)(`div`,{className:`break-all font-mono text-[11px] text-fg-muted`,children:[(0,$.jsx)(`span`,{className:`font-medium text-fg`,children:`baseUrl:`}),` `,S,w?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`br`,{}),(0,$.jsx)(`span`,{className:`font-medium text-fg`,children:`lanUrl:`}),` `,w]}):null]}),O.data?(0,$.jsx)(`img`,{src:O.data,alt:``,className:`size-56 rounded-lg border border-edge-subtle bg-white object-contain p-3 dark:border-edge`}):O.loading?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.encoding}):null,(0,$.jsx)(de,{text:D,labels:{copy:t.copyLink,copied:t.copied,copyFailed:m(e).clipboard.copyFailed}})]}):(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.mintingSecret}):(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.noUrlYet})]})]}):null}function Ht(e){let t=(0,Z.c)(18),{result:n,labels:r}=e;if(n.ok){let e;t[0]===r.ok?e=t[1]:(e=(0,$.jsx)(`span`,{className:`font-medium`,children:r.ok}),t[0]=r.ok,t[1]=e);let i;t[2]===n.latencyMs?i=t[3]:(i=(0,$.jsxs)(`span`,{className:`font-mono`,children:[n.latencyMs,`ms`]}),t[2]=n.latencyMs,t[3]=i);let a;t[4]!==r.mobileReady||t[5]!==n.mobilePairing?(a=n.mobilePairing?(0,$.jsxs)($.Fragment,{children:[` · `,(0,$.jsx)(`span`,{children:r.mobileReady})]}):null,t[4]=r.mobileReady,t[5]=n.mobilePairing,t[6]=a):a=t[6];let o;return t[7]!==e||t[8]!==i||t[9]!==a?(o=(0,$.jsxs)(`div`,{className:`rounded-lg border border-emerald-200 bg-emerald-50 px-3 py-2 text-xs text-emerald-900 dark:border-emerald-800/60 dark:bg-emerald-950/30 dark:text-emerald-100`,children:[e,` · `,i,a]}),t[7]=e,t[8]=i,t[9]=a,t[10]=o):o=t[10],o}let i=r[`code_${n.code}`]??r.codeUnknown,a;t[11]===i?a=t[12]:(a=(0,$.jsx)(`span`,{className:`font-medium`,children:i}),t[11]=i,t[12]=a);let o;t[13]===n.message?o=t[14]:(o=n.message?(0,$.jsxs)($.Fragment,{children:[` — `,(0,$.jsx)(`span`,{className:`font-mono break-all`,children:n.message})]}):null,t[13]=n.message,t[14]=o);let s;return t[15]!==a||t[16]!==o?(s=(0,$.jsxs)(`div`,{className:`rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-900 dark:border-red-800/60 dark:bg-red-950/30 dark:text-red-100`,children:[a,o]}),t[15]=a,t[16]=o,t[17]=s):s=t[17],s}var Ut=[`guide`,`tailscale`,`public`,`reverse-proxy`,`ssh`,`lan`];function Wt(e){return e&&Ut.includes(e)?e:`guide`}function Gt(e,t){return e.tabs[t]}function Kt(e,t){return e.tabIntro[t]}function qt(e){switch(e){case`tailscale`:return`tailscale-serve`;case`public`:return`public-tunnel`;case`reverse-proxy`:return`reverse-proxy`;case`ssh`:return`ssh-tunnel`;case`lan`:return`lan`;default:return}}function Jt(e){let t=(0,Z.c)(7),{tab:n,onOpenTab:r}=e;switch(n){case`guide`:{let e;return t[0]===r?e=t[1]:(e=(0,$.jsx)(At,{onOpenTab:r}),t[0]=r,t[1]=e),e}case`tailscale`:{let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(gt,{embedded:!0}),t[2]=e):e=t[2],e}case`public`:{let e;return t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(ut,{embedded:!0}),t[3]=e):e=t[3],e}case`reverse-proxy`:{let e;return t[4]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Vt,{}),t[4]=e):e=t[4],e}case`ssh`:{let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(St,{}),t[5]=e):e=t[5],e}case`lan`:{let e;return t[6]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(_t,{}),t[6]=e):e=t[6],e}}}function Yt(){let e=(0,Z.c)(2),t=v(Zt),n=m(t).remoteAccess,r=!!_(Xt),[a,o]=i(),s=Wt(a.get(`tab`)),c;e[0]===o?c=e[1]:(c=e=>{o(t=>{let n=new URLSearchParams(t);return e===`guide`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},e[0]=o,e[1]=c);let l=c,u=Kt(n,s),d=Ut.map(e=>({id:e,label:Gt(n,e)}));return(0,$.jsxs)(ve,{children:[(0,$.jsx)(_e,{title:n.pageTitle,subtitle:n.pageSubtitle,meta:(0,$.jsx)(tt,{language:t,label:n.docsLink,section:qt(s),className:`mt-1`})}),r?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Te,{items:d,activeTab:s,onChange:l,ariaLabel:n.tabsAria,tabIdPrefix:`remote-access-tab`,panelIdPrefix:`remote-access-panel`}),(0,$.jsx)(ye,{id:s,activeTab:s,tabIdPrefix:`remote-access-tab`,panelIdPrefix:`remote-access-panel`,title:Gt(n,s),hint:s===`public`?void 0:u,children:(0,$.jsx)(Jt,{tab:s,onOpenTab:l})})]}):(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.guide.needToken})]})}function Xt(e){return e.token}function Zt(e){return e.language}export{Yt as RemoteAccessHub};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{f as i}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{n as a,r as o}from"./popover-select-BzdnTy3h.js";import{t as s}from"./download-Dk-ZjtO6.js";import{t as c}from"./plus-Q2yW6OE7.js";import{t as l}from"./x-B_N4OPjy.js";import{t as u}from"./cn-JdwAhgNB.js";import{t as d}from"./button-CSEbl4zT.js";import{t as f}from"./messages-ctG2e-ix.js";import{l as p,n as m,r as h,s as g}from"./locale-store-C5MK9WcP.js";import{i as _,o as v}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{a as ee,n as y,o as b,r as te,s as x,t as ne}from"./dist-BPoKqzeH.js";import{i as S}from"./vendor-swr-BIWyz7Rc.js";import{n as C,r as w}from"./gateway-config-swr-BIxuwPQi.js";import{$i as T,$o as E,Ac as D,Bs as O,Da as k,Is as A,Jo as j,Jt as M,Mc as N,Oa as P,Qi as F,Sl as I,Xi as L,Xt as R,Yi as z,Yt as B,Zc as V,Zi as H,Zt as U,dl as W,ea as re,ec as ie,et as ae,fc as G,hi as oe,hs as se,ia as ce,kc as le,lt as ue,mc as de,mi as K,nu as fe,pi as q,qo as J,ra as pe,ta as me,tc as he,ts as ge,tu as _e}from"./index-_cuTcWjB.js";import{n as ve,t as ye}from"./use-autosave-CKpatP3S.js";import{t as be}from"./settings-advanced-gate-OP1y0Y8M.js";import{n as xe,t as Y}from"./settings-form-section-B9dnKr3M.js";import{t as Se}from"./page-tabs-CBuCKeyy.js";var X=e(t(),1),Ce=n(),Z=r();function we(e){let t=new Date(e),n=Math.floor((new Date().getTime()-t.getTime())/(1e3*60*60*24));return n===0?t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}):n===1?`Yesterday`:n<7?t.toLocaleDateString([],{weekday:`short`}):t.toLocaleDateString([],{month:`short`,day:`numeric`})}function Te(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function Ee(e){let t=(0,Ce.c)(105),{session:n,variant:r,labels:i,sessionAgentId:a,sessionAgentAvatar:o,onOpen:c,onAction:l}=e,d;t[0]!==i.unnamedSession||t[1]!==n.name?(d=n.name?.trim()||i.unnamedSession,t[0]=i.unnamedSession,t[1]=n.name,t[2]=d):d=t[2];let f=d,p;t[3]===n.name?p=t[4]:(p=n.name?.trim(),t[3]=n.name,t[4]=p);let m=!!p,h=n.status===`archived`,g=n.status===`pinned`,_=r===`list`&&`sm:flex-row sm:items-center sm:gap-4`,v;t[5]===_?v=t[6]:(v=u(`group flex min-w-0 w-full max-w-full cursor-pointer flex-col rounded-xl bg-surface-base text-left transition-colors duration-150 ease-out`,`hover:bg-surface-hover active:scale-[0.99]`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel`,_),t[5]=_,t[6]=v);let ee;t[7]===c?ee=t[8]:(ee=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),c())},t[7]=c,t[8]=ee);let y=r===`list`&&`sm:py-3`,b;t[9]===y?b=t[10]:(b=u(`flex min-w-0 items-start justify-between gap-2 bg-surface-hover/35 px-3 py-2 dark:bg-surface-hover/25`,y),t[9]=y,t[10]=b);let te;t[11]===n.sourceChannel?te=t[12]:(te=(0,Z.jsx)(`div`,{className:`flex min-w-0 items-center gap-2`,children:(0,Z.jsx)(`span`,{className:`truncate text-[11px] font-medium uppercase tracking-wide text-fg-subtle`,children:n.sourceChannel})}),t[11]=n.sourceChannel,t[12]=te);let x;t[13]===g?x=t[14]:(x=g?(0,Z.jsx)(he,{className:`size-3.5 text-accent-fg`,strokeWidth:1.75,"aria-hidden":!0}):null,t[13]=g,t[14]=x);let ne;t[15]===n.updatedAt?ne=t[16]:(ne=we(n.updatedAt),t[15]=n.updatedAt,t[16]=ne);let S;t[17]===ne?S=t[18]:(S=(0,Z.jsx)(`span`,{children:ne}),t[17]=ne,t[18]=S);let C;t[19]!==S||t[20]!==x?(C=(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5 text-xs text-fg-muted`,children:[x,S]}),t[19]=S,t[20]=x,t[21]=C):C=t[21];let w;t[22]!==C||t[23]!==b||t[24]!==te?(w=(0,Z.jsxs)(`div`,{className:b,children:[te,C]}),t[22]=C,t[23]=b,t[24]=te,t[25]=w):w=t[25];let T=r===`list`&&`sm:py-3`,E;t[26]===T?E=t[27]:(E=u(`min-w-0 flex-1 px-3 py-2`,T),t[26]=T,t[27]=E);let D=r===`list`&&`sm:items-start`,O;t[28]===D?O=t[29]:(O=u(`flex gap-3`,D),t[28]=D,t[29]=O);let k;t[30]!==o||t[31]!==a?(k=(0,Z.jsx)(ae,{agentId:a,avatar:o,size:40,className:`size-10 shrink-0 ring-1 ring-edge/60 dark:ring-edge`}),t[30]=o,t[31]=a,t[32]=k):k=t[32];let A;t[33]===f?A=t[34]:(A=(0,Z.jsx)(`div`,{className:`min-w-0 max-w-full truncate text-sm font-semibold text-fg`,title:f,children:f}),t[33]=f,t[34]=A);let j;t[35]!==n.key||t[36]!==m?(j=m?(0,Z.jsx)(`div`,{className:`mt-0.5 min-w-0 max-w-full truncate font-mono text-[11px] text-fg-subtle`,title:n.key,children:n.key}):null,t[35]=n.key,t[36]=m,t[37]=j):j=t[37];let M;t[38]!==A||t[39]!==j?(M=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[A,j]}),t[38]=A,t[39]=j,t[40]=M):M=t[40];let N;t[41]!==O||t[42]!==k||t[43]!==M?(N=(0,Z.jsxs)(`div`,{className:O,children:[k,M]}),t[41]=O,t[42]=k,t[43]=M,t[44]=N):N=t[44];let P;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,Z.jsx)(de,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[45]=P):P=t[45];let F;t[46]===n.messageCount?F=t[47]:(F=(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[P,n.messageCount]}),t[46]=n.messageCount,t[47]=F);let I;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,Z.jsx)(ge,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[48]=I):I=t[48];let L;t[49]===n.estimatedTokens?L=t[50]:(L=Te(n.estimatedTokens),t[49]=n.estimatedTokens,t[50]=L);let R;t[51]===L?R=t[52]:(R=(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[I,L]}),t[51]=L,t[52]=R);let z;t[53]!==F||t[54]!==R?(z=(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-3 text-xs text-fg-muted`,children:[F,R]}),t[53]=F,t[54]=R,t[55]=z):z=t[55];let B;t[56]===n.tags?B=t[57]:(B=n.tags.length>0?(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[n.tags.slice(0,3).map(ke),n.tags.length>3?(0,Z.jsxs)(`span`,{className:`text-[11px] text-fg-disabled`,children:[`+`,n.tags.length-3]}):null]}):null,t[56]=n.tags,t[57]=B);let V;t[58]!==E||t[59]!==N||t[60]!==z||t[61]!==B?(V=(0,Z.jsxs)(`div`,{className:E,children:[N,z,B]}),t[58]=E,t[59]=N,t[60]=z,t[61]=B,t[62]=V):V=t[62];let H;t[63]===l?H=t[64]:(H=()=>l(`continue`),t[63]=l,t[64]=H);let U;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,Z.jsx)(de,{className:`size-4`,strokeWidth:1.75}),t[65]=U):U=t[65];let W;t[66]!==i.continueChat||t[67]!==H?(W=(0,Z.jsx)(`button`,{type:`button`,className:J,title:i.continueChat,"aria-label":i.continueChat,onClick:H,children:U}),t[66]=i.continueChat,t[67]=H,t[68]=W):W=t[68];let re;t[69]!==h||t[70]!==i.archive||t[71]!==i.unarchive||t[72]!==l?(re=h?(0,Z.jsx)(`button`,{type:`button`,className:J,title:i.unarchive,"aria-label":i.unarchive,onClick:()=>l(`unarchive`),children:(0,Z.jsx)(fe,{className:`size-4`,strokeWidth:1.75})}):(0,Z.jsx)(`button`,{type:`button`,className:J,title:i.archive,"aria-label":i.archive,onClick:()=>l(`archive`),children:(0,Z.jsx)(_e,{className:`size-4`,strokeWidth:1.75})}),t[69]=h,t[70]=i.archive,t[71]=i.unarchive,t[72]=l,t[73]=re):re=t[73];let G;t[74]!==g||t[75]!==i.pin||t[76]!==i.unpin||t[77]!==l?(G=g?(0,Z.jsx)(`button`,{type:`button`,className:J,title:i.unpin,"aria-label":i.unpin,onClick:()=>l(`unpin`),children:(0,Z.jsx)(ie,{className:`size-4`,strokeWidth:1.75})}):(0,Z.jsx)(`button`,{type:`button`,className:J,title:i.pin,"aria-label":i.pin,onClick:()=>l(`pin`),children:(0,Z.jsx)(he,{className:`size-4`,strokeWidth:1.75})}),t[74]=g,t[75]=i.pin,t[76]=i.unpin,t[77]=l,t[78]=G):G=t[78];let oe;t[79]===l?oe=t[80]:(oe=()=>l(`export`),t[79]=l,t[80]=oe);let ce;t[81]===Symbol.for(`react.memo_cache_sentinel`)?(ce=(0,Z.jsx)(s,{className:`size-4`,strokeWidth:1.75}),t[81]=ce):ce=t[81];let le;t[82]!==i.export||t[83]!==oe?(le=(0,Z.jsx)(`button`,{type:`button`,className:J,title:i.export,"aria-label":i.export,onClick:oe,children:ce}),t[82]=i.export,t[83]=oe,t[84]=le):le=t[84];let ue;t[85]===Symbol.for(`react.memo_cache_sentinel`)?(ue=u(J,`text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40`),t[85]=ue):ue=t[85];let K;t[86]===l?K=t[87]:(K=()=>l(`delete`),t[86]=l,t[87]=K);let q;t[88]===Symbol.for(`react.memo_cache_sentinel`)?(q=(0,Z.jsx)(se,{className:`size-4`,strokeWidth:1.75}),t[88]=q):q=t[88];let pe;t[89]!==i.delete||t[90]!==K?(pe=(0,Z.jsx)(`button`,{type:`button`,className:ue,title:i.delete,"aria-label":i.delete,onClick:K,children:q}),t[89]=i.delete,t[90]=K,t[91]=pe):pe=t[91];let me;t[92]!==W||t[93]!==re||t[94]!==G||t[95]!==le||t[96]!==pe?(me=(0,Z.jsxs)(`div`,{role:`group`,className:`flex flex-wrap items-center gap-0.5 border-t border-edge-subtle/80 bg-surface-hover/25 p-2 dark:border-edge-subtle`,onClick:Oe,onKeyDown:De,children:[W,re,G,le,pe]}),t[92]=W,t[93]=re,t[94]=G,t[95]=le,t[96]=pe,t[97]=me):me=t[97];let ve;return t[98]!==c||t[99]!==w||t[100]!==V||t[101]!==v||t[102]!==me||t[103]!==ee?(ve=(0,Z.jsxs)(`div`,{role:`button`,tabIndex:0,className:v,onClick:c,onKeyDown:ee,children:[w,V,me]}),t[98]=c,t[99]=w,t[100]=V,t[101]=v,t[102]=me,t[103]=ee,t[104]=ve):ve=t[104],ve}function De(e){return e.stopPropagation()}function Oe(e){return e.stopPropagation()}function ke(e){return(0,Z.jsx)(`span`,{className:`max-w-full break-words rounded-md bg-surface-hover px-1.5 py-0.5 text-[11px] text-fg-muted`,children:e},e)}function Ae(e,t){return e.routing?.agentId?.trim().toLowerCase()||t.trim().toLowerCase()||`main`}function je(e,t){return t.find(t=>t.id===e)?.avatar}var Me={enabled:!0,triggerThreshold:.8,reserveTokens:8192,minMessagesBeforeCompact:10,keepRecentTokens:2e4,recentTurnsPreserve:3,summaryMaxTokens:2e3,summaryChunkTokens:24e3,summaryTimeoutMs:18e4,summaryRetries:2,qualityGuard:!0,gapAudit:!0,minToolResultKeepChars:1e3,maxActiveTranscriptBytes:2e6,postCompactionSections:[`Session Startup`,`Red Lines`]};function Ne(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Pe(e,t,n,r=1/0){return typeof e==`number`&&Number.isFinite(e)&&e>=n&&e<=r?e:t}function Q(e,t,n,r=1/0){return Number.isInteger(e)&&e>=n&&e<=r?e:t}function Fe(e){let t=Ne(e)?e:{},n=Ne(t.userContext)?t.userContext:{},r=Ne(n.memory)?n.memory:{},i=Ne(r.retention)?r.retention:{},a=Ne(i.compaction)?i.compaction:{},o=Me,s=typeof a.model==`string`&&a.model.trim()?a.model.trim():void 0,c=Array.isArray(a.postCompactionSections)&&a.postCompactionSections.length<=12&&a.postCompactionSections.every(e=>typeof e==`string`&&e.trim())?[...new Set(a.postCompactionSections.map(e=>e.trim()))]:[...o.postCompactionSections];return{enabled:typeof a.enabled==`boolean`?a.enabled:o.enabled,triggerThreshold:Pe(a.triggerThreshold,o.triggerThreshold,.1,.98),reserveTokens:Q(a.reserveTokens,o.reserveTokens,1024),minMessagesBeforeCompact:Q(a.minMessagesBeforeCompact,o.minMessagesBeforeCompact,2),keepRecentTokens:Q(a.keepRecentTokens,o.keepRecentTokens,1e3),recentTurnsPreserve:Q(a.recentTurnsPreserve,o.recentTurnsPreserve,1,12),summaryMaxTokens:Q(a.summaryMaxTokens,o.summaryMaxTokens,256),summaryChunkTokens:Q(a.summaryChunkTokens,o.summaryChunkTokens,1e3),summaryTimeoutMs:Q(a.summaryTimeoutMs,o.summaryTimeoutMs,1e3,6e5),summaryRetries:Q(a.summaryRetries,o.summaryRetries,0,5),qualityGuard:typeof a.qualityGuard==`boolean`?a.qualityGuard:o.qualityGuard,gapAudit:typeof a.gapAudit==`boolean`?a.gapAudit:o.gapAudit,...s?{model:s}:{},minToolResultKeepChars:Q(a.minToolResultKeepChars,o.minToolResultKeepChars,200),maxActiveTranscriptBytes:Q(a.maxActiveTranscriptBytes,o.maxActiveTranscriptBytes,64e3),postCompactionSections:c}}function Ie(e){return e.triggerThreshold<.1||e.triggerThreshold>.98?`triggerThreshold`:!Number.isInteger(e.reserveTokens)||e.reserveTokens<1024?`reserveTokens`:!Number.isInteger(e.minMessagesBeforeCompact)||e.minMessagesBeforeCompact<2?`minMessagesBeforeCompact`:!Number.isInteger(e.keepRecentTokens)||e.keepRecentTokens<1e3?`keepRecentTokens`:!Number.isInteger(e.recentTurnsPreserve)||e.recentTurnsPreserve<1||e.recentTurnsPreserve>12?`recentTurnsPreserve`:!Number.isInteger(e.summaryMaxTokens)||e.summaryMaxTokens<256?`summaryMaxTokens`:!Number.isInteger(e.summaryChunkTokens)||e.summaryChunkTokens<1e3?`summaryChunkTokens`:!Number.isInteger(e.summaryTimeoutMs)||e.summaryTimeoutMs<1e3||e.summaryTimeoutMs>6e5?`summaryTimeoutMs`:!Number.isInteger(e.summaryRetries)||e.summaryRetries<0||e.summaryRetries>5?`summaryRetries`:e.model!==void 0&&!e.model.trim()?`model`:!Number.isInteger(e.minToolResultKeepChars)||e.minToolResultKeepChars<200?`minToolResultKeepChars`:!Number.isInteger(e.maxActiveTranscriptBytes)||e.maxActiveTranscriptBytes<64e3?`maxActiveTranscriptBytes`:e.postCompactionSections.length>12||e.postCompactionSections.some(e=>!e.trim())?`postCompactionSections`:null}function Le(e){let t={...e,...e.model?.trim()?{model:e.model.trim()}:{}};return e.model?.trim()||delete t.model,{userContext:{memory:{retention:{compaction:t}}}}}async function Re(e){await g(h(`/api/config`),{method:`PATCH`,body:JSON.stringify(Le(e))}),await C()}var ze=128e3,Be={balanced:Me,preserve:{...Me,triggerThreshold:.88,keepRecentTokens:32e3,recentTurnsPreserve:5,maxActiveTranscriptBytes:4e6},early:{...Me,triggerThreshold:.65,reserveTokens:12e3,minMessagesBeforeCompact:6,keepRecentTokens:12e3,recentTurnsPreserve:2}},Ve=q();function He(){return u(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg disabled:cursor-not-allowed disabled:opacity-55`,E,`dark:border-edge`)}function Ue(e){let{enabled:t,model:n,postCompactionSections:r,...i}=e;return JSON.stringify(i)}function We(e){let t=Ue(e);for(let[e,n]of Object.entries(Be))if(t===Ue(n))return e;return`custom`}function Ge(e){return e>=1e6?`${(e/1e6).toFixed(e%1e6==0?0:1)}m`:e>=1e3?`${(e/1e3).toFixed(e%1e3==0?0:1)}k`:String(e)}function $(e){let t=(0,Ce.c)(20),{id:n,label:r,hint:i,value:a,min:o,max:s,step:c,disabled:l,onChange:u}=e,d=c===void 0?1:c,f;t[0]!==n||t[1]!==r?(f=(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:n,children:r}),t[0]=n,t[1]=r,t[2]=f):f=t[2];let p;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(p=He(),t[3]=p):p=t[3];let m;t[4]===u?m=t[5]:(m=e=>{if(!e.target.value.trim())return;let t=Number(e.target.value);Number.isFinite(t)&&u(t)},t[4]=u,t[5]=m);let h;t[6]!==l||t[7]!==n||t[8]!==s||t[9]!==o||t[10]!==d||t[11]!==m||t[12]!==a?(h=(0,Z.jsx)(`input`,{id:n,type:`number`,min:o,max:s,step:d,disabled:l,className:p,value:a,onChange:m}),t[6]=l,t[7]=n,t[8]=s,t[9]=o,t[10]=d,t[11]=m,t[12]=a,t[13]=h):h=t[13];let g;t[14]===i?g=t[15]:(g=i?(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:i}):null,t[14]=i,t[15]=g);let _;return t[16]!==f||t[17]!==h||t[18]!==g?(_=(0,Z.jsxs)(`div`,{children:[f,h,g]}),t[16]=f,t[17]=h,t[18]=g,t[19]=_):_=t[19],_}function Ke(e){let t=(0,Ce.c)(19),{label:n,hint:r,checked:i,disabled:a,onChange:o}=e,s=a?`cursor-not-allowed opacity-55`:`cursor-pointer`,c;t[0]===s?c=t[1]:(c=u(`flex items-start gap-2 text-sm text-fg`,s),t[0]=s,t[1]=c);let l;t[2]===o?l=t[3]:(l=e=>o(e.target.checked),t[2]=o,t[3]=l);let d;t[4]!==i||t[5]!==a||t[6]!==l?(d=(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:i,disabled:a,onChange:l}),t[4]=i,t[5]=a,t[6]=l,t[7]=d):d=t[7];let f;t[8]===n?f=t[9]:(f=(0,Z.jsx)(`span`,{className:`font-medium`,children:n}),t[8]=n,t[9]=f);let p;t[10]===r?p=t[11]:(p=(0,Z.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:r}),t[10]=r,t[11]=p);let m;t[12]!==f||t[13]!==p?(m=(0,Z.jsxs)(`span`,{children:[f,p]}),t[12]=f,t[13]=p,t[14]=m):m=t[14];let h;return t[15]!==c||t[16]!==d||t[17]!==m?(h=(0,Z.jsxs)(`label`,{className:c,children:[d,m]}),t[15]=c,t[16]=d,t[17]=m,t[18]=h):h=t[18],h}function qe({hasToken:e}){let t=f(m(e=>e.language)).sessions.compaction,{data:n,isLoading:r}=w(e),{data:i=[],isLoading:a}=S(e?R:null,U,{revalidateOnFocus:!1}),o=(0,X.useMemo)(()=>n?.payload?.config===void 0?null:Fe(n.payload.config),[n]),[s,p]=(0,X.useReducer)(Ve,{form:null,baseline:null}),[h,g]=(0,X.useState)(``),_=(0,X.useRef)(!1),v=(0,X.useRef)(s.form);v.current=s.form;let ee=(0,X.useRef)(null);K({enabled:e,parsed:o,dirty:_.current,trackedParsedRef:ee,dispatch:p,onResetDirty:()=>{_.current=!1}});let y=s.form,b=s.baseline,te=!!(y&&b&&JSON.stringify(y)!==JSON.stringify(b)),x=(0,X.useCallback)(e=>{_.current=!0,p({type:`patch`,patch:e})},[]),ne=(0,X.useCallback)(e=>({enabled:t.enabled,triggerThreshold:t.triggerThreshold,reserveTokens:t.reserveTokens,minMessagesBeforeCompact:t.minMessagesBeforeCompact,keepRecentTokens:t.keepRecentTokens,recentTurnsPreserve:t.recentTurnsPreserve,summaryMaxTokens:t.summaryMaxTokens,summaryChunkTokens:t.summaryChunkTokens,summaryTimeoutMs:t.summaryTimeoutSeconds,summaryRetries:t.summaryRetries,qualityGuard:t.qualityGuard,gapAudit:t.gapAudit,model:t.summaryModel,minToolResultKeepChars:t.minToolResultKeepChars,maxActiveTranscriptBytes:t.maxActiveTranscriptMb,postCompactionSections:t.postCompactionSections})[e],[t]),C=ye({value:y,dirty:te,onSave:(0,X.useCallback)(async e=>{try{await Re(e),p({type:`saved`,value:e}),_.current=!!(v.current&&JSON.stringify(v.current)!==JSON.stringify(e))}catch(e){throw Error(e instanceof Error?e.message:t.saveError)}},[t.saveError]),validate:e=>{let n=Ie(e);return n?t.invalidValue.replace(`{{field}}`,ne(n)):null}});if(!e||!y)return r?(0,Z.jsx)(Y,{children:(0,Z.jsxs)(`div`,{className:`space-y-3`,"aria-busy":!0,children:[(0,Z.jsx)(P,{className:`h-5 w-48`}),(0,Z.jsx)(P,{className:`h-20 w-full rounded-xl`}),(0,Z.jsx)(P,{className:`h-36 w-full rounded-xl`})]})}):null;let T=We(y),E=Math.max(0,ze-y.reserveTokens),D=Math.min(Math.floor(ze*y.triggerThreshold),E),O=Math.min(100,D/ze*100),k=Math.min(100,E/ze*100),A=y.model?i.find(e=>e.id===y.model):void 0,M=A?.contextWindow&&y.summaryChunkTokens+y.summaryMaxTokens+4096>A.contextWindow,N=y.keepRecentTokens+y.reserveTokens>D,F=Math.round(y.summaryTimeoutMs*(y.summaryRetries+1)/1e3),I=e=>{let t=Be[e];x({...t,...y.model?{model:y.model}:{model:void 0},postCompactionSections:y.postCompactionSections})},L={balanced:{title:t.presetBalanced,hint:t.presetBalancedHint},preserve:{title:t.presetPreserve,hint:t.presetPreserveHint},early:{title:t.presetEarly,hint:t.presetEarlyHint}},z=()=>{let e=h.trim();!e||y.postCompactionSections.includes(e)||y.postCompactionSections.length>=12||(x({postCompactionSections:[...y.postCompactionSections,e]}),g(``))};return(0,Z.jsxs)(Y,{onBlurCapture:C.onBlurCapture,children:[(0,Z.jsx)(xe,{icon:G,title:t.title,subtitle:t.hint,trailing:(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(ve,{status:C.status,error:C.error}),(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm font-medium text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:y.enabled,onChange:e=>x({enabled:e.target.checked})}),y.enabled?t.enabled:t.disabled]})]})}),C.error?(0,Z.jsx)(`p`,{className:`mb-4 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900 dark:bg-red-950/40 dark:text-red-300`,role:`alert`,children:C.error}):null,y.enabled?null:(0,Z.jsx)(`p`,{className:`mb-4 rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100`,children:t.disabledWarning}),(0,Z.jsxs)(`fieldset`,{disabled:!y.enabled,className:`space-y-5 disabled:opacity-60`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.presetTitle}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.presetHint})]}),T===`custom`?(0,Z.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-1 text-[11px] font-medium text-fg-muted`,children:t.presetCustom}):null]}),(0,Z.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[`balanced`,`preserve`,`early`].map(e=>(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":T===e,className:u(`rounded-xl border px-3 py-3 text-left`,j.transition,j.focusRingPanel,T===e?`border-accent/50 bg-accent-soft text-accent-fg`:`border-edge bg-surface-panel text-fg hover:bg-surface-hover`),onClick:()=>I(e),children:[(0,Z.jsx)(`span`,{className:`block text-sm font-medium`,children:L[e].title}),(0,Z.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:L[e].hint})]},e))})]}),(0,Z.jsxs)(`div`,{className:`rounded-xl border border-edge-subtle bg-surface-hover/35 p-4 dark:border-edge`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.budgetPreview}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.budgetPreviewHint})]}),(0,Z.jsx)(`span`,{className:`rounded-full bg-surface-panel px-2.5 py-1 font-mono text-xs text-fg-muted`,children:t.previewModel128k})]}),(0,Z.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{className:`mb-1 flex justify-between gap-3 text-xs text-fg-muted`,children:[(0,Z.jsx)(`span`,{children:t.compactionTrigger}),(0,Z.jsx)(`span`,{className:`font-mono text-fg`,children:Ge(D)})]}),(0,Z.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-surface-active`,children:(0,Z.jsx)(`div`,{className:`h-full rounded-full bg-accent`,style:{width:`${O}%`}})})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsxs)(`div`,{className:`mb-1 flex justify-between gap-3 text-xs text-fg-muted`,children:[(0,Z.jsx)(`span`,{children:t.hardInputLimit}),(0,Z.jsx)(`span`,{className:`font-mono text-fg`,children:Ge(E)})]}),(0,Z.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-surface-active`,children:(0,Z.jsx)(`div`,{className:`h-full rounded-full bg-fg-subtle`,style:{width:`${k}%`}})})]})]}),(0,Z.jsx)(`p`,{className:`mt-3 text-xs text-fg-subtle`,children:t.budgetFormula})]}),(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsx)($,{id:`compaction-trigger-threshold`,label:t.triggerThreshold,hint:t.triggerThresholdHint,value:Number((y.triggerThreshold*100).toFixed(2)),min:10,max:98,step:.1,onChange:e=>x({triggerThreshold:e/100})}),(0,Z.jsx)($,{id:`compaction-reserve-tokens`,label:t.reserveTokens,hint:t.reserveTokensHint.replace(`{{tokens}}`,Ge(y.reserveTokens)),value:y.reserveTokens,min:1024,step:1024,onChange:e=>x({reserveTokens:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-recent-turns`,label:t.recentTurnsPreserve,hint:t.recentTurnsPreserveHint,value:y.recentTurnsPreserve,min:1,max:12,onChange:e=>x({recentTurnsPreserve:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-keep-recent-tokens`,label:t.keepRecentTokens,hint:t.keepRecentTokensHint.replace(`{{tokens}}`,Ge(y.keepRecentTokens)),value:y.keepRecentTokens,min:1e3,step:1e3,onChange:e=>x({keepRecentTokens:Math.floor(e)})})]}),N?(0,Z.jsx)(`p`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100`,children:t.retentionWarning}):null,(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.summaryModel}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 gap-2`,children:[(0,Z.jsx)(ue,{value:y.model??``,disabled:!y.enabled,placeholder:t.summaryModelInherited,searchPlaceholder:t.summaryModelSearch,noMatches:t.summaryModelNoMatches,models:i,modelsLoading:a,className:`min-w-0 flex-1 justify-between`,contentAlign:`start`,showProviderSettingsFooter:!0,onChange:e=>x({model:e})}),y.model?(0,Z.jsx)(d,{type:`button`,variant:`secondary`,onClick:()=>x({model:void 0}),children:t.summaryModelUseSession}):null]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.summaryModelHint})]}),(0,Z.jsx)(Ke,{label:t.qualityGuard,hint:t.qualityGuardHint,checked:y.qualityGuard,onChange:e=>x({qualityGuard:e})}),(0,Z.jsx)(Ke,{label:t.gapAudit,hint:t.gapAuditHint,checked:y.gapAudit,onChange:e=>x({gapAudit:e})})]}),y.qualityGuard?null:(0,Z.jsx)(`p`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100`,children:t.qualityGuardWarning}),(0,Z.jsx)(be,{children:(0,Z.jsxs)(`div`,{className:`space-y-5 border-t border-edge pt-5`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:t.advancedTitle}),(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:t.advancedHint})]}),(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsx)($,{id:`compaction-min-messages`,label:t.minMessagesBeforeCompact,hint:t.minMessagesBeforeCompactHint,value:y.minMessagesBeforeCompact,min:2,onChange:e=>x({minMessagesBeforeCompact:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-max-transcript-mb`,label:t.maxActiveTranscriptMb,hint:t.maxActiveTranscriptMbHint,value:Number((y.maxActiveTranscriptBytes/1e6).toFixed(3)),min:.064,step:.1,onChange:e=>x({maxActiveTranscriptBytes:Math.max(64e3,Math.round(e*1e6))})}),(0,Z.jsx)($,{id:`compaction-summary-max-tokens`,label:t.summaryMaxTokens,hint:t.summaryMaxTokensHint,value:y.summaryMaxTokens,min:256,step:256,onChange:e=>x({summaryMaxTokens:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-summary-chunk-tokens`,label:t.summaryChunkTokens,hint:t.summaryChunkTokensHint,value:y.summaryChunkTokens,min:1e3,step:1e3,onChange:e=>x({summaryChunkTokens:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-summary-timeout`,label:t.summaryTimeoutSeconds,hint:t.summaryTimeoutSecondsHint.replace(`{{seconds}}`,String(F)),value:y.summaryTimeoutMs/1e3,min:1,max:600,onChange:e=>x({summaryTimeoutMs:Math.round(e*1e3)})}),(0,Z.jsx)($,{id:`compaction-summary-retries`,label:t.summaryRetries,hint:t.summaryRetriesHint,value:y.summaryRetries,min:0,max:5,onChange:e=>x({summaryRetries:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-min-tool-result-chars`,label:t.minToolResultKeepChars,hint:t.minToolResultKeepCharsHint,value:y.minToolResultKeepChars,min:200,step:100,onChange:e=>x({minToolResultKeepChars:Math.floor(e)})})]}),M?(0,Z.jsx)(`p`,{className:`rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100`,children:t.summaryBudgetWarning}):null,(0,Z.jsxs)(`div`,{className:`border-t border-edge pt-5`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:t.postCompactionSections}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.postCompactionSectionsHint}),y.postCompactionSections.length>0?(0,Z.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:y.postCompactionSections.map(e=>(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs text-fg`,children:[e,(0,Z.jsx)(`button`,{type:`button`,className:u(`text-fg-muted hover:text-fg`,j.press),"aria-label":t.removeSection.replace(`{{section}}`,e),onClick:()=>x({postCompactionSections:y.postCompactionSections.filter(t=>t!==e)}),children:(0,Z.jsx)(l,{className:`size-3.5`,"aria-hidden":!0})})]},e))}):(0,Z.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:t.postCompactionSectionsEmpty}),(0,Z.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[(0,Z.jsx)(`input`,{className:He(),value:h,maxLength:120,disabled:y.postCompactionSections.length>=12,placeholder:t.postCompactionSectionsPlaceholder,onChange:e=>g(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),z())}}),(0,Z.jsxs)(d,{type:`button`,variant:`secondary`,disabled:!h.trim()||y.postCompactionSections.length>=12,onClick:z,children:[(0,Z.jsx)(c,{className:`size-4`,"aria-hidden":!0}),t.addSection]})]})]})]})})]})]})}function Je(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ye(e){return e===`main`||e===`per-peer`||e===`per-channel-peer`||e===`per-account-channel-peer`?e:`main`}function Xe(e){let t=Je(e)?e:{},n=Je(t.session)?t.session:{},r=Je(n.storage)?n.storage:{},i=typeof r.pruneAfterDays==`number`&&Number.isFinite(r.pruneAfterDays)?Math.max(0,Math.floor(r.pruneAfterDays)):typeof r.pruneAfterMs==`number`&&Number.isFinite(r.pruneAfterMs)?Math.max(0,Math.round(r.pruneAfterMs/864e5)):null,a=typeof r.maxEntries==`number`&&Number.isFinite(r.maxEntries)?Math.max(1,Math.floor(r.maxEntries)):null;return{dmScope:Ye(n.dmScope),pruneAfterDays:i,maxEntries:a}}async function Ze(e){await g(h(`/api/config`),{method:`PATCH`,body:JSON.stringify({session:{dmScope:e.dmScope,storage:{pruneAfterMs:e.pruneAfterDays===null?null:e.pruneAfterDays*864e5,maxEntries:e.maxEntries}}})}),C()}function Qe(){return u(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,E,`dark:border-edge`)}var $e=q();function et({hasToken:e}){let t=f(m(e=>e.language)).sessions.config,{data:n,isLoading:r}=w(e),i=(0,X.useMemo)(()=>n?.payload?.config===void 0?null:Xe(n.payload.config),[n]),[s,c]=(0,X.useReducer)($e,{form:null,baseline:null}),l=s.form,u=s.baseline,d=(0,X.useRef)(!1),p=(0,X.useRef)(l);p.current=l;let h=(0,X.useRef)(null);K({enabled:e,parsed:i,dirty:d.current,trackedParsedRef:h,dispatch:c,onResetDirty:()=>{d.current=!1}});let g=!!(l&&u&&JSON.stringify(l)!==JSON.stringify(u)),_=(0,X.useCallback)(e=>{d.current=!0,c({type:`patch`,patch:e})},[]),v=ye({value:l,dirty:g,onSave:(0,X.useCallback)(async e=>{try{await Ze(e),c({type:`saved`,value:e}),d.current=!!(p.current&&JSON.stringify(p.current)!==JSON.stringify(e))}catch(e){throw Error(e instanceof Error?e.message:t.saveError)}},[t.saveError])});return!e||!l?r?(0,Z.jsx)(Y,{children:(0,Z.jsxs)(`div`,{className:`space-y-3`,"aria-busy":!0,children:[(0,Z.jsx)(P,{className:`h-5 w-40`}),(0,Z.jsx)(P,{className:`h-24 w-full rounded-xl`})]})}):null:(0,Z.jsxs)(Y,{onBlurCapture:v.onBlurCapture,children:[(0,Z.jsx)(xe,{icon:W,title:t.title,subtitle:t.hint,trailing:(0,Z.jsx)(ve,{status:v.status,error:v.error})}),(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.dmScope}),(0,Z.jsxs)(a,{className:Qe(),value:l.dmScope,onChange:e=>_({dmScope:e.target.value}),children:[(0,Z.jsx)(o,{value:`main`,children:t.dmScopeMain}),(0,Z.jsx)(o,{value:`per-peer`,children:t.dmScopePerPeer}),(0,Z.jsx)(o,{value:`per-channel-peer`,children:t.dmScopePerChannelPeer}),(0,Z.jsx)(o,{value:`per-account-channel-peer`,children:t.dmScopePerAccountChannelPeer})]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:t.dmScopeHint})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.pruneAfterDays}),(0,Z.jsx)(`input`,{type:`number`,min:0,className:Qe(),value:l.pruneAfterDays??``,placeholder:t.unsetPlaceholder,onChange:e=>{let t=e.target.value.trim();_({pruneAfterDays:t===``?null:Math.max(0,Math.floor(Number(t)||0))})}})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:t.maxEntries}),(0,Z.jsx)(`input`,{type:`number`,min:1,className:Qe(),value:l.maxEntries??``,placeholder:t.unsetPlaceholder,onChange:e=>{let t=e.target.value.trim();_({maxEntries:t===``?null:Math.max(1,Math.floor(Number(t)||1))})}})]})]})]})}function tt(e){if(typeof e==`string`)return e.length>2e3?`${e.slice(0,2e3)}…`:e;try{let t=JSON.stringify(e,null,2);return t.length>2e3?`${t.slice(0,2e3)}…`:t}catch{return String(e)}}function nt(e){let t=(0,Ce.c)(60),{open:n,loading:r,session:i,sessionAgentId:a,sessionAgentAvatar:o,labels:s,onClose:c,onArchive:f,onUnarchive:p,onPin:m,onUnpin:h,onExport:g,onDelete:S}=e,C=i?.status===`archived`,w=i?.status===`pinned`,T;t[0]===c?T=t[1]:(T=e=>!e&&c(),t[0]=c,t[1]=T);let E;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,Z.jsx)(ee,{className:u(`xopc-dialog-overlay fixed inset-0 bg-scrim`,v)}),t[2]=E):E=t[2];let D;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(D=u(`xopc-drawer-right fixed right-0 top-0 flex size-full max-w-lg flex-col border-l border-edge bg-surface-panel shadow-popover outline-none`,_,`dark:border-edge`),t[3]=D):D=t[3];let O;t[4]!==i||t[5]!==o||t[6]!==a?(O=i&&a?(0,Z.jsx)(ae,{agentId:a,avatar:o,size:40,className:`size-10 shrink-0 ring-1 ring-edge/60 dark:ring-edge`}):null,t[4]=i,t[5]=o,t[6]=a,t[7]=O):O=t[7];let k;t[8]!==s.unnamedSession||t[9]!==i?.name?(k=i?.name?.trim()||s.unnamedSession,t[8]=s.unnamedSession,t[9]=i?.name,t[10]=k):k=t[10];let A;t[11]===k?A=t[12]:(A=(0,Z.jsx)(x,{className:`min-w-0 flex-1 truncate text-base font-semibold tracking-tight text-fg`,children:k}),t[11]=k,t[12]=A);let j;t[13]!==O||t[14]!==A?(j=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[O,A]}),t[13]=O,t[14]=A,t[15]=j):j=t[15];let M;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,Z.jsx)(l,{className:`size-5`,strokeWidth:1.75}),t[16]=M):M=t[16];let N;t[17]===s.close?N=t[18]:(N=(0,Z.jsx)(y,{asChild:!0,children:(0,Z.jsx)(d,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":s.close,children:M})}),t[17]=s.close,t[18]=N);let P;t[19]!==j||t[20]!==N?(P=(0,Z.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center justify-between gap-2 border-b border-edge px-4 py-3 dark:border-edge`,children:[j,N]}),t[19]=j,t[20]=N,t[21]=P):P=t[21];let F;t[22]!==s.detailLoading||t[23]!==s.detailMessages||t[24]!==r||t[25]!==i?(F=r?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:s.detailLoading}):i?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`dl`,{className:`mb-4 grid gap-2 text-xs text-fg-muted`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`dt`,{className:`text-fg-disabled`,children:`Key`}),(0,Z.jsx)(`dd`,{className:`mt-0.5 break-all font-mono text-fg`,children:i.key})]}),(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-4`,children:(0,Z.jsxs)(`span`,{children:[i.messageCount,` msgs · `,i.estimatedTokens,` tok`]})})]}),(0,Z.jsx)(`h3`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:s.detailMessages}),(0,Z.jsx)(`ul`,{className:`space-y-3`,children:i.messages.map(rt)})]}):null,t[22]=s.detailLoading,t[23]=s.detailMessages,t[24]=r,t[25]=i,t[26]=F):F=t[26];let I;t[27]===F?I=t[28]:(I=(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:F}),t[27]=F,t[28]=I);let L;t[29]!==s.detailExport||t[30]!==g?(L=(0,Z.jsx)(d,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:g,children:s.detailExport}),t[29]=s.detailExport,t[30]=g,t[31]=L):L=t[31];let R;t[32]!==C||t[33]!==s.archive||t[34]!==s.unarchive||t[35]!==f||t[36]!==p?(R=C?(0,Z.jsx)(d,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:p,children:s.unarchive}):(0,Z.jsx)(d,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:f,children:s.archive}),t[32]=C,t[33]=s.archive,t[34]=s.unarchive,t[35]=f,t[36]=p,t[37]=R):R=t[37];let z;t[38]!==w||t[39]!==s.pin||t[40]!==s.unpin||t[41]!==m||t[42]!==h?(z=w?(0,Z.jsx)(d,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:h,children:s.unpin}):(0,Z.jsx)(d,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:m,children:s.pin}),t[38]=w,t[39]=s.pin,t[40]=s.unpin,t[41]=m,t[42]=h,t[43]=z):z=t[43];let B;t[44]!==s.delete||t[45]!==S?(B=(0,Z.jsx)(d,{type:`button`,variant:`secondary`,className:`text-sm text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40`,onClick:S,children:s.delete}),t[44]=s.delete,t[45]=S,t[46]=B):B=t[46];let V;t[47]!==L||t[48]!==R||t[49]!==z||t[50]!==B?(V=(0,Z.jsx)(`div`,{className:`shrink-0 border-t border-edge px-4 py-3 dark:border-edge`,children:(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[L,R,z,B]})}),t[47]=L,t[48]=R,t[49]=z,t[50]=B,t[51]=V):V=t[51];let H;t[52]!==P||t[53]!==I||t[54]!==V?(H=(0,Z.jsxs)(b,{children:[E,(0,Z.jsxs)(te,{className:D,"aria-describedby":void 0,children:[P,I,V]})]}),t[52]=P,t[53]=I,t[54]=V,t[55]=H):H=t[55];let U;return t[56]!==n||t[57]!==T||t[58]!==H?(U=(0,Z.jsx)(ne,{open:n,onOpenChange:T,children:H}),t[56]=n,t[57]=T,t[58]=H,t[59]=U):U=t[59],U}function rt(e){return(0,Z.jsxs)(`li`,{className:`rounded-lg border border-edge-subtle bg-surface-hover/50 p-2 dark:border-edge`,children:[(0,Z.jsx)(`div`,{className:`mb-1 text-[10px] font-medium uppercase text-fg-subtle`,children:e.role}),(0,Z.jsx)(`pre`,{className:`max-h-40 overflow-auto whitespace-pre-wrap break-words font-mono text-[11px] leading-relaxed text-fg-muted`,children:tt(e.content)})]},`${e.timestamp??``}-${e.role}-${tt(e.content).slice(0,24)}`)}var it=20;function at(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}var ot=new Set([`all`,`active`,`pinned`,`archived`]),st=new Set([`grid`,`list`]),ct=[`sessions`,`settings`];function lt(e){return e&&ct.includes(e)?e:`sessions`}function ut(e,t){return t===`sessions`?e.tabsSessions:e.tabsSettings}function dt(e,t){return t===`sessions`?e.tabsSessionsHint:e.tabsSettingsHint}function ft(e){let t=(0,Ce.c)(7),{s:n,activeTab:r,onChange:i}=e,a;t[0]===n?a=t[1]:(a=ct.map(e=>({id:e,label:ut(n,e),icon:e===`sessions`?N:A})),t[0]=n,t[1]=a);let o=a,s;return t[2]!==r||t[3]!==o||t[4]!==i||t[5]!==n.tabsAriaLabel?(s=(0,Z.jsx)(Se,{items:o,activeTab:r,onChange:i,ariaLabel:n.tabsAriaLabel,tabIdPrefix:`sessions-tab`,panelIdPrefix:`sessions-panel`}),t[2]=r,t[3]=o,t[4]=i,t[5]=n.tabsAriaLabel,t[6]=s):s=t[6],s}function pt(e){let t=(0,Ce.c)(10),{s:n,id:r,activeTab:i,plain:a,children:o}=e,s=a===void 0?!1:a;if(i!==r)return null;let c=`sessions-panel-${r}`,l=`sessions-tab-${r}`,u=s?`contents`:`rounded-2xl bg-surface-base px-4 py-5 sm:px-5`,d;t[0]!==o||t[1]!==r||t[2]!==s||t[3]!==n?(d=s?o:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`mb-5`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:ut(n,r)}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:dt(n,r)})]}),(0,Z.jsx)(`div`,{className:`space-y-4`,children:o})]}),t[0]=o,t[1]=r,t[2]=s,t[3]=n,t[4]=d):d=t[4];let f;return t[5]!==c||t[6]!==l||t[7]!==u||t[8]!==d?(f=(0,Z.jsx)(`section`,{id:c,role:`tabpanel`,"aria-labelledby":l,className:u,children:d}),t[5]=c,t[6]=l,t[7]=u,t[8]=d,t[9]=f):f=t[9],f}function mt(e){let t=e.get(`status`),n=e.get(`view`);return{searchInput:e.get(`q`)??``,debouncedSearch:(e.get(`q`)??``).trim(),statusFilter:ot.has(t)?t:`all`,viewMode:st.has(n)?n:`grid`,channelFilter:(e.get(`channel`)??``).trim(),sessions:[],loading:!1,error:null,hasMore:!1,stats:null,detailOpen:!1,detailLoading:!1,detailSession:null,confirmOpen:!1,confirmKey:null}}function ht(){let e=f(m(e=>e.language)),t=e.sessions,n=p(e=>e.token),r=!!n,{data:a,mutate:o}=S(r?[`gateway-chat-agents`,n]:null,k,{revalidateOnFocus:!1}),s=a?.defaultId??`main`,c=a?.items??[],[l,h]=i(),g=lt(l.get(`tab`)),y=(0,X.useCallback)(e=>{let t=new URLSearchParams(l);e===`sessions`?t.delete(`tab`):t.set(`tab`,e),h(t,{replace:!0})},[l,h]),[C,w]=(0,X.useReducer)(oe,l,mt),{searchInput:E,debouncedSearch:A,statusFilter:P,viewMode:R,channelFilter:U,sessions:W,loading:ie,error:ae,hasMore:G,stats:se,detailOpen:ue,detailLoading:de,detailSession:K,confirmOpen:fe,confirmKey:q}=C;(0,X.useEffect)(()=>{let e=setTimeout(()=>{let e=E.trim();A!==e&&w({type:`patch`,patch:{debouncedSearch:e}})},300);return()=>clearTimeout(e)},[E,A]);let J=l.toString(),ge=(0,X.useRef)(J);if(ge.current!==J){ge.current=J;let e=l.get(`q`)??``,t=l.get(`status`),n=l.get(`view`),r=(l.get(`channel`)??``).trim(),i=ot.has(t)?t:`all`,a=st.has(n)?n:`grid`,o=e.trim();w({type:`patch`,patch:{...E===e?{}:{searchInput:e},...A===o?{}:{debouncedSearch:o},...P===i?{}:{statusFilter:i},...R===a?{}:{viewMode:a},...U===r?{}:{channelFilter:r}}})}(0,X.useEffect)(()=>{let e=new URLSearchParams(l),t=A.trim();t?e.set(`q`,t):e.delete(`q`),P===`all`?e.delete(`status`):e.set(`status`,P),R===`grid`?e.delete(`view`):e.set(`view`,R),U?e.set(`channel`,U):e.delete(`channel`),e.toString()!==l.toString()&&h(e,{replace:!0})},[A,l,h,P,R,U]),(0,X.useEffect)(()=>{if(!r||g!==`sessions`)return;let e=!1;return(async()=>{w({type:`patch`,patch:{loading:!0,error:null}});try{let t=await re({limit:it,offset:0,...A?{search:A}:{},...P===`all`?{}:{status:P},...U?{channel:U}:{}});if(e)return;w({type:`patch`,patch:{sessions:t.items,hasMore:t.hasMore}})}catch(n){e||w({type:`patch`,patch:{error:n instanceof Error?n.message:t.loadError}})}finally{e||w({type:`patch`,patch:{loading:!1}})}})(),()=>{e=!0}},[r,g,A,P,U,t.loadError]),(0,X.useEffect)(()=>{!r||g!==`sessions`||T().then(e=>w({type:`patch`,patch:{stats:e}})).catch(()=>{})},[r,g]),(0,X.useEffect)(()=>{if(!r||g!==`sessions`)return;let e=()=>void o();return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},[r,g,o]),(0,X.useEffect)(()=>{if(!r||g!==`sessions`)return;let e=e=>{let t=e.detail;!t?.key||t.name===void 0||w({type:`patch`,patch:{sessions:W.map(e=>e.key===t.key?{...e,name:t.name}:e),detailSession:K&&K.key===t.key?{...K,name:t.name}:K}})};return window.addEventListener(`session-updated`,e),()=>{window.removeEventListener(`session-updated`,e)}},[r,g,W,K]);let ve=(0,X.useCallback)(async()=>{if(!(!r||ie||!G)){w({type:`patch`,patch:{loading:!0,error:null}});try{let e=await re({limit:it,offset:W.length,...A?{search:A}:{},...P===`all`?{}:{status:P},...U?{channel:U}:{}});w({type:`patch`,patch:{sessions:[...W,...e.items],hasMore:e.hasMore}})}catch(e){w({type:`patch`,patch:{error:e instanceof Error?e.message:t.loadError}})}finally{w({type:`patch`,patch:{loading:!1}})}}},[r,ie,G,W.length,A,P,U,t.loadError]),ye=(0,X.useCallback)((e,t)=>{w({type:`patch`,patch:{sessions:W.map(n=>n.key===e?{...n,status:t}:n),detailSession:K&&K.key===e?{...K,status:t}:K}})},[W,K]),be=(0,X.useCallback)(async e=>{w({type:`patch`,patch:{detailOpen:!0,detailLoading:!0,detailSession:null}});try{w({type:`patch`,patch:{detailSession:await F(e)}})}catch{w({type:`patch`,patch:{detailOpen:!1}})}finally{w({type:`patch`,patch:{detailLoading:!1}})}},[]),xe=e=>{be(e)},Y=async(e,t)=>{if(t===`continue`){window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{sessionKey:e},bubbles:!0}));return}if(t===`delete`){w({type:`patch`,patch:{confirmKey:e,confirmOpen:!0}});return}try{switch(t){case`archive`:await z(e),ye(e,`archived`);break;case`unarchive`:await pe(e),ye(e,`active`);break;case`pin`:await me(e),ye(e,`pinned`);break;case`unpin`:await ce(e),ye(e,`active`);break;case`export`:{let t=await H(e),n=new Blob([t],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`session-${e.replace(/[^a-z0-9]/gi,`_`)}.json`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(r);break}default:break}T().then(e=>w({type:`patch`,patch:{stats:e}})).catch(()=>{})}catch{}},Se=async e=>{try{await L(e),w({type:`patch`,patch:{sessions:W.filter(t=>t.key!==e),detailSession:K?.key===e?null:K,...K?.key===e?{detailOpen:!1}:{}}}),T().then(e=>w({type:`patch`,patch:{stats:e}})).catch(()=>{})}catch{}},Ce={continueChat:t.continueChat,archive:t.archive,unarchive:t.unarchive,pin:t.pin,unpin:t.unpin,export:t.export,delete:t.delete,unnamedSession:e.chat.newSession},we={close:t.close,detailLoading:t.detailLoading,detailMessages:t.detailMessages,detailExport:t.detailExport,archive:t.archive,unarchive:t.unarchive,pin:t.pin,unpin:t.unpin,delete:t.delete,unnamedSession:e.chat.newSession},Te=[{key:`all`,label:t.filterAll,icon:N},{key:`active`,label:t.filterActive,icon:I},{key:`pinned`,label:t.filterPinned,icon:he},{key:`archived`,label:t.filterArchived,icon:_e}],De=(()=>{let e=Object.entries(se?.byChannel??{}).sort((e,t)=>t[1]-e[1]).slice(0,6).map(([e])=>e),t=new Set(e);for(let n of[`telegram`,`weixin`,`feishu`])t.has(n)||(e.push(n),t.add(n));return e.slice(0,8)})();return r?(0,Z.jsxs)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col overflow-x-hidden bg-surface-panel`,children:[(0,Z.jsxs)(`div`,{className:`flex w-full flex-col gap-6 px-3 py-6 sm:px-5 xl:px-6`,children:[(0,Z.jsx)(`header`,{className:`flex flex-col gap-2`,children:(0,Z.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:t.title})}),(0,Z.jsx)(ft,{s:t,activeTab:g,onChange:y}),(0,Z.jsx)(pt,{s:t,id:`settings`,activeTab:g,plain:!0,children:(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[(0,Z.jsx)(qe,{hasToken:r}),(0,Z.jsx)(et,{hasToken:r})]})}),(0,Z.jsxs)(pt,{s:t,id:`sessions`,activeTab:g,plain:!0,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between`,children:[(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:Te.map(({key:e,label:t,icon:n})=>(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":P===e,onClick:()=>w({type:`patch`,patch:{statusFilter:e}}),className:u(`inline-flex items-center gap-1.5 rounded-xl px-3 py-2 text-sm font-medium`,j.transition,j.focusRingPanel,P===e?`bg-accent-soft text-accent-fg`:`bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/35`),children:[(0,Z.jsx)(n,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t]},e))}),(0,Z.jsxs)(`div`,{className:`flex w-full min-w-0 items-center gap-2 rounded-xl bg-surface-base px-3 py-2 transition-colors lg:max-w-md dark:bg-surface-hover/40`,children:[(0,Z.jsx)(O,{className:`size-4 shrink-0 text-fg-disabled`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`input`,{type:`search`,value:E,onChange:e=>w({type:`patch`,patch:{searchInput:e.target.value}}),placeholder:t.searchPlaceholder,"data-debounced-query":A||void 0,className:`min-w-0 flex-1 border-0 bg-transparent text-sm text-fg placeholder:text-fg-disabled focus:outline-none focus:ring-0`})]})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-fg-subtle`,children:t.filterChannelLabel}),(0,Z.jsx)(`button`,{type:`button`,"aria-pressed":!U,onClick:()=>w({type:`patch`,patch:{channelFilter:``}}),className:u(`inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,j.transition,j.focusRingPanel,U?`bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/35`:`bg-accent-soft text-accent-fg`),children:t.filterChannelAll}),De.map(e=>(0,Z.jsxs)(`button`,{type:`button`,"aria-pressed":U===e,onClick:()=>w({type:`patch`,patch:{channelFilter:e}}),className:u(`inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,j.transition,j.focusRingPanel,U===e?`bg-accent-soft text-accent-fg`:`bg-surface-base text-fg-muted hover:bg-surface-hover hover:text-fg dark:bg-surface-hover/35`),children:[e,se?.byChannel?.[e]==null?null:(0,Z.jsx)(`span`,{className:`ml-2 rounded-full bg-surface-hover px-2 py-0.5 text-[11px] text-fg-subtle`,children:se.byChannel[e]})]},e))]}),se?(0,Z.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[[se.totalSessions,t.totalSessions],[se.activeSessions,t.activeSessions],[se.pinnedSessions,t.pinnedSessions],[se.archivedSessions,t.archivedSessions]].map(([e,t])=>(0,Z.jsxs)(`div`,{className:`rounded-xl bg-surface-base p-3 dark:bg-surface-hover/30`,children:[(0,Z.jsx)(`div`,{className:`text-lg font-semibold tabular-nums text-fg`,children:e}),(0,Z.jsx)(`div`,{className:`text-xs text-fg-muted`,children:t})]},t))}):null,ae?(0,Z.jsx)(`div`,{className:`rounded-lg border border-edge bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-edge dark:bg-red-950/40 dark:text-red-300`,children:ae}):null,(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:at(t.sessionCount,{count:W.length})}),(0,Z.jsxs)(`div`,{className:B,role:`group`,"aria-label":t.layoutToggleGroup,children:[(0,Z.jsx)(d,{type:`button`,variant:`segmented`,title:t.gridView,"aria-pressed":R===`grid`,onClick:()=>w({type:`patch`,patch:{viewMode:`grid`}}),className:u(M,`size-7 p-0`,R===`grid`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,R===`grid`&&`text-accent-fg`),children:(0,Z.jsx)(D,{className:`size-3.5`,strokeWidth:1.5})}),(0,Z.jsx)(d,{type:`button`,variant:`segmented`,title:t.listView,"aria-pressed":R===`list`,onClick:()=>w({type:`patch`,patch:{viewMode:`list`}}),className:u(M,`size-9 p-0`,R===`list`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,R===`list`&&`text-accent-fg`),children:(0,Z.jsx)(le,{className:`size-3.5`,strokeWidth:1.5})})]})]}),ie&&W.length===0?(0,Z.jsx)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2 lg:grid-cols-3`,children:Array.from({length:6}).map((e,t)=>(0,Z.jsx)(`div`,{className:`h-40 animate-pulse rounded-xl bg-surface-hover/60 dark:bg-surface-hover/40`},t))}):W.length===0?(0,Z.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-2xl bg-surface-base py-16 text-center dark:bg-surface-hover/25`,children:[(0,Z.jsx)(V,{className:`mb-3 size-12 text-fg-disabled`,strokeWidth:1.25,"aria-hidden":!0}),(0,Z.jsx)(`p`,{className:`text-base font-semibold text-fg`,children:t.noSessions}),(0,Z.jsx)(`p`,{className:`mt-1 max-w-sm text-sm text-fg-muted`,children:t.noSessionsDescription}),(0,Z.jsx)(d,{variant:`primary`,className:`mt-6`,onClick:()=>{window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{sessionKey:``},bubbles:!0}))},children:t.startNewChat})]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:u(`grid min-w-0 gap-3`,R===`grid`?`sm:grid-cols-2 lg:grid-cols-3`:`grid-cols-1`),"data-debounced-query":A||void 0,children:W.map(e=>{let t=Ae(e,s);return(0,Z.jsx)(Ee,{session:e,variant:R,labels:Ce,sessionAgentId:t,sessionAgentAvatar:je(t,c),onOpen:()=>xe(e.key),onAction:t=>void Y(e.key,t)},e.key)})}),G?(0,Z.jsx)(`div`,{className:`flex justify-center pt-2`,children:(0,Z.jsx)(d,{type:`button`,variant:`secondary`,disabled:ie,onClick:()=>void ve(),children:t.loadMore})}):null]})]})]}),(0,Z.jsx)(nt,{open:ue,loading:de,session:K,sessionAgentId:K?Ae(K,s):void 0,sessionAgentAvatar:K?je(Ae(K,s),c):void 0,labels:we,onClose:()=>{w({type:`patch`,patch:{detailOpen:!1,detailSession:null}})},onArchive:()=>K&&void Y(K.key,`archive`),onUnarchive:()=>K&&void Y(K.key,`unarchive`),onPin:()=>K&&void Y(K.key,`pin`),onUnpin:()=>K&&void Y(K.key,`unpin`),onExport:()=>K&&void Y(K.key,`export`),onDelete:()=>K&&w({type:`patch`,patch:{confirmKey:K.key,confirmOpen:!0}})}),(0,Z.jsx)(ne,{open:fe,onOpenChange:e=>w({type:`patch`,patch:{confirmOpen:e}}),children:(0,Z.jsxs)(b,{children:[(0,Z.jsx)(ee,{className:u(`xopc-dialog-overlay fixed inset-0 bg-scrim`,v)}),(0,Z.jsxs)(te,{className:u(`xopc-dialog-content fixed left-1/2 top-1/2 w-[min(100%-2rem,24rem)] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-edge bg-surface-panel p-4 shadow-popover dark:border-edge`,_),children:[(0,Z.jsx)(x,{className:`text-base font-semibold text-fg`,children:t.deleteSessionTitle}),(0,Z.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:q?at(t.deleteSessionMessage,{name:W.find(e=>e.key===q)?.name?.trim()||e.chat.newSession}):``}),(0,Z.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,Z.jsx)(d,{type:`button`,variant:`secondary`,onClick:()=>w({type:`patch`,patch:{confirmOpen:!1}}),children:t.cancel}),(0,Z.jsx)(d,{type:`button`,variant:`primary`,className:`bg-red-600 hover:bg-red-700`,onClick:()=>{q&&Se(q),w({type:`patch`,patch:{confirmOpen:!1,confirmKey:null}})},children:t.delete})]})]})]})})]}):(0,Z.jsx)(`div`,{className:`w-full px-3 py-16 text-center text-sm text-fg-muted sm:px-5 xl:px-6`,children:t.needToken})}export{ht as SessionsPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{Pn as e}from"./index-_cuTcWjB.js";function t(t){let{children:n,fallback:r}=t,i=r===void 0?null:r;return e()?n:i}export{t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as a}from"./loader-circle-CifKLtgG.js";import{t as o}from"./cn-JdwAhgNB.js";import{t as s}from"./messages-ctG2e-ix.js";import{l as c,n as l,r as u,s as d}from"./locale-store-C5MK9WcP.js";import{i as f}from"./vendor-swr-BIWyz7Rc.js";import{r as p}from"./gateway-config-swr-BIxuwPQi.js";import{Al as m,Cl as h,Cs as g,Fc as _,Jo as v,Ko as y,Lt as b,Nl as x,Ra as S,Sl as C,Ws as w,Xt as T,Zt as E,jn as D,ms as O,ru as k}from"./index-_cuTcWjB.js";import{n as A,r as j}from"./settings-page-layout-BRQNel6r.js";import{n as M}from"./settings-loading-skeleton-CYDV2JtY.js";import{n as N,t as P}from"./settings-form-section-B9dnKr3M.js";var F=e(t(),1),I=n();function L(e){if(!e||typeof e!=`object`)return 0;let t=e.providers;return!t||typeof t!=`object`||Array.isArray(t)?0:Object.values(t).filter(e=>typeof e==`string`&&y(e)).length}function R(e){if(!e||typeof e!=`object`)return``;let t=e.agents;if(!t||typeof t!=`object`||Array.isArray(t))return``;let n=t,r=typeof n.defaultPreset==`string`&&n.defaultPreset.trim()?n.defaultPreset.trim():`default`,i=n.capabilityPresets,a=i&&typeof i==`object`&&!Array.isArray(i)?i[r]:void 0,o=a&&typeof a==`object`&&!Array.isArray(a)?a.models:void 0;if(!o||typeof o!=`object`||Array.isArray(o))return``;let s=o,c=s.roles;if(!c||typeof c!=`object`||Array.isArray(c))return``;let l=c,u=typeof s.defaultRole==`string`&&s.defaultRole.trim()?s.defaultRole.trim():Object.keys(l)[0],d=u?l[u]:void 0;if(!d||typeof d!=`object`||Array.isArray(d))return``;let f=d.model;return typeof f==`string`?f.trim():``}function z(e){if(!e||typeof e!=`object`)return!1;let t=e.channels;return!t||typeof t!=`object`||Array.isArray(t)?!1:Object.values(t).some(e=>{if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;if(`configured`in t||`config`in t||`schema`in t||`uiHints`in t){if(t.configured===!0)return!0;let e=t.config;if(!e||typeof e!=`object`||Array.isArray(e))return!1;let n=e;return n.enabled===!0||Object.keys(n).length>0}return t.enabled===!0||Object.keys(t).length>0})}function B(e){if(!e||typeof e!=`object`)return{enabled:!1,backend:`extension`};let t=e.browser;if(!t||typeof t!=`object`||Array.isArray(t))return{enabled:!1,backend:`extension`};let n=t;return{enabled:n.enabled===!0,backend:typeof n.backend==`string`&&n.backend.trim()?n.backend.trim():`extension`}}function V(e){return e?`pass`:`fail`}function H(e){if(e===`provider-auth`)return`/settings/capabilities/models`;if(e===`config-health`)return`/settings/gateway`;if(e===`state-integrity`||e===`workspace-status`)return`/agents`;if(e===`database-schema`||e===`session-integrity`)return`/settings/sessions`;if(e===`channel-config`||e===`channel-pairing-pending`||e.startsWith(`channel:`))return`/channels`;if(e===`security-audit`||e===`gateway-service`||e===`gateway-health`)return`/settings/gateway`;if(e===`version-check`)return`/settings/desktop-app`}function U(e){return{fail:4,warn:3,skip:2,pass:1}[e]}function ee(e){return e.filter(e=>e.status===`fail`||e.status===`warn`).map(e=>({id:e.id,label:e.label,status:e.status,message:e.message,hints:e.hints,path:H(e.id),source:`doctor`})).toSorted((e,t)=>U(t.status)-U(e.status)||e.label.localeCompare(t.label))}function W(e){let t=new Map(e.doctorChecks.map(e=>[e.id,e])),n=[];for(let e of[`security-audit`,`channel-config`,`channel-pairing-pending`,`gateway-health`]){let r=t.get(e);r&&n.push({id:r.id,label:r.label,status:r.status,message:r.message,path:H(r.id)})}if(e.logsHealth){let t=e.logsHealth.stats?.errorsLast24h??0;n.push({id:`logs-health`,label:`Logs`,status:e.logsHealth.shuttingDown||t>0?`warn`:`pass`,message:e.logsHealth.shuttingDown?`Logger is shutting down.`:t>0?`${t} error(s) in the last 24 hours.`:`Log system is healthy.`,path:`/settings/logs`})}for(let t of e.browserDiagnostics??[])n.push(t);return n}function te(e){let t=L(e.config),n=e.providerMeta?.configured??t,r=e.providerMeta?.total??0,i=n>0||t>0,a=R(e.config),o=a.length>0,s=e.hasToken&&e.realtimeConnected,c=z(e.config),l=e.skillCount>0,u=e.doctorChecks??[],d=ee(u),f=[{id:`gateway`,done:s,detail:s?e.labels.gatewayOnline:e.labels.gatewayOffline},{id:`provider`,done:i,detail:i?e.providerMeta&&e.providerMeta.total>0?e.labels.providersMetaReady(n,r):e.labels.providersConfigured(t):e.labels.providersMissing},{id:`defaultModel`,done:o,detail:o?e.labels.modelConfigured(a):e.labels.modelMissing},{id:`channel`,done:c,optional:!0,detail:c?e.labels.channelConfigured:e.labels.channelMissing},{id:`skill`,done:l,optional:!0,detail:l?e.labels.skillsConfigured(e.skillCount):e.labels.skillsMissing}],p=f.filter(e=>!e.optional).every(e=>e.done),m=f.every(e=>e.done),h=[{id:`gateway`,status:V(s),title:`Gateway`,detail:s?e.labels.gatewayOnline:e.labels.gatewayOffline,path:`/settings/gateway`},{id:`provider`,status:V(i),title:`Model provider`,detail:i?e.providerMeta&&e.providerMeta.total>0?e.labels.providersMetaReady(n,r):e.labels.providersConfigured(t):e.labels.providersMissing,path:`/settings/capabilities/models`},{id:`defaultModel`,status:V(o),title:`Default model`,detail:o?e.labels.modelConfigured(a):e.labels.modelMissing,path:`/settings/capabilities/models`},{id:`ready`,status:p?`pass`:`fail`,title:`Chat readiness`,detail:p?e.labels.readyToChat:e.labels.modelMissing,path:`/chat`}],g=d.some(e=>e.status===`fail`),_=d.some(e=>e.status===`warn`),v=g?`blocked`:_?`attention`:p?`ready`:`setup`,y=W({doctorChecks:u,logsHealth:e.logsHealth,browserDiagnostics:e.browserDiagnostics});return{gatewayConnected:s,providerConfigured:i,providerCount:t,providerMetaConfigured:n,providerMetaTotal:r,defaultModel:a,defaultModelConfigured:o,channelConfigured:c,skillInstalled:l,skillCount:e.skillCount,checklist:f,readiness:h,issues:d,healthTier:v,diagnosticSignals:y,requiredComplete:p,allComplete:m}}function ne(e){return B(e)}function G(e){return!e.id||!e.label||!e.status||!e.message||![`pass`,`warn`,`fail`,`skip`].includes(e.status)?null:{id:e.id,label:e.label,status:e.status,message:e.message,hints:Array.isArray(e.hints)?e.hints.filter(e=>typeof e==`string`):[],fixed:e.fixed===!0,findings:Array.isArray(e.findings)?e.findings:void 0}}function re(){return u(`/api/doctor`)}async function ie(){return((await d(re())).checks??[]).map(G).filter(e=>e!==null)}function ae(){return u(`/api/logs/health`)}async function oe(){return d(ae())}function K(e){return e?`pass`:`warn`}function q(e){return`/settings/agent-browser?tab=${encodeURIComponent(e)}`}function se(e){return e?.enabled?[`setup-browser-diagnostics`,e]:null}async function ce(e){if(!e.enabled)return[];if(e.backend===`local`){let e=await d(u(`/api/browser/playwright/doctor`)),t=e.payload?.installed===!0;return[{id:`browser-playwright`,label:`Browser: Playwright`,status:K(t),message:t?`Local Chromium is installed.`:e.payload?.reason??`Local Chromium is not installed.`,path:q(`local`)}]}if(e.backend===`cloakbrowser`){let e=await d(u(`/api/browser/cloakbrowser/doctor`)),t=e.payload?.installed===!0;return[{id:`browser-cloakbrowser`,label:`Browser: CloakBrowser`,status:K(t),message:t?`CloakBrowser ${e.payload?.version??``}`.trim():`CloakBrowser is not installed.`,path:q(`cloakbrowser`)}]}if(e.backend===`extension`){let e=await d(u(`/api/browser/extension-status?probe=true`)),t=e.artifacts?.installed===!0,n=e.connected===!0,r=e.artifacts?.needsRefresh===!0||e.artifacts?.needsChromeReload===!0;return[{id:`browser-extension`,label:`Browser: Chrome extension`,status:n?`pass`:`warn`,message:n?`Chrome extension bridge is connected.`:t?r?`Chrome extension needs refresh.`:`Chrome extension is installed but not connected.`:`Chrome extension is not installed.`,path:q(`extension`)}]}return[{id:`browser-playwright`,label:`Browser`,status:`skip`,message:`Browser backend "${e.backend}" is not checked on this overview.`,path:q(e.backend||`overview`)}]}function J(){let e=(0,I.c)(57),t=c(me),n=l(pe),r;e[0]===n?r=e[1]:(r=s(n),e[0]=n,e[1]=r);let i=r,a=i.setupStatus.labels,o=S(fe),{data:u,error:d,isLoading:m,mutate:h}=p(!!t),g;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(g={revalidateOnFocus:!1},e[2]=g):g=e[2];let{data:_,error:v,isLoading:y,mutate:x}=f(t?`setup-checklist-skills`:null,de,g),C;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(C={revalidateOnFocus:!1},e[3]=C):C=e[3];let{data:w,error:D,isLoading:O,mutate:k}=f(t?`setup-checklist-provider-meta`:null,b,C),A;e[4]===t?A=e[5]:(A=t?re():null,e[4]=t,e[5]=A);let j;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(j={revalidateOnFocus:!1},e[6]=j):j=e[6];let{data:M,error:N,isLoading:P,mutate:F}=f(A,ie,j),L;e[7]===t?L=e[8]:(L=t?ae():null,e[7]=t,e[8]=L);let R;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(R={revalidateOnFocus:!1},e[9]=R):R=e[9];let{data:z,isLoading:B,mutate:V}=f(L,oe,R);u?.payload?.config;let H=u?.payload?.config,U;e[10]===H?U=e[11]:(U=ne(H),e[10]=H,e[11]=U);let ee=t?U:null,W;e[12]===ee?W=e[13]:(W=se(ee),e[12]=ee,e[13]=W);let G;e[14]===Symbol.for(`react.memo_cache_sentinel`)?(G={revalidateOnFocus:!1},e[14]=G):G=e[14];let{data:K,isLoading:q,mutate:ce}=f(W,ue,G),J;e[15]===Symbol.for(`react.memo_cache_sentinel`)?(J={revalidateOnFocus:!1},e[15]=J):J=e[15],f(t?T:null,E,J);let Y=!t||!m&&!y&&!O&&!P&&!B&&!q,X=!!(d||v||D||N),Z;bb0:{if(!t||!Y){Z=null;break bb0}let n=_?.catalog?.length??0,r;if(e[16]!==K||e[17]!==u?.payload?.config||e[18]!==M||e[19]!==a.channelConfigured||e[20]!==a.channelMissing||e[21]!==a.gatewayOffline||e[22]!==a.gatewayOnline||e[23]!==a.modelConfigured||e[24]!==a.modelMissing||e[25]!==a.providersConfigured||e[26]!==a.providersMetaReady||e[27]!==a.providersMissing||e[28]!==a.skillsConfigured||e[29]!==a.skillsMissing||e[30]!==z||e[31]!==i.setupStatus.requiredCompleteMessage||e[32]!==w||e[33]!==o||e[34]!==n||e[35]!==t){let s=w?.filter(le).length??0,c=w?.length??0,l;e[37]===a.providersConfigured?l=e[38]:(l=e=>a.providersConfigured.replace(`{{count}}`,String(e)),e[37]=a.providersConfigured,e[38]=l);let d;e[39]===a.providersMetaReady?d=e[40]:(d=(e,t)=>a.providersMetaReady.replace(`{{configured}}`,String(e)).replace(`{{total}}`,String(t)),e[39]=a.providersMetaReady,e[40]=d);let f;e[41]===a.modelConfigured?f=e[42]:(f=e=>a.modelConfigured.replace(`{{model}}`,e),e[41]=a.modelConfigured,e[42]=f);let p;e[43]===a.skillsConfigured?p=e[44]:(p=e=>a.skillsConfigured.replace(`{{count}}`,String(e)),e[43]=a.skillsConfigured,e[44]=p),r=te({hasToken:!!t,realtimeConnected:o,config:u?.payload?.config,skillCount:n,providerMeta:c>0?{configured:s,total:c}:null,doctorChecks:M,logsHealth:z,browserDiagnostics:K,labels:{gatewayOnline:a.gatewayOnline,gatewayOffline:a.gatewayOffline,providersConfigured:l,providersMetaReady:d,providersMissing:a.providersMissing,modelConfigured:f,modelMissing:a.modelMissing,channelConfigured:a.channelConfigured,channelMissing:a.channelMissing,skillsConfigured:p,skillsMissing:a.skillsMissing,readyToChat:i.setupStatus.requiredCompleteMessage}}),e[16]=K,e[17]=u?.payload?.config,e[18]=M,e[19]=a.channelConfigured,e[20]=a.channelMissing,e[21]=a.gatewayOffline,e[22]=a.gatewayOnline,e[23]=a.modelConfigured,e[24]=a.modelMissing,e[25]=a.providersConfigured,e[26]=a.providersMetaReady,e[27]=a.providersMissing,e[28]=a.skillsConfigured,e[29]=a.skillsMissing,e[30]=z,e[31]=i.setupStatus.requiredCompleteMessage,e[32]=w,e[33]=o,e[34]=n,e[35]=t,e[36]=r}else r=e[36];Z=r}let he=Z,Q;e[45]!==ce||e[46]!==h||e[47]!==F||e[48]!==V||e[49]!==k||e[50]!==x?(Q=async()=>{await Promise.all([h(),x(),k(),F(),V(),ce()])},e[45]=ce,e[46]=h,e[47]=F,e[48]=V,e[49]=k,e[50]=x,e[51]=Q):Q=e[51];let ge=Q,$;return e[52]!==X||e[53]!==Y||e[54]!==ge||e[55]!==he?($={ready:Y,error:X,snapshot:he,refresh:ge},e[52]=X,e[53]=Y,e[54]=ge,e[55]=he,e[56]=$):$=e[56],$}function le(e){return e.configured}function ue(e){let[,t]=e;return ce(t)}function de(){return D()}function fe(e){return e.connectionState===`connected`}function pe(e){return e.language}function me(e){return e.token}var Y=r();function X(e){return e===`pass`?`border-success/30 bg-success-soft text-success`:e===`warn`?`border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300`:e===`fail`?`border-red-500/30 bg-red-500/10 text-red-700 dark:text-red-300`:`border-edge bg-surface-hover text-fg-muted`}function Z(e){return e===`pass`?m:e===`warn`?O:e===`fail`?h:_}function he(e,t){return e===`blocked`?{icon:h,className:`bg-red-500/10 text-red-950 dark:text-red-100`,title:t.health.blockedTitle,body:t.health.blockedBody,action:t.health.viewIssues,targetId:`next-steps`}:e===`attention`?{icon:O,className:`bg-amber-500/10 text-amber-950 dark:text-amber-100`,title:t.health.attentionTitle,body:t.health.attentionBody,action:t.health.viewIssues,targetId:`next-steps`}:e===`setup`?{icon:C,className:`bg-surface-base text-fg shadow-surface`,title:t.health.setupTitle,body:t.health.setupBody,action:t.health.continueSetup,targetId:`next-steps`}:{icon:m,className:`bg-success-soft text-success`,title:t.health.readyTitle,body:t.health.readyBody,action:t.health.startChat,actionPath:`/chat`}}function Q(e){let t=(0,I.c)(48),{tier:n,issueCount:r,onRunDoctor:c,ready:u,doctorRunning:d,doctorRunState:f}=e,p=l(ge),m,h,g,_,y,b,S,C,T,E,D;if(t[0]!==r||t[1]!==p||t[2]!==n){h=s(p).setupStatus;let e=he(n,h),a=e.icon,c=`targetId`in e&&typeof e.targetId==`string`?e.targetId:null,l=`actionPath`in e&&typeof e.actionPath==`string`?e.actionPath:`/chat`;m=c?(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>document.getElementById(c)?.scrollIntoView({block:`start`,behavior:`smooth`}),className:`inline-flex items-center gap-1 rounded-lg bg-surface-base px-3 py-2 text-sm font-medium text-fg shadow-sm hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[e.action,(0,Y.jsx)(x,{className:`size-4`,"aria-hidden":!0})]}):(0,Y.jsxs)(i,{to:l,className:`inline-flex items-center gap-1 rounded-lg bg-surface-base px-3 py-2 text-sm font-medium text-fg shadow-sm hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[e.action,(0,Y.jsx)(x,{className:`size-4`,"aria-hidden":!0})]}),D=o(`rounded-xl p-4`,e.className),E=`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,C=`flex min-w-0 gap-3`,T=(0,Y.jsx)(a,{className:`mt-0.5 size-5 shrink-0`,"aria-hidden":!0}),y=`min-w-0`,b=(0,Y.jsx)(`h2`,{className:`text-base font-semibold`,children:e.title}),S=(0,Y.jsx)(`p`,{className:`mt-1 text-sm opacity-85`,children:e.body}),g=`mt-2 text-xs opacity-75`,_=h.health.issueCount.replace(`{{count}}`,String(r)),t[0]=r,t[1]=p,t[2]=n,t[3]=m,t[4]=h,t[5]=g,t[6]=_,t[7]=y,t[8]=b,t[9]=S,t[10]=C,t[11]=T,t[12]=E,t[13]=D}else m=t[3],h=t[4],g=t[5],_=t[6],y=t[7],b=t[8],S=t[9],C=t[10],T=t[11],E=t[12],D=t[13];let O;t[14]!==g||t[15]!==_?(O=(0,Y.jsx)(`p`,{className:g,children:_}),t[14]=g,t[15]=_,t[16]=O):O=t[16];let k;t[17]!==O||t[18]!==y||t[19]!==b||t[20]!==S?(k=(0,Y.jsxs)(`div`,{className:y,children:[b,S,O]}),t[17]=O,t[18]=y,t[19]=b,t[20]=S,t[21]=k):k=t[21];let A;t[22]!==k||t[23]!==C||t[24]!==T?(A=(0,Y.jsxs)(`div`,{className:C,children:[T,k]}),t[22]=k,t[23]=C,t[24]=T,t[25]=A):A=t[25];let j;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(j=o(`inline-flex items-center gap-2 rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,v.press),t[26]=j):j=t[26];let M=!u||d,N;t[27]===d?N=t[28]:(N=d?(0,Y.jsx)(a,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,Y.jsx)(w,{className:`size-4`,"aria-hidden":!0}),t[27]=d,t[28]=N);let P=d?h.health.runDoctorRunning:h.health.runDoctor,F;t[29]!==d||t[30]!==c||t[31]!==M||t[32]!==N||t[33]!==P?(F=(0,Y.jsxs)(`button`,{type:`button`,className:j,onClick:c,disabled:M,"aria-busy":d,children:[N,P]}),t[29]=d,t[30]=c,t[31]=M,t[32]=N,t[33]=P,t[34]=F):F=t[34];let L;t[35]!==m||t[36]!==F?(L=(0,Y.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:[m,F]}),t[35]=m,t[36]=F,t[37]=L):L=t[37];let R;t[38]!==A||t[39]!==L||t[40]!==E?(R=(0,Y.jsxs)(`div`,{className:E,children:[A,L]}),t[38]=A,t[39]=L,t[40]=E,t[41]=R):R=t[41];let z=d?h.health.doctorRunningMessage:f===`success`?h.health.doctorCompleteMessage:f===`error`?h.health.doctorFailedMessage:h.health.doctorIdleMessage,B;t[42]===z?B=t[43]:(B=(0,Y.jsx)(`p`,{className:`mt-3 text-xs opacity-75`,role:`status`,"aria-live":`polite`,children:z}),t[42]=z,t[43]=B);let V;return t[44]!==R||t[45]!==B||t[46]!==D?(V=(0,Y.jsxs)(`section`,{className:D,children:[R,B]}),t[44]=R,t[45]=B,t[46]=D,t[47]=V):V=t[47],V}function ge(e){return e.language}function $(e){let t=(0,I.c)(34),{issue:n,fixLabel:r}=e,a;t[0]===n.status?a=t[1]:(a=Z(n.status),t[0]=n.status,t[1]=a);let s=a,c;t[2]===s?c=t[3]:(c=(0,Y.jsx)(s,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":!0}),t[2]=s,t[3]=c);let l;t[4]===n.label?l=t[5]:(l=(0,Y.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:n.label}),t[4]=n.label,t[5]=l);let u;t[6]===n.status?u=t[7]:(u=o(`rounded-full border px-2 py-0.5 text-[11px] font-medium uppercase`,X(n.status)),t[6]=n.status,t[7]=u);let d;t[8]!==n.status||t[9]!==u?(d=(0,Y.jsx)(`span`,{className:u,children:n.status}),t[8]=n.status,t[9]=u,t[10]=d):d=t[10];let f;t[11]!==l||t[12]!==d?(f=(0,Y.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[l,d]}),t[11]=l,t[12]=d,t[13]=f):f=t[13];let p;t[14]===n.message?p=t[15]:(p=(0,Y.jsx)(`span`,{className:`mt-1 block text-sm text-fg-muted`,children:n.message}),t[14]=n.message,t[15]=p);let m;t[16]===n.hints[0]?m=t[17]:(m=n.hints[0]?(0,Y.jsx)(`span`,{className:`mt-1 block truncate text-xs text-fg-subtle`,children:n.hints[0]}):null,t[16]=n.hints[0],t[17]=m);let h;t[18]!==f||t[19]!==p||t[20]!==m?(h=(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[f,p,m]}),t[18]=f,t[19]=p,t[20]=m,t[21]=h):h=t[21];let g;t[22]!==r||t[23]!==n.path?(g=n.path?(0,Y.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1 text-xs font-medium text-accent-fg`,children:[r,(0,Y.jsx)(x,{className:`size-4`,"aria-hidden":!0})]}):null,t[22]=r,t[23]=n.path,t[24]=g):g=t[24];let _;t[25]!==g||t[26]!==c||t[27]!==h?(_=(0,Y.jsxs)(Y.Fragment,{children:[c,h,g]}),t[25]=g,t[26]=c,t[27]=h,t[28]=_):_=t[28];let v=_;if(n.path){let e;return t[29]!==v||t[30]!==n.path?(e=(0,Y.jsx)(i,{to:n.path,className:`flex items-start gap-3 rounded-lg bg-surface-panel/80 p-3 shadow-surface hover:bg-surface-hover/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:v}),t[29]=v,t[30]=n.path,t[31]=e):e=t[31],e}let y;return t[32]===v?y=t[33]:(y=(0,Y.jsx)(`div`,{className:`flex items-start gap-3 rounded-lg bg-surface-panel/80 p-3 shadow-surface`,children:v}),t[32]=v,t[33]=y),y}function _e(e){let t=(0,I.c)(27),{item:n,labels:r}=e,a;t[0]===n.status?a=t[1]:(a=Z(n.status),t[0]=n.status,t[1]=a);let s=a,c=r[n.id]??n.title,l;t[2]===n.status?l=t[3]:(l=o(`flex size-7 shrink-0 items-center justify-center rounded-full border`,X(n.status)),t[2]=n.status,t[3]=l);let u;t[4]===s?u=t[5]:(u=(0,Y.jsx)(s,{className:`size-4`,"aria-hidden":!0}),t[4]=s,t[5]=u);let d;t[6]!==l||t[7]!==u?(d=(0,Y.jsx)(`span`,{className:l,children:u}),t[6]=l,t[7]=u,t[8]=d):d=t[8];let f;t[9]===c?f=t[10]:(f=(0,Y.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:c}),t[9]=c,t[10]=f);let p;t[11]===n.detail?p=t[12]:(p=(0,Y.jsx)(`span`,{className:`mt-0.5 block truncate text-xs text-fg-muted`,children:n.detail}),t[11]=n.detail,t[12]=p);let m;t[13]!==f||t[14]!==p?(m=(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[f,p]}),t[13]=f,t[14]=p,t[15]=m):m=t[15];let h;t[16]===n.path?h=t[17]:(h=n.path?(0,Y.jsx)(x,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0}):null,t[16]=n.path,t[17]=h);let g;t[18]!==d||t[19]!==m||t[20]!==h?(g=(0,Y.jsxs)(Y.Fragment,{children:[d,m,h]}),t[18]=d,t[19]=m,t[20]=h,t[21]=g):g=t[21];let _=g;if(n.path){let e;return t[22]!==_||t[23]!==n.path?(e=(0,Y.jsx)(i,{to:n.path,className:`flex items-center gap-3 rounded-lg p-3 hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:_}),t[22]=_,t[23]=n.path,t[24]=e):e=t[24],e}let v;return t[25]===_?v=t[26]:(v=(0,Y.jsx)(`div`,{className:`flex items-center gap-3 rounded-lg p-3`,children:_}),t[25]=_,t[26]=v),v}function ve(e){let t=(0,I.c)(29),{signal:n,fixLabel:r}=e,a;t[0]===n.status?a=t[1]:(a=Z(n.status),t[0]=n.status,t[1]=a);let s=a,c;t[2]===s?c=t[3]:(c=(0,Y.jsx)(s,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":!0}),t[2]=s,t[3]=c);let l;t[4]===n.label?l=t[5]:(l=(0,Y.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:n.label}),t[4]=n.label,t[5]=l);let u;t[6]===n.message?u=t[7]:(u=(0,Y.jsx)(`span`,{className:`mt-0.5 block truncate text-xs text-fg-muted`,children:n.message}),t[6]=n.message,t[7]=u);let d;t[8]!==l||t[9]!==u?(d=(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[l,u]}),t[8]=l,t[9]=u,t[10]=d):d=t[10];let f;t[11]===n.status?f=t[12]:(f=o(`shrink-0 rounded-full border px-2 py-0.5 text-[11px] font-medium uppercase`,X(n.status)),t[11]=n.status,t[12]=f);let p;t[13]!==n.status||t[14]!==f?(p=(0,Y.jsx)(`span`,{className:f,children:n.status}),t[13]=n.status,t[14]=f,t[15]=p):p=t[15];let m;t[16]!==r||t[17]!==n.path?(m=n.path?(0,Y.jsx)(`span`,{className:`sr-only`,children:r}):null,t[16]=r,t[17]=n.path,t[18]=m):m=t[18];let h;t[19]!==c||t[20]!==d||t[21]!==p||t[22]!==m?(h=(0,Y.jsxs)(Y.Fragment,{children:[c,d,p,m]}),t[19]=c,t[20]=d,t[21]=p,t[22]=m,t[23]=h):h=t[23];let g=h;if(n.path){let e;return t[24]!==g||t[25]!==n.path?(e=(0,Y.jsx)(i,{to:n.path,className:`flex min-w-0 items-start gap-2 rounded-lg bg-surface-panel/80 px-3 py-2.5 shadow-surface hover:bg-surface-hover/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:g}),t[24]=g,t[25]=n.path,t[26]=e):e=t[26],e}let _;return t[27]===g?_=t[28]:(_=(0,Y.jsx)(`div`,{className:`flex min-w-0 items-start gap-2 rounded-lg bg-surface-panel/80 px-3 py-2.5 shadow-surface`,children:g}),t[27]=g,t[28]=_),_}function ye(){let e=s(l(e=>e.language)).setupStatus,{ready:t,error:n,snapshot:r,refresh:i}=J(),[a,c]=(0,F.useState)(!1),[u,d]=(0,F.useState)(`idle`),f=r?.diagnosticSignals.filter(e=>e.status===`fail`||e.status===`warn`)??[],p=async()=>{if(!(a||!t)){c(!0),d(`idle`);try{await i(),d(`success`)}catch{d(`error`)}finally{c(!1)}}};return(0,Y.jsxs)(j,{gap:`gap-6`,children:[(0,Y.jsx)(A,{title:e.title,subtitle:e.subtitle,actions:(0,Y.jsxs)(`button`,{type:`button`,className:o(`inline-flex shrink-0 items-center gap-2 rounded-lg border border-edge px-3 py-2 text-sm font-medium text-fg`,`hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,v.press),onClick:()=>void p(),disabled:!t||a,"aria-busy":a,children:[(0,Y.jsx)(w,{className:o(`size-4`,(!t||a)&&`animate-spin`),"aria-hidden":!0}),a?e.health.runDoctorRunning:e.refresh]})}),n?(0,Y.jsx)(`p`,{className:`rounded-xl border border-red-300/40 bg-red-50 px-4 py-3 text-sm text-red-700 dark:border-red-900/40 dark:bg-red-950/30 dark:text-red-300`,children:e.loadError}):null,!t||!r?(0,Y.jsx)(M,{sections:2}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Q,{tier:r.healthTier,issueCount:r.issues.length,ready:t,onRunDoctor:()=>void p(),doctorRunning:a,doctorRunState:u}),(0,Y.jsxs)(P,{id:`next-steps`,children:[(0,Y.jsx)(N,{icon:r.issues.length?O:k,title:e.nextStepsTitle,subtitle:r.issues.length?e.nextStepsIssuesSubtitle:e.nextStepsReadySubtitle}),r.issues.length?(0,Y.jsx)(`div`,{className:`mt-4 flex flex-col gap-2`,children:r.issues.slice(0,8).map(t=>(0,Y.jsx)($,{issue:t,fixLabel:e.fixIssue},`${t.source}:${t.id}`))}):(0,Y.jsx)(`div`,{className:`mt-4 rounded-lg bg-surface-panel/80 shadow-surface`,children:r.readiness.map(t=>(0,Y.jsx)(_e,{item:t,labels:e.readinessLabels},t.id))})]}),(0,Y.jsxs)(P,{children:[(0,Y.jsx)(N,{icon:g,title:e.diagnosticsTitle,subtitle:e.diagnosticsSubtitle}),f.length?(0,Y.jsx)(`div`,{className:`mt-4 grid gap-2 md:grid-cols-2`,children:f.map(t=>(0,Y.jsx)(ve,{signal:t,fixLabel:e.fixIssue},t.id))}):(0,Y.jsx)(`p`,{className:`mt-4 rounded-lg bg-surface-panel/80 p-3 text-sm text-fg-muted shadow-surface`,children:r.diagnosticSignals.length?e.diagnosticsAllClear:e.diagnosticsEmpty})]})]})]})}export{ye as SetupStatusPanel};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{f as i}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as a}from"./check-DUBLcKHA.js";import{n as o,r as s}from"./popover-select-BzdnTy3h.js";import{t as c}from"./copy-Dv6d4Dvw.js";import{t as l}from"./loader-circle-CifKLtgG.js";import{t as u}from"./plus-Q2yW6OE7.js";import{t as d}from"./x-B_N4OPjy.js";import{t as f}from"./cn-JdwAhgNB.js";import{t as p}from"./button-CSEbl4zT.js";import{t as m}from"./copy-to-clipboard-HOJ79TWv.js";import{t as h}from"./messages-ctG2e-ix.js";import{l as g,n as _,r as v,s as y}from"./locale-store-C5MK9WcP.js";import{a as b,n as x,o as S,r as ee,s as C,t as w}from"./dist-BPoKqzeH.js";import{i as te}from"./vendor-swr-BIWyz7Rc.js";import{n as T,r as E}from"./gateway-config-swr-BIxuwPQi.js";import{$o as D,Ai as O,Ci as k,Cn as A,Di as j,Ei as M,Fl as N,Ki as P,Oa as F,Oi as I,Si as L,Ti as ne,Ws as re,Zc as ie,_i as R,bi as ae,gn as oe,hi as se,hs as z,ki as ce,rl as B,vl as V,wi as H}from"./index-_cuTcWjB.js";import{n as U,r as W,t as G}from"./settings-page-layout-BRQNel6r.js";import{t as K}from"./settings-loading-skeleton-CYDV2JtY.js";import{t as q}from"./settings-form-section-B9dnKr3M.js";import{t as le}from"./page-tabs-CBuCKeyy.js";var J=e(t(),1),ue=n(),Y={enabled:!0,defaultTtlHours:24,maxTtlDays:30,maxActiveShares:500,maxFileSizeMb:500,directoryMaxFolderSizeMb:2048,directoryMaxFileCount:1e4,inlinePreviewMimes:[`image/png`,`image/jpeg`,`image/gif`,`image/webp`,`image/svg+xml`,`application/pdf`,`text/html`,`text/markdown`,`text/plain`,`application/json`],siteEnabled:!0,siteDefaultTtlHours:24,siteMaxTtlDays:30,maxActiveSites:50,siteMaxRootDirSizeMb:1024,siteMaxFileCount:2e4};function de(){return structuredClone(Y)}var fe=36e5,X=864e5,Z=1048576;function pe(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function me(e,t=32){return Array.isArray(e)?e.filter(e=>typeof e==`string`&&e.trim().length>0).map(e=>e.trim()).slice(0,t):[]}function he(e){let t=pe(e)?e:{},n=pe(t.gateway)?t.gateway:{},r=pe(n.share)?n.share:{},i=pe(r.directory)?r.directory:{},a=pe(n.siteShare)?n.siteShare:{},o=pe(a.static)?a.static:{},s=typeof r.defaultTtlMs==`number`&&Number.isFinite(r.defaultTtlMs)?Math.floor(r.defaultTtlMs):Y.defaultTtlHours*fe,c=typeof r.maxTtlMs==`number`&&Number.isFinite(r.maxTtlMs)?Math.floor(r.maxTtlMs):Y.maxTtlDays*X,l=typeof r.maxFileSize==`number`&&Number.isFinite(r.maxFileSize)?Math.floor(r.maxFileSize):Y.maxFileSizeMb*Z,u=typeof i.maxFolderSize==`number`&&Number.isFinite(i.maxFolderSize)?Math.floor(i.maxFolderSize):Y.directoryMaxFolderSizeMb*Z,d=typeof a.defaultTtlMs==`number`&&Number.isFinite(a.defaultTtlMs)?Math.floor(a.defaultTtlMs):Y.siteDefaultTtlHours*fe,f=typeof a.maxTtlMs==`number`&&Number.isFinite(a.maxTtlMs)?Math.floor(a.maxTtlMs):Y.siteMaxTtlDays*X,p=typeof o.maxRootDirSize==`number`&&Number.isFinite(o.maxRootDirSize)?Math.floor(o.maxRootDirSize):Y.siteMaxRootDirSizeMb*Z;return{enabled:r.enabled!==!1,defaultTtlHours:Math.max(1,Math.round(s/fe)),maxTtlDays:Math.max(1,Math.round(c/X)),maxActiveShares:typeof r.maxActiveShares==`number`&&Number.isFinite(r.maxActiveShares)?Math.max(1,Math.min(1e4,Math.floor(r.maxActiveShares))):Y.maxActiveShares,maxFileSizeMb:Math.max(1,Math.round(l/Z)),directoryMaxFolderSizeMb:Math.max(1,Math.round(u/Z)),directoryMaxFileCount:typeof i.maxFileCount==`number`&&Number.isFinite(i.maxFileCount)?Math.max(1,Math.min(1e5,Math.floor(i.maxFileCount))):Y.directoryMaxFileCount,inlinePreviewMimes:me(r.inlinePreviewMimes,32).length?me(r.inlinePreviewMimes,32):[...Y.inlinePreviewMimes],siteEnabled:a.enabled!==!1,siteDefaultTtlHours:Math.max(1,Math.round(d/fe)),siteMaxTtlDays:Math.max(1,Math.round(f/X)),maxActiveSites:typeof a.maxActiveSites==`number`&&Number.isFinite(a.maxActiveSites)?Math.max(1,Math.min(1e3,Math.floor(a.maxActiveSites))):Y.maxActiveSites,siteMaxRootDirSizeMb:Math.max(1,Math.round(p/Z)),siteMaxFileCount:typeof o.maxFileCount==`number`&&Number.isFinite(o.maxFileCount)?Math.max(1,Math.min(1e5,Math.floor(o.maxFileCount))):Y.siteMaxFileCount}}function ge(e){let t=e.defaultTtlHours*fe,n=e.maxTtlDays*X,r=e.siteDefaultTtlHours*fe,i=e.siteMaxTtlDays*X;return t<6e4||t>6048e5?`Default share TTL must be between 1 minute and 7 days.`:n<6e4||n>2592e6?`Maximum share TTL must be between 1 minute and 30 days.`:t>n?`Default TTL cannot exceed maximum TTL.`:e.maxActiveShares<1||e.maxActiveShares>1e4?`Maximum active shares must be between 1 and 10,000.`:e.maxActiveSites<1||e.maxActiveSites>1e3?`Maximum active site shares must be between 1 and 1,000.`:e.maxFileSizeMb<1||e.maxFileSizeMb>10240?`Maximum file size must be between 1 MB and 10 GB.`:e.directoryMaxFolderSizeMb<1||e.directoryMaxFolderSizeMb>10240?`Maximum folder size must be between 1 MB and 10 GB.`:e.directoryMaxFileCount<1||e.directoryMaxFileCount>1e5?`Maximum directory file count must be between 1 and 100,000.`:r<6e4||r>6048e5?`Default site share TTL must be between 1 minute and 7 days.`:i<6e4||i>2592e6?`Maximum site share TTL must be between 1 minute and 30 days.`:r>i?`Default site TTL cannot exceed maximum site TTL.`:e.siteMaxRootDirSizeMb<1||e.siteMaxRootDirSizeMb>10240?`Maximum static site size must be between 1 MB and 10 GB.`:e.siteMaxFileCount<1||e.siteMaxFileCount>1e5?`Maximum static site file count must be between 1 and 100,000.`:null}async function _e(e){let t=ge(e);if(t)throw Error(t);await y(v(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{share:{enabled:e.enabled,defaultTtlMs:e.defaultTtlHours*fe,maxTtlMs:e.maxTtlDays*X,maxActiveShares:e.maxActiveShares,maxFileSize:e.maxFileSizeMb*Z,inlinePreviewMimes:e.inlinePreviewMimes,directory:{maxFolderSize:e.directoryMaxFolderSizeMb*Z,maxFileCount:e.directoryMaxFileCount}},siteShare:{enabled:e.siteEnabled,defaultTtlMs:e.siteDefaultTtlHours*fe,maxTtlMs:e.siteMaxTtlDays*X,maxActiveSites:e.maxActiveSites,static:{maxRootDirSize:e.siteMaxRootDirSizeMb*Z,maxFileCount:e.siteMaxFileCount}}}})}),T()}var Q=r();function ve(){return f(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,D,`dark:border-edge`)}function ye({hasToken:e}){let t=h(_(e=>e.language)).sharesSettings,{data:n,isLoading:r}=E(e),i=(0,J.useMemo)(()=>n?.payload?.config===void 0?null:structuredClone(he(n.payload.config)),[n]),a=(0,J.useRef)(!1),[o,s]=(0,J.useState)(null),[c,l]=(0,J.useState)(!1),[u,d]=(0,J.useState)(null),[f,m]=(0,J.useState)(!1),g=o??i,v=i,y=(0,J.useMemo)(()=>!g||!v?!1:JSON.stringify(g)!==JSON.stringify(v),[g,v]),b=(0,J.useCallback)(e=>{a.current=!0,s(t=>{let n=t??v;return n?{...n,...e}:null})},[v]),x=(0,J.useCallback)(async()=>{if(!(!g||c)){l(!0),d(null),m(!1);try{await _e(g),a.current=!1,s(null),m(!0),window.setTimeout(()=>m(!1),2500)}catch(e){d(e instanceof Error?e.message:t.policySaveError)}finally{l(!1)}}},[g,c,t.policySaveError]),S=(0,J.useCallback)(()=>{a.current=!1,s(null),d(null),m(!1)},[]);return!e||!g?r?(0,Q.jsx)(q,{children:(0,Q.jsx)(K,{rows:2})}):null:(0,Q.jsxs)(q,{children:[(0,Q.jsxs)(`div`,{className:`mb-4 flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.policyTitle}),(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:t.policyHint})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[f?(0,Q.jsx)(`span`,{className:`text-sm text-fg-muted`,children:t.policySaved}):null,(0,Q.jsx)(p,{type:`button`,variant:`secondary`,disabled:c,onClick:()=>b(de()),children:t.policyUseRecommended}),(0,Q.jsx)(p,{type:`button`,variant:`secondary`,disabled:!y||c,onClick:S,children:t.policyDiscard}),(0,Q.jsx)(p,{type:`button`,variant:`primary`,disabled:!y||c,onClick:()=>void x(),children:c?t.policySaving:t.policySave})]})]}),y?(0,Q.jsx)(`p`,{className:`mb-3 text-xs text-amber-800 dark:text-amber-200`,children:t.policyUnsaved}):null,u?(0,Q.jsx)(`p`,{className:`mb-3 text-sm text-red-600 dark:text-red-400`,children:u}):null,(0,Q.jsx)(`p`,{className:`mb-4 text-xs text-fg-subtle`,children:t.policyRestartHint}),(0,Q.jsx)(be,{t,form:g,onChange:b})]})}function be(e){let t=(0,ue.c)(150),{t:n,form:r,onChange:i}=e,a;t[0]===n.policyFileSection?a=t[1]:(a=(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.policyFileSection}),t[0]=n.policyFileSection,t[1]=a);let o;t[2]===n.policyFileSectionHint?o=t[3]:(o=(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:n.policyFileSectionHint}),t[2]=n.policyFileSectionHint,t[3]=o);let s;t[4]!==a||t[5]!==o?(s=(0,Q.jsxs)(`div`,{className:`mb-4`,children:[a,o]}),t[4]=a,t[5]=o,t[6]=s):s=t[6];let c;t[7]===i?c=t[8]:(c=e=>i({enabled:e.target.checked}),t[7]=i,t[8]=c);let l;t[9]!==r.enabled||t[10]!==c?(l=(0,Q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.enabled,onChange:c}),t[9]=r.enabled,t[10]=c,t[11]=l):l=t[11];let u;t[12]!==n.policyEnabled||t[13]!==l?(u=(0,Q.jsxs)(`label`,{className:`mb-4 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[l,n.policyEnabled]}),t[12]=n.policyEnabled,t[13]=l,t[14]=u):u=t[14];let d=!r.enabled,f;t[15]===i?f=t[16]:(f=e=>i({defaultTtlHours:e}),t[15]=i,t[16]=f);let p;t[17]!==r.defaultTtlHours||t[18]!==n.policyDefaultTtlHint||t[19]!==n.policyDefaultTtlHours||t[20]!==d||t[21]!==f?(p=(0,Q.jsx)($,{id:`share-default-ttl-hours`,label:n.policyDefaultTtlHours,hint:n.policyDefaultTtlHint,value:r.defaultTtlHours,min:1,max:168,disabled:d,onChange:f}),t[17]=r.defaultTtlHours,t[18]=n.policyDefaultTtlHint,t[19]=n.policyDefaultTtlHours,t[20]=d,t[21]=f,t[22]=p):p=t[22];let m=!r.enabled,h;t[23]===i?h=t[24]:(h=e=>i({maxTtlDays:e}),t[23]=i,t[24]=h);let g;t[25]!==r.maxTtlDays||t[26]!==n.policyMaxTtlDays||t[27]!==n.policyMaxTtlHint||t[28]!==m||t[29]!==h?(g=(0,Q.jsx)($,{id:`share-max-ttl-days`,label:n.policyMaxTtlDays,hint:n.policyMaxTtlHint,value:r.maxTtlDays,min:1,max:30,disabled:m,onChange:h}),t[25]=r.maxTtlDays,t[26]=n.policyMaxTtlDays,t[27]=n.policyMaxTtlHint,t[28]=m,t[29]=h,t[30]=g):g=t[30];let _=!r.enabled,v;t[31]===i?v=t[32]:(v=e=>i({maxActiveShares:e}),t[31]=i,t[32]=v);let y;t[33]!==r.maxActiveShares||t[34]!==n.policyMaxActiveShares||t[35]!==n.policyMaxActiveSharesHint||t[36]!==_||t[37]!==v?(y=(0,Q.jsx)($,{id:`share-max-active`,label:n.policyMaxActiveShares,hint:n.policyMaxActiveSharesHint,value:r.maxActiveShares,min:1,max:1e4,disabled:_,onChange:v}),t[33]=r.maxActiveShares,t[34]=n.policyMaxActiveShares,t[35]=n.policyMaxActiveSharesHint,t[36]=_,t[37]=v,t[38]=y):y=t[38];let b=!r.enabled,x;t[39]===i?x=t[40]:(x=e=>i({maxFileSizeMb:e}),t[39]=i,t[40]=x);let S;t[41]!==r.maxFileSizeMb||t[42]!==n.policyMaxFileSizeHint||t[43]!==n.policyMaxFileSizeMb||t[44]!==b||t[45]!==x?(S=(0,Q.jsx)($,{id:`share-max-file-mb`,label:n.policyMaxFileSizeMb,hint:n.policyMaxFileSizeHint,value:r.maxFileSizeMb,min:1,max:10240,disabled:b,onChange:x}),t[41]=r.maxFileSizeMb,t[42]=n.policyMaxFileSizeHint,t[43]=n.policyMaxFileSizeMb,t[44]=b,t[45]=x,t[46]=S):S=t[46];let ee=!r.enabled,C;t[47]===i?C=t[48]:(C=e=>i({directoryMaxFolderSizeMb:e}),t[47]=i,t[48]=C);let w;t[49]!==r.directoryMaxFolderSizeMb||t[50]!==n.policyDirectoryMaxFolderSizeHint||t[51]!==n.policyDirectoryMaxFolderSizeMb||t[52]!==ee||t[53]!==C?(w=(0,Q.jsx)($,{id:`share-directory-max-size-mb`,label:n.policyDirectoryMaxFolderSizeMb,hint:n.policyDirectoryMaxFolderSizeHint,value:r.directoryMaxFolderSizeMb,min:1,max:10240,disabled:ee,onChange:C}),t[49]=r.directoryMaxFolderSizeMb,t[50]=n.policyDirectoryMaxFolderSizeHint,t[51]=n.policyDirectoryMaxFolderSizeMb,t[52]=ee,t[53]=C,t[54]=w):w=t[54];let te=!r.enabled,T;t[55]===i?T=t[56]:(T=e=>i({directoryMaxFileCount:e}),t[55]=i,t[56]=T);let E;t[57]!==r.directoryMaxFileCount||t[58]!==n.policyDirectoryMaxFileCount||t[59]!==n.policyDirectoryMaxFileCountHint||t[60]!==te||t[61]!==T?(E=(0,Q.jsx)($,{id:`share-directory-max-files`,label:n.policyDirectoryMaxFileCount,hint:n.policyDirectoryMaxFileCountHint,value:r.directoryMaxFileCount,min:1,max:1e5,disabled:te,onChange:T}),t[57]=r.directoryMaxFileCount,t[58]=n.policyDirectoryMaxFileCount,t[59]=n.policyDirectoryMaxFileCountHint,t[60]=te,t[61]=T,t[62]=E):E=t[62];let D;t[63]!==g||t[64]!==y||t[65]!==S||t[66]!==w||t[67]!==E||t[68]!==p?(D=(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[p,g,y,S,w,E]}),t[63]=g,t[64]=y,t[65]=S,t[66]=w,t[67]=E,t[68]=p,t[69]=D):D=t[69];let O=!r.enabled,k;t[70]===i?k=t[71]:(k=e=>i({inlinePreviewMimes:e}),t[70]=i,t[71]=k);let A;t[72]!==r.inlinePreviewMimes||t[73]!==n||t[74]!==O||t[75]!==k?(A=(0,Q.jsx)(xe,{t:n,values:r.inlinePreviewMimes,disabled:O,onChange:k}),t[72]=r.inlinePreviewMimes,t[73]=n,t[74]=O,t[75]=k,t[76]=A):A=t[76];let j;t[77]!==D||t[78]!==A||t[79]!==s||t[80]!==u?(j=(0,Q.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-muted/25 p-4`,children:[s,u,D,A]}),t[77]=D,t[78]=A,t[79]=s,t[80]=u,t[81]=j):j=t[81];let M;t[82]===n.policySiteSection?M=t[83]:(M=(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.policySiteSection}),t[82]=n.policySiteSection,t[83]=M);let N;t[84]===n.policySiteSectionHint?N=t[85]:(N=(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:n.policySiteSectionHint}),t[84]=n.policySiteSectionHint,t[85]=N);let P;t[86]!==M||t[87]!==N?(P=(0,Q.jsxs)(`div`,{className:`mb-4`,children:[M,N]}),t[86]=M,t[87]=N,t[88]=P):P=t[88];let F;t[89]===i?F=t[90]:(F=e=>i({siteEnabled:e.target.checked}),t[89]=i,t[90]=F);let I;t[91]!==r.siteEnabled||t[92]!==F?(I=(0,Q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.siteEnabled,onChange:F}),t[91]=r.siteEnabled,t[92]=F,t[93]=I):I=t[93];let L;t[94]!==n.policySiteEnabled||t[95]!==I?(L=(0,Q.jsxs)(`label`,{className:`mb-4 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[I,n.policySiteEnabled]}),t[94]=n.policySiteEnabled,t[95]=I,t[96]=L):L=t[96];let ne=!r.siteEnabled,re;t[97]===i?re=t[98]:(re=e=>i({siteDefaultTtlHours:e}),t[97]=i,t[98]=re);let ie;t[99]!==r.siteDefaultTtlHours||t[100]!==n.policySiteDefaultTtlHint||t[101]!==n.policySiteDefaultTtlHours||t[102]!==ne||t[103]!==re?(ie=(0,Q.jsx)($,{id:`site-share-default-ttl-hours`,label:n.policySiteDefaultTtlHours,hint:n.policySiteDefaultTtlHint,value:r.siteDefaultTtlHours,min:1,max:168,disabled:ne,onChange:re}),t[99]=r.siteDefaultTtlHours,t[100]=n.policySiteDefaultTtlHint,t[101]=n.policySiteDefaultTtlHours,t[102]=ne,t[103]=re,t[104]=ie):ie=t[104];let R=!r.siteEnabled,ae;t[105]===i?ae=t[106]:(ae=e=>i({siteMaxTtlDays:e}),t[105]=i,t[106]=ae);let oe;t[107]!==r.siteMaxTtlDays||t[108]!==n.policySiteMaxTtlDays||t[109]!==n.policySiteMaxTtlHint||t[110]!==R||t[111]!==ae?(oe=(0,Q.jsx)($,{id:`site-share-max-ttl-days`,label:n.policySiteMaxTtlDays,hint:n.policySiteMaxTtlHint,value:r.siteMaxTtlDays,min:1,max:30,disabled:R,onChange:ae}),t[107]=r.siteMaxTtlDays,t[108]=n.policySiteMaxTtlDays,t[109]=n.policySiteMaxTtlHint,t[110]=R,t[111]=ae,t[112]=oe):oe=t[112];let se=!r.siteEnabled,z;t[113]===i?z=t[114]:(z=e=>i({maxActiveSites:e}),t[113]=i,t[114]=z);let ce;t[115]!==r.maxActiveSites||t[116]!==n.policyMaxActiveSites||t[117]!==n.policyMaxActiveSitesHint||t[118]!==se||t[119]!==z?(ce=(0,Q.jsx)($,{id:`site-share-max-active`,label:n.policyMaxActiveSites,hint:n.policyMaxActiveSitesHint,value:r.maxActiveSites,min:1,max:1e3,disabled:se,onChange:z}),t[115]=r.maxActiveSites,t[116]=n.policyMaxActiveSites,t[117]=n.policyMaxActiveSitesHint,t[118]=se,t[119]=z,t[120]=ce):ce=t[120];let B=!r.siteEnabled,V;t[121]===i?V=t[122]:(V=e=>i({siteMaxRootDirSizeMb:e}),t[121]=i,t[122]=V);let H;t[123]!==r.siteMaxRootDirSizeMb||t[124]!==n.policySiteMaxRootDirSizeHint||t[125]!==n.policySiteMaxRootDirSizeMb||t[126]!==B||t[127]!==V?(H=(0,Q.jsx)($,{id:`site-share-max-root-size-mb`,label:n.policySiteMaxRootDirSizeMb,hint:n.policySiteMaxRootDirSizeHint,value:r.siteMaxRootDirSizeMb,min:1,max:10240,disabled:B,onChange:V}),t[123]=r.siteMaxRootDirSizeMb,t[124]=n.policySiteMaxRootDirSizeHint,t[125]=n.policySiteMaxRootDirSizeMb,t[126]=B,t[127]=V,t[128]=H):H=t[128];let U=!r.siteEnabled,W;t[129]===i?W=t[130]:(W=e=>i({siteMaxFileCount:e}),t[129]=i,t[130]=W);let G;t[131]!==r.siteMaxFileCount||t[132]!==n.policySiteMaxFileCount||t[133]!==n.policySiteMaxFileCountHint||t[134]!==U||t[135]!==W?(G=(0,Q.jsx)($,{id:`site-share-max-files`,label:n.policySiteMaxFileCount,hint:n.policySiteMaxFileCountHint,value:r.siteMaxFileCount,min:1,max:1e5,disabled:U,onChange:W}),t[131]=r.siteMaxFileCount,t[132]=n.policySiteMaxFileCount,t[133]=n.policySiteMaxFileCountHint,t[134]=U,t[135]=W,t[136]=G):G=t[136];let K;t[137]!==ie||t[138]!==oe||t[139]!==ce||t[140]!==H||t[141]!==G?(K=(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[ie,oe,ce,H,G]}),t[137]=ie,t[138]=oe,t[139]=ce,t[140]=H,t[141]=G,t[142]=K):K=t[142];let q;t[143]!==P||t[144]!==L||t[145]!==K?(q=(0,Q.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-muted/25 p-4`,children:[P,L,K]}),t[143]=P,t[144]=L,t[145]=K,t[146]=q):q=t[146];let le;return t[147]!==j||t[148]!==q?(le=(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[j,q]}),t[147]=j,t[148]=q,t[149]=le):le=t[149],le}function $(e){let t=(0,ue.c)(21),{id:n,label:r,hint:i,value:a,min:o,max:s,disabled:c,onChange:l}=e,u;t[0]!==n||t[1]!==r?(u=(0,Q.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:n,children:r}),t[0]=n,t[1]=r,t[2]=u):u=t[2];let d;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(d=f(ve(),`max-w-xs font-mono text-xs`),t[3]=d):d=t[3];let p;t[4]!==s||t[5]!==o||t[6]!==l?(p=e=>{let t=Number(e.target.value);Number.isFinite(t)&&l(Math.max(o,Math.min(s,Math.floor(t))))},t[4]=s,t[5]=o,t[6]=l,t[7]=p):p=t[7];let m;t[8]!==c||t[9]!==n||t[10]!==s||t[11]!==o||t[12]!==p||t[13]!==a?(m=(0,Q.jsx)(`input`,{id:n,type:`number`,min:o,max:s,disabled:c,className:d,value:a,onChange:p}),t[8]=c,t[9]=n,t[10]=s,t[11]=o,t[12]=p,t[13]=a,t[14]=m):m=t[14];let h;t[15]===i?h=t[16]:(h=(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:i}),t[15]=i,t[16]=h);let g;return t[17]!==u||t[18]!==m||t[19]!==h?(g=(0,Q.jsxs)(`div`,{children:[u,m,h]}),t[17]=u,t[18]=m,t[19]=h,t[20]=g):g=t[20],g}function xe(e){let t=(0,ue.c)(25),{t:n,values:r,disabled:i,onChange:a}=e,o;t[0]!==a||t[1]!==r?(o=e=>{let t=e.trim();!t||r.includes(t)||r.length>=32||a([...r,t])},t[0]=a,t[1]=r,t[2]=o):o=t[2];let s=o,c;t[3]===n.policyInlinePreviewMimes?c=t[4]:(c=(0,Q.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.policyInlinePreviewMimes}),t[3]=n.policyInlinePreviewMimes,t[4]=c);let l;t[5]===n.policyInlinePreviewMimesHint?l=t[6]:(l=(0,Q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.policyInlinePreviewMimesHint}),t[5]=n.policyInlinePreviewMimesHint,t[6]=l);let u;t[7]!==i||t[8]!==a||t[9]!==r?(u=r.map(e=>(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-edge bg-surface-panel px-2 py-0.5 font-mono text-xs text-fg`,children:[e,i?null:(0,Q.jsx)(`button`,{type:`button`,className:`text-fg-muted hover:text-fg`,"aria-label":`Remove ${e}`,onClick:()=>a(r.filter(t=>t!==e)),children:`×`})]},e)),t[7]=i,t[8]=a,t[9]=r,t[10]=u):u=t[10];let d;t[11]===u?d=t[12]:(d=(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:u}),t[11]=u,t[12]=d);let p;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(p=f(ve(),`font-mono text-xs`),t[13]=p):p=t[13];let m=i||r.length>=32,h;t[14]===s?h=t[15]:(h=e=>{e.key===`Enter`&&(e.preventDefault(),s(e.target.value),e.target.value=``)},t[14]=s,t[15]=h);let g;t[16]!==n.policyMimePlaceholder||t[17]!==m||t[18]!==h?(g=(0,Q.jsx)(`input`,{className:p,placeholder:n.policyMimePlaceholder,disabled:m,onKeyDown:h}),t[16]=n.policyMimePlaceholder,t[17]=m,t[18]=h,t[19]=g):g=t[19];let _;return t[20]!==c||t[21]!==l||t[22]!==d||t[23]!==g?(_=(0,Q.jsxs)(`div`,{className:`space-y-2 border-t border-edge pt-4`,children:[c,l,d,g]}),t[20]=c,t[21]=l,t[22]=d,t[23]=g,t[24]=_):_=t[24],_}function Se(e){let t=(0,ue.c)(70),{open:n,onOpenChange:r,onConfirm:i,initialPath:a,selectKind:c,sessionKey:u,agentId:m}=e,v=c===void 0?`any`:c,y=h(_(Te)),T=y.workspace,E=y.sharesSettings,D=ae(we),{data:O}=te(g(Ce)?`picker-agents-list`:null,A),k;bb0:{let e;t[0]===m?e=t[1]:(e=m?.trim(),t[0]=m,t[1]=e);let n=e;if(n){k=n;break bb0}let r;t[2]===D?r=t[3]:(r=D.trim(),t[2]=D,t[3]=r);let i=r;if(i){k=i;break bb0}if(O?.defaultId){k=O.defaultId;break bb0}if(O?.agents?.[0]?.id){k=O.agents[0].id;break bb0}k=``}let j=k,[M,N]=(0,J.useState)(j),F,I;t[4]===j?(F=t[5],I=t[6]):(F=()=>{N(j)},I=[j],t[4]=j,t[5]=F,t[6]=I),(0,J.useEffect)(F,I);let{tree:ne,loading:R,error:se,loadRoot:z,loadChildren:ce,reset:B}=L(M,u??null),V;t[7]===a?V=t[8]:(V=a?{path:a,isDirectory:!1}:null,t[7]=a,t[8]=V);let[H,U]=(0,J.useState)(V),W;t[9]!==a||t[10]!==z||t[11]!==n||t[12]!==B||t[13]!==U?(W=()=>{if(!n){B(),U(a?{path:a,isDirectory:!1}:null);return}z()},t[9]=a,t[10]=z,t[11]=n,t[12]=B,t[13]=U,t[14]=W):W=t[14];let G;t[15]!==a||t[16]!==z||t[17]!==n||t[18]!==M||t[19]!==B||t[20]!==u?(G=[n,M,u,z,B,a],t[15]=a,t[16]=z,t[17]=n,t[18]=M,t[19]=B,t[20]=u,t[21]=G):G=t[21],(0,J.useEffect)(W,G);let K;t[22]===ce?K=t[23]:(K=e=>{ce(e)},t[22]=ce,t[23]=K);let q=K,le=H!==null&&(v===`any`||v===`file`&&!H.isDirectory||v===`directory`&&H.isDirectory),Y;bb1:{if(!H){Y=E.pickerHintNone;break bb1}if(v===`file`&&H.isDirectory){Y=E.pickerHintNeedsFile;break bb1}if(v===`directory`&&!H.isDirectory){Y=E.pickerHintNeedsDirectory;break bb1}Y=`${H.isDirectory?`📁`:`📄`} ${H.path}`}let de=Y,fe=O?.agents??[],X;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(X=(0,Q.jsx)(b,{className:`fixed inset-0 z-[70] bg-scrim backdrop-blur-[2px]`}),t[24]=X):X=t[24];let Z;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(Z=f(`fixed left-1/2 top-1/2 z-[71] w-[min(34rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2`,`flex h-[min(28rem,calc(100vh-3rem))] flex-col overflow-hidden rounded-lg border border-edge bg-surface-panel shadow-popover outline-none`),t[25]=Z):Z=t[25];let pe;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(pe=(0,Q.jsx)(ie,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),t[26]=pe):pe=t[26];let me=y.cron.refresh,he=y.cron.refresh,ge;t[27]===z?ge=t[28]:(ge=()=>void z(),t[27]=z,t[28]=ge);let _e=R&&`animate-spin`,ve;t[29]===_e?ve=t[30]:(ve=f(`size-4`,_e),t[29]=_e,t[30]=ve);let ye;t[31]===ve?ye=t[32]:(ye=(0,Q.jsx)(re,{className:ve,"aria-hidden":!0}),t[31]=ve,t[32]=ye);let be;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(be=(0,Q.jsx)(d,{className:`size-4`}),t[33]=be):be=t[33];let $;t[34]!==se||t[35]!==T.loadError?($=se?(0,Q.jsxs)(`p`,{className:`shrink-0 px-4 py-2 text-xs text-red-600 dark:text-red-400`,children:[T.loadError,`: `,se]}):null,t[34]=se,t[35]=T.loadError,t[36]=$):$=t[36];let xe;t[37]!==q||t[38]!==R||t[39]!==H?.path||t[40]!==U||t[41]!==T.emptyDir||t[42]!==T.title||t[43]!==ne?(xe=R&&ne.length===0?(0,Q.jsxs)(`p`,{className:`flex shrink-0 items-center gap-2 px-4 py-3 text-sm text-fg-muted`,children:[(0,Q.jsx)(l,{className:`size-4 animate-spin`}),T.title,`…`]}):(0,Q.jsx)(P,{tree:ne,selectedPath:H?.path??null,onSelectFile:e=>U({path:e,isDirectory:!1}),onSelectEntry:(e,t)=>U({path:e,isDirectory:t}),onExpandDir:q,onAction:void 0,emptyHint:T.emptyDir}),t[37]=q,t[38]=R,t[39]=H?.path,t[40]=U,t[41]=T.emptyDir,t[42]=T.title,t[43]=ne,t[44]=xe):xe=t[44];let Se;t[45]!==$||t[46]!==xe?(Se=(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:[$,xe]}),t[45]=$,t[46]=xe,t[47]=Se):Se=t[47];let Ee;t[48]===de?Ee=t[49]:(Ee=(0,Q.jsx)(`p`,{className:`min-w-0 flex-1 truncate text-xs text-fg-muted`,children:de}),t[48]=de,t[49]=Ee);let De;t[50]===r?De=t[51]:(De=()=>r(!1),t[50]=r,t[51]=De);let Oe;t[52]!==E.cancel||t[53]!==De?(Oe=(0,Q.jsx)(p,{type:`button`,variant:`ghost`,onClick:De,children:E.cancel}),t[52]=E.cancel,t[53]=De,t[54]=Oe):Oe=t[54];let ke=!le,Ae;t[55]!==i||t[56]!==r||t[57]!==M||t[58]!==H?(Ae=()=>{H&&(i({...H,agentId:M}),r(!1))},t[55]=i,t[56]=r,t[57]=M,t[58]=H,t[59]=Ae):Ae=t[59];let je;t[60]!==E.pickerConfirm||t[61]!==ke||t[62]!==Ae?(je=(0,Q.jsx)(p,{type:`button`,disabled:ke,onClick:Ae,children:E.pickerConfirm}),t[60]=E.pickerConfirm,t[61]=ke,t[62]=Ae,t[63]=je):je=t[63];let Me;t[64]!==Oe||t[65]!==je?(Me=(0,Q.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[Oe,je]}),t[64]=Oe,t[65]=je,t[66]=Me):Me=t[66];let Ne;return t[67]!==Ee||t[68]!==Me?(Ne=(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-3 border-t border-edge px-4 py-3`,children:[Ee,Me]}),t[67]=Ee,t[68]=Me,t[69]=Ne):Ne=t[69],(0,Q.jsx)(w,{open:n,onOpenChange:r,children:(0,Q.jsxs)(S,{children:[X,(0,Q.jsxs)(ee,{className:Z,children:[(0,Q.jsxs)(`div`,{className:`flex h-11 shrink-0 items-center gap-2 border-b border-edge px-4`,children:[pe,(0,Q.jsx)(C,{className:`min-w-0 flex-1 truncate text-base font-semibold text-fg`,children:E.pickerTitle}),(0,Q.jsx)(`button`,{type:`button`,className:`inline-flex size-8 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg disabled:opacity-50`,title:me,"aria-label":he,disabled:R,onClick:ge,children:ye}),(0,Q.jsx)(x,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,className:`inline-flex size-8 shrink-0 items-center justify-center rounded-md text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":T.close,children:be})})]}),fe.length>0?(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-edge px-4 py-2`,children:[(0,Q.jsx)(`label`,{className:`text-xs text-fg-muted`,htmlFor:`picker-agent-select`,children:E.pickerAgentLabel}),(0,Q.jsx)(o,{id:`picker-agent-select`,className:`min-w-0 flex-1 rounded-md border border-edge bg-surface-panel px-2 py-1 text-sm text-fg focus:outline-none focus:ring-2 focus:ring-accent`,value:M,onChange:e=>{N(e.target.value),U(null)},children:fe.map(e=>(0,Q.jsxs)(s,{value:e.id,children:[oe(e,y.agentsSettings),e.id===O?.defaultId?` ★`:``]},e.id))})]}):null,Se,Ne]})]})})}function Ce(e){return e.token}function we(e){return e.agentId}function Te(e){return e.language}var Ee=[`shares`,`policy`];function De(e){let t=(e??``).trim();return Ee.includes(t)?t:`shares`}function Oe(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:`${(e/(1024*1024*1024)).toFixed(1)} GB`}function ke(e,t){let n=new Date(e).getTime()-Date.now(),r=Math.abs(n),i=n<0;if(r<6e4)return t===`zh`?`刚刚`:`just now`;let a=Math.floor(r/6e4);if(a<60){let e=t===`zh`?`${a} 分钟`:`${a}m`;return i?t===`zh`?`${e}前`:`${e} ago`:e}let o=Math.floor(a/60);if(o<24){let e=t===`zh`?`${o} 小时`:`${o}h`;return i?t===`zh`?`${e}前`:`${e} ago`:e}let s=Math.floor(o/24),c=t===`zh`?`${s} 天`:`${s}d`;return i?t===`zh`?`${c}前`:`${c} ago`:c}var Ae=[{value:36e5,key:`1h`},{value:216e5,key:`6h`},{value:864e5,key:`24h`},{value:2592e5,key:`3d`},{value:6048e5,key:`7d`},{value:2592e6,key:`30d`}];function je(){let e=(0,ue.c)(24),t=_(Ne),n=h(t).sharesSettings,r=!!g(Me),[a,o]=i(),s;e[0]===a?s=e[1]:(s=De(a.get(`tab`)),e[0]=a,e[1]=s);let c=s,l;e[2]===o?l=e[3]:(l=e=>{o(t=>{let n=new URLSearchParams(t);return e===`shares`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},e[2]=o,e[3]=l);let u=l;if(!r)return(0,Q.jsx)(W,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.needToken})});let d={shares:n.tabShares,policy:n.tabPolicy},f=Ee.map(e=>({id:e,label:d[e]})),p;e[4]!==n.subtitle||e[5]!==n.title?(p=(0,Q.jsx)(U,{title:n.title,subtitle:n.subtitle}),e[4]=n.subtitle,e[5]=n.title,e[6]=p):p=e[6];let m;e[7]!==c||e[8]!==u||e[9]!==n.tabsAria||e[10]!==f?(m=(0,Q.jsx)(le,{items:f,activeTab:c,onChange:u,ariaLabel:n.tabsAria,tabIdPrefix:`shares-tab`,panelIdPrefix:`shares-panel`}),e[7]=c,e[8]=u,e[9]=n.tabsAria,e[10]=f,e[11]=m):m=e[11];let v;e[12]!==c||e[13]!==r||e[14]!==t||e[15]!==n?(v=c===`shares`?(0,Q.jsx)(Pe,{t:n,language:t}):(0,Q.jsx)(ye,{hasToken:r}),e[12]=c,e[13]=r,e[14]=t,e[15]=n,e[16]=v):v=e[16];let y;e[17]!==c||e[18]!==v?(y=(0,Q.jsx)(G,{id:c,activeTab:c,tabIdPrefix:`shares-tab`,panelIdPrefix:`shares-panel`,showHeading:!1,children:v}),e[17]=c,e[18]=v,e[19]=y):y=e[19];let b;return e[20]!==p||e[21]!==m||e[22]!==y?(b=(0,Q.jsxs)(W,{children:[p,m,y]}),e[20]=p,e[21]=m,e[22]=y,e[23]=b):b=e[23],b}function Me(e){return e.token}function Ne(e){return e.language}function Pe(e){let t=(0,ue.c)(60),{t:n,language:r}=e,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i={refreshInterval:3e4},t[0]=i):i=t[0];let{data:a,error:o,isLoading:s,mutate:c}=te(`shares-list`,M,i),l;t[1]===a?.payload?.shares?l=t[2]:(l=a?.payload?.shares??[],t[1]=a?.payload?.shares,t[2]=l);let u=l,[d,m]=(0,J.useState)(!1),h;bb0:{if(d){h=u;break bb0}let e;t[3]===u?e=t[4]:(e=u.filter(ze),t[3]=u,t[4]=e),h=e}let g=h,_;t[5]===u?_=t[6]:(_=u.filter(Re),t[5]=u,t[6]=_);let v=_.length,y;t[7]===u?y=t[8]:(y=u.filter(Le),t[7]=u,t[8]=y);let b=y.length,x;t[9]===c?x=t[10]:(x=()=>void c(),t[9]=c,t[10]=x);let S;t[11]!==n||t[12]!==x?(S=(0,Q.jsx)(Ve,{t:n,onCreated:x}),t[11]=n,t[12]=x,t[13]=S):S=t[13];let ee=d?n.allSharesTitle:n.listTitle,C;t[14]===v?C=t[15]:(C=v>0&&(0,Q.jsxs)(`span`,{className:`ml-2 text-xs font-normal text-fg-muted`,children:[`(`,v,`)`]}),t[14]=v,t[15]=C);let w;t[16]!==ee||t[17]!==C?(w=(0,Q.jsxs)(`h2`,{className:`text-sm font-semibold text-fg`,children:[ee,C]}),t[16]=ee,t[17]=C,t[18]=w):w=t[18];let T;t[19]===c?T=t[20]:(T=()=>void c(),t[19]=c,t[20]=T);let E=s&&`animate-spin`,D;t[21]===E?D=t[22]:(D=f(`size-3.5`,E),t[21]=E,t[22]=D);let O;t[23]===D?O=t[24]:(O=(0,Q.jsx)(re,{className:D}),t[23]=D,t[24]=O);let k;t[25]!==s||t[26]!==T||t[27]!==O?(k=(0,Q.jsx)(p,{type:`button`,variant:`ghost`,className:`px-2 py-1`,onClick:T,disabled:s,children:O}),t[25]=s,t[26]=T,t[27]=O,t[28]=k):k=t[28];let A;t[29]!==b||t[30]!==d||t[31]!==n.hideExpired||t[32]!==n.showExpired?(A=b>0&&(0,Q.jsx)(`button`,{type:`button`,className:`text-xs text-accent hover:underline`,onClick:()=>m(Ie),children:d?n.hideExpired:n.showExpired}),t[29]=b,t[30]=d,t[31]=n.hideExpired,t[32]=n.showExpired,t[33]=A):A=t[33];let j;t[34]!==k||t[35]!==A?(j=(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[k,A]}),t[34]=k,t[35]=A,t[36]=j):j=t[36];let N;t[37]!==w||t[38]!==j?(N=(0,Q.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[w,j]}),t[37]=w,t[38]=j,t[39]=N):N=t[39];let P;t[40]!==a||t[41]!==o||t[42]!==g||t[43]!==s||t[44]!==r||t[45]!==c||t[46]!==n?(P=s&&!a?(0,Q.jsx)(`div`,{className:`grid gap-2`,"aria-busy":`true`,children:Array.from({length:4}).map(Fe)}):o?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-red-600 dark:text-red-400`,children:[(0,Q.jsx)(`span`,{children:n.error}),(0,Q.jsx)(p,{type:`button`,variant:`ghost`,className:`px-2 py-1 text-xs`,onClick:()=>void c(),children:n.retry})]}):g.length===0?(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.emptyState}):(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:g.map(e=>(0,Q.jsx)(Ue,{share:e,t:n,language:r,onRevoked:()=>void c(),onExtended:()=>void c()},e.id))}),t[40]=a,t[41]=o,t[42]=g,t[43]=s,t[44]=r,t[45]=c,t[46]=n,t[47]=P):P=t[47];let F;t[48]!==b||t[49]!==c||t[50]!==d||t[51]!==n?(F=b>0&&d&&(0,Q.jsx)(We,{t:n,onCleaned:()=>void c()}),t[48]=b,t[49]=c,t[50]=d,t[51]=n,t[52]=F):F=t[52];let I;t[53]!==N||t[54]!==P||t[55]!==F?(I=(0,Q.jsxs)(q,{children:[N,P,F]}),t[53]=N,t[54]=P,t[55]=F,t[56]=I):I=t[56];let L;return t[57]!==I||t[58]!==S?(L=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[S,I]}),t[57]=I,t[58]=S,t[59]=L):L=t[59],L}function Fe(e,t){return(0,Q.jsx)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(F,{className:`h-4 w-2/3`}),(0,Q.jsx)(F,{className:`mt-2 h-3 w-1/2`})]}),(0,Q.jsx)(F,{className:`h-7 w-20 rounded-md`})]})},t)}function Ie(e){return!e}function Le(e){return e.expired||e.revoked}function Re(e){return!e.expired&&!e.revoked}function ze(e){return!e.expired&&!e.revoked}var Be={expanded:!0,path:``,isDirectory:!1,agentId:``,ttlMs:864e5,maxViews:null,description:``,directoryMode:`browse`,creating:!1,result:null,errorMsg:null,resultDialogOpen:!1,pickerOpen:!1};function Ve({t:e,onCreated:t}){let[n,r]=(0,J.useReducer)(se,Be),{expanded:i,path:a,isDirectory:c,agentId:d,ttlMs:m,maxViews:h,description:g,directoryMode:_,creating:v,result:y,errorMsg:b,resultDialogOpen:x,pickerOpen:S}=n,ee=(0,J.useCallback)(async()=>{if(a.trim()){r({type:`patch`,patch:{creating:!0,errorMsg:null,result:null}});try{r({type:`patch`,patch:{result:(await H({path:a.trim(),ttlMs:m,maxViews:h,description:g.trim()||void 0,...d?{agentId:d}:{},...c?{kind:`directory`,directoryMode:_}:{}})).payload,resultDialogOpen:!0}}),t()}catch(e){r({type:`patch`,patch:{errorMsg:e instanceof Error?e.message:String(e)}})}finally{r({type:`patch`,patch:{creating:!1}})}}},[a,c,d,m,h,g,_,t]),C=(0,J.useCallback)(()=>{r({type:`patch`,patch:{path:``,isDirectory:!1,agentId:``,description:``,maxViews:null,ttlMs:864e5,directoryMode:`browse`,result:null,errorMsg:null}})},[]);return i?(0,Q.jsxs)(q,{children:[(0,Q.jsx)(`h2`,{className:`mb-1 text-sm font-semibold text-fg`,children:e.createTitle}),(0,Q.jsx)(`p`,{className:`mb-4 text-xs text-fg-muted`,children:e.createHint}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.pathLabel}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`div`,{className:f(`flex min-w-0 flex-1 items-center gap-2 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm`,a?`text-fg`:`text-fg-subtle`),children:a?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{"aria-hidden":!0,children:c?`📁`:`📄`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,title:a,children:a})]}):(0,Q.jsx)(`span`,{className:`truncate`,children:e.pathPlaceholder})}),(0,Q.jsxs)(p,{type:`button`,variant:`ghost`,onClick:()=>r({type:`patch`,patch:{pickerOpen:!0}}),children:[(0,Q.jsx)(B,{className:`size-4`}),a?e.pathBrowseChange:e.pathBrowse]})]})]}),c?(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.directoryModeLabel}),(0,Q.jsxs)(o,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg focus:outline-none focus:ring-2 focus:ring-accent`,value:_,onChange:e=>r({type:`patch`,patch:{directoryMode:e.target.value===`zip-only`?`zip-only`:`browse`}}),children:[(0,Q.jsx)(s,{value:`browse`,children:e.directoryModeBrowse}),(0,Q.jsx)(s,{value:`zip-only`,children:e.directoryModeZipOnly})]})]}):null,(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-3`,children:[(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.ttlLabel}),(0,Q.jsx)(o,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg focus:outline-none focus:ring-2 focus:ring-accent`,value:m,onChange:e=>r({type:`patch`,patch:{ttlMs:Number(e.target.value)}}),children:Ae.map(t=>(0,Q.jsx)(s,{value:t.value,children:e.ttlOptions[t.key]},t.key))})]}),(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.maxViewsLabel}),(0,Q.jsxs)(o,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg focus:outline-none focus:ring-2 focus:ring-accent`,value:h??`unlimited`,onChange:e=>r({type:`patch`,patch:{maxViews:e.target.value===`unlimited`?null:Number(e.target.value)}}),children:[(0,Q.jsx)(s,{value:`unlimited`,children:e.maxViewsUnlimited}),(0,Q.jsx)(s,{value:`1`,children:`1`}),(0,Q.jsx)(s,{value:`5`,children:`5`}),(0,Q.jsx)(s,{value:`10`,children:`10`}),(0,Q.jsx)(s,{value:`50`,children:`50`}),(0,Q.jsx)(s,{value:`100`,children:`100`})]})]})]}),(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-fg`,children:e.descriptionLabel}),(0,Q.jsx)(`input`,{type:`text`,className:`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:outline-none focus:ring-2 focus:ring-accent`,placeholder:e.descriptionPlaceholder,value:g,onChange:e=>r({type:`patch`,patch:{description:e.target.value}})})]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 pt-1`,children:[(0,Q.jsxs)(p,{type:`button`,disabled:v||!a.trim(),onClick:()=>void ee(),children:[v?(0,Q.jsx)(l,{className:`size-4 animate-spin`}):(0,Q.jsx)(u,{className:`size-4`}),v?e.creating:e.createButton]}),(0,Q.jsx)(p,{type:`button`,variant:`ghost`,onClick:()=>{C(),r({type:`patch`,patch:{expanded:!1}})},children:e.cancel})]}),b&&(0,Q.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:b})]}),(0,Q.jsx)(ce,{open:x,onOpenChange:e=>{r({type:`patch`,patch:{resultDialogOpen:e,...e?{}:{result:null}}})},result:y}),(0,Q.jsx)(Se,{open:S,onOpenChange:e=>r({type:`patch`,patch:{pickerOpen:e}}),initialPath:a||void 0,selectKind:`any`,onConfirm:e=>r({type:`patch`,patch:{path:e.path,isDirectory:e.isDirectory,agentId:e.agentId,directoryMode:`browse`}})})]}):(0,Q.jsxs)(p,{type:`button`,onClick:()=>r({type:`patch`,patch:{expanded:!0}}),className:`self-start`,children:[(0,Q.jsx)(u,{className:`size-4`}),e.createTitle]})}var He={revokeOpen:!1,revoking:!1,linksOpen:!1,urlCopied:!1,copyFailed:!1,extending:!1};function Ue({share:e,t,language:n,onRevoked:r,onExtended:i}){let[o,s]=(0,J.useReducer)(se,He),{revokeOpen:u,revoking:d,linksOpen:h,urlCopied:g,copyFailed:_,extending:v}=o,y=!e.expired&&!e.revoked,b=e.revoked?t.statusRevoked:e.expired?t.statusExpired:t.statusActive,x=e.revoked?`text-red-600 dark:text-red-400`:e.expired?`text-fg-subtle`:`text-emerald-600 dark:text-emerald-400`,S=(0,J.useCallback)(async()=>{s({type:`patch`,patch:{revokeOpen:!1,revoking:!0}});try{await j(e.id),r()}catch{}finally{s({type:`patch`,patch:{revoking:!1}})}},[e.id,r]),ee=(0,J.useCallback)(async()=>{if(s({type:`patch`,patch:{linksOpen:!0,copyFailed:!1}}),!await m(e.shareUrl)){s({type:`patch`,patch:{copyFailed:!0}}),window.setTimeout(()=>s({type:`patch`,patch:{copyFailed:!1}}),2500);return}s({type:`patch`,patch:{urlCopied:!0}}),window.setTimeout(()=>s({type:`patch`,patch:{urlCopied:!1}}),2e3)},[e.shareUrl]),C=(0,J.useCallback)(async()=>{s({type:`patch`,patch:{extending:!0}});try{await ne(e.id,864e5),i()}catch{}finally{s({type:`patch`,patch:{extending:!1}})}},[e.id,i]),w=`share-links-${e.id}`;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/80 px-3 py-2.5 shadow-surface`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsxs)(`button`,{type:`button`,className:f(`flex min-w-0 flex-1 items-start gap-3 rounded-md text-left`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),"aria-expanded":h,"aria-controls":w,onClick:()=>s({type:`patch`,patch:{linksOpen:!h}}),children:[(0,Q.jsx)(N,{className:f(`mt-0.5 size-4 shrink-0 text-fg-muted transition-transform`,h?`rotate-0`:`-rotate-90`),"aria-hidden":!0}),(0,Q.jsx)(B,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.fileName}),(0,Q.jsx)(`span`,{className:f(`text-xs font-medium`,x),children:b})]}),(0,Q.jsx)(`p`,{className:`truncate text-xs text-fg-subtle`,children:e.workspaceRelativePath}),(0,Q.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-muted`,children:[(0,Q.jsx)(`span`,{children:Oe(e.fileSize)}),(0,Q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(V,{className:`size-3`}),e.expired?n===`zh`?`已过期`:`expired`:ke(e.expiresAt,n)]}),(0,Q.jsxs)(`span`,{children:[t.views,`: `,e.downloadCount,e.maxViews!==null&&` ${t.viewsOf} ${e.maxViews}`]}),e.description&&(0,Q.jsx)(`span`,{className:`italic text-fg-subtle`,children:e.description})]})]})]}),(0,Q.jsx)(`div`,{className:`flex shrink-0 items-center gap-1`,children:y&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(p,{type:`button`,variant:`ghost`,className:`px-2 py-1`,title:t.copyUrl,onClick:()=>void ee(),children:g?(0,Q.jsx)(a,{className:`size-3.5 text-emerald-500`}):(0,Q.jsx)(c,{className:`size-3.5`})}),(0,Q.jsx)(p,{type:`button`,variant:`ghost`,className:`px-2 py-1`,onClick:()=>void C(),disabled:v,title:t.extend,children:v?(0,Q.jsx)(l,{className:`size-3.5 animate-spin`}):(0,Q.jsx)(V,{className:`size-3.5`})}),(0,Q.jsx)(p,{type:`button`,variant:`ghost`,className:`px-2 py-1 text-red-600 hover:text-red-700 dark:text-red-400`,onClick:()=>s({type:`patch`,patch:{revokeOpen:!0}}),disabled:d,children:d?(0,Q.jsx)(l,{className:`size-3.5 animate-spin`}):(0,Q.jsx)(z,{className:`size-3.5`})})]})})]}),y&&h?(0,Q.jsxs)(`div`,{id:w,className:`mt-3 bg-surface-base/45 py-3 pl-7 pr-3`,children:[(0,Q.jsx)(O,{shareUrl:e.shareUrl,lanUrl:e.lanUrl,reachability:e.reachability,compact:!0}),_?(0,Q.jsx)(`p`,{className:`mt-2 text-xs text-red-600 dark:text-red-400`,children:t.copyFailed}):null,(0,Q.jsx)(`div`,{className:`mt-2`,children:(0,Q.jsx)(I,{reachability:e.reachability})})]}):null]}),(0,Q.jsx)(R,{open:u,title:t.revokeConfirmTitle,description:t.revokeConfirmBody,confirmLabel:t.revokeConfirmLabel,cancelLabel:t.cancel,destructive:!0,onConfirm:()=>void S(),onCancel:()=>s({type:`patch`,patch:{revokeOpen:!1}})})]})}function We({t:e,onCleaned:t}){let[n,r]=(0,J.useState)(!1),[i,a]=(0,J.useState)(!1),o=(0,J.useCallback)(async()=>{r(!1),a(!0);try{await k(),t()}catch{}finally{a(!1)}},[t]);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,Q.jsxs)(p,{type:`button`,variant:`secondary`,disabled:i,onClick:()=>r(!0),className:`border-danger/40 px-2 py-1 text-xs text-danger hover:bg-danger/10`,children:[i?(0,Q.jsx)(l,{className:`size-3.5 animate-spin`}):(0,Q.jsx)(z,{className:`size-3.5`}),e.cleanExpired]})}),(0,Q.jsx)(R,{open:n,title:e.cleanExpiredConfirmTitle,description:e.cleanExpiredConfirmBody,confirmLabel:e.cleanExpiredConfirmLabel,cancelLabel:e.cancel,destructive:!0,onConfirm:()=>void o(),onCancel:()=>r(!1)})]})}export{je as SharesSettingsPanel};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{n as e}from"./rolldown-runtime-aKtaBQYM.js";import{o as t,r as n}from"./locale-store-C5MK9WcP.js";import{Mn as r}from"./index-_cuTcWjB.js";var i=e({reloadSkills:()=>a});async function a(){let e=await t(n(`/api/skills/reload`),{method:`POST`});if(!e.ok)throw Error(await r(e))}export{i as n,a as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i,f as a,t as o}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{n as s,r as c}from"./popover-select-BzdnTy3h.js";import{t as l}from"./external-link-DjqjBmc3.js";import{f as u,u as d}from"./markdown-view-V4rcPPH0.js";import{t as f}from"./x-B_N4OPjy.js";import{t as p}from"./cn-JdwAhgNB.js";import{t as m}from"./button-CSEbl4zT.js";import{l as h,n as g}from"./locale-store-C5MK9WcP.js";import{i as _,n as ee,o as te,r as ne,s as re,t as v}from"./dist-BPoKqzeH.js";import{$n as ie,$t as ae,A as oe,Al as y,Cl as se,Da as b,H as ce,Ha as x,K as S,M as le,Oa as C,Qc as ue,Ql as de,Qn as fe,Qs as w,Qt as pe,R as T,Sl as E,W as D,Zc as me,Zn as O,cl as he,en as ge,er as _e,et as k,ic as A,ii as j,mc as M,n as N,nr as P,pa as F,q as ve,vi as ye,wr as be,yi as I}from"./index-_cuTcWjB.js";import{t as xe}from"./date-picker-DyNogHQH.js";import{t as L}from"./dependency-picker-BpnCuo7B.js";var R=e(t(),1),z=n();function Se(e,t,n,r){return!!(e&&t!==e.version&&n!==e.value&&r!==n)}function Ce(e,t){let n={...e.task};t.title!==void 0&&(n.title=t.title),t.priority!==void 0&&(n.priority=t.priority);for(let e of[`body`,`projectId`,`milestoneId`,`parentTaskId`,`dueAt`,`ownerId`]){let r=t[e];r!==void 0&&(r===null?delete n[e]:Object.assign(n,{[e]:r}))}return n.version+=1,n.updatedAt=Date.now(),{...e,task:n}}var B=r();function we(e,t){return(t===`zh`?{backlog:`待规划`,ready:`就绪`,active:`进行中`,review:`待验收`,closed:`已完成`}:{backlog:`Backlog`,ready:`Ready`,active:`Active`,review:`Review`,closed:`Completed`})[e]}function Te(){let e=(0,z.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,B.jsxs)(`div`,{className:`space-y-4`,"aria-busy":!0,children:[(0,B.jsx)(C,{className:`h-32 rounded-2xl`}),(0,B.jsx)(C,{className:`h-52 rounded-2xl`}),(0,B.jsx)(C,{className:`h-40 rounded-2xl`})]}),e[0]=t):t=e[0],t}function Ee(e){if(e===void 0)return``;let t=new Date(e);return new Date(t.getTime()-t.getTimezoneOffset()*6e4).toISOString().slice(0,10)}function De(e){return e?new Date(`${e}T23:59:59.999`).getTime():null}var Oe=[`backlog`,`ready`,`active`,`review`,`closed`],ke=[`low`,`normal`,`high`,`critical`],Ae=(0,R.memo)(function(e){let t=(0,z.c)(20),{value:n,disabled:r,canMove:i,canApprove:a,canReopen:o,language:l,label:u,onChange:d}=e,f;t[0]!==a||t[1]!==i||t[2]!==o||t[3]!==n?(f=e=>e!==n&&(e===`closed`?!a:n===`closed`?!o:!i),t[0]=a,t[1]=i,t[2]=o,t[3]=n,t[4]=f):f=t[4];let p=f,m;t[5]===u?m=t[6]:(m=(0,B.jsx)(`span`,{children:u}),t[5]=u,t[6]=m);let h;t[7]===d?h=t[8]:(h=e=>d(e.target.value),t[7]=d,t[8]=h);let g;t[9]!==l||t[10]!==p?(g=Oe.map(e=>(0,B.jsx)(c,{value:e,disabled:p(e),children:we(e,l)},e)),t[9]=l,t[10]=p,t[11]=g):g=t[11];let _;t[12]!==r||t[13]!==h||t[14]!==g||t[15]!==n?(_=(0,B.jsx)(s,{triggerClassName:`border-0 bg-surface-hover shadow-none focus-visible:ring-2 focus-visible:ring-accent/30`,contentClassName:`border-0`,value:n,disabled:r,onChange:h,children:g}),t[12]=r,t[13]=h,t[14]=g,t[15]=n,t[16]=_):_=t[16];let ee;return t[17]!==m||t[18]!==_?(ee=(0,B.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[m,_]}),t[17]=m,t[18]=_,t[19]=ee):ee=t[19],ee}),je=(0,R.memo)(function(e){let t=(0,z.c)(14),{value:n,disabled:r,label:i,labels:a,onChange:o}=e,l;t[0]===i?l=t[1]:(l=(0,B.jsx)(`span`,{children:i}),t[0]=i,t[1]=l);let u;t[2]===o?u=t[3]:(u=e=>o(e.target.value),t[2]=o,t[3]=u);let d;t[4]===a?d=t[5]:(d=ke.map(e=>(0,B.jsx)(c,{value:e,children:a[e]},e)),t[4]=a,t[5]=d);let f;t[6]!==r||t[7]!==u||t[8]!==d||t[9]!==n?(f=(0,B.jsx)(s,{triggerClassName:`border-0 bg-surface-hover shadow-none focus-visible:ring-2 focus-visible:ring-accent/30`,contentClassName:`border-0`,value:n,disabled:r,onChange:u,children:d}),t[6]=r,t[7]=u,t[8]=d,t[9]=n,t[10]=f):f=t[10];let p;return t[11]!==l||t[12]!==f?(p=(0,B.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[l,f]}),t[11]=l,t[12]=f,t[13]=p):p=t[13],p}),Me=(0,R.memo)(function(e){let t=(0,z.c)(10),{value:n,disabled:r,label:i,onChange:a}=e,o;t[0]===i?o=t[1]:(o=(0,B.jsx)(`span`,{children:i}),t[0]=i,t[1]=o);let s;t[2]!==r||t[3]!==i||t[4]!==a||t[5]!==n?(s=(0,B.jsx)(xe,{disabled:r,value:n,onChange:a,ariaLabel:i}),t[2]=r,t[3]=i,t[4]=a,t[5]=n,t[6]=s):s=t[6];let c;return t[7]!==o||t[8]!==s?(c=(0,B.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[o,s]}),t[7]=o,t[8]=s,t[9]=c):c=t[9],c}),Ne=(0,R.memo)(function(e){let t=(0,z.c)(17),{value:n,disabled:r,label:i,unassignedLabel:a,agents:o,onChange:l}=e,u;t[0]===i?u=t[1]:(u=(0,B.jsx)(`span`,{children:i}),t[0]=i,t[1]=u);let d;t[2]===l?d=t[3]:(d=e=>l(e.target.value),t[2]=l,t[3]=d);let f;t[4]===a?f=t[5]:(f=(0,B.jsx)(c,{value:``,disabled:!0,children:a}),t[4]=a,t[5]=f);let p;t[6]===o?p=t[7]:(p=o.map(Ye),t[6]=o,t[7]=p);let m;t[8]!==r||t[9]!==d||t[10]!==f||t[11]!==p||t[12]!==n?(m=(0,B.jsxs)(s,{triggerClassName:`border-0 bg-surface-hover shadow-none focus-visible:ring-2 focus-visible:ring-accent/30`,contentClassName:`border-0`,value:n,disabled:r,onChange:d,children:[f,p]}),t[8]=r,t[9]=d,t[10]=f,t[11]=p,t[12]=n,t[13]=m):m=t[13];let h;return t[14]!==u||t[15]!==m?(h=(0,B.jsxs)(`label`,{className:`grid gap-1.5 text-xs text-fg-muted`,children:[u,m]}),t[14]=u,t[15]=m,t[16]=h):h=t[16],h}),Pe=(0,R.memo)(function(e){let t=(0,z.c)(8),{candidates:n,selected:r,disabled:i,labels:a,onChange:o}=e,s;t[0]===r?s=t[1]:(s=r.map(Xe),t[0]=r,t[1]=s);let c;return t[2]!==n||t[3]!==i||t[4]!==a||t[5]!==o||t[6]!==s?(c=(0,B.jsx)(L,{borderless:!0,candidates:n,selectedIds:s,disabled:i,onChange:o,labels:a}),t[2]=n,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c):c=t[7],c},(e,t)=>e.disabled===t.disabled&&e.labels===t.labels&&e.onChange===t.onChange&&e.candidates.length===t.candidates.length&&e.candidates.every((e,n)=>e.id===t.candidates[n]?.id&&e.title===t.candidates[n]?.title)&&e.selected.length===t.selected.length&&e.selected.every((e,n)=>e.id===t.selected[n]?.id&&e.title===t.selected[n]?.title)),Fe=`xopc.taskDetail.chatPanelPercent`,Ie=42;function Le(e,t){let n=Math.max(30,352/Math.max(t,1)*100),r=Math.min(60,(t-480)/Math.max(t,1)*100);return r<n?Ie:Math.min(r,Math.max(n,e))}function Re(){try{let e=Number(window.localStorage.getItem(Fe));return Number.isFinite(e)&&e>=30&&e<=60?e:Ie}catch{return Ie}}function ze(e){return e.task.phase===`closed`?e.task.resolution===`done`?`completed`:`ended`:e.attention.some(e=>e.kind===`input_required`||e.kind===`approval_required`)?`needsUser`:e.operationalState===`idle`?e.task.phase===`backlog`?`captured`:e.task.phase===`ready`?`ready`:e.task.phase===`review`?`review`:`paused`:e.operationalState}function V(e){let t=(0,z.c)(9),{items:n,empty:r,verificationByCriterion:i}=e;if(n.length===0){let e;return t[0]===r?e=t[1]:(e=(0,B.jsx)(`p`,{className:`text-sm leading-6 text-fg-muted`,children:r}),t[0]=r,t[1]=e),e}let a;if(t[2]!==n||t[3]!==i){let e;t[5]===i?e=t[6]:(e=e=>{let t=i?.get(e)??`unverified`;return(0,B.jsxs)(`li`,{className:`flex gap-2 text-sm leading-6 text-fg`,children:[(0,B.jsx)(t===`passed`?y:t===`failed`?se:E,{className:t===`passed`?`mt-1 size-4 shrink-0 text-success`:t===`failed`?`mt-1 size-4 shrink-0 text-danger`:`mt-1 size-4 shrink-0 text-fg-subtle`}),(0,B.jsx)(`span`,{children:e})]},e)},t[5]=i,t[6]=e),a=n.map(e),t[2]=n,t[3]=i,t[4]=a}else a=t[4];let o;return t[7]===a?o=t[8]:(o=(0,B.jsx)(`ul`,{className:`space-y-2`,children:a}),t[7]=a,t[8]=o),o}function H({taskId:e,presentation:t,backgroundPath:n}){let[r]=a(),i=g(e=>e.language),s=h(e=>e.token),c=(0,R.useMemo)(()=>ve(i),[i]),f=x(e=>e.setPageHeader),_=x(e=>e.clearPageHeader),ee=I(e=>e.open),te=I(e=>e.sessionKeyOverride),ne=I(e=>e.openForSession),re=be(e=>e.setOpen),{data:v,error:se,mutate:C,lastChange:E,conversationLoading:ge,conversationError:ye}=oe(e),[xe,L]=(0,R.useState)(null),[z,we]=(0,R.useState)(()=>new Set),[Oe,ke]=(0,R.useState)([]),[H,Be]=(0,R.useState)(null),[Ve,He]=(0,R.useState)([]),[Ue,U]=(0,R.useState)(!1),[We,Ge]=(0,R.useState)(``),[Ke,W]=(0,R.useState)(!1),[qe,Je]=(0,R.useState)(``),[G,Ye]=(0,R.useState)(Re),[Xe,Ze]=(0,R.useState)(!1),Qe=(0,R.useRef)(null),$e=(0,R.useRef)(!1),et=(0,R.useRef)(!1),tt=(0,R.useRef)(``),nt=(0,R.useRef)(null),rt=(0,R.useRef)(null),it=(0,R.useRef)(null),at=(0,R.useRef)(v),[ot,K]=(0,R.useState)(null),[st,ct]=(0,R.useState)(null),lt=(0,R.useMemo)(()=>({link:c.linkDependencies,linked:c.linkedDependencies,searchPlaceholder:c.dependencySearchPlaceholder,noMatches:c.noDependencyMatches,noCandidates:c.noDependencyCandidates,remove:c.removeDependency}),[c.dependencySearchPlaceholder,c.linkDependencies,c.linkedDependencies,c.noDependencyCandidates,c.noDependencyMatches,c.removeDependency]),ut=v?.dependencies.map(e=>`${e.id}:${e.title}`).join(`\0`)??``,dt=(0,R.useMemo)(()=>d(r.get(`returnTo`),`/`,[`/projects`,`/chat`,`/notes`,`/tasks`]),[r]);at.current=v;let q=(0,R.useCallback)((e,t)=>{we(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r})},[]);(0,R.useEffect)(()=>{L(null),K(null),U(!1),W(!1),ct(null)},[e]),(0,R.useEffect)(()=>{let e=!0;return b().then(t=>{e&&He(t.items)}).catch(()=>void 0),()=>{e=!1}},[s]),(0,R.useEffect)(()=>{if(!E||E.source===`user`)return;ct(E);let e=window.setTimeout(()=>ct(null),3500);return()=>window.clearTimeout(e)},[E]),(0,R.useEffect)(()=>{let t=v?.task.projectId,n=v?.dependencies??[];if(!t){it.current=null,Be(null),ke(n);return}it.current!==t&&(it.current=t,Be(null));let r=!0;return F(t).then(t=>{if(!r)return;Be(t.project.name);let i=new Map;for(let r of[...t.tasks,...n])r.id!==e&&i.set(r.id,{id:r.id,title:r.title});ke([...i.values()])}).catch(()=>{r&&ke(n)}),()=>{r=!1}},[ut,v?.task.projectId,e]);let J=(0,R.useCallback)(async(t,n=`command`)=>{let r=at.current;if(r){q(n,!0),L(null);try{await C(await le(e,t,r.task.version),{revalidate:!1})}catch{L(c.actionFailed)}finally{q(n,!1)}}},[c.actionFailed,C,q,e]),Y=(0,R.useCallback)(async(t,n)=>{let r=at.current;if(!r)return!1;n&&q(n,!0),L(null);try{return await C(D(e,t,r.task.version),{optimisticData:Ce(r,t),populateCache:!0,revalidate:!1,rollbackOnError:!0}),!0}catch{return L(c.actionFailed),!1}finally{n&&q(n,!1)}},[c.actionFailed,C,q,e]),ft=async()=>{if(!v)return;if($e.current){$e.current=!1;return}let e=We.trim(),t=nt.current;if(Se(t,v.task.version,v.task.title,e)){K(`title`);return}if(!e||e===v.task.title){Ge(v.task.title),U(!1);return}await Y({title:e})&&(K(null),U(!1))},pt=async()=>{if(!v)return;if(et.current){et.current=!1;return}let e=qe.trim(),t=rt.current;if(Se(t,v.task.version,v.task.body??``,e)){K(`description`);return}if(qe===tt.current||e===(v.task.body??``).trim()){W(!1);return}await Y({body:e||null})&&(K(null),W(!1))},mt=(0,R.useCallback)(async e=>{let t=at.current;if(!(!t||e===t.task.phase)){if(t.task.phase===`closed`){await J({type:`reopen`,phase:e===`closed`?`ready`:e},`phase`);return}if(e===`closed`){await J({type:`close`,resolution:`done`},`phase`);return}await J({type:`move`,phase:e},`phase`)}},[J]),ht=(0,R.useCallback)(e=>{Y({priority:e},`priority`)},[Y]),gt=(0,R.useCallback)(e=>{Y({dueAt:De(e)},`dueAt`)},[Y]),_t=(0,R.useCallback)(e=>{Ye(e);try{window.localStorage.setItem(Fe,String(e))}catch{}},[]),vt=(0,R.useCallback)(e=>{if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`&&e.key!==`Home`)return;e.preventDefault();let t=Qe.current?.clientWidth??0;_t(Le(e.key===`Home`?Ie:G+(e.key===`ArrowLeft`?2:-2),t))},[G,_t]),yt=(0,R.useCallback)(e=>{if(!window.matchMedia(`(min-width: 1024px)`).matches)return;let t=Qe.current;if(!t)return;e.preventDefault();let n=e.currentTarget,r=e.pointerId;n.setPointerCapture(r),Ze(!0);let i=G,a=0,o=()=>{a=0,t.style.setProperty(`--task-chat-panel-width`,`${i}%`)},s=e=>{let n=t.getBoundingClientRect();i=Le((n.right-e.clientX)/n.width*100,n.width),a===0&&(a=window.requestAnimationFrame(o))},c=()=>{a!==0&&(window.cancelAnimationFrame(a),o());try{n.releasePointerCapture(r)}catch{}Ze(!1),_t(i),window.removeEventListener(`pointermove`,s),window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,c)};window.addEventListener(`pointermove`,s),window.addEventListener(`pointerup`,c),window.addEventListener(`pointercancel`,c)},[G,_t]),bt=(0,R.useCallback)(async t=>{let n=at.current;if(n){q(`dependencies`,!0),L(null);try{await C(await S(e,t,n.task.version),{revalidate:!1})}catch{L(c.dependencyUpdateFailed)}finally{q(`dependencies`,!1)}}},[c.dependencyUpdateFailed,C,q,e]),xt=(0,R.useCallback)(async t=>{let n=at.current;if(!(!n||!t||t===n.conversation.currentExecutorAgentId)){q(`delegateAgentId`,!0),L(null);try{await C(await T(e,t,n.task.version),{revalidate:!1})}catch{L(c.actionFailed)}finally{q(`delegateAgentId`,!1)}}},[c.actionFailed,C,q,e]);if((0,R.useLayoutEffect)(()=>{if(t!==`modal`)return f({startExtra:(0,B.jsx)(o,{to:dt,className:`flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover`,"aria-label":c.backToWork,children:(0,B.jsx)(de,{className:`size-4`})}),main:v?(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsx)(`p`,{className:`truncate text-sm font-semibold text-fg`,children:H?`${H} / ${c.taskLabel}`:c.taskLabel}),(0,B.jsx)(`p`,{className:`text-xs text-fg-muted`,children:c.detailStatuses[ze(v)]})]}):null,end:null}),_},[_,c.backToWork,c.detailStatuses,c.taskLabel,v,t,H,dt,f]),se&&!v)return(0,B.jsx)(`div`,{className:t===`modal`?`p-5 text-sm text-danger`:`mx-auto max-w-3xl p-6 text-sm text-danger`,children:c.taskNotFound});if(!v)return(0,B.jsx)(`div`,{className:t===`modal`?`p-5`:`mx-auto max-w-4xl p-4 sm:p-6`,children:(0,B.jsx)(Te,{})});let St=v.waits[0],Ct=St?.kind===`paused`?St:void 0,X=v.receipts[0],wt=c.detailStatuses[ze(v)],Tt=c.detailStatusDescriptions[ze(v)],Et=v.task.body?.trim()||v.task.contract?.objective.trim(),Dt=new Map(X?.verification.checks.map(e=>[e.criterion,e.status])),Ot=v.allowedCommands.includes(`mark_ready`),kt=v.allowedCommands.includes(`start`),At=v.allowedCommands.includes(`add_wait`),jt=v.task.phase===`review`&&v.allowedCommands.includes(`close`),Mt=v.allowedCommands.includes(`reopen`),Z=v.conversation.activeSessionKey,Nt=v.conversation.currentExecutorAgentId??v.task.delegateAgentId??v.task.ownerId,Pt=Ve.find(e=>e.id===Nt),Ft=!!(Z&&ee&&te===Z),It=v.attention.some(e=>e.kind===`input_required`||e.kind===`approval_required`),Lt=v.task.contract?.acceptanceCriteria??[],Rt=Lt.filter(e=>Dt.get(e)===`passed`).length,zt=v.task.contract?.expectedOutputs??[],Bt=v.task.contract?.constraints??[],Vt=v.task.contract?.approvalRequired??[],Ht=v.task.contract?.assumptions??[],Ut=v.task.contract?.risks??[],Q=(...e)=>!!st?.changedFields.some(t=>e.includes(t)),Wt=e=>t===`modal`&&n?ae(n,e):u(`/tasks/${e}`,dt),Gt=v.allowedCommands.includes(`move`),$=z.has(`command`),Kt=(0,B.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[Ot?(0,B.jsxs)(m,{variant:`primary`,disabled:$,onClick:()=>void J({type:`mark_ready`}),children:[(0,B.jsx)(w,{className:`size-4`}),c.scheduleTask]}):null,Ct?(0,B.jsxs)(m,{variant:`primary`,disabled:$,onClick:()=>void J({type:`resolve_wait`,waitId:Ct.id}),children:[(0,B.jsx)(w,{className:`size-4`}),c.resumeTask]}):null,!St&&kt&&Nt?(0,B.jsxs)(m,{variant:`primary`,disabled:$,onClick:()=>void J({type:`start`,executor:{kind:`agent`,agentId:Nt}}),children:[(0,B.jsx)(w,{className:`size-4`}),c.runTask]}):null,jt?(0,B.jsxs)(m,{variant:`primary`,disabled:$,onClick:()=>void J({type:`close`,resolution:`done`}),children:[(0,B.jsx)(y,{className:`size-4`}),c.approveTask]}):null,Mt?(0,B.jsxs)(m,{variant:`primary`,disabled:$,onClick:()=>void J({type:`reopen`,phase:`ready`}),children:[(0,B.jsx)(w,{className:`size-4`}),c.reopenTask]}):null,!St&&At?(0,B.jsxs)(m,{variant:`secondary`,className:`border-0 bg-surface-hover shadow-none`,disabled:$,onClick:()=>void J({type:`add_wait`,wait:{kind:`paused`,reason:`Paused by user`,condition:{}}}),children:[(0,B.jsx)(A,{className:`size-4`}),c.pauseTask]}):null,v.task.phase===`closed`?null:(0,B.jsxs)(_e,{children:[(0,B.jsx)(P,{asChild:!0,children:(0,B.jsx)(m,{type:`button`,variant:`ghost`,className:`size-9 p-0`,disabled:$,"aria-label":c.moreActions,children:(0,B.jsx)(he,{className:`size-4`,"aria-hidden":!0})})}),(0,B.jsx)(ie,{children:(0,B.jsx)(O,{align:`end`,sideOffset:6,className:`z-[100] min-w-40 rounded-lg border border-edge bg-surface-panel p-1 shadow-popover`,children:(0,B.jsx)(fe,{className:`cursor-pointer rounded-md px-3 py-2 text-sm text-danger outline-none hover:bg-surface-hover focus:bg-surface-hover`,onSelect:()=>void J({type:`close`,resolution:`cancelled`}),children:c.cancelTask})})})]})]});return(0,B.jsxs)(`div`,{ref:Qe,className:`${t===`modal`?`flex h-full min-h-0 flex-col lg:flex-row`:`flex min-h-[calc(100dvh-8rem)] flex-col overflow-hidden lg:flex-row`} ${Xe?`lg:cursor-col-resize lg:select-none`:``}`,style:{"--task-chat-panel-width":`${G}%`},children:[(0,B.jsxs)(`section`,{className:`task-detail-scroll min-w-0 flex-1 overflow-y-auto overscroll-contain p-5 sm:p-6`,children:[(0,B.jsxs)(`header`,{className:p(`px-4 pb-5`,Q(`title`)&&`task-detail-live-update`),children:[(0,B.jsx)(`div`,{className:`flex flex-wrap items-start justify-between gap-4`,children:(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-fg-muted`,children:[H?(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,B.jsx)(ue,{className:`size-3.5`,"aria-hidden":!0}),H]}):null,(0,B.jsx)(`span`,{children:`/`}),(0,B.jsx)(`span`,{children:c.taskLabel}),st?(0,B.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,role:`status`,children:st.source===`agent`?i===`zh`?`Agent 刚刚更新`:`Updated by Agent`:i===`zh`?`执行结果已同步`:`Execution result synced`}):null]}),Ue?(0,B.jsx)(`input`,{autoFocus:!0,"data-task-inline-editor":!0,value:We,onChange:e=>Ge(e.target.value),onBlur:()=>void ft(),onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur(),e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),$e.current=!0,Ge(v.task.title),U(!1),queueMicrotask(()=>{$e.current=!1}))},className:`mt-3 w-full max-w-3xl rounded-lg bg-surface-hover px-3 py-2 text-2xl font-semibold leading-8 text-fg outline-none ring-2 ring-accent/30 focus:ring-accent/60`}):(0,B.jsx)(`button`,{type:`button`,className:`mt-3 block max-w-3xl rounded-lg text-left outline-none hover:bg-surface-hover focus-visible:bg-surface-hover`,onClick:()=>{nt.current={value:v.task.title,version:v.task.version},K(null),Ge(v.task.title),U(!0)},children:(0,B.jsx)(`h1`,{className:`text-2xl font-semibold leading-8 text-fg`,children:v.task.title})}),ot===`title`?(0,B.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-xs text-warning`,role:`alert`,children:[(0,B.jsx)(`span`,{children:i===`zh`?`Agent 在你编辑期间更新了标题。`:`The Agent updated the title while you were editing.`}),(0,B.jsx)(`button`,{type:`button`,className:`rounded-md bg-surface-hover px-2 py-1 text-fg`,onClick:()=>{Ge(v.task.title),K(null),U(!1)},children:i===`zh`?`使用 Agent 版本`:`Use Agent version`}),(0,B.jsx)(`button`,{type:`button`,className:`rounded-md bg-accent-soft px-2 py-1 text-accent-fg`,onClick:()=>void Y({title:We.trim()}).then(e=>{e&&(K(null),U(!1))}),children:i===`zh`?`保留我的修改`:`Keep my changes`})]}):null]})}),xe?(0,B.jsx)(`p`,{className:`mt-3 text-sm text-danger`,children:xe}):null]}),(0,B.jsxs)(`div`,{className:`mt-5 flex flex-col gap-5`,children:[(0,B.jsxs)(`main`,{className:`order-2 min-w-0 space-y-5`,children:[(0,B.jsxs)(`section`,{className:p(`rounded-xl bg-surface-panel p-4`,Q(`body`)&&`task-detail-live-update`),children:[(0,B.jsx)(`h2`,{className:`font-medium text-fg`,children:c.taskDescription}),Ke?(0,B.jsx)(`textarea`,{autoFocus:!0,"data-task-inline-editor":!0,rows:6,value:qe,onChange:e=>Je(e.target.value),onBlur:()=>void pt(),onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),et.current=!0,Je(v.task.body??v.task.contract?.objective??``),W(!1),queueMicrotask(()=>{et.current=!1}))},className:`mt-3 w-full resize-y rounded-lg bg-surface-hover px-3 py-2 text-sm leading-6 text-fg outline-none ring-2 ring-accent/20 focus:ring-accent/50`}):(0,B.jsx)(`button`,{type:`button`,className:`-mx-1 mt-2 block w-[calc(100%+0.5rem)] rounded-lg px-1 py-1 text-left outline-none hover:bg-surface-hover focus-visible:bg-surface-hover`,onClick:()=>{let e=v.task.body??v.task.contract?.objective??``;tt.current=e,rt.current={value:v.task.body??``,version:v.task.version},K(null),Je(e),W(!0)},children:(0,B.jsx)(`span`,{className:`whitespace-pre-wrap text-sm leading-6 text-fg-muted`,children:Et&&Et!==v.task.title?Et:c.noTaskDescription})}),ot===`description`?(0,B.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-xs text-warning`,role:`alert`,children:[(0,B.jsx)(`span`,{children:i===`zh`?`Agent 在你编辑期间更新了描述。`:`The Agent updated the description while you were editing.`}),(0,B.jsx)(`button`,{type:`button`,className:`rounded-md bg-surface-hover px-2 py-1 text-fg`,onClick:()=>{Je(v.task.body??``),K(null),W(!1)},children:i===`zh`?`使用 Agent 版本`:`Use Agent version`}),(0,B.jsx)(`button`,{type:`button`,className:`rounded-md bg-accent-soft px-2 py-1 text-accent-fg`,onClick:()=>void Y({body:qe.trim()||null}).then(e=>{e&&(K(null),W(!1))}),children:i===`zh`?`保留我的修改`:`Keep my changes`})]}):null]}),v.attention.length>0?(0,B.jsxs)(`section`,{className:p(`rounded-xl bg-warning/10 p-4`,Q(`attention`)&&`task-detail-live-update`),children:[(0,B.jsx)(`h3`,{className:`font-medium text-fg`,children:It?c.needsAttention:c.waitingStatus}),(0,B.jsx)(`ul`,{className:`mt-3 space-y-2 text-sm text-fg-muted`,children:v.attention.map((e,t)=>(0,B.jsx)(`li`,{children:e.summary},`${e.kind}-${t}`))})]}):null,(0,B.jsxs)(`section`,{className:p(`rounded-xl bg-surface-panel p-4`,Q(`contract`)&&`task-detail-live-update`),children:[(0,B.jsx)(`h2`,{className:`font-medium text-fg`,children:c.taskDefinition}),(0,B.jsxs)(`div`,{className:`mt-5`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,B.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:c.successDefinition}),Lt.length>0?(0,B.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:c.criteriaProgress.replace(`{{verified}}`,String(Rt)).replace(`{{total}}`,String(Lt.length))}):null]}),(0,B.jsx)(`div`,{className:`mt-3`,children:(0,B.jsx)(V,{items:Lt,empty:c.noDefinition,verificationByCriterion:Dt})})]}),zt.length>0?(0,B.jsxs)(`div`,{className:`mt-5 rounded-lg bg-surface-hover p-4`,children:[(0,B.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:c.expectedOutputs}),(0,B.jsx)(`div`,{className:`mt-3`,children:(0,B.jsx)(V,{items:zt,empty:c.noDefinition})})]}):null,Bt.length>0?(0,B.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-hover p-4`,children:[(0,B.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:c.constraints}),(0,B.jsx)(`div`,{className:`mt-3`,children:(0,B.jsx)(V,{items:Bt,empty:c.noDefinition})})]}):null,Vt.length>0?(0,B.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-hover p-4`,children:[(0,B.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:c.approvalRequired}),(0,B.jsx)(`div`,{className:`mt-3`,children:(0,B.jsx)(V,{items:Vt,empty:c.noDefinition})})]}):null,Ht.length>0?(0,B.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-hover p-4`,children:[(0,B.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:c.contextAssumptions}),(0,B.jsx)(`div`,{className:`mt-3`,children:(0,B.jsx)(V,{items:Ht,empty:c.noDefinition})})]}):null,Ut.length>0?(0,B.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-hover p-4`,children:[(0,B.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:c.contextRisks}),(0,B.jsx)(`div`,{className:`mt-3`,children:(0,B.jsx)(V,{items:Ut,empty:c.noDefinition})})]}):null]}),X?(0,B.jsxs)(`section`,{className:p(`rounded-xl bg-surface-panel p-4`,Q(`runs`,`receipts`)&&`task-detail-live-update`),children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h2`,{className:`font-medium text-fg`,children:c.latestResult}),(0,B.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg`,children:X.summary})]}),(0,B.jsxs)(`span`,{className:`rounded-full bg-surface-hover px-2.5 py-1 text-xs text-fg-muted`,children:[c.receiptStatuses[X.status],` · `,c.verificationStatuses[X.verification.status]]})]}),X.remainingWork.length>0?(0,B.jsxs)(`div`,{className:`mt-4`,children:[(0,B.jsx)(`h3`,{className:`text-xs font-medium text-fg-muted`,children:c.remainingWork}),(0,B.jsx)(`div`,{className:`mt-2`,children:(0,B.jsx)(V,{items:X.remainingWork,empty:c.noRemainingWork})})]}):null,X.nextAction?(0,B.jsxs)(`div`,{className:`mt-4 rounded-lg bg-surface-hover p-3`,children:[(0,B.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:c.nextAction}),(0,B.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:X.nextAction})]}):null,(0,B.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-2`,children:[(0,B.jsx)(m,{className:`border-0 bg-surface-hover px-2 py-1 text-xs shadow-none`,variant:`secondary`,onClick:()=>void ce(X.runId,`helpful`),children:c.doneWell}),(0,B.jsx)(m,{className:`px-2 py-1 text-xs`,variant:`ghost`,onClick:()=>void ce(X.runId,`not_helpful`),children:c.needsFix}),X.evidence.filter(e=>e.uri).map(e=>(0,B.jsxs)(`a`,{className:`ml-auto inline-flex items-center gap-1 text-xs text-accent hover:underline`,href:e.uri,children:[(0,B.jsx)(l,{className:`size-3`}),e.title]},`${e.title}-${e.uri}`))]}),v.receipts.length>1?(0,B.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-hover p-4`,children:[(0,B.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted`,children:c.executionHistory.replace(`{{count}}`,String(v.receipts.length-1))}),(0,B.jsx)(`div`,{className:`mt-3 space-y-3`,children:v.receipts.slice(1).map(e=>(0,B.jsx)(`article`,{className:`rounded-lg bg-surface-active p-3`,children:(0,B.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,B.jsx)(`p`,{className:`text-sm text-fg`,children:e.summary}),(0,B.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:c.receiptStatuses[e.status]})]})},e.runId))})]}):null]}):null,v.context.length>0?(0,B.jsxs)(`section`,{className:p(`rounded-xl bg-surface-panel p-4`,Q(`context`)&&`task-detail-live-update`),children:[(0,B.jsx)(`h2`,{className:`font-medium text-fg`,children:c.contextUsed}),(0,B.jsx)(`ul`,{className:`mt-4 grid gap-2 sm:grid-cols-2`,children:v.context.map(e=>(0,B.jsxs)(`li`,{className:`min-w-0 rounded-lg bg-surface-hover p-2.5`,children:[(0,B.jsxs)(`span`,{className:`text-[11px] text-fg-subtle`,children:[c.contextRoleLabels[e.role],` · `,c.contextKindLabels[e.targetKind]]}),e.targetKind===`url`&&/^https?:\/\//.test(e.targetId)?(0,B.jsx)(`a`,{className:`mt-1 block break-all text-sm text-accent hover:underline`,href:e.targetId,target:`_blank`,rel:`noreferrer`,children:e.title??e.targetId}):(0,B.jsx)(`p`,{className:`mt-1 break-words text-sm text-fg`,children:e.title??e.targetId})]},e.id))})]}):null]}),(0,B.jsxs)(`aside`,{className:`order-1 min-w-0 space-y-4`,children:[(0,B.jsxs)(`section`,{className:p(`rounded-xl bg-surface-subtle p-4`,Q(`phase`,`resolution`,`priority`,`dueAt`,`delegateAgentId`)&&`task-detail-live-update`),children:[(0,B.jsx)(`h2`,{className:`font-medium text-fg`,children:c.taskProperties}),(0,B.jsxs)(`div`,{className:`mt-4 grid gap-4 sm:grid-cols-2`,children:[(0,B.jsx)(Ae,{value:v.task.phase,disabled:z.has(`phase`),canMove:Gt,canApprove:jt,canReopen:Mt,language:i,label:c.taskPhase,onChange:mt}),(0,B.jsx)(je,{value:v.task.priority,disabled:z.has(`priority`),label:c.priority,labels:c.priorityLabels,onChange:ht}),(0,B.jsx)(Me,{value:Ee(v.task.dueAt),disabled:z.has(`dueAt`),label:c.dueDate,onChange:gt}),(0,B.jsx)(Ne,{value:v.conversation.currentExecutorAgentId??``,disabled:z.has(`delegateAgentId`),label:c.executorLabel,unassignedLabel:c.unassigned,agents:Ve,onChange:xt}),H?(0,B.jsxs)(`div`,{className:`grid gap-1 text-xs text-fg-muted`,children:[(0,B.jsx)(`span`,{children:c.projectLabel}),(0,B.jsxs)(`span`,{className:`flex items-center gap-1.5 rounded-lg bg-surface-hover px-3 py-2 text-sm text-fg`,children:[(0,B.jsx)(ue,{className:`size-3.5`}),H]})]}):null]}),(0,B.jsxs)(`div`,{className:`mt-4 rounded-lg bg-surface-hover p-3 text-xs leading-5 text-fg-subtle`,children:[(0,B.jsx)(`p`,{children:wt}),(0,B.jsx)(`p`,{children:Tt}),(0,B.jsx)(`p`,{className:`mt-2`,children:c.updatedAt.replace(`{{date}}`,j(v.task.updatedAt,i))})]})]}),(0,B.jsxs)(`section`,{className:p(`rounded-xl bg-surface-panel p-4`,Q(`dependencies`)&&`task-detail-live-update`),children:[(0,B.jsx)(`h2`,{className:`font-medium text-fg`,children:c.taskRelations}),(0,B.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:c.dependencies}),(0,B.jsx)(Pe,{candidates:Oe,selected:v.dependencies,disabled:z.has(`dependencies`),labels:lt,onChange:bt})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:c.dependents}),v.dependents.length>0?(0,B.jsx)(`div`,{className:`space-y-1.5`,children:v.dependents.map(e=>(0,B.jsx)(o,{to:Wt(e.id),className:`block rounded-lg bg-surface-hover p-2.5 text-sm text-accent hover:underline`,children:e.title},e.id))}):(0,B.jsx)(`p`,{className:`text-sm text-fg-subtle`,children:c.noDependents})]})]})]})]})]})]}),(0,B.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":i===`zh`?`调整任务信息和 Agent 对话的宽度`:`Resize task details and Agent chat`,"aria-valuemin":30,"aria-valuemax":60,"aria-valuenow":Math.round(G),tabIndex:0,onPointerDown:yt,onKeyDown:vt,onDoubleClick:()=>_t(Ie),className:`group hidden w-2 shrink-0 cursor-col-resize touch-none items-stretch justify-center bg-surface-panel outline-none transition-colors hover:bg-surface-hover focus-visible:bg-surface-hover lg:flex ${Xe?`bg-surface-hover`:``}`,children:(0,B.jsx)(`div`,{className:`my-3 w-px rounded-full bg-edge-strong/70 transition-colors group-hover:bg-accent group-focus-visible:bg-accent`})}),(0,B.jsxs)(`aside`,{className:`flex min-h-[34rem] min-w-0 flex-col bg-surface-panel lg:min-h-0 lg:w-[var(--task-chat-panel-width)] lg:shrink-0`,children:[(0,B.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-3 bg-surface-subtle px-4 py-3.5`,children:[(0,B.jsx)(`div`,{className:`min-w-0`,children:(0,B.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[Nt?(0,B.jsx)(k,{agentId:Nt,avatar:Pt?.avatar,size:28,className:`shrink-0`}):null,(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:i===`zh`?`Agent 执行与对话`:`Agent execution and chat`}),(0,B.jsxs)(`p`,{className:`mt-0.5 truncate text-xs text-fg-muted`,children:[Pt?.name??Nt??c.unassigned,` · `,wt]})]})]})}),(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[Kt,Z&&t!==`modal`?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(m,{type:`button`,variant:`ghost`,className:p(`h-8 shrink-0 px-2 text-xs`,Ft&&`bg-surface-hover text-fg`),"aria-label":i===`zh`?`项目文件`:`Project files`,"aria-pressed":Ft,onClick:()=>{re(Z,!1),ne(Z)},children:[(0,B.jsx)(me,{className:`size-3.5`,"aria-hidden":!0}),i===`zh`?`文件`:`Files`]}),(0,B.jsx)(m,{asChild:!0,variant:`ghost`,className:`h-8 shrink-0 px-2 text-xs`,children:(0,B.jsxs)(o,{to:pe(e),children:[(0,B.jsx)(l,{className:`size-3.5`}),i===`zh`?`全屏`:`Full screen`]})})]}):null]})]}),Z?(0,B.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,B.jsx)(N,{embedded:!0,sessionKey:Z,taskId:e})}):ge?(0,B.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center p-8 text-center`,children:(0,B.jsxs)(`div`,{className:`max-w-xs`,children:[(0,B.jsx)(M,{className:`mx-auto size-8 animate-pulse text-fg-subtle`}),(0,B.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:i===`zh`?`正在创建任务会话`:`Creating task conversation`})]})}):ye?(0,B.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center p-8 text-center`,children:(0,B.jsxs)(`div`,{className:`max-w-xs`,children:[(0,B.jsx)(M,{className:`mx-auto size-8 text-danger`}),(0,B.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:i===`zh`?`任务会话创建失败`:`Could not create task conversation`}),(0,B.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-muted`,children:ye instanceof Error?ye.message:String(ye)})]})}):(0,B.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center p-8 text-center`,children:(0,B.jsxs)(`div`,{className:`max-w-xs`,children:[(0,B.jsx)(M,{className:`mx-auto size-8 text-fg-subtle`}),(0,B.jsx)(`p`,{className:`mt-3 text-sm font-medium text-fg`,children:i===`zh`?`等待任务会话`:`Waiting for a task conversation`}),(0,B.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-muted`,children:i===`zh`?`安排或开始任务后,Agent 的执行过程和持续对话会显示在这里。`:`Schedule or start the task to see the agent run and continue the conversation here.`})]})})]})]})}function Be(){let e=(0,z.c)(2),{taskId:t}=i(),n=t===void 0?``:t,r;return e[0]===n?r=e[1]:(r=(0,B.jsx)(H,{taskId:n,presentation:`page`}),e[0]=n,e[1]=r),r}function Ve(e){let t=(0,z.c)(54),{taskId:n,backgroundPath:r,onClose:i}=e,a=g(G),{data:s}=oe(n),c=s?.conversation.activeSessionKey??null,u=I(Je),d=I(qe),m=I(W),h=I(Ke),ie=be(Ge),ae=ye(We),y=ye(U),se=u?d:0,b;t[0]!==i||t[1]!==y?(b=e=>{e||(y(null),i())},t[0]=i,t[1]=y,t[2]=b):b=t[2];let ce=a===`zh`?`关闭任务详情`:`Close task details`,x;t[3]!==i||t[4]!==y?(x=()=>{y(null),i()},t[3]=i,t[4]=y,t[5]=x):x=t[5];let S;t[6]!==ce||t[7]!==x?(S=(0,B.jsx)(`button`,{type:`button`,tabIndex:-1,"data-task-modal-backdrop":!0,className:`fixed inset-0 z-[80] bg-black/45 backdrop-blur-[1px]`,"aria-label":ce,onClick:x}),t[6]=ce,t[7]=x,t[8]=S):S=t[8];let le=u?`true`:`false`,C=`${se/2}px`,ue=`${se}px`,de;t[9]!==C||t[10]!==ue?(de={"--task-detail-workspace-offset":C,"--task-detail-workspace-width":ue},t[9]=C,t[10]=ue,t[11]=de):de=t[11];let fe=de,w=a===`zh`?`任务详情`:`Task details`,T;t[12]===w?T=t[13]:(T=(0,B.jsx)(re,{className:`font-medium text-fg`,children:w}),t[12]=w,t[13]=T);let E=a===`zh`?`查看并操作任务详情`:`View and manage task details`,D;t[14]===E?D=t[15]:(D=(0,B.jsx)(_,{className:`sr-only`,children:E}),t[14]=E,t[15]=D);let O;t[16]!==c||t[17]!==a||t[18]!==h||t[19]!==ie||t[20]!==n||t[21]!==u||t[22]!==m?(O=c?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`button`,{type:`button`,className:p(`flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,u&&m===c&&`bg-surface-hover text-fg`),"aria-label":a===`zh`?`项目文件`:`Project files`,title:a===`zh`?`项目文件`:`Project files`,"aria-pressed":u&&m===c,onClick:()=>{ie(c,!1),h(c)},children:(0,B.jsx)(me,{className:`size-4`,"aria-hidden":!0})}),(0,B.jsx)(o,{to:pe(n),className:`flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":a===`zh`?`全屏打开对话`:`Open chat full screen`,title:a===`zh`?`全屏打开对话`:`Open chat full screen`,children:(0,B.jsx)(l,{className:`size-4`,"aria-hidden":!0})})]}):null,t[16]=c,t[17]=a,t[18]=h,t[19]=ie,t[20]=n,t[21]=u,t[22]=m,t[23]=O):O=t[23];let he=a===`zh`?`关闭任务详情`:`Close task details`,_e;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(_e=(0,B.jsx)(f,{className:`size-4`,"aria-hidden":!0}),t[24]=_e):_e=t[24];let k;t[25]===he?k=t[26]:(k=(0,B.jsx)(ee,{className:`flex size-8 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":he,children:_e}),t[25]=he,t[26]=k);let A;t[27]!==O||t[28]!==k?(A=(0,B.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[O,k]}),t[27]=O,t[28]=k,t[29]=A):A=t[29];let j;t[30]!==T||t[31]!==D||t[32]!==A?(j=(0,B.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between gap-3 bg-surface-panel px-5 py-3.5`,children:[T,D,A]}),t[30]=T,t[31]=D,t[32]=A,t[33]=j):j=t[33];let M;t[34]!==r||t[35]!==n?(M=(0,B.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,B.jsx)(H,{taskId:n,presentation:`modal`,backgroundPath:r})}),t[34]=r,t[35]=n,t[36]=M):M=t[36];let N;t[37]!==j||t[38]!==M||t[39]!==le||t[40]!==fe?(N=(0,B.jsxs)(ne,{className:`task-detail-modal-content fixed top-1/2 z-[90] flex h-[min(54rem,calc(100dvh-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl bg-surface-base shadow-float focus:outline-none`,"data-workspace-panel-open":le,style:fe,onEscapeKeyDown:Ue,onInteractOutside:He,children:[j,M]}),t[37]=j,t[38]=M,t[39]=le,t[40]=fe,t[41]=N):N=t[41];let P;t[42]!==ae||t[43]!==u||t[44]!==d||t[45]!==m?(P=ae?(0,B.jsx)(`div`,{className:`fixed inset-y-0 left-0 z-[100] flex min-h-0 min-w-0 overflow-hidden bg-surface-panel transition-[right] duration-200 ease-out motion-reduce:transition-none`,style:{right:u?d:0},children:(0,B.jsx)(ge,{allowOutsideChat:!0,sessionKey:m??void 0})}):null,t[42]=ae,t[43]=u,t[44]=d,t[45]=m,t[46]=P):P=t[46];let F;t[47]!==N||t[48]!==P||t[49]!==S?(F=(0,B.jsxs)(te,{children:[S,N,P]}),t[47]=N,t[48]=P,t[49]=S,t[50]=F):F=t[50];let ve;return t[51]!==b||t[52]!==F?(ve=(0,B.jsx)(v,{modal:!1,open:!0,onOpenChange:b,children:F}),t[51]=b,t[52]=F,t[53]=ve):ve=t[53],ve}function He(e){let t=e.detail.originalEvent.target;t instanceof Element&&t.closest(`#app-workspace-panel, [data-task-modal-backdrop]`)&&e.preventDefault()}function Ue(e){let t=e.target;t instanceof HTMLElement&&t.closest(`[data-task-inline-editor]`)&&e.preventDefault()}function U(e){return e.setPath}function We(e){return e.path}function Ge(e){return e.setOpen}function Ke(e){return e.openForSession}function W(e){return e.sessionKeyOverride}function qe(e){return e.widthPx}function Je(e){return e.open}function G(e){return e.language}function Ye(e){return(0,B.jsx)(c,{value:e.id,children:e.name||e.id},e.id)}function Xe(e){return e.id}export{Ve as TaskDetailModal,Be as TaskDetailPage};
|