@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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i,l as a}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as o}from"./cn-JdwAhgNB.js";import{t as s}from"./messages-DQ5X6cXp.js";import{l as c,n as l,o as u,r as d,s as f}from"./locale-store-Bjvw7jtg.js";import{i as p}from"./vendor-swr-BIWyz7Rc.js";import{Al as m,Ao as h,Ar as g,Da as _,Ea as v,Hs as y,Ko as b,La as x,Mo as S,Mr as C,Ni as w,No as T,Ns as E,Oa as D,Oo as O,Po as k,Uo as A,Xo as j,Zo as M,_s as N,bs as ee,dc as P,dr as F,dt as I,jo as L,jr as te,ko as R,ru as z,sc as ne,tc as re,tu as ie,us as ae,zc as B}from"./index-BpkdvHH0.js";import{n as oe,r as se}from"./settings-page-layout-CLtUsWsu.js";import{n as ce}from"./settings-loading-skeleton-sn4k17x7.js";import{t as le}from"./schema-form-CWoSjz9s.js";import{t as ue}from"./browser-BLJWD7WI.js";import{n as de,t as fe}from"./channels-status-swr-DPaJSYX_.js";var V=e(t(),1),H=n();function pe(e){let t=e.actions??{};for(let e of[`login.start`,`setup.start`]){let n=t[e];if(n?.result===`qr`)return[e,n]}let n=Object.entries(t).find(([,e])=>e.result===`qr`);if(n)return n;let r=e.ui?.card?.primaryAction;if(r&&t[r])return[r,t[r]];for(let e of[`login.start`,`setup.start`]){let n=t[e];if(n)return[e,n]}return Object.entries(t).find(([,e])=>e.result===`form`)??null}var me=e(ue(),1),U=r();async function he(e){let t=await u(d(`/api/channels/${encodeURIComponent(e.channelId)}/actions/${encodeURIComponent(e.actionId)}?locale=${encodeURIComponent(e.locale)}`),{method:`POST`,body:JSON.stringify({...e.accountId?{accountId:e.accountId}:{},...e.input===void 0?{}:{input:e.input}})}),n=await t.json().catch(()=>({}));if(!t.ok||n.ok===!1)throw Error(n.error?.message??t.statusText);return n.payload??{type:`ok`}}function W(e){return e?.type===`poll`&&e.phase===`done`}function G(e){return e&&`message`in e&&typeof e.message==`string`?e.message:null}function K(e,t){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrPayload?e.qrPayload:t===`weixin`&&e.qrcodeUrl?e.qrcodeUrl:null}function q(e){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrcodeUrl??null}function ge({entry:e,locale:t,messages:n,onChanged:r,compact:i=!1}){let a=(0,V.useMemo)(()=>pe(e),[e]),s=(0,V.useMemo)(()=>({defaultBooleanLabel:n.schemaBooleanDefault,unsupportedArrayType:n.schemaUnsupportedArrayType,arrayAddPlaceholder:n.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>n.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[n]),[c,l]=(0,V.useState)({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null});(0,V.useEffect)(()=>{l({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null})},[e.id]);let u=(0,V.useCallback)(async(n,i)=>{l(e=>({...e,busy:!0,error:null}));try{let a=await he({channelId:e.id,actionId:n,locale:t,input:i});l(e=>({...e,payload:a,poll:a.type===`qr`&&a.statusAction&&a.sessionKey?{actionId:a.statusAction,sessionKey:a.sessionKey,intervalMs:Math.max(1e3,a.pollIntervalMs??2500)}:null,busy:!1,formDraft:a.type===`form`?a.values??{}:e.formDraft})),`configChanged`in a&&a.configChanged===!0&&await r()}catch(e){l(t=>({...t,busy:!1,error:e instanceof Error?e.message:String(e)}))}},[e.id,t,r]);(0,V.useEffect)(()=>{let t=K(c.payload,e.id);if(!t){l(e=>e.generatedQr?{...e,generatedQr:null}:e);return}let n=!1;return l(e=>e.generatedQr?{...e,generatedQr:null}:e),me.toDataURL(t,{width:220,margin:1}).then(e=>{n||l(t=>({...t,generatedQr:e}))}),()=>{n=!0}},[e.id,c.payload]),(0,V.useEffect)(()=>{let n=c.poll;if(!n)return;let i=!1,a=window.setInterval(()=>{i||he({channelId:e.id,actionId:n.actionId,locale:t,input:{sessionKey:n.sessionKey}}).then(async e=>{i||(l(t=>({...t,payload:e,poll:W(e)?null:t.poll,error:null})),`configChanged`in e&&e.configChanged===!0&&await r(),W(e)&&window.clearInterval(a))}).catch(e=>{i||l(t=>({...t,error:e instanceof Error?e.message:String(e)}))})},n.intervalMs);return()=>{i=!0,window.clearInterval(a)}},[e.id,t,r,c.poll]);let d=a?.[1].label??(e.configured?n.reconnect:n.connect),f=e.actions?.[`doctor.run`]?.label??n.diagnose,p=G(c.payload),h=K(c.payload,e.id),g=h?c.generatedQr:q(c.payload),v=a?.[1].result===`qr`&&(c.busy||c.payload?.type===`qr`||c.payload?.type===`poll`),b=c.payload?.type===`form`?c.payload:null,x=c.payload?.type===`diagnostics`?c.payload.checks:null;return(0,U.jsxs)(`div`,{className:i?`space-y-3`:`rounded-lg bg-surface-panel/80 p-4 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:o(`flex flex-wrap items-start gap-3`,i?`justify-end`:`justify-between`),children:[i?null:(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.setupTitle}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.configured?n.setupConfiguredHint:n.setupEmptyHint})]}),(0,U.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[a?(0,U.jsxs)(N,{type:`button`,variant:`primary`,disabled:c.busy,onClick:()=>void u(a[0]),children:[c.busy?(0,U.jsx)(B,{className:`size-4 animate-spin`}):(0,U.jsx)(P,{className:`size-4`}),d]}):null,e.actions?.[`doctor.run`]?(0,U.jsxs)(N,{type:`button`,variant:`secondary`,disabled:c.busy,onClick:()=>void u(`doctor.run`),children:[(0,U.jsx)(y,{className:`size-4`}),f]}):null]})]}),p?(0,U.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:p}):null,c.error?(0,U.jsx)(`p`,{className:`mt-3 text-sm text-red-600 dark:text-red-400`,children:c.error}):null,v?(0,U.jsxs)(`div`,{className:o(`flex h-80 items-center justify-center gap-4 overflow-hidden rounded-lg bg-surface-base p-3 shadow-surface`,i?`mt-1 flex-col text-center sm:h-64 sm:flex-row sm:text-left`:`mt-4 flex-col sm:h-64 sm:flex-row`),children:[(0,U.jsx)(`div`,{className:`flex size-56 shrink-0 items-center justify-center rounded-lg border border-edge bg-white p-3`,children:g?(0,U.jsx)(`img`,{src:g,alt:`${e.label} setup QR`,className:`size-52 object-contain`}):(0,U.jsx)(`div`,{className:`flex size-52 items-center justify-center rounded-md bg-surface-base`,children:(0,U.jsx)(_,{className:`size-48 rounded-md`})})}),(0,U.jsxs)(`div`,{className:o(`min-w-0 max-w-sm text-sm text-fg-muted`,i&&`w-full sm:w-auto`),children:[g?(0,U.jsx)(`p`,{className:`line-clamp-3`,children:n.waitingConfirmation}):(0,U.jsxs)(`div`,{className:`space-y-2`,"aria-busy":`true`,children:[(0,U.jsx)(_,{className:`h-4 w-48 max-w-full`}),(0,U.jsx)(_,{className:`h-4 w-36 max-w-full`})]}),h?(0,U.jsxs)(`a`,{className:`mt-2 inline-flex items-center gap-1 text-accent hover:underline`,href:h,target:`_blank`,rel:`noreferrer`,children:[n.openSetupLink,(0,U.jsx)(m,{className:`size-3.5`})]}):null]})]}):null,c.payload?.type===`poll`&&c.payload.phase===`done`?(0,U.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 rounded-lg bg-surface-base px-3 py-2 text-sm shadow-surface`,children:[(0,U.jsx)(ie,{className:c.payload.ok?`size-4 text-green-600`:`size-4 text-red-600`}),(0,U.jsx)(`span`,{className:c.payload.ok?`text-fg`:`text-red-600 dark:text-red-400`,children:c.payload.message??(c.payload.ok?n.complete:n.failed)})]}):null,b?(0,U.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,U.jsx)(le,{schema:b.schema,values:c.formDraft,onChange:e=>l(t=>({...t,formDraft:e})),disabled:c.busy,labels:s}),(0,U.jsx)(N,{type:`button`,variant:`primary`,disabled:c.busy,onClick:()=>void u(b.submitAction,c.formDraft),children:n.saveSetup})]}):null,x?(0,U.jsx)(`div`,{className:`mt-4 space-y-2`,children:x.map((e,t)=>(0,U.jsxs)(`div`,{className:`rounded-lg bg-surface-base px-3 py-2 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,U.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.label??e.id??n.diagnosticCheckFallback.replace(`{{index}}`,String(t+1))}),(0,U.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e.status??`unknown`})]}),e.message?(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.message}):null]},e.id??t))}):null]})}var _e=40;function J(e){return`ui:route:channel:${e.trim().toLowerCase()}`}function ve(e,t){return e.find(e=>e.id===J(t))?.agentId?.trim().toLowerCase()??``}function ye(e,t,n){let r=J(t),i=e.filter(e=>e.id!==r),a=n.trim().toLowerCase();return a?[...i,{id:r,agentId:a,priority:_e,enabled:!0,match:{channel:t.trim().toLowerCase(),accountId:`*`}}]:i}function be(e){let t=e.configured===!0,n=e.enabled===!0;return e.setupStatus??{enabled:n,ready:t,state:n&&!t?`needs_setup`:n?`ready`:`disabled`,issues:[]}}function xe(e,t,n){let r=be(e);return r.ready?r.enabled?n?t?.connected===!0?`running`:`stopped`:`checking`:`disabled`:`needs_setup`}function Se(e,t=!1){return e===`drawer`?o(`xopc-drawer-right fixed right-0 top-0 flex size-full flex-col overflow-hidden border-l border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`,t?`max-w-[36rem]`:`max-w-xl`,j):o(`fixed left-1/2 top-1/2 flex h-[min(calc(100dvh-2rem),52rem)] w-[min(calc(100%-2rem),32rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,t&&`h-[min(calc(100dvh-2rem),48rem)] w-[min(calc(100%-2rem),36rem)]`,j,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`)}function Ce(e){let t=(0,H.c)(33),{presentation:n,open:r,onOpenChange:i,title:a,description:s,srTitle:c,srDescription:l,closeAriaLabel:u,children:d,footer:f,wide:p,headerExtra:m}=e,g=p===void 0?!1:p,_=n===`drawer`,[v,y]=(0,V.useState)(null),x;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,U.jsx)(S,{className:o(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,M)}),t[0]=x):x=t[0];let C;t[1]!==n||t[2]!==g?(C=Se(n,g),t[1]=n,t[2]=g,t[3]=C):C=t[3];let w;t[4]===c?w=t[5]:(w=c?(0,U.jsx)(k,{className:`sr-only`,children:c}):null,t[4]=c,t[5]=w);let E;t[6]===l?E=t[7]:(E=l?(0,U.jsx)(L,{className:`sr-only`,children:l}):null,t[6]=l,t[7]=E);let D;t[8]!==u||t[9]!==s||t[10]!==m||t[11]!==_||t[12]!==a?(D=_?(0,U.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[a?(0,U.jsx)(`div`,{className:`text-base font-semibold text-fg`,children:a}):null,s?(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:s}):null]}),(0,U.jsx)(R,{asChild:!0,children:(0,U.jsx)(N,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":u,children:(0,U.jsx)(ee,{className:`size-5`,strokeWidth:1.75})})})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(R,{asChild:!0,children:(0,U.jsx)(`button`,{type:`button`,className:o(ae,`absolute right-3 top-3 z-20 p-1.5 hover:bg-surface-hover`),"aria-label":u,children:(0,U.jsx)(ee,{className:`size-4`})})}),m]}),t[8]=u,t[9]=s,t[10]=m,t[11]=_,t[12]=a,t[13]=D):D=t[13];let A=_?`p-4`:`p-6`,j;t[14]===A?j=t[15]:(j=o(`min-h-0 flex-1 overflow-y-auto`,A),t[14]=A,t[15]=j);let P;t[16]!==d||t[17]!==j?(P=(0,U.jsx)(`div`,{className:j,children:d}),t[16]=d,t[17]=j,t[18]=P):P=t[18];let F;t[19]!==f||t[20]!==v||t[21]!==w||t[22]!==E||t[23]!==D||t[24]!==P?(F=(0,U.jsxs)(b,{layer:`modal`,portalContainer:v,children:[w,E,D,P,f]}),t[19]=f,t[20]=v,t[21]=w,t[22]=E,t[23]=D,t[24]=P,t[25]=F):F=t[25];let I;t[26]!==F||t[27]!==C?(I=(0,U.jsxs)(T,{children:[x,(0,U.jsx)(h,{ref:y,className:C,onOpenAutoFocus:we,children:F})]}),t[26]=F,t[27]=C,t[28]=I):I=t[28];let te;return t[29]!==i||t[30]!==r||t[31]!==I?(te=(0,U.jsx)(O,{open:r,onOpenChange:i,children:I}),t[29]=i,t[30]=r,t[31]=I,t[32]=te):te=t[32],te}function we(e){return e.preventDefault()}var Te=(0,V.memo)(function(e){let t=(0,H.c)(10),{ch:n,refreshing:r,saveOk:i,onRefresh:a}=e,o;t[0]!==n.saved||t[1]!==i?(o=i?(0,U.jsx)(`span`,{className:`text-sm text-fg-muted`,children:n.saved}):null,t[0]=n.saved,t[1]=i,t[2]=o):o=t[2];let s;t[3]!==n.refresh||t[4]!==a||t[5]!==r?(s=(0,U.jsx)(w,{className:`size-9 shrink-0 p-0`,loading:r,label:n.refresh,onClick:a}),t[3]=n.refresh,t[4]=a,t[5]=r,t[6]=s):s=t[6];let c;return t[7]!==o||t[8]!==s?(c=(0,U.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center justify-end gap-2`,children:[o,s]}),t[7]=o,t[8]=s,t[9]=c):c=t[9],c});function Ee(e){let t=(0,H.c)(24),{ch:n,dirty:r,saving:i,onCancel:a,onDiscard:o,onSave:s,showCancel:c}=e,l=c===void 0?!0:c,u;t[0]!==n.unsavedHint||t[1]!==r?(u=r?(0,U.jsx)(`p`,{className:`mb-3 text-xs text-amber-800 dark:text-amber-200`,children:n.unsavedHint}):null,t[0]=n.unsavedHint,t[1]=r,t[2]=u):u=t[2];let d;t[3]!==n.modalCancel||t[4]!==a||t[5]!==l?(d=l?(0,U.jsx)(N,{type:`button`,variant:`secondary`,onClick:a,children:n.modalCancel}):null,t[3]=n.modalCancel,t[4]=a,t[5]=l,t[6]=d):d=t[6];let f=!r||i,p;t[7]!==n.discard||t[8]!==o||t[9]!==f?(p=(0,U.jsx)(N,{type:`button`,variant:`secondary`,disabled:f,onClick:o,children:n.discard}),t[7]=n.discard,t[8]=o,t[9]=f,t[10]=p):p=t[10];let m=!r||i,h;t[11]===s?h=t[12]:(h=()=>void s(),t[11]=s,t[12]=h);let g=i?n.saving:n.save,_;t[13]!==m||t[14]!==h||t[15]!==g?(_=(0,U.jsx)(N,{type:`button`,variant:`primary`,disabled:m,onClick:h,children:g}),t[13]=m,t[14]=h,t[15]=g,t[16]=_):_=t[16];let v;t[17]!==d||t[18]!==p||t[19]!==_?(v=(0,U.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[d,p,_]}),t[17]=d,t[18]=p,t[19]=_,t[20]=v):v=t[20];let y;return t[21]!==v||t[22]!==u?(y=(0,U.jsxs)(`div`,{className:`sticky bottom-0 shrink-0 border-t border-edge-subtle bg-surface-panel px-6 py-4 dark:border-edge-subtle`,children:[u,v]}),t[21]=v,t[22]=u,t[23]=y):y=t[23],y}function De(e){return d(`/api/channels/catalog?locale=${encodeURIComponent(e)}`)}async function Oe(e){return(await f(De(e))).payload?.channels??[]}function ke(e,t){let n=(0,H.c)(14),r;n[0]!==e||n[1]!==t?(r=e?De(t):null,n[0]=e,n[1]=t,n[2]=r):r=n[2];let i;n[3]===t?i=n[4]:(i=()=>Oe(t),n[3]=t,n[4]=i);let a;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(a={revalidateOnFocus:!1},n[5]=a):a=n[5];let{data:o,error:s,isLoading:c,isValidating:l,mutate:u}=p(r,i,a),d;n[6]===o?d=n[7]:(d=o??[],n[6]=o,n[7]=d);let f;return n[8]!==s||n[9]!==c||n[10]!==l||n[11]!==u||n[12]!==d?(f={entries:d,isLoading:c,isValidating:l,error:s,mutate:u},n[8]=s,n[9]=c,n[10]=l,n[11]=u,n[12]=d,n[13]=f):f=n[13],f}var Ae=`channels-status`;function je(e){if(!e||typeof e!=`object`)return null;let t=e.channels;return Array.isArray(t)?t:null}function Me(e){let t=t=>e(t.detail);return window.addEventListener(Ae,t),()=>window.removeEventListener(Ae,t)}function Ne(e,t){let n=(0,H.c)(4),r=t===void 0?!0:t,i,a;n[0]!==r||n[1]!==e?(i=()=>{if(r)return Me(e)},a=[r,e],n[0]=r,n[1]=e,n[2]=i,n[3]=a):(i=n[2],a=n[3]),(0,V.useEffect)(i,a)}function Pe(e){return e?d(`/api/channels/${encodeURIComponent(e)}/config`):null}async function Fe(e){return(await f(d(`/api/channels/${encodeURIComponent(e)}/config`))).payload?.config??{}}var Ie=[`enabled`];async function Le(){let e=await f(d(`/api/config`));return{channels:e.payload?.config?.channels??{},bindings:e.payload?.config?.bindings??[]}}function Re(e){return e.split(`/`).filter(Boolean).map(e=>encodeURIComponent(e)).join(`/`)}function ze(e){return e.configPath.startsWith(`channels.`)&&e.configPath.slice(9).split(`.`)[0]||e.id}function Y(e){let t=e.configured===!0,n=e.enabled===!0;return e.setupStatus??{enabled:n,ready:t,state:n&&!t?`needs_setup`:n?`ready`:`disabled`,issues:[]}}function Be(e,t){return e===`running`?t.connectionRunning:e===`stopped`?t.connectionStopped:e===`checking`?t.connectionChecking:e===`disabled`?t.connectionDisabled:t.connectionNeedsSetup}function Ve(e,t){return e===`running`?t.connectionRunningHint:e===`stopped`?t.connectionStoppedHint:e===`disabled`?t.connectionDisabledHint:e===`needs_setup`?t.connectionNeedsSetupHint:t.connectionChecking}function He(e){return e===`running`?`bg-emerald-500/12 text-emerald-700 dark:text-emerald-300`:e===`stopped`?`bg-red-500/10 text-red-700 dark:text-red-300`:e===`checking`?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:e===`disabled`?`bg-surface-hover text-fg-muted`:`bg-amber-500/10 text-amber-700 dark:text-amber-300`}function Ue(e){if(!e)return[];let t=e.uiHints??{},n=X(e.configSchema)&&Array.isArray(e.configSchema.required)?e.configSchema.required.map(String):[],r=Y(e).issues.map(e=>e.fieldPath).filter(e=>!!e),i=Object.entries(t).filter(([,e])=>!X(e)||e.advanced===!0?!1:(Array.isArray(e.tags)?e.tags.map(String):[]).includes(`basic`)||e.advanced===!1).map(([e])=>e).filter(e=>!Ie.includes(e));return Array.from(new Set([...i,...n,...r])).filter(e=>!Ie.includes(e))}function X(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Z(e){return JSON.parse(JSON.stringify(e??{type:`object`,properties:{}}))}function We(e,t){let n={...Z(e),properties:{}};for(let r of t){let t=r.split(`.`),i=e,a=n;for(let[e,n]of t.entries()){let r=i.properties;if(!X(r)||!X(r[n]))break;let o=X(a.properties)?a.properties:{};if(a.properties=o,o[n]||(o[n]={...Z(r[n]),properties:{}}),e===t.length-1){o[n]=Z(r[n]);break}i=r[n],a=o[n]}}return n}function Ge(e){let t=e.properties;if(!X(t))return!1;for(let[e,n]of Object.entries(t))X(n)&&n.type===`object`&&Ge(n)&&delete t[e];return Object.keys(t).length===0}function Ke(e,t){let n=Z(e);for(let e of t){let t=e.split(`.`),r=n;for(let[e,n]of t.entries()){let i=r.properties;if(!X(i))break;if(e===t.length-1){delete i[n];break}if(!X(i[n]))break;r=i[n]}}return Ge(n),n}function qe(e){return e.type===`object`&&X(e.properties)&&Object.keys(e.properties).length>0}function Je(e,t){let n=e;for(let e of t.split(`.`)){if(!X(n))return;n=n[e]}return n}function Ye(e){let t=e.accounts;return X(t)?Object.values(t).filter(e=>X(e)&&e.enabled!==!1).length:+(e.configured===!0)}function Q(e,t,n){return t==null||t===``?null:e.toLowerCase().includes(`dmpolicy`)&&typeof t==`string`?`${n.dmPolicy}: ${n.policy.dm[t]??t}`:(e.toLowerCase().includes(`stream`)||e.toLowerCase().includes(`streaming`))&&typeof t==`string`?`${n.cardStream}: ${n.policy.stream[t]??t}`:typeof t==`boolean`?t?n.enabledLabel:n.disabledLabel:String(t)}function Xe(e,t,n){let r=[],i=Y(e);if(i.issues.length>0&&r.push(et(i.issues[0],n)),t){let i=e.ui?.card?.summaryFields??[`dmPolicy`,`streamMode`,`streaming.mode`];for(let e of i){let i=Q(e,Je(t,e),n);i&&r.push(i)}let a=Ye(t);a>0&&r.push(n.cardAccounts.replace(`{{count}}`,String(a)))}return r.length>0?r.slice(0,2):i.ready?[n.hubStatusConfigured]:[]}function Ze(e,t){let n=Y(e),r=pe(e);return n.state===`needs_setup`?r?.[1].label??t.completeSetup:!n.enabled&&n.ready?t.enableChannel:n.state===`error`?t.diagnose:n.ready?t.manageChannel:r?.[1].label??t.startConfiguration}function Qe(e,t){let n=pe(e);return n?.[1].result===`qr`?t.cardSetupQrHint:n?.[1].result===`form`?t.cardSetupConfigHint:t.cardSetupGenericHint}function $e(e,t){let n=e.capabilities??{},r=[];return n.login===!0&&r.push(t.cardCapabilityLogin),n.pairing===!0&&r.push(t.cardCapabilityPairing),n.multiAccount===!0&&r.push(t.cardCapabilityMultiAccount),n.streaming===!0&&r.push(t.cardCapabilityStreaming),n.media===!0&&r.push(t.cardCapabilityMedia),n.doctor===!0&&r.push(t.cardCapabilityDoctor),r.slice(0,3)}function et(e,t){return e.code===`telegram.missing_credential`?t.setupIssueTelegramMissingCredential:e.code===`weixin.missing_account`?t.setupIssueWeixinMissingAccount:e.code===`feishu.missing_credentials`?t.setupIssueFeishuMissingCredentials:e.code===`config.missing_required`&&e.fieldPath?t.setupIssueMissingRequired.replace(`{{field}}`,e.fieldPath):e.message}function tt({entry:e}){let t=c(e=>e.token),[n,r]=(0,V.useState)(!1),i=(0,V.useMemo)(()=>{if(!e.ui?.icon||n)return null;let r=new URL(d(`/api/extensions/${encodeURIComponent(e.extensionId)}/assets/${Re(e.ui.icon)}`));return t?.trim()&&r.searchParams.set(`token`,t.trim()),r.toString()},[n,e.extensionId,e.ui?.icon,t]);return(0,U.jsx)(`span`,{className:`flex size-12 shrink-0 items-center justify-center rounded-2xl bg-surface-base text-fg`,children:i?(0,U.jsx)(`img`,{src:i,alt:``,draggable:!1,className:`size-7`,"aria-hidden":!0,onError:()=>r(!0)}):(0,U.jsx)(D,{sourceChannel:e.id,className:`size-7`})})}function nt(e){let t=(0,H.c)(16),{checked:n,disabled:r,onToggle:i,label:a}=e,s;t[0]===i?s=t[1]:(s=e=>{e.stopPropagation(),i()},t[0]=i,t[1]=s);let c=n?`border-accent bg-accent`:`border-edge bg-surface-hover`,l=r&&`cursor-not-allowed opacity-60`,u;t[2]!==c||t[3]!==l?(u=o(`relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border transition-colors`,c,l),t[2]=c,t[3]=l,t[4]=u):u=t[4];let d=n?`translate-x-5`:`translate-x-0.5`,f;t[5]===d?f=t[6]:(f=o(`size-5 rounded-full bg-white shadow-surface transition-transform`,d),t[5]=d,t[6]=f);let p;t[7]===f?p=t[8]:(p=(0,U.jsx)(`span`,{className:f}),t[7]=f,t[8]=p);let m;return t[9]!==n||t[10]!==r||t[11]!==a||t[12]!==s||t[13]!==u||t[14]!==p?(m=(0,U.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":n,"aria-label":a,disabled:r,onClick:s,className:u,children:p}),t[9]=n,t[10]=r,t[11]=a,t[12]=s,t[13]=u,t[14]=p,t[15]=m):m=t[15],m}function rt(e){let t=(0,H.c)(71),{entry:n,config:r,runtime:i,busy:a,restarting:s,ch:c,onOpen:l,onToggle:u,onRestart:d}=e,f;t[0]===n?f=t[1]:(f=Y(n),t[0]=n,t[1]=f);let p=f,m,h,g,_,v,y,b;if(t[2]!==a||t[3]!==c||t[4]!==r||t[5]!==n||t[6]!==l||t[7]!==d||t[8]!==u||t[9]!==i||t[10]!==p.enabled||t[11]!==p.ready){let e=Xe(n,r,c),s=$e(n,c);m=!p.enabled&&p.ready?u:i===`stopped`?d:l,y=`flex min-h-[15.5rem] flex-col rounded-xl bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45`;let f;t[19]===n?f=t[20]:(f=(0,U.jsx)(tt,{entry:n}),t[19]=n,t[20]=f);let x;t[21]===n.label?x=t[22]:(x=(0,U.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:n.label}),t[21]=n.label,t[22]=x);let S;t[23]===i?S=t[24]:(S=o(`mt-1 inline-flex rounded-full px-2 py-0.5 text-xs font-medium`,He(i)),t[23]=i,t[24]=S);let C;t[25]!==c||t[26]!==i?(C=Be(i,c),t[25]=c,t[26]=i,t[27]=C):C=t[27];let w;t[28]!==S||t[29]!==C?(w=(0,U.jsx)(`span`,{className:S,children:C}),t[28]=S,t[29]=C,t[30]=w):w=t[30];let T;t[31]!==w||t[32]!==x?(T=(0,U.jsxs)(`div`,{className:`min-w-0`,children:[x,w]}),t[31]=w,t[32]=x,t[33]=T):T=t[33];let E;t[34]!==T||t[35]!==f?(E=(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[f,T]}),t[34]=T,t[35]=f,t[36]=E):E=t[36];let D=p.enabled,O;t[37]!==c.toggleChannel||t[38]!==n.label?(O=c.toggleChannel.replace(`{{channel}}`,n.label),t[37]=c.toggleChannel,t[38]=n.label,t[39]=O):O=t[39];let k;t[40]!==a||t[41]!==u||t[42]!==p.enabled||t[43]!==O?(k=(0,U.jsx)(nt,{checked:D,disabled:a,label:O,onToggle:u}),t[40]=a,t[41]=u,t[42]=p.enabled,t[43]=O,t[44]=k):k=t[44],t[45]!==E||t[46]!==k?(b=(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[E,k]}),t[45]=E,t[46]=k,t[47]=b):b=t[47],h=`button`,g=l,_=`mt-5 min-h-[6.25rem] text-left`,v=p.ready?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`p`,{className:`line-clamp-2 text-sm leading-6 text-fg-muted`,children:n.description??n.id}),e.length>0?(0,U.jsx)(`div`,{className:`mt-3 space-y-0.5 text-sm leading-5 text-fg-muted`,children:e.map($)}):null]}):(0,U.jsxs)(`div`,{className:`rounded-lg bg-surface-base p-3`,children:[(0,U.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:c.cardSetupTitle}),(0,U.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm leading-5 text-fg-muted`,children:e[0]??Qe(n,c)}),s.length>0?(0,U.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:s.map(it)}):null]}),t[2]=a,t[3]=c,t[4]=r,t[5]=n,t[6]=l,t[7]=d,t[8]=u,t[9]=i,t[10]=p.enabled,t[11]=p.ready,t[12]=m,t[13]=h,t[14]=g,t[15]=_,t[16]=v,t[17]=y,t[18]=b}else m=t[12],h=t[13],g=t[14],_=t[15],v=t[16],y=t[17],b=t[18];let x;t[48]!==h||t[49]!==g||t[50]!==_||t[51]!==v?(x=(0,U.jsx)(`button`,{type:h,onClick:g,className:_,children:v}),t[48]=h,t[49]=g,t[50]=_,t[51]=v,t[52]=x):x=t[52];let S=a||s,C;t[53]!==a||t[54]!==s?(C=a||s?(0,U.jsx)(B,{className:`size-4 animate-spin`}):null,t[53]=a,t[54]=s,t[55]=C):C=t[55];let w;t[56]!==c||t[57]!==n||t[58]!==s||t[59]!==i?(w=s?c.restartingChannel:i===`stopped`?c.restartChannel:Ze(n,c),t[56]=c,t[57]=n,t[58]=s,t[59]=i,t[60]=w):w=t[60];let T;t[61]!==m||t[62]!==C||t[63]!==w||t[64]!==S?(T=(0,U.jsx)(`div`,{className:`mt-auto pt-4`,children:(0,U.jsxs)(N,{type:`button`,variant:`secondary`,className:`w-full rounded-2xl py-2.5`,onClick:m,disabled:S,children:[C,w]})}),t[61]=m,t[62]=C,t[63]=w,t[64]=S,t[65]=T):T=t[65];let E;return t[66]!==T||t[67]!==y||t[68]!==b||t[69]!==x?(E=(0,U.jsxs)(`article`,{className:y,children:[b,x,T]}),t[66]=T,t[67]=y,t[68]=b,t[69]=x,t[70]=E):E=t[70],E}function it(e){return(0,U.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e},e)}function $(e){return(0,U.jsx)(`p`,{className:`truncate`,title:e,children:e},e)}function at(e){let t=(0,H.c)(51),{runtime:n,restarting:r,checking:i,showConnectionOptions:a,canManageConnection:s,ch:c,onRestart:l,onCheck:u,onManageConnection:d}=e,f=n===`running`?ie:n===`stopped`||n===`needs_setup`?z:B,p=n===`running`&&`text-emerald-600 dark:text-emerald-400`,m=n===`stopped`&&`text-red-600 dark:text-red-400`,h=n===`checking`&&`animate-spin text-amber-600 dark:text-amber-400`,g=n===`disabled`&&`text-fg-muted`,_=n===`needs_setup`&&`text-amber-600 dark:text-amber-400`,v;t[0]!==p||t[1]!==m||t[2]!==h||t[3]!==g||t[4]!==_?(v=o(`mt-0.5 size-5 shrink-0`,p,m,h,g,_),t[0]=p,t[1]=m,t[2]=h,t[3]=g,t[4]=_,t[5]=v):v=t[5];let y;t[6]!==f||t[7]!==v?(y=(0,U.jsx)(f,{className:v}),t[6]=f,t[7]=v,t[8]=y):y=t[8];let b;t[9]===c.connectionStatus?b=t[10]:(b=(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:c.connectionStatus}),t[9]=c.connectionStatus,t[10]=b);let x;t[11]!==c||t[12]!==n?(x=Ve(n,c),t[11]=c,t[12]=n,t[13]=x):x=t[13];let S;t[14]===x?S=t[15]:(S=(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:x}),t[14]=x,t[15]=S);let C;t[16]!==S||t[17]!==b?(C=(0,U.jsxs)(`div`,{children:[b,S]}),t[16]=S,t[17]=b,t[18]=C):C=t[18];let w;t[19]!==C||t[20]!==y?(w=(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[y,C]}),t[19]=C,t[20]=y,t[21]=w):w=t[21];let T=i||r,E;t[22]===i?E=t[23]:(E=i?(0,U.jsx)(B,{className:`size-4 animate-spin`}):null,t[22]=i,t[23]=E);let D=i?c.checkingConnection:c.checkConnection,O;t[24]!==u||t[25]!==T||t[26]!==E||t[27]!==D?(O=(0,U.jsxs)(N,{type:`button`,variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:T,onClick:u,children:[E,D]}),t[24]=u,t[25]=T,t[26]=E,t[27]=D,t[28]=O):O=t[28];let k;t[29]!==c.restartChannel||t[30]!==c.restartingChannel||t[31]!==i||t[32]!==l||t[33]!==r||t[34]!==n?(k=n===`stopped`?(0,U.jsxs)(N,{type:`button`,variant:`primary`,className:`px-2.5 py-1.5 text-xs`,disabled:r||i,onClick:l,children:[r?(0,U.jsx)(B,{className:`size-4 animate-spin`}):(0,U.jsx)(ne,{className:`size-4`}),r?c.restartingChannel:c.restartChannel]}):null,t[29]=c.restartChannel,t[30]=c.restartingChannel,t[31]=i,t[32]=l,t[33]=r,t[34]=n,t[35]=k):k=t[35];let A;t[36]!==s||t[37]!==c.connectionOptions||t[38]!==c.hideConnectionOptions||t[39]!==i||t[40]!==d||t[41]!==r||t[42]!==a?(A=s?(0,U.jsx)(N,{type:`button`,variant:`ghost`,className:`px-2.5 py-1.5 text-xs`,disabled:i||r,onClick:d,children:a?c.hideConnectionOptions:c.connectionOptions}):null,t[36]=s,t[37]=c.connectionOptions,t[38]=c.hideConnectionOptions,t[39]=i,t[40]=d,t[41]=r,t[42]=a,t[43]=A):A=t[43];let j;t[44]!==O||t[45]!==k||t[46]!==A?(j=(0,U.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[O,k,A]}),t[44]=O,t[45]=k,t[46]=A,t[47]=j):j=t[47];let M;return t[48]!==w||t[49]!==j?(M=(0,U.jsx)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:(0,U.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[w,j]})}),t[48]=w,t[49]=j,t[50]=M):M=t[50],M}function ot(e){let t=(0,H.c)(33),{entry:n,ch:r}=e,i,a,o,s,c,l,u,d,f;if(t[0]!==r||t[1]!==n){f=Symbol.for(`react.early_return_sentinel`);bb0:{let e=Y(n);if(e.ready||e.issues.length===0){f=null;break bb0}d=`rounded-xl border border-amber-200 bg-amber-50 px-4 py-3 text-amber-950 dark:border-amber-900/50 dark:bg-amber-950/30 dark:text-amber-100`,l=`flex items-start gap-3`,t[11]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,U.jsx)(E,{className:`mt-0.5 size-4 shrink-0`}),t[11]=u):u=t[11],o=`min-w-0`,t[12]===r.setupReadinessTitle?s=t[13]:(s=(0,U.jsx)(`h3`,{className:`text-sm font-semibold`,children:r.setupReadinessTitle}),t[12]=r.setupReadinessTitle,t[13]=s);let p=e.enabled?r.setupReadinessEnabledBody:r.setupReadinessDisabledBody;t[14]===p?c=t[15]:(c=(0,U.jsx)(`p`,{className:`mt-1 text-sm leading-5 text-amber-900 dark:text-amber-200`,children:p}),t[14]=p,t[15]=c),i=`mt-2 list-disc space-y-1 pl-5 text-sm text-amber-900 dark:text-amber-200`;let m;t[16]===r?m=t[17]:(m=e=>(0,U.jsx)(`li`,{children:et(e,r)},`${e.code}:${e.fieldPath??``}`),t[16]=r,t[17]=m),a=e.issues.map(m)}t[0]=r,t[1]=n,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=f}else i=t[2],a=t[3],o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10];if(f!==Symbol.for(`react.early_return_sentinel`))return f;let p;t[18]!==i||t[19]!==a?(p=(0,U.jsx)(`ul`,{className:i,children:a}),t[18]=i,t[19]=a,t[20]=p):p=t[20];let m;t[21]!==p||t[22]!==o||t[23]!==s||t[24]!==c?(m=(0,U.jsxs)(`div`,{className:o,children:[s,c,p]}),t[21]=p,t[22]=o,t[23]=s,t[24]=c,t[25]=m):m=t[25];let h;t[26]!==m||t[27]!==l||t[28]!==u?(h=(0,U.jsxs)(`div`,{className:l,children:[u,m]}),t[26]=m,t[27]=l,t[28]=u,t[29]=h):h=t[29];let g;return t[30]!==h||t[31]!==d?(g=(0,U.jsx)(`section`,{className:d,children:h}),t[30]=h,t[31]=d,t[32]=g):g=t[32],g}function st(){let e=l(e=>e.language),t=s(e),n=c(e=>!!e.token),r=a(),{channelId:f}=i(),h=C(f),_=ke(n,e),y=_.entries,{data:b,mutate:S,isValidating:w}=p(n?fe():null,de,{revalidateOnFocus:!0}),{data:T,mutate:E}=p(n?`channels-config-map`:null,Le,{revalidateOnFocus:!1}),D=T?.channels??{},O=T?.bindings??[],{data:k}=p(n?`channel-routing-agents`:null,v,{revalidateOnFocus:!1}),j=x(e=>e.setPageHeader),M=x(e=>e.clearPageHeader),N=(0,V.useMemo)(()=>y.find(e=>e.id===h),[h,y]),ee=N?ze(N):null,{data:P,mutate:L}=p(n&&ee?Pe(ee):null,()=>Fe(ee)),[R,z]=(0,V.useState)(null),[ne,ie]=(0,V.useState)(!1),[ae,B]=(0,V.useState)(null),[ue,H]=(0,V.useState)(null),[me,he]=(0,V.useState)(!1),[W,G]=(0,V.useState)(null),[K,q]=(0,V.useState)(null),_e=R??P??{},J=t.channelsSettings,be=(0,V.useMemo)(()=>N?.configSchema??{type:`object`,properties:{}},[N?.configSchema]),Se=(0,V.useMemo)(()=>Ke(be,Ie),[be]),we=(0,V.useMemo)(()=>Ue(N),[N]),De=(0,V.useMemo)(()=>We(Se,we),[we,Se]),Oe=(0,V.useMemo)(()=>Ke(Se,we),[we,Se]),Ae=(0,V.useMemo)(()=>qe(De),[De]),Me=N?K??ve(O,N.id):``,Re=(0,V.useMemo)(()=>(k?.items??[]).map(e=>{let n=F(e,t.agentsSettings);return{value:e.id,label:n===e.id?n:`${n} · ${e.id}`}}),[k?.items,t.agentsSettings]),Ve=k?.items.find(e=>e.id===k.defaultId),X=Ve?F(Ve,t.agentsSettings):k?.defaultId??``,Z=(0,V.useMemo)(()=>({defaultBooleanLabel:J.schemaBooleanDefault,unsupportedArrayType:J.schemaUnsupportedArrayType,arrayAddPlaceholder:J.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>J.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[J]),Ge=(0,V.useMemo)(()=>new Map((b??[]).map(e=>[e.name,e])),[b]),Je=b!==void 0,Ye=(0,V.useCallback)(e=>xe(e,Ge.get(e.id),Je),[Ge,Je]),Q=(0,V.useCallback)(async()=>{await Promise.all([_.mutate(),S()])},[_,S]);Ne((0,V.useCallback)(e=>{let t=je(e);t&&S(t,!1)},[S]),n);let Xe=(0,V.useMemo)(()=>n?(0,U.jsx)(Te,{ch:J,refreshing:_.isValidating||w,saveOk:!1,onRefresh:()=>void Q()}):null,[_.isValidating,J,n,w,Q]);(0,V.useLayoutEffect)(()=>(j({startExtra:null,main:(0,U.jsx)(`div`,{className:`min-w-0`,children:(0,U.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.settingsSections.channels})}),end:Xe}),()=>M()),[M,Xe,t.settingsSections.channels,j]);let Ze=(0,V.useCallback)(e=>{r(te(e)),z(null),q(null),G(null)},[r]),Qe=(0,V.useCallback)(()=>{r(g),z(null),q(null),G(null)},[r]),$e=(0,V.useCallback)(async e=>{H(e.id),G(null);try{let t=await u(d(`/api/channels/${encodeURIComponent(e.id)}/restart`),{method:`POST`});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}await Q()}catch(e){G(e instanceof Error?e.message:String(e))}finally{H(null)}},[Q]);(0,V.useEffect)(()=>{q(null),he(!1)},[N?.id]);let et=(0,V.useCallback)(async()=>{if(!N||!R&&K===null)return!1;let e=ze(N);ie(!0),G(null);try{let t=await u(d(`/api/config`),{method:`PATCH`,body:JSON.stringify({...R?{channels:{[e]:R}}:{},...K===null?{}:{bindings:ye(O,N.id,K)}})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}return R&&await L(R,!1),await E(),await _.mutate(),z(null),q(null),!0}catch(e){return G(e instanceof Error?e.message:String(e)),!1}finally{ie(!1)}},[N,K,O,_,R,E,L]),it=(0,V.useCallback)(async e=>{let t=Y(e),n=ze(e),r=N?.id===e.id?R:null;if(!t.enabled&&!t.ready&&!r){Ze(e.id);return}B(e.id),G(null);try{let i=t.enabled?{enabled:!1}:r?{...r,enabled:!0}:{enabled:!0},a=await u(d(`/api/config`),{method:`PATCH`,body:JSON.stringify({channels:{[n]:i}})});if(!a.ok){let e=await a.json().catch(()=>({}));throw Error(e.error?.message??a.statusText)}await _.mutate(),await E(),await S(),N?.id===e.id&&(await L(),z(null))}catch(e){G(e instanceof Error?e.message:String(e))}finally{B(null)}},[N?.id,_,R,E,L,S,Ze]),$=N?.ui?.modal,st=$?.placement!==`replace-config`,ct=N?Ye(N):`checking`,lt=N?!Y(N).ready||me:!1;return n?(0,U.jsxs)(se,{gap:`gap-4`,children:[_.isLoading?(0,U.jsx)(ce,{sections:2}):_.error?(0,U.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:String(_.error)}):(0,U.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:y.map(e=>(0,U.jsx)(rt,{entry:e,config:D[ze(e)]?.config,runtime:Ye(e),busy:ae===e.id,restarting:ue===e.id,ch:J,onOpen:()=>Ze(e.id),onToggle:()=>void it(e),onRestart:()=>void $e(e)},e.id))}),W?(0,U.jsx)(`p`,{className:`mt-4 text-sm text-red-600 dark:text-red-400`,children:W}):null,(0,U.jsx)(Ce,{presentation:`modal`,open:!!N,onOpenChange:e=>{e||Qe()},closeAriaLabel:J.close,srTitle:N?.label??J.selectChannel,srDescription:N?.description,wide:!0,footer:N?(0,U.jsx)(Ee,{ch:J,dirty:!!R||K!==null,saving:ne,onCancel:Qe,onDiscard:()=>{z(null),q(null)},onSave:et}):null,children:N?(0,U.jsxs)(`div`,{className:`space-y-4`,children:[(0,U.jsx)(`div`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,children:(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,U.jsx)(tt,{entry:N}),(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,U.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:N.label}),(0,U.jsx)(`span`,{className:o(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,He(ct)),children:Be(ct,J)})]}),(0,U.jsxs)(`div`,{className:`mt-1 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-sm text-fg-muted`,children:[(0,U.jsx)(`span`,{className:`min-w-0 truncate`,children:!Y(N).ready&&pe(N)?.[1].result===`qr`?J.scanLoginHint.replace(`{{channel}}`,N.label):N.description}),N.docsPath?(0,U.jsxs)(`a`,{href:N.docsPath,target:`_blank`,rel:`noreferrer`,className:`inline-flex shrink-0 items-center gap-1 text-accent hover:underline`,children:[J.docs,(0,U.jsx)(m,{className:`size-3.5`})]}):null]})]})]}),(0,U.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pr-8`,children:[(0,U.jsx)(`span`,{className:`hidden text-xs text-fg-muted sm:inline`,children:Y(N).enabled?J.enabledLabel:J.disabledLabel}),(0,U.jsx)(nt,{checked:Y(N).enabled,disabled:ae===N.id,label:J.toggleChannel.replace(`{{channel}}`,N.label),onToggle:()=>void it(N)})]})]})}),(0,U.jsx)(at,{runtime:ct,restarting:ue===N.id,checking:w,showConnectionOptions:me,canManageConnection:Y(N).ready&&$?.placement!==`replace-config`,ch:J,onRestart:()=>void $e(N),onCheck:()=>void Q(),onManageConnection:()=>he(e=>!e)}),(0,U.jsx)(ot,{entry:N,ch:J}),lt&&$?.placement!==`replace-config`?(0,U.jsx)(ge,{entry:N,locale:e,messages:J,compact:!0,onChanged:async()=>{await L(),await Q(),await E()}},N.id):null,$?.entrypoint&&$.placement===`before-config`?(0,U.jsx)(I,{extensionId:N.extensionId,extensionName:N.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:N.id,entry:N,config:_e}}):null,$?.entrypoint&&$.placement!==`before-config`?(0,U.jsx)(I,{extensionId:N.extensionId,extensionName:N.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:N.id,entry:N,config:_e}}):null,st&&Ae?(0,U.jsxs)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:`mb-4`,children:[(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:J.basicConfiguration}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:J.basicConfigurationHint})]}),(0,U.jsx)(le,{schema:De,values:_e,onChange:e=>z(e),disabled:ne,labels:Z})]}):null,(0,U.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,U.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,U.jsx)(re,{className:`size-4 text-fg-muted`}),J.messageHandling]}),(0,U.jsxs)(`div`,{className:`bg-surface-base/50 p-4`,children:[(0,U.jsxs)(`div`,{className:`mb-3`,children:[(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:J.agentRouting}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:J.messageHandlingHint})]}),(0,U.jsx)(A,{value:Me,options:Re,placeholder:J.agentRoutingSelect,emptyLabel:J.agentRoutingDefault.replace(`{{agent}}`,X||J.agentRoutingSelect),ariaLabel:J.agentRouting,disabled:ne||!k,onChange:e=>q(e)})]})]}),st&&qe(Oe)?(0,U.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,U.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,U.jsx)(re,{className:`size-4 text-fg-muted`}),J.advancedConfiguration]}),(0,U.jsx)(`div`,{className:`bg-surface-base/50 p-4`,children:(0,U.jsx)(le,{schema:Oe,values:_e,onChange:e=>z(e),disabled:ne,labels:Z})})]}):null,W?(0,U.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:W}):null]}):null})]}):(0,U.jsxs)(se,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,U.jsx)(oe,{title:t.settingsSections.channels}),(0,U.jsx)(`p`,{className:`text-sm text-fg-muted`,children:J.tokenRequired})]})}export{st as ChannelsSettingsPanel};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./locale-store-Bjvw7jtg.js";import{n as t}from"./channel-recipient-api-_8IiTxRB.js";function n(){return e(`/api/channels/status`)}var r=t;export{r as n,n as t};
|
package/dist/gateway/static/root/assets/{connectors-api-3ccRyS3L.js → connectors-api-vaSrhPF8.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e,s as t}from"./locale-store-
|
|
1
|
+
import{r as e,s as t}from"./locale-store-Bjvw7jtg.js";import{po as n}from"./index-BpkdvHH0.js";function r(e,t){if(!e.payload)throw Error(e.error??t);return e.payload}async function i(){return r(await t(e(`/api/connectors/catalog`)),`Could not load connector catalog.`).connectors}async function a(n){let i=new URLSearchParams;return n?.q?.trim()&&i.set(`q`,n.q.trim()),n?.page&&i.set(`page`,String(n.page)),n?.pageSize&&i.set(`pageSize`,String(n.pageSize)),n?.refresh&&i.set(`refresh`,`1`),n?.verification&&i.set(`verification`,n.verification),r(await t(e(`/api/connectors/composio/catalog${i.size?`?${i.toString()}`:``}`)),`Could not load Composio catalog.`)}async function o(n){let i=new URLSearchParams;return n?.q?.trim()&&i.set(`q`,n.q.trim()),n?.page&&i.set(`page`,String(n.page)),n?.pageSize&&i.set(`pageSize`,String(n.pageSize)),n?.category?.trim()&&i.set(`category`,n.category.trim()),n?.sort&&i.set(`sort`,n.sort),r(await t(e(`/api/capabilities/connectors${i.size?`?${i.toString()}`:``}`)),`Could not load Store connector capabilities.`)}async function s(n,i){return r(await t(e(`/api/capabilities/connectors/${encodeURIComponent(n)}/install-plan`),{method:`POST`,body:JSON.stringify({version:i})}),`Could not prepare connector installation.`).plan}async function c(i,a,o){let s=await t(e(`/api/capabilities/connectors/${encodeURIComponent(i)}/install`),{method:`POST`,body:JSON.stringify({...a,version:o})});return n(),r(s,`Could not install Store connector.`).instance}async function l(){return r(await t(e(`/api/connectors/installed`)),`Could not load installed connectors.`).instances}async function u(n){return r(await t(e(`/api/connectors/${encodeURIComponent(n)}/auth/start`),{method:`POST`}),`Could not start connector authorization.`).authorization}async function d(){return r(await t(e(`/api/connectors/composio/setup-status`)),`Could not check the connection service.`)}async function f(n){r(await t(e(`/api/connectors/composio/setup`),{method:`POST`,body:JSON.stringify({apiKey:n})}),`Could not enable the connection service.`)}async function p(i,a){let o=await t(e(`/api/connectors/${encodeURIComponent(i)}/install`),{method:`POST`,body:JSON.stringify(a)});return n(),r(o,`Could not install connector.`).instance}async function m(n,i={}){return r(await t(e(`/api/connectors/preview`),{method:`POST`,body:JSON.stringify({...i,definition:n})}),`Could not preview connector capabilities.`).preview}async function h(n,i){return r(await t(e(`/api/connectors/${encodeURIComponent(n)}/config`),{method:`POST`,body:JSON.stringify(i)}),`Could not update connector config.`).instance}async function g(r){await t(e(`/api/connectors/${encodeURIComponent(r)}`),{method:`DELETE`}),n()}async function _(n){return r(await t(e(`/api/connectors/${encodeURIComponent(n)}/test`),{method:`POST`}),`Connector test failed.`)}async function v(){return r(await t(e(`/api/connectors/composio/connections`)),`Could not load Composio connections.`).connections}async function y(e,t,n=12e4){let r=Date.now()+n;for(;Date.now()<r;){let n=(await v().catch(()=>[])).find(n=>n.toolkit.toLowerCase()===e.toLowerCase()&&n.status===`active`&&(!t||n.providerConnectionId===t));if(n)return n;await new Promise(e=>window.setTimeout(e,2e3))}throw Error(`Connection authorization timed out.`)}async function b(n,i){return r(await t(e(`/api/connectors/composio/connections/${encodeURIComponent(n)}`),{method:`PATCH`,body:JSON.stringify(i)}),`Could not update Composio connection.`).connection}async function x(n){return r(await t(e(`/api/connectors/composio/${encodeURIComponent(n)}/health`)),`Could not check Composio connector health.`).health}async function S(n){await t(e(`/api/connectors/composio/connections/${encodeURIComponent(n)}/refresh`),{method:`POST`})}async function C(n){await t(e(`/api/connectors/composio/connections/${encodeURIComponent(n)}`),{method:`DELETE`})}async function w(n){return r(await t(e(`/api/connectors/composio/${encodeURIComponent(n)}/scope`)),`Could not load Composio scope.`).scope}async function T(i,a){let o=await t(e(`/api/connectors/composio/${encodeURIComponent(i)}/scope`),{method:`POST`,body:JSON.stringify({scope:a})});return n(),r(o,`Could not update Composio scope.`).scope}async function E(n){return r(await t(e(`/api/connectors/composio/${encodeURIComponent(n)}/policy`)),`Could not load Composio policy.`)}async function D(n,i){return r(await t(e(`/api/connectors/composio/${encodeURIComponent(n)}/policy`),{method:`PATCH`,body:JSON.stringify(i)}),`Could not update Composio policy.`).policy}async function O(n){return r(await t(e(`/api/connectors/composio/${encodeURIComponent(n)}/tools`)),`Could not load Composio tools.`).tools}async function k(n=50){return r(await t(e(`/api/connectors/composio/triggers?limit=${encodeURIComponent(String(n))}`)),`Could not load Composio trigger events.`).events}async function A(n){return r(await t(e(`/api/connectors/composio/accounts/${encodeURIComponent(n)}/learning`),{method:`POST`}),`Could not start learning from this connection.`).job}async function j(){return r(await t(e(`/api/connectors/learning`)),`Could not load connector learning jobs.`).jobs}async function M(n){return r(await t(e(`/api/connectors/composio/accounts/${encodeURIComponent(n)}/sync-policy`)),`Could not load connector sync policy.`).policy}async function N(n,i){return r(await t(e(`/api/connectors/composio/accounts/${encodeURIComponent(n)}/sync-policy`),{method:`PATCH`,body:JSON.stringify(i)}),`Could not update connector sync policy.`).policy}async function P(n){return r(await t(e(`/api/connectors/${encodeURIComponent(n)}/source-sync`),{method:`POST`}),`Could not sync connector source.`)}async function F(n=``,i=100){return r(await t(e(`/api/connectors/people?${new URLSearchParams({q:n,limit:String(i)}).toString()}`)),`Could not load the connected people graph.`)}async function I(n=`pending`){return r(await t(e(`/api/connectors/approvals?status=${encodeURIComponent(n)}`)),`Could not load connector approvals.`).approvals}async function L(n,i){return r(await t(e(`/api/connectors/approvals/respond`),{method:`POST`,body:JSON.stringify({id:n,decision:i})}),`Could not update connector approval.`).approval}export{b as A,L as C,u as D,A as E,h as M,N,P as O,y as P,g as S,T,k as _,l as a,m as b,x as c,d,M as f,O as g,v as h,i,D as j,_ as k,E as l,c as m,a as n,o,p,F as r,s,f as t,w as u,I as v,C as w,S as x,j as y};
|
|
@@ -0,0 +1,2 @@
|
|
|
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-DQ5X6cXp.js";import{l as u,n as d,r as f,s as p}from"./locale-store-Bjvw7jtg.js";import{Al as m,Ao as h,Bs as g,Dc as _,Fl as v,Fo as y,Gl as b,Go as x,Jr as S,Kr as C,La as w,Mo as T,Ni as E,No as D,Oo as O,Po as k,Ps as A,Qs as j,Tl as M,Ts as N,Uo as P,Us as F,Wl as I,Wo as L,Xo as R,Yr as z,Zo as B,Zr as ee,_s as V,ac as H,bs as te,cc as ne,cs as re,di as U,ds as ie,el as ae,fi as oe,gc as se,gs as W,hc as ce,hi as le,ic as ue,jo as de,ko as fe,mi as pe,mo as me,nc as he,ou as ge,pi as _e,po as ve,qr as ye,ru as be,tc as xe,tu as Se,vc as Ce,xs as G,zc as K}from"./index-BpkdvHH0.js";import{t as we}from"./page-tabs-CROi9zm1.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-vaSrhPF8.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)(_,{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 v;return t[13]!==p||t[14]!==m||t[15]!==h||t[16]!==g?(v=(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]=v):v=t[17],v}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,m,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)(V,{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)(_,{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),m=a?`button`:void 0,h=a?0:void 0,t[29]!==n||t[30]!==a?(g=()=>a?.(n),t[29]=n,t[30]=a,t[31]=g):g=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)(Se,{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]=m,t[17]=h,t[18]=g,t[19]=v}else c=t[10],l=t[11],u=t[12],d=t[13],f=t[14],p=t[15],m=t[16],h=t[17],g=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]!==m||t[70]!==h||t[71]!==g||t[72]!==v?(x=(0,Q.jsxs)(`div`,{className:p,role:m,tabIndex:h,onClick:g,onKeyDown:v,children:[y,b]}),t[66]=y,t[67]=b,t[68]=p,t[69]=m,t[70]=h,t[71]=g,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),m=Math.max(0,e.capabilities.length-p.length),g=[...(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}))],y=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)(O,{open:!0,onOpenChange:e=>{e||n()},children:(0,Q.jsxs)(D,{children:[(0,Q.jsx)(T,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,Q.jsxs)(h,{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)(Se,{className:`size-3`,"aria-hidden":!0}),i.connectedBadge]})}):null,(0,Q.jsx)(k,{className:`text-base font-semibold text-fg`,children:e.displayName}),(0,Q.jsx)(de,{className:`mt-1 line-clamp-3 text-sm leading-6 text-fg-muted`,children:e.description})]})]}),(0,Q.jsx)(fe,{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`,ie.focusRingPanel),"aria-label":i.modalClose,children:[(0,Q.jsx)(te,{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)(G,{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)(ae,{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)(v,{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)),m>0?(0,Q.jsxs)(`span`,{className:`rounded-md border border-edge bg-surface-base px-2 py-1 text-xs text-fg-subtle`,children:[`+`,m]}):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)(ae,{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)(v,{className:`size-4 text-accent`,"aria-hidden":!0}),i.connectorSetupTitle]}),g.length>0?(0,Q.jsx)(`div`,{className:`mt-3 divide-y divide-edge overflow-hidden rounded-lg border border-edge`,children:g.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)(he,{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)(fe,{asChild:!0,children:(0,Q.jsx)(V,{variant:`secondary`,children:i.modalClose})}),(0,Q.jsxs)(V,{variant:`secondary`,disabled:a,onClick:()=>void y(),children:[a?(0,Q.jsx)(K,{className:`size-4 animate-spin`}):(0,Q.jsx)(G,{className:`size-4`}),i.connectorPreviewButton]}),t?(0,Q.jsxs)(V,{variant:`secondary`,disabled:!0,children:[(0,Q.jsx)(Ce,{className:`size-4`}),i.connectedBadge]}):(0,Q.jsxs)(V,{variant:`primary`,onClick:()=>{r(e),n()},children:[(0,Q.jsx)(_,{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`,W);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)(T,{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)(se,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0})}),t[4]=m):m=t[4];let g;t[5]===l.runtimeSettingsTitle?g=t[6]:(g=(0,Q.jsx)(k,{className:`text-base font-semibold text-fg`,children:l.runtimeSettingsTitle}),t[5]=l.runtimeSettingsTitle,t[6]=g);let _;t[7]===l.runtimeSettingsHint?_=t[8]:(_=(0,Q.jsx)(de,{className:`mt-1 text-sm text-fg-muted`,children:l.runtimeSettingsHint}),t[7]=l.runtimeSettingsHint,t[8]=_);let v;t[9]!==g||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:[g,_]})]}),t[9]=g,t[10]=_,t[11]=v):v=t[11];let y;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(y=s(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,ie.focusRingPanel),t[12]=y):y=t[12];let b;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,Q.jsx)(te,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),t[13]=b):b=t[13];let x;t[14]===l.modalClose?x=t[15]:(x=(0,Q.jsx)(fe,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,className:y,"aria-label":l.modalClose,children:b})}),t[14]=l.modalClose,t[15]=x);let S;t[16]!==x||t[17]!==v?(S=(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,x]}),t[16]=x,t[17]=v,t[18]=S):S=t[18];let C;t[19]===u.idleTtlLabel?C=t[20]:(C=(0,Q.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:u.idleTtlLabel}),t[19]=u.idleTtlLabel,t[20]=C);let w;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(w=s(bt,`w-40 flex-none`),t[21]=w):w=t[21];let E=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]!==E||t[26]!==A?(j=(0,Q.jsx)(`input`,{type:`number`,min:0,className:w,value:E,placeholder:u.idleTtlPlaceholder,onChange:A}),t[24]=u.idleTtlPlaceholder,t[25]=E,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 N;t[30]!==C||t[31]!==j||t[32]!==M?(N=(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:[C,j,M]})}),t[30]=C,t[31]=j,t[32]=M,t[33]=N):N=t[33];let P;t[34]!==c||t[35]!==i||t[36]!==l.modalCancel?(P=(0,Q.jsx)(V,{type:`button`,variant:`secondary`,disabled:i,onClick:c,children:l.modalCancel}),t[34]=c,t[35]=i,t[36]=l.modalCancel,t[37]=P):P=t[37];let F;t[38]===o?F=t[39]:(F=()=>void o(),t[38]=o,t[39]=F);let I;t[40]===i?I=t[41]:(I=i?(0,Q.jsx)(K,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,t[40]=i,t[41]=I);let L;t[42]!==u.save||t[43]!==i||t[44]!==F||t[45]!==I?(L=(0,Q.jsxs)(V,{type:`button`,variant:`primary`,disabled:i,onClick:F,children:[I,u.save]}),t[42]=u.save,t[43]=i,t[44]=F,t[45]=I,t[46]=L):L=t[46];let R;t[47]!==P||t[48]!==L?(R=(0,Q.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[P,L]}),t[47]=P,t[48]=L,t[49]=R):R=t[49];let z;t[50]!==S||t[51]!==N||t[52]!==R?(z=(0,Q.jsxs)(D,{children:[f,(0,Q.jsxs)(h,{className:p,children:[S,N,R]})]}),t[50]=S,t[51]=N,t[52]=R,t[53]=z):z=t[53];let B;return t[54]!==n||t[55]!==d||t[56]!==z?(B=(0,Q.jsx)(O,{open:n,onOpenChange:d,children:z}),t[54]=n,t[55]=d,t[56]=z,t[57]=B):B=t[57],B}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)(ue,{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)(xe,{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)(V,{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)(ce,{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)(ge,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[8]=m):m=t[8];let h;t[9]===a?h=t[10]:(h=(0,Q.jsx)(ee,{asChild:!0,children:(0,Q.jsxs)(V,{type:`button`,variant:`primary`,className:`shrink-0 gap-2`,children:[p,a,m]})}),t[9]=a,t[10]=h);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`,ie.transition),t[11]=_):_=t[11];let v;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,Q.jsx)(g,{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)(ye,{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`,ie.transition),t[16]=b):b=t[16];let x;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,Q.jsx)(G,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[17]=x):x=t[17];let w;t[18]!==c||t[19]!==r?(w=(0,Q.jsxs)(ye,{className:b,onSelect:r,children:[x,c]}),t[18]=c,t[19]=r,t[20]=w):w=t[20];let T;t[21]!==w||t[22]!==y?(T=(0,Q.jsx)(S,{children:(0,Q.jsxs)(C,{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,w]})}),t[21]=w,t[22]=y,t[23]=T):T=t[23];let E;t[24]!==T||t[25]!==h?(E=(0,Q.jsxs)(z,{children:[h,T]}),t[24]=T,t[25]=h,t[26]=E):E=t[26];let D;return t[27]!==E||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,E]}),t[27]=E,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})}),ve()}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)(V,{variant:`secondary`,disabled:a,onClick:()=>void m(),children:[a?(0,Q.jsx)(K,{className:`size-4 animate-spin`}):(0,Q.jsx)(Ce,{className:`size-4`}),t.testConnection]}),(0,Q.jsxs)(V,{variant:`ghost`,disabled:s,onClick:()=>void h(),children:[s?(0,Q.jsx)(K,{className:`size-4 animate-spin`}):(0,Q.jsx)(A,{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)(ue,{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`,W),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)(T,{className:s(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,B)}),t[0]=m):m=t[0];let g;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(g=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`,R,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`),t[1]=g):g=t[1];let _;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,Q.jsx)(G,{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)(k,{className:`flex items-center gap-2 text-base font-semibold text-fg`,children:[_,a]}),t[3]=a,t[4]=v);let y;t[5]!==i||t[6]!==o||t[7]!==f.length?(y=o.replace(`{{serverId}}`,i).replace(`{{count}}`,String(f.length)),t[5]=i,t[6]=o,t[7]=f.length,t[8]=y):y=t[8];let b;t[9]===y?b=t[10]:(b=(0,Q.jsx)(de,{className:`mt-1 text-sm text-fg-muted`,children:y}),t[9]=y,t[10]=b);let x;t[11]!==v||t[12]!==b?(x=(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[v,b]}),t[11]=v,t[12]=b,t[13]=x):x=t[13];let S;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,Q.jsx)(te,{className:`size-4`,"aria-hidden":!0}),t[14]=S):S=t[14];let C;t[15]===d?C=t[16]:(C=(0,Q.jsx)(fe,{asChild:!0,children:(0,Q.jsx)(V,{type:`button`,variant:`ghost`,className:`size-8 shrink-0 px-0`,"aria-label":d,children:S})}),t[15]=d,t[16]=C);let w;t[17]!==x||t[18]!==C?(w=(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-3 border-b border-edge px-5 py-4`,children:[x,C]}),t[17]=x,t[18]=C,t[19]=w):w=t[19];let E;t[20]!==u||t[21]!==n||t[22]!==l||t[23]!==c||t[24]!==i||t[25]!==p||t[26]!==f?(E=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]=E):E=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)(fe,{asChild:!0,children:(0,Q.jsx)(V,{type:`button`,variant:`secondary`,children:d})})}),t[28]=d,t[29]=A);let j;t[30]!==w||t[31]!==E||t[32]!==A?(j=(0,Q.jsxs)(D,{children:[m,(0,Q.jsxs)(h,{className:g,children:[w,E,A]})]}),t[30]=w,t[31]=E,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)(O,{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`,W);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,b]=(0,Z.useState)(null),[S,C]=(0,Z.useState)([]),[w,T]=(0,Z.useState)({}),[E,D]=(0,Z.useState)(`read`),[O,k]=(0,Z.useState)(!1),[j,M]=(0,Z.useState)(null),N=(0,Z.useMemo)(()=>tn(i),[i]),P=(0,Z.useCallback)(async()=>{if(!(!r||e.materialized.type!==`composio`||e.materialized.role===`credential`)){k(!0),M(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())),D(o),p(s.filter(t=>t.connectorId===e.connectorId)),h(c?.policy??null),_(c?.agents??[]),b(u),C(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)));T(Object.fromEntries(g.filter(e=>e!==null)))}catch(e){M(e instanceof Error?e.message:String(e))}finally{k(!1)}}},[e.connectorId,e.materialized,r]);(0,Z.useEffect)(()=>{P()},[P]);let I=(0,Z.useCallback)(async()=>{if(r){k(!0),M(null);try{let t=await Y(e.connectorId);if(!t.authorizationUrl)throw Error(`The authorization provider did not return an authorization URL.`);if(y()){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 P()}catch(e){M(e instanceof Error?e.message:String(e))}finally{k(!1)}}},[e.connectorId,P,n,r]),R=(0,Z.useCallback)(async e=>{if(r){D(e);try{await je(r,e),await P()}catch(e){M(e instanceof Error?e.message:String(e))}}},[P,r]),z=(0,Z.useCallback)(async(e,t)=>{k(!0),M(null);try{await J(e,t),await P()}catch(e){M(e instanceof Error?e.message:String(e))}finally{k(!1)}},[P]),B=(0,Z.useCallback)(async e=>{if(r){M(null);try{h(await Ve(r,e))}catch(e){M(e instanceof Error?e.message:String(e))}}},[e.connectorId,r]),ee=(0,Z.useCallback)(e=>{m&&B({allowedAgentIds:m.allowedAgentIds.includes(e)?m.allowedAgentIds.filter(t=>t!==e):[...m.allowedAgentIds,e]})},[B,m]),H=(0,Z.useCallback)(async e=>{k(!0),M(null);try{await e(),await P()}catch(e){M(e instanceof Error?e.message:String(e))}finally{k(!1)}},[P]);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)(V,{variant:`secondary`,disabled:O,onClick:()=>void I(),children:[O?(0,Q.jsx)(K,{className:`size-4 animate-spin`}):(0,Q.jsx)(ae,{className:`size-4`}),t.connectOAuth]}),(0,Q.jsx)(V,{variant:`ghost`,disabled:O,onClick:()=>void P(),children:t.refresh})]})]}),j?(0,Q.jsx)(`p`,{className:`mt-3 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:j}):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(N.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)(V,{variant:`ghost`,disabled:O,onClick:()=>void(v.recovery===`retry`?P():I()),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)(L,{className:s(nn,`mt-1 h-9 py-1`),value:E,onChange:e=>void R(e.currentTarget.value),children:[(0,Q.jsx)(x,{value:`read`,children:t.composioAccessReadOnly}),(0,Q.jsx)(x,{value:`write`,children:t.composioAccessReadWrite}),E===`admin`?(0,Q.jsx)(x,{value:`admin`,children:t.composioAccessAdminCurrent}):null]}),(0,Q.jsx)(`span`,{className:`mt-1 block font-normal leading-4 text-fg-muted`,children:E===`read`?t.composioAccessReadHint:E===`admin`?t.composioAccessAdminHint:t.composioAccessWriteHint})]}),(0,Q.jsxs)(`label`,{className:`text-xs font-medium text-fg-subtle`,children:[t.composioConfirmationPolicy,(0,Q.jsxs)(L,{className:s(nn,`mt-1 h-9 py-1`),value:m.confirmationPolicy,onChange:e=>void B({confirmationPolicy:e.currentTarget.value}),children:[(0,Q.jsx)(x,{value:`writes`,children:t.composioConfirmWrites}),(0,Q.jsx)(x,{value:`always`,children:t.composioConfirmAlways}),m.confirmationPolicy===`never`?(0,Q.jsx)(x,{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)(V,{variant:`secondary`,disabled:O,onClick:()=>void z(e.id,`denied`),children:[(0,Q.jsx)(te,{className:`size-4`}),t.composioDeny]}),(0,Q.jsxs)(V,{disabled:O,onClick:()=>void z(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}),N.length?[{title:t.composioConnectedAccounts,items:N.filter(e=>e.primary.status===`active`)},{title:t.composioNeedsAttention,items:N.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=S.find(e=>i.accountId?e.accountId===i.accountId:e.connectionId===i.id),o=i.accountId?w[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 H(()=>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 H(()=>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)(L,{className:s(nn,`mt-1 h-8 py-1 text-xs`),value:String(o.intervalMinutes??30),disabled:O,onChange:e=>void H(()=>De(i.accountId,{intervalMinutes:Number(e.currentTarget.value)})),children:[(0,Q.jsxs)(x,{value:`5`,children:[`5 `,t.connectorMinutes]}),(0,Q.jsxs)(x,{value:`15`,children:[`15 `,t.connectorMinutes]}),(0,Q.jsxs)(x,{value:`30`,children:[`30 `,t.connectorMinutes]}),(0,Q.jsxs)(x,{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)(V,{variant:`ghost`,className:`size-7 shrink-0 p-0`,title:t.composioRevoke,disabled:O,onClick:()=>{window.confirm(t.composioRevokeConfirm)&&H(()=>$e(e.id))},children:(0,Q.jsx)(A,{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??``)&&H(()=>q(i.id,{alias:e.currentTarget.value}))}})]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-1`,children:[(0,Q.jsx)(V,{variant:`ghost`,className:`size-8 p-0`,title:t.composioMakeDefault,disabled:O||i.isDefault||i.status!==`active`,onClick:()=>void H(async()=>{await q(i.id,{isDefault:!0}),r&&await Ve(r,{selectedConnectionIds:[i.id]})}),children:(0,Q.jsx)(F,{className:s(`size-4`,i.isDefault&&`fill-current`)})}),(0,Q.jsx)(V,{variant:`ghost`,className:`size-8 p-0`,title:t.refresh,disabled:O,onClick:()=>void H(()=>et(i.id)),children:(0,Q.jsx)(ne,{className:`size-4`})}),i.status===`active`?(0,Q.jsxs)(V,{variant:`secondary`,disabled:O,onClick:()=>void H(async()=>{if(!i.accountId)throw Error(`Connector account is unavailable.`);await Te(i.accountId),await n?.()}),children:[O?(0,Q.jsx)(K,{className:`size-4 animate-spin`}):(0,Q.jsx)(ne,{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)(L,{className:s(nn,`mt-1 h-9 py-1`),value:E,onChange:e=>void R(e.currentTarget.value),children:[(0,Q.jsx)(x,{value:`read`,children:t.composioScopeRead}),(0,Q.jsx)(x,{value:`write`,children:t.composioScopeWrite}),(0,Q.jsx)(x,{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`,W);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)(_e,{delayDuration:300,skipDelayDuration:100,children:(0,Q.jsxs)(pe,{children:[(0,Q.jsx)(le,{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)(oe,{children:(0,Q.jsx)(U,{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),[g,_]=(0,Z.useState)(null),[y,b]=(0,Z.useState)(null),[x,S]=(0,Z.useState)(e.materialized.type===`mcp`?`health`:`permissions`),[C,w]=(0,Z.useState)(!1),[E,N]=(0,Z.useState)(()=>fn(t,e)),[P,F]=(0,Z.useState)(null),I=t?.setup.config??[],L=(e.materialized.type===`mcp`||e.materialized.type===`memorySource`)&&I.length>0&&(t?.setup.secrets??[]).length===0,R=y?y.toolCount:e.usage.lastToolCount,z=(0,Z.useMemo)(()=>{let t=e.materialized.type===`mcp`?[[`health`,j,i.detailHealth],[`tools`,G,`${i.detailTools} ${y?y.toolCount:e.usage.lastToolCount??``}`],[`resources`,v,`${i.detailResources} ${y?y.resourceCount:e.usage.lastResourceCount??``}`],[`prompts`,M,`${i.detailPrompts} ${y?y.promptCount:e.usage.lastPromptCount??``}`],[`permissions`,ae,i.detailPermissions]]:[[`permissions`,ae,i.detailPermissions]];return L?[...t,[`config`,v,i.connectorConfigLabel]]:t},[y,e.materialized.type,e.usage.lastPromptCount,e.usage.lastResourceCount,e.usage.lastToolCount,L,i]),B=(0,Z.useCallback)(async()=>{c(!0),F(null);try{let t=await He(e.instanceId);b(t),t.toolCount>0&&S(`tools`),r()}catch(e){F(e instanceof Error?e.message:String(e))}finally{c(!1)}},[e.instanceId,r]),ee=(0,Z.useCallback)(async()=>{u(!0),F(null);try{await Ae(e.instanceId),await r(),n()}catch(e){F(e instanceof Error?e.message:String(e)),u(!1)}},[e.instanceId,r,n]),ne=(0,Z.useCallback)(async()=>{if(!(!t||!L)){f(!0),F(null);try{let n={};for(let e of t.setup.config??[]){let t=pn(e.type,E[e.key]??``);t!==void 0&&(n[e.key]=t)}await Ee(e.instanceId,{config:n}),await r(),S(`health`)}catch(e){F(e instanceof Error?e.message:String(e))}finally{f(!1)}}},[E,t,e.instanceId,r,L]),re=(0,Z.useCallback)(async()=>{m(!0),_(null),F(null);try{_((await Oe(e.connectorId)).recordIds.length),await r()}catch(e){F(e instanceof Error?e.message:String(e))}finally{m(!1)}},[e.connectorId,r]);return(0,Q.jsxs)(O,{open:!0,onOpenChange:e=>{e||n()},children:[(0,Q.jsxs)(D,{children:[(0,Q.jsx)(T,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,Q.jsxs)(h,{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)(k,{className:`text-base font-semibold text-fg`,children:e.displayName}),(0,Q.jsx)(de,{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)(fe,{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`,ie.focusRingPanel),"aria-label":i.modalClose,children:[(0,Q.jsx)(te,{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:[P?(0,Q.jsx)(`p`,{className:`mb-4 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:P}):null,(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:z.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`,x===e?`border-accent bg-accent-soft text-accent-fg`:`border-edge bg-surface-base text-fg-muted hover:text-fg`),onClick:()=>S(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:[x===`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:y?.ok?`font-medium text-emerald-700 dark:text-emerald-300`:`font-medium text-fg`,children:dn(y?.status??e.usage.lastHealthStatus,i)})]}),(0,Q.jsxs)(`p`,{children:[i.lastCheckLabel,` `,e.usage.lastHealthCheckAt?new Date(e.usage.lastHealthCheckAt).toLocaleString():i.never]}),y?.action?(0,Q.jsx)(`p`,{children:y.action}):null]}):null,x===`tools`?y?.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(y.tools.length)})}),(0,Q.jsx)(V,{type:`button`,variant:`ghost`,className:`h-7 text-xs`,onClick:()=>w(!0),children:a.viewAllTools})]}),(0,Q.jsx)(`div`,{className:`grid gap-2`,children:y.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:R?$(i.toolsLastCheckSummary,{count:String(R)}):i.toolsRunTestHint}),(0,Q.jsxs)(V,{type:`button`,variant:`secondary`,disabled:o,onClick:()=>void B(),children:[o?(0,Q.jsx)(K,{className:`size-4 animate-spin`}):(0,Q.jsx)(Ce,{className:`size-4`}),i.test]})]}):null,x===`resources`?y?.resources.length?(0,Q.jsx)(`div`,{className:`grid gap-2`,children:y.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,x===`prompts`?y?.prompts.length?(0,Q.jsx)(`div`,{className:`grid gap-2`,children:y.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,x===`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,x===`config`&&L?(0,Q.jsx)(`div`,{className:`grid gap-3`,children:I.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:E[e.key]??``,placeholder:e.placeholder,onChange:t=>N(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}),g===null?null:(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-emerald-600`,children:$(i.connectedSourceSynced,{count:String(g)})})]}),(0,Q.jsxs)(V,{disabled:p,onClick:()=>void re(),children:[p?(0,Q.jsx)(K,{className:`size-4 animate-spin`}):(0,Q.jsx)(v,{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)(V,{variant:`secondary`,onClick:n,children:i.modalClose}),x===`config`&&L?(0,Q.jsxs)(V,{variant:`primary`,disabled:d,onClick:()=>void ne(),children:[d?(0,Q.jsx)(K,{className:`size-4 animate-spin`}):(0,Q.jsx)(H,{className:`size-4`}),i.modalSave]}):null,e.materialized.type===`mcp`?(0,Q.jsxs)(V,{variant:`secondary`,disabled:o,onClick:()=>void B(),children:[o?(0,Q.jsx)(K,{className:`size-4 animate-spin`}):(0,Q.jsx)(Ce,{className:`size-4`}),i.test]}):null,(0,Q.jsxs)(V,{variant:`ghost`,disabled:l,onClick:()=>void ee(),children:[l?(0,Q.jsx)(K,{className:`size-4 animate-spin`}):(0,Q.jsx)(A,{className:`size-4`}),i.remove]})]})]})]}),e.materialized.type===`mcp`?(0,Q.jsx)(Qt,{open:C,onOpenChange:w,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:y?.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]),m=(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]),h=e.usage.lastHealthStatus?a.healthStatusLabels[e.usage.lastHealthStatus]??e.usage.lastHealthStatus:a.healthNotTested,g=e.usage.lastToolCount??0,_=!!(t?.setup.config?.length&&!t.setup.secrets?.length&&e.materialized.type===`mcp`),v=yn(e,t).state,y=v===`ready`?{label:a.connectionReady,Icon:Se,className:`border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`}:v===`needs_setup`?{label:a.connectionNeedsSetup,Icon:be,className:`border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300`}:{label:a.connectionChecking,Icon:I,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`,y.className),children:[(0,Q.jsx)(y.Icon,{className:`size-3`,"aria-hidden":!0}),y.label]}),_?(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,` `,h]}),(0,Q.jsx)(`span`,{className:`rounded-md bg-surface-base px-2 py-1`,children:$(a.toolsAvailable,{count:String(g)})})]}),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:[v===`needs_setup`?(0,Q.jsxs)(V,{variant:`primary`,onClick:()=>r(e),children:[(0,Q.jsx)(be,{className:`size-4`}),a.connectionResolveAction]}):null,e.materialized.type===`mcp`?(0,Q.jsxs)(V,{variant:`secondary`,disabled:o,onClick:()=>void p(),children:[o?(0,Q.jsx)(K,{className:`size-4 animate-spin`}):(0,Q.jsx)(Ce,{className:`size-4`}),a.test]}):null,(0,Q.jsxs)(V,{variant:`ghost`,disabled:l,onClick:()=>void m(),children:[l?(0,Q.jsx)(K,{className:`size-4 animate-spin`}):(0,Q.jsx)(A,{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`,W),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),[g,v]=(0,Z.useState)(``),[b,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`,E=[{id:`configure`,label:i.connectStepConfigure},{id:`health`,label:i.connectStepVerify},{id:`complete`,label:i.connectStepReady}],A=(0,Z.useCallback)(async()=>{let n=y(),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(g),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,g,u,c,a,e,o,S,t,r]);return(0,Q.jsx)(O,{open:!0,onOpenChange:e=>{e||n()},children:(0,Q.jsxs)(D,{children:[(0,Q.jsx)(T,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,Q.jsxs)(h,{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)(k,{className:`text-base font-semibold text-fg`,children:$(i.connectDialogTitle,{name:a.displayName})}),(0,Q.jsx)(de,{className:`mt-1 line-clamp-3 text-sm text-fg-muted`,children:a.description})]})]}),(0,Q.jsx)(fe,{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`,ie.focusRingPanel),"aria-label":i.modalClose,children:[(0,Q.jsx)(te,{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:E.map((e,t)=>{let n=E.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)(re,{className:`mt-3`,value:g,onChange:v,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)(re,{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)(K,{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,b?(0,Q.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:b}):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)(V,{variant:`primary`,disabled:!!e.result||e.installing||f||o&&!u&&!g.trim(),onClick:()=>void A(),children:[e.installing?(0,Q.jsx)(K,{className:`size-4 animate-spin`}):e.result?(0,Q.jsx)(Se,{className:`size-4`}):(0,Q.jsx)(_,{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`,W)}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)(V,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5 px-2 text-xs`,onClick:()=>void h(),children:[(0,Q.jsx)(b,{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)(V,{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)(A,{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`,ie.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`,W)}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)(L,{className:Fn(),value:n.transport,onChange:e=>i({transport:e.target.value}),children:Nn.map(e=>(0,Q.jsx)(x,{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)(_e,{delayDuration:300,skipDelayDuration:100,children:(0,Q.jsxs)(pe,{children:[(0,Q.jsx)(le,{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)(oe,{children:(0,Q.jsx)(U,{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),[m,g]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(null),[x,S]=(0,Z.useState)(!1),[C,w]=(0,Z.useState)({status:`idle`}),[E,A]=(0,Z.useState)(null),j=n.id.trim(),M=f.id.trim()!==j&&o.has(f.id.trim())||o.has(f.id.trim())&&t===`add`?c.reservedServerId:void 0,N=f.id.trim()&&r.some(e=>e.clientKey!==n.clientKey&&e.id.trim()===f.id.trim())?l.duplicateServerId:void 0,P=f.id.trim().length>0&&!M&&!N&&(f.transport===`stdio`?f.command.trim().length>0:f.url.trim().length>0),F=Kt(f),I=(0,Z.useCallback)(async()=>{if(f.id.trim()){v(!0),b(null),w({status:`loading`});try{w({status:`ok`,tools:(await Vt(f.id.trim(),It(f))).tools})}catch(e){w({status:`error`,message:e instanceof Error?e.message:String(e)})}finally{v(!1)}}},[f]),L=(0,Z.useCallback)(async()=>{if(!(!P||m)){g(!0),b(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){b(e instanceof Error?e.message:String(e))}finally{g(!1)}}},[P,a,r,n.clientKey,t,u,d,j,f,m,i]);return e?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(O,{open:e,onOpenChange:e=>{e||u()},children:(0,Q.jsxs)(D,{children:[(0,Q.jsx)(T,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,Q.jsxs)(h,{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)(k,{className:`text-base font-semibold text-fg`,children:t===`add`?l.addCustomServerTitle:l.editCustomServerTitle}),(0,Q.jsx)(de,{className:`mt-1 text-sm text-fg-muted`,children:t===`add`?l.addCustomServerHint:l.editCustomServerHint})]}),(0,Q.jsx)(fe,{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`,ie.focusRingPanel),"aria-label":l.modalClose,children:[(0,Q.jsx)(te,{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)(he,{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:F||(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})),b(null)},idConflictMessage:M??N})]}),C.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)(G,{className:`size-4 text-accent`,"aria-hidden":!0}),C.tools.length===0?c.toolsEmpty:c.toolsTitle.replace(`{{count}}`,String(C.tools.length))]}),C.tools.length>0?(0,Q.jsx)(V,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,onClick:()=>A(C.tools),children:c.viewAllTools}):null]}),C.tools.length>0?(0,Q.jsx)(`div`,{className:`mt-3 grid gap-2`,children:C.tools.slice(0,6).map((e,t)=>(0,Q.jsx)(Rn,{tool:e,serverId:f.id},e.name||`tool-${t}`))}):null]}):null,C.status===`error`?(0,Q.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:C.message}):null,y?(0,Q.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:y}):null,(0,Q.jsxs)(`details`,{open:x,onToggle:e=>S(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)(ge,{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})),b(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)(V,{variant:`secondary`,disabled:!f.id.trim()||_,onClick:()=>void I(),children:[_?(0,Q.jsx)(K,{className:`size-4 animate-spin`}):(0,Q.jsx)(Ce,{className:`size-4`}),c.testConnection]}),(0,Q.jsx)(fe,{asChild:!0,children:(0,Q.jsx)(V,{variant:`secondary`,children:l.modalCancel})}),(0,Q.jsxs)(V,{variant:`primary`,disabled:!P||m,onClick:()=>void L(),children:[m?(0,Q.jsx)(K,{className:`size-4 animate-spin`}):(0,Q.jsx)(Se,{className:`size-4`}),m?c.saving:l.modalSave]})]})]})]})}),E?(0,Q.jsx)(Qt,{open:!0,onOpenChange:e=>{e||A(null)},serverId:f.id,title:c.toolsDialogTitle,subtitle:c.toolsDialogSubtitle,searchPlaceholder:c.toolsDialogSearchPlaceholder,searchEmptyLabel:c.toolsDialogSearchEmpty,emptyLabel:c.toolsEmpty,closeLabel:c.toolsDialogClose,tools:E,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`),[_,v]=(0,Z.useState)(!m&&g===`connected`?`connected`:`discover`),y=(0,Z.useRef)(!1),[b,x]=(0,Z.useState)({catalog:[],registryCatalog:[],instances:[],loading:!0,error:null,peopleGraph:null}),[S,C]=(0,Z.useState)(!1),[T,D]=(0,Z.useState)(!1),[O,k]=(0,Z.useState)(1),[A,j]=(0,Z.useState)(void 0),[M,F]=(0,Z.useState)(``),[I,L]=(0,Z.useState)(``),[R,z]=(0,Z.useState)(!1),[B,ee]=(0,Z.useState)(m?f.get(`connector`)??``:``),[H,te]=(0,Z.useState)(Un(m?`understanding`:`default`)),[ne,re]=(0,Z.useState)(`name`),[U,ie]=(0,Z.useState)(m?`understand`:`all`),[ae,oe]=(0,Z.useState)(null),[se,W]=(0,Z.useState)(null),[ce,le]=(0,Z.useState)(null),[ue,de]=(0,Z.useState)(null),[fe,pe]=(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:G}=me(o),q=Ce?.payload?.config,J=(0,Z.useMemo)(()=>q===void 0?null:Ft(q),[q]),Y=J?.servers??[],Te=b.instances.length+Y.length;(0,Z.useEffect)(()=>{J&&be(J.sessionIdleTtlMinutes)},[J]);let Ee=(0,Z.useCallback)(async()=>{if(!r){x({catalog:[],registryCatalog:[],instances:[],loading:!1,error:null,peopleGraph:null});return}x(e=>({...e,loading:!0,error:null}));try{let[e,t,n]=await Promise.all([Be(),Ne(),Je(``,12).catch(()=>null)]);x(r=>({catalog:e,registryCatalog:r.registryCatalog,instances:t,loading:!1,error:null,peopleGraph:n}))}catch(e){x({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(()=>{z(!0),Je(I,50).then(t=>{e||x(e=>({...e,peopleGraph:t}))}).catch(()=>{}).finally(()=>{e||z(!1)})},250);return()=>{e=!0,window.clearTimeout(t)}},[o,I,_]),(0,Z.useEffect)(()=>{y.current||b.loading||o&&!J||(v(m?`discover`:Te>0?`connected`:`discover`),y.current=!0)},[o,Te,J,m,b.loading]);let De=(0,Z.useCallback)(e=>{y.current=!0,v(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`){x(e=>({...e,registryCatalog:[]})),k(1),j(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){C(!0),r?x(e=>({...e,error:null})):(k(1),j(void 0),x(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:ne===`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));k(n),j(o),x(e=>({...e,registryCatalog:r?Xn([...e.registryCatalog,...a]):a}))}catch(e){x(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{C(!1)}}},[ne,B,H,o,Oe]);(0,Z.useEffect)(()=>{if(_!==`discover`||b.loading)return;if(H===`builtin`){x(e=>({...e,registryCatalog:[]})),k(1),j(void 0);return}let e=window.setTimeout(()=>{ke()},B.trim()?350:0);return()=>window.clearTimeout(e)},[B,H,ke,b.loading,_]);let Ae=(0,Z.useMemo)(()=>new Set(b.instances.map(e=>e.connectorId)),[b.instances]),je=(0,Z.useMemo)(()=>new Map([...b.catalog,...b.registryCatalog].map(e=>[e.id,e])),[b.catalog,b.registryCatalog]);(0,Z.useEffect)(()=>{if(b.loading)return;let e=f.get(`connector`),t=f.get(`instance`);if(!e&&!t)return;let n=b.instances.find(n=>t?n.instanceId===t:n.connectorId===e);if(n)y.current=!0,F(``),le(n.instanceId),de(n),v(`connected`);else if(e){let t=je.get(e);if(!t)return;y.current=!0,te(Un(m?`understanding`:`default`)),ee(``),W(t),v(`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,b.instances,b.loading]);let Me=(0,Z.useCallback)(async e=>{D(!0),x(e=>({...e,error:null}));try{let t=await Ye(e);oe(On(t.definition,{packageName:t.packageName,version:t.version,permissions:t.permissions}))}catch(e){x(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{D(!1)}},[]),Pe=(0,Z.useMemo)(()=>new Set(b.instances.flatMap(e=>e.materialized.type===`mcp`?[e.materialized.serverId]:[])),[b.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 G(),await Ee()},[q,Y,Ee,J,G]),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 G(),ve(!1)}finally{Se(!1)}}},[q,Y,n.saved,J,G,ye,xe]),Re=w(e=>e.setPageHeader),ze=w(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)(()=>b.instances.map(e=>({instance:e,value:yn(e,je.get(e.connectorId))})),[je,b.instances]),Ue=(0,Z.useMemo)(()=>new Map(He.map(({instance:e,value:t})=>[e.instanceId,t])),[He]),We=(0,Z.useMemo)(()=>b.instances.filter(e=>qn(e,M)).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)}),[M,Ue,b.instances]),qe=(0,Z.useMemo)(()=>Y.filter(e=>Jn(e,M)),[M,Y]),Xe=We.length+qe.length,Ze=(0,Z.useMemo)(()=>b.catalog.filter(e=>e.source===`builtin`&&e.integrationStrategy?.preferred!==!1&&Wn(e)),[b.catalog]),Qe=(0,Z.useMemo)(()=>H===`builtin`?Ze:H===`all`?Xn([...Ze,...b.registryCatalog]):b.registryCatalog,[Ze,H,b.registryCatalog]),$e=(0,Z.useMemo)(()=>{let e=m?Qe.filter(e=>e.understanding?.mode===`activity`):Qe;return Kn(U===`all`?e:e.filter(e=>_n(e).includes(U)),B,ne)},[ne,B,Qe,m,U]),et=(0,Z.useMemo)(()=>gn.filter(e=>Qe.some(t=>_n(t).includes(e))),[Qe]);(0,Z.useEffect)(()=>{U!==`all`&&!et.includes(U)&&ie(`all`)},[et,U]);let tt=_===`discover`&&H!==`builtin`&&!!(A&&O<A),X=(0,Z.useMemo)(()=>b.instances.find(e=>e.instanceId===ce)??ue,[ce,ue,b.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)(V,{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`})}),b.error?(0,Q.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:b.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:M,onChange:F,placeholder:t.connectedSearchPlaceholder,className:`max-w-xl`}),(0,Q.jsx)(E,{className:`size-9 shrink-0 p-0`,loading:b.loading,label:t.refreshConnections,title:t.refreshConnections,onClick:Ee})]}),b.peopleGraph&&(b.peopleGraph.people.length>0||I)?(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)(N,{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(b.peopleGraph.people.length)).replace(`{{sources}}`,String(new Set(b.peopleGraph.sourceEdges.map(e=>e.sourceInstanceId)).size))})]})]}),(0,Q.jsxs)(`div`,{className:`relative w-full max-w-xs`,children:[(0,Q.jsx)(St,{value:I,onChange:L,placeholder:t.peopleGraphSearchPlaceholder}),R?(0,Q.jsx)(K,{className:`absolute right-3 top-2.5 size-4 animate-spin text-fg-subtle`,"aria-hidden":!0}):null]})]}),b.peopleGraph.people.length?(0,Q.jsx)(`div`,{className:`mt-4 grid gap-2 sm:grid-cols-2`,children:b.peopleGraph.people.slice(0,10).map(e=>{let t=[...new Set(b.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,b.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)(V,{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===fe,onOpenDetails:e=>{pe(null),le(e.instanceId),de(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`,U===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":U===e,onClick:()=>ie(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:ee,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)(P,{value:H,options:nt,placeholder:t.discoverSourceAll,allowEmpty:!1,ariaLabel:t.registrySourceAria,triggerClassName:`h-9 bg-surface-panel text-xs`,onChange:te}),(0,Q.jsx)(P,{value:ne,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=>re(e)})]})]}),(b.loading||S)&&$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:[S?(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)(K,{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,b.instances),onInstall:e=>{if(e.source===`store`){Me(e.id);return}oe(On(e))},onOpenDetails:e.source===`store`?void 0:W,t},e.id))}),tt?(0,Q.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,Q.jsxs)(V,{type:`button`,variant:`secondary`,disabled:S||T,onClick:()=>void ke({page:O+1,append:!0}),children:[S?(0,Q.jsx)(K,{className:`size-4 animate-spin`}):null,t.loadMore]})}):null]})]}):null]}),ae?(0,Q.jsx)(Dn,{draft:ae,onChange:oe,onClose:()=>oe(null),t,onInstalled:async e=>{await Ee(),await G(),pe(e.instanceId),De(`connected`)}}):null,se?(0,Q.jsx)(yt,{connector:se,installed:Ae.has(se.id)||st(se,b.instances),onClose:()=>W(null),onInstall:e=>oe(On(e)),t}):null,X?(0,Q.jsx)(hn,{instance:X,definition:je.get(X.connectorId),onClose:()=>{le(null),de(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 G(),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};
|