@xopcai/xopc 0.0.177 → 0.0.178

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.
Files changed (112) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/telegram/xopc.extension.json +1 -1
  3. package/dist/gateway/static/root/assets/{activity-store-Wu2ikfbM.js → activity-store-BzGX__8I.js} +1 -1
  4. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-B0_biISn.js → agent-avatar-dicebear-BzxntcaZ.js} +1 -1
  5. package/dist/gateway/static/root/assets/{agents-TpIpJk59.js → agents-DC9F12Kw.js} +1 -1
  6. package/dist/gateway/static/root/assets/{api-DljBt-N5.js → api-hi6f2Xtp.js} +1 -1
  7. package/dist/gateway/static/root/assets/{app-management-settings-panel-CKoZRi7Y.js → app-management-settings-panel-fTY1F7ac.js} +1 -1
  8. package/dist/gateway/static/root/assets/{appearance-settings-DOdXhNDo.js → appearance-settings-BZ-IxQfB.js} +1 -1
  9. package/dist/gateway/static/root/assets/{apps-page-Cxbn5hy8.js → apps-page-5bKr05Fa.js} +1 -1
  10. package/dist/gateway/static/root/assets/{archive-plugin-D18gyP76.js → archive-plugin-ZSLLG8wB.js} +1 -1
  11. package/dist/gateway/static/root/assets/{attachment-load-CZh9fc8u.js → attachment-load-D4YktqIF.js} +1 -1
  12. package/dist/gateway/static/root/assets/{automation-suggestion-card-DKrVoiiK.js → automation-suggestion-card-B7mxFRtf.js} +1 -1
  13. package/dist/gateway/static/root/assets/{automations-page-DYv16QMU.js → automations-page-Dg6dmt5g.js} +1 -1
  14. package/dist/gateway/static/root/assets/{binary-plugins-DdSyGL6M.js → binary-plugins-BIkPxfxj.js} +1 -1
  15. package/dist/gateway/static/root/assets/{block-editor-BOpNApiX.js → block-editor-Q3v_YQom.js} +1 -1
  16. package/dist/gateway/static/root/assets/{browser-settings-page-DlcqaGu1.js → browser-settings-page-BHoo6Rpq.js} +1 -1
  17. package/dist/gateway/static/root/assets/{browser-workflow-inputs-C0SnSj_R.js → browser-workflow-inputs-M5lTEW1I.js} +1 -1
  18. package/dist/gateway/static/root/assets/{browser-workflows-page-CzlzH7HA.js → browser-workflows-page-B3T1KYk4.js} +1 -1
  19. package/dist/gateway/static/root/assets/{capabilities-settings-panel-QPX4wsGZ.js → capabilities-settings-panel-BlsqN8Fu.js} +1 -1
  20. package/dist/gateway/static/root/assets/{capability-presets-api-RM6S7ES5.js → capability-presets-api-DE09c0VB.js} +1 -1
  21. package/dist/gateway/static/root/assets/{capability-presets-settings-panel-DmCeusO8.js → capability-presets-settings-panel-DJeT8_B4.js} +1 -1
  22. package/dist/gateway/static/root/assets/{channel-recipient-api-B4sha-30.js → channel-recipient-api-CFR5FBfS.js} +1 -1
  23. package/dist/gateway/static/root/assets/{channels-settings-HcKoP1wm.js → channels-settings-C4VVjYEm.js} +1 -1
  24. package/dist/gateway/static/root/assets/channels-status-swr-vdf8kB16.js +1 -0
  25. package/dist/gateway/static/root/assets/{connector-logo-BPsKIyoM.js → connector-logo-B1mD-3pM.js} +1 -1
  26. package/dist/gateway/static/root/assets/{connectors-page-DwbThFvd.js → connectors-page-DNcrDThX.js} +1 -1
  27. package/dist/gateway/static/root/assets/{desktop-pet-DjL1GWON.js → desktop-pet-B1urphOZ.js} +1 -1
  28. package/dist/gateway/static/root/assets/{desktop-pet-settings-u_abAXh7.js → desktop-pet-settings-DTL6J3EP.js} +1 -1
  29. package/dist/gateway/static/root/assets/{directory-picker-path-field-BoZGualI.js → directory-picker-path-field-BYQJ2XUS.js} +1 -1
  30. package/dist/gateway/static/root/assets/{dreaming-settings-s3gn3f9h.js → dreaming-settings-BXcb8fwx.js} +1 -1
  31. package/dist/gateway/static/root/assets/{extension-debug-page-DIbMngCF.js → extension-debug-page-O1Xu1r4Q.js} +1 -1
  32. package/dist/gateway/static/root/assets/{extension-page-D94f2bWQ.js → extension-page-C2Jraq8l.js} +1 -1
  33. package/dist/gateway/static/root/assets/{extension-settings-page-B7TI13ex.js → extension-settings-page-DcXQDTpG.js} +1 -1
  34. package/dist/gateway/static/root/assets/{gateway-config-api-Do77rV8R.js → gateway-config-api-DmPIZrvg.js} +1 -1
  35. package/dist/gateway/static/root/assets/{gateway-settings-Dt1PNJmb.js → gateway-settings-DmObBx9b.js} +1 -1
  36. package/dist/gateway/static/root/assets/{gateway-startup-retry-WaXTw3fi.js → gateway-startup-retry-BZEkOdPm.js} +1 -1
  37. package/dist/gateway/static/root/assets/{goal-create-dialog-DEiOOLGU.js → goal-create-dialog-BRhmmBe9.js} +1 -1
  38. package/dist/gateway/static/root/assets/{goal-detail-page-C1Qj4o1K.js → goal-detail-page-C1k7_s_O.js} +1 -1
  39. package/dist/gateway/static/root/assets/{goals-config-api-BL0fAEns.js → goals-config-api-Fwu1wjEP.js} +1 -1
  40. package/dist/gateway/static/root/assets/{goals-page-qJDcEDzc.js → goals-page-hOu9uA3q.js} +1 -1
  41. package/dist/gateway/static/root/assets/{goals-settings-DV3ZlrdI.js → goals-settings-DY-JjvHz.js} +1 -1
  42. package/dist/gateway/static/root/assets/{heartbeat-settings-C3kzg6ai.js → heartbeat-settings-BtKu2NWT.js} +1 -1
  43. package/dist/gateway/static/root/assets/{image-generation-api-BgISY8i-.js → image-generation-api-05Gg8wsU.js} +1 -1
  44. package/dist/gateway/static/root/assets/{index-C1h0zkNo.js → index-C0CGebQ1.js} +7 -7
  45. package/dist/gateway/static/root/assets/index-eqq25gvV.css +1 -0
  46. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-0KSmaPu0.js → keyboard-shortcuts-settings-CfmDR9Sc.js} +1 -1
  47. package/dist/gateway/static/root/assets/{local-app-workbench-page-DcD4mVId.js → local-app-workbench-page-EjsNT7nJ.js} +1 -1
  48. package/dist/gateway/static/root/assets/{local-apps-page-BMrU8u7w.js → local-apps-page-Df8BW1A_.js} +1 -1
  49. package/dist/gateway/static/root/assets/{locale-store-DVGhFXRz.js → locale-store-CTwSy7yW.js} +1 -1
  50. package/dist/gateway/static/root/assets/{logs-page-CW5m9Cov.js → logs-page-Dswjlraa.js} +1 -1
  51. package/dist/gateway/static/root/assets/{markdown-split-BVqbtN9o.js → markdown-split-B3FvKbaP.js} +1 -1
  52. package/dist/gateway/static/root/assets/{media-plugins-Dr_wtkNJ.js → media-plugins-DsjrvvB6.js} +1 -1
  53. package/dist/gateway/static/root/assets/messages-DP6tPKk-.js +3 -0
  54. package/dist/gateway/static/root/assets/{notes-page-BWZRXsq6.js → notes-page-tuzIwy3c.js} +1 -1
  55. package/dist/gateway/static/root/assets/{notes-workbench-DdnwNz9x.js → notes-workbench-DSh3-hMY.js} +2 -2
  56. package/dist/gateway/static/root/assets/{page-tabs-DWWgy0bF.js → page-tabs-ke9s4nYi.js} +1 -1
  57. package/dist/gateway/static/root/assets/{preview-open-alternatives-Bnfs93ZP.js → preview-open-alternatives-Cp1eI4S9.js} +1 -1
  58. package/dist/gateway/static/root/assets/{product-open-page-BR7QFmT-.js → product-open-page-dXQCMAtH.js} +1 -1
  59. package/dist/gateway/static/root/assets/{project-detail-page-B8GeS4dl.js → project-detail-page-D0QPRHR_.js} +1 -1
  60. package/dist/gateway/static/root/assets/{projects-page-DOeu1Hk_.js → projects-page-CI5Vz62F.js} +1 -1
  61. package/dist/gateway/static/root/assets/{remote-access-hub-De94rxnE.js → remote-access-hub-S1jpzBS5.js} +1 -1
  62. package/dist/gateway/static/root/assets/{save-bar-controls-BzS-rRTP.js → save-bar-controls-Bl30zjHc.js} +1 -1
  63. package/dist/gateway/static/root/assets/{schedule-field-Cl2IIDAN.js → schedule-field-DqhmXQKo.js} +1 -1
  64. package/dist/gateway/static/root/assets/{schema-form-BjKjp5eZ.js → schema-form-DkUCy6vf.js} +1 -1
  65. package/dist/gateway/static/root/assets/{sessions-page-A7p8G0OJ.js → sessions-page-CTm66k7h.js} +1 -1
  66. package/dist/gateway/static/root/assets/settings-advanced-gate-CU52AUVD.js +1 -0
  67. package/dist/gateway/static/root/assets/{settings-form-section-BSDNBfHn.js → settings-form-section-C6ZbNpdy.js} +1 -1
  68. package/dist/gateway/static/root/assets/{settings-loading-skeleton-BD4peoAv.js → settings-loading-skeleton-Bk58_cr7.js} +1 -1
  69. package/dist/gateway/static/root/assets/{settings-page-S-P3U7at.js → settings-page-k8iE_NdX.js} +1 -1
  70. package/dist/gateway/static/root/assets/{settings-page-layout-BQTLh-86.js → settings-page-layout-DgFSya2e.js} +1 -1
  71. package/dist/gateway/static/root/assets/{setup-status-panel-W3p6kNyA.js → setup-status-panel-B_KDlyZA.js} +1 -1
  72. package/dist/gateway/static/root/assets/{share-preview-page-DQjMxyvw.js → share-preview-page-CV7nL_J9.js} +1 -1
  73. package/dist/gateway/static/root/assets/{shares-settings-Xo3N99PO.js → shares-settings-DK6XK95e.js} +1 -1
  74. package/dist/gateway/static/root/assets/skill-reload-api-Bvv_u4ii.js +1 -0
  75. package/dist/gateway/static/root/assets/{skills-page-C019Ml5q.js → skills-page-BGHvVbay.js} +1 -1
  76. package/dist/gateway/static/root/assets/{skills-page.utils-CXnpudm6.js → skills-page.utils-kahBIHg0.js} +1 -1
  77. package/dist/gateway/static/root/assets/{system-settings-panel-BhFwdYJP.js → system-settings-panel-JV3-MG5F.js} +1 -1
  78. package/dist/gateway/static/root/assets/{theme-store-DQI-HPL-.js → theme-store-DFLyzoLO.js} +1 -1
  79. package/dist/gateway/static/root/assets/{time-picker-C0DCya4U.js → time-picker-XwpxdZFr.js} +1 -1
  80. package/dist/gateway/static/root/assets/{typed-models-lib-C-M3Fv2N.js → typed-models-lib-60Aqo-UJ.js} +1 -1
  81. package/dist/gateway/static/root/assets/{use-channel-catalog-Bndq4y4I.js → use-channel-catalog-CnTkHDnw.js} +1 -1
  82. package/dist/gateway/static/root/assets/{user-context-page-fYBzpus-.js → user-context-page-DBCMk-Vn.js} +1 -1
  83. package/dist/gateway/static/root/assets/{voice-api-key-field-p_g4UI1-.js → voice-api-key-field-CNa8qUgS.js} +1 -1
  84. package/dist/gateway/static/root/assets/{work-discovery-page-DI0gCZRw.js → work-discovery-page-C1UIdsCl.js} +1 -1
  85. package/dist/gateway/static/root/assets/work-item-detail-page-DEAQepB8.js +1 -0
  86. package/dist/gateway/static/root/assets/{work-page-Z-nUaS_n.js → work-page-D5qYmCTq.js} +1 -1
  87. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-CHEXVvhH.js → workflow-run-setup-panel-yV_x595t.js} +1 -1
  88. package/dist/gateway/static/root/assets/{workflows-page-BDfwnM-Y.js → workflows-page-yrK17ZZ5.js} +1 -1
  89. package/dist/gateway/static/root/index.html +7 -7
  90. package/dist/package.js +1 -1
  91. package/dist/src/agent/embedded/model-runtime.js +3 -0
  92. package/dist/src/agent/embedded/run-for-session.js +18 -5
  93. package/dist/src/agent/embedded/run-turn.js +6 -3
  94. package/dist/src/agent/embedded/types.d.ts +2 -0
  95. package/dist/src/config/agent-profile.js +1 -1
  96. package/dist/src/connectors/composio-sessions.js +1 -1
  97. package/dist/src/gateway/agents-admin.js +1 -1
  98. package/dist/src/gateway/heartbeat/service.js +1 -1
  99. package/dist/src/gateway/hono/routes/browser-install.js +1 -1
  100. package/dist/src/heartbeat/index.js +1 -1
  101. package/dist/src/providers/provider-auth-service.js +3 -0
  102. package/dist/src/providers/register-bundled-oauth-flows.d.ts +2 -0
  103. package/dist/src/providers/register-bundled-oauth-flows.js +16 -0
  104. package/dist/src/session/store.d.ts +2 -0
  105. package/dist/src/session/store.js +30 -0
  106. package/package.json +3 -11
  107. package/dist/gateway/static/root/assets/channels-status-swr-D3xr2enH.js +0 -1
  108. package/dist/gateway/static/root/assets/index-Da36E3WH.css +0 -1
  109. package/dist/gateway/static/root/assets/messages-r8L6Ur3A.js +0 -3
  110. package/dist/gateway/static/root/assets/settings-advanced-gate-BsGzjmqx.js +0 -1
  111. package/dist/gateway/static/root/assets/skill-reload-api-ByPEG5t1.js +0 -1
  112. package/dist/gateway/static/root/assets/work-item-detail-page-DnBRP2wI.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-r8L6Ur3A.js";import{l as c,n as l}from"./locale-store-DVGhFXRz.js";import{i as u}from"./vendor-swr-BIWyz7Rc.js";import{Ac as d,As as f,Bo as p,Cs as m,Dc as h,Eu as g,Go as _,Ho as v,It as y,Kr as b,Ks as x,Ns as S,Nu as C,Ps as w,Ul as T,Uo as E,Vo as D,Wo as O,Zl as k,_u as A,as as j,cc as M,hl as N,is as P,ju as ee,ls as F,ns as te,tl as I,ts as L,us as R,yc as z,zo as B}from"./index-C1h0zkNo.js";import{n as V,r as H}from"./settings-page-layout-BQTLh-86.js";import{n as ne,r as U}from"./settings-loading-skeleton-BD4peoAv.js";import{n as W,t as G}from"./settings-form-section-BSDNBfHn.js";import{a as K,i as re,n as ie,o as ae,r as oe,t as se}from"./capability-presets-api-RM6S7ES5.js";import{a as ce,i as le,o as q,s as J,t as Y}from"./typed-models-lib-C-M3Fv2N.js";import{r as X}from"./image-generation-api-BgISY8i-.js";var ue=n(),de=e(t(),1),Z=r(),fe=[`deep`,`fast`,`cheap`,`code`,`review`];function Q(e){return fe.includes(e)}function pe(e){let{rows:t,onChange:n,disabled:r,defaultRole:i,chat:a,labels:o}=e,s=(0,de.useRef)([]),c=(0,de.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),p=u>=0?t[u]:void 0,m=t.map((e,t)=>({row:e,index:t})).filter(({index:e})=>e!==u),h=(e,r)=>{n(t.map((t,n)=>n===e?{...t,...r}:t))},g=e=>{if(u>=0){h(u,{model:e});return}s.current.unshift(`preset-model-row-${c.current++}`),n([{id:l,model:e,fallbacks:[],description:Q(l)?o.roleDescriptions[l]:``},...t])},_=e=>{let n=t[e];n&&h(e,{fallbacks:[...n.fallbacks??[],``]})},v=(e,n,r)=>{let i=t[e];if(!i)return;let a=[...i.fallbacks??[]];a[n]=r,h(e,{fallbacks:a})},b=(e,n)=>{let r=t[e];r&&h(e,{fallbacks:(r.fallbacks??[]).filter((e,t)=>t!==n)})},S=e=>{s.current.splice(e,1),n(t.filter((t,n)=>n!==e))},C=e=>{if(!e)return;let r=e===`__custom__`?``:e;s.current.push(`preset-model-row-${c.current++}`),n([...t,{id:r,model:``,fallbacks:[],description:Q(r)?o.roleDescriptions[r]:``}])},w=[...fe.filter(e=>e!==l&&!t.some(t=>t.id===e)).map(e=>({value:e,label:o.roleNames[e]})),{value:`__custom__`,label:o.customRole}],T=(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)(f,{type:`button`,variant:`secondary`,className:`h-7 gap-1 px-2 text-xs`,disabled:r,onClick:()=>_(t),children:[(0,Z.jsx)(d,{className:`size-3.5`,"aria-hidden":!0}),o.addFallback]})]}),(e.fallbacks??[]).length>0?(0,Z.jsx)(`div`,{className:`grid gap-1.5`,children:(e.fallbacks??[]).map((e,n)=>(0,Z.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto] gap-2`,children:[(0,Z.jsx)(y,{value:e,disabled:r,placeholder:o.fallbackPlaceholder,searchPlaceholder:a.modelSearchPlaceholder,noMatches:a.modelNoMatches,className:`w-full max-w-none`,contentAlign:`start`,onChange:e=>v(t,n,e)}),(0,Z.jsx)(f,{type:`button`,variant:`secondary`,className:`shrink-0 px-2`,disabled:r,"aria-label":o.removeFallback,onClick:()=>b(t,n),children:(0,Z.jsx)(x,{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=>h(t,{description:e.target.value})})]})]});return(0,Z.jsxs)(`div`,{className:`grid gap-5`,children:[(0,Z.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-base p-4`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:o.defaultTitle}),(0,Z.jsx)(`span`,{className:`rounded-full bg-accent/10 px-2 py-0.5 text-[11px] font-medium text-accent`,children:o.defaultBadge})]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:o.defaultHint})]}),(0,Z.jsxs)(`span`,{className:`rounded-md bg-surface-panel px-2 py-1 font-mono text-[11px] text-fg-subtle`,children:[o.roleId,`: `,l]})]}),(0,Z.jsxs)(`div`,{className:`mt-4 grid gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:o.primaryModel}),(0,Z.jsx)(y,{value:p?.model??``,disabled:r,placeholder:a.modelPlaceholder,searchPlaceholder:a.modelSearchPlaceholder,noMatches:a.modelNoMatches,className:`w-full max-w-none`,contentAlign:`start`,onChange:g})]}),p?(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)(A,{className:`size-3.5 transition-transform group-open:rotate-180`,"aria-hidden":!0})]}),(0,Z.jsx)(`div`,{className:`mt-3`,children:T(p,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})]}),m.length>0?(0,Z.jsx)(`div`,{className:`mt-3 grid gap-2`,children:m.map(({row:e,index:t})=>{let n=Q(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=>h(t,{id:e.target.value.toLowerCase()})})]})]}),(0,Z.jsxs)(`label`,{className:`grid min-w-0 gap-1.5 text-xs font-medium text-fg-muted`,children:[o.primaryModel,(0,Z.jsx)(y,{value:e.model,disabled:r,placeholder:a.modelPlaceholder,searchPlaceholder:a.modelSearchPlaceholder,noMatches:a.modelNoMatches,className:`w-full max-w-none`,contentAlign:`start`,onChange:e=>h(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)(A,{className:`size-3.5 transition-transform group-open:rotate-180`,"aria-hidden":!0})]}),(0,Z.jsxs)(`div`,{className:`mt-3`,children:[T(e,t),(0,Z.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,Z.jsxs)(f,{type:`button`,variant:`secondary`,disabled:r,onClick:()=>S(t),children:[(0,Z.jsx)(x,{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)(L,{value:``,options:w,placeholder:o.addTaskModel,allowEmpty:!1,disabled:r,triggerClassName:`mt-3 w-fit`,onChange:C})]})]})}function me(e){let t=(0,ue.c)(34),{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]===c.inheritanceTitle?d=t[3]:(d=(0,Z.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:c.inheritanceTitle}),t[2]=c.inheritanceTitle,t[3]=d);let f;t[4]===c.inheritanceHint?f=t[5]:(f=(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:c.inheritanceHint}),t[4]=c.inheritanceHint,t[5]=f);let p;t[6]!==s||t[7]!==n||t[8]!==c.inheritanceEmpty||t[9]!==r||t[10]!==i?(p=i.length>0?(0,Z.jsx)(`div`,{className:`mt-3 grid gap-2 sm:grid-cols-2`,children:i.map(e=>{let t=n.includes(e.id);return(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 rounded-lg bg-surface-panel/70 px-3 py-2.5 shadow-surface`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 shrink-0 rounded border-edge`,checked:t,disabled:s,onChange:()=>r(t?n.filter(t=>t!==e.id):[...n,e.id])}),(0,Z.jsxs)(`span`,{className:`min-w-0`,children:[(0,Z.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:e.name}),(0,Z.jsx)(`span`,{className:`mt-0.5 block font-mono text-[11px] text-fg-subtle`,children:e.id})]})]},e.id)})}):(0,Z.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:c.inheritanceEmpty}),t[6]=s,t[7]=n,t[8]=c.inheritanceEmpty,t[9]=r,t[10]=i,t[11]=p):p=t[11];let m;t[12]!==d||t[13]!==f||t[14]!==p?(m=(0,Z.jsxs)(`section`,{children:[d,f,p]}),t[12]=d,t[13]=f,t[14]=p,t[15]=m):m=t[15];let h;t[16]===c.jsonTitle?h=t[17]:(h=(0,Z.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:c.jsonTitle}),t[16]=c.jsonTitle,t[17]=h);let g;t[18]===c.jsonHint?g=t[19]:(g=(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:c.jsonHint}),t[18]=c.jsonHint,t[19]=g);let _;t[20]!==s||t[21]!==u||t[22]!==a||t[23]!==c.fieldHints||t[24]!==c.fieldLabels||t[25]!==o?(_=(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[20]=s,t[21]=u,t[22]=a,t[23]=c.fieldHints,t[24]=c.fieldLabels,t[25]=o,t[26]=_):_=t[26];let v;t[27]!==h||t[28]!==g||t[29]!==_?(v=(0,Z.jsxs)(`section`,{children:[h,g,_]}),t[27]=h,t[28]=g,t[29]=_,t[30]=v):v=t[30];let y;return t[31]!==m||t[32]!==v?(y=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[m,v]}),t[31]=m,t[32]=v,t[33]=y):y=t[33],y}function he(e){return e.name||e.directoryId}function ge(e){let t=(0,ue.c)(56),{mode:n,selected:r,catalog:i,loading:a,disabled:s,onModeChange:c,onSelectedChange:l,labels:u}=e,d=n===`allowlist`||n===`denylist`,p;t[0]===i?p=t[1]:(p=i.map(he).filter(Boolean),t[0]=i,t[1]=p);let m=p,h;bb0:{if(n===`inherit`){h=u.inheritSummary;break bb0}if(n===`all`){h=u.allSummary;break bb0}if(n===`off`){h=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],h=i}let _=h,v;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Z.jsx)(g,{className:`size-3.5`,"aria-hidden":!0}),t[5]=v):v=t[5];let y;t[6]===u.overrideSummaryTitle?y=t[7]:(y=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[v,u.overrideSummaryTitle]}),t[6]=u.overrideSummaryTitle,t[7]=y);let b;t[8]===_?b=t[9]:(b=(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:_}),t[8]=_,t[9]=b);let x;t[10]!==y||t[11]!==b?(x=(0,Z.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/70 px-3 py-2 shadow-surface`,children:[y,b]}),t[10]=y,t[11]=b,t[12]=x):x=t[12];let S;t[13]===u.modeLabel?S=t[14]:(S=(0,Z.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:u.modeLabel}),t[13]=u.modeLabel,t[14]=S);let C;t[15]===u.modeInherit?C=t[16]:(C=[`inherit`,u.modeInherit],t[15]=u.modeInherit,t[16]=C);let w;t[17]===u.modeAll?w=t[18]:(w=[`all`,u.modeAll],t[17]=u.modeAll,t[18]=w);let T;t[19]===u.modeAllowlist?T=t[20]:(T=[`allowlist`,u.modeAllowlist],t[19]=u.modeAllowlist,t[20]=T);let E;t[21]===u.modeDenylist?E=t[22]:(E=[`denylist`,u.modeDenylist],t[21]=u.modeDenylist,t[22]=E);let D;t[23]===u.modeOff?D=t[24]:(D=[`off`,u.modeOff],t[23]=u.modeOff,t[24]=D);let O;t[25]!==E||t[26]!==D||t[27]!==C||t[28]!==w||t[29]!==T?(O=[C,w,T,E,D],t[25]=E,t[26]=D,t[27]=C,t[28]=w,t[29]=T,t[30]=O):O=t[30];let k=O,A;t[31]!==s||t[32]!==n||t[33]!==c||t[34]!==k?(A=(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:k.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]=k,t[35]=A):A=t[35];let j;t[36]!==A||t[37]!==S?(j=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[S,A]}),t[36]=A,t[37]=S,t[38]=j):j=t[38];let M;t[39]!==i||t[40]!==m||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?(M=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)(f,{type:`button`,variant:`secondary`,className:q,disabled:s||a||m.length===0,onClick:()=>l(new Set(m)),children:u.quickSelectAll}),(0,Z.jsx)(f,{type:`button`,variant:`secondary`,className:q,disabled:s||a||r.size===0,onClick:()=>l(new Set),children:u.quickClear})]})]}),a?(0,Z.jsx)(U,{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=he(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]=m,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]=M):M=t[51];let N;return t[52]!==j||t[53]!==M||t[54]!==x?(N=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[x,j,M]}),t[52]=j,t[53]=M,t[54]=x,t[55]=N):N=t[55],N}var _e=[`write_file`,`apply_patch`,`exec_command`,`execute_code`],ve=[`exec_command`,`execute_code`,`automation`,`extensions`,`bundle-mcp`,`skill_manage`],ye=[`send_message`,`send_media`,`text_to_speech`,`create_share`],be=[`read_file`,`list_dir`,`grep`,`find`,`web_search`,`web_fetch`,`web_extract`],xe=[..._e,...ye],Se=[`read_file`,`write_file`,`apply_patch`,`list_dir`,`grep`,`find`,`web_search`,`web_fetch`],Ce=[`send_message`,`send_media`];function we(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 Te(e){let t=(0,ue.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,p;t[2]!==d||t[3]!==r?(p=Object.entries(r).filter(e=>{let[t]=e;return d.has(t)}).toSorted(Ee),t[2]=d,t[3]=r,t[4]=p):p=t[4];let m=p,h;if(t[5]!==d||t[6]!==n){h=[];for(let e of K){let t=e.toolIds.filter(e=>d.has(e));t.length>0&&h.push({key:e.key,ids:[...t]})}let e;t[8]===n?e=t[9]:(e=ae(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),h.push(e)}t[5]=d,t[6]=n,t[7]=h}else h=t[7];let g=h,_;t[12]!==i||t[13]!==r?(_=(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]=_):_=t[14];let v=_,y;t[15]!==i||t[16]!==r?(y=(e,t)=>{let n=r[e];n&&i({...r,[e]:t(n)})},t[15]=i,t[16]=r,t[17]=y):y=t[17];let b=y,x;t[18]!==d||t[19]!==i?(x=e=>{i(we(d,e))},t[18]=d,t[19]=i,t[20]=x):x=t[20];let S=x;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 C;t[23]===l.quickActionsLabel?C=t[24]:(C=(0,Z.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:l.quickActionsLabel}),t[23]=l.quickActionsLabel,t[24]=C);let w;t[25]===i?w=t[26]:(w=()=>i({}),t[25]=i,t[26]=w);let T;t[27]!==a||t[28]!==l.quickClearOverrides||t[29]!==w?(T=(0,Z.jsx)(f,{type:`button`,variant:`secondary`,className:q,disabled:a,onClick:w,children:l.quickClearOverrides}),t[27]=a,t[28]=l.quickClearOverrides,t[29]=w,t[30]=T):T=t[30];let E;t[31]===S?E=t[32]:(E=()=>S([[_e,`deny`]]),t[31]=S,t[32]=E);let D;t[33]!==a||t[34]!==l.quickReadOnlyWorkspace||t[35]!==E?(D=(0,Z.jsx)(f,{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]===S?O=t[38]:(O=()=>S([[ve,`deny`]]),t[37]=S,t[38]=O);let k;t[39]!==a||t[40]!==l.quickHighRiskOff||t[41]!==O?(k=(0,Z.jsx)(f,{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]===S?A=t[44]:(A=()=>S([[ye,`deny`]]),t[43]=S,t[44]=A);let j;t[45]!==a||t[46]!==l.quickNoOutbound||t[47]!==A?(j=(0,Z.jsx)(f,{type:`button`,variant:`secondary`,className:q,disabled:a,onClick:A,children:l.quickNoOutbound}),t[45]=a,t[46]=l.quickNoOutbound,t[47]=A,t[48]=j):j=t[48];let M;t[49]===S?M=t[50]:(M=()=>S([[be,`allow`],[xe,`deny`]]),t[49]=S,t[50]=M);let N;t[51]!==a||t[52]!==l.quickResearchMode||t[53]!==M?(N=(0,Z.jsx)(f,{type:`button`,variant:`secondary`,className:q,disabled:a,onClick:M,children:l.quickResearchMode}),t[51]=a,t[52]=l.quickResearchMode,t[53]=M,t[54]=N):N=t[54];let ee;t[55]===S?ee=t[56]:(ee=()=>S([[Se,`allow`],[Ce,`deny`]]),t[55]=S,t[56]=ee);let F;t[57]!==a||t[58]!==l.quickCodingMode||t[59]!==ee?(F=(0,Z.jsx)(f,{type:`button`,variant:`secondary`,className:q,disabled:a,onClick:ee,children:l.quickCodingMode}),t[57]=a,t[58]=l.quickCodingMode,t[59]=ee,t[60]=F):F=t[60];let I;t[61]!==k||t[62]!==j||t[63]!==N||t[64]!==F||t[65]!==T||t[66]!==D?(I=(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[T,D,k,j,N,F]}),t[61]=k,t[62]=j,t[63]=N,t[64]=F,t[65]=T,t[66]=D,t[67]=I):I=t[67];let L;t[68]!==I||t[69]!==C?(L=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[C,I]}),t[68]=I,t[69]=C,t[70]=L):L=t[70];let R;t[71]===l.overrideSummaryTitle?R=t[72]:(R=(0,Z.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:l.overrideSummaryTitle}),t[71]=l.overrideSummaryTitle,t[72]=R);let z;t[73]!==l.modeAllow||t[74]!==l.modeConfirm||t[75]!==l.modeDeny||t[76]!==l.noOverrides||t[77]!==m?(z=m.length>0?(0,Z.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:m.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]=m,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]!==g||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]!==v||t[98]!==r||t[99]!==b?(V=(0,Z.jsx)(`div`,{className:`flex flex-col gap-5`,children:g.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:()=>v(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)(te,{value:n.scope??``,disabled:a,onChange:t=>b(e,e=>{let n=t.target.value;if(!n){let{scope:t,...n}=e;return n}return{...e,scope:n}}),children:[(0,Z.jsx)(P,{value:``,children:l.scopeInherit}),(0,Z.jsx)(P,{value:`readonly`,children:l.scopeReadonly}),(0,Z.jsx)(P,{value:`workspace`,children:l.scopeWorkspace}),(0,Z.jsx)(P,{value:`unrestricted`,children:l.scopeUnrestricted})]})]}),(0,Z.jsx)(Oe,{label:l.maxCallsLabel,value:n.limits?.maxCallsPerTurn,disabled:a,onChange:t=>b(e,e=>De(e,`maxCallsPerTurn`,t))}),(0,Z.jsx)(Oe,{label:l.timeoutLabel,value:n.limits?.timeoutMs,disabled:a,onChange:t=>b(e,e=>De(e,`timeoutMs`,t))})]}):null]},e)})})]},t)})}),t[82]=a,t[83]=c,t[84]=s,t[85]=g,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]=v,t[98]=r,t[99]=b,t[100]=V):V=t[100];let H;return t[101]!==L||t[102]!==B||t[103]!==V?(H=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[L,B,V]}),t[101]=L,t[102]=B,t[103]=V,t[104]=H):H=t[104],H}function Ee(e,t){let[n]=e,[r]=t;return n.localeCompare(r)}function De(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 Oe(e){let t=(0,ue.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 ke=[`blank`,`safe-coder`,`read-only`,`low-cost`],Ae=[{id:`overview`,icon:k},{id:`models`,icon:N},{id:`tools`,icon:w},{id:`skills`,icon:h},{id:`advanced`,icon:M},{id:`impact`,icon:T}];function je(e){return le(Object.entries(e?.models?.roles??{}).map(([e,t])=>({id:e,model:t.model,fallbacks:t.fallbacks??[],description:t.description})))}function $(e){return structuredClone(e?.tools?.builtin??{})}function Me(e){let t=e?.skills;if(!t)return new Set;let n=t.mode===`denylist`?t.deny:t.allow;return new Set(n??[])}function Ne(){return{primary:``,fallbacks:[],timeoutMs:``,autoProviderFallback:``}}function Pe(e){return{primary:e?.primary??``,fallbacks:[...e?.fallbacks??[]],timeoutMs:e?.timeoutMs?String(e.timeoutMs):``,autoProviderFallback:e?.autoProviderFallback===void 0?``:e.autoProviderFallback?`true`:`false`}}function Fe(){return{imageModel:Ne(),imageGenerationModel:Ne(),allowFallbacks:``,maxCostTier:``}}function Ie(e){return{imageModel:Pe(e?.models?.imageModel),imageGenerationModel:Pe(e?.models?.imageGenerationModel),allowFallbacks:e?.models?.policy?.allowFallbacks===void 0?``:e.models.policy.allowFallbacks?`true`:`false`,maxCostTier:e?.models?.policy?.maxCostTier??``}}function Le(e){return e===void 0?``:JSON.stringify(e,null,2)}function Re(){return{mcp:``,workflows:``,boundaries:``,runtime:``,locks:``}}function ze(e){return{mcp:Le(e?.tools?.mcp),workflows:Le(e?.workflows),boundaries:Le(e?.boundaries),runtime:Le(e?.runtime),locks:Le(e?.locks)}}function Be(e){return{id:e?.id??``,name:e?.name??``,description:e?.description??``,modelRows:je(e),modelAdvanced:Ie(e),toolPolicies:$(e),skillMode:e?.skills?.mode??`inherit`,skillPick:Me(e),extendsIds:[...e?.extends??[]],jsonFields:ze(e)}}function Ve(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 He(e,t){let n=Y(e.modelRows),r=Ve(e.modelAdvanced.imageModel),i=Ve(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 Ue(e){return e.trim()?JSON.parse(e):void 0}function We(e){if(!e.trim())return``;try{return JSON.stringify(JSON.parse(e))}catch{return`!invalid:${e}`}}function Ge(e){let t=Object.fromEntries(Object.entries(e.toolPolicies).toSorted(([e],[t])=>e.localeCompare(t))),n=Ue(e.jsonFields.mcp);return Object.keys(t).length>0||n?{builtin:t,...n?{mcp:n}:{}}:null}function Ke(e){return Object.fromEntries(Object.entries(e??{}).toSorted(([e],[t])=>e.localeCompare(t)))}function qe(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 Je(e,t){return{id:e.id.trim(),name:e.name.trim(),description:e.description.trim(),models:He(e,t),tools:{builtin:Ke(e.toolPolicies),mcp:We(e.jsonFields.mcp)},skills:qe(e),extends:[...e.extendsIds].toSorted(),workflows:We(e.jsonFields.workflows),boundaries:We(e.jsonFields.boundaries),runtime:We(e.jsonFields.runtime),locks:We(e.jsonFields.locks)}}function Ye(e){return e?{id:e.id,name:e.name,description:e.description??``,models:e.models??null,tools:{builtin:Ke(e.tools?.builtin),mcp:We(Le(e.tools?.mcp))},skills:e.skills??null,extends:[...e.extends??[]].toSorted(),workflows:We(Le(e.workflows)),boundaries:We(Le(e.boundaries)),runtime:We(Le(e.runtime)),locks:We(Le(e.locks))}:null}function Xe(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 Ze(){return{modelAdvanced:Fe(),extendsIds:[],jsonFields:Re()}}function Qe(e,t){return{extends:[...e.extendsIds],models:He(e,t)??void 0,tools:Ge(e)??void 0,skills:qe(e)??void 0,workflows:Ue(e.jsonFields.workflows),boundaries:Ue(e.jsonFields.boundaries),runtime:Ue(e.jsonFields.runtime),locks:Ue(e.jsonFields.locks)}}function $e(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`]),...Ze()}: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,...Ze()}: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,...Ze()}:{id:``,name:``,description:``,modelRows:[],toolPolicies:{},skillMode:`inherit`,skillPick:new Set,...Ze()}}function et(){let e=s(l(e=>e.language)),t=e.capabilityPresetsSettings,n=(0,Z.jsx)(f,{asChild:!0,type:`button`,variant:`secondary`,children:(0,Z.jsxs)(a,{to:`/agents`,children:[t.manageAgents,(0,Z.jsx)(ee,{className:`size-4`,"aria-hidden":!0})]})}),r=!!c(e=>e.token),{data:g,error:y,isLoading:A,mutate:P}=u(r?`settings-capability-presets`:null,oe,{revalidateOnFocus:!1}),{data:te=[],isLoading:L}=u(r?`settings-capability-presets-skills-catalog`:null,b,{revalidateOnFocus:!1}),[U,K]=i(),[ae,le]=(0,de.useState)(``),[q,J]=(0,de.useState)(`overview`),[Y,X]=(0,de.useState)(()=>$e(`blank`,t)),[ue,fe]=(0,de.useState)(null),[Q,he]=(0,de.useState)(!1),[_e,ve]=(0,de.useState)(null),[ye,be]=(0,de.useState)(!1),[xe,Se]=(0,de.useState)(null),[Ce,we]=(0,de.useState)(null),Ee=g?.presets??[],De=g?.defaultPresetId??`default`,Oe=Ee.find(e=>e.id===De)??null,je=Ee.filter(e=>e.id!==De),$=(0,de.useMemo)(()=>Ee.find(e=>e.id===ae)??Ee[0]??null,[Ee,ae]),Me=!$||Y.id.trim()!==$.id,Ne=!!($&&$.id===De),Pe=JSON.stringify(Je(Y,$))!==JSON.stringify(Ye($)),Fe=Je(Y,$),Ie=Ye($),Le=[Fe.id!==Ie?.id||Fe.name!==Ie?.name||Fe.description!==Ie?.description?t.tabs.overview:``,JSON.stringify(Fe.models)===JSON.stringify(Ie?.models)?``:t.tabs.models,JSON.stringify(Fe.tools)===JSON.stringify(Ie?.tools)?``:t.tabs.tools,JSON.stringify(Fe.skills)===JSON.stringify(Ie?.skills)?``:t.tabs.skills,JSON.stringify({extends:Fe.extends,workflows:Fe.workflows,boundaries:Fe.boundaries,runtime:Fe.runtime,locks:Fe.locks})===JSON.stringify({extends:Ie?.extends,workflows:Ie?.workflows,boundaries:Ie?.boundaries,runtime:Ie?.runtime,locks:Ie?.locks})?``:t.tabs.advanced].filter(Boolean),Re=_e??(y instanceof Error?y.message:null),ze=U.get(`action`)===`new`||!!U.get(`preset`),Ve=U.get(`action`)===`new`&&ue===null,He=Me?t.newPreset:$?.name??t.editorTitle,We=t=>e.agentsSettings.toolsDisableGroups[t],Ge=t=>t in e.agentsSettings.toolDescriptions?e.agentsSettings.toolDescriptions[t]:``;(0,de.useEffect)(()=>{if(!g||Q)return;if(U.get(`action`)===`new`){le(``),X($e(`blank`,t)),J(`overview`);return}let e=U.get(`preset`)?.trim(),n=e?g.presets.find(t=>t.id===e):null;if(n){le(n.id),X(Be(n)),J(U.get(`tab`)??`overview`);return}$&&(le($.id),X(e=>e.id===$.id?e:Be($)))},[Q,g,U,$]);function Ke(e){fe(null),le(e.id),X(Be(e)),K({preset:e.id},{replace:!0}),J(`overview`)}function qe(){fe(null),le(``),X($e(`blank`,t)),ve(null),K({action:`new`},{replace:!0}),J(`overview`)}function Ze(e){fe(e),X($e(e,t)),ve(null),J(`overview`)}function et(){if(ue){let e=$e(ue,t);if(JSON.stringify(Je(Y,null))!==JSON.stringify(Je(e,null))&&!window.confirm(t.changeTemplateConfirm))return}fe(null),ve(null)}function rt(){!Ve&&Pe&&!window.confirm(t.discardConfirm)||(be(!1),Se(null),K({},{replace:!0}),fe(null),ve(null),X(Be($)),J(`overview`))}async function it(){let e=ce(Y.modelRows,{invalidId:t.invalidModelRoleId,duplicateId:t.duplicateModelRoleId,invalidModel:t.invalidModelRef});if(e){ve(e),J(`models`);return}for(let e of[Y.modelAdvanced.imageModel,Y.modelAdvanced.imageGenerationModel]){if([e.primary,...e.fallbacks].map(e=>e.trim()).filter(Boolean).some(e=>!/^[^/\s]+\/.+/.test(e))){ve(t.invalidModelRef),J(`models`);return}if(e.timeoutMs.trim()&&(!Number.isInteger(Number(e.timeoutMs))||Number(e.timeoutMs)<=0)){ve(t.advancedPositiveIntegerError),J(`models`);return}}for(let e of Object.values(Y.toolPolicies))if([e.limits?.maxCallsPerTurn,e.limits?.timeoutMs].filter(e=>e!==void 0).some(e=>!Number.isInteger(e)||e<=0)){ve(t.advancedPositiveIntegerError),J(`tools`);return}for(let e of Object.keys(Y.jsonFields))try{Ue(Y.jsonFields[e])}catch{ve(t.advancedJsonError.replace(`{{field}}`,t.advancedFieldLabels[e])),J(`advanced`);return}he(!0),ve(null);try{let e=Qe(Y,$);if(Me){let t=await se({id:Y.id.trim(),name:Y.name.trim(),...Y.description.trim()?{description:Y.description.trim()}:{},...e});await P(t.presets,{revalidate:!1}),le(t.presetId),fe(null),K({preset:t.presetId},{replace:!0})}else $&&await P(await re($.id,{name:Y.name.trim(),description:Y.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){ve(e instanceof Error?e.message:t.saveError)}finally{he(!1)}}async function at(){if($){he(!0),ve(null),Se(null);try{await P(await ie($.id),{revalidate:!1}),be(!1),le(``),fe(null),X($e(`blank`,t)),J(`overview`),K({},{replace:!0})}catch(e){Se(e instanceof Error?e.message:t.deleteError)}finally{he(!1)}}}return r?(0,Z.jsxs)(H,{gap:`gap-5`,className:`pb-24`,children:[(0,Z.jsx)(V,{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)(f,{type:`button`,onClick:qe,disabled:Q,children:[(0,Z.jsx)(d,{className:`size-4`,"aria-hidden":!0}),t.newPreset]})]})}),Re?(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:Re}):null,A?(0,Z.jsx)(ne,{sections:2}):(0,Z.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[Oe?(0,Z.jsxs)(G,{children:[(0,Z.jsx)(W,{icon:N,title:t.globalDefaultsTitle,subtitle:t.globalDefaultsHint}),(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>Ke(Oe),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:Oe.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:Oe.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})]}),Oe.description?(0,Z.jsx)(`p`,{className:`mt-3 line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:Oe.description}):null,(0,Z.jsx)(`div`,{className:`mt-3 text-xs text-fg-subtle`,children:Xe(Oe,t)})]})]}):null,(0,Z.jsxs)(G,{children:[(0,Z.jsx)(W,{icon:N,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)(f,{type:`button`,variant:`secondary`,onClick:qe,disabled:Q,children:[(0,Z.jsx)(d,{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:()=>Ke(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:Xe(e,t)})]},e.id))})]})]}),(0,Z.jsx)(B,{open:ze,onOpenChange:e=>{e||rt()},children:(0,Z.jsxs)(O,{children:[(0,Z.jsx)(E,{className:o(`xopc-dialog-overlay fixed inset-0 bg-scrim`,R)}),(0,Z.jsx)(D,{ref:we,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`,F),onOpenAutoFocus:e=>e.preventDefault(),children:(0,Z.jsxs)(j,{layer:`modal`,portalContainer:Ce,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:[!Ve&&Me&&ue?(0,Z.jsx)(`button`,{type:`button`,className:o(m,`shrink-0 p-1.5 hover:bg-surface-base`),onClick:et,"aria-label":t.changeTemplate,title:t.changeTemplate,children:(0,Z.jsx)(C,{className:`size-4`,"aria-hidden":!0})}):null,(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(_,{className:`truncate text-base font-semibold text-fg`,children:He}),(0,Z.jsx)(v,{className:`mt-0.5 truncate text-xs text-fg-muted`,children:Ve?t.templatePickerSubtitle:Me&&ue?`${t.editorHint} · ${t.basedOnTemplate.replace(`{{template}}`,t.starters[ue].title)}`:Me?t.editorHint:Y.id})]})]}),(0,Z.jsx)(p,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:o(m,`shrink-0 p-1.5 hover:bg-surface-base`),"aria-label":t.closeDialog,children:(0,Z.jsx)(S,{className:`size-4`,"aria-hidden":!0})})})]}),Ve?(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:ke.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:()=>Ze(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)(f,{type:`button`,variant:`secondary`,onClick:rt,children:t.cancel})})]}):(0,Z.jsxs)(Z.Fragment,{children:[Re?(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:Re}):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:Ae.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`,q===e?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),onClick:()=>J(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:[q===`overview`?(0,Z.jsxs)(G,{children:[(0,Z.jsx)(W,{icon:k,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:Y.id,disabled:Q||!Me,onChange:e=>X(t=>({...t,id:e.target.value.toLowerCase()})),placeholder:`safe-coder`})]}),!Me&&$?(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:Y.name,disabled:Q,onChange:e=>X(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:Y.description,disabled:Q,onChange:e=>X(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)(tt,{icon:N,label:t.modelsTitle,value:String(Y.modelRows.length)}),(0,Z.jsx)(tt,{icon:w,label:t.toolsTitle,value:String(Object.keys(Y.toolPolicies).length)}),(0,Z.jsx)(tt,{icon:h,label:t.skillsTitle,value:t.skillModeLabels[Y.skillMode]})]})]}):null,q===`models`?(0,Z.jsxs)(G,{children:[(0,Z.jsx)(W,{icon:N,title:t.modelsTitle,subtitle:t.modelsHint}),(0,Z.jsx)(pe,{rows:Y.modelRows,onChange:e=>X(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)(nt,{value:Y.modelAdvanced,onChange:e=>X(t=>({...t,modelAdvanced:e})),disabled:Q,cp:t,chat:e.chat})]}):null,q===`tools`?(0,Z.jsxs)(G,{children:[(0,Z.jsx)(W,{icon:w,title:t.toolsTitle,subtitle:t.toolsHint}),(0,Z.jsx)(Te,{builtinToolIds:g?.builtinToolIds??[],toolPolicies:Y.toolPolicies,onChange:e=>X(t=>({...t,toolPolicies:e})),disabled:Q,getToolDescription:Ge,getGroupTitle:We,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,q===`skills`?(0,Z.jsxs)(G,{children:[(0,Z.jsx)(W,{icon:h,title:t.skillsTitle,subtitle:t.skillsHint}),(0,Z.jsx)(ge,{mode:Y.skillMode,selected:Y.skillPick,catalog:te,loading:L,disabled:Q,onModeChange:e=>X(t=>({...t,skillMode:e})),onSelectedChange:e=>X(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,q===`advanced`?(0,Z.jsxs)(G,{children:[(0,Z.jsx)(W,{icon:M,title:t.advancedTitle,subtitle:t.advancedHint}),(0,Z.jsx)(me,{extendsIds:Y.extendsIds,onExtendsChange:e=>X(t=>({...t,extendsIds:e})),presetOptions:Ee.filter(e=>e.id!==$?.id&&e.id!==De),jsonFields:Y.jsonFields,onJsonFieldsChange:e=>X(t=>({...t,jsonFields:e})),disabled:Q,labels:{inheritanceTitle:t.advancedInheritanceTitle,inheritanceHint:t.advancedInheritanceHint,inheritanceEmpty:t.advancedInheritanceEmpty,jsonTitle:t.advancedJsonTitle,jsonHint:t.advancedJsonHint,fieldLabels:t.advancedFieldLabels,fieldHints:t.advancedFieldHints}})]}):null,q===`impact`?(0,Z.jsxs)(G,{children:[(0,Z.jsx)(W,{icon:T,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:Le.length>0?t.changePreviewSections.replace(`{{sections}}`,Le.join(`、`)):t.changePreviewEmpty})]}),$?.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:Pe?t.unsavedTitle:t.noUnsavedTitle}),(0,Z.jsx)(`div`,{className:`text-xs text-fg-muted`,children:Pe?($?.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:[Pe?(0,Z.jsx)(f,{type:`button`,variant:`secondary`,disabled:Q,onClick:()=>X(Be($)),children:t.discard}):null,$&&!Ne?(0,Z.jsxs)(f,{type:`button`,variant:`secondary`,disabled:Q,onClick:()=>{Se(null),be(!0)},children:[(0,Z.jsx)(x,{className:`size-4`,"aria-hidden":!0}),t.delete]}):null,(0,Z.jsxs)(f,{type:`button`,disabled:Q||!Y.id.trim()||!Y.name.trim()||!Pe,onClick:()=>void it(),children:[(0,Z.jsx)(z,{className:`size-4`,"aria-hidden":!0}),t.savePreset]})]})]})]})]})})]})}),(0,Z.jsx)(B,{open:ye,onOpenChange:e=>{Q||(be(e),e||Se(null))},children:(0,Z.jsxs)(O,{children:[(0,Z.jsx)(E,{className:o(`xopc-dialog-overlay fixed inset-0 bg-scrim`,R)}),(0,Z.jsxs)(D,{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`,F),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)(_,{className:`text-base font-semibold text-fg`,children:t.deleteDialogTitle}),(0,Z.jsx)(v,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:$?t.deleteConfirm.replace(`{{name}}`,$.name):t.deleteConfirmFallback})]}),xe?(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:xe}):null,(0,Z.jsxs)(`div`,{className:`flex justify-end gap-2 px-4 py-3`,children:[(0,Z.jsx)(f,{type:`button`,variant:`secondary`,disabled:Q,onClick:()=>be(!1),children:t.cancel}),(0,Z.jsxs)(f,{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 at(),children:[Q?(0,Z.jsx)(I,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(x,{className:`size-4`,"aria-hidden":!0}),Q?t.deleting:t.delete]})]})]})]})})]}):(0,Z.jsxs)(H,{gap:`gap-3`,children:[(0,Z.jsx)(V,{title:t.title,actions:n}),(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.needToken})]})}function tt(e){let t=(0,ue.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 nt(e){let t=(0,ue.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`,X,s),f;t[1]===c?f=t[2]:(f=(c??[]).filter(at).flatMap(it),t[1]=c,t[2]=f);let p=f,m;t[3]===p?m=t[4]:(m=new Set(p.map(rt)),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,de.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 w;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,Z.jsx)(A,{className:`size-4 shrink-0 text-fg-subtle transition-transform group-open:rotate-180`,"aria-hidden":!0}),t[26]=w):w=t[26];let T;t[27]===C?T=t[28]:(T=(0,Z.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-3 p-4`,children:[C,w]}),t[27]=C,t[28]=T);let E;t[29]===y?E=t[30]:(E=e=>y(`imageModel`,e),t[29]=y,t[30]=E);let D;t[31]!==o||t[32]!==a||t[33]!==i||t[34]!==E||t[35]!==n.imageModel?(D=(0,Z.jsx)(ot,{title:a.imageUnderstandingTitle,value:n.imageModel,onChange:E,disabled:i,cp:a,chat:o,capabilitiesFilter:`vision`}),t[31]=o,t[32]=a,t[33]=i,t[34]=E,t[35]=n.imageModel,t[36]=D):D=t[36];let O;t[37]===y?O=t[38]:(O=e=>y(`imageGenerationModel`,e),t[37]=y,t[38]=O);let k;t[39]===a.modelImageSettingsLink?k=t[40]:(k={label:a.modelImageSettingsLink,path:`/settings/capabilities/image`},t[39]=a.modelImageSettingsLink,t[40]=k);let j;t[41]!==o||t[42]!==a||t[43]!==i||t[44]!==p||t[45]!==d||t[46]!==l||t[47]!==O||t[48]!==k||t[49]!==n.imageGenerationModel?(j=(0,Z.jsx)(ot,{title:a.imageGenerationTitle,value:n.imageGenerationModel,onChange:O,disabled:i,cp:a,chat:o,models:p,modelsLoading:l,modelsError:d,noMatches:a.modelNoConfiguredImageModels,settingsFooterLink:k}),t[41]=o,t[42]=a,t[43]=i,t[44]=p,t[45]=d,t[46]=l,t[47]=O,t[48]=k,t[49]=n.imageGenerationModel,t[50]=j):j=t[50];let M;t[51]!==D||t[52]!==j?(M=(0,Z.jsxs)(`div`,{className:`grid gap-3 border-t border-edge-subtle p-4 dark:border-edge lg:grid-cols-2`,children:[D,j]}),t[51]=D,t[52]=j,t[53]=M):M=t[53];let N;t[54]!==T||t[55]!==M?(N=(0,Z.jsxs)(`details`,{className:`group rounded-xl border border-edge bg-surface-base`,children:[T,M]}),t[54]=T,t[55]=M,t[56]=N):N=t[56];let ee;t[57]===a.modelAdvancedTitle?ee=t[58]:(ee=(0,Z.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:a.modelAdvancedTitle}),t[57]=a.modelAdvancedTitle,t[58]=ee);let F;t[59]===a.modelAdvancedHint?F=t[60]:(F=(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:a.modelAdvancedHint}),t[59]=a.modelAdvancedHint,t[60]=F);let I;t[61]!==ee||t[62]!==F?(I=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[ee,F]}),t[61]=ee,t[62]=F,t[63]=I):I=t[63];let L;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,Z.jsx)(A,{className:`size-4 shrink-0 text-fg-subtle transition-transform group-open:rotate-180`,"aria-hidden":!0}),t[64]=L):L=t[64];let R;t[65]===I?R=t[66]:(R=(0,Z.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-3 p-4`,children:[I,L]}),t[65]=I,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)(P,{value:``,children:a.policyInherit}),t[72]=a.policyInherit,t[73]=V);let H;t[74]===a.policyEnabled?H=t[75]:(H=(0,Z.jsx)(P,{value:`true`,children:a.policyEnabled}),t[74]=a.policyEnabled,t[75]=H);let ne;t[76]===a.policyDisabled?ne=t[77]:(ne=(0,Z.jsx)(P,{value:`false`,children:a.policyDisabled}),t[76]=a.policyDisabled,t[77]=ne);let U;t[78]!==i||t[79]!==B||t[80]!==V||t[81]!==H||t[82]!==ne||t[83]!==n.allowFallbacks?(U=(0,Z.jsxs)(te,{value:n.allowFallbacks,disabled:i,side:`top`,onChange:B,children:[V,H,ne]}),t[78]=i,t[79]=B,t[80]=V,t[81]=H,t[82]=ne,t[83]=n.allowFallbacks,t[84]=U):U=t[84];let W;t[85]!==z||t[86]!==U?(W=(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[z,U]}),t[85]=z,t[86]=U,t[87]=W):W=t[87];let G;t[88]===a.modelMaxCostTierLabel?G=t[89]:(G=(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:a.modelMaxCostTierLabel}),t[88]=a.modelMaxCostTierLabel,t[89]=G);let K;t[90]!==r||t[91]!==n?(K=e=>r({...n,maxCostTier:e.target.value}),t[90]=r,t[91]=n,t[92]=K):K=t[92];let re;t[93]===a.policyInherit?re=t[94]:(re=(0,Z.jsx)(P,{value:``,children:a.policyInherit}),t[93]=a.policyInherit,t[94]=re);let ie;t[95]===a.costTierLow?ie=t[96]:(ie=(0,Z.jsx)(P,{value:`low`,children:a.costTierLow}),t[95]=a.costTierLow,t[96]=ie);let ae;t[97]===a.costTierMedium?ae=t[98]:(ae=(0,Z.jsx)(P,{value:`medium`,children:a.costTierMedium}),t[97]=a.costTierMedium,t[98]=ae);let oe;t[99]===a.costTierHigh?oe=t[100]:(oe=(0,Z.jsx)(P,{value:`high`,children:a.costTierHigh}),t[99]=a.costTierHigh,t[100]=oe);let se;t[101]!==i||t[102]!==K||t[103]!==re||t[104]!==ie||t[105]!==ae||t[106]!==oe||t[107]!==n.maxCostTier?(se=(0,Z.jsxs)(te,{value:n.maxCostTier,disabled:i,side:`top`,onChange:K,children:[re,ie,ae,oe]}),t[101]=i,t[102]=K,t[103]=re,t[104]=ie,t[105]=ae,t[106]=oe,t[107]=n.maxCostTier,t[108]=se):se=t[108];let ce;t[109]!==G||t[110]!==se?(ce=(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[G,se]}),t[109]=G,t[110]=se,t[111]=ce):ce=t[111];let le;t[112]!==W||t[113]!==ce?(le=(0,Z.jsxs)(`div`,{className:`grid gap-3 border-t border-edge-subtle p-4 dark:border-edge sm:grid-cols-2`,children:[W,ce]}),t[112]=W,t[113]=ce,t[114]=le):le=t[114];let q;t[115]!==R||t[116]!==le?(q=(0,Z.jsxs)(`details`,{className:`group rounded-xl border border-edge bg-surface-base`,children:[R,le]}),t[115]=R,t[116]=le,t[117]=q):q=t[117];let J;return t[118]!==N||t[119]!==q?(J=(0,Z.jsxs)(`div`,{className:`mt-5 grid gap-3 border-t border-edge-subtle pt-5 dark:border-edge`,children:[N,q]}),t[118]=N,t[119]=q,t[120]=J):J=t[120],J}function rt(e){return e.id}function it(e){return e.models.map(t=>({id:`${e.id}/${t}`,name:t,provider:e.label}))}function at(e){return e.configured||e.credentialMode===`none`}function ot(e){let t=(0,ue.c)(109),{title:n,value:r,onChange:i,disabled:a,cp:o,chat:s,capabilitiesFilter:c,models:l,modelsLoading:u,modelsError:p,noMatches:m,settingsFooterLink:h}=e,g;t[0]!==i||t[1]!==r?(g=(e,t)=>{i({...r,fallbacks:r.fallbacks.map((n,r)=>r===e?t:n)})},t[0]=i,t[1]=r,t[2]=g):g=t[2];let _=g,v;t[3]===n?v=t[4]:(v=(0,Z.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n}),t[3]=n,t[4]=v);let b=r.primary||o.modelNotSet,C;t[5]===b?C=t[6]:(C=(0,Z.jsx)(`span`,{className:`max-w-48 truncate font-mono text-xs text-fg-muted`,children:b}),t[5]=b,t[6]=C);let w;t[7]!==v||t[8]!==C?(w=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-2.5`,children:[v,C]}),t[7]=v,t[8]=C,t[9]=w):w=t[9];let T;t[10]===o.modelToolPrimaryLabel?T=t[11]:(T=(0,Z.jsx)(`div`,{className:`text-xs text-fg-muted`,children:o.modelToolPrimaryLabel}),t[10]=o.modelToolPrimaryLabel,t[11]=T);let E=m??s.modelNoMatches,D;t[12]!==i||t[13]!==r?(D=e=>i({...r,primary:e}),t[12]=i,t[13]=r,t[14]=D):D=t[14];let O;t[15]!==c||t[16]!==s.modelPlaceholder||t[17]!==s.modelSearchPlaceholder||t[18]!==a||t[19]!==l||t[20]!==p||t[21]!==u||t[22]!==h||t[23]!==E||t[24]!==D||t[25]!==r.primary?(O=(0,Z.jsx)(y,{value:r.primary,disabled:a,placeholder:s.modelPlaceholder,searchPlaceholder:s.modelSearchPlaceholder,noMatches:E,models:l,modelsLoading:u,modelsError:p,settingsFooterLink:h,capabilitiesFilter:c,className:`w-full max-w-none`,contentAlign:`start`,onChange:D}),t[15]=c,t[16]=s.modelPlaceholder,t[17]=s.modelSearchPlaceholder,t[18]=a,t[19]=l,t[20]=p,t[21]=u,t[22]=h,t[23]=E,t[24]=D,t[25]=r.primary,t[26]=O):O=t[26];let k;t[27]!==o.modelClearSelection||t[28]!==a||t[29]!==i||t[30]!==r?(k=r.primary?(0,Z.jsx)(f,{type:`button`,variant:`secondary`,className:`shrink-0 px-2`,disabled:a,"aria-label":o.modelClearSelection,onClick:()=>i({...r,primary:``}),children:(0,Z.jsx)(S,{className:`size-4`,strokeWidth:1.75})}):null,t[27]=o.modelClearSelection,t[28]=a,t[29]=i,t[30]=r,t[31]=k):k=t[31];let A;t[32]!==O||t[33]!==k?(A=(0,Z.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto] gap-2`,children:[O,k]}),t[32]=O,t[33]=k,t[34]=A):A=t[34];let j;t[35]!==A||t[36]!==T?(j=(0,Z.jsxs)(`div`,{className:`grid gap-1`,children:[T,A]}),t[35]=A,t[36]=T,t[37]=j):j=t[37];let M;t[38]===o.modelToolFallbacksLabel?M=t[39]:(M=(0,Z.jsx)(`div`,{className:`text-xs text-fg-muted`,children:o.modelToolFallbacksLabel}),t[38]=o.modelToolFallbacksLabel,t[39]=M);let N;t[40]!==i||t[41]!==r?(N=()=>i({...r,fallbacks:[...r.fallbacks,``]}),t[40]=i,t[41]=r,t[42]=N):N=t[42];let ee;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(ee=(0,Z.jsx)(d,{className:`size-3.5`,strokeWidth:1.75}),t[43]=ee):ee=t[43];let F;t[44]!==o.modelAddFallback||t[45]!==a||t[46]!==N?(F=(0,Z.jsxs)(f,{type:`button`,variant:`secondary`,className:`h-7 gap-1 px-2 text-xs`,disabled:a,onClick:N,children:[ee,o.modelAddFallback]}),t[44]=o.modelAddFallback,t[45]=a,t[46]=N,t[47]=F):F=t[47];let I;t[48]!==M||t[49]!==F?(I=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[M,F]}),t[48]=M,t[49]=F,t[50]=I):I=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]!==p||t[60]!==u||t[61]!==m||t[62]!==i||t[63]!==h||t[64]!==_||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)(y,{value:e,disabled:a,placeholder:o.modelFallbackPlaceholder,searchPlaceholder:s.modelSearchPlaceholder,noMatches:m??s.modelNoMatches,models:l,modelsLoading:u,modelsError:p,settingsFooterLink:h,capabilitiesFilter:c,className:`w-full max-w-none`,contentAlign:`start`,onChange:e=>_(t,e)}),(0,Z.jsx)(f,{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)(x,{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]=p,t[60]=u,t[61]=m,t[62]=i,t[63]=h,t[64]=_,t[65]=r,t[66]=L):L=t[66];let R;t[67]!==I||t[68]!==L?(R=(0,Z.jsxs)(`div`,{className:`grid gap-1.5`,children:[I,L]}),t[67]=I,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 ne;t[83]===o.policyInherit?ne=t[84]:(ne=(0,Z.jsx)(P,{value:``,children:o.policyInherit}),t[83]=o.policyInherit,t[84]=ne);let U;t[85]===o.policyEnabled?U=t[86]:(U=(0,Z.jsx)(P,{value:`true`,children:o.policyEnabled}),t[85]=o.policyEnabled,t[86]=U);let W;t[87]===o.policyDisabled?W=t[88]:(W=(0,Z.jsx)(P,{value:`false`,children:o.policyDisabled}),t[87]=o.policyDisabled,t[88]=W);let G;t[89]!==a||t[90]!==H||t[91]!==ne||t[92]!==U||t[93]!==W||t[94]!==r.autoProviderFallback?(G=(0,Z.jsxs)(te,{value:r.autoProviderFallback,disabled:a,side:`top`,onChange:H,children:[ne,U,W]}),t[89]=a,t[90]=H,t[91]=ne,t[92]=U,t[93]=W,t[94]=r.autoProviderFallback,t[95]=G):G=t[95];let K;t[96]!==o.modelAutoProviderFallbackLabel||t[97]!==G?(K=(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-fg-muted`,children:[o.modelAutoProviderFallbackLabel,G]}),t[96]=o.modelAutoProviderFallbackLabel,t[97]=G,t[98]=K):K=t[98];let re;t[99]!==V||t[100]!==K?(re=(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[V,K]}),t[99]=V,t[100]=K,t[101]=re):re=t[101];let ie;t[102]!==j||t[103]!==R||t[104]!==re?(ie=(0,Z.jsxs)(`div`,{className:`grid gap-3 border-t border-edge-subtle p-3 dark:border-edge`,children:[j,R,re]}),t[102]=j,t[103]=R,t[104]=re,t[105]=ie):ie=t[105];let ae;return t[106]!==ie||t[107]!==w?(ae=(0,Z.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/70 shadow-surface`,children:[w,ie]}),t[106]=ie,t[107]=w,t[108]=ae):ae=t[108],ae}export{et 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-DP6tPKk-.js";import{l as c,n as l}from"./locale-store-CTwSy7yW.js";import{i as u}from"./vendor-swr-BIWyz7Rc.js";import{Ac as d,As as f,Bo as p,Cs as m,Dc as h,Eu as g,Go as _,Ho as v,It as y,Kr as b,Ks as x,Ns as S,Nu as C,Ps as w,Ul as T,Uo as E,Vo as D,Wo as O,Zl as k,_u as A,as as j,cc as M,hl as N,is as P,ju as ee,ls as F,ns as te,tl as I,ts as L,us as R,yc as z,zo as B}from"./index-C0CGebQ1.js";import{n as V,r as H}from"./settings-page-layout-DgFSya2e.js";import{n as ne,r as U}from"./settings-loading-skeleton-Bk58_cr7.js";import{n as W,t as G}from"./settings-form-section-C6ZbNpdy.js";import{a as K,i as re,n as ie,o as ae,r as oe,t as se}from"./capability-presets-api-DE09c0VB.js";import{a as ce,i as le,o as q,s as J,t as Y}from"./typed-models-lib-60Aqo-UJ.js";import{r as X}from"./image-generation-api-05Gg8wsU.js";var ue=n(),de=e(t(),1),Z=r(),fe=[`deep`,`fast`,`cheap`,`code`,`review`];function Q(e){return fe.includes(e)}function pe(e){let{rows:t,onChange:n,disabled:r,defaultRole:i,chat:a,labels:o}=e,s=(0,de.useRef)([]),c=(0,de.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),p=u>=0?t[u]:void 0,m=t.map((e,t)=>({row:e,index:t})).filter(({index:e})=>e!==u),h=(e,r)=>{n(t.map((t,n)=>n===e?{...t,...r}:t))},g=e=>{if(u>=0){h(u,{model:e});return}s.current.unshift(`preset-model-row-${c.current++}`),n([{id:l,model:e,fallbacks:[],description:Q(l)?o.roleDescriptions[l]:``},...t])},_=e=>{let n=t[e];n&&h(e,{fallbacks:[...n.fallbacks??[],``]})},v=(e,n,r)=>{let i=t[e];if(!i)return;let a=[...i.fallbacks??[]];a[n]=r,h(e,{fallbacks:a})},b=(e,n)=>{let r=t[e];r&&h(e,{fallbacks:(r.fallbacks??[]).filter((e,t)=>t!==n)})},S=e=>{s.current.splice(e,1),n(t.filter((t,n)=>n!==e))},C=e=>{if(!e)return;let r=e===`__custom__`?``:e;s.current.push(`preset-model-row-${c.current++}`),n([...t,{id:r,model:``,fallbacks:[],description:Q(r)?o.roleDescriptions[r]:``}])},w=[...fe.filter(e=>e!==l&&!t.some(t=>t.id===e)).map(e=>({value:e,label:o.roleNames[e]})),{value:`__custom__`,label:o.customRole}],T=(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)(f,{type:`button`,variant:`secondary`,className:`h-7 gap-1 px-2 text-xs`,disabled:r,onClick:()=>_(t),children:[(0,Z.jsx)(d,{className:`size-3.5`,"aria-hidden":!0}),o.addFallback]})]}),(e.fallbacks??[]).length>0?(0,Z.jsx)(`div`,{className:`grid gap-1.5`,children:(e.fallbacks??[]).map((e,n)=>(0,Z.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto] gap-2`,children:[(0,Z.jsx)(y,{value:e,disabled:r,placeholder:o.fallbackPlaceholder,searchPlaceholder:a.modelSearchPlaceholder,noMatches:a.modelNoMatches,className:`w-full max-w-none`,contentAlign:`start`,onChange:e=>v(t,n,e)}),(0,Z.jsx)(f,{type:`button`,variant:`secondary`,className:`shrink-0 px-2`,disabled:r,"aria-label":o.removeFallback,onClick:()=>b(t,n),children:(0,Z.jsx)(x,{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=>h(t,{description:e.target.value})})]})]});return(0,Z.jsxs)(`div`,{className:`grid gap-5`,children:[(0,Z.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-base p-4`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:o.defaultTitle}),(0,Z.jsx)(`span`,{className:`rounded-full bg-accent/10 px-2 py-0.5 text-[11px] font-medium text-accent`,children:o.defaultBadge})]}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:o.defaultHint})]}),(0,Z.jsxs)(`span`,{className:`rounded-md bg-surface-panel px-2 py-1 font-mono text-[11px] text-fg-subtle`,children:[o.roleId,`: `,l]})]}),(0,Z.jsxs)(`div`,{className:`mt-4 grid gap-1.5`,children:[(0,Z.jsx)(`span`,{className:`text-xs font-medium text-fg-muted`,children:o.primaryModel}),(0,Z.jsx)(y,{value:p?.model??``,disabled:r,placeholder:a.modelPlaceholder,searchPlaceholder:a.modelSearchPlaceholder,noMatches:a.modelNoMatches,className:`w-full max-w-none`,contentAlign:`start`,onChange:g})]}),p?(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)(A,{className:`size-3.5 transition-transform group-open:rotate-180`,"aria-hidden":!0})]}),(0,Z.jsx)(`div`,{className:`mt-3`,children:T(p,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})]}),m.length>0?(0,Z.jsx)(`div`,{className:`mt-3 grid gap-2`,children:m.map(({row:e,index:t})=>{let n=Q(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=>h(t,{id:e.target.value.toLowerCase()})})]})]}),(0,Z.jsxs)(`label`,{className:`grid min-w-0 gap-1.5 text-xs font-medium text-fg-muted`,children:[o.primaryModel,(0,Z.jsx)(y,{value:e.model,disabled:r,placeholder:a.modelPlaceholder,searchPlaceholder:a.modelSearchPlaceholder,noMatches:a.modelNoMatches,className:`w-full max-w-none`,contentAlign:`start`,onChange:e=>h(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)(A,{className:`size-3.5 transition-transform group-open:rotate-180`,"aria-hidden":!0})]}),(0,Z.jsxs)(`div`,{className:`mt-3`,children:[T(e,t),(0,Z.jsx)(`div`,{className:`mt-3 flex justify-end`,children:(0,Z.jsxs)(f,{type:`button`,variant:`secondary`,disabled:r,onClick:()=>S(t),children:[(0,Z.jsx)(x,{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)(L,{value:``,options:w,placeholder:o.addTaskModel,allowEmpty:!1,disabled:r,triggerClassName:`mt-3 w-fit`,onChange:C})]})]})}function me(e){let t=(0,ue.c)(34),{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]===c.inheritanceTitle?d=t[3]:(d=(0,Z.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:c.inheritanceTitle}),t[2]=c.inheritanceTitle,t[3]=d);let f;t[4]===c.inheritanceHint?f=t[5]:(f=(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:c.inheritanceHint}),t[4]=c.inheritanceHint,t[5]=f);let p;t[6]!==s||t[7]!==n||t[8]!==c.inheritanceEmpty||t[9]!==r||t[10]!==i?(p=i.length>0?(0,Z.jsx)(`div`,{className:`mt-3 grid gap-2 sm:grid-cols-2`,children:i.map(e=>{let t=n.includes(e.id);return(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 rounded-lg bg-surface-panel/70 px-3 py-2.5 shadow-surface`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 shrink-0 rounded border-edge`,checked:t,disabled:s,onChange:()=>r(t?n.filter(t=>t!==e.id):[...n,e.id])}),(0,Z.jsxs)(`span`,{className:`min-w-0`,children:[(0,Z.jsx)(`span`,{className:`block truncate text-sm font-medium text-fg`,children:e.name}),(0,Z.jsx)(`span`,{className:`mt-0.5 block font-mono text-[11px] text-fg-subtle`,children:e.id})]})]},e.id)})}):(0,Z.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:c.inheritanceEmpty}),t[6]=s,t[7]=n,t[8]=c.inheritanceEmpty,t[9]=r,t[10]=i,t[11]=p):p=t[11];let m;t[12]!==d||t[13]!==f||t[14]!==p?(m=(0,Z.jsxs)(`section`,{children:[d,f,p]}),t[12]=d,t[13]=f,t[14]=p,t[15]=m):m=t[15];let h;t[16]===c.jsonTitle?h=t[17]:(h=(0,Z.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:c.jsonTitle}),t[16]=c.jsonTitle,t[17]=h);let g;t[18]===c.jsonHint?g=t[19]:(g=(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:c.jsonHint}),t[18]=c.jsonHint,t[19]=g);let _;t[20]!==s||t[21]!==u||t[22]!==a||t[23]!==c.fieldHints||t[24]!==c.fieldLabels||t[25]!==o?(_=(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[20]=s,t[21]=u,t[22]=a,t[23]=c.fieldHints,t[24]=c.fieldLabels,t[25]=o,t[26]=_):_=t[26];let v;t[27]!==h||t[28]!==g||t[29]!==_?(v=(0,Z.jsxs)(`section`,{children:[h,g,_]}),t[27]=h,t[28]=g,t[29]=_,t[30]=v):v=t[30];let y;return t[31]!==m||t[32]!==v?(y=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[m,v]}),t[31]=m,t[32]=v,t[33]=y):y=t[33],y}function he(e){return e.name||e.directoryId}function ge(e){let t=(0,ue.c)(56),{mode:n,selected:r,catalog:i,loading:a,disabled:s,onModeChange:c,onSelectedChange:l,labels:u}=e,d=n===`allowlist`||n===`denylist`,p;t[0]===i?p=t[1]:(p=i.map(he).filter(Boolean),t[0]=i,t[1]=p);let m=p,h;bb0:{if(n===`inherit`){h=u.inheritSummary;break bb0}if(n===`all`){h=u.allSummary;break bb0}if(n===`off`){h=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],h=i}let _=h,v;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Z.jsx)(g,{className:`size-3.5`,"aria-hidden":!0}),t[5]=v):v=t[5];let y;t[6]===u.overrideSummaryTitle?y=t[7]:(y=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[v,u.overrideSummaryTitle]}),t[6]=u.overrideSummaryTitle,t[7]=y);let b;t[8]===_?b=t[9]:(b=(0,Z.jsx)(`p`,{className:`mt-1 text-sm text-fg`,children:_}),t[8]=_,t[9]=b);let x;t[10]!==y||t[11]!==b?(x=(0,Z.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/70 px-3 py-2 shadow-surface`,children:[y,b]}),t[10]=y,t[11]=b,t[12]=x):x=t[12];let S;t[13]===u.modeLabel?S=t[14]:(S=(0,Z.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:u.modeLabel}),t[13]=u.modeLabel,t[14]=S);let C;t[15]===u.modeInherit?C=t[16]:(C=[`inherit`,u.modeInherit],t[15]=u.modeInherit,t[16]=C);let w;t[17]===u.modeAll?w=t[18]:(w=[`all`,u.modeAll],t[17]=u.modeAll,t[18]=w);let T;t[19]===u.modeAllowlist?T=t[20]:(T=[`allowlist`,u.modeAllowlist],t[19]=u.modeAllowlist,t[20]=T);let E;t[21]===u.modeDenylist?E=t[22]:(E=[`denylist`,u.modeDenylist],t[21]=u.modeDenylist,t[22]=E);let D;t[23]===u.modeOff?D=t[24]:(D=[`off`,u.modeOff],t[23]=u.modeOff,t[24]=D);let O;t[25]!==E||t[26]!==D||t[27]!==C||t[28]!==w||t[29]!==T?(O=[C,w,T,E,D],t[25]=E,t[26]=D,t[27]=C,t[28]=w,t[29]=T,t[30]=O):O=t[30];let k=O,A;t[31]!==s||t[32]!==n||t[33]!==c||t[34]!==k?(A=(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:k.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]=k,t[35]=A):A=t[35];let j;t[36]!==A||t[37]!==S?(j=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[S,A]}),t[36]=A,t[37]=S,t[38]=j):j=t[38];let M;t[39]!==i||t[40]!==m||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?(M=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)(f,{type:`button`,variant:`secondary`,className:q,disabled:s||a||m.length===0,onClick:()=>l(new Set(m)),children:u.quickSelectAll}),(0,Z.jsx)(f,{type:`button`,variant:`secondary`,className:q,disabled:s||a||r.size===0,onClick:()=>l(new Set),children:u.quickClear})]})]}),a?(0,Z.jsx)(U,{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=he(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]=m,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]=M):M=t[51];let N;return t[52]!==j||t[53]!==M||t[54]!==x?(N=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[x,j,M]}),t[52]=j,t[53]=M,t[54]=x,t[55]=N):N=t[55],N}var _e=[`write_file`,`apply_patch`,`exec_command`,`execute_code`],ve=[`exec_command`,`execute_code`,`automation`,`extensions`,`bundle-mcp`,`skill_manage`],ye=[`send_message`,`send_media`,`text_to_speech`,`create_share`],be=[`read_file`,`list_dir`,`grep`,`find`,`web_search`,`web_fetch`,`web_extract`],xe=[..._e,...ye],Se=[`read_file`,`write_file`,`apply_patch`,`list_dir`,`grep`,`find`,`web_search`,`web_fetch`],Ce=[`send_message`,`send_media`];function we(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 Te(e){let t=(0,ue.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,p;t[2]!==d||t[3]!==r?(p=Object.entries(r).filter(e=>{let[t]=e;return d.has(t)}).toSorted(Ee),t[2]=d,t[3]=r,t[4]=p):p=t[4];let m=p,h;if(t[5]!==d||t[6]!==n){h=[];for(let e of K){let t=e.toolIds.filter(e=>d.has(e));t.length>0&&h.push({key:e.key,ids:[...t]})}let e;t[8]===n?e=t[9]:(e=ae(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),h.push(e)}t[5]=d,t[6]=n,t[7]=h}else h=t[7];let g=h,_;t[12]!==i||t[13]!==r?(_=(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]=_):_=t[14];let v=_,y;t[15]!==i||t[16]!==r?(y=(e,t)=>{let n=r[e];n&&i({...r,[e]:t(n)})},t[15]=i,t[16]=r,t[17]=y):y=t[17];let b=y,x;t[18]!==d||t[19]!==i?(x=e=>{i(we(d,e))},t[18]=d,t[19]=i,t[20]=x):x=t[20];let S=x;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 C;t[23]===l.quickActionsLabel?C=t[24]:(C=(0,Z.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:l.quickActionsLabel}),t[23]=l.quickActionsLabel,t[24]=C);let w;t[25]===i?w=t[26]:(w=()=>i({}),t[25]=i,t[26]=w);let T;t[27]!==a||t[28]!==l.quickClearOverrides||t[29]!==w?(T=(0,Z.jsx)(f,{type:`button`,variant:`secondary`,className:q,disabled:a,onClick:w,children:l.quickClearOverrides}),t[27]=a,t[28]=l.quickClearOverrides,t[29]=w,t[30]=T):T=t[30];let E;t[31]===S?E=t[32]:(E=()=>S([[_e,`deny`]]),t[31]=S,t[32]=E);let D;t[33]!==a||t[34]!==l.quickReadOnlyWorkspace||t[35]!==E?(D=(0,Z.jsx)(f,{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]===S?O=t[38]:(O=()=>S([[ve,`deny`]]),t[37]=S,t[38]=O);let k;t[39]!==a||t[40]!==l.quickHighRiskOff||t[41]!==O?(k=(0,Z.jsx)(f,{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]===S?A=t[44]:(A=()=>S([[ye,`deny`]]),t[43]=S,t[44]=A);let j;t[45]!==a||t[46]!==l.quickNoOutbound||t[47]!==A?(j=(0,Z.jsx)(f,{type:`button`,variant:`secondary`,className:q,disabled:a,onClick:A,children:l.quickNoOutbound}),t[45]=a,t[46]=l.quickNoOutbound,t[47]=A,t[48]=j):j=t[48];let M;t[49]===S?M=t[50]:(M=()=>S([[be,`allow`],[xe,`deny`]]),t[49]=S,t[50]=M);let N;t[51]!==a||t[52]!==l.quickResearchMode||t[53]!==M?(N=(0,Z.jsx)(f,{type:`button`,variant:`secondary`,className:q,disabled:a,onClick:M,children:l.quickResearchMode}),t[51]=a,t[52]=l.quickResearchMode,t[53]=M,t[54]=N):N=t[54];let ee;t[55]===S?ee=t[56]:(ee=()=>S([[Se,`allow`],[Ce,`deny`]]),t[55]=S,t[56]=ee);let F;t[57]!==a||t[58]!==l.quickCodingMode||t[59]!==ee?(F=(0,Z.jsx)(f,{type:`button`,variant:`secondary`,className:q,disabled:a,onClick:ee,children:l.quickCodingMode}),t[57]=a,t[58]=l.quickCodingMode,t[59]=ee,t[60]=F):F=t[60];let I;t[61]!==k||t[62]!==j||t[63]!==N||t[64]!==F||t[65]!==T||t[66]!==D?(I=(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[T,D,k,j,N,F]}),t[61]=k,t[62]=j,t[63]=N,t[64]=F,t[65]=T,t[66]=D,t[67]=I):I=t[67];let L;t[68]!==I||t[69]!==C?(L=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[C,I]}),t[68]=I,t[69]=C,t[70]=L):L=t[70];let R;t[71]===l.overrideSummaryTitle?R=t[72]:(R=(0,Z.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:l.overrideSummaryTitle}),t[71]=l.overrideSummaryTitle,t[72]=R);let z;t[73]!==l.modeAllow||t[74]!==l.modeConfirm||t[75]!==l.modeDeny||t[76]!==l.noOverrides||t[77]!==m?(z=m.length>0?(0,Z.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:m.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]=m,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]!==g||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]!==v||t[98]!==r||t[99]!==b?(V=(0,Z.jsx)(`div`,{className:`flex flex-col gap-5`,children:g.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:()=>v(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)(te,{value:n.scope??``,disabled:a,onChange:t=>b(e,e=>{let n=t.target.value;if(!n){let{scope:t,...n}=e;return n}return{...e,scope:n}}),children:[(0,Z.jsx)(P,{value:``,children:l.scopeInherit}),(0,Z.jsx)(P,{value:`readonly`,children:l.scopeReadonly}),(0,Z.jsx)(P,{value:`workspace`,children:l.scopeWorkspace}),(0,Z.jsx)(P,{value:`unrestricted`,children:l.scopeUnrestricted})]})]}),(0,Z.jsx)(Oe,{label:l.maxCallsLabel,value:n.limits?.maxCallsPerTurn,disabled:a,onChange:t=>b(e,e=>De(e,`maxCallsPerTurn`,t))}),(0,Z.jsx)(Oe,{label:l.timeoutLabel,value:n.limits?.timeoutMs,disabled:a,onChange:t=>b(e,e=>De(e,`timeoutMs`,t))})]}):null]},e)})})]},t)})}),t[82]=a,t[83]=c,t[84]=s,t[85]=g,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]=v,t[98]=r,t[99]=b,t[100]=V):V=t[100];let H;return t[101]!==L||t[102]!==B||t[103]!==V?(H=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[L,B,V]}),t[101]=L,t[102]=B,t[103]=V,t[104]=H):H=t[104],H}function Ee(e,t){let[n]=e,[r]=t;return n.localeCompare(r)}function De(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 Oe(e){let t=(0,ue.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 ke=[`blank`,`safe-coder`,`read-only`,`low-cost`],Ae=[{id:`overview`,icon:k},{id:`models`,icon:N},{id:`tools`,icon:w},{id:`skills`,icon:h},{id:`advanced`,icon:M},{id:`impact`,icon:T}];function je(e){return le(Object.entries(e?.models?.roles??{}).map(([e,t])=>({id:e,model:t.model,fallbacks:t.fallbacks??[],description:t.description})))}function $(e){return structuredClone(e?.tools?.builtin??{})}function Me(e){let t=e?.skills;if(!t)return new Set;let n=t.mode===`denylist`?t.deny:t.allow;return new Set(n??[])}function Ne(){return{primary:``,fallbacks:[],timeoutMs:``,autoProviderFallback:``}}function Pe(e){return{primary:e?.primary??``,fallbacks:[...e?.fallbacks??[]],timeoutMs:e?.timeoutMs?String(e.timeoutMs):``,autoProviderFallback:e?.autoProviderFallback===void 0?``:e.autoProviderFallback?`true`:`false`}}function Fe(){return{imageModel:Ne(),imageGenerationModel:Ne(),allowFallbacks:``,maxCostTier:``}}function Ie(e){return{imageModel:Pe(e?.models?.imageModel),imageGenerationModel:Pe(e?.models?.imageGenerationModel),allowFallbacks:e?.models?.policy?.allowFallbacks===void 0?``:e.models.policy.allowFallbacks?`true`:`false`,maxCostTier:e?.models?.policy?.maxCostTier??``}}function Le(e){return e===void 0?``:JSON.stringify(e,null,2)}function Re(){return{mcp:``,workflows:``,boundaries:``,runtime:``,locks:``}}function ze(e){return{mcp:Le(e?.tools?.mcp),workflows:Le(e?.workflows),boundaries:Le(e?.boundaries),runtime:Le(e?.runtime),locks:Le(e?.locks)}}function Be(e){return{id:e?.id??``,name:e?.name??``,description:e?.description??``,modelRows:je(e),modelAdvanced:Ie(e),toolPolicies:$(e),skillMode:e?.skills?.mode??`inherit`,skillPick:Me(e),extendsIds:[...e?.extends??[]],jsonFields:ze(e)}}function Ve(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 He(e,t){let n=Y(e.modelRows),r=Ve(e.modelAdvanced.imageModel),i=Ve(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 Ue(e){return e.trim()?JSON.parse(e):void 0}function We(e){if(!e.trim())return``;try{return JSON.stringify(JSON.parse(e))}catch{return`!invalid:${e}`}}function Ge(e){let t=Object.fromEntries(Object.entries(e.toolPolicies).toSorted(([e],[t])=>e.localeCompare(t))),n=Ue(e.jsonFields.mcp);return Object.keys(t).length>0||n?{builtin:t,...n?{mcp:n}:{}}:null}function Ke(e){return Object.fromEntries(Object.entries(e??{}).toSorted(([e],[t])=>e.localeCompare(t)))}function qe(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 Je(e,t){return{id:e.id.trim(),name:e.name.trim(),description:e.description.trim(),models:He(e,t),tools:{builtin:Ke(e.toolPolicies),mcp:We(e.jsonFields.mcp)},skills:qe(e),extends:[...e.extendsIds].toSorted(),workflows:We(e.jsonFields.workflows),boundaries:We(e.jsonFields.boundaries),runtime:We(e.jsonFields.runtime),locks:We(e.jsonFields.locks)}}function Ye(e){return e?{id:e.id,name:e.name,description:e.description??``,models:e.models??null,tools:{builtin:Ke(e.tools?.builtin),mcp:We(Le(e.tools?.mcp))},skills:e.skills??null,extends:[...e.extends??[]].toSorted(),workflows:We(Le(e.workflows)),boundaries:We(Le(e.boundaries)),runtime:We(Le(e.runtime)),locks:We(Le(e.locks))}:null}function Xe(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 Ze(){return{modelAdvanced:Fe(),extendsIds:[],jsonFields:Re()}}function Qe(e,t){return{extends:[...e.extendsIds],models:He(e,t)??void 0,tools:Ge(e)??void 0,skills:qe(e)??void 0,workflows:Ue(e.jsonFields.workflows),boundaries:Ue(e.jsonFields.boundaries),runtime:Ue(e.jsonFields.runtime),locks:Ue(e.jsonFields.locks)}}function $e(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`]),...Ze()}: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,...Ze()}: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,...Ze()}:{id:``,name:``,description:``,modelRows:[],toolPolicies:{},skillMode:`inherit`,skillPick:new Set,...Ze()}}function et(){let e=s(l(e=>e.language)),t=e.capabilityPresetsSettings,n=(0,Z.jsx)(f,{asChild:!0,type:`button`,variant:`secondary`,children:(0,Z.jsxs)(a,{to:`/agents`,children:[t.manageAgents,(0,Z.jsx)(ee,{className:`size-4`,"aria-hidden":!0})]})}),r=!!c(e=>e.token),{data:g,error:y,isLoading:A,mutate:P}=u(r?`settings-capability-presets`:null,oe,{revalidateOnFocus:!1}),{data:te=[],isLoading:L}=u(r?`settings-capability-presets-skills-catalog`:null,b,{revalidateOnFocus:!1}),[U,K]=i(),[ae,le]=(0,de.useState)(``),[q,J]=(0,de.useState)(`overview`),[Y,X]=(0,de.useState)(()=>$e(`blank`,t)),[ue,fe]=(0,de.useState)(null),[Q,he]=(0,de.useState)(!1),[_e,ve]=(0,de.useState)(null),[ye,be]=(0,de.useState)(!1),[xe,Se]=(0,de.useState)(null),[Ce,we]=(0,de.useState)(null),Ee=g?.presets??[],De=g?.defaultPresetId??`default`,Oe=Ee.find(e=>e.id===De)??null,je=Ee.filter(e=>e.id!==De),$=(0,de.useMemo)(()=>Ee.find(e=>e.id===ae)??Ee[0]??null,[Ee,ae]),Me=!$||Y.id.trim()!==$.id,Ne=!!($&&$.id===De),Pe=JSON.stringify(Je(Y,$))!==JSON.stringify(Ye($)),Fe=Je(Y,$),Ie=Ye($),Le=[Fe.id!==Ie?.id||Fe.name!==Ie?.name||Fe.description!==Ie?.description?t.tabs.overview:``,JSON.stringify(Fe.models)===JSON.stringify(Ie?.models)?``:t.tabs.models,JSON.stringify(Fe.tools)===JSON.stringify(Ie?.tools)?``:t.tabs.tools,JSON.stringify(Fe.skills)===JSON.stringify(Ie?.skills)?``:t.tabs.skills,JSON.stringify({extends:Fe.extends,workflows:Fe.workflows,boundaries:Fe.boundaries,runtime:Fe.runtime,locks:Fe.locks})===JSON.stringify({extends:Ie?.extends,workflows:Ie?.workflows,boundaries:Ie?.boundaries,runtime:Ie?.runtime,locks:Ie?.locks})?``:t.tabs.advanced].filter(Boolean),Re=_e??(y instanceof Error?y.message:null),ze=U.get(`action`)===`new`||!!U.get(`preset`),Ve=U.get(`action`)===`new`&&ue===null,He=Me?t.newPreset:$?.name??t.editorTitle,We=t=>e.agentsSettings.toolsDisableGroups[t],Ge=t=>t in e.agentsSettings.toolDescriptions?e.agentsSettings.toolDescriptions[t]:``;(0,de.useEffect)(()=>{if(!g||Q)return;if(U.get(`action`)===`new`){le(``),X($e(`blank`,t)),J(`overview`);return}let e=U.get(`preset`)?.trim(),n=e?g.presets.find(t=>t.id===e):null;if(n){le(n.id),X(Be(n)),J(U.get(`tab`)??`overview`);return}$&&(le($.id),X(e=>e.id===$.id?e:Be($)))},[Q,g,U,$]);function Ke(e){fe(null),le(e.id),X(Be(e)),K({preset:e.id},{replace:!0}),J(`overview`)}function qe(){fe(null),le(``),X($e(`blank`,t)),ve(null),K({action:`new`},{replace:!0}),J(`overview`)}function Ze(e){fe(e),X($e(e,t)),ve(null),J(`overview`)}function et(){if(ue){let e=$e(ue,t);if(JSON.stringify(Je(Y,null))!==JSON.stringify(Je(e,null))&&!window.confirm(t.changeTemplateConfirm))return}fe(null),ve(null)}function rt(){!Ve&&Pe&&!window.confirm(t.discardConfirm)||(be(!1),Se(null),K({},{replace:!0}),fe(null),ve(null),X(Be($)),J(`overview`))}async function it(){let e=ce(Y.modelRows,{invalidId:t.invalidModelRoleId,duplicateId:t.duplicateModelRoleId,invalidModel:t.invalidModelRef});if(e){ve(e),J(`models`);return}for(let e of[Y.modelAdvanced.imageModel,Y.modelAdvanced.imageGenerationModel]){if([e.primary,...e.fallbacks].map(e=>e.trim()).filter(Boolean).some(e=>!/^[^/\s]+\/.+/.test(e))){ve(t.invalidModelRef),J(`models`);return}if(e.timeoutMs.trim()&&(!Number.isInteger(Number(e.timeoutMs))||Number(e.timeoutMs)<=0)){ve(t.advancedPositiveIntegerError),J(`models`);return}}for(let e of Object.values(Y.toolPolicies))if([e.limits?.maxCallsPerTurn,e.limits?.timeoutMs].filter(e=>e!==void 0).some(e=>!Number.isInteger(e)||e<=0)){ve(t.advancedPositiveIntegerError),J(`tools`);return}for(let e of Object.keys(Y.jsonFields))try{Ue(Y.jsonFields[e])}catch{ve(t.advancedJsonError.replace(`{{field}}`,t.advancedFieldLabels[e])),J(`advanced`);return}he(!0),ve(null);try{let e=Qe(Y,$);if(Me){let t=await se({id:Y.id.trim(),name:Y.name.trim(),...Y.description.trim()?{description:Y.description.trim()}:{},...e});await P(t.presets,{revalidate:!1}),le(t.presetId),fe(null),K({preset:t.presetId},{replace:!0})}else $&&await P(await re($.id,{name:Y.name.trim(),description:Y.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){ve(e instanceof Error?e.message:t.saveError)}finally{he(!1)}}async function at(){if($){he(!0),ve(null),Se(null);try{await P(await ie($.id),{revalidate:!1}),be(!1),le(``),fe(null),X($e(`blank`,t)),J(`overview`),K({},{replace:!0})}catch(e){Se(e instanceof Error?e.message:t.deleteError)}finally{he(!1)}}}return r?(0,Z.jsxs)(H,{gap:`gap-5`,className:`pb-24`,children:[(0,Z.jsx)(V,{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)(f,{type:`button`,onClick:qe,disabled:Q,children:[(0,Z.jsx)(d,{className:`size-4`,"aria-hidden":!0}),t.newPreset]})]})}),Re?(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:Re}):null,A?(0,Z.jsx)(ne,{sections:2}):(0,Z.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[Oe?(0,Z.jsxs)(G,{children:[(0,Z.jsx)(W,{icon:N,title:t.globalDefaultsTitle,subtitle:t.globalDefaultsHint}),(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>Ke(Oe),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:Oe.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:Oe.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})]}),Oe.description?(0,Z.jsx)(`p`,{className:`mt-3 line-clamp-2 text-xs leading-relaxed text-fg-muted`,children:Oe.description}):null,(0,Z.jsx)(`div`,{className:`mt-3 text-xs text-fg-subtle`,children:Xe(Oe,t)})]})]}):null,(0,Z.jsxs)(G,{children:[(0,Z.jsx)(W,{icon:N,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)(f,{type:`button`,variant:`secondary`,onClick:qe,disabled:Q,children:[(0,Z.jsx)(d,{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:()=>Ke(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:Xe(e,t)})]},e.id))})]})]}),(0,Z.jsx)(B,{open:ze,onOpenChange:e=>{e||rt()},children:(0,Z.jsxs)(O,{children:[(0,Z.jsx)(E,{className:o(`xopc-dialog-overlay fixed inset-0 bg-scrim`,R)}),(0,Z.jsx)(D,{ref:we,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`,F),onOpenAutoFocus:e=>e.preventDefault(),children:(0,Z.jsxs)(j,{layer:`modal`,portalContainer:Ce,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:[!Ve&&Me&&ue?(0,Z.jsx)(`button`,{type:`button`,className:o(m,`shrink-0 p-1.5 hover:bg-surface-base`),onClick:et,"aria-label":t.changeTemplate,title:t.changeTemplate,children:(0,Z.jsx)(C,{className:`size-4`,"aria-hidden":!0})}):null,(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(_,{className:`truncate text-base font-semibold text-fg`,children:He}),(0,Z.jsx)(v,{className:`mt-0.5 truncate text-xs text-fg-muted`,children:Ve?t.templatePickerSubtitle:Me&&ue?`${t.editorHint} · ${t.basedOnTemplate.replace(`{{template}}`,t.starters[ue].title)}`:Me?t.editorHint:Y.id})]})]}),(0,Z.jsx)(p,{asChild:!0,children:(0,Z.jsx)(`button`,{type:`button`,className:o(m,`shrink-0 p-1.5 hover:bg-surface-base`),"aria-label":t.closeDialog,children:(0,Z.jsx)(S,{className:`size-4`,"aria-hidden":!0})})})]}),Ve?(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:ke.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:()=>Ze(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)(f,{type:`button`,variant:`secondary`,onClick:rt,children:t.cancel})})]}):(0,Z.jsxs)(Z.Fragment,{children:[Re?(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:Re}):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:Ae.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`,q===e?`bg-surface-panel text-fg shadow-surface`:`text-fg-muted hover:bg-surface-hover hover:text-fg`),onClick:()=>J(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:[q===`overview`?(0,Z.jsxs)(G,{children:[(0,Z.jsx)(W,{icon:k,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:Y.id,disabled:Q||!Me,onChange:e=>X(t=>({...t,id:e.target.value.toLowerCase()})),placeholder:`safe-coder`})]}),!Me&&$?(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:Y.name,disabled:Q,onChange:e=>X(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:Y.description,disabled:Q,onChange:e=>X(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)(tt,{icon:N,label:t.modelsTitle,value:String(Y.modelRows.length)}),(0,Z.jsx)(tt,{icon:w,label:t.toolsTitle,value:String(Object.keys(Y.toolPolicies).length)}),(0,Z.jsx)(tt,{icon:h,label:t.skillsTitle,value:t.skillModeLabels[Y.skillMode]})]})]}):null,q===`models`?(0,Z.jsxs)(G,{children:[(0,Z.jsx)(W,{icon:N,title:t.modelsTitle,subtitle:t.modelsHint}),(0,Z.jsx)(pe,{rows:Y.modelRows,onChange:e=>X(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)(nt,{value:Y.modelAdvanced,onChange:e=>X(t=>({...t,modelAdvanced:e})),disabled:Q,cp:t,chat:e.chat})]}):null,q===`tools`?(0,Z.jsxs)(G,{children:[(0,Z.jsx)(W,{icon:w,title:t.toolsTitle,subtitle:t.toolsHint}),(0,Z.jsx)(Te,{builtinToolIds:g?.builtinToolIds??[],toolPolicies:Y.toolPolicies,onChange:e=>X(t=>({...t,toolPolicies:e})),disabled:Q,getToolDescription:Ge,getGroupTitle:We,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,q===`skills`?(0,Z.jsxs)(G,{children:[(0,Z.jsx)(W,{icon:h,title:t.skillsTitle,subtitle:t.skillsHint}),(0,Z.jsx)(ge,{mode:Y.skillMode,selected:Y.skillPick,catalog:te,loading:L,disabled:Q,onModeChange:e=>X(t=>({...t,skillMode:e})),onSelectedChange:e=>X(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,q===`advanced`?(0,Z.jsxs)(G,{children:[(0,Z.jsx)(W,{icon:M,title:t.advancedTitle,subtitle:t.advancedHint}),(0,Z.jsx)(me,{extendsIds:Y.extendsIds,onExtendsChange:e=>X(t=>({...t,extendsIds:e})),presetOptions:Ee.filter(e=>e.id!==$?.id&&e.id!==De),jsonFields:Y.jsonFields,onJsonFieldsChange:e=>X(t=>({...t,jsonFields:e})),disabled:Q,labels:{inheritanceTitle:t.advancedInheritanceTitle,inheritanceHint:t.advancedInheritanceHint,inheritanceEmpty:t.advancedInheritanceEmpty,jsonTitle:t.advancedJsonTitle,jsonHint:t.advancedJsonHint,fieldLabels:t.advancedFieldLabels,fieldHints:t.advancedFieldHints}})]}):null,q===`impact`?(0,Z.jsxs)(G,{children:[(0,Z.jsx)(W,{icon:T,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:Le.length>0?t.changePreviewSections.replace(`{{sections}}`,Le.join(`、`)):t.changePreviewEmpty})]}),$?.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:Pe?t.unsavedTitle:t.noUnsavedTitle}),(0,Z.jsx)(`div`,{className:`text-xs text-fg-muted`,children:Pe?($?.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:[Pe?(0,Z.jsx)(f,{type:`button`,variant:`secondary`,disabled:Q,onClick:()=>X(Be($)),children:t.discard}):null,$&&!Ne?(0,Z.jsxs)(f,{type:`button`,variant:`secondary`,disabled:Q,onClick:()=>{Se(null),be(!0)},children:[(0,Z.jsx)(x,{className:`size-4`,"aria-hidden":!0}),t.delete]}):null,(0,Z.jsxs)(f,{type:`button`,disabled:Q||!Y.id.trim()||!Y.name.trim()||!Pe,onClick:()=>void it(),children:[(0,Z.jsx)(z,{className:`size-4`,"aria-hidden":!0}),t.savePreset]})]})]})]})]})})]})}),(0,Z.jsx)(B,{open:ye,onOpenChange:e=>{Q||(be(e),e||Se(null))},children:(0,Z.jsxs)(O,{children:[(0,Z.jsx)(E,{className:o(`xopc-dialog-overlay fixed inset-0 bg-scrim`,R)}),(0,Z.jsxs)(D,{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`,F),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)(_,{className:`text-base font-semibold text-fg`,children:t.deleteDialogTitle}),(0,Z.jsx)(v,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:$?t.deleteConfirm.replace(`{{name}}`,$.name):t.deleteConfirmFallback})]}),xe?(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:xe}):null,(0,Z.jsxs)(`div`,{className:`flex justify-end gap-2 px-4 py-3`,children:[(0,Z.jsx)(f,{type:`button`,variant:`secondary`,disabled:Q,onClick:()=>be(!1),children:t.cancel}),(0,Z.jsxs)(f,{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 at(),children:[Q?(0,Z.jsx)(I,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(x,{className:`size-4`,"aria-hidden":!0}),Q?t.deleting:t.delete]})]})]})]})})]}):(0,Z.jsxs)(H,{gap:`gap-3`,children:[(0,Z.jsx)(V,{title:t.title,actions:n}),(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.needToken})]})}function tt(e){let t=(0,ue.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 nt(e){let t=(0,ue.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`,X,s),f;t[1]===c?f=t[2]:(f=(c??[]).filter(at).flatMap(it),t[1]=c,t[2]=f);let p=f,m;t[3]===p?m=t[4]:(m=new Set(p.map(rt)),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,de.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 w;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,Z.jsx)(A,{className:`size-4 shrink-0 text-fg-subtle transition-transform group-open:rotate-180`,"aria-hidden":!0}),t[26]=w):w=t[26];let T;t[27]===C?T=t[28]:(T=(0,Z.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-3 p-4`,children:[C,w]}),t[27]=C,t[28]=T);let E;t[29]===y?E=t[30]:(E=e=>y(`imageModel`,e),t[29]=y,t[30]=E);let D;t[31]!==o||t[32]!==a||t[33]!==i||t[34]!==E||t[35]!==n.imageModel?(D=(0,Z.jsx)(ot,{title:a.imageUnderstandingTitle,value:n.imageModel,onChange:E,disabled:i,cp:a,chat:o,capabilitiesFilter:`vision`}),t[31]=o,t[32]=a,t[33]=i,t[34]=E,t[35]=n.imageModel,t[36]=D):D=t[36];let O;t[37]===y?O=t[38]:(O=e=>y(`imageGenerationModel`,e),t[37]=y,t[38]=O);let k;t[39]===a.modelImageSettingsLink?k=t[40]:(k={label:a.modelImageSettingsLink,path:`/settings/capabilities/image`},t[39]=a.modelImageSettingsLink,t[40]=k);let j;t[41]!==o||t[42]!==a||t[43]!==i||t[44]!==p||t[45]!==d||t[46]!==l||t[47]!==O||t[48]!==k||t[49]!==n.imageGenerationModel?(j=(0,Z.jsx)(ot,{title:a.imageGenerationTitle,value:n.imageGenerationModel,onChange:O,disabled:i,cp:a,chat:o,models:p,modelsLoading:l,modelsError:d,noMatches:a.modelNoConfiguredImageModels,settingsFooterLink:k}),t[41]=o,t[42]=a,t[43]=i,t[44]=p,t[45]=d,t[46]=l,t[47]=O,t[48]=k,t[49]=n.imageGenerationModel,t[50]=j):j=t[50];let M;t[51]!==D||t[52]!==j?(M=(0,Z.jsxs)(`div`,{className:`grid gap-3 border-t border-edge-subtle p-4 dark:border-edge lg:grid-cols-2`,children:[D,j]}),t[51]=D,t[52]=j,t[53]=M):M=t[53];let N;t[54]!==T||t[55]!==M?(N=(0,Z.jsxs)(`details`,{className:`group rounded-xl border border-edge bg-surface-base`,children:[T,M]}),t[54]=T,t[55]=M,t[56]=N):N=t[56];let ee;t[57]===a.modelAdvancedTitle?ee=t[58]:(ee=(0,Z.jsx)(`h4`,{className:`text-sm font-semibold text-fg`,children:a.modelAdvancedTitle}),t[57]=a.modelAdvancedTitle,t[58]=ee);let F;t[59]===a.modelAdvancedHint?F=t[60]:(F=(0,Z.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:a.modelAdvancedHint}),t[59]=a.modelAdvancedHint,t[60]=F);let I;t[61]!==ee||t[62]!==F?(I=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[ee,F]}),t[61]=ee,t[62]=F,t[63]=I):I=t[63];let L;t[64]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,Z.jsx)(A,{className:`size-4 shrink-0 text-fg-subtle transition-transform group-open:rotate-180`,"aria-hidden":!0}),t[64]=L):L=t[64];let R;t[65]===I?R=t[66]:(R=(0,Z.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center justify-between gap-3 p-4`,children:[I,L]}),t[65]=I,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)(P,{value:``,children:a.policyInherit}),t[72]=a.policyInherit,t[73]=V);let H;t[74]===a.policyEnabled?H=t[75]:(H=(0,Z.jsx)(P,{value:`true`,children:a.policyEnabled}),t[74]=a.policyEnabled,t[75]=H);let ne;t[76]===a.policyDisabled?ne=t[77]:(ne=(0,Z.jsx)(P,{value:`false`,children:a.policyDisabled}),t[76]=a.policyDisabled,t[77]=ne);let U;t[78]!==i||t[79]!==B||t[80]!==V||t[81]!==H||t[82]!==ne||t[83]!==n.allowFallbacks?(U=(0,Z.jsxs)(te,{value:n.allowFallbacks,disabled:i,side:`top`,onChange:B,children:[V,H,ne]}),t[78]=i,t[79]=B,t[80]=V,t[81]=H,t[82]=ne,t[83]=n.allowFallbacks,t[84]=U):U=t[84];let W;t[85]!==z||t[86]!==U?(W=(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[z,U]}),t[85]=z,t[86]=U,t[87]=W):W=t[87];let G;t[88]===a.modelMaxCostTierLabel?G=t[89]:(G=(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:a.modelMaxCostTierLabel}),t[88]=a.modelMaxCostTierLabel,t[89]=G);let K;t[90]!==r||t[91]!==n?(K=e=>r({...n,maxCostTier:e.target.value}),t[90]=r,t[91]=n,t[92]=K):K=t[92];let re;t[93]===a.policyInherit?re=t[94]:(re=(0,Z.jsx)(P,{value:``,children:a.policyInherit}),t[93]=a.policyInherit,t[94]=re);let ie;t[95]===a.costTierLow?ie=t[96]:(ie=(0,Z.jsx)(P,{value:`low`,children:a.costTierLow}),t[95]=a.costTierLow,t[96]=ie);let ae;t[97]===a.costTierMedium?ae=t[98]:(ae=(0,Z.jsx)(P,{value:`medium`,children:a.costTierMedium}),t[97]=a.costTierMedium,t[98]=ae);let oe;t[99]===a.costTierHigh?oe=t[100]:(oe=(0,Z.jsx)(P,{value:`high`,children:a.costTierHigh}),t[99]=a.costTierHigh,t[100]=oe);let se;t[101]!==i||t[102]!==K||t[103]!==re||t[104]!==ie||t[105]!==ae||t[106]!==oe||t[107]!==n.maxCostTier?(se=(0,Z.jsxs)(te,{value:n.maxCostTier,disabled:i,side:`top`,onChange:K,children:[re,ie,ae,oe]}),t[101]=i,t[102]=K,t[103]=re,t[104]=ie,t[105]=ae,t[106]=oe,t[107]=n.maxCostTier,t[108]=se):se=t[108];let ce;t[109]!==G||t[110]!==se?(ce=(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1.5 text-sm`,children:[G,se]}),t[109]=G,t[110]=se,t[111]=ce):ce=t[111];let le;t[112]!==W||t[113]!==ce?(le=(0,Z.jsxs)(`div`,{className:`grid gap-3 border-t border-edge-subtle p-4 dark:border-edge sm:grid-cols-2`,children:[W,ce]}),t[112]=W,t[113]=ce,t[114]=le):le=t[114];let q;t[115]!==R||t[116]!==le?(q=(0,Z.jsxs)(`details`,{className:`group rounded-xl border border-edge bg-surface-base`,children:[R,le]}),t[115]=R,t[116]=le,t[117]=q):q=t[117];let J;return t[118]!==N||t[119]!==q?(J=(0,Z.jsxs)(`div`,{className:`mt-5 grid gap-3 border-t border-edge-subtle pt-5 dark:border-edge`,children:[N,q]}),t[118]=N,t[119]=q,t[120]=J):J=t[120],J}function rt(e){return e.id}function it(e){return e.models.map(t=>({id:`${e.id}/${t}`,name:t,provider:e.label}))}function at(e){return e.configured||e.credentialMode===`none`}function ot(e){let t=(0,ue.c)(109),{title:n,value:r,onChange:i,disabled:a,cp:o,chat:s,capabilitiesFilter:c,models:l,modelsLoading:u,modelsError:p,noMatches:m,settingsFooterLink:h}=e,g;t[0]!==i||t[1]!==r?(g=(e,t)=>{i({...r,fallbacks:r.fallbacks.map((n,r)=>r===e?t:n)})},t[0]=i,t[1]=r,t[2]=g):g=t[2];let _=g,v;t[3]===n?v=t[4]:(v=(0,Z.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n}),t[3]=n,t[4]=v);let b=r.primary||o.modelNotSet,C;t[5]===b?C=t[6]:(C=(0,Z.jsx)(`span`,{className:`max-w-48 truncate font-mono text-xs text-fg-muted`,children:b}),t[5]=b,t[6]=C);let w;t[7]!==v||t[8]!==C?(w=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2 px-3 py-2.5`,children:[v,C]}),t[7]=v,t[8]=C,t[9]=w):w=t[9];let T;t[10]===o.modelToolPrimaryLabel?T=t[11]:(T=(0,Z.jsx)(`div`,{className:`text-xs text-fg-muted`,children:o.modelToolPrimaryLabel}),t[10]=o.modelToolPrimaryLabel,t[11]=T);let E=m??s.modelNoMatches,D;t[12]!==i||t[13]!==r?(D=e=>i({...r,primary:e}),t[12]=i,t[13]=r,t[14]=D):D=t[14];let O;t[15]!==c||t[16]!==s.modelPlaceholder||t[17]!==s.modelSearchPlaceholder||t[18]!==a||t[19]!==l||t[20]!==p||t[21]!==u||t[22]!==h||t[23]!==E||t[24]!==D||t[25]!==r.primary?(O=(0,Z.jsx)(y,{value:r.primary,disabled:a,placeholder:s.modelPlaceholder,searchPlaceholder:s.modelSearchPlaceholder,noMatches:E,models:l,modelsLoading:u,modelsError:p,settingsFooterLink:h,capabilitiesFilter:c,className:`w-full max-w-none`,contentAlign:`start`,onChange:D}),t[15]=c,t[16]=s.modelPlaceholder,t[17]=s.modelSearchPlaceholder,t[18]=a,t[19]=l,t[20]=p,t[21]=u,t[22]=h,t[23]=E,t[24]=D,t[25]=r.primary,t[26]=O):O=t[26];let k;t[27]!==o.modelClearSelection||t[28]!==a||t[29]!==i||t[30]!==r?(k=r.primary?(0,Z.jsx)(f,{type:`button`,variant:`secondary`,className:`shrink-0 px-2`,disabled:a,"aria-label":o.modelClearSelection,onClick:()=>i({...r,primary:``}),children:(0,Z.jsx)(S,{className:`size-4`,strokeWidth:1.75})}):null,t[27]=o.modelClearSelection,t[28]=a,t[29]=i,t[30]=r,t[31]=k):k=t[31];let A;t[32]!==O||t[33]!==k?(A=(0,Z.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto] gap-2`,children:[O,k]}),t[32]=O,t[33]=k,t[34]=A):A=t[34];let j;t[35]!==A||t[36]!==T?(j=(0,Z.jsxs)(`div`,{className:`grid gap-1`,children:[T,A]}),t[35]=A,t[36]=T,t[37]=j):j=t[37];let M;t[38]===o.modelToolFallbacksLabel?M=t[39]:(M=(0,Z.jsx)(`div`,{className:`text-xs text-fg-muted`,children:o.modelToolFallbacksLabel}),t[38]=o.modelToolFallbacksLabel,t[39]=M);let N;t[40]!==i||t[41]!==r?(N=()=>i({...r,fallbacks:[...r.fallbacks,``]}),t[40]=i,t[41]=r,t[42]=N):N=t[42];let ee;t[43]===Symbol.for(`react.memo_cache_sentinel`)?(ee=(0,Z.jsx)(d,{className:`size-3.5`,strokeWidth:1.75}),t[43]=ee):ee=t[43];let F;t[44]!==o.modelAddFallback||t[45]!==a||t[46]!==N?(F=(0,Z.jsxs)(f,{type:`button`,variant:`secondary`,className:`h-7 gap-1 px-2 text-xs`,disabled:a,onClick:N,children:[ee,o.modelAddFallback]}),t[44]=o.modelAddFallback,t[45]=a,t[46]=N,t[47]=F):F=t[47];let I;t[48]!==M||t[49]!==F?(I=(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[M,F]}),t[48]=M,t[49]=F,t[50]=I):I=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]!==p||t[60]!==u||t[61]!==m||t[62]!==i||t[63]!==h||t[64]!==_||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)(y,{value:e,disabled:a,placeholder:o.modelFallbackPlaceholder,searchPlaceholder:s.modelSearchPlaceholder,noMatches:m??s.modelNoMatches,models:l,modelsLoading:u,modelsError:p,settingsFooterLink:h,capabilitiesFilter:c,className:`w-full max-w-none`,contentAlign:`start`,onChange:e=>_(t,e)}),(0,Z.jsx)(f,{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)(x,{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]=p,t[60]=u,t[61]=m,t[62]=i,t[63]=h,t[64]=_,t[65]=r,t[66]=L):L=t[66];let R;t[67]!==I||t[68]!==L?(R=(0,Z.jsxs)(`div`,{className:`grid gap-1.5`,children:[I,L]}),t[67]=I,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 ne;t[83]===o.policyInherit?ne=t[84]:(ne=(0,Z.jsx)(P,{value:``,children:o.policyInherit}),t[83]=o.policyInherit,t[84]=ne);let U;t[85]===o.policyEnabled?U=t[86]:(U=(0,Z.jsx)(P,{value:`true`,children:o.policyEnabled}),t[85]=o.policyEnabled,t[86]=U);let W;t[87]===o.policyDisabled?W=t[88]:(W=(0,Z.jsx)(P,{value:`false`,children:o.policyDisabled}),t[87]=o.policyDisabled,t[88]=W);let G;t[89]!==a||t[90]!==H||t[91]!==ne||t[92]!==U||t[93]!==W||t[94]!==r.autoProviderFallback?(G=(0,Z.jsxs)(te,{value:r.autoProviderFallback,disabled:a,side:`top`,onChange:H,children:[ne,U,W]}),t[89]=a,t[90]=H,t[91]=ne,t[92]=U,t[93]=W,t[94]=r.autoProviderFallback,t[95]=G):G=t[95];let K;t[96]!==o.modelAutoProviderFallbackLabel||t[97]!==G?(K=(0,Z.jsxs)(`label`,{className:`flex flex-col gap-1 text-xs text-fg-muted`,children:[o.modelAutoProviderFallbackLabel,G]}),t[96]=o.modelAutoProviderFallbackLabel,t[97]=G,t[98]=K):K=t[98];let re;t[99]!==V||t[100]!==K?(re=(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[V,K]}),t[99]=V,t[100]=K,t[101]=re):re=t[101];let ie;t[102]!==j||t[103]!==R||t[104]!==re?(ie=(0,Z.jsxs)(`div`,{className:`grid gap-3 border-t border-edge-subtle p-3 dark:border-edge`,children:[j,R,re]}),t[102]=j,t[103]=R,t[104]=re,t[105]=ie):ie=t[105];let ae;return t[106]!==ie||t[107]!==w?(ae=(0,Z.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/70 shadow-surface`,children:[w,ie]}),t[106]=ie,t[107]=w,t[108]=ae):ae=t[108],ae}export{et as CapabilityPresetsSettingsPanel};
