@xopcai/xopc 0.0.145 → 0.0.147

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 (380) hide show
  1. package/README.md +2 -2
  2. package/dist/browser-ext/manifest.json +1 -1
  3. package/dist/extensions/demo-memory/src/index.js +6 -4
  4. package/dist/extensions/demo-memory/src/index.js.map +1 -1
  5. package/dist/extensions/telegram/xopc.extension.json +1 -1
  6. package/dist/gateway/static/root/assets/Combination-14nmIgxH.js +41 -0
  7. package/dist/gateway/static/root/assets/activity-store-DXeSSlw1.js +1 -0
  8. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-BEUxdhZx.js → agent-avatar-dicebear-CFdJKSjY.js} +1 -1
  9. package/dist/gateway/static/root/assets/agents-DKjbRpbA.js +2 -0
  10. package/dist/gateway/static/root/assets/api-Bs69B5zA.js +1 -0
  11. package/dist/gateway/static/root/assets/{app-management-settings-panel-CRHSZJWi.js → app-management-settings-panel-ag1ViXT_.js} +1 -1
  12. package/dist/gateway/static/root/assets/{appearance-settings-BunADYJb.js → appearance-settings-C6iMpwOM.js} +1 -1
  13. package/dist/gateway/static/root/assets/apps-page-CpX3lBFF.js +1 -0
  14. package/dist/gateway/static/root/assets/{archive-plugin-B6vTkH2A.js → archive-plugin-Dwi3mIBy.js} +1 -1
  15. package/dist/gateway/static/root/assets/{attachment-load-BjZXzaNv.js → attachment-load-BaCDoq40.js} +1 -1
  16. package/dist/gateway/static/root/assets/{automation-suggestion-card-ZDA-Stg1.js → automation-suggestion-card-CwqtFgnw.js} +1 -1
  17. package/dist/gateway/static/root/assets/automations-page-DlupOxFQ.js +6 -0
  18. package/dist/gateway/static/root/assets/{binary-plugins-DYZfLvPz.js → binary-plugins-DoAYhsxa.js} +1 -1
  19. package/dist/gateway/static/root/assets/{block-editor-C3MUlYC9.js → block-editor-Bw72pO7S.js} +31 -31
  20. package/dist/gateway/static/root/assets/browser-settings-page-BwLoUBcZ.js +8 -0
  21. package/dist/gateway/static/root/assets/capability-presets-api-vdbAR65Q.js +1 -0
  22. package/dist/gateway/static/root/assets/capability-presets-settings-panel-BAsKbJgm.js +2 -0
  23. package/dist/gateway/static/root/assets/{channel-recipient-api-fTlTnWB4.js → channel-recipient-api-rTG26jpV.js} +1 -1
  24. package/dist/gateway/static/root/assets/channels-settings-CxFWy0cE.js +1 -0
  25. package/dist/gateway/static/root/assets/channels-status-swr-OKlqTtKJ.js +1 -0
  26. package/dist/gateway/static/root/assets/{connector-logo-BVFNT2zW.js → connector-logo-DIMP4NWY.js} +1 -1
  27. package/dist/gateway/static/root/assets/connectors-page-BjQQwX62.js +2 -0
  28. package/dist/gateway/static/root/assets/{desktop-pet-_jUmoXd3.js → desktop-pet-kQq2e0BN.js} +1 -1
  29. package/dist/gateway/static/root/assets/{desktop-pet-settings-DwGOy4AQ.js → desktop-pet-settings-B6vtozMY.js} +1 -1
  30. package/dist/gateway/static/root/assets/{directory-picker-path-field-akvF0F-u.js → directory-picker-path-field-Dn5-e3v4.js} +1 -1
  31. package/dist/gateway/static/root/assets/dist-C230izr8.js +1 -0
  32. package/dist/gateway/static/root/assets/dist-CxGUk8J-.js +1 -0
  33. package/dist/gateway/static/root/assets/dreaming-settings-BzwIujPG.js +3 -0
  34. package/dist/gateway/static/root/assets/extension-debug-page-D_e_hsEy.js +1 -0
  35. package/dist/gateway/static/root/assets/{extension-page-CwWktRNz.js → extension-page-D15CWHBd.js} +1 -1
  36. package/dist/gateway/static/root/assets/{extension-settings-page-CuggWOIl.js → extension-settings-page-D4P0n1om.js} +1 -1
  37. package/dist/gateway/static/root/assets/{gateway-config-api-B7sxIbza.js → gateway-config-api-B4qZctjG.js} +1 -1
  38. package/dist/gateway/static/root/assets/{gateway-settings-DIv0eKMf.js → gateway-settings-BvndV7TP.js} +1 -1
  39. package/dist/gateway/static/root/assets/{gateway-startup-retry-DtoLihQE.js → gateway-startup-retry-BpgMunEb.js} +1 -1
  40. package/dist/gateway/static/root/assets/{goal-create-dialog-C4Kw0mfS.js → goal-create-dialog-DrVHKXHq.js} +1 -1
  41. package/dist/gateway/static/root/assets/goal-detail-page-PHlCwv68.js +4 -0
  42. package/dist/gateway/static/root/assets/{goals-config-api-B0jm5JaA.js → goals-config-api-B6YJB_ct.js} +1 -1
  43. package/dist/gateway/static/root/assets/goals-page-Hg9uyO6e.js +2 -0
  44. package/dist/gateway/static/root/assets/{goals-settings-N5_iL7es.js → goals-settings-BROWCIcL.js} +1 -1
  45. package/dist/gateway/static/root/assets/{heartbeat-settings-XzH3lbRR.js → heartbeat-settings-CoCwIOIg.js} +1 -1
  46. package/dist/gateway/static/root/assets/index-CxkNzw3e.js +259 -0
  47. package/dist/gateway/static/root/assets/index-DjCSOyaN.css +1 -0
  48. package/dist/gateway/static/root/assets/keyboard-shortcuts-settings-Bm_AIYQ7.js +1 -0
  49. package/dist/gateway/static/root/assets/local-app-workbench-page-BJWFcxwG.js +2 -0
  50. package/dist/gateway/static/root/assets/local-apps-page-BsiZMrEf.js +1 -0
  51. package/dist/gateway/static/root/assets/{locale-store-CiM-D9jA.js → locale-store-Bp8joZck.js} +1 -1
  52. package/dist/gateway/static/root/assets/logs-page-DOmK61ey.js +7 -0
  53. package/dist/gateway/static/root/assets/{markdown-split-5rJx5flj.js → markdown-split-Dy7QpaAz.js} +1 -1
  54. package/dist/gateway/static/root/assets/{media-plugins-DYXccwAd.js → media-plugins-3Lxliy9D.js} +1 -1
  55. package/dist/gateway/static/root/assets/messages-CQGpD-dC.js +5 -0
  56. package/dist/gateway/static/root/assets/models-hub-panel-DGCZom4o.js +2 -0
  57. package/dist/gateway/static/root/assets/{notes-page-BgLyndCO.js → notes-page-BJtT4vSf.js} +1 -1
  58. package/dist/gateway/static/root/assets/notes-workbench-B_bN7cOR.js +4 -0
  59. package/dist/gateway/static/root/assets/{page-tabs-6Al9_sGz.js → page-tabs-DKB6RDre.js} +1 -1
  60. package/dist/gateway/static/root/assets/{preview-open-alternatives-Cm3G72Hv.js → preview-open-alternatives-Br_YhYHp.js} +1 -1
  61. package/dist/gateway/static/root/assets/project-detail-page-Dq8JouJj.js +1 -0
  62. package/dist/gateway/static/root/assets/projects-page-DvfL7fSe.js +1 -0
  63. package/dist/gateway/static/root/assets/remote-access-hub-DqwMXSXP.js +1 -0
  64. package/dist/gateway/static/root/assets/{save-bar-controls-BYtfzu_F.js → save-bar-controls-BgIE9BBh.js} +1 -1
  65. package/dist/gateway/static/root/assets/{schedule-field-CvIRc6yK.js → schedule-field-BXDP-oMz.js} +1 -1
  66. package/dist/gateway/static/root/assets/{schema-form-CQuKx0n7.js → schema-form-Dhv-SmjG.js} +1 -1
  67. package/dist/gateway/static/root/assets/sessions-page-B_mOZkQk.js +1 -0
  68. package/dist/gateway/static/root/assets/settings-advanced-gate-BHGmH6YS.js +1 -0
  69. package/dist/gateway/static/root/assets/{settings-collapsible-section-CF3HHM-t.js → settings-collapsible-section-CUTExnlK.js} +1 -1
  70. package/dist/gateway/static/root/assets/{settings-form-section-CwWjoRN6.js → settings-form-section-CmnDhsf0.js} +1 -1
  71. package/dist/gateway/static/root/assets/{settings-loading-skeleton-aUFmJa13.js → settings-loading-skeleton-B79dq-XY.js} +1 -1
  72. package/dist/gateway/static/root/assets/{settings-page-B2UUU9TF.js → settings-page-Db8uAv3X.js} +1 -1
  73. package/dist/gateway/static/root/assets/{settings-page-layout-DqpbTWqI.js → settings-page-layout-DaFwstQw.js} +1 -1
  74. package/dist/gateway/static/root/assets/setup-status-panel-BUSEj0KK.js +1 -0
  75. package/dist/gateway/static/root/assets/{share-preview-page-BOhlPsS1.js → share-preview-page-Bi00uXzV.js} +1 -1
  76. package/dist/gateway/static/root/assets/shares-settings-DzsTYfuX.js +1 -0
  77. package/dist/gateway/static/root/assets/skill-reload-api-DSsdU081.js +1 -0
  78. package/dist/gateway/static/root/assets/skills-page-DeB1tQZL.js +2 -0
  79. package/dist/gateway/static/root/assets/{system-settings-panel-CWxSvuwD.js → system-settings-panel-Cxaph7hW.js} +1 -1
  80. package/dist/gateway/static/root/assets/{theme-store-C9Dxcppm.js → theme-store-eCTN1RpG.js} +1 -1
  81. package/dist/gateway/static/root/assets/{typed-models-lib-qROAvqTw.js → typed-models-lib-CcZ_tyFY.js} +1 -1
  82. package/dist/gateway/static/root/assets/{use-channel-catalog-DE9cpn4G.js → use-channel-catalog-C4PWbNoi.js} +1 -1
  83. package/dist/gateway/static/root/assets/user-context-page-QTVMx_hG.js +1 -0
  84. package/dist/gateway/static/root/assets/{user-profile-fields-editor-CWxc0ghP.js → user-profile-fields-editor-CPOO9Jz5.js} +1 -1
  85. package/dist/gateway/static/root/assets/{user-profile-settings-panel-DW-Up6vt.js → user-profile-settings-panel-C8cgtSF7.js} +1 -1
  86. package/dist/gateway/static/root/assets/{utils-D53uRXVr.js → utils-CiZK2KwH.js} +1 -1
  87. package/dist/gateway/static/root/assets/voice-api-key-field-b-YZtvUu.js +1 -0
  88. package/dist/gateway/static/root/assets/work-discovery-page-4zVDOl2G.js +1 -0
  89. package/dist/gateway/static/root/assets/work-item-detail-page-CHe2tfkc.js +1 -0
  90. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-D_x9ELJp.js → workflow-run-setup-panel-8SLCYeXE.js} +2 -2
  91. package/dist/gateway/static/root/assets/workflows-page-DEOFqiWn.js +11 -0
  92. package/dist/gateway/static/root/index.html +10 -9
  93. package/dist/package.js +1 -1
  94. package/dist/src/activity/types.d.ts +1 -1
  95. package/dist/src/agent/agent-instance-gateway.d.ts +1 -1
  96. package/dist/src/agent/agent-manager.d.ts +1 -1
  97. package/dist/src/agent/agent-manager.js +5 -4
  98. package/dist/src/agent/agent-manager.js.map +1 -1
  99. package/dist/src/agent/background-review/coordinator.js +0 -1
  100. package/dist/src/agent/background-review/coordinator.js.map +1 -1
  101. package/dist/src/agent/background-review/settings.d.ts +1 -1
  102. package/dist/src/agent/background-review/settings.js +10 -17
  103. package/dist/src/agent/background-review/settings.js.map +1 -1
  104. package/dist/src/agent/bootstrap/filter-bootstrap-files.d.ts +1 -1
  105. package/dist/src/agent/bootstrap/filter-bootstrap-files.js +1 -1
  106. package/dist/src/agent/bootstrap/filter-bootstrap-files.js.map +1 -1
  107. package/dist/src/agent/bootstrap/load-bootstrap-files.js +2 -3
  108. package/dist/src/agent/bootstrap/load-bootstrap-files.js.map +1 -1
  109. package/dist/src/agent/code-intelligence/binary.js +1 -1
  110. package/dist/src/agent/context/project-context.d.ts +14 -0
  111. package/dist/src/agent/context/project-context.js +23 -1
  112. package/dist/src/agent/context/project-context.js.map +1 -1
  113. package/dist/src/agent/context/workspace-templates/AGENTS.md +1 -1
  114. package/dist/src/agent/context/workspace.d.ts +1 -2
  115. package/dist/src/agent/context/workspace.js +2 -4
  116. package/dist/src/agent/context/workspace.js.map +1 -1
  117. package/dist/src/agent/embedded/run-for-session.js +1 -2
  118. package/dist/src/agent/embedded/run-for-session.js.map +1 -1
  119. package/dist/src/agent/embedded/run-turn.js +6 -1
  120. package/dist/src/agent/embedded/run-turn.js.map +1 -1
  121. package/dist/src/agent/embedded/types.d.ts +17 -0
  122. package/dist/src/agent/memory/builtin-memory-store.d.ts +2 -2
  123. package/dist/src/agent/memory/builtin-memory-store.js +2 -2
  124. package/dist/src/agent/memory/builtin-memory-store.js.map +1 -1
  125. package/dist/src/agent/memory/builtin-provider.d.ts +1 -3
  126. package/dist/src/agent/memory/builtin-provider.js +21 -48
  127. package/dist/src/agent/memory/builtin-provider.js.map +1 -1
  128. package/dist/src/agent/memory/context/planner.js +48 -9
  129. package/dist/src/agent/memory/context/planner.js.map +1 -1
  130. package/dist/src/agent/memory/context/types.d.ts +7 -1
  131. package/dist/src/agent/memory/context-fence.js +1 -1
  132. package/dist/src/agent/memory/context-fence.js.map +1 -1
  133. package/dist/src/agent/memory/create-memory-manager.js +2 -9
  134. package/dist/src/agent/memory/create-memory-manager.js.map +1 -1
  135. package/dist/src/agent/memory/dreaming/config.js +5 -10
  136. package/dist/src/agent/memory/dreaming/config.js.map +1 -1
  137. package/dist/src/agent/memory/dreaming/promotion-lifecycle.js +2 -2
  138. package/dist/src/agent/memory/dreaming/promotion-lifecycle.js.map +1 -1
  139. package/dist/src/agent/memory/dreaming/scope.d.ts +2 -3
  140. package/dist/src/agent/memory/dreaming/scope.js +8 -8
  141. package/dist/src/agent/memory/dreaming/scope.js.map +1 -1
  142. package/dist/src/agent/memory/manager.d.ts +1 -5
  143. package/dist/src/agent/memory/manager.js +2 -23
  144. package/dist/src/agent/memory/manager.js.map +1 -1
  145. package/dist/src/agent/memory/memory-config.d.ts +3 -3
  146. package/dist/src/agent/memory/memory-config.js +9 -14
  147. package/dist/src/agent/memory/memory-config.js.map +1 -1
  148. package/dist/src/agent/memory/types.d.ts +9 -5
  149. package/dist/src/agent/memory/understanding/service.js +21 -8
  150. package/dist/src/agent/memory/understanding/service.js.map +1 -1
  151. package/dist/src/agent/memory/understanding/types.d.ts +5 -0
  152. package/dist/src/agent/memory/user-context-coordinator.d.ts +1 -1
  153. package/dist/src/agent/memory/user-context-coordinator.js +6 -2
  154. package/dist/src/agent/memory/user-context-coordinator.js.map +1 -1
  155. package/dist/src/agent/orchestration/agent-orchestrator.js +2 -2
  156. package/dist/src/agent/orchestration/agent-orchestrator.js.map +1 -1
  157. package/dist/src/agent/prompt/memory/index.d.ts +1 -2
  158. package/dist/src/agent/prompt/memory/index.js +6 -7
  159. package/dist/src/agent/prompt/memory/index.js.map +1 -1
  160. package/dist/src/agent/prompt/sections/tooling.js +1 -1
  161. package/dist/src/agent/prompt/sections/tooling.js.map +1 -1
  162. package/dist/src/agent/service/direct-turn-helpers.js +13 -2
  163. package/dist/src/agent/service/direct-turn-helpers.js.map +1 -1
  164. package/dist/src/agent/tools/curated-memory-tool.js +4 -4
  165. package/dist/src/agent/tools/curated-memory-tool.js.map +1 -1
  166. package/dist/src/agent/tools/factory.d.ts +1 -1
  167. package/dist/src/agent/tools/factory.js +2 -2
  168. package/dist/src/agent/tools/factory.js.map +1 -1
  169. package/dist/src/agent/tools/memory-tool.js +1 -1
  170. package/dist/src/agent/tools/memory-tool.js.map +1 -1
  171. package/dist/src/agent/workflow/workflow-child-tools.js +2 -3
  172. package/dist/src/agent/workflow/workflow-child-tools.js.map +1 -1
  173. package/dist/src/agent/workspace-runtime/registry.d.ts +5 -5
  174. package/dist/src/agent/workspace-runtime/registry.js +6 -11
  175. package/dist/src/agent/workspace-runtime/registry.js.map +1 -1
  176. package/dist/src/agent-manifest/index.js +2 -2
  177. package/dist/src/agent-manifest/prompt.js +1 -7
  178. package/dist/src/agent-manifest/prompt.js.map +1 -1
  179. package/dist/src/agent-manifest/schema.d.ts +0 -598
  180. package/dist/src/agent-manifest/schema.js +2 -143
  181. package/dist/src/agent-manifest/schema.js.map +1 -1
  182. package/dist/src/agent-manifest/validator.js +0 -12
  183. package/dist/src/agent-manifest/validator.js.map +1 -1
  184. package/dist/src/agent-runtime/index.js +1 -1
  185. package/dist/src/agent-runtime/memory-runtime.d.ts +2 -2
  186. package/dist/src/agent-runtime/memory-runtime.js +8 -7
  187. package/dist/src/agent-runtime/memory-runtime.js.map +1 -1
  188. package/dist/src/agent-runtime/runtime-profile.d.ts +2 -0
  189. package/dist/src/agent-runtime/runtime-profile.js +2 -2
  190. package/dist/src/agent-runtime/runtime-profile.js.map +1 -1
  191. package/dist/src/chat-commands/agent-edit.js +1 -2
  192. package/dist/src/chat-commands/agent-edit.js.map +1 -1
  193. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  194. package/dist/src/cli/commands/init.js +0 -22
  195. package/dist/src/cli/commands/init.js.map +1 -1
  196. package/dist/src/cli/templates.d.ts +1 -1
  197. package/dist/src/cli/templates.js +1 -16
  198. package/dist/src/cli/templates.js.map +1 -1
  199. package/dist/src/commands/agents.config.js +0 -10
  200. package/dist/src/commands/agents.config.js.map +1 -1
  201. package/dist/src/config/agent-profile.js +1 -1
  202. package/dist/src/config/index.js +2 -2
  203. package/dist/src/config/paths.d.ts +0 -1
  204. package/dist/src/config/paths.js +1 -2
  205. package/dist/src/config/paths.js.map +1 -1
  206. package/dist/src/config/schema.d.ts +118 -532
  207. package/dist/src/config/schema.js +32 -26
  208. package/dist/src/config/schema.js.map +1 -1
  209. package/dist/src/extensions/loader.js +2 -1
  210. package/dist/src/extensions/loader.js.map +1 -1
  211. package/dist/src/gateway/agents-admin.d.ts +0 -2
  212. package/dist/src/gateway/agents-admin.js +1 -7
  213. package/dist/src/gateway/agents-admin.js.map +1 -1
  214. package/dist/src/gateway/capability-presets-admin.d.ts +0 -2
  215. package/dist/src/gateway/capability-presets-admin.js.map +1 -1
  216. package/dist/src/gateway/chat-stream/mapper.js +26 -0
  217. package/dist/src/gateway/chat-stream/mapper.js.map +1 -1
  218. package/dist/src/gateway/chat-stream/protocol.d.ts +16 -1
  219. package/dist/src/gateway/dreaming-automation-reconciler.d.ts +0 -1
  220. package/dist/src/gateway/dreaming-automation-reconciler.js +41 -63
  221. package/dist/src/gateway/dreaming-automation-reconciler.js.map +1 -1
  222. package/dist/src/gateway/heartbeat/service.js +1 -1
  223. package/dist/src/gateway/hono/app.js +3 -1
  224. package/dist/src/gateway/hono/app.js.map +1 -1
  225. package/dist/src/gateway/hono/lib/config-payload.d.ts +0 -130
  226. package/dist/src/gateway/hono/lib/config-payload.js +0 -1
  227. package/dist/src/gateway/hono/lib/config-payload.js.map +1 -1
  228. package/dist/src/gateway/hono/routes/agents.js +6 -12
  229. package/dist/src/gateway/hono/routes/agents.js.map +1 -1
  230. package/dist/src/gateway/hono/routes/auth-registry-extensions.js +6 -0
  231. package/dist/src/gateway/hono/routes/auth-registry-extensions.js.map +1 -1
  232. package/dist/src/gateway/hono/routes/capability-presets.js +2 -2
  233. package/dist/src/gateway/hono/routes/capability-presets.js.map +1 -1
  234. package/dist/src/gateway/hono/routes/dreaming.js +9 -20
  235. package/dist/src/gateway/hono/routes/dreaming.js.map +1 -1
  236. package/dist/src/gateway/hono/routes/index.js +4 -0
  237. package/dist/src/gateway/hono/routes/index.js.map +1 -1
  238. package/dist/src/gateway/hono/routes/local-apps.d.ts +5 -0
  239. package/dist/src/gateway/hono/routes/local-apps.js +99 -0
  240. package/dist/src/gateway/hono/routes/local-apps.js.map +1 -0
  241. package/dist/src/gateway/hono/routes/memory.js +48 -65
  242. package/dist/src/gateway/hono/routes/memory.js.map +1 -1
  243. package/dist/src/gateway/hono/routes/projects.js +2 -2
  244. package/dist/src/gateway/hono/routes/projects.js.map +1 -1
  245. package/dist/src/gateway/hono/routes/work-discovery.d.ts +3 -0
  246. package/dist/src/gateway/hono/routes/work-discovery.js +150 -0
  247. package/dist/src/gateway/hono/routes/work-discovery.js.map +1 -0
  248. package/dist/src/gateway/hono/routes/you.d.ts +3 -0
  249. package/dist/src/gateway/hono/routes/you.js +358 -91
  250. package/dist/src/gateway/hono/routes/you.js.map +1 -1
  251. package/dist/src/gateway/service.d.ts +3 -0
  252. package/dist/src/gateway/service.js +12 -0
  253. package/dist/src/gateway/service.js.map +1 -1
  254. package/dist/src/heartbeat/index.js +1 -1
  255. package/dist/src/knowledge/connected-knowledge-pipeline.js +9 -5
  256. package/dist/src/knowledge/connected-knowledge-pipeline.js.map +1 -1
  257. package/dist/src/local-apps/acceptance.d.ts +30 -0
  258. package/dist/src/local-apps/acceptance.js +93 -0
  259. package/dist/src/local-apps/acceptance.js.map +1 -0
  260. package/dist/src/local-apps/index.d.ts +5 -0
  261. package/dist/src/local-apps/index.js +4 -0
  262. package/dist/src/local-apps/preview-runtime-bridge.d.ts +4 -0
  263. package/dist/src/local-apps/preview-runtime-bridge.js +171 -0
  264. package/dist/src/local-apps/preview-runtime-bridge.js.map +1 -0
  265. package/dist/src/local-apps/runtime-entry.d.ts +8 -0
  266. package/dist/src/local-apps/runtime-entry.js +25 -0
  267. package/dist/src/local-apps/runtime-entry.js.map +1 -0
  268. package/dist/src/local-apps/scaffold.d.ts +8 -0
  269. package/dist/src/local-apps/scaffold.js +122 -0
  270. package/dist/src/local-apps/scaffold.js.map +1 -0
  271. package/dist/src/local-apps/service.d.ts +37 -0
  272. package/dist/src/local-apps/service.js +553 -0
  273. package/dist/src/local-apps/service.js.map +1 -0
  274. package/dist/src/local-apps/store.d.ts +44 -0
  275. package/dist/src/local-apps/store.js +195 -0
  276. package/dist/src/local-apps/store.js.map +1 -0
  277. package/dist/src/local-apps/types.d.ts +105 -0
  278. package/dist/src/local-apps/types.js +1 -0
  279. package/dist/src/storage/sqlite/index.d.ts +3 -2
  280. package/dist/src/storage/sqlite/index.js +4 -3
  281. package/dist/src/storage/sqlite/memory-index-repository.d.ts +2 -3
  282. package/dist/src/storage/sqlite/memory-index-repository.js +16 -20
  283. package/dist/src/storage/sqlite/memory-index-repository.js.map +1 -1
  284. package/dist/src/storage/sqlite/memory-records-repository.d.ts +18 -10
  285. package/dist/src/storage/sqlite/memory-records-repository.js +79 -34
  286. package/dist/src/storage/sqlite/memory-records-repository.js.map +1 -1
  287. package/dist/src/storage/sqlite/memory-reference-consent-repository.d.ts +27 -0
  288. package/dist/src/storage/sqlite/memory-reference-consent-repository.js +109 -0
  289. package/dist/src/storage/sqlite/memory-reference-consent-repository.js.map +1 -0
  290. package/dist/src/storage/sqlite/migrations/038_user_owned_memory.sql +68 -0
  291. package/dist/src/storage/sqlite/migrations/039_memory_reference_consents.sql +19 -0
  292. package/dist/src/storage/sqlite/migrations/040_local_apps.sql +32 -0
  293. package/dist/src/storage/sqlite/migrations/041_local_app_release_lifecycle.sql +17 -0
  294. package/dist/src/storage/sqlite/migrations/042_work_discovery.sql +41 -0
  295. package/dist/src/storage/sqlite/migrations/043_local_app_acceptance_runs.sql +16 -0
  296. package/dist/src/storage/sqlite/migrations/044_repair_work_discovery_foreign_keys.sql +75 -0
  297. package/dist/src/storage/sqlite/migrations/045_extension_ui_grants.sql +13 -0
  298. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  299. package/dist/src/storage/sqlite/migrations/runner.js +3 -3
  300. package/dist/src/storage/sqlite/migrations/runner.js.map +1 -1
  301. package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
  302. package/dist/src/storage/sqlite/schema.js +1 -1
  303. package/dist/src/storage/sqlite/schema.sql +20 -0
  304. package/dist/src/user-context/config.d.ts +227 -0
  305. package/dist/src/user-context/config.js +158 -0
  306. package/dist/src/user-context/config.js.map +1 -0
  307. package/dist/src/user-context/import.d.ts +1 -1
  308. package/dist/src/user-context/import.js +6 -1
  309. package/dist/src/user-context/import.js.map +1 -1
  310. package/dist/src/user-context/owner.d.ts +5 -0
  311. package/dist/src/user-context/owner.js +9 -0
  312. package/dist/src/user-context/owner.js.map +1 -0
  313. package/dist/src/user-context/projection.d.ts +11 -9
  314. package/dist/src/user-context/projection.js +74 -47
  315. package/dist/src/user-context/projection.js.map +1 -1
  316. package/dist/src/user-context/runtime.d.ts +13 -0
  317. package/dist/src/user-context/runtime.js +36 -0
  318. package/dist/src/user-context/runtime.js.map +1 -0
  319. package/dist/src/work-discovery/analyzer.d.ts +11 -0
  320. package/dist/src/work-discovery/analyzer.js +171 -0
  321. package/dist/src/work-discovery/analyzer.js.map +1 -0
  322. package/dist/src/work-discovery/index.d.ts +5 -0
  323. package/dist/src/work-discovery/index.js +5 -0
  324. package/dist/src/work-discovery/probe.d.ts +12 -0
  325. package/dist/src/work-discovery/probe.js +335 -0
  326. package/dist/src/work-discovery/probe.js.map +1 -0
  327. package/dist/src/work-discovery/repository.d.ts +11 -0
  328. package/dist/src/work-discovery/repository.js +100 -0
  329. package/dist/src/work-discovery/repository.js.map +1 -0
  330. package/dist/src/work-discovery/service.d.ts +30 -0
  331. package/dist/src/work-discovery/service.js +387 -0
  332. package/dist/src/work-discovery/service.js.map +1 -0
  333. package/dist/src/work-discovery/types.d.ts +114 -0
  334. package/dist/src/work-discovery/types.js +1 -0
  335. package/dist/src/workflows/service/workflow-session-bridge.js +1 -1
  336. package/dist/src/workflows/service/workflow-session-bridge.js.map +1 -1
  337. package/package.json +5 -3
  338. package/skills/engineering/build-xopc-local-app/SKILL.md +45 -0
  339. package/skills/engineering/build-xopc-local-app/references/app-contract.md +33 -0
  340. package/skills/engineering/build-xopc-local-app/scripts/validate-local-app.mjs +72 -0
  341. package/dist/gateway/static/root/assets/Combination-DolwnuKi.js +0 -41
  342. package/dist/gateway/static/root/assets/activity-center-store-3l9ahUqb.js +0 -1
  343. package/dist/gateway/static/root/assets/agents-1bpT0xRO.js +0 -2
  344. package/dist/gateway/static/root/assets/apps-page-Cc4JgVUQ.js +0 -1
  345. package/dist/gateway/static/root/assets/automations-page-mb0fdVpq.js +0 -6
  346. package/dist/gateway/static/root/assets/browser-settings-page-Bb0xhaMN.js +0 -8
  347. package/dist/gateway/static/root/assets/capability-presets-api-BV76yN9a.js +0 -1
  348. package/dist/gateway/static/root/assets/capability-presets-settings-panel-CUcGKZqC.js +0 -2
  349. package/dist/gateway/static/root/assets/channels-settings-BlSDMGdy.js +0 -1
  350. package/dist/gateway/static/root/assets/channels-status-swr-CJauF1CW.js +0 -1
  351. package/dist/gateway/static/root/assets/connectors-page-CMgAFGvb.js +0 -2
  352. package/dist/gateway/static/root/assets/dist-C99RGfAH.js +0 -1
  353. package/dist/gateway/static/root/assets/dreaming-settings-BLetQiYY.js +0 -3
  354. package/dist/gateway/static/root/assets/extension-debug-page-Cof2ncxE.js +0 -1
  355. package/dist/gateway/static/root/assets/goal-detail-page-BMmzYpZL.js +0 -4
  356. package/dist/gateway/static/root/assets/goals-page-CGeT77PC.js +0 -2
  357. package/dist/gateway/static/root/assets/index-CSLF84-Q.css +0 -1
  358. package/dist/gateway/static/root/assets/index-I-ZCenVw.js +0 -259
  359. package/dist/gateway/static/root/assets/keyboard-shortcuts-settings-x_v0nrIi.js +0 -1
  360. package/dist/gateway/static/root/assets/logs-page-BSh1t8cD.js +0 -7
  361. package/dist/gateway/static/root/assets/messages-Cb1VMeqP.js +0 -5
  362. package/dist/gateway/static/root/assets/models-hub-panel-BNpTenAI.js +0 -2
  363. package/dist/gateway/static/root/assets/notes-workbench-teklkhcE.js +0 -4
  364. package/dist/gateway/static/root/assets/project-detail-page-CCB_dKoh.js +0 -1
  365. package/dist/gateway/static/root/assets/projects-page-VOAFAHYj.js +0 -1
  366. package/dist/gateway/static/root/assets/remote-access-hub-USYu64Ru.js +0 -1
  367. package/dist/gateway/static/root/assets/sessions-page-oGC8O5h_.js +0 -1
  368. package/dist/gateway/static/root/assets/settings-advanced-gate-D4rP66R1.js +0 -1
  369. package/dist/gateway/static/root/assets/setup-status-panel-Ck9keROI.js +0 -1
  370. package/dist/gateway/static/root/assets/shares-settings-BYLsCuqj.js +0 -1
  371. package/dist/gateway/static/root/assets/skill-reload-api-BNHUyVML.js +0 -1
  372. package/dist/gateway/static/root/assets/skills-page-CpXbQH4n.js +0 -2
  373. package/dist/gateway/static/root/assets/user-context-page-DbNEK4Yp.js +0 -1
  374. package/dist/gateway/static/root/assets/voice-api-key-field-Cs7MOrg0.js +0 -1
  375. package/dist/gateway/static/root/assets/work-item-detail-page-D1ziG1Pp.js +0 -1
  376. package/dist/gateway/static/root/assets/workflows-page-DHGV_n6i.js +0 -11
  377. package/dist/src/agent/context/workspace-templates/MEMORY.md +0 -33
  378. package/dist/src/agent/memory/access-policy.d.ts +0 -12
  379. package/dist/src/agent/memory/access-policy.js +0 -44
  380. package/dist/src/agent/memory/access-policy.js.map +0 -1
