@xopcai/xopc 0.0.358 → 0.0.360

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 (446) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/feishu/src/adapters/cli-login.js +3 -3
  3. package/dist/extensions/feishu/src/outbound/media-load.js +1 -1
  4. package/dist/extensions/telegram/src/inbound-processor.js +2 -2
  5. package/dist/extensions/telegram/src/outbound-sender.js +1 -1
  6. package/dist/extensions/telegram/src/plugin.js +2 -2
  7. package/dist/extensions/telegram/xopc.extension.json +1 -1
  8. package/dist/extensions/weixin/src/api/api.js +2 -2
  9. package/dist/extensions/weixin/src/auth/accounts.js +12 -12
  10. package/dist/extensions/weixin/src/messaging/debug-mode.js +5 -5
  11. package/dist/extensions/weixin/src/messaging/inbound.js +11 -11
  12. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-DEs_xwQi.js → agent-avatar-dicebear-CQTERenW.js} +1 -1
  13. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-CPF0lunJ.js +1 -0
  14. package/dist/gateway/static/root/assets/agent-plugin-dialog-BjDaZlKy.js +1 -0
  15. package/dist/gateway/static/root/assets/agents-XopBILLB.js +66 -0
  16. package/dist/gateway/static/root/assets/{app-management-settings-panel-BqyvMQXO.js → app-management-settings-panel-V5QVeMvW.js} +1 -1
  17. package/dist/gateway/static/root/assets/{appearance-settings-Cn9qgXLw.js → appearance-settings-BDkRcoI6.js} +1 -1
  18. package/dist/gateway/static/root/assets/{apps-page-ChPOmrPa.js → apps-page-DzCyL89L.js} +1 -1
  19. package/dist/gateway/static/root/assets/{automations-page-OUapkL2D.js → automations-page-DOu1wMOV.js} +1 -1
  20. package/dist/gateway/static/root/assets/automations-workspace-CiY_2otj.js +7 -0
  21. package/dist/gateway/static/root/assets/{block-editor-_-QK0EnY.js → block-editor-K6is5GrS.js} +3 -3
  22. package/dist/gateway/static/root/assets/{browser-automation-inputs-CnLQ649y.js → browser-automation-inputs-MmkUGn9W.js} +1 -1
  23. package/dist/gateway/static/root/assets/{browser-automations-page-DZlWdikj.js → browser-automations-page-B8IiXEBs.js} +2 -2
  24. package/dist/gateway/static/root/assets/{browser-settings-page-CEF_LSjz.js → browser-settings-page-Cms2Bu3Q.js} +2 -2
  25. package/dist/gateway/static/root/assets/capabilities-page-BAFRNHQv.js +2 -0
  26. package/dist/gateway/static/root/assets/capabilities-settings-panel-Cws6od1d.js +8 -0
  27. package/dist/gateway/static/root/assets/{capability-header-actions-CA_XNTSW.js → capability-header-actions-wh3Nr0qS.js} +1 -1
  28. package/dist/gateway/static/root/assets/channels-DxwismTc.js +1 -0
  29. package/dist/gateway/static/root/assets/{chat-terminal-dock-DRV-4qeP.js → chat-terminal-dock-BU-X9nu1.js} +2 -2
  30. package/dist/gateway/static/root/assets/computer-settings-page-MyXsSqFJ.js +1 -0
  31. package/dist/gateway/static/root/assets/{connector-service-page-BKAt0jvO.js → connector-service-page-DyxPM_MZ.js} +1 -1
  32. package/dist/gateway/static/root/assets/connectors-page-C7-OC3MW.js +2 -0
  33. package/dist/gateway/static/root/assets/{constants-Co2_smKQ.js → constants-Dy8Gw0sF.js} +1 -1
  34. package/dist/gateway/static/root/assets/date-picker-WRFvi7Pu.js +1 -0
  35. package/dist/gateway/static/root/assets/{dependency-picker-D0RWVtBt.js → dependency-picker-CLun5Tst.js} +1 -1
  36. package/dist/gateway/static/root/assets/{desktop-pet-9B1PIjsV.js → desktop-pet-iaVa9vVM.js} +1 -1
  37. package/dist/gateway/static/root/assets/{desktop-pet-settings-cq5n59Pr.js → desktop-pet-settings-0RS3sP3Z.js} +1 -1
  38. package/dist/gateway/static/root/assets/device-pairing-wizard-DVAGb04L.js +1 -0
  39. package/dist/gateway/static/root/assets/{directory-picker-path-field-C40-GlX1.js → directory-picker-path-field-Btlldlt3.js} +1 -1
  40. package/dist/gateway/static/root/assets/{extension-debug-page-BodxNAys.js → extension-debug-page-BImQT4PU.js} +1 -1
  41. package/dist/gateway/static/root/assets/{extension-page-BshgQ_pO.js → extension-page-BmuLv-ET.js} +1 -1
  42. package/dist/gateway/static/root/assets/{extension-provider-aigS3RJu.js → extension-provider-Dg7cRxDX.js} +1 -1
  43. package/dist/gateway/static/root/assets/{extension-settings-page-DAJZVzIQ.js → extension-settings-page-7Kr8UJK4.js} +1 -1
  44. package/dist/gateway/static/root/assets/fallback-models-B0w1lumZ.js +1 -0
  45. package/dist/gateway/static/root/assets/gateway-settings-DmPvmwYp.js +1 -0
  46. package/dist/gateway/static/root/assets/home-page-N0Mp-eTJ.js +1 -0
  47. package/dist/gateway/static/root/assets/{imports-page-Bsn8Qted.js → imports-page-BLOJY67-.js} +1 -1
  48. package/dist/gateway/static/root/assets/{index-DUgsBdV3.css → index-B7AHDHSO.css} +1 -1
  49. package/dist/gateway/static/root/assets/index-BXrBL_Hb.js +106 -0
  50. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-DjuXyBbC.js → keyboard-shortcuts-settings-Dlbsip2R.js} +1 -1
  51. package/dist/gateway/static/root/assets/{local-app-workbench-page-D77r2CKa.js → local-app-workbench-page-nyWeTK0r.js} +1 -1
  52. package/dist/gateway/static/root/assets/{local-apps-page-GsohMT3J.js → local-apps-page-CfEpFLs0.js} +1 -1
  53. package/dist/gateway/static/root/assets/{logs-page-DeBeNPb4.js → logs-page-A38cawkA.js} +2 -2
  54. package/dist/gateway/static/root/assets/{management-settings-Di9r7yBX.js → management-settings-Cse9K61x.js} +1 -1
  55. package/dist/gateway/static/root/assets/{note-detail-panel-CLq8afeQ.js → note-detail-panel-CUGVyo2V.js} +3 -3
  56. package/dist/gateway/static/root/assets/notes-page-Dk89l5dC.js +8 -0
  57. package/dist/gateway/static/root/assets/{page-context-capture-button-C9H1dHg2.js → page-context-capture-button-C72qIgBg.js} +1 -1
  58. package/dist/gateway/static/root/assets/personal-page-DCtduzh8.js +1 -0
  59. package/dist/gateway/static/root/assets/popover-select-BgSdSbCL.js +1 -0
  60. package/dist/gateway/static/root/assets/{product-open-page-pW662VEC.js → product-open-page-CT98FsVl.js} +1 -1
  61. package/dist/gateway/static/root/assets/{project-detail-page-3_Bqq0OV.js → project-detail-page-BlqOVwKP.js} +1 -1
  62. package/dist/gateway/static/root/assets/{projects-page-D85PDbCM.js → projects-page-DVN2q_yR.js} +1 -1
  63. package/dist/gateway/static/root/assets/remote-access-hub-BP5kUgIN.js +1 -0
  64. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-BUgsyhm_.js → runtime-tools-settings-panel-ry0jprz7.js} +1 -1
  65. package/dist/gateway/static/root/assets/{scenes-page-Bds4V34P.js → scenes-page-CV1GkOj6.js} +2 -2
  66. package/dist/gateway/static/root/assets/{schema-form-BQz6ezGe.js → schema-form-C5zMrxgR.js} +1 -1
  67. package/dist/gateway/static/root/assets/{send-session-input-OaBPDJ9E.js → send-session-input-Dt0t5SoR.js} +1 -1
  68. package/dist/gateway/static/root/assets/session-manager-DDR-gv_e.js +16 -0
  69. package/dist/gateway/static/root/assets/sessions-page-BXtGeOsR.js +1 -0
  70. package/dist/gateway/static/root/assets/settings-advanced-gate-CvFVkELy.js +1 -0
  71. package/dist/gateway/static/root/assets/{settings-page-CKmMkdPu.js → settings-page-C88fsfZF.js} +1 -1
  72. package/dist/gateway/static/root/assets/{setup-status-panel-Cjv6CDgq.js → setup-status-panel-DESlRgZS.js} +1 -1
  73. package/dist/gateway/static/root/assets/{share-link-dialog-QAjExHAL.js → share-link-dialog-BvSRHs1P.js} +1 -1
  74. package/dist/gateway/static/root/assets/{share-preview-page-M_rAQR60.js → share-preview-page-D5Gey-6E.js} +1 -1
  75. package/dist/gateway/static/root/assets/shares-settings-btoP07Fx.js +1 -0
  76. package/dist/gateway/static/root/assets/{skill-api-BO1b2oYj.js → skill-api-1hbX3qDC.js} +1 -1
  77. package/dist/gateway/static/root/assets/skills-page-DYJbwwBT.js +2 -0
  78. package/dist/gateway/static/root/assets/{system-settings-panel-CIDRPUj4.js → system-settings-panel-DbNk-Jwq.js} +1 -1
  79. package/dist/gateway/static/root/assets/{task-detail-page-ZmkA0E9f.js → task-detail-page-DoLKOJrE.js} +1 -1
  80. package/dist/gateway/static/root/assets/{tunnel-api-BkgD61qc.js → tunnel-api-H3FheXYH.js} +1 -1
  81. package/dist/gateway/static/root/assets/{usage-page-BjgYDab4.js → usage-page-DGbqcsV6.js} +1 -1
  82. package/dist/gateway/static/root/assets/{use-composer-attachments-qK3z-EGz.js → use-composer-attachments-pzPAUV_o.js} +1 -1
  83. package/dist/gateway/static/root/assets/{use-file-preview-expanded-D809I8ur.js → use-file-preview-expanded-DNhXjL0W.js} +1 -1
  84. package/dist/gateway/static/root/assets/user-model-page-7pW4Pazn.js +2 -0
  85. package/dist/gateway/static/root/assets/{work-discovery-overlay-Ce3PKQvh.js → work-discovery-overlay-DfyI9kVf.js} +1 -1
  86. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-Dv6xUycS.js → workflow-run-setup-panel-De80GODZ.js} +2 -2
  87. package/dist/gateway/static/root/assets/workflows-page-BuH3pC1C.js +6 -0
  88. package/dist/gateway/static/root/assets/{workspace-api-BtXzxf_w.js → workspace-api-Dwa8kHdY.js} +2 -2
  89. package/dist/gateway/static/root/index.html +11 -12
  90. package/dist/package.js +1 -1
  91. package/dist/packages/gateway-contract/src/index.js +2 -0
  92. package/dist/packages/gateway-contract/src/task-result-delivery.js +30 -0
  93. package/dist/src/agent/agent-manager.js +13 -13
  94. package/dist/src/agent/agent-scope.js +2 -2
  95. package/dist/src/agent/background-review/prompts.js +1 -1
  96. package/dist/src/agent/background-review/run-background-review.js +3 -3
  97. package/dist/src/agent/coding/repository-instructions.js +1 -1
  98. package/dist/src/agent/context/coordinator.js +2 -2
  99. package/dist/src/agent/context/execution-context.js +4 -4
  100. package/dist/src/agent/context/execution-scope.js +2 -2
  101. package/dist/src/agent/context/project-context.js +3 -3
  102. package/dist/src/agent/context/workspace-templates/SOUL.md +2 -0
  103. package/dist/src/agent/data-acquisition/service.js +1 -1
  104. package/dist/src/agent/embedded/index.js +2 -2
  105. package/dist/src/agent/embedded/model-runtime.js +1 -1
  106. package/dist/src/agent/embedded/run-for-session.js +4 -4
  107. package/dist/src/agent/embedded/run-turn.js +5 -5
  108. package/dist/src/agent/embedded/session-tool-result-guard.js +3 -3
  109. package/dist/src/agent/embedded/tool-result-truncation.js +1 -1
  110. package/dist/src/agent/external-tools/cliProvider.js +3 -3
  111. package/dist/src/agent/external-tools/composio-provider.js +3 -3
  112. package/dist/src/agent/external-tools/gateway-tools.js +42 -2
  113. package/dist/src/agent/external-tools/mcp-provider.js +3 -3
  114. package/dist/src/agent/image/generation/openai-images-provider.js +1 -1
  115. package/dist/src/agent/image/generation/providers/dashscope.js +1 -1
  116. package/dist/src/agent/image/generation/providers/fal.js +1 -1
  117. package/dist/src/agent/image/generation/providers/google.js +1 -1
  118. package/dist/src/agent/image/generation/runtime.js +1 -1
  119. package/dist/src/agent/image/index.js +1 -1
  120. package/dist/src/agent/image/load-image-media.js +1 -1
  121. package/dist/src/agent/image/tool-model-config.js +1 -1
  122. package/dist/src/agent/inbound/attachment-pipeline.js +1 -1
  123. package/dist/src/agent/inbound/inbound-loop.js +2 -2
  124. package/dist/src/agent/index.js +1 -1
  125. package/dist/src/agent/mcp/bundle-mcp-config.js +1 -1
  126. package/dist/src/agent/mcp/bundle-mcp-gateway.js +1 -1
  127. package/dist/src/agent/mcp/bundle-mcp-runtime.js +2 -2
  128. package/dist/src/agent/mcp/index.js +2 -2
  129. package/dist/src/agent/mcp/mcp-stdio-transport.js +1 -1
  130. package/dist/src/agent/mcp/mcp-transport.js +1 -1
  131. package/dist/src/agent/mcp/oauth/mcp-oauth-manager.js +1 -1
  132. package/dist/src/agent/mcp/plugin-http-fetch.js +1 -1
  133. package/dist/src/agent/memory/context-recovery.js +1 -1
  134. package/dist/src/agent/memory/index.js +1 -1
  135. package/dist/src/agent/orchestration/agent-orchestrator.js +1 -1
  136. package/dist/src/agent/prompt/sections/behavior.js +4 -1
  137. package/dist/src/agent/prompt/sections/memory-skills.js +2 -0
  138. package/dist/src/agent/prompt/service-prompt-builder.js +2 -2
  139. package/dist/src/agent/sandbox/exec-policy.js +1 -1
  140. package/dist/src/agent/service/direct-turn-helpers.js +4 -4
  141. package/dist/src/agent/service/process-direct-one-shot.js +1 -1
  142. package/dist/src/agent/service/process-direct-streaming.js +5 -5
  143. package/dist/src/agent/service/webchat-tts.js +2 -2
  144. package/dist/src/agent/service.js +20 -20
  145. package/dist/src/agent/session/session-config-service.js +12 -4
  146. package/dist/src/agent/session/session-hydrator.js +1 -1
  147. package/dist/src/agent/session/session-inspector.js +1 -1
  148. package/dist/src/agent/source-context/index.js +2 -2
  149. package/dist/src/agent/tasks/task-judge-service.js +4 -4
  150. package/dist/src/agent/tools/create-share-tool.js +3 -3
  151. package/dist/src/agent/tools/dataBatch.js +1 -1
  152. package/dist/src/agent/tools/delegate-tool.js +3 -3
  153. package/dist/src/agent/tools/delegation-parent-policy.js +1 -1
  154. package/dist/src/agent/tools/executor.js +1 -1
  155. package/dist/src/agent/tools/factory.js +48 -22
  156. package/dist/src/agent/tools/fetch-text.js +1 -1
  157. package/dist/src/agent/tools/image-generate-tool.js +3 -3
  158. package/dist/src/agent/tools/index.js +6 -6
  159. package/dist/src/agent/tools/list-dir.js +1 -1
  160. package/dist/src/agent/tools/personal-preference-tool.js +11 -0
  161. package/dist/src/agent/tools/personal-request-result-tool.d.ts +22 -0
  162. package/dist/src/agent/tools/personal-request-result-tool.js +84 -0
  163. package/dist/src/agent/tools/personal-request-tool.d.ts +3 -0
  164. package/dist/src/agent/tools/personal-request-tool.js +100 -0
  165. package/dist/src/agent/tools/personal-task-tool.d.ts +6 -0
  166. package/dist/src/agent/tools/personal-task-tool.js +14 -12
  167. package/dist/src/agent/tools/publish-artifacts.js +2 -2
  168. package/dist/src/agent/tools/read.js +2 -2
  169. package/dist/src/agent/tools/review-workspace.js +1 -1
  170. package/dist/src/agent/tools/send-media.js +2 -2
  171. package/dist/src/agent/tools/skills-tools.js +1 -1
  172. package/dist/src/agent/tools/tool-media.js +2 -3
  173. package/dist/src/agent/tools/tts-tool.js +1 -1
  174. package/dist/src/agent/tools/user-context-tool.js +1 -1
  175. package/dist/src/agent/tools/write.js +2 -2
  176. package/dist/src/agent/tools/xopc-use-tool.js +3 -3
  177. package/dist/src/agent/workflow/subagent-runner.js +1 -1
  178. package/dist/src/ai-assist/text-assist.js +1 -1
  179. package/dist/src/auth/credentials.js +1 -1
  180. package/dist/src/auth/sync-provider-auth.js +1 -1
  181. package/dist/src/automations/domain/index.js +2 -2
  182. package/dist/src/automations/index.js +4 -4
  183. package/dist/src/automations/service/automation-service.js +2 -2
  184. package/dist/src/backup/archive.js +1 -1
  185. package/dist/src/browser/native-messaging-host.js +1 -1
  186. package/dist/src/channels/attachments/voice-stt-webchat.js +2 -2
  187. package/dist/src/channels/index.js +2 -2
  188. package/dist/src/channels/outbound-sender.js +1 -1
  189. package/dist/src/channels/pairing/allow-from-file.js +9 -9
  190. package/dist/src/channels/pairing/pairing-store.js +6 -6
  191. package/dist/src/chat-commands/agent-edit.js +1 -1
  192. package/dist/src/chat-commands/builtins/config.js +3 -3
  193. package/dist/src/chat-commands/builtins/review.js +1 -1
  194. package/dist/src/chat-commands/builtins/session.js +1 -1
  195. package/dist/src/chat-commands/builtins/thinking.js +1 -1
  196. package/dist/src/chat-commands/builtins/tts.js +1 -1
  197. package/dist/src/chat-commands/builtins/understanding.js +1 -1
  198. package/dist/src/chat-commands/builtins/workflow.js +2 -2
  199. package/dist/src/chat-commands/context.js +3 -3
  200. package/dist/src/chat-commands/index.js +3 -3
  201. package/dist/src/cli/commands/agent.js +6 -6
  202. package/dist/src/cli/commands/config.js +1 -1
  203. package/dist/src/cli/commands/connectors.js +1 -1
  204. package/dist/src/cli/commands/doctor/checks/channel-plugins.js +1 -1
  205. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  206. package/dist/src/cli/commands/doctor/checks/gateway-health.js +1 -1
  207. package/dist/src/cli/commands/doctor/checks/provider-auth.js +2 -2
  208. package/dist/src/cli/commands/doctor/checks/tool-runtimes.js +1 -1
  209. package/dist/src/cli/commands/extension-agent-plugin.js +2 -2
  210. package/dist/src/cli/commands/extension-dev.js +1 -1
  211. package/dist/src/cli/commands/extension-marketplace.js +2 -2
  212. package/dist/src/cli/commands/extension.js +4 -4
  213. package/dist/src/cli/commands/gateway/shared.js +1 -1
  214. package/dist/src/cli/commands/gateway/token.js +1 -1
  215. package/dist/src/cli/commands/image.js +1 -1
  216. package/dist/src/cli/commands/init.js +1 -1
  217. package/dist/src/cli/commands/onboard/channels/registry.js +1 -1
  218. package/dist/src/cli/commands/onboard.js +1 -1
  219. package/dist/src/cli/commands/project.js +2 -2
  220. package/dist/src/cli/commands/runtime.js +1 -1
  221. package/dist/src/cli/commands/skills.js +2 -2
  222. package/dist/src/cli/commands/tunnel.js +4 -4
  223. package/dist/src/cli/extension-cli-register.js +5 -5
  224. package/dist/src/cli/templates.js +4 -0
  225. package/dist/src/cli/utils/gateway-client.js +1 -1
  226. package/dist/src/cli/utils/init-workspace-core.js +1 -1
  227. package/dist/src/cli/utils/session.js +1 -1
  228. package/dist/src/computer/runtime.js +2 -2
  229. package/dist/src/config/index.js +5 -5
  230. package/dist/src/config/loader.js +1 -1
  231. package/dist/src/config/models-json.js +1 -1
  232. package/dist/src/connectors/cli/authorization.js +1 -1
  233. package/dist/src/connectors/cli/runtime.js +1 -1
  234. package/dist/src/connectors/composio-sessions.js +1 -1
  235. package/dist/src/connectors/composio.js +1 -1
  236. package/dist/src/connectors/connected-source-understanding.js +3 -3
  237. package/dist/src/connectors/connection-recovery-service.d.ts +2 -0
  238. package/dist/src/connectors/connection-recovery-service.js +28 -10
  239. package/dist/src/connectors/health.js +1 -1
  240. package/dist/src/connectors/plugin-mcp-recovery.js +1 -1
  241. package/dist/src/discussions/live-worker.js +1 -1
  242. package/dist/src/discussions/recording.js +1 -1
  243. package/dist/src/discussions/sealer.js +1 -1
  244. package/dist/src/extensions/activation-context.js +3 -3
  245. package/dist/src/extensions/api.js +4 -4
  246. package/dist/src/extensions/bundled-extension-activation.js +1 -1
  247. package/dist/src/extensions/index.js +3 -3
  248. package/dist/src/extensions/install.js +1 -1
  249. package/dist/src/extensions/loader.js +2 -2
  250. package/dist/src/extensions/sdk/index.js +1 -1
  251. package/dist/src/extensions/sdk/media.js +1 -1
  252. package/dist/src/extensions/update.js +1 -1
  253. package/dist/src/gateway/agent-builtin-tools.d.ts +1 -1
  254. package/dist/src/gateway/agents-admin.js +1 -1
  255. package/dist/src/gateway/device-routes.js +2 -2
  256. package/dist/src/gateway/file-path-classifier.js +2 -2
  257. package/dist/src/gateway/global-defaults-admin.js +1 -1
  258. package/dist/src/gateway/hono/app.js +3 -3
  259. package/dist/src/gateway/hono/lib/config-payload.js +3 -3
  260. package/dist/src/gateway/hono/routes/agents.js +1 -1
  261. package/dist/src/gateway/hono/routes/auth-registry-extensions.js +1 -1
  262. package/dist/src/gateway/hono/routes/browser.js +1 -1
  263. package/dist/src/gateway/hono/routes/commands-skills.js +4 -4
  264. package/dist/src/gateway/hono/routes/config-patch/gateway.js +1 -1
  265. package/dist/src/gateway/hono/routes/home.js +1 -1
  266. package/dist/src/gateway/hono/routes/mcp.js +2 -2
  267. package/dist/src/gateway/hono/routes/media.js +5 -4
  268. package/dist/src/gateway/hono/routes/models.js +6 -6
  269. package/dist/src/gateway/hono/routes/notes.js +1 -1
  270. package/dist/src/gateway/hono/routes/personal-agent.js +69 -1
  271. package/dist/src/gateway/hono/routes/projects.js +2 -2
  272. package/dist/src/gateway/hono/routes/session-command-handler.js +1 -1
  273. package/dist/src/gateway/hono/routes/session-input-handler.js +3 -3
  274. package/dist/src/gateway/hono/routes/sessions.js +2 -2
  275. package/dist/src/gateway/hono/routes/shares.js +3 -3
  276. package/dist/src/gateway/hono/routes/side-chats.js +1 -1
  277. package/dist/src/gateway/hono/routes/site-shares.js +1 -1
  278. package/dist/src/gateway/hono/routes/tasks.js +1 -1
  279. package/dist/src/gateway/hono/routes/user-model-refresh.js +1 -1
  280. package/dist/src/gateway/hono/routes/user-model.js +5 -5
  281. package/dist/src/gateway/hono/routes/voice.js +7 -7
  282. package/dist/src/gateway/hono/routes/workflows.js +2 -2
  283. package/dist/src/gateway/image-generation-setup.js +1 -1
  284. package/dist/src/gateway/index.js +1 -1
  285. package/dist/src/gateway/lock.js +11 -11
  286. package/dist/src/gateway/media-access.js +3 -3
  287. package/dist/src/gateway/mobile-privacy.js +2 -2
  288. package/dist/src/gateway/ports.js +6 -6
  289. package/dist/src/gateway/run-loop.js +1 -1
  290. package/dist/src/gateway/scenes/mailContext.js +1 -1
  291. package/dist/src/gateway/scenes/slackThreadSource.js +1 -1
  292. package/dist/src/gateway/server.js +1 -1
  293. package/dist/src/gateway/service/agent-runner.js +1 -1
  294. package/dist/src/gateway/service/config-coordinator.js +3 -3
  295. package/dist/src/gateway/service/run-gateway-agent.js +3 -3
  296. package/dist/src/gateway/service/session-command-service.js +2 -2
  297. package/dist/src/gateway/service/sessions-api.js +1 -1
  298. package/dist/src/gateway/service.d.ts +3 -0
  299. package/dist/src/gateway/service.js +81 -40
  300. package/dist/src/gateway/session-context-summary.js +2 -2
  301. package/dist/src/gateway/session-reset-service.js +1 -1
  302. package/dist/src/gateway/workspace-editor-path.js +2 -2
  303. package/dist/src/home-intelligence/generator.js +1 -1
  304. package/dist/src/infra/gateway-processes.js +2 -2
  305. package/dist/src/infra/path-env.js +3 -3
  306. package/dist/src/infra/update-global.js +10 -10
  307. package/dist/src/local-apps/service.js +1 -1
  308. package/dist/src/mcp/gateway-http-client.js +1 -1
  309. package/dist/src/media/index.js +2 -2
  310. package/dist/src/media/session-references.d.ts +2 -0
  311. package/dist/src/media/session-references.js +22 -2
  312. package/dist/src/media/store.d.ts +1 -0
  313. package/dist/src/media/store.js +2 -1
  314. package/dist/src/media-understanding/openai-compatible-audio.js +1 -1
  315. package/dist/src/notes/agent-context.js +4 -4
  316. package/dist/src/notes/index.js +1 -1
  317. package/dist/src/notes/service.js +1 -1
  318. package/dist/src/notes/store.js +1 -1
  319. package/dist/src/personal-agent/capability-service.d.ts +14 -0
  320. package/dist/src/personal-agent/capability-service.js +63 -0
  321. package/dist/src/personal-agent/communication.d.ts +4 -0
  322. package/dist/src/personal-agent/communication.js +24 -0
  323. package/dist/src/personal-agent/model-config.d.ts +5 -0
  324. package/dist/src/personal-agent/model-config.js +59 -0
  325. package/dist/src/personal-agent/policy.d.ts +1 -1
  326. package/dist/src/personal-agent/policy.js +2 -0
  327. package/dist/src/personal-agent/repository.d.ts +1 -0
  328. package/dist/src/personal-agent/repository.js +3 -1
  329. package/dist/src/personal-agent/request-delivery.d.ts +4 -0
  330. package/dist/src/personal-agent/request-delivery.js +159 -0
  331. package/dist/src/personal-agent/request-repository.d.ts +33 -0
  332. package/dist/src/personal-agent/request-repository.js +71 -0
  333. package/dist/src/personal-agent/request-result.d.ts +21 -0
  334. package/dist/src/personal-agent/request-result.js +45 -0
  335. package/dist/src/personal-agent/request-service.d.ts +18 -0
  336. package/dist/src/personal-agent/request-service.js +308 -0
  337. package/dist/src/personal-agent/service.js +30 -7
  338. package/dist/src/providers/auth-runtime/resolve-auth.js +1 -1
  339. package/dist/src/providers/index.js +2 -2
  340. package/dist/src/providers/model-reference-auditor.js +1 -1
  341. package/dist/src/providers/model-registry.js +1 -1
  342. package/dist/src/providers/register-runtime-providers.js +1 -1
  343. package/dist/src/remote-access/exposure-manager.js +1 -1
  344. package/dist/src/scenes/taskFollowUp/agentExecutor.js +4 -4
  345. package/dist/src/scenes/taskFollowUp/resources.js +1 -1
  346. package/dist/src/scenes/taskFollowUp/service.js +4 -4
  347. package/dist/src/session/client-history.d.ts +2 -1
  348. package/dist/src/session/client-history.js +40 -0
  349. package/dist/src/session/compact-history.js +9 -5
  350. package/dist/src/session/config-store.js +2 -1
  351. package/dist/src/session/index.js +2 -2
  352. package/dist/src/session/resolve-session.js +1 -1
  353. package/dist/src/session/session-context-for-llm.js +55 -0
  354. package/dist/src/session/session-title.js +1 -1
  355. package/dist/src/session/store.js +6 -4
  356. package/dist/src/session/thinking-resolve.js +1 -1
  357. package/dist/src/session/types.d.ts +2 -0
  358. package/dist/src/share/share-store.js +1 -1
  359. package/dist/src/share/share-thumbnail.js +1 -1
  360. package/dist/src/share/share-zip.js +1 -1
  361. package/dist/src/share/site-proxy.js +1 -1
  362. package/dist/src/share/site-share-store.js +1 -1
  363. package/dist/src/storage/sqlite/connection-wait-repository.d.ts +5 -1
  364. package/dist/src/storage/sqlite/connection-wait-repository.js +38 -8
  365. package/dist/src/storage/sqlite/connection.js +9 -9
  366. package/dist/src/storage/sqlite/migrations/231_task_result_deliveries.sql +32 -0
  367. package/dist/src/storage/sqlite/migrations/232_personal_requests.sql +28 -0
  368. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  369. package/dist/src/storage/sqlite/migrations/runner.js +3 -3
  370. package/dist/src/storage/sqlite/schema.js +1 -1
  371. package/dist/src/storage/sqlite/session-repository.js +33 -0
  372. package/dist/src/tasks/capabilities/read.js +2 -2
  373. package/dist/src/tasks/capabilities/write.js +1 -1
  374. package/dist/src/tasks/execution-context.js +1 -1
  375. package/dist/src/tasks/home-query-service.js +3 -3
  376. package/dist/src/tasks/index.js +4 -4
  377. package/dist/src/tasks/task-application-service.d.ts +1 -0
  378. package/dist/src/tasks/task-application-service.js +10 -3
  379. package/dist/src/tasks/task-collaboration-delivery.js +1 -1
  380. package/dist/src/tasks/task-context-assembler.js +2 -1
  381. package/dist/src/tasks/task-handoff-service.js +1 -1
  382. package/dist/src/tasks/task-main-update-decision-service.js +1 -1
  383. package/dist/src/tasks/task-main-update-delivery.js +32 -1
  384. package/dist/src/tasks/task-result-delivery-repository.d.ts +18 -0
  385. package/dist/src/tasks/task-result-delivery-repository.js +144 -0
  386. package/dist/src/tasks/task-result-delivery-service.d.ts +4 -0
  387. package/dist/src/tasks/task-result-delivery-service.js +128 -0
  388. package/dist/src/tasks/task-run-coordinator.js +6 -1
  389. package/dist/src/tasks/task-run-dispatcher.d.ts +1 -0
  390. package/dist/src/tasks/task-run-dispatcher.js +22 -3
  391. package/dist/src/tui/backends/embedded-backend.js +10 -10
  392. package/dist/src/tui/backends/gateway-realtime-backend.js +1 -1
  393. package/dist/src/tui/extension-host/load-extensions.js +1 -1
  394. package/dist/src/tui/tui-command-formatters.js +1 -1
  395. package/dist/src/tui/tui-commands.js +6 -6
  396. package/dist/src/tui/tui-picker-overlay.js +1 -1
  397. package/dist/src/tui/tui-skills-autocomplete.js +1 -1
  398. package/dist/src/tui/tui-startup-resources.js +4 -4
  399. package/dist/src/tui/tui.js +7 -7
  400. package/dist/src/tunnel/frpc-binary.js +1 -1
  401. package/dist/src/tunnel/gateway-lifecycle.js +1 -1
  402. package/dist/src/voice/realtime/memory-context.js +3 -3
  403. package/dist/src/voice/realtime/runtime.js +4 -4
  404. package/dist/src/voice/stt/index.js +2 -2
  405. package/dist/src/voice/stt/preflight.js +1 -1
  406. package/dist/src/voice/stt/providers/alibaba-transcription.js +1 -1
  407. package/dist/src/voice/stt/providers/xopc-cloud-transcription.js +1 -1
  408. package/dist/src/voice/stt/transcribe-core.js +1 -1
  409. package/dist/src/voice/tts/index.js +3 -3
  410. package/dist/src/voice/tts/merge-config.js +1 -1
  411. package/dist/src/voice/tts/payload.js +1 -1
  412. package/dist/src/voice/tts/providers/xopc-cloud-speech.js +1 -1
  413. package/dist/src/voice/tts/speak-core.js +1 -1
  414. package/dist/src/work-discovery/incremental-repository.js +1 -1
  415. package/dist/src/work-discovery/index.js +1 -1
  416. package/dist/src/work-discovery/service.js +5 -5
  417. package/dist/src/workflows/engine/workflow-engine.js +1 -1
  418. package/dist/src/workflows/service/workflow-run-service.js +8 -8
  419. package/dist/src/workflows/service/workflow-session-bridge.js +1 -1
  420. package/package.json +1 -1
  421. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-B23VK3UU.js +0 -1
  422. package/dist/gateway/static/root/assets/agent-plugin-dialog-BuKJ-Ybo.js +0 -1
  423. package/dist/gateway/static/root/assets/agents-DxH-UFs7.js +0 -66
  424. package/dist/gateway/static/root/assets/automations-workspace-DMqpfefB.js +0 -7
  425. package/dist/gateway/static/root/assets/capabilities-page-KUggKcIq.js +0 -2
  426. package/dist/gateway/static/root/assets/capabilities-settings-panel-CD5K7e1B.js +0 -8
  427. package/dist/gateway/static/root/assets/channels-CG_xCUnf.js +0 -1
  428. package/dist/gateway/static/root/assets/computer-settings-page-CqY40STw.js +0 -1
  429. package/dist/gateway/static/root/assets/connectors-page-Cn14oruE.js +0 -2
  430. package/dist/gateway/static/root/assets/date-picker-B4jSGi8k.js +0 -1
  431. package/dist/gateway/static/root/assets/device-pairing-wizard-DKO8iqDJ.js +0 -1
  432. package/dist/gateway/static/root/assets/gateway-settings-DAQu7q_Q.js +0 -1
  433. package/dist/gateway/static/root/assets/home-page-BHS2713D.js +0 -1
  434. package/dist/gateway/static/root/assets/index-BcTY7RBG.js +0 -106
  435. package/dist/gateway/static/root/assets/notes-page-FORwlFnt.js +0 -8
  436. package/dist/gateway/static/root/assets/personal-page-BpTFGG44.js +0 -1
  437. package/dist/gateway/static/root/assets/popover-select-BNZZDJpO.js +0 -1
  438. package/dist/gateway/static/root/assets/remote-access-hub-CzzTxbhr.js +0 -1
  439. package/dist/gateway/static/root/assets/session-manager-BK5IvdGz.js +0 -16
  440. package/dist/gateway/static/root/assets/sessions-page-DkXKhSWK.js +0 -1
  441. package/dist/gateway/static/root/assets/settings-advanced-gate-C7ww6VRj.js +0 -1
  442. package/dist/gateway/static/root/assets/settings-shell-layer-context-BTQUDoJ2.js +0 -1
  443. package/dist/gateway/static/root/assets/shares-settings-DXpj-oOC.js +0 -1
  444. package/dist/gateway/static/root/assets/skills-page-cwXzLyU0.js +0 -2
  445. package/dist/gateway/static/root/assets/user-model-page-DpPGpkkg.js +0 -2
  446. package/dist/gateway/static/root/assets/workflows-page-CgJlVdec.js +0 -6
