@xopcai/xopc 0.0.136 → 0.0.138

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 (271) hide show
  1. package/README.md +4 -0
  2. package/README.zh-CN.md +4 -0
  3. package/dist/browser-ext/manifest.json +1 -1
  4. package/dist/extensions/demo-memory/src/index.js +4 -0
  5. package/dist/extensions/demo-memory/src/index.js.map +1 -1
  6. package/dist/extensions/telegram/xopc.extension.json +1 -1
  7. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-CER17NHM.js → agent-avatar-dicebear-CIsGDJzd.js} +1 -1
  8. package/dist/gateway/static/root/assets/agents-fX97A6iN.js +2 -0
  9. package/dist/gateway/static/root/assets/{app-management-settings-panel-B3Ap_wpX.js → app-management-settings-panel-ByM4Bzwm.js} +1 -1
  10. package/dist/gateway/static/root/assets/{appearance-settings-3kBO22Xd.js → appearance-settings-BF_poRd3.js} +1 -1
  11. package/dist/gateway/static/root/assets/{apps-page-BHYbGQcZ.js → apps-page-BssdA5Qc.js} +1 -1
  12. package/dist/gateway/static/root/assets/{archive-plugin-D_vGeNB8.js → archive-plugin-DJaYoyGn.js} +1 -1
  13. package/dist/gateway/static/root/assets/{attachment-load-hWV_8pHL.js → attachment-load-xx6dBaZU.js} +1 -1
  14. package/dist/gateway/static/root/assets/{automation-suggestion-card-DVKmVTIo.js → automation-suggestion-card-BMvGqYob.js} +1 -1
  15. package/dist/gateway/static/root/assets/{automations-page-BCTXpOBp.js → automations-page-Dip8ZFmx.js} +1 -1
  16. package/dist/gateway/static/root/assets/{binary-plugins-BuXIeSPc.js → binary-plugins-CuPLWibr.js} +1 -1
  17. package/dist/gateway/static/root/assets/{block-editor-C1m0u-UU.js → block-editor-bzfvlJnh.js} +58 -54
  18. package/dist/gateway/static/root/assets/{browser-settings-page-ChUF08V5.js → browser-settings-page-lbx_8Dku.js} +4 -4
  19. package/dist/gateway/static/root/assets/{capability-presets-api-B7WWYaEh.js → capability-presets-api-X4Imbf8n.js} +1 -1
  20. package/dist/gateway/static/root/assets/{capability-presets-settings-panel-D_Bh1PnA.js → capability-presets-settings-panel-v9JgKjJu.js} +1 -1
  21. package/dist/gateway/static/root/assets/{channel-recipient-api-sV06LCht.js → channel-recipient-api-DllrPmp-.js} +1 -1
  22. package/dist/gateway/static/root/assets/{channels-settings-BI2ChQc7.js → channels-settings-CED7Oy5Y.js} +1 -1
  23. package/dist/gateway/static/root/assets/channels-status-swr-EUwWYx8l.js +1 -0
  24. package/dist/gateway/static/root/assets/{connectors-page-qgvEp09M.js → connectors-page-BMfp0jWL.js} +1 -1
  25. package/dist/gateway/static/root/assets/{desktop-pet-BxMJlvb-.js → desktop-pet-oTig6qFO.js} +1 -1
  26. package/dist/gateway/static/root/assets/{desktop-pet-settings-DCvpDImn.js → desktop-pet-settings-DXJiPL_H.js} +1 -1
  27. package/dist/gateway/static/root/assets/{directory-picker-path-field-D1nxs9PA.js → directory-picker-path-field-CltkXSR2.js} +1 -1
  28. package/dist/gateway/static/root/assets/{dreaming-settings-EAWkpOgw.js → dreaming-settings-CYrZQxoL.js} +1 -1
  29. package/dist/gateway/static/root/assets/{extension-debug-page-LUQ8dE8z.js → extension-debug-page-C-4BOy1R.js} +1 -1
  30. package/dist/gateway/static/root/assets/{extension-page-B_mnhoRd.js → extension-page-C8nMpXqh.js} +1 -1
  31. package/dist/gateway/static/root/assets/{extension-settings-page-BWQsGmvW.js → extension-settings-page-CXWYOwka.js} +1 -1
  32. package/dist/gateway/static/root/assets/{fetch-BWXmBizE.js → fetch-BID89uCH.js} +1 -1
  33. package/dist/gateway/static/root/assets/{gateway-config-api-M9bzPASf.js → gateway-config-api-B3TGdim5.js} +1 -1
  34. package/dist/gateway/static/root/assets/{gateway-settings-CbgtpprN.js → gateway-settings-D7tOnGAJ.js} +1 -1
  35. package/dist/gateway/static/root/assets/{gateway-startup-retry-BALL91S7.js → gateway-startup-retry-BkrLLlpE.js} +1 -1
  36. package/dist/gateway/static/root/assets/{goal-create-dialog-CbP4t9aM.js → goal-create-dialog-BL_cRshf.js} +1 -1
  37. package/dist/gateway/static/root/assets/{goal-detail-page-DlwI-MZZ.js → goal-detail-page-T1vg6Ng_.js} +1 -1
  38. package/dist/gateway/static/root/assets/{goals-config-api-BBhFVzBS.js → goals-config-api-D-WZWhP2.js} +1 -1
  39. package/dist/gateway/static/root/assets/{goals-page-D26r7knp.js → goals-page-1vzWXl5W.js} +1 -1
  40. package/dist/gateway/static/root/assets/{goals-settings-DdmVG_TR.js → goals-settings-DgGwvLVC.js} +1 -1
  41. package/dist/gateway/static/root/assets/{heartbeat-settings-DZW2Xq-U.js → heartbeat-settings-yh0bEIwQ.js} +1 -1
  42. package/dist/gateway/static/root/assets/index-B8s8Pq5U.css +1 -0
  43. package/dist/gateway/static/root/assets/index-NwiCnzI-.js +262 -0
  44. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-1IWd88-T.js → keyboard-shortcuts-settings-CnxRFbgA.js} +1 -1
  45. package/dist/gateway/static/root/assets/{logs-page-DxoKJO7-.js → logs-page-DebnvTpD.js} +1 -1
  46. package/dist/gateway/static/root/assets/{markdown-split-BtdBj32h.js → markdown-split-BU69Nof8.js} +1 -1
  47. package/dist/gateway/static/root/assets/{media-plugins-CpoPj3s8.js → media-plugins-CDs7OvWt.js} +1 -1
  48. package/dist/gateway/static/root/assets/messages-DbNQuFdA.js +3 -0
  49. package/dist/gateway/static/root/assets/{models-hub-panel-D1Rp__dV.js → models-hub-panel-Ca_jy26S.js} +1 -1
  50. package/dist/gateway/static/root/assets/{notes-page-CgR1bO2W.js → notes-page-DTpeaI65.js} +1 -1
  51. package/dist/gateway/static/root/assets/{notes-workbench-ozsnmDTV.js → notes-workbench-uKMYsjUU.js} +2 -2
  52. package/dist/gateway/static/root/assets/{page-tabs-CVLqCfQB.js → page-tabs-CROo8Vgz.js} +1 -1
  53. package/dist/gateway/static/root/assets/{preview-open-alternatives-CKUXJk2t.js → preview-open-alternatives-BxsS9i1G.js} +1 -1
  54. package/dist/gateway/static/root/assets/{project-detail-page-B4dqFAQF.js → project-detail-page-BWKOhshy.js} +1 -1
  55. package/dist/gateway/static/root/assets/{projects-page-DlRGXv4a.js → projects-page-CoowiCLe.js} +1 -1
  56. package/dist/gateway/static/root/assets/{remote-access-hub-rZEYQMZV.js → remote-access-hub-CiOaX1wd.js} +1 -1
  57. package/dist/gateway/static/root/assets/{save-bar-controls-BtGni268.js → save-bar-controls-B4N17dMG.js} +1 -1
  58. package/dist/gateway/static/root/assets/{schedule-field-BDGzKVWn.js → schedule-field-ClJzQ2vz.js} +1 -1
  59. package/dist/gateway/static/root/assets/{schema-form-DQJsKMCE.js → schema-form-oZvQUfDg.js} +1 -1
  60. package/dist/gateway/static/root/assets/{sessions-page-DxGoCGU8.js → sessions-page-Sx9Gc0cv.js} +1 -1
  61. package/dist/gateway/static/root/assets/settings-advanced-gate-CnbVdze4.js +1 -0
  62. package/dist/gateway/static/root/assets/{settings-collapsible-section-c8XGd4-8.js → settings-collapsible-section-B0kOLXUf.js} +1 -1
  63. package/dist/gateway/static/root/assets/{settings-form-section-By0YiDWo.js → settings-form-section-DoVPlVFd.js} +1 -1
  64. package/dist/gateway/static/root/assets/{settings-loading-skeleton-SYCPY-WM.js → settings-loading-skeleton-C7J96bLc.js} +1 -1
  65. package/dist/gateway/static/root/assets/{settings-page-D9NwvnBt.js → settings-page-CXiAByF0.js} +1 -1
  66. package/dist/gateway/static/root/assets/{settings-page-layout-CrICyGob.js → settings-page-layout-R-6ArlMI.js} +1 -1
  67. package/dist/gateway/static/root/assets/{setup-status-panel-IjK-hDxf.js → setup-status-panel-Drz23n9l.js} +1 -1
  68. package/dist/gateway/static/root/assets/{share-preview-page-Dfnk9M_m.js → share-preview-page-Bn1umseg.js} +1 -1
  69. package/dist/gateway/static/root/assets/{shares-settings-vQiRBra7.js → shares-settings-Bb-pcMWg.js} +1 -1
  70. package/dist/gateway/static/root/assets/skill-reload-api-DE9HCHct.js +1 -0
  71. package/dist/gateway/static/root/assets/{skills-page-CruV215G.js → skills-page-B6cDPqkk.js} +1 -1
  72. package/dist/gateway/static/root/assets/{system-settings-panel-BBVbSDFD.js → system-settings-panel-CtEddAy-.js} +1 -1
  73. package/dist/gateway/static/root/assets/{typed-models-lib-CwFayhxu.js → typed-models-lib-BkhSnYq7.js} +1 -1
  74. package/dist/gateway/static/root/assets/{use-channel-catalog-BKtHOM50.js → use-channel-catalog-EA4hfbsP.js} +1 -1
  75. package/dist/gateway/static/root/assets/{user-profile-settings-panel-_KDWzagh.js → user-profile-settings-panel-BssTVOBS.js} +1 -1
  76. package/dist/gateway/static/root/assets/{utils-BiUjIHb4.js → utils-CI3ywKLT.js} +1 -1
  77. package/dist/gateway/static/root/assets/{voice-api-key-field-agJqlm4o.js → voice-api-key-field-DXMEGw9O.js} +1 -1
  78. package/dist/gateway/static/root/assets/{work-item-detail-page-Bdw4ATCb.js → work-item-detail-page-DsFqU0tK.js} +1 -1
  79. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-D-Dy6mTy.js → workflow-run-setup-panel-DImBi-m6.js} +1 -1
  80. package/dist/gateway/static/root/assets/{workflow-start-dialog-GammZ2GK.js → workflow-start-dialog-DuPpKAAc.js} +1 -1
  81. package/dist/gateway/static/root/assets/{workflows-page-Cw5zrqti.js → workflows-page-DfTVzTNY.js} +1 -1
  82. package/dist/gateway/static/root/index.html +5 -5
  83. package/dist/package.js +1 -1
  84. package/dist/src/agent/agent-instance-gateway.d.ts +3 -3
  85. package/dist/src/agent/agent-manager.d.ts +7 -8
  86. package/dist/src/agent/agent-manager.js +24 -25
  87. package/dist/src/agent/agent-manager.js.map +1 -1
  88. package/dist/src/agent/background-review/coordinator.d.ts +9 -23
  89. package/dist/src/agent/background-review/coordinator.js +45 -54
  90. package/dist/src/agent/background-review/coordinator.js.map +1 -1
  91. package/dist/src/agent/background-review/prompts.d.ts +2 -4
  92. package/dist/src/agent/background-review/prompts.js +7 -19
  93. package/dist/src/agent/background-review/prompts.js.map +1 -1
  94. package/dist/src/agent/background-review/run-background-review.d.ts +0 -8
  95. package/dist/src/agent/background-review/run-background-review.js +87 -72
  96. package/dist/src/agent/background-review/run-background-review.js.map +1 -1
  97. package/dist/src/agent/background-review/settings.d.ts +4 -4
  98. package/dist/src/agent/background-review/settings.js +25 -10
  99. package/dist/src/agent/background-review/settings.js.map +1 -1
  100. package/dist/src/agent/code-intelligence/binary.d.ts +1 -0
  101. package/dist/src/agent/code-intelligence/binary.js +42 -0
  102. package/dist/src/agent/code-intelligence/binary.js.map +1 -0
  103. package/dist/src/agent/code-intelligence/index.d.ts +4 -0
  104. package/dist/src/agent/code-intelligence/index.js +4 -0
  105. package/dist/src/agent/code-intelligence/runtime.d.ts +34 -0
  106. package/dist/src/agent/code-intelligence/runtime.js +282 -0
  107. package/dist/src/agent/code-intelligence/runtime.js.map +1 -0
  108. package/dist/src/agent/code-intelligence/tools.d.ts +6 -0
  109. package/dist/src/agent/code-intelligence/tools.js +268 -0
  110. package/dist/src/agent/code-intelligence/tools.js.map +1 -0
  111. package/dist/src/agent/code-intelligence/types.d.ts +22 -0
  112. package/dist/src/agent/code-intelligence/types.js +1 -0
  113. package/dist/src/agent/memory/builtin-provider.d.ts +1 -2
  114. package/dist/src/agent/memory/builtin-provider.js +31 -12
  115. package/dist/src/agent/memory/builtin-provider.js.map +1 -1
  116. package/dist/src/agent/memory/context/planner.d.ts +11 -0
  117. package/dist/src/agent/memory/context/planner.js +163 -0
  118. package/dist/src/agent/memory/context/planner.js.map +1 -0
  119. package/dist/src/agent/memory/context/types.d.ts +19 -0
  120. package/dist/src/agent/memory/context/types.js +1 -0
  121. package/dist/src/agent/memory/context-fence.d.ts +3 -3
  122. package/dist/src/agent/memory/context-fence.js +9 -9
  123. package/dist/src/agent/memory/context-fence.js.map +1 -1
  124. package/dist/src/agent/memory/index.d.ts +6 -4
  125. package/dist/src/agent/memory/index.js +5 -5
  126. package/dist/src/agent/memory/manager.d.ts +16 -4
  127. package/dist/src/agent/memory/manager.js +32 -34
  128. package/dist/src/agent/memory/manager.js.map +1 -1
  129. package/dist/src/agent/memory/memory-config.d.ts +1 -1
  130. package/dist/src/agent/memory/memory-config.js +2 -2
  131. package/dist/src/agent/memory/memory-config.js.map +1 -1
  132. package/dist/src/agent/memory/provider.d.ts +1 -3
  133. package/dist/src/agent/memory/stub-memory-provider.d.ts +0 -1
  134. package/dist/src/agent/memory/stub-memory-provider.js +0 -5
  135. package/dist/src/agent/memory/stub-memory-provider.js.map +1 -1
  136. package/dist/src/agent/memory/types.d.ts +31 -2
  137. package/dist/src/agent/memory/understanding/correction.d.ts +3 -0
  138. package/dist/src/agent/memory/understanding/correction.js +41 -0
  139. package/dist/src/agent/memory/understanding/correction.js.map +1 -0
  140. package/dist/src/agent/memory/understanding/quality.d.ts +8 -0
  141. package/dist/src/agent/memory/understanding/quality.js +20 -0
  142. package/dist/src/agent/memory/understanding/quality.js.map +1 -0
  143. package/dist/src/agent/memory/understanding/service.d.ts +26 -0
  144. package/dist/src/agent/memory/understanding/service.js +233 -0
  145. package/dist/src/agent/memory/understanding/service.js.map +1 -0
  146. package/dist/src/agent/memory/understanding/types.d.ts +22 -0
  147. package/dist/src/agent/memory/understanding/types.js +1 -0
  148. package/dist/src/agent/memory/user-context-coordinator.d.ts +21 -0
  149. package/dist/src/agent/memory/user-context-coordinator.js +90 -0
  150. package/dist/src/agent/memory/user-context-coordinator.js.map +1 -0
  151. package/dist/src/agent/orchestration/agent-event-handler.d.ts +1 -0
  152. package/dist/src/agent/orchestration/agent-event-handler.js +1 -1
  153. package/dist/src/agent/orchestration/agent-event-handler.js.map +1 -1
  154. package/dist/src/agent/orchestration/agent-orchestrator.js +2 -2
  155. package/dist/src/agent/orchestration/agent-orchestrator.js.map +1 -1
  156. package/dist/src/agent/orchestration/index.d.ts +1 -1
  157. package/dist/src/agent/orchestration/index.js +2 -2
  158. package/dist/src/agent/prompt/sections/tooling.js +10 -0
  159. package/dist/src/agent/prompt/sections/tooling.js.map +1 -1
  160. package/dist/src/agent/prompt/system-prompt.js +2 -0
  161. package/dist/src/agent/prompt/system-prompt.js.map +1 -1
  162. package/dist/src/agent/service/direct-turn-helpers.js +2 -2
  163. package/dist/src/agent/service/direct-turn-helpers.js.map +1 -1
  164. package/dist/src/agent/service.js +7 -1
  165. package/dist/src/agent/service.js.map +1 -1
  166. package/dist/src/agent/session/session-inspector.d.ts +1 -0
  167. package/dist/src/agent/session/session-inspector.js +8 -2
  168. package/dist/src/agent/session/session-inspector.js.map +1 -1
  169. package/dist/src/agent/tools/factory.d.ts +3 -0
  170. package/dist/src/agent/tools/factory.js +17 -10
  171. package/dist/src/agent/tools/factory.js.map +1 -1
  172. package/dist/src/agent/tools/index.d.ts +1 -0
  173. package/dist/src/agent/tools/index.js +2 -1
  174. package/dist/src/agent/workspace-runtime/registry.d.ts +2 -0
  175. package/dist/src/agent/workspace-runtime/registry.js +11 -3
  176. package/dist/src/agent/workspace-runtime/registry.js.map +1 -1
  177. package/dist/src/agent-manifest/index.js +2 -2
  178. package/dist/src/agent-manifest/schema.d.ts +91 -0
  179. package/dist/src/agent-manifest/schema.js +27 -5
  180. package/dist/src/agent-manifest/schema.js.map +1 -1
  181. package/dist/src/agent-runtime/memory-runtime.d.ts +1 -1
  182. package/dist/src/agent-runtime/memory-runtime.js.map +1 -1
  183. package/dist/src/automations/domain/validation.d.ts +22 -22
  184. package/dist/src/automations/draft/automation-draft-validator.d.ts +4 -4
  185. package/dist/src/cli/command-loaders.js +1 -0
  186. package/dist/src/cli/command-loaders.js.map +1 -1
  187. package/dist/src/cli/command-manifest.js +4 -0
  188. package/dist/src/cli/command-manifest.js.map +1 -1
  189. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  190. package/dist/src/cli/commands/resume.d.ts +1 -0
  191. package/dist/src/cli/commands/resume.js +31 -0
  192. package/dist/src/cli/commands/resume.js.map +1 -0
  193. package/dist/src/cli/commands/tui-runner.d.ts +9 -0
  194. package/dist/src/cli/commands/tui-runner.js +40 -0
  195. package/dist/src/cli/commands/tui-runner.js.map +1 -0
  196. package/dist/src/cli/commands/tui.js +4 -28
  197. package/dist/src/cli/commands/tui.js.map +1 -1
  198. package/dist/src/config/agent-profile.js +1 -1
  199. package/dist/src/config/index.js +2 -2
  200. package/dist/src/config/schema.d.ts +115 -0
  201. package/dist/src/config/schema.js +53 -4
  202. package/dist/src/config/schema.js.map +1 -1
  203. package/dist/src/gateway/agent-builtin-tools.d.ts +1 -1
  204. package/dist/src/gateway/agent-builtin-tools.js +5 -0
  205. package/dist/src/gateway/agent-builtin-tools.js.map +1 -1
  206. package/dist/src/gateway/agents-admin.js +1 -1
  207. package/dist/src/gateway/hono/lib/config-payload.d.ts +18 -4
  208. package/dist/src/gateway/hono/routes/home.js +37 -2
  209. package/dist/src/gateway/hono/routes/home.js.map +1 -1
  210. package/dist/src/gateway/hono/routes/memory.js +129 -4
  211. package/dist/src/gateway/hono/routes/memory.js.map +1 -1
  212. package/dist/src/gateway/hono/routes/projects.js +16 -0
  213. package/dist/src/gateway/hono/routes/projects.js.map +1 -1
  214. package/dist/src/knowledge/index.d.ts +2 -0
  215. package/dist/src/knowledge/index.js +2 -0
  216. package/dist/src/knowledge/ingestion-service.d.ts +20 -0
  217. package/dist/src/knowledge/ingestion-service.js +75 -0
  218. package/dist/src/knowledge/ingestion-service.js.map +1 -0
  219. package/dist/src/knowledge/types.d.ts +70 -0
  220. package/dist/src/knowledge/types.js +1 -0
  221. package/dist/src/projects/project-kind.js +0 -1
  222. package/dist/src/projects/project-kind.js.map +1 -1
  223. package/dist/src/providers/presentation.js +1 -1
  224. package/dist/src/providers/presentation.js.map +1 -1
  225. package/dist/src/storage/sqlite/index.d.ts +2 -1
  226. package/dist/src/storage/sqlite/index.js +3 -2
  227. package/dist/src/storage/sqlite/knowledge-repository.d.ts +50 -0
  228. package/dist/src/storage/sqlite/knowledge-repository.js +237 -0
  229. package/dist/src/storage/sqlite/knowledge-repository.js.map +1 -0
  230. package/dist/src/storage/sqlite/memory-records-repository.d.ts +80 -2
  231. package/dist/src/storage/sqlite/memory-records-repository.js +271 -9
  232. package/dist/src/storage/sqlite/memory-records-repository.js.map +1 -1
  233. package/dist/src/storage/sqlite/migrations/029_user_understanding.sql +133 -0
  234. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  235. package/dist/src/storage/sqlite/migrations/runner.js +3 -3
  236. package/dist/src/storage/sqlite/migrations/runner.js.map +1 -1
  237. package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
  238. package/dist/src/storage/sqlite/schema.js +1 -1
  239. package/dist/src/tui/tui-picker-overlay.d.ts +6 -1
  240. package/dist/src/tui/tui-picker-overlay.js +4 -1
  241. package/dist/src/tui/tui-picker-overlay.js.map +1 -1
  242. package/dist/src/tui/tui-types.d.ts +2 -0
  243. package/dist/src/tui/tui-types.js.map +1 -1
  244. package/dist/src/tui/tui.js +17 -2
  245. package/dist/src/tui/tui.js.map +1 -1
  246. package/dist/src/work-items/work-item-service.d.ts +1 -0
  247. package/dist/src/work-items/work-item-service.js +3 -0
  248. package/dist/src/work-items/work-item-service.js.map +1 -1
  249. package/dist/src/work-items/work-item-store.d.ts +1 -0
  250. package/dist/src/work-items/work-item-store.js +13 -0
  251. package/dist/src/work-items/work-item-store.js.map +1 -1
  252. package/package.json +2 -1
  253. package/dist/gateway/static/root/assets/agents-Bv5R-N8Q.js +0 -2
  254. package/dist/gateway/static/root/assets/channels-status-swr-MY4Xh4fM.js +0 -1
  255. package/dist/gateway/static/root/assets/index-CPwVzi9x.css +0 -1
  256. package/dist/gateway/static/root/assets/index-DZOm5_ex.js +0 -262
  257. package/dist/gateway/static/root/assets/messages-CQ_k8RHj.js +0 -3
  258. package/dist/gateway/static/root/assets/settings-advanced-gate-4e8ZQwxr.js +0 -1
  259. package/dist/gateway/static/root/assets/skill-reload-api-BIWv778A.js +0 -1
  260. package/dist/src/agent/memory/candidate-extractor.d.ts +0 -6
  261. package/dist/src/agent/memory/candidate-extractor.js +0 -60
  262. package/dist/src/agent/memory/candidate-extractor.js.map +0 -1
  263. package/dist/src/agent/memory/context-assembler.d.ts +0 -10
  264. package/dist/src/agent/memory/context-assembler.js +0 -26
  265. package/dist/src/agent/memory/context-assembler.js.map +0 -1
  266. package/dist/src/agent/memory/inject-prefetch.d.ts +0 -6
  267. package/dist/src/agent/memory/inject-prefetch.js +0 -48
  268. package/dist/src/agent/memory/inject-prefetch.js.map +0 -1
  269. package/dist/src/agent/memory/prefetch-coordinator.d.ts +0 -37
  270. package/dist/src/agent/memory/prefetch-coordinator.js +0 -45
  271. package/dist/src/agent/memory/prefetch-coordinator.js.map +0 -1
