@xopcai/xopc 0.0.390 → 0.0.391
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/plugin.js +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{activity-store-DGMAYkw8.js → activity-store-DWQCDi8M.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-B4AsZzJR.js → agent-avatar-dicebear-CzS0TUv9.js} +1 -1
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-DE910MyU.js +1 -0
- package/dist/gateway/static/root/assets/agent-plugin-dialog-0SlvsYl7.js +1 -0
- package/dist/gateway/static/root/assets/agents-BZh28Qn1.js +77 -0
- package/dist/gateway/static/root/assets/{agents-admin-api-DxdaiFWn.js → agents-admin-api-Bb3Kvz3X.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-DHRfLkYD.js → app-management-settings-panel-9A7JN5V5.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-DtKSapgb.js → appearance-settings-BPdLEo6L.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-B9kuRt_z.js → apps-page-Cz7LypV9.js} +1 -1
- package/dist/gateway/static/root/assets/{archive-plugin-AgySTXp_.js → archive-plugin-DFnHPNie.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-D1o7ZtUW.js → automations-page-CnBLPVNh.js} +1 -1
- package/dist/gateway/static/root/assets/automations-workspace-BBjS-sk-.js +6 -0
- package/dist/gateway/static/root/assets/{binary-plugins-A1AXOsO6.js → binary-plugins-BQC0Tzoi.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-DUNLkLKF.js → block-editor-DSh5019z.js} +4 -4
- package/dist/gateway/static/root/assets/{browser-automation-inputs-BvUC6OiW.js → browser-automation-inputs-C5tIrIRL.js} +1 -1
- package/dist/gateway/static/root/assets/browser-automations-page-CFCMNfJN.js +3 -0
- package/dist/gateway/static/root/assets/browser-settings-page-C__tyPwu.js +3 -0
- package/dist/gateway/static/root/assets/{capabilities-D61uSJPy.js → capabilities-D6RJG4QY.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-BkCutK0V.js → capabilities-DGEmBQnF.js} +1 -1
- package/dist/gateway/static/root/assets/capabilities-page-B5AZa7ir.js +2 -0
- package/dist/gateway/static/root/assets/capabilities-settings-panel-Dskz2_bh.js +8 -0
- package/dist/gateway/static/root/assets/{capability-header-actions-D9uGs4Pw.js → capability-header-actions-xzjWZVbg.js} +1 -1
- package/dist/gateway/static/root/assets/{channels-xb7n8rwF.js → channels-DRse_dD3.js} +1 -1
- package/dist/gateway/static/root/assets/{chat-terminal-dock-Dgn09YDs.js → chat-terminal-dock-CQF0M4kE.js} +1 -1
- package/dist/gateway/static/root/assets/{computer-settings-page-C66P4ifT.js → computer-settings-page-ZfzCTS0N.js} +1 -1
- package/dist/gateway/static/root/assets/{connector-service-page-Dp35XdYf.js → connector-service-page-CwAeWVLK.js} +1 -1
- package/dist/gateway/static/root/assets/connectors-page-CanakKaj.js +1 -0
- package/dist/gateway/static/root/assets/{date-picker-CddHY982.js → date-picker-hmJlEAQZ.js} +1 -1
- package/dist/gateway/static/root/assets/{dependency-picker-Ob6BZTqv.js → dependency-picker-Us_Juz6I.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-dmwCV-I4.js → desktop-pet-CvOTI4uw.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-B-TBkZAZ.js → desktop-pet-settings-DYg-Gb8t.js} +1 -1
- package/dist/gateway/static/root/assets/device-pairing-wizard-B1FbZ8C1.js +1 -0
- package/dist/gateway/static/root/assets/{directory-picker-path-field-6VZa4fT1.js → directory-picker-path-field-DZN9EDvM.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-C0_njMva.js → extension-debug-page-YIibp6Kk.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-BeBLMFmW.js → extension-page-DkcGyb28.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-provider-DWI0KAKT.js → extension-provider-B1PQGTtY.js} +1 -1
- package/dist/gateway/static/root/assets/extension-settings-page-C_rJiSKo.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-config-swr-CmYcOqhb.js → gateway-config-swr-Dv_A5FMu.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-realtime-Ci1Jst5g.js → gateway-realtime-DghCGfY_.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-realtime-store-CMJVSnvi.js +1 -0
- package/dist/gateway/static/root/assets/gateway-settings-CjCWPHNJ.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-startup-retry-C-BG5M7H.js → gateway-startup-retry-CkTVSESs.js} +1 -1
- package/dist/gateway/static/root/assets/{highlighted-body-KQOG7T2V-CsA7lCVc.js → highlighted-body-KQOG7T2V-DV2wNqBn.js} +1 -1
- package/dist/gateway/static/root/assets/home-page-fAYsd7kG.js +2 -0
- package/dist/gateway/static/root/assets/{image-generation-api-B_DqCwtV.js → image-generation-api-B98iXt6A.js} +1 -1
- package/dist/gateway/static/root/assets/{imports-page-oAvAF9QS.js → imports-page-DoBCBN8G.js} +1 -1
- package/dist/gateway/static/root/assets/index-DFgXwLsv.js +260 -0
- package/dist/gateway/static/root/assets/index-a6ZvhclR.css +1 -0
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings--MjYe-Pb.js → keyboard-shortcuts-settings-DXVu4lqV.js} +1 -1
- package/dist/gateway/static/root/assets/local-app-workbench-page-B3fz6uRi.js +1 -0
- package/dist/gateway/static/root/assets/{local-apps-page-DOa7mxjB.js → local-apps-page-BC6xhmUh.js} +1 -1
- package/dist/gateway/static/root/assets/{local-session-drafts-DAtLkTPg.js → local-session-drafts-DFnZQu9A.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-DMy9W6IG.js → locale-store-BpK9AiDq.js} +1 -1
- package/dist/gateway/static/root/assets/logs-page-CSqSFDRU.js +2 -0
- package/dist/gateway/static/root/assets/{management-settings-C0TzuD3-.js → management-settings-gq5L0THs.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-view-wyOHdXEg.js → markdown-view-IsYTotu6.js} +18 -18
- package/dist/gateway/static/root/assets/{media-plugins-Pb2zr_-L.js → media-plugins-oSChWbcP.js} +1 -1
- package/dist/gateway/static/root/assets/mermaid-MCJ5UELQ-C_QKwqDN.js +1 -0
- package/dist/gateway/static/root/assets/{messages-O0BEUKnx.js → messages-CKTo_sIF.js} +2 -2
- package/dist/gateway/static/root/assets/{models-hub-cache-DdH1MODX.js → models-hub-cache-TjpL7hZ5.js} +1 -1
- package/dist/gateway/static/root/assets/note-detail-panel-CdpNXre-.js +5 -0
- package/dist/gateway/static/root/assets/{notes-api-CYt2pGsm.js → notes-api-CBb944yw.js} +1 -1
- package/dist/gateway/static/root/assets/notes-page-EGvGw8MN.js +8 -0
- package/dist/gateway/static/root/assets/{page-context-capture-button-3uj5EcQC.js → page-context-capture-button-CoWb7BYP.js} +1 -1
- package/dist/gateway/static/root/assets/personal-page-DYzbNTyN.js +1 -0
- package/dist/gateway/static/root/assets/{product-open-page-hI13tPS1.js → product-open-page-CTyy7H7-.js} +1 -1
- package/dist/gateway/static/root/assets/{product-preview-content-lT_in0-Q.js → product-preview-content-D4xqTaEy.js} +1 -1
- package/dist/gateway/static/root/assets/project-detail-page-DIVCw0QQ.js +1 -0
- package/dist/gateway/static/root/assets/projects-page-B4L9VnBN.js +1 -0
- package/dist/gateway/static/root/assets/{registry-api-CgQrCqL6.js → registry-api-Dsa2LvRt.js} +1 -1
- package/dist/gateway/static/root/assets/remote-access-hub-B8PvgLVz.js +1 -0
- package/dist/gateway/static/root/assets/{runtime-tools-api-D12qVKeC.js → runtime-tools-api-C2Uw89eY.js} +1 -1
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-DOSPOfCU.js → runtime-tools-settings-panel-Bqnp3tyt.js} +1 -1
- package/dist/gateway/static/root/assets/scenes-page-D50g4GM2.js +2 -0
- package/dist/gateway/static/root/assets/{schema-form-CwOFgsyh.js → schema-form-h_RCNfiO.js} +1 -1
- package/dist/gateway/static/root/assets/{send-session-input-nH8Cw0US.js → send-session-input-DypbVTT7.js} +1 -1
- package/dist/gateway/static/root/assets/{session-api-B9HrwF-c.js → session-api-ga-SUOq_.js} +1 -1
- package/dist/gateway/static/root/assets/{session-manager-aXqXuqDX.js → session-manager-C_OiKblh.js} +8 -8
- package/dist/gateway/static/root/assets/sessions-page-BsqDIbIr.js +1 -0
- package/dist/gateway/static/root/assets/settings-advanced-gate-D3zJAW4p.js +1 -0
- package/dist/gateway/static/root/assets/{settings-page-BN70wE6R.js → settings-page-DPCgrICd.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-status-panel-CHzcVRi-.js → setup-status-panel-jjSYJpDd.js} +1 -1
- package/dist/gateway/static/root/assets/{share-link-dialog-B1TDyhPt.js → share-link-dialog-BGicglAS.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-Br-eAZaP.js → share-preview-page-BORe9rLB.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-api-Bl1ZBh5S.js → shares-api-Dbx3z6-1.js} +1 -1
- package/dist/gateway/static/root/assets/shares-settings-C13FgfWk.js +1 -0
- package/dist/gateway/static/root/assets/{skill-api-ClUw3SRC.js → skill-api-Cq6O1DZK.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-reload-api--1BfIPzb.js → skill-reload-api-Cq7QDjMA.js} +1 -1
- package/dist/gateway/static/root/assets/skills-page-BM1ShEjx.js +2 -0
- package/dist/gateway/static/root/assets/{system-settings-panel-tWrqu7ai.js → system-settings-panel-BNCGFO1e.js} +1 -1
- package/dist/gateway/static/root/assets/task-detail-page-4VG82wcF.js +2 -0
- package/dist/gateway/static/root/assets/{task-expandable-content-D2t4ahzR.js → task-expandable-content-DAZGz5YC.js} +1 -1
- package/dist/gateway/static/root/assets/{theme-store-BBLjE0fi.js → theme-store-Db7hDESt.js} +1 -1
- package/dist/gateway/static/root/assets/{tracing-settings-page-5ATxQH5c.js → tracing-settings-page-C6p2Mu92.js} +1 -1
- package/dist/gateway/static/root/assets/{tunnel-api-CF1Qh4wU.js → tunnel-api-Dw15EJp0.js} +1 -1
- package/dist/gateway/static/root/assets/usage-page-DDrIqgGe.js +1 -0
- package/dist/gateway/static/root/assets/{use-autosave-tY3keIbm.js → use-autosave-DDjIdW4U.js} +1 -1
- package/dist/gateway/static/root/assets/{use-composer-attachments-CXsocZjt.js → use-composer-attachments-DNl7O3Vb.js} +1 -1
- package/dist/gateway/static/root/assets/{use-file-preview-expanded-CEsxnDnQ.js → use-file-preview-expanded-DMHehhwG.js} +2 -2
- package/dist/gateway/static/root/assets/user-model-page-CaS9dOIr.js +2 -0
- package/dist/gateway/static/root/assets/{voice-api-key-field-COTNLUU3.js → voice-api-key-field-ByAxHE4P.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-config-api-DrxBjSja.js → voice-config-api-Dl39b27p.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-transcribe-api-B47j0_xA.js → voice-transcribe-api-CVaU83Jc.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-PByMJrhV.js → work-discovery-overlay-BvVvPA1T.js} +1 -1
- package/dist/gateway/static/root/assets/workflow-run-setup-panel-BcFm9QcC.js +3 -0
- package/dist/gateway/static/root/assets/workflows-page-DMec_XZB.js +6 -0
- package/dist/gateway/static/root/assets/{workspace-api-Bmx1O449.js → workspace-api-BpfKsrtP.js} +2 -2
- package/dist/gateway/static/root/assets/{xopc-cloud-account-card-DVsAbvwP.js → xopc-cloud-account-card-CU5lzzE9.js} +1 -1
- package/dist/gateway/static/root/index.html +28 -36
- package/dist/package.js +1 -1
- package/dist/src/agent/agent-manager.d.ts +1 -0
- package/dist/src/agent/agent-manager.js +4 -1
- package/dist/src/agent/context/execution-scope.js +1 -1
- package/dist/src/agent/embedded/execution-tool-policy.d.ts +2 -0
- package/dist/src/agent/embedded/execution-tool-policy.js +8 -3
- package/dist/src/agent/embedded/run-turn.js +2 -1
- package/dist/src/agent/embedded/session-runner.js +1 -1
- package/dist/src/agent/tools/factory.js +14 -12
- package/dist/src/agent/tools/personal-read-tool.js +4 -0
- package/dist/src/agent/tools/task-collaboration-tool.js +1 -1
- package/dist/src/channels/index.js +1 -1
- package/dist/src/channels/manager.js +1 -1
- package/dist/src/cli/commands/channels.js +1 -1
- package/dist/src/cli/commands/connectors.js +1 -1
- package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
- package/dist/src/cli/commands/extension-marketplace.js +1 -1
- package/dist/src/cli/commands/models.js +1 -1
- package/dist/src/cli/commands/onboard.js +1 -1
- package/dist/src/extensions/sdk/index.js +1 -1
- package/dist/src/gateway/hono/lib/voice-settings-revisions.js +2 -1
- package/dist/src/gateway/hono/routes/commands-skills.js +15 -0
- package/dist/src/gateway/service.js +9 -7
- package/dist/src/home-intelligence/host.js +2 -2
- package/dist/src/providers/setup/profiles.d.ts +2 -2
- package/dist/src/providers/setup/profiles.js +6 -22
- package/dist/src/storage/sqlite/migrations/256_task_main_update_retries.sql +21 -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/schema.js +1 -1
- package/dist/src/tasks/task-collaboration-repository.d.ts +2 -0
- package/dist/src/tasks/task-collaboration-repository.js +7 -1
- package/dist/src/tasks/task-main-update-delivery.js +11 -4
- package/dist/src/tasks/task-main-update-input.js +2 -1
- package/dist/src/tasks/task-main-update-retry.d.ts +5 -0
- package/dist/src/tasks/task-main-update-retry.js +15 -0
- package/package.json +3 -3
- package/dist/gateway/static/root/assets/agent-defaults-settings-panel-9NUY1sO3.js +0 -1
- package/dist/gateway/static/root/assets/agent-plugin-dialog-CNc6ntzP.js +0 -1
- package/dist/gateway/static/root/assets/agents-QNY9Vkrf.js +0 -77
- package/dist/gateway/static/root/assets/automations-workspace-BJenz0P1.js +0 -6
- package/dist/gateway/static/root/assets/bot-DjLkhyZL.js +0 -1
- package/dist/gateway/static/root/assets/browser-automations-page-Dq2LlVMh.js +0 -3
- package/dist/gateway/static/root/assets/browser-settings-page-BOZ-1g51.js +0 -3
- package/dist/gateway/static/root/assets/capabilities-page-BDP6gzlv.js +0 -2
- package/dist/gateway/static/root/assets/capabilities-settings-panel-D6PL3Mfl.js +0 -8
- package/dist/gateway/static/root/assets/circle-pause-CN9jYH2s.js +0 -1
- package/dist/gateway/static/root/assets/clock-3-DnrAnuyZ.js +0 -1
- package/dist/gateway/static/root/assets/connectors-page-BHcRxYib.js +0 -1
- package/dist/gateway/static/root/assets/device-pairing-wizard-SWHwRgG3.js +0 -1
- package/dist/gateway/static/root/assets/extension-settings-page-BiLUwoKx.js +0 -1
- package/dist/gateway/static/root/assets/gateway-realtime-store-BMUiUQMk.js +0 -1
- package/dist/gateway/static/root/assets/gateway-settings-CzWT_v09.js +0 -1
- package/dist/gateway/static/root/assets/git-branch-Dh9uxTot.js +0 -1
- package/dist/gateway/static/root/assets/home-page-BeXJfxsg.js +0 -2
- package/dist/gateway/static/root/assets/index-W9ls-0Yd.css +0 -1
- package/dist/gateway/static/root/assets/index-xTL-vb51.js +0 -260
- package/dist/gateway/static/root/assets/local-app-workbench-page-DL33dtd7.js +0 -1
- package/dist/gateway/static/root/assets/logs-page-C-GbTYsM.js +0 -2
- package/dist/gateway/static/root/assets/mermaid-MCJ5UELQ-BxyGGa4D.js +0 -1
- package/dist/gateway/static/root/assets/message-square-fVE7Ghj1.js +0 -1
- package/dist/gateway/static/root/assets/note-detail-panel-BFpEqskQ.js +0 -5
- package/dist/gateway/static/root/assets/notes-page-h-qqFJ6Z.js +0 -8
- package/dist/gateway/static/root/assets/pause-DuPxgSxk.js +0 -1
- package/dist/gateway/static/root/assets/personal-page-BGyW6cdt.js +0 -1
- package/dist/gateway/static/root/assets/play-kxZvpBg8.js +0 -1
- package/dist/gateway/static/root/assets/project-detail-page-Baj7fQ7N.js +0 -1
- package/dist/gateway/static/root/assets/projects-page-D7DyQFU3.js +0 -1
- package/dist/gateway/static/root/assets/remote-access-hub-DU_d93Tm.js +0 -1
- package/dist/gateway/static/root/assets/scenes-page-swyUIF5A.js +0 -2
- package/dist/gateway/static/root/assets/sessions-page-CI_PJmlX.js +0 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-DCVaeBLW.js +0 -1
- package/dist/gateway/static/root/assets/shares-settings-jgCC_E4Y.js +0 -1
- package/dist/gateway/static/root/assets/skills-page-C9oRZSuL.js +0 -2
- package/dist/gateway/static/root/assets/sparkles-DHlfQFAF.js +0 -1
- package/dist/gateway/static/root/assets/task-detail-page-BYRW7Rrr.js +0 -2
- package/dist/gateway/static/root/assets/usage-page-CuEHzXil.js +0 -1
- package/dist/gateway/static/root/assets/user-model-page-Dvt5TIZ6.js +0 -2
- package/dist/gateway/static/root/assets/workflow-run-setup-panel-CSUkMo63.js +0 -3
- package/dist/gateway/static/root/assets/workflows-page-BUDvFo3R.js +0 -6
|
@@ -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{_ as i,p as a}from"./chunk-KS7C4IRE--EKdQGRF.js";import{t as o}from"./chevron-right-BweFrslA.js";import{n as s,r as c,t as l}from"./popover-select-DHC7J4lG.js";import{t as u}from"./circle-alert-BEjgurr2.js";import{t as d}from"./circle-check-C23XjkUj.js";import{t as f}from"./clock-3-DnrAnuyZ.js";import{t as p}from"./ellipsis-0k4rZLoy.js";import{t as m}from"./external-link-DjqjBmc3.js";import{n as h}from"./secret-input-BxWHx6J6.js";import{t as g}from"./eye-CABVeTq0.js";import{t as _}from"./loader-circle-CifKLtgG.js";import{t as v}from"./plus-Q2yW6OE7.js";import{t as y}from"./x-B_N4OPjy.js";import{t as b}from"./messages-O0BEUKnx.js";import{t as x}from"./cn-0WouolD0.js";import{a as S,c as C,n as w,r as T}from"./locale-store-DMy9W6IG.js";import{a as E,i as D,n as O,o as k,r as A,s as j,t as M}from"./dist-BGTk37IG.js";import{r as N}from"./extension-provider-DWI0KAKT.js";import{n as P}from"./copy-to-clipboard-HOJ79TWv.js";import{t as F}from"./button-aIC072nz.js";import{n as I}from"./interaction-BdhHBbYa.js";import{n as L,r as R}from"./gateway-config-swr-CmYcOqhb.js";import{s as z}from"./form-field-width-DJw_jULe.js";import{t as B}from"./skeleton-BI5TyibZ.js";import{n as V}from"./electron-env-Dit0bHgy.js";import{$ as H,$a as U,$n as W,Ba as G,Ca as K,Ec as q,Es as ee,Ga as te,Ha as ne,Ic as re,Io as J,Ja as ie,Ka as ae,La as oe,Q as se,Qa as Y,Qn as ce,Ra as le,To as ue,Ua as de,Uc as fe,Uo as X,Va as pe,Wa as me,X as he,Xa as ge,Xn as _e,Ya as ve,Z as ye,Za as be,Zn as xe,ao as Se,ar as Ce,co as Z,do as we,ec as Te,eo as Ee,et as De,fo as Oe,ho as ke,ir as Ae,is as je,ji as Me,lo as Ne,ls as Pe,mo as Fe,no as Ie,nr as Le,nt as Re,oo as ze,po as Be,ro as Ve,rr as He,rs as Ue,so as We,sr as Ge,ss as Ke,tt as qe,uo as Je,za as Ye}from"./index-xTL-vb51.js";import{n as Xe,t as Ze}from"./capability-header-actions-D9uGs4Pw.js";import{t as Qe}from"./connector-service-page-Dp35XdYf.js";import{t as $e}from"./page-tabs-HLrKIjXH.js";import{n as et}from"./agent-plugin-dialog-CNc6ntzP.js";import{t as tt}from"./number-input-DDeqHK-G.js";var Q=e(t(),1),nt=n(),$=r();function rt(e){let t=(0,nt.c)(57),{connector:n,installed:r,onInstall:i,onOpenDetails:a,t:o}=e,s,c,l,u,f,p;if(t[0]!==n||t[1]!==r||t[2]!==i||t[3]!==a||t[4]!==o){let e=n.capabilities.filter(it),m=e.slice(0,2),h=Math.max(0,e.length-m.length),g=o.connect,_;t[11]!==n||t[12]!==o?(_=H(n,o),t[11]=n,t[12]=o,t[13]=_):_=t[13];let v=_,y=n.verificationLevel===`verified`?o.connectorVerified:n.verificationLevel===`beta`?o.connectorBeta:n.verificationLevel===`experimental`?o.connectorExperimental:null,b;t[14]!==g||t[15]!==n||t[16]!==i?(b=e=>(0,$.jsxs)(F,{type:`button`,variant:`primary`,className:x(`h-8 justify-center px-2.5 text-xs font-medium`,e),onClick:()=>i(n),children:[(0,$.jsx)(ee,{className:`size-4`}),g]}),t[14]=g,t[15]=n,t[16]=i,t[17]=b):b=t[17],s=b,p=`group flex min-h-[8.75rem] flex-col rounded-xl border border-edge bg-surface-panel p-4 transition-colors hover:bg-surface-hover/45 focus-within:ring-2 focus-within:ring-accent/30`,c=`flex min-w-0 flex-1 flex-col`;let S;t[18]===n?S=t[19]:(S=(0,$.jsx)(Re,{connector:n}),t[18]=n,t[19]=S);let C;t[20]!==n||t[21]!==a?(C=a?(0,$.jsx)(`button`,{type:`button`,className:`block max-w-full truncate text-left text-sm font-semibold text-fg hover:underline`,onClick:()=>a(n),children:n.displayName}):(0,$.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:n.displayName}),t[20]=n,t[21]=a,t[22]=C):C=t[22];let w;t[23]===y?w=t[24]:(w=y?(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:y}):null,t[23]=y,t[24]=w);let T;t[25]!==w||t[26]!==C?(T=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[C,w]}),t[25]=w,t[26]=C,t[27]=T):T=t[27];let E;t[28]!==T||t[29]!==S?(E=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[S,T]}),t[28]=T,t[29]=S,t[30]=E):E=t[30];let D;t[31]!==r||t[32]!==s?(D=r?null:(0,$.jsx)(`div`,{className:`hidden shrink-0 items-center gap-1 sm:flex`,children:s()}),t[31]=r,t[32]=s,t[33]=D):D=t[33];let O;t[34]!==r||t[35]!==o.connectedBadge?(O=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)(d,{className:`size-3`,"aria-hidden":!0}),o.connectedBadge]}):null,t[34]=r,t[35]=o.connectedBadge,t[36]=O):O=t[36];let k;t[37]!==D||t[38]!==O?(k=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start gap-2`,children:[D,O]}),t[37]=D,t[38]=O,t[39]=k):k=t[39],t[40]!==E||t[41]!==k?(l=(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[E,k]}),t[40]=E,t[41]=k,t[42]=l):l=t[42],t[43]===v?u=t[44]:(u=(0,$.jsx)(`p`,{className:`mt-3 line-clamp-2 text-sm leading-6 text-fg-muted`,title:v,children:v}),t[43]=v,t[44]=u),f=m.length>0?(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:[m.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)),h>0?(0,$.jsxs)(`span`,{className:`rounded-md bg-surface-base px-2 py-0.5 text-[11px] text-fg-subtle`,children:[`+`,h]}):null]}):null,t[0]=n,t[1]=r,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=f,t[10]=p}else s=t[5],c=t[6],l=t[7],u=t[8],f=t[9],p=t[10];let m;t[45]!==c||t[46]!==l||t[47]!==u||t[48]!==f?(m=(0,$.jsxs)(`div`,{className:c,children:[l,u,f]}),t[45]=c,t[46]=l,t[47]=u,t[48]=f,t[49]=m):m=t[49];let h;t[50]!==r||t[51]!==s?(h=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[50]=r,t[51]=s,t[52]=h):h=t[52];let g;return t[53]!==p||t[54]!==m||t[55]!==h?(g=(0,$.jsxs)(`div`,{className:p,children:[m,h]}),t[53]=p,t[54]=m,t[55]=h,t[56]=g):g=t[56],g}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,nt.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`div`,{className:x(`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:x(`h-4 min-w-0 flex-1`,st)}),(0,$.jsx)(`div`,{className:x(`h-8 w-[4.5rem] shrink-0 rounded-lg`,st)})]}),(0,$.jsx)(`div`,{className:x(`h-3 w-full`,st)}),(0,$.jsx)(`div`,{className:x(`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,nt.c)(4),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`div`,{className:x(`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:x(`h-4 w-48 max-w-full`,lt)}),(0,$.jsx)(`div`,{className:x(`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:x(`h-9 w-20 rounded-lg`,lt)}),(0,$.jsx)(`div`,{className:x(`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:x(`h-8 w-20 rounded-md`,lt)}),(0,$.jsx)(`div`,{className:x(`h-8 w-24 rounded-md`,lt)}),(0,$.jsx)(`div`,{className:x(`h-8 w-28 rounded-md`,lt)})]}),(0,$.jsx)(`div`,{className:x(`mt-3 h-20 rounded-xl`,lt)})]}),e[3]=i):i=e[3],i}var dt=[`understand`,`act`,`reach`];function ft(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 pt(e){return ft(e)[0]??`act`}function mt(e,t){let n=t?pt(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 ht(e,t){return t.connectorCapabilityLabels[e]??e}function gt(e,t){if(e.runtime.type===`mcp`)return De(t.connectorRuntimeMcp,{serverId:e.runtime.serverId});let n=e.runtime.type===`composio`?e.runtime.toolkit:e.runtime.type===`cli`?e.runtime.adapterId:e.runtime.sourceKind;return De(t.connectorRuntimeGeneric,{runtime:e.runtime.type,id:n??e.runtime.type})}function _t(e,t){return e.auth.mode===`cli`?t.connectorAuthCli:e.auth.mode===`oauth`?t.connectorAuthOAuth:e.auth.mode===`apiKey`?t.connectorAuthApiKey:t.connectorAuthNone}function vt(e){let t=(0,nt.c)(133),{connector:n,installed:r,onClose:i,onInstall:a,t:o}=e,s;t[0]!==n||t[1]!==o?(s=H(n,o),t[0]=n,t[1]=o,t[2]=s):s=t[2];let c=s,l,u,f,p,m,h,g,_,v,b,S,C,w,T,N,P;if(t[3]!==n||t[4]!==c||t[5]!==r||t[6]!==i||t[7]!==o){let e=ft(n),a;t[24]!==n.setup.config||t[25]!==n.setup.secrets?(a=[...(n.setup.secrets??[]).filter(xt),...(n.setup.config??[]).filter(bt)],t[24]=n.setup.config,t[25]=n.setup.secrets,t[26]=a):a=t[26];let s=a,F=n.capabilities.filter(yt);f=M,g=!0,t[27]===i?_=t[28]:(_=e=>{e||i()},t[27]=i,t[28]=_),u=k,t[29]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(E,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),t[29]=h):h=t[29],l=A,t[30]===Symbol.for(`react.memo_cache_sentinel`)?(p=x(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(100vh-2rem,42rem)] w-[min(100%-2rem,min(92vw,44rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-overlay shadow-float outline-none dark:border-edge`),t[30]=p):p=t[30];let L;t[31]===n?L=t[32]:(L=(0,$.jsx)(Re,{connector:n,size:`lg`}),t[31]=n,t[32]=L);let R;t[33]===n.displayName?R=t[34]:(R=(0,$.jsx)(j,{className:`text-base font-semibold text-fg`,children:n.displayName}),t[33]=n.displayName,t[34]=R);let z;t[35]!==r||t[36]!==o.connectedBadge?(z=r?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-emerald-500/10 px-2 py-0.5 text-[11px] font-medium text-emerald-700 dark:text-emerald-300`,children:[(0,$.jsx)(d,{className:`size-3`,"aria-hidden":!0}),o.connectedBadge]}):null,t[35]=r,t[36]=o.connectedBadge,t[37]=z):z=t[37];let B;t[38]!==R||t[39]!==z?(B=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[R,z]}),t[38]=R,t[39]=z,t[40]=B):B=t[40];let V;t[41]===c?V=t[42]:(V=(0,$.jsx)(D,{className:`mt-1 line-clamp-3 text-sm leading-6 text-fg-muted`,children:c}),t[41]=c,t[42]=V);let H;t[43]!==B||t[44]!==V?(H=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[B,V]}),t[43]=B,t[44]=V,t[45]=H):H=t[45];let U;t[46]!==L||t[47]!==H?(U=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[L,H]}),t[46]=L,t[47]=H,t[48]=U):U=t[48];let W;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(W=x(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,I.focusRingPanel),t[49]=W):W=t[49];let G;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(G=(0,$.jsx)(y,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),t[50]=G):G=t[50];let K;t[51]===o.modalClose?K=t[52]:(K=(0,$.jsx)(O,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:W,"aria-label":o.modalClose,children:G})}),t[51]=o.modalClose,t[52]=K),t[53]!==U||t[54]!==K?(m=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-5 py-5 sm:px-6`,children:[U,K]}),t[53]=U,t[54]=K,t[55]=m):m=t[55],T=`min-h-0 flex-1 space-y-5 overflow-y-auto px-5 py-5 sm:px-6`,N=e.length?(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:o.connectorWhyConnect}),(0,$.jsx)(`div`,{className:`mt-3 divide-y divide-edge-subtle overflow-hidden rounded-xl border border-edge bg-surface-base`,children:e.map(e=>(0,$.jsxs)(`div`,{className:`px-4 py-3`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:o.connectorBenefitHeadings[e]}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:o.connectorBenefitHints[e]})]},e))})]}):null;let q;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(q=(0,$.jsx)(Te,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),t[56]=q):q=t[56];let ee;t[57]===o.detailPermissions?ee=t[58]:(ee=(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:o.detailPermissions}),t[57]=o.detailPermissions,t[58]=ee);let te;t[59]!==n||t[60]!==o?(te=_t(n,o),t[59]=n,t[60]=o,t[61]=te):te=t[61];let ne;t[62]===te?ne=t[63]:(ne=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:te}),t[62]=te,t[63]=ne);let re;t[64]!==ee||t[65]!==ne?(re=(0,$.jsxs)(`div`,{className:`flex items-start gap-3 border-b border-edge-subtle px-4 py-3`,children:[q,(0,$.jsxs)(`div`,{children:[ee,ne]})]}),t[64]=ee,t[65]=ne,t[66]=re):re=t[66];let J;t[67]===o.connectorSetupTitle?J=t[68]:(J=(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:o.connectorSetupTitle}),t[67]=o.connectorSetupTitle,t[68]=J);let ie;t[69]!==s.length||t[70]!==o.connectorRequiredInputsCount||t[71]!==o.connectorSetupNone?(ie=s.length?De(o.connectorRequiredInputsCount,{count:String(s.length)}):o.connectorSetupNone,t[69]=s.length,t[70]=o.connectorRequiredInputsCount,t[71]=o.connectorSetupNone,t[72]=ie):ie=t[72];let ae;t[73]===ie?ae=t[74]:(ae=(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:ie}),t[73]=ie,t[74]=ae);let oe;t[75]!==J||t[76]!==ae?(oe=(0,$.jsxs)(`div`,{className:`px-4 py-3`,children:[J,ae]}),t[75]=J,t[76]=ae,t[77]=oe):oe=t[77],t[78]!==re||t[79]!==oe?(P=(0,$.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-base`,children:[re,oe]}),t[78]=re,t[79]=oe,t[80]=P):P=t[80],C=`rounded-xl border border-edge bg-surface-base`,t[81]===o.connectorTechnicalDetails?w=t[82]:(w=(0,$.jsx)(`summary`,{className:`cursor-pointer px-4 py-3 text-sm font-medium text-fg-muted hover:text-fg`,children:o.connectorTechnicalDetails}),t[81]=o.connectorTechnicalDetails,t[82]=w),v=`space-y-5 border-t border-edge-subtle px-4 py-4`;let se;t[83]===Symbol.for(`react.memo_cache_sentinel`)?(se=(0,$.jsx)(je,{className:`size-3.5`,"aria-hidden":!0}),t[83]=se):se=t[83];let Y;t[84]===o.connectorRuntimeTitle?Y=t[85]:(Y=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[se,o.connectorRuntimeTitle]}),t[84]=o.connectorRuntimeTitle,t[85]=Y);let ce;t[86]!==n||t[87]!==o?(ce=gt(n,o),t[86]=n,t[87]=o,t[88]=ce):ce=t[88];let le;t[89]===ce?le=t[90]:(le=(0,$.jsx)(`p`,{className:`mt-1 break-words text-xs text-fg-subtle`,children:ce}),t[89]=ce,t[90]=le),t[91]!==Y||t[92]!==le?(b=(0,$.jsxs)(`div`,{children:[Y,le]}),t[91]=Y,t[92]=le,t[93]=b):b=t[93],S=F.length?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:F.map(e=>(0,$.jsx)(`span`,{className:`rounded-md bg-surface-panel px-2 py-1 text-xs text-fg-muted`,children:ht(e,o)},e))}):null,t[3]=n,t[4]=c,t[5]=r,t[6]=i,t[7]=o,t[8]=l,t[9]=u,t[10]=f,t[11]=p,t[12]=m,t[13]=h,t[14]=g,t[15]=_,t[16]=v,t[17]=b,t[18]=S,t[19]=C,t[20]=w,t[21]=T,t[22]=N,t[23]=P}else l=t[8],u=t[9],f=t[10],p=t[11],m=t[12],h=t[13],g=t[14],_=t[15],v=t[16],b=t[17],S=t[18],C=t[19],w=t[20],T=t[21],N=t[22],P=t[23];let L;t[94]!==v||t[95]!==b||t[96]!==S?(L=(0,$.jsxs)(`div`,{className:v,children:[b,S]}),t[94]=v,t[95]=b,t[96]=S,t[97]=L):L=t[97];let R;t[98]!==L||t[99]!==C||t[100]!==w?(R=(0,$.jsxs)(`details`,{className:C,children:[w,L]}),t[98]=L,t[99]=C,t[100]=w,t[101]=R):R=t[101];let z;t[102]!==R||t[103]!==T||t[104]!==N||t[105]!==P?(z=(0,$.jsxs)(`div`,{className:T,children:[N,P,R]}),t[102]=R,t[103]=T,t[104]=N,t[105]=P,t[106]=z):z=t[106];let B;t[107]===o.modalClose?B=t[108]:(B=(0,$.jsx)(O,{asChild:!0,children:(0,$.jsx)(F,{variant:`secondary`,children:o.modalClose})}),t[107]=o.modalClose,t[108]=B);let V;t[109]!==n||t[110]!==r||t[111]!==i||t[112]!==a||t[113]!==o.connect?(V=r?null:(0,$.jsxs)(F,{variant:`primary`,onClick:()=>{a(n),i()},children:[(0,$.jsx)(ee,{className:`size-4`}),o.connect]}),t[109]=n,t[110]=r,t[111]=i,t[112]=a,t[113]=o.connect,t[114]=V):V=t[114];let U;t[115]!==B||t[116]!==V?(U=(0,$.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-5 py-4 sm:px-6`,children:[B,V]}),t[115]=B,t[116]=V,t[117]=U):U=t[117];let W;t[118]!==l||t[119]!==p||t[120]!==m||t[121]!==z||t[122]!==U?(W=(0,$.jsxs)(l,{className:p,children:[m,z,U]}),t[118]=l,t[119]=p,t[120]=m,t[121]=z,t[122]=U,t[123]=W):W=t[123];let G;t[124]!==u||t[125]!==h||t[126]!==W?(G=(0,$.jsxs)(u,{children:[h,W]}),t[124]=u,t[125]=h,t[126]=W,t[127]=G):G=t[127];let K;return t[128]!==f||t[129]!==g||t[130]!==_||t[131]!==G?(K=(0,$.jsx)(f,{open:g,onOpenChange:_,children:G}),t[128]=f,t[129]=g,t[130]=_,t[131]=G,t[132]=K):K=t[132],K}function yt(e){return!e.startsWith(`runtime.`)&&!e.startsWith(`auth.`)}function bt(e){return e.required}function xt(e){return e.required}var St=(0,Q.memo)(function(e){let t=(0,nt.c)(45),{onRefresh:n,refreshing:r,refreshLabel:i,onBrowseCatalog:a,onAddCustomServer:o,addLabel:s,browseLabel:c,customLabel:l,serviceLabel:u,moreActionsLabel:d}=e,[f,m]=(0,Q.useState)(!1),h;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(h=x(`touch-target flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50 data-[highlighted]:bg-surface-hover`,I.transition),t[0]=h):h=t[0];let g=h,y;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(v,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[1]=y):y=t[1];let b;t[2]===s?b=t[3]:(b=(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:s}),t[2]=s,t[3]=b);let S;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,$.jsx)(fe,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[4]=S):S=t[4];let C;t[5]!==s||t[6]!==b?(C=(0,$.jsx)(Ge,{asChild:!0,children:(0,$.jsxs)(F,{type:`button`,variant:`primary`,className:`shrink-0 gap-2`,"aria-label":s,children:[y,b,S]})}),t[5]=s,t[6]=b,t[7]=C):C=t[7];let w;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(X,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[8]=w):w=t[8];let T;t[9]!==c||t[10]!==a?(T=(0,$.jsxs)(He,{className:g,onSelect:a,children:[w,c]}),t[9]=c,t[10]=a,t[11]=T):T=t[11];let E;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,$.jsx)(ue,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[12]=E):E=t[12];let D;t[13]!==l||t[14]!==o?(D=(0,$.jsxs)(He,{className:g,onSelect:o,children:[E,l]}),t[13]=l,t[14]=o,t[15]=D):D=t[15];let O;t[16]!==T||t[17]!==D?(O=(0,$.jsx)(Ae,{children:(0,$.jsxs)(Le,{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:[T,D]})}),t[16]=T,t[17]=D,t[18]=O):O=t[18];let k;t[19]!==O||t[20]!==C?(k=(0,$.jsxs)(Ce,{children:[C,O]}),t[19]=O,t[20]=C,t[21]=k):k=t[21];let A;t[22]===f?A=t[23]:(A=(0,$.jsx)(Qe,{open:f,onOpenChange:m,hideTrigger:!0}),t[22]=f,t[23]=A);let j;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,$.jsx)(p,{className:`size-4`,"aria-hidden":!0}),t[24]=j):j=t[24];let M;t[25]===d?M=t[26]:(M=(0,$.jsx)(Ge,{asChild:!0,children:(0,$.jsx)(F,{type:`button`,variant:`secondary`,className:`size-9 shrink-0 p-0`,"aria-label":d,title:d,children:j})}),t[25]=d,t[26]=M);let N;t[27]!==n||t[28]!==i||t[29]!==r?(N=n?(0,$.jsxs)(He,{className:g,disabled:r,onSelect:n,children:[r?(0,$.jsx)(_,{className:`size-4 animate-spin text-fg-muted`,"aria-hidden":!0}):(0,$.jsx)(Pe,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),i]}):null,t[27]=n,t[28]=i,t[29]=r,t[30]=N):N=t[30];let P,L;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(P=()=>m(!0),L=(0,$.jsx)(Ue,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),t[31]=P,t[32]=L):(P=t[31],L=t[32]);let R;t[33]===u?R=t[34]:(R=(0,$.jsxs)(He,{className:g,onSelect:P,children:[L,u]}),t[33]=u,t[34]=R);let z;t[35]!==N||t[36]!==R?(z=(0,$.jsx)(Ae,{children:(0,$.jsxs)(Le,{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:[N,R]})}),t[35]=N,t[36]=R,t[37]=z):z=t[37];let B;t[38]!==M||t[39]!==z?(B=(0,$.jsxs)(Ce,{children:[M,z]}),t[38]=M,t[39]=z,t[40]=B):B=t[40];let V;return t[41]!==k||t[42]!==A||t[43]!==B?(V=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center justify-end gap-2`,children:[k,A,B]}),t[41]=k,t[42]=A,t[43]=B,t[44]=V):V=t[44],V});function Ct(e=``,t=``){return{clientKey:crypto.randomUUID(),key:e,value:t}}var wt=/^([^:=]+)[:=](.*)$/;function Tt(e){let t=e.trim();if(!t)return null;try{let e=JSON.parse(t);if(e&&typeof e==`object`&&!Array.isArray(e))return Dt(e)}catch{}let n=[];for(let e of t.split(/\r?\n/)){let t=e.trim();if(!t)continue;let r=wt.exec(t);r&&n.push(Ct(r[1].trim(),r[2].trim()))}return n.length>0?n:null}function Et(e){let t=Object.create(null);for(let n of e){let e=n.key.trim();e&&(t[e]=n.reference??n.value)}return Object.keys(t).length>0?t:void 0}function Dt(e){if(!e||typeof e!=`object`)return[Ct()];let t=Object.entries(e).map(([e,t])=>typeof t==`object`&&t&&!Array.isArray(t)?{...Ct(e),reference:t}:Ct(e,t==null?``:String(t)));return t.length>0?t:[Ct()]}function Ot(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e.xopcConnector;return!!(t&&typeof t==`object`&&!Array.isArray(t)&&t.managed===!0)}function kt(e){let t=e.trim();if(!t)return;if(t.startsWith(`[`)){let e=JSON.parse(t);if(!Array.isArray(e)||e.some(e=>typeof e!=`string`))throw Error(`Command arguments must be a JSON array of strings.`);return e}let n=[],r=``,i=``,a=!1;for(let e=0;e<t.length;e++){let o=t[e];o===`\\`&&t[e+1]&&i!==`'`&&/[\s"'\\]/.test(t[e+1])?(r+=t[++e],a=!0):i?o===i?i=``:r+=o:o===`"`||o===`'`?(i=o,a=!0):/\s/.test(o)?a&&=(n.push(r),r=``,!1):(r+=o,a=!0)}if(i)throw Error(`Command arguments contain an unclosed quote.`);return a&&n.push(r),n}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){let t={...e.extra,exposure:e.exposure};if(e.displayName?.trim()?t.displayName=e.displayName.trim():delete t.displayName,delete t.command,delete t.args,delete t.env,delete t.cwd,delete t.url,delete t.headers,delete t.type,e.transport===`stdio`){t.type=`stdio`,t.command=e.command.trim();let n=kt(e.argsText);if(n&&(t.args=n),e.cwd.trim()&&(t.cwd=e.cwd.trim()),e.envEntries){let n=new Set;for(let t of e.envEntries)if(!(!t.key.trim()&&!t.value&&!t.reference)){if(!t.key.trim()||n.has(t.key.trim()))throw Error(`Environment variable names must be non-empty and unique.`);n.add(t.key.trim())}let r=Et(e.envEntries);r&&(t.env=r)}else e.envJson.trim()&&(t.env=At(e.envJson));delete t.oauth,delete t.auth}else{t.type=`http`,t.url=e.url.trim();let n=Et(e.headers);n&&(t.headers=n);let r={...t.oauth??{}};e.oauthClientId.trim()?r.clientId=e.oauthClientId.trim():delete r.clientId,Object.keys(r).length?t.oauth=r:delete t.oauth}return e.timeout===void 0?delete t.timeout:t.timeout=e.timeout,t}function Mt(e,t){let n=t.oauth;return{clientKey:e,id:e,displayName:typeof t.displayName==`string`?t.displayName:``,transport:typeof t.url==`string`?`streamable-http`:`stdio`,command:typeof t.command==`string`?t.command:``,argsText:Array.isArray(t.args)?JSON.stringify(t.args):``,envJson:t.env?JSON.stringify(t.env,null,2):``,cwd:typeof t.cwd==`string`?t.cwd:``,url:typeof t.url==`string`?t.url:``,headers:Dt(t.headers),oauthClientId:typeof n?.clientId==`string`?n.clientId:``,timeout:typeof t.timeout==`number`?t.timeout:void 0,exposure:t.exposure??`codemode`,extra:t}}function Nt(e,t){let n=`mcp`;try{n=e.transport===`streamable-http`?new URL(e.url).hostname:e.command.split(/[\\/]/).pop()||n}catch{}let r=n.replace(/[^a-zA-Z0-9_-]+/g,`_`).replace(/^_+|_+$/g,``)||`mcp`,i=new Set([...t].map(e=>e.replace(/-/g,`_`))),a=r;for(let e=2;i.has(a.replace(/-/g,`_`));e++)a=`${r}_${e}`;return a}function Pt(e){let t=e.trim(),n=new URL(/^[a-z][a-z\d+.-]*:/i.test(t)&&!/^[^/]+:\d+(?:[/?#]|$)/.test(t)?t:`${/^(localhost|127\.0\.0\.1)(:|\/|$)/i.test(t)?`http`:`https`}://${t}`);if(![`http:`,`https:`].includes(n.protocol)||n.username||n.password)throw Error(`Use an HTTP or HTTPS MCP address without embedded credentials.`);return n.href}function Ft(e){let t=JSON.parse(e);if(!t||typeof t!=`object`||Array.isArray(t))throw Error(`Expected a JSON object.`);let n=t.mcpServers??t.mcp?.servers??t.servers;if(n!==void 0&&(!n||typeof n!=`object`||Array.isArray(n)))throw Error(`Expected a server configuration object.`);let r=n?Object.entries(n):[[``,t]];if(!r.length)throw Error(`No MCP servers found.`);return r.map(([e,t])=>{if(!t||typeof t!=`object`||Array.isArray(t))throw Error(`Invalid MCP server configuration.`);let n=t;if(typeof n.url!=`string`&&typeof n.command!=`string`)throw Error(`The configuration needs an MCP URL or command.`);if(n.args!==void 0&&(!Array.isArray(n.args)||n.args.some(e=>typeof e!=`string`)))throw Error(`Command arguments must be strings.`);let r=Mt(e,n);return r.clientKey=crypto.randomUUID(),r.url&&=Pt(r.url),r})}function It(e=``){return{clientKey:crypto.randomUUID(),id:e,transport:`streamable-http`,command:``,argsText:``,envJson:``,cwd:``,url:``,headers:[],oauthClientId:``,timeout:void 0,exposure:`codemode`,extra:{}}}function Lt(e){let t=e?.mcp?.servers??{};return{servers:Object.entries(t).filter(([,e])=>!Ot(e)).map(([e,t])=>Mt(e,t)).sort((e,t)=>e.id.localeCompare(t.id))}}function Rt(e){return jt(e)}async function zt(e,t){return(await S(T(`/api/mcp/servers/${encodeURIComponent(e)}/tools`),{method:`POST`,signal:AbortSignal.any([t,AbortSignal.timeout(95e3)])})).payload.tools}async function Bt(e,t,n,r){return(await S(T(`/api/mcp/drafts`),{method:`POST`,signal:r,body:JSON.stringify({serverId:e.id,sourceServerId:t,expectedServer:n,server:jt(e)})})).payload}async function Vt(e,t){return(await S(T(`/api/mcp/drafts/${encodeURIComponent(e)}/probe`),{method:`POST`,signal:AbortSignal.any([t,AbortSignal.timeout(95e3)])})).payload}async function Ht(e){await S(T(`/api/mcp/drafts/${encodeURIComponent(e)}`),{method:`DELETE`})}async function Ut(e,t=!1){let n=await S(T(`/api/mcp/drafts/${encodeURIComponent(e)}/commit`),{method:`POST`,body:JSON.stringify({enable:t})});return L(),n.payload}async function Wt(e){return(await S(T(`/api/mcp/drafts/${encodeURIComponent(e)}/auth`),{method:`POST`})).payload}async function Gt(e,t){return(await S(T(`/api/mcp/drafts/${encodeURIComponent(e)}/auth`),{signal:t})).payload}async function Kt(e){await S(T(`/api/mcp/drafts/${encodeURIComponent(e)}/auth`),{method:`DELETE`})}async function qt(e,t){await S(T(`/api/mcp/drafts/${encodeURIComponent(e)}/auth/redirect`),{method:`POST`,body:JSON.stringify({url:t})})}async function Jt(e,t){return(await S(T(`/api/mcp/drafts/${encodeURIComponent(e)}/tools`),{signal:t})).payload.tools}async function Yt(e){let t=await S(T(`/api/mcp/servers`),{signal:e});return Object.fromEntries(t.payload.servers.filter(e=>e.lastCheck&&Number.isFinite(Date.parse(e.lastCheck.checkedAt))).map(e=>[e.id,e.lastCheck]))}async function Xt(e){let t=await S(T(`/api/mcp/servers/${encodeURIComponent(e.id)}`),{method:`DELETE`,body:JSON.stringify({expectedServer:e.extra})});return L(),t.payload}function Zt(e){let t=(0,nt.c)(90),{serverId:n,draftId:r,t:i,onClose:a,onConfigure:o}=e,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=[],t[0]=s):s=t[0];let[c,l]=(0,Q.useState)(s),[u,d]=(0,Q.useState)(!0),[f,p]=(0,Q.useState)(``),[m,h]=(0,Q.useState)(``),[g,_]=(0,Q.useState)(0),v;t[1]!==r||t[2]!==n?(v=()=>{let e=new AbortController,t=!0;return d(!0),p(``),l([]),(r?Jt(r,e.signal):zt(n,e.signal)).then(e=>{t&&l(e)}).catch(e=>{t&&p(e instanceof Error?e.message:String(e))}).finally(()=>{t&&d(!1)}),()=>{t=!1,e.abort()}},t[1]=r,t[2]=n,t[3]=v):v=t[3];let y;t[4]!==r||t[5]!==g||t[6]!==n?(y=[n,r,g],t[4]=r,t[5]=g,t[6]=n,t[7]=y):y=t[7],(0,Q.useEffect)(v,y);let b,x,S,C,w,T,N,P,I,L,R,z;if(t[8]!==f||t[9]!==u||t[10]!==a||t[11]!==o||t[12]!==m||t[13]!==n||t[14]!==i.setupConfigure||t[15]!==i.toolParameters||t[16]!==i.toolsAuthHint||t[17]!==i.toolsDialogSearchEmpty||t[18]!==i.toolsDialogSearchPlaceholder||t[19]!==i.toolsDialogSubtitle||t[20]!==i.toolsDialogTitle||t[21]!==i.toolsEmpty||t[22]!==i.toolsLoading||t[23]!==i.toolsTitle||t[24]!==c){let e=m.trim().toLowerCase(),r=c.filter(t=>`${t.name} ${t.description}`.toLowerCase().includes(e));S=M,w=!0,t[37]===a?T=t[38]:(T=e=>{e||a()},t[37]=a,t[38]=T),x=k,t[39]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,$.jsx)(E,{className:`fixed inset-0 z-[60] bg-scrim`}),t[39]=C):C=t[39],b=A,R=`fixed left-1/2 top-1/2 z-[60] flex h-[min(42rem,calc(100vh-2rem))] w-[min(48rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay`;let s;t[40]===i.toolsDialogTitle?s=t[41]:(s=(0,$.jsx)(j,{className:`font-semibold`,children:i.toolsDialogTitle}),t[40]=i.toolsDialogTitle,t[41]=s);let l;t[42]!==u||t[43]!==n||t[44]!==i.toolsDialogSubtitle||t[45]!==c.length?(l=u?n:i.toolsDialogSubtitle.replace(`{{serverId}}`,n).replace(`{{count}}`,String(c.length)),t[42]=u,t[43]=n,t[44]=i.toolsDialogSubtitle,t[45]=c.length,t[46]=l):l=t[46];let d;t[47]===l?d=t[48]:(d=(0,$.jsx)(D,{className:`mt-1 text-sm text-fg-muted`,children:l}),t[47]=l,t[48]=d);let p;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(p=e=>h(e.target.value),t[49]=p):p=t[49];let g;t[50]!==m||t[51]!==i.toolsDialogSearchPlaceholder?(g=(0,$.jsx)(`input`,{className:`mt-4 w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,value:m,onChange:p,placeholder:i.toolsDialogSearchPlaceholder,"aria-label":i.toolsDialogSearchPlaceholder}),t[50]=m,t[51]=i.toolsDialogSearchPlaceholder,t[52]=g):g=t[52],t[53]!==s||t[54]!==d||t[55]!==g?(z=(0,$.jsxs)(`div`,{className:`shrink-0 border-b border-edge p-5`,children:[s,d,g]}),t[53]=s,t[54]=d,t[55]=g,t[56]=z):z=t[56],N=`min-h-0 flex-1 overflow-y-auto p-5`,P=u,t[57]!==i.toolsTitle||t[58]!==c.length?(I=i.toolsTitle.replace(`{{count}}`,String(c.length)),t[57]=i.toolsTitle,t[58]=c.length,t[59]=I):I=t[59],L=u?(0,$.jsx)(`div`,{role:`status`,"aria-label":i.toolsLoading,className:`space-y-3`,children:[0,1,2].map($t)}):f?(0,$.jsxs)(`div`,{role:`alert`,className:`space-y-3`,children:[(0,$.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-sm text-danger`,children:f}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:i.toolsAuthHint.replace(`{{serverId}}`,n)}),o?(0,$.jsx)(F,{variant:`secondary`,onClick:o,children:i.setupConfigure}):null]}):r.length?(0,$.jsx)(`div`,{className:`space-y-3`,children:r.map(e=>(0,$.jsxs)(`article`,{className:`rounded-lg border border-edge p-4`,children:[(0,$.jsx)(`h3`,{className:`break-all font-mono text-sm font-semibold text-fg`,children:e.name}),e.exposure?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.exposure}):null,e.description?(0,$.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap break-words text-sm text-fg-muted`,children:e.description}):null,(0,$.jsxs)(`details`,{className:`mt-3`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm text-accent-fg`,children:i.toolParameters}),(0,$.jsx)(`pre`,{className:`mt-2 overflow-x-auto rounded-md bg-surface-panel p-3 text-xs text-fg`,children:JSON.stringify(e.inputSchema,null,2)})]})]},e.name))}):(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:c.length?i.toolsDialogSearchEmpty:i.toolsEmpty}),t[8]=f,t[9]=u,t[10]=a,t[11]=o,t[12]=m,t[13]=n,t[14]=i.setupConfigure,t[15]=i.toolParameters,t[16]=i.toolsAuthHint,t[17]=i.toolsDialogSearchEmpty,t[18]=i.toolsDialogSearchPlaceholder,t[19]=i.toolsDialogSubtitle,t[20]=i.toolsDialogTitle,t[21]=i.toolsEmpty,t[22]=i.toolsLoading,t[23]=i.toolsTitle,t[24]=c,t[25]=b,t[26]=x,t[27]=S,t[28]=C,t[29]=w,t[30]=T,t[31]=N,t[32]=P,t[33]=I,t[34]=L,t[35]=R,t[36]=z}else b=t[25],x=t[26],S=t[27],C=t[28],w=t[29],T=t[30],N=t[31],P=t[32],I=t[33],L=t[34],R=t[35],z=t[36];let B;t[60]!==N||t[61]!==P||t[62]!==I||t[63]!==L?(B=(0,$.jsx)(`div`,{className:N,"aria-busy":P,"aria-label":I,children:L}),t[60]=N,t[61]=P,t[62]=I,t[63]=L,t[64]=B):B=t[64];let V;t[65]===Symbol.for(`react.memo_cache_sentinel`)?(V=()=>_(Qt),t[65]=V):V=t[65];let H;t[66]!==u||t[67]!==i.refreshTools?(H=(0,$.jsx)(F,{variant:`secondary`,disabled:u,onClick:V,children:i.refreshTools}),t[66]=u,t[67]=i.refreshTools,t[68]=H):H=t[68];let U;t[69]!==a||t[70]!==i.toolsDialogClose?(U=(0,$.jsx)(O,{asChild:!0,children:(0,$.jsx)(F,{onClick:a,children:i.toolsDialogClose})}),t[69]=a,t[70]=i.toolsDialogClose,t[71]=U):U=t[71];let W;t[72]!==H||t[73]!==U?(W=(0,$.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge p-4`,children:[H,U]}),t[72]=H,t[73]=U,t[74]=W):W=t[74];let G;t[75]!==b||t[76]!==B||t[77]!==W||t[78]!==R||t[79]!==z?(G=(0,$.jsxs)(b,{className:R,children:[z,B,W]}),t[75]=b,t[76]=B,t[77]=W,t[78]=R,t[79]=z,t[80]=G):G=t[80];let K;t[81]!==x||t[82]!==C||t[83]!==G?(K=(0,$.jsxs)(x,{children:[C,G]}),t[81]=x,t[82]=C,t[83]=G,t[84]=K):K=t[84];let q;return t[85]!==S||t[86]!==w||t[87]!==T||t[88]!==K?(q=(0,$.jsx)(S,{open:w,onOpenChange:T,children:K}),t[85]=S,t[86]=w,t[87]=T,t[88]=K,t[89]=q):q=t[89],q}function Qt(e){return e+1}function $t(e){return(0,$.jsx)(B,{className:`h-24 w-full`},e)}function en(e){if(e.transport===`stdio`)return e.command.trim();try{let t=new URL(e.url);return`${t.protocol}//${t.host}${t.pathname}`}catch{return e.url.trim().split(/[?#]/,1)[0].replace(/\/\/[^/]*@/,`//`)}}function tn(e){let t=(0,nt.c)(59),{row:n,lastCheck:r,t:i,cs:a,onEdit:o,onRemove:s}=e,[c,l]=(0,Q.useState)(!1),[u,d]=(0,Q.useState)(!1),[f,p]=(0,Q.useState)(``),m=n.displayName||n.id,h;t[0]===m?h=t[1]:(h=(0,$.jsx)(`h3`,{className:`text-sm font-semibold`,children:m}),t[0]=m,t[1]=h);let g;t[2]===n?g=t[3]:(g=en(n),t[2]=n,t[3]=g);let _;t[4]===g?_=t[5]:(_=(0,$.jsx)(`p`,{className:`mt-2 break-all font-mono text-xs text-fg-muted`,children:g}),t[4]=g,t[5]=_);let v;t[6]!==o||t[7]!==h||t[8]!==_?(v=(0,$.jsxs)(`button`,{className:`block w-full text-left`,onClick:o,children:[h,_]}),t[6]=o,t[7]=h,t[8]=_,t[9]=v):v=t[9];let y;t[10]!==r||t[11]!==n.extra.enabled||t[12]!==i.setupDisabled||t[13]!==i.setupLastCheck||t[14]!==i.setupUnverified?(y=n.extra.enabled===!1?i.setupDisabled:r?i.setupLastCheck.replace(`{{count}}`,String(r.toolCount)):i.setupUnverified,t[10]=r,t[11]=n.extra.enabled,t[12]=i.setupDisabled,t[13]=i.setupLastCheck,t[14]=i.setupUnverified,t[15]=y):y=t[15];let b;t[16]===y?b=t[17]:(b=(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:y}),t[16]=y,t[17]=b);let x;t[18]===r?x=t[19]:(x=r?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:(0,$.jsx)(`time`,{dateTime:r.checkedAt,children:new Intl.DateTimeFormat(void 0,{dateStyle:`short`,timeStyle:`short`}).format(new Date(r.checkedAt))})}):null,t[18]=r,t[19]=x);let S;t[20]===f?S=t[21]:(S=f?(0,$.jsx)(`p`,{className:`text-sm text-danger`,children:f}):null,t[20]=f,t[21]=S);let C=n.extra.enabled===!1,w;t[22]===Symbol.for(`react.memo_cache_sentinel`)?(w=()=>l(!0),t[22]=w):w=t[22];let T;t[23]!==i.viewTools||t[24]!==C?(T=(0,$.jsx)(F,{variant:`secondary`,disabled:C,onClick:w,children:i.viewTools}),t[23]=i.viewTools,t[24]=C,t[25]=T):T=t[25];let E;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(E=()=>d(!0),t[26]=E):E=t[26];let D;t[27]===i.removeServer?D=t[28]:(D=(0,$.jsx)(F,{variant:`ghost`,onClick:E,children:i.removeServer}),t[27]=i.removeServer,t[28]=D);let O;t[29]!==T||t[30]!==D?(O=(0,$.jsxs)(`div`,{className:`mt-2 flex justify-end gap-2`,children:[T,D]}),t[29]=T,t[30]=D,t[31]=O):O=t[31];let k;t[32]!==o||t[33]!==n.id||t[34]!==c||t[35]!==i?(k=c?(0,$.jsx)(Zt,{serverId:n.id,t:i,onClose:()=>l(!1),onConfigure:()=>{l(!1),o()}}):null,t[32]=o,t[33]=n.id,t[34]=c,t[35]=i,t[36]=k):k=t[36];let A;t[37]!==a.removeConfirmTitle||t[38]!==n.displayName||t[39]!==n.id?(A=a.removeConfirmTitle.replace(`{{name}}`,n.displayName||n.id),t[37]=a.removeConfirmTitle,t[38]=n.displayName,t[39]=n.id,t[40]=A):A=t[40];let j;t[41]===Symbol.for(`react.memo_cache_sentinel`)?(j=()=>d(!1),t[41]=j):j=t[41];let M;t[42]===s?M=t[43]:(M=()=>{d(!1),s().catch(e=>p(String(e)))},t[42]=s,t[43]=M);let N;t[44]!==u||t[45]!==a.modalCancel||t[46]!==a.removeConfirmDescription||t[47]!==i.removeServer||t[48]!==A||t[49]!==M?(N=(0,$.jsx)(Me,{open:u,title:A,description:a.removeConfirmDescription,confirmLabel:i.removeServer,cancelLabel:a.modalCancel,destructive:!0,onCancel:j,onConfirm:M}),t[44]=u,t[45]=a.modalCancel,t[46]=a.removeConfirmDescription,t[47]=i.removeServer,t[48]=A,t[49]=M,t[50]=N):N=t[50];let P;return t[51]!==O||t[52]!==k||t[53]!==N||t[54]!==v||t[55]!==b||t[56]!==x||t[57]!==S?(P=(0,$.jsxs)(`div`,{className:`px-4 py-3.5`,children:[v,b,x,S,O,k,N]}),t[51]=O,t[52]=k,t[53]=N,t[54]=v,t[55]=b,t[56]=x,t[57]=S,t[58]=P):P=t[58],P}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?nn(t)-nn(e):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=x(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,z);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,n){return e.status===`connected`?De(n.composioHealthConnected,{count:String(t)}):e.status===`reauthorization_required`?n.composioHealthReconnect:e.status===`disconnected`?n.composioHealthDisconnected:e.errorCode===`missing_credential`?n.composioHealthMissingCredential:e.errorCode===`unauthorized`?n.composioHealthUnauthorized:e.errorCode===`forbidden`?n.composioHealthForbidden:e.errorCode===`network`?n.composioHealthNetwork:e.errorCode===`timeout`?n.composioHealthTimeout:n.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=w(e=>e.language)===`zh`,[a,o]=(0,Q.useState)([]),[l,f]=(0,Q.useState)([]),[p,m]=(0,Q.useState)([]),[h,g]=(0,Q.useState)(null),[v,y]=(0,Q.useState)([]),[b,S]=(0,Q.useState)(null),[C,T]=(0,Q.useState)(null),[E,D]=(0,Q.useState)([]),[O,k]=(0,Q.useState)({}),[A,j]=(0,Q.useState)(`read`),[M,N]=(0,Q.useState)(!1),[P,I]=(0,Q.useState)(null),[L,R]=(0,Q.useState)(!1),[z,H]=(0,Q.useState)(null),[W,G]=(0,Q.useState)(null),[K,q]=(0,Q.useState)(!1),[ee,ne]=(0,Q.useState)(!1),[re,ce]=(0,Q.useState)(!1),le=(0,Q.useRef)(0),ue=(0,Q.useRef)(0),fe=(0,Q.useMemo)(()=>an(a),[a]),X=(0,Q.useCallback)(e=>new Promise((t,n)=>{let r=window.setTimeout(()=>n(Error(i?`连接服务响应超时,请重试。`:`The connection service timed out. Please retry.`)),15e3);e.then(t,n).finally(()=>window.clearTimeout(r))}),[i]),pe=(0,Q.useCallback)(async()=>{if(!r||e.materialized.type!==`composio`||e.materialized.role===`credential`)return;N(!0),I(null);let t=++le.current;try{let e=(await Promise.allSettled([X(ge()).then(e=>{t===le.current&&(o(e.filter(e=>e.toolkit.toLowerCase()===r.toLowerCase())),q(!0))}),X(ae(r)).then(e=>{t===le.current&&j(e)}),X(te(r)).then(e=>{t===le.current&&(g(e.policy),y(e.agents))})])).find(e=>e.status===`rejected`);t===le.current&&e?.status===`rejected`&&I(String(e.reason instanceof Error?e.reason.message:e.reason))}finally{t===le.current&&N(!1)}},[e.materialized,r,X]);(0,Q.useEffect)(()=>(pe(),()=>{le.current++}),[pe]);let he=(0,Q.useCallback)(async()=>{if(!r)return;let e=++ue.current;ce(!0),R(!1);let t=t=>n=>{e===ue.current&&t(n)},n=await Promise.allSettled([X(be(r)).then(t(f)),X(Y(20)).then(t(e=>m(e.filter(e=>!e.toolkit||e.toolkit.toLowerCase()===r.toLowerCase())))),X(ie(r)).then(t(T)),X(me(r)).then(t(S))]);e===ue.current&&(R(n.some(e=>e.status===`rejected`)),ce(!1))},[r,X]);(0,Q.useEffect)(()=>(ee&&he(),()=>{ue.current++}),[ee,he]),(0,Q.useEffect)(()=>{let e=!1,t=an(a).map(e=>e.primary).filter(e=>e.supportsLearning&&e.accountId);if(t.length)return X(U()).then(t=>{e||D(t)}).catch(()=>{}),Promise.allSettled(t.map(async e=>[e.accountId,await X(ve(e.accountId))])).then(t=>{e||k(Object.fromEntries(t.flatMap(e=>e.status===`fulfilled`?[e.value]:[])))}),()=>{e=!0}},[a,X]);let _e=(0,Q.useCallback)(async i=>{if(!r)return;let a=V()?null:window.open(`about:blank`,`_blank`);a&&(a.opener=null),N(!0),I(null);try{if(!V()&&!a)throw Error(`Allow popups to open the authorization page.`);let t=await We(e.connectorId,i);if(!t.authorizationUrl)throw Error(`The authorization provider did not return an authorization URL.`);if(V()){let e=await window.electronAPI?.shell?.openExternalUrl(t.authorizationUrl);if(!e?.ok)throw Error(e?.error??`Could not open the system browser.`)}else a.location.href=t.authorizationUrl;let o=await ke(r,t.connectionId,12e4,t.attemptId);if(i&&o.accountId!==i)throw Error(`A different account was authorized. The original account and its task bindings were not changed.`);await Promise.all([n?.(),pe()])}catch(e){I(se(e,t))}finally{a?.close(),N(!1)}},[e.connectorId,pe,n,t,r]),ye=(0,Q.useCallback)(async t=>{N(!0),I(null);try{await Be(e.instanceId,{config:{...e.config??{},authConfigId:t||void 0}}),await Promise.all([n?.(),pe()])}catch(e){I(e instanceof Error?e.message:String(e))}finally{N(!1)}},[e.config,e.instanceId,pe,n]),xe=async e=>{let t=V()?null:window.open(`about:blank`,`_blank`);t&&(t.opener=null),I(null);try{let n=await de(e.id);if(n.authorizationUrl)if(V())await window.electronAPI?.shell?.openExternalUrl(n.authorizationUrl);else if(t)t.location.href=n.authorizationUrl;else throw Error(`Allow popups to reopen authorization.`);else t?.close(),await pe()}catch(e){t?.close(),I(e instanceof Error?e.message:String(e))}},Ce=(0,Q.useCallback)(async e=>{if(r){j(e),I(null);try{await Se(r,e)}catch(e){I(e instanceof Error?e.message:String(e)),await pe()}}},[pe,r]),Z=(0,Q.useCallback)(async e=>{if(r){I(null);try{g(await Oe(r,e))}catch(e){I(e instanceof Error?e.message:String(e))}}},[r]),Ae=(0,Q.useCallback)(e=>{if(!h)return;let t=h.allowedAgentIds.includes(e);t&&h.allowedAgentIds.length===1||Z({allowedAgentIds:t?h.allowedAgentIds.filter(t=>t!==e):[...h.allowedAgentIds,e]})},[Z,h]),je=(0,Q.useCallback)(async e=>{N(!0),I(null);try{await e(),await pe()}catch(e){I(e instanceof Error?e.message:String(e))}finally{N(!1)}},[pe]);if(!r)return null;if(e.materialized.type===`composio`&&e.materialized.role===`credential`)return(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.composioApiKeyStored});let Ne=fe.filter(e=>e.primary.status===`active`).length,Ie=Ne>0?t.composioAddAccount:t.composioConnectAccount,Le=K&&Ne>0,Re=C?.requiresCustomAuthConfig===!0,He=C?.authConfigs.filter(e=>e.status===`ENABLED`&&e.isEnabledForToolRouter)??[];return(0,$.jsxs)(`div`,{className:`space-y-5`,children:[(0,$.jsxs)(`section`,{className:`flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`span`,{className:x(`inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-xs font-medium`,Le?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-amber-500/10 text-amber-700 dark:text-amber-300`),children:[Le?(0,$.jsx)(d,{className:`size-3.5`}):(0,$.jsx)(u,{className:`size-3.5`}),Le?t.connectionReady:K||P?t.connectionNeedsSetup:t.connectionChecking]}),K&&(0,$.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:De(t.composioAccountCount,{count:String(fe.length)})})]}),(0,$.jsxs)(F,{variant:`primary`,className:`shrink-0`,disabled:M,onClick:()=>void _e(),children:[M?(0,$.jsx)(_,{className:`size-4 animate-spin`}):(0,$.jsx)(Te,{className:`size-4`}),Ie]})]}),P?(0,$.jsxs)(`div`,{role:`alert`,className:`flex flex-wrap items-center justify-between gap-2 rounded-xl border border-danger/20 bg-danger/5 px-3 py-2 text-sm text-danger`,children:[(0,$.jsx)(`p`,{children:P}),(0,$.jsx)(F,{variant:`secondary`,disabled:M,onClick:()=>void pe(),children:t.composioRetry})]}):null,b&&!Le?(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border border-amber-500/25 bg-amber-500/5 p-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsx)(`p`,{className:`text-sm text-amber-800 dark:text-amber-200`,children:ln(b,Ne,t)}),b.recovery===`none`?null:(0,$.jsx)(F,{variant:`secondary`,disabled:M,onClick:()=>void(b.recovery===`retry`?pe():_e()),children:b.recovery===`retry`?t.composioRetry:t.composioReconnectAccount})]}):null,Re&&He.length===0?(0,$.jsx)(`p`,{className:`rounded-xl border border-amber-500/25 bg-amber-500/5 px-4 py-3 text-sm text-amber-800 dark:text-amber-200`,children:t.composioAuthConfigEmpty}):null,h?(0,$.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-base`,children:[(0,$.jsxs)(`div`,{className:`grid gap-3 border-b border-edge-subtle px-4 py-4 sm:grid-cols-[minmax(0,1fr)_15rem] sm:items-start`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.composioAccessTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:A===`read`?t.composioAccessReadHint:A===`admin`?t.composioAccessAdminHint:t.composioAccessWriteHint})]}),(0,$.jsxs)(s,{value:A,onChange:e=>void Ce(e.currentTarget.value),children:[(0,$.jsx)(c,{value:`read`,children:t.composioAccessReadOnly}),(0,$.jsx)(c,{value:`write`,children:t.composioAccessReadWrite}),A===`admin`?(0,$.jsx)(c,{value:`admin`,children:t.composioAccessAdminCurrent}):null]})]}),(0,$.jsxs)(`details`,{children:[(0,$.jsx)(`summary`,{className:`cursor-pointer px-4 py-3 text-sm text-fg-muted`,children:t.composioAdvancedSettings}),(0,$.jsxs)(`div`,{className:`grid gap-3 border-b border-edge-subtle px-4 py-4 sm:grid-cols-[minmax(0,1fr)_15rem] sm:items-center`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.composioConfirmationPolicy}),(0,$.jsxs)(s,{value:h.confirmationPolicy,onChange:e=>void Z({confirmationPolicy:e.currentTarget.value}),children:[(0,$.jsx)(c,{value:`writes`,children:t.composioConfirmWrites}),(0,$.jsx)(c,{value:`always`,children:t.composioConfirmAlways}),h.confirmationPolicy===`never`?(0,$.jsx)(c,{value:`never`,children:t.composioConfirmNever}):null]})]}),(0,$.jsxs)(`div`,{className:`px-4 py-4`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.composioAllowedAgents}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:h.allowedAgentIds.length?t.composioAllowedAgentsSelected:t.composioAllowedAgentsAll}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,$.jsx)(`button`,{type:`button`,className:x(`rounded-full border px-2.5 py-1 text-xs transition-colors`,h.allowedAgentIds.length===0?`border-accent bg-accent/10 text-accent`:`border-edge bg-surface-panel text-fg-muted hover:text-fg`),onClick:()=>void Z({allowedAgentIds:[]}),children:t.composioAllowedAgentsAllOption}),v.map(e=>(0,$.jsx)(`button`,{type:`button`,className:x(`rounded-full border px-2.5 py-1 text-xs transition-colors`,h.allowedAgentIds.includes(e.id)?`border-accent bg-accent/10 text-accent`:`border-edge bg-surface-panel text-fg-muted hover:text-fg`),onClick:()=>Ae(e.id),children:e.name},e.id))]})]}),(0,$.jsxs)(`fieldset`,{className:`space-y-2 border-t border-edge-subtle p-4 text-xs text-fg-muted`,children:[(0,$.jsx)(`legend`,{children:i?`可用账号范围`:`Available accounts`}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:h.selectedAccountIds===null,disabled:M,onChange:e=>void Z({selectedAccountIds:e.currentTarget.checked?null:[]})}),i?`所有账号(包括以后新增)`:`All accounts, including new ones`]}),h.selectedAccountIds!==null&&fe.map(({primary:e})=>e.accountId&&(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,disabled:M,checked:h.selectedAccountIds.includes(e.accountId),onChange:t=>void Z({selectedAccountIds:t.currentTarget.checked?[...h.selectedAccountIds,e.accountId]:h.selectedAccountIds.filter(t=>t!==e.accountId)})}),e.alias??e.accountEmail??e.accountId]},e.accountId)),h.selectedAccountIds?.length===0&&(0,$.jsx)(`p`,{children:i?`未选择账号,Agent 无法使用此应用。`:`No accounts selected. Agents cannot use this app.`})]})]})]}):null,(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.composioConnectedAccounts}),K&&(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:De(t.composioAccountCount,{count:String(fe.length)})})]}),(0,$.jsxs)(F,{variant:`ghost`,className:`h-8 px-2 text-xs`,disabled:M,onClick:()=>void pe(),children:[(0,$.jsx)(Pe,{className:x(`size-3.5`,M&&`animate-spin`)}),t.refresh]})]}),fe.length?(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-xl border border-edge bg-surface-base`,children:fe.map(e=>{let r=e.primary,a=E.find(e=>r.accountId?e.accountId===r.accountId:e.connectionId===r.id),o=r.accountId?O[r.accountId]:void 0;return(0,$.jsxs)(`article`,{className:`px-4 py-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col items-start justify-between gap-3 sm:flex-row`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:(0,$.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:r.alias??r.workspace??r.accountEmail??r.username??t.composioUnnamedAuthorization})}),(0,$.jsx)(`p`,{className:`mt-1 break-all text-xs text-fg-muted`,children:r.accountEmail??r.username??r.workspace??r.accountId}),r.backendLabel&&(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:r.backendLabel}),(0,$.jsx)(`p`,{className:x(`mt-1 text-xs`,r.status===`active`?`text-emerald-700 dark:text-emerald-300`:`text-amber-700 dark:text-amber-300`),children:r.accountEnabled===!1?i?`已暂停`:`Paused`:un(r.status,t)}),a?(0,$.jsx)(`p`,{className:x(`mt-1 text-xs`,a.status===`failed`?`text-red-600`:`text-fg-subtle`),children:De(t.connectorLearningStatus,{status:dn(a,o,t),count:String(a.candidatesCreated)})}):null]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:[r.status===`pending`&&(0,$.jsx)(F,{variant:`secondary`,className:`h-8 px-2.5 text-xs`,onClick:()=>void xe(r),children:i?`继续授权`:`Continue authorization`}),r.accountId&&(0,$.jsx)(F,{variant:`ghost`,className:`h-8 px-2.5 text-xs text-danger`,disabled:M,onClick:()=>G(r.accountId),children:i?`断开`:`Disconnect`}),r.accountId&&r.status!==`active`&&(0,$.jsx)(F,{variant:`secondary`,className:`h-8 px-2.5 text-xs`,disabled:M,onClick:()=>void _e(r.accountId),children:t.composioReconnectAccount}),r.accountId&&(0,$.jsx)(F,{variant:`secondary`,className:`h-8 px-2.5 text-xs`,disabled:M,onClick:()=>void je(()=>Je(r.accountId,{enabled:r.accountEnabled===!1})),children:r.accountEnabled===!1?i?`启用`:`Enable`:i?`暂停`:`Pause`}),r.supportsLearning&&r.status===`active`&&r.accountEnabled!==!1?(0,$.jsxs)(F,{variant:`secondary`,className:`h-8 shrink-0 px-2.5 text-xs`,disabled:M,onClick:()=>void je(async()=>{if(!r.accountId)throw Error(`Connector account is unavailable.`);await ze(r.accountId),await n?.()}),children:[(0,$.jsx)(Pe,{className:`size-3.5`}),t.composioSyncNow]}):null]})]}),(0,$.jsxs)(`details`,{className:`mt-3 text-xs text-fg-muted`,children:[(0,$.jsx)(`summary`,{className:`w-fit cursor-pointer font-medium hover:text-fg`,children:t.composioAccountSettings}),(0,$.jsxs)(`div`,{className:`mt-3 space-y-4 rounded-lg bg-surface-panel p-3`,children:[r.accountId&&(0,$.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,$.jsx)(`legend`,{className:`mb-2 font-medium`,children:t.composioAllowedAgents}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,disabled:M,checked:r.allowedAgentIds==null,onChange:e=>void je(()=>Je(r.accountId,{allowedAgentIds:e.currentTarget.checked?null:[]}))}),t.composioAllowedAgentsAllOption]}),r.allowedAgentIds!=null&&v.map(e=>(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,disabled:M,checked:r.allowedAgentIds.includes(e.id),onChange:t=>{let n=t.currentTarget.checked;je(()=>Je(r.accountId,{allowedAgentIds:n?[...r.allowedAgentIds,e.id]:r.allowedAgentIds.filter(t=>t!==e.id)}))}}),e.name]},e.id)),r.allowedAgentIds?.length===0&&(0,$.jsx)(`p`,{children:i?`未选择 Agent:任何 Agent 都不能使用此账号。`:`No agents selected: this account is unavailable to all agents.`})]}),r.supportsLearning&&o?(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:o.scanEnabled,disabled:M,onChange:e=>void je(()=>Fe(r.accountId,{scanEnabled:e.currentTarget.checked}))}),t.connectorScheduledScan]}),o.scanEnabled?(0,$.jsxs)(`label`,{className:`sm:col-span-2`,children:[t.connectorScanInterval,(0,$.jsxs)(s,{className:`mt-1`,value:String(o.intervalMinutes??30),disabled:M,onChange:e=>void je(()=>Fe(r.accountId,{intervalMinutes:Number(e.currentTarget.value)})),children:[(0,$.jsxs)(c,{value:`5`,children:[`5 `,t.connectorMinutes]}),(0,$.jsxs)(c,{value:`15`,children:[`15 `,t.connectorMinutes]}),(0,$.jsxs)(c,{value:`30`,children:[`30 `,t.connectorMinutes]}),(0,$.jsxs)(c,{value:`60`,children:[`60 `,t.connectorMinutes]})]})]}):null]}):null,(0,$.jsxs)(`label`,{className:`block`,children:[t.composioAccountAlias,(0,$.jsx)(`input`,{className:x(on,`mt-1 h-8 py-1 text-xs`),defaultValue:r.alias??``,onBlur:e=>{e.currentTarget.value!==(r.alias??``)&&je(()=>we(r.id,{alias:e.currentTarget.value}))}})]}),(0,$.jsx)(`div`,{className:`space-y-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 text-fg-subtle`,children:[t.composioAuthorizationId,`: `,e.providerConnectionId]}),(0,$.jsx)(F,{variant:`ghost`,className:`size-7 shrink-0 p-0 text-danger`,title:t.composioRevoke,disabled:M,onClick:()=>H(e.id),children:(0,$.jsx)(J,{className:`size-3.5`})})]},e.id))}),(0,$.jsx)(`div`,{className:`flex justify-end gap-1`,children:(0,$.jsx)(F,{variant:`ghost`,className:`size-8 p-0`,title:t.refresh,disabled:M,onClick:()=>void je(()=>Ee(r.id)),children:(0,$.jsx)(Pe,{className:`size-4`})})})]})]})]},e.key)})}):M&&!K?(0,$.jsxs)(`div`,{"aria-busy":`true`,"aria-label":t.connectionChecking,className:`space-y-3`,children:[(0,$.jsx)(B,{className:`h-16 w-full`}),(0,$.jsx)(B,{className:`h-16 w-full`})]}):K?(0,$.jsx)(`div`,{className:`rounded-xl border border-dashed border-edge px-4 py-8 text-center`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.composioConnectionsEmpty})}):null]}),(0,$.jsxs)(`details`,{className:`rounded-xl border border-edge bg-surface-base`,onToggle:e=>ne(e.currentTarget.open),children:[(0,$.jsx)(`summary`,{className:`cursor-pointer px-4 py-3 text-sm font-medium text-fg-muted hover:text-fg`,children:t.composioAdvancedSettings}),(0,$.jsxs)(`div`,{className:`space-y-5 border-t border-edge-subtle px-4 py-4`,children:[re?(0,$.jsx)(B,{"aria-label":t.connectionChecking,className:`h-16 w-full`}):null,L?(0,$.jsxs)(`p`,{className:`rounded-lg bg-amber-500/10 px-3 py-2 text-xs text-amber-800 dark:text-amber-200`,children:[t.composioDiagnosticsUnavailable,(0,$.jsx)(F,{variant:`ghost`,disabled:re,onClick:()=>void he(),children:t.composioRetry})]}):null,C?.mode===`byok`?(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.composioAuthConfigTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:Re?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)(s,{className:`mt-3`,value:typeof e.config?.authConfigId==`string`?e.config.authConfigId:``,disabled:M,onChange:e=>void ye(e.currentTarget.value),children:[Re?null:(0,$.jsx)(c,{value:``,children:t.composioAuthConfigManaged}),Re&&typeof e.config?.authConfigId!=`string`?(0,$.jsx)(c,{value:``,disabled:!0,children:t.composioAuthConfigSelect}):null,He.map(e=>(0,$.jsxs)(c,{value:e.id,children:[e.name,` · `,e.authScheme??`OAuth`]},e.id))]})]}):null,(0,$.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioAgentTools}),(0,$.jsx)(`div`,{className:`space-y-2`,children:l.length?l.slice(0,8).map(e=>(0,$.jsxs)(`div`,{className:`rounded-lg bg-surface-panel px-3 py-2`,children:[(0,$.jsx)(`p`,{className:`truncate font-mono text-xs text-fg`,children:e.slug}),(0,$.jsxs)(`p`,{className:`mt-0.5 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)(`section`,{children:[(0,$.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioRecentTriggers}),(0,$.jsx)(`div`,{className:`space-y-2`,children:p.length?p.slice(0,5).map(e=>(0,$.jsxs)(`div`,{className:`rounded-lg bg-surface-panel px-3 py-2`,children:[(0,$.jsx)(`p`,{className:`truncate text-xs text-fg`,children:e.trigger??e.id}),(0,$.jsx)(`p`,{className:`mt-0.5 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})})]})]})]})]}),(0,$.jsx)(Me,{open:W!==null,title:i?`断开账号`:`Disconnect account`,description:i?`停止此账号的工具使用和学习,并撤销其全部授权。已保存的数据不会删除。`:`Stop tool access and learning for this account and revoke all its authorizations. Saved data will not be deleted.`,confirmLabel:i?`断开`:`Disconnect`,cancelLabel:t.modalCancel,destructive:!0,onConfirm:()=>{let e=W;G(null),e&&je(()=>oe(e))},onCancel:()=>G(null)}),(0,$.jsx)(Me,{open:z!==null,title:t.composioRevoke,description:t.composioRevokeConfirm,confirmLabel:t.composioRevoke,cancelLabel:t.modalCancel,destructive:!0,onConfirm:()=>{let e=z;H(null),e&&je(()=>Ve(e))},onCancel:()=>H(null)})]})}var pn=x(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,z);function mn(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 hn(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 gn({instance:e,definition:t,onClose:n,onChanged:r,t:i}){let[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)(!1),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(null),[h,g]=(0,Q.useState)(()=>mn(t,e)),[v,b]=(0,Q.useState)(null),[S,C]=(0,Q.useState)(!1),[w,T]=(0,Q.useState)(null),N=t?.setup.config??[],P=(e.materialized.type===`mcp`||e.materialized.type===`memorySource`)&&N.length>0&&(t?.setup.secrets??[]).length===0,L=e.materialized.type===`mcp`,R=e.materialized.type===`composio`,z=e.materialized.type===`memorySource`,B=t?H(t,i):null,V=(0,Q.useCallback)(async()=>{C(!0),b(null);try{let t=await Ne(e.instanceId);T(t),t.ok||b(t.error??t.action??i.healthStatusLabels[t.status]),await r()}catch(e){b(e instanceof Error?e.message:String(e))}finally{C(!1)}},[e.instanceId,r,i.healthStatusLabels]),U=(0,Q.useCallback)(async()=>{o(!0),b(null);try{await Ie(e.instanceId),await r(),n()}catch(e){b(e instanceof Error?e.message:String(e)),o(!1)}},[e.instanceId,r,n]),W=(0,Q.useCallback)(async()=>{if(!(!t||!P)){u(!0),b(null);try{let n={};for(let e of t.setup.config??[]){let t=hn(e.type,h[e.key]??``);t!==void 0&&(n[e.key]=t)}await Be(e.instanceId,{config:n}),await r()}catch(e){b(e instanceof Error?e.message:String(e))}finally{u(!1)}}},[h,t,e.instanceId,r,P]),G=(0,Q.useCallback)(async()=>{f(!0),m(null),b(null);try{m((await Z(e.connectorId)).recordIds.length),await r()}catch(e){b(e instanceof Error?e.message:String(e))}finally{f(!1)}},[e.connectorId,r]);return(0,$.jsxs)(M,{open:!0,onOpenChange:e=>{e||n()},children:[(0,$.jsxs)(k,{children:[(0,$.jsx)(E,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(A,{className:x(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,R?`h-[min(100dvh-2rem,36rem)] w-[min(100%-2rem,40rem)]`:`h-[min(100dvh-2rem,44rem)] w-[min(100%-2rem,min(92vw,54rem))]`,`rounded-2xl border border-edge bg-surface-overlay 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)(Re,{connector:t,size:`lg`}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(j,{className:`text-base font-semibold text-fg`,children:e.displayName}),(0,$.jsx)(D,{className:`mt-1 text-sm text-fg-muted`,children:B??(e.materialized.type===`mcp`?De(i.mcpServerRuntime,{serverId:e.materialized.serverId}):De(i.runtimeLabel,{runtime:e.materialized.type}))})]})]}),(0,$.jsx)(O,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,className:x(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,I.focusRingPanel),"aria-label":i.modalClose,children:[(0,$.jsx)(y,{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:[v?(0,$.jsx)(`p`,{className:`mb-4 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:v}):null,L?(0,$.jsxs)(`div`,{className:`space-y-3 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-3`,children:[(0,$.jsx)(`p`,{className:`text-fg-muted`,role:`status`,children:w?.ok?De(i.toolsAvailable,{count:String(w.toolCount)}):w?i.healthStatusLabels[w.status]:e.usage.lastHealthStatus?i.healthStatusLabels[e.usage.lastHealthStatus]:i.healthNotTested}),(0,$.jsxs)(F,{variant:`secondary`,"aria-busy":S,disabled:S||!e.enabled,onClick:()=>void V(),children:[S?(0,$.jsx)(_,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(Pe,{className:`size-4`,"aria-hidden":!0}),i.test]})]}),P?N.map(e=>(0,$.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`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:h[e.key]??``,placeholder:e.placeholder,onChange:t=>g(n=>({...n,[e.key]:t.currentTarget.value}))})]},e.key)):null]}):null,R?(0,$.jsx)(fn,{instance:e,t:i,onChanged:r}):null,z?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 rounded-xl border border-edge bg-surface-base p-4 text-sm`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`font-medium text-fg`,children:i.connectedSourceSync}),B?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:B}):null,p===null?null:(0,$.jsx)(`p`,{className:`mt-1 text-xs text-emerald-600`,children:De(i.connectedSourceSynced,{count:String(p)})})]}),(0,$.jsxs)(F,{disabled:d,onClick:()=>void G(),children:[d?(0,$.jsx)(_,{className:`size-4 animate-spin`}):(0,$.jsx)(q,{className:`size-4`}),i.composioSyncNow]})]}),P?(0,$.jsx)(`div`,{className:`grid gap-3 rounded-xl border border-edge bg-surface-base p-4`,children:N.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:h[e.key]??``,placeholder:e.placeholder,onChange:t=>g(n=>({...n,[e.key]:t.currentTarget.value}))})]},e.key))}):null]}):null,!L&&!R&&!z?(0,$.jsx)(`div`,{className:`rounded-xl border border-edge bg-surface-base p-4 text-sm text-fg-muted`,children:(0,$.jsx)(`p`,{children:i.connectorPolicyHint})}):null,(0,$.jsxs)(`details`,{className:`mt-5 rounded-xl border border-edge`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer px-4 py-3 text-sm font-medium text-fg-muted hover:text-danger`,children:i.dangerZone}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 border-t border-danger/15 px-4 py-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsx)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:i.removeConnectorHint}),(0,$.jsxs)(F,{variant:`secondary`,className:`shrink-0 border-danger/30 text-danger hover:bg-danger/10`,disabled:a,onClick:()=>c(!0),children:[a?(0,$.jsx)(_,{className:`size-4 animate-spin`}):(0,$.jsx)(J,{className:`size-4`}),i.remove]})]})]})]}),(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)(F,{variant:`secondary`,onClick:n,children:i.modalClose}),(L||z)&&P?(0,$.jsxs)(F,{variant:`primary`,disabled:l,onClick:()=>void W(),children:[l?(0,$.jsx)(_,{className:`size-4 animate-spin`}):(0,$.jsx)(Ke,{className:`size-4`}),i.modalSave]}):null]})]})]}),(0,$.jsx)(Me,{open:s,title:De(i.removeConfirmTitle,{name:e.displayName}),description:i.removeConfirmDescription,confirmLabel:i.removeConfirmAction,cancelLabel:i.modalCancel,destructive:!0,onConfirm:()=>{c(!1),U()},onCancel:()=>{a||c(!1)}})]})}function _n(e){let t=(0,nt.c)(2),n;return t[0]===e?n=t[1]:(n=e.instance.materialized.type===`cli`&&e.definition?(0,$.jsx)(qe,{definition:e.definition,instance:e.instance,onClose:e.onClose,onChanged:e.onChanged}):(0,$.jsx)(gn,{...e}),t[0]=e,t[1]=n),n}function vn(e){let t=(0,nt.c)(55),{instance:n,definition:r,highlighted:i,onOpenDetails:a,t:s}=e,c=i===void 0?!1:i,l;t[0]!==r||t[1]!==n?(l=mt(n,r),t[0]=r,t[1]=n,t[2]=l):l=t[2];let p=l.state,m;t[3]!==r||t[4]!==s?(m=r?H(r,s):null,t[3]=r,t[4]=s,t[5]=m):m=t[5];let h=m,g,_,v,y,b,S,C,w,T;if(t[6]!==p||t[7]!==r||t[8]!==c||t[9]!==n||t[10]!==a||t[11]!==s.connectionChecking||t[12]!==s.connectionNeedsSetup||t[13]!==s.connectionReady){g=p===`ready`?{label:s.connectionReady,Icon:d,className:`text-emerald-700 dark:text-emerald-300`}:p===`needs_setup`?{label:s.connectionNeedsSetup,Icon:u,className:`text-amber-700 dark:text-amber-300`}:{label:s.connectionChecking,Icon:f,className:`text-fg-muted`},w=`button`;let e=c&&`bg-accent-soft`;t[23]===e?T=t[24]:(T=x(`flex w-full items-center gap-3 px-4 py-3.5 text-left hover:bg-surface-hover/60`,`rounded-none first:rounded-t-[calc(var(--radius-xl)-1px)] last:rounded-b-[calc(var(--radius-xl)-1px)]`,I.transition,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,e),t[23]=e,t[24]=T),t[25]!==n||t[26]!==a?(_=()=>a(n),t[25]=n,t[26]=a,t[27]=_):_=t[27],t[28]===r?v=t[29]:(v=(0,$.jsx)(Re,{connector:r}),t[28]=r,t[29]=v),C=`min-w-0 flex-1`,b=`flex min-w-0 items-center gap-2`,t[30]===n.displayName?S=t[31]:(S=(0,$.jsx)(`h3`,{className:`truncate text-sm font-medium text-fg`,children:n.displayName}),t[30]=n.displayName,t[31]=S),y=x(`inline-flex shrink-0 items-center gap-1 text-xs font-medium`,g.className),t[6]=p,t[7]=r,t[8]=c,t[9]=n,t[10]=a,t[11]=s.connectionChecking,t[12]=s.connectionNeedsSetup,t[13]=s.connectionReady,t[14]=g,t[15]=_,t[16]=v,t[17]=y,t[18]=b,t[19]=S,t[20]=C,t[21]=w,t[22]=T}else g=t[14],_=t[15],v=t[16],y=t[17],b=t[18],S=t[19],C=t[20],w=t[21],T=t[22];let E;t[32]===g.Icon?E=t[33]:(E=(0,$.jsx)(g.Icon,{className:`size-3.5`,"aria-hidden":!0}),t[32]=g.Icon,t[33]=E);let D;t[34]!==g.label||t[35]!==E||t[36]!==y?(D=(0,$.jsxs)(`span`,{className:y,children:[E,g.label]}),t[34]=g.label,t[35]=E,t[36]=y,t[37]=D):D=t[37];let O;t[38]!==D||t[39]!==b||t[40]!==S?(O=(0,$.jsxs)(`div`,{className:b,children:[S,D]}),t[38]=D,t[39]=b,t[40]=S,t[41]=O):O=t[41];let k;t[42]===h?k=t[43]:(k=h?(0,$.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted`,children:h}):null,t[42]=h,t[43]=k);let A;t[44]!==O||t[45]!==k||t[46]!==C?(A=(0,$.jsxs)(`div`,{className:C,children:[O,k]}),t[44]=O,t[45]=k,t[46]=C,t[47]=A):A=t[47];let j;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,$.jsx)(o,{className:`size-4 shrink-0 text-fg-disabled`,"aria-hidden":!0}),t[48]=j):j=t[48];let M;return t[49]!==_||t[50]!==v||t[51]!==A||t[52]!==w||t[53]!==T?(M=(0,$.jsxs)(`button`,{type:w,className:T,onClick:_,children:[v,A,j]}),t[49]=_,t[50]=v,t[51]=A,t[52]=w,t[53]=T,t[54]=M):M=t[54],M}function yn(e,t){return It()}function bn(e){let t=e.headers.filter(e=>e.key.trim()),n=t.find(e=>e.key.toLowerCase()===`authorization`&&!e.reference&&/^Bearer\s/i.test(e.value)),r=e.extra.auth||t.some(e=>e.reference)||e.extra.oauth&&t.some(e=>e.key.toLowerCase()===`authorization`)?`existing`:e.extra.oauth?`oauth`:n?`bearer`:t.length?`headers`:`auto`;return{mode:r,token:n?.value.replace(/^Bearer\s+/i,``)??``,apiKey:``,headerName:``,customHeaders:t.length?t:[Ct()],additionalHeaders:r===`bearer`?t.filter(e=>e!==n):r===`oauth`?t:[]}}function xn(e,t){if(e.transport===`stdio`||t.mode===`existing`)return{...e,extra:{...e.extra}};let n={...e.extra};delete n.auth,t.mode!==`oauth`&&delete n.oauth;let r=t.mode===`headers`?t.customHeaders:t.additionalHeaders;if(t.mode===`bearer`){let e=t.token.trim().replace(/^Bearer\s+/i,``);r=[...r,Ct(`Authorization`,`Bearer ${e}`)]}return t.mode===`apiKey`&&(r=[...r,Ct(t.headerName.trim(),t.apiKey.trim())]),{...e,extra:n,headers:r,oauthClientId:t.mode===`oauth`?e.oauthClientId:``}}function Sn(e){let t=new Set;return e.findIndex(e=>{let n=e.key.trim();if(!n&&!e.value&&!e.reference)return!1;if(!/^[!#$%&'*+.^_`|~\da-z-]+$/i.test(n)||/[\r\n]/.test(e.value))return!0;let r=n.toLowerCase();return t.has(r)?!0:(t.add(r),!1)})}function Cn(){return x(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,z)}function wn({label:e,optionalLabel:t,addLabel:n,removeHeaderAria:r,pasteLabel:i,pasteFailed:a,pasteFailedTitle:o,dismissLabel:s,keyPlaceholder:c,valuePlaceholder:l,headers:u,onChange:d,referenceLabel:f=`Existing credential reference`,showValueLabel:p=`Show value`,hideValueLabel:m=`Hide value`,allowPaste:_=!0}){let[v,y]=(0,Q.useState)(new Set),[b,S]=(0,Q.useState)(!1),C=(e,t)=>{d(u.map((n,r)=>r===e?{...n,...t}:n))},w=()=>{d([...u,Ct()])},T=e=>{let t=u.filter((t,n)=>n!==e);d(t.length>0?t:[Ct()])},E=async()=>{try{let e=await P();if(!e){S(!0);return}let t=Tt(e);if(!t?.length){S(!0);return}d(t)}catch{S(!0)}};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)(F,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5 px-2 text-xs`,onClick:()=>void E(),children:[(0,$.jsx)(re,{className:`size-3.5`,"aria-hidden":!0}),i]}):null]}),(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:u.map((e,t)=>(0,$.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[minmax(0,1fr)_auto_auto] items-center gap-2 sm:grid-cols-[minmax(0,1fr)_minmax(0,1.4fr)_auto_auto]`,children:[(0,$.jsx)(`input`,{className:x(Cn(),`col-span-3 min-w-0 font-mono text-xs sm:col-span-1`),"aria-label":`${c} ${t+1}`,value:e.key,placeholder:c,onChange:e=>C(t,{key:e.target.value})}),(0,$.jsx)(`input`,{className:x(Cn(),`min-w-0 font-mono text-xs`),type:v.has(e.clientKey)?`text`:`password`,autoComplete:`off`,"aria-label":`${l} ${t+1}`,readOnly:!!e.reference,value:e.reference?f:e.value,placeholder:e.reference?f:l,onChange:e=>C(t,{value:e.target.value})}),(0,$.jsx)(F,{type:`button`,variant:`ghost`,className:`size-10 shrink-0 px-0`,disabled:!!e.reference,"aria-label":v.has(e.clientKey)?m:p,onClick:()=>y(t=>{let n=new Set(t);return n.has(e.clientKey)?n.delete(e.clientKey):n.add(e.clientKey),n}),children:v.has(e.clientKey)?(0,$.jsx)(h,{className:`size-4`,"aria-hidden":!0}):(0,$.jsx)(g,{className:`size-4`,"aria-hidden":!0})}),(0,$.jsx)(F,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 px-0`,disabled:u.length<=1&&!e.key&&!e.value,onClick:()=>T(t),"aria-label":r,children:(0,$.jsx)(J,{className:`size-4 text-fg-subtle`,"aria-hidden":!0})}),e.reference?(0,$.jsx)(`p`,{className:`col-span-3 break-words text-xs text-fg-muted sm:col-span-4`,children:f}):null]},e.clientKey))}),(0,$.jsx)(Me,{open:b,title:o,description:a,confirmLabel:s,onConfirm:()=>S(!1),onCancel:()=>S(!1)}),(0,$.jsxs)(`button`,{type:`button`,className:x(`self-start text-sm text-accent hover:underline`,I.press),onClick:w,children:[`+ `,n]})]})}var Tn=x(`w-full min-w-0 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,z);function En(e){let t=(0,nt.c)(20),{value:n,onChange:r,label:i,t:a,required:o}=e,s=o===void 0?!1:o,[c,l]=(0,Q.useState)(!1),u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=x(Tn,`mt-1.5`),t[0]=u):u=t[0];let d=c?`text`:`password`,f;t[1]===r?f=t[2]:(f=e=>r(e.target.value),t[1]=r,t[2]=f);let p;t[3]!==s||t[4]!==d||t[5]!==f||t[6]!==n?(p=(0,$.jsx)(`input`,{className:u,type:d,value:n,required:s,autoComplete:`off`,onChange:f}),t[3]=s,t[4]=d,t[5]=f,t[6]=n,t[7]=p):p=t[7];let m;t[8]!==i||t[9]!==p?(m=(0,$.jsxs)(`label`,{className:`block text-sm font-medium text-fg`,children:[i,p]}),t[8]=i,t[9]=p,t[10]=m):m=t[10];let _;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(_=()=>l(Dn),t[11]=_):_=t[11];let v;t[12]===c?v=t[13]:(v=c?(0,$.jsx)(h,{className:`size-4`,"aria-hidden":!0}):(0,$.jsx)(g,{className:`size-4`,"aria-hidden":!0}),t[12]=c,t[13]=v);let y=c?a.setupHideValue:a.setupShowValue,b;t[14]!==v||t[15]!==y?(b=(0,$.jsxs)(F,{type:`button`,variant:`ghost`,className:`gap-1.5 text-xs`,onClick:_,children:[v,y]}),t[14]=v,t[15]=y,t[16]=b):b=t[16];let S;return t[17]!==b||t[18]!==m?(S=(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[m,b]}),t[17]=b,t[18]=m,t[19]=S):S=t[19],S}function Dn(e){return!e}function On(e){let t=(0,nt.c)(17),{headers:n,onChange:r,t:i,additional:a,environment:o}=e,s=a===void 0?!1:a,c=o===void 0?!1:o,l=c?i.envLabel:s?i.setupAdditionalHeaders:i.headersLabel,u=c?i.setupAddEnv:i.addHeader,d=c?i.setupRemoveEnv:i.removeHeader,f=c?i.setupEnvName:i.headerKeyPlaceholder,p=c?i.setupEnvValue:i.headerValuePlaceholder,m=!c,h;return t[0]!==n||t[1]!==r||t[2]!==i.optionalSuffix||t[3]!==i.pasteHeaders||t[4]!==i.pasteHeadersDismiss||t[5]!==i.pasteHeadersFailed||t[6]!==i.pasteHeadersFailedTitle||t[7]!==i.setupHideValue||t[8]!==i.setupReference||t[9]!==i.setupShowValue||t[10]!==l||t[11]!==u||t[12]!==d||t[13]!==f||t[14]!==p||t[15]!==m?(h=(0,$.jsx)(wn,{label:l,optionalLabel:i.optionalSuffix,addLabel:u,removeHeaderAria:d,pasteLabel:i.pasteHeaders,pasteFailed:i.pasteHeadersFailed,pasteFailedTitle:i.pasteHeadersFailedTitle,dismissLabel:i.pasteHeadersDismiss,keyPlaceholder:f,valuePlaceholder:p,headers:n,onChange:r,referenceLabel:i.setupReference,showValueLabel:i.setupShowValue,hideValueLabel:i.setupHideValue,allowPaste:m}),t[0]=n,t[1]=r,t[2]=i.optionalSuffix,t[3]=i.pasteHeaders,t[4]=i.pasteHeadersDismiss,t[5]=i.pasteHeadersFailed,t[6]=i.pasteHeadersFailedTitle,t[7]=i.setupHideValue,t[8]=i.setupReference,t[9]=i.setupShowValue,t[10]=l,t[11]=u,t[12]=d,t[13]=f,t[14]=p,t[15]=m,t[16]=h):h=t[16],h}function kn(e){let t=(0,nt.c)(52),{draft:n,onChange:r,t:i,allowExisting:a}=e,o=i.setupAuthLabel,l=i.setupAuthLabel,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=x(Tn,`mt-1.5`),t[0]=u):u=t[0];let d=n.mode,f;t[1]===r?f=t[2]:(f=e=>r({mode:e.target.value}),t[1]=r,t[2]=f);let p;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(p=[`auto`,`oauth`,`bearer`,`apiKey`,`headers`,`none`],t[3]=p):p=t[3];let m;t[4]===i.setupAuthModes?m=t[5]:(m=p.map(e=>(0,$.jsx)(c,{value:e,children:i.setupAuthModes[e]},e)),t[4]=i.setupAuthModes,t[5]=m);let h;t[6]!==a||t[7]!==n.mode||t[8]!==i.setupAuthModes?(h=a||n.mode===`existing`?(0,$.jsx)(c,{value:`existing`,children:i.setupAuthModes.existing}):null,t[6]=a,t[7]=n.mode,t[8]=i.setupAuthModes,t[9]=h):h=t[9];let g;t[10]!==n.mode||t[11]!==i.setupAuthLabel||t[12]!==f||t[13]!==m||t[14]!==h?(g=(0,$.jsxs)(s,{"aria-label":l,className:u,value:d,onChange:f,children:[m,h]}),t[10]=n.mode,t[11]=i.setupAuthLabel,t[12]=f,t[13]=m,t[14]=h,t[15]=g):g=t[15];let _;t[16]!==i.setupAuthLabel||t[17]!==g?(_=(0,$.jsxs)(`label`,{className:`block text-sm font-medium text-fg`,children:[o,g]}),t[16]=i.setupAuthLabel,t[17]=g,t[18]=_):_=t[18];let v;t[19]!==n.mode||t[20]!==i.setupAuthAutoHint?(v=n.mode===`auto`?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.setupAuthAutoHint}):null,t[19]=n.mode,t[20]=i.setupAuthAutoHint,t[21]=v):v=t[21];let y;t[22]!==n.mode||t[23]!==i.setupAuthOAuthHint?(y=n.mode===`oauth`?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.setupAuthOAuthHint}):null,t[22]=n.mode,t[23]=i.setupAuthOAuthHint,t[24]=y):y=t[24];let b;t[25]!==n.mode||t[26]!==i.setupExistingHint?(b=n.mode===`existing`?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.setupExistingHint}):null,t[25]=n.mode,t[26]=i.setupExistingHint,t[27]=b):b=t[27];let S;t[28]!==n.mode||t[29]!==n.token||t[30]!==r||t[31]!==i?(S=n.mode===`bearer`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(En,{value:n.token,onChange:e=>r({token:e}),label:i.setupTokenLabel,t:i,required:!0}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.setupTokenHint})]}):null,t[28]=n.mode,t[29]=n.token,t[30]=r,t[31]=i,t[32]=S):S=t[32];let C;t[33]!==n.apiKey||t[34]!==n.headerName||t[35]!==n.mode||t[36]!==r||t[37]!==i?(C=n.mode===`apiKey`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`label`,{className:`block text-sm font-medium text-fg`,children:[i.setupApiKeyHeader,(0,$.jsx)(`input`,{className:x(Tn,`mt-1.5`),placeholder:`x-api-key`,value:n.headerName,required:!0,onChange:e=>r({headerName:e.target.value})})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.setupApiKeyHint}),(0,$.jsx)(En,{value:n.apiKey,onChange:e=>r({apiKey:e}),label:`API Key`,t:i,required:!0})]}):null,t[33]=n.apiKey,t[34]=n.headerName,t[35]=n.mode,t[36]=r,t[37]=i,t[38]=C):C=t[38];let w;t[39]!==n.customHeaders||t[40]!==n.mode||t[41]!==r||t[42]!==i?(w=n.mode===`headers`?(0,$.jsx)(On,{headers:n.customHeaders,onChange:e=>r({customHeaders:e}),t:i}):null,t[39]=n.customHeaders,t[40]=n.mode,t[41]=r,t[42]=i,t[43]=w):w=t[43];let T;return t[44]!==_||t[45]!==v||t[46]!==y||t[47]!==b||t[48]!==S||t[49]!==C||t[50]!==w?(T=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[_,v,y,b,S,C,w]}),t[44]=_,t[45]=v,t[46]=y,t[47]=b,t[48]=S,t[49]=C,t[50]=w,t[51]=T):T=t[51],T}function An(e){let t=(0,nt.c)(8),{label:n,children:r,hint:i}=e,a;t[0]===n?a=t[1]:(a=(0,$.jsx)(`span`,{children:n}),t[0]=n,t[1]=a);let o;t[2]===i?o=t[3]:(o=i?(0,$.jsx)(`span`,{className:`block text-xs font-normal text-fg-muted`,children:i}):null,t[2]=i,t[3]=o);let s;return t[4]!==r||t[5]!==a||t[6]!==o?(s=(0,$.jsxs)(`label`,{className:`block space-y-1.5 text-sm font-medium text-fg`,children:[a,r,o]}),t[4]=r,t[5]=a,t[6]=o,t[7]=s):s=t[7],s}function jn({row:e,t,onUpdate:n}){let[r,i]=(0,Q.useState)(()=>Dt(e.envJson?JSON.parse(e.envJson):void 0)),[a,o]=(0,Q.useState)(!1),s=[];try{s=kt(e.argsText)??[]}catch{}let c=e=>n({argsText:JSON.stringify(e)});return(0,$.jsxs)(`div`,{"data-field":`commandOptions`,className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.argsLabel}),(0,$.jsx)(F,{type:`button`,variant:`ghost`,onClick:()=>o(e=>!e),children:a?t.setupArgsRows:t.setupArgsPaste})]}),a?(0,$.jsx)(An,{label:t.setupArgsPaste,hint:t.argsHint,children:(0,$.jsx)(`input`,{className:Tn,value:e.argsText,onChange:e=>n({argsText:e.target.value})})}):s.map((e,n)=>(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`input`,{className:Tn,"aria-label":`${t.argsLabel} ${n+1}`,value:e,onChange:e=>c(s.map((t,r)=>r===n?e.target.value:t))}),(0,$.jsx)(F,{type:`button`,variant:`ghost`,"aria-label":t.setupRemoveArg,onClick:()=>c(s.filter((e,t)=>t!==n)),children:(0,$.jsx)(J,{className:`size-4`,"aria-hidden":!0})})]},n)),a?null:(0,$.jsxs)(F,{type:`button`,variant:`ghost`,onClick:()=>c([...s,``]),children:[(0,$.jsx)(v,{className:`size-4`,"aria-hidden":!0}),t.setupAddArg]})]}),(0,$.jsx)(On,{environment:!0,headers:r,t,onChange:e=>{i(e),n({envEntries:e,envJson:JSON.stringify(Et(e)??{})})}})]})}function Mn(e){let t=(0,nt.c)(15),{row:n,t:r,onUpdate:i,variant:a,showOAuth:o,idReadOnly:l}=e,u=a===void 0?`all`:a,d=o===void 0?!1:o,f=l===void 0?!1:l,p=u!==`advanced`,m=u!==`basic`,h;t[0]!==p||t[1]!==i||t[2]!==n||t[3]!==r?(h=p?(0,$.jsxs)($.Fragment,{children:[n.transport===`stdio`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(An,{label:`${r.commandLabel} *`,children:(0,$.jsx)(`input`,{"data-field":`command`,className:Tn,value:n.command,required:!0,onChange:e=>i({command:e.target.value})})}),(0,$.jsx)(jn,{row:n,t:r,onUpdate:i})]}):(0,$.jsx)(An,{label:`${r.urlLabel} *`,children:(0,$.jsx)(`input`,{"data-field":`url`,className:Tn,value:n.url,placeholder:`https://example.com/mcp`,required:!0,onChange:e=>i({url:e.target.value})})}),(0,$.jsx)(An,{label:r.setupNameLabel,hint:r.setupNameHint,children:(0,$.jsx)(`input`,{className:Tn,value:n.displayName??``,placeholder:r.setupNamePlaceholder,onChange:e=>i({displayName:e.target.value})})})]}):null,t[0]=p,t[1]=i,t[2]=n,t[3]=r,t[4]=h):h=t[4];let g;t[5]!==m||t[6]!==f||t[7]!==i||t[8]!==n||t[9]!==d||t[10]!==r?(g=m?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(An,{label:r.serverIdLabel,hint:r.setupIdHint,children:(0,$.jsx)(`input`,{className:Tn,readOnly:f,value:n.id,onChange:e=>i({id:e.target.value}),placeholder:r.serverIdPlaceholder})}),n.transport===`stdio`?(0,$.jsx)(An,{label:r.cwdLabel,children:(0,$.jsx)(`input`,{className:Tn,value:n.cwd,onChange:e=>i({cwd:e.target.value})})}):null,n.transport!==`stdio`&&d?(0,$.jsx)(An,{label:r.oauthClientIdLabel,hint:r.oauthClientIdHint,children:(0,$.jsx)(`input`,{className:Tn,value:n.oauthClientId,onChange:e=>i({oauthClientId:e.target.value})})}):null,(0,$.jsx)(An,{label:r.exposureLabel,hint:r.setupExposureHint,children:(0,$.jsx)(s,{"aria-label":r.exposureLabel,className:Tn,value:n.exposure,onChange:e=>i({exposure:e.target.value}),children:[`codemode`,`deferred`,`direct`,`hidden`].map(e=>(0,$.jsx)(c,{value:e,children:r.exposureLabels[e]},e))})}),(0,$.jsx)(An,{label:r.requestTimeoutLabel,children:(0,$.jsx)(tt,{allowEmpty:!0,type:`number`,min:1,className:Tn,value:n.timeout??``,placeholder:r.setupDefaultTimeout,onChange:e=>i({timeout:e.target.value?Number(e.target.value):void 0})})})]}):null,t[5]=m,t[6]=f,t[7]=i,t[8]=n,t[9]=d,t[10]=r,t[11]=g):g=t[11];let _;return t[12]!==h||t[13]!==g?(_=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[h,g]}),t[12]=h,t[13]=g,t[14]=_):_=t[14],_}function Nn(e,t){let n=e;if(n?.status===429)return t.setupRateLimited;if(n?.status===401)return t.setupGatewayUnauthorized;if(n?.status===404||n?.status===409)return t.setupConflict;if(n?.status&&n.status>=500)return t.setupGatewayCheckFailed;let r={command_missing:t.setupCommandMissing,connection_refused:t.setupConnectionRefused,host_not_found:t.setupHostNotFound,timeout:t.setupTimedOut,access_denied:t.setupAccessDenied,network:t.setupServiceNetworkFailed,tls:t.setupTlsFailed,invalid_response:t.setupInvalidResponse,not_found:t.setupEndpointNotFound,rate_limited:t.setupServiceRateLimited,configuration:t.setupInvalidConfig};if(n?.errorCode&&Object.hasOwn(r,n.errorCode))return r[n.errorCode];let i=e instanceof Error?e.message:typeof e==`string`?e:n?.error??``;return/ENOENT|command not found|executable.{0,30}not found/i.test(i)?t.setupCommandMissing:/ECONNREFUSED|connection refused/i.test(i)?t.setupConnectionRefused:/ENOTFOUND|EAI_AGAIN|could not resolve/i.test(i)?t.setupHostNotFound:/timeout|timed out/i.test(i)?t.setupTimedOut:/fetch failed|failed to fetch|network error|NetworkError/i.test(i)?n?.error===void 0?t.setupGatewayNetworkFailed:t.setupServiceNetworkFailed:/\b(?:401|403)\b|unauthorized|forbidden|permission denied/i.test(i)?t.setupAccessDenied:t.setupCheckFailed}function Pn(e,t){return JSON.stringify({id:e.id,config:Rt(xn(e,t))})}function Fn(e,t){try{return Pn(e,t)}catch{return JSON.stringify({row:e,auth:t})}}function In(e){let{t,cs:n}=e,r=(0,Q.useId)(),[i,a]=(0,Q.useState)(e.initialRow),[o,l]=(0,Q.useState)(()=>bn(e.initialRow)),[u,f]=(0,Q.useState)(`idle`),[p,h]=(0,Q.useState)(``),[g,v]=(0,Q.useState)(!1),[b,S]=(0,Q.useState)(),[C,w]=(0,Q.useState)(),[T,O]=(0,Q.useState)(),[N,P]=(0,Q.useState)(!1),[I,L]=(0,Q.useState)(!1),[R,z]=(0,Q.useState)(``),[B,V]=(0,Q.useState)(``),[H,U]=(0,Q.useState)([]),[W,G]=(0,Q.useState)(`0`),[K,q]=(0,Q.useState)(0),[ee,te]=(0,Q.useState)(``),[ne,re]=(0,Q.useState)(!1),[J,ie]=(0,Q.useState)(!1),ae=e.mode===`edit`,[oe,se]=(0,Q.useState)(``),Y=(0,Q.useRef)(void 0),[ce]=(0,Q.useState)(()=>Fn(e.initialRow,bn(e.initialRow))),le=(0,Q.useRef)(e.mode===`edit`?e.initialRow.id:``),ue=(0,Q.useRef)(void 0),de=(0,Q.useRef)(void 0),fe=(0,Q.useRef)(void 0),X=(0,Q.useRef)(null),pe=(0,Q.useRef)(``),me=(0,Q.useRef)(!0),he=(0,Q.useRef)(null),ge=(0,Q.useRef)(null),_e=(0,Q.useRef)(null),ve=(0,Q.useRef)(e.onSaved);ve.current=e.onSaved;let ye=T?.state===`starting`||T?.state===`authorizing`,be=u!==`idle`||ye,xe=ce!==Fn(i,o),Se=i.extra.enabled===!1,Ce=!g&&(xe||!!R.trim());(0,Q.useEffect)(()=>(me.current=!0,()=>{me.current=!1,ue.current?.abort(),X.current?.close(),Y.current&&Ht(Y.current).catch(()=>{})}),[]),(0,Q.useEffect)(()=>{if(!Ce)return;let e=e=>{e.preventDefault(),e.returnValue=``};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[Ce]),(0,Q.useEffect)(()=>{if(!b)return;let e=ge.current?.querySelector(`[data-field="${b.field}"]`),t=e?.closest(`details`);t&&(t.open=!0);let n=e?.querySelector(`input,button,textarea`)??e;return n?.setAttribute(`aria-invalid`,`true`),n?.setAttribute(`aria-describedby`,r),b.focus!==!1&&(n??_e.current)?.focus(),()=>{n?.removeAttribute(`aria-invalid`),n?.removeAttribute(`aria-describedby`)}},[b,r]),(0,Q.useEffect)(()=>{if(!T||!ye)return;let e=new AbortController;de.current=e;let n;async function r(){try{let n=await Gt(Y.current,e.signal);if(e.signal.aborted||(O(n),n.authorizationUrl&&pe.current!==n.authorizationUrl&&(pe.current=n.authorizationUrl,window.electronAPI?.shell?.openExternalUrl?!(await window.electronAPI.shell.openExternalUrl(n.authorizationUrl)).ok&&!e.signal.aborted&&h(t.oauthOpenFailed):X.current&&!X.current.closed&&X.current.location.replace(n.authorizationUrl)),e.signal.aborted))return;if(n.state===`connected`){fe.current=void 0,X.current?.close(),w({state:`connected`,toolCount:n.toolCount}),h(``);return}if(n.state===`error`||n.state===`cancelled`){fe.current=void 0,X.current?.close(),h(n.state===`cancelled`?t.setupCancelled:t.setupAuthFailed),/client.{0,20}(id|registration)|register|registration/i.test(n.error??``)&&P(!0);return}}catch{if(e.signal.aborted)return;Z(),X.current?.close(),h(t.setupAuthFailed);return}n=setTimeout(()=>void r(),1200)}return r(),()=>{e.abort(),clearTimeout(n)}},[T?.id,ye,t.oauthOpenFailed,t.setupCancelled,t.setupAuthFailed]);function Z(){ue.current?.abort(),de.current?.abort(),Y.current&&Ht(Y.current).catch(()=>{}),Y.current=void 0,se(``),re(!1),w(void 0),O(void 0),h(``),S(void 0)}function we(e){a(t=>({...t,...e})),Z()}function Te(e){l(t=>({...t,...e})),Z()}function Ee(){be||(Ce?ie(!0):e.onClose())}function De(){try{U(Ft(R)),G(`0`),V(``)}catch{V(t.setupImportError),U([])}}function Oe(){let t=H[Number(W)];if(!t)return;let n={...t,id:le.current||t.id,clientKey:e.initialRow.clientKey,extra:{...t.extra,...le.current?{enabled:i.extra.enabled}:{}}};a(n),l(bn(n)),Z(),q(e=>e+1),L(!1),z(``),U([])}function ke(e){function n(e,t){return S({field:e,message:t}),!1}if(e.transport===`streamable-http`){try{e.url=Pt(e.url)}catch{return n(`url`,t.setupAddressInvalid)}if(o.mode===`bearer`&&!o.token.trim().replace(/^Bearer\s*/i,``)||o.mode===`apiKey`&&(!o.apiKey.trim()||!o.headerName.trim()))return n(`auth`,t.setupCredentialRequired);if(Sn(e.headers)>=0)return n(`auth`,t.setupHeaderInvalid);if(o.mode===`oauth`&&e.headers.some(e=>e.key.trim().toLowerCase()===`authorization`))return n(`auth`,t.setupOAuthHeaderConflict);if(o.mode===`headers`&&!e.headers.some(e=>e.key.trim()&&(e.value.trim()||e.reference)))return n(`auth`,t.setupCredentialRequired)}else if(!e.command.trim())return n(`command`,t.setupCommandRequired);if(e.timeout!==void 0&&(!Number.isFinite(e.timeout)||e.timeout<=0))return n(`advanced`,t.setupInvalidConfig);try{Rt(e)}catch(r){return n(e.transport===`stdio`?`commandOptions`:`advanced`,r instanceof Error&&r.message.startsWith(`Environment`)?t.setupEnvInvalid:t.setupInvalidConfig)}return!0}async function Ae(){h(``),f(`checking`),pe.current=``,window.electronAPI?.shell?.openExternalUrl||(X.current=window.open(`about:blank`,`_blank`),X.current&&(X.current.opener=null));try{let e=await Wt(Y.current);if(!me.current){X.current?.close(),Y.current&&Ht(Y.current).catch(()=>{});return}fe.current=e.id,O(e)}catch{X.current?.close(),me.current&&h(t.setupAuthFailed)}finally{me.current&&f(`idle`)}}async function je(){let r=xn(i,o);if(!ke(r))return;let s=e.existingCustomServers.filter(t=>t.clientKey!==e.initialRow.clientKey&&t.id!==le.current),c=new Set([...e.managedServerIds,...s.map(e=>e.id)]);if(r.id=le.current||r.id.trim()||Nt(r,c),!/^[a-zA-Z0-9_-]+$/.test(r.id)||[...c].some(e=>e.replace(/-/g,`_`)===r.id.replace(/-/g,`_`))){S({field:`advanced`,message:n.duplicateServerId});return}Z(),f(`checking`);let l=new AbortController;ue.current=l;try{let n=await Bt(r,le.current||void 0,e.initialRow.extra,l.signal);if(!me.current||l.signal.aborted){Ht(n.id).catch(()=>{});return}Y.current=n.id,a(r),se(Fn(r,o));let i=await Vt(n.id,l.signal);if(!me.current||l.signal.aborted)return;w(i),i.state===`error`&&h(Nn(i,t))}catch(e){me.current&&!l.signal.aborted&&h(e.status===409?t.setupConflict:Nn(e,t))}finally{me.current&&ue.current===l&&f(`idle`)}}async function Ne(n=!1){if(!(!Y.current||C?.state!==`connected`||oe!==Fn(i,o))){f(`saving`),h(``);try{let t=await Ut(Y.current,n);Y.current=void 0,await ve.current().catch(()=>{}),t?.reloadRequired?v(!0):e.onClose()}catch(e){let n=e.status;n===404||n===409?(Z(),h(t.setupConflict)):h(t.setupSaveFailed)}finally{me.current&&f(`idle`)}}}async function Pe(){de.current?.abort();let e=Y.current;fe.current=void 0,O(void 0),X.current?.close(),h(t.setupCancelled),f(`checking`);try{e&&await Kt(e)}catch{me.current&&(Z(),h(t.setupCancelled))}finally{me.current&&f(`idle`)}}async function Fe(){T?.authorizationUrl&&(window.electronAPI?.shell?.openExternalUrl?(await window.electronAPI.shell.openExternalUrl(T.authorizationUrl)).ok||h(t.oauthOpenFailed):window.open(T.authorizationUrl,`_blank`,`noopener,noreferrer`))}async function Ie(){if(T)try{await qt(Y.current,ee),te(``),h(``)}catch{h(t.setupRedirectInvalid)}}let Le=!!Y.current&&oe===Fn(i,o)&&(o.mode===`oauth`||o.mode===`auto`&&C?.state===`oauth_required`)&&C?.state!==`connected`,Re=/^(?:https?:\/\/)?(?:localhost|127\.0\.0\.1|\[::1\])(?=[:/]|$)/i.test(i.url.trim()),ze=H[Number(W)];return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(M,{open:e.open,onOpenChange:e=>{e||Ee()},children:(0,$.jsxs)(k,{children:[(0,$.jsx)(E,{className:`fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(A,{ref:he,tabIndex:-1,className:`fixed left-1/2 top-1/2 z-[60] flex h-[min(44rem,calc(100dvh-2rem))] w-[min(42rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay`,onOpenAutoFocus:e=>{e.preventDefault(),he.current?.focus()},children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge p-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(j,{className:`font-semibold`,children:e.mode===`edit`?t.setupEditTitle:t.setupTitle}),(0,$.jsx)(D,{className:`mt-1 text-sm text-fg-muted`,children:t.setupHint})]}),(0,$.jsx)(`button`,{type:`button`,disabled:be,onClick:Ee,className:`rounded-lg p-2 text-fg-muted hover:bg-surface-hover disabled:opacity-50`,"aria-label":n.modalClose,children:(0,$.jsx)(y,{className:`size-5`,"aria-hidden":!0})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-5`,children:[I?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(F,{variant:`ghost`,onClick:()=>L(!1),children:t.setupImportBack}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.setupImportEmpty}),(0,$.jsxs)(`label`,{className:`block text-sm font-medium text-fg`,children:[t.setupImport,(0,$.jsx)(`textarea`,{className:x(Tn,`mt-1.5 min-h-40 font-mono text-xs`),value:R,placeholder:`{"mcpServers": {"docs": {"url": "https://example.com/mcp"}}}`,onChange:e=>{z(e.target.value),U([]),V(``)}})]}),(0,$.jsx)(F,{variant:`secondary`,disabled:!R.trim(),onClick:De,children:t.setupImportPreview}),B?(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:B}):null,ze?(0,$.jsxs)(`div`,{className:`space-y-3 rounded-lg border border-edge p-4`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.setupImportScope}),(0,$.jsxs)(`label`,{className:`block text-sm font-medium`,children:[t.setupImportChoose,(0,$.jsx)(s,{"aria-label":t.setupImportChoose,className:x(Tn,`mt-1.5`),value:W,onChange:e=>G(e.target.value),children:H.map((e,t)=>(0,$.jsx)(c,{value:String(t),children:e.displayName||e.id||en(e)},t))})]}),(0,$.jsxs)(`p`,{className:`break-all text-sm text-fg-muted`,children:[ze.transport===`stdio`?t.setupUseCommand:t.setupUseUrl,` · `,en(ze)]})]}):null]}):(0,$.jsxs)(`form`,{ref:ge,noValidate:!0,onBlurCapture:e=>{if(e.target instanceof HTMLInputElement&&e.target.dataset.field===`url`&&i.url.trim())try{Pt(i.url)}catch{S({field:`url`,message:t.setupAddressInvalid,focus:!1})}},onSubmit:e=>{e.preventDefault(),je()},children:[(0,$.jsxs)(`fieldset`,{disabled:be||g,className:`min-w-0 space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsx)(`div`,{className:`flex gap-1`,role:`group`,"aria-label":t.transportLabel,children:[`streamable-http`,`stdio`].map(e=>(0,$.jsx)(F,{type:`button`,variant:i.transport===e?`secondary`:`ghost`,"aria-pressed":i.transport===e,onClick:()=>we({transport:e}),children:e===`stdio`?t.setupUseCommand:t.setupUseUrl},e))}),(0,$.jsx)(F,{type:`button`,variant:`ghost`,onClick:()=>L(!0),children:t.setupImport})]}),(0,$.jsx)(`div`,{children:(0,$.jsx)(Mn,{row:i,t,variant:`basic`,onUpdate:we},`${i.transport}-${K}`)}),i.transport===`streamable-http`?(0,$.jsx)(`div`,{"data-field":`auth`,children:(0,$.jsx)(kn,{allowExisting:!!i.extra.auth||i.headers.some(e=>!!e.reference),draft:o,onChange:Te,t})}):null,b?(0,$.jsx)(`p`,{id:r,ref:_e,tabIndex:-1,role:`alert`,className:`text-sm text-danger`,children:b.message}):null,(0,$.jsxs)(`details`,{"data-field":`advanced`,className:`rounded-lg border border-edge p-3`,open:N,onToggle:e=>P(e.currentTarget.open),children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted`,children:t.setupAdvanced}),(0,$.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[(0,$.jsx)(Mn,{row:i,t,variant:`advanced`,idReadOnly:ae,showOAuth:o.mode===`oauth`,onUpdate:we}),i.transport===`streamable-http`&&o.mode!==`headers`&&o.mode!==`existing`?(0,$.jsx)(On,{additional:!0,headers:o.additionalHeaders,onChange:e=>Te({additionalHeaders:e}),t}):null]})]}),(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:i.transport===`stdio`?t.setupCommandHostHint:Re?t.setupLocalhostHint:t.setupGatewayHint}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.setupTestNotice})]}),(0,$.jsx)(`button`,{type:`submit`,hidden:!0})]}),g?(0,$.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-fg`,children:t.setupReloadRequired}):null,!I&&!g?(0,$.jsxs)(`div`,{className:`mt-4 space-y-3`,"aria-live":`polite`,children:[u===`idle`?null:(0,$.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,$.jsx)(_,{className:`size-4 animate-spin motion-reduce:animate-none`,"aria-hidden":!0}),u===`saving`?t.setupSaving:t.setupChecking]}),u===`idle`&&ae&&!xe&&!C&&!p&&!ye?(0,$.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:Se?t.setupDisabled:t.setupSavedUnchecked}):null,C?.state===`connected`?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 text-sm text-success`,children:[(0,$.jsx)(d,{className:`size-4 shrink-0`,"aria-hidden":!0}),C.toolCount?t.setupConnected.replace(`{{count}}`,String(C.toolCount)):t.setupZeroTools]}),(0,$.jsx)(F,{variant:`secondary`,onClick:()=>re(!0),children:t.viewTools})]}):null,C?.state===`token_required`?(0,$.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:t.setupNeedsAuth}):null,C?.state===`oauth_required`&&!ye?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.setupOAuthRequired}):null,ye?(0,$.jsxs)(`div`,{className:`space-y-3 rounded-lg border border-edge p-4`,children:[(0,$.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,$.jsx)(_,{className:`size-4 animate-spin motion-reduce:animate-none`,"aria-hidden":!0}),t.setupAuthorizing]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[T?.authorizationUrl?(0,$.jsxs)(F,{variant:`secondary`,onClick:()=>void Fe(),children:[(0,$.jsx)(m,{className:`size-4`,"aria-hidden":!0}),t.oauthOpenAuthorization]}):null,(0,$.jsx)(F,{variant:`ghost`,onClick:()=>void Pe(),children:t.setupCancelAuth})]}),T?.acceptsRedirect?(0,$.jsxs)(`details`,{children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm text-accent-fg`,children:t.setupRemoteFallback}),(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:t.setupRedirectHint}),(0,$.jsxs)(`label`,{className:`mt-2 block text-sm`,children:[t.setupRedirectLabel,(0,$.jsx)(`input`,{className:Tn,value:ee,onChange:e=>te(e.target.value)})]}),(0,$.jsx)(F,{className:`mt-2`,disabled:!ee.trim(),onClick:()=>void Ie(),children:t.setupContinue})]}):null]}):null,p?(0,$.jsxs)(`div`,{role:`alert`,className:`space-y-1 text-sm`,children:[(0,$.jsx)(`p`,{className:`text-danger`,children:p}),p!==t.setupSaveFailed&&u!==`saving`?(0,$.jsx)(`p`,{className:`text-fg-muted`,children:t.setupTestFailure}):null]}):null]}):null]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge p-4`,children:[(0,$.jsx)(F,{variant:`secondary`,disabled:be,onClick:Ee,children:ae||g?t.setupClose:n.modalCancel}),g?null:I?(0,$.jsx)(F,{variant:`primary`,disabled:!ze,onClick:Oe,children:t.setupImportApply}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(F,{variant:C?.state===`connected`?`secondary`:`primary`,disabled:be,onClick:()=>Le?void Ae():void je(),children:Le?t.setupSignIn:t.setupTestConnection}),C?.state===`connected`&&oe===Fn(i,o)?(0,$.jsxs)($.Fragment,{children:[Se?(0,$.jsx)(F,{variant:`secondary`,disabled:be,onClick:()=>void Ne(!0),children:t.setupEnableSave}):null,(0,$.jsx)(F,{variant:`primary`,disabled:be,"aria-busy":be,onClick:()=>void Ne(),children:ae?t.setupSaveOnly:t.setupAddConnection})]}):null]})]})]})]})}),(0,$.jsx)(Me,{open:J,title:t.setupUnsavedTitle,description:t.setupUnsavedHint,confirmLabel:t.setupDiscard,cancelLabel:t.setupKeepEditing,onCancel:()=>ie(!1),onConfirm:e.onClose,overlayClassName:`z-[70]`,contentClassName:`z-[70]`}),ne?(0,$.jsx)(Zt,{draftId:Y.current,serverId:i.id,t,onClose:()=>re(!1)}):null]})}var Ln=`builtin`,Rn=`composio`,zn=`xopc-store`;function Bn(e){return Ln}function Vn(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`,...e.branding?.iconUrl?{branding:{logoUrl:e.branding.iconUrl,source:`registry`}}:{},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 Hn(e){return e.filter((e,t,n)=>n.findIndex(t=>t.id===e.id)===t)}function Un(e){return e?.startsWith(`/`)&&!e.startsWith(`//`)?e:`/user-model`}function Wn({embedded:e=!1,onHeaderActionChange:t}){let n=N().filter(e=>e.format===`agent-plugin`),r=w(e=>e.language),o=b(r),s=o.connectorsSettings,c=o.mcpSettings,u=C(e=>e.conversationId),d=!!u,f=a(),[p,m]=i(),h=p.get(`understanding`)===`1`,g=Un(p.get(`returnTo`)),v=!!p.get(`returnTo`)&&!h,y=p.get(`tab`),[S,T]=(0,Q.useState)(!h&&y===`connected`?`connected`:`discover`),E=(0,Q.useRef)(!1),[D,O]=(0,Q.useState)({catalog:[],registryCatalog:[],instances:[],loading:!0,error:null}),[k,A]=(0,Q.useState)(!1),[j,M]=(0,Q.useState)(!1),[P,I]=(0,Q.useState)(1),[L,z]=(0,Q.useState)(void 0),[B,V]=(0,Q.useState)(``),[H,U]=(0,Q.useState)(h||v?p.get(`connector`)??``:``),[q,ee]=(0,Q.useState)(Bn(h?`understanding`:`default`)),[te,re]=(0,Q.useState)(`name`),[J,ie]=(0,Q.useState)(h?`understand`:`all`),[ae,oe]=(0,Q.useState)(null),[se,Y]=(0,Q.useState)(null),[ue,de]=(0,Q.useState)(null),[fe,X]=(0,Q.useState)(null),[me,ge]=(0,Q.useState)(null),[ve,be]=(0,Q.useState)(null),{data:Se,mutate:Ce}=R(d),Z=Se?.payload?.config,we=(0,Q.useMemo)(()=>Z===void 0?null:Lt(Z),[Z]),Te=we?.servers??[],Ee=D.instances.length+Te.length+n.reduce((e,t)=>e+(t.components?.mcp.length??0),0),[De,Oe]=(0,Q.useState)({});(0,Q.useEffect)(()=>{if(Oe({}),!d||!Z)return;let e=new AbortController;return Yt(e.signal).then(t=>{e.signal.aborted||Oe(t)}).catch(()=>{}),()=>e.abort()},[d,Z]);let ke=(0,Q.useCallback)(async()=>{if(!u){O({catalog:[],registryCatalog:[],instances:[],loading:!1,error:null});return}O(e=>({...e,loading:!0,error:null}));try{let[e,t]=await Promise.all([Ye(),G()]);O(n=>({catalog:e,registryCatalog:n.registryCatalog,instances:t,loading:!1,error:null}))}catch(e){O({catalog:[],registryCatalog:[],instances:[],loading:!1,error:e instanceof Error?e.message:String(e)})}},[u]);(0,Q.useEffect)(()=>{ke()},[ke]),(0,Q.useEffect)(()=>{E.current||D.loading||d&&!we||(T(h?`discover`:Ee>0?`connected`:`discover`),E.current=!0)},[d,Ee,we,h,D.loading]);let Ae=(0,Q.useCallback)(e=>{E.current=!0,T(e)},[]),je=(0,Q.useMemo)(()=>[{id:Rn,displayName:s.composioSourceName},{id:zn,displayName:s.storeSourceName}],[s.composioSourceName,s.storeSourceName]),Me=(0,Q.useCallback)(async e=>{if(!d||q===`builtin`){O(e=>({...e,registryCatalog:[]})),I(1),z(void 0);return}let t=H.trim(),n=Math.max(e?.page??1,1),r=e?.append??!1,i=q===`all`?je:je.filter(e=>e.id===q);if(i.length!==0){A(!0),r?O(e=>({...e,error:null})):(I(1),z(void 0),O(e=>({...e,registryCatalog:[],error:null})));try{let e=await Promise.all(i.map(async e=>{if(e.id===`composio`){let e=await le({q:t||void 0,page:n,pageSize:24,verification:`experimental`});return{connectors:e.connectors,totalPages:e.meta.totalPages}}let r=await pe({q:t||void 0,page:n,pageSize:24,sort:te===`source`?`newest`:`downloads`});return{connectors:r.items.flatMap(e=>{let t=Vn(e);return t?[t]:[]}),totalPages:r.meta.totalPages}})),a=Hn(e.flatMap(e=>e.connectors)),o=Math.max(1,...e.map(e=>e.totalPages??1));I(n),z(o),O(e=>({...e,registryCatalog:r?Hn([...e.registryCatalog,...a]):a}))}catch(e){O(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{A(!1)}}},[te,H,q,d,je]);(0,Q.useEffect)(()=>{if(S!==`discover`||D.loading)return;if(q===`builtin`){O(e=>({...e,registryCatalog:[]})),I(1),z(void 0);return}let e=window.setTimeout(()=>{Me()},H.trim()?350:0);return()=>window.clearTimeout(e)},[H,q,Me,D.loading,S]);let Ne=(0,Q.useMemo)(()=>new Set(D.instances.map(e=>e.connectorId)),[D.instances]),Pe=(0,Q.useMemo)(()=>new Map([...D.catalog,...D.registryCatalog].map(e=>[e.id,e])),[D.catalog,D.registryCatalog]);(0,Q.useEffect)(()=>{if(D.loading)return;let e=p.get(`connector`),t=p.get(`instance`);if(!e&&!t)return;let n=D.instances.find(n=>t?n.instanceId===t:n.connectorId===e);if(n)E.current=!0,V(``),de(n.instanceId),X(n),T(`connected`);else if(e){let t=Pe.get(e);if(!t)return;E.current=!0,ee(Bn(h?`understanding`:`default`)),U(``),Y(t),T(`discover`)}let r=new URLSearchParams(p);r.delete(`connector`),r.delete(`instance`),r.set(`tab`,n?`connected`:`discover`),m(r,{replace:!0})},[Pe,h,p,m,D.instances,D.loading]);let Fe=(0,Q.useCallback)(async e=>{M(!0),O(e=>({...e,error:null}));try{let t=await ne(e);oe(he(t.definition,{packageName:t.packageName,version:t.version,reviewHash:t.reviewHash,permissions:t.permissions}))}catch(e){O(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{M(!1)}},[]),Ie=(0,Q.useMemo)(()=>new Set(D.instances.flatMap(e=>e.materialized.type===`mcp`?[e.materialized.serverId]:[])),[D.instances]),Le=(0,Q.useCallback)(async e=>{let t=await Xt(e);await Ce(),await ke(),t.reloadRequired&&O(e=>({...e,error:c.setupReloadRequired}))},[ke,Ce,c.setupReloadRequired]),Re=(0,Q.useCallback)(()=>{be({mode:`add`,row:yn(Te,Ie)})},[Te,Ie]),ze=K(e=>e.setPageHeader),Be=K(e=>e.clearPageHeader),Ve=(0,Q.useMemo)(()=>({searchLabel:S===`connected`?s.connectedSearchPlaceholder:s.discoverSearchPlaceholder,search:(0,$.jsx)(Xe,{value:S===`connected`?B:H,onChange:S===`connected`?V:U,placeholder:S===`connected`?s.connectedSearchPlaceholder:s.discoverSearchPlaceholder}),secondary:(0,$.jsx)(St,{onRefresh:S===`connected`&&d?ke:void 0,refreshing:D.loading,refreshLabel:s.refreshConnections,onBrowseCatalog:()=>Ae(`discover`),onAddCustomServer:Re,addLabel:s.addConnection,browseLabel:s.addFromCatalog,customLabel:s.addCustomServerAdvanced,serviceLabel:r.startsWith(`zh`)?`应用连接服务`:`Connection service`,moreActionsLabel:o.capabilitiesHub.moreActions})}),[B,s,H,d,r,ke,o.capabilitiesHub.moreActions,Re,Ae,D.loading,S]);(0,Q.useLayoutEffect)(()=>e?(t?.(Ve),()=>t?.(null)):(ze({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:s.title})}),end:(0,$.jsx)(Ze,{contribution:Ve})}),()=>Be()),[Be,s.title,e,Ve,t,ze]);let He=(0,Q.useMemo)(()=>D.instances.map(e=>({instance:e,value:mt(e,Pe.get(e.connectorId))})),[Pe,D.instances]),Ue=(0,Q.useMemo)(()=>new Map(He.map(({instance:e,value:t})=>[e.instanceId,t])),[He]),We=(0,Q.useMemo)(()=>D.instances.filter(e=>ce(e,B)).sort((e,t)=>{let n={needs_setup:0,checking:1,ready:2},r=Ue.get(e.instanceId)?.state??`checking`,i=Ue.get(t.instanceId)?.state??`checking`;return n[r]-n[i]||e.displayName.localeCompare(t.displayName)}),[B,Ue,D.instances]),Ge=(0,Q.useMemo)(()=>We.filter(e=>Ue.get(e.instanceId)?.state===`needs_setup`),[Ue,We]),Ke=(0,Q.useMemo)(()=>We.filter(e=>Ue.get(e.instanceId)?.state!==`needs_setup`),[Ue,We]),qe=(0,Q.useMemo)(()=>Te.filter(e=>_e(e,B)),[B,Te]),Je=(0,Q.useMemo)(()=>{let e=B.trim().toLowerCase();return n.flatMap(t=>(t.components?.mcp??[]).filter(n=>`${t.name} ${n.name}`.toLowerCase().includes(e)).map(e=>({extension:t,server:e})))},[B,n]),Qe=We.length+qe.length+Je.length,tt=(0,Q.useMemo)(()=>D.catalog.filter(e=>e.source===`builtin`&&e.integrationStrategy?.preferred!==!1&&W(e)),[D.catalog]),nt=(0,Q.useMemo)(()=>q===`builtin`?tt:q===`all`?Hn([...tt,...D.registryCatalog]):D.registryCatalog,[tt,q,D.registryCatalog]),it=(0,Q.useMemo)(()=>{let e=h?nt.filter(e=>e.understanding?.mode===`activity`):nt;return xe(J===`all`?e:e.filter(e=>ft(e).includes(J)),H,te)},[te,H,nt,h,J]),st=(0,Q.useMemo)(()=>dt.filter(e=>nt.some(t=>ft(t).includes(e))),[nt]);(0,Q.useEffect)(()=>{J!==`all`&&!st.includes(J)&&ie(`all`)},[st,J]);let lt=S===`discover`&&q!==`builtin`&&!!(L&&P<L),pt=(0,Q.useMemo)(()=>D.instances.find(e=>e.instanceId===ue)??fe,[ue,fe,D.instances]),ht=(0,Q.useMemo)(()=>[{value:`all`,label:s.discoverSourceAll},{value:Ln,label:s.discoverSourceBuiltin},...je.map(e=>({value:e.id,label:e.displayName}))],[s.discoverSourceAll,s.discoverSourceBuiltin,je]),gt=[{id:`connected`,label:s.tabConnected,count:Ee},{id:`discover`,label:s.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:x(`mx-auto flex w-full max-w-7xl flex-col gap-6 px-4 sm:px-6 lg:px-8`,e?`pb-7 pt-3 lg:pb-9 lg:pt-4`:`py-7 lg:py-9`),children:[d?null:(0,$.jsx)(`p`,{className:`rounded-xl border border-edge bg-surface-panel px-4 py-3 text-sm text-fg-muted`,children:s.tokenHint}),h?(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:s.understandingSetupTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:s.understandingSetupHint})]}),(0,$.jsx)(F,{type:`button`,variant:`secondary`,className:`shrink-0`,onClick:()=>f(g),children:s.understandingSetupDone})]}):null,v?(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:s.recoverySetupTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:s.recoverySetupHint})]}),(0,$.jsx)(F,{type:`button`,variant:`secondary`,className:`min-h-11 shrink-0`,onClick:()=>f(g),children:s.recoverySetupDone})]}):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)($e,{items:gt,activeTab:S,onChange:Ae,ariaLabel:s.navAria,tabIdPrefix:`connectors-tab`,panelIdPrefix:`connectors-panel`,className:`flex-wrap`})}),D.error?(0,$.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:D.error}):null,S===`connected`&&d?(0,$.jsx)(`div`,{className:`flex flex-col gap-6`,children:D.loading?(0,$.jsx)(`div`,{className:`grid gap-3`,"aria-busy":`true`,"aria-label":s.loading,children:at.slice(0,3).map(e=>(0,$.jsx)(ut,{},e))}):Ee===0?(0,$.jsxs)(`div`,{className:`py-14 text-center`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:s.connectionsEmpty}),(0,$.jsx)(F,{type:`button`,variant:`primary`,className:`mt-4`,onClick:()=>Ae(`discover`),children:s.addFromCatalog})]}):Qe===0?(0,$.jsx)(`div`,{className:`py-14 text-center text-sm text-fg-muted`,children:s.connectionsSearchEmpty}):(0,$.jsxs)(`div`,{className:`space-y-6`,children:[Ge.length?(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:s.needsAttentionTitle}),(0,$.jsx)(`span`,{className:`text-xs tabular-nums text-amber-700 dark:text-amber-300`,children:Ge.length})]}),(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-xl border border-amber-500/25 bg-amber-500/5`,children:Ge.map(e=>(0,$.jsx)(vn,{instance:e,definition:Pe.get(e.connectorId),highlighted:e.instanceId===me,onOpenDetails:e=>{ge(null),de(e.instanceId),X(e)},t:s},e.instanceId))})]}):null,Ke.length?(0,$.jsx)(`section`,{children:(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-xl border border-edge bg-surface-base`,children:Ke.map(e=>(0,$.jsx)(vn,{instance:e,definition:Pe.get(e.connectorId),highlighted:e.instanceId===me,onOpenDetails:e=>{ge(null),de(e.instanceId),X(e)},t:s},e.instanceId))})}):null,Je.map(({extension:e,server:t})=>(0,$.jsx)(et,{pluginId:e.pluginId,server:t,enabled:e.active},t.id)),qe.length||!B.trim()?(0,$.jsxs)(`details`,{className:`rounded-xl border border-edge bg-surface-base`,children:[(0,$.jsxs)(`summary`,{className:`cursor-pointer px-4 py-3`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:s.customIntegrationsTitle}),(0,$.jsx)(`span`,{className:`ml-2 text-xs tabular-nums text-fg-subtle`,children:qe.length}),(0,$.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:s.customIntegrationsHint})]}),(0,$.jsxs)(`div`,{className:`border-t border-edge-subtle`,children:[(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2 px-4 py-3`,children:(0,$.jsx)(F,{type:`button`,variant:`secondary`,className:`h-8 text-xs`,onClick:Re,children:s.addCustomServerAdvanced})}),(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle`,children:qe.map(e=>(0,$.jsx)(tn,{row:e,lastCheck:De[e.id],t:c,cs:s,onEdit:()=>be({mode:`edit`,row:structuredClone(e)}),onRemove:async()=>Le(e)},e.clientKey))})]})]}):null]})}):null,S===`discover`&&d?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[h?null:(0,$.jsx)(`div`,{className:`flex min-w-0 flex-1 basis-80 flex-wrap gap-2`,role:`group`,"aria-label":s.taskFilterAria,children:[`all`,...st].map(e=>(0,$.jsx)(`button`,{type:`button`,className:x(`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors`,J===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":J===e,onClick:()=>ie(e),children:e===`all`?s.taskAll:s.connectorBenefitHeadings[e]},e))}),(0,$.jsxs)(`div`,{className:x(`ml-auto grid w-full gap-2 sm:flex sm:w-auto sm:justify-end`,h?`grid-cols-1`:`grid-cols-2`),children:[h?null:(0,$.jsx)(`div`,{className:`min-w-0 sm:w-40`,children:(0,$.jsx)(l,{value:q,options:ht,placeholder:s.discoverSourceAll,allowEmpty:!1,ariaLabel:s.registrySourceAria,triggerClassName:`h-9 bg-surface-panel text-xs`,onChange:ee})}),(0,$.jsx)(`div`,{className:`min-w-0 sm:w-40`,children:(0,$.jsx)(l,{value:te,options:[{value:`name`,label:s.sortName},{value:`source`,label:s.sortSource}],placeholder:s.sortName,allowEmpty:!1,ariaLabel:s.sortAria,triggerClassName:`h-9 bg-surface-panel text-xs`,onChange:e=>re(e)})})]})]}),(D.loading||k)&&it.length===0?(0,$.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,"aria-busy":`true`,"aria-label":s.loading,children:at.map(e=>(0,$.jsx)(ct,{},e))}):it.length===0?(0,$.jsx)(`div`,{className:`py-14 text-center text-sm text-fg-muted`,children:s.discoverEmpty}):(0,$.jsxs)(`div`,{className:`relative`,children:[k?(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":s.loading,children:(0,$.jsx)(_,{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:it.map(e=>(0,$.jsx)(rt,{connector:e,installed:Ne.has(e.id)||ot(e,D.instances),onInstall:e=>{if(e.source===`store`){Fe(e.id);return}oe(he(e))},onOpenDetails:e.source===`store`?void 0:Y,t:s},e.id))}),lt?(0,$.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,$.jsxs)(F,{type:`button`,variant:`secondary`,disabled:k||j,onClick:()=>void Me({page:P+1,append:!0}),children:[k?(0,$.jsx)(_,{className:`size-4 animate-spin`}):null,s.loadMore]})}):null]})]}):null]}),ae?(0,$.jsx)(ye,{draft:ae,onChange:oe,onClose:()=>oe(null),t:s,onInstalled:async e=>{await ke(),await Ce(),ge(e.instanceId),Ae(`connected`)}}):null,se?(0,$.jsx)(vt,{connector:se,installed:Ne.has(se.id)||ot(se,D.instances),onClose:()=>Y(null),onInstall:e=>oe(he(e)),t:s}):null,pt?(0,$.jsx)(_n,{instance:pt,definition:Pe.get(pt.connectorId),onClose:()=>{de(null),X(null)},onChanged:ke,t:s,mcp:c}):null,ve?(0,$.jsx)(In,{open:!0,mode:ve.mode,initialRow:ve.row,existingCustomServers:Te,config:Z,managedServerIds:Ie,t:c,cs:s,onClose:()=>be(null),onSaved:async()=>{await Ce(),await ke(),Ae(`connected`)}},`${ve.mode}-${ve.row.clientKey}`):null]})})}export{Wn as ConnectorsPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{i as e,n as t}from"./rolldown-runtime-aKtaBQYM.js";import{a as n,n as r,t as i}from"./vendor-react-BOUWij0V.js";import{p as a}from"./chunk-KS7C4IRE--EKdQGRF.js";import{t as o}from"./chevron-right-BweFrslA.js";import{t as s}from"./circle-check-C23XjkUj.js";import{t as c}from"./clock-3-DnrAnuyZ.js";import{t as l}from"./download-Dk-ZjtO6.js";import{t as u}from"./external-link-DjqjBmc3.js";import{t as d}from"./x-B_N4OPjy.js";import{t as f}from"./messages-O0BEUKnx.js";import{t as p}from"./cn-0WouolD0.js";import{n as m}from"./locale-store-DMy9W6IG.js";import{a as h,i as g,o as _,r as v,s as y,t as b}from"./dist-BGTk37IG.js";import{n as x}from"./app-link-4gpFbdsr.js";import{i as S}from"./vendor-swr-BIWyz7Rc.js";import{t as C}from"./button-aIC072nz.js";import{t as w}from"./skeleton-BI5TyibZ.js";import{i as T,o as ee}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{t as E}from"./use-async-resource-GrnWNwMZ.js";import{t as D}from"./copy-text-row-C7egVuKr.js";import{At as O,Cs as te,L as k,Mt as A,Qs as ne,R as j,Zo as M,kt as N,z as P}from"./index-xTL-vb51.js";import{_ as re,a as ie,d as ae,f as oe,g as se,h as ce,i as F,l as I,m as le,n as L,p as ue,r as R,s as z,t as B,u as de,v as fe}from"./tunnel-api-CF1Qh4wU.js";import{t as V}from"./browser-BLJWD7WI.js";var H=e(n(),1),U=r(),W=e(V(),1),G={width:240,margin:4,errorCorrectionLevel:`M`,color:{dark:`#000000ff`,light:`#ffffffff`}};async function pe(e){let t=await W.toString(e,{...G,type:`svg`});return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(t)}`}var K=i();function me(){let e=f(m(e=>e.language)),t=e.endpointToolsSettings.deviceAccess.flow,n=e.tunnelSettings,{data:r,error:i,mutate:a}=S(`tunnel-status`,L,{refreshInterval:1500}),[o,s]=(0,H.useState)(!1),[c,l]=(0,H.useState)(!1),[d,p]=(0,H.useState)(!0),[h,g]=(0,H.useState)(`idle`),[_,v]=(0,H.useState)(null),[y,b]=(0,H.useState)(``),T=(0,H.useRef)(!0);(0,H.useEffect)(()=>(T.current=!0,()=>{T.current=!1}),[]);let ee=async()=>{if(!r)return;if(r.consentRequired&&!o){l(!0);return}let e=r.registrationSecret?.configured?null:P(),t,n=!1;v(null);try{if(r.consentRequired&&await ie(),!r.registrationSecret?.configured){g(`provisioning`);let r=!1;try{await F()}catch(e){if(!de(e))throw e;r=!0}if(r){g(`authorizing`);let r=sessionStorage.getItem(`device-pairing-oauth`),i=r?JSON.parse(r):null;t=i&&i.expiresAt>Date.now()?i.sessionId:(await A(`xopc-tunnel`)).sessionId,sessionStorage.setItem(`device-pairing-oauth`,JSON.stringify({sessionId:t,expiresAt:i&&i.expiresAt>Date.now()?i.expiresAt:Date.now()+5*6e4}));let a=``,o=Date.now()+5*6e4,s=!1;for(;T.current&&Date.now()<o;){let r=await O(t);if(r.authUrl&&r.authUrl!==a&&(a=r.authUrl,await j(a,e)||b(a)),r.status===`completed`){s=!0,n=!0;break}if(r.status===`failed`||r.status===`cancelled`)throw Error(`Authorization cancelled`);await new Promise(e=>setTimeout(e,1e3))}if(!T.current)return;if(!s)throw Error(`Authorization expired`);await F()}await a()}if(!T.current)return;g(`starting`),await z(),d&&await R({autoStart:!0}),await a(),n=!0}catch(e){n=!0,T.current&&v(I(e)===`tunnel_key_limit_reached`?`key-limit`:`failed`)}finally{k(e),n&&(sessionStorage.removeItem(`device-pairing-oauth`),t&&N(t).catch(()=>{})),T.current&&(g(`idle`),b(``))}};if(!r&&!i)return(0,K.jsxs)(`div`,{className:`space-y-5`,children:[(0,K.jsx)(w,{className:`h-5 w-4/5`}),(0,K.jsx)(w,{className:`h-24 w-full`})]});let E=h===`provisioning`||h===`starting`||r?.state===`connecting`||r?.state===`reconnecting`;return(0,K.jsxs)(`div`,{className:`flex min-h-full flex-col`,children:[(0,K.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:E?t.preparingHint:h===`authorizing`?t.authorizing:t.enableHint}),y&&h===`authorizing`?(0,K.jsx)(`a`,{href:y,target:`_blank`,rel:`noopener noreferrer`,className:`mt-4 inline-flex min-h-11 items-center text-sm text-accent`,children:t.openAuthorization}):null,E?(0,K.jsxs)(`div`,{className:`mt-8 space-y-3`,"aria-label":t.preparing,children:[(0,K.jsx)(w,{className:`h-2 w-full`}),(0,K.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.preparing})]}):null,(c||r?.consentRequired)&&h===`idle`?(0,K.jsxs)(`div`,{className:`mt-6 space-y-4`,children:[(0,K.jsxs)(`details`,{open:c,className:`text-sm text-fg-muted`,children:[(0,K.jsx)(`summary`,{className:`cursor-pointer py-2`,children:t.details}),(0,K.jsx)(`p`,{className:`mt-2`,children:n.consentIntro}),(0,K.jsx)(`ul`,{className:`mt-3 list-disc space-y-2 pl-5`,children:[n.consentBullet1,n.consentBullet2,n.consentBullet3].map(e=>(0,K.jsx)(`li`,{children:e},e))})]}),(0,K.jsxs)(`label`,{className:`flex items-start gap-3 text-sm text-fg`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked),className:`mt-1 size-4 accent-accent`}),n.consentCheckbox]})]}):null,_===`key-limit`?(0,K.jsxs)(`div`,{role:`alert`,className:`mt-4 rounded-lg border border-warning/30 bg-warning/5 p-4`,children:[(0,K.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.routeKeyLimitTitle}),(0,K.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:t.routeKeyLimitHint}),(0,K.jsxs)(C,{variant:`secondary`,className:`mt-3`,onClick:()=>void x(B),children:[t.manageTunnelKeys,(0,K.jsx)(u,{className:`size-3`})]})]}):_||i||r?.state===`error`?(0,K.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-danger`,children:t.routeSetupFailed}):null,(0,K.jsx)(`div`,{className:`flex-1`}),(0,K.jsxs)(`label`,{className:`my-5 flex items-center gap-3 text-sm text-fg-muted`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:d,disabled:h!==`idle`,onChange:e=>p(e.target.checked),className:`size-4 accent-accent`}),t.autoStart]}),(0,K.jsx)(C,{className:`w-full`,variant:`primary`,disabled:!r||h!==`idle`||E||c&&!o,onClick:()=>void ee(),children:h===`authorizing`?t.authorizing:E?t.preparing:_?t.retry:t.enable}),i&&!r?(0,K.jsx)(C,{variant:`ghost`,onClick:()=>void a(),children:t.retry}):null]})}var q=t({DevicePairingWizard:()=>J});function J(e){let t=(0,U.c)(16),{open:n,onOpenChange:r,onPaired:i,targetKind:o}=e,s=a(),[c,l]=(0,H.useState)(o),u,d;t[0]===o?(u=t[1],d=t[2]):(u=()=>{l(o)},d=[o],t[0]=o,t[1]=u,t[2]=d),(0,H.useEffect)(u,d);let f;t[3]!==r||t[4]!==o?(f=e=>{e||l(o),r(e)},t[3]=r,t[4]=o,t[5]=f):f=t[5];let p=f,m;t[6]!==p||t[7]!==s||t[8]!==i||t[9]!==n||t[10]!==c?(m=n?c?(0,K.jsx)(ge,{targetKind:c,onClose:()=>p(!1),onPaired:i}):(0,K.jsx)(X,{onChoose:l,onChooseLocalBrowser:()=>{p(!1),s(`/settings/agent-browser?driver=extension`)},onClose:()=>p(!1)}):null,t[6]=p,t[7]=s,t[8]=i,t[9]=n,t[10]=c,t[11]=m):m=t[11];let h;return t[12]!==p||t[13]!==n||t[14]!==m?(h=(0,K.jsx)(b,{open:n,onOpenChange:p,children:m}),t[12]=p,t[13]=n,t[14]=m,t[15]=h):h=t[15],h}function Y(e){let t=(0,U.c)(14),{icon:n,title:r,hint:i,onClick:a}=e,s;t[0]===n?s=t[1]:(s=(0,K.jsx)(`span`,{className:`flex size-10 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-accent-fg`,children:(0,K.jsx)(n,{className:`size-5`,"aria-hidden":`true`})}),t[0]=n,t[1]=s);let c;t[2]===r?c=t[3]:(c=(0,K.jsx)(`span`,{className:`block text-sm font-semibold text-fg`,children:r}),t[2]=r,t[3]=c);let l;t[4]===i?l=t[5]:(l=(0,K.jsx)(`span`,{className:`mt-0.5 block text-xs leading-5 text-fg-muted`,children:i}),t[4]=i,t[5]=l);let u;t[6]!==c||t[7]!==l?(u=(0,K.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[c,l]}),t[6]=c,t[7]=l,t[8]=u):u=t[8];let d;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,K.jsx)(o,{className:`size-4 shrink-0 text-fg-disabled transition-transform group-hover:translate-x-0.5 group-hover:text-fg-muted`,"aria-hidden":`true`}),t[9]=d):d=t[9];let f;return t[10]!==a||t[11]!==s||t[12]!==u?(f=(0,K.jsxs)(`button`,{type:`button`,className:`group flex min-h-18 w-full cursor-pointer items-center gap-4 rounded-xl border border-edge bg-surface-panel px-4 py-3.5 text-left shadow-surface transition-[background-color,border-color,box-shadow,transform] hover:border-edge-strong hover:bg-surface-active hover:shadow-elevated active:translate-y-px active: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-panel motion-reduce:active:translate-y-0`,onClick:a,children:[s,u,d]}),t[10]=a,t[11]=s,t[12]=u,t[13]=f):f=t[13],f}function X(e){let t=(0,U.c)(40),{onChoose:n,onChooseLocalBrowser:r,onClose:i}=e,a=m(he),o;t[0]===a?o=t[1]:(o=f(a),t[0]=a,t[1]=o);let s=o.endpointToolsSettings.deviceAccess,c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,K.jsx)(h,{className:p(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,ee)}),t[2]=c):c=t[2];let l;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(l=p(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(28rem,calc(100dvh-2rem))] w-[min(40rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay`,T),t[3]=l):l=t[3];let u;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,K.jsx)(`span`,{className:`text-lg font-semibold tracking-tight text-fg`,children:`xopc`}),t[4]=u):u=t[4];let b;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,K.jsx)(d,{className:`size-4`}),t[5]=b):b=t[5];let x;t[6]!==s.cancel||t[7]!==i?(x=(0,K.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between border-b border-edge-subtle px-6 py-3`,children:[u,(0,K.jsx)(`button`,{type:`button`,className:`flex size-10 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover`,"aria-label":s.cancel,onClick:i,children:b})]}),t[6]=s.cancel,t[7]=i,t[8]=x):x=t[8];let S;t[9]===s.chooseTitle?S=t[10]:(S=(0,K.jsx)(y,{className:`text-lg font-semibold tracking-tight text-fg sm:text-xl`,children:s.chooseTitle}),t[9]=s.chooseTitle,t[10]=S);let C;t[11]===s.chooseHint?C=t[12]:(C=(0,K.jsx)(g,{className:`mt-1.5 text-sm leading-6 text-fg-muted`,children:s.chooseHint}),t[11]=s.chooseHint,t[12]=C);let w;t[13]!==s.localBrowserHint||t[14]!==s.localBrowserTitle||t[15]!==r?(w=(0,K.jsx)(Y,{icon:ne,title:s.localBrowserTitle,hint:s.localBrowserHint,onClick:r}),t[13]=s.localBrowserHint,t[14]=s.localBrowserTitle,t[15]=r,t[16]=w):w=t[16];let E;t[17]===n?E=t[18]:(E=()=>n(`mobile`),t[17]=n,t[18]=E);let D;t[19]!==s.mobileHint||t[20]!==s.mobileTitle||t[21]!==E?(D=(0,K.jsx)(Y,{icon:M,title:s.mobileTitle,hint:s.mobileHint,onClick:E}),t[19]=s.mobileHint,t[20]=s.mobileTitle,t[21]=E,t[22]=D):D=t[22];let O;t[23]===n?O=t[24]:(O=()=>n(`browser`),t[23]=n,t[24]=O);let k;t[25]!==s.remoteBrowserHint||t[26]!==s.remoteBrowserTitle||t[27]!==O?(k=(0,K.jsx)(Y,{icon:te,title:s.remoteBrowserTitle,hint:s.remoteBrowserHint,onClick:O}),t[25]=s.remoteBrowserHint,t[26]=s.remoteBrowserTitle,t[27]=O,t[28]=k):k=t[28];let A;t[29]!==D||t[30]!==k||t[31]!==w?(A=(0,K.jsxs)(`div`,{className:`mt-5 flex flex-col gap-2.5`,children:[w,D,k]}),t[29]=D,t[30]=k,t[31]=w,t[32]=A):A=t[32];let j;t[33]!==A||t[34]!==S||t[35]!==C?(j=(0,K.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-6 sm:px-8`,children:[S,C,A]}),t[33]=A,t[34]=S,t[35]=C,t[36]=j):j=t[36];let N;return t[37]!==j||t[38]!==x?(N=(0,K.jsxs)(_,{children:[c,(0,K.jsxs)(v,{className:l,children:[x,j]})]}),t[37]=j,t[38]=x,t[39]=N):N=t[39],N}function he(e){return e.language}function ge({targetKind:e,onClose:t,onPaired:n}){let r=m(e=>e.language),i=f(r),a=i.endpointToolsSettings.deviceAccess,b=a.flow,[O,te]=(0,H.useState)(!1),k=S(O?`device-pairing-readiness`:null,ce,{refreshInterval:1500}),[A,ne]=(0,H.useState)(),[j,M]=(0,H.useState)(null),[N,P]=(0,H.useState)(!1),[ie,F]=(0,H.useState)(Date.now()),[I,L]=(0,H.useState)(null),R=(0,H.useRef)(!0),z=(0,H.useRef)(null),B=(0,H.useRef)(!1),de=(0,H.useRef)(!1),V=S(A?[`device-pairing-setup`,A.id]:null,()=>se(A.id),{refreshInterval:1500}),U=V.data?.request,W=U?.status===`completed`,G=W&&U.connectedAt!==void 0,q=S(G&&window.electronAPI?.system?`system-behavior`:null,()=>window.electronAPI.system.getBehavior()),J=A?.targetKind===`mobile`?A.universalLink:``,Y=E(()=>pe(J),[J],{enabled:!!J,initial:null,errorData:null}),X=r===`zh`?`https://xopc.ai/zh#download`:`https://xopc.ai/en#download`,he=r===`zh`?`https://xopcai.github.io/xopc/zh/browser-extension`:`https://xopcai.github.io/xopc/browser-extension`,ge=E(()=>pe(X),[X],{enabled:!O&&e===`mobile`,initial:null,errorData:null});(0,H.useEffect)(()=>{R.current=!0;let e=setInterval(()=>F(Date.now()),1e3);return()=>{R.current=!1,clearInterval(e),z.current&&ae(z.current).catch(()=>{})}},[]);let Z=(0,H.useCallback)(async()=>{if(!B.current){B.current=!0,P(!0),M(null);try{z.current&&await ae(z.current),z.current=null,ne(void 0);let t=await oe(e);if(t.kind===`ready`){if(!R.current){await ae(t.setup.id);return}z.current=t.setup.id,ne(t.setup)}else await k.mutate()}catch{R.current&&M(`create`)}finally{B.current=!1,R.current&&P(!1)}}},[k,e]);(0,H.useEffect)(()=>{k.data?.ready&&!A&&j!==`create`&&!B.current&&Z()},[k.data,A,j,Z]),(0,H.useEffect)(()=>{G&&!de.current&&(de.current=!0,n?.())},[G,n]);let _e=async e=>{if(U){P(!0),M(null);try{await ue(U,e),await V.mutate()}catch{M(`decision`),await V.mutate()}finally{R.current&&P(!1)}}},ve=(0,H.useRef)(0);(0,H.useEffect)(()=>{V.data&&(ve.current=V.data.serverTime-Date.now())},[V.data]);let Q=ie+ve.current,ye=A&&Q>=A.expiresAt&&!U,be=U&&[`expired`,`rejected`,`cancelled`].includes(U.status),xe=A?A.expiresAt-Q<6e4:!1,Se=A?xe?`${Math.max(0,Math.ceil((A.expiresAt-Q)/1e3))}s`:b.valid:``,$=e===`mobile`?{connect:a.mobileScan,connectHint:a.mobileScanHint,allowTitle:a.mobileAllowTitle,success:a.mobileSuccess,successHint:a.mobileSuccessHint}:{connect:a.browserConnect,connectHint:a.browserConnectHint,allowTitle:a.browserAllowTitle,success:a.browserSuccess,successHint:a.browserSuccessHint},Ce=e===`mobile`?a.mobilePrepareTitle:a.browserPrepareTitle,we=e===`mobile`?a.mobilePrepareHint:a.browserPrepareHint,Te=O?G?$.success:U?.status===`pending`?$.allowTitle:W||U?.status===`approved`?b.waiting:A?$.connect:b.title:Ce,Ee=j===`create`?b.createFailed:j===`decision`?b.decisionFailed:j===`background`?b.backgroundFailed:j===`download`?a.browserDownloadFailed:null,De=async()=>{P(!0),M(null);try{await le()}catch{M(`download`)}finally{R.current&&P(!1)}};return(0,K.jsxs)(_,{children:[(0,K.jsx)(h,{className:p(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,ee)}),(0,K.jsxs)(v,{className:p(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(600px,calc(100dvh-48px))] w-[min(560px,calc(100vw-32px))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay`,T),children:[(0,K.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between border-b border-edge-subtle px-6 py-3`,children:[(0,K.jsx)(`span`,{className:`text-lg font-semibold tracking-tight text-fg`,children:`xopc`}),(0,K.jsx)(`button`,{type:`button`,className:`flex size-10 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover`,"aria-label":b.cancel,onClick:t,children:(0,K.jsx)(d,{className:`size-4`})})]}),(0,K.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto px-8 py-7`,children:[G?(0,K.jsx)(s,{className:`mb-5 size-7 text-success`}):null,(0,K.jsx)(y,{className:`text-xl font-semibold tracking-tight text-fg`,children:Te}),(0,K.jsx)(g,{className:`mt-2 text-sm leading-relaxed text-fg-muted`,children:O?G?$.successHint:W?b.waitingForDevice:U?U.displayName:A?$.connectHint:b.intro:we}),Ee?(0,K.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-danger`,children:Ee}):null,O&&k.error?(0,K.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-danger`,children:b.readinessFailed}):null,O&&V.error?(0,K.jsx)(`p`,{role:`status`,className:`mt-4 text-sm text-warning`,children:b.statusUnavailable}):null,O?k.data?G?(0,K.jsxs)(K.Fragment,{children:[q.data?(0,K.jsxs)(`label`,{className:`mt-8 flex items-center justify-between gap-4 border-y border-edge-subtle py-5 text-sm text-fg`,children:[a.background,(0,K.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":q.data.runInBackground??!1,disabled:!q.data.backgroundSupported,checked:q.data.runInBackground??!1,className:`size-5 accent-accent`,onChange:e=>{window.electronAPI.system.setBehavior({runInBackground:e.target.checked}).then(e=>q.mutate(e.behavior)).catch(()=>M(`background`))}})]}):null,(0,K.jsx)(`p`,{className:`mt-4 text-xs text-fg-muted`,children:a.sleep})]}):be||ye?(0,K.jsxs)(`div`,{className:`mt-10 space-y-5`,children:[(0,K.jsx)(`p`,{className:`text-sm text-fg-muted`,children:ye||U?.status===`expired`?b.expired:b.declined}),(0,K.jsx)(C,{variant:`primary`,onClick:()=>void Z(),disabled:N,children:b.refresh})]}):U?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:b.scope}),(0,K.jsxs)(`p`,{className:`mt-10 font-mono text-4xl tracking-[0.16em] text-fg`,"aria-live":`polite`,children:[U.confirmationCode.slice(0,3),` `,U.confirmationCode.slice(3)]}),(0,K.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:b.compare}),(0,K.jsxs)(`details`,{className:`mt-6 text-xs text-fg-muted`,children:[(0,K.jsx)(`summary`,{className:`cursor-pointer py-2`,children:b.access}),(0,K.jsx)(`p`,{children:b.accessHint})]})]}):A?.targetKind===`mobile`?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`my-6 flex flex-col items-center`,children:[(0,K.jsx)(`div`,{className:`rounded-[1.75rem] border border-edge bg-surface-hover/55 p-2.5 shadow-surface`,children:(0,K.jsx)(`div`,{className:`rounded-[1.25rem] bg-white p-2 shadow-sm ring-1 ring-black/5`,children:Y.data?(0,K.jsx)(`img`,{src:Y.data,alt:a.qrAlt,width:240,height:240,className:`size-[240px] max-w-full rounded-xl bg-white`}):Y.error?null:(0,K.jsx)(w,{className:`size-[240px] rounded-xl`})})}),Y.error?null:(0,K.jsxs)(`p`,{className:p(`mt-4 inline-flex min-h-8 items-center gap-1.5 rounded-full px-3 text-xs font-medium`,xe?`bg-warning-soft text-warning`:`bg-surface-hover text-fg-muted`),"aria-live":`polite`,children:[(0,K.jsx)(c,{className:`size-3.5`,"aria-hidden":`true`}),Se]})]}),Y.error?(0,K.jsx)(`p`,{role:`status`,className:`text-center text-sm text-warning`,children:b.qrFailed}):null,Y.error?(0,K.jsx)(`div`,{className:`mt-5`,children:(0,K.jsx)(D,{text:A.universalLink,labels:{copy:a.copy,copied:a.copied,copyFailed:i.clipboard.copyFailed}})}):(0,K.jsxs)(`details`,{className:`group mx-auto mt-1 w-full max-w-sm rounded-xl border border-edge bg-surface-panel text-xs text-fg-muted`,children:[(0,K.jsxs)(`summary`,{className:`flex min-h-11 cursor-pointer list-none items-center justify-between gap-3 rounded-xl px-3.5 transition-colors hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent [&::-webkit-details-marker]:hidden`,children:[(0,K.jsx)(`span`,{children:b.fallback}),(0,K.jsx)(o,{className:`size-3.5 shrink-0 transition-transform group-open:rotate-90`,"aria-hidden":`true`})]}),(0,K.jsx)(`div`,{className:`border-t border-edge-subtle p-3`,children:(0,K.jsx)(D,{text:A.universalLink,labels:{copy:a.copy,copied:a.copied,copyFailed:i.clipboard.copyFailed}})})]})]}):A?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`ol`,{className:`mt-7 space-y-2 text-sm leading-6 text-fg-muted`,children:[(0,K.jsxs)(`li`,{children:[(0,K.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`1.`}),a.browserConnectStep1]}),(0,K.jsxs)(`li`,{children:[(0,K.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`2.`}),a.browserConnectStep2]}),(0,K.jsxs)(`li`,{children:[(0,K.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`3.`}),a.browserConnectStep3]})]}),(0,K.jsx)(`div`,{className:`mt-6`,children:(0,K.jsx)(D,{text:A.browserInvitation,labels:{copy:a.copy,copied:a.copied,copyFailed:i.clipboard.copyFailed}})}),(0,K.jsx)(`p`,{className:`mt-3 text-center text-xs text-fg-muted`,children:A.expiresAt-Q<6e4?`${Math.max(0,Math.ceil((A.expiresAt-Q)/1e3))}s`:b.valid})]}):k.data.ready?(0,K.jsx)(`div`,{className:`mt-8`,children:(0,K.jsx)(w,{className:`mx-auto size-[216px]`})}):(0,K.jsxs)(`div`,{className:`mt-6 flex flex-1 flex-col`,children:[I===`tailscale`?(0,K.jsx)(fe,{embedded:!0}):I===`https`?(0,K.jsx)(re,{}):I===`choices`?(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsx)(C,{variant:`secondary`,className:`w-full`,onClick:()=>L(`tailscale`),children:a.useTailscale}),(0,K.jsx)(C,{variant:`secondary`,className:`w-full`,onClick:()=>L(`https`),children:a.useOwnHttps})]}):(0,K.jsx)(me,{}),(0,K.jsx)(C,{variant:`ghost`,className:`mt-3 w-full`,onClick:()=>L(I?null:`choices`),children:I?b.back:b.existing})]}):(0,K.jsxs)(`div`,{className:`mt-8 space-y-4`,children:[(0,K.jsx)(w,{className:`h-5 w-3/4`}),(0,K.jsx)(w,{className:`h-40 w-full`})]}):e===`mobile`?(0,K.jsxs)(`div`,{className:`mt-7 flex flex-col items-center`,children:[ge.data?(0,K.jsx)(`img`,{src:ge.data,alt:a.mobileDownloadQrAlt,width:144,height:144,className:`size-36 rounded-lg bg-white`}):(0,K.jsx)(w,{className:`size-36`}),(0,K.jsxs)(C,{variant:`secondary`,className:`mt-5 w-full`,onClick:()=>void x(X),children:[(0,K.jsx)(u,{className:`size-4`}),a.mobileDownload]}),(0,K.jsx)(`p`,{className:`mt-3 text-center text-xs leading-5 text-fg-muted`,children:a.mobileDownloadHint})]}):(0,K.jsxs)(`div`,{className:`mt-7`,children:[(0,K.jsxs)(C,{variant:`secondary`,className:`w-full`,disabled:N,onClick:()=>void De(),children:[(0,K.jsx)(l,{className:`size-4`}),a.browserDownload]}),(0,K.jsxs)(`ol`,{className:`mt-5 space-y-3 text-sm leading-6 text-fg-muted`,children:[(0,K.jsxs)(`li`,{children:[(0,K.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`1.`}),a.browserInstallStep1]}),(0,K.jsxs)(`li`,{children:[(0,K.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`2.`}),a.browserInstallStep2]}),(0,K.jsxs)(`li`,{children:[(0,K.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`3.`}),a.browserInstallStep3]})]}),(0,K.jsxs)(`button`,{type:`button`,className:`mt-5 inline-flex items-center gap-1 text-xs text-accent hover:underline`,onClick:()=>void x(he),children:[a.browserInstallHelp,(0,K.jsx)(u,{className:`size-3`})]})]})]}),!O||k.error||G||U?.status===`pending`||j===`create`||j===`decision`?(0,K.jsx)(`footer`,{className:`shrink-0 px-8 pb-6`,children:O?G?(0,K.jsx)(C,{className:`w-full`,variant:`primary`,onClick:t,children:b.done}):U?.status===`pending`?(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsx)(C,{className:`w-full`,variant:`primary`,disabled:N,onClick:()=>void _e(`approve`),children:b.allow}),(0,K.jsx)(C,{className:`w-full`,variant:`ghost`,disabled:N,onClick:()=>void _e(`reject`),children:b.cancel})]}):k.error?(0,K.jsx)(C,{className:`w-full`,variant:`primary`,onClick:()=>void k.mutate(),children:b.retry}):(0,K.jsx)(C,{className:`w-full`,variant:`primary`,disabled:N,onClick:()=>void Z(),children:b.retry}):(0,K.jsx)(C,{className:`w-full`,variant:`primary`,onClick:()=>{M(null),te(!0)},children:e===`mobile`?a.mobileReady:a.browserReady})}):null]})]})}export{q as n,J as t};
|
|
@@ -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{h as i,t as a}from"./chunk-KS7C4IRE--EKdQGRF.js";import{n as o,r as s}from"./popover-select-DHC7J4lG.js";import{t as c}from"./messages-O0BEUKnx.js";import{t as l}from"./cn-0WouolD0.js";import{a as u,c as d,i as f,n as p,r as m}from"./locale-store-DMy9W6IG.js";import{r as h}from"./extension-provider-DWI0KAKT.js";import{i as g}from"./vendor-swr-BIWyz7Rc.js";import{t as _}from"./button-aIC072nz.js";import{a as v,o as y,s as b}from"./form-field-width-DJw_jULe.js";import{An as x,oi as S}from"./index-xTL-vb51.js";import{n as C,r as w}from"./settings-page-layout-Dx5S-Msc.js";import{n as T,t as E}from"./use-autosave-tY3keIbm.js";import{a as D,c as O,o as k}from"./voice-config-api-DrxBjSja.js";import{t as A}from"./voice-api-key-field-COTNLUU3.js";import{t as j}from"./schema-form-CwOFgsyh.js";var M=e(t(),1),N=n(),P=r();function F(e){let t=(0,N.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,P.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=r),r}function I(e){let t=e?.manifest?.mediaUnderstandingProviders?.[0];if(typeof t==`string`&&t.trim())return t.trim();let n=e?.manifest?.contracts?.mediaUnderstandingProviders?.[0];if(typeof n==`string`&&n.trim())return n.trim()}function L(){return l(y,v)}function R(){return l(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,b,`dark:border-edge`)}function z(e,t,n){if(!e||!t)return{apiKey:``,model:n};let r=e.stt.providers?.[t];return{apiKey:typeof r?.apiKey==`string`?r.apiKey:``,model:typeof r?.model==`string`?r.model:n}}function B({providerId:e,voiceSettings:t,mutateVoice:n}){let r=c(p(e=>e.language)),i=r.voiceSettings,a=r.extensionSttMedia,u={maskedHelp:i.apiKeyMaskedHelp,copy:i.apiKeyCopy,copied:i.apiKeyCopied,show:i.apiKeyShow,hide:i.apiKeyHide,notInConfigFile:i.apiKeyNotInConfigFile,loadFailed:i.apiKeyRevealFailed},{data:d}=g(m(`/api/voice/stt-providers`),k,{revalidateOnFocus:!1}),f=(0,M.useMemo)(()=>d?.providers.find(t=>t.id===e),[e,d]),h=f?.configured??!1,_=f?.models??[],y=_[0]?.id??f?.fields.find(e=>e.key===`model`)?.defaultValue??``,b=(0,M.useMemo)(()=>z(t,e,y),[y,e,t]),x=(0,M.useRef)(!1),[S,C]=(0,M.useState)(null),w=S??b,D=(0,M.useRef)(w);D.current=w;let j=b,N=E({value:w,dirty:w.apiKey!==j.apiKey||w.model!==j.model,onSave:(0,M.useCallback)(async r=>{let i=structuredClone(t);i.stt.enabled=!0,i.stt.provider=e,i.stt.providers={...i.stt.providers??{},[e]:{...i.stt.providers?.[e]??{},apiKey:r.apiKey,model:r.model}},await O(i),await n(i,!1),x.current=JSON.stringify(D.current)!==JSON.stringify(r),C(e=>e&&JSON.stringify(e)===JSON.stringify(r)?null:e)},[n,e,t])}),I=_.length>0?_:w.model?[{id:w.model,name:w.model}]:[];return(0,P.jsxs)(`div`,{className:`flex flex-col gap-4 rounded-xl bg-surface-base p-4`,onBlurCapture:N.onBlurCapture,children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:a.credentialsTitle}),(0,P.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:a.credentialsHint.replace(`{providerId}`,e)})]}),(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,P.jsx)(T,{status:N.status,error:N.error}),(0,P.jsx)(`span`,{className:l(`rounded-full px-2 py-0.5 text-xs font-medium`,h?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-amber-500/10 text-amber-800 dark:text-amber-200`),children:h?a.configured:a.notConfigured})]})]}),(0,P.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,P.jsxs)(`div`,{className:l(`flex flex-col gap-1.5`,v),children:[(0,P.jsx)(F,{children:i.stt.apiKey}),(0,P.jsx)(A,{kind:`stt`,providerId:e,fieldId:`ext-stt-${e}-api-key`,value:w.apiKey,onChange:e=>{x.current=!0,C(t=>({...t??b,apiKey:e}))},labels:u,placeholder:e===`groq`?`gsk_...`:`sk-...`}),(0,P.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[i.stt.apiKeyDesc,e===`groq`?` (GROQ_API_KEY)`:``]})]}),(0,P.jsxs)(`div`,{className:l(`flex flex-col gap-1.5`,v),children:[(0,P.jsx)(F,{children:i.stt.model}),I.length>0?(0,P.jsx)(o,{className:L(),value:w.model,onChange:e=>{x.current=!0,C(t=>({...t??b,model:e.target.value})),N.saveNow({...w,model:e.target.value})},children:I.map(e=>(0,P.jsx)(s,{value:e.id,children:e.name},e.id))}):(0,P.jsx)(`input`,{className:R(),value:w.model,onChange:e=>{x.current=!0,C(t=>({...t??b,model:e.target.value}))}})]})]})]})}function V(e){let t=(0,N.c)(13),{extensionId:n}=e,r=p(U),i=d(H),a;t[0]===n?a=t[1]:(a=()=>u(m(`/api/extensions/${encodeURIComponent(n)}`)),t[0]=n,t[1]=a);let{data:o,isLoading:s}=g(i&&n?`ext-stt-detail-${n}`:null,a),c;t[2]===o?c=t[3]:(c=I(o),t[2]=o,t[3]=c);let l=c,f;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(f={revalidateOnFocus:!1},t[4]=f):f=t[4];let{data:h,mutate:_,isLoading:v}=g(i?`voice-settings-ext-stt`:null,D,f);if(!i)return null;if(s||v){let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,P.jsx)(x,{rows:2}),t[5]=e):e=t[5],e}if(!l){let e=r===`zh`?`该扩展未声明 mediaUnderstandingProviders。`:`This extension does not declare mediaUnderstandingProviders.`,n;return t[6]===e?n=t[7]:(n=(0,P.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e}),t[6]=e,t[7]=n),n}if(!h)return null;let y=`${n}:${l}`,b;return t[8]!==_||t[9]!==l||t[10]!==y||t[11]!==h?(b=(0,P.jsx)(B,{providerId:l,voiceSettings:h,mutateVoice:_},y),t[8]=_,t[9]=l,t[10]=y,t[11]=h,t[12]=b):b=t[12],b}function H(e){return!!e.conversationId}function U(e){return e.language}function W(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function G(e){let t={};if(e.type!==`object`||!W(e.properties))return t;for(let[n,r]of Object.entries(e.properties))W(r)&&Object.prototype.hasOwnProperty.call(r,`default`)&&(t[n]=r.default);return t}function K(e,t){switch(t.type){case`sync`:return{localValues:t.value,isDirty:!1};case`change`:return{localValues:t.value,isDirty:!0};case`reset-defaults`:return{localValues:t.value,isDirty:!0};case`saved`:return JSON.stringify(e.localValues)===JSON.stringify(t.value)?{localValues:e.localValues,isDirty:!1}:e}}function q({extensionId:e}){let t=d(e=>!!e.conversationId),{data:n,error:r}=g(t&&e?`ext-detail-${e}`:null,()=>u(m(`/api/extensions/${encodeURIComponent(e)}`))),{data:i,mutate:a,error:o}=g(t&&e?`ext-cfg-${e}`:null,()=>u(m(`/api/extensions/${encodeURIComponent(e)}/config`))),s=n?.manifest?.configSchema,c=(0,M.useMemo)(()=>s&&s.type===`object`?G(s):{},[s]),l=(0,M.useMemo)(()=>({...c,...i??{}}),[c,i]),[p,h]=(0,M.useReducer)(K,{localValues:{},isDirty:!1}),v=(0,M.useRef)(!1),y=(0,M.useRef)(p.localValues);y.current=p.localValues;let b=(0,M.useRef)(l);!v.current&&b.current!==l&&(b.current=l,h({type:`sync`,value:l}));let x=(0,M.useCallback)(e=>{v.current=!0,h({type:`change`,value:e})},[]),S=(0,M.useCallback)(()=>{!s||s.type!==`object`||(v.current=!0,h({type:`reset-defaults`,value:{...G(s)}}))},[s]),C=(0,M.useCallback)(async t=>{if(!e)return;let n=await f(m(`/api/extensions/${encodeURIComponent(e)}/config`),{method:`PATCH`,body:JSON.stringify(t)});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error?.message??n.statusText)}await a(t,!1),h({type:`saved`,value:t}),v.current=JSON.stringify(y.current)!==JSON.stringify(t)},[e,a]),w=E({value:p.localValues,dirty:p.isDirty,onSave:C});if(!t)return null;if(r||o){let e=r??o;return(0,P.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[`Could not load extension settings: `,e instanceof Error?e.message:String(e)]})}return!s||s.type!==`object`?null:(0,P.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl bg-surface-hover/20 p-4`,onBlurCapture:w.onBlurCapture,children:[(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,P.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Configuration`}),(0,P.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,P.jsx)(T,{status:w.status,error:w.error}),(0,P.jsx)(_,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,onClick:S,children:`Reset to defaults`})]})]}),(0,P.jsx)(j,{schema:s,values:p.localValues,onChange:x})]})}function J(){let e=(0,N.c)(38),t=p(Y),n;e[0]===t?n=e[1]:(n=c(t),e[0]=t,e[1]=n);let r=n.extensionSttMedia,{extensionId:o,panelId:s}=i(),l=h();if(!o){let t;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,P.jsx)(X,{message:`No extension ID provided.`}),e[2]=t):t=e[2],t}let u,d,f;if(e[3]!==o||e[4]!==l||e[5]!==s){f=Symbol.for(`react.early_return_sentinel`);bb0:{let t;if(e[9]===o?t=e[10]:(t=e=>e.id===o,e[9]=o,e[10]=t),u=l.find(t),!u){let t=`Extension "${o}" not found or is not available in this workspace.`,n;e[11]===t?n=e[12]:(n=(0,P.jsx)(X,{message:t}),e[11]=t,e[12]=n),f=n;break bb0}let n=u.ui?.contributions?.settingsPanels;d=s?n?.find(e=>e.id===s||e.id===`${o}.${s}`):n?.[0]}e[3]=o,e[4]=l,e[5]=s,e[6]=u,e[7]=d,e[8]=f}else u=e[6],d=e[7],f=e[8];if(f!==Symbol.for(`react.early_return_sentinel`))return f;let m=d,g=!!(m&&u.ui),_=!!u.hasConfigSchema,v=u.kind===`media-provider`;if(!_&&!g&&!v){let t=`Extension "${o}" has no settings panels or config schema.`,n;return e[13]===t?n=e[14]:(n=(0,P.jsx)(X,{message:t}),e[13]=t,e[14]=n),n}let y=m?.title??`${u.name} Settings`,b;e[15]===y?b=e[16]:(b=(0,P.jsx)(C,{title:y}),e[15]=y,e[16]=b);let x;e[17]!==v||e[18]!==r?(x=v?(0,P.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg bg-surface-base px-4 py-3 text-sm`,children:[(0,P.jsx)(`p`,{className:`leading-relaxed text-fg-muted`,children:r.banner}),(0,P.jsx)(a,{to:`/settings/capabilities/voice`,className:`w-fit font-medium text-accent hover:underline`,children:r.openVoice})]}):null,e[17]=v,e[18]=r,e[19]=x):x=e[19];let T;e[20]!==o||e[21]!==v?(T=v?(0,P.jsx)(V,{extensionId:o}):null,e[20]=o,e[21]=v,e[22]=T):T=e[22];let E;e[23]!==o||e[24]!==_?(E=_?(0,P.jsx)(q,{extensionId:o}):null,e[23]=o,e[24]=_,e[25]=E):E=e[25];let D;e[26]!==u.name||e[27]!==u.ui||e[28]!==o||e[29]!==g||e[30]!==m?(D=g&&m&&u.ui?(0,P.jsx)(`div`,{className:`overflow-hidden rounded-xl bg-surface-base shadow-surface`,children:(0,P.jsx)(S,{extensionId:o,extensionName:u.name,entrypoint:m.entrypoint,permissions:u.ui?.permissions,title:m.title,className:`w-full`,minHeight:120,maxHeight:2e3})}):null,e[26]=u.name,e[27]=u.ui,e[28]=o,e[29]=g,e[30]=m,e[31]=D):D=e[31];let O;return e[32]!==b||e[33]!==x||e[34]!==T||e[35]!==E||e[36]!==D?(O=(0,P.jsxs)(w,{gap:`gap-5`,children:[b,x,T,E,D]}),e[32]=b,e[33]=x,e[34]=T,e[35]=E,e[36]=D,e[37]=O):O=e[37],O}function Y(e){return e.language}function X(e){let t=(0,N.c)(2),{message:n}=e,r;return t[0]===n?r=t[1]:(r=(0,P.jsx)(w,{gap:`gap-3`,children:(0,P.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n})}),t[0]=n,t[1]=r),r}export{J as ExtensionSettingsPage};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{p as e}from"./locale-store-DMy9W6IG.js";var t=e(()=>({connectionState:`idle`,error:null}));function n(e){t.setState(e)}export{t as n,n as t};
|
|
@@ -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{_ as i}from"./chunk-KS7C4IRE--EKdQGRF.js";import{n as a,r as o}from"./popover-select-DHC7J4lG.js";import{t as s}from"./circle-alert-BEjgurr2.js";import{t as c}from"./secret-input-BxWHx6J6.js";import{t as l}from"./loader-circle-CifKLtgG.js";import{t as u}from"./rotate-cw-LIg3Am9S.js";import{t as d}from"./messages-O0BEUKnx.js";import{t as f}from"./cn-0WouolD0.js";import{a as p,c as m,n as h,r as g}from"./locale-store-DMy9W6IG.js";import{i as _,o as v}from"./vendor-swr-BIWyz7Rc.js";import{t as y}from"./button-aIC072nz.js";import{n as b}from"./interaction-BdhHBbYa.js";import{n as x,r as S}from"./gateway-config-swr-CmYcOqhb.js";import{s as C}from"./form-field-width-DJw_jULe.js";import{n as w}from"./is-masked-secret-DOkL5b_X.js";import{t as T}from"./skeleton-BI5TyibZ.js";import{r as E}from"./settings-form-draft-Dy10ldo8.js";import{$o as D,Ea as O,Fo as k,Os as A,Qo as j,Un as M,ec as N,er as P,ja as F,ji as I,jn as ee,ls as L,nc as R,q as te,ts as ne}from"./index-xTL-vb51.js";import{t as z}from"./page-tabs-HLrKIjXH.js";import{t as B}from"./number-input-DDeqHK-G.js";import{n as re,r as ie,t as V}from"./settings-page-layout-Dx5S-Msc.js";import{n as ae,t as oe}from"./settings-form-section-num14vSv.js";import{t as se}from"./settings-advanced-gate-DCVaeBLW.js";var H=e(t(),1),U=n(),ce=18790,W={enabled:!0,maxAttempts:5,windowMs:9e5,blockDurationMs:3e5,exemptLoopback:!0};function G(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function K(e){return w(e)}async function le(e){let t=await p(g(`/api/gateway/reveal-auth-secret/${encodeURIComponent(e)}`),{method:`POST`,body:`{}`});if(!t.ok||!t.payload)throw Error(t.error?.message??`Reveal failed`);return t.payload}function q(e){return K(e)?``:e.trim()}function J(e){return[...e].map(e=>e.trim()).sort()}function ue(e){return JSON.stringify({bind:e.bind,customBindHost:e.customBindHost.trim(),port:e.port,auth:{mode:e.auth.mode,token:q(e.auth.token),password:q(e.auth.password),rateLimit:e.auth.rateLimit,trustedProxy:{userHeader:e.auth.trustedProxy.userHeader.trim(),requiredHeaders:J(e.auth.trustedProxy.requiredHeaders),allowUsers:J(e.auth.trustedProxy.allowUsers),allowLoopback:e.auth.trustedProxy.allowLoopback}},trustedProxies:J(e.trustedProxies),allowRealIpFallback:e.allowRealIpFallback,dangerouslyAllowHostHeaderOriginFallback:e.dangerouslyAllowHostHeaderOriginFallback})}function de(e,t){return ue(e)!==ue(t)}async function fe(e){return(await p(g(`/api/gateway/cors-origin-candidates?port=${encodeURIComponent(String(e))}`))).payload?.candidates??[]}function pe(e){return e===`none`||e===`token`||e===`password`||e===`trusted-proxy`?e:`token`}function me(e){let t=G(e)?e:{};return{enabled:t.enabled!==!1,maxAttempts:typeof t.maxAttempts==`number`&&Number.isFinite(t.maxAttempts)?Math.max(1,Math.floor(t.maxAttempts)):W.maxAttempts,windowMs:typeof t.windowMs==`number`&&Number.isFinite(t.windowMs)&&t.windowMs>0?Math.floor(t.windowMs):W.windowMs,blockDurationMs:typeof t.blockDurationMs==`number`&&Number.isFinite(t.blockDurationMs)&&t.blockDurationMs>0?Math.floor(t.blockDurationMs):typeof t.lockoutMs==`number`&&Number.isFinite(t.lockoutMs)&&t.lockoutMs>0?Math.floor(t.lockoutMs):W.blockDurationMs,exemptLoopback:t.exemptLoopback!==!1}}function Y(e){let t=G(e)?e:{};return{userHeader:typeof t.userHeader==`string`?t.userHeader:``,requiredHeaders:X(t.requiredHeaders,32),allowUsers:X(t.allowUsers,128),allowLoopback:t.allowLoopback===!0}}function he(e){return e===`auto`||e===`off`||e===`explicit`?e:`auto`}function X(e,t=24){return Array.isArray(e)?e.filter(e=>typeof e==`string`&&e.trim().length>0).map(e=>e.trim()).slice(0,t):[]}function ge(e){return e===`auto`||e===`loopback`||e===`lan`||e===`tailnet`||e===`custom`?e:`loopback`}function _e(e){if(e.bind===`loopback`)return!1;if(e.bind===`lan`)return!0;if(e.bind===`custom`){let t=e.customBindHost.trim().toLowerCase();return t?t!==`127.0.0.1`&&t!==`localhost`&&t!==`::1`:!0}return!0}function ve(e){let t=_e(e);return t&&e.auth.mode===`none`?`Network-accessible gateway requires authentication (token, password, or trusted-proxy).`:t&&e.auth.mode===`trusted-proxy`&&e.trustedProxies.length===0?`Trusted-proxy auth on a network bind requires at least one gateway.trustedProxies entry.`:e.auth.mode===`trusted-proxy`&&!e.auth.trustedProxy.userHeader.trim()?`Trusted-proxy auth requires gateway.auth.trustedProxy.userHeader.`:t&&e.corsOrigins.includes(`*`)?`CORS wildcard "*" is not allowed on network-accessible binds.`:e.bind===`custom`&&!e.customBindHost.trim()?`Custom bind mode requires a bind address.`:null}function ye(e){let t=G(e)?e:{},n=G(t.gateway)?t.gateway:{},r=G(n.auth)?n.auth:{},i=G(n.security)?n.security:{},a=G(t.update)?t.update:{},o=G(a.auto)?a.auto:{},s=a.channel,c=s===`beta`||s===`dev`||s===`stable`?s:`stable`,l=Array.isArray(n.corsOrigins)?n.corsOrigins.filter(e=>typeof e==`string`&&e.trim().length>0):[];return{bind:ge(n.bind),customBindHost:typeof n.customBindHost==`string`&&n.customBindHost.trim()?n.customBindHost.trim():``,port:typeof n.port==`number`&&Number.isFinite(n.port)?Math.floor(n.port):ce,auth:{mode:pe(r.mode),token:typeof r.token==`string`?r.token:``,password:typeof r.password==`string`?r.password:``,rateLimit:me(r.rateLimit),trustedProxy:Y(r.trustedProxy)},corsOrigins:l,trustedProxies:X(n.trustedProxies,64),allowRealIpFallback:n.allowRealIpFallback===!0,dangerouslyAllowHostHeaderOriginFallback:n.dangerouslyAllowHostHeaderOriginFallback===!0,securityStrict:i.strict===!0,channelConnectDeferMode:he(n.channelConnectDeferMode),channelConnectDeferIds:X(n.channelConnectDeferIds),channelConnectDeferSkipIds:X(n.channelConnectDeferSkipIds),updateChannel:c,updateCheckOnStart:a.checkOnStart!==!1,updateAutoEnabled:o.enabled===!0,updateAutoStableDelayHours:typeof o.stableDelayHours==`number`&&Number.isFinite(o.stableDelayHours)?Math.max(0,Math.floor(o.stableDelayHours)):6,updateAutoStableJitterHours:typeof o.stableJitterHours==`number`&&Number.isFinite(o.stableJitterHours)?Math.max(0,Math.floor(o.stableJitterHours)):12,updateAutoBetaCheckIntervalHours:typeof o.betaCheckIntervalHours==`number`&&Number.isFinite(o.betaCheckIntervalHours)?Math.max(.25,o.betaCheckIntervalHours):1}}function be(e){let t={mode:e.auth.mode,rateLimit:e.auth.rateLimit};if(e.auth.mode===`token`){let n=e.auth.token.trim();n.length>0&&!K(n)&&(t.token=e.auth.token),t.password=null,t.trustedProxy=null}else if(e.auth.mode===`password`){let n=e.auth.password.trim();n.length>0&&!K(n)&&(t.password=e.auth.password),t.token=null,t.trustedProxy=null}else if(e.auth.mode===`trusted-proxy`){t.token=null,t.password=null;let n=e.auth.trustedProxy;t.trustedProxy={userHeader:n.userHeader.trim(),...n.requiredHeaders.length>0?{requiredHeaders:n.requiredHeaders}:{},...n.allowUsers.length>0?{allowUsers:n.allowUsers}:{},...n.allowLoopback?{allowLoopback:!0}:{}}}else t.token=null,t.password=null,t.trustedProxy=null;return t}async function xe(e){let t=ve(e);if(t)throw Error(t);await p(g(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{bind:e.bind,...e.bind===`custom`?{customBindHost:e.customBindHost.trim()}:{},port:e.port,auth:be(e),corsOrigins:e.corsOrigins,trustedProxies:e.trustedProxies,allowRealIpFallback:e.allowRealIpFallback,dangerouslyAllowHostHeaderOriginFallback:e.dangerouslyAllowHostHeaderOriginFallback,security:{strict:e.securityStrict},channelConnectDeferMode:e.channelConnectDeferMode,channelConnectDeferIds:e.channelConnectDeferIds,channelConnectDeferSkipIds:e.channelConnectDeferSkipIds},update:{channel:e.updateChannel,checkOnStart:e.updateCheckOnStart,auto:{enabled:e.updateAutoEnabled,stableDelayHours:e.updateAutoStableDelayHours,stableJitterHours:e.updateAutoStableJitterHours,betaCheckIntervalHours:e.updateAutoBetaCheckIntervalHours}}})}),x()}var Se={critical:3,warn:2,info:1};function Ce(){return g(`/api/doctor?security=true`)}function we(e){return e.toSorted((e,t)=>Se[t.severity]-Se[e.severity]||e.checkId.localeCompare(t.checkId))}function Te(e){let t=e?.checks?.find(e=>e.id===`security-audit`);if(!t)return{status:`skip`,message:`Security audit unavailable.`,hints:[],findings:[]};let n=we((t.findings??[]).filter(e=>typeof e.checkId==`string`&&(e.severity===`critical`||e.severity===`warn`||e.severity===`info`)&&typeof e.title==`string`&&typeof e.detail==`string`));return{status:t.status,message:t.message,hints:Array.isArray(t.hints)?t.hints.filter(e=>typeof e==`string`):[],findings:n}}async function Ee(){return Te(await p(Ce()))}var Z=r();function De(e){let t=(0,U.c)(39),{enabled:n,refreshToken:r}=e,i=r===void 0?0:r,a=h(ke),o;t[0]===a?o=t[1]:(o=d(a),t[0]=a,t[1]=o);let s=o.gatewaySettings,c;t[2]!==n||t[3]!==i?(c=n?[Ce(),i]:null,t[2]=n,t[3]=i,t[4]=c):c=t[4];let u;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(u={revalidateOnFocus:!1},t[5]=u):u=t[5];let{data:f,error:p,isLoading:m,isValidating:g,mutate:b}=_(c,Oe,u),x=f??null,S=p instanceof Error?p.message:p?String(p):null,C=m||g,w;t[6]===b?w=t[7]:(w=()=>{b(),v(Ce())},t[6]=b,t[7]=w);let E=w,D=!n||C,O;t[8]===C?O=t[9]:(O=C?(0,Z.jsx)(l,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(L,{className:`size-3.5`,"aria-hidden":!0}),t[8]=C,t[9]=O);let k;t[10]===s.securityAuditRefresh?k=t[11]:(k=(0,Z.jsx)(`span`,{className:`ml-1.5`,children:s.securityAuditRefresh}),t[10]=s.securityAuditRefresh,t[11]=k);let A;t[12]!==E||t[13]!==D||t[14]!==O||t[15]!==k?(A=(0,Z.jsxs)(y,{type:`button`,variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:D,onClick:E,children:[O,k]}),t[12]=E,t[13]=D,t[14]=O,t[15]=k,t[16]=A):A=t[16];let j;t[17]!==s.securityAuditSubtitle||t[18]!==s.securityAuditTitle||t[19]!==A?(j=(0,Z.jsx)(ae,{icon:ne,title:s.securityAuditTitle,subtitle:s.securityAuditSubtitle,trailing:A}),t[17]=s.securityAuditSubtitle,t[18]=s.securityAuditTitle,t[19]=A,t[20]=j):j=t[20];let M;t[21]===s.securityAuditSavedConfigHint?M=t[22]:(M=(0,Z.jsx)(`p`,{className:`mb-4 text-xs text-fg-subtle`,children:s.securityAuditSavedConfigHint}),t[21]=s.securityAuditSavedConfigHint,t[22]=M);let N;t[23]!==S||t[24]!==s.securityAuditLoadError?(N=S?(0,Z.jsxs)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,role:`alert`,children:[s.securityAuditLoadError,`: `,S]}):null,t[23]=S,t[24]=s.securityAuditLoadError,t[25]=N):N=t[25];let P;t[26]!==x||t[27]!==S||t[28]!==C?(P=!S&&C&&!x?(0,Z.jsxs)(`div`,{className:`space-y-2`,"aria-busy":`true`,children:[(0,Z.jsx)(T,{className:`h-11 w-full rounded-lg`}),(0,Z.jsx)(T,{className:`h-10 w-full rounded-lg`})]}):null,t[26]=x,t[27]=S,t[28]=C,t[29]=P):P=t[29];let F;t[30]!==x||t[31]!==s?(F=x?(0,Z.jsx)(Ae,{g:s,audit:x}):null,t[30]=x,t[31]=s,t[32]=F):F=t[32];let I;return t[33]!==j||t[34]!==M||t[35]!==N||t[36]!==P||t[37]!==F?(I=(0,Z.jsxs)(oe,{children:[j,M,N,P,F]}),t[33]=j,t[34]=M,t[35]=N,t[36]=P,t[37]=F,t[38]=I):I=t[38],I}function Oe(){return Ee()}function ke(e){return e.language}function Ae(e){let t=(0,U.c)(40),{g:n,audit:r}=e,i,a,o,s,c,l,u;t[0]!==r.findings||t[1]!==r.status||t[2]!==n?(a=Pe(n,r.status,r.findings),u=`space-y-4`,c=f(`rounded-lg px-3 py-2.5 text-sm`,a.bannerClass),l=`status`,s=`flex items-start gap-2`,i=a.icon,o=f(`mt-0.5 size-4 shrink-0`,a.iconClass),t[0]=r.findings,t[1]=r.status,t[2]=n,t[3]=i,t[4]=a,t[5]=o,t[6]=s,t[7]=c,t[8]=l,t[9]=u):(i=t[3],a=t[4],o=t[5],s=t[6],c=t[7],l=t[8],u=t[9]);let d;t[10]!==i||t[11]!==o?(d=(0,Z.jsx)(i,{className:o,"aria-hidden":!0}),t[10]=i,t[11]=o,t[12]=d):d=t[12];let p;t[13]===a.title?p=t[14]:(p=(0,Z.jsx)(`p`,{className:`font-medium`,children:a.title}),t[13]=a.title,t[14]=p);let m;t[15]===r.message?m=t[16]:(m=(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs opacity-90`,children:r.message}),t[15]=r.message,t[16]=m);let h;t[17]!==p||t[18]!==m?(h=(0,Z.jsxs)(`div`,{children:[p,m]}),t[17]=p,t[18]=m,t[19]=h):h=t[19];let g;t[20]!==s||t[21]!==d||t[22]!==h?(g=(0,Z.jsxs)(`div`,{className:s,children:[d,h]}),t[20]=s,t[21]=d,t[22]=h,t[23]=g):g=t[23];let _;t[24]!==g||t[25]!==c||t[26]!==l?(_=(0,Z.jsx)(`div`,{className:c,role:l,children:g}),t[24]=g,t[25]=c,t[26]=l,t[27]=_):_=t[27];let v;t[28]!==r.findings||t[29]!==r.status||t[30]!==n?(v=r.findings.length>0?(0,Z.jsx)(`ul`,{className:`space-y-2`,children:r.findings.map(e=>(0,Z.jsx)(Me,{g:n,finding:e},e.checkId))}):r.status===`pass`||r.status===`skip`?(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.securityAuditNoFindings}):null,t[28]=r.findings,t[29]=r.status,t[30]=n,t[31]=v):v=t[31];let y;t[32]!==r.hints||t[33]!==n?(y=r.hints.length>0?(0,Z.jsxs)(`div`,{className:`space-y-1 rounded-lg bg-surface-panel/50 px-3 py-2.5`,children:[(0,Z.jsx)(`p`,{className:`text-xs font-medium text-fg-muted`,children:n.securityAuditHintsTitle}),(0,Z.jsx)(`ul`,{className:`space-y-1 text-xs text-fg-subtle`,children:r.hints.map(je)})]}):null,t[32]=r.hints,t[33]=n,t[34]=y):y=t[34];let b;return t[35]!==_||t[36]!==v||t[37]!==y||t[38]!==u?(b=(0,Z.jsxs)(`div`,{className:u,children:[_,v,y]}),t[35]=_,t[36]=v,t[37]=y,t[38]=u,t[39]=b):b=t[39],b}function je(e){return(0,Z.jsx)(`li`,{className:`font-mono`,children:e},e)}function Me(e){let t=(0,U.c)(31),{g:n,finding:r}=e,i,a,o,s;if(t[0]!==r.severity){let e=Ne(r.severity);s=`rounded-lg bg-surface-panel/70 px-3 py-2.5 shadow-surface`,o=`flex items-start gap-2`,i=e.icon,a=f(`mt-0.5 size-4 shrink-0`,e.iconClass),t[0]=r.severity,t[1]=i,t[2]=a,t[3]=o,t[4]=s}else i=t[1],a=t[2],o=t[3],s=t[4];let c;t[5]!==i||t[6]!==a?(c=(0,Z.jsx)(i,{className:a,"aria-hidden":!0}),t[5]=i,t[6]=a,t[7]=c):c=t[7];let l;t[8]===r.title?l=t[9]:(l=(0,Z.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:r.title}),t[8]=r.title,t[9]=l);let u;t[10]===r.checkId?u=t[11]:(u=(0,Z.jsx)(`span`,{className:`font-mono text-[0.65rem] text-fg-subtle`,children:r.checkId}),t[10]=r.checkId,t[11]=u);let d;t[12]!==l||t[13]!==u?(d=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5`,children:[l,u]}),t[12]=l,t[13]=u,t[14]=d):d=t[14];let p;t[15]===r.detail?p=t[16]:(p=(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:r.detail}),t[15]=r.detail,t[16]=p);let m;t[17]!==r.remediation||t[18]!==n?(m=r.remediation?(0,Z.jsxs)(`p`,{className:`mt-1.5 text-xs text-fg-subtle`,children:[(0,Z.jsx)(`span`,{className:`text-fg-muted`,children:n.securityAuditRemediation}),` `,r.remediation]}):null,t[17]=r.remediation,t[18]=n,t[19]=m):m=t[19];let h;t[20]!==d||t[21]!==p||t[22]!==m?(h=(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[d,p,m]}),t[20]=d,t[21]=p,t[22]=m,t[23]=h):h=t[23];let g;t[24]!==h||t[25]!==o||t[26]!==c?(g=(0,Z.jsxs)(`div`,{className:o,children:[c,h]}),t[24]=h,t[25]=o,t[26]=c,t[27]=g):g=t[27];let _;return t[28]!==g||t[29]!==s?(_=(0,Z.jsx)(`li`,{className:s,children:g}),t[28]=g,t[29]=s,t[30]=_):_=t[30],_}function Ne(e){switch(e){case`critical`:return{icon:s,iconClass:`text-red-600 dark:text-red-400`};case`warn`:return{icon:k,iconClass:`text-amber-600 dark:text-amber-400`};default:return{icon:R,iconClass:`text-fg-muted`}}}function Pe(e,t,n){let r=n.filter(e=>e.severity===`critical`).length,i=n.filter(e=>e.severity===`warn`).length;return t===`fail`||r>0?{icon:s,iconClass:`text-red-600 dark:text-red-400`,title:e.securityAuditStatusFail,bannerClass:`bg-red-50 text-red-950 dark:bg-red-950/40 dark:text-red-100`}:t===`warn`||i>0?{icon:k,iconClass:`text-amber-600 dark:text-amber-400`,title:e.securityAuditStatusWarn,bannerClass:`bg-amber-50 text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`}:t===`skip`?{icon:R,iconClass:`text-fg-muted`,title:e.securityAuditStatusSkip,bannerClass:`bg-surface-base/55 text-fg`}:{icon:ne,iconClass:`text-emerald-600 dark:text-emerald-400`,title:e.securityAuditStatusPass,bannerClass:`bg-emerald-50 text-emerald-950 dark:bg-emerald-950/40 dark:text-emerald-100`}}var Fe=new Set([`security`,`advanced`]);function Ie(e,t){return t===`advanced`?!0:!Fe.has(e)}function Le(e,t){return e.filter(e=>Ie(e,t))}function Re(){return`network`}function ze(e,t){let n=(0,U.c)(5),r=M(Be),i,a;n[0]!==e||n[1]!==r||n[2]!==t?(i=()=>{Ie(e,r)||t(Re())},a=[e,r,t],n[0]=e,n[1]=r,n[2]=t,n[3]=i,n[4]=a):(i=n[3],a=n[4]),(0,H.useEffect)(i,a)}function Be(e){return e.mode}function Q(){return f(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,C,`dark:border-edge`)}var Ve=[`network`,`access`,`updates`,`security`,`advanced`],He={network:A,access:N,updates:L,security:D,advanced:j};function Ue(e){return e&&Ve.includes(e)?e:`network`}function We(e,t){return t===`network`?e.tabNetwork:t===`access`?e.tabAccess:t===`updates`?e.tabUpdates:t===`security`?e.tabSecurity:e.tabAdvanced}function Ge(e,t){return t===`network`?e.networkTabHint:t===`access`?e.accessTabHint:t===`updates`?e.updatesTabHint:t===`security`?e.securitySectionHint:e.advancedSectionHint}function Ke(e,t){switch(t.type){case`reset`:return{form:null,baseline:null,appliedBaseline:null};case`init-applied`:return{...e,appliedBaseline:structuredClone(t.value)};case`sync`:{let n=structuredClone(t.value);return{form:n,baseline:structuredClone(n),appliedBaseline:e.appliedBaseline}}case`set-form`:return e.form?{...e,form:t.updater(e.form)}:e;case`discard`:return e.baseline?{...e,form:structuredClone(e.baseline)}:e;case`saved`:{let n=structuredClone(t.value);return{form:n,baseline:structuredClone(n),appliedBaseline:e.appliedBaseline}}}}var qe={saving:!1,error:null,saveOk:!1,auditRefreshToken:0,restarting:!1,restartConfirmOpen:!1};function Je(){let e=m(e=>e.baseUrl),t=h(e=>e.language),n=d(t),r=n.gatewaySettings,[c,p]=i(),g=M(e=>e.mode),v=g===`advanced`,b=Ue(c.get(`tab`)),x=(0,H.useMemo)(()=>Le(Ve,g),[g]),C=(0,H.useCallback)(e=>{p(t=>{let n=new URLSearchParams(t);return e===`network`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},[p]);ze(b,C);let w=m(e=>e.conversationId),T=m(e=>e.tokenExpired),D=m(e=>e.openTokenDialog),k=!!w,[A,j]=(0,H.useReducer)(Ke,{form:null,baseline:null,appliedBaseline:null}),N=A.form,L=A.baseline,R=A.appliedBaseline,[ne,z]=(0,H.useReducer)(E,qe),{saving:V,error:ae,auditRefreshToken:oe,restarting:U,restartConfirmOpen:ce}=ne,W=(0,H.useRef)(!1),G=(0,H.useRef)(null),K=(0,H.useRef)(!1),{data:q,error:J,isLoading:ue,mutate:pe}=S(k),me=_(k&&N?[`gateway-cors-origin-candidates`,N.port]:null,([,e])=>fe(e),{revalidateOnFocus:!1}),Y=(0,H.useMemo)(()=>q?.payload?.config===void 0?null:structuredClone(ye(q.payload.config)),[q]);k?Y!==null&&(K.current||(K.current=!0,j({type:`init-applied`,value:Y})),!W.current&&G.current!==Y&&(G.current=Y,j({type:`sync`,value:Y}),z({type:`patch`,patch:{saveOk:!1}}))):(G.current!==null||K.current)&&(G.current=null,K.current=!1,j({type:`reset`}),W.current=!1);let he=!!(k&&ue&&q===void 0&&!J),X=J instanceof Error?J.message:J?String(J):null,ge=(0,H.useMemo)(()=>!N||!L?!1:JSON.stringify(N)!==JSON.stringify(L),[N,L]),_e=(0,H.useMemo)(()=>!L||!R?!1:de(R,L),[R,L]),be=(0,H.useCallback)(e=>{W.current=!0,j({type:`set-form`,updater:t=>({...t,auth:{...t.auth,...e}})})},[]),Se=(0,H.useCallback)(e=>{W.current=!0,j({type:`set-form`,updater:t=>({...t,updateChannel:e})})},[]),Ce=(0,H.useCallback)(e=>{W.current=!0,j({type:`set-form`,updater:t=>({...t,corsOrigins:e})})},[]),we=(0,H.useCallback)(e=>{W.current=!0,j({type:`set-form`,updater:t=>({...t,bind:e})})},[]),Te=(0,H.useCallback)(e=>{W.current=!0,j({type:`set-form`,updater:t=>({...t,customBindHost:e,bind:`custom`})})},[]),Ee=(0,H.useCallback)(e=>{W.current=!0,j({type:`set-form`,updater:t=>({...t,port:e})})},[]),Oe=(0,H.useCallback)(e=>{W.current=!0,j({type:`set-form`,updater:t=>({...t,auth:{...t.auth,rateLimit:{...t.auth.rateLimit,...e}}})})},[]),ke=(0,H.useCallback)(e=>{W.current=!0,j({type:`set-form`,updater:t=>({...t,channelConnectDeferMode:e})})},[]),Ae=(0,H.useCallback)(e=>{W.current=!0,j({type:`set-form`,updater:t=>({...t,channelConnectDeferIds:e})})},[]),je=(0,H.useCallback)(e=>{W.current=!0,j({type:`set-form`,updater:t=>({...t,channelConnectDeferSkipIds:e})})},[]),Me=(0,H.useCallback)(e=>{W.current=!0,j({type:`set-form`,updater:t=>({...t,trustedProxies:e})})},[]),Ne=(0,H.useCallback)(e=>{W.current=!0,j({type:`set-form`,updater:t=>({...t,auth:{...t.auth,trustedProxy:{...t.auth.trustedProxy,...e}}})})},[]),Pe=(0,H.useCallback)(e=>{W.current=!0,j({type:`set-form`,updater:t=>({...t,securityStrict:e})})},[]),Fe=(0,H.useCallback)(e=>{W.current=!0,j({type:`set-form`,updater:t=>({...t,allowRealIpFallback:e})})},[]),Ie=(0,H.useCallback)(e=>{W.current=!0,j({type:`set-form`,updater:t=>({...t,dangerouslyAllowHostHeaderOriginFallback:e})})},[]),Re=(0,H.useCallback)(async()=>{if(!N||V)return;let e=ve(N);if(e){z({type:`patch`,patch:{error:e}});return}z({type:`patch`,patch:{saving:!0,error:null,saveOk:!1}});try{await xe(N),W.current=!1,j({type:`saved`,value:N}),z({type:`patch`,patch:{saveOk:!0,auditRefreshToken:oe+1}})}catch(e){z({type:`patch`,patch:{error:e instanceof Error?e.message:r.saveError}})}finally{z({type:`patch`,patch:{saving:!1}})}},[N,V,r.saveError]),Be=(0,H.useCallback)(()=>{L&&(W.current=!1,j({type:`discard`}),z({type:`patch`,patch:{error:null,saveOk:!1}}))},[L]),He=F(r),We=(0,H.useCallback)(async()=>{if(!U){z({type:`patch`,patch:{restarting:!0,restartConfirmOpen:!1}});try{let e=await P();e.ok?window.dispatchEvent(new Event(`gateway-restart-initiated`)):z({type:`patch`,patch:{error:e.message||r.restartGatewayFailed}})}catch(e){z({type:`patch`,patch:{error:e instanceof Error?e.message:String(e)}})}finally{z({type:`patch`,patch:{restarting:!1}})}}},[U,r.restartGatewayFailed]);return k?he?(0,Z.jsx)(ie,{gap:`gap-6`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:(0,Z.jsx)(ee,{sections:3})}):N?(0,Z.jsxs)(ie,{gap:`gap-6`,children:[(0,Z.jsx)(re,{title:n.settingsSections.gateway,docsLink:O(t,`gateway`),docsLabel:r.docsLink,actions:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(y,{type:`button`,variant:`secondary`,disabled:!ge||V,onClick:Be,children:r.discard}),(0,Z.jsx)(y,{type:`button`,variant:`primary`,disabled:!ge||V,onClick:()=>void Re(),children:V?r.saving:r.save})]})}),T?(0,Z.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-lg bg-red-50 px-4 py-3 dark:bg-red-950/40`,role:`alert`,children:[(0,Z.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Z.jsx)(s,{className:`mt-0.5 size-4 shrink-0 text-red-600 dark:text-red-400`}),(0,Z.jsx)(`p`,{className:`text-sm text-red-900 dark:text-red-100`,children:r.tokenExpired})]}),(0,Z.jsx)(`div`,{children:(0,Z.jsx)(y,{type:`button`,variant:`secondary`,className:`text-sm`,onClick:()=>D(),children:r.updateToken})})]}):null,ae?(0,Z.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:ae}):null,_e?(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-lg bg-amber-50 px-3 py-2 dark:bg-amber-950/40`,children:[(0,Z.jsx)(`p`,{className:`text-xs text-amber-950 dark:text-amber-100`,children:r.restartHint}),(0,Z.jsxs)(y,{type:`button`,variant:`secondary`,className:`shrink-0 gap-1.5 border-red-300 bg-red-50 text-xs text-red-700 hover:bg-red-100 dark:border-red-800 dark:bg-red-950/50 dark:text-red-300 dark:hover:bg-red-900/60`,disabled:U,onClick:()=>z({type:`patch`,patch:{restartConfirmOpen:!0}}),children:[U?(0,Z.jsx)(l,{className:`size-3.5 animate-spin`}):(0,Z.jsx)(u,{className:`size-3.5`}),r.restartGatewayButton]})]}):null,(0,Z.jsx)(I,{open:ce,title:r.restartGatewayButton,description:r.restartGatewayConfirm,confirmLabel:r.restartGatewayButton,cancelLabel:r.discard,destructive:!0,onConfirm:()=>void We(),onCancel:()=>z({type:`patch`,patch:{restartConfirmOpen:!1}})}),(0,Z.jsx)(De,{enabled:k,refreshToken:oe}),(0,Z.jsx)(Ye,{g:r,activeTab:b,visibleTabs:x,onChange:C}),(0,Z.jsxs)(Xe,{g:r,id:`network`,activeTab:b,children:[(0,Z.jsxs)(`section`,{className:`space-y-3 rounded-xl bg-surface-hover/20 p-4`,children:[(0,Z.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t===`zh`?`当前服务连接`:`Current service connection`}),(0,Z.jsx)(`p`,{className:`break-all text-sm text-fg-muted`,children:e}),(0,Z.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,Z.jsx)(y,{type:`button`,variant:`secondary`,onClick:()=>void pe(),children:r.retry}),(0,Z.jsx)(y,{type:`button`,variant:`secondary`,onClick:()=>D(),children:r.updateToken}),(0,Z.jsx)(y,{type:`button`,variant:`secondary`,onClick:()=>z({type:`patch`,patch:{restartConfirmOpen:!0}}),children:r.restartGatewayButton})]})]}),(0,Z.jsxs)(te,{title:t===`zh`?`服务监听配置`:`Service listener configuration`,summary:`${N.bind} · ${N.port}`,children:[(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`gateway-bind-mode`,children:r.bindMode}),(0,Z.jsxs)(a,{id:`gateway-bind-mode`,className:Q(),value:N.bind,onChange:e=>we(e.target.value),children:[(0,Z.jsx)(o,{value:`loopback`,children:r.bindLoopback}),v?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(o,{value:`lan`,children:r.bindLan}),(0,Z.jsx)(o,{value:`auto`,children:r.bindAuto}),(0,Z.jsx)(o,{value:`custom`,children:r.bindCustom}),(0,Z.jsx)(o,{value:`tailnet`,children:r.bindTailnet})]}):null]})]}),N.bind===`custom`?(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`gateway-custom-bind-host`,children:r.customBindHost}),(0,Z.jsx)(`input`,{id:`gateway-custom-bind-host`,className:f(Q(),`font-mono text-xs`),value:N.customBindHost,onChange:e=>Te(e.target.value),placeholder:r.customBindHostPlaceholder,autoComplete:`off`})]}):null,(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`gateway-listen-port`,children:r.listenPort}),(0,Z.jsx)(B,{id:`gateway-listen-port`,type:`number`,min:1,max:65535,className:f(Q(),`font-mono text-xs`),value:N.port,onChange:e=>{let t=Number(e.target.value);Ee(Number.isFinite(t)?Math.max(1,Math.min(65535,Math.floor(t))):N.port)}})]})]}),(0,Z.jsx)(se,{children:(0,Z.jsx)(et,{g:r,origins:N.corsOrigins,candidates:me.data??[],onChange:Ce})})]})]}),(0,Z.jsxs)(Xe,{g:r,id:`access`,activeTab:b,children:[N.auth.mode===`none`?(0,Z.jsx)(`p`,{className:`rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:r.authModeNone}):null,(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`gateway-auth-mode`,children:r.authMode}),(0,Z.jsxs)(a,{id:`gateway-auth-mode`,value:N.auth.mode,onChange:e=>be({mode:e.target.value}),className:Q(),children:[(0,Z.jsx)(o,{value:`token`,children:r.authModeToken}),(0,Z.jsx)(o,{value:`password`,children:r.authModePassword}),v||N.auth.mode===`trusted-proxy`||N.auth.mode===`none`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(o,{value:`trusted-proxy`,children:r.authModeTrustedProxy}),(0,Z.jsx)(o,{value:`none`,children:r.authModeNoneLabel})]}):null]})]}),(0,Z.jsx)(se,{children:N.auth.mode===`trusted-proxy`?(0,Z.jsx)(Qe,{g:r,form:N,onTrustedProxyChange:Ne,onTrustedProxiesChange:Me,onAllowRealIpFallbackChange:Fe}):null}),N.auth.mode===`token`?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(it,{id:`gateway-access-token`,label:r.accessToken,help:r.tokenHelp,placeholder:r.tokenPlaceholder,value:N.auth.token,labels:He,reveal:()=>le(`token`).then(e=>e.secret),loadFailedLabel:r.saveError,onChange:e=>be({token:e})}),(0,Z.jsx)(y,{type:`button`,variant:`secondary`,className:`w-full sm:w-auto`,onClick:()=>D(),children:r.changeToken})]}):null,N.auth.mode===`password`?(0,Z.jsx)(it,{id:`gateway-auth-password`,label:r.authPassword,help:r.authPasswordHelp,placeholder:r.authPasswordPlaceholder,value:N.auth.password,labels:He,reveal:()=>le(`password`).then(e=>e.secret),loadFailedLabel:r.saveError,onChange:e=>be({password:e})}):null,(0,Z.jsx)(se,{children:N.auth.mode===`none`?null:(0,Z.jsx)(rt,{g:r,rateLimit:N.auth.rateLimit,onChange:Oe})})]}),(0,Z.jsxs)(Xe,{g:r,id:`updates`,activeTab:b,children:[(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`gateway-update-channel`,children:r.updateChannel}),(0,Z.jsxs)(a,{id:`gateway-update-channel`,value:N.updateChannel,onChange:e=>Se(e.target.value),className:Q(),children:[(0,Z.jsx)(o,{value:`stable`,children:r.channelStable}),v||N.updateChannel===`beta`?(0,Z.jsx)(o,{value:`beta`,children:r.channelBeta}):null,v||N.updateChannel===`dev`?(0,Z.jsx)(o,{value:`dev`,children:r.channelDev}):null]})]}),(0,Z.jsxs)(`div`,{className:`space-y-4 rounded-xl bg-surface-base/45 p-4`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:r.updateAutoSection}),(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:N.updateCheckOnStart,onChange:e=>{W.current=!0,j({type:`set-form`,updater:t=>({...t,updateCheckOnStart:e.target.checked})})}}),(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`span`,{className:`font-medium`,children:r.updateCheckOnStart}),(0,Z.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:r.updateCheckOnStartHint})]})]}),(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:N.updateAutoEnabled,onChange:e=>{W.current=!0,j({type:`set-form`,updater:t=>({...t,updateAutoEnabled:e.target.checked})})}}),(0,Z.jsxs)(`span`,{children:[(0,Z.jsx)(`span`,{className:`font-medium`,children:r.updateAutoEnabled}),(0,Z.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:r.updateAutoEnabledHint})]})]}),(0,Z.jsx)(se,{children:(0,Z.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`update-auto-stable-delay`,children:r.updateAutoStableDelayHours}),(0,Z.jsx)(B,{id:`update-auto-stable-delay`,type:`number`,min:0,disabled:!N.updateAutoEnabled,className:Q(),value:N.updateAutoStableDelayHours,onChange:e=>{W.current=!0,j({type:`set-form`,updater:t=>({...t,updateAutoStableDelayHours:Math.max(0,Math.floor(Number(e.target.value)||0))})})}}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:r.updateAutoStableDelayHoursHint})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`update-auto-stable-jitter`,children:r.updateAutoStableJitterHours}),(0,Z.jsx)(B,{id:`update-auto-stable-jitter`,type:`number`,min:0,disabled:!N.updateAutoEnabled,className:Q(),value:N.updateAutoStableJitterHours,onChange:e=>{W.current=!0,j({type:`set-form`,updater:t=>({...t,updateAutoStableJitterHours:Math.max(0,Math.floor(Number(e.target.value)||0))})})}}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:r.updateAutoStableJitterHoursHint})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`update-auto-beta-interval`,children:r.updateAutoBetaCheckIntervalHours}),(0,Z.jsx)(B,{id:`update-auto-beta-interval`,type:`number`,min:.25,step:.25,disabled:!N.updateAutoEnabled,className:Q(),value:N.updateAutoBetaCheckIntervalHours,onChange:e=>{W.current=!0,j({type:`set-form`,updater:t=>({...t,updateAutoBetaCheckIntervalHours:Math.max(.25,Number(e.target.value)||1)})})}}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:r.updateAutoBetaCheckIntervalHoursHint})]})]})})]})]}),(0,Z.jsx)(Xe,{g:r,id:`security`,activeTab:b,children:(0,Z.jsx)(Ze,{g:r,form:N,onSecurityStrictChange:Pe,onDangerouslyAllowHostHeaderOriginFallbackChange:Ie})}),(0,Z.jsx)(Xe,{g:r,id:`advanced`,activeTab:b,children:(0,Z.jsx)($e,{g:r,form:N,onDeferModeChange:ke,onDeferIdsChange:Ae,onSkipIdsChange:je})})]}):(0,Z.jsxs)(ie,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:ae??X??r.loadError}),(0,Z.jsx)(y,{type:`button`,variant:`secondary`,onClick:()=>void pe(),children:r.retry})]}):(0,Z.jsxs)(ie,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,Z.jsx)(re,{title:n.settingsSections.gateway}),(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.needToken})]})}function Ye(e){let t=(0,U.c)(10),{g:n,activeTab:r,visibleTabs:i,onChange:a}=e,o;if(t[0]!==n||t[1]!==i){let e;t[3]===n?e=t[4]:(e=e=>({id:e,label:We(n,e),icon:He[e]}),t[3]=n,t[4]=e),o=i.map(e),t[0]=n,t[1]=i,t[2]=o}else o=t[2];let s=o,c;return t[5]!==r||t[6]!==n.tabsAriaLabel||t[7]!==s||t[8]!==a?(c=(0,Z.jsx)(z,{items:s,activeTab:r,onChange:a,ariaLabel:n.tabsAriaLabel,tabIdPrefix:`gateway-settings-tab`,panelIdPrefix:`gateway-settings-panel`}),t[5]=r,t[6]=n.tabsAriaLabel,t[7]=s,t[8]=a,t[9]=c):c=t[9],c}function Xe(e){let t=(0,U.c)(14),{g:n,id:r,activeTab:i,children:a}=e,o;t[0]!==n||t[1]!==r?(o=We(n,r),t[0]=n,t[1]=r,t[2]=o):o=t[2];let s;t[3]!==n||t[4]!==r?(s=Ge(n,r),t[3]=n,t[4]=r,t[5]=s):s=t[5];let c;t[6]===a?c=t[7]:(c=(0,Z.jsx)(`div`,{className:`space-y-4`,children:a}),t[6]=a,t[7]=c);let l;return t[8]!==i||t[9]!==r||t[10]!==o||t[11]!==s||t[12]!==c?(l=(0,Z.jsx)(V,{id:r,activeTab:i,tabIdPrefix:`gateway-settings-tab`,panelIdPrefix:`gateway-settings-panel`,title:o,hint:s,showHeading:!1,children:c}),t[8]=i,t[9]=r,t[10]=o,t[11]=s,t[12]=c,t[13]=l):l=t[13],l}function Ze(e){let t=(0,U.c)(37),{g:n,form:r,onSecurityStrictChange:i,onDangerouslyAllowHostHeaderOriginFallbackChange:a}=e,o;t[0]===i?o=t[1]:(o=e=>i(e.target.checked),t[0]=i,t[1]=o);let s;t[2]!==r.securityStrict||t[3]!==o?(s=(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:r.securityStrict,onChange:o}),t[2]=r.securityStrict,t[3]=o,t[4]=s):s=t[4];let c;t[5]===n.securityStrict?c=t[6]:(c=(0,Z.jsx)(`span`,{className:`font-medium`,children:n.securityStrict}),t[5]=n.securityStrict,t[6]=c);let l;t[7]===n.securityStrictHint?l=t[8]:(l=(0,Z.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:n.securityStrictHint}),t[7]=n.securityStrictHint,t[8]=l);let u;t[9]!==c||t[10]!==l?(u=(0,Z.jsxs)(`span`,{children:[c,l]}),t[9]=c,t[10]=l,t[11]=u):u=t[11];let d;t[12]!==s||t[13]!==u?(d=(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[s,u]}),t[12]=s,t[13]=u,t[14]=d):d=t[14];let f;t[15]===a?f=t[16]:(f=e=>a(e.target.checked),t[15]=a,t[16]=f);let p;t[17]!==r.dangerouslyAllowHostHeaderOriginFallback||t[18]!==f?(p=(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:r.dangerouslyAllowHostHeaderOriginFallback,onChange:f}),t[17]=r.dangerouslyAllowHostHeaderOriginFallback,t[18]=f,t[19]=p):p=t[19];let m;t[20]===n.dangerouslyAllowHostHeaderOriginFallback?m=t[21]:(m=(0,Z.jsx)(`span`,{className:`font-medium`,children:n.dangerouslyAllowHostHeaderOriginFallback}),t[20]=n.dangerouslyAllowHostHeaderOriginFallback,t[21]=m);let h;t[22]===n.dangerouslyAllowHostHeaderOriginFallbackHint?h=t[23]:(h=(0,Z.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:n.dangerouslyAllowHostHeaderOriginFallbackHint}),t[22]=n.dangerouslyAllowHostHeaderOriginFallbackHint,t[23]=h);let g;t[24]!==h||t[25]!==m?(g=(0,Z.jsxs)(`span`,{children:[m,h]}),t[24]=h,t[25]=m,t[26]=g):g=t[26];let _;t[27]!==g||t[28]!==p?(_=(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[p,g]}),t[27]=g,t[28]=p,t[29]=_):_=t[29];let v;t[30]!==r.dangerouslyAllowHostHeaderOriginFallback||t[31]!==n.dangerouslyAllowHostHeaderOriginFallbackWarning?(v=r.dangerouslyAllowHostHeaderOriginFallback?(0,Z.jsx)(`p`,{className:`rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:n.dangerouslyAllowHostHeaderOriginFallbackWarning}):null,t[30]=r.dangerouslyAllowHostHeaderOriginFallback,t[31]=n.dangerouslyAllowHostHeaderOriginFallbackWarning,t[32]=v):v=t[32];let y;return t[33]!==_||t[34]!==v||t[35]!==d?(y=(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[d,_,v]}),t[33]=_,t[34]=v,t[35]=d,t[36]=y):y=t[36],y}function Qe(e){let t=(0,U.c)(80),{g:n,form:r,onTrustedProxyChange:i,onTrustedProxiesChange:a,onAllowRealIpFallbackChange:o}=e,s=r.auth.trustedProxy,c;t[0]===n.authModeTrustedProxyHint?c=t[1]:(c=(0,Z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.authModeTrustedProxyHint}),t[0]=n.authModeTrustedProxyHint,t[1]=c);let l;t[2]===n.trustedProxyUserHeader?l=t[3]:(l=(0,Z.jsx)(`label`,{className:`mb-1 block text-sm font-medium text-fg`,htmlFor:`gateway-trusted-proxy-user-header`,children:n.trustedProxyUserHeader}),t[2]=n.trustedProxyUserHeader,t[3]=l);let u;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(u=f(Q(),`font-mono text-xs`),t[4]=u):u=t[4];let d;t[5]===i?d=t[6]:(d=e=>i({userHeader:e.target.value}),t[5]=i,t[6]=d);let p;t[7]!==n.trustedProxyUserHeaderPlaceholder||t[8]!==d||t[9]!==s.userHeader?(p=(0,Z.jsx)(`input`,{id:`gateway-trusted-proxy-user-header`,className:u,value:s.userHeader,onChange:d,placeholder:n.trustedProxyUserHeaderPlaceholder,autoComplete:`off`}),t[7]=n.trustedProxyUserHeaderPlaceholder,t[8]=d,t[9]=s.userHeader,t[10]=p):p=t[10];let m;t[11]===n.trustedProxyUserHeaderHint?m=t[12]:(m=(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.trustedProxyUserHeaderHint}),t[11]=n.trustedProxyUserHeaderHint,t[12]=m);let h;t[13]!==l||t[14]!==p||t[15]!==m?(h=(0,Z.jsxs)(`div`,{children:[l,p,m]}),t[13]=l,t[14]=p,t[15]=m,t[16]=h):h=t[16];let g;t[17]===i?g=t[18]:(g=e=>i({requiredHeaders:e}),t[17]=i,t[18]=g);let _;t[19]!==n.channelIdListEmpty||t[20]!==n.trustedProxyRequiredHeaders||t[21]!==n.trustedProxyRequiredHeadersHint||t[22]!==n.trustedProxyUserHeaderPlaceholder||t[23]!==g||t[24]!==s.requiredHeaders?(_=(0,Z.jsx)($,{title:n.trustedProxyRequiredHeaders,hint:n.trustedProxyRequiredHeadersHint,emptyText:n.channelIdListEmpty,placeholder:n.trustedProxyUserHeaderPlaceholder,values:s.requiredHeaders,maxItems:32,onChange:g}),t[19]=n.channelIdListEmpty,t[20]=n.trustedProxyRequiredHeaders,t[21]=n.trustedProxyRequiredHeadersHint,t[22]=n.trustedProxyUserHeaderPlaceholder,t[23]=g,t[24]=s.requiredHeaders,t[25]=_):_=t[25];let v;t[26]===i?v=t[27]:(v=e=>i({allowUsers:e}),t[26]=i,t[27]=v);let y;t[28]!==n.channelIdListEmpty||t[29]!==n.trustedProxyAllowUsers||t[30]!==n.trustedProxyAllowUsersHint||t[31]!==n.trustedProxyUserHeaderPlaceholder||t[32]!==v||t[33]!==s.allowUsers?(y=(0,Z.jsx)($,{title:n.trustedProxyAllowUsers,hint:n.trustedProxyAllowUsersHint,emptyText:n.channelIdListEmpty,placeholder:n.trustedProxyUserHeaderPlaceholder,values:s.allowUsers,maxItems:128,onChange:v}),t[28]=n.channelIdListEmpty,t[29]=n.trustedProxyAllowUsers,t[30]=n.trustedProxyAllowUsersHint,t[31]=n.trustedProxyUserHeaderPlaceholder,t[32]=v,t[33]=s.allowUsers,t[34]=y):y=t[34];let b;t[35]===i?b=t[36]:(b=e=>i({allowLoopback:e.target.checked}),t[35]=i,t[36]=b);let x;t[37]!==b||t[38]!==s.allowLoopback?(x=(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:s.allowLoopback,onChange:b}),t[37]=b,t[38]=s.allowLoopback,t[39]=x):x=t[39];let S;t[40]===n.trustedProxyAllowLoopback?S=t[41]:(S=(0,Z.jsx)(`span`,{className:`font-medium`,children:n.trustedProxyAllowLoopback}),t[40]=n.trustedProxyAllowLoopback,t[41]=S);let C;t[42]===n.trustedProxyAllowLoopbackHint?C=t[43]:(C=(0,Z.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:n.trustedProxyAllowLoopbackHint}),t[42]=n.trustedProxyAllowLoopbackHint,t[43]=C);let w;t[44]!==S||t[45]!==C?(w=(0,Z.jsxs)(`span`,{children:[S,C]}),t[44]=S,t[45]=C,t[46]=w):w=t[46];let T;t[47]!==x||t[48]!==w?(T=(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[x,w]}),t[47]=x,t[48]=w,t[49]=T):T=t[49];let E;t[50]!==r.trustedProxies||t[51]!==n.trustedProxies||t[52]!==n.trustedProxiesEmpty||t[53]!==n.trustedProxiesHint||t[54]!==n.trustedProxiesPlaceholder||t[55]!==a?(E=(0,Z.jsx)($,{title:n.trustedProxies,hint:n.trustedProxiesHint,emptyText:n.trustedProxiesEmpty,placeholder:n.trustedProxiesPlaceholder,values:r.trustedProxies,maxItems:64,onChange:a}),t[50]=r.trustedProxies,t[51]=n.trustedProxies,t[52]=n.trustedProxiesEmpty,t[53]=n.trustedProxiesHint,t[54]=n.trustedProxiesPlaceholder,t[55]=a,t[56]=E):E=t[56];let D;t[57]===o?D=t[58]:(D=e=>o(e.target.checked),t[57]=o,t[58]=D);let O;t[59]!==r.allowRealIpFallback||t[60]!==D?(O=(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:r.allowRealIpFallback,onChange:D}),t[59]=r.allowRealIpFallback,t[60]=D,t[61]=O):O=t[61];let k;t[62]===n.allowRealIpFallback?k=t[63]:(k=(0,Z.jsx)(`span`,{className:`font-medium`,children:n.allowRealIpFallback}),t[62]=n.allowRealIpFallback,t[63]=k);let A;t[64]===n.allowRealIpFallbackHint?A=t[65]:(A=(0,Z.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:n.allowRealIpFallbackHint}),t[64]=n.allowRealIpFallbackHint,t[65]=A);let j;t[66]!==k||t[67]!==A?(j=(0,Z.jsxs)(`span`,{children:[k,A]}),t[66]=k,t[67]=A,t[68]=j):j=t[68];let M;t[69]!==O||t[70]!==j?(M=(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[O,j]}),t[69]=O,t[70]=j,t[71]=M):M=t[71];let N;return t[72]!==c||t[73]!==y||t[74]!==T||t[75]!==E||t[76]!==M||t[77]!==h||t[78]!==_?(N=(0,Z.jsxs)(`div`,{className:`space-y-4 rounded-xl bg-surface-base/45 p-4`,children:[c,h,_,y,T,E,M]}),t[72]=c,t[73]=y,t[74]=T,t[75]=E,t[76]=M,t[77]=h,t[78]=_,t[79]=N):N=t[79],N}function $e(e){let t=(0,U.c)(43),{g:n,form:r,onDeferModeChange:i,onDeferIdsChange:s,onSkipIdsChange:c}=e,l;t[0]===n.channelConnectDeferMode?l=t[1]:(l=(0,Z.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:`gateway-channel-defer-mode`,children:n.channelConnectDeferMode}),t[0]=n.channelConnectDeferMode,t[1]=l);let u=r.channelConnectDeferMode,d;t[2]===i?d=t[3]:(d=e=>i(e.target.value),t[2]=i,t[3]=d);let f;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(f=Q(),t[4]=f):f=t[4];let p;t[5]===n.channelConnectDeferModeAuto?p=t[6]:(p=(0,Z.jsx)(o,{value:`auto`,children:n.channelConnectDeferModeAuto}),t[5]=n.channelConnectDeferModeAuto,t[6]=p);let m;t[7]===n.channelConnectDeferModeOff?m=t[8]:(m=(0,Z.jsx)(o,{value:`off`,children:n.channelConnectDeferModeOff}),t[7]=n.channelConnectDeferModeOff,t[8]=m);let h;t[9]===n.channelConnectDeferModeExplicit?h=t[10]:(h=(0,Z.jsx)(o,{value:`explicit`,children:n.channelConnectDeferModeExplicit}),t[9]=n.channelConnectDeferModeExplicit,t[10]=h);let g;t[11]!==r.channelConnectDeferMode||t[12]!==d||t[13]!==p||t[14]!==m||t[15]!==h?(g=(0,Z.jsxs)(a,{id:`gateway-channel-defer-mode`,value:u,onChange:d,className:f,children:[p,m,h]}),t[11]=r.channelConnectDeferMode,t[12]=d,t[13]=p,t[14]=m,t[15]=h,t[16]=g):g=t[16];let _;t[17]===n.channelConnectDeferModeHint?_=t[18]:(_=(0,Z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.channelConnectDeferModeHint}),t[17]=n.channelConnectDeferModeHint,t[18]=_);let v;t[19]!==l||t[20]!==g||t[21]!==_?(v=(0,Z.jsxs)(`div`,{className:`space-y-2 rounded-xl bg-surface-base/45 p-4`,children:[l,g,_]}),t[19]=l,t[20]=g,t[21]=_,t[22]=v):v=t[22];let y;t[23]!==r.channelConnectDeferIds||t[24]!==r.channelConnectDeferMode||t[25]!==n.channelConnectDeferIds||t[26]!==n.channelConnectDeferIdsHint||t[27]!==n.channelIdListEmpty||t[28]!==n.channelIdListPlaceholder||t[29]!==s?(y=r.channelConnectDeferMode===`explicit`?(0,Z.jsx)($,{title:n.channelConnectDeferIds,hint:n.channelConnectDeferIdsHint,emptyText:n.channelIdListEmpty,placeholder:n.channelIdListPlaceholder,values:r.channelConnectDeferIds,maxItems:24,onChange:s}):null,t[23]=r.channelConnectDeferIds,t[24]=r.channelConnectDeferMode,t[25]=n.channelConnectDeferIds,t[26]=n.channelConnectDeferIdsHint,t[27]=n.channelIdListEmpty,t[28]=n.channelIdListPlaceholder,t[29]=s,t[30]=y):y=t[30];let b;t[31]!==r.channelConnectDeferMode||t[32]!==r.channelConnectDeferSkipIds||t[33]!==n.channelConnectDeferSkipIds||t[34]!==n.channelConnectDeferSkipIdsHint||t[35]!==n.channelIdListEmpty||t[36]!==n.channelIdListPlaceholder||t[37]!==c?(b=r.channelConnectDeferMode===`off`?null:(0,Z.jsx)($,{title:n.channelConnectDeferSkipIds,hint:n.channelConnectDeferSkipIdsHint,emptyText:n.channelIdListEmpty,placeholder:n.channelIdListPlaceholder,values:r.channelConnectDeferSkipIds,maxItems:24,onChange:c}),t[31]=r.channelConnectDeferMode,t[32]=r.channelConnectDeferSkipIds,t[33]=n.channelConnectDeferSkipIds,t[34]=n.channelConnectDeferSkipIdsHint,t[35]=n.channelIdListEmpty,t[36]=n.channelIdListPlaceholder,t[37]=c,t[38]=b):b=t[38];let x;return t[39]!==v||t[40]!==y||t[41]!==b?(x=(0,Z.jsxs)(`div`,{className:`space-y-4`,children:[v,y,b]}),t[39]=v,t[40]=y,t[41]=b,t[42]=x):x=t[42],x}function $(e){let t=(0,U.c)(25),{title:n,hint:r,emptyText:i,placeholder:a,values:o,maxItems:s,onChange:c,children:l}=e,u;t[0]!==s||t[1]!==c||t[2]!==o?(u=e=>{let t=e.trim();!t||o.includes(t)||o.length>=s||c([...o,t])},t[0]=s,t[1]=c,t[2]=o,t[3]=u):u=t[3];let d=u,p;t[4]===n?p=t[5]:(p=(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[4]=n,t[5]=p);let m;t[6]===r?m=t[7]:(m=(0,Z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r}),t[6]=r,t[7]=m);let h;t[8]!==i||t[9]!==c||t[10]!==o?(h=o.length===0?(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i}):(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:o.map(e=>(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md border border-edge bg-surface-panel px-2 py-0.5 font-mono text-xs text-fg`,children:[e,(0,Z.jsx)(`button`,{type:`button`,className:f(`text-fg-muted hover:text-fg`,b.press),"aria-label":`Remove ${e}`,onClick:()=>c(o.filter(t=>t!==e)),children:`×`})]},e))}),t[8]=i,t[9]=c,t[10]=o,t[11]=h):h=t[11];let g;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(g=f(Q(),`font-mono text-xs`),t[12]=g):g=t[12];let _=o.length>=s,v;t[13]===d?v=t[14]:(v=e=>{e.key===`Enter`&&(e.preventDefault(),d(e.target.value),e.target.value=``)},t[13]=d,t[14]=v);let y;t[15]!==a||t[16]!==_||t[17]!==v?(y=(0,Z.jsx)(`input`,{className:g,placeholder:a,disabled:_,onKeyDown:v}),t[15]=a,t[16]=_,t[17]=v,t[18]=y):y=t[18];let x;return t[19]!==l||t[20]!==p||t[21]!==m||t[22]!==h||t[23]!==y?(x=(0,Z.jsxs)(`div`,{className:`space-y-2 rounded-xl bg-surface-base/45 p-4`,children:[p,m,h,y,l]}),t[19]=l,t[20]=p,t[21]=m,t[22]=h,t[23]=y,t[24]=x):x=t[24],x}function et(e){let t=(0,U.c)(36),{g:n,origins:r,candidates:i,onChange:a}=e,o;t[0]===r?o=t[1]:(o=r.includes(`*`),t[0]=r,t[1]=o);let s=o,c,l,u,d,f,p,m,h,g;if(t[2]!==i||t[3]!==n.corsAddDetectedOrigins||t[4]!==n.corsDetectedOrigins||t[5]!==n.corsOrigins||t[6]!==n.corsOriginsEmpty||t[7]!==n.corsOriginsHint||t[8]!==n.corsOriginsPlaceholder||t[9]!==a||t[10]!==r){let e;t[20]===r?e=t[21]:(e=e=>!r.includes(e.url),t[20]=r,t[21]=e);let o=i.filter(e);c=$,l=n.corsOrigins,u=n.corsOriginsHint,d=n.corsOriginsEmpty,f=n.corsOriginsPlaceholder,p=r,m=128,h=a,g=o.length>0?(0,Z.jsxs)(`div`,{className:`rounded-lg bg-surface-base/55 px-3 py-2`,children:[(0,Z.jsx)(`p`,{className:`text-xs font-medium text-fg`,children:n.corsDetectedOrigins}),(0,Z.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:o.map(nt)}),(0,Z.jsx)(y,{type:`button`,variant:`secondary`,className:`mt-2 text-xs`,onClick:()=>a([...r,...o.map(tt)]),children:n.corsAddDetectedOrigins})]}):null,t[2]=i,t[3]=n.corsAddDetectedOrigins,t[4]=n.corsDetectedOrigins,t[5]=n.corsOrigins,t[6]=n.corsOriginsEmpty,t[7]=n.corsOriginsHint,t[8]=n.corsOriginsPlaceholder,t[9]=a,t[10]=r,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 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 _;t[22]!==n.corsOriginsWildcardWarning||t[23]!==s?(_=s?(0,Z.jsx)(`p`,{className:`rounded-lg bg-amber-50 px-3 py-2 text-xs text-amber-950 dark:bg-amber-950/40 dark:text-amber-100`,children:n.corsOriginsWildcardWarning}):null,t[22]=n.corsOriginsWildcardWarning,t[23]=s,t[24]=_):_=t[24];let v;return t[25]!==c||t[26]!==_||t[27]!==l||t[28]!==u||t[29]!==d||t[30]!==f||t[31]!==p||t[32]!==m||t[33]!==h||t[34]!==g?(v=(0,Z.jsxs)(c,{title:l,hint:u,emptyText:d,placeholder:f,values:p,maxItems:m,onChange:h,children:[g,_]}),t[25]=c,t[26]=_,t[27]=l,t[28]=u,t[29]=d,t[30]=f,t[31]=p,t[32]=m,t[33]=h,t[34]=g,t[35]=v):v=t[35],v}function tt(e){return e.url}function nt(e){return(0,Z.jsxs)(`span`,{className:`rounded-md border border-edge bg-surface-panel px-2 py-0.5 font-mono text-xs text-fg`,children:[e.url,` · `,e.interfaceName]},e.url)}function rt(e){let t=(0,U.c)(73),{g:n,rateLimit:r,onChange:i}=e,a;t[0]===n.rateLimitTitle?a=t[1]:(a=(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.rateLimitTitle}),t[0]=n.rateLimitTitle,t[1]=a);let o;t[2]===n.rateLimitHint?o=t[3]:(o=(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.rateLimitHint}),t[2]=n.rateLimitHint,t[3]=o);let s;t[4]!==a||t[5]!==o?(s=(0,Z.jsxs)(`div`,{children:[a,o]}),t[4]=a,t[5]=o,t[6]=s):s=t[6];let c;t[7]===i?c=t[8]:(c=e=>i({enabled:e.target.checked}),t[7]=i,t[8]=c);let l;t[9]!==r.enabled||t[10]!==c?(l=(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.enabled,onChange:c}),t[9]=r.enabled,t[10]=c,t[11]=l):l=t[11];let u;t[12]!==n.rateLimitEnabled||t[13]!==l?(u=(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[l,n.rateLimitEnabled]}),t[12]=n.rateLimitEnabled,t[13]=l,t[14]=u):u=t[14];let d=!r.enabled,f;t[15]===i?f=t[16]:(f=e=>i({exemptLoopback:e.target.checked}),t[15]=i,t[16]=f);let p;t[17]!==r.exemptLoopback||t[18]!==d||t[19]!==f?(p=(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:r.exemptLoopback,disabled:d,onChange:f}),t[17]=r.exemptLoopback,t[18]=d,t[19]=f,t[20]=p):p=t[20];let m;t[21]!==n.rateLimitExemptLoopback||t[22]!==p?(m=(0,Z.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[p,n.rateLimitExemptLoopback]}),t[21]=n.rateLimitExemptLoopback,t[22]=p,t[23]=m):m=t[23];let h;t[24]===n.rateLimitMaxAttempts?h=t[25]:(h=(0,Z.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,htmlFor:`gateway-rate-max`,children:n.rateLimitMaxAttempts}),t[24]=n.rateLimitMaxAttempts,t[25]=h);let g;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(g=Q(),t[26]=g):g=t[26];let _=!r.enabled,v;t[27]===i?v=t[28]:(v=e=>{let t=Number(e.target.value);Number.isFinite(t)&&i({maxAttempts:Math.max(1,Math.floor(t))})},t[27]=i,t[28]=v);let y;t[29]!==r.maxAttempts||t[30]!==_||t[31]!==v?(y=(0,Z.jsx)(B,{id:`gateway-rate-max`,type:`number`,min:1,className:g,value:r.maxAttempts,disabled:_,onChange:v}),t[29]=r.maxAttempts,t[30]=_,t[31]=v,t[32]=y):y=t[32];let b;t[33]!==h||t[34]!==y?(b=(0,Z.jsxs)(`div`,{children:[h,y]}),t[33]=h,t[34]=y,t[35]=b):b=t[35];let x;t[36]===n.rateLimitWindowMinutes?x=t[37]:(x=(0,Z.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,htmlFor:`gateway-rate-window`,children:n.rateLimitWindowMinutes}),t[36]=n.rateLimitWindowMinutes,t[37]=x);let S;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(S=Q(),t[38]=S):S=t[38];let C;t[39]===r.windowMs?C=t[40]:(C=Math.round(r.windowMs/6e4),t[39]=r.windowMs,t[40]=C);let w=!r.enabled,T;t[41]===i?T=t[42]:(T=e=>{let t=Number(e.target.value);Number.isFinite(t)&&t>0&&i({windowMs:Math.floor(t)*6e4})},t[41]=i,t[42]=T);let E;t[43]!==C||t[44]!==w||t[45]!==T?(E=(0,Z.jsx)(B,{id:`gateway-rate-window`,type:`number`,min:1,className:S,value:C,disabled:w,onChange:T}),t[43]=C,t[44]=w,t[45]=T,t[46]=E):E=t[46];let D;t[47]!==x||t[48]!==E?(D=(0,Z.jsxs)(`div`,{children:[x,E]}),t[47]=x,t[48]=E,t[49]=D):D=t[49];let O;t[50]===n.rateLimitBlockMinutes?O=t[51]:(O=(0,Z.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,htmlFor:`gateway-rate-block`,children:n.rateLimitBlockMinutes}),t[50]=n.rateLimitBlockMinutes,t[51]=O);let k;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(k=Q(),t[52]=k):k=t[52];let A;t[53]===r.blockDurationMs?A=t[54]:(A=Math.round(r.blockDurationMs/6e4),t[53]=r.blockDurationMs,t[54]=A);let j=!r.enabled,M;t[55]===i?M=t[56]:(M=e=>{let t=Number(e.target.value);Number.isFinite(t)&&t>0&&i({blockDurationMs:Math.floor(t)*6e4})},t[55]=i,t[56]=M);let N;t[57]!==A||t[58]!==j||t[59]!==M?(N=(0,Z.jsx)(B,{id:`gateway-rate-block`,type:`number`,min:1,className:k,value:A,disabled:j,onChange:M}),t[57]=A,t[58]=j,t[59]=M,t[60]=N):N=t[60];let P;t[61]!==O||t[62]!==N?(P=(0,Z.jsxs)(`div`,{children:[O,N]}),t[61]=O,t[62]=N,t[63]=P):P=t[63];let F;t[64]!==b||t[65]!==D||t[66]!==P?(F=(0,Z.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[b,D,P]}),t[64]=b,t[65]=D,t[66]=P,t[67]=F):F=t[67];let I;return t[68]!==m||t[69]!==s||t[70]!==F||t[71]!==u?(I=(0,Z.jsxs)(`div`,{className:`space-y-3 rounded-xl bg-surface-base/45 p-4`,children:[s,u,m,F]}),t[68]=m,t[69]=s,t[70]=F,t[71]=u,t[72]=I):I=t[72],I}function it(e){let t=(0,U.c)(17),{id:n,label:r,help:i,placeholder:a,value:o,labels:s,reveal:l,loadFailedLabel:u,onChange:d}=e,f;t[0]!==n||t[1]!==r?(f=(0,Z.jsx)(`label`,{className:`text-sm font-medium text-fg`,htmlFor:n,children:r}),t[0]=n,t[1]=r,t[2]=f):f=t[2];let p;t[3]!==n||t[4]!==s||t[5]!==u||t[6]!==d||t[7]!==a||t[8]!==l||t[9]!==o?(p=(0,Z.jsx)(c,{id:n,value:o,onChange:d,placeholder:a,labels:s,reveal:l,loadFailedLabel:u,inputClassName:`text-xs`}),t[3]=n,t[4]=s,t[5]=u,t[6]=d,t[7]=a,t[8]=l,t[9]=o,t[10]=p):p=t[10];let m;t[11]===i?m=t[12]:(m=(0,Z.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:i}),t[11]=i,t[12]=m);let h;return t[13]!==f||t[14]!==p||t[15]!==m?(h=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[f,p,m]}),t[13]=f,t[14]=p,t[15]=m,t[16]=h):h=t[16],h}export{Je as GatewaySettingsPanel};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./createLucideIcon-DPHK1VkS.js";var t=e(`git-branch`,[[`path`,{d:`M15 6a9 9 0 0 0-9 9V3`,key:`1cii5b`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}]]);export{t};
|