@xopcai/xopc 0.0.110 → 0.0.111
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +46 -4
- package/README.zh-CN.md +46 -4
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/Combination-BzaXOLd9.js +41 -0
- package/dist/gateway/static/root/assets/agent-avatar-dicebear-zlx9l5Yp.js +1 -0
- package/dist/gateway/static/root/assets/agent-browser-settings-page-B-0zGjt8.js +6 -0
- package/dist/gateway/static/root/assets/agent-defaults-tabbed-page-Bz7JWjRM.js +1 -0
- package/dist/gateway/static/root/assets/agents-DwDnJlXT.js +71 -0
- package/dist/gateway/static/root/assets/app-management-settings-panel-DaQwdeCq.js +1 -0
- package/dist/gateway/static/root/assets/appearance-settings-D2zv6r3P.js +1 -0
- package/dist/gateway/static/root/assets/apps-page-BIppe_jj.js +1 -0
- package/dist/gateway/static/root/assets/archive-plugin-DEmu8eH7.js +1 -0
- package/dist/gateway/static/root/assets/attachment-load-B98lJoN5.js +2 -0
- package/dist/gateway/static/root/assets/{attachment-preview-renderer-CybMSIoS.js → attachment-preview-renderer-DonnL2dL.js} +1 -1
- package/dist/gateway/static/root/assets/binary-plugins-CL9QKmyo.js +2 -0
- package/dist/gateway/static/root/assets/block-editor-BOAhMAhT.js +180 -0
- package/dist/gateway/static/root/assets/channels-settings-Br8iRnXp.js +1 -0
- package/dist/gateway/static/root/assets/cn-JdwAhgNB.js +1 -0
- package/dist/gateway/static/root/assets/code-editor-dZTY2dRW.js +1 -0
- package/dist/gateway/static/root/assets/config-api-0o1WYdz2.js +3 -0
- package/dist/gateway/static/root/assets/connectors-settings-DDvHo9in.js +2 -0
- package/dist/gateway/static/root/assets/cron-api-Dj_UZKST.js +1 -0
- package/dist/gateway/static/root/assets/cron-dreaming-jobs-nCMWCf0p.js +1 -0
- package/dist/gateway/static/root/assets/cron-page-Dv7GII9G.js +1 -0
- package/dist/gateway/static/root/assets/cron-schedule-picker-DH10KgD6.js +1 -0
- package/dist/gateway/static/root/assets/dist-By6Rh2ee.js +1 -0
- package/dist/gateway/static/root/assets/dist-CkobR7mk.js +1 -0
- package/dist/gateway/static/root/assets/dist-DokQNVMQ.js +1 -0
- package/dist/gateway/static/root/assets/dreaming-scene-BHMRVEUS.js +4585 -0
- package/dist/gateway/static/root/assets/dreaming-settings-L2rgZDQl.js +1 -0
- package/dist/gateway/static/root/assets/extension-debug-page-Cjx6pZVz.js +1 -0
- package/dist/gateway/static/root/assets/{extension-page-W1wiG38F.js → extension-page-BSPNL90V.js} +1 -1
- package/dist/gateway/static/root/assets/extension-settings-page-m_UQYkVc.js +1 -0
- package/dist/gateway/static/root/assets/fetch-Bs7in_4F.js +1 -0
- package/dist/gateway/static/root/assets/format-interval-label-CftJ5uXu.js +1 -0
- package/dist/gateway/static/root/assets/gateway-config-api-Clfck-hW.js +1 -0
- package/dist/gateway/static/root/assets/gateway-settings-CS177xni.js +1 -0
- package/dist/gateway/static/root/assets/gateway-startup-retry-BkjVJc38.js +1 -0
- package/dist/gateway/static/root/assets/goal-detail-page-kqJue0sE.js +1 -0
- package/dist/gateway/static/root/assets/goals-page-C0FujUB5.js +2 -0
- package/dist/gateway/static/root/assets/goals-settings-CJnzNSDo.js +1 -0
- package/dist/gateway/static/root/assets/heartbeat-config-api-Cp7CPuIn.js +1 -0
- package/dist/gateway/static/root/assets/heartbeat-settings-ifSI1Wbh.js +1 -0
- package/dist/gateway/static/root/assets/html-workspace-editor-CQLWDiwE.js +1 -0
- package/dist/gateway/static/root/assets/index-COkF54xv.js +121 -0
- package/dist/gateway/static/root/assets/index-DIaSNGEO.css +1 -0
- package/dist/gateway/static/root/assets/interval-presets-B29Ss_2y.js +2 -0
- package/dist/gateway/static/root/assets/keyboard-shortcuts-settings--MI1rYl7.js +1 -0
- package/dist/gateway/static/root/assets/locale-store-DjbfSsfA.js +1 -0
- package/dist/gateway/static/root/assets/logs-page-BwrVNlyW.js +2 -0
- package/dist/gateway/static/root/assets/markdown-editor-AssmZFx4.js +2 -0
- package/dist/gateway/static/root/assets/markdown-split-B_oc9lJe.js +1 -0
- package/dist/gateway/static/root/assets/media-plugins-DLPvB5H3.js +1 -0
- package/dist/gateway/static/root/assets/mermaid-render-BbqDc_LQ.js +134 -0
- package/dist/gateway/static/root/assets/messages-Csef1aW7.js +3 -0
- package/dist/gateway/static/root/assets/middleware-Pd0e8Igk.js +1 -0
- package/dist/gateway/static/root/assets/models-hub-panel-DHGiTIvf.js +2 -0
- package/dist/gateway/static/root/assets/note-detail-page-BM7zlDiT.js +2 -0
- package/dist/gateway/static/root/assets/note-image-lightbox-rSqAgOi9.js +1 -0
- package/dist/gateway/static/root/assets/note-time-hm6JO_Wi.js +1 -0
- package/dist/gateway/static/root/assets/notes-page-C9ACGEty.js +1 -0
- package/dist/gateway/static/root/assets/preview-open-alternatives-Bw_N2oZi.js +1 -0
- package/dist/gateway/static/root/assets/remote-access-hub-BhcWIKuM.js +1 -0
- package/dist/gateway/static/root/assets/save-bar-controls-CNP2jmw0.js +1 -0
- package/dist/gateway/static/root/assets/schedule-field-BPAWui3P.js +1 -0
- package/dist/gateway/static/root/assets/schedule-summary-B-hdSRdR.js +1 -0
- package/dist/gateway/static/root/assets/schema-form-CDPzua9q.js +1 -0
- package/dist/gateway/static/root/assets/sessions-page-DzkpSDZr.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-BYS-rpzn.js +1 -0
- package/dist/gateway/static/root/assets/settings-collapsible-section-C9bff85B.js +1 -0
- package/dist/gateway/static/root/assets/settings-form-section-BsrK7TBF.js +1 -0
- package/dist/gateway/static/root/assets/settings-page-DWK4Zo7s.js +1 -0
- package/dist/gateway/static/root/assets/setup-status-panel-DJiksNu4.js +1 -0
- package/dist/gateway/static/root/assets/share-preview-page-DnutoY_S.js +2 -0
- package/dist/gateway/static/root/assets/shares-settings-6oRgJMpn.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-CU9i0nJV.js +1 -0
- package/dist/gateway/static/root/assets/skills-page-ERbdWENm.js +2 -0
- package/dist/gateway/static/root/assets/system-settings-panel-qP1JDtDd.js +1 -0
- package/dist/gateway/static/root/assets/theme-store-CD2wtgZV.js +1 -0
- package/dist/gateway/static/root/assets/use-agent-defaults-form-D3FGVLZb.js +1 -0
- package/dist/gateway/static/root/assets/use-blob-object-url-D4BFuzZB.js +1 -0
- package/dist/gateway/static/root/assets/use-channel-catalog-C4mg1hjD.js +1 -0
- package/dist/gateway/static/root/assets/use-settings-tab-guard-F6C0mpJt.js +1 -0
- package/dist/gateway/static/root/assets/vendor-codemirror-CNP1wPe7.js +45 -0
- package/dist/gateway/static/root/assets/voice-api-key-field-BnDDb6qO.js +1 -0
- package/dist/gateway/static/root/assets/voice-player-store-B2EwIhtY.js +1 -0
- package/dist/gateway/static/root/assets/{workflow-page.utils-EYg_xBQS.js → workflow-page.utils-CRB7WX9l.js} +1 -1
- package/dist/gateway/static/root/assets/workflows-page-2Fptr0je.js +18 -0
- package/dist/gateway/static/root/index.html +12 -10
- package/dist/package.js +1 -1
- package/dist/src/agent/goals/checklist-judge.d.ts +5 -0
- package/dist/src/agent/goals/checklist-judge.js +26 -2
- package/dist/src/agent/goals/checklist-judge.js.map +1 -1
- package/dist/src/agent/goals/evaluate-turn.d.ts +5 -1
- package/dist/src/agent/goals/evaluate-turn.js +29 -3
- package/dist/src/agent/goals/evaluate-turn.js.map +1 -1
- package/dist/src/agent/goals/goal-locale.d.ts +0 -2
- package/dist/src/agent/goals/goal-locale.js +2 -15
- package/dist/src/agent/goals/goal-locale.js.map +1 -1
- package/dist/src/agent/goals/persistent-goal-service.d.ts +9 -0
- package/dist/src/agent/goals/persistent-goal-service.js +2 -1
- package/dist/src/agent/goals/persistent-goal-service.js.map +1 -1
- package/dist/src/agent/goals/post-turn.d.ts +7 -0
- package/dist/src/agent/goals/post-turn.js +68 -23
- package/dist/src/agent/goals/post-turn.js.map +1 -1
- package/dist/src/agent/goals/state.d.ts +0 -5
- package/dist/src/agent/goals/state.js +1 -96
- package/dist/src/agent/goals/state.js.map +1 -1
- package/dist/src/agent/messaging/command-handler.d.ts +4 -0
- package/dist/src/agent/messaging/command-handler.js +6 -2
- package/dist/src/agent/messaging/command-handler.js.map +1 -1
- package/dist/src/agent/service/direct-turn-helpers.d.ts +2 -0
- package/dist/src/agent/service/direct-turn-helpers.js +3 -2
- package/dist/src/agent/service/direct-turn-helpers.js.map +1 -1
- package/dist/src/agent/service/process-direct-streaming.js +10 -1
- package/dist/src/agent/service/process-direct-streaming.js.map +1 -1
- package/dist/src/agent/service.js +20 -1
- package/dist/src/agent/service.js.map +1 -1
- package/dist/src/agent/service.types.d.ts +8 -0
- package/dist/src/agent/tools/cronjob-tool.d.ts +2 -0
- package/dist/src/agent/tools/cronjob-tool.js +27 -4
- package/dist/src/agent/tools/cronjob-tool.js.map +1 -1
- package/dist/src/agent/tools/edit.d.ts +2 -0
- package/dist/src/agent/tools/edit.js +10 -0
- package/dist/src/agent/tools/edit.js.map +1 -1
- package/dist/src/agent/tools/factory.js +16 -3
- package/dist/src/agent/tools/factory.js.map +1 -1
- package/dist/src/agent/tools/goal-evidence-recorder.d.ts +6 -0
- package/dist/src/agent/tools/goal-evidence-recorder.js +34 -0
- package/dist/src/agent/tools/goal-evidence-recorder.js.map +1 -0
- package/dist/src/agent/tools/goal-tool.d.ts +19 -0
- package/dist/src/agent/tools/goal-tool.js +101 -0
- package/dist/src/agent/tools/goal-tool.js.map +1 -0
- package/dist/src/agent/tools/index.d.ts +1 -0
- package/dist/src/agent/tools/index.js +2 -1
- package/dist/src/agent/tools/shell.d.ts +2 -0
- package/dist/src/agent/tools/shell.js +17 -2
- package/dist/src/agent/tools/shell.js.map +1 -1
- package/dist/src/agent/tools/workflow-tool.d.ts +1 -0
- package/dist/src/agent/tools/workflow-tool.js +10 -2
- package/dist/src/agent/tools/workflow-tool.js.map +1 -1
- package/dist/src/agent/tools/write.d.ts +2 -0
- package/dist/src/agent/tools/write.js +11 -0
- package/dist/src/agent/tools/write.js.map +1 -1
- package/dist/src/channels/attachments/inbound-persist.d.ts +7 -0
- package/dist/src/channels/attachments/inbound-persist.js +20 -2
- package/dist/src/channels/attachments/inbound-persist.js.map +1 -1
- package/dist/src/chat-commands/builtins/goal.d.ts +1 -1
- package/dist/src/chat-commands/builtins/goal.js +55 -97
- package/dist/src/chat-commands/builtins/goal.js.map +1 -1
- package/dist/src/chat-commands/builtins/subgoal.d.ts +1 -1
- package/dist/src/chat-commands/builtins/subgoal.js +49 -108
- package/dist/src/chat-commands/builtins/subgoal.js.map +1 -1
- package/dist/src/chat-commands/builtins/workflow.js +132 -8
- package/dist/src/chat-commands/builtins/workflow.js.map +1 -1
- package/dist/src/chat-commands/context.d.ts +3 -0
- package/dist/src/chat-commands/context.js +5 -0
- package/dist/src/chat-commands/context.js.map +1 -1
- package/dist/src/chat-commands/types.d.ts +5 -0
- package/dist/src/cli/command-catalog.js +43 -0
- package/dist/src/cli/command-catalog.js.map +1 -1
- package/dist/src/cli/command-loaders.js +1 -0
- package/dist/src/cli/command-loaders.js.map +1 -1
- package/dist/src/cli/command-manifest.js +4 -0
- package/dist/src/cli/command-manifest.js.map +1 -1
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/cli/commands/goal.d.ts +4 -0
- package/dist/src/cli/commands/goal.js +213 -0
- package/dist/src/cli/commands/goal.js.map +1 -0
- package/dist/src/cli/commands/onboard.js +11 -5
- package/dist/src/cli/commands/onboard.js.map +1 -1
- package/dist/src/config/index.js +2 -2
- package/dist/src/config/schema.d.ts +115 -0
- package/dist/src/config/schema.js +63 -4
- package/dist/src/config/schema.js.map +1 -1
- package/dist/src/config/web-patch.d.ts +14 -0
- package/dist/src/config/web-patch.js +45 -6
- package/dist/src/config/web-patch.js.map +1 -1
- package/dist/src/cron/executor.d.ts +2 -0
- package/dist/src/cron/executor.js +25 -0
- package/dist/src/cron/executor.js.map +1 -1
- package/dist/src/cron/job-content.js +1 -0
- package/dist/src/cron/job-content.js.map +1 -1
- package/dist/src/cron/types.d.ts +19 -1
- package/dist/src/cron/validation.d.ts +20 -0
- package/dist/src/cron/validation.js +7 -0
- package/dist/src/cron/validation.js.map +1 -1
- package/dist/src/gateway/hono/lib/config-payload.d.ts +14 -0
- package/dist/src/gateway/hono/routes/goals.d.ts +1 -1
- package/dist/src/gateway/hono/routes/goals.js +670 -173
- package/dist/src/gateway/hono/routes/goals.js.map +1 -1
- package/dist/src/gateway/hono/routes/home.d.ts +5 -0
- package/dist/src/gateway/hono/routes/home.js +88 -3
- package/dist/src/gateway/hono/routes/home.js.map +1 -1
- package/dist/src/gateway/hono/routes/notes.js +20 -14
- package/dist/src/gateway/hono/routes/notes.js.map +1 -1
- package/dist/src/gateway/hono/routes/workflows.js +6 -2
- package/dist/src/gateway/hono/routes/workflows.js.map +1 -1
- package/dist/src/gateway/hono/sse.js.map +1 -1
- package/dist/src/gateway/service/agent-runner.d.ts +2 -0
- package/dist/src/gateway/service/agent-runner.js +6 -2
- package/dist/src/gateway/service/agent-runner.js.map +1 -1
- package/dist/src/gateway/service/run-gateway-agent.d.ts +3 -0
- package/dist/src/gateway/service/run-gateway-agent.js.map +1 -1
- package/dist/src/gateway/service.d.ts +8 -0
- package/dist/src/gateway/service.js +69 -2
- package/dist/src/gateway/service.js.map +1 -1
- package/dist/src/goals/goal-notifications.d.ts +29 -0
- package/dist/src/goals/goal-notifications.js +154 -0
- package/dist/src/goals/goal-notifications.js.map +1 -0
- package/dist/src/goals/goal-queue-store.d.ts +16 -0
- package/dist/src/goals/goal-queue-store.js +131 -0
- package/dist/src/goals/goal-queue-store.js.map +1 -0
- package/dist/src/goals/goal-queue-types.d.ts +31 -0
- package/dist/src/goals/goal-queue-types.js +1 -0
- package/dist/src/goals/goal-runner.d.ts +17 -0
- package/dist/src/goals/goal-runner.js +127 -0
- package/dist/src/goals/goal-runner.js.map +1 -0
- package/dist/src/goals/goal-service.d.ts +77 -0
- package/dist/src/goals/goal-service.js +261 -0
- package/dist/src/goals/goal-service.js.map +1 -0
- package/dist/src/goals/goal-store.d.ts +38 -0
- package/dist/src/goals/goal-store.js +404 -0
- package/dist/src/goals/goal-store.js.map +1 -0
- package/dist/src/goals/goal-workflow-judge.d.ts +13 -0
- package/dist/src/goals/goal-workflow-judge.js +147 -0
- package/dist/src/goals/goal-workflow-judge.js.map +1 -0
- package/dist/src/goals/index.d.ts +10 -0
- package/dist/src/goals/index.js +7 -0
- package/dist/src/goals/types.d.ts +119 -0
- package/dist/src/goals/types.js +1 -0
- package/dist/src/storage/sqlite/migrations/006_add_goals.sql +108 -0
- package/dist/src/storage/sqlite/migrations/007_goal_run_judge_schema.sql +4 -0
- package/dist/src/storage/sqlite/migrations/008_goal_queue_workflow_runs.sql +53 -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.js.map +1 -1
- package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
- package/dist/src/storage/sqlite/schema.js +1 -1
- package/dist/src/storage/sqlite/schema.sql +163 -0
- package/dist/src/utils/logger/stats.d.ts +1 -1
- package/dist/src/workflows/domain/run.d.ts +1 -0
- package/dist/src/workflows/domain/run.js.map +1 -1
- package/dist/src/workflows/service/workflow-run-service.d.ts +1 -0
- package/dist/src/workflows/service/workflow-run-service.js +5 -1
- package/dist/src/workflows/service/workflow-run-service.js.map +1 -1
- package/dist/src/workflows/service/workflow-run-service.types.d.ts +1 -0
- package/dist/src/workflows/service/workflow-session-bridge.js +7 -0
- package/dist/src/workflows/service/workflow-session-bridge.js.map +1 -1
- package/dist/src/workflows/store/run-index-store.d.ts +8 -0
- package/dist/src/workflows/store/run-index-store.js +58 -0
- package/dist/src/workflows/store/run-index-store.js.map +1 -0
- package/dist/src/workflows/store/run-store.d.ts +2 -0
- package/dist/src/workflows/store/run-store.js +14 -21
- package/dist/src/workflows/store/run-store.js.map +1 -1
- package/package.json +9 -3
- package/dist/gateway/static/root/assets/Combination-HAlzriaz.js +0 -41
- package/dist/gateway/static/root/assets/agents-CFFioJCI.js +0 -78
- package/dist/gateway/static/root/assets/apps-page-BYDmkbzG.js +0 -1
- package/dist/gateway/static/root/assets/channels-settings-CsbDaMvd.js +0 -1
- package/dist/gateway/static/root/assets/circle-check-C23XjkUj.js +0 -1
- package/dist/gateway/static/root/assets/copy-Dv6d4Dvw.js +0 -1
- package/dist/gateway/static/root/assets/cron-page-Apk-7p4p.js +0 -1
- package/dist/gateway/static/root/assets/dist-DmGDgpy2.js +0 -1
- package/dist/gateway/static/root/assets/extension-debug-page-pxFC-tUa.js +0 -1
- package/dist/gateway/static/root/assets/extension-settings-page-COXSv6xP.js +0 -1
- package/dist/gateway/static/root/assets/fetch-CFdKBnE6.js +0 -1
- package/dist/gateway/static/root/assets/gateway-startup-retry-DdngdObI.js +0 -1
- package/dist/gateway/static/root/assets/heartbeat-config-api-DcmAMYmN.js +0 -1
- package/dist/gateway/static/root/assets/index-C_2yKRJX.js +0 -4845
- package/dist/gateway/static/root/assets/index-DI5_GsZt.css +0 -1
- package/dist/gateway/static/root/assets/logs-page-DvTWUOzd.js +0 -2
- package/dist/gateway/static/root/assets/note-detail-page-CZbdugWZ.js +0 -180
- package/dist/gateway/static/root/assets/note-time-RdyBZxj3.js +0 -1
- package/dist/gateway/static/root/assets/notes-page-mEAwy3e1.js +0 -1
- package/dist/gateway/static/root/assets/schema-form-DEvdni_r.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-BsgffzV4.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-t6v8Dwb8.js +0 -2
- package/dist/gateway/static/root/assets/settings-form-section-BoYYZmJG.js +0 -1
- package/dist/gateway/static/root/assets/settings-page-ClIthYF8.js +0 -3
- package/dist/gateway/static/root/assets/share-preview-page-Dd9et7KD.js +0 -2
- package/dist/gateway/static/root/assets/skills-page-DEXtxyfQ.js +0 -2
- package/dist/gateway/static/root/assets/theme-store-BZozwAeK.js +0 -1
- package/dist/gateway/static/root/assets/url-DQRqHuL-.js +0 -3
- package/dist/gateway/static/root/assets/vendor-codemirror-DYoKfS8f.js +0 -45
- package/dist/gateway/static/root/assets/voice-api-key-field-CNrKzQrf.js +0 -1
- package/dist/gateway/static/root/assets/workflows-page-EMZkzJNN.js +0 -18
- package/dist/src/agent/goals/checklist-user.d.ts +0 -24
- package/dist/src/agent/goals/checklist-user.js +0 -92
- package/dist/src/agent/goals/checklist-user.js.map +0 -1
- package/dist/src/agent/goals/goal-run-store.d.ts +0 -19
- package/dist/src/agent/goals/goal-run-store.js +0 -138
- package/dist/src/agent/goals/goal-run-store.js.map +0 -1
- package/dist/src/agent/goals/goal-run-types.d.ts +0 -28
- package/dist/src/agent/goals/goal-run-types.js +0 -6
- package/dist/src/agent/goals/goal-run-types.js.map +0 -1
- package/dist/src/agent/goals/patch-from-user-action.d.ts +0 -20
- package/dist/src/agent/goals/patch-from-user-action.js +0 -103
- package/dist/src/agent/goals/patch-from-user-action.js.map +0 -1
- /package/dist/gateway/static/root/assets/{note-detail-page-D4ZIVQbk.css → block-editor-D4ZIVQbk.css} +0 -0
|
@@ -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{t as i}from"./cn-JdwAhgNB.js";import{t as a}from"./messages-Csef1aW7.js";import{t as o}from"./locale-store-DjbfSsfA.js";import{c as s,i as c,n as l}from"./fetch-Bs7in_4F.js";import{i as u}from"./vendor-swr-BIWyz7Rc.js";import{B as d,Ds as f,Hi as p,Ji as m,Ka as h,Mi as g,Oa as _,Ra as v,ba as y,br as b,ga as x,ki as S,qa as C,ra as w,ua as T,wi as E,xi as D,xs as O,yr as k}from"./index-COkF54xv.js";import{n as ee,t as A}from"./settings-form-section-BsrK7TBF.js";import{r as j}from"./interval-presets-B29Ss_2y.js";import{t as M}from"./schedule-summary-B-hdSRdR.js";import{t as N}from"./schedule-field-BPAWui3P.js";var P=e(t(),1),F=n();function I(){return c(`/api/dreaming`)}async function te(){let e=await l(I());if(!e.payload)throw Error(`Missing payload`);return e.payload}async function ne(e){await l(c(`/api/dreaming/action`),{method:`POST`,body:JSON.stringify({action:e})})}async function re(e=`deep`){let t=await l(c(`/api/dreaming/run`),{method:`POST`,body:JSON.stringify({phase:e})}),n=!!t.payload?.triggered,r=typeof t.payload?.jobId==`string`?t.payload.jobId:``;if(!n||!r)throw Error(`Failed to trigger`);return{triggered:n,jobId:r,phase:e}}async function ie(e){let t=await l(c(`/api/dreaming/preview${typeof e==`number`&&Number.isFinite(e)?`?limit=${encodeURIComponent(String(e))}`:``}`));if(!t.payload)throw Error(`Missing payload`);return t.payload}async function ae(e=50){return(await l(c(`/api/dreaming/events${`?limit=${encodeURIComponent(String(e))}`}`))).payload?.events??[]}function L(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var R={enabled:!0,cron:`0 */6 * * *`,lookbackDays:1,limit:50,dedupeSimilarity:.85},z={enabled:!0,cron:`0 3 * * *`,minScore:.8,minRecallCount:3,limit:10,recencyHalfLifeDays:14,maxAgeDays:30},B={enabled:!0,cron:`0 5 * * 0`,lookbackDays:7,limit:20,minPatternStrength:.6},V={enabled:!1,frequency:`0 3 * * *`,timezone:``,deepEnabled:!0,minScore:.8,minRecallCount:3,limit:10,light:R,deep:z,rem:B};function H(e,t){return Number.isFinite(e)?Math.max(0,Math.min(1,e)):t}function U(e,t){let n=typeof e==`string`?Number(e):e;return Number.isFinite(n)?Math.max(0,Math.floor(n)):t}function W(e,t){let n=typeof e==`string`?Number(e):e;return Number.isFinite(n)?n:t}function oe(e){let t=L(e)?e:{},n=L(t.agents)?t.agents:{},r=L(n.defaults)?n.defaults:{},i=L(r.memory)?r.memory:{},a=L(i.dreaming)?i.dreaming:{},o=L(a.phases)?a.phases:{},s=L(o.light)?o.light:{},c=L(o.deep)?o.deep:{},l=L(o.rem)?o.rem:{};return{enabled:a.enabled===!0,frequency:typeof a.frequency==`string`&&a.frequency.trim()?a.frequency.trim():V.frequency,timezone:typeof a.timezone==`string`?a.timezone:``,deepEnabled:c.enabled!==!1,minScore:H(typeof c.minScore==`number`?c.minScore:Number(c.minScore),V.minScore),minRecallCount:Math.max(1,U(c.minRecallCount,V.minRecallCount)),limit:U(c.limit,V.limit),light:{enabled:s.enabled!==!1,cron:typeof s.cron==`string`&&s.cron.trim()?s.cron.trim():R.cron,lookbackDays:Math.max(1,U(s.lookbackDays,R.lookbackDays)),limit:U(s.limit,R.limit),dedupeSimilarity:H(W(s.dedupeSimilarity,R.dedupeSimilarity),R.dedupeSimilarity)},deep:{enabled:c.enabled!==!1,cron:typeof c.cron==`string`&&c.cron.trim()?c.cron.trim():z.cron,minScore:H(W(c.minScore,z.minScore),z.minScore),minRecallCount:Math.max(1,U(c.minRecallCount,z.minRecallCount)),limit:U(c.limit,z.limit),recencyHalfLifeDays:Math.max(1,W(c.recencyHalfLifeDays,z.recencyHalfLifeDays)),maxAgeDays:Math.max(1,W(c.maxAgeDays,z.maxAgeDays))},rem:{enabled:l.enabled!==!1,cron:typeof l.cron==`string`&&l.cron.trim()?l.cron.trim():B.cron,lookbackDays:Math.max(1,U(l.lookbackDays,B.lookbackDays)),limit:U(l.limit,B.limit),minPatternStrength:H(W(l.minPatternStrength,B.minPatternStrength),B.minPatternStrength)}}}async function G(e){let t=e.frequency.trim(),n=e.timezone.trim();await l(c(`/api/config`),{method:`PATCH`,body:JSON.stringify({agents:{defaults:{memory:{dreaming:{enabled:!!e.enabled,frequency:t||null,timezone:n||null,phases:{light:{enabled:!!e.light.enabled,cron:e.light.cron.trim()||null,lookbackDays:Math.max(1,Math.floor(e.light.lookbackDays)),limit:Math.max(0,Math.floor(e.light.limit)),dedupeSimilarity:H(e.light.dedupeSimilarity,R.dedupeSimilarity)},deep:{enabled:!!e.deep.enabled,cron:e.deep.cron.trim()||null,minScore:H(e.deep.minScore,z.minScore),minRecallCount:Math.max(1,Math.floor(e.deep.minRecallCount)),limit:Math.max(0,Math.floor(e.deep.limit)),recencyHalfLifeDays:Math.max(1,e.deep.recencyHalfLifeDays),maxAgeDays:Math.max(1,e.deep.maxAgeDays)},rem:{enabled:!!e.rem.enabled,cron:e.rem.cron.trim()||null,lookbackDays:Math.max(1,Math.floor(e.rem.lookbackDays)),limit:Math.max(0,Math.floor(e.rem.limit)),minPatternStrength:H(e.rem.minPatternStrength,B.minPatternStrength)}}}}}}})}),k()}var K=`p-4 sm:px-5`,se=`mb-3`,q=`rounded-xl border border-edge-subtle bg-surface-panel/30 p-3 sm:p-4`,J=i(`mt-1 w-full rounded-lg border border-edge-subtle bg-surface-panel px-2.5 py-1.5 text-sm text-fg`,E);function ce(e){return e?e.replace(`T`,` `).replace(`Z`,``):`—`}function Y(e){return e===void 0||!Number.isFinite(e)||e<0?`—`:e<1e3?`${Math.round(e)} ms`:`${(e/1e3).toFixed(2)} s`}function le(e,t){return e.locked?{text:t.lockValueLocked,className:`text-amber-600 dark:text-amber-400`}:{text:t.lockValueUnlocked,className:`text-emerald-600 dark:text-emerald-400`}}var X=r(),ue=`text-xs font-medium text-fg-muted`,Z=`text-sm font-medium text-fg`;function Q(e){let t=(0,F.c)(6),{label:n,children:r,className:i}=e,a;t[0]===n?a=t[1]:(a=(0,X.jsx)(`span`,{className:ue,children:n}),t[0]=n,t[1]=a);let o;return t[2]!==r||t[3]!==i||t[4]!==a?(o=(0,X.jsxs)(`div`,{className:i,children:[a,r]}),t[2]=r,t[3]=i,t[4]=a,t[5]=o):o=t[5],o}function $(e){let t=(0,F.c)(11),{label:n,children:r,className:a}=e,o;t[0]===a?o=t[1]:(o=i(`min-w-0`,a),t[0]=a,t[1]=o);let s;t[2]===n?s=t[3]:(s=(0,X.jsx)(`dt`,{className:ue,children:n}),t[2]=n,t[3]=s);let c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=i(Z,`mt-0.5`),t[4]=c):c=t[4];let l;t[5]===r?l=t[6]:(l=(0,X.jsx)(`dd`,{className:c,children:r}),t[5]=r,t[6]=l);let u;return t[7]!==o||t[8]!==s||t[9]!==l?(u=(0,X.jsxs)(`div`,{className:o,children:[s,l]}),t[7]=o,t[8]=s,t[9]=l,t[10]=u):u=t[10],u}function de(e){let t=(0,F.c)(5),{label:n,className:r}=e,a;t[0]===r?a=t[1]:(a=i(`text-[0.7rem] font-semibold uppercase tracking-wider text-fg-muted`,r),t[0]=r,t[1]=a);let o;return t[2]!==n||t[3]!==a?(o=(0,X.jsx)(`h3`,{className:a,children:n}),t[2]=n,t[3]=a,t[4]=o):o=t[4],o}function fe(e){let t=(0,F.c)(38),{icon:n,title:r,hint:i,enabled:a,onEnabledChange:o,cron:s,onCronChange:c,scheduleLabels:l,disabled:u,onLabel:d,offLabel:f,cronLabel:p,children:m}=e,h;t[0]===n?h=t[1]:(h=(0,X.jsx)(`span`,{className:`mt-0.5 shrink-0`,children:n}),t[0]=n,t[1]=h);let g;t[2]===r?g=t[3]:(g=(0,X.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:r}),t[2]=r,t[3]=g);let _;t[4]===i?_=t[5]:(_=(0,X.jsx)(`p`,{className:`mt-0.5 text-xs leading-snug text-fg-muted`,children:i}),t[4]=i,t[5]=_);let v;t[6]!==g||t[7]!==_?(v=(0,X.jsxs)(`div`,{className:`min-w-0`,children:[g,_]}),t[6]=g,t[7]=_,t[8]=v):v=t[8];let y;t[9]!==h||t[10]!==v?(y=(0,X.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[h,v]}),t[9]=h,t[10]=v,t[11]=y):y=t[11];let b;t[12]===o?b=t[13]:(b=e=>o(e.target.checked),t[12]=o,t[13]=b);let x;t[14]!==u||t[15]!==a||t[16]!==b?(x=(0,X.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:a,disabled:u,onChange:b}),t[14]=u,t[15]=a,t[16]=b,t[17]=x):x=t[17];let S=a?d:f,C;t[18]===S?C=t[19]:(C=(0,X.jsx)(`span`,{children:S}),t[18]=S,t[19]=C);let w;t[20]!==x||t[21]!==C?(w=(0,X.jsxs)(`label`,{className:`inline-flex shrink-0 items-center gap-2 text-xs text-fg`,children:[x,C]}),t[20]=x,t[21]=C,t[22]=w):w=t[22];let T;t[23]!==w||t[24]!==y?(T=(0,X.jsxs)(`div`,{className:`mb-2.5 flex flex-wrap items-start justify-between gap-2 border-b border-edge-subtle/80 pb-2.5`,children:[y,w]}),t[23]=w,t[24]=y,t[25]=T):T=t[25];let E;t[26]!==s||t[27]!==p||t[28]!==u||t[29]!==c||t[30]!==l?(E=(0,X.jsx)(N,{kind:`cron`,className:`mb-2.5`,label:p,value:s,onChange:c,labels:l,disabled:u}),t[26]=s,t[27]=p,t[28]=u,t[29]=c,t[30]=l,t[31]=E):E=t[31];let D;t[32]===m?D=t[33]:(D=(0,X.jsx)(`div`,{className:`grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-4`,children:m}),t[32]=m,t[33]=D);let O;return t[34]!==T||t[35]!==E||t[36]!==D?(O=(0,X.jsxs)(`div`,{className:q,children:[T,E,D]}),t[34]=T,t[35]=E,t[36]=D,t[37]=O):O=t[37],O}function pe(e){let t=(0,F.c)(23),{icon:n,label:r,enabled:a,cron:o,scheduleSummary:s,details:c,t:l}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=i(q,`space-y-1`),t[0]=u):u=t[0];let d;t[1]===r?d=t[2]:(d=(0,X.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:r}),t[1]=r,t[2]=d);let f=a?`text-emerald-600 dark:text-emerald-400`:`text-fg-muted`,p;t[3]===f?p=t[4]:(p=i(`ml-auto text-xs font-medium`,f),t[3]=f,t[4]=p);let m=a?l.on:l.off,h;t[5]!==p||t[6]!==m?(h=(0,X.jsx)(`span`,{className:p,children:m}),t[5]=p,t[6]=m,t[7]=h):h=t[7];let g;t[8]!==n||t[9]!==d||t[10]!==h?(g=(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n,d,h]}),t[8]=n,t[9]=d,t[10]=h,t[11]=g):g=t[11];let _;t[12]===s?_=t[13]:(_=(0,X.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:s}),t[12]=s,t[13]=_);let v;t[14]===o?v=t[15]:(v=(0,X.jsx)(`p`,{className:`truncate font-mono text-[0.65rem] text-fg-subtle`,title:o,children:o}),t[14]=o,t[15]=v);let y;t[16]===c?y=t[17]:(y=(0,X.jsx)(`p`,{className:`text-[0.65rem] leading-snug text-fg-muted`,children:c}),t[16]=c,t[17]=y);let b;return t[18]!==y||t[19]!==g||t[20]!==_||t[21]!==v?(b=(0,X.jsxs)(`div`,{className:u,children:[g,_,v,y]}),t[18]=y,t[19]=g,t[20]=_,t[21]=v,t[22]=b):b=t[22],b}function me(e){let t=(0,F.c)(9),{label:n,lastRun:r,t:i}=e,a;t[0]===n?a=t[1]:(a=(0,X.jsx)(de,{label:n,className:`mb-2`}),t[0]=n,t[1]=a);let o;t[2]!==r||t[3]!==i.lastRunRaw||t[4]!==i.phaseLastRunEmpty?(o=r?.exists?(0,X.jsxs)(`details`,{className:`group rounded-lg border border-edge-subtle`,children:[(0,X.jsx)(`summary`,{className:`cursor-pointer list-none px-2.5 py-1.5 text-xs font-medium text-fg-muted marker:hidden [&::-webkit-details-marker]:hidden`,children:(0,X.jsx)(`span`,{className:`underline decoration-edge underline-offset-2 group-open:text-fg`,children:i.lastRunRaw})}),(0,X.jsx)(`pre`,{className:`max-h-40 overflow-auto border-t border-edge-subtle p-2.5 text-xs text-fg-muted`,children:JSON.stringify(r.raw,null,2)})]}):(0,X.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.phaseLastRunEmpty}),t[2]=r,t[3]=i.lastRunRaw,t[4]=i.phaseLastRunEmpty,t[5]=o):o=t[5];let s;return t[6]!==a||t[7]!==o?(s=(0,X.jsxs)(`div`,{className:`border-t border-edge-subtle/80 pt-3`,children:[a,o]}),t[6]=a,t[7]=o,t[8]=s):s=t[8],s}function he(e){let t=(0,F.c)(39),{t:n,r}=e,i=r.deep?.skipped,a=r.ok?`text-emerald-600 dark:text-emerald-400`:`text-amber-600 dark:text-amber-400`,o=r.ok?n.lastRunSuccess:n.lastRunFailure,s;t[0]!==a||t[1]!==o?(s=(0,X.jsx)(`span`,{className:a,children:o}),t[0]=a,t[1]=o,t[2]=s):s=t[2];let c;t[3]!==n.lastRunStatus||t[4]!==s?(c=(0,X.jsx)($,{label:n.lastRunStatus,children:s}),t[3]=n.lastRunStatus,t[4]=s,t[5]=c):c=t[5];let l=n.lastRunDuration,u;t[6]===r.durationMs?u=t[7]:(u=Y(r.durationMs),t[6]=r.durationMs,t[7]=u);let d;t[8]!==n.lastRunDuration||t[9]!==u?(d=(0,X.jsx)($,{label:l,children:u}),t[8]=n.lastRunDuration,t[9]=u,t[10]=d):d=t[10];let f=n.lastRunRanked,p=String(r.deep?.candidatesRanked??`—`),m;t[11]!==n.lastRunRanked||t[12]!==p?(m=(0,X.jsx)($,{label:f,children:p}),t[11]=n.lastRunRanked,t[12]=p,t[13]=m):m=t[13];let h=n.lastRunApplied,g=String(r.deep?.applied??`—`),_;t[14]!==n.lastRunApplied||t[15]!==g?(_=(0,X.jsx)($,{label:h,children:g}),t[14]=n.lastRunApplied,t[15]=g,t[16]=_):_=t[16];let v;t[17]===r.reason?v=t[18]:(v=(0,X.jsx)(`span`,{className:`block text-pretty`,children:r.reason}),t[17]=r.reason,t[18]=v);let y;t[19]!==r.errorMessage||t[20]!==n.lastRunError?(y=r.errorMessage?(0,X.jsx)(`span`,{className:`mt-1 block text-xs text-amber-600 dark:text-amber-400`,children:`${n.lastRunError}: ${r.errorMessage}`}):null,t[19]=r.errorMessage,t[20]=n.lastRunError,t[21]=y):y=t[21];let b;t[22]!==n.lastRunReason||t[23]!==v||t[24]!==y?(b=(0,X.jsxs)($,{label:n.lastRunReason,className:`col-span-2 sm:col-span-3 lg:col-span-4`,children:[v,y]}),t[22]=n.lastRunReason,t[23]=v,t[24]=y,t[25]=b):b=t[25];let x;t[26]!==i||t[27]!==n.lastRunSkipContaminated||t[28]!==n.lastRunSkipHash||t[29]!==n.lastRunSkipKey||t[30]!==n.lastRunSkipRehydrate?(x=i?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)($,{label:n.lastRunSkipKey,children:String(i.alreadyPromotedKey)}),(0,X.jsx)($,{label:n.lastRunSkipRehydrate,children:String(i.rehydrateFailed)}),(0,X.jsx)($,{label:n.lastRunSkipContaminated,children:String(i.contaminated)}),(0,X.jsx)($,{label:n.lastRunSkipHash,children:String(i.hashDuplicate)})]}):null,t[26]=i,t[27]=n.lastRunSkipContaminated,t[28]=n.lastRunSkipHash,t[29]=n.lastRunSkipKey,t[30]=n.lastRunSkipRehydrate,t[31]=x):x=t[31];let S;return t[32]!==m||t[33]!==_||t[34]!==b||t[35]!==x||t[36]!==c||t[37]!==d?(S=(0,X.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-3 gap-y-2 sm:grid-cols-3 lg:grid-cols-4`,children:[c,d,m,_,b,x]}),t[32]=m,t[33]=_,t[34]=b,t[35]=x,t[36]=c,t[37]=d,t[38]=S):S=t[38],S}function ge(e){let t=(0,F.c)(58),{t:n,schedulePickerLabels:r,hasToken:a,cfgForm:o,cfgBaseline:s,cfgSaving:c,cfgDirty:l,setCfgForm:u,setCfgOk:d,setCfgError:f,saveConfig:p}=e,h;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(h=i(`min-w-0`,K),t[0]=h):h=t[0];let g=!a||!o||c||!l,_;t[1]===p?_=t[2]:(_=()=>void p(),t[1]=p,t[2]=_);let y;t[3]===c?y=t[4]:(y=c?(0,X.jsx)(C,{className:`mr-2 size-4 animate-spin`,"aria-hidden":!0}):null,t[3]=c,t[4]=y);let b;t[5]!==n.saveConfig||t[6]!==g||t[7]!==_||t[8]!==y?(b=(0,X.jsxs)(S,{variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:g,onClick:_,children:[y,n.saveConfig]}),t[5]=n.saveConfig,t[6]=g,t[7]=_,t[8]=y,t[9]=b):b=t[9];let x=!a||!o||c||!l,E;t[10]!==s||t[11]!==f||t[12]!==u||t[13]!==d?(E=()=>{d(!1),f(null),u(s)},t[10]=s,t[11]=f,t[12]=u,t[13]=d,t[14]=E):E=t[14];let D;t[15]!==n.resetConfig||t[16]!==x||t[17]!==E?(D=(0,X.jsx)(S,{variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:x,onClick:E,children:n.resetConfig}),t[15]=n.resetConfig,t[16]=x,t[17]=E,t[18]=D):D=t[18];let O;t[19]!==b||t[20]!==D?(O=(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[b,D]}),t[19]=b,t[20]=D,t[21]=O):O=t[21];let k;t[22]!==n.configHint||t[23]!==n.configTitle||t[24]!==O?(k=(0,X.jsx)(ee,{className:se,icon:T,title:n.configTitle,subtitle:n.configHint,trailing:O}),t[22]=n.configHint,t[23]=n.configTitle,t[24]=O,t[25]=k):k=t[25];let j;t[26]!==o||t[27]!==c||t[28]!==a||t[29]!==r||t[30]!==u||t[31]!==n.configDeepHalfLife||t[32]!==n.configDeepLimit||t[33]!==n.configDeepMaxAge||t[34]!==n.configDeepMinRecallCount||t[35]!==n.configDeepMinScore||t[36]!==n.configFrequency||t[37]!==n.configLightDedupe||t[38]!==n.configLightLimit||t[39]!==n.configLightLookbackDays||t[40]!==n.configLoading||t[41]!==n.configPhaseCron||t[42]!==n.configPhaseDeep||t[43]!==n.configPhaseDeepHint||t[44]!==n.configPhaseLight||t[45]!==n.configPhaseLightHint||t[46]!==n.configPhaseRem||t[47]!==n.configPhaseRemHint||t[48]!==n.configRemLimit||t[49]!==n.configRemLookbackDays||t[50]!==n.configRemMinStrength||t[51]!==n.configTimezone||t[52]!==n.off||t[53]!==n.on?(j=o?(0,X.jsxs)(`div`,{className:`space-y-3`,children:[(0,X.jsx)(`div`,{className:q,children:(0,X.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 lg:grid-cols-12`,children:[(0,X.jsx)(`div`,{className:`lg:col-span-9`,children:(0,X.jsx)(N,{kind:`cron`,label:n.configFrequency,value:o.frequency,onChange:e=>u(t=>t&&{...t,frequency:e}),labels:r,disabled:!a||c})}),(0,X.jsx)(Q,{label:n.configTimezone,className:`lg:col-span-3`,children:(0,X.jsx)(`input`,{className:J,value:o.timezone,disabled:!a||c,onChange:e=>u(t=>t&&{...t,timezone:e.target.value}),placeholder:`Asia/Shanghai`})})]})}),(0,X.jsxs)(fe,{icon:(0,X.jsx)(m,{className:`size-4 text-amber-500`}),title:n.configPhaseLight,hint:n.configPhaseLightHint,enabled:o.light.enabled,onEnabledChange:e=>u(t=>t&&{...t,light:{...t.light,enabled:e}}),cron:o.light.cron,onCronChange:e=>u(t=>t&&{...t,light:{...t.light,cron:e}}),scheduleLabels:r,disabled:!a||c,onLabel:n.on,offLabel:n.off,cronLabel:n.configPhaseCron,children:[(0,X.jsx)(Q,{label:n.configLightLookbackDays,children:(0,X.jsx)(`input`,{type:`number`,step:`1`,min:1,className:J,value:o.light.lookbackDays,disabled:!a||c,onChange:e=>u(t=>t&&{...t,light:{...t.light,lookbackDays:Number(e.target.value)}})})}),(0,X.jsx)(Q,{label:n.configLightLimit,children:(0,X.jsx)(`input`,{type:`number`,step:`1`,min:0,className:J,value:o.light.limit,disabled:!a||c,onChange:e=>u(t=>t&&{...t,light:{...t.light,limit:Number(e.target.value)}})})}),(0,X.jsx)(Q,{label:n.configLightDedupe,children:(0,X.jsx)(`input`,{type:`number`,step:`0.01`,min:0,max:1,className:J,value:o.light.dedupeSimilarity,disabled:!a||c,onChange:e=>u(t=>t&&{...t,light:{...t.light,dedupeSimilarity:Number(e.target.value)}})})})]}),(0,X.jsxs)(fe,{icon:(0,X.jsx)(v,{className:`size-4 text-indigo-500`}),title:n.configPhaseDeep,hint:n.configPhaseDeepHint,enabled:o.deep.enabled,onEnabledChange:e=>u(t=>t&&{...t,deep:{...t.deep,enabled:e}}),cron:o.deep.cron,onCronChange:e=>u(t=>t&&{...t,deep:{...t.deep,cron:e}}),scheduleLabels:r,disabled:!a||c,onLabel:n.on,offLabel:n.off,cronLabel:n.configPhaseCron,children:[(0,X.jsx)(Q,{label:n.configDeepMinScore,children:(0,X.jsx)(`input`,{type:`number`,step:`0.01`,min:0,max:1,className:J,value:o.deep.minScore,disabled:!a||c,onChange:e=>u(t=>t&&{...t,deep:{...t.deep,minScore:Number(e.target.value)}})})}),(0,X.jsx)(Q,{label:n.configDeepMinRecallCount,children:(0,X.jsx)(`input`,{type:`number`,step:`1`,min:1,className:J,value:o.deep.minRecallCount,disabled:!a||c,onChange:e=>u(t=>t&&{...t,deep:{...t.deep,minRecallCount:Number(e.target.value)}})})}),(0,X.jsx)(Q,{label:n.configDeepLimit,children:(0,X.jsx)(`input`,{type:`number`,step:`1`,min:0,className:J,value:o.deep.limit,disabled:!a||c,onChange:e=>u(t=>t&&{...t,deep:{...t.deep,limit:Number(e.target.value)}})})}),(0,X.jsx)(Q,{label:n.configDeepHalfLife,children:(0,X.jsx)(`input`,{type:`number`,step:`1`,min:1,className:J,value:o.deep.recencyHalfLifeDays,disabled:!a||c,onChange:e=>u(t=>t&&{...t,deep:{...t.deep,recencyHalfLifeDays:Number(e.target.value)}})})}),(0,X.jsx)(Q,{label:n.configDeepMaxAge,children:(0,X.jsx)(`input`,{type:`number`,step:`1`,min:1,className:J,value:o.deep.maxAgeDays,disabled:!a||c,onChange:e=>u(t=>t&&{...t,deep:{...t.deep,maxAgeDays:Number(e.target.value)}})})})]}),(0,X.jsxs)(fe,{icon:(0,X.jsx)(w,{className:`size-4 text-purple-500`}),title:n.configPhaseRem,hint:n.configPhaseRemHint,enabled:o.rem.enabled,onEnabledChange:e=>u(t=>t&&{...t,rem:{...t.rem,enabled:e}}),cron:o.rem.cron,onCronChange:e=>u(t=>t&&{...t,rem:{...t.rem,cron:e}}),scheduleLabels:r,disabled:!a||c,onLabel:n.on,offLabel:n.off,cronLabel:n.configPhaseCron,children:[(0,X.jsx)(Q,{label:n.configRemLookbackDays,children:(0,X.jsx)(`input`,{type:`number`,step:`1`,min:1,className:J,value:o.rem.lookbackDays,disabled:!a||c,onChange:e=>u(t=>t&&{...t,rem:{...t.rem,lookbackDays:Number(e.target.value)}})})}),(0,X.jsx)(Q,{label:n.configRemLimit,children:(0,X.jsx)(`input`,{type:`number`,step:`1`,min:0,className:J,value:o.rem.limit,disabled:!a||c,onChange:e=>u(t=>t&&{...t,rem:{...t.rem,limit:Number(e.target.value)}})})}),(0,X.jsx)(Q,{label:n.configRemMinStrength,children:(0,X.jsx)(`input`,{type:`number`,step:`0.01`,min:0,max:1,className:J,value:o.rem.minPatternStrength,disabled:!a||c,onChange:e=>u(t=>t&&{...t,rem:{...t.rem,minPatternStrength:Number(e.target.value)}})})})]})]}):(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.configLoading}),t[26]=o,t[27]=c,t[28]=a,t[29]=r,t[30]=u,t[31]=n.configDeepHalfLife,t[32]=n.configDeepLimit,t[33]=n.configDeepMaxAge,t[34]=n.configDeepMinRecallCount,t[35]=n.configDeepMinScore,t[36]=n.configFrequency,t[37]=n.configLightDedupe,t[38]=n.configLightLimit,t[39]=n.configLightLookbackDays,t[40]=n.configLoading,t[41]=n.configPhaseCron,t[42]=n.configPhaseDeep,t[43]=n.configPhaseDeepHint,t[44]=n.configPhaseLight,t[45]=n.configPhaseLightHint,t[46]=n.configPhaseRem,t[47]=n.configPhaseRemHint,t[48]=n.configRemLimit,t[49]=n.configRemLookbackDays,t[50]=n.configRemMinStrength,t[51]=n.configTimezone,t[52]=n.off,t[53]=n.on,t[54]=j):j=t[54];let M;return t[55]!==k||t[56]!==j?(M=(0,X.jsxs)(A,{className:h,children:[k,j]}),t[55]=k,t[56]=j,t[57]=M):M=t[57],M}function _e(e){let t=(0,F.c)(20),{t:n,hasToken:r,eventsLoading:i,events:a,loadEvents:o}=e,s=!r||i,c;t[0]===o?c=t[1]:(c=()=>void o(),t[0]=o,t[1]=c);let l;t[2]===i?l=t[3]:(l=i?(0,X.jsx)(C,{className:`mr-2 size-4 animate-spin`,"aria-hidden":!0}):null,t[2]=i,t[3]=l);let u;t[4]!==n.eventsLoad||t[5]!==s||t[6]!==c||t[7]!==l?(u=(0,X.jsxs)(S,{variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:s,onClick:c,children:[l,n.eventsLoad]}),t[4]=n.eventsLoad,t[5]=s,t[6]=c,t[7]=l,t[8]=u):u=t[8];let d;t[9]!==n.eventsHint||t[10]!==n.eventsTitle||t[11]!==u?(d=(0,X.jsx)(ee,{className:se,icon:O,title:n.eventsTitle,subtitle:n.eventsHint,trailing:u}),t[9]=n.eventsHint,t[10]=n.eventsTitle,t[11]=u,t[12]=d):d=t[12];let f;t[13]!==a||t[14]!==n.eventsEmpty||t[15]!==n.eventsNotLoaded?(f=a?a.length>0?(0,X.jsx)(`div`,{className:`space-y-1.5`,children:a.map(ve)}):(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.eventsEmpty}):(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.eventsNotLoaded}),t[13]=a,t[14]=n.eventsEmpty,t[15]=n.eventsNotLoaded,t[16]=f):f=t[16];let p;return t[17]!==d||t[18]!==f?(p=(0,X.jsxs)(A,{className:K,children:[d,f]}),t[17]=d,t[18]=f,t[19]=p):p=t[19],p}function ve(e){let t=e.phase===`light`?`☀️`:e.phase===`rem`?`✨`:`🌙`,n=e.phase===`light`?`scanned=${e.scannedEntries??0} new=${e.newSignals??0} deduped=${e.deduped??0}`:e.phase===`rem`?`patterns=${e.patternsDiscovered??0} analyzed=${e.entriesAnalyzed??0}`:`candidates=${e.candidates??0} applied=${e.applied??0}`;return(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 rounded-lg border border-edge-subtle bg-surface-panel/60 px-3 py-2 text-xs`,children:[(0,X.jsx)(`span`,{children:t}),(0,X.jsx)(`span`,{className:`font-medium text-fg`,children:e.phase}),(0,X.jsx)(`span`,{className:i(`font-medium`,e.ok?`text-emerald-600 dark:text-emerald-400`:`text-amber-600 dark:text-amber-400`),children:e.ok?`OK`:`FAIL`}),(0,X.jsx)(`span`,{className:`text-fg-muted`,children:n}),(0,X.jsx)(`span`,{className:`text-fg-muted`,children:Y(e.durationMs)}),(0,X.jsx)(`span`,{className:`ml-auto text-fg-subtle`,children:ce(e.timestamp)})]},`${e.timestamp}:${e.phase}`)}function ye(e){let t=(0,F.c)(40),{t:n,cfgForm:r,dreamingEnabled:a,hasToken:o,cfgSaving:s,enableSaving:c,runPhase:l,setRunPhase:u,runBusy:d,doRunNow:f,doRefresh:p,setDreamingEnabled:m}=e,h;t[0]===n.title?h=t[1]:(h=(0,X.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:n.title}),t[0]=n.title,t[1]=h);let g;t[2]===n.subtitle?g=t[3]:(g=(0,X.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:n.subtitle}),t[2]=n.subtitle,t[3]=g);let v;t[4]!==h||t[5]!==g?(v=(0,X.jsxs)(`div`,{className:`min-w-0`,children:[h,g]}),t[4]=h,t[5]=g,t[6]=v):v=t[6];let b;t[7]!==r||t[8]!==s||t[9]!==a||t[10]!==c||t[11]!==o||t[12]!==m||t[13]!==n.configEnabled||t[14]!==n.off||t[15]!==n.on?(b=r?(0,X.jsxs)(`label`,{className:i(`inline-flex cursor-pointer items-center gap-2 rounded-xl border px-3 py-1.5 text-sm transition-colors`,a?`border-emerald-500/30 bg-emerald-500/5 text-fg`:`border-edge-subtle bg-surface-panel/50 text-fg-muted`),children:[(0,X.jsx)(`span`,{className:`text-xs font-medium`,children:n.configEnabled}),(0,X.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.enabled,disabled:!o||s||c,onChange:e=>void m(e.target.checked)}),c?(0,X.jsx)(C,{className:`size-3.5 animate-spin text-fg-muted`,"aria-hidden":!0}):(0,X.jsx)(`span`,{className:i(`text-xs font-semibold`,a?`text-emerald-600 dark:text-emerald-400`:``),children:r.enabled?n.on:n.off})]}):null,t[7]=r,t[8]=s,t[9]=a,t[10]=c,t[11]=o,t[12]=m,t[13]=n.configEnabled,t[14]=n.off,t[15]=n.on,t[16]=b):b=t[16];let x;t[17]!==f||t[18]!==a||t[19]!==o||t[20]!==d||t[21]!==l||t[22]!==u||t[23]!==n.runNow||t[24]!==n.runNowHint?(x=a?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`select`,{className:`rounded-lg border border-edge bg-surface-panel px-2 py-1.5 text-xs text-fg`,value:l,onChange:e=>u(e.target.value),disabled:!o||d,children:[(0,X.jsx)(`option`,{value:`light`,children:`Light`}),(0,X.jsx)(`option`,{value:`deep`,children:`Deep`}),(0,X.jsx)(`option`,{value:`rem`,children:`REM`})]}),(0,X.jsxs)(S,{variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:!o||d,onClick:()=>void f(l),title:n.runNowHint,children:[d?(0,X.jsx)(C,{className:`mr-2 size-4 animate-spin`,"aria-hidden":!0}):(0,X.jsx)(_,{className:`mr-2 size-4`,"aria-hidden":!0}),n.runNow]})]}):null,t[17]=f,t[18]=a,t[19]=o,t[20]=d,t[21]=l,t[22]=u,t[23]=n.runNow,t[24]=n.runNowHint,t[25]=x):x=t[25];let w=!o,T;t[26]===p?T=t[27]:(T=()=>void p(),t[26]=p,t[27]=T);let E;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,X.jsx)(y,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[28]=E):E=t[28];let D;t[29]!==n.refresh||t[30]!==w||t[31]!==T?(D=(0,X.jsx)(S,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,disabled:w,title:n.refresh,"aria-label":n.refresh,onClick:T,children:E}),t[29]=n.refresh,t[30]=w,t[31]=T,t[32]=D):D=t[32];let O;t[33]!==b||t[34]!==x||t[35]!==D?(O=(0,X.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2`,children:[b,x,D]}),t[33]=b,t[34]=x,t[35]=D,t[36]=O):O=t[36];let k;return t[37]!==O||t[38]!==v?(k=(0,X.jsxs)(`header`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:[v,O]}),t[37]=O,t[38]=v,t[39]=k):k=t[39],k}function be(e){let t=(0,F.c)(30),{t:n,disabled:r,actionBusy:a,doAction:o}=e,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=i(`max-w-2xl`,K),t[0]=s):s=t[0];let c;t[1]!==n.maintenanceHint||t[2]!==n.maintenanceTitle?(c=(0,X.jsx)(ee,{className:se,icon:g,title:n.maintenanceTitle,subtitle:n.maintenanceHint}),t[1]=n.maintenanceHint,t[2]=n.maintenanceTitle,t[3]=c):c=t[3];let l;t[4]!==o||t[5]!==n.confirmResetStore?(l=()=>{confirm(n.confirmResetStore)&&o(`reset_store`)},t[4]=o,t[5]=n.confirmResetStore,t[6]=l):l=t[6];let u;t[7]===a?u=t[8]:(u=a===`reset_store`?(0,X.jsx)(C,{className:`mr-2 size-4 animate-spin`,"aria-hidden":!0}):(0,X.jsx)(p,{className:`mr-2 size-4`,"aria-hidden":!0}),t[7]=a,t[8]=u);let d;t[9]!==r||t[10]!==n.resetStore||t[11]!==l||t[12]!==u?(d=(0,X.jsxs)(S,{variant:`secondary`,disabled:r,onClick:l,children:[u,n.resetStore]}),t[9]=r,t[10]=n.resetStore,t[11]=l,t[12]=u,t[13]=d):d=t[13];let f;t[14]!==o||t[15]!==n.confirmClearLock?(f=()=>{confirm(n.confirmClearLock)&&o(`clear_lock`)},t[14]=o,t[15]=n.confirmClearLock,t[16]=f):f=t[16];let m;t[17]===a?m=t[18]:(m=a===`clear_lock`?(0,X.jsx)(C,{className:`mr-2 size-4 animate-spin`,"aria-hidden":!0}):(0,X.jsx)(h,{className:`mr-2 size-4`,"aria-hidden":!0}),t[17]=a,t[18]=m);let _;t[19]!==r||t[20]!==n.clearLock||t[21]!==f||t[22]!==m?(_=(0,X.jsxs)(S,{variant:`secondary`,disabled:r,onClick:f,children:[m,n.clearLock]}),t[19]=r,t[20]=n.clearLock,t[21]=f,t[22]=m,t[23]=_):_=t[23];let v;t[24]!==d||t[25]!==_?(v=(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[d,_]}),t[24]=d,t[25]=_,t[26]=v):v=t[26];let y;return t[27]!==c||t[28]!==v?(y=(0,X.jsxs)(A,{className:s,children:[c,v]}),t[27]=c,t[28]=v,t[29]=y):y=t[29],y}function xe(e){let t=(0,F.c)(21),{t:n,hasToken:r,previewLoading:i,previewItems:a,loadPreview:o}=e,s=!r||i,c;t[0]===o?c=t[1]:(c=()=>void o(),t[0]=o,t[1]=c);let l;t[2]===i?l=t[3]:(l=i?(0,X.jsx)(C,{className:`mr-2 size-4 animate-spin`,"aria-hidden":!0}):null,t[2]=i,t[3]=l);let u;t[4]!==n.previewLoad||t[5]!==s||t[6]!==c||t[7]!==l?(u=(0,X.jsxs)(S,{variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:s,onClick:c,children:[l,n.previewLoad]}),t[4]=n.previewLoad,t[5]=s,t[6]=c,t[7]=l,t[8]=u):u=t[8];let d;t[9]!==n.previewHint||t[10]!==n.previewTitle||t[11]!==u?(d=(0,X.jsx)(ee,{className:se,icon:x,title:n.previewTitle,subtitle:n.previewHint,trailing:u}),t[9]=n.previewHint,t[10]=n.previewTitle,t[11]=u,t[12]=d):d=t[12];let f;t[13]!==a||t[14]!==n.previewEligible||t[15]!==n.previewEmpty||t[16]!==n.previewNotLoaded?(f=a?a.length>0?(0,X.jsx)(`div`,{className:`space-y-2`,children:a.map(e=>{let t=`${e.path}:${e.startLine}-${e.endLine}`,r=e.skippedReason;return(0,X.jsxs)(`div`,{className:`rounded-lg border border-edge-subtle bg-surface-panel/60 px-2.5 py-2`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-muted`,children:[(0,X.jsx)(`span`,{className:`font-medium text-fg`,children:t}),(0,X.jsxs)(`span`,{children:[`score=`,e.score.toFixed(3)]}),(0,X.jsxs)(`span`,{children:[`recalls=`,e.recallCount]}),(0,X.jsxs)(`span`,{children:[`avg=`,e.avgScore.toFixed(3)]}),(0,X.jsxs)(`span`,{children:[`decay=`,e.recencyDecay?.toFixed(3)??`—`]}),r?(0,X.jsx)(`span`,{className:`text-amber-600 dark:text-amber-400`,children:r}):(0,X.jsx)(`span`,{className:`text-emerald-600 dark:text-emerald-400`,children:n.previewEligible})]}),e.snippet?(0,X.jsx)(`div`,{className:`mt-2 text-sm text-fg`,children:e.snippet}):null]},`${e.key}:${e.hash}:${t}`)})}):(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.previewEmpty}):(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.previewNotLoaded}),t[13]=a,t[14]=n.previewEligible,t[15]=n.previewEmpty,t[16]=n.previewNotLoaded,t[17]=f):f=t[17];let p;return t[18]!==d||t[19]!==f?(p=(0,X.jsxs)(A,{className:K,children:[d,f]}),t[18]=d,t[19]=f,t[20]=p):p=t[20],p}function Se(e){let t=(0,F.c)(100),{t:n,data:r,isLoading:a,localeTag:o,scheduleBadgeLabels:s}=e,c;t[0]!==r||t[1]!==n?(c=r?le(r.lock,n):null,t[0]=r,t[1]=n,t[2]=c):c=t[2];let l=c,u;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(u=i(`min-w-0`,K),t[3]=u):u=t[3];let d;t[4]===a?d=t[5]:(d=a?(0,X.jsx)(C,{className:`size-4 shrink-0 animate-spin text-fg-muted`,"aria-hidden":!0}):null,t[4]=a,t[5]=d);let f;t[6]!==n.runtimeHint||t[7]!==n.runtimeTitle||t[8]!==d?(f=(0,X.jsx)(ee,{className:se,icon:O,title:n.runtimeTitle,subtitle:n.runtimeHint,trailing:d}),t[6]=n.runtimeHint,t[7]=n.runtimeTitle,t[8]=d,t[9]=f):f=t[9];let p;t[10]===n.subsectionSchedule?p=t[11]:(p=(0,X.jsx)(de,{label:n.subsectionSchedule,className:`mb-2`}),t[10]=n.subsectionSchedule,t[11]=p);let h=r?r.config.enabled?n.on:n.off:`—`,g;t[12]!==n.enabled||t[13]!==h?(g=(0,X.jsx)($,{label:n.enabled,children:h}),t[12]=n.enabled,t[13]=h,t[14]=g):g=t[14];let _=l?.className,y=l?l.text:`—`,b;t[15]!==_||t[16]!==y?(b=(0,X.jsx)(`span`,{className:_,children:y}),t[15]=_,t[16]=y,t[17]=b):b=t[17];let x;t[18]!==n.lock||t[19]!==b?(x=(0,X.jsx)($,{label:n.lock,children:b}),t[18]=n.lock,t[19]=b,t[20]=x):x=t[20];let S=r&&r.config.timezone||`—`,T;t[21]!==n.timezone||t[22]!==S?(T=(0,X.jsx)($,{label:n.timezone,children:S}),t[21]=n.timezone,t[22]=S,t[23]=T):T=t[23];let E;t[24]!==r||t[25]!==o||t[26]!==s?(E=r?(0,X.jsx)(M,{kind:`cron`,expression:r.config.frequency,locale:o,labels:s,timezone:r.config.timezone||void 0}):`—`,t[24]=r,t[25]=o,t[26]=s,t[27]=E):E=t[27];let D;t[28]===r?D=t[29]:(D=r?.config.frequency?(0,X.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-[0.65rem] text-fg-subtle`,title:r.config.frequency,children:r.config.frequency}):null,t[28]=r,t[29]=D);let k;t[30]!==n.schedule||t[31]!==E||t[32]!==D?(k=(0,X.jsxs)($,{label:n.schedule,className:`col-span-2 sm:col-span-2`,children:[E,D]}),t[30]=n.schedule,t[31]=E,t[32]=D,t[33]=k):k=t[33];let N;t[34]!==x||t[35]!==T||t[36]!==k||t[37]!==g?(N=(0,X.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-3 gap-y-2 sm:grid-cols-4`,children:[g,x,T,k]}),t[34]=x,t[35]=T,t[36]=k,t[37]=g,t[38]=N):N=t[38];let P;t[39]!==N||t[40]!==p?(P=(0,X.jsxs)(`div`,{className:q,children:[p,N]}),t[39]=N,t[40]=p,t[41]=P):P=t[41];let I;t[42]===n.subsectionStore?I=t[43]:(I=(0,X.jsx)(de,{label:n.subsectionStore,className:`mb-2`}),t[42]=n.subsectionStore,t[43]=I);let te=r?String(r.store.entryCount):`—`,ne;t[44]!==n.storeEntries||t[45]!==te?(ne=(0,X.jsx)($,{label:n.storeEntries,children:te}),t[44]=n.storeEntries,t[45]=te,t[46]=ne):ne=t[46];let re=r?String(r.store.promotedCount):`—`,ie;t[47]!==n.storePromoted||t[48]!==re?(ie=(0,X.jsx)($,{label:n.storePromoted,children:re}),t[47]=n.storePromoted,t[48]=re,t[49]=ie):ie=t[49];let ae;t[50]===r?ae=t[51]:(ae=r?ce(r.store.updatedAt):`—`,t[50]=r,t[51]=ae);let L;t[52]!==n.storeUpdatedAt||t[53]!==ae?(L=(0,X.jsx)($,{label:n.storeUpdatedAt,children:ae}),t[52]=n.storeUpdatedAt,t[53]=ae,t[54]=L):L=t[54];let R;t[55]===r?R=t[56]:(R=r?ce(r.store.lastPromotedAt):`—`,t[55]=r,t[56]=R);let z;t[57]!==n.storeLastPromotedAt||t[58]!==R?(z=(0,X.jsx)($,{label:n.storeLastPromotedAt,children:R}),t[57]=n.storeLastPromotedAt,t[58]=R,t[59]=z):z=t[59];let B;t[60]!==ne||t[61]!==ie||t[62]!==L||t[63]!==z?(B=(0,X.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-3 gap-y-2 sm:grid-cols-4`,children:[ne,ie,L,z]}),t[60]=ne,t[61]=ie,t[62]=L,t[63]=z,t[64]=B):B=t[64];let V;t[65]!==I||t[66]!==B?(V=(0,X.jsxs)(`div`,{className:q,children:[I,B]}),t[65]=I,t[66]=B,t[67]=V):V=t[67];let H;t[68]!==r||t[69]!==o||t[70]!==s||t[71]!==n?(H=r?.config?.phases?(0,X.jsxs)(`div`,{children:[(0,X.jsx)(de,{label:n.subsectionPhases,className:`mb-2`}),(0,X.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[(0,X.jsx)(pe,{icon:(0,X.jsx)(m,{className:`size-4 text-amber-500`}),label:`Light`,enabled:r.config.phases.light.enabled,cron:r.config.phases.light.cron,scheduleSummary:j(r.config.phases.light.cron,o,s,{timezone:r.config.timezone||void 0}),details:`lookback=${r.config.phases.light.lookbackDays}d, limit=${r.config.phases.light.limit}, dedupe=${r.config.phases.light.dedupeSimilarity}`,t:n}),(0,X.jsx)(pe,{icon:(0,X.jsx)(v,{className:`size-4 text-indigo-500`}),label:`Deep`,enabled:r.config.phases.deep.enabled,cron:r.config.phases.deep.cron,scheduleSummary:j(r.config.phases.deep.cron,o,s,{timezone:r.config.timezone||void 0}),details:`minScore=${r.config.phases.deep.minScore}, recalls≥${r.config.phases.deep.minRecallCount}, limit=${r.config.phases.deep.limit}, halfLife=${r.config.phases.deep.recencyHalfLifeDays}d`,t:n}),(0,X.jsx)(pe,{icon:(0,X.jsx)(w,{className:`size-4 text-purple-500`}),label:`REM`,enabled:r.config.phases.rem.enabled,cron:r.config.phases.rem.cron,scheduleSummary:j(r.config.phases.rem.cron,o,s,{timezone:r.config.timezone||void 0}),details:`lookback=${r.config.phases.rem.lookbackDays}d, limit=${r.config.phases.rem.limit}, strength≥${r.config.phases.rem.minPatternStrength}`,t:n})]})]}):null,t[68]=r,t[69]=o,t[70]=s,t[71]=n,t[72]=H):H=t[72];let U;t[73]===n.subsectionLastRun?U=t[74]:(U=(0,X.jsx)(de,{label:n.subsectionLastRun,className:`mb-2`}),t[73]=n.subsectionLastRun,t[74]=U);let W;t[75]===n.lastRunBlockHint?W=t[76]:(W=(0,X.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:n.lastRunBlockHint}),t[75]=n.lastRunBlockHint,t[76]=W);let oe;t[77]!==r||t[78]!==n?(oe=r?.lastRun?.exists?(0,X.jsxs)(`div`,{className:`space-y-2`,children:[r.lastRun.parseError?(0,X.jsxs)(`p`,{className:`text-sm text-amber-600 dark:text-amber-400`,role:`alert`,children:[n.lastRunParseError,`: `,r.lastRun.parseError]}):null,r.lastRun.record?(0,X.jsx)(`div`,{className:`rounded-lg border border-edge-subtle/80 bg-surface-panel/50 p-2.5`,children:(0,X.jsx)(he,{t:n,r:r.lastRun.record})}):null,r.lastRun.raw!==void 0&&r.lastRun.raw!==null?(0,X.jsxs)(`details`,{className:`group rounded-lg border border-edge-subtle`,children:[(0,X.jsx)(`summary`,{className:`cursor-pointer list-none px-2.5 py-1.5 text-xs font-medium text-fg-muted marker:hidden [&::-webkit-details-marker]:hidden`,children:(0,X.jsx)(`span`,{className:`underline decoration-edge underline-offset-2 group-open:text-fg`,children:n.lastRunRaw})}),(0,X.jsx)(`pre`,{className:`max-h-40 overflow-auto border-t border-edge-subtle p-2.5 text-xs text-fg-muted`,children:JSON.stringify(r.lastRun.raw,null,2)})]}):null]}):(0,X.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.lastRunEmpty}),t[77]=r,t[78]=n,t[79]=oe):oe=t[79];let G;t[80]!==U||t[81]!==W||t[82]!==oe?(G=(0,X.jsxs)(`div`,{className:q,children:[U,W,oe]}),t[80]=U,t[81]=W,t[82]=oe,t[83]=G):G=t[83];let J=r?.lightLastRun,Y;t[84]!==n||t[85]!==J?(Y=(0,X.jsx)(me,{label:n.subsectionLightLastRun,lastRun:J,t:n}),t[84]=n,t[85]=J,t[86]=Y):Y=t[86];let ue=r?.remLastRun,Z;t[87]!==n||t[88]!==ue?(Z=(0,X.jsx)(me,{label:n.subsectionRemLastRun,lastRun:ue,t:n}),t[87]=n,t[88]=ue,t[89]=Z):Z=t[89];let Q;t[90]!==P||t[91]!==V||t[92]!==H||t[93]!==G||t[94]!==Y||t[95]!==Z?(Q=(0,X.jsxs)(`div`,{className:`space-y-3`,children:[P,V,H,G,Y,Z]}),t[90]=P,t[91]=V,t[92]=H,t[93]=G,t[94]=Y,t[95]=Z,t[96]=Q):Q=t[96];let fe;return t[97]!==Q||t[98]!==f?(fe=(0,X.jsxs)(A,{className:u,children:[f,Q]}),t[97]=Q,t[98]=f,t[99]=fe):fe=t[99],fe}var Ce=[`config`,`runtime`,`insights`,`maintenance`],we={config:T,runtime:O,insights:x,maintenance:g};function Te(e){return e&&Ce.includes(e)?e:`config`}function Ee(e,t){return t===`config`?e.tabConfig:t===`runtime`?e.tabRuntime:t===`insights`?e.tabInsights:e.tabMaintenance}function De(e,t){return t===`config`?e.configTabHint:t===`runtime`?e.runtimeTabHint:t===`insights`?e.insightsTabHint:e.maintenanceTabHint}function Oe(e,t){switch(t.type){case`reset`:return{form:null,baseline:null};case`sync`:return{form:t.value,baseline:t.value};case`set`:return{...e,form:t.value};case`saved`:return{form:t.value,baseline:t.value}}}var ke={actionBusy:null,actionError:null,actionOk:!1,runBusy:!1,runOk:!1,runError:null,runPhase:`deep`,cfgSaving:!1,enableSaving:!1,cfgOk:!1,cfgError:null,previewLoading:!1,previewError:null,previewItems:null,eventsLoading:!1,eventsError:null,events:null};function Ae(){let e=o(e=>e.language),t=a(e),n=t.dreamingSettings,r=t.cron.schedulePicker,i=t.cron.scheduleBadge,c=e===`zh`?`zh-CN`:`en-US`,l=!!s(e=>e.token),[p,m]=f(),h=Te(p.get(`tab`)),g=(0,P.useCallback)(e=>{m(t=>{let n=new URLSearchParams(t);return e===`config`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},[m]),{data:_}=b(l),[v,y]=(0,P.useReducer)(d,ke),{actionBusy:x,actionError:S,actionOk:C,runBusy:w,runOk:T,runError:E,runPhase:D,cfgSaving:O,enableSaving:k,cfgOk:ee,cfgError:A,previewLoading:j,previewError:M,previewItems:N,eventsLoading:F,eventsError:L,events:R}=v,[z,B]=(0,P.useReducer)(Oe,{form:null,baseline:null}),V=z.form,H=z.baseline,U=(0,P.useRef)(!1),{data:W,error:K,isLoading:se,mutate:q}=u(l?I():null,te,{revalidateOnFocus:!1}),J=(0,P.useMemo)(()=>{let e=[];return K&&e.push(K instanceof Error?K.message:String(K)),S&&e.push(S),E&&e.push(E),M&&e.push(M),L&&e.push(L),A&&e.push(A),e},[K,S,E,M,L,A]),ce=(0,P.useMemo)(()=>{let e=[];return ee&&e.push(n.configSaved),T&&e.push(n.runQueued),C&&e.push(n.actionOk),e},[ee,T,C,n]),Y=(0,P.useCallback)(async()=>{y({type:`patch`,patch:{actionOk:!1,actionError:null,runOk:!1,runError:null,cfgOk:!1,cfgError:null,previewError:null}}),await q()},[q]),le=(0,P.useCallback)(async()=>{y({type:`patch`,patch:{previewLoading:!0,previewError:null}});try{y({type:`patch`,patch:{previewItems:(await ie(20)).items??[]}})}catch(e){y({type:`patch`,patch:{previewError:e instanceof Error?e.message:String(e)}})}finally{y({type:`patch`,patch:{previewLoading:!1}})}},[]),ue=(0,P.useCallback)(async()=>{y({type:`patch`,patch:{eventsLoading:!0,eventsError:null}});try{y({type:`patch`,patch:{events:await ae(50)}})}catch(e){y({type:`patch`,patch:{eventsError:e instanceof Error?e.message:String(e)}})}finally{y({type:`patch`,patch:{eventsLoading:!1}})}},[]),Z=(0,P.useCallback)(async(e=`deep`)=>{y({type:`patch`,patch:{runBusy:!0,runOk:!1,runError:null}});try{await re(e),y({type:`patch`,patch:{runOk:!0}}),await q()}catch(e){y({type:`patch`,patch:{runError:e instanceof Error?e.message:String(e)}})}finally{y({type:`patch`,patch:{runBusy:!1}})}},[q]),Q=(0,P.useCallback)(async e=>{y({type:`patch`,patch:{actionBusy:e,actionError:null,actionOk:!1}});try{await ne(e),y({type:`patch`,patch:{actionOk:!0}}),await q()}catch(e){y({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{y({type:`patch`,patch:{actionBusy:null}})}},[q]),$=!l||se||!!x,de=(0,P.useMemo)(()=>{let e=_?.payload?.config;return oe(e??{})},[_]);(0,P.useEffect)(()=>{if(!l){B({type:`reset`}),U.current=!1;return}U.current||B({type:`sync`,value:de})},[de,l]);let fe=(0,P.useMemo)(()=>!V||!H?!1:JSON.stringify(V)!==JSON.stringify(H),[V,H]),pe=(0,P.useCallback)(async()=>{if(V){y({type:`patch`,patch:{cfgSaving:!0,cfgOk:!1,cfgError:null}});try{await G(V),B({type:`saved`,value:V}),U.current=!1,y({type:`patch`,patch:{cfgOk:!0}}),await q()}catch(e){y({type:`patch`,patch:{cfgError:e instanceof Error?e.message:String(e)}})}finally{y({type:`patch`,patch:{cfgSaving:!1}})}}},[V,q]),me=(0,P.useCallback)(async e=>{if(!V||!l)return;let t={...V,enabled:e},n=V;U.current=!0,B({type:`set`,value:t}),y({type:`patch`,patch:{enableSaving:!0,cfgOk:!1,cfgError:null}});try{await G(t),B({type:`saved`,value:t}),U.current=!1,y({type:`patch`,patch:{cfgOk:!0}}),await q()}catch(e){B({type:`set`,value:n}),y({type:`patch`,patch:{cfgError:e instanceof Error?e.message:String(e)}})}finally{y({type:`patch`,patch:{enableSaving:!1}})}},[V,l,q]);return(0,X.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-4 px-4 py-6`,children:[(0,X.jsx)(ye,{t:n,cfgForm:V,dreamingEnabled:V?.enabled??de.enabled,hasToken:l,cfgSaving:O,enableSaving:k,runPhase:D,setRunPhase:e=>y({type:`patch`,patch:{runPhase:e}}),runBusy:w,doRunNow:Z,doRefresh:Y,setDreamingEnabled:me}),J.length>0?(0,X.jsx)(`div`,{className:`space-y-1.5 rounded-2xl border border-amber-500/20 bg-amber-500/5 px-4 py-3`,role:`alert`,children:J.map(e=>(0,X.jsx)(`p`,{className:`text-sm text-amber-800 dark:text-amber-200/90`,children:e},e))}):null,ce.length>0?(0,X.jsx)(`div`,{className:`space-y-1.5 rounded-2xl border border-emerald-500/20 bg-emerald-500/5 px-4 py-3`,role:`status`,children:ce.map(e=>(0,X.jsx)(`p`,{className:`text-sm text-emerald-800 dark:text-emerald-200/90`,children:e},e))}):null,(0,X.jsx)(je,{t:n,activeTab:h,onChange:g}),(0,X.jsx)(Me,{t:n,id:`config`,activeTab:h,children:(0,X.jsx)(ge,{t:n,schedulePickerLabels:r,hasToken:l,cfgForm:V,cfgBaseline:H,cfgSaving:O,cfgDirty:fe,setCfgForm:e=>{U.current=!0;let t=typeof e==`function`?e(V):e;t&&B({type:`set`,value:t})},setCfgOk:e=>y({type:`patch`,patch:{cfgOk:e}}),setCfgError:e=>y({type:`patch`,patch:{cfgError:e}}),saveConfig:pe})}),(0,X.jsx)(Me,{t:n,id:`runtime`,activeTab:h,children:(0,X.jsx)(Se,{t:n,data:W,isLoading:se,localeTag:c,scheduleBadgeLabels:i})}),(0,X.jsx)(Me,{t:n,id:`insights`,activeTab:h,children:(0,X.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-2`,children:[(0,X.jsx)(xe,{t:n,hasToken:l,previewLoading:j,previewItems:N,loadPreview:le}),(0,X.jsx)(_e,{t:n,hasToken:l,eventsLoading:F,events:R,loadEvents:ue})]})}),(0,X.jsx)(Me,{t:n,id:`maintenance`,activeTab:h,children:(0,X.jsx)(be,{t:n,disabled:$,actionBusy:x,doAction:Q})})]})}function je(e){let t=(0,F.c)(11),{t:n,activeTab:r,onChange:a}=e,o=n.tabsAriaLabel,s;t[0]!==r||t[1]!==a?(s=e=>{e.key!==`ArrowLeft`&&e.key!==`ArrowRight`||(e.preventDefault(),a(Ce[(Ce.indexOf(r)+(e.key===`ArrowRight`?1:-1)+Ce.length)%Ce.length]))},t[0]=r,t[1]=a,t[2]=s):s=t[2];let c;t[3]!==r||t[4]!==a||t[5]!==n?(c=Ce.map(e=>{let t=we[e],o=e===r;return(0,X.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":o,id:`dreaming-settings-tab-${e}`,"aria-controls":`dreaming-settings-panel-${e}`,className:i(`inline-flex shrink-0 items-center gap-1.5 rounded-lg px-3 py-2 text-sm font-medium transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,D.press,o?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),onClick:()=>a(e),children:[(0,X.jsx)(t,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),(0,X.jsx)(`span`,{children:Ee(n,e)})]},e)}),t[3]=r,t[4]=a,t[5]=n,t[6]=c):c=t[6];let l;return t[7]!==n.tabsAriaLabel||t[8]!==s||t[9]!==c?(l=(0,X.jsx)(`nav`,{"aria-label":o,className:`-mx-1 flex gap-1 overflow-x-auto px-1 pb-1`,role:`tablist`,onKeyDown:s,children:c}),t[7]=n.tabsAriaLabel,t[8]=s,t[9]=c,t[10]=l):l=t[10],l}function Me(e){let t=(0,F.c)(18),{t:n,id:r,activeTab:i,children:a}=e;if(i!==r)return null;let o=`dreaming-settings-panel-${r}`,s=`dreaming-settings-tab-${r}`,c;t[0]!==r||t[1]!==n?(c=Ee(n,r),t[0]=r,t[1]=n,t[2]=c):c=t[2];let l;t[3]===c?l=t[4]:(l=(0,X.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:c}),t[3]=c,t[4]=l);let u;t[5]!==r||t[6]!==n?(u=De(n,r),t[5]=r,t[6]=n,t[7]=u):u=t[7];let d;t[8]===u?d=t[9]:(d=(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:u}),t[8]=u,t[9]=d);let f;t[10]!==l||t[11]!==d?(f=(0,X.jsxs)(`div`,{className:`mb-5`,children:[l,d]}),t[10]=l,t[11]=d,t[12]=f):f=t[12];let p;return t[13]!==a||t[14]!==o||t[15]!==s||t[16]!==f?(p=(0,X.jsxs)(`section`,{id:o,role:`tabpanel`,"aria-labelledby":s,className:`rounded-2xl border border-edge bg-surface-base px-4 py-5 sm:px-5`,children:[f,a]}),t[13]=a,t[14]=o,t[15]=s,t[16]=f,t[17]=p):p=t[17],p}export{Ae as DreamingSettingsPanel};
|
|
@@ -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{t as i}from"./messages-Csef1aW7.js";import{t as a}from"./locale-store-DjbfSsfA.js";import{Dr as o}from"./index-COkF54xv.js";var s=n(),c=e(t(),1),l=r(),u=`xopc.extensionUiGrants.v1`;function d(){let e=(0,s.c)(59),t=a(h),n;e[0]===t?n=e[1]:(n=i(t),e[0]=t,e[1]=n);let r=n.extensionDebug,u=o(),[d,_]=(0,c.useState)(m),v;e[2]===u?v=e[3]:(v=u.toSorted(p),e[2]=u,e[3]=v);let y=v,b;e[4]===r.title?b=e[5]:(b=(0,l.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:r.title}),e[4]=r.title,e[5]=b);let x;e[6]===r.subtitle?x=e[7]:(x=(0,l.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r.subtitle}),e[6]=r.subtitle,e[7]=x);let S;e[8]!==b||e[9]!==x?(S=(0,l.jsxs)(`div`,{children:[b,x]}),e[8]=b,e[9]=x,e[10]=S):S=e[10];let C;e[11]===r.grantsHeading?C=e[12]:(C=(0,l.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:r.grantsHeading}),e[11]=r.grantsHeading,e[12]=C);let w;e[13]===r.grantsHint?w=e[14]:(w=(0,l.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:r.grantsHint}),e[13]=r.grantsHint,e[14]=w);let T;e[15]===d?T=e[16]:(T=(0,l.jsx)(`pre`,{className:`mt-3 max-h-48 overflow-auto rounded-lg border border-edge-subtle bg-surface-muted p-3 font-mono text-xs text-fg`,children:d}),e[15]=d,e[16]=T);let E;e[17]===Symbol.for(`react.memo_cache_sentinel`)?(E=()=>_(g()),e[17]=E):E=e[17];let D;e[18]===r.refresh?D=e[19]:(D=(0,l.jsx)(`button`,{type:`button`,className:`mt-3 rounded-lg border border-edge px-3 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover`,onClick:E,children:r.refresh}),e[18]=r.refresh,e[19]=D);let O;e[20]!==C||e[21]!==w||e[22]!==T||e[23]!==D?(O=(0,l.jsxs)(`section`,{className:`rounded-xl border border-edge bg-surface-base p-4`,children:[C,w,T,D]}),e[20]=C,e[21]=w,e[22]=T,e[23]=D,e[24]=O):O=e[24];let k;e[25]===r.listHeading?k=e[26]:(k=(0,l.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:r.listHeading}),e[25]=r.listHeading,e[26]=k);let A;e[27]===r.colId?A=e[28]:(A=(0,l.jsx)(`th`,{className:`py-2 pr-2`,children:r.colId}),e[27]=r.colId,e[28]=A);let j;e[29]===r.colName?j=e[30]:(j=(0,l.jsx)(`th`,{className:`py-2 pr-2`,children:r.colName}),e[29]=r.colName,e[30]=j);let M;e[31]===r.colPermissions?M=e[32]:(M=(0,l.jsx)(`th`,{className:`py-2`,children:r.colPermissions}),e[31]=r.colPermissions,e[32]=M);let N;e[33]!==A||e[34]!==j||e[35]!==M?(N=(0,l.jsx)(`thead`,{children:(0,l.jsxs)(`tr`,{className:`border-b border-edge text-xs uppercase text-fg-muted`,children:[A,j,M]})}),e[33]=A,e[34]=j,e[35]=M,e[36]=N):N=e[36];let P;e[37]===y?P=e[38]:(P=y.map(f),e[37]=y,e[38]=P);let F;e[39]===P?F=e[40]:(F=(0,l.jsx)(`tbody`,{children:P}),e[39]=P,e[40]=F);let I;e[41]!==N||e[42]!==F?(I=(0,l.jsx)(`div`,{className:`mt-3 overflow-x-auto`,children:(0,l.jsxs)(`table`,{className:`w-full min-w-[32rem] border-collapse text-left text-sm`,children:[N,F]})}),e[41]=N,e[42]=F,e[43]=I):I=e[43];let L;e[44]!==k||e[45]!==I?(L=(0,l.jsxs)(`section`,{className:`rounded-xl border border-edge bg-surface-base p-4`,children:[k,I]}),e[44]=k,e[45]=I,e[46]=L):L=e[46];let R;e[47]===r.futureHeading?R=e[48]:(R=(0,l.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:r.futureHeading}),e[47]=r.futureHeading,e[48]=R);let z;e[49]===r.futureBody?z=e[50]:(z=(0,l.jsx)(`p`,{className:`mt-2`,children:r.futureBody}),e[49]=r.futureBody,e[50]=z);let B;e[51]!==R||e[52]!==z?(B=(0,l.jsxs)(`section`,{className:`rounded-xl border border-dashed border-edge-subtle bg-surface-muted/50 p-4 text-sm text-fg-muted`,children:[R,z]}),e[51]=R,e[52]=z,e[53]=B):B=e[53];let V;return e[54]!==O||e[55]!==L||e[56]!==B||e[57]!==S?(V=(0,l.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-8`,children:[S,O,L,B]}),e[54]=O,e[55]=L,e[56]=B,e[57]=S,e[58]=V):V=e[58],V}function f(e){return(0,l.jsxs)(`tr`,{className:`border-b border-edge-subtle`,children:[(0,l.jsx)(`td`,{className:`py-2 pr-2 font-mono text-xs text-fg`,children:e.id}),(0,l.jsx)(`td`,{className:`py-2 pr-2 text-fg`,children:e.name}),(0,l.jsx)(`td`,{className:`py-2 font-mono text-xs text-fg-muted`,children:(e.ui?.permissions??[]).join(`, `)||`—`})]},e.id)}function p(e,t){return e.id.localeCompare(t.id)}function m(){return g()}function h(e){return e.language}function g(){try{let e=localStorage.getItem(u);if(!e)return`{}`;let t=JSON.parse(e);return JSON.stringify(t,null,2)}catch(e){return e instanceof Error?e.message:String(e)}}export{d as ExtensionDebugPage};
|
package/dist/gateway/static/root/assets/{extension-page-W1wiG38F.js → extension-page-BSPNL90V.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{
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{Ar as i,Dr as a,Es as o,b as s,ii as c}from"./index-COkF54xv.js";var l=n(),u=e(t(),1),d=r();function f(){let e=(0,l.c)(26),{extensionId:t,pageId:n}=o(),r=a(),f=c(m),g=c(p),_,v,y;e[0]!==t||e[1]!==r||e[2]!==n?(_=t?r.find(e=>e.id===t&&i(e)):void 0,v=_?.ui?.contributions?.pages,y=t&&v?.length?n?v.find(e=>e.id===n||e.id===`${t}.${n}`):v[0]:void 0,e[0]=t,e[1]=r,e[2]=n,e[3]=_,e[4]=v,e[5]=y):(_=e[3],v=e[4],y=e[5]);let b=y,x,S;if(e[6]!==g||e[7]!==_||e[8]!==t||e[9]!==b||e[10]!==f?(x=()=>{if(!t||!_||!b)return g(),()=>g();let e=b.title?.trim()||_.name||t;return f({startExtra:null,main:(0,d.jsx)(`div`,{className:`w-full min-w-0 px-3 sm:px-5 xl:px-6`,children:(0,d.jsx)(`h1`,{className:`min-w-0 truncate text-base font-semibold tracking-tight text-fg`,title:e,children:e})}),end:null}),()=>g()},S=[g,_,t,b,f],e[6]=g,e[7]=_,e[8]=t,e[9]=b,e[10]=f,e[11]=x,e[12]=S):(x=e[11],S=e[12]),(0,u.useLayoutEffect)(x,S),!t){let t;return e[13]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,d.jsx)(h,{message:`No extension ID provided.`}),e[13]=t):t=e[13],t}if(!_){let n=`Extension "${t}" not found or has no UI.`,r;return e[14]===n?r=e[15]:(r=(0,d.jsx)(h,{message:n}),e[14]=n,e[15]=r),r}if(!v?.length){let n=`Extension "${t}" has no page contributions.`,r;return e[16]===n?r=e[17]:(r=(0,d.jsx)(h,{message:n}),e[16]=n,e[17]=r),r}if(!b){let r=`Page "${n}" not found in extension "${t}".`,i;return e[18]===r?i=e[19]:(i=(0,d.jsx)(h,{message:r}),e[18]=r,e[19]=i),i}let C=_.ui?.permissions,w;return e[20]!==_.name||e[21]!==t||e[22]!==b.entrypoint||e[23]!==b.title||e[24]!==C?(w=(0,d.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,d.jsx)(s,{extensionId:t,extensionName:_.name,entrypoint:b.entrypoint,permissions:C,title:b.title,className:`min-h-0 flex-1`,fixedHeight:void 0,maxHeight:99999})}),e[20]=_.name,e[21]=t,e[22]=b.entrypoint,e[23]=b.title,e[24]=C,e[25]=w):w=e[25],w}function p(e){return e.clearPageHeader}function m(e){return e.setPageHeader}function h(e){let t=(0,l.c)(2),{message:n}=e,r;return t[0]===n?r=t[1]:(r=(0,d.jsx)(`div`,{className:`flex min-h-[min(40vh,16rem)] flex-1 items-center justify-center`,children:(0,d.jsx)(`div`,{className:`text-center`,children:(0,d.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n})})}),t[0]=n,t[1]=r),r}export{f as ExtensionPage};
|
|
@@ -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{t as i}from"./cn-JdwAhgNB.js";import{t as a}from"./messages-Csef1aW7.js";import{t as o}from"./locale-store-DjbfSsfA.js";import{c as s,i as c,n as l,t as u}from"./fetch-Bs7in_4F.js";import{i as d}from"./vendor-swr-BIWyz7Rc.js";import{Di as f,Dr as p,Es as m,Oi as h,Ss as g,Ti as _,b as v,ki as y,qa as b}from"./index-COkF54xv.js";import{a as x,c as S,d as C,i as w,l as T,s as E,t as D,u as O}from"./voice-api-key-field-BnDDb6qO.js";import{t as k}from"./schema-form-CDPzua9q.js";var A=n(),j=e(t(),1),M=r(),N=()=>c(C);function P(e){return{credentialsIntro:e.credentialsIntro,regionHint:e.regionHint,endpointPresetsHint:e.endpointPresetsHint,apiKeyLabel:e.apiKeyLabel,optionalPlaceholder:e.optionalPlaceholder,regionLabel:e.regionLabel,baseUrlLabel:e.baseUrlLabel,imageBaseUrlLabel:e.imageBaseUrlLabel,saveCredentials:e.saveCredentials,savingCredentials:e.savingCredentials,credentialsSaved:e.credentialsSaved,discardCredentials:e.discardCredentials,credentialsNothingToSave:e.credentialsNothingToSave,credentialsSaveError:e.credentialsSaveError,regionPresetDefault:e.regionPresetDefault,regionPresetCustom:e.regionPresetCustom,baseUrlPresetDefault:e.baseUrlPresetDefault,baseUrlPresetCustom:e.baseUrlPresetCustom,openExtensionSettings:e.openExtensionSettings,openImageModelsPage:e.openImageModelsPage,extensionSettingsLinkTitle:e.extensionSettingsLinkTitle,imageModelsLinkTitle:e.imageModelsLinkTitle,configured:e.configured,missingKey:e.missingKey,unsavedChanges:e.unsavedChanges,expandProvider:e.expandProvider,collapseProvider:e.collapseProvider,defaultModel:e.defaultModel,modelsLabel:e.modelsLabel,modelCountOne:e.modelCountOne,modelCountMany:e.modelCountMany,imageBaseUrlPresetHint:e.imageBaseUrlPresetHint,dashscopeRegion_beijing:e.dashscopeRegion_beijing,dashscopeRegion_singapore:e.dashscopeRegion_singapore,dashscopeRegion_us:e.dashscopeRegion_us,apiKeyMaskedHelp:e.apiKeyMaskedHelp,apiKeyCopy:e.apiKeyCopy,apiKeyCopied:e.apiKeyCopied,apiKeyShow:e.apiKeyShow,apiKeyHide:e.apiKeyHide,apiKeyNotInConfigFile:e.apiKeyNotInConfigFile,apiKeyRevealFailed:e.apiKeyRevealFailed,minimaxClusterLabel:e.minimaxClusterLabel,minimaxClusterHint:e.minimaxClusterHint,falQueueBaseLabel:e.falQueueBaseLabel,falQueueBaseHint:e.falQueueBaseHint}}function F(e){let t=(0,A.c)(40),{extensionId:n}=e,r=o(L),i;t[0]===r?i=t[1]:(i=a(r),t[0]=r,t[1]=i);let c=i,l=c.imageModelsSettings,u=s(I),f;t[2]===u?f=t[3]:(f=u?N():null,t[2]=u,t[3]=f);let p;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(p={revalidateOnFocus:!1},t[4]=p):p=t[4];let{data:m,isLoading:h}=d(f,O,p),g;t[5]===m?g=t[6]:(g=m===void 0?[]:m,t[5]=m,t[6]=g);let _=g,v;if(t[7]!==_||t[8]!==n){let e;t[10]===n?e=t[11]:(e=e=>e.id===n,t[10]=n,t[11]=e),v=_.filter(e),t[7]=_,t[8]=n,t[9]=v}else v=t[9];let y=v,x=S(y),C;t[12]===l?C=t[13]:(C=P(l),t[12]=l,t[13]=C);let w=C,E;t[14]!==c.providersSettings.getApiKey||t[15]!==c.providersSettings.getApiKeyCn||t[16]!==c.providersSettings.getApiKeyIntl?(E={getApiKey:c.providersSettings.getApiKey,getApiKeyIntl:c.providersSettings.getApiKeyIntl,getApiKeyCn:c.providersSettings.getApiKeyCn},t[14]=c.providersSettings.getApiKey,t[15]=c.providersSettings.getApiKeyCn,t[16]=c.providersSettings.getApiKeyIntl,t[17]=E):E=t[17];let D=E;if(!u)return null;if(h){let e;return t[18]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,M.jsxs)(`div`,{className:`flex items-center gap-2 py-6 text-sm text-fg-muted`,children:[(0,M.jsx)(b,{className:`size-4 animate-spin`}),`…`]}),t[18]=e):e=t[18],e}if(y.length===0){let e=r===`zh`?`网关未注册该图像 Provider,或扩展已被禁用。`:`This image provider is not registered on the gateway, or the extension is disabled.`,n;return t[19]===e?n=t[20]:(n=(0,M.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e}),t[19]=e,t[20]=n),n}let k;t[21]!==x||t[22]!==l.credentialsSaveError?(k=()=>void x.saveCredentials(l.credentialsSaveError),t[21]=x,t[22]=l.credentialsSaveError,t[23]=k):k=t[23];let j;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(j=new Set,t[24]=j):j=t[24];let F;return t[25]!==D||t[26]!==x.credBaseline||t[27]!==x.credDirty||t[28]!==x.credDraft||t[29]!==x.credError||t[30]!==x.credNoopFlash||t[31]!==x.credSavedFlash||t[32]!==x.credSaving||t[33]!==x.onDiscardCredentials||t[34]!==x.updateCredRow||t[35]!==r||t[36]!==w||t[37]!==y||t[38]!==k?(F=(0,M.jsx)(T,{summaries:y,credDraft:x.credDraft,credBaseline:x.credBaseline,credDirty:x.credDirty,credSaving:x.credSaving,credError:x.credError,credSavedFlash:x.credSavedFlash,credNoopFlash:x.credNoopFlash,updateCredRow:x.updateCredRow,onDiscardCredentials:x.onDiscardCredentials,onSaveCredentials:k,extensionIds:j,showExtensionLinks:!1,showImageModelsLink:!1,language:r,apiKeyLinkLabels:D,messages:w}),t[25]=D,t[26]=x.credBaseline,t[27]=x.credDirty,t[28]=x.credDraft,t[29]=x.credError,t[30]=x.credNoopFlash,t[31]=x.credSavedFlash,t[32]=x.credSaving,t[33]=x.onDiscardCredentials,t[34]=x.updateCredRow,t[35]=r,t[36]=w,t[37]=y,t[38]=k,t[39]=F):F=t[39],F}function I(e){return!!e.token}function L(e){return e.language}function R(e){let t=(0,A.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,M.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=r),r}var z=[{id:`whisper-large-v3-turbo`,name:`Whisper Large v3 Turbo`},{id:`whisper-large-v3`,name:`Whisper Large v3`}];function B(e){let t=e?.manifest?.mediaUnderstandingProviders?.[0];if(typeof t==`string`&&t.trim())return t.trim();let n=e?.manifest?.contracts?.mediaUnderstandingProviders?.[0];if(typeof n==`string`&&n.trim())return n.trim()}function V(){return i(f,_)}function H(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,h,`dark:border-edge`)}function U(e,t){if(!e||!t)return{apiKey:``,model:z[0].id};if(t===`alibaba`)return{apiKey:e.stt.alibaba?.apiKey??``,model:e.stt.alibaba?.model??`paraformer-v2`};if(t===`openai`)return{apiKey:e.stt.openai?.apiKey??``,model:e.stt.openai?.model??`whisper-1`};let n=e.stt.providers?.[t];return{apiKey:typeof n?.apiKey==`string`?n.apiKey:``,model:typeof n?.model==`string`?n.model:z[0].id}}function W({providerId:e,voiceSettings:t,mutateVoice:n}){let r=a(o(e=>e.language)),s=r.voiceSettings,l=r.extensionSttMedia,u={maskedHelp:s.apiKeyMaskedHelp,copy:s.apiKeyCopy,copied:s.apiKeyCopied,show:s.apiKeyShow,hide:s.apiKeyHide,notInConfigFile:s.apiKeyNotInConfigFile,loadFailed:s.apiKeyRevealFailed},{data:f}=d(c(`/api/voice/stt-providers`),x,{revalidateOnFocus:!1}),p=(0,j.useMemo)(()=>f?.providers.some(t=>t.id===e&&t.configured)??!1,[e,f]),m=(0,j.useMemo)(()=>U(t,e),[e,t]),h=(0,j.useRef)(!1),[g,v]=(0,j.useState)(null),[b,S]=(0,j.useState)(!1),[C,w]=(0,j.useState)(null),[T,O]=(0,j.useState)(!1),k=g??m,A=m,N=k.apiKey!==A.apiKey||k.model!==A.model,P=(0,j.useCallback)(async()=>{S(!0),w(null);try{let r=structuredClone(t);r.stt.enabled=!0,e===`alibaba`?(r.stt.provider=`alibaba`,r.stt.alibaba={...r.stt.alibaba,apiKey:k.apiKey,model:k.model}):e===`openai`?(r.stt.provider=`openai`,r.stt.openai={...r.stt.openai,apiKey:k.apiKey,model:k.model}):(r.stt.providers={...r.stt.providers??{},[e]:{...r.stt.providers?.[e]??{},apiKey:k.apiKey,model:k.model}},(!r.stt.provider||r.stt.provider===`alibaba`||r.stt.provider===`openai`)&&(r.stt.provider=e)),await E(r),await n(r,!1),h.current=!1,v(null),O(!0),window.setTimeout(()=>O(!1),2500)}catch(e){w(e instanceof Error?e.message:String(e))}finally{S(!1)}},[k.apiKey,k.model,n,e,t]),F=e===`groq`?z:[{id:k.model,name:k.model}];return(0,M.jsxs)(`div`,{className:`flex flex-col gap-4 rounded-xl border border-edge bg-surface-base p-4`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:l.credentialsTitle}),(0,M.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:l.credentialsHint.replace(`{providerId}`,e)})]}),(0,M.jsx)(`span`,{className:i(`rounded-full px-2 py-0.5 text-xs font-medium`,p?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-amber-500/10 text-amber-800 dark:text-amber-200`),children:p?l.configured:l.notConfigured})]}),(0,M.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,M.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,_),children:[(0,M.jsx)(R,{children:s.stt.apiKey}),(0,M.jsx)(D,{kind:`stt`,providerId:e,fieldId:`ext-stt-${e}-api-key`,value:k.apiKey,onChange:e=>{h.current=!0,v(t=>({...t??m,apiKey:e})),w(null)},labels:u,placeholder:e===`groq`?`gsk_...`:`sk-...`}),(0,M.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[s.stt.apiKeyDesc,e===`groq`?` (GROQ_API_KEY)`:``]})]}),(0,M.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,_),children:[(0,M.jsx)(R,{children:s.stt.model}),e===`groq`?(0,M.jsx)(`select`,{className:V(),value:k.model,onChange:e=>{h.current=!0,v(t=>({...t??m,model:e.target.value})),w(null)},children:F.map(e=>(0,M.jsx)(`option`,{value:e.id,children:e.name},e.id))}):(0,M.jsx)(`input`,{className:H(),value:k.model,onChange:e=>{h.current=!0,v(t=>({...t??m,model:e.target.value})),w(null)}})]})]}),(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[T?(0,M.jsx)(`span`,{className:`text-xs text-emerald-600 dark:text-emerald-400`,children:s.saved}):null,C?(0,M.jsx)(`span`,{className:`text-xs text-red-600 dark:text-red-400`,children:C}):null,(0,M.jsx)(y,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,disabled:!N||b,onClick:()=>{h.current=!1,v(null),w(null)},children:s.discard}),(0,M.jsx)(y,{type:`button`,variant:`primary`,className:`h-8 text-xs`,disabled:!N||b,onClick:()=>void P(),children:b?s.saving:s.save})]})]})}function G(e){let t=(0,A.c)(13),{extensionId:n}=e,r=o(q),i=s(K),a;t[0]===n?a=t[1]:(a=()=>l(c(`/api/extensions/${encodeURIComponent(n)}`)),t[0]=n,t[1]=a);let{data:u,isLoading:f}=d(i&&n?`ext-stt-detail-${n}`:null,a),p;t[2]===u?p=t[3]:(p=B(u),t[2]=u,t[3]=p);let m=p,h;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(h={revalidateOnFocus:!1},t[4]=h):h=t[4];let{data:g,mutate:_,isLoading:v}=d(i?`voice-settings-ext-stt`:null,w,h);if(!i)return null;if(f||v){let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,M.jsxs)(`div`,{className:`flex items-center gap-2 py-6 text-sm text-fg-muted`,children:[(0,M.jsx)(b,{className:`size-4 animate-spin`}),`…`]}),t[5]=e):e=t[5],e}if(!m){let e=r===`zh`?`该扩展未声明 mediaUnderstandingProviders。`:`This extension does not declare mediaUnderstandingProviders.`,n;return t[6]===e?n=t[7]:(n=(0,M.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e}),t[6]=e,t[7]=n),n}if(!g)return null;let y=`${n}:${m}`,x;return t[8]!==_||t[9]!==m||t[10]!==y||t[11]!==g?(x=(0,M.jsx)(W,{providerId:m,voiceSettings:g,mutateVoice:_},y),t[8]=_,t[9]=m,t[10]=y,t[11]=g,t[12]=x):x=t[12],x}function K(e){return!!e.token}function q(e){return e.language}function J(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Y(e){let t={};if(e.type!==`object`||!J(e.properties))return t;for(let[n,r]of Object.entries(e.properties))J(r)&&Object.prototype.hasOwnProperty.call(r,`default`)&&(t[n]=r.default);return t}function X(e,t){switch(t.type){case`sync`:return{...e,localValues:t.value,isDirty:!1,saveError:null};case`change`:return{...e,localValues:t.value,isDirty:!0,saveError:null,saveSuccess:!1};case`discard`:return{...e,localValues:t.value,isDirty:!1,saveError:null};case`reset-defaults`:return{...e,localValues:t.value,isDirty:!0,saveError:null,saveSuccess:!1};case`save-start`:return{...e,saving:!0,saveError:null};case`save-success`:return{...e,localValues:t.value,isDirty:!1,saving:!1,saveSuccess:!0,saveError:null};case`save-error`:return{...e,saving:!1,saveError:t.message}}}function Z({extensionId:e}){let t=a(o(e=>e.language)).agentSettings,n=s(e=>!!e.token),{data:r,error:i}=d(n&&e?`ext-detail-${e}`:null,()=>l(c(`/api/extensions/${encodeURIComponent(e)}`))),{data:f,mutate:p,error:m}=d(n&&e?`ext-cfg-${e}`:null,()=>l(c(`/api/extensions/${encodeURIComponent(e)}/config`))),h=r?.manifest?.configSchema,g=(0,j.useMemo)(()=>h&&h.type===`object`?Y(h):{},[h]),_=(0,j.useMemo)(()=>({...g,...f??{}}),[g,f]),[v,b]=(0,j.useReducer)(X,{localValues:{},isDirty:!1,saving:!1,saveError:null,saveSuccess:!1}),[x,S]=(0,j.useState)(!1),C=(0,j.useRef)(!1),w=(0,j.useRef)(_);!C.current&&w.current!==_&&(w.current=_,b({type:`sync`,value:_}));let T=(0,j.useCallback)(e=>{C.current=!0,b({type:`change`,value:e})},[]),E=(0,j.useCallback)(()=>{C.current=!1,b({type:`discard`,value:_})},[_]),D=(0,j.useCallback)(()=>{!h||h.type!==`object`||(C.current=!0,b({type:`reset-defaults`,value:{...Y(h)}}))},[h]),O=(0,j.useCallback)(async()=>{if(e){b({type:`save-start`});try{let t=await u(c(`/api/extensions/${encodeURIComponent(e)}/config`),{method:`PATCH`,body:JSON.stringify(v.localValues)});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}await p(v.localValues,!1),C.current=!1,b({type:`save-success`,value:v.localValues}),S(!0),window.setTimeout(()=>S(!1),3e3)}catch(e){b({type:`save-error`,message:e instanceof Error?e.message:String(e)})}}},[v.localValues,e,p]);if(!n)return null;if(i||m){let e=i??m;return(0,M.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[`Could not load extension settings: `,e instanceof Error?e.message:String(e)]})}return!h||h.type!==`object`?null:(0,M.jsxs)(`div`,{className:`mb-6 flex flex-col gap-3 rounded-xl border border-edge bg-surface-base p-4`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,M.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Configuration`}),(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[x?(0,M.jsx)(`span`,{className:`text-xs text-emerald-600 dark:text-emerald-400`,children:t.saved}):null,v.saveError?(0,M.jsx)(`span`,{className:`text-xs text-red-600 dark:text-red-400`,children:v.saveError}):null,(0,M.jsx)(y,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,disabled:!v.isDirty,onClick:E,children:t.discard}),(0,M.jsx)(y,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,onClick:D,children:`Reset to defaults`}),(0,M.jsx)(y,{type:`button`,variant:`primary`,className:`h-8 text-xs`,disabled:!v.isDirty||v.saving,onClick:()=>void O(),children:v.saving?t.saving:t.save})]})]}),(0,M.jsx)(k,{schema:h,values:v.localValues,onChange:T,disabled:v.saving})]})}function Q(){let e=(0,A.c)(47),t=o(ee),n;e[0]===t?n=e[1]:(n=a(t),e[0]=t,e[1]=n);let r=n,i=r.extensionImageGen,s=r.extensionSttMedia,{extensionId:c,panelId:l}=m(),u=p();if(!c){let t;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,M.jsx)($,{message:`No extension ID provided.`}),e[2]=t):t=e[2],t}let d,f,h;if(e[3]!==c||e[4]!==u||e[5]!==l){h=Symbol.for(`react.early_return_sentinel`);bb0:{let t;if(e[9]===c?t=e[10]:(t=e=>e.id===c,e[9]=c,e[10]=t),d=u.find(t),!d){let t=`Extension "${c}" not found or is not available in this workspace.`,n;e[11]===t?n=e[12]:(n=(0,M.jsx)($,{message:t}),e[11]=t,e[12]=n),h=n;break bb0}let n=d.ui?.contributions?.settingsPanels;f=l?n?.find(e=>e.id===l||e.id===`${c}.${l}`):n?.[0]}e[3]=c,e[4]=u,e[5]=l,e[6]=d,e[7]=f,e[8]=h}else d=e[6],f=e[7],h=e[8];if(h!==Symbol.for(`react.early_return_sentinel`))return h;let _=f,y=!!(_&&d.ui),b=!!d.hasConfigSchema,x=d.kind===`image-generation`,S=d.kind===`media-provider`;if(!b&&!y&&!(x||S)){let t=`Extension "${c}" has no settings panels or config schema.`,n;return e[13]===t?n=e[14]:(n=(0,M.jsx)($,{message:t}),e[13]=t,e[14]=n),n}let C=_?.title??`${d.name} Settings`,w;e[15]===C?w=e[16]:(w=(0,M.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:C}),e[15]=C,e[16]=w);let T;e[17]!==x||e[18]!==r.imageModelsSettings||e[19]!==i?(T=x?(0,M.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-base px-4 py-3 text-sm`,children:[(0,M.jsx)(`p`,{className:`leading-relaxed text-fg-muted`,children:i.banner}),(0,M.jsx)(g,{to:`/settings/credentials?tab=image-models`,className:`w-fit font-medium text-accent hover:underline`,title:r.imageModelsSettings.imageModelsLinkTitle,children:i.openImageModels})]}):null,e[17]=x,e[18]=r.imageModelsSettings,e[19]=i,e[20]=T):T=e[20];let E;e[21]!==c||e[22]!==x?(E=x?(0,M.jsx)(F,{extensionId:c}):null,e[21]=c,e[22]=x,e[23]=E):E=e[23];let D;e[24]!==S||e[25]!==s?(D=S?(0,M.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-base px-4 py-3 text-sm`,children:[(0,M.jsx)(`p`,{className:`leading-relaxed text-fg-muted`,children:s.banner}),(0,M.jsx)(g,{to:`/settings/credentials?tab=voice`,className:`w-fit font-medium text-accent hover:underline`,children:s.openVoice})]}):null,e[24]=S,e[25]=s,e[26]=D):D=e[26];let O;e[27]!==c||e[28]!==S?(O=S?(0,M.jsx)(G,{extensionId:c}):null,e[27]=c,e[28]=S,e[29]=O):O=e[29];let k;e[30]!==c||e[31]!==b?(k=b?(0,M.jsx)(Z,{extensionId:c}):null,e[30]=c,e[31]=b,e[32]=k):k=e[32];let j;e[33]!==d.name||e[34]!==d.ui||e[35]!==c||e[36]!==y||e[37]!==_?(j=y&&_&&d.ui?(0,M.jsx)(`div`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-base`,children:(0,M.jsx)(v,{extensionId:c,extensionName:d.name,entrypoint:_.entrypoint,permissions:d.ui?.permissions,title:_.title,className:`w-full`,minHeight:120,maxHeight:2e3})}):null,e[33]=d.name,e[34]=d.ui,e[35]=c,e[36]=y,e[37]=_,e[38]=j):j=e[38];let N;return e[39]!==w||e[40]!==T||e[41]!==E||e[42]!==D||e[43]!==O||e[44]!==k||e[45]!==j?(N=(0,M.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:[w,T,E,D,O,k,j]}),e[39]=w,e[40]=T,e[41]=E,e[42]=D,e[43]=O,e[44]=k,e[45]=j,e[46]=N):N=e[46],N}function ee(e){return e.language}function $(e){let t=(0,A.c)(2),{message:n}=e,r;return t[0]===n?r=t[1]:(r=(0,M.jsx)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:(0,M.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n})}),t[0]=n,t[1]=r),r}export{Q as ExtensionSettingsPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./messages-Csef1aW7.js";import{a as t,i as n,n as r,s as i,t as a}from"./locale-store-DjbfSsfA.js";var o=i((e,n)=>({baseUrl:typeof window<`u`?window.location.origin:``,token:void 0,tokenDialogOpen:!1,tokenExpired:!1,setGatewayToken:n=>{t(n),e({token:n,tokenDialogOpen:!1,tokenExpired:!1}),window.dispatchEvent(new CustomEvent(`token-saved`,{detail:{token:n}}))},clearGatewayToken:()=>{r(),e({token:void 0})},openTokenDialog:()=>e({tokenDialogOpen:!0}),closeTokenDialog:()=>e({tokenDialogOpen:!1}),onUnauthorized:()=>{n().clearGatewayToken(),e({tokenDialogOpen:!1,tokenExpired:!0}),window.dispatchEvent(new CustomEvent(`token-expired`))}}));function s(){let e=new URLSearchParams(window.location.search).get(`token`);if(e){o.getState().setGatewayToken(e);let t=window.location.pathname+window.location.hash,n=window.history.state,r=n&&typeof n==`object`&&!Array.isArray(n)?{...n}:n;window.history.replaceState(r,``,t);return}let t=n();o.setState({token:t||void 0,tokenDialogOpen:!1})}function c(){return window.location.origin}function l(e){let t=e.startsWith(`/`)?e:`/${e}`;return`${c()}${t}`}function u(e){let t=e.baseUrl.trim().replace(/\/+$/,``),n=new URL(`xopc://gateway/mobile-connect`);return n.searchParams.set(`baseUrl`,t),e.lanUrl?.trim()&&n.searchParams.set(`lanUrl`,e.lanUrl.trim().replace(/\/+$/,``)),n.searchParams.set(`ps`,e.pairingSecret),n.toString()}function d(e){try{let t=new URL(e.trim());if(t.protocol!==`http:`&&t.protocol!==`https:`)return!1;let n=t.hostname.toLowerCase();return!!(n===`localhost`||n===`127.0.0.1`||n===`[::1]`||n===`::1`||/^127\.\d+\.\d+\.\d+$/.test(n))}catch{return!1}}function f(){return a.getState().language}function p(e,t,n){let r=e.trim().toLowerCase();return!!(!r||r===`http ${t}`||n&&r===n.trim().toLowerCase()||t===500&&r===`internal server error`)}function m(t,n,r){let i=r?.trim()??``;if(i&&!p(i,t,n))return i;let a=e(f()).api;return t>=500?t===502?a.errorBadGateway:t===503?a.errorServiceUnavailable:t===504?a.errorGatewayTimeout:t===500?a.errorInternal:a.errorServer.replace(`{{status}}`,String(t)):t===404?a.errorNotFound:t===403?a.errorForbidden:a.errorRequest.replace(`{{status}}`,String(t))}var h=null,g=null;function _(){h||=new Promise(e=>{g=e})}function v(){h&&(g?.(),h=null,g=null)}typeof window<`u`&&window.addEventListener(`token-saved`,v);async function y(e,t){h&&await h;let n=o.getState().token,r=new Headers(t?.headers),i=t?.body,a=typeof FormData<`u`&&i instanceof FormData;!r.has(`Content-Type`)&&!a&&r.set(`Content-Type`,`application/json`),n&&r.set(`Authorization`,`Bearer ${n}`);let s=await fetch(e,{...t,headers:r});return s.status===401&&(_(),o.getState().onUnauthorized()),s}async function b(e,t){let n=await y(e,t);if(!n.ok){let e=await n.json().catch(()=>({})),t=typeof e.error==`string`?e.error:e.error?.message,r=m(n.status,n.statusText,t);throw Error(r)}return n.json()}export{u as a,o as c,l as i,b as n,d as o,m as r,s,y as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./interval-presets-B29Ss_2y.js";function t(e,t){switch(e){case 3e4:return t.every30s;case 6e4:return t.every1min;case 3e5:return t.every5min;case 6e5:return t.every10min;case 9e5:return t.every15min;case 18e5:return t.every30min;case 36e5:return t.every1h;case 72e5:return t.every2h;default:return null}}var n={second:new Intl.NumberFormat(`en-US`,{style:`unit`,unit:`second`,unitDisplay:`long`}),minute:new Intl.NumberFormat(`en-US`,{style:`unit`,unit:`minute`,unitDisplay:`long`}),hour:new Intl.NumberFormat(`en-US`,{style:`unit`,unit:`hour`,unitDisplay:`long`})},r={second:new Intl.NumberFormat(`zh-CN`,{style:`unit`,unit:`second`,unitDisplay:`long`}),minute:new Intl.NumberFormat(`zh-CN`,{style:`unit`,unit:`minute`,unitDisplay:`long`}),hour:new Intl.NumberFormat(`zh-CN`,{style:`unit`,unit:`hour`,unitDisplay:`long`})};function i(e,t){return e.startsWith(`zh`)?r[t]:n[t]}function a(n,r,a){let o=Math.max(1e3,Math.round(n));if(a&&e.has(o)){let e=t(o,a);if(e)return e}let s=Math.max(1,Math.round(o/1e3));if(s<120)return i(r,`second`).format(s);let c=Math.round(s/60);if(c<120)return i(r,`minute`).format(c);let l=Math.round(c/60);return i(r,`hour`).format(l)}export{a as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as e,n as t}from"./fetch-Bs7in_4F.js";import{yi as n,yr as r}from"./index-COkF54xv.js";var i=18790,a={enabled:!0,maxAttempts:5,windowMs:9e5,blockDurationMs:3e5,exemptLoopback:!0};function o(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function s(e){return n(e)}async function c(n){let r=await t(e(`/api/gateway/reveal-auth-secret/${encodeURIComponent(n)}`),{method:`POST`,body:`{}`});if(!r.ok||!r.payload)throw Error(r.error?.message??`Reveal failed`);return r.payload}async function l(){let n=await t(e(`/api/agents/browser/reveal-cloud-api-key`),{method:`POST`,headers:{"Content-Type":`application/json`},body:`{}`});if(!n.ok||!n.payload)throw Error(n.error?.message??`Reveal failed`);return n.payload}function u(e){return s(e)?``:e.trim()}function d(e){return[...e].map(e=>e.trim()).sort()}function f(e){return JSON.stringify({bind:e.bind,customBindHost:e.customBindHost.trim(),port:e.port,auth:{mode:e.auth.mode,token:u(e.auth.token),password:u(e.auth.password),rateLimit:e.auth.rateLimit,trustedProxy:{userHeader:e.auth.trustedProxy.userHeader.trim(),requiredHeaders:d(e.auth.trustedProxy.requiredHeaders),allowUsers:d(e.auth.trustedProxy.allowUsers),allowLoopback:e.auth.trustedProxy.allowLoopback}},corsOrigins:d(e.corsOrigins),trustedProxies:d(e.trustedProxies),allowRealIpFallback:e.allowRealIpFallback,dangerouslyAllowHostHeaderOriginFallback:e.dangerouslyAllowHostHeaderOriginFallback})}function p(e,t){return f(e)!==f(t)}function m(e){return e===`none`||e===`token`||e===`password`||e===`trusted-proxy`?e:`token`}function h(e){let t=o(e)?e:{};return{enabled:t.enabled!==!1,maxAttempts:typeof t.maxAttempts==`number`&&Number.isFinite(t.maxAttempts)?Math.max(1,Math.floor(t.maxAttempts)):a.maxAttempts,windowMs:typeof t.windowMs==`number`&&Number.isFinite(t.windowMs)&&t.windowMs>0?Math.floor(t.windowMs):a.windowMs,blockDurationMs:typeof t.blockDurationMs==`number`&&Number.isFinite(t.blockDurationMs)&&t.blockDurationMs>0?Math.floor(t.blockDurationMs):typeof t.lockoutMs==`number`&&Number.isFinite(t.lockoutMs)&&t.lockoutMs>0?Math.floor(t.lockoutMs):a.blockDurationMs,exemptLoopback:t.exemptLoopback!==!1}}function g(e){let t=o(e)?e:{};return{userHeader:typeof t.userHeader==`string`?t.userHeader:``,requiredHeaders:v(t.requiredHeaders,32),allowUsers:v(t.allowUsers,128),allowLoopback:t.allowLoopback===!0}}function _(e){return e===`auto`||e===`off`||e===`explicit`?e:`auto`}function v(e,t=24){return Array.isArray(e)?e.filter(e=>typeof e==`string`&&e.trim().length>0).map(e=>e.trim()).slice(0,t):[]}function y(e){return e===`auto`||e===`loopback`||e===`lan`||e===`tailnet`||e===`custom`?e:`loopback`}function b(e){if(e.bind===`loopback`)return!1;if(e.bind===`lan`)return!0;if(e.bind===`custom`){let t=e.customBindHost.trim().toLowerCase();return t?t!==`127.0.0.1`&&t!==`localhost`&&t!==`::1`:!0}return!0}function x(e){let t=b(e);return t&&e.auth.mode===`none`?`Network-accessible gateway requires authentication (token, password, or trusted-proxy).`:t&&e.auth.mode===`trusted-proxy`&&e.trustedProxies.length===0?`Trusted-proxy auth on a network bind requires at least one gateway.trustedProxies entry.`:e.auth.mode===`trusted-proxy`&&!e.auth.trustedProxy.userHeader.trim()?`Trusted-proxy auth requires gateway.auth.trustedProxy.userHeader.`:t&&e.corsOrigins.includes(`*`)?`CORS wildcard "*" is not allowed on network-accessible binds.`:e.bind===`custom`&&!e.customBindHost.trim()?`Custom bind mode requires a bind address.`:null}function S(e){let t=o(e)?e:{},n=o(t.gateway)?t.gateway:{},r=o(n.auth)?n.auth:{},a=o(n.security)?n.security:{},s=o(t.update)?t.update:{},c=o(s.auto)?s.auto:{},l=s.channel,u=l===`beta`||l===`dev`||l===`stable`?l:`stable`,d=Array.isArray(n.corsOrigins)?n.corsOrigins.filter(e=>typeof e==`string`&&e.trim().length>0):[];return{bind:y(n.bind),customBindHost:typeof n.customBindHost==`string`&&n.customBindHost.trim()?n.customBindHost.trim():``,port:typeof n.port==`number`&&Number.isFinite(n.port)?Math.floor(n.port):i,auth:{mode:m(r.mode),token:typeof r.token==`string`?r.token:``,password:typeof r.password==`string`?r.password:``,rateLimit:h(r.rateLimit),trustedProxy:g(r.trustedProxy)},corsOrigins:d,trustedProxies:v(n.trustedProxies,64),allowRealIpFallback:n.allowRealIpFallback===!0,dangerouslyAllowHostHeaderOriginFallback:n.dangerouslyAllowHostHeaderOriginFallback===!0,securityStrict:a.strict===!0,maxSseConnections:typeof n.maxSseConnections==`number`&&Number.isFinite(n.maxSseConnections)?Math.max(1,Math.floor(n.maxSseConnections)):100,channelConnectDeferMode:_(n.channelConnectDeferMode),channelConnectDeferIds:v(n.channelConnectDeferIds),channelConnectDeferSkipIds:v(n.channelConnectDeferSkipIds),updateChannel:u,updateCheckOnStart:s.checkOnStart!==!1,updateAutoEnabled:c.enabled===!0,updateAutoStableDelayHours:typeof c.stableDelayHours==`number`&&Number.isFinite(c.stableDelayHours)?Math.max(0,Math.floor(c.stableDelayHours)):6,updateAutoStableJitterHours:typeof c.stableJitterHours==`number`&&Number.isFinite(c.stableJitterHours)?Math.max(0,Math.floor(c.stableJitterHours)):12,updateAutoBetaCheckIntervalHours:typeof c.betaCheckIntervalHours==`number`&&Number.isFinite(c.betaCheckIntervalHours)?Math.max(.25,c.betaCheckIntervalHours):1}}function C(e){let t={mode:e.auth.mode,rateLimit:e.auth.rateLimit};if(e.auth.mode===`token`){let n=e.auth.token.trim();n.length>0&&!s(n)&&(t.token=e.auth.token),t.password=null,t.trustedProxy=null}else if(e.auth.mode===`password`){let n=e.auth.password.trim();n.length>0&&!s(n)&&(t.password=e.auth.password),t.token=null,t.trustedProxy=null}else if(e.auth.mode===`trusted-proxy`){t.token=null,t.password=null;let n=e.auth.trustedProxy;t.trustedProxy={userHeader:n.userHeader.trim(),...n.requiredHeaders.length>0?{requiredHeaders:n.requiredHeaders}:{},...n.allowUsers.length>0?{allowUsers:n.allowUsers}:{},...n.allowLoopback?{allowLoopback:!0}:{}}}else t.token=null,t.password=null,t.trustedProxy=null;return t}async function w(n){let i=x(n);if(i)throw Error(i);await t(e(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{bind:n.bind,...n.bind===`custom`?{customBindHost:n.customBindHost.trim()}:{},port:n.port,auth:C(n),corsOrigins:n.corsOrigins,trustedProxies:n.trustedProxies,allowRealIpFallback:n.allowRealIpFallback,dangerouslyAllowHostHeaderOriginFallback:n.dangerouslyAllowHostHeaderOriginFallback,security:{strict:n.securityStrict},maxSseConnections:n.maxSseConnections,channelConnectDeferMode:n.channelConnectDeferMode,channelConnectDeferIds:n.channelConnectDeferIds,channelConnectDeferSkipIds:n.channelConnectDeferSkipIds},update:{channel:n.updateChannel,checkOnStart:n.updateCheckOnStart,auto:{enabled:n.updateAutoEnabled,stableDelayHours:n.updateAutoStableDelayHours,stableJitterHours:n.updateAutoStableJitterHours,betaCheckIntervalHours:n.updateAutoBetaCheckIntervalHours}}})}),r()}export{c as a,l as i,S as n,x as o,w as r,p 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{t as i}from"./cn-JdwAhgNB.js";import{t as a}from"./messages-Csef1aW7.js";import{t as o}from"./locale-store-DjbfSsfA.js";import{c as s,i as c,n as l}from"./fetch-Bs7in_4F.js";import{r as u}from"./toast-z0toXu32.js";import{i as d,o as f}from"./vendor-swr-BIWyz7Rc.js";import{$o as p,B as m,Ds as h,La as g,Oi as _,Vi as v,Xt as y,aa as b,ba as x,br as S,co as C,gi as w,hi as T,ki as E,ko as D,li as O,oa as k,p as A,qa as j,sa as M,tn as N,uo as P,va as F,xi as I}from"./index-COkF54xv.js";import{t as L}from"./settings-advanced-gate-BYS-rpzn.js";import{n as ee,t as R}from"./settings-form-section-BsrK7TBF.js";import{r as te,s as ne}from"./use-settings-tab-guard-F6C0mpJt.js";import{a as re,n as ie,o as ae,r as oe,t as se}from"./gateway-config-api-Clfck-hW.js";var z=e(t(),1),B=n(),V={critical:3,warn:2,info:1};function H(){return c(`/api/doctor?security=true`)}function ce(e){return e.toSorted((e,t)=>V[t.severity]-V[e.severity]||e.checkId.localeCompare(t.checkId))}function U(e){let t=e?.checks?.find(e=>e.id===`security-audit`);if(!t)return{status:`skip`,message:`Security audit unavailable.`,hints:[],findings:[]};let n=ce((t.findings??[]).filter(e=>typeof e.checkId==`string`&&(e.severity===`critical`||e.severity===`warn`||e.severity===`info`)&&typeof e.title==`string`&&typeof e.detail==`string`));return{status:t.status,message:t.message,hints:Array.isArray(t.hints)?t.hints.filter(e=>typeof e==`string`):[],findings:n}}async function le(){return U(await l(H()))}var W=r();function ue(e){let t=(0,B.c)(40),{enabled:n,refreshToken:r}=e,i=r===void 0?0:r,s=o(K),c;t[0]===s?c=t[1]:(c=a(s),t[0]=s,t[1]=c);let l=c.gatewaySettings,u;t[2]!==n||t[3]!==i?(u=n?[H(),i]:null,t[2]=n,t[3]=i,t[4]=u):u=t[4];let p;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(p={revalidateOnFocus:!1},t[5]=p):p=t[5];let{data:m,error:h,isLoading:g,isValidating:_,mutate:v}=d(u,G,p),y=m??null,b=h instanceof Error?h.message:h?String(h):null,S=g||_,C;t[6]===v?C=t[7]:(C=()=>{v(),f(H())},t[6]=v,t[7]=C);let w=C,T=!n||S,D;t[8]===S?D=t[9]:(D=S?(0,W.jsx)(j,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,W.jsx)(x,{className:`size-3.5`,"aria-hidden":!0}),t[8]=S,t[9]=D);let O;t[10]===l.securityAuditRefresh?O=t[11]:(O=(0,W.jsx)(`span`,{className:`ml-1.5`,children:l.securityAuditRefresh}),t[10]=l.securityAuditRefresh,t[11]=O);let k;t[12]!==w||t[13]!==T||t[14]!==D||t[15]!==O?(k=(0,W.jsxs)(E,{type:`button`,variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:T,onClick:w,children:[D,O]}),t[12]=w,t[13]=T,t[14]=D,t[15]=O,t[16]=k):k=t[16];let A;t[17]!==l.securityAuditSubtitle||t[18]!==l.securityAuditTitle||t[19]!==k?(A=(0,W.jsx)(ee,{icon:M,title:l.securityAuditTitle,subtitle:l.securityAuditSubtitle,trailing:k}),t[17]=l.securityAuditSubtitle,t[18]=l.securityAuditTitle,t[19]=k,t[20]=A):A=t[20];let N;t[21]===l.securityAuditSavedConfigHint?N=t[22]:(N=(0,W.jsx)(`p`,{className:`mb-4 text-xs text-fg-subtle`,children:l.securityAuditSavedConfigHint}),t[21]=l.securityAuditSavedConfigHint,t[22]=N);let P;t[23]!==b||t[24]!==l.securityAuditLoadError?(P=b?(0,W.jsxs)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,role:`alert`,children:[l.securityAuditLoadError,`: `,b]}):null,t[23]=b,t[24]=l.securityAuditLoadError,t[25]=P):P=t[25];let F;t[26]!==y||t[27]!==b||t[28]!==l.securityAuditLoading||t[29]!==S?(F=!b&&S&&!y?(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,W.jsx)(j,{className:`size-4 animate-spin`,"aria-hidden":!0}),l.securityAuditLoading]}):null,t[26]=y,t[27]=b,t[28]=l.securityAuditLoading,t[29]=S,t[30]=F):F=t[30];let I;t[31]!==y||t[32]!==l?(I=y?(0,W.jsx)(q,{g:l,audit:y}):null,t[31]=y,t[32]=l,t[33]=I):I=t[33];let L;return t[34]!==A||t[35]!==N||t[36]!==P||t[37]!==F||t[38]!==I?(L=(0,W.jsxs)(R,{children:[A,N,P,F,I]}),t[34]=A,t[35]=N,t[36]=P,t[37]=F,t[38]=I,t[39]=L):L=t[39],L}function G(){return le()}function K(e){return e.language}function q(e){let t=(0,B.c)(40),{g:n,audit:r}=e,a,o,s,c,l,u,d;t[0]!==r.findings||t[1]!==r.status||t[2]!==n?(o=fe(n,r.status,r.findings),d=`space-y-4`,l=i(`rounded-lg border px-3 py-2.5 text-sm`,o.bannerClass),u=`status`,c=`flex items-start gap-2`,a=o.icon,s=i(`mt-0.5 size-4 shrink-0`,o.iconClass),t[0]=r.findings,t[1]=r.status,t[2]=n,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d):(a=t[3],o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9]);let f;t[10]!==a||t[11]!==s?(f=(0,W.jsx)(a,{className:s,"aria-hidden":!0}),t[10]=a,t[11]=s,t[12]=f):f=t[12];let p;t[13]===o.title?p=t[14]:(p=(0,W.jsx)(`p`,{className:`font-medium`,children:o.title}),t[13]=o.title,t[14]=p);let m;t[15]===r.message?m=t[16]:(m=(0,W.jsx)(`p`,{className:`mt-0.5 text-xs opacity-90`,children:r.message}),t[15]=r.message,t[16]=m);let h;t[17]!==p||t[18]!==m?(h=(0,W.jsxs)(`div`,{children:[p,m]}),t[17]=p,t[18]=m,t[19]=h):h=t[19];let g;t[20]!==c||t[21]!==f||t[22]!==h?(g=(0,W.jsxs)(`div`,{className:c,children:[f,h]}),t[20]=c,t[21]=f,t[22]=h,t[23]=g):g=t[23];let _;t[24]!==g||t[25]!==l||t[26]!==u?(_=(0,W.jsx)(`div`,{className:l,role:u,children:g}),t[24]=g,t[25]=l,t[26]=u,t[27]=_):_=t[27];let v;t[28]!==r.findings||t[29]!==r.status||t[30]!==n?(v=r.findings.length>0?(0,W.jsx)(`ul`,{className:`space-y-2`,children:r.findings.map(e=>(0,W.jsx)(Y,{g:n,finding:e},e.checkId))}):r.status===`pass`||r.status===`skip`?(0,W.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.securityAuditNoFindings}):null,t[28]=r.findings,t[29]=r.status,t[30]=n,t[31]=v):v=t[31];let y;t[32]!==r.hints||t[33]!==n?(y=r.hints.length>0?(0,W.jsxs)(`div`,{className:`space-y-1 border-t border-edge pt-3`,children:[(0,W.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:n.securityAuditHintsTitle}),(0,W.jsx)(`ul`,{className:`space-y-1 text-xs text-fg-subtle`,children:r.hints.map(J)})]}):null,t[32]=r.hints,t[33]=n,t[34]=y):y=t[34];let b;return t[35]!==_||t[36]!==v||t[37]!==y||t[38]!==d?(b=(0,W.jsxs)(`div`,{className:d,children:[_,v,y]}),t[35]=_,t[36]=v,t[37]=y,t[38]=d,t[39]=b):b=t[39],b}function J(e){return(0,W.jsx)(`li`,{className:`font-mono`,children:e},e)}function Y(e){let t=(0,B.c)(31),{g:n,finding:r}=e,a,o,s,c;if(t[0]!==r.severity){let e=de(r.severity);c=`rounded-lg border border-edge bg-surface-panel/50 px-3 py-2.5`,s=`flex items-start gap-2`,a=e.icon,o=i(`mt-0.5 size-4 shrink-0`,e.iconClass),t[0]=r.severity,t[1]=a,t[2]=o,t[3]=s,t[4]=c}else a=t[1],o=t[2],s=t[3],c=t[4];let l;t[5]!==a||t[6]!==o?(l=(0,W.jsx)(a,{className:o,"aria-hidden":!0}),t[5]=a,t[6]=o,t[7]=l):l=t[7];let u;t[8]===r.title?u=t[9]:(u=(0,W.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:r.title}),t[8]=r.title,t[9]=u);let d;t[10]===r.checkId?d=t[11]:(d=(0,W.jsx)(`span`,{className:`font-mono text-[0.65rem] text-fg-subtle`,children:r.checkId}),t[10]=r.checkId,t[11]=d);let f;t[12]!==u||t[13]!==d?(f=(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5`,children:[u,d]}),t[12]=u,t[13]=d,t[14]=f):f=t[14];let p;t[15]===r.detail?p=t[16]:(p=(0,W.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:r.detail}),t[15]=r.detail,t[16]=p);let m;t[17]!==r.remediation||t[18]!==n?(m=r.remediation?(0,W.jsxs)(`p`,{className:`mt-1.5 text-xs text-fg-subtle`,children:[(0,W.jsx)(`span`,{className:`text-fg-muted`,children:n.securityAuditRemediation}),` `,r.remediation]}):null,t[17]=r.remediation,t[18]=n,t[19]=m):m=t[19];let h;t[20]!==f||t[21]!==p||t[22]!==m?(h=(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[f,p,m]}),t[20]=f,t[21]=p,t[22]=m,t[23]=h):h=t[23];let g;t[24]!==h||t[25]!==s||t[26]!==l?(g=(0,W.jsxs)(`div`,{className:s,children:[l,h]}),t[24]=h,t[25]=s,t[26]=l,t[27]=g):g=t[27];let _;return t[28]!==g||t[29]!==c?(_=(0,W.jsx)(`li`,{className:c,children:g}),t[28]=g,t[29]=c,t[30]=_):_=t[30],_}function de(e){switch(e){case`critical`:return{icon:p,iconClass:`text-red-600 dark:text-red-400`};case`warn`:return{icon:v,iconClass:`text-amber-600 dark:text-amber-400`};default:return{icon:P,iconClass:`text-fg-muted`}}}function fe(e,t,n){let r=n.filter(e=>e.severity===`critical`).length,i=n.filter(e=>e.severity===`warn`).length;return t===`fail`||r>0?{icon:p,iconClass:`text-red-600 dark:text-red-400`,title:e.securityAuditStatusFail,bannerClass:`border-red-200 bg-red-50 text-red-950 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-100`}:t===`warn`||i>0?{icon:v,iconClass:`text-amber-600 dark:text-amber-400`,title:e.securityAuditStatusWarn,bannerClass:`border-amber-200 bg-amber-50 text-amber-950 dark:border-amber-800 dark:bg-amber-950/40 dark:text-amber-100`}:t===`skip`?{icon:P,iconClass:`text-fg-muted`,title:e.securityAuditStatusSkip,bannerClass:`border-edge bg-surface-panel/60 text-fg`}:{icon:M,iconClass:`text-emerald-600 dark:text-emerald-400`,title:e.securityAuditStatusPass,bannerClass:`border-emerald-200 bg-emerald-50 text-emerald-950 dark:border-emerald-900/50 dark:bg-emerald-950/40 dark:text-emerald-100`}}function X(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,_,`dark:border-edge`)}var pe=[`network`,`access`,`updates`,`security`,`advanced`],Z={network:g,access:C,updates:x,security:k,advanced:b};function me(e){return e&&pe.includes(e)?e:`network`}function he(e,t){return t===`network`?e.tabNetwork:t===`access`?e.tabAccess:t===`updates`?e.tabUpdates:t===`security`?e.tabSecurity:e.tabAdvanced}function ge(e,t){return t===`network`?e.networkTabHint:t===`access`?e.accessTabHint:t===`updates`?e.updatesTabHint:t===`security`?e.securitySectionHint:e.advancedSectionHint}function _e(e,t){switch(t.type){case`reset`:return{form:null,baseline:null,appliedBaseline:null};case`init-applied`:return{...e,appliedBaseline:structuredClone(t.value)};case`sync`:{let n=structuredClone(t.value);return{form:n,baseline:structuredClone(n),appliedBaseline:e.appliedBaseline}}case`set-form`:return e.form?{...e,form:t.updater(e.form)}:e;case`discard`:return e.baseline?{...e,form:structuredClone(e.baseline)}:e;case`saved`:{let n=structuredClone(t.value);return{form:n,baseline:structuredClone(n),appliedBaseline:e.appliedBaseline}}}}var ve={saving:!1,error:null,saveOk:!1,auditRefreshToken:0,restarting:!1,restartConfirmOpen:!1};function ye(){let e=o(e=>e.language),t=a(e),n=t.gatewaySettings,[r,c]=h(),l=y(e=>e.mode),d=l===`advanced`,f=me(r.get(`tab`)),g=(0,z.useMemo)(()=>ne(pe,l),[l]),_=(0,z.useCallback)(e=>{c(t=>{let n=new URLSearchParams(t);return e===`network`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},[c]);te(f,_);let v=s(e=>e.token),b=s(e=>e.tokenExpired),x=s(e=>e.openTokenDialog),C=!!v,[w,k]=(0,z.useReducer)(_e,{form:null,baseline:null,appliedBaseline:null}),M=w.form,P=w.baseline,I=w.appliedBaseline,[ee,R]=(0,z.useReducer)(m,ve),{saving:B,error:V,saveOk:H,auditRefreshToken:ce,restarting:U,restartConfirmOpen:le}=ee,G=(0,z.useRef)(!1),K=(0,z.useRef)(null),q=(0,z.useRef)(!1),{data:J,error:Y,isLoading:de,mutate:fe}=S(C),Z=(0,z.useMemo)(()=>J?.payload?.config===void 0?null:structuredClone(ie(J.payload.config)),[J]);C?Z!==null&&(q.current||(q.current=!0,k({type:`init-applied`,value:Z})),!G.current&&K.current!==Z&&(K.current=Z,k({type:`sync`,value:Z}),R({type:`patch`,patch:{saveOk:!1}}))):(K.current!==null||q.current)&&(K.current=null,q.current=!1,k({type:`reset`}),G.current=!1);let he=!!(C&&de&&J===void 0&&!Y),ge=Y instanceof Error?Y.message:Y?String(Y):null,ye=(0,z.useMemo)(()=>!M||!P?!1:JSON.stringify(M)!==JSON.stringify(P),[M,P]),$=(0,z.useMemo)(()=>!P||!I?!1:se(I,P),[I,P]),De=(0,z.useCallback)(e=>{G.current=!0,k({type:`set-form`,updater:t=>({...t,auth:{...t.auth,...e}})})},[]),Oe=(0,z.useCallback)(e=>{G.current=!0,k({type:`set-form`,updater:t=>({...t,updateChannel:e})})},[]),ke=(0,z.useCallback)(e=>{G.current=!0,k({type:`set-form`,updater:t=>({...t,corsOrigins:e})})},[]),Ae=(0,z.useCallback)(e=>{G.current=!0,k({type:`set-form`,updater:t=>({...t,bind:e})})},[]),je=(0,z.useCallback)(e=>{G.current=!0,k({type:`set-form`,updater:t=>({...t,customBindHost:e,bind:`custom`})})},[]),Me=(0,z.useCallback)(e=>{G.current=!0,k({type:`set-form`,updater:t=>({...t,port:e})})},[]),Ne=(0,z.useCallback)(e=>{G.current=!0,k({type:`set-form`,updater:t=>({...t,auth:{...t.auth,rateLimit:{...t.auth.rateLimit,...e}}})})},[]),Pe=(0,z.useCallback)(e=>{G.current=!0,k({type:`set-form`,updater:t=>({...t,maxSseConnections:e})})},[]),Fe=(0,z.useCallback)(e=>{G.current=!0,k({type:`set-form`,updater:t=>({...t,channelConnectDeferMode:e})})},[]),Ie=(0,z.useCallback)(e=>{G.current=!0,k({type:`set-form`,updater:t=>({...t,channelConnectDeferIds:e})})},[]),Le=(0,z.useCallback)(e=>{G.current=!0,k({type:`set-form`,updater:t=>({...t,channelConnectDeferSkipIds:e})})},[]),Re=(0,z.useCallback)(e=>{G.current=!0,k({type:`set-form`,updater:t=>({...t,trustedProxies:e})})},[]),ze=(0,z.useCallback)(e=>{G.current=!0,k({type:`set-form`,updater:t=>({...t,auth:{...t.auth,trustedProxy:{...t.auth.trustedProxy,...e}}})})},[]),Be=(0,z.useCallback)(e=>{G.current=!0,k({type:`set-form`,updater:t=>({...t,securityStrict:e})})},[]),Ve=(0,z.useCallback)(e=>{G.current=!0,k({type:`set-form`,updater:t=>({...t,allowRealIpFallback:e})})},[]),He=(0,z.useCallback)(e=>{G.current=!0,k({type:`set-form`,updater:t=>({...t,dangerouslyAllowHostHeaderOriginFallback:e})})},[]),Ue=(0,z.useCallback)(async()=>{if(!M||B)return;let e=ae(M);if(e){R({type:`patch`,patch:{error:e}});return}R({type:`patch`,patch:{saving:!0,error:null,saveOk:!1}});try{await oe(M),G.current=!1,k({type:`saved`,value:M}),R({type:`patch`,patch:{saveOk:!0,auditRefreshToken:ce+1}}),window.setTimeout(()=>R({type:`patch`,patch:{saveOk:!1}}),2500)}catch(e){R({type:`patch`,patch:{error:e instanceof Error?e.message:n.saveError}})}finally{R({type:`patch`,patch:{saving:!1}})}},[M,B,n.saveError]),We=(0,z.useCallback)(()=>{P&&(G.current=!1,k({type:`discard`}),R({type:`patch`,patch:{error:null,saveOk:!1}}))},[P]),Ge=T(n),Ke=(0,z.useCallback)(async()=>{if(!U){R({type:`patch`,patch:{restarting:!0,restartConfirmOpen:!1}});try{let e=await N();e.ok?window.dispatchEvent(new Event(`gateway-restart-initiated`)):u({type:`error`,title:n.restartGatewayFailed,message:e.message??``})}catch(e){u({type:`error`,title:n.restartGatewayFailed,message:e instanceof Error?e.message:String(e)})}finally{R({type:`patch`,patch:{restarting:!1}})}}},[U,n.restartGatewayFailed]);return C?he?(0,W.jsx)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,W.jsx)(j,{className:`size-4 animate-spin`}),n.loading]})}):M?(0,W.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-6`,children:[(0,W.jsxs)(`header`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h1`,{className:`text-lg font-semibold tracking-tight text-fg`,children:t.settingsSections.gateway}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:n.subtitle}),(0,W.jsxs)(`a`,{href:O(e,`gateway`),target:`_blank`,rel:`noreferrer`,className:`mt-1 inline-flex items-center gap-1 text-sm text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,children:[n.docsLink,(0,W.jsx)(D,{className:`size-3.5`})]})]}),(0,W.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-2`,children:[H?(0,W.jsx)(`span`,{className:`text-sm text-fg-muted`,children:n.saved}):null,(0,W.jsx)(E,{type:`button`,variant:`secondary`,disabled:!ye||B,onClick:We,children:n.discard}),(0,W.jsx)(E,{type:`button`,variant:`primary`,disabled:!ye||B,onClick:()=>void Ue(),children:B?n.saving:n.save})]})]}),b?(0,W.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-lg border border-red-200 bg-red-50 px-4 py-3 dark:border-red-900/50 dark:bg-red-950/40`,role:`alert`,children:[(0,W.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,W.jsx)(p,{className:`mt-0.5 size-4 shrink-0 text-red-600 dark:text-red-400`}),(0,W.jsx)(`p`,{className:`text-sm text-red-900 dark:text-red-100`,children:n.tokenExpired})]}),(0,W.jsx)(`div`,{children:(0,W.jsx)(E,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:()=>x(),children:n.updateToken})})]}):null,ye?(0,W.jsx)(`p`,{className:`text-xs text-amber-800 dark:text-amber-200`,children:n.unsavedHint}):null,V?(0,W.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:V}):null,$?(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg border border-amber-200 bg-amber-50 px-3 py-2 dark:border-amber-800 dark:bg-amber-950/40`,children:[(0,W.jsx)(`p`,{className:`text-xs text-amber-950 dark:text-amber-100`,children:n.restartHint}),(0,W.jsxs)(E,{type:`button`,variant:`secondary`,className:`shrink-0 gap-1.5 border-red-300 bg-red-50 text-xs text-red-700 hover:bg-red-100 dark:border-red-800 dark:bg-red-950/50 dark:text-red-300 dark:hover:bg-red-900/60`,disabled:U,onClick:()=>R({type:`patch`,patch:{restartConfirmOpen:!0}}),children:[U?(0,W.jsx)(j,{className:`size-3.5 animate-spin`}):(0,W.jsx)(F,{className:`size-3.5`}),n.restartGatewayButton]})]}):null,(0,W.jsx)(A,{open:le,title:n.restartGatewayButton,description:n.restartGatewayConfirm,confirmLabel:n.restartGatewayButton,cancelLabel:n.discard,destructive:!0,onConfirm:()=>void Ke(),onCancel:()=>R({type:`patch`,patch:{restartConfirmOpen:!1}})}),(0,W.jsx)(be,{g:n,activeTab:f,visibleTabs:g,onChange:_}),(0,W.jsxs)(Q,{g:n,id:`network`,activeTab:f,children:[(0,W.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`gateway-bind-mode`,children:n.bindMode}),(0,W.jsxs)(`select`,{id:`gateway-bind-mode`,className:X(),value:M.bind,onChange:e=>Ae(e.target.value),children:[(0,W.jsx)(`option`,{value:`loopback`,children:n.bindLoopback}),d?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`option`,{value:`lan`,children:n.bindLan}),(0,W.jsx)(`option`,{value:`auto`,children:n.bindAuto}),(0,W.jsx)(`option`,{value:`custom`,children:n.bindCustom}),(0,W.jsx)(`option`,{value:`tailnet`,children:n.bindTailnet})]}):null]})]}),M.bind===`custom`?(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`gateway-custom-bind-host`,children:n.customBindHost}),(0,W.jsx)(`input`,{id:`gateway-custom-bind-host`,className:i(X(),`font-mono text-xs`),value:M.customBindHost,onChange:e=>je(e.target.value),placeholder:n.customBindHostPlaceholder,autoComplete:`off`})]}):null,(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`gateway-listen-port`,children:n.listenPort}),(0,W.jsx)(`input`,{id:`gateway-listen-port`,type:`number`,min:1,max:65535,className:i(X(),`font-mono text-xs`),value:M.port,onChange:e=>{let t=Number(e.target.value);Me(Number.isFinite(t)?Math.max(1,Math.min(65535,Math.floor(t))):M.port)}})]}),(0,W.jsx)(`p`,{className:`text-xs text-fg-subtle sm:col-span-2`,children:n.listenHint})]}),(0,W.jsx)(L,{children:(0,W.jsx)(we,{g:n,origins:M.corsOrigins,onChange:ke})})]}),(0,W.jsxs)(Q,{g:n,id:`access`,activeTab:f,children:[M.auth.mode===`none`?(0,W.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:n.authModeNone}):null,(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`gateway-auth-mode`,children:n.authMode}),(0,W.jsxs)(`select`,{id:`gateway-auth-mode`,value:M.auth.mode,onChange:e=>De({mode:e.target.value}),className:X(),children:[(0,W.jsx)(`option`,{value:`token`,children:n.authModeToken}),(0,W.jsx)(`option`,{value:`password`,children:n.authModePassword}),d?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`option`,{value:`trusted-proxy`,children:n.authModeTrustedProxy}),(0,W.jsx)(`option`,{value:`none`,children:n.authModeNoneLabel})]}):null]})]}),(0,W.jsx)(L,{children:M.auth.mode===`trusted-proxy`?(0,W.jsx)(Se,{g:n,form:M,onTrustedProxyChange:ze,onTrustedProxiesChange:Re,onAllowRealIpFallbackChange:Ve}):null}),M.auth.mode===`token`?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Ee,{id:`gateway-access-token`,label:n.accessToken,help:n.tokenHelp,placeholder:n.tokenPlaceholder,value:M.auth.token,labels:Ge,reveal:()=>re(`token`).then(e=>e.secret),loadFailedLabel:n.saveError,onChange:e=>De({token:e})}),(0,W.jsx)(E,{type:`button`,variant:`secondary`,className:`w-full sm:w-auto`,onClick:()=>x(),children:n.changeToken})]}):null,M.auth.mode===`password`?(0,W.jsx)(Ee,{id:`gateway-auth-password`,label:n.authPassword,help:n.authPasswordHelp,placeholder:n.authPasswordPlaceholder,value:M.auth.password,labels:Ge,reveal:()=>re(`password`).then(e=>e.secret),loadFailedLabel:n.saveError,onChange:e=>De({password:e})}):null,(0,W.jsx)(L,{children:M.auth.mode===`none`?null:(0,W.jsx)(Te,{g:n,rateLimit:M.auth.rateLimit,onChange:Ne})})]}),(0,W.jsxs)(Q,{g:n,id:`updates`,activeTab:f,children:[(0,W.jsxs)(`div`,{className:`space-y-2`,children:[(0,W.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`gateway-update-channel`,children:n.updateChannel}),(0,W.jsxs)(`select`,{id:`gateway-update-channel`,value:M.updateChannel,onChange:e=>Oe(e.target.value),className:X(),children:[(0,W.jsx)(`option`,{value:`stable`,children:n.channelStable}),(0,W.jsx)(`option`,{value:`beta`,children:n.channelBeta}),(0,W.jsx)(`option`,{value:`dev`,children:n.channelDev})]}),(0,W.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.updateChannelHint})]}),(0,W.jsxs)(`div`,{className:`space-y-4 border-t border-edge pt-4`,children:[(0,W.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.updateAutoSection}),(0,W.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.updateAutoSectionHint}),(0,W.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,W.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:M.updateCheckOnStart,onChange:e=>{G.current=!0,k({type:`set-form`,updater:t=>({...t,updateCheckOnStart:e.target.checked})})}}),(0,W.jsxs)(`span`,{children:[(0,W.jsx)(`span`,{className:`font-medium`,children:n.updateCheckOnStart}),(0,W.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:n.updateCheckOnStartHint})]})]}),(0,W.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,W.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:M.updateAutoEnabled,onChange:e=>{G.current=!0,k({type:`set-form`,updater:t=>({...t,updateAutoEnabled:e.target.checked})})}}),(0,W.jsxs)(`span`,{children:[(0,W.jsx)(`span`,{className:`font-medium`,children:n.updateAutoEnabled}),(0,W.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:n.updateAutoEnabledHint})]})]}),(0,W.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`update-auto-stable-delay`,children:n.updateAutoStableDelayHours}),(0,W.jsx)(`input`,{id:`update-auto-stable-delay`,type:`number`,min:0,disabled:!M.updateAutoEnabled,className:X(),value:M.updateAutoStableDelayHours,onChange:e=>{G.current=!0,k({type:`set-form`,updater:t=>({...t,updateAutoStableDelayHours:Math.max(0,Math.floor(Number(e.target.value)||0))})})}}),(0,W.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.updateAutoStableDelayHoursHint})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`update-auto-stable-jitter`,children:n.updateAutoStableJitterHours}),(0,W.jsx)(`input`,{id:`update-auto-stable-jitter`,type:`number`,min:0,disabled:!M.updateAutoEnabled,className:X(),value:M.updateAutoStableJitterHours,onChange:e=>{G.current=!0,k({type:`set-form`,updater:t=>({...t,updateAutoStableJitterHours:Math.max(0,Math.floor(Number(e.target.value)||0))})})}}),(0,W.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.updateAutoStableJitterHoursHint})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`update-auto-beta-interval`,children:n.updateAutoBetaCheckIntervalHours}),(0,W.jsx)(`input`,{id:`update-auto-beta-interval`,type:`number`,min:.25,step:.25,disabled:!M.updateAutoEnabled,className:X(),value:M.updateAutoBetaCheckIntervalHours,onChange:e=>{G.current=!0,k({type:`set-form`,updater:t=>({...t,updateAutoBetaCheckIntervalHours:Math.max(.25,Number(e.target.value)||1)})})}}),(0,W.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.updateAutoBetaCheckIntervalHoursHint})]})]})]})]}),(0,W.jsxs)(Q,{g:n,id:`security`,activeTab:f,children:[(0,W.jsx)(ue,{enabled:C,refreshToken:ce}),(0,W.jsx)(xe,{g:n,form:M,onSecurityStrictChange:Be,onDangerouslyAllowHostHeaderOriginFallbackChange:He})]}),(0,W.jsx)(Q,{g:n,id:`advanced`,activeTab:f,children:(0,W.jsx)(Ce,{g:n,form:M,onMaxSseConnectionsChange:Pe,onDeferModeChange:Fe,onDeferIdsChange:Ie,onSkipIdsChange:Le})})]}):(0,W.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:[(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:V??ge??n.loadError}),(0,W.jsx)(E,{type:`button`,variant:`secondary`,onClick:()=>void fe(),children:n.retry})]}):(0,W.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-3 px-4 py-8`,children:[(0,W.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:t.settingsSections.gateway}),(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.needToken})]})}function be(e){let t=(0,B.c)(17),{g:n,activeTab:r,visibleTabs:a,onChange:o}=e,s=n.tabsAriaLabel,c;t[0]!==r||t[1]!==o||t[2]!==a?(c=e=>{if(e.key!==`ArrowLeft`&&e.key!==`ArrowRight`)return;e.preventDefault();let t=a.indexOf(r);t<0||o(a[(t+(e.key===`ArrowRight`?1:-1)+a.length)%a.length])},t[0]=r,t[1]=o,t[2]=a,t[3]=c):c=t[3];let l;if(t[4]!==r||t[5]!==n||t[6]!==o||t[7]!==a){let e;t[9]!==r||t[10]!==n||t[11]!==o?(e=e=>{let t=Z[e],a=e===r;return(0,W.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":a,"aria-controls":`gateway-settings-panel-${e}`,id:`gateway-settings-tab-${e}`,className:i(`inline-flex shrink-0 items-center gap-1.5 rounded-lg px-3 py-2 text-sm font-medium transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,I.press,a?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),onClick:()=>o(e),children:[(0,W.jsx)(t,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),(0,W.jsx)(`span`,{children:he(n,e)})]},e)},t[9]=r,t[10]=n,t[11]=o,t[12]=e):e=t[12],l=a.map(e),t[4]=r,t[5]=n,t[6]=o,t[7]=a,t[8]=l}else l=t[8];let u;return t[13]!==n.tabsAriaLabel||t[14]!==c||t[15]!==l?(u=(0,W.jsx)(`nav`,{"aria-label":s,className:`-mx-1 flex gap-1 overflow-x-auto px-1 pb-1`,role:`tablist`,onKeyDown:c,children:l}),t[13]=n.tabsAriaLabel,t[14]=c,t[15]=l,t[16]=u):u=t[16],u}function Q(e){let t=(0,B.c)(20),{g:n,id:r,activeTab:i,children:a}=e;if(i!==r)return null;let o=`gateway-settings-panel-${r}`,s=`gateway-settings-tab-${r}`,c;t[0]!==n||t[1]!==r?(c=he(n,r),t[0]=n,t[1]=r,t[2]=c):c=t[2];let l;t[3]===c?l=t[4]:(l=(0,W.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:c}),t[3]=c,t[4]=l);let u;t[5]!==n||t[6]!==r?(u=ge(n,r),t[5]=n,t[6]=r,t[7]=u):u=t[7];let d;t[8]===u?d=t[9]:(d=(0,W.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:u}),t[8]=u,t[9]=d);let f;t[10]!==l||t[11]!==d?(f=(0,W.jsxs)(`div`,{className:`mb-5`,children:[l,d]}),t[10]=l,t[11]=d,t[12]=f):f=t[12];let p;t[13]===a?p=t[14]:(p=(0,W.jsx)(`div`,{className:`space-y-4`,children:a}),t[13]=a,t[14]=p);let m;return t[15]!==o||t[16]!==s||t[17]!==f||t[18]!==p?(m=(0,W.jsxs)(`section`,{id:o,role:`tabpanel`,"aria-labelledby":s,className:`rounded-2xl border border-edge bg-surface-base px-4 py-5 sm:px-5`,children:[f,p]}),t[15]=o,t[16]=s,t[17]=f,t[18]=p,t[19]=m):m=t[19],m}function xe(e){let t=(0,B.c)(37),{g:n,form:r,onSecurityStrictChange:i,onDangerouslyAllowHostHeaderOriginFallbackChange:a}=e,o;t[0]===i?o=t[1]:(o=e=>i(e.target.checked),t[0]=i,t[1]=o);let s;t[2]!==r.securityStrict||t[3]!==o?(s=(0,W.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:r.securityStrict,onChange:o}),t[2]=r.securityStrict,t[3]=o,t[4]=s):s=t[4];let c;t[5]===n.securityStrict?c=t[6]:(c=(0,W.jsx)(`span`,{className:`font-medium`,children:n.securityStrict}),t[5]=n.securityStrict,t[6]=c);let l;t[7]===n.securityStrictHint?l=t[8]:(l=(0,W.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:n.securityStrictHint}),t[7]=n.securityStrictHint,t[8]=l);let u;t[9]!==c||t[10]!==l?(u=(0,W.jsxs)(`span`,{children:[c,l]}),t[9]=c,t[10]=l,t[11]=u):u=t[11];let d;t[12]!==s||t[13]!==u?(d=(0,W.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[s,u]}),t[12]=s,t[13]=u,t[14]=d):d=t[14];let f;t[15]===a?f=t[16]:(f=e=>a(e.target.checked),t[15]=a,t[16]=f);let p;t[17]!==r.dangerouslyAllowHostHeaderOriginFallback||t[18]!==f?(p=(0,W.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:r.dangerouslyAllowHostHeaderOriginFallback,onChange:f}),t[17]=r.dangerouslyAllowHostHeaderOriginFallback,t[18]=f,t[19]=p):p=t[19];let m;t[20]===n.dangerouslyAllowHostHeaderOriginFallback?m=t[21]:(m=(0,W.jsx)(`span`,{className:`font-medium`,children:n.dangerouslyAllowHostHeaderOriginFallback}),t[20]=n.dangerouslyAllowHostHeaderOriginFallback,t[21]=m);let h;t[22]===n.dangerouslyAllowHostHeaderOriginFallbackHint?h=t[23]:(h=(0,W.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:n.dangerouslyAllowHostHeaderOriginFallbackHint}),t[22]=n.dangerouslyAllowHostHeaderOriginFallbackHint,t[23]=h);let g;t[24]!==h||t[25]!==m?(g=(0,W.jsxs)(`span`,{children:[m,h]}),t[24]=h,t[25]=m,t[26]=g):g=t[26];let _;t[27]!==g||t[28]!==p?(_=(0,W.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[p,g]}),t[27]=g,t[28]=p,t[29]=_):_=t[29];let v;t[30]!==r.dangerouslyAllowHostHeaderOriginFallback||t[31]!==n.dangerouslyAllowHostHeaderOriginFallbackWarning?(v=r.dangerouslyAllowHostHeaderOriginFallback?(0,W.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:n.dangerouslyAllowHostHeaderOriginFallbackWarning}):null,t[30]=r.dangerouslyAllowHostHeaderOriginFallback,t[31]=n.dangerouslyAllowHostHeaderOriginFallbackWarning,t[32]=v):v=t[32];let y;return t[33]!==_||t[34]!==v||t[35]!==d?(y=(0,W.jsxs)(`div`,{className:`space-y-4`,children:[d,_,v]}),t[33]=_,t[34]=v,t[35]=d,t[36]=y):y=t[36],y}function Se(e){let t=(0,B.c)(80),{g:n,form:r,onTrustedProxyChange:a,onTrustedProxiesChange:o,onAllowRealIpFallbackChange:s}=e,c=r.auth.trustedProxy,l;t[0]===n.authModeTrustedProxyHint?l=t[1]:(l=(0,W.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.authModeTrustedProxyHint}),t[0]=n.authModeTrustedProxyHint,t[1]=l);let u;t[2]===n.trustedProxyUserHeader?u=t[3]:(u=(0,W.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`gateway-trusted-proxy-user-header`,children:n.trustedProxyUserHeader}),t[2]=n.trustedProxyUserHeader,t[3]=u);let d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d=i(X(),`font-mono text-xs`),t[4]=d):d=t[4];let f;t[5]===a?f=t[6]:(f=e=>a({userHeader:e.target.value}),t[5]=a,t[6]=f);let p;t[7]!==n.trustedProxyUserHeaderPlaceholder||t[8]!==f||t[9]!==c.userHeader?(p=(0,W.jsx)(`input`,{id:`gateway-trusted-proxy-user-header`,className:d,value:c.userHeader,onChange:f,placeholder:n.trustedProxyUserHeaderPlaceholder,autoComplete:`off`}),t[7]=n.trustedProxyUserHeaderPlaceholder,t[8]=f,t[9]=c.userHeader,t[10]=p):p=t[10];let m;t[11]===n.trustedProxyUserHeaderHint?m=t[12]:(m=(0,W.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.trustedProxyUserHeaderHint}),t[11]=n.trustedProxyUserHeaderHint,t[12]=m);let h;t[13]!==u||t[14]!==p||t[15]!==m?(h=(0,W.jsxs)(`div`,{children:[u,p,m]}),t[13]=u,t[14]=p,t[15]=m,t[16]=h):h=t[16];let g;t[17]===a?g=t[18]:(g=e=>a({requiredHeaders:e}),t[17]=a,t[18]=g);let _;t[19]!==n.channelIdListEmpty||t[20]!==n.trustedProxyRequiredHeaders||t[21]!==n.trustedProxyRequiredHeadersHint||t[22]!==n.trustedProxyUserHeaderPlaceholder||t[23]!==g||t[24]!==c.requiredHeaders?(_=(0,W.jsx)($,{title:n.trustedProxyRequiredHeaders,hint:n.trustedProxyRequiredHeadersHint,emptyText:n.channelIdListEmpty,placeholder:n.trustedProxyUserHeaderPlaceholder,values:c.requiredHeaders,maxItems:32,onChange:g}),t[19]=n.channelIdListEmpty,t[20]=n.trustedProxyRequiredHeaders,t[21]=n.trustedProxyRequiredHeadersHint,t[22]=n.trustedProxyUserHeaderPlaceholder,t[23]=g,t[24]=c.requiredHeaders,t[25]=_):_=t[25];let v;t[26]===a?v=t[27]:(v=e=>a({allowUsers:e}),t[26]=a,t[27]=v);let y;t[28]!==n.channelIdListEmpty||t[29]!==n.trustedProxyAllowUsers||t[30]!==n.trustedProxyAllowUsersHint||t[31]!==n.trustedProxyUserHeaderPlaceholder||t[32]!==v||t[33]!==c.allowUsers?(y=(0,W.jsx)($,{title:n.trustedProxyAllowUsers,hint:n.trustedProxyAllowUsersHint,emptyText:n.channelIdListEmpty,placeholder:n.trustedProxyUserHeaderPlaceholder,values:c.allowUsers,maxItems:128,onChange:v}),t[28]=n.channelIdListEmpty,t[29]=n.trustedProxyAllowUsers,t[30]=n.trustedProxyAllowUsersHint,t[31]=n.trustedProxyUserHeaderPlaceholder,t[32]=v,t[33]=c.allowUsers,t[34]=y):y=t[34];let b;t[35]===a?b=t[36]:(b=e=>a({allowLoopback:e.target.checked}),t[35]=a,t[36]=b);let x;t[37]!==b||t[38]!==c.allowLoopback?(x=(0,W.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:c.allowLoopback,onChange:b}),t[37]=b,t[38]=c.allowLoopback,t[39]=x):x=t[39];let S;t[40]===n.trustedProxyAllowLoopback?S=t[41]:(S=(0,W.jsx)(`span`,{className:`font-medium`,children:n.trustedProxyAllowLoopback}),t[40]=n.trustedProxyAllowLoopback,t[41]=S);let C;t[42]===n.trustedProxyAllowLoopbackHint?C=t[43]:(C=(0,W.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:n.trustedProxyAllowLoopbackHint}),t[42]=n.trustedProxyAllowLoopbackHint,t[43]=C);let w;t[44]!==S||t[45]!==C?(w=(0,W.jsxs)(`span`,{children:[S,C]}),t[44]=S,t[45]=C,t[46]=w):w=t[46];let T;t[47]!==x||t[48]!==w?(T=(0,W.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[x,w]}),t[47]=x,t[48]=w,t[49]=T):T=t[49];let E;t[50]!==r.trustedProxies||t[51]!==n.trustedProxies||t[52]!==n.trustedProxiesEmpty||t[53]!==n.trustedProxiesHint||t[54]!==n.trustedProxiesPlaceholder||t[55]!==o?(E=(0,W.jsx)($,{title:n.trustedProxies,hint:n.trustedProxiesHint,emptyText:n.trustedProxiesEmpty,placeholder:n.trustedProxiesPlaceholder,values:r.trustedProxies,maxItems:64,onChange:o}),t[50]=r.trustedProxies,t[51]=n.trustedProxies,t[52]=n.trustedProxiesEmpty,t[53]=n.trustedProxiesHint,t[54]=n.trustedProxiesPlaceholder,t[55]=o,t[56]=E):E=t[56];let D;t[57]===s?D=t[58]:(D=e=>s(e.target.checked),t[57]=s,t[58]=D);let O;t[59]!==r.allowRealIpFallback||t[60]!==D?(O=(0,W.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:r.allowRealIpFallback,onChange:D}),t[59]=r.allowRealIpFallback,t[60]=D,t[61]=O):O=t[61];let k;t[62]===n.allowRealIpFallback?k=t[63]:(k=(0,W.jsx)(`span`,{className:`font-medium`,children:n.allowRealIpFallback}),t[62]=n.allowRealIpFallback,t[63]=k);let A;t[64]===n.allowRealIpFallbackHint?A=t[65]:(A=(0,W.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:n.allowRealIpFallbackHint}),t[64]=n.allowRealIpFallbackHint,t[65]=A);let j;t[66]!==k||t[67]!==A?(j=(0,W.jsxs)(`span`,{children:[k,A]}),t[66]=k,t[67]=A,t[68]=j):j=t[68];let M;t[69]!==O||t[70]!==j?(M=(0,W.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[O,j]}),t[69]=O,t[70]=j,t[71]=M):M=t[71];let N;return t[72]!==l||t[73]!==y||t[74]!==T||t[75]!==E||t[76]!==M||t[77]!==h||t[78]!==_?(N=(0,W.jsxs)(`div`,{className:`space-y-4 border-t border-edge pt-4`,children:[l,h,_,y,T,E,M]}),t[72]=l,t[73]=y,t[74]=T,t[75]=E,t[76]=M,t[77]=h,t[78]=_,t[79]=N):N=t[79],N}function Ce(e){let t=(0,B.c)(58),{g:n,form:r,onMaxSseConnectionsChange:a,onDeferModeChange:o,onDeferIdsChange:s,onSkipIdsChange:c}=e,l;t[0]===n.maxSseConnections?l=t[1]:(l=(0,W.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`gateway-max-sse`,children:n.maxSseConnections}),t[0]=n.maxSseConnections,t[1]=l);let u;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=i(X(),`max-w-xs font-mono text-xs`),t[2]=u):u=t[2];let d;t[3]===a?d=t[4]:(d=e=>{let t=Number(e.target.value);Number.isFinite(t)&&a(Math.max(1,Math.floor(t)))},t[3]=a,t[4]=d);let f;t[5]!==r.maxSseConnections||t[6]!==d?(f=(0,W.jsx)(`input`,{id:`gateway-max-sse`,type:`number`,min:1,className:u,value:r.maxSseConnections,onChange:d}),t[5]=r.maxSseConnections,t[6]=d,t[7]=f):f=t[7];let p;t[8]===n.maxSseConnectionsHint?p=t[9]:(p=(0,W.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.maxSseConnectionsHint}),t[8]=n.maxSseConnectionsHint,t[9]=p);let m;t[10]!==l||t[11]!==f||t[12]!==p?(m=(0,W.jsxs)(`div`,{children:[l,f,p]}),t[10]=l,t[11]=f,t[12]=p,t[13]=m):m=t[13];let h;t[14]===n.channelConnectDeferMode?h=t[15]:(h=(0,W.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`gateway-channel-defer-mode`,children:n.channelConnectDeferMode}),t[14]=n.channelConnectDeferMode,t[15]=h);let g=r.channelConnectDeferMode,_;t[16]===o?_=t[17]:(_=e=>o(e.target.value),t[16]=o,t[17]=_);let v;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(v=X(),t[18]=v):v=t[18];let y;t[19]===n.channelConnectDeferModeAuto?y=t[20]:(y=(0,W.jsx)(`option`,{value:`auto`,children:n.channelConnectDeferModeAuto}),t[19]=n.channelConnectDeferModeAuto,t[20]=y);let b;t[21]===n.channelConnectDeferModeOff?b=t[22]:(b=(0,W.jsx)(`option`,{value:`off`,children:n.channelConnectDeferModeOff}),t[21]=n.channelConnectDeferModeOff,t[22]=b);let x;t[23]===n.channelConnectDeferModeExplicit?x=t[24]:(x=(0,W.jsx)(`option`,{value:`explicit`,children:n.channelConnectDeferModeExplicit}),t[23]=n.channelConnectDeferModeExplicit,t[24]=x);let S;t[25]!==r.channelConnectDeferMode||t[26]!==y||t[27]!==b||t[28]!==x||t[29]!==_?(S=(0,W.jsxs)(`select`,{id:`gateway-channel-defer-mode`,value:g,onChange:_,className:v,children:[y,b,x]}),t[25]=r.channelConnectDeferMode,t[26]=y,t[27]=b,t[28]=x,t[29]=_,t[30]=S):S=t[30];let C;t[31]===n.channelConnectDeferModeHint?C=t[32]:(C=(0,W.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.channelConnectDeferModeHint}),t[31]=n.channelConnectDeferModeHint,t[32]=C);let w;t[33]!==S||t[34]!==C||t[35]!==h?(w=(0,W.jsxs)(`div`,{className:`space-y-2 border-t border-edge pt-4`,children:[h,S,C]}),t[33]=S,t[34]=C,t[35]=h,t[36]=w):w=t[36];let T;t[37]!==r.channelConnectDeferIds||t[38]!==r.channelConnectDeferMode||t[39]!==n.channelConnectDeferIds||t[40]!==n.channelConnectDeferIdsHint||t[41]!==n.channelIdListEmpty||t[42]!==n.channelIdListPlaceholder||t[43]!==s?(T=r.channelConnectDeferMode===`explicit`?(0,W.jsx)($,{title:n.channelConnectDeferIds,hint:n.channelConnectDeferIdsHint,emptyText:n.channelIdListEmpty,placeholder:n.channelIdListPlaceholder,values:r.channelConnectDeferIds,maxItems:24,onChange:s}):null,t[37]=r.channelConnectDeferIds,t[38]=r.channelConnectDeferMode,t[39]=n.channelConnectDeferIds,t[40]=n.channelConnectDeferIdsHint,t[41]=n.channelIdListEmpty,t[42]=n.channelIdListPlaceholder,t[43]=s,t[44]=T):T=t[44];let E;t[45]!==r.channelConnectDeferMode||t[46]!==r.channelConnectDeferSkipIds||t[47]!==n.channelConnectDeferSkipIds||t[48]!==n.channelConnectDeferSkipIdsHint||t[49]!==n.channelIdListEmpty||t[50]!==n.channelIdListPlaceholder||t[51]!==c?(E=r.channelConnectDeferMode===`off`?null:(0,W.jsx)($,{title:n.channelConnectDeferSkipIds,hint:n.channelConnectDeferSkipIdsHint,emptyText:n.channelIdListEmpty,placeholder:n.channelIdListPlaceholder,values:r.channelConnectDeferSkipIds,maxItems:24,onChange:c}),t[45]=r.channelConnectDeferMode,t[46]=r.channelConnectDeferSkipIds,t[47]=n.channelConnectDeferSkipIds,t[48]=n.channelConnectDeferSkipIdsHint,t[49]=n.channelIdListEmpty,t[50]=n.channelIdListPlaceholder,t[51]=c,t[52]=E):E=t[52];let D;return t[53]!==w||t[54]!==T||t[55]!==E||t[56]!==m?(D=(0,W.jsxs)(`div`,{className:`space-y-4`,children:[m,w,T,E]}),t[53]=w,t[54]=T,t[55]=E,t[56]=m,t[57]=D):D=t[57],D}function $(e){let t=(0,B.c)(25),{title:n,hint:r,emptyText:a,placeholder:o,values:s,maxItems:c,onChange:l,children:u}=e,d;t[0]!==c||t[1]!==l||t[2]!==s?(d=e=>{let t=e.trim();!t||s.includes(t)||s.length>=c||l([...s,t])},t[0]=c,t[1]=l,t[2]=s,t[3]=d):d=t[3];let f=d,p;t[4]===n?p=t[5]:(p=(0,W.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[4]=n,t[5]=p);let m;t[6]===r?m=t[7]:(m=(0,W.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r}),t[6]=r,t[7]=m);let h;t[8]!==a||t[9]!==l||t[10]!==s?(h=s.length===0?(0,W.jsx)(`p`,{className:`text-xs text-fg-muted`,children:a}):(0,W.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:s.map(e=>(0,W.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,(0,W.jsx)(`button`,{type:`button`,className:i(`text-fg-muted hover:text-fg`,I.press),"aria-label":`Remove ${e}`,onClick:()=>l(s.filter(t=>t!==e)),children:`×`})]},e))}),t[8]=a,t[9]=l,t[10]=s,t[11]=h):h=t[11];let g;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(g=i(X(),`font-mono text-xs`),t[12]=g):g=t[12];let _=s.length>=c,v;t[13]===f?v=t[14]:(v=e=>{e.key===`Enter`&&(e.preventDefault(),f(e.target.value),e.target.value=``)},t[13]=f,t[14]=v);let y;t[15]!==o||t[16]!==_||t[17]!==v?(y=(0,W.jsx)(`input`,{className:g,placeholder:o,disabled:_,onKeyDown:v}),t[15]=o,t[16]=_,t[17]=v,t[18]=y):y=t[18];let b;return t[19]!==u||t[20]!==p||t[21]!==m||t[22]!==h||t[23]!==y?(b=(0,W.jsxs)(`div`,{className:`space-y-2 border-t border-edge pt-4`,children:[p,m,h,y,u]}),t[19]=u,t[20]=p,t[21]=m,t[22]=h,t[23]=y,t[24]=b):b=t[24],b}function we(e){let t=(0,B.c)(13),{g:n,origins:r,onChange:i}=e,a;t[0]===r?a=t[1]:(a=r.includes(`*`),t[0]=r,t[1]=a);let o=a,s;t[2]!==n.corsOriginsWildcardWarning||t[3]!==o?(s=o?(0,W.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:n.corsOriginsWildcardWarning}):null,t[2]=n.corsOriginsWildcardWarning,t[3]=o,t[4]=s):s=t[4];let c;return t[5]!==n.corsOrigins||t[6]!==n.corsOriginsEmpty||t[7]!==n.corsOriginsHint||t[8]!==n.corsOriginsPlaceholder||t[9]!==i||t[10]!==r||t[11]!==s?(c=(0,W.jsx)($,{title:n.corsOrigins,hint:n.corsOriginsHint,emptyText:n.corsOriginsEmpty,placeholder:n.corsOriginsPlaceholder,values:r,maxItems:128,onChange:i,children:s}),t[5]=n.corsOrigins,t[6]=n.corsOriginsEmpty,t[7]=n.corsOriginsHint,t[8]=n.corsOriginsPlaceholder,t[9]=i,t[10]=r,t[11]=s,t[12]=c):c=t[12],c}function Te(e){let t=(0,B.c)(73),{g:n,rateLimit:r,onChange:i}=e,a;t[0]===n.rateLimitTitle?a=t[1]:(a=(0,W.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.rateLimitTitle}),t[0]=n.rateLimitTitle,t[1]=a);let o;t[2]===n.rateLimitHint?o=t[3]:(o=(0,W.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.rateLimitHint}),t[2]=n.rateLimitHint,t[3]=o);let s;t[4]!==a||t[5]!==o?(s=(0,W.jsxs)(`div`,{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,W.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.rateLimitEnabled||t[13]!==l?(u=(0,W.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[l,n.rateLimitEnabled]}),t[12]=n.rateLimitEnabled,t[13]=l,t[14]=u):u=t[14];let d=!r.enabled,f;t[15]===i?f=t[16]:(f=e=>i({exemptLoopback:e.target.checked}),t[15]=i,t[16]=f);let p;t[17]!==r.exemptLoopback||t[18]!==d||t[19]!==f?(p=(0,W.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.exemptLoopback,disabled:d,onChange:f}),t[17]=r.exemptLoopback,t[18]=d,t[19]=f,t[20]=p):p=t[20];let m;t[21]!==n.rateLimitExemptLoopback||t[22]!==p?(m=(0,W.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[p,n.rateLimitExemptLoopback]}),t[21]=n.rateLimitExemptLoopback,t[22]=p,t[23]=m):m=t[23];let h;t[24]===n.rateLimitMaxAttempts?h=t[25]:(h=(0,W.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,htmlFor:`gateway-rate-max`,children:n.rateLimitMaxAttempts}),t[24]=n.rateLimitMaxAttempts,t[25]=h);let g;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(g=X(),t[26]=g):g=t[26];let _=!r.enabled,v;t[27]===i?v=t[28]:(v=e=>{let t=Number(e.target.value);Number.isFinite(t)&&i({maxAttempts:Math.max(1,Math.floor(t))})},t[27]=i,t[28]=v);let y;t[29]!==r.maxAttempts||t[30]!==_||t[31]!==v?(y=(0,W.jsx)(`input`,{id:`gateway-rate-max`,type:`number`,min:1,className:g,value:r.maxAttempts,disabled:_,onChange:v}),t[29]=r.maxAttempts,t[30]=_,t[31]=v,t[32]=y):y=t[32];let b;t[33]!==h||t[34]!==y?(b=(0,W.jsxs)(`div`,{children:[h,y]}),t[33]=h,t[34]=y,t[35]=b):b=t[35];let x;t[36]===n.rateLimitWindowMinutes?x=t[37]:(x=(0,W.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,htmlFor:`gateway-rate-window`,children:n.rateLimitWindowMinutes}),t[36]=n.rateLimitWindowMinutes,t[37]=x);let S;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(S=X(),t[38]=S):S=t[38];let C;t[39]===r.windowMs?C=t[40]:(C=Math.round(r.windowMs/6e4),t[39]=r.windowMs,t[40]=C);let w=!r.enabled,T;t[41]===i?T=t[42]:(T=e=>{let t=Number(e.target.value);Number.isFinite(t)&&t>0&&i({windowMs:Math.floor(t)*6e4})},t[41]=i,t[42]=T);let E;t[43]!==C||t[44]!==w||t[45]!==T?(E=(0,W.jsx)(`input`,{id:`gateway-rate-window`,type:`number`,min:1,className:S,value:C,disabled:w,onChange:T}),t[43]=C,t[44]=w,t[45]=T,t[46]=E):E=t[46];let D;t[47]!==x||t[48]!==E?(D=(0,W.jsxs)(`div`,{children:[x,E]}),t[47]=x,t[48]=E,t[49]=D):D=t[49];let O;t[50]===n.rateLimitBlockMinutes?O=t[51]:(O=(0,W.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,htmlFor:`gateway-rate-block`,children:n.rateLimitBlockMinutes}),t[50]=n.rateLimitBlockMinutes,t[51]=O);let k;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(k=X(),t[52]=k):k=t[52];let A;t[53]===r.blockDurationMs?A=t[54]:(A=Math.round(r.blockDurationMs/6e4),t[53]=r.blockDurationMs,t[54]=A);let j=!r.enabled,M;t[55]===i?M=t[56]:(M=e=>{let t=Number(e.target.value);Number.isFinite(t)&&t>0&&i({blockDurationMs:Math.floor(t)*6e4})},t[55]=i,t[56]=M);let N;t[57]!==A||t[58]!==j||t[59]!==M?(N=(0,W.jsx)(`input`,{id:`gateway-rate-block`,type:`number`,min:1,className:k,value:A,disabled:j,onChange:M}),t[57]=A,t[58]=j,t[59]=M,t[60]=N):N=t[60];let P;t[61]!==O||t[62]!==N?(P=(0,W.jsxs)(`div`,{children:[O,N]}),t[61]=O,t[62]=N,t[63]=P):P=t[63];let F;t[64]!==b||t[65]!==D||t[66]!==P?(F=(0,W.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[b,D,P]}),t[64]=b,t[65]=D,t[66]=P,t[67]=F):F=t[67];let I;return t[68]!==m||t[69]!==s||t[70]!==F||t[71]!==u?(I=(0,W.jsxs)(`div`,{className:`space-y-3 border-t border-edge pt-4`,children:[s,u,m,F]}),t[68]=m,t[69]=s,t[70]=F,t[71]=u,t[72]=I):I=t[72],I}function Ee(e){let t=(0,B.c)(17),{id:n,label:r,help:i,placeholder:a,value:o,labels:s,reveal:c,loadFailedLabel:l,onChange:u}=e,d;t[0]!==n||t[1]!==r?(d=(0,W.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:n,children:r}),t[0]=n,t[1]=r,t[2]=d):d=t[2];let f;t[3]!==n||t[4]!==s||t[5]!==l||t[6]!==u||t[7]!==a||t[8]!==c||t[9]!==o?(f=(0,W.jsx)(w,{id:n,value:o,onChange:u,placeholder:a,labels:s,reveal:c,loadFailedLabel:l,inputClassName:`text-xs`}),t[3]=n,t[4]=s,t[5]=l,t[6]=u,t[7]=a,t[8]=c,t[9]=o,t[10]=f):f=t[10];let p;t[11]===i?p=t[12]:(p=(0,W.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:i}),t[11]=i,t[12]=p);let m;return t[13]!==d||t[14]!==f||t[15]!==p?(m=(0,W.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[d,f,p]}),t[13]=d,t[14]=f,t[15]=p,t[16]=m):m=t[16],m}export{ye as GatewaySettingsPanel};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./fetch-Bs7in_4F.js";var t=6e4,n=500,r=5e3;function i(e){if(!e||typeof e!=`object`)return!1;let t=e;return t.code===`STARTUP_UNAVAILABLE`&&t.retryable===!0&&typeof t.retryAfterMs==`number`}function a(e){return new Promise(t=>setTimeout(t,e))}function o(e){let t=typeof e.retryAfterMs==`number`?e.retryAfterMs:n;return Math.min(Math.max(t,100),r)}async function s(n,r,s){let c=Date.now(),l=s?.timeoutMs??t;for(;;){let t=await e(n,r);if(t.status!==503)return t;let s=await t.clone().json().catch(()=>null);if(!i(s)||Date.now()-c>=l)return t;await a(o(s))}}export{s 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{t as i}from"./cn-JdwAhgNB.js";import{t as a}from"./messages-Csef1aW7.js";import{t as o}from"./locale-store-DjbfSsfA.js";import{i as s,n as c}from"./fetch-Bs7in_4F.js";import{$a as l,Ds as u,Ea as d,Eo as f,Es as p,Go as m,Hi as h,Ki as g,M as _,O as v,P as y,Ro as b,S as x,Ss as S,To as C,Ts as w,Wo as T,Xo as E,Yo as ee,Zo as te,ba as ne,bo as re,gs as ie,ii as ae,k as oe,ki as D,ko as O,ls as se,ma as k,vs as ce,xs as le}from"./index-COkF54xv.js";var A=n(),j=e(t(),1),M=r(),N=`min-w-0 rounded-md border border-edge bg-surface-muted px-3 py-2 text-sm text-fg placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`,ue=[`message`,`link`,`file`,`diff`,`command`,`test`,`artifact`];function de(e){return e===`command`||e===`test`?g:e===`diff`?b:e===`file`||e===`artifact`?C:e===`link`?O:k}function fe(e){return e.data&&typeof e.data==`object`&&!Array.isArray(e.data)?e.data:{}}function P(e,t){let n=e[t];return typeof n==`string`&&n.trim()?n:void 0}function pe(e,t){let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0}function me(e){let t=(0,A.c)(57),{item:n,language:r,t:i}=e,a;t[0]===n.kind?a=t[1]:(a=de(n.kind),t[0]=n.kind,t[1]=a);let o=a,s,c,l,u,d,f,p,m,h;if(t[2]!==o||t[3]!==n||t[4]!==r||t[5]!==i){let e=fe(n),a=P(e,`command`),g=pe(e,`exitCode`),_=P(e,`path`)||n.uri,v=pe(e,`outputBytes`);s=e.fuzzyMatchUsed===!0,f=`rounded-md border border-edge/70 bg-surface-muted/40 px-2.5 py-2`;let y;t[15]===o?y=t[16]:(y=(0,M.jsx)(o,{className:`mt-0.5 size-4 shrink-0 text-accent-fg`,"aria-hidden":!0}),t[15]=o,t[16]=y);let b;t[17]===n.title?b=t[18]:(b=(0,M.jsx)(`p`,{className:`break-words font-medium text-fg`,children:n.title}),t[17]=n.title,t[18]=b);let x=_?(0,M.jsx)(`p`,{className:`mt-1 break-all text-xs text-fg-muted`,children:_}):null,S;t[19]!==b||t[20]!==x?(S=(0,M.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[b,x]}),t[19]=b,t[20]=x,t[21]=S):S=t[21];let C;t[22]!==y||t[23]!==S?(C=(0,M.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-2`,children:[y,S]}),t[22]=y,t[23]=S,t[24]=C):C=t[24];let w;t[25]!==n.kind||t[26]!==i?(w=Ce(n.kind,i),t[25]=n.kind,t[26]=i,t[27]=w):w=t[27];let T;t[28]===w?T=t[29]:(T=(0,M.jsx)(`span`,{className:`rounded-full border border-edge px-2 py-0.5 text-xs text-fg-muted`,children:w}),t[28]=w,t[29]=T),t[30]!==C||t[31]!==T?(p=(0,M.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[C,T]}),t[30]=C,t[31]=T,t[32]=p):p=t[32],m=a?(0,M.jsx)(`pre`,{className:`mt-2 overflow-x-auto rounded-md bg-surface-panel px-2 py-1.5 text-xs text-fg`,children:(0,M.jsx)(`code`,{children:a})}):null,t[33]!==n.kind||t[34]!==n.summary?(h=n.summary?n.kind===`diff`?(0,M.jsx)(`pre`,{className:`mt-2 max-h-56 overflow-auto whitespace-pre-wrap rounded-md bg-surface-panel px-2 py-1.5 text-xs text-fg-muted`,children:(0,M.jsx)(`code`,{children:n.summary})}):(0,M.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap break-words text-xs text-fg-muted`,children:n.summary}):null,t[33]=n.kind,t[34]=n.summary,t[35]=h):h=t[35],c=`mt-2 flex flex-wrap items-center gap-2 text-xs text-fg-muted`;let E;t[36]!==n.createdAt||t[37]!==r||t[38]!==i?(E=L(n.createdAt,r,i),t[36]=n.createdAt,t[37]=r,t[38]=i,t[39]=E):E=t[39],t[40]===E?l=t[41]:(l=(0,M.jsx)(`time`,{children:E}),t[40]=E,t[41]=l),u=g==null?null:(0,M.jsx)(`span`,{children:F(i.exitCode,{code:g})}),d=v==null?null:(0,M.jsx)(`span`,{children:F(i.outputBytes,{bytes:v})}),t[2]=o,t[3]=n,t[4]=r,t[5]=i,t[6]=s,t[7]=c,t[8]=l,t[9]=u,t[10]=d,t[11]=f,t[12]=p,t[13]=m,t[14]=h}else s=t[6],c=t[7],l=t[8],u=t[9],d=t[10],f=t[11],p=t[12],m=t[13],h=t[14];let g;t[42]!==s||t[43]!==i?(g=s?(0,M.jsx)(`span`,{children:i.fuzzyMatch}):null,t[42]=s,t[43]=i,t[44]=g):g=t[44];let _;t[45]!==g||t[46]!==c||t[47]!==l||t[48]!==u||t[49]!==d?(_=(0,M.jsxs)(`div`,{className:c,children:[l,u,d,g]}),t[45]=g,t[46]=c,t[47]=l,t[48]=u,t[49]=d,t[50]=_):_=t[50];let v;return t[51]!==_||t[52]!==f||t[53]!==p||t[54]!==m||t[55]!==h?(v=(0,M.jsxs)(`li`,{className:f,children:[p,m,h,_]}),t[51]=_,t[52]=f,t[53]=p,t[54]=m,t[55]=h,t[56]=v):v=t[56],v}function he(e){return e===`active`?`border-accent/40 bg-accent-soft text-accent-fg`:e===`done`?`border-edge bg-surface-muted text-fg-muted`:e===`blocked`||e===`needs_input`?`border-amber-500/40 bg-amber-500/10 text-amber-700 dark:text-amber-300`:`border-edge bg-surface-panel text-fg-muted`}function ge(e){return e===`succeeded`?`border-emerald-500/40 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e===`failed`||e===`timeout`?`border-destructive/40 bg-destructive/10 text-destructive`:e===`cancelled`?`border-amber-500/40 bg-amber-500/10 text-amber-700 dark:text-amber-300`:`border-accent/40 bg-accent-soft text-accent-fg`}function _e(e){return e===`workflow_run`?re:e===`goal_run`?se:e===`queue`?ee:e===`evidence`?C:le}function F(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,String(n)),e)}function I(e){return e===`zh`?`zh-CN`:`en-US`}function L(e,t,n){return e?new Intl.DateTimeFormat(I(t),{dateStyle:`medium`,timeStyle:`short`}).format(new Date(e)):n.notSet}function ve(e,t,n){return e?new Intl.DateTimeFormat(I(t),{dateStyle:`medium`}).format(new Date(e)):n.noDeadline}function ye(e,t){return e===`blocked`||e===`needs_input`?t.primaryActions.resolveBlocker:e===`paused`?t.primaryActions.resume:e===`done`?t.primaryActions.completed:e===`archived`?t.primaryActions.archived:t.primaryActions.continue}function be(e){return e===`completed`?`✓`:e===`impossible`?`!`:`○`}function xe(e){return e===`all`||e===`queue`||e===`goal_run`||e===`workflow_run`||e===`event`||e===`evidence`}function R(e,t){return e?t.statuses[e]??e:``}function Se(e,t){return t.priorities[e]??e}function Ce(e,t){return t.evidenceKinds[e]??e}async function we(e){return(await c(s(`/api/goals/${encodeURIComponent(e)}`))).goal}async function Te(e){return(await c(s(`/api/goals/${encodeURIComponent(e)}/runs?limit=100`))).runs}async function Ee(e){return(await c(s(`/api/goals/${encodeURIComponent(e)}/evidence?limit=100`))).evidence}async function De(e){return(await c(s(`/api/goals/${encodeURIComponent(e)}/activity?limit=120`))).activities}async function Oe(e){return(await c(s(`/api/goals/${encodeURIComponent(e)}/workflow-suggestions`))).suggestions}function z(){let{goalId:e=``}=p(),t=w(),n=o(e=>e.language),r=a(n).goalDetailPage,g=ae(e=>e.setPageHeader),b=ae(e=>e.clearPageHeader),[C,se]=u(),[k,A]=(0,j.useState)(null),[de,fe]=(0,j.useState)([]),[P,pe]=(0,j.useState)([]),[I,z]=(0,j.useState)([]),[ke,Ae]=(0,j.useState)([]),[je,Me]=(0,j.useState)([]),[Ne,B]=(0,j.useState)([]),[V,Pe]=(0,j.useState)(``),[Fe,Ie]=(0,j.useState)(`message`),[H,Le]=(0,j.useState)(``),[Re,ze]=(0,j.useState)(``),[Be,Ve]=(0,j.useState)(``),[He,Ue]=(0,j.useState)(``),[We,Ge]=(0,j.useState)(``),[Ke,qe]=(0,j.useState)(`normal`),[Je,Ye]=(0,j.useState)(``),[Xe,Ze]=(0,j.useState)(`10`),[Qe,$e]=(0,j.useState)(``),[et,tt]=(0,j.useState)(``),[nt,rt]=(0,j.useState)(``),[U,it]=(0,j.useState)(``),[at,ot]=(0,j.useState)(``),[W,st]=(0,j.useState)(!0),[G,K]=(0,j.useState)(null),[ct,q]=(0,j.useState)(null),J=(0,j.useCallback)(async()=>{if(e){st(!0),q(null);try{let[t,n,r]=await Promise.all([we(e),Te(e),Ee(e)]);A(t),fe(n);let[i,a]=await Promise.all([v(e,50),De(e)]);z(i),B(a),Ae(await Oe(e)),Me(r)}catch(e){q(e instanceof Error?e.message:r.errors.load)}finally{st(!1)}}},[e,r.errors.load]);(0,j.useEffect)(()=>{J()},[J]),(0,j.useEffect)(()=>{let e=!1;return oe().then(t=>{e||(pe(t),it(e=>e||t[0]?.id||``))}).catch(t=>{e||q(t instanceof Error?t.message:r.errors.loadWorkflows)}),()=>{e=!0}},[r.errors.loadWorkflows]),(0,j.useEffect)(()=>{k&&(Ue(k.title),Ge(k.description??``),qe(k.priority),Ye(k.deadlineAt?new Date(k.deadlineAt).toISOString().slice(0,10):``),Ze(String(k.maxTurns)),$e(k.judgeModelRef??``),tt(k.nextAction??``),rt(k.blockedReason??``),ot(e=>e||k.nextAction||k.title))},[k?.id,k?.updatedAt]);let lt=async()=>{if(k){K(`continue`);try{let e=await c(s(`/api/goals/${encodeURIComponent(k.id)}/continue`),{method:`POST`,body:JSON.stringify({})});if(e.sessionKey){t(`/chat/${encodeURIComponent(e.sessionKey)}`);return}await J()}catch(e){q(e instanceof Error?e.message:r.errors.continue)}finally{K(null)}}},ut=async e=>{if(e.preventDefault(),!k)return;let t=He.trim();if(t){K(`details:save`),q(null);try{let e=Number.parseInt(Xe,10);A((await c(s(`/api/goals/${encodeURIComponent(k.id)}`),{method:`PATCH`,body:JSON.stringify({title:t,description:We.trim()||void 0,priority:Ke,deadlineAt:Je?new Date(`${Je}T23:59:59`).getTime():void 0,maxTurns:Number.isFinite(e)?e:k.maxTurns,judgeModelRef:Qe.trim()||void 0,nextAction:et.trim()||void 0,blockedReason:nt.trim()||void 0})})).goal),await Y(k.id)}catch(e){q(e instanceof Error?e.message:r.errors.save)}finally{K(null)}}},dt=async e=>{if(k){K(e);try{await c(s(`/api/goals/${encodeURIComponent(k.id)}/${e}`),{method:`POST`,body:JSON.stringify({})}),await J()}catch(e){q(e instanceof Error?e.message:r.errors.action)}finally{K(null)}}},ft=async()=>{if(!(!k||!U)){K(`workflow:run`),q(null);try{let e=await y({goalId:k.id,definitionId:U,goal:at.trim()||k.nextAction||k.title});await J(),t(`/chat/${encodeURIComponent(e.sessionKey)}`)}catch(e){q(e instanceof Error?e.message:r.errors.startWorkflow)}finally{K(null)}}},Y=async e=>{try{B(await De(e))}catch{}},pt=async e=>{try{let[t,n,r]=await Promise.all([v(e,50),De(e),Oe(e)]);z(t),B(n),Ae(r)}catch{}},mt=async e=>{if(k){K(`workflow:${e.id}:cancel`),q(null);try{await x(e.id,{ownerAgentId:k.agentId}),await pt(k.id)}catch(e){q(e instanceof Error?e.message:r.errors.cancelWorkflow)}finally{K(null)}}},ht=async e=>{if(k){K(`workflow:${e.id}:retry`),q(null);try{let n=await _(e.id,{ownerAgentId:k.agentId});await pt(k.id),t(`/chat/${encodeURIComponent(n.sessionKey)}`)}catch(e){q(e instanceof Error?e.message:r.errors.retryWorkflow)}finally{K(null)}}},gt=async e=>{if(e.preventDefault(),!k)return;let t=V.trim();if(t){K(`checklist:add`),q(null);try{A((await c(s(`/api/goals/${encodeURIComponent(k.id)}/checklist`),{method:`POST`,body:JSON.stringify({text:t})})).goal),Pe(``),await Y(k.id)}catch(e){q(e instanceof Error?e.message:r.errors.addChecklist)}finally{K(null)}}},_t=async(e,t)=>{if(k){K(`checklist:${e}:${t}`),q(null);try{A((await c(s(`/api/goals/${encodeURIComponent(k.id)}/checklist/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify({status:t})})).goal),await Y(k.id)}catch(e){q(e instanceof Error?e.message:r.errors.updateChecklist)}finally{K(null)}}},vt=async e=>{if(k){K(`checklist:${e}:delete`),q(null);try{A((await c(s(`/api/goals/${encodeURIComponent(k.id)}/checklist/${encodeURIComponent(e)}`),{method:`DELETE`})).goal),await Y(k.id)}catch(e){q(e instanceof Error?e.message:r.errors.deleteChecklist)}finally{K(null)}}},yt=async e=>{if(e.preventDefault(),!k)return;let t=H.trim();if(t){K(`evidence:add`),q(null);try{let e=await c(s(`/api/goals/${encodeURIComponent(k.id)}/evidence`),{method:`POST`,body:JSON.stringify({kind:Fe,title:t,summary:Re.trim()||void 0,uri:Be.trim()||void 0})});Me(t=>[e.evidence,...t]),Le(``),ze(``),Ve(``),await Y(k.id)}catch(e){q(e instanceof Error?e.message:r.errors.addEvidence)}finally{K(null)}}},X=k?.checklist.filter(e=>e.status===`completed`||e.status===`impossible`).length??0,Z=k?.checklist.length??0,bt=I.filter(e=>e.status===`failed`||e.status===`timeout`||e.status===`cancelled`),Q=de[0],$=xe(C.get(`timeline`))?C.get(`timeline`):`all`,xt=$===`all`?Ne:Ne.filter(e=>e.kind===$),St=I.filter(e=>e.status===`queued`||e.status===`running`),Ct=G!=null||k?.status===`done`||k?.status===`archived`,wt=(0,j.useMemo)(()=>k?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(D,{type:`button`,variant:`primary`,className:`h-9 gap-2 rounded-lg px-2.5 md:px-3`,"aria-label":ye(k.status,r),disabled:Ct,onClick:()=>void lt(),children:[(0,M.jsx)(ee,{className:`size-4`,"aria-hidden":!0}),(0,M.jsx)(`span`,{className:`hidden md:inline`,children:ye(k.status,r)})]}),k.activeSessionKey?(0,M.jsxs)(D,{type:`button`,variant:`secondary`,className:`h-9 gap-2 rounded-lg px-2.5 md:px-3`,"aria-label":r.chat,onClick:()=>t(`/chat/${encodeURIComponent(k.activeSessionKey)}`),children:[(0,M.jsx)(O,{className:`size-4`,"aria-hidden":!0}),(0,M.jsx)(`span`,{className:`hidden md:inline`,children:r.chat})]}):null,(0,M.jsxs)(D,{type:`button`,variant:`secondary`,className:`h-9 gap-2 rounded-lg px-2.5 md:px-3`,"aria-label":r.pause,disabled:G!=null||k.status!==`active`,onClick:()=>void dt(`pause`),children:[(0,M.jsx)(E,{className:`size-4`,"aria-hidden":!0}),(0,M.jsx)(`span`,{className:`hidden md:inline`,children:r.pause})]}),(0,M.jsxs)(D,{type:`button`,variant:`ghost`,className:`h-9 gap-2 rounded-lg px-2.5 md:px-3`,"aria-label":r.archive,disabled:G!=null||k.status===`archived`,onClick:()=>{window.confirm(r.archiveConfirm)&&dt(`archive`)},children:[(0,M.jsx)(ce,{className:`size-4`,"aria-hidden":!0}),(0,M.jsx)(`span`,{className:`hidden md:inline`,children:r.archive})]})]}):null,[G,k,t,Ct,r]);(0,j.useLayoutEffect)(()=>(g({startExtra:(0,M.jsx)(S,{to:`/goals`,className:`inline-flex size-9 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover hover:text-fg`,"aria-label":r.back,children:(0,M.jsx)(ie,{className:`size-4`,"aria-hidden":!0})}),main:(0,M.jsxs)(`div`,{className:`min-w-0`,children:[(0,M.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:k?.title??(W?r.loading:r.notFound)}),k?(0,M.jsxs)(`p`,{className:`truncate text-xs text-fg-muted`,children:[R(k.status,r),` · `,F(r.agent,{agentId:k.agentId}),` · `,F(r.turns,{used:k.turnsUsed,max:k.maxTurns}),Z?` · ${F(r.checklistProgress,{done:X,total:Z})}`:``]}):null]}),end:wt}),()=>b()),[b,X,k,wt,W,g,r,Z]);let Tt=e=>{let t=new URLSearchParams(C);e===`all`?t.delete(`timeline`):t.set(`timeline`,e),se(t,{replace:!0})};return(0,M.jsx)(`main`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto bg-surface-base`,children:(0,M.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-1 flex-col gap-4 px-4 py-5 sm:px-6`,children:[W?(0,M.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.loading}):null,ct?(0,M.jsx)(`p`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:ct}):null,!W&&!k?(0,M.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.notFound}):null,k?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-panel p-4`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,M.jsx)(`span`,{className:i(`rounded-full border px-2 py-0.5 text-xs`,he(k.status)),children:R(k.status,r)}),(0,M.jsx)(`span`,{className:`text-xs text-fg-muted`,children:F(r.prioritySummary,{priority:Se(k.priority,r)})}),(0,M.jsx)(`span`,{className:`text-xs text-fg-muted`,children:k.deadlineAt?ve(k.deadlineAt,n,r):r.noDeadline})]}),k.description?(0,M.jsx)(`p`,{className:`mt-3 whitespace-pre-wrap break-words text-sm text-fg-muted`,children:k.description}):null,(0,M.jsxs)(`div`,{className:`mt-3 rounded-md border border-edge/70 bg-surface-muted/40 px-3 py-2`,children:[(0,M.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:k.blockedReason?r.currentBlocker:r.nextAction}),(0,M.jsx)(`p`,{className:i(`mt-1 break-words text-sm`,k.blockedReason?`text-amber-700 dark:text-amber-300`:`text-fg`),children:k.blockedReason||k.nextAction||r.noNextAction})]})]}),(0,M.jsxs)(`section`,{className:`grid gap-4 xl:grid-cols-[minmax(0,1fr)_22rem]`,children:[(0,M.jsxs)(`div`,{className:`grid min-w-0 gap-4`,children:[(0,M.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-panel p-4`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,M.jsx)(l,{className:`size-4 text-accent`,"aria-hidden":!0}),r.acceptance]}),(0,M.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r.acceptanceHint})]}),(0,M.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[X,`/`,Z]})]}),Q?(0,M.jsxs)(`div`,{className:`mt-3 rounded-md border border-edge/70 bg-surface-muted/40 px-3 py-2`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 text-xs text-fg-muted`,children:[(0,M.jsx)(`span`,{children:F(r.latestJudgement,{status:R(Q.verdict??Q.status,r)})}),(0,M.jsx)(`time`,{children:L(Q.finishedAt??Q.startedAt,n,r)})]}),Q.reason?(0,M.jsx)(`p`,{className:`mt-1 break-words text-sm text-fg`,children:Q.reason}):null,Q.nextAction?(0,M.jsx)(`p`,{className:`mt-1 break-words text-xs text-fg-muted`,children:F(r.latestNext,{next:Q.nextAction})}):null]}):null,(0,M.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,M.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,M.jsx)(l,{className:`size-4 text-accent`,"aria-hidden":!0}),r.checklist]}),(0,M.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[X,`/`,Z]})]}),(0,M.jsxs)(`form`,{className:`mb-3 flex flex-col gap-2 sm:flex-row`,onSubmit:gt,children:[(0,M.jsx)(`input`,{value:V,onChange:e=>Pe(e.target.value),name:`checklistText`,"aria-label":r.addAcceptancePlaceholder,autoComplete:`off`,placeholder:r.addAcceptancePlaceholder,className:i(N,`flex-1`)}),(0,M.jsxs)(D,{type:`submit`,variant:`secondary`,className:`h-9 gap-2`,disabled:G!=null||!V.trim(),children:[(0,M.jsx)(d,{className:`size-4`,"aria-hidden":!0}),r.add]})]}),k.checklist.length?(0,M.jsx)(`ul`,{className:`space-y-2 text-sm`,children:k.checklist.map(e=>(0,M.jsx)(`li`,{className:`rounded-md border border-edge/70 bg-surface-muted/40 px-2.5 py-2`,children:(0,M.jsxs)(`div`,{className:`flex flex-wrap items-start gap-2`,children:[(0,M.jsx)(`span`,{className:`mt-1 w-5 shrink-0 text-center text-fg-muted`,children:be(e.status)}),(0,M.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,M.jsx)(`p`,{className:`break-words text-fg`,children:e.text}),e.evidenceSummary?(0,M.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.evidenceSummary}):null]}),(0,M.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,M.jsx)(D,{type:`button`,variant:`ghost`,className:`size-8 p-0`,title:r.markPending,"aria-label":r.markPending,disabled:G!=null||e.status===`pending`,onClick:()=>void _t(e.id,`pending`),children:(0,M.jsx)(T,{className:`size-4`,"aria-hidden":!0})}),(0,M.jsx)(D,{type:`button`,variant:`ghost`,className:`size-8 p-0`,title:r.markCompleted,"aria-label":r.markCompleted,disabled:G!=null||e.status===`completed`,onClick:()=>void _t(e.id,`completed`),children:(0,M.jsx)(te,{className:`size-4`,"aria-hidden":!0})}),(0,M.jsx)(D,{type:`button`,variant:`ghost`,className:`size-8 p-0`,title:r.markImpossible,"aria-label":r.markImpossible,disabled:G!=null||e.status===`impossible`,onClick:()=>void _t(e.id,`impossible`),children:(0,M.jsx)(m,{className:`size-4`,"aria-hidden":!0})}),(0,M.jsx)(D,{type:`button`,variant:`ghost`,className:`size-8 p-0 text-destructive hover:text-destructive`,title:r.deleteChecklistItem,"aria-label":r.deleteChecklistItem,disabled:G!=null,onClick:()=>void vt(e.id),children:(0,M.jsx)(h,{className:`size-4`,"aria-hidden":!0})})]})]})},e.id))}):(0,M.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.noChecklist}),(0,M.jsxs)(`div`,{className:`mt-4 border-t border-edge pt-4`,children:[(0,M.jsxs)(`h3`,{className:`mb-3 flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,M.jsx)(f,{className:`size-4 text-accent`,"aria-hidden":!0}),r.evidence]}),(0,M.jsxs)(`form`,{className:`mb-3 grid gap-2`,onSubmit:yt,children:[(0,M.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-[9rem_minmax(0,1fr)]`,children:[(0,M.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.kind,(0,M.jsx)(`select`,{value:Fe,onChange:e=>Ie(e.target.value),className:N,name:`evidenceKind`,children:ue.map(e=>(0,M.jsx)(`option`,{value:e,children:Ce(e,r)},e))})]}),(0,M.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.title,(0,M.jsx)(`input`,{value:H,onChange:e=>Le(e.target.value),name:`evidenceTitle`,autoComplete:`off`,placeholder:r.evidenceTitlePlaceholder,className:N})]})]}),(0,M.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.uriOrPath,(0,M.jsx)(`input`,{value:Be,onChange:e=>Ve(e.target.value),name:`evidenceUri`,autoComplete:`off`,placeholder:r.uriOrPathPlaceholder,className:N})]}),(0,M.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.summary,(0,M.jsx)(`textarea`,{value:Re,onChange:e=>ze(e.target.value),name:`evidenceSummary`,autoComplete:`off`,placeholder:r.summaryPlaceholder,rows:3,className:i(N,`resize-y`)})]}),(0,M.jsxs)(D,{type:`submit`,variant:`secondary`,className:`h-9 w-fit gap-2`,disabled:G!=null||!H.trim(),children:[(0,M.jsx)(d,{className:`size-4`,"aria-hidden":!0}),r.addEvidence]})]}),je.length?(0,M.jsx)(`ul`,{className:`space-y-2 text-sm`,children:je.slice(0,6).map(e=>(0,M.jsx)(me,{item:e,language:n,t:r},e.id))}):(0,M.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.noEvidence})]})]}),(0,M.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-panel p-4`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,M.jsx)(le,{className:`size-4 text-accent`,"aria-hidden":!0}),r.timeline]}),(0,M.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r.timelineHint})]}),(0,M.jsxs)(D,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5`,onClick:()=>void J(),children:[(0,M.jsx)(ne,{className:`size-3.5`,"aria-hidden":!0}),r.refresh]})]}),(0,M.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[`all`,`goal_run`,`workflow_run`,`evidence`,`queue`,`event`].map(e=>(0,M.jsx)(`button`,{type:`button`,className:i(`rounded-md border px-2.5 py-1 text-xs font-medium`,$===e?`border-accent bg-accent-soft text-accent-fg`:`border-edge bg-surface-panel text-fg-muted hover:bg-surface-hover hover:text-fg`),onClick:()=>Tt(e),children:r.timelineFilters[e]},e))}),xt.length?(0,M.jsx)(`ul`,{className:`mt-3 space-y-2 text-sm`,children:xt.map(e=>(0,M.jsx)(`li`,{className:`rounded-md border border-edge/60 bg-surface-muted/50 px-2.5 py-2`,children:(0,M.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,M.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-2`,children:[(0,M.jsx)(_e(e.kind),{className:`mt-0.5 size-4 shrink-0 text-accent-fg`,"aria-hidden":!0}),(0,M.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-fg-muted`,children:[(0,M.jsx)(`span`,{children:r.timelineFilters[e.kind]}),e.status?(0,M.jsx)(`span`,{children:R(e.status,r)}):null]}),(0,M.jsx)(`p`,{className:`mt-1 break-words font-medium text-fg`,children:e.title}),e.summary?(0,M.jsx)(`p`,{className:`mt-1 line-clamp-3 break-words text-xs text-fg-muted`,children:e.summary}):null]})]}),(0,M.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-1 text-xs text-fg-muted`,children:[(0,M.jsx)(`time`,{children:L(e.createdAt,n,r)}),e.link?.type===`chat`?(0,M.jsxs)(D,{type:`button`,variant:`ghost`,className:`h-7 gap-1.5`,onClick:()=>t(`/chat/${encodeURIComponent(e.link.value)}`),children:[(0,M.jsx)(O,{className:`size-3.5`,"aria-hidden":!0}),r.chat]}):null,e.link?.type===`workflow_run`?(0,M.jsxs)(D,{type:`button`,variant:`ghost`,className:`h-7 gap-1.5`,onClick:()=>t(`/workflows?run=${encodeURIComponent(e.link.value)}`),children:[(0,M.jsx)(O,{className:`size-3.5`,"aria-hidden":!0}),r.run]}):null]})]})},e.id))}):(0,M.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:r.noTimeline})]})]}),(0,M.jsxs)(`aside`,{className:`grid h-fit gap-4`,children:[(0,M.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-panel p-4`,children:[(0,M.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:r.goalSettings}),(0,M.jsxs)(`dl`,{className:`mt-3 grid gap-2 text-sm`,children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,M.jsx)(`dt`,{className:`text-fg-muted`,children:r.deadline}),(0,M.jsx)(`dd`,{className:`text-right text-fg`,children:ve(k.deadlineAt,n,r)})]}),(0,M.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,M.jsx)(`dt`,{className:`text-fg-muted`,children:r.judgeModel}),(0,M.jsx)(`dd`,{className:`min-w-0 truncate text-right text-fg`,children:k.judgeModelRef||r.default})]}),(0,M.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,M.jsx)(`dt`,{className:`text-fg-muted`,children:r.created}),(0,M.jsx)(`dd`,{className:`text-right text-fg`,children:ve(k.createdAt,n,r)})]}),(0,M.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,M.jsx)(`dt`,{className:`text-fg-muted`,children:r.updated}),(0,M.jsx)(`dd`,{className:`text-right text-fg`,children:L(k.updatedAt,n,r)})]})]}),(0,M.jsxs)(`details`,{className:`mt-4 rounded-md border border-edge/70 bg-surface-muted/40 px-3 py-2`,children:[(0,M.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:r.editDetails}),(0,M.jsxs)(`form`,{className:`mt-3 grid gap-3`,onSubmit:ut,children:[(0,M.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.title,(0,M.jsx)(`input`,{value:He,onChange:e=>Ue(e.target.value),name:`goalTitle`,autoComplete:`off`,className:N,placeholder:`${r.title}…`})]}),(0,M.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.description,(0,M.jsx)(`textarea`,{value:We,onChange:e=>Ge(e.target.value),name:`goalDescription`,autoComplete:`off`,className:i(N,`resize-y`),rows:3,placeholder:`${r.description}…`})]}),(0,M.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-3 xl:grid-cols-1`,children:[(0,M.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.priority,(0,M.jsxs)(`select`,{value:Ke,onChange:e=>qe(e.target.value),name:`goalPriority`,className:N,children:[(0,M.jsx)(`option`,{value:`low`,children:r.priorities.low}),(0,M.jsx)(`option`,{value:`normal`,children:r.priorities.normal}),(0,M.jsx)(`option`,{value:`high`,children:r.priorities.high})]})]}),(0,M.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.deadline,(0,M.jsx)(`input`,{value:Je,onChange:e=>Ye(e.target.value),name:`goalDeadline`,className:N,type:`date`})]}),(0,M.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.maxTurns,(0,M.jsx)(`input`,{value:Xe,onChange:e=>Ze(e.target.value),name:`goalMaxTurns`,className:N,type:`number`,min:1,max:500,inputMode:`numeric`,placeholder:`${r.maxTurns}…`})]})]}),(0,M.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.judgeModel,(0,M.jsx)(`input`,{value:Qe,onChange:e=>$e(e.target.value),name:`goalJudgeModel`,autoComplete:`off`,className:N,placeholder:`${r.judgeModel}…`})]}),(0,M.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.nextAction,(0,M.jsx)(`textarea`,{value:et,onChange:e=>tt(e.target.value),name:`goalNextAction`,autoComplete:`off`,className:i(N,`resize-y`),rows:2,placeholder:`${r.nextAction}…`})]}),(0,M.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.blockedReason,(0,M.jsx)(`textarea`,{value:nt,onChange:e=>rt(e.target.value),name:`goalBlockedReason`,autoComplete:`off`,className:i(N,`resize-y`),rows:2,placeholder:`${r.blockedReason}…`})]}),(0,M.jsx)(D,{type:`submit`,variant:`secondary`,className:`h-9 w-fit`,disabled:G!=null||!He.trim(),children:r.saveDetails})]})]})]}),(0,M.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-panel p-4`,children:[(0,M.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,M.jsx)(re,{className:`size-4 text-accent`,"aria-hidden":!0}),r.workflow]}),(0,M.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r.workflowHint})]}),St.length?(0,M.jsx)(`span`,{className:`rounded-full border border-accent/40 bg-accent-soft px-2 py-0.5 text-xs text-accent-fg`,children:F(r.activeCount,{count:St.length})}):null]}),ke.length?(0,M.jsx)(`div`,{className:`mt-3 grid gap-2`,children:ke.slice(0,2).map(e=>(0,M.jsxs)(`button`,{type:`button`,className:i(`min-w-0 rounded-md border border-edge/70 bg-surface-muted/40 px-2.5 py-2 text-left hover:border-accent/60 hover:bg-accent-soft/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,U===e.definitionId&&`border-accent/70 bg-accent-soft/60`),onClick:()=>{it(e.definitionId),ot(k.nextAction||k.title)},children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,M.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.title}),(0,M.jsx)(`span`,{className:`shrink-0 rounded-full border border-edge px-2 py-0.5 text-xs text-fg-muted`,children:e.score})]}),(0,M.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs text-fg-muted`,children:e.description})]},e.definitionId))}):null,(0,M.jsxs)(`div`,{className:`mt-3 grid gap-2`,children:[(0,M.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.definition,(0,M.jsxs)(`select`,{value:U,onChange:e=>it(e.target.value),className:N,name:`workflowDefinition`,disabled:P.length===0,children:[P.length===0?(0,M.jsx)(`option`,{value:``,children:r.noWorkflows}):null,P.map(e=>(0,M.jsx)(`option`,{value:e.id,children:e.title||e.name},e.id))]})]}),(0,M.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.workflowGoal,(0,M.jsx)(`input`,{value:at,onChange:e=>ot(e.target.value),name:`workflowGoal`,autoComplete:`off`,className:N,placeholder:`${r.workflowGoal}…`})]}),(0,M.jsxs)(D,{type:`button`,variant:`secondary`,className:`h-9 w-fit gap-2`,disabled:G!=null||!U||k.status===`done`||k.status===`archived`,onClick:()=>void ft(),children:[(0,M.jsx)(ee,{className:`size-4`,"aria-hidden":!0}),r.runWorkflow]})]}),I.length?(0,M.jsxs)(`div`,{className:`mt-4 border-t border-edge pt-3`,children:[(0,M.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,M.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:r.recentWorkflowRuns}),(0,M.jsx)(`button`,{type:`button`,className:`text-xs text-fg-muted hover:text-accent focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:()=>Tt(`workflow_run`),children:r.viewTimeline})]}),(0,M.jsx)(`ul`,{className:`grid gap-2`,children:I.slice(0,3).map(e=>{let a=e.metadata?.sessionKey,o=e.status===`queued`||e.status===`running`,s=e.status===`failed`||e.status===`timeout`||e.status===`cancelled`;return(0,M.jsxs)(`li`,{className:`rounded-md border border-edge/70 bg-surface-muted/40 px-2.5 py-2 text-sm`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 text-xs text-fg-muted`,children:[(0,M.jsx)(`span`,{className:`min-w-0 truncate`,children:e.definitionId}),(0,M.jsx)(`span`,{className:i(`shrink-0 rounded-full border px-2 py-0.5`,ge(e.status)),children:R(e.status,r)})]}),(0,M.jsx)(`p`,{className:`mt-1 truncate text-fg`,children:e.title}),(0,M.jsx)(`time`,{className:`mt-1 block text-xs text-fg-muted`,children:L(e.completedAtMs??e.startedAtMs??e.createdAtMs,n,r)}),(0,M.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[a?(0,M.jsxs)(D,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5`,onClick:()=>t(`/chat/${encodeURIComponent(a)}`),children:[(0,M.jsx)(O,{className:`size-3.5`,"aria-hidden":!0}),r.chat]}):null,o?(0,M.jsxs)(D,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5 text-destructive hover:text-destructive`,disabled:G!=null,onClick:()=>void mt(e),children:[(0,M.jsx)(m,{className:`size-3.5`,"aria-hidden":!0}),r.cancel]}):null,s?(0,M.jsxs)(D,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5`,disabled:G!=null,onClick:()=>void ht(e),children:[(0,M.jsx)(ne,{className:`size-3.5`,"aria-hidden":!0}),r.retry]}):null]})]},e.id)})})]}):null,bt.length?(0,M.jsxs)(`div`,{className:`mt-4 rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-2`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,M.jsx)(`p`,{className:`text-sm font-medium text-amber-800 dark:text-amber-200`,children:r.recoveryNeeded}),(0,M.jsx)(`span`,{className:`text-xs text-amber-700 dark:text-amber-300`,children:F(r.failedCount,{count:bt.length})})]}),(0,M.jsx)(`ul`,{className:`mt-2 grid gap-2`,children:bt.slice(0,3).map(e=>(0,M.jsxs)(`li`,{className:`grid gap-2 text-sm`,children:[(0,M.jsxs)(`div`,{className:`min-w-0`,children:[(0,M.jsx)(`p`,{className:`truncate text-fg`,children:e.title}),(0,M.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[e.definitionId,` · `,R(e.status,r)]})]}),(0,M.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[(0,M.jsxs)(D,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5`,onClick:()=>t(`/workflows?run=${encodeURIComponent(e.id)}`),children:[(0,M.jsx)(O,{className:`size-3.5`,"aria-hidden":!0}),r.run]}),(0,M.jsxs)(D,{type:`button`,variant:`secondary`,className:`h-8 gap-1.5`,disabled:G!=null,onClick:()=>void ht(e),children:[(0,M.jsx)(ne,{className:`size-3.5`,"aria-hidden":!0}),r.retry]})]})]},e.id))})]}):null]})]})]})]}):null]})})}export{z as GoalDetailPage};
|
|
@@ -0,0 +1,2 @@
|
|
|
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 ee}from"./cn-JdwAhgNB.js";import{t as i}from"./messages-Csef1aW7.js";import{t as a}from"./locale-store-DjbfSsfA.js";import{i as o,n as s}from"./fetch-Bs7in_4F.js";import{$a as c,$r as l,Ea as u,Hi as d,Jr as f,Qr as p,Ss as m,Ts as h,Vo as g,Xo as _,Xr as v,Yo as y,Yr as te,Zo as b,Zr as ne,ba as x,ii as S,ji as C,ki as w,ko as T,pa as E,ra as D,rs as O,ua as k,vs as A,xi as j,ya as M,ys as N}from"./index-COkF54xv.js";var P=n(),F=e(t(),1),I=r(),L=[`active`,`paused`,`blocked`,`needs_input`,`done`,`archived`],R=[`active`,`paused`,`attention`,`done`,`archived`],z=`application/x-xopc-goal-id`;function re(e){let t=e.checklist.length;return{done:e.checklist.filter(e=>e.status===`completed`||e.status===`impossible`).length,total:t}}function ie(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,String(n)),e)}function B(e,t){return new Intl.DateTimeFormat(t===`zh`?`zh-CN`:`en-US`,{dateStyle:`medium`,timeStyle:`short`}).format(new Date(e))}function ae(e,t){return t.statuses[e]??e}function V(e){return e.status===`blocked`||e.status===`needs_input`?`attention`:e.status}function oe(e){return e===`active`?`bg-accent-soft text-accent-fg`:e===`paused`?`bg-surface-hover text-fg-muted`:e===`done`?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e===`archived`?`bg-surface-muted text-fg-subtle`:`bg-amber-500/10 text-amber-700 dark:text-amber-300`}function H(e){return e===`completed`?`✓`:e===`impossible`?`!`:`○`}function U(e){return e.nextRunAt??e.finishedAt??e.startedAt??e.enqueuedAt}function W(e){return e.status===`running`?6:e.status===`retry_waiting`?5:e.status===`queued`?4:e.status===`failed`?3:e.status===`succeeded`?2:1}function G(e){let t=new Map;for(let n of e){let e=t.get(n.goalId);(!e||W(n)>W(e)||W(n)===W(e)&&U(n)>U(e))&&t.set(n.goalId,n)}return t}function se(e){return e===`running`?`bg-accent-soft text-accent-fg`:e===`retry_waiting`||e===`failed`?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:e===`succeeded`?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-surface-hover text-fg-muted`}function ce(e,t){let n=t.trim().toLowerCase();return n?[e.title,e.description,e.nextAction,e.blockedReason,e.latestRun?.reason,...e.checklist.map(e=>e.text)].filter(Boolean).join(`
|
|
2
|
+
`).toLowerCase().includes(n):!0}async function K(){return(await s(o(`/api/goals?${new URLSearchParams({status:L.join(`,`),limit:`500`}).toString()}`))).goals}async function q(){return(await s(o(`/api/goals/queue`))).queue??[]}async function J(e){return(await s(o(`/api/goals`),{method:`POST`,body:JSON.stringify({...e,source:`api`})})).goal}async function le(e,t){await s(o(`/api/goals/${encodeURIComponent(e)}/checklist`),{method:`POST`,body:JSON.stringify({text:t})})}async function Y(e,t){await s(o(`/api/goals/${encodeURIComponent(e)}/${t}`),{method:`POST`,body:JSON.stringify({})})}async function X(e){return(await s(o(`/api/goals/${encodeURIComponent(e)}/continue`),{method:`POST`,body:JSON.stringify({})})).sessionKey}function ue(e){return e.status===`active`?`continue`:e.status===`paused`||e.status===`blocked`||e.status===`needs_input`?`resume`:e.status===`done`?`reopen`:e.status===`archived`?`unarchive`:null}function de(e){return e.status===`active`?[`pause`,`complete`,`archive`]:e.status===`paused`||e.status===`blocked`||e.status===`needs_input`||e.status===`done`?[`archive`]:[]}function Z(e,t){return t.actions[e]}function Q(e){return e===`pause`?_:e===`archive`?A:e===`unarchive`?N:e===`reopen`?M:e===`complete`?b:y}function $(e,t){return V(e)===t?null:t===`active`?e.status===`done`?`reopen`:e.status===`archived`?`unarchive`:`resume`:t===`paused`?e.status===`archived`?`unarchive`:`pause`:t===`done`?`complete`:t===`archived`?`archive`:null}function fe(e){let t=(0,P.c)(107),{goal:n,queueItem:r,t:i,language:a,selected:o,dragging:s,onOpen:c,onDragStart:l,onDragEnd:u}=e,d,f,p,m,h,g,_,v,y,te,b,ne,x,S,C,w,T;if(t[0]!==s||t[1]!==n||t[2]!==a||t[3]!==u||t[4]!==l||t[5]!==c||t[6]!==r||t[7]!==o||t[8]!==i){let e=re(n),E=n.latestRun?.finishedAt??n.updatedAt;g=!0,t[26]!==n.id||t[27]!==l?(_=e=>l(n.id,e),t[26]=n.id,t[27]=l,t[28]=_):_=t[28],v=u;let D=o?`border-accent/70 ring-1 ring-accent/30`:`border-edge`,O=s?`opacity-50`:`hover:border-edge-strong hover:bg-surface-hover/50`;t[29]!==D||t[30]!==O?(y=ee(`group relative overflow-hidden rounded-xl border bg-surface-panel p-3.5 transition-colors`,D,O),t[29]=D,t[30]=O,t[31]=y):y=t[31],b=`button`,t[32]!==n||t[33]!==c?(ne=()=>c(n),t[32]=n,t[33]=c,t[34]=ne):ne=t[34],x=`${i.openDetails}: ${n.title}`,S=o?`true`:void 0,t[35]===Symbol.for(`react.memo_cache_sentinel`)?(C=ee(`w-full text-left`,j.focusRingPanel),t[35]=C):C=t[35];let k;t[36]===n.title?k=t[37]:(k=(0,I.jsx)(`div`,{className:`line-clamp-2 text-sm font-semibold leading-5 text-fg`,children:n.title}),t[36]=n.title,t[37]=k);let A;t[38]===n.agentId?A=t[39]:(A=(0,I.jsx)(`div`,{className:`mt-1 truncate text-[11px] font-medium text-fg-muted`,children:n.agentId}),t[38]=n.agentId,t[39]=A);let M;t[40]!==k||t[41]!==A?(M=(0,I.jsxs)(`div`,{className:`min-w-0`,children:[k,A]}),t[40]=k,t[41]=A,t[42]=M):M=t[42];let N;t[43]===n.status?N=t[44]:(N=ee(`shrink-0 rounded-full px-2 py-0.5 text-[10px] font-semibold shadow-sm`,oe(n.status)),t[43]=n.status,t[44]=N);let P;t[45]!==n.status||t[46]!==i?(P=ae(n.status,i),t[45]=n.status,t[46]=i,t[47]=P):P=t[47];let F;t[48]!==N||t[49]!==P?(F=(0,I.jsx)(`span`,{className:N,children:P}),t[48]=N,t[49]=P,t[50]=F):F=t[50],t[51]!==M||t[52]!==F?(w=(0,I.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-2`,children:[M,F]}),t[51]=M,t[52]=F,t[53]=w):w=t[53];let L;t[54]!==a||t[55]!==E?(L=B(E,a),t[54]=a,t[55]=E,t[56]=L):L=t[56];let R;t[57]===L?R=t[58]:(R=(0,I.jsx)(`span`,{children:L}),t[57]=L,t[58]=R);let z;t[59]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,I.jsx)(`span`,{"aria-hidden":!0,children:`·`}),t[59]=z):z=t[59];let V;t[60]!==n.maxTurns||t[61]!==n.turnsUsed||t[62]!==i.turns?(V=ie(i.turns,{used:n.turnsUsed,max:n.maxTurns}),t[60]=n.maxTurns,t[61]=n.turnsUsed,t[62]=i.turns,t[63]=V):V=t[63];let H;t[64]===V?H=t[65]:(H=(0,I.jsx)(`span`,{children:V}),t[64]=V,t[65]=H);let U=e.total?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,I.jsx)(`span`,{children:ie(i.checklistProgress,{done:e.done,total:e.total})})]}):null;t[66]!==R||t[67]!==H||t[68]!==U?(T=(0,I.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1.5 text-[11px] text-fg-subtle`,children:[R,z,H,U]}),t[66]=R,t[67]=H,t[68]=U,t[69]=T):T=t[69],t[70]!==r||t[71]!==i?(f=r?(0,I.jsx)(`div`,{className:`mt-2.5`,children:(0,I.jsx)(`span`,{className:ee(`rounded-full px-2 py-0.5 text-[11px] font-semibold`,se(r.status)),children:ae(r.status,i)})}):null,t[70]=r,t[71]=i,t[72]=f):f=t[72],t[73]===n.blockedReason?p=t[74]:(p=n.blockedReason?(0,I.jsx)(`p`,{className:`mt-2 line-clamp-2 text-xs text-amber-700 dark:text-amber-300`,children:n.blockedReason}):null,t[73]=n.blockedReason,t[74]=p),t[75]===n.nextAction?m=t[76]:(m=n.nextAction?(0,I.jsx)(`p`,{className:`mt-2 line-clamp-2 text-xs text-fg-muted`,children:n.nextAction}):null,t[75]=n.nextAction,t[76]=m),t[77]!==n.blockedReason||t[78]!==n.latestRun||t[79]!==n.nextAction?(h=!n.blockedReason&&!n.nextAction&&n.latestRun?.reason?(0,I.jsx)(`p`,{className:`mt-2 line-clamp-2 text-xs text-fg-muted`,children:n.latestRun.reason}):null,t[77]=n.blockedReason,t[78]=n.latestRun,t[79]=n.nextAction,t[80]=h):h=t[80],d=`mt-3 flex flex-wrap items-center gap-2 text-[11px] text-fg-subtle`,te=n.checklist.length?(0,I.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 font-medium text-fg-muted`,children:ie(i.checklistProgress,{done:e.done,total:e.total})}):null,t[0]=s,t[1]=n,t[2]=a,t[3]=u,t[4]=l,t[5]=c,t[6]=r,t[7]=o,t[8]=i,t[9]=d,t[10]=f,t[11]=p,t[12]=m,t[13]=h,t[14]=g,t[15]=_,t[16]=v,t[17]=y,t[18]=te,t[19]=b,t[20]=ne,t[21]=x,t[22]=S,t[23]=C,t[24]=w,t[25]=T}else d=t[9],f=t[10],p=t[11],m=t[12],h=t[13],g=t[14],_=t[15],v=t[16],y=t[17],te=t[18],b=t[19],ne=t[20],x=t[21],S=t[22],C=t[23],w=t[24],T=t[25];let E;t[81]!==o||t[82]!==i.openDetails?(E=o?(0,I.jsx)(`span`,{className:`font-medium text-accent-fg`,children:i.openDetails}):null,t[81]=o,t[82]=i.openDetails,t[83]=E):E=t[83];let D;t[84]!==d||t[85]!==E||t[86]!==te?(D=(0,I.jsxs)(`div`,{className:d,children:[te,E]}),t[84]=d,t[85]=E,t[86]=te,t[87]=D):D=t[87];let O;t[88]!==f||t[89]!==p||t[90]!==m||t[91]!==h||t[92]!==D||t[93]!==b||t[94]!==ne||t[95]!==x||t[96]!==S||t[97]!==C||t[98]!==w||t[99]!==T?(O=(0,I.jsxs)(`button`,{type:b,onClick:ne,"aria-label":x,"aria-current":S,className:C,children:[w,T,f,p,m,h,D]}),t[88]=f,t[89]=p,t[90]=m,t[91]=h,t[92]=D,t[93]=b,t[94]=ne,t[95]=x,t[96]=S,t[97]=C,t[98]=w,t[99]=T,t[100]=O):O=t[100];let k;return t[101]!==g||t[102]!==_||t[103]!==v||t[104]!==y||t[105]!==O?(k=(0,I.jsx)(`article`,{draggable:g,onDragStart:_,onDragEnd:v,className:y,children:O}),t[101]=g,t[102]=_,t[103]=v,t[104]=y,t[105]=O,t[106]=k):k=t[106],k}function pe(e){let t=(0,P.c)(17),{goalId:n,action:r,t:ee,busy:i,variant:a,onAction:o}=e,s;t[0]===r?s=t[1]:(s=Q(r),t[0]=r,t[1]=s);let c=s,l=i!=null,u;t[2]!==r||t[3]!==n||t[4]!==o?(u=()=>o(n,r),t[2]=r,t[3]=n,t[4]=o,t[5]=u):u=t[5];let d;t[6]===c?d=t[7]:(d=(0,I.jsx)(c,{className:`size-4`,"aria-hidden":!0}),t[6]=c,t[7]=d);let f;t[8]!==r||t[9]!==ee?(f=Z(r,ee),t[8]=r,t[9]=ee,t[10]=f):f=t[10];let p;return t[11]!==l||t[12]!==u||t[13]!==d||t[14]!==f||t[15]!==a?(p=(0,I.jsxs)(w,{type:`button`,variant:a,className:`h-9 rounded-lg px-3 text-sm`,disabled:l,onClick:u,children:[d,f]}),t[11]=l,t[12]=u,t[13]=d,t[14]=f,t[15]=a,t[16]=p):p=t[16],p}function me(){return{title:``,description:``,checklist:[``,``,``],priority:`normal`,deadline:``,maxTurns:`10`,agentId:``,judgeModelRef:``}}function he(e,t){let n=e.title.trim()||t.createDialog.goalFallback;return t.createDialog.aiChecklistTemplates.map(e=>ie(e,{goal:n}))}function ge(e){let t=new Set,n=[];for(let r of e){let e=r.trim();!e||t.has(e.toLowerCase())||(t.add(e.toLowerCase()),n.push(e))}return n}function _e(e){let t=(0,P.c)(143),{open:n,t:r,busy:i,onClose:a,onCreate:o}=e,[s,c]=(0,F.useState)(ye),[m,h]=(0,F.useState)(!1),[g,_]=(0,F.useState)(null),y,b;t[0]===n?(y=t[1],b=t[2]):(y=()=>{n||(c(me()),h(!1),_(null))},b=[n],t[0]=n,t[1]=y,t[2]=b),(0,F.useEffect)(y,b);let x;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(x=e=>c(t=>({...t,...e})),t[3]=x):x=t[3];let S=x,T;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(T=(e,t)=>{c(n=>({...n,checklist:n.checklist.map((n,r)=>r===e?t:n)}))},t[4]=T):T=t[4];let E=T,A;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(A=e=>{c(t=>({...t,checklist:t.checklist.filter((t,n)=>n!==e)}))},t[5]=A):A=t[5];let j=A,M;t[6]!==s||t[7]!==a||t[8]!==o||t[9]!==r.createDialog.titleRequired||t[10]!==r.errors?(M=async()=>{if(_(null),!s.title.trim()){_(r.createDialog.titleRequired);return}try{await o({...s,checklist:ge(s.checklist)}),a()}catch(e){let t=e;_(t instanceof Error?t.message:r.errors.create)}},t[6]=s,t[7]=a,t[8]=o,t[9]=r.createDialog.titleRequired,t[10]=r.errors,t[11]=M):M=t[11];let N=M,L;t[12]===a?L=t[13]:(L=e=>!e&&a(),t[12]=a,t[13]=L);let R;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,I.jsx)(v,{className:`xopc-dialog-overlay fixed inset-0 z-65 bg-scrim backdrop-blur-[1px]`}),t[14]=R):R=t[14];let z;t[15]===r.createDialog.title?z=t[16]:(z=(0,I.jsx)(l,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:r.createDialog.title}),t[15]=r.createDialog.title,t[16]=z);let re;t[17]===r.createDialog.description?re=t[18]:(re=(0,I.jsx)(te,{className:`mt-1 truncate text-sm text-fg-muted`,children:r.createDialog.description}),t[17]=r.createDialog.description,t[18]=re);let B;t[19]!==re||t[20]!==z?(B=(0,I.jsxs)(`div`,{className:`min-w-0`,children:[z,re]}),t[19]=re,t[20]=z,t[21]=B):B=t[21];let ae;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,I.jsx)(C,{className:`size-5`,"aria-hidden":!0}),t[22]=ae):ae=t[22];let V;t[23]!==a||t[24]!==r.closeDetails?(V=(0,I.jsx)(w,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":r.closeDetails,onClick:a,children:ae}),t[23]=a,t[24]=r.closeDetails,t[25]=V):V=t[25];let oe;t[26]!==B||t[27]!==V?(oe=(0,I.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-5 py-4`,children:[B,V]}),t[26]=B,t[27]=V,t[28]=oe):oe=t[28];let H;t[29]===r.createDialog.goalTitle?H=t[30]:(H=(0,I.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:r.createDialog.goalTitle}),t[29]=r.createDialog.goalTitle,t[30]=H);let U;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(U=e=>S({title:e.target.value}),t[31]=U):U=t[31];let W;t[32]!==s.title||t[33]!==r.newGoalPlaceholder?(W=(0,I.jsx)(`input`,{value:s.title,onChange:U,placeholder:r.newGoalPlaceholder,className:`rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`,autoFocus:!0}),t[32]=s.title,t[33]=r.newGoalPlaceholder,t[34]=W):W=t[34];let G;t[35]!==H||t[36]!==W?(G=(0,I.jsxs)(`label`,{className:`grid gap-1.5`,children:[H,W]}),t[35]=H,t[36]=W,t[37]=G):G=t[37];let se;t[38]===r.createDialog.goalDescription?se=t[39]:(se=(0,I.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:r.createDialog.goalDescription}),t[38]=r.createDialog.goalDescription,t[39]=se);let ce;t[40]===Symbol.for(`react.memo_cache_sentinel`)?(ce=e=>S({description:e.target.value}),t[40]=ce):ce=t[40];let K;t[41]!==s.description||t[42]!==r.createDialog.descriptionPlaceholder?(K=(0,I.jsx)(`textarea`,{value:s.description,onChange:ce,placeholder:r.createDialog.descriptionPlaceholder,rows:4,className:`resize-none rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`}),t[41]=s.description,t[42]=r.createDialog.descriptionPlaceholder,t[43]=K):K=t[43];let q;t[44]!==se||t[45]!==K?(q=(0,I.jsxs)(`label`,{className:`grid gap-1.5`,children:[se,K]}),t[44]=se,t[45]=K,t[46]=q):q=t[46];let J;t[47]===r.createDialog.criteriaTitle?J=t[48]:(J=(0,I.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:r.createDialog.criteriaTitle}),t[47]=r.createDialog.criteriaTitle,t[48]=J);let le;t[49]===r.createDialog.criteriaHint?le=t[50]:(le=(0,I.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:r.createDialog.criteriaHint}),t[49]=r.createDialog.criteriaHint,t[50]=le);let Y;t[51]!==J||t[52]!==le?(Y=(0,I.jsxs)(`div`,{children:[J,le]}),t[51]=J,t[52]=le,t[53]=Y):Y=t[53];let X;t[54]!==s||t[55]!==r?(X=()=>S({checklist:he(s,r)}),t[54]=s,t[55]=r,t[56]=X):X=t[56];let ue;t[57]===Symbol.for(`react.memo_cache_sentinel`)?(ue=(0,I.jsx)(D,{className:`size-3.5`,"aria-hidden":!0}),t[57]=ue):ue=t[57];let de;t[58]!==r.createDialog.aiDraft||t[59]!==X?(de=(0,I.jsxs)(w,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg text-xs`,onClick:X,children:[ue,r.createDialog.aiDraft]}),t[58]=r.createDialog.aiDraft,t[59]=X,t[60]=de):de=t[60];let Z;t[61]!==Y||t[62]!==de?(Z=(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[Y,de]}),t[61]=Y,t[62]=de,t[63]=Z):Z=t[63];let Q;if(t[64]!==s.checklist||t[65]!==r.createDialog.criteriaPlaceholder||t[66]!==r.createDialog.removeCriteria){let e;t[68]!==r.createDialog.criteriaPlaceholder||t[69]!==r.createDialog.removeCriteria?(e=(e,t)=>(0,I.jsxs)(`div`,{className:`flex gap-2`,children:[(0,I.jsx)(`input`,{value:e,onChange:e=>E(t,e.target.value),placeholder:ie(r.createDialog.criteriaPlaceholder,{index:t+1}),className:`min-w-0 flex-1 rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`}),(0,I.jsx)(w,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 rounded-lg p-0`,"aria-label":r.createDialog.removeCriteria,onClick:()=>j(t),children:(0,I.jsx)(d,{className:`size-4`,"aria-hidden":!0})})]},t),t[68]=r.createDialog.criteriaPlaceholder,t[69]=r.createDialog.removeCriteria,t[70]=e):e=t[70],Q=s.checklist.map(e),t[64]=s.checklist,t[65]=r.createDialog.criteriaPlaceholder,t[66]=r.createDialog.removeCriteria,t[67]=Q}else Q=t[67];let $;t[71]===s.checklist?$=t[72]:($=()=>S({checklist:[...s.checklist,``]}),t[71]=s.checklist,t[72]=$);let fe;t[73]===Symbol.for(`react.memo_cache_sentinel`)?(fe=(0,I.jsx)(u,{className:`size-3.5`,"aria-hidden":!0}),t[73]=fe):fe=t[73];let pe;t[74]!==r.createDialog.addCriteria||t[75]!==$?(pe=(0,I.jsxs)(w,{type:`button`,variant:`ghost`,className:`h-8 justify-start rounded-lg text-xs`,onClick:$,children:[fe,r.createDialog.addCriteria]}),t[74]=r.createDialog.addCriteria,t[75]=$,t[76]=pe):pe=t[76];let _e;t[77]!==Q||t[78]!==pe?(_e=(0,I.jsxs)(`div`,{className:`mt-3 grid gap-2`,children:[Q,pe]}),t[77]=Q,t[78]=pe,t[79]=_e):_e=t[79];let be;t[80]!==Z||t[81]!==_e?(be=(0,I.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base/60 p-4`,children:[Z,_e]}),t[80]=Z,t[81]=_e,t[82]=be):be=t[82];let xe;t[83]===Symbol.for(`react.memo_cache_sentinel`)?(xe=()=>h(ve),t[83]=xe):xe=t[83];let Se;t[84]===Symbol.for(`react.memo_cache_sentinel`)?(Se=(0,I.jsx)(k,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),t[84]=Se):Se=t[84];let Ce;t[85]===r.createDialog.advanced?Ce=t[86]:(Ce=(0,I.jsxs)(`span`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[Se,r.createDialog.advanced]}),t[85]=r.createDialog.advanced,t[86]=Ce);let we=m&&`rotate-180`,Te;t[87]===we?Te=t[88]:(Te=ee(`size-4 text-fg-muted transition-transform`,we),t[87]=we,t[88]=Te);let Ee;t[89]===Te?Ee=t[90]:(Ee=(0,I.jsx)(O,{className:Te,"aria-hidden":!0}),t[89]=Te,t[90]=Ee);let De;t[91]!==Ce||t[92]!==Ee?(De=(0,I.jsxs)(`button`,{type:`button`,className:`flex w-full items-center justify-between gap-3 px-4 py-3 text-left`,onClick:xe,children:[Ce,Ee]}),t[91]=Ce,t[92]=Ee,t[93]=De):De=t[93];let Oe;t[94]!==m||t[95]!==s.agentId||t[96]!==s.deadline||t[97]!==s.judgeModelRef||t[98]!==s.maxTurns||t[99]!==s.priority||t[100]!==r.createDialog.agentId||t[101]!==r.createDialog.deadline||t[102]!==r.createDialog.judgeModel||t[103]!==r.createDialog.judgeModelPlaceholder||t[104]!==r.createDialog.maxTurns||t[105]!==r.createDialog.priority||t[106]!==r.priorities?(Oe=m?(0,I.jsxs)(`div`,{className:`grid gap-3 border-t border-edge-subtle p-4 sm:grid-cols-2`,children:[(0,I.jsxs)(`label`,{className:`grid gap-1.5`,children:[(0,I.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:r.createDialog.priority}),(0,I.jsxs)(`select`,{value:s.priority,onChange:e=>S({priority:e.target.value}),className:`rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`,children:[(0,I.jsx)(`option`,{value:`normal`,children:r.priorities.normal}),(0,I.jsx)(`option`,{value:`high`,children:r.priorities.high}),(0,I.jsx)(`option`,{value:`low`,children:r.priorities.low})]})]}),(0,I.jsxs)(`label`,{className:`grid gap-1.5`,children:[(0,I.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:r.createDialog.deadline}),(0,I.jsx)(`input`,{type:`date`,value:s.deadline,onChange:e=>S({deadline:e.target.value}),className:`rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`})]}),(0,I.jsxs)(`label`,{className:`grid gap-1.5`,children:[(0,I.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:r.createDialog.maxTurns}),(0,I.jsx)(`input`,{type:`number`,min:1,max:500,value:s.maxTurns,onChange:e=>S({maxTurns:e.target.value}),className:`rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`})]}),(0,I.jsxs)(`label`,{className:`grid gap-1.5`,children:[(0,I.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:r.createDialog.agentId}),(0,I.jsx)(`input`,{value:s.agentId,onChange:e=>S({agentId:e.target.value}),placeholder:`main`,className:`rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`})]}),(0,I.jsxs)(`label`,{className:`grid gap-1.5 sm:col-span-2`,children:[(0,I.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:r.createDialog.judgeModel}),(0,I.jsx)(`input`,{value:s.judgeModelRef,onChange:e=>S({judgeModelRef:e.target.value}),placeholder:r.createDialog.judgeModelPlaceholder,className:`rounded-lg border border-edge bg-surface-muted px-3 py-2 text-sm text-fg placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent`})]})]}):null,t[94]=m,t[95]=s.agentId,t[96]=s.deadline,t[97]=s.judgeModelRef,t[98]=s.maxTurns,t[99]=s.priority,t[100]=r.createDialog.agentId,t[101]=r.createDialog.deadline,t[102]=r.createDialog.judgeModel,t[103]=r.createDialog.judgeModelPlaceholder,t[104]=r.createDialog.maxTurns,t[105]=r.createDialog.priority,t[106]=r.priorities,t[107]=Oe):Oe=t[107];let ke;t[108]!==De||t[109]!==Oe?(ke=(0,I.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base/60`,children:[De,Oe]}),t[108]=De,t[109]=Oe,t[110]=ke):ke=t[110];let Ae;t[111]===g?Ae=t[112]:(Ae=g?(0,I.jsx)(`p`,{className:`rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:g}):null,t[111]=g,t[112]=Ae);let je;t[113]!==G||t[114]!==q||t[115]!==be||t[116]!==ke||t[117]!==Ae?(je=(0,I.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:(0,I.jsxs)(`div`,{className:`grid gap-4`,children:[G,q,be,ke,Ae]})}),t[113]=G,t[114]=q,t[115]=be,t[116]=ke,t[117]=Ae,t[118]=je):je=t[118];let Me;t[119]!==a||t[120]!==r.createDialog.cancel?(Me=(0,I.jsx)(w,{type:`button`,variant:`ghost`,className:`rounded-lg`,onClick:a,children:r.createDialog.cancel}),t[119]=a,t[120]=r.createDialog.cancel,t[121]=Me):Me=t[121];let Ne;t[122]!==i||t[123]!==s.title?(Ne=i||!s.title.trim(),t[122]=i,t[123]=s.title,t[124]=Ne):Ne=t[124];let Pe;t[125]===N?Pe=t[126]:(Pe=()=>void N(),t[125]=N,t[126]=Pe);let Fe;t[127]===Symbol.for(`react.memo_cache_sentinel`)?(Fe=(0,I.jsx)(u,{className:`size-4`,"aria-hidden":!0}),t[127]=Fe):Fe=t[127];let Ie;t[128]!==r.createDialog.create||t[129]!==Ne||t[130]!==Pe?(Ie=(0,I.jsxs)(w,{type:`button`,variant:`primary`,className:`rounded-lg`,disabled:Ne,onClick:Pe,children:[Fe,r.createDialog.create]}),t[128]=r.createDialog.create,t[129]=Ne,t[130]=Pe,t[131]=Ie):Ie=t[131];let Le;t[132]!==Me||t[133]!==Ie?(Le=(0,I.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-edge px-5 py-4`,children:[Me,Ie]}),t[132]=Me,t[133]=Ie,t[134]=Le):Le=t[134];let Re;t[135]!==oe||t[136]!==je||t[137]!==Le?(Re=(0,I.jsxs)(ne,{children:[R,(0,I.jsxs)(f,{className:`fixed left-1/2 top-1/2 z-66 flex h-[min(92vh,46rem)] w-[min(100%-2rem,44rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none`,children:[oe,je,Le]})]}),t[135]=oe,t[136]=je,t[137]=Le,t[138]=Re):Re=t[138];let ze;return t[139]!==n||t[140]!==Re||t[141]!==L?(ze=(0,I.jsx)(p,{open:n,onOpenChange:L,children:Re}),t[139]=n,t[140]=Re,t[141]=L,t[142]=ze):ze=t[142],ze}function ve(e){return!e}function ye(){return me()}function be(e){let t=(0,P.c)(135),{goal:n,queueItem:r,t:i,language:a,busy:o,onClose:s,onAction:u}=e;if(!n)return null;let d,h,g,_,y,b,x,S,E,D,O,k,A,j;if(t[0]!==o||t[1]!==n||t[2]!==u||t[3]!==s||t[4]!==i){let e=re(n),r;t[19]===n?r=t[20]:(r=ue(n),t[19]=n,t[20]=r);let a=r,c=de(n);g=p,y=!0,t[21]===s?b=t[22]:(b=e=>!e&&s(),t[21]=s,t[22]=b),h=ne,t[23]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,I.jsx)(v,{className:`xopc-dialog-overlay fixed inset-0 z-65 bg-scrim backdrop-blur-[1px]`}),t[23]=j):j=t[23],d=f,k=`fixed left-1/2 top-1/2 z-66 flex h-[min(90vh,48rem)] w-[min(100%-2rem,56rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none`;let m;t[24]===n.title?m=t[25]:(m=(0,I.jsx)(l,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:n.title}),t[24]=n.title,t[25]=m);let T;t[26]!==n.status||t[27]!==i?(T=ae(n.status,i),t[26]=n.status,t[27]=i,t[28]=T):T=t[28];let M;t[29]!==n.maxTurns||t[30]!==n.turnsUsed||t[31]!==i.turns?(M=ie(i.turns,{used:n.turnsUsed,max:n.maxTurns}),t[29]=n.maxTurns,t[30]=n.turnsUsed,t[31]=i.turns,t[32]=M):M=t[32];let N;t[33]!==T||t[34]!==M?(N=(0,I.jsxs)(te,{className:`mt-1 truncate text-xs text-fg-muted`,children:[T,` · `,M]}),t[33]=T,t[34]=M,t[35]=N):N=t[35];let P;t[36]!==m||t[37]!==N?(P=(0,I.jsxs)(`div`,{className:`min-w-0`,children:[m,N]}),t[36]=m,t[37]=N,t[38]=P):P=t[38];let F;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,I.jsx)(C,{className:`size-5`,"aria-hidden":!0}),t[39]=F):F=t[39];let L;t[40]!==s||t[41]!==i.closeDetails?(L=(0,I.jsx)(w,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":i.closeDetails,onClick:s,children:F}),t[40]=s,t[41]=i.closeDetails,t[42]=L):L=t[42],t[43]!==P||t[44]!==L?(A=(0,I.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-5 py-4`,children:[P,L]}),t[43]=P,t[44]=L,t[45]=A):A=t[45],O=`min-h-0 flex-1 overflow-y-auto p-5`,E=`flex flex-col gap-4 lg:flex-row lg:items-start lg:justify-between`;let R;t[46]===n.status?R=t[47]:(R=ee(`rounded-full px-2 py-0.5 text-xs font-medium`,oe(n.status)),t[46]=n.status,t[47]=R);let z;t[48]!==n.status||t[49]!==i?(z=ae(n.status,i),t[48]=n.status,t[49]=i,t[50]=z):z=t[50];let B;t[51]!==R||t[52]!==z?(B=(0,I.jsx)(`span`,{className:R,children:z}),t[51]=R,t[52]=z,t[53]=B):B=t[53];let V;t[54]===n.agentId?V=t[55]:(V=(0,I.jsx)(`span`,{className:`text-xs text-fg-muted`,children:n.agentId}),t[54]=n.agentId,t[55]=V);let H=ie(i.checklistProgress,{done:e.done,total:e.total}),U;t[56]===H?U=t[57]:(U=(0,I.jsx)(`span`,{className:`text-xs text-fg-muted`,children:H}),t[56]=H,t[57]=U);let W;t[58]!==B||t[59]!==V||t[60]!==U?(W=(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[B,V,U]}),t[58]=B,t[59]=V,t[60]=U,t[61]=W):W=t[61];let G;t[62]===n.description?G=t[63]:(G=n.description?(0,I.jsx)(`p`,{className:`mt-3 whitespace-pre-wrap break-words text-sm leading-6 text-fg-muted`,children:n.description}):null,t[62]=n.description,t[63]=G),t[64]!==W||t[65]!==G?(D=(0,I.jsxs)(`div`,{className:`min-w-0`,children:[W,G]}),t[64]=W,t[65]=G,t[66]=D):D=t[66],_=`flex flex-wrap gap-2`,t[67]!==o||t[68]!==n.id||t[69]!==u||t[70]!==a||t[71]!==i?(x=a?(0,I.jsx)(pe,{goalId:n.id,action:a,t:i,busy:o,variant:a===`continue`?`primary`:`secondary`,onAction:u}):null,t[67]=o,t[68]=n.id,t[69]=u,t[70]=a,t[71]=i,t[72]=x):x=t[72];let se;t[73]!==o||t[74]!==n.id||t[75]!==u||t[76]!==i?(se=e=>(0,I.jsx)(pe,{goalId:n.id,action:e,t:i,busy:o,variant:e===`archive`?`ghost`:`secondary`,onAction:u},e),t[73]=o,t[74]=n.id,t[75]=u,t[76]=i,t[77]=se):se=t[77],S=c.map(se),t[0]=o,t[1]=n,t[2]=u,t[3]=s,t[4]=i,t[5]=d,t[6]=h,t[7]=g,t[8]=_,t[9]=y,t[10]=b,t[11]=x,t[12]=S,t[13]=E,t[14]=D,t[15]=O,t[16]=k,t[17]=A,t[18]=j}else d=t[5],h=t[6],g=t[7],_=t[8],y=t[9],b=t[10],x=t[11],S=t[12],E=t[13],D=t[14],O=t[15],k=t[16],A=t[17],j=t[18];let M=`/goals/${encodeURIComponent(n.id)}`,N;t[78]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,I.jsx)(T,{className:`size-4`,"aria-hidden":!0}),t[78]=N):N=t[78];let F;t[79]!==i.fullDetails||t[80]!==M?(F=(0,I.jsx)(w,{asChild:!0,type:`button`,variant:`secondary`,className:`h-9 rounded-lg`,children:(0,I.jsxs)(m,{to:M,children:[N,i.fullDetails]})}),t[79]=i.fullDetails,t[80]=M,t[81]=F):F=t[81];let L;t[82]!==_||t[83]!==F||t[84]!==x||t[85]!==S?(L=(0,I.jsxs)(`div`,{className:_,children:[x,S,F]}),t[82]=_,t[83]=F,t[84]=x,t[85]=S,t[86]=L):L=t[86];let R;t[87]!==L||t[88]!==E||t[89]!==D?(R=(0,I.jsxs)(`div`,{className:E,children:[D,L]}),t[87]=L,t[88]=E,t[89]=D,t[90]=R):R=t[90];let z;t[91]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,I.jsx)(`div`,{className:`rounded-xl bg-accent-soft p-2 text-accent-fg`,children:(0,I.jsx)(c,{className:`size-4`,"aria-hidden":!0})}),t[91]=z):z=t[91];let V=n.blockedReason?i.currentBlocker:i.nextAction,H;t[92]===V?H=t[93]:(H=(0,I.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:V}),t[92]=V,t[93]=H);let W=n.blockedReason?`text-amber-700 dark:text-amber-300`:`text-fg-muted`,G;t[94]===W?G=t[95]:(G=ee(`mt-1 text-sm leading-6`,W),t[94]=W,t[95]=G);let ce=n.blockedReason||n.nextAction||i.noNextAction,K;t[96]!==G||t[97]!==ce?(K=(0,I.jsx)(`p`,{className:G,children:ce}),t[96]=G,t[97]=ce,t[98]=K):K=t[98];let q;t[99]!==H||t[100]!==K?(q=(0,I.jsx)(`div`,{className:`mt-5 rounded-2xl border border-edge-subtle bg-surface-base/60 p-4`,children:(0,I.jsxs)(`div`,{className:`flex items-start gap-3`,children:[z,(0,I.jsxs)(`div`,{className:`min-w-0`,children:[H,K]})]})}),t[99]=H,t[100]=K,t[101]=q):q=t[101];let J;t[102]!==a||t[103]!==r||t[104]!==i?(J=r?(0,I.jsxs)(`div`,{className:`mt-4 rounded-2xl border border-edge-subtle bg-surface-base/60 p-4`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,I.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:i.executionQueue}),(0,I.jsx)(`span`,{className:ee(`rounded-full px-2 py-0.5 text-xs font-semibold`,se(r.status)),children:ae(r.status,i)})]}),(0,I.jsxs)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:[ie(i.attempt,{attempts:r.attempts,max:r.maxRetries+1}),` · `,B(U(r),a)]}),r.error?(0,I.jsx)(`p`,{className:`mt-2 text-sm text-amber-700 dark:text-amber-300`,children:r.error}):null,r.message?(0,I.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:r.message}):null]}):null,t[102]=a,t[103]=r,t[104]=i,t[105]=J):J=t[105];let le;t[106]===Symbol.for(`react.memo_cache_sentinel`)?(le=(0,I.jsx)(c,{className:`size-4 text-accent`,"aria-hidden":!0}),t[106]=le):le=t[106];let Y;t[107]===i.checklist?Y=t[108]:(Y=(0,I.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[le,i.checklist]}),t[107]=i.checklist,t[108]=Y);let X;t[109]!==n.checklist||t[110]!==i.noChecklist?(X=n.checklist.length?(0,I.jsx)(`ul`,{className:`mt-3 grid gap-2 text-sm text-fg-muted`,children:n.checklist.map(xe)}):(0,I.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:i.noChecklist}),t[109]=n.checklist,t[110]=i.noChecklist,t[111]=X):X=t[111];let Z;t[112]!==Y||t[113]!==X?(Z=(0,I.jsxs)(`div`,{className:`mt-4 rounded-2xl border border-edge-subtle bg-surface-base/60 p-4`,children:[Y,X]}),t[112]=Y,t[113]=X,t[114]=Z):Z=t[114];let Q;t[115]!==R||t[116]!==q||t[117]!==J||t[118]!==Z||t[119]!==O?(Q=(0,I.jsxs)(`section`,{className:O,children:[R,q,J,Z]}),t[115]=R,t[116]=q,t[117]=J,t[118]=Z,t[119]=O,t[120]=Q):Q=t[120];let $;t[121]!==d||t[122]!==Q||t[123]!==k||t[124]!==A?($=(0,I.jsxs)(d,{className:k,children:[A,Q]}),t[121]=d,t[122]=Q,t[123]=k,t[124]=A,t[125]=$):$=t[125];let fe;t[126]!==h||t[127]!==$||t[128]!==j?(fe=(0,I.jsxs)(h,{children:[j,$]}),t[126]=h,t[127]=$,t[128]=j,t[129]=fe):fe=t[129];let me;return t[130]!==g||t[131]!==y||t[132]!==b||t[133]!==fe?(me=(0,I.jsx)(g,{open:y,onOpenChange:b,children:fe}),t[130]=g,t[131]=y,t[132]=b,t[133]=fe,t[134]=me):me=t[134],me}function xe(e){return(0,I.jsxs)(`li`,{className:`flex gap-2`,children:[(0,I.jsx)(`span`,{className:`w-5 shrink-0 text-center`,children:H(e.status)}),(0,I.jsx)(`span`,{className:`break-words`,children:e.text})]},e.id)}function Se(){let e=h(),t=a(e=>e.language),n=i(t).goalsPage,r=S(e=>e.setPageHeader),o=S(e=>e.clearPageHeader),[s,c]=(0,F.useState)([]),[l,d]=(0,F.useState)([]),[f,p]=(0,F.useState)(``),[m,_]=(0,F.useState)(!0),[v,y]=(0,F.useState)(null),[te,b]=(0,F.useState)(null),[ne,C]=(0,F.useState)(!1),[T,D]=(0,F.useState)(null),[O,k]=(0,F.useState)(null),[A,j]=(0,F.useState)(null),M=(0,F.useCallback)(async()=>{_(!0),b(null);try{let[e,t]=await Promise.all([K(),q()]);c(e),d(t)}catch(e){b(e instanceof Error?e.message:n.errors.load)}finally{_(!1)}},[n.errors.load]);(0,F.useEffect)(()=>{M()},[M]),(0,F.useEffect)(()=>{let e=()=>{q().then(d).catch(()=>{})};return window.addEventListener(`goal-queue-updated`,e),()=>window.removeEventListener(`goal-queue-updated`,e)},[]);let N=(0,F.useMemo)(()=>G(l),[l]),P=(0,F.useMemo)(()=>s.filter(e=>ce(e,f)),[s,f]),L=(0,F.useMemo)(()=>{let e=new Map(R.map(e=>[e,[]]));for(let t of P)e.get(V(t))?.push(t);return e},[P]),re=(0,F.useMemo)(()=>s.find(e=>e.id===T)??null,[s,T]),B=(0,F.useMemo)(()=>({open:s.filter(e=>e.status===`active`||e.status===`paused`||e.status===`blocked`||e.status===`needs_input`).length,attention:s.filter(e=>e.status===`blocked`||e.status===`needs_input`).length,running:l.filter(e=>e.status===`running`).length,queued:l.filter(e=>e.status===`queued`||e.status===`retry_waiting`).length}),[s,l]),ae=(0,F.useMemo)(()=>[{key:`running`,count:B.running},{key:`queued`,count:B.queued},{key:`failed`,count:l.filter(e=>e.status===`failed`).length}],[B.queued,B.running,l]),oe=async(t,r)=>{y(`${t}:${r}`),b(null);try{if(r===`continue`){let n=await X(t);if(n){e(`/chat/${encodeURIComponent(n)}`);return}}else await Y(t,r);await M()}catch(e){b(e instanceof Error?e.message:n.errors.action)}finally{y(null)}},H=async(e,t)=>{let n=s.find(t=>t.id===e),r=n?$(n,t):null;j(null),k(null),!(!n||!r)&&await oe(n.id,r)},U=(0,F.useCallback)(async e=>{let t=Number.parseInt(e.maxTurns,10),r=e.deadline?new Date(`${e.deadline}T23:59:59`).getTime():void 0;y(`create`),b(null);try{let n=await J({title:e.title.trim(),description:e.description.trim()||void 0,priority:e.priority,deadlineAt:Number.isFinite(r)?r:void 0,maxTurns:Number.isFinite(t)?t:void 0,agentId:e.agentId.trim()||void 0,judgeModelRef:e.judgeModelRef.trim()||void 0});for(let t of ge(e.checklist))await le(n.id,t);await M(),D(n.id)}catch(e){throw b(e instanceof Error?e.message:n.errors.create),e}finally{y(null)}},[M,n.errors.create]),W=(0,F.useMemo)(()=>(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`label`,{className:`relative min-w-0`,children:[(0,I.jsx)(E,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-muted`,"aria-hidden":!0}),(0,I.jsx)(`input`,{value:f,onChange:e=>p(e.target.value),"aria-label":n.searchPlaceholder,autoComplete:`off`,placeholder:n.searchPlaceholder,className:`h-9 w-36 rounded-lg border border-edge bg-surface-muted py-2 pl-9 pr-3 text-sm text-fg placeholder:text-fg-muted focus-visible:border-accent focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-accent sm:w-56 lg:w-72`})]}),(0,I.jsx)(w,{type:`button`,variant:`secondary`,className:`size-9 rounded-lg p-0`,"aria-label":n.refresh,onClick:()=>void M(),children:(0,I.jsx)(x,{className:`size-4`,"aria-hidden":!0})}),(0,I.jsxs)(w,{type:`button`,variant:`primary`,className:`h-9 rounded-lg`,disabled:v===`create`,onClick:()=>C(!0),children:[(0,I.jsx)(u,{className:`size-4`,"aria-hidden":!0}),n.create]})]}),[v,f,M,n.create,n.refresh,n.searchPlaceholder]);return(0,F.useLayoutEffect)(()=>(r({startExtra:null,main:(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:n.title}),(0,I.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:ie(n.summary,{open:B.open,attention:B.attention,shown:P.length})})]}),end:W}),()=>o()),[o,B.attention,B.open,W,r,n.summary,n.title,P.length]),(0,I.jsxs)(`main`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden bg-surface-base`,children:[(0,I.jsxs)(`div`,{className:`flex min-h-0 w-full flex-1 flex-col gap-4 px-4 py-5 sm:px-6 2xl:px-8`,children:[(0,I.jsxs)(`section`,{className:`flex flex-wrap items-center gap-2 rounded-lg border border-edge bg-surface-panel px-3 py-2`,children:[(0,I.jsxs)(`div`,{className:`mr-1 flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,I.jsx)(g,{className:`size-4 text-accent`,"aria-hidden":!0}),n.executionQueue]}),ae.map(e=>(0,I.jsx)(`span`,{className:`rounded-full border border-edge bg-surface-muted px-2 py-0.5 text-xs text-fg-muted`,children:ie(n.queueSummary[e.key],{count:e.count})},e.key))]}),te?(0,I.jsx)(`p`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:te}):null,m?(0,I.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.loading}):null,(0,I.jsx)(`section`,{className:`-mx-1 min-h-0 flex-1 overflow-x-auto px-1 pb-3`,"aria-label":n.boardLabel,children:(0,I.jsx)(`div`,{className:`flex h-full min-w-max snap-x snap-mandatory gap-3`,children:R.map(e=>{let r=L.get(e)??[];return(0,I.jsxs)(`section`,{className:ee(`flex h-full w-80 shrink-0 snap-center flex-col overflow-hidden rounded-2xl border bg-surface-panel/40`,A===e?`border-accent ring-1 ring-accent/30`:`border-edge`),"aria-label":n.lanes[e].title,onDragOver:t=>{t.preventDefault(),t.dataTransfer.dropEffect=`move`,j(e)},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||j(null)},onDrop:t=>{t.preventDefault();let n=t.dataTransfer.getData(z)||O;n&&H(n,e)},children:[(0,I.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between gap-2 rounded-t-2xl border-b border-edge-subtle bg-surface-panel/90 px-3.5 py-3 backdrop-blur`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`size-2 rounded-full bg-accent`,"aria-hidden":!0}),(0,I.jsx)(`h2`,{className:`truncate text-sm font-semibold text-fg`,children:n.lanes[e].title})]}),(0,I.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2.5 py-1 text-xs font-semibold tabular-nums text-fg-muted`,children:r.length})]}),(0,I.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3 overflow-y-auto p-2.5`,children:[r.map(e=>(0,I.jsx)(fe,{goal:e,queueItem:N.get(e.id),t:n,language:t,selected:e.id===T,dragging:e.id===O,onOpen:e=>D(e.id),onDragStart:(e,t)=>{t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(z,e),k(e)},onDragEnd:()=>{k(null),j(null)}},e.id)),!m&&r.length===0?(0,I.jsx)(`div`,{className:`flex min-h-32 items-center justify-center rounded-xl border border-dashed border-edge bg-surface-panel/40 px-4 py-6 text-center text-xs text-fg-subtle`,children:n.lanes[e].empty}):null]})]},e)})})})]}),(0,I.jsx)(_e,{open:ne,t:n,busy:v===`create`,onClose:()=>C(!1),onCreate:U}),(0,I.jsx)(be,{goal:re,queueItem:re?N.get(re.id):void 0,t:n,language:t,busy:v,onClose:()=>D(null),onAction:(e,t)=>void oe(e,t)})]})}export{Se as GoalsPage};
|
|
@@ -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{t as i}from"./cn-JdwAhgNB.js";import{t as a}from"./messages-Csef1aW7.js";import{t as o}from"./locale-store-DjbfSsfA.js";import{c as s,i as c,n as l}from"./fetch-Bs7in_4F.js";import{i as u}from"./vendor-swr-BIWyz7Rc.js";import{Ds as d,Ea as f,Hi as p,Oi as m,U as h,br as g,ki as _,ps as v,qa as y,qi as b,ur as x,xi as S,yr as C}from"./index-COkF54xv.js";import{n as w,t as T}from"./settings-form-section-BsrK7TBF.js";import{t as E}from"./use-channel-catalog-C4mg1hjD.js";import{n as D,t as O}from"./save-bar-controls-CNP2jmw0.js";var k=e(t(),1),A=n(),j={maxTurns:20,judgeModelRef:``,checklistMode:!0,maxConsecutiveParseFailures:3,judgeTimeoutSec:60,checklistHistoryChars:24e3,notifications:{enabled:!1,includeLinkedSessions:!0,channels:[`telegram`,`weixin`],events:[`done`,`blocked`,`needs_input`,`queue_failed`,`queue_retry`],targets:[]}};function M(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function N(e){let t=M(e)?e:{},n=M(t.goals)?t.goals:{},r=M(n.notifications)?n.notifications:{};return{maxTurns:typeof n.maxTurns==`number`&&Number.isFinite(n.maxTurns)?Math.max(1,Math.min(500,Math.floor(n.maxTurns))):j.maxTurns,judgeModelRef:typeof n.judgeModelRef==`string`?n.judgeModelRef:``,checklistMode:n.checklistMode!==!1,maxConsecutiveParseFailures:typeof n.maxConsecutiveParseFailures==`number`&&Number.isFinite(n.maxConsecutiveParseFailures)?Math.max(1,Math.min(20,Math.floor(n.maxConsecutiveParseFailures))):j.maxConsecutiveParseFailures,judgeTimeoutSec:typeof n.judgeTimeoutMs==`number`&&Number.isFinite(n.judgeTimeoutMs)?Math.max(5,Math.min(120,Math.round(n.judgeTimeoutMs/1e3))):j.judgeTimeoutSec,checklistHistoryChars:typeof n.checklistHistoryChars==`number`&&Number.isFinite(n.checklistHistoryChars)?Math.max(0,Math.min(1e5,Math.floor(n.checklistHistoryChars))):j.checklistHistoryChars,notifications:{enabled:r.enabled===!0,includeLinkedSessions:r.includeLinkedSessions!==!1,channels:Array.isArray(r.channels)?r.channels.filter(e=>typeof e==`string`&&e.trim().length>0):j.notifications.channels,events:Array.isArray(r.events)?r.events.filter(e=>typeof e==`string`&&e.trim().length>0):j.notifications.events,targets:Array.isArray(r.targets)?r.targets.filter(M).map(e=>({channel:typeof e.channel==`string`?e.channel:``,chatId:typeof e.chatId==`string`?e.chatId:``,accountId:typeof e.accountId==`string`?e.accountId:void 0,threadId:typeof e.threadId==`string`||typeof e.threadId==`number`?e.threadId:void 0,silent:e.silent===!0,events:Array.isArray(e.events)?e.events.filter(e=>typeof e==`string`&&e.trim().length>0):void 0})).filter(e=>e.channel.trim()&&e.chatId.trim()):[]}}}async function P(e){let t=e.notifications.targets.map(e=>({...e,chatId:e.chatId.trim(),channel:e.channel.trim(),accountId:e.accountId?.trim()||void 0})).filter(e=>e.channel&&e.chatId&&e.chatId!==`__custom__`);await l(c(`/api/config`),{method:`PATCH`,body:JSON.stringify({goals:{maxTurns:e.maxTurns,...e.judgeModelRef.trim()?{judgeModelRef:e.judgeModelRef.trim()}:{judgeModelRef:null},checklistMode:e.checklistMode,maxConsecutiveParseFailures:e.maxConsecutiveParseFailures,judgeTimeoutMs:e.judgeTimeoutSec*1e3,checklistHistoryChars:e.checklistHistoryChars,notifications:{enabled:e.notifications.enabled,includeLinkedSessions:e.notifications.includeLinkedSessions,channels:e.notifications.channels,events:e.notifications.events,targets:t}}})}),C()}var F=r();function I(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,m,`dark:border-edge`)}var L=[`done`,`blocked`,`needs_input`,`queue_failed`,`queue_retry`,`queue_succeeded`,`queue_skipped`],R=[`judge`,`notifications`],z={judge:b,notifications:v};function B(e){return e&&R.includes(e)?e:`judge`}function V(e,t){return t===`judge`?e.tabJudge:e.tabNotifications}function H(e,t){return t===`judge`?e.tabJudgeHint:e.tabNotificationsHint}var U=[{id:`telegram`,label:`Telegram`},{id:`weixin`,label:`Weixin`},{id:`feishu`,label:`Feishu`}],W=`__custom__`;function G(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function K(e,t){let n=G(e)?e:{},r=G(n.channels)?n.channels:{},i=G(r[t])?r[t]:{},a=G(i.config)?i.config:i,o=G(a.accounts)?a.accounts:null;if(!o)return[`default`];let s=Object.entries(o).filter(([,e])=>!G(e)||e.enabled!==!1).map(([e])=>e).filter(Boolean).sort();return s.length?s:[`default`]}function q(e,t){let n=e.split(`:`),r=n.indexOf(t);return r<0?null:n[r+1]||null}function J(e,t){let n=e.split(`:`),r=n.indexOf(t);return r<0?null:n[r+2+1]||null}async function Y(e,t){let n=new URLSearchParams({account:t||`default`});return(await l(c(`/api/channels/${encodeURIComponent(e)}/pairing?${n.toString()}`))).payload??{}}function X(e){let t=(0,A.c)(81),{target:n,index:r,config:i,channelOptions:a,labels:o,inputClass:s,onChange:c,onRemove:l}=e,d=n.channel||a[0]?.id||`telegram`,f;t[0]!==d||t[1]!==i?(f=K(i,d),t[0]=d,t[1]=i,t[2]=f):f=t[2];let m=f,h=n.accountId||m[0]||`default`,g;t[3]===d?g=t[4]:(g=d?[`goal-notification-sessions`,d]:null,t[3]=d,t[4]=g);let v;t[5]===d?v=t[6]:(v=()=>x({channel:d,limit:200}),t[5]=d,t[6]=v);let y;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(y={revalidateOnFocus:!1},t[7]=y):y=t[7];let{data:b}=u(g,v,y),S;t[8]!==h||t[9]!==d?(S=d&&h?[`goal-notification-pairing`,d,h]:null,t[8]=h,t[9]=d,t[10]=S):S=t[10];let C;t[11]!==h||t[12]!==d?(C=()=>Y(d,h),t[11]=h,t[12]=d,t[13]=C):C=t[13];let w;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(w={revalidateOnFocus:!1},t[14]=w):w=t[14];let{data:T}=u(S,C,w),E;if(t[15]!==h||t[16]!==d||t[17]!==o.notificationsPaired||t[18]!==T?.paired?.fromConfig||t[19]!==T?.paired?.fromCredentials||t[20]!==b?.items){let e=new Map;for(let t of b?.items??[]){let n=q(t.key,d);if(n&&h&&n!==h)continue;let r=t.sourceChatId||J(t.key,d);r&&e.set(r,t.name?.trim()?`${t.name} (${r})`:r)}for(let t of T?.paired?.fromConfig??[])t&&e.set(t,e.get(t)??`${t} (${o.notificationsPaired})`);for(let t of T?.paired?.fromCredentials??[])t&&e.set(t,e.get(t)??`${t} (${o.notificationsPaired})`);E=[...e.entries()].map(te),t[15]=h,t[16]=d,t[17]=o.notificationsPaired,t[18]=T?.paired?.fromConfig,t[19]=T?.paired?.fromCredentials,t[20]=b?.items,t[21]=E}else E=t[21];let D=E,O;t[22]!==D||t[23]!==n.chatId?(O=n.chatId&&D.some(e=>e.id===n.chatId),t[22]=D,t[23]=n.chatId,t[24]=O):O=t[24];let k=O,j=D.length===0||n.chatId===W||n.chatId&&!k,M;t[25]!==i||t[26]!==r||t[27]!==c||t[28]!==n?(M=e=>{let t=e.target.value,a=K(i,t);c(r,{...n,channel:t,accountId:a[0]||`default`,chatId:``})},t[25]=i,t[26]=r,t[27]=c,t[28]=n,t[29]=M):M=t[29];let N;t[30]===a?N=t[31]:(N=a.map(ee),t[30]=a,t[31]=N);let P;t[32]!==d||t[33]!==s||t[34]!==M||t[35]!==N?(P=(0,F.jsx)(`select`,{className:s,value:d,onChange:M,children:N}),t[32]=d,t[33]=s,t[34]=M,t[35]=N,t[36]=P):P=t[36];let I;t[37]!==r||t[38]!==c||t[39]!==n?(I=e=>c(r,{...n,accountId:e.target.value,chatId:``}),t[37]=r,t[38]=c,t[39]=n,t[40]=I):I=t[40];let L;t[41]===m?L=t[42]:(L=m.map(Q),t[41]=m,t[42]=L);let R;t[43]!==h||t[44]!==s||t[45]!==I||t[46]!==L?(R=(0,F.jsx)(`select`,{className:s,value:h,onChange:I,children:L}),t[43]=h,t[44]=s,t[45]=I,t[46]=L,t[47]=R):R=t[47];let z;t[48]!==D||t[49]!==r||t[50]!==s||t[51]!==o.notificationsChatId||t[52]!==o.notificationsChooseChat||t[53]!==o.notificationsCustomChat||t[54]!==c||t[55]!==n||t[56]!==j?(z=j?(0,F.jsx)(`input`,{className:s,value:n.chatId===W?``:n.chatId,placeholder:o.notificationsChatId,onChange:e=>c(r,{...n,chatId:e.target.value})}):(0,F.jsxs)(`select`,{className:s,value:n.chatId||D[0]?.id||``,onChange:e=>c(r,{...n,chatId:e.target.value===W?W:e.target.value}),children:[n.chatId?null:(0,F.jsx)(`option`,{value:``,children:o.notificationsChooseChat}),D.map(Z),(0,F.jsx)(`option`,{value:W,children:o.notificationsCustomChat})]}),t[48]=D,t[49]=r,t[50]=s,t[51]=o.notificationsChatId,t[52]=o.notificationsChooseChat,t[53]=o.notificationsCustomChat,t[54]=c,t[55]=n,t[56]=j,t[57]=z):z=t[57];let B;t[58]!==r||t[59]!==l?(B=()=>l(r),t[58]=r,t[59]=l,t[60]=B):B=t[60];let V;t[61]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,F.jsx)(p,{className:`size-4`,"aria-hidden":!0}),t[61]=V):V=t[61];let H;t[62]!==o.notificationsRemoveTarget||t[63]!==B?(H=(0,F.jsx)(_,{type:`button`,variant:`ghost`,className:`size-9 p-0 text-destructive hover:text-destructive`,title:o.notificationsRemoveTarget,onClick:B,children:V}),t[62]=o.notificationsRemoveTarget,t[63]=B,t[64]=H):H=t[64];let U;t[65]!==P||t[66]!==R||t[67]!==z||t[68]!==H?(U=(0,F.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-[10rem_10rem_minmax(0,1fr)_2rem]`,children:[P,R,z,H]}),t[65]=P,t[66]=R,t[67]=z,t[68]=H,t[69]=U):U=t[69];let G;t[70]!==D[0]?.id||t[71]!==D.length||t[72]!==r||t[73]!==o.notificationsUseKnownChat||t[74]!==c||t[75]!==n||t[76]!==j?(G=D.length>0&&j?(0,F.jsx)(`button`,{type:`button`,className:`w-fit text-xs text-accent hover:underline`,onClick:()=>c(r,{...n,chatId:D[0]?.id??``}),children:o.notificationsUseKnownChat}):null,t[70]=D[0]?.id,t[71]=D.length,t[72]=r,t[73]=o.notificationsUseKnownChat,t[74]=c,t[75]=n,t[76]=j,t[77]=G):G=t[77];let X;return t[78]!==U||t[79]!==G?(X=(0,F.jsxs)(`div`,{className:`grid gap-2 rounded-md border border-edge/70 bg-surface-panel p-2`,children:[U,G]}),t[78]=U,t[79]=G,t[80]=X):X=t[80],X}function Z(e){return(0,F.jsx)(`option`,{value:e.id,children:e.label},e.id)}function Q(e){return(0,F.jsx)(`option`,{value:e,children:e},e)}function ee(e){return(0,F.jsxs)(`option`,{value:e.id,children:[e.label,` (`,e.id,`)`]},e.id)}function te(e){let[t,n]=e;return{id:t,label:n}}function ne(e){let t=(0,A.c)(11),{t:n,activeTab:r,onChange:a}=e,o=n.tabsAriaLabel,s;t[0]!==r||t[1]!==a?(s=e=>{e.key!==`ArrowLeft`&&e.key!==`ArrowRight`||(e.preventDefault(),a(R[(R.indexOf(r)+(e.key===`ArrowRight`?1:-1)+R.length)%R.length]))},t[0]=r,t[1]=a,t[2]=s):s=t[2];let c;t[3]!==r||t[4]!==a||t[5]!==n?(c=R.map(e=>{let t=z[e],o=e===r;return(0,F.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":o,id:`goals-settings-tab-${e}`,"aria-controls":`goals-settings-panel-${e}`,className:i(`inline-flex shrink-0 items-center gap-1.5 rounded-lg px-3 py-2 text-sm font-medium transition-colors`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,S.press,o?`bg-accent-soft text-accent-fg`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),onClick:()=>a(e),children:[(0,F.jsx)(t,{className:`size-3.5 shrink-0`,strokeWidth:1.75,"aria-hidden":!0}),(0,F.jsx)(`span`,{children:V(n,e)})]},e)}),t[3]=r,t[4]=a,t[5]=n,t[6]=c):c=t[6];let l;return t[7]!==n.tabsAriaLabel||t[8]!==s||t[9]!==c?(l=(0,F.jsx)(`nav`,{"aria-label":o,className:`-mx-1 flex gap-1 overflow-x-auto px-1 pb-1`,role:`tablist`,onKeyDown:s,children:c}),t[7]=n.tabsAriaLabel,t[8]=s,t[9]=c,t[10]=l):l=t[10],l}function $(e){let t=(0,A.c)(20),{t:n,id:r,activeTab:i,children:a}=e;if(i!==r)return null;let o=`goals-settings-panel-${r}`,s=`goals-settings-tab-${r}`,c;t[0]!==r||t[1]!==n?(c=V(n,r),t[0]=r,t[1]=n,t[2]=c):c=t[2];let l;t[3]===c?l=t[4]:(l=(0,F.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:c}),t[3]=c,t[4]=l);let u;t[5]!==r||t[6]!==n?(u=H(n,r),t[5]=r,t[6]=n,t[7]=u):u=t[7];let d;t[8]===u?d=t[9]:(d=(0,F.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:u}),t[8]=u,t[9]=d);let f;t[10]!==l||t[11]!==d?(f=(0,F.jsxs)(`div`,{className:`mb-5`,children:[l,d]}),t[10]=l,t[11]=d,t[12]=f):f=t[12];let p;t[13]===a?p=t[14]:(p=(0,F.jsx)(`div`,{className:`space-y-4`,children:a}),t[13]=a,t[14]=p);let m;return t[15]!==o||t[16]!==s||t[17]!==f||t[18]!==p?(m=(0,F.jsxs)(`section`,{id:o,role:`tabpanel`,"aria-labelledby":s,className:`rounded-2xl border border-edge bg-surface-base px-4 py-5 sm:px-5`,children:[f,p]}),t[15]=o,t[16]=s,t[17]=f,t[18]=p,t[19]=m):m=t[19],m}function re(e,t){switch(t.type){case`reset`:return{form:null,baseline:null};case`sync`:{let e=structuredClone(t.value);return{form:e,baseline:structuredClone(e)}}case`patch`:return{...e,form:e.form?{...e.form,...t.patch}:null};case`discard`:return e.baseline?{form:structuredClone(e.baseline),baseline:e.baseline}:e;case`saved`:{let e=structuredClone(t.value);return{form:e,baseline:structuredClone(e)}}}}function ie({hasToken:e}){let t=o(e=>e.language),n=a(t).goalsSettings,r=a(t).chat,[s,c]=d(),l=B(s.get(`tab`)),u=(0,k.useCallback)(e=>{c(t=>{let n=new URLSearchParams(t);return e===`judge`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},[c]),{data:p,isLoading:m}=g(e),{entries:v}=E(e,t),x=(0,k.useMemo)(()=>p?.payload?.config===void 0?null:N(p.payload.config),[p]),[S,C]=(0,k.useReducer)(re,{form:null,baseline:null}),O=S.form,A=S.baseline,[j,M]=(0,k.useState)(!1),[R,z]=(0,k.useState)(null),V=(0,k.useRef)(!1),H=(0,k.useRef)(null);e?x!==null&&!V.current&&H.current!==x&&(H.current=x,C({type:`sync`,value:x})):H.current!==null&&(H.current=null,C({type:`reset`}),V.current=!1);let W=!!(O&&A&&JSON.stringify(O)!==JSON.stringify(A)),G=(0,k.useCallback)(e=>{V.current=!0,C({type:`patch`,patch:e})},[]),q=(0,k.useCallback)(()=>{C({type:`discard`}),V.current=!1,z(null)},[]);D({id:`goals`,dirty:W,saving:j,save:(0,k.useCallback)(async()=>{if(!(!O||j)){M(!0),z(null);try{await P(O),V.current=!1,C({type:`saved`,value:O})}catch(e){let t=e instanceof Error?e.message:n.saveError;throw z(t),Error(t)}finally{M(!1)}}},[O,j,n.saveError]),discard:q});let J=(0,k.useCallback)(e=>{O&&G({notifications:{...O.notifications,...e}})},[O,G]),Y=(0,k.useMemo)(()=>{let e=new Map;for(let t of v)e.set(t.id,{id:t.id,label:t.label||t.id,configured:t.configured,enabled:t.enabled});for(let t of U)e.has(t.id)||e.set(t.id,t);for(let t of O?.notifications.channels??[])e.has(t)||e.set(t,{id:t,label:t});return[...e.values()].sort((e,t)=>{let n=e.enabled?0:e.configured?1:2,r=t.enabled?0:t.configured?1:2;return n===r?e.label.localeCompare(t.label):n-r})},[v,O?.notifications.channels]);return!e||!O?m?(0,F.jsx)(T,{children:(0,F.jsx)(y,{className:`size-4 animate-spin text-fg-muted`})}):null:(0,F.jsxs)(T,{children:[(0,F.jsx)(w,{icon:b,title:n.title,subtitle:n.hint}),R?(0,F.jsx)(`p`,{className:`mb-3 text-sm text-red-600 dark:text-red-400`,children:R}):null,(0,F.jsx)(ne,{t:n,activeTab:l,onChange:u}),(0,F.jsx)($,{t:n,id:`judge`,activeTab:l,children:(0,F.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:n.maxTurns}),(0,F.jsx)(`input`,{type:`number`,min:1,max:500,className:I(),value:O.maxTurns,onChange:e=>G({maxTurns:Number(e.target.value)||20})})]}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:n.judgeModelRef}),(0,F.jsx)(h,{value:O.judgeModelRef,placeholder:n.judgeModelRefPlaceholder,searchPlaceholder:r.modelSearchPlaceholder,noMatches:r.modelNoMatches,className:`w-full max-w-none min-w-0`,onChange:e=>G({judgeModelRef:e})}),O.judgeModelRef.trim()?(0,F.jsx)(`button`,{type:`button`,className:`mt-1 text-xs text-accent hover:underline`,onClick:()=>G({judgeModelRef:``}),children:n.judgeModelRefUseDefault}):(0,F.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.judgeModelRefHint})]}),(0,F.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg sm:col-span-2`,children:[(0,F.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:O.checklistMode,onChange:e=>G({checklistMode:e.target.checked})}),n.checklistMode]}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:n.parseFailures}),(0,F.jsx)(`input`,{type:`number`,min:1,max:20,className:I(),value:O.maxConsecutiveParseFailures,onChange:e=>G({maxConsecutiveParseFailures:Number(e.target.value)||3})})]}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:n.judgeTimeoutSec}),(0,F.jsx)(`input`,{type:`number`,min:5,max:120,className:I(),value:O.judgeTimeoutSec,onChange:e=>G({judgeTimeoutSec:Number(e.target.value)||60})})]}),(0,F.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,F.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:n.checklistHistoryChars}),(0,F.jsx)(`input`,{type:`number`,min:0,max:1e5,className:I(),value:O.checklistHistoryChars,onChange:e=>G({checklistHistoryChars:Math.max(0,Math.min(1e5,Math.floor(Number(e.target.value)||0)))})}),(0,F.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.checklistHistoryCharsHint})]})]})}),(0,F.jsx)($,{t:n,id:`notifications`,activeTab:l,children:(0,F.jsxs)(`div`,{className:`grid gap-3`,children:[(0,F.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg`,children:[(0,F.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:O.notifications.enabled,onChange:e=>J({enabled:e.target.checked})}),n.notificationsEnabled]}),(0,F.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg`,children:[(0,F.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:O.notifications.includeLinkedSessions,onChange:e=>J({includeLinkedSessions:e.target.checked})}),n.notificationsLinkedSessions]}),(0,F.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:n.notificationsChannels}),(0,F.jsx)(`div`,{className:`rounded-lg border border-edge bg-surface-panel p-2`,children:(0,F.jsx)(`div`,{className:`grid max-h-40 gap-1 overflow-y-auto pr-1`,children:Y.map(e=>(0,F.jsxs)(`label`,{className:`flex min-w-0 items-center gap-2 rounded-md px-2 py-1.5 text-sm text-fg hover:bg-surface-hover`,children:[(0,F.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:O.notifications.channels.includes(e.id),onChange:t=>{J({channels:t.target.checked?[...O.notifications.channels,e.id]:O.notifications.channels.filter(t=>t!==e.id)})}}),(0,F.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.label}),(0,F.jsx)(`span`,{className:`shrink-0 text-xs text-fg-muted`,children:e.id}),e.enabled?(0,F.jsx)(`span`,{className:`shrink-0 rounded-full border border-accent/40 bg-accent-soft px-1.5 py-0.5 text-[11px] text-accent-fg`,children:n.notificationsChannelEnabled}):e.configured?(0,F.jsx)(`span`,{className:`shrink-0 rounded-full border border-edge px-1.5 py-0.5 text-[11px] text-fg-muted`,children:n.notificationsChannelConfigured}):null]},e.id))})})]}),(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,children:n.notificationsEvents}),(0,F.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:L.map(e=>{let t=O.notifications.events.includes(e);return(0,F.jsx)(`button`,{type:`button`,className:i(`rounded-md border px-2 py-1 text-xs`,t?`border-accent bg-accent-soft text-accent-fg`:`border-edge bg-surface-panel text-fg-muted hover:bg-surface-hover`),onClick:()=>{J({events:t?O.notifications.events.filter(t=>t!==e):[...O.notifications.events,e]})},children:e},e)})})]})]}),(0,F.jsxs)(`div`,{className:`grid gap-2`,children:[(0,F.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,F.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.notificationsTargets}),(0,F.jsxs)(_,{type:`button`,variant:`secondary`,className:`h-8 gap-1.5 px-2.5 text-xs`,onClick:()=>J({targets:[...O.notifications.targets,{channel:Y[0]?.id??`telegram`,accountId:K(p?.payload?.config,Y[0]?.id??`telegram`)[0]??`default`,chatId:``}]}),children:[(0,F.jsx)(f,{className:`size-3.5`,"aria-hidden":!0}),n.notificationsAddTarget]})]}),O.notifications.targets.length?(0,F.jsx)(`div`,{className:`grid gap-2`,children:O.notifications.targets.map((e,t)=>(0,F.jsx)(X,{target:e,index:t,config:p?.payload?.config,channelOptions:Y,labels:n,inputClass:I(),onChange:(e,t)=>{let n=[...O.notifications.targets];n[e]=t,J({targets:n})},onRemove:e=>J({targets:O.notifications.targets.filter((t,n)=>n!==e)})},t))}):(0,F.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.notificationsNoTargets})]})]})})]})}function ae(){let e=(0,A.c)(15),t=o(se),n;e[0]===t?n=e[1]:(n=a(t),e[0]=t,e[1]=n);let r=n.goalsSettingsPage,i=!!s(oe),c;e[2]===r.title?c=e[3]:(c=(0,F.jsx)(`h1`,{className:`text-xl font-semibold tracking-tight text-fg`,children:r.title}),e[2]=r.title,e[3]=c);let l;e[4]===r.subtitle?l=e[5]:(l=(0,F.jsx)(`p`,{className:`max-w-2xl text-sm text-fg-muted`,children:r.subtitle}),e[4]=r.subtitle,e[5]=l);let u;e[6]!==c||e[7]!==l?(u=(0,F.jsxs)(`header`,{className:`flex flex-col gap-2`,children:[c,l]}),e[6]=c,e[7]=l,e[8]=u):u=e[8];let d;e[9]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,F.jsx)(O,{}),e[9]=d):d=e[9];let f;e[10]===i?f=e[11]:(f=(0,F.jsx)(ie,{hasToken:i}),e[10]=i,e[11]=f);let p;return e[12]!==u||e[13]!==f?(p=(0,F.jsxs)(`div`,{className:`mx-auto flex w-full max-w-app-main flex-col gap-6 px-4 py-6 sm:px-8`,children:[u,d,f]}),e[12]=u,e[13]=f,e[14]=p):p=e[14],p}function oe(e){return e.token}function se(e){return e.language}export{ae as GoalsSettingsPanel};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as e,n as t}from"./fetch-Bs7in_4F.js";import{o as n}from"./vendor-swr-BIWyz7Rc.js";import{yr as r}from"./index-COkF54xv.js";function i(){return e(`/api/workspace/heartbeat-md`)}async function a(){let e=await t(i());return typeof e.payload?.content==`string`?e.payload.content:``}function o(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function s(e){let t=o(e)?e:{},n=o(t.gateway)?t.gateway:{},r=o(n.heartbeat)?n.heartbeat:{},i=r.activeHours,a=o(i)?i:null,s=a&&typeof a.start==`string`&&typeof a.end==`string`&&a.start&&a.end?{start:a.start,end:a.end,timezone:typeof a.timezone==`string`?a.timezone:``}:null;return{enabled:!!(r.enabled??!0),intervalMs:typeof r.intervalMs==`number`&&Number.isFinite(r.intervalMs)?r.intervalMs:18e5,includeSystemPromptSection:r.includeSystemPromptSection===!0,target:typeof r.target==`string`?r.target:``,targetChatId:typeof r.targetChatId==`string`?r.targetChatId:``,prompt:typeof r.prompt==`string`?r.prompt:``,ackMaxChars:typeof r.ackMaxChars==`number`&&Number.isFinite(r.ackMaxChars)?r.ackMaxChars:``,isolatedSession:!!r.isolatedSession,activeHours:s}}function c(e){let t={enabled:e.enabled,intervalMs:e.intervalMs,includeSystemPromptSection:e.includeSystemPromptSection};return e.target.trim()?t.target=e.target.trim():t.target=null,e.targetChatId.trim()?t.targetChatId=e.targetChatId.trim():t.targetChatId=null,e.prompt.trim()?t.prompt=e.prompt.trim():t.prompt=null,e.ackMaxChars===``||e.ackMaxChars===void 0?t.ackMaxChars=null:t.ackMaxChars=e.ackMaxChars,e.isolatedSession?t.isolatedSession=!0:t.isolatedSession=null,e.activeHours?.start?.trim()&&e.activeHours?.end?.trim()?t.activeHours={start:e.activeHours.start.trim(),end:e.activeHours.end.trim(),...e.activeHours.timezone.trim()?{timezone:e.activeHours.timezone.trim()}:{}}:t.activeHours=null,t}async function l(n){await t(e(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{heartbeat:c(n)}})}),r()}async function u(r){await t(e(`/api/workspace/heartbeat-md`),{method:`PUT`,body:JSON.stringify({content:r})}),n(i())}async function d(n){await t(e(`/api/heartbeat/trigger`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n?{reason:n}:{})})}export{a,d as i,l as n,i as o,u as r,s as t};
|