@xopcai/xopc 0.0.405 → 0.0.407

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 (232) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/feishu/src/transport/socket-mode/monitor.js +1 -1
  3. package/dist/extensions/feishu/src/transport/webhook/monitor.js +1 -1
  4. package/dist/extensions/telegram/xopc.extension.json +1 -1
  5. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-wc__VG7A.js → agent-avatar-dicebear-CPNoFyoV.js} +1 -1
  6. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-BB0O3b4I.js +1 -0
  7. package/dist/gateway/static/root/assets/agents-Y7XtlqVm.js +77 -0
  8. package/dist/gateway/static/root/assets/{agents-admin-api-D6XzhsQy.js → agents-admin-api-D0UyB0Y_.js} +1 -1
  9. package/dist/gateway/static/root/assets/{app-management-settings-panel-DnQKk3ql.js → app-management-settings-panel-BOAkMTQ7.js} +1 -1
  10. package/dist/gateway/static/root/assets/{appearance-settings-CoL67S5e.js → appearance-settings-BWPt4-vh.js} +1 -1
  11. package/dist/gateway/static/root/assets/apps-page-Ln5N1PK3.js +1 -0
  12. package/dist/gateway/static/root/assets/{archive-plugin-CgKj53U1.js → archive-plugin-CNjE6PYZ.js} +1 -1
  13. package/dist/gateway/static/root/assets/{automations-page-Cr_WMoqc.js → automations-page-BsP4j7Nw.js} +1 -1
  14. package/dist/gateway/static/root/assets/automations-workspace-lq17XY3n.js +6 -0
  15. package/dist/gateway/static/root/assets/{binary-plugins-C_h3FTTz.js → binary-plugins-AFWJskT6.js} +1 -1
  16. package/dist/gateway/static/root/assets/{block-editor-lnkSRbxE.js → block-editor-SQ53S4oy.js} +40 -40
  17. package/dist/gateway/static/root/assets/{browser-automation-inputs-FsIEAlnO.js → browser-automation-inputs-C2SC9h-c.js} +1 -1
  18. package/dist/gateway/static/root/assets/browser-automations-page-kRoqj1qn.js +3 -0
  19. package/dist/gateway/static/root/assets/browser-settings-page-dZhjL3oj.js +3 -0
  20. package/dist/gateway/static/root/assets/capabilities-CD6PzNK7.js +1 -0
  21. package/dist/gateway/static/root/assets/capabilities-page-Dnp_ilKR.js +2 -0
  22. package/dist/gateway/static/root/assets/capabilities-settings-panel-BA9kBBqE.js +8 -0
  23. package/dist/gateway/static/root/assets/{capability-header-actions-wTmkMFS8.js → capability-header-actions-Cq5XWEDs.js} +1 -1
  24. package/dist/gateway/static/root/assets/channels-BZCzeWtD.js +1 -0
  25. package/dist/gateway/static/root/assets/{chat-terminal-dock-DJjZ0p_B.js → chat-terminal-dock-BC4EyhTx.js} +2 -2
  26. package/dist/gateway/static/root/assets/computer-settings-page-MxcoTOP1.js +1 -0
  27. package/dist/gateway/static/root/assets/{connector-service-page-DavOiSs1.js → connector-service-page-tSQ3a_Ti.js} +1 -1
  28. package/dist/gateway/static/root/assets/connectors-page-h5FTgews.js +1 -0
  29. package/dist/gateway/static/root/assets/{date-picker-cGUcobcp.js → date-picker-CavoWXMc.js} +1 -1
  30. package/dist/gateway/static/root/assets/{dependency-picker-BvEoPDqz.js → dependency-picker-Cl-3upFX.js} +1 -1
  31. package/dist/gateway/static/root/assets/{desktop-pet-DL330r9w.js → desktop-pet-B-RDVNqR.js} +1 -1
  32. package/dist/gateway/static/root/assets/{desktop-pet-settings-BkBrKnpR.js → desktop-pet-settings-rttWyUzY.js} +1 -1
  33. package/dist/gateway/static/root/assets/device-pairing-wizard-6hqiv1ui.js +1 -0
  34. package/dist/gateway/static/root/assets/{directory-picker-path-field-Bq5EumS7.js → directory-picker-path-field-1rEGI8IE.js} +1 -1
  35. package/dist/gateway/static/root/assets/{extension-debug-page-BcNqrM44.js → extension-debug-page-BaswNoXz.js} +1 -1
  36. package/dist/gateway/static/root/assets/{extension-page-BIOXclKZ.js → extension-page-uCMJMnc_.js} +1 -1
  37. package/dist/gateway/static/root/assets/{extension-settings-page-BdLmNW7c.js → extension-settings-page-DiczmHyl.js} +1 -1
  38. package/dist/gateway/static/root/assets/{gateway-config-swr-BvuySoCX.js → gateway-config-swr-CTXr917C.js} +1 -1
  39. package/dist/gateway/static/root/assets/{gateway-realtime-SBtdXzco.js → gateway-realtime-CP6L2jIR.js} +1 -1
  40. package/dist/gateway/static/root/assets/gateway-realtime-store-yXB4a40_.js +1 -0
  41. package/dist/gateway/static/root/assets/gateway-settings-DH5MOwxf.js +1 -0
  42. package/dist/gateway/static/root/assets/{gateway-startup-retry-CEpuztYK.js → gateway-startup-retry-DD2fsxdd.js} +1 -1
  43. package/dist/gateway/static/root/assets/{highlighted-body-KQOG7T2V-BJBmXHUI.js → highlighted-body-KQOG7T2V-B62h4sJ4.js} +1 -1
  44. package/dist/gateway/static/root/assets/home-page-BsjMhloP.js +2 -0
  45. package/dist/gateway/static/root/assets/{image-generation-api-vO5_70v-.js → image-generation-api-Di7HnFSL.js} +1 -1
  46. package/dist/gateway/static/root/assets/{imports-page-xvg0vgTo.js → imports-page-DpKfYZMT.js} +1 -1
  47. package/dist/gateway/static/root/assets/index-BUv4J0JN.js +267 -0
  48. package/dist/gateway/static/root/assets/index-Cr4I4q1J.css +1 -0
  49. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-D-jHSG1c.js → keyboard-shortcuts-settings-D1Q1kTMI.js} +1 -1
  50. package/dist/gateway/static/root/assets/local-app-workbench-page-CnaLbgJb.js +1 -0
  51. package/dist/gateway/static/root/assets/{local-apps-page-DQOK34TS.js → local-apps-page-CSO0RkyG.js} +1 -1
  52. package/dist/gateway/static/root/assets/{local-session-drafts-DhJjHCfQ.js → local-session-drafts-TqLFKwYo.js} +1 -1
  53. package/dist/gateway/static/root/assets/{locale-store-D5h-Ha6-.js → locale-store-D_migb9R.js} +1 -1
  54. package/dist/gateway/static/root/assets/logs-page-DruO5LTf.js +2 -0
  55. package/dist/gateway/static/root/assets/management-settings-Dw3tQKNe.js +1 -0
  56. package/dist/gateway/static/root/assets/{markdown-view-CthsQiiO.js → markdown-view-vQSMUUY_.js} +1 -1
  57. package/dist/gateway/static/root/assets/{media-plugins-4_OqZkJo.js → media-plugins-CrHXsih_.js} +1 -1
  58. package/dist/gateway/static/root/assets/mermaid-MCJ5UELQ-CNzdVIcE.js +1 -0
  59. package/dist/gateway/static/root/assets/messages-D__oW2yE.js +3 -0
  60. package/dist/gateway/static/root/assets/note-detail-panel-DCZ6Vgd_.js +5 -0
  61. package/dist/gateway/static/root/assets/note-image-lightbox-BXNZw7lJ.js +1 -0
  62. package/dist/gateway/static/root/assets/notes-page-Bqy9Rh_j.js +8 -0
  63. package/dist/gateway/static/root/assets/{page-context-capture-button-DkFhXsZj.js → page-context-capture-button-DQHbuYER.js} +1 -1
  64. package/dist/gateway/static/root/assets/personal-page-C--WEB5c.js +1 -0
  65. package/dist/gateway/static/root/assets/personal-proactivity-BJcZ3Yhi.js +1 -0
  66. package/dist/gateway/static/root/assets/personal-settings-panel-Cwgc13ls.js +1 -0
  67. package/dist/gateway/static/root/assets/plugin-details-dialog-DxkFHaU-.js +1 -0
  68. package/dist/gateway/static/root/assets/plugin-presentation-CO5BFDGW.js +1 -0
  69. package/dist/gateway/static/root/assets/{preview-open-alternatives-Bz7-AqIY.js → preview-open-alternatives-BW7P2akd.js} +1 -1
  70. package/dist/gateway/static/root/assets/{product-open-page-uAU6q84_.js → product-open-page-BnlpaYs-.js} +1 -1
  71. package/dist/gateway/static/root/assets/product-preview-content-DkXx1Vt8.js +1 -0
  72. package/dist/gateway/static/root/assets/project-detail-page-CtyCpIx8.js +1 -0
  73. package/dist/gateway/static/root/assets/projects-page-CJ0s-bI5.js +1 -0
  74. package/dist/gateway/static/root/assets/{registry-api-Bf0hVPNV.js → registry-api-4NZOh0iz.js} +1 -1
  75. package/dist/gateway/static/root/assets/remote-access-hub-yItNjAR3.js +1 -0
  76. package/dist/gateway/static/root/assets/{runtime-tools-api-ByH1meP7.js → runtime-tools-api-CmEWVrOg.js} +1 -1
  77. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-D2VV6nm2.js → runtime-tools-settings-panel-BGRbt79f.js} +1 -1
  78. package/dist/gateway/static/root/assets/{schema-form-gO0zayZd.js → schema-form-B9VP7ldU.js} +1 -1
  79. package/dist/gateway/static/root/assets/{session-api-fVuszA_P.js → session-api-aQLptIs9.js} +1 -1
  80. package/dist/gateway/static/root/assets/session-manager-D2sLfkw-.js +16 -0
  81. package/dist/gateway/static/root/assets/sessions-page-3O5S9efw.js +1 -0
  82. package/dist/gateway/static/root/assets/settings-advanced-gate-BE-SKsf6.js +1 -0
  83. package/dist/gateway/static/root/assets/{settings-form-section-CihKQYlF.js → settings-form-section-BA2RkU1S.js} +1 -1
  84. package/dist/gateway/static/root/assets/settings-page-BUT0FzfI.js +1 -0
  85. package/dist/gateway/static/root/assets/{setup-status-panel-BWVb5uxa.js → setup-status-panel-1oWs6iPS.js} +1 -1
  86. package/dist/gateway/static/root/assets/{share-preview-page-Dg0mhito.js → share-preview-page-CVNey8Lq.js} +1 -1
  87. package/dist/gateway/static/root/assets/shares-settings-Bb6YoDmU.js +1 -0
  88. package/dist/gateway/static/root/assets/{skill-api-CrNz0Fi0.js → skill-api-BWi0G9Ii.js} +1 -1
  89. package/dist/gateway/static/root/assets/skill-reload-api-DspV2olR.js +1 -0
  90. package/dist/gateway/static/root/assets/skills-page-SbNv1vpY.js +2 -0
  91. package/dist/gateway/static/root/assets/{style-CuYP4CAT.js → style-DlOTU5bN.js} +1 -1
  92. package/dist/gateway/static/root/assets/{system-settings-panel-DGFMkic_.js → system-settings-panel-DbS1qtOh.js} +1 -1
  93. package/dist/gateway/static/root/assets/task-detail-page-uSwizzx8.js +2 -0
  94. package/dist/gateway/static/root/assets/{task-expandable-content-BoGtWYbk.js → task-expandable-content-D0ahXP9o.js} +1 -1
  95. package/dist/gateway/static/root/assets/tracing-settings-page-BMhVvXXd.js +1 -0
  96. package/dist/gateway/static/root/assets/{tunnel-api-CnLkQQGi.js → tunnel-api-CO9rJLFh.js} +1 -1
  97. package/dist/gateway/static/root/assets/{usage-page-BInqKKdE.js → usage-page-DVzIDec4.js} +1 -1
  98. package/dist/gateway/static/root/assets/{use-autosave-0dTfTmCk.js → use-autosave-DqPaXiX2.js} +1 -1
  99. package/dist/gateway/static/root/assets/user-model-page-BYZCHCzG.js +2 -0
  100. package/dist/gateway/static/root/assets/{voice-api-key-field-BpOvEhu7.js → voice-api-key-field-C_iOzfIt.js} +1 -1
  101. package/dist/gateway/static/root/assets/{voice-config-api-CRjdZdJF.js → voice-config-api-4yGMrp7J.js} +1 -1
  102. package/dist/gateway/static/root/assets/{work-discovery-overlay-Br-XaBAW.js → work-discovery-overlay-n59s18s0.js} +1 -1
  103. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-B8E6qBkL.js → workflow-run-setup-panel-Lp6Vumxc.js} +2 -2
  104. package/dist/gateway/static/root/assets/workflows-page-B5BqN1Y1.js +6 -0
  105. package/dist/gateway/static/root/assets/{xopc-cloud-account-card-BARP73BX.js → xopc-cloud-account-card-QSDUy0uF.js} +1 -1
  106. package/dist/gateway/static/root/index.html +16 -15
  107. package/dist/package.js +1 -1
  108. package/dist/packages/gateway-contract/src/capabilities.js +30 -3
  109. package/dist/src/agent/external-tools/cliProvider.js +1 -1
  110. package/dist/src/agent/prompt/conversational-configuration-guide.d.ts +4 -0
  111. package/dist/src/agent/prompt/conversational-configuration-guide.js +25 -0
  112. package/dist/src/agent/prompt/service-prompt-builder.js +6 -1
  113. package/dist/src/agent/prompt/system-prompt.js +2 -2
  114. package/dist/src/agent/tool-manuals/xopc-configuration.d.ts +8 -0
  115. package/dist/src/agent/tool-manuals/xopc-configuration.js +55 -0
  116. package/dist/src/agent/tool-manuals/xopc-use.d.ts +1 -1
  117. package/dist/src/agent/tool-manuals/xopc-use.js +4 -1
  118. package/dist/src/agent/tools/factory.js +0 -5
  119. package/dist/src/agent/tools/tool-manual-tool.d.ts +1 -0
  120. package/dist/src/agent/tools/tool-manual-tool.js +27 -2
  121. package/dist/src/agent/tools/xopc-use-tool.js +12 -7
  122. package/dist/src/agent-catalog/capabilities.js +27 -1
  123. package/dist/src/agent-config/index.js +2 -2
  124. package/dist/src/agent-config/schema.d.ts +0 -116
  125. package/dist/src/agent-config/schema.js +2 -32
  126. package/dist/src/capabilities/store-connector.d.ts +9 -1
  127. package/dist/src/capabilities/store-connector.js +30 -1
  128. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  129. package/dist/src/config/schema.d.ts +1 -1
  130. package/dist/src/connectors/cli/adapterRegistry.js +1 -8
  131. package/dist/src/connectors/cli/runtime.js +1 -1
  132. package/dist/src/connectors/composio-catalog.d.ts +2 -2
  133. package/dist/src/connectors/composio-catalog.js +3 -8
  134. package/dist/src/connectors/composio-sessions.js +2 -0
  135. package/dist/src/connectors/composio.js +0 -6
  136. package/dist/src/connectors/connection-candidates.js +0 -5
  137. package/dist/src/connectors/connection-capabilities.js +0 -4
  138. package/dist/src/connectors/excluded-connectors.d.ts +4 -0
  139. package/dist/src/connectors/excluded-connectors.js +24 -0
  140. package/dist/src/connectors/install.js +3 -0
  141. package/dist/src/connectors/integration-strategy.js +0 -5
  142. package/dist/src/connectors/providers.d.ts +0 -1
  143. package/dist/src/connectors/providers.js +2 -14
  144. package/dist/src/gateway/hono/routes/personal-agent.js +4 -5
  145. package/dist/src/gateway/service/config-coordinator.d.ts +1 -1
  146. package/dist/src/personal-agent/communication.d.ts +1 -1
  147. package/dist/src/personal-agent/communication.js +1 -1
  148. package/dist/src/personal-agent/default-style.d.ts +2 -0
  149. package/dist/src/personal-agent/default-style.js +11 -0
  150. package/dist/src/personal-agent/persona.d.ts +1 -1
  151. package/dist/src/personal-agent/persona.js +1 -1
  152. package/dist/src/personal-agent/policy.d.ts +1 -1
  153. package/dist/src/personal-agent/policy.js +0 -1
  154. package/dist/src/personal-agent/proactivity/service.js +1 -4
  155. package/dist/src/personal-agent/prompts.d.ts +1 -5
  156. package/dist/src/personal-agent/prompts.js +28 -39
  157. package/dist/src/personal-agent/reply-composer.js +3 -2
  158. package/dist/src/personal-agent/reply-style.d.ts +10 -2
  159. package/dist/src/personal-agent/reply-style.js +61 -3
  160. package/dist/src/personal-agent/repository.d.ts +0 -8
  161. package/dist/src/personal-agent/repository.js +1 -9
  162. package/dist/src/personal-agent/service.d.ts +2 -32
  163. package/dist/src/personal-agent/service.js +11 -17
  164. package/dist/src/platform/contracts.d.ts +3 -3
  165. package/dist/src/storage/sqlite/migrations/259_personal_default_style.sql +10 -0
  166. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  167. package/dist/src/storage/sqlite/migrations/runner.js +3 -3
  168. package/dist/src/storage/sqlite/schema.js +1 -1
  169. package/dist/src/tasks/task-main-update-decision-service.js +1 -1
  170. package/package.json +4 -1
  171. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-DRgnm9A5.js +0 -1
  172. package/dist/gateway/static/root/assets/agents-sIMLDv80.js +0 -77
  173. package/dist/gateway/static/root/assets/apps-page-CRAr0xnF.js +0 -1
  174. package/dist/gateway/static/root/assets/automations-workspace-BGpO47Sw.js +0 -6
  175. package/dist/gateway/static/root/assets/browser-BLJWD7WI.js +0 -8
  176. package/dist/gateway/static/root/assets/browser-automations-page-Dwhk5TFz.js +0 -3
  177. package/dist/gateway/static/root/assets/browser-settings-page-B1Mfsw2n.js +0 -3
  178. package/dist/gateway/static/root/assets/capabilities-Dl3LttAm.js +0 -1
  179. package/dist/gateway/static/root/assets/capabilities-page-lfNS8DDp.js +0 -2
  180. package/dist/gateway/static/root/assets/capabilities-settings-panel-DLL614DS.js +0 -8
  181. package/dist/gateway/static/root/assets/capability-icon-DVoZxEgW.js +0 -1
  182. package/dist/gateway/static/root/assets/capability-links-DzQWK1Fh.js +0 -1
  183. package/dist/gateway/static/root/assets/channels-W60IrDrt.js +0 -1
  184. package/dist/gateway/static/root/assets/computer-settings-page-BYYgEEdX.js +0 -1
  185. package/dist/gateway/static/root/assets/connectors-page-BUTj6vNY.js +0 -1
  186. package/dist/gateway/static/root/assets/device-pairing-wizard-BYUl_dNS.js +0 -1
  187. package/dist/gateway/static/root/assets/gateway-realtime-store-dKq2fm2X.js +0 -1
  188. package/dist/gateway/static/root/assets/gateway-settings-C1vgqKYa.js +0 -1
  189. package/dist/gateway/static/root/assets/home-page-Cd4MHgKf.js +0 -2
  190. package/dist/gateway/static/root/assets/index-DdJ_djQt.js +0 -260
  191. package/dist/gateway/static/root/assets/index-QegseiyI.css +0 -1
  192. package/dist/gateway/static/root/assets/local-app-workbench-page-ER7_0M_4.js +0 -1
  193. package/dist/gateway/static/root/assets/logs-page-_v_abG4D.js +0 -2
  194. package/dist/gateway/static/root/assets/management-settings-CWojbrEe.js +0 -1
  195. package/dist/gateway/static/root/assets/mermaid-MCJ5UELQ-BXiiOI72.js +0 -1
  196. package/dist/gateway/static/root/assets/messages-Bwv-AOYl.js +0 -3
  197. package/dist/gateway/static/root/assets/note-detail-panel-tHYUDAgB.js +0 -5
  198. package/dist/gateway/static/root/assets/note-image-lightbox-DwVH-T8-.js +0 -1
  199. package/dist/gateway/static/root/assets/notes-page-BQqxqB3t.js +0 -8
  200. package/dist/gateway/static/root/assets/personal-page-DyKbVh4z.js +0 -1
  201. package/dist/gateway/static/root/assets/plugin-details-dialog-CVbHabgS.js +0 -1
  202. package/dist/gateway/static/root/assets/plugin-presentation-BfVM-8kL.js +0 -1
  203. package/dist/gateway/static/root/assets/product-preview-content-DsPKx_gw.js +0 -1
  204. package/dist/gateway/static/root/assets/project-detail-page-BpUxpCUt.js +0 -1
  205. package/dist/gateway/static/root/assets/projects-page-BWrQ05az.js +0 -1
  206. package/dist/gateway/static/root/assets/remote-access-hub-D4k7snPU.js +0 -1
  207. package/dist/gateway/static/root/assets/session-manager-BMEW_eS_.js +0 -16
  208. package/dist/gateway/static/root/assets/sessions-page-DPrI8ql2.js +0 -1
  209. package/dist/gateway/static/root/assets/settings-advanced-gate-BYXPsUzS.js +0 -1
  210. package/dist/gateway/static/root/assets/settings-page-BYP_I9AF.js +0 -1
  211. package/dist/gateway/static/root/assets/shares-settings-q0E4FYlf.js +0 -1
  212. package/dist/gateway/static/root/assets/skill-reload-api-BNCLOlJs.js +0 -1
  213. package/dist/gateway/static/root/assets/skills-page-CYwH8kim.js +0 -2
  214. package/dist/gateway/static/root/assets/task-detail-page-CTqBd0eY.js +0 -2
  215. package/dist/gateway/static/root/assets/tracing-settings-page-0CvZ40sA.js +0 -1
  216. package/dist/gateway/static/root/assets/user-model-page-3Dr0YRDG.js +0 -2
  217. package/dist/gateway/static/root/assets/workflows-page-CqC45_Fd.js +0 -6
  218. package/dist/src/agent/tools/personal-preference-tool.d.ts +0 -10
  219. package/dist/src/agent/tools/personal-preference-tool.js +0 -55
  220. package/dist/src/connectors/china-catalog.d.ts +0 -2
  221. package/dist/src/connectors/china-catalog.js +0 -873
  222. package/dist/src/connectors/cli/adapters/lark.d.ts +0 -2
  223. package/dist/src/connectors/cli/adapters/lark.js +0 -143
  224. package/dist/src/connectors/cli/adapters/larkShortcuts.d.ts +0 -3
  225. package/dist/src/connectors/cli/adapters/larkShortcuts.js +0 -64
  226. package/dist/src/connectors/cli/adapters/wecom.d.ts +0 -2
  227. package/dist/src/connectors/cli/adapters/wecom.js +0 -97
  228. package/dist/src/connectors/cli/adapters/wps365/bundle.js +0 -575
  229. package/dist/src/connectors/cli/adapters/wps365.d.ts +0 -2
  230. package/dist/src/connectors/cli/adapters/wps365.js +0 -115
  231. package/dist/src/connectors/cli/distributions.d.ts +0 -4
  232. package/dist/src/connectors/cli/distributions.js +0 -69
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{f as i}from"./chunk-KS7C4IRE-B2HK1psj.js";import{t as a}from"./circle-check-C23XjkUj.js";import{t as o}from"./external-link-DjqjBmc3.js";import{t as s}from"./x-B_N4OPjy.js";import{t as c}from"./messages-Bwv-AOYl.js";import{t as l}from"./cn-0WouolD0.js";import{a as u,c as d,i as f,n as p,r as m}from"./locale-store-D5h-Ha6-.js";import{a as h,i as g,n as _,o as v,r as y,s as b,t as x}from"./dist-BGTk37IG.js";import{i as S}from"./vendor-swr-BIWyz7Rc.js";import{Fc as C,G as w,Gn as T,Hl as E,Ju as D,Kc as O,Ml as k,On as A,Rc as j,Rn as M,Un as N,Vi as P,Wn as F,Xa as I,ms as L,mu as R,nu as z,so as ee,uf as te,uo as ne,us as re,uu as ie,vs as ae,ys as oe}from"./index-DdJ_djQt.js";import{r as se}from"./settings-page-layout-Dx5S-Msc.js";import{t as ce}from"./browser-BLJWD7WI.js";import{t as le}from"./schema-form-gO0zayZd.js";var B=e(t(),1),V=n();async function ue(){return(await u(m(`/api/channels/status`))).payload?.channels||[]}function de(){return m(`/api/channels/status`)}var fe=ue;function pe(e){let t=e.actions??{};for(let e of[`login.start`,`setup.start`]){let n=t[e];if(n?.result===`qr`)return[e,n]}let n=Object.entries(t).find(([,e])=>e.result===`qr`);if(n)return n;let r=e.ui?.card?.primaryAction;if(r&&t[r])return[r,t[r]];for(let e of[`login.start`,`setup.start`]){let n=t[e];if(n)return[e,n]}return Object.entries(t).find(([,e])=>e.result===`form`)??null}var me=e(ce(),1),H=r();async function U(e){let t=await f(m(`/api/channels/${encodeURIComponent(e.channelId)}/actions/${encodeURIComponent(e.actionId)}?locale=${encodeURIComponent(e.locale)}`),{method:`POST`,body:JSON.stringify({...e.accountId?{accountId:e.accountId}:{},...e.input===void 0?{}:{input:e.input}})}),n=await t.json().catch(()=>({}));if(!t.ok||n.ok===!1)throw Error(n.error?.message??t.statusText);return n.payload??{type:`ok`}}function W(e){return e?.type===`poll`&&e.phase===`done`}function G(e){return e&&`message`in e&&typeof e.message==`string`?e.message:null}function K(e,t){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrPayload?e.qrPayload:t===`weixin`&&e.qrcodeUrl?e.qrcodeUrl:null}function q(e){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrcodeUrl??null}function he({entry:e,locale:t,messages:n,onChanged:r,compact:i=!1}){let s=(0,B.useMemo)(()=>pe(e),[e]),c=(0,B.useMemo)(()=>({defaultBooleanLabel:n.schemaBooleanDefault,unsupportedArrayType:n.schemaUnsupportedArrayType,arrayAddPlaceholder:n.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>n.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[n]),[u,d]=(0,B.useState)({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null});(0,B.useEffect)(()=>{d({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null})},[e.id]);let f=(0,B.useCallback)(async(n,i)=>{d(e=>({...e,busy:!0,error:null}));try{let a=await U({channelId:e.id,actionId:n,locale:t,input:i});d(e=>({...e,payload:a,poll:a.type===`qr`&&a.statusAction&&a.conversationId?{actionId:a.statusAction,conversationId:a.conversationId,intervalMs:Math.max(1e3,a.pollIntervalMs??2500)}:null,busy:!1,formDraft:a.type===`form`?a.values??{}:e.formDraft})),`configChanged`in a&&a.configChanged===!0&&await r()}catch(e){d(t=>({...t,busy:!1,error:e instanceof Error?e.message:String(e)}))}},[e.id,t,r]);(0,B.useEffect)(()=>{let t=K(u.payload,e.id);if(!t){d(e=>e.generatedQr?{...e,generatedQr:null}:e);return}let n=!1;return d(e=>e.generatedQr?{...e,generatedQr:null}:e),me.toDataURL(t,{width:220,margin:1}).then(e=>{n||d(t=>({...t,generatedQr:e}))}),()=>{n=!0}},[e.id,u.payload]),(0,B.useEffect)(()=>{let n=u.poll;if(!n)return;let i=!1,a=window.setInterval(()=>{i||U({channelId:e.id,actionId:n.actionId,locale:t,input:{conversationId:n.conversationId}}).then(async e=>{i||(d(t=>({...t,payload:e,poll:W(e)?null:t.poll,error:null})),`configChanged`in e&&e.configChanged===!0&&await r(),W(e)&&window.clearInterval(a))}).catch(e=>{i||d(t=>({...t,error:e instanceof Error?e.message:String(e)}))})},n.intervalMs);return()=>{i=!0,window.clearInterval(a)}},[e.id,t,r,u.poll]);let p=s?.[1].label??(e.configured?n.reconnect:n.connect),m=e.actions?.[`doctor.run`]?.label??n.diagnose,h=G(u.payload),g=K(u.payload,e.id),_=g?u.generatedQr:q(u.payload),v=s?.[1].result===`qr`&&(u.busy||u.payload?.type===`qr`||u.payload?.type===`poll`),y=u.payload?.type===`form`?u.payload:null,b=u.payload?.type===`diagnostics`?u.payload.checks:null;return(0,H.jsxs)(`div`,{className:i?`space-y-3`:`rounded-lg bg-surface-panel/80 p-4 shadow-surface`,children:[(0,H.jsxs)(`div`,{className:l(`flex flex-wrap items-start gap-3`,i?`justify-end`:`justify-between`),children:[i?null:(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.setupTitle}),(0,H.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.configured?n.setupConfiguredHint:n.setupEmptyHint})]}),(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[s?(0,H.jsxs)(O,{type:`button`,variant:`primary`,disabled:u.busy,onClick:()=>void f(s[0]),children:[u.busy?(0,H.jsx)(D,{className:`size-4 animate-spin`}):(0,H.jsx)(R,{className:`size-4`}),p]}):null,e.actions?.[`doctor.run`]?(0,H.jsxs)(O,{type:`button`,variant:`secondary`,disabled:u.busy,onClick:()=>void f(`doctor.run`),children:[(0,H.jsx)(E,{className:`size-4`}),m]}):null]})]}),h?(0,H.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:h}):null,u.error?(0,H.jsx)(`p`,{className:`mt-3 text-sm text-red-600 dark:text-red-400`,children:u.error}):null,v?(0,H.jsxs)(`div`,{className:l(`flex h-80 items-center justify-center gap-4 overflow-hidden rounded-lg bg-surface-base p-3 shadow-surface`,i?`mt-1 flex-col text-center sm:h-64 sm:flex-row sm:text-left`:`mt-4 flex-col sm:h-64 sm:flex-row`),children:[(0,H.jsx)(`div`,{className:`flex size-56 shrink-0 items-center justify-center rounded-lg border border-edge bg-white p-3`,children:_?(0,H.jsx)(`img`,{src:_,alt:`${e.label} setup QR`,className:`size-52 object-contain`}):(0,H.jsx)(`div`,{className:`flex size-52 items-center justify-center rounded-md bg-surface-base`,children:(0,H.jsx)(j,{className:`size-48 rounded-md`})})}),(0,H.jsxs)(`div`,{className:l(`min-w-0 max-w-sm text-sm text-fg-muted`,i&&`w-full sm:w-auto`),children:[_?(0,H.jsx)(`p`,{className:`line-clamp-3`,children:n.waitingConfirmation}):(0,H.jsxs)(`div`,{className:`space-y-2`,"aria-busy":`true`,children:[(0,H.jsx)(j,{className:`h-4 w-48 max-w-full`}),(0,H.jsx)(j,{className:`h-4 w-36 max-w-full`})]}),g?(0,H.jsxs)(`a`,{className:`mt-2 inline-flex items-center gap-1 text-accent hover:underline`,href:g,target:`_blank`,rel:`noreferrer`,children:[n.openSetupLink,(0,H.jsx)(o,{className:`size-3.5`})]}):null]})]}):null,u.payload?.type===`poll`&&u.payload.phase===`done`?(0,H.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 rounded-lg bg-surface-base px-3 py-2 text-sm shadow-surface`,children:[(0,H.jsx)(a,{className:u.payload.ok?`size-4 text-green-600`:`size-4 text-red-600`}),(0,H.jsx)(`span`,{className:u.payload.ok?`text-fg`:`text-red-600 dark:text-red-400`,children:u.payload.message??(u.payload.ok?n.complete:n.failed)})]}):null,y?(0,H.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,H.jsx)(le,{schema:y.schema,values:u.formDraft,onChange:e=>d(t=>({...t,formDraft:e})),disabled:u.busy,labels:c}),(0,H.jsx)(O,{type:`button`,variant:`primary`,disabled:u.busy,onClick:()=>void f(y.submitAction,u.formDraft),children:n.saveSetup})]}):null,b?(0,H.jsx)(`div`,{className:`mt-4 space-y-2`,children:b.map((e,t)=>(0,H.jsxs)(`div`,{className:`rounded-lg bg-surface-base px-3 py-2 shadow-surface`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,H.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.label??e.id??n.diagnosticCheckFallback.replace(`{{index}}`,String(t+1))}),(0,H.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e.status??`unknown`})]}),e.message?(0,H.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.message}):null]},e.id??t))}):null]})}var ge=40;function J(e){return`ui:route:channel:${e.trim().toLowerCase()}`}function _e(e,t){return e.find(e=>e.id===J(t))?.agentId?.trim().toLowerCase()??``}function ve(e,t,n){let r=J(t),i=e.filter(e=>e.id!==r),a=n.trim().toLowerCase();return a?[...i,{id:r,agentId:a,priority:ge,enabled:!0,match:{channel:t.trim().toLowerCase(),accountId:`*`}}]:i}function ye(e){let t=e.configured===!0,n=e.enabled===!0;return e.setupStatus??{enabled:n,ready:t,state:n&&!t?`needs_setup`:n?`ready`:`disabled`,issues:[]}}function be(e,t,n){let r=ye(e);return r.ready?r.enabled?n?t?.connected===!0?`running`:`stopped`:`checking`:`disabled`:`needs_setup`}function xe(e,t=!1){return e===`drawer`?l(`xopc-drawer-right fixed right-0 top-0 flex size-full flex-col overflow-hidden border-l border-edge bg-surface-overlay shadow-popover outline-none dark:border-edge`,t?`max-w-[36rem]`:`max-w-xl`,ae):l(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(calc(100dvh-2rem),52rem)] w-[min(calc(100%-2rem),32rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,t&&`h-[min(calc(100dvh-2rem),48rem)] w-[min(calc(100%-2rem),36rem)]`,ae,`rounded-2xl border border-edge bg-surface-overlay outline-none dark:border-edge`)}function Se(e){let t=(0,V.c)(33),{presentation:n,open:r,onOpenChange:i,title:a,description:o,srTitle:c,srDescription:u,closeAriaLabel:d,children:f,footer:p,wide:m,headerExtra:S}=e,w=m===void 0?!1:m,T=n===`drawer`,[E,D]=(0,B.useState)(null),k;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,H.jsx)(h,{className:l(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,oe)}),t[0]=k):k=t[0];let A;t[1]!==n||t[2]!==w?(A=xe(n,w),t[1]=n,t[2]=w,t[3]=A):A=t[3];let j;t[4]===c?j=t[5]:(j=c?(0,H.jsx)(b,{className:`sr-only`,children:c}):null,t[4]=c,t[5]=j);let M;t[6]===u?M=t[7]:(M=u?(0,H.jsx)(g,{className:`sr-only`,children:u}):null,t[6]=u,t[7]=M);let N;t[8]!==d||t[9]!==o||t[10]!==S||t[11]!==T||t[12]!==a?(N=T?(0,H.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,H.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[a?(0,H.jsx)(`div`,{className:`text-base font-semibold text-fg`,children:a}):null,o?(0,H.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:o}):null]}),(0,H.jsx)(_,{asChild:!0,children:(0,H.jsx)(O,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":d,children:(0,H.jsx)(s,{className:`size-5`,strokeWidth:1.75})})})]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(_,{asChild:!0,children:(0,H.jsx)(`button`,{type:`button`,className:l(C,`absolute right-3 top-3 z-20 p-1.5 hover:bg-surface-hover`),"aria-label":d,children:(0,H.jsx)(s,{className:`size-4`})})}),S]}),t[8]=d,t[9]=o,t[10]=S,t[11]=T,t[12]=a,t[13]=N):N=t[13];let P=T?`p-4`:`p-6`,F;t[14]===P?F=t[15]:(F=l(`min-h-0 flex-1 overflow-y-auto`,P),t[14]=P,t[15]=F);let I;t[16]!==f||t[17]!==F?(I=(0,H.jsx)(`div`,{className:F,children:f}),t[16]=f,t[17]=F,t[18]=I):I=t[18];let R;t[19]!==p||t[20]!==E||t[21]!==j||t[22]!==M||t[23]!==N||t[24]!==I?(R=(0,H.jsxs)(L,{layer:`modal`,portalContainer:E,children:[j,M,N,I,p]}),t[19]=p,t[20]=E,t[21]=j,t[22]=M,t[23]=N,t[24]=I,t[25]=R):R=t[25];let z;t[26]!==R||t[27]!==A?(z=(0,H.jsxs)(v,{children:[k,(0,H.jsx)(y,{ref:D,className:A,onOpenAutoFocus:Ce,children:R})]}),t[26]=R,t[27]=A,t[28]=z):z=t[28];let ee;return t[29]!==i||t[30]!==r||t[31]!==z?(ee=(0,H.jsx)(x,{open:r,onOpenChange:i,children:z}),t[29]=i,t[30]=r,t[31]=z,t[32]=ee):ee=t[32],ee}function Ce(e){return e.preventDefault()}var we=(0,B.memo)(function(e){let t=(0,V.c)(10),{ch:n,refreshing:r,saveOk:i,onRefresh:a}=e,o;t[0]!==n.saved||t[1]!==i?(o=i?(0,H.jsx)(`span`,{className:`text-sm text-fg-muted`,children:n.saved}):null,t[0]=n.saved,t[1]=i,t[2]=o):o=t[2];let s;t[3]!==n.refresh||t[4]!==a||t[5]!==r?(s=(0,H.jsx)(I,{className:`size-9 shrink-0 p-0`,loading:r,label:n.refresh,onClick:a}),t[3]=n.refresh,t[4]=a,t[5]=r,t[6]=s):s=t[6];let c;return t[7]!==o||t[8]!==s?(c=(0,H.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center justify-end gap-2`,children:[o,s]}),t[7]=o,t[8]=s,t[9]=c):c=t[9],c});function Te(e){let t=(0,V.c)(24),{ch:n,dirty:r,saving:i,onCancel:a,onDiscard:o,onSave:s,showCancel:c}=e,l=c===void 0?!0:c,u;t[0]!==n.unsavedHint||t[1]!==r?(u=r?(0,H.jsx)(`p`,{className:`mb-3 text-xs text-amber-800 dark:text-amber-200`,children:n.unsavedHint}):null,t[0]=n.unsavedHint,t[1]=r,t[2]=u):u=t[2];let d;t[3]!==n.modalCancel||t[4]!==a||t[5]!==l?(d=l?(0,H.jsx)(O,{type:`button`,variant:`secondary`,onClick:a,children:n.modalCancel}):null,t[3]=n.modalCancel,t[4]=a,t[5]=l,t[6]=d):d=t[6];let f=!r||i,p;t[7]!==n.discard||t[8]!==o||t[9]!==f?(p=(0,H.jsx)(O,{type:`button`,variant:`secondary`,disabled:f,onClick:o,children:n.discard}),t[7]=n.discard,t[8]=o,t[9]=f,t[10]=p):p=t[10];let m=!r||i,h;t[11]===s?h=t[12]:(h=()=>void s(),t[11]=s,t[12]=h);let g=i?n.saving:n.save,_;t[13]!==m||t[14]!==h||t[15]!==g?(_=(0,H.jsx)(O,{type:`button`,variant:`primary`,disabled:m,onClick:h,children:g}),t[13]=m,t[14]=h,t[15]=g,t[16]=_):_=t[16];let v;t[17]!==d||t[18]!==p||t[19]!==_?(v=(0,H.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[d,p,_]}),t[17]=d,t[18]=p,t[19]=_,t[20]=v):v=t[20];let y;return t[21]!==v||t[22]!==u?(y=(0,H.jsxs)(`div`,{className:`sticky bottom-0 shrink-0 border-t border-edge-subtle bg-surface-panel px-6 py-4 dark:border-edge-subtle`,children:[u,v]}),t[21]=v,t[22]=u,t[23]=y):y=t[23],y}function Ee(e){return m(`/api/channels/catalog?locale=${encodeURIComponent(e)}`)}async function De(e){return(await u(Ee(e))).payload?.channels??[]}function Oe(e,t){let n=(0,V.c)(14),r;n[0]!==e||n[1]!==t?(r=e?Ee(t):null,n[0]=e,n[1]=t,n[2]=r):r=n[2];let i;n[3]===t?i=n[4]:(i=()=>De(t),n[3]=t,n[4]=i);let a;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(a={revalidateOnFocus:!1},n[5]=a):a=n[5];let{data:o,error:s,isLoading:c,isValidating:l,mutate:u}=S(r,i,a),d;n[6]===o?d=n[7]:(d=o??[],n[6]=o,n[7]=d);let f;return n[8]!==s||n[9]!==c||n[10]!==l||n[11]!==u||n[12]!==d?(f={entries:d,isLoading:c,isValidating:l,error:s,mutate:u},n[8]=s,n[9]=c,n[10]=l,n[11]=u,n[12]=d,n[13]=f):f=n[13],f}var ke=`channels-status`;function Ae(e){if(!e||typeof e!=`object`)return null;let t=e.channels;return Array.isArray(t)?t:null}function je(e){let t=t=>e(t.detail);return window.addEventListener(ke,t),()=>window.removeEventListener(ke,t)}function Me(e,t){let n=(0,V.c)(4),r=t===void 0?!0:t,i,a;n[0]!==r||n[1]!==e?(i=()=>{if(r)return je(e)},a=[r,e],n[0]=r,n[1]=e,n[2]=i,n[3]=a):(i=n[2],a=n[3]),(0,B.useEffect)(i,a)}function Ne(e){return e?m(`/api/channels/${encodeURIComponent(e)}/config`):null}async function Pe(e){return(await u(m(`/api/channels/${encodeURIComponent(e)}/config`))).payload?.config??{}}var Fe=[`enabled`],Ie=`max-w-7xl`,Le=`px-4 pb-7 pt-3 sm:px-6 lg:px-8 lg:pb-9 lg:pt-4`;async function Re(){let e=await u(m(`/api/config`));return{channels:e.payload?.config?.channels??{},bindings:e.payload?.config?.bindings??[]}}function ze(e){return e.split(`/`).filter(Boolean).map(e=>encodeURIComponent(e)).join(`/`)}function Be(e){return e.configPath.startsWith(`channels.`)&&e.configPath.slice(9).split(`.`)[0]||e.id}function Y(e){let t=e.configured===!0,n=e.enabled===!0;return e.setupStatus??{enabled:n,ready:t,state:n&&!t?`needs_setup`:n?`ready`:`disabled`,issues:[]}}function Ve(e,t){return e===`running`?t.connectionRunning:e===`stopped`?t.connectionStopped:e===`checking`?t.connectionChecking:e===`disabled`?t.connectionDisabled:t.connectionNeedsSetup}function He(e,t){return e===`running`?t.connectionRunningHint:e===`stopped`?t.connectionStoppedHint:e===`disabled`?t.connectionDisabledHint:e===`needs_setup`?t.connectionNeedsSetupHint:t.connectionChecking}function Ue(e){return e===`running`?`bg-emerald-500/12 text-emerald-700 dark:text-emerald-300`:e===`stopped`?`bg-red-500/10 text-red-700 dark:text-red-300`:e===`checking`?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:e===`disabled`?`bg-surface-hover text-fg-muted`:`bg-amber-500/10 text-amber-700 dark:text-amber-300`}function We(e){if(!e)return[];let t=e.uiHints??{},n=X(e.configSchema)&&Array.isArray(e.configSchema.required)?e.configSchema.required.map(String):[],r=Y(e).issues.map(e=>e.fieldPath).filter(e=>!!e),i=new Set([`dmPolicy`,`groupPolicy`,`allowFrom`,`groupAllowFrom`]),a=[...Object.keys(t).filter(e=>!e.includes(`*`)&&i.has(e.split(`.`).at(-1)??``)),...Object.keys(X(e.configSchema?.properties)?e.configSchema.properties:{}).filter(e=>i.has(e))],o=Object.entries(t).filter(([,e])=>!X(e)||e.advanced===!0?!1:(Array.isArray(e.tags)?e.tags.map(String):[]).includes(`basic`)||e.advanced===!1).map(([e])=>e).filter(e=>!Fe.includes(e));return Array.from(new Set([...o,...a,...n,...r])).filter(e=>!Fe.includes(e))}function X(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Z(e){return JSON.parse(JSON.stringify(e??{type:`object`,properties:{}}))}function Ge(e,t){let n={...Z(e),properties:{}};for(let r of t){let t=r.split(`.`),i=e,a=n;for(let[e,n]of t.entries()){let r=i.properties;if(!X(r)||!X(r[n]))break;let o=X(a.properties)?a.properties:{};if(a.properties=o,o[n]||(o[n]={...Z(r[n]),properties:{}}),e===t.length-1){o[n]=Z(r[n]);break}i=r[n],a=o[n]}}return n}function Ke(e){let t=e.properties;if(!X(t))return!1;for(let[e,n]of Object.entries(t))X(n)&&n.type===`object`&&Ke(n)&&delete t[e];return Object.keys(t).length===0}function qe(e,t){let n=Z(e);for(let e of t){let t=e.split(`.`),r=n;for(let[e,n]of t.entries()){let i=r.properties;if(!X(i))break;if(e===t.length-1){delete i[n];break}if(!X(i[n]))break;r=i[n]}}return Ke(n),n}function Je(e){return e.type===`object`&&X(e.properties)&&Object.keys(e.properties).length>0}function Q(e,t){let n=e;for(let e of t.split(`.`)){if(!X(n))return;n=n[e]}return n}function Ye(e){let t=e.accounts;return X(t)?Object.values(t).filter(e=>X(e)&&e.enabled!==!1).length:+(e.configured===!0)}function Xe(e,t,n){return t==null||t===``?null:e.toLowerCase().includes(`dmpolicy`)&&typeof t==`string`?`${n.dmPolicy}: ${n.policy.dm[t]??t}`:(e.toLowerCase().includes(`stream`)||e.toLowerCase().includes(`streaming`))&&typeof t==`string`?`${n.cardStream}: ${n.policy.stream[t]??t}`:typeof t==`boolean`?t?n.enabledLabel:n.disabledLabel:String(t)}function Ze(e,t,n){let r=[],i=Y(e);if(i.issues.length>0&&r.push($(i.issues[0],n)),t){let i=e.ui?.card?.summaryFields??[`dmPolicy`,`streamMode`,`streaming.mode`];for(let e of i){let i=Xe(e,Q(t,e),n);i&&r.push(i)}let a=Ye(t);a>0&&r.push(n.cardAccounts.replace(`{{count}}`,String(a)))}return r.length>0?r.slice(0,2):i.ready?[n.hubStatusConfigured]:[]}function Qe(e,t){let n=Y(e),r=pe(e);return n.state===`needs_setup`?r?.[1].label??t.completeSetup:!n.enabled&&n.ready?t.enableChannel:n.state===`error`?t.diagnose:n.ready?t.manageChannel:r?.[1].label??t.startConfiguration}function $e(e,t){let n=pe(e);return n?.[1].result===`qr`?t.cardSetupQrHint:n?.[1].result===`form`?t.cardSetupConfigHint:t.cardSetupGenericHint}function et(e,t){let n=e.capabilities??{},r=[];return n.login===!0&&r.push(t.cardCapabilityLogin),n.pairing===!0&&r.push(t.cardCapabilityPairing),n.multiAccount===!0&&r.push(t.cardCapabilityMultiAccount),n.streaming===!0&&r.push(t.cardCapabilityStreaming),n.media===!0&&r.push(t.cardCapabilityMedia),n.doctor===!0&&r.push(t.cardCapabilityDoctor),r.slice(0,3)}function $(e,t){return e.code===`telegram.missing_credential`?t.setupIssueTelegramMissingCredential:e.code===`weixin.missing_account`?t.setupIssueWeixinMissingAccount:e.code===`feishu.missing_credentials`?t.setupIssueFeishuMissingCredentials:e.code===`config.missing_required`&&e.fieldPath?t.setupIssueMissingRequired.replace(`{{field}}`,e.fieldPath):e.message}function tt({entry:e}){let[t,n]=(0,B.useState)(!1),r=(0,B.useMemo)(()=>!e.ui?.icon||t?null:new URL(m(`/api/extensions/${encodeURIComponent(e.extensionId)}/assets/${ze(e.ui.icon)}`)).toString(),[t,e.extensionId,e.ui?.icon]);return(0,H.jsx)(`span`,{className:`flex size-12 shrink-0 items-center justify-center rounded-2xl bg-surface-base text-fg`,children:r?(0,H.jsx)(`img`,{src:r,alt:``,draggable:!1,className:`size-7`,"aria-hidden":!0,onError:()=>n(!0)}):(0,H.jsx)(ne,{sourceChannel:e.id,className:`size-7`})})}function nt(e){let t=(0,V.c)(16),{checked:n,disabled:r,onToggle:i,label:a}=e,o;t[0]===i?o=t[1]:(o=e=>{e.stopPropagation(),i()},t[0]=i,t[1]=o);let s=n?`border-accent bg-accent`:`border-edge bg-surface-hover`,c=r&&`cursor-not-allowed opacity-60`,u;t[2]!==s||t[3]!==c?(u=l(`relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border transition-colors`,s,c),t[2]=s,t[3]=c,t[4]=u):u=t[4];let d=n?`translate-x-5`:`translate-x-0.5`,f;t[5]===d?f=t[6]:(f=l(`size-5 rounded-full bg-white shadow-surface transition-transform`,d),t[5]=d,t[6]=f);let p;t[7]===f?p=t[8]:(p=(0,H.jsx)(`span`,{className:f}),t[7]=f,t[8]=p);let m;return t[9]!==n||t[10]!==r||t[11]!==a||t[12]!==o||t[13]!==u||t[14]!==p?(m=(0,H.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":n,"aria-label":a,disabled:r,onClick:o,className:u,children:p}),t[9]=n,t[10]=r,t[11]=a,t[12]=o,t[13]=u,t[14]=p,t[15]=m):m=t[15],m}function rt(e){let t=(0,V.c)(71),{entry:n,config:r,runtime:i,busy:a,restarting:o,ch:s,onOpen:c,onToggle:u,onRestart:d}=e,f;t[0]===n?f=t[1]:(f=Y(n),t[0]=n,t[1]=f);let p=f,m,h,g,_,v,y,b;if(t[2]!==a||t[3]!==s||t[4]!==r||t[5]!==n||t[6]!==c||t[7]!==d||t[8]!==u||t[9]!==i||t[10]!==p.enabled||t[11]!==p.ready){let e=Ze(n,r,s),o=et(n,s);m=!p.enabled&&p.ready?u:i===`stopped`?d:c,y=`flex min-h-[15.5rem] flex-col rounded-xl bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45`;let f;t[19]===n?f=t[20]:(f=(0,H.jsx)(tt,{entry:n}),t[19]=n,t[20]=f);let x;t[21]===n.label?x=t[22]:(x=(0,H.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:n.label}),t[21]=n.label,t[22]=x);let S;t[23]===i?S=t[24]:(S=l(`mt-1 inline-flex rounded-full px-2 py-0.5 text-xs font-medium`,Ue(i)),t[23]=i,t[24]=S);let C;t[25]!==s||t[26]!==i?(C=Ve(i,s),t[25]=s,t[26]=i,t[27]=C):C=t[27];let w;t[28]!==S||t[29]!==C?(w=(0,H.jsx)(`span`,{className:S,children:C}),t[28]=S,t[29]=C,t[30]=w):w=t[30];let T;t[31]!==w||t[32]!==x?(T=(0,H.jsxs)(`div`,{className:`min-w-0`,children:[x,w]}),t[31]=w,t[32]=x,t[33]=T):T=t[33];let E;t[34]!==T||t[35]!==f?(E=(0,H.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[f,T]}),t[34]=T,t[35]=f,t[36]=E):E=t[36];let D=p.enabled,O;t[37]!==s.toggleChannel||t[38]!==n.label?(O=s.toggleChannel.replace(`{{channel}}`,n.label),t[37]=s.toggleChannel,t[38]=n.label,t[39]=O):O=t[39];let k;t[40]!==a||t[41]!==u||t[42]!==p.enabled||t[43]!==O?(k=(0,H.jsx)(nt,{checked:D,disabled:a,label:O,onToggle:u}),t[40]=a,t[41]=u,t[42]=p.enabled,t[43]=O,t[44]=k):k=t[44],t[45]!==E||t[46]!==k?(b=(0,H.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[E,k]}),t[45]=E,t[46]=k,t[47]=b):b=t[47],h=`button`,g=c,_=`mt-5 min-h-[6.25rem] text-left`,v=p.ready?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`p`,{className:`line-clamp-2 text-sm leading-6 text-fg-muted`,children:n.description??n.id}),e.length>0?(0,H.jsx)(`div`,{className:`mt-3 space-y-0.5 text-sm leading-5 text-fg-muted`,children:e.map(at)}):null]}):(0,H.jsxs)(`div`,{className:`rounded-lg bg-surface-base p-3`,children:[(0,H.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:s.cardSetupTitle}),(0,H.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm leading-5 text-fg-muted`,children:e[0]??$e(n,s)}),o.length>0?(0,H.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:o.map(it)}):null]}),t[2]=a,t[3]=s,t[4]=r,t[5]=n,t[6]=c,t[7]=d,t[8]=u,t[9]=i,t[10]=p.enabled,t[11]=p.ready,t[12]=m,t[13]=h,t[14]=g,t[15]=_,t[16]=v,t[17]=y,t[18]=b}else m=t[12],h=t[13],g=t[14],_=t[15],v=t[16],y=t[17],b=t[18];let x;t[48]!==h||t[49]!==g||t[50]!==_||t[51]!==v?(x=(0,H.jsx)(`button`,{type:h,onClick:g,className:_,children:v}),t[48]=h,t[49]=g,t[50]=_,t[51]=v,t[52]=x):x=t[52];let S=a||o,C;t[53]!==a||t[54]!==o?(C=a||o?(0,H.jsx)(D,{className:`size-4 animate-spin`}):null,t[53]=a,t[54]=o,t[55]=C):C=t[55];let w;t[56]!==s||t[57]!==n||t[58]!==o||t[59]!==i?(w=o?s.restartingChannel:i===`stopped`?s.restartChannel:Qe(n,s),t[56]=s,t[57]=n,t[58]=o,t[59]=i,t[60]=w):w=t[60];let T;t[61]!==m||t[62]!==C||t[63]!==w||t[64]!==S?(T=(0,H.jsx)(`div`,{className:`mt-auto pt-4`,children:(0,H.jsxs)(O,{type:`button`,variant:`secondary`,className:`w-full rounded-2xl py-2.5`,onClick:m,disabled:S,children:[C,w]})}),t[61]=m,t[62]=C,t[63]=w,t[64]=S,t[65]=T):T=t[65];let E;return t[66]!==T||t[67]!==y||t[68]!==b||t[69]!==x?(E=(0,H.jsxs)(`article`,{className:y,children:[b,x,T]}),t[66]=T,t[67]=y,t[68]=b,t[69]=x,t[70]=E):E=t[70],E}function it(e){return(0,H.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e},e)}function at(e){return(0,H.jsx)(`p`,{className:`truncate`,title:e,children:e},e)}function ot(e){let t=(0,V.c)(51),{runtime:n,restarting:r,checking:i,showConnectionOptions:o,canManageConnection:s,ch:c,onRestart:u,onCheck:d,onManageConnection:f}=e,p=n===`running`?a:n===`stopped`||n===`needs_setup`?te:D,m=n===`running`&&`text-emerald-600 dark:text-emerald-400`,h=n===`stopped`&&`text-red-600 dark:text-red-400`,g=n===`checking`&&`animate-spin text-amber-600 dark:text-amber-400`,_=n===`disabled`&&`text-fg-muted`,v=n===`needs_setup`&&`text-amber-600 dark:text-amber-400`,y;t[0]!==m||t[1]!==h||t[2]!==g||t[3]!==_||t[4]!==v?(y=l(`mt-0.5 size-5 shrink-0`,m,h,g,_,v),t[0]=m,t[1]=h,t[2]=g,t[3]=_,t[4]=v,t[5]=y):y=t[5];let b;t[6]!==p||t[7]!==y?(b=(0,H.jsx)(p,{className:y}),t[6]=p,t[7]=y,t[8]=b):b=t[8];let x;t[9]===c.connectionStatus?x=t[10]:(x=(0,H.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:c.connectionStatus}),t[9]=c.connectionStatus,t[10]=x);let S;t[11]!==c||t[12]!==n?(S=He(n,c),t[11]=c,t[12]=n,t[13]=S):S=t[13];let C;t[14]===S?C=t[15]:(C=(0,H.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:S}),t[14]=S,t[15]=C);let w;t[16]!==C||t[17]!==x?(w=(0,H.jsxs)(`div`,{children:[x,C]}),t[16]=C,t[17]=x,t[18]=w):w=t[18];let T;t[19]!==w||t[20]!==b?(T=(0,H.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[b,w]}),t[19]=w,t[20]=b,t[21]=T):T=t[21];let E=i||r,k;t[22]===i?k=t[23]:(k=i?(0,H.jsx)(D,{className:`size-4 animate-spin`}):null,t[22]=i,t[23]=k);let A=i?c.checkingConnection:c.checkConnection,j;t[24]!==d||t[25]!==E||t[26]!==k||t[27]!==A?(j=(0,H.jsxs)(O,{type:`button`,variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:E,onClick:d,children:[k,A]}),t[24]=d,t[25]=E,t[26]=k,t[27]=A,t[28]=j):j=t[28];let M;t[29]!==c.restartChannel||t[30]!==c.restartingChannel||t[31]!==i||t[32]!==u||t[33]!==r||t[34]!==n?(M=n===`stopped`?(0,H.jsxs)(O,{type:`button`,variant:`primary`,className:`px-2.5 py-1.5 text-xs`,disabled:r||i,onClick:u,children:[r?(0,H.jsx)(D,{className:`size-4 animate-spin`}):(0,H.jsx)(ie,{className:`size-4`}),r?c.restartingChannel:c.restartChannel]}):null,t[29]=c.restartChannel,t[30]=c.restartingChannel,t[31]=i,t[32]=u,t[33]=r,t[34]=n,t[35]=M):M=t[35];let N;t[36]!==s||t[37]!==c.connectionOptions||t[38]!==c.hideConnectionOptions||t[39]!==i||t[40]!==f||t[41]!==r||t[42]!==o?(N=s?(0,H.jsx)(O,{type:`button`,variant:`ghost`,className:`px-2.5 py-1.5 text-xs`,disabled:i||r,onClick:f,children:o?c.hideConnectionOptions:c.connectionOptions}):null,t[36]=s,t[37]=c.connectionOptions,t[38]=c.hideConnectionOptions,t[39]=i,t[40]=f,t[41]=r,t[42]=o,t[43]=N):N=t[43];let P;t[44]!==j||t[45]!==M||t[46]!==N?(P=(0,H.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[j,M,N]}),t[44]=j,t[45]=M,t[46]=N,t[47]=P):P=t[47];let F;return t[48]!==T||t[49]!==P?(F=(0,H.jsx)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:(0,H.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[T,P]})}),t[48]=T,t[49]=P,t[50]=F):F=t[50],F}function st(e){let t=(0,V.c)(33),{entry:n,ch:r}=e,i,a,o,s,c,l,u,d,f;if(t[0]!==r||t[1]!==n){f=Symbol.for(`react.early_return_sentinel`);bb0:{let e=Y(n);if(e.ready||e.issues.length===0){f=null;break bb0}d=`rounded-xl bg-amber-50 px-4 py-3 text-amber-950 dark:bg-amber-950/30 dark:text-amber-100`,l=`flex items-start gap-3`,t[11]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,H.jsx)(k,{className:`mt-0.5 size-4 shrink-0`}),t[11]=u):u=t[11],o=`min-w-0`,t[12]===r.setupReadinessTitle?s=t[13]:(s=(0,H.jsx)(`h3`,{className:`text-sm font-semibold`,children:r.setupReadinessTitle}),t[12]=r.setupReadinessTitle,t[13]=s);let p=e.enabled?r.setupReadinessEnabledBody:r.setupReadinessDisabledBody;t[14]===p?c=t[15]:(c=(0,H.jsx)(`p`,{className:`mt-1 text-sm leading-5 text-amber-900 dark:text-amber-200`,children:p}),t[14]=p,t[15]=c),i=`mt-2 list-disc space-y-1 pl-5 text-sm text-amber-900 dark:text-amber-200`;let m;t[16]===r?m=t[17]:(m=e=>(0,H.jsx)(`li`,{children:$(e,r)},`${e.code}:${e.fieldPath??``}`),t[16]=r,t[17]=m),a=e.issues.map(m)}t[0]=r,t[1]=n,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=f}else i=t[2],a=t[3],o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10];if(f!==Symbol.for(`react.early_return_sentinel`))return f;let p;t[18]!==i||t[19]!==a?(p=(0,H.jsx)(`ul`,{className:i,children:a}),t[18]=i,t[19]=a,t[20]=p):p=t[20];let m;t[21]!==p||t[22]!==o||t[23]!==s||t[24]!==c?(m=(0,H.jsxs)(`div`,{className:o,children:[s,c,p]}),t[21]=p,t[22]=o,t[23]=s,t[24]=c,t[25]=m):m=t[25];let h;t[26]!==m||t[27]!==l||t[28]!==u?(h=(0,H.jsxs)(`div`,{className:l,children:[u,m]}),t[26]=m,t[27]=l,t[28]=u,t[29]=h):h=t[29];let g;return t[30]!==h||t[31]!==d?(g=(0,H.jsx)(`section`,{className:d,children:h}),t[30]=h,t[31]=d,t[32]=g):g=t[32],g}function ct({channelId:e,onHeaderActionChange:t}){let n=p(e=>e.language),r=c(n),a=d(e=>!!e.conversationId),s=i(),u=T(e),h=Oe(a,n),g=h.entries,{data:_,mutate:v,isValidating:y}=S(a?de():null,fe,{revalidateOnFocus:!0}),{data:b,mutate:x}=S(a?`channels-config-map`:null,Re,{revalidateOnFocus:!1}),C=b?.channels??{},E=b?.bindings??[],{data:D}=S(a?`channel-routing-agents`:null,ee,{revalidateOnFocus:!1}),O=(0,B.useMemo)(()=>g.find(e=>e.id===u),[u,g]),k=O?Be(O):null,{data:j,mutate:I}=S(a&&k?Ne(k):null,()=>Pe(k)),[L,R]=(0,B.useState)(null),[te,ne]=(0,B.useState)(!1),[ie,ae]=(0,B.useState)(null),[oe,ce]=(0,B.useState)(null),[V,ue]=(0,B.useState)(!1),[me,U]=(0,B.useState)(null),[W,G]=(0,B.useState)(null),K=L??j??{},q=r.channelsSettings,ge=(0,B.useMemo)(()=>O?.configSchema??{type:`object`,properties:{}},[O?.configSchema]),J=(0,B.useMemo)(()=>qe(ge,Fe),[ge]),ye=(0,B.useMemo)(()=>We(O),[O]),xe=(0,B.useMemo)(()=>Ge(J,ye),[ye,J]),Ce=(0,B.useMemo)(()=>qe(J,ye),[ye,J]),Ee=(0,B.useMemo)(()=>Je(xe),[xe]),De=O?W??_e(E,O.id):``,ke=(0,B.useMemo)(()=>(D?.items??[]).map(e=>{let t=M(e,r.agentsSettings);return{value:e.id,label:t===e.id?t:`${t} · ${e.id}`}}),[D?.items,r.agentsSettings]),je=D?.items.find(e=>e.id===D.defaultId),ze=je?M(je,r.agentsSettings):D?.defaultId??``,He=(0,B.useMemo)(()=>({defaultBooleanLabel:q.schemaBooleanDefault,unsupportedArrayType:q.schemaUnsupportedArrayType,arrayAddPlaceholder:q.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>q.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[q]),X=(0,B.useMemo)(()=>new Map((_??[]).map(e=>[e.name,e])),[_]),Z=_!==void 0,Ke=(0,B.useCallback)(e=>be(e,X.get(e.id),Z),[X,Z]),Q=(0,B.useCallback)(async()=>{await Promise.all([h.mutate(),v()])},[h,v]);Me((0,B.useCallback)(e=>{let t=Ae(e);t&&v(t,!1)},[v]),a);let Ye=(0,B.useMemo)(()=>a?{secondary:(0,H.jsx)(we,{ch:q,refreshing:h.isValidating||y,saveOk:!1,onRefresh:()=>void Q()})}:null,[h.isValidating,q,a,y,Q]);(0,B.useLayoutEffect)(()=>(t?.(Ye),()=>t?.(null)),[Ye,t]);let Xe=(0,B.useCallback)(e=>{s(F(e)),R(null),G(null),U(null)},[s]),Ze=(0,B.useCallback)(()=>{s(N),R(null),G(null),U(null)},[s]),Qe=(0,B.useCallback)(async e=>{ce(e.id),U(null);try{let t=await f(m(`/api/channels/${encodeURIComponent(e.id)}/restart`),{method:`POST`});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}await Q()}catch(e){U(e instanceof Error?e.message:String(e))}finally{ce(null)}},[Q]);(0,B.useEffect)(()=>{G(null),ue(!1)},[O?.id]);let $e=(0,B.useCallback)(async()=>{if(!O||!L&&W===null)return!1;let e=Be(O);ne(!0),U(null);try{let t=await f(m(`/api/config`),{method:`PATCH`,body:JSON.stringify({...L?{channels:{[e]:L}}:{},...W===null?{}:{bindings:ve(E,O.id,W)}})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}return L&&await I(L,!1),await x(),await h.mutate(),R(null),G(null),!0}catch(e){return U(e instanceof Error?e.message:String(e)),!1}finally{ne(!1)}},[O,W,E,h,L,x,I]),et=(0,B.useCallback)(async e=>{let t=Y(e),n=Be(e),r=O?.id===e.id?L:null;if(!t.enabled&&!t.ready&&!r){Xe(e.id);return}ae(e.id),U(null);try{let i=t.enabled?{enabled:!1}:r?{...r,enabled:!0}:{enabled:!0},a=await f(m(`/api/config`),{method:`PATCH`,body:JSON.stringify({channels:{[n]:i}})});if(!a.ok){let e=await a.json().catch(()=>({}));throw Error(e.error?.message??a.statusText)}await h.mutate(),await x(),await v(),O?.id===e.id&&(await I(),R(null))}catch(e){U(e instanceof Error?e.message:String(e))}finally{ae(null)}},[O?.id,h,L,x,I,v,Xe]),$=O?.ui?.modal,it=$?.placement!==`replace-config`,at=O?Ke(O):`checking`,ct=O?!Y(O).ready||V:!1;return a?(0,H.jsxs)(se,{gap:`gap-4`,className:Ie,padding:Le,children:[h.isLoading?(0,H.jsx)(A,{sections:2}):h.error?(0,H.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:String(h.error)}):(0,H.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:g.map(e=>(0,H.jsx)(rt,{entry:e,config:C[Be(e)]?.config,runtime:Ke(e),busy:ie===e.id,restarting:oe===e.id,ch:q,onOpen:()=>Xe(e.id),onToggle:()=>void et(e),onRestart:()=>void Qe(e)},e.id))}),me?(0,H.jsx)(`p`,{className:`mt-4 text-sm text-red-600 dark:text-red-400`,children:me}):null,(0,H.jsx)(Se,{presentation:`modal`,open:!!O,onOpenChange:e=>{e||Ze()},closeAriaLabel:q.close,srTitle:O?.label??q.selectChannel,srDescription:O?.description,wide:!0,footer:O?(0,H.jsx)(Te,{ch:q,dirty:!!L||W!==null,saving:te,onCancel:Ze,onDiscard:()=>{R(null),G(null)},onSave:$e}):null,children:O?(0,H.jsxs)(`div`,{className:`space-y-4`,children:[(0,H.jsx)(`div`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,children:(0,H.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,H.jsx)(tt,{entry:O}),(0,H.jsxs)(`div`,{className:`min-w-0`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,H.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:O.label}),(0,H.jsx)(`span`,{className:l(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,Ue(at)),children:Ve(at,q)})]}),(0,H.jsxs)(`div`,{className:`mt-1 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-sm text-fg-muted`,children:[(0,H.jsx)(`span`,{className:`min-w-0 truncate`,children:!Y(O).ready&&pe(O)?.[1].result===`qr`?q.scanLoginHint.replace(`{{channel}}`,O.label):O.description}),O.docsPath?(0,H.jsxs)(`a`,{href:O.docsPath,target:`_blank`,rel:`noreferrer`,className:`inline-flex shrink-0 items-center gap-1 text-accent hover:underline`,children:[q.docs,(0,H.jsx)(o,{className:`size-3.5`})]}):null]})]})]}),(0,H.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pr-8`,children:[(0,H.jsx)(`span`,{className:`hidden text-xs text-fg-muted sm:inline`,children:Y(O).enabled?q.enabledLabel:q.disabledLabel}),(0,H.jsx)(nt,{checked:Y(O).enabled,disabled:ie===O.id,label:q.toggleChannel.replace(`{{channel}}`,O.label),onToggle:()=>void et(O)})]})]})}),(0,H.jsx)(ot,{runtime:at,restarting:oe===O.id,checking:y,showConnectionOptions:V,canManageConnection:Y(O).ready&&$?.placement!==`replace-config`,ch:q,onRestart:()=>void Qe(O),onCheck:()=>void Q(),onManageConnection:()=>ue(e=>!e)}),(0,H.jsx)(st,{entry:O,ch:q}),ct&&$?.placement!==`replace-config`?(0,H.jsx)(he,{entry:O,locale:n,messages:q,compact:!0,onChanged:async()=>{await I(),await Q(),await x()}},O.id):null,$?.entrypoint&&$.placement===`before-config`?(0,H.jsx)(P,{extensionId:O.extensionId,extensionName:O.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:O.id,entry:O,config:K}}):null,$?.entrypoint&&$.placement!==`before-config`?(0,H.jsx)(P,{extensionId:O.extensionId,extensionName:O.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:O.id,entry:O,config:K}}):null,it&&Ee?(0,H.jsxs)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:[(0,H.jsxs)(`div`,{className:`mb-4`,children:[(0,H.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:q.basicConfiguration}),(0,H.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:q.basicConfigurationHint})]}),(0,H.jsx)(le,{schema:xe,values:K,onChange:e=>R(e),disabled:te,labels:He})]}):null,(0,H.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,H.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,H.jsx)(z,{className:`size-4 text-fg-muted`}),q.messageHandling]}),(0,H.jsxs)(`div`,{className:`bg-surface-base/50 p-4`,children:[(0,H.jsxs)(`div`,{className:`mb-3`,children:[(0,H.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:q.agentRouting}),(0,H.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:q.messageHandlingHint})]}),(0,H.jsx)(re,{value:De,options:ke,placeholder:q.agentRoutingSelect,emptyLabel:q.agentRoutingDefault.replace(`{{agent}}`,ze||q.agentRoutingSelect),ariaLabel:q.agentRouting,disabled:te||!D,onChange:e=>G(e)})]})]}),it&&Je(Ce)?(0,H.jsx)(w,{title:q.advancedConfiguration,summary:q.messageHandlingHint,children:(0,H.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,H.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,H.jsx)(z,{className:`size-4 text-fg-muted`}),q.advancedConfiguration]}),(0,H.jsx)(`div`,{className:`bg-surface-base/50 p-4`,children:(0,H.jsx)(le,{schema:Ce,values:K,onChange:e=>R(e),disabled:te,labels:He})})]})}):null,me?(0,H.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:me}):null]}):null})]}):(0,H.jsx)(se,{gap:`gap-3`,className:Ie,padding:Le,children:(0,H.jsx)(`p`,{className:`text-sm text-fg-muted`,children:q.tokenRequired})})}export{ct as ChannelsSettingsPanel};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./chunk-KS7C4IRE-B2HK1psj.js";import{t as a}from"./check-DUBLcKHA.js";import{t as o}from"./plus-Q2yW6OE7.js";import{t as s}from"./messages-Bwv-AOYl.js";import{a as c,n as l,r as u}from"./locale-store-D5h-Ha6-.js";import{i as d}from"./vendor-swr-BIWyz7Rc.js";import{r as f}from"./gateway-config-swr-BvuySoCX.js";import{n as p,t as m}from"./registry-api-Bf0hVPNV.js";import{$i as h,$l as g,Fn as _,Fu as v,In as y,Iu as b,Kc as x,Rc as S,Td as C,Wl as w,as as T}from"./index-DdJ_djQt.js";import{n as E,r as ee}from"./settings-page-layout-Dx5S-Msc.js";var D=n(),O=e(t(),1),k=r();function te({zh:e}){let t=s(e?`zh`:`en`).computerSettings,n=d(`settings-agent-defaults`,_),r=d(m,p),a=n.data?.defaults.models.computerUse?.primary??``,[o,c]=(0,O.useState)(a),[l,u]=(0,O.useState)(!1),[f,g]=(0,O.useState)(``),[v,b]=(0,O.useState)(!1);(0,O.useEffect)(()=>{c(a)},[a]);let C=!o||r.data?.some(e=>e.id===o&&e.computerUse),w=async()=>{u(!0),g(``),b(!1);try{if(!C)throw Error(t.modelUnavailable);let e=await _(),r={...e.defaults.models};o?r.computerUse={primary:o,fallbacks:[]}:delete r.computerUse;let i=await y({...e.defaults,models:r});await n.mutate(i,!1),b(!0)}catch(e){g(e instanceof Error?e.message:String(e))}finally{u(!1)}};return(0,k.jsxs)(`section`,{"aria-label":t.model,className:`space-y-3`,children:[(0,k.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.model}),!n.data&&!n.error?(0,k.jsx)(S,{className:`h-52 w-full rounded-xl`}):n.error?(0,k.jsxs)(`div`,{role:`alert`,className:`text-sm text-danger`,children:[String(n.error),(0,k.jsx)(x,{onClick:()=>{n.mutate().catch(()=>{})},children:t.retry})]}):(0,k.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-panel p-4 sm:p-5`,children:[(0,k.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center`,children:[(0,k.jsx)(`div`,{className:`min-w-0 flex-1`,children:r.isLoading?(0,k.jsx)(S,{className:`h-11 w-full rounded-lg`}):(0,k.jsx)(h,{value:o,onChange:e=>{c(e),b(!1)},disabled:l,capabilitiesFilter:`computer-use`,models:r.data??[],modelsError:r.error,placeholder:t.selectModel,searchPlaceholder:t.searchModel,noMatches:t.noModels,registryEmptyHint:t.noModels,allowEmpty:!0,emptyLabel:t.noModel,ariaLabel:t.modelLabel,className:`w-full`,contentAlign:`start`})}),(0,k.jsx)(x,{variant:`primary`,disabled:l||o===a||!C||!!r.error||r.isLoading,onClick:()=>{w()},children:t.saveModel})]}),(0,k.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-4 gap-y-2 text-xs text-fg-muted`,children:[(0,k.jsx)(`span`,{children:t.modelDataUse}),(0,k.jsx)(x,{asChild:!0,variant:`ghost`,className:`h-auto p-0 text-xs`,children:(0,k.jsx)(i,{to:`/settings/capabilities/models?add=1`,children:t.manageModels})}),v&&(0,k.jsx)(`span`,{role:`status`,children:t.modelSaved})]}),!C&&!r.isLoading&&!r.error&&(0,k.jsx)(`p`,{role:`status`,className:`mt-3 text-sm text-warning`,children:t.modelUnavailable}),r.error&&(0,k.jsxs)(`p`,{role:`alert`,className:`mt-3 text-sm text-danger`,children:[String(r.error),(0,k.jsx)(x,{onClick:()=>{r.mutate().catch(()=>{})},children:t.retry})]}),f&&(0,k.jsx)(`p`,{role:`alert`,className:`mt-3 text-sm text-danger`,children:f})]})]})}function A(e){let t=(0,D.c)(15),{icon:n,title:r,description:i,children:a}=e,o;t[0]===n?o=t[1]:(o=n&&(0,k.jsx)(`div`,{className:`flex size-6 shrink-0 items-center justify-center text-fg-muted`,"aria-hidden":!0,children:n}),t[0]=n,t[1]=o);let s;t[2]===r?s=t[3]:(s=(0,k.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:r}),t[2]=r,t[3]=s);let c;t[4]===i?c=t[5]:(c=i&&(0,k.jsx)(`div`,{className:`mt-0.5 text-xs text-fg-muted`,children:i}),t[4]=i,t[5]=c);let l;t[6]!==s||t[7]!==c?(l=(0,k.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;t[9]===a?u=t[10]:(u=a&&(0,k.jsx)(`div`,{className:`flex shrink-0 items-center gap-3`,children:a}),t[9]=a,t[10]=u);let d;return t[11]!==o||t[12]!==l||t[13]!==u?(d=(0,k.jsxs)(`div`,{className:`flex min-h-16 flex-wrap items-center gap-3 px-4 py-3 sm:flex-nowrap sm:px-5`,children:[o,l,u]}),t[11]=o,t[12]=l,t[13]=u,t[14]=d):d=t[14],d}function j(){let e=(0,D.c)(2),t=l(M)===`zh`,n;return e[0]===t?n=e[1]:(n=(0,k.jsx)(N,{zh:t}),e[0]=t,e[1]=n),n}function M(e){return e.language}function N({zh:e}){let t=s(e?`zh`:`en`).computerSettings,{data:n,mutate:r,error:l}=f(!0),d=n?.payload?.config,[p,m]=(0,O.useState)(!1),[h,_]=(0,O.useState)(``),[y,D]=(0,O.useState)(!1),[j,M]=(0,O.useState)(null),[N,P]=(0,O.useState)(!1),[F,I]=(0,O.useState)(null),[ne,L]=(0,O.useState)(!1),[R,z]=(0,O.useState)(``),[B,V]=(0,O.useState)(!1),[re,H]=(0,O.useState)(!1),U=window.electronAPI?.platform===`darwin`?window.electronAPI.computer:void 0,W=window.electronAPI?.platform===`darwin`?window.electronAPI.system:void 0;(0,O.useEffect)(()=>{if(!U)return;let e=!1,t=!1,n=async()=>{if(!t){t=!0;try{let t=await U.status();e||(M(t),P(!1))}catch{e||(M(null),P(!0))}finally{t=!1}}};n();let r=window.setInterval(()=>{n()},2e3);return()=>{e=!0,window.clearInterval(r)}},[U]),(0,O.useEffect)(()=>{if(!U?.access)return;let e=!1;return U.access().then(t=>{e||(I(t),L(!1))}).catch(()=>{e||L(!0)}),()=>{e=!0}},[U]);let G=async e=>{m(!0),_(``);try{await e()}catch(e){_(e instanceof Error?e.message:String(e))}finally{m(!1)}},ie=e=>G(async()=>{T()&&(await c(u(`/api/config`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({computer:{enabled:e}})}),await r())}),ae=async()=>{_(``),D(!1);try{await U?.stop(),D(!0),U&&M(await U.status())}catch(e){_(e instanceof Error?e.message:String(e))}},K=j?.session?.status??`idle`,q=t.states[K]??K,J=T()&&d?.computer?.enabled===!0,oe=j?.controlPaused?t.pausedNotice:J?j?.connected?`${t.connected} · ${q}`:j?t.disconnected:t.checking:t.disabled,Y=!U||N||j?.reenrollmentRequired===!0||!!(j?.error||j?.session?.errorCode)||j!=null&&(!j.permissions.accessibility||j.permissions.screenRecording!==`granted`),X=j?.permissions.accessibility===!0&&j.permissions.screenRecording===`granted`&&!j.reenrollmentRequired,Z=F?.apps.filter(e=>F.authorizedAppIds.includes(e.appId))??[],Q=F?.apps.filter(e=>!F.authorizedAppIds.includes(e.appId)&&`${e.name} ${e.appId}`.toLocaleLowerCase().includes(R.toLocaleLowerCase()))??[],$=(0,k.jsxs)(`section`,{"aria-labelledby":`computer-permissions-title`,className:`space-y-3`,children:[(0,k.jsx)(`h2`,{id:`computer-permissions-title`,className:`text-sm font-semibold text-fg`,children:t.permissions}),U?N?(0,k.jsx)(`p`,{role:`alert`,className:`rounded-xl bg-danger-soft p-5 text-sm text-danger`,children:t.nativeError}):j?X&&!re?(0,k.jsx)(`div`,{className:`overflow-hidden rounded-2xl border border-edge bg-surface-panel`,children:(0,k.jsx)(A,{icon:(0,k.jsx)(g,{className:`size-5`}),title:t.systemPermissions,description:t.granted,children:(0,k.jsx)(x,{onClick:()=>H(!0),children:t.viewDetails})})}):(0,k.jsxs)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-2xl border border-edge bg-surface-panel`,children:[(0,k.jsx)(A,{icon:(0,k.jsx)(b,{className:`size-5`}),title:t.device,description:(0,k.jsxs)(`span`,{"aria-live":`polite`,children:[j.connected?t.connected:t.disconnected,` · `,q]}),children:j.reenrollmentRequired&&(0,k.jsx)(x,{disabled:p,onClick:()=>{G(async()=>{M(await U.reenroll())})},children:t.reenroll})}),W&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(A,{icon:(0,k.jsx)(g,{className:`size-5`}),title:t.accessibility,children:[(0,k.jsx)(`span`,{className:`text-xs text-fg-muted`,children:j.permissions.accessibility?t.granted:t.notGranted}),!j.permissions.accessibility&&(0,k.jsx)(x,{disabled:p,"aria-label":`${t.openSettings}: ${t.accessibility}`,onClick:()=>{G(()=>W.requestAccessibility())},children:t.openSettings})]}),(0,k.jsxs)(A,{icon:(0,k.jsx)(b,{className:`size-5`}),title:t.screen,children:[(0,k.jsx)(`span`,{className:`text-xs text-fg-muted`,children:j.permissions.screenRecording===`granted`?t.granted:t.notGranted}),j.permissions.screenRecording!==`granted`&&(0,k.jsx)(x,{disabled:p,"aria-label":`${t.openSettings}: ${t.screen}`,onClick:()=>{G(()=>W.requestScreen())},children:t.openSettings})]})]}),X&&(0,k.jsx)(`div`,{className:`flex justify-end px-4 py-2 sm:px-5`,children:(0,k.jsx)(x,{variant:`ghost`,onClick:()=>H(!1),children:t.hideDetails})})]}):(0,k.jsx)(`div`,{"aria-label":t.checking,children:(0,k.jsx)(S,{className:`h-20 w-full rounded-xl`})}):(0,k.jsx)(`p`,{className:`rounded-xl bg-surface-hover/20 p-5 text-sm leading-relaxed text-fg-muted`,children:window.electronAPI&&window.electronAPI.platform!==`darwin`?t.unsupportedPlatform:t.desktopRequired}),(j?.error||j?.session?.errorCode)&&(0,k.jsx)(`p`,{role:`alert`,className:`break-words text-sm text-red-600`,children:j.error||j.session?.errorCode})]});return(0,k.jsxs)(ee,{gap:`gap-7`,children:[(0,k.jsx)(E,{title:t.title,subtitle:t.subtitle,meta:(0,k.jsx)(`span`,{className:`mt-3 inline-flex rounded-md border border-edge px-2 py-1 text-xs text-fg-muted`,children:t.preview}),actions:U&&(0,k.jsxs)(x,{onClick:()=>{ae()},children:[(0,k.jsx)(w,{className:`size-3.5`}),t.stop]})}),h&&(0,k.jsx)(`p`,{role:`alert`,className:`text-sm text-red-600`,children:h}),y&&(0,k.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:t.stoppedNotice}),(0,k.jsxs)(`section`,{"aria-labelledby":`computer-control-title`,className:`space-y-3`,children:[(0,k.jsx)(`h2`,{id:`computer-control-title`,className:`text-sm font-semibold text-fg`,children:t.control}),!d&&!l?(0,k.jsx)(S,{className:`h-32 w-full rounded-xl`}):l?(0,k.jsxs)(`div`,{role:`alert`,className:`text-sm text-fg-muted`,children:[String(l),` `,(0,k.jsx)(x,{onClick:()=>{G(()=>r())},children:t.retry})]}):(0,k.jsxs)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-2xl border border-edge bg-surface-panel`,children:[(0,k.jsx)(A,{icon:(0,k.jsx)(v,{className:`size-5`}),title:t.desktop,description:(0,k.jsx)(`span`,{"aria-live":`polite`,children:oe}),children:(0,k.jsx)(`button`,{type:`button`,role:`switch`,"aria-label":t.desktop,"aria-checked":J,disabled:p||!T(),onClick:()=>{ie(d?.computer?.enabled!==!0)},className:`touch-target flex items-center rounded-lg px-1 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,children:(0,k.jsx)(`span`,{className:`flex h-6 w-11 items-center rounded-full p-0.5 transition-colors ${J?`bg-accent`:`bg-fg-muted/30`}`,children:(0,k.jsx)(`span`,{className:`size-5 rounded-full bg-white transition-transform ${J?`translate-x-5`:`translate-x-0`}`})})})}),j?.controlPaused&&(0,k.jsx)(`div`,{className:`flex justify-end border-t border-edge-subtle px-4 py-3 sm:px-5`,children:(0,k.jsx)(x,{disabled:p,onClick:()=>{G(async()=>{U&&M(await U.resume()),D(!1)})},children:t.resume})})]})]}),Y&&$,U?.access&&(0,k.jsxs)(`section`,{"aria-labelledby":`computer-app-access-title`,className:`space-y-3`,children:[(0,k.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,k.jsx)(`h2`,{id:`computer-app-access-title`,className:`text-sm font-semibold text-fg`,children:t.appAccess}),!F?.allowAllApps&&(0,k.jsxs)(x,{disabled:p,"aria-expanded":B,"aria-controls":B?`computer-app-picker`:void 0,onClick:()=>{V(e=>!e),z(``)},children:[B?(0,k.jsx)(a,{className:`size-4`,"aria-hidden":!0}):(0,k.jsx)(o,{className:`size-4`,"aria-hidden":!0}),B?t.doneAdding:t.addApp]})]}),F?(0,k.jsxs)(`div`,{className:`overflow-hidden rounded-2xl border border-edge bg-surface-panel`,children:[(0,k.jsx)(A,{icon:(0,k.jsx)(v,{className:`size-5`}),title:t.anyApp,description:t.anyAppDescription,children:(0,k.jsx)(`button`,{type:`button`,role:`switch`,"aria-label":t.anyApp,"aria-checked":F.allowAllApps===!0,disabled:p,onClick:()=>{G(async()=>{I(await U.setAllAppAccess(!F.allowAllApps)),V(!1)})},className:`touch-target flex items-center rounded-lg px-1 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,children:(0,k.jsx)(`span`,{className:`flex h-6 w-11 items-center rounded-full p-0.5 transition-colors ${F.allowAllApps?`bg-accent`:`bg-fg-muted/30`}`,children:(0,k.jsx)(`span`,{className:`size-5 rounded-full bg-white transition-transform ${F.allowAllApps?`translate-x-5`:`translate-x-0`}`})})})}),!F.allowAllApps&&(0,k.jsx)(`div`,{className:`border-t border-edge-subtle`,children:Z.length?Z.map(e=>(0,k.jsxs)(`div`,{className:`flex min-h-16 items-center justify-between gap-3 border-b border-edge-subtle px-4 py-3 last:border-b-0 sm:px-5`,children:[(0,k.jsxs)(`div`,{className:`min-w-0`,children:[(0,k.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:e.name}),(0,k.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:e.appId})]}),(0,k.jsx)(x,{disabled:p,variant:`ghost`,onClick:()=>{G(async()=>{let t=await U.setAppAccess(e.appId,!1);I(e=>e&&{...e,authorizedAppIds:t.authorizedAppIds})})},children:t.revokeApp})]},e.appId)):(0,k.jsx)(`p`,{className:`px-5 py-6 text-center text-sm text-fg-muted`,children:t.noAuthorizedApps})})]}):ne?(0,k.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:t.appListError}):(0,k.jsx)(S,{className:`h-20 w-full rounded-xl`}),B&&!F?.allowAllApps&&(0,k.jsxs)(`div`,{id:`computer-app-picker`,className:`space-y-3 rounded-2xl border border-edge bg-surface-panel p-4`,children:[(0,k.jsxs)(`div`,{className:`flex gap-2`,children:[(0,k.jsx)(`input`,{"aria-label":t.searchApps,value:R,onChange:e=>z(e.target.value),placeholder:t.searchApps,className:`min-w-0 flex-1 rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`}),(0,k.jsx)(x,{disabled:p,onClick:()=>{G(async()=>{I(await U.access()),L(!1)})},children:t.refreshApps})]}),F&&(0,k.jsx)(`div`,{className:`max-h-64 overflow-y-auto rounded-xl border border-edge`,children:Q.length?Q.map(e=>(0,k.jsxs)(`div`,{className:`flex min-h-14 items-center justify-between gap-3 border-b border-edge-subtle px-3 py-2 last:border-b-0`,children:[(0,k.jsxs)(`div`,{className:`min-w-0`,children:[(0,k.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:e.name}),(0,k.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:e.appId})]}),(0,k.jsx)(x,{disabled:p,variant:`secondary`,onClick:()=>{G(async()=>{let t=await U.setAppAccess(e.appId,!0);I(e=>e&&{...e,authorizedAppIds:t.authorizedAppIds})})},children:t.authorizeApp})]},e.appId)):(0,k.jsx)(`p`,{className:`px-3 py-5 text-center text-sm text-fg-muted`,children:F.appsBusy?t.appsBusy:F.appsUnavailable?t.appListError:t.noMatchingApps})})]})]}),(0,k.jsx)(te,{zh:e}),!Y&&$,(0,k.jsxs)(`section`,{"aria-labelledby":`computer-browser-title`,className:`space-y-3`,children:[(0,k.jsx)(`h2`,{id:`computer-browser-title`,className:`text-sm font-semibold text-fg`,children:t.otherControl}),(0,k.jsx)(`div`,{className:`overflow-hidden rounded-2xl border border-edge bg-surface-panel`,children:(0,k.jsx)(A,{icon:(0,k.jsx)(C,{className:`size-5`}),title:t.browser,description:d?d.browser?.enabled?t.browserEnabled:t.browserDisabled:t.checking,children:(0,k.jsx)(x,{asChild:!0,children:(0,k.jsx)(i,{to:`/settings/agent-browser`,children:t.manage})})})})]}),(0,k.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.previewFootnote})]})}export{j as ComputerSettingsPage,N as ComputerSettingsPanel};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{f as i,g as a}from"./chunk-KS7C4IRE-B2HK1psj.js";import{t as o}from"./circle-check-C23XjkUj.js";import{t as s}from"./ellipsis-0k4rZLoy.js";import{t as c}from"./external-link-DjqjBmc3.js";import{t as l}from"./eye-CABVeTq0.js";import{t as u}from"./plus-Q2yW6OE7.js";import{t as d}from"./x-B_N4OPjy.js";import{t as f}from"./messages-Bwv-AOYl.js";import{t as p}from"./cn-0WouolD0.js";import{a as m,c as h,n as g,r as _}from"./locale-store-D5h-Ha6-.js";import{a as v,i as y,n as b,o as x,r as S,s as C,t as w}from"./dist-BGTk37IG.js";import{n as T}from"./copy-to-clipboard-HOJ79TWv.js";import{n as E,r as D}from"./gateway-config-swr-BvuySoCX.js";import{$ as O,Ac as k,Ao as A,Bl as j,Dc as M,Ec as N,Go as P,Hd as F,Ic as ee,J as I,Jn as L,Ju as R,Kc as z,Mc as B,Nc as V,Nl as H,Oc as U,Pc as te,Q as W,Qd as G,Rc as K,Rs as q,Sc as J,Sl as ne,Tc as re,X as ie,Xn as ae,Y as oe,Yn as Y,Z as se,Za as ce,Zn as le,_c as ue,ac as de,ar as X,cc as fe,dc as pe,dd as me,df as Z,ds as he,du as ge,ef as _e,er as ve,et as ye,fs as be,gc as xe,hc as Se,ic as Ce,is as we,jc as Te,ju as Ee,kc as De,lc as Oe,mc as ke,nc as Ae,nr as je,oc as Me,os as Ne,pc as Pe,pf as Fe,rc as Ie,rr as Le,ru as Re,sc as ze,su as Be,tr as Ve,tu as He,uc as Ue,uf as We,us as Ge,vc as Ke,vu as qe,wc as Je,xc as Ye,yc as Xe,zd as Ze,zo as Qe}from"./index-DdJ_djQt.js";import{t as $e}from"./capability-links-DzQWK1Fh.js";import{n as et,t as tt}from"./capability-header-actions-wTmkMFS8.js";import{t as nt}from"./connector-service-page-DavOiSs1.js";import{t as rt}from"./capability-icon-DVoZxEgW.js";import{t as it}from"./number-input-DDeqHK-G.js";var Q=e(t(),1),at=n(),$=r();function ot(e){let t=(0,at.c)(57),{connector:n,installed:r,onInstall:i,onOpenDetails:a,t:s}=e,c,l,u,d,f,m;if(t[0]!==n||t[1]!==r||t[2]!==i||t[3]!==a||t[4]!==s){let e=n.capabilities.filter(st),h=e.slice(0,2),g=Math.max(0,e.length-h.length),_=s.connect,v;t[11]!==n||t[12]!==s?(v=se(n,s),t[11]=n,t[12]=s,t[13]=v):v=t[13];let y=v,b=n.verificationLevel===`verified`?s.connectorVerified:n.verificationLevel===`beta`?s.connectorBeta:n.verificationLevel===`experimental`?s.connectorExperimental:null,x;t[14]!==_||t[15]!==n||t[16]!==i?(x=e=>(0,$.jsxs)(z,{type:`button`,variant:`secondary`,className:p(`h-8 justify-center px-2.5 text-xs font-medium`,e),onClick:()=>i(n),children:[(0,$.jsx)(Ee,{className:`size-4`}),_]}),t[14]=_,t[15]=n,t[16]=i,t[17]=x):x=t[17],c=x,m=`group flex min-h-[8.75rem] flex-col rounded-xl border border-edge bg-surface-panel p-4 transition-colors hover:bg-surface-hover/45 focus-within:ring-2 focus-within:ring-accent/30`,l=`flex min-w-0 flex-1 flex-col`;let S;t[18]===n?S=t[19]:(S=(0,$.jsx)(ye,{connector:n}),t[18]=n,t[19]=S);let C;t[20]!==n||t[21]!==a?(C=a?(0,$.jsx)(`button`,{type:`button`,className:`block max-w-full truncate text-left text-sm font-semibold text-fg hover:underline`,onClick:()=>a(n),children:n.displayName}):(0,$.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:n.displayName}),t[20]=n,t[21]=a,t[22]=C):C=t[22];let w;t[23]===b?w=t[24]:(w=b?(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:b}):null,t[23]=b,t[24]=w);let T;t[25]!==w||t[26]!==C?(T=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[C,w]}),t[25]=w,t[26]=C,t[27]=T):T=t[27];let E;t[28]!==T||t[29]!==S?(E=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[S,T]}),t[28]=T,t[29]=S,t[30]=E):E=t[30];let D;t[31]!==r||t[32]!==c?(D=r?null:(0,$.jsx)(`div`,{className:`hidden shrink-0 items-center gap-1 sm:flex`,children:c()}),t[31]=r,t[32]=c,t[33]=D):D=t[33];let O;t[34]!==r||t[35]!==s.connectedBadge?(O=r?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-emerald-500/30 bg-emerald-500/10 px-2 py-0.5 text-[11px] font-medium text-emerald-700 dark:text-emerald-300`,children:[(0,$.jsx)(o,{className:`size-3`,"aria-hidden":!0}),s.connectedBadge]}):null,t[34]=r,t[35]=s.connectedBadge,t[36]=O):O=t[36];let k;t[37]!==D||t[38]!==O?(k=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start gap-2`,children:[D,O]}),t[37]=D,t[38]=O,t[39]=k):k=t[39],t[40]!==E||t[41]!==k?(u=(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[E,k]}),t[40]=E,t[41]=k,t[42]=u):u=t[42],t[43]===y?d=t[44]:(d=(0,$.jsx)(`p`,{className:`mt-3 line-clamp-2 text-sm leading-6 text-fg-muted`,title:y,children:y}),t[43]=y,t[44]=d),f=h.length>0?(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:[h.map(e=>(0,$.jsx)(`span`,{className:`rounded-md bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:s.connectorCapabilityLabels[e]??e},e)),g>0?(0,$.jsxs)(`span`,{className:`rounded-md bg-surface-base px-2 py-0.5 text-[11px] text-fg-subtle`,children:[`+`,g]}):null]}):null,t[0]=n,t[1]=r,t[2]=i,t[3]=a,t[4]=s,t[5]=c,t[6]=l,t[7]=u,t[8]=d,t[9]=f,t[10]=m}else c=t[5],l=t[6],u=t[7],d=t[8],f=t[9],m=t[10];let h;t[45]!==l||t[46]!==u||t[47]!==d||t[48]!==f?(h=(0,$.jsxs)(`div`,{className:l,children:[u,d,f]}),t[45]=l,t[46]=u,t[47]=d,t[48]=f,t[49]=h):h=t[49];let g;t[50]!==r||t[51]!==c?(g=r?null:(0,$.jsx)(`div`,{className:`mt-4 flex flex-col gap-2 border-t border-edge pt-3 sm:hidden`,children:c(`w-full`)}),t[50]=r,t[51]=c,t[52]=g):g=t[52];let _;return t[53]!==m||t[54]!==h||t[55]!==g?(_=(0,$.jsxs)(`div`,{className:m,children:[h,g]}),t[53]=m,t[54]=h,t[55]=g,t[56]=_):_=t[56],_}function st(e){return!e.startsWith(`runtime.`)&&!e.startsWith(`auth.`)}var ct=[`c0`,`c1`,`c2`,`c3`,`c4`,`c5`];function lt(e,t){return t.some(t=>t.connectorId===e.id)}var ut=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`;function dt(){let e=(0,at.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`div`,{className:p(`size-10 shrink-0 rounded-xl`,ut)}),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:p(`h-4 min-w-0 flex-1`,ut)}),(0,$.jsx)(`div`,{className:p(`h-8 w-[4.5rem] shrink-0 rounded-lg`,ut)})]}),(0,$.jsx)(`div`,{className:p(`h-3 w-full`,ut)}),(0,$.jsx)(`div`,{className:p(`h-3 w-[88%]`,ut)})]})]})}),e[1]=n):n=e[1],n}var ft=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`;function pt(){let e=(0,at.c)(4),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`div`,{className:p(`size-10 shrink-0 rounded-xl`,ft)}),e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2`,children:[(0,$.jsx)(`div`,{className:p(`h-4 w-48 max-w-full`,ft)}),(0,$.jsx)(`div`,{className:p(`h-3 w-72 max-w-full`,ft)})]}),e[1]=n):n=e[1];let r;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[t,(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-start justify-between gap-3`,children:[n,(0,$.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,$.jsx)(`div`,{className:p(`h-9 w-20 rounded-lg`,ft)}),(0,$.jsx)(`div`,{className:p(`h-9 w-20 rounded-lg`,ft)})]})]})]}),e[2]=r):r=e[2];let i;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsxs)(`div`,{className:`rounded-2xl bg-surface-panel p-4 shadow-surface`,"aria-hidden":!0,children:[r,(0,$.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,$.jsx)(`div`,{className:p(`h-8 w-20 rounded-md`,ft)}),(0,$.jsx)(`div`,{className:p(`h-8 w-24 rounded-md`,ft)}),(0,$.jsx)(`div`,{className:p(`h-8 w-28 rounded-md`,ft)})]}),(0,$.jsx)(`div`,{className:p(`mt-3 h-20 rounded-xl`,ft)})]}),e[3]=i):i=e[3],i}var mt=[`understand`,`act`,`reach`];function ht(e){if(e.benefits?.length)return[...new Set(e.benefits)];let t=new Set(e.capabilities),n=[e.id,e.displayName,...e.tags??[]].join(` `).toLowerCase(),r=[];return(t.has(`context`)||t.has(`memory_source`)||t.has(`resources`)||e.category===`docs`||e.category===`data`||/notion|drive|document|confluence|airtable|database|knowledge|wiki/.test(n))&&r.push(`understand`),t.has(`tools`)&&r.push(`act`),(t.has(`channel`)||/slack|telegram|discord|teams|mail|message|wechat|weixin/.test(n))&&r.push(`reach`),r.length?[...new Set(r)]:[`act`]}function gt(e){return ht(e)[0]??`act`}function _t(e,t){let n=t?gt(t):`act`,r=e.connectionStatus===`connected`||e.status===`connected`||e.usage.lastHealthStatus===`ok`,i=e.status===`not_configured`||e.status===`failed`||e.status===`degraded`||e.status===`unauthorized`||e.connectionStatus===`unauthorized`||e.connectionStatus===`error`,a=n===`understand`?e.usage.lastResourceCount:n===`act`?e.usage.lastToolCount:void 0;return{benefit:n,state:r?`ready`:i?`needs_setup`:`checking`,availableCount:a}}function vt(e,t){return t.connectorCapabilityLabels[e]??e}function yt(e,t){if(e.runtime.type===`mcp`)return W(t.connectorRuntimeMcp,{serverId:e.runtime.serverId});let n=e.runtime.type===`composio`?e.runtime.toolkit:e.runtime.type===`cli`?e.runtime.adapterId:e.runtime.sourceKind;return W(t.connectorRuntimeGeneric,{runtime:e.runtime.type,id:n??e.runtime.type})}function bt(e,t){return e.auth.mode===`cli`?t.connectorAuthCli:e.auth.mode===`oauth`?t.connectorAuthOAuth:e.auth.mode===`apiKey`?t.connectorAuthApiKey:t.connectorAuthNone}function xt(e){let t=(0,at.c)(133),{connector:n,installed:r,onClose:i,onInstall:a,t:s}=e,c;t[0]!==n||t[1]!==s?(c=se(n,s),t[0]=n,t[1]=s,t[2]=c):c=t[2];let l=c,u,f,m,h,g,_,T,E,D,O,k,A,j,M,N,P;if(t[3]!==n||t[4]!==l||t[5]!==r||t[6]!==i||t[7]!==s){let e=ht(n),a;t[24]!==n.setup.config||t[25]!==n.setup.secrets?(a=[...(n.setup.secrets??[]).filter(wt),...(n.setup.config??[]).filter(Ct)],t[24]=n.setup.config,t[25]=n.setup.secrets,t[26]=a):a=t[26];let c=a,F=n.capabilities.filter(St);m=w,T=!0,t[27]===i?E=t[28]:(E=e=>{e||i()},t[27]=i,t[28]=E),f=x,t[29]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(v,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),t[29]=_):_=t[29],u=S,t[30]===Symbol.for(`react.memo_cache_sentinel`)?(h=p(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(100vh-2rem,42rem)] w-[min(100%-2rem,min(92vw,44rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-overlay shadow-float outline-none dark:border-edge`),t[30]=h):h=t[30];let I;t[31]===n?I=t[32]:(I=(0,$.jsx)(ye,{connector:n,size:`lg`}),t[31]=n,t[32]=I);let L;t[33]===n.displayName?L=t[34]:(L=(0,$.jsx)(C,{className:`text-base font-semibold text-fg`,children:n.displayName}),t[33]=n.displayName,t[34]=L);let R;t[35]!==r||t[36]!==s.connectedBadge?(R=r?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-emerald-500/10 px-2 py-0.5 text-[11px] font-medium text-emerald-700 dark:text-emerald-300`,children:[(0,$.jsx)(o,{className:`size-3`,"aria-hidden":!0}),s.connectedBadge]}):null,t[35]=r,t[36]=s.connectedBadge,t[37]=R):R=t[37];let z;t[38]!==L||t[39]!==R?(z=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[L,R]}),t[38]=L,t[39]=R,t[40]=z):z=t[40];let B;t[41]===l?B=t[42]:(B=(0,$.jsx)(y,{className:`mt-1 line-clamp-3 text-sm leading-6 text-fg-muted`,children:l}),t[41]=l,t[42]=B);let V;t[43]!==z||t[44]!==B?(V=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[z,B]}),t[43]=z,t[44]=B,t[45]=V):V=t[45];let H;t[46]!==I||t[47]!==V?(H=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[I,V]}),t[46]=I,t[47]=V,t[48]=H):H=t[48];let U;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(U=p(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,ee.focusRingPanel),t[49]=U):U=t[49];let te;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(te=(0,$.jsx)(d,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),t[50]=te):te=t[50];let G;t[51]===s.modalClose?G=t[52]:(G=(0,$.jsx)(b,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:U,"aria-label":s.modalClose,children:te})}),t[51]=s.modalClose,t[52]=G),t[53]!==H||t[54]!==G?(g=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-5 py-5 sm:px-6`,children:[H,G]}),t[53]=H,t[54]=G,t[55]=g):g=t[55],M=`min-h-0 flex-1 space-y-5 overflow-y-auto px-5 py-5 sm:px-6`,N=e.length?(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:s.connectorWhyConnect}),(0,$.jsx)(`div`,{className:`mt-3 divide-y divide-edge-subtle overflow-hidden rounded-xl border border-edge bg-surface-base`,children:e.map(e=>(0,$.jsxs)(`div`,{className:`px-4 py-3`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:s.connectorBenefitHeadings[e]}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:s.connectorBenefitHints[e]})]},e))})]}):null;let K;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(K=(0,$.jsx)(me,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),t[56]=K):K=t[56];let q;t[57]===s.detailPermissions?q=t[58]:(q=(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:s.detailPermissions}),t[57]=s.detailPermissions,t[58]=q);let J;t[59]!==n||t[60]!==s?(J=bt(n,s),t[59]=n,t[60]=s,t[61]=J):J=t[61];let ne;t[62]===J?ne=t[63]:(ne=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:J}),t[62]=J,t[63]=ne);let re;t[64]!==q||t[65]!==ne?(re=(0,$.jsxs)(`div`,{className:`flex items-start gap-3 border-b border-edge-subtle px-4 py-3`,children:[K,(0,$.jsxs)(`div`,{children:[q,ne]})]}),t[64]=q,t[65]=ne,t[66]=re):re=t[66];let ie;t[67]===s.connectorSetupTitle?ie=t[68]:(ie=(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:s.connectorSetupTitle}),t[67]=s.connectorSetupTitle,t[68]=ie);let ae;t[69]!==c.length||t[70]!==s.connectorRequiredInputsCount||t[71]!==s.connectorSetupNone?(ae=c.length?W(s.connectorRequiredInputsCount,{count:String(c.length)}):s.connectorSetupNone,t[69]=c.length,t[70]=s.connectorRequiredInputsCount,t[71]=s.connectorSetupNone,t[72]=ae):ae=t[72];let oe;t[73]===ae?oe=t[74]:(oe=(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:ae}),t[73]=ae,t[74]=oe);let Y;t[75]!==ie||t[76]!==oe?(Y=(0,$.jsxs)(`div`,{className:`px-4 py-3`,children:[ie,oe]}),t[75]=ie,t[76]=oe,t[77]=Y):Y=t[77],t[78]!==re||t[79]!==Y?(P=(0,$.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-base`,children:[re,Y]}),t[78]=re,t[79]=Y,t[80]=P):P=t[80],A=`rounded-xl border border-edge bg-surface-base`,t[81]===s.connectorTechnicalDetails?j=t[82]:(j=(0,$.jsx)(`summary`,{className:`cursor-pointer px-4 py-3 text-sm font-medium text-fg-muted hover:text-fg`,children:s.connectorTechnicalDetails}),t[81]=s.connectorTechnicalDetails,t[82]=j),D=`space-y-5 border-t border-edge-subtle px-4 py-4`;let se;t[83]===Symbol.for(`react.memo_cache_sentinel`)?(se=(0,$.jsx)(Re,{className:`size-3.5`,"aria-hidden":!0}),t[83]=se):se=t[83];let ce;t[84]===s.connectorRuntimeTitle?ce=t[85]:(ce=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[se,s.connectorRuntimeTitle]}),t[84]=s.connectorRuntimeTitle,t[85]=ce);let le;t[86]!==n||t[87]!==s?(le=yt(n,s),t[86]=n,t[87]=s,t[88]=le):le=t[88];let ue;t[89]===le?ue=t[90]:(ue=(0,$.jsx)(`p`,{className:`mt-1 break-words text-xs text-fg-subtle`,children:le}),t[89]=le,t[90]=ue),t[91]!==ce||t[92]!==ue?(O=(0,$.jsxs)(`div`,{children:[ce,ue]}),t[91]=ce,t[92]=ue,t[93]=O):O=t[93],k=F.length?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:F.map(e=>(0,$.jsx)(`span`,{className:`rounded-md bg-surface-panel px-2 py-1 text-xs text-fg-muted`,children:vt(e,s)},e))}):null,t[3]=n,t[4]=l,t[5]=r,t[6]=i,t[7]=s,t[8]=u,t[9]=f,t[10]=m,t[11]=h,t[12]=g,t[13]=_,t[14]=T,t[15]=E,t[16]=D,t[17]=O,t[18]=k,t[19]=A,t[20]=j,t[21]=M,t[22]=N,t[23]=P}else u=t[8],f=t[9],m=t[10],h=t[11],g=t[12],_=t[13],T=t[14],E=t[15],D=t[16],O=t[17],k=t[18],A=t[19],j=t[20],M=t[21],N=t[22],P=t[23];let F;t[94]!==D||t[95]!==O||t[96]!==k?(F=(0,$.jsxs)(`div`,{className:D,children:[O,k]}),t[94]=D,t[95]=O,t[96]=k,t[97]=F):F=t[97];let I;t[98]!==F||t[99]!==A||t[100]!==j?(I=(0,$.jsxs)(`details`,{className:A,children:[j,F]}),t[98]=F,t[99]=A,t[100]=j,t[101]=I):I=t[101];let L;t[102]!==I||t[103]!==M||t[104]!==N||t[105]!==P?(L=(0,$.jsxs)(`div`,{className:M,children:[N,P,I]}),t[102]=I,t[103]=M,t[104]=N,t[105]=P,t[106]=L):L=t[106];let R;t[107]===s.modalClose?R=t[108]:(R=(0,$.jsx)(b,{asChild:!0,children:(0,$.jsx)(z,{variant:`secondary`,children:s.modalClose})}),t[107]=s.modalClose,t[108]=R);let B;t[109]!==n||t[110]!==r||t[111]!==i||t[112]!==a||t[113]!==s.connect?(B=r?null:(0,$.jsxs)(z,{variant:`primary`,onClick:()=>{a(n),i()},children:[(0,$.jsx)(Ee,{className:`size-4`}),s.connect]}),t[109]=n,t[110]=r,t[111]=i,t[112]=a,t[113]=s.connect,t[114]=B):B=t[114];let V;t[115]!==R||t[116]!==B?(V=(0,$.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-5 py-4 sm:px-6`,children:[R,B]}),t[115]=R,t[116]=B,t[117]=V):V=t[117];let H;t[118]!==u||t[119]!==h||t[120]!==g||t[121]!==L||t[122]!==V?(H=(0,$.jsxs)(u,{className:h,children:[g,L,V]}),t[118]=u,t[119]=h,t[120]=g,t[121]=L,t[122]=V,t[123]=H):H=t[123];let U;t[124]!==f||t[125]!==_||t[126]!==H?(U=(0,$.jsxs)(f,{children:[_,H]}),t[124]=f,t[125]=_,t[126]=H,t[127]=U):U=t[127];let te;return t[128]!==m||t[129]!==T||t[130]!==E||t[131]!==U?(te=(0,$.jsx)(m,{open:T,onOpenChange:E,children:U}),t[128]=m,t[129]=T,t[130]=E,t[131]=U,t[132]=te):te=t[132],te}function St(e){return!e.startsWith(`runtime.`)&&!e.startsWith(`auth.`)}function Ct(e){return e.required}function wt(e){return e.required}var Tt=(0,Q.memo)(function(e){let t=(0,at.c)(45),{onRefresh:n,refreshing:r,refreshLabel:i,onBrowseCatalog:a,onAddCustomServer:o,addLabel:c,browseLabel:l,customLabel:d,serviceLabel:f,moreActionsLabel:m}=e,[h,g]=(0,Q.useState)(!1),_;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(_=p(`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`,ee.transition),t[0]=_):_=t[0];let v=_,y;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(u,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[1]=y):y=t[1];let b;t[2]===c?b=t[3]:(b=(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:c}),t[2]=c,t[3]=b);let x;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(Fe,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[4]=x):x=t[4];let S;t[5]!==c||t[6]!==b?(S=(0,$.jsx)(X,{asChild:!0,children:(0,$.jsxs)(z,{type:`button`,variant:`primary`,className:`shrink-0 gap-2`,"aria-label":c,children:[y,b,x]})}),t[5]=c,t[6]=b,t[7]=S):S=t[7];let C;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,$.jsx)(j,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[8]=C):C=t[8];let w;t[9]!==l||t[10]!==a?(w=(0,$.jsxs)(Ve,{className:v,onSelect:a,children:[C,l]}),t[9]=l,t[10]=a,t[11]=w):w=t[11];let T;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(ne,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[12]=T):T=t[12];let E;t[13]!==d||t[14]!==o?(E=(0,$.jsxs)(Ve,{className:v,onSelect:o,children:[T,d]}),t[13]=d,t[14]=o,t[15]=E):E=t[15];let D;t[16]!==w||t[17]!==E?(D=(0,$.jsx)(je,{children:(0,$.jsxs)(ve,{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:[w,E]})}),t[16]=w,t[17]=E,t[18]=D):D=t[18];let O;t[19]!==D||t[20]!==S?(O=(0,$.jsxs)(Le,{children:[S,D]}),t[19]=D,t[20]=S,t[21]=O):O=t[21];let k;t[22]===h?k=t[23]:(k=(0,$.jsx)(nt,{open:h,onOpenChange:g,hideTrigger:!0}),t[22]=h,t[23]=k);let A;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,$.jsx)(s,{className:`size-4`,"aria-hidden":!0}),t[24]=A):A=t[24];let M;t[25]===m?M=t[26]:(M=(0,$.jsx)(X,{asChild:!0,children:(0,$.jsx)(z,{type:`button`,variant:`secondary`,className:`size-9 shrink-0 p-0`,"aria-label":m,title:m,children:A})}),t[25]=m,t[26]=M);let N;t[27]!==n||t[28]!==i||t[29]!==r?(N=n?(0,$.jsxs)(Ve,{className:v,disabled:r,onSelect:n,children:[r?(0,$.jsx)(R,{className:`size-4 animate-spin text-fg-muted`,"aria-hidden":!0}):(0,$.jsx)(ge,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),i]}):null,t[27]=n,t[28]=i,t[29]=r,t[30]=N):N=t[30];let P,F;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(P=()=>g(!0),F=(0,$.jsx)(He,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),t[31]=P,t[32]=F):(P=t[31],F=t[32]);let I;t[33]===f?I=t[34]:(I=(0,$.jsxs)(Ve,{className:v,onSelect:P,children:[F,f]}),t[33]=f,t[34]=I);let L;t[35]!==N||t[36]!==I?(L=(0,$.jsx)(je,{children:(0,$.jsxs)(ve,{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:[N,I]})}),t[35]=N,t[36]=I,t[37]=L):L=t[37];let B;t[38]!==M||t[39]!==L?(B=(0,$.jsxs)(Le,{children:[M,L]}),t[38]=M,t[39]=L,t[40]=B):B=t[40];let V;return t[41]!==O||t[42]!==k||t[43]!==B?(V=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2`,children:[O,k,B]}),t[41]=O,t[42]=k,t[43]=B,t[44]=V):V=t[44],V});function Et(e=``,t=``){return{clientKey:crypto.randomUUID(),key:e,value:t}}var Dt=/^([^:=]+)[:=](.*)$/;function Ot(e){let t=e.trim();if(!t)return null;try{let e=JSON.parse(t);if(e&&typeof e==`object`&&!Array.isArray(e))return At(e)}catch{}let n=[];for(let e of t.split(/\r?\n/)){let t=e.trim();if(!t)continue;let r=Dt.exec(t);r&&n.push(Et(r[1].trim(),r[2].trim()))}return n.length>0?n:null}function kt(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 At(e){if(!e||typeof e!=`object`)return[Et()];let t=Object.entries(e).map(([e,t])=>typeof t==`object`&&t&&!Array.isArray(t)?{...Et(e),reference:t}:Et(e,t==null?``:String(t)));return t.length>0?t:[Et()]}function jt(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 Mt(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 Nt(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 Pt(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=Mt(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=kt(e.envEntries);r&&(t.env=r)}else e.envJson.trim()&&(t.env=Nt(e.envJson));delete t.oauth,delete t.auth}else{t.type=`http`,t.url=e.url.trim();let n=kt(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 Ft(e,t){let n=t.oauth;return{clientKey:e,id:e,displayName:typeof t.displayName==`string`?t.displayName:``,transport:typeof t.url==`string`?`streamable-http`:`stdio`,command:typeof t.command==`string`?t.command:``,argsText:Array.isArray(t.args)?JSON.stringify(t.args):``,envJson:t.env?JSON.stringify(t.env,null,2):``,cwd:typeof t.cwd==`string`?t.cwd:``,url:typeof t.url==`string`?t.url:``,headers:At(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 It(e,t){let n=`mcp`;try{n=e.transport===`streamable-http`?new URL(e.url).hostname:e.command.split(/[\\/]/).pop()||n}catch{}let r=n.replace(/[^a-zA-Z0-9_-]+/g,`_`).replace(/^_+|_+$/g,``)||`mcp`,i=new Set([...t].map(e=>e.replace(/-/g,`_`))),a=r;for(let e=2;i.has(a.replace(/-/g,`_`));e++)a=`${r}_${e}`;return a}function Lt(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 Rt(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=Ft(e,n);return r.clientKey=crypto.randomUUID(),r.url&&=Lt(r.url),r})}function zt(e=``){return{clientKey:crypto.randomUUID(),id:e,transport:`streamable-http`,command:``,argsText:``,envJson:``,cwd:``,url:``,headers:[],oauthClientId:``,timeout:void 0,exposure:`codemode`,extra:{}}}function Bt(e){let t=e?.mcp?.servers??{};return{servers:Object.entries(t).filter(([,e])=>!jt(e)).map(([e,t])=>Ft(e,t)).sort((e,t)=>e.id.localeCompare(t.id))}}function Vt(e){return Pt(e)}async function Ht(e,t){return(await m(_(`/api/mcp/servers/${encodeURIComponent(e)}/tools`),{method:`POST`,signal:AbortSignal.any([t,AbortSignal.timeout(95e3)])})).payload.tools}async function Ut(e,t,n,r){return(await m(_(`/api/mcp/drafts`),{method:`POST`,signal:r,body:JSON.stringify({serverId:e.id,sourceServerId:t,expectedServer:n,server:Pt(e)})})).payload}async function Wt(e,t){return(await m(_(`/api/mcp/drafts/${encodeURIComponent(e)}/probe`),{method:`POST`,signal:AbortSignal.any([t,AbortSignal.timeout(95e3)])})).payload}async function Gt(e){await m(_(`/api/mcp/drafts/${encodeURIComponent(e)}`),{method:`DELETE`})}async function Kt(e,t=!1){let n=await m(_(`/api/mcp/drafts/${encodeURIComponent(e)}/commit`),{method:`POST`,body:JSON.stringify({enable:t})});return E(),n.payload}async function qt(e){return(await m(_(`/api/mcp/drafts/${encodeURIComponent(e)}/auth`),{method:`POST`})).payload}async function Jt(e,t){return(await m(_(`/api/mcp/drafts/${encodeURIComponent(e)}/auth`),{signal:t})).payload}async function Yt(e){await m(_(`/api/mcp/drafts/${encodeURIComponent(e)}/auth`),{method:`DELETE`})}async function Xt(e,t){await m(_(`/api/mcp/drafts/${encodeURIComponent(e)}/auth/redirect`),{method:`POST`,body:JSON.stringify({url:t})})}async function Zt(e,t){return(await m(_(`/api/mcp/drafts/${encodeURIComponent(e)}/tools`),{signal:t})).payload.tools}async function Qt(e){let t=await m(_(`/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 $t(e){let t=await m(_(`/api/mcp/servers/${encodeURIComponent(e.id)}`),{method:`DELETE`,body:JSON.stringify({expectedServer:e.extra})});return E(),t.payload}function en(e){let t=(0,at.c)(111),{serverId:n,displayName:r,returnFocusTo:i,draftId:a,t:o,onClose:s,onConfigure:c}=e,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=[],t[0]=l):l=t[0];let[u,d]=(0,Q.useState)(l),[f,p]=(0,Q.useState)(!0),[m,h]=(0,Q.useState)(``),[g,_]=(0,Q.useState)(``),[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 p(!0),h(``),d([]),(a?Zt(a,e.signal):Ht(n,e.signal)).then(e=>{t&&d(e)}).catch(e=>{let n=e?.status;t&&h(n===401?o.setupGatewayUnauthorized:n===403?o.setupAccessDenied:n===429?o.setupRateLimited:n===404||n===409?o.setupConflict:o.toolsLoadFailed)}).finally(()=>{t&&p(!1)}),()=>{t=!1,e.abort()}},t[1]=a,t[2]=n,t[3]=o.setupAccessDenied,t[4]=o.setupConflict,t[5]=o.setupGatewayUnauthorized,t[6]=o.setupRateLimited,t[7]=o.toolsLoadFailed,t[8]=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,ee,I,L,R,B,V,H;if(t[14]!==r||t[15]!==m||t[16]!==f||t[17]!==s||t[18]!==c||t[19]!==g||t[20]!==i||t[21]!==n||t[22]!==o.exposureLabels||t[23]!==o.setupConfigure||t[24]!==o.toolDetails||t[25]!==o.toolsClearSearch||t[26]!==o.toolsDialogSearchEmpty||t[27]!==o.toolsDialogSearchPlaceholder||t[28]!==o.toolsDialogSubtitle||t[29]!==o.toolsDialogTitle||t[30]!==o.toolsEmpty||t[31]!==o.toolsLoading||t[32]!==o.toolsRetryHint||t[33]!==o.toolsSearchSummary||t[34]!==o.toolsTitle||t[35]!==u){let e=g.trim().toLowerCase(),a;if(t[49]!==n){let e;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(e=/-/g,t[51]=e):e=t[51],a=n.replace(e,`_`),t[49]=n,t[50]=a}else a=t[50];let l=`mcp__${a}__`,d=u.filter(t=>`${t.name} ${t.description}`.toLowerCase().includes(e));M=w,F=!0,t[52]===s?ee=t[53]:(ee=e=>{e||s()},t[52]=s,t[53]=ee),j=x,t[54]===Symbol.for(`react.memo_cache_sentinel`)?(P=(0,$.jsx)(v,{className:`fixed inset-0 z-[60] bg-scrim`}),t[54]=P):P=t[54],A=S,t[55]===i?V=t[56]:(V=e=>{(D.current||i)&&e.preventDefault(),!D.current&&i?.isConnected&&i.focus()},t[55]=i,t[56]=V),H=`fixed left-1/2 top-1/2 z-[60] flex h-[min(42rem,calc(100dvh-2rem))] w-[min(48rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay`;let p;t[57]===o.toolsDialogTitle?p=t[58]:(p=(0,$.jsx)(C,{className:`font-semibold`,children:o.toolsDialogTitle}),t[57]=o.toolsDialogTitle,t[58]=p);let h;t[59]!==r||t[60]!==m||t[61]!==f||t[62]!==n||t[63]!==o.toolsDialogSubtitle||t[64]!==u.length?(h=f||m?r||n:o.toolsDialogSubtitle.replace(`{{serverId}}`,r||n).replace(`{{count}}`,String(u.length)),t[59]=r,t[60]=m,t[61]=f,t[62]=n,t[63]=o.toolsDialogSubtitle,t[64]=u.length,t[65]=h):h=t[65];let b;t[66]===h?b=t[67]:(b=(0,$.jsx)(y,{className:`mt-1 break-words text-sm text-fg-muted`,children:h}),t[66]=h,t[67]=b);let T;t[68]===Symbol.for(`react.memo_cache_sentinel`)?(T=e=>_(e.target.value),t[68]=T):T=t[68];let E;t[69]!==g||t[70]!==o.toolsDialogSearchPlaceholder?(E=(0,$.jsx)(`input`,{className:`mt-4 w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,value:g,onChange:T,placeholder:o.toolsDialogSearchPlaceholder,"aria-label":o.toolsDialogSearchPlaceholder}),t[69]=g,t[70]=o.toolsDialogSearchPlaceholder,t[71]=E):E=t[71];let O=e&&!f&&!m?(0,$.jsx)(`p`,{role:`status`,className:`mt-2 text-xs text-fg-muted`,children:o.toolsSearchSummary.replace(`{{visible}}`,String(d.length)).replace(`{{count}}`,String(u.length))}):null;t[72]!==p||t[73]!==b||t[74]!==E||t[75]!==O?(N=(0,$.jsxs)(`div`,{className:`shrink-0 border-b border-edge p-5`,children:[p,b,E,O]}),t[72]=p,t[73]=b,t[74]=E,t[75]=O,t[76]=N):N=t[76],I=`min-h-0 flex-1 overflow-y-auto p-5`,L=f,t[77]!==o.toolsTitle||t[78]!==u.length?(R=o.toolsTitle.replace(`{{count}}`,String(u.length)),t[77]=o.toolsTitle,t[78]=u.length,t[79]=R):R=t[79],B=f?(0,$.jsx)(`div`,{role:`status`,"aria-label":o.toolsLoading,className:`space-y-3`,children:[0,1,2].map(nn)}):m?(0,$.jsxs)(`div`,{role:`alert`,className:`space-y-3`,children:[(0,$.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-sm text-danger`,children:m}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:o.toolsRetryHint}),c?(0,$.jsx)(z,{variant:`secondary`,onClick:()=>{D.current=!0,c()},children:o.setupConfigure}):null]}):d.length?(0,$.jsx)(`div`,{className:`space-y-3`,children:d.map(e=>(0,$.jsxs)(`article`,{className:`rounded-lg border border-edge p-4`,children:[(0,$.jsx)(`h3`,{className:`break-all font-mono text-sm font-semibold text-fg`,children:e.name.startsWith(l)?e.name.slice(l.length):e.name}),e.exposure&&Object.hasOwn(o.exposureLabels,e.exposure)?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:o.exposureLabels[e.exposure]}):null,e.description?(0,$.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap break-words text-sm text-fg-muted`,children:e.description}):null,(0,$.jsxs)(`details`,{className:`mt-3`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm text-accent-fg`,children:o.toolDetails}),(0,$.jsx)(`p`,{className:`mt-2 break-all font-mono text-xs text-fg-muted`,children:e.name}),(0,$.jsx)(`pre`,{className:`mt-2 overflow-x-auto rounded-md bg-surface-panel p-3 text-xs text-fg`,children:JSON.stringify(e.inputSchema,null,2)})]})]},e.name))}):(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:u.length?o.toolsDialogSearchEmpty:o.toolsEmpty}),e?(0,$.jsx)(z,{variant:`secondary`,onClick:()=>_(``),children:o.toolsClearSearch}):null]}),t[14]=r,t[15]=m,t[16]=f,t[17]=s,t[18]=c,t[19]=g,t[20]=i,t[21]=n,t[22]=o.exposureLabels,t[23]=o.setupConfigure,t[24]=o.toolDetails,t[25]=o.toolsClearSearch,t[26]=o.toolsDialogSearchEmpty,t[27]=o.toolsDialogSearchPlaceholder,t[28]=o.toolsDialogSubtitle,t[29]=o.toolsDialogTitle,t[30]=o.toolsEmpty,t[31]=o.toolsLoading,t[32]=o.toolsRetryHint,t[33]=o.toolsSearchSummary,t[34]=o.toolsTitle,t[35]=u,t[36]=A,t[37]=j,t[38]=M,t[39]=N,t[40]=P,t[41]=F,t[42]=ee,t[43]=I,t[44]=L,t[45]=R,t[46]=B,t[47]=V,t[48]=H}else A=t[36],j=t[37],M=t[38],N=t[39],P=t[40],F=t[41],ee=t[42],I=t[43],L=t[44],R=t[45],B=t[46],V=t[47],H=t[48];let U;t[80]!==I||t[81]!==L||t[82]!==R||t[83]!==B?(U=(0,$.jsx)(`div`,{className:I,"aria-busy":L,"aria-label":R,children:B}),t[80]=I,t[81]=L,t[82]=R,t[83]=B,t[84]=U):U=t[84];let te;t[85]===Symbol.for(`react.memo_cache_sentinel`)?(te=()=>E(tn),t[85]=te):te=t[85];let W;t[86]!==f||t[87]!==o.refreshTools?(W=(0,$.jsx)(z,{variant:`secondary`,disabled:f,onClick:te,children:o.refreshTools}),t[86]=f,t[87]=o.refreshTools,t[88]=W):W=t[88];let G;t[89]!==s||t[90]!==o.toolsDialogClose?(G=(0,$.jsx)(b,{asChild:!0,children:(0,$.jsx)(z,{onClick:s,children:o.toolsDialogClose})}),t[89]=s,t[90]=o.toolsDialogClose,t[91]=G):G=t[91];let K;t[92]!==W||t[93]!==G?(K=(0,$.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge p-4`,children:[W,G]}),t[92]=W,t[93]=G,t[94]=K):K=t[94];let q;t[95]!==A||t[96]!==N||t[97]!==U||t[98]!==K||t[99]!==V||t[100]!==H?(q=(0,$.jsxs)(A,{onCloseAutoFocus:V,className:H,children:[N,U,K]}),t[95]=A,t[96]=N,t[97]=U,t[98]=K,t[99]=V,t[100]=H,t[101]=q):q=t[101];let J;t[102]!==j||t[103]!==P||t[104]!==q?(J=(0,$.jsxs)(j,{children:[P,q]}),t[102]=j,t[103]=P,t[104]=q,t[105]=J):J=t[105];let ne;return t[106]!==M||t[107]!==F||t[108]!==ee||t[109]!==J?(ne=(0,$.jsx)(M,{open:F,onOpenChange:ee,children:J}),t[106]=M,t[107]=F,t[108]=ee,t[109]=J,t[110]=ne):ne=t[110],ne}function tn(e){return e+1}function nn(e){return(0,$.jsx)(K,{className:`h-24 w-full`},e)}function rn(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 an({row:e,lastCheck:t,t:n,cs:r,onEdit:i,onRemove:a}){let[o,s]=(0,Q.useState)(!1),c=(0,Q.useRef)(null),[l,u]=(0,Q.useState)(!1),[d,f]=(0,Q.useState)(``);return(0,$.jsxs)(`div`,{className:`px-4 py-3.5`,children:[(0,$.jsxs)(`button`,{className:`block w-full text-left`,onClick:i,children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold`,children:e.displayName||e.id}),(0,$.jsx)(`p`,{className:`mt-2 break-all font-mono text-xs text-fg-muted`,children:rn(e)})]}),(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:e.extra.enabled===!1?n.setupDisabled:t?n.setupLastCheck.replace(`{{count}}`,String(t.toolCount)):n.setupUnverified}),t?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:(0,$.jsx)(`time`,{dateTime:t.checkedAt,children:new Intl.DateTimeFormat(void 0,{dateStyle:`short`,timeStyle:`short`}).format(new Date(t.checkedAt))})}):null,d?(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:d}):null,(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap justify-end gap-2`,children:[(0,$.jsx)(z,{variant:`ghost`,onClick:i,children:n.setupConfigure}),(0,$.jsx)(z,{ref:c,variant:`secondary`,disabled:e.extra.enabled===!1,onClick:()=>s(!0),children:n.viewTools}),(0,$.jsx)(z,{variant:`ghost`,onClick:()=>u(!0),children:n.removeServer})]}),o?(0,$.jsx)(en,{serverId:e.id,displayName:e.displayName,returnFocusTo:c.current,t:n,onClose:()=>s(!1),onConfigure:()=>{s(!1),i()}}):null,(0,$.jsx)(ce,{open:l,title:r.removeConfirmTitle.replace(`{{name}}`,e.displayName||e.id),description:r.removeConfirmDescription,confirmLabel:n.removeServer,cancelLabel:r.modalCancel,destructive:!0,onCancel:()=>u(!1),onConfirm:()=>{u(!1),f(``),a().catch(()=>f(n.setupRemoveFailed))}})]})}function on(e){return e.format===`agent-plugin`&&!!e.pluginId&&(!!e.setup?.authorizations?.length||e.authorizationStatus===`required`||!!e.components?.mcp.some(e=>e.type!==`stdio`))}function sn(e){let t=(0,at.c)(41),{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=n.branding?.iconUrl,b;t[17]===y?b=t[18]:(b=(0,$.jsx)(rt,{iconUrl:y,fallback:qe}),t[17]=y,t[18]=b);let x;t[19]===v?x=t[20]:(x=(0,$.jsx)(`span`,{className:`block text-sm font-semibold text-fg`,children:v}),t[19]=v,t[20]=x);let S;t[21]===c?S=t[22]:(S=c(`由插件提供`,`Provided by plugin`),t[21]=c,t[22]=S);let C;t[23]!==n.name||t[24]!==S?(C=(0,$.jsxs)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:[S,` · `,n.name]}),t[23]=n.name,t[24]=S,t[25]=C):C=t[25];let w;t[26]!==C||t[27]!==x?(w=(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[x,C]}),t[26]=C,t[27]=x,t[28]=w):w=t[28];let T=`shrink-0 text-xs ${d&&!u?`text-amber-700 dark:text-amber-300`:`text-fg-muted`}`,E;t[29]!==p||t[30]!==T?(E=(0,$.jsx)(`span`,{className:T,children:p}),t[29]=p,t[30]=T,t[31]=E):E=t[31];let D;t[32]===h?D=t[33]:(D=(0,$.jsx)(`span`,{className:`shrink-0 text-xs text-accent`,children:h}),t[32]=h,t[33]=D);let O;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,$.jsx)(Z,{className:`size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),t[34]=O):O=t[34];let k;return t[35]!==i||t[36]!==w||t[37]!==E||t[38]!==D||t[39]!==b?(k=(0,$.jsxs)(`button`,{type:`button`,onClick:i,className:`flex w-full items-center gap-3 px-4 py-3.5 text-left hover:bg-surface-hover/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,children:[b,w,E,D,O]}),t[35]=i,t[36]=w,t[37]=E,t[38]=D,t[39]=b,t[40]=k):k=t[40],k}function cn(e){let t=e.connectedAt?Date.parse(e.connectedAt):0;return Number.isFinite(t)?t:0}function ln(e,t){return e.status===`active`&&t.status!==`active`?-1:e.status!==`active`&&t.status===`active`?1:e.isCurrentAuthorization===t.isCurrentAuthorization?cn(t)-cn(e):e.isCurrentAuthorization?-1:1}function un(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(ln);return{key:e,primary:n[0],authorizations:n}}).sort((e,t)=>ln(e.primary,t.primary))}var dn=p(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,q);function fn(e){return e.materialized.type===`composio`?e.materialized.toolkit:null}function pn(e,t){return e===`write`?t.composioScopeWrite:e===`admin`?t.composioScopeAdmin:t.composioScopeRead}function mn(e,t,n){return e.status===`connected`?W(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 hn(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 gn(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 _n({instance:e,t,onChanged:n}){let r=fn(e),i=g(e=>e.language)===`zh`,[a,s]=(0,Q.useState)([]),[c,l]=(0,Q.useState)([]),[u,d]=(0,Q.useState)([]),[f,m]=(0,Q.useState)(null),[h,_]=(0,Q.useState)([]),[v,y]=(0,Q.useState)(null),[b,x]=(0,Q.useState)(null),[S,C]=(0,Q.useState)([]),[w,T]=(0,Q.useState)({}),[E,D]=(0,Q.useState)(`read`),[O,A]=(0,Q.useState)(!1),[j,M]=(0,Q.useState)(null),[P,F]=(0,Q.useState)(!1),[ee,I]=(0,Q.useState)(null),[L,U]=(0,Q.useState)(null),[G,q]=(0,Q.useState)(!1),[ne,ae]=(0,Q.useState)(!1),[oe,Y]=(0,Q.useState)(!1),se=(0,Q.useRef)(0),le=(0,Q.useRef)(0),de=(0,Q.useMemo)(()=>un(a),[a]),X=(0,Q.useCallback)(e=>new Promise((t,n)=>{let r=window.setTimeout(()=>n(Error(i?`连接服务响应超时,请重试。`:`The connection service timed out. Please retry.`)),15e3);e.then(t,n).finally(()=>window.clearTimeout(r))}),[i]),Z=(0,Q.useCallback)(async()=>{if(!r||e.materialized.type!==`composio`||e.materialized.role===`credential`)return;A(!0),M(null);let t=++se.current;try{let e=(await Promise.allSettled([X(Se()).then(e=>{t===se.current&&(s(e.filter(e=>e.toolkit.toLowerCase()===r.toLowerCase())),q(!0))}),X(pe(r)).then(e=>{t===se.current&&D(e)}),X(Ue(r)).then(e=>{t===se.current&&(m(e.policy),_(e.agents))})])).find(e=>e.status===`rejected`);t===se.current&&e?.status===`rejected`&&M(String(e.reason instanceof Error?e.reason.message:e.reason))}finally{t===se.current&&A(!1)}},[e.materialized,r,X]);(0,Q.useEffect)(()=>(Z(),()=>{se.current++}),[Z]);let _e=(0,Q.useCallback)(async()=>{if(!r)return;let e=++le.current;Y(!0),F(!1);let t=t=>n=>{e===le.current&&t(n)},n=await Promise.allSettled([X(xe(r)).then(t(l)),X(ue(20)).then(t(e=>d(e.filter(e=>!e.toolkit||e.toolkit.toLowerCase()===r.toLowerCase())))),X(Pe(r)).then(t(x)),X(Oe(r)).then(t(y))]);e===le.current&&(F(n.some(e=>e.status===`rejected`)),Y(!1))},[r,X]);(0,Q.useEffect)(()=>(ne&&_e(),()=>{le.current++}),[ne,_e]),(0,Q.useEffect)(()=>{let e=!1,t=un(a).map(e=>e.primary).filter(e=>e.supportsLearning&&e.accountId);if(t.length)return X(Ke()).then(t=>{e||C(t)}).catch(()=>{}),Promise.allSettled(t.map(async e=>[e.accountId,await X(ke(e.accountId))])).then(t=>{e||T(Object.fromEntries(t.flatMap(e=>e.status===`fulfilled`?[e.value]:[])))}),()=>{e=!0}},[a,X]);let ve=(0,Q.useCallback)(async i=>{if(!r)return;let a=Ne()?null:window.open(`about:blank`,`_blank`);a&&(a.opener=null),A(!0),M(null);try{if(!Ne()&&!a)throw Error(`Allow popups to open the authorization page.`);let t=await N(e.connectorId,i);if(!t.authorizationUrl)throw Error(`The authorization provider did not return an authorization URL.`);if(Ne()){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 te(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?.(),Z()])}catch(e){M(ie(e,t))}finally{a?.close(),A(!1)}},[e.connectorId,Z,n,t,r]),ye=(0,Q.useCallback)(async t=>{A(!0),M(null);try{await B(e.instanceId,{config:{...e.config??{},authConfigId:t||void 0}}),await Promise.all([n?.(),Z()])}catch(e){M(e instanceof Error?e.message:String(e))}finally{A(!1)}},[e.config,e.instanceId,Z,n]),Ce=async e=>{let t=Ne()?null:window.open(`about:blank`,`_blank`);t&&(t.opener=null),M(null);try{let n=await fe(e.id);if(n.authorizationUrl)if(Ne())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 Z()}catch(e){t?.close(),M(e instanceof Error?e.message:String(e))}},we=(0,Q.useCallback)(async e=>{if(r){D(e),M(null);try{await Je(r,e)}catch(e){M(e instanceof Error?e.message:String(e)),await Z()}}},[Z,r]),Ee=(0,Q.useCallback)(async e=>{if(r){M(null);try{m(await Te(r,e))}catch(e){M(e instanceof Error?e.message:String(e))}}},[r]),je=(0,Q.useCallback)(e=>{if(!f)return;let t=f.allowedAgentIds.includes(e);t&&f.allowedAgentIds.length===1||Ee({allowedAgentIds:t?f.allowedAgentIds.filter(t=>t!==e):[...f.allowedAgentIds,e]})},[Ee,f]),Me=(0,Q.useCallback)(async e=>{A(!0),M(null);try{await e(),await Z()}catch(e){M(e instanceof Error?e.message:String(e))}finally{A(!1)}},[Z]);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 Fe=de.filter(e=>e.primary.status===`active`).length,Ie=Fe>0?t.composioAddAccount:t.composioConnectAccount,Le=G&&Fe>0,Re=b?.requiresCustomAuthConfig===!0,ze=b?.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:p(`inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-xs font-medium`,Le?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-amber-500/10 text-amber-700 dark:text-amber-300`),children:[Le?(0,$.jsx)(o,{className:`size-3.5`}):(0,$.jsx)(We,{className:`size-3.5`}),Le?t.connectionReady:G||j?t.connectionNeedsSetup:t.connectionChecking]}),G&&(0,$.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:W(t.composioAccountCount,{count:String(de.length)})})]}),(0,$.jsxs)(z,{variant:`primary`,className:`shrink-0`,disabled:O,onClick:()=>void ve(),children:[O?(0,$.jsx)(R,{className:`size-4 animate-spin`}):(0,$.jsx)(me,{className:`size-4`}),Ie]})]}),j?(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:j}),(0,$.jsx)(z,{variant:`secondary`,disabled:O,onClick:()=>void Z(),children:t.composioRetry})]}):null,v&&!Le?(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border border-amber-500/25 bg-amber-500/5 p-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsx)(`p`,{className:`text-sm text-amber-800 dark:text-amber-200`,children:mn(v,Fe,t)}),v.recovery===`none`?null:(0,$.jsx)(z,{variant:`secondary`,disabled:O,onClick:()=>void(v.recovery===`retry`?Z():ve()),children:v.recovery===`retry`?t.composioRetry:t.composioReconnectAccount})]}):null,Re&&ze.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:E===`read`?t.composioAccessReadHint:E===`admin`?t.composioAccessAdminHint:t.composioAccessWriteHint})]}),(0,$.jsxs)(he,{value:E,onChange:e=>void we(e.currentTarget.value),children:[(0,$.jsx)(be,{value:`read`,children:t.composioAccessReadOnly}),(0,$.jsx)(be,{value:`write`,children:t.composioAccessReadWrite}),E===`admin`?(0,$.jsx)(be,{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)(he,{value:f.confirmationPolicy,onChange:e=>void Ee({confirmationPolicy:e.currentTarget.value}),children:[(0,$.jsx)(be,{value:`writes`,children:t.composioConfirmWrites}),(0,$.jsx)(be,{value:`always`,children:t.composioConfirmAlways}),f.confirmationPolicy===`never`?(0,$.jsx)(be,{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:p(`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 Ee({allowedAgentIds:[]}),children:t.composioAllowedAgentsAllOption}),h.map(e=>(0,$.jsx)(`button`,{type:`button`,className:p(`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:()=>je(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:O,onChange:e=>void Ee({selectedAccountIds:e.currentTarget.checked?null:[]})}),i?`所有账号(包括以后新增)`:`All accounts, including new ones`]}),f.selectedAccountIds!==null&&de.map(({primary:e})=>e.accountId&&(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,disabled:O,checked:f.selectedAccountIds.includes(e.accountId),onChange:t=>void Ee({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}),G&&(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:W(t.composioAccountCount,{count:String(de.length)})})]}),(0,$.jsxs)(z,{variant:`ghost`,className:`h-8 px-2 text-xs`,disabled:O,onClick:()=>void Z(),children:[(0,$.jsx)(ge,{className:p(`size-3.5`,O&&`animate-spin`)}),t.refresh]})]}),de.length?(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-xl border border-edge bg-surface-base`,children:de.map(e=>{let r=e.primary,a=S.find(e=>r.accountId?e.accountId===r.accountId:e.connectionId===r.id),o=r.accountId?w[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:p(`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`:hn(r.status,t)}),a?(0,$.jsx)(`p`,{className:p(`mt-1 text-xs`,a.status===`failed`?`text-red-600`:`text-fg-subtle`),children:W(t.connectorLearningStatus,{status:gn(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 Ce(r),children:i?`继续授权`:`Continue authorization`}),r.accountId&&(0,$.jsx)(z,{variant:`ghost`,className:`h-8 px-2.5 text-xs text-danger`,disabled:O,onClick:()=>U(r.accountId),children:i?`断开`:`Disconnect`}),r.accountId&&r.status!==`active`&&(0,$.jsx)(z,{variant:`secondary`,className:`h-8 px-2.5 text-xs`,disabled:O,onClick:()=>void ve(r.accountId),children:t.composioReconnectAccount}),r.accountId&&(0,$.jsx)(z,{variant:`secondary`,className:`h-8 px-2.5 text-xs`,disabled:O,onClick:()=>void Me(()=>De(r.accountId,{enabled:r.accountEnabled===!1})),children:r.accountEnabled===!1?i?`启用`:`Enable`:i?`暂停`:`Pause`}),r.supportsLearning&&r.status===`active`&&r.accountEnabled!==!1?(0,$.jsxs)(z,{variant:`secondary`,className:`h-8 shrink-0 px-2.5 text-xs`,disabled:O,onClick:()=>void Me(async()=>{if(!r.accountId)throw Error(`Connector account is unavailable.`);await re(r.accountId),await n?.()}),children:[(0,$.jsx)(ge,{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:O,checked:r.allowedAgentIds==null,onChange:e=>void Me(()=>De(r.accountId,{allowedAgentIds:e.currentTarget.checked?null:[]}))}),t.composioAllowedAgentsAllOption]}),r.allowedAgentIds!=null&&h.map(e=>(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,disabled:O,checked:r.allowedAgentIds.includes(e.id),onChange:t=>{let n=t.currentTarget.checked;Me(()=>De(r.accountId,{allowedAgentIds:n?[...r.allowedAgentIds,e.id]:r.allowedAgentIds.filter(t=>t!==e.id)}))}}),e.name]},e.id)),r.allowedAgentIds?.length===0&&(0,$.jsx)(`p`,{children:i?`未选择 Agent:任何 Agent 都不能使用此账号。`:`No agents selected: this account is unavailable to all agents.`})]}),r.supportsLearning&&o?(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:o.scanEnabled,disabled:O,onChange:e=>void Me(()=>V(r.accountId,{scanEnabled:e.currentTarget.checked}))}),t.connectorScheduledScan]}),o.scanEnabled?(0,$.jsxs)(`label`,{className:`sm:col-span-2`,children:[t.connectorScanInterval,(0,$.jsxs)(he,{className:`mt-1`,value:String(o.intervalMinutes??30),disabled:O,onChange:e=>void Me(()=>V(r.accountId,{intervalMinutes:Number(e.currentTarget.value)})),children:[(0,$.jsxs)(be,{value:`5`,children:[`5 `,t.connectorMinutes]}),(0,$.jsxs)(be,{value:`15`,children:[`15 `,t.connectorMinutes]}),(0,$.jsxs)(be,{value:`30`,children:[`30 `,t.connectorMinutes]}),(0,$.jsxs)(be,{value:`60`,children:[`60 `,t.connectorMinutes]})]})]}):null]}):null,(0,$.jsxs)(`label`,{className:`block`,children:[t.composioAccountAlias,(0,$.jsx)(`input`,{className:p(dn,`mt-1 h-8 py-1 text-xs`),defaultValue:r.alias??``,onBlur:e=>{e.currentTarget.value!==(r.alias??``)&&Me(()=>k(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:O,onClick:()=>I(e.id),children:(0,$.jsx)(H,{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:O,onClick:()=>void Me(()=>Xe(r.id)),children:(0,$.jsx)(ge,{className:`size-4`})})})]})]})]},e.key)})}):O&&!G?(0,$.jsxs)(`div`,{"aria-busy":`true`,"aria-label":t.connectionChecking,className:`space-y-3`,children:[(0,$.jsx)(K,{className:`h-16 w-full`}),(0,$.jsx)(K,{className:`h-16 w-full`})]}):G?(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=>ae(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:[oe?(0,$.jsx)(K,{"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:oe,onClick:()=>void _e(),children:t.composioRetry})]}):null,b?.mode===`byok`?(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.composioAuthConfigTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:Re?t.composioAuthConfigRequiredHint:t.composioAuthConfigOptionalHint})]}),(0,$.jsx)(`a`,{className:`text-xs font-medium text-accent-fg hover:underline`,href:`https://app.composio.dev`,target:`_blank`,rel:`noreferrer`,children:t.composioAuthConfigManage})]}),(0,$.jsxs)(he,{className:`mt-3`,value:typeof e.config?.authConfigId==`string`?e.config.authConfigId:``,disabled:O,onChange:e=>void ye(e.currentTarget.value),children:[Re?null:(0,$.jsx)(be,{value:``,children:t.composioAuthConfigManaged}),Re&&typeof e.config?.authConfigId!=`string`?(0,$.jsx)(be,{value:``,disabled:!0,children:t.composioAuthConfigSelect}):null,ze.map(e=>(0,$.jsxs)(be,{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:c.length?c.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:[pn(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)(ce,{open:L!==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=L;U(null),e&&Me(()=>Ae(e))},onCancel:()=>U(null)}),(0,$.jsx)(ce,{open:ee!==null,title:t.composioRevoke,description:t.composioRevokeConfirm,confirmLabel:t.composioRevoke,cancelLabel:t.modalCancel,destructive:!0,onConfirm:()=>{let e=ee;I(null),e&&Me(()=>J(e))},onCancel:()=>I(null)})]})}var vn=p(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,q);function yn(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 bn(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 xn({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),[f,m]=(0,Q.useState)(!1),[h,g]=(0,Q.useState)(null),[_,T]=(0,Q.useState)(()=>yn(t,e)),[E,D]=(0,Q.useState)(null),[O,k]=(0,Q.useState)(!1),[A,j]=(0,Q.useState)(null),N=t?.setup.config??[],P=(e.materialized.type===`mcp`||e.materialized.type===`memorySource`)&&N.length>0&&(t?.setup.secrets??[]).length===0,I=e.materialized.type===`mcp`,L=e.materialized.type===`composio`,V=e.materialized.type===`memorySource`,te=t?se(t,i):null,G=(0,Q.useCallback)(async()=>{k(!0),D(null);try{let t=await U(e.instanceId);j(t),t.ok||D(t.error??t.action??i.healthStatusLabels[t.status]),await r()}catch(e){D(e instanceof Error?e.message:String(e))}finally{k(!1)}},[e.instanceId,r,i.healthStatusLabels]),K=(0,Q.useCallback)(async()=>{o(!0),D(null);try{await Ye(e.instanceId),await r(),n()}catch(e){D(e instanceof Error?e.message:String(e)),o(!1)}},[e.instanceId,r,n]),q=(0,Q.useCallback)(async()=>{if(!(!t||!P)){u(!0),D(null);try{let n={};for(let e of t.setup.config??[]){let t=bn(e.type,_[e.key]??``);t!==void 0&&(n[e.key]=t)}await B(e.instanceId,{config:n}),await r()}catch(e){D(e instanceof Error?e.message:String(e))}finally{u(!1)}}},[_,t,e.instanceId,r,P]),J=(0,Q.useCallback)(async()=>{m(!0),g(null),D(null);try{g((await M(e.connectorId)).recordIds.length),await r()}catch(e){D(e instanceof Error?e.message:String(e))}finally{m(!1)}},[e.connectorId,r]);return(0,$.jsxs)(w,{open:!0,onOpenChange:e=>{e||n()},children:[(0,$.jsxs)(x,{children:[(0,$.jsx)(v,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(S,{className:p(`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`,L?`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)(ye,{connector:t,size:`lg`}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(C,{className:`text-base font-semibold text-fg`,children:e.displayName}),(0,$.jsx)(y,{className:`mt-1 text-sm text-fg-muted`,children:te??(e.materialized.type===`mcp`?W(i.mcpServerRuntime,{serverId:e.materialized.serverId}):W(i.runtimeLabel,{runtime:e.materialized.type}))})]})]}),(0,$.jsx)(b,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,className:p(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,ee.focusRingPanel),"aria-label":i.modalClose,children:[(0,$.jsx)(d,{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:[E?(0,$.jsx)(`p`,{className:`mb-4 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:E}):null,I?(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:A?.ok?W(i.toolsAvailable,{count:String(A.toolCount)}):A?i.healthStatusLabels[A.status]:e.usage.lastHealthStatus?i.healthStatusLabels[e.usage.lastHealthStatus]:i.healthNotTested}),(0,$.jsxs)(z,{variant:`secondary`,"aria-busy":O,disabled:O||!e.enabled,onClick:()=>void G(),children:[O?(0,$.jsx)(R,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(ge,{className:`size-4`,"aria-hidden":!0}),i.test]})]}),P?N.map(e=>(0,$.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`font-medium text-fg`,children:e.label}),e.description?(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:e.description}):null,(0,$.jsx)(`input`,{className:vn,value:_[e.key]??``,placeholder:e.placeholder,onChange:t=>T(n=>({...n,[e.key]:t.currentTarget.value}))})]},e.key)):null]}):null,L?(0,$.jsx)(_n,{instance:e,t:i,onChanged:r}):null,V?(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}),te?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:te}):null,h===null?null:(0,$.jsx)(`p`,{className:`mt-1 text-xs text-emerald-600`,children:W(i.connectedSourceSynced,{count:String(h)})})]}),(0,$.jsxs)(z,{disabled:f,onClick:()=>void J(),children:[f?(0,$.jsx)(R,{className:`size-4 animate-spin`}):(0,$.jsx)(F,{className:`size-4`}),i.composioSyncNow]})]}),P?(0,$.jsx)(`div`,{className:`grid gap-3 rounded-xl border border-edge bg-surface-base p-4`,children:N.map(e=>(0,$.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.label}),e.description?(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:e.description}):null,(0,$.jsx)(`input`,{className:vn,value:_[e.key]??``,placeholder:e.placeholder,onChange:t=>T(n=>({...n,[e.key]:t.currentTarget.value}))})]},e.key))}):null]}):null,!I&&!L&&!V?(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)(R,{className:`size-4 animate-spin`}):(0,$.jsx)(H,{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}),(I||V)&&P?(0,$.jsxs)(z,{variant:`primary`,disabled:l,onClick:()=>void q(),children:[l?(0,$.jsx)(R,{className:`size-4 animate-spin`}):(0,$.jsx)(Be,{className:`size-4`}),i.modalSave]}):null]})]})]}),(0,$.jsx)(ce,{open:s,title:W(i.removeConfirmTitle,{name:e.displayName}),description:i.removeConfirmDescription,confirmLabel:i.removeConfirmAction,cancelLabel:i.modalCancel,destructive:!0,onConfirm:()=>{c(!1),K()},onCancel:()=>{a||c(!1)}})]})}function Sn(e){let t=(0,at.c)(2),n;return t[0]===e?n=t[1]:(n=e.instance.materialized.type===`cli`&&e.definition?(0,$.jsx)(O,{definition:e.definition,instance:e.instance,onClose:e.onClose,onChanged:e.onChanged}):(0,$.jsx)(xn,{...e}),t[0]=e,t[1]=n),n}function Cn(e){let t=(0,at.c)(55),{instance:n,definition:r,highlighted:i,onOpenDetails:a,t:s}=e,c=i===void 0?!1:i,l;t[0]!==r||t[1]!==n?(l=_t(n,r),t[0]=r,t[1]=n,t[2]=l):l=t[2];let u=l.state,d;t[3]!==r||t[4]!==s?(d=r?se(r,s):null,t[3]=r,t[4]=s,t[5]=d):d=t[5];let f=d,m,h,g,_,v,y,b,x,S;if(t[6]!==u||t[7]!==r||t[8]!==c||t[9]!==n||t[10]!==a||t[11]!==s.connectionChecking||t[12]!==s.connectionNeedsSetup||t[13]!==s.connectionReady){m=u===`ready`?{label:s.connectionReady,Icon:o,className:`text-emerald-700 dark:text-emerald-300`}:u===`needs_setup`?{label:s.connectionNeedsSetup,Icon:We,className:`text-amber-700 dark:text-amber-300`}:{label:s.connectionChecking,Icon:G,className:`text-fg-muted`},x=`button`;let e=c&&`bg-accent-soft`;t[23]===e?S=t[24]:(S=p(`flex w-full items-center gap-3 px-4 py-3.5 text-left hover:bg-surface-hover/60`,`rounded-none first:rounded-t-[calc(var(--radius-xl)-1px)] last:rounded-b-[calc(var(--radius-xl)-1px)]`,ee.transition,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,e),t[23]=e,t[24]=S),t[25]!==n||t[26]!==a?(h=()=>a(n),t[25]=n,t[26]=a,t[27]=h):h=t[27],t[28]===r?g=t[29]:(g=(0,$.jsx)(ye,{connector:r}),t[28]=r,t[29]=g),b=`min-w-0 flex-1`,v=`flex min-w-0 items-center gap-2`,t[30]===n.displayName?y=t[31]:(y=(0,$.jsx)(`h3`,{className:`truncate text-sm font-medium text-fg`,children:n.displayName}),t[30]=n.displayName,t[31]=y),_=p(`inline-flex shrink-0 items-center gap-1 text-xs font-medium`,m.className),t[6]=u,t[7]=r,t[8]=c,t[9]=n,t[10]=a,t[11]=s.connectionChecking,t[12]=s.connectionNeedsSetup,t[13]=s.connectionReady,t[14]=m,t[15]=h,t[16]=g,t[17]=_,t[18]=v,t[19]=y,t[20]=b,t[21]=x,t[22]=S}else m=t[14],h=t[15],g=t[16],_=t[17],v=t[18],y=t[19],b=t[20],x=t[21],S=t[22];let C;t[32]===m.Icon?C=t[33]:(C=(0,$.jsx)(m.Icon,{className:`size-3.5`,"aria-hidden":!0}),t[32]=m.Icon,t[33]=C);let w;t[34]!==m.label||t[35]!==C||t[36]!==_?(w=(0,$.jsxs)(`span`,{className:_,children:[C,m.label]}),t[34]=m.label,t[35]=C,t[36]=_,t[37]=w):w=t[37];let T;t[38]!==w||t[39]!==v||t[40]!==y?(T=(0,$.jsxs)(`div`,{className:v,children:[y,w]}),t[38]=w,t[39]=v,t[40]=y,t[41]=T):T=t[41];let E;t[42]===f?E=t[43]:(E=f?(0,$.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted`,children:f}):null,t[42]=f,t[43]=E);let D;t[44]!==T||t[45]!==E||t[46]!==b?(D=(0,$.jsxs)(`div`,{className:b,children:[T,E]}),t[44]=T,t[45]=E,t[46]=b,t[47]=D):D=t[47];let O;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,$.jsx)(Z,{className:`size-4 shrink-0 text-fg-disabled`,"aria-hidden":!0}),t[48]=O):O=t[48];let k;return t[49]!==h||t[50]!==g||t[51]!==D||t[52]!==x||t[53]!==S?(k=(0,$.jsxs)(`button`,{type:x,className:S,onClick:h,children:[g,D,O]}),t[49]=h,t[50]=g,t[51]=D,t[52]=x,t[53]=S,t[54]=k):k=t[54],k}function wn(e,t){return zt()}function Tn(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:[Et()],additionalHeaders:r===`bearer`?t.filter(e=>e!==n):r===`oauth`?t:[]}}function En(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,Et(`Authorization`,`Bearer ${e}`)]}return t.mode===`apiKey`&&(r=[...r,Et(t.headerName.trim(),t.apiKey.trim())]),{...e,extra:n,headers:r,oauthClientId:t.mode===`oauth`?e.oauthClientId:``}}function Dn(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 On(){return p(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,q)}function kn({label:e,optionalLabel:t,addLabel:n,removeHeaderAria:r,pasteLabel:i,pasteFailed:a,pasteFailedTitle:o,dismissLabel:s,keyPlaceholder:c,valuePlaceholder:u,headers:d,onChange:f,referenceLabel:m=`Existing credential reference`,showValueLabel:h=`Show value`,hideValueLabel:g=`Hide value`,allowPaste:_=!0}){let[v,y]=(0,Q.useState)(new Set),[b,x]=(0,Q.useState)(!1),S=(e,t)=>{f(d.map((n,r)=>r===e?{...n,...t}:n))},C=()=>{f([...d,Et()])},w=e=>{let t=d.filter((t,n)=>n!==e);f(t.length>0?t:[Et()])},E=async()=>{try{let e=await T();if(!e){x(!0);return}let t=Ot(e);if(!t?.length){x(!0);return}f(t)}catch{x(!0)}};return(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 md:col-span-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium text-fg`,children:[(0,$.jsx)(`span`,{children:e}),t?(0,$.jsx)(`span`,{className:`font-normal text-fg-subtle`,children:t}):null]}),_?(0,$.jsxs)(z,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5 px-2 text-xs`,onClick:()=>void E(),children:[(0,$.jsx)(_e,{className:`size-3.5`,"aria-hidden":!0}),i]}):null]}),(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:d.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:p(On(),`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=>S(t,{key:e.target.value})}),(0,$.jsx)(`input`,{className:p(On(),`min-w-0 font-mono text-xs`),type:v.has(e.clientKey)?`text`:`password`,autoComplete:`off`,"aria-label":`${u} ${t+1}`,readOnly:!!e.reference,value:e.reference?m:e.value,placeholder:e.reference?m:u,onChange:e=>S(t,{value:e.target.value})}),(0,$.jsx)(z,{type:`button`,variant:`ghost`,className:`size-10 shrink-0 px-0`,disabled:!!e.reference,"aria-label":v.has(e.clientKey)?g:h,onClick:()=>y(t=>{let n=new Set(t);return n.has(e.clientKey)?n.delete(e.clientKey):n.add(e.clientKey),n}),children:v.has(e.clientKey)?(0,$.jsx)(Ze,{className:`size-4`,"aria-hidden":!0}):(0,$.jsx)(l,{className:`size-4`,"aria-hidden":!0})}),(0,$.jsx)(z,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 px-0`,disabled:d.length<=1&&!e.key&&!e.value,onClick:()=>w(t),"aria-label":r,children:(0,$.jsx)(H,{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:m}):null]},e.clientKey))}),(0,$.jsx)(ce,{open:b,title:o,description:a,confirmLabel:s,onConfirm:()=>x(!1),onCancel:()=>x(!1)}),(0,$.jsxs)(`button`,{type:`button`,className:p(`self-start text-sm text-accent hover:underline`,ee.press),onClick:C,children:[`+ `,n]})]})}var An=p(`w-full min-w-0 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,q);function jn(e){let t=(0,at.c)(20),{value:n,onChange:r,label:i,t:a,required:o}=e,s=o===void 0?!1:o,[c,u]=(0,Q.useState)(!1),d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=p(An,`mt-1.5`),t[0]=d):d=t[0];let f=c?`text`:`password`,m;t[1]===r?m=t[2]:(m=e=>r(e.target.value),t[1]=r,t[2]=m);let h;t[3]!==s||t[4]!==f||t[5]!==m||t[6]!==n?(h=(0,$.jsx)(`input`,{className:d,type:f,value:n,required:s,autoComplete:`off`,onChange:m}),t[3]=s,t[4]=f,t[5]=m,t[6]=n,t[7]=h):h=t[7];let g;t[8]!==i||t[9]!==h?(g=(0,$.jsxs)(`label`,{className:`block text-sm font-medium text-fg`,children:[i,h]}),t[8]=i,t[9]=h,t[10]=g):g=t[10];let _;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(_=()=>u(Mn),t[11]=_):_=t[11];let v;t[12]===c?v=t[13]:(v=c?(0,$.jsx)(Ze,{className:`size-4`,"aria-hidden":!0}):(0,$.jsx)(l,{className:`size-4`,"aria-hidden":!0}),t[12]=c,t[13]=v);let y=c?a.setupHideValue:a.setupShowValue,b;t[14]!==v||t[15]!==y?(b=(0,$.jsxs)(z,{type:`button`,variant:`ghost`,className:`gap-1.5 text-xs`,onClick:_,children:[v,y]}),t[14]=v,t[15]=y,t[16]=b):b=t[16];let x;return t[17]!==b||t[18]!==g?(x=(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[g,b]}),t[17]=b,t[18]=g,t[19]=x):x=t[19],x}function Mn(e){return!e}function Nn(e){let t=(0,at.c)(17),{headers:n,onChange:r,t:i,additional:a,environment:o}=e,s=a===void 0?!1:a,c=o===void 0?!1:o,l=c?i.envLabel:s?i.setupAdditionalHeaders:i.headersLabel,u=c?i.setupAddEnv:i.addHeader,d=c?i.setupRemoveEnv:i.removeHeader,f=c?i.setupEnvName:i.headerKeyPlaceholder,p=c?i.setupEnvValue:i.headerValuePlaceholder,m=!c,h;return t[0]!==n||t[1]!==r||t[2]!==i.optionalSuffix||t[3]!==i.pasteHeaders||t[4]!==i.pasteHeadersDismiss||t[5]!==i.pasteHeadersFailed||t[6]!==i.pasteHeadersFailedTitle||t[7]!==i.setupHideValue||t[8]!==i.setupReference||t[9]!==i.setupShowValue||t[10]!==l||t[11]!==u||t[12]!==d||t[13]!==f||t[14]!==p||t[15]!==m?(h=(0,$.jsx)(kn,{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 Pn(e){let t=(0,at.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=p(An,`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)(be,{value:e,children:i.setupAuthModes[e]},e)),t[4]=i.setupAuthModes,t[5]=f);let m;t[6]!==a||t[7]!==n.mode||t[8]!==i.setupAuthModes?(m=a||n.mode===`existing`?(0,$.jsx)(be,{value:`existing`,children:i.setupAuthModes.existing}):null,t[6]=a,t[7]=n.mode,t[8]=i.setupAuthModes,t[9]=m):m=t[9];let h;t[10]!==n.mode||t[11]!==i.setupAuthLabel||t[12]!==u||t[13]!==f||t[14]!==m?(h=(0,$.jsxs)(he,{"aria-label":s,className:c,value:l,onChange:u,children:[f,m]}),t[10]=n.mode,t[11]=i.setupAuthLabel,t[12]=u,t[13]=f,t[14]=m,t[15]=h):h=t[15];let g;t[16]!==i.setupAuthLabel||t[17]!==h?(g=(0,$.jsxs)(`label`,{className:`block text-sm font-medium text-fg`,children:[o,h]}),t[16]=i.setupAuthLabel,t[17]=h,t[18]=g):g=t[18];let _;t[19]!==n.mode||t[20]!==i.setupAuthAutoHint?(_=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]=_):_=t[21];let v;t[22]!==n.mode||t[23]!==i.setupAuthOAuthHint?(v=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]=v):v=t[24];let y;t[25]!==n.mode||t[26]!==i.setupExistingHint?(y=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]=y):y=t[27];let b;t[28]!==n.mode||t[29]!==n.token||t[30]!==r||t[31]!==i?(b=n.mode===`bearer`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(jn,{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]=b):b=t[32];let x;t[33]!==n.apiKey||t[34]!==n.headerName||t[35]!==n.mode||t[36]!==r||t[37]!==i?(x=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:p(An,`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)(jn,{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]=x):x=t[38];let S;t[39]!==n.customHeaders||t[40]!==n.mode||t[41]!==r||t[42]!==i?(S=n.mode===`headers`?(0,$.jsx)(Nn,{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]=S):S=t[43];let C;return t[44]!==g||t[45]!==_||t[46]!==v||t[47]!==y||t[48]!==b||t[49]!==x||t[50]!==S?(C=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[g,_,v,y,b,x,S]}),t[44]=g,t[45]=_,t[46]=v,t[47]=y,t[48]=b,t[49]=x,t[50]=S,t[51]=C):C=t[51],C}function Fn(e){let t=(0,at.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 In({row:e,t,onUpdate:n}){let[r,i]=(0,Q.useState)(()=>At(e.envJson?JSON.parse(e.envJson):void 0)),[a,o]=(0,Q.useState)(!1),s=[];try{s=Mt(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)(Fn,{label:t.setupArgsPaste,hint:t.argsHint,children:(0,$.jsx)(`input`,{className:An,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:An,"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)(H,{className:`size-4`,"aria-hidden":!0})})]},n)),a?null:(0,$.jsxs)(z,{type:`button`,variant:`ghost`,onClick:()=>c([...s,``]),children:[(0,$.jsx)(u,{className:`size-4`,"aria-hidden":!0}),t.setupAddArg]})]}),(0,$.jsx)(Nn,{environment:!0,headers:r,t,onChange:e=>{i(e),n({envEntries:e,envJson:JSON.stringify(kt(e)??{})})}})]})}function Ln(e){let t=(0,at.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?!1:o,u=s===void 0?!1: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)(Fn,{label:`${r.commandLabel} *`,children:(0,$.jsx)(`input`,{"data-field":`command`,className:An,value:n.command,required:!0,onChange:e=>i({command:e.target.value})})}),(0,$.jsx)(In,{row:n,t:r,onUpdate:i})]}):(0,$.jsx)(Fn,{label:`${r.urlLabel} *`,children:(0,$.jsx)(`input`,{"data-field":`url`,className:An,value:n.url,placeholder:`https://example.com/mcp`,required:!0,onChange:e=>i({url:e.target.value})})}),(0,$.jsx)(Fn,{label:r.setupNameLabel,hint:r.setupNameHint,children:(0,$.jsx)(`input`,{className:An,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)(Fn,{label:r.serverIdLabel,hint:r.setupIdHint,children:(0,$.jsx)(`input`,{className:An,readOnly:u,value:n.id,onChange:e=>i({id:e.target.value}),placeholder:r.serverIdPlaceholder})}),n.transport===`stdio`?(0,$.jsx)(Fn,{label:r.cwdLabel,children:(0,$.jsx)(`input`,{className:An,value:n.cwd,onChange:e=>i({cwd:e.target.value})})}):null,n.transport!==`stdio`&&l?(0,$.jsx)(Fn,{label:r.oauthClientIdLabel,hint:r.oauthClientIdHint,children:(0,$.jsx)(`input`,{className:An,value:n.oauthClientId,onChange:e=>i({oauthClientId:e.target.value})})}):null,(0,$.jsx)(Fn,{label:r.exposureLabel,hint:r.setupExposureHint,children:(0,$.jsx)(he,{"aria-label":r.exposureLabel,className:An,value:n.exposure,onChange:e=>i({exposure:e.target.value}),children:[`codemode`,`deferred`,`direct`,`hidden`].map(e=>(0,$.jsx)(be,{value:e,children:r.exposureLabels[e]},e))})}),(0,$.jsx)(Fn,{label:r.requestTimeoutLabel,children:(0,$.jsx)(it,{allowEmpty:!0,type:`number`,min:1,className:An,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 Rn(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 zn(e,t){return JSON.stringify({id:e.id,config:Vt(En(e,t))})}function Bn(e,t){try{return zn(e,t)}catch{return JSON.stringify({row:e,auth:t})}}function Vn(e){let{t,cs:n}=e,r=(0,Q.useId)(),[i,a]=(0,Q.useState)(e.initialRow),[s,l]=(0,Q.useState)(()=>Tn(e.initialRow)),[u,f]=(0,Q.useState)(`idle`),[m,h]=(0,Q.useState)(``),[g,_]=(0,Q.useState)(!1),[b,T]=(0,Q.useState)(),[E,D]=(0,Q.useState)(),[O,k]=(0,Q.useState)(),[j,M]=(0,Q.useState)(!1),[N,P]=(0,Q.useState)(!1),[F,ee]=(0,Q.useState)(``),[I,L]=(0,Q.useState)(``),[B,V]=(0,Q.useState)([]),[H,U]=(0,Q.useState)(`0`),[te,W]=(0,Q.useState)(0),[G,K]=(0,Q.useState)(``),[q,J]=(0,Q.useState)(!1),[ne,re]=(0,Q.useState)(!1),ie=e.mode===`edit`,[ae,oe]=(0,Q.useState)(``),Y=(0,Q.useRef)(void 0),[se]=(0,Q.useState)(()=>Bn(e.initialRow,Tn(e.initialRow))),le=(0,Q.useRef)(e.mode===`edit`?e.initialRow.id:``),ue=(0,Q.useRef)(void 0),de=(0,Q.useRef)(void 0),X=(0,Q.useRef)(void 0),fe=(0,Q.useRef)(null),pe=(0,Q.useRef)(``),me=(0,Q.useRef)(!0),Z=(0,Q.useRef)(null),ge=(0,Q.useRef)(null),_e=(0,Q.useRef)(null),ve=(0,Q.useRef)(null),ye=(0,Q.useRef)(e.onSaved);ye.current=e.onSaved;let xe=O?.state===`starting`||O?.state===`authorizing`,Se=u!==`idle`||xe,Ce=se!==Bn(i,s),we=i.extra.enabled===!1,Te=!g&&(Ce||!!F.trim());(0,Q.useEffect)(()=>(me.current=!0,()=>{me.current=!1,ue.current?.abort(),fe.current?.close(),Y.current&&Gt(Y.current).catch(()=>{})}),[]),(0,Q.useEffect)(()=>{if(!Te)return;let e=e=>{e.preventDefault(),e.returnValue=``};return window.addEventListener(`beforeunload`,e),()=>window.removeEventListener(`beforeunload`,e)},[Te]),(0,Q.useEffect)(()=>{if(!b)return;let e=_e.current?.querySelector(`[data-field="${b.field}"]`),t=e?.closest(`details`);t&&(t.open=!0);let n=e?.querySelector(`input,button,textarea`)??e;return n?.setAttribute(`aria-invalid`,`true`),n?.setAttribute(`aria-describedby`,r),b.focus!==!1&&(n??ve.current)?.focus(),()=>{n?.removeAttribute(`aria-invalid`),n?.removeAttribute(`aria-describedby`)}},[b,r]),(0,Q.useEffect)(()=>{if(!O||!xe)return;let e=new AbortController;de.current=e;let n;async function r(){try{let n=await Jt(Y.current,e.signal);if(e.signal.aborted||(k(n),n.authorizationUrl&&pe.current!==n.authorizationUrl&&(pe.current=n.authorizationUrl,window.electronAPI?.shell?.openExternalUrl?!(await window.electronAPI.shell.openExternalUrl(n.authorizationUrl)).ok&&!e.signal.aborted&&h(t.oauthOpenFailed):fe.current&&!fe.current.closed&&fe.current.location.replace(n.authorizationUrl)),e.signal.aborted))return;if(n.state===`connected`){X.current=void 0,fe.current?.close(),D({state:`connected`,toolCount:n.toolCount}),h(``);return}if(n.state===`error`||n.state===`cancelled`){X.current=void 0,fe.current?.close(),h(n.state===`cancelled`?t.setupCancelled:t.setupAuthFailed),/client.{0,20}(id|registration)|register|registration/i.test(n.error??``)&&M(!0);return}}catch{if(e.signal.aborted)return;Ee(),fe.current?.close(),h(t.setupAuthFailed);return}n=setTimeout(()=>void r(),1200)}return r(),()=>{e.abort(),clearTimeout(n)}},[O?.id,xe,t.oauthOpenFailed,t.setupCancelled,t.setupAuthFailed]);function Ee(){ue.current?.abort(),de.current?.abort(),Y.current&&Gt(Y.current).catch(()=>{}),Y.current=void 0,oe(``),J(!1),D(void 0),k(void 0),h(``),T(void 0)}function De(e){a(t=>({...t,...e})),Ee()}function Oe(e){l(t=>({...t,...e})),Ee()}function ke(){u===`saving`||xe||(u===`checking`&&(Ee(),f(`idle`)),Te?re(!0):e.onClose())}function Ae(){try{V(Rt(F)),U(`0`),L(``)}catch{L(t.setupImportError),V([])}}function je(){let t=B[Number(H)];if(!t)return;let n={...t,id:le.current||t.id,clientKey:e.initialRow.clientKey,extra:{...t.extra,...le.current?{enabled:i.extra.enabled}:{}}};a(n),l(Tn(n)),Ee(),W(e=>e+1),P(!1),ee(``),V([])}function Me(e){function n(e,t){return T({field:e,message:t}),!1}if(e.transport===`streamable-http`){try{e.url=Lt(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(Dn(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{Vt(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 Ne(){h(``),f(`checking`),pe.current=``,window.electronAPI?.shell?.openExternalUrl||(fe.current=window.open(`about:blank`,`_blank`),fe.current&&(fe.current.opener=null));try{let e=await qt(Y.current);if(!me.current){fe.current?.close(),Y.current&&Gt(Y.current).catch(()=>{});return}X.current=e.id,k(e)}catch{fe.current?.close(),me.current&&h(t.setupAuthFailed)}finally{me.current&&f(`idle`)}}async function Pe(){let r=En(i,s);if(!Me(r))return;let o=e.existingCustomServers.filter(t=>t.clientKey!==e.initialRow.clientKey&&t.id!==le.current),c=new Set([...e.managedServerIds,...o.map(e=>e.id)]);if(r.id=le.current||r.id.trim()||It(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}Ee(),f(`checking`);let l=new AbortController;ue.current=l;try{let n=await Ut(r,le.current||void 0,e.initialRow.extra,l.signal);if(!me.current||l.signal.aborted){Gt(n.id).catch(()=>{});return}Y.current=n.id,a(r),oe(Bn(r,s));let i=await Wt(n.id,l.signal);if(!me.current||l.signal.aborted)return;D(i),i.state===`error`&&h(Rn(i,t))}catch(e){me.current&&!l.signal.aborted&&h(e.status===409?t.setupConflict:Rn(e,t))}finally{me.current&&ue.current===l&&f(`idle`)}}async function Fe(n=!1){if(!(!Y.current||E?.state!==`connected`||ae!==Bn(i,s))){f(`saving`),h(``);try{let t=await Kt(Y.current,n);Y.current=void 0,await ye.current().catch(()=>{}),t?.reloadRequired?_(!0):e.onClose()}catch(e){let n=e.status;n===404||n===409?(Ee(),h(t.setupConflict)):h(t.setupSaveFailed)}finally{me.current&&f(`idle`)}}}async function Ie(){de.current?.abort();let e=Y.current;X.current=void 0,k(void 0),fe.current?.close(),h(t.setupCancelled),f(`checking`);try{e&&await Yt(e)}catch{me.current&&(Ee(),h(t.setupCancelled))}finally{me.current&&f(`idle`)}}async function Le(){O?.authorizationUrl&&(window.electronAPI?.shell?.openExternalUrl?(await window.electronAPI.shell.openExternalUrl(O.authorizationUrl)).ok||h(t.oauthOpenFailed):window.open(O.authorizationUrl,`_blank`,`noopener,noreferrer`))}async function Re(){if(O)try{await Xt(Y.current,G),K(``),h(``)}catch{h(t.setupRedirectInvalid)}}let ze=!!Y.current&&ae===Bn(i,s)&&(s.mode===`oauth`||s.mode===`auto`&&E?.state===`oauth_required`)&&E?.state!==`connected`,Be=/^(?:https?:\/\/)?(?:localhost|127\.0\.0\.1|\[::1\])(?=[:/]|$)/i.test(i.url.trim()),Ve=B[Number(H)];return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(w,{open:e.open,onOpenChange:e=>{e||ke()},children:(0,$.jsxs)(x,{children:[(0,$.jsx)(v,{className:`fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(S,{ref:Z,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(),Z.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)(C,{className:`font-semibold`,children:e.mode===`edit`?t.setupEditTitle:t.setupTitle}),(0,$.jsx)(y,{className:`mt-1 text-sm text-fg-muted`,children:t.setupHint})]}),(0,$.jsx)(`button`,{type:`button`,disabled:u===`saving`||xe,onClick:ke,className:`rounded-lg p-2 text-fg-muted hover:bg-surface-hover disabled:opacity-50`,"aria-label":n.modalClose,children:(0,$.jsx)(d,{className:`size-5`,"aria-hidden":!0})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-5`,children:[N?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(z,{variant:`ghost`,onClick:()=>P(!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:p(An,`mt-1.5 min-h-40 font-mono text-xs`),value:F,placeholder:`{"mcpServers": {"docs": {"url": "https://example.com/mcp"}}}`,onChange:e=>{ee(e.target.value),V([]),L(``)}})]}),(0,$.jsx)(z,{variant:`secondary`,disabled:!F.trim(),onClick:Ae,children:t.setupImportPreview}),I?(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:I}):null,Ve?(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)(he,{"aria-label":t.setupImportChoose,className:p(An,`mt-1.5`),value:H,onChange:e=>U(e.target.value),children:B.map((e,t)=>(0,$.jsx)(be,{value:String(t),children:e.displayName||e.id||rn(e)},t))})]}),(0,$.jsxs)(`p`,{className:`break-all text-sm text-fg-muted`,children:[Ve.transport===`stdio`?t.setupUseCommand:t.setupUseUrl,` · `,rn(Ve)]})]}):null]}):(0,$.jsxs)(`form`,{ref:_e,noValidate:!0,onBlurCapture:e=>{if(e.target instanceof HTMLInputElement&&e.target.dataset.field===`url`&&i.url.trim())try{Lt(i.url)}catch{T({field:`url`,message:t.setupAddressInvalid,focus:!1})}},onSubmit:e=>{e.preventDefault(),Pe()},children:[(0,$.jsxs)(`fieldset`,{disabled:Se||g,className:`min-w-0 space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsx)(A,{className:`flex gap-1`,role:`group`,"aria-label":t.transportLabel,children:[`streamable-http`,`stdio`].map(e=>(0,$.jsx)(z,{type:`button`,variant:i.transport===e?`secondary`:`ghost`,"aria-pressed":i.transport===e,onClick:()=>De({transport:e}),children:e===`stdio`?t.setupUseCommand:t.setupUseUrl},e))}),(0,$.jsx)(z,{type:`button`,variant:`ghost`,onClick:()=>P(!0),children:t.setupImport})]}),(0,$.jsx)(`div`,{children:(0,$.jsx)(Ln,{row:i,t,variant:`basic`,onUpdate:De},`${i.transport}-${te}`)}),i.transport===`streamable-http`?(0,$.jsx)(`div`,{"data-field":`auth`,children:(0,$.jsx)(Pn,{allowExisting:!!i.extra.auth||i.headers.some(e=>!!e.reference),draft:s,onChange:Oe,t})}):null,b?(0,$.jsx)(`p`,{id:r,ref:ve,tabIndex:-1,role:`alert`,className:`text-sm text-danger`,children:b.message}):null,(0,$.jsxs)(`details`,{"data-field":`advanced`,className:`rounded-lg border border-edge p-3`,open:j,onToggle:e=>M(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)(Ln,{row:i,t,variant:`advanced`,idReadOnly:ie,showOAuth:s.mode===`oauth`,onUpdate:De}),i.transport===`streamable-http`&&s.mode!==`headers`&&s.mode!==`existing`?(0,$.jsx)(Nn,{additional:!0,headers:s.additionalHeaders,onChange:e=>Oe({additionalHeaders:e}),t}):null]})]}),(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:i.transport===`stdio`?t.setupCommandHostHint:Be?t.setupLocalhostHint:t.setupGatewayHint}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.setupTestNotice})]}),(0,$.jsx)(`button`,{type:`submit`,hidden:!0})]}),g?(0,$.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-fg`,children:t.setupReloadRequired}):null,!N&&!g?(0,$.jsxs)(`div`,{className:`mt-4 space-y-3`,"aria-live":`polite`,children:[u===`idle`?null:(0,$.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,$.jsx)(R,{className:`size-4 animate-spin motion-reduce:animate-none`,"aria-hidden":!0}),u===`saving`?t.setupSaving:t.setupChecking]}),u===`idle`&&ie&&!Ce&&!E&&!m&&!xe?(0,$.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:we?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)(o,{className:`size-4 shrink-0`,"aria-hidden":!0}),E.toolCount?t.setupConnected.replace(`{{count}}`,String(E.toolCount)):t.setupZeroTools]}),(0,$.jsx)(z,{ref:ge,variant:`secondary`,onClick:()=>J(!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===`oauth_required`&&!xe?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.setupOAuthRequired}):null,xe?(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)(R,{className:`size-4 animate-spin motion-reduce:animate-none`,"aria-hidden":!0}),t.setupAuthorizing]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[O?.authorizationUrl?(0,$.jsxs)(z,{variant:`secondary`,onClick:()=>void Le(),children:[(0,$.jsx)(c,{className:`size-4`,"aria-hidden":!0}),t.oauthOpenAuthorization]}):null,(0,$.jsx)(z,{variant:`ghost`,onClick:()=>void Ie(),children:t.setupCancelAuth})]}),O?.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:An,value:G,onChange:e=>K(e.target.value)})]}),(0,$.jsx)(z,{className:`mt-2`,disabled:!G.trim(),onClick:()=>void Re(),children:t.setupContinue})]}):null]}):null,m?(0,$.jsxs)(`div`,{role:`alert`,className:`space-y-1 text-sm`,children:[(0,$.jsx)(`p`,{className:`text-danger`,children:m}),m!==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`||xe,onClick:ke,children:ie||g?t.setupClose:n.modalCancel}),g?null:N?(0,$.jsx)(z,{variant:`primary`,disabled:!Ve,onClick:je,children:t.setupImportApply}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(z,{variant:E?.state===`connected`?`secondary`:`primary`,disabled:Se,onClick:()=>ze?void Ne():void Pe(),children:ze?t.setupSignIn:t.setupTestConnection}),E?.state===`connected`&&ae===Bn(i,s)?(0,$.jsxs)($.Fragment,{children:[we?(0,$.jsx)(z,{variant:`secondary`,disabled:Se,onClick:()=>void Fe(!0),children:t.setupEnableSave}):null,(0,$.jsx)(z,{variant:`primary`,disabled:Se,"aria-busy":Se,onClick:()=>void Fe(),children:ie?t.setupSaveOnly:t.setupAddConnection})]}):null]})]})]})]})}),(0,$.jsx)(ce,{open:ne,title:t.setupUnsavedTitle,description:t.setupUnsavedHint,confirmLabel:t.setupDiscard,cancelLabel:t.setupKeepEditing,onCancel:()=>re(!1),onConfirm:e.onClose,overlayClassName:`z-[70]`,contentClassName:`z-[70]`}),q?(0,$.jsx)(en,{draftId:Y.current,serverId:i.id,displayName:i.displayName,returnFocusTo:ge.current,t,onClose:()=>J(!1)}):null]})}var Hn=`builtin`,Un=`composio`,Wn=`xopc-store`;function Gn(e){return Hn}function Kn(e){let t=e.connectorManifest;if(!t||typeof t!=`object`||Array.isArray(t))return null;let n=t;if(n.contractVersion!==1||n.id!==e.name)return null;let r=n.runtime,i=n.auth;if(!r||typeof r!=`object`||Array.isArray(r)||!i||typeof i!=`object`||Array.isArray(i))return null;let a=r,o=i;if(a.type!==`mcp`||typeof a.serverId!=`string`)return null;let s=[`code`,`docs`,`browser`,`data`,`automation`,`custom`].includes(String(n.category??``))?n.category:`custom`,c=o.mode===`oauth`?{mode:`oauth`,...typeof o.clientId==`string`?{clientId:o.clientId}:{}}:o.mode===`apiKey`?{mode:`apiKey`}:{mode:`none`};return{id:e.name,version:e.latestVersion??`store`,displayName:typeof n.displayName==`string`?n.displayName:e.name,description:typeof n.description==`string`?n.description:e.description,category:s,kind:`mcp`,source:`store`,...e.branding?.iconUrl?{branding:{logoUrl:e.branding.iconUrl,source:`registry`}}:{},capabilities:Array.isArray(n.capabilities)?n.capabilities.filter(e=>typeof e==`string`):[],tags:Array.isArray(n.tags)?n.tags.filter(e=>typeof e==`string`):[`store`],auth:c,setup:n.setup&&typeof n.setup==`object`&&!Array.isArray(n.setup)?n.setup:{},runtime:{type:`mcp`,serverId:a.serverId}}}function qn(e){return e.filter((e,t,n)=>n.findIndex(t=>t.id===e.id)===t)}function Jn(e){return e?.startsWith(`/`)&&!e.startsWith(`//`)?e:`/user-model`}function Yn({embedded:e=!1,onHeaderActionChange:t}){let n=Qe().filter(on),r=g(e=>e.language),o=f(r),s=o.connectorsSettings,c=o.mcpSettings,l=h(e=>e.conversationId),u=!!l,d=i(),[m,_]=a(),v=m.get(`understanding`)===`1`,y=Jn(m.get(`returnTo`)),b=!!m.get(`returnTo`)&&!v,x=m.get(`tab`),[S,C]=(0,Q.useState)(!v&&x===`connected`?`connected`:`discover`),w=(0,Q.useRef)(!1),[T,E]=(0,Q.useState)({catalog:[],registryCatalog:[],instances:[],loading:!0,error:null}),[O,k]=(0,Q.useState)(!1),[j,M]=(0,Q.useState)(!1),[N,F]=(0,Q.useState)(1),[ee,B]=(0,Q.useState)(void 0),[V,H]=(0,Q.useState)(``),[U,te]=(0,Q.useState)(v||b?m.get(`connector`)??``:``),[W,G]=(0,Q.useState)(Gn(v?`understanding`:`default`)),[K,q]=(0,Q.useState)(`name`),[J,ne]=(0,Q.useState)(v?`understand`:`all`),[re,ie]=(0,Q.useState)(null),[se,ce]=(0,Q.useState)(null),[ue,X]=(0,Q.useState)(null),[fe,pe]=(0,Q.useState)(null),[me,Z]=(0,Q.useState)(null),[he,ge]=(0,Q.useState)(null),{data:_e,mutate:ve}=D(u),ye=_e?.payload?.config,be=(0,Q.useMemo)(()=>ye===void 0?null:Bt(ye),[ye]),xe=be?.servers??[],Se=T.instances.length+xe.length+n.length,[Te,Ee]=(0,Q.useState)({});(0,Q.useEffect)(()=>{if(Ee({}),!u||!ye)return;let e=new AbortController;return Qt(e.signal).then(t=>{e.signal.aborted||Ee(t)}).catch(()=>{}),()=>e.abort()},[u,ye]);let De=(0,Q.useCallback)(async()=>{if(!l){E({catalog:[],registryCatalog:[],instances:[],loading:!1,error:null});return}E(e=>({...e,loading:!0,error:null}));try{let[e,t]=await Promise.all([Ce(),de()]);E(n=>({catalog:e,registryCatalog:n.registryCatalog,instances:t,loading:!1,error:null}))}catch(e){E({catalog:[],registryCatalog:[],instances:[],loading:!1,error:e instanceof Error?e.message:String(e)})}},[l]);(0,Q.useEffect)(()=>{De()},[De]),(0,Q.useEffect)(()=>{w.current||T.loading||u&&!be||(C(v?`discover`:Se>0?`connected`:`discover`),w.current=!0)},[u,Se,be,v,T.loading]);let Oe=(0,Q.useCallback)(e=>{w.current=!0,C(e)},[]),ke=(0,Q.useMemo)(()=>[{id:Un,displayName:s.composioSourceName},{id:Wn,displayName:s.storeSourceName}],[s.composioSourceName,s.storeSourceName]),Ae=(0,Q.useCallback)(async e=>{if(!u||W===`builtin`){E(e=>({...e,registryCatalog:[]})),F(1),B(void 0);return}let t=U.trim(),n=Math.max(e?.page??1,1),r=e?.append??!1,i=W===`all`?ke:ke.filter(e=>e.id===W);if(i.length!==0){k(!0),r?E(e=>({...e,error:null})):(F(1),B(void 0),E(e=>({...e,registryCatalog:[],error:null})));try{let e=await Promise.all(i.map(async e=>{if(e.id===`composio`){let e=await Ie({q:t||void 0,page:n,pageSize:24,verification:`experimental`});return{connectors:e.connectors,totalPages:e.meta.totalPages}}let r=await Me({q:t||void 0,page:n,pageSize:24,sort:K===`source`?`newest`:`downloads`});return{connectors:r.items.flatMap(e=>{let t=Kn(e);return t?[t]:[]}),totalPages:r.meta.totalPages}})),a=qn(e.flatMap(e=>e.connectors)),o=Math.max(1,...e.map(e=>e.totalPages??1));F(n),B(o),E(e=>({...e,registryCatalog:r?qn([...e.registryCatalog,...a]):a}))}catch(e){E(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{k(!1)}}},[K,U,W,u,ke]);(0,Q.useEffect)(()=>{if(S!==`discover`||T.loading)return;if(W===`builtin`){E(e=>({...e,registryCatalog:[]})),F(1),B(void 0);return}let e=window.setTimeout(()=>{Ae()},U.trim()?350:0);return()=>window.clearTimeout(e)},[U,W,Ae,T.loading,S]);let je=(0,Q.useMemo)(()=>new Set(T.instances.map(e=>e.connectorId)),[T.instances]),Ne=(0,Q.useMemo)(()=>new Map([...T.catalog,...T.registryCatalog].map(e=>[e.id,e])),[T.catalog,T.registryCatalog]);(0,Q.useEffect)(()=>{if(T.loading)return;let e=m.get(`connector`),t=m.get(`instance`);if(!e&&!t)return;let n=T.instances.find(n=>t?n.instanceId===t:n.connectorId===e);if(n)w.current=!0,H(``),X(n.instanceId),pe(n),C(`connected`);else if(e){let t=Ne.get(e);if(!t)return;w.current=!0,G(Gn(v?`understanding`:`default`)),te(``),ce(t),C(`discover`)}let r=new URLSearchParams(m);r.delete(`connector`),r.delete(`instance`),r.set(`tab`,n?`connected`:`discover`),_(r,{replace:!0})},[Ne,v,m,_,T.instances,T.loading]);let Pe=(0,Q.useCallback)(async e=>{M(!0),E(e=>({...e,error:null}));try{let t=await ze(e);ie(I(t.definition,{packageName:t.packageName,version:t.version,reviewHash:t.reviewHash,permissions:t.permissions}))}catch(e){E(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{M(!1)}},[]),Fe=(0,Q.useMemo)(()=>new Set(T.instances.flatMap(e=>e.materialized.type===`mcp`?[e.materialized.serverId]:[])),[T.instances]),Le=(0,Q.useCallback)(async e=>{let t=await $t(e);await ve(),await De(),t.reloadRequired&&E(e=>({...e,error:c.setupReloadRequired}))},[De,ve,c.setupReloadRequired]),Re=(0,Q.useCallback)(()=>{ge({mode:`add`,row:wn(xe,Fe)})},[xe,Fe]),Be=P(e=>e.setPageHeader),Ve=P(e=>e.clearPageHeader),He=(0,Q.useMemo)(()=>({searchLabel:S===`connected`?s.connectedSearchPlaceholder:s.discoverSearchPlaceholder,search:(0,$.jsx)(et,{value:S===`connected`?V:U,onChange:S===`connected`?H:te,placeholder:S===`connected`?s.connectedSearchPlaceholder:s.discoverSearchPlaceholder}),secondary:(0,$.jsx)(Tt,{onRefresh:S===`connected`&&u?De:void 0,refreshing:T.loading,refreshLabel:s.refreshConnections,onBrowseCatalog:()=>Oe(`discover`),onAddCustomServer:Re,addLabel:s.addConnection,browseLabel:s.addFromCatalog,customLabel:s.addCustomServerAdvanced,serviceLabel:r.startsWith(`zh`)?`应用连接服务`:`Connection service`,moreActionsLabel:o.capabilitiesHub.moreActions})}),[V,s,U,u,r,De,o.capabilitiesHub.moreActions,Re,Oe,T.loading,S]);(0,Q.useLayoutEffect)(()=>e?(t?.(He),()=>t?.(null)):(Be({startExtra:null,main:(0,$.jsx)(`div`,{className:`min-w-0`,children:(0,$.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:s.title})}),end:(0,$.jsx)(tt,{contribution:He})}),()=>Ve()),[Ve,s.title,e,He,t,Be]);let Ue=(0,Q.useMemo)(()=>T.instances.map(e=>({instance:e,value:_t(e,Ne.get(e.connectorId))})),[Ne,T.instances]),We=(0,Q.useMemo)(()=>new Map(Ue.map(({instance:e,value:t})=>[e.instanceId,t])),[Ue]),Ke=(0,Q.useMemo)(()=>T.instances.filter(e=>ae(e,V)).sort((e,t)=>{let n={needs_setup:0,checking:1,ready:2},r=We.get(e.instanceId)?.state??`checking`,i=We.get(t.instanceId)?.state??`checking`;return n[r]-n[i]||e.displayName.localeCompare(t.displayName)}),[V,We,T.instances]),qe=(0,Q.useMemo)(()=>Ke.filter(e=>We.get(e.instanceId)?.state===`needs_setup`),[We,Ke]),Je=(0,Q.useMemo)(()=>Ke.filter(e=>We.get(e.instanceId)?.state!==`needs_setup`),[We,Ke]),Ye=(0,Q.useMemo)(()=>xe.filter(e=>L(e,V)),[V,xe]),Xe=(0,Q.useMemo)(()=>{let e=V.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))},[V,n]),Ze=Ke.length+Ye.length+Xe.length,nt=(0,Q.useMemo)(()=>T.catalog.filter(e=>e.source===`builtin`&&e.integrationStrategy?.preferred!==!1&&le(e)),[T.catalog]),rt=(0,Q.useMemo)(()=>W===`builtin`?nt:W===`all`?qn([...nt,...T.registryCatalog]):T.registryCatalog,[nt,W,T.registryCatalog]),it=(0,Q.useMemo)(()=>{let e=v?rt.filter(e=>e.understanding?.mode===`activity`):rt;return Y(J===`all`?e:e.filter(e=>ht(e).includes(J)),U,K)},[K,U,rt,v,J]),at=(0,Q.useMemo)(()=>mt.filter(e=>rt.some(t=>ht(t).includes(e))),[rt]);(0,Q.useEffect)(()=>{J!==`all`&&!at.includes(J)&&ne(`all`)},[at,J]);let st=S===`discover`&&W!==`builtin`&&!!(ee&&N<ee),ut=(0,Q.useMemo)(()=>T.instances.find(e=>e.instanceId===ue)??fe,[ue,fe,T.instances]),ft=(0,Q.useMemo)(()=>[{value:`all`,label:s.discoverSourceAll},{value:Hn,label:s.discoverSourceBuiltin},...ke.map(e=>({value:e.id,label:e.displayName}))],[s.discoverSourceAll,s.discoverSourceBuiltin,ke]),gt=[{id:`connected`,label:s.tabConnected,count:Se},{id:`discover`,label:s.tabDiscover}];return(0,$.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:(0,$.jsxs)(`div`,{className:p(`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:[u?null:(0,$.jsx)(`p`,{className:`rounded-xl border border-edge bg-surface-panel px-4 py-3 text-sm text-fg-muted`,children:s.tokenHint}),v?(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border border-accent/25 bg-accent-soft px-4 py-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:s.understandingSetupTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:s.understandingSetupHint})]}),(0,$.jsx)(z,{type:`button`,variant:`secondary`,className:`shrink-0`,onClick:()=>d(y),children:s.understandingSetupDone})]}):null,b?(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border border-accent/25 bg-accent-soft px-4 py-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:s.recoverySetupTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:s.recoverySetupHint})]}),(0,$.jsx)(z,{type:`button`,variant:`secondary`,className:`min-h-11 shrink-0`,onClick:()=>d(y),children:s.recoverySetupDone})]}):null,(0,$.jsxs)(`section`,{className:`flex flex-col gap-4`,children:[(0,$.jsx)(`div`,{className:`border-b border-edge-subtle pb-3 dark:border-edge-subtle`,children:(0,$.jsx)(we,{items:gt,activeTab:S,onChange:Oe,ariaLabel:s.navAria,tabIdPrefix:`connectors-tab`,panelIdPrefix:`connectors-panel`,className:`flex-wrap`})}),T.error?(0,$.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:T.error}):null,S===`connected`&&u?(0,$.jsx)(`div`,{className:`flex flex-col gap-6`,children:T.loading?(0,$.jsx)(`div`,{className:`grid gap-3`,"aria-busy":`true`,"aria-label":s.loading,children:ct.slice(0,3).map(e=>(0,$.jsx)(pt,{},e))}):Se===0?(0,$.jsxs)(`div`,{className:`py-14 text-center`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:s.connectionsEmpty}),(0,$.jsx)(z,{type:`button`,variant:`primary`,className:`mt-4`,onClick:()=>Oe(`discover`),children:s.addFromCatalog})]}):Ze===0?(0,$.jsx)(`div`,{className:`py-14 text-center text-sm text-fg-muted`,children:s.connectionsSearchEmpty}):(0,$.jsxs)(`div`,{className:`space-y-6`,children:[qe.length?(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:s.needsAttentionTitle}),(0,$.jsx)(`span`,{className:`text-xs tabular-nums text-amber-700 dark:text-amber-300`,children:qe.length})]}),(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-xl border border-amber-500/25 bg-amber-500/5`,children:qe.map(e=>(0,$.jsx)(Cn,{instance:e,definition:Ne.get(e.connectorId),highlighted:e.instanceId===me,onOpenDetails:e=>{Z(null),X(e.instanceId),pe(e)},t:s},e.instanceId))})]}):null,Je.length?(0,$.jsx)(`section`,{children:(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-xl border border-edge bg-surface-base`,children:Je.map(e=>(0,$.jsx)(Cn,{instance:e,definition:Ne.get(e.connectorId),highlighted:e.instanceId===me,onOpenDetails:e=>{Z(null),X(e.instanceId),pe(e)},t:s},e.instanceId))})}):null,Xe.length?(0,$.jsx)(`section`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-xl border border-edge bg-surface-base`,children:Xe.map(e=>(0,$.jsx)(sn,{extension:e,language:r,onOpen:()=>d($e(e.pluginId,`connections`,e.authorizationStatus===`required`))},e.id))}):null,Ye.length||!V.trim()?(0,$.jsxs)(`section`,{"aria-label":s.customIntegrationsTitle,className:`rounded-xl border border-edge bg-surface-base`,children:[(0,$.jsxs)(`div`,{className:`px-4 py-3`,children:[(0,$.jsx)(`h2`,{className:`inline text-sm font-medium text-fg`,children:s.customIntegrationsTitle}),(0,$.jsx)(`span`,{className:`ml-2 text-xs tabular-nums text-fg-subtle`,children:Ye.length}),(0,$.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:s.customIntegrationsHint})]}),(0,$.jsxs)(`div`,{className:`border-t border-edge-subtle`,children:[(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2 px-4 py-3`,children:(0,$.jsx)(z,{type:`button`,variant:`secondary`,className:`h-8 text-xs`,onClick:Re,children:s.addCustomServerAdvanced})}),(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle`,children:Ye.map(e=>(0,$.jsx)(an,{row:e,lastCheck:Te[e.id],t:c,cs:s,onEdit:()=>ge({mode:`edit`,row:structuredClone(e)}),onRemove:async()=>Le(e)},e.clientKey))})]})]}):null]})}):null,S===`discover`&&u?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[v?null:(0,$.jsx)(A,{className:`flex min-w-0 flex-1 basis-80 flex-wrap gap-2`,role:`group`,"aria-label":s.taskFilterAria,indicatorClassName:`rounded-lg bg-surface-active`,children:[`all`,...at].map(e=>(0,$.jsx)(`button`,{type:`button`,className:p(`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors`,J===e?`border-accent/40 bg-accent-soft text-accent-fg`:`border-edge bg-surface-panel text-fg-muted hover:bg-surface-hover hover:text-fg`),"aria-pressed":J===e,onClick:()=>ne(e),children:e===`all`?s.taskAll:s.connectorBenefitHeadings[e]},e))}),(0,$.jsxs)(`div`,{className:p(`ml-auto grid w-full gap-2 sm:flex sm:w-auto sm:justify-end`,v?`grid-cols-1`:`grid-cols-2`),children:[v?null:(0,$.jsx)(`div`,{className:`min-w-0 sm:w-40`,children:(0,$.jsx)(Ge,{value:W,options:ft,placeholder:s.discoverSourceAll,allowEmpty:!1,ariaLabel:s.registrySourceAria,triggerClassName:`h-9 bg-surface-panel text-xs`,onChange:G})}),(0,$.jsx)(`div`,{className:`min-w-0 sm:w-40`,children:(0,$.jsx)(Ge,{value:K,options:[{value:`name`,label:s.sortName},{value:`source`,label:s.sortSource}],placeholder:s.sortName,allowEmpty:!1,ariaLabel:s.sortAria,triggerClassName:`h-9 bg-surface-panel text-xs`,onChange:e=>q(e)})})]})]}),(T.loading||O)&&it.length===0?(0,$.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,"aria-busy":`true`,"aria-label":s.loading,children:ct.map(e=>(0,$.jsx)(dt,{},e))}):it.length===0?(0,$.jsx)(`div`,{className:`py-14 text-center text-sm text-fg-muted`,children:s.discoverEmpty}):(0,$.jsxs)(`div`,{className:`relative`,children:[O?(0,$.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-[1] flex justify-center bg-surface-panel/40 pt-[min(28vh,7.5rem)] backdrop-blur-[1px] motion-reduce:backdrop-blur-none dark:bg-surface-base/35`,"aria-busy":`true`,"aria-label":s.loading,children:(0,$.jsx)(R,{className:`size-8 shrink-0 animate-spin text-accent motion-reduce:animate-none`,strokeWidth:2,"aria-hidden":!0})}):null,(0,$.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:it.map(e=>(0,$.jsx)(ot,{connector:e,installed:je.has(e.id)||lt(e,T.instances),onInstall:e=>{if(e.source===`store`){Pe(e.id);return}ie(I(e))},onOpenDetails:e.source===`store`?void 0:ce,t:s},e.id))}),st?(0,$.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,$.jsxs)(z,{type:`button`,variant:`secondary`,disabled:O||j,onClick:()=>void Ae({page:N+1,append:!0}),children:[O?(0,$.jsx)(R,{className:`size-4 animate-spin`}):null,s.loadMore]})}):null]})]}):null]}),re?(0,$.jsx)(oe,{draft:re,onChange:ie,onClose:()=>ie(null),t:s,onInstalled:async e=>{await De(),await ve(),Z(e.instanceId),Oe(`connected`)}}):null,se?(0,$.jsx)(xt,{connector:se,installed:je.has(se.id)||lt(se,T.instances),onClose:()=>ce(null),onInstall:e=>ie(I(e)),t:s}):null,ut?(0,$.jsx)(Sn,{instance:ut,definition:Ne.get(ut.connectorId),onClose:()=>{X(null),pe(null)},onChanged:De,t:s,mcp:c}):null,he?(0,$.jsx)(Vn,{open:!0,mode:he.mode,initialRow:he.row,lastCheck:he.mode===`edit`?Te[he.row.id]:void 0,existingCustomServers:xe,config:ye,managedServerIds:Fe,t:c,cs:s,onClose:()=>ge(null),onSaved:async()=>{await ve(),await De(),Oe(`connected`)}},`${he.mode}-${he.row.clientKey}`):null]})})}export{Yn as ConnectorsPage};
@@ -1 +0,0 @@
1
- import{i as e,n as t}from"./rolldown-runtime-aKtaBQYM.js";import{a as n,n as r,t as i}from"./vendor-react-BOUWij0V.js";import{f as a}from"./chunk-KS7C4IRE-B2HK1psj.js";import{t as o}from"./circle-check-C23XjkUj.js";import{t as s}from"./download-Dk-ZjtO6.js";import{t as c}from"./external-link-DjqjBmc3.js";import{t as l}from"./x-B_N4OPjy.js";import{t as u}from"./messages-Bwv-AOYl.js";import{t as d}from"./cn-0WouolD0.js";import{n as f}from"./locale-store-D5h-Ha6-.js";import{a as p,i as m,o as h,r as g,s as _,t as v}from"./dist-BGTk37IG.js";import{n as y}from"./app-link-BV_eGr7l.js";import{i as b}from"./vendor-swr-BIWyz7Rc.js";import{F as x,I as S,Kc as C,L as w,Ou as T,Qd as E,Rc as D,Rt as O,Vt as k,Wo as A,Yl as j,df as M,ja as N,ld as P,vs as ee,ys as te,zt as F}from"./index-DdJ_djQt.js";import{_ as ne,a as re,d as ie,f as ae,g as oe,h as se,i as ce,l as I,m as le,n as L,p as ue,r as R,s as z,t as B,u as de,v as fe}from"./tunnel-api-CnLkQQGi.js";import{t as V}from"./browser-BLJWD7WI.js";var H=e(n(),1),U=r(),W=e(V(),1),G={width:240,margin:4,errorCorrectionLevel:`M`,color:{dark:`#000000ff`,light:`#ffffffff`}};async function pe(e){let t=await W.toString(e,{...G,type:`svg`});return`data:image/svg+xml;charset=utf-8,${encodeURIComponent(t)}`}var K=i();function me(){let e=u(f(e=>e.language)),t=e.endpointToolsSettings.deviceAccess.flow,n=e.tunnelSettings,{data:r,error:i,mutate:a}=b(`tunnel-status`,L,{refreshInterval:1500}),[o,s]=(0,H.useState)(!1),[l,d]=(0,H.useState)(!1),[p,m]=(0,H.useState)(!0),[h,g]=(0,H.useState)(`idle`),[_,v]=(0,H.useState)(null),[T,E]=(0,H.useState)(``),A=(0,H.useRef)(!0);(0,H.useEffect)(()=>(A.current=!0,()=>{A.current=!1}),[]);let j=async()=>{if(!r)return;if(r.consentRequired&&!o){d(!0);return}let e=r.registrationSecret?.configured?null:w(),t,n=!1;v(null);try{if(r.consentRequired&&await re(),!r.registrationSecret?.configured){g(`provisioning`);let r=!1;try{await ce()}catch(e){if(!de(e))throw e;r=!0}if(r){g(`authorizing`);let r=sessionStorage.getItem(`device-pairing-oauth`),i=r?JSON.parse(r):null;t=i&&i.expiresAt>Date.now()?i.sessionId:(await k(`xopc-tunnel`)).sessionId,sessionStorage.setItem(`device-pairing-oauth`,JSON.stringify({sessionId:t,expiresAt:i&&i.expiresAt>Date.now()?i.expiresAt:Date.now()+5*6e4}));let a=``,o=Date.now()+5*6e4,s=!1;for(;A.current&&Date.now()<o;){let r=await F(t);if(r.authUrl&&r.authUrl!==a&&(a=r.authUrl,await S(a,e)||E(a)),r.status===`completed`){s=!0,n=!0;break}if(r.status===`failed`||r.status===`cancelled`)throw Error(`Authorization cancelled`);await new Promise(e=>setTimeout(e,1e3))}if(!A.current)return;if(!s)throw Error(`Authorization expired`);await ce()}await a()}if(!A.current)return;g(`starting`),await z(),p&&await R({autoStart:!0}),await a(),n=!0}catch(e){n=!0,A.current&&v(I(e)===`tunnel_key_limit_reached`?`key-limit`:`failed`)}finally{x(e),n&&(sessionStorage.removeItem(`device-pairing-oauth`),t&&O(t).catch(()=>{})),A.current&&(g(`idle`),E(``))}};if(!r&&!i)return(0,K.jsxs)(`div`,{className:`space-y-5`,children:[(0,K.jsx)(D,{className:`h-5 w-4/5`}),(0,K.jsx)(D,{className:`h-24 w-full`})]});let M=h===`provisioning`||h===`starting`||r?.state===`connecting`||r?.state===`reconnecting`;return(0,K.jsxs)(`div`,{className:`flex min-h-full flex-col`,children:[(0,K.jsx)(`p`,{className:`text-sm leading-relaxed text-fg-muted`,children:M?t.preparingHint:h===`authorizing`?t.authorizing:t.enableHint}),T&&h===`authorizing`?(0,K.jsx)(`a`,{href:T,target:`_blank`,rel:`noopener noreferrer`,className:`mt-4 inline-flex min-h-11 items-center text-sm text-accent`,children:t.openAuthorization}):null,M?(0,K.jsxs)(`div`,{className:`mt-8 space-y-3`,"aria-label":t.preparing,children:[(0,K.jsx)(D,{className:`h-2 w-full`}),(0,K.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.preparing})]}):null,(l||r?.consentRequired)&&h===`idle`?(0,K.jsxs)(`div`,{className:`mt-6 space-y-4`,children:[(0,K.jsxs)(`details`,{open:l,className:`text-sm text-fg-muted`,children:[(0,K.jsx)(`summary`,{className:`cursor-pointer py-2`,children:t.details}),(0,K.jsx)(`p`,{className:`mt-2`,children:n.consentIntro}),(0,K.jsx)(`ul`,{className:`mt-3 list-disc space-y-2 pl-5`,children:[n.consentBullet1,n.consentBullet2,n.consentBullet3].map(e=>(0,K.jsx)(`li`,{children:e},e))})]}),(0,K.jsxs)(`label`,{className:`flex items-start gap-3 text-sm text-fg`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked),className:`mt-1 size-4 accent-accent`}),n.consentCheckbox]})]}):null,_===`key-limit`?(0,K.jsxs)(`div`,{role:`alert`,className:`mt-4 rounded-lg border border-warning/30 bg-warning/5 p-4`,children:[(0,K.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.routeKeyLimitTitle}),(0,K.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:t.routeKeyLimitHint}),(0,K.jsxs)(C,{variant:`secondary`,className:`mt-3`,onClick:()=>void y(B),children:[t.manageTunnelKeys,(0,K.jsx)(c,{className:`size-3`})]})]}):_||i||r?.state===`error`?(0,K.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-danger`,children:t.routeSetupFailed}):null,(0,K.jsx)(`div`,{className:`flex-1`}),(0,K.jsxs)(`label`,{className:`my-5 flex items-center gap-3 text-sm text-fg-muted`,children:[(0,K.jsx)(`input`,{type:`checkbox`,checked:p,disabled:h!==`idle`,onChange:e=>m(e.target.checked),className:`size-4 accent-accent`}),t.autoStart]}),(0,K.jsx)(C,{className:`w-full`,variant:`primary`,disabled:!r||h!==`idle`||M||l&&!o,onClick:()=>void j(),children:h===`authorizing`?t.authorizing:M?t.preparing:_?t.retry:t.enable}),i&&!r?(0,K.jsx)(C,{variant:`ghost`,onClick:()=>void a(),children:t.retry}):null]})}var q=t({DevicePairingWizard:()=>J});function J(e){let t=(0,U.c)(16),{open:n,onOpenChange:r,onPaired:i,targetKind:o}=e,s=a(),[c,l]=(0,H.useState)(o),u,d;t[0]===o?(u=t[1],d=t[2]):(u=()=>{l(o)},d=[o],t[0]=o,t[1]=u,t[2]=d),(0,H.useEffect)(u,d);let f;t[3]!==r||t[4]!==o?(f=e=>{e||l(o),r(e)},t[3]=r,t[4]=o,t[5]=f):f=t[5];let p=f,m;t[6]!==p||t[7]!==s||t[8]!==i||t[9]!==n||t[10]!==c?(m=n?c?(0,K.jsx)(ge,{targetKind:c,onClose:()=>p(!1),onPaired:i}):(0,K.jsx)(X,{onChoose:l,onChooseLocalBrowser:()=>{p(!1),s(`/settings/agent-browser?driver=extension`)},onClose:()=>p(!1)}):null,t[6]=p,t[7]=s,t[8]=i,t[9]=n,t[10]=c,t[11]=m):m=t[11];let h;return t[12]!==p||t[13]!==n||t[14]!==m?(h=(0,K.jsx)(v,{open:n,onOpenChange:p,children:m}),t[12]=p,t[13]=n,t[14]=m,t[15]=h):h=t[15],h}function Y(e){let t=(0,U.c)(14),{icon:n,title:r,hint:i,onClick:a}=e,o;t[0]===n?o=t[1]:(o=(0,K.jsx)(`span`,{className:`flex size-10 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-accent-fg`,children:(0,K.jsx)(n,{className:`size-5`,"aria-hidden":`true`})}),t[0]=n,t[1]=o);let s;t[2]===r?s=t[3]:(s=(0,K.jsx)(`span`,{className:`block text-sm font-semibold text-fg`,children:r}),t[2]=r,t[3]=s);let c;t[4]===i?c=t[5]:(c=(0,K.jsx)(`span`,{className:`mt-0.5 block text-xs leading-5 text-fg-muted`,children:i}),t[4]=i,t[5]=c);let l;t[6]!==s||t[7]!==c?(l=(0,K.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,K.jsx)(M,{className:`size-4 shrink-0 text-fg-disabled transition-transform group-hover:translate-x-0.5 group-hover:text-fg-muted`,"aria-hidden":`true`}),t[9]=u):u=t[9];let d;return t[10]!==a||t[11]!==o||t[12]!==l?(d=(0,K.jsxs)(`button`,{type:`button`,className:`group flex min-h-18 w-full cursor-pointer items-center gap-4 rounded-xl border border-edge bg-surface-panel px-4 py-3.5 text-left shadow-surface transition-[background-color,border-color,box-shadow,transform] hover:border-edge-strong hover:bg-surface-active hover:shadow-elevated active:translate-y-px active:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-surface-panel motion-reduce:active:translate-y-0`,onClick:a,children:[o,l,u]}),t[10]=a,t[11]=o,t[12]=l,t[13]=d):d=t[13],d}function X(e){let t=(0,U.c)(40),{onChoose:n,onChooseLocalBrowser:r,onClose:i}=e,a=f(he),o;t[0]===a?o=t[1]:(o=u(a),t[0]=a,t[1]=o);let s=o.endpointToolsSettings.deviceAccess,c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,K.jsx)(p,{className:d(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,te)}),t[2]=c):c=t[2];let v;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(v=d(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(28rem,calc(100dvh-2rem))] w-[min(40rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay`,ee),t[3]=v):v=t[3];let y;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,K.jsx)(`span`,{className:`text-lg font-semibold tracking-tight text-fg`,children:`xopc`}),t[4]=y):y=t[4];let b;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,K.jsx)(l,{className:`size-4`}),t[5]=b):b=t[5];let x;t[6]!==s.cancel||t[7]!==i?(x=(0,K.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between border-b border-edge-subtle px-6 py-3`,children:[y,(0,K.jsx)(`button`,{type:`button`,className:`flex size-10 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover`,"aria-label":s.cancel,onClick:i,children:b})]}),t[6]=s.cancel,t[7]=i,t[8]=x):x=t[8];let S;t[9]===s.chooseTitle?S=t[10]:(S=(0,K.jsx)(_,{className:`text-lg font-semibold tracking-tight text-fg sm:text-xl`,children:s.chooseTitle}),t[9]=s.chooseTitle,t[10]=S);let C;t[11]===s.chooseHint?C=t[12]:(C=(0,K.jsx)(m,{className:`mt-1.5 text-sm leading-6 text-fg-muted`,children:s.chooseHint}),t[11]=s.chooseHint,t[12]=C);let w;t[13]!==s.localBrowserHint||t[14]!==s.localBrowserTitle||t[15]!==r?(w=(0,K.jsx)(Y,{icon:P,title:s.localBrowserTitle,hint:s.localBrowserHint,onClick:r}),t[13]=s.localBrowserHint,t[14]=s.localBrowserTitle,t[15]=r,t[16]=w):w=t[16];let E;t[17]===n?E=t[18]:(E=()=>n(`mobile`),t[17]=n,t[18]=E);let D;t[19]!==s.mobileHint||t[20]!==s.mobileTitle||t[21]!==E?(D=(0,K.jsx)(Y,{icon:j,title:s.mobileTitle,hint:s.mobileHint,onClick:E}),t[19]=s.mobileHint,t[20]=s.mobileTitle,t[21]=E,t[22]=D):D=t[22];let O;t[23]===n?O=t[24]:(O=()=>n(`browser`),t[23]=n,t[24]=O);let k;t[25]!==s.remoteBrowserHint||t[26]!==s.remoteBrowserTitle||t[27]!==O?(k=(0,K.jsx)(Y,{icon:T,title:s.remoteBrowserTitle,hint:s.remoteBrowserHint,onClick:O}),t[25]=s.remoteBrowserHint,t[26]=s.remoteBrowserTitle,t[27]=O,t[28]=k):k=t[28];let A;t[29]!==D||t[30]!==k||t[31]!==w?(A=(0,K.jsxs)(`div`,{className:`mt-5 flex flex-col gap-2.5`,children:[w,D,k]}),t[29]=D,t[30]=k,t[31]=w,t[32]=A):A=t[32];let M;t[33]!==A||t[34]!==S||t[35]!==C?(M=(0,K.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-6 sm:px-8`,children:[S,C,A]}),t[33]=A,t[34]=S,t[35]=C,t[36]=M):M=t[36];let N;return t[37]!==M||t[38]!==x?(N=(0,K.jsxs)(h,{children:[c,(0,K.jsxs)(g,{className:v,children:[x,M]})]}),t[37]=M,t[38]=x,t[39]=N):N=t[39],N}function he(e){return e.language}function ge({targetKind:e,onClose:t,onPaired:n}){let r=f(e=>e.language),i=u(r),a=i.endpointToolsSettings.deviceAccess,v=a.flow,[x,S]=(0,H.useState)(!1),w=b(x?`device-pairing-readiness`:null,se,{refreshInterval:1500}),[T,O]=(0,H.useState)(),[k,j]=(0,H.useState)(null),[P,F]=(0,H.useState)(!1),[re,ce]=(0,H.useState)(Date.now()),[I,L]=(0,H.useState)(null),R=(0,H.useRef)(!0),z=(0,H.useRef)(null),B=(0,H.useRef)(!1),de=(0,H.useRef)(!1),V=b(T?[`device-pairing-setup`,T.id]:null,()=>oe(T.id),{refreshInterval:1500}),U=V.data?.request,W=U?.status===`completed`,G=W&&U.connectedAt!==void 0,q=b(G&&window.electronAPI?.system?`system-behavior`:null,()=>window.electronAPI.system.getBehavior()),J=T?.targetKind===`mobile`?T.universalLink:``,Y=A(()=>pe(J),[J],{enabled:!!J,initial:null,errorData:null}),X=r===`zh`?`https://xopc.ai/zh#download`:`https://xopc.ai/en#download`,he=r===`zh`?`https://xopcai.github.io/xopc/zh/browser-extension`:`https://xopcai.github.io/xopc/browser-extension`,ge=A(()=>pe(X),[X],{enabled:!x&&e===`mobile`,initial:null,errorData:null});(0,H.useEffect)(()=>{R.current=!0;let e=setInterval(()=>ce(Date.now()),1e3);return()=>{R.current=!1,clearInterval(e),z.current&&ie(z.current).catch(()=>{})}},[]);let Z=(0,H.useCallback)(async()=>{if(!B.current){B.current=!0,F(!0),j(null);try{z.current&&await ie(z.current),z.current=null,O(void 0);let t=await ae(e);if(t.kind===`ready`){if(!R.current){await ie(t.setup.id);return}z.current=t.setup.id,O(t.setup)}else await w.mutate()}catch{R.current&&j(`create`)}finally{B.current=!1,R.current&&F(!1)}}},[w,e]);(0,H.useEffect)(()=>{w.data?.ready&&!T&&k!==`create`&&!B.current&&Z()},[w.data,T,k,Z]),(0,H.useEffect)(()=>{G&&!de.current&&(de.current=!0,n?.())},[G,n]);let _e=async e=>{if(U){F(!0),j(null);try{await ue(U,e),await V.mutate()}catch{j(`decision`),await V.mutate()}finally{R.current&&F(!1)}}},ve=(0,H.useRef)(0);(0,H.useEffect)(()=>{V.data&&(ve.current=V.data.serverTime-Date.now())},[V.data]);let Q=re+ve.current,ye=T&&Q>=T.expiresAt&&!U,be=U&&[`expired`,`rejected`,`cancelled`].includes(U.status),xe=T?T.expiresAt-Q<6e4:!1,Se=T?xe?`${Math.max(0,Math.ceil((T.expiresAt-Q)/1e3))}s`:v.valid:``,$=e===`mobile`?{connect:a.mobileScan,connectHint:a.mobileScanHint,allowTitle:a.mobileAllowTitle,success:a.mobileSuccess,successHint:a.mobileSuccessHint}:{connect:a.browserConnect,connectHint:a.browserConnectHint,allowTitle:a.browserAllowTitle,success:a.browserSuccess,successHint:a.browserSuccessHint},Ce=e===`mobile`?a.mobilePrepareTitle:a.browserPrepareTitle,we=e===`mobile`?a.mobilePrepareHint:a.browserPrepareHint,Te=x?G?$.success:U?.status===`pending`?$.allowTitle:W||U?.status===`approved`?v.waiting:T?$.connect:v.title:Ce,Ee=k===`create`?v.createFailed:k===`decision`?v.decisionFailed:k===`background`?v.backgroundFailed:k===`download`?a.browserDownloadFailed:null,De=async()=>{F(!0),j(null);try{await le()}catch{j(`download`)}finally{R.current&&F(!1)}};return(0,K.jsxs)(h,{children:[(0,K.jsx)(p,{className:d(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,te)}),(0,K.jsxs)(g,{className:d(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(600px,calc(100dvh-48px))] w-[min(560px,calc(100vw-32px))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay`,ee),children:[(0,K.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between border-b border-edge-subtle px-6 py-3`,children:[(0,K.jsx)(`span`,{className:`text-lg font-semibold tracking-tight text-fg`,children:`xopc`}),(0,K.jsx)(`button`,{type:`button`,className:`flex size-10 items-center justify-center rounded-lg text-fg-muted hover:bg-surface-hover`,"aria-label":v.cancel,onClick:t,children:(0,K.jsx)(l,{className:`size-4`})})]}),(0,K.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-y-auto px-8 py-7`,children:[G?(0,K.jsx)(o,{className:`mb-5 size-7 text-success`}):null,(0,K.jsx)(_,{className:`text-xl font-semibold tracking-tight text-fg`,children:Te}),(0,K.jsx)(m,{className:`mt-2 text-sm leading-relaxed text-fg-muted`,children:x?G?$.successHint:W?v.waitingForDevice:U?U.displayName:T?$.connectHint:v.intro:we}),Ee?(0,K.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-danger`,children:Ee}):null,x&&w.error?(0,K.jsx)(`p`,{role:`alert`,className:`mt-4 text-sm text-danger`,children:v.readinessFailed}):null,x&&V.error?(0,K.jsx)(`p`,{role:`status`,className:`mt-4 text-sm text-warning`,children:v.statusUnavailable}):null,x?w.data?G?(0,K.jsxs)(K.Fragment,{children:[q.data?(0,K.jsxs)(`label`,{className:`mt-8 flex items-center justify-between gap-4 border-y border-edge-subtle py-5 text-sm text-fg`,children:[a.background,(0,K.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":q.data.runInBackground??!1,disabled:!q.data.backgroundSupported,checked:q.data.runInBackground??!1,className:`size-5 accent-accent`,onChange:e=>{window.electronAPI.system.setBehavior({runInBackground:e.target.checked}).then(e=>q.mutate(e.behavior)).catch(()=>j(`background`))}})]}):null,(0,K.jsx)(`p`,{className:`mt-4 text-xs text-fg-muted`,children:a.sleep})]}):be||ye?(0,K.jsxs)(`div`,{className:`mt-10 space-y-5`,children:[(0,K.jsx)(`p`,{className:`text-sm text-fg-muted`,children:ye||U?.status===`expired`?v.expired:v.declined}),(0,K.jsx)(C,{variant:`primary`,onClick:()=>void Z(),disabled:P,children:v.refresh})]}):U?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:v.scope}),(0,K.jsxs)(`p`,{className:`mt-10 font-mono text-4xl tracking-[0.16em] text-fg`,"aria-live":`polite`,children:[U.confirmationCode.slice(0,3),` `,U.confirmationCode.slice(3)]}),(0,K.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:v.compare}),(0,K.jsxs)(`details`,{className:`mt-6 text-xs text-fg-muted`,children:[(0,K.jsx)(`summary`,{className:`cursor-pointer py-2`,children:v.access}),(0,K.jsx)(`p`,{children:v.accessHint})]})]}):T?.targetKind===`mobile`?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`div`,{className:`my-6 flex flex-col items-center`,children:[(0,K.jsx)(`div`,{className:`rounded-[1.75rem] border border-edge bg-surface-hover/55 p-2.5 shadow-surface`,children:(0,K.jsx)(`div`,{className:`rounded-[1.25rem] bg-white p-2 shadow-sm ring-1 ring-black/5`,children:Y.data?(0,K.jsx)(`img`,{src:Y.data,alt:a.qrAlt,width:240,height:240,className:`size-[240px] max-w-full rounded-xl bg-white`}):Y.error?null:(0,K.jsx)(D,{className:`size-[240px] rounded-xl`})})}),Y.error?null:(0,K.jsxs)(`p`,{className:d(`mt-4 inline-flex min-h-8 items-center gap-1.5 rounded-full px-3 text-xs font-medium`,xe?`bg-warning-soft text-warning`:`bg-surface-hover text-fg-muted`),"aria-live":`polite`,children:[(0,K.jsx)(E,{className:`size-3.5`,"aria-hidden":`true`}),Se]})]}),Y.error?(0,K.jsx)(`p`,{role:`status`,className:`text-center text-sm text-warning`,children:v.qrFailed}):null,Y.error?(0,K.jsx)(`div`,{className:`mt-5`,children:(0,K.jsx)(N,{text:T.universalLink,labels:{copy:a.copy,copied:a.copied,copyFailed:i.clipboard.copyFailed}})}):(0,K.jsxs)(`details`,{className:`group mx-auto mt-1 w-full max-w-sm rounded-xl border border-edge bg-surface-panel text-xs text-fg-muted`,children:[(0,K.jsxs)(`summary`,{className:`flex min-h-11 cursor-pointer list-none items-center justify-between gap-3 rounded-xl px-3.5 transition-colors hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent [&::-webkit-details-marker]:hidden`,children:[(0,K.jsx)(`span`,{children:v.fallback}),(0,K.jsx)(M,{className:`size-3.5 shrink-0 transition-transform group-open:rotate-90`,"aria-hidden":`true`})]}),(0,K.jsx)(`div`,{className:`border-t border-edge-subtle p-3`,children:(0,K.jsx)(N,{text:T.universalLink,labels:{copy:a.copy,copied:a.copied,copyFailed:i.clipboard.copyFailed}})})]})]}):T?(0,K.jsxs)(K.Fragment,{children:[(0,K.jsxs)(`ol`,{className:`mt-7 space-y-2 text-sm leading-6 text-fg-muted`,children:[(0,K.jsxs)(`li`,{children:[(0,K.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`1.`}),a.browserConnectStep1]}),(0,K.jsxs)(`li`,{children:[(0,K.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`2.`}),a.browserConnectStep2]}),(0,K.jsxs)(`li`,{children:[(0,K.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`3.`}),a.browserConnectStep3]})]}),(0,K.jsx)(`div`,{className:`mt-6`,children:(0,K.jsx)(N,{text:T.browserInvitation,labels:{copy:a.copy,copied:a.copied,copyFailed:i.clipboard.copyFailed}})}),(0,K.jsx)(`p`,{className:`mt-3 text-center text-xs text-fg-muted`,children:T.expiresAt-Q<6e4?`${Math.max(0,Math.ceil((T.expiresAt-Q)/1e3))}s`:v.valid})]}):w.data.ready?(0,K.jsx)(`div`,{className:`mt-8`,children:(0,K.jsx)(D,{className:`mx-auto size-[216px]`})}):(0,K.jsxs)(`div`,{className:`mt-6 flex flex-1 flex-col`,children:[I===`tailscale`?(0,K.jsx)(fe,{embedded:!0}):I===`https`?(0,K.jsx)(ne,{}):I===`choices`?(0,K.jsxs)(`div`,{className:`space-y-3`,children:[(0,K.jsx)(C,{variant:`secondary`,className:`w-full`,onClick:()=>L(`tailscale`),children:a.useTailscale}),(0,K.jsx)(C,{variant:`secondary`,className:`w-full`,onClick:()=>L(`https`),children:a.useOwnHttps})]}):(0,K.jsx)(me,{}),(0,K.jsx)(C,{variant:`ghost`,className:`mt-3 w-full`,onClick:()=>L(I?null:`choices`),children:I?v.back:v.existing})]}):(0,K.jsxs)(`div`,{className:`mt-8 space-y-4`,children:[(0,K.jsx)(D,{className:`h-5 w-3/4`}),(0,K.jsx)(D,{className:`h-40 w-full`})]}):e===`mobile`?(0,K.jsxs)(`div`,{className:`mt-7 flex flex-col items-center`,children:[ge.data?(0,K.jsx)(`img`,{src:ge.data,alt:a.mobileDownloadQrAlt,width:144,height:144,className:`size-36 rounded-lg bg-white`}):(0,K.jsx)(D,{className:`size-36`}),(0,K.jsxs)(C,{variant:`secondary`,className:`mt-5 w-full`,onClick:()=>void y(X),children:[(0,K.jsx)(c,{className:`size-4`}),a.mobileDownload]}),(0,K.jsx)(`p`,{className:`mt-3 text-center text-xs leading-5 text-fg-muted`,children:a.mobileDownloadHint})]}):(0,K.jsxs)(`div`,{className:`mt-7`,children:[(0,K.jsxs)(C,{variant:`secondary`,className:`w-full`,disabled:P,onClick:()=>void De(),children:[(0,K.jsx)(s,{className:`size-4`}),a.browserDownload]}),(0,K.jsxs)(`ol`,{className:`mt-5 space-y-3 text-sm leading-6 text-fg-muted`,children:[(0,K.jsxs)(`li`,{children:[(0,K.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`1.`}),a.browserInstallStep1]}),(0,K.jsxs)(`li`,{children:[(0,K.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`2.`}),a.browserInstallStep2]}),(0,K.jsxs)(`li`,{children:[(0,K.jsx)(`span`,{className:`mr-2 text-fg-subtle`,children:`3.`}),a.browserInstallStep3]})]}),(0,K.jsxs)(`button`,{type:`button`,className:`mt-5 inline-flex items-center gap-1 text-xs text-accent hover:underline`,onClick:()=>void y(he),children:[a.browserInstallHelp,(0,K.jsx)(c,{className:`size-3`})]})]})]}),!x||w.error||G||U?.status===`pending`||k===`create`||k===`decision`?(0,K.jsx)(`footer`,{className:`shrink-0 px-8 pb-6`,children:x?G?(0,K.jsx)(C,{className:`w-full`,variant:`primary`,onClick:t,children:v.done}):U?.status===`pending`?(0,K.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,K.jsx)(C,{className:`w-full`,variant:`primary`,disabled:P,onClick:()=>void _e(`approve`),children:v.allow}),(0,K.jsx)(C,{className:`w-full`,variant:`ghost`,disabled:P,onClick:()=>void _e(`reject`),children:v.cancel})]}):w.error?(0,K.jsx)(C,{className:`w-full`,variant:`primary`,onClick:()=>void w.mutate(),children:v.retry}):(0,K.jsx)(C,{className:`w-full`,variant:`primary`,disabled:P,onClick:()=>void Z(),children:v.retry}):(0,K.jsx)(C,{className:`w-full`,variant:`primary`,onClick:()=>{j(null),S(!0)},children:e===`mobile`?a.mobileReady:a.browserReady})}):null]})]})}export{q as n,J as t};
@@ -1 +0,0 @@
1
- import{p as e}from"./locale-store-D5h-Ha6-.js";var t=e(()=>({connectionState:`idle`,error:null}));function n(e){t.setState(e)}export{t as n,n as t};