@@ -1 +1 @@
1
- import{r as e,s as t}from"./locale-store-DVGhFXRz.js";function n(e,t){let n=Date.now()-new Date(e).getTime();return n<6e4?t.justNow:n<36e5?t.minutesAgo.replace(`{{count}}`,String(Math.floor(n/6e4))):n<864e5?t.hoursAgo.replace(`{{count}}`,String(Math.floor(n/36e5))):n<6048e5?t.daysAgo.replace(`{{count}}`,String(Math.floor(n/864e5))):new Date(e).toLocaleDateString()}function r(e,t){let r=n(e.lastActive,t);return e.channel===`telegram`&&e.peerId?`${e.accountId??`default`} · ${e.peerKind??``} · ${e.peerId} · ${r}`:`${e.channel}: ${e.chatId} · ${r}`}async function i(){return(await t(e(`/api/channels/status`))).payload?.channels||[]}async function a(n){return(await t(e(`/api/sessions/chat-ids${n?`?channel=${encodeURIComponent(n)}`:``}`))).payload?.chatIds||[]}export{i as n,a as r,r as t};
1
+ import{r as e,s as t}from"./locale-store-CTwSy7yW.js";function n(e,t){let n=Date.now()-new Date(e).getTime();return n<6e4?t.justNow:n<36e5?t.minutesAgo.replace(`{{count}}`,String(Math.floor(n/6e4))):n<864e5?t.hoursAgo.replace(`{{count}}`,String(Math.floor(n/36e5))):n<6048e5?t.daysAgo.replace(`{{count}}`,String(Math.floor(n/864e5))):new Date(e).toLocaleDateString()}function r(e,t){let r=n(e.lastActive,t);return e.channel===`telegram`&&e.peerId?`${e.accountId??`default`} · ${e.peerKind??``} · ${e.peerId} · ${r}`:`${e.channel}: ${e.chatId} · ${r}`}async function i(){return(await t(e(`/api/channels/status`))).payload?.channels||[]}async function a(n){return(await t(e(`/api/sessions/chat-ids${n?`?channel=${encodeURIComponent(n)}`:``}`))).payload?.chatIds||[]}export{i as n,a as r,r as t};
@@ -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"./circle-alert-BEjgurr2.js";import{t as s}from"./cn-JdwAhgNB.js";import{t as c}from"./messages-r8L6Ur3A.js";import{l,n as u,o as d,r as f,s as p}from"./locale-store-DVGhFXRz.js";import{i as m}from"./vendor-swr-BIWyz7Rc.js";import{$a as h,As as g,Bo as _,Cs as v,Ec as y,Et as b,Go as x,Gs as S,Ho as C,Ns as w,Rr as T,To as E,Uo as D,Vo as O,Wl as k,Wo as A,ai as j,as as M,ii as N,io as P,ls as F,oa as I,pc as L,pu as R,ri as ee,ro as z,tc as B,tl as V,ts as te,us as ne,xc as re,zo as ie}from"./index-C1h0zkNo.js";import{n as ae,r as oe}from"./settings-page-layout-BQTLh-86.js";import{n as se}from"./settings-loading-skeleton-BD4peoAv.js";import{t as ce}from"./schema-form-BjKjp5eZ.js";import{t as le}from"./browser-BLJWD7WI.js";import{n as ue,t as de}from"./channels-status-swr-D3xr2enH.js";import{t as fe}from"./use-channel-catalog-Bndq4y4I.js";var H=e(t(),1),U=n();function pe(e){let t=e.actions??{};for(let e of[`login.start`,`setup.start`]){let n=t[e];if(n?.result===`qr`)return[e,n]}let n=Object.entries(t).find(([,e])=>e.result===`qr`);if(n)return n;let r=e.ui?.card?.primaryAction;if(r&&t[r])return[r,t[r]];for(let e of[`login.start`,`setup.start`]){let n=t[e];if(n)return[e,n]}return Object.entries(t).find(([,e])=>e.result===`form`)??null}var me=e(le(),1),W=r();async function he(e){let t=await d(f(`/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 G(e){return e?.type===`poll`&&e.phase===`done`}function K(e){return e&&`message`in e&&typeof e.message==`string`?e.message:null}function q(e,t){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrPayload?e.qrPayload:t===`weixin`&&e.qrcodeUrl?e.qrcodeUrl:null}function J(e){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrcodeUrl??null}function ge({entry:e,locale:t,messages:n,onChanged:r,compact:i=!1}){let a=(0,H.useMemo)(()=>pe(e),[e]),o=(0,H.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,H.useState)({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null});(0,H.useEffect)(()=>{l({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null})},[e.id]);let u=(0,H.useCallback)(async(n,i)=>{l(e=>({...e,busy:!0,error:null}));try{let a=await he({channelId:e.id,actionId:n,locale:t,input:i});l(e=>({...e,payload:a,poll:a.type===`qr`&&a.statusAction&&a.sessionKey?{actionId:a.statusAction,sessionKey:a.sessionKey,intervalMs:Math.max(1e3,a.pollIntervalMs??2500)}:null,busy:!1,formDraft:a.type===`form`?a.values??{}:e.formDraft})),`configChanged`in a&&a.configChanged===!0&&await r()}catch(e){l(t=>({...t,busy:!1,error:e instanceof Error?e.message:String(e)}))}},[e.id,t,r]);(0,H.useEffect)(()=>{let t=q(c.payload,e.id);if(!t){l(e=>e.generatedQr?{...e,generatedQr:null}:e);return}let n=!1;return l(e=>e.generatedQr?{...e,generatedQr:null}:e),me.toDataURL(t,{width:220,margin:1}).then(e=>{n||l(t=>({...t,generatedQr:e}))}),()=>{n=!0}},[e.id,c.payload]),(0,H.useEffect)(()=>{let n=c.poll;if(!n)return;let i=!1,a=window.setInterval(()=>{i||he({channelId:e.id,actionId:n.actionId,locale:t,input:{sessionKey:n.sessionKey}}).then(async e=>{i||(l(t=>({...t,payload:e,poll:G(e)?null:t.poll,error:null})),`configChanged`in e&&e.configChanged===!0&&await r(),G(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=K(c.payload),m=q(c.payload,e.id),h=m?c.generatedQr:J(c.payload),_=a?.[1].result===`qr`&&(c.busy||c.payload?.type===`qr`||c.payload?.type===`poll`),v=c.payload?.type===`form`?c.payload:null,b=c.payload?.type===`diagnostics`?c.payload.checks:null;return(0,W.jsxs)(`div`,{className:i?`space-y-3`:`rounded-lg bg-surface-panel/80 p-4 shadow-surface`,children:[(0,W.jsxs)(`div`,{className:s(`flex flex-wrap items-start gap-3`,i?`justify-end`:`justify-between`),children:[i?null:(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.setupTitle}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.configured?n.setupConfiguredHint:n.setupEmptyHint})]}),(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[a?(0,W.jsxs)(g,{type:`button`,variant:`primary`,disabled:c.busy,onClick:()=>void u(a[0]),children:[c.busy?(0,W.jsx)(V,{className:`size-4 animate-spin`}):(0,W.jsx)(y,{className:`size-4`}),d]}):null,e.actions?.[`doctor.run`]?(0,W.jsxs)(g,{type:`button`,variant:`secondary`,disabled:c.busy,onClick:()=>void u(`doctor.run`),children:[(0,W.jsx)(B,{className:`size-4`}),f]}):null]})]}),p?(0,W.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:p}):null,c.error?(0,W.jsx)(`p`,{className:`mt-3 text-sm text-red-600 dark:text-red-400`,children:c.error}):null,_?(0,W.jsxs)(`div`,{className:s(`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,W.jsx)(`div`,{className:`flex size-56 shrink-0 items-center justify-center rounded-lg border border-edge bg-white p-3`,children:h?(0,W.jsx)(`img`,{src:h,alt:`${e.label} setup QR`,className:`size-52 object-contain`}):(0,W.jsx)(`div`,{className:`flex size-52 items-center justify-center rounded-md bg-surface-base`,children:(0,W.jsx)(z,{className:`size-48 rounded-md`})})}),(0,W.jsxs)(`div`,{className:s(`min-w-0 max-w-sm text-sm text-fg-muted`,i&&`w-full sm:w-auto`),children:[h?(0,W.jsx)(`p`,{className:`line-clamp-3`,children:n.waitingConfirmation}):(0,W.jsxs)(`div`,{className:`space-y-2`,"aria-busy":`true`,children:[(0,W.jsx)(z,{className:`h-4 w-48 max-w-full`}),(0,W.jsx)(z,{className:`h-4 w-36 max-w-full`})]}),m?(0,W.jsxs)(`a`,{className:`mt-2 inline-flex items-center gap-1 text-accent hover:underline`,href:m,target:`_blank`,rel:`noreferrer`,children:[n.openSetupLink,(0,W.jsx)(k,{className:`size-3.5`})]}):null]})]}):null,c.payload?.type===`poll`&&c.payload.phase===`done`?(0,W.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,W.jsx)(R,{className:c.payload.ok?`size-4 text-green-600`:`size-4 text-red-600`}),(0,W.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,W.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,W.jsx)(ce,{schema:v.schema,values:c.formDraft,onChange:e=>l(t=>({...t,formDraft:e})),disabled:c.busy,labels:o}),(0,W.jsx)(g,{type:`button`,variant:`primary`,disabled:c.busy,onClick:()=>void u(v.submitAction,c.formDraft),children:n.saveSetup})]}):null,b?(0,W.jsx)(`div`,{className:`mt-4 space-y-2`,children:b.map((e,t)=>(0,W.jsxs)(`div`,{className:`rounded-lg bg-surface-base px-3 py-2 shadow-surface`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,W.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.label??e.id??n.diagnosticCheckFallback.replace(`{{index}}`,String(t+1))}),(0,W.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,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.message}):null]},e.id??t))}):null]})}var _e=40;function Y(e){return`ui:route:channel:${e.trim().toLowerCase()}`}function ve(e,t){return e.find(e=>e.id===Y(t))?.agentId?.trim().toLowerCase()??``}function ye(e,t,n){let r=Y(t),i=e.filter(e=>e.id!==r),a=n.trim().toLowerCase();return a?[...i,{id:r,agentId:a,priority:_e,enabled:!0,match:{channel:t.trim().toLowerCase(),accountId:`*`}}]:i}function be(e){let t=e.configured===!0,n=e.enabled===!0;return e.setupStatus??{enabled:n,ready:t,state:n&&!t?`needs_setup`:n?`ready`:`disabled`,issues:[]}}function xe(e,t,n){let r=be(e);return r.ready?r.enabled?n?t?.connected===!0?`running`:`stopped`:`checking`:`disabled`:`needs_setup`}function Se(e,t=!1){return e===`drawer`?s(`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`,F):s(`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)]`,F,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`)}function Ce(e){let t=(0,U.c)(33),{presentation:n,open:r,onOpenChange:i,title:a,description:o,srTitle:c,srDescription:l,closeAriaLabel:u,children:d,footer:f,wide:p,headerExtra:m}=e,h=p===void 0?!1:p,y=n===`drawer`,[b,S]=(0,H.useState)(null),T;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,W.jsx)(D,{className:s(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,ne)}),t[0]=T):T=t[0];let E;t[1]!==n||t[2]!==h?(E=Se(n,h),t[1]=n,t[2]=h,t[3]=E):E=t[3];let k;t[4]===c?k=t[5]:(k=c?(0,W.jsx)(x,{className:`sr-only`,children:c}):null,t[4]=c,t[5]=k);let j;t[6]===l?j=t[7]:(j=l?(0,W.jsx)(C,{className:`sr-only`,children:l}):null,t[6]=l,t[7]=j);let N;t[8]!==u||t[9]!==o||t[10]!==m||t[11]!==y||t[12]!==a?(N=y?(0,W.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[a?(0,W.jsx)(`div`,{className:`text-base font-semibold text-fg`,children:a}):null,o?(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:o}):null]}),(0,W.jsx)(_,{asChild:!0,children:(0,W.jsx)(g,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":u,children:(0,W.jsx)(w,{className:`size-5`,strokeWidth:1.75})})})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(_,{asChild:!0,children:(0,W.jsx)(`button`,{type:`button`,className:s(v,`absolute right-3 top-3 z-20 p-1.5 hover:bg-surface-hover`),"aria-label":u,children:(0,W.jsx)(w,{className:`size-4`})})}),m]}),t[8]=u,t[9]=o,t[10]=m,t[11]=y,t[12]=a,t[13]=N):N=t[13];let P=y?`p-4`:`p-6`,F;t[14]===P?F=t[15]:(F=s(`min-h-0 flex-1 overflow-y-auto`,P),t[14]=P,t[15]=F);let I;t[16]!==d||t[17]!==F?(I=(0,W.jsx)(`div`,{className:F,children:d}),t[16]=d,t[17]=F,t[18]=I):I=t[18];let L;t[19]!==f||t[20]!==b||t[21]!==k||t[22]!==j||t[23]!==N||t[24]!==I?(L=(0,W.jsxs)(M,{layer:`modal`,portalContainer:b,children:[k,j,N,I,f]}),t[19]=f,t[20]=b,t[21]=k,t[22]=j,t[23]=N,t[24]=I,t[25]=L):L=t[25];let R;t[26]!==L||t[27]!==E?(R=(0,W.jsxs)(A,{children:[T,(0,W.jsx)(O,{ref:S,className:E,onOpenAutoFocus:we,children:L})]}),t[26]=L,t[27]=E,t[28]=R):R=t[28];let ee;return t[29]!==i||t[30]!==r||t[31]!==R?(ee=(0,W.jsx)(ie,{open:r,onOpenChange:i,children:R}),t[29]=i,t[30]=r,t[31]=R,t[32]=ee):ee=t[32],ee}function we(e){return e.preventDefault()}var Te=(0,H.memo)(function(e){let t=(0,U.c)(10),{ch:n,refreshing:r,saveOk:i,onRefresh:a}=e,o;t[0]!==n.saved||t[1]!==i?(o=i?(0,W.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,W.jsx)(I,{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,W.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,U.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,W.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,W.jsx)(g,{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,W.jsx)(g,{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 _=i?n.saving:n.save,v;t[13]!==m||t[14]!==h||t[15]!==_?(v=(0,W.jsx)(g,{type:`button`,variant:`primary`,disabled:m,onClick:h,children:_}),t[13]=m,t[14]=h,t[15]=_,t[16]=v):v=t[16];let y;t[17]!==d||t[18]!==p||t[19]!==v?(y=(0,W.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[d,p,v]}),t[17]=d,t[18]=p,t[19]=v,t[20]=y):y=t[20];let b;return t[21]!==y||t[22]!==u?(b=(0,W.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,y]}),t[21]=y,t[22]=u,t[23]=b):b=t[23],b}var De=`channels-status`;function Oe(e){if(!e||typeof e!=`object`)return null;let t=e.channels;return Array.isArray(t)?t:null}function ke(e){let t=t=>e(t.detail);return window.addEventListener(De,t),()=>window.removeEventListener(De,t)}function Ae(e,t){let n=(0,U.c)(4),r=t===void 0?!0:t,i,a;n[0]!==r||n[1]!==e?(i=()=>{if(r)return ke(e)},a=[r,e],n[0]=r,n[1]=e,n[2]=i,n[3]=a):(i=n[2],a=n[3]),(0,H.useEffect)(i,a)}function je(e){return e?f(`/api/channels/${encodeURIComponent(e)}/config`):null}async function Me(e){return(await p(f(`/api/channels/${encodeURIComponent(e)}/config`))).payload?.config??{}}var Ne=[`enabled`];async function Pe(){let e=await p(f(`/api/config`));return{channels:e.payload?.config?.channels??{},bindings:e.payload?.config?.bindings??[]}}function Fe(e){return e.split(`/`).filter(Boolean).map(e=>encodeURIComponent(e)).join(`/`)}function Ie(e){return e.configPath.startsWith(`channels.`)&&e.configPath.slice(9).split(`.`)[0]||e.id}function X(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 Le(e,t){return e===`running`?t.connectionRunning:e===`stopped`?t.connectionStopped:e===`checking`?t.connectionChecking:e===`disabled`?t.connectionDisabled:t.connectionNeedsSetup}function Re(e,t){return e===`running`?t.connectionRunningHint:e===`stopped`?t.connectionStoppedHint:e===`disabled`?t.connectionDisabledHint:e===`needs_setup`?t.connectionNeedsSetupHint:t.connectionChecking}function ze(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 Be(e){if(!e)return[];let t=e.uiHints??{},n=Z(e.configSchema)&&Array.isArray(e.configSchema.required)?e.configSchema.required.map(String):[],r=X(e).issues.map(e=>e.fieldPath).filter(e=>!!e),i=Object.entries(t).filter(([,e])=>!Z(e)||e.advanced===!0?!1:(Array.isArray(e.tags)?e.tags.map(String):[]).includes(`basic`)||e.advanced===!1).map(([e])=>e).filter(e=>!Ne.includes(e));return Array.from(new Set([...i,...n,...r])).filter(e=>!Ne.includes(e))}function Z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ve(e){return JSON.parse(JSON.stringify(e??{type:`object`,properties:{}}))}function He(e,t){let n={...Ve(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(!Z(r)||!Z(r[n]))break;let o=Z(a.properties)?a.properties:{};if(a.properties=o,o[n]||(o[n]={...Ve(r[n]),properties:{}}),e===t.length-1){o[n]=Ve(r[n]);break}i=r[n],a=o[n]}}return n}function Ue(e){let t=e.properties;if(!Z(t))return!1;for(let[e,n]of Object.entries(t))Z(n)&&n.type===`object`&&Ue(n)&&delete t[e];return Object.keys(t).length===0}function We(e,t){let n=Ve(e);for(let e of t){let t=e.split(`.`),r=n;for(let[e,n]of t.entries()){let i=r.properties;if(!Z(i))break;if(e===t.length-1){delete i[n];break}if(!Z(i[n]))break;r=i[n]}}return Ue(n),n}function Ge(e){return e.type===`object`&&Z(e.properties)&&Object.keys(e.properties).length>0}function Ke(e,t){let n=e;for(let e of t.split(`.`)){if(!Z(n))return;n=n[e]}return n}function qe(e){let t=e.accounts;return Z(t)?Object.values(t).filter(e=>Z(e)&&e.enabled!==!1).length:+(e.configured===!0)}function Je(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 Ye(e,t,n){let r=[],i=X(e);if(i.issues.length>0&&r.push(Qe(i.issues[0],n)),t){let i=e.ui?.card?.summaryFields??[`dmPolicy`,`streamMode`,`streaming.mode`];for(let e of i){let i=Je(e,Ke(t,e),n);i&&r.push(i)}let a=qe(t);a>0&&r.push(n.cardAccounts.replace(`{{count}}`,String(a)))}return r.length>0?r.slice(0,2):i.ready?[n.hubStatusConfigured]:[]}function Q(e,t){let n=X(e),r=pe(e);return n.state===`needs_setup`?r?.[1].label??t.completeSetup:!n.enabled&&n.ready?t.enableChannel:n.state===`error`?t.diagnose:n.ready?t.manageChannel:r?.[1].label??t.startConfiguration}function Xe(e,t){let n=pe(e);return n?.[1].result===`qr`?t.cardSetupQrHint:n?.[1].result===`form`?t.cardSetupConfigHint:t.cardSetupGenericHint}function Ze(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 Qe(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 $e({entry:e}){let t=l(e=>e.token),[n,r]=(0,H.useState)(!1),i=(0,H.useMemo)(()=>{if(!e.ui?.icon||n)return null;let r=new URL(f(`/api/extensions/${encodeURIComponent(e.extensionId)}/assets/${Fe(e.ui.icon)}`));return t?.trim()&&r.searchParams.set(`token`,t.trim()),r.toString()},[n,e.extensionId,e.ui?.icon,t]);return(0,W.jsx)(`span`,{className:`flex size-12 shrink-0 items-center justify-center rounded-2xl bg-surface-base text-fg`,children:i?(0,W.jsx)(`img`,{src:i,alt:``,draggable:!1,className:`size-7`,"aria-hidden":!0,onError:()=>r(!0)}):(0,W.jsx)(P,{sourceChannel:e.id,className:`size-7`})})}function et(e){let t=(0,U.c)(16),{checked:n,disabled:r,onToggle:i,label:a}=e,o;t[0]===i?o=t[1]:(o=e=>{e.stopPropagation(),i()},t[0]=i,t[1]=o);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=s(`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=s(`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,W.jsx)(`span`,{className:f}),t[7]=f,t[8]=p);let m;return t[9]!==n||t[10]!==r||t[11]!==a||t[12]!==o||t[13]!==u||t[14]!==p?(m=(0,W.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":n,"aria-label":a,disabled:r,onClick:o,className:u,children:p}),t[9]=n,t[10]=r,t[11]=a,t[12]=o,t[13]=u,t[14]=p,t[15]=m):m=t[15],m}function tt(e){let t=(0,U.c)(71),{entry:n,config:r,runtime:i,busy:a,restarting:o,ch:c,onOpen:l,onToggle:u,onRestart:d}=e,f;t[0]===n?f=t[1]:(f=X(n),t[0]=n,t[1]=f);let p=f,m,h,_,v,y,b,x;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=Ye(n,r,c),o=Ze(n,c);m=!p.enabled&&p.ready?u:i===`stopped`?d:l,b=`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,W.jsx)($e,{entry:n}),t[19]=n,t[20]=f);let g;t[21]===n.label?g=t[22]:(g=(0,W.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:n.label}),t[21]=n.label,t[22]=g);let S;t[23]===i?S=t[24]:(S=s(`mt-1 inline-flex rounded-full px-2 py-0.5 text-xs font-medium`,ze(i)),t[23]=i,t[24]=S);let C;t[25]!==c||t[26]!==i?(C=Le(i,c),t[25]=c,t[26]=i,t[27]=C):C=t[27];let w;t[28]!==S||t[29]!==C?(w=(0,W.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]!==g?(T=(0,W.jsxs)(`div`,{className:`min-w-0`,children:[g,w]}),t[31]=w,t[32]=g,t[33]=T):T=t[33];let E;t[34]!==T||t[35]!==f?(E=(0,W.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,W.jsx)(et,{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?(x=(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[E,k]}),t[45]=E,t[46]=k,t[47]=x):x=t[47],h=`button`,_=l,v=`mt-5 min-h-[6.25rem] text-left`,y=p.ready?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`p`,{className:`line-clamp-2 text-sm leading-6 text-fg-muted`,children:n.description??n.id}),e.length>0?(0,W.jsx)(`div`,{className:`mt-3 space-y-0.5 text-sm leading-5 text-fg-muted`,children:e.map(rt)}):null]}):(0,W.jsxs)(`div`,{className:`rounded-lg bg-surface-base p-3`,children:[(0,W.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:c.cardSetupTitle}),(0,W.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm leading-5 text-fg-muted`,children:e[0]??Xe(n,c)}),o.length>0?(0,W.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:o.map(nt)}):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]=_,t[15]=v,t[16]=y,t[17]=b,t[18]=x}else m=t[12],h=t[13],_=t[14],v=t[15],y=t[16],b=t[17],x=t[18];let S;t[48]!==h||t[49]!==_||t[50]!==v||t[51]!==y?(S=(0,W.jsx)(`button`,{type:h,onClick:_,className:v,children:y}),t[48]=h,t[49]=_,t[50]=v,t[51]=y,t[52]=S):S=t[52];let C=a||o,w;t[53]!==a||t[54]!==o?(w=a||o?(0,W.jsx)(V,{className:`size-4 animate-spin`}):null,t[53]=a,t[54]=o,t[55]=w):w=t[55];let T;t[56]!==c||t[57]!==n||t[58]!==o||t[59]!==i?(T=o?c.restartingChannel:i===`stopped`?c.restartChannel:Q(n,c),t[56]=c,t[57]=n,t[58]=o,t[59]=i,t[60]=T):T=t[60];let E;t[61]!==m||t[62]!==w||t[63]!==T||t[64]!==C?(E=(0,W.jsx)(`div`,{className:`mt-auto pt-4`,children:(0,W.jsxs)(g,{type:`button`,variant:`secondary`,className:`w-full rounded-2xl py-2.5`,onClick:m,disabled:C,children:[w,T]})}),t[61]=m,t[62]=w,t[63]=T,t[64]=C,t[65]=E):E=t[65];let D;return t[66]!==E||t[67]!==b||t[68]!==x||t[69]!==S?(D=(0,W.jsxs)(`article`,{className:b,children:[x,S,E]}),t[66]=E,t[67]=b,t[68]=x,t[69]=S,t[70]=D):D=t[70],D}function nt(e){return(0,W.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e},e)}function rt(e){return(0,W.jsx)(`p`,{className:`truncate`,title:e,children:e},e)}function it(e){let t=(0,U.c)(51),{runtime:n,restarting:r,checking:i,showConnectionOptions:a,canManageConnection:c,ch:l,onRestart:u,onCheck:d,onManageConnection:f}=e,p=n===`running`?R:n===`stopped`||n===`needs_setup`?o:V,m=n===`running`&&`text-emerald-600 dark:text-emerald-400`,h=n===`stopped`&&`text-red-600 dark:text-red-400`,_=n===`checking`&&`animate-spin text-amber-600 dark:text-amber-400`,v=n===`disabled`&&`text-fg-muted`,y=n===`needs_setup`&&`text-amber-600 dark:text-amber-400`,b;t[0]!==m||t[1]!==h||t[2]!==_||t[3]!==v||t[4]!==y?(b=s(`mt-0.5 size-5 shrink-0`,m,h,_,v,y),t[0]=m,t[1]=h,t[2]=_,t[3]=v,t[4]=y,t[5]=b):b=t[5];let x;t[6]!==p||t[7]!==b?(x=(0,W.jsx)(p,{className:b}),t[6]=p,t[7]=b,t[8]=x):x=t[8];let S;t[9]===l.connectionStatus?S=t[10]:(S=(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:l.connectionStatus}),t[9]=l.connectionStatus,t[10]=S);let C;t[11]!==l||t[12]!==n?(C=Re(n,l),t[11]=l,t[12]=n,t[13]=C):C=t[13];let w;t[14]===C?w=t[15]:(w=(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:C}),t[14]=C,t[15]=w);let T;t[16]!==w||t[17]!==S?(T=(0,W.jsxs)(`div`,{children:[S,w]}),t[16]=w,t[17]=S,t[18]=T):T=t[18];let E;t[19]!==T||t[20]!==x?(E=(0,W.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[x,T]}),t[19]=T,t[20]=x,t[21]=E):E=t[21];let D=i||r,O;t[22]===i?O=t[23]:(O=i?(0,W.jsx)(V,{className:`size-4 animate-spin`}):null,t[22]=i,t[23]=O);let k=i?l.checkingConnection:l.checkConnection,A;t[24]!==d||t[25]!==D||t[26]!==O||t[27]!==k?(A=(0,W.jsxs)(g,{type:`button`,variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:D,onClick:d,children:[O,k]}),t[24]=d,t[25]=D,t[26]=O,t[27]=k,t[28]=A):A=t[28];let j;t[29]!==l.restartChannel||t[30]!==l.restartingChannel||t[31]!==i||t[32]!==u||t[33]!==r||t[34]!==n?(j=n===`stopped`?(0,W.jsxs)(g,{type:`button`,variant:`primary`,className:`px-2.5 py-1.5 text-xs`,disabled:r||i,onClick:u,children:[r?(0,W.jsx)(V,{className:`size-4 animate-spin`}):(0,W.jsx)(re,{className:`size-4`}),r?l.restartingChannel:l.restartChannel]}):null,t[29]=l.restartChannel,t[30]=l.restartingChannel,t[31]=i,t[32]=u,t[33]=r,t[34]=n,t[35]=j):j=t[35];let M;t[36]!==c||t[37]!==l.connectionOptions||t[38]!==l.hideConnectionOptions||t[39]!==i||t[40]!==f||t[41]!==r||t[42]!==a?(M=c?(0,W.jsx)(g,{type:`button`,variant:`ghost`,className:`px-2.5 py-1.5 text-xs`,disabled:i||r,onClick:f,children:a?l.hideConnectionOptions:l.connectionOptions}):null,t[36]=c,t[37]=l.connectionOptions,t[38]=l.hideConnectionOptions,t[39]=i,t[40]=f,t[41]=r,t[42]=a,t[43]=M):M=t[43];let N;t[44]!==A||t[45]!==j||t[46]!==M?(N=(0,W.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[A,j,M]}),t[44]=A,t[45]=j,t[46]=M,t[47]=N):N=t[47];let P;return t[48]!==E||t[49]!==N?(P=(0,W.jsx)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:(0,W.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[E,N]})}),t[48]=E,t[49]=N,t[50]=P):P=t[50],P}function at(e){let t=(0,U.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=X(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,W.jsx)(S,{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,W.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,W.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,W.jsx)(`li`,{children:Qe(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,W.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,W.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,W.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,W.jsx)(`section`,{className:d,children:h}),t[30]=h,t[31]=d,t[32]=g):g=t[32],g}function ot(){let e=u(e=>e.language),t=c(e),n=l(e=>!!e.token),r=a(),{channelId:o}=i(),p=j(o),g=fe(n,e),_=g.entries,{data:v,mutate:y,isValidating:x}=m(n?de():null,ue,{revalidateOnFocus:!0}),{data:S,mutate:C}=m(n?`channels-config-map`:null,Pe,{revalidateOnFocus:!1}),w=S?.channels??{},D=S?.bindings??[],{data:O}=m(n?`channel-routing-agents`:null,h,{revalidateOnFocus:!1}),A=E(e=>e.setPageHeader),M=E(e=>e.clearPageHeader),P=(0,H.useMemo)(()=>_.find(e=>e.id===p),[p,_]),F=P?Ie(P):null,{data:I,mutate:R}=m(n&&F?je(F):null,()=>Me(F)),[z,B]=(0,H.useState)(null),[V,ne]=(0,H.useState)(!1),[re,ie]=(0,H.useState)(null),[le,U]=(0,H.useState)(null),[me,he]=(0,H.useState)(!1),[G,K]=(0,H.useState)(null),[q,J]=(0,H.useState)(null),_e=z??I??{},Y=t.channelsSettings,be=(0,H.useMemo)(()=>P?.configSchema??{type:`object`,properties:{}},[P?.configSchema]),Se=(0,H.useMemo)(()=>We(be,Ne),[be]),we=(0,H.useMemo)(()=>Be(P),[P]),De=(0,H.useMemo)(()=>He(Se,we),[we,Se]),ke=(0,H.useMemo)(()=>We(Se,we),[we,Se]),Fe=(0,H.useMemo)(()=>Ge(De),[De]),Re=P?q??ve(D,P.id):``,Z=(0,H.useMemo)(()=>(O?.items??[]).map(e=>{let n=T(e,t.agentsSettings);return{value:e.id,label:n===e.id?n:`${n} · ${e.id}`}}),[O?.items,t.agentsSettings]),Ve=O?.items.find(e=>e.id===O.defaultId),Ue=Ve?T(Ve,t.agentsSettings):O?.defaultId??``,Ke=(0,H.useMemo)(()=>({defaultBooleanLabel:Y.schemaBooleanDefault,unsupportedArrayType:Y.schemaUnsupportedArrayType,arrayAddPlaceholder:Y.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>Y.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[Y]),qe=(0,H.useMemo)(()=>new Map((v??[]).map(e=>[e.name,e])),[v]),Je=v!==void 0,Ye=(0,H.useCallback)(e=>xe(e,qe.get(e.id),Je),[qe,Je]),Q=(0,H.useCallback)(async()=>{await Promise.all([g.mutate(),y()])},[g,y]);Ae((0,H.useCallback)(e=>{let t=Oe(e);t&&y(t,!1)},[y]),n);let Xe=(0,H.useMemo)(()=>n?(0,W.jsx)(Te,{ch:Y,refreshing:g.isValidating||x,saveOk:!1,onRefresh:()=>void Q()}):null,[g.isValidating,Y,n,x,Q]);(0,H.useLayoutEffect)(()=>(A({startExtra:null,main:(0,W.jsx)(`div`,{className:`min-w-0`,children:(0,W.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.settingsSections.channels})}),end:Xe}),()=>M()),[M,Xe,t.settingsSections.channels,A]);let Ze=(0,H.useCallback)(e=>{r(N(e)),B(null),J(null),K(null)},[r]),Qe=(0,H.useCallback)(()=>{r(ee),B(null),J(null),K(null)},[r]),nt=(0,H.useCallback)(async e=>{U(e.id),K(null);try{let t=await d(f(`/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){K(e instanceof Error?e.message:String(e))}finally{U(null)}},[Q]);(0,H.useEffect)(()=>{J(null),he(!1)},[P?.id]);let rt=(0,H.useCallback)(async()=>{if(!P||!z&&q===null)return!1;let e=Ie(P);ne(!0),K(null);try{let t=await d(f(`/api/config`),{method:`PATCH`,body:JSON.stringify({...z?{channels:{[e]:z}}:{},...q===null?{}:{bindings:ye(D,P.id,q)}})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}return z&&await R(z,!1),await C(),await g.mutate(),B(null),J(null),!0}catch(e){return K(e instanceof Error?e.message:String(e)),!1}finally{ne(!1)}},[P,q,D,g,z,C,R]),ot=(0,H.useCallback)(async e=>{let t=X(e),n=Ie(e),r=P?.id===e.id?z:null;if(!t.enabled&&!t.ready&&!r){Ze(e.id);return}ie(e.id),K(null);try{let i=t.enabled?{enabled:!1}:r?{...r,enabled:!0}:{enabled:!0},a=await d(f(`/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 g.mutate(),await C(),await y(),P?.id===e.id&&(await R(),B(null))}catch(e){K(e instanceof Error?e.message:String(e))}finally{ie(null)}},[P?.id,g,z,C,R,y,Ze]),$=P?.ui?.modal,st=$?.placement!==`replace-config`,ct=P?Ye(P):`checking`,lt=P?!X(P).ready||me:!1;return n?(0,W.jsxs)(oe,{gap:`gap-4`,children:[g.isLoading?(0,W.jsx)(se,{sections:2}):g.error?(0,W.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:String(g.error)}):(0,W.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:_.map(e=>(0,W.jsx)(tt,{entry:e,config:w[Ie(e)]?.config,runtime:Ye(e),busy:re===e.id,restarting:le===e.id,ch:Y,onOpen:()=>Ze(e.id),onToggle:()=>void ot(e),onRestart:()=>void nt(e)},e.id))}),G?(0,W.jsx)(`p`,{className:`mt-4 text-sm text-red-600 dark:text-red-400`,children:G}):null,(0,W.jsx)(Ce,{presentation:`modal`,open:!!P,onOpenChange:e=>{e||Qe()},closeAriaLabel:Y.close,srTitle:P?.label??Y.selectChannel,srDescription:P?.description,wide:!0,footer:P?(0,W.jsx)(Ee,{ch:Y,dirty:!!z||q!==null,saving:V,onCancel:Qe,onDiscard:()=>{B(null),J(null)},onSave:rt}):null,children:P?(0,W.jsxs)(`div`,{className:`space-y-4`,children:[(0,W.jsx)(`div`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,children:(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,W.jsx)($e,{entry:P}),(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,W.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:P.label}),(0,W.jsx)(`span`,{className:s(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,ze(ct)),children:Le(ct,Y)})]}),(0,W.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,W.jsx)(`span`,{className:`min-w-0 truncate`,children:!X(P).ready&&pe(P)?.[1].result===`qr`?Y.scanLoginHint.replace(`{{channel}}`,P.label):P.description}),P.docsPath?(0,W.jsxs)(`a`,{href:P.docsPath,target:`_blank`,rel:`noreferrer`,className:`inline-flex shrink-0 items-center gap-1 text-accent hover:underline`,children:[Y.docs,(0,W.jsx)(k,{className:`size-3.5`})]}):null]})]})]}),(0,W.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pr-8`,children:[(0,W.jsx)(`span`,{className:`hidden text-xs text-fg-muted sm:inline`,children:X(P).enabled?Y.enabledLabel:Y.disabledLabel}),(0,W.jsx)(et,{checked:X(P).enabled,disabled:re===P.id,label:Y.toggleChannel.replace(`{{channel}}`,P.label),onToggle:()=>void ot(P)})]})]})}),(0,W.jsx)(it,{runtime:ct,restarting:le===P.id,checking:x,showConnectionOptions:me,canManageConnection:X(P).ready&&$?.placement!==`replace-config`,ch:Y,onRestart:()=>void nt(P),onCheck:()=>void Q(),onManageConnection:()=>he(e=>!e)}),(0,W.jsx)(at,{entry:P,ch:Y}),lt&&$?.placement!==`replace-config`?(0,W.jsx)(ge,{entry:P,locale:e,messages:Y,compact:!0,onChanged:async()=>{await R(),await Q(),await C()}},P.id):null,$?.entrypoint&&$.placement===`before-config`?(0,W.jsx)(b,{extensionId:P.extensionId,extensionName:P.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:P.id,entry:P,config:_e}}):null,$?.entrypoint&&$.placement!==`before-config`?(0,W.jsx)(b,{extensionId:P.extensionId,extensionName:P.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:P.id,entry:P,config:_e}}):null,st&&Fe?(0,W.jsxs)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:[(0,W.jsxs)(`div`,{className:`mb-4`,children:[(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:Y.basicConfiguration}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:Y.basicConfigurationHint})]}),(0,W.jsx)(ce,{schema:De,values:_e,onChange:e=>B(e),disabled:V,labels:Ke})]}):null,(0,W.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,W.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,W.jsx)(L,{className:`size-4 text-fg-muted`}),Y.messageHandling]}),(0,W.jsxs)(`div`,{className:`bg-surface-base/50 p-4`,children:[(0,W.jsxs)(`div`,{className:`mb-3`,children:[(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:Y.agentRouting}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:Y.messageHandlingHint})]}),(0,W.jsx)(te,{value:Re,options:Z,placeholder:Y.agentRoutingSelect,emptyLabel:Y.agentRoutingDefault.replace(`{{agent}}`,Ue||Y.agentRoutingSelect),ariaLabel:Y.agentRouting,disabled:V||!O,onChange:e=>J(e)})]})]}),st&&Ge(ke)?(0,W.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,W.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,W.jsx)(L,{className:`size-4 text-fg-muted`}),Y.advancedConfiguration]}),(0,W.jsx)(`div`,{className:`bg-surface-base/50 p-4`,children:(0,W.jsx)(ce,{schema:ke,values:_e,onChange:e=>B(e),disabled:V,labels:Ke})})]}):null,G?(0,W.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:G}):null]}):null})]}):(0,W.jsxs)(oe,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,W.jsx)(ae,{title:t.settingsSections.channels}),(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:Y.tokenRequired})]})}export{ot 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"./circle-alert-BEjgurr2.js";import{t as s}from"./cn-JdwAhgNB.js";import{t as c}from"./messages-DP6tPKk-.js";import{l,n as u,o as d,r as f,s as p}from"./locale-store-CTwSy7yW.js";import{i as m}from"./vendor-swr-BIWyz7Rc.js";import{$a as h,As as g,Bo as _,Cs as v,Ec as y,Et as b,Go as x,Gs as S,Ho as C,Ns as w,Rr as T,To as E,Uo as D,Vo as O,Wl as k,Wo as A,ai as j,as as M,ii as N,io as P,ls as F,oa as I,pc as L,pu as R,ri as ee,ro as z,tc as B,tl as V,ts as te,us as ne,xc as re,zo as ie}from"./index-C0CGebQ1.js";import{n as ae,r as oe}from"./settings-page-layout-DgFSya2e.js";import{n as se}from"./settings-loading-skeleton-Bk58_cr7.js";import{t as ce}from"./schema-form-DkUCy6vf.js";import{t as le}from"./browser-BLJWD7WI.js";import{n as ue,t as de}from"./channels-status-swr-vdf8kB16.js";import{t as fe}from"./use-channel-catalog-CnTkHDnw.js";var H=e(t(),1),U=n();function pe(e){let t=e.actions??{};for(let e of[`login.start`,`setup.start`]){let n=t[e];if(n?.result===`qr`)return[e,n]}let n=Object.entries(t).find(([,e])=>e.result===`qr`);if(n)return n;let r=e.ui?.card?.primaryAction;if(r&&t[r])return[r,t[r]];for(let e of[`login.start`,`setup.start`]){let n=t[e];if(n)return[e,n]}return Object.entries(t).find(([,e])=>e.result===`form`)??null}var me=e(le(),1),W=r();async function he(e){let t=await d(f(`/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 G(e){return e?.type===`poll`&&e.phase===`done`}function K(e){return e&&`message`in e&&typeof e.message==`string`?e.message:null}function q(e,t){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrPayload?e.qrPayload:t===`weixin`&&e.qrcodeUrl?e.qrcodeUrl:null}function J(e){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrcodeUrl??null}function ge({entry:e,locale:t,messages:n,onChanged:r,compact:i=!1}){let a=(0,H.useMemo)(()=>pe(e),[e]),o=(0,H.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,H.useState)({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null});(0,H.useEffect)(()=>{l({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null})},[e.id]);let u=(0,H.useCallback)(async(n,i)=>{l(e=>({...e,busy:!0,error:null}));try{let a=await he({channelId:e.id,actionId:n,locale:t,input:i});l(e=>({...e,payload:a,poll:a.type===`qr`&&a.statusAction&&a.sessionKey?{actionId:a.statusAction,sessionKey:a.sessionKey,intervalMs:Math.max(1e3,a.pollIntervalMs??2500)}:null,busy:!1,formDraft:a.type===`form`?a.values??{}:e.formDraft})),`configChanged`in a&&a.configChanged===!0&&await r()}catch(e){l(t=>({...t,busy:!1,error:e instanceof Error?e.message:String(e)}))}},[e.id,t,r]);(0,H.useEffect)(()=>{let t=q(c.payload,e.id);if(!t){l(e=>e.generatedQr?{...e,generatedQr:null}:e);return}let n=!1;return l(e=>e.generatedQr?{...e,generatedQr:null}:e),me.toDataURL(t,{width:220,margin:1}).then(e=>{n||l(t=>({...t,generatedQr:e}))}),()=>{n=!0}},[e.id,c.payload]),(0,H.useEffect)(()=>{let n=c.poll;if(!n)return;let i=!1,a=window.setInterval(()=>{i||he({channelId:e.id,actionId:n.actionId,locale:t,input:{sessionKey:n.sessionKey}}).then(async e=>{i||(l(t=>({...t,payload:e,poll:G(e)?null:t.poll,error:null})),`configChanged`in e&&e.configChanged===!0&&await r(),G(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=K(c.payload),m=q(c.payload,e.id),h=m?c.generatedQr:J(c.payload),_=a?.[1].result===`qr`&&(c.busy||c.payload?.type===`qr`||c.payload?.type===`poll`),v=c.payload?.type===`form`?c.payload:null,b=c.payload?.type===`diagnostics`?c.payload.checks:null;return(0,W.jsxs)(`div`,{className:i?`space-y-3`:`rounded-lg bg-surface-panel/80 p-4 shadow-surface`,children:[(0,W.jsxs)(`div`,{className:s(`flex flex-wrap items-start gap-3`,i?`justify-end`:`justify-between`),children:[i?null:(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.setupTitle}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.configured?n.setupConfiguredHint:n.setupEmptyHint})]}),(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[a?(0,W.jsxs)(g,{type:`button`,variant:`primary`,disabled:c.busy,onClick:()=>void u(a[0]),children:[c.busy?(0,W.jsx)(V,{className:`size-4 animate-spin`}):(0,W.jsx)(y,{className:`size-4`}),d]}):null,e.actions?.[`doctor.run`]?(0,W.jsxs)(g,{type:`button`,variant:`secondary`,disabled:c.busy,onClick:()=>void u(`doctor.run`),children:[(0,W.jsx)(B,{className:`size-4`}),f]}):null]})]}),p?(0,W.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:p}):null,c.error?(0,W.jsx)(`p`,{className:`mt-3 text-sm text-red-600 dark:text-red-400`,children:c.error}):null,_?(0,W.jsxs)(`div`,{className:s(`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,W.jsx)(`div`,{className:`flex size-56 shrink-0 items-center justify-center rounded-lg border border-edge bg-white p-3`,children:h?(0,W.jsx)(`img`,{src:h,alt:`${e.label} setup QR`,className:`size-52 object-contain`}):(0,W.jsx)(`div`,{className:`flex size-52 items-center justify-center rounded-md bg-surface-base`,children:(0,W.jsx)(z,{className:`size-48 rounded-md`})})}),(0,W.jsxs)(`div`,{className:s(`min-w-0 max-w-sm text-sm text-fg-muted`,i&&`w-full sm:w-auto`),children:[h?(0,W.jsx)(`p`,{className:`line-clamp-3`,children:n.waitingConfirmation}):(0,W.jsxs)(`div`,{className:`space-y-2`,"aria-busy":`true`,children:[(0,W.jsx)(z,{className:`h-4 w-48 max-w-full`}),(0,W.jsx)(z,{className:`h-4 w-36 max-w-full`})]}),m?(0,W.jsxs)(`a`,{className:`mt-2 inline-flex items-center gap-1 text-accent hover:underline`,href:m,target:`_blank`,rel:`noreferrer`,children:[n.openSetupLink,(0,W.jsx)(k,{className:`size-3.5`})]}):null]})]}):null,c.payload?.type===`poll`&&c.payload.phase===`done`?(0,W.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,W.jsx)(R,{className:c.payload.ok?`size-4 text-green-600`:`size-4 text-red-600`}),(0,W.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,W.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,W.jsx)(ce,{schema:v.schema,values:c.formDraft,onChange:e=>l(t=>({...t,formDraft:e})),disabled:c.busy,labels:o}),(0,W.jsx)(g,{type:`button`,variant:`primary`,disabled:c.busy,onClick:()=>void u(v.submitAction,c.formDraft),children:n.saveSetup})]}):null,b?(0,W.jsx)(`div`,{className:`mt-4 space-y-2`,children:b.map((e,t)=>(0,W.jsxs)(`div`,{className:`rounded-lg bg-surface-base px-3 py-2 shadow-surface`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,W.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.label??e.id??n.diagnosticCheckFallback.replace(`{{index}}`,String(t+1))}),(0,W.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,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.message}):null]},e.id??t))}):null]})}var _e=40;function Y(e){return`ui:route:channel:${e.trim().toLowerCase()}`}function ve(e,t){return e.find(e=>e.id===Y(t))?.agentId?.trim().toLowerCase()??``}function ye(e,t,n){let r=Y(t),i=e.filter(e=>e.id!==r),a=n.trim().toLowerCase();return a?[...i,{id:r,agentId:a,priority:_e,enabled:!0,match:{channel:t.trim().toLowerCase(),accountId:`*`}}]:i}function be(e){let t=e.configured===!0,n=e.enabled===!0;return e.setupStatus??{enabled:n,ready:t,state:n&&!t?`needs_setup`:n?`ready`:`disabled`,issues:[]}}function xe(e,t,n){let r=be(e);return r.ready?r.enabled?n?t?.connected===!0?`running`:`stopped`:`checking`:`disabled`:`needs_setup`}function Se(e,t=!1){return e===`drawer`?s(`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`,F):s(`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)]`,F,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`)}function Ce(e){let t=(0,U.c)(33),{presentation:n,open:r,onOpenChange:i,title:a,description:o,srTitle:c,srDescription:l,closeAriaLabel:u,children:d,footer:f,wide:p,headerExtra:m}=e,h=p===void 0?!1:p,y=n===`drawer`,[b,S]=(0,H.useState)(null),T;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,W.jsx)(D,{className:s(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,ne)}),t[0]=T):T=t[0];let E;t[1]!==n||t[2]!==h?(E=Se(n,h),t[1]=n,t[2]=h,t[3]=E):E=t[3];let k;t[4]===c?k=t[5]:(k=c?(0,W.jsx)(x,{className:`sr-only`,children:c}):null,t[4]=c,t[5]=k);let j;t[6]===l?j=t[7]:(j=l?(0,W.jsx)(C,{className:`sr-only`,children:l}):null,t[6]=l,t[7]=j);let N;t[8]!==u||t[9]!==o||t[10]!==m||t[11]!==y||t[12]!==a?(N=y?(0,W.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[a?(0,W.jsx)(`div`,{className:`text-base font-semibold text-fg`,children:a}):null,o?(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:o}):null]}),(0,W.jsx)(_,{asChild:!0,children:(0,W.jsx)(g,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":u,children:(0,W.jsx)(w,{className:`size-5`,strokeWidth:1.75})})})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(_,{asChild:!0,children:(0,W.jsx)(`button`,{type:`button`,className:s(v,`absolute right-3 top-3 z-20 p-1.5 hover:bg-surface-hover`),"aria-label":u,children:(0,W.jsx)(w,{className:`size-4`})})}),m]}),t[8]=u,t[9]=o,t[10]=m,t[11]=y,t[12]=a,t[13]=N):N=t[13];let P=y?`p-4`:`p-6`,F;t[14]===P?F=t[15]:(F=s(`min-h-0 flex-1 overflow-y-auto`,P),t[14]=P,t[15]=F);let I;t[16]!==d||t[17]!==F?(I=(0,W.jsx)(`div`,{className:F,children:d}),t[16]=d,t[17]=F,t[18]=I):I=t[18];let L;t[19]!==f||t[20]!==b||t[21]!==k||t[22]!==j||t[23]!==N||t[24]!==I?(L=(0,W.jsxs)(M,{layer:`modal`,portalContainer:b,children:[k,j,N,I,f]}),t[19]=f,t[20]=b,t[21]=k,t[22]=j,t[23]=N,t[24]=I,t[25]=L):L=t[25];let R;t[26]!==L||t[27]!==E?(R=(0,W.jsxs)(A,{children:[T,(0,W.jsx)(O,{ref:S,className:E,onOpenAutoFocus:we,children:L})]}),t[26]=L,t[27]=E,t[28]=R):R=t[28];let ee;return t[29]!==i||t[30]!==r||t[31]!==R?(ee=(0,W.jsx)(ie,{open:r,onOpenChange:i,children:R}),t[29]=i,t[30]=r,t[31]=R,t[32]=ee):ee=t[32],ee}function we(e){return e.preventDefault()}var Te=(0,H.memo)(function(e){let t=(0,U.c)(10),{ch:n,refreshing:r,saveOk:i,onRefresh:a}=e,o;t[0]!==n.saved||t[1]!==i?(o=i?(0,W.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,W.jsx)(I,{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,W.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,U.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,W.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,W.jsx)(g,{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,W.jsx)(g,{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 _=i?n.saving:n.save,v;t[13]!==m||t[14]!==h||t[15]!==_?(v=(0,W.jsx)(g,{type:`button`,variant:`primary`,disabled:m,onClick:h,children:_}),t[13]=m,t[14]=h,t[15]=_,t[16]=v):v=t[16];let y;t[17]!==d||t[18]!==p||t[19]!==v?(y=(0,W.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[d,p,v]}),t[17]=d,t[18]=p,t[19]=v,t[20]=y):y=t[20];let b;return t[21]!==y||t[22]!==u?(b=(0,W.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,y]}),t[21]=y,t[22]=u,t[23]=b):b=t[23],b}var De=`channels-status`;function Oe(e){if(!e||typeof e!=`object`)return null;let t=e.channels;return Array.isArray(t)?t:null}function ke(e){let t=t=>e(t.detail);return window.addEventListener(De,t),()=>window.removeEventListener(De,t)}function Ae(e,t){let n=(0,U.c)(4),r=t===void 0?!0:t,i,a;n[0]!==r||n[1]!==e?(i=()=>{if(r)return ke(e)},a=[r,e],n[0]=r,n[1]=e,n[2]=i,n[3]=a):(i=n[2],a=n[3]),(0,H.useEffect)(i,a)}function je(e){return e?f(`/api/channels/${encodeURIComponent(e)}/config`):null}async function Me(e){return(await p(f(`/api/channels/${encodeURIComponent(e)}/config`))).payload?.config??{}}var Ne=[`enabled`];async function Pe(){let e=await p(f(`/api/config`));return{channels:e.payload?.config?.channels??{},bindings:e.payload?.config?.bindings??[]}}function Fe(e){return e.split(`/`).filter(Boolean).map(e=>encodeURIComponent(e)).join(`/`)}function Ie(e){return e.configPath.startsWith(`channels.`)&&e.configPath.slice(9).split(`.`)[0]||e.id}function X(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 Le(e,t){return e===`running`?t.connectionRunning:e===`stopped`?t.connectionStopped:e===`checking`?t.connectionChecking:e===`disabled`?t.connectionDisabled:t.connectionNeedsSetup}function Re(e,t){return e===`running`?t.connectionRunningHint:e===`stopped`?t.connectionStoppedHint:e===`disabled`?t.connectionDisabledHint:e===`needs_setup`?t.connectionNeedsSetupHint:t.connectionChecking}function ze(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 Be(e){if(!e)return[];let t=e.uiHints??{},n=Z(e.configSchema)&&Array.isArray(e.configSchema.required)?e.configSchema.required.map(String):[],r=X(e).issues.map(e=>e.fieldPath).filter(e=>!!e),i=Object.entries(t).filter(([,e])=>!Z(e)||e.advanced===!0?!1:(Array.isArray(e.tags)?e.tags.map(String):[]).includes(`basic`)||e.advanced===!1).map(([e])=>e).filter(e=>!Ne.includes(e));return Array.from(new Set([...i,...n,...r])).filter(e=>!Ne.includes(e))}function Z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ve(e){return JSON.parse(JSON.stringify(e??{type:`object`,properties:{}}))}function He(e,t){let n={...Ve(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(!Z(r)||!Z(r[n]))break;let o=Z(a.properties)?a.properties:{};if(a.properties=o,o[n]||(o[n]={...Ve(r[n]),properties:{}}),e===t.length-1){o[n]=Ve(r[n]);break}i=r[n],a=o[n]}}return n}function Ue(e){let t=e.properties;if(!Z(t))return!1;for(let[e,n]of Object.entries(t))Z(n)&&n.type===`object`&&Ue(n)&&delete t[e];return Object.keys(t).length===0}function We(e,t){let n=Ve(e);for(let e of t){let t=e.split(`.`),r=n;for(let[e,n]of t.entries()){let i=r.properties;if(!Z(i))break;if(e===t.length-1){delete i[n];break}if(!Z(i[n]))break;r=i[n]}}return Ue(n),n}function Ge(e){return e.type===`object`&&Z(e.properties)&&Object.keys(e.properties).length>0}function Ke(e,t){let n=e;for(let e of t.split(`.`)){if(!Z(n))return;n=n[e]}return n}function qe(e){let t=e.accounts;return Z(t)?Object.values(t).filter(e=>Z(e)&&e.enabled!==!1).length:+(e.configured===!0)}function Je(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 Ye(e,t,n){let r=[],i=X(e);if(i.issues.length>0&&r.push(Qe(i.issues[0],n)),t){let i=e.ui?.card?.summaryFields??[`dmPolicy`,`streamMode`,`streaming.mode`];for(let e of i){let i=Je(e,Ke(t,e),n);i&&r.push(i)}let a=qe(t);a>0&&r.push(n.cardAccounts.replace(`{{count}}`,String(a)))}return r.length>0?r.slice(0,2):i.ready?[n.hubStatusConfigured]:[]}function Q(e,t){let n=X(e),r=pe(e);return n.state===`needs_setup`?r?.[1].label??t.completeSetup:!n.enabled&&n.ready?t.enableChannel:n.state===`error`?t.diagnose:n.ready?t.manageChannel:r?.[1].label??t.startConfiguration}function Xe(e,t){let n=pe(e);return n?.[1].result===`qr`?t.cardSetupQrHint:n?.[1].result===`form`?t.cardSetupConfigHint:t.cardSetupGenericHint}function Ze(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 Qe(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 $e({entry:e}){let t=l(e=>e.token),[n,r]=(0,H.useState)(!1),i=(0,H.useMemo)(()=>{if(!e.ui?.icon||n)return null;let r=new URL(f(`/api/extensions/${encodeURIComponent(e.extensionId)}/assets/${Fe(e.ui.icon)}`));return t?.trim()&&r.searchParams.set(`token`,t.trim()),r.toString()},[n,e.extensionId,e.ui?.icon,t]);return(0,W.jsx)(`span`,{className:`flex size-12 shrink-0 items-center justify-center rounded-2xl bg-surface-base text-fg`,children:i?(0,W.jsx)(`img`,{src:i,alt:``,draggable:!1,className:`size-7`,"aria-hidden":!0,onError:()=>r(!0)}):(0,W.jsx)(P,{sourceChannel:e.id,className:`size-7`})})}function et(e){let t=(0,U.c)(16),{checked:n,disabled:r,onToggle:i,label:a}=e,o;t[0]===i?o=t[1]:(o=e=>{e.stopPropagation(),i()},t[0]=i,t[1]=o);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=s(`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=s(`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,W.jsx)(`span`,{className:f}),t[7]=f,t[8]=p);let m;return t[9]!==n||t[10]!==r||t[11]!==a||t[12]!==o||t[13]!==u||t[14]!==p?(m=(0,W.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":n,"aria-label":a,disabled:r,onClick:o,className:u,children:p}),t[9]=n,t[10]=r,t[11]=a,t[12]=o,t[13]=u,t[14]=p,t[15]=m):m=t[15],m}function tt(e){let t=(0,U.c)(71),{entry:n,config:r,runtime:i,busy:a,restarting:o,ch:c,onOpen:l,onToggle:u,onRestart:d}=e,f;t[0]===n?f=t[1]:(f=X(n),t[0]=n,t[1]=f);let p=f,m,h,_,v,y,b,x;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=Ye(n,r,c),o=Ze(n,c);m=!p.enabled&&p.ready?u:i===`stopped`?d:l,b=`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,W.jsx)($e,{entry:n}),t[19]=n,t[20]=f);let g;t[21]===n.label?g=t[22]:(g=(0,W.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:n.label}),t[21]=n.label,t[22]=g);let S;t[23]===i?S=t[24]:(S=s(`mt-1 inline-flex rounded-full px-2 py-0.5 text-xs font-medium`,ze(i)),t[23]=i,t[24]=S);let C;t[25]!==c||t[26]!==i?(C=Le(i,c),t[25]=c,t[26]=i,t[27]=C):C=t[27];let w;t[28]!==S||t[29]!==C?(w=(0,W.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]!==g?(T=(0,W.jsxs)(`div`,{className:`min-w-0`,children:[g,w]}),t[31]=w,t[32]=g,t[33]=T):T=t[33];let E;t[34]!==T||t[35]!==f?(E=(0,W.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,W.jsx)(et,{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?(x=(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[E,k]}),t[45]=E,t[46]=k,t[47]=x):x=t[47],h=`button`,_=l,v=`mt-5 min-h-[6.25rem] text-left`,y=p.ready?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`p`,{className:`line-clamp-2 text-sm leading-6 text-fg-muted`,children:n.description??n.id}),e.length>0?(0,W.jsx)(`div`,{className:`mt-3 space-y-0.5 text-sm leading-5 text-fg-muted`,children:e.map(rt)}):null]}):(0,W.jsxs)(`div`,{className:`rounded-lg bg-surface-base p-3`,children:[(0,W.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:c.cardSetupTitle}),(0,W.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm leading-5 text-fg-muted`,children:e[0]??Xe(n,c)}),o.length>0?(0,W.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:o.map(nt)}):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]=_,t[15]=v,t[16]=y,t[17]=b,t[18]=x}else m=t[12],h=t[13],_=t[14],v=t[15],y=t[16],b=t[17],x=t[18];let S;t[48]!==h||t[49]!==_||t[50]!==v||t[51]!==y?(S=(0,W.jsx)(`button`,{type:h,onClick:_,className:v,children:y}),t[48]=h,t[49]=_,t[50]=v,t[51]=y,t[52]=S):S=t[52];let C=a||o,w;t[53]!==a||t[54]!==o?(w=a||o?(0,W.jsx)(V,{className:`size-4 animate-spin`}):null,t[53]=a,t[54]=o,t[55]=w):w=t[55];let T;t[56]!==c||t[57]!==n||t[58]!==o||t[59]!==i?(T=o?c.restartingChannel:i===`stopped`?c.restartChannel:Q(n,c),t[56]=c,t[57]=n,t[58]=o,t[59]=i,t[60]=T):T=t[60];let E;t[61]!==m||t[62]!==w||t[63]!==T||t[64]!==C?(E=(0,W.jsx)(`div`,{className:`mt-auto pt-4`,children:(0,W.jsxs)(g,{type:`button`,variant:`secondary`,className:`w-full rounded-2xl py-2.5`,onClick:m,disabled:C,children:[w,T]})}),t[61]=m,t[62]=w,t[63]=T,t[64]=C,t[65]=E):E=t[65];let D;return t[66]!==E||t[67]!==b||t[68]!==x||t[69]!==S?(D=(0,W.jsxs)(`article`,{className:b,children:[x,S,E]}),t[66]=E,t[67]=b,t[68]=x,t[69]=S,t[70]=D):D=t[70],D}function nt(e){return(0,W.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e},e)}function rt(e){return(0,W.jsx)(`p`,{className:`truncate`,title:e,children:e},e)}function it(e){let t=(0,U.c)(51),{runtime:n,restarting:r,checking:i,showConnectionOptions:a,canManageConnection:c,ch:l,onRestart:u,onCheck:d,onManageConnection:f}=e,p=n===`running`?R:n===`stopped`||n===`needs_setup`?o:V,m=n===`running`&&`text-emerald-600 dark:text-emerald-400`,h=n===`stopped`&&`text-red-600 dark:text-red-400`,_=n===`checking`&&`animate-spin text-amber-600 dark:text-amber-400`,v=n===`disabled`&&`text-fg-muted`,y=n===`needs_setup`&&`text-amber-600 dark:text-amber-400`,b;t[0]!==m||t[1]!==h||t[2]!==_||t[3]!==v||t[4]!==y?(b=s(`mt-0.5 size-5 shrink-0`,m,h,_,v,y),t[0]=m,t[1]=h,t[2]=_,t[3]=v,t[4]=y,t[5]=b):b=t[5];let x;t[6]!==p||t[7]!==b?(x=(0,W.jsx)(p,{className:b}),t[6]=p,t[7]=b,t[8]=x):x=t[8];let S;t[9]===l.connectionStatus?S=t[10]:(S=(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:l.connectionStatus}),t[9]=l.connectionStatus,t[10]=S);let C;t[11]!==l||t[12]!==n?(C=Re(n,l),t[11]=l,t[12]=n,t[13]=C):C=t[13];let w;t[14]===C?w=t[15]:(w=(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:C}),t[14]=C,t[15]=w);let T;t[16]!==w||t[17]!==S?(T=(0,W.jsxs)(`div`,{children:[S,w]}),t[16]=w,t[17]=S,t[18]=T):T=t[18];let E;t[19]!==T||t[20]!==x?(E=(0,W.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[x,T]}),t[19]=T,t[20]=x,t[21]=E):E=t[21];let D=i||r,O;t[22]===i?O=t[23]:(O=i?(0,W.jsx)(V,{className:`size-4 animate-spin`}):null,t[22]=i,t[23]=O);let k=i?l.checkingConnection:l.checkConnection,A;t[24]!==d||t[25]!==D||t[26]!==O||t[27]!==k?(A=(0,W.jsxs)(g,{type:`button`,variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:D,onClick:d,children:[O,k]}),t[24]=d,t[25]=D,t[26]=O,t[27]=k,t[28]=A):A=t[28];let j;t[29]!==l.restartChannel||t[30]!==l.restartingChannel||t[31]!==i||t[32]!==u||t[33]!==r||t[34]!==n?(j=n===`stopped`?(0,W.jsxs)(g,{type:`button`,variant:`primary`,className:`px-2.5 py-1.5 text-xs`,disabled:r||i,onClick:u,children:[r?(0,W.jsx)(V,{className:`size-4 animate-spin`}):(0,W.jsx)(re,{className:`size-4`}),r?l.restartingChannel:l.restartChannel]}):null,t[29]=l.restartChannel,t[30]=l.restartingChannel,t[31]=i,t[32]=u,t[33]=r,t[34]=n,t[35]=j):j=t[35];let M;t[36]!==c||t[37]!==l.connectionOptions||t[38]!==l.hideConnectionOptions||t[39]!==i||t[40]!==f||t[41]!==r||t[42]!==a?(M=c?(0,W.jsx)(g,{type:`button`,variant:`ghost`,className:`px-2.5 py-1.5 text-xs`,disabled:i||r,onClick:f,children:a?l.hideConnectionOptions:l.connectionOptions}):null,t[36]=c,t[37]=l.connectionOptions,t[38]=l.hideConnectionOptions,t[39]=i,t[40]=f,t[41]=r,t[42]=a,t[43]=M):M=t[43];let N;t[44]!==A||t[45]!==j||t[46]!==M?(N=(0,W.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[A,j,M]}),t[44]=A,t[45]=j,t[46]=M,t[47]=N):N=t[47];let P;return t[48]!==E||t[49]!==N?(P=(0,W.jsx)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:(0,W.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[E,N]})}),t[48]=E,t[49]=N,t[50]=P):P=t[50],P}function at(e){let t=(0,U.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=X(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,W.jsx)(S,{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,W.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,W.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,W.jsx)(`li`,{children:Qe(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,W.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,W.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,W.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,W.jsx)(`section`,{className:d,children:h}),t[30]=h,t[31]=d,t[32]=g):g=t[32],g}function ot(){let e=u(e=>e.language),t=c(e),n=l(e=>!!e.token),r=a(),{channelId:o}=i(),p=j(o),g=fe(n,e),_=g.entries,{data:v,mutate:y,isValidating:x}=m(n?de():null,ue,{revalidateOnFocus:!0}),{data:S,mutate:C}=m(n?`channels-config-map`:null,Pe,{revalidateOnFocus:!1}),w=S?.channels??{},D=S?.bindings??[],{data:O}=m(n?`channel-routing-agents`:null,h,{revalidateOnFocus:!1}),A=E(e=>e.setPageHeader),M=E(e=>e.clearPageHeader),P=(0,H.useMemo)(()=>_.find(e=>e.id===p),[p,_]),F=P?Ie(P):null,{data:I,mutate:R}=m(n&&F?je(F):null,()=>Me(F)),[z,B]=(0,H.useState)(null),[V,ne]=(0,H.useState)(!1),[re,ie]=(0,H.useState)(null),[le,U]=(0,H.useState)(null),[me,he]=(0,H.useState)(!1),[G,K]=(0,H.useState)(null),[q,J]=(0,H.useState)(null),_e=z??I??{},Y=t.channelsSettings,be=(0,H.useMemo)(()=>P?.configSchema??{type:`object`,properties:{}},[P?.configSchema]),Se=(0,H.useMemo)(()=>We(be,Ne),[be]),we=(0,H.useMemo)(()=>Be(P),[P]),De=(0,H.useMemo)(()=>He(Se,we),[we,Se]),ke=(0,H.useMemo)(()=>We(Se,we),[we,Se]),Fe=(0,H.useMemo)(()=>Ge(De),[De]),Re=P?q??ve(D,P.id):``,Z=(0,H.useMemo)(()=>(O?.items??[]).map(e=>{let n=T(e,t.agentsSettings);return{value:e.id,label:n===e.id?n:`${n} · ${e.id}`}}),[O?.items,t.agentsSettings]),Ve=O?.items.find(e=>e.id===O.defaultId),Ue=Ve?T(Ve,t.agentsSettings):O?.defaultId??``,Ke=(0,H.useMemo)(()=>({defaultBooleanLabel:Y.schemaBooleanDefault,unsupportedArrayType:Y.schemaUnsupportedArrayType,arrayAddPlaceholder:Y.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>Y.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[Y]),qe=(0,H.useMemo)(()=>new Map((v??[]).map(e=>[e.name,e])),[v]),Je=v!==void 0,Ye=(0,H.useCallback)(e=>xe(e,qe.get(e.id),Je),[qe,Je]),Q=(0,H.useCallback)(async()=>{await Promise.all([g.mutate(),y()])},[g,y]);Ae((0,H.useCallback)(e=>{let t=Oe(e);t&&y(t,!1)},[y]),n);let Xe=(0,H.useMemo)(()=>n?(0,W.jsx)(Te,{ch:Y,refreshing:g.isValidating||x,saveOk:!1,onRefresh:()=>void Q()}):null,[g.isValidating,Y,n,x,Q]);(0,H.useLayoutEffect)(()=>(A({startExtra:null,main:(0,W.jsx)(`div`,{className:`min-w-0`,children:(0,W.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.settingsSections.channels})}),end:Xe}),()=>M()),[M,Xe,t.settingsSections.channels,A]);let Ze=(0,H.useCallback)(e=>{r(N(e)),B(null),J(null),K(null)},[r]),Qe=(0,H.useCallback)(()=>{r(ee),B(null),J(null),K(null)},[r]),nt=(0,H.useCallback)(async e=>{U(e.id),K(null);try{let t=await d(f(`/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){K(e instanceof Error?e.message:String(e))}finally{U(null)}},[Q]);(0,H.useEffect)(()=>{J(null),he(!1)},[P?.id]);let rt=(0,H.useCallback)(async()=>{if(!P||!z&&q===null)return!1;let e=Ie(P);ne(!0),K(null);try{let t=await d(f(`/api/config`),{method:`PATCH`,body:JSON.stringify({...z?{channels:{[e]:z}}:{},...q===null?{}:{bindings:ye(D,P.id,q)}})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}return z&&await R(z,!1),await C(),await g.mutate(),B(null),J(null),!0}catch(e){return K(e instanceof Error?e.message:String(e)),!1}finally{ne(!1)}},[P,q,D,g,z,C,R]),ot=(0,H.useCallback)(async e=>{let t=X(e),n=Ie(e),r=P?.id===e.id?z:null;if(!t.enabled&&!t.ready&&!r){Ze(e.id);return}ie(e.id),K(null);try{let i=t.enabled?{enabled:!1}:r?{...r,enabled:!0}:{enabled:!0},a=await d(f(`/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 g.mutate(),await C(),await y(),P?.id===e.id&&(await R(),B(null))}catch(e){K(e instanceof Error?e.message:String(e))}finally{ie(null)}},[P?.id,g,z,C,R,y,Ze]),$=P?.ui?.modal,st=$?.placement!==`replace-config`,ct=P?Ye(P):`checking`,lt=P?!X(P).ready||me:!1;return n?(0,W.jsxs)(oe,{gap:`gap-4`,children:[g.isLoading?(0,W.jsx)(se,{sections:2}):g.error?(0,W.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:String(g.error)}):(0,W.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:_.map(e=>(0,W.jsx)(tt,{entry:e,config:w[Ie(e)]?.config,runtime:Ye(e),busy:re===e.id,restarting:le===e.id,ch:Y,onOpen:()=>Ze(e.id),onToggle:()=>void ot(e),onRestart:()=>void nt(e)},e.id))}),G?(0,W.jsx)(`p`,{className:`mt-4 text-sm text-red-600 dark:text-red-400`,children:G}):null,(0,W.jsx)(Ce,{presentation:`modal`,open:!!P,onOpenChange:e=>{e||Qe()},closeAriaLabel:Y.close,srTitle:P?.label??Y.selectChannel,srDescription:P?.description,wide:!0,footer:P?(0,W.jsx)(Ee,{ch:Y,dirty:!!z||q!==null,saving:V,onCancel:Qe,onDiscard:()=>{B(null),J(null)},onSave:rt}):null,children:P?(0,W.jsxs)(`div`,{className:`space-y-4`,children:[(0,W.jsx)(`div`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,children:(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,W.jsx)($e,{entry:P}),(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,W.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:P.label}),(0,W.jsx)(`span`,{className:s(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,ze(ct)),children:Le(ct,Y)})]}),(0,W.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,W.jsx)(`span`,{className:`min-w-0 truncate`,children:!X(P).ready&&pe(P)?.[1].result===`qr`?Y.scanLoginHint.replace(`{{channel}}`,P.label):P.description}),P.docsPath?(0,W.jsxs)(`a`,{href:P.docsPath,target:`_blank`,rel:`noreferrer`,className:`inline-flex shrink-0 items-center gap-1 text-accent hover:underline`,children:[Y.docs,(0,W.jsx)(k,{className:`size-3.5`})]}):null]})]})]}),(0,W.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pr-8`,children:[(0,W.jsx)(`span`,{className:`hidden text-xs text-fg-muted sm:inline`,children:X(P).enabled?Y.enabledLabel:Y.disabledLabel}),(0,W.jsx)(et,{checked:X(P).enabled,disabled:re===P.id,label:Y.toggleChannel.replace(`{{channel}}`,P.label),onToggle:()=>void ot(P)})]})]})}),(0,W.jsx)(it,{runtime:ct,restarting:le===P.id,checking:x,showConnectionOptions:me,canManageConnection:X(P).ready&&$?.placement!==`replace-config`,ch:Y,onRestart:()=>void nt(P),onCheck:()=>void Q(),onManageConnection:()=>he(e=>!e)}),(0,W.jsx)(at,{entry:P,ch:Y}),lt&&$?.placement!==`replace-config`?(0,W.jsx)(ge,{entry:P,locale:e,messages:Y,compact:!0,onChanged:async()=>{await R(),await Q(),await C()}},P.id):null,$?.entrypoint&&$.placement===`before-config`?(0,W.jsx)(b,{extensionId:P.extensionId,extensionName:P.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:P.id,entry:P,config:_e}}):null,$?.entrypoint&&$.placement!==`before-config`?(0,W.jsx)(b,{extensionId:P.extensionId,extensionName:P.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:P.id,entry:P,config:_e}}):null,st&&Fe?(0,W.jsxs)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:[(0,W.jsxs)(`div`,{className:`mb-4`,children:[(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:Y.basicConfiguration}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:Y.basicConfigurationHint})]}),(0,W.jsx)(ce,{schema:De,values:_e,onChange:e=>B(e),disabled:V,labels:Ke})]}):null,(0,W.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,W.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,W.jsx)(L,{className:`size-4 text-fg-muted`}),Y.messageHandling]}),(0,W.jsxs)(`div`,{className:`bg-surface-base/50 p-4`,children:[(0,W.jsxs)(`div`,{className:`mb-3`,children:[(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:Y.agentRouting}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:Y.messageHandlingHint})]}),(0,W.jsx)(te,{value:Re,options:Z,placeholder:Y.agentRoutingSelect,emptyLabel:Y.agentRoutingDefault.replace(`{{agent}}`,Ue||Y.agentRoutingSelect),ariaLabel:Y.agentRouting,disabled:V||!O,onChange:e=>J(e)})]})]}),st&&Ge(ke)?(0,W.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,W.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,W.jsx)(L,{className:`size-4 text-fg-muted`}),Y.advancedConfiguration]}),(0,W.jsx)(`div`,{className:`bg-surface-base/50 p-4`,children:(0,W.jsx)(ce,{schema:ke,values:_e,onChange:e=>B(e),disabled:V,labels:Ke})})]}):null,G?(0,W.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:G}):null]}):null})]}):(0,W.jsxs)(oe,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,W.jsx)(ae,{title:t.settingsSections.channels}),(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:Y.tokenRequired})]})}export{ot as ChannelsSettingsPanel};
@@ -0,0 +1 @@
1
+ import{r as e}from"./locale-store-CTwSy7yW.js";import{n as t}from"./channel-recipient-api-CFR5FBfS.js";function n(){return e(`/api/channels/status`)}var r=t;export{r as n,n as t};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-JdwAhgNB.js";import{r as a,s as o}from"./locale-store-DVGhFXRz.js";import{Hc as s,to as c}from"./index-C1h0zkNo.js";function l(e,t){if(!e.payload)throw Error(e.error??t);return e.payload}async function u(){return l(await o(a(`/api/connectors/catalog`)),`Could not load connector catalog.`).connectors}async function d(e){let t=new URLSearchParams;return e?.q?.trim()&&t.set(`q`,e.q.trim()),e?.page&&t.set(`page`,String(e.page)),e?.pageSize&&t.set(`pageSize`,String(e.pageSize)),e?.refresh&&t.set(`refresh`,`1`),e?.verification&&t.set(`verification`,e.verification),l(await o(a(`/api/connectors/composio/catalog${t.size?`?${t.toString()}`:``}`)),`Could not load Composio catalog.`)}async function f(e){let t=new URLSearchParams;return e?.q?.trim()&&t.set(`q`,e.q.trim()),e?.page&&t.set(`page`,String(e.page)),e?.pageSize&&t.set(`pageSize`,String(e.pageSize)),e?.category?.trim()&&t.set(`category`,e.category.trim()),e?.sort&&t.set(`sort`,e.sort),l(await o(a(`/api/capabilities/connectors${t.size?`?${t.toString()}`:``}`)),`Could not load Store connector capabilities.`)}async function p(e,t){return l(await o(a(`/api/capabilities/connectors/${encodeURIComponent(e)}/install-plan`),{method:`POST`,body:JSON.stringify({version:t})}),`Could not prepare connector installation.`).plan}async function m(e,t,n){let r=await o(a(`/api/capabilities/connectors/${encodeURIComponent(e)}/install`),{method:`POST`,body:JSON.stringify({...t,version:n})});return c(),l(r,`Could not install Store connector.`).instance}async function h(){return l(await o(a(`/api/connectors/installed`)),`Could not load installed connectors.`).instances}async function g(e){return l(await o(a(`/api/connectors/${encodeURIComponent(e)}/auth/start`),{method:`POST`}),`Could not start connector authorization.`).authorization}async function _(){return l(await o(a(`/api/connectors/composio/setup-status`)),`Could not check the connection service.`)}async function v(e){l(await o(a(`/api/connectors/composio/setup`),{method:`POST`,body:JSON.stringify({apiKey:e})}),`Could not enable the connection service.`)}async function y(e,t){let n=await o(a(`/api/connectors/${encodeURIComponent(e)}/install`),{method:`POST`,body:JSON.stringify(t)});return c(),l(n,`Could not install connector.`).instance}async function b(e,t={}){return l(await o(a(`/api/connectors/preview`),{method:`POST`,body:JSON.stringify({...t,definition:e})}),`Could not preview connector capabilities.`).preview}async function x(e,t){return l(await o(a(`/api/connectors/${encodeURIComponent(e)}/config`),{method:`POST`,body:JSON.stringify(t)}),`Could not update connector config.`).instance}async function S(e){await o(a(`/api/connectors/${encodeURIComponent(e)}`),{method:`DELETE`}),c()}async function C(e){return l(await o(a(`/api/connectors/${encodeURIComponent(e)}/test`),{method:`POST`}),`Connector test failed.`)}async function w(){return l(await o(a(`/api/connectors/composio/connections`)),`Could not load Composio connections.`).connections}async function T(e,t,n=12e4){let r=Date.now()+n;for(;Date.now()<r;){let n=(await w().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 E(e,t){return l(await o(a(`/api/connectors/composio/connections/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify(t)}),`Could not update Composio connection.`).connection}async function D(e){return l(await o(a(`/api/connectors/composio/${encodeURIComponent(e)}/health`)),`Could not check Composio connector health.`).health}async function O(e){await o(a(`/api/connectors/composio/connections/${encodeURIComponent(e)}/refresh`),{method:`POST`})}async function k(e){await o(a(`/api/connectors/composio/connections/${encodeURIComponent(e)}`),{method:`DELETE`})}async function A(e){return l(await o(a(`/api/connectors/composio/${encodeURIComponent(e)}/scope`)),`Could not load Composio scope.`).scope}async function j(e,t){let n=await o(a(`/api/connectors/composio/${encodeURIComponent(e)}/scope`),{method:`POST`,body:JSON.stringify({scope:t})});return c(),l(n,`Could not update Composio scope.`).scope}async function M(e){return l(await o(a(`/api/connectors/composio/${encodeURIComponent(e)}/policy`)),`Could not load Composio policy.`)}async function N(e,t){return l(await o(a(`/api/connectors/composio/${encodeURIComponent(e)}/policy`),{method:`PATCH`,body:JSON.stringify(t)}),`Could not update Composio policy.`).policy}async function P(e){return l(await o(a(`/api/connectors/composio/${encodeURIComponent(e)}/tools`)),`Could not load Composio tools.`).tools}async function F(e=50){return l(await o(a(`/api/connectors/composio/triggers?limit=${encodeURIComponent(String(e))}`)),`Could not load Composio trigger events.`).events}async function I(e){return l(await o(a(`/api/connectors/composio/connections/${encodeURIComponent(e)}/learning`),{method:`POST`}),`Could not start learning from this connection.`).job}async function L(){return l(await o(a(`/api/connectors/learning`)),`Could not load connector learning jobs.`).jobs}async function R(e,t){let n=t?`pause`:`resume`;l(await o(a(`/api/connectors/composio/connections/${encodeURIComponent(e)}/learning/${n}`),{method:`POST`}),`Could not ${n} connector learning.`)}async function z(e){return l(await o(a(`/api/connectors/${encodeURIComponent(e)}/source-sync`),{method:`POST`}),`Could not sync connector source.`)}async function B(e=``,t=100){return l(await o(a(`/api/connectors/people?${new URLSearchParams({q:e,limit:String(t)}).toString()}`)),`Could not load the connected people graph.`)}async function V(e=`pending`){return l(await o(a(`/api/connectors/approvals?status=${encodeURIComponent(e)}`)),`Could not load connector approvals.`).approvals}async function H(e,t){return l(await o(a(`/api/connectors/approvals/respond`),{method:`POST`,body:JSON.stringify({id:e,decision:t})}),`Could not update connector approval.`).approval}var U=n(),W=e(t(),1),G=r(),K={sm:{frame:`size-9 rounded-lg`,image:`size-6`,fallback:`size-4`},md:{frame:`size-10 rounded-xl`,image:`size-7`,fallback:`size-5`},lg:{frame:`size-12 rounded-xl`,image:`size-8`,fallback:`size-5`}};function q(e){let t=(0,U.c)(18),{connector:n,size:r,className:a}=e,o=r===void 0?`md`:r,c=n?.branding?.logoUrl,[l,u]=(0,W.useState)(!1),d=K[o],f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(f=()=>{u(!1)},t[0]=f):f=t[0];let p;t[1]===c?p=t[2]:(p=[c],t[1]=c,t[2]=p),(0,W.useEffect)(f,p);let m;t[3]!==a||t[4]!==d.frame?(m=i(`flex shrink-0 items-center justify-center overflow-hidden border border-edge bg-surface-base`,d.frame,a),t[3]=a,t[4]=d.frame,t[5]=m):m=t[5];let h;t[6]===n?h=t[7]:(h=n?.branding?.backgroundColor?{backgroundColor:n.branding.backgroundColor}:void 0,t[6]=n,t[7]=h);let g=n?.displayName,_;t[8]!==d.fallback||t[9]!==d.image||t[10]!==l||t[11]!==c?(_=c&&!l?(0,G.jsx)(`img`,{src:c,alt:``,loading:`lazy`,draggable:!1,className:i(`object-contain`,d.image),onError:()=>u(!0)}):(0,G.jsx)(s,{className:i(`text-fg-muted`,d.fallback),"aria-hidden":!0}),t[8]=d.fallback,t[9]=d.image,t[10]=l,t[11]=c,t[12]=_):_=t[12];let v;return t[13]!==m||t[14]!==h||t[15]!==g||t[16]!==_?(v=(0,G.jsx)(`span`,{className:m,style:h,title:g,children:_}),t[13]=m,t[14]=h,t[15]=g,t[16]=_,t[17]=v):v=t[17],v}export{C as A,H as C,I as D,R as E,N as M,x as N,g as O,T as P,S,j as T,F as _,u as a,b,p as c,A as d,_ as f,P as g,w as h,B as i,E as j,z as k,D as l,m,v as n,h as o,y as p,d as r,f as s,q as t,M as u,V as v,k as w,O as x,L as y};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-JdwAhgNB.js";import{r as a,s as o}from"./locale-store-CTwSy7yW.js";import{Hc as s,to as c}from"./index-C0CGebQ1.js";function l(e,t){if(!e.payload)throw Error(e.error??t);return e.payload}async function u(){return l(await o(a(`/api/connectors/catalog`)),`Could not load connector catalog.`).connectors}async function d(e){let t=new URLSearchParams;return e?.q?.trim()&&t.set(`q`,e.q.trim()),e?.page&&t.set(`page`,String(e.page)),e?.pageSize&&t.set(`pageSize`,String(e.pageSize)),e?.refresh&&t.set(`refresh`,`1`),e?.verification&&t.set(`verification`,e.verification),l(await o(a(`/api/connectors/composio/catalog${t.size?`?${t.toString()}`:``}`)),`Could not load Composio catalog.`)}async function f(e){let t=new URLSearchParams;return e?.q?.trim()&&t.set(`q`,e.q.trim()),e?.page&&t.set(`page`,String(e.page)),e?.pageSize&&t.set(`pageSize`,String(e.pageSize)),e?.category?.trim()&&t.set(`category`,e.category.trim()),e?.sort&&t.set(`sort`,e.sort),l(await o(a(`/api/capabilities/connectors${t.size?`?${t.toString()}`:``}`)),`Could not load Store connector capabilities.`)}async function p(e,t){return l(await o(a(`/api/capabilities/connectors/${encodeURIComponent(e)}/install-plan`),{method:`POST`,body:JSON.stringify({version:t})}),`Could not prepare connector installation.`).plan}async function m(e,t,n){let r=await o(a(`/api/capabilities/connectors/${encodeURIComponent(e)}/install`),{method:`POST`,body:JSON.stringify({...t,version:n})});return c(),l(r,`Could not install Store connector.`).instance}async function h(){return l(await o(a(`/api/connectors/installed`)),`Could not load installed connectors.`).instances}async function g(e){return l(await o(a(`/api/connectors/${encodeURIComponent(e)}/auth/start`),{method:`POST`}),`Could not start connector authorization.`).authorization}async function _(){return l(await o(a(`/api/connectors/composio/setup-status`)),`Could not check the connection service.`)}async function v(e){l(await o(a(`/api/connectors/composio/setup`),{method:`POST`,body:JSON.stringify({apiKey:e})}),`Could not enable the connection service.`)}async function y(e,t){let n=await o(a(`/api/connectors/${encodeURIComponent(e)}/install`),{method:`POST`,body:JSON.stringify(t)});return c(),l(n,`Could not install connector.`).instance}async function b(e,t={}){return l(await o(a(`/api/connectors/preview`),{method:`POST`,body:JSON.stringify({...t,definition:e})}),`Could not preview connector capabilities.`).preview}async function x(e,t){return l(await o(a(`/api/connectors/${encodeURIComponent(e)}/config`),{method:`POST`,body:JSON.stringify(t)}),`Could not update connector config.`).instance}async function S(e){await o(a(`/api/connectors/${encodeURIComponent(e)}`),{method:`DELETE`}),c()}async function C(e){return l(await o(a(`/api/connectors/${encodeURIComponent(e)}/test`),{method:`POST`}),`Connector test failed.`)}async function w(){return l(await o(a(`/api/connectors/composio/connections`)),`Could not load Composio connections.`).connections}async function T(e,t,n=12e4){let r=Date.now()+n;for(;Date.now()<r;){let n=(await w().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 E(e,t){return l(await o(a(`/api/connectors/composio/connections/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify(t)}),`Could not update Composio connection.`).connection}async function D(e){return l(await o(a(`/api/connectors/composio/${encodeURIComponent(e)}/health`)),`Could not check Composio connector health.`).health}async function O(e){await o(a(`/api/connectors/composio/connections/${encodeURIComponent(e)}/refresh`),{method:`POST`})}async function k(e){await o(a(`/api/connectors/composio/connections/${encodeURIComponent(e)}`),{method:`DELETE`})}async function A(e){return l(await o(a(`/api/connectors/composio/${encodeURIComponent(e)}/scope`)),`Could not load Composio scope.`).scope}async function j(e,t){let n=await o(a(`/api/connectors/composio/${encodeURIComponent(e)}/scope`),{method:`POST`,body:JSON.stringify({scope:t})});return c(),l(n,`Could not update Composio scope.`).scope}async function M(e){return l(await o(a(`/api/connectors/composio/${encodeURIComponent(e)}/policy`)),`Could not load Composio policy.`)}async function N(e,t){return l(await o(a(`/api/connectors/composio/${encodeURIComponent(e)}/policy`),{method:`PATCH`,body:JSON.stringify(t)}),`Could not update Composio policy.`).policy}async function P(e){return l(await o(a(`/api/connectors/composio/${encodeURIComponent(e)}/tools`)),`Could not load Composio tools.`).tools}async function F(e=50){return l(await o(a(`/api/connectors/composio/triggers?limit=${encodeURIComponent(String(e))}`)),`Could not load Composio trigger events.`).events}async function I(e){return l(await o(a(`/api/connectors/composio/connections/${encodeURIComponent(e)}/learning`),{method:`POST`}),`Could not start learning from this connection.`).job}async function L(){return l(await o(a(`/api/connectors/learning`)),`Could not load connector learning jobs.`).jobs}async function R(e,t){let n=t?`pause`:`resume`;l(await o(a(`/api/connectors/composio/connections/${encodeURIComponent(e)}/learning/${n}`),{method:`POST`}),`Could not ${n} connector learning.`)}async function z(e){return l(await o(a(`/api/connectors/${encodeURIComponent(e)}/source-sync`),{method:`POST`}),`Could not sync connector source.`)}async function B(e=``,t=100){return l(await o(a(`/api/connectors/people?${new URLSearchParams({q:e,limit:String(t)}).toString()}`)),`Could not load the connected people graph.`)}async function V(e=`pending`){return l(await o(a(`/api/connectors/approvals?status=${encodeURIComponent(e)}`)),`Could not load connector approvals.`).approvals}async function H(e,t){return l(await o(a(`/api/connectors/approvals/respond`),{method:`POST`,body:JSON.stringify({id:e,decision:t})}),`Could not update connector approval.`).approval}var U=n(),W=e(t(),1),G=r(),K={sm:{frame:`size-9 rounded-lg`,image:`size-6`,fallback:`size-4`},md:{frame:`size-10 rounded-xl`,image:`size-7`,fallback:`size-5`},lg:{frame:`size-12 rounded-xl`,image:`size-8`,fallback:`size-5`}};function q(e){let t=(0,U.c)(18),{connector:n,size:r,className:a}=e,o=r===void 0?`md`:r,c=n?.branding?.logoUrl,[l,u]=(0,W.useState)(!1),d=K[o],f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(f=()=>{u(!1)},t[0]=f):f=t[0];let p;t[1]===c?p=t[2]:(p=[c],t[1]=c,t[2]=p),(0,W.useEffect)(f,p);let m;t[3]!==a||t[4]!==d.frame?(m=i(`flex shrink-0 items-center justify-center overflow-hidden border border-edge bg-surface-base`,d.frame,a),t[3]=a,t[4]=d.frame,t[5]=m):m=t[5];let h;t[6]===n?h=t[7]:(h=n?.branding?.backgroundColor?{backgroundColor:n.branding.backgroundColor}:void 0,t[6]=n,t[7]=h);let g=n?.displayName,_;t[8]!==d.fallback||t[9]!==d.image||t[10]!==l||t[11]!==c?(_=c&&!l?(0,G.jsx)(`img`,{src:c,alt:``,loading:`lazy`,draggable:!1,className:i(`object-contain`,d.image),onError:()=>u(!0)}):(0,G.jsx)(s,{className:i(`text-fg-muted`,d.fallback),"aria-hidden":!0}),t[8]=d.fallback,t[9]=d.image,t[10]=l,t[11]=c,t[12]=_):_=t[12];let v;return t[13]!==m||t[14]!==h||t[15]!==g||t[16]!==_?(v=(0,G.jsx)(`span`,{className:m,style:h,title:g,children:_}),t[13]=m,t[14]=h,t[15]=g,t[16]=_,t[17]=v):v=t[17],v}export{C as A,H as C,I as D,R as E,N as M,x as N,g as O,T as P,S,j as T,F as _,u as a,b,p as c,A as d,_ as f,P as g,w as h,B as i,E as j,z as k,D as l,m,v as n,h as o,y as p,d as r,f as s,q as t,M as u,V as v,k as w,O as x,L as y};