@xopcai/xopc 0.0.323 → 0.0.325

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 (572) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/telegram/xopc.extension.json +1 -1
  3. package/dist/extensions/weixin/src/plugin.js +1 -9
  4. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-DFzmThVi.js → agent-avatar-dicebear-CxfXpPWs.js} +1 -1
  5. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-CDHe8gJf.js +1 -0
  6. package/dist/gateway/static/root/assets/{agent-plugin-dialog-DYFYiuig.js → agent-plugin-dialog-DMv-udoZ.js} +1 -1
  7. package/dist/gateway/static/root/assets/{agents-BqIlB5Co.js → agents-D_xOAXgj.js} +1 -1
  8. package/dist/gateway/static/root/assets/{app-management-settings-panel-BgvMRGWe.js → app-management-settings-panel-p7fZB4dT.js} +1 -1
  9. package/dist/gateway/static/root/assets/{appearance-settings-CliHU03A.js → appearance-settings-C-clVcfp.js} +1 -1
  10. package/dist/gateway/static/root/assets/apps-page-Dz2g7eAN.js +1 -0
  11. package/dist/gateway/static/root/assets/{archive-plugin-DnuPpm0u.js → archive-plugin-Xm6xChUX.js} +1 -1
  12. package/dist/gateway/static/root/assets/{attachment-load-BiwaK0ie.js → attachment-load-Di8kuG4L.js} +1 -1
  13. package/dist/gateway/static/root/assets/{automations-page-CJSISGQH.js → automations-page-GUZgDhKj.js} +1 -1
  14. package/dist/gateway/static/root/assets/automations-workspace-BUZhG9aJ.js +7 -0
  15. package/dist/gateway/static/root/assets/{binary-plugins-KDjduQZO.js → binary-plugins-OCrDjC9O.js} +1 -1
  16. package/dist/gateway/static/root/assets/{block-editor-bclvgove.js → block-editor-m9tqvu7x.js} +3 -3
  17. package/dist/gateway/static/root/assets/{browser-automation-inputs-CfQ2T9t6.js → browser-automation-inputs-DSWXq9lI.js} +1 -1
  18. package/dist/gateway/static/root/assets/{browser-automations-page-Cxq38Nnp.js → browser-automations-page-DuOaridE.js} +2 -2
  19. package/dist/gateway/static/root/assets/browser-settings-page-D2_PgHep.js +3 -0
  20. package/dist/gateway/static/root/assets/capabilities-sAZT4brT.js +1 -0
  21. package/dist/gateway/static/root/assets/capabilities-settings-panel-7Y_pJqyt.js +8 -0
  22. package/dist/gateway/static/root/assets/channels-settings-B-Igy1ro.js +1 -0
  23. package/dist/gateway/static/root/assets/{chat-terminal-dock-DKQC62nQ.js → chat-terminal-dock-BfnVh8oo.js} +1 -1
  24. package/dist/gateway/static/root/assets/{computer-settings-page-D1whpIqL.js → computer-settings-page-aRG2lU4w.js} +1 -1
  25. package/dist/gateway/static/root/assets/{connector-service-page-BAuYTgf5.js → connector-service-page-B5EhnfJH.js} +1 -1
  26. package/dist/gateway/static/root/assets/connectors-page-7HfRt1LW.js +2 -0
  27. package/dist/gateway/static/root/assets/date-picker-CtDyij_x.js +1 -0
  28. package/dist/gateway/static/root/assets/{dependency-picker-DOuVO2M1.js → dependency-picker-z6ouWxmz.js} +1 -1
  29. package/dist/gateway/static/root/assets/{desktop-pet-D9tu6Bhu.js → desktop-pet-BsIYCAkG.js} +1 -1
  30. package/dist/gateway/static/root/assets/{desktop-pet-settings-CQPXub2f.js → desktop-pet-settings-z-0aQ5ct.js} +1 -1
  31. package/dist/gateway/static/root/assets/{device-pairing-wizard-DxkOYSut.js → device-pairing-wizard-DlmhQvY5.js} +1 -1
  32. package/dist/gateway/static/root/assets/dist-3h6cXXhT.js +1 -0
  33. package/dist/gateway/static/root/assets/{extension-debug-page-CtWClPz-.js → extension-debug-page-Ct9pABNW.js} +1 -1
  34. package/dist/gateway/static/root/assets/{extension-page-BHh9HLCz.js → extension-page-BktsR4hj.js} +1 -1
  35. package/dist/gateway/static/root/assets/{extension-settings-page-BdT3v5Uh.js → extension-settings-page-BQJc-vXH.js} +1 -1
  36. package/dist/gateway/static/root/assets/{gateway-config-swr-1eqyz9vZ.js → gateway-config-swr-CoQVulMd.js} +1 -1
  37. package/dist/gateway/static/root/assets/{gateway-settings-CZas_Ekx.js → gateway-settings-BfDVlvy6.js} +1 -1
  38. package/dist/gateway/static/root/assets/{gateway-startup-retry-C4rsW6vJ.js → gateway-startup-retry-B5GJ-CQV.js} +1 -1
  39. package/dist/gateway/static/root/assets/home-page-CI_eQTPL.js +1 -0
  40. package/dist/gateway/static/root/assets/{image-generation-api-B5DXMylk.js → image-generation-api-DvWDkbk1.js} +1 -1
  41. package/dist/gateway/static/root/assets/{imports-page-B1JH0G5j.js → imports-page-DFpQfHVU.js} +1 -1
  42. package/dist/gateway/static/root/assets/index-19rMUT3d.js +121 -0
  43. package/dist/gateway/static/root/assets/{index-CNc4N4TX.css → index-BKL5tg2f.css} +1 -1
  44. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-DGrLJ8Yh.js → keyboard-shortcuts-settings-ctJLm8TP.js} +1 -1
  45. package/dist/gateway/static/root/assets/local-app-workbench-page-C9kaP3Dy.js +1 -0
  46. package/dist/gateway/static/root/assets/{local-apps-page-DqjStqbL.js → local-apps-page-BxC_LTqq.js} +1 -1
  47. package/dist/gateway/static/root/assets/{locale-store-BIkcRr3t.js → locale-store-BPZR8x9b.js} +1 -1
  48. package/dist/gateway/static/root/assets/logs-page-Ok5SpG-G.js +2 -0
  49. package/dist/gateway/static/root/assets/{management-settings-gCfH4cwH.js → management-settings-aOzRaQHM.js} +1 -1
  50. package/dist/gateway/static/root/assets/{markdown-view-Ck_5MADq.js → markdown-view-Dft8ASFD.js} +1 -1
  51. package/dist/gateway/static/root/assets/{media-plugins-DTsZqgo6.js → media-plugins-ni5zJ4Ok.js} +1 -1
  52. package/dist/gateway/static/root/assets/messages-kFWhF6_t.js +3 -0
  53. package/dist/gateway/static/root/assets/note-detail-panel-C9OEltN9.js +5 -0
  54. package/dist/gateway/static/root/assets/notes-page-Dj9rMgdi.js +8 -0
  55. package/dist/gateway/static/root/assets/{page-context-capture-button-DTI_g4tz.js → page-context-capture-button-BJA3d8vU.js} +1 -1
  56. package/dist/gateway/static/root/assets/{page-tabs-CfW_Q-K5.js → page-tabs-Dyc3wKkl.js} +1 -1
  57. package/dist/gateway/static/root/assets/popover-select-DcsFzD_i.js +1 -0
  58. package/dist/gateway/static/root/assets/{preview-open-alternatives-CuPN-vAn.js → preview-open-alternatives-tIOIQbNX.js} +1 -1
  59. package/dist/gateway/static/root/assets/{product-open-page-BHjxRz1E.js → product-open-page-DQctU8z3.js} +1 -1
  60. package/dist/gateway/static/root/assets/project-detail-page-Dy-EwZcc.js +1 -0
  61. package/dist/gateway/static/root/assets/{projects-page-Bk-es4i9.js → projects-page-JaGKa6rM.js} +1 -1
  62. package/dist/gateway/static/root/assets/{registry-api-BAAZUGnU.js → registry-api-DWWO6ajd.js} +1 -1
  63. package/dist/gateway/static/root/assets/remote-access-hub-Cb8-nd60.js +1 -0
  64. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-CHJBJKL1.js → runtime-tools-settings-panel-xhOSYfiX.js} +1 -1
  65. package/dist/gateway/static/root/assets/scenes-page-ClBkFdRY.js +2 -0
  66. package/dist/gateway/static/root/assets/{schema-form-FQAit5HL.js → schema-form-z8IeSdBp.js} +1 -1
  67. package/dist/gateway/static/root/assets/sessions-page-BYW5l_nY.js +1 -0
  68. package/dist/gateway/static/root/assets/settings-advanced-gate-CDNwmXuH.js +1 -0
  69. package/dist/gateway/static/root/assets/{settings-form-section-BDc6bw1q.js → settings-form-section-BXTJAser.js} +1 -1
  70. package/dist/gateway/static/root/assets/{settings-page-DnhxBJjV.js → settings-page-Br9no5e4.js} +1 -1
  71. package/dist/gateway/static/root/assets/{settings-page-layout-D3KNSQ5g.js → settings-page-layout-D6745w0p.js} +1 -1
  72. package/dist/gateway/static/root/assets/setup-status-panel-D2N9764S.js +1 -0
  73. package/dist/gateway/static/root/assets/{share-preview-page-DVQCRxwK.js → share-preview-page-CE0SER59.js} +1 -1
  74. package/dist/gateway/static/root/assets/shares-settings-Dk3_QOKQ.js +1 -0
  75. package/dist/gateway/static/root/assets/skill-reload-api-CPt61fEv.js +1 -0
  76. package/dist/gateway/static/root/assets/skills-page-Db6PB2C6.js +2 -0
  77. package/dist/gateway/static/root/assets/{skills-page.utils-mDwC9UJ-.js → skills-page.utils-DrtW5FBy.js} +1 -1
  78. package/dist/gateway/static/root/assets/{system-settings-panel-Bk7GrMij.js → system-settings-panel-CuY1Zh5s.js} +1 -1
  79. package/dist/gateway/static/root/assets/task-detail-page-o7RiDUMi.js +1 -0
  80. package/dist/gateway/static/root/assets/{tunnel-api-D3Aquraj.js → tunnel-api-PGHDgvWb.js} +1 -1
  81. package/dist/gateway/static/root/assets/{use-autosave-C1xQ-sHn.js → use-autosave-B55oBQUt.js} +1 -1
  82. package/dist/gateway/static/root/assets/user-model-page-DspelwAa.js +2 -0
  83. package/dist/gateway/static/root/assets/{voice-api-key-field-DCNECvcp.js → voice-api-key-field-By6Lgbse.js} +1 -1
  84. package/dist/gateway/static/root/assets/{voice-config-api-B-_niUTU.js → voice-config-api-BaxITrwZ.js} +1 -1
  85. package/dist/gateway/static/root/assets/{work-discovery-overlay-BrGx_JS_.js → work-discovery-overlay-DdhgIlyf.js} +1 -1
  86. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-CmmC2Pdr.js → workflow-run-setup-panel-BOJYQaxX.js} +2 -2
  87. package/dist/gateway/static/root/assets/workflows-page-6ObD0IQZ.js +6 -0
  88. package/dist/gateway/static/root/index.html +11 -10
  89. package/dist/package.js +1 -1
  90. package/dist/packages/gateway-contract/src/home.js +284 -55
  91. package/dist/packages/gateway-contract/src/index.js +0 -2
  92. package/dist/packages/gateway-contract/src/notifications.js +3 -10
  93. package/dist/src/activity/emitter.js +2 -1
  94. package/dist/src/activity/service.js +2 -1
  95. package/dist/src/agent/agent-manager.d.ts +3 -2
  96. package/dist/src/agent/agent-manager.js +36 -44
  97. package/dist/src/agent/agent-scope.d.ts +19 -48
  98. package/dist/src/agent/agent-scope.js +47 -169
  99. package/dist/src/agent/background-review/run-background-review.js +5 -4
  100. package/dist/src/agent/bootstrap/filter-bootstrap-files.js +1 -1
  101. package/dist/src/agent/commands/command-registry.js +7 -3
  102. package/dist/src/agent/context/coordinator.js +1 -1
  103. package/dist/src/agent/context/execution-context.js +2 -1
  104. package/dist/src/agent/context/execution-scope.js +2 -1
  105. package/dist/src/agent/context/workspace-seed.d.ts +1 -2
  106. package/dist/src/agent/context/workspace-seed.js +3 -3
  107. package/dist/src/agent/context/workspace-state.js +1 -1
  108. package/dist/src/agent/embedded/run-for-session.js +2 -2
  109. package/dist/src/agent/embedded/run-turn.js +2 -1
  110. package/dist/src/agent/embedded/sqlite-hydrating-session-manager.js +2 -1
  111. package/dist/src/agent/external-tools/cliProvider.js +2 -1
  112. package/dist/src/agent/external-tools/composio-provider.js +2 -1
  113. package/dist/src/agent/external-tools/endpoint-provider.js +2 -2
  114. package/dist/src/agent/external-tools/index.js +2 -3
  115. package/dist/src/agent/external-tools/mcp-provider.js +2 -2
  116. package/dist/src/agent/image/tool-model-config.js +4 -5
  117. package/dist/src/agent/inbound/attachment-pipeline.js +1 -1
  118. package/dist/src/agent/ipc/bus.js +1 -1
  119. package/dist/src/agent/ipc/socket.js +3 -3
  120. package/dist/src/agent/media-generation/runtime-shared.d.ts +1 -1
  121. package/dist/src/agent/media-generation/runtime-shared.js +1 -1
  122. package/dist/src/agent/memory/plugin-discovery.js +1 -2
  123. package/dist/src/agent/models/manager.d.ts +1 -1
  124. package/dist/src/agent/models/manager.js +2 -2
  125. package/dist/src/agent/orchestration/run-agent-turn-with-timeout.js +1 -1
  126. package/dist/src/agent/prompt/response-language.js +2 -1
  127. package/dist/src/agent/prompt/service-prompt-builder.js +6 -3
  128. package/dist/src/agent/prompt/system-prompt.js +2 -1
  129. package/dist/src/agent/reply/post-compaction-context.js +2 -2
  130. package/dist/src/agent/service/build-direct-message-content.js +1 -1
  131. package/dist/src/agent/service/direct-turn-helpers.js +2 -1
  132. package/dist/src/agent/service/parse-outbound-session-key.js +2 -1
  133. package/dist/src/agent/service/process-direct-streaming.js +3 -2
  134. package/dist/src/agent/service/webchat-tts.js +2 -1
  135. package/dist/src/agent/service.d.ts +1 -1
  136. package/dist/src/agent/service.js +12 -11
  137. package/dist/src/agent/service.types.d.ts +2 -0
  138. package/dist/src/agent/session/session-inspector.js +4 -5
  139. package/dist/src/agent/skills/marketplace/adapters/store/store-api-client.d.ts +5 -0
  140. package/dist/src/agent/starter-agents.d.ts +4 -5
  141. package/dist/src/agent/starter-agents.js +21 -20
  142. package/dist/src/agent/tasks/task-judge-service.js +2 -2
  143. package/dist/src/agent/tool-manuals/xopc-use.d.ts +1 -1
  144. package/dist/src/agent/tool-manuals/xopc-use.js +31 -1
  145. package/dist/src/agent/tools/delegation-parent-policy.js +2 -3
  146. package/dist/src/agent/tools/factory.d.ts +2 -0
  147. package/dist/src/agent/tools/factory.js +10 -9
  148. package/dist/src/agent/tools/image-generate-tool.js +1 -1
  149. package/dist/src/agent/tools/workflow-tool.js +2 -3
  150. package/dist/src/agent/tools/xopc-use-tool.d.ts +3 -2
  151. package/dist/src/agent/tools/xopc-use-tool.js +54 -6
  152. package/dist/src/agent/workflow/workflow-child-tools.js +1 -2
  153. package/dist/src/agent/workspace-runtime/registry.d.ts +1 -1
  154. package/dist/src/agent/workspace-runtime/registry.js +2 -2
  155. package/dist/src/agent-catalog/capabilities.d.ts +3 -0
  156. package/dist/src/agent-catalog/capabilities.js +238 -0
  157. package/dist/src/agent-catalog/id.d.ts +15 -0
  158. package/dist/src/agent-catalog/id.js +101 -0
  159. package/dist/src/agent-catalog/index.d.ts +6 -0
  160. package/dist/src/agent-catalog/index.js +10 -0
  161. package/dist/src/agent-catalog/migrations/legacy-config-cutover.d.ts +11 -0
  162. package/dist/src/agent-catalog/migrations/legacy-config-cutover.js +195 -0
  163. package/dist/src/agent-catalog/repository.d.ts +39 -0
  164. package/dist/src/agent-catalog/repository.js +319 -0
  165. package/dist/src/agent-catalog/service.d.ts +33 -0
  166. package/dist/src/agent-catalog/service.js +202 -0
  167. package/dist/src/agent-catalog/test-support.d.ts +14 -0
  168. package/dist/src/agent-catalog/test-support.js +34 -0
  169. package/dist/src/agent-catalog/types.d.ts +26 -0
  170. package/dist/src/agent-catalog/types.js +1 -0
  171. package/dist/src/agent-config/index.js +2 -2
  172. package/dist/src/agent-config/schema.d.ts +1 -172
  173. package/dist/src/agent-config/schema.js +2 -41
  174. package/dist/src/auth/credentials.js +3 -3
  175. package/dist/src/auth/oauth/xopc-cloud.js +1 -1
  176. package/dist/src/auth/sync-provider-auth.d.ts +1 -1
  177. package/dist/src/auth/sync-provider-auth.js +5 -9
  178. package/dist/src/automations/capabilities/drafts.js +8 -7
  179. package/dist/src/automations/service/action-executor.js +2 -1
  180. package/dist/src/bootstrap/application-state.d.ts +10 -0
  181. package/dist/src/bootstrap/application-state.js +26 -0
  182. package/dist/src/browser/automations/repository.js +2 -1
  183. package/dist/src/browser/automations/schema.d.ts +1 -1
  184. package/dist/src/browser/automations/service.d.ts +1 -1
  185. package/dist/src/browser/native-messaging-host.js +5 -4
  186. package/dist/src/browser/providers/extension.js +4 -2
  187. package/dist/src/browser/providers/realtime-extension.js +2 -1
  188. package/dist/src/capabilities/readiness/from-config.js +7 -4
  189. package/dist/src/capabilities/runtime/dispatcher.d.ts +1 -0
  190. package/dist/src/capabilities/runtime/dispatcher.js +10 -4
  191. package/dist/src/capabilities/runtime/product.js +2 -0
  192. package/dist/src/channels/catalog/channel-catalog-service.js +7 -13
  193. package/dist/src/chat-commands/agent-edit.js +4 -3
  194. package/dist/src/chat-commands/builtins/config.js +6 -8
  195. package/dist/src/chat-commands/builtins/review.js +1 -1
  196. package/dist/src/chat-commands/builtins/workflow.js +1 -1
  197. package/dist/src/chat-commands/config-paths.js +1 -1
  198. package/dist/src/chat-commands/context.js +2 -3
  199. package/dist/src/chat-previews/store.js +2 -1
  200. package/dist/src/cli/command-manifest.js +1 -1
  201. package/dist/src/cli/commands/agent.js +4 -4
  202. package/dist/src/cli/commands/agents.d.ts +1 -1
  203. package/dist/src/cli/commands/agents.js +36 -48
  204. package/dist/src/cli/commands/auth.js +2 -1
  205. package/dist/src/cli/commands/browser-cli-helpers.js +1 -2
  206. package/dist/src/cli/commands/channels.js +2 -4
  207. package/dist/src/cli/commands/config.js +4 -5
  208. package/dist/src/cli/commands/connectors.js +1 -2
  209. package/dist/src/cli/commands/doctor/checks/channel-config.js +2 -4
  210. package/dist/src/cli/commands/doctor/checks/channel-pairing-pending.js +1 -2
  211. package/dist/src/cli/commands/doctor/checks/channel-plugins.js +1 -2
  212. package/dist/src/cli/commands/doctor/checks/config-health.js +1 -2
  213. package/dist/src/cli/commands/doctor/checks/database-schema.js +4 -4
  214. package/dist/src/cli/commands/doctor/checks/gateway-health.js +1 -2
  215. package/dist/src/cli/commands/doctor/checks/gateway-service.js +1 -2
  216. package/dist/src/cli/commands/doctor/checks/provider-auth.js +13 -11
  217. package/dist/src/cli/commands/doctor/checks/security-audit.js +1 -2
  218. package/dist/src/cli/commands/doctor/checks/session-integrity.js +3 -3
  219. package/dist/src/cli/commands/doctor/checks/tool-runtimes.js +1 -2
  220. package/dist/src/cli/commands/doctor/checks/workspace-status.js +5 -7
  221. package/dist/src/cli/commands/extension-agent-plugin.js +1 -2
  222. package/dist/src/cli/commands/extension-dev.js +2 -4
  223. package/dist/src/cli/commands/extension-marketplace.js +1 -2
  224. package/dist/src/cli/commands/extension-pack.js +1 -2
  225. package/dist/src/cli/commands/extension.js +1 -2
  226. package/dist/src/cli/commands/gateway/run-foreground.js +3 -3
  227. package/dist/src/cli/commands/gateway/shared.js +1 -1
  228. package/dist/src/cli/commands/history.js +2 -1
  229. package/dist/src/cli/commands/image.js +2 -2
  230. package/dist/src/cli/commands/init.js +11 -30
  231. package/dist/src/cli/commands/mcp.js +1 -2
  232. package/dist/src/cli/commands/models.js +13 -11
  233. package/dist/src/cli/commands/onboard/channels/registry.js +1 -2
  234. package/dist/src/cli/commands/onboard/gateway.js +1 -2
  235. package/dist/src/cli/commands/onboard/model.d.ts +1 -1
  236. package/dist/src/cli/commands/onboard/model.js +18 -26
  237. package/dist/src/cli/commands/onboard.js +4 -2
  238. package/dist/src/cli/commands/platform.js +1 -0
  239. package/dist/src/cli/commands/project.js +3 -3
  240. package/dist/src/cli/commands/providers.js +2 -1
  241. package/dist/src/cli/commands/runtime.js +1 -2
  242. package/dist/src/cli/commands/search.js +1 -2
  243. package/dist/src/cli/commands/skills.js +1 -2
  244. package/dist/src/cli/commands/tui-runner.js +3 -2
  245. package/dist/src/cli/commands/tui.js +6 -8
  246. package/dist/src/cli/commands/tunnel.js +1 -1
  247. package/dist/src/cli/commands/voice.js +1 -2
  248. package/dist/src/cli/extension-cli-register.js +1 -1
  249. package/dist/src/cli/index.js +4 -2
  250. package/dist/src/cli/utils/gateway-client.js +1 -1
  251. package/dist/src/cli/utils/init-workspace-core.js +15 -16
  252. package/dist/src/cli/utils/session.js +1 -2
  253. package/dist/src/computer/model-config.d.ts +3 -3
  254. package/dist/src/computer/model-config.js +10 -20
  255. package/dist/src/computer/runtime.js +1 -1
  256. package/dist/src/config/agent-model-intents.js +2 -2
  257. package/dist/src/config/agent-profile.d.ts +5 -6
  258. package/dist/src/config/agent-profile.js +19 -19
  259. package/dist/src/config/config-surface.d.ts +0 -3
  260. package/dist/src/config/default-model.js +2 -6
  261. package/dist/src/config/index.js +7 -8
  262. package/dist/src/config/loader.js +12 -18
  263. package/dist/src/config/models-json.d.ts +6 -6
  264. package/dist/src/config/paths.d.ts +18 -19
  265. package/dist/src/config/paths.js +35 -35
  266. package/dist/src/config/reload.d.ts +0 -1
  267. package/dist/src/config/reload.js +1 -6
  268. package/dist/src/config/rules.js +0 -15
  269. package/dist/src/config/schema.d.ts +3 -406
  270. package/dist/src/config/schema.js +24 -86
  271. package/dist/src/config/validate-channel-configs.js +8 -14
  272. package/dist/src/config/workspace-dirs.d.ts +3 -4
  273. package/dist/src/config/workspace-dirs.js +9 -8
  274. package/dist/src/config/workspace-path-helpers.d.ts +1 -1
  275. package/dist/src/config/workspace-path-helpers.js +2 -2
  276. package/dist/src/connectors/cli/lifecycle.js +2 -1
  277. package/dist/src/connectors/composio-managed-events.js +2 -1
  278. package/dist/src/connectors/connected-source-ingestion.js +2 -1
  279. package/dist/src/connectors/connected-source-understanding.js +4 -2
  280. package/dist/src/connectors/content-enrichment.js +2 -1
  281. package/dist/src/connectors/learning-coordinator.js +2 -1
  282. package/dist/src/connectors/runtime-adapter-registry.js +2 -1
  283. package/dist/src/connectors/workflow-preflight.d.ts +8 -1
  284. package/dist/src/connectors/workflow-preflight.js +11 -3
  285. package/dist/src/discussions/analyzer.js +2 -2
  286. package/dist/src/endpoint-tools/runtime.js +2 -1
  287. package/dist/src/execution-environments/subject.js +2 -1
  288. package/dist/src/extensions/activation-context.js +3 -16
  289. package/dist/src/extensions/agent-plugins/validation.js +1 -1
  290. package/dist/src/extensions/discover-extensions.js +9 -15
  291. package/dist/src/extensions/extension-metadata-snapshot.d.ts +1 -1
  292. package/dist/src/extensions/extension-metadata-snapshot.js +9 -16
  293. package/dist/src/extensions/index.js +4 -10
  294. package/dist/src/extensions/install.js +1 -1
  295. package/dist/src/extensions/loader.js +7 -14
  296. package/dist/src/extensions/manifest-registry.js +93 -98
  297. package/dist/src/extensions/marketplace.js +5 -2
  298. package/dist/src/extensions/normalize-manifest.js +12 -17
  299. package/dist/src/extensions/update.js +1 -2
  300. package/dist/src/files/file-service.js +7 -8
  301. package/dist/src/gateway/agents-admin.d.ts +23 -27
  302. package/dist/src/gateway/agents-admin.js +109 -130
  303. package/dist/src/gateway/file-path-classifier.js +3 -3
  304. package/dist/src/gateway/file-space-service.js +2 -1
  305. package/dist/src/gateway/global-defaults-admin.d.ts +6 -4
  306. package/dist/src/gateway/global-defaults-admin.js +21 -20
  307. package/dist/src/gateway/hono/app.js +2 -1
  308. package/dist/src/gateway/hono/lib/config-payload.js +12 -9
  309. package/dist/src/gateway/hono/middleware/auth.js +2 -1
  310. package/dist/src/gateway/hono/middleware/scopes.js +2 -1
  311. package/dist/src/gateway/hono/routes/agents.js +22 -49
  312. package/dist/src/gateway/hono/routes/browser.js +4 -2
  313. package/dist/src/gateway/hono/routes/channels.js +1 -2
  314. package/dist/src/gateway/hono/routes/cli-connectors.js +2 -1
  315. package/dist/src/gateway/hono/routes/commands-skills.js +3 -1
  316. package/dist/src/gateway/hono/routes/composer-history.js +2 -1
  317. package/dist/src/gateway/hono/routes/config-patch/index.d.ts +1 -3
  318. package/dist/src/gateway/hono/routes/config-patch/index.js +1 -2
  319. package/dist/src/gateway/hono/routes/config-patch/misc.js +18 -11
  320. package/dist/src/gateway/hono/routes/config.js +0 -2
  321. package/dist/src/gateway/hono/routes/connectors.js +8 -4
  322. package/dist/src/gateway/hono/routes/context-sources.js +4 -3
  323. package/dist/src/gateway/hono/routes/device-pairing-approval.js +2 -1
  324. package/dist/src/gateway/hono/routes/device-push.js +3 -2
  325. package/dist/src/gateway/hono/routes/devices.js +6 -3
  326. package/dist/src/gateway/hono/routes/discussions.js +2 -1
  327. package/dist/src/gateway/hono/routes/endpoint-tools.js +2 -1
  328. package/dist/src/gateway/hono/routes/global-defaults.js +8 -16
  329. package/dist/src/gateway/hono/routes/home.js +93 -4
  330. package/dist/src/gateway/hono/routes/interaction-state.js +2 -1
  331. package/dist/src/gateway/hono/routes/models.js +8 -7
  332. package/dist/src/gateway/hono/routes/notes.js +4 -5
  333. package/dist/src/gateway/hono/routes/projects.js +6 -6
  334. package/dist/src/gateway/hono/routes/public-gateway.js +2 -1
  335. package/dist/src/gateway/hono/routes/session-input-handler.js +1 -1
  336. package/dist/src/gateway/hono/routes/sessions.js +4 -2
  337. package/dist/src/gateway/hono/routes/shares.js +4 -3
  338. package/dist/src/gateway/hono/routes/site-shares.js +2 -2
  339. package/dist/src/gateway/hono/routes/status.js +2 -3
  340. package/dist/src/gateway/hono/routes/tasks.js +1 -2
  341. package/dist/src/gateway/hono/routes/user-model-refresh.js +2 -1
  342. package/dist/src/gateway/hono/routes/user-model.js +3 -2
  343. package/dist/src/gateway/hono/routes/work-discovery.js +1 -1
  344. package/dist/src/gateway/hono/routes/workflows.js +2 -2
  345. package/dist/src/gateway/image-generation-setup.d.ts +19 -10
  346. package/dist/src/gateway/image-generation-setup.js +59 -23
  347. package/dist/src/gateway/index.js +1 -4
  348. package/dist/src/gateway/lock.js +13 -18
  349. package/dist/src/gateway/memory-maintenance-automation-reconciler.js +4 -3
  350. package/dist/src/gateway/run-loop.js +2 -3
  351. package/dist/src/gateway/security/gateway-scopes.js +6 -2
  352. package/dist/src/gateway/security/index.js +4 -1
  353. package/dist/src/gateway/service/agent-runner.js +4 -2
  354. package/dist/src/gateway/service/app-context-access.js +2 -1
  355. package/dist/src/gateway/service/config-coordinator.d.ts +0 -1
  356. package/dist/src/gateway/service/config-coordinator.js +4 -22
  357. package/dist/src/gateway/service/marketplace-service.js +3 -1
  358. package/dist/src/gateway/service/run-gateway-agent.js +4 -2
  359. package/dist/src/gateway/service/session-input-coordinator.js +4 -2
  360. package/dist/src/gateway/service.d.ts +5 -0
  361. package/dist/src/gateway/service.js +109 -33
  362. package/dist/src/gateway/session-context-summary.js +4 -2
  363. package/dist/src/gateway/xopc-cloud-capability-setup.d.ts +2 -0
  364. package/dist/src/gateway/xopc-cloud-capability-setup.js +15 -10
  365. package/dist/src/home-intelligence/application-service.d.ts +31 -0
  366. package/dist/src/home-intelligence/application-service.js +134 -0
  367. package/dist/src/home-intelligence/capability-preflight.d.ts +32 -0
  368. package/dist/src/home-intelligence/capability-preflight.js +118 -0
  369. package/dist/src/home-intelligence/evaluation.d.ts +34 -0
  370. package/dist/src/home-intelligence/evaluation.js +49 -0
  371. package/dist/src/home-intelligence/generator.d.ts +125 -0
  372. package/dist/src/home-intelligence/generator.js +227 -0
  373. package/dist/src/home-intelligence/host.d.ts +53 -0
  374. package/dist/src/home-intelligence/host.js +257 -0
  375. package/dist/src/home-intelligence/notification.d.ts +8 -0
  376. package/dist/src/home-intelligence/notification.js +20 -0
  377. package/dist/src/home-intelligence/policy.d.ts +16 -0
  378. package/dist/src/home-intelligence/policy.js +152 -0
  379. package/dist/src/home-intelligence/repository.d.ts +81 -0
  380. package/dist/src/home-intelligence/repository.js +495 -0
  381. package/dist/src/home-intelligence/snapshot.d.ts +43 -0
  382. package/dist/src/home-intelligence/snapshot.js +133 -0
  383. package/dist/src/home-intelligence/strategy.d.ts +14 -0
  384. package/dist/src/home-intelligence/strategy.js +10 -0
  385. package/dist/src/home-intelligence/types.d.ts +13 -0
  386. package/dist/src/home-intelligence/types.js +1 -0
  387. package/dist/src/infra/update-restart.js +4 -2
  388. package/dist/src/knowledge/connected-knowledge-pipeline.js +2 -1
  389. package/dist/src/knowledge/ingestion-service.js +2 -1
  390. package/dist/src/knowledge-memory/repository.js +2 -1
  391. package/dist/src/local-apps/service.js +1 -1
  392. package/dist/src/local-apps/store.js +2 -1
  393. package/dist/src/mcp/channel-bridge.js +1 -2
  394. package/dist/src/mcp/channel-server.js +1 -2
  395. package/dist/src/mcp/gateway-http-client.js +1 -2
  396. package/dist/src/media/session-references.js +2 -1
  397. package/dist/src/memory-maintenance/service.js +2 -1
  398. package/dist/src/migrations/memory-config.js +1 -2
  399. package/dist/src/notes/agent-context.js +2 -1
  400. package/dist/src/notes/attachment-ref.js +8 -4
  401. package/dist/src/notes/note-attachment-sync.js +2 -1
  402. package/dist/src/notes/note-index-meta.js +14 -7
  403. package/dist/src/notes/note-markdown.js +13 -7
  404. package/dist/src/notes/service.js +6 -3
  405. package/dist/src/notes/store.js +4 -2
  406. package/dist/src/notifications/device-store.js +1 -1
  407. package/dist/src/notifications/planner.js +24 -0
  408. package/dist/src/notifications/service.d.ts +7 -14
  409. package/dist/src/notifications/service.js +13 -3
  410. package/dist/src/notifications/store.js +1 -1
  411. package/dist/src/notifications/types.d.ts +1 -1
  412. package/dist/src/notifications/types.js +1 -1
  413. package/dist/src/projects/capabilities/write.js +2 -1
  414. package/dist/src/projects/project-agent-suggestion.js +1 -1
  415. package/dist/src/projects/project-agent.js +4 -4
  416. package/dist/src/projects/project-service.js +2 -1
  417. package/dist/src/projects/workspace.js +3 -2
  418. package/dist/src/providers/index.js +3 -3
  419. package/dist/src/providers/model-reference-auditor.d.ts +1 -2
  420. package/dist/src/providers/model-reference-auditor.js +8 -5
  421. package/dist/src/realtime/runtime.js +2 -1
  422. package/dist/src/routing/binding-schema.d.ts +41 -0
  423. package/dist/src/routing/binding-schema.js +26 -0
  424. package/dist/src/routing/bindings.d.ts +4 -2
  425. package/dist/src/routing/bindings.js +4 -4
  426. package/dist/src/routing/index.d.ts +1 -1
  427. package/dist/src/routing/resolve-route.d.ts +7 -24
  428. package/dist/src/routing/resolve-route.js +17 -18
  429. package/dist/src/routing/resolve-tui-session-key.d.ts +1 -4
  430. package/dist/src/routing/resolve-tui-session-key.js +10 -9
  431. package/dist/src/scenes/execution.d.ts +1 -1
  432. package/dist/src/scenes/model.js +1 -1
  433. package/dist/src/scenes/taskFollowUp/contracts.d.ts +1 -1
  434. package/dist/src/scenes/taskFollowUp/service.js +6 -4
  435. package/dist/src/scenes/templates.d.ts +2 -2
  436. package/dist/src/session/config-store.js +2 -1
  437. package/dist/src/session/init-session-turn.js +2 -1
  438. package/dist/src/session/resolve-session.js +2 -1
  439. package/dist/src/session/session-workspace.js +1 -1
  440. package/dist/src/session/store.js +3 -2
  441. package/dist/src/storage/sqlite/activity-repository.js +6 -2
  442. package/dist/src/storage/sqlite/browser-tab-binding-repository.js +6 -2
  443. package/dist/src/storage/sqlite/clarification-wait-repository.js +13 -8
  444. package/dist/src/storage/sqlite/collaboration-rule-repository.d.ts +1 -1
  445. package/dist/src/storage/sqlite/collaboration-rule-repository.js +8 -3
  446. package/dist/src/storage/sqlite/composer-input-history-repository.js +8 -3
  447. package/dist/src/storage/sqlite/config-repository.js +9 -5
  448. package/dist/src/storage/sqlite/connector-learning-repository.js +6 -2
  449. package/dist/src/storage/sqlite/connector-sync-policy-repository.js +6 -2
  450. package/dist/src/storage/sqlite/context-evidence-repository.js +8 -3
  451. package/dist/src/storage/sqlite/context-extraction-repository.js +8 -3
  452. package/dist/src/storage/sqlite/device-access-repository.js +15 -9
  453. package/dist/src/storage/sqlite/device-pairing-approval.js +6 -2
  454. package/dist/src/storage/sqlite/device-pairing-repository.js +10 -5
  455. package/dist/src/storage/sqlite/endpoint-principal-repository.js +6 -2
  456. package/dist/src/storage/sqlite/endpoint-session-binding-repository.js +6 -2
  457. package/dist/src/storage/sqlite/endpoint-tool-invocation-repository.js +6 -2
  458. package/dist/src/storage/sqlite/gateway-identity-repository.js +6 -2
  459. package/dist/src/storage/sqlite/home-attention-repository.js +6 -2
  460. package/dist/src/storage/sqlite/index.d.ts +0 -1
  461. package/dist/src/storage/sqlite/index.js +72 -42
  462. package/dist/src/storage/sqlite/interaction-state-repository.js +10 -4
  463. package/dist/src/storage/sqlite/knowledge-repository.js +6 -2
  464. package/dist/src/storage/sqlite/migrations/203_remove_retired_proactive_contracts.sql +70 -0
  465. package/dist/src/storage/sqlite/migrations/204_home_intelligence.sql +78 -0
  466. package/dist/src/storage/sqlite/migrations/205_agent_catalog.sql +66 -0
  467. package/dist/src/storage/sqlite/migrations/206_home_advice_strategy_version.sql +3 -0
  468. package/dist/src/storage/sqlite/migrations/conversation-backup.d.ts +2 -0
  469. package/dist/src/storage/sqlite/migrations/conversation-backup.js +8 -4
  470. package/dist/src/storage/sqlite/migrations/conversation-windows-owners.d.ts +7 -1
  471. package/dist/src/storage/sqlite/migrations/conversation-windows-owners.js +2 -2
  472. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  473. package/dist/src/storage/sqlite/migrations/runner.js +4 -4
  474. package/dist/src/storage/sqlite/note-agent-context-repository.js +6 -2
  475. package/dist/src/storage/sqlite/notes-repository.js +9 -4
  476. package/dist/src/storage/sqlite/schema.js +1 -1
  477. package/dist/src/storage/sqlite/session-task-plan-repository.js +14 -9
  478. package/dist/src/storage/sqlite/session-turn-replace-repository.js +9 -5
  479. package/dist/src/storage/sqlite/sidebar-layout-repository.js +14 -9
  480. package/dist/src/storage/sqlite/transcript-repository.js +10 -6
  481. package/dist/src/storage/sqlite/user-people-repository.js +8 -3
  482. package/dist/src/storage/sqlite/user-trust-repository.js +8 -3
  483. package/dist/src/tasks/attention-governor.d.ts +0 -1
  484. package/dist/src/tasks/attention-governor.js +1 -7
  485. package/dist/src/tasks/capabilities/read.js +2 -2
  486. package/dist/src/tasks/capabilities/write.d.ts +1 -1
  487. package/dist/src/tasks/execution-context.d.ts +2 -2
  488. package/dist/src/tasks/execution-context.js +6 -5
  489. package/dist/src/tasks/home-query-service.d.ts +3 -2
  490. package/dist/src/tasks/home-query-service.js +23 -44
  491. package/dist/src/tasks/task-context-assembler.js +2 -1
  492. package/dist/src/tasks/task-context-repository.d.ts +1 -1
  493. package/dist/src/tasks/task-contract-planner.d.ts +0 -3
  494. package/dist/src/tasks/task-contract-planner.js +1 -4
  495. package/dist/src/tasks/task-handoff-service.d.ts +0 -2
  496. package/dist/src/tasks/task-handoff-service.js +3 -3
  497. package/dist/src/tasks/task-value-metrics-service.js +2 -1
  498. package/dist/src/tui/backends/embedded-backend.js +12 -14
  499. package/dist/src/tui/extension-host/load-extensions.js +1 -1
  500. package/dist/src/tui/tui-commands.js +5 -3
  501. package/dist/src/tui/tui-skills-autocomplete.js +1 -1
  502. package/dist/src/tui/tui-startup-resources.js +3 -3
  503. package/dist/src/tui/tui.js +5 -5
  504. package/dist/src/tunnel/registration-proof.js +2 -1
  505. package/dist/src/user-context/access-policy.js +2 -1
  506. package/dist/src/user-context/domain.d.ts +1 -1
  507. package/dist/src/user-context/domain.js +18 -13
  508. package/dist/src/user-context/extraction/registry.js +2 -1
  509. package/dist/src/user-context/interaction-state.js +4 -1
  510. package/dist/src/user-context/relationship-continuity.js +2 -1
  511. package/dist/src/user-context/trust-policy.js +13 -8
  512. package/dist/src/user-model/bootstrap.js +2 -1
  513. package/dist/src/user-model/capture/executor.js +4 -2
  514. package/dist/src/user-model/capture/semantic.d.ts +1 -1
  515. package/dist/src/user-model/capture/semantic.js +1 -1
  516. package/dist/src/user-model/domain.js +7 -2
  517. package/dist/src/user-model/goals.js +2 -1
  518. package/dist/src/user-model/index.js +4 -1
  519. package/dist/src/user-model/repository.js +2 -1
  520. package/dist/src/utils/helpers.js +1 -4
  521. package/dist/src/utils/index.js +2 -2
  522. package/dist/src/utils/logger/index.d.ts +1 -1
  523. package/dist/src/utils/logger/index.js +2 -2
  524. package/dist/src/utils/logger/redact.d.ts +2 -0
  525. package/dist/src/utils/logger/redact.js +11 -3
  526. package/dist/src/utils/logger.js +2 -2
  527. package/dist/src/voice/realtime/memory-context.js +2 -1
  528. package/dist/src/voice/realtime/persona-context.js +6 -6
  529. package/dist/src/voice/tts/audio.js +1 -1
  530. package/dist/src/work-discovery/analyzer.js +3 -3
  531. package/dist/src/work-discovery/investigator.js +1 -1
  532. package/dist/src/work-discovery/service.js +12 -11
  533. package/dist/src/workflows/draft/workflow-draft-service.js +1 -1
  534. package/dist/src/workflows/service/workflow-run-service.js +4 -5
  535. package/dist/src/workflows/store/paths.js +1 -1
  536. package/package.json +5 -5
  537. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-CAFHadiy.js +0 -1
  538. package/dist/gateway/static/root/assets/apps-page-Drt3Foi9.js +0 -1
  539. package/dist/gateway/static/root/assets/automations-workspace-B-Eduqwz.js +0 -7
  540. package/dist/gateway/static/root/assets/browser-settings-page-Dwgir6mu.js +0 -3
  541. package/dist/gateway/static/root/assets/capabilities-settings-panel-H5L5vynP.js +0 -8
  542. package/dist/gateway/static/root/assets/capabilities-uFKh3Hd0.js +0 -1
  543. package/dist/gateway/static/root/assets/channels-settings-RFBRYe5S.js +0 -1
  544. package/dist/gateway/static/root/assets/connectors-page-Px-v3Q6Q.js +0 -2
  545. package/dist/gateway/static/root/assets/date-picker-CfCo3lqh.js +0 -1
  546. package/dist/gateway/static/root/assets/home-page-w3_aWeNt.js +0 -1
  547. package/dist/gateway/static/root/assets/index--3c0awkr.js +0 -121
  548. package/dist/gateway/static/root/assets/local-app-workbench-page-BYKrJpFF.js +0 -1
  549. package/dist/gateway/static/root/assets/logs-page-Dl4kM4Na.js +0 -2
  550. package/dist/gateway/static/root/assets/messages-7VAhscYe.js +0 -3
  551. package/dist/gateway/static/root/assets/note-detail-panel-j6sioeL1.js +0 -5
  552. package/dist/gateway/static/root/assets/notes-page-CMvvHv0f.js +0 -8
  553. package/dist/gateway/static/root/assets/popover-select-B-GDnZO9.js +0 -1
  554. package/dist/gateway/static/root/assets/project-detail-page-C9K_e-EV.js +0 -1
  555. package/dist/gateway/static/root/assets/remote-access-hub-CLGJNA42.js +0 -1
  556. package/dist/gateway/static/root/assets/scenes-page-ClLAD1pz.js +0 -2
  557. package/dist/gateway/static/root/assets/sessions-page-Xj8MkXN1.js +0 -1
  558. package/dist/gateway/static/root/assets/settings-advanced-gate-DwALV8mi.js +0 -1
  559. package/dist/gateway/static/root/assets/setup-status-panel-F0rCQ-2a.js +0 -1
  560. package/dist/gateway/static/root/assets/shares-settings-C7hf6Cov.js +0 -1
  561. package/dist/gateway/static/root/assets/skill-reload-api-xPrFejRE.js +0 -1
  562. package/dist/gateway/static/root/assets/skills-page-RdDYu7Yj.js +0 -2
  563. package/dist/gateway/static/root/assets/task-detail-page-2A966jFY.js +0 -1
  564. package/dist/gateway/static/root/assets/user-model-page-CnBxPBVe.js +0 -2
  565. package/dist/gateway/static/root/assets/workflows-page-BZVpqw4T.js +0 -6
  566. package/dist/packages/gateway-contract/src/proactive.js +0 -136
  567. package/dist/src/commands/agents.config.d.ts +0 -31
  568. package/dist/src/commands/agents.config.js +0 -129
  569. package/dist/src/gateway/hono/routes/config-patch/agents.d.ts +0 -2
  570. package/dist/src/gateway/hono/routes/config-patch/agents.js +0 -6
  571. package/dist/src/storage/sqlite/relationship-settings-repository.d.ts +0 -17
  572. package/dist/src/storage/sqlite/relationship-settings-repository.js +0 -65
@@ -1,3 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{f as i,g as a}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{t as o}from"./popover-select-B-GDnZO9.js";import{t as s}from"./circle-check-C23XjkUj.js";import{t as c}from"./download-Dk-ZjtO6.js";import{a as l,c as u,n as d,r as f}from"./locale-store-BIkcRr3t.js";import{t as p}from"./messages-7VAhscYe.js";import{i as m}from"./vendor-swr-BIWyz7Rc.js";import{t as h}from"./button-CS04eWY9.js";import{n as g,r as _}from"./gateway-config-swr-1eqyz9vZ.js";import{t as v}from"./skeleton-BwbyijEw.js";import{Au as y,Ca as b,Fu as x,G as S,H as C,K as w,Ll as ee,Rl as te,Sa as T,Tc as E,U as ne,W as re,dl as ie,gu as D,ku as ae,nl as oe,q as O,wl as k,yu as se}from"./index--3c0awkr.js";import{n as ce,r as A}from"./settings-page-layout-D3KNSQ5g.js";import{n as j}from"./settings-loading-skeleton-CAmWMaOT.js";import{n as M,t as N}from"./use-autosave-C1xQ-sHn.js";import{t as P}from"./settings-advanced-gate-DwALV8mi.js";var F=n(),I=e(t(),1);function le(e){let[t,n]=(0,I.useState)(!1),[r,i]=(0,I.useState)(!1),[a,o]=(0,I.useState)(null),[s,c]=(0,I.useState)(null),l=(0,I.useRef)(null);return{running:t,cancelling:r,progress:a,error:s,install:(0,I.useCallback)(async()=>{if(l.current)return;let t=new AbortController;l.current=t,n(!0),o(null),c(null);try{let n=await S(o,t.signal);if(!n.ok){n.error!==`cancelled`&&c(n.message??n.error);return}e()}catch(e){t.signal.aborted||c(e instanceof Error?e.message:String(e))}finally{l.current===t&&(l.current=null),n(!1),i(!1)}},[e]),cancel:(0,I.useCallback)(async()=>{l.current&&(i(!0),await C().catch(()=>{}),l.current.abort())},[])}}var L=r(),R={extension:`Chrome extension`,playwright:`Playwright Chromium`,cdp:`CDP`,remote:`Remote browser`};function z(e){let{enabled:t,driverKind:n,autosaveStatus:r,zh:a}=e,o=i(),c=m(t?[`browser-control-status`,n]:null,ne,{revalidateOnFocus:!0,refreshInterval:n===`extension`?3e3:0}),[l,u]=(0,I.useState)(null),[d,f]=(0,I.useState)(null),[p,g]=(0,I.useState)(null),_=r===`dirty`||r===`saving`;(0,I.useEffect)(()=>{r===`saved`&&c.mutate()},[r,c.mutate]);let y=(0,I.useCallback)(async(e,t,n)=>{u(e),f(null),g(null);try{await t(),g(n),await c.mutate()}catch(e){f(e instanceof Error?e.message:String(e))}finally{u(null)}},[c.mutate]),b=le((0,I.useCallback)(()=>{g(a?`Chromium 已安装,可以开始连接测试。`:`Chromium is installed and ready to test.`),c.mutate()},[c.mutate,a])),x=c.data?.payload,S=x?.driverKind===n,C=t?_||!S?`syncing`:x?.state:`disabled`;return(0,L.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 p-5`,children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(C===`ready`?s:C===`syncing`?te:E,{className:`size-4 shrink-0 ${C===`ready`?`text-success`:C===`syncing`?`animate-spin text-fg-muted`:C===`disabled`?`text-fg-subtle`:`text-warning`}`}),(0,L.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:a?`浏览器就绪状态`:`Browser readiness`}),(0,L.jsx)(`span`,{className:`rounded-full px-2 py-0.5 text-xs ${C===`ready`?`bg-success-soft text-success`:C===`disabled`?`bg-surface-hover text-fg-muted`:`bg-warning-soft text-warning`}`,children:C===`ready`?a?`已就绪`:`Ready`:C===`disabled`?a?`未启用`:`Disabled`:C===`syncing`?a?`正在应用配置`:`Applying configuration`:a?`需要处理`:`Needs attention`})]}),(0,L.jsxs)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:[R[n],x?.detail&&S?` · ${x.detail}`:``]})]}),(0,L.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,L.jsxs)(h,{variant:`ghost`,className:`h-9`,onClick:()=>void c.mutate(),disabled:c.isValidating,children:[(0,L.jsx)(oe,{className:`size-3.5 ${c.isValidating?`animate-spin`:``}`}),a?`刷新`:`Refresh`]}),(0,L.jsxs)(h,{variant:`secondary`,className:`h-9`,disabled:!t||_||l!==null||b.running,onClick:()=>void y(`test`,O,a?`连接测试成功。`:`Connection test passed.`),children:[l===`test`?(0,L.jsx)(te,{className:`size-3.5 animate-spin`}):(0,L.jsx)(ie,{className:`size-3.5`}),a?`测试连接`:`Test connection`]})]})]}),t&&c.isLoading?(0,L.jsxs)(`div`,{className:`mt-4 grid gap-2 sm:grid-cols-3`,children:[(0,L.jsx)(v,{className:`h-12`}),(0,L.jsx)(v,{className:`h-12`}),(0,L.jsx)(v,{className:`h-12`})]}):null,t&&c.error?(0,L.jsx)(H,{tone:`error`,children:c.error instanceof Error?c.error.message:String(c.error)}):null,d||b.error?(0,L.jsx)(H,{tone:`error`,children:d??b.error}):null,p?(0,L.jsx)(H,{tone:`success`,children:p}):null,t&&n===`extension`&&S?(0,L.jsx)(ue,{status:x?.driverStatus,zh:a,busy:l,run:y,onConnectRemote:()=>o(`/settings/devices?startDevicePairing=browser`)}):null,t&&n===`playwright`&&S?(0,L.jsx)(B,{status:x?.driverStatus,zh:a,installer:b}):null,t&&n===`cdp`?(0,L.jsx)(`p`,{className:`mt-4 rounded-lg bg-surface-inset px-3 py-2 text-xs leading-5 text-fg-muted`,children:a?`连接测试会验证已保存的 CDP 地址,并复用浏览器中现有的标签页和登录状态。`:`The connection test verifies the saved CDP endpoint and reuses that browser’s existing tabs and signed-in state.`}):null,t&&n===`remote`?(0,L.jsx)(`p`,{className:`mt-4 rounded-lg bg-surface-inset px-3 py-2 text-xs leading-5 text-fg-muted`,children:a?`连接测试会在服务商侧创建一个临时浏览器会话,并在测试结束后立即关闭。`:`The connection test creates a temporary provider session and closes it immediately after the test.`}):null]})}function ue(e){let t=(0,F.c)(70),{status:n,zh:r,busy:i,run:a,onConnectRemote:o}=e,s=n?.artifacts,l=r?`扩展文件`:`Extension files`,u=s?.installed===!0,d=s?.installed?r?`已安装`:`Installed`:r?`未安装或需更新`:`Install or update required`,f;t[0]!==l||t[1]!==u||t[2]!==d?(f=(0,L.jsx)(V,{label:l,ok:u,value:d}),t[0]=l,t[1]=u,t[2]=d,t[3]=f):f=t[3];let p=r?`本机自动发现`:`Local auto-discovery`,m=s?.nativeHost?.installed===!0,g=s?.nativeHost?.installed?r?`已就绪`:`Ready`:s?.nativeHost?.reason??(r?`需要修复`:`Repair required`),_;t[4]!==p||t[5]!==m||t[6]!==g?(_=(0,L.jsx)(V,{label:p,ok:m,value:g}),t[4]=p,t[5]=m,t[6]=g,t[7]=_):_=t[7];let v=r?`安全通道`:`Secure channel`,b=n?.transport===`gateway-realtime`,x=n?.transport===`gateway-realtime`?`Gateway Realtime`:r?`不可用`:`Unavailable`,S;t[8]!==x||t[9]!==v||t[10]!==b?(S=(0,L.jsx)(V,{label:v,ok:b,value:x}),t[8]=x,t[9]=v,t[10]=b,t[11]=S):S=t[11];let C=r?`Chrome 连接`:`Chrome connection`,w=n?.connected===!0,ee=n?.connected?r?`已连接`:`Connected`:n?.socketConnected?r?`需要重新加载扩展`:`Reload extension`:r?`等待扩展连接`:`Waiting for extension`,T;t[12]!==C||t[13]!==w||t[14]!==ee?(T=(0,L.jsx)(V,{label:C,ok:w,value:ee}),t[12]=C,t[13]=w,t[14]=ee,t[15]=T):T=t[15];let E;t[16]!==S||t[17]!==T||t[18]!==f||t[19]!==_?(E=(0,L.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-2 lg:grid-cols-4`,children:[f,_,S,T]}),t[16]=S,t[17]=T,t[18]=f,t[19]=_,t[20]=E):E=t[20];let ne=s?.extensionDir??`Gateway Realtime`,D;t[21]===ne?D=t[22]:(D=(0,L.jsx)(`p`,{className:`mt-3 break-all text-xs text-fg-subtle`,children:ne}),t[21]=ne,t[22]=D);let ae=s?.installed?`secondary`:`primary`,oe=i!==null,O;t[23]!==s?.installed||t[24]!==a||t[25]!==r?(O=()=>void a(`extension-install`,()=>re(!!s?.installed),r?`扩展文件已准备好。`:`Extension files are ready.`),t[23]=s?.installed,t[24]=a,t[25]=r,t[26]=O):O=t[26];let k;t[27]===i?k=t[28]:(k=i===`extension-install`?(0,L.jsx)(te,{className:`size-3.5 animate-spin`}):(0,L.jsx)(c,{className:`size-3.5`}),t[27]=i,t[28]=k);let ce=s?.installed?r?`刷新扩展文件`:`Refresh files`:r?`安装扩展文件`:`Install extension`,A;t[29]!==ae||t[30]!==oe||t[31]!==O||t[32]!==k||t[33]!==ce?(A=(0,L.jsxs)(h,{className:`h-9`,variant:ae,disabled:oe,onClick:O,children:[k,ce]}),t[29]=ae,t[30]=oe,t[31]=O,t[32]=k,t[33]=ce,t[34]=A):A=t[34];let j=!s?.installed||i!==null,M;t[35]!==a||t[36]!==r?(M=()=>void a(`extension-open`,fe,r?`已打开 Chrome 扩展页。`:`Chrome extensions opened.`),t[35]=a,t[36]=r,t[37]=M):M=t[37];let N;t[38]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,L.jsx)(y,{className:`size-3.5`}),t[38]=N):N=t[38];let P=r?`打开扩展页`:`Open extensions`,I;t[39]!==j||t[40]!==M||t[41]!==P?(I=(0,L.jsxs)(h,{className:`h-9`,variant:`secondary`,disabled:j,onClick:M,children:[N,P]}),t[39]=j,t[40]=M,t[41]=P,t[42]=I):I=t[42];let le=!s?.installed||i!==null,R;t[43]!==a||t[44]!==r?(R=()=>void a(`extension-folder`,de,r?`已打开扩展目录。`:`Extension folder opened.`),t[43]=a,t[44]=r,t[45]=R):R=t[45];let z;t[46]===Symbol.for(`react.memo_cache_sentinel`)?(z=(0,L.jsx)(se,{className:`size-3.5`}),t[46]=z):z=t[46];let ue=r?`打开扩展目录`:`Open folder`,B;t[47]!==le||t[48]!==R||t[49]!==ue?(B=(0,L.jsxs)(h,{className:`h-9`,variant:`ghost`,disabled:le,onClick:R,children:[z,ue]}),t[47]=le,t[48]=R,t[49]=ue,t[50]=B):B=t[50];let H=i!==null,U;t[51]===Symbol.for(`react.memo_cache_sentinel`)?(U=(0,L.jsx)(ie,{className:`size-3.5`}),t[51]=U):U=t[51];let pe=r?`连接远程 Chrome`:`Connect remote Chrome`,W;t[52]!==o||t[53]!==H||t[54]!==pe?(W=(0,L.jsxs)(h,{className:`h-9`,variant:`secondary`,disabled:H,onClick:o,children:[U,pe]}),t[52]=o,t[53]=H,t[54]=pe,t[55]=W):W=t[55];let G;t[56]!==A||t[57]!==I||t[58]!==B||t[59]!==W?(G=(0,L.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[A,I,B,W]}),t[56]=A,t[57]=I,t[58]=B,t[59]=W,t[60]=G):G=t[60];let K;t[61]!==n?.connected||t[62]!==n?.socketConnected||t[63]!==r?(K=n?.connected?null:(0,L.jsx)(`p`,{className:`mt-3 text-xs leading-5 text-fg-muted`,children:n?.socketConnected?r?`扩展仍在运行旧协议。请打开 Chrome 扩展页,找到 xopc 并点击“重新加载”,然后刷新状态。`:`The extension is still running an older protocol. Open Chrome Extensions, find xopc, click Reload, then refresh status.`:r?`打开 xopc Chrome 扩展后,它会自动发现并安全连接本机 Gateway;只有连接另一台电脑时才需要一次性邀请和手动确认。`:`Open the xopc Chrome extension to discover and securely connect to a local Gateway automatically. A one-time invitation and explicit approval are only required for Chrome on another computer.`}),t[61]=n?.connected,t[62]=n?.socketConnected,t[63]=r,t[64]=K):K=t[64];let q;return t[65]!==E||t[66]!==D||t[67]!==G||t[68]!==K?(q=(0,L.jsxs)(`div`,{className:`mt-4 rounded-xl bg-surface-base/45 p-4`,children:[E,D,G,K]}),t[65]=E,t[66]=D,t[67]=G,t[68]=K,t[69]=q):q=t[69],q}function de(){return w(`folder`)}function fe(){return w(`chrome`)}function B(e){let t=(0,F.c)(28),{status:n,zh:r,installer:i}=e,a=n?.installed===!0,o=n?.installed?r?`已安装`:`Installed`:n?.reason??(r?`未安装`:`Not installed`),s;t[0]!==a||t[1]!==o?(s=(0,L.jsx)(V,{label:`Chromium`,ok:a,value:o}),t[0]=a,t[1]=o,t[2]=s):s=t[2];let l;t[3]===n?l=t[4]:(l=n?.executablePath?(0,L.jsx)(`p`,{className:`mt-2 break-all text-xs text-fg-subtle`,children:n.executablePath}):null,t[3]=n,t[4]=l);let u;t[5]===i.progress?u=t[6]:(u=i.progress?(0,L.jsxs)(`div`,{className:`mt-3`,children:[(0,L.jsxs)(`div`,{className:`flex justify-between text-xs text-fg-muted`,children:[(0,L.jsx)(`span`,{children:i.progress.message??i.progress.phase}),(0,L.jsx)(`span`,{children:i.progress.percent==null?``:`${Math.round(i.progress.percent)}%`})]}),(0,L.jsx)(`div`,{className:`mt-1 h-1.5 overflow-hidden rounded-full bg-surface-hover`,children:(0,L.jsx)(`div`,{className:`h-full rounded-full bg-accent transition-[width]`,style:{width:`${i.progress.percent??8}%`}})})]}):null,t[5]=i.progress,t[6]=u);let d=n?.installed?`secondary`:`primary`,f;t[7]===i?f=t[8]:(f=()=>void i.install(),t[7]=i,t[8]=f);let p;t[9]===i.running?p=t[10]:(p=i.running?(0,L.jsx)(te,{className:`size-3.5 animate-spin`}):(0,L.jsx)(c,{className:`size-3.5`}),t[9]=i.running,t[10]=p);let m=n?.installed?r?`重新安装 Chromium`:`Reinstall Chromium`:r?`安装 Chromium`:`Install Chromium`,g;t[11]!==i.running||t[12]!==d||t[13]!==f||t[14]!==p||t[15]!==m?(g=(0,L.jsxs)(h,{variant:d,className:`h-9`,disabled:i.running,onClick:f,children:[p,m]}),t[11]=i.running,t[12]=d,t[13]=f,t[14]=p,t[15]=m,t[16]=g):g=t[16];let _;t[17]!==i||t[18]!==r?(_=i.running?(0,L.jsx)(h,{variant:`ghost`,className:`h-9`,disabled:i.cancelling,onClick:()=>void i.cancel(),children:i.cancelling?r?`正在取消…`:`Cancelling…`:r?`取消`:`Cancel`}):null,t[17]=i,t[18]=r,t[19]=_):_=t[19];let v;t[20]!==_||t[21]!==g?(v=(0,L.jsxs)(`div`,{className:`mt-3 flex gap-2`,children:[g,_]}),t[20]=_,t[21]=g,t[22]=v):v=t[22];let y;return t[23]!==v||t[24]!==s||t[25]!==l||t[26]!==u?(y=(0,L.jsxs)(`div`,{className:`mt-4 rounded-xl bg-surface-base/45 p-4`,children:[s,l,u,v]}),t[23]=v,t[24]=s,t[25]=l,t[26]=u,t[27]=y):y=t[27],y}function V(e){let t=(0,F.c)(11),{label:n,ok:r,value:i}=e,a;t[0]===n?a=t[1]:(a=(0,L.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n}),t[0]=n,t[1]=a);let o=`mt-1 flex items-center gap-1.5 text-sm ${r?`text-success`:`text-fg-muted`}`,s=`size-1.5 rounded-full ${r?`bg-success`:`bg-warning`}`,c;t[2]===s?c=t[3]:(c=(0,L.jsx)(`span`,{className:s}),t[2]=s,t[3]=c);let l;t[4]!==o||t[5]!==c||t[6]!==i?(l=(0,L.jsxs)(`p`,{className:o,children:[c,i]}),t[4]=o,t[5]=c,t[6]=i,t[7]=l):l=t[7];let u;return t[8]!==a||t[9]!==l?(u=(0,L.jsxs)(`div`,{className:`rounded-lg bg-surface-inset px-3 py-2`,children:[a,l]}),t[8]=a,t[9]=l,t[10]=u):u=t[10],u}function H(e){let t=(0,F.c)(4),{tone:n,children:r}=e,i=`mt-3 rounded-lg px-3 py-2 text-xs ${n===`success`?`bg-success-soft text-success`:`bg-danger-soft text-danger`}`,a=n===`error`?`alert`:`status`,o;return t[0]!==r||t[1]!==i||t[2]!==a?(o=(0,L.jsx)(`p`,{className:i,role:a,children:r}),t[0]=r,t[1]=i,t[2]=a,t[3]=o):o=t[3],o}function U(e){let t=(0,F.c)(36),{sectionId:n,vm:r,children:i}=e,a=d(pe),o;t[0]===a?o=t[1]:(o=p(a),t[0]=a,t[1]=o);let s=o,c=s.agentSettings,l=s.settingsSections[n]??n;if(!r.hasToken){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,L.jsx)(x,{className:`mt-0.5 size-5 shrink-0 text-fg-subtle`,strokeWidth:1.75}),t[2]=e):e=t[2];let n;t[3]===l?n=t[4]:(n=(0,L.jsx)(`h1`,{className:`text-base font-semibold text-fg`,children:l}),t[3]=l,t[4]=n);let r;t[5]===c.needToken?r=t[6]:(r=(0,L.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:c.needToken}),t[5]=c.needToken,t[6]=r);let i;return t[7]!==n||t[8]!==r?(i=(0,L.jsx)(A,{gap:`gap-3`,padding:`px-3 py-10 sm:px-5 xl:px-6`,children:(0,L.jsxs)(`div`,{className:`flex items-start gap-3 rounded-2xl bg-surface-base p-6`,children:[e,(0,L.jsxs)(`div`,{children:[n,r]})]})}),t[7]=n,t[8]=r,t[9]=i):i=t[9],i}if(r.loading){let e;return t[10]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,L.jsx)(A,{gap:`gap-6`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:(0,L.jsx)(j,{sections:1})}),t[10]=e):e=t[10],e}if(!r.form){let e=r.error??r.fetchError??c.loadError,n;t[11]===e?n=t[12]:(n=(0,L.jsx)(`p`,{className:`text-sm text-fg-muted`,children:e}),t[11]=e,t[12]=n);let i;t[13]===r?i=t[14]:(i=()=>void r.mutate(),t[13]=r,t[14]=i);let a;t[15]!==s.logs.refresh||t[16]!==i?(a=(0,L.jsx)(h,{type:`button`,variant:`secondary`,onClick:i,children:s.logs.refresh}),t[15]=s.logs.refresh,t[16]=i,t[17]=a):a=t[17];let o;return t[18]!==n||t[19]!==a?(o=(0,L.jsxs)(A,{gap:`gap-3`,padding:`px-3 py-10 sm:px-5 xl:px-6`,children:[n,a]}),t[18]=n,t[19]=a,t[20]=o):o=t[20],o}let u;t[21]!==r.autosaveStatus||t[22]!==r.error?(u=(0,L.jsx)(M,{status:r.autosaveStatus,error:r.error}),t[21]=r.autosaveStatus,t[22]=r.error,t[23]=u):u=t[23];let f;t[24]!==l||t[25]!==u?(f=(0,L.jsx)(ce,{title:l,actions:u}),t[24]=l,t[25]=u,t[26]=f):f=t[26];let m;t[27]===r.error?m=t[28]:(m=r.error?(0,L.jsx)(`div`,{className:`rounded-lg bg-red-50 px-3 py-2 text-sm text-red-700 dark:bg-red-950/50 dark:text-red-400`,role:`alert`,children:r.error}):null,t[27]=r.error,t[28]=m);let g;t[29]===i?g=t[30]:(g=(0,L.jsx)(`div`,{className:`flex min-w-0 flex-col gap-5 pb-8`,children:i}),t[29]=i,t[30]=g);let _;return t[31]!==f||t[32]!==m||t[33]!==g||t[34]!==r.onBlurCapture?(_=(0,L.jsxs)(A,{gap:`gap-6`,onBlurCapture:r.onBlurCapture,children:[f,m,g]}),t[31]=f,t[32]=m,t[33]=g,t[34]=r.onBlurCapture,t[35]=_):_=t[35],_}function pe(e){return e.language}var W={enabled:!0,driverKind:`extension`,headless:!1,executablePath:``,cdpEndpoint:`http://127.0.0.1:9222`,remoteProvider:`browserbase`,remoteApiKey:``,remoteProjectId:``,remoteRegion:``,maxNodes:180,maxCharacters:12e3,visualFallback:!0,actionTimeoutMs:3e4,sessionTimeoutMs:9e5,maxSequenceLength:5,allowedPrivateHosts:``,crossDomainNavigation:`ask`,uploads:`ask`,consequentialActions:`ask`};function G(e){let t=J(J(e).browser),n=J(t.driver),r=J(t.observation),i=J(t.limits),a=J(t.security),o=n.kind;return{...W,enabled:t.enabled!==!1,driverKind:o===`playwright`||o===`cdp`||o===`remote`?o:`extension`,headless:n.headless===!0,executablePath:Y(n.executablePath,``),cdpEndpoint:Y(n.endpoint,W.cdpEndpoint),remoteProvider:n.provider===`browser-use`?`browser-use`:`browserbase`,remoteApiKey:Y(n.apiKey,``),remoteProjectId:Y(n.projectId,``),remoteRegion:Y(n.region,``),maxNodes:X(r.maxNodes,W.maxNodes),maxCharacters:X(r.maxCharacters,W.maxCharacters),visualFallback:r.visualFallback!==!1,actionTimeoutMs:X(i.actionTimeoutMs,W.actionTimeoutMs),sessionTimeoutMs:X(i.sessionTimeoutMs,W.sessionTimeoutMs),maxSequenceLength:X(i.maxSequenceLength,W.maxSequenceLength),allowedPrivateHosts:Array.isArray(a.allowedPrivateHosts)?a.allowedPrivateHosts.filter(e=>typeof e==`string`).join(`
2
- `):``,crossDomainNavigation:he(a.crossDomainNavigation),uploads:he(a.uploads),consequentialActions:he(a.consequentialActions)}}function K(e){let t=e.driverKind===`extension`?{kind:`extension`}:e.driverKind===`playwright`?{kind:`playwright`,headless:e.headless,...e.executablePath.trim()?{executablePath:e.executablePath.trim()}:{}}:e.driverKind===`cdp`?{kind:`cdp`,endpoint:e.cdpEndpoint.trim()}:{kind:`remote`,provider:e.remoteProvider,...e.remoteApiKey.trim()?{apiKey:e.remoteApiKey.trim()}:{},...e.remoteProjectId.trim()?{projectId:e.remoteProjectId.trim()}:{},...e.remoteRegion.trim()?{region:e.remoteRegion.trim()}:{}};return{enabled:e.enabled,driver:t,observation:{maxNodes:e.maxNodes,maxCharacters:e.maxCharacters,visualFallback:e.visualFallback},limits:{actionTimeoutMs:e.actionTimeoutMs,sessionTimeoutMs:e.sessionTimeoutMs,maxSequenceLength:e.maxSequenceLength},security:{privateNetworks:`deny`,allowedPrivateHosts:e.allowedPrivateHosts.split(`
3
- `).map(e=>e.trim()).filter(Boolean),crossDomainNavigation:e.crossDomainNavigation,uploads:e.uploads,consequentialActions:e.consequentialActions}}}function q(e){if(e.driverKind===`cdp`)try{let t=new URL(e.cdpEndpoint);if(t.protocol!==`http:`&&t.protocol!==`https:`&&t.protocol!==`ws:`&&t.protocol!==`wss:`)return`CDP endpoint must use http, https, ws, or wss.`}catch{return`Enter a valid CDP endpoint URL.`}return!Number.isInteger(e.maxNodes)||e.maxNodes<20||e.maxNodes>500?`Max nodes must be between 20 and 500.`:!Number.isInteger(e.maxCharacters)||e.maxCharacters<1e3||e.maxCharacters>5e4?`Max characters must be between 1,000 and 50,000.`:!Number.isInteger(e.actionTimeoutMs)||e.actionTimeoutMs<1e3||e.actionTimeoutMs>12e4?`Action timeout must be between 1,000 and 120,000 ms.`:!Number.isInteger(e.sessionTimeoutMs)||e.sessionTimeoutMs<6e4||e.sessionTimeoutMs>36e5?`Session timeout must be between 60,000 and 3,600,000 ms.`:!Number.isInteger(e.maxSequenceLength)||e.maxSequenceLength<1||e.maxSequenceLength>10?`Sequence length must be between 1 and 10.`:null}async function me(e){await l(f(`/api/config`),{method:`PATCH`,body:JSON.stringify({browser:K(e)})}),g()}function J(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function Y(e,t){return typeof e==`string`?e:t}function X(e,t){return typeof e==`number`&&Number.isFinite(e)?e:t}function he(e){return e===`allow`||e===`deny`?e:`ask`}var ge=T();function _e(e){let t=!!u(e=>e.conversationId),[n,r]=(0,I.useReducer)(ge,{form:null,baseline:null}),i=n.form,a=n.baseline,o=(0,I.useRef)(!1),s=(0,I.useRef)(i);s.current=i;let c=(0,I.useRef)(null),{data:l,error:d,isLoading:f,mutate:p}=_(t);b({enabled:t,parsed:(0,I.useMemo)(()=>l?.payload?.config===void 0?null:G(l.payload.config),[l]),dirty:o.current,trackedParsedRef:c,dispatch:r,onResetDirty:()=>{o.current=!1}});let m=!!(t&&f&&l===void 0&&!d),h=d instanceof Error?d.message:d?String(d):null,g=(0,I.useMemo)(()=>!i||!a?!1:JSON.stringify(i)!==JSON.stringify(a),[i,a]),v=(0,I.useCallback)(e=>{o.current=!0,r({type:`patch`,patch:e})},[]),y=N({value:i,dirty:g,onSave:(0,I.useCallback)(async t=>{try{await me(t),r({type:`saved`,value:t}),o.current=!!(s.current&&JSON.stringify(s.current)!==JSON.stringify(t))}catch(t){throw Error(t instanceof Error?t.message:e.saveError)}},[e.saveError]),validate:q});return{hasToken:t,loading:m,fetchError:h,form:i,update:v,autosaveStatus:y.status,error:y.error,onBlurCapture:y.onBlurCapture,mutate:p}}var ve=[`extension`,`playwright`,`cdp`,`remote`];function ye(){let e=(0,F.c)(29),t=d(be),n;e[0]===t?n=e[1]:(n=p(t),e[0]=t,e[1]=n);let r=_e(n.agentSettings),i=r.form,s=t===`zh`,[c]=a(),l=(0,I.useRef)(!1),u;e[2]!==i||e[3]!==c||e[4]!==r?(u=()=>{if(!i||l.current)return;l.current=!0;let e=c.get(`driver`);ve.includes(e)&&e!==i.driverKind&&r.update({driverKind:e})},e[2]=i,e[3]=c,e[4]=r,e[5]=u):u=e[5];let f;e[6]!==i||e[7]!==c||e[8]!==r.update?(f=[i,c,r.update],e[6]=i,e[7]=c,e[8]=r.update,e[9]=f):f=e[9],(0,I.useEffect)(u,f);let m=s?`Chrome 扩展(推荐)`:`Chrome extension (recommended)`,h;e[10]===m?h=e[11]:(h={value:`extension`,label:m},e[10]=m,e[11]=h);let g;e[12]===Symbol.for(`react.memo_cache_sentinel`)?(g={value:`playwright`,label:`Playwright Chromium`},e[12]=g):g=e[12];let _=s?`CDP 已有浏览器`:`Existing browser over CDP`,v;e[13]===_?v=e[14]:(v={value:`cdp`,label:_},e[13]=_,e[14]=v);let y=s?`远程浏览器`:`Remote browser`,b;e[15]===y?b=e[16]:(b={value:`remote`,label:y},e[15]=y,e[16]=b);let x;e[17]!==h||e[18]!==v||e[19]!==b?(x=[h,g,v,b],e[17]=h,e[18]=v,e[19]=b,e[20]=x):x=e[20];let S=x,C;e[21]!==S||e[22]!==i||e[23]!==r||e[24]!==s?(C=i?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(z,{enabled:i.enabled,driverKind:i.driverKind,autosaveStatus:r.autosaveStatus,zh:s}),(0,L.jsxs)(Se,{title:s?`运行方式`:`Connection`,icon:(0,L.jsx)(k,{className:`size-4`}),children:[(0,L.jsx)(Ce,{label:s?`启用浏览器控制`:`Enable browser control`,checked:i.enabled,onChange:e=>r.update({enabled:e})}),(0,L.jsx)(Z,{label:s?`浏览器连接`:`Browser connection`,children:(0,L.jsx)(o,{value:i.driverKind,options:S,placeholder:s?`选择连接方式`:`Choose a connection`,allowEmpty:!1,onChange:e=>r.update({driverKind:e})})}),(0,L.jsx)(xe,{kind:i.driverKind,zh:s}),i.driverKind===`playwright`?(0,L.jsxs)(`div`,{className:`space-y-4 rounded-lg bg-surface-inset p-4`,children:[(0,L.jsx)(Ce,{label:s?`无头模式`:`Headless mode`,description:s?`后台运行,不显示浏览器窗口。关闭后可观察智能体的操作过程。`:`Run in the background without a visible window. Turn off to watch the agent work.`,checked:i.headless,onChange:e=>r.update({headless:e})}),(0,L.jsx)(Q,{label:s?`Chromium 可执行文件(可选)`:`Chromium executable (optional)`,description:s?`留空时使用由 xopc 安装的 Chromium。`:`Leave empty to use Chromium installed by xopc.`,value:i.executablePath,onChange:e=>r.update({executablePath:e})})]}):null,i.driverKind===`cdp`?(0,L.jsx)(`div`,{className:`rounded-lg bg-surface-inset p-4`,children:(0,L.jsx)(Q,{label:`CDP endpoint`,description:s?`例如 http://127.0.0.1:9222。Chrome 需要开启 remote debugging。`:`For example http://127.0.0.1:9222. Chrome must be started with remote debugging enabled.`,value:i.cdpEndpoint,onChange:e=>r.update({cdpEndpoint:e})})}):null,i.driverKind===`remote`?(0,L.jsxs)(`div`,{className:`space-y-4 rounded-lg bg-surface-inset p-4`,children:[(0,L.jsx)(Z,{label:s?`服务商`:`Provider`,children:(0,L.jsx)(o,{value:i.remoteProvider,options:[{value:`browserbase`,label:`Browserbase`},{value:`browser-use`,label:`Browser Use`}],placeholder:s?`选择服务商`:`Choose a provider`,allowEmpty:!1,onChange:e=>r.update({remoteProvider:e})})}),(0,L.jsx)(Q,{label:`API key`,type:`password`,autoComplete:`off`,value:i.remoteApiKey,onChange:e=>r.update({remoteApiKey:e})}),(0,L.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,L.jsx)(Q,{label:`Project ID`,value:i.remoteProjectId,onChange:e=>r.update({remoteProjectId:e})}),(0,L.jsx)(Q,{label:`Region`,value:i.remoteRegion,onChange:e=>r.update({remoteRegion:e})})]})]}):null]}),(0,L.jsx)(P,{children:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(Se,{title:s?`页面理解`:`Page understanding`,icon:(0,L.jsx)(ae,{className:`size-4`}),children:[(0,L.jsx)(Ce,{label:s?`需要时附加截图`:`Attach screenshots when needed`,checked:i.visualFallback,onChange:e=>r.update({visualFallback:e})}),(0,L.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,L.jsx)($,{label:s?`语义节点上限`:`Semantic node limit`,description:`20–500`,min:20,max:500,value:i.maxNodes,onChange:e=>r.update({maxNodes:e})}),(0,L.jsx)($,{label:s?`文本字符上限`:`Text character limit`,description:`1,000–50,000`,min:1e3,max:5e4,step:1e3,value:i.maxCharacters,onChange:e=>r.update({maxCharacters:e})})]})]}),(0,L.jsx)(Se,{title:s?`执行限制`:`Execution limits`,icon:(0,L.jsx)(D,{className:`size-4`}),children:(0,L.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-3`,children:[(0,L.jsx)($,{label:s?`操作超时(毫秒)`:`Action timeout (ms)`,min:1e3,max:12e4,step:1e3,value:i.actionTimeoutMs,onChange:e=>r.update({actionTimeoutMs:e})}),(0,L.jsx)($,{label:s?`会话超时(毫秒)`:`Session timeout (ms)`,min:6e4,max:36e5,step:6e4,value:i.sessionTimeoutMs,onChange:e=>r.update({sessionTimeoutMs:e})}),(0,L.jsx)($,{label:s?`批量步骤上限`:`Sequence step limit`,min:1,max:10,value:i.maxSequenceLength,onChange:e=>r.update({maxSequenceLength:e})})]})}),(0,L.jsxs)(Se,{title:s?`安全与审批`:`Safety and approvals`,icon:(0,L.jsx)(ee,{className:`size-4`}),children:[(0,L.jsx)(Q,{label:s?`允许访问的私网主机`:`Allowed private hosts`,description:s?`每行一个主机名或 IP,不支持通配符。`:`One hostname or IP per line. Wildcards are not supported.`,multiline:!0,value:i.allowedPrivateHosts,onChange:e=>r.update({allowedPrivateHosts:e})}),(0,L.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-3`,children:[(0,L.jsx)(we,{zh:s,label:s?`跨域导航`:`Cross-domain navigation`,value:i.crossDomainNavigation,onChange:e=>r.update({crossDomainNavigation:e})}),(0,L.jsx)(we,{zh:s,label:s?`高影响动作`:`Consequential actions`,value:i.consequentialActions,onChange:e=>r.update({consequentialActions:e})}),(0,L.jsx)(we,{zh:s,label:s?`文件上传`:`File uploads`,value:i.uploads,onChange:e=>r.update({uploads:e})})]})]})]})})]}):null,e[21]=S,e[22]=i,e[23]=r,e[24]=s,e[25]=C):C=e[25];let w;return e[26]!==C||e[27]!==r?(w=(0,L.jsx)(U,{sectionId:`agent-browser`,vm:r,children:C}),e[26]=C,e[27]=r,e[28]=w):w=e[28],w}function be(e){return e.language}function xe(e){let t=(0,F.c)(7),{kind:n,zh:r}=e,i=r?`直接操作你正在使用的 Chrome,保留登录状态和现有标签页;最适合日常协作。`:`Operate your current Chrome with its signed-in state and existing tabs; best for daily collaboration.`,a=r?`由 xopc 启动独立 Chromium,环境隔离、自动化稳定,适合无人值守任务。`:`Let xopc launch an isolated Chromium; stable for unattended automation.`,o=r?`连接已开启远程调试的 Chrome 或 Chromium,适合自定义浏览器启动方式。`:`Connect to Chrome or Chromium already running with remote debugging.`,s=r?`使用 Browserbase 或 Browser Use 的云端浏览器,适合服务器环境和长任务。`:`Use a Browserbase or Browser Use cloud browser for servers and long-running tasks.`,c;t[0]!==i||t[1]!==a||t[2]!==o||t[3]!==s?(c={extension:i,playwright:a,cdp:o,remote:s},t[0]=i,t[1]=a,t[2]=o,t[3]=s,t[4]=c):c=t[4];let l=c[n],u;return t[5]===l?u=t[6]:(u=(0,L.jsx)(`p`,{className:`rounded-lg bg-surface-inset px-3 py-2 text-xs leading-5 text-fg-muted`,children:l}),t[5]=l,t[6]=u),u}function Se(e){let t=(0,F.c)(17),{title:n,description:r,icon:i,children:a}=e,o;t[0]===i?o=t[1]:(o=(0,L.jsx)(`span`,{className:`mt-0.5 text-fg-subtle`,children:i}),t[0]=i,t[1]=o);let s;t[2]===n?s=t[3]:(s=(0,L.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n}),t[2]=n,t[3]=s);let c;t[4]===r?c=t[5]:(c=r?(0,L.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:r}):null,t[4]=r,t[5]=c);let l;t[6]!==s||t[7]!==c?(l=(0,L.jsxs)(`div`,{children:[s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;t[9]!==o||t[10]!==l?(u=(0,L.jsxs)(`div`,{className:`mb-4 flex items-start gap-2`,children:[o,l]}),t[9]=o,t[10]=l,t[11]=u):u=t[11];let d;t[12]===a?d=t[13]:(d=(0,L.jsx)(`div`,{className:`space-y-4`,children:a}),t[12]=a,t[13]=d);let f;return t[14]!==u||t[15]!==d?(f=(0,L.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 p-5`,children:[u,d]}),t[14]=u,t[15]=d,t[16]=f):f=t[16],f}function Z(e){let t=(0,F.c)(8),{label:n,description:r,children:i}=e,a;t[0]===n?a=t[1]:(a=(0,L.jsx)(`span`,{className:`mb-1.5 block font-medium`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=r?(0,L.jsx)(`span`,{className:`mt-1.5 block text-xs leading-5 text-fg-subtle`,children:r}):null,t[2]=r,t[3]=o);let s;return t[4]!==i||t[5]!==a||t[6]!==o?(s=(0,L.jsxs)(`label`,{className:`block text-sm text-fg`,children:[a,i,o]}),t[4]=i,t[5]=a,t[6]=o,t[7]=s):s=t[7],s}function Q(e){let t=(0,F.c)(10),{label:n,description:r,value:i,onChange:a,type:o,multiline:s,autoComplete:c}=e,l=o===void 0?`text`:o,u=s===void 0?!1:s,d;t[0]!==c||t[1]!==u||t[2]!==a||t[3]!==l||t[4]!==i?(d=u?(0,L.jsx)(`textarea`,{rows:3,value:i,onChange:e=>a(e.target.value),className:`w-full rounded-lg border border-edge bg-surface-inset px-3 py-2 text-sm text-fg outline-none focus:border-accent`}):(0,L.jsx)(`input`,{type:l,autoComplete:c,value:i,onChange:e=>a(e.target.value),className:`w-full rounded-lg border border-edge bg-surface-inset px-3 py-2 text-sm text-fg outline-none focus:border-accent`}),t[0]=c,t[1]=u,t[2]=a,t[3]=l,t[4]=i,t[5]=d):d=t[5];let f;return t[6]!==r||t[7]!==n||t[8]!==d?(f=(0,L.jsx)(Z,{label:n,description:r,children:d}),t[6]=r,t[7]=n,t[8]=d,t[9]=f):f=t[9],f}function $(e){let t=(0,F.c)(12),{label:n,description:r,value:i,onChange:a,min:o,max:s,step:c}=e,l=c===void 0?1:c,u;t[0]===a?u=t[1]:(u=e=>{let t=Number(e.target.value);Number.isFinite(t)&&a(t)},t[0]=a,t[1]=u);let d;t[2]!==s||t[3]!==o||t[4]!==l||t[5]!==u||t[6]!==i?(d=(0,L.jsx)(`input`,{type:`number`,min:o,max:s,step:l,value:i,onChange:u,className:`h-10 w-full rounded-lg border border-edge bg-surface-inset px-3 text-sm text-fg outline-none focus:border-accent`}),t[2]=s,t[3]=o,t[4]=l,t[5]=u,t[6]=i,t[7]=d):d=t[7];let f;return t[8]!==r||t[9]!==n||t[10]!==d?(f=(0,L.jsx)(Z,{label:n,description:r,children:d}),t[8]=r,t[9]=n,t[10]=d,t[11]=f):f=t[11],f}function Ce(e){let t=(0,F.c)(15),{label:n,description:r,checked:i,onChange:a}=e,o;t[0]===a?o=t[1]:(o=e=>a(e.target.checked),t[0]=a,t[1]=o);let s;t[2]!==i||t[3]!==o?(s=(0,L.jsx)(`input`,{type:`checkbox`,checked:i,onChange:o,className:`mt-0.5 size-4 accent-accent`}),t[2]=i,t[3]=o,t[4]=s):s=t[4];let c;t[5]===n?c=t[6]:(c=(0,L.jsx)(`span`,{className:`block font-medium`,children:n}),t[5]=n,t[6]=c);let l;t[7]===r?l=t[8]:(l=r?(0,L.jsx)(`span`,{className:`mt-1 block text-xs leading-5 text-fg-subtle`,children:r}):null,t[7]=r,t[8]=l);let u;t[9]!==c||t[10]!==l?(u=(0,L.jsxs)(`span`,{children:[c,l]}),t[9]=c,t[10]=l,t[11]=u):u=t[11];let d;return t[12]!==s||t[13]!==u?(d=(0,L.jsxs)(`label`,{className:`flex items-start gap-3 text-sm text-fg`,children:[s,u]}),t[12]=s,t[13]=u,t[14]=d):d=t[14],d}function we(e){let t=(0,F.c)(20),{zh:n,label:r,value:i,onChange:a}=e,s=n?`每次询问`:`Ask each time`,c;t[0]===s?c=t[1]:(c={value:`ask`,label:s},t[0]=s,t[1]=c);let l=n?`允许`:`Allow`,u;t[2]===l?u=t[3]:(u={value:`allow`,label:l},t[2]=l,t[3]=u);let d=n?`拒绝`:`Deny`,f;t[4]===d?f=t[5]:(f={value:`deny`,label:d},t[4]=d,t[5]=f);let p;t[6]!==c||t[7]!==u||t[8]!==f?(p=[c,u,f],t[6]=c,t[7]=u,t[8]=f,t[9]=p):p=t[9];let m=p,h=n?`选择策略`:`Choose a policy`,g;t[10]===a?g=t[11]:(g=e=>a(e),t[10]=a,t[11]=g);let _;t[12]!==m||t[13]!==h||t[14]!==g||t[15]!==i?(_=(0,L.jsx)(o,{value:i,options:m,placeholder:h,allowEmpty:!1,onChange:g}),t[12]=m,t[13]=h,t[14]=g,t[15]=i,t[16]=_):_=t[16];let v;return t[17]!==r||t[18]!==_?(v=(0,L.jsx)(Z,{label:r,children:_}),t[17]=r,t[18]=_,t[19]=v):v=t[19],v}export{ye as AgentBrowserSettingsPage};
@@ -1,8 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-swr-BIWyz7Rc.js","assets/rolldown-runtime-aKtaBQYM.js","assets/vendor-react-BOUWij0V.js"])))=>i.map(i=>d[i]);
2
- 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"./preload-helper-zJ_50EbN.js";import{f as a,g as o,m as s,r as c,t as l}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{n as u,r as d,t as f}from"./popover-select-B-GDnZO9.js";import{t as p}from"./circle-check-C23XjkUj.js";import{t as m}from"./plus-Q2yW6OE7.js";import{t as h}from"./x-B_N4OPjy.js";import{t as g}from"./cn-JdwAhgNB.js";import{a as _,c as v,i as y,n as b,r as x}from"./locale-store-BIkcRr3t.js";import{t as S}from"./messages-7VAhscYe.js";import{a as C,i as w,n as T,o as E,r as D,s as O,t as k}from"./dist-BGTk37IG.js";import{i as A}from"./vendor-swr-BIWyz7Rc.js";import{t as j}from"./button-CS04eWY9.js";import{n as M,r as N}from"./gateway-config-swr-1eqyz9vZ.js";import{t as P}from"./skeleton-BwbyijEw.js";import{i as F,o as I}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{t as L}from"./electron-env-Dit0bHgy.js";import{$u as R,Ai as ee,Au as z,Bt as B,Ca as V,Ct as H,Dt as U,Ec as W,Et as G,Ft as K,Gc as q,Hc as te,Ht as J,Ic as Y,Il as X,It as ne,Jc as re,Ko as ie,Ks as ae,Lo as oe,Lt as se,Mt as ce,Nt as le,Ot as ue,Pt as de,Rl as fe,Ro as Z,Sa as pe,St as me,Tc as he,Tn as ge,Tt as _e,Uo as ve,Ut as ye,Vt as be,Vu as xe,Wo as Se,Wt as Ce,Xo as we,Yo as Te,Zo as Ee,_t as De,as as Oe,au as ke,ba as Ae,bd as je,bt as Me,es as Ne,gt as Pe,ht as Fe,is as Ie,jt as Le,kl as Re,kt as ze,ku as Be,ll as Ve,ls as He,ml as Ue,mt as We,nd as Ge,nl as Ke,ns as qe,os as Je,qo as Ye,qs as Xe,rs as Ze,tu as Qe,ul as $e,us as et,vc as tt,vt as nt,wt as rt,xt as it,yd as at,yt as ot,zo as st,zt as ct}from"./index--3c0awkr.js";import{n as lt,r as ut}from"./settings-page-layout-D3KNSQ5g.js";import{n as dt,t as ft}from"./settings-form-section-BDc6bw1q.js";import{t as pt}from"./page-tabs-CfW_Q-K5.js";import{t as mt}from"./settings-loading-skeleton-CAmWMaOT.js";import{n as ht,t as gt}from"./use-autosave-C1xQ-sHn.js";import{a as _t,c as vt,d as yt,f as bt,h as xt,i as St,l as Ct,n as wt,o as Tt,p as Et,r as Dt,t as Ot,u as kt}from"./voice-config-api-B-_niUTU.js";import{t as At}from"./voice-api-key-field-DCNECvcp.js";import{t as jt}from"./settings-advanced-gate-DwALV8mi.js";import{a as Mt,i as Nt,n as Pt,o as Ft,r as It,t as Lt}from"./image-generation-api-B5DXMylk.js";var Rt=n(),Q=e(t(),1),$=r(),zt={en:{addTitle:`Add image service`,editTitle:`Manage image service`,intro:`Connect an endpoint that implements the OpenAI Images protocol.`,connection:`Connection`,providerId:`Provider ID`,providerIdHint:`Lowercase letters, numbers, hyphens, or underscores.`,name:`Display name`,baseUrl:`Base URL`,auth:`Authentication`,bearer:`Bearer token`,header:`Custom API key header`,none:`No authentication`,headerName:`Header name`,apiKey:`API key`,apiKeyHint:`Stored in the local credential store, separate from models.json.`,apiKeyUrl:`API key page (optional)`,docsUrl:`Documentation page (optional)`,openKeyPage:`Create API key`,paths:`Protocol and network`,generationsPath:`Generations path`,editsPath:`Edits path`,allowedHosts:`Allowed private hosts (optional)`,allowedHostsHint:`One exact hostname or IP per line. Private endpoints stay blocked unless listed here.`,staticHeaders:`Static headers (optional)`,staticHeadersHint:`One per line: X-Tenant: value. Credential headers are rejected.`,models:`Image models`,addModel:`Add model`,modelId:`Model ID`,modelName:`Name (optional)`,defaultModel:`Default model`,maxCount:`Max images`,defaultCount:`Default count`,defaultSize:`Default size`,format:`Output format`,supportsSize:`Supports size`,edit:`Supports edits`,remove:`Remove`,cancel:`Cancel`,save:`Save service`,saving:`Saving…`,test:`Test generation`,testing:`Generating…`,delete:`Delete service`,confirmDelete:`Delete permanently`,saved:`Image service saved.`,deleted:`Image service deleted.`,testReady:`Test image generated.`,show:`Show key`,hide:`Hide key`,copy:`Copy key`,copied:`Copied`,revealFailed:`Unable to reveal the saved key.`,notRevealable:`No revealable key is stored locally.`,required:`Complete the required connection and model fields.`,duplicateModels:`Model IDs must be unique.`,invalidHeaders:`Static headers must use “Name: value”, one per line.`},zh:{addTitle:`添加图片服务`,editTitle:`管理图片服务`,intro:`连接一个严格实现 OpenAI Images 协议的服务端点。`,connection:`连接信息`,providerId:`Provider ID`,providerIdHint:`仅支持小写字母、数字、连字符和下划线。`,name:`显示名称`,baseUrl:`Base URL`,auth:`认证方式`,bearer:`Bearer Token`,header:`自定义 API Key Header`,none:`无需认证`,headerName:`Header 名称`,apiKey:`API Key`,apiKeyHint:`密钥单独保存在本机凭据存储,不写入 models.json。`,apiKeyUrl:`API Key 创建页面(可选)`,docsUrl:`协议文档页面(可选)`,openKeyPage:`去创建 API Key`,paths:`协议与网络`,generationsPath:`生成路径`,editsPath:`编辑路径`,allowedHosts:`允许访问的私有主机(可选)`,allowedHostsHint:`每行一个精确主机名或 IP;未列出的私网端点保持阻止。`,staticHeaders:`静态 Headers(可选)`,staticHeadersHint:`每行一个:X-Tenant: value。认证 Header 会被拒绝。`,models:`图片模型`,addModel:`添加模型`,modelId:`模型 ID`,modelName:`名称(可选)`,defaultModel:`默认模型`,maxCount:`单次最大张数`,defaultCount:`默认张数`,defaultSize:`默认尺寸`,format:`输出格式`,supportsSize:`支持尺寸参数`,edit:`支持图片编辑`,remove:`移除`,cancel:`取消`,save:`保存服务`,saving:`保存中…`,test:`测试生成`,testing:`生成中…`,delete:`删除服务`,confirmDelete:`确认永久删除`,saved:`图片服务已保存。`,deleted:`图片服务已删除。`,testReady:`测试图片生成成功。`,show:`显示密钥`,hide:`隐藏密钥`,copy:`复制密钥`,copied:`已复制`,revealFailed:`无法查看已保存的密钥。`,notRevealable:`本机没有可查看的密钥。`,required:`请补全必填的连接和模型信息。`,duplicateModels:`模型 ID 不能重复。`,invalidHeaders:`静态 Header 必须使用“名称: 值”格式,每行一个。`}},Bt=`mt-1.5 h-10 w-full rounded-lg border border-edge bg-surface-panel px-3 text-sm text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`;function Vt(e){let t=e??{id:``,capabilities:{generate:{maxCount:1,supportsSize:!0},edit:{enabled:!1}}};return{original:t,id:t.id,name:t.name??``,maxCount:String(t.capabilities.generate?.maxCount??1),defaultCount:t.defaults?.count?String(t.defaults.count):``,defaultSize:t.defaults?.size??``,outputFormat:t.defaults?.outputFormat??``,supportsSize:t.capabilities.generate?.supportsSize??!1,editEnabled:t.capabilities.edit?.enabled??!1}}function Ht(e){let t=e.split(`
3
- `).map(e=>e.trim()).filter(Boolean);if(t.length===0)return;let n=t.map(e=>{let t=e.indexOf(`:`);if(t<=0||!e.slice(t+1).trim())throw Error(`invalid_headers`);return[e.slice(0,t).trim(),e.slice(t+1).trim()]});return Object.fromEntries(n)}function Ut({open:e,onOpenChange:t,provider:n,configured:r,language:i,onSaved:a}){let o=zt[i],[s,c]=(0,Q.useState)(``),[l,u]=(0,Q.useState)(``),[d,p]=(0,Q.useState)(``),[_,v]=(0,Q.useState)(`bearer`),[y,b]=(0,Q.useState)(`x-api-key`),[x,S]=(0,Q.useState)(``),[A,M]=(0,Q.useState)(``),[N,P]=(0,Q.useState)(``),[L,R]=(0,Q.useState)(`/images/generations`),[ee,z]=(0,Q.useState)(`/images/edits`),[B,V]=(0,Q.useState)(``),[H,U]=(0,Q.useState)(``),[G,K]=(0,Q.useState)([Vt()]),[q,te]=(0,Q.useState)(``),[J,Y]=(0,Q.useState)(),[X,ne]=(0,Q.useState)(!1),[re,ae]=(0,Q.useState)(),[oe,se]=(0,Q.useState)(),[ce,le]=(0,Q.useState)();(0,Q.useEffect)(()=>{if(!e)return;let t=n?.imageGeneration;c(n?.providerId??``),u(t?.name??``),p(n?.baseUrl??``),v(t?.auth.type??`bearer`),b(t?.auth.type===`header`?t.auth.headerName:`x-api-key`),S(r?`••••••••••••`:``),M(t?.apiKeyUrl??``),P(t?.documentationUrl??``),R(t?.paths?.generations??`/images/generations`),z(t?.paths?.edits??`/images/edits`),V(t?.network?.allowedHosts.join(`
4
- `)??``),U(Object.entries(n?.headers??{}).map(([e,t])=>`${e}: ${t}`).join(`
5
- `)),K(t?.models.map(Vt)??[Vt()]),te(t?.defaultModel??``),se(void 0),Y(void 0),ne(!1),ae(void 0),le(void 0)},[r,e,n]);let ue=(0,Q.useMemo)(()=>G.filter(e=>e.id.trim()).map(e=>({value:e.id.trim(),label:e.name.trim()||e.id.trim()})),[G]),de=(e,t)=>{K(n=>n.map((n,r)=>r===e?{...n,...t}:n))},Z=()=>{let e=s.trim(),t=G.map(e=>({...e,id:e.id.trim(),name:e.name.trim()}));if(!e||!l.trim()||!d.trim()||t.some(e=>!e.id))throw Error(o.required);if(new Set(t.map(e=>e.id)).size!==t.length)throw Error(o.duplicateModels);let n=q||t[0]?.id;if(!n||!t.some(e=>e.id===n))throw Error(o.required);let r;try{r=Ht(H)}catch{throw Error(o.invalidHeaders)}return{providerId:e,input:{baseUrl:d.trim(),...r?{headers:r}:{},imageGeneration:{api:`openai-images`,name:l.trim(),...N.trim()?{documentationUrl:N.trim()}:{},...A.trim()?{apiKeyUrl:A.trim()}:{},defaultModel:n,auth:_===`header`?{type:`header`,headerName:y.trim()}:{type:_},paths:{...L.trim()?{generations:L.trim()}:{},...ee.trim()?{edits:ee.trim()}:{}},...B.trim()?{network:{allowedHosts:B.split(`
6
- `).map(e=>e.trim()).filter(Boolean)}}:{},models:t.map(e=>({...e.original,id:e.id,...e.name?{name:e.name}:{name:void 0},capabilities:{...e.original.capabilities,generate:{...e.original.capabilities.generate,maxCount:Math.max(1,Number.parseInt(e.maxCount,10)||1),supportsSize:e.supportsSize},edit:{...e.original.capabilities.edit,enabled:e.editEnabled}},defaults:{...e.original.defaults,...e.defaultCount?{count:Math.max(1,Number.parseInt(e.defaultCount,10)||1)}:{count:void 0},...e.defaultSize.trim()?{size:e.defaultSize.trim()}:{size:void 0},...e.outputFormat?{outputFormat:e.outputFormat}:{outputFormat:void 0}}}))}}}},pe=async()=>{let e=Z();return await Nt(e.providerId,e.input),_!==`none`&&x.trim()&&!Ye(x)&&await Mt(e.providerId,x.trim()),await a(e.providerId),e},me=async()=>{Y(`save`),ae(void 0),se(void 0);try{await pe(),S(_===`none`?``:`••••••••••••`),se(o.saved)}catch(e){ae(e instanceof Error?e.message:String(e))}finally{Y(void 0)}},he=async()=>{Y(`test`),ae(void 0),se(void 0),le(void 0);try{let e=await pe();le((await Ft(e.providerId,e.input.imageGeneration.defaultModel)).images[0]?.dataUrl),se(o.testReady)}catch(e){ae(e instanceof Error?e.message:String(e))}finally{Y(void 0)}},ge=async()=>{if(n){if(!X){ne(!0);return}Y(`delete`),ae(void 0);try{await Lt(n.providerId),await a(),t(!1)}catch(e){ae(e instanceof Error?e.message:String(e))}finally{Y(void 0)}}};return(0,$.jsx)(k,{open:e,onOpenChange:t,children:(0,$.jsxs)(E,{children:[(0,$.jsx)(C,{className:g(`xopc-dialog-overlay fixed inset-0 bg-scrim`,I)}),(0,$.jsxs)(D,{className:g(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(88vh,760px)] w-[min(calc(100%-2rem),52rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-popover`,F),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,$.jsxs)(`header`,{className:`flex shrink-0 items-start justify-between gap-4 border-b border-edge px-5 py-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(O,{className:`font-semibold text-fg`,children:n?o.editTitle:o.addTitle}),(0,$.jsx)(w,{className:`mt-1 text-sm text-fg-muted`,children:o.intro})]}),(0,$.jsx)(T,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`rounded-md p-1 text-fg-muted hover:bg-surface-inset hover:text-fg`,"aria-label":o.cancel,children:(0,$.jsx)(h,{className:`size-5`})})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-6 overflow-y-auto px-5 py-4`,children:[(0,$.jsxs)(`section`,{className:`space-y-4`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-subtle`,children:o.connection}),(0,$.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.providerId,(0,$.jsx)(`input`,{value:s,disabled:!!n,onChange:e=>c(e.target.value),placeholder:`my-image-service`,className:Bt}),(0,$.jsx)(`span`,{className:`mt-1 block font-normal text-fg-subtle`,children:o.providerIdHint})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.name,(0,$.jsx)(`input`,{value:l,onChange:e=>u(e.target.value),placeholder:`My Image Service`,className:Bt})]})]}),(0,$.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[o.baseUrl,(0,$.jsx)(`input`,{value:d,onChange:e=>p(e.target.value),placeholder:`https://api.example.com/v1`,className:Bt})]}),(0,$.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.auth,(0,$.jsx)(f,{value:_,options:[{value:`bearer`,label:o.bearer},{value:`header`,label:o.header},{value:`none`,label:o.none}],placeholder:o.auth,allowEmpty:!1,onChange:e=>v(e),triggerClassName:`mt-1.5`})]}),_===`header`?(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.headerName,(0,$.jsx)(`input`,{value:y,onChange:e=>b(e.target.value),className:Bt})]}):null]}),_===`none`?null:(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`mb-1.5 flex items-center justify-between`,children:[(0,$.jsx)(`label`,{htmlFor:`custom-image-api-key`,className:`text-xs font-medium text-fg-muted`,children:o.apiKey}),A.trim()?(0,$.jsxs)(`a`,{href:A.trim(),target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent hover:underline`,children:[o.openKeyPage,(0,$.jsx)(at,{className:`size-3.5`})]}):null]}),(0,$.jsx)(ie,{id:`custom-image-api-key`,value:x,onChange:e=>S(Ye(x)?e.replace(/^•+/,``):e),labels:{show:o.show,hide:o.hide,copy:o.copy,copied:o.copied},reveal:()=>be(s).then(e=>e.apiKey),loadFailedLabel:o.revealFailed,notInConfigFile:o.notRevealable}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:o.apiKeyHint})]}),(0,$.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.apiKeyUrl,(0,$.jsx)(`input`,{value:A,onChange:e=>M(e.target.value),placeholder:`https://…`,className:Bt})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.docsUrl,(0,$.jsx)(`input`,{value:N,onChange:e=>P(e.target.value),placeholder:`https://…`,className:Bt})]})]}),(0,$.jsxs)(`details`,{className:`rounded-lg border border-edge bg-surface-inset px-3 py-2.5`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted`,children:o.paths}),(0,$.jsxs)(`div`,{className:`mt-3 grid gap-4 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.generationsPath,(0,$.jsx)(`input`,{value:L,onChange:e=>R(e.target.value),className:Bt})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.editsPath,(0,$.jsx)(`input`,{value:ee,onChange:e=>z(e.target.value),className:Bt})]})]}),(0,$.jsxs)(`label`,{className:`mt-4 block text-xs font-medium text-fg-muted`,children:[o.allowedHosts,(0,$.jsx)(`textarea`,{value:B,onChange:e=>V(e.target.value),rows:2,placeholder:`127.0.0.1
7
- image-server.lan`,className:`mt-1.5 w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 font-mono text-xs text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`}),(0,$.jsx)(`span`,{className:`mt-1 block font-normal text-fg-subtle`,children:o.allowedHostsHint})]}),(0,$.jsxs)(`label`,{className:`mt-4 block text-xs font-medium text-fg-muted`,children:[o.staticHeaders,(0,$.jsx)(`textarea`,{value:H,onChange:e=>U(e.target.value),rows:3,className:`mt-1.5 w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 font-mono text-xs text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`}),(0,$.jsx)(`span`,{className:`mt-1 block font-normal text-fg-subtle`,children:o.staticHeadersHint})]})]})]}),(0,$.jsxs)(`section`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-subtle`,children:o.models}),(0,$.jsxs)(j,{variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,onClick:()=>K(e=>[...e,Vt()]),children:[(0,$.jsx)(m,{className:`size-4`}),o.addModel]})]}),(0,$.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[o.defaultModel,(0,$.jsx)(f,{value:q||ue[0]?.value||``,options:ue,placeholder:o.defaultModel,allowEmpty:!1,onChange:te,triggerClassName:`mt-1.5 max-w-sm`})]}),G.map((e,t)=>(0,$.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,$.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.modelId,(0,$.jsx)(`input`,{value:e.id,onChange:e=>de(t,{id:e.target.value}),placeholder:`image-1`,className:Bt})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.modelName,(0,$.jsx)(`input`,{value:e.name,onChange:e=>de(t,{name:e.target.value}),className:Bt})]})]}),(0,$.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2 lg:grid-cols-4`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.maxCount,(0,$.jsx)(`input`,{type:`number`,min:1,value:e.maxCount,onChange:e=>de(t,{maxCount:e.target.value}),className:Bt})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.defaultCount,(0,$.jsx)(`input`,{type:`number`,min:1,value:e.defaultCount,onChange:e=>de(t,{defaultCount:e.target.value}),className:Bt})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.defaultSize,(0,$.jsx)(`input`,{value:e.defaultSize,onChange:e=>de(t,{defaultSize:e.target.value}),placeholder:`1024x1024`,className:Bt})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.format,(0,$.jsx)(f,{value:e.outputFormat,options:[{value:`png`,label:`PNG`},{value:`jpeg`,label:`JPEG`},{value:`webp`,label:`WebP`}],placeholder:o.format,allowEmpty:!0,onChange:e=>de(t,{outputFormat:e}),triggerClassName:`mt-1.5`})]})]}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-4`,children:[(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:e.supportsSize,onChange:e=>de(t,{supportsSize:e.target.checked})}),o.supportsSize]}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:e.editEnabled,onChange:e=>de(t,{editEnabled:e.target.checked})}),o.edit]}),(0,$.jsxs)(`button`,{type:`button`,disabled:G.length===1,onClick:()=>K(e=>e.filter((e,n)=>n!==t)),className:`ml-auto inline-flex items-center gap-1 text-xs text-red-600 disabled:opacity-40 dark:text-red-400`,children:[(0,$.jsx)(W,{className:`size-3.5`}),o.remove]})]})]},t))]}),ce?(0,$.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,$.jsx)(Be,{className:`size-4`}),o.testReady]}),(0,$.jsx)(`img`,{src:ce,alt:`Generated provider test`,className:`max-h-72 rounded-lg object-contain`})]}):null,oe?(0,$.jsx)(`p`,{className:`rounded-lg bg-emerald-500/10 px-3 py-2 text-sm text-emerald-700 dark:text-emerald-300`,role:`status`,children:oe}):null,re?(0,$.jsx)(`p`,{className:`rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-600 dark:text-red-400`,children:re}):null]}),(0,$.jsxs)(`footer`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-t border-edge px-5 py-3`,children:[n?(0,$.jsxs)(j,{variant:`secondary`,className:`border-red-500/30 text-red-600 hover:bg-red-500/10 dark:text-red-400`,disabled:!!J,onClick:()=>void ge(),children:[J===`delete`?(0,$.jsx)(fe,{className:`size-4 animate-spin`}):(0,$.jsx)(W,{className:`size-4`}),X?o.confirmDelete:o.delete]}):null,(0,$.jsxs)(`div`,{className:`ml-auto flex gap-2`,children:[(0,$.jsx)(T,{asChild:!0,children:(0,$.jsx)(j,{variant:`secondary`,children:o.cancel})}),(0,$.jsxs)(j,{variant:`secondary`,disabled:!!J,onClick:()=>void he(),children:[J===`test`?(0,$.jsx)(fe,{className:`size-4 animate-spin`}):null,J===`test`?o.testing:o.test]}),(0,$.jsxs)(j,{variant:`primary`,disabled:!!J,onClick:()=>void me(),children:[J===`save`?(0,$.jsx)(fe,{className:`size-4 animate-spin`}):null,J===`save`?o.saving:o.save]})]})]})]})]})})}var Wt=`••••••••••••`,Gt={en:{title:`Image generation`,intro:`Configure the default image model and service. Agents inherit this setting unless overridden in Agent settings.`,provider:`Provider`,model:`Model`,apiKey:`API key`,getApiKey:`Get API key`,apiKeyHint:`Stored in the local credential store, never in xopc.json.`,existingKey:`A credential or environment variable is already available. Leave this blank to reuse it.`,savedKey:`A credential is saved. Use the eye button to view it, or type a new key to replace it.`,revealFailed:`Unable to load the saved API key.`,keyNotRevealable:`This credential comes from an environment variable or another non-revealable source.`,advanced:`Provider settings`,enable:`Enable image generation`,enabling:`Verifying and enabling…`,enabled:`Image generation is ready.`,addService:`Add image service`,manageService:`Manage service`,custom:`Custom`,current:`Current`,configured:`Credential ready`,needsKey:`API key required`,connect:`Connect to a gateway to continue.`,loadError:`Unable to load image generation settings.`,selectModel:`Select a model`,show:`Show key`,hide:`Hide key`,copy:`Copy key`,copied:`Copied`},zh:{title:`图片生成`,intro:`配置全局图片生成模型和服务。各智能体默认继承此设置,也可在智能体详情中单独覆盖。`,provider:`Provider`,model:`模型`,apiKey:`API Key`,getApiKey:`获取 API Key`,apiKeyHint:`密钥只保存在本机凭据存储中,不会写入 xopc.json。`,existingKey:`已有凭据或环境变量;留空即可继续使用。`,savedKey:`凭据已保存。点击眼睛可查看,直接输入新密钥可替换。`,revealFailed:`无法读取已保存的 API Key。`,keyNotRevealable:`当前凭据来自环境变量或其他不可查看的来源。`,advanced:`服务商设置`,enable:`启用图片生成`,enabling:`正在验证并启用…`,enabled:`图片生成已可用。`,addService:`添加图片服务`,manageService:`管理服务`,custom:`自定义`,current:`当前使用`,configured:`凭据已就绪`,needsKey:`需要 API Key`,connect:`请先连接网关。`,loadError:`无法加载图片生成设置。`,selectModel:`选择模型`,show:`显示密钥`,hide:`隐藏密钥`,copy:`复制密钥`,copied:`已复制`}};async function Kt(){let e=await _(x(`/api/image-generation/default`));if(!e.payload)throw Error(`Invalid default image generation response`);return e.payload}function qt(e){let t=e?.indexOf(`/`)??-1;return t>0?e.slice(0,t):void 0}function Jt(e){let t=e?.indexOf(`/`)??-1;return t>0?e.slice(t+1):void 0}function Yt(e){return Object.fromEntries(e.configFields.map(t=>[t.key,e.config[t.key]??(t.required?t.options?.[0]?.value??``:``)]))}function Xt(e){let t=(0,Rt.c)(11),{field:n,value:r,onChange:i}=e,a;t[0]!==n.label||t[1]!==n.options||t[2]!==n.placeholder||t[3]!==n.required||t[4]!==n.type||t[5]!==i||t[6]!==r?(a=n.type===`select`?(0,$.jsx)(f,{value:r,options:(n.options??[]).map(Zt),placeholder:n.placeholder??n.label,allowEmpty:!n.required,onChange:i,triggerClassName:`mt-1.5`}):(0,$.jsx)(`input`,{type:`url`,value:r,required:n.required,onChange:e=>i(e.target.value),placeholder:n.placeholder,className:`mt-1.5 h-10 w-full rounded-lg border border-edge bg-surface-panel px-3 text-sm text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`}),t[0]=n.label,t[1]=n.options,t[2]=n.placeholder,t[3]=n.required,t[4]=n.type,t[5]=i,t[6]=r,t[7]=a):a=t[7];let o;return t[8]!==n.label||t[9]!==a?(o=(0,$.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[n.label,a]}),t[8]=n.label,t[9]=a,t[10]=o):o=t[10],o}function Zt(e){return{value:e.value,label:e.label}}function Qt(){let e=(0,Rt.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(P,{className:`h-24 rounded-xl`}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsxs)(`div`,{className:`grid gap-4`,"aria-hidden":`true`,children:[t,(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:Array.from({length:5}).map($t)}),(0,$.jsx)(P,{className:`h-64 rounded-xl`})]}),e[1]=n):n=e[1],n}function $t(e,t){return(0,$.jsx)(P,{className:`h-24 rounded-xl`},t)}function en(){let e=b(e=>e.language),t=Gt[e],n=!!v(e=>e.conversationId),[r,a]=(0,Q.useState)(``),[o,s]=(0,Q.useState)(``),[c,l]=(0,Q.useState)(``),[u,d]=(0,Q.useState)({}),[h,g]=(0,Q.useState)(!1),[y,S]=(0,Q.useState)(),[C,w]=(0,Q.useState)(!1),[T,E]=(0,Q.useState)(!1),[D,O]=(0,Q.useState)(),{data:k,isLoading:N,error:P,mutate:F}=A(n?x(`/api/image-generation/catalog`):null,It,{revalidateOnFocus:!1}),{data:I,isLoading:L,error:R,mutate:ee}=A(n?x(`/api/image-generation/custom-providers`):null,Pt,{revalidateOnFocus:!1}),{data:z,isLoading:B,error:V,mutate:H}=A(n?`default-image-generation`:null,Kt,{revalidateOnFocus:!1});(0,Q.useEffect)(()=>{if(!k||!z)return;let e=qt(z.model?.primary),t=k.find(t=>t.id===e)??k.find(e=>e.configured)??k[0];t&&(a(t.id),s(t.id===e&&Jt(z.model?.primary)||t.defaultModel),l(t.configured?Wt:``),d(Yt(t)))},[z,k]);let U=k?.find(e=>e.id===r),W=U?U.apiKeyUrl??_e(U.id,e)[0]?.href:void 0,G=(0,Q.useMemo)(()=>(U?.models??[]).map(e=>({value:e,label:e})),[U?.models]),K=z?.model?.primary,q=!!(U&&o&&(U.credentialMode!==`api-key`||U.configured||c.trim())&&U.configFields.every(e=>!e.required||u[e.key]?.trim()));if(!n)return(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.connect});if(N||L||B)return(0,$.jsx)(Qt,{});if(P||R||V||!k||!I)return(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:t.loadError});let J=e=>{a(e.id),s(e.defaultModel),l(e.configured?Wt:``),d(Yt(e)),S(void 0)},Y=()=>{O(void 0),E(!0)},X=()=>{let e=I.find(e=>e.providerId===U?.id);e&&(O(e),E(!0))},ne=async e=>{let[t,n]=await Promise.all([ee(),F()]);if(e&&n?.some(t=>t.id===e)){let r=n.find(t=>t.id===e);a(r.id),s(r.defaultModel),l(r.configured?Wt:``),d(Yt(r)),O(t?.find(t=>t.providerId===e))}},ae=async()=>{if(!(!U||!q)){g(!0),S(void 0),w(!1);try{let e=await _(x(`/api/image-generation/default/setup`),{method:`POST`,body:JSON.stringify({providerId:U.id,modelId:o,...c.trim()&&!Ye(c)?{apiKey:c.trim()}:{},providerConfig:Object.fromEntries(Object.entries(u).filter(([,e])=>e.trim()))})});if(!e.payload)throw Error(`Invalid setup response`);await Promise.all([H(e.payload.default,{revalidate:!1}),F(e.payload.providers,{revalidate:!1}),i(async()=>{let{mutate:e}=await import(`./vendor-swr-BIWyz7Rc.js`).then(e=>e.r);return{mutate:e}},__vite__mapDeps([0,1,2])).then(({mutate:e})=>Promise.all([e(`settings-agent-defaults`),e(`settings-gateway-agents`)])),M()]),l(Wt),w(!0)}catch(e){S(e instanceof Error?e.message:String(e))}finally{g(!1)}}};return(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,$.jsx)(`section`,{className:`rounded-xl bg-surface-hover/20 p-4`,children:(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,$.jsx)(`div`,{className:`rounded-lg bg-accent/10 p-2 text-accent`,children:(0,$.jsx)(ke,{className:`size-5`})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.title}),(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:t.intro})]})]})}),(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-subtle`,children:t.provider}),(0,$.jsxs)(j,{variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,onClick:Y,children:[(0,$.jsx)(m,{className:`size-4`}),t.addService]})]}),(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:k.map(e=>{let n=e.id===r,i=e.id===qt(K);return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>J(e),className:`min-h-24 rounded-xl p-4 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${n?`bg-accent-soft shadow-surface`:`bg-surface-base/55 hover:bg-surface-hover`}`,children:[(0,$.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`truncate font-medium text-fg`,children:e.label}),e.source===`custom`?(0,$.jsx)(`span`,{className:`rounded-full bg-surface-inset px-2 py-0.5 text-[10px] text-fg-subtle`,children:t.custom}):null]}),(0,$.jsx)(`span`,{"aria-hidden":!i,className:`shrink-0 rounded-full bg-accent/10 px-2 py-0.5 text-[11px] font-medium text-accent ${i?``:`invisible`}`,children:t.current})]}),(0,$.jsxs)(`span`,{className:`mt-2 flex items-center gap-1.5 text-xs ${e.configured?`text-emerald-600 dark:text-emerald-400`:`text-fg-muted`}`,children:[e.configured||e.credentialMode!==`api-key`?(0,$.jsx)(p,{className:`size-3.5`}):(0,$.jsx)(Qe,{className:`size-3.5`}),e.configured||e.credentialMode!==`api-key`?t.configured:t.needsKey]})]},e.id)})})]}),U?(0,$.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 p-4`,children:[(0,$.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[t.model,(0,$.jsx)(f,{value:o,options:G,placeholder:t.selectModel,allowEmpty:!1,onChange:s,triggerClassName:`mt-1.5`})]}),U.configFields.filter(e=>e.required).map(e=>(0,$.jsx)(Xt,{field:e,value:u[e.key]??``,onChange:t=>d(n=>({...n,[e.key]:t}))},e.key))]}),U.source===`custom`?(0,$.jsx)(`div`,{className:`mt-4 flex justify-end`,children:(0,$.jsxs)(j,{variant:`secondary`,onClick:X,children:[(0,$.jsx)(re,{className:`size-4`}),t.manageService]})}):null,U.credentialMode===`api-key`?(0,$.jsxs)(`div`,{className:`mt-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(`label`,{htmlFor:`image-generation-api-key`,className:`text-xs font-medium text-fg-muted`,children:t.apiKey}),W?(0,$.jsxs)(`a`,{href:W,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs font-medium text-accent hover:underline`,children:[t.getApiKey,(0,$.jsx)(at,{className:`size-3.5`,"aria-hidden":`true`})]}):null]}),(0,$.jsx)(ie,{id:`image-generation-api-key`,value:c,onChange:e=>l(Ye(c)?e.replace(/^•+/,``):e),placeholder:U.configured?t.existingKey:t.needsKey,labels:{show:t.show,hide:t.hide,copy:t.copy,copied:t.copied},reveal:()=>be(U.id).then(e=>e.apiKey),loadFailedLabel:t.revealFailed,notInConfigFile:t.keyNotRevealable,className:`mt-1.5`,autoComplete:`new-password`},U.id),(0,$.jsx)(`span`,{className:`mt-1.5 block font-normal leading-relaxed text-fg-subtle`,children:U.configured?t.savedKey:t.apiKeyHint})]}):null,U.configFields.some(e=>!e.required)?(0,$.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-base/55 px-3 py-2.5`,children:[(0,$.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 text-sm font-medium text-fg-muted`,children:[(0,$.jsx)(te,{className:`size-4`}),t.advanced]}),(0,$.jsx)(`div`,{className:`mt-3 grid gap-3 md:grid-cols-2`,children:U.configFields.filter(e=>!e.required).map(e=>(0,$.jsx)(Xt,{field:e,value:u[e.key]??``,onChange:t=>d(n=>({...n,[e.key]:t}))},e.key))})]}):null,C?(0,$.jsx)(`p`,{className:`mt-4 rounded-lg bg-emerald-500/10 px-3 py-2 text-sm text-emerald-700 dark:text-emerald-300`,role:`status`,children:t.enabled}):null,y?(0,$.jsx)(`p`,{className:`mt-4 rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-600 dark:text-red-400`,children:y}):null,(0,$.jsx)(`div`,{className:`mt-4 flex justify-end`,children:(0,$.jsxs)(j,{variant:`primary`,disabled:!q||h,onClick:()=>void ae(),children:[h?(0,$.jsx)(fe,{className:`size-4 animate-spin`}):(0,$.jsx)(p,{className:`size-4`}),(0,$.jsxs)(`span`,{className:`grid`,children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`invisible col-start-1 row-start-1`,children:t.enable}),(0,$.jsx)(`span`,{"aria-hidden":!0,className:`invisible col-start-1 row-start-1`,children:t.enabling}),(0,$.jsx)(`span`,{className:`col-start-1 row-start-1`,children:h?t.enabling:t.enable})]})]})})]}):null,(0,$.jsx)(Ut,{open:T,onOpenChange:E,provider:D,configured:!!(D&&k.find(e=>e.id===D.providerId)?.configured),language:e,onSaved:ne})]})}function tn({disabled:e=!1}){let t=b(e=>e.language)===`zh`,[n,r]=(0,Q.useState)(!1),[i,a]=(0,Q.useState)(``),{data:o,mutate:s,error:c}=A(x(`/api/voice/catalog`),async e=>{let t=await _(e);return Je.parse(t.payload)}),l=t?{transcription:`录音转文字`,"transcription.stream":`实时听写 / 语音助手输入`,speech:`消息朗读`,"speech.stream":`语音助手输出`,conversation:`自然语音对话`}:{transcription:`Recorded transcription`,"transcription.stream":`Live dictation / assistant input`,speech:`Message readout`,"speech.stream":`Assistant speech`,conversation:`Natural conversation`},f=async e=>{if(o){r(!0),a(``);try{let t=await _(x(e?`/api/voice/selection`:`/api/voice/catalog/refresh`),{method:e?`PUT`:`POST`,...e?{body:JSON.stringify({revision:o.revision,selection:e})}:{}});await s(Je.parse(t.payload),!1),await M()}catch(e){a(e instanceof Error?e.message:String(e)),await s()}finally{r(!1)}}};return(0,$.jsxs)(`section`,{className:`space-y-4 rounded-xl bg-surface-hover/20 p-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(`h3`,{className:`font-medium`,children:t?`XOPC 托管语音模型`:`XOPC managed voice models`}),(0,$.jsx)(j,{variant:`secondary`,disabled:n||e||!o,onClick:()=>void f(),children:t?`刷新目录`:`Refresh catalog`})]}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t?`各设备共用此 Gateway 的模型设置,修改在下次调用生效。仅显示支持对应场景的已发布模型。`:`Devices share this gateway’s selections. Changes apply to the next call. Only published models supporting each mode are shown.`}),i||c?(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-red-600`,children:i||String(c)}):null,o?Object.keys(l).map(r=>{let i=o.selections.find(e=>e.mode===r),a=o.models.filter(e=>e.voice.modes.includes(r)),s=a.find(e=>e.id===i?.model);return(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[(0,$.jsx)(`span`,{children:l[r]}),(0,$.jsxs)(u,{className:`w-full`,value:i?.model??``,disabled:n||e||!a.length,onChange:e=>void f({mode:r,model:e.target.value}),children:[(0,$.jsx)(d,{value:``,disabled:!0,children:t?`选择模型`:`Choose model`}),i&&!s?(0,$.jsxs)(d,{value:i.model,disabled:!0,children:[i.model,` · `,t?`不可用`:`Unavailable`]}):null,a.map(e=>(0,$.jsx)(d,{value:e.id,children:e.name},e.id))]}),a.length?null:(0,$.jsx)(`span`,{className:`text-xs text-fg-muted`,children:t?`暂无可用模型`:`No available model`})]}),s&&s.voice.voices.length>0?(0,$.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[(0,$.jsx)(`span`,{children:t?`音色`:`Voice`}),(0,$.jsx)(u,{className:`w-full`,value:i?.voice??``,disabled:n||e,onChange:e=>void f({mode:r,model:s.id,voice:e.target.value}),children:s.voice.voices.map(e=>(0,$.jsx)(d,{value:e.id,children:e.name},e.id))})]}):null]},r)}):(0,$.jsx)(P,{className:`h-48 w-full`})]})}function nn({v:e}){let t=He(e=>e.microphoneId),n=He(e=>e.setMicrophoneId),[r,i]=(0,Q.useState)([]),[a,o]=(0,Q.useState)(``),[s,c]=(0,Q.useState)(!1),l=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{l.current=!0;let e=()=>{navigator.mediaDevices?.enumerateDevices().then(e=>{l.current&&i(e.filter(e=>e.kind===`audioinput`))}).catch(()=>{})};return e(),navigator.mediaDevices?.addEventListener(`devicechange`,e),()=>{l.current=!1,navigator.mediaDevices?.removeEventListener(`devicechange`,e)}},[]);let f=async()=>{c(!0),o(``);try{(await navigator.mediaDevices.getUserMedia({audio:!0})).getTracks().forEach(e=>e.stop());let e=await navigator.mediaDevices.enumerateDevices();l.current&&i(e.filter(e=>e.kind===`audioinput`))}catch(e){l.current&&o(e instanceof Error?e.message:String(e))}finally{l.current&&c(!1)}};return(0,$.jsxs)(`section`,{className:`space-y-4 rounded-xl bg-surface-hover/20 p-4`,children:[(0,$.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[(0,$.jsx)(`span`,{children:e.experience.microphone}),(0,$.jsxs)(u,{value:t,onChange:e=>n(e.target.value),children:[(0,$.jsx)(d,{value:``,children:e.experience.systemDevice}),t&&!r.some(e=>e.deviceId===t)?(0,$.jsx)(d,{value:t,children:e.experience.unavailable}):null,r.filter(e=>e.deviceId&&e.deviceId!=="default").map((t,n)=>(0,$.jsx)(d,{value:t.deviceId,children:t.label||`${e.experience.microphone} ${n+1}`},t.deviceId))]})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.experience.deviceHint}),(0,$.jsx)(j,{variant:`secondary`,disabled:s,onClick:()=>void f(),children:e.experience.refreshDevices}),a?(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-red-600`,children:a}):null]})}function rn({v:e,canListen:t,canSpeak:n,disabled:r,onVerified:i}){let a=e.setup,o=(0,Q.useContext)(Ne)?.active??!1,[s,c]=(0,Q.useState)(`idle`),[l,u]=(0,Q.useState)(``),[d,f]=(0,Q.useState)(``),p=(0,Q.useRef)(`idle`),m=(0,Q.useRef)(null),h=(0,Q.useRef)(!1),g=e=>{p.current=e,c(e)},_=()=>{m.current?.(),m.current=null};(0,Q.useEffect)(()=>()=>m.current?.(),[]);async function v(e){_(),i?.({input:!1,output:!1}),h.current=!1,u(``),f(``),g(e?`connecting`:`playing`);let t=new AbortController,r,o,s,c,l=()=>{o?.cancel(),r?.getTracks().forEach(e=>e.stop()),s?.stop(`surface_closed`)},d=window.setTimeout(()=>v(a.timeout),6e4);m.current=()=>{t.abort(),window.clearTimeout(d),l(),c?.close()};function v(e){t.signal.aborted||(g(`error`),f(e),_())}async function y(){g(`playing`),l();try{let e=await bt(t.signal);if(t.signal.aborted)return;c?.enqueue(e,()=>{t.signal.aborted||(window.clearTimeout(d),g(`confirm`))})}catch(e){v(e instanceof Error?e.message:a.testFailed)}}try{if(n&&(c=new Ie,await c.start(),t.signal.throwIfAborted()),!e){await y();return}let d=window.electronAPI?.system;if(d){let e=await d.requestMicrophone();if(t.signal.throwIfAborted(),e.status===`denied`)throw Error(a.microphoneDenied)}if(r=await navigator.mediaDevices.getUserMedia({audio:et()}),t.signal.aborted){l();return}if(s=await Oe.connect({purpose:`dictation`,signal:t.signal,onEvent:e=>{t.signal.aborted||(e.type===`session.error`&&v(a.testFailed),p.current===`listening`&&(e.type===`input.transcript.delta`&&u(e.payload.text),e.type===`input.transcript.final`&&e.payload.text.trim()&&(u(e.payload.text.trim()),h.current=!0,n?y():(g(`passed`),i?.({input:!0,output:!1}),_()))))},onClose:()=>{(p.current===`listening`||p.current===`connecting`)&&v(a.testFailed)}}),t.signal.aborted){l();return}let f;if(o=await qe.start(r,{onSamples:e=>{f&&!t.signal.aborted&&s?.sendAudio(f.push(e))}}),t.signal.aborted){l();return}f=new Ze(o.sampleRate,s.session.inputFormat.sampleRate),g(`listening`)}catch(e){if(t.signal.aborted){l();return}v(e instanceof Error?e.message:a.testFailed)}}let y=s===`connecting`||s===`listening`||s===`playing`;return(0,$.jsxs)(`div`,{className:`space-y-3 rounded-xl bg-surface-base/45 p-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsxs)(j,{type:`button`,variant:`primary`,disabled:o||r||!t||y,onClick:()=>void v(!0),children:[y?(0,$.jsx)(fe,{className:`size-4 animate-spin`}):(0,$.jsx)(Re,{className:`size-4`}),n?a.test:a.testInput]}),(0,$.jsxs)(j,{type:`button`,variant:`secondary`,disabled:o||r||!n||y,onClick:()=>void v(!1),children:[(0,$.jsx)($e,{className:`size-4`}),e.tts.test.play]}),y?(0,$.jsxs)(j,{type:`button`,variant:`ghost`,onClick:()=>{_(),g(`idle`)},children:[(0,$.jsx)(Y,{className:`size-4`}),e.tts.test.stop]}):null]}),(0,$.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`space-y-2 text-xs text-fg-muted`,children:[s===`idle`?(0,$.jsx)(`p`,{children:o?e.experience.endCallBeforeTest:r?a.saveBeforeTest:a.microphoneHint}):null,s===`connecting`?(0,$.jsx)(`p`,{children:a.connecting}):null,s===`listening`?(0,$.jsx)(`p`,{children:a.speakNow}):null,l?(0,$.jsx)(`p`,{className:`rounded-lg bg-surface-base p-3 text-sm text-fg`,children:l}):null,s===`playing`?(0,$.jsx)(`p`,{children:a.playing}):null,s===`confirm`?(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`span`,{children:a.heardQuestion}),(0,$.jsx)(j,{type:`button`,variant:`secondary`,onClick:()=>{_(),i?.({input:h.current,output:!0}),g(`passed`)},children:a.heard}),(0,$.jsx)(j,{type:`button`,variant:`ghost`,onClick:()=>{_(),g(`error`),f(a.notHeard)},children:a.notHeardButton})]}):null,s===`passed`?(0,$.jsx)(`p`,{children:h.current?n?a.passed:a.inputPassed:a.outputPassed}):null,s===`error`?(0,$.jsx)(`p`,{role:`alert`,className:`text-red-600 dark:text-red-400`,children:d}):null]})]})}function an(e,t){return{...e,stt:{...e.stt,enabled:!0,provider:t},voice:{...e.voice,realtime:{...e.voice.realtime,enabled:!0,tts:e.voice.realtime.tts?.provider===t?e.voice.realtime.tts:{provider:t,...t===`alibaba`?{voice:`Cherry`}:{}},omni:e.voice.realtime.omni?.provider===t?e.voice.realtime.omni:t===`xopc-cloud`?void 0:{provider:t,model:`qwen3-omni-flash-realtime`,voice:e.voice.realtime.omni?.voice??`Cherry`,instructions:e.voice.realtime.omni?.instructions??`Keep replies conversational and concise.`}}}}}function on(e){let t=(0,Rt.c)(117),{section:n,v:r,form:i,pending:a,apiKeyLabels:o,sttProviders:s,onChange:c}=e,f=r.setup,[p,m]=(0,Q.useState)(!1),h;t[0]===i?h=t[1]:(h=JSON.stringify(i),t[0]=i,t[1]=h);let g=h,_;t[2]===g?_=t[3]:(_={signature:g,input:!1,output:!1},t[2]=g,t[3]=_);let[v,y]=(0,Q.useState)(_);v.signature!==g&&y({signature:g,input:!1,output:!1});let b;t[4]!==a||t[5]!==g?(b=a?null:[`voice-realtime-status`,g],t[4]=a,t[5]=g,t[6]=b):b=t[6];let S;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(S={revalidateOnFocus:!0},t[7]=S):S=t[7];let{data:C,error:w,isLoading:T}=A(b,Dt,S),E;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(E=x(`/api/voice/catalog`),t[8]=E):E=t[8];let{data:D}=A(E,dn),O=i.voice.realtime,k=i.stt.provider,M=O.tts,N=M?.provider??C?.tts?.provider,F=C?.tts?.model,I;t[9]!==F||t[10]!==N?(I=N&&F?[`realtime-voices`,N,F]:null,t[9]=F,t[10]=N,t[11]=I):I=t[11];let L;t[12]!==F||t[13]!==N?(L=()=>St(N,F,`realtime`),t[12]=F,t[13]=N,t[14]=L):L=t[14];let R;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(R={revalidateOnFocus:!1},t[15]=R):R=t[15];let{data:ee}=A(I,L,R),z;t[16]===ee?z=t[17]:(z=ee===void 0?[]:ee,t[16]=ee,t[17]=z);let B=z,V;t[18]!==N||t[19]!==B?(V=N===`alibaba`?B.filter(un):B,t[18]=N,t[19]=B,t[20]=V):V=t[20];let H=V,U=typeof i.stt.providers?.alibaba?.apiKey==`string`?i.stt.providers.alibaba.apiKey:``,W;t[21]!==U||t[22]!==s?(W=!!U||s.some(ln),t[21]=U,t[22]=s,t[23]=W):W=t[23];let G=W,K=O.defaultEngine===`omni`,q=K?O.omni?.voice??``:M?.voice??C?.tts?.voice??``,te;t[24]!==D?.models||t[25]!==K||t[26]!==O.omni?.model||t[27]!==O.omni?.provider||t[28]!==H?(te=K?O.omni?.provider===`xopc-cloud`?D?.models.find(e=>e.id===O.omni?.model)?.voice.voices??[]:[`Cherry`,`Ethan`,`Serena`,`Chelsie`].map(cn):H,t[24]=D?.models,t[25]=K,t[26]=O.omni?.model,t[27]=O.omni?.provider,t[28]=H,t[29]=te):te=t[29];let J=te,Y=!!(C?.enabled&&C.stt),X=!!(C?.enabled&&C.tts),ne;t[30]!==i||t[31]!==c||t[32]!==O?(ne=e=>c({...i,voice:{...i.voice,realtime:{...O,...e}}}),t[30]=i,t[31]=c,t[32]=O,t[33]=ne):ne=t[33];let re=ne,ie;t[34]!==i||t[35]!==c?(ie=e=>c(an(i,e)),t[34]=i,t[35]=c,t[36]=ie):ie=t[36];let ae=ie,oe;t[37]!==a||t[38]!==O.enabled||t[39]!==f.disabled||t[40]!==f.needsSetup||t[41]!==f.pending||t[42]!==f.unverified||t[43]!==f.verified||t[44]!==g||t[45]!==v.signature?(oe=(e,t)=>O.enabled?a?f.pending:e?t&&v.signature===g?f.verified:f.unverified:f.needsSetup:f.disabled,t[37]=a,t[38]=O.enabled,t[39]=f.disabled,t[40]=f.needsSetup,t[41]=f.pending,t[42]=f.unverified,t[43]=f.verified,t[44]=g,t[45]=v.signature,t[46]=oe):oe=t[46];let se=oe,ce;t[47]!==o||t[48]!==ae||t[49]!==p||t[50]!==w||t[51]!==i||t[52]!==U||t[53]!==G||t[54]!==c||t[55]!==a||t[56]!==k||t[57]!==O.defaultEngine||t[58]!==O.enabled||t[59]!==f.changeKey||t[60]!==f.configureConversation||t[61]!==f.customProvider||t[62]!==f.edgeHint||t[63]!==f.enable||t[64]!==f.finishSetup||t[65]!==f.hosted||t[66]!==f.hostedAccountHint||t[67]!==f.hostedHint||t[68]!==f.keyConfigured||t[69]!==f.keyHint||t[70]!==f.manageAccount||t[71]!==f.outputHint||t[72]!==f.ownKey||t[73]!==f.ownKeyHint||t[74]!==f.service||t[75]!==f.statusError||t[76]!==n||t[77]!==M||t[78]!==C?.tts||t[79]!==re||t[80]!==r.experience||t[81]!==r.stt?(ce=n===`service`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 rounded-xl bg-surface-base/45 p-3`,children:(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[(0,$.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":O.enabled,className:`size-4 accent-accent`,checked:O.enabled,onChange:e=>{e.target.checked?ae(k===`alibaba`?`alibaba`:`xopc-cloud`):re({enabled:!1})}}),f.enable]})}),w?(0,$.jsx)(`p`,{role:`alert`,className:`text-xs text-red-600 dark:text-red-400`,children:f.statusError}):null,(0,$.jsxs)(`fieldset`,{className:`space-y-3`,children:[(0,$.jsx)(`legend`,{className:`text-sm font-medium text-fg`,children:f.service}),(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[`xopc-cloud`,`alibaba`].map(e=>(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-3 rounded-lg bg-surface-base/55 px-3 py-3 text-sm text-fg has-checked:bg-accent-soft`,children:[(0,$.jsx)(`input`,{type:`radio`,name:`realtime-service`,value:e,checked:k===e,onChange:()=>ae(e),className:`mt-1 accent-accent`}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`span`,{className:`block font-medium`,children:e===`xopc-cloud`?f.hosted:f.ownKey}),(0,$.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:e===`xopc-cloud`?f.hostedHint:f.ownKeyHint})]})]},e))})]}),k!==`alibaba`&&k!==`xopc-cloud`?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:f.customProvider.replace(`{provider}`,k)}):null,k===`alibaba`?(0,$.jsx)(`div`,{className:`space-y-2 text-xs`,children:G&&!p?(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-fg-muted`,children:f.keyConfigured}),(0,$.jsx)(j,{type:`button`,variant:`ghost`,onClick:()=>m(!0),children:f.changeKey})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`label`,{htmlFor:`realtime-api-key`,className:`font-medium text-fg`,children:r.stt.apiKey}),(0,$.jsx)(At,{kind:`stt`,providerId:`alibaba`,fieldId:`realtime-api-key`,value:U,labels:{...o,maskedHelp:``},onChange:e=>c({...i,stt:{...i.stt,providers:{...i.stt.providers,alibaba:{...i.stt.providers?.alibaba,apiKey:e}}}})}),(0,$.jsx)(`p`,{className:`text-fg-muted`,children:f.keyHint})]})}):null,k===`xopc-cloud`?(0,$.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[f.hostedAccountHint,` `,(0,$.jsx)(l,{className:`text-accent hover:underline`,to:`/settings/capabilities/models`,children:f.manageAccount})]}):null,!M&&!a&&!C?.tts&&(k===`alibaba`||k===`xopc-cloud`)?(0,$.jsxs)(`div`,{className:`rounded-lg bg-surface-base p-3 text-xs`,children:[(0,$.jsx)(`p`,{className:`font-medium text-fg`,children:f.finishSetup}),(0,$.jsx)(`p`,{className:`mt-1 text-fg-muted`,children:i.tts.provider===`edge`?f.edgeHint:f.outputHint}),(0,$.jsx)(j,{className:`mt-2`,type:`button`,variant:`secondary`,onClick:()=>ae(k),children:f.configureConversation})]}):null,(0,$.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[(0,$.jsx)(`span`,{children:r.experience.defaultMode}),(0,$.jsxs)(u,{value:O.defaultEngine,className:we,onChange:e=>re({defaultEngine:e.target.value}),children:[(0,$.jsx)(d,{value:`agent`,children:r.experience.assistant}),(0,$.jsx)(d,{value:`omni`,children:r.experience.natural})]})]}),(0,$.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[O.defaultEngine===`agent`?r.experience.assistantHint:r.experience.naturalHint,` `,r.experience.nextCall]})]}):null,t[47]=o,t[48]=ae,t[49]=p,t[50]=w,t[51]=i,t[52]=U,t[53]=G,t[54]=c,t[55]=a,t[56]=k,t[57]=O.defaultEngine,t[58]=O.enabled,t[59]=f.changeKey,t[60]=f.configureConversation,t[61]=f.customProvider,t[62]=f.edgeHint,t[63]=f.enable,t[64]=f.finishSetup,t[65]=f.hosted,t[66]=f.hostedAccountHint,t[67]=f.hostedHint,t[68]=f.keyConfigured,t[69]=f.keyHint,t[70]=f.manageAccount,t[71]=f.outputHint,t[72]=f.ownKey,t[73]=f.ownKeyHint,t[74]=f.service,t[75]=f.statusError,t[76]=n,t[77]=M,t[78]=C?.tts,t[79]=re,t[80]=r.experience,t[81]=r.stt,t[82]=ce):ce=t[82];let le;t[83]!==q||t[84]!==K||t[85]!==N||t[86]!==O.bargeIn||t[87]!==O.omni||t[88]!==O.tts||t[89]!==f.bargeIn||t[90]!==f.defaultVoice||t[91]!==f.voice||t[92]!==n||t[93]!==M||t[94]!==C?.tts||t[95]!==re||t[96]!==r.realtime||t[97]!==J?(le=n===`listening`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,$.jsx)(`label`,{htmlFor:`realtime-voice`,className:`text-sm font-medium text-fg`,children:f.voice}),(0,$.jsxs)(u,{id:`realtime-voice`,className:`${we} w-full sm:w-56`,value:q,disabled:K?!O.omni:!M&&!C?.tts,onChange:e=>{if(K&&O.omni){re({omni:{...O.omni,voice:e.target.value}});return}(N===`alibaba`||N===`xopc-cloud`)&&re({tts:{...O.tts,provider:N,...e.target.value?{voice:e.target.value}:{}},...O.omni&&[`Cherry`,`Ethan`,`Serena`,`Chelsie`].includes(e.target.value)?{omni:{...O.omni,voice:e.target.value}}:{}})},children:[K?null:(0,$.jsx)(d,{value:``,children:f.defaultVoice}),q&&!J.some(e=>e.id===q)?(0,$.jsx)(d,{value:q,children:q}):null,J.map(sn)]})]}),(0,$.jsxs)(`label`,{className:`flex items-center justify-between gap-4 text-sm text-fg`,children:[(0,$.jsxs)(`span`,{children:[f.bargeIn,(0,$.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:r.realtime.bargeInDescription})]}),(0,$.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":O.bargeIn,checked:O.bargeIn,className:`size-4 accent-accent`,onChange:e=>re({bargeIn:e.target.checked})})]})]}):null,t[83]=q,t[84]=K,t[85]=N,t[86]=O.bargeIn,t[87]=O.omni,t[88]=O.tts,t[89]=f.bargeIn,t[90]=f.defaultVoice,t[91]=f.voice,t[92]=n,t[93]=M,t[94]=C?.tts,t[95]=re,t[96]=r.realtime,t[97]=J,t[98]=le):le=t[98];let ue;t[99]!==Y||t[100]!==X||t[101]!==w||t[102]!==T||t[103]!==a||t[104]!==n||t[105]!==g||t[106]!==C||t[107]!==se||t[108]!==r||t[109]!==v.input||t[110]!==v.output?(ue=n===`diagnostics`?(0,$.jsxs)($.Fragment,{children:[T?(0,$.jsx)(P,{className:`h-16 w-full`}):(0,$.jsxs)(`div`,{className:`space-y-2 text-sm`,role:`status`,children:[(0,$.jsxs)(`p`,{children:[r.experience.dictationReady,` · `,se(Y,v.input)]}),(0,$.jsxs)(`p`,{children:[r.experience.agentReady,` · `,se(Y&&X,v.input&&v.output)]}),(0,$.jsxs)(`p`,{children:[r.experience.omniReady,` · `,se(!!(C?.enabled&&C.omni),!1)]})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:r.experience.configurationOnly}),(0,$.jsx)(rn,{v:r,canListen:Y,canSpeak:X,disabled:a||T||!!w,onVerified:e=>y({signature:g,...e})},`${g}:${JSON.stringify(C)}`)]}):null,t[99]=Y,t[100]=X,t[101]=w,t[102]=T,t[103]=a,t[104]=n,t[105]=g,t[106]=C,t[107]=se,t[108]=r,t[109]=v.input,t[110]=v.output,t[111]=ue):ue=t[111];let de;return t[112]!==f.service||t[113]!==ce||t[114]!==le||t[115]!==ue?(de=(0,$.jsxs)(`section`,{className:`space-y-5 rounded-xl bg-surface-hover/20 p-4 sm:p-5`,"aria-label":f.service,children:[ce,le,ue]}),t[112]=f.service,t[113]=ce,t[114]=le,t[115]=ue,t[116]=de):de=t[116],de}function sn(e){return(0,$.jsx)(d,{value:e.id,children:e.name},e.id)}function cn(e){return{id:e,name:e}}function ln(e){return e.id===`alibaba`&&e.configured}function un(e){return[`Cherry`,`Ethan`,`Serena`,`Chelsie`].includes(e.id)}async function dn(e){return Je.parse((await _(e)).payload)}function fn(e){let t=(0,Rt.c)(22),{value:n,onChange:r}=e,i=b(mn)===`zh`,a;t[0]===i?a=t[1]:(a=(e,t)=>i?t:e,t[0]=i,t[1]=a);let o=a,s;t[2]!==r||t[3]!==n?(s=e=>{n&&r({...n,...e})},t[2]=r,t[3]=n,t[4]=s):s=t[4];let c=s,l;t[5]===o?l=t[6]:(l=o(`Natural conversation · advanced`,`自然对话 · 高级设置`),t[5]=o,t[6]=l);let f;t[7]===l?f=t[8]:(f=(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:l}),t[7]=l,t[8]=f);let p;t[9]===o?p=t[10]:(p=o(`Calls continue the same session using recent history. Service and credentials are shared with voice setup; override them here only when needed.`,`通话会接续同一会话的近期历史。默认共用语音服务与凭据,仅在需要独立配置时修改。`),t[9]=o,t[10]=p);let m;t[11]===p?m=t[12]:(m=(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:p}),t[11]=p,t[12]=m);let h;t[13]!==o||t[14]!==r||t[15]!==c||t[16]!==n?(h=n?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`label`,{className:`block space-y-1 text-sm`,children:[(0,$.jsx)(`span`,{children:o(`Connection`,`连接方式`)}),(0,$.jsx)(u,{value:n.provider,onChange:e=>r({model:n.model,voice:n.voice,instructions:n.instructions,provider:e.target.value}),children:(0,$.jsxs)(d,{value:`alibaba`,children:[`DashScope · `,o(`Your API key`,`自有 API Key`)]})})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.provider===`xopc-cloud`?o(`Uses your XOPC sign-in and the platform’s published Omni route and credits.`,`使用 XOPC 登录授权、平台发布的 Omni 路由和额度。`):o(`Leave empty to use the shared voice service credential.`,`留空使用语音服务中已配置的凭据。`)}),(0,$.jsx)(`p`,{className:`font-mono text-xs text-fg-muted`,children:n.model}),n.provider===`alibaba`?(0,$.jsxs)(`label`,{className:`block space-y-1 text-sm`,children:[(0,$.jsx)(`span`,{children:`API Key`}),(0,$.jsx)(`input`,{className:`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,type:`password`,autoComplete:`new-password`,value:n.apiKey??``,onChange:e=>c({apiKey:e.target.value})})]}):null,(0,$.jsxs)(`label`,{className:`block space-y-1 text-sm`,children:[(0,$.jsx)(`span`,{children:o(`Endpoint override (optional)`,`自定义服务地址(可选)`)}),(0,$.jsx)(`input`,{className:`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,value:n.baseUrl??``,placeholder:n.provider===`alibaba`?`wss://dashscope.aliyuncs.com/api-ws/v1/realtime`:`https://router.xopc.ai/v1`,onChange:e=>c({baseUrl:e.target.value.trim()||void 0})})]}),(0,$.jsxs)(`label`,{className:`block space-y-1 text-sm`,children:[(0,$.jsx)(`span`,{children:o(`Voice`,`音色`)}),(0,$.jsx)(u,{value:n.voice,onChange:e=>c({voice:e.target.value}),children:[`Cherry`,`Ethan`,`Serena`,`Chelsie`].map(pn)})]}),(0,$.jsxs)(`label`,{className:`block space-y-1 text-sm`,children:[(0,$.jsx)(`span`,{children:o(`Conversation instructions`,`聊天指令`)}),(0,$.jsx)(`textarea`,{className:`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,rows:3,maxLength:8e3,value:n.instructions,onChange:e=>c({instructions:e.target.value})})]})]}):(0,$.jsx)(j,{variant:`secondary`,onClick:()=>r({provider:`alibaba`,model:`qwen3-omni-flash-realtime`,voice:`Cherry`,instructions:`You are a friendly voice companion. You cannot execute tools.`}),children:o(`Configure natural conversation`,`配置自然聊天`)}),t[13]=o,t[14]=r,t[15]=c,t[16]=n,t[17]=h):h=t[17];let g;return t[18]!==f||t[19]!==m||t[20]!==h?(g=(0,$.jsxs)(`details`,{className:`space-y-3 rounded-xl bg-surface-hover/20 p-4`,children:[f,m,h]}),t[18]=f,t[19]=m,t[20]=h,t[21]=g):g=t[21],g}function pn(e){return(0,$.jsx)(d,{value:e,children:e},e)}function mn(e){return e.language}var hn=Te;function gn(){return g(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,Ee,`dark:border-edge`)}function _n(){return g(we,Te)}function vn(e){return!e||e<=0?``:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function yn(e,t){let n=window.atob(e),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return URL.createObjectURL(new Blob([r],{type:t}))}function bn(e,t){switch(e){case`xopc-local`:return t.stt.localProvider;case`openai`:return t.stt.openai;case`alibaba`:return t.stt.alibaba;case`groq`:return`Groq`;default:return e}}function xn(e,t){switch(e){case`openai`:return t.tts.providerOpenai;case`alibaba`:return t.stt.alibaba;case`edge`:return t.tts.providerEdge;case`tts-local-cli`:return t.tts.providerLocalCli;case`minimax`:return`MiniMax`;default:return e}}function Sn(e,t){switch(e){case`off`:return t.tts.triggerOff;case`always`:return t.tts.triggerAlways;case`inbound`:return t.tts.triggerInbound;case`tagged`:return t.tts.triggerTagged}}function Cn(e,t){switch(e){case`edge`:return t.tts.providerHints.edge;case`openai`:return t.tts.providerHints.openai;case`alibaba`:return t.tts.providerHints.alibaba;case`minimax`:return t.tts.providerHints.minimax;case`tts-local-cli`:return t.tts.providerHints.localCli;default:return t.tts.providerHints.generic}}function wn(e){return{maskedHelp:e.apiKeyMaskedHelp,copy:e.apiKeyCopy,copied:e.apiKeyCopied,show:e.apiKeyShow,hide:e.apiKeyHide,notInConfigFile:e.apiKeyNotInConfigFile,loadFailed:e.apiKeyRevealFailed}}function Tn(e,t){let n=e[t.key];return typeof n==`string`||typeof n==`number`||typeof n==`boolean`?n:t.defaultValue===void 0?t.type===`boolean`?!1:``:t.defaultValue}function En(e,t){if(e.type===`boolean`)return!!t;if(e.type!==`number`)return t;let n=String(t).trim();if(!n)return;let r=Number(n);return Number.isFinite(r)?r:void 0}function Dn(e,t){switch(t.type){case`reset`:return{form:null,baseline:null};case`sync`:{let e=structuredClone(t.value);return{form:e,baseline:structuredClone(e)}}case`update`:return{...e,form:t.updater(e.form)};case`saved`:{let n=structuredClone(t.value);return{form:e.form!==null&&JSON.stringify(e.form)!==JSON.stringify(t.value)?e.form:n,baseline:structuredClone(n)}}}}function On(){let e=b(e=>e.language),t=S(e).voiceSettings,[n,r]=(0,Q.useState)(`listening`),i=ge(),a=He(e=>e.captions),o=He(e=>e.setCaptions),s=!!v(e=>e.conversationId);(0,Q.useEffect)(()=>{!i&&n===`diagnostics`&&r(`listening`)},[n,i]);let[c,l]=(0,Q.useReducer)(Dn,{form:null,baseline:null}),f=c.form,p=c.baseline,[m,h]=(0,Q.useState)(null),g=(0,Q.useRef)(!1),_=(0,Q.useRef)(f);_.current=f;let y=(0,Q.useRef)({parsed:null,models:void 0}),{data:C,error:w,isLoading:T,mutate:E}=N(s),{data:D,error:O,isLoading:k,mutate:M}=A(s?x(`/api/voice/models`):null,_t,{revalidateOnFocus:!1}),{data:P,error:F,isLoading:I}=A(s?x(`/api/voice/providers`):null,Tt,{revalidateOnFocus:!1}),{data:L,error:R,isLoading:ee}=A(s?x(`/api/voice/stt-providers`):null,vt,{revalidateOnFocus:!1}),z=(0,Q.useMemo)(()=>P?.providers??[],[P]),B=(0,Q.useMemo)(()=>L?.providers??[],[L]),V=(0,Q.useMemo)(()=>C?.payload?.config===void 0?null:kt(C.payload.config),[C]),H=(0,Q.useMemo)(()=>!f||!p?!1:JSON.stringify(f)!==JSON.stringify(p),[f,p]);s?V!==null&&D!==void 0&&!g.current&&(y.current.parsed!==V||y.current.models!==D)&&(y.current={parsed:V,models:D},l({type:`sync`,value:V}),h(D)):(y.current.parsed!==null||y.current.models!==void 0)&&(y.current={parsed:null,models:void 0},l({type:`reset`}),h(null),g.current=!1);let U=!!(s&&(V===null||D===void 0||P===void 0||L===void 0)&&(T||k||I||ee)),W=w instanceof Error?w.message:w?String(w):O instanceof Error?O.message:O?String(O):F instanceof Error?F.message:F?String(F):R instanceof Error?R.message:R?String(R):null,G=(0,Q.useCallback)(e=>{g.current=!0,l({type:`update`,updater:t=>t?{...t,stt:{...t.stt,...e}}:null})},[]),K=(0,Q.useCallback)(e=>{g.current=!0,l({type:`update`,updater:t=>{if(!t)return null;let n=t.stt.fallback??{enabled:!1,order:[`xopc-local`]};return{...t,stt:{...t.stt,fallback:{...n,...e}}}}})},[]),q=(0,Q.useCallback)(e=>{g.current=!0,l({type:`update`,updater:t=>t?{...t,voice:{...t.voice,input:{...t.voice.input,refinement:{...t.voice.input.refinement,...e}}}}:null})},[]),te=(0,Q.useCallback)(t=>{g.current=!0,l({type:`update`,updater:n=>n?{...n,voice:{...n.voice,languageMode:t,...t===`auto`?{language:e}:{}}}:null})},[e]),J=(0,Q.useCallback)(e=>{g.current=!0,l({type:`update`,updater:t=>t?{...t,voice:{...t.voice,realtime:{...t.voice.realtime,...e}}}:null})},[]),Y=(0,Q.useCallback)(e=>{g.current=!0,l({type:`update`,updater:t=>t?{...t,tts:{...t.tts,...e}}:null})},[]),X=gt({value:f,dirty:H,onSave:(0,Q.useCallback)(async e=>{let n=p?.stt.provider!==`xopc-local`&&e.stt.provider===`xopc-local`;try{await yt(e),n&&window.dispatchEvent(new Event(Ot)),l({type:`saved`,value:e}),g.current=!!(_.current&&JSON.stringify(_.current)!==JSON.stringify(e))}catch(e){throw Error(e instanceof Error?e.message:t.saveError)}},[p?.stt.provider,t.saveError])}),ne=(0,Q.useCallback)(e=>{g.current=!0,l({type:`update`,updater:()=>e})},[]);if(!s)return(0,$.jsx)(`div`,{className:`flex flex-col gap-3`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.needToken})});if(U)return(0,$.jsx)(mt,{rows:4});if(!f||m===null)return(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:W??t.loadError}),(0,$.jsx)(j,{type:`button`,variant:`secondary`,onClick:()=>{E(),M()},children:t.retry})]});let re=f.stt,ie=f.tts,ae=f.voice.input.refinement,oe=wn(t);return(0,$.jsxs)(`div`,{className:`flex w-full flex-col gap-4`,onBlurCapture:X.onBlurCapture,children:[(0,$.jsx)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:(0,$.jsx)(ht,{status:X.status,error:X.error})}),X.error?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:X.error}):null,(0,$.jsx)(`nav`,{"aria-label":t.setup.advanced,className:`flex flex-wrap gap-2`,children:[`listening`,`input`,`devices`,`service`,...i?[`diagnostics`]:[]].map(e=>(0,$.jsx)(j,{variant:n===e?`secondary`:`ghost`,"aria-pressed":n===e,onClick:()=>r(e),children:t.experience[e]},e))}),n===`listening`||n===`service`||n===`diagnostics`?(0,$.jsx)(on,{section:n,v:t,form:f,pending:H||X.status===`saving`||!!X.error,apiKeyLabels:oe,sttProviders:B,onChange:ne}):null,n===`listening`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(kn,{v:t,voice:f.voice,updateLanguageMode:te}),(0,$.jsx)(`section`,{className:`rounded-xl bg-surface-hover/20 px-4 py-5 sm:px-5`,children:(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-[minmax(0,1fr)_minmax(12rem,18rem)] sm:items-center`,children:[(0,$.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:t.experience.pace}),(0,$.jsxs)(u,{className:_n(),value:String(f.voice.realtime.silenceDurationMs),onChange:e=>J({silenceDurationMs:Number(e.target.value)}),children:[(0,$.jsx)(d,{value:`800`,children:t.experience.fast}),(0,$.jsx)(d,{value:`1200`,children:t.experience.standard}),(0,$.jsx)(d,{value:`2000`,children:t.experience.relaxed}),[800,1200,2e3].includes(f.voice.realtime.silenceDurationMs)?null:(0,$.jsxs)(d,{value:String(f.voice.realtime.silenceDurationMs),children:[f.voice.realtime.silenceDurationMs,` ms`]})]})]})})]}):null,n===`input`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`label`,{className:`flex items-center justify-between text-sm`,children:[t.experience.captions,(0,$.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":a,className:`ui-checkbox`,checked:a,onChange:e=>o(e.target.checked)})]}),(0,$.jsxs)(`label`,{className:`space-y-2 text-sm`,children:[(0,$.jsx)(`span`,{children:t.stt.refinement}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.stt.refinementDesc}),(0,$.jsxs)(u,{className:_n(),value:ae.mode,onChange:e=>q({mode:e.target.value}),children:[(0,$.jsx)(d,{value:`off`,children:t.stt.refinementOff}),(0,$.jsx)(d,{value:`punctuation`,children:t.stt.refinementPunctuation}),(0,$.jsx)(d,{value:`light`,children:t.stt.refinementLight}),ae.mode===`custom`?(0,$.jsx)(d,{value:`custom`,children:t.setup.advanced}):null]})]}),(0,$.jsxs)(`details`,{className:`rounded-xl bg-surface-base/55 px-4 py-3`,children:[(0,$.jsxs)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:[t.setup.readout,` · `,ie.enabled?Sn(ie.trigger,t):t.overview.off]}),(0,$.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:t.setup.readoutHint}),(0,$.jsx)(Pn,{v:t,apiKeyLabels:oe,tts:ie,models:m,ttsProviders:z,updateTts:Y})]})]}):null,n===`devices`?(0,$.jsx)(nn,{v:t}):null,n===`service`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(tn,{disabled:H||X.status===`saving`}),f.voice.realtime.enabled&&f.voice.realtime.omni?.provider===`alibaba`?(0,$.jsx)(fn,{value:f.voice.realtime.omni,onChange:e=>J({omni:e})}):null,(0,$.jsxs)(`details`,{className:`rounded-xl bg-surface-base/55 px-4 py-3`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:t.experience.technical}),(0,$.jsx)(An,{v:t,apiKeyLabels:oe,stt:re,models:m,sttProviders:B,updateStt:G,updateSttFallback:K}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.notes.envVars})]})]}):null]})}function kn(e){let t=(0,Rt.c)(22),{v:n,voice:r,updateLanguageMode:i}=e,a;t[0]===n.language.title?a=t[1]:(a=(0,$.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:n.language.title}),t[0]=n.language.title,t[1]=a);let o=r.languageMode===`auto`?n.language.autoDescription:n.language.manualDescription,s;t[2]===o?s=t[3]:(s=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:o}),t[2]=o,t[3]=s);let c;t[4]!==a||t[5]!==s?(c=(0,$.jsxs)(`div`,{children:[a,s]}),t[4]=a,t[5]=s,t[6]=c):c=t[6];let l;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(l=_n(),t[7]=l):l=t[7];let f;t[8]===i?f=t[9]:(f=e=>i(e.target.value),t[8]=i,t[9]=f);let p;t[10]===n.language.auto?p=t[11]:(p=(0,$.jsx)(d,{value:`auto`,children:n.language.auto}),t[10]=n.language.auto,t[11]=p);let m;t[12]===n.language.manual?m=t[13]:(m=(0,$.jsx)(d,{value:`manual`,children:n.language.manual}),t[12]=n.language.manual,t[13]=m);let h;t[14]!==f||t[15]!==p||t[16]!==m||t[17]!==r.languageMode?(h=(0,$.jsxs)(u,{className:l,value:r.languageMode,onChange:f,children:[p,m]}),t[14]=f,t[15]=p,t[16]=m,t[17]=r.languageMode,t[18]=h):h=t[18];let g;return t[19]!==c||t[20]!==h?(g=(0,$.jsx)(`section`,{className:`rounded-xl bg-surface-hover/20 px-4 py-5 sm:px-5`,children:(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-[minmax(0,1fr)_minmax(12rem,18rem)] sm:items-center`,children:[c,h]})}),t[19]=c,t[20]=h,t[21]=g):g=t[21],g}function An(e){let t=(0,Rt.c)(58),{v:n,apiKeyLabels:r,stt:i,models:a,sttProviders:o,updateStt:s,updateSttFallback:c}=e,l;if(t[0]!==o){let e=new Set;l=[];for(let t of o)e.has(t.id)||(e.add(t.id),l.push(t));t[0]=o,t[1]=l}else l=t[1];let f=l,p,m,h,_;if(t[2]!==a||t[3]!==f||t[4]!==i.provider||t[5]!==i.providers){p=f.find(e=>e.id===i.provider);let e;t[10]!==i.provider||t[11]!==i.providers?(e=i.providers?.[i.provider]??{},t[10]=i.provider,t[11]=i.providers,t[12]=e):e=t[12],h=e,m=a?.stt?.[i.provider]?.length?a.stt[i.provider]:p?.models??[],_=p?.fields.find(jn),t[2]=a,t[3]=f,t[4]=i.provider,t[5]=i.providers,t[6]=p,t[7]=m,t[8]=h,t[9]=_}else p=t[6],m=t[7],h=t[8],_=t[9];let v=_,y=typeof h.model==`string`?h.model:void 0,b=y??(typeof v?.defaultValue==`string`?v.defaultValue:m[0]?.id),x;t[13]!==i.provider||t[14]!==i.providers||t[15]!==s?(x=e=>{s({providers:{...i.providers??{},[i.provider]:{...i.providers?.[i.provider]??{},...e}}})},t[13]=i.provider,t[14]=i.providers,t[15]=s,t[16]=x):x=t[16];let S=x,C,w;t[17]!==y||t[18]!==b||t[19]!==v||t[20]!==S?(C=()=>{v&&b&&y!==b&&S({model:b})},w=[y,b,v,S],t[17]=y,t[18]=b,t[19]=v,t[20]=S,t[21]=C,t[22]=w):(C=t[21],w=t[22]),(0,Q.useEffect)(C,w);let T;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(Re,{className:`size-4 text-accent`,strokeWidth:1.75}),t[23]=T):T=t[23];let E;t[24]===n.stt.title?E=t[25]:(E=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[T,n.stt.title]}),t[24]=n.stt.title,t[25]=E);let D;t[26]===n.stt.description?D=t[27]:(D=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.stt.description}),t[26]=n.stt.description,t[27]=D);let O;t[28]!==E||t[29]!==D?(O=(0,$.jsxs)(`div`,{className:`mb-4`,children:[E,D]}),t[28]=E,t[29]=D,t[30]=O):O=t[30];let k;t[31]===s?k=t[32]:(k=e=>s({enabled:e}),t[31]=s,t[32]=k);let A;t[33]!==i.enabled||t[34]!==k||t[35]!==n.stt.enable||t[36]!==n.stt.enableDesc?(A=(0,$.jsx)(In,{checked:i.enabled,title:n.stt.enable,description:n.stt.enableDesc,onChange:k}),t[33]=i.enabled,t[34]=k,t[35]=n.stt.enable,t[36]=n.stt.enableDesc,t[37]=A):A=t[37];let j;t[38]!==p?.fields||t[39]!==r||t[40]!==b||t[41]!==m||t[42]!==f||t[43]!==h||t[44]!==i.enabled||t[45]!==i.fallback?.enabled||t[46]!==i.provider||t[47]!==S||t[48]!==s||t[49]!==c||t[50]!==n?(j=i.enabled?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{className:g(`flex flex-col gap-1.5`,hn),children:[(0,$.jsx)(zn,{children:n.stt.provider}),(0,$.jsx)(u,{className:_n(),value:i.provider,onChange:e=>s({provider:e.target.value}),children:f.map(e=>(0,$.jsxs)(d,{value:e.id,children:[bn(e.id,n),e.configured?``:` *`]},e.id))})]}),(0,$.jsx)(Fn,{kind:`stt`,providerId:i.provider,fields:p?.fields??[],providerSlice:h,models:m,currentModel:b,apiKeyLabels:r,onPatch:S})]}),i.provider===`xopc-local`?(0,$.jsx)(Nn,{v:n}):null,(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.stt.fallback}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.stt.fallbackDesc})]}),(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:i.fallback?.enabled??!1,onChange:e=>c({enabled:e.target.checked})})]})]}):null,t[38]=p?.fields,t[39]=r,t[40]=b,t[41]=m,t[42]=f,t[43]=h,t[44]=i.enabled,t[45]=i.fallback?.enabled,t[46]=i.provider,t[47]=S,t[48]=s,t[49]=c,t[50]=n,t[51]=j):j=t[51];let M;t[52]!==A||t[53]!==j?(M=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[A,j]}),t[52]=A,t[53]=j,t[54]=M):M=t[54];let N;return t[55]!==M||t[56]!==O?(N=(0,$.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 px-4 py-5 sm:px-5`,children:[O,M]}),t[55]=M,t[56]=O,t[57]=N):N=t[57],N}function jn(e){return e.key===`model`}function Mn(e){return`${Math.round(e/1024/1024)} MB`}function Nn({v:e}){let{data:t,error:n,mutate:r}=A(x(`/api/voice/local/status`),wt,{revalidateOnFocus:!1,refreshInterval:e=>e?.models.some(e=>e.state===`downloading`)?1e3:0}),[i,a]=(0,Q.useState)(null),[o,s]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{let e=()=>void r();return window.addEventListener(Ot,e),()=>window.removeEventListener(Ot,e)},[r]);let c=(0,Q.useCallback)(async(e,t)=>{a(e.id),s(null);try{t===`install`?await Ct(e.id):await Et(e.id),await r()}catch(e){s(e instanceof Error?e.message:String(e))}finally{a(null)}},[r]);return(0,$.jsxs)(`div`,{className:`rounded-xl bg-surface-base/55 p-3`,children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.stt.localModels}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.stt.localModelsDesc}),n?(0,$.jsx)(`p`,{className:`mt-3 text-xs text-red-600 dark:text-red-400`,children:String(n)}):null,t?.runtime.ready===!1?(0,$.jsx)(`p`,{className:`mt-3 text-xs text-red-600 dark:text-red-400`,children:t.runtime.error??`Local voice runtime is unavailable`}):null,t?.decoder?.available===!1?(0,$.jsx)(`p`,{className:`mt-3 text-xs text-amber-700 dark:text-amber-300`,children:t.decoder.error??`Compressed audio decoding is unavailable`}):null,o?(0,$.jsx)(`p`,{className:`mt-3 text-xs text-red-600 dark:text-red-400`,children:o}):null,(0,$.jsx)(`div`,{className:`mt-3 grid gap-2`,children:(t?.models??[]).map(t=>{let n=i===t.id||t.state===`downloading`;return(0,$.jsxs)(`div`,{className:g(`flex items-center justify-between gap-3 rounded-lg bg-surface-base px-3 py-2.5`,t.recommended?`ring-1 ring-accent/40`:``),children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-sm font-medium text-fg`,children:[t.name,t.recommended?(0,$.jsx)(`span`,{className:`rounded-full bg-accent/10 px-2 py-0.5 text-[10px] font-medium text-accent`,children:e.stt.localRecommended}):null]}),(0,$.jsxs)(`div`,{className:`text-xs text-fg-muted`,children:[Mn(t.approximateBytes),` · `,t.description]}),(0,$.jsxs)(`div`,{className:`mt-0.5 text-[11px] text-fg-subtle`,children:[t.engine,` · `,t.languages.join(` / `)]}),t.state===`downloading`?(0,$.jsxs)(`div`,{className:`mt-1 text-xs text-accent`,children:[e.stt.localDownloading,` `,Math.round((t.progress??0)*100),`%`]}):t.state===`error`?(0,$.jsx)(`div`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:t.error}):null]}),(0,$.jsx)(j,{type:`button`,variant:`secondary`,disabled:n,onClick:()=>void c(t,t.state===`ready`?`remove`:`install`),children:n?(0,$.jsx)(fe,{className:`size-4 animate-spin`}):t.state===`ready`?e.stt.localRemove:e.stt.localInstall})]},t.id)})})]})}function Pn({v:e,apiKeyLabels:t,tts:n,models:r,ttsProviders:i,updateTts:a}){let[o,s]=(0,Q.useState)(e.tts.test.sampleText),[c,l]=(0,Q.useState)({status:`idle`}),f=(0,Q.useRef)(null),p=(0,Q.useRef)(null),m=(0,Q.useRef)(null),h=(0,Q.useCallback)(()=>{m.current?.abort(),m.current=null,f.current?.pause(),f.current=null,p.current&&=(URL.revokeObjectURL(p.current),null)},[]),_=(0,Q.useMemo)(()=>{let e=new Set,t=[];for(let n of i)e.has(n.id)||(e.add(n.id),t.push(n));return t},[i]),v=_.find(e=>e.id===n.provider),y=n.providers?.[n.provider]??{},b=r?.tts?.[n.provider]?.length?r.tts[n.provider]:v?.models??[],x=v?.fields.find(e=>e.key===`model`),S=v?.fields.find(e=>e.key===`voice`),C=typeof y.model==`string`?y.model:void 0,w=C??(typeof x?.defaultValue==`string`?x.defaultValue:b[0]?.id),T=b.find(e=>e.id===w),E=r?.ttsVoices?.[n.provider]?.length?r.ttsVoices[n.provider]:v?.voices??[],{data:D=[]}=A(w?`voice:tts:${n.provider}:${w}`:null,()=>St(n.provider,w??``),{revalidateOnFocus:!1}),O=D.length>0?D:E,k=typeof y.voice==`string`?y.voice:void 0,M=k??O.find(e=>e.id===T?.tts?.defaultVoice)?.id??(typeof S?.defaultValue==`string`?S.defaultValue:O[0]?.id),N=(v?.fields??[]).filter(e=>(e.key!==`speed`||T?.tts?.speed!==!1)&&(e.key!==`instructions`||T?.tts?.instructions!==!1)),P=!!v?.diagnostics.requiresApiKey,F=!!v?.configured||!P,I=(0,Q.useCallback)(e=>{a({providers:{...n.providers??{},[n.provider]:{...n.providers?.[n.provider]??{},...e}}})},[n.provider,n.providers,a]);(0,Q.useEffect)(()=>{let e={};x&&w&&C!==w&&(e.model=w),S&&M&&k!==M&&(e.voice=M),Object.keys(e).length>0&&I(e)},[C,k,w,M,x,I,S]),(0,Q.useEffect)(()=>()=>h(),[h]);let L=(0,Q.useCallback)(e=>{a({provider:e}),l({status:`idle`})},[a]),R=(0,Q.useCallback)(async()=>{let t=o.trim();if(!t){l({status:`error`,message:e.tts.test.emptyText});return}h();let r=new AbortController;m.current=r,l({status:`loading`});try{let i=await xt({text:t,provider:n.provider,providerConfig:y,...w?{model:w}:{},...M?{voice:M}:{}},r.signal);if(r.signal.aborted)return;let a=yn(i.audio,i.mimeType);p.current=a;let o=new Audio(a);f.current=o;let s=[i.provider,i.format,i.latencyMs===void 0?void 0:`${i.latencyMs}ms`,vn(i.audioSize)].filter(Boolean).join(` · `);o.addEventListener(`ended`,()=>l({status:`done`,summary:s}),{once:!0}),o.addEventListener(`error`,()=>l({status:`error`,message:e.tts.test.playFailed}),{once:!0}),await o.play(),l({status:`playing`,summary:s})}catch(e){if(r.signal.aborted)return;h(),l({status:`error`,message:e instanceof Error?e.message:String(e)})}},[w,M,y,h,o,n.provider,e.tts.test.emptyText,e.tts.test.playFailed]);return(0,$.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 px-4 py-5 sm:px-5`,children:[(0,$.jsxs)(`div`,{className:`mb-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,$.jsx)(tt,{className:`size-4 text-accent`,strokeWidth:1.75}),e.tts.title]}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.tts.description})]}),(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(In,{checked:n.enabled,title:e.tts.enable,description:e.tts.enableDesc,onChange:e=>a({enabled:e})}),n.enabled?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{className:g(`flex flex-col gap-1.5`,hn),children:[(0,$.jsx)(zn,{children:e.tts.trigger}),(0,$.jsxs)(u,{className:_n(),value:n.trigger,onChange:e=>a({trigger:e.target.value}),children:[(0,$.jsx)(d,{value:`off`,children:e.tts.triggerOff}),(0,$.jsx)(d,{value:`inbound`,children:e.tts.triggerInbound}),(0,$.jsx)(d,{value:`tagged`,children:e.tts.triggerTagged}),(0,$.jsx)(d,{value:`always`,children:e.tts.triggerAlways})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.triggerHelp})]}),(0,$.jsxs)(`div`,{className:g(`flex flex-col gap-1.5`,hn),children:[(0,$.jsx)(zn,{children:e.tts.provider}),(0,$.jsx)(u,{className:_n(),value:n.provider,onChange:e=>L(e.target.value),children:_.map(t=>(0,$.jsx)(d,{value:t.id,children:xn(t.id,e)},t.id))}),(0,$.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[v?.configured?e.tts.configured:v?.diagnostics.requiresApiKey?`${e.tts.needsKey} · ${v.diagnostics.envKeys?.join(`, `)??e.stt.apiKey}`:e.tts.noKeyNeeded,` · `,v?.description??Cn(n.provider,e)]})]})]}),(0,$.jsxs)(`details`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,open:!F||n.provider===`tts-local-cli`,children:[(0,$.jsxs)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg marker:text-fg-muted`,children:[e.tts.advanced.title,(0,$.jsx)(`span`,{className:`ml-2 text-xs font-normal text-fg-muted`,children:e.tts.advanced.description})]}),(0,$.jsx)(`div`,{className:`mt-3`,children:(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:(0,$.jsx)(Fn,{kind:`tts`,providerId:n.provider,fields:N,providerSlice:y,models:b,voices:O,currentModel:w,currentVoice:M,apiKeyLabels:t,onPatch:I,resetVoiceOnModelChange:!0})})})]}),(0,$.jsxs)(`div`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.tts.test.title}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.tts.test.description})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,$.jsxs)(j,{type:`button`,variant:`primary`,onClick:()=>void R(),disabled:c.status===`loading`,className:`h-9`,children:[c.status===`loading`?(0,$.jsx)(fe,{className:`size-4 animate-spin`}):(0,$.jsx)($e,{className:`size-4`}),c.status===`loading`?e.tts.test.generating:e.tts.test.play]}),(0,$.jsxs)(j,{type:`button`,variant:`secondary`,onClick:()=>{h(),l(e=>e.status===`playing`?{status:`done`,summary:e.summary}:{status:`idle`})},disabled:c.status!==`playing`,className:`h-9`,children:[(0,$.jsx)(Y,{className:`size-4`}),e.tts.test.stop]})]})]}),(0,$.jsxs)(`details`,{className:`mt-3`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-xs text-fg-muted`,children:e.setup.sampleText}),(0,$.jsx)(`textarea`,{className:g(gn(),`mt-3 min-h-20 resize-y`),value:o,onChange:e=>s(e.target.value),maxLength:1e3})]}),(0,$.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center justify-between gap-2 text-xs`,children:[(0,$.jsxs)(`span`,{className:`text-fg-subtle`,children:[o.length,`/1000`]}),c.status===`playing`||c.status===`done`?(0,$.jsxs)(`span`,{className:`text-emerald-700 dark:text-emerald-200`,children:[c.status===`playing`?e.tts.test.playing:e.tts.test.ready,` · `,c.summary]}):null,c.status===`error`?(0,$.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:c.message}):null]})]})]}):null]})]})}function Fn({kind:e,providerId:t,fields:n,providerSlice:r,models:i,voices:a=[],currentModel:o,currentVoice:s,apiKeyLabels:c,onPatch:l,resetVoiceOnModelChange:f=!1}){return n.map(n=>n.key===`apiKey`?(0,$.jsxs)(`div`,{className:g(`flex flex-col gap-1.5`,hn),children:[(0,$.jsx)(zn,{children:n.label}),(0,$.jsx)(At,{kind:e,providerId:t,fieldId:`voice-${e}-${t}-api-key`,value:typeof r.apiKey==`string`?r.apiKey:``,onChange:e=>l({apiKey:e}),labels:c,placeholder:n.placeholder}),n.description?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:n.description}):null]},n.key):n.key===`model`&&i.length>0?(0,$.jsxs)(`div`,{className:g(`flex flex-col gap-1.5`,hn),children:[(0,$.jsx)(zn,{children:n.label}),(0,$.jsx)(u,{className:_n(),value:o??``,onChange:e=>l({model:e.target.value,...f?{voice:void 0}:{}}),children:i.map(e=>(0,$.jsx)(d,{value:e.id,children:e.name},e.id))})]},n.key):n.key===`voice`&&a.length>0?(0,$.jsxs)(`div`,{className:g(`flex flex-col gap-1.5`,hn),children:[(0,$.jsx)(zn,{children:n.label}),(0,$.jsx)(u,{className:_n(),value:s??``,onChange:e=>l({voice:e.target.value}),children:a.map(e=>(0,$.jsx)(d,{value:e.id,children:e.name},e.id))})]},n.key):(0,$.jsx)(Ln,{field:n,value:Tn(r,n),onChange:e=>l({[n.key]:e}),className:n.type===`textarea`?`sm:col-span-2`:hn},n.key))}function In(e){let t=(0,Rt.c)(27),{checked:n,title:r,description:i,onChange:a}=e,o;t[0]!==n||t[1]!==a?(o=()=>a(!n),t[0]=n,t[1]=a,t[2]=o):o=t[2];let s=n?`bg-surface-panel text-fg`:`bg-surface-panel/80 text-fg hover:bg-surface-hover`,c;t[3]===s?c=t[4]:(c=g(`group flex w-full items-center justify-between gap-4 rounded-lg bg-surface-base/55 px-3 py-3 text-left transition-colors`,Ee,s),t[3]=s,t[4]=c);let l;t[5]===r?l=t[6]:(l=(0,$.jsx)(`span`,{className:`flex flex-wrap items-center gap-2 text-sm font-semibold text-fg`,children:r}),t[5]=r,t[6]=l);let u;t[7]===i?u=t[8]:(u=(0,$.jsx)(`span`,{className:`mt-1 block text-xs leading-relaxed text-fg-muted`,children:i}),t[7]=i,t[8]=u);let d;t[9]!==l||t[10]!==u?(d=(0,$.jsxs)(`span`,{className:`min-w-0`,children:[l,u]}),t[9]=l,t[10]=u,t[11]=d):d=t[11];let f=n?`border-accent bg-accent`:`border-edge bg-surface-hover group-hover:border-accent/40`,p;t[12]===f?p=t[13]:(p=g(`relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border transition-colors`,f),t[12]=f,t[13]=p);let m=n?`translate-x-5`:`translate-x-0.5`,h;t[14]===m?h=t[15]:(h=g(`size-5 rounded-full bg-white shadow-surface transition-transform`,m),t[14]=m,t[15]=h);let _;t[16]===h?_=t[17]:(_=(0,$.jsx)(`span`,{className:h}),t[16]=h,t[17]=_);let v;t[18]!==_||t[19]!==p?(v=(0,$.jsx)(`span`,{className:p,"aria-hidden":!0,children:_}),t[18]=_,t[19]=p,t[20]=v):v=t[20];let y;return t[21]!==n||t[22]!==o||t[23]!==v||t[24]!==c||t[25]!==d?(y=(0,$.jsxs)(`button`,{type:`button`,role:`switch`,"aria-checked":n,onClick:o,className:c,children:[d,v]}),t[21]=n,t[22]=o,t[23]=v,t[24]=c,t[25]=d,t[26]=y):y=t[26],y}function Ln(e){let t=(0,Rt.c)(36),{field:n,value:r,onChange:i,className:a}=e,o=`voice-schema-field-${n.key}`,s=n.description;if(n.type===`boolean`){let e;t[0]===a?e=t[1]:(e=g(`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,a),t[0]=a,t[1]=e);let o;t[2]===n.label?o=t[3]:(o=(0,$.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:n.label}),t[2]=n.label,t[3]=o);let c;t[4]===s?c=t[5]:(c=s?(0,$.jsx)(`span`,{className:`mt-1 block text-xs text-fg-subtle`,children:s}):null,t[4]=s,t[5]=c);let l;t[6]!==o||t[7]!==c?(l=(0,$.jsxs)(`span`,{children:[o,c]}),t[6]=o,t[7]=c,t[8]=l):l=t[8];let u=!!r,d;t[9]!==n||t[10]!==i?(d=e=>i(En(n,e.target.checked)),t[9]=n,t[10]=i,t[11]=d):d=t[11];let f;t[12]!==u||t[13]!==d?(f=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:u,onChange:d}),t[12]=u,t[13]=d,t[14]=f):f=t[14];let p;return t[15]!==e||t[16]!==l||t[17]!==f?(p=(0,$.jsxs)(`label`,{className:e,children:[l,f]}),t[15]=e,t[16]=l,t[17]=f,t[18]=p):p=t[18],p}let c=typeof r==`boolean`?``:String(r),l;t[19]===a?l=t[20]:(l=g(`flex flex-col gap-1.5`,a),t[19]=a,t[20]=l);let d;t[21]===n.label?d=t[22]:(d=(0,$.jsx)(zn,{children:n.label}),t[21]=n.label,t[22]=d);let f;t[23]!==a||t[24]!==n||t[25]!==c||t[26]!==o||t[27]!==i?(f=n.type===`select`?(0,$.jsx)(u,{id:o,className:_n(),value:c,required:n.required,onChange:e=>i(En(n,e.target.value)),children:(n.options??[]).map(Rn)}):n.type===`textarea`?(0,$.jsx)(`textarea`,{id:o,className:g(gn(),`min-h-24 resize-y`),value:c,required:n.required,placeholder:n.placeholder,onChange:e=>i(En(n,e.target.value))}):n.type===`password`?(0,$.jsx)(ie,{id:o,className:a,value:c,onChange:e=>i(En(n,e)),placeholder:n.placeholder,labels:ve}):(0,$.jsx)(`input`,{id:o,className:gn(),type:n.type===`number`?`number`:`text`,autoComplete:n.secret?`new-password`:`off`,spellCheck:!1,value:c,required:n.required,placeholder:n.placeholder,min:n.min,max:n.max,step:n.step,onChange:e=>i(En(n,e.target.value))}),t[23]=a,t[24]=n,t[25]=c,t[26]=o,t[27]=i,t[28]=f):f=t[28];let p;t[29]===s?p=t[30]:(p=s?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:s}):null,t[29]=s,t[30]=p);let m;return t[31]!==l||t[32]!==d||t[33]!==f||t[34]!==p?(m=(0,$.jsxs)(`div`,{className:l,children:[d,f,p]}),t[31]=l,t[32]=d,t[33]=f,t[34]=p,t[35]=m):m=t[35],m}function Rn(e){return(0,$.jsx)(d,{value:e.id,children:e.name},e.id)}function zn(e){let t=(0,Rt.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=r),r}function Bn(e){return e.some(e=>e.disabled?!1:e.type===`searxng`?e.url.trim().length>0:e.apiKey.trim().length>0)}function Vn(e){let t=e&&typeof e==`object`&&`tools`in e?e.tools:void 0,n=t&&typeof t==`object`&&`web`in t?t.web:void 0,r=n&&typeof n==`object`&&`region`in n?n.region:void 0,i=r===`cn`||r===`global`?r:`auto`,a=n&&typeof n==`object`&&`search`in n?n.search:void 0,o=a&&typeof a==`object`?a:{},s=typeof o.maxResults==`number`&&Number.isFinite(o.maxResults)?Math.floor(o.maxResults):5,c=n&&typeof n==`object`&&`blocklist`in n?n.blocklist:void 0,l=c&&typeof c==`object`?c:{},u=Array.isArray(l.domains)?l.domains.filter(e=>typeof e==`string`&&e.trim().length>0):[],d=o.providers;return{regionMode:i,maxResults:s,providers:Array.isArray(d)?d.map(e=>{let t=e&&typeof e==`object`?e:{},n=t.type;return{type:n===`brave`||n===`tavily`||n===`bing`||n===`searxng`?n:`brave`,apiKey:typeof t.apiKey==`string`?t.apiKey:``,url:typeof t.url==`string`?t.url:``,disabled:t.disabled===!0}}):[],blocklistEnabled:l.enabled===!0,blocklistDomains:u}}async function Hn(e){let t=e.regionMode===`auto`?`auto`:e.regionMode===`cn`?`cn`:`global`,n={maxResults:e.maxResults,providers:e.providers.map(e=>{let t={type:e.type,apiKey:e.apiKey};return e.type===`searxng`&&e.url.trim()&&(t.url=e.url.trim().replace(/\/+$/,``)),e.disabled&&(t.disabled=!0),t})};await _(x(`/api/config`),{method:`PATCH`,body:JSON.stringify({tools:{web:{region:t,search:n,blocklist:{enabled:e.blocklistEnabled,domains:e.blocklistDomains}}}})}),M()}async function Un(e){let t=await _(x(`/api/tools/web/reveal-search-api-key`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({index:e})});if(!t.ok||!t.payload)throw Error(t.error?.message??`Reveal failed`);return t.payload}function Wn(e){let t=(0,Rt.c)(8),{label:n,description:r,children:i}=e,a;t[0]===n?a=t[1]:(a=(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=a);let o;t[2]===r?o=t[3]:(o=(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:r}),t[2]=r,t[3]=o);let s;return t[4]!==i||t[5]!==a||t[6]!==o?(s=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[a,i,o]}),t[4]=i,t[5]=a,t[6]=o,t[7]=s):s=t[7],s}function Gn(){return g(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,Ee,`dark:border-edge`)}function Kn(){return g(we,Te)}var qn=[`brave`,`tavily`,`bing`,`searxng`];function Jn(){return{type:`brave`,apiKey:``,url:``,disabled:!1}}var Yn=pe();function Xn(){let e=S(b(e=>e.language)),t=e.webSearchSettings,n=e.logs,r=!!v(e=>e.conversationId),[i,a]=(0,Q.useReducer)(Yn,{form:null,baseline:null}),o=i.form,s=i.baseline,c=(0,Q.useRef)(!1),l=(0,Q.useRef)(o);l.current=o;let f=(0,Q.useRef)(null),{data:p,error:h,isLoading:_,mutate:y}=N(r);V({enabled:r,parsed:(0,Q.useMemo)(()=>p?.payload?.config===void 0?null:Vn(p.payload.config),[p]),dirty:c.current,trackedParsedRef:f,dispatch:a,onResetDirty:()=>{c.current=!1}});let x=!!(r&&_&&p===void 0&&!h),C=h instanceof Error?h.message:h?String(h):null,w=(0,Q.useMemo)(()=>!o||!s?!1:JSON.stringify(o)!==JSON.stringify(s),[o,s]),T=(0,Q.useCallback)(e=>{c.current=!0,a({type:`patch`,patch:e})},[]),E=gt({value:o,dirty:w,onSave:(0,Q.useCallback)(async e=>{try{await Hn(e),a({type:`saved`,value:e}),c.current=!!(l.current&&JSON.stringify(l.current)!==JSON.stringify(e))}catch(e){throw Error(e instanceof Error?e.message:t.saveError)}},[t.saveError])});if(!r)return(0,$.jsx)(`div`,{className:`flex flex-col gap-3`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.needToken})});if(x)return(0,$.jsx)(mt,{rows:3});if(!o)return(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:C??t.loadError}),(0,$.jsx)(j,{type:`button`,variant:`secondary`,onClick:()=>void y(),children:n.refresh})]});let D=Bn(o.providers);return(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,onBlurCapture:E.onBlurCapture,children:[E.error?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:E.error}):null,(0,$.jsxs)(ft,{children:[(0,$.jsx)(dt,{icon:Ve,title:t.sectionSearch,subtitle:t.sectionSearchHint,trailing:(0,$.jsx)(ht,{status:E.status,error:E.error})}),(0,$.jsxs)(`div`,{className:`flex max-w-2xl flex-col gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-3 rounded-lg border border-edge bg-surface-base/55 px-4 py-3`,children:[(0,$.jsx)(xe,{className:`mt-0.5 size-5 shrink-0 text-accent`}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.cloudProvider}),(0,$.jsx)(`span`,{className:g(`rounded-full px-2 py-0.5 text-[11px] font-medium`,D?`bg-surface-panel text-fg-muted`:`bg-accent-soft text-accent`),children:D?t.cloudOverridden:t.cloudAutomatic})]}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-subtle`,children:D?t.cloudOverriddenHint:t.cloudAutomaticHint})]})]}),(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:t.providersTitle}),o.providers.map((n,r)=>(0,$.jsx)(Zn,{row:n,providerIndex:r,labels:t,secretLabels:Se(e.providersSettings),onChange:e=>{let t=[...o.providers];t[r]=e,T({providers:t})},onRemove:()=>{T({providers:o.providers.filter((e,t)=>t!==r)})}},`${n.type}:${n.url}:${n.apiKey}:${n.disabled}`)),(0,$.jsxs)(j,{type:`button`,variant:`secondary`,className:`w-fit gap-1.5 text-sm`,onClick:()=>T({providers:[...o.providers,Jn()]}),children:[(0,$.jsx)(m,{className:`size-4`}),t.addProvider]})]})]}),(0,$.jsxs)(ft,{children:[(0,$.jsx)(dt,{icon:te,title:t.sectionPreferences}),(0,$.jsxs)(`div`,{className:`grid max-w-2xl gap-4 sm:grid-cols-2`,children:[(0,$.jsx)(Wn,{label:t.regionLabel,description:t.regionDesc,children:(0,$.jsxs)(u,{className:Kn(),value:o.regionMode,onChange:e=>T({regionMode:e.target.value}),children:[(0,$.jsx)(d,{value:`auto`,children:t.regionAuto}),(0,$.jsx)(d,{value:`cn`,children:t.regionCn}),(0,$.jsx)(d,{value:`global`,children:t.regionGlobal})]})}),(0,$.jsx)(Wn,{label:t.maxResultsLabel,description:t.maxResultsDesc,children:(0,$.jsx)(`input`,{type:`number`,min:1,max:50,className:Gn(),value:o.maxResults,onChange:e=>T({maxResults:Math.max(1,Math.min(50,Number(e.target.value)||5))})})})]})]}),(0,$.jsx)(jt,{children:(0,$.jsxs)(ft,{children:[(0,$.jsx)(dt,{icon:q,title:t.sectionBlocklist,subtitle:t.sectionBlocklistHint}),(0,$.jsxs)(`div`,{className:`flex max-w-2xl flex-col gap-4`,children:[(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:o.blocklistEnabled,onChange:e=>T({blocklistEnabled:e.target.checked})}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`span`,{className:`font-medium`,children:t.blocklistEnabled}),(0,$.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:t.blocklistEnabledDesc})]})]}),o.blocklistEnabled?(0,$.jsx)(Wn,{label:t.blocklistDomains,description:t.blocklistDomainsDesc,children:(0,$.jsx)(`textarea`,{className:g(Gn(),`min-h-[6rem] font-mono text-xs`),value:o.blocklistDomains.join(`
8
- `),placeholder:t.blocklistDomainsPlaceholder,onChange:e=>{T({blocklistDomains:e.target.value.split(/\r?\n/).flatMap(e=>{let t=e.trim().toLowerCase();return t?[t]:[]})})}})}):null]})]})})]})}function Zn(e){let t=(0,Rt.c)(54),{row:n,providerIndex:r,labels:i,secretLabels:a,onChange:o,onRemove:s}=e,c;t[0]===r?c=t[1]:(c=()=>Un(r).then(Qn),t[0]=r,t[1]=c);let l=c,f;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(f=g(Kn(),`min-w-[8rem]`),t[2]=f):f=t[2];let p=n.type,m;t[3]!==o||t[4]!==n?(m=e=>o({...n,type:e.target.value,url:e.target.value===`searxng`?n.url:``}),t[3]=o,t[4]=n,t[5]=m):m=t[5];let h;t[6]===i.providerTypes?h=t[7]:(h=qn.map(e=>(0,$.jsx)(d,{value:e,children:i.providerTypes[e]},e)),t[6]=i.providerTypes,t[7]=h);let _;t[8]!==n.type||t[9]!==m||t[10]!==h?(_=(0,$.jsx)(u,{className:f,value:p,onChange:m,children:h}),t[8]=n.type,t[9]=m,t[10]=h,t[11]=_):_=t[11];let v;t[12]!==o||t[13]!==n?(v=e=>o({...n,disabled:e.target.checked}),t[12]=o,t[13]=n,t[14]=v):v=t[14];let y;t[15]!==n.disabled||t[16]!==v?(y=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:n.disabled,onChange:v}),t[15]=n.disabled,t[16]=v,t[17]=y):y=t[17];let b;t[18]!==i.disabled||t[19]!==y?(b=(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5 text-xs text-fg-muted`,children:[y,i.disabled]}),t[18]=i.disabled,t[19]=y,t[20]=b):b=t[20];let x;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(W,{className:`size-4`}),t[21]=x):x=t[21];let S;t[22]===s?S=t[23]:(S=(0,$.jsx)(j,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-fg-muted`,onClick:s,children:x}),t[22]=s,t[23]=S);let C;t[24]!==S||t[25]!==b?(C=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[b,S]}),t[24]=S,t[25]=b,t[26]=C):C=t[26];let w;t[27]!==C||t[28]!==_?(w=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[_,C]}),t[27]=C,t[28]=_,t[29]=w):w=t[29];let T;t[30]!==i.urlDesc||t[31]!==i.urlLabel||t[32]!==o||t[33]!==n?(T=n.type===`searxng`?(0,$.jsx)(Wn,{label:i.urlLabel,description:i.urlDesc,children:(0,$.jsx)(`input`,{type:`url`,className:Gn(),value:n.url,placeholder:`http://localhost:8080`,onChange:e=>o({...n,url:e.target.value})})}):null,t[30]=i.urlDesc,t[31]=i.urlLabel,t[32]=o,t[33]=n,t[34]=T):T=t[34];let E;t[35]!==o||t[36]!==n?(E=e=>o({...n,apiKey:e}),t[35]=o,t[36]=n,t[37]=E):E=t[37];let D;t[38]!==i.keyPlaceholder||t[39]!==i.keyPlaceholderMasked||t[40]!==i.saveError||t[41]!==l||t[42]!==n.apiKey||t[43]!==a||t[44]!==E?(D=(0,$.jsx)(ie,{value:n.apiKey,onChange:E,placeholder:i.keyPlaceholder,labels:a,reveal:l,loadFailedLabel:i.saveError,notInConfigFile:i.keyPlaceholderMasked}),t[38]=i.keyPlaceholder,t[39]=i.keyPlaceholderMasked,t[40]=i.saveError,t[41]=l,t[42]=n.apiKey,t[43]=a,t[44]=E,t[45]=D):D=t[45];let O;t[46]!==i.apiKeyDesc||t[47]!==i.apiKeyLabel||t[48]!==D?(O=(0,$.jsx)(Wn,{label:i.apiKeyLabel,description:i.apiKeyDesc,children:D}),t[46]=i.apiKeyDesc,t[47]=i.apiKeyLabel,t[48]=D,t[49]=O):O=t[49];let k;return t[50]!==w||t[51]!==T||t[52]!==O?(k=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl bg-surface-panel/60 p-4`,children:[w,T,O]}),t[50]=w,t[51]=T,t[52]=O,t[53]=k):k=t[53],k}function Qn(e){return e.apiKey??null}function $n(e){let t=(0,Rt.c)(185),{model:n,isNew:r,providerId:i,onSave:a,onClose:o,m:s}=e,c=b(tr)===`zh`,l;t[0]===n?l=t[1]:(l=()=>n?{...n}:me(``),t[0]=n,t[1]=l);let[f,p]=(0,Q.useState)(l),[m,_]=(0,Q.useState)(er),v;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(v=(e,t)=>{p(n=>({...n,[e]:t})),_(t=>{let n=new Map(t);return n.delete(e),n})},t[2]=v):v=t[2];let y=v,x;t[3]!==f.computerUse||t[4]!==f.contextWindow||t[5]!==f.id||t[6]!==f.input||t[7]!==f.maxTokens||t[8]!==s.modelIdRequired||t[9]!==s.mustBePositive||t[10]!==c?(x=()=>{let e=new Map;return(f.id||``).trim()||e.set(`id`,s.modelIdRequired),f.contextWindow!==void 0&&f.contextWindow<=0&&e.set(`contextWindow`,s.mustBePositive),f.maxTokens!==void 0&&f.maxTokens<=0&&e.set(`maxTokens`,s.mustBePositive),f.computerUse&&!f.input?.includes(`image`)&&e.set(`computerUse`,c?`电脑控制模型必须支持图片输入`:`Computer Use requires image input`),_(e),e.size===0},t[3]=f.computerUse,t[4]=f.contextWindow,t[5]=f.id,t[6]=f.input,t[7]=f.maxTokens,t[8]=s.modelIdRequired,t[9]=s.mustBePositive,t[10]=c,t[11]=x):x=t[11];let S=x,C;t[12]!==f||t[13]!==o||t[14]!==a||t[15]!==S?(C=()=>{if(!S())return;let e=(f.id||``).trim();a({...f,id:e,name:f.name?.trim()||e,reasoning:f.reasoning||!1,input:f.input||[`text`],contextWindow:f.contextWindow??128e3,maxTokens:f.maxTokens??16384,cost:{input:f.cost?.input??0,output:f.cost?.output??0,cacheRead:f.cost?.cacheRead??0,cacheWrite:f.cost?.cacheWrite??0}}),o()},t[12]=f,t[13]=o,t[14]=a,t[15]=S,t[16]=C):C=t[16];let w=C,E=f,D;t[17]===E?D=t[18]:(D=Me(E),t[17]=E,t[18]=D);let k=D,A=r?s.addModelTitle:s.editModelTitle,M;t[19]===A?M=t[20]:(M=(0,$.jsx)(O,{className:`text-base font-semibold text-fg`,children:A}),t[19]=A,t[20]=M);let N;t[21]!==s.modelProviderLabel||t[22]!==i?(N=i?(0,$.jsxs)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:[s.modelProviderLabel,`: `,i]}):null,t[21]=s.modelProviderLabel,t[22]=i,t[23]=N):N=t[23];let P;t[24]!==M||t[25]!==N?(P=(0,$.jsxs)(`div`,{children:[M,N]}),t[24]=M,t[25]=N,t[26]=P):P=t[26];let F;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(F=g(ae,`p-1.5 hover:bg-surface-base`),t[27]=F):F=t[27];let I;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,$.jsx)(h,{className:`size-4`}),t[28]=I):I=t[28];let L;t[29]===s.close?L=t[30]:(L=(0,$.jsx)(T,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:F,"aria-label":s.close,children:I})}),t[29]=s.close,t[30]=L);let R;t[31]!==P||t[32]!==L?(R=(0,$.jsxs)(`div`,{className:`mb-3 flex shrink-0 items-start justify-between gap-2`,children:[P,L]}),t[31]=P,t[32]=L,t[33]=R):R=t[33];let ee;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(ee=(0,$.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`}),t[34]=ee):ee=t[34];let z;t[35]===s.modelId?z=t[36]:(z=(0,$.jsxs)(`label`,{className:`mb-1 block text-xs font-medium text-fg`,children:[s.modelId,ee]}),t[35]=s.modelId,t[36]=z);let B;t[37]===m?B=t[38]:(B=g(nt(),m.has(`id`)&&`border-red-500`),t[37]=m,t[38]=B);let V=f.id||``,H;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(H=e=>y(`id`,e.target.value),t[39]=H):H=t[39];let U=!r,W;t[40]!==B||t[41]!==V||t[42]!==U?(W=(0,$.jsx)(`input`,{className:B,value:V,onChange:H,placeholder:`e.g. llama3.1:8b`,disabled:U}),t[40]=B,t[41]=V,t[42]=U,t[43]=W):W=t[43];let G;t[44]===m?G=t[45]:(G=m.has(`id`)?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:m.get(`id`)}):null,t[44]=m,t[45]=G);let K;t[46]!==z||t[47]!==W||t[48]!==G?(K=(0,$.jsxs)(`div`,{children:[z,W,G]}),t[46]=z,t[47]=W,t[48]=G,t[49]=K):K=t[49];let q;t[50]===s.displayName?q=t[51]:(q=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.displayName}),t[50]=s.displayName,t[51]=q);let te;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(te=nt(),t[52]=te):te=t[52];let J=f.name||``,Y;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(Y=e=>y(`name`,e.target.value),t[53]=Y):Y=t[53];let X;t[54]===J?X=t[55]:(X=(0,$.jsx)(`input`,{className:te,value:J,onChange:Y}),t[54]=J,t[55]=X);let ne;t[56]!==q||t[57]!==X?(ne=(0,$.jsxs)(`div`,{children:[q,X]}),t[56]=q,t[57]=X,t[58]=ne):ne=t[58];let re;t[59]===s.inputTypes?re=t[60]:(re=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.inputTypes}),t[59]=s.inputTypes,t[60]=re);let ie;t[61]===Symbol.for(`react.memo_cache_sentinel`)?(ie=it(),t[61]=ie):ie=t[61];let oe;t[62]===Symbol.for(`react.memo_cache_sentinel`)?(oe=e=>y(`input`,ot(e.target.value)),t[62]=oe):oe=t[62];let se;t[63]===s?se=t[64]:(se=De.map(e=>(0,$.jsx)(d,{value:e.value,children:s[e.labelKey]},e.value)),t[63]=s,t[64]=se);let ce;t[65]!==k||t[66]!==se?(ce=(0,$.jsx)(u,{className:ie,value:k,onChange:oe,children:se}),t[65]=k,t[66]=se,t[67]=ce):ce=t[67];let le;t[68]!==re||t[69]!==ce?(le=(0,$.jsxs)(`div`,{children:[re,ce]}),t[68]=re,t[69]=ce,t[70]=le):le=t[70];let ue=f.reasoning||!1,de;t[71]===Symbol.for(`react.memo_cache_sentinel`)?(de=e=>y(`reasoning`,e.target.checked),t[71]=de):de=t[71];let fe;t[72]===ue?fe=t[73]:(fe=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:ue,onChange:de}),t[72]=ue,t[73]=fe);let Z;t[74]!==s.reasoning||t[75]!==fe?(Z=(0,$.jsxs)(`label`,{className:`mt-6 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[fe,s.reasoning]}),t[74]=s.reasoning,t[75]=fe,t[76]=Z):Z=t[76];let pe;t[77]!==le||t[78]!==Z?(pe=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[le,Z]}),t[77]=le,t[78]=Z,t[79]=pe):pe=t[79];let he;t[80]===s.contextWindow?he=t[81]:(he=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.contextWindow}),t[80]=s.contextWindow,t[81]=he);let ge;t[82]===m?ge=t[83]:(ge=g(nt(),m.has(`contextWindow`)&&`border-red-500`),t[82]=m,t[83]=ge);let _e=f.contextWindow??128e3,ve;t[84]===Symbol.for(`react.memo_cache_sentinel`)?(ve=e=>y(`contextWindow`,parseInt(e.target.value,10)||0),t[84]=ve):ve=t[84];let ye;t[85]!==ge||t[86]!==_e?(ye=(0,$.jsx)(`input`,{type:`number`,min:1,className:ge,value:_e,onChange:ve}),t[85]=ge,t[86]=_e,t[87]=ye):ye=t[87];let be;t[88]===m?be=t[89]:(be=m.has(`contextWindow`)?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:m.get(`contextWindow`)}):null,t[88]=m,t[89]=be);let xe;t[90]!==he||t[91]!==ye||t[92]!==be?(xe=(0,$.jsxs)(`div`,{children:[he,ye,be]}),t[90]=he,t[91]=ye,t[92]=be,t[93]=xe):xe=t[93];let Se;t[94]===s.maxOutputTokens?Se=t[95]:(Se=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.maxOutputTokens}),t[94]=s.maxOutputTokens,t[95]=Se);let Ce;t[96]===m?Ce=t[97]:(Ce=g(nt(),m.has(`maxTokens`)&&`border-red-500`),t[96]=m,t[97]=Ce);let we=f.maxTokens??16384,Te;t[98]===Symbol.for(`react.memo_cache_sentinel`)?(Te=e=>y(`maxTokens`,parseInt(e.target.value,10)||0),t[98]=Te):Te=t[98];let Ee;t[99]!==Ce||t[100]!==we?(Ee=(0,$.jsx)(`input`,{type:`number`,min:1,className:Ce,value:we,onChange:Te}),t[99]=Ce,t[100]=we,t[101]=Ee):Ee=t[101];let Oe;t[102]===m?Oe=t[103]:(Oe=m.has(`maxTokens`)?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:m.get(`maxTokens`)}):null,t[102]=m,t[103]=Oe);let ke;t[104]!==Se||t[105]!==Ee||t[106]!==Oe?(ke=(0,$.jsxs)(`div`,{children:[Se,Ee,Oe]}),t[104]=Se,t[105]=Ee,t[106]=Oe,t[107]=ke):ke=t[107];let Ae;t[108]!==xe||t[109]!==ke?(Ae=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[xe,ke]}),t[108]=xe,t[109]=ke,t[110]=Ae):Ae=t[110];let je;t[111]===s.costSection?je=t[112]:(je=(0,$.jsx)(`p`,{className:`mb-2 text-xs font-semibold text-fg`,children:s.costSection}),t[111]=s.costSection,t[112]=je);let Ne;t[113]===s.costInput?Ne=t[114]:(Ne=(0,$.jsx)(`label`,{className:`mb-1 block text-xs text-fg-muted`,children:s.costInput}),t[113]=s.costInput,t[114]=Ne);let Pe;t[115]===Symbol.for(`react.memo_cache_sentinel`)?(Pe=nt(),t[115]=Pe):Pe=t[115];let Fe=f.cost?.input??0,Ie;t[116]===f.cost?Ie=t[117]:(Ie=e=>y(`cost`,{...f.cost,input:parseFloat(e.target.value)||0,output:f.cost?.output??0,cacheRead:f.cost?.cacheRead??0,cacheWrite:f.cost?.cacheWrite??0}),t[116]=f.cost,t[117]=Ie);let Le;t[118]!==Fe||t[119]!==Ie?(Le=(0,$.jsx)(`input`,{type:`number`,step:`any`,min:0,className:Pe,value:Fe,onChange:Ie}),t[118]=Fe,t[119]=Ie,t[120]=Le):Le=t[120];let Re;t[121]!==Ne||t[122]!==Le?(Re=(0,$.jsxs)(`div`,{children:[Ne,Le]}),t[121]=Ne,t[122]=Le,t[123]=Re):Re=t[123];let ze;t[124]===s.costOutput?ze=t[125]:(ze=(0,$.jsx)(`label`,{className:`mb-1 block text-xs text-fg-muted`,children:s.costOutput}),t[124]=s.costOutput,t[125]=ze);let Be;t[126]===Symbol.for(`react.memo_cache_sentinel`)?(Be=nt(),t[126]=Be):Be=t[126];let Ve=f.cost?.output??0,He;t[127]===f.cost?He=t[128]:(He=e=>y(`cost`,{...f.cost,input:f.cost?.input??0,output:parseFloat(e.target.value)||0,cacheRead:f.cost?.cacheRead??0,cacheWrite:f.cost?.cacheWrite??0}),t[127]=f.cost,t[128]=He);let Ue;t[129]!==Ve||t[130]!==He?(Ue=(0,$.jsx)(`input`,{type:`number`,step:`any`,min:0,className:Be,value:Ve,onChange:He}),t[129]=Ve,t[130]=He,t[131]=Ue):Ue=t[131];let We;t[132]!==ze||t[133]!==Ue?(We=(0,$.jsxs)(`div`,{children:[ze,Ue]}),t[132]=ze,t[133]=Ue,t[134]=We):We=t[134];let Ge;t[135]!==Re||t[136]!==We?(Ge=(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[Re,We]}),t[135]=Re,t[136]=We,t[137]=Ge):Ge=t[137];let Ke;t[138]!==je||t[139]!==Ge?(Ke=(0,$.jsxs)(`div`,{className:`border-t border-edge-subtle pt-2 dark:border-edge`,children:[je,Ge]}),t[138]=je,t[139]=Ge,t[140]=Ke):Ke=t[140];let qe;t[141]!==K||t[142]!==ne||t[143]!==pe||t[144]!==Ae||t[145]!==Ke?(qe=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[K,ne,pe,Ae,Ke]}),t[141]=K,t[142]=ne,t[143]=pe,t[144]=Ae,t[145]=Ke,t[146]=qe):qe=t[146];let Je=c?`高级:电脑控制协议`:`Advanced: Computer Use protocol`,Ye;t[147]===Je?Ye=t[148]:(Ye=(0,$.jsx)(`summary`,{className:`cursor-pointer`,children:Je}),t[147]=Je,t[148]=Ye);let Xe=c?`电脑控制协议`:`Computer Use protocol`,Ze=f.computerUse?.profile??``,Qe;t[149]===Symbol.for(`react.memo_cache_sentinel`)?(Qe=e=>y(`computerUse`,e.target.value?{profile:e.target.value}:void 0),t[149]=Qe):Qe=t[149];let $e=c?`未声明`:`Not declared`,et;t[150]===$e?et=t[151]:(et=(0,$.jsx)(d,{value:``,children:$e}),t[150]=$e,t[151]=et);let tt,rt,at;t[152]===Symbol.for(`react.memo_cache_sentinel`)?(tt=(0,$.jsx)(d,{value:`gui-plus-2026-02-26`,children:`GUI-Plus (2026-02-26)`}),rt=(0,$.jsx)(d,{value:`structured-tools-v1`,children:`structured-tools-v1`}),at=(0,$.jsx)(d,{value:`openai-responses-computer-v1`,children:`OpenAI Responses Computer`}),t[152]=tt,t[153]=rt,t[154]=at):(tt=t[152],rt=t[153],at=t[154]);let st;t[155]!==Xe||t[156]!==Ze||t[157]!==et?(st=(0,$.jsxs)(u,{"aria-label":Xe,value:Ze,onChange:Qe,children:[et,tt,rt,at]}),t[155]=Xe,t[156]=Ze,t[157]=et,t[158]=st):st=t[158];let ct=c?`协议必须与模型 API 匹配。声明协议不代表模型已通过效果验证。`:`The protocol must match the model API. Declaring a protocol does not certify model quality.`,lt;t[159]===ct?lt=t[160]:(lt=(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:ct}),t[159]=ct,t[160]=lt);let ut;t[161]===m?ut=t[162]:(ut=m.has(`computerUse`)&&(0,$.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:m.get(`computerUse`)}),t[161]=m,t[162]=ut);let dt;t[163]!==st||t[164]!==lt||t[165]!==ut?(dt=(0,$.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[st,lt,ut]}),t[163]=st,t[164]=lt,t[165]=ut,t[166]=dt):dt=t[166];let ft;t[167]!==Ye||t[168]!==dt?(ft=(0,$.jsxs)(`details`,{className:`mt-4 rounded-lg border border-edge p-3 text-sm text-fg`,children:[Ye,dt]}),t[167]=Ye,t[168]=dt,t[169]=ft):ft=t[169];let pt;t[170]!==qe||t[171]!==ft?(pt=(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pr-1`,children:[qe,ft]}),t[170]=qe,t[171]=ft,t[172]=pt):pt=t[172];let mt;t[173]===s.cancel?mt=t[174]:(mt=(0,$.jsx)(T,{asChild:!0,children:(0,$.jsx)(j,{type:`button`,variant:`secondary`,children:s.cancel})}),t[173]=s.cancel,t[174]=mt);let ht=r?s.addModelConfirm:s.saveModelConfirm,gt;t[175]!==w||t[176]!==ht?(gt=(0,$.jsx)(j,{type:`button`,variant:`primary`,className:`hover:bg-accent/90`,onClick:w,children:ht}),t[175]=w,t[176]=ht,t[177]=gt):gt=t[177];let _t;t[178]!==mt||t[179]!==gt?(_t=(0,$.jsxs)(`div`,{className:`mt-4 flex shrink-0 justify-end gap-2 border-t border-edge-subtle pt-3 dark:border-edge`,children:[mt,gt]}),t[178]=mt,t[179]=gt,t[180]=_t):_t=t[180];let vt;return t[181]!==R||t[182]!==pt||t[183]!==_t?(vt=(0,$.jsxs)($.Fragment,{children:[R,pt,_t]}),t[181]=R,t[182]=pt,t[183]=_t,t[184]=vt):vt=t[184],vt}function er(){return new Map}function tr(e){return e.language}function nr(e){let t=(0,Rt.c)(16),{open:n,onOpenChange:r,providerId:i,model:a,isNew:o,onSave:s,m:c}=e,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(C,{className:g(`xopc-dialog-overlay fixed inset-0 bg-scrim`,I)}),t[0]=l):l=t[0];let u;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(u=g(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(90vh,720px)] w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2 flex-col`,F,`overflow-hidden rounded-xl border border-edge bg-surface-overlay p-4 shadow-popover dark:border-edge`),t[1]=u):u=t[1];let d;t[2]!==o||t[3]!==c||t[4]!==a||t[5]!==r||t[6]!==s||t[7]!==n||t[8]!==i?(d=n?(0,$.jsx)($n,{model:a,isNew:o,providerId:i,onSave:s,onClose:()=>r(!1),m:c},`${i??`none`}-${a?.id??`new`}`):null,t[2]=o,t[3]=c,t[4]=a,t[5]=r,t[6]=s,t[7]=n,t[8]=i,t[9]=d):d=t[9];let f;t[10]===d?f=t[11]:(f=(0,$.jsxs)(E,{children:[l,(0,$.jsx)(D,{className:u,onOpenAutoFocus:rr,children:d})]}),t[10]=d,t[11]=f);let p;return t[12]!==r||t[13]!==n||t[14]!==f?(p=(0,$.jsx)(k,{open:n,onOpenChange:r,children:f}),t[12]=r,t[13]=n,t[14]=f,t[15]=p):p=t[15],p}function rr(e){return e.preventDefault()}function ir(e){let t=(0,Rt.c)(14),{providerId:n,inputId:r,value:i,onChange:a,labels:o}=e,s;t[0]===n?s=t[1]:(s=()=>be(n).then(ar),t[0]=n,t[1]=s);let c=s,l;t[2]!==r||t[3]!==o.apiKeyLabel?(l=(0,$.jsx)(`label`,{htmlFor:r,className:`text-sm font-medium text-fg`,children:o.apiKeyLabel}),t[2]=r,t[3]=o.apiKeyLabel,t[4]=l):l=t[4];let u;t[5]!==r||t[6]!==o||t[7]!==a||t[8]!==c||t[9]!==i?(u=(0,$.jsx)(ie,{id:r,value:i,onChange:a,placeholder:o.apiKeyPlaceholder,labels:o,reveal:c,loadFailedLabel:o.loadFailed,maskedHelp:o.maskedHelp,notInConfigFile:o.notInConfigFile}),t[5]=r,t[6]=o,t[7]=a,t[8]=c,t[9]=i,t[10]=u):u=t[10];let d;return t[11]!==l||t[12]!==u?(d=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[l,u]}),t[11]=l,t[12]=u,t[13]=d):d=t[13],d}function ar(e){return e.apiKey??null}function or(e){let t=(0,Rt.c)(16),{open:n,onOpenChange:r,providerId:i,isCustom:a,builtinRows:o,customConfig:s,allModels:c,labels:l,language:u,onSaved:d}=e,f;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(f=(0,$.jsx)(C,{className:g(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,I)}),t[0]=f):f=t[0];let p;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(p=g(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(85vh,720px)] w-[calc(100%-2rem)] max-w-lg -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay`,F),t[1]=p):p=t[1];let m;t[2]!==c||t[3]!==o||t[4]!==s||t[5]!==a||t[6]!==l||t[7]!==u||t[8]!==r||t[9]!==d||t[10]!==i?(m=(0,$.jsxs)(E,{children:[f,(0,$.jsx)(D,{className:p,children:a?(0,$.jsx)(cr,{providerId:i,customConfig:s,labels:l,language:u,onClose:()=>r(!1),onSaved:d}):(0,$.jsx)(sr,{providerId:i,builtinRows:o,allModels:c,labels:l,language:u,onClose:()=>r(!1),onSaved:d})})]}),t[2]=c,t[3]=o,t[4]=s,t[5]=a,t[6]=l,t[7]=u,t[8]=r,t[9]=d,t[10]=i,t[11]=m):m=t[11];let h;return t[12]!==r||t[13]!==n||t[14]!==m?(h=(0,$.jsx)(k,{open:n,onOpenChange:r,children:m}),t[12]=r,t[13]=n,t[14]=m,t[15]=h):h=t[15],h}function sr({providerId:e,builtinRows:t,allModels:n,labels:r,language:i,onClose:a,onSaved:o}){let s=t.find(t=>t.id===e),c=rt[e],u=n.filter(t=>t.provider===e),[d,f]=(0,Q.useState)(!1),[m,_]=(0,Q.useState)(s?.apiKey??``),[v,y]=(0,Q.useState)(!1),[b,x]=(0,Q.useState)(!1),[C,w]=(0,Q.useState)(null),[E,D]=(0,Q.useState)(!1),k=S(i).providersSettings,A=s?.supportsApiKey!==!1,M=s?.supportsOAuth===!0,N=s?.authMode===`oauth`&&s.authStatus===`connected`,P=s?.configured===!0&&s.activeKeySource!==`env`&&s.activeKeySource!==`extension`&&s.activeKeySource!==`models_json`,[F,I]=(0,Q.useState)(null),[L,R]=(0,Q.useState)(null),[V,H]=(0,Q.useState)(`idle`),[q,te]=(0,Q.useState)(null),[J,Y]=(0,Q.useState)(null),[re,ie]=(0,Q.useState)(null),[ae,oe]=(0,Q.useState)(``),Z=(0,Q.useRef)(null),pe=(0,Q.useRef)(null),me=V===`waiting`||V===`waiting_code`,he=(0,Q.useMemo)(()=>_e(e,i),[e,i]),ge=m!==(s?.apiKey??``),ve=async()=>{let t=m.trim();if(!(!t||!A||ct(t))){y(!0),w(null);try{await B({[e]:t}),x(!0),window.setTimeout(()=>{o(),a()},600)}catch(e){w(e instanceof Error?e.message:r.saveError)}finally{y(!1)}}};(0,Q.useEffect)(()=>{if(!F||!me)return;let e=window.setInterval(()=>{(async()=>{try{let t=await le(F);t.status===`waiting_auth`||t.status===`waiting_code`?(H(t.status===`waiting_code`?`waiting_code`:`waiting`),R(t.message??null),te(t.authUrl??null),Y(t.instructions??null),ie(t.deviceCode??null),t.authUrl&&t.authUrl!==pe.current&&(pe.current=t.authUrl,ue(t.authUrl,Z.current).catch(()=>{}))):t.status===`completed`?(window.clearInterval(e),U(Z.current),Z.current=null,H(`success`),R(t.message??k.saved),window.setTimeout(()=>{o(),a()},600)):(t.status===`failed`||t.status===`cancelled`)&&(window.clearInterval(e),U(Z.current),Z.current=null,H(`error`),R(t.error??t.message??k.revokeFailed))}catch{}})()},1e3);return()=>window.clearInterval(e)},[F,me,a,o,k.revokeFailed,k.saved]),(0,Q.useEffect)(()=>()=>{F&&ce(F).catch(()=>{})},[F]),(0,Q.useEffect)(()=>()=>{U(Z.current),Z.current=null},[]);let ye=async()=>{try{await se(e),o(),a()}catch{}},be=async()=>{U(Z.current),Z.current=ze(),pe.current=null,H(`waiting`),R(k.oauthStarting),te(null),Y(null),ie(null),w(null);try{I((await K(e)).sessionId)}catch(e){U(Z.current),Z.current=null,H(`error`),R(e instanceof Error?e.message:k.revokeFailed)}},xe=async()=>{if(F){try{await Le(F)}catch{}U(Z.current),Z.current=null,pe.current=null,H(`idle`),R(null),I(null),te(null),Y(null),ie(null)}},Se=async()=>{if(!(!F||!ae.trim()))try{await ne(F,ae.trim()),oe(``),R(k.oauthProcessingCode)}catch(e){H(`error`),R(e instanceof Error?e.message:k.revokeFailed)}},Ce=async()=>{try{await de(e),o(),a()}catch(e){w(e instanceof Error?e.message:k.revokeFailed)}};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b border-edge-subtle px-5 py-4`,children:[(0,$.jsx)(O,{className:`text-base font-semibold text-fg`,children:s?.name??e}),(0,$.jsx)(T,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:g(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,Xe.press),children:(0,$.jsx)(h,{className:`size-4`,"aria-hidden":!0})})})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-4 overflow-y-auto px-5 py-4`,children:[c?.description?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:c.description}):null,s?.baseUrl?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:r.apiUrlLabel}),(0,$.jsx)(`code`,{className:`break-all rounded-lg border border-edge-subtle bg-surface-panel/60 px-3 py-2 font-mono text-xs text-fg-muted`,children:s.baseUrl})]}):s?.category===`extension`?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.apiUrlExtensionHint}):null,A?(0,$.jsx)(ir,{providerId:e,inputId:`manage-api-key`,value:m,onChange:e=>{_(e),x(!1)},labels:{apiKeyLabel:r.apiKeyLabel,apiKeyPlaceholder:r.apiKeyPlaceholder,maskedHelp:r.maskedHelp,copy:r.copy,copied:r.copied,show:r.showKey,hide:r.hideKey,notInConfigFile:r.notInConfigFile,loadFailed:r.loadFailed}}):s?.category===`extension`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-panel/60 px-3 py-2 text-sm text-fg-muted`,children:[(0,$.jsx)(`p`,{children:r.extensionKeyHint}),s?.extensionId?(0,$.jsxs)(l,{to:`/settings/ext/${encodeURIComponent(s.extensionId)}`,className:`inline-flex w-fit items-center gap-1 font-medium text-accent hover:underline`,title:r.extensionSettingsLinkTitle,onClick:a,children:[r.openExtensionSettings,(0,$.jsx)(z,{className:`size-3`,"aria-hidden":!0})]}):null]}):null,M?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-panel/60 p-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:k.oauth}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:N?k.sourceOauth:k.oauthHint})]}),N?(0,$.jsx)(j,{type:`button`,variant:`secondary`,className:`gap-1.5 text-red-600 dark:text-red-400`,onClick:()=>void Ce(),children:k.revoke}):(0,$.jsxs)(j,{type:`button`,variant:`primary`,className:`gap-1.5`,disabled:me,onClick:()=>void be(),children:[me?(0,$.jsx)(fe,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(X,{className:`size-3.5`,"aria-hidden":!0}),k.oauth]})]}),L?(0,$.jsx)(`p`,{className:g(`text-xs`,V===`error`?`text-red-600 dark:text-red-400`:`text-fg-muted`),children:L}):null,V===`waiting`||V===`waiting_code`?(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[q?(0,$.jsxs)(`a`,{href:q,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1.5 rounded-md bg-accent px-3 py-2 text-sm font-medium text-on-accent hover:bg-accent-hover`,children:[(0,$.jsx)(z,{className:`size-4`,"aria-hidden":!0}),k.openAuthPage]}):null,(0,$.jsx)(j,{type:`button`,variant:`secondary`,onClick:()=>void xe(),children:k.cancelOAuth})]}):null,J?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:J}):null,re?(0,$.jsxs)(`div`,{className:`rounded-lg border border-edge-subtle bg-surface-panel px-3 py-2`,children:[(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:k.deviceCodeLabel}),(0,$.jsx)(`code`,{className:`mt-1 block select-all font-mono text-lg font-semibold tracking-widest text-fg`,children:re}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:k.deviceCodeHint})]}):null,V===`waiting_code`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,$.jsx)(`input`,{type:`text`,value:ae,onChange:e=>oe(e.target.value),onKeyDown:e=>e.key===`Enter`&&void Se(),placeholder:k.pasteRedirectUrl,className:g(`min-w-0 flex-1 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,Ee)}),(0,$.jsx)(j,{type:`button`,variant:`primary`,onClick:()=>void Se(),children:k.submitCode})]}):null]}):null,he.length>0&&A?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:he.map(({kind:e,href:t})=>(0,$.jsxs)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent hover:underline`,children:[G(e,r),(0,$.jsx)(z,{className:`size-3`,"aria-hidden":!0})]},e))}):null,u.length>0?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsxs)(`span`,{className:`text-sm font-medium text-fg`,children:[r.modelsLabel,` (`,u.length,`)`]}),(0,$.jsxs)(`label`,{className:`mb-2 flex items-center gap-2 text-xs text-fg-muted`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:d,onChange:e=>f(e.target.checked)}),i===`zh`?`仅电脑控制模型`:`Computer Use only`]}),(0,$.jsx)(`div`,{className:`max-h-40 overflow-y-auto rounded-lg border border-edge-subtle bg-surface-panel/40 p-2`,children:(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:u.filter(e=>!d||e.computerUse).map(e=>(0,$.jsxs)(`span`,{className:`inline-block rounded-md bg-surface-hover px-2 py-1 text-xs text-fg-muted`,children:[ee(e,i),e.computerUse?` · Computer Use`:``]},e.id))})})]}):(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r.noModels}),C?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:C}):null]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle px-5 py-3`,children:[P?(0,$.jsxs)(j,{type:`button`,variant:`ghost`,className:`gap-1.5 text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300`,onClick:()=>D(!0),children:[(0,$.jsx)(W,{className:`size-3.5`,"aria-hidden":!0}),r.remove]}):(0,$.jsx)(`span`,{}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:A&&ge&&!ct(m.trim())?(0,$.jsx)(j,{type:`button`,variant:`primary`,disabled:!m.trim()||v||b,onClick:()=>void ve(),children:b?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(p,{className:`size-3.5`,"aria-hidden":!0}),r.saved]}):v?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(fe,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),r.saving]}):r.save}):null})]}),(0,$.jsx)(Ae,{open:E,title:r.removeConfirmTitle,description:r.removeConfirmDescription.replace(`{{provider}}`,s?.name??e),confirmLabel:r.removeConfirmAction,cancelLabel:r.cancel,destructive:!0,onConfirm:()=>void ye(),onCancel:()=>D(!1)})]})}function cr({providerId:e,customConfig:t,labels:n,language:r,onClose:i,onSaved:a}){let o=S(r).modelsSettings,s=t?.providers[e],[c,l]=(0,Q.useState)(s?.baseUrl??``),[u,d]=(0,Q.useState)(s?.apiKey??``),[f,p]=(0,Q.useState)(s?.models??[]),[_,v]=(0,Q.useState)(!1),[y,b]=(0,Q.useState)(s?.modelDiscovery?.enabled===!0),[x,C]=(0,Q.useState)(!1),[w,E]=(0,Q.useState)(null),[D,k]=(0,Q.useState)(!1),[A,M]=(0,Q.useState)(null),[N,P]=(0,Q.useState)(!1),[F,I]=(0,Q.useState)(null),L=n=>{if(!t)return null;let r=u.trim(),i={...s,baseUrl:c.trim()||void 0,apiKey:ct(r)?s?.apiKey:r||void 0,...n};return{providers:{...t.providers,[e]:i}}},R=async()=>{let e=L({models:f,modelDiscovery:{enabled:y}});if(e){C(!0),E(null);try{await H(e),a(),i()}catch(e){E(e instanceof Error?e.message:n.saveError)}finally{C(!1)}}},ee=async()=>{if(t)try{let{[e]:n,...r}=t.providers;await H({providers:r}),a(),i()}catch{}},z=(e,t)=>{I({model:e,isNew:t}),P(!0)},B=async e=>{if(!F)return;let t=F.isNew?[...f,e]:f.map(t=>t.id===e.id?e:t);p(t);let r=L({models:t});if(r)try{await H(r),a()}catch(e){E(e instanceof Error?e.message:n.saveError)}},V=async e=>{let t=f.filter(t=>t.id!==e);p(t),M(null);let r=L({models:t});if(r)try{await H(r),a()}catch(e){E(e instanceof Error?e.message:n.saveError)}};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b border-edge-subtle px-5 py-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(O,{className:`text-base font-semibold text-fg`,children:e}),(0,$.jsx)(`span`,{className:`rounded bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium text-fg-subtle`,children:n.custom})]}),(0,$.jsx)(T,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:g(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,Xe.press),children:(0,$.jsx)(h,{className:`size-4`,"aria-hidden":!0})})})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-4 overflow-y-auto px-5 py-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`manage-base-url`,className:`text-sm font-medium text-fg`,children:n.baseUrlLabel}),(0,$.jsx)(`input`,{id:`manage-base-url`,type:`url`,autoComplete:`off`,value:c,onChange:e=>l(e.target.value),className:g(`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,Ee)})]}),(0,$.jsx)(ir,{providerId:e,inputId:`manage-custom-api-key`,value:u,onChange:d,labels:{apiKeyLabel:n.apiKeyLabel,apiKeyPlaceholder:n.apiKeyPlaceholder,maskedHelp:n.maskedHelp,copy:n.copy,copied:n.copied,show:n.showKey,hide:n.hideKey,notInConfigFile:n.notInConfigFile,loadFailed:n.loadFailed}}),(0,$.jsxs)(`label`,{className:`flex items-start gap-3 rounded-xl border border-edge-subtle bg-surface-panel/40 p-3`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:y,onChange:e=>b(e.target.checked),className:`mt-0.5 size-4 rounded border-edge accent-accent`}),(0,$.jsxs)(`span`,{className:`min-w-0`,children:[(0,$.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:r===`zh`?`自动同步模型目录`:`Automatically sync model catalog`}),(0,$.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-muted`,children:r===`zh`?`启动时及定时从此服务的 /models 接口更新模型。`:`Update models from this service’s /models endpoint at startup and on schedule.`})]})]}),(0,$.jsxs)(`div`,{className:`border-t border-edge-subtle pt-3`,children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`span`,{className:`text-sm font-semibold text-fg`,children:[o.modelsSection,f.length>0?` (${f.length})`:``]}),(0,$.jsxs)(j,{type:`button`,variant:`primary`,className:`gap-1.5 px-2 py-1 text-xs`,onClick:()=>z(null,!0),children:[(0,$.jsx)(m,{className:`size-3.5`,"aria-hidden":!0}),o.addModel]})]}),(0,$.jsxs)(`label`,{className:`mb-2 flex items-center gap-2 text-xs text-fg-muted`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:_,onChange:e=>v(e.target.checked)}),r===`zh`?`仅电脑控制模型`:`Computer Use only`]}),f.filter(e=>!_||e.computerUse).length===0?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:o.modelsEmpty}):(0,$.jsx)(`ul`,{className:`space-y-2`,children:f.filter(e=>!_||e.computerUse).map(e=>(0,$.jsxs)(`li`,{className:`flex items-center justify-between gap-2 rounded-lg border border-edge-subtle bg-surface-panel/40 px-3 py-2`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:`truncate text-sm font-medium text-fg`,children:e.id}),e.computerUse&&(0,$.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`Computer Use`}),e.name&&e.name!==e.id?(0,$.jsx)(`div`,{className:`truncate text-xs text-fg-muted`,children:e.name}):null]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,$.jsx)(`button`,{type:`button`,className:g(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,Xe.press),onClick:()=>z(e,!1),"aria-label":o.editModel,children:(0,$.jsx)(Ue,{className:`size-3.5`,"aria-hidden":!0})}),(0,$.jsx)(`button`,{type:`button`,className:g(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-red-600 dark:hover:text-red-400`,Xe.press),onClick:()=>M(e.id),"aria-label":o.removeModel,children:(0,$.jsx)(W,{className:`size-3.5`,"aria-hidden":!0})})]})]},e.id))})]}),w?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:w}):null]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle px-5 py-3`,children:[(0,$.jsxs)(j,{type:`button`,variant:`ghost`,className:`gap-1.5 text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300`,onClick:()=>k(!0),children:[(0,$.jsx)(W,{className:`size-3.5`,"aria-hidden":!0}),n.remove]}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,$.jsx)(j,{type:`button`,variant:`primary`,disabled:x,onClick:()=>void R(),children:x?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(fe,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),n.saving]}):n.save})})]}),(0,$.jsx)(Ae,{open:D,title:n.removeConfirmTitle,description:n.removeConfirmDescription.replace(`{{provider}}`,e),confirmLabel:n.removeConfirmAction,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>void ee(),onCancel:()=>k(!1)}),(0,$.jsx)(Ae,{open:A!==null,title:o.removeModel,description:o.removeModelConfirm.replace(`{{id}}`,A??``),confirmLabel:n.removeConfirmAction,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>{A&&V(A)},onCancel:()=>M(null)}),(0,$.jsx)(nr,{open:N,onOpenChange:e=>{P(e),e||I(null)},providerId:e,model:F?.model??null,isNew:F?.isNew??!1,onSave:e=>void B(e),m:o})]})}function lr(e){return e.status===`ready`?`ready`:e.status===`disabled`?`off`:e.status===`degraded`?`degraded`:e.rejected?.length?`misconfigured`:`not-configured`}function ur(e,t){switch(e){case`computer-use`:return{href:`/settings/computer-use`,guidance:t?`选择兼容的电脑控制模型;本机权限需单独授权`:`Select a compatible computer model; local access requires separate approval`,action:t?`配置电脑控制`:`Configure computer use`};case`vision`:return{href:`${Z(`models`)}?add=1`,guidance:t?`接入支持图片理解的模型服务`:`Connect a model service that supports vision`,action:t?`去接入模型`:`Connect model`};case`image-generation`:return{href:Z(`image`),guidance:t?`选择图片模型并配置所需凭据`:`Choose an image model and configure its credentials`,action:t?`去配置图片生成`:`Configure image generation`};case`stt`:return{href:Z(`voice`),guidance:t?`选择语音识别服务,或安装本地语音模型`:`Choose a speech-to-text service or install a local voice model`,action:t?`去配置语音识别`:`Configure speech-to-text`};case`tts`:return{href:Z(`voice`),guidance:t?`选择语音合成服务并完成凭据配置`:`Choose a text-to-speech service and configure its credentials`,action:t?`去配置语音合成`:`Configure text-to-speech`}}}function dr(e){switch(e){case`computer-use`:return`/settings/computer-use`;case`vision`:return Z(`models`);case`image-generation`:return Z(`image`);case`stt`:case`tts`:return Z(`voice`)}}async function fr(){let e=await y(x(`/api/models/catalog`)),t=await e.json().catch(()=>null);if(!e.ok||!t?.ok||!t.payload)throw Error(t?.error?.message??`HTTP ${e.status}`);return t.payload}async function pr(){let e=await y(x(`/api/capabilities/readiness`)),t=await e.json().catch(()=>null);if(!e.ok||!t?.ok||!t.payload)throw Error(t?.error?.message??`HTTP ${e.status}`);return t.payload}function mr(){let e=b(e=>e.language)===`zh`,{data:t,error:n,isLoading:r}=A(ye,fr,{revalidateOnFocus:!1}),{data:i}=A(J,pr,{revalidateOnFocus:!1}),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(null);if(r)return(0,$.jsx)(P,{className:`h-24 w-full rounded-2xl`});let u=Object.values(t?.sources??{}),d=u.reduce((e,t)=>e+t.models.filter(e=>e.availability===`available`).length,0),f=(t?.references??[]).filter(e=>e.availability===`unavailable`),m=t?.sync.lastSuccessAt??Math.max(0,...u.map(e=>e.lastSuccessAt)),h=s??(n instanceof Error?n.message:t?.sync.lastError??Object.values(t?.sync.sourceErrors??{})[0]),_=Object.entries(i?.capabilities??{}).filter(([e])=>e!==`computer-use`||L()),v=_.some(([,e])=>{let t=lr(e);return t===`degraded`||t===`misconfigured`}),S=_.filter(([,e])=>lr(e)===`ready`).length,C=async()=>{o(!0),c(null);try{let e=await y(x(`/api/models/catalog/refresh`),{method:`POST`});if(!e.ok)throw Error(`HTTP ${e.status}`);await Ce()}catch(t){c(t instanceof Error?t.message:e?`模型目录刷新失败`:`Model catalog refresh failed`)}finally{o(!1)}};return(0,$.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/25 p-4 sm:p-5`,children:[(0,$.jsxs)(`details`,{className:`group`,open:v||void 0,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer list-none rounded-lg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:(0,$.jsxs)(`div`,{className:`flex min-h-10 items-center gap-2`,children:[v?(0,$.jsx)(he,{className:`size-4 text-amber-500`,"aria-hidden":!0}):S===_.length&&_.length>0?(0,$.jsx)(p,{className:`size-4 text-emerald-500`,"aria-hidden":!0}):(0,$.jsx)(R,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block text-sm font-semibold text-fg`,children:e?`可选能力`:`Optional capabilities`}),(0,$.jsx)(`span`,{className:`mt-0.5 block text-xs font-normal text-fg-muted`,children:e?`${S}/${_.length} 项已配置,不影响基础聊天功能`:`${S} of ${_.length} configured · Not required for chat`})]}),(0,$.jsx)(Ge,{className:`size-4 shrink-0 text-fg-subtle transition-transform group-open:rotate-90 motion-reduce:transition-none`,"aria-hidden":!0})]})}),i?(0,$.jsx)(`div`,{className:`mt-3 grid gap-1 sm:grid-cols-2`,children:Object.entries(i.capabilities).map(([t,n])=>{if(t===`computer-use`&&!L())return null;let r=t===`vision`?e?`图片理解`:`Vision`:t===`image-generation`?e?`图片生成`:`Image generation`:t===`computer-use`?e?`电脑控制模型`:`Computer use model`:t.toUpperCase(),i=n.selectionSource!==`explicit-config`,a=lr(n),o=a===`degraded`||a===`misconfigured`,s=ur(t,e),c=(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`min-w-0 text-xs font-medium text-fg`,children:r}),(0,$.jsx)(`span`,{className:a===`ready`?`shrink-0 text-xs text-emerald-600 dark:text-emerald-400`:a===`off`||a===`not-configured`?`shrink-0 text-xs text-fg-muted`:`shrink-0 text-xs text-amber-600 dark:text-amber-400`,children:a===`ready`?t===`computer-use`?e?`已配置`:`Configured`:e?`可用`:`Ready`:a===`off`?e?`已关闭`:`Off`:a===`not-configured`?e?`未配置`:`Not configured`:a===`degraded`?e?`正在使用备用方案`:`Using fallback`:e?`需处理`:`Needs attention`})]}),(0,$.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted`,title:n.primary?`${n.primary.provider}/${n.primary.model}`:void 0,children:n.primary?`${i?e?`自动`:`Auto`:e?`显式`:`Explicit`} · ${n.primary.provider}/${n.primary.model}`:a===`not-configured`?e?`可稍后按需配置`:`Set up later if needed`:e?`已配置的模型不可用`:`The configured model is unavailable`}),o?(0,$.jsxs)(`div`,{className:`mt-2 rounded-lg bg-amber-500/10 p-2`,children:[(0,$.jsx)(`p`,{className:`text-xs leading-5 text-amber-700 dark:text-amber-300`,children:n.status===`degraded`?e?`当前配置不可用,正在使用备用方案。${s.guidance}`:`The current configuration is unavailable, so a fallback is in use. ${s.guidance}.`:s.guidance}),(0,$.jsxs)(`span`,{className:`mt-1 inline-flex items-center gap-1 text-xs font-medium text-accent`,children:[s.action,(0,$.jsx)(je,{className:`size-3.5`,"aria-hidden":!0})]})]}):null]});return(0,$.jsx)(l,{to:o?s.href:dr(t),"aria-label":o?`${r}:${s.action}`:`${e?`配置`:`Configure`} ${r}`,className:g(`rounded-lg bg-surface-base/45 px-3 py-3 transition-colors`,o?`bg-amber-500/5 hover:bg-amber-500/10`:`hover:bg-surface-hover/30`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),children:c},t)})}):null]}),f.length>0?(0,$.jsx)(`div`,{className:`mt-2 space-y-1 text-sm text-amber-700 dark:text-amber-300`,children:f.slice(0,3).map(t=>(0,$.jsxs)(`p`,{children:[t.ref,` `,e?`不可用`:`is unavailable`,t.suggestedRef?` · ${e?`建议`:`Suggested`} ${t.suggestedRef}`:``,` · ${t.locations.length} ${e?`处引用`:`references`}`]},t.ref))}):null,h?(0,$.jsx)(`p`,{className:`mt-3 text-sm text-danger`,role:`alert`,children:h}):null,(0,$.jsxs)(`details`,{className:`mt-4 border-t border-edge-subtle pt-3`,children:[(0,$.jsx)(`summary`,{className:`min-h-8 cursor-pointer rounded-md py-1.5 text-xs font-medium text-fg-muted hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:e?`高级诊断`:`Advanced diagnostics`}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e?`${u.length} 个来源,${d} 个可用模型${m?` · 最近同步 ${new Date(m).toLocaleString()}`:``}`:`${u.length} sources, ${d} available models${m?` · Last synced ${new Date(m).toLocaleString()}`:``}`}),(0,$.jsxs)(j,{className:`shrink-0`,type:`button`,variant:`secondary`,disabled:a,onClick:()=>void C(),children:[a?(0,$.jsx)(fe,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(Ke,{className:`size-4`,"aria-hidden":!0}),a?e?`刷新中…`:`Refreshing…`:e?`刷新目录`:`Refresh catalog`]})]})]})]})}async function hr(){return(await _(x(`/api/models/xopc-cloud/account-summary`))).payload}function gr(e){let t=(0,Rt.c)(99),{labels:n}=e,r=b(_r)===`zh`?`zh-CN`:`en-US`,i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i={refreshInterval:6e4,revalidateOnFocus:!0},t[0]=i):i=t[0];let{data:a,error:o,isLoading:s,isValidating:c,mutate:l}=A(`/api/models/xopc-cloud/account-summary`,hr,i);if(s){let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(P,{className:`h-40 w-full rounded-xl`}),t[1]=e):e=t[1],e}if(o||!a){let e;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(he,{className:`mt-0.5 size-4 shrink-0 text-amber-500`,"aria-hidden":!0}),t[2]=e):e=t[2];let r;t[3]===n.title?r=t[4]:(r=(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.title}),t[3]=n.title,t[4]=r);let i;t[5]===n.unavailable?i=t[6]:(i=(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:n.unavailable}),t[5]=n.unavailable,t[6]=i);let a;t[7]!==r||t[8]!==i?(a=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[e,(0,$.jsxs)(`div`,{children:[r,i]})]}),t[7]=r,t[8]=i,t[9]=a):a=t[9];let o;t[10]===l?o=t[11]:(o=()=>void l(),t[10]=l,t[11]=o);let s=c?`size-4 animate-spin`:`size-4`,u;t[12]===s?u=t[13]:(u=(0,$.jsx)(Ke,{className:s,"aria-hidden":!0}),t[12]=s,t[13]=u);let d;t[14]!==c||t[15]!==n.retry||t[16]!==o||t[17]!==u?(d=(0,$.jsxs)(j,{type:`button`,variant:`secondary`,disabled:c,onClick:o,children:[u,n.retry]}),t[14]=c,t[15]=n.retry,t[16]=o,t[17]=u,t[18]=d):d=t[18];let f;return t[19]!==a||t[20]!==d?(f=(0,$.jsx)(`section`,{className:`rounded-xl bg-surface-hover/25 p-4`,children:(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[a,d]})}),t[19]=a,t[20]=d,t[21]=f):f=t[21],f}let u,d,f,p,m,h,g;if(t[22]!==a.balance.credits||t[23]!==a.links.details||t[24]!==a.links.purchase||t[25]!==a.usage.chargedCredits||t[26]!==a.usage.requests||t[27]!==a.usage.totalTokens||t[28]!==n.availableCredits||t[29]!==n.connected||t[30]!==n.details||t[31]!==n.purchase||t[32]!==n.title||t[33]!==n.usageSummary||t[34]!==r){let e=new Intl.NumberFormat(r);g=n.usageSummary.replace(`{{tokens}}`,e.format(a.usage.totalTokens)).replace(`{{credits}}`,e.format(a.usage.chargedCredits)).replace(`{{requests}}`,e.format(a.usage.requests)),m=`rounded-xl bg-surface-hover/40 p-4 sm:p-5`;let i;t[42]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsx)(xe,{className:`size-4 text-accent-fg`,"aria-hidden":!0}),t[42]=i):i=t[42];let o;t[43]===n.title?o=t[44]:(o=(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:n.title}),t[43]=n.title,t[44]=o);let s;t[45]===n.connected?s=t[46]:(s=(0,$.jsx)(`span`,{className:`rounded-full bg-emerald-500/10 px-2 py-0.5 text-xs font-medium text-emerald-700 dark:text-emerald-300`,children:n.connected}),t[45]=n.connected,t[46]=s);let c;t[47]!==s||t[48]!==o?(c=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[i,o,s]}),t[47]=s,t[48]=o,t[49]=c):c=t[49];let l;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(z,{className:`size-3.5`,"aria-hidden":!0}),t[50]=l):l=t[50];let _;t[51]!==a.links.purchase||t[52]!==n.purchase?(_=(0,$.jsx)(j,{asChild:!0,variant:`primary`,children:(0,$.jsxs)(`a`,{href:a.links.purchase,target:`_blank`,rel:`noreferrer`,children:[n.purchase,l]})}),t[51]=a.links.purchase,t[52]=n.purchase,t[53]=_):_=t[53];let v;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(z,{className:`size-3.5`,"aria-hidden":!0}),t[54]=v):v=t[54];let y;t[55]!==a.links.details||t[56]!==n.details?(y=(0,$.jsx)(j,{asChild:!0,variant:`secondary`,children:(0,$.jsxs)(`a`,{href:a.links.details,target:`_blank`,rel:`noreferrer`,children:[n.details,v]})}),t[55]=a.links.details,t[56]=n.details,t[57]=y):y=t[57];let b;t[58]!==_||t[59]!==y?(b=(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:[_,y]}),t[58]=_,t[59]=y,t[60]=b):b=t[60],t[61]!==c||t[62]!==b?(h=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[c,b]}),t[61]=c,t[62]=b,t[63]=h):h=t[63],p=`mt-4 grid gap-4 rounded-lg bg-surface-base/45 p-3 sm:grid-cols-[minmax(12rem,0.7fr)_minmax(0,1.3fr)] sm:gap-6`,t[64]===n.availableCredits?f=t[65]:(f=(0,$.jsx)(`p`,{className:`text-xs font-medium text-fg-subtle`,children:n.availableCredits}),t[64]=n.availableCredits,t[65]=f),u=`mt-1 text-2xl font-semibold tracking-tight text-fg`,d=e.format(a.balance.credits),t[22]=a.balance.credits,t[23]=a.links.details,t[24]=a.links.purchase,t[25]=a.usage.chargedCredits,t[26]=a.usage.requests,t[27]=a.usage.totalTokens,t[28]=n.availableCredits,t[29]=n.connected,t[30]=n.details,t[31]=n.purchase,t[32]=n.title,t[33]=n.usageSummary,t[34]=r,t[35]=u,t[36]=d,t[37]=f,t[38]=p,t[39]=m,t[40]=h,t[41]=g}else u=t[35],d=t[36],f=t[37],p=t[38],m=t[39],h=t[40],g=t[41];let _;t[66]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,$.jsx)(`span`,{className:`ml-2 text-sm font-medium text-fg-muted`,children:`credits`}),t[66]=_):_=t[66];let v;t[67]!==u||t[68]!==d?(v=(0,$.jsxs)(`p`,{className:u,children:[d,_]}),t[67]=u,t[68]=d,t[69]=v):v=t[69];let y;t[70]!==a.balance.credits||t[71]!==n.zeroBalance?(y=a.balance.credits===0?(0,$.jsx)(`p`,{className:`mt-1 text-sm font-medium text-danger`,children:n.zeroBalance}):null,t[70]=a.balance.credits,t[71]=n.zeroBalance,t[72]=y):y=t[72];let x;t[73]!==y||t[74]!==f||t[75]!==v?(x=(0,$.jsxs)(`div`,{children:[f,v,y]}),t[73]=y,t[74]=f,t[75]=v,t[76]=x):x=t[76];let S;t[77]===n.recentUsage?S=t[78]:(S=(0,$.jsx)(`p`,{className:`text-xs font-medium text-fg-subtle`,children:n.recentUsage}),t[77]=n.recentUsage,t[78]=S);let C;t[79]===g?C=t[80]:(C=(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:g}),t[79]=g,t[80]=C);let w;t[81]!==a.balance.updatedAt||t[82]!==n.updatedAt||t[83]!==r?(w=n.updatedAt.replace(`{{time}}`,new Date(a.balance.updatedAt).toLocaleString(r)),t[81]=a.balance.updatedAt,t[82]=n.updatedAt,t[83]=r,t[84]=w):w=t[84];let T;t[85]===w?T=t[86]:(T=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:w}),t[85]=w,t[86]=T);let E;t[87]!==S||t[88]!==C||t[89]!==T?(E=(0,$.jsxs)(`div`,{children:[S,C,T]}),t[87]=S,t[88]=C,t[89]=T,t[90]=E):E=t[90];let D;t[91]!==x||t[92]!==E||t[93]!==p?(D=(0,$.jsxs)(`div`,{className:p,children:[x,E]}),t[91]=x,t[92]=E,t[93]=p,t[94]=D):D=t[94];let O;return t[95]!==D||t[96]!==m||t[97]!==h?(O=(0,$.jsxs)(`section`,{className:m,children:[h,D]}),t[95]=D,t[96]=m,t[97]=h,t[98]=O):O=t[98],O}function _r(e){return e.language}function vr(e){return oe.includes(e)}function yr(){let e=(0,Rt.c)(69),t=b(Sr),n;e[0]===t?n=e[1]:(n=S(t),e[0]=t,e[1]=n);let r=n,i=r.capabilitiesSettings,u=a(),[d,f]=o(),p;if(e[2]!==d){let t=d.get(`returnTo`);p=t?.startsWith(`/chat/`)?t:null,e[2]=d,e[3]=p}else p=e[3];let m=p,{capability:h}=s(),[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(null),x=Fe(),C;e[4]===x.cards?C=e[5]:(C=x.cards.some(xr),e[4]=x.cards,e[5]=C);let w=C,T,E;e[6]!==h||e[7]!==d||e[8]!==f?(T=()=>{if(h!==`models`||d.get(`add`)!==`1`)return;_(!0);let e=new URLSearchParams(d);e.delete(`add`),f(e,{replace:!0})},E=[h,d,f],e[6]=h,e[7]=d,e[8]=f,e[9]=T,e[10]=E):(T=e[9],E=e[10]),(0,Q.useEffect)(T,E);let D;e[11]===i.tabs.models?D=e[12]:(D={id:`models`,icon:Ve,label:i.tabs.models},e[11]=i.tabs.models,e[12]=D);let O;e[13]===i.tabs.image?O=e[14]:(O={id:`image`,icon:ke,label:i.tabs.image},e[13]=i.tabs.image,e[14]=O);let k;e[15]!==D||e[16]!==O?(k=[D,O],e[15]=D,e[16]=O,e[17]=k):k=e[17];let A=k,j;e[18]===u?j=e[19]:(j=e=>u(Z(e)),e[18]=u,e[19]=j);let M=j,N=br;if(!vr(h)){let t;return e[20]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(c,{to:Z(`models`),replace:!0}),e[20]=t):t=e[20],t}let P=h===`models`||h===`image`,F=h===`voice`?r.nav.settingsVoice:h===`search`?r.nav.settingsSearch:r.nav.settingsModels,I;e[21]===t?I=e[22]:(I=st(t,`configuration`),e[21]=t,e[22]=I);let L;e[23]!==i.docsLink||e[24]!==F||e[25]!==I?(L=(0,$.jsx)(lt,{title:F,docsLink:I,docsLabel:i.docsLink}),e[23]=i.docsLink,e[24]=F,e[25]=I,e[26]=L):L=e[26];let R;e[27]!==h||e[28]!==m||e[29]!==t?(R=h===`voice`&&m?(0,$.jsx)(l,{to:m,className:`text-sm text-accent-fg hover:underline`,children:t===`zh`?`返回对话`:`Return to conversation`}):null,e[27]=h,e[28]=m,e[29]=t,e[30]=R):R=e[30];let ee;e[31]!==i.tabsAria||e[32]!==h||e[33]!==P||e[34]!==A||e[35]!==M?(ee=P?(0,$.jsx)(pt,{items:A,activeTab:h,onChange:M,ariaLabel:i.tabsAria,tabIdPrefix:`capability-tab`,panelIdPrefix:`capability-panel`}):null,e[31]=i.tabsAria,e[32]=h,e[33]=P,e[34]=A,e[35]=M,e[36]=ee):ee=e[36];let z=P?`tabpanel`:void 0,B=`capability-panel-${h}`,V=P?`capability-tab-${h}`:void 0,H;e[37]!==i.connectedProviders||e[38]!==i.xopcCloudAccount||e[39]!==h||e[40]!==x||e[41]!==w?(H=h===`models`?(0,$.jsxs)($.Fragment,{children:[w?(0,$.jsx)(gr,{labels:i.xopcCloudAccount}):null,(0,$.jsx)(We,{labels:i.connectedProviders,data:x,onAdd:()=>_(!0),onManage:(e,t)=>y({providerId:e,isCustom:t})}),x.cards.length>0?(0,$.jsx)(mr,{}):null]}):(0,$.jsx)(Cr,{section:h}),e[37]=i.connectedProviders,e[38]=i.xopcCloudAccount,e[39]=h,e[40]=x,e[41]=w,e[42]=H):H=e[42];let U;e[43]!==z||e[44]!==B||e[45]!==V||e[46]!==H?(U=(0,$.jsx)(`div`,{role:z,id:B,"aria-labelledby":V,className:`flex min-w-0 flex-col gap-4`,children:H}),e[43]=z,e[44]=B,e[45]=V,e[46]=H,e[47]=U):U=e[47];let W;e[48]===Symbol.for(`react.memo_cache_sentinel`)?(W=()=>N(),e[48]=W):W=e[48];let G;e[49]!==g||e[50]!==i.addProviderDialog||e[51]!==t||e[52]!==x.builtinRows||e[53]!==x.customConfig?(G=(0,$.jsx)(Pe,{open:g,onOpenChange:_,builtinRows:x.builtinRows,customConfig:x.customConfig,labels:i.addProviderDialog,language:t,onSaved:W}),e[49]=g,e[50]=i.addProviderDialog,e[51]=t,e[52]=x.builtinRows,e[53]=x.customConfig,e[54]=G):G=e[54];let K;e[55]!==i.manageProviderDialog||e[56]!==t||e[57]!==v||e[58]!==x.allModels||e[59]!==x.builtinRows||e[60]!==x.customConfig?(K=v?(0,$.jsx)(or,{open:!0,onOpenChange:e=>{e||y(null)},providerId:v.providerId,isCustom:v.isCustom,builtinRows:x.builtinRows,customConfig:x.customConfig,allModels:x.allModels,labels:i.manageProviderDialog,language:t,onSaved:N}):null,e[55]=i.manageProviderDialog,e[56]=t,e[57]=v,e[58]=x.allModels,e[59]=x.builtinRows,e[60]=x.customConfig,e[61]=K):K=e[61];let q;return e[62]!==L||e[63]!==R||e[64]!==ee||e[65]!==U||e[66]!==G||e[67]!==K?(q=(0,$.jsxs)(ut,{children:[L,R,ee,U,G,K]}),e[62]=L,e[63]=R,e[64]=ee,e[65]=U,e[66]=G,e[67]=K,e[68]=q):q=e[68],q}function br(){Ce()}function xr(e){return e.id===`xopc-cloud`&&!e.isCustom}function Sr(e){return e.language}function Cr(e){let t=(0,Rt.c)(3),{section:n}=e;switch(n){case`models`:return null;case`image`:{let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(en,{}),t[0]=e):e=t[0],e}case`voice`:{let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(On,{}),t[1]=e):e=t[1],e}case`search`:{let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Xn,{}),t[2]=e):e=t[2],e}}}export{yr as CapabilitiesSettingsPanel};
@@ -1 +0,0 @@
1
- import{_ as e,a as t,c as n,d as r,f as i,g as a,h as ee,i as o,l as s,n as te,o as c,p as l,r as u,s as d,t as f,u as p}from"./schemas-88fK3zzl.js";import{_ as m,c as h,d as ne,f as g,h as re,l as _,n as ie,o as v,s as ae}from"./tasks-CDR_RVbQ.js";import{i as oe,n as y,t as se}from"./local-apps-Bpja8nC6.js";var ce=p({id:l(),kind:f([`agent_judgment`,`task`,`connector_approval`]),title:l(),detail:l().optional(),reason:f([`needs_input`,`blocked`,`user_input`,`user_approval`,`dependency`,`external`,`scheduled`,`retry`,`paused`,`overdue`,`due_soon`,`decision_needed`,`insight_available`,`approval_required`]),urgency:f([`now`,`soon`]),href:l(),projectId:l().optional(),projectName:l().optional(),dueAt:s().int().nonnegative().optional(),updatedAt:s(),judgment:p({inboxItemId:l(),whyNow:l(),impact:l(),workDone:l(),recommendation:l(),confidence:s(),valueScore:s().min(0).max(1).optional(),evidenceIds:u(l()).max(20),attentionKind:f([`information`,`decision`,`receipt`]),disposition:f([`show_in_work`,`request_approval`,`auto_execute`]).optional(),dispositionReason:l().optional(),actionStatus:f([`not_authorized`,`approval_required`,`pending`,`executing`,`completed`,`rejected`,`failed`]).optional(),proposedActionTitle:l().optional(),actionError:l().optional(),decision:p({question:l(),options:u(p({id:l(),label:l(),consequence:l()}))}).optional()}).optional(),response:t(`kind`,[p({kind:d(`connector_approval`),approvalId:l()})]).optional()});p({id:l(),kind:f([`automation_run`,`workflow_run`]),runId:l(),title:l(),detail:l(),reason:f([`run_failed`,`run_timeout`]),href:l(),updatedAt:s(),conversationId:l().optional()});var b=t(`type`,[p({type:d(`open`),label:l(),href:l()}),p({type:d(`review_judgment`),label:l(),itemId:l()}),p({type:d(`connector_decision`),label:l(),approvalId:l(),decision:f([`approve`,`deny`])}),p({type:d(`retry_run`),label:l(),subjectKind:f([`automation_run`,`workflow_run`]),runId:l()}),p({type:d(`acknowledge_run`),label:l(),subjectKind:f([`automation_run`,`workflow_run`]),runId:l()})]),x=p({id:l(),kind:f([`decision`,`failure`,`running`,`scheduled`,`insight`]),title:l(),summary:l(),recommendation:l().optional(),dueAt:s().int().nonnegative().optional(),statusLabel:l().optional(),updatedAt:s(),openAction:b.optional(),primaryAction:b.optional(),secondaryActions:u(b).max(2).default([])}),le=p({runningConversations:u(p({conversationId:l(),runId:l(),title:l().optional(),agentId:l().optional(),updatedAt:s()})).default([]),needsUser:u(x),background:u(x),backgroundCount:s().int().nonnegative(),decisions:u(ce),attentionPolicy:p({visibleDecisionCount:s().int().nonnegative(),suppressedDecisionCount:s().int().nonnegative(),visibleAttentionCount:s().int().nonnegative(),suppressedAttentionCount:s().int().nonnegative()}).default({visibleDecisionCount:0,suppressedDecisionCount:0,visibleAttentionCount:0,suppressedAttentionCount:0})}),ue=p({northStar:p({weeklyTrustedProgress:s(),weeklyActiveUsers:s(),trustedProgressPerWeeklyActiveUser:s()}),tasks:p({total:s(),achieved:s(),partial:s(),notAchieved:s(),userCorrected:s(),achievementRate:s(),correctionRate:s(),trusted:s(),trustedRate:s()})});function de(e){return le.parse(e)}var fe=t(`kind`,[p({kind:d(`once`),at:l()}),p({kind:d(`interval`),everyMs:s().positive(),anchorMs:s().optional()}),p({kind:d(`cron`),expr:l(),tz:l().optional()})]),S=t(`kind`,[p({kind:d(`manual`)}),p({kind:d(`schedule`),schedule:fe}),p({kind:d(`webhook`),secretId:l().optional()}),p({kind:d(`event`),eventType:l(),source:l().optional(),payloadMatch:r(l(),ee([l(),s(),o(),te()])).optional()})]),C=t(`kind`,[p({kind:d(`agent`),agentId:l().optional(),instruction:l(),workingDirectory:l().optional(),model:l().optional(),timeoutSeconds:s().positive().optional()}),p({kind:d(`workflow`),workflowId:l(),agentId:l().optional(),input:a().optional(),inputEnvelope:a().optional(),goal:l().optional(),concurrency:s().int().positive().optional(),maxSubagents:s().int().nonnegative().optional(),timeoutSeconds:s().positive().optional()}),p({kind:d(`browser_automation`),automationId:l(),inputs:r(l(),a()).optional(),timeoutSeconds:s().positive().optional()}),p({kind:d(`task_command`),taskId:l(),command:ie})]),w=f([`queued`,`running`,`cancelling`,`succeeded`,`failed`,`cancelled`,`timeout`]),T=p({id:l(),name:l(),description:l().optional(),projectId:l().optional(),enabled:o(),trigger:S,action:C,safety:p({mode:f([`suggest_only`,`ask_before_apply`,`auto_apply`])}).optional(),conversationMode:f([`new_session`,`continuous`]).optional(),notificationPolicy:f([`attention`,`all`,`none`]).optional(),completionWebhookUrl:l().optional(),reliability:p({executionTimeoutSeconds:s().positive().optional(),timeoutSeconds:s().positive().optional(),retryCount:s().int().nonnegative().optional(),maxConcurrentRuns:s().int().positive().optional(),disableAfterConsecutiveFailures:s().int().positive().optional()}).optional(),state:p({nextRunAtMs:s().optional(),runningRunId:l().optional(),lastRunAtMs:s().optional(),lastRunStatus:w.optional(),lastError:l().optional(),consecutiveFailures:s().int().nonnegative().optional()}),createdAtMs:s(),updatedAtMs:s()}),E=p({id:l(),automationId:l(),automationName:l(),status:w,triggerSnapshot:S,actionSnapshot:C,manual:o(),createdAtMs:s(),startedAtMs:s().optional(),endedAtMs:s().optional(),durationMs:s().optional(),summary:l().optional(),error:l().optional(),conversationId:l().optional(),workflowRunId:l().optional(),model:l().optional(),deadlineAtMs:s().optional(),currentPhase:f([`queued`,`action`,`completion_hook`,`cancelling`,`completed`]).optional(),cancelRequestedAtMs:s().optional(),cancelConfirmedAtMs:s().optional(),termination:p({reason:f([`completed`,`failed`,`user_cancelled`,`deadline_exceeded`]),component:f([`automation`,`agent_turn`,`tool`,`mcp`,`process`]).optional(),componentName:l().optional(),cancellationConfirmed:o()}).optional(),heartbeatAtMs:s().optional(),leaseOwner:l().optional(),leaseExpiresAtMs:s().optional(),attemptNumber:s().int().positive().optional(),rootRunId:l().optional()}),D=p({id:l(),runId:l(),automationId:l(),type:f([`run.queued`,`run.started`,`run.deadline_resolved`,`run.cancel_requested`,`run.cancel_confirmed`,`run.cancellation_unconfirmed`,`run.recovered`,`action.started`,`action.retry_scheduled`,`action.completed`,`action.failed`,`completion_hook.started`,`completion_hook.completed`,`completion_hook.failed`,`run.completed`]),message:l(),data:a().optional(),createdAtMs:s()}),pe=p({totalAutomations:s().int().nonnegative(),enabledAutomations:s().int().nonnegative(),runningRuns:s().int().nonnegative(),failedLastHour:s().int().nonnegative(),nextRun:p({automationId:l(),name:l(),runAtMs:s()}).optional()}),O=i({kind:f([`note`,`task`,`project`,`scene`,`local_app`]),id:l().min(1).max(512),revision:l().min(1).max(128)}),k=i({version:d(1),clientInstanceId:l().uuid(),tabId:l().uuid(),sequence:s().int().nonnegative().max(2**53-1),surface:f([`web`,`electron`,`mobile`]),resourceRefs:u(O).max(20),selection:i({text:l().max(16e3),draft:o().default(!1)}).optional(),capturedAt:s().int().nonnegative().max(2**53-1)}),me=p({snapshot:k,resources:u(p({reference:O,title:l(),text:l().max(16e3),truncated:o()})).max(20),selectionTrust:d(`user-supplied`)});function he(e){let t=k.parse(e);if(new TextEncoder().encode(JSON.stringify(t)).byteLength>65536)throw Error(`App context exceeds 64 KiB`);let n=t.resourceRefs.map(e=>`${e.kind}:${e.id}`);if(new Set(n).size!==n.length)throw Error(`App context contains duplicate resources`);return t}var A=l().trim().min(1).max(200),j=u(A).max(100).refine(e=>new Set(e).size===e.length,`Duplicate identifiers`),ge=[`no_change`,`observation`,`artifact`,`decision`,`state_change`,`effect_proposal`,`receipt`],M=[`needs_setup`,`active`,`paused`,`completed`,`archived`],N=t(`kind`,[i({kind:d(`personal`)}),i({kind:d(`project`),id:A}),i({kind:d(`conversation`),id:A}),i({kind:d(`objects`),ids:j.refine(e=>e.length>0)})]),P=i({timeoutSeconds:s().int().min(1).max(600),maxIterations:s().int().min(1).max(30),maxToolCalls:s().int().min(0).max(100),maxOutputTokens:s().int().min(1).max(32768)}),F=i({schemaVersion:d(1),key:l().regex(/^[a-z][a-z0-9-]{0,79}$/),version:l().regex(/^\d+\.\d+\.\d+$/),title:l().trim().min(1).max(120),description:l().trim().min(1).max(2e3),goalMode:f([`finite`,`ongoing`]),contextProviders:j,triggers:u(t(`type`,[i({id:A,type:d(`manual`)}),i({id:A,type:d(`event`),eventType:A}),i({id:A,type:d(`schedule`)})])).min(1).max(20).refine(e=>new Set(e.map(e=>e.id)).size===e.length,`Duplicate trigger IDs`),execution:i({kind:d(`agent`),instruction:l().trim().min(1).max(32e3),limits:P}),allowedOutcomeKinds:u(f(ge)).min(1),allowedEffectHandlers:j}),I=i({accountIds:j,contextProviders:j,effectHandlers:j}),L=i({expectedRevision:s().int().nonnegative(),content:l().trim().max(32e3),validUntil:s().int().nonnegative().nullable().default(null)}),R=i({templateKey:A,templateVersion:A,goal:l().trim().min(1).max(12e3),scope:N,permissions:I}),z=R.extend({id:A,ownerId:A,workspaceId:l().min(1),status:f(M),setupMissing:u(l()).optional(),revision:s().int().positive()}),_e=R.pick({goal:!0,scope:!0,permissions:!0}).extend({expectedRevision:s().int().positive()}),ve=i({expectedRevision:s().int().positive(),status:f(M)}),B=i({subjectId:A,accountId:A,dueAt:s().int().nonnegative()}),ye=i({expectedRevision:s().int().positive(),dueAt:s().int().nonnegative().optional(),status:f([`watching`,`paused`,`completed`]).optional()}).refine(e=>e.dueAt!==void 0||e.status!==void 0,`Work item update is empty`),V=B.extend({id:A,activationId:A,revision:s().int().positive(),status:f([`watching`,`paused`,`completed`])}),H=s().int().min(0).max(23),U=i({level:f([`quiet`,`balanced`,`active`]).default(`balanced`),timezone:l().min(1).max(100).refine(e=>{try{return new Intl.DateTimeFormat(`en`,{timeZone:e}),!0}catch{return!1}}).default(`Asia/Shanghai`),quietStartHour:H.default(22),quietEndHour:H.default(8),dailyNotificationLimit:s().int().min(0).max(30).default(3),digestEnabled:o().default(!1),digestHour:H.default(18),digestMinute:s().int().min(0).max(59).default(0),preferredChannel:f([`in_app`,`browser`]).default(`browser`),suppressWhileViewing:o().default(!0),checksPaused:o().default(!1),checksPausedUntil:l().datetime({offset:!0}).nullable().default(null),notificationsMuted:o().default(!1)}),W=U.shape;i({expectedRevision:s().int().nonnegative(),level:W.level.removeDefault().optional(),timezone:W.timezone.removeDefault().optional(),quietStartHour:W.quietStartHour.removeDefault().optional(),quietEndHour:W.quietEndHour.removeDefault().optional(),dailyNotificationLimit:W.dailyNotificationLimit.removeDefault().optional(),digestEnabled:W.digestEnabled.removeDefault().optional(),digestHour:W.digestHour.removeDefault().optional(),digestMinute:W.digestMinute.removeDefault().optional(),preferredChannel:W.preferredChannel.removeDefault().optional(),suppressWhileViewing:W.suppressWhileViewing.removeDefault().optional(),checksPaused:W.checksPaused.removeDefault().optional(),checksPausedUntil:W.checksPausedUntil.removeDefault().optional(),notificationsMuted:W.notificationsMuted.removeDefault().optional()});var be=i({expectedRevision:s().int().nonnegative(),rating:f([`useful`,`not_useful`]),note:l().trim().max(2e3).optional()}),xe=i({weekdays:u(s().int().min(0).max(6)).min(1).max(7).refine(e=>new Set(e).size===e.length,`Duplicate weekdays`),hour:s().int().min(0).max(23),minute:s().int().min(0).max(59),timeZone:l().trim().min(1).max(100).refine(e=>{try{return new Intl.DateTimeFormat(`en`,{timeZone:e}),!0}catch{return!1}},`Invalid time zone`)});f([`http`,`agent`,`cli`,`automation`,`mcp`,`extension`]),f([`INVALID_INPUT`,`FORBIDDEN`,`NOT_FOUND`,`REVISION_CONFLICT`,`CONTRACT_CHANGED`,`APPROVAL_REQUIRED`,`IN_PROGRESS`,`UNAVAILABLE`,`OUTCOME_UNKNOWN`,`CANCELLED`,`INTERNAL`]);var Se=i({majorVersion:s().int().positive(),descriptorDigest:l().regex(/^[a-f0-9]{64}$/),input:c(),idempotencyKey:l().min(1).max(200).optional()}),Ce=p({triggerSummary:l(),actionSummary:l(),safetyNotes:u(l()),requiredConfirmations:u(l()),canRunNow:o(),runNowBlockedReason:l().optional()});i({agentId:l().trim().min(1).max(64).optional(),language:f([`en`,`zh`]).default(`en`)}),p({draftId:l(),explanation:l(),assumptions:u(l()),risks:u(l()),automation:n({name:l(),trigger:c(),action:c()}),simulation:Ce,repairAttempts:s().int().nonnegative()}),p({draftId:l(),patch:r(l(),c()),explanation:l(),expectedEffect:l(),risks:u(l()),requiresApproval:o(),repairAttempts:s().int().nonnegative()});var we=i({eventId:l().min(1),kind:f([`note`,`task`,`project`,`automation`,`scene`,`local_app`]),id:l().min(1),revision:s().int().nonnegative(),operation:f([`created`,`updated`,`deleted`]),operationId:l().optional()}),G=i({id:l().trim().min(1).max(512)}),K=i({limit:s().int().min(1).max(100).default(50),afterId:l().max(200).default(``)});p({activation:z}),ve.extend({id:l().min(1).max(512)}),p({activation:z}),U.extend({revision:s().int().positive()}),be.extend({id:l().min(1).max(512)}),p({revision:s().int().positive()}),G.extend({read:o()}),p({ok:d(!0),presentationId:l(),read:o()}),G.extend({triggerKey:l().min(1).max(200),expectedRevision:s().int().nonnegative(),schedule:xe}),p({revision:s().int().positive()}),_e.extend({id:l().min(1).max(512)}),p({activation:z}),p({intentId:l()}),L.extend({id:l().min(1).max(512)}),p({revision:s().int().positive()}),B.extend({id:l().min(1).max(512)}),p({workItem:V}),ye.safeExtend({id:l().min(1).max(512)}),p({workItem:V});var q=n({id:l(),activationId:l(),outcomeId:l(),status:l(),content:c(),readOnly:o(),createdAt:s(),sources:u(p({kind:l(),title:l(),sender:l(),href:l()})),sourceHealth:r(l(),c()).nullable()});G.extend({expectedVersion:s().int().positive(),reason:l().trim().min(1).max(4096).default(`TaskRun cancelled`)}),G.extend({rating:f([`helpful`,`not_helpful`]),reason:l().trim().max(4096).optional()}),p({ok:d(!0),feedback:p({id:l(),runId:l(),rating:f([`helpful`,`not_helpful`]),reason:l().optional(),createdAt:s()})}),p({ok:d(!0),run:g,receipt:_,model:v.pick({task:!0,operationalState:!0,attention:!0,allowedCommands:!0}),executionStopConfirmed:d(!1)}),G.extend({enabled:o(),expectedRevision:s().int().nonnegative()}),p({ok:d(!0),automation:T.loose()}).extend({run:E.loose()}),p({ok:d(!0),cancelled:o(),confirmed:o()}),p({ok:d(!0),marked:d(!0)}),i({projectId:l().trim().min(1).max(512).optional()}),p({ok:d(!0),count:s().int().nonnegative()}),G.extend({expectedRevision:s().int().nonnegative().nullable()}),p({ok:d(!0),removed:o(),automation:T.loose().optional(),cancelRunId:l().optional()});var Te=i({status:f([`inbox`,`processed`,`archived`,`trashed`]).optional(),kind:f([`thought`,`todo`,`voice`,`media`,`bookmark`,`mixed`,`task`]).optional(),tag:l().max(512).optional(),projectId:l().min(1).max(512).optional(),unassigned:o().optional(),agentEdited:o().optional(),search:l().max(4096).optional(),pinned:o().optional(),limit:s().int().min(1).max(100).default(20),offset:s().int().min(0).default(0),sortBy:f([`createdAt`,`updatedAt`,`lastOpenedAt`]).optional(),sortOrder:f([`asc`,`desc`]).optional()}),J=n({id:l().min(1),markdown:l(),kind:f([`thought`,`todo`,`voice`,`media`,`bookmark`,`mixed`,`task`]),status:f([`inbox`,`processed`,`archived`,`trashed`]),createdAt:s(),updatedAt:s(),title:l().optional(),localVersion:s().optional()}),Ee=p({note:J});G.extend({expectedRevision:s().int().positive(),revokeShares:o().default(!0)}),p({deleted:d(!0),revokedShares:s().int().nonnegative()});var De=i({title:l().max(1e3).optional(),markdown:l().max(2e6).default(``),kind:J.shape.kind.optional(),tags:u(l().max(512)).max(100).optional(),capturedVia:i({channel:f([`app`,`web`,`electron`,`tui`,`telegram`,`wechat`,`feishu`]),platform:f([`ios`,`android`,`harmonyos`]).optional()}).default({channel:`web`}),pinned:o().default(!1),projectId:l().min(1).optional()});i({id:l().min(1),expectedRevision:s().int().positive(),trigger:f([`edit`,`ai_edit`,`sync`,`restore`]).optional(),patch:i({title:l().max(1e3).optional(),markdown:l().max(2e6).optional(),tags:u(l().max(512)).max(100).optional(),pinned:o().optional(),kind:J.shape.kind.optional(),status:J.shape.status.optional(),localVersion:s().int().positive().optional(),ai:r(l(),c()).optional(),aiDeep:n({processedAt:s()}).optional()})}),i({text:l().trim().min(1).max(2e6),capturedVia:De.shape.capturedVia}),i({id:l().min(1),expectedRevision:s().int().positive().optional(),content:l().trim().min(1).max(2e6),heading:l().trim().min(1).max(1e3).default(`AI 讨论沉淀`)}),i({id:l().min(1),timestamp:s().int().positive(),expectedRevision:s().int().positive()});var Oe=n({items:u(n({id:l().min(1)})),total:s().int().nonnegative()}),ke=i({phase:re.optional(),priority:h.optional(),projectId:l().min(1).max(512).optional(),search:l().max(4096).optional(),limit:s().int().min(1).max(200).default(50),offset:s().int().nonnegative().default(0)}),Y=n({id:l().min(1),name:l(),slug:l(),status:f([`planned`,`active`,`paused`,`completed`,`cancelled`,`archived`]),executionMode:f([`local_checkout`,`managed_worktree`]),successCriteria:u(l()),scope:r(l(),a()),nonGoals:u(l()),health:f([`unknown`,`on_track`,`at_risk`,`off_track`]),version:s().int().positive(),createdAt:s(),updatedAt:s(),workspaceRoot:l().optional(),defaultAgentId:l().optional()}),Ae=i({id:l().trim().min(1),expectedVersion:s().int().positive(),pinned:o()});p({ok:d(!0),project:Y}),i({workspacePath:l().trim().min(1).max(4096),agentId:l().trim().min(1).max(512).optional(),defaultAgentId:l().trim().max(512).optional(),projectKind:f([`auto`,`coding`,`general`,`unknown`]).optional(),autoCreate:o().default(!1),conversationId:e().optional()}),p({ok:d(!0),project:Y.nullable(),reason:f([`exact`,`contained`,`auto_created`]).optional(),created:o().optional()}),Ae.omit({pinned:!0}),p({ok:d(!0),deleted:d(!0),executionStopConfirmed:d(!1)});var X={name:l().trim().min(1).max(1e3).optional(),description:l().max(2e4).optional(),defaultAgentId:l().trim().max(512).optional(),workspaceRoot:l().trim().min(1).max(4096).optional(),createWorkspaceRoot:o().optional(),executionMode:Y.shape.executionMode.optional(),brief:l().max(2e4).optional(),instructions:l().max(1e5).optional(),outcome:l().max(2e4).optional(),successCriteria:u(l().max(4096)).max(100).optional(),scope:r(l(),c()).optional(),nonGoals:u(l().max(4096)).max(100).optional(),health:Y.shape.health.optional(),ownerId:l().max(512).optional(),targetAt:s().finite().optional()};i({...X,projectKind:f([`auto`,`coding`,`general`,`unknown`]).optional(),autoUnderstand:o().default(!1)}).refine(e=>!!(e.name||e.workspaceRoot),`name or workspaceRoot is required`),i({id:l().trim().min(1),expectedVersion:s().int().positive(),patch:i({...X,status:Y.shape.status.optional(),description:X.description.unwrap().nullable().optional(),defaultAgentId:X.defaultAgentId.unwrap().nullable().optional(),workspaceRoot:l().trim().max(4096).nullable().optional(),brief:X.brief.unwrap().nullable().optional(),instructions:X.instructions.unwrap().nullable().optional(),outcome:X.outcome.unwrap().nullable().optional(),ownerId:X.ownerId.unwrap().nullable().optional(),targetAt:X.targetAt.unwrap().nullable().optional()}).refine(e=>Object.values(e).some(e=>e!==void 0),`Empty project patch`)});var je=i({status:Y.shape.status.optional(),search:l().max(4096).optional(),sortBy:f([`updatedAt`,`createdAt`,`name`]).optional(),sortOrder:f([`asc`,`desc`]).optional(),limit:s().int().min(1).max(500).default(50),offset:s().int().nonnegative().default(0)}),Z=n({id:l(),projectId:l(),title:l(),status:f([`planned`,`active`,`completed`,`cancelled`]),sortOrder:s(),createdAt:s(),updatedAt:s()}),Q=n({id:l(),projectId:l(),summary:l(),health:Y.shape.health,createdAt:s()}),$={title:l().trim().min(1).max(1e3),description:l().max(2e4).optional(),status:Z.shape.status.optional(),targetAt:s().int().nonnegative().optional(),sortOrder:s().int().optional()};i({projectId:l().trim().min(1),...$}),i({projectId:l().trim().min(1),id:l().trim().min(1),expectedRevision:s().int().nonnegative(),patch:i({...$,description:l().max(2e4).nullable().optional(),targetAt:s().int().nonnegative().nullable().optional()}).partial().refine(e=>Object.values(e).some(e=>e!==void 0),`Empty milestone patch`)}).omit({patch:!0}),p({ok:d(!0),milestone:Z,project:Y}),p({ok:d(!0),deleted:d(!0)}),i({projectId:l().trim().min(1),expectedVersion:s().int().positive(),health:Y.shape.health,summary:l().trim().min(1).max(2e4),progress:u(l().max(1e4)).max(100).default([]),risks:u(l().max(1e4)).max(100).default([]),nextSteps:u(l().max(1e4)).max(100).default([])}),p({ok:d(!0),update:Q,project:Y});var Me={"xopc.context.resolve":{input:k,output:me},"xopc.notes.preview_edit":{input:G.extend({instruction:l().trim().min(1).max(16e3),markdown:l().max(2e6).optional()}),output:p({message:l(),patch:p({id:l(),summary:l(),operations:u(p({type:d(`replaceRange`),from:s().int().nonnegative(),to:s().int().nonnegative(),markdown:l()}))})})},"xopc.automations.get_run":{input:G,output:p({ok:d(!0),run:E.loose()})},"xopc.automations.run_events":{input:G,output:p({ok:d(!0),events:u(D.loose())})},"xopc.automations.metrics":{input:i({}),output:p({ok:d(!0),metrics:pe})},"xopc.automations.product_events":{input:i({eventType:l().trim().min(1).max(512),source:l().trim().min(1).max(512).optional(),payloadKey:l().trim().min(1).max(512).optional(),payloadValue:l().max(4096).optional(),limit:s().int().min(1).max(100).default(10)}).refine(e=>e.payloadKey===void 0==(e.payloadValue===void 0),`payloadKey and payloadValue must be supplied together`),output:p({ok:d(!0),items:u(p({run:E.loose(),triggerEvent:D.loose()}))})},"xopc.automations.list":{input:i({projectId:l().trim().min(1).optional()}),output:p({ok:d(!0),items:u(T.loose()),projectId:l().optional()})},"xopc.automations.get":{input:G,output:p({ok:d(!0),automation:T.loose()})},"xopc.automations.history":{input:i({automationId:l().trim().min(1).optional(),projectId:l().trim().min(1).optional(),limit:s().int().min(1).max(200).default(50)}),output:p({ok:d(!0),items:u(E.loose()),projectId:l().optional()})},"xopc.scenes.templates":{input:i({}),output:p({templates:u(F)})},"xopc.scenes.mail_accounts":{input:i({}),output:p({accounts:u(p({id:l(),label:l()}))})},"xopc.scenes.mail_sources":{input:K,output:p({sources:u(p({id:l(),accountId:l(),subject:l(),sender:l()})),nextCursor:l().nullable()})},"xopc.scenes.results":{input:K.extend({activationId:l().min(1).max(200).optional()}),output:p({outcomes:u(q),nextCursor:l().nullable()})},"xopc.scenes.get_presentation":{input:G,output:p({outcome:q})},"xopc.scenes.get_feedback":{input:G,output:p({feedback:p({rating:f([`useful`,`not_useful`]),note:l(),revision:s().int().nonnegative()}).nullable()})},"xopc.scenes.digest_results":{input:K.extend({id:l().min(1).max(512)}),output:p({outcomes:u(q),nextCursor:l().nullable()})},"xopc.scenes.metrics":{input:i({days:s().int().min(1).max(90).default(7)}),output:p({window:p({since:s(),until:s(),days:s().int()}),ratedOutcomes:s().int().nonnegative(),usefulOutcomes:s().int().nonnegative(),unhelpfulOutcomes:s().int().nonnegative(),scenesWithUsefulOutcomes:s().int().nonnegative(),checks:s().int().nonnegative(),failedChecks:s().int().nonnegative(),skippedChecks:s().int().nonnegative()})},"xopc.scenes.diagnostics":{input:i({}),output:p({checksPaused:o(),currentModel:l().nullable(),pendingChecks:s().int().nonnegative(),oldestDueWaitMs:s().nonnegative(),lastSevenDays:p({modelCalls:s().int().nonnegative(),connectorReads:s().int().nonnegative(),tokens:s().nonnegative(),estimatedCost:s().nonnegative()}),notifications:u(p({status:l(),count:s().int().nonnegative()})),activations:u(r(l(),c()))})},"xopc.scenes.get_preferences":{input:i({}),output:U.extend({revision:s().int().nonnegative()})},"xopc.scenes.preflight":{input:R,output:p({ready:o(),missing:u(l())})},"xopc.scenes.get_template":{input:i({key:l().min(1).max(200),version:l().min(1).max(200)}),output:p({template:F})},"xopc.scenes.list":{input:K,output:p({activations:u(z),nextCursor:l().nullable()})},"xopc.scenes.get":{input:G,output:p({activation:z,runs:u(n({id:l(),status:l(),attempt:s().int(),reason:l().nullable(),createdAt:s()})),schedules:u(n({triggerKey:l(),revision:s().int(),nextDueAt:s(),schedule:c()}))})},"xopc.scenes.read_notes":{input:G,output:p({notes:p({content:l(),revision:s().int().nonnegative(),validUntil:s().nullable()})})},"xopc.scenes.list_runs":{input:K.extend({id:l().min(1).max(512)}),output:p({runs:u(n({id:l(),activationId:l(),status:l(),attempt:s().int(),reason:l().nullable(),createdAt:s()})),nextCursor:l().nullable()})},"xopc.scenes.list_schedules":{input:G,output:p({schedules:u(n({triggerKey:l(),revision:s().int(),nextDueAt:s(),schedule:c()}))})},"xopc.scenes.list_work_items":{input:K.extend({id:l().min(1).max(512)}),output:p({workItems:u(n({id:l(),subjectId:l(),accountId:l(),dueAt:s(),status:l(),revision:s().int(),lastCheckReason:l().nullable()})),nextCursor:l().nullable()})},"xopc.settings.open":{input:i({section:l().trim().regex(/^[a-z0-9][a-z0-9/_-]*$/i).max(512).default(`overview`),title:l().trim().min(1).max(512).default(`Settings`),summary:l().trim().max(4096).optional()}),output:p({ok:d(!0),settings:p({section:l(),title:l(),summary:l().optional()})})},"xopc.local_apps.list":{input:i({}),output:p({apps:u(y)})},"xopc.local_apps.get":{input:G,output:p({app:se})},"xopc.local_apps.validate":{input:G,output:p({validation:oe})},"xopc.projects.get":{input:G,output:p({ok:d(!0),project:Y})},"xopc.projects.list":{input:je,output:n({ok:d(!0),items:u(Y),total:s().int().nonnegative()})},"xopc.projects.list_milestones":{input:G,output:p({ok:d(!0),projectId:l(),items:u(Z)})},"xopc.projects.list_updates":{input:G.extend({limit:s().int().min(1).max(500).default(20)}),output:p({ok:d(!0),projectId:l(),items:u(Q)})},"xopc.task_runs.get":{input:G,output:p({ok:d(!0),run:g,receipt:_.optional(),events:u(ne),activeWaits:u(m)})},"xopc.task_runs.list":{input:i({taskId:l().trim().min(1),limit:s().int().min(1).max(200).default(20)}),output:p({ok:d(!0),taskId:l(),items:u(g),receipts:u(_),activeWaits:u(m)})},"xopc.notes.project_summaries":{input:i({}),output:p({items:u(p({id:l(),name:l(),description:l().optional(),noteCount:s().int().nonnegative(),updatedAt:s().optional()}))})},"xopc.notes.history":{input:G,output:p({entries:u(p({timestamp:s().int().nonnegative(),trigger:f([`edit`,`ai_edit`,`sync`,`restore`]),snippet:l().optional()}))})},"xopc.notes.snapshot":{input:G.extend({timestamp:s().int().nonnegative()}),output:p({snapshot:p({noteId:l(),timestamp:s().int().nonnegative(),trigger:f([`edit`,`ai_edit`,`sync`,`restore`]),title:l().optional(),markdown:l(),tags:u(l()).optional(),kind:J.shape.kind,status:J.shape.status})})},"xopc.notes.get":{input:G,output:Ee},"xopc.notes.list":{input:Te,output:Oe},"xopc.tasks.metrics":{input:i({}),output:p({ok:d(!0),metrics:ue})},"xopc.tasks.get":{input:G,output:v},"xopc.tasks.list":{input:ke,output:ae.extend({total:s().int().nonnegative()})}};export{de as a,he as i,Me as n,we as r,Se as t};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{f as i,m as a}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{t as o}from"./popover-select-B-GDnZO9.js";import{t as s}from"./circle-check-C23XjkUj.js";import{t as c}from"./x-B_N4OPjy.js";import{t as l}from"./cn-JdwAhgNB.js";import{a as u,c as d,i as f,n as p,r as m}from"./locale-store-BIkcRr3t.js";import{t as h}from"./messages-7VAhscYe.js";import{a as g,i as _,n as v,o as y,r as b,s as x,t as S}from"./dist-BGTk37IG.js";import{i as C}from"./vendor-swr-BIWyz7Rc.js";import{t as w}from"./button-CS04eWY9.js";import{t as T}from"./skeleton-BwbyijEw.js";import{i as E,o as D}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{t as O}from"./settings-shell-layer-context-BTQUDoJ2.js";import{Au as k,Cn as A,Dn as j,En as M,Fa as N,Io as P,Jc as F,Ks as ee,Ma as I,On as L,Pc as R,Rl as z,Tc as B,al as te,gi as ne,td as re,tl as ie,ya as ae}from"./index--3c0awkr.js";import{n as oe,r as se}from"./settings-page-layout-D3KNSQ5g.js";import{t as ce}from"./browser-BLJWD7WI.js";import{n as le}from"./settings-loading-skeleton-CAmWMaOT.js";import{t as ue}from"./schema-form-FQAit5HL.js";var V=e(t(),1),H=n();async function de(){return(await u(m(`/api/channels/status`))).payload?.channels||[]}function fe(){return m(`/api/channels/status`)}var pe=de;function me(e){let t=e.actions??{};for(let e of[`login.start`,`setup.start`]){let n=t[e];if(n?.result===`qr`)return[e,n]}let n=Object.entries(t).find(([,e])=>e.result===`qr`);if(n)return n;let r=e.ui?.card?.primaryAction;if(r&&t[r])return[r,t[r]];for(let e of[`login.start`,`setup.start`]){let n=t[e];if(n)return[e,n]}return Object.entries(t).find(([,e])=>e.result===`form`)??null}var he=e(ce(),1),U=r();async function W(e){let t=await f(m(`/api/channels/${encodeURIComponent(e.channelId)}/actions/${encodeURIComponent(e.actionId)}?locale=${encodeURIComponent(e.locale)}`),{method:`POST`,body:JSON.stringify({...e.accountId?{accountId:e.accountId}:{},...e.input===void 0?{}:{input:e.input}})}),n=await t.json().catch(()=>({}));if(!t.ok||n.ok===!1)throw Error(n.error?.message??t.statusText);return n.payload??{type:`ok`}}function G(e){return e?.type===`poll`&&e.phase===`done`}function K(e){return e&&`message`in e&&typeof e.message==`string`?e.message:null}function q(e,t){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrPayload?e.qrPayload:t===`weixin`&&e.qrcodeUrl?e.qrcodeUrl:null}function ge(e){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrcodeUrl??null}function _e({entry:e,locale:t,messages:n,onChanged:r,compact:i=!1}){let a=(0,V.useMemo)(()=>me(e),[e]),o=(0,V.useMemo)(()=>({defaultBooleanLabel:n.schemaBooleanDefault,unsupportedArrayType:n.schemaUnsupportedArrayType,arrayAddPlaceholder:n.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>n.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[n]),[c,u]=(0,V.useState)({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null});(0,V.useEffect)(()=>{u({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null})},[e.id]);let d=(0,V.useCallback)(async(n,i)=>{u(e=>({...e,busy:!0,error:null}));try{let a=await W({channelId:e.id,actionId:n,locale:t,input:i});u(e=>({...e,payload:a,poll:a.type===`qr`&&a.statusAction&&a.conversationId?{actionId:a.statusAction,conversationId:a.conversationId,intervalMs:Math.max(1e3,a.pollIntervalMs??2500)}:null,busy:!1,formDraft:a.type===`form`?a.values??{}:e.formDraft})),`configChanged`in a&&a.configChanged===!0&&await r()}catch(e){u(t=>({...t,busy:!1,error:e instanceof Error?e.message:String(e)}))}},[e.id,t,r]);(0,V.useEffect)(()=>{let t=q(c.payload,e.id);if(!t){u(e=>e.generatedQr?{...e,generatedQr:null}:e);return}let n=!1;return u(e=>e.generatedQr?{...e,generatedQr:null}:e),he.toDataURL(t,{width:220,margin:1}).then(e=>{n||u(t=>({...t,generatedQr:e}))}),()=>{n=!0}},[e.id,c.payload]),(0,V.useEffect)(()=>{let n=c.poll;if(!n)return;let i=!1,a=window.setInterval(()=>{i||W({channelId:e.id,actionId:n.actionId,locale:t,input:{conversationId:n.conversationId}}).then(async e=>{i||(u(t=>({...t,payload:e,poll:G(e)?null:t.poll,error:null})),`configChanged`in e&&e.configChanged===!0&&await r(),G(e)&&window.clearInterval(a))}).catch(e=>{i||u(t=>({...t,error:e instanceof Error?e.message:String(e)}))})},n.intervalMs);return()=>{i=!0,window.clearInterval(a)}},[e.id,t,r,c.poll]);let f=a?.[1].label??(e.configured?n.reconnect:n.connect),p=e.actions?.[`doctor.run`]?.label??n.diagnose,m=K(c.payload),h=q(c.payload,e.id),g=h?c.generatedQr:ge(c.payload),_=a?.[1].result===`qr`&&(c.busy||c.payload?.type===`qr`||c.payload?.type===`poll`),v=c.payload?.type===`form`?c.payload:null,y=c.payload?.type===`diagnostics`?c.payload.checks:null;return(0,U.jsxs)(`div`,{className:i?`space-y-3`:`rounded-lg bg-surface-panel/80 p-4 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:l(`flex flex-wrap items-start gap-3`,i?`justify-end`:`justify-between`),children:[i?null:(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.setupTitle}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.configured?n.setupConfiguredHint:n.setupEmptyHint})]}),(0,U.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[a?(0,U.jsxs)(w,{type:`button`,variant:`primary`,disabled:c.busy,onClick:()=>void d(a[0]),children:[c.busy?(0,U.jsx)(z,{className:`size-4 animate-spin`}):(0,U.jsx)(te,{className:`size-4`}),f]}):null,e.actions?.[`doctor.run`]?(0,U.jsxs)(w,{type:`button`,variant:`secondary`,disabled:c.busy,onClick:()=>void d(`doctor.run`),children:[(0,U.jsx)(R,{className:`size-4`}),p]}):null]})]}),m?(0,U.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:m}):null,c.error?(0,U.jsx)(`p`,{className:`mt-3 text-sm text-red-600 dark:text-red-400`,children:c.error}):null,_?(0,U.jsxs)(`div`,{className:l(`flex h-80 items-center justify-center gap-4 overflow-hidden rounded-lg bg-surface-base p-3 shadow-surface`,i?`mt-1 flex-col text-center sm:h-64 sm:flex-row sm:text-left`:`mt-4 flex-col sm:h-64 sm:flex-row`),children:[(0,U.jsx)(`div`,{className:`flex size-56 shrink-0 items-center justify-center rounded-lg border border-edge bg-white p-3`,children:g?(0,U.jsx)(`img`,{src:g,alt:`${e.label} setup QR`,className:`size-52 object-contain`}):(0,U.jsx)(`div`,{className:`flex size-52 items-center justify-center rounded-md bg-surface-base`,children:(0,U.jsx)(T,{className:`size-48 rounded-md`})})}),(0,U.jsxs)(`div`,{className:l(`min-w-0 max-w-sm text-sm text-fg-muted`,i&&`w-full sm:w-auto`),children:[g?(0,U.jsx)(`p`,{className:`line-clamp-3`,children:n.waitingConfirmation}):(0,U.jsxs)(`div`,{className:`space-y-2`,"aria-busy":`true`,children:[(0,U.jsx)(T,{className:`h-4 w-48 max-w-full`}),(0,U.jsx)(T,{className:`h-4 w-36 max-w-full`})]}),h?(0,U.jsxs)(`a`,{className:`mt-2 inline-flex items-center gap-1 text-accent hover:underline`,href:h,target:`_blank`,rel:`noreferrer`,children:[n.openSetupLink,(0,U.jsx)(k,{className:`size-3.5`})]}):null]})]}):null,c.payload?.type===`poll`&&c.payload.phase===`done`?(0,U.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 rounded-lg bg-surface-base px-3 py-2 text-sm shadow-surface`,children:[(0,U.jsx)(s,{className:c.payload.ok?`size-4 text-green-600`:`size-4 text-red-600`}),(0,U.jsx)(`span`,{className:c.payload.ok?`text-fg`:`text-red-600 dark:text-red-400`,children:c.payload.message??(c.payload.ok?n.complete:n.failed)})]}):null,v?(0,U.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,U.jsx)(ue,{schema:v.schema,values:c.formDraft,onChange:e=>u(t=>({...t,formDraft:e})),disabled:c.busy,labels:o}),(0,U.jsx)(w,{type:`button`,variant:`primary`,disabled:c.busy,onClick:()=>void d(v.submitAction,c.formDraft),children:n.saveSetup})]}):null,y?(0,U.jsx)(`div`,{className:`mt-4 space-y-2`,children:y.map((e,t)=>(0,U.jsxs)(`div`,{className:`rounded-lg bg-surface-base px-3 py-2 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,U.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.label??e.id??n.diagnosticCheckFallback.replace(`{{index}}`,String(t+1))}),(0,U.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e.status??`unknown`})]}),e.message?(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.message}):null]},e.id??t))}):null]})}var J=40;function ve(e){return`ui:route:channel:${e.trim().toLowerCase()}`}function ye(e,t){return e.find(e=>e.id===ve(t))?.agentId?.trim().toLowerCase()??``}function be(e,t,n){let r=ve(t),i=e.filter(e=>e.id!==r),a=n.trim().toLowerCase();return a?[...i,{id:r,agentId:a,priority:J,enabled:!0,match:{channel:t.trim().toLowerCase(),accountId:`*`}}]:i}function xe(e){let t=e.configured===!0,n=e.enabled===!0;return e.setupStatus??{enabled:n,ready:t,state:n&&!t?`needs_setup`:n?`ready`:`disabled`,issues:[]}}function Se(e,t,n){let r=xe(e);return r.ready?r.enabled?n?t?.connected===!0?`running`:`stopped`:`checking`:`disabled`:`needs_setup`}function Ce(e,t=!1){return e===`drawer`?l(`xopc-drawer-right fixed right-0 top-0 flex size-full flex-col overflow-hidden border-l border-edge bg-surface-overlay shadow-popover outline-none dark:border-edge`,t?`max-w-[36rem]`:`max-w-xl`,E):l(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(calc(100dvh-2rem),52rem)] w-[min(calc(100%-2rem),32rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,t&&`h-[min(calc(100dvh-2rem),48rem)] w-[min(calc(100%-2rem),36rem)]`,E,`rounded-2xl border border-edge bg-surface-overlay outline-none dark:border-edge`)}function we(e){let t=(0,H.c)(33),{presentation:n,open:r,onOpenChange:i,title:a,description:o,srTitle:s,srDescription:u,closeAriaLabel:d,children:f,footer:p,wide:m,headerExtra:h}=e,C=m===void 0?!1:m,T=n===`drawer`,[E,k]=(0,V.useState)(null),A;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(A=(0,U.jsx)(g,{className:l(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,D)}),t[0]=A):A=t[0];let j;t[1]!==n||t[2]!==C?(j=Ce(n,C),t[1]=n,t[2]=C,t[3]=j):j=t[3];let M;t[4]===s?M=t[5]:(M=s?(0,U.jsx)(x,{className:`sr-only`,children:s}):null,t[4]=s,t[5]=M);let N;t[6]===u?N=t[7]:(N=u?(0,U.jsx)(_,{className:`sr-only`,children:u}):null,t[6]=u,t[7]=N);let P;t[8]!==d||t[9]!==o||t[10]!==h||t[11]!==T||t[12]!==a?(P=T?(0,U.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[a?(0,U.jsx)(`div`,{className:`text-base font-semibold text-fg`,children:a}):null,o?(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:o}):null]}),(0,U.jsx)(v,{asChild:!0,children:(0,U.jsx)(w,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":d,children:(0,U.jsx)(c,{className:`size-5`,strokeWidth:1.75})})})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(v,{asChild:!0,children:(0,U.jsx)(`button`,{type:`button`,className:l(ee,`absolute right-3 top-3 z-20 p-1.5 hover:bg-surface-hover`),"aria-label":d,children:(0,U.jsx)(c,{className:`size-4`})})}),h]}),t[8]=d,t[9]=o,t[10]=h,t[11]=T,t[12]=a,t[13]=P):P=t[13];let F=T?`p-4`:`p-6`,I;t[14]===F?I=t[15]:(I=l(`min-h-0 flex-1 overflow-y-auto`,F),t[14]=F,t[15]=I);let L;t[16]!==f||t[17]!==I?(L=(0,U.jsx)(`div`,{className:I,children:f}),t[16]=f,t[17]=I,t[18]=L):L=t[18];let R;t[19]!==p||t[20]!==E||t[21]!==M||t[22]!==N||t[23]!==P||t[24]!==L?(R=(0,U.jsxs)(O,{layer:`modal`,portalContainer:E,children:[M,N,P,L,p]}),t[19]=p,t[20]=E,t[21]=M,t[22]=N,t[23]=P,t[24]=L,t[25]=R):R=t[25];let z;t[26]!==R||t[27]!==j?(z=(0,U.jsxs)(y,{children:[A,(0,U.jsx)(b,{ref:k,className:j,onOpenAutoFocus:Te,children:R})]}),t[26]=R,t[27]=j,t[28]=z):z=t[28];let B;return t[29]!==i||t[30]!==r||t[31]!==z?(B=(0,U.jsx)(S,{open:r,onOpenChange:i,children:z}),t[29]=i,t[30]=r,t[31]=z,t[32]=B):B=t[32],B}function Te(e){return e.preventDefault()}var Ee=(0,V.memo)(function(e){let t=(0,H.c)(10),{ch:n,refreshing:r,saveOk:i,onRefresh:a}=e,o;t[0]!==n.saved||t[1]!==i?(o=i?(0,U.jsx)(`span`,{className:`text-sm text-fg-muted`,children:n.saved}):null,t[0]=n.saved,t[1]=i,t[2]=o):o=t[2];let s;t[3]!==n.refresh||t[4]!==a||t[5]!==r?(s=(0,U.jsx)(ae,{className:`size-9 shrink-0 p-0`,loading:r,label:n.refresh,onClick:a}),t[3]=n.refresh,t[4]=a,t[5]=r,t[6]=s):s=t[6];let c;return t[7]!==o||t[8]!==s?(c=(0,U.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center justify-end gap-2`,children:[o,s]}),t[7]=o,t[8]=s,t[9]=c):c=t[9],c});function De(e){let t=(0,H.c)(24),{ch:n,dirty:r,saving:i,onCancel:a,onDiscard:o,onSave:s,showCancel:c}=e,l=c===void 0?!0:c,u;t[0]!==n.unsavedHint||t[1]!==r?(u=r?(0,U.jsx)(`p`,{className:`mb-3 text-xs text-amber-800 dark:text-amber-200`,children:n.unsavedHint}):null,t[0]=n.unsavedHint,t[1]=r,t[2]=u):u=t[2];let d;t[3]!==n.modalCancel||t[4]!==a||t[5]!==l?(d=l?(0,U.jsx)(w,{type:`button`,variant:`secondary`,onClick:a,children:n.modalCancel}):null,t[3]=n.modalCancel,t[4]=a,t[5]=l,t[6]=d):d=t[6];let f=!r||i,p;t[7]!==n.discard||t[8]!==o||t[9]!==f?(p=(0,U.jsx)(w,{type:`button`,variant:`secondary`,disabled:f,onClick:o,children:n.discard}),t[7]=n.discard,t[8]=o,t[9]=f,t[10]=p):p=t[10];let m=!r||i,h;t[11]===s?h=t[12]:(h=()=>void s(),t[11]=s,t[12]=h);let g=i?n.saving:n.save,_;t[13]!==m||t[14]!==h||t[15]!==g?(_=(0,U.jsx)(w,{type:`button`,variant:`primary`,disabled:m,onClick:h,children:g}),t[13]=m,t[14]=h,t[15]=g,t[16]=_):_=t[16];let v;t[17]!==d||t[18]!==p||t[19]!==_?(v=(0,U.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[d,p,_]}),t[17]=d,t[18]=p,t[19]=_,t[20]=v):v=t[20];let y;return t[21]!==v||t[22]!==u?(y=(0,U.jsxs)(`div`,{className:`sticky bottom-0 shrink-0 border-t border-edge-subtle bg-surface-panel px-6 py-4 dark:border-edge-subtle`,children:[u,v]}),t[21]=v,t[22]=u,t[23]=y):y=t[23],y}function Oe(e){return m(`/api/channels/catalog?locale=${encodeURIComponent(e)}`)}async function ke(e){return(await u(Oe(e))).payload?.channels??[]}function Ae(e,t){let n=(0,H.c)(14),r;n[0]!==e||n[1]!==t?(r=e?Oe(t):null,n[0]=e,n[1]=t,n[2]=r):r=n[2];let i;n[3]===t?i=n[4]:(i=()=>ke(t),n[3]=t,n[4]=i);let a;n[5]===Symbol.for(`react.memo_cache_sentinel`)?(a={revalidateOnFocus:!1},n[5]=a):a=n[5];let{data:o,error:s,isLoading:c,isValidating:l,mutate:u}=C(r,i,a),d;n[6]===o?d=n[7]:(d=o??[],n[6]=o,n[7]=d);let f;return n[8]!==s||n[9]!==c||n[10]!==l||n[11]!==u||n[12]!==d?(f={entries:d,isLoading:c,isValidating:l,error:s,mutate:u},n[8]=s,n[9]=c,n[10]=l,n[11]=u,n[12]=d,n[13]=f):f=n[13],f}var je=`channels-status`;function Me(e){if(!e||typeof e!=`object`)return null;let t=e.channels;return Array.isArray(t)?t:null}function Ne(e){let t=t=>e(t.detail);return window.addEventListener(je,t),()=>window.removeEventListener(je,t)}function Pe(e,t){let n=(0,H.c)(4),r=t===void 0?!0:t,i,a;n[0]!==r||n[1]!==e?(i=()=>{if(r)return Ne(e)},a=[r,e],n[0]=r,n[1]=e,n[2]=i,n[3]=a):(i=n[2],a=n[3]),(0,V.useEffect)(i,a)}function Fe(e){return e?m(`/api/channels/${encodeURIComponent(e)}/config`):null}async function Ie(e){return(await u(m(`/api/channels/${encodeURIComponent(e)}/config`))).payload?.config??{}}var Le=[`enabled`];async function Re(){let e=await u(m(`/api/config`));return{channels:e.payload?.config?.channels??{},bindings:e.payload?.config?.bindings??[]}}function ze(e){return e.split(`/`).filter(Boolean).map(e=>encodeURIComponent(e)).join(`/`)}function Be(e){return e.configPath.startsWith(`channels.`)&&e.configPath.slice(9).split(`.`)[0]||e.id}function Y(e){let t=e.configured===!0,n=e.enabled===!0;return e.setupStatus??{enabled:n,ready:t,state:n&&!t?`needs_setup`:n?`ready`:`disabled`,issues:[]}}function Ve(e,t){return e===`running`?t.connectionRunning:e===`stopped`?t.connectionStopped:e===`checking`?t.connectionChecking:e===`disabled`?t.connectionDisabled:t.connectionNeedsSetup}function He(e,t){return e===`running`?t.connectionRunningHint:e===`stopped`?t.connectionStoppedHint:e===`disabled`?t.connectionDisabledHint:e===`needs_setup`?t.connectionNeedsSetupHint:t.connectionChecking}function Ue(e){return e===`running`?`bg-emerald-500/12 text-emerald-700 dark:text-emerald-300`:e===`stopped`?`bg-red-500/10 text-red-700 dark:text-red-300`:e===`checking`?`bg-amber-500/10 text-amber-700 dark:text-amber-300`:e===`disabled`?`bg-surface-hover text-fg-muted`:`bg-amber-500/10 text-amber-700 dark:text-amber-300`}function We(e){if(!e)return[];let t=e.uiHints??{},n=X(e.configSchema)&&Array.isArray(e.configSchema.required)?e.configSchema.required.map(String):[],r=Y(e).issues.map(e=>e.fieldPath).filter(e=>!!e),i=Object.entries(t).filter(([,e])=>!X(e)||e.advanced===!0?!1:(Array.isArray(e.tags)?e.tags.map(String):[]).includes(`basic`)||e.advanced===!1).map(([e])=>e).filter(e=>!Le.includes(e));return Array.from(new Set([...i,...n,...r])).filter(e=>!Le.includes(e))}function X(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Z(e){return JSON.parse(JSON.stringify(e??{type:`object`,properties:{}}))}function Ge(e,t){let n={...Z(e),properties:{}};for(let r of t){let t=r.split(`.`),i=e,a=n;for(let[e,n]of t.entries()){let r=i.properties;if(!X(r)||!X(r[n]))break;let o=X(a.properties)?a.properties:{};if(a.properties=o,o[n]||(o[n]={...Z(r[n]),properties:{}}),e===t.length-1){o[n]=Z(r[n]);break}i=r[n],a=o[n]}}return n}function Ke(e){let t=e.properties;if(!X(t))return!1;for(let[e,n]of Object.entries(t))X(n)&&n.type===`object`&&Ke(n)&&delete t[e];return Object.keys(t).length===0}function qe(e,t){let n=Z(e);for(let e of t){let t=e.split(`.`),r=n;for(let[e,n]of t.entries()){let i=r.properties;if(!X(i))break;if(e===t.length-1){delete i[n];break}if(!X(i[n]))break;r=i[n]}}return Ke(n),n}function Je(e){return e.type===`object`&&X(e.properties)&&Object.keys(e.properties).length>0}function Ye(e,t){let n=e;for(let e of t.split(`.`)){if(!X(n))return;n=n[e]}return n}function Q(e){let t=e.accounts;return X(t)?Object.values(t).filter(e=>X(e)&&e.enabled!==!1).length:+(e.configured===!0)}function Xe(e,t,n){return t==null||t===``?null:e.toLowerCase().includes(`dmpolicy`)&&typeof t==`string`?`${n.dmPolicy}: ${n.policy.dm[t]??t}`:(e.toLowerCase().includes(`stream`)||e.toLowerCase().includes(`streaming`))&&typeof t==`string`?`${n.cardStream}: ${n.policy.stream[t]??t}`:typeof t==`boolean`?t?n.enabledLabel:n.disabledLabel:String(t)}function Ze(e,t,n){let r=[],i=Y(e);if(i.issues.length>0&&r.push(tt(i.issues[0],n)),t){let i=e.ui?.card?.summaryFields??[`dmPolicy`,`streamMode`,`streaming.mode`];for(let e of i){let i=Xe(e,Ye(t,e),n);i&&r.push(i)}let a=Q(t);a>0&&r.push(n.cardAccounts.replace(`{{count}}`,String(a)))}return r.length>0?r.slice(0,2):i.ready?[n.hubStatusConfigured]:[]}function Qe(e,t){let n=Y(e),r=me(e);return n.state===`needs_setup`?r?.[1].label??t.completeSetup:!n.enabled&&n.ready?t.enableChannel:n.state===`error`?t.diagnose:n.ready?t.manageChannel:r?.[1].label??t.startConfiguration}function $e(e,t){let n=me(e);return n?.[1].result===`qr`?t.cardSetupQrHint:n?.[1].result===`form`?t.cardSetupConfigHint:t.cardSetupGenericHint}function et(e,t){let n=e.capabilities??{},r=[];return n.login===!0&&r.push(t.cardCapabilityLogin),n.pairing===!0&&r.push(t.cardCapabilityPairing),n.multiAccount===!0&&r.push(t.cardCapabilityMultiAccount),n.streaming===!0&&r.push(t.cardCapabilityStreaming),n.media===!0&&r.push(t.cardCapabilityMedia),n.doctor===!0&&r.push(t.cardCapabilityDoctor),r.slice(0,3)}function tt(e,t){return e.code===`telegram.missing_credential`?t.setupIssueTelegramMissingCredential:e.code===`weixin.missing_account`?t.setupIssueWeixinMissingAccount:e.code===`feishu.missing_credentials`?t.setupIssueFeishuMissingCredentials:e.code===`config.missing_required`&&e.fieldPath?t.setupIssueMissingRequired.replace(`{{field}}`,e.fieldPath):e.message}function nt({entry:e}){let[t,n]=(0,V.useState)(!1),r=(0,V.useMemo)(()=>!e.ui?.icon||t?null:new URL(m(`/api/extensions/${encodeURIComponent(e.extensionId)}/assets/${ze(e.ui.icon)}`)).toString(),[t,e.extensionId,e.ui?.icon]);return(0,U.jsx)(`span`,{className:`flex size-12 shrink-0 items-center justify-center rounded-2xl bg-surface-base text-fg`,children:r?(0,U.jsx)(`img`,{src:r,alt:``,draggable:!1,className:`size-7`,"aria-hidden":!0,onError:()=>n(!0)}):(0,U.jsx)(N,{sourceChannel:e.id,className:`size-7`})})}function rt(e){let t=(0,H.c)(16),{checked:n,disabled:r,onToggle:i,label:a}=e,o;t[0]===i?o=t[1]:(o=e=>{e.stopPropagation(),i()},t[0]=i,t[1]=o);let s=n?`border-accent bg-accent`:`border-edge bg-surface-hover`,c=r&&`cursor-not-allowed opacity-60`,u;t[2]!==s||t[3]!==c?(u=l(`relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border transition-colors`,s,c),t[2]=s,t[3]=c,t[4]=u):u=t[4];let d=n?`translate-x-5`:`translate-x-0.5`,f;t[5]===d?f=t[6]:(f=l(`size-5 rounded-full bg-white shadow-surface transition-transform`,d),t[5]=d,t[6]=f);let p;t[7]===f?p=t[8]:(p=(0,U.jsx)(`span`,{className:f}),t[7]=f,t[8]=p);let m;return t[9]!==n||t[10]!==r||t[11]!==a||t[12]!==o||t[13]!==u||t[14]!==p?(m=(0,U.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":n,"aria-label":a,disabled:r,onClick:o,className:u,children:p}),t[9]=n,t[10]=r,t[11]=a,t[12]=o,t[13]=u,t[14]=p,t[15]=m):m=t[15],m}function it(e){let t=(0,H.c)(71),{entry:n,config:r,runtime:i,busy:a,restarting:o,ch:s,onOpen:c,onToggle:u,onRestart:d}=e,f;t[0]===n?f=t[1]:(f=Y(n),t[0]=n,t[1]=f);let p=f,m,h,g,_,v,y,b;if(t[2]!==a||t[3]!==s||t[4]!==r||t[5]!==n||t[6]!==c||t[7]!==d||t[8]!==u||t[9]!==i||t[10]!==p.enabled||t[11]!==p.ready){let e=Ze(n,r,s),o=et(n,s);m=!p.enabled&&p.ready?u:i===`stopped`?d:c,y=`flex min-h-[15.5rem] flex-col rounded-xl bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45`;let f;t[19]===n?f=t[20]:(f=(0,U.jsx)(nt,{entry:n}),t[19]=n,t[20]=f);let x;t[21]===n.label?x=t[22]:(x=(0,U.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:n.label}),t[21]=n.label,t[22]=x);let S;t[23]===i?S=t[24]:(S=l(`mt-1 inline-flex rounded-full px-2 py-0.5 text-xs font-medium`,Ue(i)),t[23]=i,t[24]=S);let C;t[25]!==s||t[26]!==i?(C=Ve(i,s),t[25]=s,t[26]=i,t[27]=C):C=t[27];let w;t[28]!==S||t[29]!==C?(w=(0,U.jsx)(`span`,{className:S,children:C}),t[28]=S,t[29]=C,t[30]=w):w=t[30];let T;t[31]!==w||t[32]!==x?(T=(0,U.jsxs)(`div`,{className:`min-w-0`,children:[x,w]}),t[31]=w,t[32]=x,t[33]=T):T=t[33];let E;t[34]!==T||t[35]!==f?(E=(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[f,T]}),t[34]=T,t[35]=f,t[36]=E):E=t[36];let D=p.enabled,O;t[37]!==s.toggleChannel||t[38]!==n.label?(O=s.toggleChannel.replace(`{{channel}}`,n.label),t[37]=s.toggleChannel,t[38]=n.label,t[39]=O):O=t[39];let k;t[40]!==a||t[41]!==u||t[42]!==p.enabled||t[43]!==O?(k=(0,U.jsx)(rt,{checked:D,disabled:a,label:O,onToggle:u}),t[40]=a,t[41]=u,t[42]=p.enabled,t[43]=O,t[44]=k):k=t[44],t[45]!==E||t[46]!==k?(b=(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[E,k]}),t[45]=E,t[46]=k,t[47]=b):b=t[47],h=`button`,g=c,_=`mt-5 min-h-[6.25rem] text-left`,v=p.ready?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`p`,{className:`line-clamp-2 text-sm leading-6 text-fg-muted`,children:n.description??n.id}),e.length>0?(0,U.jsx)(`div`,{className:`mt-3 space-y-0.5 text-sm leading-5 text-fg-muted`,children:e.map(at)}):null]}):(0,U.jsxs)(`div`,{className:`rounded-lg bg-surface-base p-3`,children:[(0,U.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:s.cardSetupTitle}),(0,U.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm leading-5 text-fg-muted`,children:e[0]??$e(n,s)}),o.length>0?(0,U.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:o.map($)}):null]}),t[2]=a,t[3]=s,t[4]=r,t[5]=n,t[6]=c,t[7]=d,t[8]=u,t[9]=i,t[10]=p.enabled,t[11]=p.ready,t[12]=m,t[13]=h,t[14]=g,t[15]=_,t[16]=v,t[17]=y,t[18]=b}else m=t[12],h=t[13],g=t[14],_=t[15],v=t[16],y=t[17],b=t[18];let x;t[48]!==h||t[49]!==g||t[50]!==_||t[51]!==v?(x=(0,U.jsx)(`button`,{type:h,onClick:g,className:_,children:v}),t[48]=h,t[49]=g,t[50]=_,t[51]=v,t[52]=x):x=t[52];let S=a||o,C;t[53]!==a||t[54]!==o?(C=a||o?(0,U.jsx)(z,{className:`size-4 animate-spin`}):null,t[53]=a,t[54]=o,t[55]=C):C=t[55];let T;t[56]!==s||t[57]!==n||t[58]!==o||t[59]!==i?(T=o?s.restartingChannel:i===`stopped`?s.restartChannel:Qe(n,s),t[56]=s,t[57]=n,t[58]=o,t[59]=i,t[60]=T):T=t[60];let E;t[61]!==m||t[62]!==C||t[63]!==T||t[64]!==S?(E=(0,U.jsx)(`div`,{className:`mt-auto pt-4`,children:(0,U.jsxs)(w,{type:`button`,variant:`secondary`,className:`w-full rounded-2xl py-2.5`,onClick:m,disabled:S,children:[C,T]})}),t[61]=m,t[62]=C,t[63]=T,t[64]=S,t[65]=E):E=t[65];let D;return t[66]!==E||t[67]!==y||t[68]!==b||t[69]!==x?(D=(0,U.jsxs)(`article`,{className:y,children:[b,x,E]}),t[66]=E,t[67]=y,t[68]=b,t[69]=x,t[70]=D):D=t[70],D}function $(e){return(0,U.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e},e)}function at(e){return(0,U.jsx)(`p`,{className:`truncate`,title:e,children:e},e)}function ot(e){let t=(0,H.c)(51),{runtime:n,restarting:r,checking:i,showConnectionOptions:a,canManageConnection:o,ch:c,onRestart:u,onCheck:d,onManageConnection:f}=e,p=n===`running`?s:n===`stopped`||n===`needs_setup`?re:z,m=n===`running`&&`text-emerald-600 dark:text-emerald-400`,h=n===`stopped`&&`text-red-600 dark:text-red-400`,g=n===`checking`&&`animate-spin text-amber-600 dark:text-amber-400`,_=n===`disabled`&&`text-fg-muted`,v=n===`needs_setup`&&`text-amber-600 dark:text-amber-400`,y;t[0]!==m||t[1]!==h||t[2]!==g||t[3]!==_||t[4]!==v?(y=l(`mt-0.5 size-5 shrink-0`,m,h,g,_,v),t[0]=m,t[1]=h,t[2]=g,t[3]=_,t[4]=v,t[5]=y):y=t[5];let b;t[6]!==p||t[7]!==y?(b=(0,U.jsx)(p,{className:y}),t[6]=p,t[7]=y,t[8]=b):b=t[8];let x;t[9]===c.connectionStatus?x=t[10]:(x=(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:c.connectionStatus}),t[9]=c.connectionStatus,t[10]=x);let S;t[11]!==c||t[12]!==n?(S=He(n,c),t[11]=c,t[12]=n,t[13]=S):S=t[13];let C;t[14]===S?C=t[15]:(C=(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:S}),t[14]=S,t[15]=C);let T;t[16]!==C||t[17]!==x?(T=(0,U.jsxs)(`div`,{children:[x,C]}),t[16]=C,t[17]=x,t[18]=T):T=t[18];let E;t[19]!==T||t[20]!==b?(E=(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[b,T]}),t[19]=T,t[20]=b,t[21]=E):E=t[21];let D=i||r,O;t[22]===i?O=t[23]:(O=i?(0,U.jsx)(z,{className:`size-4 animate-spin`}):null,t[22]=i,t[23]=O);let k=i?c.checkingConnection:c.checkConnection,A;t[24]!==d||t[25]!==D||t[26]!==O||t[27]!==k?(A=(0,U.jsxs)(w,{type:`button`,variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:D,onClick:d,children:[O,k]}),t[24]=d,t[25]=D,t[26]=O,t[27]=k,t[28]=A):A=t[28];let j;t[29]!==c.restartChannel||t[30]!==c.restartingChannel||t[31]!==i||t[32]!==u||t[33]!==r||t[34]!==n?(j=n===`stopped`?(0,U.jsxs)(w,{type:`button`,variant:`primary`,className:`px-2.5 py-1.5 text-xs`,disabled:r||i,onClick:u,children:[r?(0,U.jsx)(z,{className:`size-4 animate-spin`}):(0,U.jsx)(ie,{className:`size-4`}),r?c.restartingChannel:c.restartChannel]}):null,t[29]=c.restartChannel,t[30]=c.restartingChannel,t[31]=i,t[32]=u,t[33]=r,t[34]=n,t[35]=j):j=t[35];let M;t[36]!==o||t[37]!==c.connectionOptions||t[38]!==c.hideConnectionOptions||t[39]!==i||t[40]!==f||t[41]!==r||t[42]!==a?(M=o?(0,U.jsx)(w,{type:`button`,variant:`ghost`,className:`px-2.5 py-1.5 text-xs`,disabled:i||r,onClick:f,children:a?c.hideConnectionOptions:c.connectionOptions}):null,t[36]=o,t[37]=c.connectionOptions,t[38]=c.hideConnectionOptions,t[39]=i,t[40]=f,t[41]=r,t[42]=a,t[43]=M):M=t[43];let N;t[44]!==A||t[45]!==j||t[46]!==M?(N=(0,U.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[A,j,M]}),t[44]=A,t[45]=j,t[46]=M,t[47]=N):N=t[47];let P;return t[48]!==E||t[49]!==N?(P=(0,U.jsx)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:(0,U.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[E,N]})}),t[48]=E,t[49]=N,t[50]=P):P=t[50],P}function st(e){let t=(0,H.c)(33),{entry:n,ch:r}=e,i,a,o,s,c,l,u,d,f;if(t[0]!==r||t[1]!==n){f=Symbol.for(`react.early_return_sentinel`);bb0:{let e=Y(n);if(e.ready||e.issues.length===0){f=null;break bb0}d=`rounded-xl bg-amber-50 px-4 py-3 text-amber-950 dark:bg-amber-950/30 dark:text-amber-100`,l=`flex items-start gap-3`,t[11]===Symbol.for(`react.memo_cache_sentinel`)?(u=(0,U.jsx)(B,{className:`mt-0.5 size-4 shrink-0`}),t[11]=u):u=t[11],o=`min-w-0`,t[12]===r.setupReadinessTitle?s=t[13]:(s=(0,U.jsx)(`h3`,{className:`text-sm font-semibold`,children:r.setupReadinessTitle}),t[12]=r.setupReadinessTitle,t[13]=s);let p=e.enabled?r.setupReadinessEnabledBody:r.setupReadinessDisabledBody;t[14]===p?c=t[15]:(c=(0,U.jsx)(`p`,{className:`mt-1 text-sm leading-5 text-amber-900 dark:text-amber-200`,children:p}),t[14]=p,t[15]=c),i=`mt-2 list-disc space-y-1 pl-5 text-sm text-amber-900 dark:text-amber-200`;let m;t[16]===r?m=t[17]:(m=e=>(0,U.jsx)(`li`,{children:tt(e,r)},`${e.code}:${e.fieldPath??``}`),t[16]=r,t[17]=m),a=e.issues.map(m)}t[0]=r,t[1]=n,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=f}else i=t[2],a=t[3],o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10];if(f!==Symbol.for(`react.early_return_sentinel`))return f;let p;t[18]!==i||t[19]!==a?(p=(0,U.jsx)(`ul`,{className:i,children:a}),t[18]=i,t[19]=a,t[20]=p):p=t[20];let m;t[21]!==p||t[22]!==o||t[23]!==s||t[24]!==c?(m=(0,U.jsxs)(`div`,{className:o,children:[s,c,p]}),t[21]=p,t[22]=o,t[23]=s,t[24]=c,t[25]=m):m=t[25];let h;t[26]!==m||t[27]!==l||t[28]!==u?(h=(0,U.jsxs)(`div`,{className:l,children:[u,m]}),t[26]=m,t[27]=l,t[28]=u,t[29]=h):h=t[29];let g;return t[30]!==h||t[31]!==d?(g=(0,U.jsx)(`section`,{className:d,children:h}),t[30]=h,t[31]=d,t[32]=g):g=t[32],g}function ct(){let e=p(e=>e.language),t=h(e),n=d(e=>!!e.conversationId),r=i(),{channelId:s}=a(),c=L(s),u=Ae(n,e),g=u.entries,{data:_,mutate:v,isValidating:y}=C(n?fe():null,pe,{revalidateOnFocus:!0}),{data:b,mutate:x}=C(n?`channels-config-map`:null,Re,{revalidateOnFocus:!1}),S=b?.channels??{},w=b?.bindings??[],{data:T}=C(n?`channel-routing-agents`:null,I,{revalidateOnFocus:!1}),E=P(e=>e.setPageHeader),D=P(e=>e.clearPageHeader),O=(0,V.useMemo)(()=>g.find(e=>e.id===c),[c,g]),N=O?Be(O):null,{data:ee,mutate:R}=C(n&&N?Fe(N):null,()=>Ie(N)),[z,B]=(0,V.useState)(null),[te,re]=(0,V.useState)(!1),[ie,ae]=(0,V.useState)(null),[ce,H]=(0,V.useState)(null),[de,he]=(0,V.useState)(!1),[W,G]=(0,V.useState)(null),[K,q]=(0,V.useState)(null),ge=z??ee??{},J=t.channelsSettings,ve=(0,V.useMemo)(()=>O?.configSchema??{type:`object`,properties:{}},[O?.configSchema]),xe=(0,V.useMemo)(()=>qe(ve,Le),[ve]),Ce=(0,V.useMemo)(()=>We(O),[O]),Te=(0,V.useMemo)(()=>Ge(xe,Ce),[Ce,xe]),Oe=(0,V.useMemo)(()=>qe(xe,Ce),[Ce,xe]),ke=(0,V.useMemo)(()=>Je(Te),[Te]),je=O?K??ye(w,O.id):``,Ne=(0,V.useMemo)(()=>(T?.items??[]).map(e=>{let n=A(e,t.agentsSettings);return{value:e.id,label:n===e.id?n:`${n} · ${e.id}`}}),[T?.items,t.agentsSettings]),ze=T?.items.find(e=>e.id===T.defaultId),He=ze?A(ze,t.agentsSettings):T?.defaultId??``,X=(0,V.useMemo)(()=>({defaultBooleanLabel:J.schemaBooleanDefault,unsupportedArrayType:J.schemaUnsupportedArrayType,arrayAddPlaceholder:J.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>J.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[J]),Z=(0,V.useMemo)(()=>new Map((_??[]).map(e=>[e.name,e])),[_]),Ke=_!==void 0,Ye=(0,V.useCallback)(e=>Se(e,Z.get(e.id),Ke),[Z,Ke]),Q=(0,V.useCallback)(async()=>{await Promise.all([u.mutate(),v()])},[u,v]);Pe((0,V.useCallback)(e=>{let t=Me(e);t&&v(t,!1)},[v]),n);let Xe=(0,V.useMemo)(()=>n?(0,U.jsx)(Ee,{ch:J,refreshing:u.isValidating||y,saveOk:!1,onRefresh:()=>void Q()}):null,[u.isValidating,J,n,y,Q]);(0,V.useLayoutEffect)(()=>(E({startExtra:null,main:(0,U.jsx)(`div`,{className:`min-w-0`,children:(0,U.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:t.settingsSections.channels})}),end:Xe}),()=>D()),[D,Xe,t.settingsSections.channels,E]);let Ze=(0,V.useCallback)(e=>{r(j(e)),B(null),q(null),G(null)},[r]),Qe=(0,V.useCallback)(()=>{r(M),B(null),q(null),G(null)},[r]),$e=(0,V.useCallback)(async e=>{H(e.id),G(null);try{let t=await f(m(`/api/channels/${encodeURIComponent(e.id)}/restart`),{method:`POST`});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}await Q()}catch(e){G(e instanceof Error?e.message:String(e))}finally{H(null)}},[Q]);(0,V.useEffect)(()=>{q(null),he(!1)},[O?.id]);let et=(0,V.useCallback)(async()=>{if(!O||!z&&K===null)return!1;let e=Be(O);re(!0),G(null);try{let t=await f(m(`/api/config`),{method:`PATCH`,body:JSON.stringify({...z?{channels:{[e]:z}}:{},...K===null?{}:{bindings:be(w,O.id,K)}})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}return z&&await R(z,!1),await x(),await u.mutate(),B(null),q(null),!0}catch(e){return G(e instanceof Error?e.message:String(e)),!1}finally{re(!1)}},[O,K,w,u,z,x,R]),tt=(0,V.useCallback)(async e=>{let t=Y(e),n=Be(e),r=O?.id===e.id?z:null;if(!t.enabled&&!t.ready&&!r){Ze(e.id);return}ae(e.id),G(null);try{let i=t.enabled?{enabled:!1}:r?{...r,enabled:!0}:{enabled:!0},a=await f(m(`/api/config`),{method:`PATCH`,body:JSON.stringify({channels:{[n]:i}})});if(!a.ok){let e=await a.json().catch(()=>({}));throw Error(e.error?.message??a.statusText)}await u.mutate(),await x(),await v(),O?.id===e.id&&(await R(),B(null))}catch(e){G(e instanceof Error?e.message:String(e))}finally{ae(null)}},[O?.id,u,z,x,R,v,Ze]),$=O?.ui?.modal,at=$?.placement!==`replace-config`,ct=O?Ye(O):`checking`,lt=O?!Y(O).ready||de:!1;return n?(0,U.jsxs)(se,{gap:`gap-4`,className:`max-w-6xl`,padding:`px-4 py-7 sm:px-6 lg:px-8 lg:py-9`,children:[u.isLoading?(0,U.jsx)(le,{sections:2}):u.error?(0,U.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:String(u.error)}):(0,U.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:g.map(e=>(0,U.jsx)(it,{entry:e,config:S[Be(e)]?.config,runtime:Ye(e),busy:ie===e.id,restarting:ce===e.id,ch:J,onOpen:()=>Ze(e.id),onToggle:()=>void tt(e),onRestart:()=>void $e(e)},e.id))}),W?(0,U.jsx)(`p`,{className:`mt-4 text-sm text-red-600 dark:text-red-400`,children:W}):null,(0,U.jsx)(we,{presentation:`modal`,open:!!O,onOpenChange:e=>{e||Qe()},closeAriaLabel:J.close,srTitle:O?.label??J.selectChannel,srDescription:O?.description,wide:!0,footer:O?(0,U.jsx)(De,{ch:J,dirty:!!z||K!==null,saving:te,onCancel:Qe,onDiscard:()=>{B(null),q(null)},onSave:et}):null,children:O?(0,U.jsxs)(`div`,{className:`space-y-4`,children:[(0,U.jsx)(`div`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,children:(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,U.jsx)(nt,{entry:O}),(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,U.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:O.label}),(0,U.jsx)(`span`,{className:l(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,Ue(ct)),children:Ve(ct,J)})]}),(0,U.jsxs)(`div`,{className:`mt-1 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-sm text-fg-muted`,children:[(0,U.jsx)(`span`,{className:`min-w-0 truncate`,children:!Y(O).ready&&me(O)?.[1].result===`qr`?J.scanLoginHint.replace(`{{channel}}`,O.label):O.description}),O.docsPath?(0,U.jsxs)(`a`,{href:O.docsPath,target:`_blank`,rel:`noreferrer`,className:`inline-flex shrink-0 items-center gap-1 text-accent hover:underline`,children:[J.docs,(0,U.jsx)(k,{className:`size-3.5`})]}):null]})]})]}),(0,U.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pr-8`,children:[(0,U.jsx)(`span`,{className:`hidden text-xs text-fg-muted sm:inline`,children:Y(O).enabled?J.enabledLabel:J.disabledLabel}),(0,U.jsx)(rt,{checked:Y(O).enabled,disabled:ie===O.id,label:J.toggleChannel.replace(`{{channel}}`,O.label),onToggle:()=>void tt(O)})]})]})}),(0,U.jsx)(ot,{runtime:ct,restarting:ce===O.id,checking:y,showConnectionOptions:de,canManageConnection:Y(O).ready&&$?.placement!==`replace-config`,ch:J,onRestart:()=>void $e(O),onCheck:()=>void Q(),onManageConnection:()=>he(e=>!e)}),(0,U.jsx)(st,{entry:O,ch:J}),lt&&$?.placement!==`replace-config`?(0,U.jsx)(_e,{entry:O,locale:e,messages:J,compact:!0,onChanged:async()=>{await R(),await Q(),await x()}},O.id):null,$?.entrypoint&&$.placement===`before-config`?(0,U.jsx)(ne,{extensionId:O.extensionId,extensionName:O.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:O.id,entry:O,config:ge}}):null,$?.entrypoint&&$.placement!==`before-config`?(0,U.jsx)(ne,{extensionId:O.extensionId,extensionName:O.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:O.id,entry:O,config:ge}}):null,at&&ke?(0,U.jsxs)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:`mb-4`,children:[(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:J.basicConfiguration}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:J.basicConfigurationHint})]}),(0,U.jsx)(ue,{schema:Te,values:ge,onChange:e=>B(e),disabled:te,labels:X})]}):null,(0,U.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,U.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,U.jsx)(F,{className:`size-4 text-fg-muted`}),J.messageHandling]}),(0,U.jsxs)(`div`,{className:`bg-surface-base/50 p-4`,children:[(0,U.jsxs)(`div`,{className:`mb-3`,children:[(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:J.agentRouting}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:J.messageHandlingHint})]}),(0,U.jsx)(o,{value:je,options:Ne,placeholder:J.agentRoutingSelect,emptyLabel:J.agentRoutingDefault.replace(`{{agent}}`,He||J.agentRoutingSelect),ariaLabel:J.agentRouting,disabled:te||!T,onChange:e=>q(e)})]})]}),at&&Je(Oe)?(0,U.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,U.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,U.jsx)(F,{className:`size-4 text-fg-muted`}),J.advancedConfiguration]}),(0,U.jsx)(`div`,{className:`bg-surface-base/50 p-4`,children:(0,U.jsx)(ue,{schema:Oe,values:ge,onChange:e=>B(e),disabled:te,labels:X})})]}):null,W?(0,U.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:W}):null]}):null})]}):(0,U.jsxs)(se,{gap:`gap-3`,padding:`px-3 py-8 sm:px-5 xl:px-6`,children:[(0,U.jsx)(oe,{title:t.settingsSections.channels}),(0,U.jsx)(`p`,{className:`text-sm text-fg-muted`,children:J.tokenRequired})]})}export{ct as ChannelsSettingsPanel};