@xopcai/xopc 0.0.193 → 0.0.194
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/feishu/src/outbound/media-load.js +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-DmNq0t2n.js → agent-avatar-dicebear-4ln7j-oZ.js} +1 -1
- package/dist/gateway/static/root/assets/{agents-BOo1rVn9.js → agents-C1Z-rurI.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-B3xStqSX.js → app-management-settings-panel-B0IMpHk8.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-DglyenDq.js → appearance-settings-BG6ZGIUf.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-DC9qPFTx.js → apps-page-CwsZENTk.js} +1 -1
- package/dist/gateway/static/root/assets/{archive-plugin-DvtcrBss.js → archive-plugin-BNpjG4FR.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-CALdq4xM.js → attachment-load-BK25C_hA.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-BIGGKb0T.js → automations-page-BedezAfO.js} +1 -1
- package/dist/gateway/static/root/assets/{binary-plugins-GaVuvrDI.js → binary-plugins-fbFe6Jqc.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-C2KrMYa_.js → block-editor-SQHwWg1e.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-settings-page-CPW_E-xj.js → browser-settings-page-CC0_TfTy.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-workflow-inputs-FfEEjhIS.js → browser-workflow-inputs-DuUQ_Ycz.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-workflows-page-DFP9_UQk.js → browser-workflows-page-B8I2FmrM.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-settings-panel-CsD8aGHU.js → capabilities-settings-panel-ditT6VRs.js} +1 -1
- package/dist/gateway/static/root/assets/{capability-presets-settings-panel-NCeyWH6Z.js → capability-presets-settings-panel-bNVds1ta.js} +1 -1
- package/dist/gateway/static/root/assets/{channels-settings-CknzwxNC.js → channels-settings-DhsWSbJ2.js} +1 -1
- package/dist/gateway/static/root/assets/{connectors-api-vaSrhPF8.js → connectors-api-Ne8mQrYN.js} +1 -1
- package/dist/gateway/static/root/assets/{connectors-page-DEGE7xp_.js → connectors-page-hZA9M1z_.js} +1 -1
- package/dist/gateway/static/root/assets/{cron-expression-BjFuXlGY.js → cron-expression-DtWb3YAh.js} +1 -1
- package/dist/gateway/static/root/assets/{dependency-picker-DOdkHdPv.js → dependency-picker-3vjdusik.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-Dz-Yf8Uu.js → desktop-pet-NmW7VWdO.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-C8EHFEtd.js → desktop-pet-settings-DrdSI9lX.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-DKbfmZlZ.js → directory-picker-path-field-CG5XR1UD.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-Dq0xsr_e.js → extension-debug-page-RjIezQyy.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-IgSLUyWP.js → extension-page-D9Elz9mr.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-VC-8Pjn2.js → extension-settings-page-BvVjqFvm.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-api-CH2R7yqo.js → gateway-config-api-C-rYVz-n.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-DLQJWaBQ.js → gateway-settings-CLS25-gm.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-settings-43loWoGb.js → heartbeat-settings-DSgDxtwJ.js} +1 -1
- package/dist/gateway/static/root/assets/{home-page-DqvpI6LC.js → home-page-CDpUUelT.js} +1 -1
- package/dist/gateway/static/root/assets/{index-BpkdvHH0.js → index-Cb9y6tVR.js} +8 -8
- package/dist/gateway/static/root/assets/index-DtEVsSU1.css +1 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-DJDZes_8.js → keyboard-shortcuts-settings-RcHmSHYI.js} +1 -1
- package/dist/gateway/static/root/assets/{local-app-workbench-page-CvNQM6qm.js → local-app-workbench-page-DvzXo7dx.js} +1 -1
- package/dist/gateway/static/root/assets/{local-apps-page-C2ajOn1D.js → local-apps-page-s7PKLTvO.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-BLm5yWqQ.js → logs-page-CNm5fu3L.js} +1 -1
- package/dist/gateway/static/root/assets/{management-settings--_eXnFVr.js → management-settings-CWUHBXje.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-split-iL2oi-x2.js → markdown-split-B-IuPr4L.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-BIbkLVpQ.js → media-plugins-CiejHVt4.js} +1 -1
- package/dist/gateway/static/root/assets/{notes-page-xFxaZ6gT.js → notes-page-BSJAwHqy.js} +1 -1
- package/dist/gateway/static/root/assets/{notes-workbench-PAftxL3V.js → notes-workbench-DTWRQ_EU.js} +2 -2
- package/dist/gateway/static/root/assets/{page-tabs-CROi9zm1.js → page-tabs-D6YJ6_l_.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-BwYcPjOM.js → preview-open-alternatives-Tw_G-6jb.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-BezeuVFd.js → product-open-page-BlB3QjTV.js} +1 -1
- package/dist/gateway/static/root/assets/{project-detail-page-CCdfZcw-.js → project-detail-page-DT7aWLWT.js} +1 -1
- package/dist/gateway/static/root/assets/{projects-page-DOG9zm5e.js → projects-page-B-i3U2fU.js} +1 -1
- package/dist/gateway/static/root/assets/{remote-access-hub-DQBFgveI.js → remote-access-hub-v-kXavTc.js} +1 -1
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-Bs6tpSyX.js → runtime-tools-settings-panel-D59bftC7.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-CWoSjz9s.js → schema-form-DyXqGA71.js} +1 -1
- package/dist/gateway/static/root/assets/{sessions-page-Db6L6M2H.js → sessions-page-tEfg1Pru.js} +1 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-tbguNxVJ.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-BJaMEHsX.js → settings-form-section-DZUGXwFO.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-loading-skeleton-sn4k17x7.js → settings-loading-skeleton-Lz1ec5lN.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-D2hfeFPX.js → settings-page-DLofKC7q.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-layout-CLtUsWsu.js → settings-page-layout-BdkN2U81.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-status-panel-UmQC_uZ1.js → setup-status-panel-DQgoV7gj.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-BJ58AluH.js → share-preview-page-DrZVv8tB.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-settings-BZKn6Fdc.js → shares-settings-I2bBkyDb.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-reload-api-Cx3i24w_.js → skill-reload-api-gFdcImEc.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page-DjUllGtk.js → skills-page-zOD__-H5.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page.utils-CZYIuE26.js → skills-page.utils-ZDcx95iD.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-DUrgdQMk.js → system-settings-panel-BJhat70L.js} +1 -1
- package/dist/gateway/static/root/assets/{task-detail-page-BGG2cFe9.js → task-detail-page-DoyREaFj.js} +1 -1
- package/dist/gateway/static/root/assets/{typed-models-lib-CRNMvvFX.js → typed-models-lib-B1p3wMFK.js} +1 -1
- package/dist/gateway/static/root/assets/{use-autosave-Dle3-zdQ.js → use-autosave-Frcfbncl.js} +1 -1
- package/dist/gateway/static/root/assets/{user-context-page-BLLmw5S1.js → user-context-page-DniWcH92.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-api-key-field-BrWH0dCl.js → voice-api-key-field-CSNOUNF4.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-BZ1l9CFM.js → work-discovery-overlay-DTJGssPz.js} +1 -1
- package/dist/gateway/static/root/assets/work-discovery-page-Bt2-fzHu.js +1 -0
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-BK6e9yzK.js → workflow-run-setup-panel-D3uCmyag.js} +1 -1
- package/dist/gateway/static/root/assets/{workflows-page-Bp5JxQJa.js → workflows-page-Ba5fVQWY.js} +1 -1
- package/dist/gateway/static/root/index.html +2 -2
- package/dist/package.js +1 -1
- package/dist/src/agent/agent-manager.js +1 -1
- package/dist/src/agent/memory/create-memory-manager.js +1 -1
- package/dist/src/agent-runtime/index.js +1 -1
- package/dist/src/agent-runtime/runtime-profile.js +1 -1
- package/dist/src/cli/commands/channels.js +1 -1
- package/dist/src/cli/commands/connectors.js +1 -1
- package/dist/src/cli/commands/extension-marketplace.js +1 -1
- package/dist/src/cli/commands/gateway/lifecycle.js +1 -1
- package/dist/src/cli/commands/models.js +1 -1
- package/dist/src/cli/commands/onboard.js +1 -1
- package/dist/src/cli/commands/update.js +1 -1
- package/dist/src/config/agent-profile.js +1 -1
- package/dist/src/extensions/sdk/index.js +1 -1
- package/dist/src/gateway/agents-admin.js +1 -1
- package/dist/src/gateway/hono/routes/local-apps.js +1 -1
- package/dist/src/gateway/hono/routes/update.js +2 -2
- package/dist/src/gateway/index.js +1 -1
- package/dist/src/gateway/run-loop.js +1 -1
- package/dist/src/gateway/service.js +6 -6
- package/dist/src/infra/gateway-processes.js +1 -1
- package/dist/src/infra/update-restart.js +1 -1
- package/dist/src/infra/update-runner.js +2 -2
- package/dist/src/infra/update-startup.js +1 -1
- package/dist/src/tui/backends/gateway-realtime-backend.js +1 -1
- package/dist/src/work-discovery/analyzer.js +1 -2
- package/package.json +4 -4
- package/dist/gateway/static/root/assets/index-CFVjH-EK.css +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-CcO2bd6q.js +0 -1
- package/dist/gateway/static/root/assets/work-discovery-page-BnPF2vx7.js +0 -1
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{f as i,t as a}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as o}from"./cn-JdwAhgNB.js";import{t as s}from"./messages-DQ5X6cXp.js";import{l as c,n as l}from"./locale-store-Bjvw7jtg.js";import{i as u}from"./vendor-swr-BIWyz7Rc.js";import{$c as d,Ao as f,Cu as p,Go as m,Ko as h,Ll as g,Mo as _,No as v,Nt as y,Oo as b,Po as x,Ps as S,Su as C,Uo as w,Wo as T,Xo as E,Ys as D,Zo as O,_s as k,ac as A,bs as j,bu as M,fc as N,hc as P,jo as F,kl as I,ko as L,mu as R,ou as z,us as B,xs as V,yr as H,yu as ee,zc as te}from"./index-
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{f as i,t as a}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as o}from"./cn-JdwAhgNB.js";import{t as s}from"./messages-DQ5X6cXp.js";import{l as c,n as l}from"./locale-store-Bjvw7jtg.js";import{i as u}from"./vendor-swr-BIWyz7Rc.js";import{$c as d,Ao as f,Cu as p,Go as m,Ko as h,Ll as g,Mo as _,No as v,Nt as y,Oo as b,Po as x,Ps as S,Su as C,Uo as w,Wo as T,Xo as E,Ys as D,Zo as O,_s as k,ac as A,bs as j,bu as M,fc as N,hc as P,jo as F,kl as I,ko as L,mu as R,ou as z,us as B,xs as V,yr as H,yu as ee,zc as te}from"./index-Cb9y6tVR.js";import{l as U}from"./vendor-codemirror-DRr7hFaD.js";import{t as W}from"./code-editor-dFzqyDXS.js";import{n as ne,r as re}from"./settings-page-layout-BdkN2U81.js";import{n as ie,r as ae}from"./settings-loading-skeleton-Lz1ec5lN.js";import{n as G,t as K}from"./settings-form-section-DZUGXwFO.js";import{a as oe,c as se,i as ce,n as le,o as ue,r as de,s as fe,t as pe}from"./capability-presets-api-BoOzFotX.js";import{a as me,i as he,o as q,s as J,t as Y}from"./typed-models-lib-B1p3wMFK.js";import{r as ge}from"./image-generation-api-Cki7jfEV.js";var _e=n(),X=e(t(),1),Z=r(),Q=[`deep`,`fast`,`cheap`,`code`,`review`];function ve(e){return Q.includes(e)}function ye(e){let{rows:t,onChange:n,disabled:r,defaultRole:i,chat:a,labels:o}=e,s=(0,X.useRef)([]),c=(0,X.useRef)(0);for(;s.current.length<t.length;)s.current.push(`preset-model-row-${c.current++}`);s.current.length>t.length&&(s.current.length=t.length);let l=i??(t.some(e=>e.id===`deep`)?`deep`:t[0]?.id)??`deep`,u=t.findIndex(e=>e.id===l),d=u>=0?t[u]:void 0,f=t.map((e,t)=>({row:e,index:t})).filter(({index:e})=>e!==u),p=(e,r)=>{n(t.map((t,n)=>n===e?{...t,...r}:t))},m=e=>{if(u>=0){p(u,{model:e});return}s.current.unshift(`preset-model-row-${c.current++}`),n([{id:l,model:e,fallbacks:[],description:ve(l)?o.roleDescriptions[l]:``},...t])},h=e=>{let n=t[e];n&&p(e,{fallbacks:[...n.fallbacks??[],``]})},g=(e,n,r)=>{let i=t[e];if(!i)return;let a=[...i.fallbacks??[]];a[n]=r,p(e,{fallbacks:a})},_=(e,n)=>{let r=t[e];r&&p(e,{fallbacks:(r.fallbacks??[]).filter((e,t)=>t!==n)})},v=e=>{s.current.splice(e,1),n(t.filter((t,n)=>n!==e))},b=e=>{if(!e)return;let r=e===`__custom__`?``:e;s.current.push(`preset-model-row-${c.current++}`),n([...t,{id:r,model:``,fallbacks:[],description:ve(r)?o.roleDescriptions[r]:``}])},x=[...Q.filter(e=>e!==l&&!t.some(t=>t.id===e)).map(e=>({value:e,label:o.roleNames[e]})),{value:`__custom__`,label:o.customRole}],C=(e,t)=>(0,Z.jsxs)(`div`,{className:`grid gap-3 border-t border-edge-subtle pt-3 dark:border-edge`,children:[(0,Z.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:o.fallbackModels}),(0,Z.jsxs)(k,{type:`button`,variant:`secondary`,className:`h-7 gap-1 px-2 text-xs`,disabled:r,onClick:()=>h(t),children:[(0,Z.jsx)(P,{className:`size-3.5`,"aria-hidden":!0}),o.addFallback]})]}),(e.fallbacks??[]).length>0?(0,Z.jsx)(`div`,{className:`grid gap-1.5`,children:(e.fallbacks??[]).map((e,n)=>(0,Z.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto] gap-2`,children:[(0,Z.jsx)(y,{value:e,disabled:r,placeholder:o.fallbackPlaceholder,searchPlaceholder:a.modelSearchPlaceholder,noMatches:a.modelNoMatches,className:`w-full max-w-none`,contentAlign:`start`,onChange:e=>g(t,n,e)}),(0,Z.jsx)(k,{type:`button`,variant:`secondary`,className:`shrink-0 px-2`,disabled:r,"aria-label":o.removeFallback,onClick:()=>_(t,n),children:(0,Z.jsx)(S,{className:`size-4`,"aria-hidden":!0})})]},`${s.current[t]}-fallback-${n}`))}):(0,Z.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:o.fallbackEmptyHint})]}),(0,Z.jsxs)(`label`,{className:`grid gap-1.5 text-xs font-medium text-fg-muted`,children:[o.description,(0,Z.jsx)(`input`,{type:`text`,className:J(),value:e.description,disabled:r,placeholder:o.descriptionPlaceholder,onChange:e=>p(t,{description:e.target.value})})]})]});return(0,Z.jsxs)(`div`,{className:`grid gap-5`,children:[(0,Z.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-base p-4`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:o.defaultTitle}),(0,Z.jsx)(`span`,{className:`rounded-full bg-accent/10 px-2 py-0.5 text-[11px] font-medium text-accent`,children:o.defaultBadge})]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:o.defaultHint})]}),(0,Z.jsxs)(`span`,{className:`rounded-md bg-surface-panel px-2 py-1 font-mono text-[11px] text-fg-subtle`,children:[o.roleId,`: `,l]})]}),(0,Z.jsxs)(`div`,{className:`mt-4 grid gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:o.primaryModel}),(0,Z.jsx)(y,{value:d?.model??``,disabled:r,placeholder:a.modelPlaceholder,searchPlaceholder:a.modelSearchPlaceholder,noMatches:a.modelNoMatches,className:`w-full max-w-none`,contentAlign:`start`,onChange:m})]}),d?(0,Z.jsxs)(`details`,{className:`group mt-3`,children:[(0,Z.jsxs)(`summary`,{className:`flex w-fit cursor-pointer list-none items-center gap-1.5 rounded-md text-xs font-medium text-fg-muted hover:text-fg`,children:[o.moreSettings,(0,Z.jsx)(z,{className:`size-3.5 transition-transform group-open:rotate-180`,"aria-hidden":!0})]}),(0,Z.jsx)(`div`,{className:`mt-3`,children:C(d,u)})]}):null]}),(0,Z.jsxs)(`section`,{children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:o.otherRolesTitle}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:o.otherRolesHint})]}),f.length>0?(0,Z.jsx)(`div`,{className:`mt-3 grid gap-2`,children:f.map(({row:e,index:t})=>{let n=ve(e.id)?e.id:void 0;return(0,Z.jsxs)(`div`,{className:`rounded-lg border border-edge-subtle bg-surface-panel/60 p-3 dark:border-edge`,children:[(0,Z.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-[minmax(8rem,12rem)_minmax(0,1fr)] md:items-end`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n?o.roleNames[n]:o.customRole}),n?(0,Z.jsx)(`div`,{className:`mt-1 font-mono text-[11px] text-fg-subtle`,children:e.id}):(0,Z.jsxs)(`label`,{className:`mt-1 grid gap-1 text-[11px] text-fg-muted`,children:[o.roleId,(0,Z.jsx)(`input`,{type:`text`,className:J(),value:e.id,disabled:r,placeholder:o.roleIdPlaceholder,onChange:e=>p(t,{id:e.target.value.toLowerCase()})})]})]}),(0,Z.jsxs)(`label`,{className:`grid min-w-0 gap-1.5 text-xs font-medium text-fg-muted`,children:[o.primaryModel,(0,Z.jsx)(y,{value:e.model,disabled:r,placeholder:a.modelPlaceholder,searchPlaceholder:a.modelSearchPlaceholder,noMatches:a.modelNoMatches,className:`w-full max-w-none`,contentAlign:`start`,onChange:e=>p(t,{model:e})})]})]}),(0,Z.jsxs)(`details`,{className:`group mt-3`,children:[(0,Z.jsxs)(`summary`,{className:`flex w-fit cursor-pointer list-none items-center gap-1.5 text-xs font-medium text-fg-muted hover:text-fg`,children:[o.moreSettings,(0,Z.jsx)(z,{className:`size-3.5 transition-transform group-open:rotate-180`,"aria-hidden":!0})]}),(0,Z.jsxs)(`div`,{className:`mt-3`,children:[C(e,t),(0,Z.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,Z.jsxs)(k,{type:`button`,variant:`secondary`,disabled:r,onClick:()=>v(t),children:[(0,Z.jsx)(S,{className:`size-4`,"aria-hidden":!0}),o.removeRole]})})]})]})]},s.current[t])})}):(0,Z.jsx)(`p`,{className:`mt-3 rounded-lg bg-surface-panel/60 px-3 py-2 text-sm text-fg-muted shadow-surface`,children:o.otherRolesEmpty}),(0,Z.jsx)(w,{value:``,options:x,placeholder:o.addTaskModel,allowEmpty:!1,disabled:r,triggerClassName:`mt-3 w-fit`,onChange:b})]})]})}var be=U();function xe(e){let t=e.split(`
|
|
2
2
|
`).map(e=>e.trim()).filter(Boolean);return t.length?t:void 0}function Se(e){return e?.join(`
|
|
3
3
|
`)??``}function Ce(e,t,n){return Object.entries(e).find(([e])=>e===t||e.startsWith(`${t}.`))?.[1]??n}function we(e){return!!(e&&typeof e==`object`&&!Array.isArray(e))}function Te(e){if(!we(e)||[`models`,`tools`,`skills`,`workflows`,`boundaries`,`runtime`].some(t=>e[t]!==void 0&&!we(e[t]))||e.extends!==void 0&&!Array.isArray(e.extends)||e.locks!==void 0&&!Array.isArray(e.locks))return!1;let t=e.skills;if(t&&[`allow`,`deny`].some(e=>t[e]!==void 0&&!Array.isArray(t[e])))return!1;let n=e.workflows;if(n&&[`allowed`,`suggested`].some(e=>n[e]!==void 0&&!Array.isArray(n[e])))return!1;let r=e.boundaries;return!(r&&[`requiresConfirmation`,`forbidden`,`escalation`].some(e=>r[e]!==void 0&&!Array.isArray(r[e])))}function Ee(e){let{extendsIds:t,onExtendsChange:n,presetOptions:r,inherited:i,inheritedSources:a={},mcpServerIds:o,mcpTools:s,workflows:c,policy:l,onPolicyChange:u,rawPolicy:d,onRawPolicyChange:f,disabled:h,labels:g}=e,[_,v]=(0,X.useState)(t.length>1),[y,b]=(0,X.useState)(!1),[x,C]=(0,X.useState)(``),[w,E]=(0,X.useState)(``),D=l.mcp??{},O=l.workflows??{},A=l.boundaries??{},j=l.runtime??{},M=l.locks??[],N=[...new Set([...o,...Object.keys(D.servers??{})])].sort(),P=new Map(r.map(e=>[e.id,e])),F=r.filter(e=>!t.includes(e.id)),I=(e,t)=>{u({...l,[e]:t})},L=(e,t)=>{let n={...D.servers??{}};t?n[e]={...n[e],mode:t}:delete n[e],I(`mcp`,De({...D,servers:Object.keys(n).length?n:void 0,tools:Object.keys(D.tools??{}).length?D.tools:void 0}))},R=(e,t)=>{let n={...D.tools??{}};t?n[e]=t:delete n[e],I(`mcp`,De({...D,servers:Object.keys(D.servers??{}).length?D.servers:void 0,tools:Object.keys(n).length?n:void 0}))};return(0,Z.jsxs)(`div`,{className:`flex flex-col gap-7`,children:[(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:g.inheritanceTitle}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:g.inheritanceHint}),_?(0,Z.jsxs)(`div`,{className:`mt-3 grid gap-2`,children:[t.map((e,r)=>(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 rounded-lg bg-surface-panel/70 px-3 py-2.5 shadow-surface`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`div`,{className:`truncate text-sm font-medium text-fg`,children:P.get(e)?.name??e}),(0,Z.jsx)(`div`,{className:`font-mono text-[11px] text-fg-subtle`,children:e})]}),(0,Z.jsx)(k,{type:`button`,variant:`secondary`,className:`size-8 p-0`,disabled:h||r===0,"aria-label":g.inheritanceMoveUp,onClick:()=>{let e=[...t];[e[r-1],e[r]]=[e[r],e[r-1]],n(e)},children:(0,Z.jsx)(ee,{className:`size-3.5`})}),(0,Z.jsx)(k,{type:`button`,variant:`secondary`,className:`size-8 p-0`,disabled:h||r===t.length-1,"aria-label":g.inheritanceMoveDown,onClick:()=>{let e=[...t];[e[r],e[r+1]]=[e[r+1],e[r]],n(e)},children:(0,Z.jsx)(p,{className:`size-3.5`})}),(0,Z.jsx)(k,{type:`button`,variant:`secondary`,className:`size-8 p-0`,disabled:h,"aria-label":g.inheritanceRemove,onClick:()=>n(t.filter(t=>t!==e)),children:(0,Z.jsx)(S,{className:`size-3.5`})})]},e)),F.length?(0,Z.jsxs)(`label`,{className:`text-xs text-fg-muted`,children:[g.inheritanceAdd,(0,Z.jsxs)(T,{value:``,disabled:h,onChange:e=>e.target.value&&n([...t,e.target.value]),children:[(0,Z.jsx)(m,{value:``,children:g.inheritanceAvailable}),F.map(e=>(0,Z.jsx)(m,{value:e.id,children:e.name},e.id))]})]}):null]}):(0,Z.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-end gap-2`,children:[(0,Z.jsxs)(`label`,{className:`min-w-64 flex-1 text-xs text-fg-muted`,children:[g.inheritanceAvailable,(0,Z.jsxs)(T,{value:t[0]??``,disabled:h,onChange:e=>n(e.target.value?[e.target.value]:[]),children:[(0,Z.jsx)(m,{value:``,children:g.inherit}),r.map(e=>(0,Z.jsx)(m,{value:e.id,children:e.name},e.id))]})]}),(0,Z.jsx)(k,{type:`button`,variant:`secondary`,disabled:h,onClick:()=>v(!0),children:g.compose})]}),r.length?null:(0,Z.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:g.inheritanceEmpty})]}),(0,Z.jsx)(Oe,{title:g.mcpTitle,hint:g.mcpHint,source:Ce(a,`tools.mcp`,g.inherit),children:N.length?(0,Z.jsx)(`div`,{className:`grid gap-2`,children:N.map(e=>(0,Z.jsxs)(`details`,{className:`rounded-lg bg-surface-panel/70 px-3 py-2 shadow-surface`,children:[(0,Z.jsxs)(`summary`,{className:`grid cursor-pointer items-center gap-2 sm:grid-cols-[minmax(0,1fr)_12rem]`,children:[(0,Z.jsx)(`span`,{className:`truncate font-mono text-xs text-fg`,children:e}),(0,Z.jsxs)(T,{value:D.servers?.[e]?.mode??``,disabled:h,onClick:e=>e.stopPropagation(),onChange:t=>L(e,t.target.value),children:[(0,Z.jsx)(m,{value:``,children:i?.tools?.mcp?.servers?.[e]?.mode?`${g.inherit} · ${i.tools.mcp.servers[e].mode}`:g.inherit}),(0,Z.jsx)(m,{value:`allow`,children:g.modeAllow}),(0,Z.jsx)(m,{value:`confirm`,children:g.modeConfirm}),(0,Z.jsx)(m,{value:`deny`,children:g.modeDeny})]})]}),(0,Z.jsxs)(`div`,{className:`mt-3 grid gap-2 border-t border-edge-subtle pt-3`,children:[D.servers?.[e]?(0,Z.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:D.servers[e].scope===`readonly`,disabled:h,onChange:t=>{let n=D.servers?.[e];if(!n)return;let r={...D.servers??{},[e]:{...n,scope:t.target.checked?`readonly`:void 0}};I(`mcp`,De({...D,servers:r}))}}),g.readonlyOnly]}):null,s.filter(t=>t.serverId===e).map(e=>{let t=D.tools?.[e.id];return(0,Z.jsxs)(`div`,{className:`grid gap-2 rounded-lg bg-surface-base px-3 py-2 lg:grid-cols-[minmax(0,1fr)_11rem_8rem_8rem] lg:items-end`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`truncate font-mono text-xs text-fg`,children:e.name}),(0,Z.jsx)(`div`,{className:`truncate text-xs text-fg-muted`,children:e.description})]}),(0,Z.jsxs)(T,{value:t?.mode??``,disabled:h,onChange:n=>{let r=n.target.value;R(e.id,r?{...t??{},mode:r}:void 0)},children:[(0,Z.jsx)(m,{value:``,children:g.inherit}),(0,Z.jsx)(m,{value:`allow`,children:g.modeAllow}),(0,Z.jsx)(m,{value:`confirm`,children:g.modeConfirm}),(0,Z.jsx)(m,{value:`deny`,children:g.modeDeny})]}),(0,Z.jsx)(ke,{label:g.maxCalls,value:t?.limits?.maxCallsPerTurn,disabled:!t||h,onChange:n=>R(e.id,t?{...t,limits:De({...t.limits,maxCallsPerTurn:n})}:void 0)}),(0,Z.jsx)(ke,{label:g.timeoutMinutes,value:t?.limits?.timeoutMs?t.limits.timeoutMs/6e4:void 0,disabled:!t||h,onChange:n=>R(e.id,t?{...t,limits:De({...t.limits,timeoutMs:n?n*6e4:void 0})}:void 0)})]},e.id)})]})]},e))}):(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:g.noMcp})}),(0,Z.jsxs)(Oe,{title:g.workflowsTitle,hint:g.workflowsHint,source:Ce(a,`workflows`,g.inherit),children:[(0,Z.jsxs)(`label`,{className:`text-xs text-fg-muted`,children:[g.defaultWorkflow,(0,Z.jsxs)(T,{value:O.default??``,disabled:h,onChange:e=>I(`workflows`,De({...O,default:e.target.value||void 0})),children:[(0,Z.jsx)(m,{value:``,children:i?.workflows?.default?`${g.inherit} · ${i.workflows.default}`:g.inherit}),c.map(e=>(0,Z.jsx)(m,{value:e.id,children:e.title},e.id))]})]}),(0,Z.jsxs)(`div`,{className:`mt-3`,children:[(0,Z.jsx)(`div`,{className:`mb-2 text-xs text-fg-muted`,children:g.allowedWorkflows}),(0,Z.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:c.map(e=>{let t=O.allowed?.includes(e.id)??!1;return(0,Z.jsxs)(`label`,{className:`flex gap-2 rounded-lg bg-surface-panel/70 px-3 py-2 text-sm text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,checked:t,disabled:h,onChange:()=>{let n=new Set(O.allowed??[]);t?n.delete(e.id):n.add(e.id),I(`workflows`,De({...O,allowed:n.size?[...n].sort():void 0}))}}),(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`span`,{className:`block font-medium`,children:e.title}),(0,Z.jsx)(`span`,{className:`text-xs text-fg-muted`,children:e.description})]})]},e.id)})})]})]}),(0,Z.jsx)(Oe,{title:g.runtimeTitle,hint:g.runtimeHint,source:Ce(a,`runtime`,g.inherit),children:(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,Z.jsx)(ke,{label:g.timeoutMinutes,value:j.timeoutMs?j.timeoutMs/6e4:void 0,placeholder:i?.runtime?.timeoutMs?String(i.runtime.timeoutMs/6e4):void 0,disabled:h,onChange:e=>I(`runtime`,De({...j,timeoutMs:e?e*6e4:void 0}))}),(0,Z.jsx)(ke,{label:g.maxTurns,value:j.maxTurns,placeholder:i?.runtime?.maxTurns?String(i.runtime.maxTurns):void 0,disabled:h,onChange:e=>I(`runtime`,De({...j,maxTurns:e}))}),(0,Z.jsx)(ke,{label:g.maxFailures,value:j.maxToolFailuresPerTurn,placeholder:i?.runtime?.maxToolFailuresPerTurn?String(i.runtime.maxToolFailuresPerTurn):void 0,disabled:h,onChange:e=>I(`runtime`,De({...j,maxToolFailuresPerTurn:e}))})]})}),(0,Z.jsx)(Oe,{title:g.boundariesTitle,hint:g.boundariesHint,source:Ce(a,`boundaries`,g.inherit),children:(0,Z.jsx)(`div`,{className:`grid gap-3 lg:grid-cols-3`,children:[[`requiresConfirmation`,g.confirmRules],[`forbidden`,g.forbiddenRules],[`escalation`,g.escalationRules]].map(([e,t])=>(0,Z.jsxs)(`label`,{className:`text-xs text-fg-muted`,children:[t,(0,Z.jsx)(`textarea`,{className:`mt-1 min-h-28 w-full resize-y rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg`,placeholder:g.onePerLine,value:Se(A[e]),disabled:h,onChange:t=>I(`boundaries`,De({...A,[e]:xe(t.target.value)}))})]},e))})}),(0,Z.jsxs)(`details`,{className:`rounded-xl border border-edge-subtle bg-surface-panel/40 p-4`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer text-sm font-semibold text-fg`,children:g.governanceTitle}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:g.governanceHint}),(0,Z.jsxs)(`label`,{className:`mt-3 block text-xs text-fg-muted`,children:[g.locksLabel,(0,Z.jsx)(`textarea`,{className:`mt-1 min-h-28 w-full resize-y rounded-lg border border-edge bg-surface-base px-3 py-2 font-mono text-xs text-fg`,placeholder:g.onePerLine,value:Se(M),disabled:h,onChange:e=>I(`locks`,xe(e.target.value))})]})]}),(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:g.rawTitle}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:g.rawHint}),y?(0,Z.jsxs)(`div`,{className:`mt-3`,children:[(0,Z.jsx)(`div`,{className:`h-72 overflow-hidden rounded-lg border border-edge bg-surface-base`,children:(0,Z.jsx)(W,{initialContent:x,onChange:C,language:be,lineWrap:!0})}),w?(0,Z.jsx)(`p`,{className:`mt-2 text-sm text-red-600 dark:text-red-400`,children:w}):null,(0,Z.jsxs)(`div`,{className:`mt-2 flex gap-2`,children:[(0,Z.jsx)(k,{type:`button`,onClick:()=>{try{let e=JSON.parse(x);if(!Te(e))throw Error(`invalid policy`);f(e),E(``),b(!1)}catch{E(g.rawInvalid)}},children:g.rawApply}),(0,Z.jsx)(k,{type:`button`,variant:`secondary`,onClick:()=>b(!1),children:g.cancel})]})]}):(0,Z.jsx)(k,{className:`mt-3`,type:`button`,variant:`secondary`,onClick:()=>{C(JSON.stringify(d,null,2)),E(``),b(!0)},children:g.rawOpen})]})]})}function De(e){let t=Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0));return Object.keys(t).length?t:void 0}function Oe(e){let t=(0,_e.c)(17),n;t[0]===e.title?n=t[1]:(n=(0,Z.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:e.title}),t[0]=e.title,t[1]=n);let r;t[2]===e.hint?r=t[3]:(r=(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.hint}),t[2]=e.hint,t[3]=r);let i;t[4]!==n||t[5]!==r?(i=(0,Z.jsxs)(`div`,{children:[n,r]}),t[4]=n,t[5]=r,t[6]=i):i=t[6];let a;t[7]===e.source?a=t[8]:(a=(0,Z.jsx)(`span`,{className:`rounded-full bg-surface-panel px-2 py-0.5 text-[11px] text-fg-muted`,children:e.source}),t[7]=e.source,t[8]=a);let o;t[9]!==i||t[10]!==a?(o=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[i,a]}),t[9]=i,t[10]=a,t[11]=o):o=t[11];let s;t[12]===e.children?s=t[13]:(s=(0,Z.jsx)(`div`,{className:`mt-3`,children:e.children}),t[12]=e.children,t[13]=s);let c;return t[14]!==o||t[15]!==s?(c=(0,Z.jsxs)(`section`,{children:[o,s]}),t[14]=o,t[15]=s,t[16]=c):c=t[16],c}function ke(e){let t=(0,_e.c)(10),n=e.value??``,r;t[0]===e?r=t[1]:(r=t=>e.onChange(t.target.value?Number(t.target.value):void 0),t[0]=e,t[1]=r);let i;t[2]!==e.disabled||t[3]!==e.placeholder||t[4]!==n||t[5]!==r?(i=(0,Z.jsx)(`input`,{type:`number`,min:1,step:1,className:`mt-1 w-full rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg`,value:n,placeholder:e.placeholder,disabled:e.disabled,onChange:r}),t[2]=e.disabled,t[3]=e.placeholder,t[4]=n,t[5]=r,t[6]=i):i=t[6];let a;return t[7]!==e.label||t[8]!==i?(a=(0,Z.jsxs)(`label`,{className:`text-xs text-fg-muted`,children:[e.label,i]}),t[7]=e.label,t[8]=i,t[9]=a):a=t[9],a}function Ae(e){return e.name||e.directoryId}function je(e){let t=(0,_e.c)(56),{mode:n,selected:r,catalog:i,loading:a,disabled:s,onModeChange:c,onSelectedChange:l,labels:u}=e,d=n===`allowlist`||n===`denylist`,f;t[0]===i?f=t[1]:(f=i.map(Ae).filter(Boolean),t[0]=i,t[1]=f);let p=f,m;bb0:{if(n===`inherit`){m=u.inheritSummary;break bb0}if(n===`all`){m=u.allSummary;break bb0}if(n===`off`){m=u.offSummary;break bb0}let e=n===`allowlist`?u.allowSummary:u.denySummary,i;t[2]!==r.size||t[3]!==e?(i=e.replace(`{{count}}`,String(r.size)),t[2]=r.size,t[3]=e,t[4]=i):i=t[4],m=i}let h=m,g;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,Z.jsx)(R,{className:`size-3.5`,"aria-hidden":!0}),t[5]=g):g=t[5];let _;t[6]===u.overrideSummaryTitle?_=t[7]:(_=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[g,u.overrideSummaryTitle]}),t[6]=u.overrideSummaryTitle,t[7]=_);let v;t[8]===h?v=t[9]:(v=(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:h}),t[8]=h,t[9]=v);let y;t[10]!==_||t[11]!==v?(y=(0,Z.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/70 px-3 py-2 shadow-surface`,children:[_,v]}),t[10]=_,t[11]=v,t[12]=y):y=t[12];let b;t[13]===u.modeLabel?b=t[14]:(b=(0,Z.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:u.modeLabel}),t[13]=u.modeLabel,t[14]=b);let x;t[15]===u.modeInherit?x=t[16]:(x=[`inherit`,u.modeInherit],t[15]=u.modeInherit,t[16]=x);let S;t[17]===u.modeAll?S=t[18]:(S=[`all`,u.modeAll],t[17]=u.modeAll,t[18]=S);let C;t[19]===u.modeAllowlist?C=t[20]:(C=[`allowlist`,u.modeAllowlist],t[19]=u.modeAllowlist,t[20]=C);let w;t[21]===u.modeDenylist?w=t[22]:(w=[`denylist`,u.modeDenylist],t[21]=u.modeDenylist,t[22]=w);let T;t[23]===u.modeOff?T=t[24]:(T=[`off`,u.modeOff],t[23]=u.modeOff,t[24]=T);let E;t[25]!==w||t[26]!==T||t[27]!==x||t[28]!==S||t[29]!==C?(E=[x,S,C,w,T],t[25]=w,t[26]=T,t[27]=x,t[28]=S,t[29]=C,t[30]=E):E=t[30];let D=E,O;t[31]!==s||t[32]!==n||t[33]!==c||t[34]!==D?(O=(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:D.map(e=>{let[t,r]=e;return(0,Z.jsx)(`button`,{type:`button`,className:o(`rounded-lg px-3 py-2 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,n===t?`bg-accent-soft text-accent-fg`:`bg-surface-panel text-fg hover:bg-surface-hover/55`),disabled:s,onClick:()=>c(t),children:r},t)})}),t[31]=s,t[32]=n,t[33]=c,t[34]=D,t[35]=O):O=t[35];let A;t[36]!==O||t[37]!==b?(A=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[b,O]}),t[36]=O,t[37]=b,t[38]=A):A=t[38];let j;t[39]!==i||t[40]!==p||t[41]!==s||t[42]!==u.emptyCatalog||t[43]!==u.noDescription||t[44]!==u.quickActionsLabel||t[45]!==u.quickClear||t[46]!==u.quickSelectAll||t[47]!==a||t[48]!==l||t[49]!==d||t[50]!==r?(j=d?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Z.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:u.quickActionsLabel}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Z.jsx)(k,{type:`button`,variant:`secondary`,className:q,disabled:s||a||p.length===0,onClick:()=>l(new Set(p)),children:u.quickSelectAll}),(0,Z.jsx)(k,{type:`button`,variant:`secondary`,className:q,disabled:s||a||r.size===0,onClick:()=>l(new Set),children:u.quickClear})]})]}),a?(0,Z.jsx)(ae,{rows:3}):i.length===0?(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:u.emptyCatalog}):(0,Z.jsx)(`ul`,{className:`flex flex-col gap-2.5 text-sm`,children:i.map(e=>{let t=Ae(e),n=r.has(t),i=typeof e.description==`string`?e.description.trim():``,a=i||u.noDescription;return(0,Z.jsx)(`li`,{className:`h-16 shrink-0 overflow-hidden rounded-xl bg-surface-panel/70 px-3 shadow-surface`,children:(0,Z.jsxs)(`label`,{className:`flex h-full cursor-pointer items-center gap-3 text-sm`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`shrink-0 rounded border-edge`,checked:n,disabled:s,onChange:()=>{let e=new Set(r);n?e.delete(t):e.add(t),l(e)},"aria-label":t}),(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1 overflow-hidden`,children:[(0,Z.jsx)(`div`,{className:`truncate font-mono text-xs font-medium text-fg`,title:t,children:t}),(0,Z.jsx)(`p`,{className:o(`mt-0.5 truncate text-xs leading-tight text-fg-muted`,!i&&`italic text-fg-subtle`),title:a,children:a})]})]})},t)})})]}):null,t[39]=i,t[40]=p,t[41]=s,t[42]=u.emptyCatalog,t[43]=u.noDescription,t[44]=u.quickActionsLabel,t[45]=u.quickClear,t[46]=u.quickSelectAll,t[47]=a,t[48]=l,t[49]=d,t[50]=r,t[51]=j):j=t[51];let M;return t[52]!==A||t[53]!==j||t[54]!==y?(M=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[y,A,j]}),t[52]=A,t[53]=j,t[54]=y,t[55]=M):M=t[55],M}var Me=[`write_file`,`apply_patch`,`exec_command`,`execute_code`],Ne=[`exec_command`,`execute_code`,`automation`,`extensions`,`bundle-mcp`,`skill_manage`],$=[`send_message`,`send_media`,`text_to_speech`,`create_share`],Pe=[`read_file`,`list_dir`,`grep`,`find`,`web_search`,`web_fetch`,`web_extract`],Fe=[...Me,...$],Ie=[`read_file`,`write_file`,`apply_patch`,`list_dir`,`grep`,`find`,`web_search`,`web_fetch`],Le=[`send_message`,`send_media`];function Re(e,t){let n={};for(let[r,i]of t)for(let t of r)e.has(t)&&(n[t]={mode:i});return n}function ze(e){let t=(0,_e.c)(100),{builtinToolIds:n,toolPolicies:r,onChange:i,disabled:a,getToolDescription:s,getGroupTitle:c,labels:l}=e,u;t[0]===n?u=t[1]:(u=new Set(n),t[0]=n,t[1]=u);let d=u,f;t[2]!==d||t[3]!==r?(f=Object.entries(r).filter(e=>{let[t]=e;return d.has(t)}).toSorted(Be),t[2]=d,t[3]=r,t[4]=f):f=t[4];let p=f,m;if(t[5]!==d||t[6]!==n){m=[];for(let e of fe){let t=e.toolIds.filter(e=>d.has(e));t.length>0&&m.push({key:e.key,ids:[...t]})}let e;t[8]===n?e=t[9]:(e=se(n),t[8]=n,t[9]=e);let r=e;if(r.length>0){let e;t[10]===r?e=t[11]:(e={key:`misc`,ids:r},t[10]=r,t[11]=e),m.push(e)}t[5]=d,t[6]=n,t[7]=m}else m=t[7];let h=m,g;t[12]!==i||t[13]!==r?(g=(e,t)=>{let n={...r};t===`inherit`?delete n[e]:n[e]={...n[e],mode:t},i(n)},t[12]=i,t[13]=r,t[14]=g):g=t[14];let _=g,v;t[15]!==i||t[16]!==r?(v=(e,t)=>{let n=r[e];n&&i({...r,[e]:t(n)})},t[15]=i,t[16]=r,t[17]=v):v=t[17];let y=v,b;t[18]!==d||t[19]!==i?(b=e=>{i(Re(d,e))},t[18]=d,t[19]=i,t[20]=b):b=t[20];let x=b;if(n.length===0){let e;return t[21]===l.emptyBuiltin?e=t[22]:(e=(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:l.emptyBuiltin}),t[21]=l.emptyBuiltin,t[22]=e),e}let S;t[23]===l.quickActionsLabel?S=t[24]:(S=(0,Z.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:l.quickActionsLabel}),t[23]=l.quickActionsLabel,t[24]=S);let C;t[25]===i?C=t[26]:(C=()=>i({}),t[25]=i,t[26]=C);let w;t[27]!==a||t[28]!==l.quickClearOverrides||t[29]!==C?(w=(0,Z.jsx)(k,{type:`button`,variant:`secondary`,className:q,disabled:a,onClick:C,children:l.quickClearOverrides}),t[27]=a,t[28]=l.quickClearOverrides,t[29]=C,t[30]=w):w=t[30];let T;t[31]===x?T=t[32]:(T=()=>x([[Me,`deny`]]),t[31]=x,t[32]=T);let E;t[33]!==a||t[34]!==l.quickReadOnlyWorkspace||t[35]!==T?(E=(0,Z.jsx)(k,{type:`button`,variant:`secondary`,className:q,disabled:a,onClick:T,children:l.quickReadOnlyWorkspace}),t[33]=a,t[34]=l.quickReadOnlyWorkspace,t[35]=T,t[36]=E):E=t[36];let D;t[37]===x?D=t[38]:(D=()=>x([[Ne,`deny`]]),t[37]=x,t[38]=D);let O;t[39]!==a||t[40]!==l.quickHighRiskOff||t[41]!==D?(O=(0,Z.jsx)(k,{type:`button`,variant:`secondary`,className:q,disabled:a,onClick:D,children:l.quickHighRiskOff}),t[39]=a,t[40]=l.quickHighRiskOff,t[41]=D,t[42]=O):O=t[42];let A;t[43]===x?A=t[44]:(A=()=>x([[$,`deny`]]),t[43]=x,t[44]=A);let j;t[45]!==a||t[46]!==l.quickNoOutbound||t[47]!==A?(j=(0,Z.jsx)(k,{type:`button`,variant:`secondary`,className:q,disabled:a,onClick:A,children:l.quickNoOutbound}),t[45]=a,t[46]=l.quickNoOutbound,t[47]=A,t[48]=j):j=t[48];let M;t[49]===x?M=t[50]:(M=()=>x([[Pe,`allow`],[Fe,`deny`]]),t[49]=x,t[50]=M);let N;t[51]!==a||t[52]!==l.quickResearchMode||t[53]!==M?(N=(0,Z.jsx)(k,{type:`button`,variant:`secondary`,className:q,disabled:a,onClick:M,children:l.quickResearchMode}),t[51]=a,t[52]=l.quickResearchMode,t[53]=M,t[54]=N):N=t[54];let P;t[55]===x?P=t[56]:(P=()=>x([[Ie,`allow`],[Le,`deny`]]),t[55]=x,t[56]=P);let F;t[57]!==a||t[58]!==l.quickCodingMode||t[59]!==P?(F=(0,Z.jsx)(k,{type:`button`,variant:`secondary`,className:q,disabled:a,onClick:P,children:l.quickCodingMode}),t[57]=a,t[58]=l.quickCodingMode,t[59]=P,t[60]=F):F=t[60];let I;t[61]!==O||t[62]!==j||t[63]!==N||t[64]!==F||t[65]!==w||t[66]!==E?(I=(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[w,E,O,j,N,F]}),t[61]=O,t[62]=j,t[63]=N,t[64]=F,t[65]=w,t[66]=E,t[67]=I):I=t[67];let L;t[68]!==I||t[69]!==S?(L=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[S,I]}),t[68]=I,t[69]=S,t[70]=L):L=t[70];let R;t[71]===l.overrideSummaryTitle?R=t[72]:(R=(0,Z.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:l.overrideSummaryTitle}),t[71]=l.overrideSummaryTitle,t[72]=R);let z;t[73]!==l.modeAllow||t[74]!==l.modeConfirm||t[75]!==l.modeDeny||t[76]!==l.noOverrides||t[77]!==p?(z=p.length>0?(0,Z.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:p.map(e=>{let[t,n]=e;return(0,Z.jsxs)(`span`,{className:o(`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 font-mono text-[11px]`,n.mode===`deny`&&`border-red-500/25 bg-red-500/10 text-red-700 dark:text-red-300`,n.mode===`confirm`&&`border-amber-500/25 bg-amber-500/10 text-amber-700 dark:text-amber-300`,n.mode===`allow`&&`border-accent/25 bg-accent/10 text-accent`),children:[t,(0,Z.jsx)(`span`,{className:`font-sans opacity-80`,children:n.mode===`allow`?l.modeAllow:n.mode===`confirm`?l.modeConfirm:l.modeDeny})]},t)})}):(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:l.noOverrides}),t[73]=l.modeAllow,t[74]=l.modeConfirm,t[75]=l.modeDeny,t[76]=l.noOverrides,t[77]=p,t[78]=z):z=t[78];let B;t[79]!==R||t[80]!==z?(B=(0,Z.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/70 px-3 py-2 shadow-surface`,children:[R,z]}),t[79]=R,t[80]=z,t[81]=B):B=t[81];let V;t[82]!==a||t[83]!==c||t[84]!==s||t[85]!==h||t[86]!==l.inheritedMode||t[87]!==l.maxCallsLabel||t[88]!==l.modeAllow||t[89]!==l.modeConfirm||t[90]!==l.modeDeny||t[91]!==l.timeoutLabel||t[92]!==_||t[93]!==r||t[94]!==y?(V=(0,Z.jsx)(`div`,{className:`flex flex-col gap-5`,children:h.map(e=>{let{key:t,ids:n}=e;return(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`h4`,{className:`mb-2 text-xs font-semibold uppercase tracking-wide text-fg-muted`,children:c(t)}),(0,Z.jsx)(`ul`,{className:`flex flex-col gap-2.5`,children:n.map(e=>{let t=s(e),n=r[e],i=n?n.mode:`inherit`;return(0,Z.jsxs)(`li`,{className:o(`rounded-xl px-3 py-2.5 shadow-surface transition-colors`,i===`inherit`?`bg-surface-panel/50`:`bg-surface-panel`),children:[(0,Z.jsxs)(`div`,{className:`grid gap-2 md:grid-cols-[minmax(0,1fr)_auto] md:items-center`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`font-mono text-xs font-medium text-fg`,children:e}),t?(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:t}):null]}),(0,Z.jsx)(`div`,{className:`inline-flex w-fit rounded-lg border border-edge-subtle bg-surface-base p-0.5`,children:[`inherit`,`allow`,`confirm`,`deny`].map(t=>(0,Z.jsx)(`button`,{type:`button`,className:o(`rounded-md px-2.5 py-1.5 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,i===t?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:text-fg`),disabled:a,onClick:()=>_(e,t),children:t===`inherit`?l.inheritedMode:t===`allow`?l.modeAllow:t===`confirm`?l.modeConfirm:l.modeDeny},t))})]}),n?(0,Z.jsxs)(`div`,{className:`mt-3 grid gap-2 border-t border-edge-subtle pt-3 sm:grid-cols-2 dark:border-edge`,children:[(0,Z.jsx)(He,{label:l.maxCallsLabel,value:n.limits?.maxCallsPerTurn,disabled:a,onChange:t=>y(e,e=>Ve(e,`maxCallsPerTurn`,t))}),(0,Z.jsx)(He,{label:l.timeoutLabel,value:n.limits?.timeoutMs,disabled:a,onChange:t=>y(e,e=>Ve(e,`timeoutMs`,t))})]}):null]},e)})})]},t)})}),t[82]=a,t[83]=c,t[84]=s,t[85]=h,t[86]=l.inheritedMode,t[87]=l.maxCallsLabel,t[88]=l.modeAllow,t[89]=l.modeConfirm,t[90]=l.modeDeny,t[91]=l.timeoutLabel,t[92]=_,t[93]=r,t[94]=y,t[95]=V):V=t[95];let H;return t[96]!==L||t[97]!==B||t[98]!==V?(H=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[L,B,V]}),t[96]=L,t[97]=B,t[98]=V,t[99]=H):H=t[99],H}function Be(e,t){let[n]=e,[r]=t;return n.localeCompare(r)}function Ve(e,t,n){let r={...e.limits};if(n===void 0?delete r[t]:r[t]=n,Object.keys(r).length===0){let{limits:t,...n}=e;return n}return{...e,limits:r}}function He(e){let t=(0,_e.c)(9),n=e.value??``,r;t[0]===e?r=t[1]:(r=t=>{let n=t.target.value.trim();e.onChange(n?Number(n):void 0)},t[0]=e,t[1]=r);let i;t[2]!==e.disabled||t[3]!==n||t[4]!==r?(i=(0,Z.jsx)(`input`,{type:`number`,min:1,step:1,className:`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg focus:border-edge-strong focus:outline-none`,value:n,disabled:e.disabled,onChange:r}),t[2]=e.disabled,t[3]=n,t[4]=r,t[5]=i):i=t[5];let a;return t[6]!==e.label||t[7]!==i?(a=(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-fg-muted`,children:[e.label,i]}),t[6]=e.label,t[7]=i,t[8]=a):a=t[8],a}var Ue=[`blank`,`safe-coder`,`read-only`,`low-cost`],We=[{id:`overview`,icon:g},{id:`models`,icon:d},{id:`tools`,icon:V},{id:`skills`,icon:N},{id:`advanced`,icon:D},{id:`impact`,icon:I}];function Ge(e){return he(Object.entries(e?.models?.roles??{}).map(([e,t])=>({id:e,model:t.model,fallbacks:t.fallbacks??[],description:t.description})))}function Ke(e){return structuredClone(e?.tools?.builtin??{})}function qe(e){let t=e?.skills;if(!t)return new Set;let n=t.mode===`denylist`?t.deny:t.allow;return new Set(n??[])}function Je(){return{primary:``,fallbacks:[],timeoutMs:``,autoProviderFallback:``}}function Ye(e){return{primary:e?.primary??``,fallbacks:[...e?.fallbacks??[]],timeoutMs:e?.timeoutMs?String(e.timeoutMs):``,autoProviderFallback:e?.autoProviderFallback===void 0?``:e.autoProviderFallback?`true`:`false`}}function Xe(){return{imageModel:Je(),imageGenerationModel:Je(),allowFallbacks:``,maxCostTier:``}}function Ze(e){return{imageModel:Ye(e?.models?.imageModel),imageGenerationModel:Ye(e?.models?.imageGenerationModel),allowFallbacks:e?.models?.policy?.allowFallbacks===void 0?``:e.models.policy.allowFallbacks?`true`:`false`,maxCostTier:e?.models?.policy?.maxCostTier??``}}function Qe(e){return{mcp:structuredClone(e?.tools?.mcp),workflows:structuredClone(e?.workflows),boundaries:structuredClone(e?.boundaries),runtime:structuredClone(e?.runtime),locks:structuredClone(e?.locks)}}function $e(e){return{id:e?.id??``,name:e?.name??``,description:e?.description??``,modelRows:Ge(e),modelAdvanced:Ze(e),toolPolicies:Ke(e),skillMode:e?.skills?.mode??`inherit`,skillPick:qe(e),extendsIds:[...e?.extends??[]],advancedPolicy:Qe(e)}}function et(e,t){let n={id:e.id,name:e.name,version:1,usage:[],inherited:{},inheritedSources:{},...t};return{...e,modelRows:Ge(n),modelAdvanced:Ze(n),toolPolicies:Ke(n),skillMode:n.skills?.mode??`inherit`,skillPick:qe(n),extendsIds:[...n.extends??[]],advancedPolicy:Qe(n)}}function tt(e){let t=e.primary.trim();if(!t)return;let n=e.fallbacks.map(e=>e.trim()).filter(Boolean),r=e.timeoutMs.trim()?Number(e.timeoutMs):void 0,i=e.autoProviderFallback===``?void 0:e.autoProviderFallback===`true`;return{primary:t,...n.length>0?{fallbacks:n}:{},...r?{timeoutMs:r}:{},...i===void 0?{}:{autoProviderFallback:i}}}function nt(e,t){let n=Y(e.modelRows),r=tt(e.modelAdvanced.imageModel),i=tt(e.modelAdvanced.imageGenerationModel),a=e.modelAdvanced.allowFallbacks||e.modelAdvanced.maxCostTier?{...e.modelAdvanced.allowFallbacks?{allowFallbacks:e.modelAdvanced.allowFallbacks===`true`}:{},...e.modelAdvanced.maxCostTier?{maxCostTier:e.modelAdvanced.maxCostTier}:{}}:void 0,o={...t?.models?.defaultRole?{defaultRole:t.models.defaultRole}:{},...n?.roles?{roles:n.roles}:{},...r?{imageModel:r}:{},...i?{imageGenerationModel:i}:{},...a?{policy:a}:{}};return Object.keys(o).length>0?o:null}function rt(e){let t=Object.fromEntries(Object.entries(e.toolPolicies).toSorted(([e],[t])=>e.localeCompare(t))),n=e.advancedPolicy.mcp;return Object.keys(t).length>0||n?{builtin:t,...n?{mcp:n}:{}}:null}function it(e){return Object.fromEntries(Object.entries(e??{}).toSorted(([e],[t])=>e.localeCompare(t)))}function at(e){if(e.skillMode===`inherit`)return null;let t=[...e.skillPick].toSorted((e,t)=>e.localeCompare(t));return e.skillMode===`allowlist`?{mode:`allowlist`,allow:t}:e.skillMode===`denylist`?{mode:`denylist`,deny:t}:{mode:e.skillMode}}function ot(e,t){return{id:e.id.trim(),name:e.name.trim(),description:e.description.trim(),models:nt(e,t),tools:{builtin:it(e.toolPolicies),mcp:e.advancedPolicy.mcp},skills:at(e),extends:[...e.extendsIds].toSorted(),workflows:e.advancedPolicy.workflows,boundaries:e.advancedPolicy.boundaries,runtime:e.advancedPolicy.runtime,locks:e.advancedPolicy.locks}}function st(e){return e?{id:e.id,name:e.name,description:e.description??``,models:e.models??null,tools:{builtin:it(e.tools?.builtin),mcp:e.tools?.mcp},skills:e.skills??null,extends:[...e.extends??[]].toSorted(),workflows:e.workflows,boundaries:e.boundaries,runtime:e.runtime,locks:e.locks}:null}function ct(e,t){return[e.models?.roles?t.summaryModels.replace(`{{count}}`,String(Object.keys(e.models.roles).length)):``,e.tools?.builtin?t.summaryTools.replace(`{{count}}`,String(Object.keys(e.tools.builtin).length)):``,e.skills?t.summarySkills.replace(`{{mode}}`,t.skillModeLabels[e.skills.mode]):``].filter(Boolean).join(` · `)||t.summaryEmpty}function lt(e){return e===void 0?`—`:typeof e==`string`?e:JSON.stringify(e)}function ut(){return{modelAdvanced:Xe(),extendsIds:[],advancedPolicy:{}}}function dt(e,t){return{extends:[...e.extendsIds],models:nt(e,t)??void 0,tools:rt(e)??void 0,skills:at(e)??void 0,workflows:e.advancedPolicy.workflows,boundaries:e.advancedPolicy.boundaries,runtime:e.advancedPolicy.runtime,locks:e.advancedPolicy.locks}}function ft(e,t){return e===`safe-coder`?{id:`safe-coder`,name:t.starters[`safe-coder`].title,description:t.starters[`safe-coder`].description,modelRows:[{id:`deep`,model:``,fallbacks:[],description:t.modelRoleDescriptions.deep},{id:`code`,model:``,fallbacks:[],description:t.modelRoleDescriptions.code},{id:`review`,model:``,fallbacks:[],description:t.modelRoleDescriptions.review}],toolPolicies:{exec_command:{mode:`deny`},send_message:{mode:`deny`},send_media:{mode:`deny`}},skillMode:`allowlist`,skillPick:new Set([`diagnose`,`tdd`]),...ut()}:e===`read-only`?{id:`read-only-research`,name:t.starters[`read-only`].title,description:t.starters[`read-only`].description,modelRows:[{id:`deep`,model:``,fallbacks:[],description:t.modelRoleDescriptions.deep},{id:`fast`,model:``,fallbacks:[],description:t.modelRoleDescriptions.fast}],toolPolicies:{write_file:{mode:`deny`},apply_patch:{mode:`deny`},exec_command:{mode:`deny`},send_message:{mode:`deny`},send_media:{mode:`deny`}},skillMode:`all`,skillPick:new Set,...ut()}:e===`low-cost`?{id:`low-cost-assistant`,name:t.starters[`low-cost`].title,description:t.starters[`low-cost`].description,modelRows:[{id:`deep`,model:``,fallbacks:[],description:t.modelRoleDescriptions.deep},{id:`fast`,model:``,fallbacks:[],description:t.modelRoleDescriptions.fast},{id:`cheap`,model:``,fallbacks:[],description:t.modelRoleDescriptions.cheap}],toolPolicies:{},skillMode:`inherit`,skillPick:new Set,...ut()}:{id:``,name:``,description:``,modelRows:[],toolPolicies:{},skillMode:`inherit`,skillPick:new Set,...ut()}}function pt(){let e=s(l(e=>e.language)),t=e.capabilityPresetsSettings,n=(0,Z.jsx)(k,{asChild:!0,type:`button`,variant:`secondary`,children:(0,Z.jsxs)(a,{to:`/agents`,children:[t.manageAgents,(0,Z.jsx)(M,{className:`size-4`,"aria-hidden":!0})]})}),r=!!c(e=>e.token),{data:p,error:m,isLoading:y,mutate:w}=u(r?`settings-capability-presets`:null,ce,{revalidateOnFocus:!1}),{data:T=[],isLoading:R}=u(r?`settings-capability-presets-skills-catalog`:null,H,{revalidateOnFocus:!1}),z=p?.mcpServerIds??[],{data:ee=[]}=u(r&&z.length?[`capability-preset-mcp-tools`,...z]:null,()=>de(z),{revalidateOnFocus:!1}),[U,W]=i(),[se,fe]=(0,X.useState)(``),[he,q]=(0,X.useState)(`overview`),[J,Y]=(0,X.useState)(()=>ft(`blank`,t)),[ge,_e]=(0,X.useState)(null),[Q,ve]=(0,X.useState)(!1),[be,xe]=(0,X.useState)(null),[Se,Ce]=(0,X.useState)(!1),[we,Te]=(0,X.useState)(null),[De,Oe]=(0,X.useState)(null),ke=p?.presets??[],Ae=p?.defaultPresetId??`default`,Me=ke.find(e=>e.id===Ae)??null,Ne=ke.filter(e=>e.id!==Ae),$=(0,X.useMemo)(()=>ke.find(e=>e.id===se)??ke[0]??null,[ke,se]),Pe=!$||J.id.trim()!==$.id,Fe=!!($&&$.id===Ae),Ie=JSON.stringify(ot(J,$))!==JSON.stringify(st($)),Le=ot(J,$),Re=st($),Be=[Le.id!==Re?.id||Le.name!==Re?.name||Le.description!==Re?.description?t.tabs.overview:``,JSON.stringify(Le.models)===JSON.stringify(Re?.models)?``:t.tabs.models,JSON.stringify(Le.tools)===JSON.stringify(Re?.tools)?``:t.tabs.tools,JSON.stringify(Le.skills)===JSON.stringify(Re?.skills)?``:t.tabs.skills,JSON.stringify({extends:Le.extends,workflows:Le.workflows,boundaries:Le.boundaries,runtime:Le.runtime,locks:Le.locks})===JSON.stringify({extends:Re?.extends,workflows:Re?.workflows,boundaries:Re?.boundaries,runtime:Re?.runtime,locks:Re?.locks})?``:t.tabs.advanced].filter(Boolean),Ve=(0,X.useMemo)(()=>{if(!$||Pe)return null;let e=dt(J,$);return{name:J.name.trim(),description:J.description.trim()||null,extends:e.extends??null,models:e.models??null,tools:e.tools??null,skills:e.skills??null,workflows:e.workflows??null,boundaries:e.boundaries??null,runtime:e.runtime??null,locks:e.locks??null}},[J,Pe,$]),{data:He,error:Ge,isLoading:Ke}=u(he===`impact`&&$&&Ve?[`capability-preset-impact-preview`,$.id,JSON.stringify(Ve)]:null,()=>oe($.id,Ve),{revalidateOnFocus:!1}),qe=be??(m instanceof Error?m.message:null),Je=U.get(`action`)===`new`||!!U.get(`preset`),Ye=U.get(`action`)===`new`&&ge===null,Xe=Pe?t.newPreset:$?.name??t.editorTitle,Ze=t=>e.agentsSettings.toolsDisableGroups[t],Qe=t=>t in e.agentsSettings.toolDescriptions?e.agentsSettings.toolDescriptions[t]:``;(0,X.useEffect)(()=>{if(!p||Q)return;if(U.get(`action`)===`new`){fe(``),Y(ft(`blank`,t)),q(`overview`);return}let e=U.get(`preset`)?.trim(),n=e?p.presets.find(t=>t.id===e):null;if(n){fe(n.id),Y($e(n)),q(U.get(`tab`)??`overview`);return}$&&(fe($.id),Y(e=>e.id===$.id?e:$e($)))},[Q,p,U,$]);function tt(e){_e(null),fe(e.id),Y($e(e)),W({preset:e.id},{replace:!0}),q(`overview`)}function nt(){_e(null),fe(``),Y(ft(`blank`,t)),xe(null),W({action:`new`},{replace:!0}),q(`overview`)}function rt(e){_e(e),Y(ft(e,t)),xe(null),q(`overview`)}function it(){if(ge){let e=ft(ge,t);if(JSON.stringify(ot(J,null))!==JSON.stringify(ot(e,null))&&!window.confirm(t.changeTemplateConfirm))return}_e(null),xe(null)}function at(){!Ye&&Ie&&!window.confirm(t.discardConfirm)||(Ce(!1),Te(null),W({},{replace:!0}),_e(null),xe(null),Y($e($)),q(`overview`))}async function ut(){let e=me(J.modelRows,{invalidId:t.invalidModelRoleId,duplicateId:t.duplicateModelRoleId,invalidModel:t.invalidModelRef});if(e){xe(e),q(`models`);return}for(let e of[J.modelAdvanced.imageModel,J.modelAdvanced.imageGenerationModel]){if([e.primary,...e.fallbacks].map(e=>e.trim()).filter(Boolean).some(e=>!/^[^/\s]+\/.+/.test(e))){xe(t.invalidModelRef),q(`models`);return}if(e.timeoutMs.trim()&&(!Number.isInteger(Number(e.timeoutMs))||Number(e.timeoutMs)<=0)){xe(t.advancedPositiveIntegerError),q(`models`);return}}for(let e of Object.values(J.toolPolicies))if([e.limits?.maxCallsPerTurn,e.limits?.timeoutMs].filter(e=>e!==void 0).some(e=>!Number.isInteger(e)||e<=0)){xe(t.advancedPositiveIntegerError),q(`tools`);return}ve(!0),xe(null);try{let e=dt(J,$);if(Pe){let t=await pe({id:J.id.trim(),name:J.name.trim(),...J.description.trim()?{description:J.description.trim()}:{},...e});await w(t.presets,{revalidate:!1}),fe(t.presetId),_e(null),W({preset:t.presetId},{replace:!0})}else $&&await w(await ue($.id,{name:J.name.trim(),description:J.description.trim()||null,extends:e.extends??null,models:e.models??null,tools:e.tools??null,skills:e.skills??null,workflows:e.workflows??null,boundaries:e.boundaries??null,runtime:e.runtime??null,locks:e.locks??null}),{revalidate:!1})}catch(e){xe(e instanceof Error?e.message:t.saveError)}finally{ve(!1)}}async function pt(){if($){ve(!0),xe(null),Te(null);try{await w(await le($.id),{revalidate:!1}),Ce(!1),fe(``),_e(null),Y(ft(`blank`,t)),q(`overview`),W({},{replace:!0})}catch(e){Te(e instanceof Error?e.message:t.deleteError)}finally{ve(!1)}}}return r?(0,Z.jsxs)(re,{gap:`gap-5`,className:`pb-24`,children:[(0,Z.jsx)(ne,{title:t.title,subtitle:t.subtitle,actions:(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2`,children:[n,(0,Z.jsxs)(k,{type:`button`,onClick:nt,disabled:Q,children:[(0,Z.jsx)(P,{className:`size-4`,"aria-hidden":!0}),t.newPreset]})]})}),qe?(0,Z.jsx)(`div`,{className:`rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-200`,children:qe}):null,y?(0,Z.jsx)(ie,{sections:2}):(0,Z.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[Me?(0,Z.jsxs)(K,{children:[(0,Z.jsx)(G,{icon:d,title:t.globalDefaultsTitle,subtitle:t.globalDefaultsHint}),(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>tt(Me),className:`group rounded-lg bg-accent/5 px-4 py-3 text-left text-fg shadow-surface transition-colors hover:bg-accent/10 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-semibold text-fg`,children:Me.name}),(0,Z.jsx)(`span`,{className:`rounded-full bg-surface-panel px-2 py-0.5 text-[11px] font-medium text-accent`,children:t.globalDefaultsBadge})]}),(0,Z.jsx)(`div`,{className:`mt-1 font-mono text-[11px] text-fg-subtle`,children:Me.id})]}),(0,Z.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-panel px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:t.globalDefaultsInherited})]}),Me.description?(0,Z.jsx)(`p`,{className:`mt-3 line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:Me.description}):null,(0,Z.jsx)(`div`,{className:`mt-3 text-xs text-fg-subtle`,children:ct(Me,t)})]})]}):null,(0,Z.jsxs)(K,{children:[(0,Z.jsx)(G,{icon:d,title:t.listTitle,subtitle:t.listHint}),Ne.length===0?(0,Z.jsxs)(`div`,{className:`flex flex-col items-start gap-3 rounded-lg bg-surface-panel/70 px-3 py-4 text-sm text-fg-muted shadow-surface`,children:[(0,Z.jsx)(`p`,{children:t.empty}),(0,Z.jsxs)(k,{type:`button`,variant:`secondary`,onClick:nt,disabled:Q,children:[(0,Z.jsx)(P,{className:`size-4`,"aria-hidden":!0}),t.newPreset]})]}):(0,Z.jsx)(`div`,{className:`grid gap-3 md:grid-cols-2 xl:grid-cols-3`,children:Ne.map(e=>(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>tt(e),className:`group min-h-36 rounded-lg bg-surface-panel/80 px-4 py-3 text-left text-fg shadow-surface transition-colors hover:bg-surface-hover/55 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`truncate text-sm font-semibold text-fg`,children:e.name}),(0,Z.jsx)(`div`,{className:`mt-1 truncate font-mono text-[11px] text-fg-subtle`,children:e.id})]}),(0,Z.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:e.usage.length})]}),e.description?(0,Z.jsx)(`p`,{className:`mt-3 line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:e.description}):null,(0,Z.jsx)(`div`,{className:`mt-3 truncate text-xs text-fg-subtle`,children:ct(e,t)})]},e.id))})]})]}),(0,Z.jsx)(b,{open:Je,onOpenChange:e=>{e||at()},children:(0,Z.jsxs)(v,{children:[(0,Z.jsx)(_,{className:o(`xopc-dialog-overlay fixed inset-0 bg-scrim`,O)}),(0,Z.jsx)(f,{ref:Oe,className:o(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(90vh,760px)] w-[min(100%-2rem,64rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-popover dark:border-edge`,E),onOpenAutoFocus:e=>e.preventDefault(),children:(0,Z.jsxs)(h,{layer:`modal`,portalContainer:De,children:[(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-4 py-3 dark:border-edge`,children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[!Ye&&Pe&&ge?(0,Z.jsx)(`button`,{type:`button`,className:o(B,`shrink-0 p-1.5 hover:bg-surface-base`),onClick:it,"aria-label":t.changeTemplate,title:t.changeTemplate,children:(0,Z.jsx)(C,{className:`size-4`,"aria-hidden":!0})}):null,(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(x,{className:`truncate text-base font-semibold text-fg`,children:Xe}),(0,Z.jsx)(F,{className:`mt-0.5 truncate text-xs text-fg-muted`,children:Ye?t.templatePickerSubtitle:Pe&&ge?`${t.editorHint} · ${t.basedOnTemplate.replace(`{{template}}`,t.starters[ge].title)}`:Pe?t.editorHint:J.id})]})]}),(0,Z.jsx)(L,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:o(B,`shrink-0 p-1.5 hover:bg-surface-base`),"aria-label":t.closeDialog,children:(0,Z.jsx)(j,{className:`size-4`,"aria-hidden":!0})})})]}),Ye?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-4 sm:p-5`,children:(0,Z.jsx)(`div`,{className:`mx-auto grid max-w-3xl gap-3 sm:grid-cols-2`,children:Ue.map(e=>(0,Z.jsxs)(`button`,{type:`button`,className:`group min-h-32 rounded-xl border border-edge-subtle bg-surface-base px-4 py-4 text-left text-fg transition-colors hover:border-edge hover:bg-surface-hover/55 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,onClick:()=>rt(e),children:[(0,Z.jsxs)(`span`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsx)(`span`,{className:`font-medium`,children:t.starters[e].title}),e===`blank`?(0,Z.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,children:t.templateRecommended}):null]}),(0,Z.jsx)(`span`,{className:`mt-2 block text-xs leading-relaxed text-fg-muted`,children:t.starters[e].description})]},e))})}),(0,Z.jsx)(`div`,{className:`flex shrink-0 justify-end border-t border-edge-subtle px-4 py-3 dark:border-edge`,children:(0,Z.jsx)(k,{type:`button`,variant:`secondary`,onClick:at,children:t.cancel})})]}):(0,Z.jsxs)(Z.Fragment,{children:[qe?(0,Z.jsx)(`div`,{className:`mx-4 mt-3 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-200`,children:qe}):null,(0,Z.jsx)(`div`,{className:`flex shrink-0 flex-wrap gap-2 border-b border-edge-subtle bg-surface-base px-4 py-2 dark:border-edge`,children:We.map(({id:e,icon:n})=>(0,Z.jsxs)(`button`,{type:`button`,className:o(`inline-flex items-center gap-1.5 rounded-lg px-3 py-2 text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,he===e?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),onClick:()=>q(e),children:[(0,Z.jsx)(n,{className:`size-4`,"aria-hidden":!0}),t.tabs[e]]},e))}),(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-4`,children:(0,Z.jsxs)(`div`,{className:`w-full`,children:[he===`overview`?(0,Z.jsxs)(K,{children:[(0,Z.jsx)(G,{icon:g,title:t.overviewTitle,subtitle:t.overviewHint}),(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:t.idLabel}),(0,Z.jsx)(`input`,{className:`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:border-edge-strong focus:outline-none`,value:J.id,disabled:Q||!Pe,onChange:e=>Y(t=>({...t,id:e.target.value.toLowerCase()})),placeholder:`safe-coder`})]}),!Pe&&$?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-sm`,children:[(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:t.versionLabel}),(0,Z.jsx)(`div`,{className:`rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg-muted`,children:t.versionAutomatic.replace(`{{version}}`,String($.version))})]}):null,(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:t.nameLabel}),(0,Z.jsx)(`input`,{className:`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:border-edge-strong focus:outline-none`,value:J.name,disabled:Q,onChange:e=>Y(t=>({...t,name:e.target.value})),placeholder:t.namePlaceholder})]}),(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm sm:col-span-2`,children:[(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:t.descriptionLabel}),(0,Z.jsx)(`textarea`,{className:`min-h-24 w-full resize-y rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:border-edge-strong focus:outline-none`,value:J.description,disabled:Q,onChange:e=>Y(t=>({...t,description:e.target.value})),placeholder:t.descriptionPlaceholder})]})]}),(0,Z.jsxs)(`div`,{className:`mt-5 grid gap-2 sm:grid-cols-3`,children:[(0,Z.jsx)(mt,{icon:d,label:t.modelsTitle,value:String(J.modelRows.length)}),(0,Z.jsx)(mt,{icon:V,label:t.toolsTitle,value:String(Object.keys(J.toolPolicies).length)}),(0,Z.jsx)(mt,{icon:N,label:t.skillsTitle,value:t.skillModeLabels[J.skillMode]})]})]}):null,he===`models`?(0,Z.jsxs)(K,{children:[(0,Z.jsx)(G,{icon:d,title:t.modelsTitle,subtitle:t.modelsHint}),(0,Z.jsx)(ye,{rows:J.modelRows,onChange:e=>Y(t=>({...t,modelRows:e})),disabled:Q,defaultRole:$?.models?.defaultRole,chat:e.chat,labels:{defaultTitle:t.modelDefaultTitle,defaultHint:t.modelDefaultHint,defaultBadge:t.modelDefaultBadge,roleId:t.modelRoleIdLabel,description:t.modelRoleDescriptionLabel,descriptionPlaceholder:t.modelRoleDescriptionPlaceholder,primaryModel:t.modelPrimaryModelLabel,fallbackModels:t.modelFallbackModelsLabel,addFallback:t.modelAddFallback,removeFallback:t.modelRemoveFallback,fallbackPlaceholder:t.modelFallbackPlaceholder,fallbackEmptyHint:t.modelFallbackEmptyHint,moreSettings:t.modelMoreSettings,otherRolesTitle:t.modelOtherRolesTitle,otherRolesHint:t.modelOtherRolesHint,otherRolesEmpty:t.modelOtherRolesEmpty,addTaskModel:t.modelAddTaskModel,customRole:t.modelCustomRole,removeRole:t.removeModelRole,roleIdPlaceholder:`custom-role`,roleNames:t.modelRoleNames,roleDescriptions:t.modelRoleDescriptions}}),(0,Z.jsx)(ht,{value:J.modelAdvanced,onChange:e=>Y(t=>({...t,modelAdvanced:e})),disabled:Q,cp:t,chat:e.chat})]}):null,he===`tools`?(0,Z.jsxs)(K,{children:[(0,Z.jsx)(G,{icon:V,title:t.toolsTitle,subtitle:t.toolsHint}),(0,Z.jsx)(ze,{builtinToolIds:p?.builtinToolIds??[],toolPolicies:J.toolPolicies,onChange:e=>Y(t=>({...t,toolPolicies:e})),disabled:Q,getToolDescription:Qe,getGroupTitle:Ze,labels:{quickActionsLabel:t.toolsQuickActionsLabel,quickClearOverrides:t.toolsQuickClearOverrides,quickReadOnlyWorkspace:t.toolsQuickReadOnlyWorkspace,quickHighRiskOff:t.toolsQuickHighRiskOff,quickNoOutbound:t.toolsQuickNoOutbound,quickResearchMode:t.toolsQuickResearchMode,quickCodingMode:t.toolsQuickCodingMode,emptyBuiltin:t.toolsEmptyBuiltin,overrideSummaryTitle:t.toolsOverrideSummaryTitle,noOverrides:t.toolsNoOverrides,inheritedMode:t.toolModes.inherit,modeAllow:t.toolModes.allow,modeConfirm:t.toolModes.confirm,modeDeny:t.toolModes.deny,maxCallsLabel:t.toolMaxCallsLabel,timeoutLabel:t.toolTimeoutLabel}})]}):null,he===`skills`?(0,Z.jsxs)(K,{children:[(0,Z.jsx)(G,{icon:N,title:t.skillsTitle,subtitle:t.skillsHint}),(0,Z.jsx)(je,{mode:J.skillMode,selected:J.skillPick,catalog:T,loading:R,disabled:Q,onModeChange:e=>Y(t=>({...t,skillMode:e})),onSelectedChange:e=>Y(t=>({...t,skillPick:e})),labels:{modeLabel:t.skillsModeLabel,modeInherit:t.skillsModeInherit,modeAll:t.skillsModeAll,modeAllowlist:t.skillsModeAllowlist,modeDenylist:t.skillsModeDenylist,modeOff:t.skillsModeOff,quickActionsLabel:t.skillsQuickActionsLabel,quickSelectAll:t.skillsQuickSelectAll,quickClear:t.skillsQuickClear,catalogLoading:t.skillsCatalogLoading,emptyCatalog:t.skillsEmptyCatalog,noDescription:t.skillsNoDescription,overrideSummaryTitle:t.skillsOverrideSummaryTitle,inheritSummary:t.skillsInheritSummary,allSummary:t.skillsAllSummary,offSummary:t.skillsOffSummary,allowSummary:t.skillsAllowSummary,denySummary:t.skillsDenySummary}})]}):null,he===`advanced`?(0,Z.jsxs)(K,{children:[(0,Z.jsx)(G,{icon:D,title:t.advancedTitle,subtitle:t.advancedHint}),(0,Z.jsx)(Ee,{extendsIds:J.extendsIds,onExtendsChange:e=>Y(t=>({...t,extendsIds:e})),presetOptions:ke.filter(e=>e.id!==$?.id&&e.id!==Ae),inherited:JSON.stringify(J.extendsIds)===JSON.stringify($?.extends??[])?$?.inherited:void 0,inheritedSources:JSON.stringify(J.extendsIds)===JSON.stringify($?.extends??[])?$?.inheritedSources:void 0,mcpServerIds:p?.mcpServerIds??[],mcpTools:ee,workflows:p?.workflows??[],policy:J.advancedPolicy,onPolicyChange:e=>Y(t=>({...t,advancedPolicy:e})),rawPolicy:dt(J,$),onRawPolicyChange:e=>Y(t=>et(t,e)),disabled:Q,labels:{inheritanceTitle:t.advancedInheritanceTitle,inheritanceHint:t.advancedInheritanceHint,inheritanceEmpty:t.advancedInheritanceEmpty,inheritanceAvailable:t.advancedInheritanceAvailable,inheritanceAdd:t.advancedInheritanceAdd,inheritanceRemove:t.advancedInheritanceRemove,inheritanceMoveUp:t.advancedInheritanceMoveUp,inheritanceMoveDown:t.advancedInheritanceMoveDown,compose:t.advancedCompose,inherit:t.advancedInherit,cancel:t.cancel,mcpTitle:t.advancedMcpTitle,mcpHint:t.advancedMcpHint,noMcp:t.advancedNoMcp,workflowsTitle:t.advancedWorkflowsTitle,workflowsHint:t.advancedWorkflowsHint,defaultWorkflow:t.advancedDefaultWorkflow,allowedWorkflows:t.advancedAllowedWorkflows,runtimeTitle:t.advancedRuntimeTitle,runtimeHint:t.advancedRuntimeHint,timeoutMinutes:t.advancedTimeoutMinutes,maxTurns:t.advancedMaxTurns,maxFailures:t.advancedMaxFailures,maxCalls:t.toolMaxCallsLabel,boundariesTitle:t.advancedBoundariesTitle,boundariesHint:t.advancedBoundariesHint,confirmRules:t.advancedConfirmRules,forbiddenRules:t.advancedForbiddenRules,escalationRules:t.advancedEscalationRules,onePerLine:t.advancedOnePerLine,governanceTitle:t.advancedGovernanceTitle,governanceHint:t.advancedGovernanceHint,locksLabel:t.advancedLocksLabel,rawTitle:t.advancedRawTitle,rawHint:t.advancedRawHint,rawOpen:t.advancedRawOpen,rawApply:t.advancedRawApply,rawInvalid:t.advancedRawInvalid,modeAllow:t.toolModes.allow,modeConfirm:t.toolModes.confirm,modeDeny:t.toolModes.deny,readonlyOnly:t.toolScopeReadonly}})]}):null,he===`impact`?(0,Z.jsxs)(K,{children:[(0,Z.jsx)(G,{icon:I,title:t.usageTitle,subtitle:t.usageHint}),(0,Z.jsxs)(`div`,{className:`mb-4 rounded-lg bg-surface-panel/70 px-3 py-2 shadow-surface`,children:[(0,Z.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:t.changePreviewTitle}),(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:Be.length>0?t.changePreviewSections.replace(`{{sections}}`,Be.join(`、`)):t.changePreviewEmpty})]}),Pe?null:(0,Z.jsxs)(`div`,{className:`mb-4`,children:[(0,Z.jsx)(`div`,{className:`mb-2 text-xs font-semibold uppercase tracking-wide text-fg-muted`,children:t.effectiveChangePreviewTitle}),Ke?(0,Z.jsx)(ae,{rows:2}):Ge?(0,Z.jsx)(`p`,{className:`rounded-lg bg-surface-panel/60 px-3 py-2 text-sm text-red-600 shadow-surface dark:text-red-400`,children:t.effectiveChangePreviewError}):He?.agents.length?(0,Z.jsx)(`div`,{className:`grid gap-3`,children:He.agents.map(e=>(0,Z.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/80 px-3 py-2 shadow-surface`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.agentName||e.agentId}),(0,Z.jsx)(`div`,{className:`mt-2 grid gap-2`,children:e.diffs.map(e=>(0,Z.jsxs)(`div`,{className:`grid gap-1 text-xs sm:grid-cols-[minmax(0,12rem)_minmax(0,1fr)]`,children:[(0,Z.jsx)(`div`,{className:`truncate font-mono text-fg-muted`,children:e.path}),(0,Z.jsxs)(`div`,{className:`min-w-0 text-fg`,children:[(0,Z.jsx)(`span`,{className:`break-all text-fg-muted`,children:lt(e.before)}),(0,Z.jsx)(`span`,{className:`px-1.5 text-fg-subtle`,"aria-hidden":!0,children:`→`}),(0,Z.jsx)(`span`,{className:`break-all`,children:lt(e.after)})]})]},e.path))})]},e.agentId))}):(0,Z.jsx)(`p`,{className:`rounded-lg bg-surface-panel/60 px-3 py-2 text-sm text-fg-muted shadow-surface`,children:t.effectiveChangePreviewEmpty})]}),$?.usage.length?(0,Z.jsx)(`div`,{className:`grid gap-2`,children:$.usage.map(e=>(0,Z.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/80 px-3 py-2 shadow-surface`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.agentName||e.agentId}),(0,Z.jsx)(`div`,{className:`mt-1 font-mono text-[11px] text-fg-muted`,children:e.agentId}),(0,Z.jsx)(`div`,{className:`mt-1 text-[11px] text-fg-subtle`,children:e.direct?t.usageDirect:t.usageIndirect})]},e.agentId))}):(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.noUsage})]}):null]})}),(0,Z.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-3 border-t border-edge-subtle px-4 py-3 dark:border-edge`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 text-sm`,children:[(0,Z.jsx)(`div`,{className:`font-medium text-fg`,children:Ie?t.unsavedTitle:t.noUnsavedTitle}),(0,Z.jsx)(`div`,{className:`text-xs text-fg-muted`,children:Ie?($?.usage.length??0)>0?t.unsavedImpact.replace(`{{count}}`,String($?.usage.length??0)):t.unsavedNoImpact:t.noUnsavedHint})]}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[Ie?(0,Z.jsx)(k,{type:`button`,variant:`secondary`,disabled:Q,onClick:()=>Y($e($)),children:t.discard}):null,$&&!Fe?(0,Z.jsxs)(k,{type:`button`,variant:`secondary`,disabled:Q,onClick:()=>{Te(null),Ce(!0)},children:[(0,Z.jsx)(S,{className:`size-4`,"aria-hidden":!0}),t.delete]}):null,(0,Z.jsxs)(k,{type:`button`,disabled:Q||!J.id.trim()||!J.name.trim()||!Ie,onClick:()=>void ut(),children:[(0,Z.jsx)(A,{className:`size-4`,"aria-hidden":!0}),t.savePreset]})]})]})]})]})})]})}),(0,Z.jsx)(b,{open:Se,onOpenChange:e=>{Q||(Ce(e),e||Te(null))},children:(0,Z.jsxs)(v,{children:[(0,Z.jsx)(_,{className:o(`xopc-dialog-overlay fixed inset-0 bg-scrim`,O)}),(0,Z.jsxs)(f,{className:o(`xopc-dialog-content fixed left-1/2 top-1/2 w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2 overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-popover dark:border-edge`,E),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,Z.jsxs)(`div`,{className:`border-b border-edge-subtle px-4 py-3 dark:border-edge`,children:[(0,Z.jsx)(x,{className:`text-base font-semibold text-fg`,children:t.deleteDialogTitle}),(0,Z.jsx)(F,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:$?t.deleteConfirm.replace(`{{name}}`,$.name):t.deleteConfirmFallback})]}),we?(0,Z.jsx)(`div`,{className:`mx-4 mt-4 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-800 dark:border-red-900/50 dark:bg-red-950/40 dark:text-red-200`,children:we}):null,(0,Z.jsxs)(`div`,{className:`flex justify-end gap-2 px-4 py-3`,children:[(0,Z.jsx)(k,{type:`button`,variant:`secondary`,disabled:Q,onClick:()=>Ce(!1),children:t.cancel}),(0,Z.jsxs)(k,{type:`button`,disabled:Q||!$,className:`bg-red-600 text-white shadow-surface hover:bg-red-700 focus-visible:ring-red-600 dark:bg-red-500 dark:hover:bg-red-600`,onClick:()=>void pt(),children:[Q?(0,Z.jsx)(te,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(S,{className:`size-4`,"aria-hidden":!0}),Q?t.deleting:t.delete]})]})]})]})})]}):(0,Z.jsxs)(re,{gap:`gap-3`,children:[(0,Z.jsx)(ne,{title:t.title,actions:n}),(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.needToken})]})}function mt(e){let t=(0,_e.c)(10),{icon:n,label:r,value:i}=e,a;t[0]===n?a=t[1]:(a=(0,Z.jsx)(n,{className:`size-3.5`,"aria-hidden":!0}),t[0]=n,t[1]=a);let o;t[2]!==r||t[3]!==a?(o=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[a,r]}),t[2]=r,t[3]=a,t[4]=o):o=t[4];let s;t[5]===i?s=t[6]:(s=(0,Z.jsx)(`div`,{className:`mt-1 text-sm font-medium text-fg`,children:i}),t[5]=i,t[6]=s);let c;return t[7]!==o||t[8]!==s?(c=(0,Z.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/80 px-3 py-2 shadow-surface`,children:[o,s]}),t[7]=o,t[8]=s,t[9]=c):c=t[9],c}function ht(e){let t=(0,_e.c)(121),{value:n,onChange:r,disabled:i,cp:a,chat:o}=e,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s={revalidateOnFocus:!1},t[0]=s):s=t[0];let{data:c,isLoading:l,error:d}=u(`capability-preset-image-generation-models`,ge,s),f;t[1]===c?f=t[2]:(f=(c??[]).filter(vt).flatMap(_t),t[1]=c,t[2]=f);let p=f,h;t[3]===p?h=t[4]:(h=new Set(p.map(gt)),t[3]=p,t[4]=h);let g=h,_,v;t[5]!==g||t[6]!==c||t[7]!==r||t[8]!==n?(_=()=>{if(!c)return;let e=n.imageGenerationModel,t=g.has(e.primary)?e.primary:``,i=e.fallbacks.filter(e=>g.has(e));t===e.primary&&i.length===e.fallbacks.length||r({...n,imageGenerationModel:{...e,primary:t,fallbacks:i}})},v=[g,c,r,n],t[5]=g,t[6]=c,t[7]=r,t[8]=n,t[9]=_,t[10]=v):(_=t[9],v=t[10]),(0,X.useEffect)(_,v);let y;t[11]!==r||t[12]!==n?(y=(e,t)=>{r({...n,[e]:t})},t[11]=r,t[12]=n,t[13]=y):y=t[13];let b=y,x;t[14]===a.modelSpecializedTitle?x=t[15]:(x=(0,Z.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:a.modelSpecializedTitle}),t[14]=a.modelSpecializedTitle,t[15]=x);let S;t[16]!==a.modelNotSet||t[17]!==a.modelSpecializedSummary||t[18]!==n.imageGenerationModel.primary||t[19]!==n.imageModel.primary?(S=a.modelSpecializedSummary.replace(`{{image}}`,n.imageModel.primary||a.modelNotSet).replace(`{{generation}}`,n.imageGenerationModel.primary||a.modelNotSet),t[16]=a.modelNotSet,t[17]=a.modelSpecializedSummary,t[18]=n.imageGenerationModel.primary,t[19]=n.imageModel.primary,t[20]=S):S=t[20];let C;t[21]===S?C=t[22]:(C=(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:S}),t[21]=S,t[22]=C);let w;t[23]!==x||t[24]!==C?(w=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[x,C]}),t[23]=x,t[24]=C,t[25]=w):w=t[25];let E;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,Z.jsx)(z,{className:`size-4 shrink-0 text-fg-subtle transition-transform group-open:rotate-180`,"aria-hidden":!0}),t[26]=E):E=t[26];let D;t[27]===w?D=t[28]:(D=(0,Z.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-3 p-4`,children:[w,E]}),t[27]=w,t[28]=D);let O;t[29]===b?O=t[30]:(O=e=>b(`imageModel`,e),t[29]=b,t[30]=O);let k;t[31]!==o||t[32]!==a||t[33]!==i||t[34]!==O||t[35]!==n.imageModel?(k=(0,Z.jsx)(yt,{title:a.imageUnderstandingTitle,value:n.imageModel,onChange:O,disabled:i,cp:a,chat:o,capabilitiesFilter:`vision`}),t[31]=o,t[32]=a,t[33]=i,t[34]=O,t[35]=n.imageModel,t[36]=k):k=t[36];let A;t[37]===b?A=t[38]:(A=e=>b(`imageGenerationModel`,e),t[37]=b,t[38]=A);let j;t[39]===a.modelImageSettingsLink?j=t[40]:(j={label:a.modelImageSettingsLink,path:`/settings/capabilities/image`},t[39]=a.modelImageSettingsLink,t[40]=j);let M;t[41]!==o||t[42]!==a||t[43]!==i||t[44]!==p||t[45]!==d||t[46]!==l||t[47]!==A||t[48]!==j||t[49]!==n.imageGenerationModel?(M=(0,Z.jsx)(yt,{title:a.imageGenerationTitle,value:n.imageGenerationModel,onChange:A,disabled:i,cp:a,chat:o,models:p,modelsLoading:l,modelsError:d,noMatches:a.modelNoConfiguredImageModels,settingsFooterLink:j}),t[41]=o,t[42]=a,t[43]=i,t[44]=p,t[45]=d,t[46]=l,t[47]=A,t[48]=j,t[49]=n.imageGenerationModel,t[50]=M):M=t[50];let N;t[51]!==k||t[52]!==M?(N=(0,Z.jsxs)(`div`,{className:`grid gap-3 border-t border-edge-subtle p-4 dark:border-edge lg:grid-cols-2`,children:[k,M]}),t[51]=k,t[52]=M,t[53]=N):N=t[53];let P;t[54]!==D||t[55]!==N?(P=(0,Z.jsxs)(`details`,{className:`group rounded-xl border border-edge bg-surface-base`,children:[D,N]}),t[54]=D,t[55]=N,t[56]=P):P=t[56];let F;t[57]===a.modelAdvancedTitle?F=t[58]:(F=(0,Z.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:a.modelAdvancedTitle}),t[57]=a.modelAdvancedTitle,t[58]=F);let I;t[59]===a.modelAdvancedHint?I=t[60]:(I=(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:a.modelAdvancedHint}),t[59]=a.modelAdvancedHint,t[60]=I);let L;t[61]!==F||t[62]!==I?(L=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[F,I]}),t[61]=F,t[62]=I,t[63]=L):L=t[63];let R;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(R=(0,Z.jsx)(z,{className:`size-4 shrink-0 text-fg-subtle transition-transform group-open:rotate-180`,"aria-hidden":!0}),t[64]=R):R=t[64];let B;t[65]===L?B=t[66]:(B=(0,Z.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-3 p-4`,children:[L,R]}),t[65]=L,t[66]=B);let V;t[67]===a.modelAllowFallbacksLabel?V=t[68]:(V=(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:a.modelAllowFallbacksLabel}),t[67]=a.modelAllowFallbacksLabel,t[68]=V);let H;t[69]!==r||t[70]!==n?(H=e=>r({...n,allowFallbacks:e.target.value}),t[69]=r,t[70]=n,t[71]=H):H=t[71];let ee;t[72]===a.policyInherit?ee=t[73]:(ee=(0,Z.jsx)(m,{value:``,children:a.policyInherit}),t[72]=a.policyInherit,t[73]=ee);let te;t[74]===a.policyEnabled?te=t[75]:(te=(0,Z.jsx)(m,{value:`true`,children:a.policyEnabled}),t[74]=a.policyEnabled,t[75]=te);let U;t[76]===a.policyDisabled?U=t[77]:(U=(0,Z.jsx)(m,{value:`false`,children:a.policyDisabled}),t[76]=a.policyDisabled,t[77]=U);let W;t[78]!==i||t[79]!==H||t[80]!==ee||t[81]!==te||t[82]!==U||t[83]!==n.allowFallbacks?(W=(0,Z.jsxs)(T,{value:n.allowFallbacks,disabled:i,side:`top`,onChange:H,children:[ee,te,U]}),t[78]=i,t[79]=H,t[80]=ee,t[81]=te,t[82]=U,t[83]=n.allowFallbacks,t[84]=W):W=t[84];let ne;t[85]!==V||t[86]!==W?(ne=(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[V,W]}),t[85]=V,t[86]=W,t[87]=ne):ne=t[87];let re;t[88]===a.modelMaxCostTierLabel?re=t[89]:(re=(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:a.modelMaxCostTierLabel}),t[88]=a.modelMaxCostTierLabel,t[89]=re);let ie;t[90]!==r||t[91]!==n?(ie=e=>r({...n,maxCostTier:e.target.value}),t[90]=r,t[91]=n,t[92]=ie):ie=t[92];let ae;t[93]===a.policyInherit?ae=t[94]:(ae=(0,Z.jsx)(m,{value:``,children:a.policyInherit}),t[93]=a.policyInherit,t[94]=ae);let G;t[95]===a.costTierLow?G=t[96]:(G=(0,Z.jsx)(m,{value:`low`,children:a.costTierLow}),t[95]=a.costTierLow,t[96]=G);let K;t[97]===a.costTierMedium?K=t[98]:(K=(0,Z.jsx)(m,{value:`medium`,children:a.costTierMedium}),t[97]=a.costTierMedium,t[98]=K);let oe;t[99]===a.costTierHigh?oe=t[100]:(oe=(0,Z.jsx)(m,{value:`high`,children:a.costTierHigh}),t[99]=a.costTierHigh,t[100]=oe);let se;t[101]!==i||t[102]!==ie||t[103]!==ae||t[104]!==G||t[105]!==K||t[106]!==oe||t[107]!==n.maxCostTier?(se=(0,Z.jsxs)(T,{value:n.maxCostTier,disabled:i,side:`top`,onChange:ie,children:[ae,G,K,oe]}),t[101]=i,t[102]=ie,t[103]=ae,t[104]=G,t[105]=K,t[106]=oe,t[107]=n.maxCostTier,t[108]=se):se=t[108];let ce;t[109]!==re||t[110]!==se?(ce=(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[re,se]}),t[109]=re,t[110]=se,t[111]=ce):ce=t[111];let le;t[112]!==ne||t[113]!==ce?(le=(0,Z.jsxs)(`div`,{className:`grid gap-3 border-t border-edge-subtle p-4 dark:border-edge sm:grid-cols-2`,children:[ne,ce]}),t[112]=ne,t[113]=ce,t[114]=le):le=t[114];let ue;t[115]!==B||t[116]!==le?(ue=(0,Z.jsxs)(`details`,{className:`group rounded-xl border border-edge bg-surface-base`,children:[B,le]}),t[115]=B,t[116]=le,t[117]=ue):ue=t[117];let de;return t[118]!==P||t[119]!==ue?(de=(0,Z.jsxs)(`div`,{className:`mt-5 grid gap-3 border-t border-edge-subtle pt-5 dark:border-edge`,children:[P,ue]}),t[118]=P,t[119]=ue,t[120]=de):de=t[120],de}function gt(e){return e.id}function _t(e){return e.models.map(t=>({id:`${e.id}/${t}`,name:t,provider:e.label}))}function vt(e){return e.configured||e.credentialMode!==`api-key`}function yt(e){let t=(0,_e.c)(109),{title:n,value:r,onChange:i,disabled:a,cp:o,chat:s,capabilitiesFilter:c,models:l,modelsLoading:u,modelsError:d,noMatches:f,settingsFooterLink:p}=e,h;t[0]!==i||t[1]!==r?(h=(e,t)=>{i({...r,fallbacks:r.fallbacks.map((n,r)=>r===e?t:n)})},t[0]=i,t[1]=r,t[2]=h):h=t[2];let g=h,_;t[3]===n?_=t[4]:(_=(0,Z.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n}),t[3]=n,t[4]=_);let v=r.primary||o.modelNotSet,b;t[5]===v?b=t[6]:(b=(0,Z.jsx)(`span`,{className:`max-w-48 truncate font-mono text-xs text-fg-muted`,children:v}),t[5]=v,t[6]=b);let x;t[7]!==_||t[8]!==b?(x=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-2.5`,children:[_,b]}),t[7]=_,t[8]=b,t[9]=x):x=t[9];let C;t[10]===o.modelToolPrimaryLabel?C=t[11]:(C=(0,Z.jsx)(`div`,{className:`text-xs text-fg-muted`,children:o.modelToolPrimaryLabel}),t[10]=o.modelToolPrimaryLabel,t[11]=C);let w=f??s.modelNoMatches,E;t[12]!==i||t[13]!==r?(E=e=>i({...r,primary:e}),t[12]=i,t[13]=r,t[14]=E):E=t[14];let D;t[15]!==c||t[16]!==s.modelPlaceholder||t[17]!==s.modelSearchPlaceholder||t[18]!==a||t[19]!==l||t[20]!==d||t[21]!==u||t[22]!==p||t[23]!==w||t[24]!==E||t[25]!==r.primary?(D=(0,Z.jsx)(y,{value:r.primary,disabled:a,placeholder:s.modelPlaceholder,searchPlaceholder:s.modelSearchPlaceholder,noMatches:w,models:l,modelsLoading:u,modelsError:d,settingsFooterLink:p,capabilitiesFilter:c,className:`w-full max-w-none`,contentAlign:`start`,onChange:E}),t[15]=c,t[16]=s.modelPlaceholder,t[17]=s.modelSearchPlaceholder,t[18]=a,t[19]=l,t[20]=d,t[21]=u,t[22]=p,t[23]=w,t[24]=E,t[25]=r.primary,t[26]=D):D=t[26];let O;t[27]!==o.modelClearSelection||t[28]!==a||t[29]!==i||t[30]!==r?(O=r.primary?(0,Z.jsx)(k,{type:`button`,variant:`secondary`,className:`shrink-0 px-2`,disabled:a,"aria-label":o.modelClearSelection,onClick:()=>i({...r,primary:``}),children:(0,Z.jsx)(j,{className:`size-4`,strokeWidth:1.75})}):null,t[27]=o.modelClearSelection,t[28]=a,t[29]=i,t[30]=r,t[31]=O):O=t[31];let A;t[32]!==D||t[33]!==O?(A=(0,Z.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto] gap-2`,children:[D,O]}),t[32]=D,t[33]=O,t[34]=A):A=t[34];let M;t[35]!==A||t[36]!==C?(M=(0,Z.jsxs)(`div`,{className:`grid gap-1`,children:[C,A]}),t[35]=A,t[36]=C,t[37]=M):M=t[37];let N;t[38]===o.modelToolFallbacksLabel?N=t[39]:(N=(0,Z.jsx)(`div`,{className:`text-xs text-fg-muted`,children:o.modelToolFallbacksLabel}),t[38]=o.modelToolFallbacksLabel,t[39]=N);let F;t[40]!==i||t[41]!==r?(F=()=>i({...r,fallbacks:[...r.fallbacks,``]}),t[40]=i,t[41]=r,t[42]=F):F=t[42];let I;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,Z.jsx)(P,{className:`size-3.5`,strokeWidth:1.75}),t[43]=I):I=t[43];let L;t[44]!==o.modelAddFallback||t[45]!==a||t[46]!==F?(L=(0,Z.jsxs)(k,{type:`button`,variant:`secondary`,className:`h-7 gap-1 px-2 text-xs`,disabled:a,onClick:F,children:[I,o.modelAddFallback]}),t[44]=o.modelAddFallback,t[45]=a,t[46]=F,t[47]=L):L=t[47];let R;t[48]!==N||t[49]!==L?(R=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[N,L]}),t[48]=N,t[49]=L,t[50]=R):R=t[50];let z;t[51]!==c||t[52]!==s.modelNoMatches||t[53]!==s.modelSearchPlaceholder||t[54]!==o.modelFallbackEmptyHint||t[55]!==o.modelFallbackPlaceholder||t[56]!==o.modelRemoveFallback||t[57]!==a||t[58]!==l||t[59]!==d||t[60]!==u||t[61]!==f||t[62]!==i||t[63]!==p||t[64]!==g||t[65]!==r?(z=r.fallbacks.length>0?(0,Z.jsx)(`div`,{className:`grid gap-1.5`,children:r.fallbacks.map((e,t)=>(0,Z.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto] gap-2`,children:[(0,Z.jsx)(y,{value:e,disabled:a,placeholder:o.modelFallbackPlaceholder,searchPlaceholder:s.modelSearchPlaceholder,noMatches:f??s.modelNoMatches,models:l,modelsLoading:u,modelsError:d,settingsFooterLink:p,capabilitiesFilter:c,className:`w-full max-w-none`,contentAlign:`start`,onChange:e=>g(t,e)}),(0,Z.jsx)(k,{type:`button`,variant:`secondary`,className:`shrink-0 px-2`,disabled:a,"aria-label":o.modelRemoveFallback,onClick:()=>i({...r,fallbacks:r.fallbacks.filter((e,n)=>n!==t)}),children:(0,Z.jsx)(S,{className:`size-4`,strokeWidth:1.75})})]},`fallback-${t}`))}):(0,Z.jsx)(`div`,{className:`rounded-lg bg-surface-base px-3 py-2 text-xs text-fg-muted`,children:o.modelFallbackEmptyHint}),t[51]=c,t[52]=s.modelNoMatches,t[53]=s.modelSearchPlaceholder,t[54]=o.modelFallbackEmptyHint,t[55]=o.modelFallbackPlaceholder,t[56]=o.modelRemoveFallback,t[57]=a,t[58]=l,t[59]=d,t[60]=u,t[61]=f,t[62]=i,t[63]=p,t[64]=g,t[65]=r,t[66]=z):z=t[66];let B;t[67]!==R||t[68]!==z?(B=(0,Z.jsxs)(`div`,{className:`grid gap-1.5`,children:[R,z]}),t[67]=R,t[68]=z,t[69]=B):B=t[69];let V;t[70]!==i||t[71]!==r?(V=e=>i({...r,timeoutMs:e.target.value}),t[70]=i,t[71]=r,t[72]=V):V=t[72];let H;t[73]!==a||t[74]!==V||t[75]!==r.timeoutMs?(H=(0,Z.jsx)(`input`,{type:`number`,min:1,step:1,className:`rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg placeholder:text-fg-subtle focus:border-edge-strong focus:outline-none`,value:r.timeoutMs,disabled:a,onChange:V}),t[73]=a,t[74]=V,t[75]=r.timeoutMs,t[76]=H):H=t[76];let ee;t[77]!==o.toolTimeoutLabel||t[78]!==H?(ee=(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-fg-muted`,children:[o.toolTimeoutLabel,H]}),t[77]=o.toolTimeoutLabel,t[78]=H,t[79]=ee):ee=t[79];let te;t[80]!==i||t[81]!==r?(te=e=>i({...r,autoProviderFallback:e.target.value}),t[80]=i,t[81]=r,t[82]=te):te=t[82];let U;t[83]===o.policyInherit?U=t[84]:(U=(0,Z.jsx)(m,{value:``,children:o.policyInherit}),t[83]=o.policyInherit,t[84]=U);let W;t[85]===o.policyEnabled?W=t[86]:(W=(0,Z.jsx)(m,{value:`true`,children:o.policyEnabled}),t[85]=o.policyEnabled,t[86]=W);let ne;t[87]===o.policyDisabled?ne=t[88]:(ne=(0,Z.jsx)(m,{value:`false`,children:o.policyDisabled}),t[87]=o.policyDisabled,t[88]=ne);let re;t[89]!==a||t[90]!==te||t[91]!==U||t[92]!==W||t[93]!==ne||t[94]!==r.autoProviderFallback?(re=(0,Z.jsxs)(T,{value:r.autoProviderFallback,disabled:a,side:`top`,onChange:te,children:[U,W,ne]}),t[89]=a,t[90]=te,t[91]=U,t[92]=W,t[93]=ne,t[94]=r.autoProviderFallback,t[95]=re):re=t[95];let ie;t[96]!==o.modelAutoProviderFallbackLabel||t[97]!==re?(ie=(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-fg-muted`,children:[o.modelAutoProviderFallbackLabel,re]}),t[96]=o.modelAutoProviderFallbackLabel,t[97]=re,t[98]=ie):ie=t[98];let ae;t[99]!==ee||t[100]!==ie?(ae=(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[ee,ie]}),t[99]=ee,t[100]=ie,t[101]=ae):ae=t[101];let G;t[102]!==M||t[103]!==B||t[104]!==ae?(G=(0,Z.jsxs)(`div`,{className:`grid gap-3 border-t border-edge-subtle p-3 dark:border-edge`,children:[M,B,ae]}),t[102]=M,t[103]=B,t[104]=ae,t[105]=G):G=t[105];let K;return t[106]!==G||t[107]!==x?(K=(0,Z.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/70 shadow-surface`,children:[x,G]}),t[106]=G,t[107]=x,t[108]=K):K=t[108],K}export{pt as CapabilityPresetsSettingsPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i,l as a}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as o}from"./cn-JdwAhgNB.js";import{t as s}from"./messages-DQ5X6cXp.js";import{l as c,n as l,o as u,r as d,s as f}from"./locale-store-Bjvw7jtg.js";import{i as p}from"./vendor-swr-BIWyz7Rc.js";import{Al as m,Ao as h,Ar as g,Da as _,Ea as v,Hs as y,Ko as b,La as x,Mo as S,Mr as C,Ni as w,No as T,Ns as E,Oa as D,Oo as O,Po as k,Uo as A,Xo as j,Zo as M,_s as N,bs as ee,dc as P,dr as F,dt as I,jo as L,jr as te,ko as R,ru as z,sc as ne,tc as re,tu as ie,us as ae,zc as B}from"./index-BpkdvHH0.js";import{n as oe,r as se}from"./settings-page-layout-CLtUsWsu.js";import{n as ce}from"./settings-loading-skeleton-sn4k17x7.js";import{t as le}from"./schema-form-CWoSjz9s.js";import{t as ue}from"./browser-BLJWD7WI.js";import{n as de,t as fe}from"./channels-status-swr-DPaJSYX_.js";var V=e(t(),1),H=n();function pe(e){let t=e.actions??{};for(let e of[`login.start`,`setup.start`]){let n=t[e];if(n?.result===`qr`)return[e,n]}let n=Object.entries(t).find(([,e])=>e.result===`qr`);if(n)return n;let r=e.ui?.card?.primaryAction;if(r&&t[r])return[r,t[r]];for(let e of[`login.start`,`setup.start`]){let n=t[e];if(n)return[e,n]}return Object.entries(t).find(([,e])=>e.result===`form`)??null}var me=e(ue(),1),U=r();async function he(e){let t=await u(d(`/api/channels/${encodeURIComponent(e.channelId)}/actions/${encodeURIComponent(e.actionId)}?locale=${encodeURIComponent(e.locale)}`),{method:`POST`,body:JSON.stringify({...e.accountId?{accountId:e.accountId}:{},...e.input===void 0?{}:{input:e.input}})}),n=await t.json().catch(()=>({}));if(!t.ok||n.ok===!1)throw Error(n.error?.message??t.statusText);return n.payload??{type:`ok`}}function W(e){return e?.type===`poll`&&e.phase===`done`}function G(e){return e&&`message`in e&&typeof e.message==`string`?e.message:null}function K(e,t){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrPayload?e.qrPayload:t===`weixin`&&e.qrcodeUrl?e.qrcodeUrl:null}function q(e){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrcodeUrl??null}function ge({entry:e,locale:t,messages:n,onChanged:r,compact:i=!1}){let a=(0,V.useMemo)(()=>pe(e),[e]),s=(0,V.useMemo)(()=>({defaultBooleanLabel:n.schemaBooleanDefault,unsupportedArrayType:n.schemaUnsupportedArrayType,arrayAddPlaceholder:n.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>n.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[n]),[c,l]=(0,V.useState)({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null});(0,V.useEffect)(()=>{l({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null})},[e.id]);let u=(0,V.useCallback)(async(n,i)=>{l(e=>({...e,busy:!0,error:null}));try{let a=await he({channelId:e.id,actionId:n,locale:t,input:i});l(e=>({...e,payload:a,poll:a.type===`qr`&&a.statusAction&&a.sessionKey?{actionId:a.statusAction,sessionKey:a.sessionKey,intervalMs:Math.max(1e3,a.pollIntervalMs??2500)}:null,busy:!1,formDraft:a.type===`form`?a.values??{}:e.formDraft})),`configChanged`in a&&a.configChanged===!0&&await r()}catch(e){l(t=>({...t,busy:!1,error:e instanceof Error?e.message:String(e)}))}},[e.id,t,r]);(0,V.useEffect)(()=>{let t=K(c.payload,e.id);if(!t){l(e=>e.generatedQr?{...e,generatedQr:null}:e);return}let n=!1;return l(e=>e.generatedQr?{...e,generatedQr:null}:e),me.toDataURL(t,{width:220,margin:1}).then(e=>{n||l(t=>({...t,generatedQr:e}))}),()=>{n=!0}},[e.id,c.payload]),(0,V.useEffect)(()=>{let n=c.poll;if(!n)return;let i=!1,a=window.setInterval(()=>{i||he({channelId:e.id,actionId:n.actionId,locale:t,input:{sessionKey:n.sessionKey}}).then(async e=>{i||(l(t=>({...t,payload:e,poll:W(e)?null:t.poll,error:null})),`configChanged`in e&&e.configChanged===!0&&await r(),W(e)&&window.clearInterval(a))}).catch(e=>{i||l(t=>({...t,error:e instanceof Error?e.message:String(e)}))})},n.intervalMs);return()=>{i=!0,window.clearInterval(a)}},[e.id,t,r,c.poll]);let d=a?.[1].label??(e.configured?n.reconnect:n.connect),f=e.actions?.[`doctor.run`]?.label??n.diagnose,p=G(c.payload),h=K(c.payload,e.id),g=h?c.generatedQr:q(c.payload),v=a?.[1].result===`qr`&&(c.busy||c.payload?.type===`qr`||c.payload?.type===`poll`),b=c.payload?.type===`form`?c.payload:null,x=c.payload?.type===`diagnostics`?c.payload.checks:null;return(0,U.jsxs)(`div`,{className:i?`space-y-3`:`rounded-lg bg-surface-panel/80 p-4 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:o(`flex flex-wrap items-start gap-3`,i?`justify-end`:`justify-between`),children:[i?null:(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.setupTitle}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.configured?n.setupConfiguredHint:n.setupEmptyHint})]}),(0,U.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[a?(0,U.jsxs)(N,{type:`button`,variant:`primary`,disabled:c.busy,onClick:()=>void u(a[0]),children:[c.busy?(0,U.jsx)(B,{className:`size-4 animate-spin`}):(0,U.jsx)(P,{className:`size-4`}),d]}):null,e.actions?.[`doctor.run`]?(0,U.jsxs)(N,{type:`button`,variant:`secondary`,disabled:c.busy,onClick:()=>void u(`doctor.run`),children:[(0,U.jsx)(y,{className:`size-4`}),f]}):null]})]}),p?(0,U.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:p}):null,c.error?(0,U.jsx)(`p`,{className:`mt-3 text-sm text-red-600 dark:text-red-400`,children:c.error}):null,v?(0,U.jsxs)(`div`,{className:o(`flex h-80 items-center justify-center gap-4 overflow-hidden rounded-lg bg-surface-base p-3 shadow-surface`,i?`mt-1 flex-col text-center sm:h-64 sm:flex-row sm:text-left`:`mt-4 flex-col sm:h-64 sm:flex-row`),children:[(0,U.jsx)(`div`,{className:`flex size-56 shrink-0 items-center justify-center rounded-lg border border-edge bg-white p-3`,children:g?(0,U.jsx)(`img`,{src:g,alt:`${e.label} setup QR`,className:`size-52 object-contain`}):(0,U.jsx)(`div`,{className:`flex size-52 items-center justify-center rounded-md bg-surface-base`,children:(0,U.jsx)(_,{className:`size-48 rounded-md`})})}),(0,U.jsxs)(`div`,{className:o(`min-w-0 max-w-sm text-sm text-fg-muted`,i&&`w-full sm:w-auto`),children:[g?(0,U.jsx)(`p`,{className:`line-clamp-3`,children:n.waitingConfirmation}):(0,U.jsxs)(`div`,{className:`space-y-2`,"aria-busy":`true`,children:[(0,U.jsx)(_,{className:`h-4 w-48 max-w-full`}),(0,U.jsx)(_,{className:`h-4 w-36 max-w-full`})]}),h?(0,U.jsxs)(`a`,{className:`mt-2 inline-flex items-center gap-1 text-accent hover:underline`,href:h,target:`_blank`,rel:`noreferrer`,children:[n.openSetupLink,(0,U.jsx)(m,{className:`size-3.5`})]}):null]})]}):null,c.payload?.type===`poll`&&c.payload.phase===`done`?(0,U.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 rounded-lg bg-surface-base px-3 py-2 text-sm shadow-surface`,children:[(0,U.jsx)(ie,{className:c.payload.ok?`size-4 text-green-600`:`size-4 text-red-600`}),(0,U.jsx)(`span`,{className:c.payload.ok?`text-fg`:`text-red-600 dark:text-red-400`,children:c.payload.message??(c.payload.ok?n.complete:n.failed)})]}):null,b?(0,U.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,U.jsx)(le,{schema:b.schema,values:c.formDraft,onChange:e=>l(t=>({...t,formDraft:e})),disabled:c.busy,labels:s}),(0,U.jsx)(N,{type:`button`,variant:`primary`,disabled:c.busy,onClick:()=>void u(b.submitAction,c.formDraft),children:n.saveSetup})]}):null,x?(0,U.jsx)(`div`,{className:`mt-4 space-y-2`,children:x.map((e,t)=>(0,U.jsxs)(`div`,{className:`rounded-lg bg-surface-base px-3 py-2 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,U.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.label??e.id??n.diagnosticCheckFallback.replace(`{{index}}`,String(t+1))}),(0,U.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e.status??`unknown`})]}),e.message?(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.message}):null]},e.id??t))}):null]})}var _e=40;function J(e){return`ui:route:channel:${e.trim().toLowerCase()}`}function ve(e,t){return e.find(e=>e.id===J(t))?.agentId?.trim().toLowerCase()??``}function ye(e,t,n){let r=J(t),i=e.filter(e=>e.id!==r),a=n.trim().toLowerCase();return a?[...i,{id:r,agentId:a,priority:_e,enabled:!0,match:{channel:t.trim().toLowerCase(),accountId:`*`}}]:i}function be(e){let t=e.configured===!0,n=e.enabled===!0;return e.setupStatus??{enabled:n,ready:t,state:n&&!t?`needs_setup`:n?`ready`:`disabled`,issues:[]}}function xe(e,t,n){let r=be(e);return r.ready?r.enabled?n?t?.connected===!0?`running`:`stopped`:`checking`:`disabled`:`needs_setup`}function Se(e,t=!1){return e===`drawer`?o(`xopc-drawer-right fixed right-0 top-0 flex size-full flex-col overflow-hidden border-l border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`,t?`max-w-[36rem]`:`max-w-xl`,j):o(`fixed left-1/2 top-1/2 flex h-[min(calc(100dvh-2rem),52rem)] w-[min(calc(100%-2rem),32rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,t&&`h-[min(calc(100dvh-2rem),48rem)] w-[min(calc(100%-2rem),36rem)]`,j,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`)}function Ce(e){let t=(0,H.c)(33),{presentation:n,open:r,onOpenChange:i,title:a,description:s,srTitle:c,srDescription:l,closeAriaLabel:u,children:d,footer:f,wide:p,headerExtra:m}=e,g=p===void 0?!1:p,_=n===`drawer`,[v,y]=(0,V.useState)(null),x;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,U.jsx)(S,{className:o(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,M)}),t[0]=x):x=t[0];let C;t[1]!==n||t[2]!==g?(C=Se(n,g),t[1]=n,t[2]=g,t[3]=C):C=t[3];let w;t[4]===c?w=t[5]:(w=c?(0,U.jsx)(k,{className:`sr-only`,children:c}):null,t[4]=c,t[5]=w);let E;t[6]===l?E=t[7]:(E=l?(0,U.jsx)(L,{className:`sr-only`,children:l}):null,t[6]=l,t[7]=E);let D;t[8]!==u||t[9]!==s||t[10]!==m||t[11]!==_||t[12]!==a?(D=_?(0,U.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[a?(0,U.jsx)(`div`,{className:`text-base font-semibold text-fg`,children:a}):null,s?(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:s}):null]}),(0,U.jsx)(R,{asChild:!0,children:(0,U.jsx)(N,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":u,children:(0,U.jsx)(ee,{className:`size-5`,strokeWidth:1.75})})})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(R,{asChild:!0,children:(0,U.jsx)(`button`,{type:`button`,className:o(ae,`absolute right-3 top-3 z-20 p-1.5 hover:bg-surface-hover`),"aria-label":u,children:(0,U.jsx)(ee,{className:`size-4`})})}),m]}),t[8]=u,t[9]=s,t[10]=m,t[11]=_,t[12]=a,t[13]=D):D=t[13];let A=_?`p-4`:`p-6`,j;t[14]===A?j=t[15]:(j=o(`min-h-0 flex-1 overflow-y-auto`,A),t[14]=A,t[15]=j);let P;t[16]!==d||t[17]!==j?(P=(0,U.jsx)(`div`,{className:j,children:d}),t[16]=d,t[17]=j,t[18]=P):P=t[18];let F;t[19]!==f||t[20]!==v||t[21]!==w||t[22]!==E||t[23]!==D||t[24]!==P?(F=(0,U.jsxs)(b,{layer:`modal`,portalContainer:v,children:[w,E,D,P,f]}),t[19]=f,t[20]=v,t[21]=w,t[22]=E,t[23]=D,t[24]=P,t[25]=F):F=t[25];let I;t[26]!==F||t[27]!==C?(I=(0,U.jsxs)(T,{children:[x,(0,U.jsx)(h,{ref:y,className:C,onOpenAutoFocus:we,children:F})]}),t[26]=F,t[27]=C,t[28]=I):I=t[28];let te;return t[29]!==i||t[30]!==r||t[31]!==I?(te=(0,U.jsx)(O,{open:r,onOpenChange:i,children:I}),t[29]=i,t[30]=r,t[31]=I,t[32]=te):te=t[32],te}function we(e){return e.preventDefault()}var Te=(0,V.memo)(function(e){let t=(0,H.c)(10),{ch:n,refreshing:r,saveOk:i,onRefresh:a}=e,o;t[0]!==n.saved||t[1]!==i?(o=i?(0,U.jsx)(`span`,{className:`text-sm text-fg-muted`,children:n.saved}):null,t[0]=n.saved,t[1]=i,t[2]=o):o=t[2];let s;t[3]!==n.refresh||t[4]!==a||t[5]!==r?(s=(0,U.jsx)(w,{className:`size-9 shrink-0 p-0`,loading:r,label:n.refresh,onClick:a}),t[3]=n.refresh,t[4]=a,t[5]=r,t[6]=s):s=t[6];let c;return t[7]!==o||t[8]!==s?(c=(0,U.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center justify-end gap-2`,children:[o,s]}),t[7]=o,t[8]=s,t[9]=c):c=t[9],c});function Ee(e){let t=(0,H.c)(24),{ch:n,dirty:r,saving:i,onCancel:a,onDiscard:o,onSave:s,showCancel:c}=e,l=c===void 0?!0:c,u;t[0]!==n.unsavedHint||t[1]!==r?(u=r?(0,U.jsx)(`p`,{className:`mb-3 text-xs text-amber-800 dark:text-amber-200`,children:n.unsavedHint}):null,t[0]=n.unsavedHint,t[1]=r,t[2]=u):u=t[2];let d;t[3]!==n.modalCancel||t[4]!==a||t[5]!==l?(d=l?(0,U.jsx)(N,{type:`button`,variant:`secondary`,onClick:a,children:n.modalCancel}):null,t[3]=n.modalCancel,t[4]=a,t[5]=l,t[6]=d):d=t[6];let f=!r||i,p;t[7]!==n.discard||t[8]!==o||t[9]!==f?(p=(0,U.jsx)(N,{type:`button`,variant:`secondary`,disabled:f,onClick:o,children:n.discard}),t[7]=n.discard,t[8]=o,t[9]=f,t[10]=p):p=t[10];let m=!r||i,h;t[11]===s?h=t[12]:(h=()=>void s(),t[11]=s,t[12]=h);let g=i?n.saving:n.save,_;t[13]!==m||t[14]!==h||t[15]!==g?(_=(0,U.jsx)(N,{type:`button`,variant:`primary`,disabled:m,onClick:h,children:g}),t[13]=m,t[14]=h,t[15]=g,t[16]=_):_=t[16];let v;t[17]!==d||t[18]!==p||t[19]!==_?(v=(0,U.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[d,p,_]}),t[17]=d,t[18]=p,t[19]=_,t[20]=v):v=t[20];let y;return t[21]!==v||t[22]!==u?(y=(0,U.jsxs)(`div`,{className:`sticky bottom-0 shrink-0 border-t border-edge-subtle bg-surface-panel px-6 py-4 dark:border-edge-subtle`,children:[u,v]}),t[21]=v,t[22]=u,t[23]=y):y=t[23],y}function De(e){return d(`/api/channels/catalog?locale=${encodeURIComponent(e)}`)}async function Oe(e){return(await f(De(e))).payload?.channels??[]}function ke(e,t){let n=(0,H.c)(14),r;n[0]!==e||n[1]!==t?(r=e?De(t):null,n[0]=e,n[1]=t,n[2]=r):r=n[2];let i;n[3]===t?i=n[4]:(i=()=>Oe(t),n[3]=t,n[4]=i);let a;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(a={revalidateOnFocus:!1},n[5]=a):a=n[5];let{data:o,error:s,isLoading:c,isValidating:l,mutate:u}=p(r,i,a),d;n[6]===o?d=n[7]:(d=o??[],n[6]=o,n[7]=d);let f;return n[8]!==s||n[9]!==c||n[10]!==l||n[11]!==u||n[12]!==d?(f={entries:d,isLoading:c,isValidating:l,error:s,mutate:u},n[8]=s,n[9]=c,n[10]=l,n[11]=u,n[12]=d,n[13]=f):f=n[13],f}var Ae=`channels-status`;function je(e){if(!e||typeof e!=`object`)return null;let t=e.channels;return Array.isArray(t)?t:null}function Me(e){let t=t=>e(t.detail);return window.addEventListener(Ae,t),()=>window.removeEventListener(Ae,t)}function Ne(e,t){let n=(0,H.c)(4),r=t===void 0?!0:t,i,a;n[0]!==r||n[1]!==e?(i=()=>{if(r)return Me(e)},a=[r,e],n[0]=r,n[1]=e,n[2]=i,n[3]=a):(i=n[2],a=n[3]),(0,V.useEffect)(i,a)}function Pe(e){return e?d(`/api/channels/${encodeURIComponent(e)}/config`):null}async function Fe(e){return(await f(d(`/api/channels/${encodeURIComponent(e)}/config`))).payload?.config??{}}var Ie=[`enabled`];async function Le(){let e=await f(d(`/api/config`));return{channels:e.payload?.config?.channels??{},bindings:e.payload?.config?.bindings??[]}}function Re(e){return e.split(`/`).filter(Boolean).map(e=>encodeURIComponent(e)).join(`/`)}function ze(e){return e.configPath.startsWith(`channels.`)&&e.configPath.slice(9).split(`.`)[0]||e.id}function Y(e){let t=e.configured===!0,n=e.enabled===!0;return e.setupStatus??{enabled:n,ready:t,state:n&&!t?`needs_setup`:n?`ready`:`disabled`,issues:[]}}function Be(e,t){return e===`running`?t.connectionRunning:e===`stopped`?t.connectionStopped:e===`checking`?t.connectionChecking:e===`disabled`?t.connectionDisabled:t.connectionNeedsSetup}function Ve(e,t){return e===`running`?t.connectionRunningHint:e===`stopped`?t.connectionStoppedHint:e===`disabled`?t.connectionDisabledHint:e===`needs_setup`?t.connectionNeedsSetupHint:t.connectionChecking}function He(e){return e===`running`?`bg-emerald-500/12 text-emerald-700 dark:text-emerald-300`:e===`stopped`?`bg-red-500/10 text-red-700 dark:text-red-300`:e===`checking`?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:e===`disabled`?`bg-surface-hover text-fg-muted`:`bg-amber-500/10 text-amber-700 dark:text-amber-300`}function Ue(e){if(!e)return[];let t=e.uiHints??{},n=X(e.configSchema)&&Array.isArray(e.configSchema.required)?e.configSchema.required.map(String):[],r=Y(e).issues.map(e=>e.fieldPath).filter(e=>!!e),i=Object.entries(t).filter(([,e])=>!X(e)||e.advanced===!0?!1:(Array.isArray(e.tags)?e.tags.map(String):[]).includes(`basic`)||e.advanced===!1).map(([e])=>e).filter(e=>!Ie.includes(e));return Array.from(new Set([...i,...n,...r])).filter(e=>!Ie.includes(e))}function X(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Z(e){return JSON.parse(JSON.stringify(e??{type:`object`,properties:{}}))}function We(e,t){let n={...Z(e),properties:{}};for(let r of t){let t=r.split(`.`),i=e,a=n;for(let[e,n]of t.entries()){let r=i.properties;if(!X(r)||!X(r[n]))break;let o=X(a.properties)?a.properties:{};if(a.properties=o,o[n]||(o[n]={...Z(r[n]),properties:{}}),e===t.length-1){o[n]=Z(r[n]);break}i=r[n],a=o[n]}}return n}function Ge(e){let t=e.properties;if(!X(t))return!1;for(let[e,n]of Object.entries(t))X(n)&&n.type===`object`&&Ge(n)&&delete t[e];return Object.keys(t).length===0}function Ke(e,t){let n=Z(e);for(let e of t){let t=e.split(`.`),r=n;for(let[e,n]of t.entries()){let i=r.properties;if(!X(i))break;if(e===t.length-1){delete i[n];break}if(!X(i[n]))break;r=i[n]}}return Ge(n),n}function qe(e){return e.type===`object`&&X(e.properties)&&Object.keys(e.properties).length>0}function Je(e,t){let n=e;for(let e of t.split(`.`)){if(!X(n))return;n=n[e]}return n}function Ye(e){let t=e.accounts;return X(t)?Object.values(t).filter(e=>X(e)&&e.enabled!==!1).length:+(e.configured===!0)}function Q(e,t,n){return t==null||t===``?null:e.toLowerCase().includes(`dmpolicy`)&&typeof t==`string`?`${n.dmPolicy}: ${n.policy.dm[t]??t}`:(e.toLowerCase().includes(`stream`)||e.toLowerCase().includes(`streaming`))&&typeof t==`string`?`${n.cardStream}: ${n.policy.stream[t]??t}`:typeof t==`boolean`?t?n.enabledLabel:n.disabledLabel:String(t)}function Xe(e,t,n){let r=[],i=Y(e);if(i.issues.length>0&&r.push(et(i.issues[0],n)),t){let i=e.ui?.card?.summaryFields??[`dmPolicy`,`streamMode`,`streaming.mode`];for(let e of i){let i=Q(e,Je(t,e),n);i&&r.push(i)}let a=Ye(t);a>0&&r.push(n.cardAccounts.replace(`{{count}}`,String(a)))}return r.length>0?r.slice(0,2):i.ready?[n.hubStatusConfigured]:[]}function Ze(e,t){let n=Y(e),r=pe(e);return n.state===`needs_setup`?r?.[1].label??t.completeSetup:!n.enabled&&n.ready?t.enableChannel:n.state===`error`?t.diagnose:n.ready?t.manageChannel:r?.[1].label??t.startConfiguration}function Qe(e,t){let n=pe(e);return n?.[1].result===`qr`?t.cardSetupQrHint:n?.[1].result===`form`?t.cardSetupConfigHint:t.cardSetupGenericHint}function $e(e,t){let n=e.capabilities??{},r=[];return n.login===!0&&r.push(t.cardCapabilityLogin),n.pairing===!0&&r.push(t.cardCapabilityPairing),n.multiAccount===!0&&r.push(t.cardCapabilityMultiAccount),n.streaming===!0&&r.push(t.cardCapabilityStreaming),n.media===!0&&r.push(t.cardCapabilityMedia),n.doctor===!0&&r.push(t.cardCapabilityDoctor),r.slice(0,3)}function et(e,t){return e.code===`telegram.missing_credential`?t.setupIssueTelegramMissingCredential:e.code===`weixin.missing_account`?t.setupIssueWeixinMissingAccount:e.code===`feishu.missing_credentials`?t.setupIssueFeishuMissingCredentials:e.code===`config.missing_required`&&e.fieldPath?t.setupIssueMissingRequired.replace(`{{field}}`,e.fieldPath):e.message}function tt({entry:e}){let t=c(e=>e.token),[n,r]=(0,V.useState)(!1),i=(0,V.useMemo)(()=>{if(!e.ui?.icon||n)return null;let r=new URL(d(`/api/extensions/${encodeURIComponent(e.extensionId)}/assets/${Re(e.ui.icon)}`));return t?.trim()&&r.searchParams.set(`token`,t.trim()),r.toString()},[n,e.extensionId,e.ui?.icon,t]);return(0,U.jsx)(`span`,{className:`flex size-12 shrink-0 items-center justify-center rounded-2xl bg-surface-base text-fg`,children:i?(0,U.jsx)(`img`,{src:i,alt:``,draggable:!1,className:`size-7`,"aria-hidden":!0,onError:()=>r(!0)}):(0,U.jsx)(D,{sourceChannel:e.id,className:`size-7`})})}function nt(e){let t=(0,H.c)(16),{checked:n,disabled:r,onToggle:i,label:a}=e,s;t[0]===i?s=t[1]:(s=e=>{e.stopPropagation(),i()},t[0]=i,t[1]=s);let c=n?`border-accent bg-accent`:`border-edge bg-surface-hover`,l=r&&`cursor-not-allowed opacity-60`,u;t[2]!==c||t[3]!==l?(u=o(`relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border transition-colors`,c,l),t[2]=c,t[3]=l,t[4]=u):u=t[4];let d=n?`translate-x-5`:`translate-x-0.5`,f;t[5]===d?f=t[6]:(f=o(`size-5 rounded-full bg-white shadow-surface transition-transform`,d),t[5]=d,t[6]=f);let p;t[7]===f?p=t[8]:(p=(0,U.jsx)(`span`,{className:f}),t[7]=f,t[8]=p);let m;return t[9]!==n||t[10]!==r||t[11]!==a||t[12]!==s||t[13]!==u||t[14]!==p?(m=(0,U.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":n,"aria-label":a,disabled:r,onClick:s,className:u,children:p}),t[9]=n,t[10]=r,t[11]=a,t[12]=s,t[13]=u,t[14]=p,t[15]=m):m=t[15],m}function rt(e){let t=(0,H.c)(71),{entry:n,config:r,runtime:i,busy:a,restarting:s,ch:c,onOpen:l,onToggle:u,onRestart:d}=e,f;t[0]===n?f=t[1]:(f=Y(n),t[0]=n,t[1]=f);let p=f,m,h,g,_,v,y,b;if(t[2]!==a||t[3]!==c||t[4]!==r||t[5]!==n||t[6]!==l||t[7]!==d||t[8]!==u||t[9]!==i||t[10]!==p.enabled||t[11]!==p.ready){let e=Xe(n,r,c),s=$e(n,c);m=!p.enabled&&p.ready?u:i===`stopped`?d:l,y=`flex min-h-[15.5rem] flex-col rounded-xl bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45`;let f;t[19]===n?f=t[20]:(f=(0,U.jsx)(tt,{entry:n}),t[19]=n,t[20]=f);let x;t[21]===n.label?x=t[22]:(x=(0,U.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:n.label}),t[21]=n.label,t[22]=x);let S;t[23]===i?S=t[24]:(S=o(`mt-1 inline-flex rounded-full px-2 py-0.5 text-xs font-medium`,He(i)),t[23]=i,t[24]=S);let C;t[25]!==c||t[26]!==i?(C=Be(i,c),t[25]=c,t[26]=i,t[27]=C):C=t[27];let w;t[28]!==S||t[29]!==C?(w=(0,U.jsx)(`span`,{className:S,children:C}),t[28]=S,t[29]=C,t[30]=w):w=t[30];let T;t[31]!==w||t[32]!==x?(T=(0,U.jsxs)(`div`,{className:`min-w-0`,children:[x,w]}),t[31]=w,t[32]=x,t[33]=T):T=t[33];let E;t[34]!==T||t[35]!==f?(E=(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[f,T]}),t[34]=T,t[35]=f,t[36]=E):E=t[36];let D=p.enabled,O;t[37]!==c.toggleChannel||t[38]!==n.label?(O=c.toggleChannel.replace(`{{channel}}`,n.label),t[37]=c.toggleChannel,t[38]=n.label,t[39]=O):O=t[39];let k;t[40]!==a||t[41]!==u||t[42]!==p.enabled||t[43]!==O?(k=(0,U.jsx)(nt,{checked:D,disabled:a,label:O,onToggle:u}),t[40]=a,t[41]=u,t[42]=p.enabled,t[43]=O,t[44]=k):k=t[44],t[45]!==E||t[46]!==k?(b=(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[E,k]}),t[45]=E,t[46]=k,t[47]=b):b=t[47],h=`button`,g=l,_=`mt-5 min-h-[6.25rem] text-left`,v=p.ready?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`p`,{className:`line-clamp-2 text-sm leading-6 text-fg-muted`,children:n.description??n.id}),e.length>0?(0,U.jsx)(`div`,{className:`mt-3 space-y-0.5 text-sm leading-5 text-fg-muted`,children:e.map($)}):null]}):(0,U.jsxs)(`div`,{className:`rounded-lg bg-surface-base p-3`,children:[(0,U.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:c.cardSetupTitle}),(0,U.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm leading-5 text-fg-muted`,children:e[0]??Qe(n,c)}),s.length>0?(0,U.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:s.map(it)}):null]}),t[2]=a,t[3]=c,t[4]=r,t[5]=n,t[6]=l,t[7]=d,t[8]=u,t[9]=i,t[10]=p.enabled,t[11]=p.ready,t[12]=m,t[13]=h,t[14]=g,t[15]=_,t[16]=v,t[17]=y,t[18]=b}else m=t[12],h=t[13],g=t[14],_=t[15],v=t[16],y=t[17],b=t[18];let x;t[48]!==h||t[49]!==g||t[50]!==_||t[51]!==v?(x=(0,U.jsx)(`button`,{type:h,onClick:g,className:_,children:v}),t[48]=h,t[49]=g,t[50]=_,t[51]=v,t[52]=x):x=t[52];let S=a||s,C;t[53]!==a||t[54]!==s?(C=a||s?(0,U.jsx)(B,{className:`size-4 animate-spin`}):null,t[53]=a,t[54]=s,t[55]=C):C=t[55];let w;t[56]!==c||t[57]!==n||t[58]!==s||t[59]!==i?(w=s?c.restartingChannel:i===`stopped`?c.restartChannel:Ze(n,c),t[56]=c,t[57]=n,t[58]=s,t[59]=i,t[60]=w):w=t[60];let T;t[61]!==m||t[62]!==C||t[63]!==w||t[64]!==S?(T=(0,U.jsx)(`div`,{className:`mt-auto pt-4`,children:(0,U.jsxs)(N,{type:`button`,variant:`secondary`,className:`w-full rounded-2xl py-2.5`,onClick:m,disabled:S,children:[C,w]})}),t[61]=m,t[62]=C,t[63]=w,t[64]=S,t[65]=T):T=t[65];let E;return t[66]!==T||t[67]!==y||t[68]!==b||t[69]!==x?(E=(0,U.jsxs)(`article`,{className:y,children:[b,x,T]}),t[66]=T,t[67]=y,t[68]=b,t[69]=x,t[70]=E):E=t[70],E}function it(e){return(0,U.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e},e)}function $(e){return(0,U.jsx)(`p`,{className:`truncate`,title:e,children:e},e)}function at(e){let t=(0,H.c)(51),{runtime:n,restarting:r,checking:i,showConnectionOptions:a,canManageConnection:s,ch:c,onRestart:l,onCheck:u,onManageConnection:d}=e,f=n===`running`?ie:n===`stopped`||n===`needs_setup`?z:B,p=n===`running`&&`text-emerald-600 dark:text-emerald-400`,m=n===`stopped`&&`text-red-600 dark:text-red-400`,h=n===`checking`&&`animate-spin text-amber-600 dark:text-amber-400`,g=n===`disabled`&&`text-fg-muted`,_=n===`needs_setup`&&`text-amber-600 dark:text-amber-400`,v;t[0]!==p||t[1]!==m||t[2]!==h||t[3]!==g||t[4]!==_?(v=o(`mt-0.5 size-5 shrink-0`,p,m,h,g,_),t[0]=p,t[1]=m,t[2]=h,t[3]=g,t[4]=_,t[5]=v):v=t[5];let y;t[6]!==f||t[7]!==v?(y=(0,U.jsx)(f,{className:v}),t[6]=f,t[7]=v,t[8]=y):y=t[8];let b;t[9]===c.connectionStatus?b=t[10]:(b=(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:c.connectionStatus}),t[9]=c.connectionStatus,t[10]=b);let x;t[11]!==c||t[12]!==n?(x=Ve(n,c),t[11]=c,t[12]=n,t[13]=x):x=t[13];let S;t[14]===x?S=t[15]:(S=(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:x}),t[14]=x,t[15]=S);let C;t[16]!==S||t[17]!==b?(C=(0,U.jsxs)(`div`,{children:[b,S]}),t[16]=S,t[17]=b,t[18]=C):C=t[18];let w;t[19]!==C||t[20]!==y?(w=(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[y,C]}),t[19]=C,t[20]=y,t[21]=w):w=t[21];let T=i||r,E;t[22]===i?E=t[23]:(E=i?(0,U.jsx)(B,{className:`size-4 animate-spin`}):null,t[22]=i,t[23]=E);let D=i?c.checkingConnection:c.checkConnection,O;t[24]!==u||t[25]!==T||t[26]!==E||t[27]!==D?(O=(0,U.jsxs)(N,{type:`button`,variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:T,onClick:u,children:[E,D]}),t[24]=u,t[25]=T,t[26]=E,t[27]=D,t[28]=O):O=t[28];let k;t[29]!==c.restartChannel||t[30]!==c.restartingChannel||t[31]!==i||t[32]!==l||t[33]!==r||t[34]!==n?(k=n===`stopped`?(0,U.jsxs)(N,{type:`button`,variant:`primary`,className:`px-2.5 py-1.5 text-xs`,disabled:r||i,onClick:l,children:[r?(0,U.jsx)(B,{className:`size-4 animate-spin`}):(0,U.jsx)(ne,{className:`size-4`}),r?c.restartingChannel:c.restartChannel]}):null,t[29]=c.restartChannel,t[30]=c.restartingChannel,t[31]=i,t[32]=l,t[33]=r,t[34]=n,t[35]=k):k=t[35];let A;t[36]!==s||t[37]!==c.connectionOptions||t[38]!==c.hideConnectionOptions||t[39]!==i||t[40]!==d||t[41]!==r||t[42]!==a?(A=s?(0,U.jsx)(N,{type:`button`,variant:`ghost`,className:`px-2.5 py-1.5 text-xs`,disabled:i||r,onClick:d,children:a?c.hideConnectionOptions:c.connectionOptions}):null,t[36]=s,t[37]=c.connectionOptions,t[38]=c.hideConnectionOptions,t[39]=i,t[40]=d,t[41]=r,t[42]=a,t[43]=A):A=t[43];let j;t[44]!==O||t[45]!==k||t[46]!==A?(j=(0,U.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[O,k,A]}),t[44]=O,t[45]=k,t[46]=A,t[47]=j):j=t[47];let M;return t[48]!==w||t[49]!==j?(M=(0,U.jsx)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:(0,U.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[w,j]})}),t[48]=w,t[49]=j,t[50]=M):M=t[50],M}function ot(e){let t=(0,H.c)(33),{entry:n,ch:r}=e,i,a,o,s,c,l,u,d,f;if(t[0]!==r||t[1]!==n){f=Symbol.for(`react.early_return_sentinel`);bb0:{let e=Y(n);if(e.ready||e.issues.length===0){f=null;break bb0}d=`rounded-xl border border-amber-200 bg-amber-50 px-4 py-3 text-amber-950 dark:border-amber-900/50 dark:bg-amber-950/30 dark:text-amber-100`,l=`flex items-start gap-3`,t[11]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,U.jsx)(E,{className:`mt-0.5 size-4 shrink-0`}),t[11]=u):u=t[11],o=`min-w-0`,t[12]===r.setupReadinessTitle?s=t[13]:(s=(0,U.jsx)(`h3`,{className:`text-sm font-semibold`,children:r.setupReadinessTitle}),t[12]=r.setupReadinessTitle,t[13]=s);let p=e.enabled?r.setupReadinessEnabledBody:r.setupReadinessDisabledBody;t[14]===p?c=t[15]:(c=(0,U.jsx)(`p`,{className:`mt-1 text-sm leading-5 text-amber-900 dark:text-amber-200`,children:p}),t[14]=p,t[15]=c),i=`mt-2 list-disc space-y-1 pl-5 text-sm text-amber-900 dark:text-amber-200`;let m;t[16]===r?m=t[17]:(m=e=>(0,U.jsx)(`li`,{children:et(e,r)},`${e.code}:${e.fieldPath??``}`),t[16]=r,t[17]=m),a=e.issues.map(m)}t[0]=r,t[1]=n,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=f}else i=t[2],a=t[3],o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10];if(f!==Symbol.for(`react.early_return_sentinel`))return f;let p;t[18]!==i||t[19]!==a?(p=(0,U.jsx)(`ul`,{className:i,children:a}),t[18]=i,t[19]=a,t[20]=p):p=t[20];let m;t[21]!==p||t[22]!==o||t[23]!==s||t[24]!==c?(m=(0,U.jsxs)(`div`,{className:o,children:[s,c,p]}),t[21]=p,t[22]=o,t[23]=s,t[24]=c,t[25]=m):m=t[25];let h;t[26]!==m||t[27]!==l||t[28]!==u?(h=(0,U.jsxs)(`div`,{className:l,children:[u,m]}),t[26]=m,t[27]=l,t[28]=u,t[29]=h):h=t[29];let g;return t[30]!==h||t[31]!==d?(g=(0,U.jsx)(`section`,{className:d,children:h}),t[30]=h,t[31]=d,t[32]=g):g=t[32],g}function st(){let e=l(e=>e.language),t=s(e),n=c(e=>!!e.token),r=a(),{channelId:f}=i(),h=C(f),_=ke(n,e),y=_.entries,{data:b,mutate:S,isValidating:w}=p(n?fe():null,de,{revalidateOnFocus:!0}),{data:T,mutate:E}=p(n?`channels-config-map`:null,Le,{revalidateOnFocus:!1}),D=T?.channels??{},O=T?.bindings??[],{data:k}=p(n?`channel-routing-agents`:null,v,{revalidateOnFocus:!1}),j=x(e=>e.setPageHeader),M=x(e=>e.clearPageHeader),N=(0,V.useMemo)(()=>y.find(e=>e.id===h),[h,y]),ee=N?ze(N):null,{data:P,mutate:L}=p(n&&ee?Pe(ee):null,()=>Fe(ee)),[R,z]=(0,V.useState)(null),[ne,ie]=(0,V.useState)(!1),[ae,B]=(0,V.useState)(null),[ue,H]=(0,V.useState)(null),[me,he]=(0,V.useState)(!1),[W,G]=(0,V.useState)(null),[K,q]=(0,V.useState)(null),_e=R??P??{},J=t.channelsSettings,be=(0,V.useMemo)(()=>N?.configSchema??{type:`object`,properties:{}},[N?.configSchema]),Se=(0,V.useMemo)(()=>Ke(be,Ie),[be]),we=(0,V.useMemo)(()=>Ue(N),[N]),De=(0,V.useMemo)(()=>We(Se,we),[we,Se]),Oe=(0,V.useMemo)(()=>Ke(Se,we),[we,Se]),Ae=(0,V.useMemo)(()=>qe(De),[De]),Me=N?K??ve(O,N.id):``,Re=(0,V.useMemo)(()=>(k?.items??[]).map(e=>{let n=F(e,t.agentsSettings);return{value:e.id,label:n===e.id?n:`${n} · ${e.id}`}}),[k?.items,t.agentsSettings]),Ve=k?.items.find(e=>e.id===k.defaultId),X=Ve?F(Ve,t.agentsSettings):k?.defaultId??``,Z=(0,V.useMemo)(()=>({defaultBooleanLabel:J.schemaBooleanDefault,unsupportedArrayType:J.schemaUnsupportedArrayType,arrayAddPlaceholder:J.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>J.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[J]),Ge=(0,V.useMemo)(()=>new Map((b??[]).map(e=>[e.name,e])),[b]),Je=b!==void 0,Ye=(0,V.useCallback)(e=>xe(e,Ge.get(e.id),Je),[Ge,Je]),Q=(0,V.useCallback)(async()=>{await Promise.all([_.mutate(),S()])},[_,S]);Ne((0,V.useCallback)(e=>{let t=je(e);t&&S(t,!1)},[S]),n);let Xe=(0,V.useMemo)(()=>n?(0,U.jsx)(Te,{ch:J,refreshing:_.isValidating||w,saveOk:!1,onRefresh:()=>void Q()}):null,[_.isValidating,J,n,w,Q]);(0,V.useLayoutEffect)(()=>(j({startExtra:null,main:(0,U.jsx)(`div`,{className:`min-w-0`,children:(0,U.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.settingsSections.channels})}),end:Xe}),()=>M()),[M,Xe,t.settingsSections.channels,j]);let Ze=(0,V.useCallback)(e=>{r(te(e)),z(null),q(null),G(null)},[r]),Qe=(0,V.useCallback)(()=>{r(g),z(null),q(null),G(null)},[r]),$e=(0,V.useCallback)(async e=>{H(e.id),G(null);try{let t=await u(d(`/api/channels/${encodeURIComponent(e.id)}/restart`),{method:`POST`});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}await Q()}catch(e){G(e instanceof Error?e.message:String(e))}finally{H(null)}},[Q]);(0,V.useEffect)(()=>{q(null),he(!1)},[N?.id]);let et=(0,V.useCallback)(async()=>{if(!N||!R&&K===null)return!1;let e=ze(N);ie(!0),G(null);try{let t=await u(d(`/api/config`),{method:`PATCH`,body:JSON.stringify({...R?{channels:{[e]:R}}:{},...K===null?{}:{bindings:ye(O,N.id,K)}})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}return R&&await L(R,!1),await E(),await _.mutate(),z(null),q(null),!0}catch(e){return G(e instanceof Error?e.message:String(e)),!1}finally{ie(!1)}},[N,K,O,_,R,E,L]),it=(0,V.useCallback)(async e=>{let t=Y(e),n=ze(e),r=N?.id===e.id?R:null;if(!t.enabled&&!t.ready&&!r){Ze(e.id);return}B(e.id),G(null);try{let i=t.enabled?{enabled:!1}:r?{...r,enabled:!0}:{enabled:!0},a=await u(d(`/api/config`),{method:`PATCH`,body:JSON.stringify({channels:{[n]:i}})});if(!a.ok){let e=await a.json().catch(()=>({}));throw Error(e.error?.message??a.statusText)}await _.mutate(),await E(),await S(),N?.id===e.id&&(await L(),z(null))}catch(e){G(e instanceof Error?e.message:String(e))}finally{B(null)}},[N?.id,_,R,E,L,S,Ze]),$=N?.ui?.modal,st=$?.placement!==`replace-config`,ct=N?Ye(N):`checking`,lt=N?!Y(N).ready||me:!1;return n?(0,U.jsxs)(se,{gap:`gap-4`,children:[_.isLoading?(0,U.jsx)(ce,{sections:2}):_.error?(0,U.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:String(_.error)}):(0,U.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:y.map(e=>(0,U.jsx)(rt,{entry:e,config:D[ze(e)]?.config,runtime:Ye(e),busy:ae===e.id,restarting:ue===e.id,ch:J,onOpen:()=>Ze(e.id),onToggle:()=>void it(e),onRestart:()=>void $e(e)},e.id))}),W?(0,U.jsx)(`p`,{className:`mt-4 text-sm text-red-600 dark:text-red-400`,children:W}):null,(0,U.jsx)(Ce,{presentation:`modal`,open:!!N,onOpenChange:e=>{e||Qe()},closeAriaLabel:J.close,srTitle:N?.label??J.selectChannel,srDescription:N?.description,wide:!0,footer:N?(0,U.jsx)(Ee,{ch:J,dirty:!!R||K!==null,saving:ne,onCancel:Qe,onDiscard:()=>{z(null),q(null)},onSave:et}):null,children:N?(0,U.jsxs)(`div`,{className:`space-y-4`,children:[(0,U.jsx)(`div`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,children:(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,U.jsx)(tt,{entry:N}),(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,U.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:N.label}),(0,U.jsx)(`span`,{className:o(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,He(ct)),children:Be(ct,J)})]}),(0,U.jsxs)(`div`,{className:`mt-1 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-sm text-fg-muted`,children:[(0,U.jsx)(`span`,{className:`min-w-0 truncate`,children:!Y(N).ready&&pe(N)?.[1].result===`qr`?J.scanLoginHint.replace(`{{channel}}`,N.label):N.description}),N.docsPath?(0,U.jsxs)(`a`,{href:N.docsPath,target:`_blank`,rel:`noreferrer`,className:`inline-flex shrink-0 items-center gap-1 text-accent hover:underline`,children:[J.docs,(0,U.jsx)(m,{className:`size-3.5`})]}):null]})]})]}),(0,U.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pr-8`,children:[(0,U.jsx)(`span`,{className:`hidden text-xs text-fg-muted sm:inline`,children:Y(N).enabled?J.enabledLabel:J.disabledLabel}),(0,U.jsx)(nt,{checked:Y(N).enabled,disabled:ae===N.id,label:J.toggleChannel.replace(`{{channel}}`,N.label),onToggle:()=>void it(N)})]})]})}),(0,U.jsx)(at,{runtime:ct,restarting:ue===N.id,checking:w,showConnectionOptions:me,canManageConnection:Y(N).ready&&$?.placement!==`replace-config`,ch:J,onRestart:()=>void $e(N),onCheck:()=>void Q(),onManageConnection:()=>he(e=>!e)}),(0,U.jsx)(ot,{entry:N,ch:J}),lt&&$?.placement!==`replace-config`?(0,U.jsx)(ge,{entry:N,locale:e,messages:J,compact:!0,onChanged:async()=>{await L(),await Q(),await E()}},N.id):null,$?.entrypoint&&$.placement===`before-config`?(0,U.jsx)(I,{extensionId:N.extensionId,extensionName:N.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:N.id,entry:N,config:_e}}):null,$?.entrypoint&&$.placement!==`before-config`?(0,U.jsx)(I,{extensionId:N.extensionId,extensionName:N.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:N.id,entry:N,config:_e}}):null,st&&Ae?(0,U.jsxs)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:`mb-4`,children:[(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:J.basicConfiguration}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:J.basicConfigurationHint})]}),(0,U.jsx)(le,{schema:De,values:_e,onChange:e=>z(e),disabled:ne,labels:Z})]}):null,(0,U.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,U.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,U.jsx)(re,{className:`size-4 text-fg-muted`}),J.messageHandling]}),(0,U.jsxs)(`div`,{className:`bg-surface-base/50 p-4`,children:[(0,U.jsxs)(`div`,{className:`mb-3`,children:[(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:J.agentRouting}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:J.messageHandlingHint})]}),(0,U.jsx)(A,{value:Me,options:Re,placeholder:J.agentRoutingSelect,emptyLabel:J.agentRoutingDefault.replace(`{{agent}}`,X||J.agentRoutingSelect),ariaLabel:J.agentRouting,disabled:ne||!k,onChange:e=>q(e)})]})]}),st&&qe(Oe)?(0,U.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,U.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,U.jsx)(re,{className:`size-4 text-fg-muted`}),J.advancedConfiguration]}),(0,U.jsx)(`div`,{className:`bg-surface-base/50 p-4`,children:(0,U.jsx)(le,{schema:Oe,values:_e,onChange:e=>z(e),disabled:ne,labels:Z})})]}):null,W?(0,U.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:W}):null]}):null})]}):(0,U.jsxs)(se,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,U.jsx)(oe,{title:t.settingsSections.channels}),(0,U.jsx)(`p`,{className:`text-sm text-fg-muted`,children:J.tokenRequired})]})}export{st as ChannelsSettingsPanel};
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i,l as a}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as o}from"./cn-JdwAhgNB.js";import{t as s}from"./messages-DQ5X6cXp.js";import{l as c,n as l,o as u,r as d,s as f}from"./locale-store-Bjvw7jtg.js";import{i as p}from"./vendor-swr-BIWyz7Rc.js";import{Al as m,Ao as h,Ar as g,Da as _,Ea as v,Hs as y,Ko as b,La as x,Mo as S,Mr as C,Ni as w,No as T,Ns as E,Oa as D,Oo as O,Po as k,Uo as A,Xo as j,Zo as M,_s as N,bs as ee,dc as P,dr as F,dt as I,jo as L,jr as te,ko as R,ru as z,sc as ne,tc as re,tu as ie,us as ae,zc as B}from"./index-Cb9y6tVR.js";import{n as oe,r as se}from"./settings-page-layout-BdkN2U81.js";import{n as ce}from"./settings-loading-skeleton-Lz1ec5lN.js";import{t as le}from"./schema-form-DyXqGA71.js";import{t as ue}from"./browser-BLJWD7WI.js";import{n as de,t as fe}from"./channels-status-swr-DPaJSYX_.js";var V=e(t(),1),H=n();function pe(e){let t=e.actions??{};for(let e of[`login.start`,`setup.start`]){let n=t[e];if(n?.result===`qr`)return[e,n]}let n=Object.entries(t).find(([,e])=>e.result===`qr`);if(n)return n;let r=e.ui?.card?.primaryAction;if(r&&t[r])return[r,t[r]];for(let e of[`login.start`,`setup.start`]){let n=t[e];if(n)return[e,n]}return Object.entries(t).find(([,e])=>e.result===`form`)??null}var me=e(ue(),1),U=r();async function he(e){let t=await u(d(`/api/channels/${encodeURIComponent(e.channelId)}/actions/${encodeURIComponent(e.actionId)}?locale=${encodeURIComponent(e.locale)}`),{method:`POST`,body:JSON.stringify({...e.accountId?{accountId:e.accountId}:{},...e.input===void 0?{}:{input:e.input}})}),n=await t.json().catch(()=>({}));if(!t.ok||n.ok===!1)throw Error(n.error?.message??t.statusText);return n.payload??{type:`ok`}}function W(e){return e?.type===`poll`&&e.phase===`done`}function G(e){return e&&`message`in e&&typeof e.message==`string`?e.message:null}function K(e,t){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrPayload?e.qrPayload:t===`weixin`&&e.qrcodeUrl?e.qrcodeUrl:null}function q(e){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrcodeUrl??null}function ge({entry:e,locale:t,messages:n,onChanged:r,compact:i=!1}){let a=(0,V.useMemo)(()=>pe(e),[e]),s=(0,V.useMemo)(()=>({defaultBooleanLabel:n.schemaBooleanDefault,unsupportedArrayType:n.schemaUnsupportedArrayType,arrayAddPlaceholder:n.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>n.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[n]),[c,l]=(0,V.useState)({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null});(0,V.useEffect)(()=>{l({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null})},[e.id]);let u=(0,V.useCallback)(async(n,i)=>{l(e=>({...e,busy:!0,error:null}));try{let a=await he({channelId:e.id,actionId:n,locale:t,input:i});l(e=>({...e,payload:a,poll:a.type===`qr`&&a.statusAction&&a.sessionKey?{actionId:a.statusAction,sessionKey:a.sessionKey,intervalMs:Math.max(1e3,a.pollIntervalMs??2500)}:null,busy:!1,formDraft:a.type===`form`?a.values??{}:e.formDraft})),`configChanged`in a&&a.configChanged===!0&&await r()}catch(e){l(t=>({...t,busy:!1,error:e instanceof Error?e.message:String(e)}))}},[e.id,t,r]);(0,V.useEffect)(()=>{let t=K(c.payload,e.id);if(!t){l(e=>e.generatedQr?{...e,generatedQr:null}:e);return}let n=!1;return l(e=>e.generatedQr?{...e,generatedQr:null}:e),me.toDataURL(t,{width:220,margin:1}).then(e=>{n||l(t=>({...t,generatedQr:e}))}),()=>{n=!0}},[e.id,c.payload]),(0,V.useEffect)(()=>{let n=c.poll;if(!n)return;let i=!1,a=window.setInterval(()=>{i||he({channelId:e.id,actionId:n.actionId,locale:t,input:{sessionKey:n.sessionKey}}).then(async e=>{i||(l(t=>({...t,payload:e,poll:W(e)?null:t.poll,error:null})),`configChanged`in e&&e.configChanged===!0&&await r(),W(e)&&window.clearInterval(a))}).catch(e=>{i||l(t=>({...t,error:e instanceof Error?e.message:String(e)}))})},n.intervalMs);return()=>{i=!0,window.clearInterval(a)}},[e.id,t,r,c.poll]);let d=a?.[1].label??(e.configured?n.reconnect:n.connect),f=e.actions?.[`doctor.run`]?.label??n.diagnose,p=G(c.payload),h=K(c.payload,e.id),g=h?c.generatedQr:q(c.payload),v=a?.[1].result===`qr`&&(c.busy||c.payload?.type===`qr`||c.payload?.type===`poll`),b=c.payload?.type===`form`?c.payload:null,x=c.payload?.type===`diagnostics`?c.payload.checks:null;return(0,U.jsxs)(`div`,{className:i?`space-y-3`:`rounded-lg bg-surface-panel/80 p-4 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:o(`flex flex-wrap items-start gap-3`,i?`justify-end`:`justify-between`),children:[i?null:(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.setupTitle}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.configured?n.setupConfiguredHint:n.setupEmptyHint})]}),(0,U.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[a?(0,U.jsxs)(N,{type:`button`,variant:`primary`,disabled:c.busy,onClick:()=>void u(a[0]),children:[c.busy?(0,U.jsx)(B,{className:`size-4 animate-spin`}):(0,U.jsx)(P,{className:`size-4`}),d]}):null,e.actions?.[`doctor.run`]?(0,U.jsxs)(N,{type:`button`,variant:`secondary`,disabled:c.busy,onClick:()=>void u(`doctor.run`),children:[(0,U.jsx)(y,{className:`size-4`}),f]}):null]})]}),p?(0,U.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:p}):null,c.error?(0,U.jsx)(`p`,{className:`mt-3 text-sm text-red-600 dark:text-red-400`,children:c.error}):null,v?(0,U.jsxs)(`div`,{className:o(`flex h-80 items-center justify-center gap-4 overflow-hidden rounded-lg bg-surface-base p-3 shadow-surface`,i?`mt-1 flex-col text-center sm:h-64 sm:flex-row sm:text-left`:`mt-4 flex-col sm:h-64 sm:flex-row`),children:[(0,U.jsx)(`div`,{className:`flex size-56 shrink-0 items-center justify-center rounded-lg border border-edge bg-white p-3`,children:g?(0,U.jsx)(`img`,{src:g,alt:`${e.label} setup QR`,className:`size-52 object-contain`}):(0,U.jsx)(`div`,{className:`flex size-52 items-center justify-center rounded-md bg-surface-base`,children:(0,U.jsx)(_,{className:`size-48 rounded-md`})})}),(0,U.jsxs)(`div`,{className:o(`min-w-0 max-w-sm text-sm text-fg-muted`,i&&`w-full sm:w-auto`),children:[g?(0,U.jsx)(`p`,{className:`line-clamp-3`,children:n.waitingConfirmation}):(0,U.jsxs)(`div`,{className:`space-y-2`,"aria-busy":`true`,children:[(0,U.jsx)(_,{className:`h-4 w-48 max-w-full`}),(0,U.jsx)(_,{className:`h-4 w-36 max-w-full`})]}),h?(0,U.jsxs)(`a`,{className:`mt-2 inline-flex items-center gap-1 text-accent hover:underline`,href:h,target:`_blank`,rel:`noreferrer`,children:[n.openSetupLink,(0,U.jsx)(m,{className:`size-3.5`})]}):null]})]}):null,c.payload?.type===`poll`&&c.payload.phase===`done`?(0,U.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 rounded-lg bg-surface-base px-3 py-2 text-sm shadow-surface`,children:[(0,U.jsx)(ie,{className:c.payload.ok?`size-4 text-green-600`:`size-4 text-red-600`}),(0,U.jsx)(`span`,{className:c.payload.ok?`text-fg`:`text-red-600 dark:text-red-400`,children:c.payload.message??(c.payload.ok?n.complete:n.failed)})]}):null,b?(0,U.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,U.jsx)(le,{schema:b.schema,values:c.formDraft,onChange:e=>l(t=>({...t,formDraft:e})),disabled:c.busy,labels:s}),(0,U.jsx)(N,{type:`button`,variant:`primary`,disabled:c.busy,onClick:()=>void u(b.submitAction,c.formDraft),children:n.saveSetup})]}):null,x?(0,U.jsx)(`div`,{className:`mt-4 space-y-2`,children:x.map((e,t)=>(0,U.jsxs)(`div`,{className:`rounded-lg bg-surface-base px-3 py-2 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,U.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.label??e.id??n.diagnosticCheckFallback.replace(`{{index}}`,String(t+1))}),(0,U.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e.status??`unknown`})]}),e.message?(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.message}):null]},e.id??t))}):null]})}var _e=40;function J(e){return`ui:route:channel:${e.trim().toLowerCase()}`}function ve(e,t){return e.find(e=>e.id===J(t))?.agentId?.trim().toLowerCase()??``}function ye(e,t,n){let r=J(t),i=e.filter(e=>e.id!==r),a=n.trim().toLowerCase();return a?[...i,{id:r,agentId:a,priority:_e,enabled:!0,match:{channel:t.trim().toLowerCase(),accountId:`*`}}]:i}function be(e){let t=e.configured===!0,n=e.enabled===!0;return e.setupStatus??{enabled:n,ready:t,state:n&&!t?`needs_setup`:n?`ready`:`disabled`,issues:[]}}function xe(e,t,n){let r=be(e);return r.ready?r.enabled?n?t?.connected===!0?`running`:`stopped`:`checking`:`disabled`:`needs_setup`}function Se(e,t=!1){return e===`drawer`?o(`xopc-drawer-right fixed right-0 top-0 flex size-full flex-col overflow-hidden border-l border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`,t?`max-w-[36rem]`:`max-w-xl`,j):o(`fixed left-1/2 top-1/2 flex h-[min(calc(100dvh-2rem),52rem)] w-[min(calc(100%-2rem),32rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,t&&`h-[min(calc(100dvh-2rem),48rem)] w-[min(calc(100%-2rem),36rem)]`,j,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`)}function Ce(e){let t=(0,H.c)(33),{presentation:n,open:r,onOpenChange:i,title:a,description:s,srTitle:c,srDescription:l,closeAriaLabel:u,children:d,footer:f,wide:p,headerExtra:m}=e,g=p===void 0?!1:p,_=n===`drawer`,[v,y]=(0,V.useState)(null),x;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,U.jsx)(S,{className:o(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,M)}),t[0]=x):x=t[0];let C;t[1]!==n||t[2]!==g?(C=Se(n,g),t[1]=n,t[2]=g,t[3]=C):C=t[3];let w;t[4]===c?w=t[5]:(w=c?(0,U.jsx)(k,{className:`sr-only`,children:c}):null,t[4]=c,t[5]=w);let E;t[6]===l?E=t[7]:(E=l?(0,U.jsx)(L,{className:`sr-only`,children:l}):null,t[6]=l,t[7]=E);let D;t[8]!==u||t[9]!==s||t[10]!==m||t[11]!==_||t[12]!==a?(D=_?(0,U.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[a?(0,U.jsx)(`div`,{className:`text-base font-semibold text-fg`,children:a}):null,s?(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:s}):null]}),(0,U.jsx)(R,{asChild:!0,children:(0,U.jsx)(N,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":u,children:(0,U.jsx)(ee,{className:`size-5`,strokeWidth:1.75})})})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(R,{asChild:!0,children:(0,U.jsx)(`button`,{type:`button`,className:o(ae,`absolute right-3 top-3 z-20 p-1.5 hover:bg-surface-hover`),"aria-label":u,children:(0,U.jsx)(ee,{className:`size-4`})})}),m]}),t[8]=u,t[9]=s,t[10]=m,t[11]=_,t[12]=a,t[13]=D):D=t[13];let A=_?`p-4`:`p-6`,j;t[14]===A?j=t[15]:(j=o(`min-h-0 flex-1 overflow-y-auto`,A),t[14]=A,t[15]=j);let P;t[16]!==d||t[17]!==j?(P=(0,U.jsx)(`div`,{className:j,children:d}),t[16]=d,t[17]=j,t[18]=P):P=t[18];let F;t[19]!==f||t[20]!==v||t[21]!==w||t[22]!==E||t[23]!==D||t[24]!==P?(F=(0,U.jsxs)(b,{layer:`modal`,portalContainer:v,children:[w,E,D,P,f]}),t[19]=f,t[20]=v,t[21]=w,t[22]=E,t[23]=D,t[24]=P,t[25]=F):F=t[25];let I;t[26]!==F||t[27]!==C?(I=(0,U.jsxs)(T,{children:[x,(0,U.jsx)(h,{ref:y,className:C,onOpenAutoFocus:we,children:F})]}),t[26]=F,t[27]=C,t[28]=I):I=t[28];let te;return t[29]!==i||t[30]!==r||t[31]!==I?(te=(0,U.jsx)(O,{open:r,onOpenChange:i,children:I}),t[29]=i,t[30]=r,t[31]=I,t[32]=te):te=t[32],te}function we(e){return e.preventDefault()}var Te=(0,V.memo)(function(e){let t=(0,H.c)(10),{ch:n,refreshing:r,saveOk:i,onRefresh:a}=e,o;t[0]!==n.saved||t[1]!==i?(o=i?(0,U.jsx)(`span`,{className:`text-sm text-fg-muted`,children:n.saved}):null,t[0]=n.saved,t[1]=i,t[2]=o):o=t[2];let s;t[3]!==n.refresh||t[4]!==a||t[5]!==r?(s=(0,U.jsx)(w,{className:`size-9 shrink-0 p-0`,loading:r,label:n.refresh,onClick:a}),t[3]=n.refresh,t[4]=a,t[5]=r,t[6]=s):s=t[6];let c;return t[7]!==o||t[8]!==s?(c=(0,U.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center justify-end gap-2`,children:[o,s]}),t[7]=o,t[8]=s,t[9]=c):c=t[9],c});function Ee(e){let t=(0,H.c)(24),{ch:n,dirty:r,saving:i,onCancel:a,onDiscard:o,onSave:s,showCancel:c}=e,l=c===void 0?!0:c,u;t[0]!==n.unsavedHint||t[1]!==r?(u=r?(0,U.jsx)(`p`,{className:`mb-3 text-xs text-amber-800 dark:text-amber-200`,children:n.unsavedHint}):null,t[0]=n.unsavedHint,t[1]=r,t[2]=u):u=t[2];let d;t[3]!==n.modalCancel||t[4]!==a||t[5]!==l?(d=l?(0,U.jsx)(N,{type:`button`,variant:`secondary`,onClick:a,children:n.modalCancel}):null,t[3]=n.modalCancel,t[4]=a,t[5]=l,t[6]=d):d=t[6];let f=!r||i,p;t[7]!==n.discard||t[8]!==o||t[9]!==f?(p=(0,U.jsx)(N,{type:`button`,variant:`secondary`,disabled:f,onClick:o,children:n.discard}),t[7]=n.discard,t[8]=o,t[9]=f,t[10]=p):p=t[10];let m=!r||i,h;t[11]===s?h=t[12]:(h=()=>void s(),t[11]=s,t[12]=h);let g=i?n.saving:n.save,_;t[13]!==m||t[14]!==h||t[15]!==g?(_=(0,U.jsx)(N,{type:`button`,variant:`primary`,disabled:m,onClick:h,children:g}),t[13]=m,t[14]=h,t[15]=g,t[16]=_):_=t[16];let v;t[17]!==d||t[18]!==p||t[19]!==_?(v=(0,U.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[d,p,_]}),t[17]=d,t[18]=p,t[19]=_,t[20]=v):v=t[20];let y;return t[21]!==v||t[22]!==u?(y=(0,U.jsxs)(`div`,{className:`sticky bottom-0 shrink-0 border-t border-edge-subtle bg-surface-panel px-6 py-4 dark:border-edge-subtle`,children:[u,v]}),t[21]=v,t[22]=u,t[23]=y):y=t[23],y}function De(e){return d(`/api/channels/catalog?locale=${encodeURIComponent(e)}`)}async function Oe(e){return(await f(De(e))).payload?.channels??[]}function ke(e,t){let n=(0,H.c)(14),r;n[0]!==e||n[1]!==t?(r=e?De(t):null,n[0]=e,n[1]=t,n[2]=r):r=n[2];let i;n[3]===t?i=n[4]:(i=()=>Oe(t),n[3]=t,n[4]=i);let a;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(a={revalidateOnFocus:!1},n[5]=a):a=n[5];let{data:o,error:s,isLoading:c,isValidating:l,mutate:u}=p(r,i,a),d;n[6]===o?d=n[7]:(d=o??[],n[6]=o,n[7]=d);let f;return n[8]!==s||n[9]!==c||n[10]!==l||n[11]!==u||n[12]!==d?(f={entries:d,isLoading:c,isValidating:l,error:s,mutate:u},n[8]=s,n[9]=c,n[10]=l,n[11]=u,n[12]=d,n[13]=f):f=n[13],f}var Ae=`channels-status`;function je(e){if(!e||typeof e!=`object`)return null;let t=e.channels;return Array.isArray(t)?t:null}function Me(e){let t=t=>e(t.detail);return window.addEventListener(Ae,t),()=>window.removeEventListener(Ae,t)}function Ne(e,t){let n=(0,H.c)(4),r=t===void 0?!0:t,i,a;n[0]!==r||n[1]!==e?(i=()=>{if(r)return Me(e)},a=[r,e],n[0]=r,n[1]=e,n[2]=i,n[3]=a):(i=n[2],a=n[3]),(0,V.useEffect)(i,a)}function Pe(e){return e?d(`/api/channels/${encodeURIComponent(e)}/config`):null}async function Fe(e){return(await f(d(`/api/channels/${encodeURIComponent(e)}/config`))).payload?.config??{}}var Ie=[`enabled`];async function Le(){let e=await f(d(`/api/config`));return{channels:e.payload?.config?.channels??{},bindings:e.payload?.config?.bindings??[]}}function Re(e){return e.split(`/`).filter(Boolean).map(e=>encodeURIComponent(e)).join(`/`)}function ze(e){return e.configPath.startsWith(`channels.`)&&e.configPath.slice(9).split(`.`)[0]||e.id}function Y(e){let t=e.configured===!0,n=e.enabled===!0;return e.setupStatus??{enabled:n,ready:t,state:n&&!t?`needs_setup`:n?`ready`:`disabled`,issues:[]}}function Be(e,t){return e===`running`?t.connectionRunning:e===`stopped`?t.connectionStopped:e===`checking`?t.connectionChecking:e===`disabled`?t.connectionDisabled:t.connectionNeedsSetup}function Ve(e,t){return e===`running`?t.connectionRunningHint:e===`stopped`?t.connectionStoppedHint:e===`disabled`?t.connectionDisabledHint:e===`needs_setup`?t.connectionNeedsSetupHint:t.connectionChecking}function He(e){return e===`running`?`bg-emerald-500/12 text-emerald-700 dark:text-emerald-300`:e===`stopped`?`bg-red-500/10 text-red-700 dark:text-red-300`:e===`checking`?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:e===`disabled`?`bg-surface-hover text-fg-muted`:`bg-amber-500/10 text-amber-700 dark:text-amber-300`}function Ue(e){if(!e)return[];let t=e.uiHints??{},n=X(e.configSchema)&&Array.isArray(e.configSchema.required)?e.configSchema.required.map(String):[],r=Y(e).issues.map(e=>e.fieldPath).filter(e=>!!e),i=Object.entries(t).filter(([,e])=>!X(e)||e.advanced===!0?!1:(Array.isArray(e.tags)?e.tags.map(String):[]).includes(`basic`)||e.advanced===!1).map(([e])=>e).filter(e=>!Ie.includes(e));return Array.from(new Set([...i,...n,...r])).filter(e=>!Ie.includes(e))}function X(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Z(e){return JSON.parse(JSON.stringify(e??{type:`object`,properties:{}}))}function We(e,t){let n={...Z(e),properties:{}};for(let r of t){let t=r.split(`.`),i=e,a=n;for(let[e,n]of t.entries()){let r=i.properties;if(!X(r)||!X(r[n]))break;let o=X(a.properties)?a.properties:{};if(a.properties=o,o[n]||(o[n]={...Z(r[n]),properties:{}}),e===t.length-1){o[n]=Z(r[n]);break}i=r[n],a=o[n]}}return n}function Ge(e){let t=e.properties;if(!X(t))return!1;for(let[e,n]of Object.entries(t))X(n)&&n.type===`object`&&Ge(n)&&delete t[e];return Object.keys(t).length===0}function Ke(e,t){let n=Z(e);for(let e of t){let t=e.split(`.`),r=n;for(let[e,n]of t.entries()){let i=r.properties;if(!X(i))break;if(e===t.length-1){delete i[n];break}if(!X(i[n]))break;r=i[n]}}return Ge(n),n}function qe(e){return e.type===`object`&&X(e.properties)&&Object.keys(e.properties).length>0}function Je(e,t){let n=e;for(let e of t.split(`.`)){if(!X(n))return;n=n[e]}return n}function Ye(e){let t=e.accounts;return X(t)?Object.values(t).filter(e=>X(e)&&e.enabled!==!1).length:+(e.configured===!0)}function Q(e,t,n){return t==null||t===``?null:e.toLowerCase().includes(`dmpolicy`)&&typeof t==`string`?`${n.dmPolicy}: ${n.policy.dm[t]??t}`:(e.toLowerCase().includes(`stream`)||e.toLowerCase().includes(`streaming`))&&typeof t==`string`?`${n.cardStream}: ${n.policy.stream[t]??t}`:typeof t==`boolean`?t?n.enabledLabel:n.disabledLabel:String(t)}function Xe(e,t,n){let r=[],i=Y(e);if(i.issues.length>0&&r.push(et(i.issues[0],n)),t){let i=e.ui?.card?.summaryFields??[`dmPolicy`,`streamMode`,`streaming.mode`];for(let e of i){let i=Q(e,Je(t,e),n);i&&r.push(i)}let a=Ye(t);a>0&&r.push(n.cardAccounts.replace(`{{count}}`,String(a)))}return r.length>0?r.slice(0,2):i.ready?[n.hubStatusConfigured]:[]}function Ze(e,t){let n=Y(e),r=pe(e);return n.state===`needs_setup`?r?.[1].label??t.completeSetup:!n.enabled&&n.ready?t.enableChannel:n.state===`error`?t.diagnose:n.ready?t.manageChannel:r?.[1].label??t.startConfiguration}function Qe(e,t){let n=pe(e);return n?.[1].result===`qr`?t.cardSetupQrHint:n?.[1].result===`form`?t.cardSetupConfigHint:t.cardSetupGenericHint}function $e(e,t){let n=e.capabilities??{},r=[];return n.login===!0&&r.push(t.cardCapabilityLogin),n.pairing===!0&&r.push(t.cardCapabilityPairing),n.multiAccount===!0&&r.push(t.cardCapabilityMultiAccount),n.streaming===!0&&r.push(t.cardCapabilityStreaming),n.media===!0&&r.push(t.cardCapabilityMedia),n.doctor===!0&&r.push(t.cardCapabilityDoctor),r.slice(0,3)}function et(e,t){return e.code===`telegram.missing_credential`?t.setupIssueTelegramMissingCredential:e.code===`weixin.missing_account`?t.setupIssueWeixinMissingAccount:e.code===`feishu.missing_credentials`?t.setupIssueFeishuMissingCredentials:e.code===`config.missing_required`&&e.fieldPath?t.setupIssueMissingRequired.replace(`{{field}}`,e.fieldPath):e.message}function tt({entry:e}){let t=c(e=>e.token),[n,r]=(0,V.useState)(!1),i=(0,V.useMemo)(()=>{if(!e.ui?.icon||n)return null;let r=new URL(d(`/api/extensions/${encodeURIComponent(e.extensionId)}/assets/${Re(e.ui.icon)}`));return t?.trim()&&r.searchParams.set(`token`,t.trim()),r.toString()},[n,e.extensionId,e.ui?.icon,t]);return(0,U.jsx)(`span`,{className:`flex size-12 shrink-0 items-center justify-center rounded-2xl bg-surface-base text-fg`,children:i?(0,U.jsx)(`img`,{src:i,alt:``,draggable:!1,className:`size-7`,"aria-hidden":!0,onError:()=>r(!0)}):(0,U.jsx)(D,{sourceChannel:e.id,className:`size-7`})})}function nt(e){let t=(0,H.c)(16),{checked:n,disabled:r,onToggle:i,label:a}=e,s;t[0]===i?s=t[1]:(s=e=>{e.stopPropagation(),i()},t[0]=i,t[1]=s);let c=n?`border-accent bg-accent`:`border-edge bg-surface-hover`,l=r&&`cursor-not-allowed opacity-60`,u;t[2]!==c||t[3]!==l?(u=o(`relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border transition-colors`,c,l),t[2]=c,t[3]=l,t[4]=u):u=t[4];let d=n?`translate-x-5`:`translate-x-0.5`,f;t[5]===d?f=t[6]:(f=o(`size-5 rounded-full bg-white shadow-surface transition-transform`,d),t[5]=d,t[6]=f);let p;t[7]===f?p=t[8]:(p=(0,U.jsx)(`span`,{className:f}),t[7]=f,t[8]=p);let m;return t[9]!==n||t[10]!==r||t[11]!==a||t[12]!==s||t[13]!==u||t[14]!==p?(m=(0,U.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":n,"aria-label":a,disabled:r,onClick:s,className:u,children:p}),t[9]=n,t[10]=r,t[11]=a,t[12]=s,t[13]=u,t[14]=p,t[15]=m):m=t[15],m}function rt(e){let t=(0,H.c)(71),{entry:n,config:r,runtime:i,busy:a,restarting:s,ch:c,onOpen:l,onToggle:u,onRestart:d}=e,f;t[0]===n?f=t[1]:(f=Y(n),t[0]=n,t[1]=f);let p=f,m,h,g,_,v,y,b;if(t[2]!==a||t[3]!==c||t[4]!==r||t[5]!==n||t[6]!==l||t[7]!==d||t[8]!==u||t[9]!==i||t[10]!==p.enabled||t[11]!==p.ready){let e=Xe(n,r,c),s=$e(n,c);m=!p.enabled&&p.ready?u:i===`stopped`?d:l,y=`flex min-h-[15.5rem] flex-col rounded-xl bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45`;let f;t[19]===n?f=t[20]:(f=(0,U.jsx)(tt,{entry:n}),t[19]=n,t[20]=f);let x;t[21]===n.label?x=t[22]:(x=(0,U.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:n.label}),t[21]=n.label,t[22]=x);let S;t[23]===i?S=t[24]:(S=o(`mt-1 inline-flex rounded-full px-2 py-0.5 text-xs font-medium`,He(i)),t[23]=i,t[24]=S);let C;t[25]!==c||t[26]!==i?(C=Be(i,c),t[25]=c,t[26]=i,t[27]=C):C=t[27];let w;t[28]!==S||t[29]!==C?(w=(0,U.jsx)(`span`,{className:S,children:C}),t[28]=S,t[29]=C,t[30]=w):w=t[30];let T;t[31]!==w||t[32]!==x?(T=(0,U.jsxs)(`div`,{className:`min-w-0`,children:[x,w]}),t[31]=w,t[32]=x,t[33]=T):T=t[33];let E;t[34]!==T||t[35]!==f?(E=(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[f,T]}),t[34]=T,t[35]=f,t[36]=E):E=t[36];let D=p.enabled,O;t[37]!==c.toggleChannel||t[38]!==n.label?(O=c.toggleChannel.replace(`{{channel}}`,n.label),t[37]=c.toggleChannel,t[38]=n.label,t[39]=O):O=t[39];let k;t[40]!==a||t[41]!==u||t[42]!==p.enabled||t[43]!==O?(k=(0,U.jsx)(nt,{checked:D,disabled:a,label:O,onToggle:u}),t[40]=a,t[41]=u,t[42]=p.enabled,t[43]=O,t[44]=k):k=t[44],t[45]!==E||t[46]!==k?(b=(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[E,k]}),t[45]=E,t[46]=k,t[47]=b):b=t[47],h=`button`,g=l,_=`mt-5 min-h-[6.25rem] text-left`,v=p.ready?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`p`,{className:`line-clamp-2 text-sm leading-6 text-fg-muted`,children:n.description??n.id}),e.length>0?(0,U.jsx)(`div`,{className:`mt-3 space-y-0.5 text-sm leading-5 text-fg-muted`,children:e.map($)}):null]}):(0,U.jsxs)(`div`,{className:`rounded-lg bg-surface-base p-3`,children:[(0,U.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:c.cardSetupTitle}),(0,U.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm leading-5 text-fg-muted`,children:e[0]??Qe(n,c)}),s.length>0?(0,U.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:s.map(it)}):null]}),t[2]=a,t[3]=c,t[4]=r,t[5]=n,t[6]=l,t[7]=d,t[8]=u,t[9]=i,t[10]=p.enabled,t[11]=p.ready,t[12]=m,t[13]=h,t[14]=g,t[15]=_,t[16]=v,t[17]=y,t[18]=b}else m=t[12],h=t[13],g=t[14],_=t[15],v=t[16],y=t[17],b=t[18];let x;t[48]!==h||t[49]!==g||t[50]!==_||t[51]!==v?(x=(0,U.jsx)(`button`,{type:h,onClick:g,className:_,children:v}),t[48]=h,t[49]=g,t[50]=_,t[51]=v,t[52]=x):x=t[52];let S=a||s,C;t[53]!==a||t[54]!==s?(C=a||s?(0,U.jsx)(B,{className:`size-4 animate-spin`}):null,t[53]=a,t[54]=s,t[55]=C):C=t[55];let w;t[56]!==c||t[57]!==n||t[58]!==s||t[59]!==i?(w=s?c.restartingChannel:i===`stopped`?c.restartChannel:Ze(n,c),t[56]=c,t[57]=n,t[58]=s,t[59]=i,t[60]=w):w=t[60];let T;t[61]!==m||t[62]!==C||t[63]!==w||t[64]!==S?(T=(0,U.jsx)(`div`,{className:`mt-auto pt-4`,children:(0,U.jsxs)(N,{type:`button`,variant:`secondary`,className:`w-full rounded-2xl py-2.5`,onClick:m,disabled:S,children:[C,w]})}),t[61]=m,t[62]=C,t[63]=w,t[64]=S,t[65]=T):T=t[65];let E;return t[66]!==T||t[67]!==y||t[68]!==b||t[69]!==x?(E=(0,U.jsxs)(`article`,{className:y,children:[b,x,T]}),t[66]=T,t[67]=y,t[68]=b,t[69]=x,t[70]=E):E=t[70],E}function it(e){return(0,U.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e},e)}function $(e){return(0,U.jsx)(`p`,{className:`truncate`,title:e,children:e},e)}function at(e){let t=(0,H.c)(51),{runtime:n,restarting:r,checking:i,showConnectionOptions:a,canManageConnection:s,ch:c,onRestart:l,onCheck:u,onManageConnection:d}=e,f=n===`running`?ie:n===`stopped`||n===`needs_setup`?z:B,p=n===`running`&&`text-emerald-600 dark:text-emerald-400`,m=n===`stopped`&&`text-red-600 dark:text-red-400`,h=n===`checking`&&`animate-spin text-amber-600 dark:text-amber-400`,g=n===`disabled`&&`text-fg-muted`,_=n===`needs_setup`&&`text-amber-600 dark:text-amber-400`,v;t[0]!==p||t[1]!==m||t[2]!==h||t[3]!==g||t[4]!==_?(v=o(`mt-0.5 size-5 shrink-0`,p,m,h,g,_),t[0]=p,t[1]=m,t[2]=h,t[3]=g,t[4]=_,t[5]=v):v=t[5];let y;t[6]!==f||t[7]!==v?(y=(0,U.jsx)(f,{className:v}),t[6]=f,t[7]=v,t[8]=y):y=t[8];let b;t[9]===c.connectionStatus?b=t[10]:(b=(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:c.connectionStatus}),t[9]=c.connectionStatus,t[10]=b);let x;t[11]!==c||t[12]!==n?(x=Ve(n,c),t[11]=c,t[12]=n,t[13]=x):x=t[13];let S;t[14]===x?S=t[15]:(S=(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:x}),t[14]=x,t[15]=S);let C;t[16]!==S||t[17]!==b?(C=(0,U.jsxs)(`div`,{children:[b,S]}),t[16]=S,t[17]=b,t[18]=C):C=t[18];let w;t[19]!==C||t[20]!==y?(w=(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[y,C]}),t[19]=C,t[20]=y,t[21]=w):w=t[21];let T=i||r,E;t[22]===i?E=t[23]:(E=i?(0,U.jsx)(B,{className:`size-4 animate-spin`}):null,t[22]=i,t[23]=E);let D=i?c.checkingConnection:c.checkConnection,O;t[24]!==u||t[25]!==T||t[26]!==E||t[27]!==D?(O=(0,U.jsxs)(N,{type:`button`,variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:T,onClick:u,children:[E,D]}),t[24]=u,t[25]=T,t[26]=E,t[27]=D,t[28]=O):O=t[28];let k;t[29]!==c.restartChannel||t[30]!==c.restartingChannel||t[31]!==i||t[32]!==l||t[33]!==r||t[34]!==n?(k=n===`stopped`?(0,U.jsxs)(N,{type:`button`,variant:`primary`,className:`px-2.5 py-1.5 text-xs`,disabled:r||i,onClick:l,children:[r?(0,U.jsx)(B,{className:`size-4 animate-spin`}):(0,U.jsx)(ne,{className:`size-4`}),r?c.restartingChannel:c.restartChannel]}):null,t[29]=c.restartChannel,t[30]=c.restartingChannel,t[31]=i,t[32]=l,t[33]=r,t[34]=n,t[35]=k):k=t[35];let A;t[36]!==s||t[37]!==c.connectionOptions||t[38]!==c.hideConnectionOptions||t[39]!==i||t[40]!==d||t[41]!==r||t[42]!==a?(A=s?(0,U.jsx)(N,{type:`button`,variant:`ghost`,className:`px-2.5 py-1.5 text-xs`,disabled:i||r,onClick:d,children:a?c.hideConnectionOptions:c.connectionOptions}):null,t[36]=s,t[37]=c.connectionOptions,t[38]=c.hideConnectionOptions,t[39]=i,t[40]=d,t[41]=r,t[42]=a,t[43]=A):A=t[43];let j;t[44]!==O||t[45]!==k||t[46]!==A?(j=(0,U.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[O,k,A]}),t[44]=O,t[45]=k,t[46]=A,t[47]=j):j=t[47];let M;return t[48]!==w||t[49]!==j?(M=(0,U.jsx)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:(0,U.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[w,j]})}),t[48]=w,t[49]=j,t[50]=M):M=t[50],M}function ot(e){let t=(0,H.c)(33),{entry:n,ch:r}=e,i,a,o,s,c,l,u,d,f;if(t[0]!==r||t[1]!==n){f=Symbol.for(`react.early_return_sentinel`);bb0:{let e=Y(n);if(e.ready||e.issues.length===0){f=null;break bb0}d=`rounded-xl border border-amber-200 bg-amber-50 px-4 py-3 text-amber-950 dark:border-amber-900/50 dark:bg-amber-950/30 dark:text-amber-100`,l=`flex items-start gap-3`,t[11]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,U.jsx)(E,{className:`mt-0.5 size-4 shrink-0`}),t[11]=u):u=t[11],o=`min-w-0`,t[12]===r.setupReadinessTitle?s=t[13]:(s=(0,U.jsx)(`h3`,{className:`text-sm font-semibold`,children:r.setupReadinessTitle}),t[12]=r.setupReadinessTitle,t[13]=s);let p=e.enabled?r.setupReadinessEnabledBody:r.setupReadinessDisabledBody;t[14]===p?c=t[15]:(c=(0,U.jsx)(`p`,{className:`mt-1 text-sm leading-5 text-amber-900 dark:text-amber-200`,children:p}),t[14]=p,t[15]=c),i=`mt-2 list-disc space-y-1 pl-5 text-sm text-amber-900 dark:text-amber-200`;let m;t[16]===r?m=t[17]:(m=e=>(0,U.jsx)(`li`,{children:et(e,r)},`${e.code}:${e.fieldPath??``}`),t[16]=r,t[17]=m),a=e.issues.map(m)}t[0]=r,t[1]=n,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=f}else i=t[2],a=t[3],o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10];if(f!==Symbol.for(`react.early_return_sentinel`))return f;let p;t[18]!==i||t[19]!==a?(p=(0,U.jsx)(`ul`,{className:i,children:a}),t[18]=i,t[19]=a,t[20]=p):p=t[20];let m;t[21]!==p||t[22]!==o||t[23]!==s||t[24]!==c?(m=(0,U.jsxs)(`div`,{className:o,children:[s,c,p]}),t[21]=p,t[22]=o,t[23]=s,t[24]=c,t[25]=m):m=t[25];let h;t[26]!==m||t[27]!==l||t[28]!==u?(h=(0,U.jsxs)(`div`,{className:l,children:[u,m]}),t[26]=m,t[27]=l,t[28]=u,t[29]=h):h=t[29];let g;return t[30]!==h||t[31]!==d?(g=(0,U.jsx)(`section`,{className:d,children:h}),t[30]=h,t[31]=d,t[32]=g):g=t[32],g}function st(){let e=l(e=>e.language),t=s(e),n=c(e=>!!e.token),r=a(),{channelId:f}=i(),h=C(f),_=ke(n,e),y=_.entries,{data:b,mutate:S,isValidating:w}=p(n?fe():null,de,{revalidateOnFocus:!0}),{data:T,mutate:E}=p(n?`channels-config-map`:null,Le,{revalidateOnFocus:!1}),D=T?.channels??{},O=T?.bindings??[],{data:k}=p(n?`channel-routing-agents`:null,v,{revalidateOnFocus:!1}),j=x(e=>e.setPageHeader),M=x(e=>e.clearPageHeader),N=(0,V.useMemo)(()=>y.find(e=>e.id===h),[h,y]),ee=N?ze(N):null,{data:P,mutate:L}=p(n&&ee?Pe(ee):null,()=>Fe(ee)),[R,z]=(0,V.useState)(null),[ne,ie]=(0,V.useState)(!1),[ae,B]=(0,V.useState)(null),[ue,H]=(0,V.useState)(null),[me,he]=(0,V.useState)(!1),[W,G]=(0,V.useState)(null),[K,q]=(0,V.useState)(null),_e=R??P??{},J=t.channelsSettings,be=(0,V.useMemo)(()=>N?.configSchema??{type:`object`,properties:{}},[N?.configSchema]),Se=(0,V.useMemo)(()=>Ke(be,Ie),[be]),we=(0,V.useMemo)(()=>Ue(N),[N]),De=(0,V.useMemo)(()=>We(Se,we),[we,Se]),Oe=(0,V.useMemo)(()=>Ke(Se,we),[we,Se]),Ae=(0,V.useMemo)(()=>qe(De),[De]),Me=N?K??ve(O,N.id):``,Re=(0,V.useMemo)(()=>(k?.items??[]).map(e=>{let n=F(e,t.agentsSettings);return{value:e.id,label:n===e.id?n:`${n} · ${e.id}`}}),[k?.items,t.agentsSettings]),Ve=k?.items.find(e=>e.id===k.defaultId),X=Ve?F(Ve,t.agentsSettings):k?.defaultId??``,Z=(0,V.useMemo)(()=>({defaultBooleanLabel:J.schemaBooleanDefault,unsupportedArrayType:J.schemaUnsupportedArrayType,arrayAddPlaceholder:J.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>J.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[J]),Ge=(0,V.useMemo)(()=>new Map((b??[]).map(e=>[e.name,e])),[b]),Je=b!==void 0,Ye=(0,V.useCallback)(e=>xe(e,Ge.get(e.id),Je),[Ge,Je]),Q=(0,V.useCallback)(async()=>{await Promise.all([_.mutate(),S()])},[_,S]);Ne((0,V.useCallback)(e=>{let t=je(e);t&&S(t,!1)},[S]),n);let Xe=(0,V.useMemo)(()=>n?(0,U.jsx)(Te,{ch:J,refreshing:_.isValidating||w,saveOk:!1,onRefresh:()=>void Q()}):null,[_.isValidating,J,n,w,Q]);(0,V.useLayoutEffect)(()=>(j({startExtra:null,main:(0,U.jsx)(`div`,{className:`min-w-0`,children:(0,U.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.settingsSections.channels})}),end:Xe}),()=>M()),[M,Xe,t.settingsSections.channels,j]);let Ze=(0,V.useCallback)(e=>{r(te(e)),z(null),q(null),G(null)},[r]),Qe=(0,V.useCallback)(()=>{r(g),z(null),q(null),G(null)},[r]),$e=(0,V.useCallback)(async e=>{H(e.id),G(null);try{let t=await u(d(`/api/channels/${encodeURIComponent(e.id)}/restart`),{method:`POST`});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}await Q()}catch(e){G(e instanceof Error?e.message:String(e))}finally{H(null)}},[Q]);(0,V.useEffect)(()=>{q(null),he(!1)},[N?.id]);let et=(0,V.useCallback)(async()=>{if(!N||!R&&K===null)return!1;let e=ze(N);ie(!0),G(null);try{let t=await u(d(`/api/config`),{method:`PATCH`,body:JSON.stringify({...R?{channels:{[e]:R}}:{},...K===null?{}:{bindings:ye(O,N.id,K)}})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}return R&&await L(R,!1),await E(),await _.mutate(),z(null),q(null),!0}catch(e){return G(e instanceof Error?e.message:String(e)),!1}finally{ie(!1)}},[N,K,O,_,R,E,L]),it=(0,V.useCallback)(async e=>{let t=Y(e),n=ze(e),r=N?.id===e.id?R:null;if(!t.enabled&&!t.ready&&!r){Ze(e.id);return}B(e.id),G(null);try{let i=t.enabled?{enabled:!1}:r?{...r,enabled:!0}:{enabled:!0},a=await u(d(`/api/config`),{method:`PATCH`,body:JSON.stringify({channels:{[n]:i}})});if(!a.ok){let e=await a.json().catch(()=>({}));throw Error(e.error?.message??a.statusText)}await _.mutate(),await E(),await S(),N?.id===e.id&&(await L(),z(null))}catch(e){G(e instanceof Error?e.message:String(e))}finally{B(null)}},[N?.id,_,R,E,L,S,Ze]),$=N?.ui?.modal,st=$?.placement!==`replace-config`,ct=N?Ye(N):`checking`,lt=N?!Y(N).ready||me:!1;return n?(0,U.jsxs)(se,{gap:`gap-4`,children:[_.isLoading?(0,U.jsx)(ce,{sections:2}):_.error?(0,U.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:String(_.error)}):(0,U.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:y.map(e=>(0,U.jsx)(rt,{entry:e,config:D[ze(e)]?.config,runtime:Ye(e),busy:ae===e.id,restarting:ue===e.id,ch:J,onOpen:()=>Ze(e.id),onToggle:()=>void it(e),onRestart:()=>void $e(e)},e.id))}),W?(0,U.jsx)(`p`,{className:`mt-4 text-sm text-red-600 dark:text-red-400`,children:W}):null,(0,U.jsx)(Ce,{presentation:`modal`,open:!!N,onOpenChange:e=>{e||Qe()},closeAriaLabel:J.close,srTitle:N?.label??J.selectChannel,srDescription:N?.description,wide:!0,footer:N?(0,U.jsx)(Ee,{ch:J,dirty:!!R||K!==null,saving:ne,onCancel:Qe,onDiscard:()=>{z(null),q(null)},onSave:et}):null,children:N?(0,U.jsxs)(`div`,{className:`space-y-4`,children:[(0,U.jsx)(`div`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,children:(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,U.jsx)(tt,{entry:N}),(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,U.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:N.label}),(0,U.jsx)(`span`,{className:o(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,He(ct)),children:Be(ct,J)})]}),(0,U.jsxs)(`div`,{className:`mt-1 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-sm text-fg-muted`,children:[(0,U.jsx)(`span`,{className:`min-w-0 truncate`,children:!Y(N).ready&&pe(N)?.[1].result===`qr`?J.scanLoginHint.replace(`{{channel}}`,N.label):N.description}),N.docsPath?(0,U.jsxs)(`a`,{href:N.docsPath,target:`_blank`,rel:`noreferrer`,className:`inline-flex shrink-0 items-center gap-1 text-accent hover:underline`,children:[J.docs,(0,U.jsx)(m,{className:`size-3.5`})]}):null]})]})]}),(0,U.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pr-8`,children:[(0,U.jsx)(`span`,{className:`hidden text-xs text-fg-muted sm:inline`,children:Y(N).enabled?J.enabledLabel:J.disabledLabel}),(0,U.jsx)(nt,{checked:Y(N).enabled,disabled:ae===N.id,label:J.toggleChannel.replace(`{{channel}}`,N.label),onToggle:()=>void it(N)})]})]})}),(0,U.jsx)(at,{runtime:ct,restarting:ue===N.id,checking:w,showConnectionOptions:me,canManageConnection:Y(N).ready&&$?.placement!==`replace-config`,ch:J,onRestart:()=>void $e(N),onCheck:()=>void Q(),onManageConnection:()=>he(e=>!e)}),(0,U.jsx)(ot,{entry:N,ch:J}),lt&&$?.placement!==`replace-config`?(0,U.jsx)(ge,{entry:N,locale:e,messages:J,compact:!0,onChanged:async()=>{await L(),await Q(),await E()}},N.id):null,$?.entrypoint&&$.placement===`before-config`?(0,U.jsx)(I,{extensionId:N.extensionId,extensionName:N.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:N.id,entry:N,config:_e}}):null,$?.entrypoint&&$.placement!==`before-config`?(0,U.jsx)(I,{extensionId:N.extensionId,extensionName:N.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:N.id,entry:N,config:_e}}):null,st&&Ae?(0,U.jsxs)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:`mb-4`,children:[(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:J.basicConfiguration}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:J.basicConfigurationHint})]}),(0,U.jsx)(le,{schema:De,values:_e,onChange:e=>z(e),disabled:ne,labels:Z})]}):null,(0,U.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,U.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,U.jsx)(re,{className:`size-4 text-fg-muted`}),J.messageHandling]}),(0,U.jsxs)(`div`,{className:`bg-surface-base/50 p-4`,children:[(0,U.jsxs)(`div`,{className:`mb-3`,children:[(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:J.agentRouting}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:J.messageHandlingHint})]}),(0,U.jsx)(A,{value:Me,options:Re,placeholder:J.agentRoutingSelect,emptyLabel:J.agentRoutingDefault.replace(`{{agent}}`,X||J.agentRoutingSelect),ariaLabel:J.agentRouting,disabled:ne||!k,onChange:e=>q(e)})]})]}),st&&qe(Oe)?(0,U.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,U.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,U.jsx)(re,{className:`size-4 text-fg-muted`}),J.advancedConfiguration]}),(0,U.jsx)(`div`,{className:`bg-surface-base/50 p-4`,children:(0,U.jsx)(le,{schema:Oe,values:_e,onChange:e=>z(e),disabled:ne,labels:Z})})]}):null,W?(0,U.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:W}):null]}):null})]}):(0,U.jsxs)(se,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,U.jsx)(oe,{title:t.settingsSections.channels}),(0,U.jsx)(`p`,{className:`text-sm text-fg-muted`,children:J.tokenRequired})]})}export{st as ChannelsSettingsPanel};
|
package/dist/gateway/static/root/assets/{connectors-api-vaSrhPF8.js → connectors-api-Ne8mQrYN.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e,s as t}from"./locale-store-Bjvw7jtg.js";import{po as n}from"./index-
|
|
1
|
+
import{r as e,s as t}from"./locale-store-Bjvw7jtg.js";import{po as n}from"./index-Cb9y6tVR.js";function r(e,t){if(!e.payload)throw Error(e.error??t);return e.payload}async function i(){return r(await t(e(`/api/connectors/catalog`)),`Could not load connector catalog.`).connectors}async function a(n){let i=new URLSearchParams;return n?.q?.trim()&&i.set(`q`,n.q.trim()),n?.page&&i.set(`page`,String(n.page)),n?.pageSize&&i.set(`pageSize`,String(n.pageSize)),n?.refresh&&i.set(`refresh`,`1`),n?.verification&&i.set(`verification`,n.verification),r(await t(e(`/api/connectors/composio/catalog${i.size?`?${i.toString()}`:``}`)),`Could not load Composio catalog.`)}async function o(n){let i=new URLSearchParams;return n?.q?.trim()&&i.set(`q`,n.q.trim()),n?.page&&i.set(`page`,String(n.page)),n?.pageSize&&i.set(`pageSize`,String(n.pageSize)),n?.category?.trim()&&i.set(`category`,n.category.trim()),n?.sort&&i.set(`sort`,n.sort),r(await t(e(`/api/capabilities/connectors${i.size?`?${i.toString()}`:``}`)),`Could not load Store connector capabilities.`)}async function s(n,i){return r(await t(e(`/api/capabilities/connectors/${encodeURIComponent(n)}/install-plan`),{method:`POST`,body:JSON.stringify({version:i})}),`Could not prepare connector installation.`).plan}async function c(i,a,o){let s=await t(e(`/api/capabilities/connectors/${encodeURIComponent(i)}/install`),{method:`POST`,body:JSON.stringify({...a,version:o})});return n(),r(s,`Could not install Store connector.`).instance}async function l(){return r(await t(e(`/api/connectors/installed`)),`Could not load installed connectors.`).instances}async function u(n){return r(await t(e(`/api/connectors/${encodeURIComponent(n)}/auth/start`),{method:`POST`}),`Could not start connector authorization.`).authorization}async function d(){return r(await t(e(`/api/connectors/composio/setup-status`)),`Could not check the connection service.`)}async function f(n){r(await t(e(`/api/connectors/composio/setup`),{method:`POST`,body:JSON.stringify({apiKey:n})}),`Could not enable the connection service.`)}async function p(i,a){let o=await t(e(`/api/connectors/${encodeURIComponent(i)}/install`),{method:`POST`,body:JSON.stringify(a)});return n(),r(o,`Could not install connector.`).instance}async function m(n,i={}){return r(await t(e(`/api/connectors/preview`),{method:`POST`,body:JSON.stringify({...i,definition:n})}),`Could not preview connector capabilities.`).preview}async function h(n,i){return r(await t(e(`/api/connectors/${encodeURIComponent(n)}/config`),{method:`POST`,body:JSON.stringify(i)}),`Could not update connector config.`).instance}async function g(r){await t(e(`/api/connectors/${encodeURIComponent(r)}`),{method:`DELETE`}),n()}async function _(n){return r(await t(e(`/api/connectors/${encodeURIComponent(n)}/test`),{method:`POST`}),`Connector test failed.`)}async function v(){return r(await t(e(`/api/connectors/composio/connections`)),`Could not load Composio connections.`).connections}async function y(e,t,n=12e4){let r=Date.now()+n;for(;Date.now()<r;){let n=(await v().catch(()=>[])).find(n=>n.toolkit.toLowerCase()===e.toLowerCase()&&n.status===`active`&&(!t||n.providerConnectionId===t));if(n)return n;await new Promise(e=>window.setTimeout(e,2e3))}throw Error(`Connection authorization timed out.`)}async function b(n,i){return r(await t(e(`/api/connectors/composio/connections/${encodeURIComponent(n)}`),{method:`PATCH`,body:JSON.stringify(i)}),`Could not update Composio connection.`).connection}async function x(n){return r(await t(e(`/api/connectors/composio/${encodeURIComponent(n)}/health`)),`Could not check Composio connector health.`).health}async function S(n){await t(e(`/api/connectors/composio/connections/${encodeURIComponent(n)}/refresh`),{method:`POST`})}async function C(n){await t(e(`/api/connectors/composio/connections/${encodeURIComponent(n)}`),{method:`DELETE`})}async function w(n){return r(await t(e(`/api/connectors/composio/${encodeURIComponent(n)}/scope`)),`Could not load Composio scope.`).scope}async function T(i,a){let o=await t(e(`/api/connectors/composio/${encodeURIComponent(i)}/scope`),{method:`POST`,body:JSON.stringify({scope:a})});return n(),r(o,`Could not update Composio scope.`).scope}async function E(n){return r(await t(e(`/api/connectors/composio/${encodeURIComponent(n)}/policy`)),`Could not load Composio policy.`)}async function D(n,i){return r(await t(e(`/api/connectors/composio/${encodeURIComponent(n)}/policy`),{method:`PATCH`,body:JSON.stringify(i)}),`Could not update Composio policy.`).policy}async function O(n){return r(await t(e(`/api/connectors/composio/${encodeURIComponent(n)}/tools`)),`Could not load Composio tools.`).tools}async function k(n=50){return r(await t(e(`/api/connectors/composio/triggers?limit=${encodeURIComponent(String(n))}`)),`Could not load Composio trigger events.`).events}async function A(n){return r(await t(e(`/api/connectors/composio/accounts/${encodeURIComponent(n)}/learning`),{method:`POST`}),`Could not start learning from this connection.`).job}async function j(){return r(await t(e(`/api/connectors/learning`)),`Could not load connector learning jobs.`).jobs}async function M(n){return r(await t(e(`/api/connectors/composio/accounts/${encodeURIComponent(n)}/sync-policy`)),`Could not load connector sync policy.`).policy}async function N(n,i){return r(await t(e(`/api/connectors/composio/accounts/${encodeURIComponent(n)}/sync-policy`),{method:`PATCH`,body:JSON.stringify(i)}),`Could not update connector sync policy.`).policy}async function P(n){return r(await t(e(`/api/connectors/${encodeURIComponent(n)}/source-sync`),{method:`POST`}),`Could not sync connector source.`)}async function F(n=``,i=100){return r(await t(e(`/api/connectors/people?${new URLSearchParams({q:n,limit:String(i)}).toString()}`)),`Could not load the connected people graph.`)}async function I(n=`pending`){return r(await t(e(`/api/connectors/approvals?status=${encodeURIComponent(n)}`)),`Could not load connector approvals.`).approvals}async function L(n,i){return r(await t(e(`/api/connectors/approvals/respond`),{method:`POST`,body:JSON.stringify({id:n,decision:i})}),`Could not update connector approval.`).approval}export{b as A,L as C,u as D,A as E,h as M,N,P as O,y as P,g as S,T,k as _,l as a,m as b,x as c,d,M as f,O as g,v as h,i,D as j,_ as k,E as l,c as m,a as n,o,p,F as r,s,f as t,w as u,I as v,C as w,S as x,j as y};
|