@@ -0,0 +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{d as i}from"./chunk-QUQL4437-DXsxWP7r.js";import{t as a}from"./cn-BQ_8x0bT.js";import{t as o}from"./check-BODqo66o.js";import{n as s}from"./copy-to-clipboard-HOJ79TWv.js";import{t as c}from"./messages-CQGpD-dC.js";import{d as l,i as u,n as d,o as f}from"./locale-store-Bp8joZck.js";import{$c as p,Ao as m,As as h,Bi as g,Bl as _,Bs as v,Ci as y,Ec as b,Ei as x,Fo as S,Hi as C,Jo as w,Js as T,Ko as E,Ls as D,Mo as O,No as k,Oo as A,Po as j,Qs as M,Rc as N,Si as P,Ui as F,Uo as I,Vi as L,Wi as R,Wo as z,Xl as B,Yo as V,Zs as ee,_c as H,as as te,cs as ne,ec as re,eu as ie,hc as ae,jl as oe,jo as se,ko as U,mc as ce,ms as W,no as le,oa as ue,ps as de,rc as fe,ro as pe,sc as me,vs as G,wi as he,xi as K,xl as ge,ys as _e}from"./index-CxkNzw3e.js";import{t as ve}from"./page-tabs-DKB6RDre.js";import{t as q}from"./connector-logo-DIMP4NWY.js";var J=e(t(),1),Y=n(),X=r(),Z=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`,ye=[`c0`,`c1`,`c2`,`c3`,`c4`,`c5`];function be(e,t){return t.some(t=>t.connectorId===e.id)}function xe(){let e=(0,Y.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,X.jsx)(`div`,{className:a(`size-10 shrink-0 rounded-xl`,Z)}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,X.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,X.jsxs)(`div`,{className:`flex min-h-0 flex-1 items-start gap-3`,children:[t,(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,X.jsx)(`div`,{className:a(`h-4 min-w-0 flex-1`,Z)}),(0,X.jsx)(`div`,{className:a(`h-8 w-[4.5rem] shrink-0 rounded-lg`,Z)})]}),(0,X.jsx)(`div`,{className:a(`h-3 w-full`,Z)}),(0,X.jsx)(`div`,{className:a(`h-3 w-[88%]`,Z)})]})]})}),e[1]=n):n=e[1],n}function Se(){let e=(0,Y.c)(4),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,X.jsx)(`div`,{className:a(`size-10 shrink-0 rounded-xl`,Z)}),e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,X.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2`,children:[(0,X.jsx)(`div`,{className:a(`h-4 w-48 max-w-full`,Z)}),(0,X.jsx)(`div`,{className:a(`h-3 w-72 max-w-full`,Z)})]}),e[1]=n):n=e[1];let r;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,X.jsxs)(`div`,{className:`flex items-start gap-3`,children:[t,(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-start justify-between gap-3`,children:[n,(0,X.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,X.jsx)(`div`,{className:a(`h-9 w-20 rounded-lg`,Z)}),(0,X.jsx)(`div`,{className:a(`h-9 w-20 rounded-lg`,Z)})]})]})]}),e[2]=r):r=e[2];let i;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,X.jsxs)(`div`,{className:`rounded-2xl bg-surface-panel p-4 shadow-surface`,"aria-hidden":!0,children:[r,(0,X.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,X.jsx)(`div`,{className:a(`h-8 w-20 rounded-md`,Z)}),(0,X.jsx)(`div`,{className:a(`h-8 w-24 rounded-md`,Z)}),(0,X.jsx)(`div`,{className:a(`h-8 w-28 rounded-md`,Z)})]}),(0,X.jsx)(`div`,{className:a(`mt-3 h-20 rounded-xl`,Z)})]}),e[3]=i):i=e[3],i}function Ce(e){let t=(0,Y.c)(80),{connector:n,installed:r,onInstall:i,onOpenDetails:o,t:s}=e,c,l,u,d,f,p,m,h,g,_;if(t[0]!==n||t[1]!==r||t[2]!==i||t[3]!==o||t[4]!==s.connect||t[5]!==s.connectedBadge||t[6]!==s.connectorBeta||t[7]!==s.connectorCapabilityLabels||t[8]!==s.connectorExperimental||t[9]!==s.connectorVerified||t[10]!==s.integrationStrategyComposio||t[11]!==s.integrationStrategyMcp||t[12]!==s.integrationStrategyNative){let e=n.capabilities.filter(we),v=e.slice(0,3),y=Math.max(0,e.length-v.length),x=s.connect,S=n.verificationLevel===`verified`?s.connectorVerified:n.verificationLevel===`beta`?s.connectorBeta:n.verificationLevel===`experimental`?s.connectorExperimental:null,C=n.integrationStrategy?.lane===`native`?s.integrationStrategyNative:n.integrationStrategy?.lane===`mcp`?s.integrationStrategyMcp:n.integrationStrategy?.lane===`composio`?s.integrationStrategyComposio:null,w;t[23]!==x||t[24]!==n||t[25]!==i?(w=e=>(0,X.jsxs)(W,{type:`button`,variant:`primary`,className:a(`h-8 justify-center px-2.5 text-xs font-medium`,e),onClick:e=>{e.stopPropagation(),i(n)},children:[(0,X.jsx)(b,{className:`size-4`}),x]}),t[23]=x,t[24]=n,t[25]=i,t[26]=w):w=t[26],c=w;let T;t[27]!==n||t[28]!==o?(T=e=>{!o||e.currentTarget!==e.target||e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),o(n))},t[27]=n,t[28]=o,t[29]=T):T=t[29];let E=T,D=o?`cursor-pointer`:null;t[30]===D?p=t[31]:(p=a(`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`,D),t[30]=D,t[31]=p),m=o?`button`:void 0,h=o?0:void 0,t[32]!==n||t[33]!==o?(g=()=>o?.(n),t[32]=n,t[33]=o,t[34]=g):g=t[34],_=E,l=`flex min-w-0 flex-1 flex-col`;let O;t[35]===n?O=t[36]:(O=(0,X.jsx)(q,{connector:n}),t[35]=n,t[36]=O);let k;t[37]===n.displayName?k=t[38]:(k=(0,X.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:n.displayName}),t[37]=n.displayName,t[38]=k);let A;t[39]===S?A=t[40]:(A=S?(0,X.jsx)(`span`,{className:`mt-1 inline-flex rounded-full border border-edge px-1.5 py-0.5 text-[10px] font-medium text-fg-subtle`,children:S}):null,t[39]=S,t[40]=A);let j;t[41]===C?j=t[42]:(j=C?(0,X.jsx)(`span`,{className:`ml-1 mt-1 inline-flex rounded-full border border-accent/20 bg-accent-soft px-1.5 py-0.5 text-[10px] font-medium text-accent-fg`,children:C}):null,t[41]=C,t[42]=j);let M;t[43]!==k||t[44]!==A||t[45]!==j?(M=(0,X.jsxs)(`div`,{className:`min-w-0`,children:[k,A,j]}),t[43]=k,t[44]=A,t[45]=j,t[46]=M):M=t[46];let N;t[47]!==O||t[48]!==M?(N=(0,X.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[O,M]}),t[47]=O,t[48]=M,t[49]=N):N=t[49];let P;t[50]!==r||t[51]!==c?(P=r?null:(0,X.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:c()}),t[50]=r,t[51]=c,t[52]=P):P=t[52];let F;t[53]!==r||t[54]!==s.connectedBadge?(F=r?(0,X.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,X.jsx)(B,{className:`size-3`,"aria-hidden":!0}),s.connectedBadge]}):null,t[53]=r,t[54]=s.connectedBadge,t[55]=F):F=t[55];let I;t[56]!==P||t[57]!==F?(I=(0,X.jsxs)(`div`,{className:`flex shrink-0 items-start gap-2`,children:[P,F]}),t[56]=P,t[57]=F,t[58]=I):I=t[58],t[59]!==N||t[60]!==I?(u=(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[N,I]}),t[59]=N,t[60]=I,t[61]=u):u=t[61],t[62]===n.description?d=t[63]:(d=(0,X.jsx)(`p`,{className:`mt-4 line-clamp-2 text-sm leading-6 text-fg-muted`,title:n.description,children:n.description}),t[62]=n.description,t[63]=d),f=v.length>0?(0,X.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-1.5`,children:[v.map(e=>(0,X.jsx)(`span`,{className:`rounded-md bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:s.connectorCapabilityLabels[e]??e},e)),y>0?(0,X.jsxs)(`span`,{className:`rounded-md bg-surface-base px-2 py-0.5 text-[11px] text-fg-subtle`,children:[`+`,y]}):null]}):null,t[0]=n,t[1]=r,t[2]=i,t[3]=o,t[4]=s.connect,t[5]=s.connectedBadge,t[6]=s.connectorBeta,t[7]=s.connectorCapabilityLabels,t[8]=s.connectorExperimental,t[9]=s.connectorVerified,t[10]=s.integrationStrategyComposio,t[11]=s.integrationStrategyMcp,t[12]=s.integrationStrategyNative,t[13]=c,t[14]=l,t[15]=u,t[16]=d,t[17]=f,t[18]=p,t[19]=m,t[20]=h,t[21]=g,t[22]=_}else c=t[13],l=t[14],u=t[15],d=t[16],f=t[17],p=t[18],m=t[19],h=t[20],g=t[21],_=t[22];let v;t[64]!==l||t[65]!==u||t[66]!==d||t[67]!==f?(v=(0,X.jsxs)(`div`,{className:l,children:[u,d,f]}),t[64]=l,t[65]=u,t[66]=d,t[67]=f,t[68]=v):v=t[68];let y;t[69]!==r||t[70]!==c?(y=r?null:(0,X.jsx)(`div`,{className:`mt-4 flex flex-col gap-2 border-t border-edge pt-3 sm:hidden`,children:c(`w-full`)}),t[69]=r,t[70]=c,t[71]=y):y=t[71];let x;return t[72]!==v||t[73]!==y||t[74]!==p||t[75]!==m||t[76]!==h||t[77]!==g||t[78]!==_?(x=(0,X.jsxs)(`div`,{className:p,role:m,tabIndex:h,onClick:g,onKeyDown:_,children:[v,y]}),t[72]=v,t[73]=y,t[74]=p,t[75]=m,t[76]=h,t[77]=g,t[78]=_,t[79]=x):x=t[79],x}function we(e){return!e.startsWith(`runtime.`)&&!e.startsWith(`auth.`)}function Q(e,t){if(!e.payload)throw Error(e.error??t);return e.payload}async function Te(){let[e,t]=await Promise.all([u(l(`/api/connectors/catalog`)),Ee().catch(()=>[])]),n=Q(e,`Could not load connector catalog.`).connectors;return[...new Map([...t,...n].map(e=>[e.id,e])).values()]}async function Ee(e=!1){return Q(await u(l(`/api/connectors/composio/catalog${e?`?refresh=1`:``}`)),`Could not load Composio catalog.`).connectors}async function De(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),Q(await u(l(`/api/capabilities/connectors${t.size?`?${t.toString()}`:``}`)),`Could not load Store connector capabilities.`)}async function Oe(e,t){return Q(await u(l(`/api/capabilities/connectors/${encodeURIComponent(e)}/install-plan`),{method:`POST`,body:JSON.stringify({version:t})}),`Could not prepare connector installation.`).plan}async function ke(e,t,n){let r=await u(l(`/api/capabilities/connectors/${encodeURIComponent(e)}/install`),{method:`POST`,body:JSON.stringify({...t,version:n})});return le(),Q(r,`Could not install Store connector.`).instance}async function Ae(){return Q(await u(l(`/api/connectors/catalog`)),`Could not load connector registries.`).registries??[]}async function je(){return Q(await u(l(`/api/connectors/installed`)),`Could not load installed connectors.`).instances}var Me=new Map,Ne=300*1e3;async function Pe(e,t=`all`,n){let r=e.trim(),i=t.trim()||`all`,a=n?.browse??!1,o=Math.max(n?.page??1,1),s=Math.max(n?.pageSize??24,1),c=`${i}:${r}:${a?`browse`:`search`}:${o}:${s}`,d=Date.now(),f=Me.get(c);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(s));let m=u(l(`/api/connectors/registry/search?${p.toString()}`)).then(e=>{let t=Q(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}});Me.set(c,{expiresAt:d+Ne,promise:m});try{return await m}catch(e){throw Me.delete(c),e}}async function Fe(e){return Q(await u(l(`/api/connectors/${encodeURIComponent(e)}/auth/start`),{method:`POST`}),`Could not start connector authorization.`).authorization}async function Ie(e,t){let n=await u(l(`/api/connectors/${encodeURIComponent(e)}/install`),{method:`POST`,body:JSON.stringify(t)});return le(),Q(n,`Could not install connector.`).instance}async function Le(e,t={}){return Q(await u(l(`/api/connectors/preview`),{method:`POST`,body:JSON.stringify({...t,definition:e})}),`Could not preview connector capabilities.`).preview}async function Re(e,t){return Q(await u(l(`/api/connectors/${encodeURIComponent(e)}/config`),{method:`POST`,body:JSON.stringify(t)}),`Could not update connector config.`).instance}async function ze(e){await u(l(`/api/connectors/${encodeURIComponent(e)}`),{method:`DELETE`}),le()}async function Be(e){return Q(await u(l(`/api/connectors/${encodeURIComponent(e)}/test`),{method:`POST`}),`Connector test failed.`)}async function Ve(){return Q(await u(l(`/api/connectors/composio/connections`)),`Could not load Composio connections.`).connections}async function He(e,t){return Q(await u(l(`/api/connectors/composio/connections/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify(t)}),`Could not update Composio connection.`).connection}async function Ue(e){return Q(await u(l(`/api/connectors/composio/${encodeURIComponent(e)}/health`)),`Could not check Composio connector health.`).health}async function We(e){await u(l(`/api/connectors/composio/connections/${encodeURIComponent(e)}/refresh`),{method:`POST`})}async function Ge(e){await u(l(`/api/connectors/composio/connections/${encodeURIComponent(e)}`),{method:`DELETE`})}async function Ke(e){return Q(await u(l(`/api/connectors/composio/${encodeURIComponent(e)}/scope`)),`Could not load Composio scope.`).scope}async function qe(e,t){let n=await u(l(`/api/connectors/composio/${encodeURIComponent(e)}/scope`),{method:`POST`,body:JSON.stringify({scope:t})});return le(),Q(n,`Could not update Composio scope.`).scope}async function Je(e){return Q(await u(l(`/api/connectors/composio/${encodeURIComponent(e)}/policy`)),`Could not load Composio policy.`)}async function Ye(e,t){return Q(await u(l(`/api/connectors/composio/${encodeURIComponent(e)}/policy`),{method:`PATCH`,body:JSON.stringify(t)}),`Could not update Composio policy.`).policy}async function Xe(e){return Q(await u(l(`/api/connectors/composio/${encodeURIComponent(e)}/tools`)),`Could not load Composio tools.`).tools}async function Ze(e=50){return Q(await u(l(`/api/connectors/composio/triggers?limit=${encodeURIComponent(String(e))}`)),`Could not load Composio trigger events.`).events}async function Qe(e){return Q(await u(l(`/api/connectors/${encodeURIComponent(e.connectorId)}/memory-sync`),{method:`POST`,body:JSON.stringify(e)}),`Could not sync connector data to memory.`)}async function $e(e=`pending`){return Q(await u(l(`/api/connectors/approvals?status=${encodeURIComponent(e)}`)),`Could not load connector approvals.`).approvals}async function et(e,t){return Q(await u(l(`/api/connectors/approvals/respond`),{method:`POST`,body:JSON.stringify({id:e,decision:t})}),`Could not update connector approval.`).approval}function tt(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,String(n)),e)}function nt(e,t){return t.connectorCapabilityLabels[e]??e}function rt(e,t){if(e.runtime.type===`mcp`)return tt(t.connectorRuntimeMcp,{serverId:e.runtime.serverId});let n=e.runtime.type===`composio`?e.runtime.toolkit:e.runtime.type===`channel`?e.runtime.channelId:e.runtime.type===`nativeTool`?e.runtime.toolsetId:e.runtime.sourceKind;return tt(t.connectorRuntimeGeneric,{runtime:e.runtime.type,id:n??e.runtime.type})}function it(e,t){return e.auth.mode===`oauth`?t.connectorAuthOAuth:e.auth.mode===`apiKey`?t.connectorAuthApiKey:t.connectorAuthNone}function at(e){return(e.setup.secrets??[]).filter(e=>e.required).length+(e.setup.config??[]).filter(e=>e.required).length}function ot(e){let t=(0,Y.c)(12),{title:n,items:r}=e;if(r.length===0)return null;let i;t[0]===n?i=t[1]:(i=(0,X.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(st),t[2]=r,t[3]=a);let o;t[4]===r.length?o=t[5]:(o=r.length>16?(0,X.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,X.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,X.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 st(e){return(0,X.jsxs)(`div`,{className:`border-b border-edge-subtle px-3 py-2 last:border-b-0`,children:[(0,X.jsx)(`div`,{className:`break-words font-mono text-xs font-medium text-fg`,children:e.title}),e.description?(0,X.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:e.description}):null]},e.id)}function ct({connector:e,installed:t,onClose:n,onInstall:r,t:i}){let[o,s]=(0,J.useState)(!1),[c,l]=(0,J.useState)(null),[u,d]=(0,J.useState)(null),f=at(e),h=e.capabilities.slice(0,8),g=Math.max(0,e.capabilities.length-h.length),_=[...(e.setup.secrets??[]).map(e=>({key:`secret:${e.key}`,label:e.label,description:e.description,required:e.required,kind:i.connectorSetupSecret})),...(e.setup.config??[]).map(e=>({key:`config:${e.key}`,label:e.label,description:e.description,required:!!e.required,kind:i.connectorSetupConfig}))],v=async()=>{s(!0),d(null);try{l(await Le(e))}catch(e){l(null),d(e instanceof Error?e.message:String(e))}finally{s(!1)}};return(0,X.jsx)(A,{open:!0,onOpenChange:e=>{e||n()},children:(0,X.jsxs)(k,{children:[(0,X.jsx)(O,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,X.jsxs)(m,{className:a(`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,X.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,X.jsx)(q,{connector:e,size:`lg`}),(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-center gap-2`,children:[(0,X.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,X.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,X.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,X.jsx)(B,{className:`size-3`,"aria-hidden":!0}),i.connectedBadge]}):null]}),(0,X.jsx)(j,{className:`text-base font-semibold text-fg`,children:e.displayName}),(0,X.jsx)(se,{className:`mt-1 line-clamp-3 text-sm leading-6 text-fg-muted`,children:e.description})]})]}),(0,X.jsx)(U,{asChild:!0,children:(0,X.jsxs)(`button`,{type:`button`,className:a(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,ne.focusRingPanel),"aria-label":i.modalClose,children:[(0,X.jsx)(G,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`sr-only`,children:i.modalClose})]})})]}),(0,X.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:[(0,X.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-3`,children:[(0,X.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,X.jsx)(_e,{className:`size-3.5`,"aria-hidden":!0}),i.detailTools]}),(0,X.jsx)(`p`,{className:`mt-2 text-sm font-semibold text-fg`,children:c?tt(i.connectorPreviewToolsCount,{count:c.toolCount}):i.connectorPreviewUnknown})]}),(0,X.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,X.jsx)(p,{className:`size-3.5`,"aria-hidden":!0}),i.detailPermissions]}),(0,X.jsx)(`p`,{className:`mt-2 text-sm font-semibold text-fg`,children:it(e,i)})]}),(0,X.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[(0,X.jsx)(oe,{className:`size-3.5`,"aria-hidden":!0}),i.connectorRequiredInputs]}),(0,X.jsx)(`p`,{className:`mt-2 text-sm font-semibold text-fg`,children:tt(i.connectorRequiredInputsCount,{count:f})})]})]}),(0,X.jsxs)(`div`,{className:`mt-5 grid gap-5 lg:grid-cols-[minmax(0,1fr)_18rem]`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 space-y-5`,children:[(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:i.connectorCapabilitiesTitle}),(0,X.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:[h.map(e=>(0,X.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-base px-2 py-1 text-xs text-fg-muted`,children:nt(e,i)},e)),g>0?(0,X.jsxs)(`span`,{className:`rounded-md border border-edge bg-surface-base px-2 py-1 text-xs text-fg-subtle`,children:[`+`,g]}):null]}),(0,X.jsx)(`p`,{className:`mt-3 text-sm leading-6 text-fg-muted`,children:i.connectorCapabilitiesHint})]}),u?(0,X.jsx)(`p`,{className:`rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:u}):null,c?(0,X.jsxs)(`section`,{children:[(0,X.jsxs)(`div`,{className:`mb-3 flex flex-wrap items-center justify-between gap-2`,children:[(0,X.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:i.connectorPreviewTitle}),(0,X.jsx)(`span`,{className:a(`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?i.healthStatusHealthy:i.healthStatusLabels[c.status]??c.status})]}),(0,X.jsxs)(`div`,{className:`mb-3 grid gap-2 text-xs sm:grid-cols-3`,children:[(0,X.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base px-3 py-2`,children:[(0,X.jsx)(`div`,{className:`font-semibold text-fg`,children:c.toolCount}),(0,X.jsx)(`div`,{className:`text-fg-muted`,children:i.toolsMetric})]}),(0,X.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base px-3 py-2`,children:[(0,X.jsx)(`div`,{className:`font-semibold text-fg`,children:c.resourceCount}),(0,X.jsx)(`div`,{className:`text-fg-muted`,children:i.resourcesMetric})]}),(0,X.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base px-3 py-2`,children:[(0,X.jsx)(`div`,{className:`font-semibold text-fg`,children:c.promptCount}),(0,X.jsx)(`div`,{className:`text-fg-muted`,children:i.promptsMetric})]})]}),(0,X.jsxs)(`div`,{className:`grid gap-2`,children:[(0,X.jsx)(ot,{title:i.detailTools,items:c.tools.map(e=>({id:e.name,title:e.shortName??e.name,description:e.description}))}),(0,X.jsx)(ot,{title:i.detailResources,items:c.resources.map(e=>({id:e.uri,title:e.title??e.name??e.uri,description:e.description??e.uri}))}),(0,X.jsx)(ot,{title:i.detailPrompts,items:c.prompts.map(e=>({id:e.name,title:e.title??e.name,description:e.description??tt(i.promptArgumentCount,{count:e.argumentCount})}))})]}),c.error?(0,X.jsx)(`p`,{className:`mt-3 text-xs leading-5 text-fg-subtle`,children:c.error}):null,c.action?(0,X.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-fg-subtle`,children:c.action}):null]}):null]}),(0,X.jsxs)(`aside`,{className:`space-y-3`,children:[(0,X.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,X.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,X.jsx)(p,{className:`size-4 text-accent`,"aria-hidden":!0}),i.detailPermissions]}),(0,X.jsx)(`p`,{className:`mt-2 text-sm font-medium text-fg`,children:it(e,i)})]}),(0,X.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,X.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,X.jsx)(oe,{className:`size-4 text-accent`,"aria-hidden":!0}),i.connectorSetupTitle]}),_.length>0?(0,X.jsx)(`div`,{className:`mt-3 divide-y divide-edge overflow-hidden rounded-lg border border-edge`,children:_.map(e=>(0,X.jsxs)(`div`,{className:`bg-surface-panel px-3 py-2.5`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.label}),(0,X.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,X.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:i.connectorSetupRequired}):null]}),e.description?(0,X.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:e.description}):null]},e.key))}):(0,X.jsx)(`p`,{className:`mt-2 text-sm leading-6 text-fg-muted`,children:i.connectorSetupNone})]}),(0,X.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,X.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,X.jsx)(M,{className:`size-4 text-accent`,"aria-hidden":!0}),i.connectorRuntimeTitle]}),(0,X.jsx)(`p`,{className:`mt-2 break-words text-xs leading-5 text-fg-muted`,children:rt(e,i)})]})]})]})]}),(0,X.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[(0,X.jsx)(U,{asChild:!0,children:(0,X.jsx)(W,{variant:`secondary`,children:i.modalClose})}),(0,X.jsxs)(W,{variant:`secondary`,disabled:o,onClick:()=>void v(),children:[o?(0,X.jsx)(N,{className:`size-4 animate-spin`}):(0,X.jsx)(_e,{className:`size-4`}),i.connectorPreviewButton]}),t?(0,X.jsxs)(W,{variant:`secondary`,disabled:!0,children:[(0,X.jsx)(H,{className:`size-4`}),i.connectedBadge]}):(0,X.jsxs)(W,{variant:`primary`,onClick:()=>{r(e),n()},children:[(0,X.jsx)(b,{className:`size-4`}),i.connect]})]})]})]})})}var lt=a(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,de);function ut(e){let t=(0,Y.c)(58),{open:n,sessionIdleTtlMinutes:r,saving:i,onChange:o,onSave:s,onClose:c,t:l,mcp:u}=e,d;t[0]===c?d=t[1]:(d=e=>{e||c()},t[0]=c,t[1]=d);let f;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,X.jsx)(O,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),t[2]=f):f=t[2];let p;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(p=a(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(32rem,calc(100vh-2rem))] w-[min(100%-2rem,38rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-panel shadow-float dark:border-edge`),t[3]=p):p=t[3];let h;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,X.jsx)(`span`,{className:`flex size-10 shrink-0 items-center justify-center rounded-xl bg-accent-soft text-accent-fg`,children:(0,X.jsx)(ae,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0})}),t[4]=h):h=t[4];let g;t[5]===l.runtimeSettingsTitle?g=t[6]:(g=(0,X.jsx)(j,{className:`text-base font-semibold text-fg`,children:l.runtimeSettingsTitle}),t[5]=l.runtimeSettingsTitle,t[6]=g);let _;t[7]===l.runtimeSettingsHint?_=t[8]:(_=(0,X.jsx)(se,{className:`mt-1 text-sm text-fg-muted`,children:l.runtimeSettingsHint}),t[7]=l.runtimeSettingsHint,t[8]=_);let v;t[9]!==g||t[10]!==_?(v=(0,X.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[h,(0,X.jsxs)(`div`,{className:`min-w-0`,children:[g,_]})]}),t[9]=g,t[10]=_,t[11]=v):v=t[11];let y;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(y=a(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,ne.focusRingPanel),t[12]=y):y=t[12];let b;t[13]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,X.jsx)(G,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),t[13]=b):b=t[13];let x;t[14]===l.modalClose?x=t[15]:(x=(0,X.jsx)(U,{asChild:!0,children:(0,X.jsx)(`button`,{type:`button`,className:y,"aria-label":l.modalClose,children:b})}),t[14]=l.modalClose,t[15]=x);let S;t[16]!==x||t[17]!==v?(S=(0,X.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[v,x]}),t[16]=x,t[17]=v,t[18]=S):S=t[18];let C;t[19]===u.idleTtlLabel?C=t[20]:(C=(0,X.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:u.idleTtlLabel}),t[19]=u.idleTtlLabel,t[20]=C);let w;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(w=a(lt,`w-40 flex-none`),t[21]=w):w=t[21];let T=r??``,E;t[22]===o?E=t[23]:(E=e=>{let t=e.currentTarget.value.trim();o(t===``?void 0:Number.parseInt(t,10))},t[22]=o,t[23]=E);let D;t[24]!==u.idleTtlPlaceholder||t[25]!==T||t[26]!==E?(D=(0,X.jsx)(`input`,{type:`number`,min:0,className:w,value:T,placeholder:u.idleTtlPlaceholder,onChange:E}),t[24]=u.idleTtlPlaceholder,t[25]=T,t[26]=E,t[27]=D):D=t[27];let M;t[28]===u.idleTtlHint?M=t[29]:(M=(0,X.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:u.idleTtlHint}),t[28]=u.idleTtlHint,t[29]=M);let P;t[30]!==C||t[31]!==D||t[32]!==M?(P=(0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:(0,X.jsxs)(`label`,{className:`flex max-w-xl flex-col gap-1.5`,children:[C,D,M]})}),t[30]=C,t[31]=D,t[32]=M,t[33]=P):P=t[33];let F;t[34]!==c||t[35]!==i||t[36]!==l.modalCancel?(F=(0,X.jsx)(W,{type:`button`,variant:`secondary`,disabled:i,onClick:c,children:l.modalCancel}),t[34]=c,t[35]=i,t[36]=l.modalCancel,t[37]=F):F=t[37];let I;t[38]===s?I=t[39]:(I=()=>void s(),t[38]=s,t[39]=I);let L;t[40]===i?L=t[41]:(L=i?(0,X.jsx)(N,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,t[40]=i,t[41]=L);let R;t[42]!==u.save||t[43]!==i||t[44]!==I||t[45]!==L?(R=(0,X.jsxs)(W,{type:`button`,variant:`primary`,disabled:i,onClick:I,children:[L,u.save]}),t[42]=u.save,t[43]=i,t[44]=I,t[45]=L,t[46]=R):R=t[46];let z;t[47]!==F||t[48]!==R?(z=(0,X.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[F,R]}),t[47]=F,t[48]=R,t[49]=z):z=t[49];let B;t[50]!==S||t[51]!==P||t[52]!==z?(B=(0,X.jsxs)(k,{children:[f,(0,X.jsxs)(m,{className:p,children:[S,P,z]})]}),t[50]=S,t[51]=P,t[52]=z,t[53]=B):B=t[53];let V;return t[54]!==n||t[55]!==d||t[56]!==B?(V=(0,X.jsx)(A,{open:n,onOpenChange:d,children:B}),t[54]=n,t[55]=d,t[56]=B,t[57]=V):V=t[57],V}var dt=(0,J.memo)(function(e){let t=(0,Y.c)(12),{value:n,onChange:r,placeholder:i,className:o}=e,s;t[0]===o?s=t[1]:(s=a(`relative flex min-h-9 min-w-0 flex-1 cursor-text items-center rounded-pill border border-edge bg-surface-panel py-1.5 pl-9 pr-3 shadow-surface`,o),t[0]=o,t[1]=s);let c;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(c=(0,X.jsx)(re,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-disabled`,strokeWidth:1.75,"aria-hidden":!0}),t[2]=c):c=t[2];let l;t[3]===r?l=t[4]:(l=e=>r(e.currentTarget.value),t[3]=r,t[4]=l);let u;t[5]!==i||t[6]!==l||t[7]!==n?(u=(0,X.jsx)(`input`,{type:`search`,enterKeyHint:`search`,value:n,onChange:l,placeholder:i,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[5]=i,t[6]=l,t[7]=n,t[8]=u):u=t[8];let d;return t[9]!==s||t[10]!==u?(d=(0,X.jsxs)(`label`,{className:s,children:[c,u]}),t[9]=s,t[10]=u,t[11]=d):d=t[11],d}),ft=(0,J.memo)(function(e){let t=(0,Y.c)(30),{onBrowseCatalog:n,onAddCustomServer:r,onOpenRuntimeSettings:i,addLabel:o,browseLabel:s,customLabel:c,settingsLabel:l}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,X.jsx)(ee,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[0]=u):u=t[0];let d;t[1]===l?d=t[2]:(d=(0,X.jsx)(`span`,{className:`hidden sm:inline`,children:l}),t[1]=l,t[2]=d);let f;t[3]!==i||t[4]!==l||t[5]!==d?(f=(0,X.jsxs)(W,{type:`button`,variant:`secondary`,className:`shrink-0 gap-2`,"aria-label":l,title:l,onClick:i,children:[u,d]}),t[3]=i,t[4]=l,t[5]=d,t[6]=f):f=t[6];let p;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(p=(0,X.jsx)(ce,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[7]=p):p=t[7];let m;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,X.jsx)(ie,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[8]=m):m=t[8];let h;t[9]===o?h=t[10]:(h=(0,X.jsx)(x,{asChild:!0,children:(0,X.jsxs)(W,{type:`button`,variant:`primary`,className:`shrink-0 gap-2`,children:[p,o,m]})}),t[9]=o,t[10]=h);let g;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(g=a(`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none data-[highlighted]:bg-surface-hover`,ne.transition),t[11]=g):g=t[11];let _;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,X.jsx)(D,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[12]=_):_=t[12];let v;t[13]!==s||t[14]!==n?(v=(0,X.jsxs)(P,{className:g,onSelect:n,children:[_,s]}),t[13]=s,t[14]=n,t[15]=v):v=t[15];let b;t[16]===Symbol.for(`react.memo_cache_sentinel`)?(b=a(`flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none data-[highlighted]:bg-surface-hover`,ne.transition),t[16]=b):b=t[16];let S;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,X.jsx)(_e,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[17]=S):S=t[17];let C;t[18]!==c||t[19]!==r?(C=(0,X.jsxs)(P,{className:b,onSelect:r,children:[S,c]}),t[18]=c,t[19]=r,t[20]=C):C=t[20];let w;t[21]!==C||t[22]!==v?(w=(0,X.jsx)(y,{children:(0,X.jsxs)(K,{className:`z-50 min-w-[14rem] rounded-xl border border-edge bg-surface-panel p-1 shadow-popover dark:border-edge`,sideOffset:6,align:`end`,children:[v,C]})}),t[21]=C,t[22]=v,t[23]=w):w=t[23];let T;t[24]!==w||t[25]!==h?(T=(0,X.jsxs)(he,{children:[h,w]}),t[24]=w,t[25]=h,t[26]=T):T=t[26];let E;return t[27]!==T||t[28]!==f?(E=(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center justify-end gap-2`,children:[f,T]}),t[27]=T,t[28]=f,t[29]=E):E=t[29],E}),pt=/^([^:=]+)[:=](.*)$/;function mt(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=pt.exec(t);r&&n.push({key:r[1].trim(),value:r[2].trim()})}return n.length>0?n:null}function ht(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 gt(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 _t(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 vt(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)||_t(t)&&(r[e]=t);return r}function yt(e){let t=e.trim();if(t)return t.split(/\s+/).filter(Boolean)}function bt(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 xt(e){if(e.transport===`stdio`){let t={command:e.command.trim()},n=yt(e.argsText);return n?.length&&(t.args=n),e.cwd.trim()&&(t.cwd=e.cwd.trim()),e.envJson.trim()&&(t.env=bt(e.envJson)),e.connectionTimeoutMs!=null&&Number.isFinite(e.connectionTimeoutMs)&&(t.connectionTimeoutMs=e.connectionTimeoutMs),t}let t={url:e.url.trim(),transport:e.transport},n=ht(e.headers);return n&&(t.headers=n),e.connectionTimeoutMs!=null&&Number.isFinite(e.connectionTimeoutMs)&&(t.connectionTimeoutMs=e.connectionTimeoutMs),t}function St(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:gt(a),connectionTimeoutMs:typeof t.connectionTimeoutMs==`number`&&Number.isFinite(t.connectionTimeoutMs)?t.connectionTimeoutMs:void 0}}function Ct(e=``){return{clientKey:crypto.randomUUID(),id:e,transport:`stdio`,command:``,argsText:``,envJson:``,cwd:``,url:``,headers:[{key:`Authorization`,value:``}],connectionTimeoutMs:void 0}}function wt(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)||_t(t)?[]:[St(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 Tt(e){return xt(e)}async function Et(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]=xt(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 u(l(`/api/config`),{method:`PATCH`,body:JSON.stringify({mcp:r})}),le()}function Dt(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 Ot(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(!n||typeof n!=`object`)continue;let e=n;if(typeof e.uri!=`string`||typeof e.name!=`string`)continue;let r=e.uri.trim(),i=e.name.trim();!r||!i||t.push({uri:r,name:i,title:typeof e.title==`string`&&e.title.trim()?e.title.trim():void 0,description:typeof e.description==`string`&&e.description.trim()?e.description.trim():void 0,mimeType:typeof e.mimeType==`string`&&e.mimeType.trim()?e.mimeType.trim():void 0})}return t}function kt(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(!n||typeof n!=`object`)continue;let e=n;if(typeof e.name!=`string`)continue;let r=e.name.trim();r&&t.push({name:r,title:typeof e.title==`string`&&e.title.trim()?e.title.trim():void 0,description:typeof e.description==`string`&&e.description.trim()?e.description.trim():void 0,argumentCount:typeof e.argumentCount==`number`?e.argumentCount:0})}return t}async function At(e,t){let n=await u(l(`/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=Dt(n.payload.tools),i=Ot(n.payload.resources),a=kt(n.payload.prompts);return{serverId:n.payload.serverId??e,toolCount:typeof n.payload.toolCount==`number`?n.payload.toolCount:r.length,resourceCount:typeof n.payload.resourceCount==`number`?n.payload.resourceCount:i.length,promptCount:typeof n.payload.promptCount==`number`?n.payload.promptCount:a.length,tools:r,resources:i,prompts:a}}function jt(e){return e.connectionTimeoutMs==null||!Number.isFinite(e.connectionTimeoutMs)?``:String(Math.round(e.connectionTimeoutMs/1e3))}function Mt(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 Nt(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 $(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,n),e)}function Pt({row:e,t,cs:n,onEdit:r,onRemove:i}){let[a,o]=(0,J.useState)(!1),[s,c]=(0,J.useState)(!1),[l,u]=(0,J.useState)(null),[d,f]=(0,J.useState)(null),p=Nt(e),m=(0,J.useCallback)(async()=>{o(!0),f(null);try{let t=await At(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]),g=(0,J.useCallback)(async()=>{c(!0),f(null);try{await i()}catch(e){f(e instanceof Error?e.message:String(e)),c(!1)}},[i]);return(0,X.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,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:e.id.trim()||t.cardUntitled}),(0,X.jsx)(`span`,{className:`rounded-full bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:n.customBadge}),(0,X.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,X.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,X.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,X.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:$(n.customCapabilitySummary,{tools:String(l.toolCount),resources:String(l.resourceCount),prompts:String(l.promptCount)})}):null]}),(0,X.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-2 border-t border-edge pt-3`,onClick:e=>e.stopPropagation(),children:[(0,X.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:n.connectorDetails}),(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsxs)(W,{variant:`secondary`,disabled:a,onClick:()=>void m(),children:[a?(0,X.jsx)(N,{className:`size-4 animate-spin`}):(0,X.jsx)(H,{className:`size-4`}),t.testConnection]}),(0,X.jsxs)(W,{variant:`ghost`,disabled:s,onClick:()=>void g(),children:[s?(0,X.jsx)(N,{className:`size-4 animate-spin`}):(0,X.jsx)(h,{className:`size-4`}),t.removeServer]})]})]})]})}function Ft(e,t){return e?t&&e.startsWith(t)?e.slice(t.length):e:``}function It(e,t,n){let r=t.trim().toLowerCase();if(!r)return!0;let i=e.shortName||Ft(e.name,n);return[e.name,i,e.description].filter(Boolean).join(`
2
+ `).toLowerCase().includes(r)}function Lt(e,t){return e?t&&e.startsWith(t)?e.slice(t.length):e:``}function Rt(e){let t=(0,Y.c)(29),{tools:n,stripPrefix:r,searchPlaceholder:i,searchEmptyLabel:o}=e,[s,c]=(0,J.useState)(``),l;if(t[0]!==s||t[1]!==r||t[2]!==n){let e;t[4]!==s||t[5]!==r?(e=e=>It(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,X.jsx)(re,{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=a(`w-full rounded-lg border border-edge bg-surface-panel py-2 pl-9 pr-3 text-sm text-fg`,`placeholder:text-fg-subtle`,de),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]!==i?(g=(0,X.jsxs)(`div`,{className:`relative`,children:[p,(0,X.jsx)(`input`,{type:`search`,value:s,placeholder:i,"aria-label":i,className:m,onChange:h})]}),t[12]=s,t[13]=i,t[14]=g):g=t[14];let _;t[15]!==u.length||t[16]!==f||t[17]!==n.length?(_=f?(0,X.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,X.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,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:u.length===0?(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:o}):(0,X.jsx)(`ul`,{className:`flex flex-col gap-2`,children:u.map((e,t)=>{let n=e.shortName||Lt(e.name,r)||e.name||`?`,i=e.name||`tool-${t}`;return(0,X.jsxs)(`li`,{className:`min-w-0 rounded-lg border border-edge bg-surface-base px-3 py-2.5`,children:[(0,X.jsx)(`div`,{className:`truncate font-mono text-sm font-medium text-fg`,title:e.name===n?n:e.name,children:n}),e.description?(0,X.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,X.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 zt(e){let t=(0,Y.c)(38),{open:n,onOpenChange:r,serverId:i,title:o,subtitle:s,searchPlaceholder:c,searchEmptyLabel:l,emptyLabel:u,closeLabel:d,tools:f,stripPrefix:p}=e,h;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,X.jsx)(O,{className:a(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,V)}),t[0]=h):h=t[0];let g;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(g=a(`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`,w,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`),t[1]=g):g=t[1];let _;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,X.jsx)(_e,{className:`size-4 shrink-0 text-accent`,"aria-hidden":!0}),t[2]=_):_=t[2];let v;t[3]===o?v=t[4]:(v=(0,X.jsxs)(j,{className:`flex items-center gap-2 text-base font-semibold text-fg`,children:[_,o]}),t[3]=o,t[4]=v);let y;t[5]!==i||t[6]!==s||t[7]!==f.length?(y=s.replace(`{{serverId}}`,i).replace(`{{count}}`,String(f.length)),t[5]=i,t[6]=s,t[7]=f.length,t[8]=y):y=t[8];let b;t[9]===y?b=t[10]:(b=(0,X.jsx)(se,{className:`mt-1 text-sm text-fg-muted`,children:y}),t[9]=y,t[10]=b);let x;t[11]!==v||t[12]!==b?(x=(0,X.jsxs)(`div`,{className:`min-w-0`,children:[v,b]}),t[11]=v,t[12]=b,t[13]=x):x=t[13];let S;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,X.jsx)(G,{className:`size-4`,"aria-hidden":!0}),t[14]=S):S=t[14];let C;t[15]===d?C=t[16]:(C=(0,X.jsx)(U,{asChild:!0,children:(0,X.jsx)(W,{type:`button`,variant:`ghost`,className:`size-8 shrink-0 px-0`,"aria-label":d,children:S})}),t[15]=d,t[16]=C);let T;t[17]!==x||t[18]!==C?(T=(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-3 border-b border-edge px-5 py-4`,children:[x,C]}),t[17]=x,t[18]=C,t[19]=T):T=t[19];let E;t[20]!==u||t[21]!==n||t[22]!==l||t[23]!==c||t[24]!==i||t[25]!==p||t[26]!==f?(E=f.length>0?(0,X.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,X.jsx)(Rt,{tools:f,stripPrefix:p,searchPlaceholder:c,searchEmptyLabel:l},`${i}-${n?`open`:`closed`}`)}):(0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:u})}),t[20]=u,t[21]=n,t[22]=l,t[23]=c,t[24]=i,t[25]=p,t[26]=f,t[27]=E):E=t[27];let D;t[28]===d?D=t[29]:(D=(0,X.jsx)(`div`,{className:`flex justify-end border-t border-edge px-5 py-3`,children:(0,X.jsx)(U,{asChild:!0,children:(0,X.jsx)(W,{type:`button`,variant:`secondary`,children:d})})}),t[28]=d,t[29]=D);let M;t[30]!==T||t[31]!==E||t[32]!==D?(M=(0,X.jsxs)(k,{children:[h,(0,X.jsxs)(m,{className:g,children:[T,E,D]})]}),t[30]=T,t[31]=E,t[32]=D,t[33]=M):M=t[33];let N;return t[34]!==r||t[35]!==n||t[36]!==M?(N=(0,X.jsx)(A,{open:n,onOpenChange:r,children:M}),t[34]=r,t[35]=n,t[36]=M,t[37]=N):N=t[37],N}var Bt=a(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,de);function Vt(e){return e.materialized.type===`composio`?e.materialized.toolkit:null}function Ht(e,t){return e===`write`?t.composioScopeWrite:e===`admin`?t.composioScopeAdmin:t.composioScopeRead}function Ut(e,t){return e.errorCode===`missing_credential`?t.composioHealthMissingCredential:e.errorCode===`unauthorized`?t.composioHealthUnauthorized:e.errorCode===`forbidden`?t.composioHealthForbidden:e.errorCode===`network`?t.composioHealthNetwork:e.errorCode===`timeout`?t.composioHealthTimeout:t.composioHealthDegraded}function Wt({instance:e,t}){let n=Vt(e),[r,i]=(0,J.useState)([]),[s,c]=(0,J.useState)([]),[l,u]=(0,J.useState)([]),[d,f]=(0,J.useState)([]),[m,g]=(0,J.useState)(null),[_,y]=(0,J.useState)([]),[b,x]=(0,J.useState)(``),[S,C]=(0,J.useState)(`{}`),[w,T]=(0,J.useState)(null),[D,O]=(0,J.useState)(null),[k,A]=(0,J.useState)(`read`),[j,M]=(0,J.useState)(!1),[P,F]=(0,J.useState)(null),I=(0,J.useCallback)(async()=>{if(!(!n||e.materialized.type!==`composio`||e.materialized.role===`credential`)){M(!0),F(null);try{let[t,r,a,o,s,l,d]=await Promise.all([Ve().catch(()=>[]),Xe(n).catch(()=>[]),Ze(20).catch(()=>[]),Ke(n).catch(()=>`read`),$e().catch(()=>[]),Je(n).catch(()=>null),Ue(n).catch(()=>null)]);i(t.filter(e=>e.toolkit.toLowerCase()===n.toLowerCase())),c(r),u(a.filter(e=>!e.toolkit||e.toolkit.toLowerCase()===n.toLowerCase())),A(o),f(s.filter(t=>t.connectorId===e.connectorId)),g(l?.policy??null),y(l?.agents??[]),x(e=>e||r.find(e=>e.scope===`read`&&e.curated)?.slug||``),O(d)}catch(e){F(e instanceof Error?e.message:String(e))}finally{M(!1)}}},[e.connectorId,e.materialized,n]);(0,J.useEffect)(()=>{I()},[I]);let L=(0,J.useCallback)(async()=>{if(n){M(!0),F(null);try{let t=await Fe(e.connectorId);if(!t.authorizationUrl)throw Error(`The authorization provider did not return an authorization URL.`);window.open(t.authorizationUrl,`_blank`,`noopener,noreferrer`)}catch(e){F(e instanceof Error?e.message:String(e))}finally{M(!1)}}},[e.connectorId,n]),R=(0,J.useCallback)(async e=>{if(n){A(e);try{await qe(n,e),await I()}catch(e){F(e instanceof Error?e.message:String(e))}}},[I,n]),B=(0,J.useCallback)(async(e,t)=>{M(!0),F(null);try{await et(e,t),await I()}catch(e){F(e instanceof Error?e.message:String(e))}finally{M(!1)}},[I]),V=(0,J.useCallback)(async e=>{if(n){F(null);try{g(await Ye(n,e))}catch(e){F(e instanceof Error?e.message:String(e))}}},[e.connectorId,n]),ee=(0,J.useCallback)(e=>{m&&V({allowedAgentIds:m.allowedAgentIds.includes(e)?m.allowedAgentIds.filter(t=>t!==e):[...m.allowedAgentIds,e]})},[V,m]),H=(0,J.useCallback)(async e=>{M(!0),F(null);try{await e(),await I()}catch(e){F(e instanceof Error?e.message:String(e))}finally{M(!1)}},[I]),te=(0,J.useCallback)(async()=>{if(!(!n||!b)){M(!0),F(null),T(null);try{let n=JSON.parse(S);if(!n||typeof n!=`object`||Array.isArray(n))throw Error(t.composioMemoryArgumentsObject);let i=m?.allowedAgentIds[0]??_[0]?.id;if(!i)throw Error(t.composioMemoryAgentMissing);T((await Qe({connectorId:e.connectorId,actionId:b,agentId:i,connectionId:r.find(e=>e.isDefault)?.id,arguments:n})).recordId)}catch(e){F(e instanceof Error?e.message:String(e))}finally{M(!1)}}},[_,r,e.connectorId,b,S,m,t,n]);return n?e.materialized.type===`composio`&&e.materialized.role===`credential`?(0,X.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:t.composioApiKeyStored}):(0,X.jsxs)(`div`,{className:`mt-4 rounded-xl border border-edge bg-surface-base p-3 text-sm`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`font-medium text-fg`,children:$(t.composioToolkitTitle,{toolkit:n})}),(0,X.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:t.composioScopeHint})]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,X.jsxs)(z,{className:a(Bt,`h-9 w-28 py-1`),value:k,onChange:e=>void R(e.currentTarget.value),children:[(0,X.jsx)(E,{value:`read`,children:t.composioScopeRead}),(0,X.jsx)(E,{value:`write`,children:t.composioScopeWrite}),(0,X.jsx)(E,{value:`admin`,children:t.composioScopeAdmin})]}),(0,X.jsxs)(W,{variant:`secondary`,disabled:j,onClick:()=>void L(),children:[j?(0,X.jsx)(N,{className:`size-4 animate-spin`}):(0,X.jsx)(p,{className:`size-4`}),t.connectOAuth]}),(0,X.jsx)(W,{variant:`ghost`,disabled:j,onClick:()=>void I(),children:t.refresh})]})]}),P?(0,X.jsx)(`p`,{className:`mt-3 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:P}):null,D?(0,X.jsxs)(`div`,{className:a(`mt-3 flex flex-wrap items-center justify-between gap-2 rounded-lg border px-3 py-2 text-xs`,D.status===`connected`?`border-emerald-500/30 bg-emerald-500/5 text-emerald-700`:`border-amber-500/30 bg-amber-500/5 text-amber-700`),children:[(0,X.jsx)(`span`,{children:D.status===`connected`?$(t.composioHealthConnected,{count:String(D.activeConnections)}):D.status===`reauthorization_required`?t.composioHealthReconnect:D.status===`degraded`?Ut(D,t):t.composioHealthDisconnected}),D.recovery===`none`?null:(0,X.jsx)(W,{variant:`ghost`,disabled:j,onClick:()=>void(D.recovery===`retry`?I():L()),children:D.recovery===`retry`?t.composioRetry:t.connectOAuth}),D.status===`degraded`&&D.message?(0,X.jsx)(`p`,{className:`basis-full break-words text-[11px] opacity-80`,children:D.message}):null]}):null,m?(0,X.jsxs)(`div`,{className:`mt-4 grid gap-3 rounded-lg border border-edge bg-surface-panel p-3 md:grid-cols-[minmax(0,180px)_1fr]`,children:[(0,X.jsxs)(`label`,{className:`text-xs font-medium text-fg-subtle`,children:[t.composioConfirmationPolicy,(0,X.jsxs)(z,{className:a(Bt,`mt-1 h-9 py-1`),value:m.confirmationPolicy,onChange:e=>void V({confirmationPolicy:e.currentTarget.value}),children:[(0,X.jsx)(E,{value:`writes`,children:t.composioConfirmWrites}),(0,X.jsx)(E,{value:`always`,children:t.composioConfirmAlways}),(0,X.jsx)(E,{value:`never`,children:t.composioConfirmNever})]})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`text-xs font-medium text-fg-subtle`,children:t.composioAllowedAgents}),(0,X.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:m.allowedAgentIds.length?t.composioAllowedAgentsSelected:t.composioAllowedAgentsAll}),(0,X.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:_.map(e=>(0,X.jsx)(`button`,{type:`button`,className:a(`rounded-full border px-2.5 py-1 text-xs transition-colors`,m.allowedAgentIds.includes(e.id)?`border-accent bg-accent/10 text-accent`:`border-edge text-fg-muted hover:text-fg`),onClick:()=>ee(e.id),children:e.name},e.id))})]})]}):null,[`gmail`,`googledrive`,`notion`,`slack`].includes(n)&&s.some(e=>e.scope===`read`&&e.curated)?(0,X.jsxs)(`div`,{className:`mt-4 rounded-lg border border-edge bg-surface-panel p-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,X.jsx)(oe,{className:`mt-0.5 size-4 text-accent`}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.composioMemorySync}),(0,X.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioMemorySyncHint})]})]}),(0,X.jsxs)(`div`,{className:`mt-3 grid gap-2 md:grid-cols-[minmax(0,240px)_1fr_auto] md:items-end`,children:[(0,X.jsxs)(`label`,{className:`text-xs text-fg-subtle`,children:[t.composioMemoryReadAction,(0,X.jsx)(z,{className:a(Bt,`mt-1 h-9 py-1`),value:b,onChange:e=>x(e.currentTarget.value),children:s.filter(e=>e.scope===`read`&&e.curated).map(e=>(0,X.jsx)(E,{value:e.slug,children:e.name??e.slug},e.slug))})]}),(0,X.jsxs)(`label`,{className:`text-xs text-fg-subtle`,children:[t.composioMemoryArguments,(0,X.jsx)(`input`,{className:a(Bt,`mt-1 h-9 py-1 font-mono text-xs`),value:S,onChange:e=>C(e.currentTarget.value)})]}),(0,X.jsxs)(W,{disabled:j||!b,onClick:()=>void te(),children:[j?(0,X.jsx)(N,{className:`size-4 animate-spin`}):(0,X.jsx)(oe,{className:`size-4`}),t.composioSyncNow]})]}),w?(0,X.jsx)(`p`,{className:`mt-2 text-xs text-emerald-600`,children:$(t.composioMemorySynced,{id:w})}):null]}):null,d.length?(0,X.jsxs)(`div`,{className:`mt-4 space-y-2`,children:[(0,X.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioPendingApprovals}),d.map(e=>(0,X.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-lg border border-amber-500/30 bg-amber-500/5 p-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`p`,{className:`truncate font-mono text-xs font-medium text-fg`,children:e.actionId}),(0,X.jsx)(`p`,{className:`mt-1 break-all font-mono text-xs text-fg-subtle`,children:JSON.stringify(e.argumentsPreview)}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:$(t.composioApprovalExpires,{time:new Date(e.expiresAt).toLocaleTimeString()})})]}),(0,X.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,X.jsxs)(W,{variant:`secondary`,disabled:j,onClick:()=>void B(e.id,`denied`),children:[(0,X.jsx)(G,{className:`size-4`}),t.composioDeny]}),(0,X.jsxs)(W,{disabled:j,onClick:()=>void B(e.id,`approved`),children:[(0,X.jsx)(o,{className:`size-4`}),t.approve]})]})]},e.id))]}):null,(0,X.jsxs)(`div`,{className:`mt-4 grid gap-3 lg:grid-cols-3`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioConnections}),r.length?r.map(e=>(0,X.jsxs)(`div`,{className:`space-y-2 rounded-lg border border-edge bg-surface-panel p-2`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`truncate font-mono text-xs text-fg`,children:e.accountEmail??e.username??e.workspace??e.providerConnectionId}),(0,X.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[e.status,e.isDefault?` · ${t.composioDefaultAccount}`:``]})]}),(0,X.jsx)(`input`,{className:a(Bt,`h-8 py-1 text-xs`),defaultValue:e.alias??``,placeholder:t.composioAccountAlias,onBlur:t=>{t.currentTarget.value!==(e.alias??``)&&H(()=>He(e.id,{alias:t.currentTarget.value}))}}),(0,X.jsxs)(`div`,{className:`flex gap-1`,children:[(0,X.jsx)(W,{variant:`ghost`,className:`size-8 p-0`,title:t.composioMakeDefault,disabled:j||e.isDefault,onClick:()=>void H(async()=>{await He(e.id,{isDefault:!0}),n&&await Ye(n,{selectedConnectionIds:[e.id]})}),children:(0,X.jsx)(v,{className:a(`size-4`,e.isDefault&&`fill-current`)})}),(0,X.jsx)(W,{variant:`ghost`,className:`size-8 p-0`,title:t.refresh,disabled:j,onClick:()=>void H(()=>We(e.id)),children:(0,X.jsx)(me,{className:`size-4`})}),(0,X.jsx)(W,{variant:`ghost`,className:`size-8 p-0`,title:t.composioRevoke,disabled:j,onClick:()=>{window.confirm(t.composioRevokeConfirm)&&H(()=>Ge(e.id))},children:(0,X.jsx)(h,{className:`size-4 text-red-500`})})]})]},e.id)):(0,X.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioConnectionsEmpty})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioAgentTools}),s.length?s.slice(0,8).map(e=>(0,X.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel p-2`,children:[(0,X.jsx)(`p`,{className:`truncate font-mono text-xs text-fg`,children:e.slug}),(0,X.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[Ht(e.scope,t),e.curated?``:` ${t.composioUncuratedSuffix}`]})]},e.slug)):(0,X.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioToolsEmpty})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioRecentTriggers}),l.length?l.slice(0,5).map(e=>(0,X.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel p-2`,children:[(0,X.jsx)(`p`,{className:`truncate text-xs text-fg`,children:e.trigger??e.id}),(0,X.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:new Date(e.at).toLocaleString()})]},`${e.id}-${e.at}`)):(0,X.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioTriggersEmpty})]})]})]}):null}var Gt=a(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,de);function Kt(e,t){return e?t.healthStatusLabels[e]??e:t.healthNotTested}function qt(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 Jt(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 Yt(e){let t=(0,Y.c)(12),{title:n,description:r,meta:i}=e,o;t[0]===r?o=t[1]:(o=r?(0,X.jsx)(C,{delayDuration:300,skipDelayDuration:100,children:(0,X.jsxs)(F,{children:[(0,X.jsx)(R,{asChild:!0,children:(0,X.jsx)(`p`,{tabIndex:0,title:r,className:a(`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,X.jsx)(L,{children:(0,X.jsx)(g,{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,X.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,X.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]===i?l=t[5]:(l=i?(0,X.jsx)(`span`,{className:`shrink-0 rounded-md bg-surface-hover px-1.5 py-0.5 text-[11px] leading-4 text-fg-subtle`,children:i}):null,t[4]=i,t[5]=l);let u;t[6]!==c||t[7]!==l?(u=(0,X.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,X.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 Xt({instance:e,definition:t,onClose:n,onChanged:r,t:i,mcp:o}){let[s,c]=(0,J.useState)(!1),[l,u]=(0,J.useState)(!1),[d,f]=(0,J.useState)(!1),[g,_]=(0,J.useState)(null),[v,y]=(0,J.useState)(`health`),[b,x]=(0,J.useState)(!1),[S,C]=(0,J.useState)(()=>qt(t,e)),[w,E]=(0,J.useState)(null),D=t?.setup.config??[],M=e.materialized.type===`mcp`&&D.length>0&&(t?.setup.secrets??[]).length===0,P=g?g.toolCount:e.usage.lastToolCount,F=(0,J.useMemo)(()=>{let t=[[`health`,T,i.detailHealth],[`tools`,_e,`${i.detailTools} ${g?g.toolCount:e.usage.lastToolCount??``}`],[`resources`,oe,`${i.detailResources} ${g?g.resourceCount:e.usage.lastResourceCount??``}`],[`prompts`,ge,`${i.detailPrompts} ${g?g.promptCount:e.usage.lastPromptCount??``}`],[`permissions`,p,i.detailPermissions]];return M?[...t,[`config`,oe,i.connectorConfigLabel]]:t},[g,e.usage.lastPromptCount,e.usage.lastResourceCount,e.usage.lastToolCount,M,i]),I=(0,J.useCallback)(async()=>{c(!0),E(null);try{let t=await Be(e.instanceId);_(t),t.toolCount>0&&y(`tools`),r()}catch(e){E(e instanceof Error?e.message:String(e))}finally{c(!1)}},[e.instanceId,r]),L=(0,J.useCallback)(async()=>{u(!0),E(null);try{await ze(e.instanceId),await r(),n()}catch(e){E(e instanceof Error?e.message:String(e)),u(!1)}},[e.instanceId,r,n]),R=(0,J.useCallback)(async()=>{if(!(!t||!M)){f(!0),E(null);try{let n={};for(let e of t.setup.config??[]){let t=Jt(e.type,S[e.key]??``);t!==void 0&&(n[e.key]=t)}await Re(e.instanceId,{config:n}),await r(),y(`health`)}catch(e){E(e instanceof Error?e.message:String(e))}finally{f(!1)}}},[S,t,e.instanceId,r,M]);return(0,X.jsxs)(A,{open:!0,onOpenChange:e=>{e||n()},children:[(0,X.jsxs)(k,{children:[(0,X.jsx)(O,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,X.jsxs)(m,{className:a(`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,X.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,X.jsx)(q,{connector:t,size:`lg`}),(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(j,{className:`text-base font-semibold text-fg`,children:e.displayName}),(0,X.jsx)(se,{className:`mt-1 text-sm text-fg-muted`,children:e.materialized.type===`mcp`?$(i.mcpServerRuntime,{serverId:e.materialized.serverId}):$(i.runtimeLabel,{runtime:e.materialized.type})})]})]}),(0,X.jsx)(U,{asChild:!0,children:(0,X.jsxs)(`button`,{type:`button`,className:a(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,ne.focusRingPanel),"aria-label":i.modalClose,children:[(0,X.jsx)(G,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`sr-only`,children:i.modalClose})]})})]}),(0,X.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:[w?(0,X.jsx)(`p`,{className:`mb-4 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:w}):null,(0,X.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:F.map(([e,t,n])=>(0,X.jsxs)(`button`,{type:`button`,className:a(`inline-flex h-8 items-center gap-1.5 rounded-md border px-2.5 text-xs`,v===e?`border-accent bg-accent-soft text-accent-fg`:`border-edge bg-surface-base text-fg-muted hover:text-fg`),onClick:()=>y(e),children:[(0,X.jsx)(t,{className:`size-3.5`,"aria-hidden":!0}),n]},e))}),(0,X.jsxs)(`div`,{className:`mt-4 rounded-xl border border-edge bg-surface-base p-3 text-sm`,children:[v===`health`?(0,X.jsxs)(`div`,{className:`space-y-1 text-fg-muted`,children:[(0,X.jsxs)(`p`,{children:[i.statusLabel,` `,(0,X.jsx)(`span`,{className:g?.ok?`font-medium text-emerald-700 dark:text-emerald-300`:`font-medium text-fg`,children:Kt(g?.status??e.usage.lastHealthStatus,i)})]}),(0,X.jsxs)(`p`,{children:[i.lastCheckLabel,` `,e.usage.lastHealthCheckAt?new Date(e.usage.lastHealthCheckAt).toLocaleString():i.never]}),g?.action?(0,X.jsx)(`p`,{children:g.action}):null]}):null,v===`tools`?g?.tools.length?(0,X.jsxs)(`div`,{className:`grid gap-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,X.jsx)(`p`,{className:`text-xs text-fg-muted`,children:$(i.toolsAvailable,{count:String(g.tools.length)})}),(0,X.jsx)(W,{type:`button`,variant:`ghost`,className:`h-7 text-xs`,onClick:()=>x(!0),children:o.viewAllTools})]}),(0,X.jsx)(`div`,{className:`grid gap-2`,children:g.tools.slice(0,8).map(e=>(0,X.jsx)(Yt,{title:e.shortName??e.name,description:e.description},e.name))})]}):(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,X.jsx)(`p`,{className:`text-fg-muted`,children:P?$(i.toolsLastCheckSummary,{count:String(P)}):i.toolsRunTestHint}),(0,X.jsxs)(W,{type:`button`,variant:`secondary`,disabled:s,onClick:()=>void I(),children:[s?(0,X.jsx)(N,{className:`size-4 animate-spin`}):(0,X.jsx)(H,{className:`size-4`}),i.test]})]}):null,v===`resources`?g?.resources.length?(0,X.jsx)(`div`,{className:`grid gap-2`,children:g.resources.slice(0,8).map(e=>(0,X.jsx)(Yt,{title:e.title??e.name,description:e.uri,meta:e.mimeType},e.uri))}):(0,X.jsx)(`p`,{className:`text-fg-muted`,children:i.resourcesRunTestHint}):null,v===`prompts`?g?.prompts.length?(0,X.jsx)(`div`,{className:`grid gap-2`,children:g.prompts.slice(0,8).map(e=>(0,X.jsx)(Yt,{title:e.title??e.name,description:e.description,meta:e.argumentCount?$(i.promptArgumentCount,{count:String(e.argumentCount)}):void 0},e.name))}):(0,X.jsx)(`p`,{className:`text-fg-muted`,children:i.promptsRunTestHint}):null,v===`permissions`?(0,X.jsxs)(`div`,{className:`space-y-1 text-fg-muted`,children:[(0,X.jsx)(`p`,{children:$(i.secretsConfigured,{count:String(Object.values(e.secretStatus).filter(Boolean).length)})}),(0,X.jsx)(`p`,{children:e.materialized.type===`mcp`?$(i.runtimeServerLabel,{runtime:e.materialized.type.toUpperCase(),serverId:e.materialized.serverId}):$(i.runtimeLabel,{runtime:e.materialized.type.toUpperCase()})}),(0,X.jsx)(`p`,{children:e.materialized.type===`mcp`?i.mcpPolicyHint:i.connectorPolicyHint})]}):null,v===`config`&&M?(0,X.jsx)(`div`,{className:`grid gap-3`,children:D.map(e=>(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,X.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.label}),e.description?(0,X.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:e.description}):null,(0,X.jsx)(`input`,{className:Gt,value:S[e.key]??``,placeholder:e.placeholder,onChange:t=>C(n=>({...n,[e.key]:t.currentTarget.value}))})]},e.key))}):null]}),e.materialized.type===`composio`?(0,X.jsx)(Wt,{instance:e,t:i}):null]}),(0,X.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[(0,X.jsx)(W,{variant:`secondary`,onClick:n,children:i.modalClose}),v===`config`&&M?(0,X.jsxs)(W,{variant:`primary`,disabled:d,onClick:()=>void R(),children:[d?(0,X.jsx)(N,{className:`size-4 animate-spin`}):(0,X.jsx)(fe,{className:`size-4`}),i.modalSave]}):null,e.materialized.type===`mcp`?(0,X.jsxs)(W,{variant:`secondary`,disabled:s,onClick:()=>void I(),children:[s?(0,X.jsx)(N,{className:`size-4 animate-spin`}):(0,X.jsx)(H,{className:`size-4`}),i.test]}):null,(0,X.jsxs)(W,{variant:`ghost`,disabled:l,onClick:()=>void L(),children:[l?(0,X.jsx)(N,{className:`size-4 animate-spin`}):(0,X.jsx)(h,{className:`size-4`}),i.remove]})]})]})]}),e.materialized.type===`mcp`?(0,X.jsx)(zt,{open:b,onOpenChange:x,serverId:e.materialized.serverId,title:$(i.installedToolsDialogTitle,{name:e.displayName}),subtitle:i.installedToolsDialogSubtitle,searchPlaceholder:o.toolsDialogSearchPlaceholder,searchEmptyLabel:o.toolsDialogSearchEmpty,emptyLabel:i.toolsRunTestHint,closeLabel:o.toolsDialogClose,tools:g?.tools??[],stripPrefix:`${e.materialized.serverId}__`}):null]})}function Zt({instance:e,definition:t,highlighted:n=!1,onOpenDetails:r,onChanged:i,t:o}){let[s,c]=(0,J.useState)(!1),[l,u]=(0,J.useState)(!1),[d,f]=(0,J.useState)(null),p=(0,J.useCallback)(async()=>{c(!0),f(null);try{await Be(e.instanceId),await i()}catch(e){f(e instanceof Error?e.message:String(e))}finally{c(!1)}},[e.instanceId,i]),m=(0,J.useCallback)(async()=>{u(!0),f(null);try{await ze(e.instanceId),await i()}catch(e){f(e instanceof Error?e.message:String(e)),u(!1)}},[e.instanceId,i]),g=e.usage.lastHealthStatus?o.healthStatusLabels[e.usage.lastHealthStatus]??e.usage.lastHealthStatus:o.healthNotTested,_=e.usage.lastToolCount??0,v=!!(t?.setup.config?.length&&!t.setup.secrets?.length&&e.materialized.type===`mcp`);return(0,X.jsxs)(`div`,{className:a(`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`,n&&`ring-2 ring-accent/45 ring-offset-2 ring-offset-surface-panel`),onClick:()=>r(e),children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-3`,children:[(0,X.jsx)(q,{connector:t}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:e.displayName}),(0,X.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,X.jsx)(B,{className:`size-3`,"aria-hidden":!0}),o.connectedBadge]}),v?(0,X.jsx)(`span`,{className:`rounded-full bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:o.connectorConfigLabel}):null]}),(0,X.jsx)(`p`,{className:`mt-3 line-clamp-2 break-all text-sm leading-5 text-fg-muted`,children:e.materialized.type===`mcp`?$(o.mcpServerRuntime,{serverId:e.materialized.serverId}):$(o.runtimeLabel,{runtime:e.materialized.type})}),(0,X.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2 text-xs text-fg-muted`,children:[(0,X.jsxs)(`span`,{className:`rounded-md bg-surface-base px-2 py-1`,children:[o.statusLabel,` `,g]}),(0,X.jsx)(`span`,{className:`rounded-md bg-surface-base px-2 py-1`,children:$(o.toolsAvailable,{count:String(_)})})]}),d?(0,X.jsx)(`p`,{className:`mt-3 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:d}):null]})]}),(0,X.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-2 border-t border-edge pt-3`,onClick:e=>e.stopPropagation(),children:[(0,X.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:o.connectorDetails}),(0,X.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[e.materialized.type===`mcp`?(0,X.jsxs)(W,{variant:`secondary`,disabled:s,onClick:()=>void p(),children:[s?(0,X.jsx)(N,{className:`size-4 animate-spin`}):(0,X.jsx)(H,{className:`size-4`}),o.test]}):null,(0,X.jsxs)(W,{variant:`ghost`,disabled:l,onClick:()=>void m(),children:[l?(0,X.jsx)(N,{className:`size-4 animate-spin`}):(0,X.jsx)(h,{className:`size-4`}),o.remove]})]})]})]})}var Qt=a(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,de),$t=a(Qt,`min-h-28 font-mono`);function en(e,t){return e?t.healthStatusLabels[e]??e:t.healthStatusPending}function tn(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 nn(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,...t?{store:t}:{}}}function rn(e){let t=(0,Y.c)(12),{title:n,items:r}=e;if(r.length===0)return null;let i;t[0]===n?i=t[1]:(i=(0,X.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(an),t[2]=r,t[3]=a);let o;t[4]===r.length?o=t[5]:(o=r.length>12?(0,X.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,X.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,X.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 an(e){return(0,X.jsxs)(`div`,{className:`border-b border-edge-subtle px-3 py-2 last:border-b-0`,children:[(0,X.jsx)(`div`,{className:`break-words font-mono text-xs font-medium text-fg`,children:e.title}),e.description?(0,X.jsx)(`div`,{className:`mt-1 line-clamp-2 text-xs leading-5 text-fg-muted`,children:e.description}):null]},e.id)}function on({draft:e,onChange:t,onClose:n,onInstalled:r,t:i}){let{connector:o}=e,s=e.result?`complete`:e.installing?`health`:`configure`,c=[{id:`configure`,label:i.connectStepConfigure},{id:`health`,label:i.connectStepVerify},{id:`complete`,label:i.connectStepReady}],l=(0,J.useCallback)(async()=>{t({...e,installing:!0,error:null,result:null,health:null});try{let n={};for(let t of o.setup.config??[]){let r=tn(t.type,e.config[t.key]??``);r!==void 0&&(n[t.key]=r)}let i=e.store?await ke(e.store.packageName,{secrets:e.secrets,config:n},e.store.version):await Ie(o.id,{secrets:e.secrets,config:n,definition:o.source===`registry`?o:void 0}),a=null;try{a=await Be(i.instanceId)}catch{a=null}t({...e,installing:!1,result:i,health:a}),await r(i)}catch(n){t({...e,installing:!1,error:n instanceof Error?n.message:String(n)})}},[o,e,t,r]);return(0,X.jsx)(A,{open:!0,onOpenChange:e=>{e||n()},children:(0,X.jsxs)(k,{children:[(0,X.jsx)(O,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,X.jsxs)(m,{className:a(`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,X.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,X.jsx)(q,{connector:o,size:`lg`}),(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(j,{className:`text-base font-semibold text-fg`,children:$(i.connectDialogTitle,{name:o.displayName})}),(0,X.jsx)(se,{className:`mt-1 line-clamp-3 text-sm text-fg-muted`,children:o.description})]})]}),(0,X.jsx)(U,{asChild:!0,children:(0,X.jsxs)(`button`,{type:`button`,className:a(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,ne.focusRingPanel),"aria-label":i.modalClose,children:[(0,X.jsx)(G,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`sr-only`,children:i.modalClose})]})})]}),(0,X.jsxs)(`div`,{className:`min-h-0 overflow-y-auto px-6 py-5`,children:[(0,X.jsx)(`div`,{className:`mb-5 grid grid-cols-3 gap-2`,"aria-label":i.connectProgressAria,children:c.map((e,t)=>{let n=c.findIndex(e=>e.id===s);return(0,X.jsxs)(`div`,{className:a(`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,X.jsxs)(`span`,{className:`mr-1 tabular-nums`,children:[t+1,`.`]}),e.label]},e.id)})}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[o.integrationStrategy?(0,X.jsx)(`div`,{className:`rounded-xl border border-accent/20 bg-accent-soft/60 px-4 py-3 text-sm text-accent-fg`,children:o.integrationStrategy.lane===`mcp`?i.integrationStrategyMcpHint:o.integrationStrategy.lane===`native`?i.integrationStrategyNativeHint:i.integrationStrategyComposioHint}):null,e.store?(0,X.jsxs)(`section`,{className:`rounded-2xl border border-edge bg-surface-base p-4`,children:[(0,X.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:i.detailPermissions}),(0,X.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:[(e.store.permissions.data??[]).map(e=>(0,X.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,X.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-panel px-2 py-1 text-xs text-fg-muted`,children:e},e)),(0,X.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:i.storeLocalExecDenied})]})]}):null,(o.setup.secrets??[]).map(n=>(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,X.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.label}),n.description?(0,X.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:n.description}):null,(0,X.jsx)(te,{value:e.secrets[n.key]??``,onChange:r=>t({...e,secrets:{...e.secrets,[n.key]:r},error:null}),labels:i.secretInputLabels,placeholder:n.required?i.requiredPlaceholder:i.optionalPlaceholder})]},n.key)),(o.setup.config??[]).map(n=>(0,X.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,X.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.label}),n.type===`json`?(0,X.jsx)(`textarea`,{className:$t,value:e.config[n.key]??``,placeholder:n.placeholder,onChange:r=>t({...e,config:{...e.config,[n.key]:r.currentTarget.value},error:null})}):(0,X.jsx)(`input`,{className:Qt,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,X.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-base p-4 text-sm text-fg-muted`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 font-medium text-fg`,children:[(0,X.jsx)(N,{className:`size-4 animate-spin text-accent`,"aria-hidden":!0}),i.connectingTitle]}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:i.connectingHint})]}):null,e.error?(0,X.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,X.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-base p-4 text-sm text-fg-muted`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`font-medium text-fg`,children:$(i.connectedAs,{target:e.result.materialized.type===`mcp`?e.result.materialized.serverId:e.result.instanceId})}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:$(i.runtimeLabel,{runtime:e.result.materialized.type.toUpperCase()})})]}),(0,X.jsx)(`span`,{className:a(`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?i.healthStatusHealthy:en(e.health?.status,i)})]}),e.health?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`mt-3 grid gap-2 text-xs sm:grid-cols-3`,children:[(0,X.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2`,children:[(0,X.jsx)(`div`,{className:`font-semibold text-fg`,children:e.health.toolCount}),(0,X.jsx)(`div`,{children:i.toolsMetric})]}),(0,X.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2`,children:[(0,X.jsx)(`div`,{className:`font-semibold text-fg`,children:e.health.resourceCount}),(0,X.jsx)(`div`,{children:i.resourcesMetric})]}),(0,X.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2`,children:[(0,X.jsx)(`div`,{className:`font-semibold text-fg`,children:e.health.promptCount}),(0,X.jsx)(`div`,{children:i.promptsMetric})]})]}),(0,X.jsxs)(`div`,{className:`mt-3 grid gap-2`,children:[(0,X.jsx)(rn,{title:i.detailTools,items:e.health.tools.map(e=>({id:e.name,title:e.shortName??e.name,description:e.description}))}),(0,X.jsx)(rn,{title:i.detailResources,items:e.health.resources.map(e=>({id:e.uri,title:e.title??e.name??e.uri,description:e.description??e.uri}))}),(0,X.jsx)(rn,{title:i.detailPrompts,items:e.health.prompts.map(e=>({id:e.name,title:e.title??e.name,description:e.description??$(i.promptArgumentCount,{count:String(e.argumentCount)})}))})]})]}):(0,X.jsx)(`p`,{className:`mt-3`,children:i.installedWithoutHealth}),e.health?.action?(0,X.jsx)(`p`,{className:`mt-3 text-xs text-fg-subtle`,children:e.health.action}):null]}):null]})]}),(0,X.jsx)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:(0,X.jsxs)(W,{variant:`primary`,disabled:!!e.result||e.installing,onClick:()=>void l(),children:[e.installing?(0,X.jsx)(N,{className:`size-4 animate-spin`}):e.result?(0,X.jsx)(B,{className:`size-4`}):(0,X.jsx)(b,{className:`size-4`}),e.result?i.connectedBadge:i.connect]})})]})]})})}function sn(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 Ct(r)}function cn(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 ln(){return a(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,de)}function un({label:e,optionalLabel:t,addLabel:n,removeHeaderAria:r,pasteLabel:i,pasteFailed:o,keyPlaceholder:c,valuePlaceholder:l,headers:u,onChange:d}){let f=(e,t)=>{d(u.map((n,r)=>r===e?{...n,...t}:n))},p=()=>{d([...u,{key:``,value:``}])},m=e=>{let t=u.filter((t,n)=>n!==e);d(t.length>0?t:[{key:``,value:``}])},g=async()=>{try{let e=await s();if(!e){window.alert(o);return}let t=mt(e);if(!t?.length){window.alert(o);return}d(t)}catch{window.alert(o)}};return(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 md:col-span-2`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium text-fg`,children:[(0,X.jsx)(`span`,{children:e}),t?(0,X.jsx)(`span`,{className:`font-normal text-fg-subtle`,children:t}):null]}),(0,X.jsxs)(W,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5 px-2 text-xs`,onClick:()=>void g(),children:[(0,X.jsx)(_,{className:`size-3.5`,"aria-hidden":!0}),i]})]}),(0,X.jsx)(`div`,{className:`flex flex-col gap-2`,children:u.map((e,t)=>(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`input`,{className:a(ln(),`min-w-0 flex-1 font-mono text-xs`),value:e.key,placeholder:c,onChange:e=>f(t,{key:e.target.value})}),(0,X.jsx)(`input`,{className:a(ln(),`min-w-0 flex-[1.4] font-mono text-xs`),value:e.value,placeholder:l,onChange:e=>f(t,{value:e.target.value})}),(0,X.jsx)(W,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 px-0`,disabled:u.length<=1&&!e.key&&!e.value,onClick:()=>m(t),"aria-label":r,children:(0,X.jsx)(h,{className:`size-4 text-fg-subtle`,"aria-hidden":!0})})]},cn(e,t,u)))}),(0,X.jsxs)(`button`,{type:`button`,className:a(`self-start text-sm text-accent hover:underline`,ne.press),onClick:p,children:[`+ `,n]})]})}var dn=[`stdio`,`sse`,`streamable-http`];function fn(e){let t=(0,Y.c)(11),{label:n,description:r,required:i,children:a}=e,o;t[0]===i?o=t[1]:(o=i?(0,X.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,X.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,X.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,X.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 pn(){return a(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,de)}function mn(e){let t=(0,Y.c)(29),{row:n,t:r,onUpdate:i,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]!==i||t[2]!==n.id||t[3]!==n.transport||t[4]!==l||t[5]!==r?(d=l?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(fn,{label:r.transportLabel,required:!0,children:(0,X.jsx)(z,{className:pn(),value:n.transport,onChange:e=>i({transport:e.target.value}),children:dn.map(e=>(0,X.jsx)(E,{value:e,children:r.transportLabels[e]},e))})}),(0,X.jsxs)(fn,{label:r.serverIdLabel,required:!0,children:[(0,X.jsx)(`input`,{className:pn(),value:n.id,placeholder:r.serverIdPlaceholder,onChange:e=>i({id:e.target.value})}),o?(0,X.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-300`,children:o}):null]})]}):null,t[0]=o,t[1]=i,t[2]=n.id,t[3]=n.transport,t[4]=l,t[5]=r,t[6]=d):d=t[6];let f;t[7]!==i||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,X.jsxs)(X.Fragment,{children:[l?(0,X.jsx)(`div`,{className:c===`basic`?`md:col-span-2`:void 0,children:(0,X.jsx)(fn,{label:r.commandLabel,required:!0,children:(0,X.jsx)(`input`,{className:pn(),value:n.command,onChange:e=>i({command:e.target.value})})})}):null,u?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(fn,{label:r.argsLabel,description:r.argsHint,children:(0,X.jsx)(`input`,{className:pn(),value:n.argsText,onChange:e=>i({argsText:e.target.value})})}),(0,X.jsx)(fn,{label:r.cwdLabel,children:(0,X.jsx)(`input`,{className:pn(),value:n.cwd,onChange:e=>i({cwd:e.target.value})})}),(0,X.jsx)(fn,{label:r.envLabel,description:r.envHint,children:(0,X.jsx)(`textarea`,{className:a(pn(),`min-h-[4rem] font-mono text-xs`),value:n.envJson,onChange:e=>i({envJson:e.target.value})})})]}):null]}):(0,X.jsxs)(X.Fragment,{children:[l?(0,X.jsx)(`div`,{className:`md:col-span-2`,children:(0,X.jsx)(fn,{label:r.urlLabel,required:!0,children:(0,X.jsx)(`input`,{className:a(pn(),`font-mono text-xs`),value:n.url,placeholder:`https://example.com/mcp`,onChange:e=>i({url:e.target.value})})})}):null,u?(0,X.jsx)(un,{label:r.headersLabel,optionalLabel:r.optionalSuffix,addLabel:r.addHeader,removeHeaderAria:r.removeHeader,pasteLabel:r.pasteHeaders,pasteFailed:r.pasteHeadersFailed,keyPlaceholder:r.headerKeyPlaceholder,valuePlaceholder:r.headerValuePlaceholder,headers:n.headers,onChange:e=>i({headers:e})}):null]}),t[7]=i,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]!==i||t[21]!==n||t[22]!==u||t[23]!==r?(p=u?(0,X.jsx)(fn,{label:r.timeoutLabel,description:r.timeoutHint,children:(0,X.jsx)(`input`,{type:`number`,min:1,max:600,className:pn(),value:jt(n),placeholder:r.timeoutPlaceholder,onChange:e=>i({connectionTimeoutMs:Mt(e.target.value)})})}):null,t[20]=i,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,X.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 hn(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 gn(e){let t=(0,Y.c)(13),{tool:n,serverId:r}=e,i;t[0]!==r||t[1]!==n?(i=hn(n,r),t[0]=r,t[1]=n,t[2]=i):i=t[2];let o=i,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,X.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,X.jsx)(C,{delayDuration:300,skipDelayDuration:100,children:(0,X.jsxs)(F,{children:[(0,X.jsx)(R,{asChild:!0,children:(0,X.jsx)(`p`,{tabIndex:0,title:l,className:a(`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,X.jsx)(L,{children:(0,X.jsx)(g,{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,X.jsx)(`span`,{className:`whitespace-pre-wrap break-words`,children:l})})})]})}):null,t[8]=l,t[9]=d);let f;return t[10]!==u||t[11]!==d?(f=(0,X.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]=f):f=t[12],f}function _n({open:e,mode:t,initialRow:n,existingCustomServers:r,sessionIdleTtlMinutes:i,config:o,managedServerIds:s,t:c,cs:l,onClose:u,onSaved:d}){let[f,p]=(0,J.useState)(n),[h,g]=(0,J.useState)(!1),[_,v]=(0,J.useState)(!1),[y,b]=(0,J.useState)(null),[x,S]=(0,J.useState)(!1),[C,w]=(0,J.useState)({status:`idle`}),[T,E]=(0,J.useState)(null),D=n.id.trim(),P=f.id.trim()!==D&&s.has(f.id.trim())||s.has(f.id.trim())&&t===`add`?c.reservedServerId:void 0,F=f.id.trim()&&r.some(e=>e.clientKey!==n.clientKey&&e.id.trim()===f.id.trim())?l.duplicateServerId:void 0,I=f.id.trim().length>0&&!P&&!F&&(f.transport===`stdio`?f.command.trim().length>0:f.url.trim().length>0),L=Nt(f),R=(0,J.useCallback)(async()=>{if(f.id.trim()){v(!0),b(null),w({status:`loading`});try{w({status:`ok`,tools:(await At(f.id.trim(),Tt(f))).tools})}catch(e){w({status:`error`,message:e instanceof Error?e.message:String(e)})}finally{v(!1)}}},[f]),z=(0,J.useCallback)(async()=>{if(!(!I||h)){g(!0),b(null);try{let e=r.filter(e=>!(t===`edit`&&e.clientKey===n.clientKey));e.push(f),await Et({sessionIdleTtlMinutes:i,servers:e.sort((e,t)=>e.id.localeCompare(t.id))},vt(o)),await d(),u()}catch(e){b(e instanceof Error?e.message:String(e))}finally{g(!1)}}},[I,o,r,n.clientKey,t,u,d,D,f,h,i]);return e?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(A,{open:e,onOpenChange:e=>{e||u()},children:(0,X.jsxs)(k,{children:[(0,X.jsx)(O,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,X.jsxs)(m,{className:a(`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,X.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(j,{className:`text-base font-semibold text-fg`,children:t===`add`?l.addCustomServerTitle:l.editCustomServerTitle}),(0,X.jsx)(se,{className:`mt-1 text-sm text-fg-muted`,children:t===`add`?l.addCustomServerHint:l.editCustomServerHint})]}),(0,X.jsx)(U,{asChild:!0,children:(0,X.jsxs)(`button`,{type:`button`,className:a(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,ne.focusRingPanel),"aria-label":l.modalClose,children:[(0,X.jsx)(G,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`sr-only`,children:l.modalClose})]})})]}),(0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,X.jsx)(`section`,{className:`rounded-xl border border-edge bg-surface-base p-4`,children:(0,X.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,X.jsx)(M,{className:`size-4 text-accent`,"aria-hidden":!0}),f.id.trim()||c.cardUntitled]}),(0,X.jsx)(`p`,{className:`mt-1 break-all font-mono text-xs leading-5 text-fg-muted`,children:L||(f.transport===`stdio`?c.commandLabel:c.urlLabel)})]}),(0,X.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-[11px] font-medium text-fg-muted`,children:c.transportLabels[f.transport]})]})}),(0,X.jsxs)(`section`,{children:[(0,X.jsxs)(`div`,{className:`mb-3`,children:[(0,X.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:l.connectorBasicConfigTitle}),(0,X.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:l.connectorBasicConfigHint})]}),(0,X.jsx)(mn,{row:f,t:c,variant:`basic`,onUpdate:e=>{p(t=>({...t,...e})),b(null)},idConflictMessage:P??F})]}),C.status===`ok`?(0,X.jsxs)(`div`,{className:`rounded-xl border border-edge bg-surface-base p-3`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,X.jsx)(_e,{className:`size-4 text-accent`,"aria-hidden":!0}),C.tools.length===0?c.toolsEmpty:c.toolsTitle.replace(`{{count}}`,String(C.tools.length))]}),C.tools.length>0?(0,X.jsx)(W,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,onClick:()=>E(C.tools),children:c.viewAllTools}):null]}),C.tools.length>0?(0,X.jsx)(`div`,{className:`mt-3 grid gap-2`,children:C.tools.slice(0,6).map((e,t)=>(0,X.jsx)(gn,{tool:e,serverId:f.id},e.name||`tool-${t}`))}):null]}):null,C.status===`error`?(0,X.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:C.message}):null,y?(0,X.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:y}):null,(0,X.jsxs)(`details`,{open:x,onToggle:e=>S(e.currentTarget.open),className:`group rounded-xl border border-edge bg-surface-base`,children:[(0,X.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,X.jsx)(ie,{className:`size-4 text-fg-muted transition-transform group-open:rotate-180`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`group-open:hidden`,children:l.connectorShowAdvancedConfig}),(0,X.jsx)(`span`,{className:`hidden group-open:inline`,children:l.connectorHideAdvancedConfig})]}),(0,X.jsx)(`div`,{className:`border-t border-edge px-4 py-4`,children:(0,X.jsx)(mn,{row:f,t:c,variant:`advanced`,onUpdate:e=>{p(t=>({...t,...e})),b(null)}})})]})]})}),(0,X.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[(0,X.jsxs)(W,{variant:`secondary`,disabled:!f.id.trim()||_,onClick:()=>void R(),children:[_?(0,X.jsx)(N,{className:`size-4 animate-spin`}):(0,X.jsx)(H,{className:`size-4`}),c.testConnection]}),(0,X.jsx)(U,{asChild:!0,children:(0,X.jsx)(W,{variant:`secondary`,children:l.modalCancel})}),(0,X.jsxs)(W,{variant:`primary`,disabled:!I||h,onClick:()=>void z(),children:[h?(0,X.jsx)(N,{className:`size-4 animate-spin`}):(0,X.jsx)(B,{className:`size-4`}),h?c.saving:l.modalSave]})]})]})]})}),T?(0,X.jsx)(zt,{open:!0,onOpenChange:e=>{e||E(null)},serverId:f.id,title:c.toolsDialogTitle,subtitle:c.toolsDialogSubtitle,searchPlaceholder:c.toolsDialogSearchPlaceholder,searchEmptyLabel:c.toolsDialogSearchEmpty,emptyLabel:c.toolsEmpty,closeLabel:c.toolsDialogClose,tools:T,stripPrefix:`${f.id.trim()}__`}):null]}):null}var vn=[`understand`,`act`,`reach`];function yn(e){let t=new Set(e.capabilities),n=[e.id,e.displayName,...e.tags??[]].join(` `).toLowerCase();return t.has(`channel`)||t.has(`events`)||/slack|telegram|discord|teams|mail|message|wechat|weixin/.test(n)?`reach`:t.has(`context`)||t.has(`memory_source`)||t.has(`resources`)||e.category===`docs`||e.category===`data`||/notion|drive|document|confluence|airtable|database|knowledge|wiki/.test(n)?`understand`:`act`}function bn(e,t){let n=t?yn(t):`act`,r=e.connectionStatus===`connected`||e.status===`connected`||e.usage.lastHealthStatus===`ok`,i=e.status===`not_configured`||e.status===`failed`||e.status===`unauthorized`||e.connectionStatus===`unauthorized`||e.connectionStatus===`error`,a=n===`understand`?e.usage.lastResourceCount:n===`act`?e.usage.lastToolCount:void 0;return{benefit:n,state:r?`ready`:i?`needs_setup`:`checking`,availableCount:a}}function xn(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 Sn(e,t,n){return e.filter(e=>xn(e,t)).toSorted((e,t)=>n===`source`&&e.source!==t.source?e.source.localeCompare(t.source):e.displayName.localeCompare(t.displayName))}function Cn(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 wn(e,t){let n=t.trim().toLowerCase();return n?[e.id,e.command??``,e.url??``,e.transport].some(e=>e.toLowerCase().includes(n)):!0}var Tn=`all`,En=`builtin`,Dn=`xopc-store`;function On(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 kn(e){return e.filter((e,t,n)=>n.findIndex(t=>t.id===e.id)===t)}function An(){let e=c(d(e=>e.language)),t=e.connectorsSettings,n=e.mcpSettings,r=f(e=>e.token),o=!!r,[s,l]=i(),[u,p]=(0,J.useState)(s.get(`tab`)===`connected`?`connected`:`discover`),m=(0,J.useRef)(!1),[h,g]=(0,J.useState)({catalog:[],registryCatalog:[],instances:[],registries:[],loading:!0,error:null}),[_,v]=(0,J.useState)(!1),[y,b]=(0,J.useState)(!1),[x,C]=(0,J.useState)(1),[w,T]=(0,J.useState)(void 0),[E,D]=(0,J.useState)(``),[O,k]=(0,J.useState)(``),[A,j]=(0,J.useState)(En),[M,P]=(0,J.useState)(`name`),[F,L]=(0,J.useState)(`all`),[R,z]=(0,J.useState)(null),[B,V]=(0,J.useState)(null),[ee,H]=(0,J.useState)(null),[te,ne]=(0,J.useState)(null),[re,ie]=(0,J.useState)(null),[ae,oe]=(0,J.useState)(null),[se,U]=(0,J.useState)(!1),[ce,le]=(0,J.useState)(void 0),[de,fe]=(0,J.useState)(!1),{data:me,mutate:G}=pe(o),he=me?.payload?.config,K=(0,J.useMemo)(()=>he===void 0?null:wt(he),[he]),ge=K?.servers??[],_e=h.instances.length+ge.length;(0,J.useEffect)(()=>{K&&le(K.sessionIdleTtlMinutes)},[K]);let q=(0,J.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([Te(),je(),Ae()]);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,J.useEffect)(()=>{q()},[q]),(0,J.useEffect)(()=>{m.current||h.loading||o&&!K||(p(_e>0?`connected`:`discover`),m.current=!0)},[o,_e,K,h.loading]);let Y=(0,J.useCallback)(e=>{m.current=!0,p(e)},[]),Z=(0,J.useMemo)(()=>[{id:Dn,displayName:t.storeSourceName},...h.registries],[t.storeSourceName,h.registries]),we=(0,J.useCallback)(async e=>{if(!o||A===En){g(e=>({...e,registryCatalog:[]})),C(1),T(void 0);return}let t=O.trim(),n=e?.browse??!1,r=Math.max(e?.page??1,1),i=e?.append??!1,a=A===Tn?Z:Z.filter(e=>e.id===A);if(a.length!==0){v(!0),i?g(e=>({...e,error:null})):(C(1),T(void 0),g(e=>({...e,registryCatalog:[],error:null})));try{let e=await Promise.all(a.map(async e=>{if(e.id===Dn){let e=await De({q:t||void 0,page:r,pageSize:24,sort:M===`source`?`newest`:`downloads`});return{connectors:e.items.map(On),totalPages:e.meta.totalPages}}return Pe(t,e.id,{browse:n,page:r})})),o=kn(e.flatMap(e=>e.connectors)),s=Math.max(1,...e.map(e=>e.totalPages??1));C(r),T(s),g(e=>({...e,registryCatalog:i?kn([...e.registryCatalog,...o]):o}))}catch(e){g(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{v(!1)}}},[M,O,A,o,Z]);(0,J.useEffect)(()=>{if(u!==`discover`||h.loading)return;if(A===En){g(e=>({...e,registryCatalog:[]})),C(1),T(void 0);return}let e=window.setTimeout(()=>{we({browse:!O.trim()})},O.trim()?350:0);return()=>window.clearTimeout(e)},[O,A,we,h.loading,u]);let Q=(0,J.useMemo)(()=>new Set(h.instances.map(e=>e.connectorId)),[h.instances]),Ee=(0,J.useMemo)(()=>new Map([...h.catalog,...h.registryCatalog].map(e=>[e.id,e])),[h.catalog,h.registryCatalog]);(0,J.useEffect)(()=>{if(h.loading)return;let e=s.get(`connector`),t=s.get(`instance`);if(!e&&!t)return;let n=h.instances.find(n=>t?n.instanceId===t:n.connectorId===e);if(n)m.current=!0,D(``),H(n.instanceId),ne(n),p(`connected`);else if(e){let t=Ee.get(e);if(!t)return;m.current=!0,j(En),k(``),V(t),p(`discover`)}let r=new URLSearchParams(s);r.delete(`connector`),r.delete(`instance`),r.delete(`personalContext`),r.set(`tab`,n?`connected`:`discover`),l(r,{replace:!0})},[Ee,s,l,h.instances,h.loading]);let ke=(0,J.useCallback)(async e=>{b(!0),g(e=>({...e,error:null}));try{let t=await Oe(e);z(nn(t.definition,{packageName:t.packageName,version:t.version,permissions:t.permissions}))}catch(e){g(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{b(!1)}},[]),Me=(0,J.useMemo)(()=>new Set(h.instances.flatMap(e=>e.materialized.type===`mcp`?[e.materialized.serverId]:[])),[h.instances]),Ne=(0,J.useCallback)(async e=>{if(!K||he===void 0)return;let t=ge.filter(t=>t.clientKey!==e.clientKey);await Et({sessionIdleTtlMinutes:K.sessionIdleTtlMinutes,servers:t},vt(he)),await G(),await q()},[he,ge,q,K,G]),Fe=(0,J.useCallback)(()=>{oe({mode:`add`,row:sn(ge,Me)})},[ge,Me]),Ie=(0,J.useCallback)(async()=>{if(!(!K||he===void 0||de)){fe(!0);try{await Et({sessionIdleTtlMinutes:ce,servers:ge},vt(he)),await G(),U(!1)}finally{fe(!1)}}},[he,ge,n.saved,K,G,ce,de]),Le=S(e=>e.setPageHeader),Re=S(e=>e.clearPageHeader),ze=(0,J.useMemo)(()=>(0,X.jsx)(ft,{onBrowseCatalog:()=>Y(`discover`),onAddCustomServer:Fe,onOpenRuntimeSettings:()=>U(!0),addLabel:t.addConnection,browseLabel:t.addFromCatalog,customLabel:t.addCustomServerAdvanced,settingsLabel:t.runtimeSettings}),[t,Fe,Y]);(0,J.useLayoutEffect)(()=>(Le({startExtra:null,main:(0,X.jsx)(`div`,{className:`min-w-0`,children:(0,X.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.title})}),end:ze}),()=>Re()),[Re,t.title,ze,Le]);let Be=(0,J.useMemo)(()=>h.instances.map(e=>({instance:e,value:bn(e,Ee.get(e.connectorId))})),[Ee,h.instances]),Ve=(0,J.useMemo)(()=>new Map(Be.map(({instance:e,value:t})=>[e.instanceId,t])),[Be]),He=(0,J.useMemo)(()=>({ready:Be.filter(({value:e})=>e.state===`ready`).length,needsSetup:Be.filter(({value:e})=>e.state===`needs_setup`).length,checking:Be.filter(({value:e})=>e.state===`checking`).length}),[Be]),Ue=(0,J.useMemo)(()=>h.instances.filter(e=>Cn(e,E)).sort((e,t)=>{let n={needs_setup:0,checking:1,ready:2},r=Ve.get(e.instanceId)?.state??`checking`,i=Ve.get(t.instanceId)?.state??`checking`;return n[r]-n[i]||e.displayName.localeCompare(t.displayName)}),[E,Ve,h.instances]),We=(0,J.useMemo)(()=>ge.filter(e=>wn(e,E)),[E,ge]),Ge=Ue.length+We.length,Ke=(0,J.useMemo)(()=>h.catalog.filter(e=>e.source===`builtin`&&e.integrationStrategy?.preferred!==!1),[h.catalog]),qe=(0,J.useMemo)(()=>{let e=A===En?Ke:A===Tn?kn([...Ke,...h.registryCatalog]):h.registryCatalog;return Sn(F===`all`?e:e.filter(e=>yn(e)===F),O,M)},[Ke,M,O,A,F,h.registryCatalog]),Je=u===`discover`&&A!==En&&!!(w&&x<w),Ye=(0,J.useMemo)(()=>h.instances.find(e=>e.instanceId===ee)??te,[ee,te,h.instances]),Xe=(0,J.useMemo)(()=>[{value:Tn,label:t.discoverSourceAll},{value:En,label:t.discoverSourceBuiltin},...Z.map(e=>({value:e.id,label:e.displayName}))],[t.discoverSourceAll,t.discoverSourceBuiltin,Z]),Ze=[{id:`connected`,label:t.tabConnected,count:_e},{id:`discover`,label:t.tabDiscover}];return(0,X.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:(0,X.jsxs)(`div`,{className:`flex w-full flex-col gap-6 px-3 py-6 sm:px-5 xl:px-6`,children:[o?null:(0,X.jsx)(`p`,{className:`rounded-xl border border-edge bg-surface-panel px-4 py-3 text-sm text-fg-muted`,children:t.tokenHint}),(0,X.jsxs)(`section`,{className:`flex flex-col gap-4`,children:[(0,X.jsx)(`div`,{className:`border-b border-edge-subtle pb-3 dark:border-edge-subtle`,children:(0,X.jsx)(ve,{items:Ze,activeTab:u,onChange:Y,ariaLabel:t.navAria,tabIdPrefix:`connectors-tab`,panelIdPrefix:`connectors-panel`,className:`flex-wrap`})}),h.error?(0,X.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:h.error}):null,u===`connected`&&o?(0,X.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center`,children:[(0,X.jsx)(dt,{value:E,onChange:D,placeholder:t.connectedSearchPlaceholder,className:`max-w-xl`}),(0,X.jsx)(ue,{className:`size-9 shrink-0 p-0`,loading:h.loading,label:t.refreshConnections,title:t.refreshConnections,onClick:q})]}),Be.length>0?(0,X.jsxs)(`section`,{className:`rounded-2xl border border-edge-subtle bg-surface-base p-5`,children:[(0,X.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.connectionSummaryTitle}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t.connectionSummaryHint}),(0,X.jsxs)(`div`,{className:`mt-4 grid gap-2 sm:grid-cols-3`,children:[(0,X.jsxs)(`div`,{className:`rounded-xl bg-surface-panel p-3`,children:[(0,X.jsx)(`div`,{className:`text-xl font-semibold tabular-nums text-success`,children:He.ready}),(0,X.jsx)(`div`,{className:`mt-1 text-xs text-fg-muted`,children:t.connectionReady})]}),(0,X.jsxs)(`div`,{className:`rounded-xl bg-surface-panel p-3`,children:[(0,X.jsx)(`div`,{className:a(`text-xl font-semibold tabular-nums`,He.needsSetup>0?`text-warning`:`text-fg`),children:He.needsSetup}),(0,X.jsx)(`div`,{className:`mt-1 text-xs text-fg-muted`,children:t.connectionNeedsSetup})]}),(0,X.jsxs)(`div`,{className:`rounded-xl bg-surface-panel p-3`,children:[(0,X.jsx)(`div`,{className:`text-xl font-semibold tabular-nums text-fg`,children:He.checking}),(0,X.jsx)(`div`,{className:`mt-1 text-xs text-fg-muted`,children:t.connectionChecking})]})]})]}):null,(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.connectionsTitle}),(0,X.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.connectionsHint})]}),h.loading?(0,X.jsx)(`div`,{className:`grid gap-3`,"aria-busy":`true`,"aria-label":t.loading,children:ye.slice(0,3).map(e=>(0,X.jsx)(Se,{},e))}):_e===0?(0,X.jsxs)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center`,children:[(0,X.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.connectionsEmpty}),(0,X.jsx)(W,{type:`button`,variant:`primary`,className:`mt-4`,onClick:()=>Y(`discover`),children:t.addFromCatalog})]}):Ge===0?(0,X.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center text-sm text-fg-muted`,children:t.connectionsSearchEmpty}):(0,X.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:[Ue.map(e=>(0,X.jsx)(Zt,{instance:e,definition:Ee.get(e.connectorId),highlighted:e.instanceId===re,onOpenDetails:e=>{ie(null),H(e.instanceId),ne(e)},onChanged:q,t},e.instanceId)),We.map(e=>(0,X.jsx)(Pt,{row:e,t:n,cs:t,onEdit:()=>oe({mode:`edit`,row:structuredClone(e)}),onRemove:async()=>Ne(e)},e.clientKey))]}),(0,X.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.disableHint})]}):null,u===`discover`&&o?(0,X.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:t.discoverTitle}),(0,X.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.discoverHint})]}),(0,X.jsx)(`div`,{className:`rounded-xl border border-accent/20 bg-accent-soft/60 px-4 py-3 text-sm text-accent-fg`,children:t.integrationStrategyHint}),(0,X.jsx)(`div`,{className:`flex flex-wrap gap-2`,role:`group`,"aria-label":t.outcomeFilterAria,children:[`all`,...vn].map(e=>(0,X.jsx)(`button`,{type:`button`,className:a(`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors`,F===e?`border-accent/40 bg-accent-soft text-accent-fg`:`border-edge bg-surface-panel text-fg-muted hover:bg-surface-hover hover:text-fg`),"aria-pressed":F===e,onClick:()=>L(e),children:e===`all`?t.outcomeAll:t.connectorBenefitHeadings[e]},e))}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 lg:flex-row lg:items-center`,children:[(0,X.jsx)(dt,{value:O,onChange:k,placeholder:t.discoverSearchPlaceholder,className:`max-w-xl`}),(0,X.jsxs)(`div`,{className:`grid min-w-0 grid-cols-1 gap-2 sm:grid-cols-2 lg:ml-auto lg:w-[26rem]`,children:[(0,X.jsx)(I,{value:A,options:Xe,placeholder:t.discoverSourceAll,allowEmpty:!1,ariaLabel:t.registrySourceAria,triggerClassName:`h-9 bg-surface-panel text-xs`,onChange:j}),(0,X.jsx)(I,{value:M,options:[{value:`name`,label:t.sortName},{value:`source`,label:t.sortSource}],placeholder:t.sortName,allowEmpty:!1,ariaLabel:t.sortAria,triggerClassName:`h-9 bg-surface-panel text-xs`,onChange:e=>P(e)})]})]}),(h.loading||_)&&qe.length===0?(0,X.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,"aria-busy":`true`,"aria-label":t.loading,children:ye.map(e=>(0,X.jsx)(xe,{},e))}):qe.length===0?(0,X.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center text-sm text-fg-muted`,children:t.discoverEmpty}):(0,X.jsxs)(`div`,{className:`relative`,children:[_?(0,X.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,X.jsx)(N,{className:`size-8 shrink-0 animate-spin text-accent motion-reduce:animate-none`,strokeWidth:2,"aria-hidden":!0})}):null,(0,X.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:qe.map(e=>(0,X.jsx)(Ce,{connector:e,installed:Q.has(e.id)||be(e,h.instances),onInstall:e=>{if(e.source===`store`){ke(e.id);return}z(nn(e))},onOpenDetails:e.source===`store`?void 0:V,t},e.id))}),Je?(0,X.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,X.jsxs)(W,{type:`button`,variant:`secondary`,disabled:_||y,onClick:()=>void we({browse:!O.trim(),page:x+1,append:!0}),children:[_?(0,X.jsx)(N,{className:`size-4 animate-spin`}):null,t.loadMore]})}):null]})]}):null]}),R?(0,X.jsx)(on,{draft:R,onChange:z,onClose:()=>z(null),t,onInstalled:async e=>{await q(),await G(),ie(e.instanceId),Y(`connected`)}}):null,B?(0,X.jsx)(ct,{connector:B,installed:Q.has(B.id)||be(B,h.instances),onClose:()=>V(null),onInstall:e=>z(nn(e)),t}):null,Ye?(0,X.jsx)(Xt,{instance:Ye,definition:Ee.get(Ye.connectorId),onClose:()=>{H(null),ne(null)},onChanged:q,t,mcp:n}):null,ae?(0,X.jsx)(_n,{open:!0,mode:ae.mode,initialRow:ae.row,existingCustomServers:ge,sessionIdleTtlMinutes:ce,config:he,managedServerIds:Me,t:n,cs:t,onClose:()=>oe(null),onSaved:async()=>{await G(),await q(),Y(`connected`)}},`${ae.mode}-${ae.row.clientKey}`):null,(0,X.jsx)(ut,{open:se,sessionIdleTtlMinutes:ce,saving:de,onChange:le,onSave:Ie,onClose:()=>U(!1),t,mcp:n})]})})}export{An 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-Cb1VMeqP.js";import{n as a}from"./locale-store-CiM-D9jA.js";import{Qo as o,kl as s,t as c}from"./index-I-ZCenVw.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)(o,{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)(o,{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)(s,{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)(o,{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
+ 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-CQGpD-dC.js";import{n as a}from"./locale-store-Bp8joZck.js";import{eu as o,t as s,vs as c}from"./index-CxkNzw3e.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??s(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,s]=(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=>s(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`&&s(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)(c,{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)(c,{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)(c,{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{l as i}from"./chunk-QUQL4437-DXsxWP7r.js";import{t as a}from"./cn-BQ_8x0bT.js";import{t as o}from"./circle-alert-RzVebuX2.js";import{t as s}from"./messages-Cb1VMeqP.js";import{n as c}from"./locale-store-CiM-D9jA.js";import{Do as l,To as u,Uo as d,Vs as f,ec as p,fc as m,tl as h,ts as g,uo as _,zs as v}from"./index-I-ZCenVw.js";import{t as y}from"./desktop-pet-sprite-DqZ6fbIj.js";import{n as b,t as x}from"./settings-page-layout-DqpbTWqI.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=s(c(e=>e.language)).desktopPetSettings,t=i(),[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]),!_()||!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:a(`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`,d.press),disabled:S,onClick:()=>void j(),children:[(0,w.jsx)(f,{className:a(`size-3.5`,S&&`animate-spin`),strokeWidth:1.75}),e.refresh]}),(0,w.jsxs)(`button`,{type:`button`,className:a(`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`,d.press),onClick:()=>void k.openCustomPetsDir(),children:[(0,w.jsx)(h,{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)(g,{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:a(`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`,d.press),onClick:z,children:[(0,w.jsx)(m,{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,i=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:i.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:i.description})]}),(0,w.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[t.builtin?null:(0,w.jsxs)(`button`,{type:`button`,className:a(`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`,d.press),onClick:()=>B(t),children:[(0,w.jsx)(p,{className:`size-3.5`,strokeWidth:1.75}),e.optimizeInChat]}),(0,w.jsx)(`button`,{type:`button`,className:a(`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`,d.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)(h,{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)(o,{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:a(`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`,d.press),onClick:()=>V(t),children:[(0,w.jsx)(m,{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)(u,{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)(l,{value:`quiet`,children:e.feedbackQuiet}),(0,w.jsx)(l,{value:`normal`,children:e.feedbackNormal}),(0,w.jsx)(l,{value:`chatty`,children:e.feedbackChatty})]})]}),(0,w.jsxs)(`button`,{type:`button`,className:a(`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`,d.press),disabled:S,onClick:()=>void k.resetPosition().then(r),children:[(0,w.jsx)(v,{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{l as i}from"./chunk-QUQL4437-DXsxWP7r.js";import{t as a}from"./cn-BQ_8x0bT.js";import{t as o}from"./circle-alert-RzVebuX2.js";import{t as s}from"./messages-CQGpD-dC.js";import{n as c}from"./locale-store-Bp8joZck.js";import{Dl as l,Io as u,Ko as d,Nc as f,Wo as p,ac as m,cs as h,sc as g,xc as _,xs as v}from"./index-CxkNzw3e.js";import{t as y}from"./desktop-pet-sprite-DqZ6fbIj.js";import{n as b,t as x}from"./settings-page-layout-DaFwstQw.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=s(c(e=>e.language)).desktopPetSettings,t=i(),[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]),!u()||!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:a(`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`,h.press),disabled:S,onClick:()=>void j(),children:[(0,w.jsx)(g,{className:a(`size-3.5`,S&&`animate-spin`),strokeWidth:1.75}),e.refresh]}),(0,w.jsxs)(`button`,{type:`button`,className:a(`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`,h.press),onClick:()=>void k.openCustomPetsDir(),children:[(0,w.jsx)(l,{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)(v,{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:a(`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`,h.press),onClick:z,children:[(0,w.jsx)(f,{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,i=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:i.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:i.description})]}),(0,w.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[t.builtin?null:(0,w.jsxs)(`button`,{type:`button`,className:a(`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`,h.press),onClick:()=>B(t),children:[(0,w.jsx)(_,{className:`size-3.5`,strokeWidth:1.75}),e.optimizeInChat]}),(0,w.jsx)(`button`,{type:`button`,className:a(`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`,h.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)(l,{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)(o,{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:a(`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`,h.press),onClick:()=>V(t),children:[(0,w.jsx)(f,{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)(p,{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)(d,{value:`quiet`,children:e.feedbackQuiet}),(0,w.jsx)(d,{value:`normal`,children:e.feedbackNormal}),(0,w.jsx)(d,{value:`chatty`,children:e.feedbackChatty})]})]}),(0,w.jsxs)(`button`,{type:`button`,className:a(`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`,h.press),disabled:S,onClick:()=>void k.resetPosition().then(r),children:[(0,w.jsx)(m,{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{At as r,Tt as i,kt as a}from"./index-I-ZCenVw.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 _=a(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)(r,{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)(i,{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{At as r,Et as i,jt as a}from"./index-CxkNzw3e.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)(a,{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)(i,{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};
@@ -0,0 +1 @@
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,i as n,t as r}from"./vendor-react-BOUWij0V.js";import{i}from"./dist-CxGUk8J-.js";import{f as a,h as o,p as s,s as c}from"./Combination-14nmIgxH.js";var l=e(t(),1),u=[`top`,`right`,`bottom`,`left`],d=Math.min,f=Math.max,p=Math.round,m=Math.floor,h=e=>({x:e,y:e}),g={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function _(e,t,n){return f(e,d(t,n))}function v(e,t){return typeof e==`function`?e(t):e}function y(e){return e.split(`-`)[0]}function b(e){return e.split(`-`)[1]}function x(e){return e===`x`?`y`:`x`}function S(e){return e===`y`?`height`:`width`}function C(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function w(e){return x(C(e))}function T(e,t,n){n===void 0&&(n=!1);let r=b(e),i=w(e),a=S(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=P(o)),[o,P(o)]}function E(e){let t=P(e);return[D(e),t,D(t)]}function D(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var O=[`left`,`right`],k=[`right`,`left`],A=[`top`,`bottom`],j=[`bottom`,`top`];function M(e,t,n){switch(e){case`top`:case`bottom`:return n?t?k:O:t?O:k;case`left`:case`right`:return t?A:j;default:return[]}}function N(e,t,n,r){let i=b(e),a=M(y(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(D)))),a}function P(e){let t=y(e);return g[t]+e.slice(t.length)}function F(e){return{top:e.top??0,right:e.right??0,bottom:e.bottom??0,left:e.left??0}}function ee(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:F(e)}function I(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function L(e,t,n){let{reference:r,floating:i}=e,a=C(t),o=w(t),s=S(o),c=y(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}let m=b(t);return m&&(p[o]+=f*(m===`end`?1:-1)*(n&&l?-1:1)),p}async function R(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=v(t,e),p=ee(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=I(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),y=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},b=I(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-b.top+p.top)/y.y,bottom:(b.bottom-h.bottom+p.bottom)/y.y,left:(h.left-b.left+p.left)/y.x,right:(b.right-h.right+p.right)/y.x}}var te=50,ne=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:R},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=L(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<te&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=L(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},re=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=v(e,t)||{};if(l==null)return{};let f=ee(u),p={x:n,y:r},m=w(i),h=S(m),g=await o.getDimensions(l),y=m===`y`,x=y?`top`:`left`,C=y?`bottom`:`right`,T=y?`clientHeight`:`clientWidth`,E=a.reference[h]+a.reference[m]-p[m]-a.floating[h],D=p[m]-a.reference[m],O=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),k=O?O[T]:0;(!k||!await(o.isElement==null?void 0:o.isElement(O)))&&(k=s.floating[T]||a.floating[h]);let A=E/2-D/2,j=k/2-g[h]/2-1,M=d(f[x],j),N=d(f[C],j),P=k-g[h]-N,F=k/2-g[h]/2+A,I=_(M,F,P),L=!c.arrow&&b(i)!=null&&F!==I&&a.reference[h]/2-(F<M?M:N)-g[h]/2<0,R=L?F<M?F-M:F-P:0;return{[m]:p[m]+R,data:{[m]:I,centerOffset:F-I-R,...L&&{alignmentOffset:R}},reset:L}}}),ie=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=v(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=y(r),_=C(o),b=y(o)===o,x=await(s.isRTL==null?void 0:s.isRTL(c.floating)),S=d||(b||!m?[P(o)]:E(o)),w=p!==`none`;!d&&w&&S.push(...N(o,m,p,x));let D=[o,...S],O=await s.detectOverflow(t,h),k=[],A=i.flip?.overflows||[];if(l&&k.push(O[g]),u){let e=T(r,a,x);k.push(O[e[0]],O[e[1]])}if(A=[...A,{placement:r,overflows:k}],!k.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=D[e];if(t&&(!(u===`alignment`&&_!==C(t))||A.every(e=>C(e.placement)===_?e.overflows[0]>0:!0)))return{data:{index:e,overflows:A},reset:{placement:t}};let n=A.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=A.filter(e=>{if(w){let t=C(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o;break}if(r!==n)return{reset:{placement:n}}}return{}}}};function ae(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function oe(e){return u.some(t=>e[t]>=0)}var se=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=v(e,t);switch(i){case`referenceHidden`:{let e=ae(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:oe(e)}}}case`escaped`:{let e=ae(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:oe(e)}}}default:return{}}}}},ce=new Set([`left`,`top`]);async function le(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=y(n),s=b(n),c=C(n)===`y`,l=ce.has(o)?-1:1,u=a&&c?-1:1,d=v(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var ue=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await le(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},de=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=v(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=C(i),p=x(f),m=u[p],h=u[f],g=(e,t)=>_(t+d[e===`y`?`top`:`left`],t,t-d[e===`y`?`bottom`:`right`]);o&&(m=g(p,m)),s&&(h=g(f,h));let y=c.fn({...t,[p]:m,[f]:h});return{...y,data:{x:y.x-n,y:y.y-r,enabled:{[p]:o,[f]:s}}}}}},fe=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=v(e,t),u={x:n,y:r},d=C(i),f=x(d),p=u[f],m=u[d],h=v(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:h.mainAxis??0,crossAxis:h.crossAxis??0};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=ce.has(y(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},pe=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){let{placement:n,rects:r,platform:i,elements:a}=t,{apply:o=()=>{},...s}=v(e,t),c=await i.detectOverflow(t,s),l=y(n),u=b(n),p=C(n)===`y`,{width:m,height:h}=r.floating,g,_;l===`top`||l===`bottom`?(g=l,_=u===(await(i.isRTL==null?void 0:i.isRTL(a.floating))?`start`:`end`)?`left`:`right`):(_=l,g=u===`end`?`top`:`bottom`);let x=h-c.top-c.bottom,S=m-c.left-c.right,w=d(h-c[g],x),T=d(m-c[_],S),E=t.middlewareData.shift,D=!E,O=w,k=T;E!=null&&E.enabled.x&&(k=S),E!=null&&E.enabled.y&&(O=x),D&&!u&&(p?k=m-2*f(c.left,c.right):O=h-2*f(c.top,c.bottom)),await o({...t,availableWidth:k,availableHeight:O});let A=await i.getDimensions(a.floating);return m!==A.width||h!==A.height?{reset:{rects:!0}}:{}}}};function z(){return typeof window<`u`}function B(e){return me(e)?(e.nodeName||``).toLowerCase():`#document`}function V(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function H(e){return((me(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function me(e){return z()?e instanceof Node||e instanceof V(e).Node:!1}function U(e){return z()?e instanceof Element||e instanceof V(e).Element:!1}function W(e){return z()?e instanceof HTMLElement||e instanceof V(e).HTMLElement:!1}function he(e){return!z()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof V(e).ShadowRoot}function G(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=J(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function ge(e){return/^(table|td|th)$/.test(B(e))}function _e(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var ve=/transform|translate|scale|rotate|perspective|filter/,ye=/paint|layout|strict|content/,K=e=>!!e&&e!==`none`,be;function xe(e){let t=U(e)?J(e):e;return K(t.transform)||K(t.translate)||K(t.scale)||K(t.rotate)||K(t.perspective)||!Ce()&&(K(t.backdropFilter)||K(t.filter))||ve.test(t.willChange||``)||ye.test(t.contain||``)}function Se(e){let t=Y(e);for(;W(t)&&!q(t);){if(xe(t))return t;if(_e(t))return null;t=Y(t)}return null}function Ce(){return be??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),be}function q(e){return/^(html|body|#document)$/.test(B(e))}function J(e){return V(e).getComputedStyle(e)}function we(e){return U(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Y(e){if(B(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||he(e)&&e.host||H(e);return he(t)?t.host:t}function Te(e){let t=Y(e);return q(t)?(e.ownerDocument||e).body:W(t)&&G(t)?t:Te(t)}function X(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=Te(e),i=r===e.ownerDocument?.body,a=V(r);if(i){let e=Ee(a);return t.concat(a,a.visualViewport||[],G(r)?r:[],e&&n?X(e):[])}else return t.concat(r,X(r,[],n))}function Ee(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function De(e){let t=J(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=W(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=p(n)!==a||p(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function Oe(e){return U(e)?e:e.contextElement}function Z(e){let t=Oe(e);if(!W(t))return h(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=De(t),o=(a?p(n.width):n.width)/r,s=(a?p(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var ke=h(0);function Ae(e){let t=V(e);return!Ce()||!t.visualViewport?ke:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function je(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==V(e)?!1:t}function Q(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=Oe(e),o=h(1);t&&(r?U(r)&&(o=Z(r)):o=Z(e));let s=je(a,n,r)?Ae(a):h(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a){let e=V(a),t=r&&U(r)?V(r):r,n=e,i=Ee(n);for(;i&&r&&t!==n;){let e=Z(i),t=i.getBoundingClientRect(),r=J(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=V(i),i=Ee(n)}}return I({width:u,height:d,x:c,y:l})}function Me(e,t){let n=we(e).scrollLeft;return t?t.left+n:Q(H(e)).left+n}function Ne(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-Me(e,n),y:n.top+t.scrollTop}}function Pe(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=H(r),s=t?_e(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=h(1),u=h(0),d=W(r);if((d||!d&&!a)&&((B(r)!==`body`||G(o))&&(c=we(r)),d)){let e=Q(r);l=Z(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?Ne(o,c):h(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function Fe(e){return Array.from(e.getClientRects())}function Ie(e){let t=H(e),n=we(e),r=e.ownerDocument.body,i=f(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=f(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight),o=-n.scrollLeft+Me(e),s=-n.scrollTop;return J(r).direction===`rtl`&&(o+=f(t.clientWidth,r.clientWidth)-i),{width:i,height:a,x:o,y:s}}var Le=25;function Re(e,t){let n=V(e),r=H(e),i=n.visualViewport,a=r.clientWidth,o=r.clientHeight,s=0,c=0;if(i){a=i.width,o=i.height;let e=Ce();(!e||e&&t===`fixed`)&&(s=i.offsetLeft,c=i.offsetTop)}let l=Me(r);if(l<=0){let e=r.ownerDocument,t=e.body,n=getComputedStyle(t),i=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,o=Math.abs(r.clientWidth-t.clientWidth-i);o<=Le&&(a-=o)}else l<=Le&&(a+=l);return{width:a,height:o,x:s,y:c}}function ze(e,t){let n=Q(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=W(e)?Z(e):h(1);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function Be(e,t,n){let r;if(t===`viewport`)r=Re(e,n);else if(t===`document`)r=Ie(H(e));else if(U(t))r=ze(t,n);else{let n=Ae(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return I(r)}function Ve(e,t){let n=Y(e);return n===t||!U(n)||q(n)?!1:J(n).position===`fixed`||Ve(n,t)}function He(e,t){let n=t.get(e);if(n)return n;let r=X(e,[],!1).filter(e=>U(e)&&B(e)!==`body`),i=null,a=J(e).position===`fixed`,o=a?Y(e):e;for(;U(o)&&!q(o);){let t=J(o),n=xe(o);!n&&t.position===`fixed`&&(i=null),(a?!n&&!i:!n&&t.position===`static`&&i&&(i.position===`absolute`||i.position===`fixed`)||G(o)&&!n&&Ve(e,o))?r=r.filter(e=>e!==o):i=t,o=Y(o)}return t.set(e,r),r}function Ue(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?_e(t)?[]:He(t,this._c):[].concat(n),r],o=Be(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=Be(t,a[e],i);s=f(n.top,s),c=d(n.right,c),l=d(n.bottom,l),u=f(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function We(e){let{width:t,height:n}=De(e);return{width:t,height:n}}function Ge(e,t,n){let r=W(t),i=H(t),a=n===`fixed`,o=Q(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=h(0);function l(){c.x=Me(i)}if(r||!r&&!a)if((B(t)!==`body`||G(i))&&(s=we(t)),r){let e=Q(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}else i&&l();a&&!r&&i&&l();let u=i&&!r&&!a?Ne(i,s):h(0);return{x:o.left+s.scrollLeft-c.x-u.x,y:o.top+s.scrollTop-c.y-u.y,width:o.width,height:o.height}}function Ke(e){return J(e).position===`static`}function qe(e,t){if(!W(e)||J(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return H(e)===n&&(n=n.ownerDocument.body),n}function Je(e,t){let n=V(e);if(_e(e))return n;if(!W(e)){let t=Y(e);for(;t&&!q(t);){if(U(t)&&!Ke(t))return t;t=Y(t)}return n}let r=qe(e,t);for(;r&&ge(r)&&Ke(r);)r=qe(r,t);return r&&q(r)&&Ke(r)&&!xe(r)?n:r||Se(e)||n}var Ye=async function(e){let t=this.getOffsetParent||Je,n=this.getDimensions,r=await n(e.floating);return{reference:Ge(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Xe(e){return J(e).direction===`rtl`}var Ze={convertOffsetParentRelativeRectToViewportRelativeRect:Pe,getDocumentElement:H,getClippingRect:Ue,getOffsetParent:Je,getElementRects:Ye,getClientRects:Fe,getDimensions:We,getScale:Z,isElement:U,isRTL:Xe};function Qe(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function $e(e,t){let n=null,r,i=H(e);function a(){var e;clearTimeout(r),(e=n)==null||e.disconnect(),n=null}function o(s,c){s===void 0&&(s=!1),c===void 0&&(c=1),a();let l=e.getBoundingClientRect(),{left:u,top:p,width:h,height:g}=l;if(s||t(),!h||!g)return;let _=m(p),v=m(i.clientWidth-(u+h)),y=m(i.clientHeight-(p+g)),b=m(u),x={rootMargin:-_+`px `+-v+`px `+-y+`px `+-b+`px`,threshold:f(0,d(1,c))||1},S=!0;function C(t){let n=t[0].intersectionRatio;if(n!==c){if(!S)return o();n?o(!1,n):r=setTimeout(()=>{o(!1,1e-7)},1e3)}n===1&&!Qe(l,e.getBoundingClientRect())&&o(),S=!1}try{n=new IntersectionObserver(C,{...x,root:i.ownerDocument})}catch{n=new IntersectionObserver(C,x)}n.observe(e)}return o(!0),a}function et(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=Oe(e),u=i||a?[...l?X(l):[],...t?X(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n,{passive:!0}),a&&e.addEventListener(`resize`,n)});let d=l&&s?$e(l,n):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?Q(e):null;c&&g();function g(){let t=Q(e);h&&!Qe(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var tt=ue,nt=de,rt=ie,it=pe,at=se,ot=re,st=fe,ct=(e,t,n)=>{let r=new Map,i={platform:Ze,...n},a={...i.platform,_c:r};return ne(e,t,{...i,platform:a})},lt=e(n(),1),ut=typeof document<`u`?l.useLayoutEffect:function(){};function dt(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!dt(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!dt(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function ft(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function pt(e,t){let n=ft(e);return Math.round(t*n)/n}function mt(e){let t=l.useRef(e);return ut(()=>{t.current=e}),t}function ht(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:u}=e,[d,f]=l.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[p,m]=l.useState(r);dt(p,r)||m(r);let[h,g]=l.useState(null),[_,v]=l.useState(null),y=l.useCallback(e=>{e!==C.current&&(C.current=e,g(e))},[]),b=l.useCallback(e=>{e!==w.current&&(w.current=e,v(e))},[]),x=a||h,S=o||_,C=l.useRef(null),w=l.useRef(null),T=l.useRef(d),E=c!=null,D=mt(c),O=mt(i),k=mt(u),A=l.useCallback(()=>{if(!C.current||!w.current)return;let e={placement:t,strategy:n,middleware:p};O.current&&(e.platform=O.current),ct(C.current,w.current,e).then(e=>{let t={...e,isPositioned:k.current!==!1};j.current&&!dt(T.current,t)&&(T.current=t,lt.flushSync(()=>{f(t)}))})},[p,t,n,O,k]);ut(()=>{u===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,f(e=>({...e,isPositioned:!1})))},[u]);let j=l.useRef(!1);ut(()=>(j.current=!0,()=>{j.current=!1}),[]),ut(()=>{if(x&&(C.current=x),S&&(w.current=S),x&&S){if(D.current)return D.current(x,S,A);A()}},[x,S,A,D,E]);let M=l.useMemo(()=>({reference:C,floating:w,setReference:y,setFloating:b}),[y,b]),N=l.useMemo(()=>({reference:x,floating:S}),[x,S]),P=l.useMemo(()=>{let e={position:n,left:0,top:0};if(!N.floating)return e;let t=pt(N.floating,d.x),r=pt(N.floating,d.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...ft(N.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,N.floating,d.x,d.y]);return l.useMemo(()=>({...d,update:A,refs:M,elements:N,floatingStyles:P}),[d,A,M,N,P])}var gt=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:ot({element:r.current,padding:i}).fn(n):r?ot({element:r,padding:i}).fn(n):{}}}},_t=(e,t)=>{let n=tt(e);return{name:n.name,fn:n.fn,options:[e,t]}},vt=(e,t)=>{let n=nt(e);return{name:n.name,fn:n.fn,options:[e,t]}},yt=(e,t)=>({fn:st(e).fn,options:[e,t]}),bt=(e,t)=>{let n=rt(e);return{name:n.name,fn:n.fn,options:[e,t]}},xt=(e,t)=>{let n=it(e);return{name:n.name,fn:n.fn,options:[e,t]}},St=(e,t)=>{let n=at(e);return{name:n.name,fn:n.fn,options:[e,t]}},Ct=(e,t)=>{let n=gt(e);return{name:n.name,fn:n.fn,options:[e,t]}},$=r(),wt=`Arrow`,Tt=l.forwardRef((e,t)=>{let{children:n,width:r=10,height:i=5,...a}=e;return(0,$.jsx)(s.svg,{...a,ref:t,width:r,height:i,viewBox:`0 0 30 10`,preserveAspectRatio:`none`,children:e.asChild?n:(0,$.jsx)(`polygon`,{points:`0,0 30,0 15,10`})})});Tt.displayName=wt;var Et=Tt;function Dt(e){let[t,n]=l.useState(void 0);return c(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}else n(void 0)},[e]),t}var Ot=`Popper`,[kt,At]=o(Ot),[jt,Mt]=kt(Ot),Nt=e=>{let{__scopePopper:t,children:n}=e,[r,i]=l.useState(null),[a,o]=l.useState(void 0);return(0,$.jsx)(jt,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:o,children:n})};Nt.displayName=Ot;var Pt=`PopperAnchor`,Ft=l.forwardRef((e,t)=>{let{__scopePopper:n,virtualRef:r,...a}=e,o=Mt(Pt,n),c=l.useRef(null),u=o.onAnchorChange,d=i(t,l.useCallback(e=>{c.current=e,e&&u(e)},[u])),f=l.useRef(null);l.useEffect(()=>{if(!r)return;let e=f.current;f.current=r.current,e!==f.current&&u(f.current)});let p=o.placementState&&Gt(o.placementState),m=p?.[0],h=p?.[1];return r?null:(0,$.jsx)(s.div,{"data-radix-popper-side":m,"data-radix-popper-align":h,...a,ref:d})});Ft.displayName=Pt;var It=`PopperContent`,[Lt,Rt]=kt(It),zt=l.forwardRef((e,t)=>{let{__scopePopper:n,side:r=`bottom`,sideOffset:o=0,align:u=`center`,alignOffset:d=0,arrowPadding:f=0,avoidCollisions:p=!0,collisionBoundary:m=[],collisionPadding:h=0,sticky:g=`partial`,hideWhenDetached:_=!1,updatePositionStrategy:v=`optimized`,onPlaced:y,...b}=e,x=Mt(It,n),[S,C]=l.useState(null),w=i(t,C),[T,E]=l.useState(null),D=Dt(T),O=D?.width??0,k=D?.height??0,A=r+(u===`center`?``:`-`+u),j=typeof h==`number`?h:{top:0,right:0,bottom:0,left:0,...h},M=Array.isArray(m)?m:[m],N=M.length>0,P={padding:j,boundary:M.filter(Ut),altBoundary:N},{refs:F,floatingStyles:ee,placement:I,isPositioned:L,middlewareData:R}=ht({strategy:`fixed`,placement:A,whileElementsMounted:(...e)=>et(...e,{animationFrame:v===`always`}),elements:{reference:x.anchor},middleware:[_t({mainAxis:o+k,alignmentAxis:d}),p&&vt({mainAxis:!0,crossAxis:!1,limiter:g===`partial`?yt():void 0,...P}),p&&bt({...P}),xt({...P,apply:({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)}}),T&&Ct({element:T,padding:f}),Wt({arrowWidth:O,arrowHeight:k}),_&&St({strategy:`referenceHidden`,...P,boundary:N?P.boundary:void 0})]}),te=x.setPlacementState;c(()=>(te(I),()=>{te(void 0)}),[I,te]);let[ne,re]=Gt(I),ie=a(y);c(()=>{L&&ie?.()},[L,ie]);let ae=R.arrow?.x,oe=R.arrow?.y,se=R.arrow?.centerOffset!==0,[ce,le]=l.useState();return c(()=>{S&&le(window.getComputedStyle(S).zIndex)},[S]),(0,$.jsx)(`div`,{ref:F.setFloating,"data-radix-popper-content-wrapper":``,style:{...ee,transform:L?ee.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:ce,"--radix-popper-transform-origin":[R.transformOrigin?.x,R.transformOrigin?.y].join(` `),...R.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,$.jsx)(Lt,{scope:n,placedSide:ne,placedAlign:re,onArrowChange:E,arrowX:ae,arrowY:oe,shouldHideArrow:se,children:(0,$.jsx)(s.div,{"data-side":ne,"data-align":re,...b,ref:w,style:{...b.style,animation:L?void 0:`none`}})})})});zt.displayName=It;var Bt=`PopperArrow`,Vt={top:`bottom`,right:`left`,bottom:`top`,left:`right`},Ht=l.forwardRef(function(e,t){let{__scopePopper:n,...r}=e,i=Rt(Bt,n),a=Vt[i.placedSide];return(0,$.jsx)(`span`,{ref:i.onArrowChange,style:{position:`absolute`,left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:``,right:`0 0`,bottom:`center 0`,left:`100% 0`}[i.placedSide],transform:{top:`translateY(100%)`,right:`translateY(50%) rotate(90deg) translateX(-50%)`,bottom:`rotate(180deg)`,left:`translateY(50%) rotate(-90deg) translateX(50%)`}[i.placedSide],visibility:i.shouldHideArrow?`hidden`:void 0},children:(0,$.jsx)(Et,{...r,ref:t,style:{...r.style,display:`block`}})})});Ht.displayName=Bt;function Ut(e){return e!==null}var Wt=e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=Gt(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}});function Gt(e){let[t,n=`center`]=e.split(`-`);return[t,n]}var Kt=Nt,qt=Ft,Jt=zt,Yt=Ht;export{At as a,Kt as i,Yt as n,Jt as r,qt as t};
@@ -0,0 +1 @@
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t}from"./vendor-react-BOUWij0V.js";var n=e(t(),1);function r(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function i(...e){return t=>{let n=!1,i=e.map(e=>{let i=r(e,t);return!n&&typeof i==`function`&&(n=!0),i});if(n)return()=>{for(let t=0;t<i.length;t++){let n=i[t];typeof n==`function`?n():r(e[t],null)}}}}function a(...e){return n.useCallback(i(...e),e)}function o(e){let t=n.forwardRef((t,r)=>{let{children:i,...o}=t,s=null,c=!1,l=[];h(i)&&typeof y==`function`&&(i=y(i._payload)),n.Children.forEach(i,e=>{if(p(e)){c=!0;let t=e,n=`child`in t.props?t.props.child:t.props.children;h(n)&&typeof y==`function`&&(n=y(n._payload)),s=u(t,n),l.push(s?.props?.children)}else l.push(e)}),s?s=n.cloneElement(s,void 0,l):!c&&n.Children.count(i)===1&&n.isValidElement(i)&&(s=i);let m=s?f(s):void 0,g=a(r,m);if(!s){if(i||i===0)throw Error(c?v(e):_(e));return i}let b=d(o,s.props??{});return s.type!==n.Fragment&&(b.ref=r?g:m),n.cloneElement(s,b)});return t.displayName=`${e}.Slot`,t}var s=o(`Slot`),c=Symbol.for(`radix.slottable`);function l(e){let t=e=>`child`in e?e.children(e.child):e.children;return t.displayName=`${e}.Slottable`,t.__radixId=c,t}var u=(e,t)=>{if(`child`in e.props){let t=e.props.child;return n.isValidElement(t)?n.cloneElement(t,void 0,e.props.children(t.props.children)):null}return n.isValidElement(t)?t:null};function d(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}function f(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function p(e){return n.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===c}var m=Symbol.for(`react.lazy`);function h(e){return typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===m&&`_payload`in e&&g(e._payload)}function g(e){return typeof e==`object`&&!!e&&`then`in e}var _=e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,v=e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,y=n.use;export{a as i,o as n,l as r,s as t};
@@ -0,0 +1,3 @@
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{d as i}from"./chunk-QUQL4437-DXsxWP7r.js";import{t as a}from"./cn-BQ_8x0bT.js";import{t as o}from"./messages-CQGpD-dC.js";import{d as s,i as c,n as l,o as u}from"./locale-store-Bp8joZck.js";import{i as d}from"./vendor-swr-BIWyz7Rc.js";import{As as f,Fs as p,Ir as m,Ko as h,Lc as g,Oc as _,Rc as v,Ur as y,Wo as b,Ws as x,Zs as S,bu as C,gc as w,kt as T,ms as E,nc as D,no as O,sc as k,tl as A,us as j,ys as M}from"./index-CxkNzw3e.js";import{n as ee,r as N,t as P}from"./settings-page-layout-DaFwstQw.js";import{n as F,t as te}from"./settings-form-section-CmnDhsf0.js";import{t as I}from"./page-tabs-DKB6RDre.js";import{n as L,t as R}from"./schedule-field-BXDP-oMz.js";import{t as z}from"./format-cron-label-arqgGlVV.js";var B=e(t(),1),V=n();function H(e,t){let n=new URLSearchParams;e&&n.set(`agentId`,e);for(let[e,r]of Object.entries(t??{}))r!==void 0&&n.set(e,String(r));let r=n.toString();return r?`?${r}`:``}function ne(e){return s(`/api/dreaming${H(e)}`)}async function re(e){let t=await c(e?.startsWith(`/api/`)||e?.includes(`/api/dreaming`)?e:ne(e));if(!t.payload)throw Error(`Missing payload`);return t.payload}async function ie(e,t){await c(s(`/api/dreaming/action`),{method:`POST`,body:JSON.stringify({action:e,agentId:t})})}async function ae(e=`deep`,t){let n=await c(s(`/api/dreaming/run`),{method:`POST`,body:JSON.stringify({phase:e,agentId:t})});if(n.ok===!1||!n.payload)throw Error(`Failed to run dreaming phase`);let r=n.payload.phase;return{agentId:typeof n.payload.agentId==`string`?n.payload.agentId:void 0,phase:r===`light`||r===`deep`||r===`rem`?r:e,result:n.payload.result}}async function oe(e,t){let n=await c(s(`/api/dreaming/preview${H(t,typeof e==`number`&&Number.isFinite(e)?{limit:e}:void 0)}`));if(!n.payload)throw Error(`Missing payload`);return n.payload}async function se(e=50,t){return(await c(s(`/api/dreaming/events${H(t,{limit:e})}`))).payload?.events??[]}function U(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var W={enabled:!0,cron:`0 */6 * * *`,lookbackDays:1,limit:50,dedupeSimilarity:.85},G={enabled:!0,cron:`0 3 * * *`,minScore:.8,minRecallCount:3,minUniqueQueries:3,limit:10,recencyHalfLifeDays:14,maxAgeDays:30},K={enabled:!0,cron:`0 5 * * 0`,lookbackDays:7,limit:20,minPatternStrength:.6},q={enabled:!1,frequency:`0 3 * * *`,timezone:``,deepEnabled:!0,minScore:.8,minRecallCount:3,limit:10,light:W,deep:G,rem:K};function J(e,t){return Number.isFinite(e)?Math.max(0,Math.min(1,e)):t}function Y(e,t){let n=typeof e==`string`?Number(e):e;return Number.isFinite(n)?Math.max(0,Math.floor(n)):t}function ce(e,t){let n=typeof e==`string`?Number(e):e;return Number.isFinite(n)?n:t}function le(e){let t=U(e)?e:{},n=U(t.memory)?t.memory:{},r=U(t.dreaming)?t.dreaming:{},i=typeof t.enabled==`boolean`||typeof t.frequency==`string`||U(t.phases)?t:{},a=U(n.dreaming)?n.dreaming:Object.keys(r).length>0?r:i,o=U(a.phases)?a.phases:{},s=U(o.light)?o.light:{},c=U(o.deep)?o.deep:{},l=U(o.rem)?o.rem:{};return{enabled:a.enabled===!0,frequency:typeof a.frequency==`string`&&a.frequency.trim()?a.frequency.trim():q.frequency,timezone:typeof a.timezone==`string`?a.timezone:``,deepEnabled:c.enabled!==!1,minScore:J(typeof c.minScore==`number`?c.minScore:Number(c.minScore),q.minScore),minRecallCount:Math.max(1,Y(c.minRecallCount,q.minRecallCount)),limit:Y(c.limit,q.limit),light:{enabled:s.enabled!==!1,cron:typeof s.cron==`string`&&s.cron.trim()?s.cron.trim():W.cron,lookbackDays:Math.max(1,Y(s.lookbackDays,W.lookbackDays)),limit:Y(s.limit,W.limit),dedupeSimilarity:J(ce(s.dedupeSimilarity,W.dedupeSimilarity),W.dedupeSimilarity)},deep:{enabled:c.enabled!==!1,cron:typeof c.cron==`string`&&c.cron.trim()?c.cron.trim():G.cron,minScore:J(ce(c.minScore,G.minScore),G.minScore),minRecallCount:Math.max(1,Y(c.minRecallCount,G.minRecallCount)),minUniqueQueries:Math.max(1,Y(c.minUniqueQueries,G.minUniqueQueries)),limit:Y(c.limit,G.limit),recencyHalfLifeDays:Math.max(1,ce(c.recencyHalfLifeDays,G.recencyHalfLifeDays)),maxAgeDays:Math.max(1,ce(c.maxAgeDays,G.maxAgeDays))},rem:{enabled:l.enabled!==!1,cron:typeof l.cron==`string`&&l.cron.trim()?l.cron.trim():K.cron,lookbackDays:Math.max(1,Y(l.lookbackDays,K.lookbackDays)),limit:Y(l.limit,K.limit),minPatternStrength:J(ce(l.minPatternStrength,K.minPatternStrength),K.minPatternStrength)}}}async function ue(e,t,n){let r=t.frequency.trim(),i=t.timezone.trim();await c(s(`/api/agents/${encodeURIComponent(e)}`),{method:`PATCH`,body:JSON.stringify({memory:{...n??{},mode:t.enabled?`confirmWrite`:typeof n?.mode==`string`?n.mode:`off`,sources:Array.isArray(n?.sources)?n.sources:[`session`,`curated`,`workspace`],writePolicy:U(n?.writePolicy)?n.writePolicy:{curated:`confirm`,workspace:`confirm`},dreaming:{enabled:!!t.enabled,...r?{frequency:r}:{},...i?{timezone:i}:{},phases:{light:{enabled:!!t.light.enabled,...t.light.cron.trim()?{cron:t.light.cron.trim()}:{},lookbackDays:Math.max(1,Math.floor(t.light.lookbackDays)),limit:Math.max(0,Math.floor(t.light.limit)),dedupeSimilarity:J(t.light.dedupeSimilarity,W.dedupeSimilarity)},deep:{enabled:!!t.deep.enabled,...t.deep.cron.trim()?{cron:t.deep.cron.trim()}:{},minScore:J(t.deep.minScore,G.minScore),minRecallCount:Math.max(1,Math.floor(t.deep.minRecallCount)),minUniqueQueries:Math.max(1,Math.floor(t.deep.minUniqueQueries)),limit:Math.max(0,Math.floor(t.deep.limit)),recencyHalfLifeDays:Math.max(1,t.deep.recencyHalfLifeDays),maxAgeDays:Math.max(1,t.deep.maxAgeDays)},rem:{enabled:!!t.rem.enabled,...t.rem.cron.trim()?{cron:t.rem.cron.trim()}:{},lookbackDays:Math.max(1,Math.floor(t.rem.lookbackDays)),limit:Math.max(0,Math.floor(t.rem.limit)),minPatternStrength:J(t.rem.minPatternStrength,K.minPatternStrength)}}}}})}),O()}var de=`p-4 sm:px-5`,fe=`mb-3`,pe=`rounded-xl bg-surface-panel/60 p-3 shadow-surface sm:p-4`,X=a(`mt-1 w-full rounded-lg border border-edge-subtle bg-surface-panel px-2.5 py-1.5 text-sm text-fg`,j);function me(e){return e?e.replace(`T`,` `).replace(`Z`,``):`—`}function he(e){return e===void 0||!Number.isFinite(e)||e<0?`—`:e<1e3?`${Math.round(e)} ms`:`${(e/1e3).toFixed(2)} s`}function ge(e,t){return e.locked?{text:t.lockValueLocked,className:`text-amber-600 dark:text-amber-400`}:{text:t.lockValueUnlocked,className:`text-emerald-600 dark:text-emerald-400`}}var Z=r(),_e=`text-xs font-medium text-fg-muted`,ve=`text-sm font-medium text-fg`;function Q(e){let t=(0,V.c)(6),{label:n,children:r,className:i}=e,a;t[0]===n?a=t[1]:(a=(0,Z.jsx)(`span`,{className:_e,children:n}),t[0]=n,t[1]=a);let o;return t[2]!==r||t[3]!==i||t[4]!==a?(o=(0,Z.jsxs)(`div`,{className:i,children:[a,r]}),t[2]=r,t[3]=i,t[4]=a,t[5]=o):o=t[5],o}function $(e){let t=(0,V.c)(11),{label:n,children:r,className:i}=e,o;t[0]===i?o=t[1]:(o=a(`min-w-0`,i),t[0]=i,t[1]=o);let s;t[2]===n?s=t[3]:(s=(0,Z.jsx)(`dt`,{className:_e,children:n}),t[2]=n,t[3]=s);let c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=a(ve,`mt-0.5`),t[4]=c):c=t[4];let l;t[5]===r?l=t[6]:(l=(0,Z.jsx)(`dd`,{className:c,children:r}),t[5]=r,t[6]=l);let u;return t[7]!==o||t[8]!==s||t[9]!==l?(u=(0,Z.jsxs)(`div`,{className:o,children:[s,l]}),t[7]=o,t[8]=s,t[9]=l,t[10]=u):u=t[10],u}function ye(e){let t=(0,V.c)(5),{label:n,className:r}=e,i;t[0]===r?i=t[1]:(i=a(`text-[0.7rem] font-semibold uppercase tracking-wider text-fg-muted`,r),t[0]=r,t[1]=i);let o;return t[2]!==n||t[3]!==i?(o=(0,Z.jsx)(`h3`,{className:i,children:n}),t[2]=n,t[3]=i,t[4]=o):o=t[4],o}function be(e){let t=(0,V.c)(39),{icon:n,title:r,hint:i,enabled:a,onEnabledChange:o,cron:s,onCronChange:c,scheduleLabels:l,disabled:u,showEnabledControl:d,actions:f,status:p,enabledLabel:m,onLabel:h,offLabel:g,cronLabel:_,children:v}=e,y=d===void 0?!0:d,b;t[0]===n?b=t[1]:(b=(0,Z.jsx)(`span`,{className:`mt-0.5 shrink-0`,children:n}),t[0]=n,t[1]=b);let x;t[2]===r?x=t[3]:(x=(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:r}),t[2]=r,t[3]=x);let S;t[4]!==p||t[5]!==x?(S=(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[x,p]}),t[4]=p,t[5]=x,t[6]=S):S=t[6];let C;t[7]===i?C=t[8]:(C=(0,Z.jsx)(`p`,{className:`mt-0.5 text-xs leading-snug text-fg-muted`,children:i}),t[7]=i,t[8]=C);let w;t[9]!==S||t[10]!==C?(w=(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[S,C]}),t[9]=S,t[10]=C,t[11]=w):w=t[11];let T;t[12]!==b||t[13]!==w?(T=(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[b,w]}),t[12]=b,t[13]=w,t[14]=T):T=t[14];let E;t[15]!==f||t[16]!==u||t[17]!==a||t[18]!==m||t[19]!==g||t[20]!==o||t[21]!==h||t[22]!==y?(E=f||y?(0,Z.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[f,y?(0,Z.jsxs)(`label`,{className:`inline-flex shrink-0 items-center gap-2 text-xs text-fg`,children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:a,disabled:u,onChange:e=>o(e.target.checked)}),(0,Z.jsx)(`span`,{children:m??(a?h:g)})]}):null]}):null,t[15]=f,t[16]=u,t[17]=a,t[18]=m,t[19]=g,t[20]=o,t[21]=h,t[22]=y,t[23]=E):E=t[23];let D;t[24]!==T||t[25]!==E?(D=(0,Z.jsxs)(`div`,{className:`mb-2.5 flex flex-wrap items-start justify-between gap-2 rounded-lg bg-surface-base/45 px-3 py-2.5`,children:[T,E]}),t[24]=T,t[25]=E,t[26]=D):D=t[26];let O;t[27]!==s||t[28]!==_||t[29]!==u||t[30]!==c||t[31]!==l?(O=(0,Z.jsx)(R,{kind:`cron`,className:`mb-2.5`,label:_,value:s,onChange:c,labels:l,disabled:u}),t[27]=s,t[28]=_,t[29]=u,t[30]=c,t[31]=l,t[32]=O):O=t[32];let k;t[33]===v?k=t[34]:(k=(0,Z.jsx)(`div`,{className:`grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-4`,children:v}),t[33]=v,t[34]=k);let A;return t[35]!==O||t[36]!==k||t[37]!==D?(A=(0,Z.jsxs)(`div`,{className:pe,children:[D,O,k]}),t[35]=O,t[36]=k,t[37]=D,t[38]=A):A=t[38],A}function xe(e){let t=(0,V.c)(23),{icon:n,label:r,enabled:i,cron:o,scheduleSummary:s,details:c,t:l}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=a(pe,`space-y-1`),t[0]=u):u=t[0];let d;t[1]===r?d=t[2]:(d=(0,Z.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:r}),t[1]=r,t[2]=d);let f=i?`text-emerald-600 dark:text-emerald-400`:`text-fg-muted`,p;t[3]===f?p=t[4]:(p=a(`ml-auto text-xs font-medium`,f),t[3]=f,t[4]=p);let m=i?l.on:l.off,h;t[5]!==p||t[6]!==m?(h=(0,Z.jsx)(`span`,{className:p,children:m}),t[5]=p,t[6]=m,t[7]=h):h=t[7];let g;t[8]!==n||t[9]!==d||t[10]!==h?(g=(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n,d,h]}),t[8]=n,t[9]=d,t[10]=h,t[11]=g):g=t[11];let _;t[12]===s?_=t[13]:(_=(0,Z.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:s}),t[12]=s,t[13]=_);let v;t[14]===o?v=t[15]:(v=(0,Z.jsx)(`p`,{className:`truncate font-mono text-[0.65rem] text-fg-subtle`,title:o,children:o}),t[14]=o,t[15]=v);let y;t[16]===c?y=t[17]:(y=(0,Z.jsx)(`p`,{className:`text-[0.65rem] leading-snug text-fg-muted`,children:c}),t[16]=c,t[17]=y);let b;return t[18]!==y||t[19]!==g||t[20]!==_||t[21]!==v?(b=(0,Z.jsxs)(`div`,{className:u,children:[g,_,v,y]}),t[18]=y,t[19]=g,t[20]=_,t[21]=v,t[22]=b):b=t[22],b}function Se(e){let t=(0,V.c)(9),{label:n,lastRun:r,t:i}=e,a;t[0]===n?a=t[1]:(a=(0,Z.jsx)(ye,{label:n,className:`mb-2`}),t[0]=n,t[1]=a);let o;t[2]!==r||t[3]!==i.lastRunRaw||t[4]!==i.phaseLastRunEmpty?(o=r?.exists?(0,Z.jsxs)(`details`,{className:`group rounded-lg bg-surface-panel/70 shadow-surface`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer list-none px-2.5 py-1.5 text-xs font-medium text-fg-muted marker:hidden [&::-webkit-details-marker]:hidden`,children:(0,Z.jsx)(`span`,{className:`underline decoration-edge underline-offset-2 group-open:text-fg`,children:i.lastRunRaw})}),(0,Z.jsx)(`pre`,{className:`max-h-40 overflow-auto bg-surface-base/50 p-2.5 text-xs text-fg-muted`,children:JSON.stringify(r.raw,null,2)})]}):(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i.phaseLastRunEmpty}),t[2]=r,t[3]=i.lastRunRaw,t[4]=i.phaseLastRunEmpty,t[5]=o):o=t[5];let s;return t[6]!==a||t[7]!==o?(s=(0,Z.jsxs)(`div`,{className:`rounded-lg bg-surface-base/45 p-3`,children:[a,o]}),t[6]=a,t[7]=o,t[8]=s):s=t[8],s}function Ce(e){let t=(0,V.c)(39),{t:n,r}=e,i=r.deep?.skipped,a=r.ok?`text-emerald-600 dark:text-emerald-400`:`text-amber-600 dark:text-amber-400`,o=r.ok?n.lastRunSuccess:n.lastRunFailure,s;t[0]!==a||t[1]!==o?(s=(0,Z.jsx)(`span`,{className:a,children:o}),t[0]=a,t[1]=o,t[2]=s):s=t[2];let c;t[3]!==n.lastRunStatus||t[4]!==s?(c=(0,Z.jsx)($,{label:n.lastRunStatus,children:s}),t[3]=n.lastRunStatus,t[4]=s,t[5]=c):c=t[5];let l=n.lastRunDuration,u;t[6]===r.durationMs?u=t[7]:(u=he(r.durationMs),t[6]=r.durationMs,t[7]=u);let d;t[8]!==n.lastRunDuration||t[9]!==u?(d=(0,Z.jsx)($,{label:l,children:u}),t[8]=n.lastRunDuration,t[9]=u,t[10]=d):d=t[10];let f=n.lastRunRanked,p=String(r.deep?.candidatesRanked??`—`),m;t[11]!==n.lastRunRanked||t[12]!==p?(m=(0,Z.jsx)($,{label:f,children:p}),t[11]=n.lastRunRanked,t[12]=p,t[13]=m):m=t[13];let h=n.lastRunApplied,g=String(r.deep?.applied??`—`),_;t[14]!==n.lastRunApplied||t[15]!==g?(_=(0,Z.jsx)($,{label:h,children:g}),t[14]=n.lastRunApplied,t[15]=g,t[16]=_):_=t[16];let v;t[17]===r.reason?v=t[18]:(v=(0,Z.jsx)(`span`,{className:`block text-pretty`,children:r.reason}),t[17]=r.reason,t[18]=v);let y;t[19]!==r.errorMessage||t[20]!==n.lastRunError?(y=r.errorMessage?(0,Z.jsx)(`span`,{className:`mt-1 block text-xs text-amber-600 dark:text-amber-400`,children:`${n.lastRunError}: ${r.errorMessage}`}):null,t[19]=r.errorMessage,t[20]=n.lastRunError,t[21]=y):y=t[21];let b;t[22]!==n.lastRunReason||t[23]!==v||t[24]!==y?(b=(0,Z.jsxs)($,{label:n.lastRunReason,className:`col-span-2 sm:col-span-3 lg:col-span-4`,children:[v,y]}),t[22]=n.lastRunReason,t[23]=v,t[24]=y,t[25]=b):b=t[25];let x;t[26]!==i||t[27]!==n.lastRunSkipContaminated||t[28]!==n.lastRunSkipHash||t[29]!==n.lastRunSkipKey||t[30]!==n.lastRunSkipRehydrate?(x=i?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)($,{label:n.lastRunSkipKey,children:String(i.alreadyPromotedKey)}),(0,Z.jsx)($,{label:n.lastRunSkipRehydrate,children:String(i.rehydrateFailed)}),(0,Z.jsx)($,{label:n.lastRunSkipContaminated,children:String(i.contaminated)}),(0,Z.jsx)($,{label:n.lastRunSkipHash,children:String(i.hashDuplicate)})]}):null,t[26]=i,t[27]=n.lastRunSkipContaminated,t[28]=n.lastRunSkipHash,t[29]=n.lastRunSkipKey,t[30]=n.lastRunSkipRehydrate,t[31]=x):x=t[31];let S;return t[32]!==m||t[33]!==_||t[34]!==b||t[35]!==x||t[36]!==c||t[37]!==d?(S=(0,Z.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-3 gap-y-2 sm:grid-cols-3 lg:grid-cols-4`,children:[c,d,m,_,b,x]}),t[32]=m,t[33]=_,t[34]=b,t[35]=x,t[36]=c,t[37]=d,t[38]=S):S=t[38],S}function we(e){let t=(0,V.c)(56),{t:n,schedulePickerLabels:r,hasToken:i,cfgForm:o,cfgBaseline:s,cfgDirty:c,cfgSaving:l,runPhase:u,runBusy:d,setCfgForm:f,doRunNow:m}=e,h;t[0]!==c||t[1]!==o?.enabled||t[2]!==l||t[3]!==m||t[4]!==i||t[5]!==d||t[6]!==u||t[7]!==n?(h=(e,t)=>o?.enabled?(0,Z.jsx)(De,{t:n,busy:d&&u===e,disabled:!i||l||d||!t||c,title:c?n.runNowSaveFirstHint:n.runNowHint,onClick:()=>{m(e)}}):null,t[0]=c,t[1]=o?.enabled,t[2]=l,t[3]=m,t[4]=i,t[5]=d,t[6]=u,t[7]=n,t[8]=h):h=t[8];let g=h,v;t[9]!==s||t[10]!==o||t[11]!==n.phasePendingSave||t[12]!==n.phaseWillDisable||t[13]!==n.phaseWillEnable?(v=e=>{if(!o||!s)return null;let t=o[e],r=s[e];return JSON.stringify(t)===JSON.stringify(r)?null:t.enabled===r.enabled?n.phasePendingSave:t.enabled?n.phaseWillEnable:n.phaseWillDisable},t[9]=s,t[10]=o,t[11]=n.phasePendingSave,t[12]=n.phaseWillDisable,t[13]=n.phaseWillEnable,t[14]=v):v=t[14];let y=v,b;return t[15]!==c||t[16]!==o||t[17]!==l||t[18]!==i||t[19]!==y||t[20]!==g||t[21]!==r||t[22]!==f||t[23]!==n.configDeepHalfLife||t[24]!==n.configDeepLimit||t[25]!==n.configDeepMaxAge||t[26]!==n.configDeepMinRecallCount||t[27]!==n.configDeepMinScore||t[28]!==n.configDeepMinUniqueQueries||t[29]!==n.configFrequency||t[30]!==n.configLightDedupe||t[31]!==n.configLightLimit||t[32]!==n.configLightLookbackDays||t[33]!==n.configLoading||t[34]!==n.configPhaseCron||t[35]!==n.configPhaseDeep||t[36]!==n.configPhaseDeepHint||t[37]!==n.configPhaseLight||t[38]!==n.configPhaseLightHint||t[39]!==n.configPhaseRem||t[40]!==n.configPhaseRemHint||t[41]!==n.configRemLimit||t[42]!==n.configRemLookbackDays||t[43]!==n.configRemMinStrength||t[44]!==n.configTimezone||t[45]!==n.masterHint||t[46]!==n.masterOff||t[47]!==n.masterOn||t[48]!==n.masterTitle||t[49]!==n.off||t[50]!==n.on||t[51]!==n.phasesTitle||t[52]!==n.scheduleTitle||t[53]!==n.unsavedConfigHint||t[54]!==n.unsavedConfigTitle?(b=(0,Z.jsx)(te,{className:`min-w-0 !p-0`,children:o?(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsxs)(`div`,{className:a(pe,`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`),children:[(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:n.masterTitle}),(0,Z.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:n.masterHint})]}),(0,Z.jsxs)(`label`,{className:a(`inline-flex w-fit cursor-pointer items-center gap-2 rounded-xl border px-3 py-1.5 text-sm transition-colors`,o.enabled?`border-emerald-500/30 bg-emerald-500/5 text-fg`:`border-edge-subtle bg-surface-panel/50 text-fg-muted`),children:[(0,Z.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:o.enabled,disabled:!i||l,onChange:e=>f(t=>t&&{...t,enabled:e.target.checked})}),(0,Z.jsx)(`span`,{className:a(`text-xs font-semibold`,o.enabled?`text-emerald-600 dark:text-emerald-400`:``),children:o.enabled?n.masterOn:n.masterOff})]})]}),c?(0,Z.jsxs)(`div`,{className:`flex items-start gap-2 rounded-xl border border-amber-500/25 bg-amber-500/5 px-3 py-2 text-xs text-amber-900 dark:text-amber-100`,children:[(0,Z.jsx)(A,{className:`mt-0.5 size-3.5 shrink-0`,"aria-hidden":!0}),(0,Z.jsxs)(`div`,{className:`min-w-0`,children:[(0,Z.jsx)(`div`,{className:`font-semibold`,children:n.unsavedConfigTitle}),(0,Z.jsx)(`p`,{className:`mt-0.5 leading-snug text-amber-800/90 dark:text-amber-100/80`,children:n.unsavedConfigHint})]})]}):null,(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(Te,{title:n.scheduleTitle}),(0,Z.jsx)(`div`,{className:pe,children:(0,Z.jsxs)(`div`,{className:`grid grid-cols-1 gap-2 lg:grid-cols-12`,children:[(0,Z.jsx)(`div`,{className:`lg:col-span-9`,children:(0,Z.jsx)(R,{kind:`cron`,label:n.configFrequency,value:o.frequency,onChange:e=>f(t=>t&&{...t,frequency:e}),labels:r,disabled:!i||l})}),(0,Z.jsx)(Q,{label:n.configTimezone,className:`lg:col-span-3`,children:(0,Z.jsx)(`input`,{className:X,value:o.timezone,disabled:!i||l,onChange:e=>f(t=>t&&{...t,timezone:e.target.value}),placeholder:`Asia/Shanghai`})})]})})]}),(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(Te,{title:n.phasesTitle}),(0,Z.jsxs)(be,{icon:(0,Z.jsx)(p,{className:`size-4 text-amber-500`}),title:n.configPhaseLight,hint:n.configPhaseLightHint,enabled:o.light.enabled,onEnabledChange:e=>f(t=>t&&{...t,light:{...t.light,enabled:e}}),cron:o.light.cron,onCronChange:e=>f(t=>t&&{...t,light:{...t.light,cron:e}}),scheduleLabels:r,disabled:!i||l,showEnabledControl:o.enabled,actions:g(`light`,o.light.enabled),status:y(`light`)?(0,Z.jsx)(Ee,{label:y(`light`)??``}):null,enabledLabel:y(`light`)??void 0,onLabel:n.on,offLabel:n.off,cronLabel:n.configPhaseCron,children:[(0,Z.jsx)(Q,{label:n.configLightLookbackDays,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:1,className:X,value:o.light.lookbackDays,disabled:!i||l,onChange:e=>f(t=>t&&{...t,light:{...t.light,lookbackDays:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configLightLimit,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:0,className:X,value:o.light.limit,disabled:!i||l,onChange:e=>f(t=>t&&{...t,light:{...t.light,limit:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configLightDedupe,children:(0,Z.jsx)(`input`,{type:`number`,step:`0.01`,min:0,max:1,className:X,value:o.light.dedupeSimilarity,disabled:!i||l,onChange:e=>f(t=>t&&{...t,light:{...t.light,dedupeSimilarity:Number(e.target.value)}})})})]}),(0,Z.jsxs)(be,{icon:(0,Z.jsx)(_,{className:`size-4 text-indigo-500`}),title:n.configPhaseDeep,hint:n.configPhaseDeepHint,enabled:o.deep.enabled,onEnabledChange:e=>f(t=>t&&{...t,deep:{...t.deep,enabled:e}}),cron:o.deep.cron,onCronChange:e=>f(t=>t&&{...t,deep:{...t.deep,cron:e}}),scheduleLabels:r,disabled:!i||l,showEnabledControl:o.enabled,actions:g(`deep`,o.deep.enabled),status:y(`deep`)?(0,Z.jsx)(Ee,{label:y(`deep`)??``}):null,enabledLabel:y(`deep`)??void 0,onLabel:n.on,offLabel:n.off,cronLabel:n.configPhaseCron,children:[(0,Z.jsx)(Q,{label:n.configDeepMinScore,children:(0,Z.jsx)(`input`,{type:`number`,step:`0.01`,min:0,max:1,className:X,value:o.deep.minScore,disabled:!i||l,onChange:e=>f(t=>t&&{...t,deep:{...t.deep,minScore:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configDeepMinRecallCount,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:1,className:X,value:o.deep.minRecallCount,disabled:!i||l,onChange:e=>f(t=>t&&{...t,deep:{...t.deep,minRecallCount:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configDeepMinUniqueQueries,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:1,className:X,value:o.deep.minUniqueQueries,disabled:!i||l,onChange:e=>f(t=>t&&{...t,deep:{...t.deep,minUniqueQueries:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configDeepLimit,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:0,className:X,value:o.deep.limit,disabled:!i||l,onChange:e=>f(t=>t&&{...t,deep:{...t.deep,limit:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configDeepHalfLife,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:1,className:X,value:o.deep.recencyHalfLifeDays,disabled:!i||l,onChange:e=>f(t=>t&&{...t,deep:{...t.deep,recencyHalfLifeDays:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configDeepMaxAge,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:1,className:X,value:o.deep.maxAgeDays,disabled:!i||l,onChange:e=>f(t=>t&&{...t,deep:{...t.deep,maxAgeDays:Number(e.target.value)}})})})]}),(0,Z.jsxs)(be,{icon:(0,Z.jsx)(x,{className:`size-4 text-purple-500`}),title:n.configPhaseRem,hint:n.configPhaseRemHint,enabled:o.rem.enabled,onEnabledChange:e=>f(t=>t&&{...t,rem:{...t.rem,enabled:e}}),cron:o.rem.cron,onCronChange:e=>f(t=>t&&{...t,rem:{...t.rem,cron:e}}),scheduleLabels:r,disabled:!i||l,showEnabledControl:o.enabled,actions:g(`rem`,o.rem.enabled),status:y(`rem`)?(0,Z.jsx)(Ee,{label:y(`rem`)??``}):null,enabledLabel:y(`rem`)??void 0,onLabel:n.on,offLabel:n.off,cronLabel:n.configPhaseCron,children:[(0,Z.jsx)(Q,{label:n.configRemLookbackDays,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:1,className:X,value:o.rem.lookbackDays,disabled:!i||l,onChange:e=>f(t=>t&&{...t,rem:{...t.rem,lookbackDays:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configRemLimit,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:0,className:X,value:o.rem.limit,disabled:!i||l,onChange:e=>f(t=>t&&{...t,rem:{...t.rem,limit:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configRemMinStrength,children:(0,Z.jsx)(`input`,{type:`number`,step:`0.01`,min:0,max:1,className:X,value:o.rem.minPatternStrength,disabled:!i||l,onChange:e=>f(t=>t&&{...t,rem:{...t.rem,minPatternStrength:Number(e.target.value)}})})})]})]})]}):(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.configLoading})}),t[15]=c,t[16]=o,t[17]=l,t[18]=i,t[19]=y,t[20]=g,t[21]=r,t[22]=f,t[23]=n.configDeepHalfLife,t[24]=n.configDeepLimit,t[25]=n.configDeepMaxAge,t[26]=n.configDeepMinRecallCount,t[27]=n.configDeepMinScore,t[28]=n.configDeepMinUniqueQueries,t[29]=n.configFrequency,t[30]=n.configLightDedupe,t[31]=n.configLightLimit,t[32]=n.configLightLookbackDays,t[33]=n.configLoading,t[34]=n.configPhaseCron,t[35]=n.configPhaseDeep,t[36]=n.configPhaseDeepHint,t[37]=n.configPhaseLight,t[38]=n.configPhaseLightHint,t[39]=n.configPhaseRem,t[40]=n.configPhaseRemHint,t[41]=n.configRemLimit,t[42]=n.configRemLookbackDays,t[43]=n.configRemMinStrength,t[44]=n.configTimezone,t[45]=n.masterHint,t[46]=n.masterOff,t[47]=n.masterOn,t[48]=n.masterTitle,t[49]=n.off,t[50]=n.on,t[51]=n.phasesTitle,t[52]=n.scheduleTitle,t[53]=n.unsavedConfigHint,t[54]=n.unsavedConfigTitle,t[55]=b):b=t[55],b}function Te(e){let t=(0,V.c)(2),{title:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Z.jsx)(`div`,{className:`px-0.5 text-xs font-semibold uppercase tracking-wide text-fg-muted`,children:n}),t[0]=n,t[1]=r),r}function Ee(e){let t=(0,V.c)(2),{label:n}=e,r;return t[0]===n?r=t[1]:(r=(0,Z.jsx)(`span`,{className:`inline-flex shrink-0 rounded-md border border-amber-500/25 bg-amber-500/10 px-1.5 py-0.5 text-[0.65rem] font-semibold text-amber-800 dark:text-amber-200`,children:n}),t[0]=n,t[1]=r),r}function De(e){let t=(0,V.c)(8),{t:n,busy:r,disabled:i,title:a,onClick:o}=e,s;t[0]===r?s=t[1]:(s=r?(0,Z.jsx)(v,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(w,{className:`size-3.5`,"aria-hidden":!0}),t[0]=r,t[1]=s);let c;return t[2]!==i||t[3]!==o||t[4]!==n.runNow||t[5]!==s||t[6]!==a?(c=(0,Z.jsxs)(E,{type:`button`,variant:`secondary`,className:`h-7 gap-1.5 rounded-lg px-2 text-xs`,disabled:i,title:a,onClick:o,children:[s,n.runNow]}),t[2]=i,t[3]=o,t[4]=n.runNow,t[5]=s,t[6]=a,t[7]=c):c=t[7],c}function Oe(e){let t=(0,V.c)(20),{t:n,hasToken:r,eventsLoading:i,events:a,loadEvents:o}=e,s=!r||i,c;t[0]===o?c=t[1]:(c=()=>void o(),t[0]=o,t[1]=c);let l;t[2]===i?l=t[3]:(l=i?(0,Z.jsx)(v,{className:`mr-2 size-4 animate-spin`,"aria-hidden":!0}):null,t[2]=i,t[3]=l);let u;t[4]!==n.eventsLoad||t[5]!==s||t[6]!==c||t[7]!==l?(u=(0,Z.jsxs)(E,{variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:s,onClick:c,children:[l,n.eventsLoad]}),t[4]=n.eventsLoad,t[5]=s,t[6]=c,t[7]=l,t[8]=u):u=t[8];let d;t[9]!==n.eventsHint||t[10]!==n.eventsTitle||t[11]!==u?(d=(0,Z.jsx)(F,{className:fe,icon:C,title:n.eventsTitle,subtitle:n.eventsHint,trailing:u}),t[9]=n.eventsHint,t[10]=n.eventsTitle,t[11]=u,t[12]=d):d=t[12];let f;t[13]!==a||t[14]!==n.eventsEmpty||t[15]!==n.eventsNotLoaded?(f=a?a.length>0?(0,Z.jsx)(`div`,{className:`space-y-1.5`,children:a.map(ke)}):(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.eventsEmpty}):(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.eventsNotLoaded}),t[13]=a,t[14]=n.eventsEmpty,t[15]=n.eventsNotLoaded,t[16]=f):f=t[16];let p;return t[17]!==d||t[18]!==f?(p=(0,Z.jsxs)(te,{className:de,children:[d,f]}),t[17]=d,t[18]=f,t[19]=p):p=t[19],p}function ke(e){let t=e.phase===`light`?`☀️`:e.phase===`rem`?`✨`:`🌙`,n=e.phase===`light`?`scanned=${e.scannedEntries??0} new=${e.newSignals??0} deduped=${e.deduped??0}`:e.phase===`rem`?`patterns=${e.patternsDiscovered??0} analyzed=${e.entriesAnalyzed??0}`:`candidates=${e.candidates??0} applied=${e.applied??0}`;return(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 rounded-lg bg-surface-panel/70 px-3 py-2 text-xs shadow-surface`,children:[(0,Z.jsx)(`span`,{children:t}),(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:e.phase}),(0,Z.jsx)(`span`,{className:a(`font-medium`,e.ok?`text-emerald-600 dark:text-emerald-400`:`text-amber-600 dark:text-amber-400`),children:e.ok?`OK`:`FAIL`}),(0,Z.jsx)(`span`,{className:`text-fg-muted`,children:n}),(0,Z.jsx)(`span`,{className:`text-fg-muted`,children:he(e.durationMs)}),(0,Z.jsx)(`span`,{className:`ml-auto text-fg-subtle`,children:me(e.timestamp)})]},`${e.timestamp}:${e.phase}`)}function Ae(e){let t=(0,V.c)(41),{t:n,agentsMessages:r,hasToken:i,agents:a,selectedAgentId:o,onAgentChange:s,cfgForm:c,cfgSaving:l,enableAllBusy:u,cfgDirty:d,saveConfig:f,enableAllAgentsDreaming:p,doRefresh:g}=e,_;t[0]!==a||t[1]!==r||t[2]!==l||t[3]!==i||t[4]!==s||t[5]!==o?(_=a.length>0?(0,Z.jsx)(b,{className:`h-9 max-w-44 rounded-md border border-edge bg-surface-panel px-2 text-sm text-fg outline-none transition focus:border-accent`,value:o,disabled:!i||l,onChange:e=>s(e.currentTarget.value),"aria-label":`Agent`,children:a.map(e=>(0,Z.jsx)(h,{value:e.id,children:m(e,r)},e.id))}):null,t[0]=a,t[1]=r,t[2]=l,t[3]=i,t[4]=s,t[5]=o,t[6]=_):_=t[6];let y=!i||l||u||a.length===0,x;t[7]===p?x=t[8]:(x=()=>void p(),t[7]=p,t[8]=x);let S;t[9]===u?S=t[10]:(S=u?(0,Z.jsx)(v,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,t[9]=u,t[10]=S);let C;t[11]!==n.enableAllAgentsDreaming||t[12]!==y||t[13]!==x||t[14]!==S?(C=(0,Z.jsxs)(E,{type:`button`,variant:`secondary`,disabled:y,onClick:x,children:[S,n.enableAllAgentsDreaming]}),t[11]=n.enableAllAgentsDreaming,t[12]=y,t[13]=x,t[14]=S,t[15]=C):C=t[15];let w=!i||!c||l||u||!d,T;t[16]===f?T=t[17]:(T=()=>void f(),t[16]=f,t[17]=T);let D;t[18]===l?D=t[19]:(D=l?(0,Z.jsx)(v,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,t[18]=l,t[19]=D);let O;t[20]!==n.saveConfig||t[21]!==w||t[22]!==T||t[23]!==D?(O=(0,Z.jsxs)(E,{type:`button`,variant:`primary`,disabled:w,onClick:T,children:[D,n.saveConfig]}),t[20]=n.saveConfig,t[21]=w,t[22]=T,t[23]=D,t[24]=O):O=t[24];let A=!i,j;t[25]===g?j=t[26]:(j=()=>void g(),t[25]=g,t[26]=j);let M;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(M=(0,Z.jsx)(k,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[27]=M):M=t[27];let N;t[28]!==n.refresh||t[29]!==A||t[30]!==j?(N=(0,Z.jsx)(E,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,disabled:A,title:n.refresh,"aria-label":n.refresh,onClick:j,children:M}),t[28]=n.refresh,t[29]=A,t[30]=j,t[31]=N):N=t[31];let P;t[32]!==_||t[33]!==N||t[34]!==C||t[35]!==O?(P=(0,Z.jsxs)(Z.Fragment,{children:[_,C,O,N]}),t[32]=_,t[33]=N,t[34]=C,t[35]=O,t[36]=P):P=t[36];let F;return t[37]!==n.subtitle||t[38]!==n.title||t[39]!==P?(F=(0,Z.jsx)(ee,{title:n.title,subtitle:n.subtitle,actions:P}),t[37]=n.subtitle,t[38]=n.title,t[39]=P,t[40]=F):F=t[40],F}function je(e){let t=(0,V.c)(30),{t:n,disabled:r,actionBusy:i,doAction:o}=e,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=a(`max-w-2xl`,de),t[0]=s):s=t[0];let c;t[1]!==n.maintenanceHint||t[2]!==n.maintenanceTitle?(c=(0,Z.jsx)(F,{className:fe,icon:M,title:n.maintenanceTitle,subtitle:n.maintenanceHint}),t[1]=n.maintenanceHint,t[2]=n.maintenanceTitle,t[3]=c):c=t[3];let l;t[4]!==o||t[5]!==n.confirmResetStore?(l=()=>{confirm(n.confirmResetStore)&&o(`reset_store`)},t[4]=o,t[5]=n.confirmResetStore,t[6]=l):l=t[6];let u;t[7]===i?u=t[8]:(u=i===`reset_store`?(0,Z.jsx)(v,{className:`mr-2 size-4 animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(f,{className:`mr-2 size-4`,"aria-hidden":!0}),t[7]=i,t[8]=u);let d;t[9]!==r||t[10]!==n.resetStore||t[11]!==l||t[12]!==u?(d=(0,Z.jsxs)(E,{variant:`secondary`,disabled:r,onClick:l,children:[u,n.resetStore]}),t[9]=r,t[10]=n.resetStore,t[11]=l,t[12]=u,t[13]=d):d=t[13];let p;t[14]!==o||t[15]!==n.confirmClearLock?(p=()=>{confirm(n.confirmClearLock)&&o(`clear_lock`)},t[14]=o,t[15]=n.confirmClearLock,t[16]=p):p=t[16];let m;t[17]===i?m=t[18]:(m=i===`clear_lock`?(0,Z.jsx)(v,{className:`mr-2 size-4 animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(g,{className:`mr-2 size-4`,"aria-hidden":!0}),t[17]=i,t[18]=m);let h;t[19]!==r||t[20]!==n.clearLock||t[21]!==p||t[22]!==m?(h=(0,Z.jsxs)(E,{variant:`secondary`,disabled:r,onClick:p,children:[m,n.clearLock]}),t[19]=r,t[20]=n.clearLock,t[21]=p,t[22]=m,t[23]=h):h=t[23];let _;t[24]!==d||t[25]!==h?(_=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[d,h]}),t[24]=d,t[25]=h,t[26]=_):_=t[26];let y;return t[27]!==c||t[28]!==_?(y=(0,Z.jsxs)(te,{className:s,children:[c,_]}),t[27]=c,t[28]=_,t[29]=y):y=t[29],y}function Me(e){let t=(0,V.c)(21),{t:n,hasToken:r,previewLoading:i,previewItems:a,loadPreview:o}=e,s=!r||i,c;t[0]===o?c=t[1]:(c=()=>void o(),t[0]=o,t[1]=c);let l;t[2]===i?l=t[3]:(l=i?(0,Z.jsx)(v,{className:`mr-2 size-4 animate-spin`,"aria-hidden":!0}):null,t[2]=i,t[3]=l);let u;t[4]!==n.previewLoad||t[5]!==s||t[6]!==c||t[7]!==l?(u=(0,Z.jsxs)(E,{variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:s,onClick:c,children:[l,n.previewLoad]}),t[4]=n.previewLoad,t[5]=s,t[6]=c,t[7]=l,t[8]=u):u=t[8];let d;t[9]!==n.previewHint||t[10]!==n.previewTitle||t[11]!==u?(d=(0,Z.jsx)(F,{className:fe,icon:D,title:n.previewTitle,subtitle:n.previewHint,trailing:u}),t[9]=n.previewHint,t[10]=n.previewTitle,t[11]=u,t[12]=d):d=t[12];let f;t[13]!==a||t[14]!==n.previewEligible||t[15]!==n.previewEmpty||t[16]!==n.previewNotLoaded?(f=a?a.length>0?(0,Z.jsx)(`div`,{className:`space-y-2`,children:a.map(e=>{let t=`${e.path}:${e.startLine}-${e.endLine}`,r=e.skippedReason;return(0,Z.jsxs)(`div`,{className:`rounded-lg bg-surface-panel/70 px-2.5 py-2 shadow-surface`,children:[(0,Z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-fg-muted`,children:[(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:t}),(0,Z.jsxs)(`span`,{children:[`score=`,e.score.toFixed(3)]}),(0,Z.jsxs)(`span`,{children:[`recalls=`,e.recallCount]}),(0,Z.jsxs)(`span`,{children:[`avg=`,e.avgScore.toFixed(3)]}),(0,Z.jsxs)(`span`,{children:[`decay=`,e.recencyDecay?.toFixed(3)??`—`]}),r?(0,Z.jsx)(`span`,{className:`text-amber-600 dark:text-amber-400`,children:r}):(0,Z.jsx)(`span`,{className:`text-emerald-600 dark:text-emerald-400`,children:n.previewEligible})]}),e.snippet?(0,Z.jsx)(`div`,{className:`mt-2 text-sm text-fg`,children:e.snippet}):null]},`${e.key}:${e.hash}:${t}`)})}):(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.previewEmpty}):(0,Z.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n.previewNotLoaded}),t[13]=a,t[14]=n.previewEligible,t[15]=n.previewEmpty,t[16]=n.previewNotLoaded,t[17]=f):f=t[17];let p;return t[18]!==d||t[19]!==f?(p=(0,Z.jsxs)(te,{className:de,children:[d,f]}),t[18]=d,t[19]=f,t[20]=p):p=t[20],p}function Ne(e,t){switch(e){case 3e4:return t.every30s;case 6e4:return t.every1min;case 3e5:return t.every5min;case 6e5:return t.every10min;case 9e5:return t.every15min;case 18e5:return t.every30min;case 36e5:return t.every1h;case 72e5:return t.every2h;default:return null}}var Pe={second:new Intl.NumberFormat(`en-US`,{style:`unit`,unit:`second`,unitDisplay:`long`}),minute:new Intl.NumberFormat(`en-US`,{style:`unit`,unit:`minute`,unitDisplay:`long`}),hour:new Intl.NumberFormat(`en-US`,{style:`unit`,unit:`hour`,unitDisplay:`long`})},Fe={second:new Intl.NumberFormat(`zh-CN`,{style:`unit`,unit:`second`,unitDisplay:`long`}),minute:new Intl.NumberFormat(`zh-CN`,{style:`unit`,unit:`minute`,unitDisplay:`long`}),hour:new Intl.NumberFormat(`zh-CN`,{style:`unit`,unit:`hour`,unitDisplay:`long`})};function Ie(e,t){return e.startsWith(`zh`)?Fe[t]:Pe[t]}function Le(e,t,n){let r=Math.max(1e3,Math.round(e));if(n&&L.has(r)){let e=Ne(r,n);if(e)return e}let i=Math.max(1,Math.round(r/1e3));if(i<120)return Ie(t,`second`).format(i);let a=Math.round(i/60);if(a<120)return Ie(t,`minute`).format(a);let o=Math.round(a/60);return Ie(t,`hour`).format(o)}function Re(e){let t=(0,V.c)(12),n;t[0]!==e.expression||t[1]!==e.kind||t[2]!==e.labels||t[3]!==e.locale||t[4]!==e.nextRun||t[5]!==e.presetLabels||t[6]!==e.timezone||t[7]!==e.valueMs?(n=e.kind===`cron`?z(e.expression,e.locale,e.labels,{timezone:e.timezone,nextRun:e.nextRun}):Le(e.valueMs,e.locale,e.presetLabels),t[0]=e.expression,t[1]=e.kind,t[2]=e.labels,t[3]=e.locale,t[4]=e.nextRun,t[5]=e.presetLabels,t[6]=e.timezone,t[7]=e.valueMs,t[8]=n):n=t[8];let r=n,i;return t[9]!==e.className||t[10]!==r?(i=(0,Z.jsx)(`span`,{className:e.className,children:r}),t[9]=e.className,t[10]=r,t[11]=i):i=t[11],i}function ze(e){let t=(0,V.c)(100),{t:n,data:r,isLoading:i,localeTag:o,scheduleBadgeLabels:s}=e,c;t[0]!==r||t[1]!==n?(c=r?ge(r.lock,n):null,t[0]=r,t[1]=n,t[2]=c):c=t[2];let l=c,u;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(u=a(`min-w-0`,de),t[3]=u):u=t[3];let d;t[4]===i?d=t[5]:(d=i?(0,Z.jsx)(v,{className:`size-4 shrink-0 animate-spin text-fg-muted`,"aria-hidden":!0}):null,t[4]=i,t[5]=d);let f;t[6]!==n.runtimeHint||t[7]!==n.runtimeTitle||t[8]!==d?(f=(0,Z.jsx)(F,{className:fe,icon:C,title:n.runtimeTitle,subtitle:n.runtimeHint,trailing:d}),t[6]=n.runtimeHint,t[7]=n.runtimeTitle,t[8]=d,t[9]=f):f=t[9];let m;t[10]===n.subsectionSchedule?m=t[11]:(m=(0,Z.jsx)(ye,{label:n.subsectionSchedule,className:`mb-2`}),t[10]=n.subsectionSchedule,t[11]=m);let h=r?r.config.enabled?n.on:n.off:`—`,g;t[12]!==n.enabled||t[13]!==h?(g=(0,Z.jsx)($,{label:n.enabled,children:h}),t[12]=n.enabled,t[13]=h,t[14]=g):g=t[14];let y=l?.className,b=l?l.text:`—`,S;t[15]!==y||t[16]!==b?(S=(0,Z.jsx)(`span`,{className:y,children:b}),t[15]=y,t[16]=b,t[17]=S):S=t[17];let w;t[18]!==n.lock||t[19]!==S?(w=(0,Z.jsx)($,{label:n.lock,children:S}),t[18]=n.lock,t[19]=S,t[20]=w):w=t[20];let T=r&&r.config.timezone||`—`,E;t[21]!==n.timezone||t[22]!==T?(E=(0,Z.jsx)($,{label:n.timezone,children:T}),t[21]=n.timezone,t[22]=T,t[23]=E):E=t[23];let D;t[24]!==r||t[25]!==o||t[26]!==s?(D=r?(0,Z.jsx)(Re,{kind:`cron`,expression:r.config.frequency,locale:o,labels:s,timezone:r.config.timezone||void 0}):`—`,t[24]=r,t[25]=o,t[26]=s,t[27]=D):D=t[27];let O;t[28]===r?O=t[29]:(O=r?.config.frequency?(0,Z.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-[0.65rem] text-fg-subtle`,title:r.config.frequency,children:r.config.frequency}):null,t[28]=r,t[29]=O);let k;t[30]!==n.schedule||t[31]!==D||t[32]!==O?(k=(0,Z.jsxs)($,{label:n.schedule,className:`col-span-2 sm:col-span-2`,children:[D,O]}),t[30]=n.schedule,t[31]=D,t[32]=O,t[33]=k):k=t[33];let A;t[34]!==w||t[35]!==E||t[36]!==k||t[37]!==g?(A=(0,Z.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-3 gap-y-2 sm:grid-cols-4`,children:[g,w,E,k]}),t[34]=w,t[35]=E,t[36]=k,t[37]=g,t[38]=A):A=t[38];let j;t[39]!==A||t[40]!==m?(j=(0,Z.jsxs)(`div`,{className:pe,children:[m,A]}),t[39]=A,t[40]=m,t[41]=j):j=t[41];let M;t[42]===n.subsectionStore?M=t[43]:(M=(0,Z.jsx)(ye,{label:n.subsectionStore,className:`mb-2`}),t[42]=n.subsectionStore,t[43]=M);let ee=r?String(r.store.entryCount):`—`,N;t[44]!==n.storeEntries||t[45]!==ee?(N=(0,Z.jsx)($,{label:n.storeEntries,children:ee}),t[44]=n.storeEntries,t[45]=ee,t[46]=N):N=t[46];let P=r?String(r.store.promotedCount):`—`,I;t[47]!==n.storePromoted||t[48]!==P?(I=(0,Z.jsx)($,{label:n.storePromoted,children:P}),t[47]=n.storePromoted,t[48]=P,t[49]=I):I=t[49];let L;t[50]===r?L=t[51]:(L=r?me(r.store.updatedAt):`—`,t[50]=r,t[51]=L);let R;t[52]!==n.storeUpdatedAt||t[53]!==L?(R=(0,Z.jsx)($,{label:n.storeUpdatedAt,children:L}),t[52]=n.storeUpdatedAt,t[53]=L,t[54]=R):R=t[54];let B;t[55]===r?B=t[56]:(B=r?me(r.store.lastPromotedAt):`—`,t[55]=r,t[56]=B);let H;t[57]!==n.storeLastPromotedAt||t[58]!==B?(H=(0,Z.jsx)($,{label:n.storeLastPromotedAt,children:B}),t[57]=n.storeLastPromotedAt,t[58]=B,t[59]=H):H=t[59];let ne;t[60]!==N||t[61]!==I||t[62]!==R||t[63]!==H?(ne=(0,Z.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-3 gap-y-2 sm:grid-cols-4`,children:[N,I,R,H]}),t[60]=N,t[61]=I,t[62]=R,t[63]=H,t[64]=ne):ne=t[64];let re;t[65]!==M||t[66]!==ne?(re=(0,Z.jsxs)(`div`,{className:pe,children:[M,ne]}),t[65]=M,t[66]=ne,t[67]=re):re=t[67];let ie;t[68]!==r||t[69]!==o||t[70]!==s||t[71]!==n?(ie=r?.config?.phases?(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(ye,{label:n.subsectionPhases,className:`mb-2`}),(0,Z.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[(0,Z.jsx)(xe,{icon:(0,Z.jsx)(p,{className:`size-4 text-amber-500`}),label:`Light`,enabled:r.config.phases.light.enabled,cron:r.config.phases.light.cron,scheduleSummary:z(r.config.phases.light.cron,o,s,{timezone:r.config.timezone||void 0}),details:`lookback=${r.config.phases.light.lookbackDays}d, limit=${r.config.phases.light.limit}, dedupe=${r.config.phases.light.dedupeSimilarity}`,t:n}),(0,Z.jsx)(xe,{icon:(0,Z.jsx)(_,{className:`size-4 text-indigo-500`}),label:`Deep`,enabled:r.config.phases.deep.enabled,cron:r.config.phases.deep.cron,scheduleSummary:z(r.config.phases.deep.cron,o,s,{timezone:r.config.timezone||void 0}),details:`minScore=${r.config.phases.deep.minScore}, recalls>=${r.config.phases.deep.minRecallCount}, queries>=${r.config.phases.deep.minUniqueQueries}, limit=${r.config.phases.deep.limit}, halfLife=${r.config.phases.deep.recencyHalfLifeDays}d`,t:n}),(0,Z.jsx)(xe,{icon:(0,Z.jsx)(x,{className:`size-4 text-purple-500`}),label:`REM`,enabled:r.config.phases.rem.enabled,cron:r.config.phases.rem.cron,scheduleSummary:z(r.config.phases.rem.cron,o,s,{timezone:r.config.timezone||void 0}),details:`lookback=${r.config.phases.rem.lookbackDays}d, limit=${r.config.phases.rem.limit}, strength≥${r.config.phases.rem.minPatternStrength}`,t:n})]})]}):null,t[68]=r,t[69]=o,t[70]=s,t[71]=n,t[72]=ie):ie=t[72];let ae;t[73]===n.subsectionLastRun?ae=t[74]:(ae=(0,Z.jsx)(ye,{label:n.subsectionLastRun,className:`mb-2`}),t[73]=n.subsectionLastRun,t[74]=ae);let oe;t[75]===n.lastRunBlockHint?oe=t[76]:(oe=(0,Z.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:n.lastRunBlockHint}),t[75]=n.lastRunBlockHint,t[76]=oe);let se;t[77]!==r||t[78]!==n?(se=r?.lastRun?.exists?(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[r.lastRun.parseError?(0,Z.jsxs)(`p`,{className:`text-sm text-amber-600 dark:text-amber-400`,role:`alert`,children:[n.lastRunParseError,`: `,r.lastRun.parseError]}):null,r.lastRun.record?(0,Z.jsx)(`div`,{className:`rounded-lg bg-surface-panel/70 p-2.5 shadow-surface`,children:(0,Z.jsx)(Ce,{t:n,r:r.lastRun.record})}):null,r.lastRun.raw!==void 0&&r.lastRun.raw!==null?(0,Z.jsxs)(`details`,{className:`group rounded-lg bg-surface-panel/70 shadow-surface`,children:[(0,Z.jsx)(`summary`,{className:`cursor-pointer list-none px-2.5 py-1.5 text-xs font-medium text-fg-muted marker:hidden [&::-webkit-details-marker]:hidden`,children:(0,Z.jsx)(`span`,{className:`underline decoration-edge underline-offset-2 group-open:text-fg`,children:n.lastRunRaw})}),(0,Z.jsx)(`pre`,{className:`max-h-40 overflow-auto bg-surface-base/50 p-2.5 text-xs text-fg-muted`,children:JSON.stringify(r.lastRun.raw,null,2)})]}):null]}):(0,Z.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.lastRunEmpty}),t[77]=r,t[78]=n,t[79]=se):se=t[79];let U;t[80]!==ae||t[81]!==oe||t[82]!==se?(U=(0,Z.jsxs)(`div`,{className:pe,children:[ae,oe,se]}),t[80]=ae,t[81]=oe,t[82]=se,t[83]=U):U=t[83];let W=r?.lightLastRun,G;t[84]!==n||t[85]!==W?(G=(0,Z.jsx)(Se,{label:n.subsectionLightLastRun,lastRun:W,t:n}),t[84]=n,t[85]=W,t[86]=G):G=t[86];let K=r?.remLastRun,q;t[87]!==n||t[88]!==K?(q=(0,Z.jsx)(Se,{label:n.subsectionRemLastRun,lastRun:K,t:n}),t[87]=n,t[88]=K,t[89]=q):q=t[89];let J;t[90]!==j||t[91]!==re||t[92]!==ie||t[93]!==U||t[94]!==G||t[95]!==q?(J=(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[j,re,ie,U,G,q]}),t[90]=j,t[91]=re,t[92]=ie,t[93]=U,t[94]=G,t[95]=q,t[96]=J):J=t[96];let Y;return t[97]!==J||t[98]!==f?(Y=(0,Z.jsxs)(te,{className:u,children:[f,J]}),t[97]=J,t[98]=f,t[99]=Y):Y=t[99],Y}var Be=[`config`,`runtime`,`insights`,`maintenance`],Ve={config:S,runtime:C,insights:D,maintenance:M};function He(e){return e&&Be.includes(e)?e:`config`}function Ue(e,t){return t===`config`?e.tabConfig:t===`runtime`?e.tabRuntime:t===`insights`?e.tabInsights:e.tabMaintenance}function We(e,t){return t===`config`?e.configTabHint:t===`runtime`?e.runtimeTabHint:t===`insights`?e.insightsTabHint:e.maintenanceTabHint}function Ge(e,t){switch(t.type){case`reset`:return{form:null,baseline:null};case`sync`:return{form:t.value,baseline:t.value};case`set`:return{...e,form:t.value};case`saved`:return{form:t.value,baseline:t.value}}}var Ke={actionBusy:null,actionError:null,actionOk:!1,runBusy:!1,runOk:!1,runError:null,runPhase:`deep`,cfgSaving:!1,cfgOk:!1,cfgError:null,enableAllBusy:!1,previewLoading:!1,previewError:null,previewItems:null,eventsLoading:!1,eventsError:null,events:null},qe=900;function Je(){return typeof window>`u`||typeof window.requestAnimationFrame!=`function`?new Promise(e=>setTimeout(e,0)):new Promise(e=>{window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>e())})})}function Ye(e,t){typeof window>`u`||window.dispatchEvent(new CustomEvent(e,{detail:t}))}function Xe(){let e=l(e=>e.language),t=o(e),n=t.dreamingSettings,r=t.cron.schedulePicker,a=t.cron.scheduleBadge,s=e===`zh`?`zh-CN`:`en-US`,c=!!u(e=>e.token),[f,p]=i(),h=He(f.get(`tab`)),g=f.get(`agentId`)?.trim()||``,_=(0,B.useCallback)(e=>{p(t=>{let n=new URLSearchParams(t);return e===`config`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},[p]),[v,b]=(0,B.useReducer)(T,Ke),{actionBusy:x,actionError:S,runBusy:C,runError:w,runPhase:E,cfgSaving:D,cfgError:O,enableAllBusy:k,previewLoading:A,previewError:j,previewItems:M,eventsLoading:ee,eventsError:N,events:F}=v,[te,I]=(0,B.useReducer)(Ge,{form:null,baseline:null}),L=te.form,R=te.baseline,z=(0,B.useRef)(!1),V=d(c?`dreaming-settings-agents`:null,y,{revalidateOnFocus:!1}),H=V.data?.agents??[],U=g||V.data?.defaultId||``,W=(0,B.useMemo)(()=>H.find(e=>e.id===U),[H,U]),G=(0,B.useCallback)(e=>{z.current=!1,I({type:`reset`}),p(t=>{let n=new URLSearchParams(t);return e?n.set(`agentId`,e):n.delete(`agentId`),n},{replace:!0})},[p]),{data:K,error:q,isLoading:J,mutate:Y}=d(c&&U?ne(U):null,re,{revalidateOnFocus:!1}),ce=(0,B.useMemo)(()=>{let e=[];return q&&e.push(q instanceof Error?q.message:String(q)),S&&e.push(S),w&&e.push(w),j&&e.push(j),N&&e.push(N),O&&e.push(O),e},[q,S,w,j,N,O]),de=(0,B.useCallback)(async()=>{b({type:`patch`,patch:{actionOk:!1,actionError:null,runOk:!1,runError:null,cfgOk:!1,cfgError:null,previewError:null}}),await Y()},[Y]),fe=(0,B.useCallback)(async()=>{b({type:`patch`,patch:{previewLoading:!0,previewError:null}});try{b({type:`patch`,patch:{previewItems:(await oe(20,U)).items??[]}})}catch(e){b({type:`patch`,patch:{previewError:e instanceof Error?e.message:String(e)}})}finally{b({type:`patch`,patch:{previewLoading:!1}})}},[U]),pe=(0,B.useCallback)(async()=>{b({type:`patch`,patch:{eventsLoading:!0,eventsError:null}});try{b({type:`patch`,patch:{events:await se(50,U)}})}catch(e){b({type:`patch`,patch:{eventsError:e instanceof Error?e.message:String(e)}})}finally{b({type:`patch`,patch:{eventsLoading:!1}})}},[U]),X=(0,B.useCallback)(async(e=`deep`)=>{let n=Date.now(),r=H.length>0?H.map(e=>({id:e.id,name:m(e,t.agentsSettings),avatar:e.avatar})):[{id:U,name:W?m(W,t.agentsSettings):void 0,avatar:W?.avatar}].filter(e=>e.id),i=r.length>0?r:[{id:U}],a=[];b({type:`patch`,patch:{runPhase:e,runBusy:!0,runOk:!1,runError:null}});try{let t=i.map(t=>{let n={phase:e,...t.id?{agentId:t.id}:{},...t.name?{agentName:t.name}:{},...t.avatar?{avatar:t.avatar}:{}};return Ye(`dreaming-phase-start`,n),{target:t,detail:n}}).map(async({target:t,detail:n})=>{await Je();try{await ae(e,t.id||U)}catch(e){let n=t.name||t.id||U||`default`,r=e instanceof Error?e.message:String(e);a.push(`${n}: ${r}`)}finally{Ye(`dreaming-phase-end`,n)}});await Promise.all(t),b({type:`patch`,patch:a.length>0?{runError:a.join(`
2
+ `)}:{runOk:!0}}),await Y()}catch(e){b({type:`patch`,patch:{runError:e instanceof Error?e.message:String(e)}})}finally{let e=qe-(Date.now()-n);e>0&&await new Promise(t=>setTimeout(t,e)),b({type:`patch`,patch:{runBusy:!1}})}},[H,t.agentsSettings,Y,W?.avatar,W?.name,U]),me=(0,B.useCallback)(async e=>{b({type:`patch`,patch:{actionBusy:e,actionError:null,actionOk:!1}});try{await ie(e,U),b({type:`patch`,patch:{actionOk:!0}}),await Y()}catch(e){b({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{b({type:`patch`,patch:{actionBusy:null}})}},[Y,U]),he=!c||J||!!x,ge=(0,B.useMemo)(()=>{let e=K?.config;return le(e??{})},[K]),_e=K?.agentId||U||`main`,ve=K?.memory;(0,B.useEffect)(()=>{if(!c){I({type:`reset`}),z.current=!1;return}z.current||I({type:`sync`,value:ge})},[ge,c]);let Q=(0,B.useMemo)(()=>!L||!R?!1:JSON.stringify(L)!==JSON.stringify(R),[L,R]),$=(0,B.useCallback)(async()=>{if(L){b({type:`patch`,patch:{cfgSaving:!0,cfgOk:!1,cfgError:null}});try{await ue(_e,L,ve),I({type:`saved`,value:L}),z.current=!1,b({type:`patch`,patch:{cfgOk:!0}}),await Y()}catch(e){b({type:`patch`,patch:{cfgError:e instanceof Error?e.message:String(e)}})}finally{b({type:`patch`,patch:{cfgSaving:!1}})}}},[_e,ve,L,Y]),ye=(0,B.useCallback)(async()=>{let e=H.length>0?H:U?[{id:U,name:W?.name,avatar:W?.avatar}]:[];if(e.length===0)return;b({type:`patch`,patch:{enableAllBusy:!0,cfgOk:!1,cfgError:null}});let n=[];try{for(let r of e)try{let e=await re(r.id),t=le(e.config);await ue(r.id,{...t,enabled:!0,light:{...t.light,enabled:!0},deep:{...t.deep,enabled:!0},rem:{...t.rem,enabled:!0}},e.memory)}catch(e){let i=m(r,t.agentsSettings);n.push(`${i}: ${e instanceof Error?e.message:String(e)}`)}n.length>0?b({type:`patch`,patch:{cfgError:n.join(`
3
+ `)}}):b({type:`patch`,patch:{cfgOk:!0}}),await Y()}finally{b({type:`patch`,patch:{enableAllBusy:!1}})}},[H,t.agentsSettings,Y,W?.avatar,W?.name,U]);return(0,Z.jsxs)(P,{children:[(0,Z.jsx)(Ae,{t:n,agentsMessages:t.agentsSettings,hasToken:c,agents:H,selectedAgentId:U,onAgentChange:G,cfgForm:L,cfgSaving:D,enableAllBusy:k,cfgDirty:Q,saveConfig:$,enableAllAgentsDreaming:ye,doRefresh:de}),ce.length>0?(0,Z.jsx)(`div`,{className:`space-y-1.5 rounded-2xl border border-amber-500/20 bg-amber-500/5 px-4 py-3`,role:`alert`,children:ce.map(e=>(0,Z.jsx)(`p`,{className:`text-sm text-amber-800 dark:text-amber-200/90`,children:e},e))}):null,(0,Z.jsx)(Ze,{t:n,activeTab:h,onChange:_}),(0,Z.jsx)(Qe,{t:n,id:`config`,activeTab:h,children:(0,Z.jsx)(we,{t:n,schedulePickerLabels:r,hasToken:c,cfgForm:L,cfgBaseline:R,cfgDirty:Q,cfgSaving:D,runPhase:E,runBusy:C,setCfgForm:e=>{z.current=!0;let t=typeof e==`function`?e(L):e;t&&I({type:`set`,value:t})},doRunNow:X})}),(0,Z.jsx)(Qe,{t:n,id:`runtime`,activeTab:h,children:(0,Z.jsx)(ze,{t:n,data:K,isLoading:J,localeTag:s,scheduleBadgeLabels:a})}),(0,Z.jsx)(Qe,{t:n,id:`insights`,activeTab:h,children:(0,Z.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-2`,children:[(0,Z.jsx)(Me,{t:n,hasToken:c,previewLoading:A,previewItems:M,loadPreview:fe}),(0,Z.jsx)(Oe,{t:n,hasToken:c,eventsLoading:ee,events:F,loadEvents:pe})]})}),(0,Z.jsx)(Qe,{t:n,id:`maintenance`,activeTab:h,children:(0,Z.jsx)(je,{t:n,disabled:he,actionBusy:x,doAction:me})})]})}function Ze(e){let t=(0,V.c)(7),{t:n,activeTab:r,onChange:i}=e,a;t[0]===n?a=t[1]:(a=Be.map(e=>({id:e,label:Ue(n,e),icon:Ve[e]})),t[0]=n,t[1]=a);let o=a,s;return t[2]!==r||t[3]!==o||t[4]!==i||t[5]!==n.tabsAriaLabel?(s=(0,Z.jsx)(I,{items:o,activeTab:r,onChange:i,ariaLabel:n.tabsAriaLabel,tabIdPrefix:`dreaming-settings-tab`,panelIdPrefix:`dreaming-settings-panel`}),t[2]=r,t[3]=o,t[4]=i,t[5]=n.tabsAriaLabel,t[6]=s):s=t[6],s}function Qe(e){let t=(0,V.c)(13),{t:n,id:r,activeTab:i,children:a}=e,o=r!==`config`,s;t[0]!==r||t[1]!==n?(s=Ue(n,r),t[0]=r,t[1]=n,t[2]=s):s=t[2];let c;t[3]!==r||t[4]!==n?(c=We(n,r),t[3]=r,t[4]=n,t[5]=c):c=t[5];let l;return t[6]!==i||t[7]!==a||t[8]!==r||t[9]!==o||t[10]!==s||t[11]!==c?(l=(0,Z.jsx)(N,{id:r,activeTab:i,tabIdPrefix:`dreaming-settings-tab`,panelIdPrefix:`dreaming-settings-panel`,title:s,hint:c,showHeading:o,children:a}),t[6]=i,t[7]=a,t[8]=r,t[9]=o,t[10]=s,t[11]=c,t[12]=l):l=t[12],l}export{Xe as DreamingSettingsPanel};
@@ -0,0 +1 @@
1
+ import"./rolldown-runtime-aKtaBQYM.js";import{a as e,n as t,t as n}from"./vendor-react-BOUWij0V.js";import{t as r}from"./messages-CQGpD-dC.js";import{n as i}from"./locale-store-Bp8joZck.js";import{so as a}from"./index-CxkNzw3e.js";var o=t();e();var s=n();function c(){let e=(0,o.c)(44),t=i(d),n;e[0]===t?n=e[1]:(n=r(t),e[0]=t,e[1]=n);let c=n.extensionDebug,f=a(),p;e[2]===f?p=e[3]:(p=f.toSorted(u),e[2]=f,e[3]=p);let m=p,h;e[4]===c.title?h=e[5]:(h=(0,s.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:c.title}),e[4]=c.title,e[5]=h);let g;e[6]===c.subtitle?g=e[7]:(g=(0,s.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:c.subtitle}),e[6]=c.subtitle,e[7]=g);let _;e[8]!==h||e[9]!==g?(_=(0,s.jsxs)(`div`,{children:[h,g]}),e[8]=h,e[9]=g,e[10]=_):_=e[10];let v;e[11]===c.listHeading?v=e[12]:(v=(0,s.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:c.listHeading}),e[11]=c.listHeading,e[12]=v);let y;e[13]===c.colId?y=e[14]:(y=(0,s.jsx)(`th`,{className:`py-2 pr-2`,children:c.colId}),e[13]=c.colId,e[14]=y);let b;e[15]===c.colName?b=e[16]:(b=(0,s.jsx)(`th`,{className:`py-2 pr-2`,children:c.colName}),e[15]=c.colName,e[16]=b);let x;e[17]===c.colPermissions?x=e[18]:(x=(0,s.jsx)(`th`,{className:`py-2`,children:c.colPermissions}),e[17]=c.colPermissions,e[18]=x);let S;e[19]!==y||e[20]!==b||e[21]!==x?(S=(0,s.jsx)(`thead`,{children:(0,s.jsxs)(`tr`,{className:`border-b border-edge text-xs uppercase text-fg-muted`,children:[y,b,x]})}),e[19]=y,e[20]=b,e[21]=x,e[22]=S):S=e[22];let C;e[23]===m?C=e[24]:(C=m.map(l),e[23]=m,e[24]=C);let w;e[25]===C?w=e[26]:(w=(0,s.jsx)(`tbody`,{children:C}),e[25]=C,e[26]=w);let T;e[27]!==w||e[28]!==S?(T=(0,s.jsx)(`div`,{className:`mt-3 overflow-x-auto`,children:(0,s.jsxs)(`table`,{className:`w-full min-w-[32rem] border-collapse text-left text-sm`,children:[S,w]})}),e[27]=w,e[28]=S,e[29]=T):T=e[29];let E;e[30]!==T||e[31]!==v?(E=(0,s.jsxs)(`section`,{className:`rounded-xl bg-surface-base p-4`,children:[v,T]}),e[30]=T,e[31]=v,e[32]=E):E=e[32];let D;e[33]===c.futureHeading?D=e[34]:(D=(0,s.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:c.futureHeading}),e[33]=c.futureHeading,e[34]=D);let O;e[35]===c.futureBody?O=e[36]:(O=(0,s.jsx)(`p`,{className:`mt-2`,children:c.futureBody}),e[35]=c.futureBody,e[36]=O);let k;e[37]!==D||e[38]!==O?(k=(0,s.jsxs)(`section`,{className:`rounded-xl bg-surface-muted/50 p-4 text-sm text-fg-muted shadow-surface`,children:[D,O]}),e[37]=D,e[38]=O,e[39]=k):k=e[39];let A;return e[40]!==E||e[41]!==k||e[42]!==_?(A=(0,s.jsxs)(`div`,{className:`flex w-full flex-col gap-6 px-3 py-8 sm:px-5 xl:px-6`,children:[_,E,k]}),e[40]=E,e[41]=k,e[42]=_,e[43]=A):A=e[43],A}function l(e){return(0,s.jsxs)(`tr`,{className:`border-b border-edge-subtle`,children:[(0,s.jsx)(`td`,{className:`py-2 pr-2 font-mono text-xs text-fg`,children:e.id}),(0,s.jsx)(`td`,{className:`py-2 pr-2 text-fg`,children:e.name}),(0,s.jsx)(`td`,{className:`py-2 font-mono text-xs text-fg-muted`,children:(e.ui?.permissions??[]).join(`, `)||`—`})]},e.id)}function u(e,t){return e.id.localeCompare(t.id)}function d(e){return e.language}export{c as ExtensionDebugPage};