@xopcai/xopc 0.0.486 → 0.0.487

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.
Files changed (665) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/feishu/src/outbound/media-load.js +1 -1
  3. package/dist/extensions/feishu/src/transport/reliability/message-ingress.js +2 -2
  4. package/dist/extensions/telegram/src/inbound-processor.js +2 -2
  5. package/dist/extensions/telegram/src/outbound-sender.js +1 -1
  6. package/dist/extensions/telegram/src/plugin.js +3 -3
  7. package/dist/extensions/telegram/src/polling-session.js +1 -1
  8. package/dist/extensions/telegram/src/update-offset-store.js +2 -1
  9. package/dist/extensions/telegram/xopc.extension.json +1 -1
  10. package/dist/extensions/weixin/src/api/api.js +2 -2
  11. package/dist/extensions/weixin/src/auth/accounts.js +12 -12
  12. package/dist/extensions/weixin/src/messaging/debug-mode.js +5 -5
  13. package/dist/extensions/weixin/src/messaging/inbound.js +11 -11
  14. package/dist/extensions/weixin/src/messaging/process-message.js +2 -2
  15. package/dist/extensions/weixin/src/messaging/quote-cache.js +3 -1
  16. package/dist/extensions/weixin/src/storage/sync-buf.js +2 -1
  17. package/dist/gateway/server/chunks.bin +1568 -1404
  18. package/dist/gateway/server/chunks.json +1 -1
  19. package/dist/gateway/server/dependency-records.json +42 -0
  20. package/dist/gateway/static/root/assets/{activity-store-hSe5Nbgk.js → activity-store-CWGtissf.js} +1 -1
  21. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-BY2wRiwY.js → agent-avatar-dicebear-D4YSq8A9.js} +1 -1
  22. package/dist/gateway/static/root/assets/{agent-avatar-display-D_UDgOr9.js → agent-avatar-display-DWv7biOS.js} +2 -2
  23. package/dist/gateway/static/root/assets/{agent-defaults-settings-panel-BrcyLG9M.js → agent-defaults-settings-panel-3xdD9dR1.js} +1 -1
  24. package/dist/gateway/static/root/assets/{agent-plugin-dialog-CSJC1yud.js → agent-plugin-dialog-BNvw2z1Y.js} +1 -1
  25. package/dist/gateway/static/root/assets/{agents-DX-t3X7K.js → agents-DcENLHHW.js} +3 -3
  26. package/dist/gateway/static/root/assets/{agents-admin-api-DSr-PWuW.js → agents-admin-api-BzpxMKwk.js} +1 -1
  27. package/dist/gateway/static/root/assets/{api-CGrHK9ij.js → api-D70-LnNE.js} +1 -1
  28. package/dist/gateway/static/root/assets/{api-B3T06TLl.js → api-SIYalfjE.js} +1 -1
  29. package/dist/gateway/static/root/assets/{app-management-settings-panel-D6ZoYKaA.js → app-management-settings-panel-CEveRIMe.js} +1 -1
  30. package/dist/gateway/static/root/assets/{appearance-settings-BRb6kZT8.js → appearance-settings-CT2NLLuY.js} +1 -1
  31. package/dist/gateway/static/root/assets/{apps-page-6xeWvMpF.js → apps-page-pEqr4fAK.js} +1 -1
  32. package/dist/gateway/static/root/assets/{archive-plugin-CQ5UXgZk.js → archive-plugin-xnggGfUN.js} +1 -1
  33. package/dist/gateway/static/root/assets/{automation-api-D-gn6x5E.js → automation-api-CaBLskwk.js} +1 -1
  34. package/dist/gateway/static/root/assets/{automation-result-state-B7hq0XOL.js → automation-result-state-CeGtOXK0.js} +1 -1
  35. package/dist/gateway/static/root/assets/{automation-run-list-CM59-qm5.js → automation-run-list-DUpezxj4.js} +1 -1
  36. package/dist/gateway/static/root/assets/{automation-task-card-C453Q-Wa.js → automation-task-card-CLayJo0S.js} +1 -1
  37. package/dist/gateway/static/root/assets/{automations-page-BLFBqaPX.js → automations-page-BKfvaA41.js} +1 -1
  38. package/dist/gateway/static/root/assets/{automations-workspace-DiO3Iyuj.js → automations-workspace-BRcJzgLA.js} +2 -2
  39. package/dist/gateway/static/root/assets/{binary-plugins-D_zw0TgG.js → binary-plugins-DtD3acS4.js} +1 -1
  40. package/dist/gateway/static/root/assets/block-editor-BFDeQtYs.css +1 -0
  41. package/dist/gateway/static/root/assets/{block-editor-Cesz2DqP.js → block-editor-DXjBAN8L.js} +46 -46
  42. package/dist/gateway/static/root/assets/{browser-settings-page-BHElJSFt.js → browser-settings-page-Cgxtr2eR.js} +1 -1
  43. package/dist/gateway/static/root/assets/{capabilities-CW-vdkz6.js → capabilities-CpwoMqtm.js} +1 -1
  44. package/dist/gateway/static/root/assets/{capabilities-DZrjA95P.js → capabilities-DcD15BrU.js} +1 -1
  45. package/dist/gateway/static/root/assets/{capabilities-page-DQrfkrBA.js → capabilities-page-x_AS_XJ0.js} +2 -2
  46. package/dist/gateway/static/root/assets/{capabilities-settings-panel-DIT2dvtc.js → capabilities-settings-panel-DMgEXxkC.js} +1 -1
  47. package/dist/gateway/static/root/assets/{channels-Dcr5dgqw.js → channels-565FQAGr.js} +1 -1
  48. package/dist/gateway/static/root/assets/{chat-agents-api-CyvBfBbp.js → chat-agents-api-BfsNH-ht.js} +1 -1
  49. package/dist/gateway/static/root/assets/{chat-chart-block-B83s8HE9.js → chat-chart-block-Dpolmx0-.js} +1 -1
  50. package/dist/gateway/static/root/assets/{chat-page-DWZCzxY7.js → chat-page-Bn44NcvF.js} +6 -6
  51. package/dist/gateway/static/root/assets/{chat-terminal-dock-DCUuwiTt.js → chat-terminal-dock-D6fuI2tI.js} +1 -1
  52. package/dist/gateway/static/root/assets/{command-palette-api-UrqPvWR1.js → command-palette-api-H3lCPfK8.js} +1 -1
  53. package/dist/gateway/static/root/assets/{composer-model-config-control-C2Bku39S.js → composer-model-config-control-BcWrGT5D.js} +1 -1
  54. package/dist/gateway/static/root/assets/{composer-notifications-MGKffwC7.js → composer-notifications-0fMBrXZD.js} +1 -1
  55. package/dist/gateway/static/root/assets/{composer-payload-handoff-a0quQ25p.js → composer-payload-handoff-DCGudJjU.js} +1 -1
  56. package/dist/gateway/static/root/assets/{computer-settings-page-DUzQe6Bz.js → computer-settings-page-kvYzJ_j2.js} +1 -1
  57. package/dist/gateway/static/root/assets/confirm-dialog-yhRKgG72.js +1 -0
  58. package/dist/gateway/static/root/assets/{connected-providers-grid-BJKEp0SE.js → connected-providers-grid-CApjiM_x.js} +1 -1
  59. package/dist/gateway/static/root/assets/{connection-usage-guide-B9hoSOnN.js → connection-usage-guide-C2qOP6Nx.js} +1 -1
  60. package/dist/gateway/static/root/assets/{connector-service-page-e67KylnM.js → connector-service-page-DKihi3WL.js} +1 -1
  61. package/dist/gateway/static/root/assets/{connectors-api-CRGq-TSw.js → connectors-api-Dj9RbG9p.js} +1 -1
  62. package/dist/gateway/static/root/assets/{connectors-page-BteRI1XM.js → connectors-page-CR6a3Mne.js} +1 -1
  63. package/dist/gateway/static/root/assets/{date-picker-DwITf4I2.js → date-picker-BX5tr0IG.js} +1 -1
  64. package/dist/gateway/static/root/assets/{date-time-picker-ChG1CqR1.js → date-time-picker-CdPsuK2A.js} +1 -1
  65. package/dist/gateway/static/root/assets/{desktop-pet-BHoFymL4.js → desktop-pet-DRfOb9ZT.js} +1 -1
  66. package/dist/gateway/static/root/assets/{desktop-pet-settings-BYeBN4jj.js → desktop-pet-settings-D6qCAFLe.js} +1 -1
  67. package/dist/gateway/static/root/assets/{dev-view-store-DsjH8x76.js → dev-view-store-DrRxtile.js} +1 -1
  68. package/dist/gateway/static/root/assets/{device-connections-panel-DE01vyK_.js → device-connections-panel-Drbw9eRH.js} +1 -1
  69. package/dist/gateway/static/root/assets/{device-pairing-action-w1enAo76.js → device-pairing-action-Dd2YtIhH.js} +1 -1
  70. package/dist/gateway/static/root/assets/{device-pairing-wizard-Dt737tSq.js → device-pairing-wizard-wtsyHEO3.js} +1 -1
  71. package/dist/gateway/static/root/assets/{directory-picker-path-field-B-eUnbng.js → directory-picker-path-field-B3YBba3x.js} +1 -1
  72. package/dist/gateway/static/root/assets/{extension-authoritative-grants-DYp2nNol.js → extension-authoritative-grants-WXYRv5nA.js} +1 -1
  73. package/dist/gateway/static/root/assets/{extension-debug-page-4jJ1uVQJ.js → extension-debug-page-CKeIq8S2.js} +1 -1
  74. package/dist/gateway/static/root/assets/{extension-iframe-host-CJV5JETm.js → extension-iframe-host-Cv4PCSVv.js} +1 -1
  75. package/dist/gateway/static/root/assets/{extension-marketplace-api-DGV5FC-v.js → extension-marketplace-api-e0e9OxOT.js} +1 -1
  76. package/dist/gateway/static/root/assets/{extension-message-router-B4I-Y6qs.js → extension-message-router-GPlMiYyF.js} +1 -1
  77. package/dist/gateway/static/root/assets/{extension-page-lc7a84nG.js → extension-page-DcP7IEMp.js} +1 -1
  78. package/dist/gateway/static/root/assets/{extension-provider-D8_mIBI0.js → extension-provider-DZ97b5uA.js} +1 -1
  79. package/dist/gateway/static/root/assets/{extension-settings-page-Uw2lfWRh.js → extension-settings-page-DIYoawnA.js} +1 -1
  80. package/dist/gateway/static/root/assets/{gateway-config-swr-BD-ams0X.js → gateway-config-swr-aAsaoOK1.js} +1 -1
  81. package/dist/gateway/static/root/assets/{gateway-realtime-CoIFB3im.js → gateway-realtime-egUNyhxi.js} +1 -1
  82. package/dist/gateway/static/root/assets/gateway-realtime-store-5YcWzAfG.js +1 -0
  83. package/dist/gateway/static/root/assets/{gateway-restart-Dos1Pp84.js → gateway-restart-BY6zJgTe.js} +1 -1
  84. package/dist/gateway/static/root/assets/{gateway-settings-DUC1iOVK.js → gateway-settings-4TvJ0_i0.js} +1 -1
  85. package/dist/gateway/static/root/assets/{gateway-startup-retry-DgmvR-hb.js → gateway-startup-retry-D0dDJJQ4.js} +1 -1
  86. package/dist/gateway/static/root/assets/{global-defaults-api-B7suATYU.js → global-defaults-api-9iooq81U.js} +1 -1
  87. package/dist/gateway/static/root/assets/{home-page-mSRCU81k.js → home-page-VMzHth7Q.js} +3 -3
  88. package/dist/gateway/static/root/assets/{home-task-actions-_ZAc57Y7.js → home-task-actions-iUYzLb18.js} +1 -1
  89. package/dist/gateway/static/root/assets/{image-generation-api-Baz4xdZ4.js → image-generation-api-Dv4fjHaE.js} +1 -1
  90. package/dist/gateway/static/root/assets/{imports-page-DR0eLPgB.js → imports-page-WENCxW7P.js} +1 -1
  91. package/dist/gateway/static/root/assets/index-CaUUC83j.css +1 -0
  92. package/dist/gateway/static/root/assets/{index-CJAEAcZV.js → index-DwdoCbAF.js} +6 -6
  93. package/dist/gateway/static/root/assets/{install-connector-dialog-CntHi8Rh.js → install-connector-dialog-DNY-rpBC.js} +1 -1
  94. package/dist/gateway/static/root/assets/keyboard-shortcuts-settings-DHWEGna7.js +1 -0
  95. package/dist/gateway/static/root/assets/{local-app-workbench-page-C3Lqi8E1.js → local-app-workbench-page-Dnug0YtC.js} +1 -1
  96. package/dist/gateway/static/root/assets/{local-apps-page-BoCtITdL.js → local-apps-page-Bjr4rrgT.js} +1 -1
  97. package/dist/gateway/static/root/assets/{local-session-drafts-CGSV1RQg.js → local-session-drafts-Z3PoR-8i.js} +1 -1
  98. package/dist/gateway/static/root/assets/{locale-store-CHjsq5NR.js → locale-store-DgbX5Azb.js} +1 -1
  99. package/dist/gateway/static/root/assets/{logs-page-0hkRbcUR.js → logs-page-BIZvtqSJ.js} +1 -1
  100. package/dist/gateway/static/root/assets/{management-api-FVu7eYXD.js → management-api-CJb5Vclf.js} +1 -1
  101. package/dist/gateway/static/root/assets/{management-settings-QQB1r71U.js → management-settings-BjtIRkgJ.js} +1 -1
  102. package/dist/gateway/static/root/assets/{markdown-view-ihzUc4ud.js → markdown-view-lnMk_L03.js} +1 -1
  103. package/dist/gateway/static/root/assets/{mcp-conversation-setup-page-DffQKrjd.js → mcp-conversation-setup-page-kq0dZ2Nc.js} +1 -1
  104. package/dist/gateway/static/root/assets/{media-plugins-C78NkHfB.js → media-plugins-RU49QGcW.js} +1 -1
  105. package/dist/gateway/static/root/assets/messages-Clfka2Sx.js +3 -0
  106. package/dist/gateway/static/root/assets/{model-selector-QFZY5XNN.js → model-selector-BolKz5sx.js} +1 -1
  107. package/dist/gateway/static/root/assets/{models-hub-cache-BrD6r5Qs.js → models-hub-cache-CjdnTF5z.js} +1 -1
  108. package/dist/gateway/static/root/assets/note-detail-panel-Qm1Et_f8.js +7 -0
  109. package/dist/gateway/static/root/assets/note-image-lightbox-BVcE6TAF.js +1 -0
  110. package/dist/gateway/static/root/assets/{notes-api-D5SvfybU.js → notes-api-FjHO1h6b.js} +1 -1
  111. package/dist/gateway/static/root/assets/{notes-page-RPfvHnl6.js → notes-page-B_atfwwi.js} +2 -2
  112. package/dist/gateway/static/root/assets/{oauth-api-DnMpUoyx.js → oauth-api-B1lbdI3v.js} +1 -1
  113. package/dist/gateway/static/root/assets/{oauth-provider-connect-DGYky6ut.js → oauth-provider-connect-Cy1Yy8aX.js} +1 -1
  114. package/dist/gateway/static/root/assets/{page-context-capture-button-CVHz9b6c.js → page-context-capture-button-Phh-SyES.js} +1 -1
  115. package/dist/gateway/static/root/assets/{page-context-draft-Bk7jVvAG.js → page-context-draft-M04A73Ul.js} +1 -1
  116. package/dist/gateway/static/root/assets/{page-header-store-NP7MCIaP.js → page-header-store-CYA4Isnf.js} +1 -1
  117. package/dist/gateway/static/root/assets/{personal-avatar-1TVnHakL.js → personal-avatar-DF3Frmnt.js} +1 -1
  118. package/dist/gateway/static/root/assets/{personal-page-Dt1d3tQT.js → personal-page-DkDROUWV.js} +1 -1
  119. package/dist/gateway/static/root/assets/{personal-profile-settings-XiT1MgTK.js → personal-profile-settings-LAAXGLKs.js} +1 -1
  120. package/dist/gateway/static/root/assets/{personal-settings-panel-bcw04REt.js → personal-settings-panel-B6G-4av9.js} +1 -1
  121. package/dist/gateway/static/root/assets/{phone-dependencies-card-B4QsgIEF.js → phone-dependencies-card-DeBlKu7M.js} +1 -1
  122. package/dist/gateway/static/root/assets/{phone-model-connection-Dk5kE1Ll.js → phone-model-connection-TStZicIQ.js} +1 -1
  123. package/dist/gateway/static/root/assets/{phone-model-picker-CFoxQiws.js → phone-model-picker-C3xcbacO.js} +1 -1
  124. package/dist/gateway/static/root/assets/{phone-settings-page-Bv1xm8sh.js → phone-settings-page-CllfdPFi.js} +1 -1
  125. package/dist/gateway/static/root/assets/{phone-workspace-store-DGaibcsi.js → phone-workspace-store-CeP3GXUk.js} +1 -1
  126. package/dist/gateway/static/root/assets/{plugin-details-dialog-FcOJaeP0.js → plugin-details-dialog-Ck1dirgu.js} +1 -1
  127. package/dist/gateway/static/root/assets/{preference-select-fields-B-yK91If.js → preference-select-fields-DMClbggY.js} +1 -1
  128. package/dist/gateway/static/root/assets/{preview-runtime-FtWOW5i4.js → preview-runtime-Cl-SoLXg.js} +3 -3
  129. package/dist/gateway/static/root/assets/product-automation-feedback-Bb_lbw1l.js +1 -0
  130. package/dist/gateway/static/root/assets/{product-open-page-C09VEZjY.js → product-open-page-BWH54iuf.js} +1 -1
  131. package/dist/gateway/static/root/assets/{product-preview-content-B3mzl6-f.js → product-preview-content-NOZu0WO2.js} +1 -1
  132. package/dist/gateway/static/root/assets/{product-preview-modal-5kTp_7Qk.js → product-preview-modal-ZKiIeKof.js} +2 -2
  133. package/dist/gateway/static/root/assets/{project-detail-page-DGPfKx5M.js → project-detail-page-BTgDajpj.js} +1 -1
  134. package/dist/gateway/static/root/assets/{project-understanding-4IyHVmus.js → project-understanding-BWpcOkWw.js} +1 -1
  135. package/dist/gateway/static/root/assets/{projects-page-C-9x23LR.js → projects-page-Dnx2AcQX.js} +1 -1
  136. package/dist/gateway/static/root/assets/{providers-api-D9NuB7w3.js → providers-api-BRAMBKCK.js} +1 -1
  137. package/dist/gateway/static/root/assets/recording-upload-C0d2YjJV.js +1 -0
  138. package/dist/gateway/static/root/assets/{registry-api-CDpUAb2R.js → registry-api-Dz4umdY3.js} +1 -1
  139. package/dist/gateway/static/root/assets/{remote-access-hub-DVTs8pwO.js → remote-access-hub-BEIzBYdj.js} +1 -1
  140. package/dist/gateway/static/root/assets/{resource-unavailable-CZlqZYk-.js → resource-unavailable-82byHwG_.js} +1 -1
  141. package/dist/gateway/static/root/assets/{right-workspace-store-Cehybf-G.js → right-workspace-store-B8ooYVOe.js} +1 -1
  142. package/dist/gateway/static/root/assets/{route-preload-CzorjVc9.js → route-preload-DkUojqyb.js} +2 -2
  143. package/dist/gateway/static/root/assets/{routine-panel-n4IstC8Y.js → routine-panel-wJxaH-1V.js} +2 -2
  144. package/dist/gateway/static/root/assets/{runtime-tools-api-BhS0RWf2.js → runtime-tools-api-CQ7fTX-H.js} +1 -1
  145. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-jTbGPGeA.js → runtime-tools-settings-panel-DZD-cEXM.js} +1 -1
  146. package/dist/gateway/static/root/assets/{service-recommendation-list-wfd0Mjtu.js → service-recommendation-list-CFJ8WBzq.js} +1 -1
  147. package/dist/gateway/static/root/assets/{session-api-CR3NLqvs.js → session-api-Dxhtjzoa.js} +1 -1
  148. package/dist/gateway/static/root/assets/{session-manager-C2MCS4C5.js → session-manager-DvIGR4Sw.js} +1 -1
  149. package/dist/gateway/static/root/assets/{sessions-page-9ibCNP9o.js → sessions-page-BDPieIpD.js} +1 -1
  150. package/dist/gateway/static/root/assets/settings-advanced-gate-CaALReQD.js +1 -0
  151. package/dist/gateway/static/root/assets/{settings-advanced-section-CTLdGPvx.js → settings-advanced-section-1R7xRVEG.js} +1 -1
  152. package/dist/gateway/static/root/assets/{settings-mode-store-CCQVvItG.js → settings-mode-store-D4-i8uQI.js} +1 -1
  153. package/dist/gateway/static/root/assets/{settings-page-DsM_f07M.js → settings-page-DXo8rZFt.js} +1 -1
  154. package/dist/gateway/static/root/assets/{settings-page-header-C21Iw2rD.js → settings-page-header-BooYRGUH.js} +1 -1
  155. package/dist/gateway/static/root/assets/{settings-page-layout-BXcLlp6p.js → settings-page-layout-BeHnqGAN.js} +1 -1
  156. package/dist/gateway/static/root/assets/{setup-interaction-page-W2F5ZaR_.js → setup-interaction-page-DqmPSRNo.js} +1 -1
  157. package/dist/gateway/static/root/assets/{setup-status-panel-BFNwZuhp.js → setup-status-panel-c4yDTYiK.js} +1 -1
  158. package/dist/gateway/static/root/assets/{share-link-dialog-2JjvWs0q.js → share-link-dialog-Cvma1jxB.js} +1 -1
  159. package/dist/gateway/static/root/assets/{share-preview-page-C32Mq-BY.js → share-preview-page-BL6FwL4u.js} +1 -1
  160. package/dist/gateway/static/root/assets/{shares-api-BhWvN3LS.js → shares-api-BqIBNEtd.js} +1 -1
  161. package/dist/gateway/static/root/assets/{shares-settings-BDGbs8wz.js → shares-settings-BoBOd-eB.js} +1 -1
  162. package/dist/gateway/static/root/assets/{skill-api-BG9A1WF0.js → skill-api-oDg0Zlyb.js} +1 -1
  163. package/dist/gateway/static/root/assets/{skill-list-api-B26hHnXq.js → skill-list-api-BvfKctht.js} +1 -1
  164. package/dist/gateway/static/root/assets/{skill-reload-api-B9Eu5Yk_.js → skill-reload-api-CnchMEV8.js} +1 -1
  165. package/dist/gateway/static/root/assets/{skills-page-kL8E5zgi.js → skills-page-CFZk_0nE.js} +1 -1
  166. package/dist/gateway/static/root/assets/{space-api-_uKFiASp.js → space-api-C_GoZOc_.js} +1 -1
  167. package/dist/gateway/static/root/assets/{space-page-DwyuUvI3.js → space-page-CBSaZbyH.js} +2 -2
  168. package/dist/gateway/static/root/assets/{space-workbook-BAwHwK6O.js → space-workbook-B8JGuyIf.js} +1 -1
  169. package/dist/gateway/static/root/assets/{system-settings-panel-0e2zfQLt.js → system-settings-panel-DzNDyMOH.js} +1 -1
  170. package/dist/gateway/static/root/assets/{task-detail-page-DdCpNW8K.js → task-detail-page-BmWkL-KH.js} +1 -1
  171. package/dist/gateway/static/root/assets/{task-header-title-CLt_lmjb.js → task-header-title-CCaEJNV4.js} +1 -1
  172. package/dist/gateway/static/root/assets/{task-result-presentation-CgvcqEMD.js → task-result-presentation-DwEf7Xf7.js} +1 -1
  173. package/dist/gateway/static/root/assets/{task-run-issue-notice-8FX876PP.js → task-run-issue-notice-COE7ppvl.js} +1 -1
  174. package/dist/gateway/static/root/assets/{terminal-panel-store-Cy90Ix5U.js → terminal-panel-store-CHQ2xJtk.js} +1 -1
  175. package/dist/gateway/static/root/assets/{theme-store-CvG266p8.js → theme-store-Bij94a-6.js} +1 -1
  176. package/dist/gateway/static/root/assets/{tracing-settings-page-Cx_fOH70.js → tracing-settings-page-CKH4dKSl.js} +1 -1
  177. package/dist/gateway/static/root/assets/{tunnel-api-Cph-ZBBy.js → tunnel-api-ChjCCCGL.js} +1 -1
  178. package/dist/gateway/static/root/assets/{understanding-activity-store-CN4JzOIO.js → understanding-activity-store-BD1OXjlI.js} +1 -1
  179. package/dist/gateway/static/root/assets/{understanding-refresh-store-BuZZ1_VH.js → understanding-refresh-store-BSVLFuVh.js} +1 -1
  180. package/dist/gateway/static/root/assets/{usage-page-Du42x0ej.js → usage-page-v5c3aC-p.js} +1 -1
  181. package/dist/gateway/static/root/assets/{use-autosave-B_WH_LBE.js → use-autosave-teDzNJW4.js} +1 -1
  182. package/dist/gateway/static/root/assets/{use-composer-attachments-BEuyorVm.js → use-composer-attachments-rUl5n4_a.js} +1 -1
  183. package/dist/gateway/static/root/assets/{use-file-preview-expanded-Cehu0745.js → use-file-preview-expanded-BRjXpRde.js} +1 -1
  184. package/dist/gateway/static/root/assets/{use-generated-media-CzRbgtcv.js → use-generated-media-Bx6BscUT.js} +1 -1
  185. package/dist/gateway/static/root/assets/{use-personal-profile-D4gLM6Wi.js → use-personal-profile-Dz3wWaGt.js} +1 -1
  186. package/dist/gateway/static/root/assets/{use-personal-work-B25WRGHj.js → use-personal-work-D-Tgi4DZ.js} +1 -1
  187. package/dist/gateway/static/root/assets/{use-realtime-voice-CV3GIt_T.js → use-realtime-voice-Bp81D6PV.js} +1 -1
  188. package/dist/gateway/static/root/assets/{use-share-link-WKZLlEqr.js → use-share-link-D5HNXEIt.js} +1 -1
  189. package/dist/gateway/static/root/assets/{use-workspace-tree-C0C861cb.js → use-workspace-tree-DXKhfc1T.js} +1 -1
  190. package/dist/gateway/static/root/assets/{user-model-page-AK2U8vGc.js → user-model-page-B0tEc4rh.js} +1 -1
  191. package/dist/gateway/static/root/assets/{voice-api-key-field-BqXQj51r.js → voice-api-key-field-odum3GZx.js} +1 -1
  192. package/dist/gateway/static/root/assets/{voice-config-api-sXEIG6lz.js → voice-config-api-CiA2cr3s.js} +1 -1
  193. package/dist/gateway/static/root/assets/voice-input-shortcut-events-JsEfJGJz.js +1 -0
  194. package/dist/gateway/static/root/assets/{voice-player-store-CTbnOdeM.js → voice-player-store-CUV5cpmX.js} +1 -1
  195. package/dist/gateway/static/root/assets/{voice-settings-JpPo3BvX.js → voice-settings-FOeRWVH4.js} +1 -1
  196. package/dist/gateway/static/root/assets/{work-discovery-overlay-BjfTRFX8.js → work-discovery-overlay-CJxXUdeq.js} +1 -1
  197. package/dist/gateway/static/root/assets/{work-discovery-page-CSRkFiXc.js → work-discovery-page-Dm0XTxsk.js} +1 -1
  198. package/dist/gateway/static/root/assets/{working-directory-picker-modal-DgM21YVT.js → working-directory-picker-modal-DfyyBJpb.js} +1 -1
  199. package/dist/gateway/static/root/assets/{workspace-api-CQOuWbVv.js → workspace-api-B1JW3oZZ.js} +2 -2
  200. package/dist/gateway/static/root/assets/workspace-editor-agent-store-BbfHBVhA.js +1 -0
  201. package/dist/gateway/static/root/assets/{workspace-file-preview-dialog-CmMueTmW.js → workspace-file-preview-dialog-kGa6o4bV.js} +1 -1
  202. package/dist/gateway/static/root/assets/{workspace-open-location-menu-BAbIGS01.js → workspace-open-location-menu-Dl4QsZL3.js} +1 -1
  203. package/dist/gateway/static/root/assets/{xopc-cloud-account-card-e8HJFnTs.js → xopc-cloud-account-card-fiyk59YU.js} +1 -1
  204. package/dist/gateway/static/root/index.html +94 -94
  205. package/dist/package.js +1 -1
  206. package/dist/src/agent/agent-manager.js +18 -18
  207. package/dist/src/agent/agent-scope.js +2 -2
  208. package/dist/src/agent/background-review/prompts.js +2 -2
  209. package/dist/src/agent/background-review/run-background-review.js +14 -14
  210. package/dist/src/agent/child-agent-factory.js +4 -4
  211. package/dist/src/agent/commands/command-registry.js +2 -1
  212. package/dist/src/agent/context/coordinator.js +3 -3
  213. package/dist/src/agent/context/deep-recall.js +5 -5
  214. package/dist/src/agent/context/execution-context.js +3 -3
  215. package/dist/src/agent/context/project-context.js +4 -4
  216. package/dist/src/agent/data-acquisition/service.js +1 -1
  217. package/dist/src/agent/embedded/codemode-extension.js +1 -1
  218. package/dist/src/agent/embedded/execution-tool-policy.d.ts +1 -0
  219. package/dist/src/agent/embedded/execution-tool-policy.js +8 -4
  220. package/dist/src/agent/embedded/external-tool-discovery.js +1 -1
  221. package/dist/src/agent/embedded/index.js +1 -1
  222. package/dist/src/agent/embedded/run-for-session.js +10 -10
  223. package/dist/src/agent/embedded/run-turn.js +19 -19
  224. package/dist/src/agent/embedded/runs.js +1 -1
  225. package/dist/src/agent/embedded/session-runner.js +5 -5
  226. package/dist/src/agent/embedded/xopc-tools-bridge.js +1 -1
  227. package/dist/src/agent/external-tools/cliProvider.js +5 -5
  228. package/dist/src/agent/external-tools/composio-provider.js +3 -3
  229. package/dist/src/agent/external-tools/endpoint-provider.js +9 -9
  230. package/dist/src/agent/external-tools/extension-provider.js +1 -1
  231. package/dist/src/agent/external-tools/gateway-tools.js +3 -3
  232. package/dist/src/agent/external-tools/memory-provider.js +1 -1
  233. package/dist/src/agent/image/generation/openai-images-provider.js +1 -1
  234. package/dist/src/agent/image/generation/runtime.js +1 -1
  235. package/dist/src/agent/image/index.js +1 -1
  236. package/dist/src/agent/image/tool-model-config.js +1 -1
  237. package/dist/src/agent/inbound/attachment-pipeline.js +1 -1
  238. package/dist/src/agent/inbound/inbound-loop.js +3 -3
  239. package/dist/src/agent/independent-execution.js +1 -1
  240. package/dist/src/agent/index.js +1 -1
  241. package/dist/src/agent/mcp/connection-drafts.js +1 -1
  242. package/dist/src/agent/mcp/connection-setup.js +2 -2
  243. package/dist/src/agent/mcp/continuation-guard.js +2 -1
  244. package/dist/src/agent/mcp/conversation-setup.js +2 -1
  245. package/dist/src/agent/mcp/discovery.js +3 -2
  246. package/dist/src/agent/mcp/managed-discovery.js +1 -1
  247. package/dist/src/agent/mcp/tool-catalog.js +1 -1
  248. package/dist/src/agent/mcp/transport.js +1 -1
  249. package/dist/src/agent/memory/index.js +1 -1
  250. package/dist/src/agent/messaging/outbound-coordinator.js +1 -1
  251. package/dist/src/agent/orchestration/agent-orchestrator.js +1 -1
  252. package/dist/src/agent/orchestration/child-run-monitor.js +2 -1
  253. package/dist/src/agent/orchestration/child-run-resume.js +3 -3
  254. package/dist/src/agent/orchestration/llm-turn-retry.js +1 -1
  255. package/dist/src/agent/prompt/response-language.js +1 -1
  256. package/dist/src/agent/prompt/service-prompt-builder.js +3 -3
  257. package/dist/src/agent/prompt/system-prompt-params.js +1 -1
  258. package/dist/src/agent/sandbox/exec-policy.js +1 -1
  259. package/dist/src/agent/service/direct-turn-helpers.js +4 -4
  260. package/dist/src/agent/service/process-direct-streaming.js +7 -7
  261. package/dist/src/agent/service/webchat-tts.js +3 -3
  262. package/dist/src/agent/service.js +21 -21
  263. package/dist/src/agent/session/interaction-policy-state.js +2 -1
  264. package/dist/src/agent/session/session-config-service.js +2 -2
  265. package/dist/src/agent/session/session-hydrator.js +1 -1
  266. package/dist/src/agent/session/session-inspector.js +1 -1
  267. package/dist/src/agent/skills/skill-manager.js +1 -1
  268. package/dist/src/agent/skills/skill-sources.js +1 -1
  269. package/dist/src/agent/tasks/task-judge-service.js +7 -7
  270. package/dist/src/agent/tools/clarify-tool.js +1 -1
  271. package/dist/src/agent/tools/create-share-tool.js +1 -1
  272. package/dist/src/agent/tools/delegate-tool.js +3 -3
  273. package/dist/src/agent/tools/exec-command.js +1 -1
  274. package/dist/src/agent/tools/executor.js +1 -1
  275. package/dist/src/agent/tools/factory.js +20 -20
  276. package/dist/src/agent/tools/fetch-text.js +1 -1
  277. package/dist/src/agent/tools/image-generate-tool.js +2 -2
  278. package/dist/src/agent/tools/index.js +4 -4
  279. package/dist/src/agent/tools/knowledge-memory-tool.js +1 -1
  280. package/dist/src/agent/tools/managed-job-tool.js +1 -1
  281. package/dist/src/agent/tools/personal-attention-tool.js +2 -2
  282. package/dist/src/agent/tools/personal-memory-tool.js +7 -7
  283. package/dist/src/agent/tools/personal-read-tool.js +1 -1
  284. package/dist/src/agent/tools/personal-request-result-tool.js +2 -2
  285. package/dist/src/agent/tools/personal-request-tool.js +2 -2
  286. package/dist/src/agent/tools/personal-result-tool.js +1 -1
  287. package/dist/src/agent/tools/personal-task-tool.js +5 -5
  288. package/dist/src/agent/tools/session-search-tool.js +2 -2
  289. package/dist/src/agent/tools/skill-install-tool.js +2 -1
  290. package/dist/src/agent/tools/task-collaboration-tool.js +1 -1
  291. package/dist/src/agent/tools/tts-tool.js +1 -1
  292. package/dist/src/agent/tools/user-context-tool.js +2 -2
  293. package/dist/src/agent/tools/web.js +1 -1
  294. package/dist/src/agent/tools/workbook-tools.js +1 -1
  295. package/dist/src/agent/tools/xopc-use-tool.js +19 -13
  296. package/dist/src/agent-catalog/capabilities.js +1 -1
  297. package/dist/src/ai-assist/text-assist.js +1 -1
  298. package/dist/src/auth/oauth/xopc-cloud.js +1 -1
  299. package/dist/src/auth/sync-provider-auth.js +1 -1
  300. package/dist/src/automations/capabilities/write.js +3 -2
  301. package/dist/src/automations/domain/index.js +1 -1
  302. package/dist/src/automations/draft/automation-draft-service.js +1 -1
  303. package/dist/src/automations/index.js +2 -2
  304. package/dist/src/automations/mcp-source.js +2 -1
  305. package/dist/src/automations/service/action-executor.js +2 -2
  306. package/dist/src/automations/service/automation-service.js +2 -2
  307. package/dist/src/bootstrap/application-state.js +1 -1
  308. package/dist/src/browser/native-messaging-host.js +1 -1
  309. package/dist/src/capabilities/capability-catalog.js +4 -4
  310. package/dist/src/capabilities/runtime/dispatcher.d.ts +6 -0
  311. package/dist/src/capabilities/runtime/dispatcher.js +48 -13
  312. package/dist/src/capabilities/store-connector.js +1 -1
  313. package/dist/src/channels/attachments/inbound-persist.js +1 -0
  314. package/dist/src/channels/attachments/outbound-tts-persist.js +1 -0
  315. package/dist/src/channels/attachments/voice-stt-webchat.js +1 -1
  316. package/dist/src/channels/index.js +1 -1
  317. package/dist/src/channels/message-journal.js +2 -1
  318. package/dist/src/channels/outbound-sender.js +1 -1
  319. package/dist/src/channels/pairing/allow-from-file.js +9 -9
  320. package/dist/src/channels/pairing/pairing-store.js +6 -6
  321. package/dist/src/chat-commands/agent-edit.js +1 -1
  322. package/dist/src/chat-commands/builtins/config.js +2 -2
  323. package/dist/src/chat-commands/builtins/session.js +1 -1
  324. package/dist/src/chat-commands/builtins/thinking.js +1 -1
  325. package/dist/src/chat-commands/builtins/tts.js +1 -1
  326. package/dist/src/chat-commands/index.js +3 -3
  327. package/dist/src/cli/cli-log-level-preset.js +5 -1
  328. package/dist/src/cli/commands/agent.js +7 -7
  329. package/dist/src/cli/commands/config.js +1 -1
  330. package/dist/src/cli/commands/connectors.js +1 -1
  331. package/dist/src/cli/commands/doctor/checks/gateway-health.js +1 -1
  332. package/dist/src/cli/commands/doctor/checks/provider-auth.js +1 -1
  333. package/dist/src/cli/commands/extension-agent-plugin.js +1 -1
  334. package/dist/src/cli/commands/extension-dev.js +1 -1
  335. package/dist/src/cli/commands/extension.js +1 -1
  336. package/dist/src/cli/commands/image.js +1 -1
  337. package/dist/src/cli/commands/init.js +1 -1
  338. package/dist/src/cli/commands/mcp.js +45 -6
  339. package/dist/src/cli/commands/models.js +2 -2
  340. package/dist/src/cli/commands/onboard/model.js +1 -1
  341. package/dist/src/cli/commands/onboard.js +1 -1
  342. package/dist/src/cli/commands/project.js +1 -1
  343. package/dist/src/cli/commands/skills.js +1 -1
  344. package/dist/src/cli/commands/tunnel.js +4 -4
  345. package/dist/src/cli/extension-cli-register.js +5 -5
  346. package/dist/src/cli/index.js +9 -1
  347. package/dist/src/cli/utils/gateway-client.js +1 -1
  348. package/dist/src/cli/utils/init-workspace-core.js +1 -1
  349. package/dist/src/computer/flows.js +2 -1
  350. package/dist/src/computer/model-adapter.js +1 -1
  351. package/dist/src/computer/runtime.js +11 -11
  352. package/dist/src/config/config-file.js +1 -1
  353. package/dist/src/config/index.js +4 -4
  354. package/dist/src/config/loader.js +1 -1
  355. package/dist/src/config/models-json.js +2 -2
  356. package/dist/src/config/schema.d.ts +18 -0
  357. package/dist/src/config/schema.js +6 -0
  358. package/dist/src/connectors/cli/authorization.js +1 -1
  359. package/dist/src/connectors/composio-triggers.js +2 -1
  360. package/dist/src/connectors/connected-source-ingestion.js +2 -2
  361. package/dist/src/connectors/connected-source-understanding.js +5 -5
  362. package/dist/src/connectors/connection-recovery-service.js +4 -4
  363. package/dist/src/connectors/content-enrichment.js +1 -1
  364. package/dist/src/connectors/health.js +1 -1
  365. package/dist/src/discussions/live-worker.js +1 -1
  366. package/dist/src/discussions/sealer.js +1 -1
  367. package/dist/src/endpoint-tools/delegation.js +2 -1
  368. package/dist/src/endpoint-tools/device-capability-grants.js +2 -1
  369. package/dist/src/endpoint-tools/execution-actor.js +2 -1
  370. package/dist/src/endpoint-tools/folder-connections.js +2 -1
  371. package/dist/src/endpoint-tools/invocation-service.js +4 -3
  372. package/dist/src/endpoint-tools/provider-catalog.js +2 -1
  373. package/dist/src/endpoint-tools/provider-operation-status.js +2 -1
  374. package/dist/src/endpoint-tools/runtime.js +2 -1
  375. package/dist/src/endpoint-tools/target-resolver.js +1 -1
  376. package/dist/src/extensions/activation-context.js +3 -3
  377. package/dist/src/extensions/agent-plugins/auth.js +1 -1
  378. package/dist/src/extensions/agent-plugins/cli-authorization.js +1 -1
  379. package/dist/src/extensions/agent-plugins/credentials.js +1 -1
  380. package/dist/src/extensions/agent-plugins/setup.js +1 -1
  381. package/dist/src/extensions/agent-plugins/skill-catalog.js +3 -3
  382. package/dist/src/extensions/agent-plugins/source-http-fetch.js +1 -1
  383. package/dist/src/extensions/agent-plugins/user-config.js +1 -1
  384. package/dist/src/extensions/agent-plugins/validation.js +1 -1
  385. package/dist/src/extensions/api.js +2 -2
  386. package/dist/src/extensions/bundled-extension-activation.js +1 -1
  387. package/dist/src/extensions/index.js +1 -1
  388. package/dist/src/extensions/install.js +1 -1
  389. package/dist/src/extensions/loader.js +1 -1
  390. package/dist/src/extensions/sdk/index.js +1 -1
  391. package/dist/src/extensions/sdk/media.js +1 -1
  392. package/dist/src/files/workspace-file-spaces.d.ts +4 -0
  393. package/dist/src/files/workspace-file-spaces.js +14 -0
  394. package/dist/src/gateway/agent-reactions/reaction.js +3 -3
  395. package/dist/src/gateway/agents-admin.js +1 -1
  396. package/dist/src/gateway/device-routes.js +1 -1
  397. package/dist/src/gateway/file-path-classifier.js +1 -1
  398. package/dist/src/gateway/file-space-service.d.ts +1 -1
  399. package/dist/src/gateway/file-space-service.js +2 -8
  400. package/dist/src/gateway/global-defaults-admin.js +1 -1
  401. package/dist/src/gateway/hono/app.js +31 -10
  402. package/dist/src/gateway/hono/lib/config-payload.js +3 -3
  403. package/dist/src/gateway/hono/lib/extension-store.js +2 -1
  404. package/dist/src/gateway/hono/lib/mcp-dispatcher.d.ts +2 -0
  405. package/dist/src/gateway/hono/lib/mcp-dispatcher.js +19 -0
  406. package/dist/src/gateway/hono/oauth-async.js +1 -1
  407. package/dist/src/gateway/hono/routes/agent-plugins.js +1 -1
  408. package/dist/src/gateway/hono/routes/auth-registry-extensions.js +6 -6
  409. package/dist/src/gateway/hono/routes/capability-operations.d.ts +1 -0
  410. package/dist/src/gateway/hono/routes/capability-operations.js +6 -3
  411. package/dist/src/gateway/hono/routes/commands-skills.js +4 -4
  412. package/dist/src/gateway/hono/routes/config-patch/gateway.js +1 -1
  413. package/dist/src/gateway/hono/routes/device-connections.js +2 -2
  414. package/dist/src/gateway/hono/routes/device-targets.js +1 -1
  415. package/dist/src/gateway/hono/routes/endpoint-tools.js +1 -1
  416. package/dist/src/gateway/hono/routes/home.js +1 -1
  417. package/dist/src/gateway/hono/routes/lazy-bundles.js +19 -0
  418. package/dist/src/gateway/hono/routes/local-app-capabilities.js +1 -1
  419. package/dist/src/gateway/hono/routes/location-sharing.js +1 -1
  420. package/dist/src/gateway/hono/routes/mcp-bridge.d.ts +3 -0
  421. package/dist/src/gateway/hono/routes/mcp-bridge.js +87 -0
  422. package/dist/src/gateway/hono/routes/mcp-remote.d.ts +3 -0
  423. package/dist/src/gateway/hono/routes/mcp-remote.js +169 -0
  424. package/dist/src/gateway/hono/routes/mcp.js +1 -1
  425. package/dist/src/gateway/hono/routes/memory-learning.js +3 -3
  426. package/dist/src/gateway/hono/routes/mobile-capability-actions.js +5 -5
  427. package/dist/src/gateway/hono/routes/mobile-capability-panels.js +13 -13
  428. package/dist/src/gateway/hono/routes/mobile-model-settings.js +3 -3
  429. package/dist/src/gateway/hono/routes/models.js +5 -5
  430. package/dist/src/gateway/hono/routes/music-generation.js +1 -1
  431. package/dist/src/gateway/hono/routes/notes.js +2 -2
  432. package/dist/src/gateway/hono/routes/personal-agent.js +3 -2
  433. package/dist/src/gateway/hono/routes/phone-setup.js +4 -4
  434. package/dist/src/gateway/hono/routes/phone.js +3 -3
  435. package/dist/src/gateway/hono/routes/projects.js +5 -5
  436. package/dist/src/gateway/hono/routes/session-command-handler.js +2 -2
  437. package/dist/src/gateway/hono/routes/session-input-handler.js +3 -3
  438. package/dist/src/gateway/hono/routes/sessions.js +3 -3
  439. package/dist/src/gateway/hono/routes/shares.js +2 -2
  440. package/dist/src/gateway/hono/routes/side-chats.js +1 -1
  441. package/dist/src/gateway/hono/routes/tui.js +1 -1
  442. package/dist/src/gateway/hono/routes/user-model.js +7 -7
  443. package/dist/src/gateway/hono/routes/video-generation.js +1 -1
  444. package/dist/src/gateway/hono/routes/voice.js +6 -6
  445. package/dist/src/gateway/image-generation-setup.js +1 -1
  446. package/dist/src/gateway/lock.js +11 -11
  447. package/dist/src/gateway/media-access.js +2 -2
  448. package/dist/src/gateway/mobile-privacy.js +2 -2
  449. package/dist/src/gateway/ports.js +6 -6
  450. package/dist/src/gateway/provider-model-setup.js +1 -1
  451. package/dist/src/gateway/server.js +1 -1
  452. package/dist/src/gateway/service/agent-runner.js +11 -6
  453. package/dist/src/gateway/service/config-coordinator.d.ts +9 -0
  454. package/dist/src/gateway/service/config-coordinator.js +2 -2
  455. package/dist/src/gateway/service/marketplace-service.js +2 -2
  456. package/dist/src/gateway/service/run-gateway-agent.js +5 -5
  457. package/dist/src/gateway/service/session-command-service.js +2 -2
  458. package/dist/src/gateway/service/session-input-coordinator.d.ts +1 -0
  459. package/dist/src/gateway/service/session-input-coordinator.js +31 -3
  460. package/dist/src/gateway/service/sessions-api.js +1 -1
  461. package/dist/src/gateway/service.d.ts +4 -0
  462. package/dist/src/gateway/service.js +65 -38
  463. package/dist/src/gateway/session-context-summary.js +1 -1
  464. package/dist/src/gateway/workspace-editor-path.js +2 -2
  465. package/dist/src/gateway/xopc-cloud-capability-setup.js +2 -2
  466. package/dist/src/home-intelligence/follow-ups.js +1 -1
  467. package/dist/src/home-intelligence/generator.js +2 -2
  468. package/dist/src/home-intelligence/observation.js +1 -1
  469. package/dist/src/home-intelligence/routines.js +2 -2
  470. package/dist/src/imports/importService.js +1 -1
  471. package/dist/src/imports/inventory.js +2 -2
  472. package/dist/src/imports/productImport.js +1 -1
  473. package/dist/src/infra/bus/queue.js +1 -1
  474. package/dist/src/infra/gateway-processes.js +2 -2
  475. package/dist/src/infra/path-env.js +3 -3
  476. package/dist/src/infra/update-global.js +9 -9
  477. package/dist/src/knowledge/connected-knowledge-pipeline.js +1 -1
  478. package/dist/src/knowledge/index.js +1 -1
  479. package/dist/src/knowledge-memory/repository.js +1 -1
  480. package/dist/src/knowledge-memory/usage-policy.js +1 -1
  481. package/dist/src/local-apps/access-audit.js +2 -1
  482. package/dist/src/local-apps/automation-proposals.js +2 -1
  483. package/dist/src/local-apps/capabilities/automation-policy.js +2 -1
  484. package/dist/src/local-apps/capabilities/delegate.js +3 -2
  485. package/dist/src/local-apps/execution-authority.js +4 -3
  486. package/dist/src/local-apps/p1-services.js +4 -3
  487. package/dist/src/local-apps/public-assets.js +2 -1
  488. package/dist/src/local-apps/service.js +3 -2
  489. package/dist/src/local-apps/store.js +2 -1
  490. package/dist/src/mcp/callback-config.d.ts +5 -0
  491. package/dist/src/mcp/callback-config.js +16 -0
  492. package/dist/src/mcp/capability-server.d.ts +1 -2
  493. package/dist/src/mcp/capability-server.js +34 -79
  494. package/dist/src/mcp/connection-grants.d.ts +15 -0
  495. package/dist/src/mcp/connection-grants.js +73 -0
  496. package/dist/src/mcp/delegation.d.ts +329 -0
  497. package/dist/src/mcp/delegation.js +610 -0
  498. package/dist/src/mcp/gateway-http-client.d.ts +2 -2
  499. package/dist/src/mcp/gateway-http-client.js +5 -5
  500. package/dist/src/mcp/product-tools.d.ts +7 -0
  501. package/dist/src/mcp/product-tools.js +292 -0
  502. package/dist/src/mcp/remote-auth.d.ts +8 -0
  503. package/dist/src/mcp/remote-auth.js +51 -0
  504. package/dist/src/mcp/remote-config.d.ts +11 -0
  505. package/dist/src/mcp/remote-config.js +31 -0
  506. package/dist/src/mcp/remote-grants.d.ts +20 -0
  507. package/dist/src/mcp/remote-grants.js +60 -0
  508. package/dist/src/mcp/run-callbacks.d.ts +9 -0
  509. package/dist/src/mcp/run-callbacks.js +138 -0
  510. package/dist/src/mcp/tool-contract.d.ts +30 -0
  511. package/dist/src/mcp/tool-contract.js +81 -0
  512. package/dist/src/mcp/workspace-search.d.ts +16 -0
  513. package/dist/src/mcp/workspace-search.js +68 -0
  514. package/dist/src/media/index.js +4 -1
  515. package/dist/src/media/media-reference.js +2 -1
  516. package/dist/src/media/session-references.js +4 -2
  517. package/dist/src/media/store.js +2 -1
  518. package/dist/src/media/uri.js +17 -12
  519. package/dist/src/media-understanding/openai-compatible-audio.js +1 -1
  520. package/dist/src/memory-learning/choice-observations.js +7 -7
  521. package/dist/src/memory-learning/source-learning.js +5 -5
  522. package/dist/src/memory-learning/task-receipts.js +1 -1
  523. package/dist/src/memory-learning/work-capture.js +1 -1
  524. package/dist/src/memory-learning/work-review.js +3 -3
  525. package/dist/src/music-generation/artifact.js +3 -2
  526. package/dist/src/music-generation/settings.js +2 -1
  527. package/dist/src/music-generation/worker.js +1 -1
  528. package/dist/src/notes/agent-context.js +4 -4
  529. package/dist/src/notes/capabilities/write.js +2 -1
  530. package/dist/src/notes/service.js +1 -1
  531. package/dist/src/personal-agent/capability-service.js +1 -1
  532. package/dist/src/personal-agent/proactivity/repository.js +2 -1
  533. package/dist/src/personal-agent/proactivity/routes.js +1 -1
  534. package/dist/src/personal-agent/proactivity/service.js +7 -6
  535. package/dist/src/personal-agent/prompt-context.js +4 -4
  536. package/dist/src/personal-agent/prompts.js +1 -1
  537. package/dist/src/personal-agent/reply-composer.js +9 -9
  538. package/dist/src/personal-agent/reply-result.js +4 -2
  539. package/dist/src/personal-agent/request-delivery.js +1 -1
  540. package/dist/src/personal-agent/request-service.js +4 -4
  541. package/dist/src/personal-agent/result-reader.js +1 -1
  542. package/dist/src/personal-agent/service.js +2 -2
  543. package/dist/src/personal-agent/task-cancel.js +1 -1
  544. package/dist/src/phone/adb-driver.js +1 -1
  545. package/dist/src/phone/assistance.js +2 -1
  546. package/dist/src/phone/cloud-adb-connection.js +1 -1
  547. package/dist/src/phone/location-environment.js +2 -1
  548. package/dist/src/phone/model-adapter.js +1 -1
  549. package/dist/src/phone/repository.js +2 -1
  550. package/dist/src/phone/runtime.js +4 -4
  551. package/dist/src/phone/setup/service.js +2 -1
  552. package/dist/src/projects/index.js +2 -2
  553. package/dist/src/projects/project-service.js +2 -2
  554. package/dist/src/projects/workspace.js +1 -1
  555. package/dist/src/providers/model-catalog-persistence.js +1 -1
  556. package/dist/src/providers/model-reference-auditor.js +1 -1
  557. package/dist/src/providers/model-registry.js +1 -1
  558. package/dist/src/remote-access/exposure-manager.js +1 -1
  559. package/dist/src/session/history-recall-policy.js +2 -2
  560. package/dist/src/session/index.js +2 -2
  561. package/dist/src/session/session-title.js +1 -1
  562. package/dist/src/session/store.js +10 -9
  563. package/dist/src/session/thinking-resolve.js +1 -1
  564. package/dist/src/share/hosted-session-share.js +2 -1
  565. package/dist/src/share/note-share-revocation.js +2 -1
  566. package/dist/src/share/share-store.js +2 -1
  567. package/dist/src/share/share-thumbnail.js +1 -1
  568. package/dist/src/share/site-proxy.js +1 -1
  569. package/dist/src/share/site-share-store.js +2 -1
  570. package/dist/src/space/ingest.js +2 -1
  571. package/dist/src/space/repository.js +1 -1
  572. package/dist/src/space/workbook-proposals.js +2 -1
  573. package/dist/src/space/workbook-turn.js +2 -1
  574. package/dist/src/space/worker.js +2 -1
  575. package/dist/src/storage/sqlite/connection.js +9 -9
  576. package/dist/src/storage/sqlite/durable-state.js +43 -39
  577. package/dist/src/storage/sqlite/session-input-control-repository.js +2 -1
  578. package/dist/src/storage/sqlite/session-input-repository.js +7 -5
  579. package/dist/src/tasks/capabilities/read.js +4 -3
  580. package/dist/src/tasks/capabilities/relations.js +1 -1
  581. package/dist/src/tasks/capabilities/runs.d.ts +101 -0
  582. package/dist/src/tasks/capabilities/runs.js +42 -35
  583. package/dist/src/tasks/capabilities/write.js +5 -4
  584. package/dist/src/tasks/delegated-run-result.d.ts +16 -0
  585. package/dist/src/tasks/delegated-run-result.js +47 -0
  586. package/dist/src/tasks/home-query-service.js +1 -1
  587. package/dist/src/tasks/index.js +6 -6
  588. package/dist/src/tasks/task-allocation-service.js +6 -6
  589. package/dist/src/tasks/task-application-service.d.ts +5 -0
  590. package/dist/src/tasks/task-application-service.js +8 -4
  591. package/dist/src/tasks/task-context-assembler.js +8 -5
  592. package/dist/src/tasks/task-contract-planner.js +2 -2
  593. package/dist/src/tasks/task-deliverables.js +19 -14
  594. package/dist/src/tasks/task-delivery-checks.js +1 -1
  595. package/dist/src/tasks/task-execution-capabilities.js +1 -1
  596. package/dist/src/tasks/task-handoff-service.js +1 -1
  597. package/dist/src/tasks/task-handoff.d.ts +16 -3
  598. package/dist/src/tasks/task-handoff.js +165 -145
  599. package/dist/src/tasks/task-json-acceptance.js +4 -3
  600. package/dist/src/tasks/task-main-update-decision-service.js +2 -2
  601. package/dist/src/tasks/task-main-update-delivery.js +1 -1
  602. package/dist/src/tasks/task-model-call.js +1 -1
  603. package/dist/src/tasks/task-repository.js +3 -0
  604. package/dist/src/tasks/task-research-repair.js +2 -1
  605. package/dist/src/tasks/task-research-result.js +3 -3
  606. package/dist/src/tasks/task-result-delivery-service.js +4 -3
  607. package/dist/src/tasks/task-retry-service.js +1 -1
  608. package/dist/src/tasks/task-run-coordinator.js +8 -7
  609. package/dist/src/tasks/task-run-dispatcher.js +2 -2
  610. package/dist/src/tasks/task-run-repository.d.ts +2 -1
  611. package/dist/src/tasks/task-run-repository.js +9 -4
  612. package/dist/src/tui/backend-services.js +1 -1
  613. package/dist/src/tui/backends/embedded-backend.js +13 -13
  614. package/dist/src/tui/backends/gateway-realtime-backend.js +1 -1
  615. package/dist/src/tui/extension-host/load-extensions.js +1 -1
  616. package/dist/src/tui/tui-capabilities.js +2 -2
  617. package/dist/src/tui/tui-commands.js +3 -3
  618. package/dist/src/tui/tui-management.js +8 -8
  619. package/dist/src/tui/tui-picker-overlay.js +1 -1
  620. package/dist/src/tui/tui-skills-autocomplete.js +1 -1
  621. package/dist/src/tui/tui-startup-resources.js +3 -3
  622. package/dist/src/tui/tui.js +6 -6
  623. package/dist/src/tunnel/gateway-lifecycle.js +1 -1
  624. package/dist/src/user-context/access-policy.js +2 -2
  625. package/dist/src/user-model/bootstrap.js +1 -1
  626. package/dist/src/user-model/capture/executor.js +2 -2
  627. package/dist/src/user-model/index.js +2 -2
  628. package/dist/src/user-model/usage-policy.js +1 -1
  629. package/dist/src/video-generation/artifact.js +3 -2
  630. package/dist/src/video-generation/drafts.js +2 -1
  631. package/dist/src/video-generation/repository.js +2 -1
  632. package/dist/src/video-generation/settings.js +2 -1
  633. package/dist/src/video-generation/worker.js +1 -1
  634. package/dist/src/voice/realtime/conversation-context.js +2 -2
  635. package/dist/src/voice/realtime/memory-context.js +4 -4
  636. package/dist/src/voice/realtime/omniRoute.js +1 -1
  637. package/dist/src/voice/realtime/runtime.js +3 -3
  638. package/dist/src/voice/realtime/user-context.js +1 -1
  639. package/dist/src/voice/stt/index.js +2 -2
  640. package/dist/src/voice/stt/preflight.js +1 -1
  641. package/dist/src/voice/stt/providers/alibaba-transcription.js +1 -1
  642. package/dist/src/voice/stt/providers/bailian-plan-transcription.js +1 -1
  643. package/dist/src/voice/stt/providers/xopc-cloud-transcription.js +1 -1
  644. package/dist/src/voice/stt/transcribe-core.js +1 -1
  645. package/dist/src/voice/tts/index.js +3 -3
  646. package/dist/src/voice/tts/merge-config.js +1 -1
  647. package/dist/src/voice/tts/payload.js +1 -1
  648. package/dist/src/voice/tts/providers/bailian-plan-speech.js +1 -1
  649. package/dist/src/voice/tts/providers/xopc-cloud-speech.js +1 -1
  650. package/dist/src/voice/tts/speak-core.js +2 -2
  651. package/dist/src/work-discovery/service.js +6 -6
  652. package/package.json +3 -1
  653. package/dist/gateway/static/root/assets/block-editor-Cvy3D_4T.css +0 -1
  654. package/dist/gateway/static/root/assets/confirm-dialog-MHCmEEUZ.js +0 -1
  655. package/dist/gateway/static/root/assets/gateway-realtime-store-CTWm23Qi.js +0 -1
  656. package/dist/gateway/static/root/assets/index-B_TGvH_k.css +0 -1
  657. package/dist/gateway/static/root/assets/keyboard-shortcuts-settings-DlGDLJI2.js +0 -1
  658. package/dist/gateway/static/root/assets/messages-C7QSnTdg.js +0 -3
  659. package/dist/gateway/static/root/assets/note-detail-panel-uc-5k3a2.js +0 -7
  660. package/dist/gateway/static/root/assets/note-image-lightbox-Bvjumefe.js +0 -1
  661. package/dist/gateway/static/root/assets/product-automation-feedback-DdFoCDzG.js +0 -1
  662. package/dist/gateway/static/root/assets/recording-upload-plrQDkLa.js +0 -1
  663. package/dist/gateway/static/root/assets/settings-advanced-gate-Cq4HDQu2.js +0 -1
  664. package/dist/gateway/static/root/assets/voice-input-shortcut-events-DN-_rY5a.js +0 -1
  665. package/dist/gateway/static/root/assets/workspace-editor-agent-store-CX8zX9eZ.js +0 -1
