@xopcai/xopc 0.0.246 → 0.0.248
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/src/update-offset-store.js +17 -54
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/extensions/weixin/src/auth/accounts.js +3 -5
- package/dist/extensions/weixin/src/monitor/monitor.js +3 -5
- package/dist/extensions/weixin/src/storage/sync-buf.d.ts +3 -6
- package/dist/extensions/weixin/src/storage/sync-buf.js +9 -22
- package/dist/gateway/static/root/assets/{activity-store-BlxqErph.js → activity-store-etpmyV7S.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-CJJzpYYS.js → agent-avatar-dicebear-BmKxSM1k.js} +1 -1
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-CUXApfcE.js +1 -0
- package/dist/gateway/static/root/assets/{agents-je3sRGmk.js → agents-DNq_GKuc.js} +1 -1
- package/dist/gateway/static/root/assets/{api-BbXzyQMj.js → api-B0-hLuZ1.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-Cnn3i00c.js → app-management-settings-panel-qfwAgyhQ.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-BToQaw_v.js → appearance-settings-DqQVUpCC.js} +1 -1
- package/dist/gateway/static/root/assets/apps-page-dwIqYmXk.js +1 -0
- package/dist/gateway/static/root/assets/{archive-plugin-DD2SweEH.js → archive-plugin-BnMSgZvR.js} +1 -1
- package/dist/gateway/static/root/assets/{attachment-load-BFtcib5t.js → attachment-load-CejsQMev.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-XS8wIl5o.js → automations-page-RC8EyoAf.js} +1 -1
- package/dist/gateway/static/root/assets/automations-workspace-SkdcSZ0i.js +6 -0
- package/dist/gateway/static/root/assets/{binary-plugins-Xs7pLHxR.js → binary-plugins-DGjppLSG.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-BPdSzceB.js → block-editor-CWdP4bUc.js} +44 -44
- package/dist/gateway/static/root/assets/browser-settings-page-CKCa6TvG.js +8 -0
- package/dist/gateway/static/root/assets/{browser-workflow-inputs-BAAc151l.js → browser-workflow-inputs-BQ1Ilw_o.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-workflows-page-DUPPvE30.js → browser-workflows-page-CJh4NyxT.js} +2 -2
- package/dist/gateway/static/root/assets/{capabilities-settings-panel-cl9kYilL.js → capabilities-settings-panel-DSp--zIZ.js} +5 -5
- package/dist/gateway/static/root/assets/channels-settings-CMd2dDrI.js +1 -0
- package/dist/gateway/static/root/assets/{channels-status-swr-CCBCtLDg.js → channels-status-swr-Ohhee4vm.js} +1 -1
- package/dist/gateway/static/root/assets/{chat-terminal-dock-DKW1M6aJ.js → chat-terminal-dock-BOtoKTK3.js} +2 -2
- package/dist/gateway/static/root/assets/connectors-page-udWs5Kdm.js +2 -0
- package/dist/gateway/static/root/assets/{cron-expression-Bijb0ZQu.js → cron-expression-DTj1V3Sw.js} +1 -1
- package/dist/gateway/static/root/assets/{date-picker-BZuHw-SY.js → date-picker-Yr6OCvGL.js} +1 -1
- package/dist/gateway/static/root/assets/{dependency-picker-BsBD2JFY.js → dependency-picker-DpN3XZg9.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-Ceuw3QKb.js → desktop-pet-DbGzggPF.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-DctOXexM.js → desktop-pet-settings-DinCToZh.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-BNlMPATK.js → extension-debug-page-DgTtk4KC.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-CK4Uvzge.js → extension-page-DtQeiP6f.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-CpnXXemw.js → extension-settings-page-DcguCgsH.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-api-C_mlpe-r.js → gateway-config-api-Br7lSf6H.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-swr-826dipyU.js → gateway-config-swr-DXuXtU1w.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-DSSW17ed.js → gateway-settings-CdPoDMuj.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-DyvcAIMm.js → gateway-startup-retry-CzBzglzQ.js} +1 -1
- package/dist/gateway/static/root/assets/{heartbeat-settings-hbmIZTpg.js → heartbeat-settings-DHk1hawP.js} +1 -1
- package/dist/gateway/static/root/assets/home-page-YGipe_W6.js +1 -0
- package/dist/gateway/static/root/assets/{image-generation-api-D7cyfks6.js → image-generation-api-TIgsn04n.js} +1 -1
- package/dist/gateway/static/root/assets/{index-eZjksPvq.js → index-D5TQQpeb.js} +44 -44
- package/dist/gateway/static/root/assets/index-DReBaaTX.css +2 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-BQrDwwgi.js → keyboard-shortcuts-settings-wsWuoa8p.js} +1 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-CpyvYyrb.js +2 -0
- package/dist/gateway/static/root/assets/{local-apps-page-D-YWD6LS.js → local-apps-page-CXrbrGo8.js} +1 -1
- package/dist/gateway/static/root/assets/local-context-graph-BjUf7fQ9.js +1 -0
- package/dist/gateway/static/root/assets/{locale-store-CBoCuIMx.js → locale-store-BJFLQY8O.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-DvLc9l59.js → logs-page-CXKy6E_l.js} +2 -2
- package/dist/gateway/static/root/assets/{management-settings-DsULLUUv.js → management-settings-BdJZFR7U.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-split-CjqlP6IB.js → markdown-split-NK3ACVG2.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-view-BXsHghJd.js → markdown-view-DTF9v1gg.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-DQL029DU.js → media-plugins-F0jcUxyl.js} +1 -1
- package/dist/gateway/static/root/assets/messages-CHNYp8EQ.js +3 -0
- package/dist/gateway/static/root/assets/{mobile-pairing-wizard-gauprAae.js → mobile-pairing-wizard-3NKCniSp.js} +1 -1
- package/dist/gateway/static/root/assets/models-hub-cache-nCfkBN8M.js +1 -0
- package/dist/gateway/static/root/assets/{notes-page-AsEfLZt9.js → notes-page-DuqLahi6.js} +1 -1
- package/dist/gateway/static/root/assets/notes-workbench-C7j9EdQk.js +5 -0
- package/dist/gateway/static/root/assets/{oauth-api-BjSUDIgq.js → oauth-api-8lP_qJpq.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-CAJeUXeU.js → product-open-page-CxGGlWA8.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-CfebYVX0.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-48GvzSVa.js +1 -0
- package/dist/gateway/static/root/assets/{registry-api-BhGKnvLP.js → registry-api-CIsNlSBi.js} +1 -1
- package/dist/gateway/static/root/assets/remote-access-hub-64xj_s2m.js +1 -0
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-DH6EilMV.js → runtime-tools-settings-panel-YkjhiQfA.js} +2 -2
- package/dist/gateway/static/root/assets/{schema-form-DYHmEZeZ.js → schema-form-oFGf3G3s.js} +1 -1
- package/dist/gateway/static/root/assets/sessions-page-CcwcdRN8.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-BaN84CyW.js +1 -0
- package/dist/gateway/static/root/assets/{settings-page-BHwPd_M3.js → settings-page-C7VWs0IT.js} +1 -1
- package/dist/gateway/static/root/assets/setup-status-panel-DVVOCNbr.js +1 -0
- package/dist/gateway/static/root/assets/{share-preview-page-BjwrS03F.js → share-preview-page-t5oz18rh.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-DUYbYLi7.js +1 -0
- package/dist/gateway/static/root/assets/skill-reload-api-BGyD0gB9.js +1 -0
- package/dist/gateway/static/root/assets/{skills-page-OHyK25op.js → skills-page-CjF8DTsN.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page.utils-DQx9ulmg.js → skills-page.utils-DEDTYs2W.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-wO7DWv4C.js → system-settings-panel-BSYuRgFI.js} +1 -1
- package/dist/gateway/static/root/assets/task-detail-page-YZYSTJH7.js +1 -0
- package/dist/gateway/static/root/assets/{theme-store-hybK3oC9.js → theme-store-O597U8q_.js} +1 -1
- package/dist/gateway/static/root/assets/{tunnel-api-CVC8BHZu.js → tunnel-api-FKUi9wDL.js} +1 -1
- package/dist/gateway/static/root/assets/{use-autosave-DMvRu2XZ.js → use-autosave-B5eUJ6Zq.js} +1 -1
- package/dist/gateway/static/root/assets/user-context-page-BCyiduKd.js +2 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-DuBK2NDG.js → voice-api-key-field-CMKSwz4C.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-config-api-CBbiF1T3.js → voice-config-api-q7B6fOFB.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-B7VXWpDr.js → work-discovery-overlay-jhT2EzeH.js} +1 -1
- package/dist/gateway/static/root/assets/{workflow-run-setup-panel-BokVAsWN.js → workflow-run-setup-panel-DZmvLZjb.js} +2 -2
- package/dist/gateway/static/root/assets/workflows-page-DQC0TpMa.js +5 -0
- package/dist/gateway/static/root/index.html +12 -12
- package/dist/package.js +1 -1
- package/dist/src/agent/commands/command-registry.d.ts +1 -0
- package/dist/src/agent/commands/command-registry.js +12 -22
- package/dist/src/agent/ipc/inbox.d.ts +8 -31
- package/dist/src/agent/ipc/inbox.js +64 -133
- package/dist/src/agent/service/process-direct-one-shot.js +15 -10
- package/dist/src/agent/workflow/catalog.d.ts +1 -8
- package/dist/src/agent/workflow/catalog.js +44 -102
- package/dist/src/agent/workflow/index.d.ts +1 -1
- package/dist/src/agent/workflow/index.js +2 -2
- package/dist/src/automations/domain/types.d.ts +1 -0
- package/dist/src/automations/service/action-executor.js +2 -2
- package/dist/src/automations/service/automation-service.js +2 -2
- package/dist/src/channels/manager.d.ts +1 -1
- package/dist/src/channels/manager.js +2 -2
- package/dist/src/channels/outbound/persist-store.d.ts +2 -8
- package/dist/src/channels/outbound/persist-store.js +11 -38
- package/dist/src/channels/outbound-sender.d.ts +1 -1
- package/dist/src/channels/outbound-sender.js +2 -2
- package/dist/src/cli/commands/connectors.js +1 -1
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/config/schema.js +2 -2
- package/dist/src/connectors/auth-provider-registry.js +1 -1
- package/dist/src/connectors/composio-triggers.d.ts +2 -2
- package/dist/src/connectors/composio-triggers.js +8 -15
- package/dist/src/connectors/connected-source-ingestion.js +1 -1
- package/dist/src/connectors/health.js +1 -1
- package/dist/src/gateway/automation-agent-session.js +3 -0
- package/dist/src/gateway/heartbeat/service.js +1 -1
- package/dist/src/gateway/hono/lib/extension-store.js +8 -25
- package/dist/src/gateway/hono/routes/capabilities.js +1 -1
- package/dist/src/gateway/hono/routes/connectors.js +3 -3
- package/dist/src/gateway/hono/routes/mcp.js +1 -1
- package/dist/src/gateway/hono/routes/projects.js +1 -1
- package/dist/src/gateway/hono/routes/you.js +20 -4
- package/dist/src/gateway/service.js +4 -5
- package/dist/src/heartbeat/index.js +1 -1
- package/dist/src/notes/index.d.ts +1 -1
- package/dist/src/notes/index.js +2 -2
- package/dist/src/notes/paths.d.ts +0 -3
- package/dist/src/notes/paths.js +1 -10
- package/dist/src/notes/service.d.ts +0 -1
- package/dist/src/notes/service.js +0 -3
- package/dist/src/notes/store.d.ts +0 -2
- package/dist/src/notes/store.js +33 -80
- package/dist/src/share/hosted-session-share.d.ts +1 -4
- package/dist/src/share/hosted-session-share.js +14 -47
- package/dist/src/share/share-auto.d.ts +1 -1
- package/dist/src/share/share-auto.js +2 -2
- package/dist/src/share/share-store.d.ts +2 -7
- package/dist/src/share/share-store.js +153 -195
- package/dist/src/share/share-types.d.ts +0 -4
- package/dist/src/share/site-share-store.d.ts +3 -8
- package/dist/src/share/site-share-store.js +94 -153
- package/dist/src/share/site-share-types.d.ts +0 -4
- package/dist/src/storage/sqlite/connection.d.ts +1 -2
- package/dist/src/storage/sqlite/connection.js +50 -47
- package/dist/src/storage/sqlite/durable-queue.d.ts +16 -0
- package/dist/src/storage/sqlite/durable-queue.js +52 -0
- package/dist/src/storage/sqlite/durable-state.d.ts +16 -0
- package/dist/src/storage/sqlite/durable-state.js +43 -0
- package/dist/src/storage/sqlite/migrations/146_understanding_focus_exclusions.sql +9 -0
- package/dist/src/storage/sqlite/migrations/147_durable_application_state.sql +39 -0
- package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
- package/dist/src/storage/sqlite/migrations/runner.js +3 -3
- package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
- package/dist/src/storage/sqlite/schema.js +1 -1
- package/dist/src/storage/sqlite/understanding-focus-exclusions.d.ts +2 -0
- package/dist/src/storage/sqlite/understanding-focus-exclusions.js +24 -0
- package/dist/src/tui/tui-scoped-models.js +9 -6
- package/dist/src/tui/tui-startup-resources.js +1 -1
- package/dist/src/voice/dashscope/streaming-tts-stream.js +49 -0
- package/dist/src/voice/realtime/agentEngine.js +63 -18
- package/dist/src/voice/realtime/conversationTurn.d.ts +20 -0
- package/dist/src/voice/realtime/conversationTurn.js +83 -0
- package/dist/src/voice/realtime/omniEngine.js +72 -18
- package/dist/src/workflows/authoring/workflow-draft-store.d.ts +1 -5
- package/dist/src/workflows/authoring/workflow-draft-store.js +23 -43
- package/dist/src/workflows/index.js +2 -2
- package/dist/src/workflows/store/event-store.d.ts +1 -2
- package/dist/src/workflows/store/event-store.js +19 -64
- package/dist/src/workflows/store/paths.d.ts +0 -2
- package/dist/src/workflows/store/paths.js +1 -7
- package/dist/src/workflows/store/run-store.d.ts +0 -1
- package/dist/src/workflows/store/run-store.js +1 -24
- package/package.json +3 -3
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-0dRjnL2s.js +0 -1
- package/dist/gateway/static/root/assets/apps-page-EpUZsl4h.js +0 -1
- package/dist/gateway/static/root/assets/automations-workspace-BGQdHrip.js +0 -6
- package/dist/gateway/static/root/assets/browser-settings-page-DJGcm7rH.js +0 -8
- package/dist/gateway/static/root/assets/channels-settings-BcIr-_GM.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-DNHqaZfX.js +0 -2
- package/dist/gateway/static/root/assets/home-page-CaVvW77l.js +0 -1
- package/dist/gateway/static/root/assets/index-Dbh5SXyV.css +0 -2
- package/dist/gateway/static/root/assets/local-app-workbench-page-D3K1XmOM.js +0 -2
- package/dist/gateway/static/root/assets/messages-BbdwoxVo.js +0 -3
- package/dist/gateway/static/root/assets/models-hub-cache-88f4fzYS.js +0 -1
- package/dist/gateway/static/root/assets/notes-workbench-CI30cDh3.js +0 -4
- package/dist/gateway/static/root/assets/project-detail-page-jO_4I5zN.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-BrTGFME0.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-CH70D5SH.js +0 -1
- package/dist/gateway/static/root/assets/sessions-page-hbfUNtNs.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-Vg3_jua6.js +0 -1
- package/dist/gateway/static/root/assets/setup-status-panel-DkcpWSss.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-BL4DEt6p.js +0 -1
- package/dist/gateway/static/root/assets/skill-reload-api-CafhNktn.js +0 -1
- package/dist/gateway/static/root/assets/task-detail-page-anyomXsu.js +0 -1
- package/dist/gateway/static/root/assets/user-context-page-BBk9YdBn.js +0 -1
- package/dist/gateway/static/root/assets/workflows-page-RUTv0yvR.js +0 -5
|
@@ -1,8 +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{p as i}from"./chunk-KS7C4IRE-BaASWQor.js";import{n as a,r as o}from"./popover-select-C-Hj-nXR.js";import{t as s}from"./circle-check-C23XjkUj.js";import{t as c}from"./cloud-C4-yfnnk.js";import{t as l}from"./download-Dk-ZjtO6.js";import{t as u}from"./external-link-DjqjBmc3.js";import{t as d}from"./globe-DSSGFWFn.js";import{t as f}from"./loader-circle-CifKLtgG.js";import{t as p}from"./copy-to-clipboard-HOJ79TWv.js";import{t as m}from"./messages-BbdwoxVo.js";import{a as h,i as g,n as _,r as v,s as y}from"./locale-store-CBoCuIMx.js";import{t as b}from"./cn-JdwAhgNB.js";import{t as x}from"./button-CtTvuElV.js";import{n as S,r as C}from"./gateway-config-swr-826dipyU.js";import{a as w,o as T,s as E}from"./form-field-width-DJw_jULe.js";import{Fi as D,Fl as O,Gs as k,Hs as A,Ii as j,Is as M,Ka as N,Ks as P,Li as F,Ol as I,Qa as L,Qt as R,Ss as z,Tl as B,Ts as V,bc as ee,cc as H,ec as U,eo as te,hl as W,ic as G,lc as ne,ms as re,ri as ie,sc as K,wl as ae}from"./index-eZjksPvq.js";import{n as oe,r as se,t as ce}from"./settings-page-layout-BRQNel6r.js";import{n as le}from"./settings-loading-skeleton-CAmWMaOT.js";import{n as ue,t as q}from"./settings-form-section-DjWzRk4z.js";import{n as de,t as fe}from"./use-autosave-DMvRu2XZ.js";import{t as pe}from"./page-tabs-BaEQMYm_.js";import{t as me}from"./settings-advanced-gate-Vg3_jua6.js";import{a as he,c as ge,d as _e,u as ve}from"./gateway-config-api-C_mlpe-r.js";import{t as ye}from"./tab-completion-input-D64VNmiA.js";var J=e(t(),1),Y=n(),X=r();function Z(e){let t=(0,Y.c)(8),{label:n,description:r,children:i}=e,a;t[0]===n?a=t[1]:(a=(0,X.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=(0,X.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:r}),t[2]=r,t[3]=o);let s;return t[4]!==i||t[5]!==a||t[6]!==o?(s=(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[a,i,o]}),t[4]=i,t[5]=a,t[6]=o,t[7]=s):s=t[7],s}function Q(){return b(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,E,`dark:border-edge`)}function be(){return b(T,w)}function xe(e){switch(e){case`ready`:return`bg-emerald-500`;case`not_installed`:case`checking`:return`bg-amber-500`;case`error`:return`bg-red-500`;default:return`bg-fg-subtle/60`}}function Se(e){let t=(0,Y.c)(28),{value:n,onChange:r,onOpenConfig:i,options:o,m:s}=e,c;if(t[0]!==s.browserGoToConfigure||t[1]!==s.browserPickerSubtitle||t[2]!==s.browserPickerTitle||t[3]!==r||t[4]!==i||t[5]!==o||t[6]!==n){let e=o.find(e=>e.value===n)??o[0],l;t[8]===s.browserPickerTitle?l=t[9]:(l=(0,X.jsx)(`label`,{htmlFor:`browser-backend-select`,className:`text-sm font-medium text-fg`,children:s.browserPickerTitle}),t[8]=s.browserPickerTitle,t[9]=l);let u;t[10]===s.browserPickerSubtitle?u=t[11]:(u=(0,X.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:s.browserPickerSubtitle}),t[10]=s.browserPickerSubtitle,t[11]=u);let d;t[12]!==l||t[13]!==u?(d=(0,X.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[l,u]}),t[12]=l,t[13]=u,t[14]=d):d=t[14];let f;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(f=b(be(),`min-w-0 flex-1 sm:max-w-md`),t[15]=f):f=t[15];let p;t[16]===r?p=t[17]:(p=e=>r(e.target.value),t[16]=r,t[17]=p);let m=s.browserPickerTitle,h;t[18]===o?h=t[19]:(h=o.map(Ce),t[18]=o,t[19]=h);let g;t[20]!==s.browserPickerTitle||t[21]!==p||t[22]!==h||t[23]!==n?(g=(0,X.jsx)(a,{id:`browser-backend-select`,className:f,value:n,onChange:p,"aria-label":m,children:h}),t[20]=s.browserPickerTitle,t[21]=p,t[22]=h,t[23]=n,t[24]=g):g=t[24];let _=i?(0,X.jsxs)(`button`,{type:`button`,className:b(`inline-flex shrink-0 items-center justify-center gap-1 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-xs font-medium text-accent`,`transition-colors hover:border-edge-strong hover:bg-surface-hover`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-base`),onClick:()=>i(n),"aria-label":`${e?.name??n} — ${s.browserGoToConfigure}`,children:[(0,X.jsx)(`span`,{children:s.browserGoToConfigure}),(0,X.jsx)(O,{className:`size-4 shrink-0`,"aria-hidden":!0})]}):null,v;t[25]!==_||t[26]!==g?(v=(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:gap-2`,children:[g,_]}),t[25]=_,t[26]=g,t[27]=v):v=t[27],c=(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[d,v,e?(0,X.jsxs)(`div`,{className:`flex flex-col gap-1.5 rounded-lg bg-surface-panel/80 px-3 py-2.5 shadow-surface`,children:[(0,X.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:e.statusLabel?(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-[11px] font-medium text-fg-muted`,"aria-label":e.statusLabel,children:[(0,X.jsx)(`span`,{className:b(`inline-block size-1.5 rounded-full`,xe(e.status)),"aria-hidden":!0}),e.statusLabel]}):null}),(0,X.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:e.tagline})]}):null]}),t[0]=s.browserGoToConfigure,t[1]=s.browserPickerSubtitle,t[2]=s.browserPickerTitle,t[3]=r,t[4]=i,t[5]=o,t[6]=n,t[7]=c}else c=t[7];return c}function Ce(e){return(0,X.jsx)(o,{value:e.value,children:e.name},e.value)}function we(e){return`browser-focus-${e}`}function Te(e){switch(e){case`connection`:case`extension`:case`local`:case`cloak`:case`cdp`:case`cloud`:case`runtime`:case`security`:return e;default:return null}}function Ee(e){let t=(0,Y.c)(95),{a:n,form:r,update:i}=e,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=we(`runtime`),t[0]=s):s=t[0];let c;t[1]===n.browserBehaviorShow?c=t[2]:(c=(0,X.jsx)(ue,{icon:A,title:n.browserBehaviorShow}),t[1]=n.browserBehaviorShow,t[2]=c);let l;t[3]===i?l=t[4]:(l=e=>i({browserHeadless:e.target.checked}),t[3]=i,t[4]=l);let u;t[5]!==r.browserHeadless||t[6]!==l?(u=(0,X.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:r.browserHeadless,onChange:l}),t[5]=r.browserHeadless,t[6]=l,t[7]=u):u=t[7];let d;t[8]===n.browserHeadlessOn?d=t[9]:(d=(0,X.jsx)(`span`,{children:n.browserHeadlessOn}),t[8]=n.browserHeadlessOn,t[9]=d);let f;t[10]!==u||t[11]!==d?(f=(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[u,d]}),t[10]=u,t[11]=d,t[12]=f):f=t[12];let p;t[13]!==n.desc.browserHeadless||t[14]!==n.label.browserHeadless||t[15]!==f?(p=(0,X.jsx)(Z,{label:n.label.browserHeadless,description:n.desc.browserHeadless,children:f}),t[13]=n.desc.browserHeadless,t[14]=n.label.browserHeadless,t[15]=f,t[16]=p):p=t[16];let m=n.label.browserDialogPolicy,h=n.desc.browserDialogPolicy,g;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(g=be(),t[17]=g):g=t[17];let _;t[18]===i?_=t[19]:(_=e=>i({browserDialogPolicy:e.target.value}),t[18]=i,t[19]=_);let v;t[20]===n.browserDialogPolicyMustRespond?v=t[21]:(v=(0,X.jsx)(o,{value:`must_respond`,children:n.browserDialogPolicyMustRespond}),t[20]=n.browserDialogPolicyMustRespond,t[21]=v);let y;t[22]===n.browserDialogPolicyAutoDismiss?y=t[23]:(y=(0,X.jsx)(o,{value:`auto_dismiss`,children:n.browserDialogPolicyAutoDismiss}),t[22]=n.browserDialogPolicyAutoDismiss,t[23]=y);let b;t[24]===n.browserDialogPolicyAutoAccept?b=t[25]:(b=(0,X.jsx)(o,{value:`auto_accept`,children:n.browserDialogPolicyAutoAccept}),t[24]=n.browserDialogPolicyAutoAccept,t[25]=b);let x;t[26]!==r.browserDialogPolicy||t[27]!==_||t[28]!==v||t[29]!==y||t[30]!==b?(x=(0,X.jsxs)(a,{className:g,value:r.browserDialogPolicy,onChange:_,children:[v,y,b]}),t[26]=r.browserDialogPolicy,t[27]=_,t[28]=v,t[29]=y,t[30]=b,t[31]=x):x=t[31];let S;t[32]!==n.desc.browserDialogPolicy||t[33]!==n.label.browserDialogPolicy||t[34]!==x?(S=(0,X.jsx)(Z,{label:m,description:h,children:x}),t[32]=n.desc.browserDialogPolicy,t[33]=n.label.browserDialogPolicy,t[34]=x,t[35]=S):S=t[35];let C=n.label.browserDialogTimeout,w=n.desc.browserDialogTimeout,T;t[36]===Symbol.for(`react.memo_cache_sentinel`)?(T=Q(),t[36]=T):T=t[36];let E=r.browserDialogTimeout??``,D;t[37]===i?D=t[38]:(D=e=>i({browserDialogTimeout:Number.parseInt(e,10)}),t[37]=i,t[38]=D);let O;t[39]===i?O=t[40]:(O=e=>{let t=e.target.value;i({browserDialogTimeout:t===``?void 0:Number.parseInt(t,10)})},t[39]=i,t[40]=O);let k;t[41]!==E||t[42]!==D||t[43]!==O?(k=(0,X.jsx)(ye,{type:`number`,className:T,min:1,value:E,suggestion:`300`,onAcceptSuggestion:D,placeholder:`300`,onChange:O}),t[41]=E,t[42]=D,t[43]=O,t[44]=k):k=t[44];let j;t[45]!==n.desc.browserDialogTimeout||t[46]!==n.label.browserDialogTimeout||t[47]!==k?(j=(0,X.jsx)(Z,{label:C,description:w,children:k}),t[45]=n.desc.browserDialogTimeout,t[46]=n.label.browserDialogTimeout,t[47]=k,t[48]=j):j=t[48];let M;t[49]!==S||t[50]!==j||t[51]!==p?(M=(0,X.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[p,S,j]}),t[49]=S,t[50]=j,t[51]=p,t[52]=M):M=t[52];let N;t[53]!==c||t[54]!==M?(N=(0,X.jsx)(`div`,{id:s,className:`scroll-mt-24`,children:(0,X.jsxs)(q,{children:[c,M]})}),t[53]=c,t[54]=M,t[55]=N):N=t[55];let F;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(F=we(`security`),t[56]=F):F=t[56];let I;t[57]===n.browserSecurityShow?I=t[58]:(I=(0,X.jsx)(ue,{icon:P,title:n.browserSecurityShow}),t[57]=n.browserSecurityShow,t[58]=I);let L;t[59]===i?L=t[60]:(L=e=>i({browserAllowPrivateUrls:e.target.checked}),t[59]=i,t[60]=L);let R;t[61]!==r.browserAllowPrivateUrls||t[62]!==L?(R=(0,X.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:r.browserAllowPrivateUrls,onChange:L}),t[61]=r.browserAllowPrivateUrls,t[62]=L,t[63]=R):R=t[63];let z;t[64]===n.browserAllowPrivateOn?z=t[65]:(z=(0,X.jsx)(`span`,{children:n.browserAllowPrivateOn}),t[64]=n.browserAllowPrivateOn,t[65]=z);let B;t[66]!==R||t[67]!==z?(B=(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[R,z]}),t[66]=R,t[67]=z,t[68]=B):B=t[68];let V;t[69]!==n.desc.browserAllowPrivateUrls||t[70]!==n.label.browserAllowPrivateUrls||t[71]!==B?(V=(0,X.jsx)(Z,{label:n.label.browserAllowPrivateUrls,description:n.desc.browserAllowPrivateUrls,children:B}),t[69]=n.desc.browserAllowPrivateUrls,t[70]=n.label.browserAllowPrivateUrls,t[71]=B,t[72]=V):V=t[72];let ee=n.label.browserCommandTimeout,H=n.desc.browserCommandTimeout,U;t[73]===Symbol.for(`react.memo_cache_sentinel`)?(U=Q(),t[73]=U):U=t[73];let te=r.browserCommandTimeout??``,W;t[74]===i?W=t[75]:(W=e=>i({browserCommandTimeout:Number.parseInt(e,10)}),t[74]=i,t[75]=W);let G;t[76]===i?G=t[77]:(G=e=>{let t=e.target.value;i({browserCommandTimeout:t===``?void 0:Number.parseInt(t,10)})},t[76]=i,t[77]=G);let ne;t[78]!==te||t[79]!==W||t[80]!==G?(ne=(0,X.jsx)(ye,{type:`number`,className:U,min:5,value:te,suggestion:`30`,onAcceptSuggestion:W,placeholder:`30`,onChange:G}),t[78]=te,t[79]=W,t[80]=G,t[81]=ne):ne=t[81];let re;t[82]!==n.desc.browserCommandTimeout||t[83]!==n.label.browserCommandTimeout||t[84]!==ne?(re=(0,X.jsx)(Z,{label:ee,description:H,children:ne}),t[82]=n.desc.browserCommandTimeout,t[83]=n.label.browserCommandTimeout,t[84]=ne,t[85]=re):re=t[85];let ie;t[86]!==V||t[87]!==re?(ie=(0,X.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[V,re]}),t[86]=V,t[87]=re,t[88]=ie):ie=t[88];let K;t[89]!==I||t[90]!==ie?(K=(0,X.jsx)(`div`,{id:F,className:`scroll-mt-24`,children:(0,X.jsxs)(q,{className:`border border-amber-500/20`,children:[I,ie]})}),t[89]=I,t[90]=ie,t[91]=K):K=t[91];let ae;return t[92]!==N||t[93]!==K?(ae=(0,X.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[N,K]}),t[92]=N,t[93]=K,t[94]=ae):ae=t[94],ae}function De(e){let t=(0,Y.c)(9),{language:n,label:r,className:i}=e,a;t[0]===n?a=t[1]:(a=N(n),t[0]=n,t[1]=a);let o;t[2]===i?o=t[3]:(o=b(`inline-flex items-center gap-1 text-xs font-medium text-accent hover:underline`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`,i),t[2]=i,t[3]=o);let s;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,X.jsx)(u,{className:`size-3 shrink-0`,"aria-hidden":!0}),t[4]=s):s=t[4];let c;return t[5]!==r||t[6]!==a||t[7]!==o?(c=(0,X.jsxs)(`a`,{href:a,target:`_blank`,rel:`noreferrer`,className:o,children:[r,s]}),t[5]=r,t[6]=a,t[7]=o,t[8]=c):c=t[8],c}function Oe(e){let t=(0,Y.c)(27),{title:n,description:r,recommended:i,recommendedLabel:a,icon:o,onSelect:s,selectLabel:c}=e,l=`${n} — ${c}`,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=b(`group flex w-full flex-col rounded-xl bg-surface-panel/80 p-3 text-left shadow-surface transition-colors`,`hover:bg-surface-hover/40`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),t[0]=u):u=t[0];let d;t[1]===o?d=t[2]:(d=(0,X.jsx)(`span`,{className:`flex size-8 shrink-0 items-center justify-center rounded-lg bg-surface-hover text-fg-muted`,children:(0,X.jsx)(o,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0})}),t[1]=o,t[2]=d);let f;t[3]===n?f=t[4]:(f=(0,X.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n}),t[3]=n,t[4]=f);let p;t[5]!==i||t[6]!==a?(p=i&&a?(0,X.jsx)(`span`,{className:`rounded-full bg-accent/15 px-2 py-0.5 text-[10px] font-medium text-accent`,children:a}):null,t[5]=i,t[6]=a,t[7]=p):p=t[7];let m;t[8]!==f||t[9]!==p?(m=(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[f,p]}),t[8]=f,t[9]=p,t[10]=m):m=t[10];let h;t[11]===r?h=t[12]:(h=(0,X.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:r}),t[11]=r,t[12]=h);let g;t[13]!==m||t[14]!==h?(g=(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[m,h]}),t[13]=m,t[14]=h,t[15]=g):g=t[15];let _;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,X.jsx)(O,{className:`mt-0.5 size-4 shrink-0 text-fg-subtle transition-transform group-hover:translate-x-0.5`,"aria-hidden":!0}),t[16]=_):_=t[16];let v;t[17]!==d||t[18]!==g?(v=(0,X.jsxs)(`div`,{className:`flex items-start gap-3`,children:[d,g,_]}),t[17]=d,t[18]=g,t[19]=v):v=t[19];let y;t[20]===c?y=t[21]:(y=(0,X.jsx)(`span`,{className:`mt-2 text-[11px] font-medium text-accent`,children:c}),t[20]=c,t[21]=y);let x;return t[22]!==s||t[23]!==l||t[24]!==v||t[25]!==y?(x=(0,X.jsxs)(`button`,{type:`button`,onClick:s,"aria-label":l,className:u,children:[v,y]}),t[22]=s,t[23]=l,t[24]=v,t[25]=y,t[26]=x):x=t[26],x}function ke(e){let t=(0,Y.c)(25),{m:n,onStart:r}=e,i=R(Ae),a;t[0]!==n.browserBackendCloakBrowser||t[1]!==n.browserModeCloakTagline||t[2]!==n.browserSetupCloudDesc||t[3]!==n.browserSetupCloudTitle||t[4]!==n.browserSetupExtDesc||t[5]!==n.browserSetupExtTitle||t[6]!==n.browserSetupLocalDesc||t[7]!==n.browserSetupLocalTitle||t[8]!==i?(a=[{id:`extension`,icon:G,title:n.browserSetupExtTitle,description:n.browserSetupExtDesc,recommended:!0},{id:`cloakbrowser`,icon:k,title:n.browserBackendCloakBrowser,description:n.browserModeCloakTagline},{id:`local`,icon:ee,title:n.browserSetupLocalTitle,description:n.browserSetupLocalDesc},{id:`cloud`,icon:c,title:n.browserSetupCloudTitle,description:n.browserSetupCloudDesc}].filter(e=>ve(e.id,i)),t[0]=n.browserBackendCloakBrowser,t[1]=n.browserModeCloakTagline,t[2]=n.browserSetupCloudDesc,t[3]=n.browserSetupCloudTitle,t[4]=n.browserSetupExtDesc,t[5]=n.browserSetupExtTitle,t[6]=n.browserSetupLocalDesc,t[7]=n.browserSetupLocalTitle,t[8]=i,t[9]=a):a=t[9];let o=a,s;t[10]===n.browserSetupTitle?s=t[11]:(s=(0,X.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.browserSetupTitle}),t[10]=n.browserSetupTitle,t[11]=s);let l;t[12]===n.browserSetupSubtitle?l=t[13]:(l=(0,X.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:n.browserSetupSubtitle}),t[12]=n.browserSetupSubtitle,t[13]=l);let u;t[14]!==s||t[15]!==l?(u=(0,X.jsxs)(`div`,{children:[s,l]}),t[14]=s,t[15]=l,t[16]=u):u=t[16];let d;t[17]!==n.browserSetupRecommended||t[18]!==n.browserSetupSelect||t[19]!==o||t[20]!==r?(d=(0,X.jsx)(`div`,{className:`flex flex-col gap-2`,children:o.map(e=>(0,X.jsx)(Oe,{icon:e.icon,title:e.title,description:e.description,recommended:e.recommended,recommendedLabel:n.browserSetupRecommended,selectLabel:n.browserSetupSelect,onSelect:()=>r(e.id)},e.id))}),t[17]=n.browserSetupRecommended,t[18]=n.browserSetupSelect,t[19]=o,t[20]=r,t[21]=d):d=t[21];let f;return t[22]!==u||t[23]!==d?(f=(0,X.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl bg-surface-base p-4`,children:[u,d]}),t[22]=u,t[23]=d,t[24]=f):f=t[24],f}function Ae(e){return e.mode}function je(e){if(e.kind===`loading`)return`checking`;if(e.kind===`error`)return`error`;if(e.kind===`ok`)return e.data.installed?`ready`:`not_installed`}function Me(e,t){if(e)return{ready:t.browserStatusReady,not_installed:t.browserStatusNotInstalled,checking:t.browserStatusChecking,unknown:t.browserStatusUnknown,error:t.browserStatusError}[e]}function Ne(e){if(e.kind!==`idle`)return e.kind===`loading`?`checking`:e.kind===`error`?`error`:e.data.connected?`ready`:(e.data.running,`not_installed`)}function Pe(e,t){if(e.kind!==`idle`)return e.kind===`loading`?t.browserStatusChecking:e.kind===`error`?t.browserStatusError:e.data.connected?t.browserExtensionConnected:e.data.running?t.browserExtensionWaiting:t.browserExtensionServerOff}var Fe=[`overview`,`extension`,`local`,`cloakbrowser`,`cdp`,`cloud`],Ie=[`extension`,`local`,`cloakbrowser`,`cdp`,`cloud`],Le={connection:`overview`,extension:`extension`,local:`local`,cloak:`cloakbrowser`,cdp:`cdp`,cloud:`cloud`,runtime:`overview`,security:`overview`};function Re(e){let t=(e??``).trim();return t===`behavior`?`overview`:Fe.includes(t)?t:`overview`}function ze(e){return Ie.includes(e)}function Be(e){let t=(0,Y.c)(46),{icon:n,title:r,description:i,status:a,statusDetail:o,primaryAction:s,children:c,advanced:l,m:u,embedded:d,sectionTitle:f,advancedTitle:p}=e,m=d===void 0?!1:d,h;t[0]!==l||t[1]!==p?(h=l?(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[p?(0,X.jsx)(`h4`,{className:`text-sm font-medium text-fg`,children:p}):null,l]}):null,t[0]=l,t[1]=p,t[2]=h):h=t[2];let g=h;if(m){let e;t[3]!==i||t[4]!==f?(e=f?(0,X.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,X.jsx)(`h4`,{className:`text-sm font-medium text-fg`,children:f}),i?(0,X.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:i}):null]}):null,t[3]=i,t[4]=f,t[5]=e):e=t[5];let n;t[6]!==u||t[7]!==s||t[8]!==a||t[9]!==o?(n=a||s?(0,X.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[a?(0,X.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,X.jsx)(Ve,{kind:a,detail:o,m:u})}):(0,X.jsx)(`span`,{}),s?(0,X.jsx)(`div`,{className:`shrink-0`,children:s}):null]}):null,t[6]=u,t[7]=s,t[8]=a,t[9]=o,t[10]=n):n=t[10];let r;t[11]===c?r=t[12]:(r=c?(0,X.jsx)(`div`,{className:`flex flex-col gap-4`,children:c}):null,t[11]=c,t[12]=r);let l;return t[13]!==g||t[14]!==e||t[15]!==n||t[16]!==r?(l=(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[e,n,r,g]}),t[13]=g,t[14]=e,t[15]=n,t[16]=r,t[17]=l):l=t[17],l}let _;t[18]===n?_=t[19]:(_=(0,X.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-hover text-fg-muted`,children:(0,X.jsx)(n,{className:`size-4`,strokeWidth:1.75})}),t[18]=n,t[19]=_);let v;t[20]===r?v=t[21]:(v=(0,X.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:r}),t[20]=r,t[21]=v);let y;t[22]!==u||t[23]!==a||t[24]!==o?(y=a?(0,X.jsx)(Ve,{kind:a,detail:o,m:u}):null,t[22]=u,t[23]=a,t[24]=o,t[25]=y):y=t[25];let b;t[26]!==v||t[27]!==y?(b=(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[v,y]}),t[26]=v,t[27]=y,t[28]=b):b=t[28];let x;t[29]===i?x=t[30]:(x=(0,X.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:i}),t[29]=i,t[30]=x);let S;t[31]!==b||t[32]!==x?(S=(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[b,x]}),t[31]=b,t[32]=x,t[33]=S):S=t[33];let C;t[34]===s?C=t[35]:(C=s?(0,X.jsx)(`div`,{className:`shrink-0`,children:s}):null,t[34]=s,t[35]=C);let w;t[36]!==_||t[37]!==S||t[38]!==C?(w=(0,X.jsxs)(`div`,{className:`flex items-start gap-3`,children:[_,S,C]}),t[36]=_,t[37]=S,t[38]=C,t[39]=w):w=t[39];let T;t[40]===c?T=t[41]:(T=c?(0,X.jsx)(`div`,{className:`flex flex-col gap-4`,children:c}):null,t[40]=c,t[41]=T);let E;return t[42]!==g||t[43]!==w||t[44]!==T?(E=(0,X.jsxs)(`div`,{className:`flex flex-col gap-4 rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:[w,T,g]}),t[42]=g,t[43]=w,t[44]=T,t[45]=E):E=t[45],E}function Ve(e){let t=(0,Y.c)(27),{kind:n,detail:r,m:i}=e,a,o,c,l;if(t[0]!==n||t[1]!==i.browserStatusChecking||t[2]!==i.browserStatusError||t[3]!==i.browserStatusNotInstalled||t[4]!==i.browserStatusReady||t[5]!==i.browserStatusUnknown){let{icon:e,color:r,label:u}={ready:{icon:s,color:`text-green-600 dark:text-green-400`,label:i.browserStatusReady},not_installed:{icon:V,color:`text-amber-600 dark:text-amber-400`,label:i.browserStatusNotInstalled},checking:{icon:f,color:`text-fg-muted`,label:i.browserStatusChecking},unknown:{icon:I,color:`text-fg-muted`,label:i.browserStatusUnknown},error:{icon:B,color:`text-red-600 dark:text-red-400`,label:i.browserStatusError}}[n];a=e,o=u,l=`inline-flex min-w-0 flex-col items-start gap-1`,c=b(`inline-flex shrink-0 items-center gap-1 whitespace-nowrap text-xs font-medium`,r),t[0]=n,t[1]=i.browserStatusChecking,t[2]=i.browserStatusError,t[3]=i.browserStatusNotInstalled,t[4]=i.browserStatusReady,t[5]=i.browserStatusUnknown,t[6]=a,t[7]=o,t[8]=c,t[9]=l}else a=t[6],o=t[7],c=t[8],l=t[9];let u=n===`checking`&&`animate-spin`,d;t[10]===u?d=t[11]:(d=b(`size-3.5 shrink-0`,u),t[10]=u,t[11]=d);let p;t[12]!==a||t[13]!==d?(p=(0,X.jsx)(a,{className:d}),t[12]=a,t[13]=d,t[14]=p):p=t[14];let m;t[15]===o?m=t[16]:(m=(0,X.jsx)(`span`,{children:o}),t[15]=o,t[16]=m);let h;t[17]!==c||t[18]!==p||t[19]!==m?(h=(0,X.jsxs)(`span`,{className:c,children:[p,m]}),t[17]=c,t[18]=p,t[19]=m,t[20]=h):h=t[20];let g;t[21]===r?g=t[22]:(g=r?(0,X.jsx)(`span`,{className:`break-all font-mono text-[11px] leading-snug text-fg-subtle`,children:r}):null,t[21]=r,t[22]=g);let _;return t[23]!==l||t[24]!==h||t[25]!==g?(_=(0,X.jsxs)(`span`,{className:l,children:[h,g]}),t[23]=l,t[24]=h,t[25]=g,t[26]=_):_=t[26],_}function He(e){let t=(0,Y.c)(5),{kind:n,message:r}=e,i=n===`success`?`border-green-500/30 bg-green-500/10 text-green-700 dark:text-green-300`:`border-red-500/30 bg-red-500/10 text-red-600 dark:text-red-300`,a;t[0]===i?a=t[1]:(a=b(`rounded-lg border px-3 py-2 text-xs leading-relaxed`,i),t[0]=i,t[1]=a);let o;return t[2]!==r||t[3]!==a?(o=(0,X.jsx)(`div`,{className:a,children:r}),t[2]=r,t[3]=a,t[4]=o):o=t[4],o}var Ue={instances:[],launchStatus:`idle`,launchMessage:null,testStatus:`idle`,testMessage:null,executablePath:``};function We({m:e,cdpUrl:t,onCdpUrlChange:n,launch:r,stop:i,listInstances:a,ping:o,embedded:s=!1}){let[c,l]=(0,J.useReducer)(F,Ue),{instances:u,launchStatus:d,launchMessage:p,testStatus:m,testMessage:h,executablePath:g}=c,_=(0,J.useCallback)(async()=>{try{l({type:`patch`,patch:{instances:await a()}})}catch{}},[a]);(0,J.useEffect)(()=>{_();let e=setInterval(()=>void _(),8e3);return()=>clearInterval(e)},[_]);let v=(0,J.useCallback)(async()=>{if(d!==`pending`){l({type:`patch`,patch:{launchStatus:`pending`,launchMessage:null}});try{let t=await r(g.trim()||void 0);l({type:`patch`,patch:{launchStatus:`ok`,launchMessage:e.browserCdpLaunchedAtPort.replace(`{{port}}`,String(t.port))}}),n(t.wsEndpoint),await _()}catch(e){l({type:`patch`,patch:{launchStatus:`error`,launchMessage:e instanceof Error?e.message:String(e)}})}}},[g,r,d,e.browserCdpLaunchedAtPort,n,_]),y=(0,J.useCallback)(async e=>{await i(e),await _()},[_,i]),b=(0,J.useCallback)(async()=>{if(t.trim()){l({type:`patch`,patch:{testStatus:`pending`,testMessage:null}});try{let n=await o(t.trim());n.reachable?l({type:`patch`,patch:{testStatus:`ok`,testMessage:e.browserCdpReachable.replace(`{{browser}}`,n.browser??`—`)}}):l({type:`patch`,patch:{testStatus:`error`,testMessage:e.browserCdpUnreachable.replace(`{{error}}`,n.error??`—`)}})}catch(t){l({type:`patch`,patch:{testStatus:`error`,testMessage:e.browserCdpUnreachable.replace(`{{error}}`,t instanceof Error?t.message:String(t))}})}}},[t,e.browserCdpReachable,e.browserCdpUnreachable,o]);return(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,X.jsxs)(Be,{icon:H,title:e.browserCdpLaunchLocal,description:e.browserCdpLaunchLocalDesc,m:e,embedded:s,sectionTitle:s?e.browserCdpLaunchLocal:void 0,primaryAction:(0,X.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:d===`pending`,onClick:()=>void v(),children:[d===`pending`?(0,X.jsx)(f,{className:`size-3.5 animate-spin`}):(0,X.jsx)(H,{className:`size-3.5`}),d===`pending`?e.browserCdpLaunching:e.browserCdpLaunchLocal]}),children:[p?(0,X.jsx)(He,{kind:d===`error`?`error`:`success`,message:p}):null,(0,X.jsx)(Z,{label:e.browserCdpChromePath,description:e.browserCdpChromePathDesc,children:(0,X.jsx)(`input`,{type:`text`,className:Q(),value:g,placeholder:`/Applications/Google Chrome.app/Contents/MacOS/Google Chrome`,onChange:e=>l({type:`patch`,patch:{executablePath:e.target.value}}),autoComplete:`off`})}),u.length>0?(0,X.jsx)(`div`,{className:`flex flex-col gap-2 rounded-lg bg-surface-base p-3 shadow-surface`,children:u.map(t=>(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,X.jsxs)(`span`,{className:`font-mono text-fg`,children:[`port `,t.port,` · pid `,t.pid]}),(0,X.jsx)(`span`,{className:`truncate text-fg-subtle`,children:t.wsEndpoint})]}),(0,X.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1 rounded-md border border-edge bg-surface-panel px-2 py-1 text-xs font-medium text-fg hover:bg-surface-raised`,onClick:()=>void y(t.port),children:[(0,X.jsx)(M,{className:`size-3`}),e.browserCdpStopLocal]})]},t.port))}):null]}),(0,X.jsxs)(Be,{icon:re,title:e.label.browserCdpUrl,description:e.desc.browserCdpUrl,m:e,embedded:s,sectionTitle:s?e.label.browserCdpUrl:void 0,primaryAction:(0,X.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:!t.trim()||m===`pending`,onClick:()=>void b(),children:[m===`pending`?(0,X.jsx)(f,{className:`size-3.5 animate-spin`}):(0,X.jsx)(K,{className:`size-3.5`}),m===`pending`?e.browserCdpTesting:e.browserCdpTestConnection]}),children:[(0,X.jsx)(`input`,{type:`text`,className:Q(),value:t,placeholder:`ws://127.0.0.1:9222`,onChange:e=>n(e.target.value),autoComplete:`off`}),(0,X.jsx)(`p`,{className:`text-[11px] text-fg-subtle`,children:e.browserCdpLoopbackOnly}),h?(0,X.jsx)(He,{kind:m===`error`?`error`:`success`,message:h}):null]})]})}function Ge(e,t){let n=t.phase;if(!n)return e.browserInstallPhaseStarting;if(n===`downloading`)return t.percent==null?e.browserInstallPhaseDownloading:e.browserInstallPhaseDownloadingPercent.replace(`{{percent}}`,String(t.percent));switch(n){case`starting`:return e.browserInstallPhaseStarting;case`verifying`:return e.browserInstallPhaseVerifying;case`extracting`:return e.browserInstallPhaseExtracting;case`running`:return t.message??e.browserInstallPhaseRunning;case`ready`:return e.browserInstallPhaseReady;default:return t.message??e.browserInstallPhaseRunning}}function Ke(e){let t=(0,Y.c)(32),{m:n,progress:r,showLogs:i,onCancel:a,cancelling:o}=e,s=i===void 0?!1:i,c=o===void 0?!1:o;if(!r.phase)return null;let l;t[0]!==n||t[1]!==r?(l=Ge(n,r),t[0]=n,t[1]=r,t[2]=l):l=t[2];let u=l,d=r.percent==null?(r.phase===`extracting`||r.phase===`verifying`||r.phase===`running`||r.phase,null):Math.min(100,Math.max(0,r.percent)),f;t[3]===u?f=t[4]:(f=(0,X.jsx)(`span`,{className:`text-fg`,children:u}),t[3]=u,t[4]=f);let p;t[5]===d?p=t[6]:(p=d==null?null:(0,X.jsxs)(`span`,{className:`tabular-nums`,children:[d,`%`]}),t[5]=d,t[6]=p);let m;t[7]!==c||t[8]!==n||t[9]!==a?(m=a?(0,X.jsx)(`button`,{type:`button`,className:`rounded-md border border-edge px-2 py-0.5 text-[11px] font-medium text-fg-muted hover:bg-surface-raised hover:text-fg disabled:cursor-not-allowed disabled:opacity-60`,disabled:c,onClick:()=>void a(),children:c?n.browserInstallCancelling:n.browserInstallCancel}):null,t[7]=c,t[8]=n,t[9]=a,t[10]=m):m=t[10];let h;t[11]!==p||t[12]!==m?(h=(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[p,m]}),t[11]=p,t[12]=m,t[13]=h):h=t[13];let g;t[14]!==f||t[15]!==h?(g=(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2 text-xs text-fg-muted`,children:[f,h]}),t[14]=f,t[15]=h,t[16]=g):g=t[16];let _;t[17]===d?_=t[18]:(_=(0,X.jsx)(`div`,{className:`h-1.5 overflow-hidden rounded-full bg-surface-raised`,children:d==null?(0,X.jsx)(`div`,{className:`h-full w-1/3 animate-pulse rounded-full bg-accent/70`}):(0,X.jsx)(`div`,{className:`h-full rounded-full bg-accent transition-[width] duration-300 ease-out`,style:{width:`${d}%`}})}),t[17]=d,t[18]=_);let v;t[19]!==r.lines||t[20]!==s?(v=s&&r.lines.length>0?(0,X.jsx)(`div`,{className:`max-h-28 overflow-y-auto rounded-md bg-surface-panel px-2 py-1.5 font-mono text-[10px] leading-relaxed text-fg-muted shadow-surface`,children:r.lines.map(qe)}):null,t[19]=r.lines,t[20]=s,t[21]=v):v=t[21];let y;t[22]!==r.message||t[23]!==r.percent||t[24]!==r.phase||t[25]!==s?(y=!s&&r.phase===`downloading`&&r.message&&r.percent==null?(0,X.jsx)(`p`,{className:`text-[11px] text-fg-subtle`,children:r.message}):null,t[22]=r.message,t[23]=r.percent,t[24]=r.phase,t[25]=s,t[26]=y):y=t[26];let b;return t[27]!==v||t[28]!==y||t[29]!==g||t[30]!==_?(b=(0,X.jsxs)(`div`,{className:`space-y-2 rounded-lg bg-surface-base px-3 py-2.5 shadow-surface`,children:[g,_,v,y]}),t[27]=v,t[28]=y,t[29]=g,t[30]=_,t[31]=b):b=t[31],b}function qe(e){return(0,X.jsx)(`div`,{className:`truncate`,children:e},e)}var Je={confirmOpen:!1,installStatus:`idle`,installMessage:null,openStatus:`idle`,openMessage:null,runtime:null};function Ye({m:e,doctor:t,refetch:n,applyDoctor:r,installStream:i,fetchRuntimeStatus:c,launchCloak:u,form:d,onChange:p,embedded:m=!1}){let[h,g]=(0,J.useReducer)(F,Je),{confirmOpen:_,installStatus:v,installMessage:y,openStatus:b,openMessage:x,runtime:S}=h,{progress:C,running:w,cancelling:T,run:E,reset:D,cancel:O}=i,A=t.kind===`ok`?t.data:null,j=A?.installed===!0,M=v===`installing`||w,N=(0,J.useCallback)(async()=>{if(j)try{g({type:`patch`,patch:{runtime:await c()}})}catch{}},[c,j]);(0,J.useEffect)(()=>{if(!j){g({type:`patch`,patch:{runtime:null}});return}N();let e=setInterval(()=>void N(),8e3);return()=>clearInterval(e)},[j,N]);let P=(0,J.useCallback)(async()=>{g({type:`patch`,patch:{confirmOpen:!1,installStatus:`installing`,installMessage:null}}),D();let t=await E({body:{cacheDir:d.cacheDir.trim()||void 0,binaryPath:d.binaryPath.trim()||void 0},fallbackError:e.browserCloakInstallFailed});if(!t.ok){if(t.error===`busy`){g({type:`patch`,patch:{installStatus:`installing`}});return}if(t.error===`cancelled`){g({type:`patch`,patch:{installStatus:`idle`,installMessage:null}}),D();return}g({type:`patch`,patch:{installStatus:`failed`,installMessage:t.errorMessage??e.browserCloakInstallFailed}});return}t.payload&&r?.(t.payload),g({type:`patch`,patch:{installStatus:`installed`,installMessage:t.payload?.binaryPath?`${e.browserCloakInstalled}: ${t.payload.binaryPath}`:e.browserCloakInstalled}}),await n({cacheDir:d.cacheDir,binaryPath:d.binaryPath}),await N()},[r,d.binaryPath,d.cacheDir,e.browserCloakInstallFailed,e.browserCloakInstalled,n,N,D,E]),I=(0,J.useCallback)(async()=>{if(b!==`pending`){g({type:`patch`,patch:{openStatus:`pending`,openMessage:null}});try{let t=await u();g({type:`patch`,patch:{openStatus:`ok`,openMessage:t.reused?e.browserCloakOpenReused.replace(`{{port}}`,String(t.port)):e.browserCloakOpenLaunched.replace(`{{port}}`,String(t.port)),runtime:t}})}catch(e){g({type:`patch`,patch:{openStatus:`error`,openMessage:e instanceof Error?e.message:String(e)}})}}},[u,e.browserCloakOpenLaunched,e.browserCloakOpenReused,b]),L=t.kind===`loading`?`checking`:t.kind===`error`?`error`:j?`ready`:`not_installed`,R=j&&A?.version?`v${A.version} (${A.platform})`:void 0;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(Be,{icon:k,title:e.browserCloakGuideTitle,description:e.browserCloakGuideDesc,status:L,statusDetail:R,m:e,embedded:m,primaryAction:(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[j?(0,X.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:b===`pending`,onClick:()=>void I(),children:[b===`pending`?(0,X.jsx)(f,{className:`size-3.5 animate-spin`}):(0,X.jsx)(H,{className:`size-3.5`}),b===`pending`?e.browserCloakOpening:e.browserCloakOpen]}):null,(0,X.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:M,onClick:()=>g({type:`patch`,patch:{confirmOpen:!0}}),children:[M?(0,X.jsx)(f,{className:`size-3.5 animate-spin`}):j?(0,X.jsx)(U,{className:`size-3.5`}):v===`installed`?(0,X.jsx)(s,{className:`size-3.5 text-green-500`}):(0,X.jsx)(l,{className:`size-3.5`}),M?e.browserCloakInstalling:j?e.browserReinstall:e.browserCloakDownload]})]}),children:[w?(0,X.jsx)(Ke,{m:e,progress:C,cancelling:T,onCancel:()=>void O()}):null,y?(0,X.jsx)(He,{kind:v===`failed`?`error`:`success`,message:y}):null,x?(0,X.jsx)(He,{kind:b===`error`?`error`:`success`,message:x}):null,j&&S?(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg bg-surface-base p-3 shadow-surface`,children:[(0,X.jsx)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:(0,X.jsx)(`span`,{className:`font-medium text-fg`,children:S.running?e.browserCloakRuntimeRunning.replace(`{{port}}`,String(S.port)):e.browserCloakRuntimeOff})}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,X.jsx)(`span`,{className:`text-fg-subtle`,children:e.browserCloakProfileLabel}),(0,X.jsx)(`span`,{className:`break-all font-mono text-[11px] text-fg-muted`,children:S.userDataDir})]}),(0,X.jsx)(`p`,{className:`text-[11px] leading-relaxed text-fg-subtle`,children:e.browserCloakProfileAgentHint}),S.temporaryProfile?(0,X.jsx)(`p`,{className:`text-[11px] text-amber-600 dark:text-amber-400`,children:e.browserCloakTemporaryProfileHint}):null]}):null,(0,X.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,X.jsx)(Z,{label:e.label.browserCloakKeepOpen,description:e.desc.browserCloakKeepOpen,children:(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,X.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:d.keepOpen,onChange:e=>p({keepOpen:e.target.checked})}),(0,X.jsx)(`span`,{children:e.browserCloakKeepOpenOn})]})}),(0,X.jsx)(Z,{label:e.label.browserCloakTemporaryProfile,description:e.desc.browserCloakTemporaryProfile,children:(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,X.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:d.temporaryProfile,onChange:e=>p({temporaryProfile:e.target.checked})}),(0,X.jsx)(`span`,{children:e.browserCloakTemporaryProfileOn})]})}),(0,X.jsx)(Z,{label:e.label.browserHumanize,description:e.desc.browserHumanize,children:(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[(0,X.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:d.humanize,onChange:e=>p({humanize:e.target.checked})}),(0,X.jsx)(`span`,{children:e.browserHumanizeOn})]})}),(0,X.jsx)(Z,{label:e.label.browserHumanPreset,description:e.desc.browserHumanPreset,children:(0,X.jsxs)(a,{className:be(),value:d.humanPreset,onChange:e=>p({humanPreset:e.target.value}),children:[(0,X.jsx)(o,{value:`careful`,children:e.browserHumanPresetCareful}),(0,X.jsx)(o,{value:`default`,children:e.browserHumanPresetDefault})]})})]})]}),(0,X.jsxs)(q,{className:`mt-4`,children:[(0,X.jsx)(ue,{icon:k,title:e.browserCloakAdvancedShow}),(0,X.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,X.jsxs)(Z,{label:e.label.browserCloakCacheDir,description:e.desc.browserCloakCacheDir,children:[(0,X.jsx)(`input`,{type:`text`,className:Q(),value:d.cacheDir,placeholder:`~/.xopc/bin/cloakbrowser`,onChange:e=>p({cacheDir:e.target.value}),autoComplete:`off`}),(0,X.jsx)(`p`,{className:`text-[11px] text-fg-subtle`,children:e.browserCacheDirHomeOnly})]}),(0,X.jsxs)(Z,{label:e.label.browserCloakBinaryPath,description:e.desc.browserCloakBinaryPath,children:[(0,X.jsx)(`input`,{type:`text`,className:Q(),value:d.binaryPath,placeholder:`~/.xopc/bin/cloakbrowser/chromium-v.../Chromium.app/Contents/MacOS/Chromium`,onChange:e=>p({binaryPath:e.target.value}),autoComplete:`off`}),d.binaryPath.trim()?(0,X.jsx)(`p`,{className:`text-[11px] text-amber-600 dark:text-amber-400`,children:e.browserBinaryPathWarning}):null]}),(0,X.jsx)(Z,{label:e.label.browserCloakTimezone,description:e.desc.browserCloakTimezone,children:(0,X.jsx)(`input`,{type:`text`,className:Q(),value:d.timezone,placeholder:`America/New_York`,onChange:e=>p({timezone:e.target.value}),autoComplete:`off`})}),(0,X.jsx)(Z,{label:e.label.browserCloakLocale,description:e.desc.browserCloakLocale,children:(0,X.jsx)(`input`,{type:`text`,className:Q(),value:d.locale,placeholder:`en-US`,onChange:e=>p({locale:e.target.value}),autoComplete:`off`})}),(0,X.jsx)(Z,{label:e.label.browserCloakWebrtcIp,description:e.desc.browserCloakWebrtcIp,children:(0,X.jsx)(`input`,{type:`text`,className:Q(),value:d.webrtcIp,placeholder:`203.0.113.10`,onChange:e=>p({webrtcIp:e.target.value}),autoComplete:`off`})}),(0,X.jsx)(Z,{label:e.label.browserCloakFingerprintPlatform,description:e.desc.browserCloakFingerprintPlatform,children:(0,X.jsx)(`input`,{type:`text`,className:Q(),value:d.fingerprintPlatform,placeholder:`macos`,onChange:e=>p({fingerprintPlatform:e.target.value}),autoComplete:`off`})}),(0,X.jsx)(`div`,{className:`sm:col-span-2`,children:(0,X.jsx)(Z,{label:e.label.browserCloakExtraArgs,description:e.desc.browserCloakExtraArgs,children:(0,X.jsx)(`textarea`,{className:Xe(),value:d.extraArgs,placeholder:`--disable-dev-shm-usage`,rows:3,onChange:e=>p({extraArgs:e.target.value})})})})]})]}),(0,X.jsx)(ie,{open:_,title:e.browserConfirmDownloadTitle,description:Ze(e,A),confirmLabel:e.browserConfirmDownloadConfirm,cancelLabel:e.browserConfirmDownloadCancel,onConfirm:()=>void P(),onCancel:()=>g({type:`patch`,patch:{confirmOpen:!1}})})]})}function Xe(){return`${Q()} min-h-[4.5rem] resize-y font-mono text-xs`}function Ze(e,t){if(!t)return e.browserConfirmDownloadBody;let n=[e.browserConfirmDownloadBody.replace(`{{version}}`,t.version??`—`).replace(`{{platform}}`,t.platform).replace(`{{url}}`,t.downloadUrl||`—`)];return t.expectedSha256?n.push(`SHA-256: ${t.expectedSha256.slice(0,16)}…`):n.push(e.browserCloakSha256Skipped),n.join(`
|
|
2
|
-
`)}function Qe({m:e,form:t,onChange:n,testCloud:r,embedded:i=!1}){let[s,l]=(0,J.useState)(`idle`),[u,d]=(0,J.useState)(null),p=t.provider===`local`?`browserbase`:t.provider,h=m(_(e=>e.language)).providersSettings,g=L({show:h.show,hide:h.hide,copy:h.copy,copied:h.copied}),v=(0,J.useCallback)(()=>he().then(e=>e.apiKey??null),[]),y=(0,J.useCallback)(async()=>{l(`pending`),d(null);try{let n=await r(p,t.apiKey);n.reachable?(l(`ok`),d(e.browserCloudTestOk)):(l(`error`),d(e.browserCloudTestFailed.replace(`{{error}}`,n.error??`—`)))}catch(t){l(`error`),d(e.browserCloudTestFailed.replace(`{{error}}`,t instanceof Error?t.message:String(t)))}},[t.apiKey,e.browserCloudTestFailed,e.browserCloudTestOk,p,r]);return(0,X.jsxs)(Be,{icon:c,title:e.label.browserCloudProvider,description:e.desc.browserCloudProvider,m:e,embedded:i,primaryAction:(0,X.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:s===`pending`,onClick:()=>void y(),children:[s===`pending`?(0,X.jsx)(f,{className:`size-3.5 animate-spin`}):(0,X.jsx)(K,{className:`size-3.5`}),e.browserCloudTestConnection]}),children:[(0,X.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,X.jsx)(Z,{label:e.label.browserCloudProvider,description:e.desc.browserCloudProvider,children:(0,X.jsxs)(a,{className:be(),value:p,onChange:e=>n({provider:e.target.value}),children:[(0,X.jsx)(o,{value:`browserbase`,children:e.browserCloudProviderBrowserbase}),(0,X.jsx)(o,{value:`browser-use`,children:e.browserCloudProviderBrowserUse})]})}),(0,X.jsx)(Z,{label:e.label.browserCloudApiKey,description:e.desc.browserCloudApiKey,children:(0,X.jsx)(te,{value:t.apiKey,onChange:e=>n({apiKey:e}),placeholder:p===`browserbase`?`BROWSERBASE_API_KEY`:`BROWSER_USE_API_KEY`,labels:g,reveal:v,loadFailedLabel:`Failed to load key`})}),p===`browserbase`?(0,X.jsx)(Z,{label:e.label.browserCloudProjectId,description:e.desc.browserCloudProjectId,children:(0,X.jsx)(`input`,{type:`text`,className:Q(),value:t.projectId,placeholder:`BROWSERBASE_PROJECT_ID`,onChange:e=>n({projectId:e.target.value}),autoComplete:`off`})}):null,(0,X.jsx)(Z,{label:e.label.browserCloudRegion,description:e.desc.browserCloudRegion,children:(0,X.jsx)(`input`,{type:`text`,className:Q(),value:t.region,placeholder:`us-west-2`,onChange:e=>n({region:e.target.value}),autoComplete:`off`})})]}),u?(0,X.jsx)(He,{kind:s===`error`?`error`:`success`,message:u}):null]})}function $e(e){let t=(0,Y.c)(48),{m:n,installed:r,extensionDir:i,connected:a,busy:o,onOpenChrome:c,onCopyPath:l,onRevealFolder:u,pathBusy:d,folderBusy:f}=e,p;t[0]!==r||t[1]!==n.browserExtensionInstallStep1?(p={id:`install`,label:n.browserExtensionInstallStep1,done:r},t[0]=r,t[1]=n.browserExtensionInstallStep1,t[2]=p):p=t[2];let m=!!i&&a,h;t[3]!==o||t[4]!==i||t[5]!==f||t[6]!==n.browserExtensionCopyPath||t[7]!==n.browserExtensionInstallStep2FolderLabel||t[8]!==n.browserExtensionInstalling||t[9]!==n.browserExtensionOpenChrome||t[10]!==n.browserExtensionRevealFolder||t[11]!==l||t[12]!==c||t[13]!==u||t[14]!==d?(h=i?(0,X.jsxs)(`div`,{className:`mt-2 rounded-md bg-surface-raised px-2.5 py-2 shadow-surface`,children:[(0,X.jsx)(`p`,{className:`text-[10px] font-medium uppercase tracking-wide text-fg-subtle`,children:n.browserExtensionInstallStep2FolderLabel}),(0,X.jsx)(`p`,{className:`mt-1 break-all font-mono text-[11px] text-fg`,children:i}),(0,X.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-3`,children:[(0,X.jsx)(`button`,{type:`button`,className:`inline-flex items-center gap-1 text-[11px] text-accent hover:underline disabled:opacity-60`,disabled:o,onClick:c,children:n.browserExtensionOpenChrome}),(0,X.jsx)(`button`,{type:`button`,className:`inline-flex items-center gap-1 text-[11px] text-accent hover:underline disabled:opacity-60`,disabled:o,onClick:l,title:i,children:d?n.browserExtensionInstalling:n.browserExtensionCopyPath}),(0,X.jsx)(`button`,{type:`button`,className:`inline-flex items-center gap-1 text-[11px] text-accent hover:underline disabled:opacity-60`,disabled:o,onClick:u,title:i,children:f?n.browserExtensionInstalling:n.browserExtensionRevealFolder})]})]}):null,t[3]=o,t[4]=i,t[5]=f,t[6]=n.browserExtensionCopyPath,t[7]=n.browserExtensionInstallStep2FolderLabel,t[8]=n.browserExtensionInstalling,t[9]=n.browserExtensionOpenChrome,t[10]=n.browserExtensionRevealFolder,t[11]=l,t[12]=c,t[13]=u,t[14]=d,t[15]=h):h=t[15];let g;t[16]!==n.browserExtensionInstallStep2||t[17]!==m||t[18]!==h?(g={id:`load`,label:n.browserExtensionInstallStep2,done:m,detail:h},t[16]=n.browserExtensionInstallStep2,t[17]=m,t[18]=h,t[19]=g):g=t[19];let _;t[20]!==a||t[21]!==n.browserExtensionInstallStep3?(_={id:`connect`,label:n.browserExtensionInstallStep3,done:a},t[20]=a,t[21]=n.browserExtensionInstallStep3,t[22]=_):_=t[22];let v;t[23]!==p||t[24]!==g||t[25]!==_?(v=[p,g,_],t[23]=p,t[24]=g,t[25]=_,t[26]=v):v=t[26];let y=v,x;t[27]===y?x=t[28]:(x=y.filter(et),t[27]=y,t[28]=x);let S=x.length,C=n.browserExtensionInstallGuideTitle,w;t[29]===n.browserExtensionInstallGuideTitle?w=t[30]:(w=(0,X.jsx)(`h4`,{className:`text-sm font-medium text-fg`,children:n.browserExtensionInstallGuideTitle}),t[29]=n.browserExtensionInstallGuideTitle,t[30]=w);let T;t[31]!==S||t[32]!==n.browserExtensionChecklistProgress||t[33]!==y.length?(T=n.browserExtensionChecklistProgress.replace(`{{done}}`,String(S)).replace(`{{total}}`,String(y.length)),t[31]=S,t[32]=n.browserExtensionChecklistProgress,t[33]=y.length,t[34]=T):T=t[34];let E;t[35]===T?E=t[36]:(E=(0,X.jsx)(`span`,{className:`ml-auto text-xs font-normal text-fg-muted`,children:T}),t[35]=T,t[36]=E);let D;t[37]!==E||t[38]!==w?(D=(0,X.jsxs)(`div`,{className:`mb-3 flex items-center gap-2`,children:[w,E]}),t[37]=E,t[38]=w,t[39]=D):D=t[39];let O;t[40]!==n.browserExtensionChecklistDone||t[41]!==n.browserExtensionChecklistPending||t[42]!==y?(O=(0,X.jsx)(`ol`,{className:`flex flex-col gap-3`,children:y.map((e,t)=>(0,X.jsxs)(`li`,{className:`flex gap-2.5`,children:[(0,X.jsx)(`span`,{className:`mt-0.5 shrink-0`,"aria-hidden":!0,children:e.done?(0,X.jsx)(s,{className:`size-4 text-emerald-500`,strokeWidth:2}):(0,X.jsx)(ae,{className:`size-4 text-fg-subtle`,strokeWidth:1.75})}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`p`,{className:b(`text-[11px] leading-relaxed`,e.done?`text-fg-muted line-through decoration-fg-subtle/60`:`text-fg`),children:[(0,X.jsxs)(`span`,{className:`sr-only`,children:[e.done?n.browserExtensionChecklistDone:n.browserExtensionChecklistPending,` `]}),t+1,`. `,e.label]}),e.detail]})]},e.id))}),t[40]=n.browserExtensionChecklistDone,t[41]=n.browserExtensionChecklistPending,t[42]=y,t[43]=O):O=t[43];let k;return t[44]!==n.browserExtensionInstallGuideTitle||t[45]!==D||t[46]!==O?(k=(0,X.jsxs)(`div`,{"aria-label":C,className:`rounded-xl bg-surface-base p-3`,children:[D,O]}),t[44]=n.browserExtensionInstallGuideTitle,t[45]=D,t[46]=O,t[47]=k):k=t[47],k}function et(e){return e.done}var tt=19820,nt=3e4;function rt({m:e,probe:t,artifacts:n,onChange:r,startBridge:i,stopBridge:a,disconnectExtension:o,installArtifacts:s,refetchArtifacts:c,openExtensionChrome:u,revealExtensionFolder:d,form:m,embedded:h=!1}){let[g,_]=(0,J.useState)(null),[v,y]=(0,J.useState)(null),[b,x]=(0,J.useState)(null),S=m.port??tt,C=m.host||`127.0.0.1`,w=`ws://${C}:${S}/browser-ext`,T=t.kind===`ok`&&t.data.running,E=t.kind===`ok`&&t.data.connected,D=t.kind===`ok`&&t.data.bridgeHeld===!0,O=t.kind===`ok`&&t.data.portConflict===!0,k=T||D,A=n.kind===`ok`?n.data:t.kind===`ok`?t.data.artifacts:void 0,j=A?.installed===!0,N=A?.extensionDir,P=A?.needsChromeReload===!0,F=t.kind===`ok`?E?{icon:ne,color:`text-green-500`,label:e.browserExtensionConnected}:T?{icon:K,color:`text-amber-500`,label:e.browserExtensionWaiting}:{icon:z,color:`text-fg-muted`,label:e.browserExtensionServerOff}:{icon:z,color:`text-fg-muted`,label:`…`},I=F.icon,L=(0,J.useCallback)(async()=>{if(!g){_(`start`),y(null);try{await i({host:C,port:S})}catch(e){y(e instanceof Error?e.message:String(e))}finally{_(null)}}},[g,C,S,i]),R=(0,J.useCallback)(async()=>{if(!g){_(`stop`),y(null);try{await a()}catch(e){y(e instanceof Error?e.message:String(e))}finally{_(null)}}},[g,a]),B=(0,J.useCallback)(async()=>{if(!g){_(`disconnect`),y(null);try{await o()}catch(e){y(e instanceof Error?e.message:String(e))}finally{_(null)}}},[g,o]),V=(0,J.useCallback)(async()=>{if(!g){_(`install`),y(null),x(null);try{let t=await s({force:j});t?.extensionDir?x(`${e.browserExtensionInstalled}: ${t.extensionDir}`):x(e.browserExtensionInstalled),await c()}catch(e){y(e instanceof Error?e.message:String(e))}finally{_(null)}}},[g,s,j,e.browserExtensionInstalled,c]),ee=(0,J.useCallback)(async()=>{if(!g){_(`open`),y(null);try{await u()}catch(e){y(e instanceof Error?e.message:String(e))}finally{_(null)}}},[g,u]),U=(0,J.useCallback)(async()=>{if(!(!N||g)){_(`path`),y(null),x(null);try{await p(N)?x(e.browserExtensionPathCopied):x(e.browserExtensionPathCopyFailed)}catch(e){y(e instanceof Error?e.message:String(e))}finally{_(null)}}},[g,N,e.browserExtensionPathCopied,e.browserExtensionPathCopyFailed]),te=(0,J.useCallback)(async()=>{if(!(!N||g)){_(`folder`),y(null),x(null);try{await d(),x(e.browserExtensionFolderOpened)}catch(e){y(e instanceof Error?e.message:String(e))}finally{_(null)}}},[g,N,e.browserExtensionFolderOpened,d]),W=(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:g!==null,onClick:()=>void V(),children:[g===`install`?(0,X.jsx)(f,{className:`size-3.5 animate-spin`}):(0,X.jsx)(l,{className:`size-3.5`}),g===`install`?e.browserExtensionInstalling:e.browserExtensionInstall]}),k?(0,X.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:g!==null,onClick:()=>void R(),children:[g===`stop`?(0,X.jsx)(f,{className:`size-3.5 animate-spin`}):(0,X.jsx)(M,{className:`size-3.5`}),e.browserExtensionStopBridge]}):(0,X.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:g!==null,onClick:()=>void L(),children:[g===`start`?(0,X.jsx)(f,{className:`size-3.5 animate-spin`}):(0,X.jsx)(H,{className:`size-3.5`}),g===`start`?e.browserExtensionStarting:e.browserExtensionStartBridge]}),E?(0,X.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:g!==null,onClick:()=>void B(),children:[g===`disconnect`?(0,X.jsx)(f,{className:`size-3.5 animate-spin`}):(0,X.jsx)(z,{className:`size-3.5`}),e.browserExtensionDisconnect]}):null]});return(0,X.jsx)(Be,{icon:G,title:e.browserBackendExtension,description:e.browserExtensionDownloadHint,m:e,embedded:h,primaryAction:W,advancedTitle:e.browserAdvancedShow,advanced:(0,X.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,X.jsx)(Z,{label:e.label.browserExtensionPort,description:e.desc.browserExtensionPort,children:(0,X.jsx)(ye,{type:`number`,className:Q(),min:1024,max:65535,value:m.port??``,suggestion:String(tt),onAcceptSuggestion:e=>r({port:Number.parseInt(e,10)}),placeholder:String(tt),onChange:e=>{let t=e.target.value;r({port:t===``?void 0:Number.parseInt(t,10)})}})}),(0,X.jsx)(Z,{label:e.label.browserExtensionHost,description:e.desc.browserExtensionHost,children:(0,X.jsx)(ye,{type:`text`,className:Q(),value:m.host,suggestion:`127.0.0.1`,onAcceptSuggestion:e=>r({host:e}),placeholder:`127.0.0.1`,onChange:e=>r({host:e.target.value}),autoComplete:`off`})}),(0,X.jsx)(Z,{label:e.label.browserExtensionConnectionTimeout,description:e.desc.browserExtensionConnectionTimeout,children:(0,X.jsx)(ye,{type:`number`,className:Q(),min:1,step:1,value:m.connectionTimeoutMs==null?``:Math.round(m.connectionTimeoutMs/1e3),placeholder:String(nt/1e3),suggestion:String(nt/1e3),onAcceptSuggestion:e=>r({connectionTimeoutMs:Number.parseInt(e,10)*1e3}),onChange:e=>{let t=e.target.value;r({connectionTimeoutMs:t===``?void 0:Math.max(1,Number.parseInt(t,10))*1e3})}})})]}),children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg bg-surface-base px-3 py-2 shadow-surface`,children:[(0,X.jsx)(`span`,{className:`font-mono text-xs text-fg-muted`,children:w}),(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs ${F.color}`,children:[(0,X.jsx)(I,{className:`size-3.5`}),(0,X.jsx)(`span`,{children:F.label})]})]}),(0,X.jsx)($e,{m:e,installed:j,extensionDir:N,connected:E,busy:g!==null,pathBusy:g===`path`,folderBusy:g===`folder`,onOpenChrome:()=>void ee(),onCopyPath:()=>void U(),onRevealFolder:()=>void te()}),P?(0,X.jsx)(`div`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs leading-relaxed text-amber-800 dark:text-amber-200`,children:e.browserExtensionNeedsChromeReload}):null,O?(0,X.jsx)(`div`,{className:`rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-xs leading-relaxed text-amber-800 dark:text-amber-200`,children:e.browserExtensionPortConflict.replace(`{{port}}`,String(S))}):null,b?(0,X.jsx)(He,{kind:`success`,message:b}):null,v?(0,X.jsx)(He,{kind:`error`,message:v}):null]})})}function it(e){let t=(0,Y.c)(41),{m:n,doctor:r,refetch:i,applyDoctor:a,installStream:o,embedded:c}=e,u=c===void 0?!1:c,[d,p]=(0,J.useState)(`idle`),[m,h]=(0,J.useState)(null),{progress:g,running:_,cancelling:v,run:y,reset:b,cancel:x}=o,S;t[0]!==a||t[1]!==n.browserPlaywrightInstallFailed||t[2]!==n.browserPlaywrightInstalled||t[3]!==i||t[4]!==b||t[5]!==y?(S=async()=>{p(`installing`),h(null),b();let e=await y({fallbackError:n.browserPlaywrightInstallFailed});if(!e.ok){if(e.error===`busy`){p(`installing`);return}if(e.error===`cancelled`){p(`idle`),h(null),b();return}p(`failed`),h(e.errorMessage??n.browserPlaywrightInstallFailed);return}e.payload&&a?.(e.payload),p(`installed`),h(e.payload?.executablePath?`${n.browserPlaywrightInstalled}: ${e.payload.executablePath}`:n.browserPlaywrightInstalled),await i()},t[0]=a,t[1]=n.browserPlaywrightInstallFailed,t[2]=n.browserPlaywrightInstalled,t[3]=i,t[4]=b,t[5]=y,t[6]=S):S=t[6];let C=S,w=r.kind===`loading`?`checking`:r.kind===`error`?`error`:r.kind===`ok`?r.data.installed?`ready`:`not_installed`:`unknown`,T=r.kind===`ok`&&r.data.installed&&r.data.executablePath?r.data.executablePath:void 0,E=r.kind===`ok`&&r.data.installed,D=d===`installing`||_,O;t[7]===C?O=t[8]:(O=()=>void C(),t[7]=C,t[8]=O);let k;t[9]!==E||t[10]!==D||t[11]!==d?(k=D?(0,X.jsx)(f,{className:`size-3.5 animate-spin`}):E?(0,X.jsx)(U,{className:`size-3.5`}):d===`installed`?(0,X.jsx)(s,{className:`size-3.5 text-green-500`}):(0,X.jsx)(l,{className:`size-3.5`}),t[9]=E,t[10]=D,t[11]=d,t[12]=k):k=t[12];let A=D?n.browserPlaywrightInstalling:E?n.browserReinstall:n.browserPlaywrightInstall,j;t[13]!==D||t[14]!==O||t[15]!==k||t[16]!==A?(j=(0,X.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-raised disabled:cursor-not-allowed disabled:opacity-60`,disabled:D,onClick:O,children:[k,A]}),t[13]=D,t[14]=O,t[15]=k,t[16]=A,t[17]=j):j=t[17];let M;t[18]===n.browserPlaywrightManualInstall?M=t[19]:(M=(0,X.jsx)(`p`,{className:`text-fg-muted`,children:n.browserPlaywrightManualInstall}),t[18]=n.browserPlaywrightManualInstall,t[19]=M);let N;t[20]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,X.jsx)(`code`,{className:`mt-2 block w-fit rounded-md border border-edge bg-surface-base px-2 py-1 text-xs text-fg`,children:`node node_modules/playwright-core/cli.js install chromium`}),t[20]=N):N=t[20];let P;t[21]===M?P=t[22]:(P=(0,X.jsxs)(`div`,{className:`text-xs`,children:[M,N]}),t[21]=M,t[22]=P);let F;t[23]!==x||t[24]!==v||t[25]!==n||t[26]!==g||t[27]!==_?(F=_?(0,X.jsx)(Ke,{m:n,progress:g,showLogs:!0,cancelling:v,onCancel:()=>void x()}):null,t[23]=x,t[24]=v,t[25]=n,t[26]=g,t[27]=_,t[28]=F):F=t[28];let I;t[29]!==m||t[30]!==d?(I=m?(0,X.jsx)(He,{kind:d===`failed`?`error`:`success`,message:m}):null,t[29]=m,t[30]=d,t[31]=I):I=t[31];let L;return t[32]!==u||t[33]!==n||t[34]!==T||t[35]!==w||t[36]!==F||t[37]!==I||t[38]!==j||t[39]!==P?(L=(0,X.jsxs)(Be,{icon:ee,title:n.browserPlaywrightGuideTitle,description:n.browserPlaywrightGuideDesc,status:w,statusDetail:T,m:n,embedded:u,primaryAction:j,children:[P,F,I]}),t[32]=u,t[33]=n,t[34]=T,t[35]=w,t[36]=F,t[37]=I,t[38]=j,t[39]=P,t[40]=L):L=t[40],L}async function at(e){let t=await g(e),n=await t.json().catch(()=>({}));if(!t.ok||n.ok===!1){let e=typeof n.error==`string`?n.error:n.error?.message;throw Error(e||`Request failed: ${t.status}`)}if(n.payload===void 0)throw Error(`Empty payload`);return n.payload}async function $(e,t){let n=await g(e,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t??{})}),r=await n.json().catch(()=>({}));if(!n.ok||r.ok===!1){let e=typeof r.error==`string`?r.error:r.error?.message;throw Error(e||`Request failed: ${n.status}`)}if(r.payload===void 0)throw Error(`Empty payload`);return r.payload}var ot={playwright:{kind:`idle`},cloak:{kind:`idle`},extension:{kind:`idle`},extensionArtifacts:{kind:`idle`}};function st(e,t){switch(t.type){case`playwright`:return{...e,playwright:t.state};case`cloak`:return{...e,cloak:t.state};case`extension`:return{...e,extension:t.state};case`extension-artifacts`:return{...e,extensionArtifacts:t.state};case`playwright-idle`:return{...e,playwright:{kind:`idle`}};case`cloak-idle`:return{...e,cloak:{kind:`idle`}};case`extension-idle`:return{...e,extension:{kind:`idle`},extensionArtifacts:{kind:`idle`}};case`extension-start-probe`:return{...e,extension:e.extension.kind===`ok`?e.extension:{kind:`loading`}};case`extension-artifacts-start-probe`:return{...e,extensionArtifacts:e.extensionArtifacts.kind===`ok`?e.extensionArtifacts:{kind:`loading`}}}}function ct(e){let[t,n]=(0,J.useReducer)(st,ot),{playwright:r,cloak:i,extension:a,extensionArtifacts:o}=t,s=(0,J.useCallback)(async()=>{n({type:`playwright`,state:{kind:`loading`}});try{n({type:`playwright`,state:{kind:`ok`,data:await at(v(`/api/browser/playwright/doctor`))}})}catch(e){n({type:`playwright`,state:{kind:`error`,message:e instanceof Error?e.message:String(e)}})}},[]),c=(0,J.useCallback)(async t=>{n({type:`cloak`,state:{kind:`loading`}});let r=(t?.cacheDir??e.cacheDir??``).trim(),i=(t?.binaryPath??e.binaryPath??``).trim(),a=new URLSearchParams;r&&a.set(`cacheDir`,r),i&&a.set(`binaryPath`,i);try{let e=await at(v(`/api/browser/cloakbrowser/doctor${a.size?`?${a}`:``}`));return n({type:`cloak`,state:{kind:`ok`,data:e}}),e}catch(e){return n({type:`cloak`,state:{kind:`error`,message:e instanceof Error?e.message:String(e)}}),null}},[e.binaryPath,e.cacheDir]),l=(0,J.useCallback)(e=>{n({type:`playwright`,state:{kind:`ok`,data:e}})},[]),u=(0,J.useCallback)(e=>{n({type:`cloak`,state:{kind:`ok`,data:e}})},[]),d=(0,J.useCallback)(async()=>at(v(`/api/browser/cloakbrowser/status`)),[]),f=(0,J.useCallback)(async()=>$(v(`/api/browser/cloakbrowser/launch`),{}),[]),p=e.browserEnabled===!0&&e.probeExtension===!0,m=e.browserEnabled===!0&&e.probeLocal===!0,h=e.browserEnabled===!0&&e.probeCloak===!0,{extensionHost:_,extensionPort:y}=e,b=(0,J.useCallback)(async()=>{let e=new URLSearchParams({probe:`1`});_&&e.set(`host`,_),y!==void 0&&e.set(`port`,String(y)),n({type:`extension-start-probe`});try{let t=await g(v(`/api/browser/extension-status?${e}`),{signal:AbortSignal.timeout(3e3)}),r=await t.json().catch(()=>({}));if(!t.ok){n({type:`extension`,state:{kind:`error`,message:`HTTP ${t.status}`}});return}n({type:`extension`,state:{kind:`ok`,data:{running:r.running===!0,connected:r.connected===!0,backend:r.backend,artifacts:r.artifacts,bridgeHeld:r.bridgeHeld===!0,refCount:typeof r.refCount==`number`?r.refCount:void 0,manualBridge:r.manualBridge===!0,portConflict:r.portConflict===!0}}})}catch(e){n({type:`extension`,state:{kind:`error`,message:e instanceof Error?e.message:String(e)}})}},[_,y]),x=(0,J.useCallback)(async()=>{n({type:`extension-artifacts-start-probe`});try{let e=await at(v(`/api/browser/extension/doctor`));return n({type:`extension-artifacts`,state:{kind:`ok`,data:e}}),e}catch(e){return n({type:`extension-artifacts`,state:{kind:`error`,message:e instanceof Error?e.message:String(e)}}),null}},[]),S=(0,J.useCallback)(async e=>{let t=(await $(v(`/api/browser/extension/install`),{force:e?.force??!1})).doctor;return n({type:`extension-artifacts`,state:{kind:`ok`,data:t}}),await b(),t},[b]),C=(0,J.useCallback)(async()=>{await $(v(`/api/browser/extension/open`),{action:`chrome`})},[]),w=(0,J.useCallback)(async()=>{await $(v(`/api/browser/extension/open`),{action:`folder`})},[]);(0,J.useEffect)(()=>{if(!m){n({type:`playwright-idle`});return}s()},[m,s]),(0,J.useEffect)(()=>{if(!h){n({type:`cloak-idle`});return}c()},[h,c]);let T=(0,J.useRef)(p);T.current!==p&&(T.current=p,p||n({type:`extension-idle`})),(0,J.useEffect)(()=>{if(!p)return;b(),x();let e=setInterval(()=>void b(),5e3);return()=>clearInterval(e)},[p,b,x]);let E=(0,J.useCallback)(async e=>{await $(v(`/api/browser/extension/start`),{host:e?.host??_,port:e?.port??y}),await b()},[_,y,b]),D=(0,J.useCallback)(async()=>{await $(v(`/api/browser/extension/stop`),{}),await b()},[b]),O=(0,J.useCallback)(async()=>{await $(v(`/api/browser/extension/disconnect`),{}),await b()},[b]),k=(0,J.useRef)(null);return(0,J.useEffect)(()=>{if(!p||e.activeBackend!==`extension`){k.current=null;return}if(a.kind!==`ok`||a.data.running||a.data.bridgeHeld)return;let t=`${_}:${y??19820}`;k.current!==t&&(k.current=t,E({host:_,port:y}).catch(()=>{k.current=null}))},[p,a,_,y,e.activeBackend,E]),{playwright:r,cloak:i,extension:a,extensionArtifacts:o,refetchPlaywright:s,applyPlaywrightDoctor:l,refetchCloak:c,applyCloakDoctor:u,fetchCloakRuntimeStatus:d,launchCloak:f,refetchExtension:b,refetchExtensionArtifacts:x,installExtensionArtifacts:S,openExtensionChrome:C,revealExtensionFolder:w,pingCdp:(0,J.useCallback)(async e=>$(v(`/api/browser/cdp/ping`),{cdpUrl:e}),[]),testCloud:(0,J.useCallback)(async(e,t)=>$(v(`/api/browser/cloud/test-connection`),{provider:e,apiKey:t}),[]),launchCdp:(0,J.useCallback)(async e=>$(v(`/api/browser/cdp/launch`),{executablePath:e}),[]),stopCdp:(0,J.useCallback)(async e=>{await $(v(`/api/browser/cdp/stop`),{port:e})},[]),listCdpInstances:(0,J.useCallback)(async()=>(await at(v(`/api/browser/cdp/instances`))).instances,[]),startExtensionBridge:E,stopExtensionBridge:D,disconnectExtension:O}}var lt=`
|
|
3
|
-
|
|
4
|
-
`,ut=/\r\n/g,dt={playwright:`/api/browser/playwright/install/stream`,cloakbrowser:`/api/browser/cloakbrowser/install/stream`},ft={playwright:`/api/browser/playwright/install/cancel`,cloakbrowser:`/api/browser/cloakbrowser/install/cancel`},pt=8;function mt(){return{phase:null,message:null,percent:null,lines:[]}}function ht(e,t){let n={phase:t.phase,message:t.message??t.line??e.message,percent:t.percent??e.percent,lines:e.lines};if(t.line){let r=[...e.lines,t.line];n.lines=r.length>pt?r.slice(-8):r}return n}async function gt(e,t,n){let r=e.getReader(),i=new TextDecoder,a=``,o=null,s=e=>{let n=``,r=``;for(let t of e.split(`
|
|
5
|
-
`)){let e=t.replace(/\r$/,``);e.startsWith(`event:`)?n=e.slice(6).trim():e.startsWith(`data:`)&&(r+=e.slice(5).trimStart())}if(r){if(n===`progress`){try{let e=JSON.parse(r);e&&typeof e==`object`&&typeof e.phase==`string`&&t(e)}catch{}return}if(n===`result`)try{let e=JSON.parse(r);o=e.ok?{ok:!0,payload:e.payload}:{ok:!1,error:String(e.error??`unknown`),message:typeof e.message==`string`?e.message:void 0,status:e.error===`busy`?409:e.error===`cancelled`?499:500}}catch{o={ok:!1,error:`parse`,status:0}}}};try{let e=async()=>{if(o!==null)return o;if(n?.aborted)return await r.cancel().catch(()=>{}),{ok:!1,error:`cancelled`,status:499};let{done:t,value:c}=await r.read();if(t)return o??{ok:!1,error:`no-result`,status:0};a+=i.decode(c,{stream:!0}),a=a.replace(ut,`
|
|
6
|
-
`);let l=a.split(lt);a=l.pop()??``;for(let e of l)e.length&&s(e);return e()},t=await e();if(t)return t}catch(e){if(n?.aborted||e instanceof DOMException&&e.name===`AbortError`)return{ok:!1,error:`cancelled`,status:499};throw e}finally{r.releaseLock()}return o||(n?.aborted?{ok:!1,error:`cancelled`,status:499}:{ok:!1,error:`no-result`,status:0})}function _t(e){let[t,n]=(0,J.useState)(mt),[r,i]=(0,J.useState)(!1),[a,o]=(0,J.useState)(!1),s=(0,J.useRef)(!1),c=(0,J.useRef)(null),l=(0,J.useCallback)(()=>{s.current||n(mt())},[]),u=(0,J.useCallback)(async()=>{if(s.current){o(!0);try{await g(v(ft[e]),{method:`POST`}).catch(()=>{}),c.current?.abort()}finally{o(!1)}}},[e]);return{progress:t,running:r,cancelling:a,run:(0,J.useCallback)(async t=>{if(s.current)return{ok:!1,error:`busy`,status:409,errorMessage:`An install for this browser type is already in progress.`};let r=new AbortController;c.current=r,s.current=!0,i(!0),n(mt());try{let i=await g(v(dt[e]),{method:`POST`,headers:{Accept:`text/event-stream`,...t.body===void 0?{}:{"Content-Type":`application/json`}},body:t.body===void 0?void 0:JSON.stringify(t.body),signal:r.signal});if(!i.ok||!i.body){let e=await i.text().catch(()=>``),t=`HTTP ${i.status}`;try{let n=JSON.parse(e);typeof n.message==`string`?t=n.message:typeof n.error==`string`&&(t=n.error)}catch{e&&(t=e.slice(0,500))}return{ok:!1,error:i.status===409?`busy`:`http`,status:i.status,errorMessage:t}}let a=await gt(i.body,e=>{n(t=>ht(t,e))},r.signal);return a.ok?a:a.error===`cancelled`?{...a,errorMessage:void 0}:{...a,errorMessage:a.message??(a.error===`busy`?`An install for this browser type is already in progress.`:t.fallbackError)}}catch(e){return r.signal.aborted||e instanceof DOMException&&e.name===`AbortError`?{ok:!1,error:`cancelled`,status:499}:{ok:!1,error:`network`,errorMessage:e instanceof Error?e.message:t.fallbackError}}finally{c.current===r&&(c.current=null),s.current=!1,i(!1),o(!1)}},[e]),reset:l,cancel:u}}function vt(e){let t=(0,Y.c)(150),{a:n,form:r,update:i,activeTab:a,setActiveTab:o}=e,s=_(bt),l=R(yt),u=_t(`playwright`),f=_t(`cloakbrowser`),p=r.browserEnabled&&(a===`overview`||a===`extension`),m=r.browserEnabled&&(a===`overview`||a===`local`),h=r.browserEnabled&&(a===`overview`||a===`cloakbrowser`),g;t[0]!==r.browserBackend||t[1]!==r.browserCloakBinaryPath||t[2]!==r.browserCloakCacheDir||t[3]!==r.browserEnabled||t[4]!==r.browserExtensionHost||t[5]!==r.browserExtensionPort||t[6]!==h||t[7]!==p||t[8]!==m?(g={cacheDir:r.browserCloakCacheDir,binaryPath:r.browserCloakBinaryPath,browserEnabled:r.browserEnabled,activeBackend:r.browserBackend,probeExtension:p,probeLocal:m,probeCloak:h,extensionHost:r.browserExtensionHost,extensionPort:r.browserExtensionPort},t[0]=r.browserBackend,t[1]=r.browserCloakBinaryPath,t[2]=r.browserCloakCacheDir,t[3]=r.browserEnabled,t[4]=r.browserExtensionHost,t[5]=r.browserExtensionPort,t[6]=h,t[7]=p,t[8]=m,t[9]=g):g=t[9];let v=ct(g),y;t[10]===v.playwright?y=t[11]:(y=je(v.playwright),t[10]=v.playwright,t[11]=y);let x=y,S;t[12]===v.cloak?S=t[13]:(S=je(v.cloak),t[12]=v.cloak,t[13]=S);let C=S,w;t[14]===v.extension?w=t[15]:(w=Ne(v.extension),t[14]=v.extension,t[15]=w);let T=w,E;t[16]!==n||t[17]!==v.extension?(E=Pe(v.extension,n),t[16]=n,t[17]=v.extension,t[18]=E):E=t[18];let D=E,O;t[19]!==n||t[20]!==C||t[21]!==T||t[22]!==D||t[23]!==x||t[24]!==l?(O=[{value:`extension`,icon:G,name:n.browserBackendExtension,tagline:n.browserModeExtTagline,status:T,statusLabel:D},{value:`local`,icon:ee,name:n.browserBackendLocal,tagline:n.browserModeLocalTagline,status:x,statusLabel:Me(x,n)},{value:`cloakbrowser`,icon:k,name:n.browserBackendCloakBrowser,tagline:n.browserModeCloakTagline,status:C,statusLabel:Me(C,n)},{value:`cdp`,icon:re,name:n.browserBackendCdp,tagline:n.browserModeCdpTagline},{value:`cloud`,icon:c,name:n.browserBackendCloud,tagline:n.browserModeCloudTagline}].filter(e=>ve(e.value,l)),t[19]=n,t[20]=C,t[21]=T,t[22]=D,t[23]=x,t[24]=l,t[25]=O):O=t[25];let A=O,j;t[26]!==o||t[27]!==i?(j=e=>{i({browserEnabled:!0,browserBackend:e}),o(e)},t[26]=o,t[27]=i,t[28]=j):j=t[28];let M=j,N=!r.browserEnabled&&`pointer-events-none opacity-40`,P;t[29]===N?P=t[30]:(P=b(`flex flex-col gap-5 transition-opacity`,N),t[29]=N,t[30]=P);let F=!r.browserEnabled,I;t[31]!==n||t[32]!==a||t[33]!==v.disconnectExtension||t[34]!==v.extension||t[35]!==v.extensionArtifacts||t[36]!==v.installExtensionArtifacts||t[37]!==v.openExtensionChrome||t[38]!==v.refetchExtensionArtifacts||t[39]!==v.revealExtensionFolder||t[40]!==v.startExtensionBridge||t[41]!==v.stopExtensionBridge||t[42]!==r.browserExtensionConnectionTimeout||t[43]!==r.browserExtensionHost||t[44]!==r.browserExtensionPort||t[45]!==i?(I=a===`extension`?(0,X.jsx)(q,{children:(0,X.jsx)(rt,{embedded:!0,m:n,probe:v.extension,artifacts:v.extensionArtifacts,form:{port:r.browserExtensionPort,host:r.browserExtensionHost,connectionTimeoutMs:r.browserExtensionConnectionTimeout},onChange:e=>i({...e.port===void 0?{}:{browserExtensionPort:e.port},...e.host===void 0?{}:{browserExtensionHost:e.host},...e.connectionTimeoutMs===void 0?{}:{browserExtensionConnectionTimeout:e.connectionTimeoutMs}}),startBridge:v.startExtensionBridge,stopBridge:v.stopExtensionBridge,disconnectExtension:v.disconnectExtension,installArtifacts:v.installExtensionArtifacts,refetchArtifacts:v.refetchExtensionArtifacts,openExtensionChrome:v.openExtensionChrome,revealExtensionFolder:v.revealExtensionFolder})}):null,t[31]=n,t[32]=a,t[33]=v.disconnectExtension,t[34]=v.extension,t[35]=v.extensionArtifacts,t[36]=v.installExtensionArtifacts,t[37]=v.openExtensionChrome,t[38]=v.refetchExtensionArtifacts,t[39]=v.revealExtensionFolder,t[40]=v.startExtensionBridge,t[41]=v.stopExtensionBridge,t[42]=r.browserExtensionConnectionTimeout,t[43]=r.browserExtensionHost,t[44]=r.browserExtensionPort,t[45]=i,t[46]=I):I=t[46];let L;t[47]!==n||t[48]!==a||t[49]!==v.applyPlaywrightDoctor||t[50]!==v.playwright||t[51]!==v.refetchPlaywright||t[52]!==u?(L=a===`local`?(0,X.jsx)(q,{children:(0,X.jsx)(it,{embedded:!0,m:n,doctor:v.playwright,refetch:v.refetchPlaywright,applyDoctor:v.applyPlaywrightDoctor,installStream:u})}):null,t[47]=n,t[48]=a,t[49]=v.applyPlaywrightDoctor,t[50]=v.playwright,t[51]=v.refetchPlaywright,t[52]=u,t[53]=L):L=t[53];let z;t[54]!==n||t[55]!==a||t[56]!==f||t[57]!==v.applyCloakDoctor||t[58]!==v.cloak||t[59]!==v.fetchCloakRuntimeStatus||t[60]!==v.launchCloak||t[61]!==v.refetchCloak||t[62]!==r.browserCloakBinaryPath||t[63]!==r.browserCloakCacheDir||t[64]!==r.browserCloakExtraArgs||t[65]!==r.browserCloakFingerprintPlatform||t[66]!==r.browserCloakKeepOpen||t[67]!==r.browserCloakLocale||t[68]!==r.browserCloakTemporaryProfile||t[69]!==r.browserCloakTimezone||t[70]!==r.browserCloakWebrtcIp||t[71]!==r.browserHumanPreset||t[72]!==r.browserHumanize||t[73]!==i?(z=a===`cloakbrowser`?(0,X.jsx)(q,{children:(0,X.jsx)(Ye,{embedded:!0,m:n,doctor:v.cloak,refetch:v.refetchCloak,applyDoctor:v.applyCloakDoctor,installStream:f,fetchRuntimeStatus:v.fetchCloakRuntimeStatus,launchCloak:v.launchCloak,form:{cacheDir:r.browserCloakCacheDir,binaryPath:r.browserCloakBinaryPath,keepOpen:r.browserCloakKeepOpen,temporaryProfile:r.browserCloakTemporaryProfile,humanize:r.browserHumanize,humanPreset:r.browserHumanPreset,timezone:r.browserCloakTimezone,locale:r.browserCloakLocale,webrtcIp:r.browserCloakWebrtcIp,fingerprintPlatform:r.browserCloakFingerprintPlatform,extraArgs:r.browserCloakExtraArgs},onChange:e=>i({...e.cacheDir===void 0?{}:{browserCloakCacheDir:e.cacheDir},...e.binaryPath===void 0?{}:{browserCloakBinaryPath:e.binaryPath},...e.keepOpen===void 0?{}:{browserCloakKeepOpen:e.keepOpen},...e.temporaryProfile===void 0?{}:{browserCloakTemporaryProfile:e.temporaryProfile},...e.humanize===void 0?{}:{browserHumanize:e.humanize},...e.humanPreset===void 0?{}:{browserHumanPreset:e.humanPreset},...e.timezone===void 0?{}:{browserCloakTimezone:e.timezone},...e.locale===void 0?{}:{browserCloakLocale:e.locale},...e.webrtcIp===void 0?{}:{browserCloakWebrtcIp:e.webrtcIp},...e.fingerprintPlatform===void 0?{}:{browserCloakFingerprintPlatform:e.fingerprintPlatform},...e.extraArgs===void 0?{}:{browserCloakExtraArgs:e.extraArgs}})})}):null,t[54]=n,t[55]=a,t[56]=f,t[57]=v.applyCloakDoctor,t[58]=v.cloak,t[59]=v.fetchCloakRuntimeStatus,t[60]=v.launchCloak,t[61]=v.refetchCloak,t[62]=r.browserCloakBinaryPath,t[63]=r.browserCloakCacheDir,t[64]=r.browserCloakExtraArgs,t[65]=r.browserCloakFingerprintPlatform,t[66]=r.browserCloakKeepOpen,t[67]=r.browserCloakLocale,t[68]=r.browserCloakTemporaryProfile,t[69]=r.browserCloakTimezone,t[70]=r.browserCloakWebrtcIp,t[71]=r.browserHumanPreset,t[72]=r.browserHumanize,t[73]=i,t[74]=z):z=t[74];let B;t[75]!==n||t[76]!==a||t[77]!==v.launchCdp||t[78]!==v.listCdpInstances||t[79]!==v.pingCdp||t[80]!==v.stopCdp||t[81]!==r.browserCdpUrl||t[82]!==i?(B=a===`cdp`?(0,X.jsx)(q,{children:(0,X.jsx)(We,{embedded:!0,m:n,cdpUrl:r.browserCdpUrl,onCdpUrlChange:e=>i({browserCdpUrl:e}),launch:v.launchCdp,stop:v.stopCdp,listInstances:v.listCdpInstances,ping:v.pingCdp})}):null,t[75]=n,t[76]=a,t[77]=v.launchCdp,t[78]=v.listCdpInstances,t[79]=v.pingCdp,t[80]=v.stopCdp,t[81]=r.browserCdpUrl,t[82]=i,t[83]=B):B=t[83];let V;t[84]!==n||t[85]!==a||t[86]!==v.testCloud||t[87]!==r.browserCloudApiKey||t[88]!==r.browserCloudProjectId||t[89]!==r.browserCloudProvider||t[90]!==r.browserCloudRegion||t[91]!==i?(V=a===`cloud`?(0,X.jsx)(q,{children:(0,X.jsx)(Qe,{embedded:!0,m:n,form:{provider:r.browserCloudProvider,apiKey:r.browserCloudApiKey,projectId:r.browserCloudProjectId,region:r.browserCloudRegion},onChange:e=>i({...e.provider===void 0?{}:{browserCloudProvider:e.provider},...e.apiKey===void 0?{}:{browserCloudApiKey:e.apiKey},...e.projectId===void 0?{}:{browserCloudProjectId:e.projectId},...e.region===void 0?{}:{browserCloudRegion:e.region}}),testCloud:v.testCloud})}):null,t[84]=n,t[85]=a,t[86]=v.testCloud,t[87]=r.browserCloudApiKey,t[88]=r.browserCloudProjectId,t[89]=r.browserCloudProvider,t[90]=r.browserCloudRegion,t[91]=i,t[92]=V):V=t[92];let H;t[93]!==I||t[94]!==L||t[95]!==z||t[96]!==B||t[97]!==V||t[98]!==P||t[99]!==F?(H=(0,X.jsxs)(`div`,{className:P,"aria-hidden":F,children:[I,L,z,B,V]}),t[93]=I,t[94]=L,t[95]=z,t[96]=B,t[97]=V,t[98]=P,t[99]=F,t[100]=H):H=t[100];let U=H;if(a===`overview`){let e;t[101]!==n||t[102]!==r.browserEnabled||t[103]!==M?(e=r.browserEnabled?null:(0,X.jsx)(ke,{m:n,onStart:M}),t[101]=n,t[102]=r.browserEnabled,t[103]=M,t[104]=e):e=t[104];let a;t[105]===Symbol.for(`react.memo_cache_sentinel`)?(a=(0,X.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-surface-hover/90 text-fg-muted`,"aria-hidden":!0,children:(0,X.jsx)(d,{className:`size-4`,strokeWidth:1.75})}),t[105]=a):a=t[105];let c;t[106]===i?c=t[107]:(c=e=>i({browserEnabled:e.target.checked}),t[106]=i,t[107]=c);let l;t[108]!==r.browserEnabled||t[109]!==c?(l=(0,X.jsx)(`input`,{type:`checkbox`,className:`size-3.5 shrink-0 rounded border-edge`,checked:r.browserEnabled,onChange:c}),t[108]=r.browserEnabled,t[109]=c,t[110]=l):l=t[110];let u;t[111]===n.browserEnabledOn?u=t[112]:(u=(0,X.jsx)(`span`,{children:n.browserEnabledOn}),t[111]=n.browserEnabledOn,t[112]=u);let f;t[113]!==l||t[114]!==u?(f=(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm font-medium text-fg`,children:[l,u]}),t[113]=l,t[114]=u,t[115]=f):f=t[115];let p;t[116]!==n.desc.browserEnabled||t[117]!==n.label.browserEnabled||t[118]!==f?(p=(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-3`,children:[a,(0,X.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,X.jsx)(Z,{label:n.label.browserEnabled,description:n.desc.browserEnabled,children:f})})]}),t[116]=n.desc.browserEnabled,t[117]=n.label.browserEnabled,t[118]=f,t[119]=p):p=t[119];let m;t[120]!==n.browserDocsLink||t[121]!==s?(m=(0,X.jsx)(De,{language:s,label:n.browserDocsLink,className:`shrink-0 pt-1`}),t[120]=n.browserDocsLink,t[121]=s,t[122]=m):m=t[122];let h;t[123]!==p||t[124]!==m?(h=(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[p,m]}),t[123]=p,t[124]=m,t[125]=h):h=t[125];let g;t[126]!==n||t[127]!==r.browserBackend||t[128]!==r.browserEnabled||t[129]!==A||t[130]!==o||t[131]!==i?(g=r.browserEnabled?(0,X.jsx)(`div`,{id:we(`connection`),className:b(`scroll-mt-24 transition-opacity`,!r.browserEnabled&&`pointer-events-none opacity-40`),children:(0,X.jsx)(Se,{m:n,value:r.browserBackend,onChange:e=>i({browserBackend:e}),onOpenConfig:o,options:A})}):(0,X.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.browserDisabledHint}),t[126]=n,t[127]=r.browserBackend,t[128]=r.browserEnabled,t[129]=A,t[130]=o,t[131]=i,t[132]=g):g=t[132];let _;t[133]!==h||t[134]!==g?(_=(0,X.jsx)(q,{children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[h,g]})}),t[133]=h,t[134]=g,t[135]=_):_=t[135];let v=!r.browserEnabled&&`pointer-events-none opacity-40`,y;t[136]===v?y=t[137]:(y=b(`transition-opacity`,v),t[136]=v,t[137]=y);let x=!r.browserEnabled,S;t[138]!==n||t[139]!==r||t[140]!==i?(S=(0,X.jsx)(Ee,{a:n,form:r,update:i}),t[138]=n,t[139]=r,t[140]=i,t[141]=S):S=t[141];let C;t[142]!==y||t[143]!==x||t[144]!==S?(C=(0,X.jsx)(me,{children:(0,X.jsx)(`div`,{className:y,"aria-hidden":x,children:S})}),t[142]=y,t[143]=x,t[144]=S,t[145]=C):C=t[145];let w;return t[146]!==e||t[147]!==_||t[148]!==C?(w=(0,X.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[e,_,C]}),t[146]=e,t[147]=_,t[148]=C,t[149]=w):w=t[149],w}return ze(a)?U:null}function yt(e){return e.mode}function bt(e){return e.language}function xt(e){let t=(0,Y.c)(40),{sectionId:n,intro:r,vm:i,children:a,tabbed:o}=e,s=o===void 0?!1:o,c=_(St),l;t[0]===c?l=t[1]:(l=m(c),t[0]=c,t[1]=l);let u=l,d=u.agentSettings,f=u.settingsSections[n]??n;if(!i.hasToken){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(W,{className:`mt-0.5 size-5 shrink-0 text-fg-subtle`,strokeWidth:1.75}),t[2]=e):e=t[2];let n;t[3]===f?n=t[4]:(n=(0,X.jsx)(`h1`,{className:`text-base font-semibold text-fg`,children:f}),t[3]=f,t[4]=n);let r;t[5]===d.needToken?r=t[6]:(r=(0,X.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:d.needToken}),t[5]=d.needToken,t[6]=r);let i;return t[7]!==n||t[8]!==r?(i=(0,X.jsx)(se,{gap:`gap-3`,padding:`px-3 py-10 sm:px-5 xl:px-6`,children:(0,X.jsxs)(`div`,{className:`flex items-start gap-3 rounded-2xl bg-surface-base p-6`,children:[e,(0,X.jsxs)(`div`,{children:[n,r]})]})}),t[7]=n,t[8]=r,t[9]=i):i=t[9],i}if(i.loading){let e;return t[10]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,X.jsx)(se,{gap:`gap-6`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:(0,X.jsx)(le,{sections:1})}),t[10]=e):e=t[10],e}if(!i.form){let e=i.error??i.fetchError??d.loadError,n;t[11]===e?n=t[12]:(n=(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e}),t[11]=e,t[12]=n);let r;t[13]===i?r=t[14]:(r=()=>void i.mutate(),t[13]=i,t[14]=r);let a;t[15]!==u.logs.refresh||t[16]!==r?(a=(0,X.jsx)(x,{type:`button`,variant:`secondary`,onClick:r,children:u.logs.refresh}),t[15]=u.logs.refresh,t[16]=r,t[17]=a):a=t[17];let o;return t[18]!==n||t[19]!==a?(o=(0,X.jsxs)(se,{gap:`gap-3`,padding:`px-3 py-10 sm:px-5 xl:px-6`,children:[n,a]}),t[18]=n,t[19]=a,t[20]=o):o=t[20],o}let p=s?void 0:r,h;t[21]===d.sectionDesc?h=t[22]:(h=(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:d.sectionDesc}),t[21]=d.sectionDesc,t[22]=h);let g;t[23]!==i.autosaveStatus||t[24]!==i.error?(g=(0,X.jsx)(de,{status:i.autosaveStatus,error:i.error}),t[23]=i.autosaveStatus,t[24]=i.error,t[25]=g):g=t[25];let v;t[26]!==f||t[27]!==p||t[28]!==h||t[29]!==g?(v=(0,X.jsx)(oe,{title:f,subtitle:p,meta:h,actions:g}),t[26]=f,t[27]=p,t[28]=h,t[29]=g,t[30]=v):v=t[30];let y;t[31]===i.error?y=t[32]:(y=i.error?(0,X.jsx)(`div`,{className:`rounded-md border border-red-200 bg-red-50 px-3 py-2 text-sm text-red-700 dark:border-red-900/50 dark:bg-red-950/50 dark:text-red-400`,role:`alert`,children:i.error}):null,t[31]=i.error,t[32]=y);let b;t[33]===a?b=t[34]:(b=(0,X.jsx)(`div`,{className:`flex min-w-0 flex-col gap-5 pb-8`,children:a}),t[33]=a,t[34]=b);let S;return t[35]!==v||t[36]!==y||t[37]!==b||t[38]!==i.onBlurCapture?(S=(0,X.jsxs)(se,{gap:`gap-6`,onBlurCapture:i.onBlurCapture,children:[v,y,b]}),t[35]=v,t[36]=y,t[37]=b,t[38]=i.onBlurCapture,t[39]=S):S=t[39],S}function St(e){return e.language}var Ct={browserEnabled:!0,browserHeadless:!1,browserAllowPrivateUrls:!1,browserCommandTimeout:void 0,browserBackend:`extension`,browserCloudProvider:`local`,browserCloudApiKey:``,browserCloudProjectId:``,browserCloudRegion:``,browserCdpUrl:``,browserExtensionPort:void 0,browserExtensionHost:`127.0.0.1`,browserExtensionConnectionTimeout:void 0,browserCloakKeepOpen:!0,browserCloakTemporaryProfile:!1,browserCloakCacheDir:``,browserCloakBinaryPath:``,browserCloakTimezone:``,browserCloakLocale:``,browserCloakWebrtcIp:``,browserCloakFingerprintPlatform:``,browserCloakExtraArgs:``,browserHumanize:!0,browserHumanPreset:`careful`,browserDialogPolicy:`auto_dismiss`,browserDialogTimeout:void 0};function wt(e){return e===!0||e===`true`||e===1}function Tt(e){let t=(e&&typeof e==`object`&&!Array.isArray(e)?e:{}).browser;if(!t||typeof t!=`object`||Array.isArray(t))return{...Ct};let n=t,r=n.cloud&&typeof n.cloud==`object`&&!Array.isArray(n.cloud)?n.cloud:{},i=n.extension&&typeof n.extension==`object`&&!Array.isArray(n.extension)?n.extension:{},a=n.cloakbrowser&&typeof n.cloakbrowser==`object`&&!Array.isArray(n.cloakbrowser)?n.cloakbrowser:{},o=n.backend,s=n.cloudProvider,c=n.dialogPolicy;return{browserEnabled:wt(n.enabled),browserHeadless:wt(n.headless),browserAllowPrivateUrls:wt(n.allowPrivateUrls),browserCommandTimeout:typeof n.commandTimeout==`number`&&n.commandTimeout>=5?Math.floor(n.commandTimeout):void 0,browserBackend:o===`local`||o===`cdp`||o===`cloud`||o===`extension`||o===`cloakbrowser`?o:`extension`,browserCloudProvider:s===`browserbase`||s===`browser-use`?s:`local`,browserCloudApiKey:typeof r.apiKey==`string`?r.apiKey:``,browserCloudProjectId:typeof r.projectId==`string`?r.projectId:``,browserCloudRegion:typeof r.region==`string`?r.region:``,browserCdpUrl:typeof n.cdpUrl==`string`?n.cdpUrl:``,browserExtensionPort:typeof i.port==`number`&&i.port>=1024&&i.port<=65535?Math.floor(i.port):void 0,browserExtensionHost:typeof i.host==`string`&&i.host?i.host:`127.0.0.1`,browserExtensionConnectionTimeout:typeof i.connectionTimeout==`number`&&i.connectionTimeout>=1e3?Math.floor(i.connectionTimeout):void 0,browserCloakKeepOpen:a.keepOpen!==!1,browserCloakTemporaryProfile:a.temporaryProfile===!0,browserCloakCacheDir:typeof a.cacheDir==`string`?a.cacheDir:``,browserCloakBinaryPath:typeof a.binaryPath==`string`?a.binaryPath:``,browserCloakTimezone:typeof a.timezone==`string`?a.timezone:``,browserCloakLocale:typeof a.locale==`string`?a.locale:``,browserCloakWebrtcIp:typeof a.webrtcIp==`string`?a.webrtcIp:``,browserCloakFingerprintPlatform:typeof a.fingerprintPlatform==`string`?a.fingerprintPlatform:``,browserCloakExtraArgs:Array.isArray(a.extraArgs)?a.extraArgs.filter(e=>typeof e==`string`&&e.trim().length>0).join(`
|
|
7
|
-
`):``,browserHumanize:n.humanize!==!1,browserHumanPreset:n.humanPreset==="default"?`default`:`careful`,browserDialogPolicy:c===`must_respond`||c===`auto_accept`?c:`auto_dismiss`,browserDialogTimeout:typeof n.dialogTimeoutSeconds==`number`&&n.dialogTimeoutSeconds>=1?Math.floor(n.dialogTimeoutSeconds):void 0}}function Et(e){return{enabled:e.browserEnabled,headless:e.browserHeadless,allowPrivateUrls:e.browserAllowPrivateUrls,...e.browserCommandTimeout===void 0?{}:{commandTimeout:e.browserCommandTimeout},backend:e.browserBackend,...e.browserCloudProvider===`local`?{}:{cloudProvider:e.browserCloudProvider},...e.browserBackend===`cloud`?{cloud:{...e.browserCloudApiKey.trim()?{apiKey:e.browserCloudApiKey.trim()}:{},...e.browserCloudProjectId.trim()?{projectId:e.browserCloudProjectId.trim()}:{},...e.browserCloudRegion.trim()?{region:e.browserCloudRegion.trim()}:{}}}:{},...e.browserCdpUrl.trim()?{cdpUrl:e.browserCdpUrl.trim()}:{},...e.browserBackend===`extension`?{extension:{...e.browserExtensionPort===void 0?{}:{port:e.browserExtensionPort},...e.browserExtensionHost.trim()?{host:e.browserExtensionHost.trim()}:{},...e.browserExtensionConnectionTimeout===void 0?{}:{connectionTimeout:e.browserExtensionConnectionTimeout}}}:{},...e.browserBackend===`cloakbrowser`?{cloakbrowser:{keepOpen:e.browserCloakKeepOpen,temporaryProfile:e.browserCloakTemporaryProfile,...e.browserCloakCacheDir.trim()?{cacheDir:e.browserCloakCacheDir.trim()}:{},...e.browserCloakBinaryPath.trim()?{binaryPath:e.browserCloakBinaryPath.trim()}:{},...e.browserCloakTimezone.trim()?{timezone:e.browserCloakTimezone.trim()}:{},...e.browserCloakLocale.trim()?{locale:e.browserCloakLocale.trim()}:{},...e.browserCloakWebrtcIp.trim()?{webrtcIp:e.browserCloakWebrtcIp.trim()}:{},...e.browserCloakFingerprintPlatform.trim()?{fingerprintPlatform:e.browserCloakFingerprintPlatform.trim()}:{},...(()=>{let t=e.browserCloakExtraArgs.split(`
|
|
8
|
-
`).map(e=>e.trim()).filter(Boolean);return t.length>0?{extraArgs:t}:{}})()},humanize:e.browserHumanize,humanPreset:e.browserHumanPreset}:{},...e.browserDialogPolicy===`auto_dismiss`?{}:{dialogPolicy:e.browserDialogPolicy},...e.browserDialogTimeout===void 0?{}:{dialogTimeoutSeconds:e.browserDialogTimeout}}}async function Dt(e){await h(v(`/api/config`),{method:`PATCH`,body:JSON.stringify({browser:Et(e)})}),S()}var Ot=D();function kt(e){let t=!!y(e=>e.token),[n,r]=(0,J.useReducer)(Ot,{form:null,baseline:null}),i=n.form,a=n.baseline,o=(0,J.useRef)(!1),s=(0,J.useRef)(i);s.current=i;let c=(0,J.useRef)(null),{data:l,error:u,isLoading:d,mutate:f}=C(t);j({enabled:t,parsed:(0,J.useMemo)(()=>l?.payload?.config===void 0?null:Tt(l.payload.config),[l]),dirty:o.current,trackedParsedRef:c,dispatch:r,onResetDirty:()=>{o.current=!1}});let p=!!(t&&d&&l===void 0&&!u),m=u instanceof Error?u.message:u?String(u):null,h=(0,J.useMemo)(()=>!i||!a?!1:JSON.stringify(i)!==JSON.stringify(a),[i,a]),g=(0,J.useCallback)(e=>{o.current=!0,r({type:`patch`,patch:e})},[]),_=fe({value:i,dirty:h,onSave:(0,J.useCallback)(async t=>{try{await Dt(t),r({type:`saved`,value:t}),o.current=!!(s.current&&JSON.stringify(s.current)!==JSON.stringify(t))}catch(t){throw Error(t instanceof Error?t.message:e.saveError)}},[e.saveError])});return{hasToken:t,loading:p,fetchError:m,form:i,update:g,autosaveStatus:_.status,error:_.error,onBlurCapture:_.onBlurCapture,mutate:f}}function At(e,t){return e.browserTabs[t]}function jt(){let e=(0,Y.c)(42),t=_(Nt),n;e[0]===t?n=e[1]:(n=m(t),e[0]=t,e[1]=n);let r=n,a=r.agentSettings,o=r.chat,s=R(Mt),c=kt(a),[l,u]=i(),d;e[2]===s?d=e[3]:(d=_e(Fe,s),e[2]=s,e[3]=d);let f=d,p;e[4]===l?p=e[5]:(p=Te(l.get(`focus`)),e[4]=l,e[5]=p);let h=p,g;e[6]!==h||e[7]!==l?(g=h?Le[h]??Re(l.get(`tab`)):Re(l.get(`tab`)),e[6]=h,e[7]=l,e[8]=g):g=e[8];let v=g,y;bb0:{if(!c.form){y=null;break bb0}let t;e[9]!==a||e[10]!==o||e[11]!==c.form||e[12]!==c.update?(t={form:c.form,update:c.update,a,chat:o},e[9]=a,e[10]=o,e[11]=c.form,e[12]=c.update,e[13]=t):t=e[13],y=t}let b=y,x;e[14]===u?x=e[15]:(x=e=>{u(t=>{let n=new URLSearchParams(t);return n.delete(`focus`),e===`overview`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},e[14]=u,e[15]=x);let S=x;ge(v,S);let C,w;e[16]!==h||e[17]!==l||e[18]!==u?(C=()=>{if(!h)return;let e=Le[h]??Re(l.get(`tab`));u(t=>{let n=new URLSearchParams(t);return n.delete(`focus`),e===`overview`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0});let t=h===`runtime`||h===`security`?we(h):null;if(!t)return;let n=window.setTimeout(()=>{document.getElementById(t)?.scrollIntoView({behavior:`smooth`,block:`start`})},80);return()=>window.clearTimeout(n)},w=[h,l,u],e[16]=h,e[17]=l,e[18]=u,e[19]=C,e[20]=w):(C=e[19],w=e[20]),(0,J.useEffect)(C,w);let T;if(e[21]!==a||e[22]!==f){let t;e[24]===a?t=e[25]:(t=e=>({id:e,label:At(a,e)}),e[24]=a,e[25]=t),T=f.map(t),e[21]=a,e[22]=f,e[23]=T}else T=e[23];let E=T,D;e[26]!==v||e[27]!==a.browserTabsAria||e[28]!==S||e[29]!==E?(D=(0,X.jsx)(pe,{items:E,activeTab:v,onChange:S,ariaLabel:a.browserTabsAria,tabIdPrefix:`agent-browser-tab`,panelIdPrefix:`agent-browser-panel`}),e[26]=v,e[27]=a.browserTabsAria,e[28]=S,e[29]=E,e[30]=D):D=e[30];let O;e[31]!==v||e[32]!==b||e[33]!==S?(O=b?(0,X.jsx)(vt,{...b,activeTab:v,setActiveTab:S}):null,e[31]=v,e[32]=b,e[33]=S,e[34]=O):O=e[34];let k;e[35]!==v||e[36]!==O?(k=(0,X.jsx)(ce,{id:v,activeTab:v,tabIdPrefix:`agent-browser-tab`,panelIdPrefix:`agent-browser-panel`,showHeading:!1,framed:!1,children:O}),e[35]=v,e[36]=O,e[37]=k):k=e[37];let A;return e[38]!==k||e[39]!==D||e[40]!==c?(A=(0,X.jsxs)(xt,{sectionId:`agent-browser`,intro:``,vm:c,tabbed:!0,children:[D,k]}),e[38]=k,e[39]=D,e[40]=c,e[41]=A):A=e[41],A}function Mt(e){return e.mode}function Nt(e){return e.language}export{jt as AgentBrowserSettingsPage};
|
|
@@ -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-BaASWQor.js";import{a as o,i as s,n as c,o as l,r as u,s as d,t as f}from"./dist-CpzYSoz7.js";import{t as p}from"./popover-select-C-Hj-nXR.js";import{t as m}from"./circle-check-C23XjkUj.js";import{t as h}from"./external-link-DjqjBmc3.js";import{t as g}from"./loader-circle-CifKLtgG.js";import{t as _}from"./x-B_N4OPjy.js";import{t as v}from"./messages-BbdwoxVo.js";import{a as y,i as b,n as x,r as S,s as C}from"./locale-store-CBoCuIMx.js";import{t as w}from"./cn-JdwAhgNB.js";import{i as T}from"./vendor-swr-BIWyz7Rc.js";import{t as E}from"./button-CtTvuElV.js";import{t as D}from"./interaction-BmQogeqz.js";import{t as O}from"./skeleton-BwbyijEw.js";import{i as k,o as A}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{t as j}from"./settings-shell-layer-context-DCp6ykjQ.js";import{$s as M,Gi as N,Ki as P,Nl as F,Ps as I,Ts as L,Wt as R,Ys as z,en as B,ni as V,nn as ee,oa as te,rc as ne,tn as re,wr as ie}from"./index-eZjksPvq.js";import{n as ae,r as oe}from"./settings-page-layout-BRQNel6r.js";import{n as se}from"./settings-loading-skeleton-CAmWMaOT.js";import{t as ce}from"./browser-BLJWD7WI.js";import{t as le}from"./schema-form-DYHmEZeZ.js";import{n as ue,t as de}from"./channels-status-swr-CCBCtLDg.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(ce(),1),W=r();async function me(e){let t=await b(S(`/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]),o=(0,H.useMemo)(()=>({defaultBooleanLabel:n.schemaBooleanDefault,unsupportedArrayType:n.schemaUnsupportedArrayType,arrayAddPlaceholder:n.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>n.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[n]),[s,c]=(0,H.useState)({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null});(0,H.useEffect)(()=>{c({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null})},[e.id]);let l=(0,H.useCallback)(async(n,i)=>{c(e=>({...e,busy:!0,error:null}));try{let a=await me({channelId:e.id,actionId:n,locale:t,input:i});c(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){c(t=>({...t,busy:!1,error:e instanceof Error?e.message:String(e)}))}},[e.id,t,r]);(0,H.useEffect)(()=>{let t=q(s.payload,e.id);if(!t){c(e=>e.generatedQr?{...e,generatedQr:null}:e);return}let n=!1;return c(e=>e.generatedQr?{...e,generatedQr:null}:e),pe.toDataURL(t,{width:220,margin:1}).then(e=>{n||c(t=>({...t,generatedQr:e}))}),()=>{n=!0}},[e.id,s.payload]),(0,H.useEffect)(()=>{let n=s.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||(c(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||c(t=>({...t,error:e instanceof Error?e.message:String(e)}))})},n.intervalMs);return()=>{i=!0,window.clearInterval(a)}},[e.id,t,r,s.poll]);let u=a?.[1].label??(e.configured?n.reconnect:n.connect),d=e.actions?.[`doctor.run`]?.label??n.diagnose,f=K(s.payload),p=q(s.payload,e.id),_=p?s.generatedQr:J(s.payload),v=a?.[1].result===`qr`&&(s.busy||s.payload?.type===`qr`||s.payload?.type===`poll`),y=s.payload?.type===`form`?s.payload:null,b=s.payload?.type===`diagnostics`?s.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:w(`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)(E,{type:`button`,variant:`primary`,disabled:s.busy,onClick:()=>void l(a[0]),children:[s.busy?(0,W.jsx)(g,{className:`size-4 animate-spin`}):(0,W.jsx)(ne,{className:`size-4`}),u]}):null,e.actions?.[`doctor.run`]?(0,W.jsxs)(E,{type:`button`,variant:`secondary`,disabled:s.busy,onClick:()=>void l(`doctor.run`),children:[(0,W.jsx)(I,{className:`size-4`}),d]}):null]})]}),f?(0,W.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:f}):null,s.error?(0,W.jsx)(`p`,{className:`mt-3 text-sm text-red-600 dark:text-red-400`,children:s.error}):null,v?(0,W.jsxs)(`div`,{className:w(`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:_?(0,W.jsx)(`img`,{src:_,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)(O,{className:`size-48 rounded-md`})})}),(0,W.jsxs)(`div`,{className:w(`min-w-0 max-w-sm text-sm text-fg-muted`,i&&`w-full sm:w-auto`),children:[_?(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)(O,{className:`h-4 w-48 max-w-full`}),(0,W.jsx)(O,{className:`h-4 w-36 max-w-full`})]}),p?(0,W.jsxs)(`a`,{className:`mt-2 inline-flex items-center gap-1 text-accent hover:underline`,href:p,target:`_blank`,rel:`noreferrer`,children:[n.openSetupLink,(0,W.jsx)(h,{className:`size-3.5`})]}):null]})]}):null,s.payload?.type===`poll`&&s.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)(m,{className:s.payload.ok?`size-4 text-green-600`:`size-4 text-red-600`}),(0,W.jsx)(`span`,{className:s.payload.ok?`text-fg`:`text-red-600 dark:text-red-400`,children:s.payload.message??(s.payload.ok?n.complete:n.failed)})]}):null,y?(0,W.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,W.jsx)(le,{schema:y.schema,values:s.formDraft,onChange:e=>c(t=>({...t,formDraft:e})),disabled:s.busy,labels:o}),(0,W.jsx)(E,{type:`button`,variant:`primary`,disabled:s.busy,onClick:()=>void l(y.submitAction,s.formDraft),children:n.saveSetup})]}):null,b?(0,W.jsx)(`div`,{className:`mt-4 space-y-2`,children:b.map((e,t)=>(0,W.jsxs)(`div`,{className:`rounded-lg bg-surface-base px-3 py-2 shadow-surface`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,W.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.label??e.id??n.diagnosticCheckFallback.replace(`{{index}}`,String(t+1))}),(0,W.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e.status??`unknown`})]}),e.message?(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.message}):null]},e.id??t))}):null]})}var 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`?w(`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`,k):w(`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)]`,k,`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:p,srTitle:m,srDescription:h,closeAriaLabel:g,children:v,footer:y,wide:b,headerExtra:x}=e,S=b===void 0?!1:b,C=n===`drawer`,[T,O]=(0,H.useState)(null),k;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,W.jsx)(o,{className:w(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,A)}),t[0]=k):k=t[0];let M;t[1]!==n||t[2]!==S?(M=xe(n,S),t[1]=n,t[2]=S,t[3]=M):M=t[3];let N;t[4]===m?N=t[5]:(N=m?(0,W.jsx)(d,{className:`sr-only`,children:m}):null,t[4]=m,t[5]=N);let P;t[6]===h?P=t[7]:(P=h?(0,W.jsx)(s,{className:`sr-only`,children:h}):null,t[6]=h,t[7]=P);let F;t[8]!==g||t[9]!==p||t[10]!==x||t[11]!==C||t[12]!==a?(F=C?(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,p?(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:p}):null]}),(0,W.jsx)(c,{asChild:!0,children:(0,W.jsx)(E,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":g,children:(0,W.jsx)(_,{className:`size-5`,strokeWidth:1.75})})})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(c,{asChild:!0,children:(0,W.jsx)(`button`,{type:`button`,className:w(D,`absolute right-3 top-3 z-20 p-1.5 hover:bg-surface-hover`),"aria-label":g,children:(0,W.jsx)(_,{className:`size-4`})})}),x]}),t[8]=g,t[9]=p,t[10]=x,t[11]=C,t[12]=a,t[13]=F):F=t[13];let I=C?`p-4`:`p-6`,L;t[14]===I?L=t[15]:(L=w(`min-h-0 flex-1 overflow-y-auto`,I),t[14]=I,t[15]=L);let R;t[16]!==v||t[17]!==L?(R=(0,W.jsx)(`div`,{className:L,children:v}),t[16]=v,t[17]=L,t[18]=R):R=t[18];let z;t[19]!==y||t[20]!==T||t[21]!==N||t[22]!==P||t[23]!==F||t[24]!==R?(z=(0,W.jsxs)(j,{layer:`modal`,portalContainer:T,children:[N,P,F,R,y]}),t[19]=y,t[20]=T,t[21]=N,t[22]=P,t[23]=F,t[24]=R,t[25]=z):z=t[25];let B;t[26]!==z||t[27]!==M?(B=(0,W.jsxs)(l,{children:[k,(0,W.jsx)(u,{ref:O,className:M,onOpenAutoFocus:Ce,children:z})]}),t[26]=z,t[27]=M,t[28]=B):B=t[28];let V;return t[29]!==i||t[30]!==r||t[31]!==B?(V=(0,W.jsx)(f,{open:r,onOpenChange:i,children:B}),t[29]=i,t[30]=r,t[31]=B,t[32]=V):V=t[32],V}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)(V,{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)(E,{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)(E,{type:`button`,variant:`secondary`,disabled:f,onClick:o,children:n.discard}),t[7]=n.discard,t[8]=o,t[9]=f,t[10]=p):p=t[10];let m=!r||i,h;t[11]===s?h=t[12]:(h=()=>void s(),t[11]=s,t[12]=h);let g=i?n.saving:n.save,_;t[13]!==m||t[14]!==h||t[15]!==g?(_=(0,W.jsx)(E,{type:`button`,variant:`primary`,disabled:m,onClick:h,children:g}),t[13]=m,t[14]=h,t[15]=g,t[16]=_):_=t[16];let v;t[17]!==d||t[18]!==p||t[19]!==_?(v=(0,W.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[d,p,_]}),t[17]=d,t[18]=p,t[19]=_,t[20]=v):v=t[20];let y;return t[21]!==v||t[22]!==u?(y=(0,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,v]}),t[21]=v,t[22]=u,t[23]=y):y=t[23],y}function Ee(e){return S(`/api/channels/catalog?locale=${encodeURIComponent(e)}`)}async function De(e){return(await y(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}=T(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?S(`/api/channels/${encodeURIComponent(e)}/config`):null}async function Pe(e){return(await y(S(`/api/channels/${encodeURIComponent(e)}/config`))).payload?.config??{}}var Fe=[`enabled`];async function Ie(){let e=await y(S(`/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(S(`/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)(P,{sourceChannel:e.id,className:`size-7`})})}function nt(e){let t=(0,U.c)(16),{checked:n,disabled:r,onToggle:i,label:a}=e,o;t[0]===i?o=t[1]:(o=e=>{e.stopPropagation(),i()},t[0]=i,t[1]=o);let s=n?`border-accent bg-accent`:`border-edge bg-surface-hover`,c=r&&`cursor-not-allowed opacity-60`,l;t[2]!==s||t[3]!==c?(l=w(`relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border transition-colors`,s,c),t[2]=s,t[3]=c,t[4]=l):l=t[4];let u=n?`translate-x-5`:`translate-x-0.5`,d;t[5]===u?d=t[6]:(d=w(`size-5 rounded-full bg-white shadow-surface transition-transform`,u),t[5]=u,t[6]=d);let f;t[7]===d?f=t[8]:(f=(0,W.jsx)(`span`,{className:d}),t[7]=d,t[8]=f);let p;return t[9]!==n||t[10]!==r||t[11]!==a||t[12]!==o||t[13]!==l||t[14]!==f?(p=(0,W.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":n,"aria-label":a,disabled:r,onClick:o,className:l,children:f}),t[9]=n,t[10]=r,t[11]=a,t[12]=o,t[13]=l,t[14]=f,t[15]=p):p=t[15],p}function rt(e){let t=(0,U.c)(71),{entry:n,config:r,runtime:i,busy:a,restarting:o,ch:s,onOpen:c,onToggle:l,onRestart:u}=e,d;t[0]===n?d=t[1]:(d=X(n),t[0]=n,t[1]=d);let f=d,p,m,h,_,v,y,b;if(t[2]!==a||t[3]!==s||t[4]!==r||t[5]!==n||t[6]!==c||t[7]!==u||t[8]!==l||t[9]!==i||t[10]!==f.enabled||t[11]!==f.ready){let e=Xe(n,r,s),o=$e(n,s);p=!f.enabled&&f.ready?l:i===`stopped`?u:c,y=`flex min-h-[15.5rem] flex-col rounded-xl bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45`;let d;t[19]===n?d=t[20]:(d=(0,W.jsx)(tt,{entry:n}),t[19]=n,t[20]=d);let g;t[21]===n.label?g=t[22]:(g=(0,W.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:n.label}),t[21]=n.label,t[22]=g);let x;t[23]===i?x=t[24]:(x=w(`mt-1 inline-flex rounded-full px-2 py-0.5 text-xs font-medium`,Ve(i)),t[23]=i,t[24]=x);let S;t[25]!==s||t[26]!==i?(S=ze(i,s),t[25]=s,t[26]=i,t[27]=S):S=t[27];let C;t[28]!==x||t[29]!==S?(C=(0,W.jsx)(`span`,{className:x,children:S}),t[28]=x,t[29]=S,t[30]=C):C=t[30];let T;t[31]!==C||t[32]!==g?(T=(0,W.jsxs)(`div`,{className:`min-w-0`,children:[g,C]}),t[31]=C,t[32]=g,t[33]=T):T=t[33];let E;t[34]!==T||t[35]!==d?(E=(0,W.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[d,T]}),t[34]=T,t[35]=d,t[36]=E):E=t[36];let D=f.enabled,O;t[37]!==s.toggleChannel||t[38]!==n.label?(O=s.toggleChannel.replace(`{{channel}}`,n.label),t[37]=s.toggleChannel,t[38]=n.label,t[39]=O):O=t[39];let k;t[40]!==a||t[41]!==l||t[42]!==f.enabled||t[43]!==O?(k=(0,W.jsx)(nt,{checked:D,disabled:a,label:O,onToggle:l}),t[40]=a,t[41]=l,t[42]=f.enabled,t[43]=O,t[44]=k):k=t[44],t[45]!==E||t[46]!==k?(b=(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[E,k]}),t[45]=E,t[46]=k,t[47]=b):b=t[47],m=`button`,h=c,_=`mt-5 min-h-[6.25rem] text-left`,v=f.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:s.cardSetupTitle}),(0,W.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm leading-5 text-fg-muted`,children:e[0]??Qe(n,s)}),o.length>0?(0,W.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:o.map(it)}):null]}),t[2]=a,t[3]=s,t[4]=r,t[5]=n,t[6]=c,t[7]=u,t[8]=l,t[9]=i,t[10]=f.enabled,t[11]=f.ready,t[12]=p,t[13]=m,t[14]=h,t[15]=_,t[16]=v,t[17]=y,t[18]=b}else p=t[12],m=t[13],h=t[14],_=t[15],v=t[16],y=t[17],b=t[18];let x;t[48]!==m||t[49]!==h||t[50]!==_||t[51]!==v?(x=(0,W.jsx)(`button`,{type:m,onClick:h,className:_,children:v}),t[48]=m,t[49]=h,t[50]=_,t[51]=v,t[52]=x):x=t[52];let S=a||o,C;t[53]!==a||t[54]!==o?(C=a||o?(0,W.jsx)(g,{className:`size-4 animate-spin`}):null,t[53]=a,t[54]=o,t[55]=C):C=t[55];let T;t[56]!==s||t[57]!==n||t[58]!==o||t[59]!==i?(T=o?s.restartingChannel:i===`stopped`?s.restartChannel:Ze(n,s),t[56]=s,t[57]=n,t[58]=o,t[59]=i,t[60]=T):T=t[60];let D;t[61]!==p||t[62]!==C||t[63]!==T||t[64]!==S?(D=(0,W.jsx)(`div`,{className:`mt-auto pt-4`,children:(0,W.jsxs)(E,{type:`button`,variant:`secondary`,className:`w-full rounded-2xl py-2.5`,onClick:p,disabled:S,children:[C,T]})}),t[61]=p,t[62]=C,t[63]=T,t[64]=S,t[65]=D):D=t[65];let O;return t[66]!==D||t[67]!==y||t[68]!==b||t[69]!==x?(O=(0,W.jsxs)(`article`,{className:y,children:[b,x,D]}),t[66]=D,t[67]=y,t[68]=b,t[69]=x,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:o,ch:s,onRestart:c,onCheck:l,onManageConnection:u}=e,d=n===`running`?m:n===`stopped`||n===`needs_setup`?F:g,f=n===`running`&&`text-emerald-600 dark:text-emerald-400`,p=n===`stopped`&&`text-red-600 dark:text-red-400`,h=n===`checking`&&`animate-spin text-amber-600 dark:text-amber-400`,_=n===`disabled`&&`text-fg-muted`,v=n===`needs_setup`&&`text-amber-600 dark:text-amber-400`,y;t[0]!==f||t[1]!==p||t[2]!==h||t[3]!==_||t[4]!==v?(y=w(`mt-0.5 size-5 shrink-0`,f,p,h,_,v),t[0]=f,t[1]=p,t[2]=h,t[3]=_,t[4]=v,t[5]=y):y=t[5];let b;t[6]!==d||t[7]!==y?(b=(0,W.jsx)(d,{className:y}),t[6]=d,t[7]=y,t[8]=b):b=t[8];let x;t[9]===s.connectionStatus?x=t[10]:(x=(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:s.connectionStatus}),t[9]=s.connectionStatus,t[10]=x);let S;t[11]!==s||t[12]!==n?(S=Be(n,s),t[11]=s,t[12]=n,t[13]=S):S=t[13];let C;t[14]===S?C=t[15]:(C=(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:S}),t[14]=S,t[15]=C);let T;t[16]!==C||t[17]!==x?(T=(0,W.jsxs)(`div`,{children:[x,C]}),t[16]=C,t[17]=x,t[18]=T):T=t[18];let D;t[19]!==T||t[20]!==b?(D=(0,W.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[b,T]}),t[19]=T,t[20]=b,t[21]=D):D=t[21];let O=i||r,k;t[22]===i?k=t[23]:(k=i?(0,W.jsx)(g,{className:`size-4 animate-spin`}):null,t[22]=i,t[23]=k);let A=i?s.checkingConnection:s.checkConnection,j;t[24]!==l||t[25]!==O||t[26]!==k||t[27]!==A?(j=(0,W.jsxs)(E,{type:`button`,variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:O,onClick:l,children:[k,A]}),t[24]=l,t[25]=O,t[26]=k,t[27]=A,t[28]=j):j=t[28];let N;t[29]!==s.restartChannel||t[30]!==s.restartingChannel||t[31]!==i||t[32]!==c||t[33]!==r||t[34]!==n?(N=n===`stopped`?(0,W.jsxs)(E,{type:`button`,variant:`primary`,className:`px-2.5 py-1.5 text-xs`,disabled:r||i,onClick:c,children:[r?(0,W.jsx)(g,{className:`size-4 animate-spin`}):(0,W.jsx)(M,{className:`size-4`}),r?s.restartingChannel:s.restartChannel]}):null,t[29]=s.restartChannel,t[30]=s.restartingChannel,t[31]=i,t[32]=c,t[33]=r,t[34]=n,t[35]=N):N=t[35];let P;t[36]!==o||t[37]!==s.connectionOptions||t[38]!==s.hideConnectionOptions||t[39]!==i||t[40]!==u||t[41]!==r||t[42]!==a?(P=o?(0,W.jsx)(E,{type:`button`,variant:`ghost`,className:`px-2.5 py-1.5 text-xs`,disabled:i||r,onClick:u,children:a?s.hideConnectionOptions:s.connectionOptions}):null,t[36]=o,t[37]=s.connectionOptions,t[38]=s.hideConnectionOptions,t[39]=i,t[40]=u,t[41]=r,t[42]=a,t[43]=P):P=t[43];let I;t[44]!==j||t[45]!==N||t[46]!==P?(I=(0,W.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[j,N,P]}),t[44]=j,t[45]=N,t[46]=P,t[47]=I):I=t[47];let L;return t[48]!==D||t[49]!==I?(L=(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:[D,I]})}),t[48]=D,t[49]=I,t[50]=L):L=t[50],L}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)(L,{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=x(e=>e.language),t=v(e),n=C(e=>!!e.token),r=a(),{channelId:o}=i(),s=ee(o),c=Oe(n,e),l=c.entries,{data:u,mutate:d,isValidating:f}=T(n?de():null,ue,{revalidateOnFocus:!0}),{data:m,mutate:g}=T(n?`channels-config-map`:null,Ie,{revalidateOnFocus:!1}),_=m?.channels??{},y=m?.bindings??[],{data:E}=T(n?`channel-routing-agents`:null,N,{revalidateOnFocus:!1}),D=te(e=>e.setPageHeader),O=te(e=>e.clearPageHeader),k=(0,H.useMemo)(()=>l.find(e=>e.id===s),[s,l]),A=k?Re(k):null,{data:j,mutate:M}=T(n&&A?Ne(A):null,()=>Pe(A)),[P,F]=(0,H.useState)(null),[I,L]=(0,H.useState)(!1),[V,ne]=(0,H.useState)(null),[ce,U]=(0,H.useState)(null),[pe,me]=(0,H.useState)(!1),[G,K]=(0,H.useState)(null),[q,J]=(0,H.useState)(null),ge=P??j??{},Y=t.channelsSettings,ye=(0,H.useMemo)(()=>k?.configSchema??{type:`object`,properties:{}},[k?.configSchema]),xe=(0,H.useMemo)(()=>Ke(ye,Fe),[ye]),Ce=(0,H.useMemo)(()=>He(k),[k]),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=k?q??_e(y,k.id):``,Le=(0,H.useMemo)(()=>(E?.items??[]).map(e=>{let n=R(e,t.agentsSettings);return{value:e.id,label:n===e.id?n:`${n} · ${e.id}`}}),[E?.items,t.agentsSettings]),Be=E?.items.find(e=>e.id===E.defaultId),Z=Be?R(Be,t.agentsSettings):E?.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((u??[]).map(e=>[e.name,e])),[u]),Je=u!==void 0,Ye=(0,H.useCallback)(e=>be(e,Ge.get(e.id),Je),[Ge,Je]),Q=(0,H.useCallback)(async()=>{await Promise.all([c.mutate(),d()])},[c,d]);Me((0,H.useCallback)(e=>{let t=Ae(e);t&&d(t,!1)},[d]),n);let Xe=(0,H.useMemo)(()=>n?(0,W.jsx)(we,{ch:Y,refreshing:c.isValidating||f,saveOk:!1,onRefresh:()=>void Q()}):null,[c.isValidating,Y,n,f,Q]);(0,H.useLayoutEffect)(()=>(D({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}),()=>O()),[O,Xe,t.settingsSections.channels,D]);let Ze=(0,H.useCallback)(e=>{r(re(e)),F(null),J(null),K(null)},[r]),Qe=(0,H.useCallback)(()=>{r(B),F(null),J(null),K(null)},[r]),$e=(0,H.useCallback)(async e=>{U(e.id),K(null);try{let t=await b(S(`/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)},[k?.id]);let et=(0,H.useCallback)(async()=>{if(!k||!P&&q===null)return!1;let e=Re(k);L(!0),K(null);try{let t=await b(S(`/api/config`),{method:`PATCH`,body:JSON.stringify({...P?{channels:{[e]:P}}:{},...q===null?{}:{bindings:ve(y,k.id,q)}})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}return P&&await M(P,!1),await g(),await c.mutate(),F(null),J(null),!0}catch(e){return K(e instanceof Error?e.message:String(e)),!1}finally{L(!1)}},[k,q,y,c,P,g,M]),it=(0,H.useCallback)(async e=>{let t=X(e),n=Re(e),r=k?.id===e.id?P:null;if(!t.enabled&&!t.ready&&!r){Ze(e.id);return}ne(e.id),K(null);try{let i=t.enabled?{enabled:!1}:r?{...r,enabled:!0}:{enabled:!0},a=await b(S(`/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 c.mutate(),await g(),await d(),k?.id===e.id&&(await M(),F(null))}catch(e){K(e instanceof Error?e.message:String(e))}finally{ne(null)}},[k?.id,c,P,g,M,d,Ze]),$=k?.ui?.modal,st=$?.placement!==`replace-config`,ct=k?Ye(k):`checking`,lt=k?!X(k).ready||pe:!1;return n?(0,W.jsxs)(oe,{gap:`gap-4`,children:[c.isLoading?(0,W.jsx)(se,{sections:2}):c.error?(0,W.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:String(c.error)}):(0,W.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:l.map(e=>(0,W.jsx)(rt,{entry:e,config:_[Re(e)]?.config,runtime:Ye(e),busy:V===e.id,restarting:ce===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:!!k,onOpenChange:e=>{e||Qe()},closeAriaLabel:Y.close,srTitle:k?.label??Y.selectChannel,srDescription:k?.description,wide:!0,footer:k?(0,W.jsx)(Te,{ch:Y,dirty:!!P||q!==null,saving:I,onCancel:Qe,onDiscard:()=>{F(null),J(null)},onSave:et}):null,children:k?(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:k}),(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:k.label}),(0,W.jsx)(`span`,{className:w(`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(k).ready&&fe(k)?.[1].result===`qr`?Y.scanLoginHint.replace(`{{channel}}`,k.label):k.description}),k.docsPath?(0,W.jsxs)(`a`,{href:k.docsPath,target:`_blank`,rel:`noreferrer`,className:`inline-flex shrink-0 items-center gap-1 text-accent hover:underline`,children:[Y.docs,(0,W.jsx)(h,{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(k).enabled?Y.enabledLabel:Y.disabledLabel}),(0,W.jsx)(nt,{checked:X(k).enabled,disabled:V===k.id,label:Y.toggleChannel.replace(`{{channel}}`,k.label),onToggle:()=>void it(k)})]})]})}),(0,W.jsx)(at,{runtime:ct,restarting:ce===k.id,checking:f,showConnectionOptions:pe,canManageConnection:X(k).ready&&$?.placement!==`replace-config`,ch:Y,onRestart:()=>void $e(k),onCheck:()=>void Q(),onManageConnection:()=>me(e=>!e)}),(0,W.jsx)(ot,{entry:k,ch:Y}),lt&&$?.placement!==`replace-config`?(0,W.jsx)(he,{entry:k,locale:e,messages:Y,compact:!0,onChanged:async()=>{await M(),await Q(),await g()}},k.id):null,$?.entrypoint&&$.placement===`before-config`?(0,W.jsx)(ie,{extensionId:k.extensionId,extensionName:k.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:k.id,entry:k,config:ge}}):null,$?.entrypoint&&$.placement!==`before-config`?(0,W.jsx)(ie,{extensionId:k.extensionId,extensionName:k.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:k.id,entry:k,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)(le,{schema:Ee,values:ge,onChange:e=>F(e),disabled:I,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)(z,{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)(p,{value:je,options:Le,placeholder:Y.agentRoutingSelect,emptyLabel:Y.agentRoutingDefault.replace(`{{agent}}`,Z||Y.agentRoutingSelect),ariaLabel:Y.agentRouting,disabled:I||!E,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)(z,{className:`size-4 text-fg-muted`}),Y.advancedConfiguration]}),(0,W.jsx)(`div`,{className:`bg-surface-base/50 p-4`,children:(0,W.jsx)(le,{schema:De,values:ge,onChange:e=>F(e),disabled:I,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,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{l as i,p as a}from"./chunk-KS7C4IRE-BaASWQor.js";import{a as o,i as s,n as c,o as l,r as u,s as d,t as f}from"./dist-CpzYSoz7.js";import{t as p}from"./check-DUBLcKHA.js";import{n as m,r as h,t as g}from"./popover-select-C-Hj-nXR.js";import{t as _}from"./circle-check-C23XjkUj.js";import{t as v}from"./link-2-D_ZKYUW7.js";import{t as y}from"./loader-circle-CifKLtgG.js";import{t as b}from"./plus-Q2yW6OE7.js";import{t as x}from"./search-DA7gz22f.js";import{t as S}from"./x-B_N4OPjy.js";import{n as C}from"./copy-to-clipboard-HOJ79TWv.js";import{t as w}from"./messages-BbdwoxVo.js";import{a as T,n as E,r as D,s as O}from"./locale-store-CBoCuIMx.js";import{t as k}from"./cn-JdwAhgNB.js";import{t as A}from"./button-CtTvuElV.js";import{n as j}from"./interaction-BmQogeqz.js";import{n as M,r as N}from"./gateway-config-swr-826dipyU.js";import{s as P}from"./form-field-width-DJw_jULe.js";import{i as F,o as I}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{t as L}from"./electron-env-DH5wF8X8.js";import{a as R,i as z,n as B,r as V,t as H}from"./dist-DLmwHyAh.js";import{Ao as U,Bo as W,Co as G,Cs as ee,Do as te,Eo as ne,Es as re,Fo as ie,Fs as ae,G as oe,Gs as se,Io as ce,J as le,K as ue,Ll as de,Lo as fe,Mo as pe,Ms as me,Nl as he,No as ge,Oo as _e,Po as ve,Qs as ye,Ro as K,Sl as q,So as J,To as be,Vc as Y,Vo as xe,Xs as Se,Ys as Ce,_c as we,_o as Te,an as Ee,bo as De,ec as Oe,fo as ke,go as Ae,ho as je,in as Me,jo as Ne,ko as Pe,lc as Fe,ll as Ie,ln as Le,ml as Re,mo as ze,ni as Be,oa as Ve,on as He,po as Ue,ps as We,q as X,sc as Ge,sn as Ke,vo as qe,wo as Je,xl as Ye,xo as Xe,yo as Ze,zo as Qe}from"./index-eZjksPvq.js";import{n as $e,r as et,t as tt}from"./oauth-authorization-window-Cdolr2wE.js";import{t as nt}from"./page-tabs-BaEQMYm_.js";var Z=e(t(),1),Q=n(),$=r();function rt(e){let t=(0,Q.c)(74),{connector:n,installed:r,onInstall:i,onOpenDetails:a,t:o}=e,s,c,l,u,d,f,p,m,h,g;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(it),v=e.slice(0,3),y=Math.max(0,e.length-v.length),b=o.connect,x=n.verificationLevel===`verified`?o.connectorVerified:n.verificationLevel===`beta`?o.connectorBeta:n.verificationLevel===`experimental`?o.connectorExperimental:null,S;t[20]!==b||t[21]!==n||t[22]!==i?(S=e=>(0,$.jsxs)(A,{type:`button`,variant:`primary`,className:k(`h-8 justify-center px-2.5 text-xs font-medium`,e),onClick:e=>{e.stopPropagation(),i(n)},children:[(0,$.jsx)(we,{className:`size-4`}),b]}),t[20]=b,t[21]=n,t[22]=i,t[23]=S):S=t[23],s=S;let C;t[24]!==n||t[25]!==a?(C=e=>{!a||e.currentTarget!==e.target||e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),a(n))},t[24]=n,t[25]=a,t[26]=C):C=t[26];let w=C,T=a?`cursor-pointer`:null;t[27]===T?f=t[28]:(f=k(`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`,T),t[27]=T,t[28]=f),p=a?`button`:void 0,m=a?0:void 0,t[29]!==n||t[30]!==a?(h=()=>a?.(n),t[29]=n,t[30]=a,t[31]=h):h=t[31],g=w,c=`flex min-w-0 flex-1 flex-col`;let E;t[32]===n?E=t[33]:(E=(0,$.jsx)(le,{connector:n}),t[32]=n,t[33]=E);let D;t[34]===n.displayName?D=t[35]:(D=(0,$.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:n.displayName}),t[34]=n.displayName,t[35]=D);let O;t[36]===x?O=t[37]:(O=x?(0,$.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:x}):null,t[36]=x,t[37]=O);let j;t[38]!==D||t[39]!==O?(j=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[D,O]}),t[38]=D,t[39]=O,t[40]=j):j=t[40];let M;t[41]!==E||t[42]!==j?(M=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[E,j]}),t[41]=E,t[42]=j,t[43]=M):M=t[43];let N;t[44]!==r||t[45]!==s?(N=r?null:(0,$.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:s()}),t[44]=r,t[45]=s,t[46]=N):N=t[46];let P;t[47]!==r||t[48]!==o.connectedBadge?(P=r?(0,$.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,$.jsx)(_,{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,$.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?(l=(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[M,F]}),t[53]=M,t[54]=F,t[55]=l):l=t[55],t[56]===n.description?u=t[57]:(u=(0,$.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]=u),d=v.length>0?(0,$.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-1.5`,children:[v.map(e=>(0,$.jsx)(`span`,{className:`rounded-md bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:o.connectorCapabilityLabels[e]??e},e)),y>0?(0,$.jsxs)(`span`,{className:`rounded-md bg-surface-base px-2 py-0.5 text-[11px] text-fg-subtle`,children:[`+`,y]}):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]=s,t[11]=c,t[12]=l,t[13]=u,t[14]=d,t[15]=f,t[16]=p,t[17]=m,t[18]=h,t[19]=g}else s=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];let v;t[58]!==c||t[59]!==l||t[60]!==u||t[61]!==d?(v=(0,$.jsxs)(`div`,{className:c,children:[l,u,d]}),t[58]=c,t[59]=l,t[60]=u,t[61]=d,t[62]=v):v=t[62];let y;t[63]!==r||t[64]!==s?(y=r?null:(0,$.jsx)(`div`,{className:`mt-4 flex flex-col gap-2 border-t border-edge pt-3 sm:hidden`,children:s(`w-full`)}),t[63]=r,t[64]=s,t[65]=y):y=t[65];let b;return t[66]!==v||t[67]!==y||t[68]!==f||t[69]!==p||t[70]!==m||t[71]!==h||t[72]!==g?(b=(0,$.jsxs)(`div`,{className:f,role:p,tabIndex:m,onClick:h,onKeyDown:g,children:[v,y]}),t[66]=v,t[67]=y,t[68]=f,t[69]=p,t[70]=m,t[71]=h,t[72]=g,t[73]=b):b=t[73],b}function it(e){return!e.startsWith(`runtime.`)&&!e.startsWith(`auth.`)}var at=[`c0`,`c1`,`c2`,`c3`,`c4`,`c5`];function ot(e,t){return t.some(t=>t.connectorId===e.id)}var st=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`;function ct(){let e=(0,Q.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`div`,{className:k(`size-10 shrink-0 rounded-xl`,st)}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.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,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 items-start gap-3`,children:[t,(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,$.jsx)(`div`,{className:k(`h-4 min-w-0 flex-1`,st)}),(0,$.jsx)(`div`,{className:k(`h-8 w-[4.5rem] shrink-0 rounded-lg`,st)})]}),(0,$.jsx)(`div`,{className:k(`h-3 w-full`,st)}),(0,$.jsx)(`div`,{className:k(`h-3 w-[88%]`,st)})]})]})}),e[1]=n):n=e[1],n}var lt=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`;function ut(){let e=(0,Q.c)(4),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`div`,{className:k(`size-10 shrink-0 rounded-xl`,lt)}),e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2`,children:[(0,$.jsx)(`div`,{className:k(`h-4 w-48 max-w-full`,lt)}),(0,$.jsx)(`div`,{className:k(`h-3 w-72 max-w-full`,lt)})]}),e[1]=n):n=e[1];let r;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[t,(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-start justify-between gap-3`,children:[n,(0,$.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,$.jsx)(`div`,{className:k(`h-9 w-20 rounded-lg`,lt)}),(0,$.jsx)(`div`,{className:k(`h-9 w-20 rounded-lg`,lt)})]})]})]}),e[2]=r):r=e[2];let i;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsxs)(`div`,{className:`rounded-2xl bg-surface-panel p-4 shadow-surface`,"aria-hidden":!0,children:[r,(0,$.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,$.jsx)(`div`,{className:k(`h-8 w-20 rounded-md`,lt)}),(0,$.jsx)(`div`,{className:k(`h-8 w-24 rounded-md`,lt)}),(0,$.jsx)(`div`,{className:k(`h-8 w-28 rounded-md`,lt)})]}),(0,$.jsx)(`div`,{className:k(`mt-3 h-20 rounded-xl`,lt)})]}),e[3]=i):i=e[3],i}function dt(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,String(n)),e)}function ft(e,t){return t.connectorCapabilityLabels[e]??e}function pt(e,t){if(e.runtime.type===`mcp`)return dt(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 dt(t.connectorRuntimeGeneric,{runtime:e.runtime.type,id:n??e.runtime.type})}function mt(e,t){return e.auth.mode===`oauth`?t.connectorAuthOAuth:e.auth.mode===`apiKey`?t.connectorAuthApiKey:t.connectorAuthNone}function ht(e){return(e.setup.secrets??[]).filter(e=>e.required).length+(e.setup.config??[]).filter(e=>e.required).length}function gt(e){let t=(0,Q.c)(12),{title:n,items:r}=e;if(r.length===0)return null;let i;t[0]===n?i=t[1]:(i=(0,$.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(_t),t[2]=r,t[3]=a);let o;t[4]===r.length?o=t[5]:(o=r.length>16?(0,$.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,$.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,$.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 _t(e){return(0,$.jsxs)(`div`,{className:`border-b border-edge-subtle px-3 py-2 last:border-b-0`,children:[(0,$.jsx)(`div`,{className:`break-words font-mono text-xs font-medium text-fg`,children:e.title}),e.description?(0,$.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:e.description}):null]},e.id)}function vt({connector:e,installed:t,onClose:n,onInstall:r,t:i}){let[a,p]=(0,Z.useState)(!1),[m,h]=(0,Z.useState)(null),[g,v]=(0,Z.useState)(null),b=ht(e),x=e.capabilities.slice(0,8),C=Math.max(0,e.capabilities.length-x.length),w=[...(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}))],T=async()=>{p(!0),v(null);try{h(await te(e))}catch(e){h(null),v(e instanceof Error?e.message:String(e))}finally{p(!1)}};return(0,$.jsx)(f,{open:!0,onOpenChange:e=>{e||n()},children:(0,$.jsxs)(l,{children:[(0,$.jsx)(o,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(u,{className:k(`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,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,$.jsx)(le,{connector:e,size:`lg`}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[t?(0,$.jsx)(`div`,{className:`mb-2 flex flex-wrap items-center gap-2`,children:(0,$.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,$.jsx)(_,{className:`size-3`,"aria-hidden":!0}),i.connectedBadge]})}):null,(0,$.jsx)(d,{className:`text-base font-semibold text-fg`,children:e.displayName}),(0,$.jsx)(s,{className:`mt-1 line-clamp-3 text-sm leading-6 text-fg-muted`,children:e.description})]})]}),(0,$.jsx)(c,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,className:k(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,j.focusRingPanel),"aria-label":i.modalClose,children:[(0,$.jsx)(S,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`sr-only`,children:i.modalClose})]})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:[(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,$.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,$.jsx)(We,{className:`size-3.5`,"aria-hidden":!0}),i.detailTools]}),(0,$.jsx)(`p`,{className:`mt-2 text-sm font-semibold text-fg`,children:m?dt(i.connectorPreviewToolsCount,{count:m.toolCount}):i.connectorPreviewUnknown})]}),(0,$.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,$.jsx)(Y,{className:`size-3.5`,"aria-hidden":!0}),i.detailPermissions]}),(0,$.jsx)(`p`,{className:`mt-2 text-sm font-semibold text-fg`,children:mt(e,i)})]}),(0,$.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,$.jsx)(Re,{className:`size-3.5`,"aria-hidden":!0}),i.connectorRequiredInputs]}),(0,$.jsx)(`p`,{className:`mt-2 text-sm font-semibold text-fg`,children:dt(i.connectorRequiredInputsCount,{count:b})})]})]}),(0,$.jsxs)(`div`,{className:`mt-5 grid gap-5 lg:grid-cols-[minmax(0,1fr)_18rem]`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 space-y-5`,children:[(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:i.connectorCapabilitiesTitle}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:[x.map(e=>(0,$.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-base px-2 py-1 text-xs text-fg-muted`,children:ft(e,i)},e)),C>0?(0,$.jsxs)(`span`,{className:`rounded-md border border-edge bg-surface-base px-2 py-1 text-xs text-fg-subtle`,children:[`+`,C]}):null]})]}),g?(0,$.jsx)(`p`,{className:`rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:g}):null,m?(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:i.connectorPreviewTitle}),(0,$.jsx)(`span`,{className:k(`rounded-full px-2 py-0.5 text-xs font-medium`,m.ok?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-amber-500/10 text-amber-700 dark:text-amber-300`),children:m.ok?i.healthStatusHealthy:i.healthStatusLabels[m.status]??m.status})]}),(0,$.jsxs)(`div`,{className:`mb-3 grid gap-2 text-xs sm:grid-cols-3`,children:[(0,$.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base px-3 py-2`,children:[(0,$.jsx)(`div`,{className:`font-semibold text-fg`,children:m.toolCount}),(0,$.jsx)(`div`,{className:`text-fg-muted`,children:i.toolsMetric})]}),(0,$.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base px-3 py-2`,children:[(0,$.jsx)(`div`,{className:`font-semibold text-fg`,children:m.resourceCount}),(0,$.jsx)(`div`,{className:`text-fg-muted`,children:i.resourcesMetric})]}),(0,$.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base px-3 py-2`,children:[(0,$.jsx)(`div`,{className:`font-semibold text-fg`,children:m.promptCount}),(0,$.jsx)(`div`,{className:`text-fg-muted`,children:i.promptsMetric})]})]}),(0,$.jsxs)(`div`,{className:`grid gap-2`,children:[(0,$.jsx)(gt,{title:i.detailTools,items:m.tools.map(e=>({id:e.name,title:e.shortName??e.name,description:e.description}))}),(0,$.jsx)(gt,{title:i.detailResources,items:m.resources.map(e=>({id:e.uri,title:e.title??e.name??e.uri,description:e.description??e.uri}))}),(0,$.jsx)(gt,{title:i.detailPrompts,items:m.prompts.map(e=>({id:e.name,title:e.title??e.name,description:e.description??dt(i.promptArgumentCount,{count:e.argumentCount})}))})]}),m.error?(0,$.jsx)(`p`,{className:`mt-3 text-xs leading-5 text-fg-subtle`,children:m.error}):null,m.action?(0,$.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-subtle`,children:m.action}):null]}):null]}),(0,$.jsxs)(`aside`,{className:`space-y-3`,children:[(0,$.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,$.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,$.jsx)(Y,{className:`size-4 text-accent`,"aria-hidden":!0}),i.detailPermissions]}),(0,$.jsx)(`p`,{className:`mt-2 text-sm font-medium text-fg`,children:mt(e,i)})]}),(0,$.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,$.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,$.jsx)(Re,{className:`size-4 text-accent`,"aria-hidden":!0}),i.connectorSetupTitle]}),w.length>0?(0,$.jsx)(`div`,{className:`mt-3 divide-y divide-edge overflow-hidden rounded-lg border border-edge`,children:w.map(e=>(0,$.jsxs)(`div`,{className:`bg-surface-panel px-3 py-2.5`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.label}),(0,$.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,$.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,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:e.description}):null]},e.key))}):(0,$.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:i.connectorSetupNone})]}),(0,$.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,$.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,$.jsx)(Se,{className:`size-4 text-accent`,"aria-hidden":!0}),i.connectorRuntimeTitle]}),(0,$.jsx)(`p`,{className:`mt-2 break-words text-xs leading-5 text-fg-muted`,children:pt(e,i)})]})]})]})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[(0,$.jsx)(c,{asChild:!0,children:(0,$.jsx)(A,{variant:`secondary`,children:i.modalClose})}),(0,$.jsxs)(A,{variant:`secondary`,disabled:a,onClick:()=>void T(),children:[a?(0,$.jsx)(y,{className:`size-4 animate-spin`}):(0,$.jsx)(We,{className:`size-4`}),i.connectorPreviewButton]}),t?(0,$.jsxs)(A,{variant:`secondary`,disabled:!0,children:[(0,$.jsx)(Fe,{className:`size-4`}),i.connectedBadge]}):(0,$.jsxs)(A,{variant:`primary`,onClick:()=>{r(e),n()},children:[(0,$.jsx)(we,{className:`size-4`}),i.connect]})]})]})]})})}var yt=k(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,P);function bt(e){let t=(0,Q.c)(58),{open:n,sessionIdleTtlMinutes:r,saving:i,onChange:a,onSave:p,onClose:m,t:h,mcp:g}=e,_;t[0]===m?_=t[1]:(_=e=>{e||m()},t[0]=m,t[1]=_);let v;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(o,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),t[2]=v):v=t[2];let b;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(b=k(`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]=b):b=t[3];let x;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(`span`,{className:`flex size-10 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-accent-fg`,children:(0,$.jsx)(Ge,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0})}),t[4]=x):x=t[4];let C;t[5]===h.runtimeSettingsTitle?C=t[6]:(C=(0,$.jsx)(d,{className:`text-base font-semibold text-fg`,children:h.runtimeSettingsTitle}),t[5]=h.runtimeSettingsTitle,t[6]=C);let w;t[7]===h.runtimeSettingsHint?w=t[8]:(w=(0,$.jsx)(s,{className:`mt-1 text-sm text-fg-muted`,children:h.runtimeSettingsHint}),t[7]=h.runtimeSettingsHint,t[8]=w);let T;t[9]!==C||t[10]!==w?(T=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[x,(0,$.jsxs)(`div`,{className:`min-w-0`,children:[C,w]})]}),t[9]=C,t[10]=w,t[11]=T):T=t[11];let E;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(E=k(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,j.focusRingPanel),t[12]=E):E=t[12];let D;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,$.jsx)(S,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),t[13]=D):D=t[13];let O;t[14]===h.modalClose?O=t[15]:(O=(0,$.jsx)(c,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:E,"aria-label":h.modalClose,children:D})}),t[14]=h.modalClose,t[15]=O);let M;t[16]!==O||t[17]!==T?(M=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[T,O]}),t[16]=O,t[17]=T,t[18]=M):M=t[18];let N;t[19]===g.idleTtlLabel?N=t[20]:(N=(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:g.idleTtlLabel}),t[19]=g.idleTtlLabel,t[20]=N);let P;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(P=k(yt,`w-40 flex-none`),t[21]=P):P=t[21];let F=r??``,I;t[22]===a?I=t[23]:(I=e=>{let t=e.currentTarget.value.trim();a(t===``?void 0:Number.parseInt(t,10))},t[22]=a,t[23]=I);let L;t[24]!==g.idleTtlPlaceholder||t[25]!==F||t[26]!==I?(L=(0,$.jsx)(`input`,{type:`number`,min:0,className:P,value:F,placeholder:g.idleTtlPlaceholder,onChange:I}),t[24]=g.idleTtlPlaceholder,t[25]=F,t[26]=I,t[27]=L):L=t[27];let R;t[28]===g.idleTtlHint?R=t[29]:(R=(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:g.idleTtlHint}),t[28]=g.idleTtlHint,t[29]=R);let z;t[30]!==N||t[31]!==L||t[32]!==R?(z=(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:(0,$.jsxs)(`label`,{className:`flex max-w-xl flex-col gap-1.5`,children:[N,L,R]})}),t[30]=N,t[31]=L,t[32]=R,t[33]=z):z=t[33];let B;t[34]!==m||t[35]!==i||t[36]!==h.modalCancel?(B=(0,$.jsx)(A,{type:`button`,variant:`secondary`,disabled:i,onClick:m,children:h.modalCancel}),t[34]=m,t[35]=i,t[36]=h.modalCancel,t[37]=B):B=t[37];let V;t[38]===p?V=t[39]:(V=()=>void p(),t[38]=p,t[39]=V);let H;t[40]===i?H=t[41]:(H=i?(0,$.jsx)(y,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,t[40]=i,t[41]=H);let U;t[42]!==g.save||t[43]!==i||t[44]!==V||t[45]!==H?(U=(0,$.jsxs)(A,{type:`button`,variant:`primary`,disabled:i,onClick:V,children:[H,g.save]}),t[42]=g.save,t[43]=i,t[44]=V,t[45]=H,t[46]=U):U=t[46];let W;t[47]!==B||t[48]!==U?(W=(0,$.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[B,U]}),t[47]=B,t[48]=U,t[49]=W):W=t[49];let G;t[50]!==M||t[51]!==z||t[52]!==W?(G=(0,$.jsxs)(l,{children:[v,(0,$.jsxs)(u,{className:b,children:[M,z,W]})]}),t[50]=M,t[51]=z,t[52]=W,t[53]=G):G=t[53];let ee;return t[54]!==n||t[55]!==_||t[56]!==G?(ee=(0,$.jsx)(f,{open:n,onOpenChange:_,children:G}),t[54]=n,t[55]=_,t[56]=G,t[57]=ee):ee=t[57],ee}var xt=(0,Z.memo)(function(e){let t=(0,Q.c)(12),{value:n,onChange:r,placeholder:i,className:a}=e,o;t[0]===a?o=t[1]:(o=k(`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 s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(x,{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]=s):s=t[2];let c;t[3]===r?c=t[4]:(c=e=>r(e.currentTarget.value),t[3]=r,t[4]=c);let l;t[5]!==i||t[6]!==c||t[7]!==n?(l=(0,$.jsx)(`input`,{type:`search`,enterKeyHint:`search`,value:n,onChange:c,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]=c,t[7]=n,t[8]=l):l=t[8];let u;return t[9]!==o||t[10]!==l?(u=(0,$.jsxs)(`label`,{className:o,children:[s,l]}),t[9]=o,t[10]=l,t[11]=u):u=t[11],u}),St=(0,Z.memo)(function(e){let t=(0,Q.c)(30),{onBrowseCatalog:n,onAddCustomServer:r,onOpenRuntimeSettings:i,addLabel:a,browseLabel:o,customLabel:s,settingsLabel:c}=e,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(Ce,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[0]=l):l=t[0];let u;t[1]===c?u=t[2]:(u=(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:c}),t[1]=c,t[2]=u);let d;t[3]!==i||t[4]!==c||t[5]!==u?(d=(0,$.jsxs)(A,{type:`button`,variant:`secondary`,className:`shrink-0 gap-2`,"aria-label":c,title:c,onClick:i,children:[l,u]}),t[3]=i,t[4]=c,t[5]=u,t[6]=d):d=t[6];let f;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(b,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[7]=f):f=t[7];let p;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,$.jsx)(de,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[8]=p):p=t[8];let m;t[9]===a?m=t[10]:(m=(0,$.jsx)(Le,{asChild:!0,children:(0,$.jsxs)(A,{type:`button`,variant:`primary`,className:`shrink-0 gap-2`,children:[f,a,p]})}),t[9]=a,t[10]=m);let h;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(h=k(`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none data-[highlighted]:bg-surface-hover`,j.transition),t[11]=h):h=t[11];let g;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(me,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[12]=g):g=t[12];let _;t[13]!==o||t[14]!==n?(_=(0,$.jsxs)(Ee,{className:h,onSelect:n,children:[g,o]}),t[13]=o,t[14]=n,t[15]=_):_=t[15];let v;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(v=k(`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none data-[highlighted]:bg-surface-hover`,j.transition),t[16]=v):v=t[16];let y;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(We,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[17]=y):y=t[17];let x;t[18]!==s||t[19]!==r?(x=(0,$.jsxs)(Ee,{className:v,onSelect:r,children:[y,s]}),t[18]=s,t[19]=r,t[20]=x):x=t[20];let S;t[21]!==x||t[22]!==_?(S=(0,$.jsx)(He,{children:(0,$.jsxs)(Me,{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[21]=x,t[22]=_,t[23]=S):S=t[23];let C;t[24]!==S||t[25]!==m?(C=(0,$.jsxs)(Ke,{children:[m,S]}),t[24]=S,t[25]=m,t[26]=C):C=t[26];let w;return t[27]!==C||t[28]!==d?(w=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center justify-end gap-2`,children:[d,C]}),t[27]=C,t[28]=d,t[29]=w):w=t[29],w}),Ct=/^([^:=]+)[:=](.*)$/;function wt(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=Ct.exec(t);r&&n.push({key:r[1].trim(),value:r[2].trim()})}return n.length>0?n:null}function Tt(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 Et(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 Dt(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 Ot(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)||Dt(t)&&(r[e]=t);return r}function kt(e){let t=e.trim();if(t)return t.split(/\s+/).filter(Boolean)}function At(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 jt(e){if(e.transport===`stdio`){let t={command:e.command.trim()},n=kt(e.argsText);return n?.length&&(t.args=n),e.cwd.trim()&&(t.cwd=e.cwd.trim()),e.envJson.trim()&&(t.env=At(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=Tt(e.headers);return n&&(t.headers=n),e.transport===`streamable-http`&&e.auth===`oauth`&&(t.auth={type:`oauth`,...e.oauthClientId.trim()?{clientId:e.oauthClientId.trim()}:{}}),e.connectionTimeoutMs!=null&&Number.isFinite(e.connectionTimeoutMs)&&(t.connectionTimeoutMs=e.connectionTimeoutMs),e.requestTimeoutMs!=null&&Number.isFinite(e.requestTimeoutMs)&&(t.requestTimeoutMs=e.requestTimeoutMs),t}function Mt(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,o=t.auth&&typeof t.auth==`object`&&!Array.isArray(t.auth)?t.auth:void 0,s=o?.type===`oauth`?`oauth`:`none`;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:Et(a),auth:s,oauthClientId:typeof o?.clientId==`string`?o.clientId:``,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 Nt(e=``){return{clientKey:crypto.randomUUID(),id:e,transport:`stdio`,command:``,argsText:``,envJson:``,cwd:``,url:``,headers:[{key:`Authorization`,value:``}],auth:`none`,oauthClientId:``,connectionTimeoutMs:void 0,requestTimeoutMs:void 0}}function Pt(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)||Dt(t)?[]:[Mt(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 Ft(e){return jt(e)}async function It(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]=jt(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 T(D(`/api/config`),{method:`PATCH`,body:JSON.stringify({mcp:r})}),M()}async function Lt(e,t,n=``){let r=await T(D(`/api/mcp/servers/${encodeURIComponent(e)}/oauth${n}`),{method:t});if(!r.payload)throw Error(r.error??`MCP OAuth request failed`);return r.payload}function Rt(e){return Lt(e,`GET`)}function zt(e){return Lt(e,`POST`,`/start`)}function Bt(e){return Lt(e,`DELETE`)}function Vt(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();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 Ht(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 Ut(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 Wt(e,t){let n=await T(D(`/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=Vt(n.payload.tools),i=Ht(n.payload.resources),a=Ut(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 Gt(e){return e.connectionTimeoutMs==null||!Number.isFinite(e.connectionTimeoutMs)?``:String(Math.round(e.connectionTimeoutMs/1e3))}function Kt(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 qt(e){return e.requestTimeoutMs==null||!Number.isFinite(e.requestTimeoutMs)?``:String(Math.round(e.requestTimeoutMs/1e3))}function Jt(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 Yt(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 Xt({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,m]=(0,Z.useState)(null),[h,g]=(0,Z.useState)(!1),_=Yt(e),b=e.transport===`streamable-http`&&e.auth===`oauth`;(0,Z.useEffect)(()=>{if(!b){m(null);return}let t=!1,n=async()=>{try{let n=await Rt(e.id.trim());t||(m(n),n.status===`error`&&n.session?.error&&f(n.session.error),n.status===`connected`&&f(null))}catch(e){t||f(e instanceof Error?e.message:String(e))}};n();let r=window.setInterval(()=>{p?.status===`authorizing`&&n()},1e3);return()=>{t=!0,window.clearInterval(r)}},[p?.status,e.id,b]);let x=(0,Z.useCallback)(async()=>{g(!0),f(null);let n=et();try{let r=await zt(e.id.trim());m(r),r.status===`error`&&r.session?.error&&f(r.session.error),r.status===`connected`&&f(null);let i=r.session?.authorizationUrl;i?await $e(i,n)||f(t.oauthOpenFailed):tt(n)}catch(e){tt(n),f(e instanceof Error?e.message:String(e))}finally{g(!1)}},[e.id,t.oauthOpenFailed]),S=(0,Z.useCallback)(async()=>{g(!0),f(null);try{m(await Bt(e.id.trim()))}catch(e){f(e instanceof Error?e.message:String(e))}finally{g(!1)}},[e.id]),C=(0,Z.useCallback)(async()=>{o(!0),f(null);try{let t=await Wt(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]),w=(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,$.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,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:e.id.trim()||t.cardUntitled}),(0,$.jsx)(`span`,{className:`rounded-full bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:n.customBadge}),(0,$.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]}),b&&p?(0,$.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,children:t.oauthStatus[p.status===`not_configured`?`disconnected`:p.status]}):null]}),_?(0,$.jsx)(`p`,{className:`mt-3 line-clamp-2 break-all font-mono text-xs leading-5 text-fg-subtle`,title:_,children:_}):null,d?(0,$.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,$.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:X(n.customCapabilitySummary,{tools:String(l.toolCount),resources:String(l.resourceCount),prompts:String(l.promptCount)})}):null]}),(0,$.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-2 border-t border-edge pt-3`,onClick:e=>e.stopPropagation(),children:[(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:n.connectorDetails}),(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[b&&p?.status!==`connected`?(0,$.jsxs)(A,{variant:`secondary`,disabled:h,onClick:()=>void x(),children:[h?(0,$.jsx)(y,{className:`size-4 animate-spin`}):(0,$.jsx)(v,{className:`size-4`}),p?.status===`authorizing`?t.oauthOpenAuthorization:t.oauthConnect]}):(0,$.jsxs)(A,{variant:`secondary`,disabled:a,onClick:()=>void C(),children:[a?(0,$.jsx)(y,{className:`size-4 animate-spin`}):(0,$.jsx)(Fe,{className:`size-4`}),t.testConnection]}),b&&p?.status===`connected`?(0,$.jsxs)(A,{variant:`ghost`,disabled:h,onClick:()=>void S(),children:[h?(0,$.jsx)(y,{className:`size-4 animate-spin`}):(0,$.jsx)(ee,{className:`size-4`}),t.oauthDisconnect]}):null,(0,$.jsxs)(A,{variant:`ghost`,disabled:s,onClick:()=>void w(),children:[s?(0,$.jsx)(y,{className:`size-4 animate-spin`}):(0,$.jsx)(re,{className:`size-4`}),t.removeServer]})]})]})]})}function Zt(e,t){return e?t&&e.startsWith(t)?e.slice(t.length):e:``}function Qt(e,t,n){let r=t.trim().toLowerCase();if(!r)return!0;let i=e.shortName||Zt(e.name,n);return[e.name,i,e.description].filter(Boolean).join(`
|
|
2
|
-
`).toLowerCase().includes(r)}function $t(e,t){return e?t&&e.startsWith(t)?e.slice(t.length):e:``}function en(e){let t=(0,Q.c)(29),{tools:n,stripPrefix:r,searchPlaceholder:i,searchEmptyLabel:a}=e,[o,s]=(0,Z.useState)(``),c;if(t[0]!==o||t[1]!==r||t[2]!==n){let e;t[4]!==o||t[5]!==r?(e=e=>Qt(e,o,r),t[4]=o,t[5]=r,t[6]=e):e=t[6],c=n.filter(e),t[0]=o,t[1]=r,t[2]=n,t[3]=c}else c=t[3];let l=c,u;t[7]===o?u=t[8]:(u=o.trim(),t[7]=o,t[8]=u);let d=u.length>0,f;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(x,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),t[9]=f):f=t[9];let p,m;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(p=k(`w-full rounded-lg border border-edge bg-surface-panel py-2 pl-9 pr-3 text-sm text-fg`,`placeholder:text-fg-subtle`,P),m=e=>s(e.target.value),t[10]=p,t[11]=m):(p=t[10],m=t[11]);let h;t[12]!==o||t[13]!==i?(h=(0,$.jsxs)(`div`,{className:`relative`,children:[f,(0,$.jsx)(`input`,{type:`search`,value:o,placeholder:i,"aria-label":i,className:p,onChange:m})]}),t[12]=o,t[13]=i,t[14]=h):h=t[14];let g;t[15]!==l.length||t[16]!==d||t[17]!==n.length?(g=d?(0,$.jsxs)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:[l.length,` / `,n.length]}):null,t[15]=l.length,t[16]=d,t[17]=n.length,t[18]=g):g=t[18];let _;t[19]!==h||t[20]!==g?(_=(0,$.jsxs)(`div`,{className:`border-b border-edge px-5 py-3`,children:[h,g]}),t[19]=h,t[20]=g,t[21]=_):_=t[21];let v;t[22]!==l||t[23]!==a||t[24]!==r?(v=(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:l.length===0?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:a}):(0,$.jsx)(`ul`,{className:`flex flex-col gap-2`,children:l.map((e,t)=>{let n=e.shortName||$t(e.name,r)||e.name||`?`,i=e.name||`tool-${t}`;return(0,$.jsxs)(`li`,{className:`min-w-0 rounded-lg border border-edge bg-surface-base px-3 py-2.5`,children:[(0,$.jsx)(`div`,{className:`truncate font-mono text-sm font-medium text-fg`,title:e.name===n?n:e.name,children:n}),e.description?(0,$.jsx)(`p`,{className:`mt-1 truncate text-xs leading-relaxed text-fg-muted`,title:e.description,children:e.description}):null]},i)})})}),t[22]=l,t[23]=a,t[24]=r,t[25]=v):v=t[25];let y;return t[26]!==_||t[27]!==v?(y=(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[_,v]}),t[26]=_,t[27]=v,t[28]=y):y=t[28],y}function tn(e){let t=(0,Q.c)(38),{open:n,onOpenChange:r,serverId:i,title:a,subtitle:p,searchPlaceholder:m,searchEmptyLabel:h,emptyLabel:g,closeLabel:_,tools:v,stripPrefix:y}=e,b;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(o,{className:k(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,I)}),t[0]=b):b=t[0];let x;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(x=k(`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`,F,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`),t[1]=x):x=t[1];let C;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,$.jsx)(We,{className:`size-4 shrink-0 text-accent`,"aria-hidden":!0}),t[2]=C):C=t[2];let w;t[3]===a?w=t[4]:(w=(0,$.jsxs)(d,{className:`flex items-center gap-2 text-base font-semibold text-fg`,children:[C,a]}),t[3]=a,t[4]=w);let T;t[5]!==i||t[6]!==p||t[7]!==v.length?(T=p.replace(`{{serverId}}`,i).replace(`{{count}}`,String(v.length)),t[5]=i,t[6]=p,t[7]=v.length,t[8]=T):T=t[8];let E;t[9]===T?E=t[10]:(E=(0,$.jsx)(s,{className:`mt-1 text-sm text-fg-muted`,children:T}),t[9]=T,t[10]=E);let D;t[11]!==w||t[12]!==E?(D=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[w,E]}),t[11]=w,t[12]=E,t[13]=D):D=t[13];let O;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,$.jsx)(S,{className:`size-4`,"aria-hidden":!0}),t[14]=O):O=t[14];let j;t[15]===_?j=t[16]:(j=(0,$.jsx)(c,{asChild:!0,children:(0,$.jsx)(A,{type:`button`,variant:`ghost`,className:`size-8 shrink-0 px-0`,"aria-label":_,children:O})}),t[15]=_,t[16]=j);let M;t[17]!==D||t[18]!==j?(M=(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3 border-b border-edge px-5 py-4`,children:[D,j]}),t[17]=D,t[18]=j,t[19]=M):M=t[19];let N;t[20]!==g||t[21]!==n||t[22]!==h||t[23]!==m||t[24]!==i||t[25]!==y||t[26]!==v?(N=v.length>0?(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,$.jsx)(en,{tools:v,stripPrefix:y,searchPlaceholder:m,searchEmptyLabel:h},`${i}-${n?`open`:`closed`}`)}):(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:g})}),t[20]=g,t[21]=n,t[22]=h,t[23]=m,t[24]=i,t[25]=y,t[26]=v,t[27]=N):N=t[27];let P;t[28]===_?P=t[29]:(P=(0,$.jsx)(`div`,{className:`flex justify-end border-t border-edge px-5 py-3`,children:(0,$.jsx)(c,{asChild:!0,children:(0,$.jsx)(A,{type:`button`,variant:`secondary`,children:_})})}),t[28]=_,t[29]=P);let L;t[30]!==M||t[31]!==N||t[32]!==P?(L=(0,$.jsxs)(l,{children:[b,(0,$.jsxs)(u,{className:x,children:[M,N,P]})]}),t[30]=M,t[31]=N,t[32]=P,t[33]=L):L=t[33];let R;return t[34]!==r||t[35]!==n||t[36]!==L?(R=(0,$.jsx)(f,{open:n,onOpenChange:r,children:L}),t[34]=r,t[35]=n,t[36]=L,t[37]=R):R=t[37],R}function nn(e){let t=e.connectedAt?Date.parse(e.connectedAt):0;return Number.isFinite(t)?t:0}function rn(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?nn(t)-nn(e):e.isDefault?-1:1:e.isCurrentAuthorization?-1:1}function an(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(rn);return{key:e,primary:n[0],authorizations:n}}).sort((e,t)=>rn(e.primary,t.primary))}var on=k(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,P);function sn(e){return e.materialized.type===`composio`?e.materialized.toolkit:null}function cn(e,t){return e===`write`?t.composioScopeWrite:e===`admin`?t.composioScopeAdmin:t.composioScopeRead}function ln(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 un(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 dn(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 fn({instance:e,t,onChanged:n}){let r=sn(e),[i,a]=(0,Z.useState)([]),[o,s]=(0,Z.useState)([]),[c,l]=(0,Z.useState)([]),[u,d]=(0,Z.useState)([]),[f,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)([]),[b,x]=(0,Z.useState)(null),[C,w]=(0,Z.useState)(null),[T,E]=(0,Z.useState)([]),[D,O]=(0,Z.useState)({}),[j,M]=(0,Z.useState)(`read`),[N,P]=(0,Z.useState)(!1),[F,I]=(0,Z.useState)(null),R=(0,Z.useMemo)(()=>an(i),[i]),z=(0,Z.useCallback)(async()=>{if(!(!r||e.materialized.type!==`composio`||e.materialized.role===`credential`)){P(!0),I(null);try{let[t,n,i,o,c,u,f,p,m]=await Promise.all([J().catch(()=>[]),G(r).catch(()=>[]),Je(20).catch(()=>[]),Ze(r).catch(()=>`read`),be().catch(()=>[]),qe(r).catch(()=>null),Te(r).catch(()=>null),ne().catch(()=>[]),De(r).catch(()=>null)]);a(t.filter(e=>e.toolkit.toLowerCase()===r.toLowerCase())),s(n),l(i.filter(e=>!e.toolkit||e.toolkit.toLowerCase()===r.toLowerCase())),M(o),d(c.filter(t=>t.connectorId===e.connectorId)),g(u?.policy??null),v(u?.agents??[]),x(f),E(p),w(m);let h=an(t.filter(e=>e.toolkit.toLowerCase()===r.toLowerCase())).map(e=>e.primary).filter(e=>!!e.accountId),_=await Promise.all(h.map(async e=>[e.accountId,await Xe(e.accountId)]).map(e=>e.catch(()=>null)));O(Object.fromEntries(_.filter(e=>e!==null)))}catch(e){I(e instanceof Error?e.message:String(e))}finally{P(!1)}}},[e.connectorId,e.materialized,r]);(0,Z.useEffect)(()=>{z()},[z]);let B=(0,Z.useCallback)(async()=>{if(r){P(!0),I(null);try{let t=await ve(e.connectorId);if(!t.authorizationUrl)throw Error(`The authorization provider did not return an authorization URL.`);if(L()){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 xe(r,t.connectionId);if(!i.accountId)throw Error(`Connector account is unavailable.`);await ge(i.accountId),await n?.(),await z()}catch(e){I(e instanceof Error?e.message:String(e))}finally{P(!1)}}},[e.connectorId,z,n,r]),V=(0,Z.useCallback)(async t=>{P(!0),I(null);try{await Qe(e.instanceId,{config:{...e.config??{},...t?{authConfigId:t}:{authConfigId:void 0}}}),await n?.(),await z()}catch(e){I(e instanceof Error?e.message:String(e))}finally{P(!1)}},[e.config,e.instanceId,z,n]),H=(0,Z.useCallback)(async e=>{if(r){M(e);try{await pe(r,e),await z()}catch(e){I(e instanceof Error?e.message:String(e))}}},[z,r]),ee=(0,Z.useCallback)(async(e,t)=>{P(!0),I(null);try{await U(e,t),await z()}catch(e){I(e instanceof Error?e.message:String(e))}finally{P(!1)}},[z]),te=(0,Z.useCallback)(async e=>{if(r){I(null);try{g(await K(r,e))}catch(e){I(e instanceof Error?e.message:String(e))}}},[e.connectorId,r]),ie=(0,Z.useCallback)(e=>{f&&te({allowedAgentIds:f.allowedAgentIds.includes(e)?f.allowedAgentIds.filter(t=>t!==e):[...f.allowedAgentIds,e]})},[te,f]),oe=(0,Z.useCallback)(async e=>{P(!0),I(null);try{await e(),await z()}catch(e){I(e instanceof Error?e.message:String(e))}finally{P(!1)}},[z]);return r?e.materialized.type===`composio`&&e.materialized.role===`credential`?(0,$.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:t.composioApiKeyStored}):(0,$.jsxs)(`div`,{className:`mt-4 rounded-xl border border-edge bg-surface-base p-3 text-sm`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`font-medium text-fg`,children:X(t.composioToolkitTitle,{toolkit:r})}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:t.composioScopeHint})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsxs)(A,{variant:`secondary`,disabled:N,onClick:()=>void B(),children:[N?(0,$.jsx)(y,{className:`size-4 animate-spin`}):(0,$.jsx)(Y,{className:`size-4`}),t.connectOAuth]}),(0,$.jsx)(A,{variant:`ghost`,disabled:N,onClick:()=>void z(),children:t.refresh})]})]}),F?(0,$.jsx)(`p`,{className:`mt-3 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:F}):null,C?(0,$.jsxs)(`div`,{className:`mt-3 rounded-lg border border-edge bg-surface-panel p-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-xs font-medium text-fg`,children:t.composioAuthConfigTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:C.requiresCustomAuthConfig?t.composioAuthConfigRequiredHint:t.composioAuthConfigOptionalHint})]}),(0,$.jsx)(`a`,{className:`text-xs font-medium text-accent-fg hover:underline`,href:`https://app.composio.dev`,target:`_blank`,rel:`noreferrer`,children:t.composioAuthConfigManage})]}),(0,$.jsxs)(m,{className:k(on,`mt-2 h-9 py-1`),value:typeof e.config?.authConfigId==`string`?e.config.authConfigId:``,disabled:N,onChange:e=>void V(e.currentTarget.value),children:[C.requiresCustomAuthConfig?null:(0,$.jsx)(h,{value:``,children:t.composioAuthConfigManaged}),C.requiresCustomAuthConfig&&typeof e.config?.authConfigId!=`string`?(0,$.jsx)(h,{value:``,disabled:!0,children:t.composioAuthConfigSelect}):null,C.authConfigs.filter(e=>e.status===`ENABLED`&&e.isEnabledForToolRouter).map(e=>(0,$.jsxs)(h,{value:e.id,children:[e.name,` · `,e.authScheme??`OAuth`,` · `,e.id]},e.id))]}),C.requiresCustomAuthConfig&&C.authConfigs.every(e=>e.status!==`ENABLED`||!e.isEnabledForToolRouter)?(0,$.jsx)(`p`,{className:`mt-2 text-xs text-amber-700 dark:text-amber-300`,children:t.composioAuthConfigEmpty}):null]}):null,b?(0,$.jsxs)(`div`,{className:k(`mt-3 flex flex-wrap items-center justify-between gap-2 rounded-lg border px-3 py-2 text-xs`,b.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,$.jsx)(`span`,{children:b.status===`connected`?X(t.composioHealthConnected,{count:String(R.filter(e=>e.primary.status===`active`).length)}):b.status===`reauthorization_required`?t.composioHealthReconnect:b.status===`degraded`?ln(b,t):t.composioHealthDisconnected}),b.recovery===`none`?null:(0,$.jsx)(A,{variant:`ghost`,disabled:N,onClick:()=>void(b.recovery===`retry`?z():B()),children:b.recovery===`retry`?t.composioRetry:t.connectOAuth}),b.status===`degraded`&&b.message?(0,$.jsx)(`p`,{className:`basis-full break-words text-[11px] opacity-80`,children:b.message}):null]}):null,f?(0,$.jsxs)(`div`,{className:`mt-4 grid gap-3 rounded-lg border border-edge bg-surface-panel p-3 md:grid-cols-3`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-subtle`,children:[t.composioAccessTitle,(0,$.jsxs)(m,{className:k(on,`mt-1 h-9 py-1`),value:j,onChange:e=>void H(e.currentTarget.value),children:[(0,$.jsx)(h,{value:`read`,children:t.composioAccessReadOnly}),(0,$.jsx)(h,{value:`write`,children:t.composioAccessReadWrite}),j===`admin`?(0,$.jsx)(h,{value:`admin`,children:t.composioAccessAdminCurrent}):null]}),(0,$.jsx)(`span`,{className:`mt-1 block font-normal leading-4 text-fg-muted`,children:j===`read`?t.composioAccessReadHint:j===`admin`?t.composioAccessAdminHint:t.composioAccessWriteHint})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-subtle`,children:[t.composioConfirmationPolicy,(0,$.jsxs)(m,{className:k(on,`mt-1 h-9 py-1`),value:f.confirmationPolicy,onChange:e=>void te({confirmationPolicy:e.currentTarget.value}),children:[(0,$.jsx)(h,{value:`writes`,children:t.composioConfirmWrites}),(0,$.jsx)(h,{value:`always`,children:t.composioConfirmAlways}),f.confirmationPolicy===`never`?(0,$.jsx)(h,{value:`never`,children:t.composioConfirmNever}):null]})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-xs font-medium text-fg-subtle`,children:t.composioAllowedAgents}),(0,$.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:f.allowedAgentIds.length?t.composioAllowedAgentsSelected:t.composioAllowedAgentsAll}),(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:_.map(e=>(0,$.jsx)(`button`,{type:`button`,className:k(`rounded-full border px-2.5 py-1 text-xs transition-colors`,f.allowedAgentIds.includes(e.id)?`border-accent bg-accent/10 text-accent`:`border-edge text-fg-muted hover:text-fg`),onClick:()=>ie(e.id),children:e.name},e.id))})]})]}):null,u.length?(0,$.jsxs)(`div`,{className:`mt-4 space-y-2`,children:[(0,$.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioPendingApprovals}),u.map(e=>(0,$.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,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`truncate font-mono text-xs font-medium text-fg`,children:e.actionId}),(0,$.jsx)(`p`,{className:`mt-1 break-all font-mono text-xs text-fg-subtle`,children:JSON.stringify(e.argumentsPreview)}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:X(t.composioApprovalExpires,{time:new Date(e.expiresAt).toLocaleTimeString()})})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,$.jsxs)(A,{variant:`secondary`,disabled:N,onClick:()=>void ee(e.id,`denied`),children:[(0,$.jsx)(S,{className:`size-4`}),t.composioDeny]}),(0,$.jsxs)(A,{disabled:N,onClick:()=>void ee(e.id,`approved`),children:[(0,$.jsx)(p,{className:`size-4`}),t.approve]})]})]},e.id))]}):null,(0,$.jsx)(`div`,{className:`mt-4`,children:(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioConnections}),R.length?[{title:t.composioConnectedAccounts,items:R.filter(e=>e.primary.status===`active`)},{title:t.composioNeedsAttention,items:R.filter(e=>e.primary.status!==`active`)}].filter(e=>e.items.length>0).map(e=>(0,$.jsxs)(`section`,{className:`mb-3 space-y-2`,children:[(0,$.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=T.find(e=>i.accountId?e.accountId===i.accountId:e.connectionId===i.id),o=i.accountId?D[i.accountId]:void 0;return(0,$.jsxs)(`div`,{className:`space-y-3 rounded-xl border border-edge bg-surface-panel p-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:i.alias??i.workspace??i.accountEmail??i.username??t.composioUnnamedAuthorization}),i.connectedAt?(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:X(t.composioAuthorizedAt,{time:new Date(i.connectedAt).toLocaleString()})}):null,(0,$.jsxs)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:[X(t.composioAuthorizationCount,{count:String(e.authorizations.length)}),e.authorizations.length>1?` · ${X(t.composioDuplicateAuthorizations,{count:String(e.authorizations.length-1)})}`:``]})]}),(0,$.jsxs)(`span`,{className:k(`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:[un(i.status,t),i.isDefault?` · ${t.composioDefaultAccount}`:``]})]}),a||i.status===`active`?(0,$.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,$.jsx)(`p`,{className:`text-xs font-medium text-fg`,children:t.connectorLearningTitle}),(0,$.jsx)(`p`,{className:k(`mt-1 text-xs`,a?.status===`failed`?`text-red-600`:`text-fg-subtle`),children:a?X(t.connectorLearningStatus,{status:dn(a,o,t),count:String(a.candidatesCreated)}):t.connectorLearningEmpty}),o?(0,$.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-fg-subtle`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:o.scanEnabled,disabled:N,onChange:e=>void oe(()=>W(i.accountId,{scanEnabled:e.currentTarget.checked}))}),t.connectorScheduledScan]}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-fg-subtle`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:o.proactiveEnabled,disabled:N||!o.scanEnabled,onChange:e=>void oe(()=>W(i.accountId,{proactiveEnabled:e.currentTarget.checked}))}),t.connectorProactiveUse]}),o.scanEnabled?(0,$.jsxs)(`label`,{className:`text-xs text-fg-subtle sm:col-span-2`,children:[t.connectorScanInterval,(0,$.jsxs)(m,{className:k(on,`mt-1 h-8 py-1 text-xs`),value:String(o.intervalMinutes??30),disabled:N,onChange:e=>void oe(()=>W(i.accountId,{intervalMinutes:Number(e.currentTarget.value)})),children:[(0,$.jsxs)(h,{value:`5`,children:[`5 `,t.connectorMinutes]}),(0,$.jsxs)(h,{value:`15`,children:[`15 `,t.connectorMinutes]}),(0,$.jsxs)(h,{value:`30`,children:[`30 `,t.connectorMinutes]}),(0,$.jsxs)(h,{value:`60`,children:[`60 `,t.connectorMinutes]})]})]}):null]}):null]}):null,(0,$.jsxs)(`details`,{className:`text-xs text-fg-subtle`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer`,children:t.composioAdvancedSettings}),(0,$.jsxs)(`div`,{className:`mt-2 space-y-2 rounded-lg bg-surface-base p-2`,children:[e.authorizations.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`p`,{className:`min-w-0 break-all font-mono`,children:[t.composioAuthorizationId,`: `,e.providerConnectionId]}),(0,$.jsx)(A,{variant:`ghost`,className:`size-7 shrink-0 p-0`,title:t.composioRevoke,disabled:N,onClick:()=>{window.confirm(t.composioRevokeConfirm)&&oe(()=>Ne(e.id))},children:(0,$.jsx)(re,{className:`size-3.5 text-red-500`})})]},e.id)),(0,$.jsx)(`input`,{className:k(on,`h-8 py-1 text-xs`),defaultValue:i.alias??``,placeholder:t.composioAccountAlias,onBlur:e=>{e.currentTarget.value!==(i.alias??``)&&oe(()=>fe(i.id,{alias:e.currentTarget.value}))}})]})]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-1`,children:[(0,$.jsx)(A,{variant:`ghost`,className:`size-8 p-0`,title:t.composioMakeDefault,disabled:N||i.isDefault||i.status!==`active`,onClick:()=>void oe(async()=>{await fe(i.id,{isDefault:!0}),r&&await K(r,{selectedConnectionIds:[i.id]})}),children:(0,$.jsx)(ae,{className:k(`size-4`,i.isDefault&&`fill-current`)})}),(0,$.jsx)(A,{variant:`ghost`,className:`size-8 p-0`,title:t.refresh,disabled:N,onClick:()=>void oe(()=>_e(i.id)),children:(0,$.jsx)(Oe,{className:`size-4`})}),i.status===`active`?(0,$.jsxs)(A,{variant:`secondary`,disabled:N,onClick:()=>void oe(async()=>{if(!i.accountId)throw Error(`Connector account is unavailable.`);await ge(i.accountId),await n?.()}),children:[N?(0,$.jsx)(y,{className:`size-4 animate-spin`}):(0,$.jsx)(Oe,{className:`size-4`}),t.composioSyncNow]}):null]})]},e.key)})]},e.title)):(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioConnectionsEmpty})]})}),(0,$.jsxs)(`details`,{className:`mt-4 rounded-lg border border-edge bg-surface-panel p-3`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-xs font-medium text-fg-muted`,children:t.composioAdvancedSettings}),(0,$.jsxs)(`div`,{className:`mt-4 grid gap-4 lg:grid-cols-2`,children:[(0,$.jsx)(`div`,{className:`space-y-3`,children:(0,$.jsxs)(`label`,{className:`block text-xs text-fg-subtle`,children:[t.composioAdvancedScope,(0,$.jsxs)(m,{className:k(on,`mt-1 h-9 py-1`),value:j,onChange:e=>void H(e.currentTarget.value),children:[(0,$.jsx)(h,{value:`read`,children:t.composioScopeRead}),(0,$.jsx)(h,{value:`write`,children:t.composioScopeWrite}),(0,$.jsx)(h,{value:`admin`,children:t.composioScopeAdmin})]})]})}),(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioAgentTools}),o.length?o.slice(0,8).map(e=>(0,$.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-2`,children:[(0,$.jsx)(`p`,{className:`truncate font-mono text-xs text-fg`,children:e.slug}),(0,$.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[cn(e.scope,t),e.curated?``:` ${t.composioUncuratedSuffix}`]})]},e.slug)):(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioToolsEmpty})]}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioRecentTriggers}),c.length?c.slice(0,5).map(e=>(0,$.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-2`,children:[(0,$.jsx)(`p`,{className:`truncate text-xs text-fg`,children:e.trigger??e.id}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:new Date(e.at).toLocaleString()})]},`${e.id}-${e.at}`)):(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioTriggersEmpty})]})]})]})]})]}):null}var pn=k(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,P);function mn(e,t){return e?t.healthStatusLabels[e]??e:t.healthNotTested}function hn(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 gn(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 _n(e){let t=(0,Q.c)(12),{title:n,description:r,meta:i}=e,a;t[0]===r?a=t[1]:(a=r?(0,$.jsx)(V,{delayDuration:300,skipDelayDuration:100,children:(0,$.jsxs)(z,{children:[(0,$.jsx)(R,{asChild:!0,children:(0,$.jsx)(`p`,{tabIndex:0,title:r,className:k(`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,$.jsx)(B,{children:(0,$.jsx)(H,{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,$.jsx)(`span`,{className:`whitespace-pre-wrap break-words`,children:r})})})]})}):null,t[0]=r,t[1]=a);let o=a,s;t[2]===n?s=t[3]:(s=(0,$.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]=s);let c;t[4]===i?c=t[5]:(c=i?(0,$.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]=c);let l;t[6]!==s||t[7]!==c?(l=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-3`,children:[s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;return t[9]!==o||t[10]!==l?(u=(0,$.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2.5`,children:[l,o]}),t[9]=o,t[10]=l,t[11]=u):u=t[11],u}function vn({instance:e,definition:t,onClose:n,onChanged:r,t:i,mcp:a}){let[p,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(!1),[b,x]=(0,Z.useState)(!1),[C,w]=(0,Z.useState)(null),[T,E]=(0,Z.useState)(null),[D,O]=(0,Z.useState)(e.materialized.type===`mcp`?`health`:`permissions`),[M,N]=(0,Z.useState)(!1),[P,F]=(0,Z.useState)(()=>hn(t,e)),[I,L]=(0,Z.useState)(null),R=t?.setup.config??[],z=(e.materialized.type===`mcp`||e.materialized.type===`memorySource`)&&R.length>0&&(t?.setup.secrets??[]).length===0,B=T?T.toolCount:e.usage.lastToolCount,V=(0,Z.useMemo)(()=>{let t=e.materialized.type===`mcp`?[[`health`,se,i.detailHealth],[`tools`,We,`${i.detailTools} ${T?T.toolCount:e.usage.lastToolCount??``}`],[`resources`,Re,`${i.detailResources} ${T?T.resourceCount:e.usage.lastResourceCount??``}`],[`prompts`,Ie,`${i.detailPrompts} ${T?T.promptCount:e.usage.lastPromptCount??``}`],[`permissions`,Y,i.detailPermissions]]:[[`permissions`,Y,i.detailPermissions]];return z?[...t,[`config`,Re,i.connectorConfigLabel]]:t},[T,e.materialized.type,e.usage.lastPromptCount,e.usage.lastResourceCount,e.usage.lastToolCount,z,i]),H=(0,Z.useCallback)(async()=>{m(!0),L(null);try{let t=await ce(e.instanceId);E(t),t.toolCount>0&&O(`tools`),r()}catch(e){L(e instanceof Error?e.message:String(e))}finally{m(!1)}},[e.instanceId,r]),U=(0,Z.useCallback)(async()=>{g(!0),L(null);try{await Pe(e.instanceId),await r(),n()}catch(e){L(e instanceof Error?e.message:String(e)),g(!1)}},[e.instanceId,r,n]),W=(0,Z.useCallback)(async()=>{if(!(!t||!z)){v(!0),L(null);try{let n={};for(let e of t.setup.config??[]){let t=gn(e.type,P[e.key]??``);t!==void 0&&(n[e.key]=t)}await Qe(e.instanceId,{config:n}),await r(),O(`health`)}catch(e){L(e instanceof Error?e.message:String(e))}finally{v(!1)}}},[P,t,e.instanceId,r,z]),G=(0,Z.useCallback)(async()=>{x(!0),w(null),L(null);try{w((await ie(e.connectorId)).recordIds.length),await r()}catch(e){L(e instanceof Error?e.message:String(e))}finally{x(!1)}},[e.connectorId,r]);return(0,$.jsxs)(f,{open:!0,onOpenChange:e=>{e||n()},children:[(0,$.jsxs)(l,{children:[(0,$.jsx)(o,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(u,{className:k(`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,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,$.jsx)(le,{connector:t,size:`lg`}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(d,{className:`text-base font-semibold text-fg`,children:e.displayName}),(0,$.jsx)(s,{className:`mt-1 text-sm text-fg-muted`,children:t?.description??(e.materialized.type===`mcp`?X(i.mcpServerRuntime,{serverId:e.materialized.serverId}):X(i.runtimeLabel,{runtime:e.materialized.type}))})]})]}),(0,$.jsx)(c,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,className:k(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,j.focusRingPanel),"aria-label":i.modalClose,children:[(0,$.jsx)(S,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`sr-only`,children:i.modalClose})]})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:[I?(0,$.jsx)(`p`,{className:`mb-4 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:I}):null,(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:V.map(([e,t,n])=>(0,$.jsxs)(`button`,{type:`button`,className:k(`inline-flex h-8 items-center gap-1.5 rounded-md border px-2.5 text-xs`,D===e?`border-accent bg-accent-soft text-accent-fg`:`border-edge bg-surface-base text-fg-muted hover:text-fg`),onClick:()=>O(e),children:[(0,$.jsx)(t,{className:`size-3.5`,"aria-hidden":!0}),n]},e))}),(0,$.jsxs)(`div`,{className:`mt-4 rounded-xl border border-edge bg-surface-base p-3 text-sm`,children:[D===`health`?(0,$.jsxs)(`div`,{className:`space-y-1 text-fg-muted`,children:[(0,$.jsxs)(`p`,{children:[i.statusLabel,` `,(0,$.jsx)(`span`,{className:T?.ok?`font-medium text-emerald-700 dark:text-emerald-300`:`font-medium text-fg`,children:mn(T?.status??e.usage.lastHealthStatus,i)})]}),(0,$.jsxs)(`p`,{children:[i.lastCheckLabel,` `,e.usage.lastHealthCheckAt?new Date(e.usage.lastHealthCheckAt).toLocaleString():i.never]}),T?.action?(0,$.jsx)(`p`,{children:T.action}):null]}):null,D===`tools`?T?.tools.length?(0,$.jsxs)(`div`,{className:`grid gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:X(i.toolsAvailable,{count:String(T.tools.length)})}),(0,$.jsx)(A,{type:`button`,variant:`ghost`,className:`h-7 text-xs`,onClick:()=>N(!0),children:a.viewAllTools})]}),(0,$.jsx)(`div`,{className:`grid gap-2`,children:T.tools.slice(0,8).map(e=>(0,$.jsx)(_n,{title:e.shortName??e.name,description:e.description},e.name))})]}):(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsx)(`p`,{className:`text-fg-muted`,children:B?X(i.toolsLastCheckSummary,{count:String(B)}):i.toolsRunTestHint}),(0,$.jsxs)(A,{type:`button`,variant:`secondary`,disabled:p,onClick:()=>void H(),children:[p?(0,$.jsx)(y,{className:`size-4 animate-spin`}):(0,$.jsx)(Fe,{className:`size-4`}),i.test]})]}):null,D===`resources`?T?.resources.length?(0,$.jsx)(`div`,{className:`grid gap-2`,children:T.resources.slice(0,8).map(e=>(0,$.jsx)(_n,{title:e.title??e.name,description:e.uri,meta:e.mimeType},e.uri))}):(0,$.jsx)(`p`,{className:`text-fg-muted`,children:i.resourcesRunTestHint}):null,D===`prompts`?T?.prompts.length?(0,$.jsx)(`div`,{className:`grid gap-2`,children:T.prompts.slice(0,8).map(e=>(0,$.jsx)(_n,{title:e.title??e.name,description:e.description,meta:e.argumentCount?X(i.promptArgumentCount,{count:String(e.argumentCount)}):void 0},e.name))}):(0,$.jsx)(`p`,{className:`text-fg-muted`,children:i.promptsRunTestHint}):null,D===`permissions`?(0,$.jsxs)(`div`,{className:`space-y-1 text-fg-muted`,children:[(0,$.jsx)(`p`,{children:X(i.secretsConfigured,{count:String(Object.values(e.secretStatus).filter(Boolean).length)})}),(0,$.jsx)(`p`,{children:e.materialized.type===`mcp`?X(i.runtimeServerLabel,{runtime:e.materialized.type.toUpperCase(),serverId:e.materialized.serverId}):X(i.runtimeLabel,{runtime:e.materialized.type.toUpperCase()})}),(0,$.jsx)(`p`,{children:e.materialized.type===`mcp`?i.mcpPolicyHint:i.connectorPolicyHint})]}):null,D===`config`&&z?(0,$.jsx)(`div`,{className:`grid gap-3`,children:R.map(e=>(0,$.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.label}),e.description?(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:e.description}):null,(0,$.jsx)(`input`,{className:pn,value:P[e.key]??``,placeholder:e.placeholder,onChange:t=>F(n=>({...n,[e.key]:t.currentTarget.value}))})]},e.key))}):null]}),e.materialized.type===`composio`?(0,$.jsx)(fn,{instance:e,t:i,onChanged:r}):null,e.materialized.type===`memorySource`?(0,$.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,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`font-medium text-fg`,children:i.connectedSourceSync}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t?.description}),C===null?null:(0,$.jsx)(`p`,{className:`mt-1 text-xs text-emerald-600`,children:X(i.connectedSourceSynced,{count:String(C)})})]}),(0,$.jsxs)(A,{disabled:b,onClick:()=>void G(),children:[b?(0,$.jsx)(y,{className:`size-4 animate-spin`}):(0,$.jsx)(Re,{className:`size-4`}),i.composioSyncNow]})]}):null]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[(0,$.jsx)(A,{variant:`secondary`,onClick:n,children:i.modalClose}),D===`config`&&z?(0,$.jsxs)(A,{variant:`primary`,disabled:_,onClick:()=>void W(),children:[_?(0,$.jsx)(y,{className:`size-4 animate-spin`}):(0,$.jsx)(ye,{className:`size-4`}),i.modalSave]}):null,e.materialized.type===`mcp`?(0,$.jsxs)(A,{variant:`secondary`,disabled:p,onClick:()=>void H(),children:[p?(0,$.jsx)(y,{className:`size-4 animate-spin`}):(0,$.jsx)(Fe,{className:`size-4`}),i.test]}):null,(0,$.jsxs)(A,{variant:`ghost`,disabled:h,onClick:()=>void U(),children:[h?(0,$.jsx)(y,{className:`size-4 animate-spin`}):(0,$.jsx)(re,{className:`size-4`}),i.remove]})]})]})]}),e.materialized.type===`mcp`?(0,$.jsx)(tn,{open:M,onOpenChange:N,serverId:e.materialized.serverId,title:X(i.installedToolsDialogTitle,{name:e.displayName}),subtitle:i.installedToolsDialogSubtitle,searchPlaceholder:a.toolsDialogSearchPlaceholder,searchEmptyLabel:a.toolsDialogSearchEmpty,emptyLabel:i.toolsRunTestHint,closeLabel:a.toolsDialogClose,tools:T?.tools??[],stripPrefix:`${e.materialized.serverId}__`}):null]})}var yn=[`understand`,`act`,`reach`];function bn(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 xn(e){return bn(e)[0]??`act`}function Sn(e,t){let n=t?xn(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 Cn({instance:e,definition:t,highlighted:n=!1,onOpenDetails:r,onChanged:i,t:a}){let[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(null),f=(0,Z.useCallback)(async()=>{s(!0),d(null);try{await ce(e.instanceId),await i()}catch(e){d(e instanceof Error?e.message:String(e))}finally{s(!1)}},[e.instanceId,i]),p=(0,Z.useCallback)(async()=>{l(!0),d(null);try{await Pe(e.instanceId),await i()}catch(e){d(e instanceof Error?e.message:String(e)),l(!1)}},[e.instanceId,i]),m=e.usage.lastHealthStatus?a.healthStatusLabels[e.usage.lastHealthStatus]??e.usage.lastHealthStatus:a.healthNotTested,h=e.usage.lastToolCount??0,g=!!(t?.setup.config?.length&&!t.setup.secrets?.length&&e.materialized.type===`mcp`),v=Sn(e,t).state,b=v===`ready`?{label:a.connectionReady,Icon:_,className:`border-emerald-500/30 bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`}:v===`needs_setup`?{label:a.connectionNeedsSetup,Icon:he,className:`border-amber-500/30 bg-amber-500/10 text-amber-700 dark:text-amber-300`}:{label:a.connectionChecking,Icon:Ye,className:`border-edge bg-surface-base text-fg-muted`};return(0,$.jsxs)(`div`,{className:k(`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,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-3`,children:[(0,$.jsx)(le,{connector:t}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:e.displayName}),(0,$.jsxs)(`span`,{className:k(`inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-[11px] font-medium`,b.className),children:[(0,$.jsx)(b.Icon,{className:`size-3`,"aria-hidden":!0}),b.label]}),g?(0,$.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,$.jsx)(`p`,{className:`mt-3 line-clamp-2 text-sm leading-5 text-fg-muted`,children:t.description}):null,(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2 text-xs text-fg-muted`,children:[(0,$.jsxs)(`span`,{className:`rounded-md bg-surface-base px-2 py-1`,children:[a.statusLabel,` `,m]}),(0,$.jsx)(`span`,{className:`rounded-md bg-surface-base px-2 py-1`,children:X(a.toolsAvailable,{count:String(h)})})]}),u?(0,$.jsx)(`p`,{className:`mt-3 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:u}):null]})]}),(0,$.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-2 border-t border-edge pt-3`,onClick:e=>e.stopPropagation(),children:[(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:a.connectorDetails}),(0,$.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[v===`needs_setup`?(0,$.jsxs)(A,{variant:`primary`,onClick:()=>r(e),children:[(0,$.jsx)(he,{className:`size-4`}),a.connectionResolveAction]}):null,e.materialized.type===`mcp`?(0,$.jsxs)(A,{variant:`secondary`,disabled:o,onClick:()=>void f(),children:[o?(0,$.jsx)(y,{className:`size-4 animate-spin`}):(0,$.jsx)(Fe,{className:`size-4`}),a.test]}):null,(0,$.jsxs)(A,{variant:`ghost`,disabled:c,onClick:()=>void p(),children:[c?(0,$.jsx)(y,{className:`size-4 animate-spin`}):(0,$.jsx)(re,{className:`size-4`}),a.remove]})]})]})]})}function wn(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 Nt(r)}function Tn(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 En(){return k(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,P)}function Dn({label:e,optionalLabel:t,addLabel:n,removeHeaderAria:r,pasteLabel:i,pasteFailed:a,keyPlaceholder:o,valuePlaceholder:s,headers:c,onChange:l}){let u=(e,t)=>{l(c.map((n,r)=>r===e?{...n,...t}:n))},d=()=>{l([...c,{key:``,value:``}])},f=e=>{let t=c.filter((t,n)=>n!==e);l(t.length>0?t:[{key:``,value:``}])},p=async()=>{try{let e=await C();if(!e){window.alert(a);return}let t=wt(e);if(!t?.length){window.alert(a);return}l(t)}catch{window.alert(a)}};return(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 md:col-span-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium text-fg`,children:[(0,$.jsx)(`span`,{children:e}),t?(0,$.jsx)(`span`,{className:`font-normal text-fg-subtle`,children:t}):null]}),(0,$.jsxs)(A,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5 px-2 text-xs`,onClick:()=>void p(),children:[(0,$.jsx)(q,{className:`size-3.5`,"aria-hidden":!0}),i]})]}),(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:c.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{className:k(En(),`min-w-0 flex-1 font-mono text-xs`),value:e.key,placeholder:o,onChange:e=>u(t,{key:e.target.value})}),(0,$.jsx)(`input`,{className:k(En(),`min-w-0 flex-[1.4] font-mono text-xs`),value:e.value,placeholder:s,onChange:e=>u(t,{value:e.target.value})}),(0,$.jsx)(A,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 px-0`,disabled:c.length<=1&&!e.key&&!e.value,onClick:()=>f(t),"aria-label":r,children:(0,$.jsx)(re,{className:`size-4 text-fg-subtle`,"aria-hidden":!0})})]},Tn(e,t,c)))}),(0,$.jsxs)(`button`,{type:`button`,className:k(`self-start text-sm text-accent hover:underline`,j.press),onClick:d,children:[`+ `,n]})]})}var On=[`stdio`,`sse`,`streamable-http`],kn=[`none`,`oauth`];function An(e){let t=(0,Q.c)(11),{label:n,description:r,required:i,children:a}=e,o;t[0]===i?o=t[1]:(o=i?(0,$.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,$.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,$.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,$.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 jn(){return k(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,P)}function Mn(e){let t=(0,Q.c)(37),{row:n,t:r,onUpdate:i,idConflictMessage:a,variant:o}=e,s=o===void 0?`all`:o,c=s===`all`||s===`basic`,l=s===`all`||s===`advanced`,u;t[0]!==a||t[1]!==i||t[2]!==n.id||t[3]!==n.transport||t[4]!==c||t[5]!==r?(u=c?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(An,{label:r.transportLabel,required:!0,children:(0,$.jsx)(m,{className:jn(),value:n.transport,onChange:e=>i({transport:e.target.value}),children:On.map(e=>(0,$.jsx)(h,{value:e,children:r.transportLabels[e]},e))})}),(0,$.jsxs)(An,{label:r.serverIdLabel,required:!0,children:[(0,$.jsx)(`input`,{className:jn(),value:n.id,placeholder:r.serverIdPlaceholder,onChange:e=>i({id:e.target.value})}),a?(0,$.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]=c,t[5]=r,t[6]=u):u=t[6];let d;t[7]!==i||t[8]!==n.argsText||t[9]!==n.auth||t[10]!==n.command||t[11]!==n.cwd||t[12]!==n.envJson||t[13]!==n.headers||t[14]!==n.oauthClientId||t[15]!==n.transport||t[16]!==n.url||t[17]!==l||t[18]!==c||t[19]!==r||t[20]!==s?(d=n.transport===`stdio`?(0,$.jsxs)($.Fragment,{children:[c?(0,$.jsx)(`div`,{className:s===`basic`?`md:col-span-2`:void 0,children:(0,$.jsx)(An,{label:r.commandLabel,required:!0,children:(0,$.jsx)(`input`,{className:jn(),value:n.command,onChange:e=>i({command:e.target.value})})})}):null,l?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(An,{label:r.argsLabel,description:r.argsHint,children:(0,$.jsx)(`input`,{className:jn(),value:n.argsText,onChange:e=>i({argsText:e.target.value})})}),(0,$.jsx)(An,{label:r.cwdLabel,children:(0,$.jsx)(`input`,{className:jn(),value:n.cwd,onChange:e=>i({cwd:e.target.value})})}),(0,$.jsx)(An,{label:r.envLabel,description:r.envHint,children:(0,$.jsx)(`textarea`,{className:k(jn(),`min-h-[4rem] font-mono text-xs`),value:n.envJson,onChange:e=>i({envJson:e.target.value})})})]}):null]}):(0,$.jsxs)($.Fragment,{children:[c?(0,$.jsx)(`div`,{className:`md:col-span-2`,children:(0,$.jsx)(An,{label:r.urlLabel,required:!0,children:(0,$.jsx)(`input`,{className:k(jn(),`font-mono text-xs`),value:n.url,placeholder:`https://example.com/mcp`,onChange:e=>i({url:e.target.value})})})}):null,c&&n.transport===`streamable-http`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(An,{label:r.authLabel,description:r.authHint,children:(0,$.jsx)(m,{className:jn(),value:n.auth,onChange:e=>{let t=e.target.value;i({auth:t,headers:t===`oauth`?n.headers.filter(Pn):n.headers})},children:kn.map(e=>(0,$.jsx)(h,{value:e,children:r.authLabels[e]},e))})}),n.auth===`oauth`?(0,$.jsx)(An,{label:r.oauthClientIdLabel,description:r.oauthClientIdHint,children:(0,$.jsx)(`input`,{className:k(jn(),`font-mono text-xs`),value:n.oauthClientId,placeholder:r.oauthClientIdPlaceholder,onChange:e=>i({oauthClientId:e.target.value})})}):null]}):null,l?(0,$.jsx)(Dn,{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:n.auth===`oauth`?e.filter(Nn):e})}):null]}),t[7]=i,t[8]=n.argsText,t[9]=n.auth,t[10]=n.command,t[11]=n.cwd,t[12]=n.envJson,t[13]=n.headers,t[14]=n.oauthClientId,t[15]=n.transport,t[16]=n.url,t[17]=l,t[18]=c,t[19]=r,t[20]=s,t[21]=d):d=t[21];let f;t[22]!==i||t[23]!==n||t[24]!==l||t[25]!==r?(f=l?(0,$.jsx)(An,{label:r.timeoutLabel,description:r.timeoutHint,children:(0,$.jsx)(`input`,{type:`number`,min:1,max:600,className:jn(),value:Gt(n),placeholder:r.timeoutPlaceholder,onChange:e=>i({connectionTimeoutMs:Kt(e.target.value)})})}):null,t[22]=i,t[23]=n,t[24]=l,t[25]=r,t[26]=f):f=t[26];let p;t[27]!==i||t[28]!==n||t[29]!==l||t[30]!==r?(p=l?(0,$.jsx)(An,{label:r.requestTimeoutLabel,description:r.requestTimeoutHint,children:(0,$.jsx)(`input`,{type:`number`,min:1,max:14400,className:jn(),value:qt(n),placeholder:r.requestTimeoutPlaceholder,onChange:e=>i({requestTimeoutMs:Jt(e.target.value)})})}):null,t[27]=i,t[28]=n,t[29]=l,t[30]=r,t[31]=p):p=t[31];let g;return t[32]!==u||t[33]!==d||t[34]!==f||t[35]!==p?(g=(0,$.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[u,d,f,p]}),t[32]=u,t[33]=d,t[34]=f,t[35]=p,t[36]=g):g=t[36],g}function Nn(e){return e.key.trim().toLowerCase()!==`authorization`}function Pn(e){return e.key.trim().toLowerCase()!==`authorization`}function Fn(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 In(e){let t=(0,Q.c)(13),{tool:n,serverId:r}=e,i;t[0]!==r||t[1]!==n?(i=Fn(n,r),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a=i,o=n.name===a?a:n.name,s;t[3]===n.description?s=t[4]:(s=n.description?.trim(),t[3]=n.description,t[4]=s);let c=s,l;t[5]!==a||t[6]!==o?(l=(0,$.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]=l):l=t[7];let u;t[8]===c?u=t[9]:(u=c?(0,$.jsx)(V,{delayDuration:300,skipDelayDuration:100,children:(0,$.jsxs)(z,{children:[(0,$.jsx)(R,{asChild:!0,children:(0,$.jsx)(`p`,{tabIndex:0,title:c,className:k(`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:c})}),(0,$.jsx)(B,{children:(0,$.jsx)(H,{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,$.jsx)(`span`,{className:`whitespace-pre-wrap break-words`,children:c})})})]})}):null,t[8]=c,t[9]=u);let d;return t[10]!==l||t[11]!==u?(d=(0,$.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-edge bg-surface-panel px-3 py-2.5`,children:[l,u]}),t[10]=l,t[11]=u,t[12]=d):d=t[12],d}function Ln({open:e,mode:t,initialRow:n,existingCustomServers:r,sessionIdleTtlMinutes:i,config:a,managedServerIds:p,t:m,cs:h,onClose:g,onSaved:v}){let[b,x]=(0,Z.useState)(n),[C,w]=(0,Z.useState)(!1),[T,E]=(0,Z.useState)(!1),[D,O]=(0,Z.useState)(null),[M,N]=(0,Z.useState)(!1),[P,F]=(0,Z.useState)({status:`idle`}),[I,L]=(0,Z.useState)(null),R=n.id.trim(),z=b.id.trim()!==R&&p.has(b.id.trim())||p.has(b.id.trim())&&t===`add`?m.reservedServerId:void 0,B=b.id.trim()&&r.some(e=>e.clientKey!==n.clientKey&&e.id.trim()===b.id.trim())?h.duplicateServerId:void 0,V=b.id.trim().length>0&&!z&&!B&&(b.transport===`stdio`?b.command.trim().length>0:b.url.trim().length>0),H=!(b.transport===`streamable-http`&&b.auth===`oauth`),U=Yt(b),W=(0,Z.useCallback)(async()=>{if(b.id.trim()){E(!0),O(null),F({status:`loading`});try{F({status:`ok`,tools:(await Wt(b.id.trim(),Ft(b))).tools})}catch(e){F({status:`error`,message:e instanceof Error?e.message:String(e)})}finally{E(!1)}}},[b]),G=(0,Z.useCallback)(async()=>{if(!(!V||C)){w(!0),O(null);try{let e=r.filter(e=>!(t===`edit`&&e.clientKey===n.clientKey));e.push(b),await It({sessionIdleTtlMinutes:i,servers:e.sort((e,t)=>e.id.localeCompare(t.id))},Ot(a)),await v(),g()}catch(e){O(e instanceof Error?e.message:String(e))}finally{w(!1)}}},[V,a,r,n.clientKey,t,g,v,R,b,C,i]);return e?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(f,{open:e,onOpenChange:e=>{e||g()},children:(0,$.jsxs)(l,{children:[(0,$.jsx)(o,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(u,{className:k(`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,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(d,{className:`text-base font-semibold text-fg`,children:t===`add`?h.addCustomServerTitle:h.editCustomServerTitle}),(0,$.jsx)(s,{className:`mt-1 text-sm text-fg-muted`,children:t===`add`?h.addCustomServerHint:h.editCustomServerHint})]}),(0,$.jsx)(c,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,className:k(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,j.focusRingPanel),"aria-label":h.modalClose,children:[(0,$.jsx)(S,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`sr-only`,children:h.modalClose})]})})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsx)(`section`,{className:`rounded-xl border border-edge bg-surface-base p-4`,children:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,$.jsx)(Se,{className:`size-4 text-accent`,"aria-hidden":!0}),b.id.trim()||m.cardUntitled]}),(0,$.jsx)(`p`,{className:`mt-1 break-all font-mono text-xs leading-5 text-fg-muted`,children:U||(b.transport===`stdio`?m.commandLabel:m.urlLabel)})]}),(0,$.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:m.transportLabels[b.transport]})]})}),(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`mb-3`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:h.connectorBasicConfigTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:h.connectorBasicConfigHint})]}),(0,$.jsx)(Mn,{row:b,t:m,variant:`basic`,onUpdate:e=>{x(t=>({...t,...e})),O(null)},idConflictMessage:z??B})]}),P.status===`ok`?(0,$.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-base p-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,$.jsx)(We,{className:`size-4 text-accent`,"aria-hidden":!0}),P.tools.length===0?m.toolsEmpty:m.toolsTitle.replace(`{{count}}`,String(P.tools.length))]}),P.tools.length>0?(0,$.jsx)(A,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,onClick:()=>L(P.tools),children:m.viewAllTools}):null]}),P.tools.length>0?(0,$.jsx)(`div`,{className:`mt-3 grid gap-2`,children:P.tools.slice(0,6).map((e,t)=>(0,$.jsx)(In,{tool:e,serverId:b.id},e.name||`tool-${t}`))}):null]}):null,P.status===`error`?(0,$.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:P.message}):null,D?(0,$.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:D}):null,(0,$.jsxs)(`details`,{open:M,onToggle:e=>N(e.currentTarget.open),className:`group rounded-xl border border-edge bg-surface-base`,children:[(0,$.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,$.jsx)(de,{className:`size-4 text-fg-muted transition-transform group-open:rotate-180`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`group-open:hidden`,children:h.connectorShowAdvancedConfig}),(0,$.jsx)(`span`,{className:`hidden group-open:inline`,children:h.connectorHideAdvancedConfig})]}),(0,$.jsx)(`div`,{className:`border-t border-edge p-4`,children:(0,$.jsx)(Mn,{row:b,t:m,variant:`advanced`,onUpdate:e=>{x(t=>({...t,...e})),O(null)}})})]})]})}),(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[(0,$.jsxs)(A,{variant:`secondary`,disabled:!b.id.trim()||T||!H,title:H?void 0:m.oauthSaveBeforeTest,onClick:()=>void W(),children:[T?(0,$.jsx)(y,{className:`size-4 animate-spin`}):(0,$.jsx)(Fe,{className:`size-4`}),m.testConnection]}),(0,$.jsx)(c,{asChild:!0,children:(0,$.jsx)(A,{variant:`secondary`,children:h.modalCancel})}),(0,$.jsxs)(A,{variant:`primary`,disabled:!V||C,onClick:()=>void G(),children:[C?(0,$.jsx)(y,{className:`size-4 animate-spin`}):(0,$.jsx)(_,{className:`size-4`}),C?m.saving:h.modalSave]})]})]})]})}),I?(0,$.jsx)(tn,{open:!0,onOpenChange:e=>{e||L(null)},serverId:b.id,title:m.toolsDialogTitle,subtitle:m.toolsDialogSubtitle,searchPlaceholder:m.toolsDialogSearchPlaceholder,searchEmptyLabel:m.toolsDialogSearchEmpty,emptyLabel:m.toolsEmpty,closeLabel:m.toolsDialogClose,tools:I,stripPrefix:`${b.id.trim()}__`}):null]}):null}var Rn=`builtin`,zn=`composio`,Bn=`xopc-store`;function Vn(e){return Rn}function Hn(e){return!(e.runtime.type===`composio`&&e.runtime.role===`credential`)}function Un(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 Wn(e,t,n){return e.filter(e=>Un(e,t)).toSorted((e,t)=>n===`source`&&e.source!==t.source?e.source.localeCompare(t.source):e.displayName.localeCompare(t.displayName))}function Gn(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 Kn(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 qn(e){let t=e.connectorManifest;if(!t||typeof t!=`object`||Array.isArray(t))return null;let n=t;if(n.contractVersion!==1||n.id!==e.name)return null;let r=n.runtime,i=n.auth;if(!r||typeof r!=`object`||Array.isArray(r)||!i||typeof i!=`object`||Array.isArray(i))return null;let a=r,o=i;if(a.type!==`mcp`||typeof a.serverId!=`string`)return null;let s=[`code`,`docs`,`browser`,`data`,`automation`,`custom`].includes(String(n.category??``))?n.category:`custom`,c=o.mode===`oauth`?{mode:`oauth`,...typeof o.clientId==`string`?{clientId:o.clientId}:{}}:o.mode===`apiKey`?{mode:`apiKey`}:{mode:`none`};return{id:e.name,version:e.latestVersion??`store`,displayName:typeof n.displayName==`string`?n.displayName:e.name,description:typeof n.description==`string`?n.description:e.description,category:s,kind:`mcp`,source:`store`,capabilities:Array.isArray(n.capabilities)?n.capabilities.filter(e=>typeof e==`string`):[],tags:Array.isArray(n.tags)?n.tags.filter(e=>typeof e==`string`):[`store`],auth:c,setup:n.setup&&typeof n.setup==`object`&&!Array.isArray(n.setup)?n.setup:{},runtime:{type:`mcp`,serverId:a.serverId}}}function Jn(e){return e.filter((e,t,n)=>n.findIndex(t=>t.id===e.id)===t)}function Yn(e){return e?.startsWith(`/`)&&!e.startsWith(`//`)?e:`/you?tab=sources`}function Xn(){let e=w(E(e=>e.language)),t=e.connectorsSettings,n=e.mcpSettings,r=O(e=>e.token),o=!!r,s=i(),[c,l]=a(),u=c.get(`understanding`)===`1`,d=Yn(c.get(`returnTo`)),f=c.get(`tab`),[p,m]=(0,Z.useState)(!u&&f===`connected`?`connected`:`discover`),h=(0,Z.useRef)(!1),[_,v]=(0,Z.useState)({catalog:[],registryCatalog:[],instances:[],loading:!0,error:null}),[b,x]=(0,Z.useState)(!1),[S,C]=(0,Z.useState)(!1),[T,D]=(0,Z.useState)(1),[j,M]=(0,Z.useState)(void 0),[P,F]=(0,Z.useState)(``),[I,L]=(0,Z.useState)(u?c.get(`connector`)??``:``),[R,z]=(0,Z.useState)(Vn(u?`understanding`:`default`)),[B,V]=(0,Z.useState)(`name`),[H,U]=(0,Z.useState)(u?`understand`:`all`),[W,G]=(0,Z.useState)(null),[ee,te]=(0,Z.useState)(null),[ne,re]=(0,Z.useState)(null),[ie,ae]=(0,Z.useState)(null),[se,ce]=(0,Z.useState)(null),[le,de]=(0,Z.useState)(null),[fe,pe]=(0,Z.useState)(!1),[me,he]=(0,Z.useState)(void 0),[ge,_e]=(0,Z.useState)(!1),{data:ve,mutate:ye}=N(o),K=ve?.payload?.config,q=(0,Z.useMemo)(()=>K===void 0?null:Pt(K),[K]),J=q?.servers??[],be=_.instances.length+J.length;(0,Z.useEffect)(()=>{q&&he(q.sessionIdleTtlMinutes)},[q]);let Y=(0,Z.useCallback)(async()=>{if(!r){v({catalog:[],registryCatalog:[],instances:[],loading:!1,error:null});return}v(e=>({...e,loading:!0,error:null}));try{let[e,t]=await Promise.all([Ue(),ze()]);v(n=>({catalog:e,registryCatalog:n.registryCatalog,instances:t,loading:!1,error:null}))}catch(e){v({catalog:[],registryCatalog:[],instances:[],loading:!1,error:e instanceof Error?e.message:String(e)})}},[r]);(0,Z.useEffect)(()=>{Y()},[Y]),(0,Z.useEffect)(()=>{h.current||_.loading||o&&!q||(m(u?`discover`:be>0?`connected`:`discover`),h.current=!0)},[o,be,q,u,_.loading]);let xe=(0,Z.useCallback)(e=>{h.current=!0,m(e)},[]),Se=(0,Z.useMemo)(()=>[{id:zn,displayName:t.composioSourceName},{id:Bn,displayName:t.storeSourceName}],[t.composioSourceName,t.storeSourceName]),Ce=(0,Z.useCallback)(async e=>{if(!o||R===`builtin`){v(e=>({...e,registryCatalog:[]})),D(1),M(void 0);return}let t=I.trim(),n=Math.max(e?.page??1,1),r=e?.append??!1,i=R===`all`?Se:Se.filter(e=>e.id===R);if(i.length!==0){x(!0),r?v(e=>({...e,error:null})):(D(1),M(void 0),v(e=>({...e,registryCatalog:[],error:null})));try{let e=await Promise.all(i.map(async e=>{if(e.id===`composio`){let e=await ke({q:t||void 0,page:n,pageSize:24,verification:`experimental`});return{connectors:e.connectors,totalPages:e.meta.totalPages}}let r=await je({q:t||void 0,page:n,pageSize:24,sort:B===`source`?`newest`:`downloads`});return{connectors:r.items.flatMap(e=>{let t=qn(e);return t?[t]:[]}),totalPages:r.meta.totalPages}})),a=Jn(e.flatMap(e=>e.connectors)),o=Math.max(1,...e.map(e=>e.totalPages??1));D(n),M(o),v(e=>({...e,registryCatalog:r?Jn([...e.registryCatalog,...a]):a}))}catch(e){v(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{x(!1)}}},[B,I,R,o,Se]);(0,Z.useEffect)(()=>{if(p!==`discover`||_.loading)return;if(R===`builtin`){v(e=>({...e,registryCatalog:[]})),D(1),M(void 0);return}let e=window.setTimeout(()=>{Ce()},I.trim()?350:0);return()=>window.clearTimeout(e)},[I,R,Ce,_.loading,p]);let we=(0,Z.useMemo)(()=>new Set(_.instances.map(e=>e.connectorId)),[_.instances]),Te=(0,Z.useMemo)(()=>new Map([..._.catalog,..._.registryCatalog].map(e=>[e.id,e])),[_.catalog,_.registryCatalog]);(0,Z.useEffect)(()=>{if(_.loading)return;let e=c.get(`connector`),t=c.get(`instance`);if(!e&&!t)return;let n=_.instances.find(n=>t?n.instanceId===t:n.connectorId===e);if(n)h.current=!0,F(``),re(n.instanceId),ae(n),m(`connected`);else if(e){let t=Te.get(e);if(!t)return;h.current=!0,z(Vn(u?`understanding`:`default`)),L(``),te(t),m(`discover`)}let r=new URLSearchParams(c);r.delete(`connector`),r.delete(`instance`),r.set(`tab`,n?`connected`:`discover`),l(r,{replace:!0})},[Te,u,c,l,_.instances,_.loading]);let Ee=(0,Z.useCallback)(async e=>{C(!0),v(e=>({...e,error:null}));try{let t=await Ae(e);G(oe(t.definition,{packageName:t.packageName,version:t.version,permissions:t.permissions}))}catch(e){v(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{C(!1)}},[]),De=(0,Z.useMemo)(()=>new Set(_.instances.flatMap(e=>e.materialized.type===`mcp`?[e.materialized.serverId]:[])),[_.instances]),Oe=(0,Z.useCallback)(async e=>{if(!q||K===void 0)return;let t=J.filter(t=>t.clientKey!==e.clientKey);await It({sessionIdleTtlMinutes:q.sessionIdleTtlMinutes,servers:t},Ot(K)),await ye(),await Y()},[K,J,Y,q,ye]),Me=(0,Z.useCallback)(()=>{de({mode:`add`,row:wn(J,De)})},[J,De]),Ne=(0,Z.useCallback)(async()=>{if(!(!q||K===void 0||ge)){_e(!0);try{await It({sessionIdleTtlMinutes:me,servers:J},Ot(K)),await ye(),pe(!1)}finally{_e(!1)}}},[K,J,n.saved,q,ye,me,ge]),Pe=Ve(e=>e.setPageHeader),Fe=Ve(e=>e.clearPageHeader),Ie=(0,Z.useMemo)(()=>(0,$.jsx)(St,{onBrowseCatalog:()=>xe(`discover`),onAddCustomServer:Me,onOpenRuntimeSettings:()=>pe(!0),addLabel:t.addConnection,browseLabel:t.addFromCatalog,customLabel:t.addCustomServerAdvanced,settingsLabel:t.runtimeSettings}),[t,Me,xe]);(0,Z.useLayoutEffect)(()=>(Pe({startExtra:null,main:(0,$.jsx)(`div`,{className:`min-w-0`,children:(0,$.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.title})}),end:Ie}),()=>Fe()),[Fe,t.title,Ie,Pe]);let Le=(0,Z.useMemo)(()=>_.instances.map(e=>({instance:e,value:Sn(e,Te.get(e.connectorId))})),[Te,_.instances]),Re=(0,Z.useMemo)(()=>new Map(Le.map(({instance:e,value:t})=>[e.instanceId,t])),[Le]),He=(0,Z.useMemo)(()=>_.instances.filter(e=>Gn(e,P)).sort((e,t)=>{let n={needs_setup:0,checking:1,ready:2},r=Re.get(e.instanceId)?.state??`checking`,i=Re.get(t.instanceId)?.state??`checking`;return n[r]-n[i]||e.displayName.localeCompare(t.displayName)}),[P,Re,_.instances]),We=(0,Z.useMemo)(()=>J.filter(e=>Kn(e,P)),[P,J]),X=He.length+We.length,Ge=(0,Z.useMemo)(()=>_.catalog.filter(e=>e.source===`builtin`&&e.integrationStrategy?.preferred!==!1&&Hn(e)),[_.catalog]),Ke=(0,Z.useMemo)(()=>R===`builtin`?Ge:R===`all`?Jn([...Ge,..._.registryCatalog]):_.registryCatalog,[Ge,R,_.registryCatalog]),qe=(0,Z.useMemo)(()=>{let e=u?Ke.filter(e=>e.understanding?.mode===`activity`):Ke;return Wn(H===`all`?e:e.filter(e=>bn(e).includes(H)),I,B)},[B,I,Ke,u,H]),Je=(0,Z.useMemo)(()=>yn.filter(e=>Ke.some(t=>bn(t).includes(e))),[Ke]);(0,Z.useEffect)(()=>{H!==`all`&&!Je.includes(H)&&U(`all`)},[Je,H]);let Ye=p===`discover`&&R!==`builtin`&&!!(j&&T<j),Xe=(0,Z.useMemo)(()=>_.instances.find(e=>e.instanceId===ne)??ie,[ne,ie,_.instances]),Ze=(0,Z.useMemo)(()=>[{value:`all`,label:t.discoverSourceAll},{value:Rn,label:t.discoverSourceBuiltin},...Se.map(e=>({value:e.id,label:e.displayName}))],[t.discoverSourceAll,t.discoverSourceBuiltin,Se]),Qe=[{id:`connected`,label:t.tabConnected,count:be},{id:`discover`,label:t.tabDiscover}];return(0,$.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:(0,$.jsxs)(`div`,{className:`flex w-full flex-col gap-6 px-3 py-6 sm:px-5 xl:px-6`,children:[o?null:(0,$.jsx)(`p`,{className:`rounded-xl border border-edge bg-surface-panel px-4 py-3 text-sm text-fg-muted`,children:t.tokenHint}),u?(0,$.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,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:t.understandingSetupTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:t.understandingSetupHint})]}),(0,$.jsx)(A,{type:`button`,variant:`secondary`,className:`shrink-0`,onClick:()=>s(d),children:t.understandingSetupDone})]}):null,(0,$.jsxs)(`section`,{className:`flex flex-col gap-4`,children:[(0,$.jsx)(`div`,{className:`border-b border-edge-subtle pb-3 dark:border-edge-subtle`,children:(0,$.jsx)(nt,{items:Qe,activeTab:p,onChange:xe,ariaLabel:t.navAria,tabIdPrefix:`connectors-tab`,panelIdPrefix:`connectors-panel`,className:`flex-wrap`})}),_.error?(0,$.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:_.error}):null,p===`connected`&&o?(0,$.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center`,children:[(0,$.jsx)(xt,{value:P,onChange:F,placeholder:t.connectedSearchPlaceholder,className:`max-w-xl`}),(0,$.jsx)(Be,{className:`size-9 shrink-0 p-0`,loading:_.loading,label:t.refreshConnections,title:t.refreshConnections,onClick:Y})]}),(0,$.jsxs)(`section`,{className:`flex flex-col gap-3 rounded-2xl border border-edge bg-surface-base px-4 py-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.relationshipsEntryTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:t.relationshipsEntryHint})]}),(0,$.jsx)(A,{type:`button`,className:`shrink-0`,onClick:()=>s(`/you?tab=relationships`),children:t.relationshipsEntryAction})]}),_.loading?(0,$.jsx)(`div`,{className:`grid gap-3`,"aria-busy":`true`,"aria-label":t.loading,children:at.slice(0,3).map(e=>(0,$.jsx)(ut,{},e))}):be===0?(0,$.jsxs)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.connectionsEmpty}),(0,$.jsx)(A,{type:`button`,variant:`primary`,className:`mt-4`,onClick:()=>xe(`discover`),children:t.addFromCatalog})]}):X===0?(0,$.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center text-sm text-fg-muted`,children:t.connectionsSearchEmpty}):(0,$.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:[He.map(e=>(0,$.jsx)(Cn,{instance:e,definition:Te.get(e.connectorId),highlighted:e.instanceId===se,onOpenDetails:e=>{ce(null),re(e.instanceId),ae(e)},onChanged:Y,t},e.instanceId)),We.map(e=>(0,$.jsx)(Xt,{row:e,t:n,cs:t,onEdit:()=>de({mode:`edit`,row:structuredClone(e)}),onRemove:async()=>Oe(e)},e.clientKey))]})]}):null,p===`discover`&&o?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[u?null:(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,role:`group`,"aria-label":t.taskFilterAria,children:[`all`,...Je].map(e=>(0,$.jsx)(`button`,{type:`button`,className:k(`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors`,H===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":H===e,onClick:()=>U(e),children:e===`all`?t.taskAll:t.connectorBenefitHeadings[e]},e))}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 lg:flex-row lg:items-center`,children:[(0,$.jsx)(xt,{value:I,onChange:L,placeholder:t.discoverSearchPlaceholder,className:`max-w-xl`}),(0,$.jsxs)(`div`,{className:k(`grid min-w-0 grid-cols-1 gap-2 lg:ml-auto`,u?`lg:w-52`:`sm:grid-cols-2 lg:w-[26rem]`),children:[u?null:(0,$.jsx)(g,{value:R,options:Ze,placeholder:t.discoverSourceAll,allowEmpty:!1,ariaLabel:t.registrySourceAria,triggerClassName:`h-9 bg-surface-panel text-xs`,onChange:z}),(0,$.jsx)(g,{value:B,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=>V(e)})]})]}),(_.loading||b)&&qe.length===0?(0,$.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,"aria-busy":`true`,"aria-label":t.loading,children:at.map(e=>(0,$.jsx)(ct,{},e))}):qe.length===0?(0,$.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center text-sm text-fg-muted`,children:t.discoverEmpty}):(0,$.jsxs)(`div`,{className:`relative`,children:[b?(0,$.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,$.jsx)(y,{className:`size-8 shrink-0 animate-spin text-accent motion-reduce:animate-none`,strokeWidth:2,"aria-hidden":!0})}):null,(0,$.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:qe.map(e=>(0,$.jsx)(rt,{connector:e,installed:we.has(e.id)||ot(e,_.instances),onInstall:e=>{if(e.source===`store`){Ee(e.id);return}G(oe(e))},onOpenDetails:e.source===`store`?void 0:te,t},e.id))}),Ye?(0,$.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,$.jsxs)(A,{type:`button`,variant:`secondary`,disabled:b||S,onClick:()=>void Ce({page:T+1,append:!0}),children:[b?(0,$.jsx)(y,{className:`size-4 animate-spin`}):null,t.loadMore]})}):null]})]}):null]}),W?(0,$.jsx)(ue,{draft:W,onChange:G,onClose:()=>G(null),t,onInstalled:async e=>{await Y(),await ye(),ce(e.instanceId),xe(`connected`)}}):null,ee?(0,$.jsx)(vt,{connector:ee,installed:we.has(ee.id)||ot(ee,_.instances),onClose:()=>te(null),onInstall:e=>G(oe(e)),t}):null,Xe?(0,$.jsx)(vn,{instance:Xe,definition:Te.get(Xe.connectorId),onClose:()=>{re(null),ae(null)},onChanged:Y,t,mcp:n}):null,le?(0,$.jsx)(Ln,{open:!0,mode:le.mode,initialRow:le.row,existingCustomServers:J,sessionIdleTtlMinutes:me,config:K,managedServerIds:De,t:n,cs:t,onClose:()=>de(null),onSaved:async()=>{await ye(),await Y(),xe(`connected`)}},`${le.mode}-${le.row.clientKey}`):null,(0,$.jsx)(bt,{open:fe,sessionIdleTtlMinutes:me,saving:ge,onChange:he,onSave:Ne,onClose:()=>pe(!1),t,mcp:n})]})})}export{Xn as ConnectorsPage};
|