@xopcai/xopc 0.0.249 → 0.0.250
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/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{activity-store-B759R_qf.js → activity-store-DfBjTSo9.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-BUu7EnwM.js → agent-avatar-dicebear-BN6FJXkJ.js} +1 -1
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-C7rZH1A2.js +1 -0
- package/dist/gateway/static/root/assets/{agents-DK9HjHO0.js → agents-CgGaoo4z.js} +1 -1
- package/dist/gateway/static/root/assets/{api-Cg0v7Lpn.js → api-zxpcJfgj.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-C9DkCW_d.js → app-management-settings-panel-D2gMshuS.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-CFggS95Y.js → appearance-settings-wMu0jSKx.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-jOvT-fzU.js → apps-page-KF1Gnv36.js} +1 -1
- package/dist/gateway/static/root/assets/{archive-plugin-BQrilVVv.js → archive-plugin-u6EE3JV8.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-BG0BliqV.js → attachment-load-DbJurnv-.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-Bo4RiTkh.js → automations-page-Ew_e5HDn.js} +1 -1
- package/dist/gateway/static/root/assets/automations-workspace-Ch-ldu35.js +6 -0
- package/dist/gateway/static/root/assets/{binary-plugins-BCnyNU0C.js → binary-plugins-DtDFNfPM.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-Db8DlVvg.js → block-editor-CnAwmabq.js} +50 -50
- package/dist/gateway/static/root/assets/browser-settings-page-DtVhsHJW.js +8 -0
- package/dist/gateway/static/root/assets/{browser-workflow-inputs-C71vfl0b.js → browser-workflow-inputs-BX1-uM9L.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-workflows-page-vvmSYKsO.js → browser-workflows-page-CcbUOWDF.js} +2 -2
- package/dist/gateway/static/root/assets/capabilities-settings-panel--sXeylhe.js +7 -0
- package/dist/gateway/static/root/assets/channels-settings-AXSBDujZ.js +1 -0
- package/dist/gateway/static/root/assets/{channels-status-swr-CKyV3jY5.js → channels-status-swr-CX-yWwLD.js} +1 -1
- package/dist/gateway/static/root/assets/{chat-terminal-dock-B1Xd6OFB.js → chat-terminal-dock-CryTDNdD.js} +2 -2
- package/dist/gateway/static/root/assets/connectors-page-HBHUWohz.js +2 -0
- package/dist/gateway/static/root/assets/{cron-expression-D-F9vjtE.js → cron-expression-ji5aWrjG.js} +1 -1
- package/dist/gateway/static/root/assets/{date-picker-B2OoYvic.js → date-picker-Dro_w3eX.js} +1 -1
- package/dist/gateway/static/root/assets/{dependency-picker-BiGx9Sbj.js → dependency-picker-Ce19KKnX.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-BNMRqipe.js → desktop-pet-DsSi-3uZ.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-DeYbIV7A.js → desktop-pet-settings-8WQ4woJy.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-COyn05ub.js → extension-debug-page-CgvEBfLZ.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-oH43chS2.js → extension-page-DkznBbMj.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-BMO59994.js → extension-settings-page-BOjhchK2.js} +1 -1
- package/dist/gateway/static/root/assets/files-BArWTfr7.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-config-api-cimpViGk.js → gateway-config-api-OEruhhX3.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-swr-BGdHwT4e.js → gateway-config-swr-CMNbl0FZ.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-BHJtnSic.js → gateway-settings-BgH3A0LO.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-CuaM3b4c.js → gateway-startup-retry-CR7Xg8As.js} +1 -1
- package/dist/gateway/static/root/assets/heartbeat-settings-C97naDkO.js +1 -0
- package/dist/gateway/static/root/assets/home-page-BBKKme4G.js +1 -0
- package/dist/gateway/static/root/assets/{image-generation-api-D7duj7Uj.js → image-generation-api-C5mn73ca.js} +1 -1
- package/dist/gateway/static/root/assets/index-BcaF-dgQ.js +72 -0
- package/dist/gateway/static/root/assets/{index-DGeGmj4k.css → index-DAryGvZ7.css} +1 -1
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-D8Zw_lYd.js → keyboard-shortcuts-settings-BYhfzsqe.js} +1 -1
- package/dist/gateway/static/root/assets/{local-app-workbench-page-eBFVWmtH.js → local-app-workbench-page-DNncc2tn.js} +2 -2
- package/dist/gateway/static/root/assets/{local-apps-page-CvPDPRwb.js → local-apps-page-vBlknU7C.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-zEL8bkwx.js → locale-store-CF4erhjB.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-ClvcWlL6.js → logs-page-CizZInrT.js} +2 -2
- package/dist/gateway/static/root/assets/{management-settings-D8moh99U.js → management-settings-Dnx6mSNe.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-split-D7V3j0vE.js → markdown-split-DtBtcHWi.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-view-DGRN-8wP.js → markdown-view-CQvzsE24.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-BLaE5b1Y.js → media-plugins-DrMYeHe7.js} +1 -1
- package/dist/gateway/static/root/assets/messages-Cf5hpZE6.js +3 -0
- package/dist/gateway/static/root/assets/{mobile-pairing-wizard-DiVDuCxl.js → mobile-pairing-wizard-AKgGy3Kx.js} +1 -1
- package/dist/gateway/static/root/assets/note-detail-panel-Bw3jD9Jf.js +5 -0
- package/dist/gateway/static/root/assets/notes-page-Dpqq7Z-J.js +8 -0
- package/dist/gateway/static/root/assets/{page-tabs-BFMGjA60.js → page-tabs-CX9T71by.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-DNEWZN7H.js → preview-open-alternatives-DvEHoimN.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-Co5u7asH.js → product-open-page-COcr_NUJ.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-BuT6MCTs.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-DXWMxOjf.js +1 -0
- package/dist/gateway/static/root/assets/{registry-api-Cg92zSod.js → registry-api-BsRBlji7.js} +1 -1
- package/dist/gateway/static/root/assets/remote-access-hub-7rBCUWzZ.js +1 -0
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-C0ByNmlV.js → runtime-tools-settings-panel-CQ13P-mS.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-Dq_VQpuY.js → schema-form-BUVyTpZj.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-gmEOYNb4.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-DYYoJcl7.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-CZu6FX4k.js → settings-form-section-DVY-8_B9.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-S8ekeUZd.js → settings-page-CdiVYyTl.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-status-panel-BdVmwXMv.js → setup-status-panel-BhenBnUj.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-D2fEidbn.js → share-preview-page-C88YLKm4.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-Dq7xIj0_.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-MDI9Lz6z.js +1 -0
- package/dist/gateway/static/root/assets/{skills-page-AYiPlgZE.js → skills-page-DLir1nM0.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page.utils-DGzl-ib-.js → skills-page.utils-BMZAfS3G.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-5Xd5mIiR.js → system-settings-panel-BM8ivYan.js} +1 -1
- package/dist/gateway/static/root/assets/task-detail-page-P0_RldWv.js +1 -0
- package/dist/gateway/static/root/assets/{theme-store-ZVClZKQ0.js → theme-store-BOgkc_9D.js} +1 -1
- package/dist/gateway/static/root/assets/{tunnel-api-CdZN1Jin.js → tunnel-api-DemxChjo.js} +1 -1
- package/dist/gateway/static/root/assets/{use-autosave-czRI0NBc.js → use-autosave-CV3Ui5hu.js} +1 -1
- package/dist/gateway/static/root/assets/user-model-page-CxfnoRVn.js +2 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-8YEvA3cU.js → voice-api-key-field-CUoCi4Sq.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-config-api-CopF64lY.js → voice-config-api-C-ryeIxj.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-keLtqYYJ.js → work-discovery-overlay-BhDlkCMB.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-Dy5WgYMO.js → workflow-run-setup-panel-D8CcPc_C.js} +2 -2
- package/dist/gateway/static/root/assets/workflows-page-Bxn2Dc16.js +5 -0
- package/dist/gateway/static/root/index.html +11 -11
- package/dist/package.js +1 -1
- package/dist/packages/gateway-contract/src/user-message-display.js +18 -0
- package/dist/src/agent/agent-instance-gateway.d.ts +1 -1
- package/dist/src/agent/agent-manager.d.ts +9 -9
- package/dist/src/agent/agent-manager.js +46 -28
- package/dist/src/agent/background-review/prompts.d.ts +1 -1
- package/dist/src/agent/background-review/prompts.js +11 -2
- package/dist/src/agent/context/audit.d.ts +3 -1
- package/dist/src/agent/context/audit.js +32 -6
- package/dist/src/agent/context/coordinator.d.ts +6 -1
- package/dist/src/agent/context/coordinator.js +14 -13
- package/dist/src/agent/context/execution-context.d.ts +6 -47
- package/dist/src/agent/context/execution-context.js +79 -15
- package/dist/src/agent/context/execution-context.types.d.ts +50 -0
- package/dist/src/agent/context/execution-context.types.js +1 -0
- package/dist/src/agent/context/execution-scope.d.ts +5 -1
- package/dist/src/agent/context/execution-scope.js +6 -2
- package/dist/src/agent/context/project-context.d.ts +3 -0
- package/dist/src/agent/context/project-context.js +5 -3
- package/dist/src/agent/external-tools/index.d.ts +1 -0
- package/dist/src/agent/external-tools/index.js +1 -0
- package/dist/src/agent/external-tools/memory-provider.d.ts +1 -0
- package/dist/src/agent/external-tools/memory-provider.js +1 -0
- package/dist/src/agent/inbound/attachment-pipeline.js +5 -1
- package/dist/src/agent/memory/compaction-promotion.d.ts +1 -0
- package/dist/src/agent/memory/compaction-promotion.js +7 -2
- package/dist/src/agent/memory/index.d.ts +1 -1
- package/dist/src/agent/memory/index.js +3 -3
- package/dist/src/agent/memory/memory-config.d.ts +0 -5
- package/dist/src/agent/memory/memory-config.js +1 -8
- package/dist/src/agent/orchestration/context-overflow.js +1 -0
- package/dist/src/agent/service/direct-turn-helpers.d.ts +2 -2
- package/dist/src/agent/service/direct-turn-helpers.js +2 -2
- package/dist/src/agent/service/process-direct-streaming.js +3 -4
- package/dist/src/agent/tools/factory.d.ts +1 -0
- package/dist/src/agent/tools/factory.js +37 -7
- package/dist/src/agent/tools/knowledge-memory-tool.d.ts +6 -0
- package/dist/src/agent/tools/knowledge-memory-tool.js +81 -26
- package/dist/src/agent/tools/session-search-tool.d.ts +1 -0
- package/dist/src/agent/tools/session-search-tool.js +7 -0
- package/dist/src/agent/tools/user-context-tool.d.ts +2 -0
- package/dist/src/agent/tools/user-context-tool.js +21 -4
- package/dist/src/automations/service/automation-service.d.ts +2 -1
- package/dist/src/automations/service/automation-service.js +6 -2
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/connectors/connection-recovery-service.d.ts +1 -0
- package/dist/src/connectors/connection-recovery-service.js +46 -22
- package/dist/src/files/file-service.js +4 -1
- package/dist/src/gateway/hono/routes/connectors.js +17 -3
- package/dist/src/gateway/hono/routes/files.js +23 -2
- package/dist/src/gateway/hono/routes/tasks.js +1 -1
- package/dist/src/gateway/security/gateway-scopes.js +2 -0
- package/dist/src/gateway/service/agent-runner.js +1 -1
- package/dist/src/gateway/service/run-gateway-agent.js +1 -1
- package/dist/src/gateway/service/session-input-coordinator.js +1 -1
- package/dist/src/gateway/service.js +8 -4
- package/dist/src/knowledge-memory/domain.d.ts +1 -0
- package/dist/src/knowledge-memory/index.js +2 -2
- package/dist/src/knowledge-memory/repository.d.ts +4 -1
- package/dist/src/knowledge-memory/repository.js +16 -2
- package/dist/src/notifications/planner.js +7 -3
- package/dist/src/proactive/actions/service.d.ts +0 -1
- package/dist/src/proactive/actions/service.js +1 -10
- package/dist/src/proactive/execution/context.d.ts +6 -8
- package/dist/src/proactive/execution/context.js +78 -32
- package/dist/src/proactive/execution/insight.d.ts +4 -1
- package/dist/src/proactive/execution/insight.js +5 -2
- package/dist/src/proactive/execution/repository.d.ts +1 -0
- package/dist/src/proactive/execution/repository.js +9 -1
- package/dist/src/proactive/execution/types.d.ts +0 -1
- package/dist/src/proactive/execution/worker.js +7 -5
- package/dist/src/proactive/inbox/repository.js +8 -2
- package/dist/src/proactive/inbox/service.js +2 -2
- package/dist/src/proactive/inbox/types.d.ts +1 -0
- package/dist/src/proactive/inbox/worker.d.ts +1 -0
- package/dist/src/proactive/inbox/worker.js +7 -0
- package/dist/src/proactive/index.d.ts +1 -0
- package/dist/src/proactive/index.js +2 -1
- package/dist/src/proactive/maintenance.d.ts +4 -0
- package/dist/src/proactive/maintenance.js +21 -0
- package/dist/src/proactive/scenarios/repository.d.ts +1 -1
- package/dist/src/proactive/scenarios/repository.js +10 -3
- package/dist/src/proactive/scenarios/types.d.ts +7 -0
- package/dist/src/proactive/service.d.ts +7 -0
- package/dist/src/proactive/service.js +17 -1
- package/dist/src/projects/project-service.d.ts +2 -1
- package/dist/src/projects/project-service.js +3 -2
- package/dist/src/session/index.js +1 -1
- package/dist/src/session/store.js +5 -2
- package/dist/src/storage/sqlite/collaboration-rule-repository.d.ts +3 -1
- package/dist/src/storage/sqlite/collaboration-rule-repository.js +1 -1
- package/dist/src/storage/sqlite/config-repository.js +1 -1
- package/dist/src/storage/sqlite/connection-wait-repository.js +2 -2
- package/dist/src/storage/sqlite/index.js +2 -2
- package/dist/src/storage/sqlite/migrations/151_proactive_scope_cleanup.sql +6 -0
- package/dist/src/storage/sqlite/migrations/152_proactive_scenario_contract.sql +140 -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/row-mappers.js +2 -2
- package/dist/src/storage/sqlite/schema.js +1 -1
- package/dist/src/storage/sqlite/session-input-repository.js +1 -1
- package/dist/src/storage/sqlite/session-instance-repository.d.ts +2 -0
- package/dist/src/storage/sqlite/session-instance-repository.js +6 -0
- package/dist/src/storage/sqlite/session-repository.d.ts +1 -1
- package/dist/src/storage/sqlite/session-repository.js +3 -5
- package/dist/src/storage/sqlite/transcript-repository.js +2 -1
- package/dist/src/tasks/home-query-service.js +35 -13
- package/dist/src/tasks/project-monitoring-service.d.ts +2 -0
- package/dist/src/tasks/project-monitoring-service.js +4 -1
- package/dist/src/tui/backends/embedded-backend.js +1 -1
- package/dist/src/user-context/access-policy.d.ts +11 -0
- package/dist/src/user-context/access-policy.js +26 -0
- package/dist/src/user-model/capture/executor.d.ts +10 -0
- package/dist/src/user-model/capture/executor.js +99 -3
- package/dist/src/user-model/capture/semantic.d.ts +18 -0
- package/dist/src/user-model/capture/semantic.js +72 -6
- package/dist/src/user-model/goals.d.ts +4 -0
- package/dist/src/user-model/goals.js +4 -2
- package/package.json +3 -3
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-C1rXNUAG.js +0 -1
- package/dist/gateway/static/root/assets/automations-workspace-BKjKTlW8.js +0 -6
- package/dist/gateway/static/root/assets/browser-settings-page-Dzq18pO1.js +0 -8
- package/dist/gateway/static/root/assets/capabilities-settings-panel-DW4SBQf4.js +0 -7
- package/dist/gateway/static/root/assets/channels-settings-57OGuewD.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-CT_I3kbR.js +0 -2
- package/dist/gateway/static/root/assets/files-D6vf3S30.js +0 -1
- package/dist/gateway/static/root/assets/heartbeat-settings-DNhrZHqx.js +0 -1
- package/dist/gateway/static/root/assets/home-page-BiHwiBnQ.js +0 -1
- package/dist/gateway/static/root/assets/index-aBs0EfQB.js +0 -72
- package/dist/gateway/static/root/assets/messages-W5P19VTF.js +0 -11
- package/dist/gateway/static/root/assets/note-detail-panel-CEEvR-fV.js +0 -5
- package/dist/gateway/static/root/assets/notes-page-BLqgXNCx.js +0 -8
- package/dist/gateway/static/root/assets/project-detail-page-CIiFJ5tk.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-B3UF-Pfm.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-BUtpkJPG.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-UgJmG-V4.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-DDCzpdkl.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-BdsqnCYj.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-ghzAQKna.js +0 -1
- package/dist/gateway/static/root/assets/task-detail-page-BQAUaCDD.js +0 -1
- package/dist/gateway/static/root/assets/user-model-page-W3GTm6nA.js +0 -2
- package/dist/gateway/static/root/assets/workflows-page-BbAV3h7n.js +0 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./rolldown-runtime-aKtaBQYM.js";import{a as e,n as t,t as n}from"./vendor-react-BOUWij0V.js";import{n as r,r as i}from"./popover-select-C-Hj-nXR.js";import{t as a}from"./cn-JdwAhgNB.js";import{Xa as o,qa as s}from"./index-aBs0EfQB.js";var c=t();e();var l=n();function u(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function d(e){let t=e[`x-order`];return typeof t==`number`&&!Number.isNaN(t)?t:999}function f(e){let t=e[`x-group`];return typeof t==`string`&&t.length>0?t:``}function p(e){return e[`x-hidden`]===!0}function m(e){let t=e.properties;if(!u(t))return[];let n=[];for(let[e,r]of Object.entries(t))u(r)&&(p(r)||n.push({key:e,sub:r,order:d(r),group:f(r),hidden:!1}));return n.sort((e,t)=>e.order-t.order||e.key.localeCompare(t.key)),n}function h(e){let t=new Map;for(let n of e){let e=n.group;t.has(e)||t.set(e,[]),t.get(e).push(n)}return t}function g(e){let t=(0,c.c)(38),{name:n,s:i,value:a,onChange:u,disabled:d}=e,f=typeof i.description==`string`?i.description:void 0,p=(typeof i[`x-placeholder`]==`string`?i[`x-placeholder`]:null)||f,m=i.format;if(Array.isArray(i.enum)&&i.enum.every(v)){let e;t[0]===f?e=t[1]:(e=f?(0,l.jsx)(`label`,{className:`text-xs text-fg-muted`,children:f}):null,t[0]=f,t[1]=e);let o;t[2]===u?o=t[3]:(o=e=>u(e.target.value),t[2]=u,t[3]=o);let s;t[4]===i.enum?s=t[5]:(s=i.enum.map(_),t[4]=i.enum,t[5]=s);let c;t[6]!==d||t[7]!==n||t[8]!==o||t[9]!==s||t[10]!==a?(c=(0,l.jsx)(r,{name:n,className:`ui-input h-9 rounded-md border border-edge bg-surface-base px-2 text-sm text-fg`,value:a,disabled:d,onChange:o,children:s}),t[6]=d,t[7]=n,t[8]=o,t[9]=s,t[10]=a,t[11]=c):c=t[11];let p;return t[12]!==e||t[13]!==c?(p=(0,l.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[e,c]}),t[12]=e,t[13]=c,t[14]=p):p=t[14],p}if(m===`password`){let e;t[15]===f?e=t[16]:(e=f?(0,l.jsx)(`label`,{className:`text-xs text-fg-muted`,children:f}):null,t[15]=f,t[16]=e);let n;t[17]!==d||t[18]!==u||t[19]!==p||t[20]!==a?(n=(0,l.jsx)(o,{value:a,onChange:u,placeholder:p,labels:s,disabled:d,inputClassName:`ui-input h-9 rounded-md border border-edge bg-surface-base px-2.5 text-sm text-fg placeholder:text-fg-muted/70`}),t[17]=d,t[18]=u,t[19]=p,t[20]=a,t[21]=n):n=t[21];let r;return t[22]!==e||t[23]!==n?(r=(0,l.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[e,n]}),t[22]=e,t[23]=n,t[24]=r):r=t[24],r}let h;t[25]===f?h=t[26]:(h=f?(0,l.jsx)(`label`,{className:`text-xs text-fg-muted`,children:f}):null,t[25]=f,t[26]=h);let g;t[27]===u?g=t[28]:(g=e=>u(e.target.value),t[27]=u,t[28]=g);let y;t[29]!==d||t[30]!==n||t[31]!==p||t[32]!==g||t[33]!==a?(y=(0,l.jsx)(`input`,{name:n,type:`text`,className:`ui-input h-9 rounded-md border border-edge bg-surface-base px-2.5 text-sm text-fg placeholder:text-fg-muted/70`,value:a,placeholder:p,disabled:d,onChange:g}),t[29]=d,t[30]=n,t[31]=p,t[32]=g,t[33]=a,t[34]=y):y=t[34];let b;return t[35]!==h||t[36]!==y?(b=(0,l.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[h,y]}),t[35]=h,t[36]=y,t[37]=b):b=t[37],b}function _(e){return(0,l.jsx)(i,{value:e,children:e},e)}function v(e){return typeof e==`string`}function y(e){let t=(0,c.c)(11),{s:n,value:r,onChange:i,disabled:a}=e,o=typeof n.description==`string`?n.description:void 0,s;t[0]===o?s=t[1]:(s=o?(0,l.jsx)(`label`,{className:`text-xs text-fg-muted`,children:o}):null,t[0]=o,t[1]=s);let u=Number.isFinite(r)?r:0,d;t[2]===i?d=t[3]:(d=e=>i(Number(e.target.value)),t[2]=i,t[3]=d);let f;t[4]!==a||t[5]!==u||t[6]!==d?(f=(0,l.jsx)(`input`,{type:`number`,className:`ui-input h-9 rounded-md border border-edge bg-surface-base px-2.5 text-sm text-fg`,value:u,disabled:a,onChange:d}),t[4]=a,t[5]=u,t[6]=d,t[7]=f):f=t[7];let p;return t[8]!==s||t[9]!==f?(p=(0,l.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[s,f]}),t[8]=s,t[9]=f,t[10]=p):p=t[10],p}function b(e){let t=(0,c.c)(11),{s:n,value:r,onChange:i,disabled:a,labels:o}=e,s=(typeof n.description==`string`?n.description:void 0)??(typeof n.title==`string`&&n.title.length>0?n.title:o?.defaultBooleanLabel??`Enable`),u;t[0]===i?u=t[1]:(u=e=>i(e.target.checked),t[0]=i,t[1]=u);let d;t[2]!==a||t[3]!==u||t[4]!==r?(d=(0,l.jsx)(`input`,{type:`checkbox`,className:`size-4 rounded border border-edge`,checked:r,disabled:a,onChange:u}),t[2]=a,t[3]=u,t[4]=r,t[5]=d):d=t[5];let f;t[6]===s?f=t[7]:(f=(0,l.jsx)(`span`,{children:s}),t[6]=s,t[7]=f);let p;return t[8]!==d||t[9]!==f?(p=(0,l.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg`,children:[d,f]}),t[8]=d,t[9]=f,t[10]=p):p=t[10],p}function x(e){let t=(0,c.c)(27),{s:n,value:r,onChange:i,disabled:a,labels:o}=e,s=typeof n.description==`string`?n.description:void 0,d=n.items,f=u(d)?d.type:void 0;if(!(f===`string`||Array.isArray(f)&&f.includes(`string`))){let e=o?.unsupportedArrayType??`Unsupported array type`,n;return t[0]===e?n=t[1]:(n=(0,l.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e}),t[0]=e,t[1]=n),n}let p,m,h,g,_;if(t[2]!==s||t[3]!==a||t[4]!==i||t[5]!==r){let e=r.map(String);p=t=>{let n=t.trim();!n||e.includes(n)||i([...e,n])},g=`flex flex-col gap-1.5`,t[11]===s?_=t[12]:(_=s?(0,l.jsx)(`label`,{className:`text-xs text-fg-muted`,children:s}):null,t[11]=s,t[12]=_),m=`flex flex-wrap gap-1`,h=e.map(t=>(0,l.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-edge bg-surface-panel px-2 py-0.5 text-sm`,children:[t,(0,l.jsx)(`button`,{type:`button`,className:`text-fg-muted hover:text-fg`,disabled:a,onClick:()=>i(e.filter(e=>e!==t)),children:`×`})]},t)),t[2]=s,t[3]=a,t[4]=i,t[5]=r,t[6]=p,t[7]=m,t[8]=h,t[9]=g,t[10]=_}else p=t[6],m=t[7],h=t[8],g=t[9],_=t[10];let v;t[13]!==m||t[14]!==h?(v=(0,l.jsx)(`div`,{className:m,children:h}),t[13]=m,t[14]=h,t[15]=v):v=t[15];let y=o?.arrayAddPlaceholder??`Add and press Enter`,b;t[16]===p?b=t[17]:(b=e=>{e.key===`Enter`&&(e.preventDefault(),p(e.target.value),e.target.value=``)},t[16]=p,t[17]=b);let x;t[18]!==a||t[19]!==y||t[20]!==b?(x=(0,l.jsx)(`input`,{className:`ui-input h-9 rounded-md border border-edge bg-surface-base px-2.5 text-sm`,disabled:a,placeholder:y,onKeyDown:b}),t[18]=a,t[19]=y,t[20]=b,t[21]=x):x=t[21];let S;return t[22]!==g||t[23]!==_||t[24]!==v||t[25]!==x?(S=(0,l.jsxs)(`div`,{className:g,children:[_,v,x]}),t[22]=g,t[23]=_,t[24]=v,t[25]=x,t[26]=S):S=t[26],S}function S(e){let t=(0,c.c)(66),{k:n,sub:r,value:i,onValue:a,disabled:o,labels:s}=e,d=r.type,f=(typeof r.title==`string`&&r.title.length>0?r.title:null)??n;if(d===`boolean`){let e;t[0]===f?e=t[1]:(e=(0,l.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:f}),t[0]=f,t[1]=e);let n=i===!0,c;t[2]===a?c=t[3]:(c=e=>a(e),t[2]=a,t[3]=c);let u;t[4]!==o||t[5]!==s||t[6]!==r||t[7]!==n||t[8]!==c?(u=(0,l.jsx)(b,{s:r,value:n,disabled:o,onChange:c,labels:s}),t[4]=o,t[5]=s,t[6]=r,t[7]=n,t[8]=c,t[9]=u):u=t[9];let d;return t[10]!==e||t[11]!==u?(d=(0,l.jsxs)(`div`,{className:`space-y-1.5`,children:[e,u]}),t[10]=e,t[11]=u,t[12]=d):d=t[12],d}if(d===`number`||d===`integer`){let e;t[13]===f?e=t[14]:(e=(0,l.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:f}),t[13]=f,t[14]=e);let n=typeof i==`number`?i:0,s;t[15]!==o||t[16]!==a||t[17]!==r||t[18]!==n?(s=(0,l.jsx)(y,{s:r,value:n,disabled:o,onChange:a}),t[15]=o,t[16]=a,t[17]=r,t[18]=n,t[19]=s):s=t[19];let c;return t[20]!==e||t[21]!==s?(c=(0,l.jsxs)(`div`,{className:`space-y-1.5`,children:[e,s]}),t[20]=e,t[21]=s,t[22]=c):c=t[22],c}if(d===`string`){let e;t[23]===f?e=t[24]:(e=(0,l.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:f}),t[23]=f,t[24]=e);let s=typeof i==`string`?i:``,c;t[25]!==o||t[26]!==n||t[27]!==a||t[28]!==r||t[29]!==s?(c=(0,l.jsx)(g,{name:n,s:r,value:s,disabled:o,onChange:a}),t[25]=o,t[26]=n,t[27]=a,t[28]=r,t[29]=s,t[30]=c):c=t[30];let u;return t[31]!==e||t[32]!==c?(u=(0,l.jsxs)(`div`,{className:`space-y-1.5`,children:[e,c]}),t[31]=e,t[32]=c,t[33]=u):u=t[33],u}if(d===`array`){let e=r.items,n=u(e)?e.type:void 0;if(n===`string`||Array.isArray(n)&&n.includes(`string`)){let e;t[34]===f?e=t[35]:(e=(0,l.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:f}),t[34]=f,t[35]=e);let n;t[36]===i?n=t[37]:(n=Array.isArray(i)&&i.every(C)?i.map(String):[],t[36]=i,t[37]=n);let c;t[38]!==o||t[39]!==s||t[40]!==a||t[41]!==r||t[42]!==n?(c=(0,l.jsx)(x,{s:r,value:n,disabled:o,onChange:a,labels:s}),t[38]=o,t[39]=s,t[40]=a,t[41]=r,t[42]=n,t[43]=c):c=t[43];let u;return t[44]!==e||t[45]!==c?(u=(0,l.jsxs)(`div`,{className:`space-y-1.5`,children:[e,c]}),t[44]=e,t[45]=c,t[46]=u):u=t[46],u}}if(d===`object`){let e;t[47]===i?e=t[48]:(e=u(i)?i:{},t[47]=i,t[48]=e);let n=e,c;t[49]===f?c=t[50]:(c=(0,l.jsx)(`summary`,{className:`cursor-pointer select-none px-3 py-2 text-sm font-medium text-fg group-open:rounded-b-none`,children:f}),t[49]=f,t[50]=c);let d;t[51]!==o||t[52]!==s||t[53]!==n||t[54]!==a||t[55]!==r?(d=(0,l.jsx)(`div`,{className:`border-t border-edge p-3`,children:(0,l.jsx)(w,{schema:r,values:n,onChange:a,disabled:o,labels:s})}),t[51]=o,t[52]=s,t[53]=n,t[54]=a,t[55]=r,t[56]=d):d=t[56];let p;return t[57]!==c||t[58]!==d?(p=(0,l.jsxs)(`details`,{className:`group rounded-lg border border-edge bg-surface-panel/40 open:bg-surface-base`,open:!0,children:[c,d]}),t[57]=c,t[58]=d,t[59]=p):p=t[59],p}let p;t[60]!==s||t[61]!==d||t[62]!==f?(p=s?.unsupportedFieldType?.(f,typeof d==`string`?d:void 0)??`${f}: unsupported field type${typeof d==`string`?` (${d})`:``}`,t[60]=s,t[61]=d,t[62]=f,t[63]=p):p=t[63];let m;return t[64]===p?m=t[65]:(m=(0,l.jsx)(`p`,{className:`text-xs text-fg-muted`,children:p}),t[64]=p,t[65]=m),m}function C(e){return typeof e==`string`||typeof e==`number`}function w(e){let t=(0,c.c)(28),{schema:n,values:r,onChange:i,disabled:o,className:s,labels:d}=e,f=o===void 0?!1:o,p;bb0:{if(n.type!==`object`){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[0]=e):e=t[0],p=e;break bb0}let e;t[1]===n?e=t[2]:(e=m(n),t[1]=n,t[2]=e),p=e}let g=p,_;bb1:{if(g.length===0){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=new Map,t[3]=e):e=t[3],_=e;break bb1}let e;t[4]===g?e=t[5]:(e=h(g),t[4]=g,t[5]=e),_=e}let v=_,y;t[6]!==i||t[7]!==r?(y=(e,t)=>{i({...r,[e]:t})},t[6]=i,t[7]=r,t[8]=y):y=t[8];let b=y;if(n.type!==`object`||!u(n.properties)||g.length===0)return null;let x,C;if(t[9]!==s||t[10]!==f||t[11]!==v||t[12]!==d||t[13]!==b||t[14]!==r){let e=Array.from(v.keys()).sort(T);t[17]===s?x=t[18]:(x=a(`flex flex-col gap-4`,s),t[17]=s,t[18]=x);let n;t[19]!==f||t[20]!==v||t[21]!==d||t[22]!==b||t[23]!==r?(n=e=>{let t=(v.get(e)??[]).map(e=>(0,l.jsx)(S,{k:e.key,sub:e.sub,value:r[e.key],onValue:t=>b(e.key,t),disabled:f,labels:d},e.key));return e===``?(0,l.jsx)(`div`,{children:t},`default`):(0,l.jsxs)(`details`,{className:`group rounded-lg border border-edge bg-surface-panel/40 open:bg-surface-base`,open:!0,children:[(0,l.jsx)(`summary`,{className:`cursor-pointer select-none px-3 py-2 text-sm font-medium text-fg group-open:rounded-b-none`,children:e}),(0,l.jsx)(`div`,{className:`space-y-4 border-t border-edge p-3`,children:t})]},e)},t[19]=f,t[20]=v,t[21]=d,t[22]=b,t[23]=r,t[24]=n):n=t[24],C=e.map(n),t[9]=s,t[10]=f,t[11]=v,t[12]=d,t[13]=b,t[14]=r,t[15]=x,t[16]=C}else x=t[15],C=t[16];let w;return t[25]!==x||t[26]!==C?(w=(0,l.jsx)(`div`,{className:x,children:C}),t[25]=x,t[26]=C,t[27]=w):w=t[27],w}function T(e,t){return e===``?-1:t===``?1:e.localeCompare(t)}export{w as t};
|
|
1
|
+
import"./rolldown-runtime-aKtaBQYM.js";import{a as e,n as t,t as n}from"./vendor-react-BOUWij0V.js";import{n as r,r as i}from"./popover-select-C-Hj-nXR.js";import{t as a}from"./cn-JdwAhgNB.js";import{Qa as o,Ya as s}from"./index-BcaF-dgQ.js";var c=t();e();var l=n();function u(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function d(e){let t=e[`x-order`];return typeof t==`number`&&!Number.isNaN(t)?t:999}function f(e){let t=e[`x-group`];return typeof t==`string`&&t.length>0?t:``}function p(e){return e[`x-hidden`]===!0}function m(e){let t=e.properties;if(!u(t))return[];let n=[];for(let[e,r]of Object.entries(t))u(r)&&(p(r)||n.push({key:e,sub:r,order:d(r),group:f(r),hidden:!1}));return n.sort((e,t)=>e.order-t.order||e.key.localeCompare(t.key)),n}function h(e){let t=new Map;for(let n of e){let e=n.group;t.has(e)||t.set(e,[]),t.get(e).push(n)}return t}function g(e){let t=(0,c.c)(38),{name:n,s:i,value:a,onChange:u,disabled:d}=e,f=typeof i.description==`string`?i.description:void 0,p=(typeof i[`x-placeholder`]==`string`?i[`x-placeholder`]:null)||f,m=i.format;if(Array.isArray(i.enum)&&i.enum.every(v)){let e;t[0]===f?e=t[1]:(e=f?(0,l.jsx)(`label`,{className:`text-xs text-fg-muted`,children:f}):null,t[0]=f,t[1]=e);let o;t[2]===u?o=t[3]:(o=e=>u(e.target.value),t[2]=u,t[3]=o);let s;t[4]===i.enum?s=t[5]:(s=i.enum.map(_),t[4]=i.enum,t[5]=s);let c;t[6]!==d||t[7]!==n||t[8]!==o||t[9]!==s||t[10]!==a?(c=(0,l.jsx)(r,{name:n,className:`ui-input h-9 rounded-md border border-edge bg-surface-base px-2 text-sm text-fg`,value:a,disabled:d,onChange:o,children:s}),t[6]=d,t[7]=n,t[8]=o,t[9]=s,t[10]=a,t[11]=c):c=t[11];let p;return t[12]!==e||t[13]!==c?(p=(0,l.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[e,c]}),t[12]=e,t[13]=c,t[14]=p):p=t[14],p}if(m===`password`){let e;t[15]===f?e=t[16]:(e=f?(0,l.jsx)(`label`,{className:`text-xs text-fg-muted`,children:f}):null,t[15]=f,t[16]=e);let n;t[17]!==d||t[18]!==u||t[19]!==p||t[20]!==a?(n=(0,l.jsx)(o,{value:a,onChange:u,placeholder:p,labels:s,disabled:d,inputClassName:`ui-input h-9 rounded-md border border-edge bg-surface-base px-2.5 text-sm text-fg placeholder:text-fg-muted/70`}),t[17]=d,t[18]=u,t[19]=p,t[20]=a,t[21]=n):n=t[21];let r;return t[22]!==e||t[23]!==n?(r=(0,l.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[e,n]}),t[22]=e,t[23]=n,t[24]=r):r=t[24],r}let h;t[25]===f?h=t[26]:(h=f?(0,l.jsx)(`label`,{className:`text-xs text-fg-muted`,children:f}):null,t[25]=f,t[26]=h);let g;t[27]===u?g=t[28]:(g=e=>u(e.target.value),t[27]=u,t[28]=g);let y;t[29]!==d||t[30]!==n||t[31]!==p||t[32]!==g||t[33]!==a?(y=(0,l.jsx)(`input`,{name:n,type:`text`,className:`ui-input h-9 rounded-md border border-edge bg-surface-base px-2.5 text-sm text-fg placeholder:text-fg-muted/70`,value:a,placeholder:p,disabled:d,onChange:g}),t[29]=d,t[30]=n,t[31]=p,t[32]=g,t[33]=a,t[34]=y):y=t[34];let b;return t[35]!==h||t[36]!==y?(b=(0,l.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[h,y]}),t[35]=h,t[36]=y,t[37]=b):b=t[37],b}function _(e){return(0,l.jsx)(i,{value:e,children:e},e)}function v(e){return typeof e==`string`}function y(e){let t=(0,c.c)(11),{s:n,value:r,onChange:i,disabled:a}=e,o=typeof n.description==`string`?n.description:void 0,s;t[0]===o?s=t[1]:(s=o?(0,l.jsx)(`label`,{className:`text-xs text-fg-muted`,children:o}):null,t[0]=o,t[1]=s);let u=Number.isFinite(r)?r:0,d;t[2]===i?d=t[3]:(d=e=>i(Number(e.target.value)),t[2]=i,t[3]=d);let f;t[4]!==a||t[5]!==u||t[6]!==d?(f=(0,l.jsx)(`input`,{type:`number`,className:`ui-input h-9 rounded-md border border-edge bg-surface-base px-2.5 text-sm text-fg`,value:u,disabled:a,onChange:d}),t[4]=a,t[5]=u,t[6]=d,t[7]=f):f=t[7];let p;return t[8]!==s||t[9]!==f?(p=(0,l.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[s,f]}),t[8]=s,t[9]=f,t[10]=p):p=t[10],p}function b(e){let t=(0,c.c)(11),{s:n,value:r,onChange:i,disabled:a,labels:o}=e,s=(typeof n.description==`string`?n.description:void 0)??(typeof n.title==`string`&&n.title.length>0?n.title:o?.defaultBooleanLabel??`Enable`),u;t[0]===i?u=t[1]:(u=e=>i(e.target.checked),t[0]=i,t[1]=u);let d;t[2]!==a||t[3]!==u||t[4]!==r?(d=(0,l.jsx)(`input`,{type:`checkbox`,className:`size-4 rounded border border-edge`,checked:r,disabled:a,onChange:u}),t[2]=a,t[3]=u,t[4]=r,t[5]=d):d=t[5];let f;t[6]===s?f=t[7]:(f=(0,l.jsx)(`span`,{children:s}),t[6]=s,t[7]=f);let p;return t[8]!==d||t[9]!==f?(p=(0,l.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg`,children:[d,f]}),t[8]=d,t[9]=f,t[10]=p):p=t[10],p}function x(e){let t=(0,c.c)(27),{s:n,value:r,onChange:i,disabled:a,labels:o}=e,s=typeof n.description==`string`?n.description:void 0,d=n.items,f=u(d)?d.type:void 0;if(!(f===`string`||Array.isArray(f)&&f.includes(`string`))){let e=o?.unsupportedArrayType??`Unsupported array type`,n;return t[0]===e?n=t[1]:(n=(0,l.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e}),t[0]=e,t[1]=n),n}let p,m,h,g,_;if(t[2]!==s||t[3]!==a||t[4]!==i||t[5]!==r){let e=r.map(String);p=t=>{let n=t.trim();!n||e.includes(n)||i([...e,n])},g=`flex flex-col gap-1.5`,t[11]===s?_=t[12]:(_=s?(0,l.jsx)(`label`,{className:`text-xs text-fg-muted`,children:s}):null,t[11]=s,t[12]=_),m=`flex flex-wrap gap-1`,h=e.map(t=>(0,l.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-edge bg-surface-panel px-2 py-0.5 text-sm`,children:[t,(0,l.jsx)(`button`,{type:`button`,className:`text-fg-muted hover:text-fg`,disabled:a,onClick:()=>i(e.filter(e=>e!==t)),children:`×`})]},t)),t[2]=s,t[3]=a,t[4]=i,t[5]=r,t[6]=p,t[7]=m,t[8]=h,t[9]=g,t[10]=_}else p=t[6],m=t[7],h=t[8],g=t[9],_=t[10];let v;t[13]!==m||t[14]!==h?(v=(0,l.jsx)(`div`,{className:m,children:h}),t[13]=m,t[14]=h,t[15]=v):v=t[15];let y=o?.arrayAddPlaceholder??`Add and press Enter`,b;t[16]===p?b=t[17]:(b=e=>{e.key===`Enter`&&(e.preventDefault(),p(e.target.value),e.target.value=``)},t[16]=p,t[17]=b);let x;t[18]!==a||t[19]!==y||t[20]!==b?(x=(0,l.jsx)(`input`,{className:`ui-input h-9 rounded-md border border-edge bg-surface-base px-2.5 text-sm`,disabled:a,placeholder:y,onKeyDown:b}),t[18]=a,t[19]=y,t[20]=b,t[21]=x):x=t[21];let S;return t[22]!==g||t[23]!==_||t[24]!==v||t[25]!==x?(S=(0,l.jsxs)(`div`,{className:g,children:[_,v,x]}),t[22]=g,t[23]=_,t[24]=v,t[25]=x,t[26]=S):S=t[26],S}function S(e){let t=(0,c.c)(66),{k:n,sub:r,value:i,onValue:a,disabled:o,labels:s}=e,d=r.type,f=(typeof r.title==`string`&&r.title.length>0?r.title:null)??n;if(d===`boolean`){let e;t[0]===f?e=t[1]:(e=(0,l.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:f}),t[0]=f,t[1]=e);let n=i===!0,c;t[2]===a?c=t[3]:(c=e=>a(e),t[2]=a,t[3]=c);let u;t[4]!==o||t[5]!==s||t[6]!==r||t[7]!==n||t[8]!==c?(u=(0,l.jsx)(b,{s:r,value:n,disabled:o,onChange:c,labels:s}),t[4]=o,t[5]=s,t[6]=r,t[7]=n,t[8]=c,t[9]=u):u=t[9];let d;return t[10]!==e||t[11]!==u?(d=(0,l.jsxs)(`div`,{className:`space-y-1.5`,children:[e,u]}),t[10]=e,t[11]=u,t[12]=d):d=t[12],d}if(d===`number`||d===`integer`){let e;t[13]===f?e=t[14]:(e=(0,l.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:f}),t[13]=f,t[14]=e);let n=typeof i==`number`?i:0,s;t[15]!==o||t[16]!==a||t[17]!==r||t[18]!==n?(s=(0,l.jsx)(y,{s:r,value:n,disabled:o,onChange:a}),t[15]=o,t[16]=a,t[17]=r,t[18]=n,t[19]=s):s=t[19];let c;return t[20]!==e||t[21]!==s?(c=(0,l.jsxs)(`div`,{className:`space-y-1.5`,children:[e,s]}),t[20]=e,t[21]=s,t[22]=c):c=t[22],c}if(d===`string`){let e;t[23]===f?e=t[24]:(e=(0,l.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:f}),t[23]=f,t[24]=e);let s=typeof i==`string`?i:``,c;t[25]!==o||t[26]!==n||t[27]!==a||t[28]!==r||t[29]!==s?(c=(0,l.jsx)(g,{name:n,s:r,value:s,disabled:o,onChange:a}),t[25]=o,t[26]=n,t[27]=a,t[28]=r,t[29]=s,t[30]=c):c=t[30];let u;return t[31]!==e||t[32]!==c?(u=(0,l.jsxs)(`div`,{className:`space-y-1.5`,children:[e,c]}),t[31]=e,t[32]=c,t[33]=u):u=t[33],u}if(d===`array`){let e=r.items,n=u(e)?e.type:void 0;if(n===`string`||Array.isArray(n)&&n.includes(`string`)){let e;t[34]===f?e=t[35]:(e=(0,l.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:f}),t[34]=f,t[35]=e);let n;t[36]===i?n=t[37]:(n=Array.isArray(i)&&i.every(C)?i.map(String):[],t[36]=i,t[37]=n);let c;t[38]!==o||t[39]!==s||t[40]!==a||t[41]!==r||t[42]!==n?(c=(0,l.jsx)(x,{s:r,value:n,disabled:o,onChange:a,labels:s}),t[38]=o,t[39]=s,t[40]=a,t[41]=r,t[42]=n,t[43]=c):c=t[43];let u;return t[44]!==e||t[45]!==c?(u=(0,l.jsxs)(`div`,{className:`space-y-1.5`,children:[e,c]}),t[44]=e,t[45]=c,t[46]=u):u=t[46],u}}if(d===`object`){let e;t[47]===i?e=t[48]:(e=u(i)?i:{},t[47]=i,t[48]=e);let n=e,c;t[49]===f?c=t[50]:(c=(0,l.jsx)(`summary`,{className:`cursor-pointer select-none px-3 py-2 text-sm font-medium text-fg group-open:rounded-b-none`,children:f}),t[49]=f,t[50]=c);let d;t[51]!==o||t[52]!==s||t[53]!==n||t[54]!==a||t[55]!==r?(d=(0,l.jsx)(`div`,{className:`border-t border-edge p-3`,children:(0,l.jsx)(w,{schema:r,values:n,onChange:a,disabled:o,labels:s})}),t[51]=o,t[52]=s,t[53]=n,t[54]=a,t[55]=r,t[56]=d):d=t[56];let p;return t[57]!==c||t[58]!==d?(p=(0,l.jsxs)(`details`,{className:`group rounded-lg border border-edge bg-surface-panel/40 open:bg-surface-base`,open:!0,children:[c,d]}),t[57]=c,t[58]=d,t[59]=p):p=t[59],p}let p;t[60]!==s||t[61]!==d||t[62]!==f?(p=s?.unsupportedFieldType?.(f,typeof d==`string`?d:void 0)??`${f}: unsupported field type${typeof d==`string`?` (${d})`:``}`,t[60]=s,t[61]=d,t[62]=f,t[63]=p):p=t[63];let m;return t[64]===p?m=t[65]:(m=(0,l.jsx)(`p`,{className:`text-xs text-fg-muted`,children:p}),t[64]=p,t[65]=m),m}function C(e){return typeof e==`string`||typeof e==`number`}function w(e){let t=(0,c.c)(28),{schema:n,values:r,onChange:i,disabled:o,className:s,labels:d}=e,f=o===void 0?!1:o,p;bb0:{if(n.type!==`object`){let e;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=[],t[0]=e):e=t[0],p=e;break bb0}let e;t[1]===n?e=t[2]:(e=m(n),t[1]=n,t[2]=e),p=e}let g=p,_;bb1:{if(g.length===0){let e;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(e=new Map,t[3]=e):e=t[3],_=e;break bb1}let e;t[4]===g?e=t[5]:(e=h(g),t[4]=g,t[5]=e),_=e}let v=_,y;t[6]!==i||t[7]!==r?(y=(e,t)=>{i({...r,[e]:t})},t[6]=i,t[7]=r,t[8]=y):y=t[8];let b=y;if(n.type!==`object`||!u(n.properties)||g.length===0)return null;let x,C;if(t[9]!==s||t[10]!==f||t[11]!==v||t[12]!==d||t[13]!==b||t[14]!==r){let e=Array.from(v.keys()).sort(T);t[17]===s?x=t[18]:(x=a(`flex flex-col gap-4`,s),t[17]=s,t[18]=x);let n;t[19]!==f||t[20]!==v||t[21]!==d||t[22]!==b||t[23]!==r?(n=e=>{let t=(v.get(e)??[]).map(e=>(0,l.jsx)(S,{k:e.key,sub:e.sub,value:r[e.key],onValue:t=>b(e.key,t),disabled:f,labels:d},e.key));return e===``?(0,l.jsx)(`div`,{children:t},`default`):(0,l.jsxs)(`details`,{className:`group rounded-lg border border-edge bg-surface-panel/40 open:bg-surface-base`,open:!0,children:[(0,l.jsx)(`summary`,{className:`cursor-pointer select-none px-3 py-2 text-sm font-medium text-fg group-open:rounded-b-none`,children:e}),(0,l.jsx)(`div`,{className:`space-y-4 border-t border-edge p-3`,children:t})]},e)},t[19]=f,t[20]=v,t[21]=d,t[22]=b,t[23]=r,t[24]=n):n=t[24],C=e.map(n),t[9]=s,t[10]=f,t[11]=v,t[12]=d,t[13]=b,t[14]=r,t[15]=x,t[16]=C}else x=t[15],C=t[16];let w;return t[25]!==x||t[26]!==C?(w=(0,l.jsx)(`div`,{className:x,children:C}),t[25]=x,t[26]=C,t[27]=w):w=t[27],w}function T(e,t){return e===``?-1:t===``?1:e.localeCompare(t)}export{w as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{p as i}from"./chunk-KS7C4IRE-BaASWQor.js";import{a,n as o,o as s,r as c,s as l,t as u}from"./dist-CpzYSoz7.js";import{n as d,r as f}from"./popover-select-C-Hj-nXR.js";import{t as p}from"./download-Dk-ZjtO6.js";import{t as m}from"./plus-Q2yW6OE7.js";import{t as h}from"./x-B_N4OPjy.js";import{t as g}from"./messages-Cf5hpZE6.js";import{a as _,n as v,r as y,s as b}from"./locale-store-CF4erhjB.js";import{t as x}from"./cn-JdwAhgNB.js";import{i as S}from"./vendor-swr-BIWyz7Rc.js";import{t as C}from"./button-CtTvuElV.js";import{n as w,r as T}from"./gateway-config-swr-CMNbl0FZ.js";import{t as E}from"./skeleton-BwbyijEw.js";import{i as ee,o as D}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{n as O,t as k}from"./registry-api-BsRBlji7.js";import{Ai as A,Fi as j,Ht as M,Ko as N,Li as P,Mc as F,Mi as I,Ml as L,Ni as R,Ns as z,P as te,Pc as B,Pi as V,Qc as H,Ri as U,Su as W,Ut as G,Wl as ne,Zc as re,ac as ie,bc as ae,bl as oe,ca as se,el as ce,ga as le,io as K,ji as ue,ki as de,oa as q,qo as J,sa as fe,tc as Y,xc as pe,xu as me,ys as he,z as ge}from"./index-BcaF-dgQ.js";import{n as _e,t as ve}from"./settings-form-section-DVY-8_B9.js";import{n as ye,t as be}from"./use-autosave-CV3Ui5hu.js";import{t as xe}from"./page-tabs-CX9T71by.js";import{t as Se}from"./settings-advanced-gate-DYYoJcl7.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:s,onAction:c}=e,l;t[0]!==i.unnamedSession||t[1]!==n.name?(l=n.name?.trim()||i.unnamedSession,t[0]=i.unnamedSession,t[1]=n.name,t[2]=l):l=t[2];let u=l,d;t[3]===n.name?d=t[4]:(d=n.name?.trim(),t[3]=n.name,t[4]=d);let f=!!d,m=n.status===`archived`,h=n.status===`pinned`,g=r===`list`&&`sm:flex-row sm:items-center sm:gap-4`,_;t[5]===g?_=t[6]:(_=x(`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`,g),t[5]=g,t[6]=_);let v;t[7]===s?v=t[8]:(v=e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),s())},t[7]=s,t[8]=v);let y=r===`list`&&`sm:py-3`,b;t[9]===y?b=t[10]:(b=x(`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 S;t[11]===n.sourceChannel?S=t[12]:(S=(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]=S);let C;t[13]===h?C=t[14]:(C=h?(0,Z.jsx)(pe,{className:`size-3.5 text-accent-fg`,strokeWidth:1.75,"aria-hidden":!0}):null,t[13]=h,t[14]=C);let w;t[15]===n.updatedAt?w=t[16]:(w=we(n.updatedAt),t[15]=n.updatedAt,t[16]=w);let T;t[17]===w?T=t[18]:(T=(0,Z.jsx)(`span`,{children:w}),t[17]=w,t[18]=T);let E;t[19]!==T||t[20]!==C?(E=(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5 text-xs text-fg-muted`,children:[C,T]}),t[19]=T,t[20]=C,t[21]=E):E=t[21];let ee;t[22]!==E||t[23]!==b||t[24]!==S?(ee=(0,Z.jsxs)(`div`,{className:b,children:[S,E]}),t[22]=E,t[23]=b,t[24]=S,t[25]=ee):ee=t[25];let D=r===`list`&&`sm:py-3`,O;t[26]===D?O=t[27]:(O=x(`min-w-0 flex-1 px-3 py-2`,D),t[26]=D,t[27]=O);let k=r===`list`&&`sm:items-start`,A;t[28]===k?A=t[29]:(A=x(`flex gap-3`,k),t[28]=k,t[29]=A);let j;t[30]!==o||t[31]!==a?(j=(0,Z.jsx)(te,{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]=j):j=t[32];let M;t[33]===u?M=t[34]:(M=(0,Z.jsx)(`div`,{className:`min-w-0 max-w-full truncate text-sm font-semibold text-fg`,title:u,children:u}),t[33]=u,t[34]=M);let P;t[35]!==n.key||t[36]!==f?(P=f?(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]=f,t[37]=P):P=t[37];let F;t[38]!==M||t[39]!==P?(F=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[M,P]}),t[38]=M,t[39]=P,t[40]=F):F=t[40];let I;t[41]!==A||t[42]!==j||t[43]!==F?(I=(0,Z.jsxs)(`div`,{className:A,children:[j,F]}),t[41]=A,t[42]=j,t[43]=F,t[44]=I):I=t[44];let L;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,Z.jsx)(B,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[45]=L):L=t[45];let R;t[46]===n.messageCount?R=t[47]:(R=(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[L,n.messageCount]}),t[46]=n.messageCount,t[47]=R);let V;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,Z.jsx)(he,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[48]=V):V=t[48];let H;t[49]===n.estimatedTokens?H=t[50]:(H=Te(n.estimatedTokens),t[49]=n.estimatedTokens,t[50]=H);let U;t[51]===H?U=t[52]:(U=(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[V,H]}),t[51]=H,t[52]=U);let G;t[53]!==R||t[54]!==U?(G=(0,Z.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-3 text-xs text-fg-muted`,children:[R,U]}),t[53]=R,t[54]=U,t[55]=G):G=t[55];let ne;t[56]===n.tags?ne=t[57]:(ne=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]=ne);let re;t[58]!==O||t[59]!==I||t[60]!==G||t[61]!==ne?(re=(0,Z.jsxs)(`div`,{className:O,children:[I,G,ne]}),t[58]=O,t[59]=I,t[60]=G,t[61]=ne,t[62]=re):re=t[62];let ie;t[63]===c?ie=t[64]:(ie=()=>c(`continue`),t[63]=c,t[64]=ie);let oe;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(oe=(0,Z.jsx)(B,{className:`size-4`,strokeWidth:1.75}),t[65]=oe):oe=t[65];let se;t[66]!==i.continueChat||t[67]!==ie?(se=(0,Z.jsx)(`button`,{type:`button`,className:N,title:i.continueChat,"aria-label":i.continueChat,onClick:ie,children:oe}),t[66]=i.continueChat,t[67]=ie,t[68]=se):se=t[68];let ce;t[69]!==m||t[70]!==i.archive||t[71]!==i.unarchive||t[72]!==c?(ce=m?(0,Z.jsx)(`button`,{type:`button`,className:N,title:i.unarchive,"aria-label":i.unarchive,onClick:()=>c(`unarchive`),children:(0,Z.jsx)(W,{className:`size-4`,strokeWidth:1.75})}):(0,Z.jsx)(`button`,{type:`button`,className:N,title:i.archive,"aria-label":i.archive,onClick:()=>c(`archive`),children:(0,Z.jsx)(me,{className:`size-4`,strokeWidth:1.75})}),t[69]=m,t[70]=i.archive,t[71]=i.unarchive,t[72]=c,t[73]=ce):ce=t[73];let le;t[74]!==h||t[75]!==i.pin||t[76]!==i.unpin||t[77]!==c?(le=h?(0,Z.jsx)(`button`,{type:`button`,className:N,title:i.unpin,"aria-label":i.unpin,onClick:()=>c(`unpin`),children:(0,Z.jsx)(ae,{className:`size-4`,strokeWidth:1.75})}):(0,Z.jsx)(`button`,{type:`button`,className:N,title:i.pin,"aria-label":i.pin,onClick:()=>c(`pin`),children:(0,Z.jsx)(pe,{className:`size-4`,strokeWidth:1.75})}),t[74]=h,t[75]=i.pin,t[76]=i.unpin,t[77]=c,t[78]=le):le=t[78];let K;t[79]===c?K=t[80]:(K=()=>c(`export`),t[79]=c,t[80]=K);let ue;t[81]===Symbol.for(`react.memo_cache_sentinel`)?(ue=(0,Z.jsx)(p,{className:`size-4`,strokeWidth:1.75}),t[81]=ue):ue=t[81];let de;t[82]!==i.export||t[83]!==K?(de=(0,Z.jsx)(`button`,{type:`button`,className:N,title:i.export,"aria-label":i.export,onClick:K,children:ue}),t[82]=i.export,t[83]=K,t[84]=de):de=t[84];let q;t[85]===Symbol.for(`react.memo_cache_sentinel`)?(q=x(N,`text-red-600 hover:bg-red-50 dark:text-red-400 dark:hover:bg-red-950/40`),t[85]=q):q=t[85];let J;t[86]===c?J=t[87]:(J=()=>c(`delete`),t[86]=c,t[87]=J);let fe;t[88]===Symbol.for(`react.memo_cache_sentinel`)?(fe=(0,Z.jsx)(z,{className:`size-4`,strokeWidth:1.75}),t[88]=fe):fe=t[88];let Y;t[89]!==i.delete||t[90]!==J?(Y=(0,Z.jsx)(`button`,{type:`button`,className:q,title:i.delete,"aria-label":i.delete,onClick:J,children:fe}),t[89]=i.delete,t[90]=J,t[91]=Y):Y=t[91];let ge;t[92]!==se||t[93]!==ce||t[94]!==le||t[95]!==de||t[96]!==Y?(ge=(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:[se,ce,le,de,Y]}),t[92]=se,t[93]=ce,t[94]=le,t[95]=de,t[96]=Y,t[97]=ge):ge=t[97];let _e;return t[98]!==s||t[99]!==ee||t[100]!==re||t[101]!==_||t[102]!==ge||t[103]!==v?(_e=(0,Z.jsxs)(`div`,{role:`button`,tabIndex:0,className:_,onClick:s,onKeyDown:v,children:[ee,re,ge]}),t[98]=s,t[99]=ee,t[100]=re,t[101]=_,t[102]=ge,t[103]=v,t[104]=_e):_e=t[104],_e}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.contextPlanning)?n.contextPlanning:{},i=Ne(r.compaction)?r.compaction:{},a=Me,o=typeof i.model==`string`&&i.model.trim()?i.model.trim():void 0,s=Array.isArray(i.postCompactionSections)&&i.postCompactionSections.length<=12&&i.postCompactionSections.every(e=>typeof e==`string`&&e.trim())?[...new Set(i.postCompactionSections.map(e=>e.trim()))]:[...a.postCompactionSections];return{enabled:typeof i.enabled==`boolean`?i.enabled:a.enabled,triggerThreshold:Pe(i.triggerThreshold,a.triggerThreshold,.1,.98),reserveTokens:Q(i.reserveTokens,a.reserveTokens,1024),minMessagesBeforeCompact:Q(i.minMessagesBeforeCompact,a.minMessagesBeforeCompact,2),keepRecentTokens:Q(i.keepRecentTokens,a.keepRecentTokens,1e3),recentTurnsPreserve:Q(i.recentTurnsPreserve,a.recentTurnsPreserve,1,12),summaryMaxTokens:Q(i.summaryMaxTokens,a.summaryMaxTokens,256),summaryChunkTokens:Q(i.summaryChunkTokens,a.summaryChunkTokens,1e3),summaryTimeoutMs:Q(i.summaryTimeoutMs,a.summaryTimeoutMs,1e3,6e5),summaryRetries:Q(i.summaryRetries,a.summaryRetries,0,5),qualityGuard:typeof i.qualityGuard==`boolean`?i.qualityGuard:a.qualityGuard,gapAudit:typeof i.gapAudit==`boolean`?i.gapAudit:a.gapAudit,...o?{model:o}:{},minToolResultKeepChars:Q(i.minToolResultKeepChars,a.minToolResultKeepChars,200),maxActiveTranscriptBytes:Q(i.maxActiveTranscriptBytes,a.maxActiveTranscriptBytes,64e3),postCompactionSections:s}}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:{contextPlanning:{compaction:t}}}}async function Re(e){await _(y(`/api/config`),{method:`PATCH`,body:JSON.stringify(Le(e))}),await w()}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 x(`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`,K,`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=x(`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 u;t[4]!==i||t[5]!==a||t[6]!==l?(u=(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]=u):u=t[7];let d;t[8]===n?d=t[9]:(d=(0,Z.jsx)(`span`,{className:`font-medium`,children:n}),t[8]=n,t[9]=d);let f;t[10]===r?f=t[11]:(f=(0,Z.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:r}),t[10]=r,t[11]=f);let p;t[12]!==d||t[13]!==f?(p=(0,Z.jsxs)(`span`,{children:[d,f]}),t[12]=d,t[13]=f,t[14]=p):p=t[14];let m;return t[15]!==c||t[16]!==u||t[17]!==p?(m=(0,Z.jsxs)(`label`,{className:c,children:[u,p]}),t[15]=c,t[16]=u,t[17]=p,t[18]=m):m=t[18],m}function qe({hasToken:e}){let t=g(v(e=>e.language)).sessions.compaction,{data:n,isLoading:r}=T(e),{data:i=[],isLoading:a}=S(e?k:null,O,{revalidateOnFocus:!1}),o=(0,X.useMemo)(()=>n?.payload?.config===void 0?null:Fe(n.payload.config),[n]),[s,c]=(0,X.useReducer)(Ve,{form:null,baseline:null}),[l,u]=(0,X.useState)(``),d=(0,X.useRef)(!1),f=(0,X.useRef)(s.form);f.current=s.form;let p=(0,X.useRef)(null);fe({enabled:e,parsed:o,dirty:d.current,trackedParsedRef:p,dispatch:c,onResetDirty:()=>{d.current=!1}});let _=s.form,y=s.baseline,b=!!(_&&y&&JSON.stringify(_)!==JSON.stringify(y)),w=(0,X.useCallback)(e=>{d.current=!0,c({type:`patch`,patch:e})},[]),ee=(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]),D=be({value:_,dirty:b,onSave:(0,X.useCallback)(async e=>{try{await Re(e),c({type:`saved`,value:e}),d.current=!!(f.current&&JSON.stringify(f.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}}`,ee(n)):null}});if(!e||!_)return r?(0,Z.jsx)(ve,{children:(0,Z.jsxs)(`div`,{className:`space-y-3`,"aria-busy":!0,children:[(0,Z.jsx)(E,{className:`h-5 w-48`}),(0,Z.jsx)(E,{className:`h-20 w-full rounded-xl`}),(0,Z.jsx)(E,{className:`h-36 w-full rounded-xl`})]})}):null;let A=We(_),j=Math.max(0,ze-_.reserveTokens),M=Math.min(Math.floor(ze*_.triggerThreshold),j),N=Math.min(100,M/ze*100),P=Math.min(100,j/ze*100),I=_.model?i.find(e=>e.id===_.model):void 0,L=I?.contextWindow&&_.summaryChunkTokens+_.summaryMaxTokens+4096>I.contextWindow,R=_.keepRecentTokens+_.reserveTokens>M,z=Math.round(_.summaryTimeoutMs*(_.summaryRetries+1)/1e3),te=e=>{let t=Be[e];w({...t,..._.model?{model:_.model}:{model:void 0},postCompactionSections:_.postCompactionSections})},B={balanced:{title:t.presetBalanced,hint:t.presetBalancedHint},preserve:{title:t.presetPreserve,hint:t.presetPreserveHint},early:{title:t.presetEarly,hint:t.presetEarlyHint}},V=()=>{let e=l.trim();!e||_.postCompactionSections.includes(e)||_.postCompactionSections.length>=12||(w({postCompactionSections:[..._.postCompactionSections,e]}),u(``))};return(0,Z.jsxs)(ve,{onBlurCapture:D.onBlurCapture,children:[(0,Z.jsx)(_e,{icon:F,title:t.title,subtitle:t.hint,trailing:(0,Z.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Z.jsx)(ye,{status:D.status,error:D.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:_.enabled,onChange:e=>w({enabled:e.target.checked})}),_.enabled?t.enabled:t.disabled]})]})}),D.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:D.error}):null,_.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:!_.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})]}),A===`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":A===e,className:x(`rounded-xl border px-3 py-3 text-left`,J.transition,J.focusRingPanel,A===e?`border-accent/50 bg-accent-soft text-accent-fg`:`border-edge bg-surface-panel text-fg hover:bg-surface-hover`),onClick:()=>te(e),children:[(0,Z.jsx)(`span`,{className:`block text-sm font-medium`,children:B[e].title}),(0,Z.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:B[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(M)})]}),(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:`${N}%`}})})]}),(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(j)})]}),(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:`${P}%`}})})]})]}),(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((_.triggerThreshold*100).toFixed(2)),min:10,max:98,step:.1,onChange:e=>w({triggerThreshold:e/100})}),(0,Z.jsx)($,{id:`compaction-reserve-tokens`,label:t.reserveTokens,hint:t.reserveTokensHint.replace(`{{tokens}}`,Ge(_.reserveTokens)),value:_.reserveTokens,min:1024,step:1024,onChange:e=>w({reserveTokens:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-recent-turns`,label:t.recentTurnsPreserve,hint:t.recentTurnsPreserveHint,value:_.recentTurnsPreserve,min:1,max:12,onChange:e=>w({recentTurnsPreserve:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-keep-recent-tokens`,label:t.keepRecentTokens,hint:t.keepRecentTokensHint.replace(`{{tokens}}`,Ge(_.keepRecentTokens)),value:_.keepRecentTokens,min:1e3,step:1e3,onChange:e=>w({keepRecentTokens:Math.floor(e)})})]}),R?(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)(ge,{value:_.model??``,disabled:!_.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=>w({model:e})}),_.model?(0,Z.jsx)(C,{type:`button`,variant:`secondary`,onClick:()=>w({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:_.qualityGuard,onChange:e=>w({qualityGuard:e})}),(0,Z.jsx)(Ke,{label:t.gapAudit,hint:t.gapAuditHint,checked:_.gapAudit,onChange:e=>w({gapAudit:e})})]}),_.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)(Se,{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:_.minMessagesBeforeCompact,min:2,onChange:e=>w({minMessagesBeforeCompact:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-max-transcript-mb`,label:t.maxActiveTranscriptMb,hint:t.maxActiveTranscriptMbHint,value:Number((_.maxActiveTranscriptBytes/1e6).toFixed(3)),min:.064,step:.1,onChange:e=>w({maxActiveTranscriptBytes:Math.max(64e3,Math.round(e*1e6))})}),(0,Z.jsx)($,{id:`compaction-summary-max-tokens`,label:t.summaryMaxTokens,hint:t.summaryMaxTokensHint,value:_.summaryMaxTokens,min:256,step:256,onChange:e=>w({summaryMaxTokens:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-summary-chunk-tokens`,label:t.summaryChunkTokens,hint:t.summaryChunkTokensHint,value:_.summaryChunkTokens,min:1e3,step:1e3,onChange:e=>w({summaryChunkTokens:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-summary-timeout`,label:t.summaryTimeoutSeconds,hint:t.summaryTimeoutSecondsHint.replace(`{{seconds}}`,String(z)),value:_.summaryTimeoutMs/1e3,min:1,max:600,onChange:e=>w({summaryTimeoutMs:Math.round(e*1e3)})}),(0,Z.jsx)($,{id:`compaction-summary-retries`,label:t.summaryRetries,hint:t.summaryRetriesHint,value:_.summaryRetries,min:0,max:5,onChange:e=>w({summaryRetries:Math.floor(e)})}),(0,Z.jsx)($,{id:`compaction-min-tool-result-chars`,label:t.minToolResultKeepChars,hint:t.minToolResultKeepCharsHint,value:_.minToolResultKeepChars,min:200,step:100,onChange:e=>w({minToolResultKeepChars:Math.floor(e)})})]}),L?(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}),_.postCompactionSections.length>0?(0,Z.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:_.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:x(`text-fg-muted hover:text-fg`,J.press),"aria-label":t.removeSection.replace(`{{section}}`,e),onClick:()=>w({postCompactionSections:_.postCompactionSections.filter(t=>t!==e)}),children:(0,Z.jsx)(h,{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:l,maxLength:120,disabled:_.postCompactionSections.length>=12,placeholder:t.postCompactionSectionsPlaceholder,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),V())}}),(0,Z.jsxs)(C,{type:`button`,variant:`secondary`,disabled:!l.trim()||_.postCompactionSections.length>=12,onClick:V,children:[(0,Z.jsx)(m,{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 _(y(`/api/config`),{method:`PATCH`,body:JSON.stringify({session:{dmScope:e.dmScope,storage:{pruneAfterMs:e.pruneAfterDays===null?null:e.pruneAfterDays*864e5,maxEntries:e.maxEntries}}})}),w()}function Qe(){return x(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,K,`dark:border-edge`)}var $e=q();function et({hasToken:e}){let t=g(v(e=>e.language)).sessions.config,{data:n,isLoading:r}=T(e),i=(0,X.useMemo)(()=>n?.payload?.config===void 0?null:Xe(n.payload.config),[n]),[a,o]=(0,X.useReducer)($e,{form:null,baseline:null}),s=a.form,c=a.baseline,l=(0,X.useRef)(!1),u=(0,X.useRef)(s);u.current=s;let p=(0,X.useRef)(null);fe({enabled:e,parsed:i,dirty:l.current,trackedParsedRef:p,dispatch:o,onResetDirty:()=>{l.current=!1}});let m=!!(s&&c&&JSON.stringify(s)!==JSON.stringify(c)),h=(0,X.useCallback)(e=>{l.current=!0,o({type:`patch`,patch:e})},[]),_=be({value:s,dirty:m,onSave:(0,X.useCallback)(async e=>{try{await Ze(e),o({type:`saved`,value:e}),l.current=!!(u.current&&JSON.stringify(u.current)!==JSON.stringify(e))}catch(e){throw Error(e instanceof Error?e.message:t.saveError)}},[t.saveError])});return!e||!s?r?(0,Z.jsx)(ve,{children:(0,Z.jsxs)(`div`,{className:`space-y-3`,"aria-busy":!0,children:[(0,Z.jsx)(E,{className:`h-5 w-40`}),(0,Z.jsx)(E,{className:`h-24 w-full rounded-xl`})]})}):null:(0,Z.jsxs)(ve,{onBlurCapture:_.onBlurCapture,children:[(0,Z.jsx)(_e,{icon:L,title:t.title,subtitle:t.hint,trailing:(0,Z.jsx)(ye,{status:_.status,error:_.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)(d,{className:Qe(),value:s.dmScope,onChange:e=>h({dmScope:e.target.value}),children:[(0,Z.jsx)(f,{value:`main`,children:t.dmScopeMain}),(0,Z.jsx)(f,{value:`per-peer`,children:t.dmScopePerPeer}),(0,Z.jsx)(f,{value:`per-channel-peer`,children:t.dmScopePerChannelPeer}),(0,Z.jsx)(f,{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:s.pruneAfterDays??``,placeholder:t.unsetPlaceholder,onChange:e=>{let t=e.target.value.trim();h({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:s.maxEntries??``,placeholder:t.unsetPlaceholder,onChange:e=>{let t=e.target.value.trim();h({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:d,sessionAgentAvatar:f,labels:p,onClose:m,onArchive:g,onUnarchive:_,onPin:v,onUnpin:y,onExport:b,onDelete:S}=e,w=i?.status===`archived`,T=i?.status===`pinned`,E;t[0]===m?E=t[1]:(E=e=>!e&&m(),t[0]=m,t[1]=E);let O;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,Z.jsx)(a,{className:x(`xopc-dialog-overlay fixed inset-0 bg-scrim`,D)}),t[2]=O):O=t[2];let k;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(k=x(`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`,ee,`dark:border-edge`),t[3]=k):k=t[3];let A;t[4]!==i||t[5]!==f||t[6]!==d?(A=i&&d?(0,Z.jsx)(te,{agentId:d,avatar:f,size:40,className:`size-10 shrink-0 ring-1 ring-edge/60 dark:ring-edge`}):null,t[4]=i,t[5]=f,t[6]=d,t[7]=A):A=t[7];let j;t[8]!==p.unnamedSession||t[9]!==i?.name?(j=i?.name?.trim()||p.unnamedSession,t[8]=p.unnamedSession,t[9]=i?.name,t[10]=j):j=t[10];let M;t[11]===j?M=t[12]:(M=(0,Z.jsx)(l,{className:`min-w-0 flex-1 truncate text-base font-semibold tracking-tight text-fg`,children:j}),t[11]=j,t[12]=M);let N;t[13]!==A||t[14]!==M?(N=(0,Z.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[A,M]}),t[13]=A,t[14]=M,t[15]=N):N=t[15];let P;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,Z.jsx)(h,{className:`size-5`,strokeWidth:1.75}),t[16]=P):P=t[16];let F;t[17]===p.close?F=t[18]:(F=(0,Z.jsx)(o,{asChild:!0,children:(0,Z.jsx)(C,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":p.close,children:P})}),t[17]=p.close,t[18]=F);let I;t[19]!==N||t[20]!==F?(I=(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:[N,F]}),t[19]=N,t[20]=F,t[21]=I):I=t[21];let L;t[22]!==p.detailLoading||t[23]!==p.detailMessages||t[24]!==r||t[25]!==i?(L=r?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:p.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:p.detailMessages}),(0,Z.jsx)(`ul`,{className:`space-y-3`,children:i.messages.map(rt)})]}):null,t[22]=p.detailLoading,t[23]=p.detailMessages,t[24]=r,t[25]=i,t[26]=L):L=t[26];let R;t[27]===L?R=t[28]:(R=(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-4 py-3`,children:L}),t[27]=L,t[28]=R);let z;t[29]!==p.detailExport||t[30]!==b?(z=(0,Z.jsx)(C,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:b,children:p.detailExport}),t[29]=p.detailExport,t[30]=b,t[31]=z):z=t[31];let B;t[32]!==w||t[33]!==p.archive||t[34]!==p.unarchive||t[35]!==g||t[36]!==_?(B=w?(0,Z.jsx)(C,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:_,children:p.unarchive}):(0,Z.jsx)(C,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:g,children:p.archive}),t[32]=w,t[33]=p.archive,t[34]=p.unarchive,t[35]=g,t[36]=_,t[37]=B):B=t[37];let V;t[38]!==T||t[39]!==p.pin||t[40]!==p.unpin||t[41]!==v||t[42]!==y?(V=T?(0,Z.jsx)(C,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:y,children:p.unpin}):(0,Z.jsx)(C,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:v,children:p.pin}),t[38]=T,t[39]=p.pin,t[40]=p.unpin,t[41]=v,t[42]=y,t[43]=V):V=t[43];let H;t[44]!==p.delete||t[45]!==S?(H=(0,Z.jsx)(C,{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:p.delete}),t[44]=p.delete,t[45]=S,t[46]=H):H=t[46];let U;t[47]!==z||t[48]!==B||t[49]!==V||t[50]!==H?(U=(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:[z,B,V,H]})}),t[47]=z,t[48]=B,t[49]=V,t[50]=H,t[51]=U):U=t[51];let W;t[52]!==I||t[53]!==R||t[54]!==U?(W=(0,Z.jsxs)(s,{children:[O,(0,Z.jsxs)(c,{className:k,"aria-describedby":void 0,children:[I,R,U]})]}),t[52]=I,t[53]=R,t[54]=U,t[55]=W):W=t[55];let G;return t[56]!==n||t[57]!==E||t[58]!==W?(G=(0,Z.jsx)(u,{open:n,onOpenChange:E,children:W}),t[56]=n,t[57]=E,t[58]=W,t[59]=G):G=t[59],G}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`?ce:Y})),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)(xe,{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=g(v(e=>e.language)),t=e.sessions,n=b(e=>e.token),r=!!n,{data:o,mutate:d}=S(r?[`gateway-chat-agents`,n]:null,le,{revalidateOnFocus:!1}),f=o?.defaultId??`main`,p=o?.items??[],[m,h]=i(),_=lt(m.get(`tab`)),y=(0,X.useCallback)(e=>{let t=new URLSearchParams(m);e===`sessions`?t.delete(`tab`):t.set(`tab`,e),h(t,{replace:!0})},[m,h]),[w,T]=(0,X.useReducer)(se,m,mt),{searchInput:E,debouncedSearch:O,statusFilter:k,viewMode:N,channelFilter:F,sessions:L,loading:z,error:te,hasMore:B,stats:W,detailOpen:ae,detailLoading:K,detailSession:q,confirmOpen:fe,confirmKey:Y}=w;(0,X.useEffect)(()=>{let e=setTimeout(()=>{let e=E.trim();O!==e&&T({type:`patch`,patch:{debouncedSearch:e}})},300);return()=>clearTimeout(e)},[E,O]);let he=m.toString(),ge=(0,X.useRef)(he);if(ge.current!==he){ge.current=he;let e=m.get(`q`)??``,t=m.get(`status`),n=m.get(`view`),r=(m.get(`channel`)??``).trim(),i=ot.has(t)?t:`all`,a=st.has(n)?n:`grid`,o=e.trim();T({type:`patch`,patch:{...E===e?{}:{searchInput:e},...O===o?{}:{debouncedSearch:o},...k===i?{}:{statusFilter:i},...N===a?{}:{viewMode:a},...F===r?{}:{channelFilter:r}}})}(0,X.useEffect)(()=>{let e=new URLSearchParams(m),t=O.trim();t?e.set(`q`,t):e.delete(`q`),k===`all`?e.delete(`status`):e.set(`status`,k),N===`grid`?e.delete(`view`):e.set(`view`,N),F?e.set(`channel`,F):e.delete(`channel`),e.toString()!==m.toString()&&h(e,{replace:!0})},[O,m,h,k,N,F]),(0,X.useEffect)(()=>{if(!r||_!==`sessions`)return;let e=!1;return(async()=>{T({type:`patch`,patch:{loading:!0,error:null}});try{let t=await V({limit:it,offset:0,...O?{search:O}:{},...k===`all`?{}:{status:k},...F?{channel:F}:{}});if(e)return;T({type:`patch`,patch:{sessions:t.items,hasMore:t.hasMore}})}catch(n){e||T({type:`patch`,patch:{error:n instanceof Error?n.message:t.loadError}})}finally{e||T({type:`patch`,patch:{loading:!1}})}})(),()=>{e=!0}},[r,_,O,k,F,t.loadError]),(0,X.useEffect)(()=>{!r||_!==`sessions`||R().then(e=>T({type:`patch`,patch:{stats:e}})).catch(()=>{})},[r,_]),(0,X.useEffect)(()=>{if(!r||_!==`sessions`)return;let e=()=>void d();return window.addEventListener(`config-reload`,e),()=>window.removeEventListener(`config-reload`,e)},[r,_,d]),(0,X.useEffect)(()=>{if(!r||_!==`sessions`)return;let e=e=>{let t=e.detail;!t?.key||t.name===void 0||T({type:`patch`,patch:{sessions:L.map(e=>e.key===t.key?{...e,name:t.name}:e),detailSession:q&&q.key===t.key?{...q,name:t.name}:q}})};return window.addEventListener(`session-updated`,e),()=>{window.removeEventListener(`session-updated`,e)}},[r,_,L,q]);let _e=(0,X.useCallback)(async()=>{if(!(!r||z||!B)){T({type:`patch`,patch:{loading:!0,error:null}});try{let e=await V({limit:it,offset:L.length,...O?{search:O}:{},...k===`all`?{}:{status:k},...F?{channel:F}:{}});T({type:`patch`,patch:{sessions:[...L,...e.items],hasMore:e.hasMore}})}catch(e){T({type:`patch`,patch:{error:e instanceof Error?e.message:t.loadError}})}finally{T({type:`patch`,patch:{loading:!1}})}}},[r,z,B,L.length,O,k,F,t.loadError]),ve=(0,X.useCallback)((e,t)=>{T({type:`patch`,patch:{sessions:L.map(n=>n.key===e?{...n,status:t}:n),detailSession:q&&q.key===e?{...q,status:t}:q}})},[L,q]),ye=(0,X.useCallback)(async e=>{T({type:`patch`,patch:{detailOpen:!0,detailLoading:!0,detailSession:null}});try{T({type:`patch`,patch:{detailSession:await I(e)}})}catch{T({type:`patch`,patch:{detailOpen:!1}})}finally{T({type:`patch`,patch:{detailLoading:!1}})}},[]),be=e=>{ye(e)},xe=async(e,t)=>{if(t===`continue`){window.dispatchEvent(new CustomEvent(`navigate-to-chat`,{detail:{sessionKey:e},bubbles:!0}));return}if(t===`delete`){T({type:`patch`,patch:{confirmKey:e,confirmOpen:!0}});return}try{switch(t){case`archive`:await de(e),ve(e,`archived`);break;case`unarchive`:await P(e),ve(e,`active`);break;case`pin`:await j(e),ve(e,`pinned`);break;case`unpin`:await U(e),ve(e,`active`);break;case`export`:{let t=await ue(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}R().then(e=>T({type:`patch`,patch:{stats:e}})).catch(()=>{})}catch{}},Se=async e=>{try{await A(e),T({type:`patch`,patch:{sessions:L.filter(t=>t.key!==e),detailSession:q?.key===e?null:q,...q?.key===e?{detailOpen:!1}:{}}}),R().then(e=>T({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:ce},{key:`active`,label:t.filterActive,icon:ne},{key:`pinned`,label:t.filterPinned,icon:pe},{key:`archived`,label:t.filterArchived,icon:me}],De=(()=>{let e=Object.entries(W?.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:_,onChange:y}),(0,Z.jsx)(pt,{s:t,id:`settings`,activeTab:_,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:_,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":k===e,onClick:()=>T({type:`patch`,patch:{statusFilter:e}}),className:x(`inline-flex items-center gap-1.5 rounded-xl px-3 py-2 text-sm font-medium`,J.transition,J.focusRingPanel,k===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)(ie,{className:`size-4 shrink-0 text-fg-disabled`,strokeWidth:1.75,"aria-hidden":!0}),(0,Z.jsx)(`input`,{type:`search`,value:E,onChange:e=>T({type:`patch`,patch:{searchInput:e.target.value}}),placeholder:t.searchPlaceholder,"data-debounced-query":O||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":!F,onClick:()=>T({type:`patch`,patch:{channelFilter:``}}),className:x(`inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,J.transition,J.focusRingPanel,F?`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":F===e,onClick:()=>T({type:`patch`,patch:{channelFilter:e}}),className:x(`inline-flex items-center rounded-xl px-3 py-2 text-sm font-medium`,J.transition,J.focusRingPanel,F===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,W?.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:W.byChannel[e]})]},e))]}),W?(0,Z.jsx)(`div`,{className:`grid grid-cols-2 gap-3 sm:grid-cols-4`,children:[[W.totalSessions,t.totalSessions],[W.activeSessions,t.activeSessions],[W.pinnedSessions,t.pinnedSessions],[W.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,te?(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:te}):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:L.length})}),(0,Z.jsxs)(`div`,{className:G,role:`group`,"aria-label":t.layoutToggleGroup,children:[(0,Z.jsx)(C,{type:`button`,variant:`segmented`,title:t.gridView,"aria-pressed":N===`grid`,onClick:()=>T({type:`patch`,patch:{viewMode:`grid`}}),className:x(M,`size-7 p-0`,N===`grid`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,N===`grid`&&`text-accent-fg`),children:(0,Z.jsx)(H,{className:`size-3.5`,strokeWidth:1.5})}),(0,Z.jsx)(C,{type:`button`,variant:`segmented`,title:t.listView,"aria-pressed":N===`list`,onClick:()=>T({type:`patch`,patch:{viewMode:`list`}}),className:x(M,`size-9 p-0`,N===`list`&&`bg-surface-panel shadow-sm dark:bg-surface-panel dark:shadow-sm dark:ring-1 dark:ring-edge-strong/40`,N===`list`&&`text-accent-fg`),children:(0,Z.jsx)(re,{className:`size-3.5`,strokeWidth:1.5})})]})]}),z&&L.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))}):L.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)(oe,{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)(C,{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:x(`grid min-w-0 gap-3`,N===`grid`?`sm:grid-cols-2 lg:grid-cols-3`:`grid-cols-1`),"data-debounced-query":O||void 0,children:L.map(e=>{let t=Ae(e,f);return(0,Z.jsx)(Ee,{session:e,variant:N,labels:Ce,sessionAgentId:t,sessionAgentAvatar:je(t,p),onOpen:()=>be(e.key),onAction:t=>void xe(e.key,t)},e.key)})}),B?(0,Z.jsx)(`div`,{className:`flex justify-center pt-2`,children:(0,Z.jsx)(C,{type:`button`,variant:`secondary`,disabled:z,onClick:()=>void _e(),children:t.loadMore})}):null]})]})]}),(0,Z.jsx)(nt,{open:ae,loading:K,session:q,sessionAgentId:q?Ae(q,f):void 0,sessionAgentAvatar:q?je(Ae(q,f),p):void 0,labels:we,onClose:()=>{T({type:`patch`,patch:{detailOpen:!1,detailSession:null}})},onArchive:()=>q&&void xe(q.key,`archive`),onUnarchive:()=>q&&void xe(q.key,`unarchive`),onPin:()=>q&&void xe(q.key,`pin`),onUnpin:()=>q&&void xe(q.key,`unpin`),onExport:()=>q&&void xe(q.key,`export`),onDelete:()=>q&&T({type:`patch`,patch:{confirmKey:q.key,confirmOpen:!0}})}),(0,Z.jsx)(u,{open:fe,onOpenChange:e=>T({type:`patch`,patch:{confirmOpen:e}}),children:(0,Z.jsxs)(s,{children:[(0,Z.jsx)(a,{className:x(`xopc-dialog-overlay fixed inset-0 bg-scrim`,D)}),(0,Z.jsxs)(c,{className:x(`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`,ee),children:[(0,Z.jsx)(l,{className:`text-base font-semibold text-fg`,children:t.deleteSessionTitle}),(0,Z.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:Y?at(t.deleteSessionMessage,{name:L.find(e=>e.key===Y)?.name?.trim()||e.chat.newSession}):``}),(0,Z.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,Z.jsx)(C,{type:`button`,variant:`secondary`,onClick:()=>T({type:`patch`,patch:{confirmOpen:!1}}),children:t.cancel}),(0,Z.jsx)(C,{type:`button`,variant:`primary`,className:`bg-red-600 hover:bg-red-700`,onClick:()=>{Y&&Se(Y),T({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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{bn as e}from"./index-BcaF-dgQ.js";function t(t){let{children:n,fallback:r}=t,i=r===void 0?null:r;return e()?n:i}export{t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./cn-JdwAhgNB.js";import{
|
|
1
|
+
import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./cn-JdwAhgNB.js";import{Sc as r,qo as i}from"./index-BcaF-dgQ.js";var a=e();function o(){return`rounded-2xl border border-edge-subtle bg-surface-base px-4 py-5 sm:px-5`}var s=t();function c(e){let t=(0,a.c)(7),{children:r,className:i,id:c,onBlurCapture:l}=e,u;t[0]===i?u=t[1]:(u=n(o(),i),t[0]=i,t[1]=u);let d;return t[2]!==r||t[3]!==c||t[4]!==l||t[5]!==u?(d=(0,s.jsx)(`section`,{id:c,className:u,onBlurCapture:l,children:r}),t[2]=r,t[3]=c,t[4]=l,t[5]=u,t[6]=d):d=t[6],d}var l=`flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-hover/90 text-fg-muted transition-colors dark:bg-surface-hover/70`;function u(e){let t=(0,a.c)(29),{icon:o,title:c,subtitle:u,trailing:d,titleAccessory:f,className:p,iconInteractive:m,iconLeading:h}=e,g;t[0]===o?g=t[1]:(g=(0,s.jsx)(o,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[0]=o,t[1]=g);let _=h??g,v;t[2]===h?v=t[3]:(v=h?n(`flex size-9 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-surface-panel p-0 ring-1 ring-inset ring-edge-subtle transition-[box-shadow] hover:ring-accent/40 dark:ring-edge-subtle`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,i.press):n(l,`hover:text-fg`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`,i.press),t[2]=h,t[3]=v);let y=v,b=!!(m&&h),x;t[4]===p?x=t[5]:(x=n(`mb-5 flex items-start gap-3`,p),t[4]=p,t[5]=x);let S;t[6]!==m||t[7]!==h||t[8]!==_||t[9]!==y||t[10]!==b?(S=m?b?(0,s.jsxs)(`span`,{className:`relative shrink-0`,children:[(0,s.jsx)(`button`,{type:`button`,id:m.id,onClick:m.onClick,"aria-label":m.ariaLabel,className:y,children:_}),(0,s.jsx)(`span`,{className:`pointer-events-none absolute -bottom-0.5 -right-0.5 flex size-4 items-center justify-center rounded-md border border-edge bg-surface-panel text-fg-muted shadow-sm dark:border-edge dark:bg-surface-base`,"aria-hidden":!0,children:(0,s.jsx)(r,{className:`size-2.5`,strokeWidth:2.25})})]}):(0,s.jsx)(`button`,{type:`button`,id:m.id,onClick:m.onClick,"aria-label":m.ariaLabel,className:y,children:_}):(0,s.jsx)(`div`,{className:n(h?`flex size-9 shrink-0 items-center justify-center overflow-hidden rounded-lg bg-surface-panel ring-1 ring-inset ring-edge-subtle dark:ring-edge-subtle`:l),"aria-hidden":!h,children:_}),t[6]=m,t[7]=h,t[8]=_,t[9]=y,t[10]=b,t[11]=S):S=t[11];let C;t[12]===c?C=t[13]:(C=(0,s.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:c}),t[12]=c,t[13]=C);let w;t[14]!==C||t[15]!==f?(w=(0,s.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1.5`,children:[C,f]}),t[14]=C,t[15]=f,t[16]=w):w=t[16];let T;t[17]===u?T=t[18]:(T=u?(0,s.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:u}):null,t[17]=u,t[18]=T);let E;t[19]!==w||t[20]!==T?(E=(0,s.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[w,T]}),t[19]=w,t[20]=T,t[21]=E):E=t[21];let D;t[22]===d?D=t[23]:(D=d?(0,s.jsx)(`div`,{className:`shrink-0`,children:d}):null,t[22]=d,t[23]=D);let O;return t[24]!==x||t[25]!==S||t[26]!==E||t[27]!==D?(O=(0,s.jsxs)(`div`,{className:x,children:[S,E,D]}),t[24]=x,t[25]=S,t[26]=E,t[27]=D,t[28]=O):O=t[28],O}export{u as n,o as r,c as t};
|
package/dist/gateway/static/root/assets/{settings-page-S8ekeUZd.js → settings-page-CdiVYyTl.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
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,r as a}from"./chunk-KS7C4IRE-BaASWQor.js";import{t as o}from"./messages-
|
|
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,r as a}from"./chunk-KS7C4IRE-BaASWQor.js";import{t as o}from"./messages-Cf5hpZE6.js";import{n as s}from"./locale-store-CF4erhjB.js";import{Aa as c,Da as l,Fa as u,Ia as d,La as f,Ma as p,Na as m,Oa as h,Pa as g,Ra as _,ja as v,ka as y,za as b}from"./index-BcaF-dgQ.js";var x=n(),S=e(t(),1),C=r(),w=[`overview`,`appearance`,`keyboard-shortcuts`,`system`,`desktop-pet`,`desktop-app`,`agent-defaults`,`gateway`,`runtimes`,`devices`,`heartbeat`,`remote-access`,`shares`],T=(0,S.lazy)(()=>f().then(e=>({default:e.SetupStatusPanel}))),E=(0,S.lazy)(()=>y().then(e=>({default:e.AppearanceSettingsPanel}))),D=(0,S.lazy)(()=>g().then(e=>({default:e.KeyboardShortcutsSettingsPanel}))),O=(0,S.lazy)(()=>b().then(e=>({default:e.SystemSettingsPanel}))),k=(0,S.lazy)(()=>c().then(e=>({default:e.DesktopPetSettings}))),A=(0,S.lazy)(()=>h().then(e=>({default:e.AppManagementSettingsPanel}))),j=(0,S.lazy)(()=>p().then(e=>({default:e.GatewaySettingsPanel}))),M=(0,S.lazy)(()=>d().then(e=>({default:e.RuntimeToolsSettingsPanel}))),N=(0,S.lazy)(()=>m().then(e=>({default:e.HeartbeatSettingsPanel}))),P=(0,S.lazy)(()=>u().then(e=>({default:e.RemoteAccessHub}))),F=(0,S.lazy)(()=>_().then(e=>({default:e.SharesSettingsPanel}))),I=(0,S.lazy)(()=>l().then(e=>({default:e.AgentDefaultsSettingsPanel}))),L=(0,S.lazy)(()=>v().then(e=>({default:e.EndpointToolsManagementSettings})));function R(){let e=(0,x.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,C.jsxs)(`div`,{className:`w-full flex-1 px-3 py-8 sm:px-5 xl:px-6`,"aria-busy":!0,children:[(0,C.jsx)(`div`,{className:`h-8 w-48 max-w-full animate-pulse rounded-md bg-surface-hover`}),(0,C.jsx)(`div`,{className:`mt-6 h-36 animate-pulse rounded-xl bg-surface-hover`}),(0,C.jsx)(`div`,{className:`mt-4 h-24 animate-pulse rounded-xl bg-surface-hover`})]}),e[0]=t):t=e[0],t}function z(e){return(0,C.jsx)(S.Suspense,{fallback:(0,C.jsx)(R,{}),children:(0,C.jsx)(e,{})})}function B(){let e=(0,x.c)(28),{section:t}=i(),n=s(V),r,c,l,u,d;if(e[0]!==n||e[1]!==t){d=Symbol.for(`react.early_return_sentinel`);bb0:{let i=o(n);if(!t||!w.includes(t)){let t;e[7]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,C.jsx)(a,{to:`/settings/overview`,replace:!0}),e[7]=t):t=e[7],d=t;break bb0}let s=t;if(s===`overview`){let t;e[8]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(T),e[8]=t):t=e[8],d=t;break bb0}let f=i.settingsSections[s];if(s===`appearance`){let t;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(E),e[9]=t):t=e[9],d=t;break bb0}if(s===`keyboard-shortcuts`){let t;e[10]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(D),e[10]=t):t=e[10],d=t;break bb0}if(s===`system`){let t;e[11]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(O),e[11]=t):t=e[11],d=t;break bb0}if(s===`desktop-pet`){let t;e[12]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(k),e[12]=t):t=e[12],d=t;break bb0}if(s===`desktop-app`){let t;e[13]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(A),e[13]=t):t=e[13],d=t;break bb0}if(s===`agent-defaults`){let t;e[14]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(I),e[14]=t):t=e[14],d=t;break bb0}if(s===`gateway`){let t;e[15]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(j),e[15]=t):t=e[15],d=t;break bb0}if(s===`runtimes`){let t;e[16]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(M),e[16]=t):t=e[16],d=t;break bb0}if(s===`devices`){let t;e[17]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(L),e[17]=t):t=e[17],d=t;break bb0}if(s===`heartbeat`){let t;e[18]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(N),e[18]=t):t=e[18],d=t;break bb0}if(s===`remote-access`){let t;e[19]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(P),e[19]=t):t=e[19],d=t;break bb0}if(s===`shares`){let t;e[20]===Symbol.for(`react.memo_cache_sentinel`)?(t=z(F),e[20]=t):t=e[20],d=t;break bb0}l=`flex w-full flex-col gap-3 px-3 py-8 sm:px-5 xl:px-6`,u=(0,C.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:f}),r=`text-sm text-fg-muted`,c=i.settingsPage.comingSoon.replace(`{{title}}`,f)}e[0]=n,e[1]=t,e[2]=r,e[3]=c,e[4]=l,e[5]=u,e[6]=d}else r=e[2],c=e[3],l=e[4],u=e[5],d=e[6];if(d!==Symbol.for(`react.early_return_sentinel`))return d;let f;e[21]!==r||e[22]!==c?(f=(0,C.jsx)(`p`,{className:r,children:c}),e[21]=r,e[22]=c,e[23]=f):f=e[23];let p;return e[24]!==l||e[25]!==u||e[26]!==f?(p=(0,C.jsxs)(`div`,{className:l,children:[u,f]}),e[24]=l,e[25]=u,e[26]=f,e[27]=p):p=e[27],p}function V(e){return e.language}export{B as SettingsPage};
|
|
@@ -1 +1 @@
|
|
|
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-BaASWQor.js";import{t as a}from"./circle-check-C23XjkUj.js";import{t as o}from"./loader-circle-CifKLtgG.js";import{t as s}from"./messages-W5P19VTF.js";import{a as c,n as l,r as u,s as d}from"./locale-store-zEL8bkwx.js";import{t as f}from"./cn-JdwAhgNB.js";import{i as p}from"./vendor-swr-BIWyz7Rc.js";import{r as m}from"./gateway-config-swr-BGdHwT4e.js";import{n as h,t as g}from"./registry-api-Cg92zSod.js";import{Ca as _,Go as v,Hl as y,Rs as b,Vl as x,Xl as S,Za as C,_n as w,bu as T,jt as E,ks as D,sc as ee,tl as O}from"./index-aBs0EfQB.js";import{n as k,r as A}from"./settings-page-layout-BRQNel6r.js";import{n as j}from"./settings-loading-skeleton-CAmWMaOT.js";import{n as M,t as N}from"./settings-form-section-CZu6FX4k.js";var P=e(t(),1),F=n();function I(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`&&C(e)).length}function L(e){if(!e||typeof e!=`object`)return``;let t=e.agents;if(!t||typeof t!=`object`||Array.isArray(t))return``;let n=t.defaults,r=n&&typeof n==`object`&&!Array.isArray(n)?n.models:void 0;if(!r||typeof r!=`object`||Array.isArray(r))return``;let i=r.chat;if(!i||typeof i!=`object`||Array.isArray(i))return``;let a=i.primary;return typeof a==`string`?a.trim():``}function R(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 z(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 B(e){return e?`pass`:`fail`}function V(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 H(e){return{fail:4,warn:3,skip:2,pass:1}[e]}function te(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:V(e.id),source:`doctor`})).toSorted((e,t)=>H(t.status)-H(e.status)||e.label.localeCompare(t.label))}function U(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:V(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 ne(e){let t=I(e.config),n=e.providerMeta?.configured??t,r=e.providerMeta?.total??0,i=n>0||t>0,a=L(e.config),o=a.length>0,s=e.hasToken&&e.realtimeConnected,c=R(e.config),l=e.skillCount>0,u=e.doctorChecks??[],d=te(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:B(s),title:`Gateway`,detail:s?e.labels.gatewayOnline:e.labels.gatewayOffline,path:`/settings/gateway`},{id:`provider`,status:B(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:B(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=U({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 re(e){return z(e)}function W(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 ie(){return u(`/api/doctor`)}async function ae(){return((await c(ie())).checks??[]).map(W).filter(e=>e!==null)}function oe(){return u(`/api/logs/health`)}async function se(){return c(oe())}function G(e){return e?`pass`:`warn`}function K(e){return`/settings/agent-browser?tab=${encodeURIComponent(e)}`}function ce(e){return e?.enabled?[`setup-browser-diagnostics`,e]:null}async function q(e){if(!e.enabled)return[];if(e.backend===`local`){let e=await c(u(`/api/browser/playwright/doctor`)),t=e.payload?.installed===!0;return[{id:`browser-playwright`,label:`Browser: Playwright`,status:G(t),message:t?`Local Chromium is installed.`:e.payload?.reason??`Local Chromium is not installed.`,path:K(`local`)}]}if(e.backend===`cloakbrowser`){let e=await c(u(`/api/browser/cloakbrowser/doctor`)),t=e.payload?.installed===!0;return[{id:`browser-cloakbrowser`,label:`Browser: CloakBrowser`,status:G(t),message:t?`CloakBrowser ${e.payload?.version??``}`.trim():`CloakBrowser is not installed.`,path:K(`cloakbrowser`)}]}if(e.backend===`extension`){let e=await c(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:K(`extension`)}]}return[{id:`browser-playwright`,label:`Browser`,status:`skip`,message:`Browser backend "${e.backend}" is not checked on this overview.`,path:K(e.backend||`overview`)}]}function J(){let e=(0,F.c)(57),t=d(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=_(fe),{data:c,error:u,isLoading:f,mutate:v}=m(!!t),y;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(y={revalidateOnFocus:!1},e[2]=y):y=e[2];let{data:b,error:x,isLoading:S,mutate:C}=p(t?`setup-checklist-skills`:null,de,y),w;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(w={revalidateOnFocus:!1},e[3]=w):w=e[3];let{data:T,error:D,isLoading:ee,mutate:O}=p(t?`setup-checklist-provider-meta`:null,E,w),k;e[4]===t?k=e[5]:(k=t?ie():null,e[4]=t,e[5]=k);let A;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(A={revalidateOnFocus:!1},e[6]=A):A=e[6];let{data:j,error:M,isLoading:N,mutate:P}=p(k,ae,A),I;e[7]===t?I=e[8]:(I=t?oe():null,e[7]=t,e[8]=I);let L;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(L={revalidateOnFocus:!1},e[9]=L):L=e[9];let{data:R,isLoading:z,mutate:B}=p(I,se,L);c?.payload?.config;let V=c?.payload?.config,H;e[10]===V?H=e[11]:(H=re(V),e[10]=V,e[11]=H);let te=t?H:null,U;e[12]===te?U=e[13]:(U=ce(te),e[12]=te,e[13]=U);let W;e[14]===Symbol.for(`react.memo_cache_sentinel`)?(W={revalidateOnFocus:!1},e[14]=W):W=e[14];let{data:G,isLoading:K,mutate:q}=p(U,ue,W),J;e[15]===Symbol.for(`react.memo_cache_sentinel`)?(J={revalidateOnFocus:!1},e[15]=J):J=e[15],p(t?g:null,h,J);let Y=!t||!f&&!S&&!ee&&!N&&!z&&!K,X=!!(u||x||D||M),Z;bb0:{if(!t||!Y){Z=null;break bb0}let n=b?.catalog?.length??0,r;if(e[16]!==G||e[17]!==c?.payload?.config||e[18]!==j||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]!==R||e[31]!==i.setupStatus.requiredCompleteMessage||e[32]!==T||e[33]!==o||e[34]!==n||e[35]!==t){let s=T?.filter(le).length??0,l=T?.length??0,u;e[37]===a.providersConfigured?u=e[38]:(u=e=>a.providersConfigured.replace(`{{count}}`,String(e)),e[37]=a.providersConfigured,e[38]=u);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=ne({hasToken:!!t,realtimeConnected:o,config:c?.payload?.config,skillCount:n,providerMeta:l>0?{configured:s,total:l}:null,doctorChecks:j,logsHealth:R,browserDiagnostics:G,labels:{gatewayOnline:a.gatewayOnline,gatewayOffline:a.gatewayOffline,providersConfigured:u,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]=G,e[17]=c?.payload?.config,e[18]=j,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]=R,e[31]=i.setupStatus.requiredCompleteMessage,e[32]=T,e[33]=o,e[34]=n,e[35]=t,e[36]=r}else r=e[36];Z=r}let he=Z,Q;e[45]!==q||e[46]!==v||e[47]!==P||e[48]!==B||e[49]!==O||e[50]!==C?(Q=async()=>{await Promise.all([v(),C(),O(),P(),B(),q()])},e[45]=q,e[46]=v,e[47]=P,e[48]=B,e[49]=O,e[50]=C,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 q(t)}function de(){return w()}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`?a:e===`warn`?D:e===`fail`?y:O}function he(e,t){return e===`blocked`?{icon:y,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:D,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:x,className:`bg-surface-base text-fg shadow-surface`,title:t.health.setupTitle,body:t.health.setupBody,action:t.health.continueSetup,targetId:`next-steps`}:{icon:a,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,F.c)(48),{tier:n,issueCount:r,onRunDoctor:a,ready:c,doctorRunning:u,doctorRunState:d}=e,p=l(ge),m,h,g,_,y,b,x,C,w,T,E;if(t[0]!==r||t[1]!==p||t[2]!==n){h=s(p).setupStatus;let e=he(n,h),a=e.icon,o=`targetId`in e&&typeof e.targetId==`string`?e.targetId:null,c=`actionPath`in e&&typeof e.actionPath==`string`?e.actionPath:`/chat`;m=o?(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>document.getElementById(o)?.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)(S,{className:`size-4`,"aria-hidden":!0})]}):(0,Y.jsxs)(i,{to:c,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)(S,{className:`size-4`,"aria-hidden":!0})]}),E=f(`rounded-xl p-4`,e.className),T=`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,C=`flex min-w-0 gap-3`,w=(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}),x=(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]=x,t[10]=C,t[11]=w,t[12]=T,t[13]=E}else m=t[3],h=t[4],g=t[5],_=t[6],y=t[7],b=t[8],x=t[9],C=t[10],w=t[11],T=t[12],E=t[13];let D;t[14]!==g||t[15]!==_?(D=(0,Y.jsx)(`p`,{className:g,children:_}),t[14]=g,t[15]=_,t[16]=D):D=t[16];let O;t[17]!==D||t[18]!==y||t[19]!==b||t[20]!==x?(O=(0,Y.jsxs)(`div`,{className:y,children:[b,x,D]}),t[17]=D,t[18]=y,t[19]=b,t[20]=x,t[21]=O):O=t[21];let k;t[22]!==O||t[23]!==C||t[24]!==w?(k=(0,Y.jsxs)(`div`,{className:C,children:[w,O]}),t[22]=O,t[23]=C,t[24]=w,t[25]=k):k=t[25];let A;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(A=f(`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]=A):A=t[26];let j=!c||u,M;t[27]===u?M=t[28]:(M=u?(0,Y.jsx)(o,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,Y.jsx)(ee,{className:`size-4`,"aria-hidden":!0}),t[27]=u,t[28]=M);let N=u?h.health.runDoctorRunning:h.health.runDoctor,P;t[29]!==u||t[30]!==a||t[31]!==j||t[32]!==M||t[33]!==N?(P=(0,Y.jsxs)(`button`,{type:`button`,className:A,onClick:a,disabled:j,"aria-busy":u,children:[M,N]}),t[29]=u,t[30]=a,t[31]=j,t[32]=M,t[33]=N,t[34]=P):P=t[34];let I;t[35]!==m||t[36]!==P?(I=(0,Y.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:[m,P]}),t[35]=m,t[36]=P,t[37]=I):I=t[37];let L;t[38]!==k||t[39]!==I||t[40]!==T?(L=(0,Y.jsxs)(`div`,{className:T,children:[k,I]}),t[38]=k,t[39]=I,t[40]=T,t[41]=L):L=t[41];let R=u?h.health.doctorRunningMessage:d===`success`?h.health.doctorCompleteMessage:d===`error`?h.health.doctorFailedMessage:h.health.doctorIdleMessage,z;t[42]===R?z=t[43]:(z=(0,Y.jsx)(`p`,{className:`mt-3 text-xs opacity-75`,role:`status`,"aria-live":`polite`,children:R}),t[42]=R,t[43]=z);let B;return t[44]!==L||t[45]!==z||t[46]!==E?(B=(0,Y.jsxs)(`section`,{className:E,children:[L,z]}),t[44]=L,t[45]=z,t[46]=E,t[47]=B):B=t[47],B}function ge(e){return e.language}function $(e){let t=(0,F.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 o=a,s;t[2]===o?s=t[3]:(s=(0,Y.jsx)(o,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":!0}),t[2]=o,t[3]=s);let c;t[4]===n.label?c=t[5]:(c=(0,Y.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:n.label}),t[4]=n.label,t[5]=c);let l;t[6]===n.status?l=t[7]:(l=f(`rounded-full border px-2 py-0.5 text-[11px] font-medium uppercase`,X(n.status)),t[6]=n.status,t[7]=l);let u;t[8]!==n.status||t[9]!==l?(u=(0,Y.jsx)(`span`,{className:l,children:n.status}),t[8]=n.status,t[9]=l,t[10]=u):u=t[10];let d;t[11]!==c||t[12]!==u?(d=(0,Y.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[c,u]}),t[11]=c,t[12]=u,t[13]=d):d=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]!==d||t[19]!==p||t[20]!==m?(h=(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[d,p,m]}),t[18]=d,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)(S,{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]!==s||t[27]!==h?(_=(0,Y.jsxs)(Y.Fragment,{children:[s,h,g]}),t[25]=g,t[26]=s,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,F.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 o=a,s=r[n.id]??n.title,c;t[2]===n.status?c=t[3]:(c=f(`flex size-7 shrink-0 items-center justify-center rounded-full border`,X(n.status)),t[2]=n.status,t[3]=c);let l;t[4]===o?l=t[5]:(l=(0,Y.jsx)(o,{className:`size-4`,"aria-hidden":!0}),t[4]=o,t[5]=l);let u;t[6]!==c||t[7]!==l?(u=(0,Y.jsx)(`span`,{className:c,children:l}),t[6]=c,t[7]=l,t[8]=u):u=t[8];let d;t[9]===s?d=t[10]:(d=(0,Y.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:s}),t[9]=s,t[10]=d);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]!==d||t[14]!==p?(m=(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[d,p]}),t[13]=d,t[14]=p,t[15]=m):m=t[15];let h;t[16]===n.path?h=t[17]:(h=n.path?(0,Y.jsx)(S,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0}):null,t[16]=n.path,t[17]=h);let g;t[18]!==u||t[19]!==m||t[20]!==h?(g=(0,Y.jsxs)(Y.Fragment,{children:[u,m,h]}),t[18]=u,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,F.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 o=a,s;t[2]===o?s=t[3]:(s=(0,Y.jsx)(o,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":!0}),t[2]=o,t[3]=s);let c;t[4]===n.label?c=t[5]:(c=(0,Y.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:n.label}),t[4]=n.label,t[5]=c);let l;t[6]===n.message?l=t[7]:(l=(0,Y.jsx)(`span`,{className:`mt-0.5 block truncate text-xs text-fg-muted`,children:n.message}),t[6]=n.message,t[7]=l);let u;t[8]!==c||t[9]!==l?(u=(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[c,l]}),t[8]=c,t[9]=l,t[10]=u):u=t[10];let d;t[11]===n.status?d=t[12]:(d=f(`shrink-0 rounded-full border px-2 py-0.5 text-[11px] font-medium uppercase`,X(n.status)),t[11]=n.status,t[12]=d);let p;t[13]!==n.status||t[14]!==d?(p=(0,Y.jsx)(`span`,{className:d,children:n.status}),t[13]=n.status,t[14]=d,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]!==s||t[20]!==u||t[21]!==p||t[22]!==m?(h=(0,Y.jsxs)(Y.Fragment,{children:[s,u,p,m]}),t[19]=s,t[20]=u,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,o]=(0,P.useState)(!1),[c,u]=(0,P.useState)(`idle`),d=r?.diagnosticSignals.filter(e=>e.status===`fail`||e.status===`warn`)??[],p=async()=>{if(!(a||!t)){o(!0),u(`idle`);try{await i(),u(`success`)}catch{u(`error`)}finally{o(!1)}}};return(0,Y.jsxs)(A,{gap:`gap-6`,children:[(0,Y.jsx)(k,{title:e.title,subtitle:e.subtitle,actions:(0,Y.jsxs)(`button`,{type:`button`,className:f(`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)(ee,{className:f(`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)(j,{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:c}),(0,Y.jsxs)(N,{id:`next-steps`,children:[(0,Y.jsx)(M,{icon:r.issues.length?D:T,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)(N,{children:[(0,Y.jsx)(M,{icon:b,title:e.diagnosticsTitle,subtitle:e.diagnosticsSubtitle}),d.length?(0,Y.jsx)(`div`,{className:`mt-4 grid gap-2 md:grid-cols-2`,children:d.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
|
+
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-BaASWQor.js";import{t as a}from"./circle-check-C23XjkUj.js";import{t as o}from"./loader-circle-CifKLtgG.js";import{t as s}from"./messages-Cf5hpZE6.js";import{a as c,n as l,r as u,s as d}from"./locale-store-CF4erhjB.js";import{t as f}from"./cn-JdwAhgNB.js";import{i as p}from"./vendor-swr-BIWyz7Rc.js";import{r as m}from"./gateway-config-swr-CMNbl0FZ.js";import{n as h,t as g}from"./registry-api-BsRBlji7.js";import{$a as _,$l as v,Cu as y,Gl as b,Ms as x,Ta as S,Vs as C,Wl as w,_n as T,il as E,jt as D,qo as ee,uc as O}from"./index-BcaF-dgQ.js";import{n as k,r as A}from"./settings-page-layout-BRQNel6r.js";import{n as j}from"./settings-loading-skeleton-CAmWMaOT.js";import{n as M,t as N}from"./settings-form-section-DVY-8_B9.js";var P=e(t(),1),F=n();function I(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`&&_(e)).length}function L(e){if(!e||typeof e!=`object`)return``;let t=e.agents;if(!t||typeof t!=`object`||Array.isArray(t))return``;let n=t.defaults,r=n&&typeof n==`object`&&!Array.isArray(n)?n.models:void 0;if(!r||typeof r!=`object`||Array.isArray(r))return``;let i=r.chat;if(!i||typeof i!=`object`||Array.isArray(i))return``;let a=i.primary;return typeof a==`string`?a.trim():``}function R(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 z(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 B(e){return e?`pass`:`fail`}function V(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 H(e){return{fail:4,warn:3,skip:2,pass:1}[e]}function te(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:V(e.id),source:`doctor`})).toSorted((e,t)=>H(t.status)-H(e.status)||e.label.localeCompare(t.label))}function U(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:V(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 ne(e){let t=I(e.config),n=e.providerMeta?.configured??t,r=e.providerMeta?.total??0,i=n>0||t>0,a=L(e.config),o=a.length>0,s=e.hasToken&&e.realtimeConnected,c=R(e.config),l=e.skillCount>0,u=e.doctorChecks??[],d=te(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:B(s),title:`Gateway`,detail:s?e.labels.gatewayOnline:e.labels.gatewayOffline,path:`/settings/gateway`},{id:`provider`,status:B(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:B(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=U({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 re(e){return z(e)}function W(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 ie(){return u(`/api/doctor`)}async function ae(){return((await c(ie())).checks??[]).map(W).filter(e=>e!==null)}function oe(){return u(`/api/logs/health`)}async function se(){return c(oe())}function G(e){return e?`pass`:`warn`}function K(e){return`/settings/agent-browser?tab=${encodeURIComponent(e)}`}function ce(e){return e?.enabled?[`setup-browser-diagnostics`,e]:null}async function q(e){if(!e.enabled)return[];if(e.backend===`local`){let e=await c(u(`/api/browser/playwright/doctor`)),t=e.payload?.installed===!0;return[{id:`browser-playwright`,label:`Browser: Playwright`,status:G(t),message:t?`Local Chromium is installed.`:e.payload?.reason??`Local Chromium is not installed.`,path:K(`local`)}]}if(e.backend===`cloakbrowser`){let e=await c(u(`/api/browser/cloakbrowser/doctor`)),t=e.payload?.installed===!0;return[{id:`browser-cloakbrowser`,label:`Browser: CloakBrowser`,status:G(t),message:t?`CloakBrowser ${e.payload?.version??``}`.trim():`CloakBrowser is not installed.`,path:K(`cloakbrowser`)}]}if(e.backend===`extension`){let e=await c(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:K(`extension`)}]}return[{id:`browser-playwright`,label:`Browser`,status:`skip`,message:`Browser backend "${e.backend}" is not checked on this overview.`,path:K(e.backend||`overview`)}]}function J(){let e=(0,F.c)(57),t=d(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:c,error:u,isLoading:f,mutate:_}=m(!!t),v;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(v={revalidateOnFocus:!1},e[2]=v):v=e[2];let{data:y,error:b,isLoading:x,mutate:C}=p(t?`setup-checklist-skills`:null,de,v),w;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(w={revalidateOnFocus:!1},e[3]=w):w=e[3];let{data:T,error:E,isLoading:ee,mutate:O}=p(t?`setup-checklist-provider-meta`:null,D,w),k;e[4]===t?k=e[5]:(k=t?ie():null,e[4]=t,e[5]=k);let A;e[6]===Symbol.for(`react.memo_cache_sentinel`)?(A={revalidateOnFocus:!1},e[6]=A):A=e[6];let{data:j,error:M,isLoading:N,mutate:P}=p(k,ae,A),I;e[7]===t?I=e[8]:(I=t?oe():null,e[7]=t,e[8]=I);let L;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(L={revalidateOnFocus:!1},e[9]=L):L=e[9];let{data:R,isLoading:z,mutate:B}=p(I,se,L);c?.payload?.config;let V=c?.payload?.config,H;e[10]===V?H=e[11]:(H=re(V),e[10]=V,e[11]=H);let te=t?H:null,U;e[12]===te?U=e[13]:(U=ce(te),e[12]=te,e[13]=U);let W;e[14]===Symbol.for(`react.memo_cache_sentinel`)?(W={revalidateOnFocus:!1},e[14]=W):W=e[14];let{data:G,isLoading:K,mutate:q}=p(U,ue,W),J;e[15]===Symbol.for(`react.memo_cache_sentinel`)?(J={revalidateOnFocus:!1},e[15]=J):J=e[15],p(t?g:null,h,J);let Y=!t||!f&&!x&&!ee&&!N&&!z&&!K,X=!!(u||b||E||M),Z;bb0:{if(!t||!Y){Z=null;break bb0}let n=y?.catalog?.length??0,r;if(e[16]!==G||e[17]!==c?.payload?.config||e[18]!==j||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]!==R||e[31]!==i.setupStatus.requiredCompleteMessage||e[32]!==T||e[33]!==o||e[34]!==n||e[35]!==t){let s=T?.filter(le).length??0,l=T?.length??0,u;e[37]===a.providersConfigured?u=e[38]:(u=e=>a.providersConfigured.replace(`{{count}}`,String(e)),e[37]=a.providersConfigured,e[38]=u);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=ne({hasToken:!!t,realtimeConnected:o,config:c?.payload?.config,skillCount:n,providerMeta:l>0?{configured:s,total:l}:null,doctorChecks:j,logsHealth:R,browserDiagnostics:G,labels:{gatewayOnline:a.gatewayOnline,gatewayOffline:a.gatewayOffline,providersConfigured:u,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]=G,e[17]=c?.payload?.config,e[18]=j,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]=R,e[31]=i.setupStatus.requiredCompleteMessage,e[32]=T,e[33]=o,e[34]=n,e[35]=t,e[36]=r}else r=e[36];Z=r}let he=Z,Q;e[45]!==q||e[46]!==_||e[47]!==P||e[48]!==B||e[49]!==O||e[50]!==C?(Q=async()=>{await Promise.all([_(),C(),O(),P(),B(),q()])},e[45]=q,e[46]=_,e[47]=P,e[48]=B,e[49]=O,e[50]=C,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 q(t)}function de(){return T()}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`?a:e===`warn`?x:e===`fail`?b:E}function he(e,t){return e===`blocked`?{icon:b,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:x,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:w,className:`bg-surface-base text-fg shadow-surface`,title:t.health.setupTitle,body:t.health.setupBody,action:t.health.continueSetup,targetId:`next-steps`}:{icon:a,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,F.c)(48),{tier:n,issueCount:r,onRunDoctor:a,ready:c,doctorRunning:u,doctorRunState:d}=e,p=l(ge),m,h,g,_,y,b,x,S,C,w,T;if(t[0]!==r||t[1]!==p||t[2]!==n){h=s(p).setupStatus;let e=he(n,h),a=e.icon,o=`targetId`in e&&typeof e.targetId==`string`?e.targetId:null,c=`actionPath`in e&&typeof e.actionPath==`string`?e.actionPath:`/chat`;m=o?(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>document.getElementById(o)?.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)(v,{className:`size-4`,"aria-hidden":!0})]}):(0,Y.jsxs)(i,{to:c,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)(v,{className:`size-4`,"aria-hidden":!0})]}),T=f(`rounded-xl p-4`,e.className),w=`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,S=`flex min-w-0 gap-3`,C=(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}),x=(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]=x,t[10]=S,t[11]=C,t[12]=w,t[13]=T}else m=t[3],h=t[4],g=t[5],_=t[6],y=t[7],b=t[8],x=t[9],S=t[10],C=t[11],w=t[12],T=t[13];let E;t[14]!==g||t[15]!==_?(E=(0,Y.jsx)(`p`,{className:g,children:_}),t[14]=g,t[15]=_,t[16]=E):E=t[16];let D;t[17]!==E||t[18]!==y||t[19]!==b||t[20]!==x?(D=(0,Y.jsxs)(`div`,{className:y,children:[b,x,E]}),t[17]=E,t[18]=y,t[19]=b,t[20]=x,t[21]=D):D=t[21];let k;t[22]!==D||t[23]!==S||t[24]!==C?(k=(0,Y.jsxs)(`div`,{className:S,children:[C,D]}),t[22]=D,t[23]=S,t[24]=C,t[25]=k):k=t[25];let A;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(A=f(`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`,ee.press),t[26]=A):A=t[26];let j=!c||u,M;t[27]===u?M=t[28]:(M=u?(0,Y.jsx)(o,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,Y.jsx)(O,{className:`size-4`,"aria-hidden":!0}),t[27]=u,t[28]=M);let N=u?h.health.runDoctorRunning:h.health.runDoctor,P;t[29]!==u||t[30]!==a||t[31]!==j||t[32]!==M||t[33]!==N?(P=(0,Y.jsxs)(`button`,{type:`button`,className:A,onClick:a,disabled:j,"aria-busy":u,children:[M,N]}),t[29]=u,t[30]=a,t[31]=j,t[32]=M,t[33]=N,t[34]=P):P=t[34];let I;t[35]!==m||t[36]!==P?(I=(0,Y.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:[m,P]}),t[35]=m,t[36]=P,t[37]=I):I=t[37];let L;t[38]!==k||t[39]!==I||t[40]!==w?(L=(0,Y.jsxs)(`div`,{className:w,children:[k,I]}),t[38]=k,t[39]=I,t[40]=w,t[41]=L):L=t[41];let R=u?h.health.doctorRunningMessage:d===`success`?h.health.doctorCompleteMessage:d===`error`?h.health.doctorFailedMessage:h.health.doctorIdleMessage,z;t[42]===R?z=t[43]:(z=(0,Y.jsx)(`p`,{className:`mt-3 text-xs opacity-75`,role:`status`,"aria-live":`polite`,children:R}),t[42]=R,t[43]=z);let B;return t[44]!==L||t[45]!==z||t[46]!==T?(B=(0,Y.jsxs)(`section`,{className:T,children:[L,z]}),t[44]=L,t[45]=z,t[46]=T,t[47]=B):B=t[47],B}function ge(e){return e.language}function $(e){let t=(0,F.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 o=a,s;t[2]===o?s=t[3]:(s=(0,Y.jsx)(o,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":!0}),t[2]=o,t[3]=s);let c;t[4]===n.label?c=t[5]:(c=(0,Y.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:n.label}),t[4]=n.label,t[5]=c);let l;t[6]===n.status?l=t[7]:(l=f(`rounded-full border px-2 py-0.5 text-[11px] font-medium uppercase`,X(n.status)),t[6]=n.status,t[7]=l);let u;t[8]!==n.status||t[9]!==l?(u=(0,Y.jsx)(`span`,{className:l,children:n.status}),t[8]=n.status,t[9]=l,t[10]=u):u=t[10];let d;t[11]!==c||t[12]!==u?(d=(0,Y.jsxs)(`span`,{className:`flex flex-wrap items-center gap-2`,children:[c,u]}),t[11]=c,t[12]=u,t[13]=d):d=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]!==d||t[19]!==p||t[20]!==m?(h=(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[d,p,m]}),t[18]=d,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)(v,{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]!==s||t[27]!==h?(_=(0,Y.jsxs)(Y.Fragment,{children:[s,h,g]}),t[25]=g,t[26]=s,t[27]=h,t[28]=_):_=t[28];let y=_;if(n.path){let e;return t[29]!==y||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:y}),t[29]=y,t[30]=n.path,t[31]=e):e=t[31],e}let b;return t[32]===y?b=t[33]:(b=(0,Y.jsx)(`div`,{className:`flex items-start gap-3 rounded-lg bg-surface-panel/80 p-3 shadow-surface`,children:y}),t[32]=y,t[33]=b),b}function _e(e){let t=(0,F.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 o=a,s=r[n.id]??n.title,c;t[2]===n.status?c=t[3]:(c=f(`flex size-7 shrink-0 items-center justify-center rounded-full border`,X(n.status)),t[2]=n.status,t[3]=c);let l;t[4]===o?l=t[5]:(l=(0,Y.jsx)(o,{className:`size-4`,"aria-hidden":!0}),t[4]=o,t[5]=l);let u;t[6]!==c||t[7]!==l?(u=(0,Y.jsx)(`span`,{className:c,children:l}),t[6]=c,t[7]=l,t[8]=u):u=t[8];let d;t[9]===s?d=t[10]:(d=(0,Y.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:s}),t[9]=s,t[10]=d);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]!==d||t[14]!==p?(m=(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[d,p]}),t[13]=d,t[14]=p,t[15]=m):m=t[15];let h;t[16]===n.path?h=t[17]:(h=n.path?(0,Y.jsx)(v,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0}):null,t[16]=n.path,t[17]=h);let g;t[18]!==u||t[19]!==m||t[20]!==h?(g=(0,Y.jsxs)(Y.Fragment,{children:[u,m,h]}),t[18]=u,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 y;return t[25]===_?y=t[26]:(y=(0,Y.jsx)(`div`,{className:`flex items-center gap-3 rounded-lg p-3`,children:_}),t[25]=_,t[26]=y),y}function ve(e){let t=(0,F.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 o=a,s;t[2]===o?s=t[3]:(s=(0,Y.jsx)(o,{className:`mt-0.5 size-4 shrink-0`,"aria-hidden":!0}),t[2]=o,t[3]=s);let c;t[4]===n.label?c=t[5]:(c=(0,Y.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:n.label}),t[4]=n.label,t[5]=c);let l;t[6]===n.message?l=t[7]:(l=(0,Y.jsx)(`span`,{className:`mt-0.5 block truncate text-xs text-fg-muted`,children:n.message}),t[6]=n.message,t[7]=l);let u;t[8]!==c||t[9]!==l?(u=(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[c,l]}),t[8]=c,t[9]=l,t[10]=u):u=t[10];let d;t[11]===n.status?d=t[12]:(d=f(`shrink-0 rounded-full border px-2 py-0.5 text-[11px] font-medium uppercase`,X(n.status)),t[11]=n.status,t[12]=d);let p;t[13]!==n.status||t[14]!==d?(p=(0,Y.jsx)(`span`,{className:d,children:n.status}),t[13]=n.status,t[14]=d,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]!==s||t[20]!==u||t[21]!==p||t[22]!==m?(h=(0,Y.jsxs)(Y.Fragment,{children:[s,u,p,m]}),t[19]=s,t[20]=u,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,o]=(0,P.useState)(!1),[c,u]=(0,P.useState)(`idle`),d=r?.diagnosticSignals.filter(e=>e.status===`fail`||e.status===`warn`)??[],p=async()=>{if(!(a||!t)){o(!0),u(`idle`);try{await i(),u(`success`)}catch{u(`error`)}finally{o(!1)}}};return(0,Y.jsxs)(A,{gap:`gap-6`,children:[(0,Y.jsx)(k,{title:e.title,subtitle:e.subtitle,actions:(0,Y.jsxs)(`button`,{type:`button`,className:f(`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`,ee.press),onClick:()=>void p(),disabled:!t||a,"aria-busy":a,children:[(0,Y.jsx)(O,{className:f(`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)(j,{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:c}),(0,Y.jsxs)(N,{id:`next-steps`,children:[(0,Y.jsx)(M,{icon:r.issues.length?x:y,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)(N,{children:[(0,Y.jsx)(M,{icon:C,title:e.diagnosticsTitle,subtitle:e.diagnosticsSubtitle}),d.length?(0,Y.jsx)(`div`,{className:`mt-4 grid gap-2 md:grid-cols-2`,children:d.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,2 +1,2 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/attachment-process-heavy-B2_kr5EA.js","assets/rolldown-runtime-aKtaBQYM.js","assets/preload-helper-zJ_50EbN.js","assets/excel-worksheet-utils-EyvwNT4X.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
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"./preload-helper-zJ_50EbN.js";import{d as a}from"./chunk-KS7C4IRE-BaASWQor.js";import{t as o}from"./markdown-view-DGRN-8wP.js";import{t as s}from"./copy-to-clipboard-HOJ79TWv.js";import{t as c}from"./messages-W5P19VTF.js";import{n as l,r as u}from"./locale-store-zEL8bkwx.js";import{t as d}from"./cn-JdwAhgNB.js";import{t as f}from"./skeleton-BwbyijEw.js";import{Xr as p,Yr as m,do as h,gi as g,la as _,vi as v,yi as y}from"./index-aBs0EfQB.js";var b=e(t(),1),x=n(),S=/^ {0,3}\[([^\]]+)\]:\s*<?(https?:\/\/[^\s>]+)>?(?:\s+.*)?$/gim,C=/!\[([^\]]*)\]\(\s*<?(https?:\/\/[^\s)>]+)>?(?:\s+(?:"[^"]*"|'[^']*'|\([^)]*\)))?\s*\)/gi,w=/!\[([^\]]*)\]\[([^\]]+)\]/g;function T(e,t){let n=new Map;for(let t of e.matchAll(S))n.set(E(t[1]??``),t[2]??``);return e.replace(C,(e,n,r)=>`[${n.trim()||t}](${r})`).replace(w,(e,r,i)=>{let a=n.get(E(i));return a?`[${r.trim()||t}](${a})`:e})}function E(e){return e.trim().replace(/\s+/g,` `).toLowerCase()}var D=r();function O(){return{textContent:null,binaryBuffer:null,extractedText:null,extractedTextTruncated:!1}}function k(e){let t=(0,x.c)(30),{subtitle:n,openInlineUrl:r,landingUrl:i,...a}=e,{expanded:o,setExpanded:l}=m(),u=c(a.language),f;t[0]===u?f=t[1]:(f=async()=>{let e=await s(window.location.href);h(e?`success`:`warning`,e?u.sharesSettings.copied:u.clipboard.copyFailed)},t[0]=u,t[1]=f);let g=f,_=o&&`fixed inset-0 z-[65] h-[100dvh] max-w-none`,v;t[2]===_?v=t[3]:(v=d(`mx-auto flex h-full min-h-0 w-full max-w-[var(--max-width-app-main)] flex-col bg-surface-panel`,_),t[2]=_,t[3]=v);let y;t[4]!==l||t[5]!==a.loadError||t[6]!==a.loading?(y=!a.loading&&!a.loadError?()=>l(A):void 0,t[4]=l,t[5]=a.loadError,t[6]=a.loading,t[7]=y):y=t[7];let b;t[8]===i?b=t[9]:(b=()=>window.location.assign(i),t[8]=i,t[9]=b);let S;t[10]===g?S=t[11]:(S=()=>void g(),t[10]=g,t[11]=S);let C=a.loading||!!a.loadError,w;t[12]!==S||t[13]!==C?(w={onClick:S,disabled:C},t[12]=S,t[13]=C,t[14]=w):w=t[14];let T;t[15]===r?T=t[16]:(T={href:r},t[15]=r,t[16]=T);let E;t[17]!==o||t[18]!==n||t[19]!==y||t[20]!==b||t[21]!==w||t[22]!==T?(E={subtitle:n,expanded:o,onToggleExpanded:y,onClose:b,share:w,openInBrowser:T},t[17]=o,t[18]=n,t[19]=y,t[20]=b,t[21]=w,t[22]=T,t[23]=E):E=t[23];let O;t[24]!==a||t[25]!==E?(O=(0,D.jsx)(p,{...a,header:E}),t[24]=a,t[25]=E,t[26]=O):O=t[26];let k;return t[27]!==O||t[28]!==v?(k=(0,D.jsx)(`div`,{className:v,children:O}),t[27]=O,t[28]=v,t[29]=k):k=t[29],k}function A(e){return!e}function j(){let{token:e}=a(),t=l(e=>e.language),n=t===`zh`?P:F,[r,s]=(0,b.useState)(null),[c,d]=(0,b.useState)(O),[p,m]=(0,b.useState)(!0),[h,x]=(0,b.useState)(null),[S,C]=(0,b.useState)(null),[w,E]=(0,b.useState)(null),A=(0,b.useMemo)(()=>{if(!r||!e||r.kind!==`file`)return null;let t=v(r.fileName,r.mimeType);return{id:`share:${e}:${r.fileName}`,context:`share`,fileName:r.fileName,mimeType:t,size:r.fileSize,type:g(r.fileName,t),source:{kind:`share`,token:e}}},[r,e]);(0,b.useEffect)(()=>{if(!e){x(n.invalidLink),m(!1);return}let t=!1;return(async()=>{try{m(!0),x(null),d(O()),C(null),E(null);let r=await fetch(u(`/s/${encodeURIComponent(e)}/meta`));if(!r.ok){t||x(r.status===404?n.notFound:n.expired);return}let a=await r.json();if(t)return;if(s(a),!a.valid){x(n.expired);return}if(a.kind===`note`||a.kind===`session`){let r=await fetch(u(`/s/${encodeURIComponent(e)}/view`),{method:`POST`});if(!r.ok){x(r.status===404?n.notFound:n.expired);return}let i=await r.json();!t&&i.payload?.kind===`note`&&C(i.payload),!t&&i.payload?.kind===`session`&&E(i.payload);return}if(a.kind!==`file`)return;let o=v(a.fileName,a.mimeType),c=g(a.fileName,o),l=y(c),f=u(`/s/${encodeURIComponent(e)}?inline=1`);if(l===`text`){if(a.fileSize>5242880){x(n.tooLarge);return}let e=await fetch(f);if(!e.ok){x(n.expired);return}let r=await e.text();t||d({...O(),textContent:r});return}if(l===`binary`){if(a.fileSize>33554432){x(n.tooLarge);return}let e=await fetch(f);if(!e.ok){x(n.expired);return}let r=await e.arrayBuffer();if(t)return;if(c===`pptx`){let{processPptx:e}=await i(async()=>{let{processPptx:e}=await import(`./attachment-process-heavy-B2_kr5EA.js`);return{processPptx:e}},__vite__mapDeps([0,1,2,3])),{extractedText:t}=await e(r,a.fileName),n=t.length>_;d({textContent:null,binaryBuffer:r,extractedText:n?t.slice(0,_):t,extractedTextTruncated:n});return}d({...O(),binaryBuffer:r})}}catch(e){t||x(e instanceof Error?e.message:String(e))}finally{t||m(!1)}})(),()=>{t=!0}},[e,n.expired,n.invalidLink,n.notFound,n.tooLarge]);let j=e?u(`/s/${encodeURIComponent(e)}?dl=1`):`#`,I=e?u(`/s/${encodeURIComponent(e)}?inline=1`):`#`;return A&&r&&e?(0,D.jsx)(k,{language:t,descriptor:A,loading:p,loadError:h,textContent:c.textContent,binaryBuffer:c.binaryBuffer,extractedText:c.extractedText,extractedTextTruncated:c.extractedTextTruncated,subtitle:(0,D.jsxs)(`span`,{className:`truncate`,children:[N(r.fileSize),` · `,n.expiresAt,` `,new Date(r.expiresAt).toLocaleString(t===`zh`?`zh-CN`:`en-US`)]}),openInlineUrl:I,landingUrl:u(`/s/${encodeURIComponent(e)}`),actions:{onDownload:()=>{window.location.href=j},canDownload:!p&&!h}}):(0,D.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden bg-surface-base`,children:[(0,D.jsxs)(`header`,{className:`flex h-12 shrink-0 items-center gap-3 border-b border-edge px-4`,children:[(0,D.jsx)(`span`,{className:`text-lg`,"aria-hidden":!0,children:`#`}),(0,D.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[r?(0,D.jsx)(`div`,{className:`truncate text-sm font-semibold text-fg`,title:r.fileName,children:r.fileName}):p?(0,D.jsx)(f,{className:`h-4 w-48 max-w-full`}):(0,D.jsx)(`div`,{className:`truncate text-sm font-semibold text-fg`,children:n.error}),r?(0,D.jsxs)(`div`,{className:`truncate text-xs text-fg-muted`,children:[N(r.fileSize),` · `,n.expiresAt,` `,new Date(r.expiresAt).toLocaleString(t===`zh`?`zh-CN`:`en-US`)]}):null]})]}),(0,D.jsx)(`main`,{className:`flex min-h-0 w-full flex-1 flex-col overflow-y-auto overscroll-contain px-3 py-6 sm:px-5 xl:px-6`,children:p?(0,D.jsxs)(`div`,{className:`flex min-h-[70vh] flex-1 flex-col overflow-hidden rounded-lg bg-surface-panel p-4 shadow-surface`,"aria-busy":`true`,children:[(0,D.jsx)(f,{className:`h-5 w-56 max-w-full`}),(0,D.jsxs)(`div`,{className:`mt-5 grid gap-3`,children:[(0,D.jsx)(f,{className:`h-4 w-full`}),(0,D.jsx)(f,{className:`h-4 w-11/12`}),(0,D.jsx)(f,{className:`h-4 w-10/12`}),(0,D.jsx)(f,{className:`h-4 w-3/4`})]}),(0,D.jsx)(f,{className:`mt-6 min-h-0 flex-1 rounded-lg`})]}):h?(0,D.jsxs)(`div`,{className:`rounded-lg bg-surface-panel p-6 shadow-surface text-sm text-fg`,children:[(0,D.jsx)(`p`,{className:`font-medium`,children:n.error}),(0,D.jsx)(`p`,{className:`mt-1 text-fg-muted`,children:h})]}):r?.kind===`directory`?(0,D.jsx)(`div`,{className:`rounded-lg bg-surface-panel p-6 shadow-surface text-sm text-fg-muted`,children:n.directoryHint}):r?.kind===`note`&&S?(0,D.jsxs)(`article`,{className:`mx-auto w-full max-w-3xl rounded-xl border border-edge-subtle bg-surface-panel px-6 py-8 shadow-surface sm:px-10 sm:py-10`,children:[(0,D.jsx)(`h1`,{className:`text-3xl font-bold tracking-tight text-fg`,children:S.title}),(0,D.jsxs)(`div`,{className:`mt-2 text-xs text-fg-muted`,children:[n.sharedAt,` `,new Date(S.snapshotAt).toLocaleString(t===`zh`?`zh-CN`:`en-US`),` · `,n.expiresAt,` `,new Date(S.expiresAt).toLocaleString(t===`zh`?`zh-CN`:`en-US`)]}),S.description?(0,D.jsx)(`p`,{className:`mt-5 rounded-lg bg-surface-subtle px-4 py-3 text-sm leading-6 text-fg-muted`,children:S.description}):null,(0,D.jsx)(o,{content:T(S.markdown,n.remoteImageBlocked),className:`mt-8`}),(0,D.jsx)(`footer`,{className:`mt-10 border-t border-edge-subtle pt-4 text-center text-xs text-fg-subtle`,children:n.sharedVia})]}):r?.kind===`session`&&w?(0,D.jsxs)(`article`,{className:`mx-auto w-full max-w-4xl rounded-xl border border-edge-subtle bg-surface-panel px-4 py-7 shadow-surface sm:px-8 sm:py-9`,children:[(0,D.jsxs)(`header`,{className:`mx-auto max-w-3xl border-b border-edge-subtle pb-5`,children:[(0,D.jsx)(`h1`,{className:`text-2xl font-bold tracking-tight text-fg sm:text-3xl`,children:w.title}),(0,D.jsxs)(`div`,{className:`mt-2 text-xs text-fg-muted`,children:[n.sharedAt,` `,new Date(w.snapshotAt).toLocaleString(t===`zh`?`zh-CN`:`en-US`),` · `,n.expiresAt,` `,new Date(w.expiresAt).toLocaleString(t===`zh`?`zh-CN`:`en-US`)]}),w.description?(0,D.jsx)(`p`,{className:`mt-4 text-sm leading-6 text-fg-muted`,children:w.description}):null]}),(0,D.jsxs)(`div`,{className:`mx-auto mt-6 max-w-3xl space-y-5`,children:[w.messages.map(e=>(0,D.jsxs)(`section`,{className:e.role===`user`?`ml-auto max-w-[85%]`:`mr-auto max-w-full`,children:[(0,D.jsx)(`div`,{className:`mb-1 text-xs font-medium text-fg-subtle`,children:e.role===`user`?n.you:n.assistant}),(0,D.jsxs)(`div`,{className:e.role===`user`?`rounded-2xl bg-surface-subtle px-4 py-3`:`px-1 py-1`,children:[(0,D.jsx)(o,{content:T(e.markdown,n.remoteImageBlocked)}),w.attachments.filter(t=>e.attachmentIds.includes(t.id)).map(e=>(0,D.jsx)(M,{attachment:e},e.id)),w.toolActivities.filter(t=>t.messageId===e.id).map(e=>(0,D.jsxs)(`div`,{className:`mt-2 inline-flex items-center gap-1.5 rounded-md border border-edge-subtle px-2 py-1 text-xs text-fg-muted`,children:[(0,D.jsx)(`span`,{children:e.toolName}),(0,D.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,D.jsx)(`span`,{children:e.status===`completed`?n.toolCompleted:n.toolFailed})]},e.id))]})]},e.id)),w.toolActivities.filter(e=>!e.messageId).map(e=>(0,D.jsxs)(`div`,{className:`text-center text-xs text-fg-muted`,children:[e.toolName,` · `,e.status===`completed`?n.toolCompleted:n.toolFailed]},e.id))]}),(0,D.jsx)(`footer`,{className:`mx-auto mt-10 max-w-3xl border-t border-edge-subtle pt-4 text-center text-xs text-fg-subtle`,children:n.sharedVia})]}):null})]})}function M(e){let t=(0,x.c)(15),{attachment:n}=e;if(n.mimeType.startsWith(`image/`)){let e;return t[0]!==n.fileName||t[1]!==n.url?(e=(0,D.jsx)(`img`,{src:n.url,alt:n.fileName,loading:`lazy`,className:`mt-3 max-h-[28rem] max-w-full rounded-lg border border-edge-subtle object-contain`}),t[0]=n.fileName,t[1]=n.url,t[2]=e):e=t[2],e}if(n.mimeType.startsWith(`audio/`)){let e;return t[3]===n.url?e=t[4]:(e=(0,D.jsx)(`audio`,{src:n.url,controls:!0,preload:`none`,className:`mt-3 max-w-full`}),t[3]=n.url,t[4]=e),e}let r=n.url,i;t[5]===n.fileName?i=t[6]:(i=(0,D.jsx)(`span`,{className:`min-w-0 truncate`,children:n.fileName}),t[5]=n.fileName,t[6]=i);let a;t[7]===n.size?a=t[8]:(a=N(n.size),t[7]=n.size,t[8]=a);let o;t[9]===a?o=t[10]:(o=(0,D.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:a}),t[9]=a,t[10]=o);let s;return t[11]!==n.url||t[12]!==i||t[13]!==o?(s=(0,D.jsxs)(`a`,{href:r,target:`_blank`,rel:`noreferrer`,className:`mt-3 flex items-center justify-between gap-3 rounded-lg border border-edge-subtle px-3 py-2 text-sm text-accent hover:bg-surface-hover`,children:[i,o]}),t[11]=n.url,t[12]=i,t[13]=o,t[14]=s):s=t[14],s}function N(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:e<1073741824?`${(e/1048576).toFixed(1)} MB`:`${(e/1073741824).toFixed(1)} GB`}var P={error:`加载失败`,expired:`链接已失效`,notFound:`链接不存在`,invalidLink:`链接无效`,expiresAt:`有效期至`,directoryHint:`目录分享请使用主页面浏览。`,tooLarge:`文件过大,无法在线预览,请下载查看。`,sharedAt:`分享于`,sharedVia:`通过 xopc 分享`,you:`你`,assistant:`助手`,toolCompleted:`已完成`,toolFailed:`失败`,remoteImageBlocked:`远程图片(点击打开)`},F={error:`Failed to load`,expired:`Link no longer valid`,notFound:`Link not found`,invalidLink:`Invalid link`,expiresAt:`Expires`,directoryHint:`Directory shares are browsed from the main page.`,tooLarge:`This file is too large to preview here. Please download it instead.`,sharedAt:`Shared`,sharedVia:`Shared via xopc`,you:`You`,assistant:`Assistant`,toolCompleted:`completed`,toolFailed:`failed`,remoteImageBlocked:`Remote image (open manually)`};export{j as SharePreviewPage};
|
|
2
|
+
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"./preload-helper-zJ_50EbN.js";import{d as a}from"./chunk-KS7C4IRE-BaASWQor.js";import{t as o}from"./markdown-view-CQvzsE24.js";import{t as s}from"./copy-to-clipboard-HOJ79TWv.js";import{t as c}from"./messages-Cf5hpZE6.js";import{n as l,r as u}from"./locale-store-CF4erhjB.js";import{t as d}from"./cn-JdwAhgNB.js";import{t as f}from"./skeleton-BwbyijEw.js";import{Xr as p,Yr as m,da as h,gi as g,po as _,vi as v,yi as y}from"./index-BcaF-dgQ.js";var b=e(t(),1),x=n(),S=/^ {0,3}\[([^\]]+)\]:\s*<?(https?:\/\/[^\s>]+)>?(?:\s+.*)?$/gim,C=/!\[([^\]]*)\]\(\s*<?(https?:\/\/[^\s)>]+)>?(?:\s+(?:"[^"]*"|'[^']*'|\([^)]*\)))?\s*\)/gi,w=/!\[([^\]]*)\]\[([^\]]+)\]/g;function T(e,t){let n=new Map;for(let t of e.matchAll(S))n.set(E(t[1]??``),t[2]??``);return e.replace(C,(e,n,r)=>`[${n.trim()||t}](${r})`).replace(w,(e,r,i)=>{let a=n.get(E(i));return a?`[${r.trim()||t}](${a})`:e})}function E(e){return e.trim().replace(/\s+/g,` `).toLowerCase()}var D=r();function O(){return{textContent:null,binaryBuffer:null,extractedText:null,extractedTextTruncated:!1}}function k(e){let t=(0,x.c)(30),{subtitle:n,openInlineUrl:r,landingUrl:i,...a}=e,{expanded:o,setExpanded:l}=m(),u=c(a.language),f;t[0]===u?f=t[1]:(f=async()=>{let e=await s(window.location.href);_(e?`success`:`warning`,e?u.sharesSettings.copied:u.clipboard.copyFailed)},t[0]=u,t[1]=f);let h=f,g=o&&`fixed inset-0 z-[65] h-[100dvh] max-w-none`,v;t[2]===g?v=t[3]:(v=d(`mx-auto flex h-full min-h-0 w-full max-w-[var(--max-width-app-main)] flex-col bg-surface-panel`,g),t[2]=g,t[3]=v);let y;t[4]!==l||t[5]!==a.loadError||t[6]!==a.loading?(y=!a.loading&&!a.loadError?()=>l(A):void 0,t[4]=l,t[5]=a.loadError,t[6]=a.loading,t[7]=y):y=t[7];let b;t[8]===i?b=t[9]:(b=()=>window.location.assign(i),t[8]=i,t[9]=b);let S;t[10]===h?S=t[11]:(S=()=>void h(),t[10]=h,t[11]=S);let C=a.loading||!!a.loadError,w;t[12]!==S||t[13]!==C?(w={onClick:S,disabled:C},t[12]=S,t[13]=C,t[14]=w):w=t[14];let T;t[15]===r?T=t[16]:(T={href:r},t[15]=r,t[16]=T);let E;t[17]!==o||t[18]!==n||t[19]!==y||t[20]!==b||t[21]!==w||t[22]!==T?(E={subtitle:n,expanded:o,onToggleExpanded:y,onClose:b,share:w,openInBrowser:T},t[17]=o,t[18]=n,t[19]=y,t[20]=b,t[21]=w,t[22]=T,t[23]=E):E=t[23];let O;t[24]!==a||t[25]!==E?(O=(0,D.jsx)(p,{...a,header:E}),t[24]=a,t[25]=E,t[26]=O):O=t[26];let k;return t[27]!==O||t[28]!==v?(k=(0,D.jsx)(`div`,{className:v,children:O}),t[27]=O,t[28]=v,t[29]=k):k=t[29],k}function A(e){return!e}function j(){let{token:e}=a(),t=l(e=>e.language),n=t===`zh`?P:F,[r,s]=(0,b.useState)(null),[c,d]=(0,b.useState)(O),[p,m]=(0,b.useState)(!0),[_,x]=(0,b.useState)(null),[S,C]=(0,b.useState)(null),[w,E]=(0,b.useState)(null),A=(0,b.useMemo)(()=>{if(!r||!e||r.kind!==`file`)return null;let t=v(r.fileName,r.mimeType);return{id:`share:${e}:${r.fileName}`,context:`share`,fileName:r.fileName,mimeType:t,size:r.fileSize,type:g(r.fileName,t),source:{kind:`share`,token:e}}},[r,e]);(0,b.useEffect)(()=>{if(!e){x(n.invalidLink),m(!1);return}let t=!1;return(async()=>{try{m(!0),x(null),d(O()),C(null),E(null);let r=await fetch(u(`/s/${encodeURIComponent(e)}/meta`));if(!r.ok){t||x(r.status===404?n.notFound:n.expired);return}let a=await r.json();if(t)return;if(s(a),!a.valid){x(n.expired);return}if(a.kind===`note`||a.kind===`session`){let r=await fetch(u(`/s/${encodeURIComponent(e)}/view`),{method:`POST`});if(!r.ok){x(r.status===404?n.notFound:n.expired);return}let i=await r.json();!t&&i.payload?.kind===`note`&&C(i.payload),!t&&i.payload?.kind===`session`&&E(i.payload);return}if(a.kind!==`file`)return;let o=v(a.fileName,a.mimeType),c=g(a.fileName,o),l=y(c),f=u(`/s/${encodeURIComponent(e)}?inline=1`);if(l===`text`){if(a.fileSize>5242880){x(n.tooLarge);return}let e=await fetch(f);if(!e.ok){x(n.expired);return}let r=await e.text();t||d({...O(),textContent:r});return}if(l===`binary`){if(a.fileSize>33554432){x(n.tooLarge);return}let e=await fetch(f);if(!e.ok){x(n.expired);return}let r=await e.arrayBuffer();if(t)return;if(c===`pptx`){let{processPptx:e}=await i(async()=>{let{processPptx:e}=await import(`./attachment-process-heavy-B2_kr5EA.js`);return{processPptx:e}},__vite__mapDeps([0,1,2,3])),{extractedText:t}=await e(r,a.fileName),n=t.length>h;d({textContent:null,binaryBuffer:r,extractedText:n?t.slice(0,h):t,extractedTextTruncated:n});return}d({...O(),binaryBuffer:r})}}catch(e){t||x(e instanceof Error?e.message:String(e))}finally{t||m(!1)}})(),()=>{t=!0}},[e,n.expired,n.invalidLink,n.notFound,n.tooLarge]);let j=e?u(`/s/${encodeURIComponent(e)}?dl=1`):`#`,I=e?u(`/s/${encodeURIComponent(e)}?inline=1`):`#`;return A&&r&&e?(0,D.jsx)(k,{language:t,descriptor:A,loading:p,loadError:_,textContent:c.textContent,binaryBuffer:c.binaryBuffer,extractedText:c.extractedText,extractedTextTruncated:c.extractedTextTruncated,subtitle:(0,D.jsxs)(`span`,{className:`truncate`,children:[N(r.fileSize),` · `,n.expiresAt,` `,new Date(r.expiresAt).toLocaleString(t===`zh`?`zh-CN`:`en-US`)]}),openInlineUrl:I,landingUrl:u(`/s/${encodeURIComponent(e)}`),actions:{onDownload:()=>{window.location.href=j},canDownload:!p&&!_}}):(0,D.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden bg-surface-base`,children:[(0,D.jsxs)(`header`,{className:`flex h-12 shrink-0 items-center gap-3 border-b border-edge px-4`,children:[(0,D.jsx)(`span`,{className:`text-lg`,"aria-hidden":!0,children:`#`}),(0,D.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[r?(0,D.jsx)(`div`,{className:`truncate text-sm font-semibold text-fg`,title:r.fileName,children:r.fileName}):p?(0,D.jsx)(f,{className:`h-4 w-48 max-w-full`}):(0,D.jsx)(`div`,{className:`truncate text-sm font-semibold text-fg`,children:n.error}),r?(0,D.jsxs)(`div`,{className:`truncate text-xs text-fg-muted`,children:[N(r.fileSize),` · `,n.expiresAt,` `,new Date(r.expiresAt).toLocaleString(t===`zh`?`zh-CN`:`en-US`)]}):null]})]}),(0,D.jsx)(`main`,{className:`flex min-h-0 w-full flex-1 flex-col overflow-y-auto overscroll-contain px-3 py-6 sm:px-5 xl:px-6`,children:p?(0,D.jsxs)(`div`,{className:`flex min-h-[70vh] flex-1 flex-col overflow-hidden rounded-lg bg-surface-panel p-4 shadow-surface`,"aria-busy":`true`,children:[(0,D.jsx)(f,{className:`h-5 w-56 max-w-full`}),(0,D.jsxs)(`div`,{className:`mt-5 grid gap-3`,children:[(0,D.jsx)(f,{className:`h-4 w-full`}),(0,D.jsx)(f,{className:`h-4 w-11/12`}),(0,D.jsx)(f,{className:`h-4 w-10/12`}),(0,D.jsx)(f,{className:`h-4 w-3/4`})]}),(0,D.jsx)(f,{className:`mt-6 min-h-0 flex-1 rounded-lg`})]}):_?(0,D.jsxs)(`div`,{className:`rounded-lg bg-surface-panel p-6 shadow-surface text-sm text-fg`,children:[(0,D.jsx)(`p`,{className:`font-medium`,children:n.error}),(0,D.jsx)(`p`,{className:`mt-1 text-fg-muted`,children:_})]}):r?.kind===`directory`?(0,D.jsx)(`div`,{className:`rounded-lg bg-surface-panel p-6 shadow-surface text-sm text-fg-muted`,children:n.directoryHint}):r?.kind===`note`&&S?(0,D.jsxs)(`article`,{className:`mx-auto w-full max-w-3xl rounded-xl border border-edge-subtle bg-surface-panel px-6 py-8 shadow-surface sm:px-10 sm:py-10`,children:[(0,D.jsx)(`h1`,{className:`text-3xl font-bold tracking-tight text-fg`,children:S.title}),(0,D.jsxs)(`div`,{className:`mt-2 text-xs text-fg-muted`,children:[n.sharedAt,` `,new Date(S.snapshotAt).toLocaleString(t===`zh`?`zh-CN`:`en-US`),` · `,n.expiresAt,` `,new Date(S.expiresAt).toLocaleString(t===`zh`?`zh-CN`:`en-US`)]}),S.description?(0,D.jsx)(`p`,{className:`mt-5 rounded-lg bg-surface-subtle px-4 py-3 text-sm leading-6 text-fg-muted`,children:S.description}):null,(0,D.jsx)(o,{content:T(S.markdown,n.remoteImageBlocked),className:`mt-8`}),(0,D.jsx)(`footer`,{className:`mt-10 border-t border-edge-subtle pt-4 text-center text-xs text-fg-subtle`,children:n.sharedVia})]}):r?.kind===`session`&&w?(0,D.jsxs)(`article`,{className:`mx-auto w-full max-w-4xl rounded-xl border border-edge-subtle bg-surface-panel px-4 py-7 shadow-surface sm:px-8 sm:py-9`,children:[(0,D.jsxs)(`header`,{className:`mx-auto max-w-3xl border-b border-edge-subtle pb-5`,children:[(0,D.jsx)(`h1`,{className:`text-2xl font-bold tracking-tight text-fg sm:text-3xl`,children:w.title}),(0,D.jsxs)(`div`,{className:`mt-2 text-xs text-fg-muted`,children:[n.sharedAt,` `,new Date(w.snapshotAt).toLocaleString(t===`zh`?`zh-CN`:`en-US`),` · `,n.expiresAt,` `,new Date(w.expiresAt).toLocaleString(t===`zh`?`zh-CN`:`en-US`)]}),w.description?(0,D.jsx)(`p`,{className:`mt-4 text-sm leading-6 text-fg-muted`,children:w.description}):null]}),(0,D.jsxs)(`div`,{className:`mx-auto mt-6 max-w-3xl space-y-5`,children:[w.messages.map(e=>(0,D.jsxs)(`section`,{className:e.role===`user`?`ml-auto max-w-[85%]`:`mr-auto max-w-full`,children:[(0,D.jsx)(`div`,{className:`mb-1 text-xs font-medium text-fg-subtle`,children:e.role===`user`?n.you:n.assistant}),(0,D.jsxs)(`div`,{className:e.role===`user`?`rounded-2xl bg-surface-subtle px-4 py-3`:`px-1 py-1`,children:[(0,D.jsx)(o,{content:T(e.markdown,n.remoteImageBlocked)}),w.attachments.filter(t=>e.attachmentIds.includes(t.id)).map(e=>(0,D.jsx)(M,{attachment:e},e.id)),w.toolActivities.filter(t=>t.messageId===e.id).map(e=>(0,D.jsxs)(`div`,{className:`mt-2 inline-flex items-center gap-1.5 rounded-md border border-edge-subtle px-2 py-1 text-xs text-fg-muted`,children:[(0,D.jsx)(`span`,{children:e.toolName}),(0,D.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,D.jsx)(`span`,{children:e.status===`completed`?n.toolCompleted:n.toolFailed})]},e.id))]})]},e.id)),w.toolActivities.filter(e=>!e.messageId).map(e=>(0,D.jsxs)(`div`,{className:`text-center text-xs text-fg-muted`,children:[e.toolName,` · `,e.status===`completed`?n.toolCompleted:n.toolFailed]},e.id))]}),(0,D.jsx)(`footer`,{className:`mx-auto mt-10 max-w-3xl border-t border-edge-subtle pt-4 text-center text-xs text-fg-subtle`,children:n.sharedVia})]}):null})]})}function M(e){let t=(0,x.c)(15),{attachment:n}=e;if(n.mimeType.startsWith(`image/`)){let e;return t[0]!==n.fileName||t[1]!==n.url?(e=(0,D.jsx)(`img`,{src:n.url,alt:n.fileName,loading:`lazy`,className:`mt-3 max-h-[28rem] max-w-full rounded-lg border border-edge-subtle object-contain`}),t[0]=n.fileName,t[1]=n.url,t[2]=e):e=t[2],e}if(n.mimeType.startsWith(`audio/`)){let e;return t[3]===n.url?e=t[4]:(e=(0,D.jsx)(`audio`,{src:n.url,controls:!0,preload:`none`,className:`mt-3 max-w-full`}),t[3]=n.url,t[4]=e),e}let r=n.url,i;t[5]===n.fileName?i=t[6]:(i=(0,D.jsx)(`span`,{className:`min-w-0 truncate`,children:n.fileName}),t[5]=n.fileName,t[6]=i);let a;t[7]===n.size?a=t[8]:(a=N(n.size),t[7]=n.size,t[8]=a);let o;t[9]===a?o=t[10]:(o=(0,D.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:a}),t[9]=a,t[10]=o);let s;return t[11]!==n.url||t[12]!==i||t[13]!==o?(s=(0,D.jsxs)(`a`,{href:r,target:`_blank`,rel:`noreferrer`,className:`mt-3 flex items-center justify-between gap-3 rounded-lg border border-edge-subtle px-3 py-2 text-sm text-accent hover:bg-surface-hover`,children:[i,o]}),t[11]=n.url,t[12]=i,t[13]=o,t[14]=s):s=t[14],s}function N(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:e<1073741824?`${(e/1048576).toFixed(1)} MB`:`${(e/1073741824).toFixed(1)} GB`}var P={error:`加载失败`,expired:`链接已失效`,notFound:`链接不存在`,invalidLink:`链接无效`,expiresAt:`有效期至`,directoryHint:`目录分享请使用主页面浏览。`,tooLarge:`文件过大,无法在线预览,请下载查看。`,sharedAt:`分享于`,sharedVia:`通过 xopc 分享`,you:`你`,assistant:`助手`,toolCompleted:`已完成`,toolFailed:`失败`,remoteImageBlocked:`远程图片(点击打开)`},F={error:`Failed to load`,expired:`Link no longer valid`,notFound:`Link not found`,invalidLink:`Invalid link`,expiresAt:`Expires`,directoryHint:`Directory shares are browsed from the main page.`,tooLarge:`This file is too large to preview here. Please download it instead.`,sharedAt:`Shared`,sharedVia:`Shared via xopc`,you:`You`,assistant:`Assistant`,toolCompleted:`completed`,toolFailed:`failed`,remoteImageBlocked:`Remote image (open manually)`};export{j as SharePreviewPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{p as i}from"./chunk-KS7C4IRE-BaASWQor.js";import{a,n as o,o as s,r as c,s as l,t as u}from"./dist-CpzYSoz7.js";import{t as d}from"./check-DUBLcKHA.js";import{n as f,r as p}from"./popover-select-C-Hj-nXR.js";import{t as m}from"./copy-Dv6d4Dvw.js";import{t as h}from"./loader-circle-CifKLtgG.js";import{t as g}from"./plus-Q2yW6OE7.js";import{t as _}from"./x-B_N4OPjy.js";import{t as v}from"./copy-to-clipboard-HOJ79TWv.js";import{t as y}from"./messages-Cf5hpZE6.js";import{a as b,n as x,r as S,s as C}from"./locale-store-CF4erhjB.js";import{t as w}from"./cn-JdwAhgNB.js";import{i as ee}from"./vendor-swr-BIWyz7Rc.js";import{t as T}from"./button-CtTvuElV.js";import{n as E,r as D}from"./gateway-config-swr-CMNbl0FZ.js";import{t as O}from"./skeleton-BwbyijEw.js";import{$r as te,Bl as k,Bs as A,Ei as j,Ns as M,Oi as N,Pc as P,Tl as F,ai as I,bl as ne,ca as re,ci as L,dn as ie,ii as ae,io as R,li as oe,mn as se,oi as z,ri as B,si as V,ti as ce,tu as H,uc as le,ui as ue}from"./index-BcaF-dgQ.js";import{n as de,r as U,t as fe}from"./settings-page-layout-BRQNel6r.js";import{t as pe}from"./settings-loading-skeleton-CAmWMaOT.js";import{t as W}from"./settings-form-section-DVY-8_B9.js";import{t as me}from"./page-tabs-CX9T71by.js";var G=e(t(),1),he=n(),K={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`],noteEnabled:!0,noteMaxTotalSizeMb:250,noteMaxAttachmentCount:50,siteEnabled:!0,siteDefaultTtlHours:24,siteMaxTtlDays:30,maxActiveSites:50,siteMaxRootDirSizeMb:1024,siteMaxFileCount:2e4};function ge(){return structuredClone(K)}var q=36e5,J=864e5,Y=1048576;function _e(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function X(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 ve(e){let t=_e(e)?e:{},n=_e(t.gateway)?t.gateway:{},r=_e(n.share)?n.share:{},i=_e(r.directory)?r.directory:{},a=_e(r.note)?r.note:{},o=_e(n.siteShare)?n.siteShare:{},s=_e(o.static)?o.static:{},c=typeof r.defaultTtlMs==`number`&&Number.isFinite(r.defaultTtlMs)?Math.floor(r.defaultTtlMs):K.defaultTtlHours*q,l=typeof r.maxTtlMs==`number`&&Number.isFinite(r.maxTtlMs)?Math.floor(r.maxTtlMs):K.maxTtlDays*J,u=typeof r.maxFileSize==`number`&&Number.isFinite(r.maxFileSize)?Math.floor(r.maxFileSize):K.maxFileSizeMb*Y,d=typeof i.maxFolderSize==`number`&&Number.isFinite(i.maxFolderSize)?Math.floor(i.maxFolderSize):K.directoryMaxFolderSizeMb*Y,f=typeof o.defaultTtlMs==`number`&&Number.isFinite(o.defaultTtlMs)?Math.floor(o.defaultTtlMs):K.siteDefaultTtlHours*q,p=typeof o.maxTtlMs==`number`&&Number.isFinite(o.maxTtlMs)?Math.floor(o.maxTtlMs):K.siteMaxTtlDays*J,m=typeof s.maxRootDirSize==`number`&&Number.isFinite(s.maxRootDirSize)?Math.floor(s.maxRootDirSize):K.siteMaxRootDirSizeMb*Y,h=typeof a.maxTotalSize==`number`&&Number.isFinite(a.maxTotalSize)?Math.floor(a.maxTotalSize):K.noteMaxTotalSizeMb*Y;return{enabled:r.enabled!==!1,defaultTtlHours:Math.max(1,Math.round(c/q)),maxTtlDays:Math.max(1,Math.round(l/J)),maxActiveShares:typeof r.maxActiveShares==`number`&&Number.isFinite(r.maxActiveShares)?Math.max(1,Math.min(1e4,Math.floor(r.maxActiveShares))):K.maxActiveShares,maxFileSizeMb:Math.max(1,Math.round(u/Y)),directoryMaxFolderSizeMb:Math.max(1,Math.round(d/Y)),directoryMaxFileCount:typeof i.maxFileCount==`number`&&Number.isFinite(i.maxFileCount)?Math.max(1,Math.min(1e5,Math.floor(i.maxFileCount))):K.directoryMaxFileCount,inlinePreviewMimes:X(r.inlinePreviewMimes,32).length?X(r.inlinePreviewMimes,32):[...K.inlinePreviewMimes],noteEnabled:a.enabled!==!1,noteMaxTotalSizeMb:Math.max(1,Math.round(h/Y)),noteMaxAttachmentCount:typeof a.maxAttachmentCount==`number`&&Number.isFinite(a.maxAttachmentCount)?Math.max(0,Math.min(500,Math.floor(a.maxAttachmentCount))):K.noteMaxAttachmentCount,siteEnabled:o.enabled!==!1,siteDefaultTtlHours:Math.max(1,Math.round(f/q)),siteMaxTtlDays:Math.max(1,Math.round(p/J)),maxActiveSites:typeof o.maxActiveSites==`number`&&Number.isFinite(o.maxActiveSites)?Math.max(1,Math.min(1e3,Math.floor(o.maxActiveSites))):K.maxActiveSites,siteMaxRootDirSizeMb:Math.max(1,Math.round(m/Y)),siteMaxFileCount:typeof s.maxFileCount==`number`&&Number.isFinite(s.maxFileCount)?Math.max(1,Math.min(1e5,Math.floor(s.maxFileCount))):K.siteMaxFileCount}}function Z(e){let t=e.defaultTtlHours*q,n=e.maxTtlDays*J,r=e.siteDefaultTtlHours*q,i=e.siteMaxTtlDays*J;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.`:e.noteMaxTotalSizeMb<1||e.noteMaxTotalSizeMb>2048?`Maximum Note snapshot size must be between 1 MB and 2 GB.`:e.noteMaxAttachmentCount<0||e.noteMaxAttachmentCount>500?`Maximum Note attachment count must be between 0 and 500.`: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 ye(e){let t=Z(e);if(t)throw Error(t);await b(S(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{share:{enabled:e.enabled,defaultTtlMs:e.defaultTtlHours*q,maxTtlMs:e.maxTtlDays*J,maxActiveShares:e.maxActiveShares,maxFileSize:e.maxFileSizeMb*Y,inlinePreviewMimes:e.inlinePreviewMimes,directory:{maxFolderSize:e.directoryMaxFolderSizeMb*Y,maxFileCount:e.directoryMaxFileCount},note:{enabled:e.noteEnabled,maxTotalSize:e.noteMaxTotalSizeMb*Y,maxAttachmentCount:e.noteMaxAttachmentCount}},siteShare:{enabled:e.siteEnabled,defaultTtlMs:e.siteDefaultTtlHours*q,maxTtlMs:e.siteMaxTtlDays*J,maxActiveSites:e.maxActiveSites,static:{maxRootDirSize:e.siteMaxRootDirSizeMb*Y,maxFileCount:e.siteMaxFileCount}}}})}),E()}var Q=r();function be(){return w(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,R,`dark:border-edge`)}function xe({hasToken:e}){let t=y(x(e=>e.language)).sharesSettings,{data:n,isLoading:r}=D(e),i=(0,G.useMemo)(()=>n?.payload?.config===void 0?null:structuredClone(ve(n.payload.config)),[n]),a=(0,G.useRef)(!1),[o,s]=(0,G.useState)(null),[c,l]=(0,G.useState)(!1),[u,d]=(0,G.useState)(null),[f,p]=(0,G.useState)(!1),m=o??i,h=i,g=(0,G.useMemo)(()=>!m||!h?!1:JSON.stringify(m)!==JSON.stringify(h),[m,h]),_=(0,G.useCallback)(e=>{a.current=!0,s(t=>{let n=t??h;return n?{...n,...e}:null})},[h]),v=(0,G.useCallback)(async()=>{if(!(!m||c)){l(!0),d(null),p(!1);try{await ye(m),a.current=!1,s(null),p(!0),window.setTimeout(()=>p(!1),2500)}catch(e){d(e instanceof Error?e.message:t.policySaveError)}finally{l(!1)}}},[m,c,t.policySaveError]),b=(0,G.useCallback)(()=>{a.current=!1,s(null),d(null),p(!1)},[]);return!e||!m?r?(0,Q.jsx)(W,{children:(0,Q.jsx)(pe,{rows:2})}):null:(0,Q.jsxs)(W,{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)(T,{type:`button`,variant:`secondary`,disabled:c,onClick:()=>_(ge()),children:t.policyUseRecommended}),(0,Q.jsx)(T,{type:`button`,variant:`secondary`,disabled:!g||c,onClick:b,children:t.policyDiscard}),(0,Q.jsx)(T,{type:`button`,variant:`primary`,disabled:!g||c,onClick:()=>void v(),children:c?t.policySaving:t.policySave})]})]}),g?(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)(Se,{t,form:m,onChange:_})]})}function Se(e){let t=(0,he.c)(189),{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 C=!r.enabled,w;t[47]===i?w=t[48]:(w=e=>i({directoryMaxFolderSizeMb:e}),t[47]=i,t[48]=w);let ee;t[49]!==r.directoryMaxFolderSizeMb||t[50]!==n.policyDirectoryMaxFolderSizeHint||t[51]!==n.policyDirectoryMaxFolderSizeMb||t[52]!==C||t[53]!==w?(ee=(0,Q.jsx)($,{id:`share-directory-max-size-mb`,label:n.policyDirectoryMaxFolderSizeMb,hint:n.policyDirectoryMaxFolderSizeHint,value:r.directoryMaxFolderSizeMb,min:1,max:10240,disabled:C,onChange:w}),t[49]=r.directoryMaxFolderSizeMb,t[50]=n.policyDirectoryMaxFolderSizeHint,t[51]=n.policyDirectoryMaxFolderSizeMb,t[52]=C,t[53]=w,t[54]=ee):ee=t[54];let T=!r.enabled,E;t[55]===i?E=t[56]:(E=e=>i({directoryMaxFileCount:e}),t[55]=i,t[56]=E);let D;t[57]!==r.directoryMaxFileCount||t[58]!==n.policyDirectoryMaxFileCount||t[59]!==n.policyDirectoryMaxFileCountHint||t[60]!==T||t[61]!==E?(D=(0,Q.jsx)($,{id:`share-directory-max-files`,label:n.policyDirectoryMaxFileCount,hint:n.policyDirectoryMaxFileCountHint,value:r.directoryMaxFileCount,min:1,max:1e5,disabled:T,onChange:E}),t[57]=r.directoryMaxFileCount,t[58]=n.policyDirectoryMaxFileCount,t[59]=n.policyDirectoryMaxFileCountHint,t[60]=T,t[61]=E,t[62]=D):D=t[62];let O;t[63]!==g||t[64]!==y||t[65]!==S||t[66]!==ee||t[67]!==D||t[68]!==p?(O=(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[p,g,y,S,ee,D]}),t[63]=g,t[64]=y,t[65]=S,t[66]=ee,t[67]=D,t[68]=p,t[69]=O):O=t[69];let te=!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]!==te||t[75]!==k?(A=(0,Q.jsx)(Ce,{t:n,values:r.inlinePreviewMimes,disabled:te,onChange:k}),t[72]=r.inlinePreviewMimes,t[73]=n,t[74]=te,t[75]=k,t[76]=A):A=t[76];let j;t[77]!==O||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,O,A]}),t[77]=O,t[78]=A,t[79]=s,t[80]=u,t[81]=j):j=t[81];let M;t[82]===n.policyNoteSection?M=t[83]:(M=(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.policyNoteSection}),t[82]=n.policyNoteSection,t[83]=M);let N;t[84]===n.policyNoteSectionHint?N=t[85]:(N=(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:n.policyNoteSectionHint}),t[84]=n.policyNoteSectionHint,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({noteEnabled:e.target.checked}),t[89]=i,t[90]=F);let I;t[91]!==r.noteEnabled||t[92]!==F?(I=(0,Q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.noteEnabled,onChange:F}),t[91]=r.noteEnabled,t[92]=F,t[93]=I):I=t[93];let ne;t[94]!==n.policyNoteEnabled||t[95]!==I?(ne=(0,Q.jsxs)(`label`,{className:`mb-4 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[I,n.policyNoteEnabled]}),t[94]=n.policyNoteEnabled,t[95]=I,t[96]=ne):ne=t[96];let re=!r.enabled||!r.noteEnabled,L;t[97]===i?L=t[98]:(L=e=>i({noteMaxTotalSizeMb:e}),t[97]=i,t[98]=L);let ie;t[99]!==r.noteMaxTotalSizeMb||t[100]!==n.policyNoteMaxTotalSizeHint||t[101]!==n.policyNoteMaxTotalSizeMb||t[102]!==re||t[103]!==L?(ie=(0,Q.jsx)($,{id:`share-note-max-size-mb`,label:n.policyNoteMaxTotalSizeMb,hint:n.policyNoteMaxTotalSizeHint,value:r.noteMaxTotalSizeMb,min:1,max:2048,disabled:re,onChange:L}),t[99]=r.noteMaxTotalSizeMb,t[100]=n.policyNoteMaxTotalSizeHint,t[101]=n.policyNoteMaxTotalSizeMb,t[102]=re,t[103]=L,t[104]=ie):ie=t[104];let ae=!r.enabled||!r.noteEnabled,R;t[105]===i?R=t[106]:(R=e=>i({noteMaxAttachmentCount:e}),t[105]=i,t[106]=R);let oe;t[107]!==r.noteMaxAttachmentCount||t[108]!==n.policyNoteMaxAttachmentCount||t[109]!==n.policyNoteMaxAttachmentCountHint||t[110]!==ae||t[111]!==R?(oe=(0,Q.jsx)($,{id:`share-note-max-attachments`,label:n.policyNoteMaxAttachmentCount,hint:n.policyNoteMaxAttachmentCountHint,value:r.noteMaxAttachmentCount,min:0,max:500,disabled:ae,onChange:R}),t[107]=r.noteMaxAttachmentCount,t[108]=n.policyNoteMaxAttachmentCount,t[109]=n.policyNoteMaxAttachmentCountHint,t[110]=ae,t[111]=R,t[112]=oe):oe=t[112];let se;t[113]!==ie||t[114]!==oe?(se=(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[ie,oe]}),t[113]=ie,t[114]=oe,t[115]=se):se=t[115];let z;t[116]!==P||t[117]!==ne||t[118]!==se?(z=(0,Q.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-muted/25 p-4`,children:[P,ne,se]}),t[116]=P,t[117]=ne,t[118]=se,t[119]=z):z=t[119];let B;t[120]===n.policySiteSection?B=t[121]:(B=(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.policySiteSection}),t[120]=n.policySiteSection,t[121]=B);let V;t[122]===n.policySiteSectionHint?V=t[123]:(V=(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:n.policySiteSectionHint}),t[122]=n.policySiteSectionHint,t[123]=V);let ce;t[124]!==B||t[125]!==V?(ce=(0,Q.jsxs)(`div`,{className:`mb-4`,children:[B,V]}),t[124]=B,t[125]=V,t[126]=ce):ce=t[126];let H;t[127]===i?H=t[128]:(H=e=>i({siteEnabled:e.target.checked}),t[127]=i,t[128]=H);let le;t[129]!==r.siteEnabled||t[130]!==H?(le=(0,Q.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.siteEnabled,onChange:H}),t[129]=r.siteEnabled,t[130]=H,t[131]=le):le=t[131];let ue;t[132]!==n.policySiteEnabled||t[133]!==le?(ue=(0,Q.jsxs)(`label`,{className:`mb-4 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[le,n.policySiteEnabled]}),t[132]=n.policySiteEnabled,t[133]=le,t[134]=ue):ue=t[134];let de=!r.siteEnabled,U;t[135]===i?U=t[136]:(U=e=>i({siteDefaultTtlHours:e}),t[135]=i,t[136]=U);let fe;t[137]!==r.siteDefaultTtlHours||t[138]!==n.policySiteDefaultTtlHint||t[139]!==n.policySiteDefaultTtlHours||t[140]!==de||t[141]!==U?(fe=(0,Q.jsx)($,{id:`site-share-default-ttl-hours`,label:n.policySiteDefaultTtlHours,hint:n.policySiteDefaultTtlHint,value:r.siteDefaultTtlHours,min:1,max:168,disabled:de,onChange:U}),t[137]=r.siteDefaultTtlHours,t[138]=n.policySiteDefaultTtlHint,t[139]=n.policySiteDefaultTtlHours,t[140]=de,t[141]=U,t[142]=fe):fe=t[142];let pe=!r.siteEnabled,W;t[143]===i?W=t[144]:(W=e=>i({siteMaxTtlDays:e}),t[143]=i,t[144]=W);let me;t[145]!==r.siteMaxTtlDays||t[146]!==n.policySiteMaxTtlDays||t[147]!==n.policySiteMaxTtlHint||t[148]!==pe||t[149]!==W?(me=(0,Q.jsx)($,{id:`site-share-max-ttl-days`,label:n.policySiteMaxTtlDays,hint:n.policySiteMaxTtlHint,value:r.siteMaxTtlDays,min:1,max:30,disabled:pe,onChange:W}),t[145]=r.siteMaxTtlDays,t[146]=n.policySiteMaxTtlDays,t[147]=n.policySiteMaxTtlHint,t[148]=pe,t[149]=W,t[150]=me):me=t[150];let G=!r.siteEnabled,K;t[151]===i?K=t[152]:(K=e=>i({maxActiveSites:e}),t[151]=i,t[152]=K);let ge;t[153]!==r.maxActiveSites||t[154]!==n.policyMaxActiveSites||t[155]!==n.policyMaxActiveSitesHint||t[156]!==G||t[157]!==K?(ge=(0,Q.jsx)($,{id:`site-share-max-active`,label:n.policyMaxActiveSites,hint:n.policyMaxActiveSitesHint,value:r.maxActiveSites,min:1,max:1e3,disabled:G,onChange:K}),t[153]=r.maxActiveSites,t[154]=n.policyMaxActiveSites,t[155]=n.policyMaxActiveSitesHint,t[156]=G,t[157]=K,t[158]=ge):ge=t[158];let q=!r.siteEnabled,J;t[159]===i?J=t[160]:(J=e=>i({siteMaxRootDirSizeMb:e}),t[159]=i,t[160]=J);let Y;t[161]!==r.siteMaxRootDirSizeMb||t[162]!==n.policySiteMaxRootDirSizeHint||t[163]!==n.policySiteMaxRootDirSizeMb||t[164]!==q||t[165]!==J?(Y=(0,Q.jsx)($,{id:`site-share-max-root-size-mb`,label:n.policySiteMaxRootDirSizeMb,hint:n.policySiteMaxRootDirSizeHint,value:r.siteMaxRootDirSizeMb,min:1,max:10240,disabled:q,onChange:J}),t[161]=r.siteMaxRootDirSizeMb,t[162]=n.policySiteMaxRootDirSizeHint,t[163]=n.policySiteMaxRootDirSizeMb,t[164]=q,t[165]=J,t[166]=Y):Y=t[166];let _e=!r.siteEnabled,X;t[167]===i?X=t[168]:(X=e=>i({siteMaxFileCount:e}),t[167]=i,t[168]=X);let ve;t[169]!==r.siteMaxFileCount||t[170]!==n.policySiteMaxFileCount||t[171]!==n.policySiteMaxFileCountHint||t[172]!==_e||t[173]!==X?(ve=(0,Q.jsx)($,{id:`site-share-max-files`,label:n.policySiteMaxFileCount,hint:n.policySiteMaxFileCountHint,value:r.siteMaxFileCount,min:1,max:1e5,disabled:_e,onChange:X}),t[169]=r.siteMaxFileCount,t[170]=n.policySiteMaxFileCount,t[171]=n.policySiteMaxFileCountHint,t[172]=_e,t[173]=X,t[174]=ve):ve=t[174];let Z;t[175]!==fe||t[176]!==me||t[177]!==ge||t[178]!==Y||t[179]!==ve?(Z=(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[fe,me,ge,Y,ve]}),t[175]=fe,t[176]=me,t[177]=ge,t[178]=Y,t[179]=ve,t[180]=Z):Z=t[180];let ye;t[181]!==ce||t[182]!==ue||t[183]!==Z?(ye=(0,Q.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-muted/25 p-4`,children:[ce,ue,Z]}),t[181]=ce,t[182]=ue,t[183]=Z,t[184]=ye):ye=t[184];let be;return t[185]!==j||t[186]!==z||t[187]!==ye?(be=(0,Q.jsxs)(`div`,{className:`space-y-4`,children:[j,z,ye]}),t[185]=j,t[186]=z,t[187]=ye,t[188]=be):be=t[188],be}function $(e){let t=(0,he.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=w(be(),`max-w-xs font-mono text-xs`),t[3]=d):d=t[3];let f;t[4]!==s||t[5]!==o||t[6]!==l?(f=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]=f):f=t[7];let p;t[8]!==c||t[9]!==n||t[10]!==s||t[11]!==o||t[12]!==f||t[13]!==a?(p=(0,Q.jsx)(`input`,{id:n,type:`number`,min:o,max:s,disabled:c,className:d,value:a,onChange:f}),t[8]=c,t[9]=n,t[10]=s,t[11]=o,t[12]=f,t[13]=a,t[14]=p):p=t[14];let m;t[15]===i?m=t[16]:(m=(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:i}),t[15]=i,t[16]=m);let h;return t[17]!==u||t[18]!==p||t[19]!==m?(h=(0,Q.jsxs)(`div`,{children:[u,p,m]}),t[17]=u,t[18]=p,t[19]=m,t[20]=h):h=t[20],h}function Ce(e){let t=(0,he.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 f;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(f=w(be(),`font-mono text-xs`),t[13]=f):f=t[13];let p=i||r.length>=32,m;t[14]===s?m=t[15]:(m=e=>{e.key===`Enter`&&(e.preventDefault(),s(e.target.value),e.target.value=``)},t[14]=s,t[15]=m);let h;t[16]!==n.policyMimePlaceholder||t[17]!==p||t[18]!==m?(h=(0,Q.jsx)(`input`,{className:f,placeholder:n.policyMimePlaceholder,disabled:p,onKeyDown:m}),t[16]=n.policyMimePlaceholder,t[17]=p,t[18]=m,t[19]=h):h=t[19];let g;return t[20]!==c||t[21]!==l||t[22]!==d||t[23]!==h?(g=(0,Q.jsxs)(`div`,{className:`space-y-2 border-t border-edge pt-4`,children:[c,l,d,h]}),t[20]=c,t[21]=l,t[22]=d,t[23]=h,t[24]=g):g=t[24],g}function we(e){let t=(0,he.c)(70),{open:n,onOpenChange:r,onConfirm:i,initialPath:d,selectKind:m,sessionKey:g,agentId:v}=e,b=m===void 0?`any`:m,S=y(x(De)),E=S.workspace,D=S.sharesSettings,O=te(Ee),{data:k}=ee(C(Te)?`picker-agents-list`:null,se),A;bb0:{let e;t[0]===v?e=t[1]:(e=v?.trim(),t[0]=v,t[1]=e);let n=e;if(n){A=n;break bb0}let r;t[2]===O?r=t[3]:(r=O.trim(),t[2]=O,t[3]=r);let i=r;if(i){A=i;break bb0}if(k?.defaultId){A=k.defaultId;break bb0}if(k?.agents?.[0]?.id){A=k.agents[0].id;break bb0}A=``}let M=A,[N,P]=(0,G.useState)(M),F,I;t[4]===M?(F=t[5],I=t[6]):(F=()=>{P(M)},I=[M],t[4]=M,t[5]=F,t[6]=I),(0,G.useEffect)(F,I);let{tree:re,loading:L,error:ae,loadRoot:R,loadChildren:oe,reset:z}=ce(N,g??null),B;t[7]===d?B=t[8]:(B=d?{path:d,isDirectory:!1}:null,t[7]=d,t[8]=B);let[V,H]=(0,G.useState)(B),ue;t[9]!==d||t[10]!==R||t[11]!==n||t[12]!==z||t[13]!==H?(ue=()=>{if(!n){z(),H(d?{path:d,isDirectory:!1}:null);return}R()},t[9]=d,t[10]=R,t[11]=n,t[12]=z,t[13]=H,t[14]=ue):ue=t[14];let de;t[15]!==d||t[16]!==R||t[17]!==n||t[18]!==N||t[19]!==z||t[20]!==g?(de=[n,N,g,R,z,d],t[15]=d,t[16]=R,t[17]=n,t[18]=N,t[19]=z,t[20]=g,t[21]=de):de=t[21],(0,G.useEffect)(ue,de);let U;t[22]===oe?U=t[23]:(U=e=>{oe(e)},t[22]=oe,t[23]=U);let fe=U,pe=V!==null&&(b===`any`||b===`file`&&!V.isDirectory||b===`directory`&&V.isDirectory),W;bb1:{if(!V){W=D.pickerHintNone;break bb1}if(b===`file`&&V.isDirectory){W=D.pickerHintNeedsFile;break bb1}if(b===`directory`&&!V.isDirectory){W=D.pickerHintNeedsDirectory;break bb1}W=`${V.isDirectory?`📁`:`📄`} ${V.path}`}let me=W,K=k?.agents??[],ge;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(ge=(0,Q.jsx)(a,{className:`fixed inset-0 z-[70] bg-scrim backdrop-blur-[2px]`}),t[24]=ge):ge=t[24];let q;t[25]===Symbol.for(`react.memo_cache_sentinel`)?(q=w(`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]=q):q=t[25];let J;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(J=(0,Q.jsx)(ne,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),t[26]=J):J=t[26];let Y=S.cron.refresh,_e=S.cron.refresh,X;t[27]===R?X=t[28]:(X=()=>void R(),t[27]=R,t[28]=X);let ve=L&&`animate-spin`,Z;t[29]===ve?Z=t[30]:(Z=w(`size-4`,ve),t[29]=ve,t[30]=Z);let ye;t[31]===Z?ye=t[32]:(ye=(0,Q.jsx)(le,{className:Z,"aria-hidden":!0}),t[31]=Z,t[32]=ye);let be;t[33]===Symbol.for(`react.memo_cache_sentinel`)?(be=(0,Q.jsx)(_,{className:`size-4`}),t[33]=be):be=t[33];let xe;t[34]!==ae||t[35]!==E.loadError?(xe=ae?(0,Q.jsxs)(`p`,{className:`shrink-0 px-4 py-2 text-xs text-red-600 dark:text-red-400`,children:[E.loadError,`: `,ae]}):null,t[34]=ae,t[35]=E.loadError,t[36]=xe):xe=t[36];let Se;t[37]!==fe||t[38]!==L||t[39]!==V?.path||t[40]!==H||t[41]!==E.emptyDir||t[42]!==E.title||t[43]!==re?(Se=L&&re.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)(h,{className:`size-4 animate-spin`}),E.title,`…`]}):(0,Q.jsx)(j,{tree:re,selectedPath:V?.path??null,onSelectFile:e=>H({path:e,isDirectory:!1}),onSelectEntry:(e,t)=>H({path:e,isDirectory:t}),onExpandDir:fe,onAction:void 0,emptyHint:E.emptyDir}),t[37]=fe,t[38]=L,t[39]=V?.path,t[40]=H,t[41]=E.emptyDir,t[42]=E.title,t[43]=re,t[44]=Se):Se=t[44];let $;t[45]!==xe||t[46]!==Se?($=(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden`,children:[xe,Se]}),t[45]=xe,t[46]=Se,t[47]=$):$=t[47];let Ce;t[48]===me?Ce=t[49]:(Ce=(0,Q.jsx)(`p`,{className:`min-w-0 flex-1 truncate text-xs text-fg-muted`,children:me}),t[48]=me,t[49]=Ce);let we;t[50]===r?we=t[51]:(we=()=>r(!1),t[50]=r,t[51]=we);let Oe;t[52]!==D.cancel||t[53]!==we?(Oe=(0,Q.jsx)(T,{type:`button`,variant:`ghost`,onClick:we,children:D.cancel}),t[52]=D.cancel,t[53]=we,t[54]=Oe):Oe=t[54];let ke=!pe,Ae;t[55]!==i||t[56]!==r||t[57]!==N||t[58]!==V?(Ae=()=>{V&&(i({...V,agentId:N}),r(!1))},t[55]=i,t[56]=r,t[57]=N,t[58]=V,t[59]=Ae):Ae=t[59];let je;t[60]!==D.pickerConfirm||t[61]!==ke||t[62]!==Ae?(je=(0,Q.jsx)(T,{type:`button`,disabled:ke,onClick:Ae,children:D.pickerConfirm}),t[60]=D.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]!==Ce||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:[Ce,Me]}),t[67]=Ce,t[68]=Me,t[69]=Ne):Ne=t[69],(0,Q.jsx)(u,{open:n,onOpenChange:r,children:(0,Q.jsxs)(s,{children:[ge,(0,Q.jsxs)(c,{className:q,children:[(0,Q.jsxs)(`div`,{className:`flex h-11 shrink-0 items-center gap-2 border-b border-edge px-4`,children:[J,(0,Q.jsx)(l,{className:`min-w-0 flex-1 truncate text-base font-semibold text-fg`,children:D.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:Y,"aria-label":_e,disabled:L,onClick:X,children:ye}),(0,Q.jsx)(o,{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":E.close,children:be})})]}),K.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:D.pickerAgentLabel}),(0,Q.jsx)(f,{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:N,onChange:e=>{P(e.target.value),H(null)},children:K.map(e=>(0,Q.jsxs)(p,{value:e.id,children:[ie(e,S.agentsSettings),e.id===k?.defaultId?` ★`:``]},e.id))})]}):null,$,Ne]})]})})}function Te(e){return e.token}function Ee(e){return e.agentId}function De(e){return e.language}var Oe=[`shares`,`policy`];function ke(e){let t=(e??``).trim();return Oe.includes(t)?t:`shares`}function Ae(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 je(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 Me=[{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 Ne(){let e=(0,he.c)(24),t=x(Fe),n=y(t).sharesSettings,r=!!C(Pe),[a,o]=i(),s;e[0]===a?s=e[1]:(s=ke(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)(U,{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=Oe.map(e=>({id:e,label:d[e]})),p;e[4]!==n.subtitle||e[5]!==n.title?(p=(0,Q.jsx)(de,{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)(me,{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 h;e[12]!==c||e[13]!==r||e[14]!==t||e[15]!==n?(h=c===`shares`?(0,Q.jsx)(Ie,{t:n,language:t}):(0,Q.jsx)(xe,{hasToken:r}),e[12]=c,e[13]=r,e[14]=t,e[15]=n,e[16]=h):h=e[16];let g;e[17]!==c||e[18]!==h?(g=(0,Q.jsx)(fe,{id:c,activeTab:c,tabIdPrefix:`shares-tab`,panelIdPrefix:`shares-panel`,showHeading:!1,children:h}),e[17]=c,e[18]=h,e[19]=g):g=e[19];let _;return e[20]!==p||e[21]!==m||e[22]!==g?(_=(0,Q.jsxs)(U,{children:[p,m,g]}),e[20]=p,e[21]=m,e[22]=g,e[23]=_):_=e[23],_}function Pe(e){return e.token}function Fe(e){return e.language}function Ie(e){let t=(0,he.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}=ee(`shares-list`,z,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,f]=(0,G.useState)(!1),p;bb0:{if(d){p=u;break bb0}let e;t[3]===u?e=t[4]:(e=u.filter(Ve),t[3]=u,t[4]=e),p=e}let m=p,h;t[5]===u?h=t[6]:(h=u.filter(Be),t[5]=u,t[6]=h);let g=h.length,_;t[7]===u?_=t[8]:(_=u.filter(ze),t[7]=u,t[8]=_);let v=_.length,y;t[9]===c?y=t[10]:(y=()=>void c(),t[9]=c,t[10]=y);let b;t[11]!==n||t[12]!==y?(b=(0,Q.jsx)(Ue,{t:n,onCreated:y}),t[11]=n,t[12]=y,t[13]=b):b=t[13];let x=d?n.allSharesTitle:n.listTitle,S;t[14]===g?S=t[15]:(S=g>0&&(0,Q.jsxs)(`span`,{className:`ml-2 text-xs font-normal text-fg-muted`,children:[`(`,g,`)`]}),t[14]=g,t[15]=S);let C;t[16]!==x||t[17]!==S?(C=(0,Q.jsxs)(`h2`,{className:`text-sm font-semibold text-fg`,children:[x,S]}),t[16]=x,t[17]=S,t[18]=C):C=t[18];let E;t[19]===c?E=t[20]:(E=()=>void c(),t[19]=c,t[20]=E);let D=s&&`animate-spin`,O;t[21]===D?O=t[22]:(O=w(`size-3.5`,D),t[21]=D,t[22]=O);let te;t[23]===O?te=t[24]:(te=(0,Q.jsx)(le,{className:O}),t[23]=O,t[24]=te);let k;t[25]!==s||t[26]!==E||t[27]!==te?(k=(0,Q.jsx)(T,{type:`button`,variant:`ghost`,className:`px-2 py-1`,onClick:E,disabled:s,children:te}),t[25]=s,t[26]=E,t[27]=te,t[28]=k):k=t[28];let A;t[29]!==v||t[30]!==d||t[31]!==n.hideExpired||t[32]!==n.showExpired?(A=v>0&&(0,Q.jsx)(`button`,{type:`button`,className:`text-xs text-accent hover:underline`,onClick:()=>f(Re),children:d?n.hideExpired:n.showExpired}),t[29]=v,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 M;t[37]!==C||t[38]!==j?(M=(0,Q.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[C,j]}),t[37]=C,t[38]=j,t[39]=M):M=t[39];let N;t[40]!==a||t[41]!==o||t[42]!==m||t[43]!==s||t[44]!==r||t[45]!==c||t[46]!==n?(N=s&&!a?(0,Q.jsx)(`div`,{className:`grid gap-2`,"aria-busy":`true`,children:Array.from({length:4}).map(Le)}):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)(T,{type:`button`,variant:`ghost`,className:`px-2 py-1 text-xs`,onClick:()=>void c(),children:n.retry})]}):m.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:m.map(e=>(0,Q.jsx)(Ge,{share:e,t:n,language:r,onRevoked:()=>void c(),onExtended:()=>void c()},e.id))}),t[40]=a,t[41]=o,t[42]=m,t[43]=s,t[44]=r,t[45]=c,t[46]=n,t[47]=N):N=t[47];let P;t[48]!==v||t[49]!==c||t[50]!==d||t[51]!==n?(P=v>0&&d&&(0,Q.jsx)(Ke,{t:n,onCleaned:()=>void c()}),t[48]=v,t[49]=c,t[50]=d,t[51]=n,t[52]=P):P=t[52];let F;t[53]!==M||t[54]!==N||t[55]!==P?(F=(0,Q.jsxs)(W,{children:[M,N,P]}),t[53]=M,t[54]=N,t[55]=P,t[56]=F):F=t[56];let I;return t[57]!==F||t[58]!==b?(I=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[b,F]}),t[57]=F,t[58]=b,t[59]=I):I=t[59],I}function Le(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)(O,{className:`h-4 w-2/3`}),(0,Q.jsx)(O,{className:`mt-2 h-3 w-1/2`})]}),(0,Q.jsx)(O,{className:`h-7 w-20 rounded-md`})]})},t)}function Re(e){return!e}function ze(e){return e.expired||e.revoked}function Be(e){return!e.expired&&!e.revoked}function Ve(e){return!e.expired&&!e.revoked}var He={expanded:!0,path:``,isDirectory:!1,agentId:``,ttlMs:864e5,maxViews:null,description:``,directoryMode:`browse`,creating:!1,result:null,errorMsg:null,resultDialogOpen:!1,pickerOpen:!1};function Ue({t:e,onCreated:t}){let[n,r]=(0,G.useReducer)(re,He),{expanded:i,path:a,isDirectory:o,agentId:s,ttlMs:c,maxViews:l,description:u,directoryMode:d,creating:m,result:_,errorMsg:v,resultDialogOpen:y,pickerOpen:b}=n,x=(0,G.useCallback)(async()=>{if(a.trim()){r({type:`patch`,patch:{creating:!0,errorMsg:null,result:null}});try{r({type:`patch`,patch:{result:(await ae({path:a.trim(),ttlMs:c,maxViews:l,description:u.trim()||void 0,...s?{agentId:s}:{},...o?{kind:`directory`,directoryMode:d}:{}})).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,o,s,c,l,u,d,t]),S=(0,G.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)(W,{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:w(`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:o?`📁`:`📄`}),(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)(T,{type:`button`,variant:`ghost`,onClick:()=>r({type:`patch`,patch:{pickerOpen:!0}}),children:[(0,Q.jsx)(F,{className:`size-4`}),a?e.pathBrowseChange:e.pathBrowse]})]})]}),o?(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)(f,{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:d,onChange:e=>r({type:`patch`,patch:{directoryMode:e.target.value===`zip-only`?`zip-only`:`browse`}}),children:[(0,Q.jsx)(p,{value:`browse`,children:e.directoryModeBrowse}),(0,Q.jsx)(p,{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)(f,{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:c,onChange:e=>r({type:`patch`,patch:{ttlMs:Number(e.target.value)}}),children:Me.map(t=>(0,Q.jsx)(p,{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)(f,{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:l??`unlimited`,onChange:e=>r({type:`patch`,patch:{maxViews:e.target.value===`unlimited`?null:Number(e.target.value)}}),children:[(0,Q.jsx)(p,{value:`unlimited`,children:e.maxViewsUnlimited}),(0,Q.jsx)(p,{value:`1`,children:`1`}),(0,Q.jsx)(p,{value:`5`,children:`5`}),(0,Q.jsx)(p,{value:`10`,children:`10`}),(0,Q.jsx)(p,{value:`50`,children:`50`}),(0,Q.jsx)(p,{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:u,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)(T,{type:`button`,disabled:m||!a.trim(),onClick:()=>void x(),children:[m?(0,Q.jsx)(h,{className:`size-4 animate-spin`}):(0,Q.jsx)(g,{className:`size-4`}),m?e.creating:e.createButton]}),(0,Q.jsx)(T,{type:`button`,variant:`ghost`,onClick:()=>{S(),r({type:`patch`,patch:{expanded:!1}})},children:e.cancel})]}),v&&(0,Q.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:v})]}),(0,Q.jsx)(oe,{open:y,onOpenChange:e=>{r({type:`patch`,patch:{resultDialogOpen:e,...e?{}:{result:null}}})},result:_}),(0,Q.jsx)(we,{open:b,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)(T,{type:`button`,onClick:()=>r({type:`patch`,patch:{expanded:!0}}),className:`self-start`,children:[(0,Q.jsx)(g,{className:`size-4`}),e.createTitle]})}var We={revokeOpen:!1,revoking:!1,linksOpen:!1,urlCopied:!1,copyFailed:!1,extending:!1};function Ge({share:e,t,language:n,onRevoked:r,onExtended:i}){let[a,o]=(0,G.useReducer)(re,We),{revokeOpen:s,revoking:c,linksOpen:l,urlCopied:u,copyFailed:f,extending:p}=a,g=!e.expired&&!e.revoked,_=e.revoked?t.statusRevoked:e.expired?t.statusExpired:t.statusActive,y=e.revoked?`text-red-600 dark:text-red-400`:e.expired?`text-fg-subtle`:`text-emerald-600 dark:text-emerald-400`,b=(0,G.useCallback)(async()=>{o({type:`patch`,patch:{revokeOpen:!1,revoking:!0}});try{await V(e.id),r()}catch{}finally{o({type:`patch`,patch:{revoking:!1}})}},[e.id,r]),x=(0,G.useCallback)(async()=>{if(o({type:`patch`,patch:{linksOpen:!0,copyFailed:!1}}),!await v(e.shareUrl)){o({type:`patch`,patch:{copyFailed:!0}}),window.setTimeout(()=>o({type:`patch`,patch:{copyFailed:!1}}),2500);return}o({type:`patch`,patch:{urlCopied:!0}}),window.setTimeout(()=>o({type:`patch`,patch:{urlCopied:!1}}),2e3)},[e.shareUrl]),S=(0,G.useCallback)(async()=>{o({type:`patch`,patch:{extending:!0}});try{await I(e.id,864e5),i()}catch{}finally{o({type:`patch`,patch:{extending:!1}})}},[e.id,i]),C=`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:w(`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":l,"aria-controls":C,onClick:()=>o({type:`patch`,patch:{linksOpen:!l}}),children:[(0,Q.jsx)(H,{className:w(`mt-0.5 size-4 shrink-0 text-fg-muted transition-transform`,l?`rotate-0`:`-rotate-90`),"aria-hidden":!0}),e.kind===`note`?(0,Q.jsx)(A,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}):e.kind===`session`?(0,Q.jsx)(P,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}):(0,Q.jsx)(F,{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:w(`text-xs font-medium`,y),children:_})]}),(0,Q.jsx)(`p`,{className:`truncate text-xs text-fg-subtle`,children:e.kind===`note`?n===`zh`?`笔记快照 · 版本 ${e.snapshotRevision??1}`:`Note snapshot · revision ${e.snapshotRevision??1}`:e.kind===`session`?n===`zh`?`会话快照 · ${e.messageCount??0} 条消息 · 版本 ${e.snapshotRevision??1}`:`Conversation snapshot · ${e.messageCount??0} messages · revision ${e.snapshotRevision??1}`: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:Ae(e.fileSize)}),(0,Q.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,Q.jsx)(k,{className:`size-3`}),e.expired?n===`zh`?`已过期`:`expired`:je(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:g&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(T,{type:`button`,variant:`ghost`,className:`px-2 py-1`,title:t.copyUrl,onClick:()=>void x(),children:u?(0,Q.jsx)(d,{className:`size-3.5 text-emerald-500`}):(0,Q.jsx)(m,{className:`size-3.5`})}),(0,Q.jsx)(T,{type:`button`,variant:`ghost`,className:`px-2 py-1`,onClick:()=>void S(),disabled:p,title:t.extend,children:p?(0,Q.jsx)(h,{className:`size-3.5 animate-spin`}):(0,Q.jsx)(k,{className:`size-3.5`})}),(0,Q.jsx)(T,{type:`button`,variant:`ghost`,className:`px-2 py-1 text-red-600 hover:text-red-700 dark:text-red-400`,onClick:()=>o({type:`patch`,patch:{revokeOpen:!0}}),disabled:c,children:c?(0,Q.jsx)(h,{className:`size-3.5 animate-spin`}):(0,Q.jsx)(M,{className:`size-3.5`})})]})})]}),g&&l?(0,Q.jsxs)(`div`,{id:C,className:`mt-3 bg-surface-base/45 py-3 pl-7 pr-3`,children:[(0,Q.jsx)(ue,{shareUrl:e.shareUrl,lanUrl:e.lanUrl,reachability:e.reachability,compact:!0}),f?(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)(L,{reachability:e.reachability})})]}):null]}),(0,Q.jsx)(N,{open:s,title:t.revokeConfirmTitle,description:t.revokeConfirmBody,confirmLabel:t.revokeConfirmLabel,cancelLabel:t.cancel,destructive:!0,onConfirm:()=>void b(),onCancel:()=>o({type:`patch`,patch:{revokeOpen:!1}})})]})}function Ke({t:e,onCleaned:t}){let[n,r]=(0,G.useState)(!1),[i,a]=(0,G.useState)(!1),o=(0,G.useCallback)(async()=>{r(!1),a(!0);try{await B(),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)(T,{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)(h,{className:`size-3.5 animate-spin`}):(0,Q.jsx)(M,{className:`size-3.5`}),e.cleanExpired]})}),(0,Q.jsx)(N,{open:n,title:e.cleanExpiredConfirmTitle,description:e.cleanExpiredConfirmBody,confirmLabel:e.cleanExpiredConfirmLabel,cancelLabel:e.cancel,destructive:!0,onConfirm:()=>void o(),onCancel:()=>r(!1)})]})}export{Ne as SharesSettingsPanel};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{n as e}from"./rolldown-runtime-aKtaBQYM.js";import{i as t,r as n}from"./locale-store-CF4erhjB.js";import{vn as r}from"./index-BcaF-dgQ.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};
|