@xopcai/xopc 0.0.192 → 0.0.193
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{activity-store-B-tzXpDD.js → activity-store-BwmdJ5pv.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-xOu0qNwc.js → agent-avatar-dicebear-DmNq0t2n.js} +1 -1
- package/dist/gateway/static/root/assets/agents-BOo1rVn9.js +68 -0
- package/dist/gateway/static/root/assets/{api-fMItZb-h.js → api-BM1hNzjw.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-D6Rv3OWI.js → app-management-settings-panel-B3xStqSX.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-CKoNCwco.js → appearance-settings-DglyenDq.js} +1 -1
- package/dist/gateway/static/root/assets/apps-page-DC9qPFTx.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-BokNQBwH.js → archive-plugin-DvtcrBss.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-Dx1HglsM.js → attachment-load-CALdq4xM.js} +1 -1
- package/dist/gateway/static/root/assets/automations-page-BIGGKb0T.js +6 -0
- package/dist/gateway/static/root/assets/{binary-plugins-CPYAflIG.js → binary-plugins-GaVuvrDI.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-BFLgl8SS.js → block-editor-C2KrMYa_.js} +47 -47
- package/dist/gateway/static/root/assets/browser-settings-page-CPW_E-xj.js +8 -0
- package/dist/gateway/static/root/assets/{browser-workflow-inputs-CqLnqA9z.js → browser-workflow-inputs-FfEEjhIS.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-workflows-page-Db5v3HtE.js → browser-workflows-page-DFP9_UQk.js} +2 -2
- package/dist/gateway/static/root/assets/capabilities-settings-panel-CsD8aGHU.js +7 -0
- package/dist/gateway/static/root/assets/{capability-presets-api-lov0J9A2.js → capability-presets-api-BoOzFotX.js} +1 -1
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-NCeyWH6Z.js +3 -0
- package/dist/gateway/static/root/assets/{channel-recipient-api-DSJznouK.js → channel-recipient-api-_8IiTxRB.js} +1 -1
- package/dist/gateway/static/root/assets/channels-settings-CknzwxNC.js +1 -0
- package/dist/gateway/static/root/assets/channels-status-swr-DPaJSYX_.js +1 -0
- package/dist/gateway/static/root/assets/{connectors-api-3ccRyS3L.js → connectors-api-vaSrhPF8.js} +1 -1
- package/dist/gateway/static/root/assets/connectors-page-DEGE7xp_.js +2 -0
- package/dist/gateway/static/root/assets/{cron-expression-C9hhCiuo.js → cron-expression-BjFuXlGY.js} +1 -1
- package/dist/gateway/static/root/assets/{dependency-picker-CTtZFZug.js → dependency-picker-DOdkHdPv.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-DOUeNVmC.js → desktop-pet-Dz-Yf8Uu.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-D4704vtl.js → desktop-pet-settings-C8EHFEtd.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-DJDXeA1B.js → directory-picker-path-field-DKbfmZlZ.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-C0n2NMF1.js → extension-debug-page-Dq0xsr_e.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-vG-xxRNs.js → extension-page-IgSLUyWP.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-CtuY2THd.js → extension-settings-page-VC-8Pjn2.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-api-CZra7GuI.js → gateway-config-api-CH2R7yqo.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-Cz33jRkR.js → gateway-settings-DLQJWaBQ.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-BbVV0udv.js → gateway-startup-retry--2njcDpC.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-settings-D2XMlA_U.js → heartbeat-settings-43loWoGb.js} +1 -1
- package/dist/gateway/static/root/assets/home-page-DqvpI6LC.js +3 -0
- package/dist/gateway/static/root/assets/{image-generation-api-BgrOvhaJ.js → image-generation-api-Cki7jfEV.js} +1 -1
- package/dist/gateway/static/root/assets/{index-DzmbmOGA.js → index-BpkdvHH0.js} +61 -61
- package/dist/gateway/static/root/assets/index-CFVjH-EK.css +1 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-BfyAEG1G.js → keyboard-shortcuts-settings-DJDZes_8.js} +1 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-CvNQM6qm.js +2 -0
- package/dist/gateway/static/root/assets/{local-apps-page-BYalcRSY.js → local-apps-page-C2ajOn1D.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-VOY1wMO9.js → locale-store-Bjvw7jtg.js} +1 -1
- package/dist/gateway/static/root/assets/logs-page-BLm5yWqQ.js +2 -0
- package/dist/gateway/static/root/assets/{management-settings-BQf-6s32.js → management-settings--_eXnFVr.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-split-Cy_2SN1Q.js → markdown-split-iL2oi-x2.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-CkDupqb2.js → media-plugins-BIbkLVpQ.js} +1 -1
- package/dist/gateway/static/root/assets/{messages-DMJ-6-1m.js → messages-DQ5X6cXp.js} +2 -2
- package/dist/gateway/static/root/assets/{notes-page-kiGRR9jo.js → notes-page-xFxaZ6gT.js} +1 -1
- package/dist/gateway/static/root/assets/notes-workbench-PAftxL3V.js +4 -0
- package/dist/gateway/static/root/assets/{page-tabs-CvzSdYVj.js → page-tabs-CROi9zm1.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-kZ0nco7e.js → preview-open-alternatives-BwYcPjOM.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-DgoieqQC.js → product-open-page-BezeuVFd.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-CCdfZcw-.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-DOG9zm5e.js +1 -0
- package/dist/gateway/static/root/assets/remote-access-hub-DQBFgveI.js +1 -0
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-Bud_NTEZ.js → runtime-tools-settings-panel-Bs6tpSyX.js} +2 -2
- package/dist/gateway/static/root/assets/{schema-form-GlbsCBmv.js → schema-form-CWoSjz9s.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-Db6L6M2H.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-CcO2bd6q.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-CKLns16d.js → settings-form-section-BJaMEHsX.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-loading-skeleton-BDzpxgk0.js → settings-loading-skeleton-sn4k17x7.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-BH0pF7QB.js → settings-page-D2hfeFPX.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-layout-J793iqfm.js → settings-page-layout-CLtUsWsu.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-UmQC_uZ1.js +1 -0
- package/dist/gateway/static/root/assets/{share-preview-page-UTm_7r0l.js → share-preview-page-BJ58AluH.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-BZKn6Fdc.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-Cx3i24w_.js +1 -0
- package/dist/gateway/static/root/assets/skills-page-DjUllGtk.js +2 -0
- package/dist/gateway/static/root/assets/{skills-page.utils-Bwid1TGB.js → skills-page.utils-CZYIuE26.js} +1 -1
- package/dist/gateway/static/root/assets/system-settings-panel-DUrgdQMk.js +1 -0
- package/dist/gateway/static/root/assets/task-detail-page-BGG2cFe9.js +1 -0
- package/dist/gateway/static/root/assets/{theme-store-GVZOImyb.js → theme-store-DtxpMC5S.js} +1 -1
- package/dist/gateway/static/root/assets/{typed-models-lib-CT2c85Ju.js → typed-models-lib-CRNMvvFX.js} +1 -1
- package/dist/gateway/static/root/assets/{use-autosave-CcvY7DTh.js → use-autosave-Dle3-zdQ.js} +1 -1
- package/dist/gateway/static/root/assets/user-context-page-BLLmw5S1.js +1 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-Ricc3QGo.js → voice-api-key-field-BrWH0dCl.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-BoomfqhX.js → work-discovery-overlay-BZ1l9CFM.js} +1 -1
- package/dist/gateway/static/root/assets/work-discovery-page-BnPF2vx7.js +1 -0
- package/dist/gateway/static/root/assets/workflow-run-setup-panel-BK6e9yzK.js +3 -0
- package/dist/gateway/static/root/assets/workflows-page-Bp5JxQJa.js +5 -0
- package/dist/gateway/static/root/index.html +7 -7
- package/dist/gateway/static/root/notification-sw.js +15 -0
- package/dist/package.js +1 -1
- package/dist/src/auth/oauth/xopc-cloud.js +163 -7
- package/dist/src/gateway/heartbeat/service.js +1 -1
- package/dist/src/gateway/hono/routes/workflows.js +1 -1
- package/dist/src/gateway/service/run-gateway-agent.js +21 -8
- package/dist/src/heartbeat/index.js +1 -1
- package/package.json +3 -3
- package/dist/gateway/static/root/assets/agents-CxuwvDk0.js +0 -68
- package/dist/gateway/static/root/assets/apps-page-wAb5dnHZ.js +0 -1
- package/dist/gateway/static/root/assets/automations-page-Drgazevs.js +0 -6
- package/dist/gateway/static/root/assets/browser-settings-page-DmYlFJW7.js +0 -8
- package/dist/gateway/static/root/assets/capabilities-settings-panel-D7Z8T0o5.js +0 -7
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-COjnwO0U.js +0 -3
- package/dist/gateway/static/root/assets/channels-settings-DcRYBNN7.js +0 -1
- package/dist/gateway/static/root/assets/channels-status-swr-C2UYdebT.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-FVmvBG9H.js +0 -2
- package/dist/gateway/static/root/assets/home-page-CPrHkPN6.js +0 -3
- package/dist/gateway/static/root/assets/index-Cg7Xnlu3.css +0 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-Clz47vSr.js +0 -2
- package/dist/gateway/static/root/assets/logs-page-Cxq9WMf5.js +0 -2
- package/dist/gateway/static/root/assets/notes-workbench-DkYkPGyB.js +0 -4
- package/dist/gateway/static/root/assets/project-detail-page-CeSjJd-N.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-fZ1rm4b9.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-CbYI6KC8.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-sOJ_TnLm.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-BI0u77dt.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-CGsml89P.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-BM--lgUS.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-CGCOC-rV.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-iLyaOl48.js +0 -2
- package/dist/gateway/static/root/assets/system-settings-panel-BcB3p1e3.js +0 -1
- package/dist/gateway/static/root/assets/task-detail-page-DQYEf08v.js +0 -1
- package/dist/gateway/static/root/assets/user-context-page-CGI41bfO.js +0 -1
- package/dist/gateway/static/root/assets/work-discovery-page-mbnepbQk.js +0 -1
- package/dist/gateway/static/root/assets/workflow-run-setup-panel-DSWG2xqL.js +0 -3
- package/dist/gateway/static/root/assets/workflows-page-DtV0ruyk.js +0 -5
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i,l as a}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as o}from"./cn-JdwAhgNB.js";import{t as s}from"./messages-DMJ-6-1m.js";import{l as c,n as l,o as u,r as d,s as f}from"./locale-store-VOY1wMO9.js";import{i as p}from"./vendor-swr-BIWyz7Rc.js";import{$l as m,$s as h,Ao as g,Bs as _,Do as v,Dr as y,Ea as b,Eo as x,Er as S,Fa as C,Jo as w,Lc as T,Mo as E,Ol as D,Oo as O,Or as k,Ta as A,Vo as j,Wo as M,Yo as N,ac as P,cs as F,dt as I,hs as L,ji as R,jo as z,js as B,ko as ee,lc as te,sr as ne,tu as re,vs as ie,wa as ae}from"./index-DzmbmOGA.js";import{n as oe,r as se}from"./settings-page-layout-J793iqfm.js";import{n as ce}from"./settings-loading-skeleton-BDzpxgk0.js";import{t as le}from"./schema-form-GlbsCBmv.js";import{t as ue}from"./browser-BLJWD7WI.js";import{n as de,t as fe}from"./channels-status-swr-C2UYdebT.js";var V=e(t(),1),H=n();function pe(e){let t=e.actions??{};for(let e of[`login.start`,`setup.start`]){let n=t[e];if(n?.result===`qr`)return[e,n]}let n=Object.entries(t).find(([,e])=>e.result===`qr`);if(n)return n;let r=e.ui?.card?.primaryAction;if(r&&t[r])return[r,t[r]];for(let e of[`login.start`,`setup.start`]){let n=t[e];if(n)return[e,n]}return Object.entries(t).find(([,e])=>e.result===`form`)??null}var me=e(ue(),1),U=r();async function he(e){let t=await u(d(`/api/channels/${encodeURIComponent(e.channelId)}/actions/${encodeURIComponent(e.actionId)}?locale=${encodeURIComponent(e.locale)}`),{method:`POST`,body:JSON.stringify({...e.accountId?{accountId:e.accountId}:{},...e.input===void 0?{}:{input:e.input}})}),n=await t.json().catch(()=>({}));if(!t.ok||n.ok===!1)throw Error(n.error?.message??t.statusText);return n.payload??{type:`ok`}}function W(e){return e?.type===`poll`&&e.phase===`done`}function G(e){return e&&`message`in e&&typeof e.message==`string`?e.message:null}function K(e,t){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrPayload?e.qrPayload:t===`weixin`&&e.qrcodeUrl?e.qrcodeUrl:null}function q(e){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrcodeUrl??null}function ge({entry:e,locale:t,messages:n,onChanged:r,compact:i=!1}){let a=(0,V.useMemo)(()=>pe(e),[e]),s=(0,V.useMemo)(()=>({defaultBooleanLabel:n.schemaBooleanDefault,unsupportedArrayType:n.schemaUnsupportedArrayType,arrayAddPlaceholder:n.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>n.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[n]),[c,l]=(0,V.useState)({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null});(0,V.useEffect)(()=>{l({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null})},[e.id]);let u=(0,V.useCallback)(async(n,i)=>{l(e=>({...e,busy:!0,error:null}));try{let a=await he({channelId:e.id,actionId:n,locale:t,input:i});l(e=>({...e,payload:a,poll:a.type===`qr`&&a.statusAction&&a.sessionKey?{actionId:a.statusAction,sessionKey:a.sessionKey,intervalMs:Math.max(1e3,a.pollIntervalMs??2500)}:null,busy:!1,formDraft:a.type===`form`?a.values??{}:e.formDraft})),`configChanged`in a&&a.configChanged===!0&&await r()}catch(e){l(t=>({...t,busy:!1,error:e instanceof Error?e.message:String(e)}))}},[e.id,t,r]);(0,V.useEffect)(()=>{let t=K(c.payload,e.id);if(!t){l(e=>e.generatedQr?{...e,generatedQr:null}:e);return}let n=!1;return l(e=>e.generatedQr?{...e,generatedQr:null}:e),me.toDataURL(t,{width:220,margin:1}).then(e=>{n||l(t=>({...t,generatedQr:e}))}),()=>{n=!0}},[e.id,c.payload]),(0,V.useEffect)(()=>{let n=c.poll;if(!n)return;let i=!1,a=window.setInterval(()=>{i||he({channelId:e.id,actionId:n.actionId,locale:t,input:{sessionKey:n.sessionKey}}).then(async e=>{i||(l(t=>({...t,payload:e,poll:W(e)?null:t.poll,error:null})),`configChanged`in e&&e.configChanged===!0&&await r(),W(e)&&window.clearInterval(a))}).catch(e=>{i||l(t=>({...t,error:e instanceof Error?e.message:String(e)}))})},n.intervalMs);return()=>{i=!0,window.clearInterval(a)}},[e.id,t,r,c.poll]);let d=a?.[1].label??(e.configured?n.reconnect:n.connect),f=e.actions?.[`doctor.run`]?.label??n.diagnose,p=G(c.payload),h=K(c.payload,e.id),g=h?c.generatedQr:q(c.payload),v=a?.[1].result===`qr`&&(c.busy||c.payload?.type===`qr`||c.payload?.type===`poll`),y=c.payload?.type===`form`?c.payload:null,b=c.payload?.type===`diagnostics`?c.payload.checks:null;return(0,U.jsxs)(`div`,{className:i?`space-y-3`:`rounded-lg bg-surface-panel/80 p-4 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:o(`flex flex-wrap items-start gap-3`,i?`justify-end`:`justify-between`),children:[i?null:(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.setupTitle}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.configured?n.setupConfiguredHint:n.setupEmptyHint})]}),(0,U.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[a?(0,U.jsxs)(L,{type:`button`,variant:`primary`,disabled:c.busy,onClick:()=>void u(a[0]),children:[c.busy?(0,U.jsx)(T,{className:`size-4 animate-spin`}):(0,U.jsx)(te,{className:`size-4`}),d]}):null,e.actions?.[`doctor.run`]?(0,U.jsxs)(L,{type:`button`,variant:`secondary`,disabled:c.busy,onClick:()=>void u(`doctor.run`),children:[(0,U.jsx)(_,{className:`size-4`}),f]}):null]})]}),p?(0,U.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:p}):null,c.error?(0,U.jsx)(`p`,{className:`mt-3 text-sm text-red-600 dark:text-red-400`,children:c.error}):null,v?(0,U.jsxs)(`div`,{className:o(`flex h-80 items-center justify-center gap-4 overflow-hidden rounded-lg bg-surface-base p-3 shadow-surface`,i?`mt-1 flex-col text-center sm:h-64 sm:flex-row sm:text-left`:`mt-4 flex-col sm:h-64 sm:flex-row`),children:[(0,U.jsx)(`div`,{className:`flex size-56 shrink-0 items-center justify-center rounded-lg border border-edge bg-white p-3`,children:g?(0,U.jsx)(`img`,{src:g,alt:`${e.label} setup QR`,className:`size-52 object-contain`}):(0,U.jsx)(`div`,{className:`flex size-52 items-center justify-center rounded-md bg-surface-base`,children:(0,U.jsx)(A,{className:`size-48 rounded-md`})})}),(0,U.jsxs)(`div`,{className:o(`min-w-0 max-w-sm text-sm text-fg-muted`,i&&`w-full sm:w-auto`),children:[g?(0,U.jsx)(`p`,{className:`line-clamp-3`,children:n.waitingConfirmation}):(0,U.jsxs)(`div`,{className:`space-y-2`,"aria-busy":`true`,children:[(0,U.jsx)(A,{className:`h-4 w-48 max-w-full`}),(0,U.jsx)(A,{className:`h-4 w-36 max-w-full`})]}),h?(0,U.jsxs)(`a`,{className:`mt-2 inline-flex items-center gap-1 text-accent hover:underline`,href:h,target:`_blank`,rel:`noreferrer`,children:[n.openSetupLink,(0,U.jsx)(D,{className:`size-3.5`})]}):null]})]}):null,c.payload?.type===`poll`&&c.payload.phase===`done`?(0,U.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 rounded-lg bg-surface-base px-3 py-2 text-sm shadow-surface`,children:[(0,U.jsx)(m,{className:c.payload.ok?`size-4 text-green-600`:`size-4 text-red-600`}),(0,U.jsx)(`span`,{className:c.payload.ok?`text-fg`:`text-red-600 dark:text-red-400`,children:c.payload.message??(c.payload.ok?n.complete:n.failed)})]}):null,y?(0,U.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,U.jsx)(le,{schema:y.schema,values:c.formDraft,onChange:e=>l(t=>({...t,formDraft:e})),disabled:c.busy,labels:s}),(0,U.jsx)(L,{type:`button`,variant:`primary`,disabled:c.busy,onClick:()=>void u(y.submitAction,c.formDraft),children:n.saveSetup})]}):null,b?(0,U.jsx)(`div`,{className:`mt-4 space-y-2`,children:b.map((e,t)=>(0,U.jsxs)(`div`,{className:`rounded-lg bg-surface-base px-3 py-2 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,U.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.label??e.id??n.diagnosticCheckFallback.replace(`{{index}}`,String(t+1))}),(0,U.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e.status??`unknown`})]}),e.message?(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.message}):null]},e.id??t))}):null]})}var _e=40;function J(e){return`ui:route:channel:${e.trim().toLowerCase()}`}function ve(e,t){return e.find(e=>e.id===J(t))?.agentId?.trim().toLowerCase()??``}function ye(e,t,n){let r=J(t),i=e.filter(e=>e.id!==r),a=n.trim().toLowerCase();return a?[...i,{id:r,agentId:a,priority:_e,enabled:!0,match:{channel:t.trim().toLowerCase(),accountId:`*`}}]:i}function be(e){let t=e.configured===!0,n=e.enabled===!0;return e.setupStatus??{enabled:n,ready:t,state:n&&!t?`needs_setup`:n?`ready`:`disabled`,issues:[]}}function xe(e,t,n){let r=be(e);return r.ready?r.enabled?n?t?.connected===!0?`running`:`stopped`:`checking`:`disabled`:`needs_setup`}function Se(e,t=!1){return e===`drawer`?o(`xopc-drawer-right fixed right-0 top-0 flex size-full flex-col overflow-hidden border-l border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`,t?`max-w-[36rem]`:`max-w-xl`,w):o(`fixed left-1/2 top-1/2 flex h-[min(calc(100dvh-2rem),52rem)] w-[min(calc(100%-2rem),32rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,t&&`h-[min(calc(100dvh-2rem),48rem)] w-[min(calc(100%-2rem),36rem)]`,w,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`)}function Ce(e){let t=(0,H.c)(33),{presentation:n,open:r,onOpenChange:i,title:a,description:s,srTitle:c,srDescription:l,closeAriaLabel:u,children:d,footer:f,wide:p,headerExtra:m}=e,h=p===void 0?!1:p,_=n===`drawer`,[y,b]=(0,V.useState)(null),S;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,U.jsx)(g,{className:o(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,N)}),t[0]=S):S=t[0];let C;t[1]!==n||t[2]!==h?(C=Se(n,h),t[1]=n,t[2]=h,t[3]=C):C=t[3];let w;t[4]===c?w=t[5]:(w=c?(0,U.jsx)(E,{className:`sr-only`,children:c}):null,t[4]=c,t[5]=w);let T;t[6]===l?T=t[7]:(T=l?(0,U.jsx)(ee,{className:`sr-only`,children:l}):null,t[6]=l,t[7]=T);let D;t[8]!==u||t[9]!==s||t[10]!==m||t[11]!==_||t[12]!==a?(D=_?(0,U.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[a?(0,U.jsx)(`div`,{className:`text-base font-semibold text-fg`,children:a}):null,s?(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:s}):null]}),(0,U.jsx)(v,{asChild:!0,children:(0,U.jsx)(L,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":u,children:(0,U.jsx)(ie,{className:`size-5`,strokeWidth:1.75})})})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(v,{asChild:!0,children:(0,U.jsx)(`button`,{type:`button`,className:o(F,`absolute right-3 top-3 z-20 p-1.5 hover:bg-surface-hover`),"aria-label":u,children:(0,U.jsx)(ie,{className:`size-4`})})}),m]}),t[8]=u,t[9]=s,t[10]=m,t[11]=_,t[12]=a,t[13]=D):D=t[13];let k=_?`p-4`:`p-6`,A;t[14]===k?A=t[15]:(A=o(`min-h-0 flex-1 overflow-y-auto`,k),t[14]=k,t[15]=A);let j;t[16]!==d||t[17]!==A?(j=(0,U.jsx)(`div`,{className:A,children:d}),t[16]=d,t[17]=A,t[18]=j):j=t[18];let P;t[19]!==f||t[20]!==y||t[21]!==w||t[22]!==T||t[23]!==D||t[24]!==j?(P=(0,U.jsxs)(M,{layer:`modal`,portalContainer:y,children:[w,T,D,j,f]}),t[19]=f,t[20]=y,t[21]=w,t[22]=T,t[23]=D,t[24]=j,t[25]=P):P=t[25];let I;t[26]!==P||t[27]!==C?(I=(0,U.jsxs)(z,{children:[S,(0,U.jsx)(O,{ref:b,className:C,onOpenAutoFocus:we,children:P})]}),t[26]=P,t[27]=C,t[28]=I):I=t[28];let R;return t[29]!==i||t[30]!==r||t[31]!==I?(R=(0,U.jsx)(x,{open:r,onOpenChange:i,children:I}),t[29]=i,t[30]=r,t[31]=I,t[32]=R):R=t[32],R}function we(e){return e.preventDefault()}var Te=(0,V.memo)(function(e){let t=(0,H.c)(10),{ch:n,refreshing:r,saveOk:i,onRefresh:a}=e,o;t[0]!==n.saved||t[1]!==i?(o=i?(0,U.jsx)(`span`,{className:`text-sm text-fg-muted`,children:n.saved}):null,t[0]=n.saved,t[1]=i,t[2]=o):o=t[2];let s;t[3]!==n.refresh||t[4]!==a||t[5]!==r?(s=(0,U.jsx)(R,{className:`size-9 shrink-0 p-0`,loading:r,label:n.refresh,onClick:a}),t[3]=n.refresh,t[4]=a,t[5]=r,t[6]=s):s=t[6];let c;return t[7]!==o||t[8]!==s?(c=(0,U.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center justify-end gap-2`,children:[o,s]}),t[7]=o,t[8]=s,t[9]=c):c=t[9],c});function Ee(e){let t=(0,H.c)(24),{ch:n,dirty:r,saving:i,onCancel:a,onDiscard:o,onSave:s,showCancel:c}=e,l=c===void 0?!0:c,u;t[0]!==n.unsavedHint||t[1]!==r?(u=r?(0,U.jsx)(`p`,{className:`mb-3 text-xs text-amber-800 dark:text-amber-200`,children:n.unsavedHint}):null,t[0]=n.unsavedHint,t[1]=r,t[2]=u):u=t[2];let d;t[3]!==n.modalCancel||t[4]!==a||t[5]!==l?(d=l?(0,U.jsx)(L,{type:`button`,variant:`secondary`,onClick:a,children:n.modalCancel}):null,t[3]=n.modalCancel,t[4]=a,t[5]=l,t[6]=d):d=t[6];let f=!r||i,p;t[7]!==n.discard||t[8]!==o||t[9]!==f?(p=(0,U.jsx)(L,{type:`button`,variant:`secondary`,disabled:f,onClick:o,children:n.discard}),t[7]=n.discard,t[8]=o,t[9]=f,t[10]=p):p=t[10];let m=!r||i,h;t[11]===s?h=t[12]:(h=()=>void s(),t[11]=s,t[12]=h);let g=i?n.saving:n.save,_;t[13]!==m||t[14]!==h||t[15]!==g?(_=(0,U.jsx)(L,{type:`button`,variant:`primary`,disabled:m,onClick:h,children:g}),t[13]=m,t[14]=h,t[15]=g,t[16]=_):_=t[16];let v;t[17]!==d||t[18]!==p||t[19]!==_?(v=(0,U.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[d,p,_]}),t[17]=d,t[18]=p,t[19]=_,t[20]=v):v=t[20];let y;return t[21]!==v||t[22]!==u?(y=(0,U.jsxs)(`div`,{className:`sticky bottom-0 shrink-0 border-t border-edge-subtle bg-surface-panel px-6 py-4 dark:border-edge-subtle`,children:[u,v]}),t[21]=v,t[22]=u,t[23]=y):y=t[23],y}function De(e){return d(`/api/channels/catalog?locale=${encodeURIComponent(e)}`)}async function Oe(e){return(await f(De(e))).payload?.channels??[]}function ke(e,t){let n=(0,H.c)(14),r;n[0]!==e||n[1]!==t?(r=e?De(t):null,n[0]=e,n[1]=t,n[2]=r):r=n[2];let i;n[3]===t?i=n[4]:(i=()=>Oe(t),n[3]=t,n[4]=i);let a;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(a={revalidateOnFocus:!1},n[5]=a):a=n[5];let{data:o,error:s,isLoading:c,isValidating:l,mutate:u}=p(r,i,a),d;n[6]===o?d=n[7]:(d=o??[],n[6]=o,n[7]=d);let f;return n[8]!==s||n[9]!==c||n[10]!==l||n[11]!==u||n[12]!==d?(f={entries:d,isLoading:c,isValidating:l,error:s,mutate:u},n[8]=s,n[9]=c,n[10]=l,n[11]=u,n[12]=d,n[13]=f):f=n[13],f}var Ae=`channels-status`;function je(e){if(!e||typeof e!=`object`)return null;let t=e.channels;return Array.isArray(t)?t:null}function Me(e){let t=t=>e(t.detail);return window.addEventListener(Ae,t),()=>window.removeEventListener(Ae,t)}function Ne(e,t){let n=(0,H.c)(4),r=t===void 0?!0:t,i,a;n[0]!==r||n[1]!==e?(i=()=>{if(r)return Me(e)},a=[r,e],n[0]=r,n[1]=e,n[2]=i,n[3]=a):(i=n[2],a=n[3]),(0,V.useEffect)(i,a)}function Pe(e){return e?d(`/api/channels/${encodeURIComponent(e)}/config`):null}async function Fe(e){return(await f(d(`/api/channels/${encodeURIComponent(e)}/config`))).payload?.config??{}}var Ie=[`enabled`];async function Le(){let e=await f(d(`/api/config`));return{channels:e.payload?.config?.channels??{},bindings:e.payload?.config?.bindings??[]}}function Re(e){return e.split(`/`).filter(Boolean).map(e=>encodeURIComponent(e)).join(`/`)}function ze(e){return e.configPath.startsWith(`channels.`)&&e.configPath.slice(9).split(`.`)[0]||e.id}function Y(e){let t=e.configured===!0,n=e.enabled===!0;return e.setupStatus??{enabled:n,ready:t,state:n&&!t?`needs_setup`:n?`ready`:`disabled`,issues:[]}}function Be(e,t){return e===`running`?t.connectionRunning:e===`stopped`?t.connectionStopped:e===`checking`?t.connectionChecking:e===`disabled`?t.connectionDisabled:t.connectionNeedsSetup}function Ve(e,t){return e===`running`?t.connectionRunningHint:e===`stopped`?t.connectionStoppedHint:e===`disabled`?t.connectionDisabledHint:e===`needs_setup`?t.connectionNeedsSetupHint:t.connectionChecking}function He(e){return e===`running`?`bg-emerald-500/12 text-emerald-700 dark:text-emerald-300`:e===`stopped`?`bg-red-500/10 text-red-700 dark:text-red-300`:e===`checking`?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:e===`disabled`?`bg-surface-hover text-fg-muted`:`bg-amber-500/10 text-amber-700 dark:text-amber-300`}function Ue(e){if(!e)return[];let t=e.uiHints??{},n=X(e.configSchema)&&Array.isArray(e.configSchema.required)?e.configSchema.required.map(String):[],r=Y(e).issues.map(e=>e.fieldPath).filter(e=>!!e),i=Object.entries(t).filter(([,e])=>!X(e)||e.advanced===!0?!1:(Array.isArray(e.tags)?e.tags.map(String):[]).includes(`basic`)||e.advanced===!1).map(([e])=>e).filter(e=>!Ie.includes(e));return Array.from(new Set([...i,...n,...r])).filter(e=>!Ie.includes(e))}function X(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Z(e){return JSON.parse(JSON.stringify(e??{type:`object`,properties:{}}))}function We(e,t){let n={...Z(e),properties:{}};for(let r of t){let t=r.split(`.`),i=e,a=n;for(let[e,n]of t.entries()){let r=i.properties;if(!X(r)||!X(r[n]))break;let o=X(a.properties)?a.properties:{};if(a.properties=o,o[n]||(o[n]={...Z(r[n]),properties:{}}),e===t.length-1){o[n]=Z(r[n]);break}i=r[n],a=o[n]}}return n}function Ge(e){let t=e.properties;if(!X(t))return!1;for(let[e,n]of Object.entries(t))X(n)&&n.type===`object`&&Ge(n)&&delete t[e];return Object.keys(t).length===0}function Ke(e,t){let n=Z(e);for(let e of t){let t=e.split(`.`),r=n;for(let[e,n]of t.entries()){let i=r.properties;if(!X(i))break;if(e===t.length-1){delete i[n];break}if(!X(i[n]))break;r=i[n]}}return Ge(n),n}function qe(e){return e.type===`object`&&X(e.properties)&&Object.keys(e.properties).length>0}function Je(e,t){let n=e;for(let e of t.split(`.`)){if(!X(n))return;n=n[e]}return n}function Ye(e){let t=e.accounts;return X(t)?Object.values(t).filter(e=>X(e)&&e.enabled!==!1).length:+(e.configured===!0)}function Q(e,t,n){return t==null||t===``?null:e.toLowerCase().includes(`dmpolicy`)&&typeof t==`string`?`${n.dmPolicy}: ${n.policy.dm[t]??t}`:(e.toLowerCase().includes(`stream`)||e.toLowerCase().includes(`streaming`))&&typeof t==`string`?`${n.cardStream}: ${n.policy.stream[t]??t}`:typeof t==`boolean`?t?n.enabledLabel:n.disabledLabel:String(t)}function Xe(e,t,n){let r=[],i=Y(e);if(i.issues.length>0&&r.push(et(i.issues[0],n)),t){let i=e.ui?.card?.summaryFields??[`dmPolicy`,`streamMode`,`streaming.mode`];for(let e of i){let i=Q(e,Je(t,e),n);i&&r.push(i)}let a=Ye(t);a>0&&r.push(n.cardAccounts.replace(`{{count}}`,String(a)))}return r.length>0?r.slice(0,2):i.ready?[n.hubStatusConfigured]:[]}function Ze(e,t){let n=Y(e),r=pe(e);return n.state===`needs_setup`?r?.[1].label??t.completeSetup:!n.enabled&&n.ready?t.enableChannel:n.state===`error`?t.diagnose:n.ready?t.manageChannel:r?.[1].label??t.startConfiguration}function Qe(e,t){let n=pe(e);return n?.[1].result===`qr`?t.cardSetupQrHint:n?.[1].result===`form`?t.cardSetupConfigHint:t.cardSetupGenericHint}function $e(e,t){let n=e.capabilities??{},r=[];return n.login===!0&&r.push(t.cardCapabilityLogin),n.pairing===!0&&r.push(t.cardCapabilityPairing),n.multiAccount===!0&&r.push(t.cardCapabilityMultiAccount),n.streaming===!0&&r.push(t.cardCapabilityStreaming),n.media===!0&&r.push(t.cardCapabilityMedia),n.doctor===!0&&r.push(t.cardCapabilityDoctor),r.slice(0,3)}function et(e,t){return e.code===`telegram.missing_credential`?t.setupIssueTelegramMissingCredential:e.code===`weixin.missing_account`?t.setupIssueWeixinMissingAccount:e.code===`feishu.missing_credentials`?t.setupIssueFeishuMissingCredentials:e.code===`config.missing_required`&&e.fieldPath?t.setupIssueMissingRequired.replace(`{{field}}`,e.fieldPath):e.message}function tt({entry:e}){let t=c(e=>e.token),[n,r]=(0,V.useState)(!1),i=(0,V.useMemo)(()=>{if(!e.ui?.icon||n)return null;let r=new URL(d(`/api/extensions/${encodeURIComponent(e.extensionId)}/assets/${Re(e.ui.icon)}`));return t?.trim()&&r.searchParams.set(`token`,t.trim()),r.toString()},[n,e.extensionId,e.ui?.icon,t]);return(0,U.jsx)(`span`,{className:`flex size-12 shrink-0 items-center justify-center rounded-2xl bg-surface-base text-fg`,children:i?(0,U.jsx)(`img`,{src:i,alt:``,draggable:!1,className:`size-7`,"aria-hidden":!0,onError:()=>r(!0)}):(0,U.jsx)(b,{sourceChannel:e.id,className:`size-7`})})}function nt(e){let t=(0,H.c)(16),{checked:n,disabled:r,onToggle:i,label:a}=e,s;t[0]===i?s=t[1]:(s=e=>{e.stopPropagation(),i()},t[0]=i,t[1]=s);let c=n?`border-accent bg-accent`:`border-edge bg-surface-hover`,l=r&&`cursor-not-allowed opacity-60`,u;t[2]!==c||t[3]!==l?(u=o(`relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border transition-colors`,c,l),t[2]=c,t[3]=l,t[4]=u):u=t[4];let d=n?`translate-x-5`:`translate-x-0.5`,f;t[5]===d?f=t[6]:(f=o(`size-5 rounded-full bg-white shadow-surface transition-transform`,d),t[5]=d,t[6]=f);let p;t[7]===f?p=t[8]:(p=(0,U.jsx)(`span`,{className:f}),t[7]=f,t[8]=p);let m;return t[9]!==n||t[10]!==r||t[11]!==a||t[12]!==s||t[13]!==u||t[14]!==p?(m=(0,U.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":n,"aria-label":a,disabled:r,onClick:s,className:u,children:p}),t[9]=n,t[10]=r,t[11]=a,t[12]=s,t[13]=u,t[14]=p,t[15]=m):m=t[15],m}function rt(e){let t=(0,H.c)(71),{entry:n,config:r,runtime:i,busy:a,restarting:s,ch:c,onOpen:l,onToggle:u,onRestart:d}=e,f;t[0]===n?f=t[1]:(f=Y(n),t[0]=n,t[1]=f);let p=f,m,h,g,_,v,y,b;if(t[2]!==a||t[3]!==c||t[4]!==r||t[5]!==n||t[6]!==l||t[7]!==d||t[8]!==u||t[9]!==i||t[10]!==p.enabled||t[11]!==p.ready){let e=Xe(n,r,c),s=$e(n,c);m=!p.enabled&&p.ready?u:i===`stopped`?d:l,y=`flex min-h-[15.5rem] flex-col rounded-xl bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45`;let f;t[19]===n?f=t[20]:(f=(0,U.jsx)(tt,{entry:n}),t[19]=n,t[20]=f);let x;t[21]===n.label?x=t[22]:(x=(0,U.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:n.label}),t[21]=n.label,t[22]=x);let S;t[23]===i?S=t[24]:(S=o(`mt-1 inline-flex rounded-full px-2 py-0.5 text-xs font-medium`,He(i)),t[23]=i,t[24]=S);let C;t[25]!==c||t[26]!==i?(C=Be(i,c),t[25]=c,t[26]=i,t[27]=C):C=t[27];let w;t[28]!==S||t[29]!==C?(w=(0,U.jsx)(`span`,{className:S,children:C}),t[28]=S,t[29]=C,t[30]=w):w=t[30];let T;t[31]!==w||t[32]!==x?(T=(0,U.jsxs)(`div`,{className:`min-w-0`,children:[x,w]}),t[31]=w,t[32]=x,t[33]=T):T=t[33];let E;t[34]!==T||t[35]!==f?(E=(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[f,T]}),t[34]=T,t[35]=f,t[36]=E):E=t[36];let D=p.enabled,O;t[37]!==c.toggleChannel||t[38]!==n.label?(O=c.toggleChannel.replace(`{{channel}}`,n.label),t[37]=c.toggleChannel,t[38]=n.label,t[39]=O):O=t[39];let k;t[40]!==a||t[41]!==u||t[42]!==p.enabled||t[43]!==O?(k=(0,U.jsx)(nt,{checked:D,disabled:a,label:O,onToggle:u}),t[40]=a,t[41]=u,t[42]=p.enabled,t[43]=O,t[44]=k):k=t[44],t[45]!==E||t[46]!==k?(b=(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[E,k]}),t[45]=E,t[46]=k,t[47]=b):b=t[47],h=`button`,g=l,_=`mt-5 min-h-[6.25rem] text-left`,v=p.ready?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`p`,{className:`line-clamp-2 text-sm leading-6 text-fg-muted`,children:n.description??n.id}),e.length>0?(0,U.jsx)(`div`,{className:`mt-3 space-y-0.5 text-sm leading-5 text-fg-muted`,children:e.map($)}):null]}):(0,U.jsxs)(`div`,{className:`rounded-lg bg-surface-base p-3`,children:[(0,U.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:c.cardSetupTitle}),(0,U.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm leading-5 text-fg-muted`,children:e[0]??Qe(n,c)}),s.length>0?(0,U.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:s.map(it)}):null]}),t[2]=a,t[3]=c,t[4]=r,t[5]=n,t[6]=l,t[7]=d,t[8]=u,t[9]=i,t[10]=p.enabled,t[11]=p.ready,t[12]=m,t[13]=h,t[14]=g,t[15]=_,t[16]=v,t[17]=y,t[18]=b}else m=t[12],h=t[13],g=t[14],_=t[15],v=t[16],y=t[17],b=t[18];let x;t[48]!==h||t[49]!==g||t[50]!==_||t[51]!==v?(x=(0,U.jsx)(`button`,{type:h,onClick:g,className:_,children:v}),t[48]=h,t[49]=g,t[50]=_,t[51]=v,t[52]=x):x=t[52];let S=a||s,C;t[53]!==a||t[54]!==s?(C=a||s?(0,U.jsx)(T,{className:`size-4 animate-spin`}):null,t[53]=a,t[54]=s,t[55]=C):C=t[55];let w;t[56]!==c||t[57]!==n||t[58]!==s||t[59]!==i?(w=s?c.restartingChannel:i===`stopped`?c.restartChannel:Ze(n,c),t[56]=c,t[57]=n,t[58]=s,t[59]=i,t[60]=w):w=t[60];let E;t[61]!==m||t[62]!==C||t[63]!==w||t[64]!==S?(E=(0,U.jsx)(`div`,{className:`mt-auto pt-4`,children:(0,U.jsxs)(L,{type:`button`,variant:`secondary`,className:`w-full rounded-2xl py-2.5`,onClick:m,disabled:S,children:[C,w]})}),t[61]=m,t[62]=C,t[63]=w,t[64]=S,t[65]=E):E=t[65];let D;return t[66]!==E||t[67]!==y||t[68]!==b||t[69]!==x?(D=(0,U.jsxs)(`article`,{className:y,children:[b,x,E]}),t[66]=E,t[67]=y,t[68]=b,t[69]=x,t[70]=D):D=t[70],D}function it(e){return(0,U.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e},e)}function $(e){return(0,U.jsx)(`p`,{className:`truncate`,title:e,children:e},e)}function at(e){let t=(0,H.c)(51),{runtime:n,restarting:r,checking:i,showConnectionOptions:a,canManageConnection:s,ch:c,onRestart:l,onCheck:u,onManageConnection:d}=e,f=n===`running`?m:n===`stopped`||n===`needs_setup`?re:T,p=n===`running`&&`text-emerald-600 dark:text-emerald-400`,h=n===`stopped`&&`text-red-600 dark:text-red-400`,g=n===`checking`&&`animate-spin text-amber-600 dark:text-amber-400`,_=n===`disabled`&&`text-fg-muted`,v=n===`needs_setup`&&`text-amber-600 dark:text-amber-400`,y;t[0]!==p||t[1]!==h||t[2]!==g||t[3]!==_||t[4]!==v?(y=o(`mt-0.5 size-5 shrink-0`,p,h,g,_,v),t[0]=p,t[1]=h,t[2]=g,t[3]=_,t[4]=v,t[5]=y):y=t[5];let b;t[6]!==f||t[7]!==y?(b=(0,U.jsx)(f,{className:y}),t[6]=f,t[7]=y,t[8]=b):b=t[8];let x;t[9]===c.connectionStatus?x=t[10]:(x=(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:c.connectionStatus}),t[9]=c.connectionStatus,t[10]=x);let S;t[11]!==c||t[12]!==n?(S=Ve(n,c),t[11]=c,t[12]=n,t[13]=S):S=t[13];let C;t[14]===S?C=t[15]:(C=(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:S}),t[14]=S,t[15]=C);let w;t[16]!==C||t[17]!==x?(w=(0,U.jsxs)(`div`,{children:[x,C]}),t[16]=C,t[17]=x,t[18]=w):w=t[18];let E;t[19]!==w||t[20]!==b?(E=(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[b,w]}),t[19]=w,t[20]=b,t[21]=E):E=t[21];let D=i||r,O;t[22]===i?O=t[23]:(O=i?(0,U.jsx)(T,{className:`size-4 animate-spin`}):null,t[22]=i,t[23]=O);let k=i?c.checkingConnection:c.checkConnection,A;t[24]!==u||t[25]!==D||t[26]!==O||t[27]!==k?(A=(0,U.jsxs)(L,{type:`button`,variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:D,onClick:u,children:[O,k]}),t[24]=u,t[25]=D,t[26]=O,t[27]=k,t[28]=A):A=t[28];let j;t[29]!==c.restartChannel||t[30]!==c.restartingChannel||t[31]!==i||t[32]!==l||t[33]!==r||t[34]!==n?(j=n===`stopped`?(0,U.jsxs)(L,{type:`button`,variant:`primary`,className:`px-2.5 py-1.5 text-xs`,disabled:r||i,onClick:l,children:[r?(0,U.jsx)(T,{className:`size-4 animate-spin`}):(0,U.jsx)(P,{className:`size-4`}),r?c.restartingChannel:c.restartChannel]}):null,t[29]=c.restartChannel,t[30]=c.restartingChannel,t[31]=i,t[32]=l,t[33]=r,t[34]=n,t[35]=j):j=t[35];let M;t[36]!==s||t[37]!==c.connectionOptions||t[38]!==c.hideConnectionOptions||t[39]!==i||t[40]!==d||t[41]!==r||t[42]!==a?(M=s?(0,U.jsx)(L,{type:`button`,variant:`ghost`,className:`px-2.5 py-1.5 text-xs`,disabled:i||r,onClick:d,children:a?c.hideConnectionOptions:c.connectionOptions}):null,t[36]=s,t[37]=c.connectionOptions,t[38]=c.hideConnectionOptions,t[39]=i,t[40]=d,t[41]=r,t[42]=a,t[43]=M):M=t[43];let N;t[44]!==A||t[45]!==j||t[46]!==M?(N=(0,U.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 F;return t[48]!==E||t[49]!==N?(F=(0,U.jsx)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:(0,U.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[E,N]})}),t[48]=E,t[49]=N,t[50]=F):F=t[50],F}function ot(e){let t=(0,H.c)(33),{entry:n,ch:r}=e,i,a,o,s,c,l,u,d,f;if(t[0]!==r||t[1]!==n){f=Symbol.for(`react.early_return_sentinel`);bb0:{let e=Y(n);if(e.ready||e.issues.length===0){f=null;break bb0}d=`rounded-xl border border-amber-200 bg-amber-50 px-4 py-3 text-amber-950 dark:border-amber-900/50 dark:bg-amber-950/30 dark:text-amber-100`,l=`flex items-start gap-3`,t[11]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,U.jsx)(B,{className:`mt-0.5 size-4 shrink-0`}),t[11]=u):u=t[11],o=`min-w-0`,t[12]===r.setupReadinessTitle?s=t[13]:(s=(0,U.jsx)(`h3`,{className:`text-sm font-semibold`,children:r.setupReadinessTitle}),t[12]=r.setupReadinessTitle,t[13]=s);let p=e.enabled?r.setupReadinessEnabledBody:r.setupReadinessDisabledBody;t[14]===p?c=t[15]:(c=(0,U.jsx)(`p`,{className:`mt-1 text-sm leading-5 text-amber-900 dark:text-amber-200`,children:p}),t[14]=p,t[15]=c),i=`mt-2 list-disc space-y-1 pl-5 text-sm text-amber-900 dark:text-amber-200`;let m;t[16]===r?m=t[17]:(m=e=>(0,U.jsx)(`li`,{children:et(e,r)},`${e.code}:${e.fieldPath??``}`),t[16]=r,t[17]=m),a=e.issues.map(m)}t[0]=r,t[1]=n,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=f}else i=t[2],a=t[3],o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10];if(f!==Symbol.for(`react.early_return_sentinel`))return f;let p;t[18]!==i||t[19]!==a?(p=(0,U.jsx)(`ul`,{className:i,children:a}),t[18]=i,t[19]=a,t[20]=p):p=t[20];let m;t[21]!==p||t[22]!==o||t[23]!==s||t[24]!==c?(m=(0,U.jsxs)(`div`,{className:o,children:[s,c,p]}),t[21]=p,t[22]=o,t[23]=s,t[24]=c,t[25]=m):m=t[25];let h;t[26]!==m||t[27]!==l||t[28]!==u?(h=(0,U.jsxs)(`div`,{className:l,children:[u,m]}),t[26]=m,t[27]=l,t[28]=u,t[29]=h):h=t[29];let g;return t[30]!==h||t[31]!==d?(g=(0,U.jsx)(`section`,{className:d,children:h}),t[30]=h,t[31]=d,t[32]=g):g=t[32],g}function st(){let e=l(e=>e.language),t=s(e),n=c(e=>!!e.token),r=a(),{channelId:f}=i(),m=k(f),g=ke(n,e),_=g.entries,{data:v,mutate:b,isValidating:x}=p(n?fe():null,de,{revalidateOnFocus:!0}),{data:w,mutate:T}=p(n?`channels-config-map`:null,Le,{revalidateOnFocus:!1}),E=w?.channels??{},O=w?.bindings??[],{data:A}=p(n?`channel-routing-agents`:null,ae,{revalidateOnFocus:!1}),M=C(e=>e.setPageHeader),N=C(e=>e.clearPageHeader),P=(0,V.useMemo)(()=>_.find(e=>e.id===m),[m,_]),F=P?ze(P):null,{data:L,mutate:R}=p(n&&F?Pe(F):null,()=>Fe(F)),[z,B]=(0,V.useState)(null),[ee,te]=(0,V.useState)(!1),[re,ie]=(0,V.useState)(null),[ue,H]=(0,V.useState)(null),[me,he]=(0,V.useState)(!1),[W,G]=(0,V.useState)(null),[K,q]=(0,V.useState)(null),_e=z??L??{},J=t.channelsSettings,be=(0,V.useMemo)(()=>P?.configSchema??{type:`object`,properties:{}},[P?.configSchema]),Se=(0,V.useMemo)(()=>Ke(be,Ie),[be]),we=(0,V.useMemo)(()=>Ue(P),[P]),De=(0,V.useMemo)(()=>We(Se,we),[we,Se]),Oe=(0,V.useMemo)(()=>Ke(Se,we),[we,Se]),Ae=(0,V.useMemo)(()=>qe(De),[De]),Me=P?K??ve(O,P.id):``,Re=(0,V.useMemo)(()=>(A?.items??[]).map(e=>{let n=ne(e,t.agentsSettings);return{value:e.id,label:n===e.id?n:`${n} · ${e.id}`}}),[A?.items,t.agentsSettings]),Ve=A?.items.find(e=>e.id===A.defaultId),X=Ve?ne(Ve,t.agentsSettings):A?.defaultId??``,Z=(0,V.useMemo)(()=>({defaultBooleanLabel:J.schemaBooleanDefault,unsupportedArrayType:J.schemaUnsupportedArrayType,arrayAddPlaceholder:J.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>J.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[J]),Ge=(0,V.useMemo)(()=>new Map((v??[]).map(e=>[e.name,e])),[v]),Je=v!==void 0,Ye=(0,V.useCallback)(e=>xe(e,Ge.get(e.id),Je),[Ge,Je]),Q=(0,V.useCallback)(async()=>{await Promise.all([g.mutate(),b()])},[g,b]);Ne((0,V.useCallback)(e=>{let t=je(e);t&&b(t,!1)},[b]),n);let Xe=(0,V.useMemo)(()=>n?(0,U.jsx)(Te,{ch:J,refreshing:g.isValidating||x,saveOk:!1,onRefresh:()=>void Q()}):null,[g.isValidating,J,n,x,Q]);(0,V.useLayoutEffect)(()=>(M({startExtra:null,main:(0,U.jsx)(`div`,{className:`min-w-0`,children:(0,U.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.settingsSections.channels})}),end:Xe}),()=>N()),[N,Xe,t.settingsSections.channels,M]);let Ze=(0,V.useCallback)(e=>{r(y(e)),B(null),q(null),G(null)},[r]),Qe=(0,V.useCallback)(()=>{r(S),B(null),q(null),G(null)},[r]),$e=(0,V.useCallback)(async e=>{H(e.id),G(null);try{let t=await u(d(`/api/channels/${encodeURIComponent(e.id)}/restart`),{method:`POST`});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}await Q()}catch(e){G(e instanceof Error?e.message:String(e))}finally{H(null)}},[Q]);(0,V.useEffect)(()=>{q(null),he(!1)},[P?.id]);let et=(0,V.useCallback)(async()=>{if(!P||!z&&K===null)return!1;let e=ze(P);te(!0),G(null);try{let t=await u(d(`/api/config`),{method:`PATCH`,body:JSON.stringify({...z?{channels:{[e]:z}}:{},...K===null?{}:{bindings:ye(O,P.id,K)}})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}return z&&await R(z,!1),await T(),await g.mutate(),B(null),q(null),!0}catch(e){return G(e instanceof Error?e.message:String(e)),!1}finally{te(!1)}},[P,K,O,g,z,T,R]),it=(0,V.useCallback)(async e=>{let t=Y(e),n=ze(e),r=P?.id===e.id?z:null;if(!t.enabled&&!t.ready&&!r){Ze(e.id);return}ie(e.id),G(null);try{let i=t.enabled?{enabled:!1}:r?{...r,enabled:!0}:{enabled:!0},a=await u(d(`/api/config`),{method:`PATCH`,body:JSON.stringify({channels:{[n]:i}})});if(!a.ok){let e=await a.json().catch(()=>({}));throw Error(e.error?.message??a.statusText)}await g.mutate(),await T(),await b(),P?.id===e.id&&(await R(),B(null))}catch(e){G(e instanceof Error?e.message:String(e))}finally{ie(null)}},[P?.id,g,z,T,R,b,Ze]),$=P?.ui?.modal,st=$?.placement!==`replace-config`,ct=P?Ye(P):`checking`,lt=P?!Y(P).ready||me:!1;return n?(0,U.jsxs)(se,{gap:`gap-4`,children:[g.isLoading?(0,U.jsx)(ce,{sections:2}):g.error?(0,U.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:String(g.error)}):(0,U.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:_.map(e=>(0,U.jsx)(rt,{entry:e,config:E[ze(e)]?.config,runtime:Ye(e),busy:re===e.id,restarting:ue===e.id,ch:J,onOpen:()=>Ze(e.id),onToggle:()=>void it(e),onRestart:()=>void $e(e)},e.id))}),W?(0,U.jsx)(`p`,{className:`mt-4 text-sm text-red-600 dark:text-red-400`,children:W}):null,(0,U.jsx)(Ce,{presentation:`modal`,open:!!P,onOpenChange:e=>{e||Qe()},closeAriaLabel:J.close,srTitle:P?.label??J.selectChannel,srDescription:P?.description,wide:!0,footer:P?(0,U.jsx)(Ee,{ch:J,dirty:!!z||K!==null,saving:ee,onCancel:Qe,onDiscard:()=>{B(null),q(null)},onSave:et}):null,children:P?(0,U.jsxs)(`div`,{className:`space-y-4`,children:[(0,U.jsx)(`div`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,children:(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,U.jsx)(tt,{entry:P}),(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,U.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:P.label}),(0,U.jsx)(`span`,{className:o(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,He(ct)),children:Be(ct,J)})]}),(0,U.jsxs)(`div`,{className:`mt-1 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-sm text-fg-muted`,children:[(0,U.jsx)(`span`,{className:`min-w-0 truncate`,children:!Y(P).ready&&pe(P)?.[1].result===`qr`?J.scanLoginHint.replace(`{{channel}}`,P.label):P.description}),P.docsPath?(0,U.jsxs)(`a`,{href:P.docsPath,target:`_blank`,rel:`noreferrer`,className:`inline-flex shrink-0 items-center gap-1 text-accent hover:underline`,children:[J.docs,(0,U.jsx)(D,{className:`size-3.5`})]}):null]})]})]}),(0,U.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pr-8`,children:[(0,U.jsx)(`span`,{className:`hidden text-xs text-fg-muted sm:inline`,children:Y(P).enabled?J.enabledLabel:J.disabledLabel}),(0,U.jsx)(nt,{checked:Y(P).enabled,disabled:re===P.id,label:J.toggleChannel.replace(`{{channel}}`,P.label),onToggle:()=>void it(P)})]})]})}),(0,U.jsx)(at,{runtime:ct,restarting:ue===P.id,checking:x,showConnectionOptions:me,canManageConnection:Y(P).ready&&$?.placement!==`replace-config`,ch:J,onRestart:()=>void $e(P),onCheck:()=>void Q(),onManageConnection:()=>he(e=>!e)}),(0,U.jsx)(ot,{entry:P,ch:J}),lt&&$?.placement!==`replace-config`?(0,U.jsx)(ge,{entry:P,locale:e,messages:J,compact:!0,onChanged:async()=>{await R(),await Q(),await T()}},P.id):null,$?.entrypoint&&$.placement===`before-config`?(0,U.jsx)(I,{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,U.jsx)(I,{extensionId:P.extensionId,extensionName:P.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:P.id,entry:P,config:_e}}):null,st&&Ae?(0,U.jsxs)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:`mb-4`,children:[(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:J.basicConfiguration}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:J.basicConfigurationHint})]}),(0,U.jsx)(le,{schema:De,values:_e,onChange:e=>B(e),disabled:ee,labels:Z})]}):null,(0,U.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,U.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,U.jsx)(h,{className:`size-4 text-fg-muted`}),J.messageHandling]}),(0,U.jsxs)(`div`,{className:`bg-surface-base/50 p-4`,children:[(0,U.jsxs)(`div`,{className:`mb-3`,children:[(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:J.agentRouting}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:J.messageHandlingHint})]}),(0,U.jsx)(j,{value:Me,options:Re,placeholder:J.agentRoutingSelect,emptyLabel:J.agentRoutingDefault.replace(`{{agent}}`,X||J.agentRoutingSelect),ariaLabel:J.agentRouting,disabled:ee||!A,onChange:e=>q(e)})]})]}),st&&qe(Oe)?(0,U.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,U.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,U.jsx)(h,{className:`size-4 text-fg-muted`}),J.advancedConfiguration]}),(0,U.jsx)(`div`,{className:`bg-surface-base/50 p-4`,children:(0,U.jsx)(le,{schema:Oe,values:_e,onChange:e=>B(e),disabled:ee,labels:Z})})]}):null,W?(0,U.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:W}):null]}):null})]}):(0,U.jsxs)(se,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,U.jsx)(oe,{title:t.settingsSections.channels}),(0,U.jsx)(`p`,{className:`text-sm text-fg-muted`,children:J.tokenRequired})]})}export{st as ChannelsSettingsPanel};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./locale-store-VOY1wMO9.js";import{n as t}from"./channel-recipient-api-DSJznouK.js";function n(){return e(`/api/channels/status`)}var r=t;export{r as n,n as t};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{f as i,l as a}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as o}from"./check-DUBLcKHA.js";import{t as s}from"./cn-JdwAhgNB.js";import{n as c}from"./copy-to-clipboard-HOJ79TWv.js";import{t as l}from"./messages-DMJ-6-1m.js";import{l as u,n as d,r as f,s as p}from"./locale-store-VOY1wMO9.js";import{$l as m,$s as h,Ao as g,Cl as _,Cs as v,Do as y,Eo as b,Fa as x,Gr as S,Hl as C,Ho as w,Jo as T,Kr as E,Lc as D,Mo as O,Ms as k,Nl as A,No as j,Ol as M,Oo as N,Qc as P,Rs as F,Tc as I,Ul as L,Uo as R,Vo as z,Vs as B,Wr as V,Xs as H,Yo as ee,Yr as U,di as te,do as ne,ec as re,fi as ie,fo as ae,gc as W,hs as G,iu as oe,ji as se,jo as ce,ko as le,li as ue,ls as de,mc as fe,ms as pe,nc as me,oc as he,os as ge,pc as _e,pi as ve,qr as ye,rc as be,tu as xe,ui as Se,vs as Ce,ys as K}from"./index-DzmbmOGA.js";import{t as we}from"./page-tabs-CvzSdYVj.js";import{A as q,C as J,D as Y,E as Te,M as Ee,N as De,O as Oe,P as ke,S as Ae,T as je,_ as Me,a as Ne,b as Pe,c as Fe,d as Ie,f as Le,g as Re,h as ze,i as Be,j as Ve,k as He,l as Ue,m as We,n as Ge,o as Ke,p as qe,r as Je,s as Ye,t as Xe,u as Ze,v as Qe,w as $e,x as et,y as tt}from"./connectors-api-3ccRyS3L.js";var X=n(),Z=e(t(),1),Q=r(),nt={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 rt(e){let t=(0,X.c)(18),{connector:n,size:r,className:i}=e,a=r===void 0?`md`:r,o=n?.branding?.logoUrl,[c,l]=(0,Z.useState)(!1),u=nt[a],d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=()=>{l(!1)},t[0]=d):d=t[0];let f;t[1]===o?f=t[2]:(f=[o],t[1]=o,t[2]=f),(0,Z.useEffect)(d,f);let p;t[3]!==i||t[4]!==u.frame?(p=s(`flex shrink-0 items-center justify-center overflow-hidden border border-edge bg-surface-base`,u.frame,i),t[3]=i,t[4]=u.frame,t[5]=p):p=t[5];let m;t[6]===n?m=t[7]:(m=n?.branding?.backgroundColor?{backgroundColor:n.branding.backgroundColor}:void 0,t[6]=n,t[7]=m);let h=n?.displayName,g;t[8]!==u.fallback||t[9]!==u.image||t[10]!==c||t[11]!==o?(g=o&&!c?(0,Q.jsx)(`img`,{src:o,alt:``,loading:`lazy`,draggable:!1,className:s(`object-contain`,u.image),onError:()=>l(!0)}):(0,Q.jsx)(I,{className:s(`text-fg-muted`,u.fallback),"aria-hidden":!0}),t[8]=u.fallback,t[9]=u.image,t[10]=c,t[11]=o,t[12]=g):g=t[12];let _;return t[13]!==p||t[14]!==m||t[15]!==h||t[16]!==g?(_=(0,Q.jsx)(`span`,{className:p,style:m,title:h,children:g}),t[13]=p,t[14]=m,t[15]=h,t[16]=g,t[17]=_):_=t[17],_}function it(e){let t=(0,X.c)(74),{connector:n,installed:r,onInstall:i,onOpenDetails:a,t:o}=e,c,l,u,d,f,p,h,g,_,v;if(t[0]!==n||t[1]!==r||t[2]!==i||t[3]!==a||t[4]!==o.connect||t[5]!==o.connectedBadge||t[6]!==o.connectorBeta||t[7]!==o.connectorCapabilityLabels||t[8]!==o.connectorExperimental||t[9]!==o.connectorVerified){let e=n.capabilities.filter(at),y=e.slice(0,3),b=Math.max(0,e.length-y.length),x=o.connect,S=n.verificationLevel===`verified`?o.connectorVerified:n.verificationLevel===`beta`?o.connectorBeta:n.verificationLevel===`experimental`?o.connectorExperimental:null,C;t[20]!==x||t[21]!==n||t[22]!==i?(C=e=>(0,Q.jsxs)(G,{type:`button`,variant:`primary`,className:s(`h-8 justify-center px-2.5 text-xs font-medium`,e),onClick:e=>{e.stopPropagation(),i(n)},children:[(0,Q.jsx)(I,{className:`size-4`}),x]}),t[20]=x,t[21]=n,t[22]=i,t[23]=C):C=t[23],c=C;let w;t[24]!==n||t[25]!==a?(w=e=>{!a||e.currentTarget!==e.target||e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),a(n))},t[24]=n,t[25]=a,t[26]=w):w=t[26];let T=w,E=a?`cursor-pointer`:null;t[27]===E?p=t[28]:(p=s(`group flex min-h-[9.5rem] flex-col rounded-lg bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45 focus-within:ring-2 focus-within:ring-accent/30`,E),t[27]=E,t[28]=p),h=a?`button`:void 0,g=a?0:void 0,t[29]!==n||t[30]!==a?(_=()=>a?.(n),t[29]=n,t[30]=a,t[31]=_):_=t[31],v=T,l=`flex min-w-0 flex-1 flex-col`;let D;t[32]===n?D=t[33]:(D=(0,Q.jsx)(rt,{connector:n}),t[32]=n,t[33]=D);let O;t[34]===n.displayName?O=t[35]:(O=(0,Q.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:n.displayName}),t[34]=n.displayName,t[35]=O);let k;t[36]===S?k=t[37]:(k=S?(0,Q.jsx)(`span`,{className:`mt-1 inline-flex rounded-full border border-edge px-1.5 py-0.5 text-[10px] font-medium text-fg-subtle`,children:S}):null,t[36]=S,t[37]=k);let A;t[38]!==O||t[39]!==k?(A=(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[O,k]}),t[38]=O,t[39]=k,t[40]=A):A=t[40];let j;t[41]!==D||t[42]!==A?(j=(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[D,A]}),t[41]=D,t[42]=A,t[43]=j):j=t[43];let M;t[44]!==r||t[45]!==c?(M=r?null:(0,Q.jsx)(`div`,{className:`hidden shrink-0 items-center gap-1 transition-opacity sm:pointer-events-none sm:flex sm:opacity-0 sm:group-hover:pointer-events-auto sm:group-hover:opacity-100 sm:group-focus-within:pointer-events-auto sm:group-focus-within:opacity-100`,children:c()}),t[44]=r,t[45]=c,t[46]=M):M=t[46];let N;t[47]!==r||t[48]!==o.connectedBadge?(N=r?(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-emerald-500/30 bg-emerald-500/10 px-2 py-0.5 text-[11px] font-medium text-emerald-700 dark:text-emerald-300`,children:[(0,Q.jsx)(m,{className:`size-3`,"aria-hidden":!0}),o.connectedBadge]}):null,t[47]=r,t[48]=o.connectedBadge,t[49]=N):N=t[49];let P;t[50]!==M||t[51]!==N?(P=(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-start gap-2`,children:[M,N]}),t[50]=M,t[51]=N,t[52]=P):P=t[52],t[53]!==j||t[54]!==P?(u=(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[j,P]}),t[53]=j,t[54]=P,t[55]=u):u=t[55],t[56]===n.description?d=t[57]:(d=(0,Q.jsx)(`p`,{className:`mt-4 line-clamp-2 text-sm leading-6 text-fg-muted`,title:n.description,children:n.description}),t[56]=n.description,t[57]=d),f=y.length>0?(0,Q.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-1.5`,children:[y.map(e=>(0,Q.jsx)(`span`,{className:`rounded-md bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:o.connectorCapabilityLabels[e]??e},e)),b>0?(0,Q.jsxs)(`span`,{className:`rounded-md bg-surface-base px-2 py-0.5 text-[11px] text-fg-subtle`,children:[`+`,b]}):null]}):null,t[0]=n,t[1]=r,t[2]=i,t[3]=a,t[4]=o.connect,t[5]=o.connectedBadge,t[6]=o.connectorBeta,t[7]=o.connectorCapabilityLabels,t[8]=o.connectorExperimental,t[9]=o.connectorVerified,t[10]=c,t[11]=l,t[12]=u,t[13]=d,t[14]=f,t[15]=p,t[16]=h,t[17]=g,t[18]=_,t[19]=v}else c=t[10],l=t[11],u=t[12],d=t[13],f=t[14],p=t[15],h=t[16],g=t[17],_=t[18],v=t[19];let y;t[58]!==l||t[59]!==u||t[60]!==d||t[61]!==f?(y=(0,Q.jsxs)(`div`,{className:l,children:[u,d,f]}),t[58]=l,t[59]=u,t[60]=d,t[61]=f,t[62]=y):y=t[62];let b;t[63]!==r||t[64]!==c?(b=r?null:(0,Q.jsx)(`div`,{className:`mt-4 flex flex-col gap-2 border-t border-edge pt-3 sm:hidden`,children:c(`w-full`)}),t[63]=r,t[64]=c,t[65]=b):b=t[65];let x;return t[66]!==y||t[67]!==b||t[68]!==p||t[69]!==h||t[70]!==g||t[71]!==_||t[72]!==v?(x=(0,Q.jsxs)(`div`,{className:p,role:h,tabIndex:g,onClick:_,onKeyDown:v,children:[y,b]}),t[66]=y,t[67]=b,t[68]=p,t[69]=h,t[70]=g,t[71]=_,t[72]=v,t[73]=x):x=t[73],x}function at(e){return!e.startsWith(`runtime.`)&&!e.startsWith(`auth.`)}var ot=[`c0`,`c1`,`c2`,`c3`,`c4`,`c5`];function st(e,t){return t.some(t=>t.connectorId===e.id)}var ct=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`;function lt(){let e=(0,X.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Q.jsx)(`div`,{className:s(`size-10 shrink-0 rounded-xl`,ct)}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Q.jsx)(`div`,{className:`flex h-full min-h-[9.5rem] flex-col rounded-xl bg-surface-panel p-4 shadow-surface`,"aria-hidden":!0,children:(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 items-start gap-3`,children:[t,(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,Q.jsx)(`div`,{className:s(`h-4 min-w-0 flex-1`,ct)}),(0,Q.jsx)(`div`,{className:s(`h-8 w-[4.5rem] shrink-0 rounded-lg`,ct)})]}),(0,Q.jsx)(`div`,{className:s(`h-3 w-full`,ct)}),(0,Q.jsx)(`div`,{className:s(`h-3 w-[88%]`,ct)})]})]})}),e[1]=n):n=e[1],n}var ut=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`;function dt(){let e=(0,X.c)(4),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,Q.jsx)(`div`,{className:s(`size-10 shrink-0 rounded-xl`,ut)}),e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2`,children:[(0,Q.jsx)(`div`,{className:s(`h-4 w-48 max-w-full`,ut)}),(0,Q.jsx)(`div`,{className:s(`h-3 w-72 max-w-full`,ut)})]}),e[1]=n):n=e[1];let r;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[t,(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-start justify-between gap-3`,children:[n,(0,Q.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,Q.jsx)(`div`,{className:s(`h-9 w-20 rounded-lg`,ut)}),(0,Q.jsx)(`div`,{className:s(`h-9 w-20 rounded-lg`,ut)})]})]})]}),e[2]=r):r=e[2];let i;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Q.jsxs)(`div`,{className:`rounded-2xl bg-surface-panel p-4 shadow-surface`,"aria-hidden":!0,children:[r,(0,Q.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,Q.jsx)(`div`,{className:s(`h-8 w-20 rounded-md`,ut)}),(0,Q.jsx)(`div`,{className:s(`h-8 w-24 rounded-md`,ut)}),(0,Q.jsx)(`div`,{className:s(`h-8 w-28 rounded-md`,ut)})]}),(0,Q.jsx)(`div`,{className:s(`mt-3 h-20 rounded-xl`,ut)})]}),e[3]=i):i=e[3],i}function ft(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,String(n)),e)}function pt(e,t){return t.connectorCapabilityLabels[e]??e}function mt(e,t){if(e.runtime.type===`mcp`)return ft(t.connectorRuntimeMcp,{serverId:e.runtime.serverId});let n=e.runtime.type===`composio`?e.runtime.toolkit:e.runtime.type===`channel`?e.runtime.channelId:e.runtime.type===`nativeTool`?e.runtime.toolsetId:e.runtime.sourceKind;return ft(t.connectorRuntimeGeneric,{runtime:e.runtime.type,id:n??e.runtime.type})}function ht(e,t){return e.auth.mode===`oauth`?t.connectorAuthOAuth:e.auth.mode===`apiKey`?t.connectorAuthApiKey:t.connectorAuthNone}function gt(e){return(e.setup.secrets??[]).filter(e=>e.required).length+(e.setup.config??[]).filter(e=>e.required).length}function _t(e){let t=(0,X.c)(12),{title:n,items:r}=e;if(r.length===0)return null;let i;t[0]===n?i=t[1]:(i=(0,Q.jsx)(`div`,{className:`border-b border-edge px-3 py-2 text-xs font-semibold text-fg`,children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=r.slice(0,16).map(vt),t[2]=r,t[3]=a);let o;t[4]===r.length?o=t[5]:(o=r.length>16?(0,Q.jsxs)(`div`,{className:`px-3 py-2 text-xs text-fg-subtle`,children:[`+`,r.length-16]}):null,t[4]=r.length,t[5]=o);let s;t[6]!==a||t[7]!==o?(s=(0,Q.jsxs)(`div`,{className:`max-h-48 overflow-y-auto`,children:[a,o]}),t[6]=a,t[7]=o,t[8]=s):s=t[8];let c;return t[9]!==i||t[10]!==s?(c=(0,Q.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base`,children:[i,s]}),t[9]=i,t[10]=s,t[11]=c):c=t[11],c}function vt(e){return(0,Q.jsxs)(`div`,{className:`border-b border-edge-subtle px-3 py-2 last:border-b-0`,children:[(0,Q.jsx)(`div`,{className:`break-words font-mono text-xs font-medium text-fg`,children:e.title}),e.description?(0,Q.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:e.description}):null]},e.id)}function yt({connector:e,installed:t,onClose:n,onInstall:r,t:i}){let[a,o]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(null),[u,d]=(0,Z.useState)(null),f=gt(e),p=e.capabilities.slice(0,8),h=Math.max(0,e.capabilities.length-p.length),_=[...(e.setup.secrets??[]).map(e=>({key:`secret:${e.key}`,label:e.label,description:e.description,required:e.required,kind:i.connectorSetupSecret})),...(e.setup.config??[]).map(e=>({key:`config:${e.key}`,label:e.label,description:e.description,required:!!e.required,kind:i.connectorSetupConfig}))],v=async()=>{o(!0),d(null);try{l(await Pe(e))}catch(e){l(null),d(e instanceof Error?e.message:String(e))}finally{o(!1)}};return(0,Q.jsx)(b,{open:!0,onOpenChange:e=>{e||n()},children:(0,Q.jsxs)(ce,{children:[(0,Q.jsx)(g,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,Q.jsxs)(N,{className:s(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(100vh-2rem,44rem)] w-[min(100%-2rem,min(92vw,52rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-panel shadow-float outline-none dark:border-edge`),children:[(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,Q.jsx)(rt,{connector:e,size:`lg`}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[t?(0,Q.jsx)(`div`,{className:`mb-2 flex flex-wrap items-center gap-2`,children:(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-emerald-500/30 bg-emerald-500/10 px-2 py-0.5 text-[11px] font-medium text-emerald-700 dark:text-emerald-300`,children:[(0,Q.jsx)(m,{className:`size-3`,"aria-hidden":!0}),i.connectedBadge]})}):null,(0,Q.jsx)(O,{className:`text-base font-semibold text-fg`,children:e.displayName}),(0,Q.jsx)(le,{className:`mt-1 line-clamp-3 text-sm leading-6 text-fg-muted`,children:e.description})]})]}),(0,Q.jsx)(y,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,className:s(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,de.focusRingPanel),"aria-label":i.modalClose,children:[(0,Q.jsx)(Ce,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`sr-only`,children:i.modalClose})]})})]}),(0,Q.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:[(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,Q.jsx)(K,{className:`size-3.5`,"aria-hidden":!0}),i.detailTools]}),(0,Q.jsx)(`p`,{className:`mt-2 text-sm font-semibold text-fg`,children:c?ft(i.connectorPreviewToolsCount,{count:c.toolCount}):i.connectorPreviewUnknown})]}),(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,Q.jsx)(P,{className:`size-3.5`,"aria-hidden":!0}),i.detailPermissions]}),(0,Q.jsx)(`p`,{className:`mt-2 text-sm font-semibold text-fg`,children:ht(e,i)})]}),(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,Q.jsx)(A,{className:`size-3.5`,"aria-hidden":!0}),i.connectorRequiredInputs]}),(0,Q.jsx)(`p`,{className:`mt-2 text-sm font-semibold text-fg`,children:ft(i.connectorRequiredInputsCount,{count:f})})]})]}),(0,Q.jsxs)(`div`,{className:`mt-5 grid gap-5 lg:grid-cols-[minmax(0,1fr)_18rem]`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 space-y-5`,children:[(0,Q.jsxs)(`section`,{children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:i.connectorCapabilitiesTitle}),(0,Q.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:[p.map(e=>(0,Q.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-base px-2 py-1 text-xs text-fg-muted`,children:pt(e,i)},e)),h>0?(0,Q.jsxs)(`span`,{className:`rounded-md border border-edge bg-surface-base px-2 py-1 text-xs text-fg-subtle`,children:[`+`,h]}):null]})]}),u?(0,Q.jsx)(`p`,{className:`rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:u}):null,c?(0,Q.jsxs)(`section`,{children:[(0,Q.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:i.connectorPreviewTitle}),(0,Q.jsx)(`span`,{className:s(`rounded-full px-2 py-0.5 text-xs font-medium`,c.ok?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-amber-500/10 text-amber-700 dark:text-amber-300`),children:c.ok?i.healthStatusHealthy:i.healthStatusLabels[c.status]??c.status})]}),(0,Q.jsxs)(`div`,{className:`mb-3 grid gap-2 text-xs sm:grid-cols-3`,children:[(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base px-3 py-2`,children:[(0,Q.jsx)(`div`,{className:`font-semibold text-fg`,children:c.toolCount}),(0,Q.jsx)(`div`,{className:`text-fg-muted`,children:i.toolsMetric})]}),(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base px-3 py-2`,children:[(0,Q.jsx)(`div`,{className:`font-semibold text-fg`,children:c.resourceCount}),(0,Q.jsx)(`div`,{className:`text-fg-muted`,children:i.resourcesMetric})]}),(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base px-3 py-2`,children:[(0,Q.jsx)(`div`,{className:`font-semibold text-fg`,children:c.promptCount}),(0,Q.jsx)(`div`,{className:`text-fg-muted`,children:i.promptsMetric})]})]}),(0,Q.jsxs)(`div`,{className:`grid gap-2`,children:[(0,Q.jsx)(_t,{title:i.detailTools,items:c.tools.map(e=>({id:e.name,title:e.shortName??e.name,description:e.description}))}),(0,Q.jsx)(_t,{title:i.detailResources,items:c.resources.map(e=>({id:e.uri,title:e.title??e.name??e.uri,description:e.description??e.uri}))}),(0,Q.jsx)(_t,{title:i.detailPrompts,items:c.prompts.map(e=>({id:e.name,title:e.title??e.name,description:e.description??ft(i.promptArgumentCount,{count:e.argumentCount})}))})]}),c.error?(0,Q.jsx)(`p`,{className:`mt-3 text-xs leading-5 text-fg-subtle`,children:c.error}):null,c.action?(0,Q.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-subtle`,children:c.action}):null]}):null]}),(0,Q.jsxs)(`aside`,{className:`space-y-3`,children:[(0,Q.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,Q.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,Q.jsx)(P,{className:`size-4 text-accent`,"aria-hidden":!0}),i.detailPermissions]}),(0,Q.jsx)(`p`,{className:`mt-2 text-sm font-medium text-fg`,children:ht(e,i)})]}),(0,Q.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,Q.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,Q.jsx)(A,{className:`size-4 text-accent`,"aria-hidden":!0}),i.connectorSetupTitle]}),_.length>0?(0,Q.jsx)(`div`,{className:`mt-3 divide-y divide-edge overflow-hidden rounded-lg border border-edge`,children:_.map(e=>(0,Q.jsxs)(`div`,{className:`bg-surface-panel px-3 py-2.5`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.label}),(0,Q.jsx)(`span`,{className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[11px] text-fg-muted`,children:e.kind}),e.required?(0,Q.jsx)(`span`,{className:`rounded-md bg-amber-500/10 px-1.5 py-0.5 text-[11px] font-medium text-amber-700 dark:text-amber-300`,children:i.connectorSetupRequired}):null]}),e.description?(0,Q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:e.description}):null]},e.key))}):(0,Q.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:i.connectorSetupNone})]}),(0,Q.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,Q.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,Q.jsx)(re,{className:`size-4 text-accent`,"aria-hidden":!0}),i.connectorRuntimeTitle]}),(0,Q.jsx)(`p`,{className:`mt-2 break-words text-xs leading-5 text-fg-muted`,children:mt(e,i)})]})]})]})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[(0,Q.jsx)(y,{asChild:!0,children:(0,Q.jsx)(G,{variant:`secondary`,children:i.modalClose})}),(0,Q.jsxs)(G,{variant:`secondary`,disabled:a,onClick:()=>void v(),children:[a?(0,Q.jsx)(D,{className:`size-4 animate-spin`}):(0,Q.jsx)(K,{className:`size-4`}),i.connectorPreviewButton]}),t?(0,Q.jsxs)(G,{variant:`secondary`,disabled:!0,children:[(0,Q.jsx)(W,{className:`size-4`}),i.connectedBadge]}):(0,Q.jsxs)(G,{variant:`primary`,onClick:()=>{r(e),n()},children:[(0,Q.jsx)(I,{className:`size-4`}),i.connect]})]})]})]})})}var bt=s(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,pe);function xt(e){let t=(0,X.c)(58),{open:n,sessionIdleTtlMinutes:r,saving:i,onChange:a,onSave:o,onClose:c,t:l,mcp:u}=e,d;t[0]===c?d=t[1]:(d=e=>{e||c()},t[0]=c,t[1]=d);let f;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,Q.jsx)(g,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),t[2]=f):f=t[2];let p;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(p=s(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(32rem,calc(100vh-2rem))] w-[min(100%-2rem,38rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-panel shadow-float dark:border-edge`),t[3]=p):p=t[3];let m;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Q.jsx)(`span`,{className:`flex size-10 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-accent-fg`,children:(0,Q.jsx)(fe,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0})}),t[4]=m):m=t[4];let h;t[5]===l.runtimeSettingsTitle?h=t[6]:(h=(0,Q.jsx)(O,{className:`text-base font-semibold text-fg`,children:l.runtimeSettingsTitle}),t[5]=l.runtimeSettingsTitle,t[6]=h);let _;t[7]===l.runtimeSettingsHint?_=t[8]:(_=(0,Q.jsx)(le,{className:`mt-1 text-sm text-fg-muted`,children:l.runtimeSettingsHint}),t[7]=l.runtimeSettingsHint,t[8]=_);let v;t[9]!==h||t[10]!==_?(v=(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[m,(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[h,_]})]}),t[9]=h,t[10]=_,t[11]=v):v=t[11];let x;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(x=s(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,de.focusRingPanel),t[12]=x):x=t[12];let S;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,Q.jsx)(Ce,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),t[13]=S):S=t[13];let C;t[14]===l.modalClose?C=t[15]:(C=(0,Q.jsx)(y,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,className:x,"aria-label":l.modalClose,children:S})}),t[14]=l.modalClose,t[15]=C);let w;t[16]!==C||t[17]!==v?(w=(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[v,C]}),t[16]=C,t[17]=v,t[18]=w):w=t[18];let T;t[19]===u.idleTtlLabel?T=t[20]:(T=(0,Q.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:u.idleTtlLabel}),t[19]=u.idleTtlLabel,t[20]=T);let E;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(E=s(bt,`w-40 flex-none`),t[21]=E):E=t[21];let k=r??``,A;t[22]===a?A=t[23]:(A=e=>{let t=e.currentTarget.value.trim();a(t===``?void 0:Number.parseInt(t,10))},t[22]=a,t[23]=A);let j;t[24]!==u.idleTtlPlaceholder||t[25]!==k||t[26]!==A?(j=(0,Q.jsx)(`input`,{type:`number`,min:0,className:E,value:k,placeholder:u.idleTtlPlaceholder,onChange:A}),t[24]=u.idleTtlPlaceholder,t[25]=k,t[26]=A,t[27]=j):j=t[27];let M;t[28]===u.idleTtlHint?M=t[29]:(M=(0,Q.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:u.idleTtlHint}),t[28]=u.idleTtlHint,t[29]=M);let P;t[30]!==T||t[31]!==j||t[32]!==M?(P=(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:(0,Q.jsxs)(`label`,{className:`flex max-w-xl flex-col gap-1.5`,children:[T,j,M]})}),t[30]=T,t[31]=j,t[32]=M,t[33]=P):P=t[33];let F;t[34]!==c||t[35]!==i||t[36]!==l.modalCancel?(F=(0,Q.jsx)(G,{type:`button`,variant:`secondary`,disabled:i,onClick:c,children:l.modalCancel}),t[34]=c,t[35]=i,t[36]=l.modalCancel,t[37]=F):F=t[37];let I;t[38]===o?I=t[39]:(I=()=>void o(),t[38]=o,t[39]=I);let L;t[40]===i?L=t[41]:(L=i?(0,Q.jsx)(D,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,t[40]=i,t[41]=L);let R;t[42]!==u.save||t[43]!==i||t[44]!==I||t[45]!==L?(R=(0,Q.jsxs)(G,{type:`button`,variant:`primary`,disabled:i,onClick:I,children:[L,u.save]}),t[42]=u.save,t[43]=i,t[44]=I,t[45]=L,t[46]=R):R=t[46];let z;t[47]!==F||t[48]!==R?(z=(0,Q.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[F,R]}),t[47]=F,t[48]=R,t[49]=z):z=t[49];let B;t[50]!==w||t[51]!==P||t[52]!==z?(B=(0,Q.jsxs)(ce,{children:[f,(0,Q.jsxs)(N,{className:p,children:[w,P,z]})]}),t[50]=w,t[51]=P,t[52]=z,t[53]=B):B=t[53];let V;return t[54]!==n||t[55]!==d||t[56]!==B?(V=(0,Q.jsx)(b,{open:n,onOpenChange:d,children:B}),t[54]=n,t[55]=d,t[56]=B,t[57]=V):V=t[57],V}var St=(0,Z.memo)(function(e){let t=(0,X.c)(12),{value:n,onChange:r,placeholder:i,className:a}=e,o;t[0]===a?o=t[1]:(o=s(`relative flex min-h-9 min-w-0 flex-1 cursor-text items-center rounded-pill border border-edge bg-surface-panel py-1.5 pl-9 pr-3 shadow-surface`,a),t[0]=a,t[1]=o);let c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,Q.jsx)(me,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-disabled`,strokeWidth:1.75,"aria-hidden":!0}),t[2]=c):c=t[2];let l;t[3]===r?l=t[4]:(l=e=>r(e.currentTarget.value),t[3]=r,t[4]=l);let u;t[5]!==i||t[6]!==l||t[7]!==n?(u=(0,Q.jsx)(`input`,{type:`search`,enterKeyHint:`search`,value:n,onChange:l,placeholder:i,autoComplete:`off`,spellCheck:!1,className:`min-w-0 flex-1 appearance-none border-0 bg-transparent py-0.5 text-sm leading-normal text-fg caret-current placeholder:text-fg-disabled focus:border-0 focus:shadow-none focus:outline-none focus:ring-0 focus-visible:outline-none`}),t[5]=i,t[6]=l,t[7]=n,t[8]=u):u=t[8];let d;return t[9]!==o||t[10]!==u?(d=(0,Q.jsxs)(`label`,{className:o,children:[c,u]}),t[9]=o,t[10]=u,t[11]=d):d=t[11],d}),Ct=(0,Z.memo)(function(e){let t=(0,X.c)(30),{onBrowseCatalog:n,onAddCustomServer:r,onOpenRuntimeSettings:i,addLabel:a,browseLabel:o,customLabel:c,settingsLabel:l}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,Q.jsx)(h,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[0]=u):u=t[0];let d;t[1]===l?d=t[2]:(d=(0,Q.jsx)(`span`,{className:`hidden sm:inline`,children:l}),t[1]=l,t[2]=d);let f;t[3]!==i||t[4]!==l||t[5]!==d?(f=(0,Q.jsxs)(G,{type:`button`,variant:`secondary`,className:`shrink-0 gap-2`,"aria-label":l,title:l,onClick:i,children:[u,d]}),t[3]=i,t[4]=l,t[5]=d,t[6]=f):f=t[6];let p;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Q.jsx)(_e,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[7]=p):p=t[7];let m;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Q.jsx)(oe,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[8]=m):m=t[8];let g;t[9]===a?g=t[10]:(g=(0,Q.jsx)(U,{asChild:!0,children:(0,Q.jsxs)(G,{type:`button`,variant:`primary`,className:`shrink-0 gap-2`,children:[p,a,m]})}),t[9]=a,t[10]=g);let _;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(_=s(`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none data-[highlighted]:bg-surface-hover`,de.transition),t[11]=_):_=t[11];let v;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Q.jsx)(F,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[12]=v):v=t[12];let y;t[13]!==o||t[14]!==n?(y=(0,Q.jsxs)(S,{className:_,onSelect:n,children:[v,o]}),t[13]=o,t[14]=n,t[15]=y):y=t[15];let b;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(b=s(`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none data-[highlighted]:bg-surface-hover`,de.transition),t[16]=b):b=t[16];let x;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,Q.jsx)(K,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[17]=x):x=t[17];let C;t[18]!==c||t[19]!==r?(C=(0,Q.jsxs)(S,{className:b,onSelect:r,children:[x,c]}),t[18]=c,t[19]=r,t[20]=C):C=t[20];let w;t[21]!==C||t[22]!==y?(w=(0,Q.jsx)(E,{children:(0,Q.jsxs)(V,{className:`z-50 min-w-[14rem] rounded-xl border border-edge bg-surface-panel p-1 shadow-popover dark:border-edge`,sideOffset:6,align:`end`,children:[y,C]})}),t[21]=C,t[22]=y,t[23]=w):w=t[23];let T;t[24]!==w||t[25]!==g?(T=(0,Q.jsxs)(ye,{children:[g,w]}),t[24]=w,t[25]=g,t[26]=T):T=t[26];let D;return t[27]!==T||t[28]!==f?(D=(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center justify-end gap-2`,children:[f,T]}),t[27]=T,t[28]=f,t[29]=D):D=t[29],D}),wt=/^([^:=]+)[:=](.*)$/;function Tt(e){let t=e.trim();if(!t)return null;try{let e=JSON.parse(t);if(e&&typeof e==`object`&&!Array.isArray(e))return Object.entries(e).map(([e,t])=>({key:e,value:t==null?``:String(t)}))}catch{}let n=[];for(let e of t.split(/\r?\n/)){let t=e.trim();if(!t)continue;let r=wt.exec(t);r&&n.push({key:r[1].trim(),value:r[2].trim()})}return n.length>0?n:null}function Et(e){let t={};for(let n of e){let e=n.key.trim();e&&(t[e]=n.value)}return Object.keys(t).length>0?t:void 0}function Dt(e){if(!e||typeof e!=`object`)return[{key:``,value:``}];let t=Object.entries(e).map(([e,t])=>({key:e,value:t==null?``:String(t)}));return t.length>0?t:[{key:``,value:``}]}function Ot(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e.xopcConnector;return!!(t&&typeof t==`object`&&!Array.isArray(t)&&t.managed===!0)}function kt(e){let t=e&&typeof e==`object`&&`mcp`in e?e.mcp:void 0,n=(t&&typeof t==`object`?t:{}).servers,r={};if(!n||typeof n!=`object`||Array.isArray(n))return r;for(let[e,t]of Object.entries(n))!t||typeof t!=`object`||Array.isArray(t)||Ot(t)&&(r[e]=t);return r}function At(e){let t=e.trim();if(t)return t.split(/\s+/).filter(Boolean)}function jt(e){let t=e.trim();if(!t)return;let n=JSON.parse(t);if(!n||typeof n!=`object`||Array.isArray(n))throw Error(`Expected a JSON object`);return n}function Mt(e){if(e.transport===`stdio`){let t={command:e.command.trim()},n=At(e.argsText);return n?.length&&(t.args=n),e.cwd.trim()&&(t.cwd=e.cwd.trim()),e.envJson.trim()&&(t.env=jt(e.envJson)),e.connectionTimeoutMs!=null&&Number.isFinite(e.connectionTimeoutMs)&&(t.connectionTimeoutMs=e.connectionTimeoutMs),e.requestTimeoutMs!=null&&Number.isFinite(e.requestTimeoutMs)&&(t.requestTimeoutMs=e.requestTimeoutMs),t}let t={url:e.url.trim(),transport:e.transport},n=Et(e.headers);return n&&(t.headers=n),e.connectionTimeoutMs!=null&&Number.isFinite(e.connectionTimeoutMs)&&(t.connectionTimeoutMs=e.connectionTimeoutMs),e.requestTimeoutMs!=null&&Number.isFinite(e.requestTimeoutMs)&&(t.requestTimeoutMs=e.requestTimeoutMs),t}function Nt(e,t){let n=typeof t.url==`string`&&t.url.trim().length>0,r=typeof t.transport==`string`?t.transport.trim().toLowerCase():``,i=n?r===`sse`?`sse`:`streamable-http`:`stdio`,a=t.headers&&typeof t.headers==`object`&&!Array.isArray(t.headers)?t.headers:void 0;return{clientKey:e,id:e,transport:i,command:typeof t.command==`string`?t.command:``,argsText:Array.isArray(t.args)?t.args.map(String).join(` `):``,envJson:t.env&&typeof t.env==`object`?JSON.stringify(t.env,null,2):``,cwd:typeof t.cwd==`string`?t.cwd:typeof t.workingDirectory==`string`?t.workingDirectory:``,url:typeof t.url==`string`?t.url:``,headers:Dt(a),connectionTimeoutMs:typeof t.connectionTimeoutMs==`number`&&Number.isFinite(t.connectionTimeoutMs)?t.connectionTimeoutMs:void 0,requestTimeoutMs:typeof t.requestTimeoutMs==`number`&&Number.isFinite(t.requestTimeoutMs)?t.requestTimeoutMs:void 0}}function Pt(e=``){return{clientKey:crypto.randomUUID(),id:e,transport:`stdio`,command:``,argsText:``,envJson:``,cwd:``,url:``,headers:[{key:`Authorization`,value:``}],connectionTimeoutMs:void 0,requestTimeoutMs:void 0}}function Ft(e){let t=e&&typeof e==`object`&&`mcp`in e?e.mcp:void 0,n=t&&typeof t==`object`?t:{},r=n.servers,i=r&&typeof r==`object`&&!Array.isArray(r)?Object.entries(r).flatMap(([e,t])=>!t||typeof t!=`object`||Array.isArray(t)||Ot(t)?[]:[Nt(e,t)]).sort((e,t)=>e.id.localeCompare(t.id)):[],a=typeof n.sessionIdleTtlMs==`number`?n.sessionIdleTtlMs:void 0;return{sessionIdleTtlMinutes:a==null?void 0:a===0?0:Math.round(a/6e4),servers:i}}function It(e){return Mt(e)}async function Lt(e,t={}){let n={};for(let r of e.servers){let e=r.id.trim();if(e){if(t[e])throw Error(`Server id "${e}" is reserved by an installed connector.`);n[e]=Mt(r)}}let r={servers:{...t,...n}};e.sessionIdleTtlMinutes!=null&&Number.isFinite(e.sessionIdleTtlMinutes)&&(r.sessionIdleTtlMs=e.sessionIdleTtlMinutes===0?0:Math.round(e.sessionIdleTtlMinutes*6e4)),await p(f(`/api/config`),{method:`PATCH`,body:JSON.stringify({mcp:r})}),ne()}function Rt(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(typeof n==`string`){let e=n.trim();e&&t.push({name:e});continue}if(!n||typeof n!=`object`)continue;let e=n;if(typeof e.name!=`string`)continue;let r=e.name.trim();if(!r)continue;let i=typeof e.shortName==`string`&&e.shortName.trim()?e.shortName.trim():void 0,a=typeof e.description==`string`&&e.description.trim()?e.description.trim():void 0;t.push({name:r,shortName:i,description:a})}return t}function zt(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(!n||typeof n!=`object`)continue;let e=n;if(typeof e.uri!=`string`||typeof e.name!=`string`)continue;let r=e.uri.trim(),i=e.name.trim();!r||!i||t.push({uri:r,name:i,title:typeof e.title==`string`&&e.title.trim()?e.title.trim():void 0,description:typeof e.description==`string`&&e.description.trim()?e.description.trim():void 0,mimeType:typeof e.mimeType==`string`&&e.mimeType.trim()?e.mimeType.trim():void 0})}return t}function Bt(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(!n||typeof n!=`object`)continue;let e=n;if(typeof e.name!=`string`)continue;let r=e.name.trim();r&&t.push({name:r,title:typeof e.title==`string`&&e.title.trim()?e.title.trim():void 0,description:typeof e.description==`string`&&e.description.trim()?e.description.trim():void 0,argumentCount:typeof e.argumentCount==`number`?e.argumentCount:0})}return t}async function Vt(e,t){let n=await p(f(`/api/mcp/servers/${encodeURIComponent(e)}/test`),{method:`POST`,body:t?JSON.stringify({server:t}):void 0});if(!n.payload)throw Error(n.error??`MCP test failed`);let r=Rt(n.payload.tools),i=zt(n.payload.resources),a=Bt(n.payload.prompts);return{serverId:n.payload.serverId??e,toolCount:typeof n.payload.toolCount==`number`?n.payload.toolCount:r.length,resourceCount:typeof n.payload.resourceCount==`number`?n.payload.resourceCount:i.length,promptCount:typeof n.payload.promptCount==`number`?n.payload.promptCount:a.length,tools:r,resources:i,prompts:a}}function Ht(e){return e.connectionTimeoutMs==null||!Number.isFinite(e.connectionTimeoutMs)?``:String(Math.round(e.connectionTimeoutMs/1e3))}function Ut(e){let t=e.trim();if(!t)return;let n=Number.parseInt(t,10);if(!(!Number.isFinite(n)||n<1||n>600))return n*1e3}function Wt(e){return e.requestTimeoutMs==null||!Number.isFinite(e.requestTimeoutMs)?``:String(Math.round(e.requestTimeoutMs/1e3))}function Gt(e){let t=e.trim();if(!t)return;let n=Number.parseInt(t,10);if(!(!Number.isFinite(n)||n<1||n>14400))return n*1e3}function Kt(e){if(e.transport===`stdio`){let t=e.command.trim();if(!t)return``;let n=e.argsText.trim();return n?`${t} ${n}`:t}return e.url.trim()}function $(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,n),e)}function qt({row:e,t,cs:n,onEdit:r,onRemove:i}){let[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(null),[d,f]=(0,Z.useState)(null),p=Kt(e),m=(0,Z.useCallback)(async()=>{o(!0),f(null);try{let t=await Vt(e.id.trim());u({toolCount:t.toolCount,resourceCount:t.resourceCount,promptCount:t.promptCount})}catch(e){f(e instanceof Error?e.message:String(e))}finally{o(!1)}},[e.id]),h=(0,Z.useCallback)(async()=>{c(!0),f(null);try{await i()}catch(e){f(e instanceof Error?e.message:String(e)),c(!1)}},[i]);return(0,Q.jsxs)(`div`,{className:`flex h-full min-h-[10.5rem] cursor-pointer flex-col rounded-lg bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45`,onClick:r,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:e.id.trim()||t.cardUntitled}),(0,Q.jsx)(`span`,{className:`rounded-full bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:n.customBadge}),(0,Q.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:t.transportLabels[e.transport]})]}),p?(0,Q.jsx)(`p`,{className:`mt-3 line-clamp-2 break-all font-mono text-xs leading-5 text-fg-subtle`,title:p,children:p}):null,d?(0,Q.jsx)(`p`,{className:`mt-3 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:d}):null,l?(0,Q.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:$(n.customCapabilitySummary,{tools:String(l.toolCount),resources:String(l.resourceCount),prompts:String(l.promptCount)})}):null]}),(0,Q.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-2 border-t border-edge pt-3`,onClick:e=>e.stopPropagation(),children:[(0,Q.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:n.connectorDetails}),(0,Q.jsxs)(`div`,{className:`flex gap-2`,children:[(0,Q.jsxs)(G,{variant:`secondary`,disabled:a,onClick:()=>void m(),children:[a?(0,Q.jsx)(D,{className:`size-4 animate-spin`}):(0,Q.jsx)(W,{className:`size-4`}),t.testConnection]}),(0,Q.jsxs)(G,{variant:`ghost`,disabled:s,onClick:()=>void h(),children:[s?(0,Q.jsx)(D,{className:`size-4 animate-spin`}):(0,Q.jsx)(k,{className:`size-4`}),t.removeServer]})]})]})]})}function Jt(e,t){return e?t&&e.startsWith(t)?e.slice(t.length):e:``}function Yt(e,t,n){let r=t.trim().toLowerCase();if(!r)return!0;let i=e.shortName||Jt(e.name,n);return[e.name,i,e.description].filter(Boolean).join(`
|
|
2
|
-
`).toLowerCase().includes(r)}function Xt(e,t){return e?t&&e.startsWith(t)?e.slice(t.length):e:``}function Zt(e){let t=(0,X.c)(29),{tools:n,stripPrefix:r,searchPlaceholder:i,searchEmptyLabel:a}=e,[o,c]=(0,Z.useState)(``),l;if(t[0]!==o||t[1]!==r||t[2]!==n){let e;t[4]!==o||t[5]!==r?(e=e=>Yt(e,o,r),t[4]=o,t[5]=r,t[6]=e):e=t[6],l=n.filter(e),t[0]=o,t[1]=r,t[2]=n,t[3]=l}else l=t[3];let u=l,d;t[7]===o?d=t[8]:(d=o.trim(),t[7]=o,t[8]=d);let f=d.length>0,p;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,Q.jsx)(me,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),t[9]=p):p=t[9];let m,h;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(m=s(`w-full rounded-lg border border-edge bg-surface-panel py-2 pl-9 pr-3 text-sm text-fg`,`placeholder:text-fg-subtle`,pe),h=e=>c(e.target.value),t[10]=m,t[11]=h):(m=t[10],h=t[11]);let g;t[12]!==o||t[13]!==i?(g=(0,Q.jsxs)(`div`,{className:`relative`,children:[p,(0,Q.jsx)(`input`,{type:`search`,value:o,placeholder:i,"aria-label":i,className:m,onChange:h})]}),t[12]=o,t[13]=i,t[14]=g):g=t[14];let _;t[15]!==u.length||t[16]!==f||t[17]!==n.length?(_=f?(0,Q.jsxs)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:[u.length,` / `,n.length]}):null,t[15]=u.length,t[16]=f,t[17]=n.length,t[18]=_):_=t[18];let v;t[19]!==g||t[20]!==_?(v=(0,Q.jsxs)(`div`,{className:`border-b border-edge px-5 py-3`,children:[g,_]}),t[19]=g,t[20]=_,t[21]=v):v=t[21];let y;t[22]!==u||t[23]!==a||t[24]!==r?(y=(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:u.length===0?(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:a}):(0,Q.jsx)(`ul`,{className:`flex flex-col gap-2`,children:u.map((e,t)=>{let n=e.shortName||Xt(e.name,r)||e.name||`?`,i=e.name||`tool-${t}`;return(0,Q.jsxs)(`li`,{className:`min-w-0 rounded-lg border border-edge bg-surface-base px-3 py-2.5`,children:[(0,Q.jsx)(`div`,{className:`truncate font-mono text-sm font-medium text-fg`,title:e.name===n?n:e.name,children:n}),e.description?(0,Q.jsx)(`p`,{className:`mt-1 truncate text-xs leading-relaxed text-fg-muted`,title:e.description,children:e.description}):null]},i)})})}),t[22]=u,t[23]=a,t[24]=r,t[25]=y):y=t[25];let b;return t[26]!==v||t[27]!==y?(b=(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[v,y]}),t[26]=v,t[27]=y,t[28]=b):b=t[28],b}function Qt(e){let t=(0,X.c)(38),{open:n,onOpenChange:r,serverId:i,title:a,subtitle:o,searchPlaceholder:c,searchEmptyLabel:l,emptyLabel:u,closeLabel:d,tools:f,stripPrefix:p}=e,m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,Q.jsx)(g,{className:s(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,ee)}),t[0]=m):m=t[0];let h;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(h=s(`fixed left-1/2 top-1/2 flex max-h-[min(88vh,40rem)] w-[min(100%-2rem,min(92vw,36rem))] -translate-x-1/2 -translate-y-1/2 flex-col`,T,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`),t[1]=h):h=t[1];let _;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,Q.jsx)(K,{className:`size-4 shrink-0 text-accent`,"aria-hidden":!0}),t[2]=_):_=t[2];let v;t[3]===a?v=t[4]:(v=(0,Q.jsxs)(O,{className:`flex items-center gap-2 text-base font-semibold text-fg`,children:[_,a]}),t[3]=a,t[4]=v);let x;t[5]!==i||t[6]!==o||t[7]!==f.length?(x=o.replace(`{{serverId}}`,i).replace(`{{count}}`,String(f.length)),t[5]=i,t[6]=o,t[7]=f.length,t[8]=x):x=t[8];let S;t[9]===x?S=t[10]:(S=(0,Q.jsx)(le,{className:`mt-1 text-sm text-fg-muted`,children:x}),t[9]=x,t[10]=S);let C;t[11]!==v||t[12]!==S?(C=(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[v,S]}),t[11]=v,t[12]=S,t[13]=C):C=t[13];let w;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,Q.jsx)(Ce,{className:`size-4`,"aria-hidden":!0}),t[14]=w):w=t[14];let E;t[15]===d?E=t[16]:(E=(0,Q.jsx)(y,{asChild:!0,children:(0,Q.jsx)(G,{type:`button`,variant:`ghost`,className:`size-8 shrink-0 px-0`,"aria-label":d,children:w})}),t[15]=d,t[16]=E);let D;t[17]!==C||t[18]!==E?(D=(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-3 border-b border-edge px-5 py-4`,children:[C,E]}),t[17]=C,t[18]=E,t[19]=D):D=t[19];let k;t[20]!==u||t[21]!==n||t[22]!==l||t[23]!==c||t[24]!==i||t[25]!==p||t[26]!==f?(k=f.length>0?(0,Q.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,Q.jsx)(Zt,{tools:f,stripPrefix:p,searchPlaceholder:c,searchEmptyLabel:l},`${i}-${n?`open`:`closed`}`)}):(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:u})}),t[20]=u,t[21]=n,t[22]=l,t[23]=c,t[24]=i,t[25]=p,t[26]=f,t[27]=k):k=t[27];let A;t[28]===d?A=t[29]:(A=(0,Q.jsx)(`div`,{className:`flex justify-end border-t border-edge px-5 py-3`,children:(0,Q.jsx)(y,{asChild:!0,children:(0,Q.jsx)(G,{type:`button`,variant:`secondary`,children:d})})}),t[28]=d,t[29]=A);let j;t[30]!==D||t[31]!==k||t[32]!==A?(j=(0,Q.jsxs)(ce,{children:[m,(0,Q.jsxs)(N,{className:h,children:[D,k,A]})]}),t[30]=D,t[31]=k,t[32]=A,t[33]=j):j=t[33];let M;return t[34]!==r||t[35]!==n||t[36]!==j?(M=(0,Q.jsx)(b,{open:n,onOpenChange:r,children:j}),t[34]=r,t[35]=n,t[36]=j,t[37]=M):M=t[37],M}function $t(e){let t=e.connectedAt?Date.parse(e.connectedAt):0;return Number.isFinite(t)?t:0}function en(e,t){return e.status===`active`&&t.status!==`active`?-1:e.status!==`active`&&t.status===`active`?1:e.isCurrentAuthorization===t.isCurrentAuthorization?e.isDefault===t.isDefault?$t(t)-$t(e):e.isDefault?-1:1:e.isCurrentAuthorization?-1:1}function tn(e){let t=new Map;for(let n of e){let e=n.accountId??n.identityKey??`authorization:${n.id}`;t.set(e,[...t.get(e)??[],n])}return[...t.entries()].map(([e,t])=>{let n=[...t].sort(en);return{key:e,primary:n[0],authorizations:n}}).sort((e,t)=>en(e.primary,t.primary))}var nn=s(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,pe);function rn(e){return e.materialized.type===`composio`?e.materialized.toolkit:null}function an(e,t){return e===`write`?t.composioScopeWrite:e===`admin`?t.composioScopeAdmin:t.composioScopeRead}function on(e,t){return e.errorCode===`missing_credential`?t.composioHealthMissingCredential:e.errorCode===`unauthorized`?t.composioHealthUnauthorized:e.errorCode===`forbidden`?t.composioHealthForbidden:e.errorCode===`network`?t.composioHealthNetwork:e.errorCode===`timeout`?t.composioHealthTimeout:t.composioHealthDegraded}function sn(e,t){return e===`active`?t.composioConnectionHealthy:e===`pending`?t.composioConnectionPending:e===`expired`?t.composioConnectionExpired:e===`failed`?t.composioConnectionFailed:e===`revoked`||e===`disabled`?t.composioConnectionRevoked:t.composioConnectionUnknown}function cn(e,t,n){return e.status===`paused`?t?.scanEnabled===!1?n.connectorLearningPausedByPolicy:n.connectorLearningPausedByFailure:e.status===`queued`?n.connectorLearningQueued:e.status===`running`?n.connectorLearningRunning:e.status===`completed`?n.connectorLearningCompleted:n.connectorLearningFailed}function ln({instance:e,t,onChanged:n}){let r=rn(e),[i,a]=(0,Z.useState)([]),[c,l]=(0,Z.useState)([]),[u,d]=(0,Z.useState)([]),[f,p]=(0,Z.useState)([]),[m,h]=(0,Z.useState)(null),[g,_]=(0,Z.useState)([]),[v,y]=(0,Z.useState)(null),[b,x]=(0,Z.useState)([]),[S,C]=(0,Z.useState)({}),[T,E]=(0,Z.useState)(`read`),[O,A]=(0,Z.useState)(!1),[M,N]=(0,Z.useState)(null),F=(0,Z.useMemo)(()=>tn(i),[i]),I=(0,Z.useCallback)(async()=>{if(!(!r||e.materialized.type!==`composio`||e.materialized.role===`credential`)){A(!0),N(null);try{let[t,n,i,o,s,c,u,f]=await Promise.all([ze().catch(()=>[]),Re(r).catch(()=>[]),Me(20).catch(()=>[]),Ze(r).catch(()=>`read`),Qe().catch(()=>[]),Ue(r).catch(()=>null),Fe(r).catch(()=>null),tt().catch(()=>[])]);a(t.filter(e=>e.toolkit.toLowerCase()===r.toLowerCase())),l(n),d(i.filter(e=>!e.toolkit||e.toolkit.toLowerCase()===r.toLowerCase())),E(o),p(s.filter(t=>t.connectorId===e.connectorId)),h(c?.policy??null),_(c?.agents??[]),y(u),x(f);let m=tn(t.filter(e=>e.toolkit.toLowerCase()===r.toLowerCase())).map(e=>e.primary).filter(e=>!!e.accountId),g=await Promise.all(m.map(async e=>[e.accountId,await Le(e.accountId)]).map(e=>e.catch(()=>null)));C(Object.fromEntries(g.filter(e=>e!==null)))}catch(e){N(e instanceof Error?e.message:String(e))}finally{A(!1)}}},[e.connectorId,e.materialized,r]);(0,Z.useEffect)(()=>{I()},[I]);let L=(0,Z.useCallback)(async()=>{if(r){A(!0),N(null);try{let t=await Y(e.connectorId);if(!t.authorizationUrl)throw Error(`The authorization provider did not return an authorization URL.`);if(j()){let e=await window.electronAPI?.shell?.openExternalUrl(t.authorizationUrl);if(!e?.ok)throw Error(e?.error??`Could not open the system browser.`)}else window.open(t.authorizationUrl,`_blank`,`noopener,noreferrer`);let i=await ke(r,t.connectionId);if(!i.accountId)throw Error(`Connector account is unavailable.`);await Te(i.accountId),await n?.(),await I()}catch(e){N(e instanceof Error?e.message:String(e))}finally{A(!1)}}},[e.connectorId,I,n,r]),z=(0,Z.useCallback)(async e=>{if(r){E(e);try{await je(r,e),await I()}catch(e){N(e instanceof Error?e.message:String(e))}}},[I,r]),V=(0,Z.useCallback)(async(e,t)=>{A(!0),N(null);try{await J(e,t),await I()}catch(e){N(e instanceof Error?e.message:String(e))}finally{A(!1)}},[I]),H=(0,Z.useCallback)(async e=>{if(r){N(null);try{h(await Ve(r,e))}catch(e){N(e instanceof Error?e.message:String(e))}}},[e.connectorId,r]),ee=(0,Z.useCallback)(e=>{m&&H({allowedAgentIds:m.allowedAgentIds.includes(e)?m.allowedAgentIds.filter(t=>t!==e):[...m.allowedAgentIds,e]})},[H,m]),U=(0,Z.useCallback)(async e=>{A(!0),N(null);try{await e(),await I()}catch(e){N(e instanceof Error?e.message:String(e))}finally{A(!1)}},[I]);return r?e.materialized.type===`composio`&&e.materialized.role===`credential`?(0,Q.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:t.composioApiKeyStored}):(0,Q.jsxs)(`div`,{className:`mt-4 rounded-xl border border-edge bg-surface-base p-3 text-sm`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`font-medium text-fg`,children:$(t.composioToolkitTitle,{toolkit:r})}),(0,Q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:t.composioScopeHint})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Q.jsxs)(G,{variant:`secondary`,disabled:O,onClick:()=>void L(),children:[O?(0,Q.jsx)(D,{className:`size-4 animate-spin`}):(0,Q.jsx)(P,{className:`size-4`}),t.connectOAuth]}),(0,Q.jsx)(G,{variant:`ghost`,disabled:O,onClick:()=>void I(),children:t.refresh})]})]}),M?(0,Q.jsx)(`p`,{className:`mt-3 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:M}):null,v?(0,Q.jsxs)(`div`,{className:s(`mt-3 flex flex-wrap items-center justify-between gap-2 rounded-lg border px-3 py-2 text-xs`,v.status===`connected`?`border-emerald-500/30 bg-emerald-500/5 text-emerald-700`:`border-amber-500/30 bg-amber-500/5 text-amber-700`),children:[(0,Q.jsx)(`span`,{children:v.status===`connected`?$(t.composioHealthConnected,{count:String(F.filter(e=>e.primary.status===`active`).length)}):v.status===`reauthorization_required`?t.composioHealthReconnect:v.status===`degraded`?on(v,t):t.composioHealthDisconnected}),v.recovery===`none`?null:(0,Q.jsx)(G,{variant:`ghost`,disabled:O,onClick:()=>void(v.recovery===`retry`?I():L()),children:v.recovery===`retry`?t.composioRetry:t.connectOAuth}),v.status===`degraded`&&v.message?(0,Q.jsx)(`p`,{className:`basis-full break-words text-[11px] opacity-80`,children:v.message}):null]}):null,m?(0,Q.jsxs)(`div`,{className:`mt-4 grid gap-3 rounded-lg border border-edge bg-surface-panel p-3 md:grid-cols-3`,children:[(0,Q.jsxs)(`label`,{className:`text-xs font-medium text-fg-subtle`,children:[t.composioAccessTitle,(0,Q.jsxs)(w,{className:s(nn,`mt-1 h-9 py-1`),value:T,onChange:e=>void z(e.currentTarget.value),children:[(0,Q.jsx)(R,{value:`read`,children:t.composioAccessReadOnly}),(0,Q.jsx)(R,{value:`write`,children:t.composioAccessReadWrite}),T===`admin`?(0,Q.jsx)(R,{value:`admin`,children:t.composioAccessAdminCurrent}):null]}),(0,Q.jsx)(`span`,{className:`mt-1 block font-normal leading-4 text-fg-muted`,children:T===`read`?t.composioAccessReadHint:T===`admin`?t.composioAccessAdminHint:t.composioAccessWriteHint})]}),(0,Q.jsxs)(`label`,{className:`text-xs font-medium text-fg-subtle`,children:[t.composioConfirmationPolicy,(0,Q.jsxs)(w,{className:s(nn,`mt-1 h-9 py-1`),value:m.confirmationPolicy,onChange:e=>void H({confirmationPolicy:e.currentTarget.value}),children:[(0,Q.jsx)(R,{value:`writes`,children:t.composioConfirmWrites}),(0,Q.jsx)(R,{value:`always`,children:t.composioConfirmAlways}),m.confirmationPolicy===`never`?(0,Q.jsx)(R,{value:`never`,children:t.composioConfirmNever}):null]})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-xs font-medium text-fg-subtle`,children:t.composioAllowedAgents}),(0,Q.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:m.allowedAgentIds.length?t.composioAllowedAgentsSelected:t.composioAllowedAgentsAll}),(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:g.map(e=>(0,Q.jsx)(`button`,{type:`button`,className:s(`rounded-full border px-2.5 py-1 text-xs transition-colors`,m.allowedAgentIds.includes(e.id)?`border-accent bg-accent/10 text-accent`:`border-edge text-fg-muted hover:text-fg`),onClick:()=>ee(e.id),children:e.name},e.id))})]})]}):null,f.length?(0,Q.jsxs)(`div`,{className:`mt-4 space-y-2`,children:[(0,Q.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioPendingApprovals}),f.map(e=>(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-lg border border-amber-500/30 bg-amber-500/5 p-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`p`,{className:`truncate font-mono text-xs font-medium text-fg`,children:e.actionId}),(0,Q.jsx)(`p`,{className:`mt-1 break-all font-mono text-xs text-fg-subtle`,children:JSON.stringify(e.argumentsPreview)}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:$(t.composioApprovalExpires,{time:new Date(e.expiresAt).toLocaleTimeString()})})]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,Q.jsxs)(G,{variant:`secondary`,disabled:O,onClick:()=>void V(e.id,`denied`),children:[(0,Q.jsx)(Ce,{className:`size-4`}),t.composioDeny]}),(0,Q.jsxs)(G,{disabled:O,onClick:()=>void V(e.id,`approved`),children:[(0,Q.jsx)(o,{className:`size-4`}),t.approve]})]})]},e.id))]}):null,(0,Q.jsx)(`div`,{className:`mt-4`,children:(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioConnections}),F.length?[{title:t.composioConnectedAccounts,items:F.filter(e=>e.primary.status===`active`)},{title:t.composioNeedsAttention,items:F.filter(e=>e.primary.status!==`active`)}].filter(e=>e.items.length>0).map(e=>(0,Q.jsxs)(`section`,{className:`mb-3 space-y-2`,children:[(0,Q.jsxs)(`h4`,{className:`text-xs font-medium text-fg-muted`,children:[e.title,` · `,e.items.length]}),e.items.map(e=>{let i=e.primary,a=b.find(e=>i.accountId?e.accountId===i.accountId:e.connectionId===i.id),o=i.accountId?S[i.accountId]:void 0;return(0,Q.jsxs)(`div`,{className:`space-y-3 rounded-xl border border-edge bg-surface-panel p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:i.alias??i.workspace??i.accountEmail??i.username??t.composioUnnamedAuthorization}),i.connectedAt?(0,Q.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:$(t.composioAuthorizedAt,{time:new Date(i.connectedAt).toLocaleString()})}):null,(0,Q.jsxs)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:[$(t.composioAuthorizationCount,{count:String(e.authorizations.length)}),e.authorizations.length>1?` · ${$(t.composioDuplicateAuthorizations,{count:String(e.authorizations.length-1)})}`:``]})]}),(0,Q.jsxs)(`span`,{className:s(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,i.status===`active`?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-amber-500/10 text-amber-700 dark:text-amber-300`),children:[sn(i.status,t),i.isDefault?` · ${t.composioDefaultAccount}`:``]})]}),a||i.status===`active`?(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,Q.jsx)(`p`,{className:`text-xs font-medium text-fg`,children:t.connectorLearningTitle}),(0,Q.jsx)(`p`,{className:s(`mt-1 text-xs`,a?.status===`failed`?`text-red-600`:`text-fg-subtle`),children:a?$(t.connectorLearningStatus,{status:cn(a,o,t),count:String(a.candidatesCreated)}):t.connectorLearningEmpty}),o?(0,Q.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2`,children:[(0,Q.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-fg-subtle`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:o.scanEnabled,disabled:O,onChange:e=>void U(()=>De(i.accountId,{scanEnabled:e.currentTarget.checked}))}),t.connectorScheduledScan]}),(0,Q.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-fg-subtle`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,checked:o.proactiveEnabled,disabled:O||!o.scanEnabled,onChange:e=>void U(()=>De(i.accountId,{proactiveEnabled:e.currentTarget.checked}))}),t.connectorProactiveUse]}),o.scanEnabled?(0,Q.jsxs)(`label`,{className:`text-xs text-fg-subtle sm:col-span-2`,children:[t.connectorScanInterval,(0,Q.jsxs)(w,{className:s(nn,`mt-1 h-8 py-1 text-xs`),value:String(o.intervalMinutes??30),disabled:O,onChange:e=>void U(()=>De(i.accountId,{intervalMinutes:Number(e.currentTarget.value)})),children:[(0,Q.jsxs)(R,{value:`5`,children:[`5 `,t.connectorMinutes]}),(0,Q.jsxs)(R,{value:`15`,children:[`15 `,t.connectorMinutes]}),(0,Q.jsxs)(R,{value:`30`,children:[`30 `,t.connectorMinutes]}),(0,Q.jsxs)(R,{value:`60`,children:[`60 `,t.connectorMinutes]})]})]}):null]}):null]}):null,(0,Q.jsxs)(`details`,{className:`text-xs text-fg-subtle`,children:[(0,Q.jsx)(`summary`,{className:`cursor-pointer`,children:t.composioAdvancedSettings}),(0,Q.jsxs)(`div`,{className:`mt-2 space-y-2 rounded-lg bg-surface-base p-2`,children:[e.authorizations.map(e=>(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsxs)(`p`,{className:`min-w-0 break-all font-mono`,children:[t.composioAuthorizationId,`: `,e.providerConnectionId]}),(0,Q.jsx)(G,{variant:`ghost`,className:`size-7 shrink-0 p-0`,title:t.composioRevoke,disabled:O,onClick:()=>{window.confirm(t.composioRevokeConfirm)&&U(()=>$e(e.id))},children:(0,Q.jsx)(k,{className:`size-3.5 text-red-500`})})]},e.id)),(0,Q.jsx)(`input`,{className:s(nn,`h-8 py-1 text-xs`),defaultValue:i.alias??``,placeholder:t.composioAccountAlias,onBlur:e=>{e.currentTarget.value!==(i.alias??``)&&U(()=>q(i.id,{alias:e.currentTarget.value}))}})]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-1`,children:[(0,Q.jsx)(G,{variant:`ghost`,className:`size-8 p-0`,title:t.composioMakeDefault,disabled:O||i.isDefault||i.status!==`active`,onClick:()=>void U(async()=>{await q(i.id,{isDefault:!0}),r&&await Ve(r,{selectedConnectionIds:[i.id]})}),children:(0,Q.jsx)(B,{className:s(`size-4`,i.isDefault&&`fill-current`)})}),(0,Q.jsx)(G,{variant:`ghost`,className:`size-8 p-0`,title:t.refresh,disabled:O,onClick:()=>void U(()=>et(i.id)),children:(0,Q.jsx)(he,{className:`size-4`})}),i.status===`active`?(0,Q.jsxs)(G,{variant:`secondary`,disabled:O,onClick:()=>void U(async()=>{if(!i.accountId)throw Error(`Connector account is unavailable.`);await Te(i.accountId),await n?.()}),children:[O?(0,Q.jsx)(D,{className:`size-4 animate-spin`}):(0,Q.jsx)(he,{className:`size-4`}),t.composioSyncNow]}):null]})]},e.key)})]},e.title)):(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioConnectionsEmpty})]})}),(0,Q.jsxs)(`details`,{className:`mt-4 rounded-lg border border-edge bg-surface-panel p-3`,children:[(0,Q.jsx)(`summary`,{className:`cursor-pointer text-xs font-medium text-fg-muted`,children:t.composioAdvancedSettings}),(0,Q.jsxs)(`div`,{className:`mt-4 grid gap-4 lg:grid-cols-2`,children:[(0,Q.jsx)(`div`,{className:`space-y-3`,children:(0,Q.jsxs)(`label`,{className:`block text-xs text-fg-subtle`,children:[t.composioAdvancedScope,(0,Q.jsxs)(w,{className:s(nn,`mt-1 h-9 py-1`),value:T,onChange:e=>void z(e.currentTarget.value),children:[(0,Q.jsx)(R,{value:`read`,children:t.composioScopeRead}),(0,Q.jsx)(R,{value:`write`,children:t.composioScopeWrite}),(0,Q.jsx)(R,{value:`admin`,children:t.composioScopeAdmin})]})]})}),(0,Q.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioAgentTools}),c.length?c.slice(0,8).map(e=>(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-2`,children:[(0,Q.jsx)(`p`,{className:`truncate font-mono text-xs text-fg`,children:e.slug}),(0,Q.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[an(e.scope,t),e.curated?``:` ${t.composioUncuratedSuffix}`]})]},e.slug)):(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioToolsEmpty})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioRecentTriggers}),u.length?u.slice(0,5).map(e=>(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-2`,children:[(0,Q.jsx)(`p`,{className:`truncate text-xs text-fg`,children:e.trigger??e.id}),(0,Q.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:new Date(e.at).toLocaleString()})]},`${e.id}-${e.at}`)):(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioTriggersEmpty})]})]})]})]})]}):null}var un=s(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,pe);function dn(e,t){return e?t.healthStatusLabels[e]??e:t.healthNotTested}function fn(e,t){let n={};for(let r of e?.setup.config??[]){let e=t.config?.[r.key]??r.defaultValue??``;n[r.key]=typeof e==`string`?e:JSON.stringify(e,null,2)}return n}function pn(e,t){let n=t.trim();return e===`json`?n?JSON.parse(n):void 0:e===`number`?n?Number(n):void 0:e===`boolean`?n===`true`:n||void 0}function mn(e){let t=(0,X.c)(12),{title:n,description:r,meta:i}=e,a;t[0]===r?a=t[1]:(a=r?(0,Q.jsx)(te,{delayDuration:300,skipDelayDuration:100,children:(0,Q.jsxs)(ie,{children:[(0,Q.jsx)(ve,{asChild:!0,children:(0,Q.jsx)(`p`,{tabIndex:0,title:r,className:s(`mt-1 line-clamp-3 cursor-help text-xs leading-5 text-fg-muted`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`),children:r})}),(0,Q.jsx)(Se,{children:(0,Q.jsx)(ue,{side:`top`,align:`start`,sideOffset:6,collisionPadding:12,className:`!z-[10000] max-h-[min(16rem,45vh)] max-w-[min(32rem,calc(100vw-2rem))] overflow-y-auto rounded-md border border-edge bg-surface-panel px-2.5 py-2 text-left text-xs leading-5 text-fg shadow-popover`,children:(0,Q.jsx)(`span`,{className:`whitespace-pre-wrap break-words`,children:r})})})]})}):null,t[0]=r,t[1]=a);let o=a,c;t[2]===n?c=t[3]:(c=(0,Q.jsx)(`p`,{className:`min-w-0 break-all font-mono text-xs font-medium leading-5 text-fg`,children:n}),t[2]=n,t[3]=c);let l;t[4]===i?l=t[5]:(l=i?(0,Q.jsx)(`span`,{className:`shrink-0 rounded-md bg-surface-hover px-1.5 py-0.5 text-[11px] leading-4 text-fg-subtle`,children:i}):null,t[4]=i,t[5]=l);let u;t[6]!==c||t[7]!==l?(u=(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-3`,children:[c,l]}),t[6]=c,t[7]=l,t[8]=u):u=t[8];let d;return t[9]!==o||t[10]!==u?(d=(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2.5`,children:[u,o]}),t[9]=o,t[10]=u,t[11]=d):d=t[11],d}function hn({instance:e,definition:t,onClose:n,onChanged:r,t:i,mcp:a}){let[o,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(!1),[h,v]=(0,Z.useState)(null),[x,S]=(0,Z.useState)(null),[C,w]=(0,Z.useState)(e.materialized.type===`mcp`?`health`:`permissions`),[T,E]=(0,Z.useState)(!1),[j,M]=(0,Z.useState)(()=>fn(t,e)),[F,I]=(0,Z.useState)(null),L=t?.setup.config??[],R=(e.materialized.type===`mcp`||e.materialized.type===`memorySource`)&&L.length>0&&(t?.setup.secrets??[]).length===0,z=x?x.toolCount:e.usage.lastToolCount,B=(0,Z.useMemo)(()=>{let t=e.materialized.type===`mcp`?[[`health`,H,i.detailHealth],[`tools`,K,`${i.detailTools} ${x?x.toolCount:e.usage.lastToolCount??``}`],[`resources`,A,`${i.detailResources} ${x?x.resourceCount:e.usage.lastResourceCount??``}`],[`prompts`,_,`${i.detailPrompts} ${x?x.promptCount:e.usage.lastPromptCount??``}`],[`permissions`,P,i.detailPermissions]]:[[`permissions`,P,i.detailPermissions]];return R?[...t,[`config`,A,i.connectorConfigLabel]]:t},[x,e.materialized.type,e.usage.lastPromptCount,e.usage.lastResourceCount,e.usage.lastToolCount,R,i]),V=(0,Z.useCallback)(async()=>{c(!0),I(null);try{let t=await He(e.instanceId);S(t),t.toolCount>0&&w(`tools`),r()}catch(e){I(e instanceof Error?e.message:String(e))}finally{c(!1)}},[e.instanceId,r]),ee=(0,Z.useCallback)(async()=>{u(!0),I(null);try{await Ae(e.instanceId),await r(),n()}catch(e){I(e instanceof Error?e.message:String(e)),u(!1)}},[e.instanceId,r,n]),U=(0,Z.useCallback)(async()=>{if(!(!t||!R)){f(!0),I(null);try{let n={};for(let e of t.setup.config??[]){let t=pn(e.type,j[e.key]??``);t!==void 0&&(n[e.key]=t)}await Ee(e.instanceId,{config:n}),await r(),w(`health`)}catch(e){I(e instanceof Error?e.message:String(e))}finally{f(!1)}}},[j,t,e.instanceId,r,R]),te=(0,Z.useCallback)(async()=>{m(!0),v(null),I(null);try{v((await Oe(e.connectorId)).recordIds.length),await r()}catch(e){I(e instanceof Error?e.message:String(e))}finally{m(!1)}},[e.connectorId,r]);return(0,Q.jsxs)(b,{open:!0,onOpenChange:e=>{e||n()},children:[(0,Q.jsxs)(ce,{children:[(0,Q.jsx)(g,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,Q.jsxs)(N,{className:s(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(100vh-2rem,44rem)] w-[min(100%-2rem,min(92vw,54rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-panel shadow-float outline-none dark:border-edge`),children:[(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,Q.jsx)(rt,{connector:t,size:`lg`}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(O,{className:`text-base font-semibold text-fg`,children:e.displayName}),(0,Q.jsx)(le,{className:`mt-1 text-sm text-fg-muted`,children:t?.description??(e.materialized.type===`mcp`?$(i.mcpServerRuntime,{serverId:e.materialized.serverId}):$(i.runtimeLabel,{runtime:e.materialized.type}))})]})]}),(0,Q.jsx)(y,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,className:s(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,de.focusRingPanel),"aria-label":i.modalClose,children:[(0,Q.jsx)(Ce,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`sr-only`,children:i.modalClose})]})})]}),(0,Q.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:[F?(0,Q.jsx)(`p`,{className:`mb-4 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:F}):null,(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:B.map(([e,t,n])=>(0,Q.jsxs)(`button`,{type:`button`,className:s(`inline-flex h-8 items-center gap-1.5 rounded-md border px-2.5 text-xs`,C===e?`border-accent bg-accent-soft text-accent-fg`:`border-edge bg-surface-base text-fg-muted hover:text-fg`),onClick:()=>w(e),children:[(0,Q.jsx)(t,{className:`size-3.5`,"aria-hidden":!0}),n]},e))}),(0,Q.jsxs)(`div`,{className:`mt-4 rounded-xl border border-edge bg-surface-base p-3 text-sm`,children:[C===`health`?(0,Q.jsxs)(`div`,{className:`space-y-1 text-fg-muted`,children:[(0,Q.jsxs)(`p`,{children:[i.statusLabel,` `,(0,Q.jsx)(`span`,{className:x?.ok?`font-medium text-emerald-700 dark:text-emerald-300`:`font-medium text-fg`,children:dn(x?.status??e.usage.lastHealthStatus,i)})]}),(0,Q.jsxs)(`p`,{children:[i.lastCheckLabel,` `,e.usage.lastHealthCheckAt?new Date(e.usage.lastHealthCheckAt).toLocaleString():i.never]}),x?.action?(0,Q.jsx)(`p`,{children:x.action}):null]}):null,C===`tools`?x?.tools.length?(0,Q.jsxs)(`div`,{className:`grid gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:$(i.toolsAvailable,{count:String(x.tools.length)})}),(0,Q.jsx)(G,{type:`button`,variant:`ghost`,className:`h-7 text-xs`,onClick:()=>E(!0),children:a.viewAllTools})]}),(0,Q.jsx)(`div`,{className:`grid gap-2`,children:x.tools.slice(0,8).map(e=>(0,Q.jsx)(mn,{title:e.shortName??e.name,description:e.description},e.name))})]}):(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Q.jsx)(`p`,{className:`text-fg-muted`,children:z?$(i.toolsLastCheckSummary,{count:String(z)}):i.toolsRunTestHint}),(0,Q.jsxs)(G,{type:`button`,variant:`secondary`,disabled:o,onClick:()=>void V(),children:[o?(0,Q.jsx)(D,{className:`size-4 animate-spin`}):(0,Q.jsx)(W,{className:`size-4`}),i.test]})]}):null,C===`resources`?x?.resources.length?(0,Q.jsx)(`div`,{className:`grid gap-2`,children:x.resources.slice(0,8).map(e=>(0,Q.jsx)(mn,{title:e.title??e.name,description:e.uri,meta:e.mimeType},e.uri))}):(0,Q.jsx)(`p`,{className:`text-fg-muted`,children:i.resourcesRunTestHint}):null,C===`prompts`?x?.prompts.length?(0,Q.jsx)(`div`,{className:`grid gap-2`,children:x.prompts.slice(0,8).map(e=>(0,Q.jsx)(mn,{title:e.title??e.name,description:e.description,meta:e.argumentCount?$(i.promptArgumentCount,{count:String(e.argumentCount)}):void 0},e.name))}):(0,Q.jsx)(`p`,{className:`text-fg-muted`,children:i.promptsRunTestHint}):null,C===`permissions`?(0,Q.jsxs)(`div`,{className:`space-y-1 text-fg-muted`,children:[(0,Q.jsx)(`p`,{children:$(i.secretsConfigured,{count:String(Object.values(e.secretStatus).filter(Boolean).length)})}),(0,Q.jsx)(`p`,{children:e.materialized.type===`mcp`?$(i.runtimeServerLabel,{runtime:e.materialized.type.toUpperCase(),serverId:e.materialized.serverId}):$(i.runtimeLabel,{runtime:e.materialized.type.toUpperCase()})}),(0,Q.jsx)(`p`,{children:e.materialized.type===`mcp`?i.mcpPolicyHint:i.connectorPolicyHint})]}):null,C===`config`&&R?(0,Q.jsx)(`div`,{className:`grid gap-3`,children:L.map(e=>(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.label}),e.description?(0,Q.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:e.description}):null,(0,Q.jsx)(`input`,{className:un,value:j[e.key]??``,placeholder:e.placeholder,onChange:t=>M(n=>({...n,[e.key]:t.currentTarget.value}))})]},e.key))}):null]}),e.materialized.type===`composio`?(0,Q.jsx)(ln,{instance:e,t:i,onChanged:r}):null,e.materialized.type===`memorySource`?(0,Q.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center justify-between gap-3 rounded-xl border border-edge bg-surface-base p-3 text-sm`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`font-medium text-fg`,children:i.connectedSourceSync}),(0,Q.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t?.description}),h===null?null:(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-emerald-600`,children:$(i.connectedSourceSynced,{count:String(h)})})]}),(0,Q.jsxs)(G,{disabled:p,onClick:()=>void te(),children:[p?(0,Q.jsx)(D,{className:`size-4 animate-spin`}):(0,Q.jsx)(A,{className:`size-4`}),i.composioSyncNow]})]}):null]}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[(0,Q.jsx)(G,{variant:`secondary`,onClick:n,children:i.modalClose}),C===`config`&&R?(0,Q.jsxs)(G,{variant:`primary`,disabled:d,onClick:()=>void U(),children:[d?(0,Q.jsx)(D,{className:`size-4 animate-spin`}):(0,Q.jsx)(be,{className:`size-4`}),i.modalSave]}):null,e.materialized.type===`mcp`?(0,Q.jsxs)(G,{variant:`secondary`,disabled:o,onClick:()=>void V(),children:[o?(0,Q.jsx)(D,{className:`size-4 animate-spin`}):(0,Q.jsx)(W,{className:`size-4`}),i.test]}):null,(0,Q.jsxs)(G,{variant:`ghost`,disabled:l,onClick:()=>void ee(),children:[l?(0,Q.jsx)(D,{className:`size-4 animate-spin`}):(0,Q.jsx)(k,{className:`size-4`}),i.remove]})]})]})]}),e.materialized.type===`mcp`?(0,Q.jsx)(Qt,{open:T,onOpenChange:E,serverId:e.materialized.serverId,title:$(i.installedToolsDialogTitle,{name:e.displayName}),subtitle:i.installedToolsDialogSubtitle,searchPlaceholder:a.toolsDialogSearchPlaceholder,searchEmptyLabel:a.toolsDialogSearchEmpty,emptyLabel:i.toolsRunTestHint,closeLabel:a.toolsDialogClose,tools:x?.tools??[],stripPrefix:`${e.materialized.serverId}__`}):null]})}var gn=[`understand`,`act`,`reach`];function _n(e){if(e.benefits?.length)return[...new Set(e.benefits)];let t=new Set(e.capabilities),n=[e.id,e.displayName,...e.tags??[]].join(` `).toLowerCase(),r=[];return(t.has(`context`)||t.has(`memory_source`)||t.has(`resources`)||e.category===`docs`||e.category===`data`||/notion|drive|document|confluence|airtable|database|knowledge|wiki/.test(n))&&r.push(`understand`),t.has(`tools`)&&r.push(`act`),(t.has(`channel`)||/slack|telegram|discord|teams|mail|message|wechat|weixin/.test(n))&&r.push(`reach`),r.length?[...new Set(r)]:[`act`]}function vn(e){return _n(e)[0]??`act`}function yn(e,t){let n=t?vn(t):`act`,r=e.connectionStatus===`connected`||e.status===`connected`||e.usage.lastHealthStatus===`ok`,i=e.status===`not_configured`||e.status===`failed`||e.status===`degraded`||e.status===`unauthorized`||e.connectionStatus===`unauthorized`||e.connectionStatus===`error`,a=n===`understand`?e.usage.lastResourceCount:n===`act`?e.usage.lastToolCount:void 0;return{benefit:n,state:r?`ready`:i?`needs_setup`:`checking`,availableCount:a}}function bn({instance:e,definition:t,highlighted:n=!1,onOpenDetails:r,onChanged:i,t:a}){let[o,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(null),p=(0,Z.useCallback)(async()=>{c(!0),f(null);try{await He(e.instanceId),await i()}catch(e){f(e instanceof Error?e.message:String(e))}finally{c(!1)}},[e.instanceId,i]),h=(0,Z.useCallback)(async()=>{u(!0),f(null);try{await Ae(e.instanceId),await i()}catch(e){f(e instanceof Error?e.message:String(e)),u(!1)}},[e.instanceId,i]),g=e.usage.lastHealthStatus?a.healthStatusLabels[e.usage.lastHealthStatus]??e.usage.lastHealthStatus:a.healthNotTested,_=e.usage.lastToolCount??0,v=!!(t?.setup.config?.length&&!t.setup.secrets?.length&&e.materialized.type===`mcp`),y=yn(e,t).state,b=y===`ready`?{label:a.connectionReady,Icon:m,className:`border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`}:y===`needs_setup`?{label:a.connectionNeedsSetup,Icon:xe,className:`border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300`}:{label:a.connectionChecking,Icon:C,className:`border-edge bg-surface-base text-fg-muted`};return(0,Q.jsxs)(`div`,{className:s(`flex h-full min-h-[10.5rem] cursor-pointer flex-col rounded-lg bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45`,n&&`ring-2 ring-accent/45 ring-offset-2 ring-offset-surface-panel`),onClick:()=>r(e),children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-3`,children:[(0,Q.jsx)(rt,{connector:t}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:e.displayName}),(0,Q.jsxs)(`span`,{className:s(`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-[11px] font-medium`,b.className),children:[(0,Q.jsx)(b.Icon,{className:`size-3`,"aria-hidden":!0}),b.label]}),v?(0,Q.jsx)(`span`,{className:`rounded-full bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:a.connectorConfigLabel}):null]}),t?.description?(0,Q.jsx)(`p`,{className:`mt-3 line-clamp-2 text-sm leading-5 text-fg-muted`,children:t.description}):null,(0,Q.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2 text-xs text-fg-muted`,children:[(0,Q.jsxs)(`span`,{className:`rounded-md bg-surface-base px-2 py-1`,children:[a.statusLabel,` `,g]}),(0,Q.jsx)(`span`,{className:`rounded-md bg-surface-base px-2 py-1`,children:$(a.toolsAvailable,{count:String(_)})})]}),d?(0,Q.jsx)(`p`,{className:`mt-3 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:d}):null]})]}),(0,Q.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-2 border-t border-edge pt-3`,onClick:e=>e.stopPropagation(),children:[(0,Q.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:a.connectorDetails}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[y===`needs_setup`?(0,Q.jsxs)(G,{variant:`primary`,onClick:()=>r(e),children:[(0,Q.jsx)(xe,{className:`size-4`}),a.connectionResolveAction]}):null,e.materialized.type===`mcp`?(0,Q.jsxs)(G,{variant:`secondary`,disabled:o,onClick:()=>void p(),children:[o?(0,Q.jsx)(D,{className:`size-4 animate-spin`}):(0,Q.jsx)(W,{className:`size-4`}),a.test]}):null,(0,Q.jsxs)(G,{variant:`ghost`,disabled:l,onClick:()=>void h(),children:[l?(0,Q.jsx)(D,{className:`size-4 animate-spin`}):(0,Q.jsx)(k,{className:`size-4`}),a.remove]})]})]})]})}var xn=s(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,pe),Sn=s(xn,`min-h-28 font-mono`);function Cn(e,t){return e?t.healthStatusLabels[e]??e:t.healthStatusPending}function wn(e,t){let n=t.trim();return e===`json`?n?JSON.parse(n):void 0:e===`number`?n?Number(n):void 0:e===`boolean`?n===`true`:n||void 0}function Tn(e){let t=(0,X.c)(12),{title:n,items:r}=e;if(r.length===0)return null;let i;t[0]===n?i=t[1]:(i=(0,Q.jsx)(`div`,{className:`border-b border-edge px-3 py-2 text-xs font-semibold text-fg`,children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=r.slice(0,12).map(En),t[2]=r,t[3]=a);let o;t[4]===r.length?o=t[5]:(o=r.length>12?(0,Q.jsxs)(`div`,{className:`px-3 py-2 text-xs text-fg-subtle`,children:[`+`,r.length-12]}):null,t[4]=r.length,t[5]=o);let s;t[6]!==a||t[7]!==o?(s=(0,Q.jsxs)(`div`,{className:`max-h-40 overflow-y-auto`,children:[a,o]}),t[6]=a,t[7]=o,t[8]=s):s=t[8];let c;return t[9]!==i||t[10]!==s?(c=(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel`,children:[i,s]}),t[9]=i,t[10]=s,t[11]=c):c=t[11],c}function En(e){return(0,Q.jsxs)(`div`,{className:`border-b border-edge-subtle px-3 py-2 last:border-b-0`,children:[(0,Q.jsx)(`div`,{className:`break-words font-mono text-xs font-medium text-fg`,children:e.title}),e.description?(0,Q.jsx)(`div`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:e.description}):null]},e.id)}function Dn({draft:e,onChange:t,onClose:n,onInstalled:r,t:i}){let{connector:a}=e,o=a.runtime.type===`composio`&&a.runtime.role===`toolkit`,c=a.runtime.type===`composio`&&a.runtime.role===`toolkit`?a.runtime.toolkit:null,l=a.understanding!=null,[u,d]=(0,Z.useState)(!o),[f,p]=(0,Z.useState)(o),[h,_]=(0,Z.useState)(``),[v,x]=(0,Z.useState)(null),[S,C]=(0,Z.useState)(l);(0,Z.useEffect)(()=>{if(!o)return;let e=!1;return Ie().then(({configured:t})=>{e||d(t)}).catch(t=>{e||x(t instanceof Error?t.message:String(t))}).finally(()=>{e||p(!1)}),()=>{e=!0}},[a.id,o]);let w=e.result?`complete`:e.installing?`health`:`configure`,T=[{id:`configure`,label:i.connectStepConfigure},{id:`health`,label:i.connectStepVerify},{id:`complete`,label:i.connectStepReady}],E=(0,Z.useCallback)(async()=>{let n=j(),i=o&&!n?window.open(``,`_blank`):null;i&&(i.opener=null),x(null),t({...e,installing:!0,error:null,result:null,health:null});try{o&&!u&&(await Xe(h),d(!0));let s={};for(let t of a.setup.config??[]){let n=wn(t.type,e.config[t.key]??``);n!==void 0&&(s[t.key]=n)}let f=e.store?await We(e.store.packageName,{secrets:e.secrets,config:s},e.store.version):await qe(a.id,{secrets:e.secrets,config:s,definition:a.source===`registry`?a:void 0}),p=null;try{if(o)if((c?await Fe(c).catch(()=>null):null)?.status===`connected`){i?.close();let e=await ke(c);if(l&&S){if(!e.accountId)throw Error(`Connector account is unavailable.`);await Te(e.accountId)}}else{let e=await Y(a.id);if(!e.authorizationUrl)throw Error(`The connection service did not return an authorization URL.`);if(n){let t=await window.electronAPI?.shell?.openExternalUrl(e.authorizationUrl);if(!t?.ok)throw Error(t?.error??`Could not open the system browser.`)}else i?i.location.href=e.authorizationUrl:window.open(e.authorizationUrl,`_blank`,`noopener,noreferrer`);let t=await ke(c,e.connectionId);if(i?.close(),l&&S){if(!t.accountId)throw Error(`Connector account is unavailable.`);await Te(t.accountId)}}}catch(n){i?.close(),t({...e,installing:!1,result:f,health:null,error:n instanceof Error?n.message:String(n)}),await r(f);return}if(!o)try{p=await He(f.instanceId)}catch{p=null}t({...e,installing:!1,result:f,health:p}),await r(f)}catch(n){i?.close(),t({...e,installing:!1,error:n instanceof Error?n.message:String(n)})}},[l,h,u,c,a,e,o,S,t,r]);return(0,Q.jsx)(b,{open:!0,onOpenChange:e=>{e||n()},children:(0,Q.jsxs)(ce,{children:[(0,Q.jsx)(g,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,Q.jsxs)(N,{className:s(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(100vh-2rem,44rem)] w-[min(100%-2rem,min(92vw,48rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-panel shadow-float dark:border-edge`),children:[(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,Q.jsx)(rt,{connector:a,size:`lg`}),(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(O,{className:`text-base font-semibold text-fg`,children:$(i.connectDialogTitle,{name:a.displayName})}),(0,Q.jsx)(le,{className:`mt-1 line-clamp-3 text-sm text-fg-muted`,children:a.description})]})]}),(0,Q.jsx)(y,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,className:s(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,de.focusRingPanel),"aria-label":i.modalClose,children:[(0,Q.jsx)(Ce,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`sr-only`,children:i.modalClose})]})})]}),(0,Q.jsxs)(`div`,{className:`min-h-0 overflow-y-auto px-6 py-5`,children:[(0,Q.jsx)(`div`,{className:`mb-5 grid grid-cols-3 gap-2`,"aria-label":i.connectProgressAria,children:T.map((e,t)=>{let n=T.findIndex(e=>e.id===w);return(0,Q.jsxs)(`div`,{className:s(`rounded-xl border px-3 py-2 text-xs font-medium`,t===n?`border-accent bg-accent-soft text-accent-fg`:t<n?`border-emerald-200 bg-emerald-50 text-emerald-800 dark:border-emerald-900/40 dark:bg-emerald-950/40 dark:text-emerald-200`:`border-edge bg-surface-base text-fg-muted`),children:[(0,Q.jsxs)(`span`,{className:`mr-1 tabular-nums`,children:[t+1,`.`]}),e.label]},e.id)})}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[o&&!u?(0,Q.jsxs)(`section`,{className:`rounded-2xl border border-accent/25 bg-accent-soft/50 p-4`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:i.composioSetupTitle}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:i.composioSetupHint}),(0,Q.jsxs)(`ol`,{className:`mt-3 list-inside list-decimal space-y-1 text-xs text-fg-muted`,children:[(0,Q.jsx)(`li`,{children:i.composioSetupStepProject}),(0,Q.jsx)(`li`,{children:i.composioSetupStepKey}),(0,Q.jsx)(`li`,{children:i.composioSetupStepPaste})]}),(0,Q.jsxs)(`a`,{className:`mt-3 inline-flex items-center gap-1 text-xs font-medium text-accent-fg hover:underline`,href:`https://app.composio.dev`,target:`_blank`,rel:`noreferrer`,children:[i.composioSetupOpenDashboard,(0,Q.jsx)(M,{className:`size-3.5`,"aria-hidden":!0})]}),(0,Q.jsx)(ge,{className:`mt-3`,value:h,onChange:_,labels:i.secretInputLabels,placeholder:i.composioSetupKeyPlaceholder}),(0,Q.jsx)(`p`,{className:`mt-2 text-[11px] text-fg-subtle`,children:i.composioSetupStorageHint})]}):null,o&&l?(0,Q.jsxs)(`label`,{className:`flex items-start gap-3 rounded-2xl border border-edge bg-surface-base p-4`,children:[(0,Q.jsx)(`input`,{type:`checkbox`,className:`mt-0.5 size-4 accent-accent`,checked:S,onChange:e=>C(e.currentTarget.checked)}),(0,Q.jsxs)(`span`,{children:[(0,Q.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:i.learnAfterConnect}),(0,Q.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-muted`,children:i.learnAfterConnectHint})]})]}):null,e.store?(0,Q.jsxs)(`section`,{className:`rounded-2xl border border-edge bg-surface-base p-4`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:i.detailPermissions}),(0,Q.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:[(e.store.permissions.data??[]).map(e=>(0,Q.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-panel px-2 py-1 text-xs text-fg-muted`,children:e},e)),(e.store.permissions.networkDomains??[]).map(e=>(0,Q.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-panel px-2 py-1 text-xs text-fg-muted`,children:e},e)),(0,Q.jsx)(`span`,{className:`rounded-md border border-emerald-500/30 bg-emerald-500/10 px-2 py-1 text-xs text-emerald-700 dark:text-emerald-300`,children:i.storeLocalExecDenied})]})]}):null,(a.setup.secrets??[]).map(n=>(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.label}),n.description?(0,Q.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:n.description}):null,(0,Q.jsx)(ge,{value:e.secrets[n.key]??``,onChange:r=>t({...e,secrets:{...e.secrets,[n.key]:r},error:null}),labels:i.secretInputLabels,placeholder:n.required?i.requiredPlaceholder:i.optionalPlaceholder})]},n.key)),(a.setup.config??[]).map(n=>(0,Q.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.label}),n.type===`json`?(0,Q.jsx)(`textarea`,{className:Sn,value:e.config[n.key]??``,placeholder:n.placeholder,onChange:r=>t({...e,config:{...e.config,[n.key]:r.currentTarget.value},error:null})}):(0,Q.jsx)(`input`,{className:xn,value:e.config[n.key]??``,placeholder:n.placeholder,onChange:r=>t({...e,config:{...e.config,[n.key]:r.currentTarget.value},error:null})})]},n.key)),e.installing?(0,Q.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-base p-4 text-sm text-fg-muted`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 font-medium text-fg`,children:[(0,Q.jsx)(D,{className:`size-4 animate-spin text-accent`,"aria-hidden":!0}),i.connectingTitle]}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:i.connectingHint})]}):null,e.error?(0,Q.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:e.error}):null,v?(0,Q.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:v}):null,e.result?(0,Q.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-base p-4 text-sm text-fg-muted`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Q.jsx)(`div`,{children:(0,Q.jsx)(`p`,{className:`font-medium text-fg`,children:i.connectedBadge})}),(0,Q.jsx)(`span`,{className:s(`rounded-full px-2 py-0.5 text-xs font-medium`,e.health?.ok?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e.health?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:`bg-surface-hover text-fg-muted`),children:e.health?.ok?i.healthStatusHealthy:Cn(e.health?.status,i)})]}),e.health?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`mt-3 grid gap-2 text-xs sm:grid-cols-3`,children:[(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2`,children:[(0,Q.jsx)(`div`,{className:`font-semibold text-fg`,children:e.health.toolCount}),(0,Q.jsx)(`div`,{children:i.toolsMetric})]}),(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2`,children:[(0,Q.jsx)(`div`,{className:`font-semibold text-fg`,children:e.health.resourceCount}),(0,Q.jsx)(`div`,{children:i.resourcesMetric})]}),(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2`,children:[(0,Q.jsx)(`div`,{className:`font-semibold text-fg`,children:e.health.promptCount}),(0,Q.jsx)(`div`,{children:i.promptsMetric})]})]}),(0,Q.jsxs)(`div`,{className:`mt-3 grid gap-2`,children:[(0,Q.jsx)(Tn,{title:i.detailTools,items:e.health.tools.map(e=>({id:e.name,title:e.shortName??e.name,description:e.description}))}),(0,Q.jsx)(Tn,{title:i.detailResources,items:e.health.resources.map(e=>({id:e.uri,title:e.title??e.name??e.uri,description:e.description??e.uri}))}),(0,Q.jsx)(Tn,{title:i.detailPrompts,items:e.health.prompts.map(e=>({id:e.name,title:e.title??e.name,description:e.description??$(i.promptArgumentCount,{count:String(e.argumentCount)})}))})]})]}):(0,Q.jsx)(`p`,{className:`mt-3`,children:i.installedWithoutHealth}),e.health?.action?(0,Q.jsx)(`p`,{className:`mt-3 text-xs text-fg-subtle`,children:e.health.action}):null]}):null]})]}),(0,Q.jsx)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:(0,Q.jsxs)(G,{variant:`primary`,disabled:!!e.result||e.installing||f||o&&!u&&!h.trim(),onClick:()=>void E(),children:[e.installing?(0,Q.jsx)(D,{className:`size-4 animate-spin`}):e.result?(0,Q.jsx)(m,{className:`size-4`}):(0,Q.jsx)(I,{className:`size-4`}),e.result?i.connectedBadge:i.connect]})})]})]})})}function On(e,t){let n={};for(let t of e.setup.secrets??[])n[t.key]=``;let r={};for(let t of e.setup.config??[])r[t.key]=t.defaultValue===void 0?``:typeof t.defaultValue==`string`?t.defaultValue:JSON.stringify(t.defaultValue,null,2);return{connector:e,secrets:n,config:r,installing:!1,error:null,result:null,health:null,...t?{store:t}:{}}}function kn(e,t){let n=e.length+1,r=`server-${n}`,i=new Set([...e.map(e=>e.id.trim()),...t]);for(;i.has(r);)n+=1,r=`server-${n}`;return Pt(r)}function An(e,t,n){let r=e.key.trim();if(r)return`key:${r}`;let i=e.value.trim();return i?`value:${i}`:`empty:${n.slice(0,t).filter(e=>!e.key.trim()&&!e.value.trim()).length}`}function jn(){return s(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,pe)}function Mn({label:e,optionalLabel:t,addLabel:n,removeHeaderAria:r,pasteLabel:i,pasteFailed:a,keyPlaceholder:o,valuePlaceholder:l,headers:u,onChange:d}){let f=(e,t)=>{d(u.map((n,r)=>r===e?{...n,...t}:n))},p=()=>{d([...u,{key:``,value:``}])},m=e=>{let t=u.filter((t,n)=>n!==e);d(t.length>0?t:[{key:``,value:``}])},h=async()=>{try{let e=await c();if(!e){window.alert(a);return}let t=Tt(e);if(!t?.length){window.alert(a);return}d(t)}catch{window.alert(a)}};return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 md:col-span-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium text-fg`,children:[(0,Q.jsx)(`span`,{children:e}),t?(0,Q.jsx)(`span`,{className:`font-normal text-fg-subtle`,children:t}):null]}),(0,Q.jsxs)(G,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5 px-2 text-xs`,onClick:()=>void h(),children:[(0,Q.jsx)(L,{className:`size-3.5`,"aria-hidden":!0}),i]})]}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:u.map((e,t)=>(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(`input`,{className:s(jn(),`min-w-0 flex-1 font-mono text-xs`),value:e.key,placeholder:o,onChange:e=>f(t,{key:e.target.value})}),(0,Q.jsx)(`input`,{className:s(jn(),`min-w-0 flex-[1.4] font-mono text-xs`),value:e.value,placeholder:l,onChange:e=>f(t,{value:e.target.value})}),(0,Q.jsx)(G,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 px-0`,disabled:u.length<=1&&!e.key&&!e.value,onClick:()=>m(t),"aria-label":r,children:(0,Q.jsx)(k,{className:`size-4 text-fg-subtle`,"aria-hidden":!0})})]},An(e,t,u)))}),(0,Q.jsxs)(`button`,{type:`button`,className:s(`self-start text-sm text-accent hover:underline`,de.press),onClick:p,children:[`+ `,n]})]})}var Nn=[`stdio`,`sse`,`streamable-http`];function Pn(e){let t=(0,X.c)(11),{label:n,description:r,required:i,children:a}=e,o;t[0]===i?o=t[1]:(o=i?(0,Q.jsx)(`span`,{className:`ml-0.5 text-danger`,children:`*`}):null,t[0]=i,t[1]=o);let s;t[2]!==n||t[3]!==o?(s=(0,Q.jsxs)(`div`,{className:`text-sm font-medium text-fg`,children:[n,o]}),t[2]=n,t[3]=o,t[4]=s):s=t[4];let c;t[5]===r?c=t[6]:(c=r?(0,Q.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:r}):null,t[5]=r,t[6]=c);let l;return t[7]!==a||t[8]!==s||t[9]!==c?(l=(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[s,a,c]}),t[7]=a,t[8]=s,t[9]=c,t[10]=l):l=t[10],l}function Fn(){return s(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,pe)}function In(e){let t=(0,X.c)(35),{row:n,t:r,onUpdate:i,idConflictMessage:a,variant:o}=e,c=o===void 0?`all`:o,l=c===`all`||c===`basic`,u=c===`all`||c===`advanced`,d;t[0]!==a||t[1]!==i||t[2]!==n.id||t[3]!==n.transport||t[4]!==l||t[5]!==r?(d=l?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Pn,{label:r.transportLabel,required:!0,children:(0,Q.jsx)(w,{className:Fn(),value:n.transport,onChange:e=>i({transport:e.target.value}),children:Nn.map(e=>(0,Q.jsx)(R,{value:e,children:r.transportLabels[e]},e))})}),(0,Q.jsxs)(Pn,{label:r.serverIdLabel,required:!0,children:[(0,Q.jsx)(`input`,{className:Fn(),value:n.id,placeholder:r.serverIdPlaceholder,onChange:e=>i({id:e.target.value})}),a?(0,Q.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-300`,children:a}):null]})]}):null,t[0]=a,t[1]=i,t[2]=n.id,t[3]=n.transport,t[4]=l,t[5]=r,t[6]=d):d=t[6];let f;t[7]!==i||t[8]!==n.argsText||t[9]!==n.command||t[10]!==n.cwd||t[11]!==n.envJson||t[12]!==n.headers||t[13]!==n.transport||t[14]!==n.url||t[15]!==u||t[16]!==l||t[17]!==r||t[18]!==c?(f=n.transport===`stdio`?(0,Q.jsxs)(Q.Fragment,{children:[l?(0,Q.jsx)(`div`,{className:c===`basic`?`md:col-span-2`:void 0,children:(0,Q.jsx)(Pn,{label:r.commandLabel,required:!0,children:(0,Q.jsx)(`input`,{className:Fn(),value:n.command,onChange:e=>i({command:e.target.value})})})}):null,u?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Pn,{label:r.argsLabel,description:r.argsHint,children:(0,Q.jsx)(`input`,{className:Fn(),value:n.argsText,onChange:e=>i({argsText:e.target.value})})}),(0,Q.jsx)(Pn,{label:r.cwdLabel,children:(0,Q.jsx)(`input`,{className:Fn(),value:n.cwd,onChange:e=>i({cwd:e.target.value})})}),(0,Q.jsx)(Pn,{label:r.envLabel,description:r.envHint,children:(0,Q.jsx)(`textarea`,{className:s(Fn(),`min-h-[4rem] font-mono text-xs`),value:n.envJson,onChange:e=>i({envJson:e.target.value})})})]}):null]}):(0,Q.jsxs)(Q.Fragment,{children:[l?(0,Q.jsx)(`div`,{className:`md:col-span-2`,children:(0,Q.jsx)(Pn,{label:r.urlLabel,required:!0,children:(0,Q.jsx)(`input`,{className:s(Fn(),`font-mono text-xs`),value:n.url,placeholder:`https://example.com/mcp`,onChange:e=>i({url:e.target.value})})})}):null,u?(0,Q.jsx)(Mn,{label:r.headersLabel,optionalLabel:r.optionalSuffix,addLabel:r.addHeader,removeHeaderAria:r.removeHeader,pasteLabel:r.pasteHeaders,pasteFailed:r.pasteHeadersFailed,keyPlaceholder:r.headerKeyPlaceholder,valuePlaceholder:r.headerValuePlaceholder,headers:n.headers,onChange:e=>i({headers:e})}):null]}),t[7]=i,t[8]=n.argsText,t[9]=n.command,t[10]=n.cwd,t[11]=n.envJson,t[12]=n.headers,t[13]=n.transport,t[14]=n.url,t[15]=u,t[16]=l,t[17]=r,t[18]=c,t[19]=f):f=t[19];let p;t[20]!==i||t[21]!==n||t[22]!==u||t[23]!==r?(p=u?(0,Q.jsx)(Pn,{label:r.timeoutLabel,description:r.timeoutHint,children:(0,Q.jsx)(`input`,{type:`number`,min:1,max:600,className:Fn(),value:Ht(n),placeholder:r.timeoutPlaceholder,onChange:e=>i({connectionTimeoutMs:Ut(e.target.value)})})}):null,t[20]=i,t[21]=n,t[22]=u,t[23]=r,t[24]=p):p=t[24];let m;t[25]!==i||t[26]!==n||t[27]!==u||t[28]!==r?(m=u?(0,Q.jsx)(Pn,{label:r.requestTimeoutLabel,description:r.requestTimeoutHint,children:(0,Q.jsx)(`input`,{type:`number`,min:1,max:14400,className:Fn(),value:Wt(n),placeholder:r.requestTimeoutPlaceholder,onChange:e=>i({requestTimeoutMs:Gt(e.target.value)})})}):null,t[25]=i,t[26]=n,t[27]=u,t[28]=r,t[29]=m):m=t[29];let h;return t[30]!==d||t[31]!==f||t[32]!==p||t[33]!==m?(h=(0,Q.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[d,f,p,m]}),t[30]=d,t[31]=f,t[32]=p,t[33]=m,t[34]=h):h=t[34],h}function Ln(e,t){if(e.shortName)return e.shortName;let n=`${t.trim()}__`;return n&&e.name.startsWith(n)?e.name.slice(n.length):e.name}function Rn(e){let t=(0,X.c)(13),{tool:n,serverId:r}=e,i;t[0]!==r||t[1]!==n?(i=Ln(n,r),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a=i,o=n.name===a?a:n.name,c;t[3]===n.description?c=t[4]:(c=n.description?.trim(),t[3]=n.description,t[4]=c);let l=c,u;t[5]!==a||t[6]!==o?(u=(0,Q.jsx)(`p`,{className:`break-all font-mono text-xs font-medium leading-5 text-fg`,title:o,children:a}),t[5]=a,t[6]=o,t[7]=u):u=t[7];let d;t[8]===l?d=t[9]:(d=l?(0,Q.jsx)(te,{delayDuration:300,skipDelayDuration:100,children:(0,Q.jsxs)(ie,{children:[(0,Q.jsx)(ve,{asChild:!0,children:(0,Q.jsx)(`p`,{tabIndex:0,title:l,className:s(`mt-1 line-clamp-3 cursor-help text-xs leading-5 text-fg-muted`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`),children:l})}),(0,Q.jsx)(Se,{children:(0,Q.jsx)(ue,{side:`top`,align:`start`,sideOffset:6,collisionPadding:12,className:`!z-[10000] max-h-[min(16rem,45vh)] max-w-[min(32rem,calc(100vw-2rem))] overflow-y-auto rounded-md border border-edge bg-surface-panel px-2.5 py-2 text-left text-xs leading-5 text-fg shadow-popover`,children:(0,Q.jsx)(`span`,{className:`whitespace-pre-wrap break-words`,children:l})})})]})}):null,t[8]=l,t[9]=d);let f;return t[10]!==u||t[11]!==d?(f=(0,Q.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-edge bg-surface-panel px-3 py-2.5`,children:[u,d]}),t[10]=u,t[11]=d,t[12]=f):f=t[12],f}function zn({open:e,mode:t,initialRow:n,existingCustomServers:r,sessionIdleTtlMinutes:i,config:a,managedServerIds:o,t:c,cs:l,onClose:u,onSaved:d}){let[f,p]=(0,Z.useState)(n),[h,_]=(0,Z.useState)(!1),[v,x]=(0,Z.useState)(!1),[S,C]=(0,Z.useState)(null),[w,T]=(0,Z.useState)(!1),[E,k]=(0,Z.useState)({status:`idle`}),[A,j]=(0,Z.useState)(null),M=n.id.trim(),P=f.id.trim()!==M&&o.has(f.id.trim())||o.has(f.id.trim())&&t===`add`?c.reservedServerId:void 0,F=f.id.trim()&&r.some(e=>e.clientKey!==n.clientKey&&e.id.trim()===f.id.trim())?l.duplicateServerId:void 0,I=f.id.trim().length>0&&!P&&!F&&(f.transport===`stdio`?f.command.trim().length>0:f.url.trim().length>0),L=Kt(f),R=(0,Z.useCallback)(async()=>{if(f.id.trim()){x(!0),C(null),k({status:`loading`});try{k({status:`ok`,tools:(await Vt(f.id.trim(),It(f))).tools})}catch(e){k({status:`error`,message:e instanceof Error?e.message:String(e)})}finally{x(!1)}}},[f]),z=(0,Z.useCallback)(async()=>{if(!(!I||h)){_(!0),C(null);try{let e=r.filter(e=>!(t===`edit`&&e.clientKey===n.clientKey));e.push(f),await Lt({sessionIdleTtlMinutes:i,servers:e.sort((e,t)=>e.id.localeCompare(t.id))},kt(a)),await d(),u()}catch(e){C(e instanceof Error?e.message:String(e))}finally{_(!1)}}},[I,a,r,n.clientKey,t,u,d,M,f,h,i]);return e?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(b,{open:e,onOpenChange:e=>{e||u()},children:(0,Q.jsxs)(ce,{children:[(0,Q.jsx)(g,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,Q.jsxs)(N,{className:s(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(100vh-2rem,44rem)] w-[min(100%-2rem,min(92vw,48rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-panel shadow-float dark:border-edge`),children:[(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(O,{className:`text-base font-semibold text-fg`,children:t===`add`?l.addCustomServerTitle:l.editCustomServerTitle}),(0,Q.jsx)(le,{className:`mt-1 text-sm text-fg-muted`,children:t===`add`?l.addCustomServerHint:l.editCustomServerHint})]}),(0,Q.jsx)(y,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,className:s(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,de.focusRingPanel),"aria-label":l.modalClose,children:[(0,Q.jsx)(Ce,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`sr-only`,children:l.modalClose})]})})]}),(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,Q.jsx)(`section`,{className:`rounded-xl border border-edge bg-surface-base p-4`,children:(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,Q.jsx)(re,{className:`size-4 text-accent`,"aria-hidden":!0}),f.id.trim()||c.cardUntitled]}),(0,Q.jsx)(`p`,{className:`mt-1 break-all font-mono text-xs leading-5 text-fg-muted`,children:L||(f.transport===`stdio`?c.commandLabel:c.urlLabel)})]}),(0,Q.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:c.transportLabels[f.transport]})]})}),(0,Q.jsxs)(`section`,{children:[(0,Q.jsxs)(`div`,{className:`mb-3`,children:[(0,Q.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:l.connectorBasicConfigTitle}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:l.connectorBasicConfigHint})]}),(0,Q.jsx)(In,{row:f,t:c,variant:`basic`,onUpdate:e=>{p(t=>({...t,...e})),C(null)},idConflictMessage:P??F})]}),E.status===`ok`?(0,Q.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-base p-3`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,Q.jsx)(K,{className:`size-4 text-accent`,"aria-hidden":!0}),E.tools.length===0?c.toolsEmpty:c.toolsTitle.replace(`{{count}}`,String(E.tools.length))]}),E.tools.length>0?(0,Q.jsx)(G,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,onClick:()=>j(E.tools),children:c.viewAllTools}):null]}),E.tools.length>0?(0,Q.jsx)(`div`,{className:`mt-3 grid gap-2`,children:E.tools.slice(0,6).map((e,t)=>(0,Q.jsx)(Rn,{tool:e,serverId:f.id},e.name||`tool-${t}`))}):null]}):null,E.status===`error`?(0,Q.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:E.message}):null,S?(0,Q.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:S}):null,(0,Q.jsxs)(`details`,{open:w,onToggle:e=>T(e.currentTarget.open),className:`group rounded-xl border border-edge bg-surface-base`,children:[(0,Q.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg hover:text-fg [&::-webkit-details-marker]:hidden`,children:[(0,Q.jsx)(oe,{className:`size-4 text-fg-muted transition-transform group-open:rotate-180`,"aria-hidden":!0}),(0,Q.jsx)(`span`,{className:`group-open:hidden`,children:l.connectorShowAdvancedConfig}),(0,Q.jsx)(`span`,{className:`hidden group-open:inline`,children:l.connectorHideAdvancedConfig})]}),(0,Q.jsx)(`div`,{className:`border-t border-edge p-4`,children:(0,Q.jsx)(In,{row:f,t:c,variant:`advanced`,onUpdate:e=>{p(t=>({...t,...e})),C(null)}})})]})]})}),(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[(0,Q.jsxs)(G,{variant:`secondary`,disabled:!f.id.trim()||v,onClick:()=>void R(),children:[v?(0,Q.jsx)(D,{className:`size-4 animate-spin`}):(0,Q.jsx)(W,{className:`size-4`}),c.testConnection]}),(0,Q.jsx)(y,{asChild:!0,children:(0,Q.jsx)(G,{variant:`secondary`,children:l.modalCancel})}),(0,Q.jsxs)(G,{variant:`primary`,disabled:!I||h,onClick:()=>void z(),children:[h?(0,Q.jsx)(D,{className:`size-4 animate-spin`}):(0,Q.jsx)(m,{className:`size-4`}),h?c.saving:l.modalSave]})]})]})]})}),A?(0,Q.jsx)(Qt,{open:!0,onOpenChange:e=>{e||j(null)},serverId:f.id,title:c.toolsDialogTitle,subtitle:c.toolsDialogSubtitle,searchPlaceholder:c.toolsDialogSearchPlaceholder,searchEmptyLabel:c.toolsDialogSearchEmpty,emptyLabel:c.toolsEmpty,closeLabel:c.toolsDialogClose,tools:A,stripPrefix:`${f.id.trim()}__`}):null]}):null}var Bn=`builtin`,Vn=`composio`,Hn=`xopc-store`;function Un(e){return Bn}function Wn(e){return!(e.runtime.type===`composio`&&e.runtime.role===`credential`)}function Gn(e,t){let n=t.trim().toLowerCase();return n?[e.displayName,e.description,e.category,e.kind,e.source,...e.tags??[]].some(e=>e.toLowerCase().includes(n)):!0}function Kn(e,t,n){return e.filter(e=>Gn(e,t)).toSorted((e,t)=>n===`source`&&e.source!==t.source?e.source.localeCompare(t.source):e.displayName.localeCompare(t.displayName))}function qn(e,t){let n=t.trim().toLowerCase();return n?[e.displayName,e.connectorId,e.instanceId,e.status,e.connectionStatus??``,e.materialized.type,e.materialized.type===`mcp`?e.materialized.serverId:e.materialized.id].some(e=>e.toLowerCase().includes(n)):!0}function Jn(e,t){let n=t.trim().toLowerCase();return n?[e.id,e.command??``,e.url??``,e.transport].some(e=>e.toLowerCase().includes(n)):!0}function Yn(e){let t=[`code`,`docs`,`browser`,`data`,`automation`,`custom`].includes(e.category??``)?e.category:`custom`;return{id:e.name,version:e.latestVersion??`store`,displayName:e.name,description:e.description,category:t,kind:`mcp`,source:`store`,capabilities:[`tools`,`runtime.mcp.streamableHttp`],tags:[`store`],auth:{mode:`none`},setup:{},runtime:{type:`mcp`,serverId:`store-${e.name}`.slice(0,64)}}}function Xn(e){return e.filter((e,t,n)=>n.findIndex(t=>t.id===e.id)===t)}function Zn(e){return e?.startsWith(`/`)&&!e.startsWith(`//`)?e:`/you?tab=sources`}function Qn(){let e=l(d(e=>e.language)),t=e.connectorsSettings,n=e.mcpSettings,r=u(e=>e.token),o=!!r,c=a(),[f,p]=i(),m=f.get(`understanding`)===`1`,h=Zn(f.get(`returnTo`)),g=f.get(`tab`),[_,y]=(0,Z.useState)(!m&&g===`connected`?`connected`:`discover`),b=(0,Z.useRef)(!1),[S,C]=(0,Z.useState)({catalog:[],registryCatalog:[],instances:[],loading:!0,error:null,peopleGraph:null}),[w,T]=(0,Z.useState)(!1),[E,O]=(0,Z.useState)(!1),[k,A]=(0,Z.useState)(1),[j,M]=(0,Z.useState)(void 0),[N,P]=(0,Z.useState)(``),[F,I]=(0,Z.useState)(``),[L,R]=(0,Z.useState)(!1),[B,V]=(0,Z.useState)(m?f.get(`connector`)??``:``),[H,ee]=(0,Z.useState)(Un(m?`understanding`:`default`)),[U,te]=(0,Z.useState)(`name`),[ne,re]=(0,Z.useState)(m?`understand`:`all`),[ie,W]=(0,Z.useState)(null),[oe,ce]=(0,Z.useState)(null),[le,ue]=(0,Z.useState)(null),[de,fe]=(0,Z.useState)(null),[pe,me]=(0,Z.useState)(null),[he,ge]=(0,Z.useState)(null),[_e,ve]=(0,Z.useState)(!1),[ye,be]=(0,Z.useState)(void 0),[xe,Se]=(0,Z.useState)(!1),{data:Ce,mutate:K}=ae(o),q=Ce?.payload?.config,J=(0,Z.useMemo)(()=>q===void 0?null:Ft(q),[q]),Y=J?.servers??[],Te=S.instances.length+Y.length;(0,Z.useEffect)(()=>{J&&be(J.sessionIdleTtlMinutes)},[J]);let Ee=(0,Z.useCallback)(async()=>{if(!r){C({catalog:[],registryCatalog:[],instances:[],loading:!1,error:null,peopleGraph:null});return}C(e=>({...e,loading:!0,error:null}));try{let[e,t,n]=await Promise.all([Be(),Ne(),Je(``,12).catch(()=>null)]);C(r=>({catalog:e,registryCatalog:r.registryCatalog,instances:t,loading:!1,error:null,peopleGraph:n}))}catch(e){C({catalog:[],registryCatalog:[],instances:[],loading:!1,error:e instanceof Error?e.message:String(e),peopleGraph:null})}},[r]);(0,Z.useEffect)(()=>{Ee()},[Ee]),(0,Z.useEffect)(()=>{if(!o||_!==`connected`)return;let e=!1,t=window.setTimeout(()=>{R(!0),Je(F,50).then(t=>{e||C(e=>({...e,peopleGraph:t}))}).catch(()=>{}).finally(()=>{e||R(!1)})},250);return()=>{e=!0,window.clearTimeout(t)}},[o,F,_]),(0,Z.useEffect)(()=>{b.current||S.loading||o&&!J||(y(m?`discover`:Te>0?`connected`:`discover`),b.current=!0)},[o,Te,J,m,S.loading]);let De=(0,Z.useCallback)(e=>{b.current=!0,y(e)},[]),Oe=(0,Z.useMemo)(()=>[{id:Vn,displayName:t.composioSourceName},{id:Hn,displayName:t.storeSourceName}],[t.composioSourceName,t.storeSourceName]),ke=(0,Z.useCallback)(async e=>{if(!o||H===`builtin`){C(e=>({...e,registryCatalog:[]})),A(1),M(void 0);return}let t=B.trim(),n=Math.max(e?.page??1,1),r=e?.append??!1,i=H===`all`?Oe:Oe.filter(e=>e.id===H);if(i.length!==0){T(!0),r?C(e=>({...e,error:null})):(A(1),M(void 0),C(e=>({...e,registryCatalog:[],error:null})));try{let e=await Promise.all(i.map(async e=>{if(e.id===`composio`){let e=await Ge({q:t||void 0,page:n,pageSize:24,verification:`experimental`});return{connectors:e.connectors,totalPages:e.meta.totalPages}}let r=await Ke({q:t||void 0,page:n,pageSize:24,sort:U===`source`?`newest`:`downloads`});return{connectors:r.items.map(Yn),totalPages:r.meta.totalPages}})),a=Xn(e.flatMap(e=>e.connectors)),o=Math.max(1,...e.map(e=>e.totalPages??1));A(n),M(o),C(e=>({...e,registryCatalog:r?Xn([...e.registryCatalog,...a]):a}))}catch(e){C(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{T(!1)}}},[U,B,H,o,Oe]);(0,Z.useEffect)(()=>{if(_!==`discover`||S.loading)return;if(H===`builtin`){C(e=>({...e,registryCatalog:[]})),A(1),M(void 0);return}let e=window.setTimeout(()=>{ke()},B.trim()?350:0);return()=>window.clearTimeout(e)},[B,H,ke,S.loading,_]);let Ae=(0,Z.useMemo)(()=>new Set(S.instances.map(e=>e.connectorId)),[S.instances]),je=(0,Z.useMemo)(()=>new Map([...S.catalog,...S.registryCatalog].map(e=>[e.id,e])),[S.catalog,S.registryCatalog]);(0,Z.useEffect)(()=>{if(S.loading)return;let e=f.get(`connector`),t=f.get(`instance`);if(!e&&!t)return;let n=S.instances.find(n=>t?n.instanceId===t:n.connectorId===e);if(n)b.current=!0,P(``),ue(n.instanceId),fe(n),y(`connected`);else if(e){let t=je.get(e);if(!t)return;b.current=!0,ee(Un(m?`understanding`:`default`)),V(``),ce(t),y(`discover`)}let r=new URLSearchParams(f);r.delete(`connector`),r.delete(`instance`),r.set(`tab`,n?`connected`:`discover`),p(r,{replace:!0})},[je,m,f,p,S.instances,S.loading]);let Me=(0,Z.useCallback)(async e=>{O(!0),C(e=>({...e,error:null}));try{let t=await Ye(e);W(On(t.definition,{packageName:t.packageName,version:t.version,permissions:t.permissions}))}catch(e){C(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{O(!1)}},[]),Pe=(0,Z.useMemo)(()=>new Set(S.instances.flatMap(e=>e.materialized.type===`mcp`?[e.materialized.serverId]:[])),[S.instances]),Fe=(0,Z.useCallback)(async e=>{if(!J||q===void 0)return;let t=Y.filter(t=>t.clientKey!==e.clientKey);await Lt({sessionIdleTtlMinutes:J.sessionIdleTtlMinutes,servers:t},kt(q)),await K(),await Ee()},[q,Y,Ee,J,K]),Ie=(0,Z.useCallback)(()=>{ge({mode:`add`,row:kn(Y,Pe)})},[Y,Pe]),Le=(0,Z.useCallback)(async()=>{if(!(!J||q===void 0||xe)){Se(!0);try{await Lt({sessionIdleTtlMinutes:ye,servers:Y},kt(q)),await K(),ve(!1)}finally{Se(!1)}}},[q,Y,n.saved,J,K,ye,xe]),Re=x(e=>e.setPageHeader),ze=x(e=>e.clearPageHeader),Ve=(0,Z.useMemo)(()=>(0,Q.jsx)(Ct,{onBrowseCatalog:()=>De(`discover`),onAddCustomServer:Ie,onOpenRuntimeSettings:()=>ve(!0),addLabel:t.addConnection,browseLabel:t.addFromCatalog,customLabel:t.addCustomServerAdvanced,settingsLabel:t.runtimeSettings}),[t,Ie,De]);(0,Z.useLayoutEffect)(()=>(Re({startExtra:null,main:(0,Q.jsx)(`div`,{className:`min-w-0`,children:(0,Q.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.title})}),end:Ve}),()=>ze()),[ze,t.title,Ve,Re]);let He=(0,Z.useMemo)(()=>S.instances.map(e=>({instance:e,value:yn(e,je.get(e.connectorId))})),[je,S.instances]),Ue=(0,Z.useMemo)(()=>new Map(He.map(({instance:e,value:t})=>[e.instanceId,t])),[He]),We=(0,Z.useMemo)(()=>S.instances.filter(e=>qn(e,N)).sort((e,t)=>{let n={needs_setup:0,checking:1,ready:2},r=Ue.get(e.instanceId)?.state??`checking`,i=Ue.get(t.instanceId)?.state??`checking`;return n[r]-n[i]||e.displayName.localeCompare(t.displayName)}),[N,Ue,S.instances]),qe=(0,Z.useMemo)(()=>Y.filter(e=>Jn(e,N)),[N,Y]),Xe=We.length+qe.length,Ze=(0,Z.useMemo)(()=>S.catalog.filter(e=>e.source===`builtin`&&e.integrationStrategy?.preferred!==!1&&Wn(e)),[S.catalog]),Qe=(0,Z.useMemo)(()=>H===`builtin`?Ze:H===`all`?Xn([...Ze,...S.registryCatalog]):S.registryCatalog,[Ze,H,S.registryCatalog]),$e=(0,Z.useMemo)(()=>{let e=m?Qe.filter(e=>e.understanding?.mode===`activity`):Qe;return Kn(ne===`all`?e:e.filter(e=>_n(e).includes(ne)),B,U)},[U,B,Qe,m,ne]),et=(0,Z.useMemo)(()=>gn.filter(e=>Qe.some(t=>_n(t).includes(e))),[Qe]);(0,Z.useEffect)(()=>{ne!==`all`&&!et.includes(ne)&&re(`all`)},[et,ne]);let tt=_===`discover`&&H!==`builtin`&&!!(j&&k<j),X=(0,Z.useMemo)(()=>S.instances.find(e=>e.instanceId===le)??de,[le,de,S.instances]),nt=(0,Z.useMemo)(()=>[{value:`all`,label:t.discoverSourceAll},{value:Bn,label:t.discoverSourceBuiltin},...Oe.map(e=>({value:e.id,label:e.displayName}))],[t.discoverSourceAll,t.discoverSourceBuiltin,Oe]),rt=[{id:`connected`,label:t.tabConnected,count:Te},{id:`discover`,label:t.tabDiscover}];return(0,Q.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:(0,Q.jsxs)(`div`,{className:`flex w-full flex-col gap-6 px-3 py-6 sm:px-5 xl:px-6`,children:[o?null:(0,Q.jsx)(`p`,{className:`rounded-xl border border-edge bg-surface-panel px-4 py-3 text-sm text-fg-muted`,children:t.tokenHint}),m?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border border-accent/25 bg-accent-soft px-4 py-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:t.understandingSetupTitle}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:t.understandingSetupHint})]}),(0,Q.jsx)(G,{type:`button`,variant:`secondary`,className:`shrink-0`,onClick:()=>c(h),children:t.understandingSetupDone})]}):null,(0,Q.jsxs)(`section`,{className:`flex flex-col gap-4`,children:[(0,Q.jsx)(`div`,{className:`border-b border-edge-subtle pb-3 dark:border-edge-subtle`,children:(0,Q.jsx)(we,{items:rt,activeTab:_,onChange:De,ariaLabel:t.navAria,tabIdPrefix:`connectors-tab`,panelIdPrefix:`connectors-panel`,className:`flex-wrap`})}),S.error?(0,Q.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:S.error}):null,_===`connected`&&o?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center`,children:[(0,Q.jsx)(St,{value:N,onChange:P,placeholder:t.connectedSearchPlaceholder,className:`max-w-xl`}),(0,Q.jsx)(se,{className:`size-9 shrink-0 p-0`,loading:S.loading,label:t.refreshConnections,title:t.refreshConnections,onClick:Ee})]}),S.peopleGraph&&(S.peopleGraph.people.length>0||F)?(0,Q.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsx)(`div`,{className:`rounded-lg bg-accent-soft p-2 text-accent-fg`,children:(0,Q.jsx)(v,{className:`size-4`,"aria-hidden":!0})}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.peopleGraphTitle}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.peopleGraphHint.replace(`{{people}}`,String(S.peopleGraph.people.length)).replace(`{{sources}}`,String(new Set(S.peopleGraph.sourceEdges.map(e=>e.sourceInstanceId)).size))})]})]}),(0,Q.jsxs)(`div`,{className:`relative w-full max-w-xs`,children:[(0,Q.jsx)(St,{value:F,onChange:I,placeholder:t.peopleGraphSearchPlaceholder}),L?(0,Q.jsx)(D,{className:`absolute right-3 top-2.5 size-4 animate-spin text-fg-subtle`,"aria-hidden":!0}):null]})]}),S.peopleGraph.people.length?(0,Q.jsx)(`div`,{className:`mt-4 grid gap-2 sm:grid-cols-2`,children:S.peopleGraph.people.slice(0,10).map(e=>{let t=[...new Set(S.peopleGraph.sourceEdges.filter(t=>t.personId===e.id).map(e=>e.toolkit??e.connectorId??e.sourceInstanceId))];return(0,Q.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-panel px-3 py-2.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,Q.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:e.label}),(0,Q.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:e.mentionCount})]}),(0,Q.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted`,children:e.emails[0]??e.usernames[0]??e.roles.join(` · `)}),(0,Q.jsx)(`p`,{className:`mt-1 truncate text-[11px] text-fg-subtle`,children:t.join(` · `)})]},e.id)})}):(0,Q.jsx)(`p`,{className:`mt-4 text-sm text-fg-muted`,children:t.peopleGraphSearchEmpty})]}):null,S.loading?(0,Q.jsx)(`div`,{className:`grid gap-3`,"aria-busy":`true`,"aria-label":t.loading,children:ot.slice(0,3).map(e=>(0,Q.jsx)(dt,{},e))}):Te===0?(0,Q.jsxs)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center`,children:[(0,Q.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.connectionsEmpty}),(0,Q.jsx)(G,{type:`button`,variant:`primary`,className:`mt-4`,onClick:()=>De(`discover`),children:t.addFromCatalog})]}):Xe===0?(0,Q.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center text-sm text-fg-muted`,children:t.connectionsSearchEmpty}):(0,Q.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:[We.map(e=>(0,Q.jsx)(bn,{instance:e,definition:je.get(e.connectorId),highlighted:e.instanceId===pe,onOpenDetails:e=>{me(null),ue(e.instanceId),fe(e)},onChanged:Ee,t},e.instanceId)),qe.map(e=>(0,Q.jsx)(qt,{row:e,t:n,cs:t,onEdit:()=>ge({mode:`edit`,row:structuredClone(e)}),onRemove:async()=>Fe(e)},e.clientKey))]})]}):null,_===`discover`&&o?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[m?null:(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-2`,role:`group`,"aria-label":t.taskFilterAria,children:[`all`,...et].map(e=>(0,Q.jsx)(`button`,{type:`button`,className:s(`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors`,ne===e?`border-accent/40 bg-accent-soft text-accent-fg`:`border-edge bg-surface-panel text-fg-muted hover:bg-surface-hover hover:text-fg`),"aria-pressed":ne===e,onClick:()=>re(e),children:e===`all`?t.taskAll:t.connectorBenefitHeadings[e]},e))}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 lg:flex-row lg:items-center`,children:[(0,Q.jsx)(St,{value:B,onChange:V,placeholder:t.discoverSearchPlaceholder,className:`max-w-xl`}),(0,Q.jsxs)(`div`,{className:s(`grid min-w-0 grid-cols-1 gap-2 lg:ml-auto`,m?`lg:w-52`:`sm:grid-cols-2 lg:w-[26rem]`),children:[m?null:(0,Q.jsx)(z,{value:H,options:nt,placeholder:t.discoverSourceAll,allowEmpty:!1,ariaLabel:t.registrySourceAria,triggerClassName:`h-9 bg-surface-panel text-xs`,onChange:ee}),(0,Q.jsx)(z,{value:U,options:[{value:`name`,label:t.sortName},{value:`source`,label:t.sortSource}],placeholder:t.sortName,allowEmpty:!1,ariaLabel:t.sortAria,triggerClassName:`h-9 bg-surface-panel text-xs`,onChange:e=>te(e)})]})]}),(S.loading||w)&&$e.length===0?(0,Q.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,"aria-busy":`true`,"aria-label":t.loading,children:ot.map(e=>(0,Q.jsx)(lt,{},e))}):$e.length===0?(0,Q.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center text-sm text-fg-muted`,children:t.discoverEmpty}):(0,Q.jsxs)(`div`,{className:`relative`,children:[w?(0,Q.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-[1] flex justify-center bg-surface-panel/40 pt-[min(28vh,7.5rem)] backdrop-blur-[1px] motion-reduce:backdrop-blur-none dark:bg-surface-base/35`,"aria-busy":`true`,"aria-label":t.loading,children:(0,Q.jsx)(D,{className:`size-8 shrink-0 animate-spin text-accent motion-reduce:animate-none`,strokeWidth:2,"aria-hidden":!0})}):null,(0,Q.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:$e.map(e=>(0,Q.jsx)(it,{connector:e,installed:Ae.has(e.id)||st(e,S.instances),onInstall:e=>{if(e.source===`store`){Me(e.id);return}W(On(e))},onOpenDetails:e.source===`store`?void 0:ce,t},e.id))}),tt?(0,Q.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,Q.jsxs)(G,{type:`button`,variant:`secondary`,disabled:w||E,onClick:()=>void ke({page:k+1,append:!0}),children:[w?(0,Q.jsx)(D,{className:`size-4 animate-spin`}):null,t.loadMore]})}):null]})]}):null]}),ie?(0,Q.jsx)(Dn,{draft:ie,onChange:W,onClose:()=>W(null),t,onInstalled:async e=>{await Ee(),await K(),me(e.instanceId),De(`connected`)}}):null,oe?(0,Q.jsx)(yt,{connector:oe,installed:Ae.has(oe.id)||st(oe,S.instances),onClose:()=>ce(null),onInstall:e=>W(On(e)),t}):null,X?(0,Q.jsx)(hn,{instance:X,definition:je.get(X.connectorId),onClose:()=>{ue(null),fe(null)},onChanged:Ee,t,mcp:n}):null,he?(0,Q.jsx)(zn,{open:!0,mode:he.mode,initialRow:he.row,existingCustomServers:Y,sessionIdleTtlMinutes:ye,config:q,managedServerIds:Pe,t:n,cs:t,onClose:()=>ge(null),onSaved:async()=>{await K(),await Ee(),De(`connected`)}},`${he.mode}-${he.row.clientKey}`):null,(0,Q.jsx)(xt,{open:_e,sessionIdleTtlMinutes:ye,saving:xe,onChange:be,onSave:Le,onClose:()=>ve(!1),t,mcp:n})]})})}export{Qn as ConnectorsPage};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{c as i,l as a,t as o}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as s}from"./check-DUBLcKHA.js";import{t as c}from"./cn-JdwAhgNB.js";import{t as l}from"./messages-DMJ-6-1m.js";import{n as u,o as d,r as f}from"./locale-store-VOY1wMO9.js";import{n as p}from"./activity-store-B-tzXpDD.js";import{$l as m,Ao as h,Do as g,Eo as _,Fa as v,Fc as y,Gs as b,Hl as x,Lc as S,Mo as C,Ms as w,Oo as T,Sn as E,St as D,Ta as O,_t as k,au as A,bt as j,el as M,gt as N,hs as P,jo as ee,js as te,ko as ne,mt as re,nu as F,pc as ie,pt as ae,rt as I,tu as L,vs as oe,vt as se,wt as ce,wu as le,xn as ue,xt as de}from"./index-DzmbmOGA.js";var R=e(t(),1),z=n();function B(e){try{return decodeURIComponent(e).trim()||null}catch{return null}}function V(e){if(!e)return null;let t=e.split(/[?#]/,1)[0],n=/^\/chat\/([^/]+)\/?$/.exec(t);if(n){let e=B(n[1]);return!e||e===`new`?null:{kind:`session`,id:e}}return null}async function H(e,t){let n=`/api/sessions/${encodeURIComponent(e.id)}?limit=1`;try{return(await d(f(n),{signal:t})).status===404?`missing`:`available`}catch(e){if(t?.aborted)throw e;return`available`}}var U=r(),W=3,G={info:{Icon:M,className:`text-accent-fg bg-accent-soft`},success:{Icon:m,className:`text-success bg-success-soft`},warning:{Icon:te,className:`text-warning bg-warning-soft`},error:{Icon:L,className:`text-danger bg-danger-soft`}};function K(e,t){let n=Math.max(0,Math.round((Date.now()-e)/1e3));if(n<60)return t===`zh`?`刚刚`:`Just now`;let r=Math.round(n/60);if(r<60)return t===`zh`?`${r} 分钟前`:`${r}m ago`;let i=Math.round(r/60);if(i<24)return t===`zh`?`${i} 小时前`:`${i}h ago`;let a=Math.round(i/24);return t===`zh`?`${a} 天前`:`${a}d ago`}function q(e){let t=(0,z.c)(55),{item:n,targetAvailability:r}=e,i=u(pe),a;t[0]===i?a=t[1]:(a=l(i),t[0]=i,t[1]=a);let s=a.projectsPage.home,d=p(fe),{Icon:f,className:m}=G[n.tone],h;t[2]===m?h=t[3]:(h=c(`mt-0.5 flex size-7 shrink-0 items-center justify-center rounded-lg`,m),t[2]=m,t[3]=h);let g;t[4]!==f||t[5]!==n.status?(g=n.status===`running`?(0,U.jsx)(S,{className:`size-3.5 animate-spin motion-reduce:animate-none`,"aria-hidden":!0}):(0,U.jsx)(f,{className:`size-3.5`,"aria-hidden":!0}),t[4]=f,t[5]=n.status,t[6]=g):g=t[6];let _;t[7]!==h||t[8]!==g?(_=(0,U.jsx)(`div`,{className:h,children:g}),t[7]=h,t[8]=g,t[9]=_):_=t[9];let v;t[10]===n.title?v=t[11]:(v=(0,U.jsx)(`h3`,{className:`min-w-0 flex-1 text-sm font-medium leading-5 text-fg`,children:n.title}),t[10]=n.title,t[11]=v);let y;t[12]!==s.activityUnread||t[13]!==n.read?(y=n.read?null:(0,U.jsx)(`span`,{className:`mt-1.5 size-1.5 shrink-0 rounded-full bg-accent`,"aria-label":s.activityUnread}),t[12]=s.activityUnread,t[13]=n.read,t[14]=y):y=t[14];let b;t[15]!==v||t[16]!==y?(b=(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[v,y]}),t[15]=v,t[16]=y,t[17]=b):b=t[17];let x;t[18]===n.message?x=t[19]:(x=n.message?(0,U.jsx)(`p`,{className:`mt-0.5 line-clamp-2 text-xs leading-5 text-fg-muted`,children:n.message}):null,t[18]=n.message,t[19]=x);let C;t[20]===n.source?C=t[21]:(C=n.source?(0,U.jsx)(`span`,{className:`max-w-48 truncate`,children:n.source}):null,t[20]=n.source,t[21]=C);let w;t[22]!==n.updatedAt||t[23]!==i?(w=K(n.updatedAt,i),t[22]=n.updatedAt,t[23]=i,t[24]=w):w=t[24];let T;t[25]===w?T=t[26]:(T=(0,U.jsx)(`span`,{children:w}),t[25]=w,t[26]=T);let E;t[27]===n.occurrences?E=t[28]:(E=n.occurrences>1?(0,U.jsxs)(`span`,{children:[`×`,n.occurrences]}):null,t[27]=n.occurrences,t[28]=E);let D;t[29]!==s.activityCheckingRelated||t[30]!==s.activityRelatedMissing||t[31]!==s.activityViewRelated||t[32]!==n.href||t[33]!==r?(D=n.href&&r===`available`?(0,U.jsxs)(o,{to:n.href,className:`inline-flex items-center gap-0.5 font-medium text-accent-fg hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[s.activityViewRelated,(0,U.jsx)(F,{className:`size-3`,"aria-hidden":!0})]}):n.href&&r===`checking`?(0,U.jsx)(O,{className:`h-3 w-20 rounded`,"aria-label":s.activityCheckingRelated}):n.href&&r===`missing`?(0,U.jsx)(`span`,{className:`font-medium text-fg-subtle`,role:`status`,children:s.activityRelatedMissing}):null,t[29]=s.activityCheckingRelated,t[30]=s.activityRelatedMissing,t[31]=s.activityViewRelated,t[32]=n.href,t[33]=r,t[34]=D):D=t[34];let k;t[35]!==T||t[36]!==E||t[37]!==D||t[38]!==C?(k=(0,U.jsxs)(`div`,{className:`mt-1.5 flex min-w-0 flex-wrap items-center gap-x-2 text-[11px] text-fg-subtle`,children:[C,T,E,D]}),t[35]=T,t[36]=E,t[37]=D,t[38]=C,t[39]=k):k=t[39];let A;t[40]!==k||t[41]!==b||t[42]!==x?(A=(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[b,x,k]}),t[40]=k,t[41]=b,t[42]=x,t[43]=A):A=t[43];let j;t[44]!==n.id||t[45]!==d?(j=()=>d(n.id),t[44]=n.id,t[45]=d,t[46]=j):j=t[46];let M;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,U.jsx)(oe,{className:`size-3.5`,"aria-hidden":!0}),t[47]=M):M=t[47];let N;t[48]!==s.activityRemove||t[49]!==j?(N=(0,U.jsx)(`button`,{type:`button`,className:`rounded-md p-1 text-fg-subtle opacity-0 transition-opacity hover:bg-surface-hover hover:text-fg group-hover:opacity-100 focus:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":s.activityRemove,onClick:j,children:M}),t[48]=s.activityRemove,t[49]=j,t[50]=N):N=t[50];let P;return t[51]!==A||t[52]!==N||t[53]!==_?(P=(0,U.jsxs)(`article`,{className:`group flex items-start gap-3 border-t border-edge-subtle px-1 py-3 first:border-t-0`,children:[_,A,N]}),t[51]=A,t[52]=N,t[53]=_,t[54]=P):P=t[54],P}function fe(e){return e.remove}function pe(e){return e.language}function me(){let e=(0,z.c)(14),t=l(u(xe)).projectsPage.home,n=p(be),r=p(ye),i=p(ve),[a,o]=(0,R.useState)(!1),c;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(c={},e[0]=c):c=e[0];let[d,f]=(0,R.useState)(c),m;e[1]===n?m=e[2]:(m=n.filter(Q),e[1]=n,e[2]=m);let h=m.length,g;e[3]===n?g=e[4]:(g=n.filter(Z),e[3]=n,e[4]=g);let _=g.length,v;e[5]!==a||e[6]!==n?(v=a?n:n.slice(0,W),e[5]=a,e[6]=n,e[7]=v):v=e[7];let y=v,b;e[8]===n?b=e[9]:(b=[...new Set(n.flatMap(_e))].sort().join(`
|
|
2
|
-
`),e[8]=n,e[9]=b);let C=b,T,E;e[10]===C?(T=e[11],E=e[12]):(T=()=>{let e=new AbortController,t=new Map((C?C.split(`
|
|
3
|
-
`):[]).flatMap(ge));return f(Object.fromEntries([...t.keys()].map(he))),Promise.all([...t].map(async t=>{let[n,r]=t,i=await H(r,e.signal);e.signal.aborted||f(e=>({...e,[n]:i}))})).catch(X),()=>e.abort()},E=[C],e[10]=C,e[11]=T,e[12]=E),(0,R.useEffect)(T,E);let D;return e[13]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,U.jsx)(le,{className:`size-4 text-fg-subtle`,"aria-hidden":!0}),e[13]=D):D=e[13],(0,U.jsxs)(`section`,{className:`rounded-2xl bg-surface-base p-4 shadow-surface`,"aria-labelledby":`workbench-activity-title`,children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,U.jsx)(`div`,{children:(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[D,(0,U.jsx)(`h2`,{id:`workbench-activity-title`,className:`text-sm font-semibold text-fg`,children:t.activityTitle}),h>0?(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,children:[(0,U.jsx)(S,{className:`size-3 animate-spin motion-reduce:animate-none`,"aria-hidden":!0}),h,` `,t.running]}):_>0?(0,U.jsxs)(`span`,{className:`rounded-full bg-surface-panel px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:[_,` `,t.activityNew]}):null]})}),a&&n.length>0?(0,U.jsxs)(`div`,{className:`flex items-center gap-1`,children:[_>0?(0,U.jsxs)(P,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs`,onClick:r,children:[(0,U.jsx)(s,{className:`size-3.5`,"aria-hidden":!0}),t.activityMarkRead]}):null,n.some(Y)?(0,U.jsxs)(P,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs text-fg-muted`,onClick:i,children:[(0,U.jsx)(w,{className:`size-3.5`,"aria-hidden":!0}),t.activityClearFinished]}):null]}):null]}),n.length>0?(0,U.jsxs)(`div`,{className:`mt-3 px-1`,children:[y.map(e=>(0,U.jsx)(q,{item:e,targetAvailability:e.href&&V(e.href)?d[e.href]??`checking`:`available`},e.id)),n.length>W?(0,U.jsx)(`div`,{className:`border-t border-edge-subtle py-2 text-center`,children:(0,U.jsx)(P,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs`,onClick:()=>o(J),children:a?t.activityShowLess:t.activityShowAll.replace(`{{count}}`,String(n.length))})}):null]}):(0,U.jsxs)(`div`,{className:`mt-3 flex items-center gap-2 text-sm text-fg-muted`,children:[(0,U.jsx)(x,{className:`size-4 text-fg-subtle`,"aria-hidden":!0}),(0,U.jsx)(`p`,{children:t.activityEmpty})]})]})}function J(e){return!e}function Y(e){return e.status===`done`}function X(){}function he(e){return[e,`checking`]}function ge(e){let t=V(e);return t?[[e,t]]:[]}function _e(e){return e.href&&V(e.href)?[e.href]:[]}function Z(e){return!e.read}function Q(e){return e.status===`running`}function ve(e){return e.clearFinished}function ye(e){return e.markAllRead}function be(e){return e.items}function xe(e){return e.language}function Se(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}function Ce(e,t){if(e==null)return t;let n=new Date(e);return Number.isNaN(n.getTime())?t:I(n)}function $(e){let t=(0,z.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,U.jsx)(`span`,{className:`rounded-full bg-surface-muted px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:n}),t[0]=n,t[1]=r),r}function we(e){let t=(0,z.c)(18),{task:n,statusLabel:r,backgroundPath:i}=e,a;t[0]!==i||t[1]!==n.id?(a=E(i,n.id),t[0]=i,t[1]=n.id,t[2]=a):a=t[2];let s;t[3]===n.title?s=t[4]:(s=(0,U.jsx)(`h3`,{className:`line-clamp-2 text-sm font-semibold text-fg`,children:n.title}),t[3]=n.title,t[4]=s);let c;t[5]===n.updatedAt?c=t[6]:(c=Ce(n.updatedAt,``),t[5]=n.updatedAt,t[6]=c);let l;t[7]===c?l=t[8]:(l=(0,U.jsx)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:c}),t[7]=c,t[8]=l);let u;t[9]!==s||t[10]!==l?(u=(0,U.jsxs)(`div`,{className:`min-w-0`,children:[s,l]}),t[9]=s,t[10]=l,t[11]=u):u=t[11];let d;t[12]===r?d=t[13]:(d=(0,U.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-muted px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:r}),t[12]=r,t[13]=d);let f;return t[14]!==a||t[15]!==u||t[16]!==d?(f=(0,U.jsxs)(o,{to:a,className:`group flex items-start justify-between gap-3 rounded-xl border border-edge-subtle bg-surface-panel p-4 transition-colors hover:bg-surface-hover/55 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[u,d]}),t[14]=a,t[15]=u,t[16]=d,t[17]=f):f=t[17],f}function Te(e){let t=(0,z.c)(12),{receipt:n,evidenceLabel:r,remainingLabel:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,U.jsx)(m,{className:`mt-0.5 size-4 shrink-0 text-success`,"aria-hidden":!0}),t[0]=a):a=t[0];let o,s;t[1]===n.summary?(o=t[2],s=t[3]):(o=(0,U.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:n.summary}),s=(0,U.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:n.summary}),t[1]=n.summary,t[2]=o,t[3]=s);let c=n.remainingWork.length>0?` · ${n.remainingWork.length} ${i}`:``,l;t[4]!==r||t[5]!==n.evidence.length||t[6]!==c?(l=(0,U.jsxs)(`p`,{className:`mt-2 text-[11px] text-fg-subtle`,children:[n.evidence.length,` `,r,c]}),t[4]=r,t[5]=n.evidence.length,t[6]=c,t[7]=l):l=t[7];let u;return t[8]!==o||t[9]!==s||t[10]!==l?(u=(0,U.jsx)(`div`,{className:`block rounded-xl border border-edge-subtle px-3 py-3`,children:(0,U.jsxs)(`div`,{className:`flex items-start gap-2`,children:[a,(0,U.jsxs)(`div`,{className:`min-w-0`,children:[o,s,l]})]})}),t[8]=o,t[9]=s,t[10]=l,t[11]=u):u=t[11],u}function Ee(){let e=(0,z.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,U.jsxs)(`div`,{className:`space-y-5`,"aria-busy":!0,children:[(0,U.jsx)(O,{className:`h-20 rounded-2xl`}),(0,U.jsx)(O,{className:`h-72 rounded-2xl`}),(0,U.jsx)(O,{className:`h-44 rounded-2xl`})]}),e[0]=t):t=e[0],t}function De(e){let t=(0,z.c)(15),{chat:n,statusLabel:r}=e,i=`/chat/${encodeURIComponent(n.key)}`,a;t[0]===n.name?a=t[1]:(a=(0,U.jsx)(`h3`,{className:`min-w-0 truncate text-sm font-semibold text-fg`,children:n.name}),t[0]=n.name,t[1]=a);let s;t[2]===r?s=t[3]:(s=(0,U.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-muted px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:r}),t[2]=r,t[3]=s);let c;t[4]!==a||t[5]!==s?(c=(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[a,s]}),t[4]=a,t[5]=s,t[6]=c):c=t[6];let l;t[7]===n.updatedAt?l=t[8]:(l=Ce(n.updatedAt,``),t[7]=n.updatedAt,t[8]=l);let u;t[9]===l?u=t[10]:(u=(0,U.jsx)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:l}),t[9]=l,t[10]=u);let d;return t[11]!==i||t[12]!==c||t[13]!==u?(d=(0,U.jsxs)(o,{to:i,className:`group block rounded-xl border border-edge-subtle bg-surface-panel p-4 transition-colors hover:bg-surface-hover/55 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[c,u]}),t[11]=i,t[12]=c,t[13]=u,t[14]=d):d=t[14],d}function Oe(e){let t=(0,z.c)(27),{item:n,href:r,kindLabel:i,reasonLabel:a,approveLabel:s,denyLabel:c,busy:l,onRespond:u}=e,d;t[0]===n.title?d=t[1]:(d=(0,U.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:n.title}),t[0]=n.title,t[1]=d);let f=n.projectName||i,p;t[2]===f?p=t[3]:(p=(0,U.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-subtle`,children:f}),t[2]=f,t[3]=p);let m;t[4]!==d||t[5]!==p?(m=(0,U.jsxs)(`div`,{className:`min-w-0`,children:[d,p]}),t[4]=d,t[5]=p,t[6]=m):m=t[6];let h;t[7]===a?h=t[8]:(h=(0,U.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-panel/80 px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:a}),t[7]=a,t[8]=h);let g;t[9]!==m||t[10]!==h?(g=(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[m,h]}),t[9]=m,t[10]=h,t[11]=g):g=t[11];let _;t[12]===n.detail?_=t[13]:(_=n.detail?(0,U.jsx)(`p`,{className:`mt-2 line-clamp-2 text-xs leading-5 text-fg-muted`,children:n.detail}):null,t[12]=n.detail,t[13]=_);let v;t[14]!==r||t[15]!==g||t[16]!==_?(v=(0,U.jsxs)(o,{to:r,className:`group block focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[g,_]}),t[14]=r,t[15]=g,t[16]=_,t[17]=v):v=t[17];let y;t[18]!==s||t[19]!==l||t[20]!==c||t[21]!==n.response||t[22]!==u?(y=n.response?(0,U.jsxs)(`div`,{className:`mt-3 flex justify-end gap-2 border-t border-warning/20 pt-3`,children:[(0,U.jsx)(P,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:l,onClick:()=>u(`deny`),children:c}),(0,U.jsx)(P,{type:`button`,variant:`primary`,className:`h-8 px-2`,disabled:l,onClick:()=>u(`approve`),children:s})]}):null,t[18]=s,t[19]=l,t[20]=c,t[21]=n.response,t[22]=u,t[23]=y):y=t[23];let b;return t[24]!==v||t[25]!==y?(b=(0,U.jsxs)(`article`,{className:`rounded-xl border border-warning/35 bg-warning-soft/25 p-3.5 transition-colors hover:bg-warning-soft/40`,children:[v,y]}),t[24]=v,t[25]=y,t[26]=b):b=t[26],b}function ke(e){let t=(0,z.c)(65),{item:n,labels:r,busy:i,onDecide:a,onSnooze:o,onDismiss:s,onInstruct:c}=e,[l,u]=(0,R.useState)(``),d=n.judgment,f;t[0]===n.title?f=t[1]:(f=(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.title}),t[0]=n.title,t[1]=f);let p;t[2]===n.detail?p=t[3]:(p=(0,U.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-muted`,children:n.detail}),t[2]=n.detail,t[3]=p);let m;t[4]!==f||t[5]!==p?(m=(0,U.jsxs)(`div`,{className:`min-w-0`,children:[f,p]}),t[4]=f,t[5]=p,t[6]=m):m=t[6];let h;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,U.jsx)(b,{className:`size-4 shrink-0 text-accent`,"aria-hidden":!0}),t[7]=h):h=t[7];let g;t[8]===m?g=t[9]:(g=(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[m,h]}),t[8]=m,t[9]=g);let _;t[10]!==d.whyNow||t[11]!==r.whyNow?(_=[r.whyNow,d.whyNow],t[10]=d.whyNow,t[11]=r.whyNow,t[12]=_):_=t[12];let v;t[13]!==d.impact||t[14]!==r.impact?(v=[r.impact,d.impact],t[13]=d.impact,t[14]=r.impact,t[15]=v):v=t[15];let y;t[16]!==d.workDone||t[17]!==r.workDone?(y=[r.workDone,d.workDone],t[16]=d.workDone,t[17]=r.workDone,t[18]=y):y=t[18];let x;t[19]!==d.recommendation||t[20]!==r.recommendation?(x=[r.recommendation,d.recommendation],t[19]=d.recommendation,t[20]=r.recommendation,t[21]=x):x=t[21];let S;t[22]!==_||t[23]!==v||t[24]!==y||t[25]!==x?(S=(0,U.jsx)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-2`,children:[_,v,y,x].map(Ae)}),t[22]=_,t[23]=v,t[24]=y,t[25]=x,t[26]=S):S=t[26];let C;t[27]!==i||t[28]!==d.decision||t[29]!==a?(C=d.decision?(0,U.jsxs)(`div`,{className:`mt-4`,children:[(0,U.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:d.decision.question}),(0,U.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:d.decision.options.map(e=>(0,U.jsxs)(P,{type:`button`,variant:`secondary`,className:`h-auto min-h-9 flex-col items-start px-3 py-2 text-left`,disabled:i,title:e.consequence,onClick:()=>a(e.id),children:[(0,U.jsx)(`span`,{children:e.label}),(0,U.jsx)(`span`,{className:`text-[10px] font-normal text-fg-muted`,children:e.consequence})]},e.id))})]}):null,t[27]=i,t[28]=d.decision,t[29]=a,t[30]=C):C=t[30];let w;t[31]!==i||t[32]!==r.snooze||t[33]!==o?(w=(0,U.jsx)(P,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:i,onClick:o,children:r.snooze}),t[31]=i,t[32]=r.snooze,t[33]=o,t[34]=w):w=t[34];let T;t[35]!==i||t[36]!==r.dismiss||t[37]!==s?(T=(0,U.jsx)(P,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:i,onClick:s,children:r.dismiss}),t[35]=i,t[36]=r.dismiss,t[37]=s,t[38]=T):T=t[38];let E;t[39]!==w||t[40]!==T?(E=(0,U.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2 border-t border-edge-subtle pt-3`,children:[w,T]}),t[39]=w,t[40]=T,t[41]=E):E=t[41];let D;t[42]!==l||t[43]!==c?(D=e=>{e.preventDefault();let t=l.trim();t&&(c(t),u(``))},t[42]=l,t[43]=c,t[44]=D):D=t[44];let O;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(O=e=>u(e.target.value),t[45]=O):O=t[45];let k;t[46]!==l||t[47]!==r.feedbackPlaceholder?(k=(0,U.jsx)(`input`,{className:`min-w-0 flex-1 rounded-lg border border-edge bg-surface-base px-3 py-2 text-xs text-fg outline-none focus:border-accent`,value:l,onChange:O,placeholder:r.feedbackPlaceholder}),t[46]=l,t[47]=r.feedbackPlaceholder,t[48]=k):k=t[48];let A;t[49]!==i||t[50]!==l?(A=i||!l.trim(),t[49]=i,t[50]=l,t[51]=A):A=t[51];let j;t[52]!==r.applyFeedback||t[53]!==A?(j=(0,U.jsx)(P,{type:`submit`,variant:`secondary`,className:`h-9 px-3`,disabled:A,children:r.applyFeedback}),t[52]=r.applyFeedback,t[53]=A,t[54]=j):j=t[54];let M;t[55]!==D||t[56]!==k||t[57]!==j?(M=(0,U.jsxs)(`form`,{className:`mt-3 flex gap-2`,onSubmit:D,children:[k,j]}),t[55]=D,t[56]=k,t[57]=j,t[58]=M):M=t[58];let N;return t[59]!==S||t[60]!==C||t[61]!==E||t[62]!==M||t[63]!==g?(N=(0,U.jsxs)(`article`,{className:`rounded-xl border border-accent/25 bg-accent-soft/15 p-4`,children:[g,S,C,E,M]}),t[59]=S,t[60]=C,t[61]=E,t[62]=M,t[63]=g,t[64]=N):N=t[64],N}function Ae(e){let[t,n]=e;return(0,U.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/80 p-3`,children:[(0,U.jsx)(`p`,{className:`text-[11px] font-medium text-fg-subtle`,children:t}),(0,U.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg`,children:n})]},t)}function je(e){let t=(0,z.c)(32),{item:n,href:r,statusLabel:i,retryLabel:a,viewLabel:s,acknowledgeLabel:c,busy:l,onView:u,onRetry:d,onAcknowledge:f}=e,p;t[0]===n.title?p=t[1]:(p=(0,U.jsx)(`h3`,{className:`min-w-0 truncate text-sm font-semibold text-fg`,children:n.title}),t[0]=n.title,t[1]=p);let m;t[2]===i?m=t[3]:(m=(0,U.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-panel/80 px-2 py-0.5 text-[11px] font-medium text-danger`,children:i}),t[2]=i,t[3]=m);let h;t[4]!==p||t[5]!==m?(h=(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[p,m]}),t[4]=p,t[5]=m,t[6]=h):h=t[6];let g;t[7]===n.detail?g=t[8]:(g=(0,U.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-muted`,children:n.detail}),t[7]=n.detail,t[8]=g);let _;t[9]!==r||t[10]!==h||t[11]!==g?(_=(0,U.jsxs)(o,{to:r,className:`block focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[h,g]}),t[9]=r,t[10]=h,t[11]=g,t[12]=_):_=t[12];let v;t[13]!==c||t[14]!==l||t[15]!==f?(v=(0,U.jsx)(P,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:l,onClick:f,children:c}),t[13]=c,t[14]=l,t[15]=f,t[16]=v):v=t[16];let y;t[17]!==l||t[18]!==u||t[19]!==s?(y=(0,U.jsx)(P,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:l,onClick:u,children:s}),t[17]=l,t[18]=u,t[19]=s,t[20]=y):y=t[20];let b;t[21]!==l||t[22]!==d||t[23]!==a?(b=(0,U.jsx)(P,{type:`button`,variant:`primary`,className:`h-8 px-2`,disabled:l,onClick:d,children:a}),t[21]=l,t[22]=d,t[23]=a,t[24]=b):b=t[24];let x;t[25]!==v||t[26]!==y||t[27]!==b?(x=(0,U.jsxs)(`div`,{className:`mt-3 flex flex-wrap justify-end gap-2 border-t border-danger/15 pt-3`,children:[v,y,b]}),t[25]=v,t[26]=y,t[27]=b,t[28]=x):x=t[28];let S;return t[29]!==_||t[30]!==x?(S=(0,U.jsxs)(`article`,{className:`rounded-xl border border-danger/25 bg-danger-soft/35 p-3.5`,children:[_,x]}),t[29]=_,t[30]=x,t[31]=S):S=t[31],S}function Me(){let e=u(e=>e.language),t=l(e).projectsPage,n=ae(e),r=a(),s=i(),c=`${s.pathname}${s.search}`,d=v(e=>e.setPageHeader),f=v(e=>e.clearPageHeader),[p,x]=(0,R.useState)(null),[S,w]=(0,R.useState)(!0),[O,M]=(0,R.useState)(null),[te,F]=(0,R.useState)(!1),[I,le]=(0,R.useState)(``),[z,B]=(0,R.useState)(()=>crypto.randomUUID()),[V,H]=(0,R.useState)(!1),[W,G]=(0,R.useState)(null),[K,q]=(0,R.useState)(null),[fe,pe]=(0,R.useState)(null),J=(0,R.useCallback)(async(t=!1)=>{t&&w(!0),M(null);try{x(await se(e))}catch(e){M(e instanceof Error?e.message:String(e))}finally{w(!1)}},[e]);(0,R.useEffect)(()=>{J(!0)},[J]),(0,R.useEffect)(()=>{let e,t=t=>{e!==void 0&&window.clearTimeout(e),e=window.setTimeout(()=>{e=void 0,J()},t)},n=()=>t(100),r=()=>t(750),i=[`session-created`,`agent-run-started`,`agent-run-ended`,`automation-run-completed`,`workflow-run-updated`,`workflow-run-error`],a=[`session-updated`,`session-transcript-updated`];return i.forEach(e=>window.addEventListener(e,n)),a.forEach(e=>window.addEventListener(e,r)),()=>{i.forEach(e=>window.removeEventListener(e,n)),a.forEach(e=>window.removeEventListener(e,r)),e!==void 0&&window.clearTimeout(e)}},[J]);let Y=(0,R.useMemo)(()=>p?.decisions??[],[p]),X=(0,R.useMemo)(()=>p?.attention??[],[p]),he=(0,R.useCallback)(async t=>{t.preventDefault();let n=I.trim();if(!(!n||V)){H(!0),G(null);try{let t=await N({idempotencyKey:z,title:n,locale:e,priority:`normal`,contract:{objective:n,expectedOutputs:[],acceptanceCriteria:[],constraints:[],approvalRequired:[],assumptions:[],risks:[],acceptancePolicy:`manual`,outputDestinations:[]},dependencies:[],context:[],authorityGrants:[],activation:{mode:`start`,executor:{kind:`agent`,agentId:`main`}}});F(!1),le(``),B(crypto.randomUUID()),r(E(c,t.task.id))}catch(e){G(e instanceof Error?e.message:String(e))}finally{H(!1)}}},[c,z,V,e,r,I]),ge=(0,R.useMemo)(()=>(0,U.jsxs)(P,{type:`button`,variant:`primary`,className:`h-9 rounded-lg`,onClick:()=>F(!0),children:[(0,U.jsx)(ie,{className:`size-4`,"aria-hidden":!0}),n.newWork]}),[n.newWork]),_e=(0,R.useCallback)(async(e,t)=>{if(e.response){q(e.id),M(null);try{await de(e.response,t),await J()}catch(e){M(e instanceof Error?e.message:String(e))}finally{q(null)}}},[J]),Z=(0,R.useCallback)(async(e,t)=>{q(e.id),M(null);try{await t(),await J()}catch(e){M(e instanceof Error?e.message:String(e))}finally{q(null)}},[J]),Q=(0,R.useCallback)(async(e,t)=>{pe(e.id),M(null);try{await t({kind:e.kind,runId:e.runId}),await J()}catch(e){M(e instanceof Error?e.message:String(e))}finally{pe(null)}},[J]);return(0,R.useLayoutEffect)(()=>(d({startExtra:null,main:(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.title}),(0,U.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:t.home.subtitle})]}),end:ge}),()=>f()),[f,ge,d,t.title,t.home.subtitle]),(0,U.jsxs)(`main`,{className:`mx-auto flex w-full max-w-[1200px] flex-1 flex-col gap-7 px-4 py-7 sm:px-6 lg:px-8 lg:py-9`,children:[(0,U.jsx)(_,{open:te,onOpenChange:e=>{V||F(e),e&&(G(null),B(crypto.randomUUID()))},children:(0,U.jsxs)(ee,{children:[(0,U.jsx)(h,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,U.jsxs)(T,{className:`fixed left-1/2 top-1/2 z-[90] flex h-[min(31rem,calc(100dvh-1.5rem))] w-[min(36rem,calc(100vw-1.5rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-float focus:outline-none`,children:[(0,U.jsxs)(`div`,{className:`flex shrink-0 items-start gap-4 border-b border-edge px-5 py-4`,children:[(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(C,{className:`text-base font-semibold text-fg`,children:n.dialogTitle}),(0,U.jsx)(ne,{className:`mt-1 text-sm leading-5 text-fg-muted`,children:n.dialogDescription})]}),(0,U.jsx)(g,{asChild:!0,children:(0,U.jsx)(P,{type:`button`,variant:`ghost`,className:`-mr-2 -mt-1 size-8 shrink-0 rounded-lg p-0`,title:t.cancel,"aria-label":t.cancel,children:(0,U.jsx)(oe,{className:`size-4`,"aria-hidden":!0})})})]}),(0,U.jsxs)(`form`,{onSubmit:he,className:`flex min-h-0 flex-1 flex-col`,children:[(0,U.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto px-5 py-4`,children:[(0,U.jsx)(`label`,{htmlFor:`new-work-task`,className:`mb-2 shrink-0 text-sm font-medium text-fg`,children:n.intentLabel}),(0,U.jsx)(`textarea`,{id:`new-work-task`,className:`min-h-32 w-full flex-1 resize-none rounded-xl border border-edge bg-surface-base p-3 text-sm font-normal leading-6 text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`,value:I,onChange:e=>{le(e.target.value),B(crypto.randomUUID())},onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())},placeholder:n.intentPlaceholder,maxLength:12e3,autoFocus:!0}),(0,U.jsxs)(`div`,{className:`mt-2 flex shrink-0 items-center justify-between gap-3 text-[11px] text-fg-subtle`,children:[(0,U.jsx)(`span`,{children:t.home.submitShortcut}),(0,U.jsxs)(`span`,{className:`tabular-nums`,children:[I.length.toLocaleString(),` / `,12e3.toLocaleString()]})]}),W?(0,U.jsx)(`p`,{className:`mt-3 text-sm text-danger`,children:W}):null]}),(0,U.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,U.jsx)(g,{asChild:!0,children:(0,U.jsx)(P,{type:`button`,variant:`ghost`,disabled:V,children:t.cancel})}),(0,U.jsxs)(P,{type:`submit`,variant:`primary`,className:`min-w-32`,disabled:!I.trim()||V,children:[(0,U.jsx)(b,{className:`size-4`,"aria-hidden":!0}),V?n.starting:n.submit]})]})]})]})]})}),O?(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl border border-danger/25 bg-danger-soft px-4 py-3 text-sm text-danger`,children:[(0,U.jsx)(`span`,{children:O}),(0,U.jsx)(P,{type:`button`,variant:`ghost`,className:`h-8 px-2`,onClick:()=>void J(),children:t.home.retry})]}):null,S?(0,U.jsx)(Ee,{}):p?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`section`,{className:`border-b border-edge-subtle pb-5`,children:[(0,U.jsx)(`p`,{className:`text-xs font-medium text-fg-subtle`,children:t.home.briefingTitle}),(0,U.jsx)(`h2`,{className:`mt-1 text-xl font-semibold tracking-tight text-fg`,children:p.decisions.length+p.attention.length>0?Se(t.home.todaySummary,{attention:p.decisions.length+p.attention.length,moving:p.briefing.progress.movingCount+p.chats.running.length}):Se(t.home.todaySummaryClear,{moving:p.briefing.progress.movingCount+p.chats.running.length})}),p.briefing.summary?(0,U.jsx)(`p`,{className:`mt-2 max-w-3xl text-sm leading-6 text-fg-muted`,children:p.briefing.summary}):null]}),p.tasks.running.length===0&&p.workflowRuns.active.length===0&&p.decisions.length===0&&p.attention.length===0&&p.chats.running.length===0&&p.chats.recent.length===0&&p.upcomingAutomations.length===0?(0,U.jsxs)(`section`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center`,children:[(0,U.jsx)(y,{className:`mx-auto size-6 text-accent`,"aria-hidden":!0}),(0,U.jsx)(`h2`,{className:`mt-3 text-sm font-semibold text-fg`,children:t.home.emptyTitle}),(0,U.jsx)(`p`,{className:`mx-auto mt-1 max-w-lg text-sm leading-6 text-fg-muted`,children:t.home.emptyBody}),(0,U.jsxs)(`div`,{className:`mt-4 flex justify-center gap-2`,children:[(0,U.jsx)(P,{type:`button`,variant:`primary`,onClick:()=>r(`/chat/new`),children:t.home.startChat}),(0,U.jsx)(P,{type:`button`,variant:`secondary`,onClick:()=>F(!0),children:n.newWork})]})]}):null,(0,U.jsxs)(`div`,{className:`grid items-start gap-6 xl:grid-cols-[minmax(0,2fr)_minmax(18rem,1fr)]`,children:[(0,U.jsxs)(`div`,{className:`min-w-0 space-y-6`,children:[X.length>0?(0,U.jsxs)(`section`,{className:`rounded-2xl bg-surface-base p-5 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(L,{className:`size-4 text-danger`,"aria-hidden":!0}),(0,U.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:n.runAttention}),(0,U.jsx)($,{children:X.length.toLocaleString()})]}),(0,U.jsx)(`div`,{className:`mt-4 space-y-2`,children:X.map(e=>(0,U.jsx)(je,{item:e,href:ue(c,e.href),statusLabel:e.reason===`run_timeout`?t.home.attentionTimeout:t.home.attentionFailed,retryLabel:t.home.attentionRetry,viewLabel:t.home.attentionView,acknowledgeLabel:t.home.attentionAcknowledge,busy:fe===e.id,onView:()=>r(ue(c,e.href)),onRetry:()=>void Q(e,D),onAcknowledge:()=>void Q(e,re)},e.id))})]}):null,Y.length>0?(0,U.jsxs)(`section`,{className:`rounded-2xl bg-surface-base p-5 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(L,{className:`size-4 text-warning`,"aria-hidden":!0}),(0,U.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:n.needsAttention}),(0,U.jsx)($,{children:Y.length.toLocaleString()})]}),(0,U.jsx)(`div`,{className:`mt-4 space-y-2`,children:Y.map(e=>e.kind===`agent_judgment`&&e.judgment?(0,U.jsx)(ke,{item:e,labels:n,busy:K===e.id,onDecide:t=>void Z(e,()=>k(e.judgment.inboxItemId,t)),onSnooze:()=>void Z(e,()=>ce(e.judgment.inboxItemId,`snoozed`)),onDismiss:()=>void Z(e,()=>ce(e.judgment.inboxItemId,`resolved`)),onInstruct:t=>void Z(e,()=>j(e.judgment.inboxItemId,t))},e.id):(0,U.jsx)(Oe,{item:e,href:ue(c,e.href),kindLabel:t.home.decisionKinds[e.kind],reasonLabel:t.home.decisionReasons[e.reason],approveLabel:t.home.approve,denyLabel:t.home.deny,busy:K===e.id,onRespond:t=>void _e(e,t)},e.id))})]}):(0,U.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,U.jsx)(`span`,{className:`flex size-5 items-center justify-center rounded-full bg-success-soft text-xs text-success`,"aria-hidden":!0,children:`✓`}),t.home.nothingNeedsYou]}),(0,U.jsxs)(`section`,{className:`rounded-2xl bg-surface-base p-5 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(b,{className:`size-4 text-accent`,"aria-hidden":!0}),(0,U.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:n.running}),(0,U.jsx)($,{children:p.tasks.running.length.toLocaleString()})]}),(0,U.jsxs)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-2`,children:[p.tasks.running.map(e=>(0,U.jsx)(we,{task:e,statusLabel:n.taskStatuses.running,backgroundPath:c},e.id)),p.tasks.running.length===0?(0,U.jsx)(`p`,{className:`py-6 text-center text-sm text-fg-muted`,children:n.emptyRunning}):null]})]}),p.chats.recent.length>0?(0,U.jsxs)(`section`,{className:`rounded-2xl bg-surface-base p-5 shadow-surface`,children:[(0,U.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,U.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:n.recent})}),(0,U.jsx)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-2`,children:p.chats.recent.slice(0,6).map(e=>(0,U.jsx)(De,{chat:e,statusLabel:n.openChat},e.key))})]}):null]}),(0,U.jsxs)(`aside`,{className:`min-w-0 space-y-4`,"aria-label":t.home.nowTitle,children:[(0,U.jsx)(`div`,{className:`px-1`,children:(0,U.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.home.nowTitle})}),p.upcomingAutomations.length>0?(0,U.jsxs)(`section`,{className:`rounded-2xl bg-surface-base p-4 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(A,{className:`size-4 text-fg-subtle`,"aria-hidden":!0}),(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.home.scheduled})]}),(0,U.jsx)(`div`,{className:`mt-2 divide-y divide-edge-subtle`,children:p.upcomingAutomations.slice(0,3).map(e=>(0,U.jsxs)(o,{to:`/automations`,className:`flex items-center justify-between gap-3 rounded-lg px-1 py-3 text-sm hover:bg-surface-hover/55`,children:[(0,U.jsx)(`span`,{className:`min-w-0 truncate text-fg`,children:e.name||e.action}),(0,U.jsx)(`time`,{className:`shrink-0 text-xs text-fg-subtle`,children:Ce(e.nextRunAt,t.never)})]},e.id))})]}):null,p.recentTasks.length>0?(0,U.jsxs)(`section`,{className:`rounded-2xl bg-surface-base p-4 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(m,{className:`size-4 text-success`,"aria-hidden":!0}),(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.recentTasks})]}),(0,U.jsx)(`div`,{className:`mt-3 space-y-2`,children:p.recentTasks.slice(0,3).map(e=>(0,U.jsx)(Te,{receipt:e,evidenceLabel:n.evidenceCount,remainingLabel:n.remainingCount},e.runId))})]}):null,(0,U.jsx)(me,{}),p.briefing.wins.length>0?(0,U.jsxs)(o,{to:p.briefing.wins[0].href,className:`flex items-center justify-between gap-3 rounded-xl px-2 py-2 text-sm text-fg-muted hover:bg-surface-hover/55 hover:text-fg`,children:[(0,U.jsx)(`span`,{children:Se(t.home.completedSummary,{count:p.briefing.wins.length})}),(0,U.jsxs)(`span`,{className:`shrink-0 text-xs font-medium text-accent`,children:[t.home.viewLatestResult,` →`]})]}):null]})]})]}):null]})}export{Me as HomePage};
|