@xopcai/xopc 0.0.195 → 0.0.196
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-DkYgzssq.js → agent-avatar-dicebear-B1oxPli_.js} +1 -1
- package/dist/gateway/static/root/assets/agents-VoFNMGL3.js +68 -0
- package/dist/gateway/static/root/assets/{app-management-settings-panel-DVXLietl.js → app-management-settings-panel-vmuJ_Z6i.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-D7oohrYf.js → appearance-settings-BMlEoe-G.js} +1 -1
- package/dist/gateway/static/root/assets/apps-page-CsNB6mv_.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-CpBzHKzI.js → archive-plugin-BdE4Mati.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-DMWXe12h.js → attachment-load-CTzaQcLV.js} +1 -1
- package/dist/gateway/static/root/assets/automations-page-CW1YWgiX.js +6 -0
- package/dist/gateway/static/root/assets/{binary-plugins-BM0MgsHB.js → binary-plugins-B25zTNxl.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-C2MT7mG3.js → block-editor-Cdrf2awF.js} +47 -47
- package/dist/gateway/static/root/assets/browser-settings-page-BMTmGMM6.js +8 -0
- package/dist/gateway/static/root/assets/{browser-workflow-inputs-V01qhcZc.js → browser-workflow-inputs-BsmHy0ks.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-workflows-page-DPmSKVWx.js → browser-workflows-page-Wx9FrbK-.js} +2 -2
- package/dist/gateway/static/root/assets/capabilities-settings-panel-C5l85__e.js +7 -0
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-9T2KXAs1.js +3 -0
- package/dist/gateway/static/root/assets/channels-settings-DquD4BPQ.js +1 -0
- package/dist/gateway/static/root/assets/connectors-api-BC-4ftOM.js +1 -0
- package/dist/gateway/static/root/assets/connectors-page-7zUxVHQg.js +2 -0
- package/dist/gateway/static/root/assets/{cron-expression-5SqAw4UD.js → cron-expression-BycQlU8Q.js} +1 -1
- package/dist/gateway/static/root/assets/{dependency-picker-eiaYMDYI.js → dependency-picker-BvYqHRz0.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-BtfzkmnU.js → desktop-pet-BOb8sEhN.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-Dn3hnBOU.js → desktop-pet-settings-DStgPb82.js} +1 -1
- package/dist/gateway/static/root/assets/{directory-picker-path-field-Wa5zFvbb.js → directory-picker-path-field-DUUr9sq0.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-EWu0uOpw.js → extension-debug-page-p83TmZFd.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-2qZ7ngqL.js → extension-page-DMQ3ovxA.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-4MOAwYPT.js → extension-settings-page-BcSKEU8s.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-api-aqPj1HAI.js → gateway-config-api-C-MmtCc7.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-BbQBgKWH.js → gateway-settings-CuaRDWbg.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-settings-DXtG-Sy0.js → heartbeat-settings-Dm8TrfGa.js} +1 -1
- package/dist/gateway/static/root/assets/home-page-BYhDbUvI.js +3 -0
- package/dist/gateway/static/root/assets/{index-peR_-O6U.js → index-BzPwnXho.js} +30 -30
- package/dist/gateway/static/root/assets/index-CFFYvilx.css +1 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-WKmsr5WD.js → keyboard-shortcuts-settings-BQb06_jl.js} +1 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-CHk4x0kR.js +2 -0
- package/dist/gateway/static/root/assets/{local-apps-page-3-aNfJwB.js → local-apps-page-DQtsxjGs.js} +1 -1
- package/dist/gateway/static/root/assets/logs-page-CDqIY72S.js +2 -0
- package/dist/gateway/static/root/assets/{management-settings-D8vbsfLm.js → management-settings-D7itDEHl.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-split-DRFl6Vfw.js → markdown-split-Db-KrpOQ.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-C5J46ROp.js → media-plugins-CHN66qs0.js} +1 -1
- package/dist/gateway/static/root/assets/{notes-page-Z0lEBC-X.js → notes-page-CJtKZM0P.js} +1 -1
- package/dist/gateway/static/root/assets/notes-workbench-epHGeKd5.js +4 -0
- package/dist/gateway/static/root/assets/{page-tabs-Dyj6Snbu.js → page-tabs-HXweXqYE.js} +1 -1
- package/dist/gateway/static/root/assets/{preview-open-alternatives-CPDM4F7n.js → preview-open-alternatives-Dob6Oe2l.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-8RFhWmcU.js → product-open-page--RnCc9bb.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-BxOD5-zj.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-D-9AhrH5.js +1 -0
- package/dist/gateway/static/root/assets/remote-access-hub-CSUNXLKM.js +1 -0
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-BBgWkYk0.js → runtime-tools-settings-panel-Bg1W2__k.js} +2 -2
- package/dist/gateway/static/root/assets/{schema-form-BJqF0l7i.js → schema-form-BI4rVt3u.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-BxOUBMca.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-DAvTIbgw.js +1 -0
- package/dist/gateway/static/root/assets/{settings-form-section-CYL5uBzc.js → settings-form-section-C7rzhi7x.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-loading-skeleton-BabbixC0.js → settings-loading-skeleton-BS36Mjzz.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-B7OH9I8A.js → settings-page-BDSd7F9Y.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-layout-D9X3eVDo.js → settings-page-layout-CTMmZcwj.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-D1v-2Ci-.js +1 -0
- package/dist/gateway/static/root/assets/{share-preview-page-CMuJZ5Qq.js → share-preview-page-BeCxg6eb.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-CXL1EldF.js +1 -0
- package/dist/gateway/static/root/assets/{skill-reload-api-Dnpq03tO.js → skill-reload-api-BxwkKgVw.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page-C9U1pIT-.js → skills-page-CyfjEM4D.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page.utils-C3iaLgk9.js → skills-page.utils-CnbJncdL.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-CAN01aY0.js → system-settings-panel-CAv0Yk0Y.js} +1 -1
- package/dist/gateway/static/root/assets/task-detail-page-DGTVJs_N.js +1 -0
- package/dist/gateway/static/root/assets/{typed-models-lib-C9FMLeH2.js → typed-models-lib-DomX3Szl.js} +1 -1
- package/dist/gateway/static/root/assets/{use-autosave-AAZNoD6t.js → use-autosave-BLc4gfG0.js} +1 -1
- package/dist/gateway/static/root/assets/user-context-page-C2kQENTK.js +1 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-yLXEYgwV.js → voice-api-key-field-BijmpPjb.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-tbkbg-8l.js → work-discovery-overlay-D7w2JFFq.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-page-Dtqgvs_0.js → work-discovery-page-XtoPgPUS.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-BJHOxj4Z.js → workflow-run-setup-panel-BEmugHfL.js} +2 -2
- package/dist/gateway/static/root/assets/workflows-page-D_K2xOWq.js +5 -0
- package/dist/gateway/static/root/index.html +2 -2
- package/dist/package.js +1 -1
- package/dist/src/gateway/heartbeat/service.js +1 -1
- package/dist/src/gateway/hono/routes/understanding-sources.js +5 -1
- package/dist/src/heartbeat/index.js +1 -1
- package/dist/src/user-context/sources/activity-clustering.js +1 -1
- package/dist/src/user-context/sources/index.js +2 -2
- package/dist/src/user-context/sources/repository.d.ts +1 -0
- package/dist/src/user-context/sources/repository.js +4 -1
- package/dist/src/work-discovery/analyzer.js +8 -8
- package/package.json +3 -3
- package/dist/gateway/static/root/assets/agents-COX-ZLtY.js +0 -68
- package/dist/gateway/static/root/assets/apps-page-S52mdBX_.js +0 -1
- package/dist/gateway/static/root/assets/automations-page-DGGJQO9B.js +0 -6
- package/dist/gateway/static/root/assets/browser-settings-page-C_tkW-L_.js +0 -8
- package/dist/gateway/static/root/assets/capabilities-settings-panel-CPu6MIHF.js +0 -7
- package/dist/gateway/static/root/assets/capability-presets-settings-panel-ttuWLoiJ.js +0 -3
- package/dist/gateway/static/root/assets/channels-settings-DrWWVQjj.js +0 -1
- package/dist/gateway/static/root/assets/connectors-api-CG0UqhPN.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-CyfIrY2l.js +0 -2
- package/dist/gateway/static/root/assets/home-page-k21J7B1q.js +0 -3
- package/dist/gateway/static/root/assets/index-DtEVsSU1.css +0 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-r8wlEj3A.js +0 -2
- package/dist/gateway/static/root/assets/logs-page-OU3uRCoz.js +0 -2
- package/dist/gateway/static/root/assets/notes-workbench-B74ylIVP.js +0 -4
- package/dist/gateway/static/root/assets/project-detail-page-3ugVthse.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-VVAyOeRA.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-C6XqOPzA.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-BMj-t4hX.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-B7WvJXGJ.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-BHdz-BO7.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-B0F1jbhj.js +0 -1
- package/dist/gateway/static/root/assets/task-detail-page-Bs5oS-wN.js +0 -1
- package/dist/gateway/static/root/assets/user-context-page-CRY8IE-7.js +0 -1
- package/dist/gateway/static/root/assets/workflows-page-BBjCNaXn.js +0 -5
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i,l as a}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as o}from"./cn-JdwAhgNB.js";import{t as s}from"./messages-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{Bo as m,Cs as h,Es as g,Fo as _,Gc as v,Il as y,Io as b,Ir as x,Js as S,Lo as C,Lr as w,Ma as T,Na as E,Pa as D,Po as O,Qo as k,Ro as A,Rr as j,Ua as M,Yo as N,_c as P,_r as F,dt as I,gs as ee,lu as L,ns as R,pc as z,rs as B,sc as te,su as V,zi as ne,zo as re,zs as ie}from"./index-peR_-O6U.js";import{n as ae,r as oe}from"./settings-page-layout-D9X3eVDo.js";import{n as se}from"./settings-loading-skeleton-BabbixC0.js";import{t as ce}from"./schema-form-BJqF0l7i.js";import{t as le}from"./browser-BLJWD7WI.js";import{n as ue,t as de}from"./channels-status-swr-DPaJSYX_.js";var H=e(t(),1),U=n();function fe(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 pe=e(le(),1),W=r();async function me(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 G(e){return e?.type===`poll`&&e.phase===`done`}function K(e){return e&&`message`in e&&typeof e.message==`string`?e.message:null}function q(e,t){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrPayload?e.qrPayload:t===`weixin`&&e.qrcodeUrl?e.qrcodeUrl:null}function J(e){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrcodeUrl??null}function he({entry:e,locale:t,messages:n,onChanged:r,compact:i=!1}){let a=(0,H.useMemo)(()=>fe(e),[e]),s=(0,H.useMemo)(()=>({defaultBooleanLabel:n.schemaBooleanDefault,unsupportedArrayType:n.schemaUnsupportedArrayType,arrayAddPlaceholder:n.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>n.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[n]),[c,l]=(0,H.useState)({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null});(0,H.useEffect)(()=>{l({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null})},[e.id]);let u=(0,H.useCallback)(async(n,i)=>{l(e=>({...e,busy:!0,error:null}));try{let a=await me({channelId:e.id,actionId:n,locale:t,input:i});l(e=>({...e,payload:a,poll:a.type===`qr`&&a.statusAction&&a.sessionKey?{actionId:a.statusAction,sessionKey:a.sessionKey,intervalMs:Math.max(1e3,a.pollIntervalMs??2500)}:null,busy:!1,formDraft:a.type===`form`?a.values??{}:e.formDraft})),`configChanged`in a&&a.configChanged===!0&&await r()}catch(e){l(t=>({...t,busy:!1,error:e instanceof Error?e.message:String(e)}))}},[e.id,t,r]);(0,H.useEffect)(()=>{let t=q(c.payload,e.id);if(!t){l(e=>e.generatedQr?{...e,generatedQr:null}:e);return}let n=!1;return l(e=>e.generatedQr?{...e,generatedQr:null}:e),pe.toDataURL(t,{width:220,margin:1}).then(e=>{n||l(t=>({...t,generatedQr:e}))}),()=>{n=!0}},[e.id,c.payload]),(0,H.useEffect)(()=>{let n=c.poll;if(!n)return;let i=!1,a=window.setInterval(()=>{i||me({channelId:e.id,actionId:n.actionId,locale:t,input:{sessionKey:n.sessionKey}}).then(async e=>{i||(l(t=>({...t,payload:e,poll:G(e)?null:t.poll,error:null})),`configChanged`in e&&e.configChanged===!0&&await r(),G(e)&&window.clearInterval(a))}).catch(e=>{i||l(t=>({...t,error:e instanceof Error?e.message:String(e)}))})},n.intervalMs);return()=>{i=!0,window.clearInterval(a)}},[e.id,t,r,c.poll]);let d=a?.[1].label??(e.configured?n.reconnect:n.connect),f=e.actions?.[`doctor.run`]?.label??n.diagnose,p=K(c.payload),m=q(c.payload,e.id),g=m?c.generatedQr:J(c.payload),_=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,W.jsxs)(`div`,{className:i?`space-y-3`:`rounded-lg bg-surface-panel/80 p-4 shadow-surface`,children:[(0,W.jsxs)(`div`,{className:o(`flex flex-wrap items-start gap-3`,i?`justify-end`:`justify-between`),children:[i?null:(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.setupTitle}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.configured?n.setupConfiguredHint:n.setupEmptyHint})]}),(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[a?(0,W.jsxs)(h,{type:`button`,variant:`primary`,disabled:c.busy,onClick:()=>void u(a[0]),children:[c.busy?(0,W.jsx)(v,{className:`size-4 animate-spin`}):(0,W.jsx)(P,{className:`size-4`}),d]}):null,e.actions?.[`doctor.run`]?(0,W.jsxs)(h,{type:`button`,variant:`secondary`,disabled:c.busy,onClick:()=>void u(`doctor.run`),children:[(0,W.jsx)(S,{className:`size-4`}),f]}):null]})]}),p?(0,W.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:p}):null,c.error?(0,W.jsx)(`p`,{className:`mt-3 text-sm text-red-600 dark:text-red-400`,children:c.error}):null,_?(0,W.jsxs)(`div`,{className: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,W.jsx)(`div`,{className:`flex size-56 shrink-0 items-center justify-center rounded-lg border border-edge bg-white p-3`,children:g?(0,W.jsx)(`img`,{src:g,alt:`${e.label} setup QR`,className:`size-52 object-contain`}):(0,W.jsx)(`div`,{className:`flex size-52 items-center justify-center rounded-md bg-surface-base`,children:(0,W.jsx)(E,{className:`size-48 rounded-md`})})}),(0,W.jsxs)(`div`,{className:o(`min-w-0 max-w-sm text-sm text-fg-muted`,i&&`w-full sm:w-auto`),children:[g?(0,W.jsx)(`p`,{className:`line-clamp-3`,children:n.waitingConfirmation}):(0,W.jsxs)(`div`,{className:`space-y-2`,"aria-busy":`true`,children:[(0,W.jsx)(E,{className:`h-4 w-48 max-w-full`}),(0,W.jsx)(E,{className:`h-4 w-36 max-w-full`})]}),m?(0,W.jsxs)(`a`,{className:`mt-2 inline-flex items-center gap-1 text-accent hover:underline`,href:m,target:`_blank`,rel:`noreferrer`,children:[n.openSetupLink,(0,W.jsx)(y,{className:`size-3.5`})]}):null]})]}):null,c.payload?.type===`poll`&&c.payload.phase===`done`?(0,W.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 rounded-lg bg-surface-base px-3 py-2 text-sm shadow-surface`,children:[(0,W.jsx)(V,{className:c.payload.ok?`size-4 text-green-600`:`size-4 text-red-600`}),(0,W.jsx)(`span`,{className:c.payload.ok?`text-fg`:`text-red-600 dark:text-red-400`,children:c.payload.message??(c.payload.ok?n.complete:n.failed)})]}):null,b?(0,W.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,W.jsx)(ce,{schema:b.schema,values:c.formDraft,onChange:e=>l(t=>({...t,formDraft:e})),disabled:c.busy,labels:s}),(0,W.jsx)(h,{type:`button`,variant:`primary`,disabled:c.busy,onClick:()=>void u(b.submitAction,c.formDraft),children:n.saveSetup})]}):null,x?(0,W.jsx)(`div`,{className:`mt-4 space-y-2`,children:x.map((e,t)=>(0,W.jsxs)(`div`,{className:`rounded-lg bg-surface-base px-3 py-2 shadow-surface`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,W.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.label??e.id??n.diagnosticCheckFallback.replace(`{{index}}`,String(t+1))}),(0,W.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e.status??`unknown`})]}),e.message?(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.message}):null]},e.id??t))}):null]})}var ge=40;function Y(e){return`ui:route:channel:${e.trim().toLowerCase()}`}function _e(e,t){return e.find(e=>e.id===Y(t))?.agentId?.trim().toLowerCase()??``}function ve(e,t,n){let r=Y(t),i=e.filter(e=>e.id!==r),a=n.trim().toLowerCase();return a?[...i,{id:r,agentId:a,priority:ge,enabled:!0,match:{channel:t.trim().toLowerCase(),accountId:`*`}}]:i}function ye(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,n){let r=ye(e);return r.ready?r.enabled?n?t?.connected===!0?`running`:`stopped`:`checking`:`disabled`:`needs_setup`}function xe(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`,R):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)]`,R,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`)}function Se(e){let t=(0,U.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:v}=e,y=p===void 0?!1:p,x=n===`drawer`,[S,w]=(0,H.useState)(null),T;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,W.jsx)(A,{className:o(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,B)}),t[0]=T):T=t[0];let E;t[1]!==n||t[2]!==y?(E=xe(n,y),t[1]=n,t[2]=y,t[3]=E):E=t[3];let D;t[4]===c?D=t[5]:(D=c?(0,W.jsx)(m,{className:`sr-only`,children:c}):null,t[4]=c,t[5]=D);let j;t[6]===l?j=t[7]:(j=l?(0,W.jsx)(C,{className:`sr-only`,children:l}):null,t[6]=l,t[7]=j);let M;t[8]!==u||t[9]!==s||t[10]!==v||t[11]!==x||t[12]!==a?(M=x?(0,W.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[a?(0,W.jsx)(`div`,{className:`text-base font-semibold text-fg`,children:a}):null,s?(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:s}):null]}),(0,W.jsx)(_,{asChild:!0,children:(0,W.jsx)(h,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":u,children:(0,W.jsx)(g,{className:`size-5`,strokeWidth:1.75})})})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(_,{asChild:!0,children:(0,W.jsx)(`button`,{type:`button`,className:o(ee,`absolute right-3 top-3 z-20 p-1.5 hover:bg-surface-hover`),"aria-label":u,children:(0,W.jsx)(g,{className:`size-4`})})}),v]}),t[8]=u,t[9]=s,t[10]=v,t[11]=x,t[12]=a,t[13]=M):M=t[13];let N=x?`p-4`:`p-6`,P;t[14]===N?P=t[15]:(P=o(`min-h-0 flex-1 overflow-y-auto`,N),t[14]=N,t[15]=P);let F;t[16]!==d||t[17]!==P?(F=(0,W.jsx)(`div`,{className:P,children:d}),t[16]=d,t[17]=P,t[18]=F):F=t[18];let I;t[19]!==f||t[20]!==S||t[21]!==D||t[22]!==j||t[23]!==M||t[24]!==F?(I=(0,W.jsxs)(k,{layer:`modal`,portalContainer:S,children:[D,j,M,F,f]}),t[19]=f,t[20]=S,t[21]=D,t[22]=j,t[23]=M,t[24]=F,t[25]=I):I=t[25];let L;t[26]!==I||t[27]!==E?(L=(0,W.jsxs)(re,{children:[T,(0,W.jsx)(b,{ref:w,className:E,onOpenAutoFocus:Ce,children:I})]}),t[26]=I,t[27]=E,t[28]=L):L=t[28];let R;return t[29]!==i||t[30]!==r||t[31]!==L?(R=(0,W.jsx)(O,{open:r,onOpenChange:i,children:L}),t[29]=i,t[30]=r,t[31]=L,t[32]=R):R=t[32],R}function Ce(e){return e.preventDefault()}var we=(0,H.memo)(function(e){let t=(0,U.c)(10),{ch:n,refreshing:r,saveOk:i,onRefresh:a}=e,o;t[0]!==n.saved||t[1]!==i?(o=i?(0,W.jsx)(`span`,{className:`text-sm text-fg-muted`,children:n.saved}):null,t[0]=n.saved,t[1]=i,t[2]=o):o=t[2];let s;t[3]!==n.refresh||t[4]!==a||t[5]!==r?(s=(0,W.jsx)(ne,{className:`size-9 shrink-0 p-0`,loading:r,label:n.refresh,onClick:a}),t[3]=n.refresh,t[4]=a,t[5]=r,t[6]=s):s=t[6];let c;return t[7]!==o||t[8]!==s?(c=(0,W.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center justify-end gap-2`,children:[o,s]}),t[7]=o,t[8]=s,t[9]=c):c=t[9],c});function Te(e){let t=(0,U.c)(24),{ch:n,dirty:r,saving:i,onCancel:a,onDiscard:o,onSave:s,showCancel:c}=e,l=c===void 0?!0:c,u;t[0]!==n.unsavedHint||t[1]!==r?(u=r?(0,W.jsx)(`p`,{className:`mb-3 text-xs text-amber-800 dark:text-amber-200`,children:n.unsavedHint}):null,t[0]=n.unsavedHint,t[1]=r,t[2]=u):u=t[2];let d;t[3]!==n.modalCancel||t[4]!==a||t[5]!==l?(d=l?(0,W.jsx)(h,{type:`button`,variant:`secondary`,onClick:a,children:n.modalCancel}):null,t[3]=n.modalCancel,t[4]=a,t[5]=l,t[6]=d):d=t[6];let f=!r||i,p;t[7]!==n.discard||t[8]!==o||t[9]!==f?(p=(0,W.jsx)(h,{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,g;t[11]===s?g=t[12]:(g=()=>void s(),t[11]=s,t[12]=g);let _=i?n.saving:n.save,v;t[13]!==m||t[14]!==g||t[15]!==_?(v=(0,W.jsx)(h,{type:`button`,variant:`primary`,disabled:m,onClick:g,children:_}),t[13]=m,t[14]=g,t[15]=_,t[16]=v):v=t[16];let y;t[17]!==d||t[18]!==p||t[19]!==v?(y=(0,W.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[d,p,v]}),t[17]=d,t[18]=p,t[19]=v,t[20]=y):y=t[20];let b;return t[21]!==y||t[22]!==u?(b=(0,W.jsxs)(`div`,{className:`sticky bottom-0 shrink-0 border-t border-edge-subtle bg-surface-panel px-6 py-4 dark:border-edge-subtle`,children:[u,y]}),t[21]=y,t[22]=u,t[23]=b):b=t[23],b}function Ee(e){return d(`/api/channels/catalog?locale=${encodeURIComponent(e)}`)}async function De(e){return(await f(Ee(e))).payload?.channels??[]}function Oe(e,t){let n=(0,U.c)(14),r;n[0]!==e||n[1]!==t?(r=e?Ee(t):null,n[0]=e,n[1]=t,n[2]=r):r=n[2];let i;n[3]===t?i=n[4]:(i=()=>De(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 ke=`channels-status`;function Ae(e){if(!e||typeof e!=`object`)return null;let t=e.channels;return Array.isArray(t)?t:null}function je(e){let t=t=>e(t.detail);return window.addEventListener(ke,t),()=>window.removeEventListener(ke,t)}function Me(e,t){let n=(0,U.c)(4),r=t===void 0?!0:t,i,a;n[0]!==r||n[1]!==e?(i=()=>{if(r)return je(e)},a=[r,e],n[0]=r,n[1]=e,n[2]=i,n[3]=a):(i=n[2],a=n[3]),(0,H.useEffect)(i,a)}function Ne(e){return e?d(`/api/channels/${encodeURIComponent(e)}/config`):null}async function Pe(e){return(await f(d(`/api/channels/${encodeURIComponent(e)}/config`))).payload?.config??{}}var Fe=[`enabled`];async function Ie(){let e=await f(d(`/api/config`));return{channels:e.payload?.config?.channels??{},bindings:e.payload?.config?.bindings??[]}}function Le(e){return e.split(`/`).filter(Boolean).map(e=>encodeURIComponent(e)).join(`/`)}function Re(e){return e.configPath.startsWith(`channels.`)&&e.configPath.slice(9).split(`.`)[0]||e.id}function X(e){let t=e.configured===!0,n=e.enabled===!0;return e.setupStatus??{enabled:n,ready:t,state:n&&!t?`needs_setup`:n?`ready`:`disabled`,issues:[]}}function ze(e,t){return e===`running`?t.connectionRunning:e===`stopped`?t.connectionStopped:e===`checking`?t.connectionChecking:e===`disabled`?t.connectionDisabled:t.connectionNeedsSetup}function Be(e,t){return e===`running`?t.connectionRunningHint:e===`stopped`?t.connectionStoppedHint:e===`disabled`?t.connectionDisabledHint:e===`needs_setup`?t.connectionNeedsSetupHint:t.connectionChecking}function Ve(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 He(e){if(!e)return[];let t=e.uiHints??{},n=Z(e.configSchema)&&Array.isArray(e.configSchema.required)?e.configSchema.required.map(String):[],r=X(e).issues.map(e=>e.fieldPath).filter(e=>!!e),i=Object.entries(t).filter(([,e])=>!Z(e)||e.advanced===!0?!1:(Array.isArray(e.tags)?e.tags.map(String):[]).includes(`basic`)||e.advanced===!1).map(([e])=>e).filter(e=>!Fe.includes(e));return Array.from(new Set([...i,...n,...r])).filter(e=>!Fe.includes(e))}function Z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ue(e){return JSON.parse(JSON.stringify(e??{type:`object`,properties:{}}))}function We(e,t){let n={...Ue(e),properties:{}};for(let r of t){let t=r.split(`.`),i=e,a=n;for(let[e,n]of t.entries()){let r=i.properties;if(!Z(r)||!Z(r[n]))break;let o=Z(a.properties)?a.properties:{};if(a.properties=o,o[n]||(o[n]={...Ue(r[n]),properties:{}}),e===t.length-1){o[n]=Ue(r[n]);break}i=r[n],a=o[n]}}return n}function Ge(e){let t=e.properties;if(!Z(t))return!1;for(let[e,n]of Object.entries(t))Z(n)&&n.type===`object`&&Ge(n)&&delete t[e];return Object.keys(t).length===0}function Ke(e,t){let n=Ue(e);for(let e of t){let t=e.split(`.`),r=n;for(let[e,n]of t.entries()){let i=r.properties;if(!Z(i))break;if(e===t.length-1){delete i[n];break}if(!Z(i[n]))break;r=i[n]}}return Ge(n),n}function qe(e){return e.type===`object`&&Z(e.properties)&&Object.keys(e.properties).length>0}function Je(e,t){let n=e;for(let e of t.split(`.`)){if(!Z(n))return;n=n[e]}return n}function Ye(e){let t=e.accounts;return Z(t)?Object.values(t).filter(e=>Z(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=X(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=X(e),r=fe(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=fe(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,H.useState)(!1),i=(0,H.useMemo)(()=>{if(!e.ui?.icon||n)return null;let r=new URL(d(`/api/extensions/${encodeURIComponent(e.extensionId)}/assets/${Le(e.ui.icon)}`));return t?.trim()&&r.searchParams.set(`token`,t.trim()),r.toString()},[n,e.extensionId,e.ui?.icon,t]);return(0,W.jsx)(`span`,{className:`flex size-12 shrink-0 items-center justify-center rounded-2xl bg-surface-base text-fg`,children:i?(0,W.jsx)(`img`,{src:i,alt:``,draggable:!1,className:`size-7`,"aria-hidden":!0,onError:()=>r(!0)}):(0,W.jsx)(D,{sourceChannel:e.id,className:`size-7`})})}function nt(e){let t=(0,U.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,W.jsx)(`span`,{className:f}),t[7]=f,t[8]=p);let m;return t[9]!==n||t[10]!==r||t[11]!==a||t[12]!==s||t[13]!==u||t[14]!==p?(m=(0,W.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,U.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=X(n),t[0]=n,t[1]=f);let p=f,m,g,_,y,b,x,S;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,x=`flex min-h-[15.5rem] flex-col rounded-xl bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45`;let f;t[19]===n?f=t[20]:(f=(0,W.jsx)(tt,{entry:n}),t[19]=n,t[20]=f);let h;t[21]===n.label?h=t[22]:(h=(0,W.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:n.label}),t[21]=n.label,t[22]=h);let v;t[23]===i?v=t[24]:(v=o(`mt-1 inline-flex rounded-full px-2 py-0.5 text-xs font-medium`,Ve(i)),t[23]=i,t[24]=v);let C;t[25]!==c||t[26]!==i?(C=ze(i,c),t[25]=c,t[26]=i,t[27]=C):C=t[27];let w;t[28]!==v||t[29]!==C?(w=(0,W.jsx)(`span`,{className:v,children:C}),t[28]=v,t[29]=C,t[30]=w):w=t[30];let T;t[31]!==w||t[32]!==h?(T=(0,W.jsxs)(`div`,{className:`min-w-0`,children:[h,w]}),t[31]=w,t[32]=h,t[33]=T):T=t[33];let E;t[34]!==T||t[35]!==f?(E=(0,W.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[f,T]}),t[34]=T,t[35]=f,t[36]=E):E=t[36];let D=p.enabled,O;t[37]!==c.toggleChannel||t[38]!==n.label?(O=c.toggleChannel.replace(`{{channel}}`,n.label),t[37]=c.toggleChannel,t[38]=n.label,t[39]=O):O=t[39];let k;t[40]!==a||t[41]!==u||t[42]!==p.enabled||t[43]!==O?(k=(0,W.jsx)(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?(S=(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[E,k]}),t[45]=E,t[46]=k,t[47]=S):S=t[47],g=`button`,_=l,y=`mt-5 min-h-[6.25rem] text-left`,b=p.ready?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`p`,{className:`line-clamp-2 text-sm leading-6 text-fg-muted`,children:n.description??n.id}),e.length>0?(0,W.jsx)(`div`,{className:`mt-3 space-y-0.5 text-sm leading-5 text-fg-muted`,children:e.map($)}):null]}):(0,W.jsxs)(`div`,{className:`rounded-lg bg-surface-base p-3`,children:[(0,W.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:c.cardSetupTitle}),(0,W.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm leading-5 text-fg-muted`,children:e[0]??Qe(n,c)}),s.length>0?(0,W.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]=g,t[14]=_,t[15]=y,t[16]=b,t[17]=x,t[18]=S}else m=t[12],g=t[13],_=t[14],y=t[15],b=t[16],x=t[17],S=t[18];let C;t[48]!==g||t[49]!==_||t[50]!==y||t[51]!==b?(C=(0,W.jsx)(`button`,{type:g,onClick:_,className:y,children:b}),t[48]=g,t[49]=_,t[50]=y,t[51]=b,t[52]=C):C=t[52];let w=a||s,T;t[53]!==a||t[54]!==s?(T=a||s?(0,W.jsx)(v,{className:`size-4 animate-spin`}):null,t[53]=a,t[54]=s,t[55]=T):T=t[55];let E;t[56]!==c||t[57]!==n||t[58]!==s||t[59]!==i?(E=s?c.restartingChannel:i===`stopped`?c.restartChannel:Ze(n,c),t[56]=c,t[57]=n,t[58]=s,t[59]=i,t[60]=E):E=t[60];let D;t[61]!==m||t[62]!==T||t[63]!==E||t[64]!==w?(D=(0,W.jsx)(`div`,{className:`mt-auto pt-4`,children:(0,W.jsxs)(h,{type:`button`,variant:`secondary`,className:`w-full rounded-2xl py-2.5`,onClick:m,disabled:w,children:[T,E]})}),t[61]=m,t[62]=T,t[63]=E,t[64]=w,t[65]=D):D=t[65];let O;return t[66]!==D||t[67]!==x||t[68]!==S||t[69]!==C?(O=(0,W.jsxs)(`article`,{className:x,children:[S,C,D]}),t[66]=D,t[67]=x,t[68]=S,t[69]=C,t[70]=O):O=t[70],O}function it(e){return(0,W.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e},e)}function $(e){return(0,W.jsx)(`p`,{className:`truncate`,title:e,children:e},e)}function at(e){let t=(0,U.c)(51),{runtime:n,restarting:r,checking:i,showConnectionOptions:a,canManageConnection:s,ch:c,onRestart:l,onCheck:u,onManageConnection:d}=e,f=n===`running`?V:n===`stopped`||n===`needs_setup`?L:v,p=n===`running`&&`text-emerald-600 dark:text-emerald-400`,m=n===`stopped`&&`text-red-600 dark:text-red-400`,g=n===`checking`&&`animate-spin text-amber-600 dark:text-amber-400`,_=n===`disabled`&&`text-fg-muted`,y=n===`needs_setup`&&`text-amber-600 dark:text-amber-400`,b;t[0]!==p||t[1]!==m||t[2]!==g||t[3]!==_||t[4]!==y?(b=o(`mt-0.5 size-5 shrink-0`,p,m,g,_,y),t[0]=p,t[1]=m,t[2]=g,t[3]=_,t[4]=y,t[5]=b):b=t[5];let x;t[6]!==f||t[7]!==b?(x=(0,W.jsx)(f,{className:b}),t[6]=f,t[7]=b,t[8]=x):x=t[8];let S;t[9]===c.connectionStatus?S=t[10]:(S=(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:c.connectionStatus}),t[9]=c.connectionStatus,t[10]=S);let C;t[11]!==c||t[12]!==n?(C=Be(n,c),t[11]=c,t[12]=n,t[13]=C):C=t[13];let w;t[14]===C?w=t[15]:(w=(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:C}),t[14]=C,t[15]=w);let T;t[16]!==w||t[17]!==S?(T=(0,W.jsxs)(`div`,{children:[S,w]}),t[16]=w,t[17]=S,t[18]=T):T=t[18];let E;t[19]!==T||t[20]!==x?(E=(0,W.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[x,T]}),t[19]=T,t[20]=x,t[21]=E):E=t[21];let D=i||r,O;t[22]===i?O=t[23]:(O=i?(0,W.jsx)(v,{className:`size-4 animate-spin`}):null,t[22]=i,t[23]=O);let k=i?c.checkingConnection:c.checkConnection,A;t[24]!==u||t[25]!==D||t[26]!==O||t[27]!==k?(A=(0,W.jsxs)(h,{type:`button`,variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:D,onClick:u,children:[O,k]}),t[24]=u,t[25]=D,t[26]=O,t[27]=k,t[28]=A):A=t[28];let j;t[29]!==c.restartChannel||t[30]!==c.restartingChannel||t[31]!==i||t[32]!==l||t[33]!==r||t[34]!==n?(j=n===`stopped`?(0,W.jsxs)(h,{type:`button`,variant:`primary`,className:`px-2.5 py-1.5 text-xs`,disabled:r||i,onClick:l,children:[r?(0,W.jsx)(v,{className:`size-4 animate-spin`}):(0,W.jsx)(z,{className:`size-4`}),r?c.restartingChannel:c.restartChannel]}):null,t[29]=c.restartChannel,t[30]=c.restartingChannel,t[31]=i,t[32]=l,t[33]=r,t[34]=n,t[35]=j):j=t[35];let M;t[36]!==s||t[37]!==c.connectionOptions||t[38]!==c.hideConnectionOptions||t[39]!==i||t[40]!==d||t[41]!==r||t[42]!==a?(M=s?(0,W.jsx)(h,{type:`button`,variant:`ghost`,className:`px-2.5 py-1.5 text-xs`,disabled:i||r,onClick:d,children:a?c.hideConnectionOptions:c.connectionOptions}):null,t[36]=s,t[37]=c.connectionOptions,t[38]=c.hideConnectionOptions,t[39]=i,t[40]=d,t[41]=r,t[42]=a,t[43]=M):M=t[43];let N;t[44]!==A||t[45]!==j||t[46]!==M?(N=(0,W.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[A,j,M]}),t[44]=A,t[45]=j,t[46]=M,t[47]=N):N=t[47];let P;return t[48]!==E||t[49]!==N?(P=(0,W.jsx)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:(0,W.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[E,N]})}),t[48]=E,t[49]=N,t[50]=P):P=t[50],P}function ot(e){let t=(0,U.c)(33),{entry:n,ch:r}=e,i,a,o,s,c,l,u,d,f;if(t[0]!==r||t[1]!==n){f=Symbol.for(`react.early_return_sentinel`);bb0:{let e=X(n);if(e.ready||e.issues.length===0){f=null;break bb0}d=`rounded-xl border border-amber-200 bg-amber-50 px-4 py-3 text-amber-950 dark:border-amber-900/50 dark:bg-amber-950/30 dark:text-amber-100`,l=`flex items-start gap-3`,t[11]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,W.jsx)(ie,{className:`mt-0.5 size-4 shrink-0`}),t[11]=u):u=t[11],o=`min-w-0`,t[12]===r.setupReadinessTitle?s=t[13]:(s=(0,W.jsx)(`h3`,{className:`text-sm font-semibold`,children:r.setupReadinessTitle}),t[12]=r.setupReadinessTitle,t[13]=s);let p=e.enabled?r.setupReadinessEnabledBody:r.setupReadinessDisabledBody;t[14]===p?c=t[15]:(c=(0,W.jsx)(`p`,{className:`mt-1 text-sm leading-5 text-amber-900 dark:text-amber-200`,children:p}),t[14]=p,t[15]=c),i=`mt-2 list-disc space-y-1 pl-5 text-sm text-amber-900 dark:text-amber-200`;let m;t[16]===r?m=t[17]:(m=e=>(0,W.jsx)(`li`,{children: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,W.jsx)(`ul`,{className:i,children:a}),t[18]=i,t[19]=a,t[20]=p):p=t[20];let m;t[21]!==p||t[22]!==o||t[23]!==s||t[24]!==c?(m=(0,W.jsxs)(`div`,{className:o,children:[s,c,p]}),t[21]=p,t[22]=o,t[23]=s,t[24]=c,t[25]=m):m=t[25];let h;t[26]!==m||t[27]!==l||t[28]!==u?(h=(0,W.jsxs)(`div`,{className:l,children:[u,m]}),t[26]=m,t[27]=l,t[28]=u,t[29]=h):h=t[29];let g;return t[30]!==h||t[31]!==d?(g=(0,W.jsx)(`section`,{className:d,children:h}),t[30]=h,t[31]=d,t[32]=g):g=t[32],g}function st(){let e=l(e=>e.language),t=s(e),n=c(e=>!!e.token),r=a(),{channelId:f}=i(),m=j(f),h=Oe(n,e),g=h.entries,{data:_,mutate:v,isValidating:b}=p(n?de():null,ue,{revalidateOnFocus:!0}),{data:S,mutate:C}=p(n?`channels-config-map`:null,Ie,{revalidateOnFocus:!1}),E=S?.channels??{},D=S?.bindings??[],{data:O}=p(n?`channel-routing-agents`:null,T,{revalidateOnFocus:!1}),k=M(e=>e.setPageHeader),A=M(e=>e.clearPageHeader),P=(0,H.useMemo)(()=>g.find(e=>e.id===m),[m,g]),ee=P?Re(P):null,{data:L,mutate:R}=p(n&&ee?Ne(ee):null,()=>Pe(ee)),[z,B]=(0,H.useState)(null),[V,ne]=(0,H.useState)(!1),[re,ie]=(0,H.useState)(null),[le,U]=(0,H.useState)(null),[pe,me]=(0,H.useState)(!1),[G,K]=(0,H.useState)(null),[q,J]=(0,H.useState)(null),ge=z??L??{},Y=t.channelsSettings,ye=(0,H.useMemo)(()=>P?.configSchema??{type:`object`,properties:{}},[P?.configSchema]),xe=(0,H.useMemo)(()=>Ke(ye,Fe),[ye]),Ce=(0,H.useMemo)(()=>He(P),[P]),Ee=(0,H.useMemo)(()=>We(xe,Ce),[Ce,xe]),De=(0,H.useMemo)(()=>Ke(xe,Ce),[Ce,xe]),ke=(0,H.useMemo)(()=>qe(Ee),[Ee]),je=P?q??_e(D,P.id):``,Le=(0,H.useMemo)(()=>(O?.items??[]).map(e=>{let n=F(e,t.agentsSettings);return{value:e.id,label:n===e.id?n:`${n} · ${e.id}`}}),[O?.items,t.agentsSettings]),Be=O?.items.find(e=>e.id===O.defaultId),Z=Be?F(Be,t.agentsSettings):O?.defaultId??``,Ue=(0,H.useMemo)(()=>({defaultBooleanLabel:Y.schemaBooleanDefault,unsupportedArrayType:Y.schemaUnsupportedArrayType,arrayAddPlaceholder:Y.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>Y.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[Y]),Ge=(0,H.useMemo)(()=>new Map((_??[]).map(e=>[e.name,e])),[_]),Je=_!==void 0,Ye=(0,H.useCallback)(e=>be(e,Ge.get(e.id),Je),[Ge,Je]),Q=(0,H.useCallback)(async()=>{await Promise.all([h.mutate(),v()])},[h,v]);Me((0,H.useCallback)(e=>{let t=Ae(e);t&&v(t,!1)},[v]),n);let Xe=(0,H.useMemo)(()=>n?(0,W.jsx)(we,{ch:Y,refreshing:h.isValidating||b,saveOk:!1,onRefresh:()=>void Q()}):null,[h.isValidating,Y,n,b,Q]);(0,H.useLayoutEffect)(()=>(k({startExtra:null,main:(0,W.jsx)(`div`,{className:`min-w-0`,children:(0,W.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.settingsSections.channels})}),end:Xe}),()=>A()),[A,Xe,t.settingsSections.channels,k]);let Ze=(0,H.useCallback)(e=>{r(w(e)),B(null),J(null),K(null)},[r]),Qe=(0,H.useCallback)(()=>{r(x),B(null),J(null),K(null)},[r]),$e=(0,H.useCallback)(async e=>{U(e.id),K(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){K(e instanceof Error?e.message:String(e))}finally{U(null)}},[Q]);(0,H.useEffect)(()=>{J(null),me(!1)},[P?.id]);let et=(0,H.useCallback)(async()=>{if(!P||!z&&q===null)return!1;let e=Re(P);ne(!0),K(null);try{let t=await u(d(`/api/config`),{method:`PATCH`,body:JSON.stringify({...z?{channels:{[e]:z}}:{},...q===null?{}:{bindings:ve(D,P.id,q)}})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}return z&&await R(z,!1),await C(),await h.mutate(),B(null),J(null),!0}catch(e){return K(e instanceof Error?e.message:String(e)),!1}finally{ne(!1)}},[P,q,D,h,z,C,R]),it=(0,H.useCallback)(async e=>{let t=X(e),n=Re(e),r=P?.id===e.id?z:null;if(!t.enabled&&!t.ready&&!r){Ze(e.id);return}ie(e.id),K(null);try{let i=t.enabled?{enabled:!1}:r?{...r,enabled:!0}:{enabled:!0},a=await u(d(`/api/config`),{method:`PATCH`,body:JSON.stringify({channels:{[n]:i}})});if(!a.ok){let e=await a.json().catch(()=>({}));throw Error(e.error?.message??a.statusText)}await h.mutate(),await C(),await v(),P?.id===e.id&&(await R(),B(null))}catch(e){K(e instanceof Error?e.message:String(e))}finally{ie(null)}},[P?.id,h,z,C,R,v,Ze]),$=P?.ui?.modal,st=$?.placement!==`replace-config`,ct=P?Ye(P):`checking`,lt=P?!X(P).ready||pe:!1;return n?(0,W.jsxs)(oe,{gap:`gap-4`,children:[h.isLoading?(0,W.jsx)(se,{sections:2}):h.error?(0,W.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:String(h.error)}):(0,W.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:g.map(e=>(0,W.jsx)(rt,{entry:e,config:E[Re(e)]?.config,runtime:Ye(e),busy:re===e.id,restarting:le===e.id,ch:Y,onOpen:()=>Ze(e.id),onToggle:()=>void it(e),onRestart:()=>void $e(e)},e.id))}),G?(0,W.jsx)(`p`,{className:`mt-4 text-sm text-red-600 dark:text-red-400`,children:G}):null,(0,W.jsx)(Se,{presentation:`modal`,open:!!P,onOpenChange:e=>{e||Qe()},closeAriaLabel:Y.close,srTitle:P?.label??Y.selectChannel,srDescription:P?.description,wide:!0,footer:P?(0,W.jsx)(Te,{ch:Y,dirty:!!z||q!==null,saving:V,onCancel:Qe,onDiscard:()=>{B(null),J(null)},onSave:et}):null,children:P?(0,W.jsxs)(`div`,{className:`space-y-4`,children:[(0,W.jsx)(`div`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,children:(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,W.jsx)(tt,{entry:P}),(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,W.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:P.label}),(0,W.jsx)(`span`,{className:o(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,Ve(ct)),children:ze(ct,Y)})]}),(0,W.jsxs)(`div`,{className:`mt-1 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-sm text-fg-muted`,children:[(0,W.jsx)(`span`,{className:`min-w-0 truncate`,children:!X(P).ready&&fe(P)?.[1].result===`qr`?Y.scanLoginHint.replace(`{{channel}}`,P.label):P.description}),P.docsPath?(0,W.jsxs)(`a`,{href:P.docsPath,target:`_blank`,rel:`noreferrer`,className:`inline-flex shrink-0 items-center gap-1 text-accent hover:underline`,children:[Y.docs,(0,W.jsx)(y,{className:`size-3.5`})]}):null]})]})]}),(0,W.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pr-8`,children:[(0,W.jsx)(`span`,{className:`hidden text-xs text-fg-muted sm:inline`,children:X(P).enabled?Y.enabledLabel:Y.disabledLabel}),(0,W.jsx)(nt,{checked:X(P).enabled,disabled:re===P.id,label:Y.toggleChannel.replace(`{{channel}}`,P.label),onToggle:()=>void it(P)})]})]})}),(0,W.jsx)(at,{runtime:ct,restarting:le===P.id,checking:b,showConnectionOptions:pe,canManageConnection:X(P).ready&&$?.placement!==`replace-config`,ch:Y,onRestart:()=>void $e(P),onCheck:()=>void Q(),onManageConnection:()=>me(e=>!e)}),(0,W.jsx)(ot,{entry:P,ch:Y}),lt&&$?.placement!==`replace-config`?(0,W.jsx)(he,{entry:P,locale:e,messages:Y,compact:!0,onChanged:async()=>{await R(),await Q(),await C()}},P.id):null,$?.entrypoint&&$.placement===`before-config`?(0,W.jsx)(I,{extensionId:P.extensionId,extensionName:P.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:P.id,entry:P,config:ge}}):null,$?.entrypoint&&$.placement!==`before-config`?(0,W.jsx)(I,{extensionId:P.extensionId,extensionName:P.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:P.id,entry:P,config:ge}}):null,st&&ke?(0,W.jsxs)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:[(0,W.jsxs)(`div`,{className:`mb-4`,children:[(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:Y.basicConfiguration}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:Y.basicConfigurationHint})]}),(0,W.jsx)(ce,{schema:Ee,values:ge,onChange:e=>B(e),disabled:V,labels:Ue})]}):null,(0,W.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,W.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,W.jsx)(te,{className:`size-4 text-fg-muted`}),Y.messageHandling]}),(0,W.jsxs)(`div`,{className:`bg-surface-base/50 p-4`,children:[(0,W.jsxs)(`div`,{className:`mb-3`,children:[(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:Y.agentRouting}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:Y.messageHandlingHint})]}),(0,W.jsx)(N,{value:je,options:Le,placeholder:Y.agentRoutingSelect,emptyLabel:Y.agentRoutingDefault.replace(`{{agent}}`,Z||Y.agentRoutingSelect),ariaLabel:Y.agentRouting,disabled:V||!O,onChange:e=>J(e)})]})]}),st&&qe(De)?(0,W.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,W.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,W.jsx)(te,{className:`size-4 text-fg-muted`}),Y.advancedConfiguration]}),(0,W.jsx)(`div`,{className:`bg-surface-base/50 p-4`,children:(0,W.jsx)(ce,{schema:De,values:ge,onChange:e=>B(e),disabled:V,labels:Ue})})]}):null,G?(0,W.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:G}):null]}):null})]}):(0,W.jsxs)(oe,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,W.jsx)(ae,{title:t.settingsSections.channels}),(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:Y.tokenRequired})]})}export{st as ChannelsSettingsPanel};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{r as e,s as t}from"./locale-store-Bjvw7jtg.js";import{yo as n}from"./index-peR_-O6U.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};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{f as i,l as a}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as o}from"./check-DUBLcKHA.js";import{t as s}from"./cn-JdwAhgNB.js";import{n as c}from"./copy-to-clipboard-HOJ79TWv.js";import{t as l}from"./messages-DQ5X6cXp.js";import{l as u,n as d,r as f,s as p}from"./locale-store-Bjvw7jtg.js";import{$r as m,Bo as h,Bs as g,Cs as _,Ds as v,Es as y,Fo as b,Gc as x,Il as S,Io as C,Ks as w,Lo as T,Nc as E,Po as D,Qr as O,Ro as k,Sc as A,Ss as j,Ua as M,Vl as N,Vo as P,Xl as F,Xo as I,Yo as L,Ys as R,Zl as z,Zo as B,_i as V,_s as H,bi as U,bo as ee,cc as W,dc as te,ei as ne,fu as re,ic as ie,jl as ae,js as oe,lu as se,mc as ce,ms as le,ns as ue,ol as de,ri as fe,rs as pe,sc as me,su as he,ti as ge,uc as _e,vi as ve,wc as ye,xc as be,xi as xe,yi as Se,yo as Ce,zi as we,zo as G}from"./index-peR_-O6U.js";import{t as Te}from"./page-tabs-Dyj6Snbu.js";import{A as K,C as q,D as J,E as Ee,M as Y,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-CG0UqhPN.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)(E,{className:s(`text-fg-muted`,u.fallback),"aria-hidden":!0}),t[8]=u.fallback,t[9]=u.image,t[10]=c,t[11]=o,t[12]=g):g=t[12];let _;return t[13]!==p||t[14]!==m||t[15]!==h||t[16]!==g?(_=(0,Q.jsx)(`span`,{className:p,style:m,title:h,children:g}),t[13]=p,t[14]=m,t[15]=h,t[16]=g,t[17]=_):_=t[17],_}function it(e){let t=(0,X.c)(74),{connector:n,installed:r,onInstall:i,onOpenDetails:a,t:o}=e,c,l,u,d,f,p,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)(_,{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)(E,{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,D=a?`cursor-pointer`:null;t[27]===D?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`,D),t[27]=D,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 O;t[32]===n?O=t[33]:(O=(0,Q.jsx)(rt,{connector:n}),t[32]=n,t[33]=O);let k;t[34]===n.displayName?k=t[35]:(k=(0,Q.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:n.displayName}),t[34]=n.displayName,t[35]=k);let A;t[36]===S?A=t[37]:(A=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]=A);let j;t[38]!==k||t[39]!==A?(j=(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[k,A]}),t[38]=k,t[39]=A,t[40]=j):j=t[40];let M;t[41]!==O||t[42]!==j?(M=(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[O,j]}),t[41]=O,t[42]=j,t[43]=M):M=t[43];let N;t[44]!==r||t[45]!==c?(N=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]=N):N=t[46];let P;t[47]!==r||t[48]!==o.connectedBadge?(P=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)(he,{className:`size-3`,"aria-hidden":!0}),o.connectedBadge]}):null,t[47]=r,t[48]=o.connectedBadge,t[49]=P):P=t[49];let F;t[50]!==N||t[51]!==P?(F=(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-start gap-2`,children:[N,P]}),t[50]=N,t[51]=P,t[52]=F):F=t[52],t[53]!==M||t[54]!==F?(u=(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[M,F]}),t[53]=M,t[54]=F,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}))],S=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)(D,{open:!0,onOpenChange:e=>{e||n()},children:(0,Q.jsxs)(G,{children:[(0,Q.jsx)(k,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,Q.jsxs)(C,{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)(he,{className:`size-3`,"aria-hidden":!0}),i.connectedBadge]})}):null,(0,Q.jsx)(h,{className:`text-base font-semibold text-fg`,children:e.displayName}),(0,Q.jsx)(T,{className:`mt-1 line-clamp-3 text-sm leading-6 text-fg-muted`,children:e.description})]})]}),(0,Q.jsx)(b,{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`,H.focusRingPanel),"aria-label":i.modalClose,children:[(0,Q.jsx)(y,{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)(v,{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)(de,{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)(N,{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)(de,{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)(N,{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)(W,{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)(b,{asChild:!0,children:(0,Q.jsx)(_,{variant:`secondary`,children:i.modalClose})}),(0,Q.jsxs)(_,{variant:`secondary`,disabled:a,onClick:()=>void S(),children:[a?(0,Q.jsx)(x,{className:`size-4 animate-spin`}):(0,Q.jsx)(v,{className:`size-4`}),i.connectorPreviewButton]}),t?(0,Q.jsxs)(_,{variant:`secondary`,disabled:!0,children:[(0,Q.jsx)(ye,{className:`size-4`}),i.connectedBadge]}):(0,Q.jsxs)(_,{variant:`primary`,onClick:()=>{r(e),n()},children:[(0,Q.jsx)(E,{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`,j);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)(k,{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)(A,{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)(h,{className:`text-base font-semibold text-fg`,children:l.runtimeSettingsTitle}),t[5]=l.runtimeSettingsTitle,t[6]=g);let v;t[7]===l.runtimeSettingsHint?v=t[8]:(v=(0,Q.jsx)(T,{className:`mt-1 text-sm text-fg-muted`,children:l.runtimeSettingsHint}),t[7]=l.runtimeSettingsHint,t[8]=v);let S;t[9]!==g||t[10]!==v?(S=(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,v]})]}),t[9]=g,t[10]=v,t[11]=S):S=t[11];let w;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(w=s(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,H.focusRingPanel),t[12]=w):w=t[12];let E;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,Q.jsx)(y,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),t[13]=E):E=t[13];let O;t[14]===l.modalClose?O=t[15]:(O=(0,Q.jsx)(b,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,className:w,"aria-label":l.modalClose,children:E})}),t[14]=l.modalClose,t[15]=O);let j;t[16]!==O||t[17]!==S?(j=(0,Q.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[S,O]}),t[16]=O,t[17]=S,t[18]=j):j=t[18];let M;t[19]===u.idleTtlLabel?M=t[20]:(M=(0,Q.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:u.idleTtlLabel}),t[19]=u.idleTtlLabel,t[20]=M);let N;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(N=s(bt,`w-40 flex-none`),t[21]=N):N=t[21];let P=r??``,F;t[22]===a?F=t[23]:(F=e=>{let t=e.currentTarget.value.trim();a(t===``?void 0:Number.parseInt(t,10))},t[22]=a,t[23]=F);let I;t[24]!==u.idleTtlPlaceholder||t[25]!==P||t[26]!==F?(I=(0,Q.jsx)(`input`,{type:`number`,min:0,className:N,value:P,placeholder:u.idleTtlPlaceholder,onChange:F}),t[24]=u.idleTtlPlaceholder,t[25]=P,t[26]=F,t[27]=I):I=t[27];let L;t[28]===u.idleTtlHint?L=t[29]:(L=(0,Q.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:u.idleTtlHint}),t[28]=u.idleTtlHint,t[29]=L);let R;t[30]!==M||t[31]!==I||t[32]!==L?(R=(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:[M,I,L]})}),t[30]=M,t[31]=I,t[32]=L,t[33]=R):R=t[33];let z;t[34]!==c||t[35]!==i||t[36]!==l.modalCancel?(z=(0,Q.jsx)(_,{type:`button`,variant:`secondary`,disabled:i,onClick:c,children:l.modalCancel}),t[34]=c,t[35]=i,t[36]=l.modalCancel,t[37]=z):z=t[37];let B;t[38]===o?B=t[39]:(B=()=>void o(),t[38]=o,t[39]=B);let V;t[40]===i?V=t[41]:(V=i?(0,Q.jsx)(x,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,t[40]=i,t[41]=V);let U;t[42]!==u.save||t[43]!==i||t[44]!==B||t[45]!==V?(U=(0,Q.jsxs)(_,{type:`button`,variant:`primary`,disabled:i,onClick:B,children:[V,u.save]}),t[42]=u.save,t[43]=i,t[44]=B,t[45]=V,t[46]=U):U=t[46];let ee;t[47]!==z||t[48]!==U?(ee=(0,Q.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[z,U]}),t[47]=z,t[48]=U,t[49]=ee):ee=t[49];let W;t[50]!==j||t[51]!==R||t[52]!==ee?(W=(0,Q.jsxs)(G,{children:[f,(0,Q.jsxs)(C,{className:p,children:[j,R,ee]})]}),t[50]=j,t[51]=R,t[52]=ee,t[53]=W):W=t[53];let te;return t[54]!==n||t[55]!==d||t[56]!==W?(te=(0,Q.jsx)(D,{open:n,onOpenChange:d,children:W}),t[54]=n,t[55]=d,t[56]=W,t[57]=te):te=t[57],te}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)(_e,{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)(me,{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)(_,{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)(be,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[7]=p):p=t[7];let h;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,Q.jsx)(re,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[8]=h):h=t[8];let g;t[9]===a?g=t[10]:(g=(0,Q.jsx)(fe,{asChild:!0,children:(0,Q.jsxs)(_,{type:`button`,variant:`primary`,className:`shrink-0 gap-2`,children:[p,a,h]})}),t[9]=a,t[10]=g);let y;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(y=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`,H.transition),t[11]=y):y=t[11];let b;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,Q.jsx)(w,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[12]=b):b=t[12];let x;t[13]!==o||t[14]!==n?(x=(0,Q.jsxs)(m,{className:y,onSelect:n,children:[b,o]}),t[13]=o,t[14]=n,t[15]=x):x=t[15];let S;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(S=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`,H.transition),t[16]=S):S=t[16];let C;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,Q.jsx)(v,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[17]=C):C=t[17];let T;t[18]!==c||t[19]!==r?(T=(0,Q.jsxs)(m,{className:S,onSelect:r,children:[C,c]}),t[18]=c,t[19]=r,t[20]=T):T=t[20];let E;t[21]!==T||t[22]!==x?(E=(0,Q.jsx)(ne,{children:(0,Q.jsxs)(O,{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:[x,T]})}),t[21]=T,t[22]=x,t[23]=E):E=t[23];let D;t[24]!==E||t[25]!==g?(D=(0,Q.jsxs)(ge,{children:[g,E]}),t[24]=E,t[25]=g,t[26]=D):D=t[26];let k;return t[27]!==D||t[28]!==f?(k=(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center justify-end gap-2`,children:[f,D]}),t[27]=D,t[28]=f,t[29]=k):k=t[29],k}),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})}),Ce()}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)(_,{variant:`secondary`,disabled:a,onClick:()=>void m(),children:[a?(0,Q.jsx)(x,{className:`size-4 animate-spin`}):(0,Q.jsx)(ye,{className:`size-4`}),t.testConnection]}),(0,Q.jsxs)(_,{variant:`ghost`,disabled:s,onClick:()=>void h(),children:[s?(0,Q.jsx)(x,{className:`size-4 animate-spin`}):(0,Q.jsx)(g,{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)(_e,{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`,j),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)(k,{className:s(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,pe)}),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`,ue,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`),t[1]=g):g=t[1];let x;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,Q.jsx)(v,{className:`size-4 shrink-0 text-accent`,"aria-hidden":!0}),t[2]=x):x=t[2];let S;t[3]===a?S=t[4]:(S=(0,Q.jsxs)(h,{className:`flex items-center gap-2 text-base font-semibold text-fg`,children:[x,a]}),t[3]=a,t[4]=S);let w;t[5]!==i||t[6]!==o||t[7]!==f.length?(w=o.replace(`{{serverId}}`,i).replace(`{{count}}`,String(f.length)),t[5]=i,t[6]=o,t[7]=f.length,t[8]=w):w=t[8];let E;t[9]===w?E=t[10]:(E=(0,Q.jsx)(T,{className:`mt-1 text-sm text-fg-muted`,children:w}),t[9]=w,t[10]=E);let O;t[11]!==S||t[12]!==E?(O=(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[S,E]}),t[11]=S,t[12]=E,t[13]=O):O=t[13];let A;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,Q.jsx)(y,{className:`size-4`,"aria-hidden":!0}),t[14]=A):A=t[14];let j;t[15]===d?j=t[16]:(j=(0,Q.jsx)(b,{asChild:!0,children:(0,Q.jsx)(_,{type:`button`,variant:`ghost`,className:`size-8 shrink-0 px-0`,"aria-label":d,children:A})}),t[15]=d,t[16]=j);let M;t[17]!==O||t[18]!==j?(M=(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-3 border-b border-edge px-5 py-4`,children:[O,j]}),t[17]=O,t[18]=j,t[19]=M):M=t[19];let N;t[20]!==u||t[21]!==n||t[22]!==l||t[23]!==c||t[24]!==i||t[25]!==p||t[26]!==f?(N=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]=N):N=t[27];let P;t[28]===d?P=t[29]:(P=(0,Q.jsx)(`div`,{className:`flex justify-end border-t border-edge px-5 py-3`,children:(0,Q.jsx)(b,{asChild:!0,children:(0,Q.jsx)(_,{type:`button`,variant:`secondary`,children:d})})}),t[28]=d,t[29]=P);let F;t[30]!==M||t[31]!==N||t[32]!==P?(F=(0,Q.jsxs)(G,{children:[m,(0,Q.jsxs)(C,{className:g,children:[M,N,P]})]}),t[30]=M,t[31]=N,t[32]=P,t[33]=F):F=t[33];let I;return t[34]!==r||t[35]!==n||t[36]!==F?(I=(0,Q.jsx)(D,{open:n,onOpenChange:r,children:F}),t[34]=r,t[35]=n,t[36]=F,t[37]=I):I=t[37],I}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`,j);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),[v,b]=(0,Z.useState)([]),[S,C]=(0,Z.useState)(null),[w,T]=(0,Z.useState)([]),[E,D]=(0,Z.useState)({}),[O,k]=(0,Z.useState)(`read`),[A,j]=(0,Z.useState)(!1),[M,N]=(0,Z.useState)(null),F=(0,Z.useMemo)(()=>tn(i),[i]),L=(0,Z.useCallback)(async()=>{if(!(!r||e.materialized.type!==`composio`||e.materialized.role===`credential`)){j(!0),N(null);try{let[t,n,i,o,s,c,u,f]=await Promise.all([ze().catch(()=>[]),Re(r).catch(()=>[]),Me(20).catch(()=>[]),Ze(r).catch(()=>`read`),Qe().catch(()=>[]),Ue(r).catch(()=>null),Fe(r).catch(()=>null),tt().catch(()=>[])]);a(t.filter(e=>e.toolkit.toLowerCase()===r.toLowerCase())),l(n),d(i.filter(e=>!e.toolkit||e.toolkit.toLowerCase()===r.toLowerCase())),k(o),p(s.filter(t=>t.connectorId===e.connectorId)),h(c?.policy??null),b(c?.agents??[]),C(u),T(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)));D(Object.fromEntries(g.filter(e=>e!==null)))}catch(e){N(e instanceof Error?e.message:String(e))}finally{j(!1)}}},[e.connectorId,e.materialized,r]);(0,Z.useEffect)(()=>{L()},[L]);let z=(0,Z.useCallback)(async()=>{if(r){j(!0),N(null);try{let t=await J(e.connectorId);if(!t.authorizationUrl)throw Error(`The authorization provider did not return an authorization URL.`);if(P()){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 Ee(i.accountId),await n?.(),await L()}catch(e){N(e instanceof Error?e.message:String(e))}finally{j(!1)}}},[e.connectorId,L,n,r]),V=(0,Z.useCallback)(async e=>{if(r){k(e);try{await je(r,e),await L()}catch(e){N(e instanceof Error?e.message:String(e))}}},[L,r]),H=(0,Z.useCallback)(async(e,t)=>{j(!0),N(null);try{await q(e,t),await L()}catch(e){N(e instanceof Error?e.message:String(e))}finally{j(!1)}},[L]),U=(0,Z.useCallback)(async e=>{if(r){N(null);try{h(await Ve(r,e))}catch(e){N(e instanceof Error?e.message:String(e))}}},[e.connectorId,r]),ee=(0,Z.useCallback)(e=>{m&&U({allowedAgentIds:m.allowedAgentIds.includes(e)?m.allowedAgentIds.filter(t=>t!==e):[...m.allowedAgentIds,e]})},[U,m]),W=(0,Z.useCallback)(async e=>{j(!0),N(null);try{await e(),await L()}catch(e){N(e instanceof Error?e.message:String(e))}finally{j(!1)}},[L]);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)(_,{variant:`secondary`,disabled:A,onClick:()=>void z(),children:[A?(0,Q.jsx)(x,{className:`size-4 animate-spin`}):(0,Q.jsx)(de,{className:`size-4`}),t.connectOAuth]}),(0,Q.jsx)(_,{variant:`ghost`,disabled:A,onClick:()=>void L(),children:t.refresh})]})]}),M?(0,Q.jsx)(`p`,{className:`mt-3 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:M}):null,S?(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`,S.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:S.status===`connected`?$(t.composioHealthConnected,{count:String(F.filter(e=>e.primary.status===`active`).length)}):S.status===`reauthorization_required`?t.composioHealthReconnect:S.status===`degraded`?on(S,t):t.composioHealthDisconnected}),S.recovery===`none`?null:(0,Q.jsx)(_,{variant:`ghost`,disabled:A,onClick:()=>void(S.recovery===`retry`?L():z()),children:S.recovery===`retry`?t.composioRetry:t.connectOAuth}),S.status===`degraded`&&S.message?(0,Q.jsx)(`p`,{className:`basis-full break-words text-[11px] opacity-80`,children:S.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)(I,{className:s(nn,`mt-1 h-9 py-1`),value:O,onChange:e=>void V(e.currentTarget.value),children:[(0,Q.jsx)(B,{value:`read`,children:t.composioAccessReadOnly}),(0,Q.jsx)(B,{value:`write`,children:t.composioAccessReadWrite}),O===`admin`?(0,Q.jsx)(B,{value:`admin`,children:t.composioAccessAdminCurrent}):null]}),(0,Q.jsx)(`span`,{className:`mt-1 block font-normal leading-4 text-fg-muted`,children:O===`read`?t.composioAccessReadHint:O===`admin`?t.composioAccessAdminHint:t.composioAccessWriteHint})]}),(0,Q.jsxs)(`label`,{className:`text-xs font-medium text-fg-subtle`,children:[t.composioConfirmationPolicy,(0,Q.jsxs)(I,{className:s(nn,`mt-1 h-9 py-1`),value:m.confirmationPolicy,onChange:e=>void U({confirmationPolicy:e.currentTarget.value}),children:[(0,Q.jsx)(B,{value:`writes`,children:t.composioConfirmWrites}),(0,Q.jsx)(B,{value:`always`,children:t.composioConfirmAlways}),m.confirmationPolicy===`never`?(0,Q.jsx)(B,{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:v.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)(_,{variant:`secondary`,disabled:A,onClick:()=>void H(e.id,`denied`),children:[(0,Q.jsx)(y,{className:`size-4`}),t.composioDeny]}),(0,Q.jsxs)(_,{disabled:A,onClick:()=>void H(e.id,`approved`),children:[(0,Q.jsx)(o,{className:`size-4`}),t.approve]})]})]},e.id))]}):null,(0,Q.jsx)(`div`,{className:`mt-4`,children:(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioConnections}),F.length?[{title:t.composioConnectedAccounts,items:F.filter(e=>e.primary.status===`active`)},{title:t.composioNeedsAttention,items:F.filter(e=>e.primary.status!==`active`)}].filter(e=>e.items.length>0).map(e=>(0,Q.jsxs)(`section`,{className:`mb-3 space-y-2`,children:[(0,Q.jsxs)(`h4`,{className:`text-xs font-medium text-fg-muted`,children:[e.title,` · `,e.items.length]}),e.items.map(e=>{let i=e.primary,a=w.find(e=>i.accountId?e.accountId===i.accountId:e.connectionId===i.id),o=i.accountId?E[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:A,onChange:e=>void W(()=>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:A||!o.scanEnabled,onChange:e=>void W(()=>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)(I,{className:s(nn,`mt-1 h-8 py-1 text-xs`),value:String(o.intervalMinutes??30),disabled:A,onChange:e=>void W(()=>De(i.accountId,{intervalMinutes:Number(e.currentTarget.value)})),children:[(0,Q.jsxs)(B,{value:`5`,children:[`5 `,t.connectorMinutes]}),(0,Q.jsxs)(B,{value:`15`,children:[`15 `,t.connectorMinutes]}),(0,Q.jsxs)(B,{value:`30`,children:[`30 `,t.connectorMinutes]}),(0,Q.jsxs)(B,{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)(_,{variant:`ghost`,className:`size-7 shrink-0 p-0`,title:t.composioRevoke,disabled:A,onClick:()=>{window.confirm(t.composioRevokeConfirm)&&W(()=>$e(e.id))},children:(0,Q.jsx)(g,{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??``)&&W(()=>K(i.id,{alias:e.currentTarget.value}))}})]})]}),(0,Q.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-1`,children:[(0,Q.jsx)(_,{variant:`ghost`,className:`size-8 p-0`,title:t.composioMakeDefault,disabled:A||i.isDefault||i.status!==`active`,onClick:()=>void W(async()=>{await K(i.id,{isDefault:!0}),r&&await Ve(r,{selectedConnectionIds:[i.id]})}),children:(0,Q.jsx)(R,{className:s(`size-4`,i.isDefault&&`fill-current`)})}),(0,Q.jsx)(_,{variant:`ghost`,className:`size-8 p-0`,title:t.refresh,disabled:A,onClick:()=>void W(()=>et(i.id)),children:(0,Q.jsx)(ce,{className:`size-4`})}),i.status===`active`?(0,Q.jsxs)(_,{variant:`secondary`,disabled:A,onClick:()=>void W(async()=>{if(!i.accountId)throw Error(`Connector account is unavailable.`);await Ee(i.accountId),await n?.()}),children:[A?(0,Q.jsx)(x,{className:`size-4 animate-spin`}):(0,Q.jsx)(ce,{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)(I,{className:s(nn,`mt-1 h-9 py-1`),value:O,onChange:e=>void V(e.currentTarget.value),children:[(0,Q.jsx)(B,{value:`read`,children:t.composioScopeRead}),(0,Q.jsx)(B,{value:`write`,children:t.composioScopeWrite}),(0,Q.jsx)(B,{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`,j);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)(Se,{delayDuration:300,skipDelayDuration:100,children:(0,Q.jsxs)(U,{children:[(0,Q.jsx)(xe,{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)(ve,{children:(0,Q.jsx)(V,{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),[S,w]=(0,Z.useState)(null),[E,O]=(0,Z.useState)(null),[A,j]=(0,Z.useState)(e.materialized.type===`mcp`?`health`:`permissions`),[M,P]=(0,Z.useState)(!1),[F,I]=(0,Z.useState)(()=>fn(t,e)),[L,R]=(0,Z.useState)(null),z=t?.setup.config??[],B=(e.materialized.type===`mcp`||e.materialized.type===`memorySource`)&&z.length>0&&(t?.setup.secrets??[]).length===0,V=E?E.toolCount:e.usage.lastToolCount,U=(0,Z.useMemo)(()=>{let t=e.materialized.type===`mcp`?[[`health`,ie,i.detailHealth],[`tools`,v,`${i.detailTools} ${E?E.toolCount:e.usage.lastToolCount??``}`],[`resources`,N,`${i.detailResources} ${E?E.resourceCount:e.usage.lastResourceCount??``}`],[`prompts`,ae,`${i.detailPrompts} ${E?E.promptCount:e.usage.lastPromptCount??``}`],[`permissions`,de,i.detailPermissions]]:[[`permissions`,de,i.detailPermissions]];return B?[...t,[`config`,N,i.connectorConfigLabel]]:t},[E,e.materialized.type,e.usage.lastPromptCount,e.usage.lastResourceCount,e.usage.lastToolCount,B,i]),ee=(0,Z.useCallback)(async()=>{c(!0),R(null);try{let t=await He(e.instanceId);O(t),t.toolCount>0&&j(`tools`),r()}catch(e){R(e instanceof Error?e.message:String(e))}finally{c(!1)}},[e.instanceId,r]),W=(0,Z.useCallback)(async()=>{u(!0),R(null);try{await Ae(e.instanceId),await r(),n()}catch(e){R(e instanceof Error?e.message:String(e)),u(!1)}},[e.instanceId,r,n]),ne=(0,Z.useCallback)(async()=>{if(!(!t||!B)){f(!0),R(null);try{let n={};for(let e of t.setup.config??[]){let t=pn(e.type,F[e.key]??``);t!==void 0&&(n[e.key]=t)}await Y(e.instanceId,{config:n}),await r(),j(`health`)}catch(e){R(e instanceof Error?e.message:String(e))}finally{f(!1)}}},[F,t,e.instanceId,r,B]),re=(0,Z.useCallback)(async()=>{m(!0),w(null),R(null);try{w((await Oe(e.connectorId)).recordIds.length),await r()}catch(e){R(e instanceof Error?e.message:String(e))}finally{m(!1)}},[e.connectorId,r]);return(0,Q.jsxs)(D,{open:!0,onOpenChange:e=>{e||n()},children:[(0,Q.jsxs)(G,{children:[(0,Q.jsx)(k,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,Q.jsxs)(C,{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)(h,{className:`text-base font-semibold text-fg`,children:e.displayName}),(0,Q.jsx)(T,{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)(b,{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`,H.focusRingPanel),"aria-label":i.modalClose,children:[(0,Q.jsx)(y,{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:[L?(0,Q.jsx)(`p`,{className:`mb-4 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:L}):null,(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:U.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`,A===e?`border-accent bg-accent-soft text-accent-fg`:`border-edge bg-surface-base text-fg-muted hover:text-fg`),onClick:()=>j(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:[A===`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:E?.ok?`font-medium text-emerald-700 dark:text-emerald-300`:`font-medium text-fg`,children:dn(E?.status??e.usage.lastHealthStatus,i)})]}),(0,Q.jsxs)(`p`,{children:[i.lastCheckLabel,` `,e.usage.lastHealthCheckAt?new Date(e.usage.lastHealthCheckAt).toLocaleString():i.never]}),E?.action?(0,Q.jsx)(`p`,{children:E.action}):null]}):null,A===`tools`?E?.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(E.tools.length)})}),(0,Q.jsx)(_,{type:`button`,variant:`ghost`,className:`h-7 text-xs`,onClick:()=>P(!0),children:a.viewAllTools})]}),(0,Q.jsx)(`div`,{className:`grid gap-2`,children:E.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:V?$(i.toolsLastCheckSummary,{count:String(V)}):i.toolsRunTestHint}),(0,Q.jsxs)(_,{type:`button`,variant:`secondary`,disabled:o,onClick:()=>void ee(),children:[o?(0,Q.jsx)(x,{className:`size-4 animate-spin`}):(0,Q.jsx)(ye,{className:`size-4`}),i.test]})]}):null,A===`resources`?E?.resources.length?(0,Q.jsx)(`div`,{className:`grid gap-2`,children:E.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,A===`prompts`?E?.prompts.length?(0,Q.jsx)(`div`,{className:`grid gap-2`,children:E.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,A===`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,A===`config`&&B?(0,Q.jsx)(`div`,{className:`grid gap-3`,children:z.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:F[e.key]??``,placeholder:e.placeholder,onChange:t=>I(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}),S===null?null:(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-emerald-600`,children:$(i.connectedSourceSynced,{count:String(S)})})]}),(0,Q.jsxs)(_,{disabled:p,onClick:()=>void re(),children:[p?(0,Q.jsx)(x,{className:`size-4 animate-spin`}):(0,Q.jsx)(N,{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)(_,{variant:`secondary`,onClick:n,children:i.modalClose}),A===`config`&&B?(0,Q.jsxs)(_,{variant:`primary`,disabled:d,onClick:()=>void ne(),children:[d?(0,Q.jsx)(x,{className:`size-4 animate-spin`}):(0,Q.jsx)(te,{className:`size-4`}),i.modalSave]}):null,e.materialized.type===`mcp`?(0,Q.jsxs)(_,{variant:`secondary`,disabled:o,onClick:()=>void ee(),children:[o?(0,Q.jsx)(x,{className:`size-4 animate-spin`}):(0,Q.jsx)(ye,{className:`size-4`}),i.test]}):null,(0,Q.jsxs)(_,{variant:`ghost`,disabled:l,onClick:()=>void W(),children:[l?(0,Q.jsx)(x,{className:`size-4 animate-spin`}):(0,Q.jsx)(g,{className:`size-4`}),i.remove]})]})]})]}),e.materialized.type===`mcp`?(0,Q.jsx)(Qt,{open:M,onOpenChange:P,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:E?.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,v=e.usage.lastToolCount??0,y=!!(t?.setup.config?.length&&!t.setup.secrets?.length&&e.materialized.type===`mcp`),b=yn(e,t).state,S=b===`ready`?{label:a.connectionReady,Icon:he,className:`border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`}:b===`needs_setup`?{label:a.connectionNeedsSetup,Icon:se,className:`border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300`}:{label:a.connectionChecking,Icon:F,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`,S.className),children:[(0,Q.jsx)(S.Icon,{className:`size-3`,"aria-hidden":!0}),S.label]}),y?(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(v)})})]}),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:[b===`needs_setup`?(0,Q.jsxs)(_,{variant:`primary`,onClick:()=>r(e),children:[(0,Q.jsx)(se,{className:`size-4`}),a.connectionResolveAction]}):null,e.materialized.type===`mcp`?(0,Q.jsxs)(_,{variant:`secondary`,disabled:o,onClick:()=>void p(),children:[o?(0,Q.jsx)(x,{className:`size-4 animate-spin`}):(0,Q.jsx)(ye,{className:`size-4`}),a.test]}):null,(0,Q.jsxs)(_,{variant:`ghost`,disabled:l,onClick:()=>void m(),children:[l?(0,Q.jsx)(x,{className:`size-4 animate-spin`}):(0,Q.jsx)(g,{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`,j),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),[m,g]=(0,Z.useState)(``),[v,w]=(0,Z.useState)(null),[O,A]=(0,Z.useState)(l);(0,Z.useEffect)(()=>{if(!o)return;let e=!1;return Ie().then(({configured:t})=>{e||d(t)}).catch(t=>{e||w(t instanceof Error?t.message:String(t))}).finally(()=>{e||p(!1)}),()=>{e=!0}},[a.id,o]);let j=e.result?`complete`:e.installing?`health`:`configure`,M=[{id:`configure`,label:i.connectStepConfigure},{id:`health`,label:i.connectStepVerify},{id:`complete`,label:i.connectStepReady}],N=(0,Z.useCallback)(async()=>{let n=P(),i=o&&!n?window.open(``,`_blank`):null;i&&(i.opener=null),w(null),t({...e,installing:!0,error:null,result:null,health:null});try{o&&!u&&(await Xe(m),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&&O){if(!e.accountId)throw Error(`Connector account is unavailable.`);await Ee(e.accountId)}}else{let e=await J(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&&O){if(!t.accountId)throw Error(`Connector account is unavailable.`);await Ee(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,m,u,c,a,e,o,O,t,r]);return(0,Q.jsx)(D,{open:!0,onOpenChange:e=>{e||n()},children:(0,Q.jsxs)(G,{children:[(0,Q.jsx)(k,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,Q.jsxs)(C,{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)(h,{className:`text-base font-semibold text-fg`,children:$(i.connectDialogTitle,{name:a.displayName})}),(0,Q.jsx)(T,{className:`mt-1 line-clamp-3 text-sm text-fg-muted`,children:a.description})]})]}),(0,Q.jsx)(b,{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`,H.focusRingPanel),"aria-label":i.modalClose,children:[(0,Q.jsx)(y,{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:M.map((e,t)=>{let n=M.findIndex(e=>e.id===j);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)(S,{className:`size-3.5`,"aria-hidden":!0})]}),(0,Q.jsx)(le,{className:`mt-3`,value:m,onChange:g,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:O,onChange:e=>A(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)(le,{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)(x,{className:`size-4 animate-spin text-accent`,"aria-hidden":!0}),i.connectingTitle]}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:i.connectingHint})]}):null,e.error?(0,Q.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:e.error}):null,v?(0,Q.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:v}):null,e.result?(0,Q.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-base p-4 text-sm text-fg-muted`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,Q.jsx)(`div`,{children:(0,Q.jsx)(`p`,{className:`font-medium text-fg`,children:i.connectedBadge})}),(0,Q.jsx)(`span`,{className:s(`rounded-full px-2 py-0.5 text-xs font-medium`,e.health?.ok?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e.health?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:`bg-surface-hover text-fg-muted`),children:e.health?.ok?i.healthStatusHealthy:Cn(e.health?.status,i)})]}),e.health?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{className:`mt-3 grid gap-2 text-xs sm:grid-cols-3`,children:[(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2`,children:[(0,Q.jsx)(`div`,{className:`font-semibold text-fg`,children:e.health.toolCount}),(0,Q.jsx)(`div`,{children:i.toolsMetric})]}),(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2`,children:[(0,Q.jsx)(`div`,{className:`font-semibold text-fg`,children:e.health.resourceCount}),(0,Q.jsx)(`div`,{children:i.resourcesMetric})]}),(0,Q.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2`,children:[(0,Q.jsx)(`div`,{className:`font-semibold text-fg`,children:e.health.promptCount}),(0,Q.jsx)(`div`,{children:i.promptsMetric})]})]}),(0,Q.jsxs)(`div`,{className:`mt-3 grid gap-2`,children:[(0,Q.jsx)(Tn,{title:i.detailTools,items:e.health.tools.map(e=>({id:e.name,title:e.shortName??e.name,description:e.description}))}),(0,Q.jsx)(Tn,{title:i.detailResources,items:e.health.resources.map(e=>({id:e.uri,title:e.title??e.name??e.uri,description:e.description??e.uri}))}),(0,Q.jsx)(Tn,{title:i.detailPrompts,items:e.health.prompts.map(e=>({id:e.name,title:e.title??e.name,description:e.description??$(i.promptArgumentCount,{count:String(e.argumentCount)})}))})]})]}):(0,Q.jsx)(`p`,{className:`mt-3`,children:i.installedWithoutHealth}),e.health?.action?(0,Q.jsx)(`p`,{className:`mt-3 text-xs text-fg-subtle`,children:e.health.action}):null]}):null]})]}),(0,Q.jsx)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:(0,Q.jsxs)(_,{variant:`primary`,disabled:!!e.result||e.installing||f||o&&!u&&!m.trim(),onClick:()=>void N(),children:[e.installing?(0,Q.jsx)(x,{className:`size-4 animate-spin`}):e.result?(0,Q.jsx)(he,{className:`size-4`}):(0,Q.jsx)(E,{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`,j)}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)(_,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5 px-2 text-xs`,onClick:()=>void h(),children:[(0,Q.jsx)(z,{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)(_,{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)(g,{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`,H.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`,j)}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)(I,{className:Fn(),value:n.transport,onChange:e=>i({transport:e.target.value}),children:Nn.map(e=>(0,Q.jsx)(B,{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)(Se,{delayDuration:300,skipDelayDuration:100,children:(0,Q.jsxs)(U,{children:[(0,Q.jsx)(xe,{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)(ve,{children:(0,Q.jsx)(V,{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),[S,w]=(0,Z.useState)(!1),[E,O]=(0,Z.useState)(null),[A,j]=(0,Z.useState)(!1),[M,N]=(0,Z.useState)({status:`idle`}),[P,F]=(0,Z.useState)(null),I=n.id.trim(),L=f.id.trim()!==I&&o.has(f.id.trim())||o.has(f.id.trim())&&t===`add`?c.reservedServerId:void 0,R=f.id.trim()&&r.some(e=>e.clientKey!==n.clientKey&&e.id.trim()===f.id.trim())?l.duplicateServerId:void 0,z=f.id.trim().length>0&&!L&&!R&&(f.transport===`stdio`?f.command.trim().length>0:f.url.trim().length>0),B=Kt(f),V=(0,Z.useCallback)(async()=>{if(f.id.trim()){w(!0),O(null),N({status:`loading`});try{N({status:`ok`,tools:(await Vt(f.id.trim(),It(f))).tools})}catch(e){N({status:`error`,message:e instanceof Error?e.message:String(e)})}finally{w(!1)}}},[f]),U=(0,Z.useCallback)(async()=>{if(!(!z||m)){g(!0),O(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){O(e instanceof Error?e.message:String(e))}finally{g(!1)}}},[z,a,r,n.clientKey,t,u,d,I,f,m,i]);return e?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(D,{open:e,onOpenChange:e=>{e||u()},children:(0,Q.jsxs)(G,{children:[(0,Q.jsx)(k,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,Q.jsxs)(C,{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)(h,{className:`text-base font-semibold text-fg`,children:t===`add`?l.addCustomServerTitle:l.editCustomServerTitle}),(0,Q.jsx)(T,{className:`mt-1 text-sm text-fg-muted`,children:t===`add`?l.addCustomServerHint:l.editCustomServerHint})]}),(0,Q.jsx)(b,{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`,H.focusRingPanel),"aria-label":l.modalClose,children:[(0,Q.jsx)(y,{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)(W,{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:B||(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})),O(null)},idConflictMessage:L??R})]}),M.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)(v,{className:`size-4 text-accent`,"aria-hidden":!0}),M.tools.length===0?c.toolsEmpty:c.toolsTitle.replace(`{{count}}`,String(M.tools.length))]}),M.tools.length>0?(0,Q.jsx)(_,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,onClick:()=>F(M.tools),children:c.viewAllTools}):null]}),M.tools.length>0?(0,Q.jsx)(`div`,{className:`mt-3 grid gap-2`,children:M.tools.slice(0,6).map((e,t)=>(0,Q.jsx)(Rn,{tool:e,serverId:f.id},e.name||`tool-${t}`))}):null]}):null,M.status===`error`?(0,Q.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:M.message}):null,E?(0,Q.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:E}):null,(0,Q.jsxs)(`details`,{open:A,onToggle:e=>j(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)(re,{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})),O(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)(_,{variant:`secondary`,disabled:!f.id.trim()||S,onClick:()=>void V(),children:[S?(0,Q.jsx)(x,{className:`size-4 animate-spin`}):(0,Q.jsx)(ye,{className:`size-4`}),c.testConnection]}),(0,Q.jsx)(b,{asChild:!0,children:(0,Q.jsx)(_,{variant:`secondary`,children:l.modalCancel})}),(0,Q.jsxs)(_,{variant:`primary`,disabled:!z||m,onClick:()=>void U(),children:[m?(0,Q.jsx)(x,{className:`size-4 animate-spin`}):(0,Q.jsx)(he,{className:`size-4`}),m?c.saving:l.modalSave]})]})]})]})}),P?(0,Q.jsx)(Qt,{open:!0,onOpenChange:e=>{e||F(null)},serverId:f.id,title:c.toolsDialogTitle,subtitle:c.toolsDialogSubtitle,searchPlaceholder:c.toolsDialogSearchPlaceholder,searchEmptyLabel:c.toolsDialogSearchEmpty,emptyLabel:c.toolsEmpty,closeLabel:c.toolsDialogClose,tools:P,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,y]=(0,Z.useState)(!m&&g===`connected`?`connected`:`discover`),b=(0,Z.useRef)(!1),[S,C]=(0,Z.useState)({catalog:[],registryCatalog:[],instances:[],loading:!0,error:null,peopleGraph:null}),[w,T]=(0,Z.useState)(!1),[E,D]=(0,Z.useState)(!1),[O,k]=(0,Z.useState)(1),[A,j]=(0,Z.useState)(void 0),[N,P]=(0,Z.useState)(``),[F,I]=(0,Z.useState)(``),[R,z]=(0,Z.useState)(!1),[B,V]=(0,Z.useState)(m?f.get(`connector`)??``:``),[H,U]=(0,Z.useState)(Un(m?`understanding`:`default`)),[W,te]=(0,Z.useState)(`name`),[ne,re]=(0,Z.useState)(m?`understand`:`all`),[ie,ae]=(0,Z.useState)(null),[se,ce]=(0,Z.useState)(null),[le,ue]=(0,Z.useState)(null),[de,fe]=(0,Z.useState)(null),[pe,me]=(0,Z.useState)(null),[he,ge]=(0,Z.useState)(null),[_e,ve]=(0,Z.useState)(!1),[ye,be]=(0,Z.useState)(void 0),[xe,Se]=(0,Z.useState)(!1),{data:Ce,mutate:G}=ee(o),K=Ce?.payload?.config,q=(0,Z.useMemo)(()=>K===void 0?null:Ft(K),[K]),J=q?.servers??[],Ee=S.instances.length+J.length;(0,Z.useEffect)(()=>{q&&be(q.sessionIdleTtlMinutes)},[q]);let Y=(0,Z.useCallback)(async()=>{if(!r){C({catalog:[],registryCatalog:[],instances:[],loading:!1,error:null,peopleGraph:null});return}C(e=>({...e,loading:!0,error:null}));try{let[e,t,n]=await Promise.all([Be(),Ne(),Je(``,12).catch(()=>null)]);C(r=>({catalog:e,registryCatalog:r.registryCatalog,instances:t,loading:!1,error:null,peopleGraph:n}))}catch(e){C({catalog:[],registryCatalog:[],instances:[],loading:!1,error:e instanceof Error?e.message:String(e),peopleGraph:null})}},[r]);(0,Z.useEffect)(()=>{Y()},[Y]),(0,Z.useEffect)(()=>{if(!o||v!==`connected`)return;let e=!1,t=window.setTimeout(()=>{z(!0),Je(F,50).then(t=>{e||C(e=>({...e,peopleGraph:t}))}).catch(()=>{}).finally(()=>{e||z(!1)})},250);return()=>{e=!0,window.clearTimeout(t)}},[o,F,v]),(0,Z.useEffect)(()=>{b.current||S.loading||o&&!q||(y(m?`discover`:Ee>0?`connected`:`discover`),b.current=!0)},[o,Ee,q,m,S.loading]);let De=(0,Z.useCallback)(e=>{b.current=!0,y(e)},[]),Oe=(0,Z.useMemo)(()=>[{id:Vn,displayName:t.composioSourceName},{id:Hn,displayName:t.storeSourceName}],[t.composioSourceName,t.storeSourceName]),ke=(0,Z.useCallback)(async e=>{if(!o||H===`builtin`){C(e=>({...e,registryCatalog:[]})),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){T(!0),r?C(e=>({...e,error:null})):(k(1),j(void 0),C(e=>({...e,registryCatalog:[],error:null})));try{let e=await Promise.all(i.map(async e=>{if(e.id===`composio`){let e=await Ge({q:t||void 0,page:n,pageSize:24,verification:`experimental`});return{connectors:e.connectors,totalPages:e.meta.totalPages}}let r=await Ke({q:t||void 0,page:n,pageSize:24,sort:W===`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),C(e=>({...e,registryCatalog:r?Xn([...e.registryCatalog,...a]):a}))}catch(e){C(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{T(!1)}}},[W,B,H,o,Oe]);(0,Z.useEffect)(()=>{if(v!==`discover`||S.loading)return;if(H===`builtin`){C(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,S.loading,v]);let Ae=(0,Z.useMemo)(()=>new Set(S.instances.map(e=>e.connectorId)),[S.instances]),je=(0,Z.useMemo)(()=>new Map([...S.catalog,...S.registryCatalog].map(e=>[e.id,e])),[S.catalog,S.registryCatalog]);(0,Z.useEffect)(()=>{if(S.loading)return;let e=f.get(`connector`),t=f.get(`instance`);if(!e&&!t)return;let n=S.instances.find(n=>t?n.instanceId===t:n.connectorId===e);if(n)b.current=!0,P(``),ue(n.instanceId),fe(n),y(`connected`);else if(e){let t=je.get(e);if(!t)return;b.current=!0,U(Un(m?`understanding`:`default`)),V(``),ce(t),y(`discover`)}let r=new URLSearchParams(f);r.delete(`connector`),r.delete(`instance`),r.set(`tab`,n?`connected`:`discover`),p(r,{replace:!0})},[je,m,f,p,S.instances,S.loading]);let Me=(0,Z.useCallback)(async e=>{D(!0),C(e=>({...e,error:null}));try{let t=await Ye(e);ae(On(t.definition,{packageName:t.packageName,version:t.version,permissions:t.permissions}))}catch(e){C(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{D(!1)}},[]),Pe=(0,Z.useMemo)(()=>new Set(S.instances.flatMap(e=>e.materialized.type===`mcp`?[e.materialized.serverId]:[])),[S.instances]),Fe=(0,Z.useCallback)(async e=>{if(!q||K===void 0)return;let t=J.filter(t=>t.clientKey!==e.clientKey);await Lt({sessionIdleTtlMinutes:q.sessionIdleTtlMinutes,servers:t},kt(K)),await G(),await Y()},[K,J,Y,q,G]),Ie=(0,Z.useCallback)(()=>{ge({mode:`add`,row:kn(J,Pe)})},[J,Pe]),Le=(0,Z.useCallback)(async()=>{if(!(!q||K===void 0||xe)){Se(!0);try{await Lt({sessionIdleTtlMinutes:ye,servers:J},kt(K)),await G(),ve(!1)}finally{Se(!1)}}},[K,J,n.saved,q,G,ye,xe]),Re=M(e=>e.setPageHeader),ze=M(e=>e.clearPageHeader),Ve=(0,Z.useMemo)(()=>(0,Q.jsx)(Ct,{onBrowseCatalog:()=>De(`discover`),onAddCustomServer:Ie,onOpenRuntimeSettings:()=>ve(!0),addLabel:t.addConnection,browseLabel:t.addFromCatalog,customLabel:t.addCustomServerAdvanced,settingsLabel:t.runtimeSettings}),[t,Ie,De]);(0,Z.useLayoutEffect)(()=>(Re({startExtra:null,main:(0,Q.jsx)(`div`,{className:`min-w-0`,children:(0,Q.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.title})}),end:Ve}),()=>ze()),[ze,t.title,Ve,Re]);let He=(0,Z.useMemo)(()=>S.instances.map(e=>({instance:e,value:yn(e,je.get(e.connectorId))})),[je,S.instances]),Ue=(0,Z.useMemo)(()=>new Map(He.map(({instance:e,value:t})=>[e.instanceId,t])),[He]),We=(0,Z.useMemo)(()=>S.instances.filter(e=>qn(e,N)).sort((e,t)=>{let n={needs_setup:0,checking:1,ready:2},r=Ue.get(e.instanceId)?.state??`checking`,i=Ue.get(t.instanceId)?.state??`checking`;return n[r]-n[i]||e.displayName.localeCompare(t.displayName)}),[N,Ue,S.instances]),qe=(0,Z.useMemo)(()=>J.filter(e=>Jn(e,N)),[N,J]),Xe=We.length+qe.length,Ze=(0,Z.useMemo)(()=>S.catalog.filter(e=>e.source===`builtin`&&e.integrationStrategy?.preferred!==!1&&Wn(e)),[S.catalog]),Qe=(0,Z.useMemo)(()=>H===`builtin`?Ze:H===`all`?Xn([...Ze,...S.registryCatalog]):S.registryCatalog,[Ze,H,S.registryCatalog]),$e=(0,Z.useMemo)(()=>{let e=m?Qe.filter(e=>e.understanding?.mode===`activity`):Qe;return Kn(ne===`all`?e:e.filter(e=>_n(e).includes(ne)),B,W)},[W,B,Qe,m,ne]),et=(0,Z.useMemo)(()=>gn.filter(e=>Qe.some(t=>_n(t).includes(e))),[Qe]);(0,Z.useEffect)(()=>{ne!==`all`&&!et.includes(ne)&&re(`all`)},[et,ne]);let tt=v===`discover`&&H!==`builtin`&&!!(A&&O<A),X=(0,Z.useMemo)(()=>S.instances.find(e=>e.instanceId===le)??de,[le,de,S.instances]),nt=(0,Z.useMemo)(()=>[{value:`all`,label:t.discoverSourceAll},{value:Bn,label:t.discoverSourceBuiltin},...Oe.map(e=>({value:e.id,label:e.displayName}))],[t.discoverSourceAll,t.discoverSourceBuiltin,Oe]),rt=[{id:`connected`,label:t.tabConnected,count:Ee},{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)(_,{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)(Te,{items:rt,activeTab:v,onChange:De,ariaLabel:t.navAria,tabIdPrefix:`connectors-tab`,panelIdPrefix:`connectors-panel`,className:`flex-wrap`})}),S.error?(0,Q.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:S.error}):null,v===`connected`&&o?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center`,children:[(0,Q.jsx)(St,{value:N,onChange:P,placeholder:t.connectedSearchPlaceholder,className:`max-w-xl`}),(0,Q.jsx)(we,{className:`size-9 shrink-0 p-0`,loading:S.loading,label:t.refreshConnections,title:t.refreshConnections,onClick:Y})]}),S.peopleGraph&&(S.peopleGraph.people.length>0||F)?(0,Q.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsx)(`div`,{className:`rounded-lg bg-accent-soft p-2 text-accent-fg`,children:(0,Q.jsx)(oe,{className:`size-4`,"aria-hidden":!0})}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.peopleGraphTitle}),(0,Q.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.peopleGraphHint.replace(`{{people}}`,String(S.peopleGraph.people.length)).replace(`{{sources}}`,String(new Set(S.peopleGraph.sourceEdges.map(e=>e.sourceInstanceId)).size))})]})]}),(0,Q.jsxs)(`div`,{className:`relative w-full max-w-xs`,children:[(0,Q.jsx)(St,{value:F,onChange:I,placeholder:t.peopleGraphSearchPlaceholder}),R?(0,Q.jsx)(x,{className:`absolute right-3 top-2.5 size-4 animate-spin text-fg-subtle`,"aria-hidden":!0}):null]})]}),S.peopleGraph.people.length?(0,Q.jsx)(`div`,{className:`mt-4 grid gap-2 sm:grid-cols-2`,children:S.peopleGraph.people.slice(0,10).map(e=>{let t=[...new Set(S.peopleGraph.sourceEdges.filter(t=>t.personId===e.id).map(e=>e.toolkit??e.connectorId??e.sourceInstanceId))];return(0,Q.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-panel px-3 py-2.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,Q.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:e.label}),(0,Q.jsx)(`span`,{className:`shrink-0 text-xs text-fg-subtle`,children:e.mentionCount})]}),(0,Q.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted`,children:e.emails[0]??e.usernames[0]??e.roles.join(` · `)}),(0,Q.jsx)(`p`,{className:`mt-1 truncate text-[11px] text-fg-subtle`,children:t.join(` · `)})]},e.id)})}):(0,Q.jsx)(`p`,{className:`mt-4 text-sm text-fg-muted`,children:t.peopleGraphSearchEmpty})]}):null,S.loading?(0,Q.jsx)(`div`,{className:`grid gap-3`,"aria-busy":`true`,"aria-label":t.loading,children:ot.slice(0,3).map(e=>(0,Q.jsx)(dt,{},e))}):Ee===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)(_,{type:`button`,variant:`primary`,className:`mt-4`,onClick:()=>De(`discover`),children:t.addFromCatalog})]}):Xe===0?(0,Q.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center text-sm text-fg-muted`,children:t.connectionsSearchEmpty}):(0,Q.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:[We.map(e=>(0,Q.jsx)(bn,{instance:e,definition:je.get(e.connectorId),highlighted:e.instanceId===pe,onOpenDetails:e=>{me(null),ue(e.instanceId),fe(e)},onChanged:Y,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,v===`discover`&&o?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[m?null:(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-2`,role:`group`,"aria-label":t.taskFilterAria,children:[`all`,...et].map(e=>(0,Q.jsx)(`button`,{type:`button`,className:s(`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors`,ne===e?`border-accent/40 bg-accent-soft text-accent-fg`:`border-edge bg-surface-panel text-fg-muted hover:bg-surface-hover hover:text-fg`),"aria-pressed":ne===e,onClick:()=>re(e),children:e===`all`?t.taskAll:t.connectorBenefitHeadings[e]},e))}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 lg:flex-row lg:items-center`,children:[(0,Q.jsx)(St,{value:B,onChange:V,placeholder:t.discoverSearchPlaceholder,className:`max-w-xl`}),(0,Q.jsxs)(`div`,{className:s(`grid min-w-0 grid-cols-1 gap-2 lg:ml-auto`,m?`lg:w-52`:`sm:grid-cols-2 lg:w-[26rem]`),children:[m?null:(0,Q.jsx)(L,{value:H,options:nt,placeholder:t.discoverSourceAll,allowEmpty:!1,ariaLabel:t.registrySourceAria,triggerClassName:`h-9 bg-surface-panel text-xs`,onChange:U}),(0,Q.jsx)(L,{value:W,options:[{value:`name`,label:t.sortName},{value:`source`,label:t.sortSource}],placeholder:t.sortName,allowEmpty:!1,ariaLabel:t.sortAria,triggerClassName:`h-9 bg-surface-panel text-xs`,onChange:e=>te(e)})]})]}),(S.loading||w)&&$e.length===0?(0,Q.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,"aria-busy":`true`,"aria-label":t.loading,children:ot.map(e=>(0,Q.jsx)(lt,{},e))}):$e.length===0?(0,Q.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center text-sm text-fg-muted`,children:t.discoverEmpty}):(0,Q.jsxs)(`div`,{className:`relative`,children:[w?(0,Q.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-[1] flex justify-center bg-surface-panel/40 pt-[min(28vh,7.5rem)] backdrop-blur-[1px] motion-reduce:backdrop-blur-none dark:bg-surface-base/35`,"aria-busy":`true`,"aria-label":t.loading,children:(0,Q.jsx)(x,{className:`size-8 shrink-0 animate-spin text-accent motion-reduce:animate-none`,strokeWidth:2,"aria-hidden":!0})}):null,(0,Q.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:$e.map(e=>(0,Q.jsx)(it,{connector:e,installed:Ae.has(e.id)||st(e,S.instances),onInstall:e=>{if(e.source===`store`){Me(e.id);return}ae(On(e))},onOpenDetails:e.source===`store`?void 0:ce,t},e.id))}),tt?(0,Q.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,Q.jsxs)(_,{type:`button`,variant:`secondary`,disabled:w||E,onClick:()=>void ke({page:O+1,append:!0}),children:[w?(0,Q.jsx)(x,{className:`size-4 animate-spin`}):null,t.loadMore]})}):null]})]}):null]}),ie?(0,Q.jsx)(Dn,{draft:ie,onChange:ae,onClose:()=>ae(null),t,onInstalled:async e=>{await Y(),await G(),me(e.instanceId),De(`connected`)}}):null,se?(0,Q.jsx)(yt,{connector:se,installed:Ae.has(se.id)||st(se,S.instances),onClose:()=>ce(null),onInstall:e=>ae(On(e)),t}):null,X?(0,Q.jsx)(hn,{instance:X,definition:je.get(X.connectorId),onClose:()=>{ue(null),fe(null)},onChanged:Y,t,mcp:n}):null,he?(0,Q.jsx)(zn,{open:!0,mode:he.mode,initialRow:he.row,existingCustomServers:J,sessionIdleTtlMinutes:ye,config:K,managedServerIds:Pe,t:n,cs:t,onClose:()=>ge(null),onSaved:async()=>{await G(),await Y(),De(`connected`)}},`${he.mode}-${he.row.clientKey}`):null,(0,Q.jsx)(xt,{open:_e,sessionIdleTtlMinutes:ye,saving:xe,onChange:be,onSave:Le,onClose:()=>ve(!1),t,mcp:n})]})})}export{Qn as ConnectorsPage};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{c as i,l as a,t as o}from"./chunk-KS7C4IRE-BMhrPKJC.js";import{t as s}from"./check-DUBLcKHA.js";import{t as c}from"./cn-JdwAhgNB.js";import{t as l}from"./messages-DQ5X6cXp.js";import{n as u,o as d,r as f}from"./locale-store-Bjvw7jtg.js";import{n as p}from"./activity-store-BwmdJ5pv.js";import{$s as m,Bo as h,Bs as g,Cs as _,Dn as v,Es as y,Fo as b,Gc as x,Io as S,Lo as C,Na as w,Nu as T,On as E,Po as D,Ro as O,St as k,Ua as A,Uc as j,Xl as M,_t as N,bt as P,cl as F,gt as ee,lu as te,mt as ne,pt as re,pu as ie,rt as I,su as L,uu as R,vt as ae,wt as oe,xc as se,xt as ce,zo as le,zs as ue}from"./index-peR_-O6U.js";var z=e(t(),1),B=n();function V(e){try{return decodeURIComponent(e).trim()||null}catch{return null}}function H(e){if(!e)return null;let t=e.split(/[?#]/,1)[0],n=/^\/chat\/([^/]+)\/?$/.exec(t);if(n){let e=V(n[1]);return!e||e===`new`?null:{kind:`session`,id:e}}return null}async function U(e,t){let n=`/api/sessions/${encodeURIComponent(e.id)}?limit=1`;try{return(await d(f(n),{signal:t})).status===404?`missing`:`available`}catch(e){if(t?.aborted)throw e;return`available`}}var W=r(),G=3,K={info:{Icon:F,className:`text-accent-fg bg-accent-soft`},success:{Icon:L,className:`text-success bg-success-soft`},warning:{Icon:ue,className:`text-warning bg-warning-soft`},error:{Icon:te,className:`text-danger bg-danger-soft`}};function de(e,t){let n=Math.max(0,Math.round((Date.now()-e)/1e3));if(n<60)return t===`zh`?`刚刚`:`Just now`;let r=Math.round(n/60);if(r<60)return t===`zh`?`${r} 分钟前`:`${r}m ago`;let i=Math.round(r/60);if(i<24)return t===`zh`?`${i} 小时前`:`${i}h ago`;let a=Math.round(i/24);return t===`zh`?`${a} 天前`:`${a}d ago`}function q(e){let t=(0,B.c)(55),{item:n,targetAvailability:r}=e,i=u(pe),a;t[0]===i?a=t[1]:(a=l(i),t[0]=i,t[1]=a);let s=a.projectsPage.home,d=p(fe),{Icon:f,className:m}=K[n.tone],h;t[2]===m?h=t[3]:(h=c(`mt-0.5 flex size-7 shrink-0 items-center justify-center rounded-lg`,m),t[2]=m,t[3]=h);let g;t[4]!==f||t[5]!==n.status?(g=n.status===`running`?(0,W.jsx)(x,{className:`size-3.5 animate-spin motion-reduce:animate-none`,"aria-hidden":!0}):(0,W.jsx)(f,{className:`size-3.5`,"aria-hidden":!0}),t[4]=f,t[5]=n.status,t[6]=g):g=t[6];let _;t[7]!==h||t[8]!==g?(_=(0,W.jsx)(`div`,{className:h,children:g}),t[7]=h,t[8]=g,t[9]=_):_=t[9];let v;t[10]===n.title?v=t[11]:(v=(0,W.jsx)(`h3`,{className:`min-w-0 flex-1 text-sm font-medium leading-5 text-fg`,children:n.title}),t[10]=n.title,t[11]=v);let b;t[12]!==s.activityUnread||t[13]!==n.read?(b=n.read?null:(0,W.jsx)(`span`,{className:`mt-1.5 size-1.5 shrink-0 rounded-full bg-accent`,"aria-label":s.activityUnread}),t[12]=s.activityUnread,t[13]=n.read,t[14]=b):b=t[14];let S;t[15]!==v||t[16]!==b?(S=(0,W.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[v,b]}),t[15]=v,t[16]=b,t[17]=S):S=t[17];let C;t[18]===n.message?C=t[19]:(C=n.message?(0,W.jsx)(`p`,{className:`mt-0.5 line-clamp-2 text-xs leading-5 text-fg-muted`,children:n.message}):null,t[18]=n.message,t[19]=C);let T;t[20]===n.source?T=t[21]:(T=n.source?(0,W.jsx)(`span`,{className:`max-w-48 truncate`,children:n.source}):null,t[20]=n.source,t[21]=T);let E;t[22]!==n.updatedAt||t[23]!==i?(E=de(n.updatedAt,i),t[22]=n.updatedAt,t[23]=i,t[24]=E):E=t[24];let D;t[25]===E?D=t[26]:(D=(0,W.jsx)(`span`,{children:E}),t[25]=E,t[26]=D);let O;t[27]===n.occurrences?O=t[28]:(O=n.occurrences>1?(0,W.jsxs)(`span`,{children:[`×`,n.occurrences]}):null,t[27]=n.occurrences,t[28]=O);let k;t[29]!==s.activityCheckingRelated||t[30]!==s.activityRelatedMissing||t[31]!==s.activityViewRelated||t[32]!==n.href||t[33]!==r?(k=n.href&&r===`available`?(0,W.jsxs)(o,{to:n.href,className:`inline-flex items-center gap-0.5 font-medium text-accent-fg hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[s.activityViewRelated,(0,W.jsx)(R,{className:`size-3`,"aria-hidden":!0})]}):n.href&&r===`checking`?(0,W.jsx)(w,{className:`h-3 w-20 rounded`,"aria-label":s.activityCheckingRelated}):n.href&&r===`missing`?(0,W.jsx)(`span`,{className:`font-medium text-fg-subtle`,role:`status`,children:s.activityRelatedMissing}):null,t[29]=s.activityCheckingRelated,t[30]=s.activityRelatedMissing,t[31]=s.activityViewRelated,t[32]=n.href,t[33]=r,t[34]=k):k=t[34];let A;t[35]!==D||t[36]!==O||t[37]!==k||t[38]!==T?(A=(0,W.jsxs)(`div`,{className:`mt-1.5 flex min-w-0 flex-wrap items-center gap-x-2 text-[11px] text-fg-subtle`,children:[T,D,O,k]}),t[35]=D,t[36]=O,t[37]=k,t[38]=T,t[39]=A):A=t[39];let j;t[40]!==A||t[41]!==S||t[42]!==C?(j=(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[S,C,A]}),t[40]=A,t[41]=S,t[42]=C,t[43]=j):j=t[43];let M;t[44]!==n.id||t[45]!==d?(M=()=>d(n.id),t[44]=n.id,t[45]=d,t[46]=M):M=t[46];let N;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,W.jsx)(y,{className:`size-3.5`,"aria-hidden":!0}),t[47]=N):N=t[47];let P;t[48]!==s.activityRemove||t[49]!==M?(P=(0,W.jsx)(`button`,{type:`button`,className:`rounded-md p-1 text-fg-subtle opacity-0 transition-opacity hover:bg-surface-hover hover:text-fg group-hover:opacity-100 focus:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,"aria-label":s.activityRemove,onClick:M,children:N}),t[48]=s.activityRemove,t[49]=M,t[50]=P):P=t[50];let F;return t[51]!==j||t[52]!==P||t[53]!==_?(F=(0,W.jsxs)(`article`,{className:`group flex items-start gap-3 border-t border-edge-subtle px-1 py-3 first:border-t-0`,children:[_,j,P]}),t[51]=j,t[52]=P,t[53]=_,t[54]=F):F=t[54],F}function fe(e){return e.remove}function pe(e){return e.language}function me(){let e=(0,B.c)(14),t=l(u(xe)).projectsPage.home,n=p(be),r=p(ye),i=p(ve),[a,o]=(0,z.useState)(!1),c;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(c={},e[0]=c):c=e[0];let[d,f]=(0,z.useState)(c),m;e[1]===n?m=e[2]:(m=n.filter(Q),e[1]=n,e[2]=m);let h=m.length,v;e[3]===n?v=e[4]:(v=n.filter(Z),e[3]=n,e[4]=v);let y=v.length,b;e[5]!==a||e[6]!==n?(b=a?n:n.slice(0,G),e[5]=a,e[6]=n,e[7]=b):b=e[7];let S=b,C;e[8]===n?C=e[9]:(C=[...new Set(n.flatMap(_e))].sort().join(`
|
|
2
|
-
`),e[8]=n,e[9]=C);let w=C,E,D;e[10]===w?(E=e[11],D=e[12]):(E=()=>{let e=new AbortController,t=new Map((w?w.split(`
|
|
3
|
-
`):[]).flatMap(ge));return f(Object.fromEntries([...t.keys()].map(he))),Promise.all([...t].map(async t=>{let[n,r]=t,i=await U(r,e.signal);e.signal.aborted||f(e=>({...e,[n]:i}))})).catch(X),()=>e.abort()},D=[w],e[10]=w,e[11]=E,e[12]=D),(0,z.useEffect)(E,D);let O;return e[13]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,W.jsx)(T,{className:`size-4 text-fg-subtle`,"aria-hidden":!0}),e[13]=O):O=e[13],(0,W.jsxs)(`section`,{className:`rounded-2xl bg-surface-base p-4 shadow-surface`,"aria-labelledby":`workbench-activity-title`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,W.jsx)(`div`,{children:(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[O,(0,W.jsx)(`h2`,{id:`workbench-activity-title`,className:`text-sm font-semibold text-fg`,children:t.activityTitle}),h>0?(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,children:[(0,W.jsx)(x,{className:`size-3 animate-spin motion-reduce:animate-none`,"aria-hidden":!0}),h,` `,t.running]}):y>0?(0,W.jsxs)(`span`,{className:`rounded-full bg-surface-panel px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:[y,` `,t.activityNew]}):null]})}),a&&n.length>0?(0,W.jsxs)(`div`,{className:`flex items-center gap-1`,children:[y>0?(0,W.jsxs)(_,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs`,onClick:r,children:[(0,W.jsx)(s,{className:`size-3.5`,"aria-hidden":!0}),t.activityMarkRead]}):null,n.some(Y)?(0,W.jsxs)(_,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs text-fg-muted`,onClick:i,children:[(0,W.jsx)(g,{className:`size-3.5`,"aria-hidden":!0}),t.activityClearFinished]}):null]}):null]}),n.length>0?(0,W.jsxs)(`div`,{className:`mt-3 px-1`,children:[S.map(e=>(0,W.jsx)(q,{item:e,targetAvailability:e.href&&H(e.href)?d[e.href]??`checking`:`available`},e.id)),n.length>G?(0,W.jsx)(`div`,{className:`border-t border-edge-subtle py-2 text-center`,children:(0,W.jsx)(_,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-xs`,onClick:()=>o(J),children:a?t.activityShowLess:t.activityShowAll.replace(`{{count}}`,String(n.length))})}):null]}):(0,W.jsxs)(`div`,{className:`mt-3 flex items-center gap-2 text-sm text-fg-muted`,children:[(0,W.jsx)(M,{className:`size-4 text-fg-subtle`,"aria-hidden":!0}),(0,W.jsx)(`p`,{children:t.activityEmpty})]})]})}function J(e){return!e}function Y(e){return e.status===`done`}function X(){}function he(e){return[e,`checking`]}function ge(e){let t=H(e);return t?[[e,t]]:[]}function _e(e){return e.href&&H(e.href)?[e.href]:[]}function Z(e){return!e.read}function Q(e){return e.status===`running`}function ve(e){return e.clearFinished}function ye(e){return e.markAllRead}function be(e){return e.items}function xe(e){return e.language}function Se(e,t){return e.replace(/\{\{(\w+)\}\}/g,(e,n)=>String(t[n]??``))}function Ce(e,t){if(e==null)return t;let n=new Date(e);return Number.isNaN(n.getTime())?t:I(n)}function $(e){let t=(0,B.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,W.jsx)(`span`,{className:`rounded-full bg-surface-muted px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:n}),t[0]=n,t[1]=r),r}function we(e){let t=(0,B.c)(18),{task:n,statusLabel:r,backgroundPath:i}=e,a;t[0]!==i||t[1]!==n.id?(a=E(i,n.id),t[0]=i,t[1]=n.id,t[2]=a):a=t[2];let s;t[3]===n.title?s=t[4]:(s=(0,W.jsx)(`h3`,{className:`line-clamp-2 text-sm font-semibold text-fg`,children:n.title}),t[3]=n.title,t[4]=s);let c;t[5]===n.updatedAt?c=t[6]:(c=Ce(n.updatedAt,``),t[5]=n.updatedAt,t[6]=c);let l;t[7]===c?l=t[8]:(l=(0,W.jsx)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:c}),t[7]=c,t[8]=l);let u;t[9]!==s||t[10]!==l?(u=(0,W.jsxs)(`div`,{className:`min-w-0`,children:[s,l]}),t[9]=s,t[10]=l,t[11]=u):u=t[11];let d;t[12]===r?d=t[13]:(d=(0,W.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-muted px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:r}),t[12]=r,t[13]=d);let f;return t[14]!==a||t[15]!==u||t[16]!==d?(f=(0,W.jsxs)(o,{to:a,className:`group flex items-start justify-between gap-3 rounded-xl border border-edge-subtle bg-surface-panel p-4 transition-colors hover:bg-surface-hover/55 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[u,d]}),t[14]=a,t[15]=u,t[16]=d,t[17]=f):f=t[17],f}function Te(e){let t=(0,B.c)(12),{receipt:n,evidenceLabel:r,remainingLabel:i}=e,a;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,W.jsx)(L,{className:`mt-0.5 size-4 shrink-0 text-success`,"aria-hidden":!0}),t[0]=a):a=t[0];let o,s;t[1]===n.summary?(o=t[2],s=t[3]):(o=(0,W.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:n.summary}),s=(0,W.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:n.summary}),t[1]=n.summary,t[2]=o,t[3]=s);let c=n.remainingWork.length>0?` · ${n.remainingWork.length} ${i}`:``,l;t[4]!==r||t[5]!==n.evidence.length||t[6]!==c?(l=(0,W.jsxs)(`p`,{className:`mt-2 text-[11px] text-fg-subtle`,children:[n.evidence.length,` `,r,c]}),t[4]=r,t[5]=n.evidence.length,t[6]=c,t[7]=l):l=t[7];let u;return t[8]!==o||t[9]!==s||t[10]!==l?(u=(0,W.jsx)(`div`,{className:`block rounded-xl border border-edge-subtle px-3 py-3`,children:(0,W.jsxs)(`div`,{className:`flex items-start gap-2`,children:[a,(0,W.jsxs)(`div`,{className:`min-w-0`,children:[o,s,l]})]})}),t[8]=o,t[9]=s,t[10]=l,t[11]=u):u=t[11],u}function Ee(){let e=(0,B.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,W.jsxs)(`div`,{className:`space-y-5`,"aria-busy":!0,children:[(0,W.jsx)(w,{className:`h-20 rounded-2xl`}),(0,W.jsx)(w,{className:`h-72 rounded-2xl`}),(0,W.jsx)(w,{className:`h-44 rounded-2xl`})]}),e[0]=t):t=e[0],t}function De(e){let t=(0,B.c)(15),{chat:n,statusLabel:r}=e,i=`/chat/${encodeURIComponent(n.key)}`,a;t[0]===n.name?a=t[1]:(a=(0,W.jsx)(`h3`,{className:`min-w-0 truncate text-sm font-semibold text-fg`,children:n.name}),t[0]=n.name,t[1]=a);let s;t[2]===r?s=t[3]:(s=(0,W.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-muted px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:r}),t[2]=r,t[3]=s);let c;t[4]!==a||t[5]!==s?(c=(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[a,s]}),t[4]=a,t[5]=s,t[6]=c):c=t[6];let l;t[7]===n.updatedAt?l=t[8]:(l=Ce(n.updatedAt,``),t[7]=n.updatedAt,t[8]=l);let u;t[9]===l?u=t[10]:(u=(0,W.jsx)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:l}),t[9]=l,t[10]=u);let d;return t[11]!==i||t[12]!==c||t[13]!==u?(d=(0,W.jsxs)(o,{to:i,className:`group block rounded-xl border border-edge-subtle bg-surface-panel p-4 transition-colors hover:bg-surface-hover/55 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[c,u]}),t[11]=i,t[12]=c,t[13]=u,t[14]=d):d=t[14],d}function Oe(e){let t=(0,B.c)(27),{item:n,href:r,kindLabel:i,reasonLabel:a,approveLabel:s,denyLabel:c,busy:l,onRespond:u}=e,d;t[0]===n.title?d=t[1]:(d=(0,W.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:n.title}),t[0]=n.title,t[1]=d);let f=n.projectName||i,p;t[2]===f?p=t[3]:(p=(0,W.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-subtle`,children:f}),t[2]=f,t[3]=p);let m;t[4]!==d||t[5]!==p?(m=(0,W.jsxs)(`div`,{className:`min-w-0`,children:[d,p]}),t[4]=d,t[5]=p,t[6]=m):m=t[6];let h;t[7]===a?h=t[8]:(h=(0,W.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-panel/80 px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:a}),t[7]=a,t[8]=h);let g;t[9]!==m||t[10]!==h?(g=(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[m,h]}),t[9]=m,t[10]=h,t[11]=g):g=t[11];let v;t[12]===n.detail?v=t[13]:(v=n.detail?(0,W.jsx)(`p`,{className:`mt-2 line-clamp-2 text-xs leading-5 text-fg-muted`,children:n.detail}):null,t[12]=n.detail,t[13]=v);let y;t[14]!==r||t[15]!==g||t[16]!==v?(y=(0,W.jsxs)(o,{to:r,className:`group block focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[g,v]}),t[14]=r,t[15]=g,t[16]=v,t[17]=y):y=t[17];let b;t[18]!==s||t[19]!==l||t[20]!==c||t[21]!==n.response||t[22]!==u?(b=n.response?(0,W.jsxs)(`div`,{className:`mt-3 flex justify-end gap-2 border-t border-warning/20 pt-3`,children:[(0,W.jsx)(_,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:l,onClick:()=>u(`deny`),children:c}),(0,W.jsx)(_,{type:`button`,variant:`primary`,className:`h-8 px-2`,disabled:l,onClick:()=>u(`approve`),children:s})]}):null,t[18]=s,t[19]=l,t[20]=c,t[21]=n.response,t[22]=u,t[23]=b):b=t[23];let x;return t[24]!==y||t[25]!==b?(x=(0,W.jsxs)(`article`,{className:`rounded-xl border border-warning/35 bg-warning-soft/25 p-3.5 transition-colors hover:bg-warning-soft/40`,children:[y,b]}),t[24]=y,t[25]=b,t[26]=x):x=t[26],x}function ke(e){let t=(0,B.c)(65),{item:n,labels:r,busy:i,onDecide:a,onSnooze:o,onDismiss:s,onInstruct:c}=e,[l,u]=(0,z.useState)(``),d=n.judgment,f;t[0]===n.title?f=t[1]:(f=(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.title}),t[0]=n.title,t[1]=f);let p;t[2]===n.detail?p=t[3]:(p=(0,W.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-muted`,children:n.detail}),t[2]=n.detail,t[3]=p);let h;t[4]!==f||t[5]!==p?(h=(0,W.jsxs)(`div`,{className:`min-w-0`,children:[f,p]}),t[4]=f,t[5]=p,t[6]=h):h=t[6];let g;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,W.jsx)(m,{className:`size-4 shrink-0 text-accent`,"aria-hidden":!0}),t[7]=g):g=t[7];let v;t[8]===h?v=t[9]:(v=(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[h,g]}),t[8]=h,t[9]=v);let y;t[10]!==d.whyNow||t[11]!==r.whyNow?(y=[r.whyNow,d.whyNow],t[10]=d.whyNow,t[11]=r.whyNow,t[12]=y):y=t[12];let b;t[13]!==d.impact||t[14]!==r.impact?(b=[r.impact,d.impact],t[13]=d.impact,t[14]=r.impact,t[15]=b):b=t[15];let x;t[16]!==d.workDone||t[17]!==r.workDone?(x=[r.workDone,d.workDone],t[16]=d.workDone,t[17]=r.workDone,t[18]=x):x=t[18];let S;t[19]!==d.recommendation||t[20]!==r.recommendation?(S=[r.recommendation,d.recommendation],t[19]=d.recommendation,t[20]=r.recommendation,t[21]=S):S=t[21];let C;t[22]!==y||t[23]!==b||t[24]!==x||t[25]!==S?(C=(0,W.jsx)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-2`,children:[y,b,x,S].map(Ae)}),t[22]=y,t[23]=b,t[24]=x,t[25]=S,t[26]=C):C=t[26];let w;t[27]!==i||t[28]!==d.decision||t[29]!==a?(w=d.decision?(0,W.jsxs)(`div`,{className:`mt-4`,children:[(0,W.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:d.decision.question}),(0,W.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:d.decision.options.map(e=>(0,W.jsxs)(_,{type:`button`,variant:`secondary`,className:`h-auto min-h-9 flex-col items-start px-3 py-2 text-left`,disabled:i,title:e.consequence,onClick:()=>a(e.id),children:[(0,W.jsx)(`span`,{children:e.label}),(0,W.jsx)(`span`,{className:`text-[10px] font-normal text-fg-muted`,children:e.consequence})]},e.id))})]}):null,t[27]=i,t[28]=d.decision,t[29]=a,t[30]=w):w=t[30];let T;t[31]!==i||t[32]!==r.snooze||t[33]!==o?(T=(0,W.jsx)(_,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:i,onClick:o,children:r.snooze}),t[31]=i,t[32]=r.snooze,t[33]=o,t[34]=T):T=t[34];let E;t[35]!==i||t[36]!==r.dismiss||t[37]!==s?(E=(0,W.jsx)(_,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:i,onClick:s,children:r.dismiss}),t[35]=i,t[36]=r.dismiss,t[37]=s,t[38]=E):E=t[38];let D;t[39]!==T||t[40]!==E?(D=(0,W.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2 border-t border-edge-subtle pt-3`,children:[T,E]}),t[39]=T,t[40]=E,t[41]=D):D=t[41];let O;t[42]!==l||t[43]!==c?(O=e=>{e.preventDefault();let t=l.trim();t&&(c(t),u(``))},t[42]=l,t[43]=c,t[44]=O):O=t[44];let k;t[45]===Symbol.for(`react.memo_cache_sentinel`)?(k=e=>u(e.target.value),t[45]=k):k=t[45];let A;t[46]!==l||t[47]!==r.feedbackPlaceholder?(A=(0,W.jsx)(`input`,{className:`min-w-0 flex-1 rounded-lg border border-edge bg-surface-base px-3 py-2 text-xs text-fg outline-none focus:border-accent`,value:l,onChange:k,placeholder:r.feedbackPlaceholder}),t[46]=l,t[47]=r.feedbackPlaceholder,t[48]=A):A=t[48];let j;t[49]!==i||t[50]!==l?(j=i||!l.trim(),t[49]=i,t[50]=l,t[51]=j):j=t[51];let M;t[52]!==r.applyFeedback||t[53]!==j?(M=(0,W.jsx)(_,{type:`submit`,variant:`secondary`,className:`h-9 px-3`,disabled:j,children:r.applyFeedback}),t[52]=r.applyFeedback,t[53]=j,t[54]=M):M=t[54];let N;t[55]!==O||t[56]!==A||t[57]!==M?(N=(0,W.jsxs)(`form`,{className:`mt-3 flex gap-2`,onSubmit:O,children:[A,M]}),t[55]=O,t[56]=A,t[57]=M,t[58]=N):N=t[58];let P;return t[59]!==C||t[60]!==w||t[61]!==D||t[62]!==N||t[63]!==v?(P=(0,W.jsxs)(`article`,{className:`rounded-xl border border-accent/25 bg-accent-soft/15 p-4`,children:[v,C,w,D,N]}),t[59]=C,t[60]=w,t[61]=D,t[62]=N,t[63]=v,t[64]=P):P=t[64],P}function Ae(e){let[t,n]=e;return(0,W.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/80 p-3`,children:[(0,W.jsx)(`p`,{className:`text-[11px] font-medium text-fg-subtle`,children:t}),(0,W.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg`,children:n})]},t)}function je(e){let t=(0,B.c)(32),{item:n,href:r,statusLabel:i,retryLabel:a,viewLabel:s,acknowledgeLabel:c,busy:l,onView:u,onRetry:d,onAcknowledge:f}=e,p;t[0]===n.title?p=t[1]:(p=(0,W.jsx)(`h3`,{className:`min-w-0 truncate text-sm font-semibold text-fg`,children:n.title}),t[0]=n.title,t[1]=p);let m;t[2]===i?m=t[3]:(m=(0,W.jsx)(`span`,{className:`shrink-0 rounded-full bg-surface-panel/80 px-2 py-0.5 text-[11px] font-medium text-danger`,children:i}),t[2]=i,t[3]=m);let h;t[4]!==p||t[5]!==m?(h=(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[p,m]}),t[4]=p,t[5]=m,t[6]=h):h=t[6];let g;t[7]===n.detail?g=t[8]:(g=(0,W.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-muted`,children:n.detail}),t[7]=n.detail,t[8]=g);let v;t[9]!==r||t[10]!==h||t[11]!==g?(v=(0,W.jsxs)(o,{to:r,className:`block focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[h,g]}),t[9]=r,t[10]=h,t[11]=g,t[12]=v):v=t[12];let y;t[13]!==c||t[14]!==l||t[15]!==f?(y=(0,W.jsx)(_,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:l,onClick:f,children:c}),t[13]=c,t[14]=l,t[15]=f,t[16]=y):y=t[16];let b;t[17]!==l||t[18]!==u||t[19]!==s?(b=(0,W.jsx)(_,{type:`button`,variant:`ghost`,className:`h-8 px-2`,disabled:l,onClick:u,children:s}),t[17]=l,t[18]=u,t[19]=s,t[20]=b):b=t[20];let x;t[21]!==l||t[22]!==d||t[23]!==a?(x=(0,W.jsx)(_,{type:`button`,variant:`primary`,className:`h-8 px-2`,disabled:l,onClick:d,children:a}),t[21]=l,t[22]=d,t[23]=a,t[24]=x):x=t[24];let S;t[25]!==y||t[26]!==b||t[27]!==x?(S=(0,W.jsxs)(`div`,{className:`mt-3 flex flex-wrap justify-end gap-2 border-t border-danger/15 pt-3`,children:[y,b,x]}),t[25]=y,t[26]=b,t[27]=x,t[28]=S):S=t[28];let C;return t[29]!==v||t[30]!==S?(C=(0,W.jsxs)(`article`,{className:`rounded-xl border border-danger/25 bg-danger-soft/35 p-3.5`,children:[v,S]}),t[29]=v,t[30]=S,t[31]=C):C=t[31],C}function Me(){let e=u(e=>e.language),t=l(e).projectsPage,n=re(e),r=a(),s=i(),c=`${s.pathname}${s.search}`,d=A(e=>e.setPageHeader),f=A(e=>e.clearPageHeader),[p,g]=(0,z.useState)(null),[x,w]=(0,z.useState)(!0),[T,M]=(0,z.useState)(null),[F,I]=(0,z.useState)(!1),[R,ue]=(0,z.useState)(``),[B,V]=(0,z.useState)(()=>crypto.randomUUID()),[H,U]=(0,z.useState)(!1),[G,K]=(0,z.useState)(null),[de,q]=(0,z.useState)(null),[fe,pe]=(0,z.useState)(null),J=(0,z.useCallback)(async(t=!1)=>{t&&w(!0),M(null);try{g(await ae(e))}catch(e){M(e instanceof Error?e.message:String(e))}finally{w(!1)}},[e]);(0,z.useEffect)(()=>{J(!0)},[J]),(0,z.useEffect)(()=>{let e,t=t=>{e!==void 0&&window.clearTimeout(e),e=window.setTimeout(()=>{e=void 0,J()},t)},n=()=>t(100),r=()=>t(750),i=[`session-created`,`agent-run-started`,`agent-run-ended`,`automation-run-completed`,`workflow-run-updated`,`workflow-run-error`],a=[`session-updated`,`session-transcript-updated`];return i.forEach(e=>window.addEventListener(e,n)),a.forEach(e=>window.addEventListener(e,r)),()=>{i.forEach(e=>window.removeEventListener(e,n)),a.forEach(e=>window.removeEventListener(e,r)),e!==void 0&&window.clearTimeout(e)}},[J]);let Y=(0,z.useMemo)(()=>p?.decisions??[],[p]),X=(0,z.useMemo)(()=>p?.attention??[],[p]),he=(0,z.useCallback)(async t=>{t.preventDefault();let n=R.trim();if(!(!n||H)){U(!0),K(null);try{let t=await ee({idempotencyKey:B,title:n,locale:e,priority:`normal`,contract:{objective:n,expectedOutputs:[],acceptanceCriteria:[],constraints:[],approvalRequired:[],assumptions:[],risks:[],acceptancePolicy:`manual`,outputDestinations:[]},dependencies:[],context:[],authorityGrants:[],activation:{mode:`start`,executor:{kind:`agent`,agentId:`main`}}});I(!1),ue(``),V(crypto.randomUUID()),r(E(c,t.task.id))}catch(e){K(e instanceof Error?e.message:String(e))}finally{U(!1)}}},[c,B,H,e,r,R]),ge=(0,z.useMemo)(()=>(0,W.jsxs)(_,{type:`button`,variant:`primary`,className:`h-9 rounded-lg`,onClick:()=>I(!0),children:[(0,W.jsx)(se,{className:`size-4`,"aria-hidden":!0}),n.newWork]}),[n.newWork]),_e=(0,z.useCallback)(async(e,t)=>{if(e.response){q(e.id),M(null);try{await ce(e.response,t),await J()}catch(e){M(e instanceof Error?e.message:String(e))}finally{q(null)}}},[J]),Z=(0,z.useCallback)(async(e,t)=>{q(e.id),M(null);try{await t(),await J()}catch(e){M(e instanceof Error?e.message:String(e))}finally{q(null)}},[J]),Q=(0,z.useCallback)(async(e,t)=>{pe(e.id),M(null);try{await t({kind:e.kind,runId:e.runId}),await J()}catch(e){M(e instanceof Error?e.message:String(e))}finally{pe(null)}},[J]);return(0,z.useLayoutEffect)(()=>(d({startExtra:null,main:(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.title}),(0,W.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:t.home.subtitle})]}),end:ge}),()=>f()),[f,ge,d,t.title,t.home.subtitle]),(0,W.jsxs)(`main`,{className:`mx-auto flex w-full max-w-[1200px] flex-1 flex-col gap-7 px-4 py-7 sm:px-6 lg:px-8 lg:py-9`,children:[(0,W.jsx)(D,{open:F,onOpenChange:e=>{H||I(e),e&&(K(null),V(crypto.randomUUID()))},children:(0,W.jsxs)(le,{children:[(0,W.jsx)(O,{className:`fixed inset-0 z-[80] bg-scrim backdrop-blur-[2px]`}),(0,W.jsxs)(S,{className:`fixed left-1/2 top-1/2 z-[90] flex h-[min(31rem,calc(100dvh-1.5rem))] w-[min(36rem,calc(100vw-1.5rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-panel shadow-float focus:outline-none`,children:[(0,W.jsxs)(`div`,{className:`flex shrink-0 items-start gap-4 border-b border-edge px-5 py-4`,children:[(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsx)(h,{className:`text-base font-semibold text-fg`,children:n.dialogTitle}),(0,W.jsx)(C,{className:`mt-1 text-sm leading-5 text-fg-muted`,children:n.dialogDescription})]}),(0,W.jsx)(b,{asChild:!0,children:(0,W.jsx)(_,{type:`button`,variant:`ghost`,className:`-mr-2 -mt-1 size-8 shrink-0 rounded-lg p-0`,title:t.cancel,"aria-label":t.cancel,children:(0,W.jsx)(y,{className:`size-4`,"aria-hidden":!0})})})]}),(0,W.jsxs)(`form`,{onSubmit:he,className:`flex min-h-0 flex-1 flex-col`,children:[(0,W.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto px-5 py-4`,children:[(0,W.jsx)(`label`,{htmlFor:`new-work-task`,className:`mb-2 shrink-0 text-sm font-medium text-fg`,children:n.intentLabel}),(0,W.jsx)(`textarea`,{id:`new-work-task`,className:`min-h-32 w-full flex-1 resize-none rounded-xl border border-edge bg-surface-base p-3 text-sm font-normal leading-6 text-fg outline-none placeholder:text-fg-subtle focus:border-accent focus:ring-2 focus:ring-accent/20`,value:R,onChange:e=>{ue(e.target.value),V(crypto.randomUUID())},onKeyDown:e=>{e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())},placeholder:n.intentPlaceholder,maxLength:12e3,autoFocus:!0}),(0,W.jsxs)(`div`,{className:`mt-2 flex shrink-0 items-center justify-between gap-3 text-[11px] text-fg-subtle`,children:[(0,W.jsx)(`span`,{children:t.home.submitShortcut}),(0,W.jsxs)(`span`,{className:`tabular-nums`,children:[R.length.toLocaleString(),` / `,12e3.toLocaleString()]})]}),G?(0,W.jsx)(`p`,{className:`mt-3 text-sm text-danger`,children:G}):null]}),(0,W.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge px-5 py-4`,children:[(0,W.jsx)(b,{asChild:!0,children:(0,W.jsx)(_,{type:`button`,variant:`ghost`,disabled:H,children:t.cancel})}),(0,W.jsxs)(_,{type:`submit`,variant:`primary`,className:`min-w-32`,disabled:!R.trim()||H,children:[(0,W.jsx)(m,{className:`size-4`,"aria-hidden":!0}),H?n.starting:n.submit]})]})]})]})]})}),T?(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl border border-danger/25 bg-danger-soft px-4 py-3 text-sm text-danger`,children:[(0,W.jsx)(`span`,{children:T}),(0,W.jsx)(_,{type:`button`,variant:`ghost`,className:`h-8 px-2`,onClick:()=>void J(),children:t.home.retry})]}):null,x?(0,W.jsx)(Ee,{}):p?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`section`,{className:`border-b border-edge-subtle pb-5`,children:[(0,W.jsx)(`p`,{className:`text-xs font-medium text-fg-subtle`,children:t.home.briefingTitle}),(0,W.jsx)(`h2`,{className:`mt-1 text-xl font-semibold tracking-tight text-fg`,children:p.decisions.length+p.attention.length>0?Se(t.home.todaySummary,{attention:p.decisions.length+p.attention.length,moving:p.briefing.progress.movingCount+p.chats.running.length}):Se(t.home.todaySummaryClear,{moving:p.briefing.progress.movingCount+p.chats.running.length})}),p.briefing.summary?(0,W.jsx)(`p`,{className:`mt-2 max-w-3xl text-sm leading-6 text-fg-muted`,children:p.briefing.summary}):null]}),p.tasks.running.length===0&&p.workflowRuns.active.length===0&&p.decisions.length===0&&p.attention.length===0&&p.chats.running.length===0&&p.chats.recent.length===0&&p.upcomingAutomations.length===0?(0,W.jsxs)(`section`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center`,children:[(0,W.jsx)(j,{className:`mx-auto size-6 text-accent`,"aria-hidden":!0}),(0,W.jsx)(`h2`,{className:`mt-3 text-sm font-semibold text-fg`,children:t.home.emptyTitle}),(0,W.jsx)(`p`,{className:`mx-auto mt-1 max-w-lg text-sm leading-6 text-fg-muted`,children:t.home.emptyBody}),(0,W.jsxs)(`div`,{className:`mt-4 flex justify-center gap-2`,children:[(0,W.jsx)(_,{type:`button`,variant:`primary`,onClick:()=>r(`/chat/new`),children:t.home.startChat}),(0,W.jsx)(_,{type:`button`,variant:`secondary`,onClick:()=>I(!0),children:n.newWork})]})]}):null,(0,W.jsxs)(`div`,{className:`grid items-start gap-6 xl:grid-cols-[minmax(0,2fr)_minmax(18rem,1fr)]`,children:[(0,W.jsxs)(`div`,{className:`min-w-0 space-y-6`,children:[X.length>0?(0,W.jsxs)(`section`,{className:`rounded-2xl bg-surface-base p-5 shadow-surface`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(te,{className:`size-4 text-danger`,"aria-hidden":!0}),(0,W.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:n.runAttention}),(0,W.jsx)($,{children:X.length.toLocaleString()})]}),(0,W.jsx)(`div`,{className:`mt-4 space-y-2`,children:X.map(e=>(0,W.jsx)(je,{item:e,href:v(c,e.href),statusLabel:e.reason===`run_timeout`?t.home.attentionTimeout:t.home.attentionFailed,retryLabel:t.home.attentionRetry,viewLabel:t.home.attentionView,acknowledgeLabel:t.home.attentionAcknowledge,busy:fe===e.id,onView:()=>r(v(c,e.href)),onRetry:()=>void Q(e,k),onAcknowledge:()=>void Q(e,ne)},e.id))})]}):null,Y.length>0?(0,W.jsxs)(`section`,{className:`rounded-2xl bg-surface-base p-5 shadow-surface`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(te,{className:`size-4 text-warning`,"aria-hidden":!0}),(0,W.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:n.needsAttention}),(0,W.jsx)($,{children:Y.length.toLocaleString()})]}),(0,W.jsx)(`div`,{className:`mt-4 space-y-2`,children:Y.map(e=>e.kind===`agent_judgment`&&e.judgment?(0,W.jsx)(ke,{item:e,labels:n,busy:de===e.id,onDecide:t=>void Z(e,()=>N(e.judgment.inboxItemId,t)),onSnooze:()=>void Z(e,()=>oe(e.judgment.inboxItemId,`snoozed`)),onDismiss:()=>void Z(e,()=>oe(e.judgment.inboxItemId,`resolved`)),onInstruct:t=>void Z(e,()=>P(e.judgment.inboxItemId,t))},e.id):(0,W.jsx)(Oe,{item:e,href:v(c,e.href),kindLabel:t.home.decisionKinds[e.kind],reasonLabel:t.home.decisionReasons[e.reason],approveLabel:t.home.approve,denyLabel:t.home.deny,busy:de===e.id,onRespond:t=>void _e(e,t)},e.id))})]}):(0,W.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,W.jsx)(`span`,{className:`flex size-5 items-center justify-center rounded-full bg-success-soft text-xs text-success`,"aria-hidden":!0,children:`✓`}),t.home.nothingNeedsYou]}),(0,W.jsxs)(`section`,{className:`rounded-2xl bg-surface-base p-5 shadow-surface`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(m,{className:`size-4 text-accent`,"aria-hidden":!0}),(0,W.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:n.running}),(0,W.jsx)($,{children:p.tasks.running.length.toLocaleString()})]}),(0,W.jsxs)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-2`,children:[p.tasks.running.map(e=>(0,W.jsx)(we,{task:e,statusLabel:n.taskStatuses.running,backgroundPath:c},e.id)),p.tasks.running.length===0?(0,W.jsx)(`p`,{className:`py-6 text-center text-sm text-fg-muted`,children:n.emptyRunning}):null]})]}),p.chats.recent.length>0?(0,W.jsxs)(`section`,{className:`rounded-2xl bg-surface-base p-5 shadow-surface`,children:[(0,W.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,W.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:n.recent})}),(0,W.jsx)(`div`,{className:`mt-4 grid gap-3 sm:grid-cols-2`,children:p.chats.recent.slice(0,6).map(e=>(0,W.jsx)(De,{chat:e,statusLabel:n.openChat},e.key))})]}):null]}),(0,W.jsxs)(`aside`,{className:`min-w-0 space-y-4`,"aria-label":t.home.nowTitle,children:[(0,W.jsx)(`div`,{className:`px-1`,children:(0,W.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.home.nowTitle})}),p.upcomingAutomations.length>0?(0,W.jsxs)(`section`,{className:`rounded-2xl bg-surface-base p-4 shadow-surface`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(ie,{className:`size-4 text-fg-subtle`,"aria-hidden":!0}),(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.home.scheduled})]}),(0,W.jsx)(`div`,{className:`mt-2 divide-y divide-edge-subtle`,children:p.upcomingAutomations.slice(0,3).map(e=>(0,W.jsxs)(o,{to:`/automations`,className:`flex items-center justify-between gap-3 rounded-lg px-1 py-3 text-sm hover:bg-surface-hover/55`,children:[(0,W.jsx)(`span`,{className:`min-w-0 truncate text-fg`,children:e.name||e.action}),(0,W.jsx)(`time`,{className:`shrink-0 text-xs text-fg-subtle`,children:Ce(e.nextRunAt,t.never)})]},e.id))})]}):null,p.recentTasks.length>0?(0,W.jsxs)(`section`,{className:`rounded-2xl bg-surface-base p-4 shadow-surface`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(L,{className:`size-4 text-success`,"aria-hidden":!0}),(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.recentTasks})]}),(0,W.jsx)(`div`,{className:`mt-3 space-y-2`,children:p.recentTasks.slice(0,3).map(e=>(0,W.jsx)(Te,{receipt:e,evidenceLabel:n.evidenceCount,remainingLabel:n.remainingCount},e.runId))})]}):null,(0,W.jsx)(me,{}),p.briefing.wins.length>0?(0,W.jsxs)(o,{to:p.briefing.wins[0].href,className:`flex items-center justify-between gap-3 rounded-xl px-2 py-2 text-sm text-fg-muted hover:bg-surface-hover/55 hover:text-fg`,children:[(0,W.jsx)(`span`,{children:Se(t.home.completedSummary,{count:p.briefing.wins.length})}),(0,W.jsxs)(`span`,{className:`shrink-0 text-xs font-medium text-accent`,children:[t.home.viewLatestResult,` →`]})]}):null]})]})]}):null]})}export{Me as HomePage};
|