@xopcai/xopc 0.0.134 → 0.0.136
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/Combination-HAlzriaz.js +41 -0
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-mQ4lbZRf.js → agent-avatar-dicebear-CER17NHM.js} +1 -1
- package/dist/gateway/static/root/assets/agents-Bv5R-N8Q.js +2 -0
- package/dist/gateway/static/root/assets/{app-management-settings-panel-Bj2YJiQe.js → app-management-settings-panel-B3Ap_wpX.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-B93olV5Z.js → appearance-settings-3kBO22Xd.js} +1 -1
- package/dist/gateway/static/root/assets/apps-page-BHYbGQcZ.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-D_yymKFJ.js → archive-plugin-D_vGeNB8.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-kfyH3HV-.js → attachment-load-hWV_8pHL.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-suggestion-card-DyGBB2WH.js → automation-suggestion-card-DVKmVTIo.js} +1 -1
- package/dist/gateway/static/root/assets/automations-page-BCTXpOBp.js +4 -0
- package/dist/gateway/static/root/assets/{binary-plugins-BX1AXf98.js → binary-plugins-BuXIeSPc.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-D-WEVNHU.js → block-editor-C1m0u-UU.js} +39 -39
- package/dist/gateway/static/root/assets/browser-settings-page-ChUF08V5.js +8 -0
- package/dist/gateway/static/root/assets/capability-presets-api-B7WWYaEh.js +1 -0
- package/dist/gateway/static/root/assets/{capability-presets-settings-panel-CHExb90z.js → capability-presets-settings-panel-D_Bh1PnA.js} +1 -1
- package/dist/gateway/static/root/assets/{channel-recipient-api-RANYrzfa.js → channel-recipient-api-sV06LCht.js} +1 -1
- package/dist/gateway/static/root/assets/channels-settings-BI2ChQc7.js +1 -0
- package/dist/gateway/static/root/assets/channels-status-swr-MY4Xh4fM.js +1 -0
- package/dist/gateway/static/root/assets/connectors-page-qgvEp09M.js +2 -0
- package/dist/gateway/static/root/assets/desktop-pet-BxMJlvb-.js +1 -0
- package/dist/gateway/static/root/assets/{desktop-pet-settings-C3JDiXSu.js → desktop-pet-settings-DCvpDImn.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-MT71cjgl.js → directory-picker-path-field-D1nxs9PA.js} +1 -1
- package/dist/gateway/static/root/assets/dist-Mys7eFJ5.js +1 -0
- package/dist/gateway/static/root/assets/{dreaming-settings-Cfx_Qg4R.js → dreaming-settings-EAWkpOgw.js} +3 -3
- package/dist/gateway/static/root/assets/{extension-debug-page-Wp23cLkf.js → extension-debug-page-LUQ8dE8z.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-B5HRNtVY.js → extension-page-B_mnhoRd.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-zPfMpsYi.js → extension-settings-page-BWQsGmvW.js} +1 -1
- package/dist/gateway/static/root/assets/{fetch-6HXXdO77.js → fetch-BWXmBizE.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-api-CsS_3Ii6.js → gateway-config-api-M9bzPASf.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-DOxh0hei.js → gateway-settings-CbgtpprN.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-BE1M9fH_.js → gateway-startup-retry-BALL91S7.js} +1 -1
- package/dist/gateway/static/root/assets/goal-create-dialog-CbP4t9aM.js +1 -0
- package/dist/gateway/static/root/assets/goal-detail-page-DlwI-MZZ.js +4 -0
- package/dist/gateway/static/root/assets/{goals-config-api--3Vzceq-.js → goals-config-api-BBhFVzBS.js} +1 -1
- package/dist/gateway/static/root/assets/goals-page-D26r7knp.js +2 -0
- package/dist/gateway/static/root/assets/{goals-settings-Dg_hQNVC.js → goals-settings-DdmVG_TR.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-settings-CecoDTZJ.js → heartbeat-settings-DZW2Xq-U.js} +1 -1
- package/dist/gateway/static/root/assets/index-CPwVzi9x.css +1 -0
- package/dist/gateway/static/root/assets/index-DZOm5_ex.js +262 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-BWMLAFxf.js → keyboard-shortcuts-settings-1IWd88-T.js} +1 -1
- package/dist/gateway/static/root/assets/logs-page-DxoKJO7-.js +7 -0
- package/dist/gateway/static/root/assets/{markdown-split-5tvDwUMS.js → markdown-split-BtdBj32h.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-RSjPG4B0.js → media-plugins-CpoPj3s8.js} +1 -1
- package/dist/gateway/static/root/assets/messages-CQ_k8RHj.js +3 -0
- package/dist/gateway/static/root/assets/models-hub-panel-D1Rp__dV.js +2 -0
- package/dist/gateway/static/root/assets/notes-page-CgR1bO2W.js +1 -0
- package/dist/gateway/static/root/assets/notes-workbench-ozsnmDTV.js +2 -0
- package/dist/gateway/static/root/assets/{page-tabs-DYNWfN6S.js → page-tabs-CVLqCfQB.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-B50PdIc8.js → preview-open-alternatives-CKUXJk2t.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-B4dqFAQF.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-DlRGXv4a.js +1 -0
- package/dist/gateway/static/root/assets/remote-access-hub-rZEYQMZV.js +1 -0
- package/dist/gateway/static/root/assets/{save-bar-controls-DggNb0SF.js → save-bar-controls-BtGni268.js} +1 -1
- package/dist/gateway/static/root/assets/{schedule-field-T4ti2C8S.js → schedule-field-BDGzKVWn.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-D6wGEfEa.js → schema-form-DQJsKMCE.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-DxGoCGU8.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-4e8ZQwxr.js +1 -0
- package/dist/gateway/static/root/assets/{settings-collapsible-section-Cgd_aLBV.js → settings-collapsible-section-c8XGd4-8.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-form-section-DnDrLMWZ.js → settings-form-section-By0YiDWo.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-loading-skeleton-A2OshMK8.js → settings-loading-skeleton-SYCPY-WM.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-CXMK9Vb3.js → settings-page-D9NwvnBt.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-layout-Da_LNPDS.js → settings-page-layout-CrICyGob.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-IjK-hDxf.js +1 -0
- package/dist/gateway/static/root/assets/{share-preview-page-BGZV-PCJ.js → share-preview-page-Dfnk9M_m.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-vQiRBra7.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-BIWv778A.js +1 -0
- package/dist/gateway/static/root/assets/skills-page-CruV215G.js +2 -0
- package/dist/gateway/static/root/assets/{system-settings-panel-D8uzXP0Y.js → system-settings-panel-BBVbSDFD.js} +1 -1
- package/dist/gateway/static/root/assets/{typed-models-lib-DQxv2BHa.js → typed-models-lib-CwFayhxu.js} +1 -1
- package/dist/gateway/static/root/assets/{use-channel-catalog-BCBfSoHx.js → use-channel-catalog-BKtHOM50.js} +1 -1
- package/dist/gateway/static/root/assets/{user-profile-settings-panel-DkZSHsIs.js → user-profile-settings-panel-_KDWzagh.js} +1 -1
- package/dist/gateway/static/root/assets/{utils-ivGpUrZi.js → utils-BiUjIHb4.js} +1 -1
- package/dist/gateway/static/root/assets/voice-api-key-field-agJqlm4o.js +1 -0
- package/dist/gateway/static/root/assets/work-item-detail-page-Bdw4ATCb.js +1 -0
- package/dist/gateway/static/root/assets/workflow-run-setup-panel-D-Dy6mTy.js +3 -0
- package/dist/gateway/static/root/assets/workflow-start-dialog-GammZ2GK.js +1 -0
- package/dist/gateway/static/root/assets/workflows-page-Cw5zrqti.js +18 -0
- package/dist/gateway/static/root/index.html +7 -8
- package/dist/package.js +1 -1
- package/dist/src/agent/image/inbound-image-handling.d.ts +1 -0
- package/dist/src/agent/image/inbound-image-handling.js +4 -1
- package/dist/src/agent/image/inbound-image-handling.js.map +1 -1
- package/dist/src/agent/image/tool-model-config.d.ts +18 -2
- package/dist/src/agent/image/tool-model-config.js +100 -14
- package/dist/src/agent/image/tool-model-config.js.map +1 -1
- package/dist/src/agent/image/vision-detection.js +4 -23
- package/dist/src/agent/image/vision-detection.js.map +1 -1
- package/dist/src/agent/inbound/attachment-pipeline.js +3 -0
- package/dist/src/agent/inbound/attachment-pipeline.js.map +1 -1
- package/dist/src/agent/messaging/command-handler.d.ts +5 -2
- package/dist/src/agent/messaging/command-handler.js +4 -3
- package/dist/src/agent/messaging/command-handler.js.map +1 -1
- package/dist/src/agent/service/btw-query.d.ts +2 -0
- package/dist/src/agent/service/btw-query.js +4 -2
- package/dist/src/agent/service/btw-query.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 +1 -1
- package/dist/src/agent/service/direct-turn-helpers.js.map +1 -1
- package/dist/src/agent/service/process-direct-streaming.js +58 -1
- package/dist/src/agent/service/process-direct-streaming.js.map +1 -1
- package/dist/src/agent/service.js +1 -1
- package/dist/src/agent/service.js.map +1 -1
- package/dist/src/agent/session/session-inspector.d.ts +2 -1
- package/dist/src/agent/session/session-inspector.js +5 -3
- package/dist/src/agent/session/session-inspector.js.map +1 -1
- package/dist/src/agent/tools/factory.js +2 -1
- package/dist/src/agent/tools/factory.js.map +1 -1
- package/dist/src/agent/tools/image-tool.d.ts +1 -0
- package/dist/src/agent/tools/image-tool.js +4 -1
- package/dist/src/agent/tools/image-tool.js.map +1 -1
- package/dist/src/chat-commands/builtins/review.js +94 -7
- package/dist/src/chat-commands/builtins/review.js.map +1 -1
- package/dist/src/chat-commands/context.d.ts +5 -3
- package/dist/src/chat-commands/context.js +5 -2
- package/dist/src/chat-commands/context.js.map +1 -1
- package/dist/src/chat-commands/index.d.ts +1 -1
- package/dist/src/chat-commands/index.js.map +1 -1
- package/dist/src/chat-commands/types.d.ts +12 -1
- package/dist/src/config/agent-profile.js +1 -1
- package/dist/src/gateway/agents-admin.d.ts +5 -0
- package/dist/src/gateway/agents-admin.js +6 -1
- package/dist/src/gateway/agents-admin.js.map +1 -1
- package/dist/src/gateway/hono/routes/models.js +2 -1
- package/dist/src/gateway/hono/routes/models.js.map +1 -1
- package/dist/src/gateway/hono/routes/projects.js +88 -0
- package/dist/src/gateway/hono/routes/projects.js.map +1 -1
- package/dist/src/gateway/hono/routes/sessions.js +2 -1
- package/dist/src/gateway/hono/routes/sessions.js.map +1 -1
- package/dist/src/gateway/hono/routes/workflows.js +1 -0
- package/dist/src/gateway/hono/routes/workflows.js.map +1 -1
- package/dist/src/gateway/image-capabilities.d.ts +7 -1
- package/dist/src/gateway/image-capabilities.js +16 -3
- package/dist/src/gateway/image-capabilities.js.map +1 -1
- package/dist/src/gateway/service/sessions-api.d.ts +1 -0
- package/dist/src/gateway/service/sessions-api.js.map +1 -1
- package/dist/src/gateway/service.js +3 -3
- package/dist/src/projects/project-loop.js +2 -2
- package/dist/src/projects/project-loop.js.map +1 -1
- package/dist/src/review/review-types.js +2 -1
- package/dist/src/review/review-types.js.map +1 -1
- package/dist/src/session/client-history.d.ts +1 -0
- package/dist/src/session/client-history.js +56 -0
- package/dist/src/session/client-history.js.map +1 -1
- package/dist/src/session/index.js +1 -1
- package/dist/src/session/manager.d.ts +1 -0
- package/dist/src/session/manager.js.map +1 -1
- package/dist/src/session/store.d.ts +1 -0
- package/dist/src/session/store.js +30 -1
- package/dist/src/session/store.js.map +1 -1
- package/dist/src/tui/backends/embedded-backend.js +1 -1
- package/dist/src/tui/components/assistant-message.js +10 -3
- package/dist/src/tui/components/assistant-message.js.map +1 -1
- package/dist/src/tui/components/bash-execution.d.ts +4 -0
- package/dist/src/tui/components/bash-execution.js +15 -7
- package/dist/src/tui/components/bash-execution.js.map +1 -1
- package/dist/src/tui/tool-summary.js +9 -3
- package/dist/src/tui/tool-summary.js.map +1 -1
- package/dist/src/tui/tui-submit.d.ts +3 -0
- package/dist/src/tui/tui-submit.js +24 -1
- package/dist/src/tui/tui-submit.js.map +1 -1
- package/dist/src/tui/tui.js +29 -2
- package/dist/src/tui/tui.js.map +1 -1
- package/dist/src/work-items/index.d.ts +1 -0
- package/dist/src/work-items/index.js +2 -1
- package/dist/src/work-items/work-item-workflow-judge.d.ts +8 -0
- package/dist/src/work-items/work-item-workflow-judge.js +50 -0
- package/dist/src/work-items/work-item-workflow-judge.js.map +1 -0
- package/dist/src/workflows/domain/run.d.ts +17 -0
- package/dist/src/workflows/domain/run.js.map +1 -1
- package/dist/src/workflows/service/workflow-run-service.d.ts +3 -0
- package/dist/src/workflows/service/workflow-run-service.js +67 -0
- package/dist/src/workflows/service/workflow-run-service.js.map +1 -1
- package/dist/src/workflows/service/workflow-run-service.types.d.ts +4 -1
- package/dist/src/workflows/service/workflow-session-bridge.d.ts +1 -0
- package/dist/src/workflows/service/workflow-session-bridge.js +45 -0
- package/dist/src/workflows/service/workflow-session-bridge.js.map +1 -1
- package/package.json +1 -1
- package/dist/gateway/static/root/assets/Combination-BzaXOLd9.js +0 -41
- package/dist/gateway/static/root/assets/agents-BP0iRtiu.js +0 -2
- package/dist/gateway/static/root/assets/apps-page-12_2SDFq.js +0 -1
- package/dist/gateway/static/root/assets/automations-page-V-tw6y1o.js +0 -4
- package/dist/gateway/static/root/assets/browser-settings-page-aMPnxWXi.js +0 -8
- package/dist/gateway/static/root/assets/capability-presets-api-CsaY2Z8B.js +0 -1
- package/dist/gateway/static/root/assets/channels-settings-N8NujD--.js +0 -1
- package/dist/gateway/static/root/assets/channels-status-swr-BG_j4Ci-.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-zBJbFgnK.js +0 -2
- package/dist/gateway/static/root/assets/desktop-pet-DfA-hVlt.js +0 -1
- package/dist/gateway/static/root/assets/dist-CkobR7mk.js +0 -1
- package/dist/gateway/static/root/assets/dist-DokQNVMQ.js +0 -1
- package/dist/gateway/static/root/assets/goal-create-dialog-BOWSTGB-.js +0 -1
- package/dist/gateway/static/root/assets/goal-detail-page-CCLgkqj1.js +0 -4
- package/dist/gateway/static/root/assets/goals-page-CsfIp8Vl.js +0 -2
- package/dist/gateway/static/root/assets/index-BOme955B.js +0 -262
- package/dist/gateway/static/root/assets/index-DXUkWmeK.css +0 -1
- package/dist/gateway/static/root/assets/logs-page-CW7AMYhN.js +0 -7
- package/dist/gateway/static/root/assets/messages-DR9ODkb8.js +0 -3
- package/dist/gateway/static/root/assets/models-hub-panel-mKfeyGVq.js +0 -2
- package/dist/gateway/static/root/assets/notes-page-DYw5zPeJ.js +0 -1
- package/dist/gateway/static/root/assets/notes-workbench-SPdKpvSN.js +0 -2
- package/dist/gateway/static/root/assets/project-detail-page-D3yP4K3k.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-B6EV45NR.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-9foX60FQ.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-BReBhxWd.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-DNDBN4nT.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-C8UtBMJ_.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-xXAMKlc7.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-CurjHfEM.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-BRR7NQkL.js +0 -2
- package/dist/gateway/static/root/assets/voice-api-key-field-DCiECZN1.js +0 -1
- package/dist/gateway/static/root/assets/work-item-detail-page-DAel5CHH.js +0 -1
- package/dist/gateway/static/root/assets/workflow-run-setup-panel-2w0zj9eJ.js +0 -3
- package/dist/gateway/static/root/assets/workflow-start-dialog-B5xdDFV-.js +0 -1
- package/dist/gateway/static/root/assets/workflows-page-DRhiSwuU.js +0 -18
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-DR9ODkb8.js";import{a as o,n as s,o as c}from"./fetch-6HXXdO77.js";import{n as l}from"./locale-store-Ba72bFmP.js";import{r as u}from"./toast-z0toXu32.js";import{$a as d,$r as f,Ba as p,Cc as m,Co as h,Cs as g,Do as _,El as v,Fr as y,Ga as b,Ha as x,Lr as S,Mr as C,Ms as w,Nr as T,Oo as E,Pr as D,Qr as O,Ra as k,Ua as A,Us as j,Va as ee,Vc as M,Wa as te,Xc as N,Zr as P,_c as ne,_i as F,bs as re,cs as I,ds as L,ei as ie,ho as ae,io as oe,jc as se,ma as ce,nc as le,ns as ue,os as R,pa as z,po as de,ro as fe,ti as pe,tl as me,to as he,vo as B,wo as V,xs as ge,za as _e,zo as ve}from"./index-BOme955B.js";import{n as ye,t as be}from"./settings-form-section-DnDrLMWZ.js";import{t as xe}from"./page-tabs-DYNWfN6S.js";var H=e(t(),1),U=n(),W=r(),G=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`,Se=[`c0`,`c1`,`c2`,`c3`,`c4`,`c5`];function Ce(e,t){return t.some(t=>t.connectorId===e.id)}function K(e,t){return t[e]??e}function q(e,t){return t.connectorCategoryTemplate.replace(`{{category}}`,K(e,t.connectorCategoryLabels))}function we(){let e=(0,U.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,W.jsx)(`div`,{className:`flex h-full min-h-[9.5rem] flex-col rounded-xl bg-surface-panel p-4 shadow-surface`,"aria-hidden":!0,children:(0,W.jsx)(`div`,{className:`flex min-h-0 flex-1 items-start gap-3`,children:(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,W.jsx)(`div`,{className:i(`h-4 min-w-0 flex-1`,G)}),(0,W.jsx)(`div`,{className:i(`h-8 w-[4.5rem] shrink-0 rounded-lg`,G)})]}),(0,W.jsx)(`div`,{className:i(`h-3 w-full`,G)}),(0,W.jsx)(`div`,{className:i(`h-3 w-[88%]`,G)})]})})}),e[0]=t):t=e[0],t}function Te(){let e=(0,U.c)(3),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,W.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2`,children:[(0,W.jsx)(`div`,{className:i(`h-4 w-48 max-w-full`,G)}),(0,W.jsx)(`div`,{className:i(`h-3 w-72 max-w-full`,G)})]}),e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,W.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[t,(0,W.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,W.jsx)(`div`,{className:i(`h-9 w-20 rounded-lg`,G)}),(0,W.jsx)(`div`,{className:i(`h-9 w-20 rounded-lg`,G)})]})]}),e[1]=n):n=e[1];let r;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,W.jsxs)(`div`,{className:`rounded-2xl bg-surface-panel p-4 shadow-surface`,"aria-hidden":!0,children:[n,(0,W.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,W.jsx)(`div`,{className:i(`h-8 w-20 rounded-md`,G)}),(0,W.jsx)(`div`,{className:i(`h-8 w-24 rounded-md`,G)}),(0,W.jsx)(`div`,{className:i(`h-8 w-28 rounded-md`,G)})]}),(0,W.jsx)(`div`,{className:i(`mt-3 h-20 rounded-xl`,G)})]}),e[2]=r):r=e[2],r}function Ee(e){let t=(0,U.c)(69),{connector:n,installed:r,onInstall:a,onOpenDetails:o,t:s}=e,c;t[0]!==n.category||t[1]!==s?(c=q(n.category,s),t[0]=n.category,t[1]=s,t[2]=c):c=t[2];let l=c,u,d,f,p,m,h,g,_,v,y;if(t[3]!==l||t[4]!==n||t[5]!==r||t[6]!==a||t[7]!==o||t[8]!==s.install||t[9]!==s.installedBadge){let e=n.capabilities.slice(0,4),c=Math.max(0,n.capabilities.length-e.length),b;t[20]!==n||t[21]!==a||t[22]!==s.install?(b=e=>(0,W.jsxs)(V,{type:`button`,variant:`primary`,className:i(`h-8 justify-center px-2.5 text-xs font-medium`,e),onClick:e=>{e.stopPropagation(),a(n)},children:[(0,W.jsx)(w,{className:`size-4`}),s.install]}),t[20]=n,t[21]=a,t[22]=s.install,t[23]=b):b=t[23],u=b;let x;t[24]!==n||t[25]!==o?(x=e=>{!o||e.currentTarget!==e.target||e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),o(n))},t[24]=n,t[25]=o,t[26]=x):x=t[26];let S=x,C=o?`cursor-pointer`:null;t[27]===C?g=t[28]:(g=i(`group flex min-h-[9.5rem] flex-col rounded-lg bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45 focus-within:ring-2 focus-within:ring-accent/30`,C),t[27]=C,t[28]=g),_=o?`button`:void 0,v=o?0:void 0,t[29]!==n||t[30]!==o?(y=()=>o?.(n),t[29]=n,t[30]=o,t[31]=y):y=t[31],d=S,f=`flex min-w-0 flex-1 flex-col`;let T;t[32]===n.displayName?T=t[33]:(T=(0,W.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:n.displayName}),t[32]=n.displayName,t[33]=T);let E;t[34]===l?E=t[35]:(E=(0,W.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-subtle`,children:l}),t[34]=l,t[35]=E);let D;t[36]!==T||t[37]!==E?(D=(0,W.jsx)(`div`,{className:`flex min-w-0 items-start gap-3`,children:(0,W.jsxs)(`div`,{className:`min-w-0`,children:[T,E]})}),t[36]=T,t[37]=E,t[38]=D):D=t[38];let O;t[39]!==r||t[40]!==u?(O=r?null:(0,W.jsx)(`div`,{className:`hidden shrink-0 items-center gap-1 transition-opacity sm:pointer-events-none sm:flex sm:opacity-0 sm:group-hover:pointer-events-auto sm:group-hover:opacity-100 sm:group-focus-within:pointer-events-auto sm:group-focus-within:opacity-100`,children:u()}),t[39]=r,t[40]=u,t[41]=O):O=t[41];let k;t[42]!==r||t[43]!==s.installedBadge?(k=r?(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-emerald-500/30 bg-emerald-500/10 px-2 py-0.5 text-[11px] font-medium text-emerald-700 dark:text-emerald-300`,children:[(0,W.jsx)(N,{className:`size-3`,"aria-hidden":!0}),s.installedBadge]}):null,t[42]=r,t[43]=s.installedBadge,t[44]=k):k=t[44];let A;t[45]!==O||t[46]!==k?(A=(0,W.jsxs)(`div`,{className:`flex shrink-0 items-start gap-2`,children:[O,k]}),t[45]=O,t[46]=k,t[47]=A):A=t[47],t[48]!==D||t[49]!==A?(p=(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[D,A]}),t[48]=D,t[49]=A,t[50]=p):p=t[50],t[51]===n.description?m=t[52]:(m=(0,W.jsx)(`p`,{className:`mt-4 line-clamp-2 text-sm leading-6 text-fg-muted`,title:n.description,children:n.description}),t[51]=n.description,t[52]=m),h=e.length>0?(0,W.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-1.5`,children:[e.map(J),c>0?(0,W.jsxs)(`span`,{className:`rounded-md bg-surface-base px-2 py-0.5 text-[11px] text-fg-subtle`,children:[`+`,c]}):null]}):null,t[3]=l,t[4]=n,t[5]=r,t[6]=a,t[7]=o,t[8]=s.install,t[9]=s.installedBadge,t[10]=u,t[11]=d,t[12]=f,t[13]=p,t[14]=m,t[15]=h,t[16]=g,t[17]=_,t[18]=v,t[19]=y}else u=t[10],d=t[11],f=t[12],p=t[13],m=t[14],h=t[15],g=t[16],_=t[17],v=t[18],y=t[19];let b;t[53]!==f||t[54]!==p||t[55]!==m||t[56]!==h?(b=(0,W.jsxs)(`div`,{className:f,children:[p,m,h]}),t[53]=f,t[54]=p,t[55]=m,t[56]=h,t[57]=b):b=t[57];let x;t[58]!==r||t[59]!==u?(x=r?null:(0,W.jsx)(`div`,{className:`mt-4 flex flex-col gap-2 border-t border-edge pt-3 sm:hidden`,children:u(`w-full`)}),t[58]=r,t[59]=u,t[60]=x):x=t[60];let S;return t[61]!==d||t[62]!==b||t[63]!==x||t[64]!==g||t[65]!==_||t[66]!==v||t[67]!==y?(S=(0,W.jsxs)(`div`,{className:g,role:_,tabIndex:v,onClick:y,onKeyDown:d,children:[b,x]}),t[61]=d,t[62]=b,t[63]=x,t[64]=g,t[65]=_,t[66]=v,t[67]=y,t[68]=S):S=t[68],S}function J(e){return(0,W.jsx)(`span`,{className:`rounded-md bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:e},e)}function Y(e,t){if(!e.payload)throw Error(e.error??t);return e.payload}async function De(){return Y(await s(c(`/api/connectors/catalog`)),`Could not load connector catalog.`).connectors}async function Oe(e){let t=new URLSearchParams;return e?.q?.trim()&&t.set(`q`,e.q.trim()),e?.page&&t.set(`page`,String(e.page)),e?.pageSize&&t.set(`pageSize`,String(e.pageSize)),e?.category?.trim()&&t.set(`category`,e.category.trim()),e?.sort&&t.set(`sort`,e.sort),Y(await s(c(`/api/capabilities/connectors${t.size?`?${t.toString()}`:``}`)),`Could not load Store connector capabilities.`)}async function ke(e,t){return Y(await s(c(`/api/capabilities/connectors/${encodeURIComponent(e)}/install-plan`),{method:`POST`,body:JSON.stringify({version:t})}),`Could not prepare connector installation.`).plan}async function Ae(e,t,n){let r=await s(c(`/api/capabilities/connectors/${encodeURIComponent(e)}/install`),{method:`POST`,body:JSON.stringify({...t,version:n})});return z(),Y(r,`Could not install Store connector.`).instance}async function je(){return Y(await s(c(`/api/connectors/catalog`)),`Could not load connector registries.`).registries??[]}async function Me(){return Y(await s(c(`/api/connectors/installed`)),`Could not load installed connectors.`).instances}var Ne=new Map,Pe=300*1e3;async function Fe(e,t=`all`,n){let r=e.trim(),i=t.trim()||`all`,a=n?.browse??!1,o=Math.max(n?.page??1,1),l=Math.max(n?.pageSize??24,1),u=`${i}:${r}:${a?`browse`:`search`}:${o}:${l}`,d=Date.now(),f=Ne.get(u);if(f&&f.expiresAt>d)return f.promise;let p=new URLSearchParams;r&&p.set(`q`,r),i!==`all`&&p.set(`source`,i),a&&p.set(`browse`,`1`),p.set(`page`,String(o)),p.set(`pageSize`,String(l));let m=s(c(`/api/connectors/registry/search?${p.toString()}`)).then(e=>{let t=Y(e,`Could not search connector registries.`),n=Math.max(0,...(t.results??[]).map(e=>e.totalPages??0))||void 0;return{connectors:t.connectors,totalPages:n}});Ne.set(u,{expiresAt:d+Pe,promise:m});try{return await m}catch(e){throw Ne.delete(u),e}}async function Ie(e){return Y(await s(c(`/api/connectors/${encodeURIComponent(e)}/oauth/start`),{method:`POST`}),`Could not start connector OAuth.`).oauth}async function Le(e,t){return Y(await s(c(`/api/connectors/${encodeURIComponent(e)}/oauth/complete`),{method:`POST`,body:JSON.stringify({deviceCode:t})}),`Could not complete connector OAuth.`).oauth}async function Re(e,t){let n=await s(c(`/api/connectors/${encodeURIComponent(e)}/install`),{method:`POST`,body:JSON.stringify(t)});return z(),Y(n,`Could not install connector.`).instance}async function ze(e,t={}){return Y(await s(c(`/api/connectors/preview`),{method:`POST`,body:JSON.stringify({...t,definition:e})}),`Could not preview connector capabilities.`).preview}async function Be(e,t){return Y(await s(c(`/api/connectors/${encodeURIComponent(e)}/config`),{method:`POST`,body:JSON.stringify(t)}),`Could not update connector config.`).instance}async function Ve(e){await s(c(`/api/connectors/${encodeURIComponent(e)}`),{method:`DELETE`}),z()}async function He(e){return Y(await s(c(`/api/connectors/${encodeURIComponent(e)}/test`),{method:`POST`}),`Connector test failed.`)}async function Ue(){return Y(await s(c(`/api/connectors/composio/connections`)),`Could not load Composio connections.`).connections}async function We(e){return Y(await s(c(`/api/connectors/composio/${encodeURIComponent(e)}/authorize`),{method:`POST`}),`Could not start Composio authorization.`).oauth}async function Ge(e){return Y(await s(c(`/api/connectors/composio/${encodeURIComponent(e)}/scope`)),`Could not load Composio scope.`).scope}async function Ke(e,t){let n=await s(c(`/api/connectors/composio/${encodeURIComponent(e)}/scope`),{method:`POST`,body:JSON.stringify({scope:t})});return z(),Y(n,`Could not update Composio scope.`).scope}async function qe(e){return Y(await s(c(`/api/connectors/composio/${encodeURIComponent(e)}/tools`)),`Could not load Composio tools.`).tools}async function Je(e=50){return Y(await s(c(`/api/connectors/composio/triggers?limit=${encodeURIComponent(String(e))}`)),`Could not load Composio trigger events.`).events}function X(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,String(n)),e)}function Ye(e,t){return t.connectorCapabilityLabels[e]??e}function Xe(e,t){if(e.runtime.type===`mcp`)return X(t.connectorRuntimeMcp,{serverId:e.runtime.serverId});let n=e.runtime.id??e.runtime.channelId??e.runtime.toolkit??e.runtime.toolsetId??e.runtime.sourceKind??e.runtime.type;return X(t.connectorRuntimeGeneric,{runtime:e.runtime.type,id:n})}function Ze(e,t){return e.auth.mode===`oauth`?t.connectorAuthOAuth:e.auth.mode===`apiKey`?t.connectorAuthApiKey:t.connectorAuthNone}function Qe(e){return(e.setup.secrets??[]).filter(e=>e.required).length+(e.setup.config??[]).filter(e=>e.required).length}function $e(e){let t=(0,U.c)(12),{title:n,items:r}=e;if(r.length===0)return null;let i;t[0]===n?i=t[1]:(i=(0,W.jsx)(`div`,{className:`border-b border-edge px-3 py-2 text-xs font-semibold text-fg`,children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=r.slice(0,16).map(et),t[2]=r,t[3]=a);let o;t[4]===r.length?o=t[5]:(o=r.length>16?(0,W.jsxs)(`div`,{className:`px-3 py-2 text-xs text-fg-subtle`,children:[`+`,r.length-16]}):null,t[4]=r.length,t[5]=o);let s;t[6]!==a||t[7]!==o?(s=(0,W.jsxs)(`div`,{className:`max-h-48 overflow-y-auto`,children:[a,o]}),t[6]=a,t[7]=o,t[8]=s):s=t[8];let c;return t[9]!==i||t[10]!==s?(c=(0,W.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base`,children:[i,s]}),t[9]=i,t[10]=s,t[11]=c):c=t[11],c}function et(e){return(0,W.jsxs)(`div`,{className:`border-b border-edge-subtle px-3 py-2 last:border-b-0`,children:[(0,W.jsx)(`div`,{className:`break-words font-mono text-xs font-medium text-fg`,children:e.title}),e.description?(0,W.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:e.description}):null]},e.id)}function tt({connector:e,installed:t,onClose:n,onInstall:r,t:a}){let[o,s]=(0,H.useState)(!1),[c,l]=(0,H.useState)(null),[u,d]=(0,H.useState)(null),f=Qe(e),m=e.capabilities.slice(0,8),h=Math.max(0,e.capabilities.length-m.length),v=[...(e.setup.secrets??[]).map(e=>({key:`secret:${e.key}`,label:e.label,description:e.description,required:e.required,kind:a.connectorSetupSecret})),...(e.setup.config??[]).map(e=>({key:`config:${e.key}`,label:e.label,description:e.description,required:!!e.required,kind:a.connectorSetupConfig}))],y=async()=>{s(!0),d(null);try{l(await ze(e))}catch(e){l(null),d(e instanceof Error?e.message:String(e))}finally{s(!1)}};return(0,W.jsx)(A,{open:!0,onOpenChange:e=>{e||n()},children:(0,W.jsxs)(x,{children:[(0,W.jsx)(ee,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,W.jsxs)(_e,{className:i(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(100vh-2rem,44rem)] w-[min(100%-2rem,min(92vw,52rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-panel shadow-float outline-none dark:border-edge`),children:[(0,W.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-base px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:e.source}),(0,W.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-base px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:e.kind}),t?(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-emerald-500/30 bg-emerald-500/10 px-2 py-0.5 text-[11px] font-medium text-emerald-700 dark:text-emerald-300`,children:[(0,W.jsx)(N,{className:`size-3`,"aria-hidden":!0}),a.installedBadge]}):null]}),(0,W.jsx)(te,{className:`text-base font-semibold text-fg`,children:e.displayName}),(0,W.jsx)(p,{className:`mt-1 line-clamp-3 text-sm leading-6 text-fg-muted`,children:e.description})]}),(0,W.jsx)(k,{asChild:!0,children:(0,W.jsxs)(`button`,{type:`button`,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,B.focusRingPanel),"aria-label":a.modalClose,children:[(0,W.jsx)(_,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,W.jsx)(`span`,{className:`sr-only`,children:a.modalClose})]})})]}),(0,W.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:[(0,W.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,W.jsx)(E,{className:`size-3.5`,"aria-hidden":!0}),a.detailTools]}),(0,W.jsx)(`p`,{className:`mt-2 text-sm font-semibold text-fg`,children:c?X(a.connectorPreviewToolsCount,{count:c.toolCount}):a.connectorPreviewUnknown})]}),(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,W.jsx)(le,{className:`size-3.5`,"aria-hidden":!0}),a.detailPermissions]}),(0,W.jsx)(`p`,{className:`mt-2 text-sm font-semibold text-fg`,children:Ze(e,a)})]}),(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,W.jsx)(se,{className:`size-3.5`,"aria-hidden":!0}),a.connectorRequiredInputs]}),(0,W.jsx)(`p`,{className:`mt-2 text-sm font-semibold text-fg`,children:X(a.connectorRequiredInputsCount,{count:f})})]})]}),(0,W.jsxs)(`div`,{className:`mt-5 grid gap-5 lg:grid-cols-[minmax(0,1fr)_18rem]`,children:[(0,W.jsxs)(`div`,{className:`min-w-0 space-y-5`,children:[(0,W.jsxs)(`section`,{children:[(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.connectorCapabilitiesTitle}),(0,W.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:[m.map(e=>(0,W.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-base px-2 py-1 text-xs text-fg-muted`,children:Ye(e,a)},e)),h>0?(0,W.jsxs)(`span`,{className:`rounded-md border border-edge bg-surface-base px-2 py-1 text-xs text-fg-subtle`,children:[`+`,h]}):null]}),(0,W.jsx)(`p`,{className:`mt-3 text-sm leading-6 text-fg-muted`,children:a.connectorCapabilitiesHint})]}),u?(0,W.jsx)(`p`,{className:`rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:u}):null,c?(0,W.jsxs)(`section`,{children:[(0,W.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.connectorPreviewTitle}),(0,W.jsx)(`span`,{className:i(`rounded-full px-2 py-0.5 text-xs font-medium`,c.ok?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-amber-500/10 text-amber-700 dark:text-amber-300`),children:c.ok?a.healthStatusHealthy:a.healthStatusLabels[c.status]??c.status})]}),(0,W.jsxs)(`div`,{className:`mb-3 grid gap-2 text-xs sm:grid-cols-3`,children:[(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base px-3 py-2`,children:[(0,W.jsx)(`div`,{className:`font-semibold text-fg`,children:c.toolCount}),(0,W.jsx)(`div`,{className:`text-fg-muted`,children:a.toolsMetric})]}),(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base px-3 py-2`,children:[(0,W.jsx)(`div`,{className:`font-semibold text-fg`,children:c.resourceCount}),(0,W.jsx)(`div`,{className:`text-fg-muted`,children:a.resourcesMetric})]}),(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base px-3 py-2`,children:[(0,W.jsx)(`div`,{className:`font-semibold text-fg`,children:c.promptCount}),(0,W.jsx)(`div`,{className:`text-fg-muted`,children:a.promptsMetric})]})]}),(0,W.jsxs)(`div`,{className:`grid gap-2`,children:[(0,W.jsx)($e,{title:a.detailTools,items:c.tools.map(e=>({id:e.name,title:e.shortName??e.name,description:e.description}))}),(0,W.jsx)($e,{title:a.detailResources,items:c.resources.map(e=>({id:e.uri,title:e.title??e.name??e.uri,description:e.description??e.uri}))}),(0,W.jsx)($e,{title:a.detailPrompts,items:c.prompts.map(e=>({id:e.name,title:e.title??e.name,description:e.description??X(a.promptArgumentCount,{count:e.argumentCount})}))})]}),c.error?(0,W.jsx)(`p`,{className:`mt-3 text-xs leading-5 text-fg-subtle`,children:c.error}):null,c.action?(0,W.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-subtle`,children:c.action}):null]}):null]}),(0,W.jsxs)(`aside`,{className:`space-y-3`,children:[(0,W.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,W.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,W.jsx)(le,{className:`size-4 text-accent`,"aria-hidden":!0}),a.detailPermissions]}),(0,W.jsx)(`p`,{className:`mt-2 text-sm font-medium text-fg`,children:Ze(e,a)})]}),(0,W.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,W.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,W.jsx)(se,{className:`size-4 text-accent`,"aria-hidden":!0}),a.connectorSetupTitle]}),v.length>0?(0,W.jsx)(`div`,{className:`mt-3 divide-y divide-edge overflow-hidden rounded-lg border border-edge`,children:v.map(e=>(0,W.jsxs)(`div`,{className:`bg-surface-panel px-3 py-2.5`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.label}),(0,W.jsx)(`span`,{className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[11px] text-fg-muted`,children:e.kind}),e.required?(0,W.jsx)(`span`,{className:`rounded-md bg-amber-500/10 px-1.5 py-0.5 text-[11px] font-medium text-amber-700 dark:text-amber-300`,children:a.connectorSetupRequired}):null]}),e.description?(0,W.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:e.description}):null]},e.key))}):(0,W.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:a.connectorSetupNone})]}),(0,W.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,W.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,W.jsx)(R,{className:`size-4 text-accent`,"aria-hidden":!0}),a.connectorRuntimeTitle]}),(0,W.jsx)(`p`,{className:`mt-2 break-words text-xs leading-5 text-fg-muted`,children:Xe(e,a)})]})]})]})]}),(0,W.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[(0,W.jsx)(k,{asChild:!0,children:(0,W.jsx)(V,{variant:`secondary`,children:a.modalClose})}),(0,W.jsxs)(V,{variant:`secondary`,disabled:o,onClick:()=>void y(),children:[o?(0,W.jsx)(j,{className:`size-4 animate-spin`}):(0,W.jsx)(E,{className:`size-4`}),a.connectorPreviewButton]}),t?(0,W.jsxs)(V,{variant:`secondary`,disabled:!0,children:[(0,W.jsx)(g,{className:`size-4`}),a.installedBadge]}):(0,W.jsxs)(V,{variant:`primary`,onClick:()=>{r(e),n()},children:[(0,W.jsx)(w,{className:`size-4`}),a.install]})]})]})]})})}var nt=(0,H.memo)(function(e){let t=(0,U.c)(19),{loading:n,searchQuery:r,setSearchQuery:i,onReloadClick:a,onAddCustomServer:o,searchPlaceholder:s,addLabel:c,reloadLabel:l}=e,u;t[0]!==n||t[1]!==a||t[2]!==l?(u=(0,W.jsx)(F,{className:`size-9 shrink-0 p-0`,loading:n,label:l,title:l,onClick:a}),t[0]=n,t[1]=a,t[2]=l,t[3]=u):u=t[3];let d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,W.jsx)(I,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-disabled`,strokeWidth:1.75,"aria-hidden":!0}),t[4]=d):d=t[4];let f;t[5]===i?f=t[6]:(f=e=>i(e.currentTarget.value),t[5]=i,t[6]=f);let p;t[7]!==s||t[8]!==r||t[9]!==f?(p=(0,W.jsxs)(`label`,{className:`relative flex min-h-9 min-w-0 max-w-sm cursor-text items-center rounded-pill border border-edge bg-surface-panel py-1.5 pl-9 pr-3 shadow-surface dark:bg-surface-hover/40 sm:max-w-md`,children:[d,(0,W.jsx)(`input`,{type:`search`,enterKeyHint:`search`,value:r,onChange:f,placeholder:s,autoComplete:`off`,spellCheck:!1,className:`min-w-0 flex-1 appearance-none border-0 bg-transparent py-0.5 text-sm leading-normal text-fg caret-current placeholder:text-fg-disabled focus:border-0 focus:shadow-none focus:outline-none focus:ring-0 focus-visible:outline-none`})]}),t[7]=s,t[8]=r,t[9]=f,t[10]=p):p=t[10];let m;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,W.jsx)(re,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[11]=m):m=t[11];let h;t[12]!==c||t[13]!==o?(h=(0,W.jsxs)(V,{type:`button`,variant:`primary`,className:`shrink-0 gap-2`,onClick:o,children:[m,c]}),t[12]=c,t[13]=o,t[14]=h):h=t[14];let g;return t[15]!==u||t[16]!==p||t[17]!==h?(g=(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center justify-end gap-2`,children:[u,p,h]}),t[15]=u,t[16]=p,t[17]=h,t[18]=g):g=t[18],g}),rt=/^([^:=]+)[:=](.*)$/;function it(e){let t=e.trim();if(!t)return null;try{let e=JSON.parse(t);if(e&&typeof e==`object`&&!Array.isArray(e))return Object.entries(e).map(([e,t])=>({key:e,value:t==null?``:String(t)}))}catch{}let n=[];for(let e of t.split(/\r?\n/)){let t=e.trim();if(!t)continue;let r=rt.exec(t);r&&n.push({key:r[1].trim(),value:r[2].trim()})}return n.length>0?n:null}function at(e){let t={};for(let n of e){let e=n.key.trim();e&&(t[e]=n.value)}return Object.keys(t).length>0?t:void 0}function ot(e){if(!e||typeof e!=`object`)return[{key:``,value:``}];let t=Object.entries(e).map(([e,t])=>({key:e,value:t==null?``:String(t)}));return t.length>0?t:[{key:``,value:``}]}function st(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e.xopcConnector;return!!(t&&typeof t==`object`&&!Array.isArray(t)&&t.managed===!0)}function ct(e){let t=e&&typeof e==`object`&&`mcp`in e?e.mcp:void 0,n=(t&&typeof t==`object`?t:{}).servers,r={};if(!n||typeof n!=`object`||Array.isArray(n))return r;for(let[e,t]of Object.entries(n))!t||typeof t!=`object`||Array.isArray(t)||st(t)&&(r[e]=t);return r}function lt(e){let t=e.trim();if(t)return t.split(/\s+/).filter(Boolean)}function ut(e){let t=e.trim();if(!t)return;let n=JSON.parse(t);if(!n||typeof n!=`object`||Array.isArray(n))throw Error(`Expected a JSON object`);return n}function dt(e){if(e.transport===`stdio`){let t={command:e.command.trim()},n=lt(e.argsText);return n?.length&&(t.args=n),e.cwd.trim()&&(t.cwd=e.cwd.trim()),e.envJson.trim()&&(t.env=ut(e.envJson)),e.connectionTimeoutMs!=null&&Number.isFinite(e.connectionTimeoutMs)&&(t.connectionTimeoutMs=e.connectionTimeoutMs),t}let t={url:e.url.trim(),transport:e.transport},n=at(e.headers);return n&&(t.headers=n),e.connectionTimeoutMs!=null&&Number.isFinite(e.connectionTimeoutMs)&&(t.connectionTimeoutMs=e.connectionTimeoutMs),t}function ft(e,t){let n=typeof t.url==`string`&&t.url.trim().length>0,r=typeof t.transport==`string`?t.transport.trim().toLowerCase():``,i=n?r===`sse`?`sse`:`streamable-http`:`stdio`,a=t.headers&&typeof t.headers==`object`&&!Array.isArray(t.headers)?t.headers:void 0;return{clientKey:e,id:e,transport:i,command:typeof t.command==`string`?t.command:``,argsText:Array.isArray(t.args)?t.args.map(String).join(` `):``,envJson:t.env&&typeof t.env==`object`?JSON.stringify(t.env,null,2):``,cwd:typeof t.cwd==`string`?t.cwd:typeof t.workingDirectory==`string`?t.workingDirectory:``,url:typeof t.url==`string`?t.url:``,headers:ot(a),connectionTimeoutMs:typeof t.connectionTimeoutMs==`number`&&Number.isFinite(t.connectionTimeoutMs)?t.connectionTimeoutMs:void 0}}function pt(e=``){return{clientKey:crypto.randomUUID(),id:e,transport:`stdio`,command:``,argsText:``,envJson:``,cwd:``,url:``,headers:[{key:`Authorization`,value:``}],connectionTimeoutMs:void 0}}function mt(e){let t=e&&typeof e==`object`&&`mcp`in e?e.mcp:void 0,n=t&&typeof t==`object`?t:{},r=n.servers,i=r&&typeof r==`object`&&!Array.isArray(r)?Object.entries(r).flatMap(([e,t])=>!t||typeof t!=`object`||Array.isArray(t)||st(t)?[]:[ft(e,t)]).sort((e,t)=>e.id.localeCompare(t.id)):[],a=typeof n.sessionIdleTtlMs==`number`?n.sessionIdleTtlMs:void 0;return{sessionIdleTtlMinutes:a==null?void 0:a===0?0:Math.round(a/6e4),servers:i}}function ht(e){return dt(e)}async function gt(e,t={}){let n={};for(let r of e.servers){let e=r.id.trim();if(e){if(t[e])throw Error(`Server id "${e}" is reserved by an installed connector.`);n[e]=dt(r)}}let r={servers:{...t,...n}};e.sessionIdleTtlMinutes!=null&&Number.isFinite(e.sessionIdleTtlMinutes)&&(r.sessionIdleTtlMs=e.sessionIdleTtlMinutes===0?0:Math.round(e.sessionIdleTtlMinutes*6e4)),await s(c(`/api/config`),{method:`PATCH`,body:JSON.stringify({mcp:r})}),z()}function _t(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(typeof n==`string`){let e=n.trim();e&&t.push({name:e});continue}if(!n||typeof n!=`object`)continue;let e=n;if(typeof e.name!=`string`)continue;let r=e.name.trim();if(!r)continue;let i=typeof e.shortName==`string`&&e.shortName.trim()?e.shortName.trim():void 0,a=typeof e.description==`string`&&e.description.trim()?e.description.trim():void 0;t.push({name:r,shortName:i,description:a})}return t}function vt(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(!n||typeof n!=`object`)continue;let e=n;if(typeof e.uri!=`string`||typeof e.name!=`string`)continue;let r=e.uri.trim(),i=e.name.trim();!r||!i||t.push({uri:r,name:i,title:typeof e.title==`string`&&e.title.trim()?e.title.trim():void 0,description:typeof e.description==`string`&&e.description.trim()?e.description.trim():void 0,mimeType:typeof e.mimeType==`string`&&e.mimeType.trim()?e.mimeType.trim():void 0})}return t}function yt(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(!n||typeof n!=`object`)continue;let e=n;if(typeof e.name!=`string`)continue;let r=e.name.trim();r&&t.push({name:r,title:typeof e.title==`string`&&e.title.trim()?e.title.trim():void 0,description:typeof e.description==`string`&&e.description.trim()?e.description.trim():void 0,argumentCount:typeof e.argumentCount==`number`?e.argumentCount:0})}return t}async function bt(e,t){let n=await s(c(`/api/mcp/servers/${encodeURIComponent(e)}/test`),{method:`POST`,body:t?JSON.stringify({server:t}):void 0});if(!n.payload)throw Error(n.error??`MCP test failed`);let r=_t(n.payload.tools),i=vt(n.payload.resources),a=yt(n.payload.prompts);return{serverId:n.payload.serverId??e,toolCount:typeof n.payload.toolCount==`number`?n.payload.toolCount:r.length,resourceCount:typeof n.payload.resourceCount==`number`?n.payload.resourceCount:i.length,promptCount:typeof n.payload.promptCount==`number`?n.payload.promptCount:a.length,tools:r,resources:i,prompts:a}}function xt(e){return e.connectionTimeoutMs==null||!Number.isFinite(e.connectionTimeoutMs)?``:String(Math.round(e.connectionTimeoutMs/1e3))}function St(e){let t=e.trim();if(!t)return;let n=Number.parseInt(t,10);if(!(!Number.isFinite(n)||n<1||n>600))return n*1e3}function Ct(e){if(e.transport===`stdio`){let t=e.command.trim();if(!t)return``;let n=e.argsText.trim();return n?`${t} ${n}`:t}return e.url.trim()}function Z(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,n),e)}function wt({row:e,t,cs:n,onEdit:r,onRemove:i}){let[a,o]=(0,H.useState)(!1),[s,c]=(0,H.useState)(!1),[l,u]=(0,H.useState)(null),[d,f]=(0,H.useState)(null),p=Ct(e),m=(0,H.useCallback)(async()=>{o(!0),f(null);try{let t=await bt(e.id.trim());u({toolCount:t.toolCount,resourceCount:t.resourceCount,promptCount:t.promptCount})}catch(e){f(e instanceof Error?e.message:String(e))}finally{o(!1)}},[e.id]),h=(0,H.useCallback)(async()=>{c(!0),f(null);try{await i()}catch(e){f(e instanceof Error?e.message:String(e)),c(!1)}},[i]);return(0,W.jsxs)(`div`,{className:`flex h-full min-h-[10.5rem] cursor-pointer flex-col rounded-lg bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45`,onClick:r,children:[(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:e.id.trim()||t.cardUntitled}),(0,W.jsx)(`span`,{className:`rounded-full bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:n.customBadge}),(0,W.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:t.transportLabels[e.transport]})]}),p?(0,W.jsx)(`p`,{className:`mt-3 line-clamp-2 break-all font-mono text-xs leading-5 text-fg-subtle`,title:p,children:p}):null,d?(0,W.jsx)(`p`,{className:`mt-3 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:d}):null,l?(0,W.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:Z(n.customCapabilitySummary,{tools:String(l.toolCount),resources:String(l.resourceCount),prompts:String(l.promptCount)})}):null]}),(0,W.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-2 border-t border-edge pt-3`,onClick:e=>e.stopPropagation(),children:[(0,W.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:n.connectorDetails}),(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsxs)(V,{variant:`secondary`,disabled:a,onClick:()=>void m(),children:[a?(0,W.jsx)(j,{className:`size-4 animate-spin`}):(0,W.jsx)(g,{className:`size-4`}),t.testConnection]}),(0,W.jsxs)(V,{variant:`ghost`,disabled:s,onClick:()=>void h(),children:[s?(0,W.jsx)(j,{className:`size-4 animate-spin`}):(0,W.jsx)(ve,{className:`size-4`}),t.removeServer]})]})]})]})}function Tt(e,t){return e?t&&e.startsWith(t)?e.slice(t.length):e:``}function Et(e,t,n){let r=t.trim().toLowerCase();if(!r)return!0;let i=e.shortName||Tt(e.name,n);return[e.name,i,e.description].filter(Boolean).join(`
|
|
2
|
-
`).toLowerCase().includes(r)}function Dt(e,t){return e?t&&e.startsWith(t)?e.slice(t.length):e:``}function Ot(e){let t=(0,U.c)(29),{tools:n,stripPrefix:r,searchPlaceholder:a,searchEmptyLabel:o}=e,[s,c]=(0,H.useState)(``),l;if(t[0]!==s||t[1]!==r||t[2]!==n){let e;t[4]!==s||t[5]!==r?(e=e=>Et(e,s,r),t[4]=s,t[5]=r,t[6]=e):e=t[6],l=n.filter(e),t[0]=s,t[1]=r,t[2]=n,t[3]=l}else l=t[3];let u=l,d;t[7]===s?d=t[8]:(d=s.trim(),t[7]=s,t[8]=d);let f=d.length>0,p;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,W.jsx)(I,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),t[9]=p):p=t[9];let m,g;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(m=i(`w-full rounded-lg border border-edge bg-surface-panel py-2 pl-9 pr-3 text-sm text-fg`,`placeholder:text-fg-subtle`,h),g=e=>c(e.target.value),t[10]=m,t[11]=g):(m=t[10],g=t[11]);let _;t[12]!==s||t[13]!==a?(_=(0,W.jsxs)(`div`,{className:`relative`,children:[p,(0,W.jsx)(`input`,{type:`search`,value:s,placeholder:a,"aria-label":a,className:m,onChange:g})]}),t[12]=s,t[13]=a,t[14]=_):_=t[14];let v;t[15]!==u.length||t[16]!==f||t[17]!==n.length?(v=f?(0,W.jsxs)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:[u.length,` / `,n.length]}):null,t[15]=u.length,t[16]=f,t[17]=n.length,t[18]=v):v=t[18];let y;t[19]!==_||t[20]!==v?(y=(0,W.jsxs)(`div`,{className:`border-b border-edge px-5 py-3`,children:[_,v]}),t[19]=_,t[20]=v,t[21]=y):y=t[21];let b;t[22]!==u||t[23]!==o||t[24]!==r?(b=(0,W.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:u.length===0?(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:o}):(0,W.jsx)(`ul`,{className:`flex flex-col gap-2`,children:u.map((e,t)=>{let n=e.shortName||Dt(e.name,r)||e.name||`?`,i=e.name||`tool-${t}`;return(0,W.jsxs)(`li`,{className:`min-w-0 rounded-lg border border-edge bg-surface-base px-3 py-2.5`,children:[(0,W.jsx)(`div`,{className:`truncate font-mono text-sm font-medium text-fg`,title:e.name===n?n:e.name,children:n}),e.description?(0,W.jsx)(`p`,{className:`mt-1 truncate text-xs leading-relaxed text-fg-muted`,title:e.description,children:e.description}):null]},i)})})}),t[22]=u,t[23]=o,t[24]=r,t[25]=b):b=t[25];let x;return t[26]!==y||t[27]!==b?(x=(0,W.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[y,b]}),t[26]=y,t[27]=b,t[28]=x):x=t[28],x}function kt(e){let t=(0,U.c)(38),{open:n,onOpenChange:r,serverId:a,title:o,subtitle:s,searchPlaceholder:c,searchEmptyLabel:l,emptyLabel:u,closeLabel:d,tools:f,stripPrefix:m}=e,h;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,W.jsx)(ee,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,oe)}),t[0]=h):h=t[0];let g;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(g=i(`fixed left-1/2 top-1/2 flex max-h-[min(88vh,40rem)] w-[min(100%-2rem,min(92vw,36rem))] -translate-x-1/2 -translate-y-1/2 flex-col`,fe,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`),t[1]=g):g=t[1];let v;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,W.jsx)(E,{className:`size-4 shrink-0 text-accent`,"aria-hidden":!0}),t[2]=v):v=t[2];let y;t[3]===o?y=t[4]:(y=(0,W.jsxs)(te,{className:`flex items-center gap-2 text-base font-semibold text-fg`,children:[v,o]}),t[3]=o,t[4]=y);let b;t[5]!==a||t[6]!==s||t[7]!==f.length?(b=s.replace(`{{serverId}}`,a).replace(`{{count}}`,String(f.length)),t[5]=a,t[6]=s,t[7]=f.length,t[8]=b):b=t[8];let S;t[9]===b?S=t[10]:(S=(0,W.jsx)(p,{className:`mt-1 text-sm text-fg-muted`,children:b}),t[9]=b,t[10]=S);let C;t[11]!==y||t[12]!==S?(C=(0,W.jsxs)(`div`,{className:`min-w-0`,children:[y,S]}),t[11]=y,t[12]=S,t[13]=C):C=t[13];let w;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,W.jsx)(_,{className:`size-4`,"aria-hidden":!0}),t[14]=w):w=t[14];let T;t[15]===d?T=t[16]:(T=(0,W.jsx)(k,{asChild:!0,children:(0,W.jsx)(V,{type:`button`,variant:`ghost`,className:`size-8 shrink-0 px-0`,"aria-label":d,children:w})}),t[15]=d,t[16]=T);let D;t[17]!==C||t[18]!==T?(D=(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3 border-b border-edge px-5 py-4`,children:[C,T]}),t[17]=C,t[18]=T,t[19]=D):D=t[19];let O;t[20]!==u||t[21]!==n||t[22]!==l||t[23]!==c||t[24]!==a||t[25]!==m||t[26]!==f?(O=f.length>0?(0,W.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,W.jsx)(Ot,{tools:f,stripPrefix:m,searchPlaceholder:c,searchEmptyLabel:l},`${a}-${n?`open`:`closed`}`)}):(0,W.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:u})}),t[20]=u,t[21]=n,t[22]=l,t[23]=c,t[24]=a,t[25]=m,t[26]=f,t[27]=O):O=t[27];let j;t[28]===d?j=t[29]:(j=(0,W.jsx)(`div`,{className:`flex justify-end border-t border-edge px-5 py-3`,children:(0,W.jsx)(k,{asChild:!0,children:(0,W.jsx)(V,{type:`button`,variant:`secondary`,children:d})})}),t[28]=d,t[29]=j);let M;t[30]!==D||t[31]!==O||t[32]!==j?(M=(0,W.jsxs)(x,{children:[h,(0,W.jsxs)(_e,{className:g,children:[D,O,j]})]}),t[30]=D,t[31]=O,t[32]=j,t[33]=M):M=t[33];let N;return t[34]!==r||t[35]!==n||t[36]!==M?(N=(0,W.jsx)(A,{open:n,onOpenChange:r,children:M}),t[34]=r,t[35]=n,t[36]=M,t[37]=N):N=t[37],N}var At=i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,h);function jt(e){return e.materialized.type===`composio`?e.connectorId.replace(/^composio-/,``):null}function Mt(e,t){return e===`write`?t.composioScopeWrite:e===`admin`?t.composioScopeAdmin:t.composioScopeRead}function Nt({instance:e,t}){let n=jt(e),[r,a]=(0,H.useState)([]),[o,s]=(0,H.useState)([]),[c,l]=(0,H.useState)([]),[u,f]=(0,H.useState)(`read`),[p,m]=(0,H.useState)(!1),[h,g]=(0,H.useState)(null),_=(0,H.useCallback)(async()=>{if(!(!n||n===`api-key`)){m(!0),g(null);try{let[e,t,r,i]=await Promise.all([Ue().catch(()=>[]),qe(n).catch(()=>[]),Je(20).catch(()=>[]),Ge(n).catch(()=>`read`)]);a(e.filter(e=>e.toolkit.toLowerCase()===n.toLowerCase())),s(t),l(r.filter(e=>!e.toolkit||e.toolkit.toLowerCase()===n.toLowerCase())),f(i)}catch(e){g(e instanceof Error?e.message:String(e))}finally{m(!1)}}},[n]);(0,H.useEffect)(()=>{_()},[_]);let v=(0,H.useCallback)(async()=>{if(n){m(!0),g(null);try{let e=await We(n);window.open(e.connectUrl,`_blank`,`noopener,noreferrer`)}catch(e){g(e instanceof Error?e.message:String(e))}finally{m(!1)}}},[n]),y=(0,H.useCallback)(async e=>{if(n){f(e);try{await Ke(n,e),await _()}catch(e){g(e instanceof Error?e.message:String(e))}}},[_,n]);return n?n===`api-key`?(0,W.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:t.composioApiKeyStored}):(0,W.jsxs)(`div`,{className:`mt-4 rounded-xl border border-edge bg-surface-base p-3 text-sm`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`font-medium text-fg`,children:Z(t.composioToolkitTitle,{toolkit:n})}),(0,W.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:t.composioScopeHint})]}),(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,W.jsxs)(d,{className:i(At,`h-9 w-28 py-1`),value:u,onChange:e=>void y(e.currentTarget.value),children:[(0,W.jsx)(he,{value:`read`,children:t.composioScopeRead}),(0,W.jsx)(he,{value:`write`,children:t.composioScopeWrite}),(0,W.jsx)(he,{value:`admin`,children:t.composioScopeAdmin})]}),(0,W.jsxs)(V,{variant:`secondary`,disabled:p,onClick:()=>void v(),children:[p?(0,W.jsx)(j,{className:`size-4 animate-spin`}):(0,W.jsx)(le,{className:`size-4`}),t.connectOAuth]}),(0,W.jsx)(V,{variant:`ghost`,disabled:p,onClick:()=>void _(),children:t.refresh})]})]}),h?(0,W.jsx)(`p`,{className:`mt-3 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:h}):null,(0,W.jsxs)(`div`,{className:`mt-4 grid gap-3 lg:grid-cols-3`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioConnections}),r.length?r.map(e=>(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel p-2`,children:[(0,W.jsx)(`p`,{className:`truncate font-mono text-xs text-fg`,children:e.accountEmail??e.username??e.workspace??e.id}),(0,W.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.status})]},e.id)):(0,W.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioConnectionsEmpty})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioAgentTools}),o.length?o.slice(0,8).map(e=>(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel p-2`,children:[(0,W.jsx)(`p`,{className:`truncate font-mono text-xs text-fg`,children:e.slug}),(0,W.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[Mt(e.scope,t),e.curated?``:` ${t.composioUncuratedSuffix}`]})]},e.slug)):(0,W.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioToolsEmpty})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioRecentTriggers}),c.length?c.slice(0,5).map(e=>(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel p-2`,children:[(0,W.jsx)(`p`,{className:`truncate text-xs text-fg`,children:e.trigger??e.id}),(0,W.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:new Date(e.at).toLocaleString()})]},`${e.id}-${e.at}`)):(0,W.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioTriggersEmpty})]})]})]}):null}var Pt=i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,h);function Ft(e,t){return e?t.healthStatusLabels[e]??e:t.healthNotTested}function It(e,t){let n={};for(let r of e?.setup.config??[]){let e=t.config?.[r.key]??r.defaultValue??``;n[r.key]=typeof e==`string`?e:JSON.stringify(e,null,2)}return n}function Lt(e,t){let n=t.trim();return e===`json`?n?JSON.parse(n):void 0:e===`number`?n?Number(n):void 0:e===`boolean`?n===`true`:n||void 0}function Rt(e){let t=(0,U.c)(12),{title:n,description:r,meta:a}=e,o;t[0]===r?o=t[1]:(o=r?(0,W.jsx)(f,{delayDuration:300,skipDelayDuration:100,children:(0,W.jsxs)(ie,{children:[(0,W.jsx)(pe,{asChild:!0,children:(0,W.jsx)(`p`,{tabIndex:0,title:r,className:i(`mt-1 line-clamp-3 cursor-help text-xs leading-5 text-fg-muted`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`),children:r})}),(0,W.jsx)(O,{children:(0,W.jsx)(P,{side:`top`,align:`start`,sideOffset:6,collisionPadding:12,className:`!z-[10000] max-h-[min(16rem,45vh)] max-w-[min(32rem,calc(100vw-2rem))] overflow-y-auto rounded-md border border-edge bg-surface-panel px-2.5 py-2 text-left text-xs leading-5 text-fg shadow-popover`,children:(0,W.jsx)(`span`,{className:`whitespace-pre-wrap break-words`,children:r})})})]})}):null,t[0]=r,t[1]=o);let s=o,c;t[2]===n?c=t[3]:(c=(0,W.jsx)(`p`,{className:`min-w-0 break-all font-mono text-xs font-medium leading-5 text-fg`,children:n}),t[2]=n,t[3]=c);let l;t[4]===a?l=t[5]:(l=a?(0,W.jsx)(`span`,{className:`shrink-0 rounded-md bg-surface-hover px-1.5 py-0.5 text-[11px] leading-4 text-fg-subtle`,children:a}):null,t[4]=a,t[5]=l);let u;t[6]!==c||t[7]!==l?(u=(0,W.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-3`,children:[c,l]}),t[6]=c,t[7]=l,t[8]=u):u=t[8];let d;return t[9]!==s||t[10]!==u?(d=(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2.5`,children:[u,s]}),t[9]=s,t[10]=u,t[11]=d):d=t[11],d}function zt({instance:e,definition:t,onClose:n,onChanged:r,t:a,mcp:o}){let[s,c]=(0,H.useState)(!1),[l,u]=(0,H.useState)(!1),[d,f]=(0,H.useState)(!1),[h,v]=(0,H.useState)(null),[y,b]=(0,H.useState)(`health`),[S,C]=(0,H.useState)(!1),[w,T]=(0,H.useState)(()=>It(t,e)),[D,O]=(0,H.useState)(null),M=t?.setup.config??[],N=e.materialized.type===`mcp`&&M.length>0&&(t?.setup.secrets??[]).length===0,P=h?h.toolCount:e.usage.lastToolCount,ne=(0,H.useMemo)(()=>{let t=[[`health`,ue,a.detailHealth],[`tools`,E,`${a.detailTools} ${h?h.toolCount:e.usage.lastToolCount??``}`],[`resources`,se,`${a.detailResources} ${h?h.resourceCount:e.usage.lastResourceCount??``}`],[`prompts`,m,`${a.detailPrompts} ${h?h.promptCount:e.usage.lastPromptCount??``}`],[`permissions`,le,a.detailPermissions]];return N?[...t,[`config`,se,a.tabConfig]]:t},[h,e.usage.lastPromptCount,e.usage.lastResourceCount,e.usage.lastToolCount,N,a]),F=(0,H.useCallback)(async()=>{c(!0),O(null);try{let t=await He(e.instanceId);v(t),t.toolCount>0&&b(`tools`),r()}catch(e){O(e instanceof Error?e.message:String(e))}finally{c(!1)}},[e.instanceId,r]),re=(0,H.useCallback)(async()=>{u(!0),O(null);try{await Ve(e.instanceId),await r(),n()}catch(e){O(e instanceof Error?e.message:String(e)),u(!1)}},[e.instanceId,r,n]),I=(0,H.useCallback)(async()=>{if(!(!t||!N)){f(!0),O(null);try{let n={};for(let e of t.setup.config??[]){let t=Lt(e.type,w[e.key]??``);t!==void 0&&(n[e.key]=t)}await Be(e.instanceId,{config:n}),await r(),b(`health`)}catch(e){O(e instanceof Error?e.message:String(e))}finally{f(!1)}}},[w,t,e.instanceId,r,N]);return(0,W.jsxs)(A,{open:!0,onOpenChange:e=>{e||n()},children:[(0,W.jsxs)(x,{children:[(0,W.jsx)(ee,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,W.jsxs)(_e,{className:i(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(100vh-2rem,44rem)] w-[min(100%-2rem,min(92vw,54rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-panel shadow-float outline-none dark:border-edge`),children:[(0,W.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(te,{className:`text-base font-semibold text-fg`,children:e.displayName}),(0,W.jsx)(p,{className:`mt-1 text-sm text-fg-muted`,children:e.materialized.type===`mcp`?Z(a.mcpServerRuntime,{serverId:e.materialized.serverId}):Z(a.runtimeLabel,{runtime:e.materialized.type})})]}),(0,W.jsx)(k,{asChild:!0,children:(0,W.jsxs)(`button`,{type:`button`,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,B.focusRingPanel),"aria-label":a.modalClose,children:[(0,W.jsx)(_,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,W.jsx)(`span`,{className:`sr-only`,children:a.modalClose})]})})]}),(0,W.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:[D?(0,W.jsx)(`p`,{className:`mb-4 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:D}):null,(0,W.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:ne.map(([e,t,n])=>(0,W.jsxs)(`button`,{type:`button`,className:i(`inline-flex h-8 items-center gap-1.5 rounded-md border px-2.5 text-xs`,y===e?`border-accent bg-accent-soft text-accent-fg`:`border-edge bg-surface-base text-fg-muted hover:text-fg`),onClick:()=>b(e),children:[(0,W.jsx)(t,{className:`size-3.5`,"aria-hidden":!0}),n]},e))}),(0,W.jsxs)(`div`,{className:`mt-4 rounded-xl border border-edge bg-surface-base p-3 text-sm`,children:[y===`health`?(0,W.jsxs)(`div`,{className:`space-y-1 text-fg-muted`,children:[(0,W.jsxs)(`p`,{children:[a.statusLabel,` `,(0,W.jsx)(`span`,{className:h?.ok?`font-medium text-emerald-700 dark:text-emerald-300`:`font-medium text-fg`,children:Ft(h?.status??e.usage.lastHealthStatus,a)})]}),(0,W.jsxs)(`p`,{children:[a.lastCheckLabel,` `,e.usage.lastHealthCheckAt?new Date(e.usage.lastHealthCheckAt).toLocaleString():a.never]}),h?.action?(0,W.jsx)(`p`,{children:h.action}):null]}):null,y===`tools`?h?.tools.length?(0,W.jsxs)(`div`,{className:`grid gap-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,W.jsx)(`p`,{className:`text-xs text-fg-muted`,children:Z(a.toolsAvailable,{count:String(h.tools.length)})}),(0,W.jsx)(V,{type:`button`,variant:`ghost`,className:`h-7 text-xs`,onClick:()=>C(!0),children:o.viewAllTools})]}),(0,W.jsx)(`div`,{className:`grid gap-2`,children:h.tools.slice(0,8).map(e=>(0,W.jsx)(Rt,{title:e.shortName??e.name,description:e.description},e.name))})]}):(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,W.jsx)(`p`,{className:`text-fg-muted`,children:P?Z(a.toolsLastCheckSummary,{count:String(P)}):a.toolsRunTestHint}),(0,W.jsxs)(V,{type:`button`,variant:`secondary`,disabled:s,onClick:()=>void F(),children:[s?(0,W.jsx)(j,{className:`size-4 animate-spin`}):(0,W.jsx)(g,{className:`size-4`}),a.test]})]}):null,y===`resources`?h?.resources.length?(0,W.jsx)(`div`,{className:`grid gap-2`,children:h.resources.slice(0,8).map(e=>(0,W.jsx)(Rt,{title:e.title??e.name,description:e.uri,meta:e.mimeType},e.uri))}):(0,W.jsx)(`p`,{className:`text-fg-muted`,children:a.resourcesRunTestHint}):null,y===`prompts`?h?.prompts.length?(0,W.jsx)(`div`,{className:`grid gap-2`,children:h.prompts.slice(0,8).map(e=>(0,W.jsx)(Rt,{title:e.title??e.name,description:e.description,meta:e.argumentCount?Z(a.promptArgumentCount,{count:String(e.argumentCount)}):void 0},e.name))}):(0,W.jsx)(`p`,{className:`text-fg-muted`,children:a.promptsRunTestHint}):null,y===`permissions`?(0,W.jsxs)(`div`,{className:`space-y-1 text-fg-muted`,children:[(0,W.jsx)(`p`,{children:Z(a.secretsConfigured,{count:String(Object.values(e.secretStatus).filter(Boolean).length)})}),(0,W.jsx)(`p`,{children:e.materialized.type===`mcp`?Z(a.runtimeServerLabel,{runtime:e.materialized.type.toUpperCase(),serverId:e.materialized.serverId}):Z(a.runtimeLabel,{runtime:e.materialized.type.toUpperCase()})}),(0,W.jsx)(`p`,{children:e.materialized.type===`mcp`?a.mcpPolicyHint:a.connectorPolicyHint})]}):null,y===`config`&&N?(0,W.jsx)(`div`,{className:`grid gap-3`,children:M.map(e=>(0,W.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,W.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.label}),e.description?(0,W.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:e.description}):null,(0,W.jsx)(`input`,{className:Pt,value:w[e.key]??``,placeholder:e.placeholder,onChange:t=>T(n=>({...n,[e.key]:t.currentTarget.value}))})]},e.key))}):null]}),e.materialized.type===`composio`?(0,W.jsx)(Nt,{instance:e,t:a}):null]}),(0,W.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[(0,W.jsx)(V,{variant:`secondary`,onClick:n,children:a.modalClose}),y===`config`&&N?(0,W.jsxs)(V,{variant:`primary`,disabled:d,onClick:()=>void I(),children:[d?(0,W.jsx)(j,{className:`size-4 animate-spin`}):(0,W.jsx)(L,{className:`size-4`}),a.modalSave]}):null,e.materialized.type===`mcp`?(0,W.jsxs)(V,{variant:`secondary`,disabled:s,onClick:()=>void F(),children:[s?(0,W.jsx)(j,{className:`size-4 animate-spin`}):(0,W.jsx)(g,{className:`size-4`}),a.test]}):null,(0,W.jsxs)(V,{variant:`ghost`,disabled:l,onClick:()=>void re(),children:[l?(0,W.jsx)(j,{className:`size-4 animate-spin`}):(0,W.jsx)(ve,{className:`size-4`}),a.remove]})]})]})]}),e.materialized.type===`mcp`?(0,W.jsx)(kt,{open:S,onOpenChange:C,serverId:e.materialized.serverId,title:Z(a.installedToolsDialogTitle,{name:e.displayName}),subtitle:a.installedToolsDialogSubtitle,searchPlaceholder:o.toolsDialogSearchPlaceholder,searchEmptyLabel:o.toolsDialogSearchEmpty,emptyLabel:a.toolsRunTestHint,closeLabel:o.toolsDialogClose,tools:h?.tools??[],stripPrefix:`${e.materialized.serverId}__`}):null]})}function Bt({instance:e,definition:t,onOpenDetails:n,onChanged:r,t:i}){let[a,o]=(0,H.useState)(!1),[s,c]=(0,H.useState)(!1),[l,u]=(0,H.useState)(null),d=(0,H.useCallback)(async()=>{o(!0),u(null);try{await He(e.instanceId),await r()}catch(e){u(e instanceof Error?e.message:String(e))}finally{o(!1)}},[e.instanceId,r]),f=(0,H.useCallback)(async()=>{c(!0),u(null);try{await Ve(e.instanceId),await r()}catch(e){u(e instanceof Error?e.message:String(e)),c(!1)}},[e.instanceId,r]),p=e.usage.lastHealthStatus?i.healthStatusLabels[e.usage.lastHealthStatus]??e.usage.lastHealthStatus:i.healthNotTested,m=e.usage.lastToolCount??0,h=!!(t?.setup.config?.length&&!t.setup.secrets?.length&&e.materialized.type===`mcp`);return(0,W.jsxs)(`div`,{className:`flex h-full min-h-[10.5rem] cursor-pointer flex-col rounded-lg bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45`,onClick:()=>n(e),children:[(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:e.displayName}),(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-emerald-500/30 bg-emerald-500/10 px-2 py-0.5 text-[11px] font-medium text-emerald-700 dark:text-emerald-300`,children:[(0,W.jsx)(N,{className:`size-3`,"aria-hidden":!0}),i.installedBadge]}),h?(0,W.jsx)(`span`,{className:`rounded-full bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:i.tabConfig}):null]}),(0,W.jsx)(`p`,{className:`mt-3 line-clamp-2 break-all text-sm leading-5 text-fg-muted`,children:e.materialized.type===`mcp`?Z(i.mcpServerRuntime,{serverId:e.materialized.serverId}):Z(i.runtimeLabel,{runtime:e.materialized.type})}),(0,W.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2 text-xs text-fg-muted`,children:[(0,W.jsxs)(`span`,{className:`rounded-md bg-surface-base px-2 py-1`,children:[i.statusLabel,` `,p]}),(0,W.jsx)(`span`,{className:`rounded-md bg-surface-base px-2 py-1`,children:Z(i.toolsAvailable,{count:String(m)})})]}),l?(0,W.jsx)(`p`,{className:`mt-3 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:l}):null]}),(0,W.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-2 border-t border-edge pt-3`,onClick:e=>e.stopPropagation(),children:[(0,W.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:i.connectorDetails}),(0,W.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[e.materialized.type===`mcp`?(0,W.jsxs)(V,{variant:`secondary`,disabled:a,onClick:()=>void d(),children:[a?(0,W.jsx)(j,{className:`size-4 animate-spin`}):(0,W.jsx)(g,{className:`size-4`}),i.test]}):null,(0,W.jsxs)(V,{variant:`ghost`,disabled:s,onClick:()=>void f(),children:[s?(0,W.jsx)(j,{className:`size-4 animate-spin`}):(0,W.jsx)(ve,{className:`size-4`}),i.remove]})]})]})]})}var Vt=i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,h),Ht=i(Vt,`min-h-28 font-mono`);function Ut(e,t){return e?t.healthStatusLabels[e]??e:t.healthStatusPending}function Wt(e,t){let n=t.trim();return e===`json`?n?JSON.parse(n):void 0:e===`number`?n?Number(n):void 0:e===`boolean`?n===`true`:n||void 0}function Gt(e,t){let n={};for(let t of e.setup.secrets??[])n[t.key]=``;let r={};for(let t of e.setup.config??[])r[t.key]=t.defaultValue===void 0?``:typeof t.defaultValue==`string`?t.defaultValue:JSON.stringify(t.defaultValue,null,2);return{connector:e,secrets:n,config:r,installing:!1,error:null,result:null,health:null,oauth:{flow:null,connected:e.auth.mode!==`oauth`},...t?{store:t}:{}}}function Kt(e){let t=(0,U.c)(12),{title:n,items:r}=e;if(r.length===0)return null;let i;t[0]===n?i=t[1]:(i=(0,W.jsx)(`div`,{className:`border-b border-edge px-3 py-2 text-xs font-semibold text-fg`,children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=r.slice(0,12).map(qt),t[2]=r,t[3]=a);let o;t[4]===r.length?o=t[5]:(o=r.length>12?(0,W.jsxs)(`div`,{className:`px-3 py-2 text-xs text-fg-subtle`,children:[`+`,r.length-12]}):null,t[4]=r.length,t[5]=o);let s;t[6]!==a||t[7]!==o?(s=(0,W.jsxs)(`div`,{className:`max-h-40 overflow-y-auto`,children:[a,o]}),t[6]=a,t[7]=o,t[8]=s):s=t[8];let c;return t[9]!==i||t[10]!==s?(c=(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel`,children:[i,s]}),t[9]=i,t[10]=s,t[11]=c):c=t[11],c}function qt(e){return(0,W.jsxs)(`div`,{className:`border-b border-edge-subtle px-3 py-2 last:border-b-0`,children:[(0,W.jsx)(`div`,{className:`break-words font-mono text-xs font-medium text-fg`,children:e.title}),e.description?(0,W.jsx)(`div`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:e.description}):null]},e.id)}function Jt({draft:e,onChange:t,onClose:n,onInstalled:r,t:a}){let{connector:o}=e,s=e.result?`complete`:e.installing?`health`:`configure`,c=[{id:`configure`,label:a.installStepConfigure},{id:`health`,label:a.installStepHealth},{id:`complete`,label:a.installStepComplete}],l=(0,H.useCallback)(async()=>{t({...e,installing:!0,error:null});try{let n=await Ie(o.id);window.open(n.verificationUri,`_blank`,`noopener,noreferrer`),t({...e,installing:!1,error:null,oauth:{flow:n,connected:!1}})}catch(n){t({...e,installing:!1,error:n instanceof Error?n.message:String(n)})}},[o.id,e,t]),u=(0,H.useCallback)(async()=>{if(e.oauth.flow){t({...e,installing:!0,error:null});try{await Le(o.id,e.oauth.flow.deviceCode),t({...e,installing:!1,error:null,oauth:{...e.oauth,connected:!0}})}catch(n){t({...e,installing:!1,error:n instanceof Error?n.message:String(n)})}}},[o.id,e,t]),d=(0,H.useCallback)(async()=>{t({...e,installing:!0,error:null,result:null,health:null});try{if(o.auth.mode===`oauth`&&!e.oauth.connected)throw Error(a.oauthRequiredBeforeInstall);let n={};for(let t of o.setup.config??[]){let r=Wt(t.type,e.config[t.key]??``);r!==void 0&&(n[t.key]=r)}let i=e.store?await Ae(e.store.packageName,{secrets:e.secrets,config:n},e.store.version):await Re(o.id,{secrets:e.secrets,config:n,definition:o.source===`registry`?o:void 0}),s=null;try{s=await He(i.instanceId)}catch{s=null}t({...e,installing:!1,result:i,health:s}),await r()}catch(n){t({...e,installing:!1,error:n instanceof Error?n.message:String(n)})}},[o,e,t,r,a.oauthRequiredBeforeInstall]);return(0,W.jsx)(A,{open:!0,onOpenChange:e=>{e||n()},children:(0,W.jsxs)(x,{children:[(0,W.jsx)(ee,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,W.jsxs)(_e,{className:i(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex max-h-[min(100vh-2rem,44rem)] w-[min(100%-2rem,min(92vw,48rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-panel shadow-float dark:border-edge`),children:[(0,W.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(te,{className:`text-base font-semibold text-fg`,children:Z(a.installDialogTitle,{name:o.displayName})}),(0,W.jsx)(p,{className:`mt-1 line-clamp-3 text-sm text-fg-muted`,children:o.description})]}),(0,W.jsx)(k,{asChild:!0,children:(0,W.jsxs)(`button`,{type:`button`,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,B.focusRingPanel),"aria-label":a.modalClose,children:[(0,W.jsx)(_,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,W.jsx)(`span`,{className:`sr-only`,children:a.modalClose})]})})]}),(0,W.jsxs)(`div`,{className:`min-h-0 overflow-y-auto px-6 py-5`,children:[(0,W.jsx)(`div`,{className:`mb-5 grid grid-cols-3 gap-2`,"aria-label":a.installProgressAria,children:c.map((e,t)=>{let n=c.findIndex(e=>e.id===s);return(0,W.jsxs)(`div`,{className:i(`rounded-xl border px-3 py-2 text-xs font-medium`,t===n?`border-accent bg-accent-soft text-accent-fg`:t<n?`border-emerald-200 bg-emerald-50 text-emerald-800 dark:border-emerald-900/40 dark:bg-emerald-950/40 dark:text-emerald-200`:`border-edge bg-surface-base text-fg-muted`),children:[(0,W.jsxs)(`span`,{className:`mr-1 tabular-nums`,children:[t+1,`.`]}),e.label]},e.id)})}),(0,W.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[o.auth.mode===`oauth`?(0,W.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-panel p-4`,children:[(0,W.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:a.oauthTitle}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:a.oauthHint}),e.oauth.flow?(0,W.jsxs)(`div`,{className:`mt-3 rounded-xl bg-surface-base p-3 text-sm text-fg-muted`,children:[(0,W.jsx)(`p`,{children:Z(a.oauthOpenCodePrefix,{url:e.oauth.flow.verificationUri})}),(0,W.jsx)(`p`,{className:`mt-2 font-mono text-lg font-semibold tracking-widest text-fg`,children:e.oauth.flow.userCode})]}):null,e.oauth.connected?(0,W.jsx)(`p`,{className:`mt-3 rounded-xl bg-emerald-500/10 px-3 py-2 text-sm text-emerald-700`,children:a.oauthConnected}):null,(0,W.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,W.jsxs)(V,{variant:`secondary`,disabled:e.installing,onClick:()=>void l(),children:[e.installing&&!e.oauth.flow?(0,W.jsx)(j,{className:`size-4 animate-spin`}):(0,W.jsx)(g,{className:`size-4`}),a.oauthConnectButton]}),(0,W.jsxs)(V,{variant:`primary`,disabled:e.installing||!e.oauth.flow,onClick:()=>void u(),children:[e.installing&&e.oauth.flow?(0,W.jsx)(j,{className:`size-4 animate-spin`}):(0,W.jsx)(N,{className:`size-4`}),a.oauthAuthorizedButton]})]})]}):null,e.store?(0,W.jsxs)(`section`,{className:`rounded-2xl border border-edge bg-surface-base p-4`,children:[(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.detailPermissions}),(0,W.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:[(e.store.permissions.data??[]).map(e=>(0,W.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-panel px-2 py-1 text-xs text-fg-muted`,children:e},e)),(e.store.permissions.networkDomains??[]).map(e=>(0,W.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-panel px-2 py-1 text-xs text-fg-muted`,children:e},e)),(0,W.jsx)(`span`,{className:`rounded-md border border-emerald-500/30 bg-emerald-500/10 px-2 py-1 text-xs text-emerald-700 dark:text-emerald-300`,children:a.storeLocalExecDenied})]})]}):null,(o.setup.secrets??[]).map(n=>(0,W.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,W.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.label}),n.description?(0,W.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:n.description}):null,(0,W.jsx)(de,{value:e.secrets[n.key]??``,onChange:r=>t({...e,secrets:{...e.secrets,[n.key]:r},error:null}),labels:a.secretInputLabels,placeholder:n.required?a.requiredPlaceholder:a.optionalPlaceholder})]},n.key)),(o.setup.config??[]).map(n=>(0,W.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,W.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.label}),n.type===`json`?(0,W.jsx)(`textarea`,{className:Ht,value:e.config[n.key]??``,placeholder:n.placeholder,onChange:r=>t({...e,config:{...e.config,[n.key]:r.currentTarget.value},error:null})}):(0,W.jsx)(`input`,{className:Vt,value:e.config[n.key]??``,placeholder:n.placeholder,onChange:r=>t({...e,config:{...e.config,[n.key]:r.currentTarget.value},error:null})})]},n.key)),e.installing?(0,W.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-base p-4 text-sm text-fg-muted`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 font-medium text-fg`,children:[(0,W.jsx)(j,{className:`size-4 animate-spin text-accent`,"aria-hidden":!0}),a.installingTitle]}),(0,W.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:a.installingHint})]}):null,e.error?(0,W.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:e.error}):null,e.result?(0,W.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-base p-4 text-sm text-fg-muted`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`font-medium text-fg`,children:Z(a.installedAs,{target:e.result.materialized.type===`mcp`?e.result.materialized.serverId:e.result.instanceId})}),(0,W.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:Z(a.runtimeLabel,{runtime:e.result.materialized.type.toUpperCase()})})]}),(0,W.jsx)(`span`,{className:i(`rounded-full px-2 py-0.5 text-xs font-medium`,e.health?.ok?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e.health?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:`bg-surface-hover text-fg-muted`),children:e.health?.ok?a.healthStatusHealthy:Ut(e.health?.status,a)})]}),e.health?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`mt-3 grid gap-2 text-xs sm:grid-cols-3`,children:[(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2`,children:[(0,W.jsx)(`div`,{className:`font-semibold text-fg`,children:e.health.toolCount}),(0,W.jsx)(`div`,{children:a.toolsMetric})]}),(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2`,children:[(0,W.jsx)(`div`,{className:`font-semibold text-fg`,children:e.health.resourceCount}),(0,W.jsx)(`div`,{children:a.resourcesMetric})]}),(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2`,children:[(0,W.jsx)(`div`,{className:`font-semibold text-fg`,children:e.health.promptCount}),(0,W.jsx)(`div`,{children:a.promptsMetric})]})]}),(0,W.jsxs)(`div`,{className:`mt-3 grid gap-2`,children:[(0,W.jsx)(Kt,{title:a.detailTools,items:e.health.tools.map(e=>({id:e.name,title:e.shortName??e.name,description:e.description}))}),(0,W.jsx)(Kt,{title:a.detailResources,items:e.health.resources.map(e=>({id:e.uri,title:e.title??e.name??e.uri,description:e.description??e.uri}))}),(0,W.jsx)(Kt,{title:a.detailPrompts,items:e.health.prompts.map(e=>({id:e.name,title:e.title??e.name,description:e.description??Z(a.promptArgumentCount,{count:String(e.argumentCount)})}))})]})]}):(0,W.jsx)(`p`,{className:`mt-3`,children:a.installedWithoutHealth}),e.health?.action?(0,W.jsx)(`p`,{className:`mt-3 text-xs text-fg-subtle`,children:e.health.action}):null]}):null]})]}),(0,W.jsx)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:(0,W.jsxs)(V,{variant:`primary`,disabled:!!e.result||e.installing||o.auth.mode===`oauth`&&!e.oauth.connected,onClick:()=>void d(),children:[e.installing?(0,W.jsx)(j,{className:`size-4 animate-spin`}):e.result?(0,W.jsx)(N,{className:`size-4`}):(0,W.jsx)(w,{className:`size-4`}),e.result?a.installedBadge:a.install]})})]})]})})}function Yt(e,t){let n=e.length+1,r=`server-${n}`,i=new Set([...e.map(e=>e.id.trim()),...t]);for(;i.has(r);)n+=1,r=`server-${n}`;return pt(r)}function Xt(e,t){let n=t.trim().toLowerCase();return n?[e.displayName,e.description,e.category,e.kind,e.source,...e.tags??[]].some(e=>e.toLowerCase().includes(n)):!0}function Zt(e,t,n){return e.filter(e=>Xt(e,t)).toSorted((e,t)=>n===`source`&&e.source!==t.source?e.source.localeCompare(t.source):e.displayName.localeCompare(t.displayName))}function Qt(e,t){let n=t.trim().toLowerCase();return n?[e.displayName,e.connectorId,e.instanceId,e.status,e.connectionStatus??``,e.materialized.type,e.materialized.type===`mcp`?e.materialized.serverId:e.materialized.id].some(e=>e.toLowerCase().includes(n)):!0}function $t(e,t){let n=t.trim().toLowerCase();return n?[e.id,e.command??``,e.url??``,e.transport].some(e=>e.toLowerCase().includes(n)):!0}function en(e,t,n){let r=e.key.trim();if(r)return`key:${r}`;let i=e.value.trim();return i?`value:${i}`:`empty:${n.slice(0,t).filter(e=>!e.key.trim()&&!e.value.trim()).length}`}function tn(){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)}function nn({label:e,optionalLabel:t,addLabel:n,removeHeaderAria:r,pasteLabel:a,pasteFailed:o,keyPlaceholder:s,valuePlaceholder:c,headers:l,onChange:u}){let d=(e,t)=>{u(l.map((n,r)=>r===e?{...n,...t}:n))},f=()=>{u([...l,{key:``,value:``}])},p=e=>{let t=l.filter((t,n)=>n!==e);u(t.length>0?t:[{key:``,value:``}])},m=async()=>{try{let e=await ae();if(!e){window.alert(o);return}let t=it(e);if(!t?.length){window.alert(o);return}u(t)}catch{window.alert(o)}};return(0,W.jsxs)(`div`,{className:`flex flex-col gap-2 md:col-span-2`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium text-fg`,children:[(0,W.jsx)(`span`,{children:e}),t?(0,W.jsx)(`span`,{className:`font-normal text-fg-subtle`,children:t}):null]}),(0,W.jsxs)(V,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5 px-2 text-xs`,onClick:()=>void m(),children:[(0,W.jsx)(M,{className:`size-3.5`,"aria-hidden":!0}),a]})]}),(0,W.jsx)(`div`,{className:`flex flex-col gap-2`,children:l.map((e,t)=>(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`input`,{className:i(tn(),`min-w-0 flex-1 font-mono text-xs`),value:e.key,placeholder:s,onChange:e=>d(t,{key:e.target.value})}),(0,W.jsx)(`input`,{className:i(tn(),`min-w-0 flex-[1.4] font-mono text-xs`),value:e.value,placeholder:c,onChange:e=>d(t,{value:e.target.value})}),(0,W.jsx)(V,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 px-0`,disabled:l.length<=1&&!e.key&&!e.value,onClick:()=>p(t),"aria-label":r,children:(0,W.jsx)(ve,{className:`size-4 text-fg-subtle`,"aria-hidden":!0})})]},en(e,t,l)))}),(0,W.jsxs)(`button`,{type:`button`,className:i(`self-start text-sm text-accent hover:underline`,B.press),onClick:f,children:[`+ `,n]})]})}var rn=[`stdio`,`sse`,`streamable-http`];function Q(e){let t=(0,U.c)(11),{label:n,description:r,required:i,children:a}=e,o;t[0]===i?o=t[1]:(o=i?(0,W.jsx)(`span`,{className:`ml-0.5 text-danger`,children:`*`}):null,t[0]=i,t[1]=o);let s;t[2]!==n||t[3]!==o?(s=(0,W.jsxs)(`div`,{className:`text-sm font-medium text-fg`,children:[n,o]}),t[2]=n,t[3]=o,t[4]=s):s=t[4];let c;t[5]===r?c=t[6]:(c=r?(0,W.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:r}):null,t[5]=r,t[6]=c);let l;return t[7]!==a||t[8]!==s||t[9]!==c?(l=(0,W.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[s,a,c]}),t[7]=a,t[8]=s,t[9]=c,t[10]=l):l=t[10],l}function $(){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)}function an(e){let t=(0,U.c)(29),{row:n,t:r,onUpdate:a,idConflictMessage:o,variant:s}=e,c=s===void 0?`all`:s,l=c===`all`||c===`basic`,u=c===`all`||c===`advanced`,f;t[0]!==o||t[1]!==a||t[2]!==n.id||t[3]!==n.transport||t[4]!==l||t[5]!==r?(f=l?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Q,{label:r.transportLabel,required:!0,children:(0,W.jsx)(d,{className:$(),value:n.transport,onChange:e=>a({transport:e.target.value}),children:rn.map(e=>(0,W.jsx)(he,{value:e,children:r.transportLabels[e]},e))})}),(0,W.jsxs)(Q,{label:r.serverIdLabel,required:!0,children:[(0,W.jsx)(`input`,{className:$(),value:n.id,placeholder:r.serverIdPlaceholder,onChange:e=>a({id:e.target.value})}),o?(0,W.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-300`,children:o}):null]})]}):null,t[0]=o,t[1]=a,t[2]=n.id,t[3]=n.transport,t[4]=l,t[5]=r,t[6]=f):f=t[6];let p;t[7]!==a||t[8]!==n.argsText||t[9]!==n.command||t[10]!==n.cwd||t[11]!==n.envJson||t[12]!==n.headers||t[13]!==n.transport||t[14]!==n.url||t[15]!==u||t[16]!==l||t[17]!==r||t[18]!==c?(p=n.transport===`stdio`?(0,W.jsxs)(W.Fragment,{children:[l?(0,W.jsx)(`div`,{className:c===`basic`?`md:col-span-2`:void 0,children:(0,W.jsx)(Q,{label:r.commandLabel,required:!0,children:(0,W.jsx)(`input`,{className:$(),value:n.command,onChange:e=>a({command:e.target.value})})})}):null,u?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Q,{label:r.argsLabel,description:r.argsHint,children:(0,W.jsx)(`input`,{className:$(),value:n.argsText,onChange:e=>a({argsText:e.target.value})})}),(0,W.jsx)(Q,{label:r.cwdLabel,children:(0,W.jsx)(`input`,{className:$(),value:n.cwd,onChange:e=>a({cwd:e.target.value})})}),(0,W.jsx)(Q,{label:r.envLabel,description:r.envHint,children:(0,W.jsx)(`textarea`,{className:i($(),`min-h-[4rem] font-mono text-xs`),value:n.envJson,onChange:e=>a({envJson:e.target.value})})})]}):null]}):(0,W.jsxs)(W.Fragment,{children:[l?(0,W.jsx)(`div`,{className:`md:col-span-2`,children:(0,W.jsx)(Q,{label:r.urlLabel,required:!0,children:(0,W.jsx)(`input`,{className:i($(),`font-mono text-xs`),value:n.url,placeholder:`https://example.com/mcp`,onChange:e=>a({url:e.target.value})})})}):null,u?(0,W.jsx)(nn,{label:r.headersLabel,optionalLabel:r.optionalSuffix,addLabel:r.addHeader,removeHeaderAria:r.removeHeader,pasteLabel:r.pasteHeaders,pasteFailed:r.pasteHeadersFailed,keyPlaceholder:r.headerKeyPlaceholder,valuePlaceholder:r.headerValuePlaceholder,headers:n.headers,onChange:e=>a({headers:e})}):null]}),t[7]=a,t[8]=n.argsText,t[9]=n.command,t[10]=n.cwd,t[11]=n.envJson,t[12]=n.headers,t[13]=n.transport,t[14]=n.url,t[15]=u,t[16]=l,t[17]=r,t[18]=c,t[19]=p):p=t[19];let m;t[20]!==a||t[21]!==n||t[22]!==u||t[23]!==r?(m=u?(0,W.jsx)(Q,{label:r.timeoutLabel,description:r.timeoutHint,children:(0,W.jsx)(`input`,{type:`number`,min:1,max:600,className:$(),value:xt(n),placeholder:r.timeoutPlaceholder,onChange:e=>a({connectionTimeoutMs:St(e.target.value)})})}):null,t[20]=a,t[21]=n,t[22]=u,t[23]=r,t[24]=m):m=t[24];let h;return t[25]!==f||t[26]!==p||t[27]!==m?(h=(0,W.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[f,p,m]}),t[25]=f,t[26]=p,t[27]=m,t[28]=h):h=t[28],h}function on(e,t){if(e.shortName)return e.shortName;let n=`${t.trim()}__`;return n&&e.name.startsWith(n)?e.name.slice(n.length):e.name}function sn(e){let t=(0,U.c)(13),{tool:n,serverId:r}=e,a;t[0]!==r||t[1]!==n?(a=on(n,r),t[0]=r,t[1]=n,t[2]=a):a=t[2];let o=a,s=n.name===o?o:n.name,c;t[3]===n.description?c=t[4]:(c=n.description?.trim(),t[3]=n.description,t[4]=c);let l=c,u;t[5]!==o||t[6]!==s?(u=(0,W.jsx)(`p`,{className:`break-all font-mono text-xs font-medium leading-5 text-fg`,title:s,children:o}),t[5]=o,t[6]=s,t[7]=u):u=t[7];let d;t[8]===l?d=t[9]:(d=l?(0,W.jsx)(f,{delayDuration:300,skipDelayDuration:100,children:(0,W.jsxs)(ie,{children:[(0,W.jsx)(pe,{asChild:!0,children:(0,W.jsx)(`p`,{tabIndex:0,title:l,className:i(`mt-1 line-clamp-3 cursor-help text-xs leading-5 text-fg-muted`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`),children:l})}),(0,W.jsx)(O,{children:(0,W.jsx)(P,{side:`top`,align:`start`,sideOffset:6,collisionPadding:12,className:`!z-[10000] max-h-[min(16rem,45vh)] max-w-[min(32rem,calc(100vw-2rem))] overflow-y-auto rounded-md border border-edge bg-surface-panel px-2.5 py-2 text-left text-xs leading-5 text-fg shadow-popover`,children:(0,W.jsx)(`span`,{className:`whitespace-pre-wrap break-words`,children:l})})})]})}):null,t[8]=l,t[9]=d);let p;return t[10]!==u||t[11]!==d?(p=(0,W.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-edge bg-surface-panel px-3 py-2.5`,children:[u,d]}),t[10]=u,t[11]=d,t[12]=p):p=t[12],p}function cn({open:e,mode:t,initialRow:n,existingCustomServers:r,sessionIdleTtlMinutes:a,config:o,managedServerIds:s,t:c,cs:l,onClose:u,onSaved:d}){let[f,m]=(0,H.useState)(n),[h,v]=(0,H.useState)(!1),[y,b]=(0,H.useState)(!1),[S,C]=(0,H.useState)(null),[w,T]=(0,H.useState)(!1),[D,O]=(0,H.useState)({status:`idle`}),[M,P]=(0,H.useState)(null),ne=n.id.trim(),F=f.id.trim()!==ne&&s.has(f.id.trim())||s.has(f.id.trim())&&t===`add`?c.reservedServerId:void 0,re=f.id.trim()&&r.some(e=>e.clientKey!==n.clientKey&&e.id.trim()===f.id.trim())?l.duplicateServerId:void 0,I=f.id.trim().length>0&&!F&&!re&&(f.transport===`stdio`?f.command.trim().length>0:f.url.trim().length>0),L=Ct(f),ie=(0,H.useCallback)(async()=>{if(f.id.trim()){b(!0),C(null),O({status:`loading`});try{O({status:`ok`,tools:(await bt(f.id.trim(),ht(f))).tools})}catch(e){O({status:`error`,message:e instanceof Error?e.message:String(e)})}finally{b(!1)}}},[f]),ae=(0,H.useCallback)(async()=>{if(!(!I||h)){v(!0),C(null);try{let e=r.filter(e=>!(t===`edit`&&e.clientKey===n.clientKey));e.push(f),await gt({sessionIdleTtlMinutes:a,servers:e.sort((e,t)=>e.id.localeCompare(t.id))},ct(o)),await d(),u()}catch(e){C(e instanceof Error?e.message:String(e))}finally{v(!1)}}},[I,o,r,n.clientKey,t,u,d,ne,f,h,a]);return e?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(A,{open:e,onOpenChange:e=>{e||u()},children:(0,W.jsxs)(x,{children:[(0,W.jsx)(ee,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,W.jsxs)(_e,{className:i(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(100vh-2rem,44rem)] w-[min(100%-2rem,min(92vw,48rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-panel shadow-float dark:border-edge`),children:[(0,W.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(te,{className:`text-base font-semibold text-fg`,children:t===`add`?l.addCustomServerTitle:l.editCustomServerTitle}),(0,W.jsx)(p,{className:`mt-1 text-sm text-fg-muted`,children:t===`add`?l.addCustomServerHint:l.editCustomServerHint})]}),(0,W.jsx)(k,{asChild:!0,children:(0,W.jsxs)(`button`,{type:`button`,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,B.focusRingPanel),"aria-label":l.modalClose,children:[(0,W.jsx)(_,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,W.jsx)(`span`,{className:`sr-only`,children:l.modalClose})]})})]}),(0,W.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:(0,W.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,W.jsx)(`section`,{className:`rounded-xl border border-edge bg-surface-base p-4`,children:(0,W.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,W.jsx)(R,{className:`size-4 text-accent`,"aria-hidden":!0}),f.id.trim()||c.cardUntitled]}),(0,W.jsx)(`p`,{className:`mt-1 break-all font-mono text-xs leading-5 text-fg-muted`,children:L||(f.transport===`stdio`?c.commandLabel:c.urlLabel)})]}),(0,W.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:c.transportLabels[f.transport]})]})}),(0,W.jsxs)(`section`,{children:[(0,W.jsxs)(`div`,{className:`mb-3`,children:[(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:l.connectorBasicConfigTitle}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:l.connectorBasicConfigHint})]}),(0,W.jsx)(an,{row:f,t:c,variant:`basic`,onUpdate:e=>{m(t=>({...t,...e})),C(null)},idConflictMessage:F??re})]}),D.status===`ok`?(0,W.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-base p-3`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,W.jsx)(E,{className:`size-4 text-accent`,"aria-hidden":!0}),D.tools.length===0?c.toolsEmpty:c.toolsTitle.replace(`{{count}}`,String(D.tools.length))]}),D.tools.length>0?(0,W.jsx)(V,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,onClick:()=>P(D.tools),children:c.viewAllTools}):null]}),D.tools.length>0?(0,W.jsx)(`div`,{className:`mt-3 grid gap-2`,children:D.tools.slice(0,6).map((e,t)=>(0,W.jsx)(sn,{tool:e,serverId:f.id},e.name||`tool-${t}`))}):null]}):null,D.status===`error`?(0,W.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:D.message}):null,S?(0,W.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:S}):null,(0,W.jsxs)(`details`,{open:w,onToggle:e=>T(e.currentTarget.open),className:`group rounded-xl border border-edge bg-surface-base`,children:[(0,W.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg hover:text-fg [&::-webkit-details-marker]:hidden`,children:[(0,W.jsx)(me,{className:`size-4 text-fg-muted transition-transform group-open:rotate-180`,"aria-hidden":!0}),(0,W.jsx)(`span`,{className:`group-open:hidden`,children:l.connectorShowAdvancedConfig}),(0,W.jsx)(`span`,{className:`hidden group-open:inline`,children:l.connectorHideAdvancedConfig})]}),(0,W.jsx)(`div`,{className:`border-t border-edge px-4 py-4`,children:(0,W.jsx)(an,{row:f,t:c,variant:`advanced`,onUpdate:e=>{m(t=>({...t,...e})),C(null)}})})]})]})}),(0,W.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[(0,W.jsxs)(V,{variant:`secondary`,disabled:!f.id.trim()||y,onClick:()=>void ie(),children:[y?(0,W.jsx)(j,{className:`size-4 animate-spin`}):(0,W.jsx)(g,{className:`size-4`}),c.testConnection]}),(0,W.jsx)(k,{asChild:!0,children:(0,W.jsx)(V,{variant:`secondary`,children:l.modalCancel})}),(0,W.jsxs)(V,{variant:`primary`,disabled:!I||h,onClick:()=>void ae(),children:[h?(0,W.jsx)(j,{className:`size-4 animate-spin`}):(0,W.jsx)(N,{className:`size-4`}),h?c.saving:l.modalSave]})]})]})]})}),M?(0,W.jsx)(kt,{open:!0,onOpenChange:e=>{e||P(null)},serverId:f.id,title:c.toolsDialogTitle,subtitle:c.toolsDialogSubtitle,searchPlaceholder:c.toolsDialogSearchPlaceholder,searchEmptyLabel:c.toolsDialogSearchEmpty,emptyLabel:c.toolsEmpty,closeLabel:c.toolsDialogClose,tools:M,stripPrefix:`${f.id.trim()}__`}):null]}):null}var ln=`mprov`,un=`xopc-store`,dn=un,fn=i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,h);function pn(e){let t=[`code`,`docs`,`browser`,`data`,`automation`,`custom`].includes(e.category??``)?e.category:`custom`;return{id:e.name,version:e.latestVersion??`store`,displayName:e.name,description:e.description,category:t,kind:`mcp`,source:`store`,capabilities:[`tools`,`runtime.mcp.streamableHttp`],tags:[`store`],auth:{mode:`none`},setup:{},runtime:{type:`mcp`,serverId:`store-${e.name}`.slice(0,64)}}}function mn(){let e=a(l(e=>e.language)),t=e.connectorsSettings,n=e.mcpSettings,r=o(e=>e.token),s=!!r,[c,d]=v(),f=c.get(ln)?.trim()||dn,[p,m]=(0,H.useState)(`marketplace`),[h,g]=(0,H.useState)({catalog:[],registryCatalog:[],instances:[],registries:[],loading:!0,error:null}),[_,x]=(0,H.useState)(!1),[w,E]=(0,H.useState)(!1),[O,k]=(0,H.useState)(1),[A,ee]=(0,H.useState)(void 0),[M,te]=(0,H.useState)(``),[N,P]=(0,H.useState)(f),[F,re]=(0,H.useState)(`name`),[I,L]=(0,H.useState)(null),[ie,ae]=(0,H.useState)(null),[oe,se]=(0,H.useState)(null),[le,ue]=(0,H.useState)(null),[R,z]=(0,H.useState)(null),[de,fe]=(0,H.useState)(void 0),[pe,he]=(0,H.useState)(!1),[_e,ve]=(0,H.useState)(!1),{data:U,mutate:G}=ce(s),K=U?.payload?.config,q=(0,H.useMemo)(()=>K===void 0?null:mt(K),[K]),J=q?.servers??[];(0,H.useEffect)(()=>{q&&fe(q.sessionIdleTtlMinutes)},[q]);let Y=(0,H.useCallback)(async()=>{if(!r){g({catalog:[],registryCatalog:[],instances:[],registries:[],loading:!1,error:null});return}g(e=>({...e,loading:!0,error:null}));try{let[e,t,n]=await Promise.all([De(),Me(),je()]);g(r=>({catalog:e,registryCatalog:r.registryCatalog,instances:t,registries:n,loading:!1,error:null}))}catch(e){g({catalog:[],registryCatalog:[],instances:[],registries:[],loading:!1,error:e instanceof Error?e.message:String(e)})}},[r]);(0,H.useEffect)(()=>{Y()},[Y]);let Ae=c.toString(),Ne=(0,H.useRef)(Ae);(0,H.useEffect)(()=>{Ne.current!==Ae&&(Ne.current=Ae,P(c.get(ln)?.trim()||dn))},[c,Ae]);let Pe=(0,H.useMemo)(()=>[{id:un,displayName:t.storeSourceName},...h.registries],[t.storeSourceName,h.registries]);(0,H.useEffect)(()=>{if(Pe.length===0||Pe.some(e=>e.id===N))return;let e=Pe.some(e=>e.id===dn)?dn:Pe[0]?.id;e&&P(e)},[Pe,N]),(0,H.useEffect)(()=>{if(!N||N===c.get(ln))return;let e=new URLSearchParams(c);e.set(ln,N),Ne.current=e.toString(),d(e,{replace:!0})},[N,c,d]);let Ie=(0,H.useCallback)(async e=>{let t=M.trim(),n=e?.browse??!1,r=Math.max(e?.page??1,1),i=e?.append??!1;if(!(!s||N!==un&&!t&&!n)){x(!0),i?g(e=>({...e,error:null})):(k(1),ee(void 0),g(e=>({...e,registryCatalog:[],error:null})));try{let e=N===un?await Oe({q:t||void 0,page:r,pageSize:24,sort:F===`source`?`newest`:`downloads`}).then(e=>({connectors:e.items.map(pn),totalPages:e.meta.totalPages})):await Fe(t,N,{browse:n,page:r});k(r),ee(e.totalPages),g(t=>({...t,registryCatalog:i?[...t.registryCatalog,...e.connectors].filter((e,t,n)=>n.findIndex(t=>t.id===e.id)===t):e.connectors}))}catch(e){g(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{x(!1)}}},[F,s,M,N]);(0,H.useEffect)(()=>{if(p!==`marketplace`)return;let e=window.setTimeout(()=>{M.trim()?Ie():N&&Ie({browse:!0})},M.trim()?350:0);return()=>window.clearTimeout(e)},[N,M,Ie,h.loading,p]);let Le=(0,H.useMemo)(()=>new Set(h.instances.map(e=>e.connectorId)),[h.instances]),Re=(0,H.useMemo)(()=>new Map([...h.catalog,...h.registryCatalog].map(e=>[e.id,e])),[h.catalog,h.registryCatalog]),ze=(0,H.useCallback)(async e=>{E(!0),g(e=>({...e,error:null}));try{let n=await ke(e);if(n.requiresOAuth&&n.definition.id!==`github`)throw Error(t.storeOAuthUnsupported);L(Gt(n.definition,{packageName:n.packageName,version:n.version,permissions:n.permissions}))}catch(e){g(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{E(!1)}},[t.storeOAuthUnsupported]),Be=(0,H.useMemo)(()=>new Set(h.instances.flatMap(e=>e.materialized.type===`mcp`?[e.materialized.serverId]:[])),[h.instances]),Ve=(0,H.useCallback)(async e=>{if(!q||K===void 0)return;let t=J.filter(t=>t.clientKey!==e.clientKey);await gt({sessionIdleTtlMinutes:q.sessionIdleTtlMinutes,servers:t},ct(K)),await G(),await Y()},[K,J,Y,q,G]),He=(0,H.useCallback)(()=>{z({mode:`add`,row:Yt(J,Be)})},[J,Be]),Ue=(0,H.useCallback)(async()=>{if(!(!q||K===void 0||pe)){he(!0),ve(!1);try{await gt({sessionIdleTtlMinutes:de,servers:J},ct(K)),await G(),ve(!0),u({type:`success`,title:n.saved})}finally{he(!1)}}},[K,J,q,G,de,pe]),We=b(e=>e.setPageHeader),Ge=b(e=>e.clearPageHeader),Ke=(0,H.useMemo)(()=>(0,W.jsx)(nt,{loading:h.loading||_||w,searchQuery:M,setSearchQuery:te,onReloadClick:Y,onAddCustomServer:He,searchPlaceholder:p===`marketplace`?t.marketplaceSearchPlaceholder:p===`builtin`?t.builtinSearchPlaceholder:p===`user`?t.userSearchPlaceholder:t.configSearchPlaceholder,addLabel:t.addCustomServer,reloadLabel:t.reload}),[t,Y,He,_,M,h.loading,w,p]);(0,H.useLayoutEffect)(()=>(We({startExtra:null,main:(0,W.jsx)(`div`,{className:`min-w-0`,children:(0,W.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.title})}),end:Ke}),()=>Ge()),[Ge,t.title,Ke,We]);let qe=h.instances.length+J.length,Je=(0,H.useMemo)(()=>Zt(h.catalog.filter(e=>e.source===`builtin`),M,F),[F,M,h.catalog]),X=(0,H.useMemo)(()=>Zt(h.registryCatalog,M,F),[F,M,h.registryCatalog]),Ye=p===`marketplace`&&!!(A&&O<A),Xe=(0,H.useMemo)(()=>h.instances.filter(e=>Qt(e,M)),[M,h.instances]),Ze=(0,H.useMemo)(()=>J.filter(e=>$t(e,M)),[J,M]),Qe=(0,H.useMemo)(()=>h.instances.find(e=>e.instanceId===oe)??le,[oe,le,h.instances]),$e=Xe.length+Ze.length,et=[{id:`marketplace`,label:t.tabMarketplace},{id:`builtin`,label:t.tabBuiltin,count:Je.length},{id:`user`,label:t.tabUser,count:qe},{id:`config`,label:t.tabConfig}];return(0,W.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:(0,W.jsxs)(`div`,{className:`flex w-full flex-col gap-6 px-3 py-6 sm:px-5 xl:px-6`,children:[s?null:(0,W.jsx)(`p`,{className:`rounded-xl border border-edge bg-surface-panel px-4 py-3 text-sm text-fg-muted`,children:t.tokenHint}),(0,W.jsxs)(`section`,{className:`flex flex-col gap-4`,children:[(0,W.jsxs)(`div`,{className:`flex flex-col gap-3 border-b border-edge-subtle pb-3 sm:flex-row sm:items-center sm:justify-between dark:border-edge-subtle`,children:[(0,W.jsx)(xe,{items:et,activeTab:p,onChange:m,ariaLabel:t.navAria,tabIdPrefix:`connectors-tab`,panelIdPrefix:`connectors-panel`,className:`flex-wrap`}),(0,W.jsxs)(`div`,{className:`flex min-h-9 min-w-0 flex-wrap items-center gap-2 sm:justify-end`,children:[p===`marketplace`?(0,W.jsx)(`div`,{className:`inline-flex h-9 max-w-full shrink-0 overflow-x-auto rounded-lg border border-edge bg-surface-panel p-0.5 shadow-surface`,role:`group`,"aria-label":t.registrySourceAria,children:Pe.map(e=>(0,W.jsx)(`button`,{type:`button`,className:i(`shrink-0 rounded-md px-2.5 py-1.5 text-xs font-medium transition-colors`,B.focusRingPanel,N===e.id?`bg-fg text-surface-panel dark:bg-fg dark:text-surface-base`:`text-fg-muted hover:text-fg`),"aria-pressed":N===e.id,onClick:()=>P(e.id),children:e.displayName},e.id))}):null,p!==`user`&&p!==`config`?(0,W.jsxs)(y,{children:[(0,W.jsx)(S,{asChild:!0,children:(0,W.jsxs)(`button`,{type:`button`,className:i(`inline-flex h-9 min-h-9 min-w-[9rem] shrink-0 items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 text-xs font-medium text-fg shadow-surface`,B.transition,B.focusRingPanel),children:[(0,W.jsx)(ne,{className:`size-3.5 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),(0,W.jsx)(`span`,{children:F===`name`?t.sortName:t.sortSource}),(0,W.jsx)(me,{className:`size-3.5 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0})]})}),(0,W.jsx)(D,{children:(0,W.jsxs)(C,{className:`z-50 min-w-[10rem] rounded-xl border border-edge bg-surface-panel p-1 shadow-popover dark:border-edge`,sideOffset:6,align:`end`,children:[(0,W.jsx)(T,{className:`cursor-pointer rounded-lg px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover data-[highlighted]:bg-surface-hover`,onSelect:()=>re(`name`),children:t.sortName}),(0,W.jsx)(T,{className:`cursor-pointer rounded-lg px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover data-[highlighted]:bg-surface-hover`,onSelect:()=>re(`source`),children:t.sortSource})]})})]}):null]})]}),h.error?(0,W.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:h.error}):null,p===`user`&&s?(0,W.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.installedTitle}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.installedHint})]}),h.loading?(0,W.jsx)(`div`,{className:`grid gap-3`,"aria-busy":`true`,"aria-label":t.loading,children:Se.slice(0,3).map(e=>(0,W.jsx)(Te,{},e))}):qe===0||$e===0?(0,W.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center text-sm text-fg-muted`,children:qe===0?t.installedEmpty:t.userEmpty}):(0,W.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:[Xe.map(e=>(0,W.jsx)(Bt,{instance:e,definition:Re.get(e.connectorId),onOpenDetails:e=>{se(e.instanceId),ue(e)},onChanged:Y,t},e.instanceId)),Ze.map(e=>(0,W.jsx)(wt,{row:e,t:n,cs:t,onEdit:()=>z({mode:`edit`,row:structuredClone(e)}),onRemove:async()=>Ve(e)},e.clientKey))]}),(0,W.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.disableHint})]}):null,p===`config`&&s?(0,W.jsx)(`div`,{className:`flex flex-col gap-4`,children:(0,W.jsxs)(be,{children:[(0,W.jsx)(ye,{icon:ge,title:n.globalTitle,subtitle:n.globalHint}),(0,W.jsx)(`div`,{className:`max-w-xl`,children:(0,W.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,W.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.idleTtlLabel}),(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`input`,{type:`number`,min:0,className:i(fn,`w-40 flex-none`),value:de??``,placeholder:n.idleTtlPlaceholder,onChange:e=>{let t=e.target.value.trim();fe(t===``?void 0:Number.parseInt(t,10)),ve(!1)}}),(0,W.jsxs)(V,{variant:`secondary`,disabled:pe,onClick:()=>void Ue(),children:[pe?(0,W.jsx)(j,{className:`size-4 animate-spin`}):null,n.save]})]}),(0,W.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:n.idleTtlHint})]})})]})}):null,p===`marketplace`&&s?(0,W.jsx)(`div`,{className:`flex flex-col gap-4`,children:_&&X.length===0?(0,W.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,"aria-busy":`true`,"aria-label":t.loading,children:Se.map(e=>(0,W.jsx)(we,{},e))}):M.trim()&&X.length===0?(0,W.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center text-sm text-fg-muted`,children:t.marketplaceEmpty}):!M.trim()&&X.length===0?(0,W.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center text-sm text-fg-muted`,children:t.marketplaceStartHint}):(0,W.jsxs)(`div`,{className:`relative`,children:[_?(0,W.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-[1] flex justify-center bg-surface-panel/40 pt-[min(28vh,7.5rem)] backdrop-blur-[1px] motion-reduce:backdrop-blur-none dark:bg-surface-base/35`,"aria-busy":`true`,"aria-label":t.loading,children:(0,W.jsx)(j,{className:`size-8 shrink-0 animate-spin text-accent motion-reduce:animate-none`,strokeWidth:2,"aria-hidden":!0})}):null,(0,W.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:X.map(e=>(0,W.jsx)(Ee,{connector:e,installed:Le.has(e.id)||Ce(e,h.instances),onInstall:e=>{if(e.source===`store`){ze(e.id);return}L(Gt(e))},onOpenDetails:e.source===`store`?void 0:ae,t},e.id))}),Ye?(0,W.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,W.jsxs)(V,{type:`button`,variant:`secondary`,disabled:_||w,onClick:()=>void Ie({browse:!M.trim(),page:O+1,append:!0}),children:[_?(0,W.jsx)(j,{className:`size-4 animate-spin`}):null,t.loadMore]})}):null]})}):null,p===`builtin`&&s?(0,W.jsx)(`div`,{className:`flex flex-col gap-4`,children:h.loading?(0,W.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,"aria-busy":`true`,"aria-label":t.loading,children:Se.map(e=>(0,W.jsx)(we,{},e))}):Je.length===0?(0,W.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center text-sm text-fg-muted`,children:t.builtinEmpty}):(0,W.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:Je.map(e=>(0,W.jsx)(Ee,{connector:e,installed:Le.has(e.id)||Ce(e,h.instances),onInstall:e=>L(Gt(e)),onOpenDetails:ae,t},e.id))})}):null]}),I?(0,W.jsx)(Jt,{draft:I,onChange:L,onClose:()=>L(null),t,onInstalled:async()=>{await Y(),await G(),m(`user`)}}):null,ie?(0,W.jsx)(tt,{connector:ie,installed:Le.has(ie.id)||Ce(ie,h.instances),onClose:()=>ae(null),onInstall:e=>L(Gt(e)),t}):null,Qe?(0,W.jsx)(zt,{instance:Qe,definition:Re.get(Qe.connectorId),onClose:()=>{se(null),ue(null)},onChanged:Y,t,mcp:n}):null,R?(0,W.jsx)(cn,{open:!0,mode:R.mode,initialRow:R.row,existingCustomServers:J,sessionIdleTtlMinutes:de,config:K,managedServerIds:Be,t:n,cs:t,onClose:()=>z(null),onSaved:async()=>{await G(),await Y(),m(`user`)}},`${R.mode}-${R.row.clientKey}`):null]})})}export{mn as ConnectorsPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./messages-DR9ODkb8.js";import{n as a}from"./locale-store-Ba72bFmP.js";import{Do as o,tl as s}from"./index-BOme955B.js";import{t as c}from"./desktop-pet-sprite-DqZ6fbIj.js";var l=e(t(),1),u=n();function d(e){return e?`/chat/${e.sessionKey}`:void 0}var f=r(),p=8e3;function m(e){let t={error:0,waiting:1,running:2,success:3};return e.sort((e,n)=>t[e.state]-t[n.state]||n.timestamp-e.timestamp).slice(0,3)}function h(){return{prefs:{enabled:!0,showOnStartup:!1,selectedPetId:`ember`,alwaysOnTop:!0,bubbleEnabled:!0,clickThroughWhenIdle:!1,muted:!1,feedbackLevel:`normal`,sizePercent:100,collapsed:!1},pets:[],visible:!0,customPetsDir:``,petIssues:[]}}function g(){let e=i(a(e=>e.language)).desktopPet,[t,n]=(0,l.useState)(h),[r,u]=(0,l.useState)({}),[g,_]=(0,l.useState)(()=>new Set),[v,y]=(0,l.useState)(Date.now()),b=(0,l.useRef)(null),x=(0,l.useRef)(!1),S=(0,l.useRef)(null),C=(0,l.useRef)(null),w=(0,l.useRef)(null),T=(0,l.useMemo)(()=>t.pets.find(e=>e.id===t.prefs.selectedPetId)??t.pets[0],[t]),E=Math.min(1.4,Math.max(.7,t.prefs.sizePercent/100)),D=(0,l.useMemo)(()=>m(Object.values(r).filter(e=>!e.expiresAt||e.expiresAt>v)),[r,v]),O=(0,l.useMemo)(()=>D.filter(e=>!g.has(e.sessionKey)),[D,g]),k=O[0],A=k?.state===`error`?`error`:k?.state===`success`?`success`:k?`typing`:`idle`;(0,l.useEffect)(()=>{document.documentElement.dataset.desktopPet=`true`;let e=window.electronAPI?.pet;if(!e)return;e.getState().then(n).catch(()=>{});let t=e.onStateChanged(n),r=e.onEvent(e=>u(t=>{let n=t[e.sessionKey];return n&&e.sequence<=n.sequence?t:{...t,[e.sessionKey]:{...n,...e,outputLines:e.outputLines??n?.outputLines,expiresAt:e.state===`success`?Date.now()+p:void 0}}})),i=window.setInterval(()=>y(Date.now()),1e3);return()=>{delete document.documentElement.dataset.desktopPet,t(),r(),window.clearInterval(i)}},[]),(0,l.useLayoutEffect)(()=>{let e=S.current,t=window.electronAPI?.pet;if(!e||!t)return;let n=()=>{let e=[C.current,w.current].filter(e=>e!==null).map(e=>e.getBoundingClientRect());if(!e.length)return;let n=Math.min(...e.map(e=>e.left)),r=Math.min(...e.map(e=>e.top)),i=Math.max(...e.map(e=>e.right)),a=Math.max(...e.map(e=>e.bottom));t.setContentSize({width:Math.ceil(i-n),height:Math.ceil(a-r)})},r=new ResizeObserver(n);return r.observe(e),C.current&&r.observe(C.current),w.current&&r.observe(w.current),n(),()=>r.disconnect()},[O.length,t.prefs.collapsed,E]);let j=(e=k)=>{e?.state===`success`&&u(t=>{let{[e.sessionKey]:n,...r}=t;return r}),window.electronAPI?.pet?.openMainWindow(d(e))},M=async()=>{if(g.size>0&&(_(new Set),!t.prefs.collapsed))return;let e=await window.electronAPI?.pet?.setPrefs({collapsed:!t.prefs.collapsed});e&&n(e)},N=(0,l.useCallback)(e=>{e.button===0&&(b.current={pointerId:e.pointerId,x:e.clientX,y:e.clientY,moved:!1},e.currentTarget.setPointerCapture(e.pointerId),window.electronAPI?.pet?.startDrag({screenX:e.screenX,screenY:e.screenY}))},[]),P=(0,l.useCallback)(e=>{let t=b.current;!t||t.pointerId!==e.pointerId||Math.abs(e.clientX-t.x)+Math.abs(e.clientY-t.y)>4&&(t.moved=!0,window.electronAPI?.pet?.drag({screenX:e.screenX,screenY:e.screenY}))},[]),F=(0,l.useCallback)(e=>{let t=b.current;!t||t.pointerId!==e.pointerId||(b.current=null,window.electronAPI?.pet?.endDrag(),t.moved&&(x.current=!0,window.setTimeout(()=>{x.current=!1},0)))},[]);return T?(0,f.jsxs)(`div`,{ref:S,className:`desktop-pet-window`,style:{"--desktop-pet-stage-size":`${Math.round(132*E)}px`,"--desktop-pet-menu-size":`${Math.round(28*E)}px`,"--desktop-pet-menu-left":`0px`,"--desktop-pet-menu-bottom":`${Math.round(12*E)}px`},children:[!t.prefs.collapsed&&O.length>0?(0,f.jsx)(`div`,{ref:C,className:`desktop-pet-bubble desktop-pet-queue`,children:O.map(e=>(0,f.jsxs)(`div`,{className:`desktop-pet-session desktop-pet-session--${e.state}`,children:[(0,f.jsxs)(`button`,{type:`button`,className:`desktop-pet-session-open`,onClick:()=>j(e),children:[(0,f.jsx)(`span`,{className:`desktop-pet-session-dot`}),(0,f.jsxs)(`span`,{className:`desktop-pet-session-main`,children:[(0,f.jsx)(`strong`,{children:e.sessionLabel}),(0,f.jsxs)(`span`,{children:[e.action,e.detail?`:${e.detail}`:e.progress?` · ${e.progress.completed}/${e.progress.total}`:e.outputLines?.length?`:${e.outputLines[Math.floor((v-e.timestamp)/1800)%e.outputLines.length]}`:e.outputTail?`:${e.outputTail}`:e.state===`running`?` · ${Math.max(1,Math.floor((v-e.timestamp)/1e3))}s`:``]})]})]}),(0,f.jsx)(`button`,{type:`button`,className:`desktop-pet-session-close`,"aria-label":`收起会话`,onClick:()=>_(t=>new Set(t).add(e.sessionKey)),children:(0,f.jsx)(o,{size:12})})]},e.sessionKey))}):null,(0,f.jsxs)(`div`,{ref:w,className:`desktop-pet-stage`,children:[(0,f.jsx)(`button`,{type:`button`,className:`desktop-pet-menu-button`,onClick:()=>void M(),"aria-label":e.menu,children:(t.prefs.collapsed?D.length:g.size)>0?(0,f.jsx)(`span`,{className:`desktop-pet-tip-count`,children:Math.min(99,t.prefs.collapsed?D.length:g.size)}):(0,f.jsx)(s,{className:`desktop-pet-menu-chevron size-4`})}),(0,f.jsx)(`button`,{type:`button`,className:`desktop-pet-hit-area`,onClick:()=>{x.current||j()},onPointerDown:N,onPointerMove:P,onPointerUp:F,onPointerCancel:F,title:e.openApp,children:(0,f.jsx)(c,{pet:T,action:A,displayHeight:Math.round(112*E)})})]})]}):null}function _(){let e=(0,u.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,f.jsx)(g,{}),e[0]=t):t=e[0],t}export{_ as DesktopPetPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,i as n,t as r}from"./vendor-react-BOUWij0V.js";import{n as i}from"./dist-DokQNVMQ.js";import{_ as a,d as o,f as s,s as c}from"./Combination-BzaXOLd9.js";var l=e(t(),1),u=[`top`,`right`,`bottom`,`left`],d=Math.min,f=Math.max,p=Math.round,m=Math.floor,h=e=>({x:e,y:e}),g={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function _(e,t,n){return f(e,d(t,n))}function v(e,t){return typeof e==`function`?e(t):e}function y(e){return e.split(`-`)[0]}function b(e){return e.split(`-`)[1]}function x(e){return e===`x`?`y`:`x`}function S(e){return e===`y`?`height`:`width`}function C(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function w(e){return x(C(e))}function T(e,t,n){n===void 0&&(n=!1);let r=b(e),i=w(e),a=S(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=P(o)),[o,P(o)]}function E(e){let t=P(e);return[D(e),t,D(t)]}function D(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var O=[`left`,`right`],k=[`right`,`left`],A=[`top`,`bottom`],j=[`bottom`,`top`];function M(e,t,n){switch(e){case`top`:case`bottom`:return n?t?k:O:t?O:k;case`left`:case`right`:return t?A:j;default:return[]}}function N(e,t,n,r){let i=b(e),a=M(y(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(D)))),a}function P(e){let t=y(e);return g[t]+e.slice(t.length)}function ee(e){return{top:0,right:0,bottom:0,left:0,...e}}function te(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:ee(e)}function F(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function I(e,t,n){let{reference:r,floating:i}=e,a=C(t),o=w(t),s=S(o),c=y(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}switch(b(t)){case`start`:p[o]-=f*(n&&l?-1:1);break;case`end`:p[o]+=f*(n&&l?-1:1);break}return p}async function L(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=v(t,e),p=te(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=F(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),y=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},b=F(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-b.top+p.top)/y.y,bottom:(b.bottom-h.bottom+p.bottom)/y.y,left:(h.left-b.left+p.left)/y.x,right:(b.right-h.right+p.right)/y.x}}var R=50,ne=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:L},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=I(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<R&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=I(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},re=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=v(e,t)||{};if(l==null)return{};let f=te(u),p={x:n,y:r},m=w(i),h=S(m),g=await o.getDimensions(l),y=m===`y`,x=y?`top`:`left`,C=y?`bottom`:`right`,T=y?`clientHeight`:`clientWidth`,E=a.reference[h]+a.reference[m]-p[m]-a.floating[h],D=p[m]-a.reference[m],O=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),k=O?O[T]:0;(!k||!await(o.isElement==null?void 0:o.isElement(O)))&&(k=s.floating[T]||a.floating[h]);let A=E/2-D/2,j=k/2-g[h]/2-1,M=d(f[x],j),N=d(f[C],j),P=M,ee=k-g[h]-N,F=k/2-g[h]/2+A,I=_(P,F,ee),L=!c.arrow&&b(i)!=null&&F!==I&&a.reference[h]/2-(F<P?M:N)-g[h]/2<0,R=L?F<P?F-P:F-ee:0;return{[m]:p[m]+R,data:{[m]:I,centerOffset:F-I-R,...L&&{alignmentOffset:R}},reset:L}}}),ie=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=v(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=y(r),_=C(o),b=y(o)===o,x=await(s.isRTL==null?void 0:s.isRTL(c.floating)),S=d||(b||!m?[P(o)]:E(o)),w=p!==`none`;!d&&w&&S.push(...N(o,m,p,x));let D=[o,...S],O=await s.detectOverflow(t,h),k=[],A=i.flip?.overflows||[];if(l&&k.push(O[g]),u){let e=T(r,a,x);k.push(O[e[0]],O[e[1]])}if(A=[...A,{placement:r,overflows:k}],!k.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=D[e];if(t&&(!(u===`alignment`&&_!==C(t))||A.every(e=>C(e.placement)===_?e.overflows[0]>0:!0)))return{data:{index:e,overflows:A},reset:{placement:t}};let n=A.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=A.filter(e=>{if(w){let t=C(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o;break}if(r!==n)return{reset:{placement:n}}}return{}}}};function ae(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function oe(e){return u.some(t=>e[t]>=0)}var se=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=v(e,t);switch(i){case`referenceHidden`:{let e=ae(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:oe(e)}}}case`escaped`:{let e=ae(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:oe(e)}}}default:return{}}}}},ce=new Set([`left`,`top`]);async function le(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=y(n),s=b(n),c=C(n)===`y`,l=ce.has(o)?-1:1,u=a&&c?-1:1,d=v(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var ue=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await le(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},de=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=v(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=C(y(i)),p=x(f),m=u[p],h=u[f];if(o){let e=p===`y`?`top`:`left`,t=p===`y`?`bottom`:`right`,n=m+d[e],r=m-d[t];m=_(n,m,r)}if(s){let e=f===`y`?`top`:`left`,t=f===`y`?`bottom`:`right`,n=h+d[e],r=h-d[t];h=_(n,h,r)}let g=c.fn({...t,[p]:m,[f]:h});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[p]:o,[f]:s}}}}}},fe=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=v(e,t),u={x:n,y:r},d=C(i),f=x(d),p=u[f],m=u[d],h=v(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=ce.has(y(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},pe=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){var n,r;let{placement:i,rects:a,platform:o,elements:s}=t,{apply:c=()=>{},...l}=v(e,t),u=await o.detectOverflow(t,l),p=y(i),m=b(i),h=C(i)===`y`,{width:g,height:_}=a.floating,x,S;p===`top`||p===`bottom`?(x=p,S=m===(await(o.isRTL==null?void 0:o.isRTL(s.floating))?`start`:`end`)?`left`:`right`):(S=p,x=m===`end`?`top`:`bottom`);let w=_-u.top-u.bottom,T=g-u.left-u.right,E=d(_-u[x],w),D=d(g-u[S],T),O=!t.middlewareData.shift,k=E,A=D;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(A=T),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(k=w),O&&!m){let e=f(u.left,0),t=f(u.right,0),n=f(u.top,0),r=f(u.bottom,0);h?A=g-2*(e!==0||t!==0?e+t:f(u.left,u.right)):k=_-2*(n!==0||r!==0?n+r:f(u.top,u.bottom))}await c({...t,availableWidth:A,availableHeight:k});let j=await o.getDimensions(s.floating);return g!==j.width||_!==j.height?{reset:{rects:!0}}:{}}}};function z(){return typeof window<`u`}function B(e){return me(e)?(e.nodeName||``).toLowerCase():`#document`}function V(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function H(e){return((me(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function me(e){return z()?e instanceof Node||e instanceof V(e).Node:!1}function U(e){return z()?e instanceof Element||e instanceof V(e).Element:!1}function W(e){return z()?e instanceof HTMLElement||e instanceof V(e).HTMLElement:!1}function he(e){return!z()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof V(e).ShadowRoot}function G(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=J(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function ge(e){return/^(table|td|th)$/.test(B(e))}function _e(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var ve=/transform|translate|scale|rotate|perspective|filter/,ye=/paint|layout|strict|content/,K=e=>!!e&&e!==`none`,be;function xe(e){let t=U(e)?J(e):e;return K(t.transform)||K(t.translate)||K(t.scale)||K(t.rotate)||K(t.perspective)||!Ce()&&(K(t.backdropFilter)||K(t.filter))||ve.test(t.willChange||``)||ye.test(t.contain||``)}function Se(e){let t=Y(e);for(;W(t)&&!q(t);){if(xe(t))return t;if(_e(t))return null;t=Y(t)}return null}function Ce(){return be??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),be}function q(e){return/^(html|body|#document)$/.test(B(e))}function J(e){return V(e).getComputedStyle(e)}function we(e){return U(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Y(e){if(B(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||he(e)&&e.host||H(e);return he(t)?t.host:t}function Te(e){let t=Y(e);return q(t)?e.ownerDocument?e.ownerDocument.body:e.body:W(t)&&G(t)?t:Te(t)}function X(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=Te(e),i=r===e.ownerDocument?.body,a=V(r);if(i){let e=Ee(a);return t.concat(a,a.visualViewport||[],G(r)?r:[],e&&n?X(e):[])}else return t.concat(r,X(r,[],n))}function Ee(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function De(e){let t=J(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=W(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=p(n)!==a||p(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function Oe(e){return U(e)?e:e.contextElement}function Z(e){let t=Oe(e);if(!W(t))return h(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=De(t),o=(a?p(n.width):n.width)/r,s=(a?p(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var ke=h(0);function Ae(e){let t=V(e);return!Ce()||!t.visualViewport?ke:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function je(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==V(e)?!1:t}function Q(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=Oe(e),o=h(1);t&&(r?U(r)&&(o=Z(r)):o=Z(e));let s=je(a,n,r)?Ae(a):h(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a){let e=V(a),t=r&&U(r)?V(r):r,n=e,i=Ee(n);for(;i&&r&&t!==n;){let e=Z(i),t=i.getBoundingClientRect(),r=J(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=V(i),i=Ee(n)}}return F({width:u,height:d,x:c,y:l})}function Me(e,t){let n=we(e).scrollLeft;return t?t.left+n:Q(H(e)).left+n}function Ne(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-Me(e,n),y:n.top+t.scrollTop}}function Pe(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=H(r),s=t?_e(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=h(1),u=h(0),d=W(r);if((d||!d&&!a)&&((B(r)!==`body`||G(o))&&(c=we(r)),d)){let e=Q(r);l=Z(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?Ne(o,c):h(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function Fe(e){return Array.from(e.getClientRects())}function Ie(e){let t=H(e),n=we(e),r=e.ownerDocument.body,i=f(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=f(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight),o=-n.scrollLeft+Me(e),s=-n.scrollTop;return J(r).direction===`rtl`&&(o+=f(t.clientWidth,r.clientWidth)-i),{width:i,height:a,x:o,y:s}}var Le=25;function Re(e,t){let n=V(e),r=H(e),i=n.visualViewport,a=r.clientWidth,o=r.clientHeight,s=0,c=0;if(i){a=i.width,o=i.height;let e=Ce();(!e||e&&t===`fixed`)&&(s=i.offsetLeft,c=i.offsetTop)}let l=Me(r);if(l<=0){let e=r.ownerDocument,t=e.body,n=getComputedStyle(t),i=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,o=Math.abs(r.clientWidth-t.clientWidth-i);o<=Le&&(a-=o)}else l<=Le&&(a+=l);return{width:a,height:o,x:s,y:c}}function ze(e,t){let n=Q(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=W(e)?Z(e):h(1);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function Be(e,t,n){let r;if(t===`viewport`)r=Re(e,n);else if(t===`document`)r=Ie(H(e));else if(U(t))r=ze(t,n);else{let n=Ae(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return F(r)}function Ve(e,t){let n=Y(e);return n===t||!U(n)||q(n)?!1:J(n).position===`fixed`||Ve(n,t)}function He(e,t){let n=t.get(e);if(n)return n;let r=X(e,[],!1).filter(e=>U(e)&&B(e)!==`body`),i=null,a=J(e).position===`fixed`,o=a?Y(e):e;for(;U(o)&&!q(o);){let t=J(o),n=xe(o);!n&&t.position===`fixed`&&(i=null),(a?!n&&!i:!n&&t.position===`static`&&i&&(i.position===`absolute`||i.position===`fixed`)||G(o)&&!n&&Ve(e,o))?r=r.filter(e=>e!==o):i=t,o=Y(o)}return t.set(e,r),r}function Ue(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?_e(t)?[]:He(t,this._c):[].concat(n),r],o=Be(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=Be(t,a[e],i);s=f(n.top,s),c=d(n.right,c),l=d(n.bottom,l),u=f(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function We(e){let{width:t,height:n}=De(e);return{width:t,height:n}}function Ge(e,t,n){let r=W(t),i=H(t),a=n===`fixed`,o=Q(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=h(0);function l(){c.x=Me(i)}if(r||!r&&!a)if((B(t)!==`body`||G(i))&&(s=we(t)),r){let e=Q(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}else i&&l();a&&!r&&i&&l();let u=i&&!r&&!a?Ne(i,s):h(0);return{x:o.left+s.scrollLeft-c.x-u.x,y:o.top+s.scrollTop-c.y-u.y,width:o.width,height:o.height}}function Ke(e){return J(e).position===`static`}function qe(e,t){if(!W(e)||J(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return H(e)===n&&(n=n.ownerDocument.body),n}function Je(e,t){let n=V(e);if(_e(e))return n;if(!W(e)){let t=Y(e);for(;t&&!q(t);){if(U(t)&&!Ke(t))return t;t=Y(t)}return n}let r=qe(e,t);for(;r&&ge(r)&&Ke(r);)r=qe(r,t);return r&&q(r)&&Ke(r)&&!xe(r)?n:r||Se(e)||n}var Ye=async function(e){let t=this.getOffsetParent||Je,n=this.getDimensions,r=await n(e.floating);return{reference:Ge(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Xe(e){return J(e).direction===`rtl`}var Ze={convertOffsetParentRelativeRectToViewportRelativeRect:Pe,getDocumentElement:H,getClippingRect:Ue,getOffsetParent:Je,getElementRects:Ye,getClientRects:Fe,getDimensions:We,getScale:Z,isElement:U,isRTL:Xe};function Qe(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function $e(e,t){let n=null,r,i=H(e);function a(){var e;clearTimeout(r),(e=n)==null||e.disconnect(),n=null}function o(s,c){s===void 0&&(s=!1),c===void 0&&(c=1),a();let l=e.getBoundingClientRect(),{left:u,top:p,width:h,height:g}=l;if(s||t(),!h||!g)return;let _=m(p),v=m(i.clientWidth-(u+h)),y=m(i.clientHeight-(p+g)),b=m(u),x={rootMargin:-_+`px `+-v+`px `+-y+`px `+-b+`px`,threshold:f(0,d(1,c))||1},S=!0;function C(t){let n=t[0].intersectionRatio;if(n!==c){if(!S)return o();n?o(!1,n):r=setTimeout(()=>{o(!1,1e-7)},1e3)}n===1&&!Qe(l,e.getBoundingClientRect())&&o(),S=!1}try{n=new IntersectionObserver(C,{...x,root:i.ownerDocument})}catch{n=new IntersectionObserver(C,x)}n.observe(e)}return o(!0),a}function et(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=Oe(e),u=i||a?[...l?X(l):[],...t?X(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n,{passive:!0}),a&&e.addEventListener(`resize`,n)});let d=l&&s?$e(l,n):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?Q(e):null;c&&g();function g(){let t=Q(e);h&&!Qe(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var tt=ue,nt=de,rt=ie,it=pe,at=se,ot=re,st=fe,ct=(e,t,n)=>{let r=new Map,i={platform:Ze,...n},a={...i.platform,_c:r};return ne(e,t,{...i,platform:a})},lt=e(n(),1),ut=typeof document<`u`?l.useLayoutEffect:function(){};function dt(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!dt(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!dt(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function ft(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function pt(e,t){let n=ft(e);return Math.round(t*n)/n}function mt(e){let t=l.useRef(e);return ut(()=>{t.current=e}),t}function ht(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:u}=e,[d,f]=l.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[p,m]=l.useState(r);dt(p,r)||m(r);let[h,g]=l.useState(null),[_,v]=l.useState(null),y=l.useCallback(e=>{e!==C.current&&(C.current=e,g(e))},[]),b=l.useCallback(e=>{e!==w.current&&(w.current=e,v(e))},[]),x=a||h,S=o||_,C=l.useRef(null),w=l.useRef(null),T=l.useRef(d),E=c!=null,D=mt(c),O=mt(i),k=mt(u),A=l.useCallback(()=>{if(!C.current||!w.current)return;let e={placement:t,strategy:n,middleware:p};O.current&&(e.platform=O.current),ct(C.current,w.current,e).then(e=>{let t={...e,isPositioned:k.current!==!1};j.current&&!dt(T.current,t)&&(T.current=t,lt.flushSync(()=>{f(t)}))})},[p,t,n,O,k]);ut(()=>{u===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,f(e=>({...e,isPositioned:!1})))},[u]);let j=l.useRef(!1);ut(()=>(j.current=!0,()=>{j.current=!1}),[]),ut(()=>{if(x&&(C.current=x),S&&(w.current=S),x&&S){if(D.current)return D.current(x,S,A);A()}},[x,S,A,D,E]);let M=l.useMemo(()=>({reference:C,floating:w,setReference:y,setFloating:b}),[y,b]),N=l.useMemo(()=>({reference:x,floating:S}),[x,S]),P=l.useMemo(()=>{let e={position:n,left:0,top:0};if(!N.floating)return e;let t=pt(N.floating,d.x),r=pt(N.floating,d.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...ft(N.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,N.floating,d.x,d.y]);return l.useMemo(()=>({...d,update:A,refs:M,elements:N,floatingStyles:P}),[d,A,M,N,P])}var gt=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:ot({element:r.current,padding:i}).fn(n):r?ot({element:r,padding:i}).fn(n):{}}}},_t=(e,t)=>{let n=tt(e);return{name:n.name,fn:n.fn,options:[e,t]}},vt=(e,t)=>{let n=nt(e);return{name:n.name,fn:n.fn,options:[e,t]}},yt=(e,t)=>({fn:st(e).fn,options:[e,t]}),bt=(e,t)=>{let n=rt(e);return{name:n.name,fn:n.fn,options:[e,t]}},xt=(e,t)=>{let n=it(e);return{name:n.name,fn:n.fn,options:[e,t]}},St=(e,t)=>{let n=at(e);return{name:n.name,fn:n.fn,options:[e,t]}},Ct=(e,t)=>{let n=gt(e);return{name:n.name,fn:n.fn,options:[e,t]}},$=r(),wt=`Arrow`,Tt=l.forwardRef((e,t)=>{let{children:n,width:r=10,height:i=5,...a}=e;return(0,$.jsx)(s.svg,{...a,ref:t,width:r,height:i,viewBox:`0 0 30 10`,preserveAspectRatio:`none`,children:e.asChild?n:(0,$.jsx)(`polygon`,{points:`0,0 30,0 15,10`})})});Tt.displayName=wt;var Et=Tt;function Dt(e){let[t,n]=l.useState(void 0);return c(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}else n(void 0)},[e]),t}var Ot=`Popper`,[kt,At]=a(Ot),[jt,Mt]=kt(Ot),Nt=e=>{let{__scopePopper:t,children:n}=e,[r,i]=l.useState(null);return(0,$.jsx)(jt,{scope:t,anchor:r,onAnchorChange:i,children:n})};Nt.displayName=Ot;var Pt=`PopperAnchor`,Ft=l.forwardRef((e,t)=>{let{__scopePopper:n,virtualRef:r,...a}=e,o=Mt(Pt,n),c=l.useRef(null),u=i(t,c),d=l.useRef(null);return l.useEffect(()=>{let e=d.current;d.current=r?.current||c.current,e!==d.current&&o.onAnchorChange(d.current)}),r?null:(0,$.jsx)(s.div,{...a,ref:u})});Ft.displayName=Pt;var It=`PopperContent`,[Lt,Rt]=kt(It),zt=l.forwardRef((e,t)=>{let{__scopePopper:n,side:r=`bottom`,sideOffset:a=0,align:u=`center`,alignOffset:d=0,arrowPadding:f=0,avoidCollisions:p=!0,collisionBoundary:m=[],collisionPadding:h=0,sticky:g=`partial`,hideWhenDetached:_=!1,updatePositionStrategy:v=`optimized`,onPlaced:y,...b}=e,x=Mt(It,n),[S,C]=l.useState(null),w=i(t,e=>C(e)),[T,E]=l.useState(null),D=Dt(T),O=D?.width??0,k=D?.height??0,A=r+(u===`center`?``:`-`+u),j=typeof h==`number`?h:{top:0,right:0,bottom:0,left:0,...h},M=Array.isArray(m)?m:[m],N=M.length>0,P={padding:j,boundary:M.filter(Ut),altBoundary:N},{refs:ee,floatingStyles:te,placement:F,isPositioned:I,middlewareData:L}=ht({strategy:`fixed`,placement:A,whileElementsMounted:(...e)=>et(...e,{animationFrame:v===`always`}),elements:{reference:x.anchor},middleware:[_t({mainAxis:a+k,alignmentAxis:d}),p&&vt({mainAxis:!0,crossAxis:!1,limiter:g===`partial`?yt():void 0,...P}),p&&bt({...P}),xt({...P,apply:({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)}}),T&&Ct({element:T,padding:f}),Wt({arrowWidth:O,arrowHeight:k}),_&&St({strategy:`referenceHidden`,...P})]}),[R,ne]=Gt(F),re=o(y);c(()=>{I&&re?.()},[I,re]);let ie=L.arrow?.x,ae=L.arrow?.y,oe=L.arrow?.centerOffset!==0,[se,ce]=l.useState();return c(()=>{S&&ce(window.getComputedStyle(S).zIndex)},[S]),(0,$.jsx)(`div`,{ref:ee.setFloating,"data-radix-popper-content-wrapper":``,style:{...te,transform:I?te.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:se,"--radix-popper-transform-origin":[L.transformOrigin?.x,L.transformOrigin?.y].join(` `),...L.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,$.jsx)(Lt,{scope:n,placedSide:R,onArrowChange:E,arrowX:ie,arrowY:ae,shouldHideArrow:oe,children:(0,$.jsx)(s.div,{"data-side":R,"data-align":ne,...b,ref:w,style:{...b.style,animation:I?void 0:`none`}})})})});zt.displayName=It;var Bt=`PopperArrow`,Vt={top:`bottom`,right:`left`,bottom:`top`,left:`right`},Ht=l.forwardRef(function(e,t){let{__scopePopper:n,...r}=e,i=Rt(Bt,n),a=Vt[i.placedSide];return(0,$.jsx)(`span`,{ref:i.onArrowChange,style:{position:`absolute`,left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:``,right:`0 0`,bottom:`center 0`,left:`100% 0`}[i.placedSide],transform:{top:`translateY(100%)`,right:`translateY(50%) rotate(90deg) translateX(-50%)`,bottom:`rotate(180deg)`,left:`translateY(50%) rotate(-90deg) translateX(50%)`}[i.placedSide],visibility:i.shouldHideArrow?`hidden`:void 0},children:(0,$.jsx)(Et,{...r,ref:t,style:{...r.style,display:`block`}})})});Ht.displayName=Bt;function Ut(e){return e!==null}var Wt=e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=Gt(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}});function Gt(e){let[t,n=`center`]=e.split(`-`);return[t,n]}var Kt=Nt,qt=Ft,Jt=zt,Yt=Ht;export{At as a,Kt as i,Yt as n,Jt as r,qt as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t}from"./vendor-react-BOUWij0V.js";var n=e(t(),1);function r(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function i(...e){return t=>{let n=!1,i=e.map(e=>{let i=r(e,t);return!n&&typeof i==`function`&&(n=!0),i});if(n)return()=>{for(let t=0;t<i.length;t++){let n=i[t];typeof n==`function`?n():r(e[t],null)}}}}function a(...e){return n.useCallback(i(...e),e)}export{a as n,i as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,t as n}from"./vendor-react-BOUWij0V.js";import{t as r}from"./cn-BQ_8x0bT.js";import{t as i}from"./messages-DR9ODkb8.js";import{n as a}from"./locale-store-Ba72bFmP.js";import{$a as o,Ba as s,Do as c,Ha as l,Kn as u,Qo as d,Ua as f,Va as p,Wa as m,as as h,bs as g,eo as _,ks as v,kt as y,ot as b,qn as x,tl as S,to as C,wo as w,za as T,zo as E}from"./index-BOme955B.js";var D=e(t(),1),O=n();function k(){return{title:``,objective:``,description:``,attachments:[],checklist:[``],scopeBoundary:``,evidencePlan:[``],priority:`normal`,deadlineMode:`none`,deadline:``,maxTurns:`10`,agentId:``,judgeModelRef:``}}function A(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,String(n)),e)}function j(e){let t=e=>String(e).padStart(2,`0`);return[e.getFullYear(),`-`,t(e.getMonth()+1),`-`,t(e.getDate()),`T`,t(e.getHours()),`:`,t(e.getMinutes())].join(``)}function M(e){let t=new Date;return t.setDate(t.getDate()+e),t.setHours(23,59,0,0),j(t)}function N(){let e=new Date,t=e.getDay(),n=t<=5?5-t:7-t+5;return e.setDate(e.getDate()+n),e.setHours(23,59,0,0),j(e)}function P(e){if(e===`today`)return M(0);if(e===`tomorrow`)return M(1);if(e===`friday`)return N();if(e===`custom`){let e=new Date;return e.setHours(e.getHours()+1,0,0,0),j(e)}return``}function F(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 I({open:e,t,chat:n,busy:j,options:M,onClose:N,onCreate:I,onDraftContract:L}){let R=i(a(e=>e.language)).agentsSettings,[z,B]=(0,D.useState)(()=>k()),[V,H]=(0,D.useState)(!1),[U,W]=(0,D.useState)(null),[G,K]=(0,D.useState)(!1),q=b({chat:n});(0,D.useEffect)(()=>{e||(B(k()),H(!1),W(null),K(!1),q.clearAttachments())},[q.clearAttachments,e]),(0,D.useEffect)(()=>{!e||!M.defaultAgentId||B(e=>e.agentId?e:{...e,agentId:M.defaultAgentId})},[e,M.defaultAgentId]);let J=e=>B(t=>({...t,...e})),Y=M.agents.length?M.agents:[{id:M.defaultAgentId||`main`,workspace:``,profileDir:``,typedModels:{defaultRole:`deep`,preset:[],effective:[]},extends:[],isDefault:!0,skills:{preset:[]},tools:{presetDenied:[],entryDisable:[],effectiveDisable:[]}}],X=Y.find(e=>e.id===z.agentId)??Y.find(e=>e.id===M.defaultAgentId)??Y[0],Z=X?u(X,R):``,Q=z.agentId||X?.id||`main`,$=[...X?.typedModels.effective??[]].sort((e,t)=>e.id===`judge`?-1:t.id===`judge`?1:e.id.localeCompare(t.id)),ee=M.models.filter((e,t,n)=>n.findIndex(t=>t.id===e.id)===t),te=e=>{J({deadlineMode:e,deadline:P(e)})},ne=(e,t)=>{B(n=>({...n,checklist:n.checklist.map((n,r)=>r===e?t:n)}))},re=e=>{B(t=>({...t,checklist:t.checklist.filter((t,n)=>n!==e)}))},ie=(e,t)=>{B(n=>({...n,evidencePlan:n.evidencePlan.map((n,r)=>r===e?t:n)}))},ae=e=>{B(t=>({...t,evidencePlan:t.evidencePlan.filter((t,n)=>n!==e)}))},oe=async()=>{W(null),K(!0);try{J(L?await L({...z,attachments:q.wireAttachmentsPayload()}):{objective:z.objective||z.title,scopeBoundary:z.scopeBoundary,evidencePlan:F(z.evidencePlan).length?z.evidencePlan:[...t.createDialog.defaultEvidencePlan],checklist:z.checklist})}catch(e){W(e instanceof Error?e.message:t.createDialog.draftFailed)}finally{K(!1)}},se=async()=>{if(W(null),!z.title.trim()){W(t.createDialog.titleRequired);return}try{await I({...z,attachments:q.wireAttachmentsPayload(),checklist:F(z.checklist)}),N()}catch(e){W(e instanceof Error?e.message:t.errors.create)}};return(0,O.jsx)(f,{open:e,onOpenChange:e=>!e&&N(),children:(0,O.jsxs)(l,{children:[(0,O.jsx)(p,{className:`xopc-dialog-overlay fixed inset-0 z-65 bg-scrim backdrop-blur-[1px]`}),(0,O.jsxs)(T,{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:[(0,O.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-5 py-4`,children:[(0,O.jsxs)(`div`,{className:`min-w-0`,children:[(0,O.jsx)(m,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.createDialog.title}),(0,O.jsx)(s,{className:`mt-1 truncate text-sm text-fg-muted`,children:t.createDialog.description})]}),(0,O.jsx)(w,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":t.closeDetails,onClick:N,children:(0,O.jsx)(c,{className:`size-5`,"aria-hidden":!0})})]}),(0,O.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:(0,O.jsxs)(`div`,{className:`grid gap-4`,children:[(0,O.jsxs)(`label`,{className:`grid gap-1.5`,children:[(0,O.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.goalTitle}),(0,O.jsx)(`input`,{value:z.title,onChange:e=>J({title:e.target.value}),placeholder:t.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})]}),(0,O.jsxs)(`label`,{className:`grid gap-1.5`,children:[(0,O.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,O.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.goalDescription}),(0,O.jsxs)(w,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg text-xs`,onClick:()=>q.fileInputRef.current?.click(),children:[(0,O.jsx)(v,{className:`size-3.5`,"aria-hidden":!0}),t.createDialog.addAttachment]})]}),(0,O.jsx)(`textarea`,{value:z.description,onChange:e=>J({description:e.target.value}),placeholder:t.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`}),(0,O.jsx)(`input`,{ref:q.fileInputRef,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{let t=Array.from(e.currentTarget.files??[]);e.currentTarget.value=``,q.processFiles(t)}}),(0,O.jsx)(y,{attachments:q.attachments,topPadded:!1,onRemove:q.removeAttachment})]}),(0,O.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base/60 p-4`,children:[(0,O.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,O.jsxs)(`div`,{children:[(0,O.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.createDialog.criteriaTitle}),(0,O.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.createDialog.criteriaHint}),(0,O.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:M.checklistDecomposePolicy===`supplement_existing`?t.createDialog.checklistPolicySupplementExisting:t.createDialog.checklistPolicyEmptyOnly})]}),(0,O.jsxs)(w,{type:`button`,variant:`secondary`,className:`h-8 rounded-lg text-xs`,onClick:()=>void oe(),disabled:G||!z.title.trim()&&!z.description.trim(),children:[(0,O.jsx)(d,{className:`size-3.5`,"aria-hidden":!0}),G?t.createDialog.drafting:t.createDialog.aiDraft]})]}),(0,O.jsxs)(`div`,{className:`mt-3 grid gap-2`,children:[z.checklist.map((e,n)=>(0,O.jsxs)(`div`,{className:`flex gap-2`,children:[(0,O.jsx)(`input`,{value:e,onChange:e=>ne(n,e.target.value),placeholder:A(t.createDialog.criteriaPlaceholder,{index:n+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,O.jsx)(w,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 rounded-lg p-0`,"aria-label":t.createDialog.removeCriteria,onClick:()=>re(n),children:(0,O.jsx)(E,{className:`size-4`,"aria-hidden":!0})})]},n)),(0,O.jsxs)(w,{type:`button`,variant:`ghost`,className:`h-8 justify-start rounded-lg text-xs`,onClick:()=>J({checklist:[...z.checklist,``]}),children:[(0,O.jsx)(g,{className:`size-3.5`,"aria-hidden":!0}),t.createDialog.addCriteria]})]})]}),(0,O.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base/60 p-4`,children:[(0,O.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.createDialog.contractTitle}),(0,O.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.createDialog.contractHint}),(0,O.jsxs)(`label`,{className:`mt-3 grid gap-1.5`,children:[(0,O.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.objective}),(0,O.jsx)(`textarea`,{value:z.objective,onChange:e=>J({objective:e.target.value}),placeholder:t.createDialog.objectivePlaceholder,rows:2,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`})]}),(0,O.jsxs)(`label`,{className:`mt-3 grid gap-1.5`,children:[(0,O.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.scopeBoundary}),(0,O.jsx)(`textarea`,{value:z.scopeBoundary,onChange:e=>J({scopeBoundary:e.target.value}),placeholder:t.createDialog.scopeBoundaryPlaceholder,rows:2,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`})]}),(0,O.jsxs)(`div`,{className:`mt-3 grid gap-1.5`,children:[(0,O.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.evidencePlan}),(0,O.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.createDialog.evidencePlanHint}),z.evidencePlan.map((e,n)=>(0,O.jsxs)(`div`,{className:`flex gap-2`,children:[(0,O.jsx)(`input`,{value:e,onChange:e=>ie(n,e.target.value),placeholder:A(t.createDialog.evidencePlanPlaceholder,{index:n+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,O.jsx)(w,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 rounded-lg p-0`,"aria-label":t.createDialog.removeEvidence,onClick:()=>ae(n),children:(0,O.jsx)(E,{className:`size-4`,"aria-hidden":!0})})]},n)),(0,O.jsxs)(w,{type:`button`,variant:`ghost`,className:`h-8 justify-start rounded-lg text-xs`,onClick:()=>J({evidencePlan:[...z.evidencePlan,``]}),children:[(0,O.jsx)(g,{className:`size-3.5`,"aria-hidden":!0}),t.createDialog.addEvidence]})]})]}),(0,O.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base/60`,children:[(0,O.jsxs)(`button`,{type:`button`,className:`flex w-full items-center justify-between gap-3 px-4 py-3 text-left`,onClick:()=>H(e=>!e),children:[(0,O.jsxs)(`span`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,O.jsx)(h,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),t.createDialog.advanced]}),(0,O.jsx)(S,{className:r(`size-4 text-fg-muted transition-transform`,V&&`rotate-180`),"aria-hidden":!0})]}),V?(0,O.jsxs)(`div`,{className:`grid gap-3 border-t border-edge-subtle p-4 sm:grid-cols-2`,children:[(0,O.jsxs)(`label`,{className:`grid gap-1.5 sm:col-span-2`,children:[(0,O.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.agentId}),(0,O.jsx)(o,{value:Q,onChange:e=>J({agentId: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:Y.map(e=>(0,O.jsx)(C,{value:e.id,children:x(e,R)+(e.isDefault?` · ${t.createDialog.defaultAgent}`:` · ${e.id}`)},e.id))}),Z?(0,O.jsx)(`span`,{className:`line-clamp-2 text-xs text-fg-muted`,children:Z}):X?.model?.primary?(0,O.jsx)(`span`,{className:`truncate text-xs text-fg-muted`,children:A(t.createDialog.agentPrimaryModel,{model:X.model.primary})}):null]}),(0,O.jsxs)(`label`,{className:`grid gap-1.5`,children:[(0,O.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.priority}),(0,O.jsxs)(o,{value:z.priority,onChange:e=>J({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,O.jsx)(C,{value:`normal`,children:t.priorities.normal}),(0,O.jsx)(C,{value:`high`,children:t.priorities.high}),(0,O.jsx)(C,{value:`low`,children:t.priorities.low})]})]}),(0,O.jsxs)(`label`,{className:`grid gap-1.5`,children:[(0,O.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.deadline}),(0,O.jsxs)(o,{value:z.deadlineMode,onChange:e=>te(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,O.jsx)(C,{value:`none`,children:t.createDialog.deadlineNone}),(0,O.jsx)(C,{value:`today`,children:t.createDialog.deadlineToday}),(0,O.jsx)(C,{value:`tomorrow`,children:t.createDialog.deadlineTomorrow}),(0,O.jsx)(C,{value:`friday`,children:t.createDialog.deadlineFriday}),(0,O.jsx)(C,{value:`custom`,children:t.createDialog.deadlineCustom})]})]}),z.deadlineMode===`none`?null:(0,O.jsxs)(`label`,{className:`grid gap-1.5`,children:[(0,O.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.deadlineAt}),(0,O.jsx)(`input`,{type:`datetime-local`,value:z.deadline,onChange:e=>J({deadline:e.target.value,deadlineMode:`custom`}),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,O.jsxs)(`label`,{className:`grid gap-1.5`,children:[(0,O.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.maxTurns}),(0,O.jsx)(`input`,{type:`number`,min:1,max:500,value:z.maxTurns,onChange:e=>J({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,O.jsxs)(`label`,{className:`grid gap-1.5 sm:col-span-2`,children:[(0,O.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.createDialog.judgeModel}),(0,O.jsxs)(o,{value:z.judgeModelRef,onChange:e=>J({judgeModelRef: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,O.jsx)(C,{value:``,children:t.createDialog.judgeModelPlaceholder}),$.length?(0,O.jsx)(_,{label:t.createDialog.agentModelRoles,children:$.map(e=>(0,O.jsxs)(C,{value:e.model,children:[e.id===`judge`?t.createDialog.judgeRole:e.id,` · `,e.model]},`${e.id}:${e.model}`))}):null,(0,O.jsx)(_,{label:t.createDialog.configuredModels,children:ee.map(e=>(0,O.jsxs)(C,{value:e.id,children:[e.name,` · `,e.id]},e.id))})]})]})]}):null]}),U?(0,O.jsx)(`p`,{className:`rounded-lg border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:U}):null]})}),(0,O.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,O.jsx)(w,{type:`button`,variant:`ghost`,className:`rounded-lg`,onClick:N,children:t.createDialog.cancel}),(0,O.jsxs)(w,{type:`button`,variant:`primary`,className:`rounded-lg`,disabled:j||!z.title.trim(),onClick:()=>void se(),children:[(0,O.jsx)(g,{className:`size-4`,"aria-hidden":!0}),t.createDialog.create]})]})]})]})})}export{F as n,I as t};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-DR9ODkb8.js";import{n as o,o as s}from"./fetch-6HXXdO77.js";import{n as c}from"./locale-store-Ba72bFmP.js";import{$a as l,Cc as u,Dc as d,El as f,Ga as p,Ho as m,Jc as h,Lc as g,Tl as _,Uc as v,Wc as y,Xc as b,Yc as x,Ys as S,_ as C,_t as w,bl as T,bs as E,h as ee,ha as D,hc as te,hl as ne,ls as O,ms as re,mt as ie,pt as ae,sl as oe,st as se,to as k,vl as ce,wc as le,wl as ue,wo as A,xl as de,yt as fe,zo as pe}from"./index-BOme955B.js";import{t as me}from"./automation-suggestion-card-DyGBB2WH.js";var j=n(),M=e(t(),1),N=r();function he(e){return e.split(`
|
|
2
|
-
`).map(e=>e.trim()).filter(Boolean)}function ge(){let e=(0,j.c)(7),t,n,r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,N.jsx)(D,{className:`h-5 w-20 rounded-full`}),(0,N.jsx)(D,{className:`h-4 w-28`}),(0,N.jsx)(D,{className:`h-4 w-24`})]}),n=(0,N.jsx)(D,{className:`mt-4 h-4 w-full max-w-3xl`}),r=(0,N.jsx)(D,{className:`mt-2 h-4 w-2/3 max-w-2xl`}),e[0]=t,e[1]=n,e[2]=r):(t=e[0],n=e[1],r=e[2]);let i;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,N.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[t,n,r,(0,N.jsxs)(`div`,{className:`mt-4 grid gap-3 md:grid-cols-3`,children:[(0,N.jsx)(D,{className:`h-16 rounded-md`}),(0,N.jsx)(D,{className:`h-16 rounded-md`}),(0,N.jsx)(D,{className:`h-16 rounded-md`})]})]}),e[3]=i):i=e[3];let a;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,N.jsx)(D,{className:`h-4 w-32`}),e[4]=a):a=e[4];let o;e[5]===Symbol.for(`react.memo_cache_sentinel`)?(o=(0,N.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[a,(0,N.jsx)(`div`,{className:`mt-4 grid gap-3`,children:Array.from({length:5}).map(P)})]}),e[5]=o):o=e[5];let s;return e[6]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,N.jsxs)(`div`,{className:`grid gap-4`,"aria-hidden":`true`,children:[i,(0,N.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-[minmax(0,1fr)_22rem]`,children:[o,(0,N.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[(0,N.jsx)(D,{className:`h-4 w-28`}),(0,N.jsx)(D,{className:`mt-4 h-24 rounded-md`}),(0,N.jsx)(D,{className:`mt-3 h-24 rounded-md`})]})]})]}),e[6]=s):s=e[6],s}function P(e,t){return(0,N.jsx)(D,{className:`h-14 rounded-md`},t)}var F=`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`,_e=[`message`,`link`,`file`,`diff`,`command`,`test`,`artifact`];function ve(e){return e===`command`||e===`test`?m:e===`diff`?g:e===`file`||e===`artifact`?u:e===`link`?d:O}function ye(e){return e.data&&typeof e.data==`object`&&!Array.isArray(e.data)?e.data:{}}function be(e,t){let n=e[t];return typeof n==`string`&&n.trim()?n:void 0}function xe(e,t){let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0}function Se(e){let t=(0,j.c)(57),{item:n,language:r,t:i}=e,a;t[0]===n.kind?a=t[1]:(a=ve(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=ye(n),a=be(e,`command`),g=xe(e,`exitCode`),_=be(e,`path`)||n.uri,v=xe(e,`outputBytes`);s=e.fuzzyMatchUsed===!0,f=`rounded-md bg-surface-muted/40 px-2.5 py-2`;let y;t[15]===o?y=t[16]:(y=(0,N.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,N.jsx)(`p`,{className:`break-words font-medium text-fg`,children:n.title}),t[17]=n.title,t[18]=b);let x=_?(0,N.jsx)(`p`,{className:`mt-1 break-all text-xs text-fg-muted`,children:_}):null,S;t[19]!==b||t[20]!==x?(S=(0,N.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,N.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=je(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,N.jsx)(`span`,{className:`rounded-full bg-surface-hover 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,N.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,N.jsx)(`pre`,{className:`mt-2 overflow-x-auto rounded-md bg-surface-panel px-2 py-1.5 text-xs text-fg`,children:(0,N.jsx)(`code`,{children:a})}):null,t[33]!==n.kind||t[34]!==n.summary?(h=n.summary?n.kind===`diff`?(0,N.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,N.jsx)(`code`,{children:n.summary})}):(0,N.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=R(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,N.jsx)(`time`,{children:E}),t[40]=E,t[41]=l),u=g==null?null:(0,N.jsx)(`span`,{children:I(i.exitCode,{code:g})}),d=v==null?null:(0,N.jsx)(`span`,{children:I(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,N.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,N.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,N.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 Ce(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 we(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 Te(e){return e===`workflow_run`?te:e===`goal_run`?oe:e===`queue`?h:e===`evidence`?u:T}function I(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,String(n)),e)}function L(e){return e===`zh`?`zh-CN`:`en-US`}function R(e,t,n){return e?new Intl.DateTimeFormat(L(t),{dateStyle:`medium`,timeStyle:`short`}).format(new Date(e)):n.notSet}function Ee(e,t,n){return e?new Intl.DateTimeFormat(L(t),{dateStyle:`medium`}).format(new Date(e)):n.noDeadline}function De(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 Oe(e){return e===`completed`?`✓`:e===`impossible`?`!`:`○`}function ke(e){return e===`all`||e===`queue`||e===`goal_run`||e===`workflow_run`||e===`event`||e===`evidence`}function z(e,t){return e?t.statuses[e]??e:``}function Ae(e,t){return t.priorities[e]??e}function je(e,t){return t.evidenceKinds[e]??e}function Me(e){let t=e?.trim();return!t||!t.startsWith(`/projects/`)||t.startsWith(`//`)||t.includes(`://`)?`/goals`:t}async function B(e){return(await o(s(`/api/goals/${encodeURIComponent(e)}`))).goal}async function Ne(e){return(await o(s(`/api/goals/${encodeURIComponent(e)}/runs?limit=100`))).runs}async function Pe(e){return(await o(s(`/api/goals/${encodeURIComponent(e)}/evidence?limit=100`))).evidence}async function Fe(e){return(await o(s(`/api/goals/${encodeURIComponent(e)}/activity?limit=120`))).activities}async function Ie(e){return(await o(s(`/api/goals/${encodeURIComponent(e)}/workflow-suggestions`))).suggestions}function Le(){let{goalId:e=``}=_(),t=ue(),n=c(e=>e.language),r=a(n).goalDetailPage,u=a(n).automations.suggestions,m=p(e=>e.setPageHeader),g=p(e=>e.clearPageHeader),[O,oe]=f(),[j,P]=(0,M.useState)(null),[ve,xe]=(0,M.useState)([]),[L,Le]=(0,M.useState)([]),[V,Re]=(0,M.useState)([]),[ze,Be]=(0,M.useState)([]),[H,Ve]=(0,M.useState)([]),[He,Ue]=(0,M.useState)([]),[We,Ge]=(0,M.useState)(``),[Ke,qe]=(0,M.useState)(`message`),[Je,Ye]=(0,M.useState)(``),[Xe,Ze]=(0,M.useState)(``),[Qe,$e]=(0,M.useState)(``),[et,tt]=(0,M.useState)(``),[nt,rt]=(0,M.useState)(``),[it,at]=(0,M.useState)(``),[ot,st]=(0,M.useState)(`normal`),[ct,lt]=(0,M.useState)(``),[ut,dt]=(0,M.useState)(`10`),[ft,pt]=(0,M.useState)(``),[mt,ht]=(0,M.useState)(``),[gt,_t]=(0,M.useState)(``),[vt,yt]=(0,M.useState)(``),[bt,xt]=(0,M.useState)(``),[St,Ct]=(0,M.useState)(``),[wt,Tt]=(0,M.useState)(``),[U,Et]=(0,M.useState)(``),[Dt,Ot]=(0,M.useState)(``),[W,kt]=(0,M.useState)(!0),[G,K]=(0,M.useState)(null),[At,q]=(0,M.useState)(null),jt=(0,M.useMemo)(()=>Me(O.get(`returnTo`)),[O]),J=(0,M.useCallback)(async()=>{if(e){kt(!0),q(null);try{let[t,n,r]=await Promise.all([B(e),Ne(e),Pe(e)]);P(t),xe(n);let[i,a]=await Promise.all([ae(e,50),Fe(e)]);Re(i),Ue(a),Be(await Ie(e)),Ve(r)}catch(e){q(e instanceof Error?e.message:r.errors.load)}finally{kt(!1)}}},[e,r.errors.load]);(0,M.useEffect)(()=>{J()},[J]),(0,M.useEffect)(()=>{let e=!1;return ie().then(t=>{e||(Le(t),Et(e=>e||t[0]?.id||``))}).catch(t=>{e||q(t instanceof Error?t.message:r.errors.loadWorkflows)}),()=>{e=!0}},[r.errors.loadWorkflows]),(0,M.useEffect)(()=>{j&&(rt(j.title),at(j.description??``),st(j.priority),lt(j.deadlineAt?new Date(j.deadlineAt).toISOString().slice(0,10):``),dt(String(j.maxTurns)),pt(j.judgeModelRef??``),ht(j.nextAction??``),_t(j.blockedReason??``),yt(j.contract?.objective??j.title),xt(j.contract?.scopeBoundary??``),Ct(j.checklist.map(e=>e.text).join(`
|
|
3
|
-
`)),Tt(j.contract?.evidencePlan.join(`
|
|
4
|
-
`)??``),tt(e=>j.evidenceRequirements.some(t=>t.id===e)?e:j.evidenceRequirements[0]?.id??``),Ot(e=>e||j.nextAction||j.title))},[j?.id,j?.updatedAt]);let Mt=async()=>{if(j){K(`continue`);try{let e=await o(s(`/api/goals/${encodeURIComponent(j.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)}}},Nt=async e=>{if(e.preventDefault(),!j)return;let t=nt.trim();if(t){K(`details:save`),q(null);try{let e=Number.parseInt(ut,10);P((await o(s(`/api/goals/${encodeURIComponent(j.id)}`),{method:`PATCH`,body:JSON.stringify({title:t,description:it.trim()||void 0,priority:ot,deadlineAt:ct?new Date(`${ct}T23:59:59`).getTime():void 0,maxTurns:Number.isFinite(e)?e:j.maxTurns,judgeModelRef:ft.trim()||void 0,nextAction:mt.trim()||void 0,blockedReason:gt.trim()||void 0})})).goal),await Y(j.id)}catch(e){q(e instanceof Error?e.message:r.errors.save)}finally{K(null)}}},Pt=async e=>{if(e.preventDefault(),!j)return;let t=vt.trim();if(t){K(`contract:save`),q(null);try{P((await o(s(`/api/goals/${encodeURIComponent(j.id)}/contract`),{method:`PUT`,body:JSON.stringify({objective:t,scopeBoundary:bt.trim()||void 0,criteria:he(St),evidencePlan:he(wt)})})).goal),await Y(j.id)}catch(e){q(e instanceof Error?e.message:r.errors.save)}finally{K(null)}}},Ft=async e=>{if(j){K(e);try{await o(s(`/api/goals/${encodeURIComponent(j.id)}/${e}`),{method:`POST`,body:JSON.stringify({})}),await J()}catch(e){q(e instanceof Error?e.message:r.errors.action)}finally{K(null)}}},It=async()=>{if(!(!j||!U)){K(`workflow:run`),q(null);try{let e=await fe({goalId:j.id,definitionId:U,goal:Dt.trim()||j.nextAction||j.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{Ue(await Fe(e))}catch{}},Lt=async e=>{try{let[t,n,r]=await Promise.all([ae(e,50),Fe(e),Ie(e)]);Re(t),Ue(n),Be(r)}catch{}},Rt=async e=>{if(j){K(`workflow:${e.id}:cancel`),q(null);try{await se(e.id,{ownerAgentId:j.agentId}),await Lt(j.id)}catch(e){q(e instanceof Error?e.message:r.errors.cancelWorkflow)}finally{K(null)}}},zt=async e=>{if(j){K(`workflow:${e.id}:retry`),q(null);try{let n=await w(e.id,{ownerAgentId:j.agentId});await Lt(j.id),t(`/chat/${encodeURIComponent(n.sessionKey)}`)}catch(e){q(e instanceof Error?e.message:r.errors.retryWorkflow)}finally{K(null)}}},Bt=async e=>{if(e.preventDefault(),!j)return;let t=We.trim();if(t){K(`checklist:add`),q(null);try{P((await o(s(`/api/goals/${encodeURIComponent(j.id)}/checklist`),{method:`POST`,body:JSON.stringify({text:t})})).goal),Ge(``),await Y(j.id)}catch(e){q(e instanceof Error?e.message:r.errors.addChecklist)}finally{K(null)}}},Vt=async(e,t)=>{if(j){K(`checklist:${e}:${t}`),q(null);try{P((await o(s(`/api/goals/${encodeURIComponent(j.id)}/checklist/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify({status:t})})).goal),await Y(j.id)}catch(e){q(e instanceof Error?e.message:r.errors.updateChecklist)}finally{K(null)}}},Ht=async e=>{if(j){K(`checklist:${e}:delete`),q(null);try{P((await o(s(`/api/goals/${encodeURIComponent(j.id)}/checklist/${encodeURIComponent(e)}`),{method:`DELETE`})).goal),await Y(j.id)}catch(e){q(e instanceof Error?e.message:r.errors.deleteChecklist)}finally{K(null)}}},Ut=async e=>{if(e.preventDefault(),!j)return;let t=Je.trim();if(t){K(`evidence:add`),q(null);try{let e=await o(s(`/api/goals/${encodeURIComponent(j.id)}/evidence`),{method:`POST`,body:JSON.stringify({kind:Ke,title:t,summary:Xe.trim()||void 0,uri:Qe.trim()||void 0,requirementId:et||void 0})});Ve(t=>[e.evidence,...t]),P(await B(j.id)),Ye(``),Ze(``),$e(``),await Y(j.id)}catch(e){q(e instanceof Error?e.message:r.errors.addEvidence)}finally{K(null)}}},Wt=async e=>{if(j){K(`requirement:${e}:review`),q(null);try{await o(s(`/api/goals/${encodeURIComponent(j.id)}/evidence-requirements/${encodeURIComponent(e)}/review`),{method:`POST`,body:JSON.stringify({modelRef:j.judgeModelRef})}),P(await B(j.id)),await Y(j.id)}catch(e){q(e instanceof Error?e.message:r.errors.addEvidence)}finally{K(null)}}},Gt=async e=>{if(j){K(`requirement:${e}:approve`),q(null);try{await o(s(`/api/goals/${encodeURIComponent(j.id)}/evidence-requirements/${encodeURIComponent(e)}/approve`),{method:`POST`,body:JSON.stringify({})}),P(await B(j.id)),await Y(j.id)}catch(e){q(e instanceof Error?e.message:r.errors.addEvidence)}finally{K(null)}}},Kt=async e=>{if(!j||!e.summary)return;q(null);let t=a(n).automations,r=await o(s(`/api/goals/${encodeURIComponent(j.id)}/evidence`),{method:`POST`,body:JSON.stringify({kind:`message`,title:C(t.feedback.insightEvidenceTitle,{name:e.automationName}),summary:e.summary,data:{source:`automation`,automationRunId:e.id,automationId:e.automationId,automationName:e.automationName,sessionKey:e.sessionKey,workflowRunId:e.workflowRunId}})});Ve(e=>[r.evidence,...e]),await Y(j.id)},X=j?.checklist.filter(e=>e.status===`completed`||e.status===`impossible`).length??0,Z=j?.checklist.length??0,qt=(0,M.useMemo)(()=>{let e=new Set;for(let t of H){let n=be(ye(t),`automationRunId`);n&&e.add(n)}return e},[H]),Q=V.filter(e=>e.status===`failed`||e.status===`timeout`||e.status===`cancelled`),$=ve[0],Jt=ke(O.get(`timeline`))?O.get(`timeline`):`all`,Yt=Jt===`all`?He:He.filter(e=>e.kind===Jt),Xt=V.filter(e=>e.status===`queued`||e.status===`running`),Zt=G!=null||j?.status===`done`||j?.status===`archived`,Qt=(0,M.useMemo)(()=>j?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(A,{type:`button`,variant:`primary`,className:`h-9 gap-2 rounded-lg px-2.5 md:px-3`,"aria-label":De(j.status,r),disabled:Zt,onClick:()=>void Mt(),children:[(0,N.jsx)(h,{className:`size-4`,"aria-hidden":!0}),(0,N.jsx)(`span`,{className:`hidden md:inline`,children:De(j.status,r)})]}),j.activeSessionKey?(0,N.jsxs)(A,{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(j.activeSessionKey)}`),children:[(0,N.jsx)(d,{className:`size-4`,"aria-hidden":!0}),(0,N.jsx)(`span`,{className:`hidden md:inline`,children:r.chat})]}):null,(0,N.jsxs)(A,{type:`button`,variant:`secondary`,className:`h-9 gap-2 rounded-lg px-2.5 md:px-3`,"aria-label":r.pause,disabled:G!=null||j.status!==`active`,onClick:()=>void Ft(`pause`),children:[(0,N.jsx)(x,{className:`size-4`,"aria-hidden":!0}),(0,N.jsx)(`span`,{className:`hidden md:inline`,children:r.pause})]}),(0,N.jsxs)(A,{type:`button`,variant:`ghost`,className:`h-9 gap-2 rounded-lg px-2.5 md:px-3`,"aria-label":r.archive,disabled:G!=null||j.status===`archived`,onClick:()=>{window.confirm(r.archiveConfirm)&&Ft(`archive`)},children:[(0,N.jsx)(ce,{className:`size-4`,"aria-hidden":!0}),(0,N.jsx)(`span`,{className:`hidden md:inline`,children:r.archive})]})]}):null,[G,j,t,Zt,r]);(0,M.useLayoutEffect)(()=>(m({startExtra:(0,N.jsx)(de,{to:jt,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,N.jsx)(ne,{className:`size-4`,"aria-hidden":!0})}),main:(0,N.jsxs)(`div`,{className:`min-w-0`,children:[W?(0,N.jsx)(D,{className:`h-5 w-48 max-w-full`}):(0,N.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:j?.title??r.notFound}),j?(0,N.jsxs)(`p`,{className:`truncate text-xs text-fg-muted`,children:[z(j.status,r),` · `,I(r.agent,{agentId:j.agentId}),` · `,I(r.turns,{used:j.turnsUsed,max:j.maxTurns}),Z?` · ${I(r.checklistProgress,{done:X,total:Z})}`:``]}):null]}),end:Qt}),()=>g()),[jt,g,X,j,Qt,W,m,r,Z]);let $t=e=>{let t=new URLSearchParams(O);e===`all`?t.delete(`timeline`):t.set(`timeline`,e),oe(t,{replace:!0})};return(0,N.jsx)(`main`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto bg-surface-panel`,children:(0,N.jsxs)(`div`,{className:`flex w-full flex-1 flex-col gap-4 px-3 py-5 sm:px-5 xl:px-6`,children:[At?(0,N.jsx)(`p`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:At}):null,!W&&!j?(0,N.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.notFound}):null,W?(0,N.jsx)(ge,{}):j?(0,N.jsxs)(N.Fragment,{children:[(0,N.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,N.jsx)(`span`,{className:i(`rounded-full border px-2 py-0.5 text-xs`,Ce(j.status)),children:z(j.status,r)}),(0,N.jsx)(`span`,{className:`text-xs text-fg-muted`,children:I(r.prioritySummary,{priority:Ae(j.priority,r)})}),(0,N.jsx)(`span`,{className:`text-xs text-fg-muted`,children:j.deadlineAt?Ee(j.deadlineAt,n,r):r.noDeadline})]}),j.description?(0,N.jsx)(`p`,{className:`mt-3 whitespace-pre-wrap break-words text-sm text-fg-muted`,children:j.description}):null,j.contract?(0,N.jsxs)(`div`,{className:`mt-3 rounded-md border border-edge-subtle bg-surface-muted/40 px-3 py-3`,children:[(0,N.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:r.goalContract}),(0,N.jsx)(`p`,{className:`mt-1 break-words text-sm text-fg`,children:j.contract.objective}),j.contract.scopeBoundary?(0,N.jsxs)(`div`,{className:`mt-3`,children:[(0,N.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:r.scopeBoundary}),(0,N.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap break-words text-sm text-fg-muted`,children:j.contract.scopeBoundary})]}):null,j.contract.evidencePlan.length?(0,N.jsxs)(`div`,{className:`mt-3`,children:[(0,N.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:r.completionEvidence}),(0,N.jsx)(`ul`,{className:`mt-1 grid gap-1 text-sm text-fg-muted`,children:j.contract.evidencePlan.map(e=>(0,N.jsxs)(`li`,{children:[`• `,e]},e))})]}):null,(0,N.jsxs)(`details`,{className:`mt-3 rounded-md bg-surface-base/70 px-3 py-2`,children:[(0,N.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:r.editContract}),(0,N.jsxs)(`form`,{className:`mt-3 grid gap-3`,onSubmit:Pt,children:[(0,N.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.contractObjective,(0,N.jsx)(`textarea`,{value:vt,onChange:e=>yt(e.target.value),name:`contractObjective`,autoComplete:`off`,className:i(F,`resize-y`),rows:2,placeholder:r.contractObjectivePlaceholder})]}),(0,N.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.scopeBoundary,(0,N.jsx)(`textarea`,{value:bt,onChange:e=>xt(e.target.value),name:`contractScopeBoundary`,autoComplete:`off`,className:i(F,`resize-y`),rows:2,placeholder:r.scopeBoundaryPlaceholder})]}),(0,N.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.acceptanceCriteria,(0,N.jsx)(`textarea`,{value:St,onChange:e=>Ct(e.target.value),name:`contractCriteria`,autoComplete:`off`,className:i(F,`resize-y`),rows:3,placeholder:r.contractLinesHint})]}),(0,N.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.completionEvidence,(0,N.jsx)(`textarea`,{value:wt,onChange:e=>Tt(e.target.value),name:`contractEvidencePlan`,autoComplete:`off`,className:i(F,`resize-y`),rows:3,placeholder:r.contractLinesHint})]}),(0,N.jsx)(A,{type:`submit`,variant:`secondary`,className:`h-9 w-fit`,disabled:G!=null||!vt.trim(),children:r.saveContract})]})]})]}):null,(0,N.jsxs)(`div`,{className:`mt-3 rounded-md bg-surface-muted/40 px-3 py-2`,children:[(0,N.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:j.blockedReason?r.currentBlocker:r.nextAction}),(0,N.jsx)(`p`,{className:i(`mt-1 break-words text-sm`,j.blockedReason?`text-amber-700 dark:text-amber-300`:`text-fg`),children:j.blockedReason||j.nextAction||r.noNextAction})]})]}),(0,N.jsxs)(`section`,{className:`grid gap-4 xl:grid-cols-[minmax(0,1fr)_22rem]`,children:[(0,N.jsxs)(`div`,{className:`grid min-w-0 gap-4`,children:[(0,N.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[(0,N.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,N.jsx)(S,{className:`size-4 text-accent`,"aria-hidden":!0}),r.acceptance]}),(0,N.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r.acceptanceHint})]}),(0,N.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[X,`/`,Z]})]}),$?(0,N.jsxs)(`div`,{className:`mt-3 rounded-md bg-surface-muted/40 px-3 py-2`,children:[(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 text-xs text-fg-muted`,children:[(0,N.jsx)(`span`,{children:I(r.latestJudgement,{status:z($.verdict??$.status,r)})}),(0,N.jsx)(`time`,{children:R($.finishedAt??$.startedAt,n,r)})]}),$.reason?(0,N.jsx)(`p`,{className:`mt-1 break-words text-sm text-fg`,children:$.reason}):null,$.nextAction?(0,N.jsx)(`p`,{className:`mt-1 break-words text-xs text-fg-muted`,children:I(r.latestNext,{next:$.nextAction})}):null]}):null,(0,N.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,N.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,N.jsx)(S,{className:`size-4 text-accent`,"aria-hidden":!0}),r.checklist]}),(0,N.jsxs)(`span`,{className:`text-xs text-fg-muted`,children:[X,`/`,Z]})]}),(0,N.jsxs)(`form`,{className:`mb-3 flex flex-col gap-2 sm:flex-row`,onSubmit:Bt,children:[(0,N.jsx)(`input`,{value:We,onChange:e=>Ge(e.target.value),name:`checklistText`,"aria-label":r.addAcceptancePlaceholder,autoComplete:`off`,placeholder:r.addAcceptancePlaceholder,className:i(F,`flex-1`)}),(0,N.jsxs)(A,{type:`submit`,variant:`secondary`,className:`h-9 gap-2`,disabled:G!=null||!We.trim(),children:[(0,N.jsx)(E,{className:`size-4`,"aria-hidden":!0}),r.add]})]}),j.checklist.length?(0,N.jsx)(`ul`,{className:`space-y-2 text-sm`,children:j.checklist.map(e=>(0,N.jsx)(`li`,{className:`rounded-md bg-surface-muted/40 px-2.5 py-2`,children:(0,N.jsxs)(`div`,{className:`flex flex-wrap items-start gap-2`,children:[(0,N.jsx)(`span`,{className:`mt-1 w-5 shrink-0 text-center text-fg-muted`,children:Oe(e.status)}),(0,N.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,N.jsx)(`p`,{className:`break-words text-fg`,children:e.text}),e.evidenceSummary?(0,N.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.evidenceSummary}):null]}),(0,N.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,N.jsx)(A,{type:`button`,variant:`ghost`,className:`size-8 p-0`,title:r.markPending,"aria-label":r.markPending,disabled:G!=null||e.status===`pending`,onClick:()=>void Vt(e.id,`pending`),children:(0,N.jsx)(v,{className:`size-4`,"aria-hidden":!0})}),(0,N.jsx)(A,{type:`button`,variant:`ghost`,className:`size-8 p-0`,title:r.markCompleted,"aria-label":r.markCompleted,disabled:G!=null||e.status===`completed`,onClick:()=>void Vt(e.id,`completed`),children:(0,N.jsx)(b,{className:`size-4`,"aria-hidden":!0})}),(0,N.jsx)(A,{type:`button`,variant:`ghost`,className:`size-8 p-0`,title:r.markImpossible,"aria-label":r.markImpossible,disabled:G!=null||e.status===`impossible`,onClick:()=>void Vt(e.id,`impossible`),children:(0,N.jsx)(y,{className:`size-4`,"aria-hidden":!0})}),(0,N.jsx)(A,{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 Ht(e.id),children:(0,N.jsx)(pe,{className:`size-4`,"aria-hidden":!0})})]})]})},e.id))}):(0,N.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.noChecklist}),(0,N.jsxs)(`div`,{className:`mt-4 border-t border-edge pt-4`,children:[(0,N.jsxs)(`h3`,{className:`mb-3 flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,N.jsx)(le,{className:`size-4 text-accent`,"aria-hidden":!0}),r.evidence]}),j.evidenceRequirements.length?(0,N.jsxs)(`div`,{className:`mb-4 grid gap-2 rounded-md border border-edge-subtle bg-surface-muted/40 p-3`,children:[(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,N.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:r.evidenceRequirements}),(0,N.jsx)(`span`,{className:`text-xs text-fg-muted`,children:I(r.evidenceRequirementProgress,{approved:j.evidenceRequirements.filter(e=>e.status===`approved`).length,total:j.evidenceRequirements.length})})]}),j.evidenceRequirements.map(e=>(0,N.jsx)(`div`,{className:`rounded-md bg-surface-base px-2.5 py-2`,children:(0,N.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,N.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,N.jsx)(`p`,{className:`break-words text-sm text-fg`,children:e.text}),(0,N.jsxs)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[I(r.linkedEvidenceCount,{count:e.evidenceIds.length}),` · `,r.evidenceRequirementStatuses[e.status]]}),e.reviewReason?(0,N.jsx)(`p`,{className:`mt-1 break-words text-xs text-fg-muted`,children:e.reviewReason}):null]}),(0,N.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-1.5`,children:[(0,N.jsx)(A,{type:`button`,variant:`ghost`,className:`h-7 text-xs`,disabled:G!=null||e.evidenceIds.length===0,onClick:()=>void Wt(e.id),children:r.reviewEvidence}),(0,N.jsx)(A,{type:`button`,variant:`secondary`,className:`h-7 text-xs`,disabled:G!=null||e.evidenceIds.length===0||e.status===`approved`,onClick:()=>void Gt(e.id),children:r.approveEvidence})]})]})},e.id))]}):null,(0,N.jsxs)(`form`,{className:`mb-3 grid gap-2`,onSubmit:Ut,children:[(0,N.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-[9rem_minmax(0,1fr)]`,children:[(0,N.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.kind,(0,N.jsx)(l,{value:Ke,onChange:e=>qe(e.target.value),className:F,name:`evidenceKind`,children:_e.map(e=>(0,N.jsx)(k,{value:e,children:je(e,r)},e))})]}),(0,N.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.title,(0,N.jsx)(`input`,{value:Je,onChange:e=>Ye(e.target.value),name:`evidenceTitle`,autoComplete:`off`,placeholder:r.evidenceTitlePlaceholder,className:F})]})]}),j.evidenceRequirements.length?(0,N.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.provesRequirement,(0,N.jsx)(l,{value:et,onChange:e=>tt(e.target.value),name:`evidenceRequirement`,className:F,children:j.evidenceRequirements.map(e=>(0,N.jsx)(k,{value:e.id,children:e.text},e.id))})]}):null,(0,N.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.uriOrPath,(0,N.jsx)(`input`,{value:Qe,onChange:e=>$e(e.target.value),name:`evidenceUri`,autoComplete:`off`,placeholder:r.uriOrPathPlaceholder,className:F})]}),(0,N.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.summary,(0,N.jsx)(`textarea`,{value:Xe,onChange:e=>Ze(e.target.value),name:`evidenceSummary`,autoComplete:`off`,placeholder:r.summaryPlaceholder,rows:3,className:i(F,`resize-y`)})]}),(0,N.jsxs)(A,{type:`submit`,variant:`secondary`,className:`h-9 w-fit gap-2`,disabled:G!=null||!Je.trim(),children:[(0,N.jsx)(E,{className:`size-4`,"aria-hidden":!0}),r.addEvidence]})]}),H.length?(0,N.jsx)(`ul`,{className:`space-y-2 text-sm`,children:H.slice(0,6).map(e=>(0,N.jsx)(Se,{item:e,language:n,t:r},e.id))}):(0,N.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.noEvidence})]})]}),(0,N.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[(0,N.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,N.jsx)(T,{className:`size-4 text-accent`,"aria-hidden":!0}),r.timeline]}),(0,N.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r.timelineHint})]}),(0,N.jsxs)(A,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5`,onClick:()=>void J(),children:[(0,N.jsx)(re,{className:`size-3.5`,"aria-hidden":!0}),r.refresh]})]}),(0,N.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[`all`,`goal_run`,`workflow_run`,`evidence`,`queue`,`event`].map(e=>(0,N.jsx)(`button`,{type:`button`,className:i(`rounded-md border px-2.5 py-1 text-xs font-medium`,Jt===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:()=>$t(e),children:r.timelineFilters[e]},e))}),Yt.length?(0,N.jsx)(`ul`,{className:`mt-3 space-y-2 text-sm`,children:Yt.map(e=>(0,N.jsx)(`li`,{className:`rounded-md bg-surface-muted/50 px-2.5 py-2`,children:(0,N.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,N.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-2`,children:[(0,N.jsx)(Te(e.kind),{className:`mt-0.5 size-4 shrink-0 text-accent-fg`,"aria-hidden":!0}),(0,N.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-xs text-fg-muted`,children:[(0,N.jsx)(`span`,{children:r.timelineFilters[e.kind]}),e.status?(0,N.jsx)(`span`,{children:z(e.status,r)}):null]}),(0,N.jsx)(`p`,{className:`mt-1 break-words font-medium text-fg`,children:e.title}),e.summary?(0,N.jsx)(`p`,{className:`mt-1 line-clamp-3 break-words text-xs text-fg-muted`,children:e.summary}):null]})]}),(0,N.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-1 text-xs text-fg-muted`,children:[(0,N.jsx)(`time`,{children:R(e.createdAt,n,r)}),e.link?.type===`chat`?(0,N.jsxs)(A,{type:`button`,variant:`ghost`,className:`h-7 gap-1.5`,onClick:()=>t(`/chat/${encodeURIComponent(e.link.value)}`),children:[(0,N.jsx)(d,{className:`size-3.5`,"aria-hidden":!0}),r.chat]}):null,e.link?.type===`workflow_run`?(0,N.jsxs)(A,{type:`button`,variant:`ghost`,className:`h-7 gap-1.5`,onClick:()=>t(`/workflows?run=${encodeURIComponent(e.link.value)}`),children:[(0,N.jsx)(d,{className:`size-3.5`,"aria-hidden":!0}),r.run]}):null]})]})},e.id))}):(0,N.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:r.noTimeline})]})]}),(0,N.jsxs)(`aside`,{className:`grid h-fit gap-4`,children:[(0,N.jsx)(ee,{eventType:`goal.status_changed`,source:`goals`,payloadKey:`goalId`,payloadValue:j.id,onSaveInsight:Kt,isInsightSaved:e=>qt.has(e.id)}),(0,N.jsx)(ee,{eventType:`goal.created`,source:`goals`,payloadKey:`goalId`,payloadValue:j.id,onSaveInsight:Kt,isInsightSaved:e=>qt.has(e.id)}),j.status===`blocked`||j.blockedReason?(0,N.jsx)(me,{title:u.goalBlockedTitle,description:u.goalBlockedDescription,prompt:I(u.goalBlockedPrompt,{title:j.title}),coverage:{eventType:`goal.status_changed`,source:`goals`,eventPayload:{goalId:j.id,status:`blocked`}}}):null,(0,N.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[(0,N.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:r.goalSettings}),(0,N.jsxs)(`dl`,{className:`mt-3 grid gap-2 text-sm`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,N.jsx)(`dt`,{className:`text-fg-muted`,children:r.deadline}),(0,N.jsx)(`dd`,{className:`text-right text-fg`,children:Ee(j.deadlineAt,n,r)})]}),(0,N.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,N.jsx)(`dt`,{className:`text-fg-muted`,children:r.judgeModel}),(0,N.jsx)(`dd`,{className:`min-w-0 truncate text-right text-fg`,children:j.judgeModelRef||r.default})]}),(0,N.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,N.jsx)(`dt`,{className:`text-fg-muted`,children:r.created}),(0,N.jsx)(`dd`,{className:`text-right text-fg`,children:Ee(j.createdAt,n,r)})]}),(0,N.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,N.jsx)(`dt`,{className:`text-fg-muted`,children:r.updated}),(0,N.jsx)(`dd`,{className:`text-right text-fg`,children:R(j.updatedAt,n,r)})]})]}),(0,N.jsxs)(`details`,{className:`mt-4 rounded-md bg-surface-muted/40 px-3 py-2`,children:[(0,N.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:r.editDetails}),(0,N.jsxs)(`form`,{className:`mt-3 grid gap-3`,onSubmit:Nt,children:[(0,N.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.title,(0,N.jsx)(`input`,{value:nt,onChange:e=>rt(e.target.value),name:`goalTitle`,autoComplete:`off`,className:F,placeholder:`${r.title}…`})]}),(0,N.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.description,(0,N.jsx)(`textarea`,{value:it,onChange:e=>at(e.target.value),name:`goalDescription`,autoComplete:`off`,className:i(F,`resize-y`),rows:3,placeholder:`${r.description}…`})]}),(0,N.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-3 xl:grid-cols-1`,children:[(0,N.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.priority,(0,N.jsxs)(l,{value:ot,onChange:e=>st(e.target.value),name:`goalPriority`,className:F,children:[(0,N.jsx)(k,{value:`low`,children:r.priorities.low}),(0,N.jsx)(k,{value:`normal`,children:r.priorities.normal}),(0,N.jsx)(k,{value:`high`,children:r.priorities.high})]})]}),(0,N.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.deadline,(0,N.jsx)(`input`,{value:ct,onChange:e=>lt(e.target.value),name:`goalDeadline`,className:F,type:`date`})]}),(0,N.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.maxTurns,(0,N.jsx)(`input`,{value:ut,onChange:e=>dt(e.target.value),name:`goalMaxTurns`,className:F,type:`number`,min:1,max:500,inputMode:`numeric`,placeholder:`${r.maxTurns}…`})]})]}),(0,N.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.judgeModel,(0,N.jsx)(`input`,{value:ft,onChange:e=>pt(e.target.value),name:`goalJudgeModel`,autoComplete:`off`,className:F,placeholder:`${r.judgeModel}…`})]}),(0,N.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.nextAction,(0,N.jsx)(`textarea`,{value:mt,onChange:e=>ht(e.target.value),name:`goalNextAction`,autoComplete:`off`,className:i(F,`resize-y`),rows:2,placeholder:`${r.nextAction}…`})]}),(0,N.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.blockedReason,(0,N.jsx)(`textarea`,{value:gt,onChange:e=>_t(e.target.value),name:`goalBlockedReason`,autoComplete:`off`,className:i(F,`resize-y`),rows:2,placeholder:`${r.blockedReason}…`})]}),(0,N.jsx)(A,{type:`submit`,variant:`secondary`,className:`h-9 w-fit`,disabled:G!=null||!nt.trim(),children:r.saveDetails})]})]})]}),(0,N.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-base p-4 shadow-surface`,children:[(0,N.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,N.jsxs)(`div`,{children:[(0,N.jsxs)(`h2`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,N.jsx)(te,{className:`size-4 text-accent`,"aria-hidden":!0}),r.workflow]}),(0,N.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r.workflowHint})]}),Xt.length?(0,N.jsx)(`span`,{className:`rounded-full border border-accent/40 bg-accent-soft px-2 py-0.5 text-xs text-accent-fg`,children:I(r.activeCount,{count:Xt.length})}):null]}),ze.length?(0,N.jsx)(`div`,{className:`mt-3 grid gap-2`,children:ze.slice(0,2).map(e=>(0,N.jsxs)(`button`,{type:`button`,className:i(`min-w-0 rounded-md bg-surface-muted/40 px-2.5 py-2 text-left hover:bg-accent-soft/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,U===e.definitionId&&`bg-accent-soft/60 ring-1 ring-accent/30`),onClick:()=>{Et(e.definitionId),Ot(j.nextAction||j.title)},children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,N.jsx)(`span`,{className:`truncate text-sm font-medium text-fg`,children:e.title}),(0,N.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e.score})]}),(0,N.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs text-fg-muted`,children:e.description})]},e.definitionId))}):null,(0,N.jsxs)(`div`,{className:`mt-3 grid gap-2`,children:[(0,N.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.definition,(0,N.jsxs)(l,{value:U,onChange:e=>Et(e.target.value),className:F,name:`workflowDefinition`,disabled:L.length===0,children:[L.length===0?(0,N.jsx)(k,{value:``,children:r.noWorkflows}):null,L.map(e=>(0,N.jsx)(k,{value:e.id,children:e.title||e.name},e.id))]})]}),(0,N.jsxs)(`label`,{className:`grid gap-1 text-xs font-medium text-fg-muted`,children:[r.workflowGoal,(0,N.jsx)(`input`,{value:Dt,onChange:e=>Ot(e.target.value),name:`workflowGoal`,autoComplete:`off`,className:F,placeholder:`${r.workflowGoal}…`})]}),(0,N.jsxs)(A,{type:`button`,variant:`secondary`,className:`h-9 w-fit gap-2`,disabled:G!=null||!U||j.status===`done`||j.status===`archived`,onClick:()=>void It(),children:[(0,N.jsx)(h,{className:`size-4`,"aria-hidden":!0}),r.runWorkflow]})]}),V.length?(0,N.jsxs)(`div`,{className:`mt-4 border-t border-edge pt-3`,children:[(0,N.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,N.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:r.recentWorkflowRuns}),(0,N.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:()=>$t(`workflow_run`),children:r.viewTimeline})]}),(0,N.jsx)(`ul`,{className:`grid gap-2`,children:V.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,N.jsxs)(`li`,{className:`rounded-md bg-surface-muted/40 px-2.5 py-2 text-sm`,children:[(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 text-xs text-fg-muted`,children:[(0,N.jsx)(`span`,{className:`min-w-0 truncate`,children:e.definitionId}),(0,N.jsx)(`span`,{className:i(`shrink-0 rounded-full border px-2 py-0.5`,we(e.status)),children:z(e.status,r)})]}),(0,N.jsx)(`p`,{className:`mt-1 truncate text-fg`,children:e.title}),(0,N.jsx)(`time`,{className:`mt-1 block text-xs text-fg-muted`,children:R(e.completedAtMs??e.startedAtMs??e.createdAtMs,n,r)}),(0,N.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-1`,children:[a?(0,N.jsxs)(A,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5`,onClick:()=>t(`/chat/${encodeURIComponent(a)}`),children:[(0,N.jsx)(d,{className:`size-3.5`,"aria-hidden":!0}),r.chat]}):null,o?(0,N.jsxs)(A,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5 text-destructive hover:text-destructive`,disabled:G!=null,onClick:()=>void Rt(e),children:[(0,N.jsx)(y,{className:`size-3.5`,"aria-hidden":!0}),r.cancel]}):null,s?(0,N.jsxs)(A,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5`,disabled:G!=null,onClick:()=>void zt(e),children:[(0,N.jsx)(re,{className:`size-3.5`,"aria-hidden":!0}),r.retry]}):null]})]},e.id)})})]}):null,Q.length?(0,N.jsxs)(`div`,{className:`mt-4 rounded-md border border-amber-500/30 bg-amber-500/10 px-3 py-2`,children:[(0,N.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,N.jsx)(`p`,{className:`text-sm font-medium text-amber-800 dark:text-amber-200`,children:r.recoveryNeeded}),(0,N.jsx)(`span`,{className:`text-xs text-amber-700 dark:text-amber-300`,children:I(r.failedCount,{count:Q.length})})]}),(0,N.jsx)(`ul`,{className:`mt-2 grid gap-2`,children:Q.slice(0,3).map(e=>(0,N.jsxs)(`li`,{className:`grid gap-2 text-sm`,children:[(0,N.jsxs)(`div`,{className:`min-w-0`,children:[(0,N.jsx)(`p`,{className:`truncate text-fg`,children:e.title}),(0,N.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[e.definitionId,` · `,z(e.status,r)]})]}),(0,N.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[(0,N.jsxs)(A,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5`,onClick:()=>t(`/workflows?run=${encodeURIComponent(e.id)}`),children:[(0,N.jsx)(d,{className:`size-3.5`,"aria-hidden":!0}),r.run]}),(0,N.jsxs)(A,{type:`button`,variant:`secondary`,className:`h-8 gap-1.5`,disabled:G!=null,onClick:()=>void zt(e),children:[(0,N.jsx)(re,{className:`size-3.5`,"aria-hidden":!0}),r.retry]})]})]},e.id))})]}):null]})]})]})]}):null]})})}export{Le as GoalDetailPage};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-DR9ODkb8.js";import{n as o,o as s}from"./fetch-6HXXdO77.js";import{n as c}from"./locale-store-Ba72bFmP.js";import{$s as l,Ba as u,Bc as d,Dc as f,Do as p,Ga as m,Ha as h,Jc as g,Oc as _,Ua as v,Va as y,Wa as b,Xc as x,Yc as S,Ys as C,_i as w,_n as T,bs as E,cs as D,er as O,fa as k,ha as A,ps as j,qs as M,vl as N,vo as P,wl as F,wo as I,xl as L,yl as R,za as z}from"./index-BOme955B.js";import{t as B}from"./goals-config-api--3Vzceq-.js";import{n as V,t as H}from"./goal-create-dialog-BOWSTGB-.js";var U=n(),W=e(t(),1),G=r(),K=[`active`,`paused`,`blocked`,`needs_input`,`done`,`archived`],ee=[`active`,`paused`,`attention`,`done`,`archived`],q=[`attention`,`running`,`active`,`paused`,`recentDone`],J=`application/x-xopc-goal-id`;function te(e){return e instanceof Element?!!e.closest(`a,button,input,select,textarea,[contenteditable="true"],[draggable="true"],[data-board-pan-skip="true"]`):!0}function ne(e){let t=e.checklist.length;return{done:e.checklist.filter(e=>e.status===`completed`||e.status===`impossible`).length,total:t}}function Y(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,String(n)),e)}function re(e,t){return new Intl.DateTimeFormat(t===`zh`?`zh-CN`:`en-US`,{dateStyle:`medium`,timeStyle:`short`}).format(new Date(e))}function ie(e,t){return t.statuses[e]??e}function ae(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 se(e){return e===`completed`?`✓`:e===`impossible`?`!`:`○`}function ce(e){return e.nextRunAt??e.finishedAt??e.startedAt??e.enqueuedAt}function X(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 le(e){let t=new Map;for(let n of e){let e=t.get(n.goalId);(!e||X(n)>X(e)||X(n)===X(e)&&ce(n)>ce(e))&&t.set(n.goalId,n)}return t}function ue(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 Z(e){return e===`running`||e===`queued`||e===`retry_waiting`}function de(e,t){return e.status===`archived`?null:e.status===`blocked`||e.status===`needs_input`||t?.status===`failed`?`attention`:t&&Z(t.status)?`running`:e.status===`active`?`active`:e.status===`paused`?`paused`:e.status===`done`?`recentDone`:null}function Q(e){return e===`high`?3:e===`normal`?2:1}function fe(e,t,n){let r=n.get(e.id),i=n.get(t.id),a=(r?X(r):0)-(i?X(i):0);if(a!==0)return-a;let o=Q(e.priority)-Q(t.priority);if(o!==0)return-o;let s=e.deadlineAt??1/0,c=t.deadlineAt??1/0;return s===c?t.updatedAt-e.updatedAt:s-c}function pe(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 me(){return(await o(s(`/api/goals?${new URLSearchParams({status:K.join(`,`),limit:`500`}).toString()}`))).goals}async function he(){return(await o(s(`/api/goals/queue`))).queue??[]}async function ge(e){return(await o(s(`/api/goals`),{method:`POST`,body:JSON.stringify({...e,source:`api`})})).goal}async function _e(e,t){let n=await o(s(`/api/goals/contract/draft`),{method:`POST`,body:JSON.stringify({title:e.title,context:e.description,criteria:e.checklist,judgeModelRef:e.judgeModelRef||void 0,uiLocale:t})});return{objective:n.contract.objective??e.objective,scopeBoundary:n.contract.scopeBoundary??e.scopeBoundary,evidencePlan:n.contract.evidencePlan??e.evidencePlan,checklist:n.contract.criteria??e.checklist}}async function ve(e,t){await o(s(`/api/goals/${encodeURIComponent(e)}/${t}`),{method:`POST`,body:JSON.stringify({})})}async function ye(e){return(await o(s(`/api/goals/${encodeURIComponent(e)}/continue`),{method:`POST`,body:JSON.stringify({})})).sessionKey}function be(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 xe(e){return e.status===`active`?[`pause`,`complete`,`archive`]:e.status===`paused`||e.status===`blocked`||e.status===`needs_input`||e.status===`done`?[`archive`]:[]}function Se(e,t){return t.actions[e]}function $(e){return e===`pause`?S:e===`archive`?N:e===`unarchive`?R:e===`reopen`?j:e===`complete`?x:g}function Ce(e,t){return ae(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 we(e){let t=(0,U.c)(107),{goal:n,queueItem:r,t:a,language:o,selected:s,dragging:c,onOpen:l,onDragStart:u,onDragEnd:d}=e,f,p,m,h,g,_,v,y,b,x,S,C,w,T,E,D,O;if(t[0]!==c||t[1]!==n||t[2]!==o||t[3]!==d||t[4]!==u||t[5]!==l||t[6]!==r||t[7]!==s||t[8]!==a){let e=ne(n),k=n.latestRun?.finishedAt??n.updatedAt;_=!0,t[26]!==n.id||t[27]!==u?(v=e=>u(n.id,e),t[26]=n.id,t[27]=u,t[28]=v):v=t[28],y=d;let A=s&&`ring-1 ring-accent/30`,j=c?`opacity-50`:`hover:bg-surface-hover`;t[29]!==A||t[30]!==j?(b=i(`group relative flex min-h-24 w-full min-w-0 max-w-full cursor-grab flex-col overflow-hidden rounded-lg bg-surface-panel px-3 py-3 shadow-surface transition-colors active:cursor-grabbing`,A,j),t[29]=A,t[30]=j,t[31]=b):b=t[31],S=`button`,t[32]!==n||t[33]!==l?(C=()=>l(n),t[32]=n,t[33]=l,t[34]=C):C=t[34],w=`${a.openDetails}: ${n.title}`,T=s?`true`:void 0,t[35]===Symbol.for(`react.memo_cache_sentinel`)?(E=i(`w-full text-left`,P.focusRingPanel),t[35]=E):E=t[35];let M;t[36]===n.title?M=t[37]:(M=(0,G.jsx)(`div`,{className:`line-clamp-2 text-sm font-medium leading-5 text-fg`,children:n.title}),t[36]=n.title,t[37]=M);let N;t[38]===n.agentId?N=t[39]:(N=(0,G.jsx)(`div`,{className:`mt-1 truncate text-[11px] text-fg-muted`,children:n.agentId}),t[38]=n.agentId,t[39]=N);let F;t[40]!==M||t[41]!==N?(F=(0,G.jsxs)(`div`,{className:`min-w-0`,children:[M,N]}),t[40]=M,t[41]=N,t[42]=F):F=t[42];let I;t[43]===n.status?I=t[44]:(I=i(`shrink-0 rounded-full px-2 py-0.5 text-[10px] font-semibold shadow-sm`,oe(n.status)),t[43]=n.status,t[44]=I);let L;t[45]!==n.status||t[46]!==a?(L=ie(n.status,a),t[45]=n.status,t[46]=a,t[47]=L):L=t[47];let R;t[48]!==I||t[49]!==L?(R=(0,G.jsx)(`span`,{className:I,children:L}),t[48]=I,t[49]=L,t[50]=R):R=t[50],t[51]!==F||t[52]!==R?(D=(0,G.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-2`,children:[F,R]}),t[51]=F,t[52]=R,t[53]=D):D=t[53];let z;t[54]!==o||t[55]!==k?(z=re(k,o),t[54]=o,t[55]=k,t[56]=z):z=t[56];let B;t[57]===z?B=t[58]:(B=(0,G.jsx)(`span`,{children:z}),t[57]=z,t[58]=B);let V;t[59]===Symbol.for(`react.memo_cache_sentinel`)?(V=(0,G.jsx)(`span`,{"aria-hidden":!0,children:`·`}),t[59]=V):V=t[59];let H;t[60]!==n.maxTurns||t[61]!==n.turnsUsed||t[62]!==a.turns?(H=Y(a.turns,{used:n.turnsUsed,max:n.maxTurns}),t[60]=n.maxTurns,t[61]=n.turnsUsed,t[62]=a.turns,t[63]=H):H=t[63];let U;t[64]===H?U=t[65]:(U=(0,G.jsx)(`span`,{children:H}),t[64]=H,t[65]=U);let W=e.total?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,G.jsx)(`span`,{children:Y(a.checklistProgress,{done:e.done,total:e.total})})]}):null;t[66]!==B||t[67]!==U||t[68]!==W?(O=(0,G.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1.5 text-[11px] text-fg-subtle`,children:[B,V,U,W]}),t[66]=B,t[67]=U,t[68]=W,t[69]=O):O=t[69],t[70]!==r||t[71]!==a?(p=r?(0,G.jsx)(`div`,{className:`mt-2.5`,children:(0,G.jsx)(`span`,{className:i(`rounded-full px-2 py-0.5 text-[11px] font-semibold`,ue(r.status)),children:ie(r.status,a)})}):null,t[70]=r,t[71]=a,t[72]=p):p=t[72],t[73]===n.blockedReason?m=t[74]:(m=n.blockedReason?(0,G.jsx)(`p`,{className:`mt-2 line-clamp-1 text-xs leading-5 text-amber-700 dark:text-amber-300`,children:n.blockedReason}):null,t[73]=n.blockedReason,t[74]=m),t[75]===n.nextAction?h=t[76]:(h=n.nextAction?(0,G.jsx)(`p`,{className:`mt-2 line-clamp-1 text-xs leading-5 text-fg-muted`,children:n.nextAction}):null,t[75]=n.nextAction,t[76]=h),t[77]!==n.blockedReason||t[78]!==n.latestRun||t[79]!==n.nextAction?(g=!n.blockedReason&&!n.nextAction&&n.latestRun?.reason?(0,G.jsx)(`p`,{className:`mt-2 line-clamp-1 text-xs leading-5 text-fg-muted`,children:n.latestRun.reason}):null,t[77]=n.blockedReason,t[78]=n.latestRun,t[79]=n.nextAction,t[80]=g):g=t[80],f=`mt-3 flex flex-wrap items-center gap-2 text-[11px] text-fg-subtle`,x=n.checklist.length?(0,G.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 font-medium text-fg-muted`,children:Y(a.checklistProgress,{done:e.done,total:e.total})}):null,t[0]=c,t[1]=n,t[2]=o,t[3]=d,t[4]=u,t[5]=l,t[6]=r,t[7]=s,t[8]=a,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]=b,t[18]=x,t[19]=S,t[20]=C,t[21]=w,t[22]=T,t[23]=E,t[24]=D,t[25]=O}else f=t[9],p=t[10],m=t[11],h=t[12],g=t[13],_=t[14],v=t[15],y=t[16],b=t[17],x=t[18],S=t[19],C=t[20],w=t[21],T=t[22],E=t[23],D=t[24],O=t[25];let k;t[81]!==s||t[82]!==a.openDetails?(k=s?(0,G.jsx)(`span`,{className:`font-medium text-accent-fg`,children:a.openDetails}):null,t[81]=s,t[82]=a.openDetails,t[83]=k):k=t[83];let A;t[84]!==f||t[85]!==k||t[86]!==x?(A=(0,G.jsxs)(`div`,{className:f,children:[x,k]}),t[84]=f,t[85]=k,t[86]=x,t[87]=A):A=t[87];let j;t[88]!==p||t[89]!==m||t[90]!==h||t[91]!==g||t[92]!==A||t[93]!==S||t[94]!==C||t[95]!==w||t[96]!==T||t[97]!==E||t[98]!==D||t[99]!==O?(j=(0,G.jsxs)(`button`,{type:S,onClick:C,"aria-label":w,"aria-current":T,className:E,children:[D,O,p,m,h,g,A]}),t[88]=p,t[89]=m,t[90]=h,t[91]=g,t[92]=A,t[93]=S,t[94]=C,t[95]=w,t[96]=T,t[97]=E,t[98]=D,t[99]=O,t[100]=j):j=t[100];let M;return t[101]!==_||t[102]!==v||t[103]!==y||t[104]!==b||t[105]!==j?(M=(0,G.jsx)(`article`,{draggable:_,onDragStart:v,onDragEnd:y,className:b,children:j}),t[101]=_,t[102]=v,t[103]=y,t[104]=b,t[105]=j,t[106]=M):M=t[106],M}function Te(e){let t=(0,U.c)(113),{goal:n,queueItem:r,t:a,language:o,busy:s,selected:c,onOpen:l,onAction:u}=e,d,p,m,h,g,_,v,y,b,x,S,C,w,T;if(t[0]!==n||t[1]!==o||t[2]!==l||t[3]!==r||t[4]!==c||t[5]!==a){let e=ne(n),s;t[20]===n?s=t[21]:(s=be(n),t[20]=n,t[21]=s),d=s;let u=n.blockedReason||n.nextAction||n.latestRun?.reason||a.noNextAction,f=n.latestRun?.finishedAt??n.updatedAt,E=c?`bg-surface-active ring-1 ring-accent/30`:`bg-surface-panel`;t[22]===E?_=t[23]:(_=i(`rounded-lg shadow-surface transition-colors hover:bg-surface-hover/40`,E),t[22]=E,t[23]=_),g=`flex flex-col gap-3 p-3.5 lg:flex-row lg:items-center`,x=`button`,t[24]===Symbol.for(`react.memo_cache_sentinel`)?(S=i(`min-w-0 flex-1 text-left`,P.focusRingPanel),t[24]=S):S=t[24],C=`${a.openDetails}: ${n.title}`,t[25]!==n||t[26]!==l?(w=()=>l(n),t[25]=n,t[26]=l,t[27]=w):w=t[27];let D;t[28]===n.status?D=t[29]:(D=i(`rounded-full px-2 py-0.5 text-[11px] font-semibold`,oe(n.status)),t[28]=n.status,t[29]=D);let O;t[30]!==n.status||t[31]!==a?(O=ie(n.status,a),t[30]=n.status,t[31]=a,t[32]=O):O=t[32];let k;t[33]!==D||t[34]!==O?(k=(0,G.jsx)(`span`,{className:D,children:O}),t[33]=D,t[34]=O,t[35]=k):k=t[35];let A;t[36]!==r||t[37]!==a?(A=r?(0,G.jsx)(`span`,{className:i(`rounded-full px-2 py-0.5 text-[11px] font-semibold`,ue(r.status)),children:ie(r.status,a)}):null,t[36]=r,t[37]=a,t[38]=A):A=t[38];let j=a.priorities[n.priority],M;t[39]!==a.prioritySummary||t[40]!==j?(M=Y(a.prioritySummary,{priority:j}),t[39]=a.prioritySummary,t[40]=j,t[41]=M):M=t[41];let N;t[42]===M?N=t[43]:(N=(0,G.jsx)(`span`,{className:`text-[11px] font-medium text-fg-muted`,children:M}),t[42]=M,t[43]=N);let F;t[44]===n.agentId?F=t[45]:(F=(0,G.jsx)(`span`,{className:`text-[11px] text-fg-subtle`,children:n.agentId}),t[44]=n.agentId,t[45]=F),t[46]!==k||t[47]!==A||t[48]!==N||t[49]!==F?(T=(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[k,A,N,F]}),t[46]=k,t[47]=A,t[48]=N,t[49]=F,t[50]=T):T=t[50],t[51]===n.title?m=t[52]:(m=(0,G.jsx)(`h3`,{className:`mt-2 line-clamp-2 text-sm font-semibold leading-5 text-fg`,children:n.title}),t[51]=n.title,t[52]=m);let I=n.blockedReason?`text-amber-700 dark:text-amber-300`:`text-fg-muted`,L;t[53]===I?L=t[54]:(L=i(`mt-1 line-clamp-2 text-sm leading-5`,I),t[53]=I,t[54]=L),t[55]!==u||t[56]!==L?(h=(0,G.jsx)(`p`,{className:L,children:u}),t[55]=u,t[56]=L,t[57]=h):h=t[57],p=`mt-2 flex flex-wrap items-center gap-x-2 gap-y-1 text-[11px] text-fg-subtle`;let R;t[58]!==o||t[59]!==f?(R=re(f,o),t[58]=o,t[59]=f,t[60]=R):R=t[60],t[61]===R?v=t[62]:(v=(0,G.jsx)(`span`,{children:R}),t[61]=R,t[62]=v);let z;t[63]!==n.maxTurns||t[64]!==n.turnsUsed||t[65]!==a.turns?(z=Y(a.turns,{used:n.turnsUsed,max:n.maxTurns}),t[63]=n.maxTurns,t[64]=n.turnsUsed,t[65]=a.turns,t[66]=z):z=t[66],t[67]===z?y=t[68]:(y=(0,G.jsx)(`span`,{children:z}),t[67]=z,t[68]=y),b=e.total?(0,G.jsx)(`span`,{children:Y(a.checklistProgress,{done:e.done,total:e.total})}):null,t[0]=n,t[1]=o,t[2]=l,t[3]=r,t[4]=c,t[5]=a,t[6]=d,t[7]=p,t[8]=m,t[9]=h,t[10]=g,t[11]=_,t[12]=v,t[13]=y,t[14]=b,t[15]=x,t[16]=S,t[17]=C,t[18]=w,t[19]=T}else d=t[6],p=t[7],m=t[8],h=t[9],g=t[10],_=t[11],v=t[12],y=t[13],b=t[14],x=t[15],S=t[16],C=t[17],w=t[18],T=t[19];let E;t[69]!==n.deadlineAt||t[70]!==o||t[71]!==a.deadlineSummary?(E=n.deadlineAt?(0,G.jsx)(`span`,{children:Y(a.deadlineSummary,{deadline:re(n.deadlineAt,o)})}):null,t[69]=n.deadlineAt,t[70]=o,t[71]=a.deadlineSummary,t[72]=E):E=t[72];let D;t[73]!==r||t[74]!==a.sourceSummary||t[75]!==a.sources?(D=r?(0,G.jsx)(`span`,{children:Y(a.sourceSummary,{source:a.sources[r.source]})}):null,t[73]=r,t[74]=a.sourceSummary,t[75]=a.sources,t[76]=D):D=t[76];let O;t[77]!==p||t[78]!==E||t[79]!==D||t[80]!==v||t[81]!==y||t[82]!==b?(O=(0,G.jsxs)(`div`,{className:p,children:[v,y,b,E,D]}),t[77]=p,t[78]=E,t[79]=D,t[80]=v,t[81]=y,t[82]=b,t[83]=O):O=t[83];let k;t[84]!==m||t[85]!==h||t[86]!==O||t[87]!==x||t[88]!==S||t[89]!==C||t[90]!==w||t[91]!==T?(k=(0,G.jsxs)(`button`,{type:x,className:S,"aria-label":C,onClick:w,children:[T,m,h,O]}),t[84]=m,t[85]=h,t[86]=O,t[87]=x,t[88]=S,t[89]=C,t[90]=w,t[91]=T,t[92]=k):k=t[92];let A;t[93]!==s||t[94]!==n.id||t[95]!==u||t[96]!==d||t[97]!==a?(A=d?(0,G.jsx)(Ee,{goalId:n.id,action:d,t:a,busy:s,variant:d===`continue`?`primary`:`secondary`,onAction:u}):null,t[93]=s,t[94]=n.id,t[95]=u,t[96]=d,t[97]=a,t[98]=A):A=t[98];let j=`/goals/${encodeURIComponent(n.id)}`,M;t[99]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,G.jsx)(f,{className:`size-4`,"aria-hidden":!0}),t[99]=M):M=t[99];let N;t[100]!==a.fullDetails||t[101]!==j?(N=(0,G.jsx)(I,{asChild:!0,type:`button`,variant:`ghost`,className:`h-9 rounded-lg px-3`,children:(0,G.jsxs)(L,{to:j,children:[M,a.fullDetails]})}),t[100]=a.fullDetails,t[101]=j,t[102]=N):N=t[102];let F;t[103]!==A||t[104]!==N?(F=(0,G.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 lg:justify-end`,children:[A,N]}),t[103]=A,t[104]=N,t[105]=F):F=t[105];let R;t[106]!==g||t[107]!==k||t[108]!==F?(R=(0,G.jsxs)(`div`,{className:g,children:[k,F]}),t[106]=g,t[107]=k,t[108]=F,t[109]=R):R=t[109];let z;return t[110]!==_||t[111]!==R?(z=(0,G.jsx)(`article`,{className:_,children:R}),t[110]=_,t[111]=R,t[112]=z):z=t[112],z}function Ee(e){let t=(0,U.c)(17),{goalId:n,action:r,t:i,busy:a,variant:o,onAction:s}=e,c;t[0]===r?c=t[1]:(c=$(r),t[0]=r,t[1]=c);let l=c,u=a!=null,d;t[2]!==r||t[3]!==n||t[4]!==s?(d=()=>s(n,r),t[2]=r,t[3]=n,t[4]=s,t[5]=d):d=t[5];let f;t[6]===l?f=t[7]:(f=(0,G.jsx)(l,{className:`size-4`,"aria-hidden":!0}),t[6]=l,t[7]=f);let p;t[8]!==r||t[9]!==i?(p=Se(r,i),t[8]=r,t[9]=i,t[10]=p):p=t[10];let m;return t[11]!==u||t[12]!==d||t[13]!==f||t[14]!==p||t[15]!==o?(m=(0,G.jsxs)(I,{type:`button`,variant:o,className:`h-9 rounded-lg px-3 text-sm`,disabled:u,onClick:d,children:[f,p]}),t[11]=u,t[12]=d,t[13]=f,t[14]=p,t[15]=o,t[16]=m):m=t[16],m}function De(){let e=(0,U.c)(5),t,n,r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(A,{className:`h-5 w-16 rounded-full`}),(0,G.jsx)(A,{className:`h-5 w-20 rounded-full`}),(0,G.jsx)(A,{className:`h-3 w-24`})]}),n=(0,G.jsx)(A,{className:`mt-3 h-4 w-2/3 max-w-full`}),r=(0,G.jsx)(A,{className:`mt-2 h-4 w-full max-w-xl`}),e[0]=t,e[1]=n,e[2]=r):(t=e[0],n=e[1],r=e[2]);let i;e[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[t,n,r,(0,G.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,G.jsx)(A,{className:`h-3 w-24`}),(0,G.jsx)(A,{className:`h-3 w-28`}),(0,G.jsx)(A,{className:`h-3 w-20`})]})]}),e[3]=i):i=e[3];let a;return e[4]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,G.jsx)(`article`,{className:`rounded-lg bg-surface-panel p-3.5 shadow-surface`,"aria-hidden":`true`,children:(0,G.jsxs)(`div`,{className:`flex flex-col gap-3 lg:flex-row lg:items-center`,children:[i,(0,G.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,G.jsx)(A,{className:`h-9 w-24 rounded-lg`}),(0,G.jsx)(A,{className:`h-9 w-24 rounded-lg`})]})]})}),e[4]=a):a=e[4],a}function Oe(){let e=(0,U.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(A,{className:`h-4 w-4/5`}),(0,G.jsx)(A,{className:`mt-2 h-3 w-24`})]}),(0,G.jsx)(A,{className:`h-5 w-16 rounded-full`})]}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,G.jsxs)(`article`,{className:`min-h-24 rounded-lg bg-surface-panel px-3 py-3 shadow-surface`,"aria-hidden":`true`,children:[t,(0,G.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[(0,G.jsx)(A,{className:`h-3 w-20`}),(0,G.jsx)(A,{className:`h-3 w-24`})]}),(0,G.jsx)(A,{className:`mt-3 h-4 w-full`}),(0,G.jsx)(A,{className:`mt-2 h-4 w-2/3`}),(0,G.jsx)(A,{className:`mt-4 h-5 w-28 rounded-full`})]}),e[1]=n):n=e[1],n}function ke(e){let t=(0,U.c)(135),{goal:n,queueItem:r,t:a,language:o,busy:s,onClose:c,onAction:l}=e;if(!n)return null;let d,m,g,_,x,S,w,T,E,D,O,k,A,j;if(t[0]!==s||t[1]!==n||t[2]!==l||t[3]!==c||t[4]!==a){let e=ne(n),r;t[19]===n?r=t[20]:(r=be(n),t[19]=n,t[20]=r);let o=r,f=xe(n);g=v,x=!0,t[21]===c?S=t[22]:(S=e=>!e&&c(),t[21]=c,t[22]=S),m=h,t[23]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,G.jsx)(y,{className:`xopc-dialog-overlay fixed inset-0 z-65 bg-scrim backdrop-blur-[1px]`}),t[23]=j):j=t[23],d=z,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 C;t[24]===n.title?C=t[25]:(C=(0,G.jsx)(b,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:n.title}),t[24]=n.title,t[25]=C);let M;t[26]!==n.status||t[27]!==a?(M=ie(n.status,a),t[26]=n.status,t[27]=a,t[28]=M):M=t[28];let N;t[29]!==n.maxTurns||t[30]!==n.turnsUsed||t[31]!==a.turns?(N=Y(a.turns,{used:n.turnsUsed,max:n.maxTurns}),t[29]=n.maxTurns,t[30]=n.turnsUsed,t[31]=a.turns,t[32]=N):N=t[32];let P;t[33]!==M||t[34]!==N?(P=(0,G.jsxs)(u,{className:`mt-1 truncate text-xs text-fg-muted`,children:[M,` · `,N]}),t[33]=M,t[34]=N,t[35]=P):P=t[35];let F;t[36]!==C||t[37]!==P?(F=(0,G.jsxs)(`div`,{className:`min-w-0`,children:[C,P]}),t[36]=C,t[37]=P,t[38]=F):F=t[38];let L;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,G.jsx)(p,{className:`size-5`,"aria-hidden":!0}),t[39]=L):L=t[39];let R;t[40]!==c||t[41]!==a.closeDetails?(R=(0,G.jsx)(I,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":a.closeDetails,onClick:c,children:L}),t[40]=c,t[41]=a.closeDetails,t[42]=R):R=t[42],t[43]!==F||t[44]!==R?(A=(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-b border-edge px-5 py-4`,children:[F,R]}),t[43]=F,t[44]=R,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 B;t[46]===n.status?B=t[47]:(B=i(`rounded-full px-2 py-0.5 text-xs font-medium`,oe(n.status)),t[46]=n.status,t[47]=B);let V;t[48]!==n.status||t[49]!==a?(V=ie(n.status,a),t[48]=n.status,t[49]=a,t[50]=V):V=t[50];let H;t[51]!==B||t[52]!==V?(H=(0,G.jsx)(`span`,{className:B,children:V}),t[51]=B,t[52]=V,t[53]=H):H=t[53];let U;t[54]===n.agentId?U=t[55]:(U=(0,G.jsx)(`span`,{className:`text-xs text-fg-muted`,children:n.agentId}),t[54]=n.agentId,t[55]=U);let W=Y(a.checklistProgress,{done:e.done,total:e.total}),K;t[56]===W?K=t[57]:(K=(0,G.jsx)(`span`,{className:`text-xs text-fg-muted`,children:W}),t[56]=W,t[57]=K);let ee;t[58]!==H||t[59]!==U||t[60]!==K?(ee=(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[H,U,K]}),t[58]=H,t[59]=U,t[60]=K,t[61]=ee):ee=t[61];let q;t[62]===n.description?q=t[63]:(q=n.description?(0,G.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]=q),t[64]!==ee||t[65]!==q?(D=(0,G.jsxs)(`div`,{className:`min-w-0`,children:[ee,q]}),t[64]=ee,t[65]=q,t[66]=D):D=t[66],_=`flex flex-wrap gap-2`,t[67]!==s||t[68]!==n.id||t[69]!==l||t[70]!==o||t[71]!==a?(w=o?(0,G.jsx)(Ee,{goalId:n.id,action:o,t:a,busy:s,variant:o===`continue`?`primary`:`secondary`,onAction:l}):null,t[67]=s,t[68]=n.id,t[69]=l,t[70]=o,t[71]=a,t[72]=w):w=t[72];let J;t[73]!==s||t[74]!==n.id||t[75]!==l||t[76]!==a?(J=e=>(0,G.jsx)(Ee,{goalId:n.id,action:e,t:a,busy:s,variant:e===`archive`?`ghost`:`secondary`,onAction:l},e),t[73]=s,t[74]=n.id,t[75]=l,t[76]=a,t[77]=J):J=t[77],T=f.map(J),t[0]=s,t[1]=n,t[2]=l,t[3]=c,t[4]=a,t[5]=d,t[6]=m,t[7]=g,t[8]=_,t[9]=x,t[10]=S,t[11]=w,t[12]=T,t[13]=E,t[14]=D,t[15]=O,t[16]=k,t[17]=A,t[18]=j}else d=t[5],m=t[6],g=t[7],_=t[8],x=t[9],S=t[10],w=t[11],T=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,G.jsx)(f,{className:`size-4`,"aria-hidden":!0}),t[78]=N):N=t[78];let P;t[79]!==a.fullDetails||t[80]!==M?(P=(0,G.jsx)(I,{asChild:!0,type:`button`,variant:`secondary`,className:`h-9 rounded-lg`,children:(0,G.jsxs)(L,{to:M,children:[N,a.fullDetails]})}),t[79]=a.fullDetails,t[80]=M,t[81]=P):P=t[81];let F;t[82]!==_||t[83]!==P||t[84]!==w||t[85]!==T?(F=(0,G.jsxs)(`div`,{className:_,children:[w,T,P]}),t[82]=_,t[83]=P,t[84]=w,t[85]=T,t[86]=F):F=t[86];let R;t[87]!==F||t[88]!==E||t[89]!==D?(R=(0,G.jsxs)(`div`,{className:E,children:[D,F]}),t[87]=F,t[88]=E,t[89]=D,t[90]=R):R=t[90];let B;t[91]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,G.jsx)(`div`,{className:`rounded-xl bg-accent-soft p-2 text-accent-fg`,children:(0,G.jsx)(C,{className:`size-4`,"aria-hidden":!0})}),t[91]=B):B=t[91];let V=n.blockedReason?a.currentBlocker:a.nextAction,H;t[92]===V?H=t[93]:(H=(0,G.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`,K;t[94]===W?K=t[95]:(K=i(`mt-1 text-sm leading-6`,W),t[94]=W,t[95]=K);let ee=n.blockedReason||n.nextAction||a.noNextAction,q;t[96]!==K||t[97]!==ee?(q=(0,G.jsx)(`p`,{className:K,children:ee}),t[96]=K,t[97]=ee,t[98]=q):q=t[98];let J;t[99]!==H||t[100]!==q?(J=(0,G.jsx)(`div`,{className:`mt-5 rounded-2xl bg-surface-base/60 p-4`,children:(0,G.jsxs)(`div`,{className:`flex items-start gap-3`,children:[B,(0,G.jsxs)(`div`,{className:`min-w-0`,children:[H,q]})]})}),t[99]=H,t[100]=q,t[101]=J):J=t[101];let te;t[102]!==o||t[103]!==r||t[104]!==a?(te=r?(0,G.jsxs)(`div`,{className:`mt-4 rounded-2xl bg-surface-base/60 p-4`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,G.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.executionQueue}),(0,G.jsx)(`span`,{className:i(`rounded-full px-2 py-0.5 text-xs font-semibold`,ue(r.status)),children:ie(r.status,a)})]}),(0,G.jsxs)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:[Y(a.attempt,{attempts:r.attempts,max:r.maxRetries+1}),` · `,re(ce(r),o)]}),r.error?(0,G.jsx)(`p`,{className:`mt-2 text-sm text-amber-700 dark:text-amber-300`,children:r.error}):null,r.userTurn?.text?(0,G.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:r.userTurn.text}):null]}):null,t[102]=o,t[103]=r,t[104]=a,t[105]=te):te=t[105];let ae;t[106]===Symbol.for(`react.memo_cache_sentinel`)?(ae=(0,G.jsx)(C,{className:`size-4 text-accent`,"aria-hidden":!0}),t[106]=ae):ae=t[106];let se;t[107]===a.checklist?se=t[108]:(se=(0,G.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[ae,a.checklist]}),t[107]=a.checklist,t[108]=se);let X;t[109]!==n.checklist||t[110]!==a.noChecklist?(X=n.checklist.length?(0,G.jsx)(`ul`,{className:`mt-3 grid gap-2 text-sm text-fg-muted`,children:n.checklist.map(Ae)}):(0,G.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:a.noChecklist}),t[109]=n.checklist,t[110]=a.noChecklist,t[111]=X):X=t[111];let le;t[112]!==se||t[113]!==X?(le=(0,G.jsxs)(`div`,{className:`mt-4 rounded-2xl bg-surface-base/60 p-4`,children:[se,X]}),t[112]=se,t[113]=X,t[114]=le):le=t[114];let Z;t[115]!==R||t[116]!==J||t[117]!==te||t[118]!==le||t[119]!==O?(Z=(0,G.jsxs)(`section`,{className:O,children:[R,J,te,le]}),t[115]=R,t[116]=J,t[117]=te,t[118]=le,t[119]=O,t[120]=Z):Z=t[120];let de;t[121]!==d||t[122]!==Z||t[123]!==k||t[124]!==A?(de=(0,G.jsxs)(d,{className:k,children:[A,Z]}),t[121]=d,t[122]=Z,t[123]=k,t[124]=A,t[125]=de):de=t[125];let Q;t[126]!==m||t[127]!==de||t[128]!==j?(Q=(0,G.jsxs)(m,{children:[j,de]}),t[126]=m,t[127]=de,t[128]=j,t[129]=Q):Q=t[129];let fe;return t[130]!==g||t[131]!==x||t[132]!==S||t[133]!==Q?(fe=(0,G.jsx)(g,{open:x,onOpenChange:S,children:Q}),t[130]=g,t[131]=x,t[132]=S,t[133]=Q,t[134]=fe):fe=t[134],fe}function Ae(e){return(0,G.jsxs)(`li`,{className:`flex gap-2`,children:[(0,G.jsx)(`span`,{className:`w-5 shrink-0 text-center`,children:se(e.status)}),(0,G.jsx)(`span`,{className:`break-words`,children:e.text})]},e.id)}function je(){let e=F(),t=c(e=>e.language),n=a(t).goalsPage,r=m(e=>e.setPageHeader),o=m(e=>e.clearPageHeader),s=(0,W.useRef)(null),u=(0,W.useRef)(null),[f,p]=(0,W.useState)([]),[h,g]=(0,W.useState)([]),[v,y]=(0,W.useState)(``),[b,x]=(0,W.useState)(!0),[S,C]=(0,W.useState)(null),[A,j]=(0,W.useState)(null),[N,P]=(0,W.useState)(!1),[L,R]=(0,W.useState)({defaultAgentId:``,agents:[],models:[],checklistDecomposePolicy:`empty_only`}),[z,U]=(0,W.useState)(`focus`),[K,ne]=(0,W.useState)(null),[re,ie]=(0,W.useState)(null),[oe,se]=(0,W.useState)(null),[ce,X]=(0,W.useState)(!1),ue=(0,W.useCallback)(async()=>{x(!0),j(null);try{let[e,t]=await Promise.all([me(),he()]);p(e),g(t)}catch(e){j(e instanceof Error?e.message:n.errors.load)}finally{x(!1)}},[n.errors.load]);(0,W.useEffect)(()=>{ue()},[ue]),(0,W.useEffect)(()=>{let e=!1;async function t(){let[t,n,r]=await Promise.allSettled([O(),T(),k()]);e||R(e=>{let i=t.status===`fulfilled`?t.value.defaultId:e.defaultAgentId,a=t.status===`fulfilled`?t.value.agents:e.agents,o=n.status===`fulfilled`?n.value:e.models,s=r.status===`fulfilled`?B(r.value.payload?.config).checklistDecomposePolicy:e.checklistDecomposePolicy;return{defaultAgentId:i,agents:a.length?a:[{id:i||`main`,workspace:``,profileDir:``,typedModels:{defaultRole:`deep`,preset:[],effective:[]},extends:[],isDefault:!0,skills:{preset:[]},tools:{presetDenied:[],entryDisable:[],effectiveDisable:[]}}],models:o,checklistDecomposePolicy:s}})}return t(),()=>{e=!0}},[]),(0,W.useEffect)(()=>{let e=()=>{he().then(g).catch(()=>{})};return window.addEventListener(`goal-queue-updated`,e),()=>window.removeEventListener(`goal-queue-updated`,e)},[]);let Z=(0,W.useMemo)(()=>le(h),[h]),Q=(0,W.useMemo)(()=>f.filter(e=>pe(e,v)),[f,v]),be=(0,W.useMemo)(()=>{let e=new Map(q.map(e=>[e,[]]));for(let t of Q){let n=de(t,Z.get(t.id));n&&e.get(n)?.push(t)}for(let t of q)e.get(t)?.sort((e,t)=>fe(e,t,Z));return e},[Z,Q]),xe=(0,W.useMemo)(()=>{let e=new Map(ee.map(e=>[e,[]]));for(let t of Q)e.get(ae(t))?.push(t);return e},[Q]),Se=(0,W.useMemo)(()=>f.find(e=>e.id===K)??null,[f,K]),$=(0,W.useMemo)(()=>({open:f.filter(e=>e.status===`active`||e.status===`paused`||e.status===`blocked`||e.status===`needs_input`).length,attention:f.filter(e=>e.status===`blocked`||e.status===`needs_input`).length,running:h.filter(e=>e.status===`running`).length,queued:h.filter(e=>e.status===`queued`||e.status===`retry_waiting`).length,failed:h.filter(e=>e.status===`failed`).length,active:f.filter(e=>e.status===`active`).length}),[f,h]),Ee=(0,W.useMemo)(()=>[{key:`running`,count:$.running},{key:`queued`,count:$.queued},{key:`failed`,count:$.failed}],[$.failed,$.queued,$.running]),Ae=async(t,r)=>{C(`${t}:${r}`),j(null);try{if(r===`continue`){let n=await ye(t);if(n){e(`/chat/${encodeURIComponent(n)}`);return}}else await ve(t,r);await ue()}catch(e){j(e instanceof Error?e.message:n.errors.action)}finally{C(null)}},je=async(e,t)=>{let n=f.find(t=>t.id===e),r=n?Ce(n,t):null;se(null),ie(null),!(!n||!r)&&await Ae(n.id,r)},Me=(0,W.useCallback)(e=>{let t=u.current;!t||t.pointerId!==e.pointerId||(u.current=null,X(!1),e.currentTarget.hasPointerCapture?.(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId))},[]),Ne=(0,W.useCallback)(e=>{if(e.button!==0||re||te(e.target))return;let t=s.current;t&&(u.current={pointerId:e.pointerId,startX:e.clientX,scrollLeft:t.scrollLeft,active:!1},e.currentTarget.setPointerCapture(e.pointerId))},[re]),Pe=(0,W.useCallback)(e=>{let t=u.current,n=s.current;if(!t||!n||t.pointerId!==e.pointerId)return;let r=e.clientX-t.startX;!t.active&&Math.abs(r)<5||(t.active||(t.active=!0,X(!0)),e.preventDefault(),n.scrollLeft=t.scrollLeft-r)},[]),Fe=(0,W.useCallback)(async e=>{let t=Number.parseInt(e.maxTurns,10),r=e.deadline?new Date(e.deadline).getTime():void 0;C(`create`),j(null);try{let n=await ge({title:e.title.trim(),contextMessage:{text:e.description.trim(),attachments:e.attachments.length?e.attachments: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,contract:{objective:e.objective.trim()||e.title.trim(),scopeBoundary:e.scopeBoundary.trim()||void 0,evidencePlan:V(e.evidencePlan),criteria:V(e.checklist)}});await ue(),ne(n.id)}catch(e){throw j(e instanceof Error?e.message:n.errors.create),e}finally{C(null)}},[ue,n.errors.create]),Ie=(0,W.useMemo)(()=>(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`label`,{className:`relative min-w-0`,children:[(0,G.jsx)(D,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-muted`,"aria-hidden":!0}),(0,G.jsx)(`input`,{value:v,onChange:e=>y(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,G.jsx)(w,{className:`size-9 shrink-0 p-0`,loading:b,label:n.refresh,onClick:ue}),(0,G.jsxs)(I,{type:`button`,variant:`primary`,className:`h-9 rounded-lg`,disabled:S===`create`,onClick:()=>P(!0),children:[(0,G.jsx)(E,{className:`size-4`,"aria-hidden":!0}),n.create]})]}),[S,b,v,ue,n.create,n.refresh,n.searchPlaceholder]);return(0,W.useLayoutEffect)(()=>(r({startExtra:null,main:(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:n.title}),(0,G.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:Y(n.summary,{open:$.open,attention:$.attention,shown:Q.length})})]}),end:Ie}),()=>o()),[o,$.attention,$.open,Ie,r,n.summary,n.title,Q.length]),(0,G.jsxs)(`main`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden bg-surface-panel`,children:[(0,G.jsxs)(`div`,{className:`flex min-h-0 w-full flex-1 flex-col gap-4 px-3 py-5 sm:px-5 xl:px-6`,children:[(0,G.jsx)(`section`,{className:`w-full rounded-lg border border-edge-subtle bg-surface-base p-3 shadow-surface`,children:(0,G.jsxs)(`div`,{className:`flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between`,children:[(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 sm:grid-cols-4`,children:[(0,G.jsxs)(`div`,{className:`rounded-md bg-surface-muted/50 px-3 py-2`,children:[(0,G.jsx)(`p`,{className:`text-[11px] font-medium text-fg-muted`,children:n.overview.attention}),(0,G.jsx)(`p`,{className:`mt-1 text-lg font-semibold tabular-nums text-fg`,children:$.attention+$.failed})]}),(0,G.jsxs)(`div`,{className:`rounded-md bg-surface-muted/50 px-3 py-2`,children:[(0,G.jsx)(`p`,{className:`text-[11px] font-medium text-fg-muted`,children:n.overview.running}),(0,G.jsx)(`p`,{className:`mt-1 text-lg font-semibold tabular-nums text-fg`,children:$.running})]}),(0,G.jsxs)(`div`,{className:`rounded-md bg-surface-muted/50 px-3 py-2`,children:[(0,G.jsx)(`p`,{className:`text-[11px] font-medium text-fg-muted`,children:n.overview.queued}),(0,G.jsx)(`p`,{className:`mt-1 text-lg font-semibold tabular-nums text-fg`,children:$.queued})]}),(0,G.jsxs)(`div`,{className:`rounded-md bg-surface-muted/50 px-3 py-2`,children:[(0,G.jsx)(`p`,{className:`text-[11px] font-medium text-fg-muted`,children:n.overview.active}),(0,G.jsx)(`p`,{className:`mt-1 text-lg font-semibold tabular-nums text-fg`,children:$.active})]})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsxs)(`div`,{className:`mr-1 flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,G.jsx)(d,{className:`size-4 text-accent`,"aria-hidden":!0}),n.executionQueue]}),Ee.map(e=>(0,G.jsx)(`span`,{className:`rounded-full bg-surface-muted px-2 py-0.5 text-xs text-fg-muted`,children:Y(n.queueSummary[e.key],{count:e.count})},e.key)),(0,G.jsxs)(`div`,{className:`ml-0 flex rounded-lg border border-edge bg-surface-muted p-0.5 lg:ml-2`,children:[(0,G.jsxs)(`button`,{type:`button`,className:i(`inline-flex h-8 items-center gap-1.5 rounded-md px-2.5 text-xs font-medium transition-colors`,z===`focus`?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:text-fg`),onClick:()=>U(`focus`),children:[(0,G.jsx)(M,{className:`size-3.5`,"aria-hidden":!0}),n.viewModes.focus]}),(0,G.jsxs)(`button`,{type:`button`,className:i(`inline-flex h-8 items-center gap-1.5 rounded-md px-2.5 text-xs font-medium transition-colors`,z===`board`?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:text-fg`),onClick:()=>U(`board`),children:[(0,G.jsx)(l,{className:`size-3.5`,"aria-hidden":!0}),n.viewModes.board]})]})]})]})}),A?(0,G.jsx)(`p`,{className:`rounded-md border border-destructive/40 bg-destructive/10 px-3 py-2 text-sm text-destructive`,children:A}):null,z===`focus`?(0,G.jsx)(`section`,{className:`min-h-0 flex-1 overflow-y-auto pb-3`,"aria-label":n.focusLabel,children:(0,G.jsx)(`div`,{className:`grid w-full gap-4`,children:q.map(e=>{let r=be.get(e)??[];return(0,G.jsxs)(`section`,{className:`rounded-lg border border-edge-subtle bg-surface-base shadow-surface`,children:[(0,G.jsxs)(`header`,{className:`flex flex-wrap items-start justify-between gap-3 border-b border-edge-subtle px-4 py-3`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.focusSections[e].title}),(0,G.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.focusSections[e].description})]}),(0,G.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,G.jsxs)(`div`,{className:`grid gap-2 p-2.5`,children:[b&&r.length===0?Array.from({length:e===`attention`?2:1}).map((e,t)=>(0,G.jsx)(De,{},t)):r.map(e=>(0,G.jsx)(Te,{goal:e,queueItem:Z.get(e.id),t:n,language:t,busy:S,selected:e.id===K,onOpen:e=>ne(e.id),onAction:(e,t)=>void Ae(e,t)},e.id)),!b&&r.length===0?(0,G.jsx)(`div`,{className:`flex min-h-20 items-center justify-center rounded-md border border-dashed border-edge bg-surface-panel/40 px-4 py-5 text-center text-xs text-fg-subtle`,children:n.focusSections[e].empty}):null]})]},e)})})}):(0,G.jsx)(`section`,{ref:s,className:i(`min-h-0 w-full flex-1 overflow-x-auto rounded-lg px-2 py-2`,ce?`cursor-grabbing select-none`:`cursor-grab`),"aria-label":n.boardLabel,onPointerDown:Ne,onPointerMove:Pe,onPointerUp:Me,onPointerCancel:Me,onLostPointerCapture:e=>{u.current?.pointerId===e.pointerId&&(u.current=null,X(!1))},children:(0,G.jsx)(`div`,{className:`flex min-h-full min-w-max items-start gap-3 pr-4`,children:ee.map(e=>{let r=xe.get(e)??[];return(0,G.jsxs)(`section`,{className:i(`flex max-h-full w-72 min-w-72 max-w-72 shrink-0 flex-col overflow-y-auto rounded-lg bg-surface-base shadow-surface`,oe===e&&`bg-surface-active`),"aria-label":n.lanes[e].title,onDragOver:t=>{t.preventDefault(),t.dataTransfer.dropEffect=`move`,se(e)},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||se(null)},onDrop:t=>{t.preventDefault();let n=t.dataTransfer.getData(J)||re;n&&je(n,e)},children:[(0,G.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between gap-2 px-3 py-3`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,G.jsx)(`h2`,{className:`truncate text-sm font-semibold text-fg`,children:n.lanes[e].title}),(0,G.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:r.length})]}),(0,G.jsx)(_,{className:`size-4 shrink-0 text-fg-subtle`,"aria-hidden":!0})]}),(0,G.jsxs)(`div`,{className:`mx-2 mt-3 grid min-h-0 min-w-0 content-start gap-2 pb-2 pr-1 [scrollbar-gutter:stable]`,children:[b&&r.length===0?Array.from({length:3}).map((e,t)=>(0,G.jsx)(Oe,{},t)):r.map(e=>(0,G.jsx)(we,{goal:e,queueItem:Z.get(e.id),t:n,language:t,selected:e.id===K,dragging:e.id===re,onOpen:e=>ne(e.id),onDragStart:(e,t)=>{t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(J,e),ie(e)},onDragEnd:()=>{ie(null),se(null)}},e.id)),!b&&r.length===0?(0,G.jsx)(`div`,{className:`rounded-lg bg-surface-panel/70 px-3 py-6 text-center text-xs text-fg-subtle`,children:n.lanes[e].empty}):null]})]},e)})})})]}),(0,G.jsx)(H,{open:N,t:n,chat:a(t).chat,busy:S===`create`,options:L,onClose:()=>P(!1),onCreate:Fe,onDraftContract:e=>_e(e,t)}),(0,G.jsx)(ke,{goal:Se,queueItem:Se?Z.get(Se.id):void 0,t:n,language:t,busy:S,onClose:()=>ne(null),onAction:(e,t)=>void Ae(e,t)})]})}export{je as GoalsPage};
|