@xopcai/xopc 0.0.424 → 0.0.426
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser-ext/manifest.json +1 -1
- package/dist/extensions/telegram/xopc.extension.json +1 -1
- package/dist/gateway/static/root/assets/{activity-store-AI081rxe.js → activity-store-D_DXNHba.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-dicebear-DupnTbL7.js → agent-avatar-dicebear-CjaQxFQt.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-avatar-display-CmEj6Uqy.js → agent-avatar-display-6Z4m31Fz.js} +2 -2
- package/dist/gateway/static/root/assets/{agent-defaults-settings-panel-IEV5yKuu.js → agent-defaults-settings-panel-Dne9A10p.js} +1 -1
- package/dist/gateway/static/root/assets/{agent-plugin-dialog-D_njOuFA.js → agent-plugin-dialog-BoHL-b1o.js} +1 -1
- package/dist/gateway/static/root/assets/{agents-B_yg9nA3.js → agents-CIiIlVBp.js} +3 -3
- package/dist/gateway/static/root/assets/{agents-admin-api-CUZUolwG.js → agents-admin-api-u5c3GREg.js} +1 -1
- package/dist/gateway/static/root/assets/{api-bpQ7yR10.js → api-C3Tp9MkF.js} +1 -1
- package/dist/gateway/static/root/assets/{api-CWWEVThO.js → api-CRT9ZyH0.js} +1 -1
- package/dist/gateway/static/root/assets/{app-management-settings-panel-C0_hxwgg.js → app-management-settings-panel-C8yc3yHG.js} +1 -1
- package/dist/gateway/static/root/assets/{appearance-settings-CLh-qnCC.js → appearance-settings-BELgtR3O.js} +1 -1
- package/dist/gateway/static/root/assets/{apps-page-Bjtm3Rgi.js → apps-page-vgS1CHDj.js} +1 -1
- package/dist/gateway/static/root/assets/{archive-plugin-dGnstkhB.js → archive-plugin-BCQnOkV8.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-api-MB2xCoFF.js → automation-api-hRsGx-qe.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-result-state-DJQflY78.js → automation-result-state-CMfVTv_i.js} +1 -1
- package/dist/gateway/static/root/assets/{automation-task-card-DXgBxVE2.js → automation-task-card-MnzgyTVA.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-page-D3O7M2FH.js → automations-page-CdIPdwF0.js} +1 -1
- package/dist/gateway/static/root/assets/{automations-workspace-Dk3FVWoX.js → automations-workspace-C3xZLafX.js} +2 -2
- package/dist/gateway/static/root/assets/{binary-plugins-BrVJXmYf.js → binary-plugins-CIB5cbvQ.js} +1 -1
- package/dist/gateway/static/root/assets/{block-editor-Dok4sfT3.js → block-editor-BQtTLe6Q.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-automation-inputs-PJbT3CxW.js → browser-automation-inputs-DeraGZ1y.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-automations-page-kkpX1Q7K.js → browser-automations-page-SpPzRNqU.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-control-api-Bg4wnkeA.js → browser-control-api-CbbPvhHR.js} +1 -1
- package/dist/gateway/static/root/assets/{browser-settings-page-BrgX_Yb2.js → browser-settings-page-BD1uF_Nb.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-BMaJizw4.js → capabilities-BGE6hiUE.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-Cs6Jt5Gl.js → capabilities-DLMuj21P.js} +1 -1
- package/dist/gateway/static/root/assets/{capabilities-page-D5hvAG6D.js → capabilities-page-Bda4mSdf.js} +2 -2
- package/dist/gateway/static/root/assets/{capabilities-settings-panel-BrEvm4IH.js → capabilities-settings-panel-B2B7no22.js} +2 -2
- package/dist/gateway/static/root/assets/{channels-1jQgGVc9.js → channels-NtsjZThx.js} +1 -1
- package/dist/gateway/static/root/assets/{chat-agents-api-BAOWaUJf.js → chat-agents-api-D8YS5amE.js} +1 -1
- package/dist/gateway/static/root/assets/{chat-chart-block-DeWrb9XR.js → chat-chart-block-DCzUECct.js} +1 -1
- package/dist/gateway/static/root/assets/chat-page-BnOCCAXG.js +72 -0
- package/dist/gateway/static/root/assets/{chat-terminal-dock-C544n0-R.js → chat-terminal-dock-Dl-OTkJI.js} +1 -1
- package/dist/gateway/static/root/assets/{command-palette-api-D9PXzY8b.js → command-palette-api-Dijix7V6.js} +1 -1
- package/dist/gateway/static/root/assets/{composer-payload-handoff-CYXfjpem.js → composer-payload-handoff-CQc-VTaL.js} +1 -1
- package/dist/gateway/static/root/assets/{computer-settings-page-DJmod8-w.js → computer-settings-page-B-lGMimW.js} +1 -1
- package/dist/gateway/static/root/assets/connected-providers-grid-CcXe9kz5.js +1 -0
- package/dist/gateway/static/root/assets/{connector-service-page-BqDbTOTp.js → connector-service-page-C8InhrMt.js} +1 -1
- package/dist/gateway/static/root/assets/{connectors-api-CwRuUnH4.js → connectors-api-DEJU8mgn.js} +1 -1
- package/dist/gateway/static/root/assets/{connectors-page-Mq9Bvoax.js → connectors-page-Ci0L2How.js} +1 -1
- package/dist/gateway/static/root/assets/{date-picker-DWaT0IC0.js → date-picker-kqic8j73.js} +1 -1
- package/dist/gateway/static/root/assets/{dependency-picker-DV9XAt6F.js → dependency-picker-cbC6-2Ya.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-Dffq2NxL.js → desktop-pet-DFNehTtd.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-narrative-CS8qJpNO.js → desktop-pet-narrative-ChwjpnsG.js} +1 -1
- package/dist/gateway/static/root/assets/{desktop-pet-settings-CrB1ICax.js → desktop-pet-settings-BDS7_tQ_.js} +1 -1
- package/dist/gateway/static/root/assets/{dev-view-store-liRgSkcT.js → dev-view-store-CeZZLOc6.js} +1 -1
- package/dist/gateway/static/root/assets/device-pairing-wizard-_3BJFWVQ.js +1 -0
- package/dist/gateway/static/root/assets/{directory-picker-path-field-EKqQLQrE.js → directory-picker-path-field-Di0h3ws4.js} +1 -1
- package/dist/gateway/static/root/assets/{discussion-annotation-sync-D-b1X6ro.js → discussion-annotation-sync-ClKEyXmN.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-debug-page-wD97GeG0.js → extension-debug-page-DwB5KMGk.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-iframe-host-B4Q1CjvW.js → extension-iframe-host-Cqg1K70e.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-marketplace-api-ak1_K3u8.js → extension-marketplace-api-DRBszrCR.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-page-DWFI4iIh.js → extension-page-DyrQtG82.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-provider-BZwcaU5Y.js → extension-provider-C_uKqJxP.js} +1 -1
- package/dist/gateway/static/root/assets/{extension-settings-page-cn4KS42C.js → extension-settings-page-BAMQHzkX.js} +1 -1
- package/dist/gateway/static/root/assets/{file-preview-surface-c3gDD9sM.js → file-preview-surface-DfkXvFnc.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-config-swr-Dmt5JhZU.js → gateway-config-swr-BOCt_zOo.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-realtime-CJtDXQCt.js → gateway-realtime-BL_Cf0OQ.js} +1 -1
- package/dist/gateway/static/root/assets/gateway-realtime-store-BHBOPF_q.js +1 -0
- package/dist/gateway/static/root/assets/{gateway-restart-DInvvT5u.js → gateway-restart-CHf8qY7H.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-settings-BZXdv2FE.js → gateway-settings-uAboiElC.js} +1 -1
- package/dist/gateway/static/root/assets/{gateway-startup-retry-s2KcWekp.js → gateway-startup-retry-CvkJYurV.js} +1 -1
- package/dist/gateway/static/root/assets/{global-defaults-api-DtnmDd87.js → global-defaults-api-BWMbKu72.js} +1 -1
- package/dist/gateway/static/root/assets/{home-page-CAVjA5rO.js → home-page-D6pCBY1V.js} +2 -2
- package/dist/gateway/static/root/assets/{image-generation-api-RQQokgE9.js → image-generation-api-CQxZSTWA.js} +1 -1
- package/dist/gateway/static/root/assets/{imports-page-BP_4TubV.js → imports-page-C90644id.js} +1 -1
- package/dist/gateway/static/root/assets/index-Cc41XQid.css +1 -0
- package/dist/gateway/static/root/assets/index-CnOYR6jq.js +11 -0
- package/dist/gateway/static/root/assets/{install-connector-dialog-BNzNuXJ8.js → install-connector-dialog-BuNXON0P.js} +1 -1
- package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-DNRQFepg.js → keyboard-shortcuts-settings-CbeubKe1.js} +1 -1
- package/dist/gateway/static/root/assets/{local-app-workbench-page-CvY5XxbX.js → local-app-workbench-page-CP-BkbB6.js} +1 -1
- package/dist/gateway/static/root/assets/{local-apps-page-DfwEvd8G.js → local-apps-page-C6zFgwkr.js} +1 -1
- package/dist/gateway/static/root/assets/{local-session-drafts-CuDdIyxR.js → local-session-drafts-BJ1B1dQ7.js} +1 -1
- package/dist/gateway/static/root/assets/{locale-store-TQcz_Vjt.js → locale-store-Br7IfbXK.js} +1 -1
- package/dist/gateway/static/root/assets/{logs-page-eq49F1Rt.js → logs-page-CpVCvAWE.js} +1 -1
- package/dist/gateway/static/root/assets/{management-settings-BaYXDMOJ.js → management-settings-I-pXv4ML.js} +1 -1
- package/dist/gateway/static/root/assets/{markdown-view-D4nII6Zv.js → markdown-view-DrVAMlwc.js} +1 -1
- package/dist/gateway/static/root/assets/{media-plugins-MvlAY405.js → media-plugins-Ba6vUE4J.js} +1 -1
- package/dist/gateway/static/root/assets/messages-ByFlEbsu.js +3 -0
- package/dist/gateway/static/root/assets/{model-selector-nsoNHqif.js → model-selector-CXcxc30J.js} +1 -1
- package/dist/gateway/static/root/assets/{models-hub-cache-CFIazNIF.js → models-hub-cache-Bd-fYUrV.js} +1 -1
- package/dist/gateway/static/root/assets/{note-detail-panel-KPzbHiEW.js → note-detail-panel-CbpLXAVh.js} +3 -3
- package/dist/gateway/static/root/assets/note-image-lightbox-cLGiF8oU.js +1 -0
- package/dist/gateway/static/root/assets/{notes-api-HVxR5bRD.js → notes-api-CUlhTRv0.js} +1 -1
- package/dist/gateway/static/root/assets/{notes-page-yShJeR3i.js → notes-page-eoKX85K5.js} +1 -1
- package/dist/gateway/static/root/assets/{oauth-api-CfKjRVnb.js → oauth-api-DMMdeaNd.js} +1 -1
- package/dist/gateway/static/root/assets/{oauth-provider-connect-D4uqONWr.js → oauth-provider-connect-C8BXow79.js} +1 -1
- package/dist/gateway/static/root/assets/{page-context-capture-button-B98nlKTc.js → page-context-capture-button-CBFK41OS.js} +1 -1
- package/dist/gateway/static/root/assets/{page-context-draft-HcuK45iu.js → page-context-draft-LF33STHC.js} +1 -1
- package/dist/gateway/static/root/assets/page-header-store-Du44NIEJ.js +1 -0
- package/dist/gateway/static/root/assets/{personal-avatar-_d72UP_d.js → personal-avatar-D6CzIIfo.js} +1 -1
- package/dist/gateway/static/root/assets/{personal-page-B19h_3WQ.js → personal-page-CXR1Gy0x.js} +1 -1
- package/dist/gateway/static/root/assets/{personal-settings-panel-CfwtGyue.js → personal-settings-panel-DnYapLo7.js} +1 -1
- package/dist/gateway/static/root/assets/{phone-dependencies-card-D8bqsDk_.js → phone-dependencies-card-DBiKtzwz.js} +1 -1
- package/dist/gateway/static/root/assets/{phone-model-picker-CL_Zn6Xd.js → phone-model-picker-BmSxEr7M.js} +1 -1
- package/dist/gateway/static/root/assets/{phone-settings-page-C5Jia8eQ.js → phone-settings-page-vg65qilc.js} +1 -1
- package/dist/gateway/static/root/assets/{phone-workspace-store-FBfrfkYq.js → phone-workspace-store-SN7hfddU.js} +1 -1
- package/dist/gateway/static/root/assets/{plugin-details-dialog-gAq2KPzK.js → plugin-details-dialog-B3Hn2cbx.js} +1 -1
- package/dist/gateway/static/root/assets/{preference-select-fields-Ck8GAX_y.js → preference-select-fields-Cu_ZC9Up.js} +1 -1
- package/dist/gateway/static/root/assets/{product-automation-feedback-BJ9oTnNs.js → product-automation-feedback-Tn2dUJWM.js} +1 -1
- package/dist/gateway/static/root/assets/{product-open-page-Dw9hUdxP.js → product-open-page-Nf-Oqf1h.js} +1 -1
- package/dist/gateway/static/root/assets/{product-preview-content-C0iPzmSm.js → product-preview-content-D6NwUm3A.js} +1 -1
- package/dist/gateway/static/root/assets/{product-preview-modal-COFtHoh6.js → product-preview-modal-BfNcGgXA.js} +2 -2
- package/dist/gateway/static/root/assets/{project-detail-page-C5Amjah-.js → project-detail-page-Ch-ZMyTu.js} +1 -1
- package/dist/gateway/static/root/assets/{project-understanding-DpL9ADQU.js → project-understanding-B1BK7Ixi.js} +1 -1
- package/dist/gateway/static/root/assets/{projects-page-gGg9nM2t.js → projects-page-B7cetxao.js} +1 -1
- package/dist/gateway/static/root/assets/{providers-api-D6JJRlJb.js → providers-api-DOnNfkwQ.js} +1 -1
- package/dist/gateway/static/root/assets/{recording-upload-DxX1xKyt.js → recording-upload-RAhaLUcQ.js} +1 -1
- package/dist/gateway/static/root/assets/{registry-api-BfXzBR1D.js → registry-api-DFDvOTg4.js} +1 -1
- package/dist/gateway/static/root/assets/{remote-access-hub-BZA4StwC.js → remote-access-hub-DWsOWetc.js} +1 -1
- package/dist/gateway/static/root/assets/{resource-unavailable-X-SIrZYI.js → resource-unavailable-TQcRCpAg.js} +1 -1
- package/dist/gateway/static/root/assets/{route-preload-CWRb0UCt.js → route-preload-Zc5Z3fNv.js} +2 -2
- package/dist/gateway/static/root/assets/{runtime-tools-api-1DjsPyQ5.js → runtime-tools-api-9o3Wfji1.js} +1 -1
- package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-BnCtyORj.js → runtime-tools-settings-panel-BGiXeHF5.js} +1 -1
- package/dist/gateway/static/root/assets/{service-recommendation-list-ChSOfHHh.js → service-recommendation-list-BEnNx0u7.js} +1 -1
- package/dist/gateway/static/root/assets/{session-api-rvY5aWw8.js → session-api-Bs3r_d2_.js} +1 -1
- package/dist/gateway/static/root/assets/session-manager-ChUtTAoG.js +23 -0
- package/dist/gateway/static/root/assets/{sessions-page-DAS2IUGT.js → sessions-page-Bt52kBvJ.js} +1 -1
- package/dist/gateway/static/root/assets/settings-advanced-gate-BI4DMz4_.js +1 -0
- package/dist/gateway/static/root/assets/{settings-advanced-section-ZKRIuk7h.js → settings-advanced-section-CURRjsLK.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-mode-store-CtJ8pEfm.js → settings-mode-store-CiRpsdTJ.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-B3pUce-_.js → settings-page-GtsbT6as.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-header-DuNCn8i-.js → settings-page-header-DBL0_u0Z.js} +1 -1
- package/dist/gateway/static/root/assets/{settings-page-layout-DeNC8YHJ.js → settings-page-layout-IAvpbz4A.js} +1 -1
- package/dist/gateway/static/root/assets/{setup-status-panel-Fc3vuz_h.js → setup-status-panel-A6uMpGRy.js} +1 -1
- package/dist/gateway/static/root/assets/{share-link-dialog-B3hwjVAx.js → share-link-dialog-D1otGSXD.js} +1 -1
- package/dist/gateway/static/root/assets/{share-preview-page-D_9oFzGS.js → share-preview-page-L9KYu8M7.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-api-BoUpXmxq.js → shares-api-D8Q-m46d.js} +1 -1
- package/dist/gateway/static/root/assets/{shares-settings-Drfuvepz.js → shares-settings-Bmfadz8A.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-api-By2HhJ9O.js → skill-api-uKU4sRiv.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-list-api-TaUCzS8Y.js → skill-list-api-BzKzG-xG.js} +1 -1
- package/dist/gateway/static/root/assets/{skill-reload-api-CN2fpS1n.js → skill-reload-api-DkUXekcd.js} +1 -1
- package/dist/gateway/static/root/assets/{skills-page-LzGLique.js → skills-page-BZklXTX9.js} +1 -1
- package/dist/gateway/static/root/assets/{system-settings-panel-Cuyg8Ml3.js → system-settings-panel-CsvcFoaJ.js} +1 -1
- package/dist/gateway/static/root/assets/task-detail-page-SjZGW1Dx.js +2 -0
- package/dist/gateway/static/root/assets/{task-result-evidence-DDubAU_5.js → task-result-evidence-B8xUiwW3.js} +1 -1
- package/dist/gateway/static/root/assets/{terminal-panel-store-BNs75Wdr.js → terminal-panel-store-DJVC7HqA.js} +1 -1
- package/dist/gateway/static/root/assets/{theme-store-DB1ZfBUm.js → theme-store-Dlnmgryi.js} +1 -1
- package/dist/gateway/static/root/assets/tool-friendly-title-DcCc6g7o.js +1 -0
- package/dist/gateway/static/root/assets/{tracing-settings-page-TvtX4Goh.js → tracing-settings-page-MvG4SH64.js} +1 -1
- package/dist/gateway/static/root/assets/{tunnel-api-COoVEdV9.js → tunnel-api-BB7u79ID.js} +1 -1
- package/dist/gateway/static/root/assets/{understanding-activity-store-Dr_MLgYe.js → understanding-activity-store-C4bblRnQ.js} +1 -1
- package/dist/gateway/static/root/assets/{understanding-refresh-store-DGmLGEqw.js → understanding-refresh-store-BvCj9-Ue.js} +1 -1
- package/dist/gateway/static/root/assets/{usage-page-DP6eb6ed.js → usage-page-Cv4Je5XJ.js} +1 -1
- package/dist/gateway/static/root/assets/{use-autosave-itwjDYUb.js → use-autosave-YHxQ-UZg.js} +1 -1
- package/dist/gateway/static/root/assets/{use-composer-attachments-hjIGlI_2.js → use-composer-attachments-vDdxHtUb.js} +1 -1
- package/dist/gateway/static/root/assets/{use-file-preview-expanded-ClLa0g8D.js → use-file-preview-expanded-Ce2mgYme.js} +2 -2
- package/dist/gateway/static/root/assets/{use-personal-profile-vhWk6tTU.js → use-personal-profile-D2Un8G1L.js} +1 -1
- package/dist/gateway/static/root/assets/{use-workspace-tree-dfXXjA2-.js → use-workspace-tree-BQEiJzK7.js} +1 -1
- package/dist/gateway/static/root/assets/{user-model-page-D8dswPWd.js → user-model-page-DRSsn4EV.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-api-key-field-BIfBySnN.js → voice-api-key-field-DCM69u8Y.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-config-api-J4o59ICE.js → voice-config-api-CrULrSKC.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-input-shortcut-events-B1mlpUdC.js → voice-input-shortcut-events-DFMNIyy4.js} +1 -1
- package/dist/gateway/static/root/assets/{voice-transcribe-api-xxaSOOmq.js → voice-transcribe-api-Bbyj0yGR.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-overlay-DqwT1E5u.js → work-discovery-overlay-CVe9UmFl.js} +1 -1
- package/dist/gateway/static/root/assets/{work-discovery-page-BzYQmPLT.js → work-discovery-page-CtqkRMN5.js} +1 -1
- package/dist/gateway/static/root/assets/{working-directory-picker-modal-D2Zf3GOG.js → working-directory-picker-modal-CDZ1xh3o.js} +1 -1
- package/dist/gateway/static/root/assets/{workspace-api-Bnx3eS2M.js → workspace-api-tbifz2zY.js} +2 -2
- package/dist/gateway/static/root/assets/workspace-editor-agent-store-4cZ26iaD.js +1 -0
- package/dist/gateway/static/root/assets/{workspace-file-preview-dialog-D13qHzVr.js → workspace-file-preview-dialog-BubQwQwU.js} +1 -1
- package/dist/gateway/static/root/assets/{workspace-open-location-menu-Cou-ig1H.js → workspace-open-location-menu-DZk3MBSa.js} +1 -1
- package/dist/gateway/static/root/assets/{xopc-cloud-account-card-DQGPKxHA.js → xopc-cloud-account-card-CIavPUr3.js} +1 -1
- package/dist/gateway/static/root/index.html +81 -81
- package/dist/package.js +1 -1
- package/dist/packages/computer-control-contract/src/index.js +33 -3
- package/dist/src/agent/embedded/run-turn.js +64 -4
- package/dist/src/agent/tool-manuals/computer.d.ts +1 -1
- package/dist/src/agent/tool-manuals/computer.js +6 -0
- package/dist/src/agent/tools/computer-use-tool.js +18 -5
- package/dist/src/agent/tools/phone-use-tool.js +12 -2
- package/dist/src/computer/agent-context.d.ts +21 -0
- package/dist/src/computer/agent-context.js +107 -0
- package/dist/src/computer/broker.d.ts +4 -2
- package/dist/src/computer/broker.js +26 -11
- package/dist/src/computer/diagnostics.d.ts +60 -6
- package/dist/src/computer/diagnostics.js +45 -4
- package/dist/src/computer/errors.d.ts +1 -1
- package/dist/src/computer/errors.js +4 -0
- package/dist/src/computer/evaluation.d.ts +2 -2
- package/dist/src/computer/native-timing.d.ts +15 -0
- package/dist/src/computer/native-timing.js +49 -0
- package/dist/src/computer/program-runtime.d.ts +22 -0
- package/dist/src/computer/program-runtime.js +105 -0
- package/dist/src/computer/runtime.d.ts +36 -2
- package/dist/src/computer/runtime.js +269 -58
- package/dist/src/config/models-json.d.ts +12 -0
- package/dist/src/config/schema.d.ts +18 -0
- package/dist/src/gateway/hono/routes/phone-setup.js +12 -7
- package/dist/src/gateway/hono/routes/phone.js +2 -4
- package/dist/src/gateway/service/config-coordinator.d.ts +6 -0
- package/dist/src/gateway/service.js +4 -4
- package/dist/src/gateway/xopc-cloud-capability-setup.js +9 -1
- package/dist/src/home-intelligence/host.js +2 -2
- package/dist/src/phone/adb-driver.d.ts +15 -1
- package/dist/src/phone/adb-driver.js +104 -41
- package/dist/src/phone/autoglm-protocol.d.ts +36 -0
- package/dist/src/phone/autoglm-protocol.js +88 -0
- package/dist/src/phone/autoglm-upstream-prompt.d.ts +2 -0
- package/dist/src/phone/autoglm-upstream-prompt.js +5 -0
- package/dist/src/phone/autoglm-upstream.LICENSE +201 -0
- package/dist/src/phone/cloud-adb-connection.d.ts +3 -0
- package/dist/src/phone/cloud-adb-connection.js +105 -31
- package/dist/src/phone/cloud-adb.js +18 -6
- package/dist/src/phone/completion-recovery.d.ts +6 -0
- package/dist/src/phone/completion-recovery.js +30 -0
- package/dist/src/phone/contracts.d.ts +24 -0
- package/dist/src/phone/contracts.js +12 -1
- package/dist/src/phone/execution-trace.d.ts +51 -0
- package/dist/src/phone/execution-trace.js +78 -0
- package/dist/src/phone/gui-protocol.d.ts +7 -0
- package/dist/src/phone/gui-protocol.js +302 -0
- package/dist/src/phone/model-adapter.d.ts +10 -2
- package/dist/src/phone/model-adapter.js +136 -62
- package/dist/src/phone/model-response.d.ts +5 -0
- package/dist/src/phone/model-response.js +118 -0
- package/dist/src/phone/runtime.d.ts +4 -0
- package/dist/src/phone/runtime.js +154 -18
- package/dist/src/phone/text-session.d.ts +14 -0
- package/dist/src/phone/text-session.js +39 -0
- package/dist/src/phone/ui-dump-binary.d.ts +1 -1
- package/dist/src/phone/ui-dump-binary.js +1 -1
- package/dist/src/phone/ui-session.d.ts +24 -0
- package/dist/src/phone/ui-session.js +210 -0
- package/dist/src/process/phone-process.d.ts +1 -0
- package/dist/src/process/phone-process.js +11 -1
- package/dist/src/providers/env-keys.js +2 -0
- package/dist/src/providers/index.js +11 -0
- package/dist/src/providers/model-catalog-types.d.ts +1 -1
- package/dist/src/providers/model-supplements.d.ts +1 -1
- package/dist/src/providers/model-supplements.js +6 -3
- package/dist/src/providers/phone-models.d.ts +3 -0
- package/dist/src/providers/phone-models.js +33 -0
- package/dist/src/providers/presentation.js +0 -1
- package/dist/src/tui/tui.js +1 -1
- package/dist/src/voice/platform-catalog.d.ts +1 -1
- package/package.json +2 -1
- package/dist/gateway/static/root/assets/chat-page-CafkCKOj.js +0 -72
- package/dist/gateway/static/root/assets/connected-providers-grid-b46VH4uy.js +0 -1
- package/dist/gateway/static/root/assets/device-pairing-wizard-1du1hfi5.js +0 -1
- package/dist/gateway/static/root/assets/gateway-realtime-store-DcsZyYEa.js +0 -1
- package/dist/gateway/static/root/assets/index-BS9mjvSL.js +0 -11
- package/dist/gateway/static/root/assets/index-pT-m6l6b.css +0 -1
- package/dist/gateway/static/root/assets/messages-DaLmc4W1.js +0 -3
- package/dist/gateway/static/root/assets/note-image-lightbox-DticJxxh.js +0 -1
- package/dist/gateway/static/root/assets/page-header-store-D6SzJ9Ch.js +0 -1
- package/dist/gateway/static/root/assets/session-manager-D2rbRfX3.js +0 -23
- package/dist/gateway/static/root/assets/settings-advanced-gate-CYDQybNF.js +0 -1
- package/dist/gateway/static/root/assets/task-detail-page-6A9337pK.js +0 -2
- package/dist/gateway/static/root/assets/tool-friendly-title-DGmi7rCQ.js +0 -1
- package/dist/gateway/static/root/assets/workspace-editor-agent-store-COUVwj-p.js +0 -1
package/dist/gateway/static/root/assets/{connectors-page-Mq9Bvoax.js → connectors-page-Ci0L2How.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{m as i,u as a}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{i as o,l as s,n as c,o as l}from"./locale-store-TQcz_Vjt.js";import{t as u}from"./messages-DaLmc4W1.js";import{i as d,n as f,r as p,t as m}from"./service-recommendation-list-ChSOfHHh.js";import{t as h}from"./chevron-down-ccbiQQz_.js";import{t as g}from"./chevron-right-BweFrslA.js";import{n as _,r as v,t as y}from"./popover-select-DD8fmrxH.js";import{t as b}from"./circle-alert-BEjgurr2.js";import{t as x}from"./circle-check-C23XjkUj.js";import{t as S}from"./circle-pause-CN9jYH2s.js";import{a as C,i as w,n as T,r as E,t as D}from"./connector-filters-Cfcx9EA2.js";import{t as O}from"./clock-3-DnrAnuyZ.js";import{t as k}from"./database-CjjeZfRG.js";import{t as A}from"./ellipsis-0k4rZLoy.js";import{t as j}from"./external-link-DjqjBmc3.js";import{n as M}from"./secret-input-BQvFXqzz.js";import{t as N}from"./eye-CABVeTq0.js";import{t as P}from"./key-round-DWbpyU2U.js";import{t as F}from"./loader-circle-CifKLtgG.js";import{a as I,c as L,i as R,n as z,o as B,r as V,s as H,t as U}from"./install-connector-dialog-BNzNuXJ8.js";import{t as ee}from"./plug-DKYPEgkR.js";import{t as W}from"./plus-Q2yW6OE7.js";import{t as te}from"./refresh-cw-BRlGaq2w.js";import{t as G}from"./save-DRDABU--.js";import{t as K}from"./server-BlHCBjiE.js";import{t as ne}from"./settings-uiTATseT.js";import{t as re}from"./store-SzD1Jvgm.js";import{t as q}from"./terminal-oKqqZdiG.js";import{t as ie}from"./trash-2-DusmjVPV.js";import{t as J}from"./wrench-DFb4r8bH.js";import{t as ae}from"./x-B_N4OPjy.js";import{t as Y}from"./cn-0WouolD0.js";import{t as X}from"./button-CnRSIP6m.js";import{t as Z}from"./skeleton-BI5TyibZ.js";import{a as oe,i as se,n as ce,o as le,r as ue,s as de,t as fe}from"./dist-DfWfZ9iu.js";import{i as pe}from"./vendor-swr-CdRzEUwF.js";import{r as me}from"./extension-provider-BZwcaU5Y.js";import{n as he}from"./copy-to-clipboard-HOJ79TWv.js";import{n as ge}from"./interaction-BdhHBbYa.js";import{n as _e,r as ve}from"./gateway-config-swr-Dmt5JhZU.js";import{A as ye,E as be,F as xe,I as Se,L as Ce,M as we,N as Te,O as Ee,P as De,R as Oe,S as ke,_ as Ae,a as je,c as Me,d as Ne,i as Pe,j as Fe,l as Ie,m as Le,n as Re,o as ze,p as Be,r as Ve,s as He,u as Ue,v as We,w as Ge,x as Ke,y as qe,z as Je}from"./connectors-api-CwRuUnH4.js";import{s as Ye}from"./form-field-width-DJw_jULe.js";import{n as Xe}from"./electron-env-DHOGevH3.js";import{t as Ze}from"./page-tabs-oeTY7z3_.js";import{t as Qe}from"./page-header-store-D6SzJ9Ch.js";import{t as $e}from"./sliding-tab-list-DuQyViqe.js";import{t as et}from"./confirm-dialog-XGclfBqe.js";import{l as tt,m as nt,o as rt,r as it,t as at}from"./dist-D3lWNSe7.js";import{t as ot}from"./capability-links-DzQWK1Fh.js";import{t as st}from"./capability-icon-DVoZxEgW.js";import{n as ct,t as lt}from"./capability-header-actions-CTUCuBlW.js";import{t as ut}from"./connector-service-page-BqDbTOTp.js";import{t as dt}from"./number-input-El7Szeln.js";var Q=e(t(),1),ft=n(),$=r();function pt(e){let t=(0,ft.c)(57),{connector:n,installed:r,onInstall:i,onOpenDetails:a,t:o}=e,s,c,l,u,d,f;if(t[0]!==n||t[1]!==r||t[2]!==i||t[3]!==a||t[4]!==o){let e=n.capabilities.filter(mt),p=e.slice(0,2),m=Math.max(0,e.length-p.length),h=o.connect,g;t[11]!==n||t[12]!==o?(g=R(n,o),t[11]=n,t[12]=o,t[13]=g):g=t[13];let _=g,v=n.verificationLevel===`verified`?o.connectorVerified:n.verificationLevel===`beta`?o.connectorBeta:n.verificationLevel===`experimental`?o.connectorExperimental:null,y;t[14]!==h||t[15]!==n||t[16]!==i?(y=e=>(0,$.jsxs)(X,{type:`button`,variant:`secondary`,className:Y(`h-8 justify-center px-2.5 text-xs font-medium`,e),onClick:()=>i(n),children:[(0,$.jsx)(L,{className:`size-4`}),h]}),t[14]=h,t[15]=n,t[16]=i,t[17]=y):y=t[17],s=y,f=`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 b;t[18]===n?b=t[19]:(b=(0,$.jsx)(z,{connector:n}),t[18]=n,t[19]=b);let S;t[20]!==n||t[21]!==a?(S=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]=S):S=t[22];let C;t[23]===v?C=t[24]:(C=v?(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:v}):null,t[23]=v,t[24]=C);let w;t[25]!==C||t[26]!==S?(w=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[S,C]}),t[25]=C,t[26]=S,t[27]=w):w=t[27];let T;t[28]!==w||t[29]!==b?(T=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[b,w]}),t[28]=w,t[29]=b,t[30]=T):T=t[30];let E;t[31]!==r||t[32]!==s?(E=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]=E):E=t[33];let D;t[34]!==r||t[35]!==o.connectedBadge?(D=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)(x,{className:`size-3`,"aria-hidden":!0}),o.connectedBadge]}):null,t[34]=r,t[35]=o.connectedBadge,t[36]=D):D=t[36];let O;t[37]!==E||t[38]!==D?(O=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start gap-2`,children:[E,D]}),t[37]=E,t[38]=D,t[39]=O):O=t[39],t[40]!==T||t[41]!==O?(l=(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[T,O]}),t[40]=T,t[41]=O,t[42]=l):l=t[42],t[43]===_?u=t[44]:(u=(0,$.jsx)(`p`,{className:`mt-3 line-clamp-2 text-sm leading-6 text-fg-muted`,title:_,children:_}),t[43]=_,t[44]=u),d=p.length>0?(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:[p.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)),m>0?(0,$.jsxs)(`span`,{className:`rounded-md bg-surface-base px-2 py-0.5 text-[11px] text-fg-subtle`,children:[`+`,m]}):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]=d,t[10]=f}else s=t[5],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10];let p;t[45]!==c||t[46]!==l||t[47]!==u||t[48]!==d?(p=(0,$.jsxs)(`div`,{className:c,children:[l,u,d]}),t[45]=c,t[46]=l,t[47]=u,t[48]=d,t[49]=p):p=t[49];let m;t[50]!==r||t[51]!==s?(m=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]=m):m=t[52];let h;return t[53]!==f||t[54]!==p||t[55]!==m?(h=(0,$.jsxs)(`div`,{className:f,children:[p,m]}),t[53]=f,t[54]=p,t[55]=m,t[56]=h):h=t[56],h}function mt(e){return!e.startsWith(`runtime.`)&&!e.startsWith(`auth.`)}var ht=[`c0`,`c1`,`c2`,`c3`,`c4`,`c5`];function gt(e,t){return t.some(t=>t.connectorId===e.id)}var _t=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`;function vt(){let e=(0,ft.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`div`,{className:Y(`size-10 shrink-0 rounded-xl`,_t)}),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:Y(`h-4 min-w-0 flex-1`,_t)}),(0,$.jsx)(`div`,{className:Y(`h-8 w-[4.5rem] shrink-0 rounded-lg`,_t)})]}),(0,$.jsx)(`div`,{className:Y(`h-3 w-full`,_t)}),(0,$.jsx)(`div`,{className:Y(`h-3 w-[88%]`,_t)})]})]})}),e[1]=n):n=e[1],n}function yt(){let e=(0,ft.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(Z,{className:`size-9 shrink-0 rounded-lg`}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsxs)(`div`,{className:`flex min-h-[8.75rem] min-w-0 flex-col rounded-xl border border-edge bg-surface-panel p-4`,"aria-hidden":!0,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[t,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2`,children:[(0,$.jsx)(Z,{className:`h-4 w-28 max-w-full`}),(0,$.jsx)(Z,{className:`h-3 w-20 max-w-full`})]})]}),(0,$.jsx)(Z,{className:`mt-2 h-3 w-48 max-w-full`}),(0,$.jsx)(Z,{className:`ml-auto mt-auto h-3 w-16`})]}),e[1]=n):n=e[1],n}var bt=[`understand`,`act`,`reach`];function xt(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 St(e){return xt(e)[0]??`act`}function Ct(e,t){let n=t?St(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 wt(e,t){return t.connectorCapabilityLabels[e]??e}function Tt(e,t){if(e.runtime.type===`mcp`)return I(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 I(t.connectorRuntimeGeneric,{runtime:e.runtime.type,id:n??e.runtime.type})}function Et(e,t){return e.auth.mode===`cli`?t.connectorAuthCli:e.auth.mode===`oauth`?t.connectorAuthOAuth:e.auth.mode===`apiKey`?t.connectorAuthApiKey:t.connectorAuthNone}function Dt(e){let t=(0,ft.c)(133),{connector:n,installed:r,onClose:i,onInstall:a,t:o}=e,s;t[0]!==n||t[1]!==o?(s=R(n,o),t[0]=n,t[1]=o,t[2]=s):s=t[2];let c=s,l,u,d,f,p,m,h,g,_,v,y,b,S,C,w,T;if(t[3]!==n||t[4]!==c||t[5]!==r||t[6]!==i||t[7]!==o){let e=xt(n),a;t[24]!==n.setup.config||t[25]!==n.setup.secrets?(a=[...(n.setup.secrets??[]).filter(At),...(n.setup.config??[]).filter(kt)],t[24]=n.setup.config,t[25]=n.setup.secrets,t[26]=a):a=t[26];let s=a,E=n.capabilities.filter(Ot);d=fe,h=!0,t[27]===i?g=t[28]:(g=e=>{e||i()},t[27]=i,t[28]=g),u=le,t[29]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(oe,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),t[29]=m):m=t[29],l=ue,t[30]===Symbol.for(`react.memo_cache_sentinel`)?(f=Y(`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]=f):f=t[30];let D;t[31]===n?D=t[32]:(D=(0,$.jsx)(z,{connector:n,size:`lg`}),t[31]=n,t[32]=D);let O;t[33]===n.displayName?O=t[34]:(O=(0,$.jsx)(de,{className:`text-base font-semibold text-fg`,children:n.displayName}),t[33]=n.displayName,t[34]=O);let k;t[35]!==r||t[36]!==o.connectedBadge?(k=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)(x,{className:`size-3`,"aria-hidden":!0}),o.connectedBadge]}):null,t[35]=r,t[36]=o.connectedBadge,t[37]=k):k=t[37];let A;t[38]!==O||t[39]!==k?(A=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[O,k]}),t[38]=O,t[39]=k,t[40]=A):A=t[40];let j;t[41]===c?j=t[42]:(j=(0,$.jsx)(se,{className:`mt-1 line-clamp-3 text-sm leading-6 text-fg-muted`,children:c}),t[41]=c,t[42]=j);let M;t[43]!==A||t[44]!==j?(M=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[A,j]}),t[43]=A,t[44]=j,t[45]=M):M=t[45];let N;t[46]!==D||t[47]!==M?(N=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[D,M]}),t[46]=D,t[47]=M,t[48]=N):N=t[48];let F;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(F=Y(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,ge.focusRingPanel),t[49]=F):F=t[49];let L;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,$.jsx)(ae,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),t[50]=L):L=t[50];let R;t[51]===o.modalClose?R=t[52]:(R=(0,$.jsx)(ce,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:F,"aria-label":o.modalClose,children:L})}),t[51]=o.modalClose,t[52]=R),t[53]!==N||t[54]!==R?(p=(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:[N,R]}),t[53]=N,t[54]=R,t[55]=p):p=t[55],C=`min-h-0 flex-1 space-y-5 overflow-y-auto px-5 py-5 sm:px-6`,w=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 B;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,$.jsx)(P,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),t[56]=B):B=t[56];let V;t[57]===o.detailPermissions?V=t[58]:(V=(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:o.detailPermissions}),t[57]=o.detailPermissions,t[58]=V);let H;t[59]!==n||t[60]!==o?(H=Et(n,o),t[59]=n,t[60]=o,t[61]=H):H=t[61];let U;t[62]===H?U=t[63]:(U=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:H}),t[62]=H,t[63]=U);let ee;t[64]!==V||t[65]!==U?(ee=(0,$.jsxs)(`div`,{className:`flex items-start gap-3 border-b border-edge-subtle px-4 py-3`,children:[B,(0,$.jsxs)(`div`,{children:[V,U]})]}),t[64]=V,t[65]=U,t[66]=ee):ee=t[66];let W;t[67]===o.connectorSetupTitle?W=t[68]:(W=(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:o.connectorSetupTitle}),t[67]=o.connectorSetupTitle,t[68]=W);let te;t[69]!==s.length||t[70]!==o.connectorRequiredInputsCount||t[71]!==o.connectorSetupNone?(te=s.length?I(o.connectorRequiredInputsCount,{count:String(s.length)}):o.connectorSetupNone,t[69]=s.length,t[70]=o.connectorRequiredInputsCount,t[71]=o.connectorSetupNone,t[72]=te):te=t[72];let G;t[73]===te?G=t[74]:(G=(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:te}),t[73]=te,t[74]=G);let ne;t[75]!==W||t[76]!==G?(ne=(0,$.jsxs)(`div`,{className:`px-4 py-3`,children:[W,G]}),t[75]=W,t[76]=G,t[77]=ne):ne=t[77],t[78]!==ee||t[79]!==ne?(T=(0,$.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-base`,children:[ee,ne]}),t[78]=ee,t[79]=ne,t[80]=T):T=t[80],b=`rounded-xl border border-edge bg-surface-base`,t[81]===o.connectorTechnicalDetails?S=t[82]:(S=(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]=S),_=`space-y-5 border-t border-edge-subtle px-4 py-4`;let re;t[83]===Symbol.for(`react.memo_cache_sentinel`)?(re=(0,$.jsx)(K,{className:`size-3.5`,"aria-hidden":!0}),t[83]=re):re=t[83];let q;t[84]===o.connectorRuntimeTitle?q=t[85]:(q=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[re,o.connectorRuntimeTitle]}),t[84]=o.connectorRuntimeTitle,t[85]=q);let ie;t[86]!==n||t[87]!==o?(ie=Tt(n,o),t[86]=n,t[87]=o,t[88]=ie):ie=t[88];let J;t[89]===ie?J=t[90]:(J=(0,$.jsx)(`p`,{className:`mt-1 break-words text-xs text-fg-subtle`,children:ie}),t[89]=ie,t[90]=J),t[91]!==q||t[92]!==J?(v=(0,$.jsxs)(`div`,{children:[q,J]}),t[91]=q,t[92]=J,t[93]=v):v=t[93],y=E.length?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:E.map(e=>(0,$.jsx)(`span`,{className:`rounded-md bg-surface-panel px-2 py-1 text-xs text-fg-muted`,children:wt(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]=d,t[11]=f,t[12]=p,t[13]=m,t[14]=h,t[15]=g,t[16]=_,t[17]=v,t[18]=y,t[19]=b,t[20]=S,t[21]=C,t[22]=w,t[23]=T}else l=t[8],u=t[9],d=t[10],f=t[11],p=t[12],m=t[13],h=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=t[23];let E;t[94]!==_||t[95]!==v||t[96]!==y?(E=(0,$.jsxs)(`div`,{className:_,children:[v,y]}),t[94]=_,t[95]=v,t[96]=y,t[97]=E):E=t[97];let D;t[98]!==E||t[99]!==b||t[100]!==S?(D=(0,$.jsxs)(`details`,{className:b,children:[S,E]}),t[98]=E,t[99]=b,t[100]=S,t[101]=D):D=t[101];let O;t[102]!==D||t[103]!==C||t[104]!==w||t[105]!==T?(O=(0,$.jsxs)(`div`,{className:C,children:[w,T,D]}),t[102]=D,t[103]=C,t[104]=w,t[105]=T,t[106]=O):O=t[106];let k;t[107]===o.modalClose?k=t[108]:(k=(0,$.jsx)(ce,{asChild:!0,children:(0,$.jsx)(X,{variant:`secondary`,children:o.modalClose})}),t[107]=o.modalClose,t[108]=k);let A;t[109]!==n||t[110]!==r||t[111]!==i||t[112]!==a||t[113]!==o.connect?(A=r?null:(0,$.jsxs)(X,{variant:`primary`,onClick:()=>{a(n),i()},children:[(0,$.jsx)(L,{className:`size-4`}),o.connect]}),t[109]=n,t[110]=r,t[111]=i,t[112]=a,t[113]=o.connect,t[114]=A):A=t[114];let j;t[115]!==k||t[116]!==A?(j=(0,$.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-5 py-4 sm:px-6`,children:[k,A]}),t[115]=k,t[116]=A,t[117]=j):j=t[117];let M;t[118]!==l||t[119]!==f||t[120]!==p||t[121]!==O||t[122]!==j?(M=(0,$.jsxs)(l,{className:f,children:[p,O,j]}),t[118]=l,t[119]=f,t[120]=p,t[121]=O,t[122]=j,t[123]=M):M=t[123];let N;t[124]!==u||t[125]!==m||t[126]!==M?(N=(0,$.jsxs)(u,{children:[m,M]}),t[124]=u,t[125]=m,t[126]=M,t[127]=N):N=t[127];let F;return t[128]!==d||t[129]!==h||t[130]!==g||t[131]!==N?(F=(0,$.jsx)(d,{open:h,onOpenChange:g,children:N}),t[128]=d,t[129]=h,t[130]=g,t[131]=N,t[132]=F):F=t[132],F}function Ot(e){return!e.startsWith(`runtime.`)&&!e.startsWith(`auth.`)}function kt(e){return e.required}function At(e){return e.required}var jt=(0,Q.memo)(function(e){let t=(0,ft.c)(45),{onRefresh:n,refreshing:r,refreshLabel:i,onBrowseCatalog:a,onAddCustomServer:o,addLabel:s,browseLabel:c,customLabel:l,serviceLabel:u,moreActionsLabel:d}=e,[f,p]=(0,Q.useState)(!1),m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=Y(`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`,ge.transition),t[0]=m):m=t[0];let g=m,_;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(W,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[1]=_):_=t[1];let v;t[2]===s?v=t[3]:(v=(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:s}),t[2]=s,t[3]=v);let y;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(h,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[4]=y):y=t[4];let b;t[5]!==s||t[6]!==v?(b=(0,$.jsx)(nt,{asChild:!0,children:(0,$.jsxs)(X,{type:`button`,variant:`primary`,className:`shrink-0 gap-2`,"aria-label":s,children:[_,v,y]})}),t[5]=s,t[6]=v,t[7]=b):b=t[7];let x;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(re,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[8]=x):x=t[8];let S;t[9]!==c||t[10]!==a?(S=(0,$.jsxs)(it,{className:g,onSelect:a,children:[x,c]}),t[9]=c,t[10]=a,t[11]=S):S=t[11];let C;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,$.jsx)(J,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[12]=C):C=t[12];let w;t[13]!==l||t[14]!==o?(w=(0,$.jsxs)(it,{className:g,onSelect:o,children:[C,l]}),t[13]=l,t[14]=o,t[15]=w):w=t[15];let T;t[16]!==S||t[17]!==w?(T=(0,$.jsx)(rt,{children:(0,$.jsxs)(at,{className:`z-50 min-w-[14rem] rounded-xl border border-edge bg-surface-overlay p-1 shadow-popover dark:border-edge`,sideOffset:6,align:`end`,children:[S,w]})}),t[16]=S,t[17]=w,t[18]=T):T=t[18];let E;t[19]!==T||t[20]!==b?(E=(0,$.jsxs)(tt,{children:[b,T]}),t[19]=T,t[20]=b,t[21]=E):E=t[21];let D;t[22]===f?D=t[23]:(D=(0,$.jsx)(ut,{open:f,onOpenChange:p,hideTrigger:!0}),t[22]=f,t[23]=D);let O;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,$.jsx)(A,{className:`size-4`,"aria-hidden":!0}),t[24]=O):O=t[24];let k;t[25]===d?k=t[26]:(k=(0,$.jsx)(nt,{asChild:!0,children:(0,$.jsx)(X,{type:`button`,variant:`secondary`,className:`size-9 shrink-0 p-0`,"aria-label":d,title:d,children:O})}),t[25]=d,t[26]=k);let j;t[27]!==n||t[28]!==i||t[29]!==r?(j=n?(0,$.jsxs)(it,{className:g,disabled:r,onSelect:n,children:[r?(0,$.jsx)(F,{className:`size-4 animate-spin text-fg-muted`,"aria-hidden":!0}):(0,$.jsx)(te,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),i]}):null,t[27]=n,t[28]=i,t[29]=r,t[30]=j):j=t[30];let M,N;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(M=()=>p(!0),N=(0,$.jsx)(ne,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),t[31]=M,t[32]=N):(M=t[31],N=t[32]);let P;t[33]===u?P=t[34]:(P=(0,$.jsxs)(it,{className:g,onSelect:M,children:[N,u]}),t[33]=u,t[34]=P);let I;t[35]!==j||t[36]!==P?(I=(0,$.jsx)(rt,{children:(0,$.jsxs)(at,{className:`z-50 min-w-[14rem] rounded-xl border border-edge bg-surface-overlay p-1 shadow-popover dark:border-edge`,sideOffset:6,align:`end`,children:[j,P]})}),t[35]=j,t[36]=P,t[37]=I):I=t[37];let L;t[38]!==k||t[39]!==I?(L=(0,$.jsxs)(tt,{children:[k,I]}),t[38]=k,t[39]=I,t[40]=L):L=t[40];let R;return t[41]!==E||t[42]!==D||t[43]!==L?(R=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2`,children:[E,D,L]}),t[41]=E,t[42]=D,t[43]=L,t[44]=R):R=t[44],R});function Mt(e=``,t=``){return{clientKey:crypto.randomUUID(),key:e,value:t}}var Nt=/^([^:=]+)[:=](.*)$/;function Pt(e){let t=e.trim();if(!t)return null;try{let e=JSON.parse(t);if(e&&typeof e==`object`&&!Array.isArray(e))return It(e)}catch{}let n=[];for(let e of t.split(/\r?\n/)){let t=e.trim();if(!t)continue;let r=Nt.exec(t);r&&n.push(Mt(r[1].trim(),r[2].trim()))}return n.length>0?n:null}function Ft(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 It(e){if(!e||typeof e!=`object`)return[Mt()];let t=Object.entries(e).map(([e,t])=>typeof t==`object`&&t&&!Array.isArray(t)?{...Mt(e),reference:t}:Mt(e,t==null?``:String(t)));return t.length>0?t:[Mt()]}function Lt(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 Rt(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 zt(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 Bt(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=Rt(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=Ft(e.envEntries);r&&(t.env=r)}else e.envJson.trim()&&(t.env=zt(e.envJson));delete t.oauth,delete t.auth}else{t.type=`http`,t.url=e.url.trim();let n=Ft(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 Vt(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:It(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 Ht(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 Ut(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 Wt(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=Vt(e,n);return r.clientKey=crypto.randomUUID(),r.url&&=Ut(r.url),r})}function Gt(e=``){return{clientKey:crypto.randomUUID(),id:e,transport:`streamable-http`,command:``,argsText:``,envJson:``,cwd:``,url:``,headers:[],oauthClientId:``,timeout:void 0,exposure:`codemode`,extra:{}}}function Kt(e){let t=e?.mcp?.servers??{};return{servers:Object.entries(t).filter(([,e])=>!Lt(e)).map(([e,t])=>Vt(e,t)).sort((e,t)=>e.id.localeCompare(t.id))}}function qt(e){return Bt(e)}async function Jt(e,t){return(await l(o(`/api/mcp/servers/${encodeURIComponent(e)}/tools`),{method:`POST`,signal:AbortSignal.any([t,AbortSignal.timeout(95e3)])})).payload.tools}async function Yt(e,t,n,r){return(await l(o(`/api/mcp/drafts`),{method:`POST`,signal:r,body:JSON.stringify({serverId:e.id,sourceServerId:t,expectedServer:n,server:Bt(e)})})).payload}async function Xt(e,t){return(await l(o(`/api/mcp/drafts/${encodeURIComponent(e)}/probe`),{method:`POST`,signal:AbortSignal.any([t,AbortSignal.timeout(95e3)])})).payload}async function Zt(e){await l(o(`/api/mcp/drafts/${encodeURIComponent(e)}`),{method:`DELETE`})}async function Qt(e,t=!1){let n=await l(o(`/api/mcp/drafts/${encodeURIComponent(e)}/commit`),{method:`POST`,body:JSON.stringify({enable:t})});return _e(),n.payload}async function $t(e){return(await l(o(`/api/mcp/drafts/${encodeURIComponent(e)}/auth`),{method:`POST`})).payload}async function en(e,t){return(await l(o(`/api/mcp/drafts/${encodeURIComponent(e)}/auth`),{signal:t})).payload}async function tn(e){await l(o(`/api/mcp/drafts/${encodeURIComponent(e)}/auth`),{method:`DELETE`})}async function nn(e,t){await l(o(`/api/mcp/drafts/${encodeURIComponent(e)}/auth/redirect`),{method:`POST`,body:JSON.stringify({url:t})})}async function rn(e,t){return(await l(o(`/api/mcp/drafts/${encodeURIComponent(e)}/tools`),{signal:t})).payload.tools}async function an(e){let t=await l(o(`/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 on(e){let t=await l(o(`/api/mcp/servers/${encodeURIComponent(e.id)}`),{method:`DELETE`,body:JSON.stringify({expectedServer:e.extra})});return _e(),t.payload}function sn(e){let t=(0,ft.c)(111),{serverId:n,displayName:r,returnFocusTo:i,draftId:a,t:o,onClose:s,onConfigure:c}=e,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=[],t[0]=l):l=t[0];let[u,d]=(0,Q.useState)(l),[f,p]=(0,Q.useState)(!0),[m,h]=(0,Q.useState)(``),[g,_]=(0,Q.useState)(``),[v,y]=(0,Q.useState)(0),b=(0,Q.useRef)(!1),x;t[1]!==a||t[2]!==n||t[3]!==o.setupAccessDenied||t[4]!==o.setupConflict||t[5]!==o.setupGatewayUnauthorized||t[6]!==o.setupRateLimited||t[7]!==o.toolsLoadFailed?(x=()=>{let e=new AbortController,t=!0;return p(!0),h(``),d([]),(a?rn(a,e.signal):Jt(n,e.signal)).then(e=>{t&&d(e)}).catch(e=>{let n=e?.status;t&&h(n===401?o.setupGatewayUnauthorized:n===403?o.setupAccessDenied:n===429?o.setupRateLimited:n===404||n===409?o.setupConflict:o.toolsLoadFailed)}).finally(()=>{t&&p(!1)}),()=>{t=!1,e.abort()}},t[1]=a,t[2]=n,t[3]=o.setupAccessDenied,t[4]=o.setupConflict,t[5]=o.setupGatewayUnauthorized,t[6]=o.setupRateLimited,t[7]=o.toolsLoadFailed,t[8]=x):x=t[8];let S;t[9]!==a||t[10]!==v||t[11]!==n||t[12]!==o?(S=[n,a,v,o],t[9]=a,t[10]=v,t[11]=n,t[12]=o,t[13]=S):S=t[13],(0,Q.useEffect)(x,S);let C,w,T,E,D,O,k,A,j,M,N,P,F;if(t[14]!==r||t[15]!==m||t[16]!==f||t[17]!==s||t[18]!==c||t[19]!==g||t[20]!==i||t[21]!==n||t[22]!==o.exposureLabels||t[23]!==o.setupConfigure||t[24]!==o.toolDetails||t[25]!==o.toolsClearSearch||t[26]!==o.toolsDialogSearchEmpty||t[27]!==o.toolsDialogSearchPlaceholder||t[28]!==o.toolsDialogSubtitle||t[29]!==o.toolsDialogTitle||t[30]!==o.toolsEmpty||t[31]!==o.toolsLoading||t[32]!==o.toolsRetryHint||t[33]!==o.toolsSearchSummary||t[34]!==o.toolsTitle||t[35]!==u){let e=g.trim().toLowerCase(),a;if(t[49]!==n){let e;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(e=/-/g,t[51]=e):e=t[51],a=n.replace(e,`_`),t[49]=n,t[50]=a}else a=t[50];let l=`mcp__${a}__`,d=u.filter(t=>`${t.name} ${t.description}`.toLowerCase().includes(e));T=fe,O=!0,t[52]===s?k=t[53]:(k=e=>{e||s()},t[52]=s,t[53]=k),w=le,t[54]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,$.jsx)(oe,{className:`fixed inset-0 z-[60] bg-scrim`}),t[54]=D):D=t[54],C=ue,t[55]===i?P=t[56]:(P=e=>{(b.current||i)&&e.preventDefault(),!b.current&&i?.isConnected&&i.focus()},t[55]=i,t[56]=P),F=`fixed left-1/2 top-1/2 z-[60] flex h-[min(42rem,calc(100dvh-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 p;t[57]===o.toolsDialogTitle?p=t[58]:(p=(0,$.jsx)(de,{className:`font-semibold`,children:o.toolsDialogTitle}),t[57]=o.toolsDialogTitle,t[58]=p);let h;t[59]!==r||t[60]!==m||t[61]!==f||t[62]!==n||t[63]!==o.toolsDialogSubtitle||t[64]!==u.length?(h=f||m?r||n:o.toolsDialogSubtitle.replace(`{{serverId}}`,r||n).replace(`{{count}}`,String(u.length)),t[59]=r,t[60]=m,t[61]=f,t[62]=n,t[63]=o.toolsDialogSubtitle,t[64]=u.length,t[65]=h):h=t[65];let v;t[66]===h?v=t[67]:(v=(0,$.jsx)(se,{className:`mt-1 break-words text-sm text-fg-muted`,children:h}),t[66]=h,t[67]=v);let y;t[68]===Symbol.for(`react.memo_cache_sentinel`)?(y=e=>_(e.target.value),t[68]=y):y=t[68];let x;t[69]!==g||t[70]!==o.toolsDialogSearchPlaceholder?(x=(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:g,onChange:y,placeholder:o.toolsDialogSearchPlaceholder,"aria-label":o.toolsDialogSearchPlaceholder}),t[69]=g,t[70]=o.toolsDialogSearchPlaceholder,t[71]=x):x=t[71];let S=e&&!f&&!m?(0,$.jsx)(`p`,{role:`status`,className:`mt-2 text-xs text-fg-muted`,children:o.toolsSearchSummary.replace(`{{visible}}`,String(d.length)).replace(`{{count}}`,String(u.length))}):null;t[72]!==p||t[73]!==v||t[74]!==x||t[75]!==S?(E=(0,$.jsxs)(`div`,{className:`shrink-0 border-b border-edge p-5`,children:[p,v,x,S]}),t[72]=p,t[73]=v,t[74]=x,t[75]=S,t[76]=E):E=t[76],A=`min-h-0 flex-1 overflow-y-auto p-5`,j=f,t[77]!==o.toolsTitle||t[78]!==u.length?(M=o.toolsTitle.replace(`{{count}}`,String(u.length)),t[77]=o.toolsTitle,t[78]=u.length,t[79]=M):M=t[79],N=f?(0,$.jsx)(`div`,{role:`status`,"aria-label":o.toolsLoading,className:`space-y-3`,children:[0,1,2].map(ln)}):m?(0,$.jsxs)(`div`,{role:`alert`,className:`space-y-3`,children:[(0,$.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-sm text-danger`,children:m}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:o.toolsRetryHint}),c?(0,$.jsx)(X,{variant:`secondary`,onClick:()=>{b.current=!0,c()},children:o.setupConfigure}):null]}):d.length?(0,$.jsx)(`div`,{className:`space-y-3`,children:d.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.startsWith(l)?e.name.slice(l.length):e.name}),e.exposure&&Object.hasOwn(o.exposureLabels,e.exposure)?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:o.exposureLabels[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:o.toolDetails}),(0,$.jsx)(`p`,{className:`mt-2 break-all font-mono text-xs text-fg-muted`,children:e.name}),(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,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:u.length?o.toolsDialogSearchEmpty:o.toolsEmpty}),e?(0,$.jsx)(X,{variant:`secondary`,onClick:()=>_(``),children:o.toolsClearSearch}):null]}),t[14]=r,t[15]=m,t[16]=f,t[17]=s,t[18]=c,t[19]=g,t[20]=i,t[21]=n,t[22]=o.exposureLabels,t[23]=o.setupConfigure,t[24]=o.toolDetails,t[25]=o.toolsClearSearch,t[26]=o.toolsDialogSearchEmpty,t[27]=o.toolsDialogSearchPlaceholder,t[28]=o.toolsDialogSubtitle,t[29]=o.toolsDialogTitle,t[30]=o.toolsEmpty,t[31]=o.toolsLoading,t[32]=o.toolsRetryHint,t[33]=o.toolsSearchSummary,t[34]=o.toolsTitle,t[35]=u,t[36]=C,t[37]=w,t[38]=T,t[39]=E,t[40]=D,t[41]=O,t[42]=k,t[43]=A,t[44]=j,t[45]=M,t[46]=N,t[47]=P,t[48]=F}else C=t[36],w=t[37],T=t[38],E=t[39],D=t[40],O=t[41],k=t[42],A=t[43],j=t[44],M=t[45],N=t[46],P=t[47],F=t[48];let I;t[80]!==A||t[81]!==j||t[82]!==M||t[83]!==N?(I=(0,$.jsx)(`div`,{className:A,"aria-busy":j,"aria-label":M,children:N}),t[80]=A,t[81]=j,t[82]=M,t[83]=N,t[84]=I):I=t[84];let L;t[85]===Symbol.for(`react.memo_cache_sentinel`)?(L=()=>y(cn),t[85]=L):L=t[85];let R;t[86]!==f||t[87]!==o.refreshTools?(R=(0,$.jsx)(X,{variant:`secondary`,disabled:f,onClick:L,children:o.refreshTools}),t[86]=f,t[87]=o.refreshTools,t[88]=R):R=t[88];let z;t[89]!==s||t[90]!==o.toolsDialogClose?(z=(0,$.jsx)(ce,{asChild:!0,children:(0,$.jsx)(X,{onClick:s,children:o.toolsDialogClose})}),t[89]=s,t[90]=o.toolsDialogClose,t[91]=z):z=t[91];let B;t[92]!==R||t[93]!==z?(B=(0,$.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge p-4`,children:[R,z]}),t[92]=R,t[93]=z,t[94]=B):B=t[94];let V;t[95]!==C||t[96]!==E||t[97]!==I||t[98]!==B||t[99]!==P||t[100]!==F?(V=(0,$.jsxs)(C,{onCloseAutoFocus:P,className:F,children:[E,I,B]}),t[95]=C,t[96]=E,t[97]=I,t[98]=B,t[99]=P,t[100]=F,t[101]=V):V=t[101];let H;t[102]!==w||t[103]!==D||t[104]!==V?(H=(0,$.jsxs)(w,{children:[D,V]}),t[102]=w,t[103]=D,t[104]=V,t[105]=H):H=t[105];let U;return t[106]!==T||t[107]!==O||t[108]!==k||t[109]!==H?(U=(0,$.jsx)(T,{open:O,onOpenChange:k,children:H}),t[106]=T,t[107]=O,t[108]=k,t[109]=H,t[110]=U):U=t[110],U}function cn(e){return e+1}function ln(e){return(0,$.jsx)(Z,{className:`h-24 w-full`},e)}function un(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 dn({row:e,lastCheck:t,t:n,cs:r,onEdit:i,onRemove:a}){let o=c(e=>e.language),[s,l]=(0,Q.useState)(!1),u=(0,Q.useRef)(null),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(``),h=e.displayName||e.id,g=un(e),_=e.extra.enabled===!1,v=_?S:t?x:O,y=e.transport===`stdio`?q:K,b=_?n.setupDisabled:t?r.customCheckSucceeded:r.customUnchecked,C=t?new Intl.DateTimeFormat(o,{dateStyle:`medium`,timeStyle:`short`}).format(new Date(t.checkedAt)):null;return(0,$.jsxs)(`li`,{className:`flex min-h-[8.75rem] min-w-0 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`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,$.jsx)(`div`,{title:n.transportLabels[e.transport],className:`flex size-9 shrink-0 items-center justify-center rounded-xl border border-edge-subtle bg-surface-inset text-fg-muted`,children:(0,$.jsx)(y,{className:`size-4`,"aria-hidden":!0})}),(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col items-start gap-1`,children:[(0,$.jsx)(`h3`,{className:`min-w-0 max-w-full text-sm font-semibold text-fg`,children:(0,$.jsx)(`button`,{type:`button`,onClick:i,title:h,className:`block max-w-full truncate rounded text-left hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:h})}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-[11px]`,children:[(0,$.jsxs)(`span`,{title:C?r.customLastChecked.replace(`{{time}}`,C):void 0,"aria-label":C?`${b} · ${r.customLastChecked.replace(`{{time}}`,C)}`:b,className:Y(`inline-flex shrink-0 items-center gap-1`,!_&&t?`text-emerald-700 dark:text-emerald-300`:`text-fg-muted`),children:[(0,$.jsx)(v,{className:`size-3.5`,"aria-hidden":!0}),b]}),t?(0,$.jsx)(`span`,{className:`text-fg-muted`,children:r.customToolCount.replace(`{{count}}`,String(t.toolCount))}):null]})]})})]}),(0,$.jsx)(`p`,{title:g,className:`mt-2 truncate font-mono text-xs leading-5 text-fg-muted`,children:g})]}),(0,$.jsxs)(`div`,{className:`mt-2 flex shrink-0 items-center gap-1`,children:[(0,$.jsx)(`span`,{className:`mr-auto text-[11px] text-fg-subtle`,children:n.transportLabels[e.transport]}),(0,$.jsx)(X,{variant:`ghost`,className:`h-8 px-2 py-1 text-xs`,onClick:i,children:n.setupConfigure}),(0,$.jsx)(X,{ref:u,variant:`secondary`,className:`h-8 px-2 py-1 text-xs shadow-none sm:shadow-none`,disabled:_,onClick:()=>l(!0),children:n.viewTools}),(0,$.jsxs)(tt,{children:[(0,$.jsx)(nt,{asChild:!0,children:(0,$.jsx)(X,{variant:`ghost`,className:`size-8 p-0`,"aria-label":r.customManage.replace(`{{name}}`,h),title:r.customManage.replace(`{{name}}`,h),children:(0,$.jsx)(A,{className:`size-4`,"aria-hidden":!0})})}),(0,$.jsx)(rt,{children:(0,$.jsx)(at,{align:`end`,sideOffset:6,className:`z-50 min-w-36 rounded-xl border border-edge bg-surface-overlay p-1 shadow-popover`,children:(0,$.jsxs)(it,{onSelect:()=>f(!0),className:`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-danger outline-none data-[highlighted]:bg-surface-hover`,children:[(0,$.jsx)(ie,{className:`size-4`,"aria-hidden":!0}),n.removeServer]})})})]})]}),p?(0,$.jsx)(`p`,{role:`alert`,className:`mt-2 text-sm text-danger`,children:p}):null,s?(0,$.jsx)(sn,{serverId:e.id,displayName:e.displayName,returnFocusTo:u.current,t:n,onClose:()=>l(!1),onConfigure:()=>{l(!1),i()}}):null,(0,$.jsx)(et,{open:d,title:r.removeConfirmTitle.replace(`{{name}}`,h),description:r.removeConfirmDescription,confirmLabel:n.removeServer,cancelLabel:r.modalCancel,destructive:!0,onCancel:()=>f(!1),onConfirm:()=>{f(!1),m(``),a().catch(()=>m(n.setupRemoveFailed))}})]})}function fn(e){let t=(0,ft.c)(30),{servers:n,lastChecks:r,t:i,cs:a,onAdd:o,onEdit:s,onRemove:c}=e,l;t[0]===a.customIntegrationsTitle?l=t[1]:(l=(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:a.customIntegrationsTitle}),t[0]=a.customIntegrationsTitle,t[1]=l);let u;t[2]===n.length?u=t[3]:(u=(0,$.jsx)(`span`,{className:`rounded-md bg-surface-inset px-1.5 py-0.5 text-xs tabular-nums text-fg-muted`,children:n.length}),t[2]=n.length,t[3]=u);let d;t[4]!==l||t[5]!==u?(d=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[l,u]}),t[4]=l,t[5]=u,t[6]=d):d=t[6];let f;t[7]===a.customIntegrationsHint?f=t[8]:(f=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:a.customIntegrationsHint}),t[7]=a.customIntegrationsHint,t[8]=f);let p;t[9]!==d||t[10]!==f?(p=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[d,f]}),t[9]=d,t[10]=f,t[11]=p):p=t[11];let m;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(W,{className:`size-3.5`,"aria-hidden":!0}),t[12]=m):m=t[12];let h;t[13]!==a.customAdd||t[14]!==o?(h=(0,$.jsxs)(X,{variant:`secondary`,className:`shrink-0 text-xs shadow-none sm:shadow-none`,onClick:o,children:[m,a.customAdd]}),t[13]=a.customAdd,t[14]=o,t[15]=h):h=t[15];let g;t[16]!==p||t[17]!==h?(g=(0,$.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center justify-between gap-3`,children:[p,h]}),t[16]=p,t[17]=h,t[18]=g):g=t[18];let _;t[19]!==a||t[20]!==r||t[21]!==s||t[22]!==c||t[23]!==n||t[24]!==i?(_=n.length?(0,$.jsx)(`ul`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:n.map(e=>(0,$.jsx)(dn,{row:e,lastCheck:r[e.id],t:i,cs:a,onEdit:()=>s(e),onRemove:()=>c(e)},e.clientKey))}):(0,$.jsx)(`p`,{className:`rounded-xl border border-dashed border-edge px-5 py-8 text-center text-sm text-fg-muted`,children:a.customEmpty}),t[19]=a,t[20]=r,t[21]=s,t[22]=c,t[23]=n,t[24]=i,t[25]=_):_=t[25];let v;return t[26]!==a.customIntegrationsTitle||t[27]!==g||t[28]!==_?(v=(0,$.jsxs)(`section`,{"aria-label":a.customIntegrationsTitle,children:[g,_]}),t[26]=a.customIntegrationsTitle,t[27]=g,t[28]=_,t[29]=v):v=t[29],v}function pn(e){return e.format===`agent-plugin`&&!!e.pluginId&&(!!e.setup?.authorizations?.length||e.authorizationStatus===`required`||!!e.components?.mcp.some(e=>e.type!==`stdio`))}function mn(e){let t=(0,ft.c)(54),{extension:n,language:r,onOpen:i}=e,a;t[0]===r?a=t[1]:(a=r.startsWith(`zh`),t[0]=r,t[1]=a);let o=a,s;t[2]===o?s=t[3]:(s=(e,t)=>o?e:t,t[2]=o,t[3]=s);let c=s,l=n.installationState===`preparing`,u=n.activationEligible===!1,d=n.authorizationStatus===`required`,f;t[4]!==u||t[5]!==n.readiness||t[6]!==d||t[7]!==l||t[8]!==c?(f=l?c(`准备未完成`,`Setup incomplete`):u?c(`已停用`,`Disabled`):d?c(`需要授权`,`Authorization required`):n.readiness===`blocked`||n.readiness===`degraded`?c(`需要处理`,`Needs attention`):c(`已连接`,`Connected`),t[4]=u,t[5]=n.readiness,t[6]=d,t[7]=l,t[8]=c,t[9]=f):f=t[9];let p=f,m;t[10]!==u||t[11]!==d||t[12]!==l||t[13]!==c?(m=l?c(`继续安装`,`Continue setup`):!u&&d?c(`去授权`,`Connect account`):c(`查看详情`,`View details`),t[10]=u,t[11]=d,t[12]=l,t[13]=c,t[14]=m):m=t[14];let h=m,_;t[15]===n.setup?.authorizations?_=t[16]:(_=n.setup?.authorizations??[],t[15]=n.setup?.authorizations,t[16]=_);let v=_,y=v.length===1?v[0].title:n.name,C=l||!u&&(d||n.readiness===`blocked`||n.readiness===`degraded`),w=l?O:u?S:C?b:x,T=C&&`border-amber-500/25`,E;t[17]===T?E=t[18]:(E=Y(`flex min-h-[8.75rem] w-full min-w-0 flex-col rounded-xl border border-edge bg-surface-panel p-4 text-left transition-colors hover:bg-surface-hover/45 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,T),t[17]=T,t[18]=E);let D=n.branding?.iconUrl,k;t[19]===D?k=t[20]:(k=(0,$.jsx)(st,{iconUrl:D,fallback:ee,className:`size-9`}),t[19]=D,t[20]=k);let A;t[21]===y?A=t[22]:(A=(0,$.jsx)(`span`,{className:`block truncate text-sm font-semibold text-fg`,title:y,children:y}),t[21]=y,t[22]=A);let j=C?`text-amber-700 dark:text-amber-300`:u?`text-fg-muted`:`text-emerald-700 dark:text-emerald-300`,M;t[23]===j?M=t[24]:(M=Y(`mt-1 inline-flex items-center gap-1 text-[11px]`,j),t[23]=j,t[24]=M);let N;t[25]===w?N=t[26]:(N=(0,$.jsx)(w,{className:`size-3.5`,"aria-hidden":!0}),t[25]=w,t[26]=N);let P;t[27]!==p||t[28]!==M||t[29]!==N?(P=(0,$.jsxs)(`span`,{className:M,children:[N,p]}),t[27]=p,t[28]=M,t[29]=N,t[30]=P):P=t[30];let F;t[31]!==A||t[32]!==P?(F=(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[A,P]}),t[31]=A,t[32]=P,t[33]=F):F=t[33];let I;t[34]!==F||t[35]!==k?(I=(0,$.jsxs)(`span`,{className:`flex w-full min-w-0 items-start gap-3`,children:[k,F]}),t[34]=F,t[35]=k,t[36]=I):I=t[36];let L=n.name,R;t[37]===c?R=t[38]:(R=c(`由插件提供`,`Provided by plugin`),t[37]=c,t[38]=R);let z;t[39]!==n.name||t[40]!==R?(z=(0,$.jsxs)(`span`,{className:`mt-2 block w-full truncate text-xs leading-5 text-fg-muted`,title:L,children:[R,` · `,n.name]}),t[39]=n.name,t[40]=R,t[41]=z):z=t[41];let B=C?`text-accent-fg`:`text-fg-muted`,V;t[42]===B?V=t[43]:(V=Y(`mt-auto flex w-full items-center justify-end gap-1 pt-2 text-xs`,B),t[42]=B,t[43]=V);let H;t[44]===Symbol.for(`react.memo_cache_sentinel`)?(H=(0,$.jsx)(g,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[44]=H):H=t[44];let U;t[45]!==h||t[46]!==V?(U=(0,$.jsxs)(`span`,{className:V,children:[h,H]}),t[45]=h,t[46]=V,t[47]=U):U=t[47];let W;return t[48]!==i||t[49]!==I||t[50]!==z||t[51]!==U||t[52]!==E?(W=(0,$.jsxs)(`button`,{type:`button`,onClick:i,className:E,children:[I,z,U]}),t[48]=i,t[49]=I,t[50]=z,t[51]=U,t[52]=E,t[53]=W):W=t[53],W}function hn(e){let t=e.connectedAt?Date.parse(e.connectedAt):0;return Number.isFinite(t)?t:0}function gn(e,t){return e.status===`active`&&t.status!==`active`?-1:e.status!==`active`&&t.status===`active`?1:e.isCurrentAuthorization===t.isCurrentAuthorization?hn(t)-hn(e):e.isCurrentAuthorization?-1:1}function _n(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(gn);return{key:e,primary:n[0],authorizations:n}}).sort((e,t)=>gn(e.primary,t.primary))}var vn=Y(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,Ye);function yn(e){return e.materialized.type===`composio`?e.materialized.toolkit:null}function bn(e,t){return e===`write`?t.composioScopeWrite:e===`admin`?t.composioScopeAdmin:t.composioScopeRead}function xn(e,t,n){return e.status===`connected`?I(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 Sn(e,t){return e===`active`?t.composioConnectionHealthy:e===`pending`?t.composioConnectionPending:e===`expired`?t.composioConnectionExpired:e===`failed`?t.composioConnectionFailed:e===`revoked`||e===`disabled`?t.composioConnectionRevoked:t.composioConnectionUnknown}function Cn(e,t,n){return e.status===`paused`?t?.scanEnabled===!1?n.connectorLearningPausedByPolicy:n.connectorLearningPausedByFailure:e.status===`queued`?n.connectorLearningQueued:e.status===`running`?n.connectorLearningRunning:e.status===`completed`?n.connectorLearningCompleted:n.connectorLearningFailed}function wn({instance:e,t,onChanged:n}){let r=yn(e),i=c(e=>e.language)===`zh`,[a,o]=(0,Q.useState)([]),[s,l]=(0,Q.useState)([]),[u,d]=(0,Q.useState)([]),[f,p]=(0,Q.useState)(null),[m,h]=(0,Q.useState)([]),[g,y]=(0,Q.useState)(null),[S,C]=(0,Q.useState)(null),[w,T]=(0,Q.useState)([]),[E,D]=(0,Q.useState)({}),[O,k]=(0,Q.useState)(`read`),[A,j]=(0,Q.useState)(!1),[M,N]=(0,Q.useState)(null),[L,R]=(0,Q.useState)(!1),[z,B]=(0,Q.useState)(null),[H,U]=(0,Q.useState)(null),[ee,W]=(0,Q.useState)(!1),[G,K]=(0,Q.useState)(!1),[ne,re]=(0,Q.useState)(!1),q=(0,Q.useRef)(0),J=(0,Q.useRef)(0),ae=(0,Q.useMemo)(()=>_n(a),[a]),oe=(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]),se=(0,Q.useCallback)(async()=>{if(!r||e.materialized.type!==`composio`||e.materialized.role===`credential`)return;j(!0),N(null);let t=++q.current;try{let e=(await Promise.allSettled([oe(Ae()).then(e=>{t===q.current&&(o(e.filter(e=>e.toolkit.toLowerCase()===r.toLowerCase())),W(!0))}),oe(Ne(r)).then(e=>{t===q.current&&k(e)}),oe(Ue(r)).then(e=>{t===q.current&&(p(e.policy),h(e.agents))})])).find(e=>e.status===`rejected`);t===q.current&&e?.status===`rejected`&&N(String(e.reason instanceof Error?e.reason.message:e.reason))}finally{t===q.current&&j(!1)}},[e.materialized,r,oe]);(0,Q.useEffect)(()=>(se(),()=>{q.current++}),[se]);let ce=(0,Q.useCallback)(async()=>{if(!r)return;let e=++J.current;re(!0),R(!1);let t=t=>n=>{e===J.current&&t(n)},n=await Promise.allSettled([oe(We(r)).then(t(l)),oe(qe(20)).then(t(e=>d(e.filter(e=>!e.toolkit||e.toolkit.toLowerCase()===r.toLowerCase())))),oe(Be(r)).then(t(C)),oe(Ie(r)).then(t(y))]);e===J.current&&(R(n.some(e=>e.status===`rejected`)),re(!1))},[r,oe]);(0,Q.useEffect)(()=>(G&&ce(),()=>{J.current++}),[G,ce]),(0,Q.useEffect)(()=>{let e=!1,t=_n(a).map(e=>e.primary).filter(e=>e.supportsLearning&&e.accountId);if(t.length)return oe(Ke()).then(t=>{e||T(t)}).catch(()=>{}),Promise.allSettled(t.map(async e=>[e.accountId,await oe(Le(e.accountId))])).then(t=>{e||D(Object.fromEntries(t.flatMap(e=>e.status===`fulfilled`?[e.value]:[])))}),()=>{e=!0}},[a,oe]);let le=(0,Q.useCallback)(async i=>{if(!r)return;let a=Xe()?null:window.open(`about:blank`,`_blank`);a&&(a.opener=null),j(!0),N(null);try{if(!Xe()&&!a)throw Error(`Allow popups to open the authorization page.`);let t=await Fe(e.connectorId,i);if(!t.authorizationUrl)throw Error(`The authorization provider did not return an authorization URL.`);if(Xe()){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 Je(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?.(),se()])}catch(e){N(V(e,t))}finally{a?.close(),j(!1)}},[e.connectorId,se,n,t,r]),ue=(0,Q.useCallback)(async t=>{j(!0),N(null);try{await Ce(e.instanceId,{config:{...e.config??{},authConfigId:t||void 0}}),await Promise.all([n?.(),se()])}catch(e){N(e instanceof Error?e.message:String(e))}finally{j(!1)}},[e.config,e.instanceId,se,n]),de=async e=>{let t=Xe()?null:window.open(`about:blank`,`_blank`);t&&(t.opener=null),N(null);try{let n=await Me(e.id);if(n.authorizationUrl)if(Xe())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 se()}catch(e){t?.close(),N(e instanceof Error?e.message:String(e))}},fe=(0,Q.useCallback)(async e=>{if(r){k(e),N(null);try{await Ee(r,e)}catch(e){N(e instanceof Error?e.message:String(e)),await se()}}},[se,r]),pe=(0,Q.useCallback)(async e=>{if(r){N(null);try{p(await Se(r,e))}catch(e){N(e instanceof Error?e.message:String(e))}}},[r]),me=(0,Q.useCallback)(e=>{if(!f)return;let t=f.allowedAgentIds.includes(e);if(t&&f.allowedAgentIds.length===1)return;let n=t?f.allowedAgentIds.filter(t=>t!==e):[...f.allowedAgentIds,e];pe({allowedAgentIds:n})},[pe,f]),he=(0,Q.useCallback)(async e=>{j(!0),N(null);try{await e(),await se()}catch(e){N(e instanceof Error?e.message:String(e))}finally{j(!1)}},[se]);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 ge=ae.filter(e=>e.primary.status===`active`).length,_e=ge>0?t.composioAddAccount:t.composioConnectAccount,ve=ee&&ge>0,we=S?.requiresCustomAuthConfig===!0,Te=S?.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:Y(`inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-xs font-medium`,ve?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-amber-500/10 text-amber-700 dark:text-amber-300`),children:[ve?(0,$.jsx)(x,{className:`size-3.5`}):(0,$.jsx)(b,{className:`size-3.5`}),ve?t.connectionReady:ee||M?t.connectionNeedsSetup:t.connectionChecking]}),ee&&(0,$.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:I(t.composioAccountCount,{count:String(ae.length)})})]}),(0,$.jsxs)(X,{variant:`primary`,className:`shrink-0`,disabled:A,onClick:()=>void le(),children:[A?(0,$.jsx)(F,{className:`size-4 animate-spin`}):(0,$.jsx)(P,{className:`size-4`}),_e]})]}),M?(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:M}),(0,$.jsx)(X,{variant:`secondary`,disabled:A,onClick:()=>void se(),children:t.composioRetry})]}):null,g&&!ve?(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:xn(g,ge,t)}),g.recovery===`none`?null:(0,$.jsx)(X,{variant:`secondary`,disabled:A,onClick:()=>void(g.recovery===`retry`?se():le()),children:g.recovery===`retry`?t.composioRetry:t.composioReconnectAccount})]}):null,we&&Te.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,f?(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:O===`read`?t.composioAccessReadHint:O===`admin`?t.composioAccessAdminHint:t.composioAccessWriteHint})]}),(0,$.jsxs)(_,{value:O,onChange:e=>void fe(e.currentTarget.value),children:[(0,$.jsx)(v,{value:`read`,children:t.composioAccessReadOnly}),(0,$.jsx)(v,{value:`write`,children:t.composioAccessReadWrite}),O===`admin`?(0,$.jsx)(v,{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)(_,{value:f.confirmationPolicy,onChange:e=>void pe({confirmationPolicy:e.currentTarget.value}),children:[(0,$.jsx)(v,{value:`writes`,children:t.composioConfirmWrites}),(0,$.jsx)(v,{value:`always`,children:t.composioConfirmAlways}),f.confirmationPolicy===`never`?(0,$.jsx)(v,{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:f.allowedAgentIds.length?t.composioAllowedAgentsSelected:t.composioAllowedAgentsAll}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,$.jsx)(`button`,{type:`button`,className:Y(`rounded-full border px-2.5 py-1 text-xs transition-colors`,f.allowedAgentIds.length===0?`border-accent bg-accent/10 text-accent`:`border-edge bg-surface-panel text-fg-muted hover:text-fg`),onClick:()=>void pe({allowedAgentIds:[]}),children:t.composioAllowedAgentsAllOption}),m.map(e=>(0,$.jsx)(`button`,{type:`button`,className:Y(`rounded-full border px-2.5 py-1 text-xs transition-colors`,f.allowedAgentIds.includes(e.id)?`border-accent bg-accent/10 text-accent`:`border-edge bg-surface-panel text-fg-muted hover:text-fg`),onClick:()=>me(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:f.selectedAccountIds===null,disabled:A,onChange:e=>void pe({selectedAccountIds:e.currentTarget.checked?null:[]})}),i?`所有账号(包括以后新增)`:`All accounts, including new ones`]}),f.selectedAccountIds!==null&&ae.map(({primary:e})=>e.accountId&&(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,disabled:A,checked:f.selectedAccountIds.includes(e.accountId),onChange:t=>void pe({selectedAccountIds:t.currentTarget.checked?[...f.selectedAccountIds,e.accountId]:f.selectedAccountIds.filter(t=>t!==e.accountId)})}),e.alias??e.accountEmail??e.accountId]},e.accountId)),f.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}),ee&&(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:I(t.composioAccountCount,{count:String(ae.length)})})]}),(0,$.jsxs)(X,{variant:`ghost`,className:`h-8 px-2 text-xs`,disabled:A,onClick:()=>void se(),children:[(0,$.jsx)(te,{className:Y(`size-3.5`,A&&`animate-spin`)}),t.refresh]})]}),ae.length?(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-xl border border-edge bg-surface-base`,children:ae.map(e=>{let r=e.primary,a=w.find(e=>r.accountId?e.accountId===r.accountId:e.connectionId===r.id),o=r.accountId?E[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:Y(`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`:Sn(r.status,t)}),a?(0,$.jsx)(`p`,{className:Y(`mt-1 text-xs`,a.status===`failed`?`text-red-600`:`text-fg-subtle`),children:I(t.connectorLearningStatus,{status:Cn(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)(X,{variant:`secondary`,className:`h-8 px-2.5 text-xs`,onClick:()=>void de(r),children:i?`继续授权`:`Continue authorization`}),r.accountId&&(0,$.jsx)(X,{variant:`ghost`,className:`h-8 px-2.5 text-xs text-danger`,disabled:A,onClick:()=>U(r.accountId),children:i?`断开`:`Disconnect`}),r.accountId&&r.status!==`active`&&(0,$.jsx)(X,{variant:`secondary`,className:`h-8 px-2.5 text-xs`,disabled:A,onClick:()=>void le(r.accountId),children:t.composioReconnectAccount}),r.accountId&&(0,$.jsx)(X,{variant:`secondary`,className:`h-8 px-2.5 text-xs`,disabled:A,onClick:()=>void he(()=>De(r.accountId,{enabled:r.accountEnabled===!1})),children:r.accountEnabled===!1?i?`启用`:`Enable`:i?`暂停`:`Pause`}),r.supportsLearning&&r.status===`active`&&r.accountEnabled!==!1?(0,$.jsxs)(X,{variant:`secondary`,className:`h-8 shrink-0 px-2.5 text-xs`,disabled:A,onClick:()=>void he(async()=>{if(!r.accountId)throw Error(`Connector account is unavailable.`);await ye(r.accountId),await n?.()}),children:[(0,$.jsx)(te,{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:A,checked:r.allowedAgentIds==null,onChange:e=>void he(()=>De(r.accountId,{allowedAgentIds:e.currentTarget.checked?null:[]}))}),t.composioAllowedAgentsAllOption]}),r.allowedAgentIds!=null&&m.map(e=>(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,disabled:A,checked:r.allowedAgentIds.includes(e.id),onChange:t=>{let n=t.currentTarget.checked;he(()=>De(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:A,onChange:e=>void he(()=>Oe(r.accountId,{scanEnabled:e.currentTarget.checked}))}),t.connectorScheduledScan]}),o.scanEnabled?(0,$.jsxs)(`label`,{className:`sm:col-span-2`,children:[t.connectorScanInterval,(0,$.jsxs)(_,{className:`mt-1`,value:String(o.intervalMinutes??30),disabled:A,onChange:e=>void he(()=>Oe(r.accountId,{intervalMinutes:Number(e.currentTarget.value)})),children:[(0,$.jsxs)(v,{value:`5`,children:[`5 `,t.connectorMinutes]}),(0,$.jsxs)(v,{value:`15`,children:[`15 `,t.connectorMinutes]}),(0,$.jsxs)(v,{value:`30`,children:[`30 `,t.connectorMinutes]}),(0,$.jsxs)(v,{value:`60`,children:[`60 `,t.connectorMinutes]})]})]}):null]}):null,(0,$.jsxs)(`label`,{className:`block`,children:[t.composioAccountAlias,(0,$.jsx)(`input`,{className:Y(vn,`mt-1 h-8 py-1 text-xs`),defaultValue:r.alias??``,onBlur:e=>{e.currentTarget.value!==(r.alias??``)&&he(()=>xe(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)(X,{variant:`ghost`,className:`size-7 shrink-0 p-0 text-danger`,title:t.composioRevoke,disabled:A,onClick:()=>B(e.id),children:(0,$.jsx)(ie,{className:`size-3.5`})})]},e.id))}),(0,$.jsx)(`div`,{className:`flex justify-end gap-1`,children:(0,$.jsx)(X,{variant:`ghost`,className:`size-8 p-0`,title:t.refresh,disabled:A,onClick:()=>void he(()=>ke(r.id)),children:(0,$.jsx)(te,{className:`size-4`})})})]})]})]},e.key)})}):A&&!ee?(0,$.jsxs)(`div`,{"aria-busy":`true`,"aria-label":t.connectionChecking,className:`space-y-3`,children:[(0,$.jsx)(Z,{className:`h-16 w-full`}),(0,$.jsx)(Z,{className:`h-16 w-full`})]}):ee?(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=>K(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:[ne?(0,$.jsx)(Z,{"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)(X,{variant:`ghost`,disabled:ne,onClick:()=>void ce(),children:t.composioRetry})]}):null,S?.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:we?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)(_,{className:`mt-3`,value:typeof e.config?.authConfigId==`string`?e.config.authConfigId:``,disabled:A,onChange:e=>void ue(e.currentTarget.value),children:[we?null:(0,$.jsx)(v,{value:``,children:t.composioAuthConfigManaged}),we&&typeof e.config?.authConfigId!=`string`?(0,$.jsx)(v,{value:``,disabled:!0,children:t.composioAuthConfigSelect}):null,Te.map(e=>(0,$.jsxs)(v,{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:s.length?s.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:[bn(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:u.length?u.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)(et,{open:H!==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=H;U(null),e&&he(()=>Re(e))},onCancel:()=>U(null)}),(0,$.jsx)(et,{open:z!==null,title:t.composioRevoke,description:t.composioRevokeConfirm,confirmLabel:t.composioRevoke,cancelLabel:t.modalCancel,destructive:!0,onConfirm:()=>{let e=z;B(null),e&&he(()=>be(e))},onCancel:()=>B(null)})]})}var Tn=Y(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,Ye);function En(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 Dn(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 On({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)(()=>En(t,e)),[_,v]=(0,Q.useState)(null),[y,b]=(0,Q.useState)(!1),[x,S]=(0,Q.useState)(null),C=t?.setup.config??[],w=(e.materialized.type===`mcp`||e.materialized.type===`memorySource`)&&C.length>0&&(t?.setup.secrets??[]).length===0,T=e.materialized.type===`mcp`,E=e.materialized.type===`composio`,D=e.materialized.type===`memorySource`,O=t?R(t,i):null,A=(0,Q.useCallback)(async()=>{b(!0),v(null);try{let t=await Te(e.instanceId);S(t),t.ok||v(t.error??t.action??i.healthStatusLabels[t.status]),await r()}catch(e){v(e instanceof Error?e.message:String(e))}finally{b(!1)}},[e.instanceId,r,i.healthStatusLabels]),j=(0,Q.useCallback)(async()=>{o(!0),v(null);try{await Ge(e.instanceId),await r(),n()}catch(e){v(e instanceof Error?e.message:String(e)),o(!1)}},[e.instanceId,r,n]),M=(0,Q.useCallback)(async()=>{if(!(!t||!w)){u(!0),v(null);try{let n={};for(let e of t.setup.config??[]){let t=Dn(e.type,h[e.key]??``);t!==void 0&&(n[e.key]=t)}await Ce(e.instanceId,{config:n}),await r()}catch(e){v(e instanceof Error?e.message:String(e))}finally{u(!1)}}},[h,t,e.instanceId,r,w]),N=(0,Q.useCallback)(async()=>{f(!0),m(null),v(null);try{let t=await we(e.connectorId);m(t.recordIds.length),await r()}catch(e){v(e instanceof Error?e.message:String(e))}finally{f(!1)}},[e.connectorId,r]);return(0,$.jsxs)(fe,{open:!0,onOpenChange:e=>{e||n()},children:[(0,$.jsxs)(le,{children:[(0,$.jsx)(oe,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(ue,{className:Y(`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`,E?`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)(z,{connector:t,size:`lg`}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(de,{className:`text-base font-semibold text-fg`,children:e.displayName}),(0,$.jsx)(se,{className:`mt-1 text-sm text-fg-muted`,children:O??(e.materialized.type===`mcp`?I(i.mcpServerRuntime,{serverId:e.materialized.serverId}):I(i.runtimeLabel,{runtime:e.materialized.type}))})]})]}),(0,$.jsx)(ce,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,className:Y(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,ge.focusRingPanel),"aria-label":i.modalClose,children:[(0,$.jsx)(ae,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`sr-only`,children:i.modalClose})]})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:[_?(0,$.jsx)(`p`,{className:`mb-4 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:_}):null,T?(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:x?.ok?I(i.toolsAvailable,{count:String(x.toolCount)}):x?i.healthStatusLabels[x.status]:e.usage.lastHealthStatus?i.healthStatusLabels[e.usage.lastHealthStatus]:i.healthNotTested}),(0,$.jsxs)(X,{variant:`secondary`,"aria-busy":y,disabled:y||!e.enabled,onClick:()=>void A(),children:[y?(0,$.jsx)(F,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(te,{className:`size-4`,"aria-hidden":!0}),i.test]})]}),w?C.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:Tn,value:h[e.key]??``,placeholder:e.placeholder,onChange:t=>g(n=>({...n,[e.key]:t.currentTarget.value}))})]},e.key)):null]}):null,E?(0,$.jsx)(wn,{instance:e,t:i,onChanged:r}):null,D?(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}),O?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:O}):null,p===null?null:(0,$.jsx)(`p`,{className:`mt-1 text-xs text-emerald-600`,children:I(i.connectedSourceSynced,{count:String(p)})})]}),(0,$.jsxs)(X,{disabled:d,onClick:()=>void N(),children:[d?(0,$.jsx)(F,{className:`size-4 animate-spin`}):(0,$.jsx)(k,{className:`size-4`}),i.composioSyncNow]})]}),w?(0,$.jsx)(`div`,{className:`grid gap-3 rounded-xl border border-edge bg-surface-base p-4`,children:C.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:Tn,value:h[e.key]??``,placeholder:e.placeholder,onChange:t=>g(n=>({...n,[e.key]:t.currentTarget.value}))})]},e.key))}):null]}):null,!T&&!E&&!D?(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)(X,{variant:`secondary`,className:`shrink-0 border-danger/30 text-danger hover:bg-danger/10`,disabled:a,onClick:()=>c(!0),children:[a?(0,$.jsx)(F,{className:`size-4 animate-spin`}):(0,$.jsx)(ie,{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)(X,{variant:`secondary`,onClick:n,children:i.modalClose}),(T||D)&&w?(0,$.jsxs)(X,{variant:`primary`,disabled:l,onClick:()=>void M(),children:[l?(0,$.jsx)(F,{className:`size-4 animate-spin`}):(0,$.jsx)(G,{className:`size-4`}),i.modalSave]}):null]})]})]}),(0,$.jsx)(et,{open:s,title:I(i.removeConfirmTitle,{name:e.displayName}),description:i.removeConfirmDescription,confirmLabel:i.removeConfirmAction,cancelLabel:i.modalCancel,destructive:!0,onConfirm:()=>{c(!1),j()},onCancel:()=>{a||c(!1)}})]})}function kn(e){let t=(0,ft.c)(2),n;return t[0]===e?n=t[1]:(n=e.instance.materialized.type===`cli`&&e.definition?(0,$.jsx)(B,{definition:e.definition,instance:e.instance,onClose:e.onClose,onChanged:e.onChanged}):(0,$.jsx)(On,{...e}),t[0]=e,t[1]=n),n}function An(e){let t=(0,ft.c)(59),{instance:n,definition:r,highlighted:i,onOpenDetails:a,t:o}=e,s=i!==void 0&&i,c;t[0]!==r||t[1]!==n?(c=Ct(n,r),t[0]=r,t[1]=n,t[2]=c):c=t[2];let l=c.state,u;t[3]!==r||t[4]!==o?(u=r?R(r,o):null,t[3]=r,t[4]=o,t[5]=u):u=t[5];let d=u,f,p,m,h,_,v,y,S,C;if(t[6]!==l||t[7]!==r||t[8]!==s||t[9]!==n||t[10]!==a||t[11]!==o.connectionChecking||t[12]!==o.connectionNeedsSetup||t[13]!==o.connectionReady){f=l===`ready`?{label:o.connectionReady,Icon:x,className:`text-emerald-700 dark:text-emerald-300`}:l===`needs_setup`?{label:o.connectionNeedsSetup,Icon:b,className:`text-amber-700 dark:text-amber-300`}:{label:o.connectionChecking,Icon:O,className:`text-fg-muted`},C=`button`;let e=l===`needs_setup`&&`border-amber-500/25`,i=s&&`bg-accent-soft`;t[23]!==e||t[24]!==i?(p=Y(`flex min-h-[8.75rem] w-full min-w-0 flex-col rounded-xl border border-edge bg-surface-panel p-4 text-left hover:bg-surface-hover/45`,ge.transition,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,e,i),t[23]=e,t[24]=i,t[25]=p):p=t[25],t[26]!==n||t[27]!==a?(m=()=>a(n),t[26]=n,t[27]=a,t[28]=m):m=t[28],y=`flex w-full min-w-0 items-start gap-3`,t[29]===r?S=t[30]:(S=(0,$.jsx)(z,{connector:r,size:`sm`}),t[29]=r,t[30]=S),_=`min-w-0 flex-1`,t[31]===n.displayName?v=t[32]:(v=(0,$.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,title:n.displayName,children:n.displayName}),t[31]=n.displayName,t[32]=v),h=Y(`mt-1 inline-flex items-center gap-1 text-[11px]`,f.className),t[6]=l,t[7]=r,t[8]=s,t[9]=n,t[10]=a,t[11]=o.connectionChecking,t[12]=o.connectionNeedsSetup,t[13]=o.connectionReady,t[14]=f,t[15]=p,t[16]=m,t[17]=h,t[18]=_,t[19]=v,t[20]=y,t[21]=S,t[22]=C}else f=t[14],p=t[15],m=t[16],h=t[17],_=t[18],v=t[19],y=t[20],S=t[21],C=t[22];let w;t[33]===f.Icon?w=t[34]:(w=(0,$.jsx)(f.Icon,{className:`size-3.5`,"aria-hidden":!0}),t[33]=f.Icon,t[34]=w);let T;t[35]!==f.label||t[36]!==w||t[37]!==h?(T=(0,$.jsxs)(`span`,{className:h,children:[w,f.label]}),t[35]=f.label,t[36]=w,t[37]=h,t[38]=T):T=t[38];let E;t[39]!==T||t[40]!==_||t[41]!==v?(E=(0,$.jsxs)(`div`,{className:_,children:[v,T]}),t[39]=T,t[40]=_,t[41]=v,t[42]=E):E=t[42];let D;t[43]!==E||t[44]!==y||t[45]!==S?(D=(0,$.jsxs)(`div`,{className:y,children:[S,E]}),t[43]=E,t[44]=y,t[45]=S,t[46]=D):D=t[46];let k;t[47]===d?k=t[48]:(k=d?(0,$.jsx)(`p`,{className:`mt-2 w-full line-clamp-2 text-xs leading-5 text-fg-muted`,title:d,children:d}):null,t[47]=d,t[48]=k);let A;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,$.jsx)(g,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[49]=A):A=t[49];let j;t[50]===o.installedDetails?j=t[51]:(j=(0,$.jsxs)(`span`,{className:`mt-auto flex w-full items-center justify-end gap-1 pt-2 text-xs text-fg-muted`,children:[o.installedDetails,A]}),t[50]=o.installedDetails,t[51]=j);let M;return t[52]!==p||t[53]!==m||t[54]!==D||t[55]!==k||t[56]!==j||t[57]!==C?(M=(0,$.jsxs)(`button`,{type:C,className:p,onClick:m,children:[D,k,j]}),t[52]=p,t[53]=m,t[54]=D,t[55]=k,t[56]=j,t[57]=C,t[58]=M):M=t[58],M}function jn(e,t){return Gt()}function Mn(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:[Mt()],additionalHeaders:r===`bearer`?t.filter(e=>e!==n):r===`oauth`?t:[]}}function Nn(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,Mt(`Authorization`,`Bearer ${e}`)]}return t.mode===`apiKey`&&(r=[...r,Mt(t.headerName.trim(),t.apiKey.trim())]),{...e,extra:n,headers:r,oauthClientId:t.mode===`oauth`?e.oauthClientId:``}}function Pn(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 Fn(){return Y(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,Ye)}function In({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:h=!0}){let[g,_]=(0,Q.useState)(new Set),[v,y]=(0,Q.useState)(!1),b=(e,t)=>{d(u.map((n,r)=>r===e?{...n,...t}:n))},x=()=>{d([...u,Mt()])},S=e=>{let t=u.filter((t,n)=>n!==e);d(t.length>0?t:[Mt()])},w=async()=>{try{let e=await he();if(!e){y(!0);return}let t=Pt(e);if(!t?.length){y(!0);return}d(t)}catch{y(!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]}),h?(0,$.jsxs)(X,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5 px-2 text-xs`,onClick:()=>void w(),children:[(0,$.jsx)(C,{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:Y(Fn(),`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=>b(t,{key:e.target.value})}),(0,$.jsx)(`input`,{className:Y(Fn(),`min-w-0 font-mono text-xs`),type:g.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=>b(t,{value:e.target.value})}),(0,$.jsx)(X,{type:`button`,variant:`ghost`,className:`size-10 shrink-0 px-0`,disabled:!!e.reference,"aria-label":g.has(e.clientKey)?m:p,onClick:()=>_(t=>{let n=new Set(t);return n.has(e.clientKey)?n.delete(e.clientKey):n.add(e.clientKey),n}),children:g.has(e.clientKey)?(0,$.jsx)(M,{className:`size-4`,"aria-hidden":!0}):(0,$.jsx)(N,{className:`size-4`,"aria-hidden":!0})}),(0,$.jsx)(X,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 px-0`,disabled:u.length<=1&&!e.key&&!e.value,onClick:()=>S(t),"aria-label":r,children:(0,$.jsx)(ie,{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)(et,{open:v,title:o,description:a,confirmLabel:s,onConfirm:()=>y(!1),onCancel:()=>y(!1)}),(0,$.jsxs)(`button`,{type:`button`,className:Y(`self-start text-sm text-accent hover:underline`,ge.press),onClick:x,children:[`+ `,n]})]})}var Ln=Y(`w-full min-w-0 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,Ye);function Rn(e){let t=(0,ft.c)(20),{value:n,onChange:r,label:i,t:a,required:o}=e,s=o!==void 0&&o,[c,l]=(0,Q.useState)(!1),u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=Y(Ln,`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 h;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(h=()=>l(zn),t[11]=h):h=t[11];let g;t[12]===c?g=t[13]:(g=c?(0,$.jsx)(M,{className:`size-4`,"aria-hidden":!0}):(0,$.jsx)(N,{className:`size-4`,"aria-hidden":!0}),t[12]=c,t[13]=g);let _=c?a.setupHideValue:a.setupShowValue,v;t[14]!==g||t[15]!==_?(v=(0,$.jsxs)(X,{type:`button`,variant:`ghost`,className:`gap-1.5 text-xs`,onClick:h,children:[g,_]}),t[14]=g,t[15]=_,t[16]=v):v=t[16];let y;return t[17]!==v||t[18]!==m?(y=(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[m,v]}),t[17]=v,t[18]=m,t[19]=y):y=t[19],y}function zn(e){return!e}function Bn(e){let t=(0,ft.c)(17),{headers:n,onChange:r,t:i,additional:a,environment:o}=e,s=a!==void 0&&a,c=o!==void 0&&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)(In,{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 Vn(e){let t=(0,ft.c)(52),{draft:n,onChange:r,t:i,allowExisting:a}=e,o=i.setupAuthLabel,s=i.setupAuthLabel,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=Y(Ln,`mt-1.5`),t[0]=c):c=t[0];let l=n.mode,u;t[1]===r?u=t[2]:(u=e=>r({mode:e.target.value}),t[1]=r,t[2]=u);let d;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(d=[`auto`,`oauth`,`bearer`,`apiKey`,`headers`,`none`],t[3]=d):d=t[3];let f;t[4]===i.setupAuthModes?f=t[5]:(f=d.map(e=>(0,$.jsx)(v,{value:e,children:i.setupAuthModes[e]},e)),t[4]=i.setupAuthModes,t[5]=f);let p;t[6]!==a||t[7]!==n.mode||t[8]!==i.setupAuthModes?(p=a||n.mode===`existing`?(0,$.jsx)(v,{value:`existing`,children:i.setupAuthModes.existing}):null,t[6]=a,t[7]=n.mode,t[8]=i.setupAuthModes,t[9]=p):p=t[9];let m;t[10]!==n.mode||t[11]!==i.setupAuthLabel||t[12]!==u||t[13]!==f||t[14]!==p?(m=(0,$.jsxs)(_,{"aria-label":s,className:c,value:l,onChange:u,children:[f,p]}),t[10]=n.mode,t[11]=i.setupAuthLabel,t[12]=u,t[13]=f,t[14]=p,t[15]=m):m=t[15];let h;t[16]!==i.setupAuthLabel||t[17]!==m?(h=(0,$.jsxs)(`label`,{className:`block text-sm font-medium text-fg`,children:[o,m]}),t[16]=i.setupAuthLabel,t[17]=m,t[18]=h):h=t[18];let g;t[19]!==n.mode||t[20]!==i.setupAuthAutoHint?(g=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]=g):g=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 x;t[28]!==n.mode||t[29]!==n.token||t[30]!==r||t[31]!==i?(x=n.mode===`bearer`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Rn,{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]=x):x=t[32];let S;t[33]!==n.apiKey||t[34]!==n.headerName||t[35]!==n.mode||t[36]!==r||t[37]!==i?(S=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:Y(Ln,`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)(Rn,{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]=S):S=t[38];let C;t[39]!==n.customHeaders||t[40]!==n.mode||t[41]!==r||t[42]!==i?(C=n.mode===`headers`?(0,$.jsx)(Bn,{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]=C):C=t[43];let w;return t[44]!==h||t[45]!==g||t[46]!==y||t[47]!==b||t[48]!==x||t[49]!==S||t[50]!==C?(w=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[h,g,y,b,x,S,C]}),t[44]=h,t[45]=g,t[46]=y,t[47]=b,t[48]=x,t[49]=S,t[50]=C,t[51]=w):w=t[51],w}function Hn(e){let t=(0,ft.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 Un({row:e,t,onUpdate:n}){let[r,i]=(0,Q.useState)(()=>It(e.envJson?JSON.parse(e.envJson):void 0)),[a,o]=(0,Q.useState)(!1),s=[];try{s=Rt(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)(X,{type:`button`,variant:`ghost`,onClick:()=>o(e=>!e),children:a?t.setupArgsRows:t.setupArgsPaste})]}),a?(0,$.jsx)(Hn,{label:t.setupArgsPaste,hint:t.argsHint,children:(0,$.jsx)(`input`,{className:Ln,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:Ln,"aria-label":`${t.argsLabel} ${n+1}`,value:e,onChange:e=>c(s.map((t,r)=>r===n?e.target.value:t))}),(0,$.jsx)(X,{type:`button`,variant:`ghost`,"aria-label":t.setupRemoveArg,onClick:()=>c(s.filter((e,t)=>t!==n)),children:(0,$.jsx)(ie,{className:`size-4`,"aria-hidden":!0})})]},n)),a?null:(0,$.jsxs)(X,{type:`button`,variant:`ghost`,onClick:()=>c([...s,``]),children:[(0,$.jsx)(W,{className:`size-4`,"aria-hidden":!0}),t.setupAddArg]})]}),(0,$.jsx)(Bn,{environment:!0,headers:r,t,onChange:e=>{i(e),n({envEntries:e,envJson:JSON.stringify(Ft(e)??{})})}})]})}function Wn(e){let t=(0,ft.c)(15),{row:n,t:r,onUpdate:i,variant:a,showOAuth:o,idReadOnly:s}=e,c=a===void 0?`all`:a,l=o!==void 0&&o,u=s!==void 0&&s,d=c!==`advanced`,f=c!==`basic`,p;t[0]!==d||t[1]!==i||t[2]!==n||t[3]!==r?(p=d?(0,$.jsxs)($.Fragment,{children:[n.transport===`stdio`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Hn,{label:`${r.commandLabel} *`,children:(0,$.jsx)(`input`,{"data-field":`command`,className:Ln,value:n.command,required:!0,onChange:e=>i({command:e.target.value})})}),(0,$.jsx)(Un,{row:n,t:r,onUpdate:i})]}):(0,$.jsx)(Hn,{label:`${r.urlLabel} *`,children:(0,$.jsx)(`input`,{"data-field":`url`,className:Ln,value:n.url,placeholder:`https://example.com/mcp`,required:!0,onChange:e=>i({url:e.target.value})})}),(0,$.jsx)(Hn,{label:r.setupNameLabel,hint:r.setupNameHint,children:(0,$.jsx)(`input`,{className:Ln,value:n.displayName??``,placeholder:r.setupNamePlaceholder,onChange:e=>i({displayName:e.target.value})})})]}):null,t[0]=d,t[1]=i,t[2]=n,t[3]=r,t[4]=p):p=t[4];let m;t[5]!==f||t[6]!==u||t[7]!==i||t[8]!==n||t[9]!==l||t[10]!==r?(m=f?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Hn,{label:r.serverIdLabel,hint:r.setupIdHint,children:(0,$.jsx)(`input`,{className:Ln,readOnly:u,value:n.id,onChange:e=>i({id:e.target.value}),placeholder:r.serverIdPlaceholder})}),n.transport===`stdio`?(0,$.jsx)(Hn,{label:r.cwdLabel,children:(0,$.jsx)(`input`,{className:Ln,value:n.cwd,onChange:e=>i({cwd:e.target.value})})}):null,n.transport!==`stdio`&&l?(0,$.jsx)(Hn,{label:r.oauthClientIdLabel,hint:r.oauthClientIdHint,children:(0,$.jsx)(`input`,{className:Ln,value:n.oauthClientId,onChange:e=>i({oauthClientId:e.target.value})})}):null,(0,$.jsx)(Hn,{label:r.exposureLabel,hint:r.setupExposureHint,children:(0,$.jsx)(_,{"aria-label":r.exposureLabel,className:Ln,value:n.exposure,onChange:e=>i({exposure:e.target.value}),children:[`codemode`,`deferred`,`direct`,`hidden`].map(e=>(0,$.jsx)(v,{value:e,children:r.exposureLabels[e]},e))})}),(0,$.jsx)(Hn,{label:r.requestTimeoutLabel,children:(0,$.jsx)(dt,{allowEmpty:!0,type:`number`,min:1,className:Ln,value:n.timeout??``,placeholder:r.setupDefaultTimeout,onChange:e=>i({timeout:e.target.value?Number(e.target.value):void 0})})})]}):null,t[5]=f,t[6]=u,t[7]=i,t[8]=n,t[9]=l,t[10]=r,t[11]=m):m=t[11];let h;return t[12]!==p||t[13]!==m?(h=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[p,m]}),t[12]=p,t[13]=m,t[14]=h):h=t[14],h}function Gn(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 Kn(e,t){return JSON.stringify({id:e.id,config:qt(Nn(e,t))})}function qn(e,t){try{return Kn(e,t)}catch{return JSON.stringify({row:e,auth:t})}}function Jn(e){let{t,cs:n}=e,r=(0,Q.useId)(),[i,a]=(0,Q.useState)(e.initialRow),[o,s]=(0,Q.useState)(()=>Mn(e.initialRow)),[c,l]=(0,Q.useState)(`idle`),[u,d]=(0,Q.useState)(``),[f,p]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(),[g,y]=(0,Q.useState)(),[b,S]=(0,Q.useState)(),[C,w]=(0,Q.useState)(!1),[T,E]=(0,Q.useState)(!1),[D,O]=(0,Q.useState)(``),[k,A]=(0,Q.useState)(``),[M,N]=(0,Q.useState)([]),[P,I]=(0,Q.useState)(`0`),[L,R]=(0,Q.useState)(0),[z,B]=(0,Q.useState)(``),[V,H]=(0,Q.useState)(!1),[U,ee]=(0,Q.useState)(!1),W=e.mode===`edit`,[te,G]=(0,Q.useState)(``),K=(0,Q.useRef)(void 0),[ne]=(0,Q.useState)(()=>qn(e.initialRow,Mn(e.initialRow))),re=(0,Q.useRef)(e.mode===`edit`?e.initialRow.id:``),q=(0,Q.useRef)(void 0),ie=(0,Q.useRef)(void 0),J=(0,Q.useRef)(void 0),Z=(0,Q.useRef)(null),ce=(0,Q.useRef)(``),pe=(0,Q.useRef)(!0),me=(0,Q.useRef)(null),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=b?.state===`starting`||b?.state===`authorizing`,be=c!==`idle`||ye,xe=ne!==qn(i,o),Se=i.extra.enabled===!1,Ce=!f&&(xe||!!D.trim());(0,Q.useEffect)(()=>(pe.current=!0,()=>{pe.current=!1,q.current?.abort(),Z.current?.close(),K.current&&Zt(K.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(!m)return;let e=ge.current?.querySelector(`[data-field="${m.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),m.focus!==!1&&(n??_e.current)?.focus(),()=>{n?.removeAttribute(`aria-invalid`),n?.removeAttribute(`aria-describedby`)}},[m,r]),(0,Q.useEffect)(()=>{if(!b||!ye)return;let e=new AbortController;ie.current=e;let n;async function r(){try{let n=await en(K.current,e.signal);if(e.signal.aborted||(S(n),n.authorizationUrl&&ce.current!==n.authorizationUrl&&(ce.current=n.authorizationUrl,window.electronAPI?.shell?.openExternalUrl?!(await window.electronAPI.shell.openExternalUrl(n.authorizationUrl)).ok&&!e.signal.aborted&&d(t.oauthOpenFailed):Z.current&&!Z.current.closed&&Z.current.location.replace(n.authorizationUrl)),e.signal.aborted))return;if(n.state===`connected`){J.current=void 0,Z.current?.close(),y({state:`connected`,toolCount:n.toolCount}),d(``);return}if(n.state===`error`||n.state===`cancelled`){J.current=void 0,Z.current?.close(),d(n.state===`cancelled`?t.setupCancelled:t.setupAuthFailed),/client.{0,20}(id|registration)|register|registration/i.test(n.error??``)&&w(!0);return}}catch{if(e.signal.aborted)return;we(),Z.current?.close(),d(t.setupAuthFailed);return}n=setTimeout(()=>void r(),1200)}return r(),()=>{e.abort(),clearTimeout(n)}},[b?.id,ye,t.oauthOpenFailed,t.setupCancelled,t.setupAuthFailed]);function we(){q.current?.abort(),ie.current?.abort(),K.current&&Zt(K.current).catch(()=>{}),K.current=void 0,G(``),H(!1),y(void 0),S(void 0),d(``),h(void 0)}function Te(e){a(t=>({...t,...e})),we()}function Ee(e){s(t=>({...t,...e})),we()}function De(){c===`saving`||ye||(c===`checking`&&(we(),l(`idle`)),Ce?ee(!0):e.onClose())}function Oe(){try{N(Wt(D)),I(`0`),A(``)}catch{A(t.setupImportError),N([])}}function ke(){let t=M[Number(P)];if(!t)return;let n={...t,id:re.current||t.id,clientKey:e.initialRow.clientKey,extra:{...t.extra,...re.current?{enabled:i.extra.enabled}:{}}};a(n),s(Mn(n)),we(),R(e=>e+1),E(!1),O(``),N([])}function Ae(e){function n(e,t){return h({field:e,message:t}),!1}if(e.transport===`streamable-http`){try{e.url=Ut(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(Pn(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{qt(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 je(){d(``),l(`checking`),ce.current=``,window.electronAPI?.shell?.openExternalUrl||(Z.current=window.open(`about:blank`,`_blank`),Z.current&&(Z.current.opener=null));try{let e=await $t(K.current);if(!pe.current){Z.current?.close(),K.current&&Zt(K.current).catch(()=>{});return}J.current=e.id,S(e)}catch{Z.current?.close(),pe.current&&d(t.setupAuthFailed)}finally{pe.current&&l(`idle`)}}async function Me(){let r=Nn(i,o);if(!Ae(r))return;let s=e.existingCustomServers.filter(t=>t.clientKey!==e.initialRow.clientKey&&t.id!==re.current),c=new Set([...e.managedServerIds,...s.map(e=>e.id)]);if(r.id=re.current||r.id.trim()||Ht(r,c),!/^[a-zA-Z0-9_-]+$/.test(r.id)||[...c].some(e=>e.replace(/-/g,`_`)===r.id.replace(/-/g,`_`))){h({field:`advanced`,message:n.duplicateServerId});return}we(),l(`checking`);let u=new AbortController;q.current=u;try{let n=await Yt(r,re.current||void 0,e.initialRow.extra,u.signal);if(!pe.current||u.signal.aborted){Zt(n.id).catch(()=>{});return}K.current=n.id,a(r),G(qn(r,o));let i=await Xt(n.id,u.signal);if(!pe.current||u.signal.aborted)return;y(i),i.state===`error`&&d(Gn(i,t))}catch(e){pe.current&&!u.signal.aborted&&d(e.status===409?t.setupConflict:Gn(e,t))}finally{pe.current&&q.current===u&&l(`idle`)}}async function Ne(n=!1){if(!(!K.current||g?.state!==`connected`||te!==qn(i,o))){l(`saving`),d(``);try{let t=await Qt(K.current,n);K.current=void 0,await ve.current().catch(()=>{}),t?.reloadRequired?p(!0):e.onClose()}catch(e){let n=e.status;n===404||n===409?(we(),d(t.setupConflict)):d(t.setupSaveFailed)}finally{pe.current&&l(`idle`)}}}async function Pe(){ie.current?.abort();let e=K.current;J.current=void 0,S(void 0),Z.current?.close(),d(t.setupCancelled),l(`checking`);try{e&&await tn(e)}catch{pe.current&&(we(),d(t.setupCancelled))}finally{pe.current&&l(`idle`)}}async function Fe(){b?.authorizationUrl&&(window.electronAPI?.shell?.openExternalUrl?(await window.electronAPI.shell.openExternalUrl(b.authorizationUrl)).ok||d(t.oauthOpenFailed):window.open(b.authorizationUrl,`_blank`,`noopener,noreferrer`))}async function Ie(){if(b)try{await nn(K.current,z),B(``),d(``)}catch{d(t.setupRedirectInvalid)}}let Le=!!K.current&&te===qn(i,o)&&(o.mode===`oauth`||o.mode===`auto`&&g?.state===`oauth_required`)&&g?.state!==`connected`,Re=/^(?:https?:\/\/)?(?:localhost|127\.0\.0\.1|\[::1\])(?=[:/]|$)/i.test(i.url.trim()),ze=M[Number(P)];return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(fe,{open:e.open,onOpenChange:e=>{e||De()},children:(0,$.jsxs)(le,{children:[(0,$.jsx)(oe,{className:`fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(ue,{ref:me,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(),me.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)(de,{className:`font-semibold`,children:e.mode===`edit`?t.setupEditTitle:t.setupTitle}),(0,$.jsx)(se,{className:`mt-1 text-sm text-fg-muted`,children:t.setupHint})]}),(0,$.jsx)(`button`,{type:`button`,disabled:c===`saving`||ye,onClick:De,className:`rounded-lg p-2 text-fg-muted hover:bg-surface-hover disabled:opacity-50`,"aria-label":n.modalClose,children:(0,$.jsx)(ae,{className:`size-5`,"aria-hidden":!0})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-5`,children:[T?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(X,{variant:`ghost`,onClick:()=>E(!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:Y(Ln,`mt-1.5 min-h-40 font-mono text-xs`),value:D,placeholder:`{"mcpServers": {"docs": {"url": "https://example.com/mcp"}}}`,onChange:e=>{O(e.target.value),N([]),A(``)}})]}),(0,$.jsx)(X,{variant:`secondary`,disabled:!D.trim(),onClick:Oe,children:t.setupImportPreview}),k?(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:k}):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)(_,{"aria-label":t.setupImportChoose,className:Y(Ln,`mt-1.5`),value:P,onChange:e=>I(e.target.value),children:M.map((e,t)=>(0,$.jsx)(v,{value:String(t),children:e.displayName||e.id||un(e)},t))})]}),(0,$.jsxs)(`p`,{className:`break-all text-sm text-fg-muted`,children:[ze.transport===`stdio`?t.setupUseCommand:t.setupUseUrl,` · `,un(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{Ut(i.url)}catch{h({field:`url`,message:t.setupAddressInvalid,focus:!1})}},onSubmit:e=>{e.preventDefault(),Me()},children:[(0,$.jsxs)(`fieldset`,{disabled:be||f,className:`min-w-0 space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsx)($e,{className:`flex gap-1`,role:`group`,"aria-label":t.transportLabel,children:[`streamable-http`,`stdio`].map(e=>(0,$.jsx)(X,{type:`button`,variant:i.transport===e?`secondary`:`ghost`,"aria-pressed":i.transport===e,onClick:()=>Te({transport:e}),children:e===`stdio`?t.setupUseCommand:t.setupUseUrl},e))}),(0,$.jsx)(X,{type:`button`,variant:`ghost`,onClick:()=>E(!0),children:t.setupImport})]}),(0,$.jsx)(`div`,{children:(0,$.jsx)(Wn,{row:i,t,variant:`basic`,onUpdate:Te},`${i.transport}-${L}`)}),i.transport===`streamable-http`?(0,$.jsx)(`div`,{"data-field":`auth`,children:(0,$.jsx)(Vn,{allowExisting:!!i.extra.auth||i.headers.some(e=>!!e.reference),draft:o,onChange:Ee,t})}):null,m?(0,$.jsx)(`p`,{id:r,ref:_e,tabIndex:-1,role:`alert`,className:`text-sm text-danger`,children:m.message}):null,(0,$.jsxs)(`details`,{"data-field":`advanced`,className:`rounded-lg border border-edge p-3`,open:C,onToggle:e=>w(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)(Wn,{row:i,t,variant:`advanced`,idReadOnly:W,showOAuth:o.mode===`oauth`,onUpdate:Te}),i.transport===`streamable-http`&&o.mode!==`headers`&&o.mode!==`existing`?(0,$.jsx)(Bn,{additional:!0,headers:o.additionalHeaders,onChange:e=>Ee({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})]}),f?(0,$.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-fg`,children:t.setupReloadRequired}):null,!T&&!f?(0,$.jsxs)(`div`,{className:`mt-4 space-y-3`,"aria-live":`polite`,children:[c===`idle`?null:(0,$.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,$.jsx)(F,{className:`size-4 animate-spin motion-reduce:animate-none`,"aria-hidden":!0}),c===`saving`?t.setupSaving:t.setupChecking]}),c===`idle`&&W&&!xe&&!g&&!u&&!ye?(0,$.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:Se?t.setupDisabled:e.lastCheck?t.setupLastCheck.replace(`{{count}}`,String(e.lastCheck.toolCount)):t.setupSavedUnchecked}):null,g?.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)(x,{className:`size-4 shrink-0`,"aria-hidden":!0}),g.toolCount?t.setupConnected.replace(`{{count}}`,String(g.toolCount)):t.setupZeroTools]}),(0,$.jsx)(X,{ref:he,variant:`secondary`,onClick:()=>H(!0),children:t.viewTools})]}):null,g?.state===`token_required`?(0,$.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:t.setupNeedsAuth}):null,g?.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)(F,{className:`size-4 animate-spin motion-reduce:animate-none`,"aria-hidden":!0}),t.setupAuthorizing]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[b?.authorizationUrl?(0,$.jsxs)(X,{variant:`secondary`,onClick:()=>void Fe(),children:[(0,$.jsx)(j,{className:`size-4`,"aria-hidden":!0}),t.oauthOpenAuthorization]}):null,(0,$.jsx)(X,{variant:`ghost`,onClick:()=>void Pe(),children:t.setupCancelAuth})]}),b?.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:Ln,value:z,onChange:e=>B(e.target.value)})]}),(0,$.jsx)(X,{className:`mt-2`,disabled:!z.trim(),onClick:()=>void Ie(),children:t.setupContinue})]}):null]}):null,u?(0,$.jsxs)(`div`,{role:`alert`,className:`space-y-1 text-sm`,children:[(0,$.jsx)(`p`,{className:`text-danger`,children:u}),u!==t.setupSaveFailed&&c!==`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)(X,{variant:`secondary`,disabled:c===`saving`||ye,onClick:De,children:W||f?t.setupClose:n.modalCancel}),f?null:T?(0,$.jsx)(X,{variant:`primary`,disabled:!ze,onClick:ke,children:t.setupImportApply}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(X,{variant:g?.state===`connected`?`secondary`:`primary`,disabled:be,onClick:()=>Le?void je():void Me(),children:Le?t.setupSignIn:t.setupTestConnection}),g?.state===`connected`&&te===qn(i,o)?(0,$.jsxs)($.Fragment,{children:[Se?(0,$.jsx)(X,{variant:`secondary`,disabled:be,onClick:()=>void Ne(!0),children:t.setupEnableSave}):null,(0,$.jsx)(X,{variant:`primary`,disabled:be,"aria-busy":be,onClick:()=>void Ne(),children:W?t.setupSaveOnly:t.setupAddConnection})]}):null]})]})]})]})}),(0,$.jsx)(et,{open:U,title:t.setupUnsavedTitle,description:t.setupUnsavedHint,confirmLabel:t.setupDiscard,cancelLabel:t.setupKeepEditing,onCancel:()=>ee(!1),onConfirm:e.onClose,overlayClassName:`z-[70]`,contentClassName:`z-[70]`}),V?(0,$.jsx)(sn,{draftId:K.current,serverId:i.id,displayName:i.displayName,returnFocusTo:he.current,t,onClose:()=>H(!1)}):null]})}var Yn=`recommended`,Xn=`builtin`,Zn=`composio`,Qn=`xopc-store`;function $n(e,t=`en`){return e==="default"&&t.startsWith(`zh`)?Yn:Xn}function er(e,t){let n=e.connectorManifest;if(!n||typeof n!=`object`||Array.isArray(n))return null;let r=n;if(r.contractVersion!==1||r.id!==e.name)return null;let i=r.runtime,a=r.auth;if(!i||typeof i!=`object`||Array.isArray(i)||!a||typeof a!=`object`||Array.isArray(a))return null;let o=i,s=a;if(o.type!==`mcp`||typeof o.serverId!=`string`)return null;let c=[`code`,`docs`,`browser`,`data`,`automation`,`custom`].includes(String(r.category??``))?r.category:`custom`,l=s.mode===`oauth`?{mode:`oauth`,...typeof s.clientId==`string`?{clientId:s.clientId}:{}}:s.mode===`apiKey`?{mode:`apiKey`}:{mode:`none`},u=e.localizations?.[t===`zh`?`zh-CN`:`en`];return{id:e.name,version:e.latestVersion??`store`,displayName:u?.displayName??(typeof r.displayName==`string`?r.displayName:e.name),description:u?.description??(typeof r.description==`string`?r.description:e.description),category:c,kind:`mcp`,source:`store`,...e.branding?.iconUrl?{branding:{logoUrl:e.branding.iconUrl,source:`registry`}}:{},capabilities:Array.isArray(r.capabilities)?r.capabilities.filter(e=>typeof e==`string`):[],tags:Array.isArray(r.tags)?r.tags.filter(e=>typeof e==`string`):[`store`],auth:l,setup:r.setup&&typeof r.setup==`object`&&!Array.isArray(r.setup)?r.setup:{},runtime:{type:`mcp`,serverId:o.serverId}}}function tr(e){return d(e.map(e=>({connector:e,service:{id:e.id,source:e.source===`builtin`?`builtin-connector`:e.source===`store`?`store-connector`:`registry-connector`}})),`en`).map(e=>e.connector)}function nr(e){return e?.startsWith(`/`)&&!e.startsWith(`//`)?e:`/user-model`}function rr({embedded:e=!1,onHeaderActionChange:t}){let n=me().filter(pn),r=c(e=>e.language),o=u(r),l=o.connectorsSettings,d=o.mcpSettings,h=s(e=>e.conversationId),g=!!h,_=a(),[v,b]=i(),x=v.get(`understanding`)===`1`,S=nr(v.get(`returnTo`)),C=!!v.get(`returnTo`)&&!x,O=v.get(`tab`),[k,A]=(0,Q.useState)(!x&&O===`connected`?`connected`:`discover`),{data:j}=pe(g&&k===`discover`&&!x?[`service-recommendations`,r]:null,()=>f(r),{revalidateOnFocus:!1}),M=(0,Q.useMemo)(()=>new Set(j?.items.filter(e=>e.service?.source===`store-plugin`).map(e=>p(e.id))??[]),[j]),N=(0,Q.useRef)(!1),[P,I]=(0,Q.useState)({catalog:[],registryCatalog:[],instances:[],loading:!0,error:null}),[L,R]=(0,Q.useState)(!1),[z,B]=(0,Q.useState)(!1),[V,ee]=(0,Q.useState)(1),[W,te]=(0,Q.useState)(void 0),[G,K]=(0,Q.useState)(``),[ne,re]=(0,Q.useState)(x||C?v.get(`connector`)??``:``),[q,ie]=(0,Q.useState)($n(x?`understanding`:`default`,r)),[J,ae]=(0,Q.useState)(`name`),[Z,oe]=(0,Q.useState)(x?`understand`:`all`),[se,ce]=(0,Q.useState)(null),[le,ue]=(0,Q.useState)(null),[de,fe]=(0,Q.useState)(null),[he,ge]=(0,Q.useState)(null),[_e,ye]=(0,Q.useState)(null),[be,xe]=(0,Q.useState)(null),{data:Se,mutate:Ce}=ve(g),we=Se?.payload?.config,Te=(0,Q.useMemo)(()=>we===void 0?null:Kt(we),[we]),Ee=Te?.servers??[],De=P.instances.length+Ee.length+n.length,[Oe,ke]=(0,Q.useState)({});(0,Q.useEffect)(()=>{if(ke({}),!g||!we)return;let e=new AbortController;return an(e.signal).then(t=>{e.signal.aborted||ke(t)}).catch(()=>{}),()=>e.abort()},[g,we]);let Ae=(0,Q.useCallback)(async()=>{if(!h){I({catalog:[],registryCatalog:[],instances:[],loading:!1,error:null});return}I(e=>({...e,loading:!0,error:null}));try{let[e,t]=await Promise.all([Pe(),je()]);I(n=>({catalog:e,registryCatalog:n.registryCatalog,instances:t,loading:!1,error:null}))}catch(e){I({catalog:[],registryCatalog:[],instances:[],loading:!1,error:e instanceof Error?e.message:String(e)})}},[h]);(0,Q.useEffect)(()=>{Ae()},[Ae]),(0,Q.useEffect)(()=>{N.current||P.loading||g&&!Te||(A(x?`discover`:De>0?`connected`:`discover`),N.current=!0)},[g,De,Te,x,P.loading]),(0,Q.useEffect)(()=>{ie(e=>e===`builtin`||e===`recommended`?$n(x?`understanding`:`default`,r):e)},[r,x]);let Me=(0,Q.useCallback)(e=>{N.current=!0,A(e)},[]),Ne=(0,Q.useMemo)(()=>[{id:Zn,displayName:l.composioSourceName},{id:Qn,displayName:l.storeSourceName}],[l.composioSourceName,l.storeSourceName]),Fe=(0,Q.useCallback)(async e=>{if(!g||q===`builtin`||q===`recommended`){I(e=>({...e,registryCatalog:[]})),ee(1),te(void 0);return}let t=ne.trim(),n=Math.max(e?.page??1,1),i=e?.append??!1,a=q===`all`?Ne:Ne.filter(e=>e.id===q);if(a.length!==0){R(!0),i?I(e=>({...e,error:null})):(ee(1),te(void 0),I(e=>({...e,registryCatalog:[],error:null})));try{let e=await Promise.all(a.map(async e=>{if(e.id===`composio`){let e=await Ve({q:t||void 0,page:n,pageSize:24,verification:`experimental`});return{connectors:e.connectors,totalPages:e.meta.totalPages}}let i=await ze({q:t||void 0,page:n,pageSize:24,sort:J===`source`?`newest`:`downloads`});return{connectors:i.items.flatMap(e=>{let t=er(e,r);return t?[t]:[]}),totalPages:i.meta.totalPages}})),o=tr(e.flatMap(e=>e.connectors)),s=Math.max(1,...e.map(e=>e.totalPages??1));ee(n),te(s),I(e=>({...e,registryCatalog:i?tr([...e.registryCatalog,...o]):o}))}catch(e){I(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{R(!1)}}},[J,ne,q,g,Ne,r]);(0,Q.useEffect)(()=>{if(k!==`discover`||P.loading)return;if(q===`builtin`||q===`recommended`){I(e=>({...e,registryCatalog:[]})),ee(1),te(void 0);return}let e=window.setTimeout(()=>{Fe()},ne.trim()?350:0);return()=>window.clearTimeout(e)},[ne,q,Fe,P.loading,k]);let Ie=(0,Q.useMemo)(()=>new Set(P.instances.map(e=>e.connectorId)),[P.instances]),Le=(0,Q.useMemo)(()=>new Map([...P.catalog,...P.registryCatalog].map(e=>[e.id,e])),[P.catalog,P.registryCatalog]);(0,Q.useEffect)(()=>{if(P.loading)return;let e=v.get(`connector`),t=v.get(`instance`);if(!e&&!t)return;let n=P.instances.find(n=>t?n.instanceId===t:n.connectorId===e);if(n)N.current=!0,K(``),fe(n.instanceId),ge(n),A(`connected`);else if(e){let t=Le.get(e);if(!t)return;N.current=!0,ie($n(x?`understanding`:`default`,r)),re(``),ue(t),A(`discover`)}let i=new URLSearchParams(v);i.delete(`connector`),i.delete(`instance`),i.set(`tab`,n?`connected`:`discover`),b(i,{replace:!0})},[Le,x,r,v,b,P.instances,P.loading]);let Re=(0,Q.useCallback)(async e=>{B(!0),I(e=>({...e,error:null}));try{let t=await He(e);ce(H(t.definition,{packageName:t.packageName,version:t.version,reviewHash:t.reviewHash,permissions:t.permissions}))}catch(e){I(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{B(!1)}},[]);(0,Q.useEffect)(()=>{let e=v.get(`storeConnector`);if(!g||!e)return;let t=new URLSearchParams(v);t.delete(`storeConnector`),b(t,{replace:!0}),Re(e)},[g,v,b,Re]);let Be=(0,Q.useMemo)(()=>new Set(P.instances.flatMap(e=>e.materialized.type===`mcp`?[e.materialized.serverId]:[])),[P.instances]),Ue=(0,Q.useCallback)(async e=>{let t=await on(e);await Ce(),await Ae(),t.reloadRequired&&I(e=>({...e,error:d.setupReloadRequired}))},[Ae,Ce,d.setupReloadRequired]),We=(0,Q.useCallback)(()=>{xe({mode:`add`,row:jn(Ee,Be)})},[Ee,Be]),Ge=Qe(e=>e.setPageHeader),Ke=Qe(e=>e.clearPageHeader),qe=(0,Q.useMemo)(()=>({searchLabel:k===`connected`?l.connectedSearchPlaceholder:l.discoverSearchPlaceholder,search:(0,$.jsx)(ct,{value:k===`connected`?G:ne,onChange:k===`connected`?K:re,placeholder:k===`connected`?l.connectedSearchPlaceholder:l.discoverSearchPlaceholder}),secondary:(0,$.jsx)(jt,{onRefresh:k===`connected`&&g?Ae:void 0,refreshing:P.loading,refreshLabel:l.refreshConnections,onBrowseCatalog:()=>Me(`discover`),onAddCustomServer:We,addLabel:l.addConnection,browseLabel:l.addFromCatalog,customLabel:l.addCustomServerAdvanced,serviceLabel:r.startsWith(`zh`)?`应用连接服务`:`Connection service`,moreActionsLabel:o.capabilitiesHub.moreActions})}),[G,l,ne,g,r,Ae,o.capabilitiesHub.moreActions,We,Me,P.loading,k]);(0,Q.useLayoutEffect)(()=>e?(t?.(qe),()=>t?.(null)):(Ge({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:l.title})}),end:(0,$.jsx)(lt,{contribution:qe})}),()=>Ke()),[Ke,l.title,e,qe,t,Ge]);let Je=(0,Q.useMemo)(()=>P.instances.map(e=>({instance:e,value:Ct(e,Le.get(e.connectorId))})),[Le,P.instances]),Ye=(0,Q.useMemo)(()=>new Map(Je.map(({instance:e,value:t})=>[e.instanceId,t])),[Je]),Xe=(0,Q.useMemo)(()=>P.instances.filter(e=>E(e,G)).sort((e,t)=>{let n={needs_setup:0,checking:1,ready:2},r=Ye.get(e.instanceId)?.state??`checking`,i=Ye.get(t.instanceId)?.state??`checking`;return n[r]-n[i]||e.displayName.localeCompare(t.displayName)}),[G,Ye,P.instances]),et=(0,Q.useMemo)(()=>Xe.filter(e=>Ye.get(e.instanceId)?.state===`needs_setup`),[Ye,Xe]),tt=(0,Q.useMemo)(()=>Xe.filter(e=>Ye.get(e.instanceId)?.state!==`needs_setup`),[Ye,Xe]),nt=(0,Q.useMemo)(()=>Ee.filter(e=>D(e,G)),[G,Ee]),rt=(0,Q.useMemo)(()=>{let e=G.trim().toLowerCase();return n.filter(t=>[t.name,t.description,...(t.setup?.authorizations??[]).map(e=>e.title),...(t.components?.mcp??[]).map(e=>e.name)].filter(Boolean).join(` `).toLowerCase().includes(e))},[G,n]),it=Xe.length+nt.length+rt.length,at=(0,Q.useMemo)(()=>P.catalog.filter(e=>e.source===`builtin`&&e.integrationStrategy?.preferred!==!1&&w(e)),[P.catalog]),st=(0,Q.useMemo)(()=>q===`recommended`?[]:q===`builtin`?at:q===`all`?tr([...at,...P.registryCatalog]):P.registryCatalog,[at,q,P.registryCatalog]),ut=(0,Q.useMemo)(()=>{let e=x?st.filter(e=>e.understanding?.mode===`activity`):tr(st).filter(e=>!M.has(p(e.id)));return T(Z===`all`?e:e.filter(e=>xt(e).includes(Z)),ne,J)},[J,ne,st,x,Z,M]),dt=(0,Q.useMemo)(()=>bt.filter(e=>st.some(t=>xt(t).includes(e))),[st]);(0,Q.useEffect)(()=>{Z!==`all`&&!dt.includes(Z)&&oe(`all`)},[dt,Z]);let ft=k===`discover`&&q!==`builtin`&&!!(W&&V<W),mt=(0,Q.useMemo)(()=>P.instances.find(e=>e.instanceId===de)??he,[de,he,P.instances]),_t=(0,Q.useMemo)(()=>[{value:Yn,label:r===`zh`?`推荐服务`:`Recommended services`},{value:`all`,label:l.discoverSourceAll},{value:Xn,label:l.discoverSourceBuiltin},...Ne.map(e=>({value:e.id,label:e.displayName}))],[l.discoverSourceAll,l.discoverSourceBuiltin,Ne,r]),St=[{id:`connected`,label:l.tabConnected,count:De},{id:`discover`,label:l.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:Y(`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:[g?null:(0,$.jsx)(`p`,{className:`rounded-xl border border-edge bg-surface-panel px-4 py-3 text-sm text-fg-muted`,children:l.tokenHint}),x?(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:l.understandingSetupTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:l.understandingSetupHint})]}),(0,$.jsx)(X,{type:`button`,variant:`secondary`,className:`shrink-0`,onClick:()=>_(S),children:l.understandingSetupDone})]}):null,C?(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:l.recoverySetupTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:l.recoverySetupHint})]}),(0,$.jsx)(X,{type:`button`,variant:`secondary`,className:`min-h-11 shrink-0`,onClick:()=>_(S),children:l.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)(Ze,{items:St,activeTab:k,onChange:Me,ariaLabel:l.navAria,tabIdPrefix:`connectors-tab`,panelIdPrefix:`connectors-panel`,className:`flex-wrap`})}),P.error?(0,$.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:P.error}):null,k===`connected`&&g?(0,$.jsx)(`div`,{className:`flex flex-col gap-6`,children:P.loading?(0,$.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,"aria-busy":`true`,"aria-label":l.loading,children:ht.slice(0,3).map(e=>(0,$.jsx)(yt,{},e))}):De===0?(0,$.jsxs)(`div`,{className:`py-14 text-center`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:l.connectionsEmpty}),(0,$.jsx)(X,{type:`button`,variant:`primary`,className:`mt-4`,onClick:()=>Me(`discover`),children:l.addFromCatalog})]}):it===0?(0,$.jsx)(`div`,{className:`py-14 text-center text-sm text-fg-muted`,children:l.connectionsSearchEmpty}):(0,$.jsxs)(`div`,{className:`space-y-6`,children:[et.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:l.needsAttentionTitle}),(0,$.jsx)(`span`,{className:`text-xs tabular-nums text-amber-700 dark:text-amber-300`,children:et.length})]}),(0,$.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:et.map(e=>(0,$.jsx)(An,{instance:e,definition:Le.get(e.connectorId),highlighted:e.instanceId===_e,onOpenDetails:e=>{ye(null),fe(e.instanceId),ge(e)},t:l},e.instanceId))})]}):null,tt.length||rt.length?(0,$.jsx)(`section`,{children:(0,$.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:[tt.map(e=>(0,$.jsx)(An,{instance:e,definition:Le.get(e.connectorId),highlighted:e.instanceId===_e,onOpenDetails:e=>{ye(null),fe(e.instanceId),ge(e)},t:l},e.instanceId)),rt.map(e=>(0,$.jsx)(mn,{extension:e,language:r,onOpen:()=>_(ot(e.pluginId,`connections`,e.authorizationStatus===`required`))},e.id))]})}):null,nt.length||!G.trim()?(0,$.jsx)(fn,{servers:nt,lastChecks:Oe,t:d,cs:l,onAdd:We,onEdit:e=>xe({mode:`edit`,row:structuredClone(e)}),onRemove:Ue}):null]})}):null,k===`discover`&&g?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[x?null:(0,$.jsx)($e,{className:`flex min-w-0 flex-1 basis-80 flex-wrap gap-2`,role:`group`,"aria-label":l.taskFilterAria,indicatorClassName:`rounded-lg bg-surface-active`,children:[`all`,...dt].map(e=>(0,$.jsx)(`button`,{type:`button`,className:Y(`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors`,Z===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":Z===e,onClick:()=>oe(e),children:e===`all`?l.taskAll:l.connectorBenefitHeadings[e]},e))}),(0,$.jsxs)(`div`,{className:Y(`ml-auto grid w-full gap-2 sm:flex sm:w-auto sm:justify-end`,x?`grid-cols-1`:`grid-cols-2`),children:[x?null:(0,$.jsx)(`div`,{className:`min-w-0 sm:w-40`,children:(0,$.jsx)(y,{value:q,options:_t,placeholder:l.discoverSourceAll,allowEmpty:!1,ariaLabel:l.registrySourceAria,triggerClassName:`h-9 bg-surface-panel text-xs`,onChange:ie})}),q===`recommended`?null:(0,$.jsx)(`div`,{className:`min-w-0 sm:w-40`,children:(0,$.jsx)(y,{value:J,options:[{value:`name`,label:l.sortName},{value:`source`,label:l.sortSource}],placeholder:l.sortName,allowEmpty:!1,ariaLabel:l.sortAria,triggerClassName:`h-9 bg-surface-panel text-xs`,onChange:e=>ae(e)})})]})]}),q===`recommended`?(0,$.jsx)(m,{layout:`cards`,initialCount:6,query:ne,onChanged:async()=>{await Ae(),await Ce()}}):(P.loading||L)&&ut.length===0?(0,$.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,"aria-busy":`true`,"aria-label":l.loading,children:ht.map(e=>(0,$.jsx)(vt,{},e))}):ut.length===0?(0,$.jsx)(`div`,{className:`py-14 text-center text-sm text-fg-muted`,children:l.discoverEmpty}):(0,$.jsxs)(`div`,{className:`relative`,children:[L?(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":l.loading,children:(0,$.jsx)(F,{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:ut.map(e=>(0,$.jsx)(pt,{connector:e,installed:Ie.has(e.id)||gt(e,P.instances),onInstall:e=>{if(e.source===`store`){Re(e.id);return}ce(H(e))},onOpenDetails:e.source===`store`?void 0:ue,t:l},e.id))}),ft?(0,$.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,$.jsxs)(X,{type:`button`,variant:`secondary`,disabled:L||z,onClick:()=>void Fe({page:V+1,append:!0}),children:[L?(0,$.jsx)(F,{className:`size-4 animate-spin`}):null,l.loadMore]})}):null]})]}):null]}),se?(0,$.jsx)(U,{draft:se,onChange:ce,onClose:()=>ce(null),t:l,onInstalled:async e=>{await Ae(),await Ce(),ye(e.instanceId),Me(`connected`)}}):null,le?(0,$.jsx)(Dt,{connector:le,installed:Ie.has(le.id)||gt(le,P.instances),onClose:()=>ue(null),onInstall:e=>ce(H(e)),t:l}):null,mt?(0,$.jsx)(kn,{instance:mt,definition:Le.get(mt.connectorId),onClose:()=>{fe(null),ge(null)},onChanged:Ae,t:l,mcp:d}):null,be?(0,$.jsx)(Jn,{open:!0,mode:be.mode,initialRow:be.row,lastCheck:be.mode===`edit`?Oe[be.row.id]:void 0,existingCustomServers:Ee,config:we,managedServerIds:Be,t:d,cs:l,onClose:()=>xe(null),onSaved:async()=>{await Ce(),await Ae(),Me(`connected`)}},`${be.mode}-${be.row.clientKey}`):null]})})}export{rr as ConnectorsPage};
|
|
1
|
+
import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{m as i,u as a}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{i as o,l as s,n as c,o as l}from"./locale-store-Br7IfbXK.js";import{t as u}from"./messages-ByFlEbsu.js";import{i as d,n as f,r as p,t as m}from"./service-recommendation-list-BEnNx0u7.js";import{t as h}from"./chevron-down-ccbiQQz_.js";import{t as g}from"./chevron-right-BweFrslA.js";import{n as _,r as v,t as y}from"./popover-select-DD8fmrxH.js";import{t as b}from"./circle-alert-BEjgurr2.js";import{t as x}from"./circle-check-C23XjkUj.js";import{t as S}from"./circle-pause-CN9jYH2s.js";import{a as C,i as w,n as T,r as E,t as D}from"./connector-filters-Cfcx9EA2.js";import{t as O}from"./clock-3-DnrAnuyZ.js";import{t as k}from"./database-CjjeZfRG.js";import{t as A}from"./ellipsis-0k4rZLoy.js";import{t as j}from"./external-link-DjqjBmc3.js";import{n as M}from"./secret-input-BQvFXqzz.js";import{t as N}from"./eye-CABVeTq0.js";import{t as P}from"./key-round-DWbpyU2U.js";import{t as F}from"./loader-circle-CifKLtgG.js";import{a as I,c as L,i as R,n as z,o as B,r as V,s as H,t as U}from"./install-connector-dialog-BuNXON0P.js";import{t as ee}from"./plug-DKYPEgkR.js";import{t as W}from"./plus-Q2yW6OE7.js";import{t as te}from"./refresh-cw-BRlGaq2w.js";import{t as G}from"./save-DRDABU--.js";import{t as K}from"./server-BlHCBjiE.js";import{t as ne}from"./settings-uiTATseT.js";import{t as re}from"./store-SzD1Jvgm.js";import{t as q}from"./terminal-oKqqZdiG.js";import{t as ie}from"./trash-2-DusmjVPV.js";import{t as J}from"./wrench-DFb4r8bH.js";import{t as ae}from"./x-B_N4OPjy.js";import{t as Y}from"./cn-0WouolD0.js";import{t as X}from"./button-CnRSIP6m.js";import{t as Z}from"./skeleton-BI5TyibZ.js";import{a as oe,i as se,n as ce,o as le,r as ue,s as de,t as fe}from"./dist-DfWfZ9iu.js";import{i as pe}from"./vendor-swr-CdRzEUwF.js";import{r as me}from"./extension-provider-C_uKqJxP.js";import{n as he}from"./copy-to-clipboard-HOJ79TWv.js";import{n as ge}from"./interaction-BdhHBbYa.js";import{n as _e,r as ve}from"./gateway-config-swr-BOCt_zOo.js";import{A as ye,E as be,F as xe,I as Se,L as Ce,M as we,N as Te,O as Ee,P as De,R as Oe,S as ke,_ as Ae,a as je,c as Me,d as Ne,i as Pe,j as Fe,l as Ie,m as Le,n as Re,o as ze,p as Be,r as Ve,s as He,u as Ue,v as We,w as Ge,x as Ke,y as qe,z as Je}from"./connectors-api-DEJU8mgn.js";import{s as Ye}from"./form-field-width-DJw_jULe.js";import{n as Xe}from"./electron-env-DHOGevH3.js";import{t as Ze}from"./page-tabs-oeTY7z3_.js";import{t as Qe}from"./page-header-store-Du44NIEJ.js";import{t as $e}from"./sliding-tab-list-DuQyViqe.js";import{t as et}from"./confirm-dialog-XGclfBqe.js";import{l as tt,m as nt,o as rt,r as it,t as at}from"./dist-D3lWNSe7.js";import{t as ot}from"./capability-links-DzQWK1Fh.js";import{t as st}from"./capability-icon-DVoZxEgW.js";import{n as ct,t as lt}from"./capability-header-actions-CTUCuBlW.js";import{t as ut}from"./connector-service-page-C8InhrMt.js";import{t as dt}from"./number-input-El7Szeln.js";var Q=e(t(),1),ft=n(),$=r();function pt(e){let t=(0,ft.c)(57),{connector:n,installed:r,onInstall:i,onOpenDetails:a,t:o}=e,s,c,l,u,d,f;if(t[0]!==n||t[1]!==r||t[2]!==i||t[3]!==a||t[4]!==o){let e=n.capabilities.filter(mt),p=e.slice(0,2),m=Math.max(0,e.length-p.length),h=o.connect,g;t[11]!==n||t[12]!==o?(g=R(n,o),t[11]=n,t[12]=o,t[13]=g):g=t[13];let _=g,v=n.verificationLevel===`verified`?o.connectorVerified:n.verificationLevel===`beta`?o.connectorBeta:n.verificationLevel===`experimental`?o.connectorExperimental:null,y;t[14]!==h||t[15]!==n||t[16]!==i?(y=e=>(0,$.jsxs)(X,{type:`button`,variant:`secondary`,className:Y(`h-8 justify-center px-2.5 text-xs font-medium`,e),onClick:()=>i(n),children:[(0,$.jsx)(L,{className:`size-4`}),h]}),t[14]=h,t[15]=n,t[16]=i,t[17]=y):y=t[17],s=y,f=`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 b;t[18]===n?b=t[19]:(b=(0,$.jsx)(z,{connector:n}),t[18]=n,t[19]=b);let S;t[20]!==n||t[21]!==a?(S=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]=S):S=t[22];let C;t[23]===v?C=t[24]:(C=v?(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:v}):null,t[23]=v,t[24]=C);let w;t[25]!==C||t[26]!==S?(w=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[S,C]}),t[25]=C,t[26]=S,t[27]=w):w=t[27];let T;t[28]!==w||t[29]!==b?(T=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[b,w]}),t[28]=w,t[29]=b,t[30]=T):T=t[30];let E;t[31]!==r||t[32]!==s?(E=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]=E):E=t[33];let D;t[34]!==r||t[35]!==o.connectedBadge?(D=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)(x,{className:`size-3`,"aria-hidden":!0}),o.connectedBadge]}):null,t[34]=r,t[35]=o.connectedBadge,t[36]=D):D=t[36];let O;t[37]!==E||t[38]!==D?(O=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start gap-2`,children:[E,D]}),t[37]=E,t[38]=D,t[39]=O):O=t[39],t[40]!==T||t[41]!==O?(l=(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[T,O]}),t[40]=T,t[41]=O,t[42]=l):l=t[42],t[43]===_?u=t[44]:(u=(0,$.jsx)(`p`,{className:`mt-3 line-clamp-2 text-sm leading-6 text-fg-muted`,title:_,children:_}),t[43]=_,t[44]=u),d=p.length>0?(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:[p.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)),m>0?(0,$.jsxs)(`span`,{className:`rounded-md bg-surface-base px-2 py-0.5 text-[11px] text-fg-subtle`,children:[`+`,m]}):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]=d,t[10]=f}else s=t[5],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10];let p;t[45]!==c||t[46]!==l||t[47]!==u||t[48]!==d?(p=(0,$.jsxs)(`div`,{className:c,children:[l,u,d]}),t[45]=c,t[46]=l,t[47]=u,t[48]=d,t[49]=p):p=t[49];let m;t[50]!==r||t[51]!==s?(m=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]=m):m=t[52];let h;return t[53]!==f||t[54]!==p||t[55]!==m?(h=(0,$.jsxs)(`div`,{className:f,children:[p,m]}),t[53]=f,t[54]=p,t[55]=m,t[56]=h):h=t[56],h}function mt(e){return!e.startsWith(`runtime.`)&&!e.startsWith(`auth.`)}var ht=[`c0`,`c1`,`c2`,`c3`,`c4`,`c5`];function gt(e,t){return t.some(t=>t.connectorId===e.id)}var _t=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`;function vt(){let e=(0,ft.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`div`,{className:Y(`size-10 shrink-0 rounded-xl`,_t)}),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:Y(`h-4 min-w-0 flex-1`,_t)}),(0,$.jsx)(`div`,{className:Y(`h-8 w-[4.5rem] shrink-0 rounded-lg`,_t)})]}),(0,$.jsx)(`div`,{className:Y(`h-3 w-full`,_t)}),(0,$.jsx)(`div`,{className:Y(`h-3 w-[88%]`,_t)})]})]})}),e[1]=n):n=e[1],n}function yt(){let e=(0,ft.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(Z,{className:`size-9 shrink-0 rounded-lg`}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsxs)(`div`,{className:`flex min-h-[8.75rem] min-w-0 flex-col rounded-xl border border-edge bg-surface-panel p-4`,"aria-hidden":!0,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[t,(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2`,children:[(0,$.jsx)(Z,{className:`h-4 w-28 max-w-full`}),(0,$.jsx)(Z,{className:`h-3 w-20 max-w-full`})]})]}),(0,$.jsx)(Z,{className:`mt-2 h-3 w-48 max-w-full`}),(0,$.jsx)(Z,{className:`ml-auto mt-auto h-3 w-16`})]}),e[1]=n):n=e[1],n}var bt=[`understand`,`act`,`reach`];function xt(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 St(e){return xt(e)[0]??`act`}function Ct(e,t){let n=t?St(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 wt(e,t){return t.connectorCapabilityLabels[e]??e}function Tt(e,t){if(e.runtime.type===`mcp`)return I(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 I(t.connectorRuntimeGeneric,{runtime:e.runtime.type,id:n??e.runtime.type})}function Et(e,t){return e.auth.mode===`cli`?t.connectorAuthCli:e.auth.mode===`oauth`?t.connectorAuthOAuth:e.auth.mode===`apiKey`?t.connectorAuthApiKey:t.connectorAuthNone}function Dt(e){let t=(0,ft.c)(133),{connector:n,installed:r,onClose:i,onInstall:a,t:o}=e,s;t[0]!==n||t[1]!==o?(s=R(n,o),t[0]=n,t[1]=o,t[2]=s):s=t[2];let c=s,l,u,d,f,p,m,h,g,_,v,y,b,S,C,w,T;if(t[3]!==n||t[4]!==c||t[5]!==r||t[6]!==i||t[7]!==o){let e=xt(n),a;t[24]!==n.setup.config||t[25]!==n.setup.secrets?(a=[...(n.setup.secrets??[]).filter(At),...(n.setup.config??[]).filter(kt)],t[24]=n.setup.config,t[25]=n.setup.secrets,t[26]=a):a=t[26];let s=a,E=n.capabilities.filter(Ot);d=fe,h=!0,t[27]===i?g=t[28]:(g=e=>{e||i()},t[27]=i,t[28]=g),u=le,t[29]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(oe,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),t[29]=m):m=t[29],l=ue,t[30]===Symbol.for(`react.memo_cache_sentinel`)?(f=Y(`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]=f):f=t[30];let D;t[31]===n?D=t[32]:(D=(0,$.jsx)(z,{connector:n,size:`lg`}),t[31]=n,t[32]=D);let O;t[33]===n.displayName?O=t[34]:(O=(0,$.jsx)(de,{className:`text-base font-semibold text-fg`,children:n.displayName}),t[33]=n.displayName,t[34]=O);let k;t[35]!==r||t[36]!==o.connectedBadge?(k=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)(x,{className:`size-3`,"aria-hidden":!0}),o.connectedBadge]}):null,t[35]=r,t[36]=o.connectedBadge,t[37]=k):k=t[37];let A;t[38]!==O||t[39]!==k?(A=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[O,k]}),t[38]=O,t[39]=k,t[40]=A):A=t[40];let j;t[41]===c?j=t[42]:(j=(0,$.jsx)(se,{className:`mt-1 line-clamp-3 text-sm leading-6 text-fg-muted`,children:c}),t[41]=c,t[42]=j);let M;t[43]!==A||t[44]!==j?(M=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[A,j]}),t[43]=A,t[44]=j,t[45]=M):M=t[45];let N;t[46]!==D||t[47]!==M?(N=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[D,M]}),t[46]=D,t[47]=M,t[48]=N):N=t[48];let F;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(F=Y(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,ge.focusRingPanel),t[49]=F):F=t[49];let L;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,$.jsx)(ae,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),t[50]=L):L=t[50];let R;t[51]===o.modalClose?R=t[52]:(R=(0,$.jsx)(ce,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:F,"aria-label":o.modalClose,children:L})}),t[51]=o.modalClose,t[52]=R),t[53]!==N||t[54]!==R?(p=(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:[N,R]}),t[53]=N,t[54]=R,t[55]=p):p=t[55],C=`min-h-0 flex-1 space-y-5 overflow-y-auto px-5 py-5 sm:px-6`,w=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 B;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,$.jsx)(P,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),t[56]=B):B=t[56];let V;t[57]===o.detailPermissions?V=t[58]:(V=(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:o.detailPermissions}),t[57]=o.detailPermissions,t[58]=V);let H;t[59]!==n||t[60]!==o?(H=Et(n,o),t[59]=n,t[60]=o,t[61]=H):H=t[61];let U;t[62]===H?U=t[63]:(U=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:H}),t[62]=H,t[63]=U);let ee;t[64]!==V||t[65]!==U?(ee=(0,$.jsxs)(`div`,{className:`flex items-start gap-3 border-b border-edge-subtle px-4 py-3`,children:[B,(0,$.jsxs)(`div`,{children:[V,U]})]}),t[64]=V,t[65]=U,t[66]=ee):ee=t[66];let W;t[67]===o.connectorSetupTitle?W=t[68]:(W=(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:o.connectorSetupTitle}),t[67]=o.connectorSetupTitle,t[68]=W);let te;t[69]!==s.length||t[70]!==o.connectorRequiredInputsCount||t[71]!==o.connectorSetupNone?(te=s.length?I(o.connectorRequiredInputsCount,{count:String(s.length)}):o.connectorSetupNone,t[69]=s.length,t[70]=o.connectorRequiredInputsCount,t[71]=o.connectorSetupNone,t[72]=te):te=t[72];let G;t[73]===te?G=t[74]:(G=(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:te}),t[73]=te,t[74]=G);let ne;t[75]!==W||t[76]!==G?(ne=(0,$.jsxs)(`div`,{className:`px-4 py-3`,children:[W,G]}),t[75]=W,t[76]=G,t[77]=ne):ne=t[77],t[78]!==ee||t[79]!==ne?(T=(0,$.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-base`,children:[ee,ne]}),t[78]=ee,t[79]=ne,t[80]=T):T=t[80],b=`rounded-xl border border-edge bg-surface-base`,t[81]===o.connectorTechnicalDetails?S=t[82]:(S=(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]=S),_=`space-y-5 border-t border-edge-subtle px-4 py-4`;let re;t[83]===Symbol.for(`react.memo_cache_sentinel`)?(re=(0,$.jsx)(K,{className:`size-3.5`,"aria-hidden":!0}),t[83]=re):re=t[83];let q;t[84]===o.connectorRuntimeTitle?q=t[85]:(q=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[re,o.connectorRuntimeTitle]}),t[84]=o.connectorRuntimeTitle,t[85]=q);let ie;t[86]!==n||t[87]!==o?(ie=Tt(n,o),t[86]=n,t[87]=o,t[88]=ie):ie=t[88];let J;t[89]===ie?J=t[90]:(J=(0,$.jsx)(`p`,{className:`mt-1 break-words text-xs text-fg-subtle`,children:ie}),t[89]=ie,t[90]=J),t[91]!==q||t[92]!==J?(v=(0,$.jsxs)(`div`,{children:[q,J]}),t[91]=q,t[92]=J,t[93]=v):v=t[93],y=E.length?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:E.map(e=>(0,$.jsx)(`span`,{className:`rounded-md bg-surface-panel px-2 py-1 text-xs text-fg-muted`,children:wt(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]=d,t[11]=f,t[12]=p,t[13]=m,t[14]=h,t[15]=g,t[16]=_,t[17]=v,t[18]=y,t[19]=b,t[20]=S,t[21]=C,t[22]=w,t[23]=T}else l=t[8],u=t[9],d=t[10],f=t[11],p=t[12],m=t[13],h=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=t[23];let E;t[94]!==_||t[95]!==v||t[96]!==y?(E=(0,$.jsxs)(`div`,{className:_,children:[v,y]}),t[94]=_,t[95]=v,t[96]=y,t[97]=E):E=t[97];let D;t[98]!==E||t[99]!==b||t[100]!==S?(D=(0,$.jsxs)(`details`,{className:b,children:[S,E]}),t[98]=E,t[99]=b,t[100]=S,t[101]=D):D=t[101];let O;t[102]!==D||t[103]!==C||t[104]!==w||t[105]!==T?(O=(0,$.jsxs)(`div`,{className:C,children:[w,T,D]}),t[102]=D,t[103]=C,t[104]=w,t[105]=T,t[106]=O):O=t[106];let k;t[107]===o.modalClose?k=t[108]:(k=(0,$.jsx)(ce,{asChild:!0,children:(0,$.jsx)(X,{variant:`secondary`,children:o.modalClose})}),t[107]=o.modalClose,t[108]=k);let A;t[109]!==n||t[110]!==r||t[111]!==i||t[112]!==a||t[113]!==o.connect?(A=r?null:(0,$.jsxs)(X,{variant:`primary`,onClick:()=>{a(n),i()},children:[(0,$.jsx)(L,{className:`size-4`}),o.connect]}),t[109]=n,t[110]=r,t[111]=i,t[112]=a,t[113]=o.connect,t[114]=A):A=t[114];let j;t[115]!==k||t[116]!==A?(j=(0,$.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-5 py-4 sm:px-6`,children:[k,A]}),t[115]=k,t[116]=A,t[117]=j):j=t[117];let M;t[118]!==l||t[119]!==f||t[120]!==p||t[121]!==O||t[122]!==j?(M=(0,$.jsxs)(l,{className:f,children:[p,O,j]}),t[118]=l,t[119]=f,t[120]=p,t[121]=O,t[122]=j,t[123]=M):M=t[123];let N;t[124]!==u||t[125]!==m||t[126]!==M?(N=(0,$.jsxs)(u,{children:[m,M]}),t[124]=u,t[125]=m,t[126]=M,t[127]=N):N=t[127];let F;return t[128]!==d||t[129]!==h||t[130]!==g||t[131]!==N?(F=(0,$.jsx)(d,{open:h,onOpenChange:g,children:N}),t[128]=d,t[129]=h,t[130]=g,t[131]=N,t[132]=F):F=t[132],F}function Ot(e){return!e.startsWith(`runtime.`)&&!e.startsWith(`auth.`)}function kt(e){return e.required}function At(e){return e.required}var jt=(0,Q.memo)(function(e){let t=(0,ft.c)(45),{onRefresh:n,refreshing:r,refreshLabel:i,onBrowseCatalog:a,onAddCustomServer:o,addLabel:s,browseLabel:c,customLabel:l,serviceLabel:u,moreActionsLabel:d}=e,[f,p]=(0,Q.useState)(!1),m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=Y(`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`,ge.transition),t[0]=m):m=t[0];let g=m,_;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(W,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[1]=_):_=t[1];let v;t[2]===s?v=t[3]:(v=(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:s}),t[2]=s,t[3]=v);let y;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(h,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[4]=y):y=t[4];let b;t[5]!==s||t[6]!==v?(b=(0,$.jsx)(nt,{asChild:!0,children:(0,$.jsxs)(X,{type:`button`,variant:`primary`,className:`shrink-0 gap-2`,"aria-label":s,children:[_,v,y]})}),t[5]=s,t[6]=v,t[7]=b):b=t[7];let x;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(re,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[8]=x):x=t[8];let S;t[9]!==c||t[10]!==a?(S=(0,$.jsxs)(it,{className:g,onSelect:a,children:[x,c]}),t[9]=c,t[10]=a,t[11]=S):S=t[11];let C;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,$.jsx)(J,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[12]=C):C=t[12];let w;t[13]!==l||t[14]!==o?(w=(0,$.jsxs)(it,{className:g,onSelect:o,children:[C,l]}),t[13]=l,t[14]=o,t[15]=w):w=t[15];let T;t[16]!==S||t[17]!==w?(T=(0,$.jsx)(rt,{children:(0,$.jsxs)(at,{className:`z-50 min-w-[14rem] rounded-xl border border-edge bg-surface-overlay p-1 shadow-popover dark:border-edge`,sideOffset:6,align:`end`,children:[S,w]})}),t[16]=S,t[17]=w,t[18]=T):T=t[18];let E;t[19]!==T||t[20]!==b?(E=(0,$.jsxs)(tt,{children:[b,T]}),t[19]=T,t[20]=b,t[21]=E):E=t[21];let D;t[22]===f?D=t[23]:(D=(0,$.jsx)(ut,{open:f,onOpenChange:p,hideTrigger:!0}),t[22]=f,t[23]=D);let O;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,$.jsx)(A,{className:`size-4`,"aria-hidden":!0}),t[24]=O):O=t[24];let k;t[25]===d?k=t[26]:(k=(0,$.jsx)(nt,{asChild:!0,children:(0,$.jsx)(X,{type:`button`,variant:`secondary`,className:`size-9 shrink-0 p-0`,"aria-label":d,title:d,children:O})}),t[25]=d,t[26]=k);let j;t[27]!==n||t[28]!==i||t[29]!==r?(j=n?(0,$.jsxs)(it,{className:g,disabled:r,onSelect:n,children:[r?(0,$.jsx)(F,{className:`size-4 animate-spin text-fg-muted`,"aria-hidden":!0}):(0,$.jsx)(te,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),i]}):null,t[27]=n,t[28]=i,t[29]=r,t[30]=j):j=t[30];let M,N;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(M=()=>p(!0),N=(0,$.jsx)(ne,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),t[31]=M,t[32]=N):(M=t[31],N=t[32]);let P;t[33]===u?P=t[34]:(P=(0,$.jsxs)(it,{className:g,onSelect:M,children:[N,u]}),t[33]=u,t[34]=P);let I;t[35]!==j||t[36]!==P?(I=(0,$.jsx)(rt,{children:(0,$.jsxs)(at,{className:`z-50 min-w-[14rem] rounded-xl border border-edge bg-surface-overlay p-1 shadow-popover dark:border-edge`,sideOffset:6,align:`end`,children:[j,P]})}),t[35]=j,t[36]=P,t[37]=I):I=t[37];let L;t[38]!==k||t[39]!==I?(L=(0,$.jsxs)(tt,{children:[k,I]}),t[38]=k,t[39]=I,t[40]=L):L=t[40];let R;return t[41]!==E||t[42]!==D||t[43]!==L?(R=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2`,children:[E,D,L]}),t[41]=E,t[42]=D,t[43]=L,t[44]=R):R=t[44],R});function Mt(e=``,t=``){return{clientKey:crypto.randomUUID(),key:e,value:t}}var Nt=/^([^:=]+)[:=](.*)$/;function Pt(e){let t=e.trim();if(!t)return null;try{let e=JSON.parse(t);if(e&&typeof e==`object`&&!Array.isArray(e))return It(e)}catch{}let n=[];for(let e of t.split(/\r?\n/)){let t=e.trim();if(!t)continue;let r=Nt.exec(t);r&&n.push(Mt(r[1].trim(),r[2].trim()))}return n.length>0?n:null}function Ft(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 It(e){if(!e||typeof e!=`object`)return[Mt()];let t=Object.entries(e).map(([e,t])=>typeof t==`object`&&t&&!Array.isArray(t)?{...Mt(e),reference:t}:Mt(e,t==null?``:String(t)));return t.length>0?t:[Mt()]}function Lt(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 Rt(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 zt(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 Bt(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=Rt(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=Ft(e.envEntries);r&&(t.env=r)}else e.envJson.trim()&&(t.env=zt(e.envJson));delete t.oauth,delete t.auth}else{t.type=`http`,t.url=e.url.trim();let n=Ft(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 Vt(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:It(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 Ht(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 Ut(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 Wt(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=Vt(e,n);return r.clientKey=crypto.randomUUID(),r.url&&=Ut(r.url),r})}function Gt(e=``){return{clientKey:crypto.randomUUID(),id:e,transport:`streamable-http`,command:``,argsText:``,envJson:``,cwd:``,url:``,headers:[],oauthClientId:``,timeout:void 0,exposure:`codemode`,extra:{}}}function Kt(e){let t=e?.mcp?.servers??{};return{servers:Object.entries(t).filter(([,e])=>!Lt(e)).map(([e,t])=>Vt(e,t)).sort((e,t)=>e.id.localeCompare(t.id))}}function qt(e){return Bt(e)}async function Jt(e,t){return(await l(o(`/api/mcp/servers/${encodeURIComponent(e)}/tools`),{method:`POST`,signal:AbortSignal.any([t,AbortSignal.timeout(95e3)])})).payload.tools}async function Yt(e,t,n,r){return(await l(o(`/api/mcp/drafts`),{method:`POST`,signal:r,body:JSON.stringify({serverId:e.id,sourceServerId:t,expectedServer:n,server:Bt(e)})})).payload}async function Xt(e,t){return(await l(o(`/api/mcp/drafts/${encodeURIComponent(e)}/probe`),{method:`POST`,signal:AbortSignal.any([t,AbortSignal.timeout(95e3)])})).payload}async function Zt(e){await l(o(`/api/mcp/drafts/${encodeURIComponent(e)}`),{method:`DELETE`})}async function Qt(e,t=!1){let n=await l(o(`/api/mcp/drafts/${encodeURIComponent(e)}/commit`),{method:`POST`,body:JSON.stringify({enable:t})});return _e(),n.payload}async function $t(e){return(await l(o(`/api/mcp/drafts/${encodeURIComponent(e)}/auth`),{method:`POST`})).payload}async function en(e,t){return(await l(o(`/api/mcp/drafts/${encodeURIComponent(e)}/auth`),{signal:t})).payload}async function tn(e){await l(o(`/api/mcp/drafts/${encodeURIComponent(e)}/auth`),{method:`DELETE`})}async function nn(e,t){await l(o(`/api/mcp/drafts/${encodeURIComponent(e)}/auth/redirect`),{method:`POST`,body:JSON.stringify({url:t})})}async function rn(e,t){return(await l(o(`/api/mcp/drafts/${encodeURIComponent(e)}/tools`),{signal:t})).payload.tools}async function an(e){let t=await l(o(`/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 on(e){let t=await l(o(`/api/mcp/servers/${encodeURIComponent(e.id)}`),{method:`DELETE`,body:JSON.stringify({expectedServer:e.extra})});return _e(),t.payload}function sn(e){let t=(0,ft.c)(111),{serverId:n,displayName:r,returnFocusTo:i,draftId:a,t:o,onClose:s,onConfigure:c}=e,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=[],t[0]=l):l=t[0];let[u,d]=(0,Q.useState)(l),[f,p]=(0,Q.useState)(!0),[m,h]=(0,Q.useState)(``),[g,_]=(0,Q.useState)(``),[v,y]=(0,Q.useState)(0),b=(0,Q.useRef)(!1),x;t[1]!==a||t[2]!==n||t[3]!==o.setupAccessDenied||t[4]!==o.setupConflict||t[5]!==o.setupGatewayUnauthorized||t[6]!==o.setupRateLimited||t[7]!==o.toolsLoadFailed?(x=()=>{let e=new AbortController,t=!0;return p(!0),h(``),d([]),(a?rn(a,e.signal):Jt(n,e.signal)).then(e=>{t&&d(e)}).catch(e=>{let n=e?.status;t&&h(n===401?o.setupGatewayUnauthorized:n===403?o.setupAccessDenied:n===429?o.setupRateLimited:n===404||n===409?o.setupConflict:o.toolsLoadFailed)}).finally(()=>{t&&p(!1)}),()=>{t=!1,e.abort()}},t[1]=a,t[2]=n,t[3]=o.setupAccessDenied,t[4]=o.setupConflict,t[5]=o.setupGatewayUnauthorized,t[6]=o.setupRateLimited,t[7]=o.toolsLoadFailed,t[8]=x):x=t[8];let S;t[9]!==a||t[10]!==v||t[11]!==n||t[12]!==o?(S=[n,a,v,o],t[9]=a,t[10]=v,t[11]=n,t[12]=o,t[13]=S):S=t[13],(0,Q.useEffect)(x,S);let C,w,T,E,D,O,k,A,j,M,N,P,F;if(t[14]!==r||t[15]!==m||t[16]!==f||t[17]!==s||t[18]!==c||t[19]!==g||t[20]!==i||t[21]!==n||t[22]!==o.exposureLabels||t[23]!==o.setupConfigure||t[24]!==o.toolDetails||t[25]!==o.toolsClearSearch||t[26]!==o.toolsDialogSearchEmpty||t[27]!==o.toolsDialogSearchPlaceholder||t[28]!==o.toolsDialogSubtitle||t[29]!==o.toolsDialogTitle||t[30]!==o.toolsEmpty||t[31]!==o.toolsLoading||t[32]!==o.toolsRetryHint||t[33]!==o.toolsSearchSummary||t[34]!==o.toolsTitle||t[35]!==u){let e=g.trim().toLowerCase(),a;if(t[49]!==n){let e;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(e=/-/g,t[51]=e):e=t[51],a=n.replace(e,`_`),t[49]=n,t[50]=a}else a=t[50];let l=`mcp__${a}__`,d=u.filter(t=>`${t.name} ${t.description}`.toLowerCase().includes(e));T=fe,O=!0,t[52]===s?k=t[53]:(k=e=>{e||s()},t[52]=s,t[53]=k),w=le,t[54]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,$.jsx)(oe,{className:`fixed inset-0 z-[60] bg-scrim`}),t[54]=D):D=t[54],C=ue,t[55]===i?P=t[56]:(P=e=>{(b.current||i)&&e.preventDefault(),!b.current&&i?.isConnected&&i.focus()},t[55]=i,t[56]=P),F=`fixed left-1/2 top-1/2 z-[60] flex h-[min(42rem,calc(100dvh-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 p;t[57]===o.toolsDialogTitle?p=t[58]:(p=(0,$.jsx)(de,{className:`font-semibold`,children:o.toolsDialogTitle}),t[57]=o.toolsDialogTitle,t[58]=p);let h;t[59]!==r||t[60]!==m||t[61]!==f||t[62]!==n||t[63]!==o.toolsDialogSubtitle||t[64]!==u.length?(h=f||m?r||n:o.toolsDialogSubtitle.replace(`{{serverId}}`,r||n).replace(`{{count}}`,String(u.length)),t[59]=r,t[60]=m,t[61]=f,t[62]=n,t[63]=o.toolsDialogSubtitle,t[64]=u.length,t[65]=h):h=t[65];let v;t[66]===h?v=t[67]:(v=(0,$.jsx)(se,{className:`mt-1 break-words text-sm text-fg-muted`,children:h}),t[66]=h,t[67]=v);let y;t[68]===Symbol.for(`react.memo_cache_sentinel`)?(y=e=>_(e.target.value),t[68]=y):y=t[68];let x;t[69]!==g||t[70]!==o.toolsDialogSearchPlaceholder?(x=(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:g,onChange:y,placeholder:o.toolsDialogSearchPlaceholder,"aria-label":o.toolsDialogSearchPlaceholder}),t[69]=g,t[70]=o.toolsDialogSearchPlaceholder,t[71]=x):x=t[71];let S=e&&!f&&!m?(0,$.jsx)(`p`,{role:`status`,className:`mt-2 text-xs text-fg-muted`,children:o.toolsSearchSummary.replace(`{{visible}}`,String(d.length)).replace(`{{count}}`,String(u.length))}):null;t[72]!==p||t[73]!==v||t[74]!==x||t[75]!==S?(E=(0,$.jsxs)(`div`,{className:`shrink-0 border-b border-edge p-5`,children:[p,v,x,S]}),t[72]=p,t[73]=v,t[74]=x,t[75]=S,t[76]=E):E=t[76],A=`min-h-0 flex-1 overflow-y-auto p-5`,j=f,t[77]!==o.toolsTitle||t[78]!==u.length?(M=o.toolsTitle.replace(`{{count}}`,String(u.length)),t[77]=o.toolsTitle,t[78]=u.length,t[79]=M):M=t[79],N=f?(0,$.jsx)(`div`,{role:`status`,"aria-label":o.toolsLoading,className:`space-y-3`,children:[0,1,2].map(ln)}):m?(0,$.jsxs)(`div`,{role:`alert`,className:`space-y-3`,children:[(0,$.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-sm text-danger`,children:m}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:o.toolsRetryHint}),c?(0,$.jsx)(X,{variant:`secondary`,onClick:()=>{b.current=!0,c()},children:o.setupConfigure}):null]}):d.length?(0,$.jsx)(`div`,{className:`space-y-3`,children:d.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.startsWith(l)?e.name.slice(l.length):e.name}),e.exposure&&Object.hasOwn(o.exposureLabels,e.exposure)?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:o.exposureLabels[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:o.toolDetails}),(0,$.jsx)(`p`,{className:`mt-2 break-all font-mono text-xs text-fg-muted`,children:e.name}),(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,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:u.length?o.toolsDialogSearchEmpty:o.toolsEmpty}),e?(0,$.jsx)(X,{variant:`secondary`,onClick:()=>_(``),children:o.toolsClearSearch}):null]}),t[14]=r,t[15]=m,t[16]=f,t[17]=s,t[18]=c,t[19]=g,t[20]=i,t[21]=n,t[22]=o.exposureLabels,t[23]=o.setupConfigure,t[24]=o.toolDetails,t[25]=o.toolsClearSearch,t[26]=o.toolsDialogSearchEmpty,t[27]=o.toolsDialogSearchPlaceholder,t[28]=o.toolsDialogSubtitle,t[29]=o.toolsDialogTitle,t[30]=o.toolsEmpty,t[31]=o.toolsLoading,t[32]=o.toolsRetryHint,t[33]=o.toolsSearchSummary,t[34]=o.toolsTitle,t[35]=u,t[36]=C,t[37]=w,t[38]=T,t[39]=E,t[40]=D,t[41]=O,t[42]=k,t[43]=A,t[44]=j,t[45]=M,t[46]=N,t[47]=P,t[48]=F}else C=t[36],w=t[37],T=t[38],E=t[39],D=t[40],O=t[41],k=t[42],A=t[43],j=t[44],M=t[45],N=t[46],P=t[47],F=t[48];let I;t[80]!==A||t[81]!==j||t[82]!==M||t[83]!==N?(I=(0,$.jsx)(`div`,{className:A,"aria-busy":j,"aria-label":M,children:N}),t[80]=A,t[81]=j,t[82]=M,t[83]=N,t[84]=I):I=t[84];let L;t[85]===Symbol.for(`react.memo_cache_sentinel`)?(L=()=>y(cn),t[85]=L):L=t[85];let R;t[86]!==f||t[87]!==o.refreshTools?(R=(0,$.jsx)(X,{variant:`secondary`,disabled:f,onClick:L,children:o.refreshTools}),t[86]=f,t[87]=o.refreshTools,t[88]=R):R=t[88];let z;t[89]!==s||t[90]!==o.toolsDialogClose?(z=(0,$.jsx)(ce,{asChild:!0,children:(0,$.jsx)(X,{onClick:s,children:o.toolsDialogClose})}),t[89]=s,t[90]=o.toolsDialogClose,t[91]=z):z=t[91];let B;t[92]!==R||t[93]!==z?(B=(0,$.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge p-4`,children:[R,z]}),t[92]=R,t[93]=z,t[94]=B):B=t[94];let V;t[95]!==C||t[96]!==E||t[97]!==I||t[98]!==B||t[99]!==P||t[100]!==F?(V=(0,$.jsxs)(C,{onCloseAutoFocus:P,className:F,children:[E,I,B]}),t[95]=C,t[96]=E,t[97]=I,t[98]=B,t[99]=P,t[100]=F,t[101]=V):V=t[101];let H;t[102]!==w||t[103]!==D||t[104]!==V?(H=(0,$.jsxs)(w,{children:[D,V]}),t[102]=w,t[103]=D,t[104]=V,t[105]=H):H=t[105];let U;return t[106]!==T||t[107]!==O||t[108]!==k||t[109]!==H?(U=(0,$.jsx)(T,{open:O,onOpenChange:k,children:H}),t[106]=T,t[107]=O,t[108]=k,t[109]=H,t[110]=U):U=t[110],U}function cn(e){return e+1}function ln(e){return(0,$.jsx)(Z,{className:`h-24 w-full`},e)}function un(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 dn({row:e,lastCheck:t,t:n,cs:r,onEdit:i,onRemove:a}){let o=c(e=>e.language),[s,l]=(0,Q.useState)(!1),u=(0,Q.useRef)(null),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(``),h=e.displayName||e.id,g=un(e),_=e.extra.enabled===!1,v=_?S:t?x:O,y=e.transport===`stdio`?q:K,b=_?n.setupDisabled:t?r.customCheckSucceeded:r.customUnchecked,C=t?new Intl.DateTimeFormat(o,{dateStyle:`medium`,timeStyle:`short`}).format(new Date(t.checkedAt)):null;return(0,$.jsxs)(`li`,{className:`flex min-h-[8.75rem] min-w-0 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`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,$.jsx)(`div`,{title:n.transportLabels[e.transport],className:`flex size-9 shrink-0 items-center justify-center rounded-xl border border-edge-subtle bg-surface-inset text-fg-muted`,children:(0,$.jsx)(y,{className:`size-4`,"aria-hidden":!0})}),(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-col items-start gap-1`,children:[(0,$.jsx)(`h3`,{className:`min-w-0 max-w-full text-sm font-semibold text-fg`,children:(0,$.jsx)(`button`,{type:`button`,onClick:i,title:h,className:`block max-w-full truncate rounded text-left hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:h})}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1 text-[11px]`,children:[(0,$.jsxs)(`span`,{title:C?r.customLastChecked.replace(`{{time}}`,C):void 0,"aria-label":C?`${b} · ${r.customLastChecked.replace(`{{time}}`,C)}`:b,className:Y(`inline-flex shrink-0 items-center gap-1`,!_&&t?`text-emerald-700 dark:text-emerald-300`:`text-fg-muted`),children:[(0,$.jsx)(v,{className:`size-3.5`,"aria-hidden":!0}),b]}),t?(0,$.jsx)(`span`,{className:`text-fg-muted`,children:r.customToolCount.replace(`{{count}}`,String(t.toolCount))}):null]})]})})]}),(0,$.jsx)(`p`,{title:g,className:`mt-2 truncate font-mono text-xs leading-5 text-fg-muted`,children:g})]}),(0,$.jsxs)(`div`,{className:`mt-2 flex shrink-0 items-center gap-1`,children:[(0,$.jsx)(`span`,{className:`mr-auto text-[11px] text-fg-subtle`,children:n.transportLabels[e.transport]}),(0,$.jsx)(X,{variant:`ghost`,className:`h-8 px-2 py-1 text-xs`,onClick:i,children:n.setupConfigure}),(0,$.jsx)(X,{ref:u,variant:`secondary`,className:`h-8 px-2 py-1 text-xs shadow-none sm:shadow-none`,disabled:_,onClick:()=>l(!0),children:n.viewTools}),(0,$.jsxs)(tt,{children:[(0,$.jsx)(nt,{asChild:!0,children:(0,$.jsx)(X,{variant:`ghost`,className:`size-8 p-0`,"aria-label":r.customManage.replace(`{{name}}`,h),title:r.customManage.replace(`{{name}}`,h),children:(0,$.jsx)(A,{className:`size-4`,"aria-hidden":!0})})}),(0,$.jsx)(rt,{children:(0,$.jsx)(at,{align:`end`,sideOffset:6,className:`z-50 min-w-36 rounded-xl border border-edge bg-surface-overlay p-1 shadow-popover`,children:(0,$.jsxs)(it,{onSelect:()=>f(!0),className:`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-danger outline-none data-[highlighted]:bg-surface-hover`,children:[(0,$.jsx)(ie,{className:`size-4`,"aria-hidden":!0}),n.removeServer]})})})]})]}),p?(0,$.jsx)(`p`,{role:`alert`,className:`mt-2 text-sm text-danger`,children:p}):null,s?(0,$.jsx)(sn,{serverId:e.id,displayName:e.displayName,returnFocusTo:u.current,t:n,onClose:()=>l(!1),onConfigure:()=>{l(!1),i()}}):null,(0,$.jsx)(et,{open:d,title:r.removeConfirmTitle.replace(`{{name}}`,h),description:r.removeConfirmDescription,confirmLabel:n.removeServer,cancelLabel:r.modalCancel,destructive:!0,onCancel:()=>f(!1),onConfirm:()=>{f(!1),m(``),a().catch(()=>m(n.setupRemoveFailed))}})]})}function fn(e){let t=(0,ft.c)(30),{servers:n,lastChecks:r,t:i,cs:a,onAdd:o,onEdit:s,onRemove:c}=e,l;t[0]===a.customIntegrationsTitle?l=t[1]:(l=(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:a.customIntegrationsTitle}),t[0]=a.customIntegrationsTitle,t[1]=l);let u;t[2]===n.length?u=t[3]:(u=(0,$.jsx)(`span`,{className:`rounded-md bg-surface-inset px-1.5 py-0.5 text-xs tabular-nums text-fg-muted`,children:n.length}),t[2]=n.length,t[3]=u);let d;t[4]!==l||t[5]!==u?(d=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[l,u]}),t[4]=l,t[5]=u,t[6]=d):d=t[6];let f;t[7]===a.customIntegrationsHint?f=t[8]:(f=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:a.customIntegrationsHint}),t[7]=a.customIntegrationsHint,t[8]=f);let p;t[9]!==d||t[10]!==f?(p=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[d,f]}),t[9]=d,t[10]=f,t[11]=p):p=t[11];let m;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(W,{className:`size-3.5`,"aria-hidden":!0}),t[12]=m):m=t[12];let h;t[13]!==a.customAdd||t[14]!==o?(h=(0,$.jsxs)(X,{variant:`secondary`,className:`shrink-0 text-xs shadow-none sm:shadow-none`,onClick:o,children:[m,a.customAdd]}),t[13]=a.customAdd,t[14]=o,t[15]=h):h=t[15];let g;t[16]!==p||t[17]!==h?(g=(0,$.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center justify-between gap-3`,children:[p,h]}),t[16]=p,t[17]=h,t[18]=g):g=t[18];let _;t[19]!==a||t[20]!==r||t[21]!==s||t[22]!==c||t[23]!==n||t[24]!==i?(_=n.length?(0,$.jsx)(`ul`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:n.map(e=>(0,$.jsx)(dn,{row:e,lastCheck:r[e.id],t:i,cs:a,onEdit:()=>s(e),onRemove:()=>c(e)},e.clientKey))}):(0,$.jsx)(`p`,{className:`rounded-xl border border-dashed border-edge px-5 py-8 text-center text-sm text-fg-muted`,children:a.customEmpty}),t[19]=a,t[20]=r,t[21]=s,t[22]=c,t[23]=n,t[24]=i,t[25]=_):_=t[25];let v;return t[26]!==a.customIntegrationsTitle||t[27]!==g||t[28]!==_?(v=(0,$.jsxs)(`section`,{"aria-label":a.customIntegrationsTitle,children:[g,_]}),t[26]=a.customIntegrationsTitle,t[27]=g,t[28]=_,t[29]=v):v=t[29],v}function pn(e){return e.format===`agent-plugin`&&!!e.pluginId&&(!!e.setup?.authorizations?.length||e.authorizationStatus===`required`||!!e.components?.mcp.some(e=>e.type!==`stdio`))}function mn(e){let t=(0,ft.c)(54),{extension:n,language:r,onOpen:i}=e,a;t[0]===r?a=t[1]:(a=r.startsWith(`zh`),t[0]=r,t[1]=a);let o=a,s;t[2]===o?s=t[3]:(s=(e,t)=>o?e:t,t[2]=o,t[3]=s);let c=s,l=n.installationState===`preparing`,u=n.activationEligible===!1,d=n.authorizationStatus===`required`,f;t[4]!==u||t[5]!==n.readiness||t[6]!==d||t[7]!==l||t[8]!==c?(f=l?c(`准备未完成`,`Setup incomplete`):u?c(`已停用`,`Disabled`):d?c(`需要授权`,`Authorization required`):n.readiness===`blocked`||n.readiness===`degraded`?c(`需要处理`,`Needs attention`):c(`已连接`,`Connected`),t[4]=u,t[5]=n.readiness,t[6]=d,t[7]=l,t[8]=c,t[9]=f):f=t[9];let p=f,m;t[10]!==u||t[11]!==d||t[12]!==l||t[13]!==c?(m=l?c(`继续安装`,`Continue setup`):!u&&d?c(`去授权`,`Connect account`):c(`查看详情`,`View details`),t[10]=u,t[11]=d,t[12]=l,t[13]=c,t[14]=m):m=t[14];let h=m,_;t[15]===n.setup?.authorizations?_=t[16]:(_=n.setup?.authorizations??[],t[15]=n.setup?.authorizations,t[16]=_);let v=_,y=v.length===1?v[0].title:n.name,C=l||!u&&(d||n.readiness===`blocked`||n.readiness===`degraded`),w=l?O:u?S:C?b:x,T=C&&`border-amber-500/25`,E;t[17]===T?E=t[18]:(E=Y(`flex min-h-[8.75rem] w-full min-w-0 flex-col rounded-xl border border-edge bg-surface-panel p-4 text-left transition-colors hover:bg-surface-hover/45 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,T),t[17]=T,t[18]=E);let D=n.branding?.iconUrl,k;t[19]===D?k=t[20]:(k=(0,$.jsx)(st,{iconUrl:D,fallback:ee,className:`size-9`}),t[19]=D,t[20]=k);let A;t[21]===y?A=t[22]:(A=(0,$.jsx)(`span`,{className:`block truncate text-sm font-semibold text-fg`,title:y,children:y}),t[21]=y,t[22]=A);let j=C?`text-amber-700 dark:text-amber-300`:u?`text-fg-muted`:`text-emerald-700 dark:text-emerald-300`,M;t[23]===j?M=t[24]:(M=Y(`mt-1 inline-flex items-center gap-1 text-[11px]`,j),t[23]=j,t[24]=M);let N;t[25]===w?N=t[26]:(N=(0,$.jsx)(w,{className:`size-3.5`,"aria-hidden":!0}),t[25]=w,t[26]=N);let P;t[27]!==p||t[28]!==M||t[29]!==N?(P=(0,$.jsxs)(`span`,{className:M,children:[N,p]}),t[27]=p,t[28]=M,t[29]=N,t[30]=P):P=t[30];let F;t[31]!==A||t[32]!==P?(F=(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[A,P]}),t[31]=A,t[32]=P,t[33]=F):F=t[33];let I;t[34]!==F||t[35]!==k?(I=(0,$.jsxs)(`span`,{className:`flex w-full min-w-0 items-start gap-3`,children:[k,F]}),t[34]=F,t[35]=k,t[36]=I):I=t[36];let L=n.name,R;t[37]===c?R=t[38]:(R=c(`由插件提供`,`Provided by plugin`),t[37]=c,t[38]=R);let z;t[39]!==n.name||t[40]!==R?(z=(0,$.jsxs)(`span`,{className:`mt-2 block w-full truncate text-xs leading-5 text-fg-muted`,title:L,children:[R,` · `,n.name]}),t[39]=n.name,t[40]=R,t[41]=z):z=t[41];let B=C?`text-accent-fg`:`text-fg-muted`,V;t[42]===B?V=t[43]:(V=Y(`mt-auto flex w-full items-center justify-end gap-1 pt-2 text-xs`,B),t[42]=B,t[43]=V);let H;t[44]===Symbol.for(`react.memo_cache_sentinel`)?(H=(0,$.jsx)(g,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[44]=H):H=t[44];let U;t[45]!==h||t[46]!==V?(U=(0,$.jsxs)(`span`,{className:V,children:[h,H]}),t[45]=h,t[46]=V,t[47]=U):U=t[47];let W;return t[48]!==i||t[49]!==I||t[50]!==z||t[51]!==U||t[52]!==E?(W=(0,$.jsxs)(`button`,{type:`button`,onClick:i,className:E,children:[I,z,U]}),t[48]=i,t[49]=I,t[50]=z,t[51]=U,t[52]=E,t[53]=W):W=t[53],W}function hn(e){let t=e.connectedAt?Date.parse(e.connectedAt):0;return Number.isFinite(t)?t:0}function gn(e,t){return e.status===`active`&&t.status!==`active`?-1:e.status!==`active`&&t.status===`active`?1:e.isCurrentAuthorization===t.isCurrentAuthorization?hn(t)-hn(e):e.isCurrentAuthorization?-1:1}function _n(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(gn);return{key:e,primary:n[0],authorizations:n}}).sort((e,t)=>gn(e.primary,t.primary))}var vn=Y(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,Ye);function yn(e){return e.materialized.type===`composio`?e.materialized.toolkit:null}function bn(e,t){return e===`write`?t.composioScopeWrite:e===`admin`?t.composioScopeAdmin:t.composioScopeRead}function xn(e,t,n){return e.status===`connected`?I(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 Sn(e,t){return e===`active`?t.composioConnectionHealthy:e===`pending`?t.composioConnectionPending:e===`expired`?t.composioConnectionExpired:e===`failed`?t.composioConnectionFailed:e===`revoked`||e===`disabled`?t.composioConnectionRevoked:t.composioConnectionUnknown}function Cn(e,t,n){return e.status===`paused`?t?.scanEnabled===!1?n.connectorLearningPausedByPolicy:n.connectorLearningPausedByFailure:e.status===`queued`?n.connectorLearningQueued:e.status===`running`?n.connectorLearningRunning:e.status===`completed`?n.connectorLearningCompleted:n.connectorLearningFailed}function wn({instance:e,t,onChanged:n}){let r=yn(e),i=c(e=>e.language)===`zh`,[a,o]=(0,Q.useState)([]),[s,l]=(0,Q.useState)([]),[u,d]=(0,Q.useState)([]),[f,p]=(0,Q.useState)(null),[m,h]=(0,Q.useState)([]),[g,y]=(0,Q.useState)(null),[S,C]=(0,Q.useState)(null),[w,T]=(0,Q.useState)([]),[E,D]=(0,Q.useState)({}),[O,k]=(0,Q.useState)(`read`),[A,j]=(0,Q.useState)(!1),[M,N]=(0,Q.useState)(null),[L,R]=(0,Q.useState)(!1),[z,B]=(0,Q.useState)(null),[H,U]=(0,Q.useState)(null),[ee,W]=(0,Q.useState)(!1),[G,K]=(0,Q.useState)(!1),[ne,re]=(0,Q.useState)(!1),q=(0,Q.useRef)(0),J=(0,Q.useRef)(0),ae=(0,Q.useMemo)(()=>_n(a),[a]),oe=(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]),se=(0,Q.useCallback)(async()=>{if(!r||e.materialized.type!==`composio`||e.materialized.role===`credential`)return;j(!0),N(null);let t=++q.current;try{let e=(await Promise.allSettled([oe(Ae()).then(e=>{t===q.current&&(o(e.filter(e=>e.toolkit.toLowerCase()===r.toLowerCase())),W(!0))}),oe(Ne(r)).then(e=>{t===q.current&&k(e)}),oe(Ue(r)).then(e=>{t===q.current&&(p(e.policy),h(e.agents))})])).find(e=>e.status===`rejected`);t===q.current&&e?.status===`rejected`&&N(String(e.reason instanceof Error?e.reason.message:e.reason))}finally{t===q.current&&j(!1)}},[e.materialized,r,oe]);(0,Q.useEffect)(()=>(se(),()=>{q.current++}),[se]);let ce=(0,Q.useCallback)(async()=>{if(!r)return;let e=++J.current;re(!0),R(!1);let t=t=>n=>{e===J.current&&t(n)},n=await Promise.allSettled([oe(We(r)).then(t(l)),oe(qe(20)).then(t(e=>d(e.filter(e=>!e.toolkit||e.toolkit.toLowerCase()===r.toLowerCase())))),oe(Be(r)).then(t(C)),oe(Ie(r)).then(t(y))]);e===J.current&&(R(n.some(e=>e.status===`rejected`)),re(!1))},[r,oe]);(0,Q.useEffect)(()=>(G&&ce(),()=>{J.current++}),[G,ce]),(0,Q.useEffect)(()=>{let e=!1,t=_n(a).map(e=>e.primary).filter(e=>e.supportsLearning&&e.accountId);if(t.length)return oe(Ke()).then(t=>{e||T(t)}).catch(()=>{}),Promise.allSettled(t.map(async e=>[e.accountId,await oe(Le(e.accountId))])).then(t=>{e||D(Object.fromEntries(t.flatMap(e=>e.status===`fulfilled`?[e.value]:[])))}),()=>{e=!0}},[a,oe]);let le=(0,Q.useCallback)(async i=>{if(!r)return;let a=Xe()?null:window.open(`about:blank`,`_blank`);a&&(a.opener=null),j(!0),N(null);try{if(!Xe()&&!a)throw Error(`Allow popups to open the authorization page.`);let t=await Fe(e.connectorId,i);if(!t.authorizationUrl)throw Error(`The authorization provider did not return an authorization URL.`);if(Xe()){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 Je(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?.(),se()])}catch(e){N(V(e,t))}finally{a?.close(),j(!1)}},[e.connectorId,se,n,t,r]),ue=(0,Q.useCallback)(async t=>{j(!0),N(null);try{await Ce(e.instanceId,{config:{...e.config??{},authConfigId:t||void 0}}),await Promise.all([n?.(),se()])}catch(e){N(e instanceof Error?e.message:String(e))}finally{j(!1)}},[e.config,e.instanceId,se,n]),de=async e=>{let t=Xe()?null:window.open(`about:blank`,`_blank`);t&&(t.opener=null),N(null);try{let n=await Me(e.id);if(n.authorizationUrl)if(Xe())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 se()}catch(e){t?.close(),N(e instanceof Error?e.message:String(e))}},fe=(0,Q.useCallback)(async e=>{if(r){k(e),N(null);try{await Ee(r,e)}catch(e){N(e instanceof Error?e.message:String(e)),await se()}}},[se,r]),pe=(0,Q.useCallback)(async e=>{if(r){N(null);try{p(await Se(r,e))}catch(e){N(e instanceof Error?e.message:String(e))}}},[r]),me=(0,Q.useCallback)(e=>{if(!f)return;let t=f.allowedAgentIds.includes(e);if(t&&f.allowedAgentIds.length===1)return;let n=t?f.allowedAgentIds.filter(t=>t!==e):[...f.allowedAgentIds,e];pe({allowedAgentIds:n})},[pe,f]),he=(0,Q.useCallback)(async e=>{j(!0),N(null);try{await e(),await se()}catch(e){N(e instanceof Error?e.message:String(e))}finally{j(!1)}},[se]);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 ge=ae.filter(e=>e.primary.status===`active`).length,_e=ge>0?t.composioAddAccount:t.composioConnectAccount,ve=ee&&ge>0,we=S?.requiresCustomAuthConfig===!0,Te=S?.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:Y(`inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-xs font-medium`,ve?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-amber-500/10 text-amber-700 dark:text-amber-300`),children:[ve?(0,$.jsx)(x,{className:`size-3.5`}):(0,$.jsx)(b,{className:`size-3.5`}),ve?t.connectionReady:ee||M?t.connectionNeedsSetup:t.connectionChecking]}),ee&&(0,$.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:I(t.composioAccountCount,{count:String(ae.length)})})]}),(0,$.jsxs)(X,{variant:`primary`,className:`shrink-0`,disabled:A,onClick:()=>void le(),children:[A?(0,$.jsx)(F,{className:`size-4 animate-spin`}):(0,$.jsx)(P,{className:`size-4`}),_e]})]}),M?(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:M}),(0,$.jsx)(X,{variant:`secondary`,disabled:A,onClick:()=>void se(),children:t.composioRetry})]}):null,g&&!ve?(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:xn(g,ge,t)}),g.recovery===`none`?null:(0,$.jsx)(X,{variant:`secondary`,disabled:A,onClick:()=>void(g.recovery===`retry`?se():le()),children:g.recovery===`retry`?t.composioRetry:t.composioReconnectAccount})]}):null,we&&Te.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,f?(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:O===`read`?t.composioAccessReadHint:O===`admin`?t.composioAccessAdminHint:t.composioAccessWriteHint})]}),(0,$.jsxs)(_,{value:O,onChange:e=>void fe(e.currentTarget.value),children:[(0,$.jsx)(v,{value:`read`,children:t.composioAccessReadOnly}),(0,$.jsx)(v,{value:`write`,children:t.composioAccessReadWrite}),O===`admin`?(0,$.jsx)(v,{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)(_,{value:f.confirmationPolicy,onChange:e=>void pe({confirmationPolicy:e.currentTarget.value}),children:[(0,$.jsx)(v,{value:`writes`,children:t.composioConfirmWrites}),(0,$.jsx)(v,{value:`always`,children:t.composioConfirmAlways}),f.confirmationPolicy===`never`?(0,$.jsx)(v,{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:f.allowedAgentIds.length?t.composioAllowedAgentsSelected:t.composioAllowedAgentsAll}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,$.jsx)(`button`,{type:`button`,className:Y(`rounded-full border px-2.5 py-1 text-xs transition-colors`,f.allowedAgentIds.length===0?`border-accent bg-accent/10 text-accent`:`border-edge bg-surface-panel text-fg-muted hover:text-fg`),onClick:()=>void pe({allowedAgentIds:[]}),children:t.composioAllowedAgentsAllOption}),m.map(e=>(0,$.jsx)(`button`,{type:`button`,className:Y(`rounded-full border px-2.5 py-1 text-xs transition-colors`,f.allowedAgentIds.includes(e.id)?`border-accent bg-accent/10 text-accent`:`border-edge bg-surface-panel text-fg-muted hover:text-fg`),onClick:()=>me(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:f.selectedAccountIds===null,disabled:A,onChange:e=>void pe({selectedAccountIds:e.currentTarget.checked?null:[]})}),i?`所有账号(包括以后新增)`:`All accounts, including new ones`]}),f.selectedAccountIds!==null&&ae.map(({primary:e})=>e.accountId&&(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,disabled:A,checked:f.selectedAccountIds.includes(e.accountId),onChange:t=>void pe({selectedAccountIds:t.currentTarget.checked?[...f.selectedAccountIds,e.accountId]:f.selectedAccountIds.filter(t=>t!==e.accountId)})}),e.alias??e.accountEmail??e.accountId]},e.accountId)),f.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}),ee&&(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:I(t.composioAccountCount,{count:String(ae.length)})})]}),(0,$.jsxs)(X,{variant:`ghost`,className:`h-8 px-2 text-xs`,disabled:A,onClick:()=>void se(),children:[(0,$.jsx)(te,{className:Y(`size-3.5`,A&&`animate-spin`)}),t.refresh]})]}),ae.length?(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-xl border border-edge bg-surface-base`,children:ae.map(e=>{let r=e.primary,a=w.find(e=>r.accountId?e.accountId===r.accountId:e.connectionId===r.id),o=r.accountId?E[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:Y(`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`:Sn(r.status,t)}),a?(0,$.jsx)(`p`,{className:Y(`mt-1 text-xs`,a.status===`failed`?`text-red-600`:`text-fg-subtle`),children:I(t.connectorLearningStatus,{status:Cn(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)(X,{variant:`secondary`,className:`h-8 px-2.5 text-xs`,onClick:()=>void de(r),children:i?`继续授权`:`Continue authorization`}),r.accountId&&(0,$.jsx)(X,{variant:`ghost`,className:`h-8 px-2.5 text-xs text-danger`,disabled:A,onClick:()=>U(r.accountId),children:i?`断开`:`Disconnect`}),r.accountId&&r.status!==`active`&&(0,$.jsx)(X,{variant:`secondary`,className:`h-8 px-2.5 text-xs`,disabled:A,onClick:()=>void le(r.accountId),children:t.composioReconnectAccount}),r.accountId&&(0,$.jsx)(X,{variant:`secondary`,className:`h-8 px-2.5 text-xs`,disabled:A,onClick:()=>void he(()=>De(r.accountId,{enabled:r.accountEnabled===!1})),children:r.accountEnabled===!1?i?`启用`:`Enable`:i?`暂停`:`Pause`}),r.supportsLearning&&r.status===`active`&&r.accountEnabled!==!1?(0,$.jsxs)(X,{variant:`secondary`,className:`h-8 shrink-0 px-2.5 text-xs`,disabled:A,onClick:()=>void he(async()=>{if(!r.accountId)throw Error(`Connector account is unavailable.`);await ye(r.accountId),await n?.()}),children:[(0,$.jsx)(te,{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:A,checked:r.allowedAgentIds==null,onChange:e=>void he(()=>De(r.accountId,{allowedAgentIds:e.currentTarget.checked?null:[]}))}),t.composioAllowedAgentsAllOption]}),r.allowedAgentIds!=null&&m.map(e=>(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,disabled:A,checked:r.allowedAgentIds.includes(e.id),onChange:t=>{let n=t.currentTarget.checked;he(()=>De(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:A,onChange:e=>void he(()=>Oe(r.accountId,{scanEnabled:e.currentTarget.checked}))}),t.connectorScheduledScan]}),o.scanEnabled?(0,$.jsxs)(`label`,{className:`sm:col-span-2`,children:[t.connectorScanInterval,(0,$.jsxs)(_,{className:`mt-1`,value:String(o.intervalMinutes??30),disabled:A,onChange:e=>void he(()=>Oe(r.accountId,{intervalMinutes:Number(e.currentTarget.value)})),children:[(0,$.jsxs)(v,{value:`5`,children:[`5 `,t.connectorMinutes]}),(0,$.jsxs)(v,{value:`15`,children:[`15 `,t.connectorMinutes]}),(0,$.jsxs)(v,{value:`30`,children:[`30 `,t.connectorMinutes]}),(0,$.jsxs)(v,{value:`60`,children:[`60 `,t.connectorMinutes]})]})]}):null]}):null,(0,$.jsxs)(`label`,{className:`block`,children:[t.composioAccountAlias,(0,$.jsx)(`input`,{className:Y(vn,`mt-1 h-8 py-1 text-xs`),defaultValue:r.alias??``,onBlur:e=>{e.currentTarget.value!==(r.alias??``)&&he(()=>xe(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)(X,{variant:`ghost`,className:`size-7 shrink-0 p-0 text-danger`,title:t.composioRevoke,disabled:A,onClick:()=>B(e.id),children:(0,$.jsx)(ie,{className:`size-3.5`})})]},e.id))}),(0,$.jsx)(`div`,{className:`flex justify-end gap-1`,children:(0,$.jsx)(X,{variant:`ghost`,className:`size-8 p-0`,title:t.refresh,disabled:A,onClick:()=>void he(()=>ke(r.id)),children:(0,$.jsx)(te,{className:`size-4`})})})]})]})]},e.key)})}):A&&!ee?(0,$.jsxs)(`div`,{"aria-busy":`true`,"aria-label":t.connectionChecking,className:`space-y-3`,children:[(0,$.jsx)(Z,{className:`h-16 w-full`}),(0,$.jsx)(Z,{className:`h-16 w-full`})]}):ee?(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=>K(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:[ne?(0,$.jsx)(Z,{"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)(X,{variant:`ghost`,disabled:ne,onClick:()=>void ce(),children:t.composioRetry})]}):null,S?.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:we?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)(_,{className:`mt-3`,value:typeof e.config?.authConfigId==`string`?e.config.authConfigId:``,disabled:A,onChange:e=>void ue(e.currentTarget.value),children:[we?null:(0,$.jsx)(v,{value:``,children:t.composioAuthConfigManaged}),we&&typeof e.config?.authConfigId!=`string`?(0,$.jsx)(v,{value:``,disabled:!0,children:t.composioAuthConfigSelect}):null,Te.map(e=>(0,$.jsxs)(v,{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:s.length?s.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:[bn(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:u.length?u.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)(et,{open:H!==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=H;U(null),e&&he(()=>Re(e))},onCancel:()=>U(null)}),(0,$.jsx)(et,{open:z!==null,title:t.composioRevoke,description:t.composioRevokeConfirm,confirmLabel:t.composioRevoke,cancelLabel:t.modalCancel,destructive:!0,onConfirm:()=>{let e=z;B(null),e&&he(()=>be(e))},onCancel:()=>B(null)})]})}var Tn=Y(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,Ye);function En(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 Dn(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 On({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)(()=>En(t,e)),[_,v]=(0,Q.useState)(null),[y,b]=(0,Q.useState)(!1),[x,S]=(0,Q.useState)(null),C=t?.setup.config??[],w=(e.materialized.type===`mcp`||e.materialized.type===`memorySource`)&&C.length>0&&(t?.setup.secrets??[]).length===0,T=e.materialized.type===`mcp`,E=e.materialized.type===`composio`,D=e.materialized.type===`memorySource`,O=t?R(t,i):null,A=(0,Q.useCallback)(async()=>{b(!0),v(null);try{let t=await Te(e.instanceId);S(t),t.ok||v(t.error??t.action??i.healthStatusLabels[t.status]),await r()}catch(e){v(e instanceof Error?e.message:String(e))}finally{b(!1)}},[e.instanceId,r,i.healthStatusLabels]),j=(0,Q.useCallback)(async()=>{o(!0),v(null);try{await Ge(e.instanceId),await r(),n()}catch(e){v(e instanceof Error?e.message:String(e)),o(!1)}},[e.instanceId,r,n]),M=(0,Q.useCallback)(async()=>{if(!(!t||!w)){u(!0),v(null);try{let n={};for(let e of t.setup.config??[]){let t=Dn(e.type,h[e.key]??``);t!==void 0&&(n[e.key]=t)}await Ce(e.instanceId,{config:n}),await r()}catch(e){v(e instanceof Error?e.message:String(e))}finally{u(!1)}}},[h,t,e.instanceId,r,w]),N=(0,Q.useCallback)(async()=>{f(!0),m(null),v(null);try{let t=await we(e.connectorId);m(t.recordIds.length),await r()}catch(e){v(e instanceof Error?e.message:String(e))}finally{f(!1)}},[e.connectorId,r]);return(0,$.jsxs)(fe,{open:!0,onOpenChange:e=>{e||n()},children:[(0,$.jsxs)(le,{children:[(0,$.jsx)(oe,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(ue,{className:Y(`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`,E?`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)(z,{connector:t,size:`lg`}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(de,{className:`text-base font-semibold text-fg`,children:e.displayName}),(0,$.jsx)(se,{className:`mt-1 text-sm text-fg-muted`,children:O??(e.materialized.type===`mcp`?I(i.mcpServerRuntime,{serverId:e.materialized.serverId}):I(i.runtimeLabel,{runtime:e.materialized.type}))})]})]}),(0,$.jsx)(ce,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,className:Y(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,ge.focusRingPanel),"aria-label":i.modalClose,children:[(0,$.jsx)(ae,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`sr-only`,children:i.modalClose})]})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:[_?(0,$.jsx)(`p`,{className:`mb-4 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:_}):null,T?(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:x?.ok?I(i.toolsAvailable,{count:String(x.toolCount)}):x?i.healthStatusLabels[x.status]:e.usage.lastHealthStatus?i.healthStatusLabels[e.usage.lastHealthStatus]:i.healthNotTested}),(0,$.jsxs)(X,{variant:`secondary`,"aria-busy":y,disabled:y||!e.enabled,onClick:()=>void A(),children:[y?(0,$.jsx)(F,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(te,{className:`size-4`,"aria-hidden":!0}),i.test]})]}),w?C.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:Tn,value:h[e.key]??``,placeholder:e.placeholder,onChange:t=>g(n=>({...n,[e.key]:t.currentTarget.value}))})]},e.key)):null]}):null,E?(0,$.jsx)(wn,{instance:e,t:i,onChanged:r}):null,D?(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}),O?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:O}):null,p===null?null:(0,$.jsx)(`p`,{className:`mt-1 text-xs text-emerald-600`,children:I(i.connectedSourceSynced,{count:String(p)})})]}),(0,$.jsxs)(X,{disabled:d,onClick:()=>void N(),children:[d?(0,$.jsx)(F,{className:`size-4 animate-spin`}):(0,$.jsx)(k,{className:`size-4`}),i.composioSyncNow]})]}),w?(0,$.jsx)(`div`,{className:`grid gap-3 rounded-xl border border-edge bg-surface-base p-4`,children:C.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:Tn,value:h[e.key]??``,placeholder:e.placeholder,onChange:t=>g(n=>({...n,[e.key]:t.currentTarget.value}))})]},e.key))}):null]}):null,!T&&!E&&!D?(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)(X,{variant:`secondary`,className:`shrink-0 border-danger/30 text-danger hover:bg-danger/10`,disabled:a,onClick:()=>c(!0),children:[a?(0,$.jsx)(F,{className:`size-4 animate-spin`}):(0,$.jsx)(ie,{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)(X,{variant:`secondary`,onClick:n,children:i.modalClose}),(T||D)&&w?(0,$.jsxs)(X,{variant:`primary`,disabled:l,onClick:()=>void M(),children:[l?(0,$.jsx)(F,{className:`size-4 animate-spin`}):(0,$.jsx)(G,{className:`size-4`}),i.modalSave]}):null]})]})]}),(0,$.jsx)(et,{open:s,title:I(i.removeConfirmTitle,{name:e.displayName}),description:i.removeConfirmDescription,confirmLabel:i.removeConfirmAction,cancelLabel:i.modalCancel,destructive:!0,onConfirm:()=>{c(!1),j()},onCancel:()=>{a||c(!1)}})]})}function kn(e){let t=(0,ft.c)(2),n;return t[0]===e?n=t[1]:(n=e.instance.materialized.type===`cli`&&e.definition?(0,$.jsx)(B,{definition:e.definition,instance:e.instance,onClose:e.onClose,onChanged:e.onChanged}):(0,$.jsx)(On,{...e}),t[0]=e,t[1]=n),n}function An(e){let t=(0,ft.c)(59),{instance:n,definition:r,highlighted:i,onOpenDetails:a,t:o}=e,s=i!==void 0&&i,c;t[0]!==r||t[1]!==n?(c=Ct(n,r),t[0]=r,t[1]=n,t[2]=c):c=t[2];let l=c.state,u;t[3]!==r||t[4]!==o?(u=r?R(r,o):null,t[3]=r,t[4]=o,t[5]=u):u=t[5];let d=u,f,p,m,h,_,v,y,S,C;if(t[6]!==l||t[7]!==r||t[8]!==s||t[9]!==n||t[10]!==a||t[11]!==o.connectionChecking||t[12]!==o.connectionNeedsSetup||t[13]!==o.connectionReady){f=l===`ready`?{label:o.connectionReady,Icon:x,className:`text-emerald-700 dark:text-emerald-300`}:l===`needs_setup`?{label:o.connectionNeedsSetup,Icon:b,className:`text-amber-700 dark:text-amber-300`}:{label:o.connectionChecking,Icon:O,className:`text-fg-muted`},C=`button`;let e=l===`needs_setup`&&`border-amber-500/25`,i=s&&`bg-accent-soft`;t[23]!==e||t[24]!==i?(p=Y(`flex min-h-[8.75rem] w-full min-w-0 flex-col rounded-xl border border-edge bg-surface-panel p-4 text-left hover:bg-surface-hover/45`,ge.transition,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,e,i),t[23]=e,t[24]=i,t[25]=p):p=t[25],t[26]!==n||t[27]!==a?(m=()=>a(n),t[26]=n,t[27]=a,t[28]=m):m=t[28],y=`flex w-full min-w-0 items-start gap-3`,t[29]===r?S=t[30]:(S=(0,$.jsx)(z,{connector:r,size:`sm`}),t[29]=r,t[30]=S),_=`min-w-0 flex-1`,t[31]===n.displayName?v=t[32]:(v=(0,$.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,title:n.displayName,children:n.displayName}),t[31]=n.displayName,t[32]=v),h=Y(`mt-1 inline-flex items-center gap-1 text-[11px]`,f.className),t[6]=l,t[7]=r,t[8]=s,t[9]=n,t[10]=a,t[11]=o.connectionChecking,t[12]=o.connectionNeedsSetup,t[13]=o.connectionReady,t[14]=f,t[15]=p,t[16]=m,t[17]=h,t[18]=_,t[19]=v,t[20]=y,t[21]=S,t[22]=C}else f=t[14],p=t[15],m=t[16],h=t[17],_=t[18],v=t[19],y=t[20],S=t[21],C=t[22];let w;t[33]===f.Icon?w=t[34]:(w=(0,$.jsx)(f.Icon,{className:`size-3.5`,"aria-hidden":!0}),t[33]=f.Icon,t[34]=w);let T;t[35]!==f.label||t[36]!==w||t[37]!==h?(T=(0,$.jsxs)(`span`,{className:h,children:[w,f.label]}),t[35]=f.label,t[36]=w,t[37]=h,t[38]=T):T=t[38];let E;t[39]!==T||t[40]!==_||t[41]!==v?(E=(0,$.jsxs)(`div`,{className:_,children:[v,T]}),t[39]=T,t[40]=_,t[41]=v,t[42]=E):E=t[42];let D;t[43]!==E||t[44]!==y||t[45]!==S?(D=(0,$.jsxs)(`div`,{className:y,children:[S,E]}),t[43]=E,t[44]=y,t[45]=S,t[46]=D):D=t[46];let k;t[47]===d?k=t[48]:(k=d?(0,$.jsx)(`p`,{className:`mt-2 w-full line-clamp-2 text-xs leading-5 text-fg-muted`,title:d,children:d}):null,t[47]=d,t[48]=k);let A;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,$.jsx)(g,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[49]=A):A=t[49];let j;t[50]===o.installedDetails?j=t[51]:(j=(0,$.jsxs)(`span`,{className:`mt-auto flex w-full items-center justify-end gap-1 pt-2 text-xs text-fg-muted`,children:[o.installedDetails,A]}),t[50]=o.installedDetails,t[51]=j);let M;return t[52]!==p||t[53]!==m||t[54]!==D||t[55]!==k||t[56]!==j||t[57]!==C?(M=(0,$.jsxs)(`button`,{type:C,className:p,onClick:m,children:[D,k,j]}),t[52]=p,t[53]=m,t[54]=D,t[55]=k,t[56]=j,t[57]=C,t[58]=M):M=t[58],M}function jn(e,t){return Gt()}function Mn(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:[Mt()],additionalHeaders:r===`bearer`?t.filter(e=>e!==n):r===`oauth`?t:[]}}function Nn(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,Mt(`Authorization`,`Bearer ${e}`)]}return t.mode===`apiKey`&&(r=[...r,Mt(t.headerName.trim(),t.apiKey.trim())]),{...e,extra:n,headers:r,oauthClientId:t.mode===`oauth`?e.oauthClientId:``}}function Pn(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 Fn(){return Y(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,Ye)}function In({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:h=!0}){let[g,_]=(0,Q.useState)(new Set),[v,y]=(0,Q.useState)(!1),b=(e,t)=>{d(u.map((n,r)=>r===e?{...n,...t}:n))},x=()=>{d([...u,Mt()])},S=e=>{let t=u.filter((t,n)=>n!==e);d(t.length>0?t:[Mt()])},w=async()=>{try{let e=await he();if(!e){y(!0);return}let t=Pt(e);if(!t?.length){y(!0);return}d(t)}catch{y(!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]}),h?(0,$.jsxs)(X,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5 px-2 text-xs`,onClick:()=>void w(),children:[(0,$.jsx)(C,{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:Y(Fn(),`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=>b(t,{key:e.target.value})}),(0,$.jsx)(`input`,{className:Y(Fn(),`min-w-0 font-mono text-xs`),type:g.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=>b(t,{value:e.target.value})}),(0,$.jsx)(X,{type:`button`,variant:`ghost`,className:`size-10 shrink-0 px-0`,disabled:!!e.reference,"aria-label":g.has(e.clientKey)?m:p,onClick:()=>_(t=>{let n=new Set(t);return n.has(e.clientKey)?n.delete(e.clientKey):n.add(e.clientKey),n}),children:g.has(e.clientKey)?(0,$.jsx)(M,{className:`size-4`,"aria-hidden":!0}):(0,$.jsx)(N,{className:`size-4`,"aria-hidden":!0})}),(0,$.jsx)(X,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 px-0`,disabled:u.length<=1&&!e.key&&!e.value,onClick:()=>S(t),"aria-label":r,children:(0,$.jsx)(ie,{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)(et,{open:v,title:o,description:a,confirmLabel:s,onConfirm:()=>y(!1),onCancel:()=>y(!1)}),(0,$.jsxs)(`button`,{type:`button`,className:Y(`self-start text-sm text-accent hover:underline`,ge.press),onClick:x,children:[`+ `,n]})]})}var Ln=Y(`w-full min-w-0 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,Ye);function Rn(e){let t=(0,ft.c)(20),{value:n,onChange:r,label:i,t:a,required:o}=e,s=o!==void 0&&o,[c,l]=(0,Q.useState)(!1),u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=Y(Ln,`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 h;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(h=()=>l(zn),t[11]=h):h=t[11];let g;t[12]===c?g=t[13]:(g=c?(0,$.jsx)(M,{className:`size-4`,"aria-hidden":!0}):(0,$.jsx)(N,{className:`size-4`,"aria-hidden":!0}),t[12]=c,t[13]=g);let _=c?a.setupHideValue:a.setupShowValue,v;t[14]!==g||t[15]!==_?(v=(0,$.jsxs)(X,{type:`button`,variant:`ghost`,className:`gap-1.5 text-xs`,onClick:h,children:[g,_]}),t[14]=g,t[15]=_,t[16]=v):v=t[16];let y;return t[17]!==v||t[18]!==m?(y=(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[m,v]}),t[17]=v,t[18]=m,t[19]=y):y=t[19],y}function zn(e){return!e}function Bn(e){let t=(0,ft.c)(17),{headers:n,onChange:r,t:i,additional:a,environment:o}=e,s=a!==void 0&&a,c=o!==void 0&&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)(In,{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 Vn(e){let t=(0,ft.c)(52),{draft:n,onChange:r,t:i,allowExisting:a}=e,o=i.setupAuthLabel,s=i.setupAuthLabel,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=Y(Ln,`mt-1.5`),t[0]=c):c=t[0];let l=n.mode,u;t[1]===r?u=t[2]:(u=e=>r({mode:e.target.value}),t[1]=r,t[2]=u);let d;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(d=[`auto`,`oauth`,`bearer`,`apiKey`,`headers`,`none`],t[3]=d):d=t[3];let f;t[4]===i.setupAuthModes?f=t[5]:(f=d.map(e=>(0,$.jsx)(v,{value:e,children:i.setupAuthModes[e]},e)),t[4]=i.setupAuthModes,t[5]=f);let p;t[6]!==a||t[7]!==n.mode||t[8]!==i.setupAuthModes?(p=a||n.mode===`existing`?(0,$.jsx)(v,{value:`existing`,children:i.setupAuthModes.existing}):null,t[6]=a,t[7]=n.mode,t[8]=i.setupAuthModes,t[9]=p):p=t[9];let m;t[10]!==n.mode||t[11]!==i.setupAuthLabel||t[12]!==u||t[13]!==f||t[14]!==p?(m=(0,$.jsxs)(_,{"aria-label":s,className:c,value:l,onChange:u,children:[f,p]}),t[10]=n.mode,t[11]=i.setupAuthLabel,t[12]=u,t[13]=f,t[14]=p,t[15]=m):m=t[15];let h;t[16]!==i.setupAuthLabel||t[17]!==m?(h=(0,$.jsxs)(`label`,{className:`block text-sm font-medium text-fg`,children:[o,m]}),t[16]=i.setupAuthLabel,t[17]=m,t[18]=h):h=t[18];let g;t[19]!==n.mode||t[20]!==i.setupAuthAutoHint?(g=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]=g):g=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 x;t[28]!==n.mode||t[29]!==n.token||t[30]!==r||t[31]!==i?(x=n.mode===`bearer`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Rn,{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]=x):x=t[32];let S;t[33]!==n.apiKey||t[34]!==n.headerName||t[35]!==n.mode||t[36]!==r||t[37]!==i?(S=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:Y(Ln,`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)(Rn,{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]=S):S=t[38];let C;t[39]!==n.customHeaders||t[40]!==n.mode||t[41]!==r||t[42]!==i?(C=n.mode===`headers`?(0,$.jsx)(Bn,{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]=C):C=t[43];let w;return t[44]!==h||t[45]!==g||t[46]!==y||t[47]!==b||t[48]!==x||t[49]!==S||t[50]!==C?(w=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[h,g,y,b,x,S,C]}),t[44]=h,t[45]=g,t[46]=y,t[47]=b,t[48]=x,t[49]=S,t[50]=C,t[51]=w):w=t[51],w}function Hn(e){let t=(0,ft.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 Un({row:e,t,onUpdate:n}){let[r,i]=(0,Q.useState)(()=>It(e.envJson?JSON.parse(e.envJson):void 0)),[a,o]=(0,Q.useState)(!1),s=[];try{s=Rt(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)(X,{type:`button`,variant:`ghost`,onClick:()=>o(e=>!e),children:a?t.setupArgsRows:t.setupArgsPaste})]}),a?(0,$.jsx)(Hn,{label:t.setupArgsPaste,hint:t.argsHint,children:(0,$.jsx)(`input`,{className:Ln,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:Ln,"aria-label":`${t.argsLabel} ${n+1}`,value:e,onChange:e=>c(s.map((t,r)=>r===n?e.target.value:t))}),(0,$.jsx)(X,{type:`button`,variant:`ghost`,"aria-label":t.setupRemoveArg,onClick:()=>c(s.filter((e,t)=>t!==n)),children:(0,$.jsx)(ie,{className:`size-4`,"aria-hidden":!0})})]},n)),a?null:(0,$.jsxs)(X,{type:`button`,variant:`ghost`,onClick:()=>c([...s,``]),children:[(0,$.jsx)(W,{className:`size-4`,"aria-hidden":!0}),t.setupAddArg]})]}),(0,$.jsx)(Bn,{environment:!0,headers:r,t,onChange:e=>{i(e),n({envEntries:e,envJson:JSON.stringify(Ft(e)??{})})}})]})}function Wn(e){let t=(0,ft.c)(15),{row:n,t:r,onUpdate:i,variant:a,showOAuth:o,idReadOnly:s}=e,c=a===void 0?`all`:a,l=o!==void 0&&o,u=s!==void 0&&s,d=c!==`advanced`,f=c!==`basic`,p;t[0]!==d||t[1]!==i||t[2]!==n||t[3]!==r?(p=d?(0,$.jsxs)($.Fragment,{children:[n.transport===`stdio`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Hn,{label:`${r.commandLabel} *`,children:(0,$.jsx)(`input`,{"data-field":`command`,className:Ln,value:n.command,required:!0,onChange:e=>i({command:e.target.value})})}),(0,$.jsx)(Un,{row:n,t:r,onUpdate:i})]}):(0,$.jsx)(Hn,{label:`${r.urlLabel} *`,children:(0,$.jsx)(`input`,{"data-field":`url`,className:Ln,value:n.url,placeholder:`https://example.com/mcp`,required:!0,onChange:e=>i({url:e.target.value})})}),(0,$.jsx)(Hn,{label:r.setupNameLabel,hint:r.setupNameHint,children:(0,$.jsx)(`input`,{className:Ln,value:n.displayName??``,placeholder:r.setupNamePlaceholder,onChange:e=>i({displayName:e.target.value})})})]}):null,t[0]=d,t[1]=i,t[2]=n,t[3]=r,t[4]=p):p=t[4];let m;t[5]!==f||t[6]!==u||t[7]!==i||t[8]!==n||t[9]!==l||t[10]!==r?(m=f?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Hn,{label:r.serverIdLabel,hint:r.setupIdHint,children:(0,$.jsx)(`input`,{className:Ln,readOnly:u,value:n.id,onChange:e=>i({id:e.target.value}),placeholder:r.serverIdPlaceholder})}),n.transport===`stdio`?(0,$.jsx)(Hn,{label:r.cwdLabel,children:(0,$.jsx)(`input`,{className:Ln,value:n.cwd,onChange:e=>i({cwd:e.target.value})})}):null,n.transport!==`stdio`&&l?(0,$.jsx)(Hn,{label:r.oauthClientIdLabel,hint:r.oauthClientIdHint,children:(0,$.jsx)(`input`,{className:Ln,value:n.oauthClientId,onChange:e=>i({oauthClientId:e.target.value})})}):null,(0,$.jsx)(Hn,{label:r.exposureLabel,hint:r.setupExposureHint,children:(0,$.jsx)(_,{"aria-label":r.exposureLabel,className:Ln,value:n.exposure,onChange:e=>i({exposure:e.target.value}),children:[`codemode`,`deferred`,`direct`,`hidden`].map(e=>(0,$.jsx)(v,{value:e,children:r.exposureLabels[e]},e))})}),(0,$.jsx)(Hn,{label:r.requestTimeoutLabel,children:(0,$.jsx)(dt,{allowEmpty:!0,type:`number`,min:1,className:Ln,value:n.timeout??``,placeholder:r.setupDefaultTimeout,onChange:e=>i({timeout:e.target.value?Number(e.target.value):void 0})})})]}):null,t[5]=f,t[6]=u,t[7]=i,t[8]=n,t[9]=l,t[10]=r,t[11]=m):m=t[11];let h;return t[12]!==p||t[13]!==m?(h=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[p,m]}),t[12]=p,t[13]=m,t[14]=h):h=t[14],h}function Gn(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 Kn(e,t){return JSON.stringify({id:e.id,config:qt(Nn(e,t))})}function qn(e,t){try{return Kn(e,t)}catch{return JSON.stringify({row:e,auth:t})}}function Jn(e){let{t,cs:n}=e,r=(0,Q.useId)(),[i,a]=(0,Q.useState)(e.initialRow),[o,s]=(0,Q.useState)(()=>Mn(e.initialRow)),[c,l]=(0,Q.useState)(`idle`),[u,d]=(0,Q.useState)(``),[f,p]=(0,Q.useState)(!1),[m,h]=(0,Q.useState)(),[g,y]=(0,Q.useState)(),[b,S]=(0,Q.useState)(),[C,w]=(0,Q.useState)(!1),[T,E]=(0,Q.useState)(!1),[D,O]=(0,Q.useState)(``),[k,A]=(0,Q.useState)(``),[M,N]=(0,Q.useState)([]),[P,I]=(0,Q.useState)(`0`),[L,R]=(0,Q.useState)(0),[z,B]=(0,Q.useState)(``),[V,H]=(0,Q.useState)(!1),[U,ee]=(0,Q.useState)(!1),W=e.mode===`edit`,[te,G]=(0,Q.useState)(``),K=(0,Q.useRef)(void 0),[ne]=(0,Q.useState)(()=>qn(e.initialRow,Mn(e.initialRow))),re=(0,Q.useRef)(e.mode===`edit`?e.initialRow.id:``),q=(0,Q.useRef)(void 0),ie=(0,Q.useRef)(void 0),J=(0,Q.useRef)(void 0),Z=(0,Q.useRef)(null),ce=(0,Q.useRef)(``),pe=(0,Q.useRef)(!0),me=(0,Q.useRef)(null),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=b?.state===`starting`||b?.state===`authorizing`,be=c!==`idle`||ye,xe=ne!==qn(i,o),Se=i.extra.enabled===!1,Ce=!f&&(xe||!!D.trim());(0,Q.useEffect)(()=>(pe.current=!0,()=>{pe.current=!1,q.current?.abort(),Z.current?.close(),K.current&&Zt(K.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(!m)return;let e=ge.current?.querySelector(`[data-field="${m.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),m.focus!==!1&&(n??_e.current)?.focus(),()=>{n?.removeAttribute(`aria-invalid`),n?.removeAttribute(`aria-describedby`)}},[m,r]),(0,Q.useEffect)(()=>{if(!b||!ye)return;let e=new AbortController;ie.current=e;let n;async function r(){try{let n=await en(K.current,e.signal);if(e.signal.aborted||(S(n),n.authorizationUrl&&ce.current!==n.authorizationUrl&&(ce.current=n.authorizationUrl,window.electronAPI?.shell?.openExternalUrl?!(await window.electronAPI.shell.openExternalUrl(n.authorizationUrl)).ok&&!e.signal.aborted&&d(t.oauthOpenFailed):Z.current&&!Z.current.closed&&Z.current.location.replace(n.authorizationUrl)),e.signal.aborted))return;if(n.state===`connected`){J.current=void 0,Z.current?.close(),y({state:`connected`,toolCount:n.toolCount}),d(``);return}if(n.state===`error`||n.state===`cancelled`){J.current=void 0,Z.current?.close(),d(n.state===`cancelled`?t.setupCancelled:t.setupAuthFailed),/client.{0,20}(id|registration)|register|registration/i.test(n.error??``)&&w(!0);return}}catch{if(e.signal.aborted)return;we(),Z.current?.close(),d(t.setupAuthFailed);return}n=setTimeout(()=>void r(),1200)}return r(),()=>{e.abort(),clearTimeout(n)}},[b?.id,ye,t.oauthOpenFailed,t.setupCancelled,t.setupAuthFailed]);function we(){q.current?.abort(),ie.current?.abort(),K.current&&Zt(K.current).catch(()=>{}),K.current=void 0,G(``),H(!1),y(void 0),S(void 0),d(``),h(void 0)}function Te(e){a(t=>({...t,...e})),we()}function Ee(e){s(t=>({...t,...e})),we()}function De(){c===`saving`||ye||(c===`checking`&&(we(),l(`idle`)),Ce?ee(!0):e.onClose())}function Oe(){try{N(Wt(D)),I(`0`),A(``)}catch{A(t.setupImportError),N([])}}function ke(){let t=M[Number(P)];if(!t)return;let n={...t,id:re.current||t.id,clientKey:e.initialRow.clientKey,extra:{...t.extra,...re.current?{enabled:i.extra.enabled}:{}}};a(n),s(Mn(n)),we(),R(e=>e+1),E(!1),O(``),N([])}function Ae(e){function n(e,t){return h({field:e,message:t}),!1}if(e.transport===`streamable-http`){try{e.url=Ut(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(Pn(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{qt(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 je(){d(``),l(`checking`),ce.current=``,window.electronAPI?.shell?.openExternalUrl||(Z.current=window.open(`about:blank`,`_blank`),Z.current&&(Z.current.opener=null));try{let e=await $t(K.current);if(!pe.current){Z.current?.close(),K.current&&Zt(K.current).catch(()=>{});return}J.current=e.id,S(e)}catch{Z.current?.close(),pe.current&&d(t.setupAuthFailed)}finally{pe.current&&l(`idle`)}}async function Me(){let r=Nn(i,o);if(!Ae(r))return;let s=e.existingCustomServers.filter(t=>t.clientKey!==e.initialRow.clientKey&&t.id!==re.current),c=new Set([...e.managedServerIds,...s.map(e=>e.id)]);if(r.id=re.current||r.id.trim()||Ht(r,c),!/^[a-zA-Z0-9_-]+$/.test(r.id)||[...c].some(e=>e.replace(/-/g,`_`)===r.id.replace(/-/g,`_`))){h({field:`advanced`,message:n.duplicateServerId});return}we(),l(`checking`);let u=new AbortController;q.current=u;try{let n=await Yt(r,re.current||void 0,e.initialRow.extra,u.signal);if(!pe.current||u.signal.aborted){Zt(n.id).catch(()=>{});return}K.current=n.id,a(r),G(qn(r,o));let i=await Xt(n.id,u.signal);if(!pe.current||u.signal.aborted)return;y(i),i.state===`error`&&d(Gn(i,t))}catch(e){pe.current&&!u.signal.aborted&&d(e.status===409?t.setupConflict:Gn(e,t))}finally{pe.current&&q.current===u&&l(`idle`)}}async function Ne(n=!1){if(!(!K.current||g?.state!==`connected`||te!==qn(i,o))){l(`saving`),d(``);try{let t=await Qt(K.current,n);K.current=void 0,await ve.current().catch(()=>{}),t?.reloadRequired?p(!0):e.onClose()}catch(e){let n=e.status;n===404||n===409?(we(),d(t.setupConflict)):d(t.setupSaveFailed)}finally{pe.current&&l(`idle`)}}}async function Pe(){ie.current?.abort();let e=K.current;J.current=void 0,S(void 0),Z.current?.close(),d(t.setupCancelled),l(`checking`);try{e&&await tn(e)}catch{pe.current&&(we(),d(t.setupCancelled))}finally{pe.current&&l(`idle`)}}async function Fe(){b?.authorizationUrl&&(window.electronAPI?.shell?.openExternalUrl?(await window.electronAPI.shell.openExternalUrl(b.authorizationUrl)).ok||d(t.oauthOpenFailed):window.open(b.authorizationUrl,`_blank`,`noopener,noreferrer`))}async function Ie(){if(b)try{await nn(K.current,z),B(``),d(``)}catch{d(t.setupRedirectInvalid)}}let Le=!!K.current&&te===qn(i,o)&&(o.mode===`oauth`||o.mode===`auto`&&g?.state===`oauth_required`)&&g?.state!==`connected`,Re=/^(?:https?:\/\/)?(?:localhost|127\.0\.0\.1|\[::1\])(?=[:/]|$)/i.test(i.url.trim()),ze=M[Number(P)];return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(fe,{open:e.open,onOpenChange:e=>{e||De()},children:(0,$.jsxs)(le,{children:[(0,$.jsx)(oe,{className:`fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(ue,{ref:me,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(),me.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)(de,{className:`font-semibold`,children:e.mode===`edit`?t.setupEditTitle:t.setupTitle}),(0,$.jsx)(se,{className:`mt-1 text-sm text-fg-muted`,children:t.setupHint})]}),(0,$.jsx)(`button`,{type:`button`,disabled:c===`saving`||ye,onClick:De,className:`rounded-lg p-2 text-fg-muted hover:bg-surface-hover disabled:opacity-50`,"aria-label":n.modalClose,children:(0,$.jsx)(ae,{className:`size-5`,"aria-hidden":!0})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-5`,children:[T?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(X,{variant:`ghost`,onClick:()=>E(!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:Y(Ln,`mt-1.5 min-h-40 font-mono text-xs`),value:D,placeholder:`{"mcpServers": {"docs": {"url": "https://example.com/mcp"}}}`,onChange:e=>{O(e.target.value),N([]),A(``)}})]}),(0,$.jsx)(X,{variant:`secondary`,disabled:!D.trim(),onClick:Oe,children:t.setupImportPreview}),k?(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:k}):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)(_,{"aria-label":t.setupImportChoose,className:Y(Ln,`mt-1.5`),value:P,onChange:e=>I(e.target.value),children:M.map((e,t)=>(0,$.jsx)(v,{value:String(t),children:e.displayName||e.id||un(e)},t))})]}),(0,$.jsxs)(`p`,{className:`break-all text-sm text-fg-muted`,children:[ze.transport===`stdio`?t.setupUseCommand:t.setupUseUrl,` · `,un(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{Ut(i.url)}catch{h({field:`url`,message:t.setupAddressInvalid,focus:!1})}},onSubmit:e=>{e.preventDefault(),Me()},children:[(0,$.jsxs)(`fieldset`,{disabled:be||f,className:`min-w-0 space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsx)($e,{className:`flex gap-1`,role:`group`,"aria-label":t.transportLabel,children:[`streamable-http`,`stdio`].map(e=>(0,$.jsx)(X,{type:`button`,variant:i.transport===e?`secondary`:`ghost`,"aria-pressed":i.transport===e,onClick:()=>Te({transport:e}),children:e===`stdio`?t.setupUseCommand:t.setupUseUrl},e))}),(0,$.jsx)(X,{type:`button`,variant:`ghost`,onClick:()=>E(!0),children:t.setupImport})]}),(0,$.jsx)(`div`,{children:(0,$.jsx)(Wn,{row:i,t,variant:`basic`,onUpdate:Te},`${i.transport}-${L}`)}),i.transport===`streamable-http`?(0,$.jsx)(`div`,{"data-field":`auth`,children:(0,$.jsx)(Vn,{allowExisting:!!i.extra.auth||i.headers.some(e=>!!e.reference),draft:o,onChange:Ee,t})}):null,m?(0,$.jsx)(`p`,{id:r,ref:_e,tabIndex:-1,role:`alert`,className:`text-sm text-danger`,children:m.message}):null,(0,$.jsxs)(`details`,{"data-field":`advanced`,className:`rounded-lg border border-edge p-3`,open:C,onToggle:e=>w(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)(Wn,{row:i,t,variant:`advanced`,idReadOnly:W,showOAuth:o.mode===`oauth`,onUpdate:Te}),i.transport===`streamable-http`&&o.mode!==`headers`&&o.mode!==`existing`?(0,$.jsx)(Bn,{additional:!0,headers:o.additionalHeaders,onChange:e=>Ee({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})]}),f?(0,$.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-fg`,children:t.setupReloadRequired}):null,!T&&!f?(0,$.jsxs)(`div`,{className:`mt-4 space-y-3`,"aria-live":`polite`,children:[c===`idle`?null:(0,$.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,$.jsx)(F,{className:`size-4 animate-spin motion-reduce:animate-none`,"aria-hidden":!0}),c===`saving`?t.setupSaving:t.setupChecking]}),c===`idle`&&W&&!xe&&!g&&!u&&!ye?(0,$.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:Se?t.setupDisabled:e.lastCheck?t.setupLastCheck.replace(`{{count}}`,String(e.lastCheck.toolCount)):t.setupSavedUnchecked}):null,g?.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)(x,{className:`size-4 shrink-0`,"aria-hidden":!0}),g.toolCount?t.setupConnected.replace(`{{count}}`,String(g.toolCount)):t.setupZeroTools]}),(0,$.jsx)(X,{ref:he,variant:`secondary`,onClick:()=>H(!0),children:t.viewTools})]}):null,g?.state===`token_required`?(0,$.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:t.setupNeedsAuth}):null,g?.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)(F,{className:`size-4 animate-spin motion-reduce:animate-none`,"aria-hidden":!0}),t.setupAuthorizing]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[b?.authorizationUrl?(0,$.jsxs)(X,{variant:`secondary`,onClick:()=>void Fe(),children:[(0,$.jsx)(j,{className:`size-4`,"aria-hidden":!0}),t.oauthOpenAuthorization]}):null,(0,$.jsx)(X,{variant:`ghost`,onClick:()=>void Pe(),children:t.setupCancelAuth})]}),b?.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:Ln,value:z,onChange:e=>B(e.target.value)})]}),(0,$.jsx)(X,{className:`mt-2`,disabled:!z.trim(),onClick:()=>void Ie(),children:t.setupContinue})]}):null]}):null,u?(0,$.jsxs)(`div`,{role:`alert`,className:`space-y-1 text-sm`,children:[(0,$.jsx)(`p`,{className:`text-danger`,children:u}),u!==t.setupSaveFailed&&c!==`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)(X,{variant:`secondary`,disabled:c===`saving`||ye,onClick:De,children:W||f?t.setupClose:n.modalCancel}),f?null:T?(0,$.jsx)(X,{variant:`primary`,disabled:!ze,onClick:ke,children:t.setupImportApply}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(X,{variant:g?.state===`connected`?`secondary`:`primary`,disabled:be,onClick:()=>Le?void je():void Me(),children:Le?t.setupSignIn:t.setupTestConnection}),g?.state===`connected`&&te===qn(i,o)?(0,$.jsxs)($.Fragment,{children:[Se?(0,$.jsx)(X,{variant:`secondary`,disabled:be,onClick:()=>void Ne(!0),children:t.setupEnableSave}):null,(0,$.jsx)(X,{variant:`primary`,disabled:be,"aria-busy":be,onClick:()=>void Ne(),children:W?t.setupSaveOnly:t.setupAddConnection})]}):null]})]})]})]})}),(0,$.jsx)(et,{open:U,title:t.setupUnsavedTitle,description:t.setupUnsavedHint,confirmLabel:t.setupDiscard,cancelLabel:t.setupKeepEditing,onCancel:()=>ee(!1),onConfirm:e.onClose,overlayClassName:`z-[70]`,contentClassName:`z-[70]`}),V?(0,$.jsx)(sn,{draftId:K.current,serverId:i.id,displayName:i.displayName,returnFocusTo:he.current,t,onClose:()=>H(!1)}):null]})}var Yn=`recommended`,Xn=`builtin`,Zn=`composio`,Qn=`xopc-store`;function $n(e,t=`en`){return e==="default"&&t.startsWith(`zh`)?Yn:Xn}function er(e,t){let n=e.connectorManifest;if(!n||typeof n!=`object`||Array.isArray(n))return null;let r=n;if(r.contractVersion!==1||r.id!==e.name)return null;let i=r.runtime,a=r.auth;if(!i||typeof i!=`object`||Array.isArray(i)||!a||typeof a!=`object`||Array.isArray(a))return null;let o=i,s=a;if(o.type!==`mcp`||typeof o.serverId!=`string`)return null;let c=[`code`,`docs`,`browser`,`data`,`automation`,`custom`].includes(String(r.category??``))?r.category:`custom`,l=s.mode===`oauth`?{mode:`oauth`,...typeof s.clientId==`string`?{clientId:s.clientId}:{}}:s.mode===`apiKey`?{mode:`apiKey`}:{mode:`none`},u=e.localizations?.[t===`zh`?`zh-CN`:`en`];return{id:e.name,version:e.latestVersion??`store`,displayName:u?.displayName??(typeof r.displayName==`string`?r.displayName:e.name),description:u?.description??(typeof r.description==`string`?r.description:e.description),category:c,kind:`mcp`,source:`store`,...e.branding?.iconUrl?{branding:{logoUrl:e.branding.iconUrl,source:`registry`}}:{},capabilities:Array.isArray(r.capabilities)?r.capabilities.filter(e=>typeof e==`string`):[],tags:Array.isArray(r.tags)?r.tags.filter(e=>typeof e==`string`):[`store`],auth:l,setup:r.setup&&typeof r.setup==`object`&&!Array.isArray(r.setup)?r.setup:{},runtime:{type:`mcp`,serverId:o.serverId}}}function tr(e){return d(e.map(e=>({connector:e,service:{id:e.id,source:e.source===`builtin`?`builtin-connector`:e.source===`store`?`store-connector`:`registry-connector`}})),`en`).map(e=>e.connector)}function nr(e){return e?.startsWith(`/`)&&!e.startsWith(`//`)?e:`/user-model`}function rr({embedded:e=!1,onHeaderActionChange:t}){let n=me().filter(pn),r=c(e=>e.language),o=u(r),l=o.connectorsSettings,d=o.mcpSettings,h=s(e=>e.conversationId),g=!!h,_=a(),[v,b]=i(),x=v.get(`understanding`)===`1`,S=nr(v.get(`returnTo`)),C=!!v.get(`returnTo`)&&!x,O=v.get(`tab`),[k,A]=(0,Q.useState)(!x&&O===`connected`?`connected`:`discover`),{data:j}=pe(g&&k===`discover`&&!x?[`service-recommendations`,r]:null,()=>f(r),{revalidateOnFocus:!1}),M=(0,Q.useMemo)(()=>new Set(j?.items.filter(e=>e.service?.source===`store-plugin`).map(e=>p(e.id))??[]),[j]),N=(0,Q.useRef)(!1),[P,I]=(0,Q.useState)({catalog:[],registryCatalog:[],instances:[],loading:!0,error:null}),[L,R]=(0,Q.useState)(!1),[z,B]=(0,Q.useState)(!1),[V,ee]=(0,Q.useState)(1),[W,te]=(0,Q.useState)(void 0),[G,K]=(0,Q.useState)(``),[ne,re]=(0,Q.useState)(x||C?v.get(`connector`)??``:``),[q,ie]=(0,Q.useState)($n(x?`understanding`:`default`,r)),[J,ae]=(0,Q.useState)(`name`),[Z,oe]=(0,Q.useState)(x?`understand`:`all`),[se,ce]=(0,Q.useState)(null),[le,ue]=(0,Q.useState)(null),[de,fe]=(0,Q.useState)(null),[he,ge]=(0,Q.useState)(null),[_e,ye]=(0,Q.useState)(null),[be,xe]=(0,Q.useState)(null),{data:Se,mutate:Ce}=ve(g),we=Se?.payload?.config,Te=(0,Q.useMemo)(()=>we===void 0?null:Kt(we),[we]),Ee=Te?.servers??[],De=P.instances.length+Ee.length+n.length,[Oe,ke]=(0,Q.useState)({});(0,Q.useEffect)(()=>{if(ke({}),!g||!we)return;let e=new AbortController;return an(e.signal).then(t=>{e.signal.aborted||ke(t)}).catch(()=>{}),()=>e.abort()},[g,we]);let Ae=(0,Q.useCallback)(async()=>{if(!h){I({catalog:[],registryCatalog:[],instances:[],loading:!1,error:null});return}I(e=>({...e,loading:!0,error:null}));try{let[e,t]=await Promise.all([Pe(),je()]);I(n=>({catalog:e,registryCatalog:n.registryCatalog,instances:t,loading:!1,error:null}))}catch(e){I({catalog:[],registryCatalog:[],instances:[],loading:!1,error:e instanceof Error?e.message:String(e)})}},[h]);(0,Q.useEffect)(()=>{Ae()},[Ae]),(0,Q.useEffect)(()=>{N.current||P.loading||g&&!Te||(A(x?`discover`:De>0?`connected`:`discover`),N.current=!0)},[g,De,Te,x,P.loading]),(0,Q.useEffect)(()=>{ie(e=>e===`builtin`||e===`recommended`?$n(x?`understanding`:`default`,r):e)},[r,x]);let Me=(0,Q.useCallback)(e=>{N.current=!0,A(e)},[]),Ne=(0,Q.useMemo)(()=>[{id:Zn,displayName:l.composioSourceName},{id:Qn,displayName:l.storeSourceName}],[l.composioSourceName,l.storeSourceName]),Fe=(0,Q.useCallback)(async e=>{if(!g||q===`builtin`||q===`recommended`){I(e=>({...e,registryCatalog:[]})),ee(1),te(void 0);return}let t=ne.trim(),n=Math.max(e?.page??1,1),i=e?.append??!1,a=q===`all`?Ne:Ne.filter(e=>e.id===q);if(a.length!==0){R(!0),i?I(e=>({...e,error:null})):(ee(1),te(void 0),I(e=>({...e,registryCatalog:[],error:null})));try{let e=await Promise.all(a.map(async e=>{if(e.id===`composio`){let e=await Ve({q:t||void 0,page:n,pageSize:24,verification:`experimental`});return{connectors:e.connectors,totalPages:e.meta.totalPages}}let i=await ze({q:t||void 0,page:n,pageSize:24,sort:J===`source`?`newest`:`downloads`});return{connectors:i.items.flatMap(e=>{let t=er(e,r);return t?[t]:[]}),totalPages:i.meta.totalPages}})),o=tr(e.flatMap(e=>e.connectors)),s=Math.max(1,...e.map(e=>e.totalPages??1));ee(n),te(s),I(e=>({...e,registryCatalog:i?tr([...e.registryCatalog,...o]):o}))}catch(e){I(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{R(!1)}}},[J,ne,q,g,Ne,r]);(0,Q.useEffect)(()=>{if(k!==`discover`||P.loading)return;if(q===`builtin`||q===`recommended`){I(e=>({...e,registryCatalog:[]})),ee(1),te(void 0);return}let e=window.setTimeout(()=>{Fe()},ne.trim()?350:0);return()=>window.clearTimeout(e)},[ne,q,Fe,P.loading,k]);let Ie=(0,Q.useMemo)(()=>new Set(P.instances.map(e=>e.connectorId)),[P.instances]),Le=(0,Q.useMemo)(()=>new Map([...P.catalog,...P.registryCatalog].map(e=>[e.id,e])),[P.catalog,P.registryCatalog]);(0,Q.useEffect)(()=>{if(P.loading)return;let e=v.get(`connector`),t=v.get(`instance`);if(!e&&!t)return;let n=P.instances.find(n=>t?n.instanceId===t:n.connectorId===e);if(n)N.current=!0,K(``),fe(n.instanceId),ge(n),A(`connected`);else if(e){let t=Le.get(e);if(!t)return;N.current=!0,ie($n(x?`understanding`:`default`,r)),re(``),ue(t),A(`discover`)}let i=new URLSearchParams(v);i.delete(`connector`),i.delete(`instance`),i.set(`tab`,n?`connected`:`discover`),b(i,{replace:!0})},[Le,x,r,v,b,P.instances,P.loading]);let Re=(0,Q.useCallback)(async e=>{B(!0),I(e=>({...e,error:null}));try{let t=await He(e);ce(H(t.definition,{packageName:t.packageName,version:t.version,reviewHash:t.reviewHash,permissions:t.permissions}))}catch(e){I(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{B(!1)}},[]);(0,Q.useEffect)(()=>{let e=v.get(`storeConnector`);if(!g||!e)return;let t=new URLSearchParams(v);t.delete(`storeConnector`),b(t,{replace:!0}),Re(e)},[g,v,b,Re]);let Be=(0,Q.useMemo)(()=>new Set(P.instances.flatMap(e=>e.materialized.type===`mcp`?[e.materialized.serverId]:[])),[P.instances]),Ue=(0,Q.useCallback)(async e=>{let t=await on(e);await Ce(),await Ae(),t.reloadRequired&&I(e=>({...e,error:d.setupReloadRequired}))},[Ae,Ce,d.setupReloadRequired]),We=(0,Q.useCallback)(()=>{xe({mode:`add`,row:jn(Ee,Be)})},[Ee,Be]),Ge=Qe(e=>e.setPageHeader),Ke=Qe(e=>e.clearPageHeader),qe=(0,Q.useMemo)(()=>({searchLabel:k===`connected`?l.connectedSearchPlaceholder:l.discoverSearchPlaceholder,search:(0,$.jsx)(ct,{value:k===`connected`?G:ne,onChange:k===`connected`?K:re,placeholder:k===`connected`?l.connectedSearchPlaceholder:l.discoverSearchPlaceholder}),secondary:(0,$.jsx)(jt,{onRefresh:k===`connected`&&g?Ae:void 0,refreshing:P.loading,refreshLabel:l.refreshConnections,onBrowseCatalog:()=>Me(`discover`),onAddCustomServer:We,addLabel:l.addConnection,browseLabel:l.addFromCatalog,customLabel:l.addCustomServerAdvanced,serviceLabel:r.startsWith(`zh`)?`应用连接服务`:`Connection service`,moreActionsLabel:o.capabilitiesHub.moreActions})}),[G,l,ne,g,r,Ae,o.capabilitiesHub.moreActions,We,Me,P.loading,k]);(0,Q.useLayoutEffect)(()=>e?(t?.(qe),()=>t?.(null)):(Ge({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:l.title})}),end:(0,$.jsx)(lt,{contribution:qe})}),()=>Ke()),[Ke,l.title,e,qe,t,Ge]);let Je=(0,Q.useMemo)(()=>P.instances.map(e=>({instance:e,value:Ct(e,Le.get(e.connectorId))})),[Le,P.instances]),Ye=(0,Q.useMemo)(()=>new Map(Je.map(({instance:e,value:t})=>[e.instanceId,t])),[Je]),Xe=(0,Q.useMemo)(()=>P.instances.filter(e=>E(e,G)).sort((e,t)=>{let n={needs_setup:0,checking:1,ready:2},r=Ye.get(e.instanceId)?.state??`checking`,i=Ye.get(t.instanceId)?.state??`checking`;return n[r]-n[i]||e.displayName.localeCompare(t.displayName)}),[G,Ye,P.instances]),et=(0,Q.useMemo)(()=>Xe.filter(e=>Ye.get(e.instanceId)?.state===`needs_setup`),[Ye,Xe]),tt=(0,Q.useMemo)(()=>Xe.filter(e=>Ye.get(e.instanceId)?.state!==`needs_setup`),[Ye,Xe]),nt=(0,Q.useMemo)(()=>Ee.filter(e=>D(e,G)),[G,Ee]),rt=(0,Q.useMemo)(()=>{let e=G.trim().toLowerCase();return n.filter(t=>[t.name,t.description,...(t.setup?.authorizations??[]).map(e=>e.title),...(t.components?.mcp??[]).map(e=>e.name)].filter(Boolean).join(` `).toLowerCase().includes(e))},[G,n]),it=Xe.length+nt.length+rt.length,at=(0,Q.useMemo)(()=>P.catalog.filter(e=>e.source===`builtin`&&e.integrationStrategy?.preferred!==!1&&w(e)),[P.catalog]),st=(0,Q.useMemo)(()=>q===`recommended`?[]:q===`builtin`?at:q===`all`?tr([...at,...P.registryCatalog]):P.registryCatalog,[at,q,P.registryCatalog]),ut=(0,Q.useMemo)(()=>{let e=x?st.filter(e=>e.understanding?.mode===`activity`):tr(st).filter(e=>!M.has(p(e.id)));return T(Z===`all`?e:e.filter(e=>xt(e).includes(Z)),ne,J)},[J,ne,st,x,Z,M]),dt=(0,Q.useMemo)(()=>bt.filter(e=>st.some(t=>xt(t).includes(e))),[st]);(0,Q.useEffect)(()=>{Z!==`all`&&!dt.includes(Z)&&oe(`all`)},[dt,Z]);let ft=k===`discover`&&q!==`builtin`&&!!(W&&V<W),mt=(0,Q.useMemo)(()=>P.instances.find(e=>e.instanceId===de)??he,[de,he,P.instances]),_t=(0,Q.useMemo)(()=>[{value:Yn,label:r===`zh`?`推荐服务`:`Recommended services`},{value:`all`,label:l.discoverSourceAll},{value:Xn,label:l.discoverSourceBuiltin},...Ne.map(e=>({value:e.id,label:e.displayName}))],[l.discoverSourceAll,l.discoverSourceBuiltin,Ne,r]),St=[{id:`connected`,label:l.tabConnected,count:De},{id:`discover`,label:l.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:Y(`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:[g?null:(0,$.jsx)(`p`,{className:`rounded-xl border border-edge bg-surface-panel px-4 py-3 text-sm text-fg-muted`,children:l.tokenHint}),x?(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:l.understandingSetupTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:l.understandingSetupHint})]}),(0,$.jsx)(X,{type:`button`,variant:`secondary`,className:`shrink-0`,onClick:()=>_(S),children:l.understandingSetupDone})]}):null,C?(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:l.recoverySetupTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:l.recoverySetupHint})]}),(0,$.jsx)(X,{type:`button`,variant:`secondary`,className:`min-h-11 shrink-0`,onClick:()=>_(S),children:l.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)(Ze,{items:St,activeTab:k,onChange:Me,ariaLabel:l.navAria,tabIdPrefix:`connectors-tab`,panelIdPrefix:`connectors-panel`,className:`flex-wrap`})}),P.error?(0,$.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:P.error}):null,k===`connected`&&g?(0,$.jsx)(`div`,{className:`flex flex-col gap-6`,children:P.loading?(0,$.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,"aria-busy":`true`,"aria-label":l.loading,children:ht.slice(0,3).map(e=>(0,$.jsx)(yt,{},e))}):De===0?(0,$.jsxs)(`div`,{className:`py-14 text-center`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:l.connectionsEmpty}),(0,$.jsx)(X,{type:`button`,variant:`primary`,className:`mt-4`,onClick:()=>Me(`discover`),children:l.addFromCatalog})]}):it===0?(0,$.jsx)(`div`,{className:`py-14 text-center text-sm text-fg-muted`,children:l.connectionsSearchEmpty}):(0,$.jsxs)(`div`,{className:`space-y-6`,children:[et.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:l.needsAttentionTitle}),(0,$.jsx)(`span`,{className:`text-xs tabular-nums text-amber-700 dark:text-amber-300`,children:et.length})]}),(0,$.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:et.map(e=>(0,$.jsx)(An,{instance:e,definition:Le.get(e.connectorId),highlighted:e.instanceId===_e,onOpenDetails:e=>{ye(null),fe(e.instanceId),ge(e)},t:l},e.instanceId))})]}):null,tt.length||rt.length?(0,$.jsx)(`section`,{children:(0,$.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:[tt.map(e=>(0,$.jsx)(An,{instance:e,definition:Le.get(e.connectorId),highlighted:e.instanceId===_e,onOpenDetails:e=>{ye(null),fe(e.instanceId),ge(e)},t:l},e.instanceId)),rt.map(e=>(0,$.jsx)(mn,{extension:e,language:r,onOpen:()=>_(ot(e.pluginId,`connections`,e.authorizationStatus===`required`))},e.id))]})}):null,nt.length||!G.trim()?(0,$.jsx)(fn,{servers:nt,lastChecks:Oe,t:d,cs:l,onAdd:We,onEdit:e=>xe({mode:`edit`,row:structuredClone(e)}),onRemove:Ue}):null]})}):null,k===`discover`&&g?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[x?null:(0,$.jsx)($e,{className:`flex min-w-0 flex-1 basis-80 flex-wrap gap-2`,role:`group`,"aria-label":l.taskFilterAria,indicatorClassName:`rounded-lg bg-surface-active`,children:[`all`,...dt].map(e=>(0,$.jsx)(`button`,{type:`button`,className:Y(`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors`,Z===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":Z===e,onClick:()=>oe(e),children:e===`all`?l.taskAll:l.connectorBenefitHeadings[e]},e))}),(0,$.jsxs)(`div`,{className:Y(`ml-auto grid w-full gap-2 sm:flex sm:w-auto sm:justify-end`,x?`grid-cols-1`:`grid-cols-2`),children:[x?null:(0,$.jsx)(`div`,{className:`min-w-0 sm:w-40`,children:(0,$.jsx)(y,{value:q,options:_t,placeholder:l.discoverSourceAll,allowEmpty:!1,ariaLabel:l.registrySourceAria,triggerClassName:`h-9 bg-surface-panel text-xs`,onChange:ie})}),q===`recommended`?null:(0,$.jsx)(`div`,{className:`min-w-0 sm:w-40`,children:(0,$.jsx)(y,{value:J,options:[{value:`name`,label:l.sortName},{value:`source`,label:l.sortSource}],placeholder:l.sortName,allowEmpty:!1,ariaLabel:l.sortAria,triggerClassName:`h-9 bg-surface-panel text-xs`,onChange:e=>ae(e)})})]})]}),q===`recommended`?(0,$.jsx)(m,{layout:`cards`,initialCount:6,query:ne,onChanged:async()=>{await Ae(),await Ce()}}):(P.loading||L)&&ut.length===0?(0,$.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,"aria-busy":`true`,"aria-label":l.loading,children:ht.map(e=>(0,$.jsx)(vt,{},e))}):ut.length===0?(0,$.jsx)(`div`,{className:`py-14 text-center text-sm text-fg-muted`,children:l.discoverEmpty}):(0,$.jsxs)(`div`,{className:`relative`,children:[L?(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":l.loading,children:(0,$.jsx)(F,{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:ut.map(e=>(0,$.jsx)(pt,{connector:e,installed:Ie.has(e.id)||gt(e,P.instances),onInstall:e=>{if(e.source===`store`){Re(e.id);return}ce(H(e))},onOpenDetails:e.source===`store`?void 0:ue,t:l},e.id))}),ft?(0,$.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,$.jsxs)(X,{type:`button`,variant:`secondary`,disabled:L||z,onClick:()=>void Fe({page:V+1,append:!0}),children:[L?(0,$.jsx)(F,{className:`size-4 animate-spin`}):null,l.loadMore]})}):null]})]}):null]}),se?(0,$.jsx)(U,{draft:se,onChange:ce,onClose:()=>ce(null),t:l,onInstalled:async e=>{await Ae(),await Ce(),ye(e.instanceId),Me(`connected`)}}):null,le?(0,$.jsx)(Dt,{connector:le,installed:Ie.has(le.id)||gt(le,P.instances),onClose:()=>ue(null),onInstall:e=>ce(H(e)),t:l}):null,mt?(0,$.jsx)(kn,{instance:mt,definition:Le.get(mt.connectorId),onClose:()=>{fe(null),ge(null)},onChanged:Ae,t:l,mcp:d}):null,be?(0,$.jsx)(Jn,{open:!0,mode:be.mode,initialRow:be.row,lastCheck:be.mode===`edit`?Oe[be.row.id]:void 0,existingCustomServers:Ee,config:we,managedServerIds:Be,t:d,cs:l,onClose:()=>xe(null),onSaved:async()=>{await Ce(),await Ae(),Me(`connected`)}},`${be.mode}-${be.row.clientKey}`):null]})})}export{rr as ConnectorsPage};
|