@xopcai/xopc 0.0.303 → 0.0.307

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 (431) hide show
  1. package/README.md +4 -4
  2. package/README.zh-CN.md +4 -4
  3. package/dist/browser-ext/dist/assets/{auth-B_9ZuGDx.js → auth-C3yV1y_l.js} +67 -22
  4. package/dist/browser-ext/dist/background.js +4 -4
  5. package/dist/browser-ext/dist/sidepanel.html +1 -1
  6. package/dist/browser-ext/dist/sidepanel.js +3 -3
  7. package/dist/browser-ext/manifest.json +1 -1
  8. package/dist/extensions/feishu/xopc.extension.json +0 -3
  9. package/dist/extensions/telegram/xopc.extension.json +1 -4
  10. package/dist/extensions/weixin/xopc.extension.json +0 -3
  11. package/dist/gateway/static/root/assets/{activity-store-DCi5rh4e.js → activity-store-wgSB2HYK.js} +1 -1
  12. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-Ch3DzUvP.js → agent-avatar-dicebear-CZeQo09T.js} +1 -1
  13. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-BPsRb9Ck.js +1 -0
  14. package/dist/gateway/static/root/assets/{agents-DXHD-ST3.js → agents-BlrHMbRx.js} +1 -1
  15. package/dist/gateway/static/root/assets/{api-CAV9PN9i.js → api-BKHmTb0w.js} +1 -1
  16. package/dist/gateway/static/root/assets/api-DFOlahZv.js +1 -0
  17. package/dist/gateway/static/root/assets/app-management-settings-panel-Bzw4fQP8.js +1 -0
  18. package/dist/gateway/static/root/assets/appearance-settings-8GZpUXva.js +1 -0
  19. package/dist/gateway/static/root/assets/apps-page-BkQQtIxH.js +1 -0
  20. package/dist/gateway/static/root/assets/{archive-plugin-BKGzaVvM.js → archive-plugin-CQ2NaoHb.js} +1 -1
  21. package/dist/gateway/static/root/assets/{attachment-load-8bARdLnp.js → attachment-load-BFi1H7yJ.js} +1 -1
  22. package/dist/gateway/static/root/assets/{automations-page-BAEenyzx.js → automations-page-CDBXcii_.js} +1 -1
  23. package/dist/gateway/static/root/assets/automations-workspace-CUpiTTiY.js +6 -0
  24. package/dist/gateway/static/root/assets/{binary-plugins-Cv3GS9Eo.js → binary-plugins-D07eWmOx.js} +1 -1
  25. package/dist/gateway/static/root/assets/{block-editor-D4ZIVQbk.css → block-editor-BdOTO0Yo.css} +1 -1
  26. package/dist/gateway/static/root/assets/{block-editor-DUeb92LG.js → block-editor-CtVnjyYU.js} +3 -3
  27. package/dist/gateway/static/root/assets/{browser-automation-inputs-BGT0xoTv.js → browser-automation-inputs-BzkJog8e.js} +1 -1
  28. package/dist/gateway/static/root/assets/{browser-automations-page-D1O22WIf.js → browser-automations-page-DyrSbDdG.js} +2 -2
  29. package/dist/gateway/static/root/assets/browser-settings-page-CqTxLpil.js +3 -0
  30. package/dist/gateway/static/root/assets/button-CS04eWY9.js +1 -0
  31. package/dist/gateway/static/root/assets/capabilities-settings-panel-BZ_-pnS6.js +8 -0
  32. package/dist/gateway/static/root/assets/channels-settings-DAD9qE3J.js +1 -0
  33. package/dist/gateway/static/root/assets/{channels-status-swr-C_icwbWj.js → channels-status-swr-B2JwuTjG.js} +1 -1
  34. package/dist/gateway/static/root/assets/{chat-terminal-dock-D-JYPVYl.js → chat-terminal-dock-B62SZdAo.js} +2 -2
  35. package/dist/gateway/static/root/assets/{computer-settings-page-Bcfp948A.js → computer-settings-page-ClSresNq.js} +1 -1
  36. package/dist/gateway/static/root/assets/connector-service-page-CPqVmNvx.js +1 -0
  37. package/dist/gateway/static/root/assets/connectors-page-BUQyg3CW.js +2 -0
  38. package/dist/gateway/static/root/assets/cron-expression-CTMi_tql.js +2 -0
  39. package/dist/gateway/static/root/assets/date-picker-B71AJK50.js +1 -0
  40. package/dist/gateway/static/root/assets/{dependency-picker-UtoUm57Q.js → dependency-picker-DlyGK-kA.js} +1 -1
  41. package/dist/gateway/static/root/assets/{desktop-pet-Bryx7gRM.js → desktop-pet-DGkbTE8_.js} +1 -1
  42. package/dist/gateway/static/root/assets/desktop-pet-settings-BY8r9j66.js +1 -0
  43. package/dist/gateway/static/root/assets/device-pairing-wizard-DzRrgd59.js +1 -0
  44. package/dist/gateway/static/root/assets/{extension-debug-page-DQlFTVBx.js → extension-debug-page-L8Mm1n3A.js} +1 -1
  45. package/dist/gateway/static/root/assets/{extension-page-BSsqRDXh.js → extension-page-CFc4vSNU.js} +1 -1
  46. package/dist/gateway/static/root/assets/{extension-settings-page-DbVZv9ve.js → extension-settings-page-B5zWyHr3.js} +1 -1
  47. package/dist/gateway/static/root/assets/{gateway-config-swr-D5AM8cyQ.js → gateway-config-swr-B6wHa6ZI.js} +1 -1
  48. package/dist/gateway/static/root/assets/gateway-realtime-B53R0CA4.js +1 -0
  49. package/dist/gateway/static/root/assets/gateway-realtime-store-BLDgrJ30.js +1 -0
  50. package/dist/gateway/static/root/assets/gateway-settings-D7qmTH4R.js +1 -0
  51. package/dist/gateway/static/root/assets/{gateway-startup-retry-CSJWdnFs.js → gateway-startup-retry-DRzGnEV-.js} +1 -1
  52. package/dist/gateway/static/root/assets/{heartbeat-settings-Cxowc29b.js → heartbeat-settings-Glsl3X5b.js} +1 -1
  53. package/dist/gateway/static/root/assets/home-page-s9hDQ8Hc.js +1 -0
  54. package/dist/gateway/static/root/assets/{image-generation-api-BNh604hw.js → image-generation-api-Ck_pyDom.js} +1 -1
  55. package/dist/gateway/static/root/assets/imports-page-ByBX7ome.js +1 -0
  56. package/dist/gateway/static/root/assets/index-RBCkv8a_.js +79 -0
  57. package/dist/gateway/static/root/assets/index-cFU4S35z.css +1 -0
  58. package/dist/gateway/static/root/assets/keyboard-shortcuts-settings-C45RlO8a.js +1 -0
  59. package/dist/gateway/static/root/assets/local-app-workbench-page-DP0x2jpR.js +2 -0
  60. package/dist/gateway/static/root/assets/{local-apps-page-CXPaPDGm.js → local-apps-page-C_AQc2bI.js} +1 -1
  61. package/dist/gateway/static/root/assets/{locale-store-DLK05Y1a.js → locale-store-msTfRK8P.js} +1 -1
  62. package/dist/gateway/static/root/assets/logs-page-DvM8Pyok.js +2 -0
  63. package/dist/gateway/static/root/assets/management-settings-D1uwSutV.js +1 -0
  64. package/dist/gateway/static/root/assets/{markdown-view-B8maDRWh.js → markdown-view-BInabSKf.js} +2 -2
  65. package/dist/gateway/static/root/assets/{media-plugins-tSJ0CvcX.js → media-plugins-C4mhf13f.js} +1 -1
  66. package/dist/gateway/static/root/assets/messages-F74LVAiU.js +3 -0
  67. package/dist/gateway/static/root/assets/note-detail-panel-D35sErp2.js +5 -0
  68. package/dist/gateway/static/root/assets/notes-page-8jCDklDn.js +8 -0
  69. package/dist/gateway/static/root/assets/{page-tabs-CQx6H-GS.js → page-tabs-1go_BtX1.js} +1 -1
  70. package/dist/gateway/static/root/assets/{popover-select-DldSX8GX.js → popover-select-9i-ZtHXL.js} +1 -1
  71. package/dist/gateway/static/root/assets/{preview-open-alternatives-A3-bVtdy.js → preview-open-alternatives-DmoSC0j1.js} +1 -1
  72. package/dist/gateway/static/root/assets/{proactive-page-D46cR3sf.js → proactive-page-xAjKTIID.js} +1 -1
  73. package/dist/gateway/static/root/assets/{product-open-page-CujZXOea.js → product-open-page-gmi5LLwM.js} +1 -1
  74. package/dist/gateway/static/root/assets/project-detail-page-BUMQHy_N.js +1 -0
  75. package/dist/gateway/static/root/assets/projects-page-DT-Mt7XR.js +1 -0
  76. package/dist/gateway/static/root/assets/{registry-api-BMFL4vis.js → registry-api-BSWtko7U.js} +1 -1
  77. package/dist/gateway/static/root/assets/remote-access-hub-Clz3byir.js +1 -0
  78. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-CR0qvq9C.js → runtime-tools-settings-panel-ClkOoxDl.js} +2 -2
  79. package/dist/gateway/static/root/assets/{schema-form-BUD9lLEE.js → schema-form-BuEmLiaU.js} +1 -1
  80. package/dist/gateway/static/root/assets/sessions-page-tQRwktKm.js +1 -0
  81. package/dist/gateway/static/root/assets/settings-advanced-gate-DqWg9XS5.js +1 -0
  82. package/dist/gateway/static/root/assets/{settings-form-section-BZPCUH6a.js → settings-form-section-Dor39QON.js} +1 -1
  83. package/dist/gateway/static/root/assets/{settings-page-XoHmqIdm.js → settings-page-Xj-yvIc8.js} +1 -1
  84. package/dist/gateway/static/root/assets/setup-status-panel-BB_sMB7P.js +1 -0
  85. package/dist/gateway/static/root/assets/share-preview-page-BFWZoXdm.js +2 -0
  86. package/dist/gateway/static/root/assets/shares-settings-oDALm4b6.js +1 -0
  87. package/dist/gateway/static/root/assets/skill-reload-api-DmwelnfK.js +1 -0
  88. package/dist/gateway/static/root/assets/skills-page-BE9JXz4U.js +2 -0
  89. package/dist/gateway/static/root/assets/{skills-page.utils-CH-quGxZ.js → skills-page.utils-Ii8qeXhs.js} +1 -1
  90. package/dist/gateway/static/root/assets/{system-settings-panel-CGC7eBso.js → system-settings-panel-Di6OSO-0.js} +1 -1
  91. package/dist/gateway/static/root/assets/task-detail-page-D1AWszc7.js +1 -0
  92. package/dist/gateway/static/root/assets/theme-store-1SZ-HFHX.js +1 -0
  93. package/dist/gateway/static/root/assets/tunnel-api-DDOlOYlj.js +1 -0
  94. package/dist/gateway/static/root/assets/{use-autosave-BydB6x2K.js → use-autosave-CQ8uWNnB.js} +1 -1
  95. package/dist/gateway/static/root/assets/user-model-page-C00i4ea0.js +2 -0
  96. package/dist/gateway/static/root/assets/{voice-api-key-field-CPUDBcag.js → voice-api-key-field-COTzshjL.js} +1 -1
  97. package/dist/gateway/static/root/assets/{voice-config-api-bZqN8-UF.js → voice-config-api-DgJML_uM.js} +1 -1
  98. package/dist/gateway/static/root/assets/{work-discovery-overlay-D_FmJbGH.js → work-discovery-overlay-_URrXbi4.js} +1 -1
  99. package/dist/gateway/static/root/assets/workflow-run-setup-panel-CALs-1nd.js +3 -0
  100. package/dist/gateway/static/root/assets/workflows-page-BUiBjz6m.js +6 -0
  101. package/dist/gateway/static/root/channel-icons/feishu.svg +6 -12
  102. package/dist/gateway/static/root/connector-icons/SOURCES.md +12 -0
  103. package/dist/gateway/static/root/connector-icons/dingtalk-mark.svg +1 -0
  104. package/dist/gateway/static/root/connector-icons/tencent-meeting-mark.svg +37 -0
  105. package/dist/gateway/static/root/connector-icons/wps-calendar.svg +14 -0
  106. package/dist/gateway/static/root/connector-icons/wps-docs.svg +14 -0
  107. package/dist/gateway/static/root/connector-icons/wps-mail.svg +7 -0
  108. package/dist/gateway/static/root/index.html +14 -12
  109. package/dist/package.js +1 -1
  110. package/dist/packages/gateway-contract/src/device-pairing.js +100 -7
  111. package/dist/packages/gateway-contract/src/gateway-scopes.js +53 -0
  112. package/dist/packages/gateway-contract/src/index.js +2 -0
  113. package/dist/packages/realtime-client/src/index.js +14 -2
  114. package/dist/packages/realtime-protocol/src/index.js +18 -14
  115. package/dist/src/agent/agent-instance-gateway.d.ts +2 -0
  116. package/dist/src/agent/agent-manager.d.ts +2 -0
  117. package/dist/src/agent/agent-manager.js +40 -12
  118. package/dist/src/agent/agent-scope.d.ts +4 -1
  119. package/dist/src/agent/agent-scope.js +19 -3
  120. package/dist/src/agent/commands/command-isolation.js +11 -9
  121. package/dist/src/agent/commands/command-registry.js +18 -33
  122. package/dist/src/agent/context/audit.js +12 -2
  123. package/dist/src/agent/context/coordinator.d.ts +13 -3
  124. package/dist/src/agent/context/coordinator.js +27 -11
  125. package/dist/src/agent/context/execution-context.js +42 -22
  126. package/dist/src/agent/context/execution-context.types.d.ts +4 -2
  127. package/dist/src/agent/context/execution-scope.d.ts +2 -2
  128. package/dist/src/agent/context/execution-scope.js +1 -1
  129. package/dist/src/agent/context/project-context.d.ts +2 -2
  130. package/dist/src/agent/context/project-context.js +3 -3
  131. package/dist/src/agent/embedded/run-for-session.d.ts +1 -0
  132. package/dist/src/agent/embedded/run-for-session.js +7 -1
  133. package/dist/src/agent/external-tools/composio-provider.js +83 -20
  134. package/dist/src/agent/external-tools/gateway-tools.js +2 -1
  135. package/dist/src/agent/inbound/attachment-pipeline.d.ts +2 -0
  136. package/dist/src/agent/inbound/attachment-pipeline.js +3 -3
  137. package/dist/src/agent/inbound/inbound-loop.js +1 -0
  138. package/dist/src/agent/inbound/turn-dispatcher.js +3 -3
  139. package/dist/src/agent/mcp/bundle-mcp-runtime.js +1 -1
  140. package/dist/src/agent/mcp/mcp-stdio-transport.js +5 -2
  141. package/dist/src/agent/mcp/oauth/mcp-oauth-manager.js +1 -1
  142. package/dist/src/agent/memory/compaction-promotion.js +7 -2
  143. package/dist/src/agent/memory/create-memory-manager.js +1 -0
  144. package/dist/src/agent/memory/manager.d.ts +6 -0
  145. package/dist/src/agent/memory/manager.js +74 -39
  146. package/dist/src/agent/memory/runtime.d.ts +3 -3
  147. package/dist/src/agent/memory/runtime.js +11 -4
  148. package/dist/src/agent/orchestration/agent-orchestrator.js +4 -1
  149. package/dist/src/agent/prompt/cache-boundary.d.ts +2 -0
  150. package/dist/src/agent/prompt/cache-boundary.js +10 -1
  151. package/dist/src/agent/service/build-direct-message-content.d.ts +1 -0
  152. package/dist/src/agent/service/build-direct-message-content.js +2 -1
  153. package/dist/src/agent/service/direct-turn-helpers.js +3 -2
  154. package/dist/src/agent/service/process-direct-streaming.d.ts +3 -1
  155. package/dist/src/agent/service/process-direct-streaming.js +3 -2
  156. package/dist/src/agent/service/webchat-tts.d.ts +0 -4
  157. package/dist/src/agent/service/webchat-tts.js +20 -19
  158. package/dist/src/agent/tools/factory.js +3 -3
  159. package/dist/src/agent/tools/knowledge-memory-tool.d.ts +2 -2
  160. package/dist/src/agent/tools/knowledge-memory-tool.js +7 -7
  161. package/dist/src/browser/native-messaging-host.js +2 -2
  162. package/dist/src/channels/attachments/voice-stt-webchat.d.ts +3 -0
  163. package/dist/src/channels/attachments/voice-stt-webchat.js +22 -9
  164. package/dist/src/cli/commands/agent.js +2 -0
  165. package/dist/src/cli/commands/config.js +8 -9
  166. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  167. package/dist/src/cli/commands/extension-marketplace.js +69 -44
  168. package/dist/src/cli/commands/extension-pack.js +0 -2
  169. package/dist/src/cli/commands/extension.js +4 -25
  170. package/dist/src/cli/commands/gateway/lifecycle.js +1 -1
  171. package/dist/src/cli/commands/onboard/gateway.js +2 -1
  172. package/dist/src/cli/utils/init-workspace-core.js +5 -2
  173. package/dist/src/config/index.js +2 -2
  174. package/dist/src/config/loader.d.ts +1 -0
  175. package/dist/src/config/loader.js +14 -1
  176. package/dist/src/config/schema.d.ts +22 -3
  177. package/dist/src/config/schema.js +13 -3
  178. package/dist/src/connectors/account-access.d.ts +4 -0
  179. package/dist/src/connectors/account-access.js +23 -0
  180. package/dist/src/connectors/approval-resume.d.ts +4 -0
  181. package/dist/src/connectors/approval-resume.js +23 -0
  182. package/dist/src/connectors/auth-provider-registry.d.ts +1 -0
  183. package/dist/src/connectors/auth-provider-registry.js +2 -1
  184. package/dist/src/connectors/authorization-attempts.d.ts +21 -0
  185. package/dist/src/connectors/authorization-attempts.js +33 -0
  186. package/dist/src/connectors/builtin-catalog.js +1 -3
  187. package/dist/src/connectors/catalog.js +2 -1
  188. package/dist/src/connectors/china-catalog.d.ts +2 -0
  189. package/dist/src/connectors/china-catalog.js +430 -0
  190. package/dist/src/connectors/composio-backends.d.ts +26 -0
  191. package/dist/src/connectors/composio-backends.js +65 -0
  192. package/dist/src/connectors/composio-catalog.js +2 -1
  193. package/dist/src/connectors/composio-managed-client.js +3 -1
  194. package/dist/src/connectors/composio-managed-events.js +5 -2
  195. package/dist/src/connectors/composio-session-types.d.ts +2 -0
  196. package/dist/src/connectors/composio-sessions.d.ts +11 -2
  197. package/dist/src/connectors/composio-sessions.js +137 -35
  198. package/dist/src/connectors/composio-triggers.js +4 -2
  199. package/dist/src/connectors/composio.d.ts +11 -8
  200. package/dist/src/connectors/composio.js +68 -84
  201. package/dist/src/connectors/connected-source-ingestion.js +4 -3
  202. package/dist/src/connectors/connection-recovery-service.js +25 -13
  203. package/dist/src/connectors/connector-identity.d.ts +2 -0
  204. package/dist/src/connectors/connector-identity.js +18 -5
  205. package/dist/src/connectors/content-enrichment.js +1 -1
  206. package/dist/src/connectors/instances.js +1 -7
  207. package/dist/src/connectors/learning-coordinator.js +4 -3
  208. package/dist/src/connectors/materialize.js +14 -1
  209. package/dist/src/connectors/policy.d.ts +1 -1
  210. package/dist/src/connectors/policy.js +1 -1
  211. package/dist/src/connectors/principal.js +24 -3
  212. package/dist/src/connectors/providers.d.ts +1 -0
  213. package/dist/src/connectors/providers.js +14 -2
  214. package/dist/src/connectors/runtime-adapter-registry.js +4 -9
  215. package/dist/src/connectors/secret-store.d.ts +4 -1
  216. package/dist/src/connectors/secret-store.js +7 -3
  217. package/dist/src/connectors/source-change-publisher.js +4 -2
  218. package/dist/src/connectors/types.d.ts +16 -11
  219. package/dist/src/connectors/workflow-preflight.d.ts +2 -1
  220. package/dist/src/connectors/workflow-preflight.js +20 -3
  221. package/dist/src/execution-environments/local-worktree-manager.js +17 -15
  222. package/dist/src/execution-environments/store.js +4 -2
  223. package/dist/src/execution-environments/types.d.ts +3 -0
  224. package/dist/src/execution-environments/types.js +2 -1
  225. package/dist/src/execution-environments/worktree-safety.d.ts +8 -0
  226. package/dist/src/execution-environments/worktree-safety.js +43 -0
  227. package/dist/src/extensions/activation-planner.d.ts +1 -1
  228. package/dist/src/extensions/activation-planner.js +1 -1
  229. package/dist/src/extensions/api-version.d.ts +4 -0
  230. package/dist/src/extensions/api-version.js +15 -0
  231. package/dist/src/extensions/api.d.ts +3 -9
  232. package/dist/src/extensions/api.js +26 -32
  233. package/dist/src/extensions/config-validation.d.ts +8 -0
  234. package/dist/src/extensions/config-validation.js +25 -0
  235. package/dist/src/extensions/extension-registry-impl.d.ts +20 -9
  236. package/dist/src/extensions/extension-registry-impl.js +79 -11
  237. package/dist/src/extensions/hooks.d.ts +1 -1
  238. package/dist/src/extensions/index.d.ts +2 -1
  239. package/dist/src/extensions/install-transaction.d.ts +2 -0
  240. package/dist/src/extensions/install-transaction.js +32 -21
  241. package/dist/src/extensions/install.js +18 -1
  242. package/dist/src/extensions/loader.d.ts +5 -5
  243. package/dist/src/extensions/loader.js +109 -47
  244. package/dist/src/extensions/lockfile.d.ts +3 -5
  245. package/dist/src/extensions/lockfile.js +41 -14
  246. package/dist/src/extensions/normalize-manifest.js +6 -60
  247. package/dist/src/extensions/sdk/index.d.ts +3 -2
  248. package/dist/src/extensions/sdk/index.js +2 -2
  249. package/dist/src/extensions/sdk/testing.js +0 -4
  250. package/dist/src/extensions/security.js +5 -7
  251. package/dist/src/extensions/types/core.d.ts +0 -5
  252. package/dist/src/extensions/types/index.d.ts +1 -1
  253. package/dist/src/extensions/types/manifest.d.ts +1 -25
  254. package/dist/src/extensions/types/providers.d.ts +1 -1
  255. package/dist/src/extensions/types/registration.d.ts +0 -12
  256. package/dist/src/extensions/update.js +71 -30
  257. package/dist/src/gateway/heartbeat/service.js +2 -2
  258. package/dist/src/gateway/hono/lib/config-payload.d.ts +3 -1
  259. package/dist/src/gateway/hono/routes/auth-registry-extensions.js +47 -10
  260. package/dist/src/gateway/hono/routes/connectors.js +208 -17
  261. package/dist/src/gateway/hono/routes/context-sources.js +1 -1
  262. package/dist/src/gateway/hono/routes/devices.js +10 -7
  263. package/dist/src/gateway/hono/routes/endpoint-compatibility.js +6 -0
  264. package/dist/src/gateway/hono/routes/extension-gateway.js +0 -33
  265. package/dist/src/gateway/hono/routes/home.js +4 -1
  266. package/dist/src/gateway/hono/routes/lazy-bundles.js +0 -1
  267. package/dist/src/gateway/hono/routes/mcp.js +1 -1
  268. package/dist/src/gateway/hono/routes/realtime.js +30 -8
  269. package/dist/src/gateway/hono/routes/user-model.js +25 -6
  270. package/dist/src/gateway/index.js +4 -1
  271. package/dist/src/gateway/lock.d.ts +2 -0
  272. package/dist/src/gateway/lock.js +31 -14
  273. package/dist/src/gateway/run-loop.js +2 -1
  274. package/dist/src/gateway/security/gateway-scopes.d.ts +2 -5
  275. package/dist/src/gateway/security/gateway-scopes.js +3 -45
  276. package/dist/src/gateway/security/index.js +2 -1
  277. package/dist/src/gateway/service.js +11 -7
  278. package/dist/src/heartbeat/index.js +1 -1
  279. package/dist/src/imports/importService.d.ts +1 -1
  280. package/dist/src/imports/inventory.js +16 -2
  281. package/dist/src/imports/productImport.js +5 -5
  282. package/dist/src/imports/types.d.ts +3 -3
  283. package/dist/src/infra/exec.d.ts +2 -2
  284. package/dist/src/infra/exec.js +32 -27
  285. package/dist/src/infra/run-command.js +15 -50
  286. package/dist/src/infra/update-restart.js +1 -1
  287. package/dist/src/knowledge/connected-knowledge-pipeline.js +13 -3
  288. package/dist/src/knowledge-memory/domain.d.ts +17 -1
  289. package/dist/src/knowledge-memory/index.js +2 -2
  290. package/dist/src/knowledge-memory/repository.d.ts +26 -4
  291. package/dist/src/knowledge-memory/repository.js +171 -36
  292. package/dist/src/mcp/channel-bridge.js +7 -3
  293. package/dist/src/media-understanding/registry.js +6 -1
  294. package/dist/src/migrations/knowledge-memory-read-policy-config.d.ts +2 -0
  295. package/dist/src/migrations/knowledge-memory-read-policy-config.js +48 -0
  296. package/dist/src/migrations/runner.js +2 -1
  297. package/dist/src/proactive/follow-ups.js +2 -1
  298. package/dist/src/process/bounded-output.d.ts +10 -0
  299. package/dist/src/process/bounded-output.js +41 -0
  300. package/dist/src/process/kill-tree.d.ts +6 -17
  301. package/dist/src/process/kill-tree.js +43 -75
  302. package/dist/src/process/process-spec.d.ts +39 -0
  303. package/dist/src/process/process-spec.js +13 -0
  304. package/dist/src/process/run-process.d.ts +4 -0
  305. package/dist/src/process/run-process.js +97 -0
  306. package/dist/src/providers/plugin-registry.d.ts +1 -1
  307. package/dist/src/providers/plugin-registry.js +6 -0
  308. package/dist/src/realtime/runtime.js +3 -1
  309. package/dist/src/session/store.js +1 -1
  310. package/dist/src/storage/sqlite/connection-wait-repository.d.ts +3 -0
  311. package/dist/src/storage/sqlite/connection-wait-repository.js +63 -2
  312. package/dist/src/storage/sqlite/connector-account-repository.d.ts +6 -0
  313. package/dist/src/storage/sqlite/connector-account-repository.js +35 -7
  314. package/dist/src/storage/sqlite/connector-repository.js +15 -10
  315. package/dist/src/storage/sqlite/connector-sync-policy-repository.js +1 -1
  316. package/dist/src/storage/sqlite/device-pairing-approval.js +1 -1
  317. package/dist/src/storage/sqlite/index.d.ts +1 -1
  318. package/dist/src/storage/sqlite/index.js +6 -4
  319. package/dist/src/storage/sqlite/migrations/180_execution_environment_ownership.sql +7 -0
  320. package/dist/src/storage/sqlite/migrations/181_knowledge_item_status_events.sql +12 -0
  321. package/dist/src/storage/sqlite/migrations/182_connector_account_policies.sql +92 -0
  322. package/dist/src/storage/sqlite/migrations/183_connector_backend_consistency.sql +20 -0
  323. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  324. package/dist/src/storage/sqlite/migrations/runner.js +7 -7
  325. package/dist/src/storage/sqlite/schema.js +1 -1
  326. package/dist/src/storage/sqlite/schema.sql +13 -0
  327. package/dist/src/storage/sqlite/transcript-repository.d.ts +4 -0
  328. package/dist/src/storage/sqlite/transcript-repository.js +36 -1
  329. package/dist/src/tasks/home-query-service.js +3 -3
  330. package/dist/src/tui/backends/embedded-backend.d.ts +24 -8
  331. package/dist/src/tui/backends/embedded-backend.js +114 -10
  332. package/dist/src/tui/backends/gateway-realtime-backend.d.ts +18 -0
  333. package/dist/src/tui/backends/gateway-realtime-backend.js +31 -4
  334. package/dist/src/tui/components/assistant-message.d.ts +4 -1
  335. package/dist/src/tui/components/assistant-message.js +10 -2
  336. package/dist/src/tui/components/cell-render-mode.d.ts +4 -0
  337. package/dist/src/tui/components/cell-render-mode.js +1 -0
  338. package/dist/src/tui/components/chat-log.d.ts +17 -4
  339. package/dist/src/tui/components/chat-log.js +68 -50
  340. package/dist/src/tui/components/custom-editor.d.ts +2 -2
  341. package/dist/src/tui/components/custom-editor.js +5 -1
  342. package/dist/src/tui/components/pending-input-preview.d.ts +9 -0
  343. package/dist/src/tui/components/pending-input-preview.js +33 -0
  344. package/dist/src/tui/components/semantic-cell.d.ts +17 -0
  345. package/dist/src/tui/components/semantic-cell.js +29 -0
  346. package/dist/src/tui/components/tool-execution.d.ts +5 -1
  347. package/dist/src/tui/components/tool-execution.js +33 -10
  348. package/dist/src/tui/components/transcript-overlay.d.ts +29 -0
  349. package/dist/src/tui/components/transcript-overlay.js +114 -0
  350. package/dist/src/tui/components/tui-bottom-bar.js +3 -1
  351. package/dist/src/tui/components/user-message.d.ts +5 -1
  352. package/dist/src/tui/components/user-message.js +12 -1
  353. package/dist/src/tui/extension-host/load-extensions.d.ts +1 -1
  354. package/dist/src/tui/extension-host/runtime-context.js +2 -1
  355. package/dist/src/tui/extension-host/runtime.d.ts +1 -1
  356. package/dist/src/tui/format-tui-hotkeys.js +8 -1
  357. package/dist/src/tui/tui-agent-events.js +31 -0
  358. package/dist/src/tui/tui-backend.d.ts +23 -11
  359. package/dist/src/tui/tui-backend.js +1 -9
  360. package/dist/src/tui/tui-chat-input-state.d.ts +25 -0
  361. package/dist/src/tui/tui-chat-input-state.js +36 -0
  362. package/dist/src/tui/tui-command-formatters.js +2 -1
  363. package/dist/src/tui/tui-commands.js +1 -1
  364. package/dist/src/tui/tui-startup-resources.js +1 -1
  365. package/dist/src/tui/tui-types.d.ts +2 -1
  366. package/dist/src/tui/tui-types.js +2 -1
  367. package/dist/src/tui/tui.js +122 -30
  368. package/dist/src/tui/xopc-tui-keybindings.d.ts +23 -3
  369. package/dist/src/tui/xopc-tui-keybindings.js +22 -2
  370. package/dist/src/user-context/access-policy.d.ts +2 -2
  371. package/dist/src/user-context/access-policy.js +10 -2
  372. package/dist/src/user-context/config.d.ts +23 -6
  373. package/dist/src/user-context/config.js +54 -7
  374. package/dist/src/voice/platform-streams.js +11 -1
  375. package/dist/src/voice/realtime/omniEngine.js +13 -1
  376. package/dist/src/voice/realtime/runtime.js +2 -1
  377. package/dist/src/voice/tts/audio.js +1 -1
  378. package/dist/src/voice/tts/speech-registry.js +6 -1
  379. package/dist/src/workflows/domain/definition.d.ts +1 -0
  380. package/dist/src/workflows/domain/validation.js +1 -1
  381. package/dist/src/workflows/service/workflow-run-service.js +14 -0
  382. package/dist/src/workflows/service/workflow-session-bridge.d.ts +1 -0
  383. package/dist/src/workflows/service/workflow-session-bridge.js +1 -0
  384. package/package.json +5 -3
  385. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-4oGrNj3m.js +0 -1
  386. package/dist/gateway/static/root/assets/api-fPapljyb.js +0 -1
  387. package/dist/gateway/static/root/assets/app-management-settings-panel-CdXnNtTg.js +0 -1
  388. package/dist/gateway/static/root/assets/appearance-settings-izNAyDhW.js +0 -1
  389. package/dist/gateway/static/root/assets/apps-page-BQb3RCga.js +0 -1
  390. package/dist/gateway/static/root/assets/automations-workspace-5vTl4x0h.js +0 -6
  391. package/dist/gateway/static/root/assets/browser-settings-page-CH9prS-f.js +0 -3
  392. package/dist/gateway/static/root/assets/button-CGlRPNzi.js +0 -1
  393. package/dist/gateway/static/root/assets/capabilities-settings-panel-DMURlZbj.js +0 -8
  394. package/dist/gateway/static/root/assets/channels-settings-CFBS3Yqy.js +0 -1
  395. package/dist/gateway/static/root/assets/connectors-page-DI1c3BMz.js +0 -2
  396. package/dist/gateway/static/root/assets/cron-expression-BJMBFKCh.js +0 -2
  397. package/dist/gateway/static/root/assets/date-picker-BFRIn5y9.js +0 -1
  398. package/dist/gateway/static/root/assets/desktop-pet-settings-DFsyEJUr.js +0 -1
  399. package/dist/gateway/static/root/assets/device-pairing-wizard-C3TQVPRy.js +0 -1
  400. package/dist/gateway/static/root/assets/gateway-settings-DUqVsB3X.js +0 -1
  401. package/dist/gateway/static/root/assets/home-page-CLkumXdN.js +0 -1
  402. package/dist/gateway/static/root/assets/imports-page-DXNfRmk9.js +0 -1
  403. package/dist/gateway/static/root/assets/index-BLRIcVQa.css +0 -1
  404. package/dist/gateway/static/root/assets/index-gheM453N.js +0 -79
  405. package/dist/gateway/static/root/assets/keyboard-shortcuts-settings-5Hcec8Xf.js +0 -1
  406. package/dist/gateway/static/root/assets/local-app-workbench-page-BDg1-fcw.js +0 -2
  407. package/dist/gateway/static/root/assets/logs-page-BWZc5jwO.js +0 -2
  408. package/dist/gateway/static/root/assets/management-settings-COa3PhMs.js +0 -1
  409. package/dist/gateway/static/root/assets/messages-C9h8SImu.js +0 -3
  410. package/dist/gateway/static/root/assets/note-detail-panel-D_YGzNcR.js +0 -5
  411. package/dist/gateway/static/root/assets/notes-page-D1f2oI2-.js +0 -8
  412. package/dist/gateway/static/root/assets/project-detail-page-CRlD_Rwv.js +0 -1
  413. package/dist/gateway/static/root/assets/projects-page-mmX0SavY.js +0 -1
  414. package/dist/gateway/static/root/assets/remote-access-hub-Cqr3K6T5.js +0 -1
  415. package/dist/gateway/static/root/assets/sessions-page-CPkvbdJP.js +0 -1
  416. package/dist/gateway/static/root/assets/settings-advanced-gate-Cu0DAbeH.js +0 -1
  417. package/dist/gateway/static/root/assets/setup-status-panel-D8fQF1jZ.js +0 -1
  418. package/dist/gateway/static/root/assets/share-preview-page-BgHqwTuT.js +0 -2
  419. package/dist/gateway/static/root/assets/shares-settings-Id4vRHzI.js +0 -1
  420. package/dist/gateway/static/root/assets/skill-reload-api-BB2Fj_di.js +0 -1
  421. package/dist/gateway/static/root/assets/skills-page-BAwF4LpS.js +0 -2
  422. package/dist/gateway/static/root/assets/task-detail-page-BVjw812D.js +0 -1
  423. package/dist/gateway/static/root/assets/theme-store-KfFEGMlp.js +0 -1
  424. package/dist/gateway/static/root/assets/tunnel-api-Do98Xk05.js +0 -1
  425. package/dist/gateway/static/root/assets/user-model-page-Nv68a4ak.js +0 -2
  426. package/dist/gateway/static/root/assets/workflow-run-setup-panel-1lZ_btki.js +0 -3
  427. package/dist/gateway/static/root/assets/workflows-page-DFOhccm3.js +0 -6
  428. package/dist/src/extensions/when-context.d.ts +0 -6
  429. package/dist/src/extensions/when-context.js +0 -26
  430. package/dist/src/extensions/when-expression.d.ts +0 -11
  431. package/dist/src/extensions/when-expression.js +0 -213
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i,p as a}from"./chunk-KS7C4IRE-Cq1tE_3b.js";import{t as o}from"./popover-select-DldSX8GX.js";import{t as s}from"./circle-check-C23XjkUj.js";import{t as c}from"./external-link-DjqjBmc3.js";import{t as l}from"./loader-circle-CifKLtgG.js";import{t as u}from"./x-B_N4OPjy.js";import{t as d}from"./cn-JdwAhgNB.js";import{a as f,c as p,i as m,n as h,r as g}from"./locale-store-DLK05Y1a.js";import{t as _}from"./messages-C9h8SImu.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{i as T}from"./vendor-swr-BIWyz7Rc.js";import{t as E}from"./button-CGlRPNzi.js";import{t as D}from"./skeleton-BwbyijEw.js";import{i as O,o as k}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{t as A}from"./settings-shell-layer-context-DCp6ykjQ.js";import{Cn as j,Fc as M,Mu as N,Oc as P,So as F,Tn as I,Xr as L,ac as R,ga as z,mc as B,pn as ee,ra as te,wn as ne,ws as re,ya as ie,zc as ae}from"./index-gheM453N.js";import{n as oe,r as se}from"./settings-page-layout-X1x-2Cp9.js";import{t as ce}from"./browser-BLJWD7WI.js";import{n as le}from"./settings-loading-skeleton-CAmWMaOT.js";import{t as ue}from"./schema-form-BUD9lLEE.js";import{n as de,t as fe}from"./channels-status-swr-C_icwbWj.js";var V=e(t(),1),H=n();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),U=r();async function he(e){let t=await m(g(`/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 ge({entry:e,locale:t,messages:n,onChanged:r,compact:i=!1}){let a=(0,V.useMemo)(()=>pe(e),[e]),o=(0,V.useMemo)(()=>({defaultBooleanLabel:n.schemaBooleanDefault,unsupportedArrayType:n.schemaUnsupportedArrayType,arrayAddPlaceholder:n.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>n.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[n]),[u,f]=(0,V.useState)({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null});(0,V.useEffect)(()=>{f({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null})},[e.id]);let p=(0,V.useCallback)(async(n,i)=>{f(e=>({...e,busy:!0,error:null}));try{let a=await he({channelId:e.id,actionId:n,locale:t,input:i});f(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){f(t=>({...t,busy:!1,error:e instanceof Error?e.message:String(e)}))}},[e.id,t,r]);(0,V.useEffect)(()=>{let t=K(u.payload,e.id);if(!t){f(e=>e.generatedQr?{...e,generatedQr:null}:e);return}let n=!1;return f(e=>e.generatedQr?{...e,generatedQr:null}:e),me.toDataURL(t,{width:220,margin:1}).then(e=>{n||f(t=>({...t,generatedQr:e}))}),()=>{n=!0}},[e.id,u.payload]),(0,V.useEffect)(()=>{let n=u.poll;if(!n)return;let i=!1,a=window.setInterval(()=>{i||he({channelId:e.id,actionId:n.actionId,locale:t,input:{conversationId:n.conversationId}}).then(async e=>{i||(f(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||f(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 m=a?.[1].label??(e.configured?n.reconnect:n.connect),h=e.actions?.[`doctor.run`]?.label??n.diagnose,g=G(u.payload),_=K(u.payload,e.id),v=_?u.generatedQr:q(u.payload),y=a?.[1].result===`qr`&&(u.busy||u.payload?.type===`qr`||u.payload?.type===`poll`),b=u.payload?.type===`form`?u.payload:null,x=u.payload?.type===`diagnostics`?u.payload.checks:null;return(0,U.jsxs)(`div`,{className:i?`space-y-3`:`rounded-lg bg-surface-panel/80 p-4 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:d(`flex flex-wrap items-start gap-3`,i?`justify-end`:`justify-between`),children:[i?null:(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.setupTitle}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.configured?n.setupConfiguredHint:n.setupEmptyHint})]}),(0,U.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[a?(0,U.jsxs)(E,{type:`button`,variant:`primary`,disabled:u.busy,onClick:()=>void p(a[0]),children:[u.busy?(0,U.jsx)(l,{className:`size-4 animate-spin`}):(0,U.jsx)(ae,{className:`size-4`}),m]}):null,e.actions?.[`doctor.run`]?(0,U.jsxs)(E,{type:`button`,variant:`secondary`,disabled:u.busy,onClick:()=>void p(`doctor.run`),children:[(0,U.jsx)(B,{className:`size-4`}),h]}):null]})]}),g?(0,U.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:g}):null,u.error?(0,U.jsx)(`p`,{className:`mt-3 text-sm text-red-600 dark:text-red-400`,children:u.error}):null,y?(0,U.jsxs)(`div`,{className:d(`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,U.jsx)(`div`,{className:`flex size-56 shrink-0 items-center justify-center rounded-lg border border-edge bg-white p-3`,children:v?(0,U.jsx)(`img`,{src:v,alt:`${e.label} setup QR`,className:`size-52 object-contain`}):(0,U.jsx)(`div`,{className:`flex size-52 items-center justify-center rounded-md bg-surface-base`,children:(0,U.jsx)(D,{className:`size-48 rounded-md`})})}),(0,U.jsxs)(`div`,{className:d(`min-w-0 max-w-sm text-sm text-fg-muted`,i&&`w-full sm:w-auto`),children:[v?(0,U.jsx)(`p`,{className:`line-clamp-3`,children:n.waitingConfirmation}):(0,U.jsxs)(`div`,{className:`space-y-2`,"aria-busy":`true`,children:[(0,U.jsx)(D,{className:`h-4 w-48 max-w-full`}),(0,U.jsx)(D,{className:`h-4 w-36 max-w-full`})]}),_?(0,U.jsxs)(`a`,{className:`mt-2 inline-flex items-center gap-1 text-accent hover:underline`,href:_,target:`_blank`,rel:`noreferrer`,children:[n.openSetupLink,(0,U.jsx)(c,{className:`size-3.5`})]}):null]})]}):null,u.payload?.type===`poll`&&u.payload.phase===`done`?(0,U.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,U.jsx)(s,{className:u.payload.ok?`size-4 text-green-600`:`size-4 text-red-600`}),(0,U.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,b?(0,U.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,U.jsx)(ue,{schema:b.schema,values:u.formDraft,onChange:e=>f(t=>({...t,formDraft:e})),disabled:u.busy,labels:o}),(0,U.jsx)(E,{type:`button`,variant:`primary`,disabled:u.busy,onClick:()=>void p(b.submitAction,u.formDraft),children:n.saveSetup})]}):null,x?(0,U.jsx)(`div`,{className:`mt-4 space-y-2`,children:x.map((e,t)=>(0,U.jsxs)(`div`,{className:`rounded-lg bg-surface-base px-3 py-2 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,U.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.label??e.id??n.diagnosticCheckFallback.replace(`{{index}}`,String(t+1))}),(0,U.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,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.message}):null]},e.id??t))}):null]})}var _e=40;function J(e){return`ui:route:channel:${e.trim().toLowerCase()}`}function ve(e,t){return e.find(e=>e.id===J(t))?.agentId?.trim().toLowerCase()??``}function ye(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:_e,enabled:!0,match:{channel:t.trim().toLowerCase(),accountId:`*`}}]:i}function be(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 xe(e,t,n){let r=be(e);return r.ready?r.enabled?n?t?.connected===!0?`running`:`stopped`:`checking`:`disabled`:`needs_setup`}function Se(e,t=!1){return e===`drawer`?d(`xopc-drawer-right fixed right-0 top-0 flex size-full flex-col overflow-hidden border-l border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`,t?`max-w-[36rem]`:`max-w-xl`,O):d(`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)]`,O,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`)}function Ce(e){let t=(0,H.c)(33),{presentation:n,open:r,onOpenChange:i,title:a,description:o,srTitle:s,srDescription:c,closeAriaLabel:l,children:f,footer:p,wide:m,headerExtra:h}=e,g=m===void 0?!1:m,_=n===`drawer`,[T,D]=(0,V.useState)(null),O;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,U.jsx)(v,{className:d(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,k)}),t[0]=O):O=t[0];let j;t[1]!==n||t[2]!==g?(j=Se(n,g),t[1]=n,t[2]=g,t[3]=j):j=t[3];let M;t[4]===s?M=t[5]:(M=s?(0,U.jsx)(C,{className:`sr-only`,children:s}):null,t[4]=s,t[5]=M);let N;t[6]===c?N=t[7]:(N=c?(0,U.jsx)(y,{className:`sr-only`,children:c}):null,t[6]=c,t[7]=N);let P;t[8]!==l||t[9]!==o||t[10]!==h||t[11]!==_||t[12]!==a?(P=_?(0,U.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[a?(0,U.jsx)(`div`,{className:`text-base font-semibold text-fg`,children:a}):null,o?(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:o}):null]}),(0,U.jsx)(b,{asChild:!0,children:(0,U.jsx)(E,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":l,children:(0,U.jsx)(u,{className:`size-5`,strokeWidth:1.75})})})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(b,{asChild:!0,children:(0,U.jsx)(`button`,{type:`button`,className:d(re,`absolute right-3 top-3 z-20 p-1.5 hover:bg-surface-hover`),"aria-label":l,children:(0,U.jsx)(u,{className:`size-4`})})}),h]}),t[8]=l,t[9]=o,t[10]=h,t[11]=_,t[12]=a,t[13]=P):P=t[13];let F=_?`p-4`:`p-6`,I;t[14]===F?I=t[15]:(I=d(`min-h-0 flex-1 overflow-y-auto`,F),t[14]=F,t[15]=I);let L;t[16]!==f||t[17]!==I?(L=(0,U.jsx)(`div`,{className:I,children:f}),t[16]=f,t[17]=I,t[18]=L):L=t[18];let R;t[19]!==p||t[20]!==T||t[21]!==M||t[22]!==N||t[23]!==P||t[24]!==L?(R=(0,U.jsxs)(A,{layer:`modal`,portalContainer:T,children:[M,N,P,L,p]}),t[19]=p,t[20]=T,t[21]=M,t[22]=N,t[23]=P,t[24]=L,t[25]=R):R=t[25];let z;t[26]!==R||t[27]!==j?(z=(0,U.jsxs)(x,{children:[O,(0,U.jsx)(S,{ref:D,className:j,onOpenAutoFocus:we,children:R})]}),t[26]=R,t[27]=j,t[28]=z):z=t[28];let B;return t[29]!==i||t[30]!==r||t[31]!==z?(B=(0,U.jsx)(w,{open:r,onOpenChange:i,children:z}),t[29]=i,t[30]=r,t[31]=z,t[32]=B):B=t[32],B}function we(e){return e.preventDefault()}var Te=(0,V.memo)(function(e){let t=(0,H.c)(10),{ch:n,refreshing:r,saveOk:i,onRefresh:a}=e,o;t[0]!==n.saved||t[1]!==i?(o=i?(0,U.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,U.jsx)(te,{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,U.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 Ee(e){let t=(0,H.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,U.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,U.jsx)(E,{type:`button`,variant:`secondary`,onClick:a,children:n.modalCancel}):null,t[3]=n.modalCancel,t[4]=a,t[5]=l,t[6]=d):d=t[6];let f=!r||i,p;t[7]!==n.discard||t[8]!==o||t[9]!==f?(p=(0,U.jsx)(E,{type:`button`,variant:`secondary`,disabled:f,onClick:o,children:n.discard}),t[7]=n.discard,t[8]=o,t[9]=f,t[10]=p):p=t[10];let m=!r||i,h;t[11]===s?h=t[12]:(h=()=>void s(),t[11]=s,t[12]=h);let g=i?n.saving:n.save,_;t[13]!==m||t[14]!==h||t[15]!==g?(_=(0,U.jsx)(E,{type:`button`,variant:`primary`,disabled:m,onClick:h,children:g}),t[13]=m,t[14]=h,t[15]=g,t[16]=_):_=t[16];let v;t[17]!==d||t[18]!==p||t[19]!==_?(v=(0,U.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,U.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 De(e){return g(`/api/channels/catalog?locale=${encodeURIComponent(e)}`)}async function Oe(e){return(await f(De(e))).payload?.channels??[]}function ke(e,t){let n=(0,H.c)(14),r;n[0]!==e||n[1]!==t?(r=e?De(t):null,n[0]=e,n[1]=t,n[2]=r):r=n[2];let i;n[3]===t?i=n[4]:(i=()=>Oe(t),n[3]=t,n[4]=i);let a;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(a={revalidateOnFocus:!1},n[5]=a):a=n[5];let{data:o,error:s,isLoading:c,isValidating:l,mutate:u}=T(r,i,a),d;n[6]===o?d=n[7]:(d=o??[],n[6]=o,n[7]=d);let f;return n[8]!==s||n[9]!==c||n[10]!==l||n[11]!==u||n[12]!==d?(f={entries:d,isLoading:c,isValidating:l,error:s,mutate:u},n[8]=s,n[9]=c,n[10]=l,n[11]=u,n[12]=d,n[13]=f):f=n[13],f}var Ae=`channels-status`;function je(e){if(!e||typeof e!=`object`)return null;let t=e.channels;return Array.isArray(t)?t:null}function Me(e){let t=t=>e(t.detail);return window.addEventListener(Ae,t),()=>window.removeEventListener(Ae,t)}function Ne(e,t){let n=(0,H.c)(4),r=t===void 0?!0:t,i,a;n[0]!==r||n[1]!==e?(i=()=>{if(r)return Me(e)},a=[r,e],n[0]=r,n[1]=e,n[2]=i,n[3]=a):(i=n[2],a=n[3]),(0,V.useEffect)(i,a)}function Pe(e){return e?g(`/api/channels/${encodeURIComponent(e)}/config`):null}async function Fe(e){return(await f(g(`/api/channels/${encodeURIComponent(e)}/config`))).payload?.config??{}}var Ie=[`enabled`];async function Le(){let e=await f(g(`/api/config`));return{channels:e.payload?.config?.channels??{},bindings:e.payload?.config?.bindings??[]}}function Re(e){return e.split(`/`).filter(Boolean).map(e=>encodeURIComponent(e)).join(`/`)}function ze(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 Be(e,t){return e===`running`?t.connectionRunning:e===`stopped`?t.connectionStopped:e===`checking`?t.connectionChecking:e===`disabled`?t.connectionDisabled:t.connectionNeedsSetup}function Ve(e,t){return e===`running`?t.connectionRunningHint:e===`stopped`?t.connectionStoppedHint:e===`disabled`?t.connectionDisabledHint:e===`needs_setup`?t.connectionNeedsSetupHint:t.connectionChecking}function He(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 Ue(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=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=>!Ie.includes(e));return Array.from(new Set([...i,...n,...r])).filter(e=>!Ie.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 We(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 Ge(e){let t=e.properties;if(!X(t))return!1;for(let[e,n]of Object.entries(t))X(n)&&n.type===`object`&&Ge(n)&&delete t[e];return Object.keys(t).length===0}function Ke(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 Ge(n),n}function qe(e){return e.type===`object`&&X(e.properties)&&Object.keys(e.properties).length>0}function Je(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 Q(e,t,n){return t==null||t===``?null:e.toLowerCase().includes(`dmpolicy`)&&typeof t==`string`?`${n.dmPolicy}: ${n.policy.dm[t]??t}`:(e.toLowerCase().includes(`stream`)||e.toLowerCase().includes(`streaming`))&&typeof t==`string`?`${n.cardStream}: ${n.policy.stream[t]??t}`:typeof t==`boolean`?t?n.enabledLabel:n.disabledLabel:String(t)}function Xe(e,t,n){let r=[],i=Y(e);if(i.issues.length>0&&r.push(et(i.issues[0],n)),t){let i=e.ui?.card?.summaryFields??[`dmPolicy`,`streamMode`,`streaming.mode`];for(let e of i){let i=Q(e,Je(t,e),n);i&&r.push(i)}let a=Ye(t);a>0&&r.push(n.cardAccounts.replace(`{{count}}`,String(a)))}return r.length>0?r.slice(0,2):i.ready?[n.hubStatusConfigured]:[]}function Ze(e,t){let n=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 Qe(e,t){let n=pe(e);return n?.[1].result===`qr`?t.cardSetupQrHint:n?.[1].result===`form`?t.cardSetupConfigHint:t.cardSetupGenericHint}function $e(e,t){let n=e.capabilities??{},r=[];return n.login===!0&&r.push(t.cardCapabilityLogin),n.pairing===!0&&r.push(t.cardCapabilityPairing),n.multiAccount===!0&&r.push(t.cardCapabilityMultiAccount),n.streaming===!0&&r.push(t.cardCapabilityStreaming),n.media===!0&&r.push(t.cardCapabilityMedia),n.doctor===!0&&r.push(t.cardCapabilityDoctor),r.slice(0,3)}function et(e,t){return e.code===`telegram.missing_credential`?t.setupIssueTelegramMissingCredential:e.code===`weixin.missing_account`?t.setupIssueWeixinMissingAccount:e.code===`feishu.missing_credentials`?t.setupIssueFeishuMissingCredentials:e.code===`config.missing_required`&&e.fieldPath?t.setupIssueMissingRequired.replace(`{{field}}`,e.fieldPath):e.message}function tt({entry:e}){let[t,n]=(0,V.useState)(!1),r=(0,V.useMemo)(()=>!e.ui?.icon||t?null:new URL(g(`/api/extensions/${encodeURIComponent(e.extensionId)}/assets/${Re(e.ui.icon)}`)).toString(),[t,e.extensionId,e.ui?.icon]);return(0,U.jsx)(`span`,{className:`flex size-12 shrink-0 items-center justify-center rounded-2xl bg-surface-base text-fg`,children:r?(0,U.jsx)(`img`,{src:r,alt:``,draggable:!1,className:`size-7`,"aria-hidden":!0,onError:()=>n(!0)}):(0,U.jsx)(ie,{sourceChannel:e.id,className:`size-7`})})}function nt(e){let t=(0,H.c)(16),{checked:n,disabled:r,onToggle:i,label:a}=e,o;t[0]===i?o=t[1]:(o=e=>{e.stopPropagation(),i()},t[0]=i,t[1]=o);let s=n?`border-accent bg-accent`:`border-edge bg-surface-hover`,c=r&&`cursor-not-allowed opacity-60`,l;t[2]!==s||t[3]!==c?(l=d(`relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border transition-colors`,s,c),t[2]=s,t[3]=c,t[4]=l):l=t[4];let u=n?`translate-x-5`:`translate-x-0.5`,f;t[5]===u?f=t[6]:(f=d(`size-5 rounded-full bg-white shadow-surface transition-transform`,u),t[5]=u,t[6]=f);let p;t[7]===f?p=t[8]:(p=(0,U.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]!==l||t[14]!==p?(m=(0,U.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":n,"aria-label":a,disabled:r,onClick:o,className:l,children:p}),t[9]=n,t[10]=r,t[11]=a,t[12]=o,t[13]=l,t[14]=p,t[15]=m):m=t[15],m}function rt(e){let t=(0,H.c)(71),{entry:n,config:r,runtime:i,busy:a,restarting:o,ch:s,onOpen:c,onToggle:u,onRestart:f}=e,p;t[0]===n?p=t[1]:(p=Y(n),t[0]=n,t[1]=p);let m=p,h,g,_,v,y,b,x;if(t[2]!==a||t[3]!==s||t[4]!==r||t[5]!==n||t[6]!==c||t[7]!==f||t[8]!==u||t[9]!==i||t[10]!==m.enabled||t[11]!==m.ready){let e=Xe(n,r,s),o=$e(n,s);h=!m.enabled&&m.ready?u:i===`stopped`?f:c,b=`flex min-h-[15.5rem] flex-col rounded-xl bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45`;let l;t[19]===n?l=t[20]:(l=(0,U.jsx)(tt,{entry:n}),t[19]=n,t[20]=l);let p;t[21]===n.label?p=t[22]:(p=(0,U.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:n.label}),t[21]=n.label,t[22]=p);let S;t[23]===i?S=t[24]:(S=d(`mt-1 inline-flex rounded-full px-2 py-0.5 text-xs font-medium`,He(i)),t[23]=i,t[24]=S);let C;t[25]!==s||t[26]!==i?(C=Be(i,s),t[25]=s,t[26]=i,t[27]=C):C=t[27];let w;t[28]!==S||t[29]!==C?(w=(0,U.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]!==p?(T=(0,U.jsxs)(`div`,{className:`min-w-0`,children:[p,w]}),t[31]=w,t[32]=p,t[33]=T):T=t[33];let E;t[34]!==T||t[35]!==l?(E=(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[l,T]}),t[34]=T,t[35]=l,t[36]=E):E=t[36];let D=m.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]!==m.enabled||t[43]!==O?(k=(0,U.jsx)(nt,{checked:D,disabled:a,label:O,onToggle:u}),t[40]=a,t[41]=u,t[42]=m.enabled,t[43]=O,t[44]=k):k=t[44],t[45]!==E||t[46]!==k?(x=(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[E,k]}),t[45]=E,t[46]=k,t[47]=x):x=t[47],g=`button`,_=c,v=`mt-5 min-h-[6.25rem] text-left`,y=m.ready?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`p`,{className:`line-clamp-2 text-sm leading-6 text-fg-muted`,children:n.description??n.id}),e.length>0?(0,U.jsx)(`div`,{className:`mt-3 space-y-0.5 text-sm leading-5 text-fg-muted`,children:e.map($)}):null]}):(0,U.jsxs)(`div`,{className:`rounded-lg bg-surface-base p-3`,children:[(0,U.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:s.cardSetupTitle}),(0,U.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm leading-5 text-fg-muted`,children:e[0]??Qe(n,s)}),o.length>0?(0,U.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]=f,t[8]=u,t[9]=i,t[10]=m.enabled,t[11]=m.ready,t[12]=h,t[13]=g,t[14]=_,t[15]=v,t[16]=y,t[17]=b,t[18]=x}else h=t[12],g=t[13],_=t[14],v=t[15],y=t[16],b=t[17],x=t[18];let S;t[48]!==g||t[49]!==_||t[50]!==v||t[51]!==y?(S=(0,U.jsx)(`button`,{type:g,onClick:_,className:v,children:y}),t[48]=g,t[49]=_,t[50]=v,t[51]=y,t[52]=S):S=t[52];let C=a||o,w;t[53]!==a||t[54]!==o?(w=a||o?(0,U.jsx)(l,{className:`size-4 animate-spin`}):null,t[53]=a,t[54]=o,t[55]=w):w=t[55];let T;t[56]!==s||t[57]!==n||t[58]!==o||t[59]!==i?(T=o?s.restartingChannel:i===`stopped`?s.restartChannel:Ze(n,s),t[56]=s,t[57]=n,t[58]=o,t[59]=i,t[60]=T):T=t[60];let D;t[61]!==h||t[62]!==w||t[63]!==T||t[64]!==C?(D=(0,U.jsx)(`div`,{className:`mt-auto pt-4`,children:(0,U.jsxs)(E,{type:`button`,variant:`secondary`,className:`w-full rounded-2xl py-2.5`,onClick:h,disabled:C,children:[w,T]})}),t[61]=h,t[62]=w,t[63]=T,t[64]=C,t[65]=D):D=t[65];let O;return t[66]!==D||t[67]!==b||t[68]!==x||t[69]!==S?(O=(0,U.jsxs)(`article`,{className:b,children:[x,S,D]}),t[66]=D,t[67]=b,t[68]=x,t[69]=S,t[70]=O):O=t[70],O}function it(e){return(0,U.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e},e)}function $(e){return(0,U.jsx)(`p`,{className:`truncate`,title:e,children:e},e)}function at(e){let t=(0,H.c)(51),{runtime:n,restarting:r,checking:i,showConnectionOptions:a,canManageConnection:o,ch:c,onRestart:u,onCheck:f,onManageConnection:p}=e,m=n===`running`?s:n===`stopped`||n===`needs_setup`?N:l,h=n===`running`&&`text-emerald-600 dark:text-emerald-400`,g=n===`stopped`&&`text-red-600 dark:text-red-400`,_=n===`checking`&&`animate-spin text-amber-600 dark:text-amber-400`,v=n===`disabled`&&`text-fg-muted`,y=n===`needs_setup`&&`text-amber-600 dark:text-amber-400`,b;t[0]!==h||t[1]!==g||t[2]!==_||t[3]!==v||t[4]!==y?(b=d(`mt-0.5 size-5 shrink-0`,h,g,_,v,y),t[0]=h,t[1]=g,t[2]=_,t[3]=v,t[4]=y,t[5]=b):b=t[5];let x;t[6]!==m||t[7]!==b?(x=(0,U.jsx)(m,{className:b}),t[6]=m,t[7]=b,t[8]=x):x=t[8];let S;t[9]===c.connectionStatus?S=t[10]:(S=(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:c.connectionStatus}),t[9]=c.connectionStatus,t[10]=S);let C;t[11]!==c||t[12]!==n?(C=Ve(n,c),t[11]=c,t[12]=n,t[13]=C):C=t[13];let w;t[14]===C?w=t[15]:(w=(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:C}),t[14]=C,t[15]=w);let T;t[16]!==w||t[17]!==S?(T=(0,U.jsxs)(`div`,{children:[S,w]}),t[16]=w,t[17]=S,t[18]=T):T=t[18];let D;t[19]!==T||t[20]!==x?(D=(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[x,T]}),t[19]=T,t[20]=x,t[21]=D):D=t[21];let O=i||r,k;t[22]===i?k=t[23]:(k=i?(0,U.jsx)(l,{className:`size-4 animate-spin`}):null,t[22]=i,t[23]=k);let A=i?c.checkingConnection:c.checkConnection,j;t[24]!==f||t[25]!==O||t[26]!==k||t[27]!==A?(j=(0,U.jsxs)(E,{type:`button`,variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:O,onClick:f,children:[k,A]}),t[24]=f,t[25]=O,t[26]=k,t[27]=A,t[28]=j):j=t[28];let P;t[29]!==c.restartChannel||t[30]!==c.restartingChannel||t[31]!==i||t[32]!==u||t[33]!==r||t[34]!==n?(P=n===`stopped`?(0,U.jsxs)(E,{type:`button`,variant:`primary`,className:`px-2.5 py-1.5 text-xs`,disabled:r||i,onClick:u,children:[r?(0,U.jsx)(l,{className:`size-4 animate-spin`}):(0,U.jsx)(M,{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]=P):P=t[35];let F;t[36]!==o||t[37]!==c.connectionOptions||t[38]!==c.hideConnectionOptions||t[39]!==i||t[40]!==p||t[41]!==r||t[42]!==a?(F=o?(0,U.jsx)(E,{type:`button`,variant:`ghost`,className:`px-2.5 py-1.5 text-xs`,disabled:i||r,onClick:p,children:a?c.hideConnectionOptions:c.connectionOptions}):null,t[36]=o,t[37]=c.connectionOptions,t[38]=c.hideConnectionOptions,t[39]=i,t[40]=p,t[41]=r,t[42]=a,t[43]=F):F=t[43];let I;t[44]!==j||t[45]!==P||t[46]!==F?(I=(0,U.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[j,P,F]}),t[44]=j,t[45]=P,t[46]=F,t[47]=I):I=t[47];let L;return t[48]!==D||t[49]!==I?(L=(0,U.jsx)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:(0,U.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[D,I]})}),t[48]=D,t[49]=I,t[50]=L):L=t[50],L}function ot(e){let t=(0,H.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,U.jsx)(R,{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,U.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,U.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,U.jsx)(`li`,{children:et(e,r)},`${e.code}:${e.fieldPath??``}`),t[16]=r,t[17]=m),a=e.issues.map(m)}t[0]=r,t[1]=n,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=f}else i=t[2],a=t[3],o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10];if(f!==Symbol.for(`react.early_return_sentinel`))return f;let p;t[18]!==i||t[19]!==a?(p=(0,U.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,U.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,U.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,U.jsx)(`section`,{className:d,children:h}),t[30]=h,t[31]=d,t[32]=g):g=t[32],g}function st(){let e=h(e=>e.language),t=_(e),n=p(e=>!!e.conversationId),r=i(),{channelId:s}=a(),l=I(s),u=ke(n,e),f=u.entries,{data:v,mutate:y,isValidating:b}=T(n?fe():null,de,{revalidateOnFocus:!0}),{data:x,mutate:S}=T(n?`channels-config-map`:null,Le,{revalidateOnFocus:!1}),C=x?.channels??{},w=x?.bindings??[],{data:E}=T(n?`channel-routing-agents`:null,z,{revalidateOnFocus:!1}),D=F(e=>e.setPageHeader),O=F(e=>e.clearPageHeader),k=(0,V.useMemo)(()=>f.find(e=>e.id===l),[l,f]),A=k?ze(k):null,{data:M,mutate:N}=T(n&&A?Pe(A):null,()=>Fe(A)),[R,B]=(0,V.useState)(null),[te,re]=(0,V.useState)(!1),[ie,ae]=(0,V.useState)(null),[ce,H]=(0,V.useState)(null),[me,he]=(0,V.useState)(!1),[W,G]=(0,V.useState)(null),[K,q]=(0,V.useState)(null),_e=R??M??{},J=t.channelsSettings,be=(0,V.useMemo)(()=>k?.configSchema??{type:`object`,properties:{}},[k?.configSchema]),Se=(0,V.useMemo)(()=>Ke(be,Ie),[be]),we=(0,V.useMemo)(()=>Ue(k),[k]),De=(0,V.useMemo)(()=>We(Se,we),[we,Se]),Oe=(0,V.useMemo)(()=>Ke(Se,we),[we,Se]),Ae=(0,V.useMemo)(()=>qe(De),[De]),Me=k?K??ve(w,k.id):``,Re=(0,V.useMemo)(()=>(E?.items??[]).map(e=>{let n=ee(e,t.agentsSettings);return{value:e.id,label:n===e.id?n:`${n} · ${e.id}`}}),[E?.items,t.agentsSettings]),Ve=E?.items.find(e=>e.id===E.defaultId),X=Ve?ee(Ve,t.agentsSettings):E?.defaultId??``,Z=(0,V.useMemo)(()=>({defaultBooleanLabel:J.schemaBooleanDefault,unsupportedArrayType:J.schemaUnsupportedArrayType,arrayAddPlaceholder:J.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>J.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[J]),Ge=(0,V.useMemo)(()=>new Map((v??[]).map(e=>[e.name,e])),[v]),Je=v!==void 0,Ye=(0,V.useCallback)(e=>xe(e,Ge.get(e.id),Je),[Ge,Je]),Q=(0,V.useCallback)(async()=>{await Promise.all([u.mutate(),y()])},[u,y]);Ne((0,V.useCallback)(e=>{let t=je(e);t&&y(t,!1)},[y]),n);let Xe=(0,V.useMemo)(()=>n?(0,U.jsx)(Te,{ch:J,refreshing:u.isValidating||b,saveOk:!1,onRefresh:()=>void Q()}):null,[u.isValidating,J,n,b,Q]);(0,V.useLayoutEffect)(()=>(D({startExtra:null,main:(0,U.jsx)(`div`,{className:`min-w-0`,children:(0,U.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.settingsSections.channels})}),end:Xe}),()=>O()),[O,Xe,t.settingsSections.channels,D]);let Ze=(0,V.useCallback)(e=>{r(ne(e)),B(null),q(null),G(null)},[r]),Qe=(0,V.useCallback)(()=>{r(j),B(null),q(null),G(null)},[r]),$e=(0,V.useCallback)(async e=>{H(e.id),G(null);try{let t=await m(g(`/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){G(e instanceof Error?e.message:String(e))}finally{H(null)}},[Q]);(0,V.useEffect)(()=>{q(null),he(!1)},[k?.id]);let et=(0,V.useCallback)(async()=>{if(!k||!R&&K===null)return!1;let e=ze(k);re(!0),G(null);try{let t=await m(g(`/api/config`),{method:`PATCH`,body:JSON.stringify({...R?{channels:{[e]:R}}:{},...K===null?{}:{bindings:ye(w,k.id,K)}})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}return R&&await N(R,!1),await S(),await u.mutate(),B(null),q(null),!0}catch(e){return G(e instanceof Error?e.message:String(e)),!1}finally{re(!1)}},[k,K,w,u,R,S,N]),it=(0,V.useCallback)(async e=>{let t=Y(e),n=ze(e),r=k?.id===e.id?R:null;if(!t.enabled&&!t.ready&&!r){Ze(e.id);return}ae(e.id),G(null);try{let i=t.enabled?{enabled:!1}:r?{...r,enabled:!0}:{enabled:!0},a=await m(g(`/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 u.mutate(),await S(),await y(),k?.id===e.id&&(await N(),B(null))}catch(e){G(e instanceof Error?e.message:String(e))}finally{ae(null)}},[k?.id,u,R,S,N,y,Ze]),$=k?.ui?.modal,st=$?.placement!==`replace-config`,ct=k?Ye(k):`checking`,lt=k?!Y(k).ready||me:!1;return n?(0,U.jsxs)(se,{gap:`gap-4`,className:`max-w-6xl`,padding:`px-4 py-7 sm:px-6 lg:px-8 lg:py-9`,children:[u.isLoading?(0,U.jsx)(le,{sections:2}):u.error?(0,U.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:String(u.error)}):(0,U.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:f.map(e=>(0,U.jsx)(rt,{entry:e,config:C[ze(e)]?.config,runtime:Ye(e),busy:ie===e.id,restarting:ce===e.id,ch:J,onOpen:()=>Ze(e.id),onToggle:()=>void it(e),onRestart:()=>void $e(e)},e.id))}),W?(0,U.jsx)(`p`,{className:`mt-4 text-sm text-red-600 dark:text-red-400`,children:W}):null,(0,U.jsx)(Ce,{presentation:`modal`,open:!!k,onOpenChange:e=>{e||Qe()},closeAriaLabel:J.close,srTitle:k?.label??J.selectChannel,srDescription:k?.description,wide:!0,footer:k?(0,U.jsx)(Ee,{ch:J,dirty:!!R||K!==null,saving:te,onCancel:Qe,onDiscard:()=>{B(null),q(null)},onSave:et}):null,children:k?(0,U.jsxs)(`div`,{className:`space-y-4`,children:[(0,U.jsx)(`div`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,children:(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,U.jsx)(tt,{entry:k}),(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,U.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:k.label}),(0,U.jsx)(`span`,{className:d(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,He(ct)),children:Be(ct,J)})]}),(0,U.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,U.jsx)(`span`,{className:`min-w-0 truncate`,children:!Y(k).ready&&pe(k)?.[1].result===`qr`?J.scanLoginHint.replace(`{{channel}}`,k.label):k.description}),k.docsPath?(0,U.jsxs)(`a`,{href:k.docsPath,target:`_blank`,rel:`noreferrer`,className:`inline-flex shrink-0 items-center gap-1 text-accent hover:underline`,children:[J.docs,(0,U.jsx)(c,{className:`size-3.5`})]}):null]})]})]}),(0,U.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pr-8`,children:[(0,U.jsx)(`span`,{className:`hidden text-xs text-fg-muted sm:inline`,children:Y(k).enabled?J.enabledLabel:J.disabledLabel}),(0,U.jsx)(nt,{checked:Y(k).enabled,disabled:ie===k.id,label:J.toggleChannel.replace(`{{channel}}`,k.label),onToggle:()=>void it(k)})]})]})}),(0,U.jsx)(at,{runtime:ct,restarting:ce===k.id,checking:b,showConnectionOptions:me,canManageConnection:Y(k).ready&&$?.placement!==`replace-config`,ch:J,onRestart:()=>void $e(k),onCheck:()=>void Q(),onManageConnection:()=>he(e=>!e)}),(0,U.jsx)(ot,{entry:k,ch:J}),lt&&$?.placement!==`replace-config`?(0,U.jsx)(ge,{entry:k,locale:e,messages:J,compact:!0,onChanged:async()=>{await N(),await Q(),await S()}},k.id):null,$?.entrypoint&&$.placement===`before-config`?(0,U.jsx)(L,{extensionId:k.extensionId,extensionName:k.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:k.id,entry:k,config:_e}}):null,$?.entrypoint&&$.placement!==`before-config`?(0,U.jsx)(L,{extensionId:k.extensionId,extensionName:k.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:k.id,entry:k,config:_e}}):null,st&&Ae?(0,U.jsxs)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:`mb-4`,children:[(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:J.basicConfiguration}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:J.basicConfigurationHint})]}),(0,U.jsx)(ue,{schema:De,values:_e,onChange:e=>B(e),disabled:te,labels:Z})]}):null,(0,U.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,U.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,U.jsx)(P,{className:`size-4 text-fg-muted`}),J.messageHandling]}),(0,U.jsxs)(`div`,{className:`bg-surface-base/50 p-4`,children:[(0,U.jsxs)(`div`,{className:`mb-3`,children:[(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:J.agentRouting}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:J.messageHandlingHint})]}),(0,U.jsx)(o,{value:Me,options:Re,placeholder:J.agentRoutingSelect,emptyLabel:J.agentRoutingDefault.replace(`{{agent}}`,X||J.agentRoutingSelect),ariaLabel:J.agentRouting,disabled:te||!E,onChange:e=>q(e)})]})]}),st&&qe(Oe)?(0,U.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,U.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,U.jsx)(P,{className:`size-4 text-fg-muted`}),J.advancedConfiguration]}),(0,U.jsx)(`div`,{className:`bg-surface-base/50 p-4`,children:(0,U.jsx)(ue,{schema:Oe,values:_e,onChange:e=>B(e),disabled:te,labels:Z})})]}):null,W?(0,U.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:W}):null]}):null})]}):(0,U.jsxs)(se,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,U.jsx)(oe,{title:t.settingsSections.channels}),(0,U.jsx)(`p`,{className:`text-sm text-fg-muted`,children:J.tokenRequired})]})}export{st as ChannelsSettingsPanel};
@@ -1,2 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i,h as a}from"./chunk-KS7C4IRE-Cq1tE_3b.js";import{n as o,r as s,t as c}from"./popover-select-DldSX8GX.js";import{t as l}from"./circle-check-C23XjkUj.js";import{t as u}from"./loader-circle-CifKLtgG.js";import{t as d}from"./plus-Q2yW6OE7.js";import{t as f}from"./x-B_N4OPjy.js";import{t as p}from"./cn-JdwAhgNB.js";import{a as m,c as h,n as g,r as _}from"./locale-store-DLK05Y1a.js";import{t as v}from"./messages-C9h8SImu.js";import{a as y,i as b,n as x,o as S,r as C,s as w,t as T}from"./dist-BGTk37IG.js";import{n as E}from"./copy-to-clipboard-HOJ79TWv.js";import{t as D}from"./button-CGlRPNzi.js";import{n as O,r as k}from"./gateway-config-swr-D5AM8cyQ.js";import{i as A,o as j}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{n as M}from"./electron-env-Dit0bHgy.js";import{a as N,i as P,n as F,r as I,t as L}from"./dist-Che_jiQF.js";import{$o as R,An as z,B,Cs as V,Cu as H,Dn as U,Fu as W,G,Gc as ee,H as K,Ic as te,J as ne,K as re,Lo as q,Mn as ie,Mu as ae,Nc as oe,Nu as se,Oc as ce,On as le,Pl as ue,Qo as de,Sc as fe,So as pe,Ss as me,Tc as he,Tl as ge,Ts as J,Uc as _e,V as ve,W as ye,Xo as be,Xs as xe,Zo as Se,_s as Ce,as as we,bs as Y,cs as Te,ds as Ee,es as De,fc as Oe,fs as ke,fu as Ae,gs as je,hc as Me,hs as Ne,ia as Pe,is as Fe,jc as Ie,kc as Le,kn as Re,ls as ze,ms as Be,ns as Ve,oc as He,os as Ue,ps as We,q as X,ra as Ge,rc as Ke,rs as qe,ru as Je,ss as Ye,tl as Xe,ts as Ze,us as Qe,vs as $e,xs as et,xu as tt,ys as nt}from"./index-gheM453N.js";import{t as rt}from"./page-tabs-CQx6H-GS.js";var Z=e(t(),1),Q=n(),$=r();function it(e){let t=(0,Q.c)(57),{connector:n,installed:r,onInstall:i,onOpenDetails:a,t:o}=e,s,c,u,d,f,m;if(t[0]!==n||t[1]!==r||t[2]!==i||t[3]!==a||t[4]!==o){let e=n.capabilities.filter(at),h=e.slice(0,2),g=Math.max(0,e.length-h.length),_=o.connect,v;t[11]!==n||t[12]!==o?(v=re(n,o),t[11]=n,t[12]=o,t[13]=v):v=t[13];let y=v,b=n.verificationLevel===`verified`?o.connectorVerified:n.verificationLevel===`beta`?o.connectorBeta:n.verificationLevel===`experimental`?o.connectorExperimental:null,x;t[14]!==_||t[15]!==n||t[16]!==i?(x=e=>(0,$.jsxs)(D,{type:`button`,variant:`primary`,className:p(`h-8 justify-center px-2.5 text-xs font-medium`,e),onClick:()=>i(n),children:[(0,$.jsx)(Xe,{className:`size-4`}),_]}),t[14]=_,t[15]=n,t[16]=i,t[17]=x):x=t[17],s=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`,c=`flex min-w-0 flex-1 flex-col`;let S;t[18]===n?S=t[19]:(S=(0,$.jsx)(ne,{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 O;t[31]!==r||t[32]!==s?(O=r?null:(0,$.jsx)(`div`,{className:`hidden shrink-0 items-center gap-1 sm:flex`,children:s()}),t[31]=r,t[32]=s,t[33]=O):O=t[33];let k;t[34]!==r||t[35]!==o.connectedBadge?(k=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)(l,{className:`size-3`,"aria-hidden":!0}),o.connectedBadge]}):null,t[34]=r,t[35]=o.connectedBadge,t[36]=k):k=t[36];let A;t[37]!==O||t[38]!==k?(A=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start gap-2`,children:[O,k]}),t[37]=O,t[38]=k,t[39]=A):A=t[39],t[40]!==E||t[41]!==A?(u=(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[E,A]}),t[40]=E,t[41]=A,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:o.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]=o,t[5]=s,t[6]=c,t[7]=u,t[8]=d,t[9]=f,t[10]=m}else s=t[5],c=t[6],u=t[7],d=t[8],f=t[9],m=t[10];let h;t[45]!==c||t[46]!==u||t[47]!==d||t[48]!==f?(h=(0,$.jsxs)(`div`,{className:c,children:[u,d,f]}),t[45]=c,t[46]=u,t[47]=d,t[48]=f,t[49]=h):h=t[49];let g;t[50]!==r||t[51]!==s?(g=r?null:(0,$.jsx)(`div`,{className:`mt-4 flex flex-col gap-2 border-t border-edge pt-3 sm:hidden`,children:s(`w-full`)}),t[50]=r,t[51]=s,t[52]=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 at(e){return!e.startsWith(`runtime.`)&&!e.startsWith(`auth.`)}var ot=[`c0`,`c1`,`c2`,`c3`,`c4`,`c5`];function st(e,t){return t.some(t=>t.connectorId===e.id)}var ct=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`;function lt(){let e=(0,Q.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`div`,{className:p(`size-10 shrink-0 rounded-xl`,ct)}),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`,ct)}),(0,$.jsx)(`div`,{className:p(`h-8 w-[4.5rem] shrink-0 rounded-lg`,ct)})]}),(0,$.jsx)(`div`,{className:p(`h-3 w-full`,ct)}),(0,$.jsx)(`div`,{className:p(`h-3 w-[88%]`,ct)})]})]})}),e[1]=n):n=e[1],n}var ut=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`;function dt(){let e=(0,Q.c)(4),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;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`,ut)}),(0,$.jsx)(`div`,{className:p(`h-3 w-72 max-w-full`,ut)})]}),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`,ut)}),(0,$.jsx)(`div`,{className:p(`h-9 w-20 rounded-lg`,ut)})]})]})]}),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`,ut)}),(0,$.jsx)(`div`,{className:p(`h-8 w-24 rounded-md`,ut)}),(0,$.jsx)(`div`,{className:p(`h-8 w-28 rounded-md`,ut)})]}),(0,$.jsx)(`div`,{className:p(`mt-3 h-20 rounded-xl`,ut)})]}),e[3]=i):i=e[3],i}var ft=[`understand`,`act`,`reach`];function pt(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 mt(e){return pt(e)[0]??`act`}function ht(e,t){let n=t?mt(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 gt(e,t){return t.connectorCapabilityLabels[e]??e}function _t(e,t){if(e.runtime.type===`mcp`)return X(t.connectorRuntimeMcp,{serverId:e.runtime.serverId});let n=e.runtime.type===`composio`?e.runtime.toolkit:e.runtime.type===`channel`?e.runtime.channelId:e.runtime.type===`nativeTool`?e.runtime.toolsetId:e.runtime.sourceKind;return X(t.connectorRuntimeGeneric,{runtime:e.runtime.type,id:n??e.runtime.type})}function vt(e,t){return e.auth.mode===`oauth`?t.connectorAuthOAuth:e.auth.mode===`apiKey`?t.connectorAuthApiKey:t.connectorAuthNone}function yt(e){let t=(0,Q.c)(9),{title:n,items:r}=e;if(r.length===0)return null;let i;t[0]===n?i=t[1]:(i=(0,$.jsx)(`h4`,{className:`mb-2 text-xs font-medium text-fg-muted`,children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=r.slice(0,12).map(bt),t[2]=r,t[3]=a);let o;t[4]===a?o=t[5]:(o=(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-lg border border-edge bg-surface-panel`,children:a}),t[4]=a,t[5]=o);let s;return t[6]!==i||t[7]!==o?(s=(0,$.jsxs)(`section`,{children:[i,o]}),t[6]=i,t[7]=o,t[8]=s):s=t[8],s}function bt(e){return(0,$.jsxs)(`div`,{className:`px-3 py-2.5`,children:[(0,$.jsx)(`p`,{className:`break-words font-mono text-xs font-medium text-fg`,children:e.title}),e.description?(0,$.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:e.description}):null]},e.id)}function xt({connector:e,installed:t,onClose:n,onInstall:r,t:i}){let[a,o]=(0,Z.useState)(!1),s=re(e,i),[c,d]=(0,Z.useState)(null),[m,h]=(0,Z.useState)(null),g=pt(e),_=[...(e.setup.secrets??[]).filter(e=>e.required),...(e.setup.config??[]).filter(e=>e.required)],v=e.capabilities.filter(e=>!e.startsWith(`runtime.`)&&!e.startsWith(`auth.`)),E=async()=>{o(!0),h(null);try{d(await Qe(e))}catch(e){d(null),h(e instanceof Error?e.message:String(e))}finally{o(!1)}};return(0,$.jsx)(T,{open:!0,onOpenChange:e=>{e||n()},children:(0,$.jsxs)(S,{children:[(0,$.jsx)(y,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(C,{className: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-panel shadow-float outline-none dark:border-edge`),children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-5 py-5 sm:px-6`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,$.jsx)(ne,{connector:e,size:`lg`}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(w,{className:`text-base font-semibold text-fg`,children:e.displayName}),t?(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)(l,{className:`size-3`,"aria-hidden":!0}),i.connectedBadge]}):null]}),(0,$.jsx)(b,{className:`mt-1 line-clamp-3 text-sm leading-6 text-fg-muted`,children:s})]})]}),(0,$.jsx)(x,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:p(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,J.focusRingPanel),"aria-label":i.modalClose,children:(0,$.jsx)(f,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0})})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-5 overflow-y-auto px-5 py-5 sm:px-6`,children:[g.length?(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:i.connectorWhyConnect}),(0,$.jsx)(`div`,{className:`mt-3 divide-y divide-edge-subtle overflow-hidden rounded-xl border border-edge bg-surface-base`,children:g.map(e=>(0,$.jsxs)(`div`,{className:`px-4 py-3`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:i.connectorBenefitHeadings[e]}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:i.connectorBenefitHints[e]})]},e))})]}):null,(0,$.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-base`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-3 border-b border-edge-subtle px-4 py-3`,children:[(0,$.jsx)(ue,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:i.detailPermissions}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:vt(e,i)})]})]}),(0,$.jsxs)(`div`,{className:`px-4 py-3`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:i.connectorSetupTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:_.length?X(i.connectorRequiredInputsCount,{count:String(_.length)}):i.connectorSetupNone})]})]}),(0,$.jsxs)(`details`,{className:`rounded-xl border border-edge bg-surface-base`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer px-4 py-3 text-sm font-medium text-fg-muted hover:text-fg`,children:i.connectorTechnicalDetails}),(0,$.jsxs)(`div`,{className:`space-y-5 border-t border-edge-subtle px-4 py-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,$.jsx)(Le,{className:`size-3.5`,"aria-hidden":!0}),i.connectorRuntimeTitle]}),(0,$.jsx)(`p`,{className:`mt-1 break-words text-xs text-fg-subtle`,children:_t(e,i)})]}),v.length?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:v.map(e=>(0,$.jsx)(`span`,{className:`rounded-md bg-surface-panel px-2 py-1 text-xs text-fg-muted`,children:gt(e,i)},e))}):null,(0,$.jsxs)(D,{variant:`secondary`,disabled:a,onClick:()=>void E(),children:[a?(0,$.jsx)(u,{className:`size-4 animate-spin`}):(0,$.jsx)(xe,{className:`size-4`}),i.connectorPreviewButton]}),m?(0,$.jsx)(`p`,{className:`rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:m}):null,c?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(yt,{title:i.detailTools,items:c.tools.map(e=>({id:e.name,title:e.shortName??e.name,description:e.description}))}),(0,$.jsx)(yt,{title:i.detailResources,items:c.resources.map(e=>({id:e.uri,title:e.title??e.name??e.uri,description:e.description}))}),(0,$.jsx)(yt,{title:i.detailPrompts,items:c.prompts.map(e=>({id:e.name,title:e.title??e.name,description:e.description}))})]}):null]})]})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-5 py-4 sm:px-6`,children:[(0,$.jsx)(x,{asChild:!0,children:(0,$.jsx)(D,{variant:`secondary`,children:i.modalClose})}),t?null:(0,$.jsxs)(D,{variant:`primary`,onClick:()=>{r(e),n()},children:[(0,$.jsx)(Xe,{className:`size-4`}),i.connect]})]})]})]})})}var St=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 Ct(e){let t=(0,Q.c)(58),{open:n,sessionIdleTtlMinutes:r,saving:i,onChange:a,onSave:o,onClose:s,t:c,mcp:l}=e,d;t[0]===s?d=t[1]:(d=e=>{e||s()},t[0]=s,t[1]=d);let m;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,$.jsx)(y,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),t[2]=m):m=t[2];let h;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(h=p(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(32rem,calc(100vh-2rem))] w-[min(100%-2rem,38rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-panel shadow-float dark:border-edge`),t[3]=h):h=t[3];let g;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(`span`,{className:`flex size-10 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-accent-fg`,children:(0,$.jsx)(_e,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0})}),t[4]=g):g=t[4];let _;t[5]===c.runtimeSettingsTitle?_=t[6]:(_=(0,$.jsx)(w,{className:`text-base font-semibold text-fg`,children:c.runtimeSettingsTitle}),t[5]=c.runtimeSettingsTitle,t[6]=_);let v;t[7]===c.runtimeSettingsHint?v=t[8]:(v=(0,$.jsx)(b,{className:`mt-1 text-sm text-fg-muted`,children:c.runtimeSettingsHint}),t[7]=c.runtimeSettingsHint,t[8]=v);let E;t[9]!==_||t[10]!==v?(E=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[g,(0,$.jsxs)(`div`,{className:`min-w-0`,children:[_,v]})]}),t[9]=_,t[10]=v,t[11]=E):E=t[11];let O;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(O=p(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,J.focusRingPanel),t[12]=O):O=t[12];let k;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,$.jsx)(f,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),t[13]=k):k=t[13];let A;t[14]===c.modalClose?A=t[15]:(A=(0,$.jsx)(x,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:O,"aria-label":c.modalClose,children:k})}),t[14]=c.modalClose,t[15]=A);let j;t[16]!==A||t[17]!==E?(j=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[E,A]}),t[16]=A,t[17]=E,t[18]=j):j=t[18];let M;t[19]===l.idleTtlLabel?M=t[20]:(M=(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:l.idleTtlLabel}),t[19]=l.idleTtlLabel,t[20]=M);let N;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(N=p(St,`w-40 flex-none`),t[21]=N):N=t[21];let P=r??``,F;t[22]===a?F=t[23]:(F=e=>{let t=e.currentTarget.value.trim();a(t===``?void 0:Number.parseInt(t,10))},t[22]=a,t[23]=F);let I;t[24]!==l.idleTtlPlaceholder||t[25]!==P||t[26]!==F?(I=(0,$.jsx)(`input`,{type:`number`,min:0,className:N,value:P,placeholder:l.idleTtlPlaceholder,onChange:F}),t[24]=l.idleTtlPlaceholder,t[25]=P,t[26]=F,t[27]=I):I=t[27];let L;t[28]===l.idleTtlHint?L=t[29]:(L=(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:l.idleTtlHint}),t[28]=l.idleTtlHint,t[29]=L);let R;t[30]!==M||t[31]!==I||t[32]!==L?(R=(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:(0,$.jsxs)(`label`,{className:`flex max-w-xl flex-col gap-1.5`,children:[M,I,L]})}),t[30]=M,t[31]=I,t[32]=L,t[33]=R):R=t[33];let z;t[34]!==s||t[35]!==i||t[36]!==c.modalCancel?(z=(0,$.jsx)(D,{type:`button`,variant:`secondary`,disabled:i,onClick:s,children:c.modalCancel}),t[34]=s,t[35]=i,t[36]=c.modalCancel,t[37]=z):z=t[37];let B;t[38]===o?B=t[39]:(B=()=>void o(),t[38]=o,t[39]=B);let V;t[40]===i?V=t[41]:(V=i?(0,$.jsx)(u,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,t[40]=i,t[41]=V);let H;t[42]!==l.save||t[43]!==i||t[44]!==B||t[45]!==V?(H=(0,$.jsxs)(D,{type:`button`,variant:`primary`,disabled:i,onClick:B,children:[V,l.save]}),t[42]=l.save,t[43]=i,t[44]=B,t[45]=V,t[46]=H):H=t[46];let U;t[47]!==z||t[48]!==H?(U=(0,$.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[z,H]}),t[47]=z,t[48]=H,t[49]=U):U=t[49];let W;t[50]!==j||t[51]!==R||t[52]!==U?(W=(0,$.jsxs)(S,{children:[m,(0,$.jsxs)(C,{className:h,children:[j,R,U]})]}),t[50]=j,t[51]=R,t[52]=U,t[53]=W):W=t[53];let G;return t[54]!==n||t[55]!==d||t[56]!==W?(G=(0,$.jsx)(T,{open:n,onOpenChange:d,children:W}),t[54]=n,t[55]=d,t[56]=W,t[57]=G):G=t[57],G}var wt=(0,Z.memo)(function(e){let t=(0,Q.c)(12),{value:n,onChange:r,placeholder:i,className:a}=e,o;t[0]===a?o=t[1]:(o=p(`relative flex min-h-11 sm:min-h-9 min-w-0 flex-1 cursor-text items-center rounded-pill border border-edge bg-surface-panel py-1.5 pl-9 pr-3 focus-within:ring-2 focus-within:ring-accent`,a),t[0]=a,t[1]=o);let s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(Ie,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-disabled`,strokeWidth:1.75,"aria-hidden":!0}),t[2]=s):s=t[2];let c;t[3]===r?c=t[4]:(c=e=>r(e.currentTarget.value),t[3]=r,t[4]=c);let l;t[5]!==i||t[6]!==c||t[7]!==n?(l=(0,$.jsx)(`input`,{type:`search`,"aria-label":i,enterKeyHint:`search`,value:n,onChange:c,placeholder:i,autoComplete:`off`,spellCheck:!1,className:`min-w-0 flex-1 appearance-none border-0 bg-transparent py-0.5 text-base sm:text-sm leading-normal text-fg caret-current placeholder:text-fg-disabled focus:border-0 focus:shadow-none focus:outline-none focus:ring-0 focus-visible:outline-none`}),t[5]=i,t[6]=c,t[7]=n,t[8]=l):l=t[8];let u;return t[9]!==o||t[10]!==l?(u=(0,$.jsxs)(`label`,{className:o,children:[s,l]}),t[9]=o,t[10]=l,t[11]=u):u=t[11],u}),Tt=(0,Z.memo)(function(e){let t=(0,Q.c)(20),{onBrowseCatalog:n,onAddCustomServer:r,addLabel:i,browseLabel:a,customLabel:o}=e,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,$.jsx)(d,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[0]=s):s=t[0];let c;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,$.jsx)(W,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[1]=c):c=t[1];let l;t[2]===i?l=t[3]:(l=(0,$.jsx)(ie,{asChild:!0,children:(0,$.jsxs)(D,{type:`button`,variant:`primary`,className:`shrink-0 gap-2`,children:[s,i,c]})}),t[2]=i,t[3]=l);let u;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(u=p(`touch-target flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none data-[highlighted]:bg-surface-hover`,J.transition),t[4]=u):u=t[4];let f;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(Oe,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[5]=f):f=t[5];let m;t[6]!==a||t[7]!==n?(m=(0,$.jsxs)(le,{className:u,onSelect:n,children:[f,a]}),t[6]=a,t[7]=n,t[8]=m):m=t[8];let h;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(h=p(`touch-target flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none data-[highlighted]:bg-surface-hover`,J.transition),t[9]=h):h=t[9];let g;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(xe,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[10]=g):g=t[10];let _;t[11]!==o||t[12]!==r?(_=(0,$.jsxs)(le,{className:h,onSelect:r,children:[g,o]}),t[11]=o,t[12]=r,t[13]=_):_=t[13];let v;t[14]!==m||t[15]!==_?(v=(0,$.jsx)(Re,{children:(0,$.jsxs)(U,{className:`z-50 min-w-[14rem] rounded-xl border border-edge bg-surface-panel p-1 shadow-popover dark:border-edge`,sideOffset:6,align:`end`,children:[m,_]})}),t[14]=m,t[15]=_,t[16]=v):v=t[16];let y;return t[17]!==v||t[18]!==l?(y=(0,$.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center justify-end gap-2`,children:(0,$.jsxs)(z,{children:[l,v]})}),t[17]=v,t[18]=l,t[19]=y):y=t[19],y}),Et=/^([^:=]+)[:=](.*)$/;function Dt(e){let t=e.trim();if(!t)return null;try{let e=JSON.parse(t);if(e&&typeof e==`object`&&!Array.isArray(e))return Object.entries(e).map(([e,t])=>({key:e,value:t==null?``:String(t)}))}catch{}let n=[];for(let e of t.split(/\r?\n/)){let t=e.trim();if(!t)continue;let r=Et.exec(t);r&&n.push({key:r[1].trim(),value:r[2].trim()})}return n.length>0?n:null}function Ot(e){let t={};for(let n of e){let e=n.key.trim();e&&(t[e]=n.value)}return Object.keys(t).length>0?t:void 0}function kt(e){if(!e||typeof e!=`object`)return[{key:``,value:``}];let t=Object.entries(e).map(([e,t])=>({key:e,value:t==null?``:String(t)}));return t.length>0?t:[{key:``,value:``}]}function At(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 jt(e){let t=e&&typeof e==`object`&&`mcp`in e?e.mcp:void 0,n=(t&&typeof t==`object`?t:{}).servers,r={};if(!n||typeof n!=`object`||Array.isArray(n))return r;for(let[e,t]of Object.entries(n))!t||typeof t!=`object`||Array.isArray(t)||At(t)&&(r[e]=t);return r}function Mt(e){let t=e.trim();if(t)return t.split(/\s+/).filter(Boolean)}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){if(e.transport===`stdio`){let t={command:e.command.trim()},n=Mt(e.argsText);return n?.length&&(t.args=n),e.cwd.trim()&&(t.cwd=e.cwd.trim()),e.envJson.trim()&&(t.env=Nt(e.envJson)),e.connectionTimeoutMs!=null&&Number.isFinite(e.connectionTimeoutMs)&&(t.connectionTimeoutMs=e.connectionTimeoutMs),e.requestTimeoutMs!=null&&Number.isFinite(e.requestTimeoutMs)&&(t.requestTimeoutMs=e.requestTimeoutMs),t}let t={url:e.url.trim(),transport:e.transport},n=Ot(e.headers);return n&&(t.headers=n),e.transport===`streamable-http`&&e.auth===`oauth`&&(t.auth={type:`oauth`,...e.oauthClientId.trim()?{clientId:e.oauthClientId.trim()}:{}}),e.connectionTimeoutMs!=null&&Number.isFinite(e.connectionTimeoutMs)&&(t.connectionTimeoutMs=e.connectionTimeoutMs),e.requestTimeoutMs!=null&&Number.isFinite(e.requestTimeoutMs)&&(t.requestTimeoutMs=e.requestTimeoutMs),t}function Ft(e,t){let n=typeof t.url==`string`&&t.url.trim().length>0,r=typeof t.transport==`string`?t.transport.trim().toLowerCase():``,i=n?r===`sse`?`sse`:`streamable-http`:`stdio`,a=t.headers&&typeof t.headers==`object`&&!Array.isArray(t.headers)?t.headers:void 0,o=t.auth&&typeof t.auth==`object`&&!Array.isArray(t.auth)?t.auth:void 0,s=o?.type===`oauth`?`oauth`:`none`;return{clientKey:e,id:e,transport:i,command:typeof t.command==`string`?t.command:``,argsText:Array.isArray(t.args)?t.args.map(String).join(` `):``,envJson:t.env&&typeof t.env==`object`?JSON.stringify(t.env,null,2):``,cwd:typeof t.cwd==`string`?t.cwd:typeof t.workingDirectory==`string`?t.workingDirectory:``,url:typeof t.url==`string`?t.url:``,headers:kt(a),auth:s,oauthClientId:typeof o?.clientId==`string`?o.clientId:``,connectionTimeoutMs:typeof t.connectionTimeoutMs==`number`&&Number.isFinite(t.connectionTimeoutMs)?t.connectionTimeoutMs:void 0,requestTimeoutMs:typeof t.requestTimeoutMs==`number`&&Number.isFinite(t.requestTimeoutMs)?t.requestTimeoutMs:void 0}}function It(e=``){return{clientKey:crypto.randomUUID(),id:e,transport:`stdio`,command:``,argsText:``,envJson:``,cwd:``,url:``,headers:[{key:`Authorization`,value:``}],auth:`none`,oauthClientId:``,connectionTimeoutMs:void 0,requestTimeoutMs:void 0}}function Lt(e){let t=e&&typeof e==`object`&&`mcp`in e?e.mcp:void 0,n=t&&typeof t==`object`?t:{},r=n.servers,i=r&&typeof r==`object`&&!Array.isArray(r)?Object.entries(r).flatMap(([e,t])=>!t||typeof t!=`object`||Array.isArray(t)||At(t)?[]:[Ft(e,t)]).sort((e,t)=>e.id.localeCompare(t.id)):[],a=typeof n.sessionIdleTtlMs==`number`?n.sessionIdleTtlMs:void 0;return{sessionIdleTtlMinutes:a==null?void 0:a===0?0:Math.round(a/6e4),servers:i}}function Rt(e){return Pt(e)}async function zt(e,t={}){let n={};for(let r of e.servers){let e=r.id.trim();if(e){if(t[e])throw Error(`Server id "${e}" is reserved by an installed connector.`);n[e]=Pt(r)}}let r={servers:{...t,...n}};e.sessionIdleTtlMinutes!=null&&Number.isFinite(e.sessionIdleTtlMinutes)&&(r.sessionIdleTtlMs=e.sessionIdleTtlMinutes===0?0:Math.round(e.sessionIdleTtlMinutes*6e4)),await m(_(`/api/config`),{method:`PATCH`,body:JSON.stringify({mcp:r})}),O()}async function Bt(e,t,n=``){let r=await m(_(`/api/mcp/servers/${encodeURIComponent(e)}/oauth${n}`),{method:t});if(!r.payload)throw Error(r.error??`MCP OAuth request failed`);return r.payload}function Vt(e){return Bt(e,`GET`)}function Ht(e){return Bt(e,`POST`,`/start`)}function Ut(e){return Bt(e,`DELETE`)}function Wt(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(!n||typeof n!=`object`)continue;let e=n;if(typeof e.name!=`string`)continue;let r=e.name.trim();if(!r)continue;let i=typeof e.shortName==`string`&&e.shortName.trim()?e.shortName.trim():void 0,a=typeof e.description==`string`&&e.description.trim()?e.description.trim():void 0;t.push({name:r,shortName:i,description:a})}return t}function Gt(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(!n||typeof n!=`object`)continue;let e=n;if(typeof e.uri!=`string`||typeof e.name!=`string`)continue;let r=e.uri.trim(),i=e.name.trim();!r||!i||t.push({uri:r,name:i,title:typeof e.title==`string`&&e.title.trim()?e.title.trim():void 0,description:typeof e.description==`string`&&e.description.trim()?e.description.trim():void 0,mimeType:typeof e.mimeType==`string`&&e.mimeType.trim()?e.mimeType.trim():void 0})}return t}function Kt(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(!n||typeof n!=`object`)continue;let e=n;if(typeof e.name!=`string`)continue;let r=e.name.trim();r&&t.push({name:r,title:typeof e.title==`string`&&e.title.trim()?e.title.trim():void 0,description:typeof e.description==`string`&&e.description.trim()?e.description.trim():void 0,argumentCount:typeof e.argumentCount==`number`?e.argumentCount:0})}return t}async function qt(e,t){let n=await m(_(`/api/mcp/servers/${encodeURIComponent(e)}/test`),{method:`POST`,body:t?JSON.stringify({server:t}):void 0});if(!n.payload)throw Error(n.error??`MCP test failed`);let r=Wt(n.payload.tools),i=Gt(n.payload.resources),a=Kt(n.payload.prompts);return{serverId:n.payload.serverId??e,toolCount:typeof n.payload.toolCount==`number`?n.payload.toolCount:r.length,resourceCount:typeof n.payload.resourceCount==`number`?n.payload.resourceCount:i.length,promptCount:typeof n.payload.promptCount==`number`?n.payload.promptCount:a.length,tools:r,resources:i,prompts:a}}function Jt(e){return e.connectionTimeoutMs==null||!Number.isFinite(e.connectionTimeoutMs)?``:String(Math.round(e.connectionTimeoutMs/1e3))}function Yt(e){let t=e.trim();if(!t)return;let n=Number.parseInt(t,10);if(!(!Number.isFinite(n)||n<1||n>600))return n*1e3}function Xt(e){return e.requestTimeoutMs==null||!Number.isFinite(e.requestTimeoutMs)?``:String(Math.round(e.requestTimeoutMs/1e3))}function Zt(e){let t=e.trim();if(!t)return;let n=Number.parseInt(t,10);if(!(!Number.isFinite(n)||n<1||n>14400))return n*1e3}function Qt(e){if(e.transport===`stdio`){let t=e.command.trim();if(!t)return``;let n=e.argsText.trim();return n?`${t} ${n}`:t}return e.url.trim()}function $t({row:e,t,cs:n,onEdit:r,onRemove:i}){let[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(!1),[l,d]=(0,Z.useState)(!1),[f,p]=(0,Z.useState)(null),[m,h]=(0,Z.useState)(null),[g,_]=(0,Z.useState)(null),[v,y]=(0,Z.useState)(!1),b=Qt(e),x=e.transport===`streamable-http`&&e.auth===`oauth`;(0,Z.useEffect)(()=>{if(!x){_(null);return}let t=!1,n=async()=>{try{let n=await Vt(e.id.trim());t||(_(n),n.status===`error`&&n.session?.error&&h(n.session.error),n.status===`connected`&&h(null))}catch(e){t||h(e instanceof Error?e.message:String(e))}};n();let r=window.setInterval(()=>{g?.status===`authorizing`&&n()},1e3);return()=>{t=!0,window.clearInterval(r)}},[g?.status,e.id,x]);let S=(0,Z.useCallback)(async()=>{y(!0),h(null);let n=K();try{let r=await Ht(e.id.trim());_(r),r.status===`error`&&r.session?.error&&h(r.session.error),r.status===`connected`&&h(null);let i=r.session?.authorizationUrl;i?await ve(i,n)||h(t.oauthOpenFailed):B(n)}catch(e){B(n),h(e instanceof Error?e.message:String(e))}finally{y(!1)}},[e.id,t.oauthOpenFailed]),C=(0,Z.useCallback)(async()=>{y(!0),h(null);try{_(await Ut(e.id.trim()))}catch(e){h(e instanceof Error?e.message:String(e))}finally{y(!1)}},[e.id]),w=(0,Z.useCallback)(async()=>{o(!0),h(null);try{let t=await qt(e.id.trim());p({toolCount:t.toolCount,resourceCount:t.resourceCount,promptCount:t.promptCount})}catch(e){h(e instanceof Error?e.message:String(e))}finally{o(!1)}},[e.id]),T=(0,Z.useCallback)(async()=>{c(!0),h(null);try{await i()}catch(e){h(e instanceof Error?e.message:String(e)),c(!1)}},[i]);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`px-4 py-3.5 hover:bg-surface-hover/50`,children:[(0,$.jsxs)(`button`,{type:`button`,className:`block w-full min-w-0 text-left`,onClick:r,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:e.id.trim()||t.cardUntitled}),(0,$.jsx)(`span`,{className:`rounded-full bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:n.customBadge}),(0,$.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:t.transportLabels[e.transport]}),x&&g?(0,$.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2 py-0.5 text-[11px] font-medium text-accent-fg`,children:t.oauthStatus[g.status===`not_configured`?`disconnected`:g.status]}):null]}),b?(0,$.jsx)(`p`,{className:`mt-3 line-clamp-2 break-all font-mono text-xs leading-5 text-fg-subtle`,title:b,children:b}):null,m?(0,$.jsx)(`p`,{className:`mt-3 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:m}):null,f?(0,$.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:X(n.customCapabilitySummary,{tools:String(f.toolCount),resources:String(f.resourceCount),prompts:String(f.promptCount)})}):null]}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap justify-end gap-2`,children:[x&&g?.status!==`connected`?(0,$.jsxs)(D,{variant:`secondary`,disabled:v,onClick:()=>void S(),children:[v?(0,$.jsx)(u,{className:`size-4 animate-spin`}):(0,$.jsx)(ge,{className:`size-4`}),g?.status===`authorizing`?t.oauthOpenAuthorization:t.oauthConnect]}):(0,$.jsxs)(D,{variant:`secondary`,disabled:a,onClick:()=>void w(),children:[a?(0,$.jsx)(u,{className:`size-4 animate-spin`}):(0,$.jsx)(ee,{className:`size-4`}),t.testConnection]}),x&&g?.status===`connected`?(0,$.jsxs)(D,{variant:`ghost`,disabled:v,onClick:()=>void C(),children:[v?(0,$.jsx)(u,{className:`size-4 animate-spin`}):(0,$.jsx)(Ke,{className:`size-4`}),t.oauthDisconnect]}):null,(0,$.jsxs)(D,{variant:`ghost`,disabled:s,onClick:()=>d(!0),children:[s?(0,$.jsx)(u,{className:`size-4 animate-spin`}):(0,$.jsx)(He,{className:`size-4`}),t.removeServer]})]})]}),(0,$.jsx)(Pe,{open:l,title:n.removeConfirmTitle.replace(`{{name}}`,e.id.trim()||t.cardUntitled),description:n.removeConfirmDescription,confirmLabel:t.removeServer,cancelLabel:n.modalCancel,destructive:!0,onConfirm:()=>{d(!1),T()},onCancel:()=>{s||d(!1)}})]})}function en(e,t){return e?t&&e.startsWith(t)?e.slice(t.length):e:``}function tn(e,t,n){let r=t.trim().toLowerCase();if(!r)return!0;let i=e.shortName||en(e.name,n);return[e.name,i,e.description].filter(Boolean).join(`
2
- `).toLowerCase().includes(r)}function nn(e,t){return e?t&&e.startsWith(t)?e.slice(t.length):e:``}function rn(e){let t=(0,Q.c)(29),{tools:n,stripPrefix:r,searchPlaceholder:i,searchEmptyLabel:a}=e,[o,s]=(0,Z.useState)(``),c;if(t[0]!==o||t[1]!==r||t[2]!==n){let e;t[4]!==o||t[5]!==r?(e=e=>tn(e,o,r),t[4]=o,t[5]=r,t[6]=e):e=t[6],c=n.filter(e),t[0]=o,t[1]=r,t[2]=n,t[3]=c}else c=t[3];let l=c,u;t[7]===o?u=t[8]:(u=o.trim(),t[7]=o,t[8]=u);let d=u.length>0,f;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(Ie,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),t[9]=f):f=t[9];let m,h;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(m=p(`w-full rounded-lg border border-edge bg-surface-panel py-2 pl-9 pr-3 text-sm text-fg`,`placeholder:text-fg-subtle`,q),h=e=>s(e.target.value),t[10]=m,t[11]=h):(m=t[10],h=t[11]);let g;t[12]!==o||t[13]!==i?(g=(0,$.jsxs)(`div`,{className:`relative`,children:[f,(0,$.jsx)(`input`,{type:`search`,value:o,placeholder:i,"aria-label":i,className:m,onChange:h})]}),t[12]=o,t[13]=i,t[14]=g):g=t[14];let _;t[15]!==l.length||t[16]!==d||t[17]!==n.length?(_=d?(0,$.jsxs)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:[l.length,` / `,n.length]}):null,t[15]=l.length,t[16]=d,t[17]=n.length,t[18]=_):_=t[18];let v;t[19]!==g||t[20]!==_?(v=(0,$.jsxs)(`div`,{className:`border-b border-edge px-5 py-3`,children:[g,_]}),t[19]=g,t[20]=_,t[21]=v):v=t[21];let y;t[22]!==l||t[23]!==a||t[24]!==r?(y=(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:l.length===0?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:a}):(0,$.jsx)(`ul`,{className:`flex flex-col gap-2`,children:l.map((e,t)=>{let n=e.shortName||nn(e.name,r)||e.name||`?`,i=e.name||`tool-${t}`;return(0,$.jsxs)(`li`,{className:`min-w-0 rounded-lg border border-edge bg-surface-base px-3 py-2.5`,children:[(0,$.jsx)(`div`,{className:`truncate font-mono text-sm font-medium text-fg`,title:e.name===n?n:e.name,children:n}),e.description?(0,$.jsx)(`p`,{className:`mt-1 truncate text-xs leading-relaxed text-fg-muted`,title:e.description,children:e.description}):null]},i)})})}),t[22]=l,t[23]=a,t[24]=r,t[25]=y):y=t[25];let b;return t[26]!==v||t[27]!==y?(b=(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[v,y]}),t[26]=v,t[27]=y,t[28]=b):b=t[28],b}function an(e){let t=(0,Q.c)(38),{open:n,onOpenChange:r,serverId:i,title:a,subtitle:o,searchPlaceholder:s,searchEmptyLabel:c,emptyLabel:l,closeLabel:u,tools:d,stripPrefix:m}=e,h;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(y,{className:p(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,j)}),t[0]=h):h=t[0];let g;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(g=p(`fixed left-1/2 top-1/2 flex max-h-[min(88vh,40rem)] w-[min(100%-2rem,min(92vw,36rem))] -translate-x-1/2 -translate-y-1/2 flex-col`,A,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`),t[1]=g):g=t[1];let _;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(xe,{className:`size-4 shrink-0 text-accent`,"aria-hidden":!0}),t[2]=_):_=t[2];let v;t[3]===a?v=t[4]:(v=(0,$.jsxs)(w,{className:`flex items-center gap-2 text-base font-semibold text-fg`,children:[_,a]}),t[3]=a,t[4]=v);let E;t[5]!==i||t[6]!==o||t[7]!==d.length?(E=o.replace(`{{serverId}}`,i).replace(`{{count}}`,String(d.length)),t[5]=i,t[6]=o,t[7]=d.length,t[8]=E):E=t[8];let O;t[9]===E?O=t[10]:(O=(0,$.jsx)(b,{className:`mt-1 text-sm text-fg-muted`,children:E}),t[9]=E,t[10]=O);let k;t[11]!==v||t[12]!==O?(k=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[v,O]}),t[11]=v,t[12]=O,t[13]=k):k=t[13];let M;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,$.jsx)(f,{className:`size-4`,"aria-hidden":!0}),t[14]=M):M=t[14];let N;t[15]===u?N=t[16]:(N=(0,$.jsx)(x,{asChild:!0,children:(0,$.jsx)(D,{type:`button`,variant:`ghost`,className:`size-8 shrink-0 px-0`,"aria-label":u,children:M})}),t[15]=u,t[16]=N);let P;t[17]!==k||t[18]!==N?(P=(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3 border-b border-edge px-5 py-4`,children:[k,N]}),t[17]=k,t[18]=N,t[19]=P):P=t[19];let F;t[20]!==l||t[21]!==n||t[22]!==c||t[23]!==s||t[24]!==i||t[25]!==m||t[26]!==d?(F=d.length>0?(0,$.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,$.jsx)(rn,{tools:d,stripPrefix:m,searchPlaceholder:s,searchEmptyLabel:c},`${i}-${n?`open`:`closed`}`)}):(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:l})}),t[20]=l,t[21]=n,t[22]=c,t[23]=s,t[24]=i,t[25]=m,t[26]=d,t[27]=F):F=t[27];let I;t[28]===u?I=t[29]:(I=(0,$.jsx)(`div`,{className:`flex justify-end border-t border-edge px-5 py-3`,children:(0,$.jsx)(x,{asChild:!0,children:(0,$.jsx)(D,{type:`button`,variant:`secondary`,children:u})})}),t[28]=u,t[29]=I);let L;t[30]!==P||t[31]!==F||t[32]!==I?(L=(0,$.jsxs)(S,{children:[h,(0,$.jsxs)(C,{className:g,children:[P,F,I]})]}),t[30]=P,t[31]=F,t[32]=I,t[33]=L):L=t[33];let R;return t[34]!==r||t[35]!==n||t[36]!==L?(R=(0,$.jsx)(T,{open:n,onOpenChange:r,children:L}),t[34]=r,t[35]=n,t[36]=L,t[37]=R):R=t[37],R}function on(e){let t=e.connectedAt?Date.parse(e.connectedAt):0;return Number.isFinite(t)?t:0}function sn(e,t){return e.status===`active`&&t.status!==`active`?-1:e.status!==`active`&&t.status===`active`?1:e.isCurrentAuthorization===t.isCurrentAuthorization?e.isDefault===t.isDefault?on(t)-on(e):e.isDefault?-1:1:e.isCurrentAuthorization?-1:1}function cn(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(sn);return{key:e,primary:n[0],authorizations:n}}).sort((e,t)=>sn(e.primary,t.primary))}var ln=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 un(e){return e.materialized.type===`composio`?e.materialized.toolkit:null}function dn(e,t){return e===`write`?t.composioScopeWrite:e===`admin`?t.composioScopeAdmin:t.composioScopeRead}function fn(e,t,n){return e.status===`connected`?X(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 pn(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 mn(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 hn({instance:e,t,onChanged:n}){let r=un(e),[i,a]=(0,Z.useState)([]),[c,d]=(0,Z.useState)([]),[f,m]=(0,Z.useState)([]),[h,g]=(0,Z.useState)(null),[_,v]=(0,Z.useState)([]),[y,b]=(0,Z.useState)(null),[x,S]=(0,Z.useState)(null),[C,w]=(0,Z.useState)([]),[T,E]=(0,Z.useState)({}),[O,k]=(0,Z.useState)(`read`),[A,j]=(0,Z.useState)(!1),[N,P]=(0,Z.useState)(null),[F,I]=(0,Z.useState)(!1),[L,R]=(0,Z.useState)(null),z=(0,Z.useMemo)(()=>cn(i),[i]),B=(0,Z.useCallback)(async()=>{if(!(!r||e.materialized.type!==`composio`||e.materialized.role===`credential`)){j(!0),P(null);try{let[e,t,n,i,o,s]=await Promise.all([Ue(),qe(r),Ve(r),Ze(r),ze(),Fe(r)]),[c,l]=await Promise.allSettled([Ye(r),Te(20)]),u=e.filter(e=>e.toolkit.toLowerCase()===r.toLowerCase());a(u),d(c.status===`fulfilled`?c.value:[]),m(l.status===`fulfilled`?l.value.filter(e=>!e.toolkit||e.toolkit.toLowerCase()===r.toLowerCase()):[]),I(c.status===`rejected`||l.status===`rejected`),k(t),g(n.policy),v(n.agents),b(i),w(o),S(s);let f=cn(u).map(e=>e.primary).filter(e=>!!e.accountId),p=await Promise.allSettled(f.map(async e=>[e.accountId,await we(e.accountId)]));E(Object.fromEntries(p.flatMap(e=>e.status===`fulfilled`?[e.value]:[])))}catch(e){P(e instanceof Error?e.message:String(e))}finally{j(!1)}}},[e.materialized,r]);(0,Z.useEffect)(()=>{B()},[B]);let H=(0,Z.useCallback)(async()=>{if(r){j(!0),P(null);try{let t=await je(e.connectorId);if(!t.authorizationUrl)throw Error(`The authorization provider did not return an authorization URL.`);if(M()){let e=await window.electronAPI?.shell?.openExternalUrl(t.authorizationUrl);if(!e?.ok)throw Error(e?.error??`Could not open the system browser.`)}else window.open(t.authorizationUrl,`_blank`,`noopener,noreferrer`);await V(r,t.connectionId),await Promise.all([n?.(),B()])}catch(e){P(e instanceof Error?e.message:String(e))}finally{j(!1)}}},[e.connectorId,B,n,r]),U=(0,Z.useCallback)(async t=>{j(!0),P(null);try{await et(e.instanceId,{config:{...e.config??{},authConfigId:t||void 0}}),await Promise.all([n?.(),B()])}catch(e){P(e instanceof Error?e.message:String(e))}finally{j(!1)}},[e.config,e.instanceId,B,n]),W=(0,Z.useCallback)(async e=>{if(r){k(e),P(null);try{await Be(r,e)}catch(e){P(e instanceof Error?e.message:String(e)),await B()}}},[B,r]),G=(0,Z.useCallback)(async e=>{if(r){P(null);try{g(await Y(r,e))}catch(e){P(e instanceof Error?e.message:String(e))}}},[r]),ee=(0,Z.useCallback)(e=>{if(!h)return;let t=h.allowedAgentIds.includes(e);t&&h.allowedAgentIds.length===1||G({allowedAgentIds:t?h.allowedAgentIds.filter(t=>t!==e):[...h.allowedAgentIds,e]})},[G,h]),K=(0,Z.useCallback)(async e=>{j(!0),P(null);try{await e(),await B()}catch(e){P(e instanceof Error?e.message:String(e))}finally{j(!1)}},[B]);if(!r)return null;if(e.materialized.type===`composio`&&e.materialized.role===`credential`)return(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.composioApiKeyStored});let ne=z.filter(e=>e.primary.status===`active`).length,re=ne>0?t.composioAddAccount:t.composioConnectAccount,q=y?.status===`connected`,ie=x?.requiresCustomAuthConfig===!0,oe=x?.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`,q?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-amber-500/10 text-amber-700 dark:text-amber-300`),children:[q?(0,$.jsx)(l,{className:`size-3.5`}):(0,$.jsx)(ae,{className:`size-3.5`}),q?t.connectionReady:y?t.connectionNeedsSetup:t.connectionChecking]}),(0,$.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:X(t.composioAccountCount,{count:String(z.length)})})]}),(0,$.jsxs)(D,{variant:`primary`,className:`shrink-0`,disabled:A,onClick:()=>void H(),children:[A?(0,$.jsx)(u,{className:`size-4 animate-spin`}):(0,$.jsx)(ue,{className:`size-4`}),re]})]}),N?(0,$.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:N}):null,y&&!q?(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:fn(y,ne,t)}),y.recovery===`none`?null:(0,$.jsx)(D,{variant:`secondary`,disabled:A,onClick:()=>void(y.recovery===`retry`?B():H()),children:y.recovery===`retry`?t.composioRetry:t.composioReconnectAccount})]}):null,ie&&oe.length===0?(0,$.jsx)(`p`,{className:`rounded-xl border border-amber-500/25 bg-amber-500/5 px-4 py-3 text-sm text-amber-800 dark:text-amber-200`,children:t.composioAuthConfigEmpty}):null,h?(0,$.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-base`,children:[(0,$.jsxs)(`div`,{className:`grid gap-3 border-b border-edge-subtle px-4 py-4 sm:grid-cols-[minmax(0,1fr)_15rem] sm:items-start`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.composioAccessTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:O===`read`?t.composioAccessReadHint:O===`admin`?t.composioAccessAdminHint:t.composioAccessWriteHint})]}),(0,$.jsxs)(o,{value:O,onChange:e=>void W(e.currentTarget.value),children:[(0,$.jsx)(s,{value:`read`,children:t.composioAccessReadOnly}),(0,$.jsx)(s,{value:`write`,children:t.composioAccessReadWrite}),O===`admin`?(0,$.jsx)(s,{value:`admin`,children:t.composioAccessAdminCurrent}):null]})]}),(0,$.jsxs)(`div`,{className:`grid gap-3 border-b border-edge-subtle px-4 py-4 sm:grid-cols-[minmax(0,1fr)_15rem] sm:items-center`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.composioConfirmationPolicy}),(0,$.jsxs)(o,{value:h.confirmationPolicy,onChange:e=>void G({confirmationPolicy:e.currentTarget.value}),children:[(0,$.jsx)(s,{value:`writes`,children:t.composioConfirmWrites}),(0,$.jsx)(s,{value:`always`,children:t.composioConfirmAlways}),h.confirmationPolicy===`never`?(0,$.jsx)(s,{value:`never`,children:t.composioConfirmNever}):null]})]}),(0,$.jsxs)(`div`,{className:`px-4 py-4`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.composioAllowedAgents}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:h.allowedAgentIds.length?t.composioAllowedAgentsSelected:t.composioAllowedAgentsAll}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,$.jsx)(`button`,{type:`button`,className:p(`rounded-full border px-2.5 py-1 text-xs transition-colors`,h.allowedAgentIds.length===0?`border-accent bg-accent/10 text-accent`:`border-edge bg-surface-panel text-fg-muted hover:text-fg`),onClick:()=>void G({allowedAgentIds:[]}),children:t.composioAllowedAgentsAllOption}),_.map(e=>(0,$.jsx)(`button`,{type:`button`,className:p(`rounded-full border px-2.5 py-1 text-xs transition-colors`,h.allowedAgentIds.includes(e.id)?`border-accent bg-accent/10 text-accent`:`border-edge bg-surface-panel text-fg-muted hover:text-fg`),onClick:()=>ee(e.id),children:e.name},e.id))]})]})]}):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}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:X(t.composioAccountCount,{count:String(z.length)})})]}),(0,$.jsxs)(D,{variant:`ghost`,className:`h-8 px-2 text-xs`,disabled:A,onClick:()=>void B(),children:[(0,$.jsx)(te,{className:p(`size-3.5`,A&&`animate-spin`)}),t.refresh]})]}),z.length?(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-xl border border-edge bg-surface-base`,children:z.map(e=>{let i=e.primary,a=C.find(e=>i.accountId?e.accountId===i.accountId:e.connectionId===i.id),c=i.accountId?T[i.accountId]:void 0;return(0,$.jsxs)(`article`,{className:`px-4 py-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:i.alias??i.workspace??i.accountEmail??i.username??t.composioUnnamedAuthorization}),i.isDefault?(0,$.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-[11px] text-fg-muted`,children:t.composioDefaultAccount}):null]}),(0,$.jsx)(`p`,{className:p(`mt-1 text-xs`,i.status===`active`?`text-emerald-700 dark:text-emerald-300`:`text-amber-700 dark:text-amber-300`),children:pn(i.status,t)}),a?(0,$.jsx)(`p`,{className:p(`mt-1 text-xs`,a.status===`failed`?`text-red-600`:`text-fg-subtle`),children:X(t.connectorLearningStatus,{status:mn(a,c,t),count:String(a.candidatesCreated)})}):null]}),i.status===`active`?(0,$.jsxs)(D,{variant:`secondary`,className:`h-8 shrink-0 px-2.5 text-xs`,disabled:A,onClick:()=>void K(async()=>{if(!i.accountId)throw Error(`Connector account is unavailable.`);await Ne(i.accountId),await n?.()}),children:[(0,$.jsx)(te,{className:`size-3.5`}),t.composioSyncNow]}):null]}),(0,$.jsxs)(`details`,{className:`mt-3 text-xs text-fg-muted`,children:[(0,$.jsx)(`summary`,{className:`w-fit cursor-pointer font-medium hover:text-fg`,children:t.composioAccountSettings}),(0,$.jsxs)(`div`,{className:`mt-3 space-y-4 rounded-lg bg-surface-panel p-3`,children:[c?(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:c.scanEnabled,disabled:A,onChange:e=>void K(()=>me(i.accountId,{scanEnabled:e.currentTarget.checked}))}),t.connectorScheduledScan]}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:c.proactiveEnabled,disabled:A||!c.scanEnabled,onChange:e=>void K(()=>me(i.accountId,{proactiveEnabled:e.currentTarget.checked}))}),t.connectorProactiveUse]}),c.scanEnabled?(0,$.jsxs)(`label`,{className:`sm:col-span-2`,children:[t.connectorScanInterval,(0,$.jsxs)(o,{className:`mt-1`,value:String(c.intervalMinutes??30),disabled:A,onChange:e=>void K(()=>me(i.accountId,{intervalMinutes:Number(e.currentTarget.value)})),children:[(0,$.jsxs)(s,{value:`5`,children:[`5 `,t.connectorMinutes]}),(0,$.jsxs)(s,{value:`15`,children:[`15 `,t.connectorMinutes]}),(0,$.jsxs)(s,{value:`30`,children:[`30 `,t.connectorMinutes]}),(0,$.jsxs)(s,{value:`60`,children:[`60 `,t.connectorMinutes]})]})]}):null]}):null,(0,$.jsxs)(`label`,{className:`block`,children:[t.composioAccountAlias,(0,$.jsx)(`input`,{className:p(ln,`mt-1 h-8 py-1 text-xs`),defaultValue:i.alias??``,onBlur:e=>{e.currentTarget.value!==(i.alias??``)&&K(()=>nt(i.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)(D,{variant:`ghost`,className:`size-7 shrink-0 p-0 text-danger`,title:t.composioRevoke,disabled:A,onClick:()=>R(e.id),children:(0,$.jsx)(He,{className:`size-3.5`})})]},e.id))}),(0,$.jsxs)(`div`,{className:`flex justify-end gap-1`,children:[(0,$.jsx)(D,{variant:`ghost`,className:`size-8 p-0`,title:t.composioMakeDefault,disabled:A||i.isDefault||i.status!==`active`,onClick:()=>void K(async()=>{await nt(i.id,{isDefault:!0}),await Y(r,{selectedConnectionIds:[i.id]})}),children:(0,$.jsx)(Me,{className:p(`size-4`,i.isDefault&&`fill-current`)})}),(0,$.jsx)(D,{variant:`ghost`,className:`size-8 p-0`,title:t.refresh,disabled:A,onClick:()=>void K(()=>Ee(i.id)),children:(0,$.jsx)(te,{className:`size-4`})})]})]})]})]},e.key)})}):(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})})]}),(0,$.jsxs)(`details`,{className:`rounded-xl border border-edge bg-surface-base`,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:[F?(0,$.jsx)(`p`,{className:`rounded-lg bg-amber-500/10 px-3 py-2 text-xs text-amber-800 dark:text-amber-200`,children:t.composioDiagnosticsUnavailable}):null,x?(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:ie?t.composioAuthConfigRequiredHint:t.composioAuthConfigOptionalHint})]}),(0,$.jsx)(`a`,{className:`text-xs font-medium text-accent-fg hover:underline`,href:`https://app.composio.dev`,target:`_blank`,rel:`noreferrer`,children:t.composioAuthConfigManage})]}),(0,$.jsxs)(o,{className:`mt-3`,value:typeof e.config?.authConfigId==`string`?e.config.authConfigId:``,disabled:A,onChange:e=>void U(e.currentTarget.value),children:[ie?null:(0,$.jsx)(s,{value:``,children:t.composioAuthConfigManaged}),ie&&typeof e.config?.authConfigId!=`string`?(0,$.jsx)(s,{value:``,disabled:!0,children:t.composioAuthConfigSelect}):null,oe.map(e=>(0,$.jsxs)(s,{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:[dn(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:f.length?f.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)(Pe,{open:L!==null,title:t.composioRevoke,description:t.composioRevokeConfirm,confirmLabel:t.composioRevoke,cancelLabel:t.modalCancel,destructive:!0,onConfirm:()=>{let e=L;R(null),e&&K(()=>We(e))},onCancel:()=>R(null)})]})}var gn=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 _n(e,t){return e?t.healthStatusLabels[e]??e:t.healthNotTested}function vn(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 yn(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 bn(e){let t=(0,Q.c)(12),{title:n,description:r,meta:i}=e,a;t[0]===r?a=t[1]:(a=r?(0,$.jsx)(I,{delayDuration:300,skipDelayDuration:100,children:(0,$.jsxs)(P,{children:[(0,$.jsx)(N,{asChild:!0,children:(0,$.jsx)(`p`,{tabIndex:0,title:r,className:p(`mt-1 line-clamp-3 cursor-help text-xs leading-5 text-fg-muted`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`),children:r})}),(0,$.jsx)(F,{children:(0,$.jsx)(L,{side:`top`,align:`start`,sideOffset:6,collisionPadding:12,className:`!z-[10000] max-h-[min(16rem,45vh)] max-w-[min(32rem,calc(100vw-2rem))] overflow-y-auto rounded-md border border-edge bg-surface-panel px-2.5 py-2 text-left text-xs leading-5 text-fg shadow-popover`,children:(0,$.jsx)(`span`,{className:`whitespace-pre-wrap break-words`,children:r})})})]})}):null,t[0]=r,t[1]=a);let o=a,s;t[2]===n?s=t[3]:(s=(0,$.jsx)(`p`,{className:`min-w-0 break-all font-mono text-xs font-medium leading-5 text-fg`,children:n}),t[2]=n,t[3]=s);let c;t[4]===i?c=t[5]:(c=i?(0,$.jsx)(`span`,{className:`shrink-0 rounded-md bg-surface-hover px-1.5 py-0.5 text-[11px] leading-4 text-fg-subtle`,children:i}):null,t[4]=i,t[5]=c);let l;t[6]!==s||t[7]!==c?(l=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-3`,children:[s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;return t[9]!==o||t[10]!==l?(u=(0,$.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2.5`,children:[l,o]}),t[9]=o,t[10]=l,t[11]=u):u=t[11],u}function xn({instance:e,definition:t,onClose:n,onChanged:r,t:i,mcp:a}){let[o,s]=(0,Z.useState)(!1),[c,l]=(0,Z.useState)(!1),[d,m]=(0,Z.useState)(!1),[h,g]=(0,Z.useState)(!1),[_,v]=(0,Z.useState)(!1),[E,O]=(0,Z.useState)(null),[k,A]=(0,Z.useState)(null),[j,M]=(0,Z.useState)(`health`),[N,P]=(0,Z.useState)(!1),[F,I]=(0,Z.useState)(()=>vn(t,e)),[L,R]=(0,Z.useState)(null),z=t?.setup.config??[],B=(e.materialized.type===`mcp`||e.materialized.type===`memorySource`)&&z.length>0&&(t?.setup.secrets??[]).length===0,V=k?k.toolCount:e.usage.lastToolCount,H=e.materialized.type===`mcp`,U=e.materialized.type===`composio`,W=e.materialized.type===`memorySource`,G=t?re(t,i):null,K=(0,Z.useMemo)(()=>{let t=[[`health`,he,i.detailHealth],[`tools`,xe,`${i.detailTools} ${k?k.toolCount:e.usage.lastToolCount??``}`],[`resources`,Ae,`${i.detailResources} ${k?k.resourceCount:e.usage.lastResourceCount??``}`],[`prompts`,Je,`${i.detailPrompts} ${k?k.promptCount:e.usage.lastPromptCount??``}`],[`permissions`,ue,i.detailPermissions]];return B?[...t,[`config`,Ae,i.connectorConfigLabel]]:t},[k,e.usage.lastPromptCount,e.usage.lastResourceCount,e.usage.lastToolCount,B,i]),te=(0,Z.useCallback)(async()=>{s(!0),R(null);try{let t=await $e(e.instanceId);A(t),t.toolCount>0&&M(`tools`),r()}catch(e){R(e instanceof Error?e.message:String(e))}finally{s(!1)}},[e.instanceId,r]),q=(0,Z.useCallback)(async()=>{l(!0),R(null);try{await ke(e.instanceId),await r(),n()}catch(e){R(e instanceof Error?e.message:String(e)),l(!1)}},[e.instanceId,r,n]),ie=(0,Z.useCallback)(async()=>{if(!(!t||!B)){g(!0),R(null);try{let n={};for(let e of t.setup.config??[]){let t=yn(e.type,F[e.key]??``);t!==void 0&&(n[e.key]=t)}await et(e.instanceId,{config:n}),await r(),M(`health`)}catch(e){R(e instanceof Error?e.message:String(e))}finally{g(!1)}}},[F,t,e.instanceId,r,B]),ae=(0,Z.useCallback)(async()=>{v(!0),O(null),R(null);try{O((await Ce(e.connectorId)).recordIds.length),await r()}catch(e){R(e instanceof Error?e.message:String(e))}finally{v(!1)}},[e.connectorId,r]);return(0,$.jsxs)(T,{open:!0,onOpenChange:e=>{e||n()},children:[(0,$.jsxs)(S,{children:[(0,$.jsx)(y,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(C,{className:p(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(100vh-2rem,44rem)] w-[min(100%-2rem,min(92vw,54rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-panel shadow-float outline-none dark:border-edge`),children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,$.jsx)(ne,{connector:t,size:`lg`}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(w,{className:`text-base font-semibold text-fg`,children:e.displayName}),(0,$.jsx)(b,{className:`mt-1 text-sm text-fg-muted`,children:G??(e.materialized.type===`mcp`?X(i.mcpServerRuntime,{serverId:e.materialized.serverId}):X(i.runtimeLabel,{runtime:e.materialized.type}))})]})]}),(0,$.jsx)(x,{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`,J.focusRingPanel),"aria-label":i.modalClose,children:[(0,$.jsx)(f,{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:[L?(0,$.jsx)(`p`,{className:`mb-4 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:L}):null,H?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:K.map(([e,t,n])=>(0,$.jsxs)(`button`,{type:`button`,className:p(`inline-flex h-8 items-center gap-1.5 rounded-md border px-2.5 text-xs`,j===e?`border-accent bg-accent-soft text-accent-fg`:`border-edge bg-surface-base text-fg-muted hover:text-fg`),onClick:()=>M(e),children:[(0,$.jsx)(t,{className:`size-3.5`,"aria-hidden":!0}),n]},e))}),(0,$.jsxs)(`div`,{className:`mt-4 rounded-xl border border-edge bg-surface-base p-3 text-sm`,children:[j===`health`?(0,$.jsxs)(`div`,{className:`space-y-1 text-fg-muted`,children:[(0,$.jsxs)(`p`,{children:[i.statusLabel,` `,(0,$.jsx)(`span`,{className:k?.ok?`font-medium text-emerald-700 dark:text-emerald-300`:`font-medium text-fg`,children:_n(k?.status??e.usage.lastHealthStatus,i)})]}),(0,$.jsxs)(`p`,{children:[i.lastCheckLabel,` `,e.usage.lastHealthCheckAt?new Date(e.usage.lastHealthCheckAt).toLocaleString():i.never]}),k?.action?(0,$.jsx)(`p`,{children:k.action}):null]}):null,j===`tools`?k?.tools.length?(0,$.jsxs)(`div`,{className:`grid gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:X(i.toolsAvailable,{count:String(k.tools.length)})}),(0,$.jsx)(D,{type:`button`,variant:`ghost`,className:`h-7 text-xs`,onClick:()=>P(!0),children:a.viewAllTools})]}),(0,$.jsx)(`div`,{className:`grid gap-2`,children:k.tools.slice(0,8).map(e=>(0,$.jsx)(bn,{title:e.shortName??e.name,description:e.description},e.name))})]}):(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsx)(`p`,{className:`text-fg-muted`,children:V?X(i.toolsLastCheckSummary,{count:String(V)}):i.toolsRunTestHint}),(0,$.jsxs)(D,{type:`button`,variant:`secondary`,disabled:o,onClick:()=>void te(),children:[o?(0,$.jsx)(u,{className:`size-4 animate-spin`}):(0,$.jsx)(ee,{className:`size-4`}),i.test]})]}):null,j===`resources`?k?.resources.length?(0,$.jsx)(`div`,{className:`grid gap-2`,children:k.resources.slice(0,8).map(e=>(0,$.jsx)(bn,{title:e.title??e.name,description:e.uri,meta:e.mimeType},e.uri))}):(0,$.jsx)(`p`,{className:`text-fg-muted`,children:i.resourcesRunTestHint}):null,j===`prompts`?k?.prompts.length?(0,$.jsx)(`div`,{className:`grid gap-2`,children:k.prompts.slice(0,8).map(e=>(0,$.jsx)(bn,{title:e.title??e.name,description:e.description,meta:e.argumentCount?X(i.promptArgumentCount,{count:String(e.argumentCount)}):void 0},e.name))}):(0,$.jsx)(`p`,{className:`text-fg-muted`,children:i.promptsRunTestHint}):null,j===`permissions`?(0,$.jsxs)(`div`,{className:`space-y-1 text-fg-muted`,children:[(0,$.jsx)(`p`,{children:X(i.secretsConfigured,{count:String(Object.values(e.secretStatus).filter(Boolean).length)})}),(0,$.jsx)(`p`,{children:e.materialized.type===`mcp`?X(i.runtimeServerLabel,{runtime:e.materialized.type.toUpperCase(),serverId:e.materialized.serverId}):X(i.runtimeLabel,{runtime:e.materialized.type.toUpperCase()})}),(0,$.jsx)(`p`,{children:e.materialized.type===`mcp`?i.mcpPolicyHint:i.connectorPolicyHint})]}):null,j===`config`&&B?(0,$.jsx)(`div`,{className:`grid gap-3`,children:z.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:gn,value:F[e.key]??``,placeholder:e.placeholder,onChange:t=>I(n=>({...n,[e.key]:t.currentTarget.value}))})]},e.key))}):null]})]}):null,U?(0,$.jsx)(hn,{instance:e,t:i,onChanged:r}):null,W?(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}),G?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:G}):null,E===null?null:(0,$.jsx)(`p`,{className:`mt-1 text-xs text-emerald-600`,children:X(i.connectedSourceSynced,{count:String(E)})})]}),(0,$.jsxs)(D,{disabled:_,onClick:()=>void ae(),children:[_?(0,$.jsx)(u,{className:`size-4 animate-spin`}):(0,$.jsx)(Ae,{className:`size-4`}),i.composioSyncNow]})]}),B?(0,$.jsx)(`div`,{className:`grid gap-3 rounded-xl border border-edge bg-surface-base p-4`,children:z.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:gn,value:F[e.key]??``,placeholder:e.placeholder,onChange:t=>I(n=>({...n,[e.key]:t.currentTarget.value}))})]},e.key))}):null]}):null,!H&&!U&&!W?(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-danger/20 bg-danger/5`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer px-4 py-3 text-sm font-medium 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)(D,{variant:`secondary`,className:`shrink-0 border-danger/30 text-danger hover:bg-danger/10`,disabled:c,onClick:()=>m(!0),children:[c?(0,$.jsx)(u,{className:`size-4 animate-spin`}):(0,$.jsx)(He,{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)(D,{variant:`secondary`,onClick:n,children:i.modalClose}),(H&&j===`config`||W)&&B?(0,$.jsxs)(D,{variant:`primary`,disabled:h,onClick:()=>void ie(),children:[h?(0,$.jsx)(u,{className:`size-4 animate-spin`}):(0,$.jsx)(oe,{className:`size-4`}),i.modalSave]}):null,H?(0,$.jsxs)(D,{variant:`secondary`,disabled:o,onClick:()=>void te(),children:[o?(0,$.jsx)(u,{className:`size-4 animate-spin`}):(0,$.jsx)(ee,{className:`size-4`}),i.test]}):null]})]})]}),e.materialized.type===`mcp`?(0,$.jsx)(an,{open:N,onOpenChange:P,serverId:e.materialized.serverId,title:X(i.installedToolsDialogTitle,{name:e.displayName}),subtitle:i.installedToolsDialogSubtitle,searchPlaceholder:a.toolsDialogSearchPlaceholder,searchEmptyLabel:a.toolsDialogSearchEmpty,emptyLabel:i.toolsRunTestHint,closeLabel:a.toolsDialogClose,tools:k?.tools??[],stripPrefix:`${e.materialized.serverId}__`}):null,(0,$.jsx)(Pe,{open:d,title:X(i.removeConfirmTitle,{name:e.displayName}),description:i.removeConfirmDescription,confirmLabel:i.removeConfirmAction,cancelLabel:i.modalCancel,destructive:!0,onConfirm:()=>{m(!1),q()},onCancel:()=>{c||m(!1)}})]})}function Sn(e){let t=(0,Q.c)(55),{instance:n,definition:r,highlighted:i,onOpenDetails:a,t:o}=e,s=i===void 0?!1:i,c;t[0]!==r||t[1]!==n?(c=ht(n,r),t[0]=r,t[1]=n,t[2]=c):c=t[2];let u=c.state,d;t[3]!==r||t[4]!==o?(d=r?re(r,o):null,t[3]=r,t[4]=o,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]!==s||t[9]!==n||t[10]!==a||t[11]!==o.connectionChecking||t[12]!==o.connectionNeedsSetup||t[13]!==o.connectionReady){m=u===`ready`?{label:o.connectionReady,Icon:l,className:`text-emerald-700 dark:text-emerald-300`}:u===`needs_setup`?{label:o.connectionNeedsSetup,Icon:ae,className:`text-amber-700 dark:text-amber-300`}:{label:o.connectionChecking,Icon:tt,className:`text-fg-muted`},x=`button`;let e=s&&`bg-accent-soft ring-2 ring-inset ring-accent/40`;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`,J.transition,J.focusRingPanel,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)(ne,{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]=s,t[9]=n,t[10]=a,t[11]=o.connectionChecking,t[12]=o.connectionNeedsSetup,t[13]=o.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)(se,{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 Cn(e,t){let n=e.length+1,r=`server-${n}`,i=new Set([...e.map(e=>e.id.trim()),...t]);for(;i.has(r);)n+=1,r=`server-${n}`;return It(r)}function wn(e,t,n){let r=e.key.trim();if(r)return`key:${r}`;let i=e.value.trim();return i?`value:${i}`:`empty:${n.slice(0,t).filter(e=>!e.key.trim()&&!e.value.trim()).length}`}function Tn(){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 En({label:e,optionalLabel:t,addLabel:n,removeHeaderAria:r,pasteLabel:i,pasteFailed:a,keyPlaceholder:o,valuePlaceholder:s,headers:c,onChange:l}){let u=(e,t)=>{l(c.map((n,r)=>r===e?{...n,...t}:n))},d=()=>{l([...c,{key:``,value:``}])},f=e=>{let t=c.filter((t,n)=>n!==e);l(t.length>0?t:[{key:``,value:``}])},m=async()=>{try{let e=await E();if(!e){window.alert(a);return}let t=Dt(e);if(!t?.length){window.alert(a);return}l(t)}catch{window.alert(a)}};return(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 md:col-span-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium text-fg`,children:[(0,$.jsx)(`span`,{children:e}),t?(0,$.jsx)(`span`,{className:`font-normal text-fg-subtle`,children:t}):null]}),(0,$.jsxs)(D,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5 px-2 text-xs`,onClick:()=>void m(),children:[(0,$.jsx)(H,{className:`size-3.5`,"aria-hidden":!0}),i]})]}),(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:c.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{className:p(Tn(),`min-w-0 flex-1 font-mono text-xs`),value:e.key,placeholder:o,onChange:e=>u(t,{key:e.target.value})}),(0,$.jsx)(`input`,{className:p(Tn(),`min-w-0 flex-[1.4] font-mono text-xs`),value:e.value,placeholder:s,onChange:e=>u(t,{value:e.target.value})}),(0,$.jsx)(D,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 px-0`,disabled:c.length<=1&&!e.key&&!e.value,onClick:()=>f(t),"aria-label":r,children:(0,$.jsx)(He,{className:`size-4 text-fg-subtle`,"aria-hidden":!0})})]},wn(e,t,c)))}),(0,$.jsxs)(`button`,{type:`button`,className:p(`self-start text-sm text-accent hover:underline`,J.press),onClick:d,children:[`+ `,n]})]})}var Dn=[`stdio`,`sse`,`streamable-http`],On=[`none`,`oauth`];function kn(e){let t=(0,Q.c)(11),{label:n,description:r,required:i,children:a}=e,o;t[0]===i?o=t[1]:(o=i?(0,$.jsx)(`span`,{className:`ml-0.5 text-danger`,children:`*`}):null,t[0]=i,t[1]=o);let s;t[2]!==n||t[3]!==o?(s=(0,$.jsxs)(`div`,{className:`text-sm font-medium text-fg`,children:[n,o]}),t[2]=n,t[3]=o,t[4]=s):s=t[4];let c;t[5]===r?c=t[6]:(c=r?(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:r}):null,t[5]=r,t[6]=c);let l;return t[7]!==a||t[8]!==s||t[9]!==c?(l=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[s,a,c]}),t[7]=a,t[8]=s,t[9]=c,t[10]=l):l=t[10],l}function An(){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 jn(e){let t=(0,Q.c)(37),{row:n,t:r,onUpdate:i,idConflictMessage:a,variant:c}=e,l=c===void 0?`all`:c,u=l===`all`||l===`basic`,d=l===`all`||l===`advanced`,f;t[0]!==a||t[1]!==i||t[2]!==n.id||t[3]!==n.transport||t[4]!==u||t[5]!==r?(f=u?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(kn,{label:r.transportLabel,required:!0,children:(0,$.jsx)(o,{className:An(),value:n.transport,onChange:e=>i({transport:e.target.value}),children:Dn.map(e=>(0,$.jsx)(s,{value:e,children:r.transportLabels[e]},e))})}),(0,$.jsxs)(kn,{label:r.serverIdLabel,required:!0,children:[(0,$.jsx)(`input`,{className:An(),value:n.id,placeholder:r.serverIdPlaceholder,onChange:e=>i({id:e.target.value})}),a?(0,$.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-300`,children:a}):null]})]}):null,t[0]=a,t[1]=i,t[2]=n.id,t[3]=n.transport,t[4]=u,t[5]=r,t[6]=f):f=t[6];let m;t[7]!==i||t[8]!==n.argsText||t[9]!==n.auth||t[10]!==n.command||t[11]!==n.cwd||t[12]!==n.envJson||t[13]!==n.headers||t[14]!==n.oauthClientId||t[15]!==n.transport||t[16]!==n.url||t[17]!==d||t[18]!==u||t[19]!==r||t[20]!==l?(m=n.transport===`stdio`?(0,$.jsxs)($.Fragment,{children:[u?(0,$.jsx)(`div`,{className:l===`basic`?`md:col-span-2`:void 0,children:(0,$.jsx)(kn,{label:r.commandLabel,required:!0,children:(0,$.jsx)(`input`,{className:An(),value:n.command,onChange:e=>i({command:e.target.value})})})}):null,d?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(kn,{label:r.argsLabel,description:r.argsHint,children:(0,$.jsx)(`input`,{className:An(),value:n.argsText,onChange:e=>i({argsText:e.target.value})})}),(0,$.jsx)(kn,{label:r.cwdLabel,children:(0,$.jsx)(`input`,{className:An(),value:n.cwd,onChange:e=>i({cwd:e.target.value})})}),(0,$.jsx)(kn,{label:r.envLabel,description:r.envHint,children:(0,$.jsx)(`textarea`,{className:p(An(),`min-h-[4rem] font-mono text-xs`),value:n.envJson,onChange:e=>i({envJson:e.target.value})})})]}):null]}):(0,$.jsxs)($.Fragment,{children:[u?(0,$.jsx)(`div`,{className:`md:col-span-2`,children:(0,$.jsx)(kn,{label:r.urlLabel,required:!0,children:(0,$.jsx)(`input`,{className:p(An(),`font-mono text-xs`),value:n.url,placeholder:`https://example.com/mcp`,onChange:e=>i({url:e.target.value})})})}):null,u&&n.transport===`streamable-http`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(kn,{label:r.authLabel,description:r.authHint,children:(0,$.jsx)(o,{className:An(),value:n.auth,onChange:e=>{let t=e.target.value;i({auth:t,headers:t===`oauth`?n.headers.filter(Nn):n.headers})},children:On.map(e=>(0,$.jsx)(s,{value:e,children:r.authLabels[e]},e))})}),n.auth===`oauth`?(0,$.jsx)(kn,{label:r.oauthClientIdLabel,description:r.oauthClientIdHint,children:(0,$.jsx)(`input`,{className:p(An(),`font-mono text-xs`),value:n.oauthClientId,placeholder:r.oauthClientIdPlaceholder,onChange:e=>i({oauthClientId:e.target.value})})}):null]}):null,d?(0,$.jsx)(En,{label:r.headersLabel,optionalLabel:r.optionalSuffix,addLabel:r.addHeader,removeHeaderAria:r.removeHeader,pasteLabel:r.pasteHeaders,pasteFailed:r.pasteHeadersFailed,keyPlaceholder:r.headerKeyPlaceholder,valuePlaceholder:r.headerValuePlaceholder,headers:n.headers,onChange:e=>i({headers:n.auth===`oauth`?e.filter(Mn):e})}):null]}),t[7]=i,t[8]=n.argsText,t[9]=n.auth,t[10]=n.command,t[11]=n.cwd,t[12]=n.envJson,t[13]=n.headers,t[14]=n.oauthClientId,t[15]=n.transport,t[16]=n.url,t[17]=d,t[18]=u,t[19]=r,t[20]=l,t[21]=m):m=t[21];let h;t[22]!==i||t[23]!==n||t[24]!==d||t[25]!==r?(h=d?(0,$.jsx)(kn,{label:r.timeoutLabel,description:r.timeoutHint,children:(0,$.jsx)(`input`,{type:`number`,min:1,max:600,className:An(),value:Jt(n),placeholder:r.timeoutPlaceholder,onChange:e=>i({connectionTimeoutMs:Yt(e.target.value)})})}):null,t[22]=i,t[23]=n,t[24]=d,t[25]=r,t[26]=h):h=t[26];let g;t[27]!==i||t[28]!==n||t[29]!==d||t[30]!==r?(g=d?(0,$.jsx)(kn,{label:r.requestTimeoutLabel,description:r.requestTimeoutHint,children:(0,$.jsx)(`input`,{type:`number`,min:1,max:14400,className:An(),value:Xt(n),placeholder:r.requestTimeoutPlaceholder,onChange:e=>i({requestTimeoutMs:Zt(e.target.value)})})}):null,t[27]=i,t[28]=n,t[29]=d,t[30]=r,t[31]=g):g=t[31];let _;return t[32]!==f||t[33]!==m||t[34]!==h||t[35]!==g?(_=(0,$.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[f,m,h,g]}),t[32]=f,t[33]=m,t[34]=h,t[35]=g,t[36]=_):_=t[36],_}function Mn(e){return e.key.trim().toLowerCase()!==`authorization`}function Nn(e){return e.key.trim().toLowerCase()!==`authorization`}function Pn(e,t){if(e.shortName)return e.shortName;let n=`${t.trim()}__`;return n&&e.name.startsWith(n)?e.name.slice(n.length):e.name}function Fn(e){let t=(0,Q.c)(13),{tool:n,serverId:r}=e,i;t[0]!==r||t[1]!==n?(i=Pn(n,r),t[0]=r,t[1]=n,t[2]=i):i=t[2];let a=i,o=n.name===a?a:n.name,s;t[3]===n.description?s=t[4]:(s=n.description?.trim(),t[3]=n.description,t[4]=s);let c=s,l;t[5]!==a||t[6]!==o?(l=(0,$.jsx)(`p`,{className:`break-all font-mono text-xs font-medium leading-5 text-fg`,title:o,children:a}),t[5]=a,t[6]=o,t[7]=l):l=t[7];let u;t[8]===c?u=t[9]:(u=c?(0,$.jsx)(I,{delayDuration:300,skipDelayDuration:100,children:(0,$.jsxs)(P,{children:[(0,$.jsx)(N,{asChild:!0,children:(0,$.jsx)(`p`,{tabIndex:0,title:c,className:p(`mt-1 line-clamp-3 cursor-help text-xs leading-5 text-fg-muted`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent/40`),children:c})}),(0,$.jsx)(F,{children:(0,$.jsx)(L,{side:`top`,align:`start`,sideOffset:6,collisionPadding:12,className:`!z-[10000] max-h-[min(16rem,45vh)] max-w-[min(32rem,calc(100vw-2rem))] overflow-y-auto rounded-md border border-edge bg-surface-panel px-2.5 py-2 text-left text-xs leading-5 text-fg shadow-popover`,children:(0,$.jsx)(`span`,{className:`whitespace-pre-wrap break-words`,children:c})})})]})}):null,t[8]=c,t[9]=u);let d;return t[10]!==l||t[11]!==u?(d=(0,$.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-edge bg-surface-panel px-3 py-2.5`,children:[l,u]}),t[10]=l,t[11]=u,t[12]=d):d=t[12],d}function In({open:e,mode:t,initialRow:n,existingCustomServers:r,sessionIdleTtlMinutes:i,config:a,managedServerIds:o,t:s,cs:c,onClose:d,onSaved:m}){let[h,g]=(0,Z.useState)(n),[_,v]=(0,Z.useState)(!1),[E,O]=(0,Z.useState)(!1),[k,A]=(0,Z.useState)(null),[j,M]=(0,Z.useState)(!1),[N,P]=(0,Z.useState)({status:`idle`}),[F,I]=(0,Z.useState)(null),L=n.id.trim(),R=h.id.trim()!==L&&o.has(h.id.trim())||o.has(h.id.trim())&&t===`add`?s.reservedServerId:void 0,z=h.id.trim()&&r.some(e=>e.clientKey!==n.clientKey&&e.id.trim()===h.id.trim())?c.duplicateServerId:void 0,B=h.id.trim().length>0&&!R&&!z&&(h.transport===`stdio`?h.command.trim().length>0:h.url.trim().length>0),V=!(h.transport===`streamable-http`&&h.auth===`oauth`),H=Qt(h),U=(0,Z.useCallback)(async()=>{if(h.id.trim()){O(!0),A(null),P({status:`loading`});try{P({status:`ok`,tools:(await qt(h.id.trim(),Rt(h))).tools})}catch(e){P({status:`error`,message:e instanceof Error?e.message:String(e)})}finally{O(!1)}}},[h]),G=(0,Z.useCallback)(async()=>{if(!(!B||_)){v(!0),A(null);try{let e=r.filter(e=>!(t===`edit`&&e.clientKey===n.clientKey));e.push(h),await zt({sessionIdleTtlMinutes:i,servers:e.sort((e,t)=>e.id.localeCompare(t.id))},jt(a)),await m(),d()}catch(e){A(e instanceof Error?e.message:String(e))}finally{v(!1)}}},[B,a,r,n.clientKey,t,d,m,L,h,_,i]);return e?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(T,{open:e,onOpenChange:e=>{e||d()},children:(0,$.jsxs)(S,{children:[(0,$.jsx)(y,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(C,{className:p(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(100vh-2rem,44rem)] w-[min(100%-2rem,min(92vw,48rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-panel shadow-float dark:border-edge`),children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(w,{className:`text-base font-semibold text-fg`,children:t===`add`?c.addCustomServerTitle:c.editCustomServerTitle}),(0,$.jsx)(b,{className:`mt-1 text-sm text-fg-muted`,children:t===`add`?c.addCustomServerHint:c.editCustomServerHint})]}),(0,$.jsx)(x,{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`,J.focusRingPanel),"aria-label":c.modalClose,children:[(0,$.jsx)(f,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`sr-only`,children:c.modalClose})]})})]}),(0,$.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsx)(`section`,{className:`rounded-xl border border-edge bg-surface-base p-4`,children:(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,$.jsx)(Le,{className:`size-4 text-accent`,"aria-hidden":!0}),h.id.trim()||s.cardUntitled]}),(0,$.jsx)(`p`,{className:`mt-1 break-all font-mono text-xs leading-5 text-fg-muted`,children:H||(h.transport===`stdio`?s.commandLabel:s.urlLabel)})]}),(0,$.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:s.transportLabels[h.transport]})]})}),(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`mb-3`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:c.connectorBasicConfigTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:c.connectorBasicConfigHint})]}),(0,$.jsx)(jn,{row:h,t:s,variant:`basic`,onUpdate:e=>{g(t=>({...t,...e})),A(null)},idConflictMessage:R??z})]}),N.status===`ok`?(0,$.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-base p-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,$.jsx)(xe,{className:`size-4 text-accent`,"aria-hidden":!0}),N.tools.length===0?s.toolsEmpty:s.toolsTitle.replace(`{{count}}`,String(N.tools.length))]}),N.tools.length>0?(0,$.jsx)(D,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,onClick:()=>I(N.tools),children:s.viewAllTools}):null]}),N.tools.length>0?(0,$.jsx)(`div`,{className:`mt-3 grid gap-2`,children:N.tools.slice(0,6).map((e,t)=>(0,$.jsx)(Fn,{tool:e,serverId:h.id},e.name||`tool-${t}`))}):null]}):null,N.status===`error`?(0,$.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:N.message}):null,k?(0,$.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:k}):null,(0,$.jsxs)(`details`,{open:j,onToggle:e=>M(e.currentTarget.open),className:`group rounded-xl border border-edge bg-surface-base`,children:[(0,$.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg hover:text-fg [&::-webkit-details-marker]:hidden`,children:[(0,$.jsx)(W,{className:`size-4 text-fg-muted transition-transform group-open:rotate-180`,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`group-open:hidden`,children:c.connectorShowAdvancedConfig}),(0,$.jsx)(`span`,{className:`hidden group-open:inline`,children:c.connectorHideAdvancedConfig})]}),(0,$.jsx)(`div`,{className:`border-t border-edge p-4`,children:(0,$.jsx)(jn,{row:h,t:s,variant:`advanced`,onUpdate:e=>{g(t=>({...t,...e})),A(null)}})})]})]})}),(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[(0,$.jsxs)(D,{variant:`secondary`,disabled:!h.id.trim()||E||!V,title:V?void 0:s.oauthSaveBeforeTest,onClick:()=>void U(),children:[E?(0,$.jsx)(u,{className:`size-4 animate-spin`}):(0,$.jsx)(ee,{className:`size-4`}),s.testConnection]}),(0,$.jsx)(x,{asChild:!0,children:(0,$.jsx)(D,{variant:`secondary`,children:c.modalCancel})}),(0,$.jsxs)(D,{variant:`primary`,disabled:!B||_,onClick:()=>void G(),children:[_?(0,$.jsx)(u,{className:`size-4 animate-spin`}):(0,$.jsx)(l,{className:`size-4`}),_?s.saving:c.modalSave]})]})]})]})}),F?(0,$.jsx)(an,{open:!0,onOpenChange:e=>{e||I(null)},serverId:h.id,title:s.toolsDialogTitle,subtitle:s.toolsDialogSubtitle,searchPlaceholder:s.toolsDialogSearchPlaceholder,searchEmptyLabel:s.toolsDialogSearchEmpty,emptyLabel:s.toolsEmpty,closeLabel:s.toolsDialogClose,tools:F,stripPrefix:`${h.id.trim()}__`}):null]}):null}var Ln=`builtin`,Rn=`composio`,zn=`xopc-store`;function Bn(e){return Ln}function Vn(e){return!(e.runtime.type===`composio`&&e.runtime.role===`credential`)}function Hn(e,t){let n=t.trim().toLowerCase();return n?[e.displayName,e.description,e.category,e.kind,e.source,...e.tags??[]].some(e=>e.toLowerCase().includes(n)):!0}function Un(e,t,n){return e.filter(e=>Hn(e,t)).toSorted((e,t)=>n===`source`&&e.source!==t.source?e.source.localeCompare(t.source):e.displayName.localeCompare(t.displayName))}function Wn(e,t){let n=t.trim().toLowerCase();return n?[e.displayName,e.connectorId,e.instanceId,e.status,e.connectionStatus??``,e.materialized.type,e.materialized.type===`mcp`?e.materialized.serverId:e.materialized.id].some(e=>e.toLowerCase().includes(n)):!0}function Gn(e,t){let n=t.trim().toLowerCase();return n?[e.id,e.command??``,e.url??``,e.transport].some(e=>e.toLowerCase().includes(n)):!0}function 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`,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(){let e=v(g(e=>e.language)),t=e.connectorsSettings,n=e.mcpSettings,r=h(e=>e.conversationId),o=!!r,s=i(),[l,d]=a(),f=l.get(`understanding`)===`1`,m=Jn(l.get(`returnTo`)),_=l.get(`tab`),[y,b]=(0,Z.useState)(!f&&_===`connected`?`connected`:`discover`),x=(0,Z.useRef)(!1),[S,C]=(0,Z.useState)({catalog:[],registryCatalog:[],instances:[],loading:!0,error:null}),[w,T]=(0,Z.useState)(!1),[E,O]=(0,Z.useState)(!1),[A,j]=(0,Z.useState)(1),[M,N]=(0,Z.useState)(void 0),[P,F]=(0,Z.useState)(``),[I,L]=(0,Z.useState)(f?l.get(`connector`)??``:``),[z,B]=(0,Z.useState)(Bn(f?`understanding`:`default`)),[V,H]=(0,Z.useState)(`name`),[U,W]=(0,Z.useState)(f?`understand`:`all`),[ee,K]=(0,Z.useState)(null),[te,ne]=(0,Z.useState)(null),[re,q]=(0,Z.useState)(null),[ie,ae]=(0,Z.useState)(null),[oe,se]=(0,Z.useState)(null),[le,ue]=(0,Z.useState)(null),[me,he]=(0,Z.useState)(!1),[ge,J]=(0,Z.useState)(void 0),[_e,ve]=(0,Z.useState)(!1),{data:xe,mutate:Ce}=k(o),we=xe?.payload?.config,Y=(0,Z.useMemo)(()=>we===void 0?null:Lt(we),[we]),Te=Y?.servers??[],Ee=S.instances.length+Te.length;(0,Z.useEffect)(()=>{Y&&J(Y.sessionIdleTtlMinutes)},[Y]);let Oe=(0,Z.useCallback)(async()=>{if(!r){C({catalog:[],registryCatalog:[],instances:[],loading:!1,error:null});return}C(e=>({...e,loading:!0,error:null}));try{let[e,t]=await Promise.all([Se(),de()]);C(n=>({catalog:e,registryCatalog:n.registryCatalog,instances:t,loading:!1,error:null}))}catch(e){C({catalog:[],registryCatalog:[],instances:[],loading:!1,error:e instanceof Error?e.message:String(e)})}},[r]);(0,Z.useEffect)(()=>{Oe()},[Oe]),(0,Z.useEffect)(()=>{x.current||S.loading||o&&!Y||(b(f?`discover`:Ee>0?`connected`:`discover`),x.current=!0)},[o,Ee,Y,f,S.loading]);let ke=(0,Z.useCallback)(e=>{x.current=!0,b(e)},[]),Ae=(0,Z.useMemo)(()=>[{id:Rn,displayName:t.composioSourceName},{id:zn,displayName:t.storeSourceName}],[t.composioSourceName,t.storeSourceName]),je=(0,Z.useCallback)(async e=>{if(!o||z===`builtin`){C(e=>({...e,registryCatalog:[]})),j(1),N(void 0);return}let t=I.trim(),n=Math.max(e?.page??1,1),r=e?.append??!1,i=z===`all`?Ae:Ae.filter(e=>e.id===z);if(i.length!==0){T(!0),r?C(e=>({...e,error:null})):(j(1),N(void 0),C(e=>({...e,registryCatalog:[],error:null})));try{let e=await Promise.all(i.map(async e=>{if(e.id===`composio`){let e=await be({q:t||void 0,page:n,pageSize:24,verification:`experimental`});return{connectors:e.connectors,totalPages:e.meta.totalPages}}let r=await R({q:t||void 0,page:n,pageSize:24,sort:V===`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));j(n),N(o),C(e=>({...e,registryCatalog:r?qn([...e.registryCatalog,...a]):a}))}catch(e){C(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{T(!1)}}},[V,I,z,o,Ae]);(0,Z.useEffect)(()=>{if(y!==`discover`||S.loading)return;if(z===`builtin`){C(e=>({...e,registryCatalog:[]})),j(1),N(void 0);return}let e=window.setTimeout(()=>{je()},I.trim()?350:0);return()=>window.clearTimeout(e)},[I,z,je,S.loading,y]);let Me=(0,Z.useMemo)(()=>new Set(S.instances.map(e=>e.connectorId)),[S.instances]),Ne=(0,Z.useMemo)(()=>new Map([...S.catalog,...S.registryCatalog].map(e=>[e.id,e])),[S.catalog,S.registryCatalog]);(0,Z.useEffect)(()=>{if(S.loading)return;let e=l.get(`connector`),t=l.get(`instance`);if(!e&&!t)return;let n=S.instances.find(n=>t?n.instanceId===t:n.connectorId===e);if(n)x.current=!0,F(``),q(n.instanceId),ae(n),b(`connected`);else if(e){let t=Ne.get(e);if(!t)return;x.current=!0,B(Bn(f?`understanding`:`default`)),L(``),ne(t),b(`discover`)}let r=new URLSearchParams(l);r.delete(`connector`),r.delete(`instance`),r.set(`tab`,n?`connected`:`discover`),d(r,{replace:!0})},[Ne,f,l,d,S.instances,S.loading]);let Pe=(0,Z.useCallback)(async e=>{O(!0),C(e=>({...e,error:null}));try{let t=await De(e);K(ye(t.definition,{packageName:t.packageName,version:t.version,permissions:t.permissions}))}catch(e){C(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{O(!1)}},[]),Fe=(0,Z.useMemo)(()=>new Set(S.instances.flatMap(e=>e.materialized.type===`mcp`?[e.materialized.serverId]:[])),[S.instances]),Ie=(0,Z.useCallback)(async e=>{if(!Y||we===void 0)return;let t=Te.filter(t=>t.clientKey!==e.clientKey);await zt({sessionIdleTtlMinutes:Y.sessionIdleTtlMinutes,servers:t},jt(we)),await Ce(),await Oe()},[we,Te,Oe,Y,Ce]),Le=(0,Z.useCallback)(()=>{ue({mode:`add`,row:Cn(Te,Fe)})},[Te,Fe]),Re=(0,Z.useCallback)(async()=>{if(!(!Y||we===void 0||_e)){ve(!0);try{await zt({sessionIdleTtlMinutes:ge,servers:Te},jt(we)),await Ce(),he(!1)}finally{ve(!1)}}},[we,Te,n.saved,Y,Ce,ge,_e]),ze=pe(e=>e.setPageHeader),Be=pe(e=>e.clearPageHeader),Ve=(0,Z.useMemo)(()=>(0,$.jsx)(Tt,{onBrowseCatalog:()=>ke(`discover`),onAddCustomServer:Le,addLabel:t.addConnection,browseLabel:t.addFromCatalog,customLabel:t.addCustomServerAdvanced}),[t,Le,ke]);(0,Z.useLayoutEffect)(()=>(ze({startExtra:null,main:(0,$.jsx)(`div`,{className:`min-w-0`,children:(0,$.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.title})}),end:Ve}),()=>Be()),[Be,t.title,Ve,ze]);let He=(0,Z.useMemo)(()=>S.instances.map(e=>({instance:e,value:ht(e,Ne.get(e.connectorId))})),[Ne,S.instances]),Ue=(0,Z.useMemo)(()=>new Map(He.map(({instance:e,value:t})=>[e.instanceId,t])),[He]),We=(0,Z.useMemo)(()=>S.instances.filter(e=>Wn(e,P)).sort((e,t)=>{let n={needs_setup:0,checking:1,ready:2},r=Ue.get(e.instanceId)?.state??`checking`,i=Ue.get(t.instanceId)?.state??`checking`;return n[r]-n[i]||e.displayName.localeCompare(t.displayName)}),[P,Ue,S.instances]),X=(0,Z.useMemo)(()=>We.filter(e=>Ue.get(e.instanceId)?.state===`needs_setup`),[Ue,We]),Ke=(0,Z.useMemo)(()=>We.filter(e=>Ue.get(e.instanceId)?.state!==`needs_setup`),[Ue,We]),qe=(0,Z.useMemo)(()=>Te.filter(e=>Gn(e,P)),[P,Te]),Je=We.length+qe.length,Ye=(0,Z.useMemo)(()=>S.catalog.filter(e=>e.source===`builtin`&&e.integrationStrategy?.preferred!==!1&&Vn(e)),[S.catalog]),Xe=(0,Z.useMemo)(()=>z===`builtin`?Ye:z===`all`?qn([...Ye,...S.registryCatalog]):S.registryCatalog,[Ye,z,S.registryCatalog]),Ze=(0,Z.useMemo)(()=>{let e=f?Xe.filter(e=>e.understanding?.mode===`activity`):Xe;return Un(U===`all`?e:e.filter(e=>pt(e).includes(U)),I,V)},[V,I,Xe,f,U]),Qe=(0,Z.useMemo)(()=>ft.filter(e=>Xe.some(t=>pt(t).includes(e))),[Xe]);(0,Z.useEffect)(()=>{U!==`all`&&!Qe.includes(U)&&W(`all`)},[Qe,U]);let $e=y===`discover`&&z!==`builtin`&&!!(M&&A<M),et=(0,Z.useMemo)(()=>S.instances.find(e=>e.instanceId===re)??ie,[re,ie,S.instances]),tt=(0,Z.useMemo)(()=>[{value:`all`,label:t.discoverSourceAll},{value:Ln,label:t.discoverSourceBuiltin},...Ae.map(e=>({value:e.id,label:e.displayName}))],[t.discoverSourceAll,t.discoverSourceBuiltin,Ae]),nt=[{id:`connected`,label:t.tabConnected,count:Ee},{id:`discover`,label:t.tabDiscover}];return(0,$.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:(0,$.jsxs)(`div`,{className:`mx-auto flex w-full max-w-7xl flex-col gap-6 px-4 py-7 sm:px-6 lg:px-8 lg:py-9`,children:[o?null:(0,$.jsx)(`p`,{className:`rounded-xl border border-edge bg-surface-panel px-4 py-3 text-sm text-fg-muted`,children:t.tokenHint}),f?(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border border-accent/25 bg-accent-soft px-4 py-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:t.understandingSetupTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:t.understandingSetupHint})]}),(0,$.jsx)(D,{type:`button`,variant:`secondary`,className:`shrink-0`,onClick:()=>s(m),children:t.understandingSetupDone})]}):null,(0,$.jsxs)(`section`,{className:`flex flex-col gap-4`,children:[(0,$.jsx)(`div`,{className:`border-b border-edge-subtle pb-3 dark:border-edge-subtle`,children:(0,$.jsx)(rt,{items:nt,activeTab:y,onChange:ke,ariaLabel:t.navAria,tabIdPrefix:`connectors-tab`,panelIdPrefix:`connectors-panel`,className:`flex-wrap`})}),S.error?(0,$.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:S.error}):null,y===`connected`&&o?(0,$.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[Ee>5||P?(0,$.jsx)(wt,{value:P,onChange:F,placeholder:t.connectedSearchPlaceholder,className:`max-w-xl`}):(0,$.jsx)(`div`,{className:`flex-1`}),(0,$.jsx)(Ge,{className:`size-9 shrink-0 p-0`,loading:S.loading,label:t.refreshConnections,title:t.refreshConnections,onClick:Oe})]}),S.loading?(0,$.jsx)(`div`,{className:`grid gap-3`,"aria-busy":`true`,"aria-label":t.loading,children:ot.slice(0,3).map(e=>(0,$.jsx)(dt,{},e))}):Ee===0?(0,$.jsxs)(`div`,{className:`py-14 text-center`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.connectionsEmpty}),(0,$.jsx)(D,{type:`button`,variant:`primary`,className:`mt-4`,onClick:()=>ke(`discover`),children:t.addFromCatalog})]}):Je===0?(0,$.jsx)(`div`,{className:`py-14 text-center text-sm text-fg-muted`,children:t.connectionsSearchEmpty}):(0,$.jsxs)(`div`,{className:`space-y-6`,children:[X.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:t.needsAttentionTitle}),(0,$.jsx)(`span`,{className:`text-xs tabular-nums text-amber-700 dark:text-amber-300`,children:X.length})]}),(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-xl border border-amber-500/25 bg-amber-500/5`,children:X.map(e=>(0,$.jsx)(Sn,{instance:e,definition:Ne.get(e.connectorId),highlighted:e.instanceId===oe,onOpenDetails:e=>{se(null),q(e.instanceId),ae(e)},t},e.instanceId))})]}):null,Ke.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:t.connectedServicesTitle}),(0,$.jsx)(`span`,{className:`text-xs tabular-nums text-fg-subtle`,children:Ke.length})]}),(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-xl border border-edge bg-surface-base`,children:Ke.map(e=>(0,$.jsx)(Sn,{instance:e,definition:Ne.get(e.connectorId),highlighted:e.instanceId===oe,onOpenDetails:e=>{se(null),q(e.instanceId),ae(e)},t},e.instanceId))})]}):null,qe.length||!P.trim()?(0,$.jsxs)(`details`,{className:`rounded-xl border border-edge bg-surface-base`,children:[(0,$.jsxs)(`summary`,{className:`cursor-pointer px-4 py-3`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.customIntegrationsTitle}),(0,$.jsx)(`span`,{className:`ml-2 text-xs tabular-nums text-fg-subtle`,children:qe.length}),(0,$.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:t.customIntegrationsHint})]}),(0,$.jsxs)(`div`,{className:`border-t border-edge-subtle`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2 px-4 py-3`,children:[(0,$.jsx)(D,{type:`button`,variant:`secondary`,className:`h-8 text-xs`,onClick:Le,children:t.addCustomServerAdvanced}),(0,$.jsxs)(D,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,onClick:()=>he(!0),children:[(0,$.jsx)(ce,{className:`size-3.5`}),t.runtimeSettings]})]}),(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle`,children:qe.map(e=>(0,$.jsx)($t,{row:e,t:n,cs:t,onEdit:()=>ue({mode:`edit`,row:structuredClone(e)}),onRemove:async()=>Ie(e)},e.clientKey))})]})]}):null]})]}):null,y===`discover`&&o?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[f?null:(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,role:`group`,"aria-label":t.taskFilterAria,children:[`all`,...Qe].map(e=>(0,$.jsx)(`button`,{type:`button`,className:p(`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors`,U===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":U===e,onClick:()=>W(e),children:e===`all`?t.taskAll:t.connectorBenefitHeadings[e]},e))}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 lg:flex-row lg:items-center`,children:[(0,$.jsx)(wt,{value:I,onChange:L,placeholder:t.discoverSearchPlaceholder,className:`max-w-xl`}),(0,$.jsxs)(`details`,{className:`relative shrink-0 lg:ml-auto`,children:[(0,$.jsxs)(`summary`,{className:`flex h-9 cursor-pointer list-none items-center gap-2 rounded-lg border border-edge bg-surface-panel px-3 text-xs font-medium text-fg-muted hover:bg-surface-hover hover:text-fg`,children:[(0,$.jsx)(fe,{className:`size-3.5`,"aria-hidden":!0}),t.filters]}),(0,$.jsxs)(`div`,{className:p(`mt-2 grid min-w-[15rem] grid-cols-1 gap-2 rounded-xl border border-edge bg-surface-panel p-3 shadow-popover sm:absolute sm:right-0 sm:z-10`,!f&&`sm:min-w-[24rem] sm:grid-cols-2`),children:[f?null:(0,$.jsx)(c,{value:z,options:tt,placeholder:t.discoverSourceAll,allowEmpty:!1,ariaLabel:t.registrySourceAria,triggerClassName:`h-9 bg-surface-panel text-xs`,onChange:B}),(0,$.jsx)(c,{value:V,options:[{value:`name`,label:t.sortName},{value:`source`,label:t.sortSource}],placeholder:t.sortName,allowEmpty:!1,ariaLabel:t.sortAria,triggerClassName:`h-9 bg-surface-panel text-xs`,onChange:e=>H(e)})]})]})]}),(S.loading||w)&&Ze.length===0?(0,$.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,"aria-busy":`true`,"aria-label":t.loading,children:ot.map(e=>(0,$.jsx)(lt,{},e))}):Ze.length===0?(0,$.jsx)(`div`,{className:`py-14 text-center text-sm text-fg-muted`,children:t.discoverEmpty}):(0,$.jsxs)(`div`,{className:`relative`,children:[w?(0,$.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-[1] flex justify-center bg-surface-panel/40 pt-[min(28vh,7.5rem)] backdrop-blur-[1px] motion-reduce:backdrop-blur-none dark:bg-surface-base/35`,"aria-busy":`true`,"aria-label":t.loading,children:(0,$.jsx)(u,{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:Ze.map(e=>(0,$.jsx)(it,{connector:e,installed:Me.has(e.id)||st(e,S.instances),onInstall:e=>{if(e.source===`store`){Pe(e.id);return}K(ye(e))},onOpenDetails:e.source===`store`?void 0:ne,t},e.id))}),$e?(0,$.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,$.jsxs)(D,{type:`button`,variant:`secondary`,disabled:w||E,onClick:()=>void je({page:A+1,append:!0}),children:[w?(0,$.jsx)(u,{className:`size-4 animate-spin`}):null,t.loadMore]})}):null]})]}):null]}),ee?(0,$.jsx)(G,{draft:ee,onChange:K,onClose:()=>K(null),t,onInstalled:async e=>{await Oe(),await Ce(),se(e.instanceId),ke(`connected`)}}):null,te?(0,$.jsx)(xt,{connector:te,installed:Me.has(te.id)||st(te,S.instances),onClose:()=>ne(null),onInstall:e=>K(ye(e)),t}):null,et?(0,$.jsx)(xn,{instance:et,definition:Ne.get(et.connectorId),onClose:()=>{q(null),ae(null)},onChanged:Oe,t,mcp:n}):null,le?(0,$.jsx)(In,{open:!0,mode:le.mode,initialRow:le.row,existingCustomServers:Te,sessionIdleTtlMinutes:ge,config:we,managedServerIds:Fe,t:n,cs:t,onClose:()=>ue(null),onSaved:async()=>{await Ce(),await Oe(),ke(`connected`)}},`${le.mode}-${le.row.clientKey}`):null,(0,$.jsx)(Ct,{open:me,sessionIdleTtlMinutes:ge,saving:_e,onChange:J,onSave:Re,onClose:()=>he(!1),t,mcp:n})]})})}export{Yn as ConnectorsPage};