@@ -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{_ as i,f as a}from"./chunk-KS7C4IRE-DIIvxCDx.js";import{i as o,l as s,n as c,o as l}from"./locale-store-CHjsq5NR.js";import{t as u}from"./messages-C7QSnTdg.js";import{a as d,i as f,n as p,o as m,r as h,s as g,t as _}from"./dist-DlirbHVs.js";import{a as v,c as y,i as b,n as x,o as S,r as C,s as w,t as T}from"./service-recommendation-list-wfd0Mjtu.js";import{t as E}from"./chevron-down-ccbiQQz_.js";import{t as D}from"./chevron-right-BweFrslA.js";import{n as O,r as k,t as A}from"./popover-select-hRG1EzAY.js";import{t as j}from"./circle-alert-BEjgurr2.js";import{t as M}from"./circle-check-C23XjkUj.js";import{t as N}from"./circle-pause-CN9jYH2s.js";import{a as P,i as F,n as I,r as L,t as R}from"./connector-filters-Cfcx9EA2.js";import{t as z}from"./clock-3-DnrAnuyZ.js";import{t as B}from"./database-CjjeZfRG.js";import{t as V}from"./ellipsis-0k4rZLoy.js";import{t as ee}from"./external-link-DjqjBmc3.js";import{n as H}from"./secret-input-DsjfQmDn.js";import{t as te}from"./eye-CABVeTq0.js";import{t as ne}from"./key-round-DWbpyU2U.js";import{t as re}from"./loader-circle-CifKLtgG.js";import{a as U,c as ie,i as W,n as G,o as K,r as ae,s as oe,t as se}from"./install-connector-dialog-CntHi8Rh.js";import{t as q}from"./plug-DKYPEgkR.js";import{t as ce}from"./plus-Q2yW6OE7.js";import{t as le}from"./refresh-cw-BRlGaq2w.js";import{t as J}from"./save-DRDABU--.js";import{t as ue}from"./server-BlHCBjiE.js";import{t as de}from"./settings-uiTATseT.js";import{t as fe}from"./store-SzD1Jvgm.js";import{t as pe}from"./terminal-oKqqZdiG.js";import{t as me}from"./trash-2-DusmjVPV.js";import{t as Y}from"./wrench-DFb4r8bH.js";import{t as he}from"./x-B_N4OPjy.js";import{t as X}from"./cn-0WouolD0.js";import{t as ge}from"./skeleton-DzdOeGYz.js";import{i as _e}from"./vendor-swr-CdRzEUwF.js";import{n as ve,r as ye}from"./gateway-config-swr-BD-ams0X.js";import{t as Z}from"./button-C5tRaJxt.js";import{n as be}from"./copy-to-clipboard-HOJ79TWv.js";import{n as xe}from"./interaction-BdhHBbYa.js";import{A as Se,E as Ce,F as we,I as Te,L as Ee,M as De,N as Oe,O as ke,P as Ae,R as je,S as Me,_ as Ne,a as Pe,c as Fe,d as Ie,i as Le,j as Re,l as ze,m as Be,n as Ve,o as He,p as Ue,r as We,s as Ge,u as Ke,v as qe,w as Je,x as Ye,y as Xe,z as Ze}from"./connectors-api-CRGq-TSw.js";import{s as Qe}from"./form-field-width-DJw_jULe.js";import{n as $e}from"./electron-env-DHOGevH3.js";import{t as et}from"./page-tabs-DoYMKhVO.js";import{t as tt}from"./page-header-store-NP7MCIaP.js";import{r as nt}from"./extension-provider-D8_mIBI0.js";import{t as rt}from"./sliding-tab-list-CmcrqRzN.js";import{t as it}from"./confirm-dialog-MHCmEEUZ.js";import{l as at,m as ot,o as st,r as ct,t as lt}from"./dist-DaFr5KMw.js";import{t as ut}from"./connection-usage-guide-B9hoSOnN.js";import{t as dt}from"./capability-links-MZdYfPKx.js";import{t as ft}from"./capability-icon-CmvCZOJX.js";import{n as pt,t as mt}from"./capability-header-actions-Ck3ILShB.js";import{t as ht}from"./connector-service-page-e67KylnM.js";import{i as gt,n as _t,t as vt}from"./installed-connector-row-skeleton-BAe_utvG.js";import{t as yt}from"./number-input-El7Szeln.js";var Q=e(t(),1),bt=n(),$=r();function xt(e){let t=(0,bt.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(St),p=e.slice(0,2),m=Math.max(0,e.length-p.length),h=o.connect,g;t[11]!==n||t[12]!==o?(g=W(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)(Z,{type:`button`,variant:`secondary`,className:X(`h-8 justify-center px-2.5 text-xs font-medium`,e),onClick:()=>i(n),children:[(0,$.jsx)(ie,{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 bg-surface-panel p-4 transition-colors hover:bg-surface-panel-hover 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)(G,{connector:n}),t[18]=n,t[19]=b);let x;t[20]!==n||t[21]!==a?(x=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]=x):x=t[22];let S;t[23]===v?S=t[24]:(S=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]=S);let C;t[25]!==S||t[26]!==x?(C=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[x,S]}),t[25]=S,t[26]=x,t[27]=C):C=t[27];let w;t[28]!==C||t[29]!==b?(w=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[b,C]}),t[28]=C,t[29]=b,t[30]=w):w=t[30];let T;t[31]!==r||t[32]!==s?(T=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]=T):T=t[33];let E;t[34]!==r||t[35]!==o.connectedBadge?(E=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)(M,{className:`size-3`,"aria-hidden":!0}),o.connectedBadge]}):null,t[34]=r,t[35]=o.connectedBadge,t[36]=E):E=t[36];let D;t[37]!==T||t[38]!==E?(D=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start gap-2`,children:[T,E]}),t[37]=T,t[38]=E,t[39]=D):D=t[39],t[40]!==w||t[41]!==D?(l=(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[w,D]}),t[40]=w,t[41]=D,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 St(e){return!e.startsWith(`runtime.`)&&!e.startsWith(`auth.`)}var Ct=[`c0`,`c1`,`c2`,`c3`,`c4`,`c5`];function wt(e,t){return t.some(t=>t.connectorId===e.id)}var Tt=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`;function Et(){let e=(0,bt.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`div`,{className:X(`size-10 shrink-0 rounded-xl`,Tt)}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`div`,{className:`flex h-full min-h-[9.5rem] flex-col rounded-xl bg-surface-panel p-4 shadow-surface`,"aria-hidden":!0,children:(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 items-start gap-3`,children:[t,(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,$.jsx)(`div`,{className:X(`h-4 min-w-0 flex-1`,Tt)}),(0,$.jsx)(`div`,{className:X(`h-8 w-[4.5rem] shrink-0 rounded-lg`,Tt)})]}),(0,$.jsx)(`div`,{className:X(`h-3 w-full`,Tt)}),(0,$.jsx)(`div`,{className:X(`h-3 w-[88%]`,Tt)})]})]})}),e[1]=n):n=e[1],n}var Dt=(0,Q.memo)(function(e){let t=(0,bt.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=X(`touch-target flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50 data-[highlighted]:bg-surface-hover`,xe.transition),t[0]=m):m=t[0];let h=m,g;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(ce,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[1]=g):g=t[1];let _;t[2]===s?_=t[3]:(_=(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:s}),t[2]=s,t[3]=_);let v;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(E,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[4]=v):v=t[4];let y;t[5]!==s||t[6]!==_?(y=(0,$.jsx)(ot,{asChild:!0,children:(0,$.jsxs)(Z,{type:`button`,variant:`primary`,className:`shrink-0 gap-2`,"aria-label":s,children:[g,_,v]})}),t[5]=s,t[6]=_,t[7]=y):y=t[7];let b;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(fe,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[8]=b):b=t[8];let x;t[9]!==c||t[10]!==a?(x=(0,$.jsxs)(ct,{className:h,onSelect:a,children:[b,c]}),t[9]=c,t[10]=a,t[11]=x):x=t[11];let S;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,$.jsx)(Y,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[12]=S):S=t[12];let C;t[13]!==l||t[14]!==o?(C=(0,$.jsxs)(ct,{className:h,onSelect:o,children:[S,l]}),t[13]=l,t[14]=o,t[15]=C):C=t[15];let w;t[16]!==x||t[17]!==C?(w=(0,$.jsx)(st,{children:(0,$.jsxs)(lt,{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:[x,C]})}),t[16]=x,t[17]=C,t[18]=w):w=t[18];let T;t[19]!==w||t[20]!==y?(T=(0,$.jsxs)(at,{children:[y,w]}),t[19]=w,t[20]=y,t[21]=T):T=t[21];let D;t[22]===f?D=t[23]:(D=(0,$.jsx)(ht,{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)(V,{className:`size-4`,"aria-hidden":!0}),t[24]=O):O=t[24];let k;t[25]===d?k=t[26]:(k=(0,$.jsx)(ot,{asChild:!0,children:(0,$.jsx)(Z,{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 A;t[27]!==n||t[28]!==i||t[29]!==r?(A=n?(0,$.jsxs)(ct,{className:h,disabled:r,onSelect:n,children:[r?(0,$.jsx)(re,{className:`size-4 animate-spin text-fg-muted`,"aria-hidden":!0}):(0,$.jsx)(le,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),i]}):null,t[27]=n,t[28]=i,t[29]=r,t[30]=A):A=t[30];let j,M;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(j=()=>p(!0),M=(0,$.jsx)(de,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),t[31]=j,t[32]=M):(j=t[31],M=t[32]);let N;t[33]===u?N=t[34]:(N=(0,$.jsxs)(ct,{className:h,onSelect:j,children:[M,u]}),t[33]=u,t[34]=N);let P;t[35]!==A||t[36]!==N?(P=(0,$.jsx)(st,{children:(0,$.jsxs)(lt,{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:[A,N]})}),t[35]=A,t[36]=N,t[37]=P):P=t[37];let F;t[38]!==k||t[39]!==P?(F=(0,$.jsxs)(at,{children:[k,P]}),t[38]=k,t[39]=P,t[40]=F):F=t[40];let I;return t[41]!==T||t[42]!==D||t[43]!==F?(I=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2`,children:[T,D,F]}),t[41]=T,t[42]=D,t[43]=F,t[44]=I):I=t[44],I});function Ot(e=``,t=``){return{clientKey:crypto.randomUUID(),key:e,value:t}}var kt=/^([^:=]+)[:=](.*)$/;function At(e){let t=e.trim();if(!t)return null;try{let e=JSON.parse(t);if(e&&typeof e==`object`&&!Array.isArray(e))return Mt(e)}catch{}let n=[];for(let e of t.split(/\r?\n/)){let t=e.trim();if(!t)continue;let r=kt.exec(t);r&&n.push(Ot(r[1].trim(),r[2].trim()))}return n.length>0?n:null}function jt(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 Mt(e){if(!e||typeof e!=`object`)return[Ot()];let t=Object.entries(e).map(([e,t])=>typeof t==`object`&&t&&!Array.isArray(t)?{...Ot(e),reference:t}:Ot(e,t==null?``:String(t)));return t.length>0?t:[Ot()]}function Nt(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 Pt(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 Ft(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 It(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=Pt(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=jt(e.envEntries);r&&(t.env=r)}else e.envJson.trim()&&(t.env=Ft(e.envJson));delete t.oauth,delete t.auth}else{t.type=e.transport===`sse`?`sse`:`http`,t.url=e.url.trim();let n=jt(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 Lt(e,t){let n=t.oauth;return{clientKey:e,id:e,displayName:typeof t.displayName==`string`?t.displayName:``,transport:typeof t.url==`string`?t.type===`sse`?`sse`:`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:Mt(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 Rt(e,t){let n=`mcp`;try{n=e.transport===`stdio`?e.command.split(/[\\/]/).pop()||n:new URL(e.url).hostname}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 zt(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 Bt(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=Lt(e,n);return r.clientKey=crypto.randomUUID(),r.url&&=zt(r.url),r})}function Vt(e=``){return{clientKey:crypto.randomUUID(),id:e,transport:`streamable-http`,command:``,argsText:``,envJson:``,cwd:``,url:``,headers:[],oauthClientId:``,timeout:void 0,exposure:`codemode`,extra:{}}}function Ht(e){let t=e?.mcp?.servers??{};return{servers:Object.entries(t).filter(([,e])=>!Nt(e)).map(([e,t])=>Lt(e,t)).sort((e,t)=>e.id.localeCompare(t.id))}}function Ut(e){return It(e)}async function Wt(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 Gt(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:It(e)})})).payload}async function Kt(e,t){return(await l(o(`/api/mcp/drafts/${encodeURIComponent(e)}/probe`),{method:`POST`,signal:AbortSignal.any([t,AbortSignal.timeout(95e3)])})).payload}async function qt(e){await l(o(`/api/mcp/drafts/${encodeURIComponent(e)}`),{method:`DELETE`})}async function Jt(e,t=!1){let n=await l(o(`/api/mcp/drafts/${encodeURIComponent(e)}/commit`),{method:`POST`,body:JSON.stringify({enable:t})});return ve(),n.payload}async function Yt(e){return(await l(o(`/api/mcp/drafts/${encodeURIComponent(e)}/auth`),{method:`POST`})).payload}async function Xt(e,t){return(await l(o(`/api/mcp/drafts/${encodeURIComponent(e)}/auth`),{signal:t})).payload}async function Zt(e){await l(o(`/api/mcp/drafts/${encodeURIComponent(e)}/auth`),{method:`DELETE`})}async function Qt(e,t){await l(o(`/api/mcp/drafts/${encodeURIComponent(e)}/auth/redirect`),{method:`POST`,body:JSON.stringify({url:t})})}async function $t(e,t){return(await l(o(`/api/mcp/drafts/${encodeURIComponent(e)}/tools`),{signal:t})).payload.tools}async function en(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 tn(e){let t=await l(o(`/api/mcp/servers/${encodeURIComponent(e.id)}`),{method:`DELETE`,body:JSON.stringify({expectedServer:e.extra})});return ve(),t.payload}function nn(e){let t=(0,bt.c)(114),{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,v]=(0,Q.useState)(l),[y,b]=(0,Q.useState)(!0),[x,S]=(0,Q.useState)(``),[C,w]=(0,Q.useState)(``),[T,E]=(0,Q.useState)(0),D=(0,Q.useRef)(!1),O;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?(O=()=>{let e=new AbortController,t=!0;return b(!0),S(``),v([]),(a?$t(a,e.signal):Wt(n,e.signal)).then(e=>{t&&v(e)}).catch(e=>{let n=e?.status;t&&S(n===401?o.setupGatewayUnauthorized:n===403?o.setupAccessDenied:n===429?o.setupRateLimited:n===404||n===409?o.setupConflict:o.toolsLoadFailed)}).finally(()=>{t&&b(!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]=O):O=t[8];let k;t[9]!==a||t[10]!==T||t[11]!==n||t[12]!==o?(k=[n,a,T,o],t[9]=a,t[10]=T,t[11]=n,t[12]=o,t[13]=k):k=t[13],(0,Q.useEffect)(O,k);let A,j,M,N,P,F,I,L,R,z,B,V,ee,H;if(t[14]!==r||t[15]!==a||t[16]!==x||t[17]!==y||t[18]!==s||t[19]!==c||t[20]!==C||t[21]!==i||t[22]!==n||t[23]!==o.exposureLabels||t[24]!==o.setupConfigure||t[25]!==o.toolDetails||t[26]!==o.toolsClearSearch||t[27]!==o.toolsDialogSearchEmpty||t[28]!==o.toolsDialogSearchPlaceholder||t[29]!==o.toolsDialogSubtitle||t[30]!==o.toolsDialogTitle||t[31]!==o.toolsEmpty||t[32]!==o.toolsLoading||t[33]!==o.toolsRetryHint||t[34]!==o.toolsSearchSummary||t[35]!==o.toolsTitle||t[36]!==u){let e=C.trim().toLowerCase(),l;if(t[51]!==n){let e;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(e=/-/g,t[53]=e):e=t[53],l=n.replace(e,`_`),t[51]=n,t[52]=l}else l=t[52];let p=`mcp__${l}__`,v=u.filter(t=>`${t.name} ${t.description}`.toLowerCase().includes(e));M=_,I=!0,t[54]===s?L=t[55]:(L=e=>{e||s()},t[54]=s,t[55]=L),j=m,t[56]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,$.jsx)(d,{className:`fixed inset-0 z-[60] bg-scrim`}),t[56]=F):F=t[56],A=h,t[57]===i?H=t[58]:(H=e=>{(D.current||i)&&e.preventDefault(),!D.current&&i?.isConnected&&i.focus()},t[57]=i,t[58]=H),N=`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 b;t[59]===o.toolsDialogTitle?b=t[60]:(b=(0,$.jsx)(g,{className:`font-semibold`,children:o.toolsDialogTitle}),t[59]=o.toolsDialogTitle,t[60]=b);let S;t[61]!==r||t[62]!==x||t[63]!==y||t[64]!==n||t[65]!==o.toolsDialogSubtitle||t[66]!==u.length?(S=y||x?r||n:o.toolsDialogSubtitle.replace(`{{serverId}}`,r||n).replace(`{{count}}`,String(u.length)),t[61]=r,t[62]=x,t[63]=y,t[64]=n,t[65]=o.toolsDialogSubtitle,t[66]=u.length,t[67]=S):S=t[67];let T;t[68]===S?T=t[69]:(T=(0,$.jsx)(f,{className:`mt-1 break-words text-sm text-fg-muted`,children:S}),t[68]=S,t[69]=T);let E;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(E=e=>w(e.target.value),t[70]=E):E=t[70];let O;t[71]!==C||t[72]!==o.toolsDialogSearchPlaceholder?(O=(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:C,onChange:E,placeholder:o.toolsDialogSearchPlaceholder,"aria-label":o.toolsDialogSearchPlaceholder}),t[71]=C,t[72]=o.toolsDialogSearchPlaceholder,t[73]=O):O=t[73];let k=e&&!y&&!x?(0,$.jsx)(`p`,{role:`status`,className:`mt-2 text-xs text-fg-muted`,children:o.toolsSearchSummary.replace(`{{visible}}`,String(v.length)).replace(`{{count}}`,String(u.length))}):null;t[74]!==b||t[75]!==T||t[76]!==O||t[77]!==k?(P=(0,$.jsxs)(`div`,{className:`shrink-0 border-b border-edge p-5`,children:[b,T,O,k]}),t[74]=b,t[75]=T,t[76]=O,t[77]=k,t[78]=P):P=t[78],R=`min-h-0 flex-1 overflow-y-auto p-5`,z=y,t[79]!==o.toolsTitle||t[80]!==u.length?(B=o.toolsTitle.replace(`{{count}}`,String(u.length)),t[79]=o.toolsTitle,t[80]=u.length,t[81]=B):B=t[81],V=!y&&!x&&u.length&&!e?(0,$.jsx)(`div`,{className:`mb-5`,children:(0,$.jsx)(ut,{target:{kind:`mcp`,id:n,name:r||n},preview:!!a,onStart:s})}):null,ee=y?(0,$.jsx)(`div`,{role:`status`,"aria-label":o.toolsLoading,className:`space-y-3`,children:[0,1,2].map(an)}):x?(0,$.jsxs)(`div`,{role:`alert`,className:`space-y-3`,children:[(0,$.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-sm text-danger`,children:x}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:o.toolsRetryHint}),c?(0,$.jsx)(Z,{variant:`secondary`,onClick:()=>{D.current=!0,c()},children:o.setupConfigure}):null]}):v.length?(0,$.jsx)(`div`,{className:`space-y-3`,children:v.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(p)?e.name.slice(p.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)(Z,{variant:`secondary`,onClick:()=>w(``),children:o.toolsClearSearch}):null]}),t[14]=r,t[15]=a,t[16]=x,t[17]=y,t[18]=s,t[19]=c,t[20]=C,t[21]=i,t[22]=n,t[23]=o.exposureLabels,t[24]=o.setupConfigure,t[25]=o.toolDetails,t[26]=o.toolsClearSearch,t[27]=o.toolsDialogSearchEmpty,t[28]=o.toolsDialogSearchPlaceholder,t[29]=o.toolsDialogSubtitle,t[30]=o.toolsDialogTitle,t[31]=o.toolsEmpty,t[32]=o.toolsLoading,t[33]=o.toolsRetryHint,t[34]=o.toolsSearchSummary,t[35]=o.toolsTitle,t[36]=u,t[37]=A,t[38]=j,t[39]=M,t[40]=N,t[41]=P,t[42]=F,t[43]=I,t[44]=L,t[45]=R,t[46]=z,t[47]=B,t[48]=V,t[49]=ee,t[50]=H}else A=t[37],j=t[38],M=t[39],N=t[40],P=t[41],F=t[42],I=t[43],L=t[44],R=t[45],z=t[46],B=t[47],V=t[48],ee=t[49],H=t[50];let te;t[82]!==R||t[83]!==z||t[84]!==B||t[85]!==V||t[86]!==ee?(te=(0,$.jsxs)(`div`,{className:R,"aria-busy":z,"aria-label":B,children:[V,ee]}),t[82]=R,t[83]=z,t[84]=B,t[85]=V,t[86]=ee,t[87]=te):te=t[87];let ne;t[88]===Symbol.for(`react.memo_cache_sentinel`)?(ne=()=>E(rn),t[88]=ne):ne=t[88];let re;t[89]!==y||t[90]!==o.refreshTools?(re=(0,$.jsx)(Z,{variant:`secondary`,disabled:y,onClick:ne,children:o.refreshTools}),t[89]=y,t[90]=o.refreshTools,t[91]=re):re=t[91];let U;t[92]!==s||t[93]!==o.toolsDialogClose?(U=(0,$.jsx)(p,{asChild:!0,children:(0,$.jsx)(Z,{onClick:s,children:o.toolsDialogClose})}),t[92]=s,t[93]=o.toolsDialogClose,t[94]=U):U=t[94];let ie;t[95]!==re||t[96]!==U?(ie=(0,$.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge p-4`,children:[re,U]}),t[95]=re,t[96]=U,t[97]=ie):ie=t[97];let W;t[98]!==A||t[99]!==N||t[100]!==P||t[101]!==te||t[102]!==ie||t[103]!==H?(W=(0,$.jsxs)(A,{onCloseAutoFocus:H,className:N,children:[P,te,ie]}),t[98]=A,t[99]=N,t[100]=P,t[101]=te,t[102]=ie,t[103]=H,t[104]=W):W=t[104];let G;t[105]!==j||t[106]!==F||t[107]!==W?(G=(0,$.jsxs)(j,{children:[F,W]}),t[105]=j,t[106]=F,t[107]=W,t[108]=G):G=t[108];let K;return t[109]!==M||t[110]!==I||t[111]!==L||t[112]!==G?(K=(0,$.jsx)(M,{open:I,onOpenChange:L,children:G}),t[109]=M,t[110]=I,t[111]=L,t[112]=G,t[113]=K):K=t[113],K}function rn(e){return e+1}function an(e){return(0,$.jsx)(ge,{className:`h-24 w-full`},e)}function on(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 sn({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=on(e),_=e.extra.enabled===!1,v=_?N:t?M:z,y=e.transport===`stdio`?pe:ue,b=_?n.setupDisabled:t?r.customCheckSucceeded:r.customUnchecked,x=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 bg-surface-panel p-4 transition-colors hover:bg-surface-panel-hover 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:x?r.customLastChecked.replace(`{{time}}`,x):void 0,"aria-label":x?`${b} · ${r.customLastChecked.replace(`{{time}}`,x)}`:b,className:X(`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)(Z,{variant:`ghost`,className:`h-8 px-2 py-1 text-xs`,onClick:i,children:n.setupConfigure}),(0,$.jsx)(Z,{ref:u,variant:`secondary`,className:`h-8 px-2 py-1 text-xs shadow-none sm:shadow-none`,disabled:_,onClick:()=>l(!0),children:o===`zh`?`用法与工具`:`Usage & tools`}),(0,$.jsxs)(at,{children:[(0,$.jsx)(ot,{asChild:!0,children:(0,$.jsx)(Z,{variant:`ghost`,className:`size-8 p-0`,"aria-label":r.customManage.replace(`{{name}}`,h),title:r.customManage.replace(`{{name}}`,h),children:(0,$.jsx)(V,{className:`size-4`,"aria-hidden":!0})})}),(0,$.jsx)(st,{children:(0,$.jsx)(lt,{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)(ct,{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)(me,{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)(nn,{serverId:e.id,displayName:e.displayName,returnFocusTo:u.current,t:n,onClose:()=>l(!1),onConfigure:()=>{l(!1),i()}}):null,(0,$.jsx)(it,{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 cn(e){let t=(0,bt.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)(ce,{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)(Z,{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)(sn,{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 ln(e){return e.format===`agent-plugin`&&!!e.pluginId&&(!!e.setup?.authorizations?.length||e.authorizationStatus===`required`||!!e.components?.mcp.some(e=>e.type!==`stdio`))}function un(e){let t=(0,bt.c)(51),{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,g;t[15]===n.setup?.authorizations?g=t[16]:(g=n.setup?.authorizations??[],t[15]=n.setup?.authorizations,t[16]=g);let _=g,v=_.length===1?_[0].title:n.name,y=l||!u&&(d||n.readiness===`blocked`||n.readiness===`degraded`),b=l?z:u?N:y?j:M,x=n.branding?.iconUrl,S;t[17]===x?S=t[18]:(S=(0,$.jsx)(ft,{iconUrl:x,fallback:q,className:`size-9`}),t[17]=x,t[18]=S);let C;t[19]===v?C=t[20]:(C=(0,$.jsx)(`span`,{className:`block truncate text-sm font-semibold text-fg`,title:v,children:v}),t[19]=v,t[20]=C);let w=y?`text-amber-700 dark:text-amber-300`:u?`text-fg-muted`:`text-emerald-700 dark:text-emerald-300`,T;t[21]===w?T=t[22]:(T=X(`mt-1 inline-flex items-center gap-1 text-[11px]`,w),t[21]=w,t[22]=T);let E;t[23]===b?E=t[24]:(E=(0,$.jsx)(b,{className:`size-3.5`,"aria-hidden":!0}),t[23]=b,t[24]=E);let O;t[25]!==p||t[26]!==T||t[27]!==E?(O=(0,$.jsxs)(`span`,{className:T,children:[E,p]}),t[25]=p,t[26]=T,t[27]=E,t[28]=O):O=t[28];let k;t[29]!==O||t[30]!==C?(k=(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[C,O]}),t[29]=O,t[30]=C,t[31]=k):k=t[31];let A;t[32]!==k||t[33]!==S?(A=(0,$.jsxs)(`span`,{className:`flex w-full min-w-0 items-start gap-3`,children:[S,k]}),t[32]=k,t[33]=S,t[34]=A):A=t[34];let P=n.name,F;t[35]===c?F=t[36]:(F=c(`由插件提供`,`Provided by plugin`),t[35]=c,t[36]=F);let I;t[37]!==n.name||t[38]!==F?(I=(0,$.jsxs)(`span`,{className:`mt-2 block w-full truncate text-xs leading-5 text-fg-muted`,title:P,children:[F,` · `,n.name]}),t[37]=n.name,t[38]=F,t[39]=I):I=t[39];let L=y?`text-accent-fg`:`text-fg-muted`,R;t[40]===L?R=t[41]:(R=X(`mt-auto flex w-full items-center justify-end gap-1 pt-2 text-xs`,L),t[40]=L,t[41]=R);let B;t[42]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,$.jsx)(D,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[42]=B):B=t[42];let V;t[43]!==h||t[44]!==R?(V=(0,$.jsxs)(`span`,{className:R,children:[h,B]}),t[43]=h,t[44]=R,t[45]=V):V=t[45];let ee;return t[46]!==i||t[47]!==A||t[48]!==I||t[49]!==V?(ee=(0,$.jsxs)(`button`,{type:`button`,onClick:i,className:`flex min-h-[8.75rem] w-full min-w-0 flex-col rounded-xl bg-surface-panel p-4 text-left transition-colors hover:bg-surface-panel-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,children:[A,I,V]}),t[46]=i,t[47]=A,t[48]=I,t[49]=V,t[50]=ee):ee=t[50],ee}function dn(e){let t=e.connectedAt?Date.parse(e.connectedAt):0;return Number.isFinite(t)?t:0}function fn(e,t){return e.status===`active`&&t.status!==`active`?-1:e.status!==`active`&&t.status===`active`?1:e.isCurrentAuthorization===t.isCurrentAuthorization?dn(t)-dn(e):e.isCurrentAuthorization?-1:1}function pn(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(fn);return{key:e,primary:n[0],authorizations:n}}).sort((e,t)=>fn(e.primary,t.primary))}var mn=X(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,Qe);function hn(e){return e.materialized.type===`composio`?e.materialized.toolkit:null}function gn(e,t){return e===`write`?t.composioScopeWrite:e===`admin`?t.composioScopeAdmin:t.composioScopeRead}function _n(e,t,n){return e.status===`connected`?U(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 vn(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 yn(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 bn({instance:e,t,onChanged:n}){let r=hn(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,_]=(0,Q.useState)(null),[v,y]=(0,Q.useState)(null),[b,x]=(0,Q.useState)([]),[S,C]=(0,Q.useState)({}),[w,T]=(0,Q.useState)(`read`),[E,D]=(0,Q.useState)(!1),[A,N]=(0,Q.useState)(null),[P,F]=(0,Q.useState)(!1),[I,L]=(0,Q.useState)(null),[R,z]=(0,Q.useState)(null),[B,V]=(0,Q.useState)(!1),[ee,H]=(0,Q.useState)(!1),[te,ie]=(0,Q.useState)(!1),W=(0,Q.useRef)(0),G=(0,Q.useRef)(0),K=(0,Q.useMemo)(()=>pn(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;D(!0),N(null);let t=++W.current;try{let e=(await Promise.allSettled([oe(Ne()).then(e=>{t===W.current&&(o(e.filter(e=>e.toolkit.toLowerCase()===r.toLowerCase())),V(!0))}),oe(Ie(r)).then(e=>{t===W.current&&T(e)}),oe(Ke(r)).then(e=>{t===W.current&&(p(e.policy),h(e.agents))})])).find(e=>e.status===`rejected`);t===W.current&&e?.status===`rejected`&&N(String(e.reason instanceof Error?e.reason.message:e.reason))}finally{t===W.current&&D(!1)}},[e.materialized,r,oe]);(0,Q.useEffect)(()=>(se(),()=>{W.current++}),[se]);let q=(0,Q.useCallback)(async()=>{if(!r)return;let e=++G.current;ie(!0),F(!1);let t=t=>n=>{e===G.current&&t(n)},n=await Promise.allSettled([oe(qe(r)).then(t(l)),oe(Xe(20)).then(t(e=>d(e.filter(e=>!e.toolkit||e.toolkit.toLowerCase()===r.toLowerCase())))),oe(Ue(r)).then(t(y)),oe(ze(r)).then(t(_))]);e===G.current&&(F(n.some(e=>e.status===`rejected`)),ie(!1))},[r,oe]);(0,Q.useEffect)(()=>(ee&&q(),()=>{G.current++}),[ee,q]),(0,Q.useEffect)(()=>{let e=!1,t=pn(a).map(e=>e.primary).filter(e=>e.supportsLearning&&e.accountId);if(t.length)return oe(Ye()).then(t=>{e||x(t)}).catch(()=>{}),Promise.allSettled(t.map(async e=>[e.accountId,await oe(Be(e.accountId))])).then(t=>{e||C(Object.fromEntries(t.flatMap(e=>e.status===`fulfilled`?[e.value]:[])))}),()=>{e=!0}},[a,oe]);let ce=(0,Q.useCallback)(async i=>{if(!r)return;let a=$e()?null:window.open(`about:blank`,`_blank`);a&&(a.opener=null),D(!0),N(null);try{if(!$e()&&!a)throw Error(`Allow popups to open the authorization page.`);let t=await Re(e.connectorId,i);if(!t.authorizationUrl)throw Error(`The authorization provider did not return an authorization URL.`);if($e()){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 Ze(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(ae(e,t))}finally{a?.close(),D(!1)}},[e.connectorId,se,n,t,r]),J=(0,Q.useCallback)(async t=>{D(!0),N(null);try{await Ee(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{D(!1)}},[e.config,e.instanceId,se,n]),ue=async e=>{let t=$e()?null:window.open(`about:blank`,`_blank`);t&&(t.opener=null),N(null);try{let n=await Fe(e.id);if(n.authorizationUrl)if($e())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))}},de=(0,Q.useCallback)(async e=>{if(r){T(e),N(null);try{await ke(r,e)}catch(e){N(e instanceof Error?e.message:String(e)),await se()}}},[se,r]),fe=(0,Q.useCallback)(async e=>{if(r){N(null);try{p(await Te(r,e))}catch(e){N(e instanceof Error?e.message:String(e))}}},[r]),pe=(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];fe({allowedAgentIds:n})},[fe,f]),Y=(0,Q.useCallback)(async e=>{D(!0),N(null);try{await e(),await se()}catch(e){N(e instanceof Error?e.message:String(e))}finally{D(!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 he=K.filter(e=>e.primary.status===`active`).length,_e=he>0?t.composioAddAccount:t.composioConnectAccount,ve=B&&he>0,ye=v?.requiresCustomAuthConfig===!0,be=v?.authConfigs.filter(e=>e.status===`ENABLED`&&e.isEnabledForToolRouter)??[];return(0,$.jsxs)(`div`,{className:`space-y-5`,children:[(0,$.jsxs)(`section`,{className:`flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`span`,{className:X(`inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-xs font-medium`,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)(M,{className:`size-3.5`}):(0,$.jsx)(j,{className:`size-3.5`}),ve?t.connectionReady:B||A?t.connectionNeedsSetup:t.connectionChecking]}),B&&(0,$.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:U(t.composioAccountCount,{count:String(K.length)})})]}),(0,$.jsxs)(Z,{variant:`primary`,className:`shrink-0`,disabled:E,onClick:()=>void ce(),children:[E?(0,$.jsx)(re,{className:`size-4 animate-spin`}):(0,$.jsx)(ne,{className:`size-4`}),_e]})]}),A?(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:A}),(0,$.jsx)(Z,{variant:`secondary`,disabled:E,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:_n(g,he,t)}),g.recovery===`none`?null:(0,$.jsx)(Z,{variant:`secondary`,disabled:E,onClick:()=>void(g.recovery===`retry`?se():ce()),children:g.recovery===`retry`?t.composioRetry:t.composioReconnectAccount})]}):null,ye&&be.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:w===`read`?t.composioAccessReadHint:w===`admin`?t.composioAccessAdminHint:t.composioAccessWriteHint})]}),(0,$.jsxs)(O,{value:w,onChange:e=>void de(e.currentTarget.value),children:[(0,$.jsx)(k,{value:`read`,children:t.composioAccessReadOnly}),(0,$.jsx)(k,{value:`write`,children:t.composioAccessReadWrite}),w===`admin`?(0,$.jsx)(k,{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)(O,{value:f.confirmationPolicy,onChange:e=>void fe({confirmationPolicy:e.currentTarget.value}),children:[(0,$.jsx)(k,{value:`writes`,children:t.composioConfirmWrites}),(0,$.jsx)(k,{value:`always`,children:t.composioConfirmAlways}),f.confirmationPolicy===`never`?(0,$.jsx)(k,{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:X(`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 fe({allowedAgentIds:[]}),children:t.composioAllowedAgentsAllOption}),m.map(e=>(0,$.jsx)(`button`,{type:`button`,className:X(`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:()=>pe(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:E,onChange:e=>void fe({selectedAccountIds:e.currentTarget.checked?null:[]})}),i?`所有账号(包括以后新增)`:`All accounts, including new ones`]}),f.selectedAccountIds!==null&&K.map(({primary:e})=>e.accountId&&(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,disabled:E,checked:f.selectedAccountIds.includes(e.accountId),onChange:t=>void fe({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}),B&&(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:U(t.composioAccountCount,{count:String(K.length)})})]}),(0,$.jsxs)(Z,{variant:`ghost`,className:`h-8 px-2 text-xs`,disabled:E,onClick:()=>void se(),children:[(0,$.jsx)(le,{className:X(`size-3.5`,E&&`animate-spin`)}),t.refresh]})]}),K.length?(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-xl border border-edge bg-surface-base`,children:K.map(e=>{let r=e.primary,a=b.find(e=>r.accountId?e.accountId===r.accountId:e.connectionId===r.id),o=r.accountId?S[r.accountId]:void 0;return(0,$.jsxs)(`article`,{className:`px-4 py-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col items-start justify-between gap-3 sm:flex-row`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:(0,$.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:r.alias??r.workspace??r.accountEmail??r.username??t.composioUnnamedAuthorization})}),(0,$.jsx)(`p`,{className:`mt-1 break-all text-xs text-fg-muted`,children:r.accountEmail??r.username??r.workspace??r.accountId}),r.backendLabel&&(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:r.backendLabel}),(0,$.jsx)(`p`,{className:X(`mt-1 text-xs`,r.status===`active`?`text-emerald-700 dark:text-emerald-300`:`text-amber-700 dark:text-amber-300`),children:r.accountEnabled===!1?i?`已暂停`:`Paused`:vn(r.status,t)}),a?(0,$.jsx)(`p`,{className:X(`mt-1 text-xs`,a.status===`failed`?`text-red-600`:`text-fg-subtle`),children:U(t.connectorLearningStatus,{status:yn(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)(Z,{variant:`secondary`,className:`h-8 px-2.5 text-xs`,onClick:()=>void ue(r),children:i?`继续授权`:`Continue authorization`}),r.accountId&&(0,$.jsx)(Z,{variant:`ghost`,className:`h-8 px-2.5 text-xs text-danger`,disabled:E,onClick:()=>z(r.accountId),children:i?`断开`:`Disconnect`}),r.accountId&&r.status!==`active`&&(0,$.jsx)(Z,{variant:`secondary`,className:`h-8 px-2.5 text-xs`,disabled:E,onClick:()=>void ce(r.accountId),children:t.composioReconnectAccount}),r.accountId&&(0,$.jsx)(Z,{variant:`secondary`,className:`h-8 px-2.5 text-xs`,disabled:E,onClick:()=>void Y(()=>Ae(r.accountId,{enabled:r.accountEnabled===!1})),children:r.accountEnabled===!1?i?`启用`:`Enable`:i?`暂停`:`Pause`}),r.supportsLearning&&r.status===`active`&&r.accountEnabled!==!1?(0,$.jsxs)(Z,{variant:`secondary`,className:`h-8 shrink-0 px-2.5 text-xs`,disabled:E,onClick:()=>void Y(async()=>{if(!r.accountId)throw Error(`Connector account is unavailable.`);await Se(r.accountId),await n?.()}),children:[(0,$.jsx)(le,{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:E,checked:r.allowedAgentIds==null,onChange:e=>void Y(()=>Ae(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:E,checked:r.allowedAgentIds.includes(e.id),onChange:t=>{let n=t.currentTarget.checked;Y(()=>Ae(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:E,onChange:e=>void Y(()=>je(r.accountId,{scanEnabled:e.currentTarget.checked}))}),t.connectorScheduledScan]}),o.scanEnabled?(0,$.jsxs)(`label`,{className:`sm:col-span-2`,children:[t.connectorScanInterval,(0,$.jsxs)(O,{className:`mt-1`,value:String(o.intervalMinutes??30),disabled:E,onChange:e=>void Y(()=>je(r.accountId,{intervalMinutes:Number(e.currentTarget.value)})),children:[(0,$.jsxs)(k,{value:`5`,children:[`5 `,t.connectorMinutes]}),(0,$.jsxs)(k,{value:`15`,children:[`15 `,t.connectorMinutes]}),(0,$.jsxs)(k,{value:`30`,children:[`30 `,t.connectorMinutes]}),(0,$.jsxs)(k,{value:`60`,children:[`60 `,t.connectorMinutes]})]})]}):null]}):null,(0,$.jsxs)(`label`,{className:`block`,children:[t.composioAccountAlias,(0,$.jsx)(`input`,{className:X(mn,`mt-1 h-8 py-1 text-xs`),defaultValue:r.alias??``,onBlur:e=>{e.currentTarget.value!==(r.alias??``)&&Y(()=>we(r.id,{alias:e.currentTarget.value}))}})]}),(0,$.jsx)(`div`,{className:`space-y-2`,children:e.authorizations.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`p`,{className:`min-w-0 break-all font-mono text-fg-subtle`,children:[t.composioAuthorizationId,`: `,e.providerConnectionId]}),(0,$.jsx)(Z,{variant:`ghost`,className:`size-7 shrink-0 p-0 text-danger`,title:t.composioRevoke,disabled:E,onClick:()=>L(e.id),children:(0,$.jsx)(me,{className:`size-3.5`})})]},e.id))}),(0,$.jsx)(`div`,{className:`flex justify-end gap-1`,children:(0,$.jsx)(Z,{variant:`ghost`,className:`size-8 p-0`,title:t.refresh,disabled:E,onClick:()=>void Y(()=>Me(r.id)),children:(0,$.jsx)(le,{className:`size-4`})})})]})]})]},e.key)})}):E&&!B?(0,$.jsxs)(`div`,{"aria-busy":`true`,"aria-label":t.connectionChecking,className:`space-y-3`,children:[(0,$.jsx)(ge,{className:`h-16 w-full`}),(0,$.jsx)(ge,{className:`h-16 w-full`})]}):B?(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=>H(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:[te?(0,$.jsx)(ge,{"aria-label":t.connectionChecking,className:`h-16 w-full`}):null,P?(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)(Z,{variant:`ghost`,disabled:te,onClick:()=>void q(),children:t.composioRetry})]}):null,v?.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:ye?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)(O,{className:`mt-3`,value:typeof e.config?.authConfigId==`string`?e.config.authConfigId:``,disabled:E,onChange:e=>void J(e.currentTarget.value),children:[ye?null:(0,$.jsx)(k,{value:``,children:t.composioAuthConfigManaged}),ye&&typeof e.config?.authConfigId!=`string`?(0,$.jsx)(k,{value:``,disabled:!0,children:t.composioAuthConfigSelect}):null,be.map(e=>(0,$.jsxs)(k,{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:[gn(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)(it,{open:R!==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=R;z(null),e&&Y(()=>Ve(e))},onCancel:()=>z(null)}),(0,$.jsx)(it,{open:I!==null,title:t.composioRevoke,description:t.composioRevokeConfirm,confirmLabel:t.composioRevoke,cancelLabel:t.modalCancel,destructive:!0,onConfirm:()=>{let e=I;L(null),e&&Y(()=>Ce(e))},onCancel:()=>L(null)})]})}var xn=X(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,Qe);function Sn(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 Cn(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 wn({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),[v,y]=(0,Q.useState)(!1),[b,x]=(0,Q.useState)(null),[S,C]=(0,Q.useState)(()=>Sn(t,e)),[w,T]=(0,Q.useState)(null),[E,D]=(0,Q.useState)(!1),[O,k]=(0,Q.useState)(null),A=t?.setup.config??[],j=(e.materialized.type===`mcp`||e.materialized.type===`memorySource`)&&A.length>0&&(t?.setup.secrets??[]).length===0,M=e.materialized.type===`mcp`,N=e.materialized.type===`composio`,P=e.materialized.type===`memorySource`,F=t?W(t,i):null,I=(0,Q.useCallback)(async()=>{D(!0),T(null);try{let t=await Oe(e.instanceId);k(t),t.ok||T(t.error??t.action??i.healthStatusLabels[t.status]),await r()}catch(e){T(e instanceof Error?e.message:String(e))}finally{D(!1)}},[e.instanceId,r,i.healthStatusLabels]),L=(0,Q.useCallback)(async()=>{o(!0),T(null);try{await Je(e.instanceId),await r(),n()}catch(e){T(e instanceof Error?e.message:String(e)),o(!1)}},[e.instanceId,r,n]),R=(0,Q.useCallback)(async()=>{if(!(!t||!j)){u(!0),T(null);try{let n={};for(let e of t.setup.config??[]){let t=Cn(e.type,S[e.key]??``);t!==void 0&&(n[e.key]=t)}await Ee(e.instanceId,{config:n}),await r()}catch(e){T(e instanceof Error?e.message:String(e))}finally{u(!1)}}},[S,t,e.instanceId,r,j]),z=(0,Q.useCallback)(async()=>{y(!0),x(null),T(null);try{let t=await De(e.connectorId);x(t.recordIds.length),await r()}catch(e){T(e instanceof Error?e.message:String(e))}finally{y(!1)}},[e.connectorId,r]);return(0,$.jsxs)(_,{open:!0,onOpenChange:e=>{e||n()},children:[(0,$.jsxs)(m,{children:[(0,$.jsx)(d,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(h,{className:X(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,N?`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)(G,{connector:t,size:`lg`}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(g,{className:`text-base font-semibold text-fg`,children:e.displayName}),(0,$.jsx)(f,{className:`mt-1 text-sm text-fg-muted`,children:F??(e.materialized.type===`mcp`?U(i.mcpServerRuntime,{serverId:e.materialized.serverId}):U(i.runtimeLabel,{runtime:e.materialized.type}))})]})]}),(0,$.jsx)(p,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,className:X(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,xe.focusRingPanel),"aria-label":i.modalClose,children:[(0,$.jsx)(he,{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:[w?(0,$.jsx)(`p`,{className:`mb-4 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:w}):null,e.enabled&&(O?O.ok:e.connectionStatus===`connected`||e.status===`connected`||e.usage.lastHealthStatus===`ok`)?(0,$.jsx)(`div`,{className:`mb-5`,children:(0,$.jsx)(ut,{target:{kind:`connector`,id:e.connectorId,name:e.displayName},onStart:n})}):null,M?(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:O?.ok?U(i.toolsAvailable,{count:String(O.toolCount)}):O?i.healthStatusLabels[O.status]:e.usage.lastHealthStatus?i.healthStatusLabels[e.usage.lastHealthStatus]:i.healthNotTested}),(0,$.jsxs)(Z,{variant:`secondary`,"aria-busy":E,disabled:E||!e.enabled,onClick:()=>void I(),children:[E?(0,$.jsx)(re,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(le,{className:`size-4`,"aria-hidden":!0}),i.test]})]}),j?A.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:xn,value:S[e.key]??``,placeholder:e.placeholder,onChange:t=>C(n=>({...n,[e.key]:t.currentTarget.value}))})]},e.key)):null]}):null,N?(0,$.jsx)(bn,{instance:e,t:i,onChanged:r}):null,P?(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}),F?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:F}):null,b===null?null:(0,$.jsx)(`p`,{className:`mt-1 text-xs text-emerald-600`,children:U(i.connectedSourceSynced,{count:String(b)})})]}),(0,$.jsxs)(Z,{disabled:v,onClick:()=>void z(),children:[v?(0,$.jsx)(re,{className:`size-4 animate-spin`}):(0,$.jsx)(B,{className:`size-4`}),i.composioSyncNow]})]}),j?(0,$.jsx)(`div`,{className:`grid gap-3 rounded-xl border border-edge bg-surface-base p-4`,children:A.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:xn,value:S[e.key]??``,placeholder:e.placeholder,onChange:t=>C(n=>({...n,[e.key]:t.currentTarget.value}))})]},e.key))}):null]}):null,!M&&!N&&!P?(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)(Z,{variant:`secondary`,className:`shrink-0 border-danger/30 text-danger hover:bg-danger/10`,disabled:a,onClick:()=>c(!0),children:[a?(0,$.jsx)(re,{className:`size-4 animate-spin`}):(0,$.jsx)(me,{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)(Z,{variant:`secondary`,onClick:n,children:i.modalClose}),(M||P)&&j?(0,$.jsxs)(Z,{variant:`primary`,disabled:l,onClick:()=>void R(),children:[l?(0,$.jsx)(re,{className:`size-4 animate-spin`}):(0,$.jsx)(J,{className:`size-4`}),i.modalSave]}):null]})]})]}),(0,$.jsx)(it,{open:s,title:U(i.removeConfirmTitle,{name:e.displayName}),description:i.removeConfirmDescription,confirmLabel:i.removeConfirmAction,cancelLabel:i.modalCancel,destructive:!0,onConfirm:()=>{c(!1),L()},onCancel:()=>{a||c(!1)}})]})}function Tn(e){let t=(0,bt.c)(2),n;return t[0]===e?n=t[1]:(n=e.instance.materialized.type===`cli`&&e.definition?(0,$.jsx)(K,{definition:e.definition,instance:e.instance,onClose:e.onClose,onChanged:e.onChanged}):(0,$.jsx)(wn,{...e}),t[0]=e,t[1]=n),n}function En(e){let t=(0,bt.c)(37),{instance:n,definition:r,highlighted:i,onOpenDetails:a,t:o}=e,s=i!==void 0&&i,c;t[0]!==r||t[1]!==n?(c=v(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?W(r,o):null,t[3]=r,t[4]=o,t[5]=u):u=t[5];let d=u,f,p,m,h,g;t[6]!==l||t[7]!==r||t[8]!==n.displayName||t[9]!==o.connectionChecking||t[10]!==o.connectionNeedsSetup||t[11]!==o.connectionReady?(p=l===`ready`?{label:o.connectionReady,Icon:M,className:`text-emerald-700 dark:text-emerald-300`}:l===`needs_setup`?{label:o.connectionNeedsSetup,Icon:j,className:`text-amber-700 dark:text-amber-300`}:{label:o.connectionChecking,Icon:z,className:`text-fg-muted`},f=gt,h=n.displayName,t[17]===r?g=t[18]:(g=(0,$.jsx)(G,{connector:r,size:`sm`}),t[17]=r,t[18]=g),m=X(`mt-1 inline-flex items-center gap-1 text-[11px]`,p.className),t[6]=l,t[7]=r,t[8]=n.displayName,t[9]=o.connectionChecking,t[10]=o.connectionNeedsSetup,t[11]=o.connectionReady,t[12]=f,t[13]=p,t[14]=m,t[15]=h,t[16]=g):(f=t[12],p=t[13],m=t[14],h=t[15],g=t[16]);let _;t[19]===p.Icon?_=t[20]:(_=(0,$.jsx)(p.Icon,{className:`size-3.5`,"aria-hidden":!0}),t[19]=p.Icon,t[20]=_);let y;t[21]!==p.label||t[22]!==m||t[23]!==_?(y=(0,$.jsxs)(`span`,{className:m,children:[_,p.label]}),t[21]=p.label,t[22]=m,t[23]=_,t[24]=y):y=t[24];let b;t[25]!==n||t[26]!==a?(b=()=>a(n),t[25]=n,t[26]=a,t[27]=b):b=t[27];let x;return t[28]!==f||t[29]!==d||t[30]!==s||t[31]!==o.installedDetails||t[32]!==h||t[33]!==g||t[34]!==y||t[35]!==b?(x=(0,$.jsx)(f,{name:h,icon:g,status:y,description:d,action:o.installedDetails,highlighted:s,onOpen:b}),t[28]=f,t[29]=d,t[30]=s,t[31]=o.installedDetails,t[32]=h,t[33]=g,t[34]=y,t[35]=b,t[36]=x):x=t[36],x}function Dn(e,t){return Vt()}function On(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:[Ot()],additionalHeaders:r===`bearer`?t.filter(e=>e!==n):r===`oauth`?t:[]}}function kn(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,Ot(`Authorization`,`Bearer ${e}`)]}return t.mode===`apiKey`&&(r=[...r,Ot(t.headerName.trim(),t.apiKey.trim())]),{...e,extra:n,headers:r,oauthClientId:t.mode===`oauth`?e.oauthClientId:``}}function An(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 jn(){return X(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,Qe)}function Mn({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,Ot()])},S=e=>{let t=u.filter((t,n)=>n!==e);d(t.length>0?t:[Ot()])},C=async()=>{try{let e=await be();if(!e){y(!0);return}let t=At(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)(Z,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5 px-2 text-xs`,onClick:()=>void C(),children:[(0,$.jsx)(P,{className:`size-3.5`,"aria-hidden":!0}),i]}):null]}),(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:u.map((e,t)=>(0,$.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[minmax(0,1fr)_auto_auto] items-center gap-2 sm:grid-cols-[minmax(0,1fr)_minmax(0,1.4fr)_auto_auto]`,children:[(0,$.jsx)(`input`,{className:X(jn(),`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:X(jn(),`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)(Z,{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)(H,{className:`size-4`,"aria-hidden":!0}):(0,$.jsx)(te,{className:`size-4`,"aria-hidden":!0})}),(0,$.jsx)(Z,{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)(me,{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)(it,{open:v,title:o,description:a,confirmLabel:s,onConfirm:()=>y(!1),onCancel:()=>y(!1)}),(0,$.jsxs)(`button`,{type:`button`,className:X(`self-start text-sm text-accent hover:underline`,xe.press),onClick:x,children:[`+ `,n]})]})}var Nn=X(`w-full min-w-0 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,Qe);function Pn(e){let t=(0,bt.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=X(Nn,`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(Fn),t[11]=h):h=t[11];let g;t[12]===c?g=t[13]:(g=c?(0,$.jsx)(H,{className:`size-4`,"aria-hidden":!0}):(0,$.jsx)(te,{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)(Z,{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 Fn(e){return!e}function In(e){let t=(0,bt.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)(Mn,{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 Ln(e){let t=(0,bt.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=X(Nn,`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)(k,{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)(k,{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)(O,{"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 _;t[22]!==n.mode||t[23]!==i.setupAuthOAuthHint?(_=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]=_):_=t[24];let v;t[25]!==n.mode||t[26]!==i.setupExistingHint?(v=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]=v):v=t[27];let y;t[28]!==n.mode||t[29]!==n.token||t[30]!==r||t[31]!==i?(y=n.mode===`bearer`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Pn,{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]=y):y=t[32];let b;t[33]!==n.apiKey||t[34]!==n.headerName||t[35]!==n.mode||t[36]!==r||t[37]!==i?(b=n.mode===`apiKey`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`label`,{className:`block text-sm font-medium text-fg`,children:[i.setupApiKeyHeader,(0,$.jsx)(`input`,{className:X(Nn,`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)(Pn,{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]=b):b=t[38];let x;t[39]!==n.customHeaders||t[40]!==n.mode||t[41]!==r||t[42]!==i?(x=n.mode===`headers`?(0,$.jsx)(In,{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]=x):x=t[43];let S;return t[44]!==h||t[45]!==g||t[46]!==_||t[47]!==v||t[48]!==y||t[49]!==b||t[50]!==x?(S=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[h,g,_,v,y,b,x]}),t[44]=h,t[45]=g,t[46]=_,t[47]=v,t[48]=y,t[49]=b,t[50]=x,t[51]=S):S=t[51],S}function Rn(e){let t=(0,bt.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 zn({row:e,t,onUpdate:n}){let[r,i]=(0,Q.useState)(()=>Mt(e.envJson?JSON.parse(e.envJson):void 0)),[a,o]=(0,Q.useState)(!1),s=[];try{s=Pt(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)(Z,{type:`button`,variant:`ghost`,onClick:()=>o(e=>!e),children:a?t.setupArgsRows:t.setupArgsPaste})]}),a?(0,$.jsx)(Rn,{label:t.setupArgsPaste,hint:t.argsHint,children:(0,$.jsx)(`input`,{className:Nn,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:Nn,"aria-label":`${t.argsLabel} ${n+1}`,value:e,onChange:e=>c(s.map((t,r)=>r===n?e.target.value:t))}),(0,$.jsx)(Z,{type:`button`,variant:`ghost`,"aria-label":t.setupRemoveArg,onClick:()=>c(s.filter((e,t)=>t!==n)),children:(0,$.jsx)(me,{className:`size-4`,"aria-hidden":!0})})]},n)),a?null:(0,$.jsxs)(Z,{type:`button`,variant:`ghost`,onClick:()=>c([...s,``]),children:[(0,$.jsx)(ce,{className:`size-4`,"aria-hidden":!0}),t.setupAddArg]})]}),(0,$.jsx)(In,{environment:!0,headers:r,t,onChange:e=>{i(e),n({envEntries:e,envJson:JSON.stringify(jt(e)??{})})}})]})}function Bn(e){let t=(0,bt.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)(Rn,{label:`${r.commandLabel} *`,children:(0,$.jsx)(`input`,{"data-field":`command`,className:Nn,value:n.command,required:!0,onChange:e=>i({command:e.target.value})})}),(0,$.jsx)(zn,{row:n,t:r,onUpdate:i})]}):(0,$.jsx)(Rn,{label:`${r.urlLabel} *`,children:(0,$.jsx)(`input`,{"data-field":`url`,className:Nn,value:n.url,placeholder:`https://example.com/mcp`,required:!0,onChange:e=>i({url:e.target.value})})}),(0,$.jsx)(Rn,{label:r.setupNameLabel,hint:r.setupNameHint,children:(0,$.jsx)(`input`,{className:Nn,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)(Rn,{label:r.serverIdLabel,hint:r.setupIdHint,children:(0,$.jsx)(`input`,{className:Nn,readOnly:u,value:n.id,onChange:e=>i({id:e.target.value}),placeholder:r.serverIdPlaceholder})}),n.transport===`stdio`?(0,$.jsx)(Rn,{label:r.cwdLabel,children:(0,$.jsx)(`input`,{className:Nn,value:n.cwd,onChange:e=>i({cwd:e.target.value})})}):null,n.transport!==`stdio`&&l?(0,$.jsx)(Rn,{label:r.oauthClientIdLabel,hint:r.oauthClientIdHint,children:(0,$.jsx)(`input`,{className:Nn,value:n.oauthClientId,onChange:e=>i({oauthClientId:e.target.value})})}):null,(0,$.jsx)(Rn,{label:r.exposureLabel,hint:r.setupExposureHint,children:(0,$.jsx)(O,{"aria-label":r.exposureLabel,className:Nn,value:n.exposure,onChange:e=>i({exposure:e.target.value}),children:[`codemode`,`deferred`,`direct`,`hidden`].map(e=>(0,$.jsx)(k,{value:e,children:r.exposureLabels[e]},e))})}),(0,$.jsx)(Rn,{label:r.requestTimeoutLabel,children:(0,$.jsx)(yt,{allowEmpty:!0,type:`number`,min:1,className:Nn,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 Vn(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 Hn(e,t){return JSON.stringify({id:e.id,config:Ut(kn(e,t))})}function Un(e,t){try{return Hn(e,t)}catch{return JSON.stringify({row:e,auth:t})}}function Wn(e){let{t,cs:n}=e,r=c(e=>e.language),i=(0,Q.useId)(),[a,o]=(0,Q.useState)(e.initialRow),[s,l]=(0,Q.useState)(()=>On(e.initialRow)),[u,p]=(0,Q.useState)(`idle`),[v,y]=(0,Q.useState)(``),[b,x]=(0,Q.useState)(!1),[S,C]=(0,Q.useState)(!1),[w,T]=(0,Q.useState)(),[E,D]=(0,Q.useState)(),[A,j]=(0,Q.useState)(),[N,P]=(0,Q.useState)(!1),[F,I]=(0,Q.useState)(!1),[L,R]=(0,Q.useState)(``),[z,B]=(0,Q.useState)(``),[V,H]=(0,Q.useState)([]),[te,ne]=(0,Q.useState)(`0`),[U,ie]=(0,Q.useState)(0),[W,G]=(0,Q.useState)(``),[K,ae]=(0,Q.useState)(!1),[oe,se]=(0,Q.useState)(!1),q=e.mode===`edit`,[ce,le]=(0,Q.useState)(``),J=(0,Q.useRef)(void 0),[ue]=(0,Q.useState)(()=>Un(e.initialRow,On(e.initialRow))),de=(0,Q.useRef)(e.mode===`edit`?e.initialRow.id:``),fe=(0,Q.useRef)(void 0),pe=(0,Q.useRef)(void 0),me=(0,Q.useRef)(void 0),Y=(0,Q.useRef)(null),ge=(0,Q.useRef)(``),_e=(0,Q.useRef)(!0),ve=(0,Q.useRef)(null),ye=(0,Q.useRef)(null),be=(0,Q.useRef)(null),xe=(0,Q.useRef)(null),Se=(0,Q.useRef)(e.onSaved);Se.current=e.onSaved;let Ce=A?.state===`starting`||A?.state===`authorizing`,we=u!==`idle`||Ce,Te=ue!==Un(a,s),Ee=a.extra.enabled===!1,De=!S&&!b&&(Te||!!L.trim());(0,Q.useEffect)(()=>(_e.current=!0,()=>{_e.current=!1,fe.current?.abort(),Y.current?.close(),J.current&&qt(J.current).catch(()=>{})}),[]),(0,Q.useEffect)(()=>{if(!De)return;let e=e=>{e.preventDefault(),e.returnValue=``};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[De]),(0,Q.useEffect)(()=>{if(!w)return;let e=be.current?.querySelector(`[data-field="${w.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`,i),w.focus!==!1&&(n??xe.current)?.focus(),()=>{n?.removeAttribute(`aria-invalid`),n?.removeAttribute(`aria-describedby`)}},[w,i]),(0,Q.useEffect)(()=>{if(!A||!Ce)return;let e=new AbortController;pe.current=e;let n;async function r(){try{let n=await Xt(J.current,e.signal);if(e.signal.aborted||(j(n),n.authorizationUrl&&ge.current!==n.authorizationUrl&&(ge.current=n.authorizationUrl,window.electronAPI?.shell?.openExternalUrl?!(await window.electronAPI.shell.openExternalUrl(n.authorizationUrl)).ok&&!e.signal.aborted&&y(t.oauthOpenFailed):Y.current&&!Y.current.closed&&Y.current.location.replace(n.authorizationUrl)),e.signal.aborted))return;if(n.state===`connected`){me.current=void 0,Y.current?.close(),D({state:`connected`,toolCount:n.toolCount}),y(``);return}if(n.state===`error`||n.state===`cancelled`){me.current=void 0,Y.current?.close(),y(n.state===`cancelled`?t.setupCancelled:t.setupAuthFailed),/client.{0,20}(id|registration)|register|registration/i.test(n.error??``)&&P(!0);return}}catch{if(e.signal.aborted)return;Oe(),Y.current?.close(),y(t.setupAuthFailed);return}n=setTimeout(()=>void r(),1200)}return r(),()=>{e.abort(),clearTimeout(n)}},[A?.id,Ce,t.oauthOpenFailed,t.setupCancelled,t.setupAuthFailed]);function Oe(){fe.current?.abort(),pe.current?.abort(),J.current&&qt(J.current).catch(()=>{}),J.current=void 0,le(``),ae(!1),D(void 0),j(void 0),y(``),T(void 0)}function ke(e){o(t=>({...t,...e})),Oe()}function Ae(e){l(t=>({...t,...e})),Oe()}function je(){u===`saving`||Ce||(u===`checking`&&(Oe(),p(`idle`)),De?se(!0):e.onClose())}function Me(){try{H(Bt(L)),ne(`0`),B(``)}catch{B(t.setupImportError),H([])}}function Ne(){let t=V[Number(te)];if(!t)return;let n={...t,id:de.current||t.id,clientKey:e.initialRow.clientKey,extra:{...t.extra,...de.current?{enabled:a.extra.enabled}:{}}};o(n),l(On(n)),Oe(),ie(e=>e+1),I(!1),R(``),H([])}function Pe(e){function n(e,t){return T({field:e,message:t}),!1}if(e.transport!==`stdio`){try{e.url=zt(e.url)}catch{return n(`url`,t.setupAddressInvalid)}if(s.mode===`bearer`&&!s.token.trim().replace(/^Bearer\s*/i,``)||s.mode===`apiKey`&&(!s.apiKey.trim()||!s.headerName.trim()))return n(`auth`,t.setupCredentialRequired);if(An(e.headers)>=0)return n(`auth`,t.setupHeaderInvalid);if(s.mode===`oauth`&&e.headers.some(e=>e.key.trim().toLowerCase()===`authorization`))return n(`auth`,t.setupOAuthHeaderConflict);if(s.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{Ut(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 Fe(){y(``),p(`checking`),ge.current=``,window.electronAPI?.shell?.openExternalUrl||(Y.current=window.open(`about:blank`,`_blank`),Y.current&&(Y.current.opener=null));try{let e=await Yt(J.current);if(!_e.current){Y.current?.close(),J.current&&qt(J.current).catch(()=>{});return}me.current=e.id,j(e)}catch{Y.current?.close(),_e.current&&y(t.setupAuthFailed)}finally{_e.current&&p(`idle`)}}async function Ie(){let r=kn(a,s);if(!Pe(r))return;let i=e.existingCustomServers.filter(t=>t.clientKey!==e.initialRow.clientKey&&t.id!==de.current),c=new Set([...e.managedServerIds,...i.map(e=>e.id)]);if(r.id=de.current||r.id.trim()||Rt(r,c),!/^[a-zA-Z0-9_-]+$/.test(r.id)||[...c].some(e=>e.replace(/-/g,`_`)===r.id.replace(/-/g,`_`))){T({field:`advanced`,message:n.duplicateServerId});return}Oe(),p(`checking`);let l=new AbortController;fe.current=l;try{let n=await Gt(r,de.current||void 0,e.initialRow.extra,l.signal);if(!_e.current||l.signal.aborted){qt(n.id).catch(()=>{});return}J.current=n.id,o(r),le(Un(r,s));let i=await Kt(n.id,l.signal);if(!_e.current||l.signal.aborted)return;D(i),i.state===`error`&&y(Vn(i,t))}catch(e){_e.current&&!l.signal.aborted&&y(e.status===409?t.setupConflict:Vn(e,t))}finally{_e.current&&fe.current===l&&p(`idle`)}}async function Le(e=!1){if(!(!J.current||E?.state!==`connected`||ce!==Un(a,s))){p(`saving`),y(``);try{let t=await Jt(J.current,e);J.current=void 0,await Se.current().catch(()=>{}),t?.reloadRequired?x(!0):(e&&o(e=>({...e,extra:{...e.extra,enabled:!0}})),C(!0))}catch(e){let n=e.status;n===404||n===409?(Oe(),y(t.setupConflict)):y(t.setupSaveFailed)}finally{_e.current&&p(`idle`)}}}async function Re(){pe.current?.abort();let e=J.current;me.current=void 0,j(void 0),Y.current?.close(),y(t.setupCancelled),p(`checking`);try{e&&await Zt(e)}catch{_e.current&&(Oe(),y(t.setupCancelled))}finally{_e.current&&p(`idle`)}}async function ze(){A?.authorizationUrl&&(window.electronAPI?.shell?.openExternalUrl?(await window.electronAPI.shell.openExternalUrl(A.authorizationUrl)).ok||y(t.oauthOpenFailed):window.open(A.authorizationUrl,`_blank`,`noopener,noreferrer`))}async function Be(){if(A)try{await Qt(J.current,W),G(``),y(``)}catch{y(t.setupRedirectInvalid)}}let Ve=!!J.current&&ce===Un(a,s)&&(s.mode===`oauth`||s.mode===`auto`&&E?.state===`oauth_required`)&&E?.state!==`connected`,He=/^(?:https?:\/\/)?(?:localhost|127\.0\.0\.1|\[::1\])(?=[:/]|$)/i.test(a.url.trim()),Ue=V[Number(te)];return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(_,{open:e.open,onOpenChange:e=>{e||je()},children:(0,$.jsxs)(m,{children:[(0,$.jsx)(d,{className:`fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(h,{ref:ve,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(),ve.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)(g,{className:`font-semibold`,children:S?a.displayName||a.id:e.mode===`edit`?t.setupEditTitle:t.setupTitle}),(0,$.jsx)(f,{className:`mt-1 text-sm text-fg-muted`,children:t.setupHint})]}),(0,$.jsx)(`button`,{type:`button`,disabled:u===`saving`||Ce,onClick:je,className:`rounded-lg p-2 text-fg-muted hover:bg-surface-hover disabled:opacity-50`,"aria-label":n.modalClose,children:(0,$.jsx)(he,{className:`size-5`,"aria-hidden":!0})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-5`,children:[S?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 text-sm text-success`,children:[(0,$.jsx)(M,{className:`size-4`,"aria-hidden":!0}),Ee?t.setupDisabled:r===`zh`?`连接已保存,可以开始使用`:`Connection saved and ready to use`]}),Ee?null:(0,$.jsx)(ut,{target:{kind:`mcp`,id:a.id,name:a.displayName||a.id},onStart:e.onClose})]}):F?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(Z,{variant:`ghost`,onClick:()=>I(!1),children:t.setupImportBack}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.setupImportEmpty}),(0,$.jsxs)(`label`,{className:`block text-sm font-medium text-fg`,children:[t.setupImport,(0,$.jsx)(`textarea`,{className:X(Nn,`mt-1.5 min-h-40 font-mono text-xs`),value:L,placeholder:`{"mcpServers": {"docs": {"url": "https://example.com/mcp"}}}`,onChange:e=>{R(e.target.value),H([]),B(``)}})]}),(0,$.jsx)(Z,{variant:`secondary`,disabled:!L.trim(),onClick:Me,children:t.setupImportPreview}),z?(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:z}):null,Ue?(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)(O,{"aria-label":t.setupImportChoose,className:X(Nn,`mt-1.5`),value:te,onChange:e=>ne(e.target.value),children:V.map((e,t)=>(0,$.jsx)(k,{value:String(t),children:e.displayName||e.id||on(e)},t))})]}),(0,$.jsxs)(`p`,{className:`break-all text-sm text-fg-muted`,children:[Ue.transport===`stdio`?t.setupUseCommand:t.setupUseUrl,` · `,on(Ue)]})]}):null]}):(0,$.jsxs)(`form`,{ref:be,noValidate:!0,onBlurCapture:e=>{if(e.target instanceof HTMLInputElement&&e.target.dataset.field===`url`&&a.url.trim())try{zt(a.url)}catch{T({field:`url`,message:t.setupAddressInvalid,focus:!1})}},onSubmit:e=>{e.preventDefault(),Ie()},children:[(0,$.jsxs)(`fieldset`,{disabled:we||b,className:`min-w-0 space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsx)(rt,{className:`flex gap-1`,role:`group`,"aria-label":t.transportLabel,children:[`streamable-http`,`sse`,`stdio`].map(e=>(0,$.jsx)(Z,{type:`button`,variant:a.transport===e?`secondary`:`ghost`,"aria-pressed":a.transport===e,onClick:()=>ke({transport:e}),children:e===`stdio`?t.setupUseCommand:e===`sse`?r===`zh`?`旧版 SSE`:`Legacy SSE`:t.setupUseUrl},e))}),(0,$.jsx)(Z,{type:`button`,variant:`ghost`,onClick:()=>I(!0),children:t.setupImport})]}),(0,$.jsx)(`div`,{children:(0,$.jsx)(Bn,{row:a,t,variant:`basic`,onUpdate:ke},`${a.transport}-${U}`)}),a.transport===`stdio`?null:(0,$.jsx)(`div`,{"data-field":`auth`,children:(0,$.jsx)(Ln,{allowExisting:!!a.extra.auth||a.headers.some(e=>!!e.reference),draft:s,onChange:Ae,t})}),w?(0,$.jsx)(`p`,{id:i,ref:xe,tabIndex:-1,role:`alert`,className:`text-sm text-danger`,children:w.message}):null,(0,$.jsxs)(`details`,{"data-field":`advanced`,className:`rounded-lg border border-edge p-3`,open:N,onToggle:e=>P(e.currentTarget.open),children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted`,children:t.setupAdvanced}),(0,$.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[(0,$.jsx)(Bn,{row:a,t,variant:`advanced`,idReadOnly:q,showOAuth:s.mode===`oauth`,onUpdate:ke}),a.transport!==`stdio`&&s.mode!==`headers`&&s.mode!==`existing`?(0,$.jsx)(In,{additional:!0,headers:s.additionalHeaders,onChange:e=>Ae({additionalHeaders:e}),t}):null]})]}),(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:a.transport===`stdio`?t.setupCommandHostHint:He?t.setupLocalhostHint:t.setupGatewayHint}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.setupTestNotice})]}),(0,$.jsx)(`button`,{type:`submit`,hidden:!0})]}),b?(0,$.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-fg`,children:t.setupReloadRequired}):null,!S&&!F&&!b?(0,$.jsxs)(`div`,{className:`mt-4 space-y-3`,"aria-live":`polite`,children:[u===`idle`?null:(0,$.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,$.jsx)(re,{className:`size-4 animate-spin motion-reduce:animate-none`,"aria-hidden":!0}),u===`saving`?t.setupSaving:t.setupChecking]}),u===`idle`&&q&&!Te&&!E&&!v&&!Ce?(0,$.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:Ee?t.setupDisabled:e.lastCheck?t.setupLastCheck.replace(`{{count}}`,String(e.lastCheck.toolCount)):t.setupSavedUnchecked}):null,E?.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)(M,{className:`size-4 shrink-0`,"aria-hidden":!0}),E.toolCount?t.setupConnected.replace(`{{count}}`,String(E.toolCount)):t.setupZeroTools]}),(0,$.jsx)(ut,{preview:!0,target:{kind:`mcp`,id:a.id,name:a.displayName||a.id}}),(0,$.jsx)(Z,{ref:ye,variant:`secondary`,onClick:()=>ae(!0),children:t.viewTools})]}):null,E?.state===`token_required`?(0,$.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:t.setupNeedsAuth}):null,E?.state===`auth_unknown`?(0,$.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:r===`zh`?`认证方式尚未确定。请核实服务接入说明,选择 Token 或已确认支持的 OAuth。`:`Authentication is undetermined. Check the integration guide and select a Token or verified OAuth method.`}):null,E?.state===`oauth_required`&&!Ce?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.setupOAuthRequired}):null,Ce?(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)(re,{className:`size-4 animate-spin motion-reduce:animate-none`,"aria-hidden":!0}),t.setupAuthorizing]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[A?.authorizationUrl?(0,$.jsxs)(Z,{variant:`secondary`,onClick:()=>void ze(),children:[(0,$.jsx)(ee,{className:`size-4`,"aria-hidden":!0}),t.oauthOpenAuthorization]}):null,(0,$.jsx)(Z,{variant:`ghost`,onClick:()=>void Re(),children:t.setupCancelAuth})]}),A?.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:Nn,value:W,onChange:e=>G(e.target.value)})]}),(0,$.jsx)(Z,{className:`mt-2`,disabled:!W.trim(),onClick:()=>void Be(),children:t.setupContinue})]}):null]}):null,v?(0,$.jsxs)(`div`,{role:`alert`,className:`space-y-1 text-sm`,children:[(0,$.jsx)(`p`,{className:`text-danger`,children:v}),v!==t.setupSaveFailed&&u!==`saving`?(0,$.jsx)(`p`,{className:`text-fg-muted`,children:t.setupTestFailure}):null]}):null]}):null]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge p-4`,children:[(0,$.jsx)(Z,{variant:`secondary`,disabled:u===`saving`||Ce,onClick:je,children:S||q||b?t.setupClose:n.modalCancel}),S||b?null:F?(0,$.jsx)(Z,{variant:`primary`,disabled:!Ue,onClick:Ne,children:t.setupImportApply}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Z,{variant:E?.state===`connected`?`secondary`:`primary`,disabled:we,onClick:()=>Ve?void Fe():void Ie(),children:Ve?t.setupSignIn:t.setupTestConnection}),E?.state===`connected`&&ce===Un(a,s)?(0,$.jsxs)($.Fragment,{children:[Ee?(0,$.jsx)(Z,{variant:`secondary`,disabled:we,onClick:()=>void Le(!0),children:t.setupEnableSave}):null,(0,$.jsx)(Z,{variant:`primary`,disabled:we,"aria-busy":we,onClick:()=>void Le(),children:q?t.setupSaveOnly:t.setupAddConnection})]}):null]})]})]})]})}),(0,$.jsx)(it,{open:oe,title:t.setupUnsavedTitle,description:t.setupUnsavedHint,confirmLabel:t.setupDiscard,cancelLabel:t.setupKeepEditing,onCancel:()=>se(!1),onConfirm:e.onClose,overlayClassName:`z-[70]`,contentClassName:`z-[70]`}),K?(0,$.jsx)(nn,{draftId:J.current,serverId:a.id,displayName:a.displayName,returnFocusTo:ye.current,t,onClose:()=>ae(!1)}):null]})}var Gn=`recommended`,Kn=`builtin`,qn=`composio`,Jn=`xopc-store`;function Yn(e,t=`en`){return e==="default"&&t.startsWith(`zh`)?Gn:Kn}function Xn(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 Zn(e){return y(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 Qn(e){return e?.startsWith(`/`)&&!e.startsWith(`//`)?e:`/user-model`}function $n({embedded:e=!1,onHeaderActionChange:t}){let n=nt().filter(ln),r=c(e=>e.language),o=u(r),l=o.connectorsSettings,d=o.mcpSettings,f=s(e=>e.conversationId),p=!!f,m=a(),[h,g]=i(),_=h.get(`understanding`)===`1`,y=Qn(h.get(`returnTo`)),E=!!h.get(`returnTo`)&&!_,D=h.get(`tab`),[O,k]=(0,Q.useState)(!_&&D===`connected`?`connected`:`discover`),{data:j}=_e(p&&O===`discover`&&!_?[`service-recommendations`,r]:null,()=>S(r),{revalidateOnFocus:!1}),M=(0,Q.useMemo)(()=>new Set(j?.items.filter(e=>e.service?.source===`store-plugin`).map(e=>w(e.id))??[]),[j]),N=(0,Q.useRef)(!1),[P,z]=(0,Q.useState)({catalog:[],registryCatalog:[],instances:[],loading:!0,error:null}),[B,V]=(0,Q.useState)(!1),[ee,H]=(0,Q.useState)(!1),[te,ne]=(0,Q.useState)(1),[U,ie]=(0,Q.useState)(void 0),[W,G]=(0,Q.useState)(``),[K,ae]=(0,Q.useState)(_||E?h.get(`connector`)??``:``),[q,ce]=(0,Q.useState)(Yn(_?`understanding`:`default`,r)),[le,J]=(0,Q.useState)(`name`),[ue,de]=(0,Q.useState)(_?`understand`:`all`),[fe,pe]=(0,Q.useState)(null),[me,Y]=(0,Q.useState)(null),[he,ge]=(0,Q.useState)(null),[ve,be]=(0,Q.useState)(null),[xe,Se]=(0,Q.useState)(null),[Ce,we]=(0,Q.useState)(null),{data:Te,mutate:Ee}=ye(p),De=Te?.payload?.config,Oe=(0,Q.useMemo)(()=>De===void 0?null:Ht(De),[De]),ke=Oe?.servers??[],Ae=P.instances.length+ke.length+n.length,[je,Me]=(0,Q.useState)({});(0,Q.useEffect)(()=>{if(Me({}),!p||!De)return;let e=new AbortController;return en(e.signal).then(t=>{e.signal.aborted||Me(t)}).catch(()=>{}),()=>e.abort()},[p,De]);let Ne=(0,Q.useCallback)(async()=>{if(!f){z({catalog:[],registryCatalog:[],instances:[],loading:!1,error:null});return}z(e=>({...e,loading:!0,error:null}));try{let[e,t]=await Promise.all([Le(),Pe()]);z(n=>({catalog:e,registryCatalog:n.registryCatalog,instances:t,loading:!1,error:null}))}catch(e){z({catalog:[],registryCatalog:[],instances:[],loading:!1,error:e instanceof Error?e.message:String(e)})}},[f]);(0,Q.useEffect)(()=>{Ne()},[Ne]),(0,Q.useEffect)(()=>{N.current||P.loading||p&&!Oe||(k(_?`discover`:Ae>0?`connected`:`discover`),N.current=!0)},[p,Ae,Oe,_,P.loading]),(0,Q.useEffect)(()=>{ce(e=>e===`builtin`||e===`recommended`?Yn(_?`understanding`:`default`,r):e)},[r,_]);let Fe=(0,Q.useCallback)(e=>{N.current=!0,k(e)},[]),Ie=(0,Q.useMemo)(()=>[{id:qn,displayName:l.composioSourceName},{id:Jn,displayName:l.storeSourceName}],[l.composioSourceName,l.storeSourceName]),Re=(0,Q.useCallback)(async e=>{if(!p||q===`builtin`||q===`recommended`){z(e=>({...e,registryCatalog:[]})),ne(1),ie(void 0);return}let t=K.trim(),n=Math.max(e?.page??1,1),i=e?.append??!1,a=q===`all`?Ie:Ie.filter(e=>e.id===q);if(a.length!==0){V(!0),i?z(e=>({...e,error:null})):(ne(1),ie(void 0),z(e=>({...e,registryCatalog:[],error:null})));try{let e=await Promise.all(a.map(async e=>{if(e.id===`composio`){let e=await We({q:t||void 0,page:n,pageSize:24,verification:`experimental`});return{connectors:e.connectors,totalPages:e.meta.totalPages}}let i=await He({q:t||void 0,page:n,pageSize:24,sort:le===`source`?`newest`:`downloads`});return{connectors:i.items.flatMap(e=>{let t=Xn(e,r);return t?[t]:[]}),totalPages:i.meta.totalPages}})),o=Zn(e.flatMap(e=>e.connectors)),s=Math.max(1,...e.map(e=>e.totalPages??1));ne(n),ie(s),z(e=>({...e,registryCatalog:i?Zn([...e.registryCatalog,...o]):o}))}catch(e){z(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{V(!1)}}},[le,K,q,p,Ie,r]);(0,Q.useEffect)(()=>{if(O!==`discover`||P.loading)return;if(q===`builtin`||q===`recommended`){z(e=>({...e,registryCatalog:[]})),ne(1),ie(void 0);return}let e=window.setTimeout(()=>{Re()},K.trim()?350:0);return()=>window.clearTimeout(e)},[K,q,Re,P.loading,O]);let ze=(0,Q.useMemo)(()=>new Set(P.instances.map(e=>e.connectorId)),[P.instances]),Be=(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=h.get(`connector`),t=h.get(`instance`);if(!e&&!t)return;let n=P.instances.find(n=>t?n.instanceId===t:n.connectorId===e);if(n)N.current=!0,G(``),ge(n.instanceId),be(n),k(`connected`);else if(e){let t=Be.get(e);if(!t)return;N.current=!0,ce(Yn(_?`understanding`:`default`,r)),ae(``),Y(t),k(`discover`)}let i=new URLSearchParams(h);i.delete(`connector`),i.delete(`instance`),i.set(`tab`,n?`connected`:`discover`),g(i,{replace:!0})},[Be,_,r,h,g,P.instances,P.loading]);let Ve=(0,Q.useCallback)(async e=>{H(!0),z(e=>({...e,error:null}));try{let t=await Ge(e);pe(oe(t.definition,{packageName:t.packageName,version:t.version,reviewHash:t.reviewHash,permissions:t.permissions}))}catch(e){z(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{H(!1)}},[]);(0,Q.useEffect)(()=>{let e=h.get(`storeConnector`);if(!p||!e)return;let t=new URLSearchParams(h);t.delete(`storeConnector`),g(t,{replace:!0}),Ve(e)},[p,h,g,Ve]);let Ue=(0,Q.useMemo)(()=>new Set(P.instances.flatMap(e=>e.materialized.type===`mcp`?[e.materialized.serverId]:[])),[P.instances]),Ke=(0,Q.useCallback)(async e=>{let t=await tn(e);await Ee(),await Ne(),t.reloadRequired&&z(e=>({...e,error:d.setupReloadRequired}))},[Ne,Ee,d.setupReloadRequired]),qe=(0,Q.useCallback)(()=>{we({mode:`add`,row:Dn(ke,Ue)})},[ke,Ue]),Je=tt(e=>e.setPageHeader),Ye=tt(e=>e.clearPageHeader),Xe=(0,Q.useMemo)(()=>({searchLabel:O===`connected`?l.connectedSearchPlaceholder:l.discoverSearchPlaceholder,search:(0,$.jsx)(pt,{value:O===`connected`?W:K,onChange:O===`connected`?G:ae,placeholder:O===`connected`?l.connectedSearchPlaceholder:l.discoverSearchPlaceholder}),secondary:(0,$.jsx)(Dt,{onRefresh:O===`connected`&&p?Ne:void 0,refreshing:P.loading,refreshLabel:l.refreshConnections,onBrowseCatalog:()=>Fe(`discover`),onAddCustomServer:qe,addLabel:l.addConnection,browseLabel:l.addFromCatalog,customLabel:l.addCustomServerAdvanced,serviceLabel:r.startsWith(`zh`)?`应用连接服务`:`Connection service`,moreActionsLabel:o.capabilitiesHub.moreActions})}),[W,l,K,p,r,Ne,o.capabilitiesHub.moreActions,qe,Fe,P.loading,O]);(0,Q.useLayoutEffect)(()=>e?(t?.(Xe),()=>t?.(null)):(Je({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)(mt,{contribution:Xe})}),()=>Ye()),[Ye,l.title,e,Xe,t,Je]);let Ze=(0,Q.useMemo)(()=>P.instances.map(e=>({instance:e,value:v(e,Be.get(e.connectorId))})),[Be,P.instances]),Qe=(0,Q.useMemo)(()=>new Map(Ze.map(({instance:e,value:t})=>[e.instanceId,t])),[Ze]),$e=(0,Q.useMemo)(()=>P.instances.filter(e=>L(e,W)).sort((e,t)=>{let n={needs_setup:0,checking:1,ready:2},r=Qe.get(e.instanceId)?.state??`checking`,i=Qe.get(t.instanceId)?.state??`checking`;return n[r]-n[i]||e.displayName.localeCompare(t.displayName)}),[W,Qe,P.instances]),it=(0,Q.useMemo)(()=>$e.filter(e=>Qe.get(e.instanceId)?.state===`needs_setup`),[Qe,$e]),at=(0,Q.useMemo)(()=>$e.filter(e=>Qe.get(e.instanceId)?.state!==`needs_setup`),[Qe,$e]),ot=(0,Q.useMemo)(()=>ke.filter(e=>R(e,W)),[W,ke]),st=(0,Q.useMemo)(()=>{let e=W.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))},[W,n]),ct=$e.length+ot.length+st.length,lt=(0,Q.useMemo)(()=>P.catalog.filter(e=>e.source===`builtin`&&e.integrationStrategy?.preferred!==!1&&F(e)),[P.catalog]),ut=(0,Q.useMemo)(()=>q===`recommended`?[]:q===`builtin`?lt:q===`all`?Zn([...lt,...P.registryCatalog]):P.registryCatalog,[lt,q,P.registryCatalog]),ft=(0,Q.useMemo)(()=>{let e=_?ut.filter(e=>e.understanding?.mode===`activity`):Zn(ut).filter(e=>!M.has(w(e.id)));return I(ue===`all`?e:e.filter(e=>b(e).includes(ue)),K,le)},[le,K,ut,_,ue,M]),ht=(0,Q.useMemo)(()=>C.filter(e=>ut.some(t=>b(t).includes(e))),[ut]);(0,Q.useEffect)(()=>{ue!==`all`&&!ht.includes(ue)&&de(`all`)},[ht,ue]);let gt=O===`discover`&&q!==`builtin`&&!!(U&&te<U),yt=(0,Q.useMemo)(()=>P.instances.find(e=>e.instanceId===he)??ve,[he,ve,P.instances]),bt=(0,Q.useMemo)(()=>[{value:Gn,label:r===`zh`?`推荐服务`:`Recommended services`},{value:`all`,label:l.discoverSourceAll},{value:Kn,label:l.discoverSourceBuiltin},...Ie.map(e=>({value:e.id,label:e.displayName}))],[l.discoverSourceAll,l.discoverSourceBuiltin,Ie,r]),St=[{id:`connected`,label:l.tabConnected,count:Ae},{id:`discover`,label:l.tabDiscover}];return(0,$.jsx)(`div`,{className:X(`flex min-h-0 min-w-0 flex-1 flex-col`,!e&&`bg-surface-base`),children:(0,$.jsxs)(`div`,{className:X(`mx-auto flex w-full max-w-7xl flex-col gap-6 px-4 sm:px-6 lg:px-8`,e?`pb-7 pt-3 lg:pb-9 lg:pt-4`:`py-7 lg:py-9`),children:[p?null:(0,$.jsx)(`p`,{className:`rounded-xl bg-surface-panel px-4 py-3 text-sm text-fg-muted`,children:l.tokenHint}),_?(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)(Z,{type:`button`,variant:`secondary`,className:`shrink-0`,onClick:()=>m(y),children:l.understandingSetupDone})]}):null,E?(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)(Z,{type:`button`,variant:`secondary`,className:`min-h-11 shrink-0`,onClick:()=>m(y),children:l.recoverySetupDone})]}):null,(0,$.jsxs)(`section`,{className:`flex flex-col gap-4`,children:[(0,$.jsx)(`div`,{children:(0,$.jsx)(et,{items:St,activeTab:O,onChange:Fe,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,O===`connected`&&p?(0,$.jsx)(`div`,{className:`flex flex-col gap-6`,children:P.loading?(0,$.jsx)(`div`,{className:_t,"aria-busy":`true`,"aria-label":l.loading,children:Ct.slice(0,3).map(e=>(0,$.jsx)(vt,{},e))}):Ae===0?(0,$.jsxs)(`div`,{className:`py-14 text-center`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:l.connectionsEmpty}),(0,$.jsx)(Z,{type:`button`,variant:`primary`,className:`mt-4`,onClick:()=>Fe(`discover`),children:l.addFromCatalog})]}):ct===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:[it.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:it.length})]}),(0,$.jsx)(`div`,{className:_t,children:it.map(e=>(0,$.jsx)(En,{instance:e,definition:Be.get(e.connectorId),highlighted:e.instanceId===xe,onOpenDetails:e=>{Se(null),ge(e.instanceId),be(e)},t:l},e.instanceId))})]}):null,at.length||st.length?(0,$.jsx)(`section`,{children:(0,$.jsxs)(`div`,{className:_t,children:[at.map(e=>(0,$.jsx)(En,{instance:e,definition:Be.get(e.connectorId),highlighted:e.instanceId===xe,onOpenDetails:e=>{Se(null),ge(e.instanceId),be(e)},t:l},e.instanceId)),st.map(e=>(0,$.jsx)(un,{extension:e,language:r,onOpen:()=>m(dt(e.pluginId,`connections`,e.authorizationStatus===`required`))},e.id))]})}):null,ot.length||!W.trim()?(0,$.jsx)(cn,{servers:ot,lastChecks:je,t:d,cs:l,onAdd:qe,onEdit:e=>we({mode:`edit`,row:structuredClone(e)}),onRemove:Ke}):null]})}):null,O===`discover`&&p?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[_?null:(0,$.jsx)(rt,{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`,...ht].map(e=>(0,$.jsx)(`button`,{type:`button`,className:X(`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors`,ue===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":ue===e,onClick:()=>de(e),children:e===`all`?l.taskAll:l.connectorBenefitHeadings[e]},e))}),(0,$.jsxs)(`div`,{className:X(`ml-auto grid w-full gap-2 sm:flex sm:w-auto sm:justify-end`,_?`grid-cols-1`:`grid-cols-2`),children:[_?null:(0,$.jsx)(`div`,{className:`min-w-0 sm:w-40`,children:(0,$.jsx)(A,{value:q,options:bt,placeholder:l.discoverSourceAll,allowEmpty:!1,ariaLabel:l.registrySourceAria,triggerClassName:`h-9 bg-surface-panel text-xs`,onChange:ce})}),q===`recommended`?null:(0,$.jsx)(`div`,{className:`min-w-0 sm:w-40`,children:(0,$.jsx)(A,{value:le,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=>J(e)})})]})]}),q===`recommended`?(0,$.jsx)(T,{layout:`cards`,showAll:!0,query:K,onChanged:async()=>{await Ne(),await Ee()}}):(P.loading||B)&&ft.length===0?(0,$.jsx)(`div`,{className:_t,"aria-busy":`true`,"aria-label":l.loading,children:Ct.map(e=>(0,$.jsx)(Et,{},e))}):ft.length===0?(0,$.jsx)(`div`,{className:`py-14 text-center text-sm text-fg-muted`,children:l.discoverEmpty}):(0,$.jsxs)(`div`,{className:`relative`,children:[B?(0,$.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-[1] flex justify-center bg-surface-panel/40 pt-[min(28vh,7.5rem)] backdrop-blur-[1px] motion-reduce:backdrop-blur-none dark:bg-surface-base/35`,"aria-busy":`true`,"aria-label":l.loading,children:(0,$.jsx)(re,{className:`size-8 shrink-0 animate-spin text-accent motion-reduce:animate-none`,strokeWidth:2,"aria-hidden":!0})}):null,(0,$.jsx)(`div`,{className:_t,children:ft.map(e=>(0,$.jsx)(xt,{connector:e,installed:ze.has(e.id)||wt(e,P.instances),onInstall:e=>{if(e.source===`store`){Ve(e.id);return}pe(oe(e))},onOpenDetails:e.source===`store`?void 0:Y,t:l},e.id))}),gt?(0,$.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,$.jsxs)(Z,{type:`button`,variant:`secondary`,disabled:B||ee,onClick:()=>void Re({page:te+1,append:!0}),children:[B?(0,$.jsx)(re,{className:`size-4 animate-spin`}):null,l.loadMore]})}):null]})]}):null]}),fe?(0,$.jsx)(se,{draft:fe,onChange:pe,onClose:()=>pe(null),t:l,onInstalled:async e=>{await Ne(),await Ee(),Se(e.instanceId),Fe(`connected`)}}):null,me?(0,$.jsx)(x,{connector:me,installed:ze.has(me.id)||wt(me,P.instances),onClose:()=>Y(null),onInstall:e=>pe(oe(e)),t:l}):null,yt?(0,$.jsx)(Tn,{instance:yt,definition:Be.get(yt.connectorId),onClose:()=>{ge(null),be(null)},onChanged:Ne,t:l,mcp:d}):null,Ce?(0,$.jsx)(Wn,{open:!0,mode:Ce.mode,initialRow:Ce.row,lastCheck:Ce.mode===`edit`?je[Ce.row.id]:void 0,existingCustomServers:ke,config:De,managedServerIds:Ue,t:d,cs:l,onClose:()=>we(null),onSaved:async()=>{await Ee(),await Ne(),Fe(`connected`)}},`${Ce.mode}-${Ce.row.clientKey}`):null]})})}export{$n 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{_ as i,f as a}from"./chunk-KS7C4IRE-DIIvxCDx.js";import{i as o,l as s,n as c,o as l}from"./locale-store-DgbX5Azb.js";import{t as u}from"./messages-Clfka2Sx.js";import{a as d,i as f,n as p,o as m,r as h,s as g,t as _}from"./dist-DlirbHVs.js";import{a as v,c as y,i as b,n as x,o as S,r as C,s as w,t as T}from"./service-recommendation-list-CFJ8WBzq.js";import{t as E}from"./chevron-down-ccbiQQz_.js";import{t as D}from"./chevron-right-BweFrslA.js";import{n as O,r as k,t as A}from"./popover-select-hRG1EzAY.js";import{t as j}from"./circle-alert-BEjgurr2.js";import{t as M}from"./circle-check-C23XjkUj.js";import{t as N}from"./circle-pause-CN9jYH2s.js";import{a as P,i as F,n as I,r as L,t as R}from"./connector-filters-Cfcx9EA2.js";import{t as z}from"./clock-3-DnrAnuyZ.js";import{t as B}from"./database-CjjeZfRG.js";import{t as V}from"./ellipsis-0k4rZLoy.js";import{t as ee}from"./external-link-DjqjBmc3.js";import{n as H}from"./secret-input-DsjfQmDn.js";import{t as te}from"./eye-CABVeTq0.js";import{t as ne}from"./key-round-DWbpyU2U.js";import{t as re}from"./loader-circle-CifKLtgG.js";import{a as U,c as ie,i as W,n as G,o as K,r as ae,s as oe,t as se}from"./install-connector-dialog-DNY-rpBC.js";import{t as q}from"./plug-DKYPEgkR.js";import{t as ce}from"./plus-Q2yW6OE7.js";import{t as le}from"./refresh-cw-BRlGaq2w.js";import{t as J}from"./save-DRDABU--.js";import{t as ue}from"./server-BlHCBjiE.js";import{t as de}from"./settings-uiTATseT.js";import{t as fe}from"./store-SzD1Jvgm.js";import{t as pe}from"./terminal-oKqqZdiG.js";import{t as me}from"./trash-2-DusmjVPV.js";import{t as Y}from"./wrench-DFb4r8bH.js";import{t as he}from"./x-B_N4OPjy.js";import{t as X}from"./cn-0WouolD0.js";import{t as ge}from"./skeleton-DzdOeGYz.js";import{i as _e}from"./vendor-swr-CdRzEUwF.js";import{n as ve,r as ye}from"./gateway-config-swr-aAsaoOK1.js";import{t as Z}from"./button-C5tRaJxt.js";import{n as be}from"./copy-to-clipboard-HOJ79TWv.js";import{n as xe}from"./interaction-BdhHBbYa.js";import{A as Se,E as Ce,F as we,I as Te,L as Ee,M as De,N as Oe,O as ke,P as Ae,R as je,S as Me,_ as Ne,a as Pe,c as Fe,d as Ie,i as Le,j as Re,l as ze,m as Be,n as Ve,o as He,p as Ue,r as We,s as Ge,u as Ke,v as qe,w as Je,x as Ye,y as Xe,z as Ze}from"./connectors-api-Dj9RbG9p.js";import{s as Qe}from"./form-field-width-DJw_jULe.js";import{n as $e}from"./electron-env-DHOGevH3.js";import{t as et}from"./page-tabs-DoYMKhVO.js";import{t as tt}from"./page-header-store-CYA4Isnf.js";import{r as nt}from"./extension-provider-DZ97b5uA.js";import{t as rt}from"./sliding-tab-list-CmcrqRzN.js";import{t as it}from"./confirm-dialog-yhRKgG72.js";import{l as at,m as ot,o as st,r as ct,t as lt}from"./dist-DaFr5KMw.js";import{t as ut}from"./connection-usage-guide-C2qOP6Nx.js";import{t as dt}from"./capability-links-MZdYfPKx.js";import{t as ft}from"./capability-icon-CmvCZOJX.js";import{n as pt,t as mt}from"./capability-header-actions-Ck3ILShB.js";import{t as ht}from"./connector-service-page-DKihi3WL.js";import{i as gt,n as _t,t as vt}from"./installed-connector-row-skeleton-BAe_utvG.js";import{t as yt}from"./number-input-El7Szeln.js";var Q=e(t(),1),bt=n(),$=r();function xt(e){let t=(0,bt.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(St),p=e.slice(0,2),m=Math.max(0,e.length-p.length),h=o.connect,g;t[11]!==n||t[12]!==o?(g=W(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)(Z,{type:`button`,variant:`secondary`,className:X(`h-8 justify-center px-2.5 text-xs font-medium`,e),onClick:()=>i(n),children:[(0,$.jsx)(ie,{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 bg-surface-panel p-4 transition-colors hover:bg-surface-panel-hover 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)(G,{connector:n}),t[18]=n,t[19]=b);let x;t[20]!==n||t[21]!==a?(x=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]=x):x=t[22];let S;t[23]===v?S=t[24]:(S=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]=S);let C;t[25]!==S||t[26]!==x?(C=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[x,S]}),t[25]=S,t[26]=x,t[27]=C):C=t[27];let w;t[28]!==C||t[29]!==b?(w=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[b,C]}),t[28]=C,t[29]=b,t[30]=w):w=t[30];let T;t[31]!==r||t[32]!==s?(T=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]=T):T=t[33];let E;t[34]!==r||t[35]!==o.connectedBadge?(E=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)(M,{className:`size-3`,"aria-hidden":!0}),o.connectedBadge]}):null,t[34]=r,t[35]=o.connectedBadge,t[36]=E):E=t[36];let D;t[37]!==T||t[38]!==E?(D=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start gap-2`,children:[T,E]}),t[37]=T,t[38]=E,t[39]=D):D=t[39],t[40]!==w||t[41]!==D?(l=(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[w,D]}),t[40]=w,t[41]=D,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 St(e){return!e.startsWith(`runtime.`)&&!e.startsWith(`auth.`)}var Ct=[`c0`,`c1`,`c2`,`c3`,`c4`,`c5`];function wt(e,t){return t.some(t=>t.connectorId===e.id)}var Tt=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`;function Et(){let e=(0,bt.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`div`,{className:X(`size-10 shrink-0 rounded-xl`,Tt)}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`div`,{className:`flex h-full min-h-[9.5rem] flex-col rounded-xl bg-surface-panel p-4 shadow-surface`,"aria-hidden":!0,children:(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 items-start gap-3`,children:[t,(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,$.jsx)(`div`,{className:X(`h-4 min-w-0 flex-1`,Tt)}),(0,$.jsx)(`div`,{className:X(`h-8 w-[4.5rem] shrink-0 rounded-lg`,Tt)})]}),(0,$.jsx)(`div`,{className:X(`h-3 w-full`,Tt)}),(0,$.jsx)(`div`,{className:X(`h-3 w-[88%]`,Tt)})]})]})}),e[1]=n):n=e[1],n}var Dt=(0,Q.memo)(function(e){let t=(0,bt.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=X(`touch-target flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50 data-[highlighted]:bg-surface-hover`,xe.transition),t[0]=m):m=t[0];let h=m,g;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(ce,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[1]=g):g=t[1];let _;t[2]===s?_=t[3]:(_=(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:s}),t[2]=s,t[3]=_);let v;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(E,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[4]=v):v=t[4];let y;t[5]!==s||t[6]!==_?(y=(0,$.jsx)(ot,{asChild:!0,children:(0,$.jsxs)(Z,{type:`button`,variant:`primary`,className:`shrink-0 gap-2`,"aria-label":s,children:[g,_,v]})}),t[5]=s,t[6]=_,t[7]=y):y=t[7];let b;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(fe,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[8]=b):b=t[8];let x;t[9]!==c||t[10]!==a?(x=(0,$.jsxs)(ct,{className:h,onSelect:a,children:[b,c]}),t[9]=c,t[10]=a,t[11]=x):x=t[11];let S;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,$.jsx)(Y,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[12]=S):S=t[12];let C;t[13]!==l||t[14]!==o?(C=(0,$.jsxs)(ct,{className:h,onSelect:o,children:[S,l]}),t[13]=l,t[14]=o,t[15]=C):C=t[15];let w;t[16]!==x||t[17]!==C?(w=(0,$.jsx)(st,{children:(0,$.jsxs)(lt,{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:[x,C]})}),t[16]=x,t[17]=C,t[18]=w):w=t[18];let T;t[19]!==w||t[20]!==y?(T=(0,$.jsxs)(at,{children:[y,w]}),t[19]=w,t[20]=y,t[21]=T):T=t[21];let D;t[22]===f?D=t[23]:(D=(0,$.jsx)(ht,{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)(V,{className:`size-4`,"aria-hidden":!0}),t[24]=O):O=t[24];let k;t[25]===d?k=t[26]:(k=(0,$.jsx)(ot,{asChild:!0,children:(0,$.jsx)(Z,{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 A;t[27]!==n||t[28]!==i||t[29]!==r?(A=n?(0,$.jsxs)(ct,{className:h,disabled:r,onSelect:n,children:[r?(0,$.jsx)(re,{className:`size-4 animate-spin text-fg-muted`,"aria-hidden":!0}):(0,$.jsx)(le,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),i]}):null,t[27]=n,t[28]=i,t[29]=r,t[30]=A):A=t[30];let j,M;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(j=()=>p(!0),M=(0,$.jsx)(de,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),t[31]=j,t[32]=M):(j=t[31],M=t[32]);let N;t[33]===u?N=t[34]:(N=(0,$.jsxs)(ct,{className:h,onSelect:j,children:[M,u]}),t[33]=u,t[34]=N);let P;t[35]!==A||t[36]!==N?(P=(0,$.jsx)(st,{children:(0,$.jsxs)(lt,{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:[A,N]})}),t[35]=A,t[36]=N,t[37]=P):P=t[37];let F;t[38]!==k||t[39]!==P?(F=(0,$.jsxs)(at,{children:[k,P]}),t[38]=k,t[39]=P,t[40]=F):F=t[40];let I;return t[41]!==T||t[42]!==D||t[43]!==F?(I=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2`,children:[T,D,F]}),t[41]=T,t[42]=D,t[43]=F,t[44]=I):I=t[44],I});function Ot(e=``,t=``){return{clientKey:crypto.randomUUID(),key:e,value:t}}var kt=/^([^:=]+)[:=](.*)$/;function At(e){let t=e.trim();if(!t)return null;try{let e=JSON.parse(t);if(e&&typeof e==`object`&&!Array.isArray(e))return Mt(e)}catch{}let n=[];for(let e of t.split(/\r?\n/)){let t=e.trim();if(!t)continue;let r=kt.exec(t);r&&n.push(Ot(r[1].trim(),r[2].trim()))}return n.length>0?n:null}function jt(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 Mt(e){if(!e||typeof e!=`object`)return[Ot()];let t=Object.entries(e).map(([e,t])=>typeof t==`object`&&t&&!Array.isArray(t)?{...Ot(e),reference:t}:Ot(e,t==null?``:String(t)));return t.length>0?t:[Ot()]}function Nt(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 Pt(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 Ft(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 It(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=Pt(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=jt(e.envEntries);r&&(t.env=r)}else e.envJson.trim()&&(t.env=Ft(e.envJson));delete t.oauth,delete t.auth}else{t.type=e.transport===`sse`?`sse`:`http`,t.url=e.url.trim();let n=jt(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 Lt(e,t){let n=t.oauth;return{clientKey:e,id:e,displayName:typeof t.displayName==`string`?t.displayName:``,transport:typeof t.url==`string`?t.type===`sse`?`sse`:`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:Mt(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 Rt(e,t){let n=`mcp`;try{n=e.transport===`stdio`?e.command.split(/[\\/]/).pop()||n:new URL(e.url).hostname}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 zt(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 Bt(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=Lt(e,n);return r.clientKey=crypto.randomUUID(),r.url&&=zt(r.url),r})}function Vt(e=``){return{clientKey:crypto.randomUUID(),id:e,transport:`streamable-http`,command:``,argsText:``,envJson:``,cwd:``,url:``,headers:[],oauthClientId:``,timeout:void 0,exposure:`codemode`,extra:{}}}function Ht(e){let t=e?.mcp?.servers??{};return{servers:Object.entries(t).filter(([,e])=>!Nt(e)).map(([e,t])=>Lt(e,t)).sort((e,t)=>e.id.localeCompare(t.id))}}function Ut(e){return It(e)}async function Wt(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 Gt(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:It(e)})})).payload}async function Kt(e,t){return(await l(o(`/api/mcp/drafts/${encodeURIComponent(e)}/probe`),{method:`POST`,signal:AbortSignal.any([t,AbortSignal.timeout(95e3)])})).payload}async function qt(e){await l(o(`/api/mcp/drafts/${encodeURIComponent(e)}`),{method:`DELETE`})}async function Jt(e,t=!1){let n=await l(o(`/api/mcp/drafts/${encodeURIComponent(e)}/commit`),{method:`POST`,body:JSON.stringify({enable:t})});return ve(),n.payload}async function Yt(e){return(await l(o(`/api/mcp/drafts/${encodeURIComponent(e)}/auth`),{method:`POST`})).payload}async function Xt(e,t){return(await l(o(`/api/mcp/drafts/${encodeURIComponent(e)}/auth`),{signal:t})).payload}async function Zt(e){await l(o(`/api/mcp/drafts/${encodeURIComponent(e)}/auth`),{method:`DELETE`})}async function Qt(e,t){await l(o(`/api/mcp/drafts/${encodeURIComponent(e)}/auth/redirect`),{method:`POST`,body:JSON.stringify({url:t})})}async function $t(e,t){return(await l(o(`/api/mcp/drafts/${encodeURIComponent(e)}/tools`),{signal:t})).payload.tools}async function en(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 tn(e){let t=await l(o(`/api/mcp/servers/${encodeURIComponent(e.id)}`),{method:`DELETE`,body:JSON.stringify({expectedServer:e.extra})});return ve(),t.payload}function nn(e){let t=(0,bt.c)(114),{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,v]=(0,Q.useState)(l),[y,b]=(0,Q.useState)(!0),[x,S]=(0,Q.useState)(``),[C,w]=(0,Q.useState)(``),[T,E]=(0,Q.useState)(0),D=(0,Q.useRef)(!1),O;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?(O=()=>{let e=new AbortController,t=!0;return b(!0),S(``),v([]),(a?$t(a,e.signal):Wt(n,e.signal)).then(e=>{t&&v(e)}).catch(e=>{let n=e?.status;t&&S(n===401?o.setupGatewayUnauthorized:n===403?o.setupAccessDenied:n===429?o.setupRateLimited:n===404||n===409?o.setupConflict:o.toolsLoadFailed)}).finally(()=>{t&&b(!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]=O):O=t[8];let k;t[9]!==a||t[10]!==T||t[11]!==n||t[12]!==o?(k=[n,a,T,o],t[9]=a,t[10]=T,t[11]=n,t[12]=o,t[13]=k):k=t[13],(0,Q.useEffect)(O,k);let A,j,M,N,P,F,I,L,R,z,B,V,ee,H;if(t[14]!==r||t[15]!==a||t[16]!==x||t[17]!==y||t[18]!==s||t[19]!==c||t[20]!==C||t[21]!==i||t[22]!==n||t[23]!==o.exposureLabels||t[24]!==o.setupConfigure||t[25]!==o.toolDetails||t[26]!==o.toolsClearSearch||t[27]!==o.toolsDialogSearchEmpty||t[28]!==o.toolsDialogSearchPlaceholder||t[29]!==o.toolsDialogSubtitle||t[30]!==o.toolsDialogTitle||t[31]!==o.toolsEmpty||t[32]!==o.toolsLoading||t[33]!==o.toolsRetryHint||t[34]!==o.toolsSearchSummary||t[35]!==o.toolsTitle||t[36]!==u){let e=C.trim().toLowerCase(),l;if(t[51]!==n){let e;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(e=/-/g,t[53]=e):e=t[53],l=n.replace(e,`_`),t[51]=n,t[52]=l}else l=t[52];let p=`mcp__${l}__`,v=u.filter(t=>`${t.name} ${t.description}`.toLowerCase().includes(e));M=_,I=!0,t[54]===s?L=t[55]:(L=e=>{e||s()},t[54]=s,t[55]=L),j=m,t[56]===Symbol.for(`react.memo_cache_sentinel`)?(F=(0,$.jsx)(d,{className:`fixed inset-0 z-[60] bg-scrim`}),t[56]=F):F=t[56],A=h,t[57]===i?H=t[58]:(H=e=>{(D.current||i)&&e.preventDefault(),!D.current&&i?.isConnected&&i.focus()},t[57]=i,t[58]=H),N=`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 b;t[59]===o.toolsDialogTitle?b=t[60]:(b=(0,$.jsx)(g,{className:`font-semibold`,children:o.toolsDialogTitle}),t[59]=o.toolsDialogTitle,t[60]=b);let S;t[61]!==r||t[62]!==x||t[63]!==y||t[64]!==n||t[65]!==o.toolsDialogSubtitle||t[66]!==u.length?(S=y||x?r||n:o.toolsDialogSubtitle.replace(`{{serverId}}`,r||n).replace(`{{count}}`,String(u.length)),t[61]=r,t[62]=x,t[63]=y,t[64]=n,t[65]=o.toolsDialogSubtitle,t[66]=u.length,t[67]=S):S=t[67];let T;t[68]===S?T=t[69]:(T=(0,$.jsx)(f,{className:`mt-1 break-words text-sm text-fg-muted`,children:S}),t[68]=S,t[69]=T);let E;t[70]===Symbol.for(`react.memo_cache_sentinel`)?(E=e=>w(e.target.value),t[70]=E):E=t[70];let O;t[71]!==C||t[72]!==o.toolsDialogSearchPlaceholder?(O=(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:C,onChange:E,placeholder:o.toolsDialogSearchPlaceholder,"aria-label":o.toolsDialogSearchPlaceholder}),t[71]=C,t[72]=o.toolsDialogSearchPlaceholder,t[73]=O):O=t[73];let k=e&&!y&&!x?(0,$.jsx)(`p`,{role:`status`,className:`mt-2 text-xs text-fg-muted`,children:o.toolsSearchSummary.replace(`{{visible}}`,String(v.length)).replace(`{{count}}`,String(u.length))}):null;t[74]!==b||t[75]!==T||t[76]!==O||t[77]!==k?(P=(0,$.jsxs)(`div`,{className:`shrink-0 border-b border-edge p-5`,children:[b,T,O,k]}),t[74]=b,t[75]=T,t[76]=O,t[77]=k,t[78]=P):P=t[78],R=`min-h-0 flex-1 overflow-y-auto p-5`,z=y,t[79]!==o.toolsTitle||t[80]!==u.length?(B=o.toolsTitle.replace(`{{count}}`,String(u.length)),t[79]=o.toolsTitle,t[80]=u.length,t[81]=B):B=t[81],V=!y&&!x&&u.length&&!e?(0,$.jsx)(`div`,{className:`mb-5`,children:(0,$.jsx)(ut,{target:{kind:`mcp`,id:n,name:r||n},preview:!!a,onStart:s})}):null,ee=y?(0,$.jsx)(`div`,{role:`status`,"aria-label":o.toolsLoading,className:`space-y-3`,children:[0,1,2].map(an)}):x?(0,$.jsxs)(`div`,{role:`alert`,className:`space-y-3`,children:[(0,$.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-sm text-danger`,children:x}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:o.toolsRetryHint}),c?(0,$.jsx)(Z,{variant:`secondary`,onClick:()=>{D.current=!0,c()},children:o.setupConfigure}):null]}):v.length?(0,$.jsx)(`div`,{className:`space-y-3`,children:v.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(p)?e.name.slice(p.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)(Z,{variant:`secondary`,onClick:()=>w(``),children:o.toolsClearSearch}):null]}),t[14]=r,t[15]=a,t[16]=x,t[17]=y,t[18]=s,t[19]=c,t[20]=C,t[21]=i,t[22]=n,t[23]=o.exposureLabels,t[24]=o.setupConfigure,t[25]=o.toolDetails,t[26]=o.toolsClearSearch,t[27]=o.toolsDialogSearchEmpty,t[28]=o.toolsDialogSearchPlaceholder,t[29]=o.toolsDialogSubtitle,t[30]=o.toolsDialogTitle,t[31]=o.toolsEmpty,t[32]=o.toolsLoading,t[33]=o.toolsRetryHint,t[34]=o.toolsSearchSummary,t[35]=o.toolsTitle,t[36]=u,t[37]=A,t[38]=j,t[39]=M,t[40]=N,t[41]=P,t[42]=F,t[43]=I,t[44]=L,t[45]=R,t[46]=z,t[47]=B,t[48]=V,t[49]=ee,t[50]=H}else A=t[37],j=t[38],M=t[39],N=t[40],P=t[41],F=t[42],I=t[43],L=t[44],R=t[45],z=t[46],B=t[47],V=t[48],ee=t[49],H=t[50];let te;t[82]!==R||t[83]!==z||t[84]!==B||t[85]!==V||t[86]!==ee?(te=(0,$.jsxs)(`div`,{className:R,"aria-busy":z,"aria-label":B,children:[V,ee]}),t[82]=R,t[83]=z,t[84]=B,t[85]=V,t[86]=ee,t[87]=te):te=t[87];let ne;t[88]===Symbol.for(`react.memo_cache_sentinel`)?(ne=()=>E(rn),t[88]=ne):ne=t[88];let re;t[89]!==y||t[90]!==o.refreshTools?(re=(0,$.jsx)(Z,{variant:`secondary`,disabled:y,onClick:ne,children:o.refreshTools}),t[89]=y,t[90]=o.refreshTools,t[91]=re):re=t[91];let U;t[92]!==s||t[93]!==o.toolsDialogClose?(U=(0,$.jsx)(p,{asChild:!0,children:(0,$.jsx)(Z,{onClick:s,children:o.toolsDialogClose})}),t[92]=s,t[93]=o.toolsDialogClose,t[94]=U):U=t[94];let ie;t[95]!==re||t[96]!==U?(ie=(0,$.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge p-4`,children:[re,U]}),t[95]=re,t[96]=U,t[97]=ie):ie=t[97];let W;t[98]!==A||t[99]!==N||t[100]!==P||t[101]!==te||t[102]!==ie||t[103]!==H?(W=(0,$.jsxs)(A,{onCloseAutoFocus:H,className:N,children:[P,te,ie]}),t[98]=A,t[99]=N,t[100]=P,t[101]=te,t[102]=ie,t[103]=H,t[104]=W):W=t[104];let G;t[105]!==j||t[106]!==F||t[107]!==W?(G=(0,$.jsxs)(j,{children:[F,W]}),t[105]=j,t[106]=F,t[107]=W,t[108]=G):G=t[108];let K;return t[109]!==M||t[110]!==I||t[111]!==L||t[112]!==G?(K=(0,$.jsx)(M,{open:I,onOpenChange:L,children:G}),t[109]=M,t[110]=I,t[111]=L,t[112]=G,t[113]=K):K=t[113],K}function rn(e){return e+1}function an(e){return(0,$.jsx)(ge,{className:`h-24 w-full`},e)}function on(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 sn({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=on(e),_=e.extra.enabled===!1,v=_?N:t?M:z,y=e.transport===`stdio`?pe:ue,b=_?n.setupDisabled:t?r.customCheckSucceeded:r.customUnchecked,x=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 bg-surface-panel p-4 transition-colors hover:bg-surface-panel-hover 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:x?r.customLastChecked.replace(`{{time}}`,x):void 0,"aria-label":x?`${b} · ${r.customLastChecked.replace(`{{time}}`,x)}`:b,className:X(`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)(Z,{variant:`ghost`,className:`h-8 px-2 py-1 text-xs`,onClick:i,children:n.setupConfigure}),(0,$.jsx)(Z,{ref:u,variant:`secondary`,className:`h-8 px-2 py-1 text-xs shadow-none sm:shadow-none`,disabled:_,onClick:()=>l(!0),children:o===`zh`?`用法与工具`:`Usage & tools`}),(0,$.jsxs)(at,{children:[(0,$.jsx)(ot,{asChild:!0,children:(0,$.jsx)(Z,{variant:`ghost`,className:`size-8 p-0`,"aria-label":r.customManage.replace(`{{name}}`,h),title:r.customManage.replace(`{{name}}`,h),children:(0,$.jsx)(V,{className:`size-4`,"aria-hidden":!0})})}),(0,$.jsx)(st,{children:(0,$.jsx)(lt,{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)(ct,{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)(me,{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)(nn,{serverId:e.id,displayName:e.displayName,returnFocusTo:u.current,t:n,onClose:()=>l(!1),onConfigure:()=>{l(!1),i()}}):null,(0,$.jsx)(it,{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 cn(e){let t=(0,bt.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)(ce,{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)(Z,{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)(sn,{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 ln(e){return e.format===`agent-plugin`&&!!e.pluginId&&(!!e.setup?.authorizations?.length||e.authorizationStatus===`required`||!!e.components?.mcp.some(e=>e.type!==`stdio`))}function un(e){let t=(0,bt.c)(51),{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,g;t[15]===n.setup?.authorizations?g=t[16]:(g=n.setup?.authorizations??[],t[15]=n.setup?.authorizations,t[16]=g);let _=g,v=_.length===1?_[0].title:n.name,y=l||!u&&(d||n.readiness===`blocked`||n.readiness===`degraded`),b=l?z:u?N:y?j:M,x=n.branding?.iconUrl,S;t[17]===x?S=t[18]:(S=(0,$.jsx)(ft,{iconUrl:x,fallback:q,className:`size-9`}),t[17]=x,t[18]=S);let C;t[19]===v?C=t[20]:(C=(0,$.jsx)(`span`,{className:`block truncate text-sm font-semibold text-fg`,title:v,children:v}),t[19]=v,t[20]=C);let w=y?`text-amber-700 dark:text-amber-300`:u?`text-fg-muted`:`text-emerald-700 dark:text-emerald-300`,T;t[21]===w?T=t[22]:(T=X(`mt-1 inline-flex items-center gap-1 text-[11px]`,w),t[21]=w,t[22]=T);let E;t[23]===b?E=t[24]:(E=(0,$.jsx)(b,{className:`size-3.5`,"aria-hidden":!0}),t[23]=b,t[24]=E);let O;t[25]!==p||t[26]!==T||t[27]!==E?(O=(0,$.jsxs)(`span`,{className:T,children:[E,p]}),t[25]=p,t[26]=T,t[27]=E,t[28]=O):O=t[28];let k;t[29]!==O||t[30]!==C?(k=(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[C,O]}),t[29]=O,t[30]=C,t[31]=k):k=t[31];let A;t[32]!==k||t[33]!==S?(A=(0,$.jsxs)(`span`,{className:`flex w-full min-w-0 items-start gap-3`,children:[S,k]}),t[32]=k,t[33]=S,t[34]=A):A=t[34];let P=n.name,F;t[35]===c?F=t[36]:(F=c(`由插件提供`,`Provided by plugin`),t[35]=c,t[36]=F);let I;t[37]!==n.name||t[38]!==F?(I=(0,$.jsxs)(`span`,{className:`mt-2 block w-full truncate text-xs leading-5 text-fg-muted`,title:P,children:[F,` · `,n.name]}),t[37]=n.name,t[38]=F,t[39]=I):I=t[39];let L=y?`text-accent-fg`:`text-fg-muted`,R;t[40]===L?R=t[41]:(R=X(`mt-auto flex w-full items-center justify-end gap-1 pt-2 text-xs`,L),t[40]=L,t[41]=R);let B;t[42]===Symbol.for(`react.memo_cache_sentinel`)?(B=(0,$.jsx)(D,{className:`size-3.5 shrink-0`,"aria-hidden":!0}),t[42]=B):B=t[42];let V;t[43]!==h||t[44]!==R?(V=(0,$.jsxs)(`span`,{className:R,children:[h,B]}),t[43]=h,t[44]=R,t[45]=V):V=t[45];let ee;return t[46]!==i||t[47]!==A||t[48]!==I||t[49]!==V?(ee=(0,$.jsxs)(`button`,{type:`button`,onClick:i,className:`flex min-h-[8.75rem] w-full min-w-0 flex-col rounded-xl bg-surface-panel p-4 text-left transition-colors hover:bg-surface-panel-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,children:[A,I,V]}),t[46]=i,t[47]=A,t[48]=I,t[49]=V,t[50]=ee):ee=t[50],ee}function dn(e){let t=e.connectedAt?Date.parse(e.connectedAt):0;return Number.isFinite(t)?t:0}function fn(e,t){return e.status===`active`&&t.status!==`active`?-1:e.status!==`active`&&t.status===`active`?1:e.isCurrentAuthorization===t.isCurrentAuthorization?dn(t)-dn(e):e.isCurrentAuthorization?-1:1}function pn(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(fn);return{key:e,primary:n[0],authorizations:n}}).sort((e,t)=>fn(e.primary,t.primary))}var mn=X(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,Qe);function hn(e){return e.materialized.type===`composio`?e.materialized.toolkit:null}function gn(e,t){return e===`write`?t.composioScopeWrite:e===`admin`?t.composioScopeAdmin:t.composioScopeRead}function _n(e,t,n){return e.status===`connected`?U(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 vn(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 yn(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 bn({instance:e,t,onChanged:n}){let r=hn(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,_]=(0,Q.useState)(null),[v,y]=(0,Q.useState)(null),[b,x]=(0,Q.useState)([]),[S,C]=(0,Q.useState)({}),[w,T]=(0,Q.useState)(`read`),[E,D]=(0,Q.useState)(!1),[A,N]=(0,Q.useState)(null),[P,F]=(0,Q.useState)(!1),[I,L]=(0,Q.useState)(null),[R,z]=(0,Q.useState)(null),[B,V]=(0,Q.useState)(!1),[ee,H]=(0,Q.useState)(!1),[te,ie]=(0,Q.useState)(!1),W=(0,Q.useRef)(0),G=(0,Q.useRef)(0),K=(0,Q.useMemo)(()=>pn(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;D(!0),N(null);let t=++W.current;try{let e=(await Promise.allSettled([oe(Ne()).then(e=>{t===W.current&&(o(e.filter(e=>e.toolkit.toLowerCase()===r.toLowerCase())),V(!0))}),oe(Ie(r)).then(e=>{t===W.current&&T(e)}),oe(Ke(r)).then(e=>{t===W.current&&(p(e.policy),h(e.agents))})])).find(e=>e.status===`rejected`);t===W.current&&e?.status===`rejected`&&N(String(e.reason instanceof Error?e.reason.message:e.reason))}finally{t===W.current&&D(!1)}},[e.materialized,r,oe]);(0,Q.useEffect)(()=>(se(),()=>{W.current++}),[se]);let q=(0,Q.useCallback)(async()=>{if(!r)return;let e=++G.current;ie(!0),F(!1);let t=t=>n=>{e===G.current&&t(n)},n=await Promise.allSettled([oe(qe(r)).then(t(l)),oe(Xe(20)).then(t(e=>d(e.filter(e=>!e.toolkit||e.toolkit.toLowerCase()===r.toLowerCase())))),oe(Ue(r)).then(t(y)),oe(ze(r)).then(t(_))]);e===G.current&&(F(n.some(e=>e.status===`rejected`)),ie(!1))},[r,oe]);(0,Q.useEffect)(()=>(ee&&q(),()=>{G.current++}),[ee,q]),(0,Q.useEffect)(()=>{let e=!1,t=pn(a).map(e=>e.primary).filter(e=>e.supportsLearning&&e.accountId);if(t.length)return oe(Ye()).then(t=>{e||x(t)}).catch(()=>{}),Promise.allSettled(t.map(async e=>[e.accountId,await oe(Be(e.accountId))])).then(t=>{e||C(Object.fromEntries(t.flatMap(e=>e.status===`fulfilled`?[e.value]:[])))}),()=>{e=!0}},[a,oe]);let ce=(0,Q.useCallback)(async i=>{if(!r)return;let a=$e()?null:window.open(`about:blank`,`_blank`);a&&(a.opener=null),D(!0),N(null);try{if(!$e()&&!a)throw Error(`Allow popups to open the authorization page.`);let t=await Re(e.connectorId,i);if(!t.authorizationUrl)throw Error(`The authorization provider did not return an authorization URL.`);if($e()){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 Ze(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(ae(e,t))}finally{a?.close(),D(!1)}},[e.connectorId,se,n,t,r]),J=(0,Q.useCallback)(async t=>{D(!0),N(null);try{await Ee(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{D(!1)}},[e.config,e.instanceId,se,n]),ue=async e=>{let t=$e()?null:window.open(`about:blank`,`_blank`);t&&(t.opener=null),N(null);try{let n=await Fe(e.id);if(n.authorizationUrl)if($e())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))}},de=(0,Q.useCallback)(async e=>{if(r){T(e),N(null);try{await ke(r,e)}catch(e){N(e instanceof Error?e.message:String(e)),await se()}}},[se,r]),fe=(0,Q.useCallback)(async e=>{if(r){N(null);try{p(await Te(r,e))}catch(e){N(e instanceof Error?e.message:String(e))}}},[r]),pe=(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];fe({allowedAgentIds:n})},[fe,f]),Y=(0,Q.useCallback)(async e=>{D(!0),N(null);try{await e(),await se()}catch(e){N(e instanceof Error?e.message:String(e))}finally{D(!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 he=K.filter(e=>e.primary.status===`active`).length,_e=he>0?t.composioAddAccount:t.composioConnectAccount,ve=B&&he>0,ye=v?.requiresCustomAuthConfig===!0,be=v?.authConfigs.filter(e=>e.status===`ENABLED`&&e.isEnabledForToolRouter)??[];return(0,$.jsxs)(`div`,{className:`space-y-5`,children:[(0,$.jsxs)(`section`,{className:`flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`span`,{className:X(`inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-xs font-medium`,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)(M,{className:`size-3.5`}):(0,$.jsx)(j,{className:`size-3.5`}),ve?t.connectionReady:B||A?t.connectionNeedsSetup:t.connectionChecking]}),B&&(0,$.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:U(t.composioAccountCount,{count:String(K.length)})})]}),(0,$.jsxs)(Z,{variant:`primary`,className:`shrink-0`,disabled:E,onClick:()=>void ce(),children:[E?(0,$.jsx)(re,{className:`size-4 animate-spin`}):(0,$.jsx)(ne,{className:`size-4`}),_e]})]}),A?(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:A}),(0,$.jsx)(Z,{variant:`secondary`,disabled:E,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:_n(g,he,t)}),g.recovery===`none`?null:(0,$.jsx)(Z,{variant:`secondary`,disabled:E,onClick:()=>void(g.recovery===`retry`?se():ce()),children:g.recovery===`retry`?t.composioRetry:t.composioReconnectAccount})]}):null,ye&&be.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:w===`read`?t.composioAccessReadHint:w===`admin`?t.composioAccessAdminHint:t.composioAccessWriteHint})]}),(0,$.jsxs)(O,{value:w,onChange:e=>void de(e.currentTarget.value),children:[(0,$.jsx)(k,{value:`read`,children:t.composioAccessReadOnly}),(0,$.jsx)(k,{value:`write`,children:t.composioAccessReadWrite}),w===`admin`?(0,$.jsx)(k,{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)(O,{value:f.confirmationPolicy,onChange:e=>void fe({confirmationPolicy:e.currentTarget.value}),children:[(0,$.jsx)(k,{value:`writes`,children:t.composioConfirmWrites}),(0,$.jsx)(k,{value:`always`,children:t.composioConfirmAlways}),f.confirmationPolicy===`never`?(0,$.jsx)(k,{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:X(`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 fe({allowedAgentIds:[]}),children:t.composioAllowedAgentsAllOption}),m.map(e=>(0,$.jsx)(`button`,{type:`button`,className:X(`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:()=>pe(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:E,onChange:e=>void fe({selectedAccountIds:e.currentTarget.checked?null:[]})}),i?`所有账号(包括以后新增)`:`All accounts, including new ones`]}),f.selectedAccountIds!==null&&K.map(({primary:e})=>e.accountId&&(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,disabled:E,checked:f.selectedAccountIds.includes(e.accountId),onChange:t=>void fe({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}),B&&(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:U(t.composioAccountCount,{count:String(K.length)})})]}),(0,$.jsxs)(Z,{variant:`ghost`,className:`h-8 px-2 text-xs`,disabled:E,onClick:()=>void se(),children:[(0,$.jsx)(le,{className:X(`size-3.5`,E&&`animate-spin`)}),t.refresh]})]}),K.length?(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-xl border border-edge bg-surface-base`,children:K.map(e=>{let r=e.primary,a=b.find(e=>r.accountId?e.accountId===r.accountId:e.connectionId===r.id),o=r.accountId?S[r.accountId]:void 0;return(0,$.jsxs)(`article`,{className:`px-4 py-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col items-start justify-between gap-3 sm:flex-row`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:(0,$.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:r.alias??r.workspace??r.accountEmail??r.username??t.composioUnnamedAuthorization})}),(0,$.jsx)(`p`,{className:`mt-1 break-all text-xs text-fg-muted`,children:r.accountEmail??r.username??r.workspace??r.accountId}),r.backendLabel&&(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:r.backendLabel}),(0,$.jsx)(`p`,{className:X(`mt-1 text-xs`,r.status===`active`?`text-emerald-700 dark:text-emerald-300`:`text-amber-700 dark:text-amber-300`),children:r.accountEnabled===!1?i?`已暂停`:`Paused`:vn(r.status,t)}),a?(0,$.jsx)(`p`,{className:X(`mt-1 text-xs`,a.status===`failed`?`text-red-600`:`text-fg-subtle`),children:U(t.connectorLearningStatus,{status:yn(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)(Z,{variant:`secondary`,className:`h-8 px-2.5 text-xs`,onClick:()=>void ue(r),children:i?`继续授权`:`Continue authorization`}),r.accountId&&(0,$.jsx)(Z,{variant:`ghost`,className:`h-8 px-2.5 text-xs text-danger`,disabled:E,onClick:()=>z(r.accountId),children:i?`断开`:`Disconnect`}),r.accountId&&r.status!==`active`&&(0,$.jsx)(Z,{variant:`secondary`,className:`h-8 px-2.5 text-xs`,disabled:E,onClick:()=>void ce(r.accountId),children:t.composioReconnectAccount}),r.accountId&&(0,$.jsx)(Z,{variant:`secondary`,className:`h-8 px-2.5 text-xs`,disabled:E,onClick:()=>void Y(()=>Ae(r.accountId,{enabled:r.accountEnabled===!1})),children:r.accountEnabled===!1?i?`启用`:`Enable`:i?`暂停`:`Pause`}),r.supportsLearning&&r.status===`active`&&r.accountEnabled!==!1?(0,$.jsxs)(Z,{variant:`secondary`,className:`h-8 shrink-0 px-2.5 text-xs`,disabled:E,onClick:()=>void Y(async()=>{if(!r.accountId)throw Error(`Connector account is unavailable.`);await Se(r.accountId),await n?.()}),children:[(0,$.jsx)(le,{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:E,checked:r.allowedAgentIds==null,onChange:e=>void Y(()=>Ae(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:E,checked:r.allowedAgentIds.includes(e.id),onChange:t=>{let n=t.currentTarget.checked;Y(()=>Ae(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:E,onChange:e=>void Y(()=>je(r.accountId,{scanEnabled:e.currentTarget.checked}))}),t.connectorScheduledScan]}),o.scanEnabled?(0,$.jsxs)(`label`,{className:`sm:col-span-2`,children:[t.connectorScanInterval,(0,$.jsxs)(O,{className:`mt-1`,value:String(o.intervalMinutes??30),disabled:E,onChange:e=>void Y(()=>je(r.accountId,{intervalMinutes:Number(e.currentTarget.value)})),children:[(0,$.jsxs)(k,{value:`5`,children:[`5 `,t.connectorMinutes]}),(0,$.jsxs)(k,{value:`15`,children:[`15 `,t.connectorMinutes]}),(0,$.jsxs)(k,{value:`30`,children:[`30 `,t.connectorMinutes]}),(0,$.jsxs)(k,{value:`60`,children:[`60 `,t.connectorMinutes]})]})]}):null]}):null,(0,$.jsxs)(`label`,{className:`block`,children:[t.composioAccountAlias,(0,$.jsx)(`input`,{className:X(mn,`mt-1 h-8 py-1 text-xs`),defaultValue:r.alias??``,onBlur:e=>{e.currentTarget.value!==(r.alias??``)&&Y(()=>we(r.id,{alias:e.currentTarget.value}))}})]}),(0,$.jsx)(`div`,{className:`space-y-2`,children:e.authorizations.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`p`,{className:`min-w-0 break-all font-mono text-fg-subtle`,children:[t.composioAuthorizationId,`: `,e.providerConnectionId]}),(0,$.jsx)(Z,{variant:`ghost`,className:`size-7 shrink-0 p-0 text-danger`,title:t.composioRevoke,disabled:E,onClick:()=>L(e.id),children:(0,$.jsx)(me,{className:`size-3.5`})})]},e.id))}),(0,$.jsx)(`div`,{className:`flex justify-end gap-1`,children:(0,$.jsx)(Z,{variant:`ghost`,className:`size-8 p-0`,title:t.refresh,disabled:E,onClick:()=>void Y(()=>Me(r.id)),children:(0,$.jsx)(le,{className:`size-4`})})})]})]})]},e.key)})}):E&&!B?(0,$.jsxs)(`div`,{"aria-busy":`true`,"aria-label":t.connectionChecking,className:`space-y-3`,children:[(0,$.jsx)(ge,{className:`h-16 w-full`}),(0,$.jsx)(ge,{className:`h-16 w-full`})]}):B?(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=>H(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:[te?(0,$.jsx)(ge,{"aria-label":t.connectionChecking,className:`h-16 w-full`}):null,P?(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)(Z,{variant:`ghost`,disabled:te,onClick:()=>void q(),children:t.composioRetry})]}):null,v?.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:ye?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)(O,{className:`mt-3`,value:typeof e.config?.authConfigId==`string`?e.config.authConfigId:``,disabled:E,onChange:e=>void J(e.currentTarget.value),children:[ye?null:(0,$.jsx)(k,{value:``,children:t.composioAuthConfigManaged}),ye&&typeof e.config?.authConfigId!=`string`?(0,$.jsx)(k,{value:``,disabled:!0,children:t.composioAuthConfigSelect}):null,be.map(e=>(0,$.jsxs)(k,{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:[gn(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)(it,{open:R!==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=R;z(null),e&&Y(()=>Ve(e))},onCancel:()=>z(null)}),(0,$.jsx)(it,{open:I!==null,title:t.composioRevoke,description:t.composioRevokeConfirm,confirmLabel:t.composioRevoke,cancelLabel:t.modalCancel,destructive:!0,onConfirm:()=>{let e=I;L(null),e&&Y(()=>Ce(e))},onCancel:()=>L(null)})]})}var xn=X(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,Qe);function Sn(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 Cn(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 wn({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),[v,y]=(0,Q.useState)(!1),[b,x]=(0,Q.useState)(null),[S,C]=(0,Q.useState)(()=>Sn(t,e)),[w,T]=(0,Q.useState)(null),[E,D]=(0,Q.useState)(!1),[O,k]=(0,Q.useState)(null),A=t?.setup.config??[],j=(e.materialized.type===`mcp`||e.materialized.type===`memorySource`)&&A.length>0&&(t?.setup.secrets??[]).length===0,M=e.materialized.type===`mcp`,N=e.materialized.type===`composio`,P=e.materialized.type===`memorySource`,F=t?W(t,i):null,I=(0,Q.useCallback)(async()=>{D(!0),T(null);try{let t=await Oe(e.instanceId);k(t),t.ok||T(t.error??t.action??i.healthStatusLabels[t.status]),await r()}catch(e){T(e instanceof Error?e.message:String(e))}finally{D(!1)}},[e.instanceId,r,i.healthStatusLabels]),L=(0,Q.useCallback)(async()=>{o(!0),T(null);try{await Je(e.instanceId),await r(),n()}catch(e){T(e instanceof Error?e.message:String(e)),o(!1)}},[e.instanceId,r,n]),R=(0,Q.useCallback)(async()=>{if(!(!t||!j)){u(!0),T(null);try{let n={};for(let e of t.setup.config??[]){let t=Cn(e.type,S[e.key]??``);t!==void 0&&(n[e.key]=t)}await Ee(e.instanceId,{config:n}),await r()}catch(e){T(e instanceof Error?e.message:String(e))}finally{u(!1)}}},[S,t,e.instanceId,r,j]),z=(0,Q.useCallback)(async()=>{y(!0),x(null),T(null);try{let t=await De(e.connectorId);x(t.recordIds.length),await r()}catch(e){T(e instanceof Error?e.message:String(e))}finally{y(!1)}},[e.connectorId,r]);return(0,$.jsxs)(_,{open:!0,onOpenChange:e=>{e||n()},children:[(0,$.jsxs)(m,{children:[(0,$.jsx)(d,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(h,{className:X(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,N?`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)(G,{connector:t,size:`lg`}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(g,{className:`text-base font-semibold text-fg`,children:e.displayName}),(0,$.jsx)(f,{className:`mt-1 text-sm text-fg-muted`,children:F??(e.materialized.type===`mcp`?U(i.mcpServerRuntime,{serverId:e.materialized.serverId}):U(i.runtimeLabel,{runtime:e.materialized.type}))})]})]}),(0,$.jsx)(p,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,className:X(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,xe.focusRingPanel),"aria-label":i.modalClose,children:[(0,$.jsx)(he,{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:[w?(0,$.jsx)(`p`,{className:`mb-4 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:w}):null,e.enabled&&(O?O.ok:e.connectionStatus===`connected`||e.status===`connected`||e.usage.lastHealthStatus===`ok`)?(0,$.jsx)(`div`,{className:`mb-5`,children:(0,$.jsx)(ut,{target:{kind:`connector`,id:e.connectorId,name:e.displayName},onStart:n})}):null,M?(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:O?.ok?U(i.toolsAvailable,{count:String(O.toolCount)}):O?i.healthStatusLabels[O.status]:e.usage.lastHealthStatus?i.healthStatusLabels[e.usage.lastHealthStatus]:i.healthNotTested}),(0,$.jsxs)(Z,{variant:`secondary`,"aria-busy":E,disabled:E||!e.enabled,onClick:()=>void I(),children:[E?(0,$.jsx)(re,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(le,{className:`size-4`,"aria-hidden":!0}),i.test]})]}),j?A.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:xn,value:S[e.key]??``,placeholder:e.placeholder,onChange:t=>C(n=>({...n,[e.key]:t.currentTarget.value}))})]},e.key)):null]}):null,N?(0,$.jsx)(bn,{instance:e,t:i,onChanged:r}):null,P?(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}),F?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:F}):null,b===null?null:(0,$.jsx)(`p`,{className:`mt-1 text-xs text-emerald-600`,children:U(i.connectedSourceSynced,{count:String(b)})})]}),(0,$.jsxs)(Z,{disabled:v,onClick:()=>void z(),children:[v?(0,$.jsx)(re,{className:`size-4 animate-spin`}):(0,$.jsx)(B,{className:`size-4`}),i.composioSyncNow]})]}),j?(0,$.jsx)(`div`,{className:`grid gap-3 rounded-xl border border-edge bg-surface-base p-4`,children:A.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:xn,value:S[e.key]??``,placeholder:e.placeholder,onChange:t=>C(n=>({...n,[e.key]:t.currentTarget.value}))})]},e.key))}):null]}):null,!M&&!N&&!P?(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)(Z,{variant:`secondary`,className:`shrink-0 border-danger/30 text-danger hover:bg-danger/10`,disabled:a,onClick:()=>c(!0),children:[a?(0,$.jsx)(re,{className:`size-4 animate-spin`}):(0,$.jsx)(me,{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)(Z,{variant:`secondary`,onClick:n,children:i.modalClose}),(M||P)&&j?(0,$.jsxs)(Z,{variant:`primary`,disabled:l,onClick:()=>void R(),children:[l?(0,$.jsx)(re,{className:`size-4 animate-spin`}):(0,$.jsx)(J,{className:`size-4`}),i.modalSave]}):null]})]})]}),(0,$.jsx)(it,{open:s,title:U(i.removeConfirmTitle,{name:e.displayName}),description:i.removeConfirmDescription,confirmLabel:i.removeConfirmAction,cancelLabel:i.modalCancel,destructive:!0,onConfirm:()=>{c(!1),L()},onCancel:()=>{a||c(!1)}})]})}function Tn(e){let t=(0,bt.c)(2),n;return t[0]===e?n=t[1]:(n=e.instance.materialized.type===`cli`&&e.definition?(0,$.jsx)(K,{definition:e.definition,instance:e.instance,onClose:e.onClose,onChanged:e.onChanged}):(0,$.jsx)(wn,{...e}),t[0]=e,t[1]=n),n}function En(e){let t=(0,bt.c)(37),{instance:n,definition:r,highlighted:i,onOpenDetails:a,t:o}=e,s=i!==void 0&&i,c;t[0]!==r||t[1]!==n?(c=v(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?W(r,o):null,t[3]=r,t[4]=o,t[5]=u):u=t[5];let d=u,f,p,m,h,g;t[6]!==l||t[7]!==r||t[8]!==n.displayName||t[9]!==o.connectionChecking||t[10]!==o.connectionNeedsSetup||t[11]!==o.connectionReady?(p=l===`ready`?{label:o.connectionReady,Icon:M,className:`text-emerald-700 dark:text-emerald-300`}:l===`needs_setup`?{label:o.connectionNeedsSetup,Icon:j,className:`text-amber-700 dark:text-amber-300`}:{label:o.connectionChecking,Icon:z,className:`text-fg-muted`},f=gt,h=n.displayName,t[17]===r?g=t[18]:(g=(0,$.jsx)(G,{connector:r,size:`sm`}),t[17]=r,t[18]=g),m=X(`mt-1 inline-flex items-center gap-1 text-[11px]`,p.className),t[6]=l,t[7]=r,t[8]=n.displayName,t[9]=o.connectionChecking,t[10]=o.connectionNeedsSetup,t[11]=o.connectionReady,t[12]=f,t[13]=p,t[14]=m,t[15]=h,t[16]=g):(f=t[12],p=t[13],m=t[14],h=t[15],g=t[16]);let _;t[19]===p.Icon?_=t[20]:(_=(0,$.jsx)(p.Icon,{className:`size-3.5`,"aria-hidden":!0}),t[19]=p.Icon,t[20]=_);let y;t[21]!==p.label||t[22]!==m||t[23]!==_?(y=(0,$.jsxs)(`span`,{className:m,children:[_,p.label]}),t[21]=p.label,t[22]=m,t[23]=_,t[24]=y):y=t[24];let b;t[25]!==n||t[26]!==a?(b=()=>a(n),t[25]=n,t[26]=a,t[27]=b):b=t[27];let x;return t[28]!==f||t[29]!==d||t[30]!==s||t[31]!==o.installedDetails||t[32]!==h||t[33]!==g||t[34]!==y||t[35]!==b?(x=(0,$.jsx)(f,{name:h,icon:g,status:y,description:d,action:o.installedDetails,highlighted:s,onOpen:b}),t[28]=f,t[29]=d,t[30]=s,t[31]=o.installedDetails,t[32]=h,t[33]=g,t[34]=y,t[35]=b,t[36]=x):x=t[36],x}function Dn(e,t){return Vt()}function On(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:[Ot()],additionalHeaders:r===`bearer`?t.filter(e=>e!==n):r===`oauth`?t:[]}}function kn(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,Ot(`Authorization`,`Bearer ${e}`)]}return t.mode===`apiKey`&&(r=[...r,Ot(t.headerName.trim(),t.apiKey.trim())]),{...e,extra:n,headers:r,oauthClientId:t.mode===`oauth`?e.oauthClientId:``}}function An(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 jn(){return X(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,Qe)}function Mn({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,Ot()])},S=e=>{let t=u.filter((t,n)=>n!==e);d(t.length>0?t:[Ot()])},C=async()=>{try{let e=await be();if(!e){y(!0);return}let t=At(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)(Z,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5 px-2 text-xs`,onClick:()=>void C(),children:[(0,$.jsx)(P,{className:`size-3.5`,"aria-hidden":!0}),i]}):null]}),(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:u.map((e,t)=>(0,$.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[minmax(0,1fr)_auto_auto] items-center gap-2 sm:grid-cols-[minmax(0,1fr)_minmax(0,1.4fr)_auto_auto]`,children:[(0,$.jsx)(`input`,{className:X(jn(),`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:X(jn(),`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)(Z,{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)(H,{className:`size-4`,"aria-hidden":!0}):(0,$.jsx)(te,{className:`size-4`,"aria-hidden":!0})}),(0,$.jsx)(Z,{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)(me,{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)(it,{open:v,title:o,description:a,confirmLabel:s,onConfirm:()=>y(!1),onCancel:()=>y(!1)}),(0,$.jsxs)(`button`,{type:`button`,className:X(`self-start text-sm text-accent hover:underline`,xe.press),onClick:x,children:[`+ `,n]})]})}var Nn=X(`w-full min-w-0 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,Qe);function Pn(e){let t=(0,bt.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=X(Nn,`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(Fn),t[11]=h):h=t[11];let g;t[12]===c?g=t[13]:(g=c?(0,$.jsx)(H,{className:`size-4`,"aria-hidden":!0}):(0,$.jsx)(te,{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)(Z,{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 Fn(e){return!e}function In(e){let t=(0,bt.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)(Mn,{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 Ln(e){let t=(0,bt.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=X(Nn,`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)(k,{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)(k,{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)(O,{"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 _;t[22]!==n.mode||t[23]!==i.setupAuthOAuthHint?(_=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]=_):_=t[24];let v;t[25]!==n.mode||t[26]!==i.setupExistingHint?(v=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]=v):v=t[27];let y;t[28]!==n.mode||t[29]!==n.token||t[30]!==r||t[31]!==i?(y=n.mode===`bearer`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Pn,{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]=y):y=t[32];let b;t[33]!==n.apiKey||t[34]!==n.headerName||t[35]!==n.mode||t[36]!==r||t[37]!==i?(b=n.mode===`apiKey`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`label`,{className:`block text-sm font-medium text-fg`,children:[i.setupApiKeyHeader,(0,$.jsx)(`input`,{className:X(Nn,`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)(Pn,{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]=b):b=t[38];let x;t[39]!==n.customHeaders||t[40]!==n.mode||t[41]!==r||t[42]!==i?(x=n.mode===`headers`?(0,$.jsx)(In,{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]=x):x=t[43];let S;return t[44]!==h||t[45]!==g||t[46]!==_||t[47]!==v||t[48]!==y||t[49]!==b||t[50]!==x?(S=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[h,g,_,v,y,b,x]}),t[44]=h,t[45]=g,t[46]=_,t[47]=v,t[48]=y,t[49]=b,t[50]=x,t[51]=S):S=t[51],S}function Rn(e){let t=(0,bt.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 zn({row:e,t,onUpdate:n}){let[r,i]=(0,Q.useState)(()=>Mt(e.envJson?JSON.parse(e.envJson):void 0)),[a,o]=(0,Q.useState)(!1),s=[];try{s=Pt(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)(Z,{type:`button`,variant:`ghost`,onClick:()=>o(e=>!e),children:a?t.setupArgsRows:t.setupArgsPaste})]}),a?(0,$.jsx)(Rn,{label:t.setupArgsPaste,hint:t.argsHint,children:(0,$.jsx)(`input`,{className:Nn,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:Nn,"aria-label":`${t.argsLabel} ${n+1}`,value:e,onChange:e=>c(s.map((t,r)=>r===n?e.target.value:t))}),(0,$.jsx)(Z,{type:`button`,variant:`ghost`,"aria-label":t.setupRemoveArg,onClick:()=>c(s.filter((e,t)=>t!==n)),children:(0,$.jsx)(me,{className:`size-4`,"aria-hidden":!0})})]},n)),a?null:(0,$.jsxs)(Z,{type:`button`,variant:`ghost`,onClick:()=>c([...s,``]),children:[(0,$.jsx)(ce,{className:`size-4`,"aria-hidden":!0}),t.setupAddArg]})]}),(0,$.jsx)(In,{environment:!0,headers:r,t,onChange:e=>{i(e),n({envEntries:e,envJson:JSON.stringify(jt(e)??{})})}})]})}function Bn(e){let t=(0,bt.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)(Rn,{label:`${r.commandLabel} *`,children:(0,$.jsx)(`input`,{"data-field":`command`,className:Nn,value:n.command,required:!0,onChange:e=>i({command:e.target.value})})}),(0,$.jsx)(zn,{row:n,t:r,onUpdate:i})]}):(0,$.jsx)(Rn,{label:`${r.urlLabel} *`,children:(0,$.jsx)(`input`,{"data-field":`url`,className:Nn,value:n.url,placeholder:`https://example.com/mcp`,required:!0,onChange:e=>i({url:e.target.value})})}),(0,$.jsx)(Rn,{label:r.setupNameLabel,hint:r.setupNameHint,children:(0,$.jsx)(`input`,{className:Nn,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)(Rn,{label:r.serverIdLabel,hint:r.setupIdHint,children:(0,$.jsx)(`input`,{className:Nn,readOnly:u,value:n.id,onChange:e=>i({id:e.target.value}),placeholder:r.serverIdPlaceholder})}),n.transport===`stdio`?(0,$.jsx)(Rn,{label:r.cwdLabel,children:(0,$.jsx)(`input`,{className:Nn,value:n.cwd,onChange:e=>i({cwd:e.target.value})})}):null,n.transport!==`stdio`&&l?(0,$.jsx)(Rn,{label:r.oauthClientIdLabel,hint:r.oauthClientIdHint,children:(0,$.jsx)(`input`,{className:Nn,value:n.oauthClientId,onChange:e=>i({oauthClientId:e.target.value})})}):null,(0,$.jsx)(Rn,{label:r.exposureLabel,hint:r.setupExposureHint,children:(0,$.jsx)(O,{"aria-label":r.exposureLabel,className:Nn,value:n.exposure,onChange:e=>i({exposure:e.target.value}),children:[`codemode`,`deferred`,`direct`,`hidden`].map(e=>(0,$.jsx)(k,{value:e,children:r.exposureLabels[e]},e))})}),(0,$.jsx)(Rn,{label:r.requestTimeoutLabel,children:(0,$.jsx)(yt,{allowEmpty:!0,type:`number`,min:1,className:Nn,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 Vn(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 Hn(e,t){return JSON.stringify({id:e.id,config:Ut(kn(e,t))})}function Un(e,t){try{return Hn(e,t)}catch{return JSON.stringify({row:e,auth:t})}}function Wn(e){let{t,cs:n}=e,r=c(e=>e.language),i=(0,Q.useId)(),[a,o]=(0,Q.useState)(e.initialRow),[s,l]=(0,Q.useState)(()=>On(e.initialRow)),[u,p]=(0,Q.useState)(`idle`),[v,y]=(0,Q.useState)(``),[b,x]=(0,Q.useState)(!1),[S,C]=(0,Q.useState)(!1),[w,T]=(0,Q.useState)(),[E,D]=(0,Q.useState)(),[A,j]=(0,Q.useState)(),[N,P]=(0,Q.useState)(!1),[F,I]=(0,Q.useState)(!1),[L,R]=(0,Q.useState)(``),[z,B]=(0,Q.useState)(``),[V,H]=(0,Q.useState)([]),[te,ne]=(0,Q.useState)(`0`),[U,ie]=(0,Q.useState)(0),[W,G]=(0,Q.useState)(``),[K,ae]=(0,Q.useState)(!1),[oe,se]=(0,Q.useState)(!1),q=e.mode===`edit`,[ce,le]=(0,Q.useState)(``),J=(0,Q.useRef)(void 0),[ue]=(0,Q.useState)(()=>Un(e.initialRow,On(e.initialRow))),de=(0,Q.useRef)(e.mode===`edit`?e.initialRow.id:``),fe=(0,Q.useRef)(void 0),pe=(0,Q.useRef)(void 0),me=(0,Q.useRef)(void 0),Y=(0,Q.useRef)(null),ge=(0,Q.useRef)(``),_e=(0,Q.useRef)(!0),ve=(0,Q.useRef)(null),ye=(0,Q.useRef)(null),be=(0,Q.useRef)(null),xe=(0,Q.useRef)(null),Se=(0,Q.useRef)(e.onSaved);Se.current=e.onSaved;let Ce=A?.state===`starting`||A?.state===`authorizing`,we=u!==`idle`||Ce,Te=ue!==Un(a,s),Ee=a.extra.enabled===!1,De=!S&&!b&&(Te||!!L.trim());(0,Q.useEffect)(()=>(_e.current=!0,()=>{_e.current=!1,fe.current?.abort(),Y.current?.close(),J.current&&qt(J.current).catch(()=>{})}),[]),(0,Q.useEffect)(()=>{if(!De)return;let e=e=>{e.preventDefault(),e.returnValue=``};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[De]),(0,Q.useEffect)(()=>{if(!w)return;let e=be.current?.querySelector(`[data-field="${w.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`,i),w.focus!==!1&&(n??xe.current)?.focus(),()=>{n?.removeAttribute(`aria-invalid`),n?.removeAttribute(`aria-describedby`)}},[w,i]),(0,Q.useEffect)(()=>{if(!A||!Ce)return;let e=new AbortController;pe.current=e;let n;async function r(){try{let n=await Xt(J.current,e.signal);if(e.signal.aborted||(j(n),n.authorizationUrl&&ge.current!==n.authorizationUrl&&(ge.current=n.authorizationUrl,window.electronAPI?.shell?.openExternalUrl?!(await window.electronAPI.shell.openExternalUrl(n.authorizationUrl)).ok&&!e.signal.aborted&&y(t.oauthOpenFailed):Y.current&&!Y.current.closed&&Y.current.location.replace(n.authorizationUrl)),e.signal.aborted))return;if(n.state===`connected`){me.current=void 0,Y.current?.close(),D({state:`connected`,toolCount:n.toolCount}),y(``);return}if(n.state===`error`||n.state===`cancelled`){me.current=void 0,Y.current?.close(),y(n.state===`cancelled`?t.setupCancelled:t.setupAuthFailed),/client.{0,20}(id|registration)|register|registration/i.test(n.error??``)&&P(!0);return}}catch{if(e.signal.aborted)return;Oe(),Y.current?.close(),y(t.setupAuthFailed);return}n=setTimeout(()=>void r(),1200)}return r(),()=>{e.abort(),clearTimeout(n)}},[A?.id,Ce,t.oauthOpenFailed,t.setupCancelled,t.setupAuthFailed]);function Oe(){fe.current?.abort(),pe.current?.abort(),J.current&&qt(J.current).catch(()=>{}),J.current=void 0,le(``),ae(!1),D(void 0),j(void 0),y(``),T(void 0)}function ke(e){o(t=>({...t,...e})),Oe()}function Ae(e){l(t=>({...t,...e})),Oe()}function je(){u===`saving`||Ce||(u===`checking`&&(Oe(),p(`idle`)),De?se(!0):e.onClose())}function Me(){try{H(Bt(L)),ne(`0`),B(``)}catch{B(t.setupImportError),H([])}}function Ne(){let t=V[Number(te)];if(!t)return;let n={...t,id:de.current||t.id,clientKey:e.initialRow.clientKey,extra:{...t.extra,...de.current?{enabled:a.extra.enabled}:{}}};o(n),l(On(n)),Oe(),ie(e=>e+1),I(!1),R(``),H([])}function Pe(e){function n(e,t){return T({field:e,message:t}),!1}if(e.transport!==`stdio`){try{e.url=zt(e.url)}catch{return n(`url`,t.setupAddressInvalid)}if(s.mode===`bearer`&&!s.token.trim().replace(/^Bearer\s*/i,``)||s.mode===`apiKey`&&(!s.apiKey.trim()||!s.headerName.trim()))return n(`auth`,t.setupCredentialRequired);if(An(e.headers)>=0)return n(`auth`,t.setupHeaderInvalid);if(s.mode===`oauth`&&e.headers.some(e=>e.key.trim().toLowerCase()===`authorization`))return n(`auth`,t.setupOAuthHeaderConflict);if(s.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{Ut(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 Fe(){y(``),p(`checking`),ge.current=``,window.electronAPI?.shell?.openExternalUrl||(Y.current=window.open(`about:blank`,`_blank`),Y.current&&(Y.current.opener=null));try{let e=await Yt(J.current);if(!_e.current){Y.current?.close(),J.current&&qt(J.current).catch(()=>{});return}me.current=e.id,j(e)}catch{Y.current?.close(),_e.current&&y(t.setupAuthFailed)}finally{_e.current&&p(`idle`)}}async function Ie(){let r=kn(a,s);if(!Pe(r))return;let i=e.existingCustomServers.filter(t=>t.clientKey!==e.initialRow.clientKey&&t.id!==de.current),c=new Set([...e.managedServerIds,...i.map(e=>e.id)]);if(r.id=de.current||r.id.trim()||Rt(r,c),!/^[a-zA-Z0-9_-]+$/.test(r.id)||[...c].some(e=>e.replace(/-/g,`_`)===r.id.replace(/-/g,`_`))){T({field:`advanced`,message:n.duplicateServerId});return}Oe(),p(`checking`);let l=new AbortController;fe.current=l;try{let n=await Gt(r,de.current||void 0,e.initialRow.extra,l.signal);if(!_e.current||l.signal.aborted){qt(n.id).catch(()=>{});return}J.current=n.id,o(r),le(Un(r,s));let i=await Kt(n.id,l.signal);if(!_e.current||l.signal.aborted)return;D(i),i.state===`error`&&y(Vn(i,t))}catch(e){_e.current&&!l.signal.aborted&&y(e.status===409?t.setupConflict:Vn(e,t))}finally{_e.current&&fe.current===l&&p(`idle`)}}async function Le(e=!1){if(!(!J.current||E?.state!==`connected`||ce!==Un(a,s))){p(`saving`),y(``);try{let t=await Jt(J.current,e);J.current=void 0,await Se.current().catch(()=>{}),t?.reloadRequired?x(!0):(e&&o(e=>({...e,extra:{...e.extra,enabled:!0}})),C(!0))}catch(e){let n=e.status;n===404||n===409?(Oe(),y(t.setupConflict)):y(t.setupSaveFailed)}finally{_e.current&&p(`idle`)}}}async function Re(){pe.current?.abort();let e=J.current;me.current=void 0,j(void 0),Y.current?.close(),y(t.setupCancelled),p(`checking`);try{e&&await Zt(e)}catch{_e.current&&(Oe(),y(t.setupCancelled))}finally{_e.current&&p(`idle`)}}async function ze(){A?.authorizationUrl&&(window.electronAPI?.shell?.openExternalUrl?(await window.electronAPI.shell.openExternalUrl(A.authorizationUrl)).ok||y(t.oauthOpenFailed):window.open(A.authorizationUrl,`_blank`,`noopener,noreferrer`))}async function Be(){if(A)try{await Qt(J.current,W),G(``),y(``)}catch{y(t.setupRedirectInvalid)}}let Ve=!!J.current&&ce===Un(a,s)&&(s.mode===`oauth`||s.mode===`auto`&&E?.state===`oauth_required`)&&E?.state!==`connected`,He=/^(?:https?:\/\/)?(?:localhost|127\.0\.0\.1|\[::1\])(?=[:/]|$)/i.test(a.url.trim()),Ue=V[Number(te)];return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(_,{open:e.open,onOpenChange:e=>{e||je()},children:(0,$.jsxs)(m,{children:[(0,$.jsx)(d,{className:`fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(h,{ref:ve,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(),ve.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)(g,{className:`font-semibold`,children:S?a.displayName||a.id:e.mode===`edit`?t.setupEditTitle:t.setupTitle}),(0,$.jsx)(f,{className:`mt-1 text-sm text-fg-muted`,children:t.setupHint})]}),(0,$.jsx)(`button`,{type:`button`,disabled:u===`saving`||Ce,onClick:je,className:`rounded-lg p-2 text-fg-muted hover:bg-surface-hover disabled:opacity-50`,"aria-label":n.modalClose,children:(0,$.jsx)(he,{className:`size-5`,"aria-hidden":!0})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-5`,children:[S?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 text-sm text-success`,children:[(0,$.jsx)(M,{className:`size-4`,"aria-hidden":!0}),Ee?t.setupDisabled:r===`zh`?`连接已保存,可以开始使用`:`Connection saved and ready to use`]}),Ee?null:(0,$.jsx)(ut,{target:{kind:`mcp`,id:a.id,name:a.displayName||a.id},onStart:e.onClose})]}):F?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(Z,{variant:`ghost`,onClick:()=>I(!1),children:t.setupImportBack}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.setupImportEmpty}),(0,$.jsxs)(`label`,{className:`block text-sm font-medium text-fg`,children:[t.setupImport,(0,$.jsx)(`textarea`,{className:X(Nn,`mt-1.5 min-h-40 font-mono text-xs`),value:L,placeholder:`{"mcpServers": {"docs": {"url": "https://example.com/mcp"}}}`,onChange:e=>{R(e.target.value),H([]),B(``)}})]}),(0,$.jsx)(Z,{variant:`secondary`,disabled:!L.trim(),onClick:Me,children:t.setupImportPreview}),z?(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:z}):null,Ue?(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)(O,{"aria-label":t.setupImportChoose,className:X(Nn,`mt-1.5`),value:te,onChange:e=>ne(e.target.value),children:V.map((e,t)=>(0,$.jsx)(k,{value:String(t),children:e.displayName||e.id||on(e)},t))})]}),(0,$.jsxs)(`p`,{className:`break-all text-sm text-fg-muted`,children:[Ue.transport===`stdio`?t.setupUseCommand:t.setupUseUrl,` · `,on(Ue)]})]}):null]}):(0,$.jsxs)(`form`,{ref:be,noValidate:!0,onBlurCapture:e=>{if(e.target instanceof HTMLInputElement&&e.target.dataset.field===`url`&&a.url.trim())try{zt(a.url)}catch{T({field:`url`,message:t.setupAddressInvalid,focus:!1})}},onSubmit:e=>{e.preventDefault(),Ie()},children:[(0,$.jsxs)(`fieldset`,{disabled:we||b,className:`min-w-0 space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsx)(rt,{className:`flex gap-1`,role:`group`,"aria-label":t.transportLabel,children:[`streamable-http`,`sse`,`stdio`].map(e=>(0,$.jsx)(Z,{type:`button`,variant:a.transport===e?`secondary`:`ghost`,"aria-pressed":a.transport===e,onClick:()=>ke({transport:e}),children:e===`stdio`?t.setupUseCommand:e===`sse`?r===`zh`?`旧版 SSE`:`Legacy SSE`:t.setupUseUrl},e))}),(0,$.jsx)(Z,{type:`button`,variant:`ghost`,onClick:()=>I(!0),children:t.setupImport})]}),(0,$.jsx)(`div`,{children:(0,$.jsx)(Bn,{row:a,t,variant:`basic`,onUpdate:ke},`${a.transport}-${U}`)}),a.transport===`stdio`?null:(0,$.jsx)(`div`,{"data-field":`auth`,children:(0,$.jsx)(Ln,{allowExisting:!!a.extra.auth||a.headers.some(e=>!!e.reference),draft:s,onChange:Ae,t})}),w?(0,$.jsx)(`p`,{id:i,ref:xe,tabIndex:-1,role:`alert`,className:`text-sm text-danger`,children:w.message}):null,(0,$.jsxs)(`details`,{"data-field":`advanced`,className:`rounded-lg border border-edge p-3`,open:N,onToggle:e=>P(e.currentTarget.open),children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted`,children:t.setupAdvanced}),(0,$.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[(0,$.jsx)(Bn,{row:a,t,variant:`advanced`,idReadOnly:q,showOAuth:s.mode===`oauth`,onUpdate:ke}),a.transport!==`stdio`&&s.mode!==`headers`&&s.mode!==`existing`?(0,$.jsx)(In,{additional:!0,headers:s.additionalHeaders,onChange:e=>Ae({additionalHeaders:e}),t}):null]})]}),(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:a.transport===`stdio`?t.setupCommandHostHint:He?t.setupLocalhostHint:t.setupGatewayHint}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.setupTestNotice})]}),(0,$.jsx)(`button`,{type:`submit`,hidden:!0})]}),b?(0,$.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-fg`,children:t.setupReloadRequired}):null,!S&&!F&&!b?(0,$.jsxs)(`div`,{className:`mt-4 space-y-3`,"aria-live":`polite`,children:[u===`idle`?null:(0,$.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,$.jsx)(re,{className:`size-4 animate-spin motion-reduce:animate-none`,"aria-hidden":!0}),u===`saving`?t.setupSaving:t.setupChecking]}),u===`idle`&&q&&!Te&&!E&&!v&&!Ce?(0,$.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:Ee?t.setupDisabled:e.lastCheck?t.setupLastCheck.replace(`{{count}}`,String(e.lastCheck.toolCount)):t.setupSavedUnchecked}):null,E?.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)(M,{className:`size-4 shrink-0`,"aria-hidden":!0}),E.toolCount?t.setupConnected.replace(`{{count}}`,String(E.toolCount)):t.setupZeroTools]}),(0,$.jsx)(ut,{preview:!0,target:{kind:`mcp`,id:a.id,name:a.displayName||a.id}}),(0,$.jsx)(Z,{ref:ye,variant:`secondary`,onClick:()=>ae(!0),children:t.viewTools})]}):null,E?.state===`token_required`?(0,$.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:t.setupNeedsAuth}):null,E?.state===`auth_unknown`?(0,$.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:r===`zh`?`认证方式尚未确定。请核实服务接入说明,选择 Token 或已确认支持的 OAuth。`:`Authentication is undetermined. Check the integration guide and select a Token or verified OAuth method.`}):null,E?.state===`oauth_required`&&!Ce?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.setupOAuthRequired}):null,Ce?(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)(re,{className:`size-4 animate-spin motion-reduce:animate-none`,"aria-hidden":!0}),t.setupAuthorizing]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[A?.authorizationUrl?(0,$.jsxs)(Z,{variant:`secondary`,onClick:()=>void ze(),children:[(0,$.jsx)(ee,{className:`size-4`,"aria-hidden":!0}),t.oauthOpenAuthorization]}):null,(0,$.jsx)(Z,{variant:`ghost`,onClick:()=>void Re(),children:t.setupCancelAuth})]}),A?.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:Nn,value:W,onChange:e=>G(e.target.value)})]}),(0,$.jsx)(Z,{className:`mt-2`,disabled:!W.trim(),onClick:()=>void Be(),children:t.setupContinue})]}):null]}):null,v?(0,$.jsxs)(`div`,{role:`alert`,className:`space-y-1 text-sm`,children:[(0,$.jsx)(`p`,{className:`text-danger`,children:v}),v!==t.setupSaveFailed&&u!==`saving`?(0,$.jsx)(`p`,{className:`text-fg-muted`,children:t.setupTestFailure}):null]}):null]}):null]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge p-4`,children:[(0,$.jsx)(Z,{variant:`secondary`,disabled:u===`saving`||Ce,onClick:je,children:S||q||b?t.setupClose:n.modalCancel}),S||b?null:F?(0,$.jsx)(Z,{variant:`primary`,disabled:!Ue,onClick:Ne,children:t.setupImportApply}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Z,{variant:E?.state===`connected`?`secondary`:`primary`,disabled:we,onClick:()=>Ve?void Fe():void Ie(),children:Ve?t.setupSignIn:t.setupTestConnection}),E?.state===`connected`&&ce===Un(a,s)?(0,$.jsxs)($.Fragment,{children:[Ee?(0,$.jsx)(Z,{variant:`secondary`,disabled:we,onClick:()=>void Le(!0),children:t.setupEnableSave}):null,(0,$.jsx)(Z,{variant:`primary`,disabled:we,"aria-busy":we,onClick:()=>void Le(),children:q?t.setupSaveOnly:t.setupAddConnection})]}):null]})]})]})]})}),(0,$.jsx)(it,{open:oe,title:t.setupUnsavedTitle,description:t.setupUnsavedHint,confirmLabel:t.setupDiscard,cancelLabel:t.setupKeepEditing,onCancel:()=>se(!1),onConfirm:e.onClose,overlayClassName:`z-[70]`,contentClassName:`z-[70]`}),K?(0,$.jsx)(nn,{draftId:J.current,serverId:a.id,displayName:a.displayName,returnFocusTo:ye.current,t,onClose:()=>ae(!1)}):null]})}var Gn=`recommended`,Kn=`builtin`,qn=`composio`,Jn=`xopc-store`;function Yn(e,t=`en`){return e==="default"&&t.startsWith(`zh`)?Gn:Kn}function Xn(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 Zn(e){return y(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 Qn(e){return e?.startsWith(`/`)&&!e.startsWith(`//`)?e:`/user-model`}function $n({embedded:e=!1,onHeaderActionChange:t}){let n=nt().filter(ln),r=c(e=>e.language),o=u(r),l=o.connectorsSettings,d=o.mcpSettings,f=s(e=>e.conversationId),p=!!f,m=a(),[h,g]=i(),_=h.get(`understanding`)===`1`,y=Qn(h.get(`returnTo`)),E=!!h.get(`returnTo`)&&!_,D=h.get(`tab`),[O,k]=(0,Q.useState)(!_&&D===`connected`?`connected`:`discover`),{data:j}=_e(p&&O===`discover`&&!_?[`service-recommendations`,r]:null,()=>S(r),{revalidateOnFocus:!1}),M=(0,Q.useMemo)(()=>new Set(j?.items.filter(e=>e.service?.source===`store-plugin`).map(e=>w(e.id))??[]),[j]),N=(0,Q.useRef)(!1),[P,z]=(0,Q.useState)({catalog:[],registryCatalog:[],instances:[],loading:!0,error:null}),[B,V]=(0,Q.useState)(!1),[ee,H]=(0,Q.useState)(!1),[te,ne]=(0,Q.useState)(1),[U,ie]=(0,Q.useState)(void 0),[W,G]=(0,Q.useState)(``),[K,ae]=(0,Q.useState)(_||E?h.get(`connector`)??``:``),[q,ce]=(0,Q.useState)(Yn(_?`understanding`:`default`,r)),[le,J]=(0,Q.useState)(`name`),[ue,de]=(0,Q.useState)(_?`understand`:`all`),[fe,pe]=(0,Q.useState)(null),[me,Y]=(0,Q.useState)(null),[he,ge]=(0,Q.useState)(null),[ve,be]=(0,Q.useState)(null),[xe,Se]=(0,Q.useState)(null),[Ce,we]=(0,Q.useState)(null),{data:Te,mutate:Ee}=ye(p),De=Te?.payload?.config,Oe=(0,Q.useMemo)(()=>De===void 0?null:Ht(De),[De]),ke=Oe?.servers??[],Ae=P.instances.length+ke.length+n.length,[je,Me]=(0,Q.useState)({});(0,Q.useEffect)(()=>{if(Me({}),!p||!De)return;let e=new AbortController;return en(e.signal).then(t=>{e.signal.aborted||Me(t)}).catch(()=>{}),()=>e.abort()},[p,De]);let Ne=(0,Q.useCallback)(async()=>{if(!f){z({catalog:[],registryCatalog:[],instances:[],loading:!1,error:null});return}z(e=>({...e,loading:!0,error:null}));try{let[e,t]=await Promise.all([Le(),Pe()]);z(n=>({catalog:e,registryCatalog:n.registryCatalog,instances:t,loading:!1,error:null}))}catch(e){z({catalog:[],registryCatalog:[],instances:[],loading:!1,error:e instanceof Error?e.message:String(e)})}},[f]);(0,Q.useEffect)(()=>{Ne()},[Ne]),(0,Q.useEffect)(()=>{N.current||P.loading||p&&!Oe||(k(_?`discover`:Ae>0?`connected`:`discover`),N.current=!0)},[p,Ae,Oe,_,P.loading]),(0,Q.useEffect)(()=>{ce(e=>e===`builtin`||e===`recommended`?Yn(_?`understanding`:`default`,r):e)},[r,_]);let Fe=(0,Q.useCallback)(e=>{N.current=!0,k(e)},[]),Ie=(0,Q.useMemo)(()=>[{id:qn,displayName:l.composioSourceName},{id:Jn,displayName:l.storeSourceName}],[l.composioSourceName,l.storeSourceName]),Re=(0,Q.useCallback)(async e=>{if(!p||q===`builtin`||q===`recommended`){z(e=>({...e,registryCatalog:[]})),ne(1),ie(void 0);return}let t=K.trim(),n=Math.max(e?.page??1,1),i=e?.append??!1,a=q===`all`?Ie:Ie.filter(e=>e.id===q);if(a.length!==0){V(!0),i?z(e=>({...e,error:null})):(ne(1),ie(void 0),z(e=>({...e,registryCatalog:[],error:null})));try{let e=await Promise.all(a.map(async e=>{if(e.id===`composio`){let e=await We({q:t||void 0,page:n,pageSize:24,verification:`experimental`});return{connectors:e.connectors,totalPages:e.meta.totalPages}}let i=await He({q:t||void 0,page:n,pageSize:24,sort:le===`source`?`newest`:`downloads`});return{connectors:i.items.flatMap(e=>{let t=Xn(e,r);return t?[t]:[]}),totalPages:i.meta.totalPages}})),o=Zn(e.flatMap(e=>e.connectors)),s=Math.max(1,...e.map(e=>e.totalPages??1));ne(n),ie(s),z(e=>({...e,registryCatalog:i?Zn([...e.registryCatalog,...o]):o}))}catch(e){z(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{V(!1)}}},[le,K,q,p,Ie,r]);(0,Q.useEffect)(()=>{if(O!==`discover`||P.loading)return;if(q===`builtin`||q===`recommended`){z(e=>({...e,registryCatalog:[]})),ne(1),ie(void 0);return}let e=window.setTimeout(()=>{Re()},K.trim()?350:0);return()=>window.clearTimeout(e)},[K,q,Re,P.loading,O]);let ze=(0,Q.useMemo)(()=>new Set(P.instances.map(e=>e.connectorId)),[P.instances]),Be=(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=h.get(`connector`),t=h.get(`instance`);if(!e&&!t)return;let n=P.instances.find(n=>t?n.instanceId===t:n.connectorId===e);if(n)N.current=!0,G(``),ge(n.instanceId),be(n),k(`connected`);else if(e){let t=Be.get(e);if(!t)return;N.current=!0,ce(Yn(_?`understanding`:`default`,r)),ae(``),Y(t),k(`discover`)}let i=new URLSearchParams(h);i.delete(`connector`),i.delete(`instance`),i.set(`tab`,n?`connected`:`discover`),g(i,{replace:!0})},[Be,_,r,h,g,P.instances,P.loading]);let Ve=(0,Q.useCallback)(async e=>{H(!0),z(e=>({...e,error:null}));try{let t=await Ge(e);pe(oe(t.definition,{packageName:t.packageName,version:t.version,reviewHash:t.reviewHash,permissions:t.permissions}))}catch(e){z(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{H(!1)}},[]);(0,Q.useEffect)(()=>{let e=h.get(`storeConnector`);if(!p||!e)return;let t=new URLSearchParams(h);t.delete(`storeConnector`),g(t,{replace:!0}),Ve(e)},[p,h,g,Ve]);let Ue=(0,Q.useMemo)(()=>new Set(P.instances.flatMap(e=>e.materialized.type===`mcp`?[e.materialized.serverId]:[])),[P.instances]),Ke=(0,Q.useCallback)(async e=>{let t=await tn(e);await Ee(),await Ne(),t.reloadRequired&&z(e=>({...e,error:d.setupReloadRequired}))},[Ne,Ee,d.setupReloadRequired]),qe=(0,Q.useCallback)(()=>{we({mode:`add`,row:Dn(ke,Ue)})},[ke,Ue]),Je=tt(e=>e.setPageHeader),Ye=tt(e=>e.clearPageHeader),Xe=(0,Q.useMemo)(()=>({searchLabel:O===`connected`?l.connectedSearchPlaceholder:l.discoverSearchPlaceholder,search:(0,$.jsx)(pt,{value:O===`connected`?W:K,onChange:O===`connected`?G:ae,placeholder:O===`connected`?l.connectedSearchPlaceholder:l.discoverSearchPlaceholder}),secondary:(0,$.jsx)(Dt,{onRefresh:O===`connected`&&p?Ne:void 0,refreshing:P.loading,refreshLabel:l.refreshConnections,onBrowseCatalog:()=>Fe(`discover`),onAddCustomServer:qe,addLabel:l.addConnection,browseLabel:l.addFromCatalog,customLabel:l.addCustomServerAdvanced,serviceLabel:r.startsWith(`zh`)?`应用连接服务`:`Connection service`,moreActionsLabel:o.capabilitiesHub.moreActions})}),[W,l,K,p,r,Ne,o.capabilitiesHub.moreActions,qe,Fe,P.loading,O]);(0,Q.useLayoutEffect)(()=>e?(t?.(Xe),()=>t?.(null)):(Je({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)(mt,{contribution:Xe})}),()=>Ye()),[Ye,l.title,e,Xe,t,Je]);let Ze=(0,Q.useMemo)(()=>P.instances.map(e=>({instance:e,value:v(e,Be.get(e.connectorId))})),[Be,P.instances]),Qe=(0,Q.useMemo)(()=>new Map(Ze.map(({instance:e,value:t})=>[e.instanceId,t])),[Ze]),$e=(0,Q.useMemo)(()=>P.instances.filter(e=>L(e,W)).sort((e,t)=>{let n={needs_setup:0,checking:1,ready:2},r=Qe.get(e.instanceId)?.state??`checking`,i=Qe.get(t.instanceId)?.state??`checking`;return n[r]-n[i]||e.displayName.localeCompare(t.displayName)}),[W,Qe,P.instances]),it=(0,Q.useMemo)(()=>$e.filter(e=>Qe.get(e.instanceId)?.state===`needs_setup`),[Qe,$e]),at=(0,Q.useMemo)(()=>$e.filter(e=>Qe.get(e.instanceId)?.state!==`needs_setup`),[Qe,$e]),ot=(0,Q.useMemo)(()=>ke.filter(e=>R(e,W)),[W,ke]),st=(0,Q.useMemo)(()=>{let e=W.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))},[W,n]),ct=$e.length+ot.length+st.length,lt=(0,Q.useMemo)(()=>P.catalog.filter(e=>e.source===`builtin`&&e.integrationStrategy?.preferred!==!1&&F(e)),[P.catalog]),ut=(0,Q.useMemo)(()=>q===`recommended`?[]:q===`builtin`?lt:q===`all`?Zn([...lt,...P.registryCatalog]):P.registryCatalog,[lt,q,P.registryCatalog]),ft=(0,Q.useMemo)(()=>{let e=_?ut.filter(e=>e.understanding?.mode===`activity`):Zn(ut).filter(e=>!M.has(w(e.id)));return I(ue===`all`?e:e.filter(e=>b(e).includes(ue)),K,le)},[le,K,ut,_,ue,M]),ht=(0,Q.useMemo)(()=>C.filter(e=>ut.some(t=>b(t).includes(e))),[ut]);(0,Q.useEffect)(()=>{ue!==`all`&&!ht.includes(ue)&&de(`all`)},[ht,ue]);let gt=O===`discover`&&q!==`builtin`&&!!(U&&te<U),yt=(0,Q.useMemo)(()=>P.instances.find(e=>e.instanceId===he)??ve,[he,ve,P.instances]),bt=(0,Q.useMemo)(()=>[{value:Gn,label:r===`zh`?`推荐服务`:`Recommended services`},{value:`all`,label:l.discoverSourceAll},{value:Kn,label:l.discoverSourceBuiltin},...Ie.map(e=>({value:e.id,label:e.displayName}))],[l.discoverSourceAll,l.discoverSourceBuiltin,Ie,r]),St=[{id:`connected`,label:l.tabConnected,count:Ae},{id:`discover`,label:l.tabDiscover}];return(0,$.jsx)(`div`,{className:X(`flex min-h-0 min-w-0 flex-1 flex-col`,!e&&`bg-surface-base`),children:(0,$.jsxs)(`div`,{className:X(`mx-auto flex w-full max-w-7xl flex-col gap-6 px-4 sm:px-6 lg:px-8`,e?`pb-7 pt-3 lg:pb-9 lg:pt-4`:`py-7 lg:py-9`),children:[p?null:(0,$.jsx)(`p`,{className:`rounded-xl bg-surface-panel px-4 py-3 text-sm text-fg-muted`,children:l.tokenHint}),_?(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)(Z,{type:`button`,variant:`secondary`,className:`shrink-0`,onClick:()=>m(y),children:l.understandingSetupDone})]}):null,E?(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)(Z,{type:`button`,variant:`secondary`,className:`min-h-11 shrink-0`,onClick:()=>m(y),children:l.recoverySetupDone})]}):null,(0,$.jsxs)(`section`,{className:`flex flex-col gap-4`,children:[(0,$.jsx)(`div`,{children:(0,$.jsx)(et,{items:St,activeTab:O,onChange:Fe,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,O===`connected`&&p?(0,$.jsx)(`div`,{className:`flex flex-col gap-6`,children:P.loading?(0,$.jsx)(`div`,{className:_t,"aria-busy":`true`,"aria-label":l.loading,children:Ct.slice(0,3).map(e=>(0,$.jsx)(vt,{},e))}):Ae===0?(0,$.jsxs)(`div`,{className:`py-14 text-center`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:l.connectionsEmpty}),(0,$.jsx)(Z,{type:`button`,variant:`primary`,className:`mt-4`,onClick:()=>Fe(`discover`),children:l.addFromCatalog})]}):ct===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:[it.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:it.length})]}),(0,$.jsx)(`div`,{className:_t,children:it.map(e=>(0,$.jsx)(En,{instance:e,definition:Be.get(e.connectorId),highlighted:e.instanceId===xe,onOpenDetails:e=>{Se(null),ge(e.instanceId),be(e)},t:l},e.instanceId))})]}):null,at.length||st.length?(0,$.jsx)(`section`,{children:(0,$.jsxs)(`div`,{className:_t,children:[at.map(e=>(0,$.jsx)(En,{instance:e,definition:Be.get(e.connectorId),highlighted:e.instanceId===xe,onOpenDetails:e=>{Se(null),ge(e.instanceId),be(e)},t:l},e.instanceId)),st.map(e=>(0,$.jsx)(un,{extension:e,language:r,onOpen:()=>m(dt(e.pluginId,`connections`,e.authorizationStatus===`required`))},e.id))]})}):null,ot.length||!W.trim()?(0,$.jsx)(cn,{servers:ot,lastChecks:je,t:d,cs:l,onAdd:qe,onEdit:e=>we({mode:`edit`,row:structuredClone(e)}),onRemove:Ke}):null]})}):null,O===`discover`&&p?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[_?null:(0,$.jsx)(rt,{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`,...ht].map(e=>(0,$.jsx)(`button`,{type:`button`,className:X(`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors`,ue===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":ue===e,onClick:()=>de(e),children:e===`all`?l.taskAll:l.connectorBenefitHeadings[e]},e))}),(0,$.jsxs)(`div`,{className:X(`ml-auto grid w-full gap-2 sm:flex sm:w-auto sm:justify-end`,_?`grid-cols-1`:`grid-cols-2`),children:[_?null:(0,$.jsx)(`div`,{className:`min-w-0 sm:w-40`,children:(0,$.jsx)(A,{value:q,options:bt,placeholder:l.discoverSourceAll,allowEmpty:!1,ariaLabel:l.registrySourceAria,triggerClassName:`h-9 bg-surface-panel text-xs`,onChange:ce})}),q===`recommended`?null:(0,$.jsx)(`div`,{className:`min-w-0 sm:w-40`,children:(0,$.jsx)(A,{value:le,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=>J(e)})})]})]}),q===`recommended`?(0,$.jsx)(T,{layout:`cards`,showAll:!0,query:K,onChanged:async()=>{await Ne(),await Ee()}}):(P.loading||B)&&ft.length===0?(0,$.jsx)(`div`,{className:_t,"aria-busy":`true`,"aria-label":l.loading,children:Ct.map(e=>(0,$.jsx)(Et,{},e))}):ft.length===0?(0,$.jsx)(`div`,{className:`py-14 text-center text-sm text-fg-muted`,children:l.discoverEmpty}):(0,$.jsxs)(`div`,{className:`relative`,children:[B?(0,$.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-[1] flex justify-center bg-surface-panel/40 pt-[min(28vh,7.5rem)] backdrop-blur-[1px] motion-reduce:backdrop-blur-none dark:bg-surface-base/35`,"aria-busy":`true`,"aria-label":l.loading,children:(0,$.jsx)(re,{className:`size-8 shrink-0 animate-spin text-accent motion-reduce:animate-none`,strokeWidth:2,"aria-hidden":!0})}):null,(0,$.jsx)(`div`,{className:_t,children:ft.map(e=>(0,$.jsx)(xt,{connector:e,installed:ze.has(e.id)||wt(e,P.instances),onInstall:e=>{if(e.source===`store`){Ve(e.id);return}pe(oe(e))},onOpenDetails:e.source===`store`?void 0:Y,t:l},e.id))}),gt?(0,$.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,$.jsxs)(Z,{type:`button`,variant:`secondary`,disabled:B||ee,onClick:()=>void Re({page:te+1,append:!0}),children:[B?(0,$.jsx)(re,{className:`size-4 animate-spin`}):null,l.loadMore]})}):null]})]}):null]}),fe?(0,$.jsx)(se,{draft:fe,onChange:pe,onClose:()=>pe(null),t:l,onInstalled:async e=>{await Ne(),await Ee(),Se(e.instanceId),Fe(`connected`)}}):null,me?(0,$.jsx)(x,{connector:me,installed:ze.has(me.id)||wt(me,P.instances),onClose:()=>Y(null),onInstall:e=>pe(oe(e)),t:l}):null,yt?(0,$.jsx)(Tn,{instance:yt,definition:Be.get(yt.connectorId),onClose:()=>{ge(null),be(null)},onChanged:Ne,t:l,mcp:d}):null,Ce?(0,$.jsx)(Wn,{open:!0,mode:Ce.mode,initialRow:Ce.row,lastCheck:Ce.mode===`edit`?je[Ce.row.id]:void 0,existingCustomServers:ke,config:De,managedServerIds:Ue,t:d,cs:l,onClose:()=>we(null),onSaved:async()=>{await Ee(),await Ne(),Fe(`connected`)}},`${Ce.mode}-${Ce.row.clientKey}`):null]})})}export{$n as ConnectorsPage};