@xopcai/xopc 0.0.123 → 0.0.124

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 (264) hide show
  1. package/README.md +28 -11
  2. package/README.zh-CN.md +28 -11
  3. package/dist/browser-ext/manifest.json +1 -1
  4. package/dist/extensions/telegram/xopc.extension.json +1 -1
  5. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-Bicr3ZBg.js → agent-avatar-dicebear-B5uSVAyJ.js} +1 -1
  6. package/dist/gateway/static/root/assets/agents-BjIxt67Z.js +2 -0
  7. package/dist/gateway/static/root/assets/{app-management-settings-panel-CbEy9sR1.js → app-management-settings-panel-CYCONLIL.js} +1 -1
  8. package/dist/gateway/static/root/assets/{appearance-settings-CTHja6n9.js → appearance-settings-Clw3ryKg.js} +1 -1
  9. package/dist/gateway/static/root/assets/apps-page-QICTeGjX.js +1 -0
  10. package/dist/gateway/static/root/assets/{archive-plugin-Bpy64GjU.js → archive-plugin-CXUGRp2i.js} +1 -1
  11. package/dist/gateway/static/root/assets/{attachment-load-DMkp4xSb.js → attachment-load-Cmiub3Wg.js} +1 -1
  12. package/dist/gateway/static/root/assets/{automation-suggestion-card-KnYaP7NT.js → automation-suggestion-card-CU0-4nQ-.js} +1 -1
  13. package/dist/gateway/static/root/assets/automations-page-Car-jtiz.js +1 -0
  14. package/dist/gateway/static/root/assets/{binary-plugins-DA9C5mCw.js → binary-plugins-0Izz-N3p.js} +1 -1
  15. package/dist/gateway/static/root/assets/{block-editor-CiSXk_YC.js → block-editor-C1Kv0IkJ.js} +6 -6
  16. package/dist/gateway/static/root/assets/browser-settings-page-CMeBJzlS.js +8 -0
  17. package/dist/gateway/static/root/assets/{capability-presets-api-CEJ44WCU.js → capability-presets-api-BmQTM9Il.js} +1 -1
  18. package/dist/gateway/static/root/assets/capability-presets-settings-panel-DZEJEoCF.js +1 -0
  19. package/dist/gateway/static/root/assets/{channel-recipient-api-CDhrhfhN.js → channel-recipient-api-BeA2aVor.js} +1 -1
  20. package/dist/gateway/static/root/assets/channels-settings-kkW-xFau.js +1 -0
  21. package/dist/gateway/static/root/assets/connectors-page-BvaQvO5F.js +2 -0
  22. package/dist/gateway/static/root/assets/{directory-picker-path-field-7jKfbH0J.js → directory-picker-path-field-2rjzUu57.js} +1 -1
  23. package/dist/gateway/static/root/assets/{dreaming-settings-m1-wmz4o.js → dreaming-settings-DnHO686d.js} +1 -1
  24. package/dist/gateway/static/root/assets/{extension-debug-page-C9qQQrBS.js → extension-debug-page-BGLRuWVN.js} +1 -1
  25. package/dist/gateway/static/root/assets/{extension-page-DcBBMEGl.js → extension-page-D978ePp9.js} +1 -1
  26. package/dist/gateway/static/root/assets/{extension-settings-page-BQ-jMMP9.js → extension-settings-page-B6Ih4Swx.js} +1 -1
  27. package/dist/gateway/static/root/assets/{fetch-Dtpbbe0s.js → fetch-BU5S0Sn7.js} +1 -1
  28. package/dist/gateway/static/root/assets/{gateway-config-api-BN6pyX2c.js → gateway-config-api-BIPGwrl1.js} +1 -1
  29. package/dist/gateway/static/root/assets/gateway-settings-CMEA3r5u.js +1 -0
  30. package/dist/gateway/static/root/assets/{gateway-startup-retry-BIET2x3y.js → gateway-startup-retry-Cd0Zz30N.js} +1 -1
  31. package/dist/gateway/static/root/assets/{goal-create-dialog-BuIMDx6C.js → goal-create-dialog-B-KHKeXN.js} +1 -1
  32. package/dist/gateway/static/root/assets/goal-detail-page-BxrSoWdj.js +1 -0
  33. package/dist/gateway/static/root/assets/{goals-config-api-CQm2r1Ty.js → goals-config-api-B95KdGMj.js} +1 -1
  34. package/dist/gateway/static/root/assets/goals-page-BTJzIl28.js +2 -0
  35. package/dist/gateway/static/root/assets/{goals-settings-DDrdRMxB.js → goals-settings-BJyEuLLm.js} +1 -1
  36. package/dist/gateway/static/root/assets/heartbeat-settings-wkOjYNQT.js +1 -0
  37. package/dist/gateway/static/root/assets/{index-CBDr5xjB.css → index-BLaXr6Ev.css} +1 -1
  38. package/dist/gateway/static/root/assets/index-c_9TVr_C.js +191 -0
  39. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-C2TuQppb.js → keyboard-shortcuts-settings-BT8T4DyC.js} +1 -1
  40. package/dist/gateway/static/root/assets/logs-page-CrxBJUgI.js +2 -0
  41. package/dist/gateway/static/root/assets/{markdown-split-DhONQ81k.js → markdown-split-Dv66bO2b.js} +1 -1
  42. package/dist/gateway/static/root/assets/{media-plugins-DS44pJzr.js → media-plugins-BhIQU5yS.js} +1 -1
  43. package/dist/gateway/static/root/assets/messages-O6TAtdFC.js +3 -0
  44. package/dist/gateway/static/root/assets/models-hub-panel-DOOpz6y1.js +2 -0
  45. package/dist/gateway/static/root/assets/notes-page-Br16pK9v.js +1 -0
  46. package/dist/gateway/static/root/assets/notes-workbench-PSJAi0ZC.js +2 -0
  47. package/dist/gateway/static/root/assets/{preview-open-alternatives-Dej6zHnr.js → preview-open-alternatives-DGzet1d7.js} +1 -1
  48. package/dist/gateway/static/root/assets/project-detail-page-CIGGgKuw.js +1 -0
  49. package/dist/gateway/static/root/assets/projects-page-B2grhsBt.js +1 -0
  50. package/dist/gateway/static/root/assets/remote-access-hub-CXMORxBD.js +1 -0
  51. package/dist/gateway/static/root/assets/{save-bar-controls-Zu1FzH6z.js → save-bar-controls-Cqgb-jqa.js} +1 -1
  52. package/dist/gateway/static/root/assets/{schedule-field-BW78mKc0.js → schedule-field-DVZcI8Yt.js} +1 -1
  53. package/dist/gateway/static/root/assets/{schema-form-Cc-IOydE.js → schema-form-Bj7sOxC8.js} +1 -1
  54. package/dist/gateway/static/root/assets/sessions-page-Bi2wkBzU.js +1 -0
  55. package/dist/gateway/static/root/assets/settings-advanced-gate-B1L3G4IA.js +1 -0
  56. package/dist/gateway/static/root/assets/{settings-collapsible-section-DIpIYht_.js → settings-collapsible-section-BmXn-8N6.js} +1 -1
  57. package/dist/gateway/static/root/assets/{settings-form-section-BFxBNxOG.js → settings-form-section-BnqYMWHR.js} +1 -1
  58. package/dist/gateway/static/root/assets/settings-page-BfRSHJmO.js +1 -0
  59. package/dist/gateway/static/root/assets/{settings-page-layout-CLx4o2PN.js → settings-page-layout-CdWZU1hd.js} +1 -1
  60. package/dist/gateway/static/root/assets/setup-status-panel-CWtPM7RK.js +1 -0
  61. package/dist/gateway/static/root/assets/{share-preview-page-ZswWCrDu.js → share-preview-page-IB1v8i86.js} +1 -1
  62. package/dist/gateway/static/root/assets/shares-settings-ngbsBgij.js +1 -0
  63. package/dist/gateway/static/root/assets/skill-reload-api-BIe442Gv.js +1 -0
  64. package/dist/gateway/static/root/assets/skills-page-BfchZRVa.js +2 -0
  65. package/dist/gateway/static/root/assets/{system-settings-panel-3ZNcGRhS.js → system-settings-panel-BxQ384RC.js} +1 -1
  66. package/dist/gateway/static/root/assets/{typed-models-lib-bpzZjiVF.js → typed-models-lib-BkcpvFYO.js} +1 -1
  67. package/dist/gateway/static/root/assets/{use-channel-catalog-BCjZLZ3O.js → use-channel-catalog-Cd0FaEQ4.js} +1 -1
  68. package/dist/gateway/static/root/assets/{user-profile-settings-panel-CIXafITi.js → user-profile-settings-panel-DQ7NnRSY.js} +1 -1
  69. package/dist/gateway/static/root/assets/{utils-DXMtz5j_.js → utils-YKhVf7Ka.js} +1 -1
  70. package/dist/gateway/static/root/assets/voice-api-key-field-C5Ov8Uk_.js +1 -0
  71. package/dist/gateway/static/root/assets/workflow-run-setup-panel-BYD9BtOq.js +3 -0
  72. package/dist/gateway/static/root/assets/{workflow-start-dialog-B4sZpTDQ.js → workflow-start-dialog-BNJVCWoS.js} +1 -1
  73. package/dist/gateway/static/root/assets/workflows-page-BYF29ANm.js +18 -0
  74. package/dist/gateway/static/root/index.html +5 -5
  75. package/dist/package.js +1 -1
  76. package/dist/src/agent/agent-manager.d.ts +6 -1
  77. package/dist/src/agent/agent-manager.js +28 -12
  78. package/dist/src/agent/agent-manager.js.map +1 -1
  79. package/dist/src/agent/context/workspace-templates/AGENTS.md +1 -1
  80. package/dist/src/agent/embedded/xopc-tools-bridge.js +11 -7
  81. package/dist/src/agent/embedded/xopc-tools-bridge.js.map +1 -1
  82. package/dist/src/agent/lifecycle/progress.js +3 -1
  83. package/dist/src/agent/lifecycle/progress.js.map +1 -1
  84. package/dist/src/agent/lifecycle/timeout-wrapper.d.ts +2 -2
  85. package/dist/src/agent/lifecycle/timeout-wrapper.js +4 -4
  86. package/dist/src/agent/lifecycle/timeout-wrapper.js.map +1 -1
  87. package/dist/src/agent/memory/summary-generator.d.ts +1 -1
  88. package/dist/src/agent/memory/summary-generator.js +1 -2
  89. package/dist/src/agent/memory/summary-generator.js.map +1 -1
  90. package/dist/src/agent/middleware/index.d.ts +1 -1
  91. package/dist/src/agent/middleware/self-verify.d.ts +44 -14
  92. package/dist/src/agent/middleware/self-verify.js +214 -44
  93. package/dist/src/agent/middleware/self-verify.js.map +1 -1
  94. package/dist/src/agent/orchestration/agent-event-handler.js +57 -15
  95. package/dist/src/agent/orchestration/agent-event-handler.js.map +1 -1
  96. package/dist/src/agent/prompt/sections/tooling.js +18 -13
  97. package/dist/src/agent/prompt/sections/tooling.js.map +1 -1
  98. package/dist/src/agent/prompt/system-reminder.js +2 -2
  99. package/dist/src/agent/prompt/system-reminder.js.map +1 -1
  100. package/dist/src/agent/sandbox/sanitize-env-vars.d.ts +2 -2
  101. package/dist/src/agent/sandbox/sanitize-env-vars.js +2 -2
  102. package/dist/src/agent/sandbox/sanitize-env-vars.js.map +1 -1
  103. package/dist/src/agent/sandbox/types.d.ts +2 -2
  104. package/dist/src/agent/sandbox/types.js.map +1 -1
  105. package/dist/src/agent/service/btw-query.js +1 -1
  106. package/dist/src/agent/service/btw-query.js.map +1 -1
  107. package/dist/src/agent/service/process-direct-one-shot.js +6 -2
  108. package/dist/src/agent/service/process-direct-one-shot.js.map +1 -1
  109. package/dist/src/agent/service/process-direct-streaming.js +12 -7
  110. package/dist/src/agent/service/process-direct-streaming.js.map +1 -1
  111. package/dist/src/agent/service.js +2 -1
  112. package/dist/src/agent/service.js.map +1 -1
  113. package/dist/src/agent/skills/skill-tool-gating.js +1 -1
  114. package/dist/src/agent/skills/skill-tool-gating.js.map +1 -1
  115. package/dist/src/agent/starter-agents.js +9 -9
  116. package/dist/src/agent/starter-agents.js.map +1 -1
  117. package/dist/src/agent/tools/apply-patch.d.ts +25 -0
  118. package/dist/src/agent/tools/apply-patch.js +256 -0
  119. package/dist/src/agent/tools/apply-patch.js.map +1 -0
  120. package/dist/src/agent/tools/delegate-tool.d.ts +1 -1
  121. package/dist/src/agent/tools/delegate-tool.js +3 -3
  122. package/dist/src/agent/tools/delegate-tool.js.map +1 -1
  123. package/dist/src/agent/tools/exec-command.d.ts +30 -0
  124. package/dist/src/agent/tools/exec-command.js +224 -0
  125. package/dist/src/agent/tools/exec-command.js.map +1 -0
  126. package/dist/src/agent/tools/execute-code-tool.js +7 -4
  127. package/dist/src/agent/tools/execute-code-tool.js.map +1 -1
  128. package/dist/src/agent/tools/factory.d.ts +3 -3
  129. package/dist/src/agent/tools/factory.js +7 -8
  130. package/dist/src/agent/tools/factory.js.map +1 -1
  131. package/dist/src/agent/tools/index.d.ts +3 -2
  132. package/dist/src/agent/tools/index.js +5 -4
  133. package/dist/src/agent/tools/skills-tools.d.ts +1 -1
  134. package/dist/src/agent/tools/skills-tools.js.map +1 -1
  135. package/dist/src/agent/tools/update-plan-tool.d.ts +11 -0
  136. package/dist/src/agent/tools/update-plan-tool.js +72 -0
  137. package/dist/src/agent/tools/update-plan-tool.js.map +1 -0
  138. package/dist/src/agent/workflow/builtins/debug-incident.d.ts +1 -1
  139. package/dist/src/agent/workflow/builtins/debug-incident.js +1 -1
  140. package/dist/src/agent/workflow/builtins/debug-incident.js.map +1 -1
  141. package/dist/src/agent/workflow/builtins/pr-review.d.ts +1 -1
  142. package/dist/src/agent/workflow/builtins/pr-review.js +1 -1
  143. package/dist/src/agent/workflow/builtins/pr-review.js.map +1 -1
  144. package/dist/src/agent/workflow/builtins/release-check.d.ts +1 -1
  145. package/dist/src/agent/workflow/builtins/release-check.js +1 -1
  146. package/dist/src/agent/workflow/builtins/release-check.js.map +1 -1
  147. package/dist/src/agent/workflow/step-labels.js +7 -3
  148. package/dist/src/agent/workflow/step-labels.js.map +1 -1
  149. package/dist/src/chat-commands/agent-edit.js +1 -1
  150. package/dist/src/chat-commands/agent-edit.js.map +1 -1
  151. package/dist/src/chat-commands/builtins/review.d.ts +1 -0
  152. package/dist/src/chat-commands/builtins/review.js +167 -0
  153. package/dist/src/chat-commands/builtins/review.js.map +1 -0
  154. package/dist/src/chat-commands/index.d.ts +1 -0
  155. package/dist/src/chat-commands/index.js +3 -1
  156. package/dist/src/chat-commands/index.js.map +1 -1
  157. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  158. package/dist/src/cli/commands/gateway/lifecycle.js +1 -1
  159. package/dist/src/gateway/agent-builtin-tools.d.ts +1 -1
  160. package/dist/src/gateway/agent-builtin-tools.js +3 -2
  161. package/dist/src/gateway/agent-builtin-tools.js.map +1 -1
  162. package/dist/src/gateway/chat-stream/mapper.d.ts +6 -0
  163. package/dist/src/gateway/chat-stream/mapper.js +149 -6
  164. package/dist/src/gateway/chat-stream/mapper.js.map +1 -1
  165. package/dist/src/gateway/chat-stream/protocol.d.ts +51 -1
  166. package/dist/src/gateway/hono/routes/commands-skills.js +21 -0
  167. package/dist/src/gateway/hono/routes/commands-skills.js.map +1 -1
  168. package/dist/src/gateway/hono/routes/index.js +2 -0
  169. package/dist/src/gateway/hono/routes/index.js.map +1 -1
  170. package/dist/src/gateway/hono/routes/lazy-bundles.js +1 -0
  171. package/dist/src/gateway/hono/routes/lazy-bundles.js.map +1 -1
  172. package/dist/src/gateway/hono/routes/projects.js +40 -2
  173. package/dist/src/gateway/hono/routes/projects.js.map +1 -1
  174. package/dist/src/gateway/hono/routes/search.d.ts +3 -0
  175. package/dist/src/gateway/hono/routes/search.js +47 -0
  176. package/dist/src/gateway/hono/routes/search.js.map +1 -0
  177. package/dist/src/gateway/security/dangerous-tools.js +1 -1
  178. package/dist/src/gateway/security/dangerous-tools.js.map +1 -1
  179. package/dist/src/infra/update-restart.js +1 -1
  180. package/dist/src/mcp/channel-bridge.js +1 -1
  181. package/dist/src/projects/index.d.ts +2 -0
  182. package/dist/src/projects/index.js +3 -1
  183. package/dist/src/projects/project-agent-suggestion.d.ts +14 -0
  184. package/dist/src/projects/project-agent-suggestion.js +19 -0
  185. package/dist/src/projects/project-agent-suggestion.js.map +1 -0
  186. package/dist/src/projects/project-kind.d.ts +13 -0
  187. package/dist/src/projects/project-kind.js +147 -0
  188. package/dist/src/projects/project-kind.js.map +1 -0
  189. package/dist/src/projects/project-service.d.ts +1 -0
  190. package/dist/src/projects/project-service.js +1 -1
  191. package/dist/src/projects/project-service.js.map +1 -1
  192. package/dist/src/projects/project-store.js +32 -8
  193. package/dist/src/projects/project-store.js.map +1 -1
  194. package/dist/src/projects/types.d.ts +1 -0
  195. package/dist/src/review/review-git.d.ts +48 -0
  196. package/dist/src/review/review-git.js +333 -0
  197. package/dist/src/review/review-git.js.map +1 -0
  198. package/dist/src/review/review-types.d.ts +22 -0
  199. package/dist/src/review/review-types.js +29 -0
  200. package/dist/src/review/review-types.js.map +1 -0
  201. package/dist/src/session/session-context-for-llm.js +151 -0
  202. package/dist/src/session/session-context-for-llm.js.map +1 -1
  203. package/dist/src/storage/sqlite/migrations/021_projects_fts.sql +21 -0
  204. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  205. package/dist/src/storage/sqlite/migrations/runner.js +3 -3
  206. package/dist/src/storage/sqlite/migrations/runner.js.map +1 -1
  207. package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
  208. package/dist/src/storage/sqlite/schema.js +1 -1
  209. package/dist/src/tui/backends/embedded-backend.d.ts +1 -0
  210. package/dist/src/tui/backends/embedded-backend.js +20 -0
  211. package/dist/src/tui/backends/embedded-backend.js.map +1 -1
  212. package/dist/src/tui/backends/gateway-sse-backend.d.ts +2 -0
  213. package/dist/src/tui/backends/gateway-sse-backend.js +7 -0
  214. package/dist/src/tui/backends/gateway-sse-backend.js.map +1 -1
  215. package/dist/src/tui/components/assistant-message.js +35 -0
  216. package/dist/src/tui/components/assistant-message.js.map +1 -1
  217. package/dist/src/tui/tui-agent-events.js +25 -0
  218. package/dist/src/tui/tui-agent-events.js.map +1 -1
  219. package/dist/src/tui/tui-backend.d.ts +4 -0
  220. package/dist/src/tui/tui-commands.d.ts +1 -0
  221. package/dist/src/tui/tui-commands.js +110 -4
  222. package/dist/src/tui/tui-commands.js.map +1 -1
  223. package/dist/src/tui/tui-picker-overlay.d.ts +2 -0
  224. package/dist/src/tui/tui-picker-overlay.js +153 -1
  225. package/dist/src/tui/tui-picker-overlay.js.map +1 -1
  226. package/dist/src/tui/tui.js +16 -3
  227. package/dist/src/tui/tui.js.map +1 -1
  228. package/package.json +1 -1
  229. package/dist/gateway/static/root/assets/agents-CxDSFHGx.js +0 -2
  230. package/dist/gateway/static/root/assets/apps-page-CyZdgqvm.js +0 -1
  231. package/dist/gateway/static/root/assets/automations-page-8VLKM4au.js +0 -1
  232. package/dist/gateway/static/root/assets/browser-settings-page-5tPg0DcP.js +0 -8
  233. package/dist/gateway/static/root/assets/capability-presets-settings-panel-BJW3aVST.js +0 -1
  234. package/dist/gateway/static/root/assets/channels-settings-CorUCTrs.js +0 -1
  235. package/dist/gateway/static/root/assets/connectors-page-VKstC3sP.js +0 -2
  236. package/dist/gateway/static/root/assets/gateway-settings-hQtgVmSR.js +0 -1
  237. package/dist/gateway/static/root/assets/goal-detail-page-FEypCq74.js +0 -1
  238. package/dist/gateway/static/root/assets/goals-page-C4-2_MLG.js +0 -2
  239. package/dist/gateway/static/root/assets/heartbeat-settings-BJVok3Sl.js +0 -1
  240. package/dist/gateway/static/root/assets/index-T0SaNd5a.js +0 -191
  241. package/dist/gateway/static/root/assets/logs-page-DwkwPgid.js +0 -2
  242. package/dist/gateway/static/root/assets/messages-avfvyZuQ.js +0 -3
  243. package/dist/gateway/static/root/assets/models-hub-panel-huNY4A1G.js +0 -2
  244. package/dist/gateway/static/root/assets/notes-page-DdfGuEZ1.js +0 -1
  245. package/dist/gateway/static/root/assets/notes-workbench-B0bT9Hqa.js +0 -2
  246. package/dist/gateway/static/root/assets/project-detail-page-CjxhPorG.js +0 -1
  247. package/dist/gateway/static/root/assets/projects-page-C4Z5OJMF.js +0 -1
  248. package/dist/gateway/static/root/assets/remote-access-hub-CVCOPUVd.js +0 -1
  249. package/dist/gateway/static/root/assets/sessions-page-B4qExXHC.js +0 -1
  250. package/dist/gateway/static/root/assets/settings-advanced-gate-Ce8yLTBi.js +0 -1
  251. package/dist/gateway/static/root/assets/settings-page-C4fivemT.js +0 -1
  252. package/dist/gateway/static/root/assets/setup-status-panel-Kyc4eUf0.js +0 -1
  253. package/dist/gateway/static/root/assets/shares-settings-Bu76CMiC.js +0 -1
  254. package/dist/gateway/static/root/assets/skill-reload-api-D-CFg86j.js +0 -1
  255. package/dist/gateway/static/root/assets/skills-page-CUU4f6Ss.js +0 -2
  256. package/dist/gateway/static/root/assets/voice-api-key-field-C1MrQD8R.js +0 -1
  257. package/dist/gateway/static/root/assets/workflow-run-setup-panel-DqizIcY5.js +0 -3
  258. package/dist/gateway/static/root/assets/workflows-page-B3sVNPFk.js +0 -18
  259. package/dist/src/agent/tools/edit.d.ts +0 -14
  260. package/dist/src/agent/tools/edit.js +0 -132
  261. package/dist/src/agent/tools/edit.js.map +0 -1
  262. package/dist/src/agent/tools/shell.d.ts +0 -15
  263. package/dist/src/agent/tools/shell.js +0 -158
  264. package/dist/src/agent/tools/shell.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{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-O6TAtdFC.js";import{n as o}from"./locale-store-Ba72bFmP.js";import{c as s,i as c,n as l}from"./fetch-BU5S0Sn7.js";import{r as u}from"./toast-z0toXu32.js";import{Aa as d,Ba as f,Co as p,Fa as m,Fo as h,Gs as g,H as _,Io as v,Ko as y,Ls as b,Ma as x,Mi as S,Ni as C,Ro as w,Ua as T,Va as E,Vo as D,Wa as O,Wr as k,_a as A,_o as j,aa as M,ba as N,ca as ee,eo as P,gs as F,hc as te,ia as I,js as ne,na as re,oa as L,ra as ie,rs as R,sa as z,ta as B,tc as ae,uc as V,xa as oe,ya as H,zc as se}from"./index-c_9TVr_C.js";import{n as ce,t as le}from"./settings-form-section-BnqYMWHR.js";import{i as ue,n as de,o as fe,r as pe,t as me}from"./dist-wO9a2_ID.js";var U=e(t(),1),W=n(),G=r(),K=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`,he=[`c0`,`c1`,`c2`,`c3`,`c4`,`c5`];function ge(e,t){return t.some(t=>t.connectorId===e.id)}function q(e,t){return t[e]??e}function J(e,t){return t.connectorCategoryTemplate.replace(`{{category}}`,q(e,t.connectorCategoryLabels))}function _e(){let e=(0,W.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,G.jsx)(`div`,{className:`flex h-full min-h-[9.5rem] flex-col rounded-xl border border-edge-subtle bg-surface-base p-4 dark:border-edge-subtle`,"aria-hidden":!0,children:(0,G.jsx)(`div`,{className:`flex min-h-0 flex-1 items-start gap-3`,children:(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,G.jsx)(`div`,{className:i(`h-4 min-w-0 flex-1`,K)}),(0,G.jsx)(`div`,{className:i(`h-8 w-[4.5rem] shrink-0 rounded-lg`,K)})]}),(0,G.jsx)(`div`,{className:i(`h-3 w-full`,K)}),(0,G.jsx)(`div`,{className:i(`h-3 w-[88%]`,K)})]})})}),e[0]=t):t=e[0],t}function ve(){let e=(0,W.c)(3),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,G.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2`,children:[(0,G.jsx)(`div`,{className:i(`h-4 w-48 max-w-full`,K)}),(0,G.jsx)(`div`,{className:i(`h-3 w-72 max-w-full`,K)})]}),e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,G.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[t,(0,G.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,G.jsx)(`div`,{className:i(`h-9 w-20 rounded-lg`,K)}),(0,G.jsx)(`div`,{className:i(`h-9 w-20 rounded-lg`,K)})]})]}),e[1]=n):n=e[1];let r;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,G.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-panel p-4 shadow-surface`,"aria-hidden":!0,children:[n,(0,G.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,G.jsx)(`div`,{className:i(`h-8 w-20 rounded-md`,K)}),(0,G.jsx)(`div`,{className:i(`h-8 w-24 rounded-md`,K)}),(0,G.jsx)(`div`,{className:i(`h-8 w-28 rounded-md`,K)})]}),(0,G.jsx)(`div`,{className:i(`mt-3 h-20 rounded-xl`,K)})]}),e[2]=r):r=e[2],r}function ye(e){let t=(0,W.c)(52),{connector:n,installed:r,onInstall:a,t:o}=e,s;t[0]!==n.category||t[1]!==o?(s=J(n.category,o),t[0]=n.category,t[1]=o,t[2]=s):s=t[2];let c=s,l,u,d,f,p,m;if(t[3]!==c||t[4]!==n||t[5]!==r||t[6]!==a||t[7]!==o.install||t[8]!==o.installedBadge){let e=n.capabilities.slice(0,4),s=Math.max(0,n.capabilities.length-e.length),h;t[15]!==n||t[16]!==a||t[17]!==o.install?(h=e=>(0,G.jsxs)(E,{type:`button`,variant:`primary`,className:i(`h-8 justify-center px-2.5 text-xs font-medium`,e),onClick:()=>a(n),children:[(0,G.jsx)(y,{className:`size-4`}),o.install]}),t[15]=n,t[16]=a,t[17]=o.install,t[18]=h):h=t[18],l=h,m=`group flex min-h-[9.5rem] flex-col rounded-lg border border-edge bg-surface-panel p-4 shadow-surface transition-colors hover:border-accent/50 focus-within:border-accent/50`,u=`flex min-w-0 flex-1 flex-col`;let g;t[19]===n.displayName?g=t[20]:(g=(0,G.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:n.displayName}),t[19]=n.displayName,t[20]=g);let _;t[21]===c?_=t[22]:(_=(0,G.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-subtle`,children:c}),t[21]=c,t[22]=_);let v;t[23]!==g||t[24]!==_?(v=(0,G.jsx)(`div`,{className:`flex min-w-0 items-start gap-3`,children:(0,G.jsxs)(`div`,{className:`min-w-0`,children:[g,_]})}),t[23]=g,t[24]=_,t[25]=v):v=t[25];let b;t[26]!==r||t[27]!==l?(b=r?null:(0,G.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:l()}),t[26]=r,t[27]=l,t[28]=b):b=t[28];let x;t[29]!==r||t[30]!==o.installedBadge?(x=r?(0,G.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,G.jsx)(V,{className:`size-3`,"aria-hidden":!0}),o.installedBadge]}):null,t[29]=r,t[30]=o.installedBadge,t[31]=x):x=t[31];let S;t[32]!==b||t[33]!==x?(S=(0,G.jsxs)(`div`,{className:`flex shrink-0 items-start gap-2`,children:[b,x]}),t[32]=b,t[33]=x,t[34]=S):S=t[34],t[35]!==v||t[36]!==S?(d=(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[v,S]}),t[35]=v,t[36]=S,t[37]=d):d=t[37],t[38]===n.description?f=t[39]:(f=(0,G.jsx)(`p`,{className:`mt-4 line-clamp-2 text-sm leading-6 text-fg-muted`,title:n.description,children:n.description}),t[38]=n.description,t[39]=f),p=e.length>0?(0,G.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-1.5`,children:[e.map(be),s>0?(0,G.jsxs)(`span`,{className:`rounded-md border border-edge bg-surface-base px-2 py-0.5 text-[11px] text-fg-subtle`,children:[`+`,s]}):null]}):null,t[3]=c,t[4]=n,t[5]=r,t[6]=a,t[7]=o.install,t[8]=o.installedBadge,t[9]=l,t[10]=u,t[11]=d,t[12]=f,t[13]=p,t[14]=m}else l=t[9],u=t[10],d=t[11],f=t[12],p=t[13],m=t[14];let h;t[40]!==u||t[41]!==d||t[42]!==f||t[43]!==p?(h=(0,G.jsxs)(`div`,{className:u,children:[d,f,p]}),t[40]=u,t[41]=d,t[42]=f,t[43]=p,t[44]=h):h=t[44];let g;t[45]!==r||t[46]!==l?(g=r?null:(0,G.jsx)(`div`,{className:`mt-4 flex items-center justify-end border-t border-edge pt-3 sm:hidden`,children:l(`w-full`)}),t[45]=r,t[46]=l,t[47]=g):g=t[47];let _;return t[48]!==m||t[49]!==h||t[50]!==g?(_=(0,G.jsxs)(`div`,{className:m,children:[h,g]}),t[48]=m,t[49]=h,t[50]=g,t[51]=_):_=t[51],_}function be(e){return(0,G.jsx)(`span`,{className:`rounded-md border border-edge bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:e},e)}var xe=(0,U.memo)(function(e){let t=(0,W.c)(19),{loading:n,searchQuery:r,setSearchQuery:i,onReloadClick:a,onAddCustomServer:o,searchPlaceholder:s,addLabel:c,reloadLabel:l}=e,u;t[0]!==n||t[1]!==a||t[2]!==l?(u=(0,G.jsx)(k,{className:`size-9 shrink-0 p-0`,loading:n,label:l,title:l,onClick:a}),t[0]=n,t[1]=a,t[2]=l,t[3]=u):u=t[3];let d;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,G.jsx)(p,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-disabled`,strokeWidth:1.75,"aria-hidden":!0}),t[4]=d):d=t[4];let f;t[5]===i?f=t[6]:(f=e=>i(e.currentTarget.value),t[5]=i,t[6]=f);let m;t[7]!==s||t[8]!==r||t[9]!==f?(m=(0,G.jsxs)(`label`,{className:`relative flex min-h-9 min-w-0 max-w-sm cursor-text items-center rounded-pill border border-edge bg-surface-base py-1.5 pl-9 pr-3 shadow-surface dark:bg-surface-hover/40 sm:max-w-md`,children:[d,(0,G.jsx)(`input`,{type:`search`,enterKeyHint:`search`,value:r,onChange:f,placeholder:s,autoComplete:`off`,spellCheck:!1,className:`min-w-0 flex-1 appearance-none border-0 bg-transparent py-0.5 text-sm leading-normal text-fg caret-current placeholder:text-fg-disabled focus:border-0 focus:shadow-none focus:outline-none focus:ring-0 focus-visible:outline-none`})]}),t[7]=s,t[8]=r,t[9]=f,t[10]=m):m=t[10];let g;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,G.jsx)(h,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[11]=g):g=t[11];let _;t[12]!==c||t[13]!==o?(_=(0,G.jsxs)(E,{type:`button`,variant:`primary`,className:`shrink-0 gap-2`,onClick:o,children:[g,c]}),t[12]=c,t[13]=o,t[14]=_):_=t[14];let v;return t[15]!==u||t[16]!==m||t[17]!==_?(v=(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center justify-end gap-2`,children:[u,m,_]}),t[15]=u,t[16]=m,t[17]=_,t[18]=v):v=t[18],v}),Se=/^([^:=]+)[:=](.*)$/;function Y(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=Se.exec(t);r&&n.push({key:r[1].trim(),value:r[2].trim()})}return n.length>0?n:null}function Ce(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 we(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 Te(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 Ee(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)||Te(t)&&(r[e]=t);return r}function De(e){let t=e.trim();if(t)return t.split(/\s+/).filter(Boolean)}function Oe(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 ke(e){if(e.transport===`stdio`){let t={command:e.command.trim()},n=De(e.argsText);return n?.length&&(t.args=n),e.cwd.trim()&&(t.cwd=e.cwd.trim()),e.envJson.trim()&&(t.env=Oe(e.envJson)),e.connectionTimeoutMs!=null&&Number.isFinite(e.connectionTimeoutMs)&&(t.connectionTimeoutMs=e.connectionTimeoutMs),t}let t={url:e.url.trim(),transport:e.transport},n=Ce(e.headers);return n&&(t.headers=n),e.connectionTimeoutMs!=null&&Number.isFinite(e.connectionTimeoutMs)&&(t.connectionTimeoutMs=e.connectionTimeoutMs),t}function Ae(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:we(a),connectionTimeoutMs:typeof t.connectionTimeoutMs==`number`&&Number.isFinite(t.connectionTimeoutMs)?t.connectionTimeoutMs:void 0}}function je(e=``){return{clientKey:crypto.randomUUID(),id:e,transport:`stdio`,command:``,argsText:``,envJson:``,cwd:``,url:``,headers:[{key:`Authorization`,value:``}],connectionTimeoutMs:void 0}}function Me(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)||Te(t)?[]:[Ae(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 Ne(e){return ke(e)}async function Pe(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]=ke(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 l(c(`/api/config`),{method:`PATCH`,body:JSON.stringify({mcp:r})}),S()}function Fe(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 Ie(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 Le(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 Re(e,t){let n=await l(c(`/api/mcp/servers/${encodeURIComponent(e)}/test`),{method:`POST`,body:t?JSON.stringify({server:t}):void 0});if(!n.payload)throw Error(n.error??`MCP test failed`);let r=Fe(n.payload.tools),i=Ie(n.payload.resources),a=Le(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 ze(e){return e.connectionTimeoutMs==null||!Number.isFinite(e.connectionTimeoutMs)?``:String(Math.round(e.connectionTimeoutMs/1e3))}function Be(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 Ve(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 X(e,t){return Object.entries(t).reduce((e,[t,n])=>e.replaceAll(`{{${t}}}`,n),e)}function He({row:e,t,cs:n,onEdit:r,onRemove:i}){let[a,o]=(0,U.useState)(!1),[s,c]=(0,U.useState)(!1),[l,u]=(0,U.useState)(null),[d,f]=(0,U.useState)(null),p=Ve(e),m=(0,U.useCallback)(async()=>{o(!0),f(null);try{let t=await Re(e.id.trim());u({toolCount:t.toolCount,resourceCount:t.resourceCount,promptCount:t.promptCount})}catch(e){f(e instanceof Error?e.message:String(e))}finally{o(!1)}},[e.id]),h=(0,U.useCallback)(async()=>{c(!0),f(null);try{await i()}catch(e){f(e instanceof Error?e.message:String(e)),c(!1)}},[i]);return(0,G.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-panel p-4 shadow-surface`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:e.id.trim()||t.cardUntitled}),(0,G.jsx)(`span`,{className:`rounded-full border border-edge bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:n.customBadge}),(0,G.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,G.jsx)(`p`,{className:`mt-1 truncate font-mono text-xs text-fg-subtle`,title:p,children:p}):null]}),(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[(0,G.jsxs)(E,{variant:`secondary`,disabled:a,onClick:()=>void m(),children:[a?(0,G.jsx)(R,{className:`size-4 animate-spin`}):(0,G.jsx)(w,{className:`size-4`}),t.testConnection]}),(0,G.jsxs)(E,{variant:`secondary`,onClick:r,children:[(0,G.jsx)(D,{className:`size-4`}),n.editCustomServer]}),(0,G.jsxs)(E,{variant:`ghost`,disabled:s,onClick:()=>void h(),children:[s?(0,G.jsx)(R,{className:`size-4 animate-spin`}):(0,G.jsx)(P,{className:`size-4`}),t.removeServer]})]})]}),d?(0,G.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,G.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:X(n.customCapabilitySummary,{tools:String(l.toolCount),resources:String(l.resourceCount),prompts:String(l.promptCount)})}):null]})}function Z(e,t){if(!e.payload)throw Error(e.error??t);return e.payload}async function Ue(){return Z(await l(c(`/api/connectors/catalog`)),`Could not load connector catalog.`).connectors}async function We(){return Z(await l(c(`/api/connectors/catalog`)),`Could not load connector registries.`).registries??[]}async function Ge(){return Z(await l(c(`/api/connectors/installed`)),`Could not load installed connectors.`).instances}var Ke=new Map,qe=300*1e3;async function Je(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),u=`${i}:${r}:${a?`browse`:`search`}:${o}:${s}`,d=Date.now(),f=Ke.get(u);if(f&&f.expiresAt>d)return f.promise;let p=new URLSearchParams;r&&p.set(`q`,r),i!==`all`&&p.set(`source`,i),a&&p.set(`browse`,`1`),p.set(`page`,String(o)),p.set(`pageSize`,String(s));let m=l(c(`/api/connectors/registry/search?${p.toString()}`)).then(e=>{let t=Z(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}});Ke.set(u,{expiresAt:d+qe,promise:m});try{return await m}catch(e){throw Ke.delete(u),e}}async function Ye(e){return Z(await l(c(`/api/connectors/${encodeURIComponent(e)}/oauth/start`),{method:`POST`}),`Could not start connector OAuth.`).oauth}async function Xe(e,t){return Z(await l(c(`/api/connectors/${encodeURIComponent(e)}/oauth/complete`),{method:`POST`,body:JSON.stringify({deviceCode:t})}),`Could not complete connector OAuth.`).oauth}async function Ze(e,t){let n=await l(c(`/api/connectors/${encodeURIComponent(e)}/install`),{method:`POST`,body:JSON.stringify(t)});return S(),Z(n,`Could not install connector.`).instance}async function Qe(e){await l(c(`/api/connectors/${encodeURIComponent(e)}`),{method:`DELETE`}),S()}async function $e(e){return Z(await l(c(`/api/connectors/${encodeURIComponent(e)}/test`),{method:`POST`}),`Connector test failed.`)}async function et(){return Z(await l(c(`/api/connectors/composio/connections`)),`Could not load Composio connections.`).connections}async function tt(e){return Z(await l(c(`/api/connectors/composio/${encodeURIComponent(e)}/authorize`),{method:`POST`}),`Could not start Composio authorization.`).oauth}async function nt(e){return Z(await l(c(`/api/connectors/composio/${encodeURIComponent(e)}/scope`)),`Could not load Composio scope.`).scope}async function rt(e,t){let n=await l(c(`/api/connectors/composio/${encodeURIComponent(e)}/scope`),{method:`POST`,body:JSON.stringify({scope:t})});return S(),Z(n,`Could not update Composio scope.`).scope}async function it(e){return Z(await l(c(`/api/connectors/composio/${encodeURIComponent(e)}/tools`)),`Could not load Composio tools.`).tools}async function at(e=50){return Z(await l(c(`/api/connectors/composio/triggers?limit=${encodeURIComponent(String(e))}`)),`Could not load Composio trigger events.`).events}function ot(e,t){return e?t&&e.startsWith(t)?e.slice(t.length):e:``}function st(e,t,n){let r=t.trim().toLowerCase();if(!r)return!0;let i=e.shortName||ot(e.name,n);return[e.name,i,e.description].filter(Boolean).join(`
2
+ `).toLowerCase().includes(r)}function ct(e,t){return e?t&&e.startsWith(t)?e.slice(t.length):e:``}function lt(e){let t=(0,W.c)(29),{tools:n,stripPrefix:r,searchPlaceholder:a,searchEmptyLabel:o}=e,[s,c]=(0,U.useState)(``),l;if(t[0]!==s||t[1]!==r||t[2]!==n){let e;t[4]!==s||t[5]!==r?(e=e=>st(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 m=d.length>0,h;t[9]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,G.jsx)(p,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-subtle`,"aria-hidden":!0}),t[9]=h):h=t[9];let g,_;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(g=i(`w-full rounded-lg border border-edge bg-surface-panel py-2 pl-9 pr-3 text-sm text-fg`,`placeholder:text-fg-subtle`,f),_=e=>c(e.target.value),t[10]=g,t[11]=_):(g=t[10],_=t[11]);let v;t[12]!==s||t[13]!==a?(v=(0,G.jsxs)(`div`,{className:`relative`,children:[h,(0,G.jsx)(`input`,{type:`search`,value:s,placeholder:a,"aria-label":a,className:g,onChange:_})]}),t[12]=s,t[13]=a,t[14]=v):v=t[14];let y;t[15]!==u.length||t[16]!==m||t[17]!==n.length?(y=m?(0,G.jsxs)(`p`,{className:`mt-2 text-xs text-fg-subtle`,children:[u.length,` / `,n.length]}):null,t[15]=u.length,t[16]=m,t[17]=n.length,t[18]=y):y=t[18];let b;t[19]!==v||t[20]!==y?(b=(0,G.jsxs)(`div`,{className:`border-b border-edge px-5 py-3`,children:[v,y]}),t[19]=v,t[20]=y,t[21]=b):b=t[21];let x;t[22]!==u||t[23]!==o||t[24]!==r?(x=(0,G.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:u.length===0?(0,G.jsx)(`p`,{className:`text-sm text-fg-muted`,children:o}):(0,G.jsx)(`ul`,{className:`flex flex-col gap-2`,children:u.map((e,t)=>{let n=e.shortName||ct(e.name,r)||e.name||`?`,i=e.name||`tool-${t}`;return(0,G.jsxs)(`li`,{className:`min-w-0 rounded-lg border border-edge bg-surface-base px-3 py-2.5`,children:[(0,G.jsx)(`div`,{className:`truncate font-mono text-sm font-medium text-fg`,title:e.name===n?n:e.name,children:n}),e.description?(0,G.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]=x):x=t[25];let S;return t[26]!==b||t[27]!==x?(S=(0,G.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[b,x]}),t[26]=b,t[27]=x,t[28]=S):S=t[28],S}function ut(e){let t=(0,W.c)(38),{open:n,onOpenChange:r,serverId:a,title:o,subtitle:s,searchPlaceholder:c,searchEmptyLabel:l,emptyLabel:u,closeLabel:d,tools:f,stripPrefix:p}=e,m;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(m=(0,G.jsx)(I,{className:i(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,oe)}),t[0]=m):m=t[0];let h;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(h=i(`fixed left-1/2 top-1/2 flex max-h-[min(88vh,40rem)] w-[min(100%-2rem,min(92vw,36rem))] -translate-x-1/2 -translate-y-1/2 flex-col`,N,`rounded-2xl border border-edge bg-surface-panel shadow-popover outline-none dark:border-edge`),t[1]=h):h=t[1];let g;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,G.jsx)(O,{className:`size-4 shrink-0 text-accent`,"aria-hidden":!0}),t[2]=g):g=t[2];let _;t[3]===o?_=t[4]:(_=(0,G.jsxs)(z,{className:`flex items-center gap-2 text-base font-semibold text-fg`,children:[g,o]}),t[3]=o,t[4]=_);let v;t[5]!==a||t[6]!==s||t[7]!==f.length?(v=s.replace(`{{serverId}}`,a).replace(`{{count}}`,String(f.length)),t[5]=a,t[6]=s,t[7]=f.length,t[8]=v):v=t[8];let y;t[9]===v?y=t[10]:(y=(0,G.jsx)(ie,{className:`mt-1 text-sm text-fg-muted`,children:v}),t[9]=v,t[10]=y);let b;t[11]!==_||t[12]!==y?(b=(0,G.jsxs)(`div`,{className:`min-w-0`,children:[_,y]}),t[11]=_,t[12]=y,t[13]=b):b=t[13];let x;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,G.jsx)(T,{className:`size-4`,"aria-hidden":!0}),t[14]=x):x=t[14];let S;t[15]===d?S=t[16]:(S=(0,G.jsx)(B,{asChild:!0,children:(0,G.jsx)(E,{type:`button`,variant:`ghost`,className:`size-8 shrink-0 px-0`,"aria-label":d,children:x})}),t[15]=d,t[16]=S);let C;t[17]!==b||t[18]!==S?(C=(0,G.jsxs)(`div`,{className:`flex items-start justify-between gap-3 border-b border-edge px-5 py-4`,children:[b,S]}),t[17]=b,t[18]=S,t[19]=C):C=t[19];let w;t[20]!==u||t[21]!==n||t[22]!==l||t[23]!==c||t[24]!==a||t[25]!==p||t[26]!==f?(w=f.length>0?(0,G.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,G.jsx)(lt,{tools:f,stripPrefix:p,searchPlaceholder:c,searchEmptyLabel:l},`${a}-${n?`open`:`closed`}`)}):(0,G.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-5 py-4`,children:(0,G.jsx)(`p`,{className:`text-sm text-fg-muted`,children:u})}),t[20]=u,t[21]=n,t[22]=l,t[23]=c,t[24]=a,t[25]=p,t[26]=f,t[27]=w):w=t[27];let D;t[28]===d?D=t[29]:(D=(0,G.jsx)(`div`,{className:`flex justify-end border-t border-edge px-5 py-3`,children:(0,G.jsx)(B,{asChild:!0,children:(0,G.jsx)(E,{type:`button`,variant:`secondary`,children:d})})}),t[28]=d,t[29]=D);let k;t[30]!==C||t[31]!==w||t[32]!==D?(k=(0,G.jsxs)(M,{children:[m,(0,G.jsxs)(re,{className:h,children:[C,w,D]})]}),t[30]=C,t[31]=w,t[32]=D,t[33]=k):k=t[33];let A;return t[34]!==r||t[35]!==n||t[36]!==k?(A=(0,G.jsx)(L,{open:n,onOpenChange:r,children:k}),t[34]=r,t[35]=n,t[36]=k,t[37]=A):A=t[37],A}var dt=i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,f);function ft(e){return e.materialized.type===`composio`?e.connectorId.replace(/^composio-/,``):null}function pt(e,t){return e===`write`?t.composioScopeWrite:e===`admin`?t.composioScopeAdmin:t.composioScopeRead}function mt({instance:e,t}){let n=ft(e),[r,a]=(0,U.useState)([]),[o,s]=(0,U.useState)([]),[c,l]=(0,U.useState)([]),[u,d]=(0,U.useState)(`read`),[f,p]=(0,U.useState)(!1),[m,h]=(0,U.useState)(null),g=(0,U.useCallback)(async()=>{if(!(!n||n===`api-key`)){p(!0),h(null);try{let[e,t,r,i]=await Promise.all([et().catch(()=>[]),it(n).catch(()=>[]),at(20).catch(()=>[]),nt(n).catch(()=>`read`)]);a(e.filter(e=>e.toolkit.toLowerCase()===n.toLowerCase())),s(t),l(r.filter(e=>!e.toolkit||e.toolkit.toLowerCase()===n.toLowerCase())),d(i)}catch(e){h(e instanceof Error?e.message:String(e))}finally{p(!1)}}},[n]);(0,U.useEffect)(()=>{g()},[g]);let _=(0,U.useCallback)(async()=>{if(n){p(!0),h(null);try{let e=await tt(n);window.open(e.connectUrl,`_blank`,`noopener,noreferrer`)}catch(e){h(e instanceof Error?e.message:String(e))}finally{p(!1)}}},[n]),v=(0,U.useCallback)(async e=>{if(n){d(e);try{await rt(n,e),await g()}catch(e){h(e instanceof Error?e.message:String(e))}}},[g,n]);return n?n===`api-key`?(0,G.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:t.composioApiKeyStored}):(0,G.jsxs)(`div`,{className:`mt-4 rounded-xl border border-edge bg-surface-base p-3 text-sm`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`font-medium text-fg`,children:X(t.composioToolkitTitle,{toolkit:n})}),(0,G.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:t.composioScopeHint})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,G.jsxs)(A,{className:i(dt,`h-9 w-28 py-1`),value:u,onChange:e=>void v(e.currentTarget.value),children:[(0,G.jsx)(H,{value:`read`,children:t.composioScopeRead}),(0,G.jsx)(H,{value:`write`,children:t.composioScopeWrite}),(0,G.jsx)(H,{value:`admin`,children:t.composioScopeAdmin})]}),(0,G.jsxs)(E,{variant:`secondary`,disabled:f,onClick:()=>void _(),children:[f?(0,G.jsx)(R,{className:`size-4 animate-spin`}):(0,G.jsx)(F,{className:`size-4`}),t.connectOAuth]}),(0,G.jsx)(E,{variant:`ghost`,disabled:f,onClick:()=>void g(),children:t.refresh})]})]}),m?(0,G.jsx)(`p`,{className:`mt-3 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:m}):null,(0,G.jsxs)(`div`,{className:`mt-4 grid gap-3 lg:grid-cols-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioConnections}),r.length?r.map(e=>(0,G.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel p-2`,children:[(0,G.jsx)(`p`,{className:`truncate font-mono text-xs text-fg`,children:e.accountEmail??e.username??e.workspace??e.id}),(0,G.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.status})]},e.id)):(0,G.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioConnectionsEmpty})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioAgentTools}),o.length?o.slice(0,8).map(e=>(0,G.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel p-2`,children:[(0,G.jsx)(`p`,{className:`truncate font-mono text-xs text-fg`,children:e.slug}),(0,G.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[pt(e.scope,t),e.curated?``:` ${t.composioUncuratedSuffix}`]})]},e.slug)):(0,G.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioToolsEmpty})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioRecentTriggers}),c.length?c.slice(0,5).map(e=>(0,G.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel p-2`,children:[(0,G.jsx)(`p`,{className:`truncate text-xs text-fg`,children:e.trigger??e.id}),(0,G.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:new Date(e.at).toLocaleString()})]},`${e.id}-${e.at}`)):(0,G.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioTriggersEmpty})]})]})]}):null}function ht(e,t){return e?t.healthStatusLabels[e]??e:t.healthNotTested}function gt({instance:e,onChanged:t,t:n,mcp:r}){let[a,o]=(0,U.useState)(!1),[s,c]=(0,U.useState)(!1),[l,u]=(0,U.useState)(null),[d,f]=(0,U.useState)(`health`),[p,m]=(0,U.useState)(!1),[h,_]=(0,U.useState)(null),v=(0,U.useCallback)(async()=>{o(!0),_(null);try{let n=await $e(e.instanceId);u(n),n.toolCount>0&&f(`tools`),await t()}catch(e){_(e instanceof Error?e.message:String(e))}finally{o(!1)}},[e.instanceId,t]),y=(0,U.useCallback)(async()=>{c(!0),_(null);try{await Qe(e.instanceId),await t()}catch(e){_(e instanceof Error?e.message:String(e)),c(!1)}},[e.instanceId,t]),x=l?l.toolCount:e.usage.lastToolCount;return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-panel p-4 shadow-surface`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:e.displayName}),(0,G.jsx)(`span`,{className:`rounded-full border border-edge bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:n.catalogBadge})]}),(0,G.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.materialized.type===`mcp`?X(n.mcpServerRuntime,{serverId:e.materialized.serverId}):X(n.runtimeLabel,{runtime:e.materialized.type})})]}),(0,G.jsxs)(`div`,{className:`flex gap-2`,children:[e.materialized.type===`mcp`?(0,G.jsxs)(E,{variant:`secondary`,disabled:a,onClick:()=>void v(),children:[a?(0,G.jsx)(R,{className:`size-4 animate-spin`}):(0,G.jsx)(w,{className:`size-4`}),n.test]}):null,(0,G.jsxs)(E,{variant:`ghost`,disabled:s,onClick:()=>void y(),children:[s?(0,G.jsx)(R,{className:`size-4 animate-spin`}):(0,G.jsx)(P,{className:`size-4`}),n.remove]})]})]}),h?(0,G.jsx)(`p`,{className:`mt-3 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:h}):null,(0,G.jsx)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[[`health`,j,n.detailHealth],[`tools`,O,`${n.detailTools} ${l?l.toolCount:e.usage.lastToolCount??``}`],[`resources`,g,`${n.detailResources} ${l?l.resourceCount:e.usage.lastResourceCount??``}`],[`prompts`,b,`${n.detailPrompts} ${l?l.promptCount:e.usage.lastPromptCount??``}`],[`permissions`,F,n.detailPermissions]].map(([e,t,n])=>(0,G.jsxs)(`button`,{type:`button`,className:i(`inline-flex h-8 items-center gap-1.5 rounded-md border px-2.5 text-xs`,d===e?`border-accent bg-accent-soft text-accent-fg`:`border-edge bg-surface-base text-fg-muted hover:text-fg`),onClick:()=>f(e),children:[(0,G.jsx)(t,{className:`size-3.5`,"aria-hidden":!0}),n]},e))}),(0,G.jsxs)(`div`,{className:`mt-3 rounded-xl border border-edge bg-surface-base p-3 text-sm`,children:[d===`health`?(0,G.jsxs)(`div`,{className:`space-y-1 text-fg-muted`,children:[(0,G.jsxs)(`p`,{children:[n.statusLabel,` `,(0,G.jsx)(`span`,{className:l?.ok?`font-medium text-emerald-700 dark:text-emerald-300`:`font-medium text-fg`,children:ht(l?.status??e.usage.lastHealthStatus,n)})]}),(0,G.jsxs)(`p`,{children:[n.lastCheckLabel,` `,e.usage.lastHealthCheckAt?new Date(e.usage.lastHealthCheckAt).toLocaleString():n.never]}),l?.action?(0,G.jsx)(`p`,{children:l.action}):null]}):null,d===`tools`?l?.tools.length?(0,G.jsxs)(`div`,{className:`grid gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,G.jsx)(`p`,{className:`text-xs text-fg-muted`,children:X(n.toolsAvailable,{count:String(l.tools.length)})}),(0,G.jsx)(E,{type:`button`,variant:`ghost`,className:`h-7 text-xs`,onClick:()=>m(!0),children:r.viewAllTools})]}),l.tools.slice(0,8).map(e=>(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`p`,{className:`truncate font-mono text-xs text-fg`,children:e.shortName??e.name}),e.description?(0,G.jsx)(`p`,{className:`truncate text-xs text-fg-subtle`,children:e.description}):null]},e.name))]}):(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,G.jsx)(`p`,{className:`text-fg-muted`,children:x?X(n.toolsLastCheckSummary,{count:String(x)}):n.toolsRunTestHint}),(0,G.jsxs)(E,{type:`button`,variant:`secondary`,disabled:a,onClick:()=>void v(),children:[a?(0,G.jsx)(R,{className:`size-4 animate-spin`}):(0,G.jsx)(w,{className:`size-4`}),n.test]})]}):null,d===`resources`?l?.resources.length?(0,G.jsx)(`div`,{className:`grid gap-2`,children:l.resources.slice(0,8).map(e=>(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`p`,{className:`truncate font-mono text-xs text-fg`,children:e.title??e.name}),(0,G.jsx)(`p`,{className:`truncate text-xs text-fg-subtle`,children:e.uri})]},e.uri))}):(0,G.jsx)(`p`,{className:`text-fg-muted`,children:n.resourcesRunTestHint}):null,d===`prompts`?l?.prompts.length?(0,G.jsx)(`div`,{className:`grid gap-2`,children:l.prompts.slice(0,8).map(e=>(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`p`,{className:`truncate font-mono text-xs text-fg`,children:e.title??e.name}),e.description?(0,G.jsx)(`p`,{className:`truncate text-xs text-fg-subtle`,children:e.description}):null]},e.name))}):(0,G.jsx)(`p`,{className:`text-fg-muted`,children:n.promptsRunTestHint}):null,d===`permissions`?(0,G.jsxs)(`div`,{className:`space-y-1 text-fg-muted`,children:[(0,G.jsx)(`p`,{children:X(n.secretsConfigured,{count:String(Object.values(e.secretStatus).filter(Boolean).length)})}),(0,G.jsx)(`p`,{children:e.materialized.type===`mcp`?X(n.runtimeServerLabel,{runtime:e.materialized.type.toUpperCase(),serverId:e.materialized.serverId}):X(n.runtimeLabel,{runtime:e.materialized.type.toUpperCase()})}),(0,G.jsx)(`p`,{children:e.materialized.type===`mcp`?n.mcpPolicyHint:n.connectorPolicyHint})]}):null]}),e.materialized.type===`composio`?(0,G.jsx)(mt,{instance:e,t:n}):null]}),e.materialized.type===`mcp`?(0,G.jsx)(ut,{open:p,onOpenChange:m,serverId:e.materialized.serverId,title:X(n.installedToolsDialogTitle,{name:e.displayName}),subtitle:n.installedToolsDialogSubtitle,searchPlaceholder:r.toolsDialogSearchPlaceholder,searchEmptyLabel:r.toolsDialogSearchEmpty,emptyLabel:n.toolsRunTestHint,closeLabel:r.toolsDialogClose,tools:l?.tools??[],stripPrefix:`${e.materialized.serverId}__`}):null]})}var _t=i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,f),vt=i(_t,`min-h-28 font-mono`);function yt(e,t){return e?t.healthStatusLabels[e]??e:t.healthStatusPending}function bt(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 xt(e){let t={};for(let n of e.setup.secrets??[])t[n.key]=``;let n={};for(let t of e.setup.config??[])n[t.key]=t.defaultValue===void 0?``:typeof t.defaultValue==`string`?t.defaultValue:JSON.stringify(t.defaultValue,null,2);return{connector:e,secrets:t,config:n,installing:!1,error:null,result:null,health:null,oauth:{flow:null,connected:e.auth.mode!==`oauth`}}}function St({draft:e,onChange:t,onClose:n,onInstalled:r,t:a}){let{connector:o}=e,s=e.result?`complete`:e.installing?`health`:`configure`,c=[{id:`configure`,label:a.installStepConfigure},{id:`health`,label:a.installStepHealth},{id:`complete`,label:a.installStepComplete}],l=(0,U.useCallback)(async()=>{t({...e,installing:!0,error:null});try{let n=await Ye(o.id);window.open(n.verificationUri,`_blank`,`noopener,noreferrer`),t({...e,installing:!1,error:null,oauth:{flow:n,connected:!1}})}catch(n){t({...e,installing:!1,error:n instanceof Error?n.message:String(n)})}},[o.id,e,t]),u=(0,U.useCallback)(async()=>{if(e.oauth.flow){t({...e,installing:!0,error:null});try{await Xe(o.id,e.oauth.flow.deviceCode),t({...e,installing:!1,error:null,oauth:{...e.oauth,connected:!0}})}catch(n){t({...e,installing:!1,error:n instanceof Error?n.message:String(n)})}}},[o.id,e,t]),f=(0,U.useCallback)(async()=>{t({...e,installing:!0,error:null,result:null,health:null});try{if(o.auth.mode===`oauth`&&!e.oauth.connected)throw Error(a.oauthRequiredBeforeInstall);let n={};for(let t of o.setup.config??[]){let r=bt(t.type,e.config[t.key]??``);r!==void 0&&(n[t.key]=r)}let i=await Ze(o.id,{secrets:e.secrets,config:n,definition:o.source===`registry`?o:void 0}),s=null;try{s=await $e(i.instanceId)}catch{s=null}t({...e,installing:!1,result:i,health:s}),await r()}catch(n){t({...e,installing:!1,error:n instanceof Error?n.message:String(n)})}},[o,e,t,r,a.oauthRequiredBeforeInstall]);return(0,G.jsx)(L,{open:!0,onOpenChange:e=>{e||n()},children:(0,G.jsxs)(M,{children:[(0,G.jsx)(I,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,G.jsxs)(re,{className:i(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex max-h-[min(100vh-2rem,44rem)] w-[min(100%-2rem,min(92vw,48rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-panel shadow-float dark:border-edge`),children:[(0,G.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(z,{className:`text-base font-semibold text-fg`,children:X(a.installDialogTitle,{name:o.displayName})}),(0,G.jsx)(ie,{className:`mt-1 line-clamp-3 text-sm text-fg-muted`,children:o.description})]}),(0,G.jsx)(B,{asChild:!0,children:(0,G.jsxs)(`button`,{type:`button`,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,m.focusRingPanel),"aria-label":a.modalClose,children:[(0,G.jsx)(T,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,G.jsx)(`span`,{className:`sr-only`,children:a.modalClose})]})})]}),(0,G.jsxs)(`div`,{className:`min-h-0 overflow-y-auto px-6 py-5`,children:[(0,G.jsx)(`div`,{className:`mb-5 grid grid-cols-3 gap-2`,"aria-label":a.installProgressAria,children:c.map((e,t)=>{let n=c.findIndex(e=>e.id===s);return(0,G.jsxs)(`div`,{className:i(`rounded-xl border px-3 py-2 text-xs font-medium`,t===n?`border-accent bg-accent-soft text-accent-fg`:t<n?`border-emerald-200 bg-emerald-50 text-emerald-800 dark:border-emerald-900/40 dark:bg-emerald-950/40 dark:text-emerald-200`:`border-edge bg-surface-base text-fg-muted`),children:[(0,G.jsxs)(`span`,{className:`mr-1 tabular-nums`,children:[t+1,`.`]}),e.label]},e.id)})}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[o.auth.mode===`oauth`?(0,G.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-panel p-4`,children:[(0,G.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:a.oauthTitle}),(0,G.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:a.oauthHint}),e.oauth.flow?(0,G.jsxs)(`div`,{className:`mt-3 rounded-xl bg-surface-base p-3 text-sm text-fg-muted`,children:[(0,G.jsx)(`p`,{children:X(a.oauthOpenCodePrefix,{url:e.oauth.flow.verificationUri})}),(0,G.jsx)(`p`,{className:`mt-2 font-mono text-lg font-semibold tracking-widest text-fg`,children:e.oauth.flow.userCode})]}):null,e.oauth.connected?(0,G.jsx)(`p`,{className:`mt-3 rounded-xl bg-emerald-500/10 px-3 py-2 text-sm text-emerald-700`,children:a.oauthConnected}):null,(0,G.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,G.jsxs)(E,{variant:`secondary`,disabled:e.installing,onClick:()=>void l(),children:[e.installing&&!e.oauth.flow?(0,G.jsx)(R,{className:`size-4 animate-spin`}):(0,G.jsx)(w,{className:`size-4`}),a.oauthConnectButton]}),(0,G.jsxs)(E,{variant:`primary`,disabled:e.installing||!e.oauth.flow,onClick:()=>void u(),children:[e.installing&&e.oauth.flow?(0,G.jsx)(R,{className:`size-4 animate-spin`}):(0,G.jsx)(V,{className:`size-4`}),a.oauthAuthorizedButton]})]})]}):null,(o.setup.secrets??[]).map(n=>(0,G.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,G.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.label}),n.description?(0,G.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:n.description}):null,(0,G.jsx)(d,{value:e.secrets[n.key]??``,onChange:r=>t({...e,secrets:{...e.secrets,[n.key]:r},error:null}),labels:a.secretInputLabels,placeholder:n.required?a.requiredPlaceholder:a.optionalPlaceholder})]},n.key)),(o.setup.config??[]).map(n=>(0,G.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,G.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.label}),n.type===`json`?(0,G.jsx)(`textarea`,{className:vt,value:e.config[n.key]??``,placeholder:n.placeholder,onChange:r=>t({...e,config:{...e.config,[n.key]:r.currentTarget.value},error:null})}):(0,G.jsx)(`input`,{className:_t,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,G.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-base p-4 text-sm text-fg-muted`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 font-medium text-fg`,children:[(0,G.jsx)(R,{className:`size-4 animate-spin text-accent`,"aria-hidden":!0}),a.installingTitle]}),(0,G.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:a.installingHint})]}):null,e.error?(0,G.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,G.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-base p-4 text-sm text-fg-muted`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`font-medium text-fg`,children:X(a.installedAs,{target:e.result.materialized.type===`mcp`?e.result.materialized.serverId:e.result.instanceId})}),(0,G.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:X(a.runtimeLabel,{runtime:e.result.materialized.type.toUpperCase()})})]}),(0,G.jsx)(`span`,{className:i(`rounded-full px-2 py-0.5 text-xs font-medium`,e.health?.ok?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:e.health?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:`bg-surface-hover text-fg-muted`),children:e.health?.ok?a.healthStatusHealthy:yt(e.health?.status,a)})]}),e.health?(0,G.jsxs)(`div`,{className:`mt-3 grid gap-2 text-xs sm:grid-cols-3`,children:[(0,G.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2`,children:[(0,G.jsx)(`div`,{className:`font-semibold text-fg`,children:e.health.toolCount}),(0,G.jsx)(`div`,{children:a.toolsMetric})]}),(0,G.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2`,children:[(0,G.jsx)(`div`,{className:`font-semibold text-fg`,children:e.health.resourceCount}),(0,G.jsx)(`div`,{children:a.resourcesMetric})]}),(0,G.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-panel px-3 py-2`,children:[(0,G.jsx)(`div`,{className:`font-semibold text-fg`,children:e.health.promptCount}),(0,G.jsx)(`div`,{children:a.promptsMetric})]})]}):(0,G.jsx)(`p`,{className:`mt-3`,children:a.installedWithoutHealth}),e.health?.action?(0,G.jsx)(`p`,{className:`mt-3 text-xs text-fg-subtle`,children:e.health.action}):null]}):null]})]}),(0,G.jsx)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:(0,G.jsxs)(E,{variant:`primary`,disabled:!!e.result||e.installing||o.auth.mode===`oauth`&&!e.oauth.connected,onClick:()=>void f(),children:[e.installing?(0,G.jsx)(R,{className:`size-4 animate-spin`}):e.result?(0,G.jsx)(V,{className:`size-4`}):(0,G.jsx)(y,{className:`size-4`}),e.result?a.installedBadge:a.install]})})]})]})})}function Ct(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 je(r)}function wt(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 Tt(e,t,n){return e.filter(e=>wt(e,t)).toSorted((e,t)=>n===`source`&&e.source!==t.source?e.source.localeCompare(t.source):e.displayName.localeCompare(t.displayName))}function Et(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 Dt(e,t){let n=t.trim().toLowerCase();return n?[e.id,e.command??``,e.url??``,e.transport].some(e=>e.toLowerCase().includes(n)):!0}function Ot(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 kt(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,f)}function At({label:e,optionalLabel:t,addLabel:n,removeHeaderAria:r,pasteLabel:a,pasteFailed:o,keyPlaceholder:s,valuePlaceholder:c,headers:l,onChange:u}){let d=(e,t)=>{u(l.map((n,r)=>r===e?{...n,...t}:n))},f=()=>{u([...l,{key:``,value:``}])},p=e=>{let t=l.filter((t,n)=>n!==e);u(t.length>0?t:[{key:``,value:``}])},h=async()=>{try{let e=await x();if(!e){window.alert(o);return}let t=Y(e);if(!t?.length){window.alert(o);return}u(t)}catch{window.alert(o)}};return(0,G.jsxs)(`div`,{className:`flex flex-col gap-2 md:col-span-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium text-fg`,children:[(0,G.jsx)(`span`,{children:e}),t?(0,G.jsx)(`span`,{className:`font-normal text-fg-subtle`,children:t}):null]}),(0,G.jsxs)(E,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5 px-2 text-xs`,onClick:()=>void h(),children:[(0,G.jsx)(ae,{className:`size-3.5`,"aria-hidden":!0}),a]})]}),(0,G.jsx)(`div`,{className:`flex flex-col gap-2`,children:l.map((e,t)=>(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`input`,{className:i(kt(),`min-w-0 flex-1 font-mono text-xs`),value:e.key,placeholder:s,onChange:e=>d(t,{key:e.target.value})}),(0,G.jsx)(`input`,{className:i(kt(),`min-w-0 flex-[1.4] font-mono text-xs`),value:e.value,placeholder:c,onChange:e=>d(t,{value:e.target.value})}),(0,G.jsx)(E,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 px-0`,disabled:l.length<=1&&!e.key&&!e.value,onClick:()=>p(t),"aria-label":r,children:(0,G.jsx)(P,{className:`size-4 text-fg-subtle`,"aria-hidden":!0})})]},Ot(e,t,l)))}),(0,G.jsxs)(`button`,{type:`button`,className:i(`self-start text-sm text-accent hover:underline`,m.press),onClick:f,children:[`+ `,n]})]})}var jt=[`stdio`,`sse`,`streamable-http`];function Q(e){let t=(0,W.c)(11),{label:n,description:r,required:i,children:a}=e,o;t[0]===i?o=t[1]:(o=i?(0,G.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,G.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,G.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,G.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[s,a,c]}),t[7]=a,t[8]=s,t[9]=c,t[10]=l):l=t[10],l}function $(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,f)}function Mt(e){let t=(0,W.c)(67),{row:n,t:r,onUpdate:a,idConflictMessage:o}=e,s=r.transportLabel,c;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(c=$(),t[0]=c):c=t[0];let l=n.transport,u;t[1]===a?u=t[2]:(u=e=>a({transport:e.target.value}),t[1]=a,t[2]=u);let d;t[3]===r.transportLabels?d=t[4]:(d=jt.map(e=>(0,G.jsx)(H,{value:e,children:r.transportLabels[e]},e)),t[3]=r.transportLabels,t[4]=d);let f;t[5]!==n.transport||t[6]!==u||t[7]!==d?(f=(0,G.jsx)(A,{className:c,value:l,onChange:u,children:d}),t[5]=n.transport,t[6]=u,t[7]=d,t[8]=f):f=t[8];let p;t[9]!==r.transportLabel||t[10]!==f?(p=(0,G.jsx)(Q,{label:s,required:!0,children:f}),t[9]=r.transportLabel,t[10]=f,t[11]=p):p=t[11];let m=r.serverIdLabel,h;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(h=$(),t[12]=h):h=t[12];let g;t[13]===a?g=t[14]:(g=e=>a({id:e.target.value}),t[13]=a,t[14]=g);let _;t[15]!==n.id||t[16]!==r.serverIdPlaceholder||t[17]!==g?(_=(0,G.jsx)(`input`,{className:h,value:n.id,placeholder:r.serverIdPlaceholder,onChange:g}),t[15]=n.id,t[16]=r.serverIdPlaceholder,t[17]=g,t[18]=_):_=t[18];let v;t[19]===o?v=t[20]:(v=o?(0,G.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-300`,children:o}):null,t[19]=o,t[20]=v);let y;t[21]!==r.serverIdLabel||t[22]!==_||t[23]!==v?(y=(0,G.jsxs)(Q,{label:m,required:!0,children:[_,v]}),t[21]=r.serverIdLabel,t[22]=_,t[23]=v,t[24]=y):y=t[24];let b;t[25]!==a||t[26]!==n.argsText||t[27]!==n.command||t[28]!==n.cwd||t[29]!==n.envJson||t[30]!==n.headers||t[31]!==n.transport||t[32]!==n.url||t[33]!==r.addHeader||t[34]!==r.argsHint||t[35]!==r.argsLabel||t[36]!==r.commandLabel||t[37]!==r.cwdLabel||t[38]!==r.envHint||t[39]!==r.envLabel||t[40]!==r.headerKeyPlaceholder||t[41]!==r.headerValuePlaceholder||t[42]!==r.headersLabel||t[43]!==r.optionalSuffix||t[44]!==r.pasteHeaders||t[45]!==r.pasteHeadersFailed||t[46]!==r.removeHeader||t[47]!==r.urlLabel?(b=n.transport===`stdio`?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Q,{label:r.commandLabel,required:!0,children:(0,G.jsx)(`input`,{className:$(),value:n.command,onChange:e=>a({command:e.target.value})})}),(0,G.jsx)(Q,{label:r.argsLabel,description:r.argsHint,children:(0,G.jsx)(`input`,{className:$(),value:n.argsText,onChange:e=>a({argsText:e.target.value})})}),(0,G.jsx)(Q,{label:r.cwdLabel,children:(0,G.jsx)(`input`,{className:$(),value:n.cwd,onChange:e=>a({cwd:e.target.value})})}),(0,G.jsx)(Q,{label:r.envLabel,description:r.envHint,children:(0,G.jsx)(`textarea`,{className:i($(),`min-h-[4rem] font-mono text-xs`),value:n.envJson,onChange:e=>a({envJson:e.target.value})})})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{className:`md:col-span-2`,children:(0,G.jsx)(Q,{label:r.urlLabel,required:!0,children:(0,G.jsx)(`input`,{className:i($(),`font-mono text-xs`),value:n.url,placeholder:`https://example.com/mcp`,onChange:e=>a({url:e.target.value})})})}),(0,G.jsx)(At,{label:r.headersLabel,optionalLabel:r.optionalSuffix,addLabel:r.addHeader,removeHeaderAria:r.removeHeader,pasteLabel:r.pasteHeaders,pasteFailed:r.pasteHeadersFailed,keyPlaceholder:r.headerKeyPlaceholder,valuePlaceholder:r.headerValuePlaceholder,headers:n.headers,onChange:e=>a({headers:e})})]}),t[25]=a,t[26]=n.argsText,t[27]=n.command,t[28]=n.cwd,t[29]=n.envJson,t[30]=n.headers,t[31]=n.transport,t[32]=n.url,t[33]=r.addHeader,t[34]=r.argsHint,t[35]=r.argsLabel,t[36]=r.commandLabel,t[37]=r.cwdLabel,t[38]=r.envHint,t[39]=r.envLabel,t[40]=r.headerKeyPlaceholder,t[41]=r.headerValuePlaceholder,t[42]=r.headersLabel,t[43]=r.optionalSuffix,t[44]=r.pasteHeaders,t[45]=r.pasteHeadersFailed,t[46]=r.removeHeader,t[47]=r.urlLabel,t[48]=b):b=t[48];let x=r.timeoutLabel,S=r.timeoutHint,C;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(C=$(),t[49]=C):C=t[49];let w;t[50]===n?w=t[51]:(w=ze(n),t[50]=n,t[51]=w);let T;t[52]===a?T=t[53]:(T=e=>a({connectionTimeoutMs:Be(e.target.value)}),t[52]=a,t[53]=T);let E;t[54]!==r.timeoutPlaceholder||t[55]!==w||t[56]!==T?(E=(0,G.jsx)(`input`,{type:`number`,min:1,max:600,className:C,value:w,placeholder:r.timeoutPlaceholder,onChange:T}),t[54]=r.timeoutPlaceholder,t[55]=w,t[56]=T,t[57]=E):E=t[57];let D;t[58]!==r.timeoutHint||t[59]!==r.timeoutLabel||t[60]!==E?(D=(0,G.jsx)(Q,{label:x,description:S,children:E}),t[58]=r.timeoutHint,t[59]=r.timeoutLabel,t[60]=E,t[61]=D):D=t[61];let O;return t[62]!==y||t[63]!==b||t[64]!==D||t[65]!==p?(O=(0,G.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[p,y,b,D]}),t[62]=y,t[63]=b,t[64]=D,t[65]=p,t[66]=O):O=t[66],O}function Nt({open:e,mode:t,initialRow:n,existingCustomServers:r,sessionIdleTtlMinutes:a,config:o,managedServerIds:s,t:c,cs:l,onClose:u,onSaved:d}){let[f,p]=(0,U.useState)(n),[h,g]=(0,U.useState)(!1),[_,v]=(0,U.useState)(!1),[y,b]=(0,U.useState)(null),[x,S]=(0,U.useState)({status:`idle`}),[C,D]=(0,U.useState)(null),k=n.id.trim(),A=f.id.trim()!==k&&s.has(f.id.trim())||s.has(f.id.trim())&&t===`add`?c.reservedServerId:void 0,j=f.id.trim()&&r.some(e=>e.clientKey!==n.clientKey&&e.id.trim()===f.id.trim())?l.duplicateServerId:void 0,N=f.id.trim().length>0&&!A&&!j&&(f.transport===`stdio`?f.command.trim().length>0:f.url.trim().length>0),ee=(0,U.useCallback)(async()=>{if(f.id.trim()){v(!0),b(null),S({status:`loading`});try{S({status:`ok`,tools:(await Re(f.id.trim(),Ne(f))).tools})}catch(e){S({status:`error`,message:e instanceof Error?e.message:String(e)})}finally{v(!1)}}},[f]),P=(0,U.useCallback)(async()=>{if(!(!N||h)){g(!0),b(null);try{let e=r.filter(e=>!(t===`edit`&&e.clientKey===n.clientKey));e.push(f),await Pe({sessionIdleTtlMinutes:a,servers:e.sort((e,t)=>e.id.localeCompare(t.id))},Ee(o)),await d(),u()}catch(e){b(e instanceof Error?e.message:String(e))}finally{g(!1)}}},[N,o,r,n.clientKey,t,u,d,k,f,h,a]);return e?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(L,{open:e,onOpenChange:e=>{e||u()},children:(0,G.jsxs)(M,{children:[(0,G.jsx)(I,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,G.jsxs)(re,{className:i(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(100vh-2rem,44rem)] w-[min(100%-2rem,min(92vw,48rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-panel shadow-float dark:border-edge`),children:[(0,G.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(z,{className:`text-base font-semibold text-fg`,children:t===`add`?l.addCustomServerTitle:l.editCustomServerTitle}),(0,G.jsx)(ie,{className:`mt-1 text-sm text-fg-muted`,children:t===`add`?l.addCustomServerHint:l.editCustomServerHint})]}),(0,G.jsx)(B,{asChild:!0,children:(0,G.jsxs)(`button`,{type:`button`,className:i(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,m.focusRingPanel),"aria-label":l.modalClose,children:[(0,G.jsx)(T,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,G.jsx)(`span`,{className:`sr-only`,children:l.modalClose})]})})]}),(0,G.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:(0,G.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,G.jsx)(Mt,{row:f,t:c,onUpdate:e=>{p(t=>({...t,...e})),b(null)},idConflictMessage:A??j}),x.status===`ok`?(0,G.jsx)(`div`,{className:`rounded-xl border border-edge bg-surface-base px-3 py-2.5`,children:(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,G.jsx)(O,{className:`size-4 text-accent`,"aria-hidden":!0}),x.tools.length===0?c.toolsEmpty:c.toolsTitle.replace(`{{count}}`,String(x.tools.length))]}),x.tools.length>0?(0,G.jsx)(E,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,onClick:()=>D(x.tools),children:c.viewAllTools}):null]})}):null,x.status===`error`?(0,G.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:x.message}):null,y?(0,G.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:y}):null]})}),(0,G.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[(0,G.jsxs)(E,{variant:`secondary`,disabled:!f.id.trim()||_,onClick:()=>void ee(),children:[_?(0,G.jsx)(R,{className:`size-4 animate-spin`}):(0,G.jsx)(w,{className:`size-4`}),c.testConnection]}),(0,G.jsx)(B,{asChild:!0,children:(0,G.jsx)(E,{variant:`secondary`,children:l.modalCancel})}),(0,G.jsxs)(E,{variant:`primary`,disabled:!N||h,onClick:()=>void P(),children:[h?(0,G.jsx)(R,{className:`size-4 animate-spin`}):(0,G.jsx)(V,{className:`size-4`}),h?c.saving:l.modalSave]})]})]})]})}),C?(0,G.jsx)(ut,{open:!0,onOpenChange:e=>{e||D(null)},serverId:f.id,title:c.toolsDialogTitle,subtitle:c.toolsDialogSubtitle,searchPlaceholder:c.toolsDialogSearchPlaceholder,searchEmptyLabel:c.toolsDialogSearchEmpty,emptyLabel:c.toolsEmpty,closeLabel:c.toolsDialogClose,tools:C,stripPrefix:`${f.id.trim()}__`}):null]}):null}var Pt=`mprov`,Ft=`smithery`,It=i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,f);function Lt(){let e=a(o(e=>e.language)),t=e.connectorsSettings,n=e.mcpSettings,r=s(e=>e.token),c=!!r,[l,d]=se(),f=l.get(Pt)?.trim()||Ft,[p,h]=(0,U.useState)(`marketplace`),[g,y]=(0,U.useState)({catalog:[],registryCatalog:[],instances:[],registries:[],loading:!0,error:null}),[b,x]=(0,U.useState)(!1),[S,w]=(0,U.useState)(1),[T,D]=(0,U.useState)(void 0),[O,k]=(0,U.useState)(``),[A,j]=(0,U.useState)(f),[M,N]=(0,U.useState)(`name`),[P,F]=(0,U.useState)(null),[I,re]=(0,U.useState)(null),[L,ie]=(0,U.useState)(void 0),[z,B]=(0,U.useState)(!1),[ae,V]=(0,U.useState)(!1),{data:oe,mutate:H}=C(c),W=oe?.payload?.config,K=(0,U.useMemo)(()=>W===void 0?null:Me(W),[W]),q=K?.servers??[];(0,U.useEffect)(()=>{K&&ie(K.sessionIdleTtlMinutes)},[K]);let J=(0,U.useCallback)(async()=>{if(!r){y({catalog:[],registryCatalog:[],instances:[],registries:[],loading:!1,error:null});return}y(e=>({...e,loading:!0,error:null}));try{let[e,t,n]=await Promise.all([Ue(),Ge(),We()]);y(r=>({catalog:e,registryCatalog:r.registryCatalog,instances:t,registries:n,loading:!1,error:null}))}catch(e){y({catalog:[],registryCatalog:[],instances:[],registries:[],loading:!1,error:e instanceof Error?e.message:String(e)})}},[r]);(0,U.useEffect)(()=>{J()},[J]);let be=l.toString(),Se=(0,U.useRef)(be);(0,U.useEffect)(()=>{Se.current!==be&&(Se.current=be,j(l.get(Pt)?.trim()||Ft))},[l,be]);let Y=(0,U.useMemo)(()=>g.registries.map(e=>e.id),[g.registries]);(0,U.useEffect)(()=>{if(Y.length===0||Y.includes(A))return;let e=Y.includes(Ft)?Ft:Y[0];e&&j(e)},[A,Y]),(0,U.useEffect)(()=>{if(!A||A===l.get(Pt))return;let e=new URLSearchParams(l);e.set(Pt,A),Se.current=e.toString(),d(e,{replace:!0})},[A,l,d]);let Ce=(0,U.useCallback)(async e=>{let t=O.trim(),n=e?.browse??!1,r=Math.max(e?.page??1,1),i=e?.append??!1;if(!(!c||!t&&!n)){x(!0),i?y(e=>({...e,error:null})):(w(1),D(void 0),y(e=>({...e,registryCatalog:[],error:null})));try{let e=await Je(t,A,{browse:n,page:r});w(r),D(e.totalPages),y(t=>({...t,registryCatalog:i?[...t.registryCatalog,...e.connectors].filter((e,t,n)=>n.findIndex(t=>t.id===e.id)===t):e.connectors}))}catch(e){y(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{x(!1)}}},[c,O,A]);(0,U.useEffect)(()=>{if(p!==`marketplace`)return;let e=window.setTimeout(()=>{O.trim()?Ce():A&&Ce({browse:!0})},O.trim()?350:0);return()=>window.clearTimeout(e)},[A,O,Ce,g.loading,p]);let we=(0,U.useMemo)(()=>new Set(g.instances.map(e=>e.connectorId)),[g.instances]),Te=(0,U.useMemo)(()=>new Set(g.instances.flatMap(e=>e.materialized.type===`mcp`?[e.materialized.serverId]:[])),[g.instances]),De=(0,U.useCallback)(async e=>{if(!K||W===void 0)return;let t=q.filter(t=>t.clientKey!==e.clientKey);await Pe({sessionIdleTtlMinutes:K.sessionIdleTtlMinutes,servers:t},Ee(W)),await H(),await J()},[W,q,J,K,H]),Oe=(0,U.useCallback)(()=>{re({mode:`add`,row:Ct(q,Te)})},[q,Te]),ke=(0,U.useCallback)(async()=>{if(!(!K||W===void 0||z)){B(!0),V(!1);try{await Pe({sessionIdleTtlMinutes:L,servers:q},Ee(W)),await H(),V(!0),u({type:`success`,title:n.saved})}finally{B(!1)}}},[W,q,K,H,L,z]),Ae=ee(e=>e.setPageHeader),je=ee(e=>e.clearPageHeader),Ne=(0,U.useMemo)(()=>(0,G.jsx)(xe,{loading:g.loading||b,searchQuery:O,setSearchQuery:k,onReloadClick:J,onAddCustomServer:Oe,searchPlaceholder:p===`marketplace`?t.marketplaceSearchPlaceholder:p===`builtin`?t.builtinSearchPlaceholder:p===`user`?t.userSearchPlaceholder:t.configSearchPlaceholder,addLabel:t.addCustomServer,reloadLabel:t.reload}),[t,J,Oe,b,O,g.loading,p]);(0,U.useLayoutEffect)(()=>(Ae({startExtra:null,main:(0,G.jsx)(`div`,{className:`min-w-0`,children:(0,G.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.title})}),end:Ne}),()=>je()),[je,t.title,Ne,Ae]);let Fe=g.instances.length+q.length,Ie=(0,U.useMemo)(()=>Tt(g.catalog.filter(e=>e.source===`builtin`),O,M),[M,O,g.catalog]),Le=(0,U.useMemo)(()=>Tt(g.registryCatalog,O,M),[M,O,g.registryCatalog]),Re=p===`marketplace`&&!!(T&&S<T),ze=(0,U.useMemo)(()=>g.instances.filter(e=>Et(e,O)),[O,g.instances]),Be=(0,U.useMemo)(()=>q.filter(e=>Dt(e,O)),[q,O]),Ve=ze.length+Be.length,X=[{id:`marketplace`,label:t.tabMarketplace},{id:`builtin`,label:t.tabBuiltin,count:Ie.length},{id:`user`,label:t.tabUser,count:Fe},{id:`config`,label:t.tabConfig}];return(0,G.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:(0,G.jsxs)(`div`,{className:`flex w-full flex-col gap-6 px-3 py-6 sm:px-5 xl:px-6`,children:[c?null:(0,G.jsx)(`p`,{className:`rounded-xl border border-edge bg-surface-panel px-4 py-3 text-sm text-fg-muted`,children:t.tokenHint}),(0,G.jsxs)(`section`,{className:`flex flex-col gap-4`,children:[(0,G.jsxs)(`div`,{className:`flex flex-col gap-3 border-b border-edge-subtle pb-3 sm:flex-row sm:items-center sm:justify-between dark:border-edge-subtle`,children:[(0,G.jsx)(_,{items:X,activeTab:p,onChange:h,ariaLabel:t.navAria,tabIdPrefix:`connectors-tab`,panelIdPrefix:`connectors-panel`,className:`flex-wrap`}),(0,G.jsxs)(`div`,{className:`flex min-h-9 min-w-0 flex-wrap items-center gap-2 sm:justify-end`,children:[p===`marketplace`?(0,G.jsx)(`div`,{className:`inline-flex h-9 max-w-full shrink-0 overflow-x-auto rounded-lg border border-edge bg-surface-panel p-0.5 shadow-surface`,role:`group`,"aria-label":t.registrySourceAria,children:g.registries.map(e=>(0,G.jsx)(`button`,{type:`button`,className:i(`shrink-0 rounded-md px-2.5 py-1.5 text-xs font-medium transition-colors`,m.focusRingPanel,A===e.id?`bg-fg text-surface-panel dark:bg-fg dark:text-surface-base`:`text-fg-muted hover:text-fg`),"aria-pressed":A===e.id,onClick:()=>j(e.id),children:e.displayName},e.id))}):null,p!==`user`&&p!==`config`?(0,G.jsxs)(ue,{children:[(0,G.jsx)(fe,{asChild:!0,children:(0,G.jsxs)(`button`,{type:`button`,className:i(`inline-flex h-9 min-h-9 min-w-[9rem] shrink-0 items-center gap-1.5 rounded-lg border border-edge bg-surface-panel px-2.5 text-xs font-medium text-fg shadow-surface`,m.transition,m.focusRingPanel),children:[(0,G.jsx)(ne,{className:`size-3.5 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),(0,G.jsx)(`span`,{children:M===`name`?t.sortName:t.sortSource}),(0,G.jsx)(te,{className:`size-3.5 text-fg-subtle`,strokeWidth:1.75,"aria-hidden":!0})]})}),(0,G.jsx)(pe,{children:(0,G.jsxs)(me,{className:`z-50 min-w-[10rem] rounded-xl border border-edge bg-surface-panel p-1 shadow-popover dark:border-edge`,sideOffset:6,align:`end`,children:[(0,G.jsx)(de,{className:`cursor-pointer rounded-lg px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover data-[highlighted]:bg-surface-hover`,onSelect:()=>N(`name`),children:t.sortName}),(0,G.jsx)(de,{className:`cursor-pointer rounded-lg px-3 py-2 text-sm text-fg outline-none hover:bg-surface-hover data-[highlighted]:bg-surface-hover`,onSelect:()=>N(`source`),children:t.sortSource})]})})]}):null]})]}),g.error?(0,G.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:g.error}):null,p===`user`&&c?(0,G.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.installedTitle}),(0,G.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:t.installedHint})]}),g.loading?(0,G.jsx)(`div`,{className:`grid gap-3`,"aria-busy":`true`,"aria-label":t.loading,children:he.slice(0,3).map(e=>(0,G.jsx)(ve,{},e))}):Fe===0||Ve===0?(0,G.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center text-sm text-fg-muted`,children:Fe===0?t.installedEmpty:t.userEmpty}):(0,G.jsxs)(`div`,{className:`grid gap-3`,children:[ze.map(e=>(0,G.jsx)(gt,{instance:e,onChanged:J,t,mcp:n},e.instanceId)),Be.map(e=>(0,G.jsx)(He,{row:e,t:n,cs:t,onEdit:()=>re({mode:`edit`,row:structuredClone(e)}),onRemove:async()=>De(e)},e.clientKey))]}),(0,G.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.disableHint})]}):null,p===`config`&&c?(0,G.jsx)(`div`,{className:`flex flex-col gap-4`,children:(0,G.jsxs)(le,{children:[(0,G.jsx)(ce,{icon:v,title:n.globalTitle,subtitle:n.globalHint}),(0,G.jsx)(`div`,{className:`max-w-xl`,children:(0,G.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,G.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:n.idleTtlLabel}),(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,G.jsx)(`input`,{type:`number`,min:0,className:i(It,`w-40 flex-none`),value:L??``,placeholder:n.idleTtlPlaceholder,onChange:e=>{let t=e.target.value.trim();ie(t===``?void 0:Number.parseInt(t,10)),V(!1)}}),(0,G.jsxs)(E,{variant:`secondary`,disabled:z,onClick:()=>void ke(),children:[z?(0,G.jsx)(R,{className:`size-4 animate-spin`}):null,n.save]})]}),(0,G.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:n.idleTtlHint})]})})]})}):null,p===`marketplace`&&c?(0,G.jsx)(`div`,{className:`flex flex-col gap-4`,children:b&&Le.length===0?(0,G.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,"aria-busy":`true`,"aria-label":t.loading,children:he.map(e=>(0,G.jsx)(_e,{},e))}):O.trim()&&Le.length===0?(0,G.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center text-sm text-fg-muted`,children:t.marketplaceEmpty}):!O.trim()&&Le.length===0?(0,G.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center text-sm text-fg-muted`,children:t.marketplaceStartHint}):(0,G.jsxs)(`div`,{className:`relative`,children:[b?(0,G.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,G.jsx)(R,{className:`size-8 shrink-0 animate-spin text-accent motion-reduce:animate-none`,strokeWidth:2,"aria-hidden":!0})}):null,(0,G.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:Le.map(e=>(0,G.jsx)(ye,{connector:e,installed:we.has(e.id)||ge(e,g.instances),onInstall:e=>F(xt(e)),t},e.id))}),Re?(0,G.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,G.jsxs)(E,{type:`button`,variant:`secondary`,disabled:b,onClick:()=>void Ce({browse:!O.trim(),page:S+1,append:!0}),children:[b?(0,G.jsx)(R,{className:`size-4 animate-spin`}):null,t.loadMore]})}):null]})}):null,p===`builtin`&&c?(0,G.jsx)(`div`,{className:`flex flex-col gap-4`,children:g.loading?(0,G.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,"aria-busy":`true`,"aria-label":t.loading,children:he.map(e=>(0,G.jsx)(_e,{},e))}):Ie.length===0?(0,G.jsx)(`div`,{className:`rounded-2xl border border-dashed border-edge p-8 text-center text-sm text-fg-muted`,children:t.builtinEmpty}):(0,G.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:Ie.map(e=>(0,G.jsx)(ye,{connector:e,installed:we.has(e.id)||ge(e,g.instances),onInstall:e=>F(xt(e)),t},e.id))})}):null]}),P?(0,G.jsx)(St,{draft:P,onChange:F,onClose:()=>F(null),t,onInstalled:async()=>{await J(),await H(),h(`user`)}}):null,I?(0,G.jsx)(Nt,{open:!0,mode:I.mode,initialRow:I.row,existingCustomServers:q,sessionIdleTtlMinutes:L,config:W,managedServerIds:Te,t:n,cs:t,onClose:()=>re(null),onSaved:async()=>{await H(),await J(),h(`user`)}},`${I.mode}-${I.row.clientKey}`):null]})})}export{Lt as ConnectorsPage};
@@ -1 +1 @@
1
- import{n as e,t}from"./vendor-react-BOUWij0V.js";import{t as n}from"./cn-BQ_8x0bT.js";import{dt as r,ft as i,st as a}from"./index-T0SaNd5a.js";var o=e(),s=t();function c(e){let t=(0,o.c)(37),{value:c,onChange:l,disabled:u,wd:d,placeholder:f,inputClassName:p,trailing:m}=e,h;t[0]!==l||t[1]!==c?(h={initialPath:c,onPicked:l},t[0]=l,t[1]=c,t[2]=h):h=t[2];let g=r(h),_;t[3]===c?_=t[4]:(_=c.trim(),t[3]=c,t[4]=_);let v=_,y=v?`${v}\n${d.chooseFolder}`:`${f??d.notSet}\n${d.selectWorkingDirectory}`,b;t[5]===p?b=t[6]:(b=n(`min-w-0 flex-1`,p),t[5]=p,t[6]=b);let x=u||g.picking,S;t[7]===l?S=t[8]:(S=e=>void l(e.target.value),t[7]=l,t[8]=S);let C=f??d.pathInputPlaceholder,w;t[9]!==b||t[10]!==x||t[11]!==S||t[12]!==C||t[13]!==c?(w=(0,s.jsx)(`input`,{type:`text`,className:b,value:c,disabled:x,onChange:S,placeholder:C,autoComplete:`off`,spellCheck:!1}),t[9]=b,t[10]=x,t[11]=S,t[12]=C,t[13]=c,t[14]=w):w=t[14];let T=u||g.picking,E;t[15]!==y||t[16]!==g.pick||t[17]!==T||t[18]!==c||t[19]!==d.selectWorkingDirectory?(E=(0,s.jsx)(i,{compact:!0,value:c,onPick:g.pick,disabled:T,title:y,"aria-label":d.selectWorkingDirectory}),t[15]=y,t[16]=g.pick,t[17]=T,t[18]=c,t[19]=d.selectWorkingDirectory,t[20]=E):E=t[20];let D;t[21]!==E||t[22]!==m?(D=(0,s.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[E,m]}),t[21]=E,t[22]=m,t[23]=D):D=t[23];let O;t[24]!==D||t[25]!==w?(O=(0,s.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center`,children:[w,D]}),t[24]=D,t[25]=w,t[26]=O):O=t[26];let k;t[27]!==g.confirmPick||t[28]!==g.hasNativePicker||t[29]!==g.modalOpen||t[30]!==g.setModalOpen||t[31]!==v||t[32]!==d?(k=g.hasNativePicker?null:(0,s.jsx)(a,{open:g.modalOpen,onOpenChange:g.setModalOpen,initialAbsolutePath:v||void 0,onConfirm:g.confirmPick,wd:d}),t[27]=g.confirmPick,t[28]=g.hasNativePicker,t[29]=g.modalOpen,t[30]=g.setModalOpen,t[31]=v,t[32]=d,t[33]=k):k=t[33];let A;return t[34]!==O||t[35]!==k?(A=(0,s.jsxs)(s.Fragment,{children:[O,k]}),t[34]=O,t[35]=k,t[36]=A):A=t[36],A}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{dt as r,ft as i,st as a}from"./index-c_9TVr_C.js";var o=e(),s=t();function c(e){let t=(0,o.c)(37),{value:c,onChange:l,disabled:u,wd:d,placeholder:f,inputClassName:p,trailing:m}=e,h;t[0]!==l||t[1]!==c?(h={initialPath:c,onPicked:l},t[0]=l,t[1]=c,t[2]=h):h=t[2];let g=r(h),_;t[3]===c?_=t[4]:(_=c.trim(),t[3]=c,t[4]=_);let v=_,y=v?`${v}\n${d.chooseFolder}`:`${f??d.notSet}\n${d.selectWorkingDirectory}`,b;t[5]===p?b=t[6]:(b=n(`min-w-0 flex-1`,p),t[5]=p,t[6]=b);let x=u||g.picking,S;t[7]===l?S=t[8]:(S=e=>void l(e.target.value),t[7]=l,t[8]=S);let C=f??d.pathInputPlaceholder,w;t[9]!==b||t[10]!==x||t[11]!==S||t[12]!==C||t[13]!==c?(w=(0,s.jsx)(`input`,{type:`text`,className:b,value:c,disabled:x,onChange:S,placeholder:C,autoComplete:`off`,spellCheck:!1}),t[9]=b,t[10]=x,t[11]=S,t[12]=C,t[13]=c,t[14]=w):w=t[14];let T=u||g.picking,E;t[15]!==y||t[16]!==g.pick||t[17]!==T||t[18]!==c||t[19]!==d.selectWorkingDirectory?(E=(0,s.jsx)(i,{compact:!0,value:c,onPick:g.pick,disabled:T,title:y,"aria-label":d.selectWorkingDirectory}),t[15]=y,t[16]=g.pick,t[17]=T,t[18]=c,t[19]=d.selectWorkingDirectory,t[20]=E):E=t[20];let D;t[21]!==E||t[22]!==m?(D=(0,s.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2`,children:[E,m]}),t[21]=E,t[22]=m,t[23]=D):D=t[23];let O;t[24]!==D||t[25]!==w?(O=(0,s.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-center`,children:[w,D]}),t[24]=D,t[25]=w,t[26]=O):O=t[26];let k;t[27]!==g.confirmPick||t[28]!==g.hasNativePicker||t[29]!==g.modalOpen||t[30]!==g.setModalOpen||t[31]!==v||t[32]!==d?(k=g.hasNativePicker?null:(0,s.jsx)(a,{open:g.modalOpen,onOpenChange:g.setModalOpen,initialAbsolutePath:v||void 0,onConfirm:g.confirmPick,wd:d}),t[27]=g.confirmPick,t[28]=g.hasNativePicker,t[29]=g.modalOpen,t[30]=g.setModalOpen,t[31]=v,t[32]=d,t[33]=k):k=t[33];let A;return t[34]!==O||t[35]!==k?(A=(0,s.jsxs)(s.Fragment,{children:[O,k]}),t[34]=O,t[35]=k,t[36]=A):A=t[36],A}export{c as t};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-avfvyZuQ.js";import{n as o}from"./locale-store-Ba72bFmP.js";import{c as s,i as c,n as l}from"./fetch-Dtpbbe0s.js";import{i as u}from"./vendor-swr-BIWyz7Rc.js";import{$a as d,Ba as f,H as p,Ia as m,Io as h,Mc as g,Oo as _,Rc as v,Ua as y,_s as b,fo as x,io as S,ji as C,ns as w,qo as T,ts as E,ut as D,wo as O,yo as k}from"./index-T0SaNd5a.js";import{n as A,t as ee}from"./settings-form-section-BFxBNxOG.js";import{n as j,r as M,t as te}from"./settings-page-layout-CLx4o2PN.js";import{n as N,t as P}from"./schedule-field-BW78mKc0.js";import{t as F}from"./format-cron-label-arqgGlVV.js";var I=e(t(),1),L=n();function R(){return c(`/api/dreaming`)}async function z(){let e=await l(R());if(!e.payload)throw Error(`Missing payload`);return e.payload}async function ne(e){await l(c(`/api/dreaming/action`),{method:`POST`,body:JSON.stringify({action:e})})}async function re(e=`deep`){let t=await l(c(`/api/dreaming/run`),{method:`POST`,body:JSON.stringify({phase:e})});if(t.ok===!1||!t.payload)throw Error(`Failed to run dreaming phase`);let n=t.payload.phase;return{phase:n===`light`||n===`deep`||n===`rem`?n:e,result:t.payload.result}}async function ie(e){let t=await l(c(`/api/dreaming/preview${typeof e==`number`&&Number.isFinite(e)?`?limit=${encodeURIComponent(String(e))}`:``}`));if(!t.payload)throw Error(`Missing payload`);return t.payload}async function ae(e=50){return(await l(c(`/api/dreaming/events${`?limit=${encodeURIComponent(String(e))}`}`))).payload?.events??[]}function B(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var V={enabled:!0,cron:`0 */6 * * *`,lookbackDays:1,limit:50,dedupeSimilarity:.85},H={enabled:!0,cron:`0 3 * * *`,minScore:.8,minRecallCount:3,limit:10,recencyHalfLifeDays:14,maxAgeDays:30},U={enabled:!0,cron:`0 5 * * 0`,lookbackDays:7,limit:20,minPatternStrength:.6},W={enabled:!1,frequency:`0 3 * * *`,timezone:``,deepEnabled:!0,minScore:.8,minRecallCount:3,limit:10,light:V,deep:H,rem:U};function G(e,t){return Number.isFinite(e)?Math.max(0,Math.min(1,e)):t}function K(e,t){let n=typeof e==`string`?Number(e):e;return Number.isFinite(n)?Math.max(0,Math.floor(n)):t}function q(e,t){let n=typeof e==`string`?Number(e):e;return Number.isFinite(n)?n:t}function oe(e){let t=B(e)?e:{},n=B(t.memory)?t.memory:{},r=B(t.dreaming)?t.dreaming:{},i=typeof t.enabled==`boolean`||typeof t.frequency==`string`||B(t.phases)?t:{},a=B(n.dreaming)?n.dreaming:Object.keys(r).length>0?r:i,o=B(a.phases)?a.phases:{},s=B(o.light)?o.light:{},c=B(o.deep)?o.deep:{},l=B(o.rem)?o.rem:{};return{enabled:a.enabled===!0,frequency:typeof a.frequency==`string`&&a.frequency.trim()?a.frequency.trim():W.frequency,timezone:typeof a.timezone==`string`?a.timezone:``,deepEnabled:c.enabled!==!1,minScore:G(typeof c.minScore==`number`?c.minScore:Number(c.minScore),W.minScore),minRecallCount:Math.max(1,K(c.minRecallCount,W.minRecallCount)),limit:K(c.limit,W.limit),light:{enabled:s.enabled!==!1,cron:typeof s.cron==`string`&&s.cron.trim()?s.cron.trim():V.cron,lookbackDays:Math.max(1,K(s.lookbackDays,V.lookbackDays)),limit:K(s.limit,V.limit),dedupeSimilarity:G(q(s.dedupeSimilarity,V.dedupeSimilarity),V.dedupeSimilarity)},deep:{enabled:c.enabled!==!1,cron:typeof c.cron==`string`&&c.cron.trim()?c.cron.trim():H.cron,minScore:G(q(c.minScore,H.minScore),H.minScore),minRecallCount:Math.max(1,K(c.minRecallCount,H.minRecallCount)),limit:K(c.limit,H.limit),recencyHalfLifeDays:Math.max(1,q(c.recencyHalfLifeDays,H.recencyHalfLifeDays)),maxAgeDays:Math.max(1,q(c.maxAgeDays,H.maxAgeDays))},rem:{enabled:l.enabled!==!1,cron:typeof l.cron==`string`&&l.cron.trim()?l.cron.trim():U.cron,lookbackDays:Math.max(1,K(l.lookbackDays,U.lookbackDays)),limit:K(l.limit,U.limit),minPatternStrength:G(q(l.minPatternStrength,U.minPatternStrength),U.minPatternStrength)}}}async function se(e,t,n){let r=t.frequency.trim(),i=t.timezone.trim();await l(c(`/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:B(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:G(t.light.dedupeSimilarity,V.dedupeSimilarity)},deep:{enabled:!!t.deep.enabled,...t.deep.cron.trim()?{cron:t.deep.cron.trim()}:{},minScore:G(t.deep.minScore,H.minScore),minRecallCount:Math.max(1,Math.floor(t.deep.minRecallCount)),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:G(t.rem.minPatternStrength,U.minPatternStrength)}}}}})}),C()}var ce=`p-4 sm:px-5`,le=`mb-3`,J=`rounded-xl border border-edge-subtle bg-surface-panel/30 p-3 sm:p-4`,Y=i(`mt-1 w-full rounded-lg border border-edge-subtle bg-surface-panel px-2.5 py-1.5 text-sm text-fg`,m);function ue(e){return e?e.replace(`T`,` `).replace(`Z`,``):`—`}function X(e){return e===void 0||!Number.isFinite(e)||e<0?`—`:e<1e3?`${Math.round(e)} ms`:`${(e/1e3).toFixed(2)} s`}function de(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(),fe=`text-xs font-medium text-fg-muted`,pe=`text-sm font-medium text-fg`;function Q(e){let t=(0,L.c)(6),{label:n,children:r,className:i}=e,a;t[0]===n?a=t[1]:(a=(0,Z.jsx)(`span`,{className:fe,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,L.c)(11),{label:n,children:r,className:a}=e,o;t[0]===a?o=t[1]:(o=i(`min-w-0`,a),t[0]=a,t[1]=o);let s;t[2]===n?s=t[3]:(s=(0,Z.jsx)(`dt`,{className:fe,children:n}),t[2]=n,t[3]=s);let c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=i(pe,`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 me(e){let t=(0,L.c)(5),{label:n,className:r}=e,a;t[0]===r?a=t[1]:(a=i(`text-[0.7rem] font-semibold uppercase tracking-wider text-fg-muted`,r),t[0]=r,t[1]=a);let o;return t[2]!==n||t[3]!==a?(o=(0,Z.jsx)(`h3`,{className:a,children:n}),t[2]=n,t[3]=a,t[4]=o):o=t[4],o}function he(e){let t=(0,L.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 border-b border-edge-subtle/80 pb-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)(P,{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:J,children:[D,O,k]}),t[35]=O,t[36]=k,t[37]=D,t[38]=A):A=t[38],A}function ge(e){let t=(0,L.c)(23),{icon:n,label:r,enabled:a,cron:o,scheduleSummary:s,details:c,t:l}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=i(J,`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=a?`text-emerald-600 dark:text-emerald-400`:`text-fg-muted`,p;t[3]===f?p=t[4]:(p=i(`ml-auto text-xs font-medium`,f),t[3]=f,t[4]=p);let m=a?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 _e(e){let t=(0,L.c)(9),{label:n,lastRun:r,t:i}=e,a;t[0]===n?a=t[1]:(a=(0,Z.jsx)(me,{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 border border-edge-subtle`,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 border-t border-edge-subtle 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:`border-t border-edge-subtle/80 pt-3`,children:[a,o]}),t[6]=a,t[7]=o,t[8]=s):s=t[8],s}function ve(e){let t=(0,L.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=X(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 ye(e){let t=(0,L.c)(56),{t:n,schedulePickerLabels:r,hasToken:a,cfgForm:o,cfgBaseline:s,cfgDirty:c,cfgSaving:l,runPhase:u,setRunPhase:d,runBusy:f,setCfgForm:p,doRunNow:m}=e,h;t[0]!==c||t[1]!==o?.enabled||t[2]!==l||t[3]!==m||t[4]!==a||t[5]!==f||t[6]!==u||t[7]!==d||t[8]!==n?(h=(e,t)=>o?.enabled?(0,Z.jsx)(Se,{t:n,busy:f&&u===e,disabled:!a||l||f||!t||c,title:c?n.runNowSaveFirstHint:n.runNowHint,onClick:()=>{d(e),m(e)}}):null,t[0]=c,t[1]=o?.enabled,t[2]=l,t[3]=m,t[4]=a,t[5]=f,t[6]=u,t[7]=d,t[8]=n,t[9]=h):h=t[9];let g=h,_;t[10]!==s||t[11]!==o||t[12]!==n.phasePendingSave||t[13]!==n.phaseWillDisable||t[14]!==n.phaseWillEnable?(_=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[10]=s,t[11]=o,t[12]=n.phasePendingSave,t[13]=n.phaseWillDisable,t[14]=n.phaseWillEnable,t[15]=_):_=t[15];let v=_,y;return t[16]!==c||t[17]!==o||t[18]!==l||t[19]!==a||t[20]!==v||t[21]!==g||t[22]!==r||t[23]!==p||t[24]!==n.configDeepHalfLife||t[25]!==n.configDeepLimit||t[26]!==n.configDeepMaxAge||t[27]!==n.configDeepMinRecallCount||t[28]!==n.configDeepMinScore||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?(y=(0,Z.jsx)(ee,{className:`min-w-0 !p-0`,children:o?(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsxs)(`div`,{className:i(J,`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:i(`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:!a||l,onChange:e=>p(t=>t&&{...t,enabled:e.target.checked})}),(0,Z.jsx)(`span`,{className:i(`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)(b,{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)(be,{title:n.scheduleTitle}),(0,Z.jsx)(`div`,{className:J,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)(P,{kind:`cron`,label:n.configFrequency,value:o.frequency,onChange:e=>p(t=>t&&{...t,frequency:e}),labels:r,disabled:!a||l})}),(0,Z.jsx)(Q,{label:n.configTimezone,className:`lg:col-span-3`,children:(0,Z.jsx)(`input`,{className:Y,value:o.timezone,disabled:!a||l,onChange:e=>p(t=>t&&{...t,timezone:e.target.value}),placeholder:`Asia/Shanghai`})})]})})]}),(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(be,{title:n.phasesTitle}),(0,Z.jsxs)(he,{icon:(0,Z.jsx)(S,{className:`size-4 text-amber-500`}),title:n.configPhaseLight,hint:n.configPhaseLightHint,enabled:o.light.enabled,onEnabledChange:e=>p(t=>t&&{...t,light:{...t.light,enabled:e}}),cron:o.light.cron,onCronChange:e=>p(t=>t&&{...t,light:{...t.light,cron:e}}),scheduleLabels:r,disabled:!a||l,showEnabledControl:o.enabled,actions:g(`light`,o.light.enabled),status:v(`light`)?(0,Z.jsx)(xe,{label:v(`light`)??``}):null,enabledLabel:v(`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:Y,value:o.light.lookbackDays,disabled:!a||l,onChange:e=>p(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:Y,value:o.light.limit,disabled:!a||l,onChange:e=>p(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:Y,value:o.light.dedupeSimilarity,disabled:!a||l,onChange:e=>p(t=>t&&{...t,light:{...t.light,dedupeSimilarity:Number(e.target.value)}})})})]}),(0,Z.jsxs)(he,{icon:(0,Z.jsx)(T,{className:`size-4 text-indigo-500`}),title:n.configPhaseDeep,hint:n.configPhaseDeepHint,enabled:o.deep.enabled,onEnabledChange:e=>p(t=>t&&{...t,deep:{...t.deep,enabled:e}}),cron:o.deep.cron,onCronChange:e=>p(t=>t&&{...t,deep:{...t.deep,cron:e}}),scheduleLabels:r,disabled:!a||l,showEnabledControl:o.enabled,actions:g(`deep`,o.deep.enabled),status:v(`deep`)?(0,Z.jsx)(xe,{label:v(`deep`)??``}):null,enabledLabel:v(`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:Y,value:o.deep.minScore,disabled:!a||l,onChange:e=>p(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:Y,value:o.deep.minRecallCount,disabled:!a||l,onChange:e=>p(t=>t&&{...t,deep:{...t.deep,minRecallCount:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configDeepLimit,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:0,className:Y,value:o.deep.limit,disabled:!a||l,onChange:e=>p(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:Y,value:o.deep.recencyHalfLifeDays,disabled:!a||l,onChange:e=>p(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:Y,value:o.deep.maxAgeDays,disabled:!a||l,onChange:e=>p(t=>t&&{...t,deep:{...t.deep,maxAgeDays:Number(e.target.value)}})})})]}),(0,Z.jsxs)(he,{icon:(0,Z.jsx)(x,{className:`size-4 text-purple-500`}),title:n.configPhaseRem,hint:n.configPhaseRemHint,enabled:o.rem.enabled,onEnabledChange:e=>p(t=>t&&{...t,rem:{...t.rem,enabled:e}}),cron:o.rem.cron,onCronChange:e=>p(t=>t&&{...t,rem:{...t.rem,cron:e}}),scheduleLabels:r,disabled:!a||l,showEnabledControl:o.enabled,actions:g(`rem`,o.rem.enabled),status:v(`rem`)?(0,Z.jsx)(xe,{label:v(`rem`)??``}):null,enabledLabel:v(`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:Y,value:o.rem.lookbackDays,disabled:!a||l,onChange:e=>p(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:Y,value:o.rem.limit,disabled:!a||l,onChange:e=>p(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:Y,value:o.rem.minPatternStrength,disabled:!a||l,onChange:e=>p(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[16]=c,t[17]=o,t[18]=l,t[19]=a,t[20]=v,t[21]=g,t[22]=r,t[23]=p,t[24]=n.configDeepHalfLife,t[25]=n.configDeepLimit,t[26]=n.configDeepMaxAge,t[27]=n.configDeepMinRecallCount,t[28]=n.configDeepMinScore,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]=y):y=t[55],y}function be(e){let t=(0,L.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 xe(e){let t=(0,L.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 Se(e){let t=(0,L.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)(w,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(h,{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)(f,{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 Ce(e){let t=(0,L.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)(w,{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)(f,{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)(A,{className:le,icon:g,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 p;t[13]!==a||t[14]!==n.eventsEmpty||t[15]!==n.eventsNotLoaded?(p=a?a.length>0?(0,Z.jsx)(`div`,{className:`space-y-1.5`,children:a.map(we)}):(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]=p):p=t[16];let m;return t[17]!==d||t[18]!==p?(m=(0,Z.jsxs)(ee,{className:ce,children:[d,p]}),t[17]=d,t[18]=p,t[19]=m):m=t[19],m}function we(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 border border-edge-subtle bg-surface-panel/60 px-3 py-2 text-xs`,children:[(0,Z.jsx)(`span`,{children:t}),(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:e.phase}),(0,Z.jsx)(`span`,{className:i(`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:X(e.durationMs)}),(0,Z.jsx)(`span`,{className:`ml-auto text-fg-subtle`,children:ue(e.timestamp)})]},`${e.timestamp}:${e.phase}`)}function Te(e){let t=(0,L.c)(23),{t:n,hasToken:r,cfgForm:i,cfgSaving:a,cfgDirty:o,saveConfig:s,doRefresh:c}=e,l=!r||!i||a||!o,u;t[0]===s?u=t[1]:(u=()=>void s(),t[0]=s,t[1]=u);let d;t[2]===a?d=t[3]:(d=a?(0,Z.jsx)(w,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,t[2]=a,t[3]=d);let p;t[4]!==n.saveConfig||t[5]!==l||t[6]!==u||t[7]!==d?(p=(0,Z.jsxs)(f,{type:`button`,variant:`primary`,disabled:l,onClick:u,children:[d,n.saveConfig]}),t[4]=n.saveConfig,t[5]=l,t[6]=u,t[7]=d,t[8]=p):p=t[8];let m=!r,h;t[9]===c?h=t[10]:(h=()=>void c(),t[9]=c,t[10]=h);let g;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,Z.jsx)(_,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[11]=g):g=t[11];let v;t[12]!==n.refresh||t[13]!==m||t[14]!==h?(v=(0,Z.jsx)(f,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,disabled:m,title:n.refresh,"aria-label":n.refresh,onClick:h,children:g}),t[12]=n.refresh,t[13]=m,t[14]=h,t[15]=v):v=t[15];let y;t[16]!==p||t[17]!==v?(y=(0,Z.jsxs)(Z.Fragment,{children:[p,v]}),t[16]=p,t[17]=v,t[18]=y):y=t[18];let b;return t[19]!==n.subtitle||t[20]!==n.title||t[21]!==y?(b=(0,Z.jsx)(j,{title:n.title,subtitle:n.subtitle,actions:y}),t[19]=n.subtitle,t[20]=n.title,t[21]=y,t[22]=b):b=t[22],b}function Ee(e){let t=(0,L.c)(30),{t:n,disabled:r,actionBusy:a,doAction:o}=e,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=i(`max-w-2xl`,ce),t[0]=s):s=t[0];let c;t[1]!==n.maintenanceHint||t[2]!==n.maintenanceTitle?(c=(0,Z.jsx)(A,{className:le,icon:y,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]===a?u=t[8]:(u=a===`reset_store`?(0,Z.jsx)(w,{className:`mr-2 size-4 animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(d,{className:`mr-2 size-4`,"aria-hidden":!0}),t[7]=a,t[8]=u);let p;t[9]!==r||t[10]!==n.resetStore||t[11]!==l||t[12]!==u?(p=(0,Z.jsxs)(f,{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]=p):p=t[13];let m;t[14]!==o||t[15]!==n.confirmClearLock?(m=()=>{confirm(n.confirmClearLock)&&o(`clear_lock`)},t[14]=o,t[15]=n.confirmClearLock,t[16]=m):m=t[16];let h;t[17]===a?h=t[18]:(h=a===`clear_lock`?(0,Z.jsx)(w,{className:`mr-2 size-4 animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(E,{className:`mr-2 size-4`,"aria-hidden":!0}),t[17]=a,t[18]=h);let g;t[19]!==r||t[20]!==n.clearLock||t[21]!==m||t[22]!==h?(g=(0,Z.jsxs)(f,{variant:`secondary`,disabled:r,onClick:m,children:[h,n.clearLock]}),t[19]=r,t[20]=n.clearLock,t[21]=m,t[22]=h,t[23]=g):g=t[23];let _;t[24]!==p||t[25]!==g?(_=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[p,g]}),t[24]=p,t[25]=g,t[26]=_):_=t[26];let v;return t[27]!==c||t[28]!==_?(v=(0,Z.jsxs)(ee,{className:s,children:[c,_]}),t[27]=c,t[28]=_,t[29]=v):v=t[29],v}function De(e){let t=(0,L.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)(w,{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)(f,{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)(A,{className:le,icon:O,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 p;t[13]!==a||t[14]!==n.previewEligible||t[15]!==n.previewEmpty||t[16]!==n.previewNotLoaded?(p=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 border border-edge-subtle bg-surface-panel/60 px-2.5 py-2`,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]=p):p=t[17];let m;return t[18]!==d||t[19]!==p?(m=(0,Z.jsxs)(ee,{className:ce,children:[d,p]}),t[18]=d,t[19]=p,t[20]=m):m=t[20],m}function Oe(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 ke={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`})},Ae={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 je(e,t){return e.startsWith(`zh`)?Ae[t]:ke[t]}function Me(e,t,n){let r=Math.max(1e3,Math.round(e));if(n&&N.has(r)){let e=Oe(r,n);if(e)return e}let i=Math.max(1,Math.round(r/1e3));if(i<120)return je(t,`second`).format(i);let a=Math.round(i/60);if(a<120)return je(t,`minute`).format(a);let o=Math.round(a/60);return je(t,`hour`).format(o)}function Ne(e){let t=(0,L.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`?F(e.expression,e.locale,e.labels,{timezone:e.timezone,nextRun:e.nextRun}):Me(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 Pe(e){let t=(0,L.c)(100),{t:n,data:r,isLoading:a,localeTag:o,scheduleBadgeLabels:s}=e,c;t[0]!==r||t[1]!==n?(c=r?de(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=i(`min-w-0`,ce),t[3]=u):u=t[3];let d;t[4]===a?d=t[5]:(d=a?(0,Z.jsx)(w,{className:`size-4 shrink-0 animate-spin text-fg-muted`,"aria-hidden":!0}):null,t[4]=a,t[5]=d);let f;t[6]!==n.runtimeHint||t[7]!==n.runtimeTitle||t[8]!==d?(f=(0,Z.jsx)(A,{className:le,icon:g,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 p;t[10]===n.subsectionSchedule?p=t[11]:(p=(0,Z.jsx)(me,{label:n.subsectionSchedule,className:`mb-2`}),t[10]=n.subsectionSchedule,t[11]=p);let m=r?r.config.enabled?n.on:n.off:`—`,h;t[12]!==n.enabled||t[13]!==m?(h=(0,Z.jsx)($,{label:n.enabled,children:m}),t[12]=n.enabled,t[13]=m,t[14]=h):h=t[14];let _=l?.className,v=l?l.text:`—`,y;t[15]!==_||t[16]!==v?(y=(0,Z.jsx)(`span`,{className:_,children:v}),t[15]=_,t[16]=v,t[17]=y):y=t[17];let b;t[18]!==n.lock||t[19]!==y?(b=(0,Z.jsx)($,{label:n.lock,children:y}),t[18]=n.lock,t[19]=y,t[20]=b):b=t[20];let C=r&&r.config.timezone||`—`,E;t[21]!==n.timezone||t[22]!==C?(E=(0,Z.jsx)($,{label:n.timezone,children:C}),t[21]=n.timezone,t[22]=C,t[23]=E):E=t[23];let D;t[24]!==r||t[25]!==o||t[26]!==s?(D=r?(0,Z.jsx)(Ne,{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 j;t[34]!==b||t[35]!==E||t[36]!==k||t[37]!==h?(j=(0,Z.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-3 gap-y-2 sm:grid-cols-4`,children:[h,b,E,k]}),t[34]=b,t[35]=E,t[36]=k,t[37]=h,t[38]=j):j=t[38];let M;t[39]!==j||t[40]!==p?(M=(0,Z.jsxs)(`div`,{className:J,children:[p,j]}),t[39]=j,t[40]=p,t[41]=M):M=t[41];let te;t[42]===n.subsectionStore?te=t[43]:(te=(0,Z.jsx)(me,{label:n.subsectionStore,className:`mb-2`}),t[42]=n.subsectionStore,t[43]=te);let N=r?String(r.store.entryCount):`—`,P;t[44]!==n.storeEntries||t[45]!==N?(P=(0,Z.jsx)($,{label:n.storeEntries,children:N}),t[44]=n.storeEntries,t[45]=N,t[46]=P):P=t[46];let I=r?String(r.store.promotedCount):`—`,R;t[47]!==n.storePromoted||t[48]!==I?(R=(0,Z.jsx)($,{label:n.storePromoted,children:I}),t[47]=n.storePromoted,t[48]=I,t[49]=R):R=t[49];let z;t[50]===r?z=t[51]:(z=r?ue(r.store.updatedAt):`—`,t[50]=r,t[51]=z);let ne;t[52]!==n.storeUpdatedAt||t[53]!==z?(ne=(0,Z.jsx)($,{label:n.storeUpdatedAt,children:z}),t[52]=n.storeUpdatedAt,t[53]=z,t[54]=ne):ne=t[54];let re;t[55]===r?re=t[56]:(re=r?ue(r.store.lastPromotedAt):`—`,t[55]=r,t[56]=re);let ie;t[57]!==n.storeLastPromotedAt||t[58]!==re?(ie=(0,Z.jsx)($,{label:n.storeLastPromotedAt,children:re}),t[57]=n.storeLastPromotedAt,t[58]=re,t[59]=ie):ie=t[59];let ae;t[60]!==P||t[61]!==R||t[62]!==ne||t[63]!==ie?(ae=(0,Z.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-3 gap-y-2 sm:grid-cols-4`,children:[P,R,ne,ie]}),t[60]=P,t[61]=R,t[62]=ne,t[63]=ie,t[64]=ae):ae=t[64];let B;t[65]!==te||t[66]!==ae?(B=(0,Z.jsxs)(`div`,{className:J,children:[te,ae]}),t[65]=te,t[66]=ae,t[67]=B):B=t[67];let V;t[68]!==r||t[69]!==o||t[70]!==s||t[71]!==n?(V=r?.config?.phases?(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(me,{label:n.subsectionPhases,className:`mb-2`}),(0,Z.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[(0,Z.jsx)(ge,{icon:(0,Z.jsx)(S,{className:`size-4 text-amber-500`}),label:`Light`,enabled:r.config.phases.light.enabled,cron:r.config.phases.light.cron,scheduleSummary:F(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)(ge,{icon:(0,Z.jsx)(T,{className:`size-4 text-indigo-500`}),label:`Deep`,enabled:r.config.phases.deep.enabled,cron:r.config.phases.deep.cron,scheduleSummary:F(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}, limit=${r.config.phases.deep.limit}, halfLife=${r.config.phases.deep.recencyHalfLifeDays}d`,t:n}),(0,Z.jsx)(ge,{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:F(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]=V):V=t[72];let H;t[73]===n.subsectionLastRun?H=t[74]:(H=(0,Z.jsx)(me,{label:n.subsectionLastRun,className:`mb-2`}),t[73]=n.subsectionLastRun,t[74]=H);let U;t[75]===n.lastRunBlockHint?U=t[76]:(U=(0,Z.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:n.lastRunBlockHint}),t[75]=n.lastRunBlockHint,t[76]=U);let W;t[77]!==r||t[78]!==n?(W=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 border border-edge-subtle/80 bg-surface-panel/50 p-2.5`,children:(0,Z.jsx)(ve,{t:n,r:r.lastRun.record})}):null,r.lastRun.raw!==void 0&&r.lastRun.raw!==null?(0,Z.jsxs)(`details`,{className:`group rounded-lg border border-edge-subtle`,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 border-t border-edge-subtle 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]=W):W=t[79];let G;t[80]!==H||t[81]!==U||t[82]!==W?(G=(0,Z.jsxs)(`div`,{className:J,children:[H,U,W]}),t[80]=H,t[81]=U,t[82]=W,t[83]=G):G=t[83];let K=r?.lightLastRun,q;t[84]!==n||t[85]!==K?(q=(0,Z.jsx)(_e,{label:n.subsectionLightLastRun,lastRun:K,t:n}),t[84]=n,t[85]=K,t[86]=q):q=t[86];let oe=r?.remLastRun,se;t[87]!==n||t[88]!==oe?(se=(0,Z.jsx)(_e,{label:n.subsectionRemLastRun,lastRun:oe,t:n}),t[87]=n,t[88]=oe,t[89]=se):se=t[89];let Y;t[90]!==M||t[91]!==B||t[92]!==V||t[93]!==G||t[94]!==q||t[95]!==se?(Y=(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[M,B,V,G,q,se]}),t[90]=M,t[91]=B,t[92]=V,t[93]=G,t[94]=q,t[95]=se,t[96]=Y):Y=t[96];let X;return t[97]!==Y||t[98]!==f?(X=(0,Z.jsxs)(ee,{className:u,children:[f,Y]}),t[97]=Y,t[98]=f,t[99]=X):X=t[99],X}var Fe=[`config`,`runtime`,`insights`,`maintenance`],Ie={config:k,runtime:g,insights:O,maintenance:y};function Le(e){return e&&Fe.includes(e)?e:`config`}function Re(e,t){return t===`config`?e.tabConfig:t===`runtime`?e.tabRuntime:t===`insights`?e.tabInsights:e.tabMaintenance}function ze(e,t){return t===`config`?e.configTabHint:t===`runtime`?e.runtimeTabHint:t===`insights`?e.insightsTabHint:e.maintenanceTabHint}function Be(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 Ve={actionBusy:null,actionError:null,actionOk:!1,runBusy:!1,runOk:!1,runError:null,runPhase:`deep`,cfgSaving:!1,cfgOk:!1,cfgError:null,previewLoading:!1,previewError:null,previewItems:null,eventsLoading:!1,eventsError:null,events:null};function He(){let e=o(e=>e.language),t=a(e),n=t.dreamingSettings,r=t.cron.schedulePicker,i=t.cron.scheduleBadge,c=e===`zh`?`zh-CN`:`en-US`,l=!!s(e=>e.token),[d,f]=v(),p=Le(d.get(`tab`)),m=(0,I.useCallback)(e=>{f(t=>{let n=new URLSearchParams(t);return e===`config`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},[f]),[h,g]=(0,I.useReducer)(D,Ve),{actionBusy:_,actionError:y,runBusy:b,runError:x,runPhase:S,cfgSaving:C,cfgError:w,previewLoading:T,previewError:E,previewItems:O,eventsLoading:k,eventsError:A,events:ee}=h,[j,M]=(0,I.useReducer)(Be,{form:null,baseline:null}),N=j.form,P=j.baseline,F=(0,I.useRef)(!1),{data:L,error:B,isLoading:V,mutate:H}=u(l?R():null,z,{revalidateOnFocus:!1}),U=(0,I.useMemo)(()=>{let e=[];return B&&e.push(B instanceof Error?B.message:String(B)),y&&e.push(y),x&&e.push(x),E&&e.push(E),A&&e.push(A),w&&e.push(w),e},[B,y,x,E,A,w]),W=(0,I.useCallback)(async()=>{g({type:`patch`,patch:{actionOk:!1,actionError:null,runOk:!1,runError:null,cfgOk:!1,cfgError:null,previewError:null}}),await H()},[H]),G=(0,I.useCallback)(async()=>{g({type:`patch`,patch:{previewLoading:!0,previewError:null}});try{g({type:`patch`,patch:{previewItems:(await ie(20)).items??[]}})}catch(e){g({type:`patch`,patch:{previewError:e instanceof Error?e.message:String(e)}})}finally{g({type:`patch`,patch:{previewLoading:!1}})}},[]),K=(0,I.useCallback)(async()=>{g({type:`patch`,patch:{eventsLoading:!0,eventsError:null}});try{g({type:`patch`,patch:{events:await ae(50)}})}catch(e){g({type:`patch`,patch:{eventsError:e instanceof Error?e.message:String(e)}})}finally{g({type:`patch`,patch:{eventsLoading:!1}})}},[]),q=(0,I.useCallback)(async(e=`deep`)=>{g({type:`patch`,patch:{runBusy:!0,runOk:!1,runError:null}});try{await re(e),g({type:`patch`,patch:{runOk:!0}}),await H()}catch(e){g({type:`patch`,patch:{runError:e instanceof Error?e.message:String(e)}})}finally{g({type:`patch`,patch:{runBusy:!1}})}},[H]),ce=(0,I.useCallback)(async e=>{g({type:`patch`,patch:{actionBusy:e,actionError:null,actionOk:!1}});try{await ne(e),g({type:`patch`,patch:{actionOk:!0}}),await H()}catch(e){g({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{g({type:`patch`,patch:{actionBusy:null}})}},[H]),le=!l||V||!!_,J=(0,I.useMemo)(()=>{let e=L?.config;return oe(e??{})},[L]),Y=L?.agentId??`main`,ue=L?.memory;(0,I.useEffect)(()=>{if(!l){M({type:`reset`}),F.current=!1;return}F.current||M({type:`sync`,value:J})},[J,l]);let X=(0,I.useMemo)(()=>!N||!P?!1:JSON.stringify(N)!==JSON.stringify(P),[N,P]);return(0,Z.jsxs)(te,{children:[(0,Z.jsx)(Te,{t:n,hasToken:l,cfgForm:N,cfgSaving:C,cfgDirty:X,saveConfig:(0,I.useCallback)(async()=>{if(N){g({type:`patch`,patch:{cfgSaving:!0,cfgOk:!1,cfgError:null}});try{await se(Y,N,ue),M({type:`saved`,value:N}),F.current=!1,g({type:`patch`,patch:{cfgOk:!0}}),await H()}catch(e){g({type:`patch`,patch:{cfgError:e instanceof Error?e.message:String(e)}})}finally{g({type:`patch`,patch:{cfgSaving:!1}})}}},[Y,ue,N,H]),doRefresh:W}),U.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:U.map(e=>(0,Z.jsx)(`p`,{className:`text-sm text-amber-800 dark:text-amber-200/90`,children:e},e))}):null,(0,Z.jsx)(Ue,{t:n,activeTab:p,onChange:m}),(0,Z.jsx)(We,{t:n,id:`config`,activeTab:p,children:(0,Z.jsx)(ye,{t:n,schedulePickerLabels:r,hasToken:l,cfgForm:N,cfgBaseline:P,cfgDirty:X,cfgSaving:C,runPhase:S,setRunPhase:e=>g({type:`patch`,patch:{runPhase:e}}),runBusy:b,setCfgForm:e=>{F.current=!0;let t=typeof e==`function`?e(N):e;t&&M({type:`set`,value:t})},doRunNow:q})}),(0,Z.jsx)(We,{t:n,id:`runtime`,activeTab:p,children:(0,Z.jsx)(Pe,{t:n,data:L,isLoading:V,localeTag:c,scheduleBadgeLabels:i})}),(0,Z.jsx)(We,{t:n,id:`insights`,activeTab:p,children:(0,Z.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-2`,children:[(0,Z.jsx)(De,{t:n,hasToken:l,previewLoading:T,previewItems:O,loadPreview:G}),(0,Z.jsx)(Ce,{t:n,hasToken:l,eventsLoading:k,events:ee,loadEvents:K})]})}),(0,Z.jsx)(We,{t:n,id:`maintenance`,activeTab:p,children:(0,Z.jsx)(Ee,{t:n,disabled:le,actionBusy:_,doAction:ce})})]})}function Ue(e){let t=(0,L.c)(7),{t:n,activeTab:r,onChange:i}=e,a;t[0]===n?a=t[1]:(a=Fe.map(e=>({id:e,label:Re(n,e),icon:Ie[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)(p,{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 We(e){let t=(0,L.c)(13),{t:n,id:r,activeTab:i,children:a}=e,o=r!==`config`,s;t[0]!==r||t[1]!==n?(s=Re(n,r),t[0]=r,t[1]=n,t[2]=s):s=t[2];let c;t[3]!==r||t[4]!==n?(c=ze(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)(M,{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{He as DreamingSettingsPanel};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-O6TAtdFC.js";import{n as o}from"./locale-store-Ba72bFmP.js";import{c as s,i as c,n as l}from"./fetch-BU5S0Sn7.js";import{i as u}from"./vendor-swr-BIWyz7Rc.js";import{H as d,Jo as f,La as p,Lo as m,Mi as h,Nc as g,To as _,Va as v,Wa as y,ao as b,bo as x,eo as S,ko as C,ns as w,po as T,rs as E,ut as D,vs as O,zc as k}from"./index-c_9TVr_C.js";import{n as A,t as ee}from"./settings-form-section-BnqYMWHR.js";import{n as j,r as M,t as te}from"./settings-page-layout-CdWZU1hd.js";import{n as N,t as P}from"./schedule-field-DVZcI8Yt.js";import{t as F}from"./format-cron-label-arqgGlVV.js";var I=e(t(),1),L=n();function R(){return c(`/api/dreaming`)}async function ne(){let e=await l(R());if(!e.payload)throw Error(`Missing payload`);return e.payload}async function z(e){await l(c(`/api/dreaming/action`),{method:`POST`,body:JSON.stringify({action:e})})}async function re(e=`deep`){let t=await l(c(`/api/dreaming/run`),{method:`POST`,body:JSON.stringify({phase:e})});if(t.ok===!1||!t.payload)throw Error(`Failed to run dreaming phase`);let n=t.payload.phase;return{phase:n===`light`||n===`deep`||n===`rem`?n:e,result:t.payload.result}}async function ie(e){let t=await l(c(`/api/dreaming/preview${typeof e==`number`&&Number.isFinite(e)?`?limit=${encodeURIComponent(String(e))}`:``}`));if(!t.payload)throw Error(`Missing payload`);return t.payload}async function ae(e=50){return(await l(c(`/api/dreaming/events${`?limit=${encodeURIComponent(String(e))}`}`))).payload?.events??[]}function B(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var V={enabled:!0,cron:`0 */6 * * *`,lookbackDays:1,limit:50,dedupeSimilarity:.85},H={enabled:!0,cron:`0 3 * * *`,minScore:.8,minRecallCount:3,limit:10,recencyHalfLifeDays:14,maxAgeDays:30},U={enabled:!0,cron:`0 5 * * 0`,lookbackDays:7,limit:20,minPatternStrength:.6},W={enabled:!1,frequency:`0 3 * * *`,timezone:``,deepEnabled:!0,minScore:.8,minRecallCount:3,limit:10,light:V,deep:H,rem:U};function G(e,t){return Number.isFinite(e)?Math.max(0,Math.min(1,e)):t}function K(e,t){let n=typeof e==`string`?Number(e):e;return Number.isFinite(n)?Math.max(0,Math.floor(n)):t}function q(e,t){let n=typeof e==`string`?Number(e):e;return Number.isFinite(n)?n:t}function oe(e){let t=B(e)?e:{},n=B(t.memory)?t.memory:{},r=B(t.dreaming)?t.dreaming:{},i=typeof t.enabled==`boolean`||typeof t.frequency==`string`||B(t.phases)?t:{},a=B(n.dreaming)?n.dreaming:Object.keys(r).length>0?r:i,o=B(a.phases)?a.phases:{},s=B(o.light)?o.light:{},c=B(o.deep)?o.deep:{},l=B(o.rem)?o.rem:{};return{enabled:a.enabled===!0,frequency:typeof a.frequency==`string`&&a.frequency.trim()?a.frequency.trim():W.frequency,timezone:typeof a.timezone==`string`?a.timezone:``,deepEnabled:c.enabled!==!1,minScore:G(typeof c.minScore==`number`?c.minScore:Number(c.minScore),W.minScore),minRecallCount:Math.max(1,K(c.minRecallCount,W.minRecallCount)),limit:K(c.limit,W.limit),light:{enabled:s.enabled!==!1,cron:typeof s.cron==`string`&&s.cron.trim()?s.cron.trim():V.cron,lookbackDays:Math.max(1,K(s.lookbackDays,V.lookbackDays)),limit:K(s.limit,V.limit),dedupeSimilarity:G(q(s.dedupeSimilarity,V.dedupeSimilarity),V.dedupeSimilarity)},deep:{enabled:c.enabled!==!1,cron:typeof c.cron==`string`&&c.cron.trim()?c.cron.trim():H.cron,minScore:G(q(c.minScore,H.minScore),H.minScore),minRecallCount:Math.max(1,K(c.minRecallCount,H.minRecallCount)),limit:K(c.limit,H.limit),recencyHalfLifeDays:Math.max(1,q(c.recencyHalfLifeDays,H.recencyHalfLifeDays)),maxAgeDays:Math.max(1,q(c.maxAgeDays,H.maxAgeDays))},rem:{enabled:l.enabled!==!1,cron:typeof l.cron==`string`&&l.cron.trim()?l.cron.trim():U.cron,lookbackDays:Math.max(1,K(l.lookbackDays,U.lookbackDays)),limit:K(l.limit,U.limit),minPatternStrength:G(q(l.minPatternStrength,U.minPatternStrength),U.minPatternStrength)}}}async function se(e,t,n){let r=t.frequency.trim(),i=t.timezone.trim();await l(c(`/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:B(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:G(t.light.dedupeSimilarity,V.dedupeSimilarity)},deep:{enabled:!!t.deep.enabled,...t.deep.cron.trim()?{cron:t.deep.cron.trim()}:{},minScore:G(t.deep.minScore,H.minScore),minRecallCount:Math.max(1,Math.floor(t.deep.minRecallCount)),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:G(t.rem.minPatternStrength,U.minPatternStrength)}}}}})}),h()}var ce=`p-4 sm:px-5`,le=`mb-3`,J=`rounded-xl border border-edge-subtle bg-surface-panel/30 p-3 sm:p-4`,Y=i(`mt-1 w-full rounded-lg border border-edge-subtle bg-surface-panel px-2.5 py-1.5 text-sm text-fg`,p);function ue(e){return e?e.replace(`T`,` `).replace(`Z`,``):`—`}function X(e){return e===void 0||!Number.isFinite(e)||e<0?`—`:e<1e3?`${Math.round(e)} ms`:`${(e/1e3).toFixed(2)} s`}function de(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(),fe=`text-xs font-medium text-fg-muted`,pe=`text-sm font-medium text-fg`;function Q(e){let t=(0,L.c)(6),{label:n,children:r,className:i}=e,a;t[0]===n?a=t[1]:(a=(0,Z.jsx)(`span`,{className:fe,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,L.c)(11),{label:n,children:r,className:a}=e,o;t[0]===a?o=t[1]:(o=i(`min-w-0`,a),t[0]=a,t[1]=o);let s;t[2]===n?s=t[3]:(s=(0,Z.jsx)(`dt`,{className:fe,children:n}),t[2]=n,t[3]=s);let c;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(c=i(pe,`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 me(e){let t=(0,L.c)(5),{label:n,className:r}=e,a;t[0]===r?a=t[1]:(a=i(`text-[0.7rem] font-semibold uppercase tracking-wider text-fg-muted`,r),t[0]=r,t[1]=a);let o;return t[2]!==n||t[3]!==a?(o=(0,Z.jsx)(`h3`,{className:a,children:n}),t[2]=n,t[3]=a,t[4]=o):o=t[4],o}function he(e){let t=(0,L.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 border-b border-edge-subtle/80 pb-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)(P,{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:J,children:[D,O,k]}),t[35]=O,t[36]=k,t[37]=D,t[38]=A):A=t[38],A}function ge(e){let t=(0,L.c)(23),{icon:n,label:r,enabled:a,cron:o,scheduleSummary:s,details:c,t:l}=e,u;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(u=i(J,`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=a?`text-emerald-600 dark:text-emerald-400`:`text-fg-muted`,p;t[3]===f?p=t[4]:(p=i(`ml-auto text-xs font-medium`,f),t[3]=f,t[4]=p);let m=a?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 _e(e){let t=(0,L.c)(9),{label:n,lastRun:r,t:i}=e,a;t[0]===n?a=t[1]:(a=(0,Z.jsx)(me,{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 border border-edge-subtle`,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 border-t border-edge-subtle 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:`border-t border-edge-subtle/80 pt-3`,children:[a,o]}),t[6]=a,t[7]=o,t[8]=s):s=t[8],s}function ve(e){let t=(0,L.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=X(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 ye(e){let t=(0,L.c)(56),{t:n,schedulePickerLabels:r,hasToken:a,cfgForm:o,cfgBaseline:s,cfgDirty:c,cfgSaving:l,runPhase:u,setRunPhase:d,runBusy:p,setCfgForm:m,doRunNow:h}=e,g;t[0]!==c||t[1]!==o?.enabled||t[2]!==l||t[3]!==h||t[4]!==a||t[5]!==p||t[6]!==u||t[7]!==d||t[8]!==n?(g=(e,t)=>o?.enabled?(0,Z.jsx)(Se,{t:n,busy:p&&u===e,disabled:!a||l||p||!t||c,title:c?n.runNowSaveFirstHint:n.runNowHint,onClick:()=>{d(e),h(e)}}):null,t[0]=c,t[1]=o?.enabled,t[2]=l,t[3]=h,t[4]=a,t[5]=p,t[6]=u,t[7]=d,t[8]=n,t[9]=g):g=t[9];let _=g,v;t[10]!==s||t[11]!==o||t[12]!==n.phasePendingSave||t[13]!==n.phaseWillDisable||t[14]!==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[10]=s,t[11]=o,t[12]=n.phasePendingSave,t[13]=n.phaseWillDisable,t[14]=n.phaseWillEnable,t[15]=v):v=t[15];let y=v,x;return t[16]!==c||t[17]!==o||t[18]!==l||t[19]!==a||t[20]!==y||t[21]!==_||t[22]!==r||t[23]!==m||t[24]!==n.configDeepHalfLife||t[25]!==n.configDeepLimit||t[26]!==n.configDeepMaxAge||t[27]!==n.configDeepMinRecallCount||t[28]!==n.configDeepMinScore||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?(x=(0,Z.jsx)(ee,{className:`min-w-0 !p-0`,children:o?(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[(0,Z.jsxs)(`div`,{className:i(J,`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:i(`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:!a||l,onChange:e=>m(t=>t&&{...t,enabled:e.target.checked})}),(0,Z.jsx)(`span`,{className:i(`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)(O,{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)(be,{title:n.scheduleTitle}),(0,Z.jsx)(`div`,{className:J,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)(P,{kind:`cron`,label:n.configFrequency,value:o.frequency,onChange:e=>m(t=>t&&{...t,frequency:e}),labels:r,disabled:!a||l})}),(0,Z.jsx)(Q,{label:n.configTimezone,className:`lg:col-span-3`,children:(0,Z.jsx)(`input`,{className:Y,value:o.timezone,disabled:!a||l,onChange:e=>m(t=>t&&{...t,timezone:e.target.value}),placeholder:`Asia/Shanghai`})})]})})]}),(0,Z.jsxs)(`div`,{className:`space-y-2`,children:[(0,Z.jsx)(be,{title:n.phasesTitle}),(0,Z.jsxs)(he,{icon:(0,Z.jsx)(b,{className:`size-4 text-amber-500`}),title:n.configPhaseLight,hint:n.configPhaseLightHint,enabled:o.light.enabled,onEnabledChange:e=>m(t=>t&&{...t,light:{...t.light,enabled:e}}),cron:o.light.cron,onCronChange:e=>m(t=>t&&{...t,light:{...t.light,cron:e}}),scheduleLabels:r,disabled:!a||l,showEnabledControl:o.enabled,actions:_(`light`,o.light.enabled),status:y(`light`)?(0,Z.jsx)(xe,{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:Y,value:o.light.lookbackDays,disabled:!a||l,onChange:e=>m(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:Y,value:o.light.limit,disabled:!a||l,onChange:e=>m(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:Y,value:o.light.dedupeSimilarity,disabled:!a||l,onChange:e=>m(t=>t&&{...t,light:{...t.light,dedupeSimilarity:Number(e.target.value)}})})})]}),(0,Z.jsxs)(he,{icon:(0,Z.jsx)(f,{className:`size-4 text-indigo-500`}),title:n.configPhaseDeep,hint:n.configPhaseDeepHint,enabled:o.deep.enabled,onEnabledChange:e=>m(t=>t&&{...t,deep:{...t.deep,enabled:e}}),cron:o.deep.cron,onCronChange:e=>m(t=>t&&{...t,deep:{...t.deep,cron:e}}),scheduleLabels:r,disabled:!a||l,showEnabledControl:o.enabled,actions:_(`deep`,o.deep.enabled),status:y(`deep`)?(0,Z.jsx)(xe,{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:Y,value:o.deep.minScore,disabled:!a||l,onChange:e=>m(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:Y,value:o.deep.minRecallCount,disabled:!a||l,onChange:e=>m(t=>t&&{...t,deep:{...t.deep,minRecallCount:Number(e.target.value)}})})}),(0,Z.jsx)(Q,{label:n.configDeepLimit,children:(0,Z.jsx)(`input`,{type:`number`,step:`1`,min:0,className:Y,value:o.deep.limit,disabled:!a||l,onChange:e=>m(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:Y,value:o.deep.recencyHalfLifeDays,disabled:!a||l,onChange:e=>m(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:Y,value:o.deep.maxAgeDays,disabled:!a||l,onChange:e=>m(t=>t&&{...t,deep:{...t.deep,maxAgeDays:Number(e.target.value)}})})})]}),(0,Z.jsxs)(he,{icon:(0,Z.jsx)(T,{className:`size-4 text-purple-500`}),title:n.configPhaseRem,hint:n.configPhaseRemHint,enabled:o.rem.enabled,onEnabledChange:e=>m(t=>t&&{...t,rem:{...t.rem,enabled:e}}),cron:o.rem.cron,onCronChange:e=>m(t=>t&&{...t,rem:{...t.rem,cron:e}}),scheduleLabels:r,disabled:!a||l,showEnabledControl:o.enabled,actions:_(`rem`,o.rem.enabled),status:y(`rem`)?(0,Z.jsx)(xe,{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:Y,value:o.rem.lookbackDays,disabled:!a||l,onChange:e=>m(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:Y,value:o.rem.limit,disabled:!a||l,onChange:e=>m(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:Y,value:o.rem.minPatternStrength,disabled:!a||l,onChange:e=>m(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[16]=c,t[17]=o,t[18]=l,t[19]=a,t[20]=y,t[21]=_,t[22]=r,t[23]=m,t[24]=n.configDeepHalfLife,t[25]=n.configDeepLimit,t[26]=n.configDeepMaxAge,t[27]=n.configDeepMinRecallCount,t[28]=n.configDeepMinScore,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]=x):x=t[55],x}function be(e){let t=(0,L.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 xe(e){let t=(0,L.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 Se(e){let t=(0,L.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)(E,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(m,{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)(v,{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 Ce(e){let t=(0,L.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)(E,{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)(v,{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)(A,{className:le,icon:g,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(we)}):(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)(ee,{className:ce,children:[d,f]}),t[17]=d,t[18]=f,t[19]=p):p=t[19],p}function we(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 border border-edge-subtle bg-surface-panel/60 px-3 py-2 text-xs`,children:[(0,Z.jsx)(`span`,{children:t}),(0,Z.jsx)(`span`,{className:`font-medium text-fg`,children:e.phase}),(0,Z.jsx)(`span`,{className:i(`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:X(e.durationMs)}),(0,Z.jsx)(`span`,{className:`ml-auto text-fg-subtle`,children:ue(e.timestamp)})]},`${e.timestamp}:${e.phase}`)}function Te(e){let t=(0,L.c)(23),{t:n,hasToken:r,cfgForm:i,cfgSaving:a,cfgDirty:o,saveConfig:s,doRefresh:c}=e,l=!r||!i||a||!o,u;t[0]===s?u=t[1]:(u=()=>void s(),t[0]=s,t[1]=u);let d;t[2]===a?d=t[3]:(d=a?(0,Z.jsx)(E,{className:`size-4 animate-spin`,"aria-hidden":!0}):null,t[2]=a,t[3]=d);let f;t[4]!==n.saveConfig||t[5]!==l||t[6]!==u||t[7]!==d?(f=(0,Z.jsxs)(v,{type:`button`,variant:`primary`,disabled:l,onClick:u,children:[d,n.saveConfig]}),t[4]=n.saveConfig,t[5]=l,t[6]=u,t[7]=d,t[8]=f):f=t[8];let p=!r,m;t[9]===c?m=t[10]:(m=()=>void c(),t[9]=c,t[10]=m);let h;t[11]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,Z.jsx)(C,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[11]=h):h=t[11];let g;t[12]!==n.refresh||t[13]!==p||t[14]!==m?(g=(0,Z.jsx)(v,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,disabled:p,title:n.refresh,"aria-label":n.refresh,onClick:m,children:h}),t[12]=n.refresh,t[13]=p,t[14]=m,t[15]=g):g=t[15];let _;t[16]!==f||t[17]!==g?(_=(0,Z.jsxs)(Z.Fragment,{children:[f,g]}),t[16]=f,t[17]=g,t[18]=_):_=t[18];let y;return t[19]!==n.subtitle||t[20]!==n.title||t[21]!==_?(y=(0,Z.jsx)(j,{title:n.title,subtitle:n.subtitle,actions:_}),t[19]=n.subtitle,t[20]=n.title,t[21]=_,t[22]=y):y=t[22],y}function Ee(e){let t=(0,L.c)(30),{t:n,disabled:r,actionBusy:a,doAction:o}=e,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=i(`max-w-2xl`,ce),t[0]=s):s=t[0];let c;t[1]!==n.maintenanceHint||t[2]!==n.maintenanceTitle?(c=(0,Z.jsx)(A,{className:le,icon:y,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]===a?u=t[8]:(u=a===`reset_store`?(0,Z.jsx)(E,{className:`mr-2 size-4 animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(S,{className:`mr-2 size-4`,"aria-hidden":!0}),t[7]=a,t[8]=u);let d;t[9]!==r||t[10]!==n.resetStore||t[11]!==l||t[12]!==u?(d=(0,Z.jsxs)(v,{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 f;t[14]!==o||t[15]!==n.confirmClearLock?(f=()=>{confirm(n.confirmClearLock)&&o(`clear_lock`)},t[14]=o,t[15]=n.confirmClearLock,t[16]=f):f=t[16];let p;t[17]===a?p=t[18]:(p=a===`clear_lock`?(0,Z.jsx)(E,{className:`mr-2 size-4 animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(w,{className:`mr-2 size-4`,"aria-hidden":!0}),t[17]=a,t[18]=p);let m;t[19]!==r||t[20]!==n.clearLock||t[21]!==f||t[22]!==p?(m=(0,Z.jsxs)(v,{variant:`secondary`,disabled:r,onClick:f,children:[p,n.clearLock]}),t[19]=r,t[20]=n.clearLock,t[21]=f,t[22]=p,t[23]=m):m=t[23];let h;t[24]!==d||t[25]!==m?(h=(0,Z.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[d,m]}),t[24]=d,t[25]=m,t[26]=h):h=t[26];let g;return t[27]!==c||t[28]!==h?(g=(0,Z.jsxs)(ee,{className:s,children:[c,h]}),t[27]=c,t[28]=h,t[29]=g):g=t[29],g}function De(e){let t=(0,L.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)(E,{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)(v,{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)(A,{className:le,icon:_,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 border border-edge-subtle bg-surface-panel/60 px-2.5 py-2`,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)(ee,{className:ce,children:[d,f]}),t[18]=d,t[19]=f,t[20]=p):p=t[20],p}function Oe(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 ke={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`})},Ae={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 je(e,t){return e.startsWith(`zh`)?Ae[t]:ke[t]}function Me(e,t,n){let r=Math.max(1e3,Math.round(e));if(n&&N.has(r)){let e=Oe(r,n);if(e)return e}let i=Math.max(1,Math.round(r/1e3));if(i<120)return je(t,`second`).format(i);let a=Math.round(i/60);if(a<120)return je(t,`minute`).format(a);let o=Math.round(a/60);return je(t,`hour`).format(o)}function Ne(e){let t=(0,L.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`?F(e.expression,e.locale,e.labels,{timezone:e.timezone,nextRun:e.nextRun}):Me(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 Pe(e){let t=(0,L.c)(100),{t:n,data:r,isLoading:a,localeTag:o,scheduleBadgeLabels:s}=e,c;t[0]!==r||t[1]!==n?(c=r?de(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=i(`min-w-0`,ce),t[3]=u):u=t[3];let d;t[4]===a?d=t[5]:(d=a?(0,Z.jsx)(E,{className:`size-4 shrink-0 animate-spin text-fg-muted`,"aria-hidden":!0}):null,t[4]=a,t[5]=d);let p;t[6]!==n.runtimeHint||t[7]!==n.runtimeTitle||t[8]!==d?(p=(0,Z.jsx)(A,{className:le,icon:g,title:n.runtimeTitle,subtitle:n.runtimeHint,trailing:d}),t[6]=n.runtimeHint,t[7]=n.runtimeTitle,t[8]=d,t[9]=p):p=t[9];let m;t[10]===n.subsectionSchedule?m=t[11]:(m=(0,Z.jsx)(me,{label:n.subsectionSchedule,className:`mb-2`}),t[10]=n.subsectionSchedule,t[11]=m);let h=r?r.config.enabled?n.on:n.off:`—`,_;t[12]!==n.enabled||t[13]!==h?(_=(0,Z.jsx)($,{label:n.enabled,children:h}),t[12]=n.enabled,t[13]=h,t[14]=_):_=t[14];let v=l?.className,y=l?l.text:`—`,x;t[15]!==v||t[16]!==y?(x=(0,Z.jsx)(`span`,{className:v,children:y}),t[15]=v,t[16]=y,t[17]=x):x=t[17];let S;t[18]!==n.lock||t[19]!==x?(S=(0,Z.jsx)($,{label:n.lock,children:x}),t[18]=n.lock,t[19]=x,t[20]=S):S=t[20];let C=r&&r.config.timezone||`—`,w;t[21]!==n.timezone||t[22]!==C?(w=(0,Z.jsx)($,{label:n.timezone,children:C}),t[21]=n.timezone,t[22]=C,t[23]=w):w=t[23];let D;t[24]!==r||t[25]!==o||t[26]!==s?(D=r?(0,Z.jsx)(Ne,{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 j;t[34]!==S||t[35]!==w||t[36]!==k||t[37]!==_?(j=(0,Z.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-3 gap-y-2 sm:grid-cols-4`,children:[_,S,w,k]}),t[34]=S,t[35]=w,t[36]=k,t[37]=_,t[38]=j):j=t[38];let M;t[39]!==j||t[40]!==m?(M=(0,Z.jsxs)(`div`,{className:J,children:[m,j]}),t[39]=j,t[40]=m,t[41]=M):M=t[41];let te;t[42]===n.subsectionStore?te=t[43]:(te=(0,Z.jsx)(me,{label:n.subsectionStore,className:`mb-2`}),t[42]=n.subsectionStore,t[43]=te);let N=r?String(r.store.entryCount):`—`,P;t[44]!==n.storeEntries||t[45]!==N?(P=(0,Z.jsx)($,{label:n.storeEntries,children:N}),t[44]=n.storeEntries,t[45]=N,t[46]=P):P=t[46];let I=r?String(r.store.promotedCount):`—`,R;t[47]!==n.storePromoted||t[48]!==I?(R=(0,Z.jsx)($,{label:n.storePromoted,children:I}),t[47]=n.storePromoted,t[48]=I,t[49]=R):R=t[49];let ne;t[50]===r?ne=t[51]:(ne=r?ue(r.store.updatedAt):`—`,t[50]=r,t[51]=ne);let z;t[52]!==n.storeUpdatedAt||t[53]!==ne?(z=(0,Z.jsx)($,{label:n.storeUpdatedAt,children:ne}),t[52]=n.storeUpdatedAt,t[53]=ne,t[54]=z):z=t[54];let re;t[55]===r?re=t[56]:(re=r?ue(r.store.lastPromotedAt):`—`,t[55]=r,t[56]=re);let ie;t[57]!==n.storeLastPromotedAt||t[58]!==re?(ie=(0,Z.jsx)($,{label:n.storeLastPromotedAt,children:re}),t[57]=n.storeLastPromotedAt,t[58]=re,t[59]=ie):ie=t[59];let ae;t[60]!==P||t[61]!==R||t[62]!==z||t[63]!==ie?(ae=(0,Z.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-3 gap-y-2 sm:grid-cols-4`,children:[P,R,z,ie]}),t[60]=P,t[61]=R,t[62]=z,t[63]=ie,t[64]=ae):ae=t[64];let B;t[65]!==te||t[66]!==ae?(B=(0,Z.jsxs)(`div`,{className:J,children:[te,ae]}),t[65]=te,t[66]=ae,t[67]=B):B=t[67];let V;t[68]!==r||t[69]!==o||t[70]!==s||t[71]!==n?(V=r?.config?.phases?(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(me,{label:n.subsectionPhases,className:`mb-2`}),(0,Z.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[(0,Z.jsx)(ge,{icon:(0,Z.jsx)(b,{className:`size-4 text-amber-500`}),label:`Light`,enabled:r.config.phases.light.enabled,cron:r.config.phases.light.cron,scheduleSummary:F(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)(ge,{icon:(0,Z.jsx)(f,{className:`size-4 text-indigo-500`}),label:`Deep`,enabled:r.config.phases.deep.enabled,cron:r.config.phases.deep.cron,scheduleSummary:F(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}, limit=${r.config.phases.deep.limit}, halfLife=${r.config.phases.deep.recencyHalfLifeDays}d`,t:n}),(0,Z.jsx)(ge,{icon:(0,Z.jsx)(T,{className:`size-4 text-purple-500`}),label:`REM`,enabled:r.config.phases.rem.enabled,cron:r.config.phases.rem.cron,scheduleSummary:F(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]=V):V=t[72];let H;t[73]===n.subsectionLastRun?H=t[74]:(H=(0,Z.jsx)(me,{label:n.subsectionLastRun,className:`mb-2`}),t[73]=n.subsectionLastRun,t[74]=H);let U;t[75]===n.lastRunBlockHint?U=t[76]:(U=(0,Z.jsx)(`p`,{className:`mb-2 text-xs text-fg-muted`,children:n.lastRunBlockHint}),t[75]=n.lastRunBlockHint,t[76]=U);let W;t[77]!==r||t[78]!==n?(W=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 border border-edge-subtle/80 bg-surface-panel/50 p-2.5`,children:(0,Z.jsx)(ve,{t:n,r:r.lastRun.record})}):null,r.lastRun.raw!==void 0&&r.lastRun.raw!==null?(0,Z.jsxs)(`details`,{className:`group rounded-lg border border-edge-subtle`,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 border-t border-edge-subtle 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]=W):W=t[79];let G;t[80]!==H||t[81]!==U||t[82]!==W?(G=(0,Z.jsxs)(`div`,{className:J,children:[H,U,W]}),t[80]=H,t[81]=U,t[82]=W,t[83]=G):G=t[83];let K=r?.lightLastRun,q;t[84]!==n||t[85]!==K?(q=(0,Z.jsx)(_e,{label:n.subsectionLightLastRun,lastRun:K,t:n}),t[84]=n,t[85]=K,t[86]=q):q=t[86];let oe=r?.remLastRun,se;t[87]!==n||t[88]!==oe?(se=(0,Z.jsx)(_e,{label:n.subsectionRemLastRun,lastRun:oe,t:n}),t[87]=n,t[88]=oe,t[89]=se):se=t[89];let Y;t[90]!==M||t[91]!==B||t[92]!==V||t[93]!==G||t[94]!==q||t[95]!==se?(Y=(0,Z.jsxs)(`div`,{className:`space-y-3`,children:[M,B,V,G,q,se]}),t[90]=M,t[91]=B,t[92]=V,t[93]=G,t[94]=q,t[95]=se,t[96]=Y):Y=t[96];let X;return t[97]!==Y||t[98]!==p?(X=(0,Z.jsxs)(ee,{className:u,children:[p,Y]}),t[97]=Y,t[98]=p,t[99]=X):X=t[99],X}var Fe=[`config`,`runtime`,`insights`,`maintenance`],Ie={config:x,runtime:g,insights:_,maintenance:y};function Le(e){return e&&Fe.includes(e)?e:`config`}function Re(e,t){return t===`config`?e.tabConfig:t===`runtime`?e.tabRuntime:t===`insights`?e.tabInsights:e.tabMaintenance}function ze(e,t){return t===`config`?e.configTabHint:t===`runtime`?e.runtimeTabHint:t===`insights`?e.insightsTabHint:e.maintenanceTabHint}function Be(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 Ve={actionBusy:null,actionError:null,actionOk:!1,runBusy:!1,runOk:!1,runError:null,runPhase:`deep`,cfgSaving:!1,cfgOk:!1,cfgError:null,previewLoading:!1,previewError:null,previewItems:null,eventsLoading:!1,eventsError:null,events:null};function He(){let e=o(e=>e.language),t=a(e),n=t.dreamingSettings,r=t.cron.schedulePicker,i=t.cron.scheduleBadge,c=e===`zh`?`zh-CN`:`en-US`,l=!!s(e=>e.token),[d,f]=k(),p=Le(d.get(`tab`)),m=(0,I.useCallback)(e=>{f(t=>{let n=new URLSearchParams(t);return e===`config`?n.delete(`tab`):n.set(`tab`,e),n},{replace:!0})},[f]),[h,g]=(0,I.useReducer)(D,Ve),{actionBusy:_,actionError:v,runBusy:y,runError:b,runPhase:x,cfgSaving:S,cfgError:C,previewLoading:w,previewError:T,previewItems:E,eventsLoading:O,eventsError:A,events:ee}=h,[j,M]=(0,I.useReducer)(Be,{form:null,baseline:null}),N=j.form,P=j.baseline,F=(0,I.useRef)(!1),{data:L,error:B,isLoading:V,mutate:H}=u(l?R():null,ne,{revalidateOnFocus:!1}),U=(0,I.useMemo)(()=>{let e=[];return B&&e.push(B instanceof Error?B.message:String(B)),v&&e.push(v),b&&e.push(b),T&&e.push(T),A&&e.push(A),C&&e.push(C),e},[B,v,b,T,A,C]),W=(0,I.useCallback)(async()=>{g({type:`patch`,patch:{actionOk:!1,actionError:null,runOk:!1,runError:null,cfgOk:!1,cfgError:null,previewError:null}}),await H()},[H]),G=(0,I.useCallback)(async()=>{g({type:`patch`,patch:{previewLoading:!0,previewError:null}});try{g({type:`patch`,patch:{previewItems:(await ie(20)).items??[]}})}catch(e){g({type:`patch`,patch:{previewError:e instanceof Error?e.message:String(e)}})}finally{g({type:`patch`,patch:{previewLoading:!1}})}},[]),K=(0,I.useCallback)(async()=>{g({type:`patch`,patch:{eventsLoading:!0,eventsError:null}});try{g({type:`patch`,patch:{events:await ae(50)}})}catch(e){g({type:`patch`,patch:{eventsError:e instanceof Error?e.message:String(e)}})}finally{g({type:`patch`,patch:{eventsLoading:!1}})}},[]),q=(0,I.useCallback)(async(e=`deep`)=>{g({type:`patch`,patch:{runBusy:!0,runOk:!1,runError:null}});try{await re(e),g({type:`patch`,patch:{runOk:!0}}),await H()}catch(e){g({type:`patch`,patch:{runError:e instanceof Error?e.message:String(e)}})}finally{g({type:`patch`,patch:{runBusy:!1}})}},[H]),ce=(0,I.useCallback)(async e=>{g({type:`patch`,patch:{actionBusy:e,actionError:null,actionOk:!1}});try{await z(e),g({type:`patch`,patch:{actionOk:!0}}),await H()}catch(e){g({type:`patch`,patch:{actionError:e instanceof Error?e.message:String(e)}})}finally{g({type:`patch`,patch:{actionBusy:null}})}},[H]),le=!l||V||!!_,J=(0,I.useMemo)(()=>{let e=L?.config;return oe(e??{})},[L]),Y=L?.agentId??`main`,ue=L?.memory;(0,I.useEffect)(()=>{if(!l){M({type:`reset`}),F.current=!1;return}F.current||M({type:`sync`,value:J})},[J,l]);let X=(0,I.useMemo)(()=>!N||!P?!1:JSON.stringify(N)!==JSON.stringify(P),[N,P]);return(0,Z.jsxs)(te,{children:[(0,Z.jsx)(Te,{t:n,hasToken:l,cfgForm:N,cfgSaving:S,cfgDirty:X,saveConfig:(0,I.useCallback)(async()=>{if(N){g({type:`patch`,patch:{cfgSaving:!0,cfgOk:!1,cfgError:null}});try{await se(Y,N,ue),M({type:`saved`,value:N}),F.current=!1,g({type:`patch`,patch:{cfgOk:!0}}),await H()}catch(e){g({type:`patch`,patch:{cfgError:e instanceof Error?e.message:String(e)}})}finally{g({type:`patch`,patch:{cfgSaving:!1}})}}},[Y,ue,N,H]),doRefresh:W}),U.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:U.map(e=>(0,Z.jsx)(`p`,{className:`text-sm text-amber-800 dark:text-amber-200/90`,children:e},e))}):null,(0,Z.jsx)(Ue,{t:n,activeTab:p,onChange:m}),(0,Z.jsx)(We,{t:n,id:`config`,activeTab:p,children:(0,Z.jsx)(ye,{t:n,schedulePickerLabels:r,hasToken:l,cfgForm:N,cfgBaseline:P,cfgDirty:X,cfgSaving:S,runPhase:x,setRunPhase:e=>g({type:`patch`,patch:{runPhase:e}}),runBusy:y,setCfgForm:e=>{F.current=!0;let t=typeof e==`function`?e(N):e;t&&M({type:`set`,value:t})},doRunNow:q})}),(0,Z.jsx)(We,{t:n,id:`runtime`,activeTab:p,children:(0,Z.jsx)(Pe,{t:n,data:L,isLoading:V,localeTag:c,scheduleBadgeLabels:i})}),(0,Z.jsx)(We,{t:n,id:`insights`,activeTab:p,children:(0,Z.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-2`,children:[(0,Z.jsx)(De,{t:n,hasToken:l,previewLoading:w,previewItems:E,loadPreview:G}),(0,Z.jsx)(Ce,{t:n,hasToken:l,eventsLoading:O,events:ee,loadEvents:K})]})}),(0,Z.jsx)(We,{t:n,id:`maintenance`,activeTab:p,children:(0,Z.jsx)(Ee,{t:n,disabled:le,actionBusy:_,doAction:ce})})]})}function Ue(e){let t=(0,L.c)(7),{t:n,activeTab:r,onChange:i}=e,a;t[0]===n?a=t[1]:(a=Fe.map(e=>({id:e,label:Re(n,e),icon:Ie[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)(d,{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 We(e){let t=(0,L.c)(13),{t:n,id:r,activeTab:i,children:a}=e,o=r!==`config`,s;t[0]!==r||t[1]!==n?(s=Re(n,r),t[0]=r,t[1]=n,t[2]=s):s=t[2];let c;t[3]!==r||t[4]!==n?(c=ze(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)(M,{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{He as DreamingSettingsPanel};
@@ -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-avfvyZuQ.js";import{n as a}from"./locale-store-Ba72bFmP.js";import{Fi as o}from"./index-T0SaNd5a.js";var s=n(),c=e(t(),1),l=r(),u=`xopc.extensionUiGrants.v1`;function d(){let e=(0,s.c)(59),t=a(h),n;e[0]===t?n=e[1]:(n=i(t),e[0]=t,e[1]=n);let r=n.extensionDebug,u=o(),[d,_]=(0,c.useState)(m),v;e[2]===u?v=e[3]:(v=u.toSorted(p),e[2]=u,e[3]=v);let y=v,b;e[4]===r.title?b=e[5]:(b=(0,l.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:r.title}),e[4]=r.title,e[5]=b);let x;e[6]===r.subtitle?x=e[7]:(x=(0,l.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r.subtitle}),e[6]=r.subtitle,e[7]=x);let S;e[8]!==b||e[9]!==x?(S=(0,l.jsxs)(`div`,{children:[b,x]}),e[8]=b,e[9]=x,e[10]=S):S=e[10];let C;e[11]===r.grantsHeading?C=e[12]:(C=(0,l.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:r.grantsHeading}),e[11]=r.grantsHeading,e[12]=C);let w;e[13]===r.grantsHint?w=e[14]:(w=(0,l.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:r.grantsHint}),e[13]=r.grantsHint,e[14]=w);let T;e[15]===d?T=e[16]:(T=(0,l.jsx)(`pre`,{className:`mt-3 max-h-48 overflow-auto rounded-lg border border-edge-subtle bg-surface-muted p-3 font-mono text-xs text-fg`,children:d}),e[15]=d,e[16]=T);let E;e[17]===Symbol.for(`react.memo_cache_sentinel`)?(E=()=>_(g()),e[17]=E):E=e[17];let D;e[18]===r.refresh?D=e[19]:(D=(0,l.jsx)(`button`,{type:`button`,className:`mt-3 rounded-lg border border-edge px-3 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover`,onClick:E,children:r.refresh}),e[18]=r.refresh,e[19]=D);let O;e[20]!==C||e[21]!==w||e[22]!==T||e[23]!==D?(O=(0,l.jsxs)(`section`,{className:`rounded-xl border border-edge bg-surface-base p-4`,children:[C,w,T,D]}),e[20]=C,e[21]=w,e[22]=T,e[23]=D,e[24]=O):O=e[24];let k;e[25]===r.listHeading?k=e[26]:(k=(0,l.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:r.listHeading}),e[25]=r.listHeading,e[26]=k);let A;e[27]===r.colId?A=e[28]:(A=(0,l.jsx)(`th`,{className:`py-2 pr-2`,children:r.colId}),e[27]=r.colId,e[28]=A);let j;e[29]===r.colName?j=e[30]:(j=(0,l.jsx)(`th`,{className:`py-2 pr-2`,children:r.colName}),e[29]=r.colName,e[30]=j);let M;e[31]===r.colPermissions?M=e[32]:(M=(0,l.jsx)(`th`,{className:`py-2`,children:r.colPermissions}),e[31]=r.colPermissions,e[32]=M);let N;e[33]!==A||e[34]!==j||e[35]!==M?(N=(0,l.jsx)(`thead`,{children:(0,l.jsxs)(`tr`,{className:`border-b border-edge text-xs uppercase text-fg-muted`,children:[A,j,M]})}),e[33]=A,e[34]=j,e[35]=M,e[36]=N):N=e[36];let P;e[37]===y?P=e[38]:(P=y.map(f),e[37]=y,e[38]=P);let F;e[39]===P?F=e[40]:(F=(0,l.jsx)(`tbody`,{children:P}),e[39]=P,e[40]=F);let I;e[41]!==N||e[42]!==F?(I=(0,l.jsx)(`div`,{className:`mt-3 overflow-x-auto`,children:(0,l.jsxs)(`table`,{className:`w-full min-w-[32rem] border-collapse text-left text-sm`,children:[N,F]})}),e[41]=N,e[42]=F,e[43]=I):I=e[43];let L;e[44]!==k||e[45]!==I?(L=(0,l.jsxs)(`section`,{className:`rounded-xl border border-edge bg-surface-base p-4`,children:[k,I]}),e[44]=k,e[45]=I,e[46]=L):L=e[46];let R;e[47]===r.futureHeading?R=e[48]:(R=(0,l.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:r.futureHeading}),e[47]=r.futureHeading,e[48]=R);let z;e[49]===r.futureBody?z=e[50]:(z=(0,l.jsx)(`p`,{className:`mt-2`,children:r.futureBody}),e[49]=r.futureBody,e[50]=z);let B;e[51]!==R||e[52]!==z?(B=(0,l.jsxs)(`section`,{className:`rounded-xl border border-dashed border-edge-subtle bg-surface-muted/50 p-4 text-sm text-fg-muted`,children:[R,z]}),e[51]=R,e[52]=z,e[53]=B):B=e[53];let V;return e[54]!==O||e[55]!==L||e[56]!==B||e[57]!==S?(V=(0,l.jsxs)(`div`,{className:`flex w-full flex-col gap-6 px-3 py-8 sm:px-5 xl:px-6`,children:[S,O,L,B]}),e[54]=O,e[55]=L,e[56]=B,e[57]=S,e[58]=V):V=e[58],V}function f(e){return(0,l.jsxs)(`tr`,{className:`border-b border-edge-subtle`,children:[(0,l.jsx)(`td`,{className:`py-2 pr-2 font-mono text-xs text-fg`,children:e.id}),(0,l.jsx)(`td`,{className:`py-2 pr-2 text-fg`,children:e.name}),(0,l.jsx)(`td`,{className:`py-2 font-mono text-xs text-fg-muted`,children:(e.ui?.permissions??[]).join(`, `)||`—`})]},e.id)}function p(e,t){return e.id.localeCompare(t.id)}function m(){return g()}function h(e){return e.language}function g(){try{let e=localStorage.getItem(u);if(!e)return`{}`;let t=JSON.parse(e);return JSON.stringify(t,null,2)}catch(e){return e instanceof Error?e.message:String(e)}}export{d as ExtensionDebugPage};
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-O6TAtdFC.js";import{n as a}from"./locale-store-Ba72bFmP.js";import{Ii as o}from"./index-c_9TVr_C.js";var s=n(),c=e(t(),1),l=r(),u=`xopc.extensionUiGrants.v1`;function d(){let e=(0,s.c)(59),t=a(h),n;e[0]===t?n=e[1]:(n=i(t),e[0]=t,e[1]=n);let r=n.extensionDebug,u=o(),[d,_]=(0,c.useState)(m),v;e[2]===u?v=e[3]:(v=u.toSorted(p),e[2]=u,e[3]=v);let y=v,b;e[4]===r.title?b=e[5]:(b=(0,l.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:r.title}),e[4]=r.title,e[5]=b);let x;e[6]===r.subtitle?x=e[7]:(x=(0,l.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:r.subtitle}),e[6]=r.subtitle,e[7]=x);let S;e[8]!==b||e[9]!==x?(S=(0,l.jsxs)(`div`,{children:[b,x]}),e[8]=b,e[9]=x,e[10]=S):S=e[10];let C;e[11]===r.grantsHeading?C=e[12]:(C=(0,l.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:r.grantsHeading}),e[11]=r.grantsHeading,e[12]=C);let w;e[13]===r.grantsHint?w=e[14]:(w=(0,l.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:r.grantsHint}),e[13]=r.grantsHint,e[14]=w);let T;e[15]===d?T=e[16]:(T=(0,l.jsx)(`pre`,{className:`mt-3 max-h-48 overflow-auto rounded-lg border border-edge-subtle bg-surface-muted p-3 font-mono text-xs text-fg`,children:d}),e[15]=d,e[16]=T);let E;e[17]===Symbol.for(`react.memo_cache_sentinel`)?(E=()=>_(g()),e[17]=E):E=e[17];let D;e[18]===r.refresh?D=e[19]:(D=(0,l.jsx)(`button`,{type:`button`,className:`mt-3 rounded-lg border border-edge px-3 py-1.5 text-xs font-medium text-fg hover:bg-surface-hover`,onClick:E,children:r.refresh}),e[18]=r.refresh,e[19]=D);let O;e[20]!==C||e[21]!==w||e[22]!==T||e[23]!==D?(O=(0,l.jsxs)(`section`,{className:`rounded-xl border border-edge bg-surface-base p-4`,children:[C,w,T,D]}),e[20]=C,e[21]=w,e[22]=T,e[23]=D,e[24]=O):O=e[24];let k;e[25]===r.listHeading?k=e[26]:(k=(0,l.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:r.listHeading}),e[25]=r.listHeading,e[26]=k);let A;e[27]===r.colId?A=e[28]:(A=(0,l.jsx)(`th`,{className:`py-2 pr-2`,children:r.colId}),e[27]=r.colId,e[28]=A);let j;e[29]===r.colName?j=e[30]:(j=(0,l.jsx)(`th`,{className:`py-2 pr-2`,children:r.colName}),e[29]=r.colName,e[30]=j);let M;e[31]===r.colPermissions?M=e[32]:(M=(0,l.jsx)(`th`,{className:`py-2`,children:r.colPermissions}),e[31]=r.colPermissions,e[32]=M);let N;e[33]!==A||e[34]!==j||e[35]!==M?(N=(0,l.jsx)(`thead`,{children:(0,l.jsxs)(`tr`,{className:`border-b border-edge text-xs uppercase text-fg-muted`,children:[A,j,M]})}),e[33]=A,e[34]=j,e[35]=M,e[36]=N):N=e[36];let P;e[37]===y?P=e[38]:(P=y.map(f),e[37]=y,e[38]=P);let F;e[39]===P?F=e[40]:(F=(0,l.jsx)(`tbody`,{children:P}),e[39]=P,e[40]=F);let I;e[41]!==N||e[42]!==F?(I=(0,l.jsx)(`div`,{className:`mt-3 overflow-x-auto`,children:(0,l.jsxs)(`table`,{className:`w-full min-w-[32rem] border-collapse text-left text-sm`,children:[N,F]})}),e[41]=N,e[42]=F,e[43]=I):I=e[43];let L;e[44]!==k||e[45]!==I?(L=(0,l.jsxs)(`section`,{className:`rounded-xl border border-edge bg-surface-base p-4`,children:[k,I]}),e[44]=k,e[45]=I,e[46]=L):L=e[46];let R;e[47]===r.futureHeading?R=e[48]:(R=(0,l.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:r.futureHeading}),e[47]=r.futureHeading,e[48]=R);let z;e[49]===r.futureBody?z=e[50]:(z=(0,l.jsx)(`p`,{className:`mt-2`,children:r.futureBody}),e[49]=r.futureBody,e[50]=z);let B;e[51]!==R||e[52]!==z?(B=(0,l.jsxs)(`section`,{className:`rounded-xl border border-dashed border-edge-subtle bg-surface-muted/50 p-4 text-sm text-fg-muted`,children:[R,z]}),e[51]=R,e[52]=z,e[53]=B):B=e[53];let V;return e[54]!==O||e[55]!==L||e[56]!==B||e[57]!==S?(V=(0,l.jsxs)(`div`,{className:`flex w-full flex-col gap-6 px-3 py-8 sm:px-5 xl:px-6`,children:[S,O,L,B]}),e[54]=O,e[55]=L,e[56]=B,e[57]=S,e[58]=V):V=e[58],V}function f(e){return(0,l.jsxs)(`tr`,{className:`border-b border-edge-subtle`,children:[(0,l.jsx)(`td`,{className:`py-2 pr-2 font-mono text-xs text-fg`,children:e.id}),(0,l.jsx)(`td`,{className:`py-2 pr-2 text-fg`,children:e.name}),(0,l.jsx)(`td`,{className:`py-2 font-mono text-xs text-fg-muted`,children:(e.ui?.permissions??[]).join(`, `)||`—`})]},e.id)}function p(e,t){return e.id.localeCompare(t.id)}function m(){return g()}function h(e){return e.language}function g(){try{let e=localStorage.getItem(u);if(!e)return`{}`;let t=JSON.parse(e);return JSON.stringify(t,null,2)}catch(e){return e instanceof Error?e.message:String(e)}}export{d as ExtensionDebugPage};
@@ -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{Fi as i,Lc as a,Ri as o,U as s,sa as c}from"./index-T0SaNd5a.js";var l=n(),u=e(t(),1),d=r();function f(){let e=(0,l.c)(26),{extensionId:t,pageId:n}=a(),r=i(),f=c(m),g=c(p),_,v,y;e[0]!==t||e[1]!==r||e[2]!==n?(_=t?r.find(e=>e.id===t&&o(e)):void 0,v=_?.ui?.contributions?.pages,y=t&&v?.length?n?v.find(e=>e.id===n||e.id===`${t}.${n}`):v[0]:void 0,e[0]=t,e[1]=r,e[2]=n,e[3]=_,e[4]=v,e[5]=y):(_=e[3],v=e[4],y=e[5]);let b=y,x,S;if(e[6]!==g||e[7]!==_||e[8]!==t||e[9]!==b||e[10]!==f?(x=()=>{if(!t||!_||!b)return g(),()=>g();let e=b.title?.trim()||_.name||t;return f({startExtra:null,main:(0,d.jsx)(`div`,{className:`w-full min-w-0 px-3 sm:px-5 xl:px-6`,children:(0,d.jsx)(`h1`,{className:`min-w-0 truncate text-base font-semibold tracking-tight text-fg`,title:e,children:e})}),end:null}),()=>g()},S=[g,_,t,b,f],e[6]=g,e[7]=_,e[8]=t,e[9]=b,e[10]=f,e[11]=x,e[12]=S):(x=e[11],S=e[12]),(0,u.useLayoutEffect)(x,S),!t){let t;return e[13]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,d.jsx)(h,{message:`No extension ID provided.`}),e[13]=t):t=e[13],t}if(!_){let n=`Extension "${t}" not found or has no UI.`,r;return e[14]===n?r=e[15]:(r=(0,d.jsx)(h,{message:n}),e[14]=n,e[15]=r),r}if(!v?.length){let n=`Extension "${t}" has no page contributions.`,r;return e[16]===n?r=e[17]:(r=(0,d.jsx)(h,{message:n}),e[16]=n,e[17]=r),r}if(!b){let r=`Page "${n}" not found in extension "${t}".`,i;return e[18]===r?i=e[19]:(i=(0,d.jsx)(h,{message:r}),e[18]=r,e[19]=i),i}let C=_.ui?.permissions,w;return e[20]!==_.name||e[21]!==t||e[22]!==b.entrypoint||e[23]!==b.title||e[24]!==C?(w=(0,d.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,d.jsx)(s,{extensionId:t,extensionName:_.name,entrypoint:b.entrypoint,permissions:C,title:b.title,className:`min-h-0 flex-1`,fixedHeight:void 0,maxHeight:99999})}),e[20]=_.name,e[21]=t,e[22]=b.entrypoint,e[23]=b.title,e[24]=C,e[25]=w):w=e[25],w}function p(e){return e.clearPageHeader}function m(e){return e.setPageHeader}function h(e){let t=(0,l.c)(2),{message:n}=e,r;return t[0]===n?r=t[1]:(r=(0,d.jsx)(`div`,{className:`flex min-h-[min(40vh,16rem)] flex-1 items-center justify-center`,children:(0,d.jsx)(`div`,{className:`text-center`,children:(0,d.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n})})}),t[0]=n,t[1]=r),r}export{f as ExtensionPage};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{Ii as i,Rc as a,U as o,ca as s,zi as c}from"./index-c_9TVr_C.js";var l=n(),u=e(t(),1),d=r();function f(){let e=(0,l.c)(26),{extensionId:t,pageId:n}=a(),r=i(),f=s(m),g=s(p),_,v,y;e[0]!==t||e[1]!==r||e[2]!==n?(_=t?r.find(e=>e.id===t&&c(e)):void 0,v=_?.ui?.contributions?.pages,y=t&&v?.length?n?v.find(e=>e.id===n||e.id===`${t}.${n}`):v[0]:void 0,e[0]=t,e[1]=r,e[2]=n,e[3]=_,e[4]=v,e[5]=y):(_=e[3],v=e[4],y=e[5]);let b=y,x,S;if(e[6]!==g||e[7]!==_||e[8]!==t||e[9]!==b||e[10]!==f?(x=()=>{if(!t||!_||!b)return g(),()=>g();let e=b.title?.trim()||_.name||t;return f({startExtra:null,main:(0,d.jsx)(`div`,{className:`w-full min-w-0 px-3 sm:px-5 xl:px-6`,children:(0,d.jsx)(`h1`,{className:`min-w-0 truncate text-base font-semibold tracking-tight text-fg`,title:e,children:e})}),end:null}),()=>g()},S=[g,_,t,b,f],e[6]=g,e[7]=_,e[8]=t,e[9]=b,e[10]=f,e[11]=x,e[12]=S):(x=e[11],S=e[12]),(0,u.useLayoutEffect)(x,S),!t){let t;return e[13]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,d.jsx)(h,{message:`No extension ID provided.`}),e[13]=t):t=e[13],t}if(!_){let n=`Extension "${t}" not found or has no UI.`,r;return e[14]===n?r=e[15]:(r=(0,d.jsx)(h,{message:n}),e[14]=n,e[15]=r),r}if(!v?.length){let n=`Extension "${t}" has no page contributions.`,r;return e[16]===n?r=e[17]:(r=(0,d.jsx)(h,{message:n}),e[16]=n,e[17]=r),r}if(!b){let r=`Page "${n}" not found in extension "${t}".`,i;return e[18]===r?i=e[19]:(i=(0,d.jsx)(h,{message:r}),e[18]=r,e[19]=i),i}let C=_.ui?.permissions,w;return e[20]!==_.name||e[21]!==t||e[22]!==b.entrypoint||e[23]!==b.title||e[24]!==C?(w=(0,d.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,d.jsx)(o,{extensionId:t,extensionName:_.name,entrypoint:b.entrypoint,permissions:C,title:b.title,className:`min-h-0 flex-1`,fixedHeight:void 0,maxHeight:99999})}),e[20]=_.name,e[21]=t,e[22]=b.entrypoint,e[23]=b.title,e[24]=C,e[25]=w):w=e[25],w}function p(e){return e.clearPageHeader}function m(e){return e.setPageHeader}function h(e){let t=(0,l.c)(2),{message:n}=e,r;return t[0]===n?r=t[1]:(r=(0,d.jsx)(`div`,{className:`flex min-h-[min(40vh,16rem)] flex-1 items-center justify-center`,children:(0,d.jsx)(`div`,{className:`text-center`,children:(0,d.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n})})}),t[0]=n,t[1]=r),r}export{f as ExtensionPage};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-avfvyZuQ.js";import{n as o}from"./locale-store-Ba72bFmP.js";import{c as s,i as c,n as l,t as u}from"./fetch-Dtpbbe0s.js";import{r as d}from"./toast-z0toXu32.js";import{i as f}from"./vendor-swr-BIWyz7Rc.js";import{Ba as p,Fi as m,La as h,Lc as g,Nc as _,Ra as v,U as y,ga as b,ns as x,va as S,za as C}from"./index-T0SaNd5a.js";import{a as w,d as T,f as E,i as D,l as O,s as k,t as A,u as j}from"./voice-api-key-field-C1MrQD8R.js";import{t as M}from"./schema-form-Cc-IOydE.js";var N=n(),P=e(t(),1),F=r(),I=()=>c(E);function L(e){return{credentialsIntro:e.credentialsIntro,regionHint:e.regionHint,endpointPresetsHint:e.endpointPresetsHint,apiKeyLabel:e.apiKeyLabel,optionalPlaceholder:e.optionalPlaceholder,regionLabel:e.regionLabel,baseUrlLabel:e.baseUrlLabel,imageBaseUrlLabel:e.imageBaseUrlLabel,saveCredentials:e.saveCredentials,savingCredentials:e.savingCredentials,credentialsSaved:e.credentialsSaved,discardCredentials:e.discardCredentials,credentialsNothingToSave:e.credentialsNothingToSave,credentialsSaveError:e.credentialsSaveError,regionPresetDefault:e.regionPresetDefault,regionPresetCustom:e.regionPresetCustom,baseUrlPresetDefault:e.baseUrlPresetDefault,baseUrlPresetCustom:e.baseUrlPresetCustom,openExtensionSettings:e.openExtensionSettings,openImageModelsPage:e.openImageModelsPage,extensionSettingsLinkTitle:e.extensionSettingsLinkTitle,imageModelsLinkTitle:e.imageModelsLinkTitle,configured:e.configured,missingKey:e.missingKey,unsavedChanges:e.unsavedChanges,expandProvider:e.expandProvider,collapseProvider:e.collapseProvider,defaultModel:e.defaultModel,modelsLabel:e.modelsLabel,modelCountOne:e.modelCountOne,modelCountMany:e.modelCountMany,imageBaseUrlPresetHint:e.imageBaseUrlPresetHint,dashscopeRegion_beijing:e.dashscopeRegion_beijing,dashscopeRegion_singapore:e.dashscopeRegion_singapore,dashscopeRegion_us:e.dashscopeRegion_us,apiKeyMaskedHelp:e.apiKeyMaskedHelp,apiKeyCopy:e.apiKeyCopy,apiKeyCopied:e.apiKeyCopied,apiKeyShow:e.apiKeyShow,apiKeyHide:e.apiKeyHide,apiKeyNotInConfigFile:e.apiKeyNotInConfigFile,apiKeyRevealFailed:e.apiKeyRevealFailed,minimaxClusterLabel:e.minimaxClusterLabel,minimaxClusterHint:e.minimaxClusterHint,falQueueBaseLabel:e.falQueueBaseLabel,falQueueBaseHint:e.falQueueBaseHint}}function R(e){let t=(0,N.c)(40),{extensionId:n}=e,r=o(B),i;t[0]===r?i=t[1]:(i=a(r),t[0]=r,t[1]=i);let c=i,l=c.imageModelsSettings,u=s(z),d;t[2]===u?d=t[3]:(d=u?I():null,t[2]=u,t[3]=d);let p;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(p={revalidateOnFocus:!1},t[4]=p):p=t[4];let{data:m,isLoading:h}=f(d,T,p),g;t[5]===m?g=t[6]:(g=m===void 0?[]:m,t[5]=m,t[6]=g);let _=g,v;if(t[7]!==_||t[8]!==n){let e;t[10]===n?e=t[11]:(e=e=>e.id===n,t[10]=n,t[11]=e),v=_.filter(e),t[7]=_,t[8]=n,t[9]=v}else v=t[9];let y=v,b=O(y),S;t[12]===l?S=t[13]:(S=L(l),t[12]=l,t[13]=S);let C=S,w;t[14]!==c.providersSettings.getApiKey||t[15]!==c.providersSettings.getApiKeyCn||t[16]!==c.providersSettings.getApiKeyIntl?(w={getApiKey:c.providersSettings.getApiKey,getApiKeyIntl:c.providersSettings.getApiKeyIntl,getApiKeyCn:c.providersSettings.getApiKeyCn},t[14]=c.providersSettings.getApiKey,t[15]=c.providersSettings.getApiKeyCn,t[16]=c.providersSettings.getApiKeyIntl,t[17]=w):w=t[17];let E=w;if(!u)return null;if(h){let e;return t[18]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,F.jsxs)(`div`,{className:`flex items-center gap-2 py-6 text-sm text-fg-muted`,children:[(0,F.jsx)(x,{className:`size-4 animate-spin`}),`…`]}),t[18]=e):e=t[18],e}if(y.length===0){let e=r===`zh`?`网关未注册该图像 Provider,或扩展已被禁用。`:`This image provider is not registered on the gateway, or the extension is disabled.`,n;return t[19]===e?n=t[20]:(n=(0,F.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e}),t[19]=e,t[20]=n),n}let D;t[21]!==b||t[22]!==l.credentialsSaveError?(D=()=>void b.saveCredentials(l.credentialsSaveError),t[21]=b,t[22]=l.credentialsSaveError,t[23]=D):D=t[23];let k;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(k=new Set,t[24]=k):k=t[24];let A;return t[25]!==E||t[26]!==b.credBaseline||t[27]!==b.credDirty||t[28]!==b.credDraft||t[29]!==b.credError||t[30]!==b.credNoopFlash||t[31]!==b.credSavedFlash||t[32]!==b.credSaving||t[33]!==b.onDiscardCredentials||t[34]!==b.updateCredRow||t[35]!==r||t[36]!==C||t[37]!==y||t[38]!==D?(A=(0,F.jsx)(j,{summaries:y,credDraft:b.credDraft,credBaseline:b.credBaseline,credDirty:b.credDirty,credSaving:b.credSaving,credError:b.credError,credSavedFlash:b.credSavedFlash,credNoopFlash:b.credNoopFlash,updateCredRow:b.updateCredRow,onDiscardCredentials:b.onDiscardCredentials,onSaveCredentials:D,extensionIds:k,showExtensionLinks:!1,showImageModelsLink:!1,language:r,apiKeyLinkLabels:E,messages:C}),t[25]=E,t[26]=b.credBaseline,t[27]=b.credDirty,t[28]=b.credDraft,t[29]=b.credError,t[30]=b.credNoopFlash,t[31]=b.credSavedFlash,t[32]=b.credSaving,t[33]=b.onDiscardCredentials,t[34]=b.updateCredRow,t[35]=r,t[36]=C,t[37]=y,t[38]=D,t[39]=A):A=t[39],A}function z(e){return!!e.token}function B(e){return e.language}function V(e){let t=(0,N.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,F.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=r),r}var H=[{id:`whisper-large-v3-turbo`,name:`Whisper Large v3 Turbo`},{id:`whisper-large-v3`,name:`Whisper Large v3`}];function U(e){let t=e?.manifest?.mediaUnderstandingProviders?.[0];if(typeof t==`string`&&t.trim())return t.trim();let n=e?.manifest?.contracts?.mediaUnderstandingProviders?.[0];if(typeof n==`string`&&n.trim())return n.trim()}function W(){return i(v,h)}function G(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,C,`dark:border-edge`)}function K(e,t){if(!e||!t)return{apiKey:``,model:H[0].id};if(t===`alibaba`)return{apiKey:e.stt.alibaba?.apiKey??``,model:e.stt.alibaba?.model??`paraformer-v2`};if(t===`openai`)return{apiKey:e.stt.openai?.apiKey??``,model:e.stt.openai?.model??`whisper-1`};let n=e.stt.providers?.[t];return{apiKey:typeof n?.apiKey==`string`?n.apiKey:``,model:typeof n?.model==`string`?n.model:H[0].id}}function q({providerId:e,voiceSettings:t,mutateVoice:n}){let r=a(o(e=>e.language)),s=r.voiceSettings,l=r.extensionSttMedia,u={maskedHelp:s.apiKeyMaskedHelp,copy:s.apiKeyCopy,copied:s.apiKeyCopied,show:s.apiKeyShow,hide:s.apiKeyHide,notInConfigFile:s.apiKeyNotInConfigFile,loadFailed:s.apiKeyRevealFailed},{data:m}=f(c(`/api/voice/stt-providers`),w,{revalidateOnFocus:!1}),g=(0,P.useMemo)(()=>m?.providers.some(t=>t.id===e&&t.configured)??!1,[e,m]),_=(0,P.useMemo)(()=>K(t,e),[e,t]),v=(0,P.useRef)(!1),[y,x]=(0,P.useState)(null),[C,T]=(0,P.useState)(!1),[E,D]=(0,P.useState)(null),[O,j]=(0,P.useState)(!1),M=y??_,N=_,I=M.apiKey!==N.apiKey||M.model!==N.model,L=(0,P.useCallback)(async()=>{T(!0),D(null);try{let r=structuredClone(t);r.stt.enabled=!0,e===`alibaba`?(r.stt.provider=`alibaba`,r.stt.alibaba={...r.stt.alibaba,apiKey:M.apiKey,model:M.model}):e===`openai`?(r.stt.provider=`openai`,r.stt.openai={...r.stt.openai,apiKey:M.apiKey,model:M.model}):(r.stt.providers={...r.stt.providers??{},[e]:{...r.stt.providers?.[e]??{},apiKey:M.apiKey,model:M.model}},(!r.stt.provider||r.stt.provider===`alibaba`||r.stt.provider===`openai`)&&(r.stt.provider=e)),await k(r),await n(r,!1),v.current=!1,x(null),j(!0),d({type:`success`,title:s.saved})}catch(e){D(e instanceof Error?e.message:String(e))}finally{T(!1)}},[M.apiKey,M.model,n,e,t]),R=e===`groq`?H:[{id:M.model,name:M.model}];return(0,F.jsxs)(`div`,{className:`flex flex-col gap-4 rounded-xl border border-edge bg-surface-base p-4`,children:[(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:l.credentialsTitle}),(0,F.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:l.credentialsHint.replace(`{providerId}`,e)})]}),(0,F.jsx)(`span`,{className:i(`rounded-full px-2 py-0.5 text-xs font-medium`,g?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-amber-500/10 text-amber-800 dark:text-amber-200`),children:g?l.configured:l.notConfigured})]}),(0,F.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,F.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,h),children:[(0,F.jsx)(V,{children:s.stt.apiKey}),(0,F.jsx)(A,{kind:`stt`,providerId:e,fieldId:`ext-stt-${e}-api-key`,value:M.apiKey,onChange:e=>{v.current=!0,x(t=>({...t??_,apiKey:e})),D(null)},labels:u,placeholder:e===`groq`?`gsk_...`:`sk-...`}),(0,F.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[s.stt.apiKeyDesc,e===`groq`?` (GROQ_API_KEY)`:``]})]}),(0,F.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,h),children:[(0,F.jsx)(V,{children:s.stt.model}),e===`groq`?(0,F.jsx)(b,{className:W(),value:M.model,onChange:e=>{v.current=!0,x(t=>({...t??_,model:e.target.value})),D(null)},children:R.map(e=>(0,F.jsx)(S,{value:e.id,children:e.name},e.id))}):(0,F.jsx)(`input`,{className:G(),value:M.model,onChange:e=>{v.current=!0,x(t=>({...t??_,model:e.target.value})),D(null)}})]})]}),(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[E?(0,F.jsx)(`span`,{className:`text-xs text-red-600 dark:text-red-400`,children:E}):null,(0,F.jsx)(p,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,disabled:!I||C,onClick:()=>{v.current=!1,x(null),D(null)},children:s.discard}),(0,F.jsx)(p,{type:`button`,variant:`primary`,className:`h-8 text-xs`,disabled:!I||C,onClick:()=>void L(),children:C?s.saving:s.save})]})]})}function J(e){let t=(0,N.c)(13),{extensionId:n}=e,r=o(X),i=s(Y),a;t[0]===n?a=t[1]:(a=()=>l(c(`/api/extensions/${encodeURIComponent(n)}`)),t[0]=n,t[1]=a);let{data:u,isLoading:d}=f(i&&n?`ext-stt-detail-${n}`:null,a),p;t[2]===u?p=t[3]:(p=U(u),t[2]=u,t[3]=p);let m=p,h;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(h={revalidateOnFocus:!1},t[4]=h):h=t[4];let{data:g,mutate:_,isLoading:v}=f(i?`voice-settings-ext-stt`:null,D,h);if(!i)return null;if(d||v){let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,F.jsxs)(`div`,{className:`flex items-center gap-2 py-6 text-sm text-fg-muted`,children:[(0,F.jsx)(x,{className:`size-4 animate-spin`}),`…`]}),t[5]=e):e=t[5],e}if(!m){let e=r===`zh`?`该扩展未声明 mediaUnderstandingProviders。`:`This extension does not declare mediaUnderstandingProviders.`,n;return t[6]===e?n=t[7]:(n=(0,F.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e}),t[6]=e,t[7]=n),n}if(!g)return null;let y=`${n}:${m}`,b;return t[8]!==_||t[9]!==m||t[10]!==y||t[11]!==g?(b=(0,F.jsx)(q,{providerId:m,voiceSettings:g,mutateVoice:_},y),t[8]=_,t[9]=m,t[10]=y,t[11]=g,t[12]=b):b=t[12],b}function Y(e){return!!e.token}function X(e){return e.language}function Z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Q(e){let t={};if(e.type!==`object`||!Z(e.properties))return t;for(let[n,r]of Object.entries(e.properties))Z(r)&&Object.prototype.hasOwnProperty.call(r,`default`)&&(t[n]=r.default);return t}function ee(e,t){switch(t.type){case`sync`:return{...e,localValues:t.value,isDirty:!1,saveError:null};case`change`:return{...e,localValues:t.value,isDirty:!0,saveError:null,saveSuccess:!1};case`discard`:return{...e,localValues:t.value,isDirty:!1,saveError:null};case`reset-defaults`:return{...e,localValues:t.value,isDirty:!0,saveError:null,saveSuccess:!1};case`save-start`:return{...e,saving:!0,saveError:null};case`save-success`:return{...e,localValues:t.value,isDirty:!1,saving:!1,saveSuccess:!0,saveError:null};case`save-error`:return{...e,saving:!1,saveError:t.message}}}function te({extensionId:e}){let t=a(o(e=>e.language)).agentSettings,n=s(e=>!!e.token),{data:r,error:i}=f(n&&e?`ext-detail-${e}`:null,()=>l(c(`/api/extensions/${encodeURIComponent(e)}`))),{data:m,mutate:h,error:g}=f(n&&e?`ext-cfg-${e}`:null,()=>l(c(`/api/extensions/${encodeURIComponent(e)}/config`))),_=r?.manifest?.configSchema,v=(0,P.useMemo)(()=>_&&_.type===`object`?Q(_):{},[_]),y=(0,P.useMemo)(()=>({...v,...m??{}}),[v,m]),[b,x]=(0,P.useReducer)(ee,{localValues:{},isDirty:!1,saving:!1,saveError:null,saveSuccess:!1}),[S,C]=(0,P.useState)(!1),w=(0,P.useRef)(!1),T=(0,P.useRef)(y);!w.current&&T.current!==y&&(T.current=y,x({type:`sync`,value:y}));let E=(0,P.useCallback)(e=>{w.current=!0,x({type:`change`,value:e})},[]),D=(0,P.useCallback)(()=>{w.current=!1,x({type:`discard`,value:y})},[y]),O=(0,P.useCallback)(()=>{!_||_.type!==`object`||(w.current=!0,x({type:`reset-defaults`,value:{...Q(_)}}))},[_]),k=(0,P.useCallback)(async()=>{if(e){x({type:`save-start`});try{let n=await u(c(`/api/extensions/${encodeURIComponent(e)}/config`),{method:`PATCH`,body:JSON.stringify(b.localValues)});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error?.message??n.statusText)}await h(b.localValues,!1),w.current=!1,x({type:`save-success`,value:b.localValues}),C(!0),d({type:`success`,title:t.saved})}catch(e){x({type:`save-error`,message:e instanceof Error?e.message:String(e)})}}},[b.localValues,e,h]);if(!n)return null;if(i||g){let e=i??g;return(0,F.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[`Could not load extension settings: `,e instanceof Error?e.message:String(e)]})}return!_||_.type!==`object`?null:(0,F.jsxs)(`div`,{className:`mb-6 flex flex-col gap-3 rounded-xl border border-edge bg-surface-base p-4`,children:[(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,F.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Configuration`}),(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[b.saveError?(0,F.jsx)(`span`,{className:`text-xs text-red-600 dark:text-red-400`,children:b.saveError}):null,(0,F.jsx)(p,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,disabled:!b.isDirty,onClick:D,children:t.discard}),(0,F.jsx)(p,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,onClick:O,children:`Reset to defaults`}),(0,F.jsx)(p,{type:`button`,variant:`primary`,className:`h-8 text-xs`,disabled:!b.isDirty||b.saving,onClick:()=>void k(),children:b.saving?t.saving:t.save})]})]}),(0,F.jsx)(M,{schema:_,values:b.localValues,onChange:E,disabled:b.saving})]})}function ne(){let e=(0,N.c)(47),t=o(re),n;e[0]===t?n=e[1]:(n=a(t),e[0]=t,e[1]=n);let r=n,i=r.extensionImageGen,s=r.extensionSttMedia,{extensionId:c,panelId:l}=g(),u=m();if(!c){let t;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,F.jsx)($,{message:`No extension ID provided.`}),e[2]=t):t=e[2],t}let d,f,p;if(e[3]!==c||e[4]!==u||e[5]!==l){p=Symbol.for(`react.early_return_sentinel`);bb0:{let t;if(e[9]===c?t=e[10]:(t=e=>e.id===c,e[9]=c,e[10]=t),d=u.find(t),!d){let t=`Extension "${c}" not found or is not available in this workspace.`,n;e[11]===t?n=e[12]:(n=(0,F.jsx)($,{message:t}),e[11]=t,e[12]=n),p=n;break bb0}let n=d.ui?.contributions?.settingsPanels;f=l?n?.find(e=>e.id===l||e.id===`${c}.${l}`):n?.[0]}e[3]=c,e[4]=u,e[5]=l,e[6]=d,e[7]=f,e[8]=p}else d=e[6],f=e[7],p=e[8];if(p!==Symbol.for(`react.early_return_sentinel`))return p;let h=f,v=!!(h&&d.ui),b=!!d.hasConfigSchema,x=d.kind===`image-generation`,S=d.kind===`media-provider`;if(!b&&!v&&!(x||S)){let t=`Extension "${c}" has no settings panels or config schema.`,n;return e[13]===t?n=e[14]:(n=(0,F.jsx)($,{message:t}),e[13]=t,e[14]=n),n}let C=h?.title??`${d.name} Settings`,w;e[15]===C?w=e[16]:(w=(0,F.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:C}),e[15]=C,e[16]=w);let T;e[17]!==x||e[18]!==r.imageModelsSettings||e[19]!==i?(T=x?(0,F.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-base px-4 py-3 text-sm`,children:[(0,F.jsx)(`p`,{className:`leading-relaxed text-fg-muted`,children:i.banner}),(0,F.jsx)(_,{to:`/settings/credentials?tab=image-models`,className:`w-fit font-medium text-accent hover:underline`,title:r.imageModelsSettings.imageModelsLinkTitle,children:i.openImageModels})]}):null,e[17]=x,e[18]=r.imageModelsSettings,e[19]=i,e[20]=T):T=e[20];let E;e[21]!==c||e[22]!==x?(E=x?(0,F.jsx)(R,{extensionId:c}):null,e[21]=c,e[22]=x,e[23]=E):E=e[23];let D;e[24]!==S||e[25]!==s?(D=S?(0,F.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-base px-4 py-3 text-sm`,children:[(0,F.jsx)(`p`,{className:`leading-relaxed text-fg-muted`,children:s.banner}),(0,F.jsx)(_,{to:`/settings/credentials?tab=voice`,className:`w-fit font-medium text-accent hover:underline`,children:s.openVoice})]}):null,e[24]=S,e[25]=s,e[26]=D):D=e[26];let O;e[27]!==c||e[28]!==S?(O=S?(0,F.jsx)(J,{extensionId:c}):null,e[27]=c,e[28]=S,e[29]=O):O=e[29];let k;e[30]!==c||e[31]!==b?(k=b?(0,F.jsx)(te,{extensionId:c}):null,e[30]=c,e[31]=b,e[32]=k):k=e[32];let A;e[33]!==d.name||e[34]!==d.ui||e[35]!==c||e[36]!==v||e[37]!==h?(A=v&&h&&d.ui?(0,F.jsx)(`div`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-base`,children:(0,F.jsx)(y,{extensionId:c,extensionName:d.name,entrypoint:h.entrypoint,permissions:d.ui?.permissions,title:h.title,className:`w-full`,minHeight:120,maxHeight:2e3})}):null,e[33]=d.name,e[34]=d.ui,e[35]=c,e[36]=v,e[37]=h,e[38]=A):A=e[38];let j;return e[39]!==w||e[40]!==T||e[41]!==E||e[42]!==D||e[43]!==O||e[44]!==k||e[45]!==A?(j=(0,F.jsxs)(`div`,{className:`flex w-full flex-col gap-3 px-3 py-8 sm:px-5 xl:px-6`,children:[w,T,E,D,O,k,A]}),e[39]=w,e[40]=T,e[41]=E,e[42]=D,e[43]=O,e[44]=k,e[45]=A,e[46]=j):j=e[46],j}function re(e){return e.language}function $(e){let t=(0,N.c)(2),{message:n}=e,r;return t[0]===n?r=t[1]:(r=(0,F.jsx)(`div`,{className:`flex w-full flex-col gap-3 px-3 py-8 sm:px-5 xl:px-6`,children:(0,F.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n})}),t[0]=n,t[1]=r),r}export{ne as ExtensionSettingsPage};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./cn-BQ_8x0bT.js";import{t as a}from"./messages-O6TAtdFC.js";import{n as o}from"./locale-store-Ba72bFmP.js";import{c as s,i as c,n as l,t as u}from"./fetch-BU5S0Sn7.js";import{r as d}from"./toast-z0toXu32.js";import{i as f}from"./vendor-swr-BIWyz7Rc.js";import{Ba as p,Ii as m,Pc as h,Ra as g,Rc as _,U as v,Va as y,_a as b,rs as x,ya as S,za as C}from"./index-c_9TVr_C.js";import{a as w,d as T,f as E,i as D,l as O,s as k,t as A,u as j}from"./voice-api-key-field-C5Ov8Uk_.js";import{t as M}from"./schema-form-Bj7sOxC8.js";var N=n(),P=e(t(),1),F=r(),I=()=>c(E);function L(e){return{credentialsIntro:e.credentialsIntro,regionHint:e.regionHint,endpointPresetsHint:e.endpointPresetsHint,apiKeyLabel:e.apiKeyLabel,optionalPlaceholder:e.optionalPlaceholder,regionLabel:e.regionLabel,baseUrlLabel:e.baseUrlLabel,imageBaseUrlLabel:e.imageBaseUrlLabel,saveCredentials:e.saveCredentials,savingCredentials:e.savingCredentials,credentialsSaved:e.credentialsSaved,discardCredentials:e.discardCredentials,credentialsNothingToSave:e.credentialsNothingToSave,credentialsSaveError:e.credentialsSaveError,regionPresetDefault:e.regionPresetDefault,regionPresetCustom:e.regionPresetCustom,baseUrlPresetDefault:e.baseUrlPresetDefault,baseUrlPresetCustom:e.baseUrlPresetCustom,openExtensionSettings:e.openExtensionSettings,openImageModelsPage:e.openImageModelsPage,extensionSettingsLinkTitle:e.extensionSettingsLinkTitle,imageModelsLinkTitle:e.imageModelsLinkTitle,configured:e.configured,missingKey:e.missingKey,unsavedChanges:e.unsavedChanges,expandProvider:e.expandProvider,collapseProvider:e.collapseProvider,defaultModel:e.defaultModel,modelsLabel:e.modelsLabel,modelCountOne:e.modelCountOne,modelCountMany:e.modelCountMany,imageBaseUrlPresetHint:e.imageBaseUrlPresetHint,dashscopeRegion_beijing:e.dashscopeRegion_beijing,dashscopeRegion_singapore:e.dashscopeRegion_singapore,dashscopeRegion_us:e.dashscopeRegion_us,apiKeyMaskedHelp:e.apiKeyMaskedHelp,apiKeyCopy:e.apiKeyCopy,apiKeyCopied:e.apiKeyCopied,apiKeyShow:e.apiKeyShow,apiKeyHide:e.apiKeyHide,apiKeyNotInConfigFile:e.apiKeyNotInConfigFile,apiKeyRevealFailed:e.apiKeyRevealFailed,minimaxClusterLabel:e.minimaxClusterLabel,minimaxClusterHint:e.minimaxClusterHint,falQueueBaseLabel:e.falQueueBaseLabel,falQueueBaseHint:e.falQueueBaseHint}}function R(e){let t=(0,N.c)(40),{extensionId:n}=e,r=o(B),i;t[0]===r?i=t[1]:(i=a(r),t[0]=r,t[1]=i);let c=i,l=c.imageModelsSettings,u=s(z),d;t[2]===u?d=t[3]:(d=u?I():null,t[2]=u,t[3]=d);let p;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(p={revalidateOnFocus:!1},t[4]=p):p=t[4];let{data:m,isLoading:h}=f(d,T,p),g;t[5]===m?g=t[6]:(g=m===void 0?[]:m,t[5]=m,t[6]=g);let _=g,v;if(t[7]!==_||t[8]!==n){let e;t[10]===n?e=t[11]:(e=e=>e.id===n,t[10]=n,t[11]=e),v=_.filter(e),t[7]=_,t[8]=n,t[9]=v}else v=t[9];let y=v,b=O(y),S;t[12]===l?S=t[13]:(S=L(l),t[12]=l,t[13]=S);let C=S,w;t[14]!==c.providersSettings.getApiKey||t[15]!==c.providersSettings.getApiKeyCn||t[16]!==c.providersSettings.getApiKeyIntl?(w={getApiKey:c.providersSettings.getApiKey,getApiKeyIntl:c.providersSettings.getApiKeyIntl,getApiKeyCn:c.providersSettings.getApiKeyCn},t[14]=c.providersSettings.getApiKey,t[15]=c.providersSettings.getApiKeyCn,t[16]=c.providersSettings.getApiKeyIntl,t[17]=w):w=t[17];let E=w;if(!u)return null;if(h){let e;return t[18]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,F.jsxs)(`div`,{className:`flex items-center gap-2 py-6 text-sm text-fg-muted`,children:[(0,F.jsx)(x,{className:`size-4 animate-spin`}),`…`]}),t[18]=e):e=t[18],e}if(y.length===0){let e=r===`zh`?`网关未注册该图像 Provider,或扩展已被禁用。`:`This image provider is not registered on the gateway, or the extension is disabled.`,n;return t[19]===e?n=t[20]:(n=(0,F.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e}),t[19]=e,t[20]=n),n}let D;t[21]!==b||t[22]!==l.credentialsSaveError?(D=()=>void b.saveCredentials(l.credentialsSaveError),t[21]=b,t[22]=l.credentialsSaveError,t[23]=D):D=t[23];let k;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(k=new Set,t[24]=k):k=t[24];let A;return t[25]!==E||t[26]!==b.credBaseline||t[27]!==b.credDirty||t[28]!==b.credDraft||t[29]!==b.credError||t[30]!==b.credNoopFlash||t[31]!==b.credSavedFlash||t[32]!==b.credSaving||t[33]!==b.onDiscardCredentials||t[34]!==b.updateCredRow||t[35]!==r||t[36]!==C||t[37]!==y||t[38]!==D?(A=(0,F.jsx)(j,{summaries:y,credDraft:b.credDraft,credBaseline:b.credBaseline,credDirty:b.credDirty,credSaving:b.credSaving,credError:b.credError,credSavedFlash:b.credSavedFlash,credNoopFlash:b.credNoopFlash,updateCredRow:b.updateCredRow,onDiscardCredentials:b.onDiscardCredentials,onSaveCredentials:D,extensionIds:k,showExtensionLinks:!1,showImageModelsLink:!1,language:r,apiKeyLinkLabels:E,messages:C}),t[25]=E,t[26]=b.credBaseline,t[27]=b.credDirty,t[28]=b.credDraft,t[29]=b.credError,t[30]=b.credNoopFlash,t[31]=b.credSavedFlash,t[32]=b.credSaving,t[33]=b.onDiscardCredentials,t[34]=b.updateCredRow,t[35]=r,t[36]=C,t[37]=y,t[38]=D,t[39]=A):A=t[39],A}function z(e){return!!e.token}function B(e){return e.language}function V(e){let t=(0,N.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,F.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=r),r}var H=[{id:`whisper-large-v3-turbo`,name:`Whisper Large v3 Turbo`},{id:`whisper-large-v3`,name:`Whisper Large v3`}];function U(e){let t=e?.manifest?.mediaUnderstandingProviders?.[0];if(typeof t==`string`&&t.trim())return t.trim();let n=e?.manifest?.contracts?.mediaUnderstandingProviders?.[0];if(typeof n==`string`&&n.trim())return n.trim()}function W(){return i(C,g)}function G(){return i(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,p,`dark:border-edge`)}function K(e,t){if(!e||!t)return{apiKey:``,model:H[0].id};if(t===`alibaba`)return{apiKey:e.stt.alibaba?.apiKey??``,model:e.stt.alibaba?.model??`paraformer-v2`};if(t===`openai`)return{apiKey:e.stt.openai?.apiKey??``,model:e.stt.openai?.model??`whisper-1`};let n=e.stt.providers?.[t];return{apiKey:typeof n?.apiKey==`string`?n.apiKey:``,model:typeof n?.model==`string`?n.model:H[0].id}}function q({providerId:e,voiceSettings:t,mutateVoice:n}){let r=a(o(e=>e.language)),s=r.voiceSettings,l=r.extensionSttMedia,u={maskedHelp:s.apiKeyMaskedHelp,copy:s.apiKeyCopy,copied:s.apiKeyCopied,show:s.apiKeyShow,hide:s.apiKeyHide,notInConfigFile:s.apiKeyNotInConfigFile,loadFailed:s.apiKeyRevealFailed},{data:p}=f(c(`/api/voice/stt-providers`),w,{revalidateOnFocus:!1}),m=(0,P.useMemo)(()=>p?.providers.some(t=>t.id===e&&t.configured)??!1,[e,p]),h=(0,P.useMemo)(()=>K(t,e),[e,t]),_=(0,P.useRef)(!1),[v,x]=(0,P.useState)(null),[C,T]=(0,P.useState)(!1),[E,D]=(0,P.useState)(null),[O,j]=(0,P.useState)(!1),M=v??h,N=h,I=M.apiKey!==N.apiKey||M.model!==N.model,L=(0,P.useCallback)(async()=>{T(!0),D(null);try{let r=structuredClone(t);r.stt.enabled=!0,e===`alibaba`?(r.stt.provider=`alibaba`,r.stt.alibaba={...r.stt.alibaba,apiKey:M.apiKey,model:M.model}):e===`openai`?(r.stt.provider=`openai`,r.stt.openai={...r.stt.openai,apiKey:M.apiKey,model:M.model}):(r.stt.providers={...r.stt.providers??{},[e]:{...r.stt.providers?.[e]??{},apiKey:M.apiKey,model:M.model}},(!r.stt.provider||r.stt.provider===`alibaba`||r.stt.provider===`openai`)&&(r.stt.provider=e)),await k(r),await n(r,!1),_.current=!1,x(null),j(!0),d({type:`success`,title:s.saved})}catch(e){D(e instanceof Error?e.message:String(e))}finally{T(!1)}},[M.apiKey,M.model,n,e,t]),R=e===`groq`?H:[{id:M.model,name:M.model}];return(0,F.jsxs)(`div`,{className:`flex flex-col gap-4 rounded-xl border border-edge bg-surface-base p-4`,children:[(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:l.credentialsTitle}),(0,F.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:l.credentialsHint.replace(`{providerId}`,e)})]}),(0,F.jsx)(`span`,{className:i(`rounded-full px-2 py-0.5 text-xs font-medium`,m?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-amber-500/10 text-amber-800 dark:text-amber-200`),children:m?l.configured:l.notConfigured})]}),(0,F.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,F.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,g),children:[(0,F.jsx)(V,{children:s.stt.apiKey}),(0,F.jsx)(A,{kind:`stt`,providerId:e,fieldId:`ext-stt-${e}-api-key`,value:M.apiKey,onChange:e=>{_.current=!0,x(t=>({...t??h,apiKey:e})),D(null)},labels:u,placeholder:e===`groq`?`gsk_...`:`sk-...`}),(0,F.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[s.stt.apiKeyDesc,e===`groq`?` (GROQ_API_KEY)`:``]})]}),(0,F.jsxs)(`div`,{className:i(`flex flex-col gap-1.5`,g),children:[(0,F.jsx)(V,{children:s.stt.model}),e===`groq`?(0,F.jsx)(b,{className:W(),value:M.model,onChange:e=>{_.current=!0,x(t=>({...t??h,model:e.target.value})),D(null)},children:R.map(e=>(0,F.jsx)(S,{value:e.id,children:e.name},e.id))}):(0,F.jsx)(`input`,{className:G(),value:M.model,onChange:e=>{_.current=!0,x(t=>({...t??h,model:e.target.value})),D(null)}})]})]}),(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[E?(0,F.jsx)(`span`,{className:`text-xs text-red-600 dark:text-red-400`,children:E}):null,(0,F.jsx)(y,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,disabled:!I||C,onClick:()=>{_.current=!1,x(null),D(null)},children:s.discard}),(0,F.jsx)(y,{type:`button`,variant:`primary`,className:`h-8 text-xs`,disabled:!I||C,onClick:()=>void L(),children:C?s.saving:s.save})]})]})}function J(e){let t=(0,N.c)(13),{extensionId:n}=e,r=o(X),i=s(Y),a;t[0]===n?a=t[1]:(a=()=>l(c(`/api/extensions/${encodeURIComponent(n)}`)),t[0]=n,t[1]=a);let{data:u,isLoading:d}=f(i&&n?`ext-stt-detail-${n}`:null,a),p;t[2]===u?p=t[3]:(p=U(u),t[2]=u,t[3]=p);let m=p,h;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(h={revalidateOnFocus:!1},t[4]=h):h=t[4];let{data:g,mutate:_,isLoading:v}=f(i?`voice-settings-ext-stt`:null,D,h);if(!i)return null;if(d||v){let e;return t[5]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,F.jsxs)(`div`,{className:`flex items-center gap-2 py-6 text-sm text-fg-muted`,children:[(0,F.jsx)(x,{className:`size-4 animate-spin`}),`…`]}),t[5]=e):e=t[5],e}if(!m){let e=r===`zh`?`该扩展未声明 mediaUnderstandingProviders。`:`This extension does not declare mediaUnderstandingProviders.`,n;return t[6]===e?n=t[7]:(n=(0,F.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e}),t[6]=e,t[7]=n),n}if(!g)return null;let y=`${n}:${m}`,b;return t[8]!==_||t[9]!==m||t[10]!==y||t[11]!==g?(b=(0,F.jsx)(q,{providerId:m,voiceSettings:g,mutateVoice:_},y),t[8]=_,t[9]=m,t[10]=y,t[11]=g,t[12]=b):b=t[12],b}function Y(e){return!!e.token}function X(e){return e.language}function Z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Q(e){let t={};if(e.type!==`object`||!Z(e.properties))return t;for(let[n,r]of Object.entries(e.properties))Z(r)&&Object.prototype.hasOwnProperty.call(r,`default`)&&(t[n]=r.default);return t}function ee(e,t){switch(t.type){case`sync`:return{...e,localValues:t.value,isDirty:!1,saveError:null};case`change`:return{...e,localValues:t.value,isDirty:!0,saveError:null,saveSuccess:!1};case`discard`:return{...e,localValues:t.value,isDirty:!1,saveError:null};case`reset-defaults`:return{...e,localValues:t.value,isDirty:!0,saveError:null,saveSuccess:!1};case`save-start`:return{...e,saving:!0,saveError:null};case`save-success`:return{...e,localValues:t.value,isDirty:!1,saving:!1,saveSuccess:!0,saveError:null};case`save-error`:return{...e,saving:!1,saveError:t.message}}}function te({extensionId:e}){let t=a(o(e=>e.language)).agentSettings,n=s(e=>!!e.token),{data:r,error:i}=f(n&&e?`ext-detail-${e}`:null,()=>l(c(`/api/extensions/${encodeURIComponent(e)}`))),{data:p,mutate:m,error:h}=f(n&&e?`ext-cfg-${e}`:null,()=>l(c(`/api/extensions/${encodeURIComponent(e)}/config`))),g=r?.manifest?.configSchema,_=(0,P.useMemo)(()=>g&&g.type===`object`?Q(g):{},[g]),v=(0,P.useMemo)(()=>({..._,...p??{}}),[_,p]),[b,x]=(0,P.useReducer)(ee,{localValues:{},isDirty:!1,saving:!1,saveError:null,saveSuccess:!1}),[S,C]=(0,P.useState)(!1),w=(0,P.useRef)(!1),T=(0,P.useRef)(v);!w.current&&T.current!==v&&(T.current=v,x({type:`sync`,value:v}));let E=(0,P.useCallback)(e=>{w.current=!0,x({type:`change`,value:e})},[]),D=(0,P.useCallback)(()=>{w.current=!1,x({type:`discard`,value:v})},[v]),O=(0,P.useCallback)(()=>{!g||g.type!==`object`||(w.current=!0,x({type:`reset-defaults`,value:{...Q(g)}}))},[g]),k=(0,P.useCallback)(async()=>{if(e){x({type:`save-start`});try{let n=await u(c(`/api/extensions/${encodeURIComponent(e)}/config`),{method:`PATCH`,body:JSON.stringify(b.localValues)});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error?.message??n.statusText)}await m(b.localValues,!1),w.current=!1,x({type:`save-success`,value:b.localValues}),C(!0),d({type:`success`,title:t.saved})}catch(e){x({type:`save-error`,message:e instanceof Error?e.message:String(e)})}}},[b.localValues,e,m]);if(!n)return null;if(i||h){let e=i??h;return(0,F.jsxs)(`p`,{className:`text-sm text-fg-muted`,children:[`Could not load extension settings: `,e instanceof Error?e.message:String(e)]})}return!g||g.type!==`object`?null:(0,F.jsxs)(`div`,{className:`mb-6 flex flex-col gap-3 rounded-xl border border-edge bg-surface-base p-4`,children:[(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,F.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:`Configuration`}),(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[b.saveError?(0,F.jsx)(`span`,{className:`text-xs text-red-600 dark:text-red-400`,children:b.saveError}):null,(0,F.jsx)(y,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,disabled:!b.isDirty,onClick:D,children:t.discard}),(0,F.jsx)(y,{type:`button`,variant:`ghost`,className:`h-8 text-xs`,onClick:O,children:`Reset to defaults`}),(0,F.jsx)(y,{type:`button`,variant:`primary`,className:`h-8 text-xs`,disabled:!b.isDirty||b.saving,onClick:()=>void k(),children:b.saving?t.saving:t.save})]})]}),(0,F.jsx)(M,{schema:g,values:b.localValues,onChange:E,disabled:b.saving})]})}function ne(){let e=(0,N.c)(47),t=o(re),n;e[0]===t?n=e[1]:(n=a(t),e[0]=t,e[1]=n);let r=n,i=r.extensionImageGen,s=r.extensionSttMedia,{extensionId:c,panelId:l}=_(),u=m();if(!c){let t;return e[2]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,F.jsx)($,{message:`No extension ID provided.`}),e[2]=t):t=e[2],t}let d,f,p;if(e[3]!==c||e[4]!==u||e[5]!==l){p=Symbol.for(`react.early_return_sentinel`);bb0:{let t;if(e[9]===c?t=e[10]:(t=e=>e.id===c,e[9]=c,e[10]=t),d=u.find(t),!d){let t=`Extension "${c}" not found or is not available in this workspace.`,n;e[11]===t?n=e[12]:(n=(0,F.jsx)($,{message:t}),e[11]=t,e[12]=n),p=n;break bb0}let n=d.ui?.contributions?.settingsPanels;f=l?n?.find(e=>e.id===l||e.id===`${c}.${l}`):n?.[0]}e[3]=c,e[4]=u,e[5]=l,e[6]=d,e[7]=f,e[8]=p}else d=e[6],f=e[7],p=e[8];if(p!==Symbol.for(`react.early_return_sentinel`))return p;let g=f,y=!!(g&&d.ui),b=!!d.hasConfigSchema,x=d.kind===`image-generation`,S=d.kind===`media-provider`;if(!b&&!y&&!(x||S)){let t=`Extension "${c}" has no settings panels or config schema.`,n;return e[13]===t?n=e[14]:(n=(0,F.jsx)($,{message:t}),e[13]=t,e[14]=n),n}let C=g?.title??`${d.name} Settings`,w;e[15]===C?w=e[16]:(w=(0,F.jsx)(`h1`,{className:`text-lg font-semibold text-fg`,children:C}),e[15]=C,e[16]=w);let T;e[17]!==x||e[18]!==r.imageModelsSettings||e[19]!==i?(T=x?(0,F.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-base px-4 py-3 text-sm`,children:[(0,F.jsx)(`p`,{className:`leading-relaxed text-fg-muted`,children:i.banner}),(0,F.jsx)(h,{to:`/settings/credentials?tab=image-models`,className:`w-fit font-medium text-accent hover:underline`,title:r.imageModelsSettings.imageModelsLinkTitle,children:i.openImageModels})]}):null,e[17]=x,e[18]=r.imageModelsSettings,e[19]=i,e[20]=T):T=e[20];let E;e[21]!==c||e[22]!==x?(E=x?(0,F.jsx)(R,{extensionId:c}):null,e[21]=c,e[22]=x,e[23]=E):E=e[23];let D;e[24]!==S||e[25]!==s?(D=S?(0,F.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-base px-4 py-3 text-sm`,children:[(0,F.jsx)(`p`,{className:`leading-relaxed text-fg-muted`,children:s.banner}),(0,F.jsx)(h,{to:`/settings/credentials?tab=voice`,className:`w-fit font-medium text-accent hover:underline`,children:s.openVoice})]}):null,e[24]=S,e[25]=s,e[26]=D):D=e[26];let O;e[27]!==c||e[28]!==S?(O=S?(0,F.jsx)(J,{extensionId:c}):null,e[27]=c,e[28]=S,e[29]=O):O=e[29];let k;e[30]!==c||e[31]!==b?(k=b?(0,F.jsx)(te,{extensionId:c}):null,e[30]=c,e[31]=b,e[32]=k):k=e[32];let A;e[33]!==d.name||e[34]!==d.ui||e[35]!==c||e[36]!==y||e[37]!==g?(A=y&&g&&d.ui?(0,F.jsx)(`div`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-base`,children:(0,F.jsx)(v,{extensionId:c,extensionName:d.name,entrypoint:g.entrypoint,permissions:d.ui?.permissions,title:g.title,className:`w-full`,minHeight:120,maxHeight:2e3})}):null,e[33]=d.name,e[34]=d.ui,e[35]=c,e[36]=y,e[37]=g,e[38]=A):A=e[38];let j;return e[39]!==w||e[40]!==T||e[41]!==E||e[42]!==D||e[43]!==O||e[44]!==k||e[45]!==A?(j=(0,F.jsxs)(`div`,{className:`flex w-full flex-col gap-3 px-3 py-8 sm:px-5 xl:px-6`,children:[w,T,E,D,O,k,A]}),e[39]=w,e[40]=T,e[41]=E,e[42]=D,e[43]=O,e[44]=k,e[45]=A,e[46]=j):j=e[46],j}function re(e){return e.language}function $(e){let t=(0,N.c)(2),{message:n}=e,r;return t[0]===n?r=t[1]:(r=(0,F.jsx)(`div`,{className:`flex w-full flex-col gap-3 px-3 py-8 sm:px-5 xl:px-6`,children:(0,F.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n})}),t[0]=n,t[1]=r),r}export{ne as ExtensionSettingsPage};
@@ -1 +1 @@
1
- import{t as e}from"./messages-avfvyZuQ.js";import{a as t,c as n,n as r,o as i,r as a}from"./locale-store-Ba72bFmP.js";var o=n((e,t)=>({baseUrl:typeof window<`u`?window.location.origin:``,token:void 0,tokenDialogOpen:!1,tokenExpired:!1,setGatewayToken:t=>{i(t),e({token:t,tokenDialogOpen:!1,tokenExpired:!1}),window.dispatchEvent(new CustomEvent(`token-saved`,{detail:{token:t}}))},clearGatewayToken:()=>{a(),e({token:void 0})},openTokenDialog:()=>e({tokenDialogOpen:!0}),closeTokenDialog:()=>e({tokenDialogOpen:!1}),onUnauthorized:()=>{t().clearGatewayToken(),e({tokenDialogOpen:!1,tokenExpired:!0}),window.dispatchEvent(new CustomEvent(`token-expired`))}}));function s(){let e=new URLSearchParams(window.location.search).get(`token`);if(e){o.getState().setGatewayToken(e);let t=window.location.pathname+window.location.hash,n=window.history.state,r=n&&typeof n==`object`&&!Array.isArray(n)?{...n}:n;window.history.replaceState(r,``,t);return}let n=t();o.setState({token:n||void 0,tokenDialogOpen:!1})}function c(){return window.location.origin}function l(e){let t=e.startsWith(`/`)?e:`/${e}`;return`${c()}${t}`}function u(e){let t=e.baseUrl.trim().replace(/\/+$/,``),n=new URL(`xopc://gateway/mobile-connect`);return n.searchParams.set(`baseUrl`,t),e.lanUrl?.trim()&&n.searchParams.set(`lanUrl`,e.lanUrl.trim().replace(/\/+$/,``)),n.searchParams.set(`ps`,e.pairingSecret),n.toString()}function d(e){try{let t=new URL(e.trim());if(t.protocol!==`http:`&&t.protocol!==`https:`)return!1;let n=t.hostname.toLowerCase();return!!(n===`localhost`||n===`127.0.0.1`||n===`[::1]`||n===`::1`||/^127\.\d+\.\d+\.\d+$/.test(n))}catch{return!1}}function f(){return r.getState().language}function p(e,t,n){let r=e.trim().toLowerCase();return!!(!r||r===`http ${t}`||n&&r===n.trim().toLowerCase()||t===500&&r===`internal server error`)}function m(t,n,r){let i=r?.trim()??``;if(i&&!p(i,t,n))return i;let a=e(f()).api;return t>=500?t===502?a.errorBadGateway:t===503?a.errorServiceUnavailable:t===504?a.errorGatewayTimeout:t===500?a.errorInternal:a.errorServer.replace(`{{status}}`,String(t)):t===404?a.errorNotFound:t===403?a.errorForbidden:a.errorRequest.replace(`{{status}}`,String(t))}var h=null,g=null;function _(){h||=new Promise(e=>{g=e})}function v(){h&&(g?.(),h=null,g=null)}typeof window<`u`&&window.addEventListener(`token-saved`,v);async function y(e,t){h&&await h;let n=o.getState().token,r=new Headers(t?.headers),i=t?.body,a=typeof FormData<`u`&&i instanceof FormData;!r.has(`Content-Type`)&&!a&&r.set(`Content-Type`,`application/json`),n&&r.set(`Authorization`,`Bearer ${n}`);let s=await fetch(e,{...t,headers:r});return s.status===401&&(_(),o.getState().onUnauthorized()),s}async function b(e,t){let n=await y(e,t);if(!n.ok){let e=await n.json().catch(()=>({})),t=typeof e.error==`string`?e.error:e.error?.message,r=m(n.status,n.statusText,t);throw Object.assign(Error(r),{status:n.status,body:e})}return n.json()}export{u as a,o as c,l as i,b as n,d as o,m as r,s,y as t};
1
+ import{t as e}from"./messages-O6TAtdFC.js";import{a as t,c as n,n as r,o as i,r as a}from"./locale-store-Ba72bFmP.js";var o=n((e,t)=>({baseUrl:typeof window<`u`?window.location.origin:``,token:void 0,tokenDialogOpen:!1,tokenExpired:!1,setGatewayToken:t=>{i(t),e({token:t,tokenDialogOpen:!1,tokenExpired:!1}),window.dispatchEvent(new CustomEvent(`token-saved`,{detail:{token:t}}))},clearGatewayToken:()=>{a(),e({token:void 0})},openTokenDialog:()=>e({tokenDialogOpen:!0}),closeTokenDialog:()=>e({tokenDialogOpen:!1}),onUnauthorized:()=>{t().clearGatewayToken(),e({tokenDialogOpen:!1,tokenExpired:!0}),window.dispatchEvent(new CustomEvent(`token-expired`))}}));function s(){let e=new URLSearchParams(window.location.search).get(`token`);if(e){o.getState().setGatewayToken(e);let t=window.location.pathname+window.location.hash,n=window.history.state,r=n&&typeof n==`object`&&!Array.isArray(n)?{...n}:n;window.history.replaceState(r,``,t);return}let n=t();o.setState({token:n||void 0,tokenDialogOpen:!1})}function c(){return window.location.origin}function l(e){let t=e.startsWith(`/`)?e:`/${e}`;return`${c()}${t}`}function u(e){let t=e.baseUrl.trim().replace(/\/+$/,``),n=new URL(`xopc://gateway/mobile-connect`);return n.searchParams.set(`baseUrl`,t),e.lanUrl?.trim()&&n.searchParams.set(`lanUrl`,e.lanUrl.trim().replace(/\/+$/,``)),n.searchParams.set(`ps`,e.pairingSecret),n.toString()}function d(e){try{let t=new URL(e.trim());if(t.protocol!==`http:`&&t.protocol!==`https:`)return!1;let n=t.hostname.toLowerCase();return!!(n===`localhost`||n===`127.0.0.1`||n===`[::1]`||n===`::1`||/^127\.\d+\.\d+\.\d+$/.test(n))}catch{return!1}}function f(){return r.getState().language}function p(e,t,n){let r=e.trim().toLowerCase();return!!(!r||r===`http ${t}`||n&&r===n.trim().toLowerCase()||t===500&&r===`internal server error`)}function m(t,n,r){let i=r?.trim()??``;if(i&&!p(i,t,n))return i;let a=e(f()).api;return t>=500?t===502?a.errorBadGateway:t===503?a.errorServiceUnavailable:t===504?a.errorGatewayTimeout:t===500?a.errorInternal:a.errorServer.replace(`{{status}}`,String(t)):t===404?a.errorNotFound:t===403?a.errorForbidden:a.errorRequest.replace(`{{status}}`,String(t))}var h=null,g=null;function _(){h||=new Promise(e=>{g=e})}function v(){h&&(g?.(),h=null,g=null)}typeof window<`u`&&window.addEventListener(`token-saved`,v);async function y(e,t){h&&await h;let n=o.getState().token,r=new Headers(t?.headers),i=t?.body,a=typeof FormData<`u`&&i instanceof FormData;!r.has(`Content-Type`)&&!a&&r.set(`Content-Type`,`application/json`),n&&r.set(`Authorization`,`Bearer ${n}`);let s=await fetch(e,{...t,headers:r});return s.status===401&&(_(),o.getState().onUnauthorized()),s}async function b(e,t){let n=await y(e,t);if(!n.ok){let e=await n.json().catch(()=>({})),t=typeof e.error==`string`?e.error:e.error?.message,r=m(n.status,n.statusText,t);throw Object.assign(Error(r),{status:n.status,body:e})}return n.json()}export{u as a,o as c,l as i,b as n,d as o,m as r,s,y as t};
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n}from"./vendor-react-BOUWij0V.js";import{i as r,n as i}from"./fetch-Dtpbbe0s.js";import{Ma as a,Zn as o,ji as s}from"./index-T0SaNd5a.js";var c=e(t(),1),l=n(),u=new Set([`updates`,`security`,`advanced`]),d=new Set([`local`,`cdp`,`cloud`]);function f(e,t){return t===`advanced`?!0:!u.has(e)}function p(e,t){return e.filter(e=>f(e,t))}function m(e,t){return t===`advanced`?!0:!d.has(e)}function h(e,t){return e.filter(e=>m(e,t))}function g(){return`network`}function _(){return`overview`}function v(e,t){let n=(0,l.c)(5),r=o(y),i,a;n[0]!==e||n[1]!==r||n[2]!==t?(i=()=>{f(e,r)||t(g())},a=[e,r,t],n[0]=e,n[1]=r,n[2]=t,n[3]=i,n[4]=a):(i=n[3],a=n[4]),(0,c.useEffect)(i,a)}function y(e){return e.mode}function b(e,t){let n=(0,l.c)(5),r=o(x),i,a;n[0]!==e||n[1]!==r||n[2]!==t?(i=()=>{m(e,r)||t(_())},a=[e,r,t],n[0]=e,n[1]=r,n[2]=t,n[3]=i,n[4]=a):(i=n[3],a=n[4]),(0,c.useEffect)(i,a)}function x(e){return e.mode}var S=18790,C={enabled:!0,maxAttempts:5,windowMs:9e5,blockDurationMs:3e5,exemptLoopback:!0};function w(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function T(e){return a(e)}async function E(e){let t=await i(r(`/api/gateway/reveal-auth-secret/${encodeURIComponent(e)}`),{method:`POST`,body:`{}`});if(!t.ok||!t.payload)throw Error(t.error?.message??`Reveal failed`);return t.payload}async function D(){let e=await i(r(`/api/agents/browser/reveal-cloud-api-key`),{method:`POST`,headers:{"Content-Type":`application/json`},body:`{}`});if(!e.ok||!e.payload)throw Error(e.error?.message??`Reveal failed`);return e.payload}function O(e){return T(e)?``:e.trim()}function k(e){return[...e].map(e=>e.trim()).sort()}function A(e){return JSON.stringify({bind:e.bind,customBindHost:e.customBindHost.trim(),port:e.port,auth:{mode:e.auth.mode,token:O(e.auth.token),password:O(e.auth.password),rateLimit:e.auth.rateLimit,trustedProxy:{userHeader:e.auth.trustedProxy.userHeader.trim(),requiredHeaders:k(e.auth.trustedProxy.requiredHeaders),allowUsers:k(e.auth.trustedProxy.allowUsers),allowLoopback:e.auth.trustedProxy.allowLoopback}},corsOrigins:k(e.corsOrigins),trustedProxies:k(e.trustedProxies),allowRealIpFallback:e.allowRealIpFallback,dangerouslyAllowHostHeaderOriginFallback:e.dangerouslyAllowHostHeaderOriginFallback})}function j(e,t){return A(e)!==A(t)}function M(e){return e===`none`||e===`token`||e===`password`||e===`trusted-proxy`?e:`token`}function N(e){let t=w(e)?e:{};return{enabled:t.enabled!==!1,maxAttempts:typeof t.maxAttempts==`number`&&Number.isFinite(t.maxAttempts)?Math.max(1,Math.floor(t.maxAttempts)):C.maxAttempts,windowMs:typeof t.windowMs==`number`&&Number.isFinite(t.windowMs)&&t.windowMs>0?Math.floor(t.windowMs):C.windowMs,blockDurationMs:typeof t.blockDurationMs==`number`&&Number.isFinite(t.blockDurationMs)&&t.blockDurationMs>0?Math.floor(t.blockDurationMs):typeof t.lockoutMs==`number`&&Number.isFinite(t.lockoutMs)&&t.lockoutMs>0?Math.floor(t.lockoutMs):C.blockDurationMs,exemptLoopback:t.exemptLoopback!==!1}}function P(e){let t=w(e)?e:{};return{userHeader:typeof t.userHeader==`string`?t.userHeader:``,requiredHeaders:I(t.requiredHeaders,32),allowUsers:I(t.allowUsers,128),allowLoopback:t.allowLoopback===!0}}function F(e){return e===`auto`||e===`off`||e===`explicit`?e:`auto`}function I(e,t=24){return Array.isArray(e)?e.filter(e=>typeof e==`string`&&e.trim().length>0).map(e=>e.trim()).slice(0,t):[]}function L(e){return e===`auto`||e===`loopback`||e===`lan`||e===`tailnet`||e===`custom`?e:`loopback`}function R(e){if(e.bind===`loopback`)return!1;if(e.bind===`lan`)return!0;if(e.bind===`custom`){let t=e.customBindHost.trim().toLowerCase();return t?t!==`127.0.0.1`&&t!==`localhost`&&t!==`::1`:!0}return!0}function z(e){let t=R(e);return t&&e.auth.mode===`none`?`Network-accessible gateway requires authentication (token, password, or trusted-proxy).`:t&&e.auth.mode===`trusted-proxy`&&e.trustedProxies.length===0?`Trusted-proxy auth on a network bind requires at least one gateway.trustedProxies entry.`:e.auth.mode===`trusted-proxy`&&!e.auth.trustedProxy.userHeader.trim()?`Trusted-proxy auth requires gateway.auth.trustedProxy.userHeader.`:t&&e.corsOrigins.includes(`*`)?`CORS wildcard "*" is not allowed on network-accessible binds.`:e.bind===`custom`&&!e.customBindHost.trim()?`Custom bind mode requires a bind address.`:null}function B(e){let t=w(e)?e:{},n=w(t.gateway)?t.gateway:{},r=w(n.auth)?n.auth:{},i=w(n.security)?n.security:{},a=w(t.update)?t.update:{},o=w(a.auto)?a.auto:{},s=a.channel,c=s===`beta`||s===`dev`||s===`stable`?s:`stable`,l=Array.isArray(n.corsOrigins)?n.corsOrigins.filter(e=>typeof e==`string`&&e.trim().length>0):[];return{bind:L(n.bind),customBindHost:typeof n.customBindHost==`string`&&n.customBindHost.trim()?n.customBindHost.trim():``,port:typeof n.port==`number`&&Number.isFinite(n.port)?Math.floor(n.port):S,auth:{mode:M(r.mode),token:typeof r.token==`string`?r.token:``,password:typeof r.password==`string`?r.password:``,rateLimit:N(r.rateLimit),trustedProxy:P(r.trustedProxy)},corsOrigins:l,trustedProxies:I(n.trustedProxies,64),allowRealIpFallback:n.allowRealIpFallback===!0,dangerouslyAllowHostHeaderOriginFallback:n.dangerouslyAllowHostHeaderOriginFallback===!0,securityStrict:i.strict===!0,maxSseConnections:typeof n.maxSseConnections==`number`&&Number.isFinite(n.maxSseConnections)?Math.max(1,Math.floor(n.maxSseConnections)):100,channelConnectDeferMode:F(n.channelConnectDeferMode),channelConnectDeferIds:I(n.channelConnectDeferIds),channelConnectDeferSkipIds:I(n.channelConnectDeferSkipIds),updateChannel:c,updateCheckOnStart:a.checkOnStart!==!1,updateAutoEnabled:o.enabled===!0,updateAutoStableDelayHours:typeof o.stableDelayHours==`number`&&Number.isFinite(o.stableDelayHours)?Math.max(0,Math.floor(o.stableDelayHours)):6,updateAutoStableJitterHours:typeof o.stableJitterHours==`number`&&Number.isFinite(o.stableJitterHours)?Math.max(0,Math.floor(o.stableJitterHours)):12,updateAutoBetaCheckIntervalHours:typeof o.betaCheckIntervalHours==`number`&&Number.isFinite(o.betaCheckIntervalHours)?Math.max(.25,o.betaCheckIntervalHours):1}}function V(e){let t={mode:e.auth.mode,rateLimit:e.auth.rateLimit};if(e.auth.mode===`token`){let n=e.auth.token.trim();n.length>0&&!T(n)&&(t.token=e.auth.token),t.password=null,t.trustedProxy=null}else if(e.auth.mode===`password`){let n=e.auth.password.trim();n.length>0&&!T(n)&&(t.password=e.auth.password),t.token=null,t.trustedProxy=null}else if(e.auth.mode===`trusted-proxy`){t.token=null,t.password=null;let n=e.auth.trustedProxy;t.trustedProxy={userHeader:n.userHeader.trim(),...n.requiredHeaders.length>0?{requiredHeaders:n.requiredHeaders}:{},...n.allowUsers.length>0?{allowUsers:n.allowUsers}:{},...n.allowLoopback?{allowLoopback:!0}:{}}}else t.token=null,t.password=null,t.trustedProxy=null;return t}async function H(e){let t=z(e);if(t)throw Error(t);await i(r(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{bind:e.bind,...e.bind===`custom`?{customBindHost:e.customBindHost.trim()}:{},port:e.port,auth:V(e),corsOrigins:e.corsOrigins,trustedProxies:e.trustedProxies,allowRealIpFallback:e.allowRealIpFallback,dangerouslyAllowHostHeaderOriginFallback:e.dangerouslyAllowHostHeaderOriginFallback,security:{strict:e.securityStrict},maxSseConnections:e.maxSseConnections,channelConnectDeferMode:e.channelConnectDeferMode,channelConnectDeferIds:e.channelConnectDeferIds,channelConnectDeferSkipIds:e.channelConnectDeferSkipIds},update:{channel:e.updateChannel,checkOnStart:e.updateCheckOnStart,auto:{enabled:e.updateAutoEnabled,stableDelayHours:e.updateAutoStableDelayHours,stableJitterHours:e.updateAutoStableJitterHours,betaCheckIntervalHours:e.updateAutoBetaCheckIntervalHours}}})}),s()}export{E as a,v as c,p as d,D as i,m as l,B as n,z as o,H as r,b as s,j as t,h as u};
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n}from"./vendor-react-BOUWij0V.js";import{i as r,n as i}from"./fetch-BU5S0Sn7.js";import{Mi as a,Na as o,Zn as s}from"./index-c_9TVr_C.js";var c=e(t(),1),l=n(),u=new Set([`updates`,`security`,`advanced`]),d=new Set([`local`,`cdp`,`cloud`]);function f(e,t){return t===`advanced`?!0:!u.has(e)}function p(e,t){return e.filter(e=>f(e,t))}function m(e,t){return t===`advanced`?!0:!d.has(e)}function h(e,t){return e.filter(e=>m(e,t))}function g(){return`network`}function _(){return`overview`}function v(e,t){let n=(0,l.c)(5),r=s(y),i,a;n[0]!==e||n[1]!==r||n[2]!==t?(i=()=>{f(e,r)||t(g())},a=[e,r,t],n[0]=e,n[1]=r,n[2]=t,n[3]=i,n[4]=a):(i=n[3],a=n[4]),(0,c.useEffect)(i,a)}function y(e){return e.mode}function b(e,t){let n=(0,l.c)(5),r=s(x),i,a;n[0]!==e||n[1]!==r||n[2]!==t?(i=()=>{m(e,r)||t(_())},a=[e,r,t],n[0]=e,n[1]=r,n[2]=t,n[3]=i,n[4]=a):(i=n[3],a=n[4]),(0,c.useEffect)(i,a)}function x(e){return e.mode}var S=18790,C={enabled:!0,maxAttempts:5,windowMs:9e5,blockDurationMs:3e5,exemptLoopback:!0};function w(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function T(e){return o(e)}async function E(e){let t=await i(r(`/api/gateway/reveal-auth-secret/${encodeURIComponent(e)}`),{method:`POST`,body:`{}`});if(!t.ok||!t.payload)throw Error(t.error?.message??`Reveal failed`);return t.payload}async function D(){let e=await i(r(`/api/agents/browser/reveal-cloud-api-key`),{method:`POST`,headers:{"Content-Type":`application/json`},body:`{}`});if(!e.ok||!e.payload)throw Error(e.error?.message??`Reveal failed`);return e.payload}function O(e){return T(e)?``:e.trim()}function k(e){return[...e].map(e=>e.trim()).sort()}function A(e){return JSON.stringify({bind:e.bind,customBindHost:e.customBindHost.trim(),port:e.port,auth:{mode:e.auth.mode,token:O(e.auth.token),password:O(e.auth.password),rateLimit:e.auth.rateLimit,trustedProxy:{userHeader:e.auth.trustedProxy.userHeader.trim(),requiredHeaders:k(e.auth.trustedProxy.requiredHeaders),allowUsers:k(e.auth.trustedProxy.allowUsers),allowLoopback:e.auth.trustedProxy.allowLoopback}},corsOrigins:k(e.corsOrigins),trustedProxies:k(e.trustedProxies),allowRealIpFallback:e.allowRealIpFallback,dangerouslyAllowHostHeaderOriginFallback:e.dangerouslyAllowHostHeaderOriginFallback})}function j(e,t){return A(e)!==A(t)}function M(e){return e===`none`||e===`token`||e===`password`||e===`trusted-proxy`?e:`token`}function N(e){let t=w(e)?e:{};return{enabled:t.enabled!==!1,maxAttempts:typeof t.maxAttempts==`number`&&Number.isFinite(t.maxAttempts)?Math.max(1,Math.floor(t.maxAttempts)):C.maxAttempts,windowMs:typeof t.windowMs==`number`&&Number.isFinite(t.windowMs)&&t.windowMs>0?Math.floor(t.windowMs):C.windowMs,blockDurationMs:typeof t.blockDurationMs==`number`&&Number.isFinite(t.blockDurationMs)&&t.blockDurationMs>0?Math.floor(t.blockDurationMs):typeof t.lockoutMs==`number`&&Number.isFinite(t.lockoutMs)&&t.lockoutMs>0?Math.floor(t.lockoutMs):C.blockDurationMs,exemptLoopback:t.exemptLoopback!==!1}}function P(e){let t=w(e)?e:{};return{userHeader:typeof t.userHeader==`string`?t.userHeader:``,requiredHeaders:I(t.requiredHeaders,32),allowUsers:I(t.allowUsers,128),allowLoopback:t.allowLoopback===!0}}function F(e){return e===`auto`||e===`off`||e===`explicit`?e:`auto`}function I(e,t=24){return Array.isArray(e)?e.filter(e=>typeof e==`string`&&e.trim().length>0).map(e=>e.trim()).slice(0,t):[]}function L(e){return e===`auto`||e===`loopback`||e===`lan`||e===`tailnet`||e===`custom`?e:`loopback`}function R(e){if(e.bind===`loopback`)return!1;if(e.bind===`lan`)return!0;if(e.bind===`custom`){let t=e.customBindHost.trim().toLowerCase();return t?t!==`127.0.0.1`&&t!==`localhost`&&t!==`::1`:!0}return!0}function z(e){let t=R(e);return t&&e.auth.mode===`none`?`Network-accessible gateway requires authentication (token, password, or trusted-proxy).`:t&&e.auth.mode===`trusted-proxy`&&e.trustedProxies.length===0?`Trusted-proxy auth on a network bind requires at least one gateway.trustedProxies entry.`:e.auth.mode===`trusted-proxy`&&!e.auth.trustedProxy.userHeader.trim()?`Trusted-proxy auth requires gateway.auth.trustedProxy.userHeader.`:t&&e.corsOrigins.includes(`*`)?`CORS wildcard "*" is not allowed on network-accessible binds.`:e.bind===`custom`&&!e.customBindHost.trim()?`Custom bind mode requires a bind address.`:null}function B(e){let t=w(e)?e:{},n=w(t.gateway)?t.gateway:{},r=w(n.auth)?n.auth:{},i=w(n.security)?n.security:{},a=w(t.update)?t.update:{},o=w(a.auto)?a.auto:{},s=a.channel,c=s===`beta`||s===`dev`||s===`stable`?s:`stable`,l=Array.isArray(n.corsOrigins)?n.corsOrigins.filter(e=>typeof e==`string`&&e.trim().length>0):[];return{bind:L(n.bind),customBindHost:typeof n.customBindHost==`string`&&n.customBindHost.trim()?n.customBindHost.trim():``,port:typeof n.port==`number`&&Number.isFinite(n.port)?Math.floor(n.port):S,auth:{mode:M(r.mode),token:typeof r.token==`string`?r.token:``,password:typeof r.password==`string`?r.password:``,rateLimit:N(r.rateLimit),trustedProxy:P(r.trustedProxy)},corsOrigins:l,trustedProxies:I(n.trustedProxies,64),allowRealIpFallback:n.allowRealIpFallback===!0,dangerouslyAllowHostHeaderOriginFallback:n.dangerouslyAllowHostHeaderOriginFallback===!0,securityStrict:i.strict===!0,maxSseConnections:typeof n.maxSseConnections==`number`&&Number.isFinite(n.maxSseConnections)?Math.max(1,Math.floor(n.maxSseConnections)):100,channelConnectDeferMode:F(n.channelConnectDeferMode),channelConnectDeferIds:I(n.channelConnectDeferIds),channelConnectDeferSkipIds:I(n.channelConnectDeferSkipIds),updateChannel:c,updateCheckOnStart:a.checkOnStart!==!1,updateAutoEnabled:o.enabled===!0,updateAutoStableDelayHours:typeof o.stableDelayHours==`number`&&Number.isFinite(o.stableDelayHours)?Math.max(0,Math.floor(o.stableDelayHours)):6,updateAutoStableJitterHours:typeof o.stableJitterHours==`number`&&Number.isFinite(o.stableJitterHours)?Math.max(0,Math.floor(o.stableJitterHours)):12,updateAutoBetaCheckIntervalHours:typeof o.betaCheckIntervalHours==`number`&&Number.isFinite(o.betaCheckIntervalHours)?Math.max(.25,o.betaCheckIntervalHours):1}}function V(e){let t={mode:e.auth.mode,rateLimit:e.auth.rateLimit};if(e.auth.mode===`token`){let n=e.auth.token.trim();n.length>0&&!T(n)&&(t.token=e.auth.token),t.password=null,t.trustedProxy=null}else if(e.auth.mode===`password`){let n=e.auth.password.trim();n.length>0&&!T(n)&&(t.password=e.auth.password),t.token=null,t.trustedProxy=null}else if(e.auth.mode===`trusted-proxy`){t.token=null,t.password=null;let n=e.auth.trustedProxy;t.trustedProxy={userHeader:n.userHeader.trim(),...n.requiredHeaders.length>0?{requiredHeaders:n.requiredHeaders}:{},...n.allowUsers.length>0?{allowUsers:n.allowUsers}:{},...n.allowLoopback?{allowLoopback:!0}:{}}}else t.token=null,t.password=null,t.trustedProxy=null;return t}async function H(e){let t=z(e);if(t)throw Error(t);await i(r(`/api/config`),{method:`PATCH`,body:JSON.stringify({gateway:{bind:e.bind,...e.bind===`custom`?{customBindHost:e.customBindHost.trim()}:{},port:e.port,auth:V(e),corsOrigins:e.corsOrigins,trustedProxies:e.trustedProxies,allowRealIpFallback:e.allowRealIpFallback,dangerouslyAllowHostHeaderOriginFallback:e.dangerouslyAllowHostHeaderOriginFallback,security:{strict:e.securityStrict},maxSseConnections:e.maxSseConnections,channelConnectDeferMode:e.channelConnectDeferMode,channelConnectDeferIds:e.channelConnectDeferIds,channelConnectDeferSkipIds:e.channelConnectDeferSkipIds},update:{channel:e.updateChannel,checkOnStart:e.updateCheckOnStart,auto:{enabled:e.updateAutoEnabled,stableDelayHours:e.updateAutoStableDelayHours,stableJitterHours:e.updateAutoStableJitterHours,betaCheckIntervalHours:e.updateAutoBetaCheckIntervalHours}}})}),a()}export{E as a,v as c,p as d,D as i,m as l,B as n,z as o,H as r,b as s,j as t,h as u};