@@ -1,2 +1,2 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-CQ_k8RHj.js";import{a as o,n as s,o as c}from"./fetch-BWXmBizE.js";import{n as l}from"./locale-store-Ba72bFmP.js";import{r as u}from"./toast-z0toXu32.js";import{$c as d,$r as f,Ao as p,Ba as m,Cs as h,Ec as g,Eo as _,Es as v,Fr as y,Fs as b,Ga as x,Ha as S,Ir as C,Ka as w,Ks as T,Lr as E,Pc as D,Pr as O,To as k,Ua as A,Va as j,Vo as M,Wa as N,Wc as P,_o as F,ac as I,ao as L,bc as ee,bo as R,cs as z,ei as B,ga as te,ha as V,ho as ne,il as re,is as ie,kl as ae,ko as oe,ni as se,oo as ce,ps as le,qa as ue,ri as de,ro as fe,ti as pe,to as me,us as he,ws as ge,yi as _e,zr as ve}from"./index-DZOm5_ex.js";import{n as ye,t as be}from"./settings-form-section-By0YiDWo.js";import{t as xe}from"./page-tabs-CVLqCfQB.js";var H=e(t(),1),U=n(),W=r(),G=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`,Se=[`c0`,`c1`,`c2`,`c3`,`c4`,`c5`];function Ce(e,t){return t.some(t=>t.connectorId===e.id)}function K(e,t){return t[e]??e}function q(e,t){return t.connectorCategoryTemplate.replace(`{{category}}`,K(e,t.connectorCategoryLabels))}function we(){let e=(0,U.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,W.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,W.jsx)(`div`,{className:`flex min-h-0 flex-1 items-start gap-3`,children:(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,W.jsx)(`div`,{className:i(`h-4 min-w-0 flex-1`,G)}),(0,W.jsx)(`div`,{className:i(`h-8 w-[4.5rem] shrink-0 rounded-lg`,G)})]}),(0,W.jsx)(`div`,{className:i(`h-3 w-full`,G)}),(0,W.jsx)(`div`,{className:i(`h-3 w-[88%]`,G)})]})})}),e[0]=t):t=e[0],t}function Te(){let e=(0,U.c)(3),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,W.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2`,children:[(0,W.jsx)(`div`,{className:i(`h-4 w-48 max-w-full`,G)}),(0,W.jsx)(`div`,{className:i(`h-3 w-72 max-w-full`,G)})]}),e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,W.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[t,(0,W.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,W.jsx)(`div`,{className:i(`h-9 w-20 rounded-lg`,G)}),(0,W.jsx)(`div`,{className:i(`h-9 w-20 rounded-lg`,G)})]})]}),e[1]=n):n=e[1];let r;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,W.jsxs)(`div`,{className:`rounded-2xl bg-surface-panel p-4 shadow-surface`,"aria-hidden":!0,children:[n,(0,W.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,W.jsx)(`div`,{className:i(`h-8 w-20 rounded-md`,G)}),(0,W.jsx)(`div`,{className:i(`h-8 w-24 rounded-md`,G)}),(0,W.jsx)(`div`,{className:i(`h-8 w-28 rounded-md`,G)})]}),(0,W.jsx)(`div`,{className:i(`mt-3 h-20 rounded-xl`,G)})]}),e[2]=r):r=e[2],r}function Ee(e){let t=(0,U.c)(69),{connector:n,installed:r,onInstall:a,onOpenDetails:o,t:s}=e,c;t[0]!==n.category||t[1]!==s?(c=q(n.category,s),t[0]=n.category,t[1]=s,t[2]=c):c=t[2];let l=c,u,f,p,m,h,g,v,y,x,S;if(t[3]!==l||t[4]!==n||t[5]!==r||t[6]!==a||t[7]!==o||t[8]!==s.install||t[9]!==s.installedBadge){let e=n.capabilities.slice(0,4),c=Math.max(0,n.capabilities.length-e.length),C;t[20]!==n||t[21]!==a||t[22]!==s.install?(C=e=>(0,W.jsxs)(_,{type:`button`,variant:`primary`,className:i(`h-8 justify-center px-2.5 text-xs font-medium`,e),onClick:e=>{e.stopPropagation(),a(n)},children:[(0,W.jsx)(b,{className:`size-4`}),s.install]}),t[20]=n,t[21]=a,t[22]=s.install,t[23]=C):C=t[23],u=C;let w;t[24]!==n||t[25]!==o?(w=e=>{!o||e.currentTarget!==e.target||e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),o(n))},t[24]=n,t[25]=o,t[26]=w):w=t[26];let T=w,E=o?`cursor-pointer`:null;t[27]===E?v=t[28]:(v=i(`group flex min-h-[9.5rem] flex-col rounded-lg bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45 focus-within:ring-2 focus-within:ring-accent/30`,E),t[27]=E,t[28]=v),y=o?`button`:void 0,x=o?0:void 0,t[29]!==n||t[30]!==o?(S=()=>o?.(n),t[29]=n,t[30]=o,t[31]=S):S=t[31],f=T,p=`flex min-w-0 flex-1 flex-col`;let D;t[32]===n.displayName?D=t[33]:(D=(0,W.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:n.displayName}),t[32]=n.displayName,t[33]=D);let O;t[34]===l?O=t[35]:(O=(0,W.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-subtle`,children:l}),t[34]=l,t[35]=O);let k;t[36]!==D||t[37]!==O?(k=(0,W.jsx)(`div`,{className:`flex min-w-0 items-start gap-3`,children:(0,W.jsxs)(`div`,{className:`min-w-0`,children:[D,O]})}),t[36]=D,t[37]=O,t[38]=k):k=t[38];let A;t[39]!==r||t[40]!==u?(A=r?null:(0,W.jsx)(`div`,{className:`hidden shrink-0 items-center gap-1 transition-opacity sm:pointer-events-none sm:flex sm:opacity-0 sm:group-hover:pointer-events-auto sm:group-hover:opacity-100 sm:group-focus-within:pointer-events-auto sm:group-focus-within:opacity-100`,children:u()}),t[39]=r,t[40]=u,t[41]=A):A=t[41];let j;t[42]!==r||t[43]!==s.installedBadge?(j=r?(0,W.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,W.jsx)(d,{className:`size-3`,"aria-hidden":!0}),s.installedBadge]}):null,t[42]=r,t[43]=s.installedBadge,t[44]=j):j=t[44];let M;t[45]!==A||t[46]!==j?(M=(0,W.jsxs)(`div`,{className:`flex shrink-0 items-start gap-2`,children:[A,j]}),t[45]=A,t[46]=j,t[47]=M):M=t[47],t[48]!==k||t[49]!==M?(m=(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[k,M]}),t[48]=k,t[49]=M,t[50]=m):m=t[50],t[51]===n.description?h=t[52]:(h=(0,W.jsx)(`p`,{className:`mt-4 line-clamp-2 text-sm leading-6 text-fg-muted`,title:n.description,children:n.description}),t[51]=n.description,t[52]=h),g=e.length>0?(0,W.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-1.5`,children:[e.map(J),c>0?(0,W.jsxs)(`span`,{className:`rounded-md bg-surface-base px-2 py-0.5 text-[11px] text-fg-subtle`,children:[`+`,c]}):null]}):null,t[3]=l,t[4]=n,t[5]=r,t[6]=a,t[7]=o,t[8]=s.install,t[9]=s.installedBadge,t[10]=u,t[11]=f,t[12]=p,t[13]=m,t[14]=h,t[15]=g,t[16]=v,t[17]=y,t[18]=x,t[19]=S}else u=t[10],f=t[11],p=t[12],m=t[13],h=t[14],g=t[15],v=t[16],y=t[17],x=t[18],S=t[19];let C;t[53]!==p||t[54]!==m||t[55]!==h||t[56]!==g?(C=(0,W.jsxs)(`div`,{className:p,children:[m,h,g]}),t[53]=p,t[54]=m,t[55]=h,t[56]=g,t[57]=C):C=t[57];let w;t[58]!==r||t[59]!==u?(w=r?null:(0,W.jsx)(`div`,{className:`mt-4 flex flex-col gap-2 border-t border-edge pt-3 sm:hidden`,children:u(`w-full`)}),t[58]=r,t[59]=u,t[60]=w):w=t[60];let T;return t[61]!==f||t[62]!==C||t[63]!==w||t[64]!==v||t[65]!==y||t[66]!==x||t[67]!==S?(T=(0,W.jsxs)(`div`,{className:v,role:y,tabIndex:x,onClick:S,onKeyDown:f,children:[C,w]}),t[61]=f,t[62]=C,t[63]=w,t[64]=v,t[65]=y,t[66]=x,t[67]=S,t[68]=T):T=t[68],T}function J(e){return(0,W.jsx)(`span`,{className:`rounded-md bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:e},e)}function Y(e,t){if(!e.payload)throw Error(e.error??t);return e.payload}async function De(){return Y(await s(c(`/api/connectors/catalog`)),`Could not load connector catalog.`).connectors}async function Oe(e){let t=new URLSearchParams;return e?.q?.trim()&&t.set(`q`,e.q.trim()),e?.page&&t.set(`page`,String(e.page)),e?.pageSize&&t.set(`pageSize`,String(e.pageSize)),e?.category?.trim()&&t.set(`category`,e.category.trim()),e?.sort&&t.set(`sort`,e.sort),Y(await s(c(`/api/capabilities/connectors${t.size?`?${t.toString()}`:``}`)),`Could not load Store connector capabilities.`)}async function ke(e,t){return Y(await s(c(`/api/capabilities/connectors/${encodeURIComponent(e)}/install-plan`),{method:`POST`,body:JSON.stringify({version:t})}),`Could not prepare connector installation.`).plan}async function Ae(e,t,n){let r=await s(c(`/api/capabilities/connectors/${encodeURIComponent(e)}/install`),{method:`POST`,body:JSON.stringify({...t,version:n})});return V(),Y(r,`Could not install Store connector.`).instance}async function je(){return Y(await s(c(`/api/connectors/catalog`)),`Could not load connector registries.`).registries??[]}async function Me(){return Y(await s(c(`/api/connectors/installed`)),`Could not load installed connectors.`).instances}var Ne=new Map,Pe=300*1e3;async function Fe(e,t=`all`,n){let r=e.trim(),i=t.trim()||`all`,a=n?.browse??!1,o=Math.max(n?.page??1,1),l=Math.max(n?.pageSize??24,1),u=`${i}:${r}:${a?`browse`:`search`}:${o}:${l}`,d=Date.now(),f=Ne.get(u);if(f&&f.expiresAt>d)return f.promise;let p=new URLSearchParams;r&&p.set(`q`,r),i!==`all`&&p.set(`source`,i),a&&p.set(`browse`,`1`),p.set(`page`,String(o)),p.set(`pageSize`,String(l));let m=s(c(`/api/connectors/registry/search?${p.toString()}`)).then(e=>{let t=Y(e,`Could not search connector registries.`),n=Math.max(0,...(t.results??[]).map(e=>e.totalPages??0))||void 0;return{connectors:t.connectors,totalPages:n}});Ne.set(u,{expiresAt:d+Pe,promise:m});try{return await m}catch(e){throw Ne.delete(u),e}}async function Ie(e){return Y(await s(c(`/api/connectors/${encodeURIComponent(e)}/oauth/start`),{method:`POST`}),`Could not start connector OAuth.`).oauth}async function Le(e,t){return Y(await s(c(`/api/connectors/${encodeURIComponent(e)}/oauth/complete`),{method:`POST`,body:JSON.stringify({deviceCode:t})}),`Could not complete connector OAuth.`).oauth}async function Re(e,t){let n=await s(c(`/api/connectors/${encodeURIComponent(e)}/install`),{method:`POST`,body:JSON.stringify(t)});return V(),Y(n,`Could not install connector.`).instance}async function ze(e,t={}){return Y(await s(c(`/api/connectors/preview`),{method:`POST`,body:JSON.stringify({...t,definition:e})}),`Could not preview connector capabilities.`).preview}async function Be(e,t){return Y(await s(c(`/api/connectors/${encodeURIComponent(e)}/config`),{method:`POST`,body:JSON.stringify(t)}),`Could not update connector config.`).instance}async function Ve(e){await s(c(`/api/connectors/${encodeURIComponent(e)}`),{method:`DELETE`}),V()}async function He(e){return Y(await s(c(`/api/connectors/${encodeURIComponent(e)}/test`),{method:`POST`}),`Connector test failed.`)}async function Ue(){return Y(await s(c(`/api/connectors/composio/connections`)),`Could not load Composio connections.`).connections}async function We(e){return Y(await s(c(`/api/connectors/composio/${encodeURIComponent(e)}/authorize`),{method:`POST`}),`Could not start Composio authorization.`).oauth}async function Ge(e){return Y(await s(c(`/api/connectors/composio/${encodeURIComponent(e)}/scope`)),`Could not load Composio scope.`).scope}async function Ke(e,t){let n=await s(c(`/api/connectors/composio/${encodeURIComponent(e)}/scope`),{method:`POST`,body:JSON.stringify({scope:t})});return V(),Y(n,`Could not update Composio scope.`).scope}async function qe(e){return Y(await s(c(`/api/connectors/composio/${encodeURIComponent(e)}/tools`)),`Could not load Composio tools.`).tools}async function Je(e=50){return Y(await s(c(`/api/connectors/composio/triggers?limit=${encodeURIComponent(String(e))}`)),`Could not load Composio trigger events.`).events}function X(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,String(n)),e)}function Ye(e,t){return t.connectorCapabilityLabels[e]??e}function Xe(e,t){if(e.runtime.type===`mcp`)return X(t.connectorRuntimeMcp,{serverId:e.runtime.serverId});let n=e.runtime.id??e.runtime.channelId??e.runtime.toolkit??e.runtime.toolsetId??e.runtime.sourceKind??e.runtime.type;return X(t.connectorRuntimeGeneric,{runtime:e.runtime.type,id:n})}function Ze(e,t){return e.auth.mode===`oauth`?t.connectorAuthOAuth:e.auth.mode===`apiKey`?t.connectorAuthApiKey:t.connectorAuthNone}function Qe(e){return(e.setup.secrets??[]).filter(e=>e.required).length+(e.setup.config??[]).filter(e=>e.required).length}function $e(e){let t=(0,U.c)(12),{title:n,items:r}=e;if(r.length===0)return null;let i;t[0]===n?i=t[1]:(i=(0,W.jsx)(`div`,{className:`border-b border-edge px-3 py-2 text-xs font-semibold text-fg`,children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=r.slice(0,16).map(et),t[2]=r,t[3]=a);let o;t[4]===r.length?o=t[5]:(o=r.length>16?(0,W.jsxs)(`div`,{className:`px-3 py-2 text-xs text-fg-subtle`,children:[`+`,r.length-16]}):null,t[4]=r.length,t[5]=o);let s;t[6]!==a||t[7]!==o?(s=(0,W.jsxs)(`div`,{className:`max-h-48 overflow-y-auto`,children:[a,o]}),t[6]=a,t[7]=o,t[8]=s):s=t[8];let c;return t[9]!==i||t[10]!==s?(c=(0,W.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base`,children:[i,s]}),t[9]=i,t[10]=s,t[11]=c):c=t[11],c}function et(e){return(0,W.jsxs)(`div`,{className:`border-b border-edge-subtle px-3 py-2 last:border-b-0`,children:[(0,W.jsx)(`div`,{className:`break-words font-mono text-xs font-medium text-fg`,children:e.title}),e.description?(0,W.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:e.description}):null]},e.id)}function tt({connector:e,installed:t,onClose:n,onInstall:r,t:a}){let[o,s]=(0,H.useState)(!1),[c,l]=(0,H.useState)(null),[u,f]=(0,H.useState)(null),h=Qe(e),g=e.capabilities.slice(0,8),y=Math.max(0,e.capabilities.length-g.length),C=[...(e.setup.secrets??[]).map(e=>({key:`secret:${e.key}`,label:e.label,description:e.description,required:e.required,kind:a.connectorSetupSecret})),...(e.setup.config??[]).map(e=>({key:`config:${e.key}`,label:e.label,description:e.description,required:!!e.required,kind:a.connectorSetupConfig}))],E=async()=>{s(!0),f(null);try{l(await ze(e))}catch(e){l(null),f(e instanceof Error?e.message:String(e))}finally{s(!1)}};return(0,W.jsx)(x,{open:!0,onOpenChange:e=>{e||n()},children:(0,W.jsxs)(N,{children:[(0,W.jsx)(A,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,W.jsxs)(j,{className:i(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(100vh-2rem,44rem)] w-[min(100%-2rem,min(92vw,52rem))] -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,W.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-base px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:e.source}),(0,W.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-base px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:e.kind}),t?(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md 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,W.jsx)(d,{className:`size-3`,"aria-hidden":!0}),a.installedBadge]}):null]}),(0,W.jsx)(w,{className:`text-base font-semibold text-fg`,children:e.displayName}),(0,W.jsx)(S,{className:`mt-1 line-clamp-3 text-sm leading-6 text-fg-muted`,children:e.description})]}),(0,W.jsx)(m,{asChild:!0,children:(0,W.jsxs)(`button`,{type:`button`,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,R.focusRingPanel),"aria-label":a.modalClose,children:[(0,W.jsx)(oe,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,W.jsx)(`span`,{className:`sr-only`,children:a.modalClose})]})})]}),(0,W.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:[(0,W.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,W.jsx)(p,{className:`size-3.5`,"aria-hidden":!0}),a.detailTools]}),(0,W.jsx)(`p`,{className:`mt-2 text-sm font-semibold text-fg`,children:c?X(a.connectorPreviewToolsCount,{count:c.toolCount}):a.connectorPreviewUnknown})]}),(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,W.jsx)(I,{className:`size-3.5`,"aria-hidden":!0}),a.detailPermissions]}),(0,W.jsx)(`p`,{className:`mt-2 text-sm font-semibold text-fg`,children:Ze(e,a)})]}),(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,W.jsx)(D,{className:`size-3.5`,"aria-hidden":!0}),a.connectorRequiredInputs]}),(0,W.jsx)(`p`,{className:`mt-2 text-sm font-semibold text-fg`,children:X(a.connectorRequiredInputsCount,{count:h})})]})]}),(0,W.jsxs)(`div`,{className:`mt-5 grid gap-5 lg:grid-cols-[minmax(0,1fr)_18rem]`,children:[(0,W.jsxs)(`div`,{className:`min-w-0 space-y-5`,children:[(0,W.jsxs)(`section`,{children:[(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.connectorCapabilitiesTitle}),(0,W.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:[g.map(e=>(0,W.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-base px-2 py-1 text-xs text-fg-muted`,children:Ye(e,a)},e)),y>0?(0,W.jsxs)(`span`,{className:`rounded-md border border-edge bg-surface-base px-2 py-1 text-xs text-fg-subtle`,children:[`+`,y]}):null]}),(0,W.jsx)(`p`,{className:`mt-3 text-sm leading-6 text-fg-muted`,children:a.connectorCapabilitiesHint})]}),u?(0,W.jsx)(`p`,{className:`rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:u}):null,c?(0,W.jsxs)(`section`,{children:[(0,W.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.connectorPreviewTitle}),(0,W.jsx)(`span`,{className:i(`rounded-full px-2 py-0.5 text-xs font-medium`,c.ok?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-amber-500/10 text-amber-700 dark:text-amber-300`),children:c.ok?a.healthStatusHealthy:a.healthStatusLabels[c.status]??c.status})]}),(0,W.jsxs)(`div`,{className:`mb-3 grid gap-2 text-xs sm:grid-cols-3`,children:[(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base px-3 py-2`,children:[(0,W.jsx)(`div`,{className:`font-semibold text-fg`,children:c.toolCount}),(0,W.jsx)(`div`,{className:`text-fg-muted`,children:a.toolsMetric})]}),(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base px-3 py-2`,children:[(0,W.jsx)(`div`,{className:`font-semibold text-fg`,children:c.resourceCount}),(0,W.jsx)(`div`,{className:`text-fg-muted`,children:a.resourcesMetric})]}),(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base px-3 py-2`,children:[(0,W.jsx)(`div`,{className:`font-semibold text-fg`,children:c.promptCount}),(0,W.jsx)(`div`,{className:`text-fg-muted`,children:a.promptsMetric})]})]}),(0,W.jsxs)(`div`,{className:`grid gap-2`,children:[(0,W.jsx)($e,{title:a.detailTools,items:c.tools.map(e=>({id:e.name,title:e.shortName??e.name,description:e.description}))}),(0,W.jsx)($e,{title:a.detailResources,items:c.resources.map(e=>({id:e.uri,title:e.title??e.name??e.uri,description:e.description??e.uri}))}),(0,W.jsx)($e,{title:a.detailPrompts,items:c.prompts.map(e=>({id:e.name,title:e.title??e.name,description:e.description??X(a.promptArgumentCount,{count:e.argumentCount})}))})]}),c.error?(0,W.jsx)(`p`,{className:`mt-3 text-xs leading-5 text-fg-subtle`,children:c.error}):null,c.action?(0,W.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-subtle`,children:c.action}):null]}):null]}),(0,W.jsxs)(`aside`,{className:`space-y-3`,children:[(0,W.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,W.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,W.jsx)(I,{className:`size-4 text-accent`,"aria-hidden":!0}),a.detailPermissions]}),(0,W.jsx)(`p`,{className:`mt-2 text-sm font-medium text-fg`,children:Ze(e,a)})]}),(0,W.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,W.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,W.jsx)(D,{className:`size-4 text-accent`,"aria-hidden":!0}),a.connectorSetupTitle]}),C.length>0?(0,W.jsx)(`div`,{className:`mt-3 divide-y divide-edge overflow-hidden rounded-lg border border-edge`,children:C.map(e=>(0,W.jsxs)(`div`,{className:`bg-surface-panel px-3 py-2.5`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.label}),(0,W.jsx)(`span`,{className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[11px] text-fg-muted`,children:e.kind}),e.required?(0,W.jsx)(`span`,{className:`rounded-md bg-amber-500/10 px-1.5 py-0.5 text-[11px] font-medium text-amber-700 dark:text-amber-300`,children:a.connectorSetupRequired}):null]}),e.description?(0,W.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:e.description}):null]},e.key))}):(0,W.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:a.connectorSetupNone})]}),(0,W.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,W.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,W.jsx)(z,{className:`size-4 text-accent`,"aria-hidden":!0}),a.connectorRuntimeTitle]}),(0,W.jsx)(`p`,{className:`mt-2 break-words text-xs leading-5 text-fg-muted`,children:Xe(e,a)})]})]})]})]}),(0,W.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[(0,W.jsx)(m,{asChild:!0,children:(0,W.jsx)(_,{variant:`secondary`,children:a.modalClose})}),(0,W.jsxs)(_,{variant:`secondary`,disabled:o,onClick:()=>void E(),children:[o?(0,W.jsx)(T,{className:`size-4 animate-spin`}):(0,W.jsx)(p,{className:`size-4`}),a.connectorPreviewButton]}),t?(0,W.jsxs)(_,{variant:`secondary`,disabled:!0,children:[(0,W.jsx)(v,{className:`size-4`}),a.installedBadge]}):(0,W.jsxs)(_,{variant:`primary`,onClick:()=>{r(e),n()},children:[(0,W.jsx)(b,{className:`size-4`}),a.install]})]})]})]})})}var nt=(0,H.memo)(function(e){let t=(0,U.c)(19),{loading:n,searchQuery:r,setSearchQuery:i,onReloadClick:a,onAddCustomServer:o,searchPlaceholder:s,addLabel:c,reloadLabel:l}=e,u;t[0]!==n||t[1]!==a||t[2]!==l?(u=(0,W.jsx)(_e,{className:`size-9 shrink-0 p-0`,loading:n,label:l,title:l,onClick:a}),t[0]=n,t[1]=a,t[2]=l,t[3]=u):u=t[3];let d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,W.jsx)(he,{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[4]=d):d=t[4];let f;t[5]===i?f=t[6]:(f=e=>i(e.currentTarget.value),t[5]=i,t[6]=f);let p;t[7]!==s||t[8]!==r||t[9]!==f?(p=(0,W.jsxs)(`label`,{className:`relative flex min-h-9 min-w-0 max-w-sm cursor-text items-center rounded-pill border border-edge bg-surface-panel py-1.5 pl-9 pr-3 shadow-surface dark:bg-surface-hover/40 sm:max-w-md`,children:[d,(0,W.jsx)(`input`,{type:`search`,enterKeyHint:`search`,value:r,onChange:f,placeholder:s,autoComplete:`off`,spellCheck:!1,className:`min-w-0 flex-1 appearance-none border-0 bg-transparent py-0.5 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[7]=s,t[8]=r,t[9]=f,t[10]=p):p=t[10];let m;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,W.jsx)(h,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[11]=m):m=t[11];let g;t[12]!==c||t[13]!==o?(g=(0,W.jsxs)(_,{type:`button`,variant:`primary`,className:`shrink-0 gap-2`,onClick:o,children:[m,c]}),t[12]=c,t[13]=o,t[14]=g):g=t[14];let v;return t[15]!==u||t[16]!==p||t[17]!==g?(v=(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center justify-end gap-2`,children:[u,p,g]}),t[15]=u,t[16]=p,t[17]=g,t[18]=v):v=t[18],v}),rt=/^([^:=]+)[:=](.*)$/;function it(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=rt.exec(t);r&&n.push({key:r[1].trim(),value:r[2].trim()})}return n.length>0?n:null}function at(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 ot(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 st(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 ct(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)||st(t)&&(r[e]=t);return r}function lt(e){let t=e.trim();if(t)return t.split(/\s+/).filter(Boolean)}function ut(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 dt(e){if(e.transport===`stdio`){let t={command:e.command.trim()},n=lt(e.argsText);return n?.length&&(t.args=n),e.cwd.trim()&&(t.cwd=e.cwd.trim()),e.envJson.trim()&&(t.env=ut(e.envJson)),e.connectionTimeoutMs!=null&&Number.isFinite(e.connectionTimeoutMs)&&(t.connectionTimeoutMs=e.connectionTimeoutMs),t}let t={url:e.url.trim(),transport:e.transport},n=at(e.headers);return n&&(t.headers=n),e.connectionTimeoutMs!=null&&Number.isFinite(e.connectionTimeoutMs)&&(t.connectionTimeoutMs=e.connectionTimeoutMs),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;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:ot(a),connectionTimeoutMs:typeof t.connectionTimeoutMs==`number`&&Number.isFinite(t.connectionTimeoutMs)?t.connectionTimeoutMs:void 0}}function pt(e=``){return{clientKey:crypto.randomUUID(),id:e,transport:`stdio`,command:``,argsText:``,envJson:``,cwd:``,url:``,headers:[{key:`Authorization`,value:``}],connectionTimeoutMs:void 0}}function mt(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)||st(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 ht(e){return dt(e)}async function gt(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]=dt(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 s(c(`/api/config`),{method:`PATCH`,body:JSON.stringify({mcp:r})}),V()}function _t(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(typeof n==`string`){let e=n.trim();e&&t.push({name:e});continue}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 vt(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 yt(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 bt(e,t){let n=await s(c(`/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=_t(n.payload.tools),i=vt(n.payload.resources),a=yt(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 xt(e){return e.connectionTimeoutMs==null||!Number.isFinite(e.connectionTimeoutMs)?``:String(Math.round(e.connectionTimeoutMs/1e3))}function St(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 Ct(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 Z(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,n),e)}function wt({row:e,t,cs:n,onEdit:r,onRemove:i}){let[a,o]=(0,H.useState)(!1),[s,c]=(0,H.useState)(!1),[l,u]=(0,H.useState)(null),[d,f]=(0,H.useState)(null),p=Ct(e),m=(0,H.useCallback)(async()=>{o(!0),f(null);try{let t=await bt(e.id.trim());u({toolCount:t.toolCount,resourceCount:t.resourceCount,promptCount:t.promptCount})}catch(e){f(e instanceof Error?e.message:String(e))}finally{o(!1)}},[e.id]),h=(0,H.useCallback)(async()=>{c(!0),f(null);try{await i()}catch(e){f(e instanceof Error?e.message:String(e)),c(!1)}},[i]);return(0,W.jsxs)(`div`,{className:`flex h-full min-h-[10.5rem] cursor-pointer flex-col rounded-lg bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45`,onClick:r,children:[(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:e.id.trim()||t.cardUntitled}),(0,W.jsx)(`span`,{className:`rounded-full bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:n.customBadge}),(0,W.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]})]}),p?(0,W.jsx)(`p`,{className:`mt-3 line-clamp-2 break-all font-mono text-xs leading-5 text-fg-subtle`,title:p,children:p}):null,d?(0,W.jsx)(`p`,{className:`mt-3 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:d}):null,l?(0,W.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:Z(n.customCapabilitySummary,{tools:String(l.toolCount),resources:String(l.resourceCount),prompts:String(l.promptCount)})}):null]}),(0,W.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-2 border-t border-edge pt-3`,onClick:e=>e.stopPropagation(),children:[(0,W.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:n.connectorDetails}),(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsxs)(_,{variant:`secondary`,disabled:a,onClick:()=>void m(),children:[a?(0,W.jsx)(T,{className:`size-4 animate-spin`}):(0,W.jsx)(v,{className:`size-4`}),t.testConnection]}),(0,W.jsxs)(_,{variant:`ghost`,disabled:s,onClick:()=>void h(),children:[s?(0,W.jsx)(T,{className:`size-4 animate-spin`}):(0,W.jsx)(M,{className:`size-4`}),t.removeServer]})]})]})]})}function Tt(e,t){return e?t&&e.startsWith(t)?e.slice(t.length):e:``}function Et(e,t,n){let r=t.trim().toLowerCase();if(!r)return!0;let i=e.shortName||Tt(e.name,n);return[e.name,i,e.description].filter(Boolean).join(`
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-DbNQuFdA.js";import{a as o,n as s,o as c}from"./fetch-BID89uCH.js";import{n as l}from"./locale-store-Ba72bFmP.js";import{r as u}from"./toast-z0toXu32.js";import{$c as d,$r as f,Ao as p,Ba as m,Cs as h,Ec as g,Eo as _,Es as v,Fr as y,Fs as b,Ga as x,Ha as S,Ir as C,Ka as w,Ks as T,Lr as E,Pc as D,Pr as O,To as k,Ua as A,Va as j,Vo as M,Wa as N,Wc as P,_o as F,ac as I,ao as L,bc as ee,bo as R,cs as z,ei as B,ga as te,ha as V,ho as ne,il as re,is as ie,kl as ae,ko as oe,ni as se,oo as ce,ps as le,qa as ue,ri as de,ro as fe,ti as pe,to as me,us as he,ws as ge,yi as _e,zr as ve}from"./index-NwiCnzI-.js";import{n as ye,t as be}from"./settings-form-section-DoVPlVFd.js";import{t as xe}from"./page-tabs-CROo8Vgz.js";var H=e(t(),1),U=n(),W=r(),G=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`,Se=[`c0`,`c1`,`c2`,`c3`,`c4`,`c5`];function Ce(e,t){return t.some(t=>t.connectorId===e.id)}function K(e,t){return t[e]??e}function q(e,t){return t.connectorCategoryTemplate.replace(`{{category}}`,K(e,t.connectorCategoryLabels))}function we(){let e=(0,U.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,W.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,W.jsx)(`div`,{className:`flex min-h-0 flex-1 items-start gap-3`,children:(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,W.jsx)(`div`,{className:i(`h-4 min-w-0 flex-1`,G)}),(0,W.jsx)(`div`,{className:i(`h-8 w-[4.5rem] shrink-0 rounded-lg`,G)})]}),(0,W.jsx)(`div`,{className:i(`h-3 w-full`,G)}),(0,W.jsx)(`div`,{className:i(`h-3 w-[88%]`,G)})]})})}),e[0]=t):t=e[0],t}function Te(){let e=(0,U.c)(3),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,W.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2`,children:[(0,W.jsx)(`div`,{className:i(`h-4 w-48 max-w-full`,G)}),(0,W.jsx)(`div`,{className:i(`h-3 w-72 max-w-full`,G)})]}),e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,W.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[t,(0,W.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,W.jsx)(`div`,{className:i(`h-9 w-20 rounded-lg`,G)}),(0,W.jsx)(`div`,{className:i(`h-9 w-20 rounded-lg`,G)})]})]}),e[1]=n):n=e[1];let r;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,W.jsxs)(`div`,{className:`rounded-2xl bg-surface-panel p-4 shadow-surface`,"aria-hidden":!0,children:[n,(0,W.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,W.jsx)(`div`,{className:i(`h-8 w-20 rounded-md`,G)}),(0,W.jsx)(`div`,{className:i(`h-8 w-24 rounded-md`,G)}),(0,W.jsx)(`div`,{className:i(`h-8 w-28 rounded-md`,G)})]}),(0,W.jsx)(`div`,{className:i(`mt-3 h-20 rounded-xl`,G)})]}),e[2]=r):r=e[2],r}function Ee(e){let t=(0,U.c)(69),{connector:n,installed:r,onInstall:a,onOpenDetails:o,t:s}=e,c;t[0]!==n.category||t[1]!==s?(c=q(n.category,s),t[0]=n.category,t[1]=s,t[2]=c):c=t[2];let l=c,u,f,p,m,h,g,v,y,x,S;if(t[3]!==l||t[4]!==n||t[5]!==r||t[6]!==a||t[7]!==o||t[8]!==s.install||t[9]!==s.installedBadge){let e=n.capabilities.slice(0,4),c=Math.max(0,n.capabilities.length-e.length),C;t[20]!==n||t[21]!==a||t[22]!==s.install?(C=e=>(0,W.jsxs)(_,{type:`button`,variant:`primary`,className:i(`h-8 justify-center px-2.5 text-xs font-medium`,e),onClick:e=>{e.stopPropagation(),a(n)},children:[(0,W.jsx)(b,{className:`size-4`}),s.install]}),t[20]=n,t[21]=a,t[22]=s.install,t[23]=C):C=t[23],u=C;let w;t[24]!==n||t[25]!==o?(w=e=>{!o||e.currentTarget!==e.target||e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),o(n))},t[24]=n,t[25]=o,t[26]=w):w=t[26];let T=w,E=o?`cursor-pointer`:null;t[27]===E?v=t[28]:(v=i(`group flex min-h-[9.5rem] flex-col rounded-lg bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45 focus-within:ring-2 focus-within:ring-accent/30`,E),t[27]=E,t[28]=v),y=o?`button`:void 0,x=o?0:void 0,t[29]!==n||t[30]!==o?(S=()=>o?.(n),t[29]=n,t[30]=o,t[31]=S):S=t[31],f=T,p=`flex min-w-0 flex-1 flex-col`;let D;t[32]===n.displayName?D=t[33]:(D=(0,W.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:n.displayName}),t[32]=n.displayName,t[33]=D);let O;t[34]===l?O=t[35]:(O=(0,W.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-subtle`,children:l}),t[34]=l,t[35]=O);let k;t[36]!==D||t[37]!==O?(k=(0,W.jsx)(`div`,{className:`flex min-w-0 items-start gap-3`,children:(0,W.jsxs)(`div`,{className:`min-w-0`,children:[D,O]})}),t[36]=D,t[37]=O,t[38]=k):k=t[38];let A;t[39]!==r||t[40]!==u?(A=r?null:(0,W.jsx)(`div`,{className:`hidden shrink-0 items-center gap-1 transition-opacity sm:pointer-events-none sm:flex sm:opacity-0 sm:group-hover:pointer-events-auto sm:group-hover:opacity-100 sm:group-focus-within:pointer-events-auto sm:group-focus-within:opacity-100`,children:u()}),t[39]=r,t[40]=u,t[41]=A):A=t[41];let j;t[42]!==r||t[43]!==s.installedBadge?(j=r?(0,W.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,W.jsx)(d,{className:`size-3`,"aria-hidden":!0}),s.installedBadge]}):null,t[42]=r,t[43]=s.installedBadge,t[44]=j):j=t[44];let M;t[45]!==A||t[46]!==j?(M=(0,W.jsxs)(`div`,{className:`flex shrink-0 items-start gap-2`,children:[A,j]}),t[45]=A,t[46]=j,t[47]=M):M=t[47],t[48]!==k||t[49]!==M?(m=(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[k,M]}),t[48]=k,t[49]=M,t[50]=m):m=t[50],t[51]===n.description?h=t[52]:(h=(0,W.jsx)(`p`,{className:`mt-4 line-clamp-2 text-sm leading-6 text-fg-muted`,title:n.description,children:n.description}),t[51]=n.description,t[52]=h),g=e.length>0?(0,W.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-1.5`,children:[e.map(J),c>0?(0,W.jsxs)(`span`,{className:`rounded-md bg-surface-base px-2 py-0.5 text-[11px] text-fg-subtle`,children:[`+`,c]}):null]}):null,t[3]=l,t[4]=n,t[5]=r,t[6]=a,t[7]=o,t[8]=s.install,t[9]=s.installedBadge,t[10]=u,t[11]=f,t[12]=p,t[13]=m,t[14]=h,t[15]=g,t[16]=v,t[17]=y,t[18]=x,t[19]=S}else u=t[10],f=t[11],p=t[12],m=t[13],h=t[14],g=t[15],v=t[16],y=t[17],x=t[18],S=t[19];let C;t[53]!==p||t[54]!==m||t[55]!==h||t[56]!==g?(C=(0,W.jsxs)(`div`,{className:p,children:[m,h,g]}),t[53]=p,t[54]=m,t[55]=h,t[56]=g,t[57]=C):C=t[57];let w;t[58]!==r||t[59]!==u?(w=r?null:(0,W.jsx)(`div`,{className:`mt-4 flex flex-col gap-2 border-t border-edge pt-3 sm:hidden`,children:u(`w-full`)}),t[58]=r,t[59]=u,t[60]=w):w=t[60];let T;return t[61]!==f||t[62]!==C||t[63]!==w||t[64]!==v||t[65]!==y||t[66]!==x||t[67]!==S?(T=(0,W.jsxs)(`div`,{className:v,role:y,tabIndex:x,onClick:S,onKeyDown:f,children:[C,w]}),t[61]=f,t[62]=C,t[63]=w,t[64]=v,t[65]=y,t[66]=x,t[67]=S,t[68]=T):T=t[68],T}function J(e){return(0,W.jsx)(`span`,{className:`rounded-md bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:e},e)}function Y(e,t){if(!e.payload)throw Error(e.error??t);return e.payload}async function De(){return Y(await s(c(`/api/connectors/catalog`)),`Could not load connector catalog.`).connectors}async function Oe(e){let t=new URLSearchParams;return e?.q?.trim()&&t.set(`q`,e.q.trim()),e?.page&&t.set(`page`,String(e.page)),e?.pageSize&&t.set(`pageSize`,String(e.pageSize)),e?.category?.trim()&&t.set(`category`,e.category.trim()),e?.sort&&t.set(`sort`,e.sort),Y(await s(c(`/api/capabilities/connectors${t.size?`?${t.toString()}`:``}`)),`Could not load Store connector capabilities.`)}async function ke(e,t){return Y(await s(c(`/api/capabilities/connectors/${encodeURIComponent(e)}/install-plan`),{method:`POST`,body:JSON.stringify({version:t})}),`Could not prepare connector installation.`).plan}async function Ae(e,t,n){let r=await s(c(`/api/capabilities/connectors/${encodeURIComponent(e)}/install`),{method:`POST`,body:JSON.stringify({...t,version:n})});return V(),Y(r,`Could not install Store connector.`).instance}async function je(){return Y(await s(c(`/api/connectors/catalog`)),`Could not load connector registries.`).registries??[]}async function Me(){return Y(await s(c(`/api/connectors/installed`)),`Could not load installed connectors.`).instances}var Ne=new Map,Pe=300*1e3;async function Fe(e,t=`all`,n){let r=e.trim(),i=t.trim()||`all`,a=n?.browse??!1,o=Math.max(n?.page??1,1),l=Math.max(n?.pageSize??24,1),u=`${i}:${r}:${a?`browse`:`search`}:${o}:${l}`,d=Date.now(),f=Ne.get(u);if(f&&f.expiresAt>d)return f.promise;let p=new URLSearchParams;r&&p.set(`q`,r),i!==`all`&&p.set(`source`,i),a&&p.set(`browse`,`1`),p.set(`page`,String(o)),p.set(`pageSize`,String(l));let m=s(c(`/api/connectors/registry/search?${p.toString()}`)).then(e=>{let t=Y(e,`Could not search connector registries.`),n=Math.max(0,...(t.results??[]).map(e=>e.totalPages??0))||void 0;return{connectors:t.connectors,totalPages:n}});Ne.set(u,{expiresAt:d+Pe,promise:m});try{return await m}catch(e){throw Ne.delete(u),e}}async function Ie(e){return Y(await s(c(`/api/connectors/${encodeURIComponent(e)}/oauth/start`),{method:`POST`}),`Could not start connector OAuth.`).oauth}async function Le(e,t){return Y(await s(c(`/api/connectors/${encodeURIComponent(e)}/oauth/complete`),{method:`POST`,body:JSON.stringify({deviceCode:t})}),`Could not complete connector OAuth.`).oauth}async function Re(e,t){let n=await s(c(`/api/connectors/${encodeURIComponent(e)}/install`),{method:`POST`,body:JSON.stringify(t)});return V(),Y(n,`Could not install connector.`).instance}async function ze(e,t={}){return Y(await s(c(`/api/connectors/preview`),{method:`POST`,body:JSON.stringify({...t,definition:e})}),`Could not preview connector capabilities.`).preview}async function Be(e,t){return Y(await s(c(`/api/connectors/${encodeURIComponent(e)}/config`),{method:`POST`,body:JSON.stringify(t)}),`Could not update connector config.`).instance}async function Ve(e){await s(c(`/api/connectors/${encodeURIComponent(e)}`),{method:`DELETE`}),V()}async function He(e){return Y(await s(c(`/api/connectors/${encodeURIComponent(e)}/test`),{method:`POST`}),`Connector test failed.`)}async function Ue(){return Y(await s(c(`/api/connectors/composio/connections`)),`Could not load Composio connections.`).connections}async function We(e){return Y(await s(c(`/api/connectors/composio/${encodeURIComponent(e)}/authorize`),{method:`POST`}),`Could not start Composio authorization.`).oauth}async function Ge(e){return Y(await s(c(`/api/connectors/composio/${encodeURIComponent(e)}/scope`)),`Could not load Composio scope.`).scope}async function Ke(e,t){let n=await s(c(`/api/connectors/composio/${encodeURIComponent(e)}/scope`),{method:`POST`,body:JSON.stringify({scope:t})});return V(),Y(n,`Could not update Composio scope.`).scope}async function qe(e){return Y(await s(c(`/api/connectors/composio/${encodeURIComponent(e)}/tools`)),`Could not load Composio tools.`).tools}async function Je(e=50){return Y(await s(c(`/api/connectors/composio/triggers?limit=${encodeURIComponent(String(e))}`)),`Could not load Composio trigger events.`).events}function X(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,String(n)),e)}function Ye(e,t){return t.connectorCapabilityLabels[e]??e}function Xe(e,t){if(e.runtime.type===`mcp`)return X(t.connectorRuntimeMcp,{serverId:e.runtime.serverId});let n=e.runtime.id??e.runtime.channelId??e.runtime.toolkit??e.runtime.toolsetId??e.runtime.sourceKind??e.runtime.type;return X(t.connectorRuntimeGeneric,{runtime:e.runtime.type,id:n})}function Ze(e,t){return e.auth.mode===`oauth`?t.connectorAuthOAuth:e.auth.mode===`apiKey`?t.connectorAuthApiKey:t.connectorAuthNone}function Qe(e){return(e.setup.secrets??[]).filter(e=>e.required).length+(e.setup.config??[]).filter(e=>e.required).length}function $e(e){let t=(0,U.c)(12),{title:n,items:r}=e;if(r.length===0)return null;let i;t[0]===n?i=t[1]:(i=(0,W.jsx)(`div`,{className:`border-b border-edge px-3 py-2 text-xs font-semibold text-fg`,children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=r.slice(0,16).map(et),t[2]=r,t[3]=a);let o;t[4]===r.length?o=t[5]:(o=r.length>16?(0,W.jsxs)(`div`,{className:`px-3 py-2 text-xs text-fg-subtle`,children:[`+`,r.length-16]}):null,t[4]=r.length,t[5]=o);let s;t[6]!==a||t[7]!==o?(s=(0,W.jsxs)(`div`,{className:`max-h-48 overflow-y-auto`,children:[a,o]}),t[6]=a,t[7]=o,t[8]=s):s=t[8];let c;return t[9]!==i||t[10]!==s?(c=(0,W.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base`,children:[i,s]}),t[9]=i,t[10]=s,t[11]=c):c=t[11],c}function et(e){return(0,W.jsxs)(`div`,{className:`border-b border-edge-subtle px-3 py-2 last:border-b-0`,children:[(0,W.jsx)(`div`,{className:`break-words font-mono text-xs font-medium text-fg`,children:e.title}),e.description?(0,W.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:e.description}):null]},e.id)}function tt({connector:e,installed:t,onClose:n,onInstall:r,t:a}){let[o,s]=(0,H.useState)(!1),[c,l]=(0,H.useState)(null),[u,f]=(0,H.useState)(null),h=Qe(e),g=e.capabilities.slice(0,8),y=Math.max(0,e.capabilities.length-g.length),C=[...(e.setup.secrets??[]).map(e=>({key:`secret:${e.key}`,label:e.label,description:e.description,required:e.required,kind:a.connectorSetupSecret})),...(e.setup.config??[]).map(e=>({key:`config:${e.key}`,label:e.label,description:e.description,required:!!e.required,kind:a.connectorSetupConfig}))],E=async()=>{s(!0),f(null);try{l(await ze(e))}catch(e){l(null),f(e instanceof Error?e.message:String(e))}finally{s(!1)}};return(0,W.jsx)(x,{open:!0,onOpenChange:e=>{e||n()},children:(0,W.jsxs)(N,{children:[(0,W.jsx)(A,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,W.jsxs)(j,{className:i(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(100vh-2rem,44rem)] w-[min(100%-2rem,min(92vw,52rem))] -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,W.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-base px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:e.source}),(0,W.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-base px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:e.kind}),t?(0,W.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-md 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,W.jsx)(d,{className:`size-3`,"aria-hidden":!0}),a.installedBadge]}):null]}),(0,W.jsx)(w,{className:`text-base font-semibold text-fg`,children:e.displayName}),(0,W.jsx)(S,{className:`mt-1 line-clamp-3 text-sm leading-6 text-fg-muted`,children:e.description})]}),(0,W.jsx)(m,{asChild:!0,children:(0,W.jsxs)(`button`,{type:`button`,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,R.focusRingPanel),"aria-label":a.modalClose,children:[(0,W.jsx)(oe,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,W.jsx)(`span`,{className:`sr-only`,children:a.modalClose})]})})]}),(0,W.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:[(0,W.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,W.jsx)(p,{className:`size-3.5`,"aria-hidden":!0}),a.detailTools]}),(0,W.jsx)(`p`,{className:`mt-2 text-sm font-semibold text-fg`,children:c?X(a.connectorPreviewToolsCount,{count:c.toolCount}):a.connectorPreviewUnknown})]}),(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,W.jsx)(I,{className:`size-3.5`,"aria-hidden":!0}),a.detailPermissions]}),(0,W.jsx)(`p`,{className:`mt-2 text-sm font-semibold text-fg`,children:Ze(e,a)})]}),(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,W.jsx)(D,{className:`size-3.5`,"aria-hidden":!0}),a.connectorRequiredInputs]}),(0,W.jsx)(`p`,{className:`mt-2 text-sm font-semibold text-fg`,children:X(a.connectorRequiredInputsCount,{count:h})})]})]}),(0,W.jsxs)(`div`,{className:`mt-5 grid gap-5 lg:grid-cols-[minmax(0,1fr)_18rem]`,children:[(0,W.jsxs)(`div`,{className:`min-w-0 space-y-5`,children:[(0,W.jsxs)(`section`,{children:[(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.connectorCapabilitiesTitle}),(0,W.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:[g.map(e=>(0,W.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-base px-2 py-1 text-xs text-fg-muted`,children:Ye(e,a)},e)),y>0?(0,W.jsxs)(`span`,{className:`rounded-md border border-edge bg-surface-base px-2 py-1 text-xs text-fg-subtle`,children:[`+`,y]}):null]}),(0,W.jsx)(`p`,{className:`mt-3 text-sm leading-6 text-fg-muted`,children:a.connectorCapabilitiesHint})]}),u?(0,W.jsx)(`p`,{className:`rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:u}):null,c?(0,W.jsxs)(`section`,{children:[(0,W.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.connectorPreviewTitle}),(0,W.jsx)(`span`,{className:i(`rounded-full px-2 py-0.5 text-xs font-medium`,c.ok?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-amber-500/10 text-amber-700 dark:text-amber-300`),children:c.ok?a.healthStatusHealthy:a.healthStatusLabels[c.status]??c.status})]}),(0,W.jsxs)(`div`,{className:`mb-3 grid gap-2 text-xs sm:grid-cols-3`,children:[(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base px-3 py-2`,children:[(0,W.jsx)(`div`,{className:`font-semibold text-fg`,children:c.toolCount}),(0,W.jsx)(`div`,{className:`text-fg-muted`,children:a.toolsMetric})]}),(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base px-3 py-2`,children:[(0,W.jsx)(`div`,{className:`font-semibold text-fg`,children:c.resourceCount}),(0,W.jsx)(`div`,{className:`text-fg-muted`,children:a.resourcesMetric})]}),(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base px-3 py-2`,children:[(0,W.jsx)(`div`,{className:`font-semibold text-fg`,children:c.promptCount}),(0,W.jsx)(`div`,{className:`text-fg-muted`,children:a.promptsMetric})]})]}),(0,W.jsxs)(`div`,{className:`grid gap-2`,children:[(0,W.jsx)($e,{title:a.detailTools,items:c.tools.map(e=>({id:e.name,title:e.shortName??e.name,description:e.description}))}),(0,W.jsx)($e,{title:a.detailResources,items:c.resources.map(e=>({id:e.uri,title:e.title??e.name??e.uri,description:e.description??e.uri}))}),(0,W.jsx)($e,{title:a.detailPrompts,items:c.prompts.map(e=>({id:e.name,title:e.title??e.name,description:e.description??X(a.promptArgumentCount,{count:e.argumentCount})}))})]}),c.error?(0,W.jsx)(`p`,{className:`mt-3 text-xs leading-5 text-fg-subtle`,children:c.error}):null,c.action?(0,W.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-subtle`,children:c.action}):null]}):null]}),(0,W.jsxs)(`aside`,{className:`space-y-3`,children:[(0,W.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,W.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,W.jsx)(I,{className:`size-4 text-accent`,"aria-hidden":!0}),a.detailPermissions]}),(0,W.jsx)(`p`,{className:`mt-2 text-sm font-medium text-fg`,children:Ze(e,a)})]}),(0,W.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,W.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,W.jsx)(D,{className:`size-4 text-accent`,"aria-hidden":!0}),a.connectorSetupTitle]}),C.length>0?(0,W.jsx)(`div`,{className:`mt-3 divide-y divide-edge overflow-hidden rounded-lg border border-edge`,children:C.map(e=>(0,W.jsxs)(`div`,{className:`bg-surface-panel px-3 py-2.5`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.label}),(0,W.jsx)(`span`,{className:`rounded-md bg-surface-hover px-1.5 py-0.5 text-[11px] text-fg-muted`,children:e.kind}),e.required?(0,W.jsx)(`span`,{className:`rounded-md bg-amber-500/10 px-1.5 py-0.5 text-[11px] font-medium text-amber-700 dark:text-amber-300`,children:a.connectorSetupRequired}):null]}),e.description?(0,W.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:e.description}):null]},e.key))}):(0,W.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:a.connectorSetupNone})]}),(0,W.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,W.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,W.jsx)(z,{className:`size-4 text-accent`,"aria-hidden":!0}),a.connectorRuntimeTitle]}),(0,W.jsx)(`p`,{className:`mt-2 break-words text-xs leading-5 text-fg-muted`,children:Xe(e,a)})]})]})]})]}),(0,W.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[(0,W.jsx)(m,{asChild:!0,children:(0,W.jsx)(_,{variant:`secondary`,children:a.modalClose})}),(0,W.jsxs)(_,{variant:`secondary`,disabled:o,onClick:()=>void E(),children:[o?(0,W.jsx)(T,{className:`size-4 animate-spin`}):(0,W.jsx)(p,{className:`size-4`}),a.connectorPreviewButton]}),t?(0,W.jsxs)(_,{variant:`secondary`,disabled:!0,children:[(0,W.jsx)(v,{className:`size-4`}),a.installedBadge]}):(0,W.jsxs)(_,{variant:`primary`,onClick:()=>{r(e),n()},children:[(0,W.jsx)(b,{className:`size-4`}),a.install]})]})]})]})})}var nt=(0,H.memo)(function(e){let t=(0,U.c)(19),{loading:n,searchQuery:r,setSearchQuery:i,onReloadClick:a,onAddCustomServer:o,searchPlaceholder:s,addLabel:c,reloadLabel:l}=e,u;t[0]!==n||t[1]!==a||t[2]!==l?(u=(0,W.jsx)(_e,{className:`size-9 shrink-0 p-0`,loading:n,label:l,title:l,onClick:a}),t[0]=n,t[1]=a,t[2]=l,t[3]=u):u=t[3];let d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,W.jsx)(he,{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[4]=d):d=t[4];let f;t[5]===i?f=t[6]:(f=e=>i(e.currentTarget.value),t[5]=i,t[6]=f);let p;t[7]!==s||t[8]!==r||t[9]!==f?(p=(0,W.jsxs)(`label`,{className:`relative flex min-h-9 min-w-0 max-w-sm cursor-text items-center rounded-pill border border-edge bg-surface-panel py-1.5 pl-9 pr-3 shadow-surface dark:bg-surface-hover/40 sm:max-w-md`,children:[d,(0,W.jsx)(`input`,{type:`search`,enterKeyHint:`search`,value:r,onChange:f,placeholder:s,autoComplete:`off`,spellCheck:!1,className:`min-w-0 flex-1 appearance-none border-0 bg-transparent py-0.5 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[7]=s,t[8]=r,t[9]=f,t[10]=p):p=t[10];let m;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,W.jsx)(h,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[11]=m):m=t[11];let g;t[12]!==c||t[13]!==o?(g=(0,W.jsxs)(_,{type:`button`,variant:`primary`,className:`shrink-0 gap-2`,onClick:o,children:[m,c]}),t[12]=c,t[13]=o,t[14]=g):g=t[14];let v;return t[15]!==u||t[16]!==p||t[17]!==g?(v=(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center justify-end gap-2`,children:[u,p,g]}),t[15]=u,t[16]=p,t[17]=g,t[18]=v):v=t[18],v}),rt=/^([^:=]+)[:=](.*)$/;function it(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=rt.exec(t);r&&n.push({key:r[1].trim(),value:r[2].trim()})}return n.length>0?n:null}function at(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 ot(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 st(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 ct(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)||st(t)&&(r[e]=t);return r}function lt(e){let t=e.trim();if(t)return t.split(/\s+/).filter(Boolean)}function ut(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 dt(e){if(e.transport===`stdio`){let t={command:e.command.trim()},n=lt(e.argsText);return n?.length&&(t.args=n),e.cwd.trim()&&(t.cwd=e.cwd.trim()),e.envJson.trim()&&(t.env=ut(e.envJson)),e.connectionTimeoutMs!=null&&Number.isFinite(e.connectionTimeoutMs)&&(t.connectionTimeoutMs=e.connectionTimeoutMs),t}let t={url:e.url.trim(),transport:e.transport},n=at(e.headers);return n&&(t.headers=n),e.connectionTimeoutMs!=null&&Number.isFinite(e.connectionTimeoutMs)&&(t.connectionTimeoutMs=e.connectionTimeoutMs),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;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:ot(a),connectionTimeoutMs:typeof t.connectionTimeoutMs==`number`&&Number.isFinite(t.connectionTimeoutMs)?t.connectionTimeoutMs:void 0}}function pt(e=``){return{clientKey:crypto.randomUUID(),id:e,transport:`stdio`,command:``,argsText:``,envJson:``,cwd:``,url:``,headers:[{key:`Authorization`,value:``}],connectionTimeoutMs:void 0}}function mt(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)||st(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 ht(e){return dt(e)}async function gt(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]=dt(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 s(c(`/api/config`),{method:`PATCH`,body:JSON.stringify({mcp:r})}),V()}function _t(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(typeof n==`string`){let e=n.trim();e&&t.push({name:e});continue}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 vt(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 yt(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 bt(e,t){let n=await s(c(`/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=_t(n.payload.tools),i=vt(n.payload.resources),a=yt(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 xt(e){return e.connectionTimeoutMs==null||!Number.isFinite(e.connectionTimeoutMs)?``:String(Math.round(e.connectionTimeoutMs/1e3))}function St(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 Ct(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 Z(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,n),e)}function wt({row:e,t,cs:n,onEdit:r,onRemove:i}){let[a,o]=(0,H.useState)(!1),[s,c]=(0,H.useState)(!1),[l,u]=(0,H.useState)(null),[d,f]=(0,H.useState)(null),p=Ct(e),m=(0,H.useCallback)(async()=>{o(!0),f(null);try{let t=await bt(e.id.trim());u({toolCount:t.toolCount,resourceCount:t.resourceCount,promptCount:t.promptCount})}catch(e){f(e instanceof Error?e.message:String(e))}finally{o(!1)}},[e.id]),h=(0,H.useCallback)(async()=>{c(!0),f(null);try{await i()}catch(e){f(e instanceof Error?e.message:String(e)),c(!1)}},[i]);return(0,W.jsxs)(`div`,{className:`flex h-full min-h-[10.5rem] cursor-pointer flex-col rounded-lg bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45`,onClick:r,children:[(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:e.id.trim()||t.cardUntitled}),(0,W.jsx)(`span`,{className:`rounded-full bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:n.customBadge}),(0,W.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]})]}),p?(0,W.jsx)(`p`,{className:`mt-3 line-clamp-2 break-all font-mono text-xs leading-5 text-fg-subtle`,title:p,children:p}):null,d?(0,W.jsx)(`p`,{className:`mt-3 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:d}):null,l?(0,W.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:Z(n.customCapabilitySummary,{tools:String(l.toolCount),resources:String(l.resourceCount),prompts:String(l.promptCount)})}):null]}),(0,W.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-2 border-t border-edge pt-3`,onClick:e=>e.stopPropagation(),children:[(0,W.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:n.connectorDetails}),(0,W.jsxs)(`div`,{className:`flex gap-2`,children:[(0,W.jsxs)(_,{variant:`secondary`,disabled:a,onClick:()=>void m(),children:[a?(0,W.jsx)(T,{className:`size-4 animate-spin`}):(0,W.jsx)(v,{className:`size-4`}),t.testConnection]}),(0,W.jsxs)(_,{variant:`ghost`,disabled:s,onClick:()=>void h(),children:[s?(0,W.jsx)(T,{className:`size-4 animate-spin`}):(0,W.jsx)(M,{className:`size-4`}),t.removeServer]})]})]})]})}function Tt(e,t){return e?t&&e.startsWith(t)?e.slice(t.length):e:``}function Et(e,t,n){let r=t.trim().toLowerCase();if(!r)return!0;let i=e.shortName||Tt(e.name,n);return[e.name,i,e.description].filter(Boolean).join(`
2
2
  `).toLowerCase().includes(r)}function Dt(e,t){return e?t&&e.startsWith(t)?e.slice(t.length):e:``}function Ot(e){let t=(0,U.c)(29),{tools:n,stripPrefix:r,searchPlaceholder:a,searchEmptyLabel:o}=e,[s,c]=(0,H.useState)(``),l;if(t[0]!==s||t[1]!==r||t[2]!==n){let e;t[4]!==s||t[5]!==r?(e=e=>Et(e,s,r),t[4]=s,t[5]=r,t[6]=e):e=t[6],l=n.filter(e),t[0]=s,t[1]=r,t[2]=n,t[3]=l}else l=t[3];let u=l,d;t[7]===s?d=t[8]:(d=s.trim(),t[7]=s,t[8]=d);let f=d.length>0,p;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,W.jsx)(he,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),t[9]=p):p=t[9];let m,h;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(m=i(`w-full rounded-lg border border-edge bg-surface-panel py-2 pl-9 pr-3 text-sm text-fg`,`placeholder:text-fg-subtle`,k),h=e=>c(e.target.value),t[10]=m,t[11]=h):(m=t[10],h=t[11]);let g;t[12]!==s||t[13]!==a?(g=(0,W.jsxs)(`div`,{className:`relative`,children:[p,(0,W.jsx)(`input`,{type:`search`,value:s,placeholder:a,"aria-label":a,className:m,onChange:h})]}),t[12]=s,t[13]=a,t[14]=g):g=t[14];let _;t[15]!==u.length||t[16]!==f||t[17]!==n.length?(_=f?(0,W.jsxs)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:[u.length,` / `,n.length]}):null,t[15]=u.length,t[16]=f,t[17]=n.length,t[18]=_):_=t[18];let v;t[19]!==g||t[20]!==_?(v=(0,W.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]!==u||t[23]!==o||t[24]!==r?(y=(0,W.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:u.length===0?(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:o}):(0,W.jsx)(`ul`,{className:`flex flex-col gap-2`,children:u.map((e,t)=>{let n=e.shortName||Dt(e.name,r)||e.name||`?`,i=e.name||`tool-${t}`;return(0,W.jsxs)(`li`,{className:`min-w-0 rounded-lg border border-edge bg-surface-base px-3 py-2.5`,children:[(0,W.jsx)(`div`,{className:`truncate font-mono text-sm font-medium text-fg`,title:e.name===n?n:e.name,children:n}),e.description?(0,W.jsx)(`p`,{className:`mt-1 truncate text-xs leading-relaxed text-fg-muted`,title:e.description,children:e.description}):null]},i)})})}),t[22]=u,t[23]=o,t[24]=r,t[25]=y):y=t[25];let b;return t[26]!==v||t[27]!==y?(b=(0,W.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 kt(e){let t=(0,U.c)(38),{open:n,onOpenChange:r,serverId:a,title:o,subtitle:s,searchPlaceholder:c,searchEmptyLabel:l,emptyLabel:u,closeLabel:d,tools:f,stripPrefix:h}=e,g;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,W.jsx)(A,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,ce)}),t[0]=g):g=t[0];let v;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(v=i(`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`,L,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`),t[1]=v):v=t[1];let y;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,W.jsx)(p,{className:`size-4 shrink-0 text-accent`,"aria-hidden":!0}),t[2]=y):y=t[2];let b;t[3]===o?b=t[4]:(b=(0,W.jsxs)(w,{className:`flex items-center gap-2 text-base font-semibold text-fg`,children:[y,o]}),t[3]=o,t[4]=b);let C;t[5]!==a||t[6]!==s||t[7]!==f.length?(C=s.replace(`{{serverId}}`,a).replace(`{{count}}`,String(f.length)),t[5]=a,t[6]=s,t[7]=f.length,t[8]=C):C=t[8];let T;t[9]===C?T=t[10]:(T=(0,W.jsx)(S,{className:`mt-1 text-sm text-fg-muted`,children:C}),t[9]=C,t[10]=T);let E;t[11]!==b||t[12]!==T?(E=(0,W.jsxs)(`div`,{className:`min-w-0`,children:[b,T]}),t[11]=b,t[12]=T,t[13]=E):E=t[13];let D;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,W.jsx)(oe,{className:`size-4`,"aria-hidden":!0}),t[14]=D):D=t[14];let O;t[15]===d?O=t[16]:(O=(0,W.jsx)(m,{asChild:!0,children:(0,W.jsx)(_,{type:`button`,variant:`ghost`,className:`size-8 shrink-0 px-0`,"aria-label":d,children:D})}),t[15]=d,t[16]=O);let k;t[17]!==E||t[18]!==O?(k=(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3 border-b border-edge px-5 py-4`,children:[E,O]}),t[17]=E,t[18]=O,t[19]=k):k=t[19];let M;t[20]!==u||t[21]!==n||t[22]!==l||t[23]!==c||t[24]!==a||t[25]!==h||t[26]!==f?(M=f.length>0?(0,W.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,W.jsx)(Ot,{tools:f,stripPrefix:h,searchPlaceholder:c,searchEmptyLabel:l},`${a}-${n?`open`:`closed`}`)}):(0,W.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:u})}),t[20]=u,t[21]=n,t[22]=l,t[23]=c,t[24]=a,t[25]=h,t[26]=f,t[27]=M):M=t[27];let P;t[28]===d?P=t[29]:(P=(0,W.jsx)(`div`,{className:`flex justify-end border-t border-edge px-5 py-3`,children:(0,W.jsx)(m,{asChild:!0,children:(0,W.jsx)(_,{type:`button`,variant:`secondary`,children:d})})}),t[28]=d,t[29]=P);let F;t[30]!==k||t[31]!==M||t[32]!==P?(F=(0,W.jsxs)(N,{children:[g,(0,W.jsxs)(j,{className:v,children:[k,M,P]})]}),t[30]=k,t[31]=M,t[32]=P,t[33]=F):F=t[33];let I;return t[34]!==r||t[35]!==n||t[36]!==F?(I=(0,W.jsx)(x,{open:n,onOpenChange:r,children:F}),t[34]=r,t[35]=n,t[36]=F,t[37]=I):I=t[37],I}var At=i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,k);function jt(e){return e.materialized.type===`composio`?e.connectorId.replace(/^composio-/,``):null}function Mt(e,t){return e===`write`?t.composioScopeWrite:e===`admin`?t.composioScopeAdmin:t.composioScopeRead}function Nt({instance:e,t}){let n=jt(e),[r,a]=(0,H.useState)([]),[o,s]=(0,H.useState)([]),[c,l]=(0,H.useState)([]),[u,d]=(0,H.useState)(`read`),[f,p]=(0,H.useState)(!1),[m,h]=(0,H.useState)(null),g=(0,H.useCallback)(async()=>{if(!(!n||n===`api-key`)){p(!0),h(null);try{let[e,t,r,i]=await Promise.all([Ue().catch(()=>[]),qe(n).catch(()=>[]),Je(20).catch(()=>[]),Ge(n).catch(()=>`read`)]);a(e.filter(e=>e.toolkit.toLowerCase()===n.toLowerCase())),s(t),l(r.filter(e=>!e.toolkit||e.toolkit.toLowerCase()===n.toLowerCase())),d(i)}catch(e){h(e instanceof Error?e.message:String(e))}finally{p(!1)}}},[n]);(0,H.useEffect)(()=>{g()},[g]);let v=(0,H.useCallback)(async()=>{if(n){p(!0),h(null);try{let e=await We(n);window.open(e.connectUrl,`_blank`,`noopener,noreferrer`)}catch(e){h(e instanceof Error?e.message:String(e))}finally{p(!1)}}},[n]),y=(0,H.useCallback)(async e=>{if(n){d(e);try{await Ke(n,e),await g()}catch(e){h(e instanceof Error?e.message:String(e))}}},[g,n]);return n?n===`api-key`?(0,W.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:t.composioApiKeyStored}):(0,W.jsxs)(`div`,{className:`mt-4 rounded-xl border border-edge bg-surface-base p-3 text-sm`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`font-medium text-fg`,children:Z(t.composioToolkitTitle,{toolkit:n})}),(0,W.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:t.composioScopeHint})]}),(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,W.jsxs)(me,{className:i(At,`h-9 w-28 py-1`),value:u,onChange:e=>void y(e.currentTarget.value),children:[(0,W.jsx)(fe,{value:`read`,children:t.composioScopeRead}),(0,W.jsx)(fe,{value:`write`,children:t.composioScopeWrite}),(0,W.jsx)(fe,{value:`admin`,children:t.composioScopeAdmin})]}),(0,W.jsxs)(_,{variant:`secondary`,disabled:f,onClick:()=>void v(),children:[f?(0,W.jsx)(T,{className:`size-4 animate-spin`}):(0,W.jsx)(I,{className:`size-4`}),t.connectOAuth]}),(0,W.jsx)(_,{variant:`ghost`,disabled:f,onClick:()=>void g(),children:t.refresh})]})]}),m?(0,W.jsx)(`p`,{className:`mt-3 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:m}):null,(0,W.jsxs)(`div`,{className:`mt-4 grid gap-3 lg:grid-cols-3`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioConnections}),r.length?r.map(e=>(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel p-2`,children:[(0,W.jsx)(`p`,{className:`truncate font-mono text-xs text-fg`,children:e.accountEmail??e.username??e.workspace??e.id}),(0,W.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.status})]},e.id)):(0,W.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioConnectionsEmpty})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioAgentTools}),o.length?o.slice(0,8).map(e=>(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel p-2`,children:[(0,W.jsx)(`p`,{className:`truncate font-mono text-xs text-fg`,children:e.slug}),(0,W.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[Mt(e.scope,t),e.curated?``:` ${t.composioUncuratedSuffix}`]})]},e.slug)):(0,W.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioToolsEmpty})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioRecentTriggers}),c.length?c.slice(0,5).map(e=>(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel p-2`,children:[(0,W.jsx)(`p`,{className:`truncate text-xs text-fg`,children:e.trigger??e.id}),(0,W.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:new Date(e.at).toLocaleString()})]},`${e.id}-${e.at}`)):(0,W.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioTriggersEmpty})]})]})]}):null}var Pt=i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,k);function Ft(e,t){return e?t.healthStatusLabels[e]??e:t.healthNotTested}function It(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 Lt(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 Rt(e){let t=(0,U.c)(12),{title:n,description:r,meta:a}=e,o;t[0]===r?o=t[1]:(o=r?(0,W.jsx)(pe,{delayDuration:300,skipDelayDuration:100,children:(0,W.jsxs)(se,{children:[(0,W.jsx)(de,{asChild:!0,children:(0,W.jsx)(`p`,{tabIndex:0,title:r,className:i(`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,W.jsx)(B,{children:(0,W.jsx)(f,{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,W.jsx)(`span`,{className:`whitespace-pre-wrap break-words`,children:r})})})]})}):null,t[0]=r,t[1]=o);let s=o,c;t[2]===n?c=t[3]:(c=(0,W.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]=c);let l;t[4]===a?l=t[5]:(l=a?(0,W.jsx)(`span`,{className:`shrink-0 rounded-md bg-surface-hover px-1.5 py-0.5 text-[11px] leading-4 text-fg-subtle`,children:a}):null,t[4]=a,t[5]=l);let u;t[6]!==c||t[7]!==l?(u=(0,W.jsxs)(`div`,{className:`flex min-w-0 items-start justify-between gap-3`,children:[c,l]}),t[6]=c,t[7]=l,t[8]=u):u=t[8];let d;return t[9]!==s||t[10]!==u?(d=(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2.5`,children:[u,s]}),t[9]=s,t[10]=u,t[11]=d):d=t[11],d}function zt({instance:e,definition:t,onClose:n,onChanged:r,t:a,mcp:o}){let[s,c]=(0,H.useState)(!1),[l,u]=(0,H.useState)(!1),[d,f]=(0,H.useState)(!1),[h,y]=(0,H.useState)(null),[b,C]=(0,H.useState)(`health`),[E,O]=(0,H.useState)(!1),[k,P]=(0,H.useState)(()=>It(t,e)),[F,L]=(0,H.useState)(null),ee=t?.setup.config??[],z=e.materialized.type===`mcp`&&ee.length>0&&(t?.setup.secrets??[]).length===0,B=h?h.toolCount:e.usage.lastToolCount,te=(0,H.useMemo)(()=>{let t=[[`health`,ie,a.detailHealth],[`tools`,p,`${a.detailTools} ${h?h.toolCount:e.usage.lastToolCount??``}`],[`resources`,D,`${a.detailResources} ${h?h.resourceCount:e.usage.lastResourceCount??``}`],[`prompts`,g,`${a.detailPrompts} ${h?h.promptCount:e.usage.lastPromptCount??``}`],[`permissions`,I,a.detailPermissions]];return z?[...t,[`config`,D,a.tabConfig]]:t},[h,e.usage.lastPromptCount,e.usage.lastResourceCount,e.usage.lastToolCount,z,a]),V=(0,H.useCallback)(async()=>{c(!0),L(null);try{let t=await He(e.instanceId);y(t),t.toolCount>0&&C(`tools`),r()}catch(e){L(e instanceof Error?e.message:String(e))}finally{c(!1)}},[e.instanceId,r]),ne=(0,H.useCallback)(async()=>{u(!0),L(null);try{await Ve(e.instanceId),await r(),n()}catch(e){L(e instanceof Error?e.message:String(e)),u(!1)}},[e.instanceId,r,n]),re=(0,H.useCallback)(async()=>{if(!(!t||!z)){f(!0),L(null);try{let n={};for(let e of t.setup.config??[]){let t=Lt(e.type,k[e.key]??``);t!==void 0&&(n[e.key]=t)}await Be(e.instanceId,{config:n}),await r(),C(`health`)}catch(e){L(e instanceof Error?e.message:String(e))}finally{f(!1)}}},[k,t,e.instanceId,r,z]);return(0,W.jsxs)(x,{open:!0,onOpenChange:e=>{e||n()},children:[(0,W.jsxs)(N,{children:[(0,W.jsx)(A,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,W.jsxs)(j,{className:i(`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,W.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(w,{className:`text-base font-semibold text-fg`,children:e.displayName}),(0,W.jsx)(S,{className:`mt-1 text-sm text-fg-muted`,children:e.materialized.type===`mcp`?Z(a.mcpServerRuntime,{serverId:e.materialized.serverId}):Z(a.runtimeLabel,{runtime:e.materialized.type})})]}),(0,W.jsx)(m,{asChild:!0,children:(0,W.jsxs)(`button`,{type:`button`,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,R.focusRingPanel),"aria-label":a.modalClose,children:[(0,W.jsx)(oe,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,W.jsx)(`span`,{className:`sr-only`,children:a.modalClose})]})})]}),(0,W.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:[F?(0,W.jsx)(`p`,{className:`mb-4 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:F}):null,(0,W.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:te.map(([e,t,n])=>(0,W.jsxs)(`button`,{type:`button`,className:i(`inline-flex h-8 items-center gap-1.5 rounded-md border px-2.5 text-xs`,b===e?`border-accent bg-accent-soft text-accent-fg`:`border-edge bg-surface-base text-fg-muted hover:text-fg`),onClick:()=>C(e),children:[(0,W.jsx)(t,{className:`size-3.5`,"aria-hidden":!0}),n]},e))}),(0,W.jsxs)(`div`,{className:`mt-4 rounded-xl border border-edge bg-surface-base p-3 text-sm`,children:[b===`health`?(0,W.jsxs)(`div`,{className:`space-y-1 text-fg-muted`,children:[(0,W.jsxs)(`p`,{children:[a.statusLabel,` `,(0,W.jsx)(`span`,{className:h?.ok?`font-medium text-emerald-700 dark:text-emerald-300`:`font-medium text-fg`,children:Ft(h?.status??e.usage.lastHealthStatus,a)})]}),(0,W.jsxs)(`p`,{children:[a.lastCheckLabel,` `,e.usage.lastHealthCheckAt?new Date(e.usage.lastHealthCheckAt).toLocaleString():a.never]}),h?.action?(0,W.jsx)(`p`,{children:h.action}):null]}):null,b===`tools`?h?.tools.length?(0,W.jsxs)(`div`,{className:`grid gap-3`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,W.jsx)(`p`,{className:`text-xs text-fg-muted`,children:Z(a.toolsAvailable,{count:String(h.tools.length)})}),(0,W.jsx)(_,{type:`button`,variant:`ghost`,className:`h-7 text-xs`,onClick:()=>O(!0),children:o.viewAllTools})]}),(0,W.jsx)(`div`,{className:`grid gap-2`,children:h.tools.slice(0,8).map(e=>(0,W.jsx)(Rt,{title:e.shortName??e.name,description:e.description},e.name))})]}):(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,W.jsx)(`p`,{className:`text-fg-muted`,children:B?Z(a.toolsLastCheckSummary,{count:String(B)}):a.toolsRunTestHint}),(0,W.jsxs)(_,{type:`button`,variant:`secondary`,disabled:s,onClick:()=>void V(),children:[s?(0,W.jsx)(T,{className:`size-4 animate-spin`}):(0,W.jsx)(v,{className:`size-4`}),a.test]})]}):null,b===`resources`?h?.resources.length?(0,W.jsx)(`div`,{className:`grid gap-2`,children:h.resources.slice(0,8).map(e=>(0,W.jsx)(Rt,{title:e.title??e.name,description:e.uri,meta:e.mimeType},e.uri))}):(0,W.jsx)(`p`,{className:`text-fg-muted`,children:a.resourcesRunTestHint}):null,b===`prompts`?h?.prompts.length?(0,W.jsx)(`div`,{className:`grid gap-2`,children:h.prompts.slice(0,8).map(e=>(0,W.jsx)(Rt,{title:e.title??e.name,description:e.description,meta:e.argumentCount?Z(a.promptArgumentCount,{count:String(e.argumentCount)}):void 0},e.name))}):(0,W.jsx)(`p`,{className:`text-fg-muted`,children:a.promptsRunTestHint}):null,b===`permissions`?(0,W.jsxs)(`div`,{className:`space-y-1 text-fg-muted`,children:[(0,W.jsx)(`p`,{children:Z(a.secretsConfigured,{count:String(Object.values(e.secretStatus).filter(Boolean).length)})}),(0,W.jsx)(`p`,{children:e.materialized.type===`mcp`?Z(a.runtimeServerLabel,{runtime:e.materialized.type.toUpperCase(),serverId:e.materialized.serverId}):Z(a.runtimeLabel,{runtime:e.materialized.type.toUpperCase()})}),(0,W.jsx)(`p`,{children:e.materialized.type===`mcp`?a.mcpPolicyHint:a.connectorPolicyHint})]}):null,b===`config`&&z?(0,W.jsx)(`div`,{className:`grid gap-3`,children:ee.map(e=>(0,W.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,W.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.label}),e.description?(0,W.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:e.description}):null,(0,W.jsx)(`input`,{className:Pt,value:k[e.key]??``,placeholder:e.placeholder,onChange:t=>P(n=>({...n,[e.key]:t.currentTarget.value}))})]},e.key))}):null]}),e.materialized.type===`composio`?(0,W.jsx)(Nt,{instance:e,t:a}):null]}),(0,W.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[(0,W.jsx)(_,{variant:`secondary`,onClick:n,children:a.modalClose}),b===`config`&&z?(0,W.jsxs)(_,{variant:`primary`,disabled:d,onClick:()=>void re(),children:[d?(0,W.jsx)(T,{className:`size-4 animate-spin`}):(0,W.jsx)(le,{className:`size-4`}),a.modalSave]}):null,e.materialized.type===`mcp`?(0,W.jsxs)(_,{variant:`secondary`,disabled:s,onClick:()=>void V(),children:[s?(0,W.jsx)(T,{className:`size-4 animate-spin`}):(0,W.jsx)(v,{className:`size-4`}),a.test]}):null,(0,W.jsxs)(_,{variant:`ghost`,disabled:l,onClick:()=>void ne(),children:[l?(0,W.jsx)(T,{className:`size-4 animate-spin`}):(0,W.jsx)(M,{className:`size-4`}),a.remove]})]})]})]}),e.materialized.type===`mcp`?(0,W.jsx)(kt,{open:E,onOpenChange:O,serverId:e.materialized.serverId,title:Z(a.installedToolsDialogTitle,{name:e.displayName}),subtitle:a.installedToolsDialogSubtitle,searchPlaceholder:o.toolsDialogSearchPlaceholder,searchEmptyLabel:o.toolsDialogSearchEmpty,emptyLabel:a.toolsRunTestHint,closeLabel:o.toolsDialogClose,tools:h?.tools??[],stripPrefix:`${e.materialized.serverId}__`}):null]})}function Bt({instance:e,definition:t,onOpenDetails:n,onChanged:r,t:i}){let[a,o]=(0,H.useState)(!1),[s,c]=(0,H.useState)(!1),[l,u]=(0,H.useState)(null),f=(0,H.useCallback)(async()=>{o(!0),u(null);try{await He(e.instanceId),await r()}catch(e){u(e instanceof Error?e.message:String(e))}finally{o(!1)}},[e.instanceId,r]),p=(0,H.useCallback)(async()=>{c(!0),u(null);try{await Ve(e.instanceId),await r()}catch(e){u(e instanceof Error?e.message:String(e)),c(!1)}},[e.instanceId,r]),m=e.usage.lastHealthStatus?i.healthStatusLabels[e.usage.lastHealthStatus]??e.usage.lastHealthStatus:i.healthNotTested,h=e.usage.lastToolCount??0,g=!!(t?.setup.config?.length&&!t.setup.secrets?.length&&e.materialized.type===`mcp`);return(0,W.jsxs)(`div`,{className:`flex h-full min-h-[10.5rem] cursor-pointer flex-col rounded-lg bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45`,onClick:()=>n(e),children:[(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:e.displayName}),(0,W.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,W.jsx)(d,{className:`size-3`,"aria-hidden":!0}),i.installedBadge]}),g?(0,W.jsx)(`span`,{className:`rounded-full bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:i.tabConfig}):null]}),(0,W.jsx)(`p`,{className:`mt-3 line-clamp-2 break-all text-sm leading-5 text-fg-muted`,children:e.materialized.type===`mcp`?Z(i.mcpServerRuntime,{serverId:e.materialized.serverId}):Z(i.runtimeLabel,{runtime:e.materialized.type})}),(0,W.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2 text-xs text-fg-muted`,children:[(0,W.jsxs)(`span`,{className:`rounded-md bg-surface-base px-2 py-1`,children:[i.statusLabel,` `,m]}),(0,W.jsx)(`span`,{className:`rounded-md bg-surface-base px-2 py-1`,children:Z(i.toolsAvailable,{count:String(h)})})]}),l?(0,W.jsx)(`p`,{className:`mt-3 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:l}):null]}),(0,W.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-2 border-t border-edge pt-3`,onClick:e=>e.stopPropagation(),children:[(0,W.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:i.connectorDetails}),(0,W.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[e.materialized.type===`mcp`?(0,W.jsxs)(_,{variant:`secondary`,disabled:a,onClick:()=>void f(),children:[a?(0,W.jsx)(T,{className:`size-4 animate-spin`}):(0,W.jsx)(v,{className:`size-4`}),i.test]}):null,(0,W.jsxs)(_,{variant:`ghost`,disabled:s,onClick:()=>void p(),children:[s?(0,W.jsx)(T,{className:`size-4 animate-spin`}):(0,W.jsx)(M,{className:`size-4`}),i.remove]})]})]})]})}var Vt=i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,k),Ht=i(Vt,`min-h-28 font-mono`);function Ut(e,t){return e?t.healthStatusLabels[e]??e:t.healthStatusPending}function Wt(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 Gt(e,t){let n={};for(let t of e.setup.secrets??[])n[t.key]=``;let r={};for(let t of e.setup.config??[])r[t.key]=t.defaultValue===void 0?``:typeof t.defaultValue==`string`?t.defaultValue:JSON.stringify(t.defaultValue,null,2);return{connector:e,secrets:n,config:r,installing:!1,error:null,result:null,health:null,oauth:{flow:null,connected:e.auth.mode!==`oauth`},...t?{store:t}:{}}}function Kt(e){let t=(0,U.c)(12),{title:n,items:r}=e;if(r.length===0)return null;let i;t[0]===n?i=t[1]:(i=(0,W.jsx)(`div`,{className:`border-b border-edge px-3 py-2 text-xs font-semibold text-fg`,children:n}),t[0]=n,t[1]=i);let a;t[2]===r?a=t[3]:(a=r.slice(0,12).map(qt),t[2]=r,t[3]=a);let o;t[4]===r.length?o=t[5]:(o=r.length>12?(0,W.jsxs)(`div`,{className:`px-3 py-2 text-xs text-fg-subtle`,children:[`+`,r.length-12]}):null,t[4]=r.length,t[5]=o);let s;t[6]!==a||t[7]!==o?(s=(0,W.jsxs)(`div`,{className:`max-h-40 overflow-y-auto`,children:[a,o]}),t[6]=a,t[7]=o,t[8]=s):s=t[8];let c;return t[9]!==i||t[10]!==s?(c=(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel`,children:[i,s]}),t[9]=i,t[10]=s,t[11]=c):c=t[11],c}function qt(e){return(0,W.jsxs)(`div`,{className:`border-b border-edge-subtle px-3 py-2 last:border-b-0`,children:[(0,W.jsx)(`div`,{className:`break-words font-mono text-xs font-medium text-fg`,children:e.title}),e.description?(0,W.jsx)(`div`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:e.description}):null]},e.id)}function Jt({draft:e,onChange:t,onClose:n,onInstalled:r,t:a}){let{connector:o}=e,s=e.result?`complete`:e.installing?`health`:`configure`,c=[{id:`configure`,label:a.installStepConfigure},{id:`health`,label:a.installStepHealth},{id:`complete`,label:a.installStepComplete}],l=(0,H.useCallback)(async()=>{t({...e,installing:!0,error:null});try{let n=await Ie(o.id);window.open(n.verificationUri,`_blank`,`noopener,noreferrer`),t({...e,installing:!1,error:null,oauth:{flow:n,connected:!1}})}catch(n){t({...e,installing:!1,error:n instanceof Error?n.message:String(n)})}},[o.id,e,t]),u=(0,H.useCallback)(async()=>{if(e.oauth.flow){t({...e,installing:!0,error:null});try{await Le(o.id,e.oauth.flow.deviceCode),t({...e,installing:!1,error:null,oauth:{...e.oauth,connected:!0}})}catch(n){t({...e,installing:!1,error:n instanceof Error?n.message:String(n)})}}},[o.id,e,t]),f=(0,H.useCallback)(async()=>{t({...e,installing:!0,error:null,result:null,health:null});try{if(o.auth.mode===`oauth`&&!e.oauth.connected)throw Error(a.oauthRequiredBeforeInstall);let n={};for(let t of o.setup.config??[]){let r=Wt(t.type,e.config[t.key]??``);r!==void 0&&(n[t.key]=r)}let i=e.store?await Ae(e.store.packageName,{secrets:e.secrets,config:n},e.store.version):await Re(o.id,{secrets:e.secrets,config:n,definition:o.source===`registry`?o:void 0}),s=null;try{s=await He(i.instanceId)}catch{s=null}t({...e,installing:!1,result:i,health:s}),await r()}catch(n){t({...e,installing:!1,error:n instanceof Error?n.message:String(n)})}},[o,e,t,r,a.oauthRequiredBeforeInstall]);return(0,W.jsx)(x,{open:!0,onOpenChange:e=>{e||n()},children:(0,W.jsxs)(N,{children:[(0,W.jsx)(A,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,W.jsxs)(j,{className:i(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex max-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,W.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(w,{className:`text-base font-semibold text-fg`,children:Z(a.installDialogTitle,{name:o.displayName})}),(0,W.jsx)(S,{className:`mt-1 line-clamp-3 text-sm text-fg-muted`,children:o.description})]}),(0,W.jsx)(m,{asChild:!0,children:(0,W.jsxs)(`button`,{type:`button`,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,R.focusRingPanel),"aria-label":a.modalClose,children:[(0,W.jsx)(oe,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,W.jsx)(`span`,{className:`sr-only`,children:a.modalClose})]})})]}),(0,W.jsxs)(`div`,{className:`min-h-0 overflow-y-auto px-6 py-5`,children:[(0,W.jsx)(`div`,{className:`mb-5 grid grid-cols-3 gap-2`,"aria-label":a.installProgressAria,children:c.map((e,t)=>{let n=c.findIndex(e=>e.id===s);return(0,W.jsxs)(`div`,{className:i(`rounded-xl border px-3 py-2 text-xs font-medium`,t===n?`border-accent bg-accent-soft text-accent-fg`:t<n?`border-emerald-200 bg-emerald-50 text-emerald-800 dark:border-emerald-900/40 dark:bg-emerald-950/40 dark:text-emerald-200`:`border-edge bg-surface-base text-fg-muted`),children:[(0,W.jsxs)(`span`,{className:`mr-1 tabular-nums`,children:[t+1,`.`]}),e.label]},e.id)})}),(0,W.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[o.auth.mode===`oauth`?(0,W.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-panel p-4`,children:[(0,W.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:a.oauthTitle}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:a.oauthHint}),e.oauth.flow?(0,W.jsxs)(`div`,{className:`mt-3 rounded-xl bg-surface-base p-3 text-sm text-fg-muted`,children:[(0,W.jsx)(`p`,{children:Z(a.oauthOpenCodePrefix,{url:e.oauth.flow.verificationUri})}),(0,W.jsx)(`p`,{className:`mt-2 font-mono text-lg font-semibold tracking-widest text-fg`,children:e.oauth.flow.userCode})]}):null,e.oauth.connected?(0,W.jsx)(`p`,{className:`mt-3 rounded-xl bg-emerald-500/10 px-3 py-2 text-sm text-emerald-700`,children:a.oauthConnected}):null,(0,W.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,W.jsxs)(_,{variant:`secondary`,disabled:e.installing,onClick:()=>void l(),children:[e.installing&&!e.oauth.flow?(0,W.jsx)(T,{className:`size-4 animate-spin`}):(0,W.jsx)(v,{className:`size-4`}),a.oauthConnectButton]}),(0,W.jsxs)(_,{variant:`primary`,disabled:e.installing||!e.oauth.flow,onClick:()=>void u(),children:[e.installing&&e.oauth.flow?(0,W.jsx)(T,{className:`size-4 animate-spin`}):(0,W.jsx)(d,{className:`size-4`}),a.oauthAuthorizedButton]})]})]}):null,e.store?(0,W.jsxs)(`section`,{className:`rounded-2xl border border-edge bg-surface-base p-4`,children:[(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.detailPermissions}),(0,W.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:[(e.store.permissions.data??[]).map(e=>(0,W.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-panel px-2 py-1 text-xs text-fg-muted`,children:e},e)),(e.store.permissions.networkDomains??[]).map(e=>(0,W.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-panel px-2 py-1 text-xs text-fg-muted`,children:e},e)),(0,W.jsx)(`span`,{className:`rounded-md border border-emerald-500/30 bg-emerald-500/10 px-2 py-1 text-xs text-emerald-700 dark:text-emerald-300`,children:a.storeLocalExecDenied})]})]}):null,(o.setup.secrets??[]).map(n=>(0,W.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,W.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.label}),n.description?(0,W.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:n.description}):null,(0,W.jsx)(ne,{value:e.secrets[n.key]??``,onChange:r=>t({...e,secrets:{...e.secrets,[n.key]:r},error:null}),labels:a.secretInputLabels,placeholder:n.required?a.requiredPlaceholder:a.optionalPlaceholder})]},n.key)),(o.setup.config??[]).map(n=>(0,W.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,W.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.label}),n.type===`json`?(0,W.jsx)(`textarea`,{className:Ht,value:e.config[n.key]??``,placeholder:n.placeholder,onChange:r=>t({...e,config:{...e.config,[n.key]:r.currentTarget.value},error:null})}):(0,W.jsx)(`input`,{className:Vt,value:e.config[n.key]??``,placeholder:n.placeholder,onChange:r=>t({...e,config:{...e.config,[n.key]:r.currentTarget.value},error:null})})]},n.key)),e.installing?(0,W.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-base p-4 text-sm text-fg-muted`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 font-medium text-fg`,children:[(0,W.jsx)(T,{className:`size-4 animate-spin text-accent`,"aria-hidden":!0}),a.installingTitle]}),(0,W.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:a.installingHint})]}):null,e.error?(0,W.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:e.error}):null,e.result?(0,W.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-base p-4 text-sm text-fg-muted`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`p`,{className:`font-medium text-fg`,children:Z(a.installedAs,{target:e.result.materialized.type===`mcp`?e.result.materialized.serverId:e.result.instanceId})}),(0,W.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:Z(a.runtimeLabel,{runtime:e.result.materialized.type.toUpperCase()})})]}),(0,W.jsx)(`span`,{className:i(`rounded-full px-2 py-0.5 text-xs font-medium`,e.health?.ok?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e.health?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:`bg-surface-hover text-fg-muted`),children:e.health?.ok?a.healthStatusHealthy:Ut(e.health?.status,a)})]}),e.health?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`mt-3 grid gap-2 text-xs sm:grid-cols-3`,children:[(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2`,children:[(0,W.jsx)(`div`,{className:`font-semibold text-fg`,children:e.health.toolCount}),(0,W.jsx)(`div`,{children:a.toolsMetric})]}),(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2`,children:[(0,W.jsx)(`div`,{className:`font-semibold text-fg`,children:e.health.resourceCount}),(0,W.jsx)(`div`,{children:a.resourcesMetric})]}),(0,W.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2`,children:[(0,W.jsx)(`div`,{className:`font-semibold text-fg`,children:e.health.promptCount}),(0,W.jsx)(`div`,{children:a.promptsMetric})]})]}),(0,W.jsxs)(`div`,{className:`mt-3 grid gap-2`,children:[(0,W.jsx)(Kt,{title:a.detailTools,items:e.health.tools.map(e=>({id:e.name,title:e.shortName??e.name,description:e.description}))}),(0,W.jsx)(Kt,{title:a.detailResources,items:e.health.resources.map(e=>({id:e.uri,title:e.title??e.name??e.uri,description:e.description??e.uri}))}),(0,W.jsx)(Kt,{title:a.detailPrompts,items:e.health.prompts.map(e=>({id:e.name,title:e.title??e.name,description:e.description??Z(a.promptArgumentCount,{count:String(e.argumentCount)})}))})]})]}):(0,W.jsx)(`p`,{className:`mt-3`,children:a.installedWithoutHealth}),e.health?.action?(0,W.jsx)(`p`,{className:`mt-3 text-xs text-fg-subtle`,children:e.health.action}):null]}):null]})]}),(0,W.jsx)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:(0,W.jsxs)(_,{variant:`primary`,disabled:!!e.result||e.installing||o.auth.mode===`oauth`&&!e.oauth.connected,onClick:()=>void f(),children:[e.installing?(0,W.jsx)(T,{className:`size-4 animate-spin`}):e.result?(0,W.jsx)(d,{className:`size-4`}):(0,W.jsx)(b,{className:`size-4`}),e.result?a.installedBadge:a.install]})})]})]})})}function Yt(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 pt(r)}function Xt(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 Zt(e,t,n){return e.filter(e=>Xt(e,t)).toSorted((e,t)=>n===`source`&&e.source!==t.source?e.source.localeCompare(t.source):e.displayName.localeCompare(t.displayName))}function Qt(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 $t(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 en(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 i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,k)}function nn({label:e,optionalLabel:t,addLabel:n,removeHeaderAria:r,pasteLabel:a,pasteFailed:o,keyPlaceholder:s,valuePlaceholder:c,headers:l,onChange:u}){let d=(e,t)=>{u(l.map((n,r)=>r===e?{...n,...t}:n))},f=()=>{u([...l,{key:``,value:``}])},p=e=>{let t=l.filter((t,n)=>n!==e);u(t.length>0?t:[{key:``,value:``}])},m=async()=>{try{let e=await F();if(!e){window.alert(o);return}let t=it(e);if(!t?.length){window.alert(o);return}u(t)}catch{window.alert(o)}};return(0,W.jsxs)(`div`,{className:`flex flex-col gap-2 md:col-span-2`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium text-fg`,children:[(0,W.jsx)(`span`,{children:e}),t?(0,W.jsx)(`span`,{className:`font-normal text-fg-subtle`,children:t}):null]}),(0,W.jsxs)(_,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5 px-2 text-xs`,onClick:()=>void m(),children:[(0,W.jsx)(P,{className:`size-3.5`,"aria-hidden":!0}),a]})]}),(0,W.jsx)(`div`,{className:`flex flex-col gap-2`,children:l.map((e,t)=>(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`input`,{className:i(tn(),`min-w-0 flex-1 font-mono text-xs`),value:e.key,placeholder:s,onChange:e=>d(t,{key:e.target.value})}),(0,W.jsx)(`input`,{className:i(tn(),`min-w-0 flex-[1.4] font-mono text-xs`),value:e.value,placeholder:c,onChange:e=>d(t,{value:e.target.value})}),(0,W.jsx)(_,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 px-0`,disabled:l.length<=1&&!e.key&&!e.value,onClick:()=>p(t),"aria-label":r,children:(0,W.jsx)(M,{className:`size-4 text-fg-subtle`,"aria-hidden":!0})})]},en(e,t,l)))}),(0,W.jsxs)(`button`,{type:`button`,className:i(`self-start text-sm text-accent hover:underline`,R.press),onClick:f,children:[`+ `,n]})]})}var rn=[`stdio`,`sse`,`streamable-http`];function Q(e){let t=(0,U.c)(11),{label:n,description:r,required:i,children:a}=e,o;t[0]===i?o=t[1]:(o=i?(0,W.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,W.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,W.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,W.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 $(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,k)}function an(e){let t=(0,U.c)(29),{row:n,t:r,onUpdate:a,idConflictMessage:o,variant:s}=e,c=s===void 0?`all`:s,l=c===`all`||c===`basic`,u=c===`all`||c===`advanced`,d;t[0]!==o||t[1]!==a||t[2]!==n.id||t[3]!==n.transport||t[4]!==l||t[5]!==r?(d=l?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Q,{label:r.transportLabel,required:!0,children:(0,W.jsx)(me,{className:$(),value:n.transport,onChange:e=>a({transport:e.target.value}),children:rn.map(e=>(0,W.jsx)(fe,{value:e,children:r.transportLabels[e]},e))})}),(0,W.jsxs)(Q,{label:r.serverIdLabel,required:!0,children:[(0,W.jsx)(`input`,{className:$(),value:n.id,placeholder:r.serverIdPlaceholder,onChange:e=>a({id:e.target.value})}),o?(0,W.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-300`,children:o}):null]})]}):null,t[0]=o,t[1]=a,t[2]=n.id,t[3]=n.transport,t[4]=l,t[5]=r,t[6]=d):d=t[6];let f;t[7]!==a||t[8]!==n.argsText||t[9]!==n.command||t[10]!==n.cwd||t[11]!==n.envJson||t[12]!==n.headers||t[13]!==n.transport||t[14]!==n.url||t[15]!==u||t[16]!==l||t[17]!==r||t[18]!==c?(f=n.transport===`stdio`?(0,W.jsxs)(W.Fragment,{children:[l?(0,W.jsx)(`div`,{className:c===`basic`?`md:col-span-2`:void 0,children:(0,W.jsx)(Q,{label:r.commandLabel,required:!0,children:(0,W.jsx)(`input`,{className:$(),value:n.command,onChange:e=>a({command:e.target.value})})})}):null,u?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(Q,{label:r.argsLabel,description:r.argsHint,children:(0,W.jsx)(`input`,{className:$(),value:n.argsText,onChange:e=>a({argsText:e.target.value})})}),(0,W.jsx)(Q,{label:r.cwdLabel,children:(0,W.jsx)(`input`,{className:$(),value:n.cwd,onChange:e=>a({cwd:e.target.value})})}),(0,W.jsx)(Q,{label:r.envLabel,description:r.envHint,children:(0,W.jsx)(`textarea`,{className:i($(),`min-h-[4rem] font-mono text-xs`),value:n.envJson,onChange:e=>a({envJson:e.target.value})})})]}):null]}):(0,W.jsxs)(W.Fragment,{children:[l?(0,W.jsx)(`div`,{className:`md:col-span-2`,children:(0,W.jsx)(Q,{label:r.urlLabel,required:!0,children:(0,W.jsx)(`input`,{className:i($(),`font-mono text-xs`),value:n.url,placeholder:`https://example.com/mcp`,onChange:e=>a({url:e.target.value})})})}):null,u?(0,W.jsx)(nn,{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=>a({headers:e})}):null]}),t[7]=a,t[8]=n.argsText,t[9]=n.command,t[10]=n.cwd,t[11]=n.envJson,t[12]=n.headers,t[13]=n.transport,t[14]=n.url,t[15]=u,t[16]=l,t[17]=r,t[18]=c,t[19]=f):f=t[19];let p;t[20]!==a||t[21]!==n||t[22]!==u||t[23]!==r?(p=u?(0,W.jsx)(Q,{label:r.timeoutLabel,description:r.timeoutHint,children:(0,W.jsx)(`input`,{type:`number`,min:1,max:600,className:$(),value:xt(n),placeholder:r.timeoutPlaceholder,onChange:e=>a({connectionTimeoutMs:St(e.target.value)})})}):null,t[20]=a,t[21]=n,t[22]=u,t[23]=r,t[24]=p):p=t[24];let m;return t[25]!==d||t[26]!==f||t[27]!==p?(m=(0,W.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[d,f,p]}),t[25]=d,t[26]=f,t[27]=p,t[28]=m):m=t[28],m}function on(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 sn(e){let t=(0,U.c)(13),{tool:n,serverId:r}=e,a;t[0]!==r||t[1]!==n?(a=on(n,r),t[0]=r,t[1]=n,t[2]=a):a=t[2];let o=a,s=n.name===o?o:n.name,c;t[3]===n.description?c=t[4]:(c=n.description?.trim(),t[3]=n.description,t[4]=c);let l=c,u;t[5]!==o||t[6]!==s?(u=(0,W.jsx)(`p`,{className:`break-all font-mono text-xs font-medium leading-5 text-fg`,title:s,children:o}),t[5]=o,t[6]=s,t[7]=u):u=t[7];let d;t[8]===l?d=t[9]:(d=l?(0,W.jsx)(pe,{delayDuration:300,skipDelayDuration:100,children:(0,W.jsxs)(se,{children:[(0,W.jsx)(de,{asChild:!0,children:(0,W.jsx)(`p`,{tabIndex:0,title:l,className:i(`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:l})}),(0,W.jsx)(B,{children:(0,W.jsx)(f,{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,W.jsx)(`span`,{className:`whitespace-pre-wrap break-words`,children:l})})})]})}):null,t[8]=l,t[9]=d);let p;return t[10]!==u||t[11]!==d?(p=(0,W.jsxs)(`div`,{className:`min-w-0 rounded-lg border border-edge bg-surface-panel px-3 py-2.5`,children:[u,d]}),t[10]=u,t[11]=d,t[12]=p):p=t[12],p}function cn({open:e,mode:t,initialRow:n,existingCustomServers:r,sessionIdleTtlMinutes:a,config:o,managedServerIds:s,t:c,cs:l,onClose:u,onSaved:f}){let[h,g]=(0,H.useState)(n),[y,b]=(0,H.useState)(!1),[C,E]=(0,H.useState)(!1),[D,O]=(0,H.useState)(null),[k,M]=(0,H.useState)(!1),[P,F]=(0,H.useState)({status:`idle`}),[I,L]=(0,H.useState)(null),ee=n.id.trim(),B=h.id.trim()!==ee&&s.has(h.id.trim())||s.has(h.id.trim())&&t===`add`?c.reservedServerId:void 0,te=h.id.trim()&&r.some(e=>e.clientKey!==n.clientKey&&e.id.trim()===h.id.trim())?l.duplicateServerId:void 0,V=h.id.trim().length>0&&!B&&!te&&(h.transport===`stdio`?h.command.trim().length>0:h.url.trim().length>0),ne=Ct(h),ie=(0,H.useCallback)(async()=>{if(h.id.trim()){E(!0),O(null),F({status:`loading`});try{F({status:`ok`,tools:(await bt(h.id.trim(),ht(h))).tools})}catch(e){F({status:`error`,message:e instanceof Error?e.message:String(e)})}finally{E(!1)}}},[h]),ae=(0,H.useCallback)(async()=>{if(!(!V||y)){b(!0),O(null);try{let e=r.filter(e=>!(t===`edit`&&e.clientKey===n.clientKey));e.push(h),await gt({sessionIdleTtlMinutes:a,servers:e.sort((e,t)=>e.id.localeCompare(t.id))},ct(o)),await f(),u()}catch(e){O(e instanceof Error?e.message:String(e))}finally{b(!1)}}},[V,o,r,n.clientKey,t,u,f,ee,h,y,a]);return e?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(x,{open:e,onOpenChange:e=>{e||u()},children:(0,W.jsxs)(N,{children:[(0,W.jsx)(A,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,W.jsxs)(j,{className:i(`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,W.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsx)(w,{className:`text-base font-semibold text-fg`,children:t===`add`?l.addCustomServerTitle:l.editCustomServerTitle}),(0,W.jsx)(S,{className:`mt-1 text-sm text-fg-muted`,children:t===`add`?l.addCustomServerHint:l.editCustomServerHint})]}),(0,W.jsx)(m,{asChild:!0,children:(0,W.jsxs)(`button`,{type:`button`,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,R.focusRingPanel),"aria-label":l.modalClose,children:[(0,W.jsx)(oe,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,W.jsx)(`span`,{className:`sr-only`,children:l.modalClose})]})})]}),(0,W.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:(0,W.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,W.jsx)(`section`,{className:`rounded-xl border border-edge bg-surface-base p-4`,children:(0,W.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,W.jsx)(z,{className:`size-4 text-accent`,"aria-hidden":!0}),h.id.trim()||c.cardUntitled]}),(0,W.jsx)(`p`,{className:`mt-1 break-all font-mono text-xs leading-5 text-fg-muted`,children:ne||(h.transport===`stdio`?c.commandLabel:c.urlLabel)})]}),(0,W.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:c.transportLabels[h.transport]})]})}),(0,W.jsxs)(`section`,{children:[(0,W.jsxs)(`div`,{className:`mb-3`,children:[(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:l.connectorBasicConfigTitle}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:l.connectorBasicConfigHint})]}),(0,W.jsx)(an,{row:h,t:c,variant:`basic`,onUpdate:e=>{g(t=>({...t,...e})),O(null)},idConflictMessage:B??te})]}),P.status===`ok`?(0,W.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-base p-3`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,W.jsx)(p,{className:`size-4 text-accent`,"aria-hidden":!0}),P.tools.length===0?c.toolsEmpty:c.toolsTitle.replace(`{{count}}`,String(P.tools.length))]}),P.tools.length>0?(0,W.jsx)(_,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,onClick:()=>L(P.tools),children:c.viewAllTools}):null]}),P.tools.length>0?(0,W.jsx)(`div`,{className:`mt-3 grid gap-2`,children:P.tools.slice(0,6).map((e,t)=>(0,W.jsx)(sn,{tool:e,serverId:h.id},e.name||`tool-${t}`))}):null]}):null,P.status===`error`?(0,W.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:P.message}):null,D?(0,W.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:D}):null,(0,W.jsxs)(`details`,{open:k,onToggle:e=>M(e.currentTarget.open),className:`group rounded-xl border border-edge bg-surface-base`,children:[(0,W.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,W.jsx)(re,{className:`size-4 text-fg-muted transition-transform group-open:rotate-180`,"aria-hidden":!0}),(0,W.jsx)(`span`,{className:`group-open:hidden`,children:l.connectorShowAdvancedConfig}),(0,W.jsx)(`span`,{className:`hidden group-open:inline`,children:l.connectorHideAdvancedConfig})]}),(0,W.jsx)(`div`,{className:`border-t border-edge px-4 py-4`,children:(0,W.jsx)(an,{row:h,t:c,variant:`advanced`,onUpdate:e=>{g(t=>({...t,...e})),O(null)}})})]})]})}),(0,W.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[(0,W.jsxs)(_,{variant:`secondary`,disabled:!h.id.trim()||C,onClick:()=>void ie(),children:[C?(0,W.jsx)(T,{className:`size-4 animate-spin`}):(0,W.jsx)(v,{className:`size-4`}),c.testConnection]}),(0,W.jsx)(m,{asChild:!0,children:(0,W.jsx)(_,{variant:`secondary`,children:l.modalCancel})}),(0,W.jsxs)(_,{variant:`primary`,disabled:!V||y,onClick:()=>void ae(),children:[y?(0,W.jsx)(T,{className:`size-4 animate-spin`}):(0,W.jsx)(d,{className:`size-4`}),y?c.saving:l.modalSave]})]})]})]})}),I?(0,W.jsx)(kt,{open:!0,onOpenChange:e=>{e||L(null)},serverId:h.id,title:c.toolsDialogTitle,subtitle:c.toolsDialogSubtitle,searchPlaceholder:c.toolsDialogSearchPlaceholder,searchEmptyLabel:c.toolsDialogSearchEmpty,emptyLabel:c.toolsEmpty,closeLabel:c.toolsDialogClose,tools:I,stripPrefix:`${h.id.trim()}__`}):null]}):null}var ln=`mprov`,un=`xopc-store`,dn=un,fn=i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,k);function pn(e){let t=[`code`,`docs`,`browser`,`data`,`automation`,`custom`].includes(e.category??``)?e.category:`custom`;return{id:e.name,version:e.latestVersion??`store`,displayName:e.name,description:e.description,category:t,kind:`mcp`,source:`store`,capabilities:[`tools`,`runtime.mcp.streamableHttp`],tags:[`store`],auth:{mode:`none`},setup:{},runtime:{type:`mcp`,serverId:`store-${e.name}`.slice(0,64)}}}function mn(){let e=a(l(e=>e.language)),t=e.connectorsSettings,n=e.mcpSettings,r=o(e=>e.token),s=!!r,[c,d]=ae(),f=c.get(ln)?.trim()||dn,[p,m]=(0,H.useState)(`marketplace`),[h,g]=(0,H.useState)({catalog:[],registryCatalog:[],instances:[],registries:[],loading:!0,error:null}),[v,b]=(0,H.useState)(!1),[x,S]=(0,H.useState)(!1),[w,D]=(0,H.useState)(1),[k,A]=(0,H.useState)(void 0),[j,M]=(0,H.useState)(``),[N,P]=(0,H.useState)(f),[F,I]=(0,H.useState)(`name`),[L,z]=(0,H.useState)(null),[B,V]=(0,H.useState)(null),[ne,ie]=(0,H.useState)(null),[oe,se]=(0,H.useState)(null),[ce,le]=(0,H.useState)(null),[de,fe]=(0,H.useState)(void 0),[pe,me]=(0,H.useState)(!1),[he,_e]=(0,H.useState)(!1),{data:U,mutate:G}=te(s),K=U?.payload?.config,q=(0,H.useMemo)(()=>K===void 0?null:mt(K),[K]),J=q?.servers??[];(0,H.useEffect)(()=>{q&&fe(q.sessionIdleTtlMinutes)},[q]);let Y=(0,H.useCallback)(async()=>{if(!r){g({catalog:[],registryCatalog:[],instances:[],registries:[],loading:!1,error:null});return}g(e=>({...e,loading:!0,error:null}));try{let[e,t,n]=await Promise.all([De(),Me(),je()]);g(r=>({catalog:e,registryCatalog:r.registryCatalog,instances:t,registries:n,loading:!1,error:null}))}catch(e){g({catalog:[],registryCatalog:[],instances:[],registries:[],loading:!1,error:e instanceof Error?e.message:String(e)})}},[r]);(0,H.useEffect)(()=>{Y()},[Y]);let Ae=c.toString(),Ne=(0,H.useRef)(Ae);(0,H.useEffect)(()=>{Ne.current!==Ae&&(Ne.current=Ae,P(c.get(ln)?.trim()||dn))},[c,Ae]);let Pe=(0,H.useMemo)(()=>[{id:un,displayName:t.storeSourceName},...h.registries],[t.storeSourceName,h.registries]);(0,H.useEffect)(()=>{if(Pe.length===0||Pe.some(e=>e.id===N))return;let e=Pe.some(e=>e.id===dn)?dn:Pe[0]?.id;e&&P(e)},[Pe,N]),(0,H.useEffect)(()=>{if(!N||N===c.get(ln))return;let e=new URLSearchParams(c);e.set(ln,N),Ne.current=e.toString(),d(e,{replace:!0})},[N,c,d]);let Ie=(0,H.useCallback)(async e=>{let t=j.trim(),n=e?.browse??!1,r=Math.max(e?.page??1,1),i=e?.append??!1;if(!(!s||N!==un&&!t&&!n)){b(!0),i?g(e=>({...e,error:null})):(D(1),A(void 0),g(e=>({...e,registryCatalog:[],error:null})));try{let e=N===un?await Oe({q:t||void 0,page:r,pageSize:24,sort:F===`source`?`newest`:`downloads`}).then(e=>({connectors:e.items.map(pn),totalPages:e.meta.totalPages})):await Fe(t,N,{browse:n,page:r});D(r),A(e.totalPages),g(t=>({...t,registryCatalog:i?[...t.registryCatalog,...e.connectors].filter((e,t,n)=>n.findIndex(t=>t.id===e.id)===t):e.connectors}))}catch(e){g(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{b(!1)}}},[F,s,j,N]);(0,H.useEffect)(()=>{if(p!==`marketplace`)return;let e=window.setTimeout(()=>{j.trim()?Ie():N&&Ie({browse:!0})},j.trim()?350:0);return()=>window.clearTimeout(e)},[N,j,Ie,h.loading,p]);let Le=(0,H.useMemo)(()=>new Set(h.instances.map(e=>e.connectorId)),[h.instances]),Re=(0,H.useMemo)(()=>new Map([...h.catalog,...h.registryCatalog].map(e=>[e.id,e])),[h.catalog,h.registryCatalog]),ze=(0,H.useCallback)(async e=>{S(!0),g(e=>({...e,error:null}));try{let n=await ke(e);if(n.requiresOAuth&&n.definition.id!==`github`)throw Error(t.storeOAuthUnsupported);z(Gt(n.definition,{packageName:n.packageName,version:n.version,permissions:n.permissions}))}catch(e){g(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{S(!1)}},[t.storeOAuthUnsupported]),Be=(0,H.useMemo)(()=>new Set(h.instances.flatMap(e=>e.materialized.type===`mcp`?[e.materialized.serverId]:[])),[h.instances]),Ve=(0,H.useCallback)(async e=>{if(!q||K===void 0)return;let t=J.filter(t=>t.clientKey!==e.clientKey);await gt({sessionIdleTtlMinutes:q.sessionIdleTtlMinutes,servers:t},ct(K)),await G(),await Y()},[K,J,Y,q,G]),He=(0,H.useCallback)(()=>{le({mode:`add`,row:Yt(J,Be)})},[J,Be]),Ue=(0,H.useCallback)(async()=>{if(!(!q||K===void 0||pe)){me(!0),_e(!1);try{await gt({sessionIdleTtlMinutes:de,servers:J},ct(K)),await G(),_e(!0),u({type:`success`,title:n.saved})}finally{me(!1)}}},[K,J,q,G,de,pe]),We=ue(e=>e.setPageHeader),Ge=ue(e=>e.clearPageHeader),Ke=(0,H.useMemo)(()=>(0,W.jsx)(nt,{loading:h.loading||v||x,searchQuery:j,setSearchQuery:M,onReloadClick:Y,onAddCustomServer:He,searchPlaceholder:p===`marketplace`?t.marketplaceSearchPlaceholder:p===`builtin`?t.builtinSearchPlaceholder:p===`user`?t.userSearchPlaceholder:t.configSearchPlaceholder,addLabel:t.addCustomServer,reloadLabel:t.reload}),[t,Y,He,v,j,h.loading,x,p]);(0,H.useLayoutEffect)(()=>(We({startExtra:null,main:(0,W.jsx)(`div`,{className:`min-w-0`,children:(0,W.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.title})}),end:Ke}),()=>Ge()),[Ge,t.title,Ke,We]);let qe=h.instances.length+J.length,Je=(0,H.useMemo)(()=>Zt(h.catalog.filter(e=>e.source===`builtin`),j,F),[F,j,h.catalog]),X=(0,H.useMemo)(()=>Zt(h.registryCatalog,j,F),[F,j,h.registryCatalog]),Ye=p===`marketplace`&&!!(k&&w<k),Xe=(0,H.useMemo)(()=>h.instances.filter(e=>Qt(e,j)),[j,h.instances]),Ze=(0,H.useMemo)(()=>J.filter(e=>$t(e,j)),[J,j]),Qe=(0,H.useMemo)(()=>h.instances.find(e=>e.instanceId===ne)??oe,[ne,oe,h.instances]),$e=Xe.length+Ze.length,et=[{id:`marketplace`,label:t.tabMarketplace},{id:`builtin`,label:t.tabBuiltin,count:Je.length},{id:`user`,label:t.tabUser,count:qe},{id:`config`,label:t.tabConfig}];return(0,W.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:(0,W.jsxs)(`div`,{className:`flex w-full flex-col gap-6 px-3 py-6 sm:px-5 xl:px-6`,children:[s?null:(0,W.jsx)(`p`,{className:`rounded-xl border border-edge bg-surface-panel px-4 py-3 text-sm text-fg-muted`,children:t.tokenHint}),(0,W.jsxs)(`section`,{className:`flex flex-col gap-4`,children:[(0,W.jsxs)(`div`,{className:`flex flex-col gap-3 border-b border-edge-subtle pb-3 sm:flex-row sm:items-center sm:justify-between dark:border-edge-subtle`,children:[(0,W.jsx)(xe,{items:et,activeTab:p,onChange:m,ariaLabel:t.navAria,tabIdPrefix:`connectors-tab`,panelIdPrefix:`connectors-panel`,className:`flex-wrap`}),(0,W.jsxs)(`div`,{className:`flex min-h-9 min-w-0 flex-wrap items-center gap-2 sm:justify-end`,children:[p===`marketplace`?(0,W.jsx)(`div`,{className:`inline-flex h-9 max-w-full shrink-0 overflow-x-auto rounded-lg border border-edge bg-surface-panel p-0.5 shadow-surface`,role:`group`,"aria-label":t.registrySourceAria,children:Pe.map(e=>(0,W.jsx)(`button`,{type:`button`,className:i(`shrink-0 rounded-md px-2.5 py-1.5 text-xs font-medium transition-colors`,R.focusRingPanel,N===e.id?`bg-fg text-surface-panel dark:bg-fg dark:text-surface-base`:`text-fg-muted hover:text-fg`),"aria-pressed":N===e.id,onClick:()=>P(e.id),children:e.displayName},e.id))}):null,p!==`user`&&p!==`config`?(0,W.jsxs)(E,{children:[(0,W.jsx)(ve,{asChild:!0,children:(0,W.jsxs)(`button`,{type:`button`,className:i(`inline-flex h-9 min-h-9 min-w-[9rem] shrink-0 items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 text-xs font-medium text-fg shadow-surface`,R.transition,R.focusRingPanel),children:[(0,W.jsx)(ee,{className:`size-3.5 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),(0,W.jsx)(`span`,{children:F===`name`?t.sortName:t.sortSource}),(0,W.jsx)(re,{className:`size-3.5 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0})]})}),(0,W.jsx)(C,{children:(0,W.jsxs)(O,{className:`z-50 min-w-[10rem] rounded-xl border border-edge bg-surface-panel p-1 shadow-popover dark:border-edge`,sideOffset:6,align:`end`,children:[(0,W.jsx)(y,{className:`cursor-pointer rounded-lg px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover data-[highlighted]:bg-surface-hover`,onSelect:()=>I(`name`),children:t.sortName}),(0,W.jsx)(y,{className:`cursor-pointer rounded-lg px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover data-[highlighted]:bg-surface-hover`,onSelect:()=>I(`source`),children:t.sortSource})]})})]}):null]})]}),h.error?(0,W.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:h.error}):null,p===`user`&&s?(0,W.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.installedTitle}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.installedHint})]}),h.loading?(0,W.jsx)(`div`,{className:`grid gap-3`,"aria-busy":`true`,"aria-label":t.loading,children:Se.slice(0,3).map(e=>(0,W.jsx)(Te,{},e))}):qe===0||$e===0?(0,W.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center text-sm text-fg-muted`,children:qe===0?t.installedEmpty:t.userEmpty}):(0,W.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:[Xe.map(e=>(0,W.jsx)(Bt,{instance:e,definition:Re.get(e.connectorId),onOpenDetails:e=>{ie(e.instanceId),se(e)},onChanged:Y,t},e.instanceId)),Ze.map(e=>(0,W.jsx)(wt,{row:e,t:n,cs:t,onEdit:()=>le({mode:`edit`,row:structuredClone(e)}),onRemove:async()=>Ve(e)},e.clientKey))]}),(0,W.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.disableHint})]}):null,p===`config`&&s?(0,W.jsx)(`div`,{className:`flex flex-col gap-4`,children:(0,W.jsxs)(be,{children:[(0,W.jsx)(ye,{icon:ge,title:n.globalTitle,subtitle:n.globalHint}),(0,W.jsx)(`div`,{className:`max-w-xl`,children:(0,W.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,W.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.idleTtlLabel}),(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`input`,{type:`number`,min:0,className:i(fn,`w-40 flex-none`),value:de??``,placeholder:n.idleTtlPlaceholder,onChange:e=>{let t=e.target.value.trim();fe(t===``?void 0:Number.parseInt(t,10)),_e(!1)}}),(0,W.jsxs)(_,{variant:`secondary`,disabled:pe,onClick:()=>void Ue(),children:[pe?(0,W.jsx)(T,{className:`size-4 animate-spin`}):null,n.save]})]}),(0,W.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:n.idleTtlHint})]})})]})}):null,p===`marketplace`&&s?(0,W.jsx)(`div`,{className:`flex flex-col gap-4`,children:v&&X.length===0?(0,W.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,"aria-busy":`true`,"aria-label":t.loading,children:Se.map(e=>(0,W.jsx)(we,{},e))}):j.trim()&&X.length===0?(0,W.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center text-sm text-fg-muted`,children:t.marketplaceEmpty}):!j.trim()&&X.length===0?(0,W.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center text-sm text-fg-muted`,children:t.marketplaceStartHint}):(0,W.jsxs)(`div`,{className:`relative`,children:[v?(0,W.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,W.jsx)(T,{className:`size-8 shrink-0 animate-spin text-accent motion-reduce:animate-none`,strokeWidth:2,"aria-hidden":!0})}):null,(0,W.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:X.map(e=>(0,W.jsx)(Ee,{connector:e,installed:Le.has(e.id)||Ce(e,h.instances),onInstall:e=>{if(e.source===`store`){ze(e.id);return}z(Gt(e))},onOpenDetails:e.source===`store`?void 0:V,t},e.id))}),Ye?(0,W.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,W.jsxs)(_,{type:`button`,variant:`secondary`,disabled:v||x,onClick:()=>void Ie({browse:!j.trim(),page:w+1,append:!0}),children:[v?(0,W.jsx)(T,{className:`size-4 animate-spin`}):null,t.loadMore]})}):null]})}):null,p===`builtin`&&s?(0,W.jsx)(`div`,{className:`flex flex-col gap-4`,children:h.loading?(0,W.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,"aria-busy":`true`,"aria-label":t.loading,children:Se.map(e=>(0,W.jsx)(we,{},e))}):Je.length===0?(0,W.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center text-sm text-fg-muted`,children:t.builtinEmpty}):(0,W.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:Je.map(e=>(0,W.jsx)(Ee,{connector:e,installed:Le.has(e.id)||Ce(e,h.instances),onInstall:e=>z(Gt(e)),onOpenDetails:V,t},e.id))})}):null]}),L?(0,W.jsx)(Jt,{draft:L,onChange:z,onClose:()=>z(null),t,onInstalled:async()=>{await Y(),await G(),m(`user`)}}):null,B?(0,W.jsx)(tt,{connector:B,installed:Le.has(B.id)||Ce(B,h.instances),onClose:()=>V(null),onInstall:e=>z(Gt(e)),t}):null,Qe?(0,W.jsx)(zt,{instance:Qe,definition:Re.get(Qe.connectorId),onClose:()=>{ie(null),se(null)},onChanged:Y,t,mcp:n}):null,ce?(0,W.jsx)(cn,{open:!0,mode:ce.mode,initialRow:ce.row,existingCustomServers:J,sessionIdleTtlMinutes:de,config:K,managedServerIds:Be,t:n,cs:t,onClose:()=>le(null),onSaved:async()=>{await G(),await Y(),m(`user`)}},`${ce.mode}-${ce.row.clientKey}`):null]})})}export{mn as ConnectorsPage};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./messages-CQ_k8RHj.js";import{n as a}from"./locale-store-Ba72bFmP.js";import{il as o,ko as s,t as c}from"./index-DZOm5_ex.js";import{t as l}from"./desktop-pet-sprite-DqZ6fbIj.js";var u=e(t(),1),d=n();function f(e){return e?`/chat/${e.sessionKey}`:void 0}var p=r(),m=8e3,h=9e4,g=3e4,_=20*6e4,v=45*6e4,y=58;function b(e){let t={error:0,waiting:1,running:2,success:3};return e.sort((e,n)=>t[e.state]-t[n.state]||n.timestamp-e.timestamp).slice(0,3)}function x(e,t){return e.state===`running`&&t-(e.startedAt??e.timestamp)>=h}function S(e,t){return e.state===`running`&&t-e.timestamp>=g}function C(e,t,n){return S(e,n)||t===`chatty`||x(e,n)&&t===`normal`?!0:t===`quiet`?e.priority===`high`||e.state===`waiting`||e.state===`error`:e.priority!==`low`}function w(e){return e?e.state===`error`?`error`:e.state===`success`?`success`:e.animation??c(e.phase):`idle`}function T(e,t){return e.replace(/\{\{detail\}\}/g,t)}function E(e){return e.replace(/\s+/g,` `).trim()}function D(e){let t=E(e);return t.length>y?`${t.slice(0,y-1)}…`:t}function O(e,t,n){if(e.progress){let t=`${e.progress.completed}/${e.progress.total}`;return e.action.includes(t)?``:` · ${t}`}return e.outputLines?.length?T(n,e.outputLines[Math.floor((t-e.timestamp)/1800)%e.outputLines.length]):e.outputTail?T(n,e.outputTail):e.detail&&!e.action.includes(e.detail)?T(n,e.detail):e.state===`running`?` · ${Math.max(1,Math.floor((t-e.timestamp)/1e3))}s`:``}function k(e,t){if(e.state!==`success`)return;let n=e.outputLines?.map(E).filter(Boolean).at(-1)??e.outputTail;if(n)return t.replace(/\{\{summary\}\}/g,D(n))}function A(e,t,n){if(S(e,t))return n.stale;if(x(e,t))return n.longRunning}function j(e,t){if(e.state===`waiting`)return t.needsInput;if(e.state===`error`)return t.reviewIssue;if(e.state===`success`)return t.open}function M(e){let t=e.now-e.lastActivityAt;return e.bubbleEnabled&&e.feedbackLevel!==`quiet`&&!e.collapsed&&e.queuedCount===0&&e.activeCount===0&&t>=_&&t<=1245e3&&e.now>=e.dismissedUntil}function N(){return{prefs:{enabled:!0,showOnStartup:!1,selectedPetId:`ember`,alwaysOnTop:!0,bubbleEnabled:!0,clickThroughWhenIdle:!1,muted:!1,feedbackLevel:`normal`,sizePercent:100,collapsed:!1},pets:[],visible:!0,customPetsDir:``,petIssues:[]}}function P(){let e=i(a(e=>e.language)).desktopPet,[t,n]=(0,u.useState)(N),[r,c]=(0,u.useState)({}),[d,h]=(0,u.useState)(()=>new Set),[g,_]=(0,u.useState)(Date.now()),[y,x]=(0,u.useState)(()=>Date.now()),[S,T]=(0,u.useState)(0),E=(0,u.useRef)(null),D=(0,u.useRef)(!1),P=(0,u.useRef)(null),F=(0,u.useRef)(null),I=(0,u.useRef)(null),L=(0,u.useMemo)(()=>t.pets.find(e=>e.id===t.prefs.selectedPetId)??t.pets[0],[t]),R=Math.min(1.4,Math.max(.7,t.prefs.sizePercent/100)),z=(0,u.useMemo)(()=>b(Object.values(r).filter(e=>!e.expiresAt||e.expiresAt>g)),[r,g]),B=(0,u.useMemo)(()=>t.prefs.bubbleEnabled?z.filter(e=>!d.has(e.sessionKey)&&C(e,t.prefs.feedbackLevel,g)):[],[z,d,g,t.prefs.bubbleEnabled,t.prefs.feedbackLevel]),V=(0,u.useMemo)(()=>t.prefs.bubbleEnabled?z.filter(e=>d.has(e.sessionKey)&&C(e,t.prefs.feedbackLevel,g)).length:0,[z,d,g,t.prefs.bubbleEnabled,t.prefs.feedbackLevel]),H=B[0]??z[0],U=w(H),W=M({bubbleEnabled:t.prefs.bubbleEnabled,feedbackLevel:t.prefs.feedbackLevel,collapsed:t.prefs.collapsed,queuedCount:B.length,activeCount:z.length,now:g,lastActivityAt:y,dismissedUntil:S});(0,u.useEffect)(()=>{document.documentElement.dataset.desktopPet=`true`;let e=window.electronAPI?.pet;if(!e)return;e.getState().then(n).catch(()=>{});let t=e.onStateChanged(n),r=e.onEvent(e=>c(t=>{x(Date.now());let n=t[e.sessionKey];return n&&e.sequence<=n.sequence?t:{...t,[e.sessionKey]:{...n,...e,startedAt:n?.startedAt??e.timestamp,outputLines:e.outputLines??n?.outputLines,expiresAt:e.state===`success`?Date.now()+m:void 0}}})),i=window.setInterval(()=>_(Date.now()),1e3);return()=>{delete document.documentElement.dataset.desktopPet,t(),r(),window.clearInterval(i)}},[]),(0,u.useLayoutEffect)(()=>{let e=P.current,t=window.electronAPI?.pet;if(!e||!t)return;let n=()=>{let e=[F.current,I.current].filter(e=>e!==null).map(e=>e.getBoundingClientRect());if(!e.length)return;let n=Math.min(...e.map(e=>e.left)),r=Math.min(...e.map(e=>e.top)),i=Math.max(...e.map(e=>e.right)),a=Math.max(...e.map(e=>e.bottom));t.setContentSize({width:Math.ceil(i-n),height:Math.ceil(a-r)})},r=new ResizeObserver(n);return r.observe(e),F.current&&r.observe(F.current),I.current&&r.observe(I.current),n(),()=>r.disconnect()},[W,B.length,t.prefs.collapsed,R]);let G=(e=H)=>{e?.state===`success`&&c(t=>{let{[e.sessionKey]:n,...r}=t;return r}),window.electronAPI?.pet?.openMainWindow(f(e))},K=async()=>{if(d.size>0&&(h(new Set),!t.prefs.collapsed))return;let e=await window.electronAPI?.pet?.setPrefs({collapsed:!t.prefs.collapsed});e&&n(e)},q=(0,u.useCallback)(e=>{e.button===0&&(E.current={pointerId:e.pointerId,x:e.clientX,y:e.clientY,moved:!1},e.currentTarget.setPointerCapture(e.pointerId),window.electronAPI?.pet?.startDrag({screenX:e.screenX,screenY:e.screenY}))},[]),J=(0,u.useCallback)(e=>{let t=E.current;!t||t.pointerId!==e.pointerId||Math.abs(e.clientX-t.x)+Math.abs(e.clientY-t.y)>4&&(t.moved=!0,window.electronAPI?.pet?.drag({screenX:e.screenX,screenY:e.screenY}))},[]),Y=(0,u.useCallback)(e=>{let t=E.current;!t||t.pointerId!==e.pointerId||(E.current=null,window.electronAPI?.pet?.endDrag(),t.moved&&(D.current=!0,window.setTimeout(()=>{D.current=!1},0)))},[]),X=()=>{D.current||G()};if(!L)return null;let Z={"--desktop-pet-stage-size":`${Math.round(132*R)}px`,"--desktop-pet-menu-size":`${Math.round(28*R)}px`,"--desktop-pet-menu-left":`0px`,"--desktop-pet-menu-bottom":`${Math.round(12*R)}px`},Q=t.prefs.collapsed?B.length:V;return(0,p.jsxs)(`div`,{ref:P,className:`desktop-pet-window`,style:Z,children:[!t.prefs.collapsed&&B.length>0?(0,p.jsx)(`div`,{ref:F,className:`desktop-pet-bubble desktop-pet-queue`,children:B.map(t=>{let n=A(t,g,{longRunning:e.tipLongRunning,stale:e.tipStaleSignal}),r=k(t,e.tipCompleteSummary),i=j(t,{open:e.viewSession,needsInput:e.petCtaNeedsInput,reviewIssue:e.petCtaReviewIssue});return(0,p.jsxs)(`div`,{className:`desktop-pet-session desktop-pet-session--${t.state}${n?` desktop-pet-session--health`:``}`,children:[(0,p.jsxs)(`button`,{type:`button`,className:`desktop-pet-session-open`,onClick:()=>G(t),children:[(0,p.jsx)(`span`,{className:`desktop-pet-session-dot`}),(0,p.jsxs)(`span`,{className:`desktop-pet-session-main`,children:[(0,p.jsx)(`strong`,{children:t.sessionLabel}),(0,p.jsxs)(`span`,{children:[r??n??t.action,r||n?``:O(t,g,e.tipTargetSuffix)]})]}),i?(0,p.jsx)(`span`,{className:`desktop-pet-session-cta`,children:i}):null]}),(0,p.jsx)(`button`,{type:`button`,className:`desktop-pet-session-close`,"aria-label":`收起会话`,onClick:()=>h(e=>new Set(e).add(t.sessionKey)),children:(0,p.jsx)(s,{size:12})})]},t.sessionKey)})}):null,W?(0,p.jsx)(`div`,{ref:F,className:`desktop-pet-bubble desktop-pet-queue desktop-pet-idle-tip`,children:(0,p.jsxs)(`div`,{className:`desktop-pet-session desktop-pet-session--idle`,children:[(0,p.jsxs)(`button`,{type:`button`,className:`desktop-pet-session-open`,onClick:()=>G(),children:[(0,p.jsx)(`span`,{className:`desktop-pet-session-dot`}),(0,p.jsxs)(`span`,{className:`desktop-pet-session-main`,children:[(0,p.jsx)(`strong`,{children:e.idleTipTitle}),(0,p.jsx)(`span`,{children:e.idleTipBody})]})]}),(0,p.jsx)(`button`,{type:`button`,className:`desktop-pet-session-close`,"aria-label":`收起会话`,onClick:()=>T(Date.now()+v),children:(0,p.jsx)(s,{size:12})})]})}):null,(0,p.jsxs)(`div`,{ref:I,className:`desktop-pet-stage`,children:[(0,p.jsx)(`button`,{type:`button`,className:`desktop-pet-menu-button`,onClick:()=>void K(),"aria-label":e.menu,children:Q>0?(0,p.jsx)(`span`,{className:`desktop-pet-tip-count`,children:Math.min(99,Q)}):(0,p.jsx)(o,{className:`desktop-pet-menu-chevron size-4`})}),(0,p.jsx)(`button`,{type:`button`,className:`desktop-pet-hit-area`,onClick:X,onPointerDown:q,onPointerMove:J,onPointerUp:Y,onPointerCancel:Y,title:e.openApp,children:(0,p.jsx)(l,{pet:L,action:U,displayHeight:Math.round(112*R)})})]})]})}function F(){let e=(0,d.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,p.jsx)(P,{}),e[0]=t):t=e[0],t}export{F as DesktopPetPage};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./messages-DbNQuFdA.js";import{n as a}from"./locale-store-Ba72bFmP.js";import{il as o,ko as s,t as c}from"./index-NwiCnzI-.js";import{t as l}from"./desktop-pet-sprite-DqZ6fbIj.js";var u=e(t(),1),d=n();function f(e){return e?`/chat/${e.sessionKey}`:void 0}var p=r(),m=8e3,h=9e4,g=3e4,_=20*6e4,v=45*6e4,y=58;function b(e){let t={error:0,waiting:1,running:2,success:3};return e.sort((e,n)=>t[e.state]-t[n.state]||n.timestamp-e.timestamp).slice(0,3)}function x(e,t){return e.state===`running`&&t-(e.startedAt??e.timestamp)>=h}function S(e,t){return e.state===`running`&&t-e.timestamp>=g}function C(e,t,n){return S(e,n)||t===`chatty`||x(e,n)&&t===`normal`?!0:t===`quiet`?e.priority===`high`||e.state===`waiting`||e.state===`error`:e.priority!==`low`}function w(e){return e?e.state===`error`?`error`:e.state===`success`?`success`:e.animation??c(e.phase):`idle`}function T(e,t){return e.replace(/\{\{detail\}\}/g,t)}function E(e){return e.replace(/\s+/g,` `).trim()}function D(e){let t=E(e);return t.length>y?`${t.slice(0,y-1)}…`:t}function O(e,t,n){if(e.progress){let t=`${e.progress.completed}/${e.progress.total}`;return e.action.includes(t)?``:` · ${t}`}return e.outputLines?.length?T(n,e.outputLines[Math.floor((t-e.timestamp)/1800)%e.outputLines.length]):e.outputTail?T(n,e.outputTail):e.detail&&!e.action.includes(e.detail)?T(n,e.detail):e.state===`running`?` · ${Math.max(1,Math.floor((t-e.timestamp)/1e3))}s`:``}function k(e,t){if(e.state!==`success`)return;let n=e.outputLines?.map(E).filter(Boolean).at(-1)??e.outputTail;if(n)return t.replace(/\{\{summary\}\}/g,D(n))}function A(e,t,n){if(S(e,t))return n.stale;if(x(e,t))return n.longRunning}function j(e,t){if(e.state===`waiting`)return t.needsInput;if(e.state===`error`)return t.reviewIssue;if(e.state===`success`)return t.open}function M(e){let t=e.now-e.lastActivityAt;return e.bubbleEnabled&&e.feedbackLevel!==`quiet`&&!e.collapsed&&e.queuedCount===0&&e.activeCount===0&&t>=_&&t<=1245e3&&e.now>=e.dismissedUntil}function N(){return{prefs:{enabled:!0,showOnStartup:!1,selectedPetId:`ember`,alwaysOnTop:!0,bubbleEnabled:!0,clickThroughWhenIdle:!1,muted:!1,feedbackLevel:`normal`,sizePercent:100,collapsed:!1},pets:[],visible:!0,customPetsDir:``,petIssues:[]}}function P(){let e=i(a(e=>e.language)).desktopPet,[t,n]=(0,u.useState)(N),[r,c]=(0,u.useState)({}),[d,h]=(0,u.useState)(()=>new Set),[g,_]=(0,u.useState)(Date.now()),[y,x]=(0,u.useState)(()=>Date.now()),[S,T]=(0,u.useState)(0),E=(0,u.useRef)(null),D=(0,u.useRef)(!1),P=(0,u.useRef)(null),F=(0,u.useRef)(null),I=(0,u.useRef)(null),L=(0,u.useMemo)(()=>t.pets.find(e=>e.id===t.prefs.selectedPetId)??t.pets[0],[t]),R=Math.min(1.4,Math.max(.7,t.prefs.sizePercent/100)),z=(0,u.useMemo)(()=>b(Object.values(r).filter(e=>!e.expiresAt||e.expiresAt>g)),[r,g]),B=(0,u.useMemo)(()=>t.prefs.bubbleEnabled?z.filter(e=>!d.has(e.sessionKey)&&C(e,t.prefs.feedbackLevel,g)):[],[z,d,g,t.prefs.bubbleEnabled,t.prefs.feedbackLevel]),V=(0,u.useMemo)(()=>t.prefs.bubbleEnabled?z.filter(e=>d.has(e.sessionKey)&&C(e,t.prefs.feedbackLevel,g)).length:0,[z,d,g,t.prefs.bubbleEnabled,t.prefs.feedbackLevel]),H=B[0]??z[0],U=w(H),W=M({bubbleEnabled:t.prefs.bubbleEnabled,feedbackLevel:t.prefs.feedbackLevel,collapsed:t.prefs.collapsed,queuedCount:B.length,activeCount:z.length,now:g,lastActivityAt:y,dismissedUntil:S});(0,u.useEffect)(()=>{document.documentElement.dataset.desktopPet=`true`;let e=window.electronAPI?.pet;if(!e)return;e.getState().then(n).catch(()=>{});let t=e.onStateChanged(n),r=e.onEvent(e=>c(t=>{x(Date.now());let n=t[e.sessionKey];return n&&e.sequence<=n.sequence?t:{...t,[e.sessionKey]:{...n,...e,startedAt:n?.startedAt??e.timestamp,outputLines:e.outputLines??n?.outputLines,expiresAt:e.state===`success`?Date.now()+m:void 0}}})),i=window.setInterval(()=>_(Date.now()),1e3);return()=>{delete document.documentElement.dataset.desktopPet,t(),r(),window.clearInterval(i)}},[]),(0,u.useLayoutEffect)(()=>{let e=P.current,t=window.electronAPI?.pet;if(!e||!t)return;let n=()=>{let e=[F.current,I.current].filter(e=>e!==null).map(e=>e.getBoundingClientRect());if(!e.length)return;let n=Math.min(...e.map(e=>e.left)),r=Math.min(...e.map(e=>e.top)),i=Math.max(...e.map(e=>e.right)),a=Math.max(...e.map(e=>e.bottom));t.setContentSize({width:Math.ceil(i-n),height:Math.ceil(a-r)})},r=new ResizeObserver(n);return r.observe(e),F.current&&r.observe(F.current),I.current&&r.observe(I.current),n(),()=>r.disconnect()},[W,B.length,t.prefs.collapsed,R]);let G=(e=H)=>{e?.state===`success`&&c(t=>{let{[e.sessionKey]:n,...r}=t;return r}),window.electronAPI?.pet?.openMainWindow(f(e))},K=async()=>{if(d.size>0&&(h(new Set),!t.prefs.collapsed))return;let e=await window.electronAPI?.pet?.setPrefs({collapsed:!t.prefs.collapsed});e&&n(e)},q=(0,u.useCallback)(e=>{e.button===0&&(E.current={pointerId:e.pointerId,x:e.clientX,y:e.clientY,moved:!1},e.currentTarget.setPointerCapture(e.pointerId),window.electronAPI?.pet?.startDrag({screenX:e.screenX,screenY:e.screenY}))},[]),J=(0,u.useCallback)(e=>{let t=E.current;!t||t.pointerId!==e.pointerId||Math.abs(e.clientX-t.x)+Math.abs(e.clientY-t.y)>4&&(t.moved=!0,window.electronAPI?.pet?.drag({screenX:e.screenX,screenY:e.screenY}))},[]),Y=(0,u.useCallback)(e=>{let t=E.current;!t||t.pointerId!==e.pointerId||(E.current=null,window.electronAPI?.pet?.endDrag(),t.moved&&(D.current=!0,window.setTimeout(()=>{D.current=!1},0)))},[]),X=()=>{D.current||G()},Z=()=>{window.electronAPI?.pet?.hide()};if(!L)return null;let Q={"--desktop-pet-stage-size":`${Math.round(132*R)}px`,"--desktop-pet-menu-size":`${Math.round(28*R)}px`,"--desktop-pet-menu-left":`0px`,"--desktop-pet-menu-bottom":`${Math.round(12*R)}px`},$=t.prefs.collapsed?B.length:V;return(0,p.jsxs)(`div`,{ref:P,className:`desktop-pet-window`,style:Q,children:[!t.prefs.collapsed&&B.length>0?(0,p.jsx)(`div`,{ref:F,className:`desktop-pet-bubble desktop-pet-queue`,children:B.map(t=>{let n=A(t,g,{longRunning:e.tipLongRunning,stale:e.tipStaleSignal}),r=k(t,e.tipCompleteSummary),i=j(t,{open:e.viewSession,needsInput:e.petCtaNeedsInput,reviewIssue:e.petCtaReviewIssue});return(0,p.jsxs)(`div`,{className:`desktop-pet-session desktop-pet-session--${t.state}${n?` desktop-pet-session--health`:``}`,children:[(0,p.jsxs)(`button`,{type:`button`,className:`desktop-pet-session-open`,onClick:()=>G(t),children:[(0,p.jsx)(`span`,{className:`desktop-pet-session-dot`}),(0,p.jsxs)(`span`,{className:`desktop-pet-session-main`,children:[(0,p.jsx)(`strong`,{children:t.sessionLabel}),(0,p.jsxs)(`span`,{children:[r??n??t.action,r||n?``:O(t,g,e.tipTargetSuffix)]})]}),i?(0,p.jsx)(`span`,{className:`desktop-pet-session-cta`,children:i}):null]}),(0,p.jsx)(`button`,{type:`button`,className:`desktop-pet-session-close`,"aria-label":`收起会话`,onClick:()=>h(e=>new Set(e).add(t.sessionKey)),children:(0,p.jsx)(s,{size:12})})]},t.sessionKey)})}):null,W?(0,p.jsx)(`div`,{ref:F,className:`desktop-pet-bubble desktop-pet-queue desktop-pet-idle-tip`,children:(0,p.jsxs)(`div`,{className:`desktop-pet-session desktop-pet-session--idle`,children:[(0,p.jsxs)(`button`,{type:`button`,className:`desktop-pet-session-open`,onClick:()=>G(),children:[(0,p.jsx)(`span`,{className:`desktop-pet-session-dot`}),(0,p.jsxs)(`span`,{className:`desktop-pet-session-main`,children:[(0,p.jsx)(`strong`,{children:e.idleTipTitle}),(0,p.jsx)(`span`,{children:e.idleTipBody})]})]}),(0,p.jsx)(`button`,{type:`button`,className:`desktop-pet-session-close`,"aria-label":`收起会话`,onClick:()=>T(Date.now()+v),children:(0,p.jsx)(s,{size:12})})]})}):null,(0,p.jsxs)(`div`,{ref:I,className:`desktop-pet-stage`,children:[(0,p.jsx)(`button`,{type:`button`,className:`desktop-pet-menu-button`,onClick:()=>void K(),"aria-label":e.menu,children:$>0?(0,p.jsx)(`span`,{className:`desktop-pet-tip-count`,children:Math.min(99,$)}):(0,p.jsx)(o,{className:`desktop-pet-menu-chevron size-4`})}),(0,p.jsx)(`button`,{type:`button`,className:`desktop-pet-close-button`,onClick:Z,"aria-label":e.hide,title:e.hide,children:(0,p.jsx)(s,{size:14})}),(0,p.jsx)(`button`,{type:`button`,className:`desktop-pet-hit-area`,onClick:X,onPointerDown:q,onPointerMove:J,onPointerUp:Y,onPointerCancel:Y,title:e.openApp,children:(0,p.jsx)(l,{pet:L,action:U,displayHeight:Math.round(112*R)})})]})]})}function F(){let e=(0,d.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,p.jsx)(P,{}),e[0]=t):t=e[0],t}export{F as DesktopPetPage};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-CQ_k8RHj.js";import{n as o}from"./locale-store-Ba72bFmP.js";import{Ac as s,As as c,Dl as l,Hs as u,Ja as d,Mo as f,_s as p,bo as m,hs as h,ro as g,tl as _,to as v}from"./index-DZOm5_ex.js";import{t as y}from"./desktop-pet-sprite-DqZ6fbIj.js";import{n as b,t as x}from"./settings-page-layout-CrICyGob.js";var S=n(),C=e(t(),1),w=r();function T(e){let t=(0,S.c)(16),{title:n,desc:r,checked:i,disabled:a,onChange:o}=e,s;t[0]===n?s=t[1]:(s=(0,w.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=s);let c;t[2]===r?c=t[3]:(c=(0,w.jsx)(`p`,{className:`text-xs text-fg-muted`,children:r}),t[2]=r,t[3]=c);let l;t[4]!==s||t[5]!==c?(l=(0,w.jsxs)(`div`,{className:`min-w-0`,children:[s,c]}),t[4]=s,t[5]=c,t[6]=l):l=t[6];let u;t[7]===o?u=t[8]:(u=e=>o(e.target.checked),t[7]=o,t[8]=u);let d;t[9]!==i||t[10]!==a||t[11]!==u?(d=(0,w.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:a,checked:i,onChange:u}),t[9]=i,t[10]=a,t[11]=u,t[12]=d):d=t[12];let f;return t[13]!==l||t[14]!==d?(f=(0,w.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[l,d]}),t[13]=l,t[14]=d,t[15]=f):f=t[15],f}function E(){let e=a(o(e=>e.language)).desktopPetSettings,t=l(),[n,r]=(0,C.useState)(null),[S,E]=(0,C.useState)(!1),[D,O]=(0,C.useState)(null),k=typeof window<`u`?window.electronAPI?.pet:void 0,A=(0,C.useMemo)(()=>n?.pets.find(e=>e.id===n.prefs.selectedPetId)??n?.pets[0],[n]),j=(0,C.useCallback)(async()=>{if(k){E(!0);try{r(await k.getState())}finally{E(!1)}}},[k]);if((0,C.useEffect)(()=>{if(k)return j(),k.onStateChanged(r)},[k,j]),!d()||!k)return null;if(!n)return(0,w.jsxs)(x,{gap:`gap-4`,children:[(0,w.jsx)(b,{title:e.title,subtitle:e.subtitle}),(0,w.jsx)(`section`,{className:`rounded-xl border border-edge bg-surface-base p-4 text-sm text-fg-muted`,children:e.loading})]});let M=async e=>{E(!0);try{r(await k.setPrefs(e))}finally{E(!1)}},N=async e=>{e?(await k.show(),r(await k.getState())):r(await k.setPrefs({enabled:!1}))},P=e=>{M({selectedPetId:e})},F=t=>{if(t.builtin&&t.i18nKey){let n=e.builtinPets[t.i18nKey];if(n)return n}return{name:t.name,description:t.description}},I=e=>{t({pathname:`/chat/new`,search:`?draft=${encodeURIComponent(e)}`})},L=e=>{if(e.sourcePrompt?.trim())return e.sourcePrompt.trim();let{description:t}=F(e);return t.replace(/^Custom pet generated from:\s*/i,``).trim()||t},R=(e,t)=>Object.entries(t).reduce((e,[t,n])=>e.split(`{${t}}`).join(n),e),z=()=>{I(e.createChatDraft)},B=t=>{I(R(e.optimizeChatDraft,{id:t.id,name:F(t).name,description:F(t).description,sourcePrompt:L(t)}))},V=t=>{I(R(e.fixChatDraft,{dir:t.dir,reason:t.reason,details:t.details?.join(`; `)||e.noIssueDetails}))},H=D??n.prefs.sizePercent,U=async(e=H)=>{let t=Math.min(140,Math.max(70,Math.round(e/5)*5));O(null),t!==n.prefs.sizePercent&&await M({sizePercent:t})};return(0,w.jsxs)(x,{gap:`gap-4`,children:[(0,w.jsx)(b,{title:e.title,subtitle:e.subtitle,actions:(0,w.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:[(0,w.jsxs)(`button`,{type:`button`,className:i(`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`,m.press),disabled:S,onClick:()=>void j(),children:[(0,w.jsx)(p,{className:i(`size-3.5`,S&&`animate-spin`),strokeWidth:1.75}),e.refresh]}),(0,w.jsxs)(`button`,{type:`button`,className:i(`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover`,m.press),onClick:()=>void k.openCustomPetsDir(),children:[(0,w.jsx)(s,{className:`size-3.5`,strokeWidth:1.75}),e.openFolder]})]})}),(0,w.jsxs)(`section`,{className:`rounded-xl border border-edge bg-surface-base p-4 shadow-surface`,children:[(0,w.jsxs)(`div`,{className:`space-y-2`,children:[(0,w.jsx)(T,{title:e.enable,desc:e.enableDesc,checked:n.prefs.enabled,disabled:S,onChange:e=>void N(e)}),(0,w.jsx)(T,{title:e.showOnStartup,desc:e.showOnStartupDesc,checked:n.prefs.showOnStartup,disabled:S,onChange:e=>void M({showOnStartup:e})})]}),(0,w.jsx)(`div`,{className:`mt-5 rounded-xl border border-edge-subtle bg-surface-panel p-3`,children:(0,w.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,w.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[(0,w.jsx)(f,{className:`mt-0.5 size-4 text-accent-fg`,strokeWidth:1.8}),(0,w.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,w.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:e.createTitle}),(0,w.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.createDesc})]})]}),(0,w.jsxs)(`button`,{type:`button`,className:i(`inline-flex h-9 shrink-0 items-center justify-center gap-1.5 rounded-lg bg-accent px-3 text-xs font-semibold text-white hover:bg-accent/90`,m.press),onClick:z,children:[(0,w.jsx)(u,{className:`size-3.5`,strokeWidth:1.75}),e.createInChat]})]})}),(0,w.jsxs)(`div`,{className:`mt-5`,children:[(0,w.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:e.petList}),(0,w.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.petListDesc})]}),A?(0,w.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2.5 py-1 text-xs font-medium text-accent-fg`,children:F(A).name}):null]}),(0,w.jsxs)(`div`,{className:`divide-y divide-edge-subtle rounded-xl border border-edge bg-surface-base`,children:[n.pets.map(t=>{let r=t.id===n.prefs.selectedPetId,a=F(t);return(0,w.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-3`,children:[(0,w.jsx)(y,{pet:t,action:`idle`,size:`tiny`}),(0,w.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,w.jsx)(`p`,{className:`truncate text-sm font-semibold text-fg`,children:a.name}),t.builtin?null:(0,w.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:e.customBadge})]}),(0,w.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:a.description})]}),(0,w.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[t.builtin?null:(0,w.jsxs)(`button`,{type:`button`,className:i(`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover`,m.press),onClick:()=>B(t),children:[(0,w.jsx)(c,{className:`size-3.5`,strokeWidth:1.75}),e.optimizeInChat]}),(0,w.jsx)(`button`,{type:`button`,className:i(`rounded-lg px-2.5 py-1.5 text-xs font-medium transition-colors`,r?`bg-surface-hover text-fg-muted`:`bg-surface-panel text-fg hover:bg-surface-hover`,m.press),disabled:r||S,onClick:()=>P(t.id),children:r?e.selected:e.select})]})]},t.id)}),(0,w.jsxs)(`div`,{className:`flex flex-col gap-1 px-3 py-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`p`,{className:`text-xs font-semibold text-fg`,children:e.customPets}),(0,w.jsx)(`p`,{className:`font-mono text-xs text-fg-muted`,children:n.customPetsDir})]}),(0,w.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 text-xs font-medium text-fg-muted hover:text-fg`,onClick:()=>void k.openCustomPetsDir(),children:[e.openFolder,(0,w.jsx)(s,{className:`size-3.5`,strokeWidth:1.75})]})]})]}),n.petIssues.length>0?(0,w.jsxs)(`div`,{className:`mt-2 rounded-xl border border-danger/30 bg-danger/5 p-3`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-semibold text-danger`,children:[(0,w.jsx)(_,{className:`size-3.5`,strokeWidth:1.8}),e.invalidPets]}),(0,w.jsx)(`div`,{className:`mt-2 space-y-2`,children:n.petIssues.map(t=>(0,w.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg bg-surface-base/70 p-2 text-xs text-fg-muted sm:flex-row sm:items-start sm:justify-between`,children:[(0,w.jsxs)(`div`,{className:`min-w-0`,children:[(0,w.jsx)(`p`,{className:`truncate font-mono text-[11px] text-fg`,children:t.dir}),(0,w.jsx)(`p`,{children:t.reason}),t.details?.length?(0,w.jsx)(`p`,{className:`line-clamp-2`,children:t.details.join(`; `)}):null]}),(0,w.jsxs)(`button`,{type:`button`,className:i(`inline-flex h-8 shrink-0 items-center justify-center gap-1.5 rounded-lg border border-danger/30 bg-surface-base px-2.5 text-xs font-medium text-danger hover:bg-danger/10`,m.press),onClick:()=>V(t),children:[(0,w.jsx)(u,{className:`size-3.5`,strokeWidth:1.75}),e.fixInChat]})]},`${t.dir}-${t.reason}`))})]}):null]}),(0,w.jsxs)(`div`,{className:`mt-5 grid gap-2`,children:[(0,w.jsxs)(`div`,{className:`rounded-xl bg-surface-hover/50 px-3 py-3 dark:bg-surface-hover/35`,children:[(0,w.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.size}),(0,w.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.sizeDesc})]}),(0,w.jsxs)(`span`,{className:`text-xs font-medium text-fg-muted`,children:[H,`%`]})]}),(0,w.jsx)(`input`,{type:`range`,min:70,max:140,step:5,className:`mt-3 w-full accent-accent`,value:H,onChange:e=>O(Number(e.target.value)),onBlur:()=>void U(),onKeyUp:e=>{(e.key===`Enter`||e.key===` `||e.key.startsWith(`Arrow`))&&U()},onPointerUp:()=>void U()})]}),(0,w.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:[(0,w.jsx)(T,{title:e.alwaysOnTop,desc:e.alwaysOnTopDesc,checked:n.prefs.alwaysOnTop,disabled:S,onChange:e=>void M({alwaysOnTop:e})}),(0,w.jsx)(T,{title:e.bubbles,desc:e.bubblesDesc,checked:n.prefs.bubbleEnabled,disabled:S,onChange:e=>void M({bubbleEnabled:e})})]}),(0,w.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-xl bg-surface-hover/50 px-3 py-3 dark:bg-surface-hover/35 sm:flex-row sm:items-center sm:justify-between`,children:[(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.feedbackLevel}),(0,w.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.feedbackLevelDesc})]}),(0,w.jsxs)(v,{className:`w-full sm:w-40`,triggerClassName:`h-9 bg-surface-panel`,value:n.prefs.feedbackLevel,onChange:e=>void M({feedbackLevel:e.target.value}),children:[(0,w.jsx)(g,{value:`quiet`,children:e.feedbackQuiet}),(0,w.jsx)(g,{value:`normal`,children:e.feedbackNormal}),(0,w.jsx)(g,{value:`chatty`,children:e.feedbackChatty})]})]}),(0,w.jsxs)(`button`,{type:`button`,className:i(`inline-flex w-fit items-center gap-1.5 rounded-lg border border-edge bg-surface-base px-3 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`,m.press),disabled:S,onClick:()=>void k.resetPosition().then(r),children:[(0,w.jsx)(h,{className:`size-3.5`,strokeWidth:1.75}),e.resetPosition]})]})]})]})}export{E as DesktopPetSettings};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-DbNQuFdA.js";import{n as o}from"./locale-store-Ba72bFmP.js";import{Ac as s,As as c,Dl as l,Hs as u,Ja as d,Mo as f,_s as p,bo as m,hs as h,ro as g,tl as _,to as v}from"./index-NwiCnzI-.js";import{t as y}from"./desktop-pet-sprite-DqZ6fbIj.js";import{n as b,t as x}from"./settings-page-layout-R-6ArlMI.js";var S=n(),C=e(t(),1),w=r();function T(e){let t=(0,S.c)(16),{title:n,desc:r,checked:i,disabled:a,onChange:o}=e,s;t[0]===n?s=t[1]:(s=(0,w.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=s);let c;t[2]===r?c=t[3]:(c=(0,w.jsx)(`p`,{className:`text-xs text-fg-muted`,children:r}),t[2]=r,t[3]=c);let l;t[4]!==s||t[5]!==c?(l=(0,w.jsxs)(`div`,{className:`min-w-0`,children:[s,c]}),t[4]=s,t[5]=c,t[6]=l):l=t[6];let u;t[7]===o?u=t[8]:(u=e=>o(e.target.checked),t[7]=o,t[8]=u);let d;t[9]!==i||t[10]!==a||t[11]!==u?(d=(0,w.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,disabled:a,checked:i,onChange:u}),t[9]=i,t[10]=a,t[11]=u,t[12]=d):d=t[12];let f;return t[13]!==l||t[14]!==d?(f=(0,w.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[l,d]}),t[13]=l,t[14]=d,t[15]=f):f=t[15],f}function E(){let e=a(o(e=>e.language)).desktopPetSettings,t=l(),[n,r]=(0,C.useState)(null),[S,E]=(0,C.useState)(!1),[D,O]=(0,C.useState)(null),k=typeof window<`u`?window.electronAPI?.pet:void 0,A=(0,C.useMemo)(()=>n?.pets.find(e=>e.id===n.prefs.selectedPetId)??n?.pets[0],[n]),j=(0,C.useCallback)(async()=>{if(k){E(!0);try{r(await k.getState())}finally{E(!1)}}},[k]);if((0,C.useEffect)(()=>{if(k)return j(),k.onStateChanged(r)},[k,j]),!d()||!k)return null;if(!n)return(0,w.jsxs)(x,{gap:`gap-4`,children:[(0,w.jsx)(b,{title:e.title,subtitle:e.subtitle}),(0,w.jsx)(`section`,{className:`rounded-xl border border-edge bg-surface-base p-4 text-sm text-fg-muted`,children:e.loading})]});let M=async e=>{E(!0);try{r(await k.setPrefs(e))}finally{E(!1)}},N=async e=>{e?(await k.show(),r(await k.getState())):r(await k.setPrefs({enabled:!1}))},P=e=>{M({selectedPetId:e})},F=t=>{if(t.builtin&&t.i18nKey){let n=e.builtinPets[t.i18nKey];if(n)return n}return{name:t.name,description:t.description}},I=e=>{t({pathname:`/chat/new`,search:`?draft=${encodeURIComponent(e)}`})},L=e=>{if(e.sourcePrompt?.trim())return e.sourcePrompt.trim();let{description:t}=F(e);return t.replace(/^Custom pet generated from:\s*/i,``).trim()||t},R=(e,t)=>Object.entries(t).reduce((e,[t,n])=>e.split(`{${t}}`).join(n),e),z=()=>{I(e.createChatDraft)},B=t=>{I(R(e.optimizeChatDraft,{id:t.id,name:F(t).name,description:F(t).description,sourcePrompt:L(t)}))},V=t=>{I(R(e.fixChatDraft,{dir:t.dir,reason:t.reason,details:t.details?.join(`; `)||e.noIssueDetails}))},H=D??n.prefs.sizePercent,U=async(e=H)=>{let t=Math.min(140,Math.max(70,Math.round(e/5)*5));O(null),t!==n.prefs.sizePercent&&await M({sizePercent:t})};return(0,w.jsxs)(x,{gap:`gap-4`,children:[(0,w.jsx)(b,{title:e.title,subtitle:e.subtitle,actions:(0,w.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:[(0,w.jsxs)(`button`,{type:`button`,className:i(`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`,m.press),disabled:S,onClick:()=>void j(),children:[(0,w.jsx)(p,{className:i(`size-3.5`,S&&`animate-spin`),strokeWidth:1.75}),e.refresh]}),(0,w.jsxs)(`button`,{type:`button`,className:i(`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover`,m.press),onClick:()=>void k.openCustomPetsDir(),children:[(0,w.jsx)(s,{className:`size-3.5`,strokeWidth:1.75}),e.openFolder]})]})}),(0,w.jsxs)(`section`,{className:`rounded-xl border border-edge bg-surface-base p-4 shadow-surface`,children:[(0,w.jsxs)(`div`,{className:`space-y-2`,children:[(0,w.jsx)(T,{title:e.enable,desc:e.enableDesc,checked:n.prefs.enabled,disabled:S,onChange:e=>void N(e)}),(0,w.jsx)(T,{title:e.showOnStartup,desc:e.showOnStartupDesc,checked:n.prefs.showOnStartup,disabled:S,onChange:e=>void M({showOnStartup:e})})]}),(0,w.jsx)(`div`,{className:`mt-5 rounded-xl border border-edge-subtle bg-surface-panel p-3`,children:(0,w.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,w.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[(0,w.jsx)(f,{className:`mt-0.5 size-4 text-accent-fg`,strokeWidth:1.8}),(0,w.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,w.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:e.createTitle}),(0,w.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.createDesc})]})]}),(0,w.jsxs)(`button`,{type:`button`,className:i(`inline-flex h-9 shrink-0 items-center justify-center gap-1.5 rounded-lg bg-accent px-3 text-xs font-semibold text-white hover:bg-accent/90`,m.press),onClick:z,children:[(0,w.jsx)(u,{className:`size-3.5`,strokeWidth:1.75}),e.createInChat]})]})}),(0,w.jsxs)(`div`,{className:`mt-5`,children:[(0,w.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:e.petList}),(0,w.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.petListDesc})]}),A?(0,w.jsx)(`span`,{className:`rounded-full bg-accent-soft px-2.5 py-1 text-xs font-medium text-accent-fg`,children:F(A).name}):null]}),(0,w.jsxs)(`div`,{className:`divide-y divide-edge-subtle rounded-xl border border-edge bg-surface-base`,children:[n.pets.map(t=>{let r=t.id===n.prefs.selectedPetId,a=F(t);return(0,w.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-3`,children:[(0,w.jsx)(y,{pet:t,action:`idle`,size:`tiny`}),(0,w.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,w.jsx)(`p`,{className:`truncate text-sm font-semibold text-fg`,children:a.name}),t.builtin?null:(0,w.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:e.customBadge})]}),(0,w.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:a.description})]}),(0,w.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[t.builtin?null:(0,w.jsxs)(`button`,{type:`button`,className:i(`inline-flex items-center gap-1.5 rounded-lg border border-edge bg-surface-base px-2.5 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover`,m.press),onClick:()=>B(t),children:[(0,w.jsx)(c,{className:`size-3.5`,strokeWidth:1.75}),e.optimizeInChat]}),(0,w.jsx)(`button`,{type:`button`,className:i(`rounded-lg px-2.5 py-1.5 text-xs font-medium transition-colors`,r?`bg-surface-hover text-fg-muted`:`bg-surface-panel text-fg hover:bg-surface-hover`,m.press),disabled:r||S,onClick:()=>P(t.id),children:r?e.selected:e.select})]})]},t.id)}),(0,w.jsxs)(`div`,{className:`flex flex-col gap-1 px-3 py-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`p`,{className:`text-xs font-semibold text-fg`,children:e.customPets}),(0,w.jsx)(`p`,{className:`font-mono text-xs text-fg-muted`,children:n.customPetsDir})]}),(0,w.jsxs)(`button`,{type:`button`,className:`inline-flex items-center gap-1.5 text-xs font-medium text-fg-muted hover:text-fg`,onClick:()=>void k.openCustomPetsDir(),children:[e.openFolder,(0,w.jsx)(s,{className:`size-3.5`,strokeWidth:1.75})]})]})]}),n.petIssues.length>0?(0,w.jsxs)(`div`,{className:`mt-2 rounded-xl border border-danger/30 bg-danger/5 p-3`,children:[(0,w.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-semibold text-danger`,children:[(0,w.jsx)(_,{className:`size-3.5`,strokeWidth:1.8}),e.invalidPets]}),(0,w.jsx)(`div`,{className:`mt-2 space-y-2`,children:n.petIssues.map(t=>(0,w.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg bg-surface-base/70 p-2 text-xs text-fg-muted sm:flex-row sm:items-start sm:justify-between`,children:[(0,w.jsxs)(`div`,{className:`min-w-0`,children:[(0,w.jsx)(`p`,{className:`truncate font-mono text-[11px] text-fg`,children:t.dir}),(0,w.jsx)(`p`,{children:t.reason}),t.details?.length?(0,w.jsx)(`p`,{className:`line-clamp-2`,children:t.details.join(`; `)}):null]}),(0,w.jsxs)(`button`,{type:`button`,className:i(`inline-flex h-8 shrink-0 items-center justify-center gap-1.5 rounded-lg border border-danger/30 bg-surface-base px-2.5 text-xs font-medium text-danger hover:bg-danger/10`,m.press),onClick:()=>V(t),children:[(0,w.jsx)(u,{className:`size-3.5`,strokeWidth:1.75}),e.fixInChat]})]},`${t.dir}-${t.reason}`))})]}):null]}),(0,w.jsxs)(`div`,{className:`mt-5 grid gap-2`,children:[(0,w.jsxs)(`div`,{className:`rounded-xl bg-surface-hover/50 px-3 py-3 dark:bg-surface-hover/35`,children:[(0,w.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.size}),(0,w.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.sizeDesc})]}),(0,w.jsxs)(`span`,{className:`text-xs font-medium text-fg-muted`,children:[H,`%`]})]}),(0,w.jsx)(`input`,{type:`range`,min:70,max:140,step:5,className:`mt-3 w-full accent-accent`,value:H,onChange:e=>O(Number(e.target.value)),onBlur:()=>void U(),onKeyUp:e=>{(e.key===`Enter`||e.key===` `||e.key.startsWith(`Arrow`))&&U()},onPointerUp:()=>void U()})]}),(0,w.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2`,children:[(0,w.jsx)(T,{title:e.alwaysOnTop,desc:e.alwaysOnTopDesc,checked:n.prefs.alwaysOnTop,disabled:S,onChange:e=>void M({alwaysOnTop:e})}),(0,w.jsx)(T,{title:e.bubbles,desc:e.bubblesDesc,checked:n.prefs.bubbleEnabled,disabled:S,onChange:e=>void M({bubbleEnabled:e})})]}),(0,w.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-xl bg-surface-hover/50 px-3 py-3 dark:bg-surface-hover/35 sm:flex-row sm:items-center sm:justify-between`,children:[(0,w.jsxs)(`div`,{children:[(0,w.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.feedbackLevel}),(0,w.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.feedbackLevelDesc})]}),(0,w.jsxs)(v,{className:`w-full sm:w-40`,triggerClassName:`h-9 bg-surface-panel`,value:n.prefs.feedbackLevel,onChange:e=>void M({feedbackLevel:e.target.value}),children:[(0,w.jsx)(g,{value:`quiet`,children:e.feedbackQuiet}),(0,w.jsx)(g,{value:`normal`,children:e.feedbackNormal}),(0,w.jsx)(g,{value:`chatty`,children:e.feedbackChatty})]})]}),(0,w.jsxs)(`button`,{type:`button`,className:i(`inline-flex w-fit items-center gap-1.5 rounded-lg border border-edge bg-surface-base px-3 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover disabled:opacity-50`,m.press),disabled:S,onClick:()=>void k.resetPosition().then(r),children:[(0,w.jsx)(h,{className:`size-3.5`,strokeWidth:1.75}),e.resetPosition]})]})]})]})}export{E as DesktopPetSettings};
@@ -1 +1 @@
1
- import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./cn-BQ_8x0bT.js";import{Ot as r,kt as i,wt as a}from"./index-DZOm5_ex.js";var o=e(),s=t();function c(e){let t=(0,o.c)(38),{value:c,onChange:l,disabled:u,wd:d,placeholder:f,inputClassName:p,autoFocus:m,trailing:h}=e,g;t[0]!==l||t[1]!==c?(g={initialPath:c,onPicked:l},t[0]=l,t[1]=c,t[2]=g):g=t[2];let _=r(g),v;t[3]===c?v=t[4]:(v=c.trim(),t[3]=c,t[4]=v);let y=v,b=y?`${y}\n${d.chooseFolder}`:`${f??d.notSet}\n${d.selectWorkingDirectory}`,x;t[5]===p?x=t[6]:(x=n(`min-w-0 flex-1`,p),t[5]=p,t[6]=x);let S=u||_.picking,C;t[7]===l?C=t[8]:(C=e=>void l(e.target.value),t[7]=l,t[8]=C);let w=f??d.pathInputPlaceholder,T;t[9]!==m||t[10]!==x||t[11]!==S||t[12]!==C||t[13]!==w||t[14]!==c?(T=(0,s.jsx)(`input`,{type:`text`,className:x,value:c,disabled:S,onChange:C,placeholder:w,autoFocus:m,autoComplete:`off`,spellCheck:!1}),t[9]=m,t[10]=x,t[11]=S,t[12]=C,t[13]=w,t[14]=c,t[15]=T):T=t[15];let E=u||_.picking,D;t[16]!==b||t[17]!==_.pick||t[18]!==E||t[19]!==c||t[20]!==d.selectWorkingDirectory?(D=(0,s.jsx)(i,{compact:!0,value:c,onPick:_.pick,disabled:E,title:b,"aria-label":d.selectWorkingDirectory}),t[16]=b,t[17]=_.pick,t[18]=E,t[19]=c,t[20]=d.selectWorkingDirectory,t[21]=D):D=t[21];let O;t[22]!==D||t[23]!==h?(O=(0,s.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[D,h]}),t[22]=D,t[23]=h,t[24]=O):O=t[24];let k;t[25]!==O||t[26]!==T?(k=(0,s.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center`,children:[T,O]}),t[25]=O,t[26]=T,t[27]=k):k=t[27];let A;t[28]!==_.confirmPick||t[29]!==_.hasNativePicker||t[30]!==_.modalOpen||t[31]!==_.setModalOpen||t[32]!==y||t[33]!==d?(A=_.hasNativePicker?null:(0,s.jsx)(a,{open:_.modalOpen,onOpenChange:_.setModalOpen,initialAbsolutePath:y||void 0,onConfirm:_.confirmPick,wd:d}),t[28]=_.confirmPick,t[29]=_.hasNativePicker,t[30]=_.modalOpen,t[31]=_.setModalOpen,t[32]=y,t[33]=d,t[34]=A):A=t[34];let j;return t[35]!==k||t[36]!==A?(j=(0,s.jsxs)(s.Fragment,{children:[k,A]}),t[35]=k,t[36]=A,t[37]=j):j=t[37],j}export{c as t};
1
+ import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./cn-BQ_8x0bT.js";import{Ot as r,kt as i,wt as a}from"./index-NwiCnzI-.js";var o=e(),s=t();function c(e){let t=(0,o.c)(38),{value:c,onChange:l,disabled:u,wd:d,placeholder:f,inputClassName:p,autoFocus:m,trailing:h}=e,g;t[0]!==l||t[1]!==c?(g={initialPath:c,onPicked:l},t[0]=l,t[1]=c,t[2]=g):g=t[2];let _=r(g),v;t[3]===c?v=t[4]:(v=c.trim(),t[3]=c,t[4]=v);let y=v,b=y?`${y}\n${d.chooseFolder}`:`${f??d.notSet}\n${d.selectWorkingDirectory}`,x;t[5]===p?x=t[6]:(x=n(`min-w-0 flex-1`,p),t[5]=p,t[6]=x);let S=u||_.picking,C;t[7]===l?C=t[8]:(C=e=>void l(e.target.value),t[7]=l,t[8]=C);let w=f??d.pathInputPlaceholder,T;t[9]!==m||t[10]!==x||t[11]!==S||t[12]!==C||t[13]!==w||t[14]!==c?(T=(0,s.jsx)(`input`,{type:`text`,className:x,value:c,disabled:S,onChange:C,placeholder:w,autoFocus:m,autoComplete:`off`,spellCheck:!1}),t[9]=m,t[10]=x,t[11]=S,t[12]=C,t[13]=w,t[14]=c,t[15]=T):T=t[15];let E=u||_.picking,D;t[16]!==b||t[17]!==_.pick||t[18]!==E||t[19]!==c||t[20]!==d.selectWorkingDirectory?(D=(0,s.jsx)(i,{compact:!0,value:c,onPick:_.pick,disabled:E,title:b,"aria-label":d.selectWorkingDirectory}),t[16]=b,t[17]=_.pick,t[18]=E,t[19]=c,t[20]=d.selectWorkingDirectory,t[21]=D):D=t[21];let O;t[22]!==D||t[23]!==h?(O=(0,s.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[D,h]}),t[22]=D,t[23]=h,t[24]=O):O=t[24];let k;t[25]!==O||t[26]!==T?(k=(0,s.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center`,children:[T,O]}),t[25]=O,t[26]=T,t[27]=k):k=t[27];let A;t[28]!==_.confirmPick||t[29]!==_.hasNativePicker||t[30]!==_.modalOpen||t[31]!==_.setModalOpen||t[32]!==y||t[33]!==d?(A=_.hasNativePicker?null:(0,s.jsx)(a,{open:_.modalOpen,onOpenChange:_.setModalOpen,initialAbsolutePath:y||void 0,onConfirm:_.confirmPick,wd:d}),t[28]=_.confirmPick,t[29]=_.hasNativePicker,t[30]=_.modalOpen,t[31]=_.setModalOpen,t[32]=y,t[33]=d,t[34]=A):A=t[34];let j;return t[35]!==k||t[36]!==A?(j=(0,s.jsxs)(s.Fragment,{children:[k,A]}),t[35]=k,t[36]=A,t[37]=j):j=t[37],j}export{c as t};