@xopcai/xopc 0.0.190 → 0.0.191
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-9vAbkroX.js → agent-avatar-dicebear-DvEkT222.js} +1 -1
- package/dist/gateway/static/root/assets/{agents-D1t4SfMQ.js → agents-CXyivfqY.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-DkFeIdBf.js → app-management-settings-panel-COpP_pKN.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-Bxs8Fpaj.js → appearance-settings-DTVNUEDq.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-Cgrgu5OW.js → apps-page-DsE67BSO.js} +1 -1
- package/dist/gateway/static/root/assets/{archive-plugin-Ch2RmLCC.js → archive-plugin-IpX6VA0o.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-BhMQM_Ky.js → attachment-load-CKVFNUi1.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-CtJxstKh.js → automations-page-D0TVev47.js} +1 -1
- package/dist/gateway/static/root/assets/{binary-plugins-D6CqlymH.js → binary-plugins-BrfvfOS4.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-ClL6HEg9.js → block-editor-D9sEfg32.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-settings-page-DW99iDmD.js → browser-settings-page-DpZzq8j2.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-workflow-inputs-BYy48VhN.js → browser-workflow-inputs-BixZ5lCR.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-workflows-page-zgLibuMH.js → browser-workflows-page-YEFuodJI.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-settings-panel-CHUrT9EB.js → capabilities-settings-panel-B9Cmcuff.js} +2 -2
- package/dist/gateway/static/root/assets/{capability-presets-settings-panel-Cycrv0YV.js → capability-presets-settings-panel-C_EpuQtk.js} +1 -1
- package/dist/gateway/static/root/assets/{channels-settings-V96gPUAU.js → channels-settings-CvzD5qSv.js} +1 -1
- package/dist/gateway/static/root/assets/{connectors-api-DS9ED-EL.js → connectors-api-BMMqC0_9.js} +1 -1
- package/dist/gateway/static/root/assets/{connectors-page-BhlyQoQI.js → connectors-page-BKrm7tJ9.js} +1 -1
- package/dist/gateway/static/root/assets/{cron-expression-CkgsvhtW.js → cron-expression-Bm8koRoD.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-Cv8rGhYW.js → desktop-pet-CMG3mcaJ.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-CIeJdwfV.js → desktop-pet-settings-D8aaPb0x.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-D8jXEiAY.js → directory-picker-path-field-C95yW03b.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-CCZ9u6TZ.js → extension-debug-page-DsG7Z9lV.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-CV36ILRG.js → extension-page-CUAXEbAt.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-IyQrSILY.js → extension-settings-page-CsR7QOJo.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-api-D4_r5iJM.js → gateway-config-api-DL70Nakc.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-CYlntpBH.js → gateway-settings-BgDxQ08c.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-settings-D4SyWob8.js → heartbeat-settings-BX7q55uZ.js} +1 -1
- package/dist/gateway/static/root/assets/{home-page-B2Kagoh8.js → home-page-C08Nen5T.js} +1 -1
- package/dist/gateway/static/root/assets/{index-CYT5DOzr.js → index-B-_CEvIX.js} +7 -7
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-BMhCuVBZ.js → keyboard-shortcuts-settings-Dt6wS5zW.js} +1 -1
- package/dist/gateway/static/root/assets/{local-app-workbench-page-BHYbFjqy.js → local-app-workbench-page-BQVC0tWq.js} +1 -1
- package/dist/gateway/static/root/assets/{local-apps-page-ijIe7_y2.js → local-apps-page-DcD3-N00.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-IIn8Tess.js → logs-page-D6yvW-E4.js} +1 -1
- package/dist/gateway/static/root/assets/{management-settings--V_fovKD.js → management-settings-B6EVkJQy.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-split-Dt9-in6W.js → markdown-split-CHUjCnBh.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-B3pj_iO0.js → media-plugins-DRrtI2O0.js} +1 -1
- package/dist/gateway/static/root/assets/{notes-page-DZ366lIT.js → notes-page-fermYvpI.js} +1 -1
- package/dist/gateway/static/root/assets/{notes-workbench-S2sBVOLw.js → notes-workbench-BVCwabjq.js} +2 -2
- package/dist/gateway/static/root/assets/{page-tabs-C5ge434C.js → page-tabs-BO262zuu.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-BFa9DgSV.js → preview-open-alternatives-yZYTy-2e.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-Dc9CcWdu.js → product-open-page-Dgy8XWhR.js} +1 -1
- package/dist/gateway/static/root/assets/{project-detail-page-BilzoCJ7.js → project-detail-page-CS4Ujor7.js} +1 -1
- package/dist/gateway/static/root/assets/{projects-page-BoQUyacP.js → projects-page-DMtPC8c4.js} +1 -1
- package/dist/gateway/static/root/assets/{remote-access-hub-DUyUaCRF.js → remote-access-hub-BpfHZT88.js} +1 -1
- package/dist/gateway/static/root/assets/{schema-form-B84DckWe.js → schema-form-DdE4gtw_.js} +1 -1
- package/dist/gateway/static/root/assets/{sessions-page-Dzxlq1F0.js → sessions-page-BZkyrJBM.js} +1 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-DQlK0A4l.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-Dp9itvdy.js → settings-form-section-CiYU8AvV.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-loading-skeleton-CCtlhoy7.js → settings-loading-skeleton-Bv03cWib.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-DQmMKf8r.js → settings-page-C-LdINFj.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-layout-EQIOJa_L.js → settings-page-layout-t_Ox1slk.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-status-panel-Cwi-SPja.js → setup-status-panel-HRG_lK4_.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-C4_B2jvf.js → share-preview-page-DF8gW6bo.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-settings-CkyuGlZK.js → shares-settings-v_iLhxxa.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-reload-api-BJCePQK5.js → skill-reload-api-S-bjtsXX.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page-BYWLfmJi.js → skills-page-BiNBfaX5.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page.utils-Jhm24i4h.js → skills-page.utils-DlnGtvAH.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-Dpx2ags2.js → system-settings-panel-Bv7GXFc6.js} +1 -1
- package/dist/gateway/static/root/assets/{task-detail-page-DLAdxI6e.js → task-detail-page-BhQcOpnx.js} +1 -1
- package/dist/gateway/static/root/assets/{typed-models-lib-DULmTHUB.js → typed-models-lib-4XBsLEuv.js} +1 -1
- package/dist/gateway/static/root/assets/{use-autosave-BrjVk5VH.js → use-autosave-BN2QgFGn.js} +1 -1
- package/dist/gateway/static/root/assets/{user-context-page-9AAFpGAL.js → user-context-page-PtcY7BoJ.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-api-key-field-BISTPfq_.js → voice-api-key-field-DnhJtC5l.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-Wr-uF7VA.js → work-discovery-overlay-nmEAafFl.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-page-BWds95sL.js → work-discovery-page-C5Kwe_bc.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-DHqHP8_6.js → workflow-run-setup-panel-BnNWBDwz.js} +1 -1
- package/dist/gateway/static/root/assets/{workflows-page-0b4_DFHr.js → workflows-page-Z_qzaohv.js} +1 -1
- package/dist/gateway/static/root/index.html +1 -1
- package/dist/package.js +1 -1
- package/dist/src/agent/image/generation/openai-images-provider.d.ts +1 -1
- package/dist/src/agent/image/generation/openai-images-provider.js +1 -1
- package/dist/src/agent/image/generation/provider-registry.d.ts +2 -0
- package/dist/src/agent/image/generation/provider-registry.js +20 -10
- package/dist/src/agent/image/generation/providers/xopc-cloud.d.ts +2 -0
- package/dist/src/agent/image/generation/providers/xopc-cloud.js +74 -0
- package/dist/src/agent/image/generation/types.d.ts +2 -2
- package/dist/src/cli/commands/gateway/lifecycle.js +1 -1
- package/dist/src/cli/commands/onboard/model.d.ts +3 -0
- package/dist/src/cli/commands/onboard/model.js +19 -4
- package/dist/src/cli/commands/update.js +1 -1
- package/dist/src/config/agent-profile.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/models.js +9 -8
- 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 +5 -5
- 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/providers/model-catalog-store.d.ts +15 -0
- package/dist/src/providers/model-catalog-store.js +14 -1
- package/dist/src/providers/model-catalog-sync-service.js +6 -0
- package/dist/src/providers/model-registry.js +4 -4
- package/dist/src/providers/register-runtime-providers.js +4 -4
- package/dist/src/providers/xopc-cloud-model-source.js +55 -8
- package/dist/src/tui/backends/gateway-realtime-backend.js +1 -1
- package/package.json +3 -3
- package/dist/gateway/static/root/assets/settings-advanced-gate-TzwlZxU6.js +0 -1
|
@@ -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{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-B4XqB8I6.js";import{l as c,n as l}from"./locale-store-deR2zRaE.js";import{i as u}from"./vendor-swr-BIWyz7Rc.js";import{$s as d,Bo as f,Co as p,Do as m,Eo as h,Go as g,Lo as _,Mt as v,Nc as y,Ol as b,Oo as x,Or as S,Os as C,Ro as w,So as T,To as E,Us as D,Wo as O,Zl as k,au as A,bl as j,ds as M,fu as N,hs as P,is as F,lc as I,lu as L,ms as ee,oc as R,pu as z,qc as B,uu as V,wo as H,zo as U}from"./index-CYT5DOzr.js";import{n as te,r as ne}from"./settings-page-layout-EQIOJa_L.js";import{n as re,r as ie}from"./settings-loading-skeleton-CCtlhoy7.js";import{n as W,t as G}from"./settings-form-section-Dp9itvdy.js";import{a as ae,i as oe,n as se,o as ce,r as le,s as K,t as ue}from"./capability-presets-api-BB8t4Ja7.js";import{a as de,i as fe,o as q,s as J,t as Y}from"./typed-models-lib-DULmTHUB.js";import{r as pe}from"./image-generation-api-Bu7PyVSh.js";var me=n(),X=e(t(),1),Z=r(),Q=[`deep`,`fast`,`cheap`,`code`,`review`];function he(e){return Q.includes(e)}function ge(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:he(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})},y=(e,n)=>{let r=t[e];r&&p(e,{fallbacks:(r.fallbacks??[]).filter((e,t)=>t!==n)})},b=e=>{s.current.splice(e,1),n(t.filter((t,n)=>n!==e))},x=e=>{if(!e)return;let r=e===`__custom__`?``:e;s.current.push(`preset-model-row-${c.current++}`),n([...t,{id:r,model:``,fallbacks:[],description:he(r)?o.roleDescriptions[r]:``}])},S=[...Q.filter(e=>e!==l&&!t.some(t=>t.id===e)).map(e=>({value:e,label:o.roleNames[e]})),{value:`__custom__`,label:o.customRole}],w=(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)(M,{type:`button`,variant:`secondary`,className:`h-7 gap-1 px-2 text-xs`,disabled:r,onClick:()=>h(t),children:[(0,Z.jsx)(I,{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)(v,{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)(M,{type:`button`,variant:`secondary`,className:`shrink-0 px-2`,disabled:r,"aria-label":o.removeFallback,onClick:()=>y(t,n),children:(0,Z.jsx)(C,{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)(v,{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)(k,{className:`size-3.5 transition-transform group-open:rotate-180`,"aria-hidden":!0})]}),(0,Z.jsx)(`div`,{className:`mt-3`,children:w(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=he(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)(v,{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)(k,{className:`size-3.5 transition-transform group-open:rotate-180`,"aria-hidden":!0})]}),(0,Z.jsxs)(`div`,{className:`mt-3`,children:[w(e,t),(0,Z.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,Z.jsxs)(M,{type:`button`,variant:`secondary`,disabled:r,onClick:()=>b(t),children:[(0,Z.jsx)(C,{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)(_,{value:``,options:S,placeholder:o.addTaskModel,allowEmpty:!1,disabled:r,triggerClassName:`mt-3 w-fit`,onChange:x})]})]})}function _e(e){let t=(0,me.c)(62),{extendsIds:n,onExtendsChange:r,presetOptions:i,jsonFields:a,onJsonFieldsChange:o,disabled:s,labels:c}=e,l;t[0]===a?l=t[1]:(l=Object.keys(a),t[0]=a,t[1]=l);let u=l,d;t[2]===i?d=t[3]:(d=new Map(i.map(ve)),t[2]=i,t[3]=d);let f=d,p,m,h,g,_;if(t[4]!==s||t[5]!==n||t[6]!==c.inheritanceAdd||t[7]!==c.inheritanceApplied||t[8]!==c.inheritanceAvailable||t[9]!==c.inheritanceEmpty||t[10]!==c.inheritanceHint||t[11]!==c.inheritanceMoveDown||t[12]!==c.inheritanceMoveUp||t[13]!==c.inheritanceRemove||t[14]!==c.inheritanceTitle||t[15]!==r||t[16]!==f||t[17]!==i){let e;t[23]===n?e=t[24]:(e=e=>!n.includes(e.id),t[23]=n,t[24]=e);let a=i.filter(e);_=`flex flex-col gap-6`,t[25]===c.inheritanceTitle?p=t[26]:(p=(0,Z.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:c.inheritanceTitle}),t[25]=c.inheritanceTitle,t[26]=p),t[27]===c.inheritanceHint?m=t[28]:(m=(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:c.inheritanceHint}),t[27]=c.inheritanceHint,t[28]=m),t[29]!==s||t[30]!==n||t[31]!==c.inheritanceApplied||t[32]!==c.inheritanceMoveDown||t[33]!==c.inheritanceMoveUp||t[34]!==c.inheritanceRemove||t[35]!==r||t[36]!==f?(h=n.length>0?(0,Z.jsxs)(`div`,{className:`mt-3`,children:[(0,Z.jsx)(`div`,{className:`mb-2 text-xs font-medium text-fg-muted`,children:c.inheritanceApplied}),(0,Z.jsx)(`div`,{className:`grid gap-2`,children:n.map((e,t)=>(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:f.get(e)?.name??e}),(0,Z.jsx)(`div`,{className:`mt-0.5 font-mono text-[11px] text-fg-subtle`,children:e})]}),(0,Z.jsx)(M,{type:`button`,variant:`secondary`,className:`size-8 p-0`,disabled:s||t===0,"aria-label":c.inheritanceMoveUp,onClick:()=>{let e=[...n],[i,a]=[e[t],e[t-1]];e[t-1]=i,e[t]=a,r(e)},children:(0,Z.jsx)(L,{className:`size-3.5`,"aria-hidden":!0})}),(0,Z.jsx)(M,{type:`button`,variant:`secondary`,className:`size-8 p-0`,disabled:s||t===n.length-1,"aria-label":c.inheritanceMoveDown,onClick:()=>{let e=[...n],[i,a]=[e[t+1],e[t]];e[t]=i,e[t+1]=a,r(e)},children:(0,Z.jsx)(z,{className:`size-3.5`,"aria-hidden":!0})}),(0,Z.jsx)(M,{type:`button`,variant:`secondary`,className:`size-8 p-0`,disabled:s,"aria-label":c.inheritanceRemove,onClick:()=>r(n.filter(t=>t!==e)),children:(0,Z.jsx)(C,{className:`size-3.5`,"aria-hidden":!0})})]},e))})]}):null,t[29]=s,t[30]=n,t[31]=c.inheritanceApplied,t[32]=c.inheritanceMoveDown,t[33]=c.inheritanceMoveUp,t[34]=c.inheritanceRemove,t[35]=r,t[36]=f,t[37]=h):h=t[37],g=a.length>0?(0,Z.jsxs)(`div`,{className:`mt-3`,children:[(0,Z.jsx)(`div`,{className:`mb-2 text-xs font-medium text-fg-muted`,children:c.inheritanceAvailable}),(0,Z.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:a.map(e=>(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:e.name}),(0,Z.jsx)(`div`,{className:`mt-0.5 font-mono text-[11px] text-fg-subtle`,children:e.id})]}),(0,Z.jsx)(M,{type:`button`,variant:`secondary`,className:`size-8 p-0`,disabled:s,"aria-label":c.inheritanceAdd,onClick:()=>r([...n,e.id]),children:(0,Z.jsx)(I,{className:`size-3.5`,"aria-hidden":!0})})]},e.id))})]}):n.length===0?(0,Z.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:c.inheritanceEmpty}):null,t[4]=s,t[5]=n,t[6]=c.inheritanceAdd,t[7]=c.inheritanceApplied,t[8]=c.inheritanceAvailable,t[9]=c.inheritanceEmpty,t[10]=c.inheritanceHint,t[11]=c.inheritanceMoveDown,t[12]=c.inheritanceMoveUp,t[13]=c.inheritanceRemove,t[14]=c.inheritanceTitle,t[15]=r,t[16]=f,t[17]=i,t[18]=p,t[19]=m,t[20]=h,t[21]=g,t[22]=_}else p=t[18],m=t[19],h=t[20],g=t[21],_=t[22];let v;t[38]!==p||t[39]!==m||t[40]!==h||t[41]!==g?(v=(0,Z.jsxs)(`section`,{children:[p,m,h,g]}),t[38]=p,t[39]=m,t[40]=h,t[41]=g,t[42]=v):v=t[42];let y;t[43]===c.jsonTitle?y=t[44]:(y=(0,Z.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:c.jsonTitle}),t[43]=c.jsonTitle,t[44]=y);let b;t[45]===c.jsonHint?b=t[46]:(b=(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:c.jsonHint}),t[45]=c.jsonHint,t[46]=b);let x;t[47]!==s||t[48]!==u||t[49]!==a||t[50]!==c.fieldHints||t[51]!==c.fieldLabels||t[52]!==o?(x=(0,Z.jsx)(`div`,{className:`mt-3 grid gap-4 lg:grid-cols-2`,children:u.map(e=>(0,Z.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:c.fieldLabels[e]}),(0,Z.jsx)(`span`,{className:`min-h-8 text-xs leading-relaxed text-fg-muted`,children:c.fieldHints[e]}),(0,Z.jsx)(`textarea`,{className:`min-h-36 resize-y rounded-lg border border-edge bg-surface-base px-3 py-2 font-mono text-xs leading-relaxed text-fg placeholder:text-fg-subtle focus:border-edge-strong focus:outline-none`,value:a[e],disabled:s,spellCheck:!1,placeholder:`{}`,onChange:t=>o({...a,[e]:t.target.value})})]},e))}),t[47]=s,t[48]=u,t[49]=a,t[50]=c.fieldHints,t[51]=c.fieldLabels,t[52]=o,t[53]=x):x=t[53];let S;t[54]!==x||t[55]!==y||t[56]!==b?(S=(0,Z.jsxs)(`section`,{children:[y,b,x]}),t[54]=x,t[55]=y,t[56]=b,t[57]=S):S=t[57];let w;return t[58]!==S||t[59]!==_||t[60]!==v?(w=(0,Z.jsxs)(`div`,{className:_,children:[v,S]}),t[58]=S,t[59]=_,t[60]=v,t[61]=w):w=t[61],w}function ve(e){return[e.id,e]}function ye(e){return e.name||e.directoryId}function be(e){let t=(0,me.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(ye).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)(A,{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 k;t[36]!==O||t[37]!==b?(k=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[b,O]}),t[36]=O,t[37]=b,t[38]=k):k=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)(M,{type:`button`,variant:`secondary`,className:q,disabled:s||a||p.length===0,onClick:()=>l(new Set(p)),children:u.quickSelectAll}),(0,Z.jsx)(M,{type:`button`,variant:`secondary`,className:q,disabled:s||a||r.size===0,onClick:()=>l(new Set),children:u.quickClear})]})]}),a?(0,Z.jsx)(ie,{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=ye(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 N;return t[52]!==k||t[53]!==j||t[54]!==y?(N=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[y,k,j]}),t[52]=k,t[53]=j,t[54]=y,t[55]=N):N=t[55],N}var xe=[`write_file`,`apply_patch`,`exec_command`,`execute_code`],Se=[`exec_command`,`execute_code`,`automation`,`extensions`,`bundle-mcp`,`skill_manage`],Ce=[`send_message`,`send_media`,`text_to_speech`,`create_share`],we=[`read_file`,`list_dir`,`grep`,`find`,`web_search`,`web_fetch`,`web_extract`],Te=[...xe,...Ce],Ee=[`read_file`,`write_file`,`apply_patch`,`list_dir`,`grep`,`find`,`web_search`,`web_fetch`],De=[`send_message`,`send_media`];function Oe(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 ke(e){let t=(0,me.c)(105),{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(Ae),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 ce){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=K(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(Oe(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 T;t[27]!==a||t[28]!==l.quickClearOverrides||t[29]!==C?(T=(0,Z.jsx)(M,{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]=T):T=t[30];let E;t[31]===x?E=t[32]:(E=()=>x([[xe,`deny`]]),t[31]=x,t[32]=E);let D;t[33]!==a||t[34]!==l.quickReadOnlyWorkspace||t[35]!==E?(D=(0,Z.jsx)(M,{type:`button`,variant:`secondary`,className:q,disabled:a,onClick:E,children:l.quickReadOnlyWorkspace}),t[33]=a,t[34]=l.quickReadOnlyWorkspace,t[35]=E,t[36]=D):D=t[36];let O;t[37]===x?O=t[38]:(O=()=>x([[Se,`deny`]]),t[37]=x,t[38]=O);let k;t[39]!==a||t[40]!==l.quickHighRiskOff||t[41]!==O?(k=(0,Z.jsx)(M,{type:`button`,variant:`secondary`,className:q,disabled:a,onClick:O,children:l.quickHighRiskOff}),t[39]=a,t[40]=l.quickHighRiskOff,t[41]=O,t[42]=k):k=t[42];let A;t[43]===x?A=t[44]:(A=()=>x([[Ce,`deny`]]),t[43]=x,t[44]=A);let j;t[45]!==a||t[46]!==l.quickNoOutbound||t[47]!==A?(j=(0,Z.jsx)(M,{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 N;t[49]===x?N=t[50]:(N=()=>x([[we,`allow`],[Te,`deny`]]),t[49]=x,t[50]=N);let P;t[51]!==a||t[52]!==l.quickResearchMode||t[53]!==N?(P=(0,Z.jsx)(M,{type:`button`,variant:`secondary`,className:q,disabled:a,onClick:N,children:l.quickResearchMode}),t[51]=a,t[52]=l.quickResearchMode,t[53]=N,t[54]=P):P=t[54];let F;t[55]===x?F=t[56]:(F=()=>x([[Ee,`allow`],[De,`deny`]]),t[55]=x,t[56]=F);let I;t[57]!==a||t[58]!==l.quickCodingMode||t[59]!==F?(I=(0,Z.jsx)(M,{type:`button`,variant:`secondary`,className:q,disabled:a,onClick:F,children:l.quickCodingMode}),t[57]=a,t[58]=l.quickCodingMode,t[59]=F,t[60]=I):I=t[60];let L;t[61]!==k||t[62]!==j||t[63]!==P||t[64]!==I||t[65]!==T||t[66]!==D?(L=(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[T,D,k,j,P,I]}),t[61]=k,t[62]=j,t[63]=P,t[64]=I,t[65]=T,t[66]=D,t[67]=L):L=t[67];let ee;t[68]!==L||t[69]!==S?(ee=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[S,L]}),t[68]=L,t[69]=S,t[70]=ee):ee=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.scopeInherit||t[92]!==l.scopeLabel||t[93]!==l.scopeReadonly||t[94]!==l.scopeUnrestricted||t[95]!==l.scopeWorkspace||t[96]!==l.timeoutLabel||t[97]!==_||t[98]!==r||t[99]!==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-3 dark:border-edge`,children:[(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-fg-muted`,children:[l.scopeLabel,(0,Z.jsxs)(w,{value:n.scope??``,disabled:a,onChange:t=>y(e,e=>{let n=t.target.value;if(!n){let{scope:t,...n}=e;return n}return{...e,scope:n}}),children:[(0,Z.jsx)(U,{value:``,children:l.scopeInherit}),(0,Z.jsx)(U,{value:`readonly`,children:l.scopeReadonly}),(0,Z.jsx)(U,{value:`workspace`,children:l.scopeWorkspace}),(0,Z.jsx)(U,{value:`unrestricted`,children:l.scopeUnrestricted})]})]}),(0,Z.jsx)($,{label:l.maxCallsLabel,value:n.limits?.maxCallsPerTurn,disabled:a,onChange:t=>y(e,e=>je(e,`maxCallsPerTurn`,t))}),(0,Z.jsx)($,{label:l.timeoutLabel,value:n.limits?.timeoutMs,disabled:a,onChange:t=>y(e,e=>je(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.scopeInherit,t[92]=l.scopeLabel,t[93]=l.scopeReadonly,t[94]=l.scopeUnrestricted,t[95]=l.scopeWorkspace,t[96]=l.timeoutLabel,t[97]=_,t[98]=r,t[99]=y,t[100]=V):V=t[100];let H;return t[101]!==ee||t[102]!==B||t[103]!==V?(H=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[ee,B,V]}),t[101]=ee,t[102]=B,t[103]=V,t[104]=H):H=t[104],H}function Ae(e,t){let[n]=e,[r]=t;return n.localeCompare(r)}function je(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 $(e){let t=(0,me.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 Me=[`blank`,`safe-coder`,`read-only`,`low-cost`],Ne=[{id:`overview`,icon:b},{id:`models`,icon:B},{id:`tools`,icon:P},{id:`skills`,icon:R},{id:`advanced`,icon:D},{id:`impact`,icon:j}];function Pe(e){return fe(Object.entries(e?.models?.roles??{}).map(([e,t])=>({id:e,model:t.model,fallbacks:t.fallbacks??[],description:t.description})))}function Fe(e){return structuredClone(e?.tools?.builtin??{})}function Ie(e){let t=e?.skills;if(!t)return new Set;let n=t.mode===`denylist`?t.deny:t.allow;return new Set(n??[])}function Le(){return{primary:``,fallbacks:[],timeoutMs:``,autoProviderFallback:``}}function Re(e){return{primary:e?.primary??``,fallbacks:[...e?.fallbacks??[]],timeoutMs:e?.timeoutMs?String(e.timeoutMs):``,autoProviderFallback:e?.autoProviderFallback===void 0?``:e.autoProviderFallback?`true`:`false`}}function ze(){return{imageModel:Le(),imageGenerationModel:Le(),allowFallbacks:``,maxCostTier:``}}function Be(e){return{imageModel:Re(e?.models?.imageModel),imageGenerationModel:Re(e?.models?.imageGenerationModel),allowFallbacks:e?.models?.policy?.allowFallbacks===void 0?``:e.models.policy.allowFallbacks?`true`:`false`,maxCostTier:e?.models?.policy?.maxCostTier??``}}function Ve(e){return e===void 0?``:JSON.stringify(e,null,2)}function He(){return{mcp:``,workflows:``,boundaries:``,runtime:``,locks:``}}function Ue(e){return{mcp:Ve(e?.tools?.mcp),workflows:Ve(e?.workflows),boundaries:Ve(e?.boundaries),runtime:Ve(e?.runtime),locks:Ve(e?.locks)}}function We(e){return{id:e?.id??``,name:e?.name??``,description:e?.description??``,modelRows:Pe(e),modelAdvanced:Be(e),toolPolicies:Fe(e),skillMode:e?.skills?.mode??`inherit`,skillPick:Ie(e),extendsIds:[...e?.extends??[]],jsonFields:Ue(e)}}function Ge(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 Ke(e,t){let n=Y(e.modelRows),r=Ge(e.modelAdvanced.imageModel),i=Ge(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 qe(e){return e.trim()?JSON.parse(e):void 0}function Je(e){if(!e.trim())return``;try{return JSON.stringify(JSON.parse(e))}catch{return`!invalid:${e}`}}function Ye(e){let t=Object.fromEntries(Object.entries(e.toolPolicies).toSorted(([e],[t])=>e.localeCompare(t))),n=qe(e.jsonFields.mcp);return Object.keys(t).length>0||n?{builtin:t,...n?{mcp:n}:{}}:null}function Xe(e){return Object.fromEntries(Object.entries(e??{}).toSorted(([e],[t])=>e.localeCompare(t)))}function Ze(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 Qe(e,t){return{id:e.id.trim(),name:e.name.trim(),description:e.description.trim(),models:Ke(e,t),tools:{builtin:Xe(e.toolPolicies),mcp:Je(e.jsonFields.mcp)},skills:Ze(e),extends:[...e.extendsIds].toSorted(),workflows:Je(e.jsonFields.workflows),boundaries:Je(e.jsonFields.boundaries),runtime:Je(e.jsonFields.runtime),locks:Je(e.jsonFields.locks)}}function $e(e){return e?{id:e.id,name:e.name,description:e.description??``,models:e.models??null,tools:{builtin:Xe(e.tools?.builtin),mcp:Je(Ve(e.tools?.mcp))},skills:e.skills??null,extends:[...e.extends??[]].toSorted(),workflows:Je(Ve(e.workflows)),boundaries:Je(Ve(e.boundaries)),runtime:Je(Ve(e.runtime)),locks:Je(Ve(e.locks))}:null}function et(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 tt(e){return e===void 0?`—`:typeof e==`string`?e:JSON.stringify(e)}function nt(){return{modelAdvanced:ze(),extendsIds:[],jsonFields:He()}}function rt(e,t){return{extends:[...e.extendsIds],models:Ke(e,t)??void 0,tools:Ye(e)??void 0,skills:Ze(e)??void 0,workflows:qe(e.jsonFields.workflows),boundaries:qe(e.jsonFields.boundaries),runtime:qe(e.jsonFields.runtime),locks:qe(e.jsonFields.locks)}}function it(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`]),...nt()}: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,...nt()}: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,...nt()}:{id:``,name:``,description:``,modelRows:[],toolPolicies:{},skillMode:`inherit`,skillPick:new Set,...nt()}}function at(){let e=s(l(e=>e.language)),t=e.capabilityPresetsSettings,n=(0,Z.jsx)(M,{asChild:!0,type:`button`,variant:`secondary`,children:(0,Z.jsxs)(a,{to:`/agents`,children:[t.manageAgents,(0,Z.jsx)(V,{className:`size-4`,"aria-hidden":!0})]})}),r=!!c(e=>e.token),{data:_,error:v,isLoading:w,mutate:k}=u(r?`settings-capability-presets`:null,le,{revalidateOnFocus:!1}),{data:A=[],isLoading:L}=u(r?`settings-capability-presets-skills-catalog`:null,S,{revalidateOnFocus:!1}),[z,U]=i(),[ce,K]=(0,X.useState)(``),[fe,q]=(0,X.useState)(`overview`),[J,Y]=(0,X.useState)(()=>it(`blank`,t)),[pe,me]=(0,X.useState)(null),[Q,he]=(0,X.useState)(!1),[ve,ye]=(0,X.useState)(null),[xe,Se]=(0,X.useState)(!1),[Ce,we]=(0,X.useState)(null),[Te,Ee]=(0,X.useState)(null),De=_?.presets??[],Oe=_?.defaultPresetId??`default`,Ae=De.find(e=>e.id===Oe)??null,je=De.filter(e=>e.id!==Oe),$=(0,X.useMemo)(()=>De.find(e=>e.id===ce)??De[0]??null,[De,ce]),Pe=!$||J.id.trim()!==$.id,Fe=!!($&&$.id===Oe),Ie=JSON.stringify(Qe(J,$))!==JSON.stringify($e($)),Le=Qe(J,$),Re=$e($),ze=[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),Be=(0,X.useMemo)(()=>{if(!$||Pe)return null;try{let e=rt(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}}catch{return null}},[J,Pe,$]),{data:Ve,error:He,isLoading:Ue}=u(fe===`impact`&&$&&Be?[`capability-preset-impact-preview`,$.id,JSON.stringify(Be)]:null,()=>oe($.id,Be),{revalidateOnFocus:!1}),Ge=ve??(v instanceof Error?v.message:null),Ke=z.get(`action`)===`new`||!!z.get(`preset`),Je=z.get(`action`)===`new`&&pe===null,Ye=Pe?t.newPreset:$?.name??t.editorTitle,Xe=t=>e.agentsSettings.toolsDisableGroups[t],Ze=t=>t in e.agentsSettings.toolDescriptions?e.agentsSettings.toolDescriptions[t]:``;(0,X.useEffect)(()=>{if(!_||Q)return;if(z.get(`action`)===`new`){K(``),Y(it(`blank`,t)),q(`overview`);return}let e=z.get(`preset`)?.trim(),n=e?_.presets.find(t=>t.id===e):null;if(n){K(n.id),Y(We(n)),q(z.get(`tab`)??`overview`);return}$&&(K($.id),Y(e=>e.id===$.id?e:We($)))},[Q,_,z,$]);function nt(e){me(null),K(e.id),Y(We(e)),U({preset:e.id},{replace:!0}),q(`overview`)}function at(){me(null),K(``),Y(it(`blank`,t)),ye(null),U({action:`new`},{replace:!0}),q(`overview`)}function ct(e){me(e),Y(it(e,t)),ye(null),q(`overview`)}function lt(){if(pe){let e=it(pe,t);if(JSON.stringify(Qe(J,null))!==JSON.stringify(Qe(e,null))&&!window.confirm(t.changeTemplateConfirm))return}me(null),ye(null)}function ut(){!Je&&Ie&&!window.confirm(t.discardConfirm)||(Se(!1),we(null),U({},{replace:!0}),me(null),ye(null),Y(We($)),q(`overview`))}async function dt(){let e=de(J.modelRows,{invalidId:t.invalidModelRoleId,duplicateId:t.duplicateModelRoleId,invalidModel:t.invalidModelRef});if(e){ye(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))){ye(t.invalidModelRef),q(`models`);return}if(e.timeoutMs.trim()&&(!Number.isInteger(Number(e.timeoutMs))||Number(e.timeoutMs)<=0)){ye(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)){ye(t.advancedPositiveIntegerError),q(`tools`);return}for(let e of Object.keys(J.jsonFields))try{qe(J.jsonFields[e])}catch{ye(t.advancedJsonError.replace(`{{field}}`,t.advancedFieldLabels[e])),q(`advanced`);return}he(!0),ye(null);try{let e=rt(J,$);if(Pe){let t=await ue({id:J.id.trim(),name:J.name.trim(),...J.description.trim()?{description:J.description.trim()}:{},...e});await k(t.presets,{revalidate:!1}),K(t.presetId),me(null),U({preset:t.presetId},{replace:!0})}else $&&await k(await ae($.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){ye(e instanceof Error?e.message:t.saveError)}finally{he(!1)}}async function ft(){if($){he(!0),ye(null),we(null);try{await k(await se($.id),{revalidate:!1}),Se(!1),K(``),me(null),Y(it(`blank`,t)),q(`overview`),U({},{replace:!0})}catch(e){we(e instanceof Error?e.message:t.deleteError)}finally{he(!1)}}}return r?(0,Z.jsxs)(ne,{gap:`gap-5`,className:`pb-24`,children:[(0,Z.jsx)(te,{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)(M,{type:`button`,onClick:at,disabled:Q,children:[(0,Z.jsx)(I,{className:`size-4`,"aria-hidden":!0}),t.newPreset]})]})}),Ge?(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:Ge}):null,w?(0,Z.jsx)(re,{sections:2}):(0,Z.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[Ae?(0,Z.jsxs)(G,{children:[(0,Z.jsx)(W,{icon:B,title:t.globalDefaultsTitle,subtitle:t.globalDefaultsHint}),(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>nt(Ae),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:Ae.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:Ae.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})]}),Ae.description?(0,Z.jsx)(`p`,{className:`mt-3 line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:Ae.description}):null,(0,Z.jsx)(`div`,{className:`mt-3 text-xs text-fg-subtle`,children:et(Ae,t)})]})]}):null,(0,Z.jsxs)(G,{children:[(0,Z.jsx)(W,{icon:B,title:t.listTitle,subtitle:t.listHint}),je.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)(M,{type:`button`,variant:`secondary`,onClick:at,disabled:Q,children:[(0,Z.jsx)(I,{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:je.map(e=>(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>nt(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:et(e,t)})]},e.id))})]})]}),(0,Z.jsx)(T,{open:Ke,onOpenChange:e=>{e||ut()},children:(0,Z.jsxs)(m,{children:[(0,Z.jsx)(h,{className:o(`xopc-dialog-overlay fixed inset-0 bg-scrim`,g)}),(0,Z.jsx)(H,{ref:Ee,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`,O),onOpenAutoFocus:e=>e.preventDefault(),children:(0,Z.jsxs)(f,{layer:`modal`,portalContainer:Te,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:[!Je&&Pe&&pe?(0,Z.jsx)(`button`,{type:`button`,className:o(F,`shrink-0 p-1.5 hover:bg-surface-base`),onClick:lt,"aria-label":t.changeTemplate,title:t.changeTemplate,children:(0,Z.jsx)(N,{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:Ye}),(0,Z.jsx)(E,{className:`mt-0.5 truncate text-xs text-fg-muted`,children:Je?t.templatePickerSubtitle:Pe&&pe?`${t.editorHint} · ${t.basedOnTemplate.replace(`{{template}}`,t.starters[pe].title)}`:Pe?t.editorHint:J.id})]})]}),(0,Z.jsx)(p,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:o(F,`shrink-0 p-1.5 hover:bg-surface-base`),"aria-label":t.closeDialog,children:(0,Z.jsx)(ee,{className:`size-4`,"aria-hidden":!0})})})]}),Je?(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:Me.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:()=>ct(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)(M,{type:`button`,variant:`secondary`,onClick:ut,children:t.cancel})})]}):(0,Z.jsxs)(Z.Fragment,{children:[Ge?(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:Ge}):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:Ne.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`,fe===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:[fe===`overview`?(0,Z.jsxs)(G,{children:[(0,Z.jsx)(W,{icon:b,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)(ot,{icon:B,label:t.modelsTitle,value:String(J.modelRows.length)}),(0,Z.jsx)(ot,{icon:P,label:t.toolsTitle,value:String(Object.keys(J.toolPolicies).length)}),(0,Z.jsx)(ot,{icon:R,label:t.skillsTitle,value:t.skillModeLabels[J.skillMode]})]})]}):null,fe===`models`?(0,Z.jsxs)(G,{children:[(0,Z.jsx)(W,{icon:B,title:t.modelsTitle,subtitle:t.modelsHint}),(0,Z.jsx)(ge,{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)(st,{value:J.modelAdvanced,onChange:e=>Y(t=>({...t,modelAdvanced:e})),disabled:Q,cp:t,chat:e.chat})]}):null,fe===`tools`?(0,Z.jsxs)(G,{children:[(0,Z.jsx)(W,{icon:P,title:t.toolsTitle,subtitle:t.toolsHint}),(0,Z.jsx)(ke,{builtinToolIds:_?.builtinToolIds??[],toolPolicies:J.toolPolicies,onChange:e=>Y(t=>({...t,toolPolicies:e})),disabled:Q,getToolDescription:Ze,getGroupTitle:Xe,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,scopeLabel:t.toolScopeLabel,scopeInherit:t.toolScopeInherit,scopeReadonly:t.toolScopeReadonly,scopeWorkspace:t.toolScopeWorkspace,scopeUnrestricted:t.toolScopeUnrestricted,maxCallsLabel:t.toolMaxCallsLabel,timeoutLabel:t.toolTimeoutLabel}})]}):null,fe===`skills`?(0,Z.jsxs)(G,{children:[(0,Z.jsx)(W,{icon:R,title:t.skillsTitle,subtitle:t.skillsHint}),(0,Z.jsx)(be,{mode:J.skillMode,selected:J.skillPick,catalog:A,loading:L,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,fe===`advanced`?(0,Z.jsxs)(G,{children:[(0,Z.jsx)(W,{icon:D,title:t.advancedTitle,subtitle:t.advancedHint}),(0,Z.jsx)(_e,{extendsIds:J.extendsIds,onExtendsChange:e=>Y(t=>({...t,extendsIds:e})),presetOptions:De.filter(e=>e.id!==$?.id&&e.id!==Oe),jsonFields:J.jsonFields,onJsonFieldsChange:e=>Y(t=>({...t,jsonFields:e})),disabled:Q,labels:{inheritanceTitle:t.advancedInheritanceTitle,inheritanceHint:t.advancedInheritanceHint,inheritanceEmpty:t.advancedInheritanceEmpty,inheritanceApplied:t.advancedInheritanceApplied,inheritanceAvailable:t.advancedInheritanceAvailable,inheritanceAdd:t.advancedInheritanceAdd,inheritanceRemove:t.advancedInheritanceRemove,inheritanceMoveUp:t.advancedInheritanceMoveUp,inheritanceMoveDown:t.advancedInheritanceMoveDown,jsonTitle:t.advancedJsonTitle,jsonHint:t.advancedJsonHint,fieldLabels:t.advancedFieldLabels,fieldHints:t.advancedFieldHints}})]}):null,fe===`impact`?(0,Z.jsxs)(G,{children:[(0,Z.jsx)(W,{icon:j,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:ze.length>0?t.changePreviewSections.replace(`{{sections}}`,ze.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}),Ue?(0,Z.jsx)(ie,{rows:2}):He?(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}):Be?Ve?.agents.length?(0,Z.jsx)(`div`,{className:`grid gap-3`,children:Ve.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:tt(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:tt(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}):(0,Z.jsx)(`p`,{className:`rounded-lg bg-surface-panel/60 px-3 py-2 text-sm text-fg-muted shadow-surface`,children:t.effectiveChangePreviewInvalid})]}),$?.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)(M,{type:`button`,variant:`secondary`,disabled:Q,onClick:()=>Y(We($)),children:t.discard}):null,$&&!Fe?(0,Z.jsxs)(M,{type:`button`,variant:`secondary`,disabled:Q,onClick:()=>{we(null),Se(!0)},children:[(0,Z.jsx)(C,{className:`size-4`,"aria-hidden":!0}),t.delete]}):null,(0,Z.jsxs)(M,{type:`button`,disabled:Q||!J.id.trim()||!J.name.trim()||!Ie,onClick:()=>void dt(),children:[(0,Z.jsx)(d,{className:`size-4`,"aria-hidden":!0}),t.savePreset]})]})]})]})]})})]})}),(0,Z.jsx)(T,{open:xe,onOpenChange:e=>{Q||(Se(e),e||we(null))},children:(0,Z.jsxs)(m,{children:[(0,Z.jsx)(h,{className:o(`xopc-dialog-overlay fixed inset-0 bg-scrim`,g)}),(0,Z.jsxs)(H,{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`,O),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)(E,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:$?t.deleteConfirm.replace(`{{name}}`,$.name):t.deleteConfirmFallback})]}),Ce?(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:Ce}):null,(0,Z.jsxs)(`div`,{className:`flex justify-end gap-2 px-4 py-3`,children:[(0,Z.jsx)(M,{type:`button`,variant:`secondary`,disabled:Q,onClick:()=>Se(!1),children:t.cancel}),(0,Z.jsxs)(M,{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 ft(),children:[Q?(0,Z.jsx)(y,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(C,{className:`size-4`,"aria-hidden":!0}),Q?t.deleting:t.delete]})]})]})]})})]}):(0,Z.jsxs)(ne,{gap:`gap-3`,children:[(0,Z.jsx)(te,{title:t.title,actions:n}),(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.needToken})]})}function ot(e){let t=(0,me.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 st(e){let t=(0,me.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`,pe,s),f;t[1]===c?f=t[2]:(f=(c??[]).filter(ut).flatMap(lt),t[1]=c,t[2]=f);let p=f,m;t[3]===p?m=t[4]:(m=new Set(p.map(ct)),t[3]=p,t[4]=m);let h=m,g,_;t[5]!==h||t[6]!==c||t[7]!==r||t[8]!==n?(g=()=>{if(!c)return;let e=n.imageGenerationModel,t=h.has(e.primary)?e.primary:``,i=e.fallbacks.filter(e=>h.has(e));t===e.primary&&i.length===e.fallbacks.length||r({...n,imageGenerationModel:{...e,primary:t,fallbacks:i}})},_=[h,c,r,n],t[5]=h,t[6]=c,t[7]=r,t[8]=n,t[9]=g,t[10]=_):(g=t[9],_=t[10]),(0,X.useEffect)(g,_);let v;t[11]!==r||t[12]!==n?(v=(e,t)=>{r({...n,[e]:t})},t[11]=r,t[12]=n,t[13]=v):v=t[13];let y=v,b;t[14]===a.modelSpecializedTitle?b=t[15]:(b=(0,Z.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:a.modelSpecializedTitle}),t[14]=a.modelSpecializedTitle,t[15]=b);let x;t[16]!==a.modelNotSet||t[17]!==a.modelSpecializedSummary||t[18]!==n.imageGenerationModel.primary||t[19]!==n.imageModel.primary?(x=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]=x):x=t[20];let S;t[21]===x?S=t[22]:(S=(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:x}),t[21]=x,t[22]=S);let C;t[23]!==b||t[24]!==S?(C=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[b,S]}),t[23]=b,t[24]=S,t[25]=C):C=t[25];let T;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,Z.jsx)(k,{className:`size-4 shrink-0 text-fg-subtle transition-transform group-open:rotate-180`,"aria-hidden":!0}),t[26]=T):T=t[26];let E;t[27]===C?E=t[28]:(E=(0,Z.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-3 p-4`,children:[C,T]}),t[27]=C,t[28]=E);let D;t[29]===y?D=t[30]:(D=e=>y(`imageModel`,e),t[29]=y,t[30]=D);let O;t[31]!==o||t[32]!==a||t[33]!==i||t[34]!==D||t[35]!==n.imageModel?(O=(0,Z.jsx)(dt,{title:a.imageUnderstandingTitle,value:n.imageModel,onChange:D,disabled:i,cp:a,chat:o,capabilitiesFilter:`vision`}),t[31]=o,t[32]=a,t[33]=i,t[34]=D,t[35]=n.imageModel,t[36]=O):O=t[36];let A;t[37]===y?A=t[38]:(A=e=>y(`imageGenerationModel`,e),t[37]=y,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)(dt,{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]!==O||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:[O,M]}),t[51]=O,t[52]=M,t[53]=N):N=t[53];let P;t[54]!==E||t[55]!==N?(P=(0,Z.jsxs)(`details`,{className:`group rounded-xl border border-edge bg-surface-base`,children:[E,N]}),t[54]=E,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 ee;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(ee=(0,Z.jsx)(k,{className:`size-4 shrink-0 text-fg-subtle transition-transform group-open:rotate-180`,"aria-hidden":!0}),t[64]=ee):ee=t[64];let R;t[65]===L?R=t[66]:(R=(0,Z.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-3 p-4`,children:[L,ee]}),t[65]=L,t[66]=R);let z;t[67]===a.modelAllowFallbacksLabel?z=t[68]:(z=(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:a.modelAllowFallbacksLabel}),t[67]=a.modelAllowFallbacksLabel,t[68]=z);let B;t[69]!==r||t[70]!==n?(B=e=>r({...n,allowFallbacks:e.target.value}),t[69]=r,t[70]=n,t[71]=B):B=t[71];let V;t[72]===a.policyInherit?V=t[73]:(V=(0,Z.jsx)(U,{value:``,children:a.policyInherit}),t[72]=a.policyInherit,t[73]=V);let H;t[74]===a.policyEnabled?H=t[75]:(H=(0,Z.jsx)(U,{value:`true`,children:a.policyEnabled}),t[74]=a.policyEnabled,t[75]=H);let te;t[76]===a.policyDisabled?te=t[77]:(te=(0,Z.jsx)(U,{value:`false`,children:a.policyDisabled}),t[76]=a.policyDisabled,t[77]=te);let ne;t[78]!==i||t[79]!==B||t[80]!==V||t[81]!==H||t[82]!==te||t[83]!==n.allowFallbacks?(ne=(0,Z.jsxs)(w,{value:n.allowFallbacks,disabled:i,side:`top`,onChange:B,children:[V,H,te]}),t[78]=i,t[79]=B,t[80]=V,t[81]=H,t[82]=te,t[83]=n.allowFallbacks,t[84]=ne):ne=t[84];let re;t[85]!==z||t[86]!==ne?(re=(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[z,ne]}),t[85]=z,t[86]=ne,t[87]=re):re=t[87];let ie;t[88]===a.modelMaxCostTierLabel?ie=t[89]:(ie=(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:a.modelMaxCostTierLabel}),t[88]=a.modelMaxCostTierLabel,t[89]=ie);let W;t[90]!==r||t[91]!==n?(W=e=>r({...n,maxCostTier:e.target.value}),t[90]=r,t[91]=n,t[92]=W):W=t[92];let G;t[93]===a.policyInherit?G=t[94]:(G=(0,Z.jsx)(U,{value:``,children:a.policyInherit}),t[93]=a.policyInherit,t[94]=G);let ae;t[95]===a.costTierLow?ae=t[96]:(ae=(0,Z.jsx)(U,{value:`low`,children:a.costTierLow}),t[95]=a.costTierLow,t[96]=ae);let oe;t[97]===a.costTierMedium?oe=t[98]:(oe=(0,Z.jsx)(U,{value:`medium`,children:a.costTierMedium}),t[97]=a.costTierMedium,t[98]=oe);let se;t[99]===a.costTierHigh?se=t[100]:(se=(0,Z.jsx)(U,{value:`high`,children:a.costTierHigh}),t[99]=a.costTierHigh,t[100]=se);let ce;t[101]!==i||t[102]!==W||t[103]!==G||t[104]!==ae||t[105]!==oe||t[106]!==se||t[107]!==n.maxCostTier?(ce=(0,Z.jsxs)(w,{value:n.maxCostTier,disabled:i,side:`top`,onChange:W,children:[G,ae,oe,se]}),t[101]=i,t[102]=W,t[103]=G,t[104]=ae,t[105]=oe,t[106]=se,t[107]=n.maxCostTier,t[108]=ce):ce=t[108];let le;t[109]!==ie||t[110]!==ce?(le=(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[ie,ce]}),t[109]=ie,t[110]=ce,t[111]=le):le=t[111];let K;t[112]!==re||t[113]!==le?(K=(0,Z.jsxs)(`div`,{className:`grid gap-3 border-t border-edge-subtle p-4 dark:border-edge sm:grid-cols-2`,children:[re,le]}),t[112]=re,t[113]=le,t[114]=K):K=t[114];let ue;t[115]!==R||t[116]!==K?(ue=(0,Z.jsxs)(`details`,{className:`group rounded-xl border border-edge bg-surface-base`,children:[R,K]}),t[115]=R,t[116]=K,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 ct(e){return e.id}function lt(e){return e.models.map(t=>({id:`${e.id}/${t}`,name:t,provider:e.label}))}function ut(e){return e.configured||e.credentialMode===`none`}function dt(e){let t=(0,me.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,m;t[0]!==i||t[1]!==r?(m=(e,t)=>{i({...r,fallbacks:r.fallbacks.map((n,r)=>r===e?t:n)})},t[0]=i,t[1]=r,t[2]=m):m=t[2];let h=m,g;t[3]===n?g=t[4]:(g=(0,Z.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n}),t[3]=n,t[4]=g);let _=r.primary||o.modelNotSet,y;t[5]===_?y=t[6]:(y=(0,Z.jsx)(`span`,{className:`max-w-48 truncate font-mono text-xs text-fg-muted`,children:_}),t[5]=_,t[6]=y);let b;t[7]!==g||t[8]!==y?(b=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-2.5`,children:[g,y]}),t[7]=g,t[8]=y,t[9]=b):b=t[9];let x;t[10]===o.modelToolPrimaryLabel?x=t[11]:(x=(0,Z.jsx)(`div`,{className:`text-xs text-fg-muted`,children:o.modelToolPrimaryLabel}),t[10]=o.modelToolPrimaryLabel,t[11]=x);let S=f??s.modelNoMatches,T;t[12]!==i||t[13]!==r?(T=e=>i({...r,primary:e}),t[12]=i,t[13]=r,t[14]=T):T=t[14];let 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]!==S||t[24]!==T||t[25]!==r.primary?(E=(0,Z.jsx)(v,{value:r.primary,disabled:a,placeholder:s.modelPlaceholder,searchPlaceholder:s.modelSearchPlaceholder,noMatches:S,models:l,modelsLoading:u,modelsError:d,settingsFooterLink:p,capabilitiesFilter:c,className:`w-full max-w-none`,contentAlign:`start`,onChange:T}),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]=S,t[24]=T,t[25]=r.primary,t[26]=E):E=t[26];let D;t[27]!==o.modelClearSelection||t[28]!==a||t[29]!==i||t[30]!==r?(D=r.primary?(0,Z.jsx)(M,{type:`button`,variant:`secondary`,className:`shrink-0 px-2`,disabled:a,"aria-label":o.modelClearSelection,onClick:()=>i({...r,primary:``}),children:(0,Z.jsx)(ee,{className:`size-4`,strokeWidth:1.75})}):null,t[27]=o.modelClearSelection,t[28]=a,t[29]=i,t[30]=r,t[31]=D):D=t[31];let O;t[32]!==E||t[33]!==D?(O=(0,Z.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto] gap-2`,children:[E,D]}),t[32]=E,t[33]=D,t[34]=O):O=t[34];let k;t[35]!==O||t[36]!==x?(k=(0,Z.jsxs)(`div`,{className:`grid gap-1`,children:[x,O]}),t[35]=O,t[36]=x,t[37]=k):k=t[37];let A;t[38]===o.modelToolFallbacksLabel?A=t[39]:(A=(0,Z.jsx)(`div`,{className:`text-xs text-fg-muted`,children:o.modelToolFallbacksLabel}),t[38]=o.modelToolFallbacksLabel,t[39]=A);let j;t[40]!==i||t[41]!==r?(j=()=>i({...r,fallbacks:[...r.fallbacks,``]}),t[40]=i,t[41]=r,t[42]=j):j=t[42];let N;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,Z.jsx)(I,{className:`size-3.5`,strokeWidth:1.75}),t[43]=N):N=t[43];let P;t[44]!==o.modelAddFallback||t[45]!==a||t[46]!==j?(P=(0,Z.jsxs)(M,{type:`button`,variant:`secondary`,className:`h-7 gap-1 px-2 text-xs`,disabled:a,onClick:j,children:[N,o.modelAddFallback]}),t[44]=o.modelAddFallback,t[45]=a,t[46]=j,t[47]=P):P=t[47];let F;t[48]!==A||t[49]!==P?(F=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[A,P]}),t[48]=A,t[49]=P,t[50]=F):F=t[50];let L;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]!==h||t[65]!==r?(L=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)(v,{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=>h(t,e)}),(0,Z.jsx)(M,{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)(C,{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]=h,t[65]=r,t[66]=L):L=t[66];let R;t[67]!==F||t[68]!==L?(R=(0,Z.jsxs)(`div`,{className:`grid gap-1.5`,children:[F,L]}),t[67]=F,t[68]=L,t[69]=R):R=t[69];let z;t[70]!==i||t[71]!==r?(z=e=>i({...r,timeoutMs:e.target.value}),t[70]=i,t[71]=r,t[72]=z):z=t[72];let B;t[73]!==a||t[74]!==z||t[75]!==r.timeoutMs?(B=(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:z}),t[73]=a,t[74]=z,t[75]=r.timeoutMs,t[76]=B):B=t[76];let V;t[77]!==o.toolTimeoutLabel||t[78]!==B?(V=(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-fg-muted`,children:[o.toolTimeoutLabel,B]}),t[77]=o.toolTimeoutLabel,t[78]=B,t[79]=V):V=t[79];let H;t[80]!==i||t[81]!==r?(H=e=>i({...r,autoProviderFallback:e.target.value}),t[80]=i,t[81]=r,t[82]=H):H=t[82];let te;t[83]===o.policyInherit?te=t[84]:(te=(0,Z.jsx)(U,{value:``,children:o.policyInherit}),t[83]=o.policyInherit,t[84]=te);let ne;t[85]===o.policyEnabled?ne=t[86]:(ne=(0,Z.jsx)(U,{value:`true`,children:o.policyEnabled}),t[85]=o.policyEnabled,t[86]=ne);let re;t[87]===o.policyDisabled?re=t[88]:(re=(0,Z.jsx)(U,{value:`false`,children:o.policyDisabled}),t[87]=o.policyDisabled,t[88]=re);let ie;t[89]!==a||t[90]!==H||t[91]!==te||t[92]!==ne||t[93]!==re||t[94]!==r.autoProviderFallback?(ie=(0,Z.jsxs)(w,{value:r.autoProviderFallback,disabled:a,side:`top`,onChange:H,children:[te,ne,re]}),t[89]=a,t[90]=H,t[91]=te,t[92]=ne,t[93]=re,t[94]=r.autoProviderFallback,t[95]=ie):ie=t[95];let W;t[96]!==o.modelAutoProviderFallbackLabel||t[97]!==ie?(W=(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-fg-muted`,children:[o.modelAutoProviderFallbackLabel,ie]}),t[96]=o.modelAutoProviderFallbackLabel,t[97]=ie,t[98]=W):W=t[98];let G;t[99]!==V||t[100]!==W?(G=(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[V,W]}),t[99]=V,t[100]=W,t[101]=G):G=t[101];let ae;t[102]!==k||t[103]!==R||t[104]!==G?(ae=(0,Z.jsxs)(`div`,{className:`grid gap-3 border-t border-edge-subtle p-3 dark:border-edge`,children:[k,R,G]}),t[102]=k,t[103]=R,t[104]=G,t[105]=ae):ae=t[105];let oe;return t[106]!==ae||t[107]!==b?(oe=(0,Z.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/70 shadow-surface`,children:[b,ae]}),t[106]=ae,t[107]=b,t[108]=oe):oe=t[108],oe}export{at as CapabilityPresetsSettingsPanel};
|
|
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-B4XqB8I6.js";import{l as c,n as l}from"./locale-store-deR2zRaE.js";import{i as u}from"./vendor-swr-BIWyz7Rc.js";import{$s as d,Bo as f,Co as p,Do as m,Eo as h,Go as g,Lo as _,Mt as v,Nc as y,Ol as b,Oo as x,Or as S,Os as C,Ro as w,So as T,To as E,Us as D,Wo as O,Zl as k,au as A,bl as j,ds as M,fu as N,hs as P,is as F,lc as I,lu as L,ms as ee,oc as R,pu as z,qc as B,uu as V,wo as H,zo as U}from"./index-B-_CEvIX.js";import{n as te,r as ne}from"./settings-page-layout-t_Ox1slk.js";import{n as re,r as ie}from"./settings-loading-skeleton-Bv03cWib.js";import{n as W,t as G}from"./settings-form-section-CiYU8AvV.js";import{a as ae,i as oe,n as se,o as ce,r as le,s as K,t as ue}from"./capability-presets-api-BB8t4Ja7.js";import{a as de,i as fe,o as q,s as J,t as Y}from"./typed-models-lib-4XBsLEuv.js";import{r as pe}from"./image-generation-api-Bu7PyVSh.js";var me=n(),X=e(t(),1),Z=r(),Q=[`deep`,`fast`,`cheap`,`code`,`review`];function he(e){return Q.includes(e)}function ge(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:he(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})},y=(e,n)=>{let r=t[e];r&&p(e,{fallbacks:(r.fallbacks??[]).filter((e,t)=>t!==n)})},b=e=>{s.current.splice(e,1),n(t.filter((t,n)=>n!==e))},x=e=>{if(!e)return;let r=e===`__custom__`?``:e;s.current.push(`preset-model-row-${c.current++}`),n([...t,{id:r,model:``,fallbacks:[],description:he(r)?o.roleDescriptions[r]:``}])},S=[...Q.filter(e=>e!==l&&!t.some(t=>t.id===e)).map(e=>({value:e,label:o.roleNames[e]})),{value:`__custom__`,label:o.customRole}],w=(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)(M,{type:`button`,variant:`secondary`,className:`h-7 gap-1 px-2 text-xs`,disabled:r,onClick:()=>h(t),children:[(0,Z.jsx)(I,{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)(v,{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)(M,{type:`button`,variant:`secondary`,className:`shrink-0 px-2`,disabled:r,"aria-label":o.removeFallback,onClick:()=>y(t,n),children:(0,Z.jsx)(C,{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)(v,{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)(k,{className:`size-3.5 transition-transform group-open:rotate-180`,"aria-hidden":!0})]}),(0,Z.jsx)(`div`,{className:`mt-3`,children:w(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=he(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)(v,{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)(k,{className:`size-3.5 transition-transform group-open:rotate-180`,"aria-hidden":!0})]}),(0,Z.jsxs)(`div`,{className:`mt-3`,children:[w(e,t),(0,Z.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,Z.jsxs)(M,{type:`button`,variant:`secondary`,disabled:r,onClick:()=>b(t),children:[(0,Z.jsx)(C,{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)(_,{value:``,options:S,placeholder:o.addTaskModel,allowEmpty:!1,disabled:r,triggerClassName:`mt-3 w-fit`,onChange:x})]})]})}function _e(e){let t=(0,me.c)(62),{extendsIds:n,onExtendsChange:r,presetOptions:i,jsonFields:a,onJsonFieldsChange:o,disabled:s,labels:c}=e,l;t[0]===a?l=t[1]:(l=Object.keys(a),t[0]=a,t[1]=l);let u=l,d;t[2]===i?d=t[3]:(d=new Map(i.map(ve)),t[2]=i,t[3]=d);let f=d,p,m,h,g,_;if(t[4]!==s||t[5]!==n||t[6]!==c.inheritanceAdd||t[7]!==c.inheritanceApplied||t[8]!==c.inheritanceAvailable||t[9]!==c.inheritanceEmpty||t[10]!==c.inheritanceHint||t[11]!==c.inheritanceMoveDown||t[12]!==c.inheritanceMoveUp||t[13]!==c.inheritanceRemove||t[14]!==c.inheritanceTitle||t[15]!==r||t[16]!==f||t[17]!==i){let e;t[23]===n?e=t[24]:(e=e=>!n.includes(e.id),t[23]=n,t[24]=e);let a=i.filter(e);_=`flex flex-col gap-6`,t[25]===c.inheritanceTitle?p=t[26]:(p=(0,Z.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:c.inheritanceTitle}),t[25]=c.inheritanceTitle,t[26]=p),t[27]===c.inheritanceHint?m=t[28]:(m=(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:c.inheritanceHint}),t[27]=c.inheritanceHint,t[28]=m),t[29]!==s||t[30]!==n||t[31]!==c.inheritanceApplied||t[32]!==c.inheritanceMoveDown||t[33]!==c.inheritanceMoveUp||t[34]!==c.inheritanceRemove||t[35]!==r||t[36]!==f?(h=n.length>0?(0,Z.jsxs)(`div`,{className:`mt-3`,children:[(0,Z.jsx)(`div`,{className:`mb-2 text-xs font-medium text-fg-muted`,children:c.inheritanceApplied}),(0,Z.jsx)(`div`,{className:`grid gap-2`,children:n.map((e,t)=>(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:f.get(e)?.name??e}),(0,Z.jsx)(`div`,{className:`mt-0.5 font-mono text-[11px] text-fg-subtle`,children:e})]}),(0,Z.jsx)(M,{type:`button`,variant:`secondary`,className:`size-8 p-0`,disabled:s||t===0,"aria-label":c.inheritanceMoveUp,onClick:()=>{let e=[...n],[i,a]=[e[t],e[t-1]];e[t-1]=i,e[t]=a,r(e)},children:(0,Z.jsx)(L,{className:`size-3.5`,"aria-hidden":!0})}),(0,Z.jsx)(M,{type:`button`,variant:`secondary`,className:`size-8 p-0`,disabled:s||t===n.length-1,"aria-label":c.inheritanceMoveDown,onClick:()=>{let e=[...n],[i,a]=[e[t+1],e[t]];e[t]=i,e[t+1]=a,r(e)},children:(0,Z.jsx)(z,{className:`size-3.5`,"aria-hidden":!0})}),(0,Z.jsx)(M,{type:`button`,variant:`secondary`,className:`size-8 p-0`,disabled:s,"aria-label":c.inheritanceRemove,onClick:()=>r(n.filter(t=>t!==e)),children:(0,Z.jsx)(C,{className:`size-3.5`,"aria-hidden":!0})})]},e))})]}):null,t[29]=s,t[30]=n,t[31]=c.inheritanceApplied,t[32]=c.inheritanceMoveDown,t[33]=c.inheritanceMoveUp,t[34]=c.inheritanceRemove,t[35]=r,t[36]=f,t[37]=h):h=t[37],g=a.length>0?(0,Z.jsxs)(`div`,{className:`mt-3`,children:[(0,Z.jsx)(`div`,{className:`mb-2 text-xs font-medium text-fg-muted`,children:c.inheritanceAvailable}),(0,Z.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:a.map(e=>(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:e.name}),(0,Z.jsx)(`div`,{className:`mt-0.5 font-mono text-[11px] text-fg-subtle`,children:e.id})]}),(0,Z.jsx)(M,{type:`button`,variant:`secondary`,className:`size-8 p-0`,disabled:s,"aria-label":c.inheritanceAdd,onClick:()=>r([...n,e.id]),children:(0,Z.jsx)(I,{className:`size-3.5`,"aria-hidden":!0})})]},e.id))})]}):n.length===0?(0,Z.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:c.inheritanceEmpty}):null,t[4]=s,t[5]=n,t[6]=c.inheritanceAdd,t[7]=c.inheritanceApplied,t[8]=c.inheritanceAvailable,t[9]=c.inheritanceEmpty,t[10]=c.inheritanceHint,t[11]=c.inheritanceMoveDown,t[12]=c.inheritanceMoveUp,t[13]=c.inheritanceRemove,t[14]=c.inheritanceTitle,t[15]=r,t[16]=f,t[17]=i,t[18]=p,t[19]=m,t[20]=h,t[21]=g,t[22]=_}else p=t[18],m=t[19],h=t[20],g=t[21],_=t[22];let v;t[38]!==p||t[39]!==m||t[40]!==h||t[41]!==g?(v=(0,Z.jsxs)(`section`,{children:[p,m,h,g]}),t[38]=p,t[39]=m,t[40]=h,t[41]=g,t[42]=v):v=t[42];let y;t[43]===c.jsonTitle?y=t[44]:(y=(0,Z.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:c.jsonTitle}),t[43]=c.jsonTitle,t[44]=y);let b;t[45]===c.jsonHint?b=t[46]:(b=(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:c.jsonHint}),t[45]=c.jsonHint,t[46]=b);let x;t[47]!==s||t[48]!==u||t[49]!==a||t[50]!==c.fieldHints||t[51]!==c.fieldLabels||t[52]!==o?(x=(0,Z.jsx)(`div`,{className:`mt-3 grid gap-4 lg:grid-cols-2`,children:u.map(e=>(0,Z.jsxs)(`label`,{className:`flex min-w-0 flex-col gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:c.fieldLabels[e]}),(0,Z.jsx)(`span`,{className:`min-h-8 text-xs leading-relaxed text-fg-muted`,children:c.fieldHints[e]}),(0,Z.jsx)(`textarea`,{className:`min-h-36 resize-y rounded-lg border border-edge bg-surface-base px-3 py-2 font-mono text-xs leading-relaxed text-fg placeholder:text-fg-subtle focus:border-edge-strong focus:outline-none`,value:a[e],disabled:s,spellCheck:!1,placeholder:`{}`,onChange:t=>o({...a,[e]:t.target.value})})]},e))}),t[47]=s,t[48]=u,t[49]=a,t[50]=c.fieldHints,t[51]=c.fieldLabels,t[52]=o,t[53]=x):x=t[53];let S;t[54]!==x||t[55]!==y||t[56]!==b?(S=(0,Z.jsxs)(`section`,{children:[y,b,x]}),t[54]=x,t[55]=y,t[56]=b,t[57]=S):S=t[57];let w;return t[58]!==S||t[59]!==_||t[60]!==v?(w=(0,Z.jsxs)(`div`,{className:_,children:[v,S]}),t[58]=S,t[59]=_,t[60]=v,t[61]=w):w=t[61],w}function ve(e){return[e.id,e]}function ye(e){return e.name||e.directoryId}function be(e){let t=(0,me.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(ye).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)(A,{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 k;t[36]!==O||t[37]!==b?(k=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[b,O]}),t[36]=O,t[37]=b,t[38]=k):k=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)(M,{type:`button`,variant:`secondary`,className:q,disabled:s||a||p.length===0,onClick:()=>l(new Set(p)),children:u.quickSelectAll}),(0,Z.jsx)(M,{type:`button`,variant:`secondary`,className:q,disabled:s||a||r.size===0,onClick:()=>l(new Set),children:u.quickClear})]})]}),a?(0,Z.jsx)(ie,{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=ye(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 N;return t[52]!==k||t[53]!==j||t[54]!==y?(N=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[y,k,j]}),t[52]=k,t[53]=j,t[54]=y,t[55]=N):N=t[55],N}var xe=[`write_file`,`apply_patch`,`exec_command`,`execute_code`],Se=[`exec_command`,`execute_code`,`automation`,`extensions`,`bundle-mcp`,`skill_manage`],Ce=[`send_message`,`send_media`,`text_to_speech`,`create_share`],we=[`read_file`,`list_dir`,`grep`,`find`,`web_search`,`web_fetch`,`web_extract`],Te=[...xe,...Ce],Ee=[`read_file`,`write_file`,`apply_patch`,`list_dir`,`grep`,`find`,`web_search`,`web_fetch`],De=[`send_message`,`send_media`];function Oe(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 ke(e){let t=(0,me.c)(105),{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(Ae),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 ce){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=K(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(Oe(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 T;t[27]!==a||t[28]!==l.quickClearOverrides||t[29]!==C?(T=(0,Z.jsx)(M,{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]=T):T=t[30];let E;t[31]===x?E=t[32]:(E=()=>x([[xe,`deny`]]),t[31]=x,t[32]=E);let D;t[33]!==a||t[34]!==l.quickReadOnlyWorkspace||t[35]!==E?(D=(0,Z.jsx)(M,{type:`button`,variant:`secondary`,className:q,disabled:a,onClick:E,children:l.quickReadOnlyWorkspace}),t[33]=a,t[34]=l.quickReadOnlyWorkspace,t[35]=E,t[36]=D):D=t[36];let O;t[37]===x?O=t[38]:(O=()=>x([[Se,`deny`]]),t[37]=x,t[38]=O);let k;t[39]!==a||t[40]!==l.quickHighRiskOff||t[41]!==O?(k=(0,Z.jsx)(M,{type:`button`,variant:`secondary`,className:q,disabled:a,onClick:O,children:l.quickHighRiskOff}),t[39]=a,t[40]=l.quickHighRiskOff,t[41]=O,t[42]=k):k=t[42];let A;t[43]===x?A=t[44]:(A=()=>x([[Ce,`deny`]]),t[43]=x,t[44]=A);let j;t[45]!==a||t[46]!==l.quickNoOutbound||t[47]!==A?(j=(0,Z.jsx)(M,{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 N;t[49]===x?N=t[50]:(N=()=>x([[we,`allow`],[Te,`deny`]]),t[49]=x,t[50]=N);let P;t[51]!==a||t[52]!==l.quickResearchMode||t[53]!==N?(P=(0,Z.jsx)(M,{type:`button`,variant:`secondary`,className:q,disabled:a,onClick:N,children:l.quickResearchMode}),t[51]=a,t[52]=l.quickResearchMode,t[53]=N,t[54]=P):P=t[54];let F;t[55]===x?F=t[56]:(F=()=>x([[Ee,`allow`],[De,`deny`]]),t[55]=x,t[56]=F);let I;t[57]!==a||t[58]!==l.quickCodingMode||t[59]!==F?(I=(0,Z.jsx)(M,{type:`button`,variant:`secondary`,className:q,disabled:a,onClick:F,children:l.quickCodingMode}),t[57]=a,t[58]=l.quickCodingMode,t[59]=F,t[60]=I):I=t[60];let L;t[61]!==k||t[62]!==j||t[63]!==P||t[64]!==I||t[65]!==T||t[66]!==D?(L=(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[T,D,k,j,P,I]}),t[61]=k,t[62]=j,t[63]=P,t[64]=I,t[65]=T,t[66]=D,t[67]=L):L=t[67];let ee;t[68]!==L||t[69]!==S?(ee=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[S,L]}),t[68]=L,t[69]=S,t[70]=ee):ee=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.scopeInherit||t[92]!==l.scopeLabel||t[93]!==l.scopeReadonly||t[94]!==l.scopeUnrestricted||t[95]!==l.scopeWorkspace||t[96]!==l.timeoutLabel||t[97]!==_||t[98]!==r||t[99]!==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-3 dark:border-edge`,children:[(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-fg-muted`,children:[l.scopeLabel,(0,Z.jsxs)(w,{value:n.scope??``,disabled:a,onChange:t=>y(e,e=>{let n=t.target.value;if(!n){let{scope:t,...n}=e;return n}return{...e,scope:n}}),children:[(0,Z.jsx)(U,{value:``,children:l.scopeInherit}),(0,Z.jsx)(U,{value:`readonly`,children:l.scopeReadonly}),(0,Z.jsx)(U,{value:`workspace`,children:l.scopeWorkspace}),(0,Z.jsx)(U,{value:`unrestricted`,children:l.scopeUnrestricted})]})]}),(0,Z.jsx)($,{label:l.maxCallsLabel,value:n.limits?.maxCallsPerTurn,disabled:a,onChange:t=>y(e,e=>je(e,`maxCallsPerTurn`,t))}),(0,Z.jsx)($,{label:l.timeoutLabel,value:n.limits?.timeoutMs,disabled:a,onChange:t=>y(e,e=>je(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.scopeInherit,t[92]=l.scopeLabel,t[93]=l.scopeReadonly,t[94]=l.scopeUnrestricted,t[95]=l.scopeWorkspace,t[96]=l.timeoutLabel,t[97]=_,t[98]=r,t[99]=y,t[100]=V):V=t[100];let H;return t[101]!==ee||t[102]!==B||t[103]!==V?(H=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[ee,B,V]}),t[101]=ee,t[102]=B,t[103]=V,t[104]=H):H=t[104],H}function Ae(e,t){let[n]=e,[r]=t;return n.localeCompare(r)}function je(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 $(e){let t=(0,me.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 Me=[`blank`,`safe-coder`,`read-only`,`low-cost`],Ne=[{id:`overview`,icon:b},{id:`models`,icon:B},{id:`tools`,icon:P},{id:`skills`,icon:R},{id:`advanced`,icon:D},{id:`impact`,icon:j}];function Pe(e){return fe(Object.entries(e?.models?.roles??{}).map(([e,t])=>({id:e,model:t.model,fallbacks:t.fallbacks??[],description:t.description})))}function Fe(e){return structuredClone(e?.tools?.builtin??{})}function Ie(e){let t=e?.skills;if(!t)return new Set;let n=t.mode===`denylist`?t.deny:t.allow;return new Set(n??[])}function Le(){return{primary:``,fallbacks:[],timeoutMs:``,autoProviderFallback:``}}function Re(e){return{primary:e?.primary??``,fallbacks:[...e?.fallbacks??[]],timeoutMs:e?.timeoutMs?String(e.timeoutMs):``,autoProviderFallback:e?.autoProviderFallback===void 0?``:e.autoProviderFallback?`true`:`false`}}function ze(){return{imageModel:Le(),imageGenerationModel:Le(),allowFallbacks:``,maxCostTier:``}}function Be(e){return{imageModel:Re(e?.models?.imageModel),imageGenerationModel:Re(e?.models?.imageGenerationModel),allowFallbacks:e?.models?.policy?.allowFallbacks===void 0?``:e.models.policy.allowFallbacks?`true`:`false`,maxCostTier:e?.models?.policy?.maxCostTier??``}}function Ve(e){return e===void 0?``:JSON.stringify(e,null,2)}function He(){return{mcp:``,workflows:``,boundaries:``,runtime:``,locks:``}}function Ue(e){return{mcp:Ve(e?.tools?.mcp),workflows:Ve(e?.workflows),boundaries:Ve(e?.boundaries),runtime:Ve(e?.runtime),locks:Ve(e?.locks)}}function We(e){return{id:e?.id??``,name:e?.name??``,description:e?.description??``,modelRows:Pe(e),modelAdvanced:Be(e),toolPolicies:Fe(e),skillMode:e?.skills?.mode??`inherit`,skillPick:Ie(e),extendsIds:[...e?.extends??[]],jsonFields:Ue(e)}}function Ge(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 Ke(e,t){let n=Y(e.modelRows),r=Ge(e.modelAdvanced.imageModel),i=Ge(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 qe(e){return e.trim()?JSON.parse(e):void 0}function Je(e){if(!e.trim())return``;try{return JSON.stringify(JSON.parse(e))}catch{return`!invalid:${e}`}}function Ye(e){let t=Object.fromEntries(Object.entries(e.toolPolicies).toSorted(([e],[t])=>e.localeCompare(t))),n=qe(e.jsonFields.mcp);return Object.keys(t).length>0||n?{builtin:t,...n?{mcp:n}:{}}:null}function Xe(e){return Object.fromEntries(Object.entries(e??{}).toSorted(([e],[t])=>e.localeCompare(t)))}function Ze(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 Qe(e,t){return{id:e.id.trim(),name:e.name.trim(),description:e.description.trim(),models:Ke(e,t),tools:{builtin:Xe(e.toolPolicies),mcp:Je(e.jsonFields.mcp)},skills:Ze(e),extends:[...e.extendsIds].toSorted(),workflows:Je(e.jsonFields.workflows),boundaries:Je(e.jsonFields.boundaries),runtime:Je(e.jsonFields.runtime),locks:Je(e.jsonFields.locks)}}function $e(e){return e?{id:e.id,name:e.name,description:e.description??``,models:e.models??null,tools:{builtin:Xe(e.tools?.builtin),mcp:Je(Ve(e.tools?.mcp))},skills:e.skills??null,extends:[...e.extends??[]].toSorted(),workflows:Je(Ve(e.workflows)),boundaries:Je(Ve(e.boundaries)),runtime:Je(Ve(e.runtime)),locks:Je(Ve(e.locks))}:null}function et(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 tt(e){return e===void 0?`—`:typeof e==`string`?e:JSON.stringify(e)}function nt(){return{modelAdvanced:ze(),extendsIds:[],jsonFields:He()}}function rt(e,t){return{extends:[...e.extendsIds],models:Ke(e,t)??void 0,tools:Ye(e)??void 0,skills:Ze(e)??void 0,workflows:qe(e.jsonFields.workflows),boundaries:qe(e.jsonFields.boundaries),runtime:qe(e.jsonFields.runtime),locks:qe(e.jsonFields.locks)}}function it(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`]),...nt()}: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,...nt()}: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,...nt()}:{id:``,name:``,description:``,modelRows:[],toolPolicies:{},skillMode:`inherit`,skillPick:new Set,...nt()}}function at(){let e=s(l(e=>e.language)),t=e.capabilityPresetsSettings,n=(0,Z.jsx)(M,{asChild:!0,type:`button`,variant:`secondary`,children:(0,Z.jsxs)(a,{to:`/agents`,children:[t.manageAgents,(0,Z.jsx)(V,{className:`size-4`,"aria-hidden":!0})]})}),r=!!c(e=>e.token),{data:_,error:v,isLoading:w,mutate:k}=u(r?`settings-capability-presets`:null,le,{revalidateOnFocus:!1}),{data:A=[],isLoading:L}=u(r?`settings-capability-presets-skills-catalog`:null,S,{revalidateOnFocus:!1}),[z,U]=i(),[ce,K]=(0,X.useState)(``),[fe,q]=(0,X.useState)(`overview`),[J,Y]=(0,X.useState)(()=>it(`blank`,t)),[pe,me]=(0,X.useState)(null),[Q,he]=(0,X.useState)(!1),[ve,ye]=(0,X.useState)(null),[xe,Se]=(0,X.useState)(!1),[Ce,we]=(0,X.useState)(null),[Te,Ee]=(0,X.useState)(null),De=_?.presets??[],Oe=_?.defaultPresetId??`default`,Ae=De.find(e=>e.id===Oe)??null,je=De.filter(e=>e.id!==Oe),$=(0,X.useMemo)(()=>De.find(e=>e.id===ce)??De[0]??null,[De,ce]),Pe=!$||J.id.trim()!==$.id,Fe=!!($&&$.id===Oe),Ie=JSON.stringify(Qe(J,$))!==JSON.stringify($e($)),Le=Qe(J,$),Re=$e($),ze=[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),Be=(0,X.useMemo)(()=>{if(!$||Pe)return null;try{let e=rt(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}}catch{return null}},[J,Pe,$]),{data:Ve,error:He,isLoading:Ue}=u(fe===`impact`&&$&&Be?[`capability-preset-impact-preview`,$.id,JSON.stringify(Be)]:null,()=>oe($.id,Be),{revalidateOnFocus:!1}),Ge=ve??(v instanceof Error?v.message:null),Ke=z.get(`action`)===`new`||!!z.get(`preset`),Je=z.get(`action`)===`new`&&pe===null,Ye=Pe?t.newPreset:$?.name??t.editorTitle,Xe=t=>e.agentsSettings.toolsDisableGroups[t],Ze=t=>t in e.agentsSettings.toolDescriptions?e.agentsSettings.toolDescriptions[t]:``;(0,X.useEffect)(()=>{if(!_||Q)return;if(z.get(`action`)===`new`){K(``),Y(it(`blank`,t)),q(`overview`);return}let e=z.get(`preset`)?.trim(),n=e?_.presets.find(t=>t.id===e):null;if(n){K(n.id),Y(We(n)),q(z.get(`tab`)??`overview`);return}$&&(K($.id),Y(e=>e.id===$.id?e:We($)))},[Q,_,z,$]);function nt(e){me(null),K(e.id),Y(We(e)),U({preset:e.id},{replace:!0}),q(`overview`)}function at(){me(null),K(``),Y(it(`blank`,t)),ye(null),U({action:`new`},{replace:!0}),q(`overview`)}function ct(e){me(e),Y(it(e,t)),ye(null),q(`overview`)}function lt(){if(pe){let e=it(pe,t);if(JSON.stringify(Qe(J,null))!==JSON.stringify(Qe(e,null))&&!window.confirm(t.changeTemplateConfirm))return}me(null),ye(null)}function ut(){!Je&&Ie&&!window.confirm(t.discardConfirm)||(Se(!1),we(null),U({},{replace:!0}),me(null),ye(null),Y(We($)),q(`overview`))}async function dt(){let e=de(J.modelRows,{invalidId:t.invalidModelRoleId,duplicateId:t.duplicateModelRoleId,invalidModel:t.invalidModelRef});if(e){ye(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))){ye(t.invalidModelRef),q(`models`);return}if(e.timeoutMs.trim()&&(!Number.isInteger(Number(e.timeoutMs))||Number(e.timeoutMs)<=0)){ye(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)){ye(t.advancedPositiveIntegerError),q(`tools`);return}for(let e of Object.keys(J.jsonFields))try{qe(J.jsonFields[e])}catch{ye(t.advancedJsonError.replace(`{{field}}`,t.advancedFieldLabels[e])),q(`advanced`);return}he(!0),ye(null);try{let e=rt(J,$);if(Pe){let t=await ue({id:J.id.trim(),name:J.name.trim(),...J.description.trim()?{description:J.description.trim()}:{},...e});await k(t.presets,{revalidate:!1}),K(t.presetId),me(null),U({preset:t.presetId},{replace:!0})}else $&&await k(await ae($.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){ye(e instanceof Error?e.message:t.saveError)}finally{he(!1)}}async function ft(){if($){he(!0),ye(null),we(null);try{await k(await se($.id),{revalidate:!1}),Se(!1),K(``),me(null),Y(it(`blank`,t)),q(`overview`),U({},{replace:!0})}catch(e){we(e instanceof Error?e.message:t.deleteError)}finally{he(!1)}}}return r?(0,Z.jsxs)(ne,{gap:`gap-5`,className:`pb-24`,children:[(0,Z.jsx)(te,{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)(M,{type:`button`,onClick:at,disabled:Q,children:[(0,Z.jsx)(I,{className:`size-4`,"aria-hidden":!0}),t.newPreset]})]})}),Ge?(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:Ge}):null,w?(0,Z.jsx)(re,{sections:2}):(0,Z.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[Ae?(0,Z.jsxs)(G,{children:[(0,Z.jsx)(W,{icon:B,title:t.globalDefaultsTitle,subtitle:t.globalDefaultsHint}),(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>nt(Ae),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:Ae.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:Ae.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})]}),Ae.description?(0,Z.jsx)(`p`,{className:`mt-3 line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:Ae.description}):null,(0,Z.jsx)(`div`,{className:`mt-3 text-xs text-fg-subtle`,children:et(Ae,t)})]})]}):null,(0,Z.jsxs)(G,{children:[(0,Z.jsx)(W,{icon:B,title:t.listTitle,subtitle:t.listHint}),je.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)(M,{type:`button`,variant:`secondary`,onClick:at,disabled:Q,children:[(0,Z.jsx)(I,{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:je.map(e=>(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>nt(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:et(e,t)})]},e.id))})]})]}),(0,Z.jsx)(T,{open:Ke,onOpenChange:e=>{e||ut()},children:(0,Z.jsxs)(m,{children:[(0,Z.jsx)(h,{className:o(`xopc-dialog-overlay fixed inset-0 bg-scrim`,g)}),(0,Z.jsx)(H,{ref:Ee,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`,O),onOpenAutoFocus:e=>e.preventDefault(),children:(0,Z.jsxs)(f,{layer:`modal`,portalContainer:Te,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:[!Je&&Pe&&pe?(0,Z.jsx)(`button`,{type:`button`,className:o(F,`shrink-0 p-1.5 hover:bg-surface-base`),onClick:lt,"aria-label":t.changeTemplate,title:t.changeTemplate,children:(0,Z.jsx)(N,{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:Ye}),(0,Z.jsx)(E,{className:`mt-0.5 truncate text-xs text-fg-muted`,children:Je?t.templatePickerSubtitle:Pe&&pe?`${t.editorHint} · ${t.basedOnTemplate.replace(`{{template}}`,t.starters[pe].title)}`:Pe?t.editorHint:J.id})]})]}),(0,Z.jsx)(p,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:o(F,`shrink-0 p-1.5 hover:bg-surface-base`),"aria-label":t.closeDialog,children:(0,Z.jsx)(ee,{className:`size-4`,"aria-hidden":!0})})})]}),Je?(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:Me.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:()=>ct(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)(M,{type:`button`,variant:`secondary`,onClick:ut,children:t.cancel})})]}):(0,Z.jsxs)(Z.Fragment,{children:[Ge?(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:Ge}):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:Ne.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`,fe===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:[fe===`overview`?(0,Z.jsxs)(G,{children:[(0,Z.jsx)(W,{icon:b,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)(ot,{icon:B,label:t.modelsTitle,value:String(J.modelRows.length)}),(0,Z.jsx)(ot,{icon:P,label:t.toolsTitle,value:String(Object.keys(J.toolPolicies).length)}),(0,Z.jsx)(ot,{icon:R,label:t.skillsTitle,value:t.skillModeLabels[J.skillMode]})]})]}):null,fe===`models`?(0,Z.jsxs)(G,{children:[(0,Z.jsx)(W,{icon:B,title:t.modelsTitle,subtitle:t.modelsHint}),(0,Z.jsx)(ge,{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)(st,{value:J.modelAdvanced,onChange:e=>Y(t=>({...t,modelAdvanced:e})),disabled:Q,cp:t,chat:e.chat})]}):null,fe===`tools`?(0,Z.jsxs)(G,{children:[(0,Z.jsx)(W,{icon:P,title:t.toolsTitle,subtitle:t.toolsHint}),(0,Z.jsx)(ke,{builtinToolIds:_?.builtinToolIds??[],toolPolicies:J.toolPolicies,onChange:e=>Y(t=>({...t,toolPolicies:e})),disabled:Q,getToolDescription:Ze,getGroupTitle:Xe,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,scopeLabel:t.toolScopeLabel,scopeInherit:t.toolScopeInherit,scopeReadonly:t.toolScopeReadonly,scopeWorkspace:t.toolScopeWorkspace,scopeUnrestricted:t.toolScopeUnrestricted,maxCallsLabel:t.toolMaxCallsLabel,timeoutLabel:t.toolTimeoutLabel}})]}):null,fe===`skills`?(0,Z.jsxs)(G,{children:[(0,Z.jsx)(W,{icon:R,title:t.skillsTitle,subtitle:t.skillsHint}),(0,Z.jsx)(be,{mode:J.skillMode,selected:J.skillPick,catalog:A,loading:L,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,fe===`advanced`?(0,Z.jsxs)(G,{children:[(0,Z.jsx)(W,{icon:D,title:t.advancedTitle,subtitle:t.advancedHint}),(0,Z.jsx)(_e,{extendsIds:J.extendsIds,onExtendsChange:e=>Y(t=>({...t,extendsIds:e})),presetOptions:De.filter(e=>e.id!==$?.id&&e.id!==Oe),jsonFields:J.jsonFields,onJsonFieldsChange:e=>Y(t=>({...t,jsonFields:e})),disabled:Q,labels:{inheritanceTitle:t.advancedInheritanceTitle,inheritanceHint:t.advancedInheritanceHint,inheritanceEmpty:t.advancedInheritanceEmpty,inheritanceApplied:t.advancedInheritanceApplied,inheritanceAvailable:t.advancedInheritanceAvailable,inheritanceAdd:t.advancedInheritanceAdd,inheritanceRemove:t.advancedInheritanceRemove,inheritanceMoveUp:t.advancedInheritanceMoveUp,inheritanceMoveDown:t.advancedInheritanceMoveDown,jsonTitle:t.advancedJsonTitle,jsonHint:t.advancedJsonHint,fieldLabels:t.advancedFieldLabels,fieldHints:t.advancedFieldHints}})]}):null,fe===`impact`?(0,Z.jsxs)(G,{children:[(0,Z.jsx)(W,{icon:j,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:ze.length>0?t.changePreviewSections.replace(`{{sections}}`,ze.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}),Ue?(0,Z.jsx)(ie,{rows:2}):He?(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}):Be?Ve?.agents.length?(0,Z.jsx)(`div`,{className:`grid gap-3`,children:Ve.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:tt(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:tt(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}):(0,Z.jsx)(`p`,{className:`rounded-lg bg-surface-panel/60 px-3 py-2 text-sm text-fg-muted shadow-surface`,children:t.effectiveChangePreviewInvalid})]}),$?.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)(M,{type:`button`,variant:`secondary`,disabled:Q,onClick:()=>Y(We($)),children:t.discard}):null,$&&!Fe?(0,Z.jsxs)(M,{type:`button`,variant:`secondary`,disabled:Q,onClick:()=>{we(null),Se(!0)},children:[(0,Z.jsx)(C,{className:`size-4`,"aria-hidden":!0}),t.delete]}):null,(0,Z.jsxs)(M,{type:`button`,disabled:Q||!J.id.trim()||!J.name.trim()||!Ie,onClick:()=>void dt(),children:[(0,Z.jsx)(d,{className:`size-4`,"aria-hidden":!0}),t.savePreset]})]})]})]})]})})]})}),(0,Z.jsx)(T,{open:xe,onOpenChange:e=>{Q||(Se(e),e||we(null))},children:(0,Z.jsxs)(m,{children:[(0,Z.jsx)(h,{className:o(`xopc-dialog-overlay fixed inset-0 bg-scrim`,g)}),(0,Z.jsxs)(H,{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`,O),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)(E,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:$?t.deleteConfirm.replace(`{{name}}`,$.name):t.deleteConfirmFallback})]}),Ce?(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:Ce}):null,(0,Z.jsxs)(`div`,{className:`flex justify-end gap-2 px-4 py-3`,children:[(0,Z.jsx)(M,{type:`button`,variant:`secondary`,disabled:Q,onClick:()=>Se(!1),children:t.cancel}),(0,Z.jsxs)(M,{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 ft(),children:[Q?(0,Z.jsx)(y,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(C,{className:`size-4`,"aria-hidden":!0}),Q?t.deleting:t.delete]})]})]})]})})]}):(0,Z.jsxs)(ne,{gap:`gap-3`,children:[(0,Z.jsx)(te,{title:t.title,actions:n}),(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.needToken})]})}function ot(e){let t=(0,me.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 st(e){let t=(0,me.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`,pe,s),f;t[1]===c?f=t[2]:(f=(c??[]).filter(ut).flatMap(lt),t[1]=c,t[2]=f);let p=f,m;t[3]===p?m=t[4]:(m=new Set(p.map(ct)),t[3]=p,t[4]=m);let h=m,g,_;t[5]!==h||t[6]!==c||t[7]!==r||t[8]!==n?(g=()=>{if(!c)return;let e=n.imageGenerationModel,t=h.has(e.primary)?e.primary:``,i=e.fallbacks.filter(e=>h.has(e));t===e.primary&&i.length===e.fallbacks.length||r({...n,imageGenerationModel:{...e,primary:t,fallbacks:i}})},_=[h,c,r,n],t[5]=h,t[6]=c,t[7]=r,t[8]=n,t[9]=g,t[10]=_):(g=t[9],_=t[10]),(0,X.useEffect)(g,_);let v;t[11]!==r||t[12]!==n?(v=(e,t)=>{r({...n,[e]:t})},t[11]=r,t[12]=n,t[13]=v):v=t[13];let y=v,b;t[14]===a.modelSpecializedTitle?b=t[15]:(b=(0,Z.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:a.modelSpecializedTitle}),t[14]=a.modelSpecializedTitle,t[15]=b);let x;t[16]!==a.modelNotSet||t[17]!==a.modelSpecializedSummary||t[18]!==n.imageGenerationModel.primary||t[19]!==n.imageModel.primary?(x=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]=x):x=t[20];let S;t[21]===x?S=t[22]:(S=(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:x}),t[21]=x,t[22]=S);let C;t[23]!==b||t[24]!==S?(C=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[b,S]}),t[23]=b,t[24]=S,t[25]=C):C=t[25];let T;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,Z.jsx)(k,{className:`size-4 shrink-0 text-fg-subtle transition-transform group-open:rotate-180`,"aria-hidden":!0}),t[26]=T):T=t[26];let E;t[27]===C?E=t[28]:(E=(0,Z.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-3 p-4`,children:[C,T]}),t[27]=C,t[28]=E);let D;t[29]===y?D=t[30]:(D=e=>y(`imageModel`,e),t[29]=y,t[30]=D);let O;t[31]!==o||t[32]!==a||t[33]!==i||t[34]!==D||t[35]!==n.imageModel?(O=(0,Z.jsx)(dt,{title:a.imageUnderstandingTitle,value:n.imageModel,onChange:D,disabled:i,cp:a,chat:o,capabilitiesFilter:`vision`}),t[31]=o,t[32]=a,t[33]=i,t[34]=D,t[35]=n.imageModel,t[36]=O):O=t[36];let A;t[37]===y?A=t[38]:(A=e=>y(`imageGenerationModel`,e),t[37]=y,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)(dt,{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]!==O||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:[O,M]}),t[51]=O,t[52]=M,t[53]=N):N=t[53];let P;t[54]!==E||t[55]!==N?(P=(0,Z.jsxs)(`details`,{className:`group rounded-xl border border-edge bg-surface-base`,children:[E,N]}),t[54]=E,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 ee;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(ee=(0,Z.jsx)(k,{className:`size-4 shrink-0 text-fg-subtle transition-transform group-open:rotate-180`,"aria-hidden":!0}),t[64]=ee):ee=t[64];let R;t[65]===L?R=t[66]:(R=(0,Z.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-3 p-4`,children:[L,ee]}),t[65]=L,t[66]=R);let z;t[67]===a.modelAllowFallbacksLabel?z=t[68]:(z=(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:a.modelAllowFallbacksLabel}),t[67]=a.modelAllowFallbacksLabel,t[68]=z);let B;t[69]!==r||t[70]!==n?(B=e=>r({...n,allowFallbacks:e.target.value}),t[69]=r,t[70]=n,t[71]=B):B=t[71];let V;t[72]===a.policyInherit?V=t[73]:(V=(0,Z.jsx)(U,{value:``,children:a.policyInherit}),t[72]=a.policyInherit,t[73]=V);let H;t[74]===a.policyEnabled?H=t[75]:(H=(0,Z.jsx)(U,{value:`true`,children:a.policyEnabled}),t[74]=a.policyEnabled,t[75]=H);let te;t[76]===a.policyDisabled?te=t[77]:(te=(0,Z.jsx)(U,{value:`false`,children:a.policyDisabled}),t[76]=a.policyDisabled,t[77]=te);let ne;t[78]!==i||t[79]!==B||t[80]!==V||t[81]!==H||t[82]!==te||t[83]!==n.allowFallbacks?(ne=(0,Z.jsxs)(w,{value:n.allowFallbacks,disabled:i,side:`top`,onChange:B,children:[V,H,te]}),t[78]=i,t[79]=B,t[80]=V,t[81]=H,t[82]=te,t[83]=n.allowFallbacks,t[84]=ne):ne=t[84];let re;t[85]!==z||t[86]!==ne?(re=(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[z,ne]}),t[85]=z,t[86]=ne,t[87]=re):re=t[87];let ie;t[88]===a.modelMaxCostTierLabel?ie=t[89]:(ie=(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:a.modelMaxCostTierLabel}),t[88]=a.modelMaxCostTierLabel,t[89]=ie);let W;t[90]!==r||t[91]!==n?(W=e=>r({...n,maxCostTier:e.target.value}),t[90]=r,t[91]=n,t[92]=W):W=t[92];let G;t[93]===a.policyInherit?G=t[94]:(G=(0,Z.jsx)(U,{value:``,children:a.policyInherit}),t[93]=a.policyInherit,t[94]=G);let ae;t[95]===a.costTierLow?ae=t[96]:(ae=(0,Z.jsx)(U,{value:`low`,children:a.costTierLow}),t[95]=a.costTierLow,t[96]=ae);let oe;t[97]===a.costTierMedium?oe=t[98]:(oe=(0,Z.jsx)(U,{value:`medium`,children:a.costTierMedium}),t[97]=a.costTierMedium,t[98]=oe);let se;t[99]===a.costTierHigh?se=t[100]:(se=(0,Z.jsx)(U,{value:`high`,children:a.costTierHigh}),t[99]=a.costTierHigh,t[100]=se);let ce;t[101]!==i||t[102]!==W||t[103]!==G||t[104]!==ae||t[105]!==oe||t[106]!==se||t[107]!==n.maxCostTier?(ce=(0,Z.jsxs)(w,{value:n.maxCostTier,disabled:i,side:`top`,onChange:W,children:[G,ae,oe,se]}),t[101]=i,t[102]=W,t[103]=G,t[104]=ae,t[105]=oe,t[106]=se,t[107]=n.maxCostTier,t[108]=ce):ce=t[108];let le;t[109]!==ie||t[110]!==ce?(le=(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[ie,ce]}),t[109]=ie,t[110]=ce,t[111]=le):le=t[111];let K;t[112]!==re||t[113]!==le?(K=(0,Z.jsxs)(`div`,{className:`grid gap-3 border-t border-edge-subtle p-4 dark:border-edge sm:grid-cols-2`,children:[re,le]}),t[112]=re,t[113]=le,t[114]=K):K=t[114];let ue;t[115]!==R||t[116]!==K?(ue=(0,Z.jsxs)(`details`,{className:`group rounded-xl border border-edge bg-surface-base`,children:[R,K]}),t[115]=R,t[116]=K,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 ct(e){return e.id}function lt(e){return e.models.map(t=>({id:`${e.id}/${t}`,name:t,provider:e.label}))}function ut(e){return e.configured||e.credentialMode!==`api-key`}function dt(e){let t=(0,me.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,m;t[0]!==i||t[1]!==r?(m=(e,t)=>{i({...r,fallbacks:r.fallbacks.map((n,r)=>r===e?t:n)})},t[0]=i,t[1]=r,t[2]=m):m=t[2];let h=m,g;t[3]===n?g=t[4]:(g=(0,Z.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n}),t[3]=n,t[4]=g);let _=r.primary||o.modelNotSet,y;t[5]===_?y=t[6]:(y=(0,Z.jsx)(`span`,{className:`max-w-48 truncate font-mono text-xs text-fg-muted`,children:_}),t[5]=_,t[6]=y);let b;t[7]!==g||t[8]!==y?(b=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-2.5`,children:[g,y]}),t[7]=g,t[8]=y,t[9]=b):b=t[9];let x;t[10]===o.modelToolPrimaryLabel?x=t[11]:(x=(0,Z.jsx)(`div`,{className:`text-xs text-fg-muted`,children:o.modelToolPrimaryLabel}),t[10]=o.modelToolPrimaryLabel,t[11]=x);let S=f??s.modelNoMatches,T;t[12]!==i||t[13]!==r?(T=e=>i({...r,primary:e}),t[12]=i,t[13]=r,t[14]=T):T=t[14];let 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]!==S||t[24]!==T||t[25]!==r.primary?(E=(0,Z.jsx)(v,{value:r.primary,disabled:a,placeholder:s.modelPlaceholder,searchPlaceholder:s.modelSearchPlaceholder,noMatches:S,models:l,modelsLoading:u,modelsError:d,settingsFooterLink:p,capabilitiesFilter:c,className:`w-full max-w-none`,contentAlign:`start`,onChange:T}),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]=S,t[24]=T,t[25]=r.primary,t[26]=E):E=t[26];let D;t[27]!==o.modelClearSelection||t[28]!==a||t[29]!==i||t[30]!==r?(D=r.primary?(0,Z.jsx)(M,{type:`button`,variant:`secondary`,className:`shrink-0 px-2`,disabled:a,"aria-label":o.modelClearSelection,onClick:()=>i({...r,primary:``}),children:(0,Z.jsx)(ee,{className:`size-4`,strokeWidth:1.75})}):null,t[27]=o.modelClearSelection,t[28]=a,t[29]=i,t[30]=r,t[31]=D):D=t[31];let O;t[32]!==E||t[33]!==D?(O=(0,Z.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto] gap-2`,children:[E,D]}),t[32]=E,t[33]=D,t[34]=O):O=t[34];let k;t[35]!==O||t[36]!==x?(k=(0,Z.jsxs)(`div`,{className:`grid gap-1`,children:[x,O]}),t[35]=O,t[36]=x,t[37]=k):k=t[37];let A;t[38]===o.modelToolFallbacksLabel?A=t[39]:(A=(0,Z.jsx)(`div`,{className:`text-xs text-fg-muted`,children:o.modelToolFallbacksLabel}),t[38]=o.modelToolFallbacksLabel,t[39]=A);let j;t[40]!==i||t[41]!==r?(j=()=>i({...r,fallbacks:[...r.fallbacks,``]}),t[40]=i,t[41]=r,t[42]=j):j=t[42];let N;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,Z.jsx)(I,{className:`size-3.5`,strokeWidth:1.75}),t[43]=N):N=t[43];let P;t[44]!==o.modelAddFallback||t[45]!==a||t[46]!==j?(P=(0,Z.jsxs)(M,{type:`button`,variant:`secondary`,className:`h-7 gap-1 px-2 text-xs`,disabled:a,onClick:j,children:[N,o.modelAddFallback]}),t[44]=o.modelAddFallback,t[45]=a,t[46]=j,t[47]=P):P=t[47];let F;t[48]!==A||t[49]!==P?(F=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[A,P]}),t[48]=A,t[49]=P,t[50]=F):F=t[50];let L;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]!==h||t[65]!==r?(L=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)(v,{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=>h(t,e)}),(0,Z.jsx)(M,{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)(C,{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]=h,t[65]=r,t[66]=L):L=t[66];let R;t[67]!==F||t[68]!==L?(R=(0,Z.jsxs)(`div`,{className:`grid gap-1.5`,children:[F,L]}),t[67]=F,t[68]=L,t[69]=R):R=t[69];let z;t[70]!==i||t[71]!==r?(z=e=>i({...r,timeoutMs:e.target.value}),t[70]=i,t[71]=r,t[72]=z):z=t[72];let B;t[73]!==a||t[74]!==z||t[75]!==r.timeoutMs?(B=(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:z}),t[73]=a,t[74]=z,t[75]=r.timeoutMs,t[76]=B):B=t[76];let V;t[77]!==o.toolTimeoutLabel||t[78]!==B?(V=(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-fg-muted`,children:[o.toolTimeoutLabel,B]}),t[77]=o.toolTimeoutLabel,t[78]=B,t[79]=V):V=t[79];let H;t[80]!==i||t[81]!==r?(H=e=>i({...r,autoProviderFallback:e.target.value}),t[80]=i,t[81]=r,t[82]=H):H=t[82];let te;t[83]===o.policyInherit?te=t[84]:(te=(0,Z.jsx)(U,{value:``,children:o.policyInherit}),t[83]=o.policyInherit,t[84]=te);let ne;t[85]===o.policyEnabled?ne=t[86]:(ne=(0,Z.jsx)(U,{value:`true`,children:o.policyEnabled}),t[85]=o.policyEnabled,t[86]=ne);let re;t[87]===o.policyDisabled?re=t[88]:(re=(0,Z.jsx)(U,{value:`false`,children:o.policyDisabled}),t[87]=o.policyDisabled,t[88]=re);let ie;t[89]!==a||t[90]!==H||t[91]!==te||t[92]!==ne||t[93]!==re||t[94]!==r.autoProviderFallback?(ie=(0,Z.jsxs)(w,{value:r.autoProviderFallback,disabled:a,side:`top`,onChange:H,children:[te,ne,re]}),t[89]=a,t[90]=H,t[91]=te,t[92]=ne,t[93]=re,t[94]=r.autoProviderFallback,t[95]=ie):ie=t[95];let W;t[96]!==o.modelAutoProviderFallbackLabel||t[97]!==ie?(W=(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-fg-muted`,children:[o.modelAutoProviderFallbackLabel,ie]}),t[96]=o.modelAutoProviderFallbackLabel,t[97]=ie,t[98]=W):W=t[98];let G;t[99]!==V||t[100]!==W?(G=(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[V,W]}),t[99]=V,t[100]=W,t[101]=G):G=t[101];let ae;t[102]!==k||t[103]!==R||t[104]!==G?(ae=(0,Z.jsxs)(`div`,{className:`grid gap-3 border-t border-edge-subtle p-3 dark:border-edge`,children:[k,R,G]}),t[102]=k,t[103]=R,t[104]=G,t[105]=ae):ae=t[105];let oe;return t[106]!==ae||t[107]!==b?(oe=(0,Z.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/70 shadow-surface`,children:[b,ae]}),t[106]=ae,t[107]=b,t[108]=oe):oe=t[108],oe}export{at 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-B4XqB8I6.js";import{l as c,n as l,o as u,r as d,s as f}from"./locale-store-deR2zRaE.js";import{i as p}from"./vendor-swr-BIWyz7Rc.js";import{Ba as m,Bo as h,Br as g,Co as _,Do as v,Ds as y,Eo as b,Go as x,Is as S,Jl as C,Kl as w,La as T,Lo as E,Nc as D,Oo as O,So as k,To as A,Va as j,Vr as M,Wi as N,Wo as P,Xa as F,Ys as I,ac as L,br as ee,ds as R,dt as te,is as z,ms as ne,tc as re,wo as ie,xl as ae,zr as oe}from"./index-CYT5DOzr.js";import{n as se,r as ce}from"./settings-page-layout-EQIOJa_L.js";import{n as le}from"./settings-loading-skeleton-CCtlhoy7.js";import{t as ue}from"./schema-form-B84DckWe.js";import{t as de}from"./browser-BLJWD7WI.js";import{n as fe,t as pe}from"./channels-status-swr-Cz7SAAkm.js";var B=e(t(),1),V=n();function me(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 he=e(de(),1),H=r();async function ge(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 U(e){return e?.type===`poll`&&e.phase===`done`}function W(e){return e&&`message`in e&&typeof e.message==`string`?e.message:null}function G(e,t){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrPayload?e.qrPayload:t===`weixin`&&e.qrcodeUrl?e.qrcodeUrl:null}function K(e){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrcodeUrl??null}function _e({entry:e,locale:t,messages:n,onChanged:r,compact:i=!1}){let a=(0,B.useMemo)(()=>me(e),[e]),s=(0,B.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,B.useState)({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null});(0,B.useEffect)(()=>{l({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null})},[e.id]);let u=(0,B.useCallback)(async(n,i)=>{l(e=>({...e,busy:!0,error:null}));try{let a=await ge({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,B.useEffect)(()=>{let t=G(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),he.toDataURL(t,{width:220,margin:1}).then(e=>{n||l(t=>({...t,generatedQr:e}))}),()=>{n=!0}},[e.id,c.payload]),(0,B.useEffect)(()=>{let n=c.poll;if(!n)return;let i=!1,a=window.setInterval(()=>{i||ge({channelId:e.id,actionId:n.actionId,locale:t,input:{sessionKey:n.sessionKey}}).then(async e=>{i||(l(t=>({...t,payload:e,poll:U(e)?null:t.poll,error:null})),`configChanged`in e&&e.configChanged===!0&&await r(),U(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=W(c.payload),h=G(c.payload,e.id),g=h?c.generatedQr:K(c.payload),_=a?.[1].result===`qr`&&(c.busy||c.payload?.type===`qr`||c.payload?.type===`poll`),v=c.payload?.type===`form`?c.payload:null,y=c.payload?.type===`diagnostics`?c.payload.checks:null;return(0,H.jsxs)(`div`,{className:i?`space-y-3`:`rounded-lg bg-surface-panel/80 p-4 shadow-surface`,children:[(0,H.jsxs)(`div`,{className:o(`flex flex-wrap items-start gap-3`,i?`justify-end`:`justify-between`),children:[i?null:(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.setupTitle}),(0,H.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.configured?n.setupConfiguredHint:n.setupEmptyHint})]}),(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[a?(0,H.jsxs)(R,{type:`button`,variant:`primary`,disabled:c.busy,onClick:()=>void u(a[0]),children:[c.busy?(0,H.jsx)(D,{className:`size-4 animate-spin`}):(0,H.jsx)(L,{className:`size-4`}),d]}):null,e.actions?.[`doctor.run`]?(0,H.jsxs)(R,{type:`button`,variant:`secondary`,disabled:c.busy,onClick:()=>void u(`doctor.run`),children:[(0,H.jsx)(S,{className:`size-4`}),f]}):null]})]}),p?(0,H.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:p}):null,c.error?(0,H.jsx)(`p`,{className:`mt-3 text-sm text-red-600 dark:text-red-400`,children:c.error}):null,_?(0,H.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,H.jsx)(`div`,{className:`flex size-56 shrink-0 items-center justify-center rounded-lg border border-edge bg-white p-3`,children:g?(0,H.jsx)(`img`,{src:g,alt:`${e.label} setup QR`,className:`size-52 object-contain`}):(0,H.jsx)(`div`,{className:`flex size-52 items-center justify-center rounded-md bg-surface-base`,children:(0,H.jsx)(m,{className:`size-48 rounded-md`})})}),(0,H.jsxs)(`div`,{className:o(`min-w-0 max-w-sm text-sm text-fg-muted`,i&&`w-full sm:w-auto`),children:[g?(0,H.jsx)(`p`,{className:`line-clamp-3`,children:n.waitingConfirmation}):(0,H.jsxs)(`div`,{className:`space-y-2`,"aria-busy":`true`,children:[(0,H.jsx)(m,{className:`h-4 w-48 max-w-full`}),(0,H.jsx)(m,{className:`h-4 w-36 max-w-full`})]}),h?(0,H.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,H.jsx)(ae,{className:`size-3.5`})]}):null]})]}):null,c.payload?.type===`poll`&&c.payload.phase===`done`?(0,H.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,H.jsx)(w,{className:c.payload.ok?`size-4 text-green-600`:`size-4 text-red-600`}),(0,H.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,v?(0,H.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,H.jsx)(ue,{schema:v.schema,values:c.formDraft,onChange:e=>l(t=>({...t,formDraft:e})),disabled:c.busy,labels:s}),(0,H.jsx)(R,{type:`button`,variant:`primary`,disabled:c.busy,onClick:()=>void u(v.submitAction,c.formDraft),children:n.saveSetup})]}):null,y?(0,H.jsx)(`div`,{className:`mt-4 space-y-2`,children:y.map((e,t)=>(0,H.jsxs)(`div`,{className:`rounded-lg bg-surface-base px-3 py-2 shadow-surface`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,H.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.label??e.id??n.diagnosticCheckFallback.replace(`{{index}}`,String(t+1))}),(0,H.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,H.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.message}):null]},e.id??t))}):null]})}var q=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:q,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`,P):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)]`,P,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`)}function Ce(e){let t=(0,V.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,y=n===`drawer`,[S,C]=(0,B.useState)(null),w;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,H.jsx)(b,{className:o(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,x)}),t[0]=w):w=t[0];let T;t[1]!==n||t[2]!==g?(T=Se(n,g),t[1]=n,t[2]=g,t[3]=T):T=t[3];let E;t[4]===c?E=t[5]:(E=c?(0,H.jsx)(O,{className:`sr-only`,children:c}):null,t[4]=c,t[5]=E);let D;t[6]===l?D=t[7]:(D=l?(0,H.jsx)(A,{className:`sr-only`,children:l}):null,t[6]=l,t[7]=D);let j;t[8]!==u||t[9]!==s||t[10]!==m||t[11]!==y||t[12]!==a?(j=y?(0,H.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[a?(0,H.jsx)(`div`,{className:`text-base font-semibold text-fg`,children:a}):null,s?(0,H.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:s}):null]}),(0,H.jsx)(_,{asChild:!0,children:(0,H.jsx)(R,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":u,children:(0,H.jsx)(ne,{className:`size-5`,strokeWidth:1.75})})})]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(_,{asChild:!0,children:(0,H.jsx)(`button`,{type:`button`,className:o(z,`absolute right-3 top-3 z-20 p-1.5 hover:bg-surface-hover`),"aria-label":u,children:(0,H.jsx)(ne,{className:`size-4`})})}),m]}),t[8]=u,t[9]=s,t[10]=m,t[11]=y,t[12]=a,t[13]=j):j=t[13];let M=y?`p-4`:`p-6`,N;t[14]===M?N=t[15]:(N=o(`min-h-0 flex-1 overflow-y-auto`,M),t[14]=M,t[15]=N);let P;t[16]!==d||t[17]!==N?(P=(0,H.jsx)(`div`,{className:N,children:d}),t[16]=d,t[17]=N,t[18]=P):P=t[18];let F;t[19]!==f||t[20]!==S||t[21]!==E||t[22]!==D||t[23]!==j||t[24]!==P?(F=(0,H.jsxs)(h,{layer:`modal`,portalContainer:S,children:[E,D,j,P,f]}),t[19]=f,t[20]=S,t[21]=E,t[22]=D,t[23]=j,t[24]=P,t[25]=F):F=t[25];let I;t[26]!==F||t[27]!==T?(I=(0,H.jsxs)(v,{children:[w,(0,H.jsx)(ie,{ref:C,className:T,onOpenAutoFocus:we,children:F})]}),t[26]=F,t[27]=T,t[28]=I):I=t[28];let L;return t[29]!==i||t[30]!==r||t[31]!==I?(L=(0,H.jsx)(k,{open:r,onOpenChange:i,children:I}),t[29]=i,t[30]=r,t[31]=I,t[32]=L):L=t[32],L}function we(e){return e.preventDefault()}var Te=(0,B.memo)(function(e){let t=(0,V.c)(10),{ch:n,refreshing:r,saveOk:i,onRefresh:a}=e,o;t[0]!==n.saved||t[1]!==i?(o=i?(0,H.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,H.jsx)(N,{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,H.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,V.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,H.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,H.jsx)(R,{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,H.jsx)(R,{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,H.jsx)(R,{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,H.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,H.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,V.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,V.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,B.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=me(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=me(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,B.useState)(!1),i=(0,B.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,H.jsx)(`span`,{className:`flex size-12 shrink-0 items-center justify-center rounded-2xl bg-surface-base text-fg`,children:i?(0,H.jsx)(`img`,{src:i,alt:``,draggable:!1,className:`size-7`,"aria-hidden":!0,onError:()=>r(!0)}):(0,H.jsx)(j,{sourceChannel:e.id,className:`size-7`})})}function nt(e){let t=(0,V.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,H.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,H.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,V.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,H.jsx)(tt,{entry:n}),t[19]=n,t[20]=f);let x;t[21]===n.label?x=t[22]:(x=(0,H.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,H.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,H.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,H.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,H.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,H.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,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`p`,{className:`line-clamp-2 text-sm leading-6 text-fg-muted`,children:n.description??n.id}),e.length>0?(0,H.jsx)(`div`,{className:`mt-3 space-y-0.5 text-sm leading-5 text-fg-muted`,children:e.map($)}):null]}):(0,H.jsxs)(`div`,{className:`rounded-lg bg-surface-base p-3`,children:[(0,H.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:c.cardSetupTitle}),(0,H.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,H.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,H.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,H.jsx)(D,{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,H.jsx)(`div`,{className:`mt-auto pt-4`,children:(0,H.jsxs)(R,{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,H.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,H.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,H.jsx)(`p`,{className:`truncate`,title:e,children:e},e)}function at(e){let t=(0,V.c)(51),{runtime:n,restarting:r,checking:i,showConnectionOptions:a,canManageConnection:s,ch:c,onRestart:l,onCheck:u,onManageConnection:d}=e,f=n===`running`?w:n===`stopped`||n===`needs_setup`?C:D,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,H.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,H.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,H.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:x}),t[14]=x,t[15]=S);let T;t[16]!==S||t[17]!==b?(T=(0,H.jsxs)(`div`,{children:[b,S]}),t[16]=S,t[17]=b,t[18]=T):T=t[18];let E;t[19]!==T||t[20]!==y?(E=(0,H.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[y,T]}),t[19]=T,t[20]=y,t[21]=E):E=t[21];let O=i||r,k;t[22]===i?k=t[23]:(k=i?(0,H.jsx)(D,{className:`size-4 animate-spin`}):null,t[22]=i,t[23]=k);let A=i?c.checkingConnection:c.checkConnection,j;t[24]!==u||t[25]!==O||t[26]!==k||t[27]!==A?(j=(0,H.jsxs)(R,{type:`button`,variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:O,onClick:u,children:[k,A]}),t[24]=u,t[25]=O,t[26]=k,t[27]=A,t[28]=j):j=t[28];let M;t[29]!==c.restartChannel||t[30]!==c.restartingChannel||t[31]!==i||t[32]!==l||t[33]!==r||t[34]!==n?(M=n===`stopped`?(0,H.jsxs)(R,{type:`button`,variant:`primary`,className:`px-2.5 py-1.5 text-xs`,disabled:r||i,onClick:l,children:[r?(0,H.jsx)(D,{className:`size-4 animate-spin`}):(0,H.jsx)(re,{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]=M):M=t[35];let N;t[36]!==s||t[37]!==c.connectionOptions||t[38]!==c.hideConnectionOptions||t[39]!==i||t[40]!==d||t[41]!==r||t[42]!==a?(N=s?(0,H.jsx)(R,{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]=N):N=t[43];let P;t[44]!==j||t[45]!==M||t[46]!==N?(P=(0,H.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[j,M,N]}),t[44]=j,t[45]=M,t[46]=N,t[47]=P):P=t[47];let F;return t[48]!==E||t[49]!==P?(F=(0,H.jsx)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:(0,H.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[E,P]})}),t[48]=E,t[49]=P,t[50]=F):F=t[50],F}function ot(e){let t=(0,V.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,H.jsx)(y,{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,H.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,H.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,H.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,H.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,H.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,H.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,H.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(),m=M(f),h=ke(n,e),_=h.entries,{data:v,mutate:y,isValidating:b}=p(n?pe():null,fe,{revalidateOnFocus:!0}),{data:x,mutate:S}=p(n?`channels-config-map`:null,Le,{revalidateOnFocus:!1}),C=x?.channels??{},w=x?.bindings??[],{data:D}=p(n?`channel-routing-agents`:null,T,{revalidateOnFocus:!1}),O=F(e=>e.setPageHeader),k=F(e=>e.clearPageHeader),A=(0,B.useMemo)(()=>_.find(e=>e.id===m),[m,_]),j=A?ze(A):null,{data:N,mutate:P}=p(n&&j?Pe(j):null,()=>Fe(j)),[L,R]=(0,B.useState)(null),[z,ne]=(0,B.useState)(!1),[re,ie]=(0,B.useState)(null),[de,V]=(0,B.useState)(null),[he,ge]=(0,B.useState)(!1),[U,W]=(0,B.useState)(null),[G,K]=(0,B.useState)(null),q=L??N??{},J=t.channelsSettings,be=(0,B.useMemo)(()=>A?.configSchema??{type:`object`,properties:{}},[A?.configSchema]),Se=(0,B.useMemo)(()=>Ke(be,Ie),[be]),we=(0,B.useMemo)(()=>Ue(A),[A]),De=(0,B.useMemo)(()=>We(Se,we),[we,Se]),Oe=(0,B.useMemo)(()=>Ke(Se,we),[we,Se]),Ae=(0,B.useMemo)(()=>qe(De),[De]),Me=A?G??ve(w,A.id):``,Re=(0,B.useMemo)(()=>(D?.items??[]).map(e=>{let n=ee(e,t.agentsSettings);return{value:e.id,label:n===e.id?n:`${n} · ${e.id}`}}),[D?.items,t.agentsSettings]),Ve=D?.items.find(e=>e.id===D.defaultId),X=Ve?ee(Ve,t.agentsSettings):D?.defaultId??``,Z=(0,B.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,B.useMemo)(()=>new Map((v??[]).map(e=>[e.name,e])),[v]),Je=v!==void 0,Ye=(0,B.useCallback)(e=>xe(e,Ge.get(e.id),Je),[Ge,Je]),Q=(0,B.useCallback)(async()=>{await Promise.all([h.mutate(),y()])},[h,y]);Ne((0,B.useCallback)(e=>{let t=je(e);t&&y(t,!1)},[y]),n);let Xe=(0,B.useMemo)(()=>n?(0,H.jsx)(Te,{ch:J,refreshing:h.isValidating||b,saveOk:!1,onRefresh:()=>void Q()}):null,[h.isValidating,J,n,b,Q]);(0,B.useLayoutEffect)(()=>(O({startExtra:null,main:(0,H.jsx)(`div`,{className:`min-w-0`,children:(0,H.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.settingsSections.channels})}),end:Xe}),()=>k()),[k,Xe,t.settingsSections.channels,O]);let Ze=(0,B.useCallback)(e=>{r(g(e)),R(null),K(null),W(null)},[r]),Qe=(0,B.useCallback)(()=>{r(oe),R(null),K(null),W(null)},[r]),$e=(0,B.useCallback)(async e=>{V(e.id),W(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){W(e instanceof Error?e.message:String(e))}finally{V(null)}},[Q]);(0,B.useEffect)(()=>{K(null),ge(!1)},[A?.id]);let et=(0,B.useCallback)(async()=>{if(!A||!L&&G===null)return!1;let e=ze(A);ne(!0),W(null);try{let t=await u(d(`/api/config`),{method:`PATCH`,body:JSON.stringify({...L?{channels:{[e]:L}}:{},...G===null?{}:{bindings:ye(w,A.id,G)}})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}return L&&await P(L,!1),await S(),await h.mutate(),R(null),K(null),!0}catch(e){return W(e instanceof Error?e.message:String(e)),!1}finally{ne(!1)}},[A,G,w,h,L,S,P]),it=(0,B.useCallback)(async e=>{let t=Y(e),n=ze(e),r=A?.id===e.id?L:null;if(!t.enabled&&!t.ready&&!r){Ze(e.id);return}ie(e.id),W(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 h.mutate(),await S(),await y(),A?.id===e.id&&(await P(),R(null))}catch(e){W(e instanceof Error?e.message:String(e))}finally{ie(null)}},[A?.id,h,L,S,P,y,Ze]),$=A?.ui?.modal,st=$?.placement!==`replace-config`,ct=A?Ye(A):`checking`,lt=A?!Y(A).ready||he:!1;return n?(0,H.jsxs)(ce,{gap:`gap-4`,children:[h.isLoading?(0,H.jsx)(le,{sections:2}):h.error?(0,H.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:String(h.error)}):(0,H.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:_.map(e=>(0,H.jsx)(rt,{entry:e,config:C[ze(e)]?.config,runtime:Ye(e),busy:re===e.id,restarting:de===e.id,ch:J,onOpen:()=>Ze(e.id),onToggle:()=>void it(e),onRestart:()=>void $e(e)},e.id))}),U?(0,H.jsx)(`p`,{className:`mt-4 text-sm text-red-600 dark:text-red-400`,children:U}):null,(0,H.jsx)(Ce,{presentation:`modal`,open:!!A,onOpenChange:e=>{e||Qe()},closeAriaLabel:J.close,srTitle:A?.label??J.selectChannel,srDescription:A?.description,wide:!0,footer:A?(0,H.jsx)(Ee,{ch:J,dirty:!!L||G!==null,saving:z,onCancel:Qe,onDiscard:()=>{R(null),K(null)},onSave:et}):null,children:A?(0,H.jsxs)(`div`,{className:`space-y-4`,children:[(0,H.jsx)(`div`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,children:(0,H.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,H.jsx)(tt,{entry:A}),(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,H.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:A.label}),(0,H.jsx)(`span`,{className:o(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,He(ct)),children:Be(ct,J)})]}),(0,H.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,H.jsx)(`span`,{className:`min-w-0 truncate`,children:!Y(A).ready&&me(A)?.[1].result===`qr`?J.scanLoginHint.replace(`{{channel}}`,A.label):A.description}),A.docsPath?(0,H.jsxs)(`a`,{href:A.docsPath,target:`_blank`,rel:`noreferrer`,className:`inline-flex shrink-0 items-center gap-1 text-accent hover:underline`,children:[J.docs,(0,H.jsx)(ae,{className:`size-3.5`})]}):null]})]})]}),(0,H.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pr-8`,children:[(0,H.jsx)(`span`,{className:`hidden text-xs text-fg-muted sm:inline`,children:Y(A).enabled?J.enabledLabel:J.disabledLabel}),(0,H.jsx)(nt,{checked:Y(A).enabled,disabled:re===A.id,label:J.toggleChannel.replace(`{{channel}}`,A.label),onToggle:()=>void it(A)})]})]})}),(0,H.jsx)(at,{runtime:ct,restarting:de===A.id,checking:b,showConnectionOptions:he,canManageConnection:Y(A).ready&&$?.placement!==`replace-config`,ch:J,onRestart:()=>void $e(A),onCheck:()=>void Q(),onManageConnection:()=>ge(e=>!e)}),(0,H.jsx)(ot,{entry:A,ch:J}),lt&&$?.placement!==`replace-config`?(0,H.jsx)(_e,{entry:A,locale:e,messages:J,compact:!0,onChanged:async()=>{await P(),await Q(),await S()}},A.id):null,$?.entrypoint&&$.placement===`before-config`?(0,H.jsx)(te,{extensionId:A.extensionId,extensionName:A.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:A.id,entry:A,config:q}}):null,$?.entrypoint&&$.placement!==`before-config`?(0,H.jsx)(te,{extensionId:A.extensionId,extensionName:A.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:A.id,entry:A,config:q}}):null,st&&Ae?(0,H.jsxs)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:[(0,H.jsxs)(`div`,{className:`mb-4`,children:[(0,H.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:J.basicConfiguration}),(0,H.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:J.basicConfigurationHint})]}),(0,H.jsx)(ue,{schema:De,values:q,onChange:e=>R(e),disabled:z,labels:Z})]}):null,(0,H.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,H.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,H.jsx)(I,{className:`size-4 text-fg-muted`}),J.messageHandling]}),(0,H.jsxs)(`div`,{className:`bg-surface-base/50 p-4`,children:[(0,H.jsxs)(`div`,{className:`mb-3`,children:[(0,H.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:J.agentRouting}),(0,H.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:J.messageHandlingHint})]}),(0,H.jsx)(E,{value:Me,options:Re,placeholder:J.agentRoutingSelect,emptyLabel:J.agentRoutingDefault.replace(`{{agent}}`,X||J.agentRoutingSelect),ariaLabel:J.agentRouting,disabled:z||!D,onChange:e=>K(e)})]})]}),st&&qe(Oe)?(0,H.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,H.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,H.jsx)(I,{className:`size-4 text-fg-muted`}),J.advancedConfiguration]}),(0,H.jsx)(`div`,{className:`bg-surface-base/50 p-4`,children:(0,H.jsx)(ue,{schema:Oe,values:q,onChange:e=>R(e),disabled:z,labels:Z})})]}):null,U?(0,H.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:U}):null]}):null})]}):(0,H.jsxs)(ce,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,H.jsx)(se,{title:t.settingsSections.channels}),(0,H.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-B4XqB8I6.js";import{l as c,n as l,o as u,r as d,s as f}from"./locale-store-deR2zRaE.js";import{i as p}from"./vendor-swr-BIWyz7Rc.js";import{Ba as m,Bo as h,Br as g,Co as _,Do as v,Ds as y,Eo as b,Go as x,Is as S,Jl as C,Kl as w,La as T,Lo as E,Nc as D,Oo as O,So as k,To as A,Va as j,Vr as M,Wi as N,Wo as P,Xa as F,Ys as I,ac as L,br as ee,ds as R,dt as te,is as z,ms as ne,tc as re,wo as ie,xl as ae,zr as oe}from"./index-B-_CEvIX.js";import{n as se,r as ce}from"./settings-page-layout-t_Ox1slk.js";import{n as le}from"./settings-loading-skeleton-Bv03cWib.js";import{t as ue}from"./schema-form-DdE4gtw_.js";import{t as de}from"./browser-BLJWD7WI.js";import{n as fe,t as pe}from"./channels-status-swr-Cz7SAAkm.js";var B=e(t(),1),V=n();function me(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 he=e(de(),1),H=r();async function ge(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 U(e){return e?.type===`poll`&&e.phase===`done`}function W(e){return e&&`message`in e&&typeof e.message==`string`?e.message:null}function G(e,t){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrPayload?e.qrPayload:t===`weixin`&&e.qrcodeUrl?e.qrcodeUrl:null}function K(e){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrcodeUrl??null}function _e({entry:e,locale:t,messages:n,onChanged:r,compact:i=!1}){let a=(0,B.useMemo)(()=>me(e),[e]),s=(0,B.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,B.useState)({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null});(0,B.useEffect)(()=>{l({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null})},[e.id]);let u=(0,B.useCallback)(async(n,i)=>{l(e=>({...e,busy:!0,error:null}));try{let a=await ge({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,B.useEffect)(()=>{let t=G(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),he.toDataURL(t,{width:220,margin:1}).then(e=>{n||l(t=>({...t,generatedQr:e}))}),()=>{n=!0}},[e.id,c.payload]),(0,B.useEffect)(()=>{let n=c.poll;if(!n)return;let i=!1,a=window.setInterval(()=>{i||ge({channelId:e.id,actionId:n.actionId,locale:t,input:{sessionKey:n.sessionKey}}).then(async e=>{i||(l(t=>({...t,payload:e,poll:U(e)?null:t.poll,error:null})),`configChanged`in e&&e.configChanged===!0&&await r(),U(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=W(c.payload),h=G(c.payload,e.id),g=h?c.generatedQr:K(c.payload),_=a?.[1].result===`qr`&&(c.busy||c.payload?.type===`qr`||c.payload?.type===`poll`),v=c.payload?.type===`form`?c.payload:null,y=c.payload?.type===`diagnostics`?c.payload.checks:null;return(0,H.jsxs)(`div`,{className:i?`space-y-3`:`rounded-lg bg-surface-panel/80 p-4 shadow-surface`,children:[(0,H.jsxs)(`div`,{className:o(`flex flex-wrap items-start gap-3`,i?`justify-end`:`justify-between`),children:[i?null:(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.setupTitle}),(0,H.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.configured?n.setupConfiguredHint:n.setupEmptyHint})]}),(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[a?(0,H.jsxs)(R,{type:`button`,variant:`primary`,disabled:c.busy,onClick:()=>void u(a[0]),children:[c.busy?(0,H.jsx)(D,{className:`size-4 animate-spin`}):(0,H.jsx)(L,{className:`size-4`}),d]}):null,e.actions?.[`doctor.run`]?(0,H.jsxs)(R,{type:`button`,variant:`secondary`,disabled:c.busy,onClick:()=>void u(`doctor.run`),children:[(0,H.jsx)(S,{className:`size-4`}),f]}):null]})]}),p?(0,H.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:p}):null,c.error?(0,H.jsx)(`p`,{className:`mt-3 text-sm text-red-600 dark:text-red-400`,children:c.error}):null,_?(0,H.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,H.jsx)(`div`,{className:`flex size-56 shrink-0 items-center justify-center rounded-lg border border-edge bg-white p-3`,children:g?(0,H.jsx)(`img`,{src:g,alt:`${e.label} setup QR`,className:`size-52 object-contain`}):(0,H.jsx)(`div`,{className:`flex size-52 items-center justify-center rounded-md bg-surface-base`,children:(0,H.jsx)(m,{className:`size-48 rounded-md`})})}),(0,H.jsxs)(`div`,{className:o(`min-w-0 max-w-sm text-sm text-fg-muted`,i&&`w-full sm:w-auto`),children:[g?(0,H.jsx)(`p`,{className:`line-clamp-3`,children:n.waitingConfirmation}):(0,H.jsxs)(`div`,{className:`space-y-2`,"aria-busy":`true`,children:[(0,H.jsx)(m,{className:`h-4 w-48 max-w-full`}),(0,H.jsx)(m,{className:`h-4 w-36 max-w-full`})]}),h?(0,H.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,H.jsx)(ae,{className:`size-3.5`})]}):null]})]}):null,c.payload?.type===`poll`&&c.payload.phase===`done`?(0,H.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,H.jsx)(w,{className:c.payload.ok?`size-4 text-green-600`:`size-4 text-red-600`}),(0,H.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,v?(0,H.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,H.jsx)(ue,{schema:v.schema,values:c.formDraft,onChange:e=>l(t=>({...t,formDraft:e})),disabled:c.busy,labels:s}),(0,H.jsx)(R,{type:`button`,variant:`primary`,disabled:c.busy,onClick:()=>void u(v.submitAction,c.formDraft),children:n.saveSetup})]}):null,y?(0,H.jsx)(`div`,{className:`mt-4 space-y-2`,children:y.map((e,t)=>(0,H.jsxs)(`div`,{className:`rounded-lg bg-surface-base px-3 py-2 shadow-surface`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,H.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.label??e.id??n.diagnosticCheckFallback.replace(`{{index}}`,String(t+1))}),(0,H.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,H.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.message}):null]},e.id??t))}):null]})}var q=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:q,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`,P):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)]`,P,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`)}function Ce(e){let t=(0,V.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,y=n===`drawer`,[S,C]=(0,B.useState)(null),w;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,H.jsx)(b,{className:o(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,x)}),t[0]=w):w=t[0];let T;t[1]!==n||t[2]!==g?(T=Se(n,g),t[1]=n,t[2]=g,t[3]=T):T=t[3];let E;t[4]===c?E=t[5]:(E=c?(0,H.jsx)(O,{className:`sr-only`,children:c}):null,t[4]=c,t[5]=E);let D;t[6]===l?D=t[7]:(D=l?(0,H.jsx)(A,{className:`sr-only`,children:l}):null,t[6]=l,t[7]=D);let j;t[8]!==u||t[9]!==s||t[10]!==m||t[11]!==y||t[12]!==a?(j=y?(0,H.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[a?(0,H.jsx)(`div`,{className:`text-base font-semibold text-fg`,children:a}):null,s?(0,H.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:s}):null]}),(0,H.jsx)(_,{asChild:!0,children:(0,H.jsx)(R,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":u,children:(0,H.jsx)(ne,{className:`size-5`,strokeWidth:1.75})})})]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(_,{asChild:!0,children:(0,H.jsx)(`button`,{type:`button`,className:o(z,`absolute right-3 top-3 z-20 p-1.5 hover:bg-surface-hover`),"aria-label":u,children:(0,H.jsx)(ne,{className:`size-4`})})}),m]}),t[8]=u,t[9]=s,t[10]=m,t[11]=y,t[12]=a,t[13]=j):j=t[13];let M=y?`p-4`:`p-6`,N;t[14]===M?N=t[15]:(N=o(`min-h-0 flex-1 overflow-y-auto`,M),t[14]=M,t[15]=N);let P;t[16]!==d||t[17]!==N?(P=(0,H.jsx)(`div`,{className:N,children:d}),t[16]=d,t[17]=N,t[18]=P):P=t[18];let F;t[19]!==f||t[20]!==S||t[21]!==E||t[22]!==D||t[23]!==j||t[24]!==P?(F=(0,H.jsxs)(h,{layer:`modal`,portalContainer:S,children:[E,D,j,P,f]}),t[19]=f,t[20]=S,t[21]=E,t[22]=D,t[23]=j,t[24]=P,t[25]=F):F=t[25];let I;t[26]!==F||t[27]!==T?(I=(0,H.jsxs)(v,{children:[w,(0,H.jsx)(ie,{ref:C,className:T,onOpenAutoFocus:we,children:F})]}),t[26]=F,t[27]=T,t[28]=I):I=t[28];let L;return t[29]!==i||t[30]!==r||t[31]!==I?(L=(0,H.jsx)(k,{open:r,onOpenChange:i,children:I}),t[29]=i,t[30]=r,t[31]=I,t[32]=L):L=t[32],L}function we(e){return e.preventDefault()}var Te=(0,B.memo)(function(e){let t=(0,V.c)(10),{ch:n,refreshing:r,saveOk:i,onRefresh:a}=e,o;t[0]!==n.saved||t[1]!==i?(o=i?(0,H.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,H.jsx)(N,{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,H.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,V.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,H.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,H.jsx)(R,{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,H.jsx)(R,{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,H.jsx)(R,{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,H.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,H.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,V.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,V.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,B.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=me(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=me(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,B.useState)(!1),i=(0,B.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,H.jsx)(`span`,{className:`flex size-12 shrink-0 items-center justify-center rounded-2xl bg-surface-base text-fg`,children:i?(0,H.jsx)(`img`,{src:i,alt:``,draggable:!1,className:`size-7`,"aria-hidden":!0,onError:()=>r(!0)}):(0,H.jsx)(j,{sourceChannel:e.id,className:`size-7`})})}function nt(e){let t=(0,V.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,H.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,H.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,V.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,H.jsx)(tt,{entry:n}),t[19]=n,t[20]=f);let x;t[21]===n.label?x=t[22]:(x=(0,H.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,H.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,H.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,H.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,H.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,H.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,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`p`,{className:`line-clamp-2 text-sm leading-6 text-fg-muted`,children:n.description??n.id}),e.length>0?(0,H.jsx)(`div`,{className:`mt-3 space-y-0.5 text-sm leading-5 text-fg-muted`,children:e.map($)}):null]}):(0,H.jsxs)(`div`,{className:`rounded-lg bg-surface-base p-3`,children:[(0,H.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:c.cardSetupTitle}),(0,H.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,H.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,H.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,H.jsx)(D,{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,H.jsx)(`div`,{className:`mt-auto pt-4`,children:(0,H.jsxs)(R,{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,H.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,H.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,H.jsx)(`p`,{className:`truncate`,title:e,children:e},e)}function at(e){let t=(0,V.c)(51),{runtime:n,restarting:r,checking:i,showConnectionOptions:a,canManageConnection:s,ch:c,onRestart:l,onCheck:u,onManageConnection:d}=e,f=n===`running`?w:n===`stopped`||n===`needs_setup`?C:D,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,H.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,H.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,H.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:x}),t[14]=x,t[15]=S);let T;t[16]!==S||t[17]!==b?(T=(0,H.jsxs)(`div`,{children:[b,S]}),t[16]=S,t[17]=b,t[18]=T):T=t[18];let E;t[19]!==T||t[20]!==y?(E=(0,H.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[y,T]}),t[19]=T,t[20]=y,t[21]=E):E=t[21];let O=i||r,k;t[22]===i?k=t[23]:(k=i?(0,H.jsx)(D,{className:`size-4 animate-spin`}):null,t[22]=i,t[23]=k);let A=i?c.checkingConnection:c.checkConnection,j;t[24]!==u||t[25]!==O||t[26]!==k||t[27]!==A?(j=(0,H.jsxs)(R,{type:`button`,variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:O,onClick:u,children:[k,A]}),t[24]=u,t[25]=O,t[26]=k,t[27]=A,t[28]=j):j=t[28];let M;t[29]!==c.restartChannel||t[30]!==c.restartingChannel||t[31]!==i||t[32]!==l||t[33]!==r||t[34]!==n?(M=n===`stopped`?(0,H.jsxs)(R,{type:`button`,variant:`primary`,className:`px-2.5 py-1.5 text-xs`,disabled:r||i,onClick:l,children:[r?(0,H.jsx)(D,{className:`size-4 animate-spin`}):(0,H.jsx)(re,{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]=M):M=t[35];let N;t[36]!==s||t[37]!==c.connectionOptions||t[38]!==c.hideConnectionOptions||t[39]!==i||t[40]!==d||t[41]!==r||t[42]!==a?(N=s?(0,H.jsx)(R,{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]=N):N=t[43];let P;t[44]!==j||t[45]!==M||t[46]!==N?(P=(0,H.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[j,M,N]}),t[44]=j,t[45]=M,t[46]=N,t[47]=P):P=t[47];let F;return t[48]!==E||t[49]!==P?(F=(0,H.jsx)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:(0,H.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[E,P]})}),t[48]=E,t[49]=P,t[50]=F):F=t[50],F}function ot(e){let t=(0,V.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,H.jsx)(y,{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,H.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,H.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,H.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,H.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,H.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,H.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,H.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(),m=M(f),h=ke(n,e),_=h.entries,{data:v,mutate:y,isValidating:b}=p(n?pe():null,fe,{revalidateOnFocus:!0}),{data:x,mutate:S}=p(n?`channels-config-map`:null,Le,{revalidateOnFocus:!1}),C=x?.channels??{},w=x?.bindings??[],{data:D}=p(n?`channel-routing-agents`:null,T,{revalidateOnFocus:!1}),O=F(e=>e.setPageHeader),k=F(e=>e.clearPageHeader),A=(0,B.useMemo)(()=>_.find(e=>e.id===m),[m,_]),j=A?ze(A):null,{data:N,mutate:P}=p(n&&j?Pe(j):null,()=>Fe(j)),[L,R]=(0,B.useState)(null),[z,ne]=(0,B.useState)(!1),[re,ie]=(0,B.useState)(null),[de,V]=(0,B.useState)(null),[he,ge]=(0,B.useState)(!1),[U,W]=(0,B.useState)(null),[G,K]=(0,B.useState)(null),q=L??N??{},J=t.channelsSettings,be=(0,B.useMemo)(()=>A?.configSchema??{type:`object`,properties:{}},[A?.configSchema]),Se=(0,B.useMemo)(()=>Ke(be,Ie),[be]),we=(0,B.useMemo)(()=>Ue(A),[A]),De=(0,B.useMemo)(()=>We(Se,we),[we,Se]),Oe=(0,B.useMemo)(()=>Ke(Se,we),[we,Se]),Ae=(0,B.useMemo)(()=>qe(De),[De]),Me=A?G??ve(w,A.id):``,Re=(0,B.useMemo)(()=>(D?.items??[]).map(e=>{let n=ee(e,t.agentsSettings);return{value:e.id,label:n===e.id?n:`${n} · ${e.id}`}}),[D?.items,t.agentsSettings]),Ve=D?.items.find(e=>e.id===D.defaultId),X=Ve?ee(Ve,t.agentsSettings):D?.defaultId??``,Z=(0,B.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,B.useMemo)(()=>new Map((v??[]).map(e=>[e.name,e])),[v]),Je=v!==void 0,Ye=(0,B.useCallback)(e=>xe(e,Ge.get(e.id),Je),[Ge,Je]),Q=(0,B.useCallback)(async()=>{await Promise.all([h.mutate(),y()])},[h,y]);Ne((0,B.useCallback)(e=>{let t=je(e);t&&y(t,!1)},[y]),n);let Xe=(0,B.useMemo)(()=>n?(0,H.jsx)(Te,{ch:J,refreshing:h.isValidating||b,saveOk:!1,onRefresh:()=>void Q()}):null,[h.isValidating,J,n,b,Q]);(0,B.useLayoutEffect)(()=>(O({startExtra:null,main:(0,H.jsx)(`div`,{className:`min-w-0`,children:(0,H.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.settingsSections.channels})}),end:Xe}),()=>k()),[k,Xe,t.settingsSections.channels,O]);let Ze=(0,B.useCallback)(e=>{r(g(e)),R(null),K(null),W(null)},[r]),Qe=(0,B.useCallback)(()=>{r(oe),R(null),K(null),W(null)},[r]),$e=(0,B.useCallback)(async e=>{V(e.id),W(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){W(e instanceof Error?e.message:String(e))}finally{V(null)}},[Q]);(0,B.useEffect)(()=>{K(null),ge(!1)},[A?.id]);let et=(0,B.useCallback)(async()=>{if(!A||!L&&G===null)return!1;let e=ze(A);ne(!0),W(null);try{let t=await u(d(`/api/config`),{method:`PATCH`,body:JSON.stringify({...L?{channels:{[e]:L}}:{},...G===null?{}:{bindings:ye(w,A.id,G)}})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}return L&&await P(L,!1),await S(),await h.mutate(),R(null),K(null),!0}catch(e){return W(e instanceof Error?e.message:String(e)),!1}finally{ne(!1)}},[A,G,w,h,L,S,P]),it=(0,B.useCallback)(async e=>{let t=Y(e),n=ze(e),r=A?.id===e.id?L:null;if(!t.enabled&&!t.ready&&!r){Ze(e.id);return}ie(e.id),W(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 h.mutate(),await S(),await y(),A?.id===e.id&&(await P(),R(null))}catch(e){W(e instanceof Error?e.message:String(e))}finally{ie(null)}},[A?.id,h,L,S,P,y,Ze]),$=A?.ui?.modal,st=$?.placement!==`replace-config`,ct=A?Ye(A):`checking`,lt=A?!Y(A).ready||he:!1;return n?(0,H.jsxs)(ce,{gap:`gap-4`,children:[h.isLoading?(0,H.jsx)(le,{sections:2}):h.error?(0,H.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:String(h.error)}):(0,H.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:_.map(e=>(0,H.jsx)(rt,{entry:e,config:C[ze(e)]?.config,runtime:Ye(e),busy:re===e.id,restarting:de===e.id,ch:J,onOpen:()=>Ze(e.id),onToggle:()=>void it(e),onRestart:()=>void $e(e)},e.id))}),U?(0,H.jsx)(`p`,{className:`mt-4 text-sm text-red-600 dark:text-red-400`,children:U}):null,(0,H.jsx)(Ce,{presentation:`modal`,open:!!A,onOpenChange:e=>{e||Qe()},closeAriaLabel:J.close,srTitle:A?.label??J.selectChannel,srDescription:A?.description,wide:!0,footer:A?(0,H.jsx)(Ee,{ch:J,dirty:!!L||G!==null,saving:z,onCancel:Qe,onDiscard:()=>{R(null),K(null)},onSave:et}):null,children:A?(0,H.jsxs)(`div`,{className:`space-y-4`,children:[(0,H.jsx)(`div`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,children:(0,H.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,H.jsx)(tt,{entry:A}),(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,H.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:A.label}),(0,H.jsx)(`span`,{className:o(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,He(ct)),children:Be(ct,J)})]}),(0,H.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,H.jsx)(`span`,{className:`min-w-0 truncate`,children:!Y(A).ready&&me(A)?.[1].result===`qr`?J.scanLoginHint.replace(`{{channel}}`,A.label):A.description}),A.docsPath?(0,H.jsxs)(`a`,{href:A.docsPath,target:`_blank`,rel:`noreferrer`,className:`inline-flex shrink-0 items-center gap-1 text-accent hover:underline`,children:[J.docs,(0,H.jsx)(ae,{className:`size-3.5`})]}):null]})]})]}),(0,H.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pr-8`,children:[(0,H.jsx)(`span`,{className:`hidden text-xs text-fg-muted sm:inline`,children:Y(A).enabled?J.enabledLabel:J.disabledLabel}),(0,H.jsx)(nt,{checked:Y(A).enabled,disabled:re===A.id,label:J.toggleChannel.replace(`{{channel}}`,A.label),onToggle:()=>void it(A)})]})]})}),(0,H.jsx)(at,{runtime:ct,restarting:de===A.id,checking:b,showConnectionOptions:he,canManageConnection:Y(A).ready&&$?.placement!==`replace-config`,ch:J,onRestart:()=>void $e(A),onCheck:()=>void Q(),onManageConnection:()=>ge(e=>!e)}),(0,H.jsx)(ot,{entry:A,ch:J}),lt&&$?.placement!==`replace-config`?(0,H.jsx)(_e,{entry:A,locale:e,messages:J,compact:!0,onChanged:async()=>{await P(),await Q(),await S()}},A.id):null,$?.entrypoint&&$.placement===`before-config`?(0,H.jsx)(te,{extensionId:A.extensionId,extensionName:A.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:A.id,entry:A,config:q}}):null,$?.entrypoint&&$.placement!==`before-config`?(0,H.jsx)(te,{extensionId:A.extensionId,extensionName:A.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:A.id,entry:A,config:q}}):null,st&&Ae?(0,H.jsxs)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:[(0,H.jsxs)(`div`,{className:`mb-4`,children:[(0,H.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:J.basicConfiguration}),(0,H.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:J.basicConfigurationHint})]}),(0,H.jsx)(ue,{schema:De,values:q,onChange:e=>R(e),disabled:z,labels:Z})]}):null,(0,H.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,H.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,H.jsx)(I,{className:`size-4 text-fg-muted`}),J.messageHandling]}),(0,H.jsxs)(`div`,{className:`bg-surface-base/50 p-4`,children:[(0,H.jsxs)(`div`,{className:`mb-3`,children:[(0,H.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:J.agentRouting}),(0,H.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:J.messageHandlingHint})]}),(0,H.jsx)(E,{value:Me,options:Re,placeholder:J.agentRoutingSelect,emptyLabel:J.agentRoutingDefault.replace(`{{agent}}`,X||J.agentRoutingSelect),ariaLabel:J.agentRouting,disabled:z||!D,onChange:e=>K(e)})]})]}),st&&qe(Oe)?(0,H.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,H.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,H.jsx)(I,{className:`size-4 text-fg-muted`}),J.advancedConfiguration]}),(0,H.jsx)(`div`,{className:`bg-surface-base/50 p-4`,children:(0,H.jsx)(ue,{schema:Oe,values:q,onChange:e=>R(e),disabled:z,labels:Z})})]}):null,U?(0,H.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:U}):null]}):null})]}):(0,H.jsxs)(ce,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,H.jsx)(se,{title:t.settingsSections.channels}),(0,H.jsx)(`p`,{className:`text-sm text-fg-muted`,children:J.tokenRequired})]})}export{st as ChannelsSettingsPanel};
|
package/dist/gateway/static/root/assets/{connectors-api-DS9ED-EL.js → connectors-api-BMMqC0_9.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e,s as t}from"./locale-store-deR2zRaE.js";import{Ra as n}from"./index-
|
|
1
|
+
import{r as e,s as t}from"./locale-store-deR2zRaE.js";import{Ra as n}from"./index-B-_CEvIX.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};
|