@@ -1,2 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/skills-page-cwXzLyU0.js","assets/rolldown-runtime-aKtaBQYM.js","assets/index-BcTY7RBG.js","assets/preload-helper-zJ_50EbN.js","assets/es2015-DBLcMg5B.js","assets/vendor-react-BOUWij0V.js","assets/dist-CxGUk8J-.js","assets/dist-CI_fqRk-.js","assets/floating-ui.dom-B7uQOZZW.js","assets/markdown-view-DKlJx4eo.js","assets/dist-BGTk37IG.js","assets/chunk-KS7C4IRE-BMYIfy9x.js","assets/createLucideIcon-DPHK1VkS.js","assets/download-Dk-ZjtO6.js","assets/plus-Q2yW6OE7.js","assets/x-B_N4OPjy.js","assets/locale-store-ChN_vjs2.js","assets/messages-CnM6Qfr7.js","assets/cn-JdwAhgNB.js","assets/app-link-DRL0YnPs.js","assets/product-delivery-BAks11S4.js","assets/schemas-CObaziC7.js","assets/local-apps-yys1VChX.js","assets/copy-to-clipboard-HOJ79TWv.js","assets/markdown-view-DSjfHfaW.css","assets/dist-Che_jiQF.js","assets/vendor-swr-BIWyz7Rc.js","assets/activity-YogQEteU.js","assets/bot-DjLkhyZL.js","assets/check-DUBLcKHA.js","assets/chevron-right-BweFrslA.js","assets/popover-select-BNZZDJpO.js","assets/dist-C3DSFZCi.js","assets/skeleton-BwbyijEw.js","assets/settings-shell-dialog-layer-BU3UuiJr.js","assets/settings-shell-layer-context-BTQUDoJ2.js","assets/circle-alert-BEjgurr2.js","assets/circle-check-C23XjkUj.js","assets/circle-dashed-8qMD7gHf.js","assets/circle-dot-BAseJTrF.js","assets/circle-pause-CN9jYH2s.js","assets/clock-3-DnrAnuyZ.js","assets/cloud-C4-yfnnk.js","assets/copy-Dv6d4Dvw.js","assets/ellipsis-0k4rZLoy.js","assets/external-link-DjqjBmc3.js","assets/secret-input-DPl3VYM8.js","assets/eye-CABVeTq0.js","assets/loader-circle-CifKLtgG.js","assets/form-field-width-DJw_jULe.js","assets/interaction-BdhHBbYa.js","assets/is-masked-secret-DOkL5b_X.js","assets/use-composer-attachments-qK3z-EGz.js","assets/mic-CuUb7zc-.js","assets/use-file-preview-expanded-D809I8ur.js","assets/folder-open-CyzJ19I9.js","assets/link-2-D_ZKYUW7.js","assets/message-square-plus-XP0tGdlV.js","assets/minimize-2-DtOGrlpo.js","assets/pencil-DmIY3Oa-.js","assets/rotate-cw-LIg3Am9S.js","assets/search-DA7gz22f.js","assets/index.module-Cd9ENXfk.js","assets/session-api-UkGomZfv.js","assets/gateway-startup-retry-Wtxq_y2f.js","assets/constants-Co2_smKQ.js","assets/app-chrome-BeB4KgOf.js","assets/attachment-utils-core-BIOUBrpT.js","assets/workspace-api-BtXzxf_w.js","assets/files-Bw4SBGdM.js","assets/electron-env-Dit0bHgy.js","assets/use-async-resource-GrnWNwMZ.js","assets/activity-store-CnmHVy1D.js","assets/share-link-dialog-QAjExHAL.js","assets/globe-DSSGFWFn.js","assets/button-CS04eWY9.js","assets/copy-text-row-BHDs3cBa.js","assets/capabilities-Bigu28Z6.js","assets/local-session-drafts-CeHhcudO.js","assets/tasks-CH6KoBeY.js","assets/skill-wire-pattern-BPpeIcCi.js","assets/shares-api-DwqLga5H.js","assets/capabilities-BXG_5wIg.js","assets/git-branch-Dh9uxTot.js","assets/notes-api-D8nvWMMC.js","assets/message-square-fVE7Ghj1.js","assets/pause-DuPxgSxk.js","assets/play-kxZvpBg8.js","assets/rotate-ccw-JM1TBLpp.js","assets/settings-2-D-csvaET.js","assets/sparkles-DHlfQFAF.js","assets/middleware-Pd0e8Igk.js","assets/gateway-realtime-DBRa17u3.js","assets/gateway-realtime-store-7glMlD2l.js","assets/extension-provider-aigS3RJu.js","assets/session-manager-BK5IvdGz.js","assets/tool-activity-BtJkgjFf.js","assets/registry-api-BM_81rLe.js","assets/agents-admin-api-BtnYiq7O.js","assets/gateway-config-swr-EZxaKXdC.js","assets/send-session-input-OaBPDJ9E.js","assets/theme-store-DTYk7Gll.js","assets/loopi-Djb8XU3l.js","assets/loopi-C09I2mNj.css","assets/models-hub-cache-DnIOzcvn.js","assets/oauth-api-BXn1a9qx.js","assets/skill-api-utils-C7V4JVXM.js","assets/model-display-name-DXhO9rcM.js","assets/settings-form-draft-Dy10ldo8.js","assets/index-DUgsBdV3.css","assets/page-tabs-D2xpUV26.js","assets/capability-header-actions-CA_XNTSW.js","assets/capability-icon-BYm2-nS-.js","assets/skill-api-BO1b2oYj.js","assets/skill-reload-api-C1hzIawD.js","assets/connectors-page-Cn14oruE.js","assets/connector-service-page-BKAt0jvO.js","assets/agent-plugin-dialog-BuKJ-Ybo.js","assets/apps-page-ChPOmrPa.js","assets/agents-DxH-UFs7.js","assets/directory-picker-path-field-C40-GlX1.js","assets/settings-page-layout-X1x-2Cp9.js","assets/channels-CG_xCUnf.js","assets/browser-BLJWD7WI.js","assets/schema-form-BQz6ezGe.js","assets/settings-loading-skeleton-CAmWMaOT.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{m as a,r as o}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{t as s}from"./messages-CnM6Qfr7.js";import{n as c}from"./locale-store-ChN_vjs2.js";import{t as l}from"./skeleton-BwbyijEw.js";import{Ki as u,Xa as d}from"./index-BcTY7RBG.js";import{t as f}from"./capability-header-actions-CA_XNTSW.js";var p=n(),m=e(t(),1),h=r(),g=(0,m.lazy)(()=>i(()=>import(`./skills-page-cwXzLyU0.js`).then(e=>({default:e.SkillsPage})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114]))),_=(0,m.lazy)(()=>i(()=>import(`./connectors-page-Cn14oruE.js`).then(e=>({default:e.ConnectorsPage})),__vite__mapDeps([115,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,116,117]))),v=(0,m.lazy)(()=>i(()=>import(`./apps-page-ChPOmrPa.js`).then(e=>({default:e.ExtensionsPage})),__vite__mapDeps([118,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,117]))),y=(0,m.lazy)(()=>i(()=>import(`./agents-DxH-UFs7.js`).then(e=>({default:e.AgentsSettingsPanel})),__vite__mapDeps([119,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,120,121]))),b=(0,m.lazy)(()=>i(()=>import(`./channels-CG_xCUnf.js`).then(e=>({default:e.ChannelsSettingsPanel})),__vite__mapDeps([122,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,123,124,125,121])));function x(e){return d.includes(e)?e:null}function S(e){let t=(0,p.c)(3),{label:n}=e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=Array.from({length:6},C),t[0]=r):r=t[0];let i;return t[1]===n?i=t[2]:(i=(0,h.jsx)(`div`,{className:`mx-auto grid w-full max-w-7xl gap-4 px-4 pb-7 pt-3 sm:grid-cols-2 sm:px-6 lg:grid-cols-3 lg:px-8 lg:pb-9 lg:pt-4`,"aria-label":n,"aria-busy":!0,children:r}),t[1]=n,t[2]=i),i}function C(e,t){return(0,h.jsx)(l,{className:`h-40 rounded-xl`},t)}function w(){let e=(0,p.c)(41),t=c(D),n;e[0]===t?n=e[1]:(n=s(t),e[0]=t,e[1]=n);let r=n,i=r.capabilitiesHub,{section:l,detailId:d}=a(),C;e[2]===l?C=e[3]:(C=x(l),e[2]=l,e[3]=C);let w=C,O=w??`skills`,k=r.productNavigation.sections[`capabilities-${O}`],A=u(E),j=u(T),M;e[4]===O?M=e[5]:(M={section:O,value:null},e[4]=O,e[5]=M);let[N,P]=(0,m.useState)(M),F=N.section===O?N.value:null,I;e[6]===O?I=e[7]:(I=e=>{P({section:O,value:e})},e[6]=O,e[7]=I);let L=I,R,z;if(e[8]!==j||e[9]!==F||e[10]!==k||e[11]!==A?(R=()=>(A({startExtra:null,main:(0,h.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:k}),end:(0,h.jsx)(f,{contribution:F})}),()=>j()),z=[j,F,k,A],e[8]=j,e[9]=F,e[10]=k,e[11]=A,e[12]=R,e[13]=z):(R=e[12],z=e[13]),(0,m.useLayoutEffect)(R,z),!w){let t;return e[14]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,h.jsx)(o,{to:`/capabilities/skills`,replace:!0}),e[14]=t):t=e[14],t}let B;e[15]===i.discoverLoading?B=e[16]:(B=(0,h.jsx)(S,{label:i.discoverLoading}),e[15]=i.discoverLoading,e[16]=B);let V;e[17]!==d||e[18]!==L||e[19]!==O?(V=O===`agents`?(0,h.jsx)(y,{agentId:d,onHeaderActionChange:L}):null,e[17]=d,e[18]=L,e[19]=O,e[20]=V):V=e[20];let H;e[21]!==L||e[22]!==O?(H=O===`skills`?(0,h.jsx)(g,{embedded:!0,onHeaderActionChange:L}):null,e[21]=L,e[22]=O,e[23]=H):H=e[23];let U;e[24]!==L||e[25]!==O?(U=O===`connectors`?(0,h.jsx)(_,{embedded:!0,onHeaderActionChange:L}):null,e[24]=L,e[25]=O,e[26]=U):U=e[26];let W;e[27]!==d||e[28]!==L||e[29]!==O?(W=O===`channels`?(0,h.jsx)(b,{channelId:d,onHeaderActionChange:L}):null,e[27]=d,e[28]=L,e[29]=O,e[30]=W):W=e[30];let G;e[31]!==L||e[32]!==O?(G=O===`extensions`?(0,h.jsx)(v,{embedded:!0,onHeaderActionChange:L}):null,e[31]=L,e[32]=O,e[33]=G):G=e[33];let K;return e[34]!==W||e[35]!==G||e[36]!==B||e[37]!==V||e[38]!==H||e[39]!==U?(K=(0,h.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:(0,h.jsxs)(m.Suspense,{fallback:B,children:[V,H,U,W,G]})}),e[34]=W,e[35]=G,e[36]=B,e[37]=V,e[38]=H,e[39]=U,e[40]=K):K=e[40],K}function T(e){return e.clearPageHeader}function E(e){return e.setPageHeader}function D(e){return e.language}export{w as CapabilitiesPage};
@@ -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{t as u}from"./chevron-right-BweFrslA.js";import{n as d,r as f,t as p}from"./popover-select-BNZZDJpO.js";import{t as m}from"./circle-check-C23XjkUj.js";import{t as h}from"./circle-dashed-8qMD7gHf.js";import{t as g}from"./cloud-C4-yfnnk.js";import{t as _}from"./external-link-DjqjBmc3.js";import{t as v}from"./secret-input-DPl3VYM8.js";import{t as y}from"./eye-CABVeTq0.js";import{t as b}from"./loader-circle-CifKLtgG.js";import{t as x}from"./mic-CuUb7zc-.js";import{t as S}from"./pencil-DmIY3Oa-.js";import{t as C}from"./play-kxZvpBg8.js";import{t as w}from"./plus-Q2yW6OE7.js";import{t as T}from"./settings-2-D-csvaET.js";import{t as E}from"./x-B_N4OPjy.js";import{t as D}from"./messages-CnM6Qfr7.js";import{t as O}from"./cn-JdwAhgNB.js";import{a as k,c as A,i as j,n as M,r as N}from"./locale-store-ChN_vjs2.js";import{a as P,i as F,n as I,o as L,r as R,s as ee,t as z}from"./dist-BGTk37IG.js";import{i as B}from"./vendor-swr-BIWyz7Rc.js";import{t as V}from"./button-CS04eWY9.js";import{n as H,t as te}from"./interaction-BdhHBbYa.js";import{n as ne,r as U}from"./gateway-config-swr-EZxaKXdC.js";import{a as W,o as G,s as K}from"./form-field-width-DJw_jULe.js";import{n as re}from"./is-masked-secret-DOkL5b_X.js";import{t as q}from"./skeleton-BwbyijEw.js";import{i as J,o as Y}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{t as X}from"./electron-env-Dit0bHgy.js";import{n as Z,t as ie}from"./settings-form-draft-Dy10ldo8.js";import{t as ae}from"./model-display-name-DXhO9rcM.js";import{i as oe,r as se,t as ce}from"./models-hub-cache-DnIOzcvn.js";import{a as le,i as ue,n as de,o as fe,r as pe,t as me}from"./oauth-api-BXn1a9qx.js";import{$i as he,As as ge,At as _e,Ct as ve,Do as ye,Dt as be,Es as xe,Et as Se,Fo as Ce,Ft as we,Ho as Te,It as Ee,Ji as De,Mc as Oe,Mt as ke,Ot as Ae,Pt as je,Qa as Me,Qi as Ne,St as Pe,Tt as Fe,Yi as Ie,_t as Le,aa as Re,bt as ze,ca as Be,co as Ve,da as He,eo as Ue,gt as We,ht as Ge,jc as Ke,kt as qe,la as Je,ls as Ye,mn as Xe,na as Ze,oa as Qe,qi as $e,sa as et,so as tt,ti as nt,ua as rt,vt as it,wo as at,wt as ot,xt as st,yn as ct,yo as lt,yt as ut}from"./index-BcTY7RBG.js";import{t as dt}from"./page-tabs-D2xpUV26.js";import{n as ft,r as pt}from"./settings-page-layout-X1x-2Cp9.js";import{n as mt,t as ht}from"./settings-form-section-exRhP9xn.js";import{t as gt}from"./settings-loading-skeleton-CAmWMaOT.js";import{n as _t,t as vt}from"./use-autosave-R3hEHQQq.js";import{c as yt,d as bt,i as xt,l as St,n as Ct,o as wt,r as Tt,s as Et,t as Dt}from"./voice-config-api-CxGsCDoW.js";import{t as Ot}from"./voice-api-key-field-C-AF-IcO.js";import{t as kt}from"./settings-advanced-gate-C7ww6VRj.js";import{a as At,i as jt,n as Mt,o as Nt,r as Pt,t as Ft}from"./image-generation-api-Bnl0CH4n.js";var It=n(),Q=e(t(),1),$=r(),Lt={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 必须使用“名称: 值”格式,每行一个。`}},Rt=`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 zt(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 Bt(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 Vt({open:e,onOpenChange:t,provider:n,configured:r,language:i,onSaved:a}){let o=Lt[i],[s,c]=(0,Q.useState)(``),[l,u]=(0,Q.useState)(``),[d,f]=(0,Q.useState)(``),[m,h]=(0,Q.useState)(`bearer`),[g,_]=(0,Q.useState)(`x-api-key`),[x,S]=(0,Q.useState)(``),[C,T]=(0,Q.useState)(``),[D,k]=(0,Q.useState)(``),[A,j]=(0,Q.useState)(`/images/generations`),[M,N]=(0,Q.useState)(`/images/edits`),[B,H]=(0,Q.useState)(``),[te,ne]=(0,Q.useState)(``),[U,W]=(0,Q.useState)([zt()]),[G,K]=(0,Q.useState)(``),[q,X]=(0,Q.useState)(),[Z,ie]=(0,Q.useState)(!1),[ae,oe]=(0,Q.useState)(),[se,ce]=(0,Q.useState)(),[le,ue]=(0,Q.useState)();(0,Q.useEffect)(()=>{if(!e)return;let t=n?.imageGeneration;c(n?.providerId??``),u(t?.name??``),f(n?.baseUrl??``),h(t?.auth.type??`bearer`),_(t?.auth.type===`header`?t.auth.headerName:`x-api-key`),S(r?`••••••••••••`:``),T(t?.apiKeyUrl??``),k(t?.documentationUrl??``),j(t?.paths?.generations??`/images/generations`),N(t?.paths?.edits??`/images/edits`),H(t?.network?.allowedHosts.join(`
4
- `)??``),ne(Object.entries(n?.headers??{}).map(([e,t])=>`${e}: ${t}`).join(`
5
- `)),W(t?.models.map(zt)??[zt()]),K(t?.defaultModel??``),ce(void 0),X(void 0),ie(!1),oe(void 0),ue(void 0)},[r,e,n]);let de=(0,Q.useMemo)(()=>U.filter(e=>e.id.trim()).map(e=>({value:e.id.trim(),label:e.name.trim()||e.id.trim()})),[U]),fe=(e,t)=>{W(n=>n.map((n,r)=>r===e?{...n,...t}:n))},pe=()=>{let e=s.trim(),t=U.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=G||t[0]?.id;if(!n||!t.some(e=>e.id===n))throw Error(o.required);let r;try{r=Bt(te)}catch{throw Error(o.invalidHeaders)}return{providerId:e,input:{baseUrl:d.trim(),...r?{headers:r}:{},imageGeneration:{api:`openai-images`,name:l.trim(),...D.trim()?{documentationUrl:D.trim()}:{},...C.trim()?{apiKeyUrl:C.trim()}:{},defaultModel:n,auth:m===`header`?{type:`header`,headerName:g.trim()}:{type:m},paths:{...A.trim()?{generations:A.trim()}:{},...M.trim()?{edits:M.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}}}))}}}},me=async()=>{let e=pe();return await jt(e.providerId,e.input),m!==`none`&&x.trim()&&!re(x)&&await At(e.providerId,x.trim()),await a(e.providerId),e},he=async()=>{X(`save`),oe(void 0),ce(void 0);try{await me(),S(m===`none`?``:`••••••••••••`),ce(o.saved)}catch(e){oe(e instanceof Error?e.message:String(e))}finally{X(void 0)}},ge=async()=>{X(`test`),oe(void 0),ce(void 0),ue(void 0);try{let e=await me();ue((await Nt(e.providerId,e.input.imageGeneration.defaultModel)).images[0]?.dataUrl),ce(o.testReady)}catch(e){oe(e instanceof Error?e.message:String(e))}finally{X(void 0)}},_e=async()=>{if(n){if(!Z){ie(!0);return}X(`delete`),oe(void 0);try{await Ft(n.providerId),await a(),t(!1)}catch(e){oe(e instanceof Error?e.message:String(e))}finally{X(void 0)}}};return(0,$.jsx)(z,{open:e,onOpenChange:t,children:(0,$.jsxs)(L,{children:[(0,$.jsx)(P,{className:O(`xopc-dialog-overlay fixed inset-0 bg-scrim`,Y)}),(0,$.jsxs)(R,{className:O(`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`,J),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)(ee,{className:`font-semibold text-fg`,children:n?o.editTitle:o.addTitle}),(0,$.jsx)(F,{className:`mt-1 text-sm text-fg-muted`,children:o.intro})]}),(0,$.jsx)(I,{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)(E,{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:Rt}),(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:Rt})]})]}),(0,$.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[o.baseUrl,(0,$.jsx)(`input`,{value:d,onChange:e=>f(e.target.value),placeholder:`https://api.example.com/v1`,className:Rt})]}),(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)(p,{value:m,options:[{value:`bearer`,label:o.bearer},{value:`header`,label:o.header},{value:`none`,label:o.none}],placeholder:o.auth,allowEmpty:!1,onChange:e=>h(e),triggerClassName:`mt-1.5`})]}),m===`header`?(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.headerName,(0,$.jsx)(`input`,{value:g,onChange:e=>_(e.target.value),className:Rt})]}):null]}),m===`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}),C.trim()?(0,$.jsxs)(`a`,{href:C.trim(),target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent hover:underline`,children:[o.openKeyPage,(0,$.jsx)(Ke,{className:`size-3.5`})]}):null]}),(0,$.jsx)(v,{id:`custom-image-api-key`,value:x,onChange:e=>S(re(x)?e.replace(/^•+/,``):e),labels:{show:o.show,hide:o.hide,copy:o.copy,copied:o.copied},reveal:()=>Ee(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:C,onChange:e=>T(e.target.value),placeholder:`https://…`,className:Rt})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.docsUrl,(0,$.jsx)(`input`,{value:D,onChange:e=>k(e.target.value),placeholder:`https://…`,className:Rt})]})]}),(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:A,onChange:e=>j(e.target.value),className:Rt})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.editsPath,(0,$.jsx)(`input`,{value:M,onChange:e=>N(e.target.value),className:Rt})]})]}),(0,$.jsxs)(`label`,{className:`mt-4 block text-xs font-medium text-fg-muted`,children:[o.allowedHosts,(0,$.jsx)(`textarea`,{value:B,onChange:e=>H(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:te,onChange:e=>ne(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)(V,{variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,onClick:()=>W(e=>[...e,zt()]),children:[(0,$.jsx)(w,{className:`size-4`}),o.addModel]})]}),(0,$.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[o.defaultModel,(0,$.jsx)(p,{value:G||de[0]?.value||``,options:de,placeholder:o.defaultModel,allowEmpty:!1,onChange:K,triggerClassName:`mt-1.5 max-w-sm`})]}),U.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=>fe(t,{id:e.target.value}),placeholder:`image-1`,className:Rt})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.modelName,(0,$.jsx)(`input`,{value:e.name,onChange:e=>fe(t,{name:e.target.value}),className:Rt})]})]}),(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=>fe(t,{maxCount:e.target.value}),className:Rt})]}),(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=>fe(t,{defaultCount:e.target.value}),className:Rt})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.defaultSize,(0,$.jsx)(`input`,{value:e.defaultSize,onChange:e=>fe(t,{defaultSize:e.target.value}),placeholder:`1024x1024`,className:Rt})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.format,(0,$.jsx)(p,{value:e.outputFormat,options:[{value:`png`,label:`PNG`},{value:`jpeg`,label:`JPEG`},{value:`webp`,label:`WebP`}],placeholder:o.format,allowEmpty:!0,onChange:e=>fe(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=>fe(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=>fe(t,{editEnabled:e.target.checked})}),o.edit]}),(0,$.jsxs)(`button`,{type:`button`,disabled:U.length===1,onClick:()=>W(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)(Ve,{className:`size-3.5`}),o.remove]})]})]},t))]}),le?(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)(y,{className:`size-4`}),o.testReady]}),(0,$.jsx)(`img`,{src:le,alt:`Generated provider test`,className:`max-h-72 rounded-lg object-contain`})]}):null,se?(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:se}):null,ae?(0,$.jsx)(`p`,{className:`rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-600 dark:text-red-400`,children:ae}):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)(V,{variant:`secondary`,className:`border-red-500/30 text-red-600 hover:bg-red-500/10 dark:text-red-400`,disabled:!!q,onClick:()=>void _e(),children:[q===`delete`?(0,$.jsx)(b,{className:`size-4 animate-spin`}):(0,$.jsx)(Ve,{className:`size-4`}),Z?o.confirmDelete:o.delete]}):null,(0,$.jsxs)(`div`,{className:`ml-auto flex gap-2`,children:[(0,$.jsx)(I,{asChild:!0,children:(0,$.jsx)(V,{variant:`secondary`,children:o.cancel})}),(0,$.jsxs)(V,{variant:`secondary`,disabled:!!q,onClick:()=>void ge(),children:[q===`test`?(0,$.jsx)(b,{className:`size-4 animate-spin`}):null,q===`test`?o.testing:o.test]}),(0,$.jsxs)(V,{variant:`primary`,disabled:!!q,onClick:()=>void he(),children:[q===`save`?(0,$.jsx)(b,{className:`size-4 animate-spin`}):null,q===`save`?o.saving:o.save]})]})]})]})]})})}var Ht=`••••••••••••`,Ut={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 Wt(){let e=await k(N(`/api/image-generation/default`));if(!e.payload)throw Error(`Invalid default image generation response`);return e.payload}function Gt(e){let t=e?.indexOf(`/`)??-1;return t>0?e.slice(0,t):void 0}function Kt(e){let t=e?.indexOf(`/`)??-1;return t>0?e.slice(t+1):void 0}function qt(e){return Object.fromEntries(e.configFields.map(t=>[t.key,e.config[t.key]??(t.required?t.options?.[0]?.value??``:``)]))}function Jt(e){let t=(0,It.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)(p,{value:r,options:(n.options??[]).map(Yt),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 Yt(e){return{value:e.value,label:e.label}}function Xt(){let e=(0,It.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(q,{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(Zt)}),(0,$.jsx)(q,{className:`h-64 rounded-xl`})]}),e[1]=n):n=e[1],n}function Zt(e,t){return(0,$.jsx)(q,{className:`h-24 rounded-xl`},t)}function Qt(){let e=M(e=>e.language),t=Ut[e],n=!!A(e=>e.conversationId),[r,a]=(0,Q.useState)(``),[o,s]=(0,Q.useState)(``),[c,l]=(0,Q.useState)(``),[u,d]=(0,Q.useState)({}),[f,h]=(0,Q.useState)(!1),[g,_]=(0,Q.useState)(),[y,x]=(0,Q.useState)(!1),[S,C]=(0,Q.useState)(!1),[E,D]=(0,Q.useState)(),{data:O,isLoading:j,error:P,mutate:F}=B(n?N(`/api/image-generation/catalog`):null,Pt,{revalidateOnFocus:!1}),{data:I,isLoading:L,error:R,mutate:ee}=B(n?N(`/api/image-generation/custom-providers`):null,Mt,{revalidateOnFocus:!1}),{data:z,isLoading:H,error:te,mutate:U}=B(n?`default-image-generation`:null,Wt,{revalidateOnFocus:!1});(0,Q.useEffect)(()=>{if(!O||!z)return;let e=Gt(z.model?.primary),t=O.find(t=>t.id===e)??O.find(e=>e.configured)??O[0];t&&(a(t.id),s(t.id===e&&Kt(z.model?.primary)||t.defaultModel),l(t.configured?Ht:``),d(qt(t)))},[z,O]);let W=O?.find(e=>e.id===r),G=W?W.apiKeyUrl??Se(W.id,e)[0]?.href:void 0,K=(0,Q.useMemo)(()=>(W?.models??[]).map(e=>({value:e,label:e})),[W?.models]),q=z?.model?.primary,J=!!(W&&o&&(W.credentialMode!==`api-key`||W.configured||c.trim())&&W.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(j||L||H)return(0,$.jsx)(Xt,{});if(P||R||te||!O||!I)return(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:t.loadError});let Y=e=>{a(e.id),s(e.defaultModel),l(e.configured?Ht:``),d(qt(e)),_(void 0)},X=()=>{D(void 0),C(!0)},Z=()=>{let e=I.find(e=>e.providerId===W?.id);e&&(D(e),C(!0))},ie=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?Ht:``),d(qt(r)),D(t?.find(t=>t.providerId===e))}},ae=async()=>{if(!(!W||!J)){h(!0),_(void 0),x(!1);try{let e=await k(N(`/api/image-generation/default/setup`),{method:`POST`,body:JSON.stringify({providerId:W.id,modelId:o,...c.trim()&&!re(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([U(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`)])),ne()]),l(Ht),x(!0)}catch(e){_(e instanceof Error?e.message:String(e))}finally{h(!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)(ge,{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)(V,{variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,onClick:X,children:[(0,$.jsx)(w,{className:`size-4`}),t.addService]})]}),(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:O.map(e=>{let n=e.id===r,i=e.id===Gt(q);return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>Y(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)(m,{className:`size-3.5`}):(0,$.jsx)(xe,{className:`size-3.5`}),e.configured||e.credentialMode!==`api-key`?t.configured:t.needsKey]})]},e.id)})})]}),W?(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)(p,{value:o,options:K,placeholder:t.selectModel,allowEmpty:!1,onChange:s,triggerClassName:`mt-1.5`})]}),W.configFields.filter(e=>e.required).map(e=>(0,$.jsx)(Jt,{field:e,value:u[e.key]??``,onChange:t=>d(n=>({...n,[e.key]:t}))},e.key))]}),W.source===`custom`?(0,$.jsx)(`div`,{className:`mt-4 flex justify-end`,children:(0,$.jsxs)(V,{variant:`secondary`,onClick:Z,children:[(0,$.jsx)(T,{className:`size-4`}),t.manageService]})}):null,W.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}),G?(0,$.jsxs)(`a`,{href:G,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs font-medium text-accent hover:underline`,children:[t.getApiKey,(0,$.jsx)(Ke,{className:`size-3.5`,"aria-hidden":`true`})]}):null]}),(0,$.jsx)(v,{id:`image-generation-api-key`,value:c,onChange:e=>l(re(c)?e.replace(/^•+/,``):e),placeholder:W.configured?t.existingKey:t.needsKey,labels:{show:t.show,hide:t.hide,copy:t.copy,copied:t.copied},reveal:()=>Ee(W.id).then(e=>e.apiKey),loadFailedLabel:t.revealFailed,notInConfigFile:t.keyNotRevealable,className:`mt-1.5`,autoComplete:`new-password`},W.id),(0,$.jsx)(`span`,{className:`mt-1.5 block font-normal leading-relaxed text-fg-subtle`,children:W.configured?t.savedKey:t.apiKeyHint})]}):null,W.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)(at,{className:`size-4`}),t.advanced]}),(0,$.jsx)(`div`,{className:`mt-3 grid gap-3 md:grid-cols-2`,children:W.configFields.filter(e=>!e.required).map(e=>(0,$.jsx)(Jt,{field:e,value:u[e.key]??``,onChange:t=>d(n=>({...n,[e.key]:t}))},e.key))})]}):null,y?(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,g?(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:g}):null,(0,$.jsx)(`div`,{className:`mt-4 flex justify-end`,children:(0,$.jsxs)(V,{variant:`primary`,disabled:!J||f,onClick:()=>void ae(),children:[f?(0,$.jsx)(b,{className:`size-4 animate-spin`}):(0,$.jsx)(m,{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:f?t.enabling:t.enable})]})]})})]}):null,(0,$.jsx)(Vt,{open:S,onOpenChange:C,provider:E,configured:!!(E&&O.find(e=>e.id===E.providerId)?.configured),language:e,onSaved:ie})]})}function $t({disabled:e=!1}){let t=M(e=>e.language)===`zh`,[n,r]=(0,Q.useState)(!1),[i,a]=(0,Q.useState)(``),{data:o,mutate:s,error:c}=B(N(`/api/voice/catalog`),async e=>{let t=await k(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`},u=async e=>{if(o){r(!0),a(``);try{let t=await k(N(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 ne()}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)(V,{variant:`secondary`,disabled:n||e||!o,onClick:()=>void u(),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)(d,{className:`w-full`,value:i?.model??``,disabled:n||e||!a.length,onChange:e=>void u({mode:r,model:e.target.value}),children:[(0,$.jsx)(f,{value:``,disabled:!0,children:t?`选择模型`:`Choose model`}),i&&!s?(0,$.jsxs)(f,{value:i.model,disabled:!0,children:[i.model,` · `,t?`不可用`:`Unavailable`]}):null,a.map(e=>(0,$.jsx)(f,{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)(d,{className:`w-full`,value:i?.voice??``,disabled:n||e,onChange:e=>void u({mode:r,model:s.id,voice:e.target.value}),children:s.voice.voices.map(e=>(0,$.jsxs)(f,{value:e.id,children:[e.name,e.gender?` · ${t?e.gender===`female`?`女声`:`男声`:e.gender}`:``,e.style?` · ${e.style}`:``]},e.id))}),s.voice.voices.find(e=>e.id===(i?.voice??s.voice.defaultVoice))?.description?(0,$.jsx)(`span`,{className:`block text-xs text-fg-muted`,children:s.voice.voices.find(e=>e.id===(i?.voice??s.voice.defaultVoice))?.description}):null]}):null]},r)}):(0,$.jsx)(q,{className:`h-48 w-full`})]})}function en({v:e}){let t=rt(e=>e.microphoneId),n=rt(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 u=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)(d,{value:t,onChange:e=>n(e.target.value),children:[(0,$.jsx)(f,{value:``,children:e.experience.systemDevice}),t&&!r.some(e=>e.deviceId===t)?(0,$.jsx)(f,{value:t,children:e.experience.unavailable}):null,r.filter(e=>e.deviceId&&e.deviceId!=="default").map((t,n)=>(0,$.jsx)(f,{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)(V,{variant:`secondary`,disabled:s,onClick:()=>void u(),children:e.experience.refreshDevices}),a?(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-red-600`,children:a}):null]})}function tn({v:e,canListen:t,canSpeak:n,disabled:r,onVerified:i}){let a=e.setup,o=(0,Q.useContext)(Ze)?.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 St(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 et,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:He()}),t.signal.aborted){l();return}if(s=await Be.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 Re.start(r,{onSamples:e=>{f&&!t.signal.aborted&&s?.sendAudio(f.push(e))}}),t.signal.aborted){l();return}f=new Qe(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)(V,{type:`button`,variant:`primary`,disabled:o||r||!t||y,onClick:()=>void v(!0),children:[y?(0,$.jsx)(b,{className:`size-4 animate-spin`}):(0,$.jsx)(x,{className:`size-4`}),n?a.test:a.testInput]}),(0,$.jsxs)(V,{type:`button`,variant:`secondary`,disabled:o||r||!n||y,onClick:()=>void v(!1),children:[(0,$.jsx)(C,{className:`size-4`}),e.tts.test.play]}),y?(0,$.jsxs)(V,{type:`button`,variant:`ghost`,onClick:()=>{_(),g(`idle`)},children:[(0,$.jsx)(lt,{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)(V,{type:`button`,variant:`secondary`,onClick:()=>{_(),i?.({input:h.current,output:!0}),g(`passed`)},children:a.heard}),(0,$.jsx)(V,{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 nn(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 rn(e){let t=(0,It.c)(117),{section:n,v:r,form:i,pending:a,apiKeyLabels:o,sttProviders:s,onChange:c}=e,u=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 x;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(x={revalidateOnFocus:!0},t[7]=x):x=t[7];let{data:S,error:C,isLoading:w}=B(b,Dt,x),T;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(T=N(`/api/voice/catalog`),t[8]=T):T=t[8];let{data:E}=B(T,ln),D=i.voice.realtime,O=i.stt.provider,k=D.tts,A=k?.provider??S?.tts?.provider,j=S?.tts?.model,M;t[9]!==j||t[10]!==A?(M=A&&j?[`realtime-voices`,A,j]:null,t[9]=j,t[10]=A,t[11]=M):M=t[11];let P;t[12]!==j||t[13]!==A?(P=()=>Ct(A,j,`realtime`),t[12]=j,t[13]=A,t[14]=P):P=t[14];let F;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(F={revalidateOnFocus:!1},t[15]=F):F=t[15];let{data:I}=B(M,P,F),L;t[16]===I?L=t[17]:(L=I===void 0?[]:I,t[16]=I,t[17]=L);let R=L,ee=R,z;t[18]===R?z=t[19]:(z=R.filter(cn),t[18]=R,t[19]=z);let H=z,te=typeof i.stt.providers?.alibaba?.apiKey==`string`?i.stt.providers.alibaba.apiKey:``,ne;t[20]!==te||t[21]!==s?(ne=!!te||s.some(sn),t[20]=te,t[21]=s,t[22]=ne):ne=t[22];let U=ne,W=D.defaultEngine===`omni`,K=W?D.omni?.voice??``:k?.voice??S?.tts?.voice??``,re;t[23]!==E?.models||t[24]!==W||t[25]!==H||t[26]!==D.omni?.model||t[27]!==D.omni?.provider||t[28]!==ee?(re=W?D.omni?.provider===`xopc-cloud`?E?.models.find(e=>e.id===D.omni?.model)?.voice.voices??[]:H.length?H:[`Cherry`,`Ethan`,`Serena`,`Chelsie`].map(on):ee,t[23]=E?.models,t[24]=W,t[25]=H,t[26]=D.omni?.model,t[27]=D.omni?.provider,t[28]=ee,t[29]=re):re=t[29];let J=re,Y=!!(S?.enabled&&S.stt),X=!!(S?.enabled&&S.tts),Z;t[30]!==i||t[31]!==c||t[32]!==D?(Z=e=>c({...i,voice:{...i.voice,realtime:{...D,...e}}}),t[30]=i,t[31]=c,t[32]=D,t[33]=Z):Z=t[33];let ie=Z,ae;t[34]!==i||t[35]!==c?(ae=e=>c(nn(i,e)),t[34]=i,t[35]=c,t[36]=ae):ae=t[36];let oe=ae,se;t[37]!==a||t[38]!==D.enabled||t[39]!==u.disabled||t[40]!==u.needsSetup||t[41]!==u.pending||t[42]!==u.unverified||t[43]!==u.verified||t[44]!==g||t[45]!==v.signature?(se=(e,t)=>D.enabled?a?u.pending:e?t&&v.signature===g?u.verified:u.unverified:u.needsSetup:u.disabled,t[37]=a,t[38]=D.enabled,t[39]=u.disabled,t[40]=u.needsSetup,t[41]=u.pending,t[42]=u.unverified,t[43]=u.verified,t[44]=g,t[45]=v.signature,t[46]=se):se=t[46];let ce=se,le;t[47]!==o||t[48]!==oe||t[49]!==p||t[50]!==C||t[51]!==i||t[52]!==te||t[53]!==U||t[54]!==c||t[55]!==a||t[56]!==O||t[57]!==D.defaultEngine||t[58]!==D.enabled||t[59]!==u.changeKey||t[60]!==u.configureConversation||t[61]!==u.customProvider||t[62]!==u.edgeHint||t[63]!==u.enable||t[64]!==u.finishSetup||t[65]!==u.hosted||t[66]!==u.hostedAccountHint||t[67]!==u.hostedHint||t[68]!==u.keyConfigured||t[69]!==u.keyHint||t[70]!==u.manageAccount||t[71]!==u.outputHint||t[72]!==u.ownKey||t[73]!==u.ownKeyHint||t[74]!==u.service||t[75]!==u.statusError||t[76]!==n||t[77]!==k||t[78]!==S?.tts||t[79]!==ie||t[80]!==r.experience||t[81]!==r.stt?(le=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":D.enabled,className:`size-4 accent-accent`,checked:D.enabled,onChange:e=>{e.target.checked?oe(O===`alibaba`?`alibaba`:`xopc-cloud`):ie({enabled:!1})}}),u.enable]})}),C?(0,$.jsx)(`p`,{role:`alert`,className:`text-xs text-red-600 dark:text-red-400`,children:u.statusError}):null,(0,$.jsxs)(`fieldset`,{className:`space-y-3`,children:[(0,$.jsx)(`legend`,{className:`text-sm font-medium text-fg`,children:u.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:O===e,onChange:()=>oe(e),className:`mt-1 accent-accent`}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`span`,{className:`block font-medium`,children:e===`xopc-cloud`?u.hosted:u.ownKey}),(0,$.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:e===`xopc-cloud`?u.hostedHint:u.ownKeyHint})]})]},e))})]}),O!==`alibaba`&&O!==`xopc-cloud`?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:u.customProvider.replace(`{provider}`,O)}):null,O===`alibaba`?(0,$.jsx)(`div`,{className:`space-y-2 text-xs`,children:U&&!p?(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-fg-muted`,children:u.keyConfigured}),(0,$.jsx)(V,{type:`button`,variant:`ghost`,onClick:()=>m(!0),children:u.changeKey})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`label`,{htmlFor:`realtime-api-key`,className:`font-medium text-fg`,children:r.stt.apiKey}),(0,$.jsx)(Ot,{kind:`stt`,providerId:`alibaba`,fieldId:`realtime-api-key`,value:te,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:u.keyHint})]})}):null,O===`xopc-cloud`?(0,$.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[u.hostedAccountHint,` `,(0,$.jsx)(l,{className:`text-accent hover:underline`,to:`/settings/capabilities/models`,children:u.manageAccount})]}):null,!k&&!a&&!S?.tts&&(O===`alibaba`||O===`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:u.finishSetup}),(0,$.jsx)(`p`,{className:`mt-1 text-fg-muted`,children:i.tts.provider===`edge`?u.edgeHint:u.outputHint}),(0,$.jsx)(V,{className:`mt-2`,type:`button`,variant:`secondary`,onClick:()=>oe(O),children:u.configureConversation})]}):null,(0,$.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[(0,$.jsx)(`span`,{children:r.experience.defaultMode}),(0,$.jsxs)(d,{value:D.defaultEngine,className:G,onChange:e=>ie({defaultEngine:e.target.value}),children:[(0,$.jsx)(f,{value:`agent`,children:r.experience.assistant}),(0,$.jsx)(f,{value:`omni`,children:r.experience.natural})]})]}),(0,$.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[D.defaultEngine===`agent`?r.experience.assistantHint:r.experience.naturalHint,` `,r.experience.nextCall]})]}):null,t[47]=o,t[48]=oe,t[49]=p,t[50]=C,t[51]=i,t[52]=te,t[53]=U,t[54]=c,t[55]=a,t[56]=O,t[57]=D.defaultEngine,t[58]=D.enabled,t[59]=u.changeKey,t[60]=u.configureConversation,t[61]=u.customProvider,t[62]=u.edgeHint,t[63]=u.enable,t[64]=u.finishSetup,t[65]=u.hosted,t[66]=u.hostedAccountHint,t[67]=u.hostedHint,t[68]=u.keyConfigured,t[69]=u.keyHint,t[70]=u.manageAccount,t[71]=u.outputHint,t[72]=u.ownKey,t[73]=u.ownKeyHint,t[74]=u.service,t[75]=u.statusError,t[76]=n,t[77]=k,t[78]=S?.tts,t[79]=ie,t[80]=r.experience,t[81]=r.stt,t[82]=le):le=t[82];let ue;t[83]!==K||t[84]!==W||t[85]!==A||t[86]!==D.bargeIn||t[87]!==D.omni||t[88]!==D.tts||t[89]!==u.bargeIn||t[90]!==u.defaultVoice||t[91]!==u.voice||t[92]!==n||t[93]!==k||t[94]!==S?.tts||t[95]!==ie||t[96]!==r.realtime||t[97]!==J?(ue=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:u.voice}),(0,$.jsxs)(d,{id:`realtime-voice`,className:`${G} w-full sm:w-56`,value:K,disabled:W?!D.omni:!k&&!S?.tts,onChange:e=>{if(W&&D.omni){ie({omni:{...D.omni,voice:e.target.value}});return}(A===`alibaba`||A===`xopc-cloud`)&&ie({tts:{...D.tts,provider:A,...e.target.value?{voice:e.target.value}:{}},...D.omni&&[`Cherry`,`Ethan`,`Serena`,`Chelsie`].includes(e.target.value)?{omni:{...D.omni,voice:e.target.value}}:{}})},children:[W?null:(0,$.jsx)(f,{value:``,children:u.defaultVoice}),K&&!J.some(e=>e.id===K)?(0,$.jsx)(f,{value:K,children:K}):null,J.map(an)]}),(()=>{let e=J.find(e=>e.id===K);return e&&`description`in e&&typeof e.description==`string`?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.description}):null})()]}),(0,$.jsxs)(`label`,{className:`flex items-center justify-between gap-4 text-sm text-fg`,children:[(0,$.jsxs)(`span`,{children:[u.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":D.bargeIn,checked:D.bargeIn,className:`size-4 accent-accent`,onChange:e=>ie({bargeIn:e.target.checked})})]})]}):null,t[83]=K,t[84]=W,t[85]=A,t[86]=D.bargeIn,t[87]=D.omni,t[88]=D.tts,t[89]=u.bargeIn,t[90]=u.defaultVoice,t[91]=u.voice,t[92]=n,t[93]=k,t[94]=S?.tts,t[95]=ie,t[96]=r.realtime,t[97]=J,t[98]=ue):ue=t[98];let de;t[99]!==Y||t[100]!==X||t[101]!==C||t[102]!==w||t[103]!==a||t[104]!==n||t[105]!==g||t[106]!==S||t[107]!==ce||t[108]!==r||t[109]!==v.input||t[110]!==v.output?(de=n===`diagnostics`?(0,$.jsxs)($.Fragment,{children:[w?(0,$.jsx)(q,{className:`h-16 w-full`}):(0,$.jsxs)(`div`,{className:`space-y-2 text-sm`,role:`status`,children:[(0,$.jsxs)(`p`,{children:[r.experience.dictationReady,` · `,ce(Y,v.input)]}),(0,$.jsxs)(`p`,{children:[r.experience.agentReady,` · `,ce(Y&&X,v.input&&v.output)]}),(0,$.jsxs)(`p`,{children:[r.experience.omniReady,` · `,ce(!!(S?.enabled&&S.omni),!1)]})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:r.experience.configurationOnly}),(0,$.jsx)(tn,{v:r,canListen:Y,canSpeak:X,disabled:a||w||!!C,onVerified:e=>y({signature:g,...e})},`${g}:${JSON.stringify(S)}`)]}):null,t[99]=Y,t[100]=X,t[101]=C,t[102]=w,t[103]=a,t[104]=n,t[105]=g,t[106]=S,t[107]=ce,t[108]=r,t[109]=v.input,t[110]=v.output,t[111]=de):de=t[111];let fe;return t[112]!==u.service||t[113]!==le||t[114]!==ue||t[115]!==de?(fe=(0,$.jsxs)(`section`,{className:`space-y-5 rounded-xl bg-surface-hover/20 p-4 sm:p-5`,"aria-label":u.service,children:[le,ue,de]}),t[112]=u.service,t[113]=le,t[114]=ue,t[115]=de,t[116]=fe):fe=t[116],fe}function an(e){return(0,$.jsxs)(f,{value:e.id,children:[e.name,`gender`in e&&e.gender?` · ${e.gender===`female`?`女声`:`男声`}`:``,`style`in e&&e.style?` · ${e.style}`:``]},e.id)}function on(e){return{id:e,name:e}}function sn(e){return e.id===`alibaba`&&e.configured}function cn(e){return[`Cherry`,`Ethan`,`Serena`,`Chelsie`].includes(e.id)}async function ln(e){return Je.parse((await k(e)).payload)}function un(e){let t=(0,It.c)(22),{value:n,onChange:r}=e,i=M(fn)===`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 u;t[7]===l?u=t[8]:(u=(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:l}),t[7]=l,t[8]=u);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)(d,{value:n.provider,onChange:e=>r({model:n.model,voice:n.voice,instructions:n.instructions,provider:e.target.value}),children:(0,$.jsxs)(f,{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)(d,{value:n.voice,onChange:e=>c({voice:e.target.value}),children:[`Cherry`,`Ethan`,`Serena`,`Chelsie`].map(dn)})]}),(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)(V,{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]!==u||t[19]!==m||t[20]!==h?(g=(0,$.jsxs)(`details`,{className:`space-y-3 rounded-xl bg-surface-hover/20 p-4`,children:[u,m,h]}),t[18]=u,t[19]=m,t[20]=h,t[21]=g):g=t[21],g}function dn(e){return(0,$.jsx)(f,{value:e,children:e},e)}function fn(e){return e.language}var pn=W;function mn(){return O(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,K,`dark:border-edge`)}function hn(){return O(G,W)}function gn(e){return!e||e<=0?``:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function _n(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 vn(e,t){switch(e){case`openai`:return t.stt.openai;case`alibaba`:return t.stt.alibaba;case`groq`:return`Groq`;default:return e}}function yn(e,t){switch(e){case`openai`:return t.tts.providerOpenai;case`alibaba`:return t.stt.alibaba;case`edge`:return t.tts.providerEdge;case`minimax`:return`MiniMax`;default:return e}}function bn(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 xn(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;default:return t.tts.providerHints.generic}}function Sn(e){return{maskedHelp:e.apiKeyMaskedHelp,copy:e.apiKeyCopy,copied:e.apiKeyCopied,show:e.apiKeyShow,hide:e.apiKeyHide,notInConfigFile:e.apiKeyNotInConfigFile,loadFailed:e.apiKeyRevealFailed}}function Cn(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 wn(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 Tn(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 En(){let e=M(e=>e.language),t=D(e).voiceSettings,[n,r]=(0,Q.useState)(`listening`),i=Xe(),a=rt(e=>e.captions),o=rt(e=>e.setCaptions),s=!!A(e=>e.conversationId);(0,Q.useEffect)(()=>{!i&&n===`diagnostics`&&r(`listening`)},[n,i]);let[c,l]=(0,Q.useReducer)(Tn,{form:null,baseline:null}),u=c.form,p=c.baseline,[m,h]=(0,Q.useState)(null),g=(0,Q.useRef)(!1),_=(0,Q.useRef)(u);_.current=u;let v=(0,Q.useRef)({parsed:null,models:void 0}),{data:y,error:b,isLoading:x,mutate:S}=U(s),{data:C,error:w,isLoading:T,mutate:E}=B(s?N(`/api/voice/models`):null,Tt,{revalidateOnFocus:!1}),{data:O,error:k,isLoading:j}=B(s?N(`/api/voice/providers`):null,xt,{revalidateOnFocus:!1}),{data:P,error:F,isLoading:I}=B(s?N(`/api/voice/stt-providers`):null,wt,{revalidateOnFocus:!1}),L=(0,Q.useMemo)(()=>O?.providers??[],[O]),R=(0,Q.useMemo)(()=>P?.providers??[],[P]),ee=(0,Q.useMemo)(()=>y?.payload?.config===void 0?null:Et(y.payload.config),[y]),z=(0,Q.useMemo)(()=>!u||!p?!1:JSON.stringify(u)!==JSON.stringify(p),[u,p]);s?ee!==null&&C!==void 0&&!g.current&&(v.current.parsed!==ee||v.current.models!==C)&&(v.current={parsed:ee,models:C},l({type:`sync`,value:ee}),h(C)):(v.current.parsed!==null||v.current.models!==void 0)&&(v.current={parsed:null,models:void 0},l({type:`reset`}),h(null),g.current=!1);let H=!!(s&&(ee===null||C===void 0||O===void 0||P===void 0)&&(x||T||j||I)),te=b instanceof Error?b.message:b?String(b):w instanceof Error?w.message:w?String(w):k instanceof Error?k.message:k?String(k):F instanceof Error?F.message:F?String(F):null,ne=(0,Q.useCallback)(e=>{g.current=!0,l({type:`update`,updater:t=>t?{...t,stt:{...t.stt,...e}}:null})},[]),W=(0,Q.useCallback)(e=>{g.current=!0,l({type:`update`,updater:t=>{if(!t)return null;let n=t.stt.fallback??{enabled:!1,order:[]};return{...t,stt:{...t.stt,fallback:{...n,...e}}}}})},[]),G=(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})},[]),K=(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]),re=(0,Q.useCallback)(e=>{g.current=!0,l({type:`update`,updater:t=>t?{...t,voice:{...t.voice,realtime:{...t.voice.realtime,...e}}}:null})},[]),q=(0,Q.useCallback)(e=>{g.current=!0,l({type:`update`,updater:t=>t?{...t,tts:{...t.tts,...e}}:null})},[]),J=vt({value:u,dirty:z,onSave:(0,Q.useCallback)(async e=>{try{await yt(e),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)}},[t.saveError])}),Y=(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(H)return(0,$.jsx)(gt,{rows:4});if(!u||m===null)return(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:te??t.loadError}),(0,$.jsx)(V,{type:`button`,variant:`secondary`,onClick:()=>{S(),E()},children:t.retry})]});let X=u.stt,Z=u.tts,ie=u.voice.input.refinement,ae=Sn(t);return(0,$.jsxs)(`div`,{className:`flex w-full flex-col gap-4`,onBlurCapture:J.onBlurCapture,children:[(0,$.jsx)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:(0,$.jsx)(_t,{status:J.status,error:J.error})}),J.error?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:J.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)(V,{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)(rn,{section:n,v:t,form:u,pending:z||J.status===`saving`||!!J.error,apiKeyLabels:ae,sttProviders:R,onChange:Y}):null,n===`listening`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Dn,{v:t,voice:u.voice,updateLanguageMode:K}),(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)(d,{className:hn(),value:String(u.voice.realtime.silenceDurationMs),onChange:e=>re({silenceDurationMs:Number(e.target.value)}),children:[(0,$.jsx)(f,{value:`800`,children:t.experience.fast}),(0,$.jsx)(f,{value:`1200`,children:t.experience.standard}),(0,$.jsx)(f,{value:`2000`,children:t.experience.relaxed}),[800,1200,2e3].includes(u.voice.realtime.silenceDurationMs)?null:(0,$.jsxs)(f,{value:String(u.voice.realtime.silenceDurationMs),children:[u.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)(d,{className:hn(),value:ie.mode,onChange:e=>G({mode:e.target.value}),children:[(0,$.jsx)(f,{value:`off`,children:t.stt.refinementOff}),(0,$.jsx)(f,{value:`punctuation`,children:t.stt.refinementPunctuation}),(0,$.jsx)(f,{value:`light`,children:t.stt.refinementLight}),ie.mode===`custom`?(0,$.jsx)(f,{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,` · `,Z.enabled?bn(Z.trigger,t):t.overview.off]}),(0,$.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:t.setup.readoutHint}),(0,$.jsx)(An,{v:t,apiKeyLabels:ae,tts:Z,models:m,ttsProviders:L,updateTts:q})]})]}):null,n===`devices`?(0,$.jsx)(en,{v:t}):null,n===`service`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)($t,{disabled:z||J.status===`saving`}),u.voice.realtime.enabled&&u.voice.realtime.omni?.provider===`alibaba`?(0,$.jsx)(un,{value:u.voice.realtime.omni,onChange:e=>re({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)(On,{v:t,apiKeyLabels:ae,stt:X,models:m,sttProviders:R,updateStt:ne,updateSttFallback:W}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.notes.envVars})]})]}):null]})}function Dn(e){let t=(0,It.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=hn(),t[7]=l):l=t[7];let u;t[8]===i?u=t[9]:(u=e=>i(e.target.value),t[8]=i,t[9]=u);let p;t[10]===n.language.auto?p=t[11]:(p=(0,$.jsx)(f,{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)(f,{value:`manual`,children:n.language.manual}),t[12]=n.language.manual,t[13]=m);let h;t[14]!==u||t[15]!==p||t[16]!==m||t[17]!==r.languageMode?(h=(0,$.jsxs)(d,{className:l,value:r.languageMode,onChange:u,children:[p,m]}),t[14]=u,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 On(e){let t=(0,It.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 u=l,p,m,h,g;if(t[2]!==a||t[3]!==u||t[4]!==i.provider||t[5]!==i.providers){p=u.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??[],g=p?.fields.find(kn),t[2]=a,t[3]=u,t[4]=i.provider,t[5]=i.providers,t[6]=p,t[7]=m,t[8]=h,t[9]=g}else p=t[6],m=t[7],h=t[8],g=t[9];let _=g,v=typeof h.model==`string`?h.model:void 0,y=v??(typeof _?.defaultValue==`string`?_.defaultValue:m[0]?.id),b;t[13]!==i.provider||t[14]!==i.providers||t[15]!==s?(b=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]=b):b=t[16];let S=b,C,w;t[17]!==v||t[18]!==y||t[19]!==_||t[20]!==S?(C=()=>{_&&y&&v!==y&&S({model:y})},w=[v,y,_,S],t[17]=v,t[18]=y,t[19]=_,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)(x,{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 k;t[28]!==E||t[29]!==D?(k=(0,$.jsxs)(`div`,{className:`mb-4`,children:[E,D]}),t[28]=E,t[29]=D,t[30]=k):k=t[30];let A;t[31]===s?A=t[32]:(A=e=>s({enabled:e}),t[31]=s,t[32]=A);let j;t[33]!==i.enabled||t[34]!==A||t[35]!==n.stt.enable||t[36]!==n.stt.enableDesc?(j=(0,$.jsx)(Mn,{checked:i.enabled,title:n.stt.enable,description:n.stt.enableDesc,onChange:A}),t[33]=i.enabled,t[34]=A,t[35]=n.stt.enable,t[36]=n.stt.enableDesc,t[37]=j):j=t[37];let M;t[38]!==p?.fields||t[39]!==r||t[40]!==y||t[41]!==m||t[42]!==u||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?(M=i.enabled?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{className:O(`flex flex-col gap-1.5`,pn),children:[(0,$.jsx)(Fn,{children:n.stt.provider}),(0,$.jsx)(d,{className:hn(),value:i.provider,onChange:e=>s({provider:e.target.value}),children:u.map(e=>(0,$.jsxs)(f,{value:e.id,children:[vn(e.id,n),e.configured?``:` *`]},e.id))})]}),(0,$.jsx)(jn,{kind:`stt`,providerId:i.provider,fields:p?.fields??[],providerSlice:h,models:m,currentModel:y,apiKeyLabels:r,onPatch:S})]}),(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]=y,t[41]=m,t[42]=u,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]=M):M=t[51];let N;t[52]!==j||t[53]!==M?(N=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[j,M]}),t[52]=j,t[53]=M,t[54]=N):N=t[54];let P;return t[55]!==N||t[56]!==k?(P=(0,$.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 px-4 py-5 sm:px-5`,children:[k,N]}),t[55]=N,t[56]=k,t[57]=P):P=t[57],P}function kn(e){return e.key===`model`}function An({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`}),u=(0,Q.useRef)(null),p=(0,Q.useRef)(null),m=(0,Q.useRef)(null),h=(0,Q.useCallback)(()=>{m.current?.abort(),m.current=null,u.current?.pause(),u.current=null,p.current&&=(URL.revokeObjectURL(p.current),null)},[]),g=(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]),_=g.find(e=>e.id===n.provider),v=n.providers?.[n.provider]??{},y=r?.tts?.[n.provider]?.length?r.tts[n.provider]:_?.models??[],x=_?.fields.find(e=>e.key===`model`),S=_?.fields.find(e=>e.key===`voice`),w=typeof v.model==`string`?v.model:void 0,T=w??(typeof x?.defaultValue==`string`?x.defaultValue:y[0]?.id),E=y.find(e=>e.id===T),D=r?.ttsVoices?.[n.provider]?.length?r.ttsVoices[n.provider]:_?.voices??[],{data:k=[]}=B(T?`voice:tts:${n.provider}:${T}`:null,()=>Ct(n.provider,T??``),{revalidateOnFocus:!1}),A=k.length>0?k:D,j=typeof v.voice==`string`?v.voice:void 0,M=j??A.find(e=>e.id===E?.tts?.defaultVoice)?.id??(typeof S?.defaultValue==`string`?S.defaultValue:A[0]?.id),N=(_?.fields??[]).filter(e=>(e.key!==`speed`||E?.tts?.speed!==!1)&&(e.key!==`instructions`||E?.tts?.instructions!==!1)),P=!!_?.diagnostics.requiresApiKey,F=!!_?.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&&T&&w!==T&&(e.model=T),S&&M&&j!==M&&(e.voice=M),Object.keys(e).length>0&&I(e)},[w,j,T,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 bt({text:t,provider:n.provider,providerConfig:v,...T?{model:T}:{},...M?{voice:M}:{}},r.signal);if(r.signal.aborted)return;let a=_n(i.audio,i.mimeType);p.current=a;let o=new Audio(a);u.current=o;let s=[i.provider,i.format,i.latencyMs===void 0?void 0:`${i.latencyMs}ms`,gn(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)})}},[T,M,v,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)(Ue,{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)(Mn,{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:O(`flex flex-col gap-1.5`,pn),children:[(0,$.jsx)(Fn,{children:e.tts.trigger}),(0,$.jsxs)(d,{className:hn(),value:n.trigger,onChange:e=>a({trigger:e.target.value}),children:[(0,$.jsx)(f,{value:`off`,children:e.tts.triggerOff}),(0,$.jsx)(f,{value:`inbound`,children:e.tts.triggerInbound}),(0,$.jsx)(f,{value:`tagged`,children:e.tts.triggerTagged}),(0,$.jsx)(f,{value:`always`,children:e.tts.triggerAlways})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.triggerHelp})]}),(0,$.jsxs)(`div`,{className:O(`flex flex-col gap-1.5`,pn),children:[(0,$.jsx)(Fn,{children:e.tts.provider}),(0,$.jsx)(d,{className:hn(),value:n.provider,onChange:e=>L(e.target.value),children:g.map(t=>(0,$.jsx)(f,{value:t.id,children:yn(t.id,e)},t.id))}),(0,$.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[_?.configured?e.tts.configured:_?.diagnostics.requiresApiKey?`${e.tts.needsKey} · ${_.diagnostics.envKeys?.join(`, `)??e.stt.apiKey}`:e.tts.noKeyNeeded,` · `,_?.description??xn(n.provider,e)]})]})]}),(0,$.jsxs)(`details`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,open:!F,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)(jn,{kind:`tts`,providerId:n.provider,fields:N,providerSlice:v,models:y,voices:A,currentModel:T,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)(V,{type:`button`,variant:`primary`,onClick:()=>void R(),disabled:c.status===`loading`,className:`h-9`,children:[c.status===`loading`?(0,$.jsx)(b,{className:`size-4 animate-spin`}):(0,$.jsx)(C,{className:`size-4`}),c.status===`loading`?e.tts.test.generating:e.tts.test.play]}),(0,$.jsxs)(V,{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)(lt,{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:O(mn(),`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 jn({kind:e,providerId:t,fields:n,providerSlice:r,models:i,voices:a=[],currentModel:o,currentVoice:s,apiKeyLabels:c,onPatch:l,resetVoiceOnModelChange:u=!1}){return n.map(n=>n.key===`apiKey`?(0,$.jsxs)(`div`,{className:O(`flex flex-col gap-1.5`,pn),children:[(0,$.jsx)(Fn,{children:n.label}),(0,$.jsx)(Ot,{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:O(`flex flex-col gap-1.5`,pn),children:[(0,$.jsx)(Fn,{children:n.label}),(0,$.jsx)(d,{className:hn(),value:o??``,onChange:e=>l({model:e.target.value,...u?{voice:void 0}:{}}),children:i.map(e=>(0,$.jsx)(f,{value:e.id,children:e.name},e.id))})]},n.key):n.key===`voice`&&a.length>0?(0,$.jsxs)(`div`,{className:O(`flex flex-col gap-1.5`,pn),children:[(0,$.jsx)(Fn,{children:n.label}),(0,$.jsxs)(d,{className:hn(),value:s??``,onChange:e=>l({voice:e.target.value}),children:[s&&!a.some(e=>e.id===s)?(0,$.jsxs)(f,{value:s,children:[s,` · unavailable`]}):null,a.map(e=>(0,$.jsxs)(f,{value:e.id,children:[e.name,e.gender?` · ${e.gender===`female`?`女声`:`男声`}`:``,e.style?` · ${e.style}`:``]},e.id))]}),a.find(e=>e.id===s)?.description?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:a.find(e=>e.id===s)?.description}):null]},n.key):(0,$.jsx)(Nn,{field:n,value:Cn(r,n),onChange:e=>l({[n.key]:e}),className:n.type===`textarea`?`sm:col-span-2`:pn},n.key))}function Mn(e){let t=(0,It.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=O(`group flex w-full items-center justify-between gap-4 rounded-lg bg-surface-base/55 px-3 py-3 text-left transition-colors`,K,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=O(`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=O(`size-5 rounded-full bg-white shadow-surface transition-transform`,m),t[14]=m,t[15]=h);let g;t[16]===h?g=t[17]:(g=(0,$.jsx)(`span`,{className:h}),t[16]=h,t[17]=g);let _;t[18]!==g||t[19]!==p?(_=(0,$.jsx)(`span`,{className:p,"aria-hidden":!0,children:g}),t[18]=g,t[19]=p,t[20]=_):_=t[20];let v;return t[21]!==n||t[22]!==o||t[23]!==_||t[24]!==c||t[25]!==d?(v=(0,$.jsxs)(`button`,{type:`button`,role:`switch`,"aria-checked":n,onClick:o,className:c,children:[d,_]}),t[21]=n,t[22]=o,t[23]=_,t[24]=c,t[25]=d,t[26]=v):v=t[26],v}function Nn(e){let t=(0,It.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=O(`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(wn(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=O(`flex flex-col gap-1.5`,a),t[19]=a,t[20]=l);let u;t[21]===n.label?u=t[22]:(u=(0,$.jsx)(Fn,{children:n.label}),t[21]=n.label,t[22]=u);let f;t[23]!==a||t[24]!==n||t[25]!==c||t[26]!==o||t[27]!==i?(f=n.type===`select`?(0,$.jsx)(d,{id:o,className:hn(),value:c,required:n.required,onChange:e=>i(wn(n,e.target.value)),children:(n.options??[]).map(Pn)}):n.type===`textarea`?(0,$.jsx)(`textarea`,{id:o,className:O(mn(),`min-h-24 resize-y`),value:c,required:n.required,placeholder:n.placeholder,onChange:e=>i(wn(n,e.target.value))}):n.type===`password`?(0,$.jsx)(v,{id:o,className:a,value:c,onChange:e=>i(wn(n,e)),placeholder:n.placeholder,labels:Ne}):(0,$.jsx)(`input`,{id:o,className:mn(),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(wn(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]!==u||t[33]!==f||t[34]!==p?(m=(0,$.jsxs)(`div`,{className:l,children:[u,f,p]}),t[31]=l,t[32]=u,t[33]=f,t[34]=p,t[35]=m):m=t[35],m}function Pn(e){return(0,$.jsx)(f,{value:e.id,children:e.name},e.id)}function Fn(e){let t=(0,It.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 In(e){return e.some(e=>e.disabled?!1:e.type===`searxng`?e.url.trim().length>0:e.apiKey.trim().length>0)}function Ln(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 Rn(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 k(N(`/api/config`),{method:`PATCH`,body:JSON.stringify({tools:{web:{region:t,search:n,blocklist:{enabled:e.blocklistEnabled,domains:e.blocklistDomains}}}})}),ne()}async function zn(e){let t=await k(N(`/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 Bn(e){let t=(0,It.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 Vn(){return O(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,K,`dark:border-edge`)}function Hn(){return O(G,W)}var Un=[`brave`,`tavily`,`bing`,`searxng`];function Wn(){return{type:`brave`,apiKey:``,url:``,disabled:!1}}var Gn=ie();function Kn(){let e=D(M(e=>e.language)),t=e.webSearchSettings,n=e.logs,r=!!A(e=>e.conversationId),[i,a]=(0,Q.useReducer)(Gn,{form:null,baseline:null}),o=i.form,s=i.baseline,c=(0,Q.useRef)(!1),l=(0,Q.useRef)(o);l.current=o;let u=(0,Q.useRef)(null),{data:p,error:m,isLoading:h,mutate:_}=U(r);Z({enabled:r,parsed:(0,Q.useMemo)(()=>p?.payload?.config===void 0?null:Ln(p.payload.config),[p]),dirty:c.current,trackedParsedRef:u,dispatch:a,onResetDirty:()=>{c.current=!1}});let v=!!(r&&h&&p===void 0&&!m),y=m instanceof Error?m.message:m?String(m):null,b=(0,Q.useMemo)(()=>!o||!s?!1:JSON.stringify(o)!==JSON.stringify(s),[o,s]),x=(0,Q.useCallback)(e=>{c.current=!0,a({type:`patch`,patch:e})},[]),S=vt({value:o,dirty:b,onSave:(0,Q.useCallback)(async e=>{try{await Rn(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(v)return(0,$.jsx)(gt,{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:y??t.loadError}),(0,$.jsx)(V,{type:`button`,variant:`secondary`,onClick:()=>void _(),children:n.refresh})]});let C=In(o.providers);return(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,onBlurCapture:S.onBlurCapture,children:[S.error?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:S.error}):null,(0,$.jsxs)(ht,{children:[(0,$.jsx)(mt,{icon:Te,title:t.sectionSearch,subtitle:t.sectionSearchHint,trailing:(0,$.jsx)(_t,{status:S.status,error:S.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)(g,{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:O(`rounded-full px-2 py-0.5 text-[11px] font-medium`,C?`bg-surface-panel text-fg-muted`:`bg-accent-soft text-accent`),children:C?t.cloudOverridden:t.cloudAutomatic})]}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-subtle`,children:C?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)(qn,{row:n,providerIndex:r,labels:t,secretLabels:he(e.providersSettings),onChange:e=>{let t=[...o.providers];t[r]=e,x({providers:t})},onRemove:()=>{x({providers:o.providers.filter((e,t)=>t!==r)})}},`${n.type}:${n.url}:${n.apiKey}:${n.disabled}`)),(0,$.jsxs)(V,{type:`button`,variant:`secondary`,className:`w-fit gap-1.5 text-sm`,onClick:()=>x({providers:[...o.providers,Wn()]}),children:[(0,$.jsx)(w,{className:`size-4`}),t.addProvider]})]})]}),(0,$.jsxs)(ht,{children:[(0,$.jsx)(mt,{icon:at,title:t.sectionPreferences}),(0,$.jsxs)(`div`,{className:`grid max-w-2xl gap-4 sm:grid-cols-2`,children:[(0,$.jsx)(Bn,{label:t.regionLabel,description:t.regionDesc,children:(0,$.jsxs)(d,{className:Hn(),value:o.regionMode,onChange:e=>x({regionMode:e.target.value}),children:[(0,$.jsx)(f,{value:`auto`,children:t.regionAuto}),(0,$.jsx)(f,{value:`cn`,children:t.regionCn}),(0,$.jsx)(f,{value:`global`,children:t.regionGlobal})]})}),(0,$.jsx)(Bn,{label:t.maxResultsLabel,description:t.maxResultsDesc,children:(0,$.jsx)(`input`,{type:`number`,min:1,max:50,className:Vn(),value:o.maxResults,onChange:e=>x({maxResults:Math.max(1,Math.min(50,Number(e.target.value)||5))})})})]})]}),(0,$.jsx)(kt,{children:(0,$.jsxs)(ht,{children:[(0,$.jsx)(mt,{icon:ye,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=>x({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)(Bn,{label:t.blocklistDomains,description:t.blocklistDomainsDesc,children:(0,$.jsx)(`textarea`,{className:O(Vn(),`min-h-[6rem] font-mono text-xs`),value:o.blocklistDomains.join(`
8
- `),placeholder:t.blocklistDomainsPlaceholder,onChange:e=>{x({blocklistDomains:e.target.value.split(/\r?\n/).flatMap(e=>{let t=e.trim().toLowerCase();return t?[t]:[]})})}})}):null]})]})})]})}function qn(e){let t=(0,It.c)(54),{row:n,providerIndex:r,labels:i,secretLabels:a,onChange:o,onRemove:s}=e,c;t[0]===r?c=t[1]:(c=()=>zn(r).then(Jn),t[0]=r,t[1]=c);let l=c,u;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=O(Hn(),`min-w-[8rem]`),t[2]=u):u=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=Un.map(e=>(0,$.jsx)(f,{value:e,children:i.providerTypes[e]},e)),t[6]=i.providerTypes,t[7]=h);let g;t[8]!==n.type||t[9]!==m||t[10]!==h?(g=(0,$.jsx)(d,{className:u,value:p,onChange:m,children:h}),t[8]=n.type,t[9]=m,t[10]=h,t[11]=g):g=t[11];let _;t[12]!==o||t[13]!==n?(_=e=>o({...n,disabled:e.target.checked}),t[12]=o,t[13]=n,t[14]=_):_=t[14];let y;t[15]!==n.disabled||t[16]!==_?(y=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:n.disabled,onChange:_}),t[15]=n.disabled,t[16]=_,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)(Ve,{className:`size-4`}),t[21]=x):x=t[21];let S;t[22]===s?S=t[23]:(S=(0,$.jsx)(V,{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]!==g?(w=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[g,C]}),t[27]=C,t[28]=g,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)(Bn,{label:i.urlLabel,description:i.urlDesc,children:(0,$.jsx)(`input`,{type:`url`,className:Vn(),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)(v,{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 k;t[46]!==i.apiKeyDesc||t[47]!==i.apiKeyLabel||t[48]!==D?(k=(0,$.jsx)(Bn,{label:i.apiKeyLabel,description:i.apiKeyDesc,children:D}),t[46]=i.apiKeyDesc,t[47]=i.apiKeyLabel,t[48]=D,t[49]=k):k=t[49];let A;return t[50]!==w||t[51]!==T||t[52]!==k?(A=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl bg-surface-panel/60 p-4`,children:[w,T,k]}),t[50]=w,t[51]=T,t[52]=k,t[53]=A):A=t[53],A}function Jn(e){return e.apiKey??null}function Yn(e){let t=(0,It.c)(185),{model:n,isNew:r,providerId:i,onSave:a,onClose:o,m:s}=e,c=M(Zn)===`zh`,l;t[0]===n?l=t[1]:(l=()=>n?{...n}:ve(``),t[0]=n,t[1]=l);let[u,p]=(0,Q.useState)(l),[m,h]=(0,Q.useState)(Xn),g;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(g=(e,t)=>{p(n=>({...n,[e]:t})),h(t=>{let n=new Map(t);return n.delete(e),n})},t[2]=g):g=t[2];let _=g,v;t[3]!==u.computerUse||t[4]!==u.contextWindow||t[5]!==u.id||t[6]!==u.input||t[7]!==u.maxTokens||t[8]!==s.modelIdRequired||t[9]!==s.mustBePositive||t[10]!==c?(v=()=>{let e=new Map;return(u.id||``).trim()||e.set(`id`,s.modelIdRequired),u.contextWindow!==void 0&&u.contextWindow<=0&&e.set(`contextWindow`,s.mustBePositive),u.maxTokens!==void 0&&u.maxTokens<=0&&e.set(`maxTokens`,s.mustBePositive),u.computerUse&&!u.input?.includes(`image`)&&e.set(`computerUse`,c?`电脑控制模型必须支持图片输入`:`Computer Use requires image input`),h(e),e.size===0},t[3]=u.computerUse,t[4]=u.contextWindow,t[5]=u.id,t[6]=u.input,t[7]=u.maxTokens,t[8]=s.modelIdRequired,t[9]=s.mustBePositive,t[10]=c,t[11]=v):v=t[11];let y=v,b;t[12]!==u||t[13]!==o||t[14]!==a||t[15]!==y?(b=()=>{if(!y())return;let e=(u.id||``).trim();a({...u,id:e,name:u.name?.trim()||e,reasoning:u.reasoning||!1,input:u.input||[`text`],contextWindow:u.contextWindow??128e3,maxTokens:u.maxTokens??16384,cost:{input:u.cost?.input??0,output:u.cost?.output??0,cacheRead:u.cost?.cacheRead??0,cacheWrite:u.cost?.cacheWrite??0}}),o()},t[12]=u,t[13]=o,t[14]=a,t[15]=y,t[16]=b):b=t[16];let x=b,S=u,C;t[17]===S?C=t[18]:(C=st(S),t[17]=S,t[18]=C);let w=C,T=r?s.addModelTitle:s.editModelTitle,D;t[19]===T?D=t[20]:(D=(0,$.jsx)(ee,{className:`text-base font-semibold text-fg`,children:T}),t[19]=T,t[20]=D);let k;t[21]!==s.modelProviderLabel||t[22]!==i?(k=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]=k):k=t[23];let A;t[24]!==D||t[25]!==k?(A=(0,$.jsxs)(`div`,{children:[D,k]}),t[24]=D,t[25]=k,t[26]=A):A=t[26];let j;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(j=O(te,`p-1.5 hover:bg-surface-base`),t[27]=j):j=t[27];let N;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,$.jsx)(E,{className:`size-4`}),t[28]=N):N=t[28];let P;t[29]===s.close?P=t[30]:(P=(0,$.jsx)(I,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:j,"aria-label":s.close,children:N})}),t[29]=s.close,t[30]=P);let F;t[31]!==A||t[32]!==P?(F=(0,$.jsxs)(`div`,{className:`mb-3 flex shrink-0 items-start justify-between gap-2`,children:[A,P]}),t[31]=A,t[32]=P,t[33]=F):F=t[33];let L;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,$.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`}),t[34]=L):L=t[34];let R;t[35]===s.modelId?R=t[36]:(R=(0,$.jsxs)(`label`,{className:`mb-1 block text-xs font-medium text-fg`,children:[s.modelId,L]}),t[35]=s.modelId,t[36]=R);let z;t[37]===m?z=t[38]:(z=O(ut(),m.has(`id`)&&`border-red-500`),t[37]=m,t[38]=z);let B=u.id||``,H;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(H=e=>_(`id`,e.target.value),t[39]=H):H=t[39];let ne=!r,U;t[40]!==z||t[41]!==B||t[42]!==ne?(U=(0,$.jsx)(`input`,{className:z,value:B,onChange:H,placeholder:`e.g. llama3.1:8b`,disabled:ne}),t[40]=z,t[41]=B,t[42]=ne,t[43]=U):U=t[43];let W;t[44]===m?W=t[45]:(W=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]=W);let G;t[46]!==R||t[47]!==U||t[48]!==W?(G=(0,$.jsxs)(`div`,{children:[R,U,W]}),t[46]=R,t[47]=U,t[48]=W,t[49]=G):G=t[49];let K;t[50]===s.displayName?K=t[51]:(K=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.displayName}),t[50]=s.displayName,t[51]=K);let re;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(re=ut(),t[52]=re):re=t[52];let q=u.name||``,J;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(J=e=>_(`name`,e.target.value),t[53]=J):J=t[53];let Y;t[54]===q?Y=t[55]:(Y=(0,$.jsx)(`input`,{className:re,value:q,onChange:J}),t[54]=q,t[55]=Y);let X;t[56]!==K||t[57]!==Y?(X=(0,$.jsxs)(`div`,{children:[K,Y]}),t[56]=K,t[57]=Y,t[58]=X):X=t[58];let Z;t[59]===s.inputTypes?Z=t[60]:(Z=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.inputTypes}),t[59]=s.inputTypes,t[60]=Z);let ie;t[61]===Symbol.for(`react.memo_cache_sentinel`)?(ie=Pe(),t[61]=ie):ie=t[61];let ae;t[62]===Symbol.for(`react.memo_cache_sentinel`)?(ae=e=>_(`input`,ze(e.target.value)),t[62]=ae):ae=t[62];let oe;t[63]===s?oe=t[64]:(oe=it.map(e=>(0,$.jsx)(f,{value:e.value,children:s[e.labelKey]},e.value)),t[63]=s,t[64]=oe);let se;t[65]!==w||t[66]!==oe?(se=(0,$.jsx)(d,{className:ie,value:w,onChange:ae,children:oe}),t[65]=w,t[66]=oe,t[67]=se):se=t[67];let ce;t[68]!==Z||t[69]!==se?(ce=(0,$.jsxs)(`div`,{children:[Z,se]}),t[68]=Z,t[69]=se,t[70]=ce):ce=t[70];let le=u.reasoning||!1,ue;t[71]===Symbol.for(`react.memo_cache_sentinel`)?(ue=e=>_(`reasoning`,e.target.checked),t[71]=ue):ue=t[71];let de;t[72]===le?de=t[73]:(de=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:le,onChange:ue}),t[72]=le,t[73]=de);let fe;t[74]!==s.reasoning||t[75]!==de?(fe=(0,$.jsxs)(`label`,{className:`mt-6 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[de,s.reasoning]}),t[74]=s.reasoning,t[75]=de,t[76]=fe):fe=t[76];let pe;t[77]!==ce||t[78]!==fe?(pe=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[ce,fe]}),t[77]=ce,t[78]=fe,t[79]=pe):pe=t[79];let me;t[80]===s.contextWindow?me=t[81]:(me=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.contextWindow}),t[80]=s.contextWindow,t[81]=me);let he;t[82]===m?he=t[83]:(he=O(ut(),m.has(`contextWindow`)&&`border-red-500`),t[82]=m,t[83]=he);let ge=u.contextWindow??128e3,_e;t[84]===Symbol.for(`react.memo_cache_sentinel`)?(_e=e=>_(`contextWindow`,parseInt(e.target.value,10)||0),t[84]=_e):_e=t[84];let ye;t[85]!==he||t[86]!==ge?(ye=(0,$.jsx)(`input`,{type:`number`,min:1,className:he,value:ge,onChange:_e}),t[85]=he,t[86]=ge,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]!==me||t[91]!==ye||t[92]!==be?(xe=(0,$.jsxs)(`div`,{children:[me,ye,be]}),t[90]=me,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=O(ut(),m.has(`maxTokens`)&&`border-red-500`),t[96]=m,t[97]=Ce);let we=u.maxTokens??16384,Te;t[98]===Symbol.for(`react.memo_cache_sentinel`)?(Te=e=>_(`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 De;t[102]===m?De=t[103]:(De=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]=De);let Oe;t[104]!==Se||t[105]!==Ee||t[106]!==De?(Oe=(0,$.jsxs)(`div`,{children:[Se,Ee,De]}),t[104]=Se,t[105]=Ee,t[106]=De,t[107]=Oe):Oe=t[107];let ke;t[108]!==xe||t[109]!==Oe?(ke=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[xe,Oe]}),t[108]=xe,t[109]=Oe,t[110]=ke):ke=t[110];let Ae;t[111]===s.costSection?Ae=t[112]:(Ae=(0,$.jsx)(`p`,{className:`mb-2 text-xs font-semibold text-fg`,children:s.costSection}),t[111]=s.costSection,t[112]=Ae);let je;t[113]===s.costInput?je=t[114]:(je=(0,$.jsx)(`label`,{className:`mb-1 block text-xs text-fg-muted`,children:s.costInput}),t[113]=s.costInput,t[114]=je);let Me;t[115]===Symbol.for(`react.memo_cache_sentinel`)?(Me=ut(),t[115]=Me):Me=t[115];let Ne=u.cost?.input??0,Fe;t[116]===u.cost?Fe=t[117]:(Fe=e=>_(`cost`,{...u.cost,input:parseFloat(e.target.value)||0,output:u.cost?.output??0,cacheRead:u.cost?.cacheRead??0,cacheWrite:u.cost?.cacheWrite??0}),t[116]=u.cost,t[117]=Fe);let Ie;t[118]!==Ne||t[119]!==Fe?(Ie=(0,$.jsx)(`input`,{type:`number`,step:`any`,min:0,className:Me,value:Ne,onChange:Fe}),t[118]=Ne,t[119]=Fe,t[120]=Ie):Ie=t[120];let Le;t[121]!==je||t[122]!==Ie?(Le=(0,$.jsxs)(`div`,{children:[je,Ie]}),t[121]=je,t[122]=Ie,t[123]=Le):Le=t[123];let Re;t[124]===s.costOutput?Re=t[125]:(Re=(0,$.jsx)(`label`,{className:`mb-1 block text-xs text-fg-muted`,children:s.costOutput}),t[124]=s.costOutput,t[125]=Re);let Be;t[126]===Symbol.for(`react.memo_cache_sentinel`)?(Be=ut(),t[126]=Be):Be=t[126];let Ve=u.cost?.output??0,He;t[127]===u.cost?He=t[128]:(He=e=>_(`cost`,{...u.cost,input:u.cost?.input??0,output:parseFloat(e.target.value)||0,cacheRead:u.cost?.cacheRead??0,cacheWrite:u.cost?.cacheWrite??0}),t[127]=u.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]!==Re||t[133]!==Ue?(We=(0,$.jsxs)(`div`,{children:[Re,Ue]}),t[132]=Re,t[133]=Ue,t[134]=We):We=t[134];let Ge;t[135]!==Le||t[136]!==We?(Ge=(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[Le,We]}),t[135]=Le,t[136]=We,t[137]=Ge):Ge=t[137];let Ke;t[138]!==Ae||t[139]!==Ge?(Ke=(0,$.jsxs)(`div`,{className:`border-t border-edge-subtle pt-2 dark:border-edge`,children:[Ae,Ge]}),t[138]=Ae,t[139]=Ge,t[140]=Ke):Ke=t[140];let qe;t[141]!==G||t[142]!==X||t[143]!==pe||t[144]!==ke||t[145]!==Ke?(qe=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[G,X,pe,ke,Ke]}),t[141]=G,t[142]=X,t[143]=pe,t[144]=ke,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=u.computerUse?.profile??``,Qe;t[149]===Symbol.for(`react.memo_cache_sentinel`)?(Qe=e=>_(`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)(f,{value:``,children:$e}),t[150]=$e,t[151]=et);let tt,nt,rt;t[152]===Symbol.for(`react.memo_cache_sentinel`)?(tt=(0,$.jsx)(f,{value:`gui-plus-2026-02-26`,children:`GUI-Plus (2026-02-26)`}),nt=(0,$.jsx)(f,{value:`structured-tools-v1`,children:`structured-tools-v1`}),rt=(0,$.jsx)(f,{value:`openai-responses-computer-v1`,children:`OpenAI Responses Computer`}),t[152]=tt,t[153]=nt,t[154]=rt):(tt=t[152],nt=t[153],rt=t[154]);let at;t[155]!==Xe||t[156]!==Ze||t[157]!==et?(at=(0,$.jsxs)(d,{"aria-label":Xe,value:Ze,onChange:Qe,children:[et,tt,nt,rt]}),t[155]=Xe,t[156]=Ze,t[157]=et,t[158]=at):at=t[158];let ot=c?`协议必须与模型 API 匹配。声明协议不代表模型已通过效果验证。`:`The protocol must match the model API. Declaring a protocol does not certify model quality.`,ct;t[159]===ot?ct=t[160]:(ct=(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:ot}),t[159]=ot,t[160]=ct);let lt;t[161]===m?lt=t[162]:(lt=m.has(`computerUse`)&&(0,$.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:m.get(`computerUse`)}),t[161]=m,t[162]=lt);let dt;t[163]!==at||t[164]!==ct||t[165]!==lt?(dt=(0,$.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[at,ct,lt]}),t[163]=at,t[164]=ct,t[165]=lt,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)(I,{asChild:!0,children:(0,$.jsx)(V,{type:`button`,variant:`secondary`,children:s.cancel})}),t[173]=s.cancel,t[174]=mt);let ht=r?s.addModelConfirm:s.saveModelConfirm,gt;t[175]!==x||t[176]!==ht?(gt=(0,$.jsx)(V,{type:`button`,variant:`primary`,className:`hover:bg-accent/90`,onClick:x,children:ht}),t[175]=x,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]!==F||t[182]!==pt||t[183]!==_t?(vt=(0,$.jsxs)($.Fragment,{children:[F,pt,_t]}),t[181]=F,t[182]=pt,t[183]=_t,t[184]=vt):vt=t[184],vt}function Xn(){return new Map}function Zn(e){return e.language}function Qn(e){let t=(0,It.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)(P,{className:O(`xopc-dialog-overlay fixed inset-0 bg-scrim`,Y)}),t[0]=l):l=t[0];let u;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(u=O(`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`,J,`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)(Yn,{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)(L,{children:[l,(0,$.jsx)(R,{className:u,onOpenAutoFocus:$n,children:d})]}),t[10]=d,t[11]=f);let p;return t[12]!==r||t[13]!==n||t[14]!==f?(p=(0,$.jsx)(z,{open:n,onOpenChange:r,children:f}),t[12]=r,t[13]=n,t[14]=f,t[15]=p):p=t[15],p}function $n(e){return e.preventDefault()}function er(e){let t=(0,It.c)(14),{providerId:n,inputId:r,value:i,onChange:a,labels:o}=e,s;t[0]===n?s=t[1]:(s=()=>Ee(n).then(tr),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)(v,{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 tr(e){return e.apiKey??null}function nr(e){let t=(0,It.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)(P,{className:O(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,Y)}),t[0]=f):f=t[0];let p;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(p=O(`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`,J),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)(L,{children:[f,(0,$.jsx)(R,{className:p,children:a?(0,$.jsx)(ir,{providerId:i,customConfig:s,labels:l,language:u,onClose:()=>r(!1),onSaved:d}):(0,$.jsx)(rr,{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)(z,{open:n,onOpenChange:r,children:m}),t[12]=r,t[13]=n,t[14]=m,t[15]=h):h=t[15],h}function rr({providerId:e,builtinRows:t,allModels:n,labels:r,language:i,onClose:a,onSaved:o}){let s=t.find(t=>t.id===e),c=Fe[e],u=n.filter(t=>t.provider===e),[d,f]=(0,Q.useState)(!1),[p,h]=(0,Q.useState)(s?.apiKey??``),[g,v]=(0,Q.useState)(!1),[y,x]=(0,Q.useState)(!1),[S,C]=(0,Q.useState)(null),[w,T]=(0,Q.useState)(!1),k=D(i).providersSettings,A=s?.supportsApiKey!==!1,j=s?.supportsOAuth===!0,M=s?.authMode===`oauth`&&s.authStatus===`connected`,N=s?.configured===!0&&s.activeKeySource!==`env`&&s.activeKeySource!==`extension`&&s.activeKeySource!==`models_json`,[P,F]=(0,Q.useState)(null),[L,R]=(0,Q.useState)(null),[z,B]=(0,Q.useState)(`idle`),[te,ne]=(0,Q.useState)(null),[U,W]=(0,Q.useState)(null),[G,re]=(0,Q.useState)(null),[q,J]=(0,Q.useState)(``),Y=(0,Q.useRef)(null),X=(0,Q.useRef)(null),Z=z===`waiting`||z===`waiting_code`,ie=(0,Q.useMemo)(()=>Se(e,i),[e,i]),oe=p!==(s?.apiKey??``),se=async()=>{let t=p.trim();if(!(!t||!A||je(t))){v(!0),C(null);try{await we({[e]:t}),x(!0),window.setTimeout(()=>{o(),a()},600)}catch(e){C(e instanceof Error?e.message:r.saveError)}finally{v(!1)}}};(0,Q.useEffect)(()=>{if(!P||!Z)return;let e=window.setInterval(()=>{(async()=>{try{let t=await pe(P);t.status===`waiting_auth`||t.status===`waiting_code`?(B(t.status===`waiting_code`?`waiting_code`:`waiting`),R(t.message??null),ne(t.authUrl??null),W(t.instructions??null),re(t.deviceCode??null),t.authUrl&&t.authUrl!==X.current&&(X.current=t.authUrl,qe(t.authUrl,Y.current).catch(()=>{}))):t.status===`completed`?(window.clearInterval(e),Ae(Y.current),Y.current=null,B(`success`),R(t.message??k.saved),window.setTimeout(()=>{o(),a()},600)):(t.status===`failed`||t.status===`cancelled`)&&(window.clearInterval(e),Ae(Y.current),Y.current=null,B(`error`),R(t.error??t.message??k.revokeFailed))}catch{}})()},1e3);return()=>window.clearInterval(e)},[P,Z,a,o,k.revokeFailed,k.saved]),(0,Q.useEffect)(()=>()=>{P&&de(P).catch(()=>{})},[P]),(0,Q.useEffect)(()=>()=>{Ae(Y.current),Y.current=null},[]);let ce=async()=>{try{await ke(e),o(),a()}catch{}},he=async()=>{Ae(Y.current),Y.current=_e(),X.current=null,B(`waiting`),R(k.oauthStarting),ne(null),W(null),re(null),C(null);try{F((await le(e)).sessionId)}catch(e){Ae(Y.current),Y.current=null,B(`error`),R(e instanceof Error?e.message:k.revokeFailed)}},ge=async()=>{if(P){try{await me(P)}catch{}Ae(Y.current),Y.current=null,X.current=null,B(`idle`),R(null),F(null),ne(null),W(null),re(null)}},ve=async()=>{if(!(!P||!q.trim()))try{await fe(P,q.trim()),J(``),R(k.oauthProcessingCode)}catch(e){B(`error`),R(e instanceof Error?e.message:k.revokeFailed)}},ye=async()=>{try{await ue(e),o(),a()}catch(e){C(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)(ee,{className:`text-base font-semibold text-fg`,children:s?.name??e}),(0,$.jsx)(I,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:O(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,H.press),children:(0,$.jsx)(E,{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)(er,{providerId:e,inputId:`manage-api-key`,value:p,onChange:e=>{h(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)(_,{className:`size-3`,"aria-hidden":!0})]}):null]}):null,j?(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:M?k.sourceOauth:k.oauthHint})]}),M?(0,$.jsx)(V,{type:`button`,variant:`secondary`,className:`gap-1.5 text-red-600 dark:text-red-400`,onClick:()=>void ye(),children:k.revoke}):(0,$.jsxs)(V,{type:`button`,variant:`primary`,className:`gap-1.5`,disabled:Z,onClick:()=>void he(),children:[Z?(0,$.jsx)(b,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(Ye,{className:`size-3.5`,"aria-hidden":!0}),k.oauth]})]}),L?(0,$.jsx)(`p`,{className:O(`text-xs`,z===`error`?`text-red-600 dark:text-red-400`:`text-fg-muted`),children:L}):null,z===`waiting`||z===`waiting_code`?(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[te?(0,$.jsxs)(`a`,{href:te,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)(_,{className:`size-4`,"aria-hidden":!0}),k.openAuthPage]}):null,(0,$.jsx)(V,{type:`button`,variant:`secondary`,onClick:()=>void ge(),children:k.cancelOAuth})]}):null,U?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:U}):null,G?(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:G}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:k.deviceCodeHint})]}):null,z===`waiting_code`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,$.jsx)(`input`,{type:`text`,value:q,onChange:e=>J(e.target.value),onKeyDown:e=>e.key===`Enter`&&void ve(),placeholder:k.pasteRedirectUrl,className:O(`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`,K)}),(0,$.jsx)(V,{type:`button`,variant:`primary`,onClick:()=>void ve(),children:k.submitCode})]}):null]}):null,ie.length>0&&A?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:ie.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:[be(e,r),(0,$.jsx)(_,{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:[ae(e,i),e.computerUse?` · Computer Use`:``]},e.id))})})]}):(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r.noModels}),S?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:S}):null]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle px-5 py-3`,children:[N?(0,$.jsxs)(V,{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:()=>T(!0),children:[(0,$.jsx)(Ve,{className:`size-3.5`,"aria-hidden":!0}),r.remove]}):(0,$.jsx)(`span`,{}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:A&&oe&&!je(p.trim())?(0,$.jsx)(V,{type:`button`,variant:`primary`,disabled:!p.trim()||g||y,onClick:()=>void se(),children:y?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(m,{className:`size-3.5`,"aria-hidden":!0}),r.saved]}):g?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(b,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),r.saving]}):r.save}):null})]}),(0,$.jsx)(nt,{open:w,title:r.removeConfirmTitle,description:r.removeConfirmDescription.replace(`{{provider}}`,s?.name??e),confirmLabel:r.removeConfirmAction,cancelLabel:r.cancel,destructive:!0,onConfirm:()=>void ce(),onCancel:()=>T(!1)})]})}function ir({providerId:e,customConfig:t,labels:n,language:r,onClose:i,onSaved:a}){let o=D(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??[]),[m,h]=(0,Q.useState)(!1),[g,_]=(0,Q.useState)(s?.modelDiscovery?.enabled===!0),[v,y]=(0,Q.useState)(!1),[x,C]=(0,Q.useState)(null),[T,k]=(0,Q.useState)(!1),[A,j]=(0,Q.useState)(null),[M,N]=(0,Q.useState)(!1),[P,F]=(0,Q.useState)(null),L=n=>{if(!t)return null;let r=u.trim(),i={...s,baseUrl:c.trim()||void 0,apiKey:je(r)?s?.apiKey:r||void 0,...n};return{providers:{...t.providers,[e]:i}}},R=async()=>{let e=L({models:f,modelDiscovery:{enabled:g}});if(e){y(!0),C(null);try{await ot(e),a(),i()}catch(e){C(e instanceof Error?e.message:n.saveError)}finally{y(!1)}}},z=async()=>{if(t)try{let{[e]:n,...r}=t.providers;await ot({providers:r}),a(),i()}catch{}},B=(e,t)=>{F({model:e,isNew:t}),N(!0)},te=async e=>{if(!P)return;let t=P.isNew?[...f,e]:f.map(t=>t.id===e.id?e:t);p(t);let r=L({models:t});if(r)try{await ot(r),a()}catch(e){C(e instanceof Error?e.message:n.saveError)}},ne=async e=>{let t=f.filter(t=>t.id!==e);p(t),j(null);let r=L({models:t});if(r)try{await ot(r),a()}catch(e){C(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)(ee,{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)(I,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:O(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,H.press),children:(0,$.jsx)(E,{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:O(`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,K)})]}),(0,$.jsx)(er,{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:g,onChange:e=>_(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)(V,{type:`button`,variant:`primary`,className:`gap-1.5 px-2 py-1 text-xs`,onClick:()=>B(null,!0),children:[(0,$.jsx)(w,{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:m,onChange:e=>h(e.target.checked)}),r===`zh`?`仅电脑控制模型`:`Computer Use only`]}),f.filter(e=>!m||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=>!m||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:O(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,H.press),onClick:()=>B(e,!1),"aria-label":o.editModel,children:(0,$.jsx)(S,{className:`size-3.5`,"aria-hidden":!0})}),(0,$.jsx)(`button`,{type:`button`,className:O(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-red-600 dark:hover:text-red-400`,H.press),onClick:()=>j(e.id),"aria-label":o.removeModel,children:(0,$.jsx)(Ve,{className:`size-3.5`,"aria-hidden":!0})})]})]},e.id))})]}),x?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:x}):null]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle px-5 py-3`,children:[(0,$.jsxs)(V,{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)(Ve,{className:`size-3.5`,"aria-hidden":!0}),n.remove]}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,$.jsx)(V,{type:`button`,variant:`primary`,disabled:v,onClick:()=>void R(),children:v?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(b,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),n.saving]}):n.save})})]}),(0,$.jsx)(nt,{open:T,title:n.removeConfirmTitle,description:n.removeConfirmDescription.replace(`{{provider}}`,e),confirmLabel:n.removeConfirmAction,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>void z(),onCancel:()=>k(!1)}),(0,$.jsx)(nt,{open:A!==null,title:o.removeModel,description:o.removeModelConfirm.replace(`{{id}}`,A??``),confirmLabel:n.removeConfirmAction,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>{A&&ne(A)},onCancel:()=>j(null)}),(0,$.jsx)(Qn,{open:M,onOpenChange:e=>{N(e),e||F(null)},providerId:e,model:P?.model??null,isNew:P?.isNew??!1,onSave:e=>void te(e),m:o})]})}function ar(e){return e.status===`ready`?`ready`:e.status===`disabled`?`off`:e.status===`degraded`?`degraded`:e.rejected?.length?`misconfigured`:`not-configured`}function or(e,t){if(e.startsWith(`agentCatalog.defaults.models`))return{label:t?`全局智能体默认模型`:`Global agent defaults`,href:`/settings/agent-defaults`};let n=e.match(/^agentCatalog\.agents\.([^.]+)\.models/);return n?.[1]?{label:t?`智能体 ${n[1]}`:`Agent ${n[1]}`,href:ct(n[1])}:e.startsWith(`sessions.`)?{label:t?`会话模型覆盖`:`Session model override`,href:`/settings/sessions`}:{label:e,href:`/settings/agent-defaults`}}function sr(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:`${De(`models`)}?add=1`,guidance:t?`接入支持图片理解的模型服务`:`Connect a model service that supports vision`,action:t?`去接入模型`:`Connect model`};case`image-generation`:return{href:De(`image`),guidance:t?`选择图片模型并配置所需凭据`:`Choose an image model and configure its credentials`,action:t?`去配置图片生成`:`Configure image generation`};case`stt`:return{href:De(`voice`),guidance:t?`选择语音识别服务,或安装自管 STT 扩展`:`Choose a speech-to-text service or install a self-managed STT extension`,action:t?`去配置语音识别`:`Configure speech-to-text`};case`tts`:return{href:De(`voice`),guidance:t?`选择语音合成服务并完成凭据配置`:`Choose a text-to-speech service and configure its credentials`,action:t?`去配置语音合成`:`Configure text-to-speech`}}}function cr(e){switch(e){case`computer-use`:return`/settings/computer-use`;case`vision`:return De(`models`);case`image-generation`:return De(`image`);case`stt`:case`tts`:return De(`voice`)}}async function lr(){let e=await j(N(`/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 ur(){let e=await j(N(`/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 dr(){let e=M(e=>e.language)===`zh`,{data:t,error:n,isLoading:r}=B(se,lr,{revalidateOnFocus:!0,refreshInterval:6e4}),{data:i}=B(ce,ur,{revalidateOnFocus:!1}),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(null);if(r)return(0,$.jsx)(q,{className:`h-24 w-full rounded-2xl`});let d=Object.values(t?.sources??{}),f=d.reduce((e,t)=>e+t.models.filter(e=>e.availability===`available`).length,0),p=(t?.references??[]).filter(e=>e.availability===`unavailable`),g=t?.sync.lastSuccessAt??Math.max(0,...d.map(e=>e.lastSuccessAt)),_=!!n,v=t?.sync.sourceErrors??{},y=[...t?.sync.lastError?[[`catalog`,t.sync.lastError]]:[],...Object.entries(v),...s?[[`refresh`,s]]:[],...n instanceof Error?[[`load`,n.message]]:[]],x=t?.sync.lastAttemptAt??g,S=Object.entries(i?.capabilities??{}).filter(([e])=>e!==`computer-use`||X()),C=S.some(([,e])=>{let t=ar(e);return t===`degraded`||t===`misconfigured`}),w=S.filter(([,e])=>ar(e)===`ready`).length,T=async()=>{o(!0),c(null);try{let e=await j(N(`/api/models/catalog/refresh`),{method:`POST`});if(!e.ok)throw Error(`HTTP ${e.status}`);await oe()}catch(e){c(e instanceof Error?e.message:String(e))}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:C||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:[C?(0,$.jsx)(tt,{className:`size-4 text-amber-500`,"aria-hidden":!0}):w===S.length&&S.length>0?(0,$.jsx)(m,{className:`size-4 text-emerald-500`,"aria-hidden":!0}):(0,$.jsx)(h,{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?`${w}/${S.length} 项已配置,不影响基础聊天功能`:`${w} of ${S.length} configured · Not required for chat`})]}),(0,$.jsx)(u,{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`&&!X())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=ar(n),o=a===`degraded`||a===`misconfigured`,s=sr(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)(Oe,{className:`size-3.5`,"aria-hidden":!0})]})]}):null]});return(0,$.jsx)(l,{to:o?s.href:cr(t),"aria-label":o?`${r}:${s.action}`:`${e?`配置`:`Configure`} ${r}`,className:O(`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]}),p.length>0?(0,$.jsx)(`div`,{className:`mt-3 space-y-2`,"aria-live":`polite`,children:p.map(t=>(0,$.jsx)(`div`,{className:`rounded-lg border border-amber-500/25 bg-amber-500/5 p-3`,children:(()=>{let n=!!v[t.ref.split(`/`)[0]??``],r=or(t.locations[0]??``,e);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(tt,{className:`mt-0.5 size-4 shrink-0 text-amber-500`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`p`,{className:`break-words text-sm font-medium text-fg`,children:[t.ref,(0,$.jsx)(`span`,{className:`ml-2 font-normal text-amber-700 dark:text-amber-300`,children:n?e?`暂时无法验证`:`Temporarily unverified`:e?`不可用`:`Unavailable`})]}),(0,$.jsxs)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:[n?e?`模型目录同步暂时失败,当前状态可能已过期;不会影响其他可用模型。`:`Catalog sync temporarily failed, so this status may be stale. Other available models are unaffected.`:e?`此模型已无法从当前配置中解析,使用它的功能可能失败。`:`This model no longer resolves from the current configuration. Features using it may fail.`,x?` · ${e?`最近检测`:`Last checked`} ${new Date(x).toLocaleString()}`:``]}),t.suggestedRef?(0,$.jsxs)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[e?`可替换为`:`Suggested replacement`,`:`,(0,$.jsx)(`span`,{className:`font-medium text-fg`,children:t.suggestedRef})]}):null]})]}),(0,$.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1`,children:[(0,$.jsxs)(V,{className:`px-2.5 py-1.5 text-xs`,variant:`ghost`,disabled:a,onClick:()=>void T(),children:[a?(0,$.jsx)(b,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(Ce,{className:`size-3.5`,"aria-hidden":!0}),a?e?`检测中…`:`Checking…`:e?`重新检测`:`Check again`]}),(0,$.jsx)(V,{asChild:!0,className:`px-2.5 py-1.5 text-xs`,variant:`ghost`,children:(0,$.jsxs)(l,{to:r.href,children:[(0,$.jsx)(Me,{className:`size-3.5`,"aria-hidden":!0}),t.suggestedRef?e?`更换模型`:`Replace model`:e?`调整配置`:`Adjust configuration`]})}),(0,$.jsxs)(`details`,{className:`group/references`,children:[(0,$.jsxs)(`summary`,{className:`touch-target inline-flex cursor-pointer list-none items-center gap-1 rounded-xl px-2.5 py-1.5 text-xs font-medium text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[e?`查看 ${t.locations.length} 处引用`:`View ${t.locations.length} ${t.locations.length===1?`reference`:`references`}`,(0,$.jsx)(u,{className:`size-3.5 transition-transform group-open/references:rotate-90 motion-reduce:transition-none`,"aria-hidden":!0})]}),(0,$.jsx)(`ul`,{className:`mt-1 space-y-1 pl-2 text-xs text-fg-muted`,children:t.locations.map(t=>{let n=or(t,e);return(0,$.jsx)(`li`,{children:(0,$.jsx)(l,{className:`inline-flex rounded px-1.5 py-1 text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,to:n.href,title:t,children:n.label})},t)})})]})]})]})})()},t.ref))}):null,_||s?(0,$.jsx)(`p`,{className:`mt-3 text-sm text-danger`,role:`alert`,children:_?e?`暂时无法读取模型状态,请重新检测;详细信息可在高级诊断中查看。`:`Model status is temporarily unavailable. Check again; details are available in Advanced diagnostics.`:e?`重新检测失败,请稍后重试;详细信息可在高级诊断中查看。`:`The check failed. Try again later; details are available in Advanced diagnostics.`}):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,$.jsxs)(`div`,{className:`min-w-0 text-xs text-fg-muted`,children:[(0,$.jsx)(`p`,{children:e?`${d.length} 个来源,${f} 个可用模型${g?` · 最近同步 ${new Date(g).toLocaleString()}`:``}`:`${d.length} sources, ${f} available models${g?` · Last synced ${new Date(g).toLocaleString()}`:``}`}),y.length>0?(0,$.jsx)(`div`,{className:`mt-2 space-y-1 rounded-lg bg-surface-base/45 p-2 font-mono text-[11px] leading-5`,"aria-label":e?`同步错误详情`:`Sync error details`,children:y.map(([e,t],n)=>(0,$.jsxs)(`p`,{className:`break-words`,children:[e,`: `,t]},`${e}-${n}`))}):null]}),(0,$.jsxs)(V,{className:`shrink-0`,type:`button`,variant:`secondary`,disabled:a,onClick:()=>void T(),children:[a?(0,$.jsx)(b,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(Ce,{className:`size-4`,"aria-hidden":!0}),a?e?`刷新中…`:`Refreshing…`:e?`刷新目录`:`Refresh catalog`]})]})]})]})}async function fr(){return(await k(N(`/api/models/xopc-cloud/account-summary`))).payload}function pr(e){let t=(0,It.c)(99),{labels:n}=e,r=M(mr)===`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}=B(`/api/models/xopc-cloud/account-summary`,fr,i);if(s){let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(q,{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)(tt,{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)(Ce,{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)(V,{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,v;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);v=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)(g,{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)(_,{className:`size-3.5`,"aria-hidden":!0}),t[50]=l):l=t[50];let y;t[51]!==a.links.purchase||t[52]!==n.purchase?(y=(0,$.jsx)(V,{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]=y):y=t[53];let b;t[54]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(_,{className:`size-3.5`,"aria-hidden":!0}),t[54]=b):b=t[54];let x;t[55]!==a.links.details||t[56]!==n.details?(x=(0,$.jsx)(V,{asChild:!0,variant:`secondary`,children:(0,$.jsxs)(`a`,{href:a.links.details,target:`_blank`,rel:`noreferrer`,children:[n.details,b]})}),t[55]=a.links.details,t[56]=n.details,t[57]=x):x=t[57];let S;t[58]!==y||t[59]!==x?(S=(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:[y,x]}),t[58]=y,t[59]=x,t[60]=S):S=t[60],t[61]!==c||t[62]!==S?(h=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[c,S]}),t[61]=c,t[62]=S,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]=v}else u=t[35],d=t[36],f=t[37],p=t[38],m=t[39],h=t[40],v=t[41];let y;t[66]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(`span`,{className:`ml-2 text-sm font-medium text-fg-muted`,children:`credits`}),t[66]=y):y=t[66];let b;t[67]!==u||t[68]!==d?(b=(0,$.jsxs)(`p`,{className:u,children:[d,y]}),t[67]=u,t[68]=d,t[69]=b):b=t[69];let x;t[70]!==a.balance.credits||t[71]!==n.zeroBalance?(x=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]=x):x=t[72];let S;t[73]!==x||t[74]!==f||t[75]!==b?(S=(0,$.jsxs)(`div`,{children:[f,b,x]}),t[73]=x,t[74]=f,t[75]=b,t[76]=S):S=t[76];let C;t[77]===n.recentUsage?C=t[78]:(C=(0,$.jsx)(`p`,{className:`text-xs font-medium text-fg-subtle`,children:n.recentUsage}),t[77]=n.recentUsage,t[78]=C);let w;t[79]===v?w=t[80]:(w=(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:v}),t[79]=v,t[80]=w);let T;t[81]!==a.balance.updatedAt||t[82]!==n.updatedAt||t[83]!==r?(T=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]=T):T=t[84];let E;t[85]===T?E=t[86]:(E=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:T}),t[85]=T,t[86]=E);let D;t[87]!==C||t[88]!==w||t[89]!==E?(D=(0,$.jsxs)(`div`,{children:[C,w,E]}),t[87]=C,t[88]=w,t[89]=E,t[90]=D):D=t[90];let O;t[91]!==S||t[92]!==D||t[93]!==p?(O=(0,$.jsxs)(`div`,{className:p,children:[S,D]}),t[91]=S,t[92]=D,t[93]=p,t[94]=O):O=t[94];let k;return t[95]!==O||t[96]!==m||t[97]!==h?(k=(0,$.jsxs)(`section`,{className:m,children:[h,O]}),t[95]=O,t[96]=m,t[97]=h,t[98]=k):k=t[98],k}function mr(e){return e.language}function hr(e){return $e.includes(e)}function gr(){let e=(0,It.c)(69),t=M(yr),n;e[0]===t?n=e[1]:(n=D(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),b=We(),x;e[4]===b.cards?x=e[5]:(x=b.cards.some(vr),e[4]=b.cards,e[5]=x);let S=x,C,w;e[6]!==h||e[7]!==d||e[8]!==f?(C=()=>{if(h!==`models`||d.get(`add`)!==`1`)return;_(!0);let e=new URLSearchParams(d);e.delete(`add`),f(e,{replace:!0})},w=[h,d,f],e[6]=h,e[7]=d,e[8]=f,e[9]=C,e[10]=w):(C=e[9],w=e[10]),(0,Q.useEffect)(C,w);let T;e[11]===i.tabs.models?T=e[12]:(T={id:`models`,icon:Te,label:i.tabs.models},e[11]=i.tabs.models,e[12]=T);let E;e[13]===i.tabs.image?E=e[14]:(E={id:`image`,icon:ge,label:i.tabs.image},e[13]=i.tabs.image,e[14]=E);let O;e[15]!==T||e[16]!==E?(O=[T,E],e[15]=T,e[16]=E,e[17]=O):O=e[17];let k=O,A;e[18]===u?A=e[19]:(A=e=>u(De(e)),e[18]=u,e[19]=A);let j=A,N=_r;if(!hr(h)){let t;return e[20]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(c,{to:De(`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=Ie(t,`configuration`),e[21]=t,e[22]=I);let L;e[23]!==i.docsLink||e[24]!==F||e[25]!==I?(L=(0,$.jsx)(ft,{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]!==k||e[35]!==j?(ee=P?(0,$.jsx)(dt,{items:k,activeTab:h,onChange:j,ariaLabel:i.tabsAria,tabIdPrefix:`capability-tab`,panelIdPrefix:`capability-panel`}):null,e[31]=i.tabsAria,e[32]=h,e[33]=P,e[34]=k,e[35]=j,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]!==b||e[41]!==S?(H=h===`models`?(0,$.jsxs)($.Fragment,{children:[S?(0,$.jsx)(pr,{labels:i.xopcCloudAccount}):null,(0,$.jsx)(Ge,{labels:i.connectedProviders,data:b,onAdd:()=>_(!0),onManage:(e,t)=>y({providerId:e,isCustom:t})}),b.cards.length>0?(0,$.jsx)(dr,{}):null]}):(0,$.jsx)(br,{section:h}),e[37]=i.connectedProviders,e[38]=i.xopcCloudAccount,e[39]=h,e[40]=b,e[41]=S,e[42]=H):H=e[42];let te;e[43]!==z||e[44]!==B||e[45]!==V||e[46]!==H?(te=(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]=te):te=e[47];let ne;e[48]===Symbol.for(`react.memo_cache_sentinel`)?(ne=()=>N(),e[48]=ne):ne=e[48];let U;e[49]!==g||e[50]!==i.addProviderDialog||e[51]!==t||e[52]!==b.builtinRows||e[53]!==b.customConfig?(U=(0,$.jsx)(Le,{open:g,onOpenChange:_,builtinRows:b.builtinRows,customConfig:b.customConfig,labels:i.addProviderDialog,language:t,onSaved:ne}),e[49]=g,e[50]=i.addProviderDialog,e[51]=t,e[52]=b.builtinRows,e[53]=b.customConfig,e[54]=U):U=e[54];let W;e[55]!==i.manageProviderDialog||e[56]!==t||e[57]!==v||e[58]!==b.allModels||e[59]!==b.builtinRows||e[60]!==b.customConfig?(W=v?(0,$.jsx)(nr,{open:!0,onOpenChange:e=>{e||y(null)},providerId:v.providerId,isCustom:v.isCustom,builtinRows:b.builtinRows,customConfig:b.customConfig,allModels:b.allModels,labels:i.manageProviderDialog,language:t,onSaved:N}):null,e[55]=i.manageProviderDialog,e[56]=t,e[57]=v,e[58]=b.allModels,e[59]=b.builtinRows,e[60]=b.customConfig,e[61]=W):W=e[61];let G;return e[62]!==L||e[63]!==R||e[64]!==ee||e[65]!==te||e[66]!==U||e[67]!==W?(G=(0,$.jsxs)(pt,{children:[L,R,ee,te,U,W]}),e[62]=L,e[63]=R,e[64]=ee,e[65]=te,e[66]=U,e[67]=W,e[68]=G):G=e[68],G}function _r(){oe()}function vr(e){return e.id===`xopc-cloud`&&!e.isCustom}function yr(e){return e.language}function br(e){let t=(0,It.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)(Qt,{}),t[0]=e):e=t[0],e}case`voice`:{let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(En,{}),t[1]=e):e=t[1],e}case`search`:{let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Kn,{}),t[2]=e):e=t[2],e}}}export{gr as CapabilitiesSettingsPanel};
@@ -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}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{t as a}from"./popover-select-BNZZDJpO.js";import{t as o}from"./circle-alert-BEjgurr2.js";import{t as s}from"./circle-check-C23XjkUj.js";import{t as c}from"./external-link-DjqjBmc3.js";import{t as l}from"./loader-circle-CifKLtgG.js";import{t as u}from"./rotate-ccw-JM1TBLpp.js";import{t as d}from"./settings-2-D-csvaET.js";import{t as f}from"./x-B_N4OPjy.js";import{t as p}from"./messages-CnM6Qfr7.js";import{t as m}from"./cn-JdwAhgNB.js";import{a as h,c as g,i as _,n as v,r as y}from"./locale-store-ChN_vjs2.js";import{a as b,i as x,n as S,o as C,r as w,s as T,t as E}from"./dist-BGTk37IG.js";import{i as D}from"./vendor-swr-BIWyz7Rc.js";import{t as O}from"./button-CS04eWY9.js";import{t as k}from"./interaction-BdhHBbYa.js";import{t as A}from"./skeleton-BwbyijEw.js";import{i as j,o as M}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{t as N}from"./settings-shell-layer-context-BTQUDoJ2.js";import{Mr as P,Ro as F,_n as I,_o as L,ai as R,ci as z,dn as B,ei as V,gn as ee,hn as te,so as ne}from"./index-BcTY7RBG.js";import{r as re}from"./settings-page-layout-X1x-2Cp9.js";import{t as ie}from"./browser-BLJWD7WI.js";import{n as ae}from"./settings-loading-skeleton-CAmWMaOT.js";import{t as oe}from"./schema-form-BQz6ezGe.js";var H=e(t(),1),U=n();async function se(){return(await h(y(`/api/channels/status`))).payload?.channels||[]}function ce(){return y(`/api/channels/status`)}var le=se;function ue(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 de=e(ie(),1),W=r();async function G(e){let t=await _(y(`/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 K(e){return e?.type===`poll`&&e.phase===`done`}function q(e){return e&&`message`in e&&typeof e.message==`string`?e.message:null}function J(e,t){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrPayload?e.qrPayload:t===`weixin`&&e.qrcodeUrl?e.qrcodeUrl:null}function Y(e){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrcodeUrl??null}function fe({entry:e,locale:t,messages:n,onChanged:r,compact:i=!1}){let a=(0,H.useMemo)(()=>ue(e),[e]),o=(0,H.useMemo)(()=>({defaultBooleanLabel:n.schemaBooleanDefault,unsupportedArrayType:n.schemaUnsupportedArrayType,arrayAddPlaceholder:n.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>n.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[n]),[u,d]=(0,H.useState)({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null});(0,H.useEffect)(()=>{d({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null})},[e.id]);let f=(0,H.useCallback)(async(n,i)=>{d(e=>({...e,busy:!0,error:null}));try{let a=await G({channelId:e.id,actionId:n,locale:t,input:i});d(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){d(t=>({...t,busy:!1,error:e instanceof Error?e.message:String(e)}))}},[e.id,t,r]);(0,H.useEffect)(()=>{let t=J(u.payload,e.id);if(!t){d(e=>e.generatedQr?{...e,generatedQr:null}:e);return}let n=!1;return d(e=>e.generatedQr?{...e,generatedQr:null}:e),de.toDataURL(t,{width:220,margin:1}).then(e=>{n||d(t=>({...t,generatedQr:e}))}),()=>{n=!0}},[e.id,u.payload]),(0,H.useEffect)(()=>{let n=u.poll;if(!n)return;let i=!1,a=window.setInterval(()=>{i||G({channelId:e.id,actionId:n.actionId,locale:t,input:{conversationId:n.conversationId}}).then(async e=>{i||(d(t=>({...t,payload:e,poll:K(e)?null:t.poll,error:null})),`configChanged`in e&&e.configChanged===!0&&await r(),K(e)&&window.clearInterval(a))}).catch(e=>{i||d(t=>({...t,error:e instanceof Error?e.message:String(e)}))})},n.intervalMs);return()=>{i=!0,window.clearInterval(a)}},[e.id,t,r,u.poll]);let p=a?.[1].label??(e.configured?n.reconnect:n.connect),h=e.actions?.[`doctor.run`]?.label??n.diagnose,g=q(u.payload),_=J(u.payload,e.id),v=_?u.generatedQr:Y(u.payload),y=a?.[1].result===`qr`&&(u.busy||u.payload?.type===`qr`||u.payload?.type===`poll`),b=u.payload?.type===`form`?u.payload:null,x=u.payload?.type===`diagnostics`?u.payload.checks:null;return(0,W.jsxs)(`div`,{className:i?`space-y-3`:`rounded-lg bg-surface-panel/80 p-4 shadow-surface`,children:[(0,W.jsxs)(`div`,{className:m(`flex flex-wrap items-start gap-3`,i?`justify-end`:`justify-between`),children:[i?null:(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.setupTitle}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.configured?n.setupConfiguredHint:n.setupEmptyHint})]}),(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[a?(0,W.jsxs)(O,{type:`button`,variant:`primary`,disabled:u.busy,onClick:()=>void f(a[0]),children:[u.busy?(0,W.jsx)(l,{className:`size-4 animate-spin`}):(0,W.jsx)(F,{className:`size-4`}),p]}):null,e.actions?.[`doctor.run`]?(0,W.jsxs)(O,{type:`button`,variant:`secondary`,disabled:u.busy,onClick:()=>void f(`doctor.run`),children:[(0,W.jsx)(L,{className:`size-4`}),h]}):null]})]}),g?(0,W.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:g}):null,u.error?(0,W.jsx)(`p`,{className:`mt-3 text-sm text-red-600 dark:text-red-400`,children:u.error}):null,y?(0,W.jsxs)(`div`,{className:m(`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,W.jsx)(`div`,{className:`flex size-56 shrink-0 items-center justify-center rounded-lg border border-edge bg-white p-3`,children:v?(0,W.jsx)(`img`,{src:v,alt:`${e.label} setup QR`,className:`size-52 object-contain`}):(0,W.jsx)(`div`,{className:`flex size-52 items-center justify-center rounded-md bg-surface-base`,children:(0,W.jsx)(A,{className:`size-48 rounded-md`})})}),(0,W.jsxs)(`div`,{className:m(`min-w-0 max-w-sm text-sm text-fg-muted`,i&&`w-full sm:w-auto`),children:[v?(0,W.jsx)(`p`,{className:`line-clamp-3`,children:n.waitingConfirmation}):(0,W.jsxs)(`div`,{className:`space-y-2`,"aria-busy":`true`,children:[(0,W.jsx)(A,{className:`h-4 w-48 max-w-full`}),(0,W.jsx)(A,{className:`h-4 w-36 max-w-full`})]}),_?(0,W.jsxs)(`a`,{className:`mt-2 inline-flex items-center gap-1 text-accent hover:underline`,href:_,target:`_blank`,rel:`noreferrer`,children:[n.openSetupLink,(0,W.jsx)(c,{className:`size-3.5`})]}):null]})]}):null,u.payload?.type===`poll`&&u.payload.phase===`done`?(0,W.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,W.jsx)(s,{className:u.payload.ok?`size-4 text-green-600`:`size-4 text-red-600`}),(0,W.jsx)(`span`,{className:u.payload.ok?`text-fg`:`text-red-600 dark:text-red-400`,children:u.payload.message??(u.payload.ok?n.complete:n.failed)})]}):null,b?(0,W.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,W.jsx)(oe,{schema:b.schema,values:u.formDraft,onChange:e=>d(t=>({...t,formDraft:e})),disabled:u.busy,labels:o}),(0,W.jsx)(O,{type:`button`,variant:`primary`,disabled:u.busy,onClick:()=>void f(b.submitAction,u.formDraft),children:n.saveSetup})]}):null,x?(0,W.jsx)(`div`,{className:`mt-4 space-y-2`,children:x.map((e,t)=>(0,W.jsxs)(`div`,{className:`rounded-lg bg-surface-base px-3 py-2 shadow-surface`,children:[(0,W.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,W.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.label??e.id??n.diagnosticCheckFallback.replace(`{{index}}`,String(t+1))}),(0,W.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,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.message}):null]},e.id??t))}):null]})}var pe=40;function me(e){return`ui:route:channel:${e.trim().toLowerCase()}`}function he(e,t){return e.find(e=>e.id===me(t))?.agentId?.trim().toLowerCase()??``}function ge(e,t,n){let r=me(t),i=e.filter(e=>e.id!==r),a=n.trim().toLowerCase();return a?[...i,{id:r,agentId:a,priority:pe,enabled:!0,match:{channel:t.trim().toLowerCase(),accountId:`*`}}]:i}function _e(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,n){let r=_e(e);return r.ready?r.enabled?n?t?.connected===!0?`running`:`stopped`:`checking`:`disabled`:`needs_setup`}function ye(e,t=!1){return e===`drawer`?m(`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`,j):m(`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)]`,j,`rounded-2xl border border-edge bg-surface-overlay outline-none dark:border-edge`)}function be(e){let t=(0,U.c)(33),{presentation:n,open:r,onOpenChange:i,title:a,description:o,srTitle:s,srDescription:c,closeAriaLabel:l,children:u,footer:d,wide:p,headerExtra:h}=e,g=p===void 0?!1:p,_=n===`drawer`,[v,y]=(0,H.useState)(null),D;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(D=(0,W.jsx)(b,{className:m(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,M)}),t[0]=D):D=t[0];let A;t[1]!==n||t[2]!==g?(A=ye(n,g),t[1]=n,t[2]=g,t[3]=A):A=t[3];let j;t[4]===s?j=t[5]:(j=s?(0,W.jsx)(T,{className:`sr-only`,children:s}):null,t[4]=s,t[5]=j);let P;t[6]===c?P=t[7]:(P=c?(0,W.jsx)(x,{className:`sr-only`,children:c}):null,t[6]=c,t[7]=P);let F;t[8]!==l||t[9]!==o||t[10]!==h||t[11]!==_||t[12]!==a?(F=_?(0,W.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,W.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[a?(0,W.jsx)(`div`,{className:`text-base font-semibold text-fg`,children:a}):null,o?(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:o}):null]}),(0,W.jsx)(S,{asChild:!0,children:(0,W.jsx)(O,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":l,children:(0,W.jsx)(f,{className:`size-5`,strokeWidth:1.75})})})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(S,{asChild:!0,children:(0,W.jsx)(`button`,{type:`button`,className:m(k,`absolute right-3 top-3 z-20 p-1.5 hover:bg-surface-hover`),"aria-label":l,children:(0,W.jsx)(f,{className:`size-4`})})}),h]}),t[8]=l,t[9]=o,t[10]=h,t[11]=_,t[12]=a,t[13]=F):F=t[13];let I=_?`p-4`:`p-6`,L;t[14]===I?L=t[15]:(L=m(`min-h-0 flex-1 overflow-y-auto`,I),t[14]=I,t[15]=L);let R;t[16]!==u||t[17]!==L?(R=(0,W.jsx)(`div`,{className:L,children:u}),t[16]=u,t[17]=L,t[18]=R):R=t[18];let z;t[19]!==d||t[20]!==v||t[21]!==j||t[22]!==P||t[23]!==F||t[24]!==R?(z=(0,W.jsxs)(N,{layer:`modal`,portalContainer:v,children:[j,P,F,R,d]}),t[19]=d,t[20]=v,t[21]=j,t[22]=P,t[23]=F,t[24]=R,t[25]=z):z=t[25];let B;t[26]!==z||t[27]!==A?(B=(0,W.jsxs)(C,{children:[D,(0,W.jsx)(w,{ref:y,className:A,onOpenAutoFocus:xe,children:z})]}),t[26]=z,t[27]=A,t[28]=B):B=t[28];let V;return t[29]!==i||t[30]!==r||t[31]!==B?(V=(0,W.jsx)(E,{open:r,onOpenChange:i,children:B}),t[29]=i,t[30]=r,t[31]=B,t[32]=V):V=t[32],V}function xe(e){return e.preventDefault()}var Se=(0,H.memo)(function(e){let t=(0,U.c)(10),{ch:n,refreshing:r,saveOk:i,onRefresh:a}=e,o;t[0]!==n.saved||t[1]!==i?(o=i?(0,W.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,W.jsx)(V,{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,W.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 Ce(e){let t=(0,U.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,W.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,W.jsx)(O,{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,W.jsx)(O,{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,W.jsx)(O,{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,W.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,W.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 we(e){return y(`/api/channels/catalog?locale=${encodeURIComponent(e)}`)}async function Te(e){return(await h(we(e))).payload?.channels??[]}function Ee(e,t){let n=(0,U.c)(14),r;n[0]!==e||n[1]!==t?(r=e?we(t):null,n[0]=e,n[1]=t,n[2]=r):r=n[2];let i;n[3]===t?i=n[4]:(i=()=>Te(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}=D(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 De=`channels-status`;function Oe(e){if(!e||typeof e!=`object`)return null;let t=e.channels;return Array.isArray(t)?t:null}function ke(e){let t=t=>e(t.detail);return window.addEventListener(De,t),()=>window.removeEventListener(De,t)}function Ae(e,t){let n=(0,U.c)(4),r=t===void 0?!0:t,i,a;n[0]!==r||n[1]!==e?(i=()=>{if(r)return ke(e)},a=[r,e],n[0]=r,n[1]=e,n[2]=i,n[3]=a):(i=n[2],a=n[3]),(0,H.useEffect)(i,a)}function je(e){return e?y(`/api/channels/${encodeURIComponent(e)}/config`):null}async function Me(e){return(await h(y(`/api/channels/${encodeURIComponent(e)}/config`))).payload?.config??{}}var Ne=[`enabled`],Pe=`max-w-7xl`,Fe=`px-4 pb-7 pt-3 sm:px-6 lg:px-8 lg:pb-9 lg:pt-4`;async function Ie(){let e=await h(y(`/api/config`));return{channels:e.payload?.config?.channels??{},bindings:e.payload?.config?.bindings??[]}}function Le(e){return e.split(`/`).filter(Boolean).map(e=>encodeURIComponent(e)).join(`/`)}function Re(e){return e.configPath.startsWith(`channels.`)&&e.configPath.slice(9).split(`.`)[0]||e.id}function X(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 ze(e,t){return e===`running`?t.connectionRunning:e===`stopped`?t.connectionStopped:e===`checking`?t.connectionChecking:e===`disabled`?t.connectionDisabled:t.connectionNeedsSetup}function Be(e,t){return e===`running`?t.connectionRunningHint:e===`stopped`?t.connectionStoppedHint:e===`disabled`?t.connectionDisabledHint:e===`needs_setup`?t.connectionNeedsSetupHint:t.connectionChecking}function Ve(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 He(e){if(!e)return[];let t=e.uiHints??{},n=Z(e.configSchema)&&Array.isArray(e.configSchema.required)?e.configSchema.required.map(String):[],r=X(e).issues.map(e=>e.fieldPath).filter(e=>!!e),i=Object.entries(t).filter(([,e])=>!Z(e)||e.advanced===!0?!1:(Array.isArray(e.tags)?e.tags.map(String):[]).includes(`basic`)||e.advanced===!1).map(([e])=>e).filter(e=>!Ne.includes(e));return Array.from(new Set([...i,...n,...r])).filter(e=>!Ne.includes(e))}function Z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Ue(e){return JSON.parse(JSON.stringify(e??{type:`object`,properties:{}}))}function We(e,t){let n={...Ue(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(!Z(r)||!Z(r[n]))break;let o=Z(a.properties)?a.properties:{};if(a.properties=o,o[n]||(o[n]={...Ue(r[n]),properties:{}}),e===t.length-1){o[n]=Ue(r[n]);break}i=r[n],a=o[n]}}return n}function Ge(e){let t=e.properties;if(!Z(t))return!1;for(let[e,n]of Object.entries(t))Z(n)&&n.type===`object`&&Ge(n)&&delete t[e];return Object.keys(t).length===0}function Ke(e,t){let n=Ue(e);for(let e of t){let t=e.split(`.`),r=n;for(let[e,n]of t.entries()){let i=r.properties;if(!Z(i))break;if(e===t.length-1){delete i[n];break}if(!Z(i[n]))break;r=i[n]}}return Ge(n),n}function qe(e){return e.type===`object`&&Z(e.properties)&&Object.keys(e.properties).length>0}function Q(e,t){let n=e;for(let e of t.split(`.`)){if(!Z(n))return;n=n[e]}return n}function Je(e){let t=e.accounts;return Z(t)?Object.values(t).filter(e=>Z(e)&&e.enabled!==!1).length:+(e.configured===!0)}function Ye(e,t,n){return t==null||t===``?null:e.toLowerCase().includes(`dmpolicy`)&&typeof t==`string`?`${n.dmPolicy}: ${n.policy.dm[t]??t}`:(e.toLowerCase().includes(`stream`)||e.toLowerCase().includes(`streaming`))&&typeof t==`string`?`${n.cardStream}: ${n.policy.stream[t]??t}`:typeof t==`boolean`?t?n.enabledLabel:n.disabledLabel:String(t)}function Xe(e,t,n){let r=[],i=X(e);if(i.issues.length>0&&r.push($(i.issues[0],n)),t){let i=e.ui?.card?.summaryFields??[`dmPolicy`,`streamMode`,`streaming.mode`];for(let e of i){let i=Ye(e,Q(t,e),n);i&&r.push(i)}let a=Je(t);a>0&&r.push(n.cardAccounts.replace(`{{count}}`,String(a)))}return r.length>0?r.slice(0,2):i.ready?[n.hubStatusConfigured]:[]}function Ze(e,t){let n=X(e),r=ue(e);return n.state===`needs_setup`?r?.[1].label??t.completeSetup:!n.enabled&&n.ready?t.enableChannel:n.state===`error`?t.diagnose:n.ready?t.manageChannel:r?.[1].label??t.startConfiguration}function Qe(e,t){let n=ue(e);return n?.[1].result===`qr`?t.cardSetupQrHint:n?.[1].result===`form`?t.cardSetupConfigHint:t.cardSetupGenericHint}function $e(e,t){let n=e.capabilities??{},r=[];return n.login===!0&&r.push(t.cardCapabilityLogin),n.pairing===!0&&r.push(t.cardCapabilityPairing),n.multiAccount===!0&&r.push(t.cardCapabilityMultiAccount),n.streaming===!0&&r.push(t.cardCapabilityStreaming),n.media===!0&&r.push(t.cardCapabilityMedia),n.doctor===!0&&r.push(t.cardCapabilityDoctor),r.slice(0,3)}function $(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 et({entry:e}){let[t,n]=(0,H.useState)(!1),r=(0,H.useMemo)(()=>!e.ui?.icon||t?null:new URL(y(`/api/extensions/${encodeURIComponent(e.extensionId)}/assets/${Le(e.ui.icon)}`)).toString(),[t,e.extensionId,e.ui?.icon]);return(0,W.jsx)(`span`,{className:`flex size-12 shrink-0 items-center justify-center rounded-2xl bg-surface-base text-fg`,children:r?(0,W.jsx)(`img`,{src:r,alt:``,draggable:!1,className:`size-7`,"aria-hidden":!0,onError:()=>n(!0)}):(0,W.jsx)(z,{sourceChannel:e.id,className:`size-7`})})}function tt(e){let t=(0,U.c)(16),{checked:n,disabled:r,onToggle:i,label:a}=e,o;t[0]===i?o=t[1]:(o=e=>{e.stopPropagation(),i()},t[0]=i,t[1]=o);let s=n?`border-accent bg-accent`:`border-edge bg-surface-hover`,c=r&&`cursor-not-allowed opacity-60`,l;t[2]!==s||t[3]!==c?(l=m(`relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border transition-colors`,s,c),t[2]=s,t[3]=c,t[4]=l):l=t[4];let u=n?`translate-x-5`:`translate-x-0.5`,d;t[5]===u?d=t[6]:(d=m(`size-5 rounded-full bg-white shadow-surface transition-transform`,u),t[5]=u,t[6]=d);let f;t[7]===d?f=t[8]:(f=(0,W.jsx)(`span`,{className:d}),t[7]=d,t[8]=f);let p;return t[9]!==n||t[10]!==r||t[11]!==a||t[12]!==o||t[13]!==l||t[14]!==f?(p=(0,W.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":n,"aria-label":a,disabled:r,onClick:o,className:l,children:f}),t[9]=n,t[10]=r,t[11]=a,t[12]=o,t[13]=l,t[14]=f,t[15]=p):p=t[15],p}function nt(e){let t=(0,U.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=X(n),t[0]=n,t[1]=f);let p=f,h,g,_,v,y,b,x;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=Xe(n,r,s),o=$e(n,s);h=!p.enabled&&p.ready?u:i===`stopped`?d:c,b=`flex min-h-[15.5rem] flex-col rounded-xl bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45`;let l;t[19]===n?l=t[20]:(l=(0,W.jsx)(et,{entry:n}),t[19]=n,t[20]=l);let f;t[21]===n.label?f=t[22]:(f=(0,W.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:n.label}),t[21]=n.label,t[22]=f);let S;t[23]===i?S=t[24]:(S=m(`mt-1 inline-flex rounded-full px-2 py-0.5 text-xs font-medium`,Ve(i)),t[23]=i,t[24]=S);let C;t[25]!==s||t[26]!==i?(C=ze(i,s),t[25]=s,t[26]=i,t[27]=C):C=t[27];let w;t[28]!==S||t[29]!==C?(w=(0,W.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]!==f?(T=(0,W.jsxs)(`div`,{className:`min-w-0`,children:[f,w]}),t[31]=w,t[32]=f,t[33]=T):T=t[33];let E;t[34]!==T||t[35]!==l?(E=(0,W.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[l,T]}),t[34]=T,t[35]=l,t[36]=E):E=t[36];let D=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,W.jsx)(tt,{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?(x=(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[E,k]}),t[45]=E,t[46]=k,t[47]=x):x=t[47],g=`button`,_=c,v=`mt-5 min-h-[6.25rem] text-left`,y=p.ready?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`p`,{className:`line-clamp-2 text-sm leading-6 text-fg-muted`,children:n.description??n.id}),e.length>0?(0,W.jsx)(`div`,{className:`mt-3 space-y-0.5 text-sm leading-5 text-fg-muted`,children:e.map(it)}):null]}):(0,W.jsxs)(`div`,{className:`rounded-lg bg-surface-base p-3`,children:[(0,W.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:s.cardSetupTitle}),(0,W.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm leading-5 text-fg-muted`,children:e[0]??Qe(n,s)}),o.length>0?(0,W.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:o.map(rt)}):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]=h,t[13]=g,t[14]=_,t[15]=v,t[16]=y,t[17]=b,t[18]=x}else h=t[12],g=t[13],_=t[14],v=t[15],y=t[16],b=t[17],x=t[18];let S;t[48]!==g||t[49]!==_||t[50]!==v||t[51]!==y?(S=(0,W.jsx)(`button`,{type:g,onClick:_,className:v,children:y}),t[48]=g,t[49]=_,t[50]=v,t[51]=y,t[52]=S):S=t[52];let C=a||o,w;t[53]!==a||t[54]!==o?(w=a||o?(0,W.jsx)(l,{className:`size-4 animate-spin`}):null,t[53]=a,t[54]=o,t[55]=w):w=t[55];let T;t[56]!==s||t[57]!==n||t[58]!==o||t[59]!==i?(T=o?s.restartingChannel:i===`stopped`?s.restartChannel:Ze(n,s),t[56]=s,t[57]=n,t[58]=o,t[59]=i,t[60]=T):T=t[60];let E;t[61]!==h||t[62]!==w||t[63]!==T||t[64]!==C?(E=(0,W.jsx)(`div`,{className:`mt-auto pt-4`,children:(0,W.jsxs)(O,{type:`button`,variant:`secondary`,className:`w-full rounded-2xl py-2.5`,onClick:h,disabled:C,children:[w,T]})}),t[61]=h,t[62]=w,t[63]=T,t[64]=C,t[65]=E):E=t[65];let D;return t[66]!==E||t[67]!==b||t[68]!==x||t[69]!==S?(D=(0,W.jsxs)(`article`,{className:b,children:[x,S,E]}),t[66]=E,t[67]=b,t[68]=x,t[69]=S,t[70]=D):D=t[70],D}function rt(e){return(0,W.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e},e)}function it(e){return(0,W.jsx)(`p`,{className:`truncate`,title:e,children:e},e)}function at(e){let t=(0,U.c)(51),{runtime:n,restarting:r,checking:i,showConnectionOptions:a,canManageConnection:c,ch:d,onRestart:f,onCheck:p,onManageConnection:h}=e,g=n===`running`?s:n===`stopped`||n===`needs_setup`?o:l,_=n===`running`&&`text-emerald-600 dark:text-emerald-400`,v=n===`stopped`&&`text-red-600 dark:text-red-400`,y=n===`checking`&&`animate-spin text-amber-600 dark:text-amber-400`,b=n===`disabled`&&`text-fg-muted`,x=n===`needs_setup`&&`text-amber-600 dark:text-amber-400`,S;t[0]!==_||t[1]!==v||t[2]!==y||t[3]!==b||t[4]!==x?(S=m(`mt-0.5 size-5 shrink-0`,_,v,y,b,x),t[0]=_,t[1]=v,t[2]=y,t[3]=b,t[4]=x,t[5]=S):S=t[5];let C;t[6]!==g||t[7]!==S?(C=(0,W.jsx)(g,{className:S}),t[6]=g,t[7]=S,t[8]=C):C=t[8];let w;t[9]===d.connectionStatus?w=t[10]:(w=(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:d.connectionStatus}),t[9]=d.connectionStatus,t[10]=w);let T;t[11]!==d||t[12]!==n?(T=Be(n,d),t[11]=d,t[12]=n,t[13]=T):T=t[13];let E;t[14]===T?E=t[15]:(E=(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:T}),t[14]=T,t[15]=E);let D;t[16]!==E||t[17]!==w?(D=(0,W.jsxs)(`div`,{children:[w,E]}),t[16]=E,t[17]=w,t[18]=D):D=t[18];let k;t[19]!==D||t[20]!==C?(k=(0,W.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[C,D]}),t[19]=D,t[20]=C,t[21]=k):k=t[21];let A=i||r,j;t[22]===i?j=t[23]:(j=i?(0,W.jsx)(l,{className:`size-4 animate-spin`}):null,t[22]=i,t[23]=j);let M=i?d.checkingConnection:d.checkConnection,N;t[24]!==p||t[25]!==A||t[26]!==j||t[27]!==M?(N=(0,W.jsxs)(O,{type:`button`,variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:A,onClick:p,children:[j,M]}),t[24]=p,t[25]=A,t[26]=j,t[27]=M,t[28]=N):N=t[28];let P;t[29]!==d.restartChannel||t[30]!==d.restartingChannel||t[31]!==i||t[32]!==f||t[33]!==r||t[34]!==n?(P=n===`stopped`?(0,W.jsxs)(O,{type:`button`,variant:`primary`,className:`px-2.5 py-1.5 text-xs`,disabled:r||i,onClick:f,children:[r?(0,W.jsx)(l,{className:`size-4 animate-spin`}):(0,W.jsx)(u,{className:`size-4`}),r?d.restartingChannel:d.restartChannel]}):null,t[29]=d.restartChannel,t[30]=d.restartingChannel,t[31]=i,t[32]=f,t[33]=r,t[34]=n,t[35]=P):P=t[35];let F;t[36]!==c||t[37]!==d.connectionOptions||t[38]!==d.hideConnectionOptions||t[39]!==i||t[40]!==h||t[41]!==r||t[42]!==a?(F=c?(0,W.jsx)(O,{type:`button`,variant:`ghost`,className:`px-2.5 py-1.5 text-xs`,disabled:i||r,onClick:h,children:a?d.hideConnectionOptions:d.connectionOptions}):null,t[36]=c,t[37]=d.connectionOptions,t[38]=d.hideConnectionOptions,t[39]=i,t[40]=h,t[41]=r,t[42]=a,t[43]=F):F=t[43];let I;t[44]!==N||t[45]!==P||t[46]!==F?(I=(0,W.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[N,P,F]}),t[44]=N,t[45]=P,t[46]=F,t[47]=I):I=t[47];let L;return t[48]!==k||t[49]!==I?(L=(0,W.jsx)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:(0,W.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[k,I]})}),t[48]=k,t[49]=I,t[50]=L):L=t[50],L}function ot(e){let t=(0,U.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=X(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,W.jsx)(ne,{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,W.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,W.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,W.jsx)(`li`,{children:$(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,W.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,W.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,W.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,W.jsx)(`section`,{className:d,children:h}),t[30]=h,t[31]=d,t[32]=g):g=t[32],g}function st({channelId:e,onHeaderActionChange:t}){let n=v(e=>e.language),r=p(n),o=g(e=>!!e.conversationId),s=i(),l=I(e),u=Ee(o,n),f=u.entries,{data:h,mutate:b,isValidating:x}=D(o?ce():null,le,{revalidateOnFocus:!0}),{data:S,mutate:C}=D(o?`channels-config-map`:null,Ie,{revalidateOnFocus:!1}),w=S?.channels??{},T=S?.bindings??[],{data:E}=D(o?`channel-routing-agents`:null,R,{revalidateOnFocus:!1}),O=(0,H.useMemo)(()=>f.find(e=>e.id===l),[l,f]),k=O?Re(O):null,{data:A,mutate:j}=D(o&&k?je(k):null,()=>Me(k)),[M,N]=(0,H.useState)(null),[F,L]=(0,H.useState)(!1),[z,V]=(0,H.useState)(null),[ne,ie]=(0,H.useState)(null),[U,se]=(0,H.useState)(!1),[de,G]=(0,H.useState)(null),[K,q]=(0,H.useState)(null),J=M??A??{},Y=r.channelsSettings,pe=(0,H.useMemo)(()=>O?.configSchema??{type:`object`,properties:{}},[O?.configSchema]),me=(0,H.useMemo)(()=>Ke(pe,Ne),[pe]),_e=(0,H.useMemo)(()=>He(O),[O]),ye=(0,H.useMemo)(()=>We(me,_e),[_e,me]),xe=(0,H.useMemo)(()=>Ke(me,_e),[_e,me]),we=(0,H.useMemo)(()=>qe(ye),[ye]),Te=O?K??he(T,O.id):``,De=(0,H.useMemo)(()=>(E?.items??[]).map(e=>{let t=B(e,r.agentsSettings);return{value:e.id,label:t===e.id?t:`${t} · ${e.id}`}}),[E?.items,r.agentsSettings]),ke=E?.items.find(e=>e.id===E.defaultId),Le=ke?B(ke,r.agentsSettings):E?.defaultId??``,Be=(0,H.useMemo)(()=>({defaultBooleanLabel:Y.schemaBooleanDefault,unsupportedArrayType:Y.schemaUnsupportedArrayType,arrayAddPlaceholder:Y.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>Y.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[Y]),Z=(0,H.useMemo)(()=>new Map((h??[]).map(e=>[e.name,e])),[h]),Ue=h!==void 0,Ge=(0,H.useCallback)(e=>ve(e,Z.get(e.id),Ue),[Z,Ue]),Q=(0,H.useCallback)(async()=>{await Promise.all([u.mutate(),b()])},[u,b]);Ae((0,H.useCallback)(e=>{let t=Oe(e);t&&b(t,!1)},[b]),o);let Je=(0,H.useMemo)(()=>o?{secondary:(0,W.jsx)(Se,{ch:Y,refreshing:u.isValidating||x,saveOk:!1,onRefresh:()=>void Q()})}:null,[u.isValidating,Y,o,x,Q]);(0,H.useLayoutEffect)(()=>(t?.(Je),()=>t?.(null)),[Je,t]);let Ye=(0,H.useCallback)(e=>{s(ee(e)),N(null),q(null),G(null)},[s]),Xe=(0,H.useCallback)(()=>{s(te),N(null),q(null),G(null)},[s]),Ze=(0,H.useCallback)(async e=>{ie(e.id),G(null);try{let t=await _(y(`/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{ie(null)}},[Q]);(0,H.useEffect)(()=>{q(null),se(!1)},[O?.id]);let Qe=(0,H.useCallback)(async()=>{if(!O||!M&&K===null)return!1;let e=Re(O);L(!0),G(null);try{let t=await _(y(`/api/config`),{method:`PATCH`,body:JSON.stringify({...M?{channels:{[e]:M}}:{},...K===null?{}:{bindings:ge(T,O.id,K)}})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}return M&&await j(M,!1),await C(),await u.mutate(),N(null),q(null),!0}catch(e){return G(e instanceof Error?e.message:String(e)),!1}finally{L(!1)}},[O,K,T,u,M,C,j]),$e=(0,H.useCallback)(async e=>{let t=X(e),n=Re(e),r=O?.id===e.id?M:null;if(!t.enabled&&!t.ready&&!r){Ye(e.id);return}V(e.id),G(null);try{let i=t.enabled?{enabled:!1}:r?{...r,enabled:!0}:{enabled:!0},a=await _(y(`/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 C(),await b(),O?.id===e.id&&(await j(),N(null))}catch(e){G(e instanceof Error?e.message:String(e))}finally{V(null)}},[O?.id,u,M,C,j,b,Ye]),$=O?.ui?.modal,rt=$?.placement!==`replace-config`,it=O?Ge(O):`checking`,st=O?!X(O).ready||U:!1;return o?(0,W.jsxs)(re,{gap:`gap-4`,className:Pe,padding:Fe,children:[u.isLoading?(0,W.jsx)(ae,{sections:2}):u.error?(0,W.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:String(u.error)}):(0,W.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:f.map(e=>(0,W.jsx)(nt,{entry:e,config:w[Re(e)]?.config,runtime:Ge(e),busy:z===e.id,restarting:ne===e.id,ch:Y,onOpen:()=>Ye(e.id),onToggle:()=>void $e(e),onRestart:()=>void Ze(e)},e.id))}),de?(0,W.jsx)(`p`,{className:`mt-4 text-sm text-red-600 dark:text-red-400`,children:de}):null,(0,W.jsx)(be,{presentation:`modal`,open:!!O,onOpenChange:e=>{e||Xe()},closeAriaLabel:Y.close,srTitle:O?.label??Y.selectChannel,srDescription:O?.description,wide:!0,footer:O?(0,W.jsx)(Ce,{ch:Y,dirty:!!M||K!==null,saving:F,onCancel:Xe,onDiscard:()=>{N(null),q(null)},onSave:Qe}):null,children:O?(0,W.jsxs)(`div`,{className:`space-y-4`,children:[(0,W.jsx)(`div`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,children:(0,W.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,W.jsx)(et,{entry:O}),(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,W.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:O.label}),(0,W.jsx)(`span`,{className:m(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,Ve(it)),children:ze(it,Y)})]}),(0,W.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,W.jsx)(`span`,{className:`min-w-0 truncate`,children:!X(O).ready&&ue(O)?.[1].result===`qr`?Y.scanLoginHint.replace(`{{channel}}`,O.label):O.description}),O.docsPath?(0,W.jsxs)(`a`,{href:O.docsPath,target:`_blank`,rel:`noreferrer`,className:`inline-flex shrink-0 items-center gap-1 text-accent hover:underline`,children:[Y.docs,(0,W.jsx)(c,{className:`size-3.5`})]}):null]})]})]}),(0,W.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pr-8`,children:[(0,W.jsx)(`span`,{className:`hidden text-xs text-fg-muted sm:inline`,children:X(O).enabled?Y.enabledLabel:Y.disabledLabel}),(0,W.jsx)(tt,{checked:X(O).enabled,disabled:z===O.id,label:Y.toggleChannel.replace(`{{channel}}`,O.label),onToggle:()=>void $e(O)})]})]})}),(0,W.jsx)(at,{runtime:it,restarting:ne===O.id,checking:x,showConnectionOptions:U,canManageConnection:X(O).ready&&$?.placement!==`replace-config`,ch:Y,onRestart:()=>void Ze(O),onCheck:()=>void Q(),onManageConnection:()=>se(e=>!e)}),(0,W.jsx)(ot,{entry:O,ch:Y}),st&&$?.placement!==`replace-config`?(0,W.jsx)(fe,{entry:O,locale:n,messages:Y,compact:!0,onChanged:async()=>{await j(),await Q(),await C()}},O.id):null,$?.entrypoint&&$.placement===`before-config`?(0,W.jsx)(P,{extensionId:O.extensionId,extensionName:O.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:O.id,entry:O,config:J}}):null,$?.entrypoint&&$.placement!==`before-config`?(0,W.jsx)(P,{extensionId:O.extensionId,extensionName:O.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:O.id,entry:O,config:J}}):null,rt&&we?(0,W.jsxs)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:[(0,W.jsxs)(`div`,{className:`mb-4`,children:[(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:Y.basicConfiguration}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:Y.basicConfigurationHint})]}),(0,W.jsx)(oe,{schema:ye,values:J,onChange:e=>N(e),disabled:F,labels:Be})]}):null,(0,W.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,W.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,W.jsx)(d,{className:`size-4 text-fg-muted`}),Y.messageHandling]}),(0,W.jsxs)(`div`,{className:`bg-surface-base/50 p-4`,children:[(0,W.jsxs)(`div`,{className:`mb-3`,children:[(0,W.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:Y.agentRouting}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:Y.messageHandlingHint})]}),(0,W.jsx)(a,{value:Te,options:De,placeholder:Y.agentRoutingSelect,emptyLabel:Y.agentRoutingDefault.replace(`{{agent}}`,Le||Y.agentRoutingSelect),ariaLabel:Y.agentRouting,disabled:F||!E,onChange:e=>q(e)})]})]}),rt&&qe(xe)?(0,W.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,W.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,W.jsx)(d,{className:`size-4 text-fg-muted`}),Y.advancedConfiguration]}),(0,W.jsx)(`div`,{className:`bg-surface-base/50 p-4`,children:(0,W.jsx)(oe,{schema:xe,values:J,onChange:e=>N(e),disabled:F,labels:Be})})]}):null,de?(0,W.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:de}):null]}):null})]}):(0,W.jsx)(re,{gap:`gap-3`,className:Pe,padding:Fe,children:(0,W.jsx)(`p`,{className:`text-sm text-fg-muted`,children:Y.tokenRequired})})}export{st as ChannelsSettingsPanel};
@@ -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{t as i}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{t as a}from"./check-DUBLcKHA.js";import{t as o}from"./globe-DSSGFWFn.js";import{t as s}from"./plus-Q2yW6OE7.js";import{t as c}from"./messages-CnM6Qfr7.js";import{a as l,n as u,r as d}from"./locale-store-ChN_vjs2.js";import{i as f}from"./vendor-swr-BIWyz7Rc.js";import{t as p}from"./button-CS04eWY9.js";import{r as m}from"./gateway-config-swr-EZxaKXdC.js";import{n as h,t as g}from"./registry-api-BM_81rLe.js";import{t as _}from"./skeleton-BwbyijEw.js";import{t as v}from"./electron-env-Dit0bHgy.js";import{Do as y,Hr as b,cn as x,ln as S,ns as C,rs as w,yo as ee}from"./index-BcTY7RBG.js";import{n as te,r as ne}from"./settings-page-layout-X1x-2Cp9.js";var T=n(),E=e(t(),1),D=r();function O({zh:e}){let t=c(e?`zh`:`en`).computerSettings,n=f(`settings-agent-defaults`,x),r=f(g,h),a=n.data?.defaults.models.computerUse?.primary??``,[o,s]=(0,E.useState)(a),[l,u]=(0,E.useState)(!1),[d,m]=(0,E.useState)(``),[v,y]=(0,E.useState)(!1);(0,E.useEffect)(()=>{s(a)},[a]);let C=!o||r.data?.some(e=>e.id===o&&e.computerUse),w=async()=>{u(!0),m(``),y(!1);try{if(!C)throw Error(t.modelUnavailable);let e=await x(),r={...e.defaults.models};o?r.computerUse={primary:o,fallbacks:[]}:delete r.computerUse;let i=await S({...e.defaults,models:r});await n.mutate(i,!1),y(!0)}catch(e){m(e instanceof Error?e.message:String(e))}finally{u(!1)}};return(0,D.jsxs)(`section`,{"aria-label":t.model,className:`space-y-3`,children:[(0,D.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t.model}),!n.data&&!n.error?(0,D.jsx)(_,{className:`h-52 w-full rounded-xl`}):n.error?(0,D.jsxs)(`div`,{role:`alert`,className:`text-sm text-danger`,children:[String(n.error),(0,D.jsx)(p,{onClick:()=>{n.mutate().catch(()=>{})},children:t.retry})]}):(0,D.jsxs)(`div`,{className:`rounded-2xl border border-edge bg-surface-panel p-4 sm:p-5`,children:[(0,D.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-center`,children:[(0,D.jsx)(`div`,{className:`min-w-0 flex-1`,children:r.isLoading?(0,D.jsx)(_,{className:`h-11 w-full rounded-lg`}):(0,D.jsx)(b,{value:o,onChange:e=>{s(e),y(!1)},disabled:l,capabilitiesFilter:`computer-use`,models:r.data??[],modelsError:r.error,placeholder:t.selectModel,searchPlaceholder:t.searchModel,noMatches:t.noModels,registryEmptyHint:t.noModels,allowEmpty:!0,emptyLabel:t.noModel,ariaLabel:t.modelLabel,className:`w-full`,contentAlign:`start`})}),(0,D.jsx)(p,{variant:`primary`,disabled:l||o===a||!C||!!r.error||r.isLoading,onClick:()=>{w()},children:t.saveModel})]}),(0,D.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-4 gap-y-2 text-xs text-fg-muted`,children:[(0,D.jsx)(`span`,{children:t.modelDataUse}),(0,D.jsx)(p,{asChild:!0,variant:`ghost`,className:`h-auto p-0 text-xs`,children:(0,D.jsx)(i,{to:`/settings/capabilities/models?add=1`,children:t.manageModels})}),v&&(0,D.jsx)(`span`,{role:`status`,children:t.modelSaved})]}),!C&&!r.isLoading&&!r.error&&(0,D.jsx)(`p`,{role:`status`,className:`mt-3 text-sm text-warning`,children:t.modelUnavailable}),r.error&&(0,D.jsxs)(`p`,{role:`alert`,className:`mt-3 text-sm text-danger`,children:[String(r.error),(0,D.jsx)(p,{onClick:()=>{r.mutate().catch(()=>{})},children:t.retry})]}),d&&(0,D.jsx)(`p`,{role:`alert`,className:`mt-3 text-sm text-danger`,children:d})]})]})}function k(e){let t=(0,T.c)(15),{icon:n,title:r,description:i,children:a}=e,o;t[0]===n?o=t[1]:(o=n&&(0,D.jsx)(`div`,{className:`flex size-6 shrink-0 items-center justify-center text-fg-muted`,"aria-hidden":!0,children:n}),t[0]=n,t[1]=o);let s;t[2]===r?s=t[3]:(s=(0,D.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:r}),t[2]=r,t[3]=s);let c;t[4]===i?c=t[5]:(c=i&&(0,D.jsx)(`div`,{className:`mt-0.5 text-xs text-fg-muted`,children:i}),t[4]=i,t[5]=c);let l;t[6]!==s||t[7]!==c?(l=(0,D.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[s,c]}),t[6]=s,t[7]=c,t[8]=l):l=t[8];let u;t[9]===a?u=t[10]:(u=a&&(0,D.jsx)(`div`,{className:`flex shrink-0 items-center gap-3`,children:a}),t[9]=a,t[10]=u);let d;return t[11]!==o||t[12]!==l||t[13]!==u?(d=(0,D.jsxs)(`div`,{className:`flex min-h-16 flex-wrap items-center gap-3 px-4 py-3 sm:flex-nowrap sm:px-5`,children:[o,l,u]}),t[11]=o,t[12]=l,t[13]=u,t[14]=d):d=t[14],d}function A(){let e=(0,T.c)(2),t=u(j)===`zh`,n;return e[0]===t?n=e[1]:(n=(0,D.jsx)(M,{zh:t}),e[0]=t,e[1]=n),n}function j(e){return e.language}function M({zh:e}){let t=c(e?`zh`:`en`).computerSettings,{data:n,mutate:r,error:u}=m(!0),f=n?.payload?.config,[h,g]=(0,E.useState)(!1),[b,x]=(0,E.useState)(``),[S,T]=(0,E.useState)(!1),[A,j]=(0,E.useState)(null),[M,N]=(0,E.useState)(!1),[P,F]=(0,E.useState)(null),[re,I]=(0,E.useState)(!1),[L,R]=(0,E.useState)(``),[z,B]=(0,E.useState)(!1),[ie,V]=(0,E.useState)(!1),H=window.electronAPI?.platform===`darwin`?window.electronAPI.computer:void 0,U=window.electronAPI?.platform===`darwin`?window.electronAPI.system:void 0;(0,E.useEffect)(()=>{if(!H)return;let e=!1,t=!1,n=async()=>{if(!t){t=!0;try{let t=await H.status();e||(j(t),N(!1))}catch{e||(j(null),N(!0))}finally{t=!1}}};n();let r=window.setInterval(()=>{n()},2e3);return()=>{e=!0,window.clearInterval(r)}},[H]),(0,E.useEffect)(()=>{if(!H?.access)return;let e=!1;return H.access().then(t=>{e||(F(t),I(!1))}).catch(()=>{e||I(!0)}),()=>{e=!0}},[H]);let W=async e=>{g(!0),x(``);try{await e()}catch(e){x(e instanceof Error?e.message:String(e))}finally{g(!1)}},ae=e=>W(async()=>{v()&&(await l(d(`/api/config`),{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({computer:{enabled:e}})}),await r())}),G=async()=>{x(``),T(!1);try{await H?.stop(),T(!0),H&&j(await H.status())}catch(e){x(e instanceof Error?e.message:String(e))}},K=A?.session?.status??`idle`,q=t.states[K]??K,J=v()&&f?.computer?.enabled===!0,oe=A?.controlPaused?t.pausedNotice:J?A?.connected?`${t.connected} · ${q}`:A?t.disconnected:t.checking:t.disabled,Y=!H||M||A?.reenrollmentRequired===!0||!!(A?.error||A?.session?.errorCode)||A!=null&&(!A.permissions.accessibility||A.permissions.screenRecording!==`granted`),X=A?.permissions.accessibility===!0&&A.permissions.screenRecording===`granted`&&!A.reenrollmentRequired,Z=P?.apps.filter(e=>P.authorizedAppIds.includes(e.appId))??[],Q=P?.apps.filter(e=>!P.authorizedAppIds.includes(e.appId)&&`${e.name} ${e.appId}`.toLocaleLowerCase().includes(L.toLocaleLowerCase()))??[],$=(0,D.jsxs)(`section`,{"aria-labelledby":`computer-permissions-title`,className:`space-y-3`,children:[(0,D.jsx)(`h2`,{id:`computer-permissions-title`,className:`text-sm font-semibold text-fg`,children:t.permissions}),H?M?(0,D.jsx)(`p`,{role:`alert`,className:`rounded-xl bg-danger-soft p-5 text-sm text-danger`,children:t.nativeError}):A?X&&!ie?(0,D.jsx)(`div`,{className:`overflow-hidden rounded-2xl border border-edge bg-surface-panel`,children:(0,D.jsx)(k,{icon:(0,D.jsx)(y,{className:`size-5`}),title:t.systemPermissions,description:t.granted,children:(0,D.jsx)(p,{onClick:()=>V(!0),children:t.viewDetails})})}):(0,D.jsxs)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-2xl border border-edge bg-surface-panel`,children:[(0,D.jsx)(k,{icon:(0,D.jsx)(w,{className:`size-5`}),title:t.device,description:(0,D.jsxs)(`span`,{"aria-live":`polite`,children:[A.connected?t.connected:t.disconnected,` · `,q]}),children:A.reenrollmentRequired&&(0,D.jsx)(p,{disabled:h,onClick:()=>{W(async()=>{j(await H.reenroll())})},children:t.reenroll})}),U&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(k,{icon:(0,D.jsx)(y,{className:`size-5`}),title:t.accessibility,children:[(0,D.jsx)(`span`,{className:`text-xs text-fg-muted`,children:A.permissions.accessibility?t.granted:t.notGranted}),!A.permissions.accessibility&&(0,D.jsx)(p,{disabled:h,"aria-label":`${t.openSettings}: ${t.accessibility}`,onClick:()=>{W(()=>U.requestAccessibility())},children:t.openSettings})]}),(0,D.jsxs)(k,{icon:(0,D.jsx)(w,{className:`size-5`}),title:t.screen,children:[(0,D.jsx)(`span`,{className:`text-xs text-fg-muted`,children:A.permissions.screenRecording===`granted`?t.granted:t.notGranted}),A.permissions.screenRecording!==`granted`&&(0,D.jsx)(p,{disabled:h,"aria-label":`${t.openSettings}: ${t.screen}`,onClick:()=>{W(()=>U.requestScreen())},children:t.openSettings})]})]}),X&&(0,D.jsx)(`div`,{className:`flex justify-end px-4 py-2 sm:px-5`,children:(0,D.jsx)(p,{variant:`ghost`,onClick:()=>V(!1),children:t.hideDetails})})]}):(0,D.jsx)(`div`,{"aria-label":t.checking,children:(0,D.jsx)(_,{className:`h-20 w-full rounded-xl`})}):(0,D.jsx)(`p`,{className:`rounded-xl bg-surface-hover/20 p-5 text-sm leading-relaxed text-fg-muted`,children:window.electronAPI&&window.electronAPI.platform!==`darwin`?t.unsupportedPlatform:t.desktopRequired}),(A?.error||A?.session?.errorCode)&&(0,D.jsx)(`p`,{role:`alert`,className:`break-words text-sm text-red-600`,children:A.error||A.session?.errorCode})]});return(0,D.jsxs)(ne,{gap:`gap-7`,children:[(0,D.jsx)(te,{title:t.title,subtitle:t.subtitle,meta:(0,D.jsx)(`span`,{className:`mt-3 inline-flex rounded-md border border-edge px-2 py-1 text-xs text-fg-muted`,children:t.preview}),actions:H&&(0,D.jsxs)(p,{onClick:()=>{G()},children:[(0,D.jsx)(ee,{className:`size-3.5`}),t.stop]})}),b&&(0,D.jsx)(`p`,{role:`alert`,className:`text-sm text-red-600`,children:b}),S&&(0,D.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:t.stoppedNotice}),(0,D.jsxs)(`section`,{"aria-labelledby":`computer-control-title`,className:`space-y-3`,children:[(0,D.jsx)(`h2`,{id:`computer-control-title`,className:`text-sm font-semibold text-fg`,children:t.control}),!f&&!u?(0,D.jsx)(_,{className:`h-32 w-full rounded-xl`}):u?(0,D.jsxs)(`div`,{role:`alert`,className:`text-sm text-fg-muted`,children:[String(u),` `,(0,D.jsx)(p,{onClick:()=>{W(()=>r())},children:t.retry})]}):(0,D.jsxs)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-2xl border border-edge bg-surface-panel`,children:[(0,D.jsx)(k,{icon:(0,D.jsx)(C,{className:`size-5`}),title:t.desktop,description:(0,D.jsx)(`span`,{"aria-live":`polite`,children:oe}),children:(0,D.jsx)(`button`,{type:`button`,role:`switch`,"aria-label":t.desktop,"aria-checked":J,disabled:h||!v(),onClick:()=>{ae(f?.computer?.enabled!==!0)},className:`touch-target flex items-center rounded-lg px-1 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,children:(0,D.jsx)(`span`,{className:`flex h-6 w-11 items-center rounded-full p-0.5 transition-colors ${J?`bg-accent`:`bg-fg-muted/30`}`,children:(0,D.jsx)(`span`,{className:`size-5 rounded-full bg-white transition-transform ${J?`translate-x-5`:`translate-x-0`}`})})})}),A?.controlPaused&&(0,D.jsx)(`div`,{className:`flex justify-end border-t border-edge-subtle px-4 py-3 sm:px-5`,children:(0,D.jsx)(p,{disabled:h,onClick:()=>{W(async()=>{H&&j(await H.resume()),T(!1)})},children:t.resume})})]})]}),Y&&$,H?.access&&(0,D.jsxs)(`section`,{"aria-labelledby":`computer-app-access-title`,className:`space-y-3`,children:[(0,D.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,D.jsx)(`h2`,{id:`computer-app-access-title`,className:`text-sm font-semibold text-fg`,children:t.appAccess}),!P?.allowAllApps&&(0,D.jsxs)(p,{disabled:h,"aria-expanded":z,"aria-controls":z?`computer-app-picker`:void 0,onClick:()=>{B(e=>!e),R(``)},children:[z?(0,D.jsx)(a,{className:`size-4`,"aria-hidden":!0}):(0,D.jsx)(s,{className:`size-4`,"aria-hidden":!0}),z?t.doneAdding:t.addApp]})]}),P?(0,D.jsxs)(`div`,{className:`overflow-hidden rounded-2xl border border-edge bg-surface-panel`,children:[(0,D.jsx)(k,{icon:(0,D.jsx)(C,{className:`size-5`}),title:t.anyApp,description:t.anyAppDescription,children:(0,D.jsx)(`button`,{type:`button`,role:`switch`,"aria-label":t.anyApp,"aria-checked":P.allowAllApps===!0,disabled:h,onClick:()=>{W(async()=>{F(await H.setAllAppAccess(!P.allowAllApps)),B(!1)})},className:`touch-target flex items-center rounded-lg px-1 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,children:(0,D.jsx)(`span`,{className:`flex h-6 w-11 items-center rounded-full p-0.5 transition-colors ${P.allowAllApps?`bg-accent`:`bg-fg-muted/30`}`,children:(0,D.jsx)(`span`,{className:`size-5 rounded-full bg-white transition-transform ${P.allowAllApps?`translate-x-5`:`translate-x-0`}`})})})}),!P.allowAllApps&&(0,D.jsx)(`div`,{className:`border-t border-edge-subtle`,children:Z.length?Z.map(e=>(0,D.jsxs)(`div`,{className:`flex min-h-16 items-center justify-between gap-3 border-b border-edge-subtle px-4 py-3 last:border-b-0 sm:px-5`,children:[(0,D.jsxs)(`div`,{className:`min-w-0`,children:[(0,D.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:e.name}),(0,D.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:e.appId})]}),(0,D.jsx)(p,{disabled:h,variant:`ghost`,onClick:()=>{W(async()=>{let t=await H.setAppAccess(e.appId,!1);F(e=>e&&{...e,authorizedAppIds:t.authorizedAppIds})})},children:t.revokeApp})]},e.appId)):(0,D.jsx)(`p`,{className:`px-5 py-6 text-center text-sm text-fg-muted`,children:t.noAuthorizedApps})})]}):re?(0,D.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:t.appListError}):(0,D.jsx)(_,{className:`h-20 w-full rounded-xl`}),z&&!P?.allowAllApps&&(0,D.jsxs)(`div`,{id:`computer-app-picker`,className:`space-y-3 rounded-2xl border border-edge bg-surface-panel p-4`,children:[(0,D.jsxs)(`div`,{className:`flex gap-2`,children:[(0,D.jsx)(`input`,{"aria-label":t.searchApps,value:L,onChange:e=>R(e.target.value),placeholder:t.searchApps,className:`min-w-0 flex-1 rounded-lg border border-edge bg-surface-base px-3 py-2 text-sm text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`}),(0,D.jsx)(p,{disabled:h,onClick:()=>{W(async()=>{F(await H.access()),I(!1)})},children:t.refreshApps})]}),P&&(0,D.jsx)(`div`,{className:`max-h-64 overflow-y-auto rounded-xl border border-edge`,children:Q.length?Q.map(e=>(0,D.jsxs)(`div`,{className:`flex min-h-14 items-center justify-between gap-3 border-b border-edge-subtle px-3 py-2 last:border-b-0`,children:[(0,D.jsxs)(`div`,{className:`min-w-0`,children:[(0,D.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:e.name}),(0,D.jsx)(`p`,{className:`truncate text-xs text-fg-muted`,children:e.appId})]}),(0,D.jsx)(p,{disabled:h,variant:`secondary`,onClick:()=>{W(async()=>{let t=await H.setAppAccess(e.appId,!0);F(e=>e&&{...e,authorizedAppIds:t.authorizedAppIds})})},children:t.authorizeApp})]},e.appId)):(0,D.jsx)(`p`,{className:`px-3 py-5 text-center text-sm text-fg-muted`,children:P.appsBusy?t.appsBusy:P.appsUnavailable?t.appListError:t.noMatchingApps})})]})]}),(0,D.jsx)(O,{zh:e}),!Y&&$,(0,D.jsxs)(`section`,{"aria-labelledby":`computer-browser-title`,className:`space-y-3`,children:[(0,D.jsx)(`h2`,{id:`computer-browser-title`,className:`text-sm font-semibold text-fg`,children:t.otherControl}),(0,D.jsx)(`div`,{className:`overflow-hidden rounded-2xl border border-edge bg-surface-panel`,children:(0,D.jsx)(k,{icon:(0,D.jsx)(o,{className:`size-5`}),title:t.browser,description:f?f.browser?.enabled?t.browserEnabled:t.browserDisabled:t.checking,children:(0,D.jsx)(p,{asChild:!0,children:(0,D.jsx)(i,{to:`/settings/agent-browser`,children:t.manage})})})})]}),(0,D.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.previewFootnote})]})}export{A as ComputerSettingsPage,M as ComputerSettingsPanel};