@xopcai/xopc 0.0.392 → 0.0.393

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 (422) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/telegram/xopc.extension.json +1 -1
  3. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-CZmaQbC9.js → agent-avatar-dicebear-1AF2KGju.js} +1 -1
  4. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-CPJr7NRR.js +1 -0
  5. package/dist/gateway/static/root/assets/agent-plugin-dialog-cjJXJj_3.js +1 -0
  6. package/dist/gateway/static/root/assets/agents-DW3TlnIg.js +77 -0
  7. package/dist/gateway/static/root/assets/{agents-admin-api-znm6_dW_.js → agents-admin-api-B5aykqg_.js} +1 -1
  8. package/dist/gateway/static/root/assets/app-management-settings-panel-B_MFhXXU.js +1 -0
  9. package/dist/gateway/static/root/assets/appearance-settings-TYGidVnd.js +1 -0
  10. package/dist/gateway/static/root/assets/apps-page-DOkyvOF0.js +1 -0
  11. package/dist/gateway/static/root/assets/{archive-plugin-dSkmoISk.js → archive-plugin-BrFfEp0u.js} +1 -1
  12. package/dist/gateway/static/root/assets/{automations-page-DhWRn0dZ.js → automations-page-B7OofUPF.js} +1 -1
  13. package/dist/gateway/static/root/assets/automations-workspace-DIod-bfm.js +6 -0
  14. package/dist/gateway/static/root/assets/{binary-plugins-BJlZrYym.js → binary-plugins-BfAWnYG8.js} +1 -1
  15. package/dist/gateway/static/root/assets/{block-editor-OHBssIfN.js → block-editor-_Y-QwZ-3.js} +5 -5
  16. package/dist/gateway/static/root/assets/browser-automation-inputs-DH9QHI9m.js +1 -0
  17. package/dist/gateway/static/root/assets/browser-automations-page-B_SnD9B0.js +3 -0
  18. package/dist/gateway/static/root/assets/browser-settings-page-BPlqYpMM.js +3 -0
  19. package/dist/gateway/static/root/assets/capabilities-page-BtzZvMIK.js +2 -0
  20. package/dist/gateway/static/root/assets/{capabilities-CgDteXZH.js → capabilities-pt2M56-E.js} +1 -1
  21. package/dist/gateway/static/root/assets/capabilities-settings-panel-WzoG3oBb.js +8 -0
  22. package/dist/gateway/static/root/assets/capability-header-actions-CFVx3iaZ.js +1 -0
  23. package/dist/gateway/static/root/assets/channels-BXA55GY2.js +1 -0
  24. package/dist/gateway/static/root/assets/chat-terminal-dock-D3GuiG3N.js +36 -0
  25. package/dist/gateway/static/root/assets/computer-settings-page-CIbHDlp8.js +1 -0
  26. package/dist/gateway/static/root/assets/connector-service-page-CDyCHkpK.js +1 -0
  27. package/dist/gateway/static/root/assets/connectors-page-DA2b6cJu.js +1 -0
  28. package/dist/gateway/static/root/assets/date-picker-C424c_g9.js +1 -0
  29. package/dist/gateway/static/root/assets/dependency-picker-BVJh9sYc.js +1 -0
  30. package/dist/gateway/static/root/assets/desktop-pet-Q52A8vjp.js +1 -0
  31. package/dist/gateway/static/root/assets/desktop-pet-settings-CZr1CXxu.js +1 -0
  32. package/dist/gateway/static/root/assets/desktop-pet-sprite-Bd-aOI7N.js +30 -0
  33. package/dist/gateway/static/root/assets/desktop-pet-sprite-BuB0g8zv.css +1 -0
  34. package/dist/gateway/static/root/assets/device-pairing-wizard-D_WWTsze.js +1 -0
  35. package/dist/gateway/static/root/assets/directory-picker-path-field-C6cUgrvg.js +1 -0
  36. package/dist/gateway/static/root/assets/extension-debug-page-DyyfC4gA.js +1 -0
  37. package/dist/gateway/static/root/assets/extension-page-Dho9o3ZZ.js +1 -0
  38. package/dist/gateway/static/root/assets/extension-settings-page-CdnIGyCH.js +1 -0
  39. package/dist/gateway/static/root/assets/{gateway-config-swr-BM__9Fws.js → gateway-config-swr-BEePO3Wl.js} +1 -1
  40. package/dist/gateway/static/root/assets/{gateway-realtime-DS_GDx-x.js → gateway-realtime-Dng_VOvI.js} +1 -1
  41. package/dist/gateway/static/root/assets/gateway-realtime-store-DtlBf7oH.js +1 -0
  42. package/dist/gateway/static/root/assets/gateway-settings-D0KSQRNZ.js +1 -0
  43. package/dist/gateway/static/root/assets/{gateway-startup-retry-DosoyMIH.js → gateway-startup-retry-CDCiy7Cd.js} +1 -1
  44. package/dist/gateway/static/root/assets/{highlighted-body-KQOG7T2V-BYHXWIfK.js → highlighted-body-KQOG7T2V-BNpj_mIM.js} +1 -1
  45. package/dist/gateway/static/root/assets/home-page-CH_A0W29.js +2 -0
  46. package/dist/gateway/static/root/assets/image-generation-api-DwkO2y46.js +1 -0
  47. package/dist/gateway/static/root/assets/imports-page-BrYvomnU.js +1 -0
  48. package/dist/gateway/static/root/assets/index-CKdOZoVu.js +260 -0
  49. package/dist/gateway/static/root/assets/index-Rxjt-jc3.css +1 -0
  50. package/dist/gateway/static/root/assets/keyboard-shortcuts-settings-BveDYfYk.js +1 -0
  51. package/dist/gateway/static/root/assets/local-app-workbench-page-CcIi1BhT.js +1 -0
  52. package/dist/gateway/static/root/assets/local-apps-page-B1a69mlV.js +1 -0
  53. package/dist/gateway/static/root/assets/{local-session-drafts-Bye3ZtsW.js → local-session-drafts-CYEDUPH7.js} +1 -1
  54. package/dist/gateway/static/root/assets/{locale-store-BKyOF23r.js → locale-store-CE7L6MlS.js} +1 -1
  55. package/dist/gateway/static/root/assets/logs-page-Us1jv3C4.js +2 -0
  56. package/dist/gateway/static/root/assets/management-settings-C9RAM7-s.js +1 -0
  57. package/dist/gateway/static/root/assets/{markdown-view-D_7clISS.js → markdown-view-PrKvVpRh.js} +1 -1
  58. package/dist/gateway/static/root/assets/{media-plugins-B_4o8hac.js → media-plugins-CR1fp6IL.js} +1 -1
  59. package/dist/gateway/static/root/assets/mermaid-MCJ5UELQ-DQdcaMiu.js +1 -0
  60. package/dist/gateway/static/root/assets/messages-CaeL_miw.js +3 -0
  61. package/dist/gateway/static/root/assets/note-detail-panel-Q4yRx9iZ.js +5 -0
  62. package/dist/gateway/static/root/assets/notes-page-C9qu16IN.js +8 -0
  63. package/dist/gateway/static/root/assets/page-context-capture-button-Cn_WK68Y.js +1 -0
  64. package/dist/gateway/static/root/assets/personal-page-DrP6hEcg.js +1 -0
  65. package/dist/gateway/static/root/assets/preview-open-alternatives-3NbiWGRG.js +1 -0
  66. package/dist/gateway/static/root/assets/product-open-page-KKE5-V8k.js +1 -0
  67. package/dist/gateway/static/root/assets/product-preview-content-BM0oqNxi.js +1 -0
  68. package/dist/gateway/static/root/assets/project-detail-page-CPZrwf8n.js +1 -0
  69. package/dist/gateway/static/root/assets/projects-page-Besfx_07.js +1 -0
  70. package/dist/gateway/static/root/assets/{registry-api-DLHHYP_v.js → registry-api-BO2Ck3aA.js} +1 -1
  71. package/dist/gateway/static/root/assets/remote-access-hub-CTDghL5L.js +1 -0
  72. package/dist/gateway/static/root/assets/{runtime-tools-api-Dq_50s27.js → runtime-tools-api-B1sb8nlw.js} +1 -1
  73. package/dist/gateway/static/root/assets/runtime-tools-settings-panel-W0X_Fy7b.js +1 -0
  74. package/dist/gateway/static/root/assets/schema-form-DNM2Zdyr.js +1 -0
  75. package/dist/gateway/static/root/assets/{session-api-Br11ih_M.js → session-api-CaAUJvu1.js} +1 -1
  76. package/dist/gateway/static/root/assets/session-manager-DoFTlgNz.js +16 -0
  77. package/dist/gateway/static/root/assets/sessions-page-Dxtablvd.js +1 -0
  78. package/dist/gateway/static/root/assets/settings-advanced-gate-C7zklouD.js +1 -0
  79. package/dist/gateway/static/root/assets/settings-form-section-DCSHPFAN.js +1 -0
  80. package/dist/gateway/static/root/assets/{settings-page-4odCW0_2.js → settings-page-B18UbbaJ.js} +1 -1
  81. package/dist/gateway/static/root/assets/setup-status-panel-JoSfluza.js +1 -0
  82. package/dist/gateway/static/root/assets/share-preview-page-BLnS3hoH.js +2 -0
  83. package/dist/gateway/static/root/assets/shares-settings-DcIuPJK3.js +1 -0
  84. package/dist/gateway/static/root/assets/skill-api-CcYGkRPL.js +1 -0
  85. package/dist/gateway/static/root/assets/skill-reload-api-PnUZjoPK.js +1 -0
  86. package/dist/gateway/static/root/assets/skills-page-D3JAw62U.js +2 -0
  87. package/dist/gateway/static/root/assets/style-BQqU-1pP.js +7 -0
  88. package/dist/gateway/static/root/assets/system-settings-panel-C974myUM.js +1 -0
  89. package/dist/gateway/static/root/assets/tab-completion-input-CxtEp0aP.js +1 -0
  90. package/dist/gateway/static/root/assets/task-detail-page-CiljFekC.js +2 -0
  91. package/dist/gateway/static/root/assets/{task-expandable-content-CmQt5uxa.js → task-expandable-content-DTEVoNrM.js} +1 -1
  92. package/dist/gateway/static/root/assets/tracing-settings-page-DEE75MUn.js +1 -0
  93. package/dist/gateway/static/root/assets/tunnel-api-DWyI3uA3.js +1 -0
  94. package/dist/gateway/static/root/assets/usage-page-DJYvbxk7.js +1 -0
  95. package/dist/gateway/static/root/assets/use-autosave-CY0YuljR.js +1 -0
  96. package/dist/gateway/static/root/assets/user-model-page-eHZJD6Fw.js +2 -0
  97. package/dist/gateway/static/root/assets/voice-api-key-field-BNG4ixJE.js +1 -0
  98. package/dist/gateway/static/root/assets/{voice-config-api-CmDtDA4g.js → voice-config-api-D0Wscn9W.js} +1 -1
  99. package/dist/gateway/static/root/assets/work-discovery-overlay-CohIoAre.js +1 -0
  100. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-Czfs5XFH.js → workflow-run-setup-panel-BXI8eyYh.js} +2 -2
  101. package/dist/gateway/static/root/assets/workflows-page-CVti0u-l.js +6 -0
  102. package/dist/gateway/static/root/assets/xopc-cloud-account-card-C_COnY_B.js +1 -0
  103. package/dist/gateway/static/root/index.html +19 -69
  104. package/dist/package.js +1 -1
  105. package/dist/src/agent/agent-instance-gateway.d.ts +2 -0
  106. package/dist/src/agent/agent-manager.d.ts +1 -1
  107. package/dist/src/agent/agent-manager.js +11 -20
  108. package/dist/src/agent/background-review/run-background-review.js +1 -1
  109. package/dist/src/agent/child-agent-factory.d.ts +2 -1
  110. package/dist/src/agent/child-agent-factory.js +2 -1
  111. package/dist/src/agent/coding/projectEvidence.d.ts +9 -0
  112. package/dist/src/agent/coding/projectEvidence.js +177 -0
  113. package/dist/src/agent/coding/repository-instructions.d.ts +8 -1
  114. package/dist/src/agent/coding/repository-instructions.js +9 -4
  115. package/dist/src/agent/coding/run-verification.d.ts +17 -2
  116. package/dist/src/agent/coding/run-verification.js +82 -12
  117. package/dist/src/agent/embedded/codemode-extension.js +1 -1
  118. package/dist/src/agent/embedded/execution-context.d.ts +1 -0
  119. package/dist/src/agent/embedded/execution-context.js +4 -1
  120. package/dist/src/agent/embedded/external-tool-discovery.js +1 -1
  121. package/dist/src/agent/embedded/run-for-session.js +1 -0
  122. package/dist/src/agent/embedded/run-turn.js +41 -5
  123. package/dist/src/agent/embedded/session-runner.js +1 -1
  124. package/dist/src/agent/embedded/session-tool-result-guard.js +5 -0
  125. package/dist/src/agent/embedded/types.d.ts +2 -0
  126. package/dist/src/agent/embedded/xopc-tools-bridge.js +2 -1
  127. package/dist/src/agent/external-tools/cliProvider.js +2 -2
  128. package/dist/src/agent/external-tools/composio-provider.js +2 -2
  129. package/dist/src/agent/external-tools/endpoint-provider.js +2 -2
  130. package/dist/src/agent/external-tools/extension-provider.js +1 -1
  131. package/dist/src/agent/external-tools/gateway-tools.js +1 -1
  132. package/dist/src/agent/external-tools/memory-provider.js +1 -1
  133. package/dist/src/agent/independent-execution.d.ts +2 -0
  134. package/dist/src/agent/independent-execution.js +12 -0
  135. package/dist/src/agent/memory/compaction.js +1 -1
  136. package/dist/src/agent/orchestration/delegation-scope.d.ts +1 -0
  137. package/dist/src/agent/orchestration/delegation-scope.js +4 -1
  138. package/dist/src/agent/orchestration/loop-guard.js +6 -2
  139. package/dist/src/agent/prompt/sections/agent-identity.js +4 -6
  140. package/dist/src/agent/prompt/sections/behavior.d.ts +3 -2
  141. package/dist/src/agent/prompt/sections/behavior.js +34 -27
  142. package/dist/src/agent/prompt/sections/memory-skills.d.ts +1 -1
  143. package/dist/src/agent/prompt/sections/memory-skills.js +10 -11
  144. package/dist/src/agent/prompt/sections/messaging-runtime.d.ts +3 -2
  145. package/dist/src/agent/prompt/sections/messaging-runtime.js +21 -24
  146. package/dist/src/agent/prompt/sections/response-language.js +7 -6
  147. package/dist/src/agent/prompt/sections/tooling.js +11 -10
  148. package/dist/src/agent/prompt/service-prompt-builder.js +3 -1
  149. package/dist/src/agent/prompt/system-prompt-params.d.ts +2 -1
  150. package/dist/src/agent/prompt/system-prompt-params.js +2 -0
  151. package/dist/src/agent/prompt/system-prompt.d.ts +2 -1
  152. package/dist/src/agent/prompt/system-prompt.js +21 -18
  153. package/dist/src/agent/prompt/types.d.ts +2 -0
  154. package/dist/src/agent/service/process-direct-streaming.js +1 -1
  155. package/dist/src/agent/service.js +3 -2
  156. package/dist/src/agent/skills/format-skills-prompt.js +5 -2
  157. package/dist/src/agent/skills/index.js +1 -1
  158. package/dist/src/agent/skills/managed-store.js +1 -1
  159. package/dist/src/agent/skills/skill-manage-ops.js +1 -1
  160. package/dist/src/agent/tool-manuals/xopc-use.d.ts +1 -1
  161. package/dist/src/agent/tool-manuals/xopc-use.js +5 -0
  162. package/dist/src/agent/tools/dataBatch.d.ts +1 -0
  163. package/dist/src/agent/tools/dataBatch.js +4 -1
  164. package/dist/src/agent/tools/delegate-tool.d.ts +1 -0
  165. package/dist/src/agent/tools/delegate-tool.js +1 -0
  166. package/dist/src/agent/tools/error-tracker.js +4 -2
  167. package/dist/src/agent/tools/exec-command.js +4 -3
  168. package/dist/src/agent/tools/factory.d.ts +1 -0
  169. package/dist/src/agent/tools/factory.js +20 -21
  170. package/dist/src/agent/tools/{delegation-parent-policy.d.ts → noninteractive-tool-policy.d.ts} +1 -1
  171. package/dist/src/agent/tools/{delegation-parent-policy.js → noninteractive-tool-policy.js} +4 -4
  172. package/dist/src/agent/tools/personal-read-tool.js +1 -1
  173. package/dist/src/agent/tools/personal-task-tool.js +1 -1
  174. package/dist/src/agent/tools/publish-artifacts.js +1 -1
  175. package/dist/src/agent/tools/search/cache.d.ts +3 -1
  176. package/dist/src/agent/tools/search/cache.js +4 -1
  177. package/dist/src/agent/tools/search/providers/deepseek-protocol.d.ts +9 -0
  178. package/dist/src/agent/tools/search/providers/deepseek-protocol.js +84 -0
  179. package/dist/src/agent/tools/search/providers/deepseek.d.ts +9 -0
  180. package/dist/src/agent/tools/search/providers/deepseek.js +55 -0
  181. package/dist/src/agent/tools/search/providers/xopc-cloud.d.ts +2 -1
  182. package/dist/src/agent/tools/search/providers/xopc-cloud.js +36 -1
  183. package/dist/src/agent/tools/search/registry.d.ts +1 -0
  184. package/dist/src/agent/tools/search/registry.js +32 -6
  185. package/dist/src/agent/tools/search/request-gate.d.ts +13 -0
  186. package/dist/src/agent/tools/search/request-gate.js +41 -0
  187. package/dist/src/agent/tools/search/resolve-config.js +1 -1
  188. package/dist/src/agent/tools/search/search-info.d.ts +8 -0
  189. package/dist/src/agent/tools/search/search-info.js +34 -0
  190. package/dist/src/agent/tools/search/types.d.ts +19 -1
  191. package/dist/src/agent/tools/toolExposure.d.ts +3 -0
  192. package/dist/src/agent/tools/toolExposure.js +25 -0
  193. package/dist/src/agent/tools/web.js +8 -1
  194. package/dist/src/agent/tools/xopc-use-tool.js +7 -3
  195. package/dist/src/agent/workflow/subagent-runner.d.ts +1 -0
  196. package/dist/src/agent/workflow/subagent-runner.js +3 -3
  197. package/dist/src/agent/workflow/workflow-child-tools.js +13 -8
  198. package/dist/src/agent/workspace-runtime/registry.js +1 -1
  199. package/dist/src/agent-catalog/capabilities.js +2 -2
  200. package/dist/src/automations/capabilities/drafts.js +1 -1
  201. package/dist/src/automations/service/action-executor.js +2 -2
  202. package/dist/src/bootstrap/application-state.js +1 -1
  203. package/dist/src/capabilities/runtime/dispatcher.js +1 -1
  204. package/dist/src/capabilities/runtime/product.js +1 -1
  205. package/dist/src/chat-commands/agent-edit.js +1 -1
  206. package/dist/src/cli/command-manifest.js +1 -1
  207. package/dist/src/cli/commands/agent.js +1 -1
  208. package/dist/src/cli/commands/agents.js +1 -1
  209. package/dist/src/cli/commands/models.js +1 -1
  210. package/dist/src/cli/commands/onboard/model.js +1 -1
  211. package/dist/src/cli/commands/search.d.ts +2 -2
  212. package/dist/src/cli/commands/search.js +8 -6
  213. package/dist/src/cli/utils/init-workspace-core.js +1 -1
  214. package/dist/src/computer/model-adapter.d.ts +3 -0
  215. package/dist/src/computer/model-adapter.js +120 -3
  216. package/dist/src/computer/model-policy.d.ts +1 -1
  217. package/dist/src/computer/model-policy.js +13 -6
  218. package/dist/src/computer/runtime.js +1 -0
  219. package/dist/src/config/agent-model-intents.js +1 -1
  220. package/dist/src/config/agent-profile.js +2 -2
  221. package/dist/src/config/loader.js +1 -1
  222. package/dist/src/config/models-json.d.ts +14 -8
  223. package/dist/src/config/models-json.js +3 -1
  224. package/dist/src/config/outbound-proxy.d.ts +11 -0
  225. package/dist/src/config/outbound-proxy.js +30 -0
  226. package/dist/src/config/rules.js +5 -0
  227. package/dist/src/config/schema.d.ts +29 -6
  228. package/dist/src/config/schema.js +21 -4
  229. package/dist/src/extensions/agent-plugins/validation.js +1 -1
  230. package/dist/src/gateway/agents-admin.js +2 -2
  231. package/dist/src/gateway/config-tools-web.js +15 -4
  232. package/dist/src/gateway/gateway-workflow-host.types.d.ts +3 -0
  233. package/dist/src/gateway/hono/lib/config-payload.d.ts +5 -0
  234. package/dist/src/gateway/hono/lib/config-payload.js +6 -1
  235. package/dist/src/gateway/hono/routes/config-patch/gateway.js +7 -0
  236. package/dist/src/gateway/hono/routes/config-patch/misc.js +2 -2
  237. package/dist/src/gateway/hono/routes/connectors.js +1 -1
  238. package/dist/src/gateway/hono/routes/context-sources.js +1 -1
  239. package/dist/src/gateway/hono/routes/models.js +5 -2
  240. package/dist/src/gateway/hono/routes/notes.js +2 -2
  241. package/dist/src/gateway/hono/routes/projects.js +2 -2
  242. package/dist/src/gateway/hono/routes/session-input-handler.js +1 -1
  243. package/dist/src/gateway/hono/routes/tasks.js +1 -1
  244. package/dist/src/gateway/image-generation-setup.js +1 -1
  245. package/dist/src/gateway/lock.js +1 -1
  246. package/dist/src/gateway/service/config-coordinator.d.ts +8 -3
  247. package/dist/src/gateway/service.js +5 -3
  248. package/dist/src/gateway/xopc-cloud-capability-setup.js +1 -1
  249. package/dist/src/infra/http-proxy-env.d.ts +3 -0
  250. package/dist/src/infra/http-proxy-env.js +22 -2
  251. package/dist/src/local-apps/service.js +1 -1
  252. package/dist/src/personal-agent/communication.d.ts +2 -1
  253. package/dist/src/personal-agent/communication.js +11 -2
  254. package/dist/src/personal-agent/persona.d.ts +2 -1
  255. package/dist/src/personal-agent/persona.js +3 -2
  256. package/dist/src/personal-agent/proactivity/service.js +1 -1
  257. package/dist/src/personal-agent/prompts.d.ts +2 -0
  258. package/dist/src/personal-agent/prompts.js +69 -7
  259. package/dist/src/personal-agent/reply-composer.js +2 -2
  260. package/dist/src/personal-agent/reply-style.d.ts +4 -2
  261. package/dist/src/personal-agent/reply-style.js +19 -3
  262. package/dist/src/personal-agent/request-service.js +14 -9
  263. package/dist/src/personal-agent/service.js +2 -2
  264. package/dist/src/pets/loopi-artwork.d.ts +2 -0
  265. package/dist/src/pets/loopi-artwork.js +36 -0
  266. package/dist/src/pets/pointer.d.ts +6 -0
  267. package/dist/src/pets/pointer.js +16 -0
  268. package/dist/src/project-trust/trust-store.d.ts +5 -0
  269. package/dist/src/project-trust/trust-store.js +7 -1
  270. package/dist/src/providers/index.js +3 -3
  271. package/dist/src/providers/model-catalog-persistence.js +1 -1
  272. package/dist/src/providers/model-registry.js +2 -0
  273. package/dist/src/providers/model-supplements.d.ts +0 -2
  274. package/dist/src/providers/model-supplements.js +2 -18
  275. package/dist/src/providers/xopc-cloud-credit-budget.d.ts +1 -0
  276. package/dist/src/providers/xopc-cloud-credit-budget.js +4 -1
  277. package/dist/src/routing/resolve-route.js +1 -1
  278. package/dist/src/routing/resolve-tui-session-key.js +1 -1
  279. package/dist/src/tasks/capabilities/read.js +2 -2
  280. package/dist/src/tasks/capabilities/write.js +1 -1
  281. package/dist/src/tasks/task-allocation-service.js +51 -40
  282. package/dist/src/tasks/task-application-service.js +5 -1
  283. package/dist/src/tasks/task-contract-planner.js +21 -6
  284. package/dist/src/tasks/task-handoff-service.js +1 -1
  285. package/dist/src/tasks/task-language.d.ts +2 -0
  286. package/dist/src/tasks/task-language.js +13 -2
  287. package/dist/src/tasks/task-run-coordinator.js +5 -1
  288. package/dist/src/tasks/task-run-dispatcher.js +2 -1
  289. package/dist/src/tui/backends/embedded-backend.js +2 -2
  290. package/dist/src/tui/tui.js +1 -1
  291. package/dist/src/voice/realtime/persona-context.js +1 -1
  292. package/dist/src/workflows/service/workflow-run-service.js +2 -3
  293. package/package.json +8 -4
  294. package/dist/gateway/static/root/assets/activity-YogQEteU.js +0 -1
  295. package/dist/gateway/static/root/assets/activity-store-DtTSRUyF.js +0 -1
  296. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-0GXoU7WL.js +0 -1
  297. package/dist/gateway/static/root/assets/agent-plugin-dialog-BxDqL7uc.js +0 -1
  298. package/dist/gateway/static/root/assets/agents-CYmRcXr-.js +0 -77
  299. package/dist/gateway/static/root/assets/app-chrome-BeB4KgOf.js +0 -1
  300. package/dist/gateway/static/root/assets/app-management-settings-panel-FhWeowCY.js +0 -1
  301. package/dist/gateway/static/root/assets/appearance-settings-DXin262V.js +0 -1
  302. package/dist/gateway/static/root/assets/apps-page-2M_l4Naz.js +0 -1
  303. package/dist/gateway/static/root/assets/automations-workspace-CVIWgoTx.js +0 -6
  304. package/dist/gateway/static/root/assets/browser-automation-inputs-uVEhZWHz.js +0 -1
  305. package/dist/gateway/static/root/assets/browser-automations-page-CEFnpvTO.js +0 -3
  306. package/dist/gateway/static/root/assets/browser-settings-page-sQpJic5b.js +0 -3
  307. package/dist/gateway/static/root/assets/button-aIC072nz.js +0 -1
  308. package/dist/gateway/static/root/assets/capabilities-BSB93QBR.js +0 -1
  309. package/dist/gateway/static/root/assets/capabilities-page-BKkN4sTh.js +0 -2
  310. package/dist/gateway/static/root/assets/capabilities-settings-panel-DCZTR8Hu.js +0 -8
  311. package/dist/gateway/static/root/assets/capability-header-actions-D0HwmxyW.js +0 -1
  312. package/dist/gateway/static/root/assets/channels-DRraXYSd.js +0 -1
  313. package/dist/gateway/static/root/assets/chat-terminal-dock-DpM489kK.js +0 -36
  314. package/dist/gateway/static/root/assets/chevron-left-DqFhpbvK.js +0 -1
  315. package/dist/gateway/static/root/assets/chevron-right-BweFrslA.js +0 -1
  316. package/dist/gateway/static/root/assets/circle-alert-BEjgurr2.js +0 -1
  317. package/dist/gateway/static/root/assets/circle-dashed-8qMD7gHf.js +0 -1
  318. package/dist/gateway/static/root/assets/circle-dot-BAseJTrF.js +0 -1
  319. package/dist/gateway/static/root/assets/cloud-C4-yfnnk.js +0 -1
  320. package/dist/gateway/static/root/assets/computer-settings-page-D0ir9aA1.js +0 -1
  321. package/dist/gateway/static/root/assets/connector-service-page-Y5SYaiJO.js +0 -1
  322. package/dist/gateway/static/root/assets/connectors-page-DRSbj4gn.js +0 -1
  323. package/dist/gateway/static/root/assets/copy-text-row-C7egVuKr.js +0 -1
  324. package/dist/gateway/static/root/assets/date-formatters-CUZAyDEg.js +0 -1
  325. package/dist/gateway/static/root/assets/date-picker-DyUP-8hR.js +0 -1
  326. package/dist/gateway/static/root/assets/dependency-picker-QF9qLWIG.js +0 -1
  327. package/dist/gateway/static/root/assets/desktop-pet-Qfns4SO-.js +0 -1
  328. package/dist/gateway/static/root/assets/desktop-pet-settings-CuITd-Xa.js +0 -1
  329. package/dist/gateway/static/root/assets/desktop-pet-sprite-BP6iMVw1.js +0 -1
  330. package/dist/gateway/static/root/assets/device-pairing-wizard-C8RPqM_F.js +0 -1
  331. package/dist/gateway/static/root/assets/directory-picker-path-field-DnD9eyoU.js +0 -1
  332. package/dist/gateway/static/root/assets/dist-C3DSFZCi.js +0 -1
  333. package/dist/gateway/static/root/assets/electron-env-Dit0bHgy.js +0 -1
  334. package/dist/gateway/static/root/assets/extension-debug-page-B5ikNsSj.js +0 -1
  335. package/dist/gateway/static/root/assets/extension-page-D-PBMAtT.js +0 -1
  336. package/dist/gateway/static/root/assets/extension-provider-CdlACvkE.js +0 -1
  337. package/dist/gateway/static/root/assets/extension-settings-page-BPUYMNb0.js +0 -1
  338. package/dist/gateway/static/root/assets/form-field-width-DJw_jULe.js +0 -1
  339. package/dist/gateway/static/root/assets/gateway-realtime-store-uEdmIROn.js +0 -1
  340. package/dist/gateway/static/root/assets/gateway-settings-BKj4PQs4.js +0 -1
  341. package/dist/gateway/static/root/assets/globe-DSSGFWFn.js +0 -1
  342. package/dist/gateway/static/root/assets/home-page-D1ZBF3me.js +0 -2
  343. package/dist/gateway/static/root/assets/image-generation-api-BB3D6OV1.js +0 -1
  344. package/dist/gateway/static/root/assets/imports-page-BCcWIxOO.js +0 -1
  345. package/dist/gateway/static/root/assets/index-Bo70AuAq.js +0 -260
  346. package/dist/gateway/static/root/assets/index-BxoR4_xr.css +0 -1
  347. package/dist/gateway/static/root/assets/index.module-Cd9ENXfk.js +0 -1
  348. package/dist/gateway/static/root/assets/interaction-BdhHBbYa.js +0 -1
  349. package/dist/gateway/static/root/assets/is-masked-secret-DOkL5b_X.js +0 -1
  350. package/dist/gateway/static/root/assets/keyboard-shortcuts-settings-Bc9UWPqr.js +0 -1
  351. package/dist/gateway/static/root/assets/loader-circle-CifKLtgG.js +0 -1
  352. package/dist/gateway/static/root/assets/local-app-workbench-page-jnK1j04U.js +0 -1
  353. package/dist/gateway/static/root/assets/local-apps-page-DpN8UN_Y.js +0 -1
  354. package/dist/gateway/static/root/assets/logs-page-DBR5mfxw.js +0 -2
  355. package/dist/gateway/static/root/assets/loopi-C09I2mNj.css +0 -1
  356. package/dist/gateway/static/root/assets/loopi-Djb8XU3l.js +0 -1
  357. package/dist/gateway/static/root/assets/management-settings-rs2cdb5f.js +0 -1
  358. package/dist/gateway/static/root/assets/mermaid-MCJ5UELQ-Bl4kOOZT.js +0 -1
  359. package/dist/gateway/static/root/assets/message-square-plus-XP0tGdlV.js +0 -1
  360. package/dist/gateway/static/root/assets/messages-B7VtMXec.js +0 -3
  361. package/dist/gateway/static/root/assets/mic-CuUb7zc-.js +0 -1
  362. package/dist/gateway/static/root/assets/minimize-2-DtOGrlpo.js +0 -1
  363. package/dist/gateway/static/root/assets/models-hub-cache-D0vR7vex.js +0 -1
  364. package/dist/gateway/static/root/assets/note-detail-panel-B7R-cZWE.js +0 -5
  365. package/dist/gateway/static/root/assets/notes-api-DZkezSIy.js +0 -2
  366. package/dist/gateway/static/root/assets/notes-page-DY9MNatd.js +0 -8
  367. package/dist/gateway/static/root/assets/page-context-capture-button-C-X8J1IO.js +0 -1
  368. package/dist/gateway/static/root/assets/pencil-DmIY3Oa-.js +0 -1
  369. package/dist/gateway/static/root/assets/personal-page-CIZWUoUh.js +0 -1
  370. package/dist/gateway/static/root/assets/popover-select-DGKUpVsz.js +0 -1
  371. package/dist/gateway/static/root/assets/preview-open-alternatives-BJU2fmPn.js +0 -1
  372. package/dist/gateway/static/root/assets/product-open-page-CYV_8zRl.js +0 -1
  373. package/dist/gateway/static/root/assets/product-preview-content-DfQ9h_YX.js +0 -1
  374. package/dist/gateway/static/root/assets/project-detail-page-B_fYXcAW.js +0 -1
  375. package/dist/gateway/static/root/assets/projects-page-CHdeAtpp.js +0 -1
  376. package/dist/gateway/static/root/assets/remote-access-hub-CbJWGHW_.js +0 -1
  377. package/dist/gateway/static/root/assets/rotate-ccw-JM1TBLpp.js +0 -1
  378. package/dist/gateway/static/root/assets/rotate-cw-LIg3Am9S.js +0 -1
  379. package/dist/gateway/static/root/assets/runtime-tools-settings-panel-jqYXsCuk.js +0 -1
  380. package/dist/gateway/static/root/assets/schema-form-DNXZLVqh.js +0 -1
  381. package/dist/gateway/static/root/assets/search-DA7gz22f.js +0 -1
  382. package/dist/gateway/static/root/assets/secret-input-BxWHx6J6.js +0 -1
  383. package/dist/gateway/static/root/assets/send-session-input-NpLYu1ip.js +0 -1
  384. package/dist/gateway/static/root/assets/session-manager-Bb9pevyM.js +0 -16
  385. package/dist/gateway/static/root/assets/sessions-page-DrGCnBhV.js +0 -1
  386. package/dist/gateway/static/root/assets/settings-2-D-csvaET.js +0 -1
  387. package/dist/gateway/static/root/assets/settings-advanced-gate-B61Eh7eB.js +0 -1
  388. package/dist/gateway/static/root/assets/settings-form-draft-Dy10ldo8.js +0 -1
  389. package/dist/gateway/static/root/assets/settings-form-section-num14vSv.js +0 -1
  390. package/dist/gateway/static/root/assets/settings-shell-dialog-layer-BU3UuiJr.js +0 -1
  391. package/dist/gateway/static/root/assets/setup-status-panel-DaU9o0Ll.js +0 -1
  392. package/dist/gateway/static/root/assets/share-link-dialog-BhjQPZbF.js +0 -1
  393. package/dist/gateway/static/root/assets/share-preview-page-LERhIwgz.js +0 -2
  394. package/dist/gateway/static/root/assets/shares-api-CgsiMdCX.js +0 -1
  395. package/dist/gateway/static/root/assets/shares-settings-DmvyqIyT.js +0 -1
  396. package/dist/gateway/static/root/assets/skeleton-BI5TyibZ.js +0 -1
  397. package/dist/gateway/static/root/assets/skill-api-plToSoFo.js +0 -1
  398. package/dist/gateway/static/root/assets/skill-api-utils-C7V4JVXM.js +0 -1
  399. package/dist/gateway/static/root/assets/skill-reload-api-BFw81Ar6.js +0 -1
  400. package/dist/gateway/static/root/assets/skill-wire-pattern-BPpeIcCi.js +0 -1
  401. package/dist/gateway/static/root/assets/skills-page-BLUsxGOo.js +0 -2
  402. package/dist/gateway/static/root/assets/style-1FPsMO2E.js +0 -7
  403. package/dist/gateway/static/root/assets/system-settings-panel-DL3WXRnL.js +0 -1
  404. package/dist/gateway/static/root/assets/tab-completion-input-D64VNmiA.js +0 -1
  405. package/dist/gateway/static/root/assets/task-detail-page-DWM5xGbe.js +0 -2
  406. package/dist/gateway/static/root/assets/theme-store-CPdeCbZI.js +0 -1
  407. package/dist/gateway/static/root/assets/tracing-settings-page-m51enJFx.js +0 -1
  408. package/dist/gateway/static/root/assets/tunnel-api-B5I53jzk.js +0 -1
  409. package/dist/gateway/static/root/assets/usage-page-B7qyfnMN.js +0 -1
  410. package/dist/gateway/static/root/assets/use-async-resource-GrnWNwMZ.js +0 -1
  411. package/dist/gateway/static/root/assets/use-autosave-C2__K1-y.js +0 -1
  412. package/dist/gateway/static/root/assets/use-composer-attachments-61W-5Q6m.js +0 -2
  413. package/dist/gateway/static/root/assets/use-file-preview-expanded-DZUWxdhm.js +0 -2
  414. package/dist/gateway/static/root/assets/user-model-page-DkIuYpuf.js +0 -2
  415. package/dist/gateway/static/root/assets/voice-api-key-field-DB--pFJX.js +0 -1
  416. package/dist/gateway/static/root/assets/voice-transcribe-api-Cp2uDvFO.js +0 -1
  417. package/dist/gateway/static/root/assets/work-discovery-overlay-Blwp7T-_.js +0 -1
  418. package/dist/gateway/static/root/assets/workflows-page-RN_QXcGY.js +0 -6
  419. package/dist/gateway/static/root/assets/workspace-api-lHTRLje0.js +0 -2
  420. package/dist/gateway/static/root/assets/xopc-cloud-account-card-D31rz9OQ.js +0 -1
  421. package/dist/src/agent/bootstrap/project-agents-context.d.ts +0 -2
  422. package/dist/src/agent/bootstrap/project-agents-context.js +0 -30
@@ -0,0 +1,8 @@
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{d as a,g as o,m as s,r as c,t as l}from"./chunk-KS7C4IRE-B2HK1psj.js";import{t as u}from"./circle-check-C23XjkUj.js";import{t as d}from"./external-link-DjqjBmc3.js";import{t as f}from"./eye-CABVeTq0.js";import{t as p}from"./plus-Q2yW6OE7.js";import{t as m}from"./x-B_N4OPjy.js";import{t as h}from"./messages-CaeL_miw.js";import{t as g}from"./cn-0WouolD0.js";import{a as _,c as v,i as y,n as b,r as x}from"./locale-store-CE7L6MlS.js";import{a as S,i as C,n as w,o as T,r as E,s as D,t as O}from"./dist-BGTk37IG.js";import{i as k}from"./vendor-swr-BIWyz7Rc.js";import{n as A,r as j}from"./gateway-config-swr-BEePO3Wl.js";import{n as M,t as N}from"./registry-api-BO2Ck3aA.js";import{$a as P,$i as F,At as I,Bt as L,Bu as R,Cf as z,Cn as B,Ct as V,Dl as H,Dn as U,Dt as ee,En as W,Et as te,F as ne,Fn as G,Fs as K,Ft as re,G as q,Gl as ie,Gs as ae,Gt as J,Hc as Y,Hs as oe,Ht as se,Hu as ce,I as le,Ic as X,In as ue,Is as de,Jl as fe,Js as pe,Jt as me,Kn as he,Ks as ge,Kt as _e,L as ve,Lt as ye,Ms as be,Mt as xe,Nc as Se,Nt as Ce,Nu as we,Ol as Te,Os as Ee,Ot as De,Pc as Oe,Ps as ke,Pt as Ae,Qi as je,Qs as Me,Rt as Ne,Sf as Pe,Sn as Fe,St as Ie,Tn as Le,Tt as Re,Us as ze,Ut as Be,Vt as Ve,Wd as He,Ws as Ue,Xa as We,Xt as Ge,Yt as Ke,Zl as qe,Zs as Je,_l as Ye,_s as Xe,_t as Ze,ad as Qe,af as $e,as as et,au as tt,bn as nt,bt as rt,cs as it,eo as at,fu as ot,gs as st,js as ct,jt as lt,ks as ut,kt as dt,ld as ft,ls as pt,ml as mt,nf as ht,pu as gt,qs as _t,qt as vt,rs as yt,us as Z,vt as bt,vu as xt,wn as St,wt as Ct,xn as wt,xt as Tt,yl as Et,yt as Dt,zl as Ot,zs as kt,zt as At}from"./index-CKdOZoVu.js";import{t as jt}from"./number-input-DDeqHK-G.js";import{n as Mt,r as Nt}from"./settings-page-layout-Dx5S-Msc.js";import{n as Pt,t as Ft}from"./settings-form-section-DCSHPFAN.js";import{n as It,t as Lt}from"./use-autosave-CY0YuljR.js";import{c as Rt,f as zt,i as Bt,l as Vt,n as Ht,o as Ut,r as Wt,s as Gt,t as Kt,u as qt}from"./voice-config-api-D0Wscn9W.js";import{t as Jt}from"./voice-api-key-field-BNG4ixJE.js";import{a as Yt,i as Xt,n as Zt,o as Qt,r as $t,s as en,t as tn}from"./image-generation-api-DwkO2y46.js";import{t as nn}from"./xopc-cloud-account-card-C_COnY_B.js";var rn=n(),Q=e(t(),1),$=r(),an={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 必须使用“名称: 值”格式,每行一个。`}},on=`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 sn(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 cn(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 ln({open:e,onOpenChange:t,provider:n,configured:r,language:i,onSaved:a,portalContainer:o,onPendingChange:s}){let c=an[i],[l,u]=(0,Q.useState)(``),[d,h]=(0,Q.useState)(``),[_,v]=(0,Q.useState)(``),[y,b]=(0,Q.useState)(`bearer`),[x,k]=(0,Q.useState)(`x-api-key`),[A,j]=(0,Q.useState)(``),[M,N]=(0,Q.useState)(``),[P,F]=(0,Q.useState)(``),[I,L]=(0,Q.useState)(`/images/generations`),[R,z]=(0,Q.useState)(`/images/edits`),[B,V]=(0,Q.useState)(``),[H,U]=(0,Q.useState)(``),[ee,W]=(0,Q.useState)([sn()]),[te,ne]=(0,Q.useState)(``),[G,K]=(0,Q.useState)(),[re,q]=(0,Q.useState)(!1),[ie,ae]=(0,Q.useState)(),[J,oe]=(0,Q.useState)(),[se,le]=(0,Q.useState)();(0,Q.useEffect)(()=>(s?.(!!G),()=>s?.(!1)),[G,s]),(0,Q.useEffect)(()=>{if(!e)return;let t=n?.imageGeneration;u(n?.providerId??``),h(t?.name??``),v(n?.baseUrl??``),b(t?.auth.type??`bearer`),k(t?.auth.type===`header`?t.auth.headerName:`x-api-key`),j(r?`••••••••••••`:``),N(t?.apiKeyUrl??``),F(t?.documentationUrl??``),L(t?.paths?.generations??`/images/generations`),z(t?.paths?.edits??`/images/edits`),V(t?.network?.allowedHosts.join(`
4
+ `)??``),U(Object.entries(n?.headers??{}).map(([e,t])=>`${e}: ${t}`).join(`
5
+ `)),W(t?.models.map(sn)??[sn()]),ne(t?.defaultModel??``),oe(void 0),K(void 0),q(!1),ae(void 0),le(void 0)},[r,e,n]);let X=(0,Q.useMemo)(()=>ee.filter(e=>e.id.trim()).map(e=>({value:e.id.trim(),label:e.name.trim()||e.id.trim()})),[ee]),ue=(e,t)=>{W(n=>n.map((n,r)=>r===e?{...n,...t}:n))},de=()=>{let e=l.trim(),t=ee.map(e=>({...e,id:e.id.trim(),name:e.name.trim()}));if(!e||!d.trim()||!_.trim()||t.some(e=>!e.id))throw Error(c.required);if(new Set(t.map(e=>e.id)).size!==t.length)throw Error(c.duplicateModels);let n=te||t[0]?.id;if(!n||!t.some(e=>e.id===n))throw Error(c.required);let r;try{r=cn(H)}catch{throw Error(c.invalidHeaders)}return{providerId:e,input:{baseUrl:_.trim(),...r?{headers:r}:{},imageGeneration:{api:`openai-images`,name:d.trim(),...P.trim()?{documentationUrl:P.trim()}:{},...M.trim()?{apiKeyUrl:M.trim()}:{},defaultModel:n,auth:y===`header`?{type:`header`,headerName:x.trim()}:{type:y},paths:{...I.trim()?{generations:I.trim()}:{},...R.trim()?{edits:R.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}}}))}}}},fe=async()=>{let e=de();return await Xt(e.providerId,e.input),y!==`none`&&A.trim()&&!be(A)&&await Yt(e.providerId,A.trim()),await a(e.providerId),e},pe=async()=>{K(`save`),ae(void 0),oe(void 0);try{await fe(),j(y===`none`?``:`••••••••••••`),oe(c.saved)}catch(e){ae(e instanceof Error?e.message:String(e))}finally{K(void 0)}},me=async()=>{K(`test`),ae(void 0),oe(void 0),le(void 0);try{let e=await fe();le((await Qt(e.providerId,e.input.imageGeneration.defaultModel)).images[0]?.dataUrl),oe(c.testReady)}catch(e){ae(e instanceof Error?e.message:String(e))}finally{K(void 0)}},he=async()=>{if(n){if(!re){q(!0);return}K(`delete`),ae(void 0);try{await tn(n.providerId),await a(),t(!1)}catch(e){ae(e instanceof Error?e.message:String(e))}finally{K(void 0)}}};return(0,$.jsx)(O,{open:e,onOpenChange:e=>{G||t(e)},children:(0,$.jsxs)(T,{container:o,children:[(0,$.jsx)(S,{className:g(`xopc-dialog-overlay fixed inset-0 bg-scrim`,Xe)}),(0,$.jsxs)(E,{className:g(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(88vh,760px)] w-[min(calc(100%-2rem),52rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-popover`,st),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)(D,{className:`font-semibold text-fg`,children:n?c.editTitle:c.addTitle}),(0,$.jsx)(C,{className:`mt-1 text-sm text-fg-muted`,children:c.intro})]}),(0,$.jsx)(w,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,disabled:!!G,className:`rounded-md p-1 text-fg-muted hover:bg-surface-inset hover:text-fg`,"aria-label":c.cancel,children:(0,$.jsx)(m,{className:`size-5`})})})]}),(0,$.jsxs)(`fieldset`,{disabled:!!G,className:`min-h-0 min-w-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:c.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:[c.providerId,(0,$.jsx)(`input`,{value:l,disabled:!!n,onChange:e=>u(e.target.value),placeholder:`my-image-service`,className:on}),(0,$.jsx)(`span`,{className:`mt-1 block font-normal text-fg-subtle`,children:c.providerIdHint})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.name,(0,$.jsx)(`input`,{value:d,onChange:e=>h(e.target.value),placeholder:`My Image Service`,className:on})]})]}),(0,$.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[c.baseUrl,(0,$.jsx)(`input`,{value:_,onChange:e=>v(e.target.value),placeholder:`https://api.example.com/v1`,className:on})]}),(0,$.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.auth,(0,$.jsx)(it,{value:y,options:[{value:`bearer`,label:c.bearer},{value:`header`,label:c.header},{value:`none`,label:c.none}],placeholder:c.auth,allowEmpty:!1,onChange:e=>b(e),triggerClassName:`mt-1.5`})]}),y===`header`?(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.headerName,(0,$.jsx)(`input`,{value:x,onChange:e=>k(e.target.value),className:on})]}):null]}),y===`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:c.apiKey}),M.trim()?(0,$.jsxs)(`a`,{href:M.trim(),target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent hover:underline`,children:[c.openKeyPage,(0,$.jsx)(Pe,{className:`size-3.5`})]}):null]}),(0,$.jsx)(ct,{id:`custom-image-api-key`,value:A,onChange:e=>j(be(A)?e.replace(/^•+/,``):e),labels:{show:c.show,hide:c.hide,copy:c.copy,copied:c.copied},reveal:()=>vt(l).then(e=>e.apiKey),loadFailedLabel:c.revealFailed,notInConfigFile:c.notRevealable}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:c.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:[c.apiKeyUrl,(0,$.jsx)(`input`,{value:M,onChange:e=>N(e.target.value),placeholder:`https://…`,className:on})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.docsUrl,(0,$.jsx)(`input`,{value:P,onChange:e=>F(e.target.value),placeholder:`https://…`,className:on})]})]}),(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:c.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:[c.generationsPath,(0,$.jsx)(`input`,{value:I,onChange:e=>L(e.target.value),className:on})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.editsPath,(0,$.jsx)(`input`,{value:R,onChange:e=>z(e.target.value),className:on})]})]}),(0,$.jsxs)(`label`,{className:`mt-4 block text-xs font-medium text-fg-muted`,children:[c.allowedHosts,(0,$.jsx)(`textarea`,{value:B,onChange:e=>V(e.target.value),rows:2,placeholder:`127.0.0.1
7
+ image-server.lan`,className:`mt-1.5 w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 font-mono text-xs text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`}),(0,$.jsx)(`span`,{className:`mt-1 block font-normal text-fg-subtle`,children:c.allowedHostsHint})]}),(0,$.jsxs)(`label`,{className:`mt-4 block text-xs font-medium text-fg-muted`,children:[c.staticHeaders,(0,$.jsx)(`textarea`,{value:H,onChange:e=>U(e.target.value),rows:3,className:`mt-1.5 w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 font-mono text-xs text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`}),(0,$.jsx)(`span`,{className:`mt-1 block font-normal text-fg-subtle`,children:c.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:c.models}),(0,$.jsxs)(Y,{variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,onClick:()=>W(e=>[...e,sn()]),children:[(0,$.jsx)(p,{className:`size-4`}),c.addModel]})]}),(0,$.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[c.defaultModel,(0,$.jsx)(it,{value:te||X[0]?.value||``,options:X,placeholder:c.defaultModel,allowEmpty:!1,onChange:ne,triggerClassName:`mt-1.5 max-w-sm`})]}),ee.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:[c.modelId,(0,$.jsx)(`input`,{value:e.id,onChange:e=>ue(t,{id:e.target.value}),placeholder:`image-1`,className:on})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.modelName,(0,$.jsx)(`input`,{value:e.name,onChange:e=>ue(t,{name:e.target.value}),className:on})]})]}),(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:[c.maxCount,(0,$.jsx)(`input`,{type:`number`,min:1,value:e.maxCount,onChange:e=>ue(t,{maxCount:e.target.value}),className:on})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.defaultCount,(0,$.jsx)(`input`,{type:`number`,min:1,value:e.defaultCount,onChange:e=>ue(t,{defaultCount:e.target.value}),className:on})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.defaultSize,(0,$.jsx)(`input`,{value:e.defaultSize,onChange:e=>ue(t,{defaultSize:e.target.value}),placeholder:`1024x1024`,className:on})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.format,(0,$.jsx)(it,{value:e.outputFormat,options:[{value:`png`,label:`PNG`},{value:`jpeg`,label:`JPEG`},{value:`webp`,label:`WebP`}],placeholder:c.format,allowEmpty:!0,onChange:e=>ue(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=>ue(t,{supportsSize:e.target.checked})}),c.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=>ue(t,{editEnabled:e.target.checked})}),c.edit]}),(0,$.jsxs)(`button`,{type:`button`,disabled:ee.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)(Te,{className:`size-3.5`}),c.remove]})]})]},t))]}),se?(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)(f,{className:`size-4`}),c.testReady]}),(0,$.jsx)(`img`,{src:se,alt:`Generated provider test`,className:`max-h-72 rounded-lg object-contain`})]}):null,J?(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:J}):null,ie?(0,$.jsx)(`p`,{className:`rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-600 dark:text-red-400`,children:ie}):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)(Y,{variant:`secondary`,className:`border-red-500/30 text-red-600 hover:bg-red-500/10 dark:text-red-400`,disabled:!!G,onClick:()=>void he(),children:[G===`delete`?(0,$.jsx)(ce,{className:`size-4 animate-spin`}):(0,$.jsx)(Te,{className:`size-4`}),re?c.confirmDelete:c.delete]}):null,(0,$.jsxs)(`div`,{className:`ml-auto flex gap-2`,children:[(0,$.jsx)(w,{asChild:!0,children:(0,$.jsx)(Y,{variant:`secondary`,disabled:!!G,children:c.cancel})}),(0,$.jsxs)(Y,{variant:`secondary`,disabled:!!G,onClick:()=>void me(),children:[G===`test`?(0,$.jsx)(ce,{className:`size-4 animate-spin`}):null,G===`test`?c.testing:c.test]}),(0,$.jsxs)(Y,{variant:`primary`,disabled:!!G,onClick:()=>void pe(),children:[G===`save`?(0,$.jsx)(ce,{className:`size-4 animate-spin`}):null,G===`save`?c.saving:c.save]})]})]})]})]})})}var un=`••••••••••••`,dn={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 fn(){let e=await _(x(`/api/image-generation/default`));if(!e.payload)throw Error(`Invalid default image generation response`);return e.payload}function pn(e){let t=e?.indexOf(`/`)??-1;return t>0?e.slice(0,t):void 0}function mn(e){let t=e?.indexOf(`/`)??-1;return t>0?e.slice(t+1):void 0}function hn(e){return Object.fromEntries(e.configFields.map(t=>[t.key,e.config[t.key]??(t.required?t.options?.[0]?.value??``:``)]))}function gn(e){let t=(0,rn.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)(it,{value:r,options:(n.options??[]).map(_n),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 _n(e){return{value:e.value,label:e.label}}function vn(){let e=(0,rn.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(X,{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(yn)}),(0,$.jsx)(X,{className:`h-64 rounded-xl`})]}),e[1]=n):n=e[1],n}function yn(e,t){return(0,$.jsx)(X,{className:`h-24 rounded-xl`},t)}function bn({connectOnly:e=!1,onConnected:t,onPendingChange:n}={}){let r=b(e=>e.language),a=dn[r],o=!!v(e=>e.conversationId),[s,c]=(0,Q.useState)(``),[l,d]=(0,Q.useState)(``),[f,m]=(0,Q.useState)(``),[h,g]=(0,Q.useState)({}),[y,S]=(0,Q.useState)(!1),[C,w]=(0,Q.useState)(!1),[T,E]=(0,Q.useState)(null);(0,Q.useEffect)(()=>(n?.(y||C),()=>n?.(!1)),[y,C,n]);let[D,O]=(0,Q.useState)(),[j,M]=(0,Q.useState)(!1),[N,P]=(0,Q.useState)(!1),[F,I]=(0,Q.useState)(),{data:L,isLoading:R,error:z,mutate:B}=k(o?x(`/api/image-generation/catalog`):null,$t,{revalidateOnFocus:!1}),{data:V,isLoading:H,error:U,mutate:ee}=k(o?x(`/api/image-generation/custom-providers`):null,Zt,{revalidateOnFocus:!1}),{data:W,isLoading:te,error:ne,mutate:G}=k(o?`default-image-generation`:null,fn,{revalidateOnFocus:!1});(0,Q.useEffect)(()=>{if(!L||!W)return;let e=pn(W.model?.primary),t=L.find(t=>t.id===e)??L.find(e=>e.configured)??L[0];t&&(c(t.id),d(t.id===e&&mn(W.model?.primary)||t.defaultModel),m(t.configured?un:``),g(hn(t)))},[W,L]);let K=L?.find(e=>e.id===s),re=K?K.apiKeyUrl??lt(K.id,r)[0]?.href:void 0,q=(0,Q.useMemo)(()=>(K?.models??[]).map(e=>({value:e,label:e})),[K?.models]),ae=W?.model?.primary,J=!!(K&&l&&(K.credentialMode!==`api-key`||K.configured||f.trim())&&K.configFields.every(e=>!e.required||h[e.key]?.trim()));if(!o)return(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:a.connect});if(R||H||te)return(0,$.jsx)(vn,{});if(z||U||ne||!L||!V)return(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:a.loadError});let oe=e=>{c(e.id),d(e.defaultModel),m(e.configured?un:``),g(hn(e)),O(void 0)},se=()=>{I(void 0),P(!0)},le=()=>{let e=V.find(e=>e.providerId===K?.id);e&&(I(e),P(!0))},X=async n=>{let[r,i]=await Promise.all([ee(),B()]);if(n&&i?.some(e=>e.id===n)){let a=i.find(e=>e.id===n);c(a.id),d(a.defaultModel),m(a.configured?un:``),g(hn(a)),I(r?.find(e=>e.providerId===n)),e&&a.configured&&t?.()}},ue=async()=>{if(!(!K||!J)){S(!0),O(void 0),M(!1);try{if(e){f.trim()&&!be(f)&&await Yt(K.id,f.trim()),Object.keys(h).length&&await _(x(`/api/config`),{method:`PATCH`,body:JSON.stringify({providersConfig:{[K.id]:h}})});let[e]=await Promise.all([B(),A()]);if(!e?.find(e=>e.id===K.id)?.configured)throw Error(r===`zh`?`连接尚未就绪,请先完成对应服务的授权或凭据设置。`:`Connection is not ready. Complete authorization or credentials first.`);M(!0),t?.();return}let n=await _(x(`/api/image-generation/default/setup`),{method:`POST`,body:JSON.stringify({providerId:K.id,modelId:l,...f.trim()&&!be(f)?{apiKey:f.trim()}:{},providerConfig:Object.fromEntries(Object.entries(h).filter(([,e])=>e.trim()))})});if(!n.payload)throw Error(`Invalid setup response`);await Promise.all([G(n.payload.default,{revalidate:!1}),B(n.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`)])),A()]),m(un),M(!0)}catch(e){O(e instanceof Error?e.message:String(e))}finally{S(!1)}}};return(0,$.jsxs)(`div`,{ref:E,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)(ft,{className:`size-5`})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.title}),(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:e?r===`zh`?`连接图片来源,不修改默认模型,也不发送生成测试请求。`:`Connect image sources without changing defaults or sending generation tests.`:a.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:a.provider}),(0,$.jsxs)(Y,{variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,onClick:se,children:[(0,$.jsx)(p,{className:`size-4`}),a.addService]})]}),(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:L.map(e=>{let t=e.id===s,n=e.id===pn(ae);return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>oe(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 ${t?`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:a.custom}):null]}),(0,$.jsx)(`span`,{"aria-hidden":!n,className:`shrink-0 rounded-full bg-accent/10 px-2 py-0.5 text-[11px] font-medium text-accent ${n?``:`invisible`}`,children:a.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)(u,{className:`size-3.5`}):(0,$.jsx)(Qe,{className:`size-3.5`}),e.configured||e.credentialMode!==`api-key`?a.configured:a.needsKey]})]},e.id)})})]}),K?(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:[e?null:(0,$.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[a.model,(0,$.jsx)(it,{value:l,options:q,placeholder:a.selectModel,allowEmpty:!1,onChange:d,triggerClassName:`mt-1.5`})]}),K.configFields.filter(e=>e.required).map(e=>(0,$.jsx)(gn,{field:e,value:h[e.key]??``,onChange:t=>g(n=>({...n,[e.key]:t}))},e.key))]}),K.source===`custom`?(0,$.jsx)(`div`,{className:`mt-4 flex justify-end`,children:(0,$.jsxs)(Y,{variant:`secondary`,onClick:le,children:[(0,$.jsx)(qe,{className:`size-4`}),a.manageService]})}):null,K.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:a.apiKey}),re?(0,$.jsxs)(`a`,{href:re,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs font-medium text-accent hover:underline`,children:[a.getApiKey,(0,$.jsx)(Pe,{className:`size-3.5`,"aria-hidden":`true`})]}):null]}),(0,$.jsx)(ct,{id:`image-generation-api-key`,value:f,onChange:e=>m(be(f)?e.replace(/^•+/,``):e),placeholder:K.configured?a.existingKey:a.needsKey,labels:{show:a.show,hide:a.hide,copy:a.copy,copied:a.copied},reveal:()=>vt(K.id).then(e=>e.apiKey),loadFailedLabel:a.revealFailed,notInConfigFile:a.keyNotRevealable,className:`mt-1.5`,autoComplete:`new-password`},K.id),(0,$.jsx)(`span`,{className:`mt-1.5 block font-normal leading-relaxed text-fg-subtle`,children:K.configured?a.savedKey:a.apiKeyHint})]}):null,K.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)(ie,{className:`size-4`}),a.advanced]}),(0,$.jsx)(`div`,{className:`mt-3 grid gap-3 md:grid-cols-2`,children:K.configFields.filter(e=>!e.required).map(e=>(0,$.jsx)(gn,{field:e,value:h[e.key]??``,onChange:t=>g(n=>({...n,[e.key]:t}))},e.key))})]}):null,j?(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:e?r===`zh`?`连接已保存`:`Connection saved`:a.enabled}):null,D?(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:D}):null,(0,$.jsx)(`div`,{className:`mt-4 flex justify-end`,children:(0,$.jsxs)(Y,{variant:`primary`,disabled:!J||y,onClick:()=>void ue(),children:[y?(0,$.jsx)(ce,{className:`size-4 animate-spin`}):(0,$.jsx)(u,{className:`size-4`}),(0,$.jsxs)(`span`,{className:`grid`,children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`invisible col-start-1 row-start-1`,children:a.enable}),(0,$.jsx)(`span`,{"aria-hidden":!0,className:`invisible col-start-1 row-start-1`,children:a.enabling}),(0,$.jsx)(`span`,{className:`col-start-1 row-start-1`,children:e?y?r===`zh`?`保存中…`:`Saving…`:r===`zh`?`保存图片连接`:`Save image connection`:y?a.enabling:a.enable})]})]})})]}):null,(0,$.jsx)(ln,{portalContainer:T?.closest(`[role="dialog"]`),onPendingChange:w,open:N,onOpenChange:P,provider:F,configured:!!(F&&L.find(e=>e.id===F.providerId)?.configured),language:r,onSaved:X})]})}function xn({disabled:e=!1,modes:t,onPendingChange:n}){let r=b(e=>e.language),i=r===`zh`,[a,o]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>(n?.(a),()=>n?.(!1)),[a,n]);let[s,c]=(0,Q.useState)(``),{data:l,mutate:u,error:d}=k(x(`/api/voice/catalog`),async e=>{let t=await _(e);return _t.parse(t.payload)}),f=i?{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`},p=async e=>{if(l){o(!0),c(``);try{let t=await _(x(e?`/api/voice/selection`:`/api/voice/catalog/refresh`),{method:e?`PUT`:`POST`,...e?{body:JSON.stringify({revision:l.revision,selection:e})}:{}});await u(_t.parse(t.payload),!1),await A()}catch(e){c(e instanceof Error?e.message:String(e)),await u()}finally{o(!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:i?`XOPC 托管语音模型`:`XOPC managed voice models`}),(0,$.jsx)(Y,{variant:`secondary`,disabled:a||e||!l,onClick:()=>void p(),children:i?`刷新目录`:`Refresh catalog`})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i?`修改在下次调用生效。各设备共用此 Gateway 的配置。`:`Changes apply to the next call and are shared across devices.`}),s||d?(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-red-600`,children:s||String(d)}):null,l?(0,$.jsx)($.Fragment,{children:t.map(t=>{let n=l.selections.find(e=>e.mode===t),o=l.models.filter(e=>e.voice.modes.includes(t)),s=o.find(e=>e.id===n?.model),c=s?.voice.voices.filter(e=>pe(e,t))??[],u=n?.voice??c.find(e=>e.id===s?.voice.defaultVoice)?.id??c[0]?.id??``;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:f[t]}),(0,$.jsxs)(pt,{className:`w-full`,value:n?.model??``,disabled:a||e||!o.length,onChange:e=>void p({mode:t,model:e.target.value}),children:[(0,$.jsx)(Z,{value:``,disabled:!0,children:i?`选择模型`:`Choose model`}),n&&!s?(0,$.jsxs)(Z,{value:n.model,disabled:!0,children:[n.model,` · `,i?`不可用`:`Unavailable`]}):null,o.map(e=>(0,$.jsx)(Z,{value:e.id,children:F(e,r)},e.id))]}),o.length?null:(0,$.jsx)(`span`,{className:`text-xs text-fg-muted`,children:i?`暂无可用模型`:`No available model`})]}),s&&c.length>0?(0,$.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[(0,$.jsx)(`span`,{children:i?`音色`:`Voice`}),(0,$.jsxs)(pt,{className:`w-full`,value:u,disabled:a||e,onChange:e=>void p({mode:t,model:s.id,voice:e.target.value}),children:[n?.voice&&!c.some(e=>e.id===n.voice)?(0,$.jsxs)(Z,{value:n.voice,disabled:!0,children:[n.voice,` · `,i?`当前场景不可用`:`Unavailable for this mode`]}):null,c.map(e=>(0,$.jsxs)(Z,{value:e.id,children:[F(e,r),e.gender?` · ${i?e.gender===`female`?`女声`:`男声`:e.gender}`:``,e.style?` · ${e.style}`:``]},e.id))]}),c.find(e=>e.id===u)?.description?(0,$.jsx)(`span`,{className:`block text-xs text-fg-muted`,children:c.find(e=>e.id===u)?.description}):null]}):null]},t)})}):(0,$.jsx)(X,{className:`h-48 w-full`})]})}function Sn({v:e}){let t=Je(e=>e.microphoneId),n=Je(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)(pt,{value:t,onChange:e=>n(e.target.value),children:[(0,$.jsx)(Z,{value:``,children:e.experience.systemDevice}),t&&!r.some(e=>e.deviceId===t)?(0,$.jsx)(Z,{value:t,children:e.experience.unavailable}):null,r.filter(e=>e.deviceId&&e.deviceId!=="default").map((t,n)=>(0,$.jsx)(Z,{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)(Y,{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]})}var Cn=(0,Q.createContext)(null);function wn(e){let t=(0,rn.c)(18),n,r;t[0]===e?(n=t[1],r=t[2]):({to:r,...n}=e,t[0]=e,t[1]=n,t[2]=r);let[i]=o(),a=(0,Q.useContext)(Cn),s,c;t[3]===r?(s=t[4],c=t[5]):(s=new URLSearchParams(r.split(`?`)[1]??``),c=B(s.get(`configure`)),t[3]=r,t[4]=s,t[5]=c);let u=c,d;t[6]!==a||t[7]!==n||t[8]!==s||t[9]!==u?(d=e=>{n.onClick?.(e),!e.defaultPrevented&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&e.button===0&&a&&u&&s.get(`tab`)===`services`&&(e.preventDefault(),a(u))},t[6]=a,t[7]=n,t[8]=s,t[9]=u,t[10]=d):d=t[10];let f;t[11]!==i||t[12]!==r?(f=St(r,i),t[11]=i,t[12]=r,t[13]=f):f=t[13];let p;return t[14]!==n||t[15]!==d||t[16]!==f?(p=(0,$.jsx)(l,{...n,onClick:d,to:f}),t[14]=n,t[15]=d,t[16]=f,t[17]=p):p=t[17],p}function Tn(e){let t=(0,rn.c)(19),{zh:n}=e,{data:r,error:i,mutate:a}=k(`voice-dictation-route`,En),o,s;t[0]===a?(o=t[1],s=t[2]):(o=()=>{let e=()=>{a()};return window.addEventListener(`voice-config-changed`,e),window.addEventListener(`config-reload`,e),()=>{window.removeEventListener(`voice-config-changed`,e),window.removeEventListener(`config-reload`,e)}},s=[a],t[0]=a,t[1]=o,t[2]=s),(0,Q.useEffect)(o,s);let c=n?`同时用于聊天听写`:`Also used for chat dictation`,l;t[3]===c?l=t[4]:(l=(0,$.jsx)(`h2`,{className:`font-medium text-fg`,children:c}),t[3]=c,t[4]=l);let u=n?`默认与录音识别共用模型。已有的独立听写设置会保留。`:`Dictation shares this recognition model. Existing separate dictation settings are preserved.`,d;t[5]===u?d=t[6]:(d=(0,$.jsx)(`p`,{className:`text-fg-muted`,children:u}),t[5]=u,t[6]=d);let f;t[7]!==r||t[8]!==i||t[9]!==n?(f=!r&&!i?(0,$.jsx)(X,{className:`h-5 w-64 max-w-full`}):(0,$.jsx)(`p`,{role:i?`alert`:`status`,className:`text-fg-muted`,children:i?n?`暂时无法读取听写状态。`:`Dictation status could not be loaded.`:r?.mode===`recorded`?n?`当前使用 ${r.provider},点击完成后转为文字。`:`Using ${r.provider}. Choose Finish to transcribe.`:r?.mode===`streaming`?n?`当前使用流式识别${r.provider?` · ${r.provider}`:``}。`:`Using streaming recognition${r.provider?` · ${r.provider}`:``}.`:n?`听写未就绪,请检查识别模型或已有的流式配置。`:`Check the recognition model or existing streaming configuration.`}),t[7]=r,t[8]=i,t[9]=n,t[10]=f):f=t[10];let p;t[11]!==r?.mode||t[12]!==n?(p=r?.mode===`recorded`?null:(0,$.jsx)(wn,{className:`inline-block text-accent-fg hover:underline`,to:`/settings/capabilities/models?tab=services&configure=transcription`,children:n?`管理识别服务`:`Manage recognition services`}),t[11]=r?.mode,t[12]=n,t[13]=p):p=t[13];let m;return t[14]!==l||t[15]!==d||t[16]!==f||t[17]!==p?(m=(0,$.jsxs)(`section`,{className:`space-y-2 rounded-xl border border-edge p-4 text-sm`,children:[l,d,f,p]}),t[14]=l,t[15]=d,t[16]=f,t[17]=p,t[18]=m):m=t[18],m}function En(){return oe(AbortSignal.timeout(15e3))}function Dn({v:e,canListen:t,canSpeak:n,disabled:r,onVerified:i}){let a=e.setup,o=(0,Q.useContext)(kt)?.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 Vt(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 ae,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:Me()}),t.signal.aborted){l();return}if(s=await ge.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 ze.start(r,{onSamples:e=>{f&&!t.signal.aborted&&s?.sendAudio(f.push(e))}}),t.signal.aborted){l();return}f=new Ue(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)(Y,{type:`button`,variant:`primary`,disabled:o||r||!t||y,onClick:()=>void v(!0),children:[y?(0,$.jsx)(ce,{className:`size-4 animate-spin`}):(0,$.jsx)(we,{className:`size-4`}),n?a.test:a.testInput]}),(0,$.jsxs)(Y,{type:`button`,variant:`secondary`,disabled:o||r||!n||y,onClick:()=>void v(!1),children:[(0,$.jsx)(gt,{className:`size-4`}),e.tts.test.play]}),y?(0,$.jsxs)(Y,{type:`button`,variant:`ghost`,onClick:()=>{_(),g(`idle`)},children:[(0,$.jsx)(Ot,{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)(Y,{type:`button`,variant:`secondary`,onClick:()=>{_(),i?.({input:h.current,output:!0}),g(`passed`)},children:a.heard}),(0,$.jsx)(Y,{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 On(e){let t=(0,rn.c)(78),{section:n,v:r,form:i,pending:a,onChange:o}=e,s=b(Nn),c=r.setup,l;t[0]===i?l=t[1]:(l=JSON.stringify(i),t[0]=i,t[1]=l);let u=l,d;t[2]===u?d=t[3]:(d={signature:u,input:!1,output:!1},t[2]=u,t[3]=d);let[f,p]=(0,Q.useState)(d);f.signature!==u&&p({signature:u,input:!1,output:!1});let m;t[4]!==a||t[5]!==u?(m=a?null:[`voice-realtime-status`,u],t[4]=a,t[5]=u,t[6]=m):m=t[6];let h;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(h={revalidateOnFocus:!0},t[7]=h):h=t[7];let{data:g,error:_,isLoading:v}=k(m,Kt,h),y;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(y=x(`/api/voice/catalog`),t[8]=y):y=t[8];let{data:S}=k(y,Mn),C=i.voice.realtime,w=C.tts,T=w?.provider??g?.tts?.provider,E=g?.tts?.model,D;t[9]!==E||t[10]!==T?(D=T&&E?[`realtime-voices`,T,E]:null,t[9]=E,t[10]=T,t[11]=D):D=t[11];let O;t[12]!==E||t[13]!==T?(O=()=>Ht(T,E,`realtime`),t[12]=E,t[13]=T,t[14]=O):O=t[14];let A;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(A={revalidateOnFocus:!1},t[15]=A):A=t[15];let{data:j}=k(D,O,A),M;t[16]===j?M=t[17]:(M=j===void 0?[]:j,t[16]=j,t[17]=M);let N=M,P=N,I;t[18]===N?I=t[19]:(I=N.filter(jn),t[18]=N,t[19]=I);let L=I,R=C.defaultEngine===`omni`,z=R?C.omni?.voice??``:w?.voice??``,B;t[20]!==S?.models||t[21]!==R||t[22]!==L||t[23]!==C.omni||t[24]!==P?(B=R&&C.omni?.provider===`qwen-token-plan-cn`?[{id:C.omni.voice,name:C.omni.voice}]:R?C.omni?.provider===`xopc-cloud`?S?.models.find(e=>e.id===C.omni?.model)?.voice.voices.filter(An)??[]:L.length?L:[`Cherry`,`Ethan`,`Serena`,`Chelsie`].map(kn):P,t[20]=S?.models,t[21]=R,t[22]=L,t[23]=C.omni,t[24]=P,t[25]=B):B=t[25];let V=B,H=!!(g?.enabled&&g.stt),U=!!(g?.enabled&&g.tts),ee;t[26]!==i||t[27]!==o||t[28]!==C?(ee=e=>o({...i,voice:{...i.voice,realtime:{...C,...e}}}),t[26]=i,t[27]=o,t[28]=C,t[29]=ee):ee=t[29];let W=ee,te;t[30]!==a||t[31]!==C.enabled||t[32]!==c.disabled||t[33]!==c.needsSetup||t[34]!==c.pending||t[35]!==c.unverified||t[36]!==c.verified||t[37]!==u||t[38]!==f.signature?(te=(e,t)=>C.enabled?a?c.pending:e?t&&f.signature===u?c.verified:c.unverified:c.needsSetup:c.disabled,t[30]=a,t[31]=C.enabled,t[32]=c.disabled,t[33]=c.needsSetup,t[34]=c.pending,t[35]=c.unverified,t[36]=c.verified,t[37]=u,t[38]=f.signature,t[39]=te):te=t[39];let ne=te,G;t[40]!==z||t[41]!==s||t[42]!==R||t[43]!==T||t[44]!==C.bargeIn||t[45]!==C.defaultEngine||t[46]!==C.enabled||t[47]!==C.omni||t[48]!==C.tts||t[49]!==c.bargeIn||t[50]!==c.defaultVoice||t[51]!==c.enable||t[52]!==c.voice||t[53]!==n||t[54]!==w||t[55]!==g?.tts||t[56]!==W||t[57]!==r.experience||t[58]!==r.realtime||t[59]!==V?(G=n===`listening`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-sm font-medium text-fg`,children:[(0,$.jsx)(`span`,{children:c.enable}),(0,$.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":C.enabled,className:`ui-checkbox`,checked:C.enabled,onChange:e=>W({enabled:e.target.checked})})]}),(0,$.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[(0,$.jsx)(`span`,{children:r.experience.defaultMode}),(0,$.jsxs)(pt,{value:C.defaultEngine,className:K,onChange:e=>W({defaultEngine:e.target.value}),children:[(0,$.jsx)(Z,{value:`agent`,children:r.experience.assistant}),(0,$.jsx)(Z,{value:`omni`,children:r.experience.natural})]})]}),(0,$.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[C.defaultEngine===`agent`?r.experience.assistantHint:r.experience.naturalHint,` `,r.experience.nextCall]}),(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:c.voice}),(0,$.jsxs)(pt,{id:`realtime-voice`,className:`${K} w-full sm:w-56`,value:z,disabled:R?!C.omni:!w&&!g?.tts,onChange:e=>{if(R&&C.omni){W({omni:{...C.omni,voice:e.target.value}});return}if(T===`alibaba`||T===`xopc-cloud`){let t={...C.tts,provider:T};e.target.value?t.voice=e.target.value:delete t.voice,W({tts:t})}},children:[R?null:(0,$.jsx)(Z,{value:``,children:c.defaultVoice}),z&&!V.some(e=>e.id===z)?(0,$.jsx)(Z,{value:z,children:z}):null,V.map(e=>(0,$.jsxs)(Z,{value:e.id,children:[F(e,s),`gender`in e&&e.gender?` · ${e.gender===`female`?`女声`:`男声`}`:``,`style`in e&&e.style?` · ${e.style}`:``]},e.id))]}),(()=>{let e=V.find(e=>e.id===z);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:[c.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":C.bargeIn,checked:C.bargeIn,className:`size-4 accent-accent`,onChange:e=>W({bargeIn:e.target.checked})})]})]}):null,t[40]=z,t[41]=s,t[42]=R,t[43]=T,t[44]=C.bargeIn,t[45]=C.defaultEngine,t[46]=C.enabled,t[47]=C.omni,t[48]=C.tts,t[49]=c.bargeIn,t[50]=c.defaultVoice,t[51]=c.enable,t[52]=c.voice,t[53]=n,t[54]=w,t[55]=g?.tts,t[56]=W,t[57]=r.experience,t[58]=r.realtime,t[59]=V,t[60]=G):G=t[60];let re;t[61]!==H||t[62]!==U||t[63]!==_||t[64]!==v||t[65]!==a||t[66]!==n||t[67]!==u||t[68]!==g||t[69]!==ne||t[70]!==r||t[71]!==f.input||t[72]!==f.output?(re=n===`diagnostics`?(0,$.jsxs)($.Fragment,{children:[v?(0,$.jsx)(X,{className:`h-16 w-full`}):(0,$.jsxs)(`div`,{className:`space-y-2 text-sm`,role:`status`,children:[(0,$.jsxs)(`p`,{children:[r.experience.dictationReady,` · `,ne(H,f.input)]}),(0,$.jsxs)(`p`,{children:[r.experience.agentReady,` · `,ne(H&&U,f.input&&f.output)]}),(0,$.jsxs)(`p`,{children:[r.experience.omniReady,` · `,ne(!!(g?.enabled&&g.omni),!1)]})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:r.experience.configurationOnly}),(0,$.jsx)(Dn,{v:r,canListen:H,canSpeak:U,disabled:a||v||!!_,onVerified:e=>p({signature:u,...e})},`${u}:${JSON.stringify(g)}`)]}):null,t[61]=H,t[62]=U,t[63]=_,t[64]=v,t[65]=a,t[66]=n,t[67]=u,t[68]=g,t[69]=ne,t[70]=r,t[71]=f.input,t[72]=f.output,t[73]=re):re=t[73];let q;return t[74]!==c.service||t[75]!==G||t[76]!==re?(q=(0,$.jsxs)(`section`,{className:`space-y-5 rounded-xl bg-surface-hover/20 p-4 sm:p-5`,"aria-label":c.service,children:[G,re]}),t[74]=c.service,t[75]=G,t[76]=re,t[77]=q):q=t[77],q}function kn(e){return{id:e,name:e}}function An(e){return pe(e,`conversation`)}function jn(e){return[`Cherry`,`Ethan`,`Serena`,`Chelsie`].includes(e.id)}async function Mn(e){return _t.parse((await _(e)).payload)}function Nn(e){return e.language}function Pn(e){let t=(0,rn.c)(19),{value:n,onChange:r}=e,i=b(Fn)===`zh`,a=i?`通话指令`:`Conversation instructions`,o;t[0]===a?o=t[1]:(o=(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:a}),t[0]=a,t[1]=o);let s=i?`通话会接续当前会话。可在这里调整语气与回答方式。`:`Calls continue the current conversation. Adjust tone and response style here.`,c;t[2]===s?c=t[3]:(c=(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:s}),t[2]=s,t[3]=c);let l=i?`通话指令`:`Conversation instructions`,u;t[4]===l?u=t[5]:(u=(0,$.jsx)(`span`,{children:l}),t[4]=l,t[5]=u);let d;t[6]!==r||t[7]!==n?(d=e=>r({...n,instructions:e.target.value}),t[6]=r,t[7]=n,t[8]=d):d=t[8];let f;t[9]!==d||t[10]!==n.instructions?(f=(0,$.jsx)(`textarea`,{className:`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,rows:3,maxLength:8e3,value:n.instructions,onChange:d}),t[9]=d,t[10]=n.instructions,t[11]=f):f=t[11];let p;t[12]!==u||t[13]!==f?(p=(0,$.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[u,f]}),t[12]=u,t[13]=f,t[14]=p):p=t[14];let m;return t[15]!==o||t[16]!==c||t[17]!==p?(m=(0,$.jsxs)(`details`,{className:`space-y-3 rounded-xl bg-surface-hover/20 p-4`,children:[o,c,p]}),t[15]=o,t[16]=c,t[17]=p,t[18]=m):m=t[18],m}function Fn(e){return e.language}var In=ke;function Ln(){return g(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,de,`dark:border-edge`)}function Rn(){return g(K,ke)}function zn(e){return!e||e<=0?``:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function Bn(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`xopc-cloud`:return t.setup.hosted;case`openai`:return t.stt.openai;case`alibaba`:return t.stt.alibaba;case`groq`:return`Groq`;default:return e}}function Hn(e,t){switch(e){case`xopc-cloud`:return t.setup.hosted;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 Un(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 Wn(e){return{maskedHelp:e.apiKeyMaskedHelp,copy:e.apiKeyCopy,copied:e.apiKeyCopied,show:e.apiKeyShow,hide:e.apiKeyHide,notInConfigFile:e.apiKeyNotInConfigFile,loadFailed:e.apiKeyRevealFailed}}function Gn(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 Kn(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 qn(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 Jn(e){let t=(0,rn.c)(4),[n,r]=(0,Q.useState)(0),i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=()=>r(Yn),t[0]=i):i=t[0];let a;return t[1]!==n||t[2]!==e?(a=(0,$.jsx)(Xn,{...e,onReload:i},n),t[1]=n,t[2]=e,t[3]=a):a=t[3],a}function Yn(e){return e+1}function Xn({capability:e,onPendingChange:t,disabled:n=!1,onReload:r}){let i=b(e=>e.language),a=h(i).voiceSettings,o=Je(e=>e.captions),s=Je(e=>e.setCaptions),c=!!v(e=>e.conversationId),[l,u]=(0,Q.useState)(!1),[d,f]=(0,Q.useReducer)(qn,{form:null,baseline:null}),p=d.form,m=d.baseline,[g,_]=(0,Q.useState)(null),y=(0,Q.useRef)(!1),S=(0,Q.useRef)({}),C=(0,Q.useRef)(p);C.current=p;let w=(0,Q.useRef)({parsed:null,models:void 0}),{data:T,error:E,isLoading:D,mutate:O}=j(c),{data:A,error:M,isLoading:N,mutate:P}=k(c?x(`/api/voice/models`):null,Wt,{revalidateOnFocus:!1}),{data:F,error:I,isLoading:L}=k(c?x(`/api/voice/providers`):null,Bt,{revalidateOnFocus:!1}),{data:R,error:z,isLoading:B}=k(c?x(`/api/voice/stt-providers`):null,Ut,{revalidateOnFocus:!1}),V=(0,Q.useMemo)(()=>F?.providers??[],[F]),H=(0,Q.useMemo)(()=>R?.providers??[],[R]),ee=(0,Q.useMemo)(()=>T?.payload?.config===void 0?null:Gt(T.payload.config),[T]),W=(0,Q.useMemo)(()=>!p||!m?!1:JSON.stringify(p)!==JSON.stringify(m),[p,m]);c?ee!==null&&A!==void 0&&!y.current&&(w.current.parsed!==ee||w.current.models!==A)&&(w.current={parsed:ee,models:A},S.current=qt(T?.payload?.config),f({type:`sync`,value:ee}),_(A)):(w.current.parsed!==null||w.current.models!==void 0)&&(w.current={parsed:null,models:void 0},f({type:`reset`}),_(null),y.current=!1);let te=!!(c&&(ee===null||A===void 0||F===void 0||R===void 0)&&(D||N||L||B)),ne=E instanceof Error?E.message:E?String(E):M instanceof Error?M.message:M?String(M):I instanceof Error?I.message:I?String(I):z instanceof Error?z.message:z?String(z):null,G=(0,Q.useCallback)(e=>{y.current=!0,f({type:`update`,updater:t=>t?{...t,stt:{...t.stt,...e},...e.provider&&e.provider!==`xopc-cloud`?{voice:{...t.voice,realtime:{...t.voice.realtime,stt:void 0}}}:{}}:null})},[]),K=(0,Q.useCallback)(e=>{y.current=!0,f({type:`update`,updater:t=>{if(!t)return null;let n=t.stt.fallback??{enabled:!1,order:[]};return{...t,stt:{...t.stt,fallback:{...n,...e}}}}})},[]),re=(0,Q.useCallback)(e=>{y.current=!0,f({type:`update`,updater:t=>t?{...t,voice:{...t.voice,input:{...t.voice.input,refinement:{...t.voice.input.refinement,...e}}}}:null})},[]),q=(0,Q.useCallback)(e=>{y.current=!0,f({type:`update`,updater:t=>t?{...t,voice:{...t.voice,languageMode:e,...e===`auto`?{language:i}:{}}}:null})},[i]),ie=(0,Q.useCallback)(e=>{y.current=!0,f({type:`update`,updater:t=>t?{...t,voice:{...t.voice,realtime:{...t.voice.realtime,...e}}}:null})},[]),ae=(0,Q.useCallback)(e=>{y.current=!0,f({type:`update`,updater:t=>t?{...t,tts:{...t.tts,...e}}:null})},[]),J=Lt({value:p,dirty:W,onSave:(0,Q.useCallback)(async t=>{try{let n=await Rt(t,e,S.current[e]);S.current={...S.current,...n},f({type:`saved`,value:t}),y.current=!!(C.current&&JSON.stringify(C.current)!==JSON.stringify(t))}catch(e){throw Error(e instanceof Error?e.message:a.saveError)}},[a.saveError,e])});(0,Q.useEffect)(()=>{t?.(W||J.status===`saving`||l)},[W,J.status,l,t]),(0,Q.useEffect)(()=>()=>t?.(!1),[t]);let oe=(0,Q.useCallback)(e=>{y.current=!0,f({type:`update`,updater:()=>e})},[]);if(!c)return(0,$.jsx)(`div`,{className:`flex flex-col gap-3`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:a.needToken})});if(te)return(0,$.jsx)(U,{rows:4});if(!p||g===null)return(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:ne??a.loadError}),(0,$.jsx)(Y,{type:`button`,variant:`secondary`,onClick:()=>{O(),P()},children:a.retry})]});let se=p.stt,ce=p.tts,le=p.voice.input.refinement,X=Wn(a);return(0,$.jsxs)(`fieldset`,{disabled:n||l,className:`flex min-w-0 flex-col gap-4`,onBlurCapture:J.error?void 0:J.onBlurCapture,children:[(0,$.jsx)(It,{status:J.status,error:J.error}),J.error?(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsx)(Y,{variant:`secondary`,onClick:J.retry,children:i===`zh`?`重试保存`:`Retry saving`}),(0,$.jsx)(Y,{variant:`ghost`,onClick:()=>{O().then(()=>r()).catch(()=>{})},children:i===`zh`?`重新加载(放弃未保存更改)`:`Reload and discard unsaved changes`})]}):null,e===`transcription`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Tn,{zh:i===`zh`}),(0,$.jsx)($n,{managedModel:!0,v:a,apiKeyLabels:X,stt:se,models:g,sttProviders:H,updateStt:G,updateSttFallback:K}),(0,$.jsx)(Qn,{v:a,voice:p.voice,updateLanguageMode:q}),(0,$.jsxs)(`details`,{"data-voice-section":`input-processing`,className:`rounded-xl bg-surface-hover/20 p-4`,children:[(0,$.jsxs)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:[a.experience.inputProcessing,` · `,le.mode===`off`?a.stt.refinementOff:le.mode===`punctuation`?a.stt.refinementPunctuation:le.mode===`light`?a.stt.refinementLight:a.setup.advanced]}),(0,$.jsxs)(`label`,{className:`mt-4 block space-y-2 text-sm`,children:[(0,$.jsx)(`span`,{children:a.stt.refinement}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:a.stt.refinementDesc}),(0,$.jsxs)(pt,{className:Rn(),value:le.mode,onChange:e=>re({mode:e.target.value}),children:[(0,$.jsx)(Z,{value:`off`,children:a.stt.refinementOff}),(0,$.jsx)(Z,{value:`punctuation`,children:a.stt.refinementPunctuation}),(0,$.jsx)(Z,{value:`light`,children:a.stt.refinementLight}),le.mode===`custom`?(0,$.jsx)(Z,{value:`custom`,children:a.setup.advanced}):null]})]})]}),se.provider===`xopc-cloud`?(0,$.jsxs)(`details`,{className:`rounded-xl border border-edge p-4`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium`,children:i===`zh`?`实时听写`:`Live dictation`}),(0,$.jsx)(`div`,{className:`mt-4`,children:(0,$.jsx)(xn,{modes:[`transcription.stream`],disabled:W||J.status===`saving`,onPendingChange:u})})]}):null]}):e===`speech`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(tr,{managedModel:!0,v:a,apiKeyLabels:X,tts:ce,models:g,ttsProviders:V,updateTts:ae}),(0,$.jsx)(Zn,{v:a,tts:ce,updateTts:ae})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(On,{section:`listening`,v:a,form:p,pending:W||J.status===`saving`||!!J.error,onChange:oe}),p.voice.realtime.defaultEngine===`omni`&&p.voice.realtime.omni?(0,$.jsx)(Pn,{value:p.voice.realtime.omni,onChange:e=>ie({omni:e})}):null,(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:a.experience.pace}),(0,$.jsxs)(pt,{className:Rn(),value:String(p.voice.realtime.silenceDurationMs),onChange:e=>ie({silenceDurationMs:Number(e.target.value)}),children:[(0,$.jsx)(Z,{value:`800`,children:a.experience.fast}),(0,$.jsx)(Z,{value:`1200`,children:a.experience.standard}),(0,$.jsx)(Z,{value:`2000`,children:a.experience.relaxed}),[800,1200,2e3].includes(p.voice.realtime.silenceDurationMs)?null:(0,$.jsxs)(Z,{value:String(p.voice.realtime.silenceDurationMs),children:[p.voice.realtime.silenceDurationMs,` ms`]})]})]})}),(0,$.jsxs)(`label`,{className:`flex items-center justify-between text-sm`,children:[a.experience.captions,(0,$.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":o,className:`ui-checkbox`,checked:o,onChange:e=>s(e.target.checked)})]}),p.voice.realtime.defaultEngine===`agent`&&se.provider===`xopc-cloud`?(0,$.jsxs)(`details`,{className:`rounded-xl border border-edge p-4`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium`,children:i===`zh`?`语音助手输出`:`Assistant speech output`}),(0,$.jsx)(`div`,{className:`mt-4`,children:(0,$.jsx)(xn,{modes:[`speech.stream`],disabled:W||J.status===`saving`,onPendingChange:u})})]}):null,(0,$.jsxs)(`details`,{className:`rounded-xl border border-edge p-4`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium`,children:i===`zh`?`麦克风、扬声器与诊断`:`Microphone, speakers and diagnostics`}),(0,$.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[(0,$.jsx)(Sn,{v:a}),(0,$.jsx)(On,{section:`diagnostics`,v:a,form:p,pending:W||J.status===`saving`||!!J.error,onChange:oe})]})]})]})]})}function Zn(e){let t=(0,rn.c)(29),{v:n,tts:r,updateTts:i}=e,a;t[0]===n.setup.readout?a=t[1]:(a=(0,$.jsx)(`span`,{className:`font-medium`,children:n.setup.readout}),t[0]=n.setup.readout,t[1]=a);let o=n.setup.readout,s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=Rn(),t[2]=s):s=t[2];let c=r.enabled?r.trigger:`off`,l;t[3]===i?l=t[4]:(l=e=>i({enabled:e.target.value!==`off`,trigger:e.target.value}),t[3]=i,t[4]=l);let u;t[5]===n.tts.triggerOff?u=t[6]:(u=(0,$.jsx)(Z,{value:`off`,children:n.tts.triggerOff}),t[5]=n.tts.triggerOff,t[6]=u);let d;t[7]===n.tts.triggerInbound?d=t[8]:(d=(0,$.jsx)(Z,{value:`inbound`,children:n.tts.triggerInbound}),t[7]=n.tts.triggerInbound,t[8]=d);let f;t[9]===n.tts.triggerAlways?f=t[10]:(f=(0,$.jsx)(Z,{value:`always`,children:n.tts.triggerAlways}),t[9]=n.tts.triggerAlways,t[10]=f);let p;t[11]===n.tts.triggerTagged?p=t[12]:(p=(0,$.jsx)(Z,{value:`tagged`,children:n.tts.triggerTagged}),t[11]=n.tts.triggerTagged,t[12]=p);let m;t[13]!==c||t[14]!==l||t[15]!==u||t[16]!==d||t[17]!==f||t[18]!==p||t[19]!==n.setup.readout?(m=(0,$.jsxs)(pt,{"aria-label":o,className:s,value:c,onChange:l,children:[u,d,f,p]}),t[13]=c,t[14]=l,t[15]=u,t[16]=d,t[17]=f,t[18]=p,t[19]=n.setup.readout,t[20]=m):m=t[20];let h;t[21]!==a||t[22]!==m?(h=(0,$.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[a,m]}),t[21]=a,t[22]=m,t[23]=h):h=t[23];let g;t[24]===n.setup.readoutHint?g=t[25]:(g=(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.setup.readoutHint}),t[24]=n.setup.readoutHint,t[25]=g);let _;return t[26]!==h||t[27]!==g?(_=(0,$.jsxs)(`section`,{className:`space-y-2 rounded-xl bg-surface-hover/20 p-4 sm:p-5`,children:[h,g]}),t[26]=h,t[27]=g,t[28]=_):_=t[28],_}function Qn(e){let t=(0,rn.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=Rn(),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 d;t[10]===n.language.auto?d=t[11]:(d=(0,$.jsx)(Z,{value:`auto`,children:n.language.auto}),t[10]=n.language.auto,t[11]=d);let f;t[12]===n.language.manual?f=t[13]:(f=(0,$.jsx)(Z,{value:`manual`,children:n.language.manual}),t[12]=n.language.manual,t[13]=f);let p;t[14]!==u||t[15]!==d||t[16]!==f||t[17]!==r.languageMode?(p=(0,$.jsxs)(pt,{className:l,value:r.languageMode,onChange:u,children:[d,f]}),t[14]=u,t[15]=d,t[16]=f,t[17]=r.languageMode,t[18]=p):p=t[18];let m;return t[19]!==c||t[20]!==p?(m=(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,p]})}),t[19]=c,t[20]=p,t[21]=m):m=t[21],m}function $n(e){let t=(0,rn.c)(65),{v:n,apiKeyLabels:r,stt:i,models:a,sttProviders:o,updateStt:s,updateSttFallback:c,managedModel:l}=e,u=l===void 0?!1:l,d;if(t[0]!==o){let e=new Set;d=[];for(let t of o)e.has(t.id)||(e.add(t.id),d.push(t));t[0]=o,t[1]=d}else d=t[1];let f=d,p,m,h,_;if(t[2]!==a||t[3]!==f||t[4]!==i.provider||t[5]!==i.providers){p=f.find(e=>e.id===i.provider);let e;t[10]!==i.provider||t[11]!==i.providers?(e=i.providers?.[i.provider]??{},t[10]=i.provider,t[11]=i.providers,t[12]=e):e=t[12],h=e,m=a?.stt?.[i.provider]?.length?a.stt[i.provider]:p?.models??[],_=p?.fields.find(er),t[2]=a,t[3]=f,t[4]=i.provider,t[5]=i.providers,t[6]=p,t[7]=m,t[8]=h,t[9]=_}else p=t[6],m=t[7],h=t[8],_=t[9];let v=_,y=typeof h.model==`string`?h.model:void 0,b=y??(typeof v?.defaultValue==`string`?v.defaultValue:m[0]?.id),x;t[13]!==i.provider||t[14]!==i.providers||t[15]!==s?(x=e=>{s({providers:{...i.providers??{},[i.provider]:{...i.providers?.[i.provider]??{},...e}}})},t[13]=i.provider,t[14]=i.providers,t[15]=s,t[16]=x):x=t[16];let S=x,C,w;t[17]!==y||t[18]!==b||t[19]!==u||t[20]!==v||t[21]!==S?(C=()=>{!u&&v&&b&&y!==b&&S({model:b})},w=[u,y,b,v,S],t[17]=y,t[18]=b,t[19]=u,t[20]=v,t[21]=S,t[22]=C,t[23]=w):(C=t[22],w=t[23]),(0,Q.useEffect)(C,w);let T;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(we,{"aria-hidden":`true`,className:`size-4 text-accent`,strokeWidth:1.75}),t[24]=T):T=t[24];let E;t[25]===n.stt.title?E=t[26]:(E=(0,$.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[T,n.stt.title]}),t[25]=n.stt.title,t[26]=E);let D;t[27]===n.stt.enable?D=t[28]:(D=(0,$.jsx)(`span`,{children:n.stt.enable}),t[27]=n.stt.enable,t[28]=D);let O;t[29]===s?O=t[30]:(O=e=>s({enabled:e.target.checked}),t[29]=s,t[30]=O);let k;t[31]!==i.enabled||t[32]!==O?(k=(0,$.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":i.enabled,className:`ui-checkbox`,checked:i.enabled,onChange:O}),t[31]=i.enabled,t[32]=O,t[33]=k):k=t[33];let A;t[34]!==k||t[35]!==D?(A=(0,$.jsxs)(`label`,{className:`flex min-h-10 items-center gap-2 text-xs text-fg-muted`,children:[D,k]}),t[34]=k,t[35]=D,t[36]=A):A=t[36];let j;t[37]!==A||t[38]!==E?(j=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[E,A]}),t[37]=A,t[38]=E,t[39]=j):j=t[39];let M;t[40]===n.stt.description?M=t[41]:(M=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.stt.description}),t[40]=n.stt.description,t[41]=M);let N;t[42]!==j||t[43]!==M?(N=(0,$.jsxs)(`div`,{className:`mb-4`,children:[j,M]}),t[42]=j,t[43]=M,t[44]=N):N=t[44];let P;t[45]!==p?.fields||t[46]!==r||t[47]!==b||t[48]!==u||t[49]!==m||t[50]!==f||t[51]!==h||t[52]!==i.enabled||t[53]!==i.fallback?.enabled||t[54]!==i.provider||t[55]!==S||t[56]!==s||t[57]!==c||t[58]!==n?(P=i.enabled?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[u?null:(0,$.jsxs)(`div`,{className:g(`flex flex-col gap-1.5`,In),children:[(0,$.jsx)(lr,{children:n.stt.provider}),(0,$.jsx)(pt,{"aria-label":n.stt.provider,className:Rn(),value:i.provider,onChange:e=>s({provider:e.target.value}),children:f.map(e=>(0,$.jsxs)(Z,{value:e.id,children:[Vn(e.id,n),e.configured?``:` *`]},e.id))})]}),(0,$.jsx)(nr,{managedModel:u,kind:`stt`,providerId:i.provider,fields:p?.fields??[],providerSlice:h,models:m,currentModel:b,apiKeyLabels:r,onPatch:S})]}),i.provider===`alibaba`?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.setup.keyHint}):null,(0,$.jsxs)(`details`,{className:`rounded-lg border border-edge p-3`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:n.stt.fallback}),(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[45]=p?.fields,t[46]=r,t[47]=b,t[48]=u,t[49]=m,t[50]=f,t[51]=h,t[52]=i.enabled,t[53]=i.fallback?.enabled,t[54]=i.provider,t[55]=S,t[56]=s,t[57]=c,t[58]=n,t[59]=P):P=t[59];let F;t[60]===P?F=t[61]:(F=(0,$.jsx)(`div`,{className:`space-y-4`,children:P}),t[60]=P,t[61]=F);let I;return t[62]!==N||t[63]!==F?(I=(0,$.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 px-4 py-5 sm:px-5`,children:[N,F]}),t[62]=N,t[63]=F,t[64]=I):I=t[64],I}function er(e){return e.key===`model`}function tr({v:e,apiKeyLabels:t,tts:n,models:r,ttsProviders:i,updateTts:a,managedModel:o=!1}){let[s,c]=(0,Q.useState)(e.tts.test.sampleText),[l,u]=(0,Q.useState)({status:`idle`}),d=(0,Q.useRef)(null),f=(0,Q.useRef)(null),p=(0,Q.useRef)(null),m=(0,Q.useCallback)(()=>{p.current?.abort(),p.current=null,d.current?.pause(),d.current=null,f.current&&=(URL.revokeObjectURL(f.current),null)},[]),h=(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]),_=h.find(e=>e.id===n.provider),v=n.providers?.[n.provider]??{},y=r?.tts?.[n.provider]?.length?r.tts[n.provider]:_?.models??[],b=_?.fields.find(e=>e.key===`model`),x=_?.fields.find(e=>e.key===`voice`),S=typeof v.model==`string`?v.model:void 0,C=S??(typeof b?.defaultValue==`string`?b.defaultValue:y[0]?.id),w=y.find(e=>e.id===C),T=r?.ttsVoices?.[n.provider]?.length?r.ttsVoices[n.provider]:_?.voices??[],{data:E=[]}=k(C?`voice:tts:${n.provider}:${C}`:null,()=>Ht(n.provider,C??``),{revalidateOnFocus:!1}),D=E.length>0?E:T,O=typeof v.voice==`string`?v.voice:void 0,A=O??D.find(e=>e.id===w?.tts?.defaultVoice)?.id??(typeof x?.defaultValue==`string`?x.defaultValue:D[0]?.id),j=(_?.fields??[]).filter(e=>(e.key!==`speed`||w?.tts?.speed!==!1)&&(e.key!==`instructions`||w?.tts?.instructions!==!1)),M=(0,Q.useCallback)(e=>{a({providers:{...n.providers??{},[n.provider]:{...n.providers?.[n.provider]??{},...e}}})},[n.provider,n.providers,a]);(0,Q.useEffect)(()=>{if(o)return;let e={};b&&C&&S!==C&&(e.model=C),x&&A&&O!==A&&(e.voice=A),Object.keys(e).length>0&&M(e)},[o,S,O,C,A,b,M,x]),(0,Q.useEffect)(()=>()=>m(),[m]);let N=(0,Q.useCallback)(e=>{a({provider:e}),u({status:`idle`})},[a]),P=(0,Q.useCallback)(async()=>{let t=s.trim();if(!t){u({status:`error`,message:e.tts.test.emptyText});return}m();let r=new AbortController;p.current=r,u({status:`loading`});try{let i=await zt({text:t,provider:n.provider,providerConfig:v,...C?{model:C}:{},...A?{voice:A}:{}},r.signal);if(r.signal.aborted)return;let a=Bn(i.audio,i.mimeType);f.current=a;let o=new Audio(a);d.current=o;let s=[i.provider,i.format,i.latencyMs===void 0?void 0:`${i.latencyMs}ms`,zn(i.audioSize)].filter(Boolean).join(` · `);o.addEventListener(`ended`,()=>u({status:`done`,summary:s}),{once:!0}),o.addEventListener(`error`,()=>u({status:`error`,message:e.tts.test.playFailed}),{once:!0}),await o.play(),u({status:`playing`,summary:s})}catch(e){if(r.signal.aborted)return;m(),u({status:`error`,message:e instanceof Error?e.message:String(e)})}},[C,A,v,m,s,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)(Et,{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,$.jsx)(`div`,{className:`space-y-4`,children:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:o?null:(0,$.jsxs)(`div`,{className:g(`flex flex-col gap-1.5`,In),children:[(0,$.jsx)(lr,{children:e.tts.provider}),(0,$.jsx)(pt,{"aria-label":e.tts.provider,className:Rn(),value:n.provider,onChange:e=>N(e.target.value),children:h.map(t=>(0,$.jsx)(Z,{value:t.id,children:Hn(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??Un(n.provider,e)]})]})}),(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:(0,$.jsx)(nr,{managedModel:o,kind:`tts`,providerId:n.provider,fields:j,providerSlice:v,models:y,voices:D,currentModel:C,currentVoice:A,apiKeyLabels:t,onPatch:M,resetVoiceOnModelChange:!0})}),(0,$.jsxs)(`details`,{className:`rounded-xl bg-surface-panel/80 p-3`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:e.tts.test.title}),(0,$.jsxs)(`div`,{className:`mt-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,$.jsx)(`div`,{children:(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)(Y,{type:`button`,variant:`primary`,onClick:()=>void P(),disabled:l.status===`loading`,className:`h-9`,children:[l.status===`loading`?(0,$.jsx)(ce,{className:`size-4 animate-spin`}):(0,$.jsx)(gt,{className:`size-4`}),l.status===`loading`?e.tts.test.generating:e.tts.test.play]}),(0,$.jsxs)(Y,{type:`button`,variant:`secondary`,onClick:()=>{m(),u(e=>e.status===`playing`?{status:`done`,summary:e.summary}:{status:`idle`})},disabled:l.status!==`playing`,className:`h-9`,children:[(0,$.jsx)(Ot,{className:`size-4`}),e.tts.test.stop]})]})]}),(0,$.jsxs)(`details`,{className:`mt-3`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-xs text-fg-muted`,children:e.setup.sampleText}),(0,$.jsx)(`textarea`,{className:g(Ln(),`mt-3 min-h-20 resize-y`),value:s,onChange:e=>c(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:[s.length,`/1000`]}),l.status===`playing`||l.status===`done`?(0,$.jsxs)(`span`,{className:`text-emerald-700 dark:text-emerald-200`,children:[l.status===`playing`?e.tts.test.playing:e.tts.test.ready,` · `,l.summary]}):null,l.status===`error`?(0,$.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:l.message}):null]})]})]})]})})]})}function nr(e){let t=(0,rn.c)(48),{kind:n,providerId:r,fields:i,providerSlice:a,models:o,voices:s,currentModel:c,currentVoice:l,apiKeyLabels:u,onPatch:d,resetVoiceOnModelChange:f,managedModel:p}=e,m;t[0]===s?m=t[1]:(m=s===void 0?[]:s,t[0]=s,t[1]=m);let _=m,v=f===void 0?!1:f,y=p===void 0?!1:p,x=b(or),S;t[2]===x?S=t[3]:(S=h(x),t[2]=x,t[3]=S);let C=S.voiceSettings,w=y,T=ar,E=ir,D,O,k;if(t[4]!==u||t[5]!==c||t[6]!==l||t[7]!==i||t[8]!==n||t[9]!==x||t[10]!==y||t[11]!==o||t[12]!==d||t[13]!==r||t[14]!==a||t[15]!==v||t[16]!==w||t[17]!==C||t[18]!==_){let e;t[22]===w?e=t[23]:(e=e=>!w||e.key!==`model`&&!E(e),t[22]=w,t[23]=e);let s=i.filter(e),f;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(f=e=>!T(e),t[24]=f):f=t[24];let p=s.filter(f),m;t[25]!==u||t[26]!==c||t[27]!==l||t[28]!==n||t[29]!==x||t[30]!==y||t[31]!==o||t[32]!==d||t[33]!==r||t[34]!==a||t[35]!==v||t[36]!==C||t[37]!==_?(m=e=>e.map(e=>y&&e.key===`model`?null:e.key===`apiKey`?(0,$.jsxs)(`div`,{className:g(`flex flex-col gap-1.5`,In),children:[(0,$.jsx)(lr,{htmlFor:`voice-${n}-${r}-api-key`,children:C.stt.apiKey}),(0,$.jsx)(Jt,{kind:n,providerId:r,fieldId:`voice-${n}-${r}-api-key`,value:typeof a.apiKey==`string`?a.apiKey:``,onChange:e=>d({apiKey:e}),labels:u,placeholder:e.placeholder}),e.description?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.description}):null]},e.key):e.key===`model`&&o.length>0?(0,$.jsxs)(`div`,{className:g(`flex flex-col gap-1.5`,In),children:[(0,$.jsx)(lr,{htmlFor:`voice-${n}-${r}-model`,children:C.stt.model}),(0,$.jsx)(pt,{id:`voice-${n}-${r}-model`,className:Rn(),value:c??``,onChange:e=>d({model:e.target.value,...v?{voice:void 0}:{}}),children:o.map(rr)})]},e.key):e.key===`voice`&&_.length>0?(0,$.jsxs)(`div`,{className:g(`flex flex-col gap-1.5`,In),children:[(0,$.jsx)(lr,{htmlFor:`voice-${n}-${r}-voice`,children:C.tts.voice}),(0,$.jsxs)(pt,{id:`voice-${n}-${r}-voice`,className:Rn(),value:l??``,onChange:e=>d({voice:e.target.value}),children:[l&&!_.some(e=>e.id===l)?(0,$.jsxs)(Z,{value:l,children:[l,` · unavailable`]}):null,_.map(e=>(0,$.jsxs)(Z,{value:e.id,children:[F(e,x),e.gender?` · ${e.gender===`female`?`女声`:`男声`}`:``,e.style?` · ${e.style}`:``]},e.id))]}),_.find(e=>e.id===l)?.description?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:_.find(e=>e.id===l)?.description}):null]},e.key):(0,$.jsx)(sr,{fieldId:`voice-${n}-${r}-${e.key}`,field:e,value:Gn(a,e),onChange:t=>d({[e.key]:t}),className:e.type===`textarea`?`sm:col-span-2`:In},e.key)),t[25]=u,t[26]=c,t[27]=l,t[28]=n,t[29]=x,t[30]=y,t[31]=o,t[32]=d,t[33]=r,t[34]=a,t[35]=v,t[36]=C,t[37]=_,t[38]=m):m=t[38];let h=m;t[39]!==i||t[40]!==n||t[41]!==x||t[42]!==w?(D=w&&i.some(E)?(0,$.jsx)(wn,{className:`text-sm text-accent-fg hover:underline`,to:`/settings/capabilities/models?tab=services&configure=${n===`stt`?`transcription`:`speech`}`,children:x===`zh`?`管理服务连接`:`Manage service connection`}):null,t[39]=i,t[40]=n,t[41]=x,t[42]=w,t[43]=D):D=t[43],O=h(s.filter(T)),k=p.length?(0,$.jsxs)(`details`,{className:`rounded-lg border border-edge p-3 sm:col-span-2`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:C.experience.providerOptions}),(0,$.jsx)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2`,children:h(p)})]}):null,t[4]=u,t[5]=c,t[6]=l,t[7]=i,t[8]=n,t[9]=x,t[10]=y,t[11]=o,t[12]=d,t[13]=r,t[14]=a,t[15]=v,t[16]=w,t[17]=C,t[18]=_,t[19]=D,t[20]=O,t[21]=k}else D=t[19],O=t[20],k=t[21];let A;return t[44]!==D||t[45]!==O||t[46]!==k?(A=(0,$.jsxs)($.Fragment,{children:[D,O,k]}),t[44]=D,t[45]=O,t[46]=k,t[47]=A):A=t[47],A}function rr(e){return(0,$.jsx)(Z,{value:e.id,children:e.name},e.id)}function ir(e){return e.secret||e.type===`password`||[`apiKey`,`baseUrl`,`region`,`groupId`].includes(e.key)}function ar(e){return e.required||[`apiKey`,`model`,`voice`].includes(e.key)}function or(e){return e.language}function sr(e){let t=(0,rn.c)(37),{fieldId:n,field:r,value:i,onChange:a,className:o}=e,s=n??`voice-schema-field-${r.key}`,c=r.description;if(r.type===`boolean`){let e;t[0]===o?e=t[1]:(e=g(`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,o),t[0]=o,t[1]=e);let n;t[2]===r.label?n=t[3]:(n=(0,$.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:r.label}),t[2]=r.label,t[3]=n);let s;t[4]===c?s=t[5]:(s=c?(0,$.jsx)(`span`,{className:`mt-1 block text-xs text-fg-subtle`,children:c}):null,t[4]=c,t[5]=s);let l;t[6]!==n||t[7]!==s?(l=(0,$.jsxs)(`span`,{children:[n,s]}),t[6]=n,t[7]=s,t[8]=l):l=t[8];let u=!!i,d;t[9]!==r||t[10]!==a?(d=e=>a(Kn(r,e.target.checked)),t[9]=r,t[10]=a,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 l=typeof i==`boolean`?``:String(i),u;t[19]===o?u=t[20]:(u=g(`flex flex-col gap-1.5`,o),t[19]=o,t[20]=u);let d;t[21]!==r.label||t[22]!==s?(d=(0,$.jsx)(lr,{htmlFor:s,children:r.label}),t[21]=r.label,t[22]=s,t[23]=d):d=t[23];let f;t[24]!==o||t[25]!==r||t[26]!==l||t[27]!==s||t[28]!==a?(f=r.type===`select`?(0,$.jsx)(pt,{id:s,className:Rn(),value:l,required:r.required,onChange:e=>a(Kn(r,e.target.value)),children:(r.options??[]).map(cr)}):r.type===`textarea`?(0,$.jsx)(`textarea`,{id:s,className:g(Ln(),`min-h-24 resize-y`),value:l,required:r.required,placeholder:r.placeholder,onChange:e=>a(Kn(r,e.target.value))}):r.type===`password`?(0,$.jsx)(ct,{id:s,className:o,value:l,onChange:e=>a(Kn(r,e)),placeholder:r.placeholder,labels:Ee}):r.type===`number`?(0,$.jsx)(jt,{id:s,className:Ln(),autoComplete:r.secret?`new-password`:`off`,spellCheck:!1,value:l,required:r.required,allowEmpty:!r.required,placeholder:r.placeholder,min:r.min,max:r.max,step:r.step,onChange:e=>a(Kn(r,e.target.value))}):(0,$.jsx)(`input`,{id:s,className:Ln(),type:`text`,autoComplete:r.secret?`new-password`:`off`,spellCheck:!1,value:l,required:r.required,placeholder:r.placeholder,min:r.min,max:r.max,step:r.step,onChange:e=>a(Kn(r,e.target.value))}),t[24]=o,t[25]=r,t[26]=l,t[27]=s,t[28]=a,t[29]=f):f=t[29];let p;t[30]===c?p=t[31]:(p=c?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:c}):null,t[30]=c,t[31]=p);let m;return t[32]!==u||t[33]!==d||t[34]!==f||t[35]!==p?(m=(0,$.jsxs)(`div`,{className:u,children:[d,f,p]}),t[32]=u,t[33]=d,t[34]=f,t[35]=p,t[36]=m):m=t[36],m}function cr(e){return(0,$.jsx)(Z,{value:e.id,children:e.name},e.id)}function lr(e){let t=(0,rn.c)(3),{children:n,htmlFor:r}=e,i;return t[0]!==n||t[1]!==r?(i=r?(0,$.jsx)(`label`,{htmlFor:r,className:`text-sm font-medium text-fg`,children:n}):(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i}function ur(e){return e.some(e=>e.disabled?!1:e.type===`searxng`?e.url.trim().length>0:e.apiKey.trim().length>0)}function dr(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,t)=>{let n=e&&typeof e==`object`?e:{},r=n.type,i=r===`brave`||r===`tavily`||r===`bing`||r===`searxng`||r===`deepseek`?r:`brave`;return{clientKey:`search-provider-${t}`,type:i,apiKey:typeof n.apiKey==`string`?n.apiKey:``,url:typeof n.url==`string`?n.url:``,disabled:n.disabled===!0}}):[],blocklistEnabled:l.enabled===!0,blocklistDomains:u}}async function fr(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.type===`deepseek`)&&e.url.trim()&&(t.url=e.url.trim().replace(/\/+$/,``)),e.disabled&&(t.disabled=!0),t})};await _(x(`/api/config`),{method:`PATCH`,body:JSON.stringify({tools:{web:{region:t,search:n,blocklist:{enabled:e.blocklistEnabled,domains:e.blocklistDomains}}}})}),A()}async function pr(e){let t=await _(x(`/api/tools/web/reveal-search-api-key`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({index:e})});if(!t.ok||!t.payload)throw Error(t.error?.message??`Reveal failed`);return t.payload}function mr(e){let t=(0,rn.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 hr(){return g(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,de,`dark:border-edge`)}function gr(){return g(K,ke)}var _r=[`brave`,`tavily`,`bing`,`searxng`,`deepseek`];function vr(){return{clientKey:crypto.randomUUID(),type:`brave`,apiKey:``,url:``,disabled:!1}}var yr=P();function br(){let e=h(b(e=>e.language)),t=e.webSearchSettings,n=e.logs,r=!!v(e=>e.conversationId),[i,a]=(0,Q.useReducer)(yr,{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:d,error:f,isLoading:m,mutate:_}=j(r);at({enabled:r,parsed:(0,Q.useMemo)(()=>d?.payload?.config===void 0?null:dr(d.payload.config),[d]),dirty:c.current,trackedParsedRef:u,dispatch:a,onResetDirty:()=>{c.current=!1}});let y=!!(r&&m&&d===void 0&&!f),x=f instanceof Error?f.message:f?String(f):null,S=(0,Q.useMemo)(()=>!o||!s?!1:JSON.stringify(o)!==JSON.stringify(s),[o,s]),C=(0,Q.useCallback)(e=>{c.current=!0,a({type:`patch`,patch:e})},[]),w=Lt({value:o,dirty:S,onSave:(0,Q.useCallback)(async e=>{try{await fr(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(y)return(0,$.jsx)(U,{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:x??t.loadError}),(0,$.jsx)(Y,{type:`button`,variant:`secondary`,onClick:()=>void _(),children:n.refresh})]});let T=ur(o.providers);return(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,onBlurCapture:w.onBlurCapture,children:[w.error?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:w.error}):null,(0,$.jsxs)(Ft,{children:[(0,$.jsx)(Pt,{icon:ot,title:t.sectionSearch,subtitle:t.sectionSearchHint,trailing:(0,$.jsx)(It,{status:w.status,error:w.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)(He,{className:`mt-0.5 size-5 shrink-0 text-accent`}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.cloudProvider}),(0,$.jsx)(`span`,{className:g(`rounded-full px-2 py-0.5 text-[11px] font-medium`,T?`bg-surface-panel text-fg-muted`:`bg-accent-soft text-accent`),children:T?t.cloudOverridden:t.cloudAutomatic})]}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-subtle`,children:T?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)(xr,{row:n,providerIndex:r,labels:t,secretLabels:ut(e.providersSettings),onChange:e=>{let t=[...o.providers];t[r]=e,C({providers:t})},onRemove:()=>{C({providers:o.providers.filter((e,t)=>t!==r)})}},n.clientKey??r)),(0,$.jsxs)(Y,{type:`button`,variant:`secondary`,className:`w-fit gap-1.5 text-sm`,onClick:()=>C({providers:[...o.providers,vr()]}),children:[(0,$.jsx)(p,{className:`size-4`}),t.addProvider]})]})]}),(0,$.jsxs)(Ft,{children:[(0,$.jsx)(Pt,{icon:ie,title:t.sectionPreferences}),(0,$.jsxs)(`div`,{className:`grid max-w-2xl gap-4 sm:grid-cols-2`,children:[(0,$.jsx)(mr,{label:t.regionLabel,description:t.regionDesc,children:(0,$.jsxs)(pt,{className:gr(),value:o.regionMode,onChange:e=>C({regionMode:e.target.value}),children:[(0,$.jsx)(Z,{value:`auto`,children:t.regionAuto}),(0,$.jsx)(Z,{value:`cn`,children:t.regionCn}),(0,$.jsx)(Z,{value:`global`,children:t.regionGlobal})]})}),(0,$.jsx)(q,{title:t.maxResultsLabel,summary:o.maxResults,children:(0,$.jsx)(mr,{label:t.maxResultsLabel,description:t.maxResultsDesc,children:(0,$.jsx)(jt,{type:`number`,min:1,max:50,className:hr(),value:o.maxResults,onChange:e=>C({maxResults:Math.max(1,Math.min(50,Number(e.target.value)||5))})})})})]})]}),(0,$.jsxs)(`details`,{className:`rounded-xl bg-surface-hover/20 p-4`,children:[(0,$.jsxs)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:[t.sectionBlocklist,` · `,o.blocklistEnabled?o.blocklistDomains.length:0]}),(0,$.jsxs)(Ft,{children:[(0,$.jsx)(Pt,{icon:fe,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=>C({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)(mr,{label:t.blocklistDomains,description:t.blocklistDomainsDesc,children:(0,$.jsx)(`textarea`,{className:g(hr(),`min-h-[6rem] font-mono text-xs`),value:o.blocklistDomains.join(`
8
+ `),placeholder:t.blocklistDomainsPlaceholder,onChange:e=>{C({blocklistDomains:e.target.value.split(/\r?\n/).flatMap(e=>{let t=e.trim().toLowerCase();return t?[t]:[]})})}})}):null]})]})]})]})}function xr(e){let t=(0,rn.c)(56),{row:n,providerIndex:r,labels:i,secretLabels:a,onChange:o,onRemove:s}=e,c;t[0]===r?c=t[1]:(c=()=>pr(r).then(Sr),t[0]=r,t[1]=c);let l=c,u;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=g(gr(),`min-w-[8rem]`),t[2]=u):u=t[2];let d=n.type,f;t[3]!==o||t[4]!==n?(f=e=>o({...n,type:e.target.value,url:``,apiKey:``}),t[3]=o,t[4]=n,t[5]=f):f=t[5];let p;t[6]===i.providerTypes?p=t[7]:(p=_r.map(e=>(0,$.jsx)(Z,{value:e,children:i.providerTypes[e]},e)),t[6]=i.providerTypes,t[7]=p);let m;t[8]!==n.type||t[9]!==f||t[10]!==p?(m=(0,$.jsx)(pt,{className:u,value:d,onChange:f,children:p}),t[8]=n.type,t[9]=f,t[10]=p,t[11]=m):m=t[11];let h;t[12]!==o||t[13]!==n?(h=e=>o({...n,disabled:e.target.checked}),t[12]=o,t[13]=n,t[14]=h):h=t[14];let _;t[15]!==n.disabled||t[16]!==h?(_=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:n.disabled,onChange:h}),t[15]=n.disabled,t[16]=h,t[17]=_):_=t[17];let v;t[18]!==i.disabled||t[19]!==_?(v=(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5 text-xs text-fg-muted`,children:[_,i.disabled]}),t[18]=i.disabled,t[19]=_,t[20]=v):v=t[20];let y;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(y=(0,$.jsx)(Te,{className:`size-4`}),t[21]=y):y=t[21];let b;t[22]===s?b=t[23]:(b=(0,$.jsx)(Y,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-fg-muted`,onClick:s,children:y}),t[22]=s,t[23]=b);let x;t[24]!==b||t[25]!==v?(x=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[v,b]}),t[24]=b,t[25]=v,t[26]=x):x=t[26];let S;t[27]!==x||t[28]!==m?(S=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[m,x]}),t[27]=x,t[28]=m,t[29]=S):S=t[29];let C;t[30]!==i.deepseekUrlDesc||t[31]!==i.deepseekUrlLabel||t[32]!==i.urlDesc||t[33]!==i.urlLabel||t[34]!==o||t[35]!==n?(C=n.type===`searxng`||n.type===`deepseek`?(0,$.jsx)(mr,{label:n.type===`deepseek`?i.deepseekUrlLabel:i.urlLabel,description:n.type===`deepseek`?i.deepseekUrlDesc:i.urlDesc,children:(0,$.jsx)(`input`,{type:`url`,className:hr(),value:n.url,placeholder:n.type===`deepseek`?`https://api.deepseek.com`:`http://localhost:8080`,onChange:e=>o({...n,url:e.target.value})})}):null,t[30]=i.deepseekUrlDesc,t[31]=i.deepseekUrlLabel,t[32]=i.urlDesc,t[33]=i.urlLabel,t[34]=o,t[35]=n,t[36]=C):C=t[36];let w;t[37]!==o||t[38]!==n?(w=e=>o({...n,apiKey:e}),t[37]=o,t[38]=n,t[39]=w):w=t[39];let T;t[40]!==i.keyPlaceholder||t[41]!==i.keyPlaceholderMasked||t[42]!==i.saveError||t[43]!==l||t[44]!==n.apiKey||t[45]!==a||t[46]!==w?(T=(0,$.jsx)(ct,{value:n.apiKey,onChange:w,placeholder:i.keyPlaceholder,labels:a,reveal:l,loadFailedLabel:i.saveError,notInConfigFile:i.keyPlaceholderMasked}),t[40]=i.keyPlaceholder,t[41]=i.keyPlaceholderMasked,t[42]=i.saveError,t[43]=l,t[44]=n.apiKey,t[45]=a,t[46]=w,t[47]=T):T=t[47];let E;t[48]!==i.apiKeyDesc||t[49]!==i.apiKeyLabel||t[50]!==T?(E=(0,$.jsx)(mr,{label:i.apiKeyLabel,description:i.apiKeyDesc,children:T}),t[48]=i.apiKeyDesc,t[49]=i.apiKeyLabel,t[50]=T,t[51]=E):E=t[51];let D;return t[52]!==S||t[53]!==C||t[54]!==E?(D=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl bg-surface-panel/60 p-4`,children:[S,C,E]}),t[52]=S,t[53]=C,t[54]=E,t[55]=D):D=t[55],D}function Sr(e){return e.apiKey??null}function Cr(e,t,n=[]){return e.filter(e=>!n.includes(e.providerId)&&e.uses.some(e=>e.id===t&&e.choices.length>0))}function wr(e){let t=(0,rn.c)(75),{use:n,data:r,language:i,labels:a,onSaved:o,inline:s,onPendingChange:c,onEditingChange:l}=e,u=s===void 0?!1:s,d=i===`zh`,[f,p]=(0,Q.useState)(),[m,h]=(0,Q.useState)(!1),g;t[0]===c?g=t[1]:(g=e=>{h(e),c?.(e)},t[0]=c,t[1]=g);let _=g,v=n===`transcription`?`stt`:n===`speech`?`tts`:void 0,y,b,x;if(t[2]!==r.builtinRows||t[3]!==r.cards||t[4]!==r.customConfig?.providers||t[5]!==r.loading||t[6]!==n){let e=new Set(r.cards.filter(e=>!Re(e.id)||!!r.customConfig?.providers?.[e.id]).map(Nr));y=[...new Set([...r.builtinRows.map(Mr),...e])].filter(t=>!Re(t)||e.has(t)).sort(),b=k,x=r.loading?null:[`capability-service-connections`,n,y.join(`,`)],t[2]=r.builtinRows,t[3]=r.cards,t[4]=r.customConfig?.providers,t[5]=r.loading,t[6]=n,t[7]=y,t[8]=b,t[9]=x}else y=t[7],b=t[8],x=t[9];let S;t[10]!==y||t[11]!==n||t[12]!==v?(S=async()=>{let e=v===`stt`?await Ut():v===`tts`?await Bt():void 0,t=e?.providers.filter(jr).map(Ar),r=e?.providers.filter(kr).map(Or)??[],i=t?y.filter(e=>t.includes(e)):y,a=await Promise.allSettled(i.map(Ae));return{services:Cr(a.flatMap(Dr),n,r),failed:a.some(Er)}},t[10]=y,t[11]=n,t[12]=v,t[13]=S):S=t[13];let C;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(C={revalidateOnFocus:!1},t[14]=C):C=t[14];let{data:w,error:T,isLoading:E,mutate:D}=b(x,S,C),O;t[15]===w?.services?O=t[16]:(O=new Set(w?.services.map(Tr)),t[15]=w?.services,t[16]=O);let A=O,j,M;if(t[17]!==l||t[18]!==f?(j=()=>(l?.(!!f),()=>l?.(!1)),M=[f,l],t[17]=l,t[18]=f,t[19]=j,t[20]=M):(j=t[19],M=t[20]),(0,Q.useEffect)(j,M),f&&u){let e;if(t[21]!==r.builtinRows||t[22]!==f){let n;t[24]===f?n=t[25]:(n=e=>e.id===f,t[24]=f,t[25]=n),e=r.builtinRows.find(n),t[21]=r.builtinRows,t[22]=f,t[23]=e}else e=t[23];let a;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(a=()=>p(void 0),t[26]=a):a=t[26];let s;t[27]!==D||t[28]!==o?(s=()=>{D(),p(void 0),o()},t[27]=D,t[28]=o,t[29]=s):s=t[29];let c;return t[30]!==i||t[31]!==f||t[32]!==_||t[33]!==e||t[34]!==s||t[35]!==n?(c=(0,$.jsx)(`section`,{className:`overflow-hidden rounded-xl border border-edge`,children:(0,$.jsx)(Tt,{inline:!0,providerId:f,row:e,targetUse:n,language:i,onPendingChange:_,onDone:a,onApplied:s},f)}),t[30]=i,t[31]=f,t[32]=_,t[33]=e,t[34]=s,t[35]=n,t[36]=c):c=t[36],c}let N=d?`选择服务`:`Choose a service`,P;t[37]===N?P=t[38]:(P=(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:N}),t[37]=N,t[38]=P);let F;t[39]!==r.loading||t[40]!==E?(F=r.loading||E?(0,$.jsx)(X,{className:`h-24 w-full`}):null,t[39]=r.loading,t[40]=E,t[41]=F):F=t[41];let I;t[42]!==w?.failed||t[43]!==T||t[44]!==D||t[45]!==d?(I=T||w?.failed?(0,$.jsxs)(`p`,{role:`alert`,className:`text-sm text-fg-muted`,children:[d?`部分服务目录暂时不可用。`:`Some service catalogs are unavailable.`,(0,$.jsx)(Y,{variant:`ghost`,onClick:()=>void D(),children:d?`重试`:`Retry`})]}):null,t[42]=w?.failed,t[43]=T,t[44]=D,t[45]=d,t[46]=I):I=t[46];let L;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(L=[!0,!1],t[47]=L):L=t[47];let R;t[48]!==m||t[49]!==w?.services||t[50]!==d?(R=L.map(e=>{let t=w?.services.filter(t=>t.configured===e)??[];return t.length?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-medium text-fg-muted`,children:e?d?`已连接`:`Connected`:d?`添加服务`:`Add a service`}),t.map(t=>(0,$.jsxs)(`button`,{type:`button`,disabled:m,onClick:()=>p(t.providerId),className:`flex min-h-14 w-full items-center justify-between gap-3 rounded-lg px-3 py-3 text-left transition-colors hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,children:[(0,$.jsx)(`span`,{className:`min-w-0 text-sm font-medium text-fg`,children:W(t.providerId,t.profile.name,d)}),(0,$.jsx)(`span`,{className:`shrink-0 text-sm text-accent-fg`,children:e?d?`选择`:`Choose`:d?`连接`:`Connect`})]},t.providerId))]},String(e)):null}),t[48]=m,t[49]=w?.services,t[50]=d,t[51]=R):R=t[51];let z;t[52]!==w||t[53]!==d?(z=w&&!w.services.length&&!w.failed?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:d?`暂无支持此能力的模型服务。`:`No model services currently support this capability.`}):null,t[52]=w,t[53]=d,t[54]=z):z=t[54];let B=d?`仅列出支持${wt[n][0]}的服务。`:`Only compatible services are shown. Reuse saved credentials, then return to select a model.`,V;t[55]===B?V=t[56]:(V=(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:B}),t[55]=B,t[56]=V);let H;t[57]!==r.builtinRows||t[58]!==r.customConfig||t[59]!==A||t[60]!==a||t[61]!==i||t[62]!==D||t[63]!==o||t[64]!==f||t[65]!==n?(H=f?(0,$.jsx)(Dt,{open:!0,initialProviderId:f,initialUse:n,connectOnly:!0,onOpenChange:e=>{e||p(void 0)},builtinRows:r.builtinRows.filter(e=>A.has(e.id)),customConfig:r.customConfig,labels:a,language:i,onSaved:()=>{D(),p(void 0),o()}},f):null,t[57]=r.builtinRows,t[58]=r.customConfig,t[59]=A,t[60]=a,t[61]=i,t[62]=D,t[63]=o,t[64]=f,t[65]=n,t[66]=H):H=t[66];let U;return t[67]!==P||t[68]!==F||t[69]!==I||t[70]!==R||t[71]!==z||t[72]!==V||t[73]!==H?(U=(0,$.jsxs)(`section`,{className:`space-y-3 rounded-xl border border-edge p-4`,children:[P,F,I,R,z,V,H]}),t[67]=P,t[68]=F,t[69]=I,t[70]=R,t[71]=z,t[72]=V,t[73]=H,t[74]=U):U=t[74],U}function Tr(e){return e.providerId}function Er(e){return e.status===`rejected`}function Dr(e){return e.status===`fulfilled`?[e.value]:[]}function Or(e){return e.id}function kr(e){return e.diagnostics.requiresApiKey}function Ar(e){return e.id}function jr(e){return!e.diagnostics.requiresApiKey}function Mr(e){return e.id}function Nr(e){return e.id}function Pr({zh:e,kind:t,modelServiceIds:n,onSaved:r,onPendingChange:i}){let{data:a,error:o,mutate:s}=k([`native-voice-connections`,t??`all`,n.join(`,`)],async()=>{let[e,r]=await Promise.all([t===`tts`?Promise.resolve({providers:[]}):Ut(),t===`stt`?Promise.resolve({providers:[]}):Bt()]);return[...e.providers.map(e=>({...e,kind:`stt`})),...r.providers.map(e=>({...e,kind:`tts`}))].filter(e=>e.diagnostics.requiresApiKey||!n.includes(e.id))}),[c,l]=(0,Q.useState)(``),[u,d]=(0,Q.useState)({}),[f,p]=(0,Q.useState)(!1),m=(0,Q.useRef)(!1),[h,g]=(0,Q.useState)(``);(0,Q.useEffect)(()=>(i?.(f),()=>i?.(!1)),[f,i]);let v=a?.find(e=>`${e.kind}:${e.id}`===c),y=v?.fields.filter(e=>e.secret||e.type===`password`||[`baseUrl`,`region`,`groupId`].includes(e.key))??[],b=async()=>{if(!(!v||m.current)){m.current=!0,p(!0),g(``);try{let t=Object.fromEntries(Object.entries(u).filter(([,e])=>e.trim()).map(([e,t])=>[e,t.trim()]));Object.keys(t).length&&await _(x(`/api/config`),{method:`PATCH`,body:JSON.stringify({[v.kind]:{providers:{[v.id]:t}}})});let[n]=await Promise.all([s(),Ge()]);if(!n?.find(e=>e.kind===v.kind&&e.id===v.id)?.configured)throw Error(e?`连接尚未就绪,请补齐所需凭据。`:`Connection is not ready. Complete the required credentials.`);d({}),r()}catch(e){g(e instanceof Error?e.message:String(e))}finally{m.current=!1,p(!1)}}};return a&&!a.length?null:(0,$.jsxs)(`details`,{className:`rounded-xl border border-edge p-4`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:e?`其他语音服务与本地语音`:`Other voice services and local speech`}),(0,$.jsxs)(`section`,{className:`mt-4 space-y-4`,children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t===`stt`?e?`其他识别服务`:`Other recognition services`:t===`tts`?e?`其他合成服务与本地语音`:`Other synthesis services and local speech`:e?`语音 API 与本地语音`:`Voice APIs and local speech`}),!a&&!o?(0,$.jsx)(X,{className:`h-20 w-full`}):null,o?(0,$.jsxs)(`p`,{role:`alert`,children:[e?`语音服务加载失败`:`Could not load voice services`,(0,$.jsx)(Y,{variant:`ghost`,onClick:()=>void s(),children:e?`重试`:`Retry`})]}):null,(0,$.jsxs)(pt,{value:c,disabled:f,"aria-label":e?`语音服务接入`:`Connect voice service`,onChange:e=>{l(e.target.value),d({}),g(``)},children:[(0,$.jsx)(Z,{value:``,children:e?`选择语音来源`:`Choose a voice source`}),a?.map(n=>(0,$.jsxs)(Z,{value:`${n.kind}:${n.id}`,children:[n.displayName,t?``:` · ${n.kind.toUpperCase()}`,n.configured?e?` · 已连接`:` · Connected`:``]},`${n.kind}:${n.id}`))]}),v?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:v.diagnostics.requiresApiKey?e?`此服务使用独立的 API Key。保存连接后,可在“模型与参数”中选用。`:`This service uses its own API key. Save the connection, then choose it in Model and parameters.`:e?`此来源无需 API Key,可返回能力设置选择。`:`No API key needed. Choose this source in capability settings.`}),y.map(t=>(0,$.jsxs)(`label`,{className:`block space-y-1 text-sm text-fg`,children:[(0,$.jsx)(`span`,{children:t.label}),t.secret||t.type===`password`?(0,$.jsx)(ct,{labels:Ee,value:u[t.key]??``,onChange:e=>d(n=>({...n,[t.key]:e})),disabled:f}):t.options?.length?(0,$.jsxs)(pt,{value:u[t.key]??``,disabled:f,onChange:e=>d(n=>({...n,[t.key]:e.target.value})),children:[(0,$.jsx)(Z,{value:``,children:e?`保留现有值`:`Keep existing`}),t.options.map(e=>(0,$.jsx)(Z,{value:e.id,children:e.name},e.id))]}):(0,$.jsx)(`input`,{className:`w-full rounded-lg border border-edge bg-surface-panel p-2`,value:u[t.key]??``,disabled:f,placeholder:t.placeholder,onChange:e=>d(n=>({...n,[t.key]:e.target.value}))})]},t.key)),h?(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:h}):null,(0,$.jsx)(Y,{disabled:f||!v.configured&&v.diagnostics.requiresApiKey&&!Object.values(u).some(e=>e.trim()),onClick:()=>void b(),children:f?e?`保存中…`:`Saving…`:e?`保存连接`:`Save connection`})]}):null]})]})}function Fr(e){let t=(0,rn.c)(40),{label:n,value:r,currentLabel:i,options:a,loading:o,disabled:s,zh:c,onConnect:l,onSelect:u}=e,[d,f]=(0,Q.useState)(``),p;if(t[0]!==a||t[1]!==d){let e=d.trim().toLowerCase().split(/\s+/).filter(Boolean);p=a.filter(t=>{let n=`${t.label} ${t.group} ${t.value} ${t.searchText??``}`.toLowerCase();return e.every(e=>n.includes(e))}),t[0]=a,t[1]=d,t[2]=p}else p=t[2];let m=p,h;if(t[3]!==a||t[4]!==r){let e;t[6]===r?e=t[7]:(e=e=>e.value===r,t[6]=r,t[7]=e),h=a.find(e),t[3]=a,t[4]=r,t[5]=h}else h=t[5];let g=h,_;t[8]!==a||t[9]!==g?.group||t[10]!==r?(_=g?.group??a.find(e=>e.value.split(`/`)[0]===r?.split(`/`)[0])?.group,t[8]=a,t[9]=g?.group,t[10]=r,t[11]=_):_=t[11];let v=_,y;t[12]!==i||t[13]!==g?.label||t[14]!==r||t[15]!==c?(y=g?.label??(r?.endsWith(`/default`)?c?`默认模型`:`Default model`:i??r),t[12]=i,t[13]=g?.label,t[14]=r,t[15]=c,t[16]=y):y=t[16];let b=y,x=v?`${b} · ${v}`:b;if(!o&&!a.length){let e=`${c?`连接`:`Connect`} ${n}`,r=c?`连接服务以启用`:`Connect a service to enable`,i;return t[17]!==s||t[18]!==l||t[19]!==e||t[20]!==r?(i=(0,$.jsx)(Y,{variant:`secondary`,className:`min-h-11 w-full sm:justify-start`,"aria-label":e,disabled:s,onClick:l,children:r}),t[17]=s,t[18]=l,t[19]=e,t[20]=r,t[21]=i):i=t[21],i}let S=r??``,C=c?`选择模型`:`Choose a model`,w=`${c?`选择`:`Select`} ${n}`,T=c?`搜索模型或服务`:`Search models or services`,E=m.length?void 0:c?`没有可用模型`:`No available models`,D;t[22]!==s||t[23]!==m||t[24]!==o||t[25]!==b||t[26]!==u||t[27]!==d||t[28]!==x||t[29]!==S||t[30]!==C||t[31]!==w||t[32]!==T||t[33]!==E?(D=(0,$.jsx)(it,{value:S,options:m,selectedLabel:b,title:x,placeholder:C,ariaLabel:w,allowEmpty:!1,disabled:s,loading:o,onChange:u,searchPlaceholder:T,searchValue:d,onSearchChange:f,statusMessage:E,triggerClassName:`min-h-11`}),t[22]=s,t[23]=m,t[24]=o,t[25]=b,t[26]=u,t[27]=d,t[28]=x,t[29]=S,t[30]=C,t[31]=w,t[32]=T,t[33]=E,t[34]=D):D=t[34];let O;t[35]===v?O=t[36]:(O=v?(0,$.jsx)(`p`,{className:`px-1 text-xs text-fg-muted`,children:v}):null,t[35]=v,t[36]=O);let k;return t[37]!==D||t[38]!==O?(k=(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[D,O]}),t[37]=D,t[38]=O,t[39]=k):k=t[39],k}function Ir({data:e,zh:t,onChange:n,onSettings:r,onlyUse:i,disabled:a=!1,onPendingChange:o}){let{data:s,error:c,mutate:l}=k(`settings-agent-defaults`,G),{data:u}=j(!0),{data:d,isLoading:f,error:p,mutate:m}=k(`model-capability-media-sources`,async()=>{let e=await Promise.allSettled([Bt(),Ut(),$t()]);return{ids:[...new Set(e.flatMap(e=>e.status===`fulfilled`?(Array.isArray(e.value)?e.value:e.value.providers).filter(e=>e.configured).map(e=>e.id):[]))],failed:e.some(e=>e.status===`rejected`)}}),h=[...new Set([...e.cards.filter(t=>t.configured&&(!Re(t.id)||!!e.customConfig?.providers?.[t.id])).map(e=>e.id),...d?.ids??[]])].sort(),{data:g,isLoading:_,mutate:v}=k(e.loading?null:[`model-use-choices`,...h],async()=>{let e=await Promise.allSettled(h.map(Ae));return{previews:e.flatMap(e=>e.status===`fulfilled`&&e.value.configured?[e.value]:[]),failed:e.some(e=>e.status===`rejected`)}},{revalidateOnFocus:!1}),[y,b]=(0,Q.useState)(null),[x,S]=(0,Q.useState)(null),C=(0,Q.useRef)(!1),w=(0,Q.useRef)(null);(0,Q.useEffect)(()=>()=>o?.(!1),[o]);let T=async(e,t)=>{if(C.current||a)return;let n=g?.previews.find(n=>n.uses.some(n=>n.id===e&&n.choices.some(e=>e.id===t)));if(!n)return;C.current=!0,o?.(!0),b(e),S(null);let r={mode:`replace`,selected:[e],overrides:{[e]:t}};try{let t=await re(n.providerId,r);await Ce(n.providerId,r,t.revision),await Promise.all([l(),v()]),S({use:e})}catch(t){S({use:e,error:t instanceof Error?t.message:String(t)}),Promise.allSettled([l(),v()])}finally{C.current=!1,b(null),o?.(!1),requestAnimationFrame(()=>w.current?.querySelector(`[data-capability="${e}"] button[aria-label]`)?.focus())}},E=u?.payload?.config?Gt(u.payload.config):void 0;if(!s&&!c)return(0,$.jsx)(X,{className:`h-48 w-full rounded-xl`});if(c)return(0,$.jsxs)(`div`,{role:`alert`,className:`text-sm text-danger`,children:[t?`模型用途加载失败`:`Could not load model uses`,(0,$.jsx)(Y,{variant:`ghost`,onClick:()=>void l(),children:t?`重试`:`Retry`})]});let D=s.defaults.models,O=D.background?.primary??D.chat.primary,A=e.builtinRows.find(e=>e.id===O.split(`/`)[0])?.setupProfile?.interactiveOnly!==!0,M=g?.previews[0]?.uses.find(e=>e.id===`background`),N=M?M.current:A?O:void 0,P=[{id:`chat`,label:t?`对话与任务`:`Chat and tasks`,ref:D.chat.primary},{id:`vision`,label:t?`看图`:`Image understanding`,ref:D.imageUnderstanding?.primary},{id:`image`,label:t?`画图`:`Image generation`,ref:D.imageGeneration?.primary},{id:`background`,label:t?`后台任务`:`Background tasks`,ref:N,inherited:!D.background&&!!N},{id:`transcription`,label:t?`录音与听写`:`Recording and dictation`,ref:E?.stt.enabled?`${E.stt.provider}/${E.stt.providers?.[E.stt.provider]?.model??`default`}`:void 0},{id:`speech`,label:t?`语音合成`:`Speech synthesis`,ref:E?.tts.enabled?`${E.tts.provider}/${E.tts.providers?.[E.tts.provider]?.model??`default`}`:void 0},{id:`conversation`,label:t?`实时语音对话`:`Realtime conversation`,ref:E?.voice.realtime.enabled?E.voice.realtime.defaultEngine===`omni`&&E.voice.realtime.omni?`${E.voice.realtime.omni.provider}/${E.voice.realtime.omni.model}`:E.voice.realtime.defaultEngine===`agent`?`agent`:void 0:void 0}];return(0,$.jsxs)(`section`,{ref:w,className:`@container min-w-0`,children:[(0,$.jsx)(`h2`,{className:i?`mb-2 text-sm font-semibold text-fg`:`sr-only`,children:i?t?`当前模型`:`Current model`:t?`能力总览`:`Capabilities`}),(0,$.jsx)(`div`,{className:i?`space-y-4`:`overflow-hidden rounded-2xl border border-edge bg-surface-panel`,children:nt.filter(e=>!i||e.uses.includes(i)).map(o=>(0,$.jsxs)(`section`,{className:i?`min-w-0`:`min-w-0 border-t border-edge first:border-t-0`,children:[i?null:(0,$.jsxs)(`div`,{className:`flex items-center justify-between bg-surface-inset/55 px-4 py-2`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-medium text-fg-muted`,children:o.label[+!t]}),(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:o.uses[0]===`chat`?t?`基础能力`:`Core capability`:t?`按需启用`:`Optional`})]}),(0,$.jsx)(`div`,{className:i?`divide-y divide-edge-subtle`:`divide-y divide-edge-subtle px-4`,children:o.uses.filter(e=>!i||e===i).map(o=>{let s=P.find(e=>e.id===o),c=Lr(g?.previews??[],s.id,t),l=s.id===`conversation`&&E?.voice.realtime.enabled&&E.voice.realtime.defaultEngine===`agent`?t?`语音助手 · 使用对话、听写和语音输出配置`:`Voice assistant · Uses chat, dictation and voice output`:s.ref?e.allModels.find(e=>e.id===s.ref)?.name??s.ref:void 0;return(0,$.jsx)(`div`,{"data-capability":s.id,children:(0,$.jsxs)(`div`,{className:i?`py-2`:`grid grid-cols-1 items-center gap-x-3 gap-y-2 py-3 @min-[40rem]:gap-x-4 ${r?`@min-[40rem]:grid-cols-[minmax(0,1fr)_minmax(0,1.35fr)_auto]`:`@min-[40rem]:grid-cols-[minmax(0,1fr)_minmax(0,1.35fr)]`}`,children:[(0,$.jsxs)(`div`,{className:i?`hidden`:`col-start-1 row-start-1 min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:wt[s.id][+!t]}),(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:s.ref?c.some(e=>e.value===s.ref||s.ref?.endsWith(`/default`)&&e.value.split(`/`)[0]===s.ref.split(`/`)[0])||s.ref===`agent`?null:t?`待连接`:`Connection needed`:t?`未配置`:`Not set up`})]}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:Le[s.id][+!t]}),s.inherited?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t?`继承默认对话`:`Inherits chat default`}):null]}),(0,$.jsxs)(`div`,{className:i?`w-full min-w-0 space-y-1`:`row-start-2 w-full min-w-0 space-y-1 @min-[40rem]:col-span-1 @min-[40rem]:col-start-2 @min-[40rem]:row-start-1`,children:[(0,$.jsx)(Fr,{label:wt[s.id][+!t],value:s.ref,currentLabel:l,options:c,loading:e.loading||_||f,disabled:y!==null||a,zh:t,onConnect:()=>n(s.id),onSelect:e=>{e!==s.ref&&T(s.id,e)}}),y===s.id?(0,$.jsx)(`p`,{role:`status`,className:`text-xs text-fg-muted`,children:t?`正在切换…`:`Switching…`}):null,x?.use===s.id?(0,$.jsx)(`div`,{role:x.error?`alert`:`status`,className:`text-xs text-fg-muted`,children:x.error?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`text-danger`,children:t?`未能切换模型,请重试。`:`Could not switch models. Please retry.`}),(0,$.jsxs)(`details`,{className:`mt-1`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer`,children:t?`查看详情`:`Show details`}),(0,$.jsx)(`p`,{className:`mt-1 break-words`,children:x.error})]})]}):t?`已切换`:`Model changed`}):null]}),r&&(c.length>0||_||f)?(0,$.jsxs)(`div`,{className:`row-start-3 flex flex-wrap items-center justify-end gap-1 @min-[40rem]:col-start-3 @min-[40rem]:row-start-1`,children:[(0,$.jsx)(Y,{variant:`ghost`,disabled:y!==null||a,onClick:()=>r(s.id),children:t?`设置`:`Settings`}),(0,$.jsx)(Y,{variant:`ghost`,disabled:y!==null||a,onClick:()=>n(s.id),children:t?`管理服务`:`Manage services`})]}):null]})},s.id)})})]},o.uses[0]))}),(!r||i)&&(g?.failed||d?.failed||p)?(0,$.jsxs)(`p`,{role:`alert`,className:`mt-2 text-xs text-danger`,children:[t?`部分服务的模型加载失败`:`Some model services could not be loaded`,(0,$.jsx)(Y,{variant:`ghost`,onClick:()=>void Promise.all([m(),v()]),children:t?`重试`:`Retry`})]}):null,i||r?null:(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:t?`快速与复杂任务模型随对话配置;音色、流式听写及电脑操作可在详细设置中调整。`:`Fast and complex task models follow chat setup. Voices, streaming dictation and Computer Use have detailed settings.`})]})}function Lr(e,t,n=!1){return e.flatMap(e=>e.uses.find(e=>e.id===t)?.choices.map(t=>({value:t.id,label:t.name,group:W(e.providerId,e.profile.name,n),searchText:e.profile.name}))??[])}function Rr(e){let t=(0,rn.c)(185),{model:n,isNew:r,providerId:i,onSave:a,onClose:o,m:s}=e,c=b(Br)===`zh`,l;t[0]===n?l=t[1]:(l=()=>n?{...n}:De(``),t[0]=n,t[1]=l);let[u,d]=(0,Q.useState)(l),[f,p]=(0,Q.useState)(zr),h;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(h=(e,t)=>{d(n=>({...n,[e]:t})),p(t=>{let n=new Map(t);return n.delete(e),n})},t[2]=h):h=t[2];let _=h,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`),p(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,x;t[12]!==u||t[13]!==o||t[14]!==a||t[15]!==y?(x=()=>{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]=x):x=t[16];let S=x,C=u,T;t[17]===C?T=t[18]:(T=te(C),t[17]=C,t[18]=T);let E=T,O=r?s.addModelTitle:s.editModelTitle,k;t[19]===O?k=t[20]:(k=(0,$.jsx)(D,{className:`text-base font-semibold text-fg`,children:O}),t[19]=O,t[20]=k);let A;t[21]!==s.modelProviderLabel||t[22]!==i?(A=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]=A):A=t[23];let j;t[24]!==k||t[25]!==A?(j=(0,$.jsxs)(`div`,{children:[k,A]}),t[24]=k,t[25]=A,t[26]=j):j=t[26];let M;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(M=g(Se,`p-1.5 hover:bg-surface-base`),t[27]=M):M=t[27];let N;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,$.jsx)(m,{className:`size-4`}),t[28]=N):N=t[28];let P;t[29]===s.close?P=t[30]:(P=(0,$.jsx)(w,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:M,"aria-label":s.close,children:N})}),t[29]=s.close,t[30]=P);let F;t[31]!==j||t[32]!==P?(F=(0,$.jsxs)(`div`,{className:`mb-3 flex shrink-0 items-start justify-between gap-2`,children:[j,P]}),t[31]=j,t[32]=P,t[33]=F):F=t[33];let I;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,$.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`}),t[34]=I):I=t[34];let L;t[35]===s.modelId?L=t[36]:(L=(0,$.jsxs)(`label`,{className:`mb-1 block text-xs font-medium text-fg`,children:[s.modelId,I]}),t[35]=s.modelId,t[36]=L);let R;t[37]===f?R=t[38]:(R=g(V(),f.has(`id`)&&`border-red-500`),t[37]=f,t[38]=R);let z=u.id||``,B;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(B=e=>_(`id`,e.target.value),t[39]=B):B=t[39];let H=!r,U;t[40]!==R||t[41]!==z||t[42]!==H?(U=(0,$.jsx)(`input`,{className:R,value:z,onChange:B,placeholder:`e.g. llama3.1:8b`,disabled:H}),t[40]=R,t[41]=z,t[42]=H,t[43]=U):U=t[43];let W;t[44]===f?W=t[45]:(W=f.has(`id`)?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:f.get(`id`)}):null,t[44]=f,t[45]=W);let ne;t[46]!==L||t[47]!==U||t[48]!==W?(ne=(0,$.jsxs)(`div`,{children:[L,U,W]}),t[46]=L,t[47]=U,t[48]=W,t[49]=ne):ne=t[49];let G;t[50]===s.displayName?G=t[51]:(G=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.displayName}),t[50]=s.displayName,t[51]=G);let K;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(K=V(),t[52]=K):K=t[52];let re=u.name||``,q;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(q=e=>_(`name`,e.target.value),t[53]=q):q=t[53];let ie;t[54]===re?ie=t[55]:(ie=(0,$.jsx)(`input`,{className:K,value:re,onChange:q}),t[54]=re,t[55]=ie);let ae;t[56]!==G||t[57]!==ie?(ae=(0,$.jsxs)(`div`,{children:[G,ie]}),t[56]=G,t[57]=ie,t[58]=ae):ae=t[58];let J;t[59]===s.inputTypes?J=t[60]:(J=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.inputTypes}),t[59]=s.inputTypes,t[60]=J);let oe;t[61]===Symbol.for(`react.memo_cache_sentinel`)?(oe=ee(),t[61]=oe):oe=t[61];let se;t[62]===Symbol.for(`react.memo_cache_sentinel`)?(se=e=>_(`input`,Ct(e.target.value)),t[62]=se):se=t[62];let ce;t[63]===s?ce=t[64]:(ce=Ie.map(e=>(0,$.jsx)(Z,{value:e.value,children:s[e.labelKey]},e.value)),t[63]=s,t[64]=ce);let le;t[65]!==E||t[66]!==ce?(le=(0,$.jsx)(pt,{className:oe,value:E,onChange:se,children:ce}),t[65]=E,t[66]=ce,t[67]=le):le=t[67];let X;t[68]!==J||t[69]!==le?(X=(0,$.jsxs)(`div`,{children:[J,le]}),t[68]=J,t[69]=le,t[70]=X):X=t[70];let ue=u.reasoning||!1,de;t[71]===Symbol.for(`react.memo_cache_sentinel`)?(de=e=>_(`reasoning`,e.target.checked),t[71]=de):de=t[71];let fe;t[72]===ue?fe=t[73]:(fe=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:ue,onChange:de}),t[72]=ue,t[73]=fe);let pe;t[74]!==s.reasoning||t[75]!==fe?(pe=(0,$.jsxs)(`label`,{className:`mt-6 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[fe,s.reasoning]}),t[74]=s.reasoning,t[75]=fe,t[76]=pe):pe=t[76];let me;t[77]!==X||t[78]!==pe?(me=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[X,pe]}),t[77]=X,t[78]=pe,t[79]=me):me=t[79];let he;t[80]===s.contextWindow?he=t[81]:(he=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.contextWindow}),t[80]=s.contextWindow,t[81]=he);let ge;t[82]===f?ge=t[83]:(ge=g(V(),f.has(`contextWindow`)&&`border-red-500`),t[82]=f,t[83]=ge);let _e=u.contextWindow??128e3,ve;t[84]===Symbol.for(`react.memo_cache_sentinel`)?(ve=e=>_(`contextWindow`,parseInt(e.target.value,10)||0),t[84]=ve):ve=t[84];let ye;t[85]!==ge||t[86]!==_e?(ye=(0,$.jsx)(jt,{type:`number`,min:1,className:ge,value:_e,onChange:ve}),t[85]=ge,t[86]=_e,t[87]=ye):ye=t[87];let be;t[88]===f?be=t[89]:(be=f.has(`contextWindow`)?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:f.get(`contextWindow`)}):null,t[88]=f,t[89]=be);let xe;t[90]!==he||t[91]!==ye||t[92]!==be?(xe=(0,$.jsxs)(`div`,{children:[he,ye,be]}),t[90]=he,t[91]=ye,t[92]=be,t[93]=xe):xe=t[93];let Ce;t[94]===s.maxOutputTokens?Ce=t[95]:(Ce=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.maxOutputTokens}),t[94]=s.maxOutputTokens,t[95]=Ce);let we;t[96]===f?we=t[97]:(we=g(V(),f.has(`maxTokens`)&&`border-red-500`),t[96]=f,t[97]=we);let Te=u.maxTokens??16384,Ee;t[98]===Symbol.for(`react.memo_cache_sentinel`)?(Ee=e=>_(`maxTokens`,parseInt(e.target.value,10)||0),t[98]=Ee):Ee=t[98];let Oe;t[99]!==we||t[100]!==Te?(Oe=(0,$.jsx)(jt,{type:`number`,min:1,className:we,value:Te,onChange:Ee}),t[99]=we,t[100]=Te,t[101]=Oe):Oe=t[101];let ke;t[102]===f?ke=t[103]:(ke=f.has(`maxTokens`)?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:f.get(`maxTokens`)}):null,t[102]=f,t[103]=ke);let Ae;t[104]!==Ce||t[105]!==Oe||t[106]!==ke?(Ae=(0,$.jsxs)(`div`,{children:[Ce,Oe,ke]}),t[104]=Ce,t[105]=Oe,t[106]=ke,t[107]=Ae):Ae=t[107];let je;t[108]!==xe||t[109]!==Ae?(je=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[xe,Ae]}),t[108]=xe,t[109]=Ae,t[110]=je):je=t[110];let Me;t[111]===s.costSection?Me=t[112]:(Me=(0,$.jsx)(`p`,{className:`mb-2 text-xs font-semibold text-fg`,children:s.costSection}),t[111]=s.costSection,t[112]=Me);let Ne;t[113]===s.costInput?Ne=t[114]:(Ne=(0,$.jsx)(`label`,{className:`mb-1 block text-xs text-fg-muted`,children:s.costInput}),t[113]=s.costInput,t[114]=Ne);let Pe;t[115]===Symbol.for(`react.memo_cache_sentinel`)?(Pe=V(),t[115]=Pe):Pe=t[115];let Fe=u.cost?.input??0,Le;t[116]===u.cost?Le=t[117]:(Le=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]=Le);let Re;t[118]!==Fe||t[119]!==Le?(Re=(0,$.jsx)(jt,{type:`number`,step:`any`,min:0,className:Pe,value:Fe,onChange:Le}),t[118]=Fe,t[119]=Le,t[120]=Re):Re=t[120];let ze;t[121]!==Ne||t[122]!==Re?(ze=(0,$.jsxs)(`div`,{children:[Ne,Re]}),t[121]=Ne,t[122]=Re,t[123]=ze):ze=t[123];let Be;t[124]===s.costOutput?Be=t[125]:(Be=(0,$.jsx)(`label`,{className:`mb-1 block text-xs text-fg-muted`,children:s.costOutput}),t[124]=s.costOutput,t[125]=Be);let Ve;t[126]===Symbol.for(`react.memo_cache_sentinel`)?(Ve=V(),t[126]=Ve):Ve=t[126];let He=u.cost?.output??0,Ue;t[127]===u.cost?Ue=t[128]:(Ue=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]=Ue);let We;t[129]!==He||t[130]!==Ue?(We=(0,$.jsx)(jt,{type:`number`,step:`any`,min:0,className:Ve,value:He,onChange:Ue}),t[129]=He,t[130]=Ue,t[131]=We):We=t[131];let Ge;t[132]!==Be||t[133]!==We?(Ge=(0,$.jsxs)(`div`,{children:[Be,We]}),t[132]=Be,t[133]=We,t[134]=Ge):Ge=t[134];let Ke;t[135]!==ze||t[136]!==Ge?(Ke=(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[ze,Ge]}),t[135]=ze,t[136]=Ge,t[137]=Ke):Ke=t[137];let qe;t[138]!==Me||t[139]!==Ke?(qe=(0,$.jsxs)(`div`,{className:`border-t border-edge-subtle pt-2 dark:border-edge`,children:[Me,Ke]}),t[138]=Me,t[139]=Ke,t[140]=qe):qe=t[140];let Je;t[141]!==ne||t[142]!==ae||t[143]!==me||t[144]!==je||t[145]!==qe?(Je=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[ne,ae,me,je,qe]}),t[141]=ne,t[142]=ae,t[143]=me,t[144]=je,t[145]=qe,t[146]=Je):Je=t[146];let Ye=c?`高级:电脑控制协议`:`Advanced: Computer Use protocol`,Xe;t[147]===Ye?Xe=t[148]:(Xe=(0,$.jsx)(`summary`,{className:`cursor-pointer`,children:Ye}),t[147]=Ye,t[148]=Xe);let Ze=c?`电脑控制协议`:`Computer Use protocol`,Qe=u.computerUse?.profile??``,$e;t[149]===Symbol.for(`react.memo_cache_sentinel`)?($e=e=>_(`computerUse`,e.target.value?{profile:e.target.value}:void 0),t[149]=$e):$e=t[149];let et=c?`未声明`:`Not declared`,tt;t[150]===et?tt=t[151]:(tt=(0,$.jsx)(Z,{value:``,children:et}),t[150]=et,t[151]=tt);let nt,rt,it;t[152]===Symbol.for(`react.memo_cache_sentinel`)?(nt=(0,$.jsx)(Z,{value:`gui-plus-2026-02-26`,children:`GUI-Plus (2026-02-26)`}),rt=(0,$.jsx)(Z,{value:`structured-tools-v1`,children:`structured-tools-v1`}),it=(0,$.jsx)(Z,{value:`openai-responses-computer-v1`,children:`OpenAI Responses Computer`}),t[152]=nt,t[153]=rt,t[154]=it):(nt=t[152],rt=t[153],it=t[154]);let at;t[155]!==Ze||t[156]!==Qe||t[157]!==tt?(at=(0,$.jsxs)(pt,{"aria-label":Ze,value:Qe,onChange:$e,children:[tt,nt,rt,it]}),t[155]=Ze,t[156]=Qe,t[157]=tt,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.`,st;t[159]===ot?st=t[160]:(st=(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:ot}),t[159]=ot,t[160]=st);let ct;t[161]===f?ct=t[162]:(ct=f.has(`computerUse`)&&(0,$.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:f.get(`computerUse`)}),t[161]=f,t[162]=ct);let lt;t[163]!==at||t[164]!==st||t[165]!==ct?(lt=(0,$.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[at,st,ct]}),t[163]=at,t[164]=st,t[165]=ct,t[166]=lt):lt=t[166];let ut;t[167]!==Xe||t[168]!==lt?(ut=(0,$.jsxs)(`details`,{className:`mt-4 rounded-lg border border-edge p-3 text-sm text-fg`,children:[Xe,lt]}),t[167]=Xe,t[168]=lt,t[169]=ut):ut=t[169];let dt;t[170]!==Je||t[171]!==ut?(dt=(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pr-1`,children:[Je,ut]}),t[170]=Je,t[171]=ut,t[172]=dt):dt=t[172];let ft;t[173]===s.cancel?ft=t[174]:(ft=(0,$.jsx)(w,{asChild:!0,children:(0,$.jsx)(Y,{type:`button`,variant:`secondary`,children:s.cancel})}),t[173]=s.cancel,t[174]=ft);let mt=r?s.addModelConfirm:s.saveModelConfirm,ht;t[175]!==S||t[176]!==mt?(ht=(0,$.jsx)(Y,{type:`button`,variant:`primary`,className:`hover:bg-accent/90`,onClick:S,children:mt}),t[175]=S,t[176]=mt,t[177]=ht):ht=t[177];let gt;t[178]!==ft||t[179]!==ht?(gt=(0,$.jsxs)(`div`,{className:`mt-4 flex shrink-0 justify-end gap-2 border-t border-edge-subtle pt-3 dark:border-edge`,children:[ft,ht]}),t[178]=ft,t[179]=ht,t[180]=gt):gt=t[180];let _t;return t[181]!==F||t[182]!==dt||t[183]!==gt?(_t=(0,$.jsxs)($.Fragment,{children:[F,dt,gt]}),t[181]=F,t[182]=dt,t[183]=gt,t[184]=_t):_t=t[184],_t}function zr(){return new Map}function Br(e){return e.language}function Vr(e){let t=(0,rn.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)(S,{className:g(`xopc-dialog-overlay fixed inset-0 bg-scrim`,Xe)}),t[0]=l):l=t[0];let u;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(u=g(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(90vh,720px)] w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2 flex-col`,st,`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)(Rr,{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)(T,{children:[l,(0,$.jsx)(E,{className:u,onOpenAutoFocus:Hr,children:d})]}),t[10]=d,t[11]=f);let p;return t[12]!==r||t[13]!==n||t[14]!==f?(p=(0,$.jsx)(O,{open:n,onOpenChange:r,children:f}),t[12]=r,t[13]=n,t[14]=f,t[15]=p):p=t[15],p}function Hr(e){return e.preventDefault()}function Ur(e){let t=(0,rn.c)(14),{providerId:n,inputId:r,value:i,onChange:a,labels:o}=e,s;t[0]===n?s=t[1]:(s=()=>vt(n).then(Wr),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)(ct,{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 Wr(e){return e.apiKey??null}function Gr(e){let t=(0,rn.c)(23),{open:n,onOpenChange:r,providerId:i,isCustom:a,builtinRows:o,customConfig:s,allModels:c,labels:l,language:u,onSaved:d}=e,f=(0,Q.useRef)(null),[p,m]=(0,Q.useState)(!1),[h,_]=(0,Q.useState)(null),v;t[0]===r?v=t[1]:(v=e=>{e||(_(null),m(!1)),r(e)},t[0]=r,t[1]=v);let y=v,b;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(S,{className:g(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,Xe)}),t[2]=b):b=t[2];let x,C,w;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(x=()=>{f.current=document.activeElement instanceof HTMLElement?document.activeElement:null},C=e=>{f.current?.isConnected&&(e.preventDefault(),f.current.focus({preventScroll:!0}))},w=g(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(85vh,720px)] w-[calc(100%-2rem)] max-w-lg -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay`,st),t[3]=x,t[4]=C,t[5]=w):(x=t[3],C=t[4],w=t[5]);let D;t[6]!==c||t[7]!==o||t[8]!==s||t[9]!==y||t[10]!==a||t[11]!==l||t[12]!==u||t[13]!==r||t[14]!==d||t[15]!==i||t[16]!==p||t[17]!==h?(D=(0,$.jsxs)(T,{children:[b,(0,$.jsx)(E,{onOpenAutoFocus:x,onCloseAutoFocus:C,className:w,children:h?(0,$.jsx)(rt,{target:h,zh:u===`zh`,onDone:()=>y(!1)}):!a&&p?(0,$.jsx)(Tt,{providerId:i,existingConnection:!0,row:o.find(e=>e.id===i),language:u,onApplied:d,onBack:()=>m(!1),onDone:()=>y(!1)}):a?(0,$.jsx)(qr,{providerId:i,customConfig:s,labels:l,language:u,onClose:()=>r(!1),onSaved:d,onModelAdded:e=>_({providerId:i,modelIds:[e]})}):(0,$.jsx)(Kr,{providerId:i,builtinRows:o,allModels:c,labels:l,language:u,onClose:()=>r(!1),onSaved:d,onQuickSetup:()=>m(!0)})})]}),t[6]=c,t[7]=o,t[8]=s,t[9]=y,t[10]=a,t[11]=l,t[12]=u,t[13]=r,t[14]=d,t[15]=i,t[16]=p,t[17]=h,t[18]=D):D=t[18];let k;return t[19]!==y||t[20]!==n||t[21]!==D?(k=(0,$.jsx)(O,{open:n,onOpenChange:y,children:D}),t[19]=y,t[20]=n,t[21]=D,t[22]=k):k=t[22],k}function Kr({providerId:e,builtinRows:t,allModels:n,labels:r,language:i,onClose:a,onSaved:o,onQuickSetup:s}){let c=t.find(t=>t.id===e),f=I[e],p=n.filter(t=>t.provider===e),[_,v]=(0,Q.useState)(!1),[y,b]=(0,Q.useState)(c?.apiKey??``),[x,S]=(0,Q.useState)(!1),[C,T]=(0,Q.useState)(!1),[E,O]=(0,Q.useState)(null),[k,A]=(0,Q.useState)(!1),j=h(i).providersSettings,M=c?.supportsApiKey!==!1,N=c?.supportsOAuth===!0,P=c?.authMode===`oauth`&&c.authStatus===`connected`,z=c?.configured===!0&&c.activeKeySource!==`env`&&c.activeKeySource!==`extension`&&c.activeKeySource!==`models_json`,[B,V]=(0,Q.useState)(null),[H,U]=(0,Q.useState)(null),[ee,W]=(0,Q.useState)(`idle`),[te,G]=(0,Q.useState)(null),[K,re]=(0,Q.useState)(null),[q,ie]=(0,Q.useState)(null),[ae,oe]=(0,Q.useState)(``),X=(0,Q.useRef)(null),ue=(0,Q.useRef)(null),fe=ee===`waiting`||ee===`waiting_code`,pe=(0,Q.useMemo)(()=>lt(e,i),[e,i]),me=y!==(c?.apiKey??``),he=async()=>{let t=y.trim();if(!(!t||!M||J(t))){S(!0),O(null);try{await _e({[e]:t}),T(!0),window.setTimeout(()=>{o(),a()},600)}catch(e){O(e instanceof Error?e.message:r.saveError)}finally{S(!1)}}};(0,Q.useEffect)(()=>{if(!B||!fe)return;let e=window.setInterval(()=>{(async()=>{try{let t=await At(B);t.status===`waiting_auth`||t.status===`waiting_code`?(W(t.status===`waiting_code`?`waiting_code`:`waiting`),U(t.message??null),G(t.authUrl??null),re(t.instructions??null),ie(t.deviceCode??null),t.authUrl&&t.authUrl!==ue.current&&(ue.current=t.authUrl,le(t.authUrl,X.current).catch(()=>{}))):t.status===`completed`?(window.clearInterval(e),ne(X.current),X.current=null,W(`success`),U(t.message??j.saved),window.setTimeout(()=>{o(),a()},600)):(t.status===`failed`||t.status===`cancelled`)&&(window.clearInterval(e),ne(X.current),X.current=null,W(`error`),U(t.error??t.message??j.revokeFailed))}catch{}})()},1e3);return()=>window.clearInterval(e)},[B,fe,a,o,j.revokeFailed,j.saved]),(0,Q.useEffect)(()=>()=>{B&&Ne(B).catch(()=>{})},[B]),(0,Q.useEffect)(()=>()=>{ne(X.current),X.current=null},[]);let ge=async()=>{try{await Be(e),o(),a()}catch{}},be=async()=>{ne(X.current),X.current=ve(),ue.current=null,W(`waiting`),U(j.oauthStarting),G(null),re(null),ie(null),O(null);try{V((await Ve(e)).sessionId)}catch(e){ne(X.current),X.current=null,W(`error`),U(e instanceof Error?e.message:j.revokeFailed)}},Se=async()=>{if(B){try{await ye(B)}catch{}ne(X.current),X.current=null,ue.current=null,W(`idle`),U(null),V(null),G(null),re(null),ie(null)}},Ce=async()=>{if(!(!B||!ae.trim()))try{await se(B,ae.trim()),oe(``),U(j.oauthProcessingCode)}catch(e){W(`error`),U(e instanceof Error?e.message:j.revokeFailed)}},we=async()=>{try{await L(e),o(),a()}catch(e){O(e instanceof Error?e.message:j.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)(D,{className:`text-base font-semibold text-fg`,children:c?.name??e}),(0,$.jsx)(w,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:g(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,Oe.press),children:(0,$.jsx)(m,{className:`size-4`,"aria-hidden":!0})})})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-4 overflow-y-auto px-5 py-4`,children:[s?(0,$.jsx)(Y,{variant:`secondary`,onClick:s,children:i===`zh`?`配置模型用途`:`Configure model uses`}):null,f?.description?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:f.description}):null,c?.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:c.baseUrl})]}):c?.category===`extension`?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.apiUrlExtensionHint}):null,M?(0,$.jsx)(Ur,{providerId:e,inputId:`manage-api-key`,value:y,onChange:e=>{b(e),T(!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}}):c?.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}),c?.extensionId?(0,$.jsxs)(l,{to:`/settings/ext/${encodeURIComponent(c.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)(d,{className:`size-3`,"aria-hidden":!0})]}):null]}):null,N?(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:j.oauth}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:P?j.sourceOauth:j.oauthHint})]}),P?(0,$.jsx)(Y,{type:`button`,variant:`secondary`,className:`gap-1.5 text-red-600 dark:text-red-400`,onClick:()=>void we(),children:j.revoke}):(0,$.jsxs)(Y,{type:`button`,variant:`primary`,className:`gap-1.5`,disabled:fe,onClick:()=>void be(),children:[fe?(0,$.jsx)(ce,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(R,{className:`size-3.5`,"aria-hidden":!0}),j.oauth]})]}),H?(0,$.jsx)(`p`,{className:g(`text-xs`,ee===`error`?`text-red-600 dark:text-red-400`:`text-fg-muted`),children:H}):null,ee===`waiting`||ee===`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)(d,{className:`size-4`,"aria-hidden":!0}),j.openAuthPage]}):null,(0,$.jsx)(Y,{type:`button`,variant:`secondary`,onClick:()=>void Se(),children:j.cancelOAuth})]}):null,K?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:K}):null,q?(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:j.deviceCodeLabel}),(0,$.jsx)(`code`,{className:`mt-1 block select-all font-mono text-lg font-semibold tracking-widest text-fg`,children:q}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:j.deviceCodeHint})]}):null,ee===`waiting_code`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,$.jsx)(`input`,{type:`text`,value:ae,onChange:e=>oe(e.target.value),onKeyDown:e=>e.key===`Enter`&&void Ce(),placeholder:j.pasteRedirectUrl,className:g(`min-w-0 flex-1 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,de)}),(0,$.jsx)(Y,{type:`button`,variant:`primary`,onClick:()=>void Ce(),children:j.submitCode})]}):null]}):null,pe.length>0&&M?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:pe.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:[xe(e,r),(0,$.jsx)(d,{className:`size-3`,"aria-hidden":!0})]},e))}):null,p.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,` (`,p.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:_,onChange:e=>v(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:p.filter(e=>!_||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:[F(e,i),e.computerUse?` · Computer Use`:``]},e.id))})})]}):(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r.noModels}),E?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:E}):null]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle px-5 py-3`,children:[z?(0,$.jsxs)(Y,{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:()=>A(!0),children:[(0,$.jsx)(Te,{className:`size-3.5`,"aria-hidden":!0}),r.remove]}):(0,$.jsx)(`span`,{}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:M&&me&&!J(y.trim())?(0,$.jsx)(Y,{type:`button`,variant:`primary`,disabled:!y.trim()||x||C,onClick:()=>void he(),children:C?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(u,{className:`size-3.5`,"aria-hidden":!0}),r.saved]}):x?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(ce,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),r.saving]}):r.save}):null})]}),(0,$.jsx)(We,{open:k,title:r.removeConfirmTitle,description:r.removeConfirmDescription.replace(`{{provider}}`,c?.name??e),confirmLabel:r.removeConfirmAction,cancelLabel:r.cancel,destructive:!0,onConfirm:()=>void ge(),onCancel:()=>A(!1)})]})}function qr({providerId:e,customConfig:t,labels:n,language:r,onClose:i,onSaved:a,onModelAdded:o}){let s=h(r).modelsSettings,c=t?.providers[e],[l,u]=(0,Q.useState)(c?.baseUrl??``),[d,f]=(0,Q.useState)(c?.apiKey??``),[_,v]=(0,Q.useState)(c?.models??[]),[y,b]=(0,Q.useState)(!1),[x,S]=(0,Q.useState)(c?.modelDiscovery?.enabled===!0),[C,T]=(0,Q.useState)(!1),[E,O]=(0,Q.useState)(null),[k,A]=(0,Q.useState)(!1),[j,M]=(0,Q.useState)(null),[N,P]=(0,Q.useState)(!1),[F,I]=(0,Q.useState)(null),L=n=>{if(!t)return null;let r=d.trim(),i={...c,baseUrl:l.trim()||void 0,apiKey:J(r)?c?.apiKey:r||void 0,...n};return{providers:{...t.providers,[e]:i}}},R=async()=>{let e=L({models:_,modelDiscovery:{enabled:x}});if(e){T(!0),O(null);try{await dt(e),a(),i()}catch(e){O(e instanceof Error?e.message:n.saveError)}finally{T(!1)}}},z=async()=>{if(t)try{let{[e]:n,...r}=t.providers;await dt({providers:r}),a(),i()}catch{}},B=(e,t)=>{I({model:e,isNew:t}),P(!0)},V=async e=>{if(!F)return;let t=F.isNew&&!_.some(t=>t.id===e.id),r=F.isNew?[..._,e]:_.map(t=>t.id===e.id?e:t);v(r);let i=L({models:r});if(i)try{await dt(i),a(),t&&!e.computerUse&&o(e.id)}catch(e){O(e instanceof Error?e.message:n.saveError)}},H=async e=>{let t=_.filter(t=>t.id!==e);v(t),M(null);let r=L({models:t});if(r)try{await dt(r),a()}catch(e){O(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)(D,{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)(w,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:g(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,Oe.press),children:(0,$.jsx)(m,{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:l,onChange:e=>u(e.target.value),className:g(`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,de)})]}),(0,$.jsx)(Ur,{providerId:e,inputId:`manage-custom-api-key`,value:d,onChange:f,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:x,onChange:e=>S(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:[s.modelsSection,_.length>0?` (${_.length})`:``]}),(0,$.jsxs)(Y,{type:`button`,variant:`primary`,className:`gap-1.5 px-2 py-1 text-xs`,onClick:()=>B(null,!0),children:[(0,$.jsx)(p,{className:`size-3.5`,"aria-hidden":!0}),s.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:y,onChange:e=>b(e.target.checked)}),r===`zh`?`仅电脑控制模型`:`Computer Use only`]}),_.filter(e=>!y||e.computerUse).length===0?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:s.modelsEmpty}):(0,$.jsx)(`ul`,{className:`space-y-2`,children:_.filter(e=>!y||e.computerUse).map(e=>(0,$.jsxs)(`li`,{className:`flex items-center justify-between gap-2 rounded-lg border border-edge-subtle bg-surface-panel/40 px-3 py-2`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:`truncate text-sm font-medium text-fg`,children:e.id}),e.computerUse&&(0,$.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`Computer Use`}),e.name&&e.name!==e.id?(0,$.jsx)(`div`,{className:`truncate text-xs text-fg-muted`,children:e.name}):null]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,$.jsx)(`button`,{type:`button`,className:g(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,Oe.press),onClick:()=>B(e,!1),"aria-label":s.editModel,children:(0,$.jsx)(xt,{className:`size-3.5`,"aria-hidden":!0})}),(0,$.jsx)(`button`,{type:`button`,className:g(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-red-600 dark:hover:text-red-400`,Oe.press),onClick:()=>M(e.id),"aria-label":s.removeModel,children:(0,$.jsx)(Te,{className:`size-3.5`,"aria-hidden":!0})})]})]},e.id))})]}),E?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:E}):null]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle px-5 py-3`,children:[(0,$.jsxs)(Y,{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:()=>A(!0),children:[(0,$.jsx)(Te,{className:`size-3.5`,"aria-hidden":!0}),n.remove]}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,$.jsx)(Y,{type:`button`,variant:`primary`,disabled:C,onClick:()=>void R(),children:C?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(ce,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),n.saving]}):n.save})})]}),(0,$.jsx)(We,{open:k,title:n.removeConfirmTitle,description:n.removeConfirmDescription.replace(`{{provider}}`,e),confirmLabel:n.removeConfirmAction,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>void z(),onCancel:()=>A(!1)}),(0,$.jsx)(We,{open:j!==null,title:s.removeModel,description:s.removeModelConfirm.replace(`{{id}}`,j??``),confirmLabel:n.removeConfirmAction,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>{j&&H(j)},onCancel:()=>M(null)}),(0,$.jsx)(Vr,{open:N,onOpenChange:e=>{P(e),e||I(null)},providerId:e,model:F?.model??null,isNew:F?.isNew??!1,onSave:e=>void V(e),m:s})]})}var Jr=[`fast`,`reasoning`,`coding`,`review`,`vision`,`understanding`],Yr=`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/15`,Xr={en:{fast:[`Fast tasks`,`Short, low-latency work`],reasoning:[`Complex reasoning`,`Planning and multi-step analysis`],coding:[`Coding`,`Implementation and debugging`],review:[`Review`,`Critique and verification`],vision:[`Vision`,`Image and visual analysis`],understanding:[`Understanding`,`Long-form content comprehension`]},zh:{fast:[`快速任务`,`简短、低延迟的工作`],reasoning:[`复杂推理`,`规划和多步骤分析`],coding:[`编程`,`实现、调试和代码修改`],review:[`审查`,`检查、批评和验证`],vision:[`视觉任务`,`图片和视觉内容分析`],understanding:[`内容理解`,`长内容阅读和理解`]}};function Zr(e,t){return{primary:t,fallbacks:e?.fallbacks??[]}}function Qr(e){let t=(0,rn.c)(38),{draft:n,setDraft:r,zh:i,capability:a}=e,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o={revalidateOnFocus:!1},t[0]=o):o=t[0];let s=k(N,M,o),c;t[1]===s.data?c=t[2]:(c=s.data??[],t[1]=s.data,t[2]=c);let l=c,u=i?Xr.zh:Xr.en,d;t[3]!==n||t[4]!==r?(d=(e,t)=>{let i={...n.models.intents};t?i[e]=Zr(i[e],t):delete i[e],r({...n,models:{...n.models,intents:i}})},t[3]=n,t[4]=r,t[5]=d):d=t[5];let f=d,p;t[6]!==a||t[7]!==n||t[8]!==l||t[9]!==s.error||t[10]!==s.isLoading||t[11]!==r||t[12]!==i?(p=a===`chat`?(0,$.jsx)(`section`,{className:`rounded-xl bg-surface-hover/20 p-5`,children:(0,$.jsx)(q,{title:i?`模型回退`:`Model fallbacks`,summary:i?`已配置 ${n.models.chat.fallbacks.length} 个备用模型。`:`${n.models.chat.fallbacks.length} fallback models configured.`,children:(0,$.jsx)(`div`,{className:`mt-6 rounded-xl bg-surface-base/45 p-4`,children:(0,$.jsx)(en,{primary:n.models.chat.primary,value:n.models.chat.fallbacks,models:l,loading:s.isLoading,error:s.error,zh:i,onChange:e=>r({...n,models:{...n.models,chat:{...n.models.chat,fallbacks:e}}})})})})}):null,t[6]=a,t[7]=n,t[8]=l,t[9]=s.error,t[10]=s.isLoading,t[11]=r,t[12]=i,t[13]=p):p=t[13];let m;t[14]!==a||t[15]!==n||t[16]!==r||t[17]!==i?(m=a===`image`?(0,$.jsx)(`section`,{className:`rounded-xl bg-surface-hover/20 p-5`,children:n.models.imageGeneration?(0,$.jsx)(q,{title:i?`图片执行策略`:`Image execution policy`,summary:i?`当前超时与回退策略继续生效。`:`The current timeout and fallback policy remains active.`,children:(0,$.jsxs)(`div`,{className:`mt-5 grid gap-4 rounded-xl bg-surface-base/45 p-4 sm:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[i?`生成超时(毫秒)`:`Generation timeout (ms)`,(0,$.jsx)(jt,{allowEmpty:!0,type:`number`,min:1,className:`${Yr} mt-2`,value:n.models.imageGeneration.timeoutMs??``,onChange:e=>r({...n,models:{...n.models,imageGeneration:{...n.models.imageGeneration,timeoutMs:e.target.value?Number(e.target.value):void 0}}})})]}),(0,$.jsxs)(`div`,{className:`text-xs font-medium text-fg-muted`,children:[(0,$.jsx)(`span`,{children:i?`服务商自动回退`:`Automatic provider fallback`}),(0,$.jsx)(`div`,{className:`mt-1.5 flex rounded-lg bg-surface-panel p-1`,children:[!0,!1].map(e=>(0,$.jsx)(Y,{variant:n.models.imageGeneration?.autoProviderFallback===e?`secondary`:`ghost`,className:`flex-1 py-1.5 text-xs`,onClick:()=>r({...n,models:{...n.models,imageGeneration:{...n.models.imageGeneration,autoProviderFallback:e}}}),children:e?i?`开启`:`On`:i?`关闭`:`Off`},String(e)))})]})]})}):null}):null,t[14]=a,t[15]=n,t[16]=r,t[17]=i,t[18]=m):m=t[18];let h;t[19]!==a||t[20]!==n||t[21]!==l||t[22]!==s.error||t[23]!==s.isLoading||t[24]!==r||t[25]!==i?(h=a===`vision`&&n.models.imageUnderstanding?(0,$.jsx)(q,{title:i?`模型回退`:`Model fallbacks`,summary:i?`主模型不可用时使用已配置的备用模型。`:`Use configured fallback models when the primary is unavailable.`,children:(0,$.jsx)(en,{primary:n.models.imageUnderstanding.primary,value:n.models.imageUnderstanding.fallbacks,models:l.filter($r),loading:s.isLoading,error:s.error,zh:i,onChange:e=>r({...n,models:{...n.models,imageUnderstanding:{...n.models.imageUnderstanding,fallbacks:e}}})})}):null,t[19]=a,t[20]=n,t[21]=l,t[22]=s.error,t[23]=s.isLoading,t[24]=r,t[25]=i,t[26]=h):h=t[26];let g;t[27]!==a||t[28]!==u||t[29]!==n||t[30]!==f||t[31]!==i?(g=a===`chat`?(0,$.jsx)(q,{title:i?`任务模型路由`:`Task model routing`,summary:i?`已配置 ${Object.keys(n.models.intents).length} 类任务路由;其他任务使用默认模型。`:`${Object.keys(n.models.intents).length} task routes configured; other tasks use the default model.`,children:(0,$.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 p-5`,children:[(0,$.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:i?`按任务选择模型`:`Route by task`}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:i?`仅在确实需要不同模型时设置;否则保持“使用默认对话模型”。`:`Set a route only when a task genuinely needs another model; otherwise keep the default.`}),(0,$.jsx)(`div`,{className:`mt-5 grid gap-3 lg:grid-cols-2`,children:Jr.map(e=>(0,$.jsxs)(`div`,{className:`rounded-xl bg-surface-base/55 p-4`,children:[(0,$.jsxs)(`div`,{className:`mb-3`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:u[e][0]}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:u[e][1]})]}),(0,$.jsx)(je,{value:n.models.intents[e]?.primary??``,placeholder:i?`使用默认对话模型`:`Use default conversation model`,searchPlaceholder:i?`搜索模型或服务商`:`Search models or providers`,noMatches:i?`没有匹配的模型`:`No matching models`,allowEmpty:!0,emptyLabel:i?`使用默认对话模型`:`Use default conversation model`,showProviderInTrigger:!1,contentAlign:`start`,className:`w-full`,ariaLabel:i?`${u[e][0]}模型`:`${u[e][0]} model`,onChange:t=>f(e,t)})]},e))})]})}):null,t[27]=a,t[28]=u,t[29]=n,t[30]=f,t[31]=i,t[32]=g):g=t[32];let _;return t[33]!==p||t[34]!==m||t[35]!==h||t[36]!==g?(_=(0,$.jsxs)(`div`,{className:`space-y-5`,children:[p,m,h,g]}),t[33]=p,t[34]=m,t[35]=h,t[36]=g,t[37]=_):_=t[37],_}function $r(e){return e.vision}function ei(e){let t=(0,rn.c)(9),{data:n,error:r}=k(`settings-agent-defaults`,G);if(r&&!n){let e=String(r),n;return t[0]===e?n=t[1]:(n=(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:e}),t[0]=e,t[1]=n),n}if(!n){let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(X,{className:`h-32 rounded-xl`}),t[2]=e):e=t[2],e}let i;t[3]===n.defaults.models?i=t[4]:(i=JSON.stringify(n.defaults.models),t[3]=n.defaults.models,t[4]=i);let a;return t[5]!==n.defaults||t[6]!==e||t[7]!==i?(a=(0,$.jsx)(ti,{...e,initial:n.defaults},i),t[5]=n.defaults,t[6]=e,t[7]=i,t[8]=a):a=t[8],a}function ti(e){let t=(0,rn.c)(36),{initial:n,capability:r,zh:i,disabled:a,onPendingChange:o}=e,s;t[0]===n?s=t[1]:(s=()=>structuredClone(n),t[0]=n,t[1]=s);let[c,l]=(0,Q.useState)(s),u;t[2]===n?u=t[3]:(u=()=>structuredClone(n),t[2]=n,t[3]=u);let[d,f]=(0,Q.useState)(u),p;t[4]===c.models?p=t[5]:(p=JSON.stringify(c.models),t[4]=c.models,t[5]=p);let m;t[6]===d.models?m=t[7]:(m=JSON.stringify(d.models),t[6]=d.models,t[7]=m);let h=p!==m,g;t[8]!==n.models||t[9]!==i?(g=async e=>{let t=await G();if(JSON.stringify(t.defaults.models)!==JSON.stringify(n.models))throw Error(i?`模型设置已变化,请刷新后重试。`:`Model settings changed. Refresh before retrying.`);f((await ue({...t.defaults,models:e.models},{scope:`models`,expectedModels:n.models})).defaults),await Ge()},t[8]=n.models,t[9]=i,t[10]=g):g=t[10];let _=g,v;t[11]!==h||t[12]!==c||t[13]!==_?(v={value:c,dirty:h,onSave:_,delayMs:0},t[11]=h,t[12]=c,t[13]=_,t[14]=v):v=t[14];let y=Lt(v),b=h||y.status===`saving`||!!y.error,x,S;t[15]!==o||t[16]!==b?(x=()=>(o(b),()=>o(!1)),S=[b,o],t[15]=o,t[16]=b,t[17]=x,t[18]=S):(x=t[17],S=t[18]),(0,Q.useEffect)(x,S);let C=a||y.status===`saving`,w;t[19]!==y.error||t[20]!==y.status?(w=(0,$.jsx)(It,{status:y.status,error:y.error}),t[19]=y.error,t[20]=y.status,t[21]=w):w=t[21];let T;t[22]!==y.error||t[23]!==y.retry||t[24]!==i?(T=y.error?(0,$.jsx)(Y,{variant:`secondary`,onClick:y.retry,children:i?`重试保存`:`Retry saving`}):null,t[22]=y.error,t[23]=y.retry,t[24]=i,t[25]=T):T=t[25];let E;t[26]!==r||t[27]!==c||t[28]!==i?(E=(0,$.jsx)(Qr,{capability:r,draft:c,setDraft:l,zh:i}),t[26]=r,t[27]=c,t[28]=i,t[29]=E):E=t[29];let D;return t[30]!==y.onBlurCapture||t[31]!==w||t[32]!==T||t[33]!==E||t[34]!==C?(D=(0,$.jsxs)(`fieldset`,{disabled:C,onBlurCapture:y.onBlurCapture,className:`min-w-0 space-y-3`,children:[w,T,E]}),t[30]=y.onBlurCapture,t[31]=w,t[32]=T,t[33]=E,t[34]=C,t[35]=D):D=t[35],D}function ni(e){return e.status===`ready`?`ready`:e.status===`disabled`?`off`:e.status===`degraded`?`degraded`:e.rejected?.length?`misconfigured`:`not-configured`}function ri(e,t){if(e.startsWith(`agentCatalog.defaults.models`))return{label:t?`模型与能力`:`Models and capabilities`,href:`/settings/capabilities/models`};let n=e.match(/^agentCatalog\.agents\.([^.]+)\.models/);return n?.[1]?{label:t?`智能体 ${n[1]}`:`Agent ${n[1]}`,href:he(n[1])}:e.startsWith(`sessions.`)?{label:t?`会话模型覆盖`:`Session model override`,href:`/settings/sessions`}:{label:e,href:`/settings/agent-defaults`}}function ii(e,t){switch(e){case`computer-use`:return{guidance:t?`选择兼容的电脑控制模型;本机权限需单独授权`:`Select a compatible computer model; local access requires separate approval`,action:t?`配置电脑控制`:`Configure computer use`};case`vision`:return{guidance:t?`接入支持图片理解的模型服务`:`Connect a model service that supports vision`,action:t?`去接入模型`:`Connect model`};case`image-generation`:return{guidance:t?`选择图片模型并配置所需凭据`:`Choose an image model and configure its credentials`,action:t?`去配置图片生成`:`Configure image generation`};case`stt`:return{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{guidance:t?`选择语音合成服务并完成凭据配置`:`Choose a text-to-speech service and configure its credentials`,action:t?`去配置语音合成`:`Configure text-to-speech`}}}async function ai(){let e=await y(x(`/api/models/catalog`)),t=await e.json().catch(()=>null);if(!e.ok||!t?.ok||!t.payload)throw Error(t?.error?.message??`HTTP ${e.status}`);return t.payload}async function oi(){let e=await y(x(`/api/capabilities/readiness`)),t=await e.json().catch(()=>null);if(!e.ok||!t?.ok||!t.payload)throw Error(t?.error?.message??`HTTP ${e.status}`);return t.payload}function si({showCapabilities:e=!0}={}){let t=b(e=>e.language)===`zh`,{data:n,error:r,isLoading:i}=k(Ke,ai,{revalidateOnFocus:!0,refreshInterval:6e4}),{data:a}=k(me,oi,{revalidateOnFocus:!1}),[o,s]=(0,Q.useState)(!1),[c,d]=(0,Q.useState)(null),f=Object.values(n?.sources??{}),p=f.reduce((e,t)=>e+t.models.filter(e=>e.availability===`available`).length,0),m=(n?.references??[]).filter(e=>e.availability===`unavailable`),h=n?.sync.lastSuccessAt??Math.max(0,...f.map(e=>e.lastSuccessAt)),_=!!r,v=n?.sync.sourceErrors??{},S=[...n?.sync.lastError?[[`catalog`,n.sync.lastError]]:[],...Object.entries(v),...c?[[`refresh`,c]]:[],...r instanceof Error?[[`load`,r.message]]:[]],C=n?.sync.lastAttemptAt??h,w=Object.entries(a?.capabilities??{}).filter(([e])=>e!==`computer-use`||yt()),T=w.some(([,e])=>{let t=ni(e);return t===`degraded`||t===`misconfigured`}),E=w.filter(([,e])=>ni(e)===`ready`).length,D=(0,Q.useRef)(null);if((0,Q.useEffect)(()=>{T&&!i&&D.current?.setAttribute(`open`,``)},[T,i]),i)return(0,$.jsx)(X,{className:`h-24 w-full rounded-2xl`});let O=async()=>{s(!0),d(null);try{let e=await y(x(`/api/models/catalog/refresh`),{method:`POST`});if(!e.ok)throw Error(`HTTP ${e.status}`);await Ge()}catch(e){d(e instanceof Error?e.message:String(e))}finally{s(!1)}};return(0,$.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/25 p-4 sm:p-5`,children:[e?(0,$.jsxs)(`details`,{ref:D,className:`group`,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:[T?(0,$.jsx)(H,{className:`size-4 text-amber-500`,"aria-hidden":!0}):E===w.length&&w.length>0?(0,$.jsx)(u,{className:`size-4 text-emerald-500`,"aria-hidden":!0}):(0,$.jsx)(ht,{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:t?`可选能力`:`Optional capabilities`}),(0,$.jsx)(`span`,{className:`mt-0.5 block text-xs font-normal text-fg-muted`,children:t?`${E}/${w.length} 项已配置,不影响基础聊天功能`:`${E} of ${w.length} configured · Not required for chat`})]}),(0,$.jsx)($e,{className:`size-4 shrink-0 text-fg-subtle transition-transform group-open:rotate-90 motion-reduce:transition-none`,"aria-hidden":!0})]})}),a?(0,$.jsx)(`div`,{className:`mt-3 grid gap-1 sm:grid-cols-2`,children:Object.entries(a.capabilities).map(([e,n])=>{if(e===`computer-use`&&!yt())return null;let r=e===`vision`?t?`图片理解`:`Vision`:e===`image-generation`?t?`图片生成`:`Image generation`:e===`computer-use`?t?`电脑控制模型`:`Computer use model`:e.toUpperCase(),i=n.selectionSource!==`explicit-config`,a=ni(n),o=a===`degraded`||a===`misconfigured`,s=ii(e,t),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`?e===`computer-use`?t?`已配置`:`Configured`:t?`可用`:`Ready`:a===`off`?t?`已关闭`:`Off`:a===`not-configured`?t?`未配置`:`Not configured`:a===`degraded`?t?`正在使用备用方案`:`Using fallback`:t?`需处理`:`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?t?`自动`:`Auto`:t?`显式`:`Explicit`} · ${n.primary.provider}/${n.primary.model}`:a===`not-configured`?t?`可稍后按需配置`:`Set up later if needed`:t?`已配置的模型不可用`:`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`?t?`当前配置不可用,正在使用备用方案。${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)(z,{className:`size-3.5`,"aria-hidden":!0})]})]}):null]}),u={"aria-label":o?`${r}:${s.action}`:`${t?`配置`:`Configure`} ${r}`,className:g(`rounded-lg bg-surface-base/45 px-3 py-3 text-left 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`)};if(e===`computer-use`)return(0,$.jsx)(l,{to:`/settings/computer-use`,...u,children:c},e);let d={vision:`vision`,"image-generation":`image`,stt:`transcription`,tts:`speech`}[e];return(0,$.jsx)(`button`,{type:`button`,"aria-haspopup":`dialog`,...u,onClick:()=>mt(d,o?`services`:`settings`),children:c},e)})}):null]}):null,m.length>0?(0,$.jsx)(`div`,{className:`mt-3 space-y-2`,"aria-live":`polite`,children:m.map(e=>(0,$.jsx)(`div`,{className:`rounded-lg border border-amber-500/25 bg-amber-500/5 p-3`,children:(()=>{let n=!!v[e.ref.split(`/`)[0]??``],r=ri(e.locations[0]??``,t);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(H,{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:[e.ref,(0,$.jsx)(`span`,{className:`ml-2 font-normal text-amber-700 dark:text-amber-300`,children:n?t?`暂时无法验证`:`Temporarily unverified`:t?`不可用`:`Unavailable`})]}),(0,$.jsxs)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:[n?t?`模型目录同步暂时失败,当前状态可能已过期;不会影响其他可用模型。`:`Catalog sync temporarily failed, so this status may be stale. Other available models are unaffected.`:t?`此模型已无法从当前配置中解析,使用它的功能可能失败。`:`This model no longer resolves from the current configuration. Features using it may fail.`,C?` · ${t?`最近检测`:`Last checked`} ${new Date(C).toLocaleString()}`:``]}),e.suggestedRef?(0,$.jsxs)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[t?`可替换为`:`Suggested replacement`,`:`,(0,$.jsx)(`span`,{className:`font-medium text-fg`,children:e.suggestedRef})]}):null]})]}),(0,$.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1`,children:[(0,$.jsxs)(Y,{className:`px-2.5 py-1.5 text-xs`,variant:`ghost`,disabled:o,onClick:()=>void O(),children:[o?(0,$.jsx)(ce,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(tt,{className:`size-3.5`,"aria-hidden":!0}),o?t?`检测中…`:`Checking…`:t?`重新检测`:`Check again`]}),(0,$.jsx)(Y,{asChild:!0,className:`px-2.5 py-1.5 text-xs`,variant:`ghost`,children:(0,$.jsxs)(l,{to:r.href,children:[(0,$.jsx)(Ye,{className:`size-3.5`,"aria-hidden":!0}),e.suggestedRef?t?`更换模型`:`Replace model`:t?`调整配置`:`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:[t?`查看 ${e.locations.length} 处引用`:`View ${e.locations.length} ${e.locations.length===1?`reference`:`references`}`,(0,$.jsx)($e,{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:e.locations.map(e=>{let n=ri(e,t);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:e,children:n.label})},e)})})]})]})]})})()},e.ref))}):null,_||c?(0,$.jsx)(`p`,{className:`mt-3 text-sm text-danger`,role:`alert`,children:_?t?`暂时无法读取模型状态,请重新检测;详细信息可在高级诊断中查看。`:`Model status is temporarily unavailable. Check again; details are available in Advanced diagnostics.`:t?`重新检测失败,请稍后重试;详细信息可在高级诊断中查看。`:`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:t?`高级诊断`:`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:t?`${f.length} 个来源,${p} 个可用模型${h?` · 最近同步 ${new Date(h).toLocaleString()}`:``}`:`${f.length} sources, ${p} available models${h?` · Last synced ${new Date(h).toLocaleString()}`:``}`}),S.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":t?`同步错误详情`:`Sync error details`,children:S.map(([e,t],n)=>(0,$.jsxs)(`p`,{className:`break-words`,children:[e,`: `,t]},`${e}-${n}`))}):null]}),(0,$.jsxs)(Y,{className:`shrink-0`,type:`button`,variant:`secondary`,disabled:o,onClick:()=>void O(),children:[o?(0,$.jsx)(ce,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(tt,{className:`size-4`,"aria-hidden":!0}),o?t?`刷新中…`:`Refreshing…`:t?`刷新目录`:`Refresh catalog`]})]})]})]})}function ci(e){let t=(0,rn.c)(167),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{inlineUse:r,inlineView:i,onViewChange:u,onPendingChange:d}=n,f=i===void 0?`settings`:i,p=b(fi),m=p===`zh`,g;t[2]===p?g=t[3]:(g=h(p),t[2]=p,t[3]=g);let _=g.capabilitiesSettings,{capability:v}=s(),[y,x]=o(),{state:S}=a(),C;t[4]===y?C=t[5]:(C=Fe(y.get(`returnTo`)),t[4]=y,t[5]=C);let w=C,[T,E]=(0,Q.useState)(),[D,O]=(0,Q.useState)(!1),[k,A]=(0,Q.useState)(!1),[j,M]=(0,Q.useState)(!1),[N,P]=(0,Q.useState)(!1),F=j||N||k,[I,L]=(0,Q.useState)(!1),[R,z]=(0,Q.useState)(null),V=(0,Q.useRef)(null),H=bt(),U=di,ee,W;t[6]!==d||t[7]!==F?(ee=()=>(d?.(F),()=>d?.(!1)),W=[F,d],t[6]=d,t[7]=F,t[8]=ee,t[9]=W):(ee=t[8],W=t[9]),(0,Q.useEffect)(ee,W);let te,ne;t[10]!==v||t[11]!==r||t[12]!==S||t[13]!==y||t[14]!==x?(te=()=>{if(r||v!==`models`)return;let e=B(y.get(`configure`));if(!e&&y.get(`add`)!==`1`)return;let t=window.setTimeout(()=>{e?mt(e,y.get(`tab`)===`services`?`services`:`settings`):L(!0);let t=new URLSearchParams(y);t.delete(`configure`),t.delete(`tab`),t.delete(`add`),x(t,{replace:!0,state:S})},0);return()=>window.clearTimeout(t)},ne=[v,r,y,x,S],t[10]=v,t[11]=r,t[12]=S,t[13]=y,t[14]=x,t[15]=te,t[16]=ne):(te=t[15],ne=t[16]),(0,Q.useEffect)(te,ne);let G;t[17]!==r||t[18]!==u||t[19]!==F?(G=e=>{if(!F){if(!r){mt(e,`services`);return}u?.(`services`),E(void 0)}},t[17]=r,t[18]=u,t[19]=F,t[20]=G):G=t[20];let K=G,re;t[21]===u?re=t[22]:(re=e=>{U(),u?.(`settings`),E(e)},t[21]=u,t[22]=re);let q=re;if(r){let e=f===`services`,n=N||k,i;t[23]!==r||t[24]!==K||t[25]!==H||t[26]!==n||t[27]!==m?(i=(0,$.jsx)(Ir,{data:H,zh:m,onlyUse:r,disabled:n,onPendingChange:M,onChange:K}),t[23]=r,t[24]=K,t[25]=H,t[26]=n,t[27]=m,t[28]=i):i=t[28];let a;t[29]!==e||t[30]!==i?(a=(0,$.jsx)(`div`,{hidden:e,children:i}),t[29]=e,t[30]=i,t[31]=a):a=t[31];let o;t[32]!==T||t[33]!==r||t[34]!==f||t[35]!==m?(o=T===r&&f===`settings`?(0,$.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:m?`服务设置已保存`:`Service settings saved`}):null,t[32]=T,t[33]=r,t[34]=f,t[35]=m,t[36]=o):o=t[36];let s=f!==`services`,c;t[37]!==q||t[38]!==r?(c=()=>q(r),t[37]=q,t[38]=r,t[39]=c):c=t[39];let l;t[40]!==_.addProviderDialog||t[41]!==r||t[42]!==p||t[43]!==H||t[44]!==c?(l=(0,$.jsx)(wr,{inline:!0,onEditingChange:O,use:r,data:H,language:p,labels:_.addProviderDialog,onPendingChange:A,onSaved:c},r),t[40]=_.addProviderDialog,t[41]=r,t[42]=p,t[43]=H,t[44]=c,t[45]=l):l=t[45];let u;t[46]!==q||t[47]!==D||t[48]!==r||t[49]!==H||t[50]!==m?(u=r===`transcription`||r===`speech`?(0,$.jsx)(`div`,{hidden:D,children:(0,$.jsx)(Pr,{kind:r===`transcription`?`stt`:`tts`,modelServiceIds:H.builtinRows.map(ui),zh:m,onPendingChange:A,onSaved:()=>q(r)},r)}):null,t[46]=q,t[47]=D,t[48]=r,t[49]=H,t[50]=m,t[51]=u):u=t[51];let d;t[52]!==q||t[53]!==r?(d=r===`image`?(0,$.jsx)(bn,{connectOnly:!0,onPendingChange:A,onConnected:()=>q(r)}):null,t[52]=q,t[53]=r,t[54]=d):d=t[54];let h;t[55]!==k||t[56]!==s||t[57]!==l||t[58]!==u||t[59]!==d?(h=(0,$.jsxs)(`fieldset`,{hidden:s,disabled:k,className:`min-w-0 space-y-3`,children:[l,u,d]}),t[55]=k,t[56]=s,t[57]=l,t[58]=u,t[59]=d,t[60]=h):h=t[60];let g=f===`services`,v;t[61]!==k||t[62]!==r||t[63]!==j?(v=r===`transcription`||r===`speech`||r===`conversation`?(0,$.jsx)(Jn,{capability:r,onPendingChange:P,disabled:j||k},r):null,t[61]=k,t[62]=r,t[63]=j,t[64]=v):v=t[64];let y;t[65]!==k||t[66]!==r||t[67]!==j||t[68]!==m?(y=r===`chat`||r===`vision`||r===`image`?(0,$.jsx)(ei,{capability:r,zh:m,disabled:j||k,onPendingChange:P}):null,t[65]=k,t[66]=r,t[67]=j,t[68]=m,t[69]=y):y=t[69];let b;t[70]!==r||t[71]!==m?(b=r===`background`?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:m?`使用所选模型执行自动化、定时和无人值守任务。此设置不会启用任务,也不会自动改用其他计费服务。`:`Use the selected model for automations, schedules and unattended tasks. This does not enable tasks or automatically switch billing services.`}):null,t[70]=r,t[71]=m,t[72]=b):b=t[72];let x;t[73]!==g||t[74]!==v||t[75]!==y||t[76]!==b?(x=(0,$.jsxs)(`div`,{hidden:g,className:`space-y-4`,children:[v,y,b]}),t[73]=g,t[74]=v,t[75]=y,t[76]=b,t[77]=x):x=t[77];let S;t[78]!==K||t[79]!==o||t[80]!==h||t[81]!==x?(S=(0,$.jsxs)(Cn.Provider,{value:K,children:[o,h,x]}),t[78]=K,t[79]=o,t[80]=h,t[81]=x,t[82]=S):S=t[82];let C;return t[83]!==a||t[84]!==S?(C=(0,$.jsxs)(`div`,{className:`min-w-0 space-y-4`,children:[a,S]}),t[83]=a,t[84]=S,t[85]=C):C=t[85],C}if(v===`search`){let e;t[86]===p?e=t[87]:(e=h(p),t[86]=p,t[87]=e);let n;t[88]===e.nav.settingsSearch?n=t[89]:(n=(0,$.jsx)(Mt,{title:e.nav.settingsSearch}),t[88]=e.nav.settingsSearch,t[89]=n);let r;t[90]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(br,{}),t[90]=r):r=t[90];let i;return t[91]===n?i=t[92]:(i=(0,$.jsxs)(Nt,{children:[n,r]}),t[91]=n,t[92]=i),i}if(v!==`models`){let e;return t[93]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(c,{to:`/settings/capabilities/models`,replace:!0}),t[93]=e):e=t[93],e}let ie=m?`模型与能力`:`Models and capabilities`,ae=m?`按用途选择模型,在设置中调整参数与服务连接。`:`Choose models by purpose. Adjust parameters and connections in settings.`,J;t[94]===p?J=t[95]:(J=et(p,`configuration`),t[94]=p,t[95]=J);let oe;t[96]!==_.docsLink||t[97]!==J?(oe=(0,$.jsx)(`a`,{href:J,target:`_blank`,rel:`noreferrer`,className:`inline-flex min-h-11 items-center rounded-lg px-2 text-xs text-fg-muted hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:_.docsLink}),t[96]=_.docsLink,t[97]=J,t[98]=oe):oe=t[98];let se;t[99]===Symbol.for(`react.memo_cache_sentinel`)?(se=()=>{V.current?.scrollIntoView?.({block:`start`}),V.current?.focus({preventScroll:!0})},t[99]=se):se=t[99];let ce=m?`服务账户`:`Service accounts`,le;t[100]!==F||t[101]!==ce?(le=(0,$.jsx)(Y,{variant:`secondary`,disabled:F,onClick:se,children:ce}),t[100]=F,t[101]=ce,t[102]=le):le=t[102];let X;t[103]!==oe||t[104]!==le?(X=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[oe,le]}),t[103]=oe,t[104]=le,t[105]=X):X=t[105];let ue;t[106]!==ie||t[107]!==ae||t[108]!==X?(ue=(0,$.jsx)(Mt,{title:ie,subtitle:ae,actions:X}),t[106]=ie,t[107]=ae,t[108]=X,t[109]=ue):ue=t[109];let de;t[110]!==w||t[111]!==m?(de=w?(0,$.jsx)(l,{to:w,className:`text-sm text-accent-fg hover:underline`,children:m?`返回`:`Back`}):null,t[110]=w,t[111]=m,t[112]=de):de=t[112];let fe;t[113]===F?fe=t[114]:(fe=e=>{F||mt(e)},t[113]=F,t[114]=fe);let pe;t[115]!==K||t[116]!==H||t[117]!==F||t[118]!==fe||t[119]!==m?(pe=(0,$.jsx)(Ir,{data:H,zh:m,disabled:F,onPendingChange:M,onChange:K,onSettings:fe}),t[115]=K,t[116]=H,t[117]=F,t[118]=fe,t[119]=m,t[120]=pe):pe=t[120];let me=m?`连接的服务`:`Connected services`,he;t[121]===me?he=t[122]:(he=(0,$.jsx)(`h2`,{id:`model-services-heading`,className:`text-base font-semibold text-fg`,children:me}),t[121]=me,t[122]=he);let ge=m?`在这里管理账户和密钥;各项能力的模型与参数在上方调整。`:`Manage accounts and keys here. Choose models and adjust capability settings above.`,_e;t[123]===ge?_e=t[124]:(_e=(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:ge}),t[123]=ge,t[124]=_e);let ve;t[125]!==he||t[126]!==_e?(ve=(0,$.jsxs)(`div`,{children:[he,_e]}),t[125]=he,t[126]=_e,t[127]=ve):ve=t[127];let ye;t[128]!==_.xopcCloudAccount||t[129]!==H.cards?(ye=H.cards.some(li)?(0,$.jsx)(nn,{labels:_.xopcCloudAccount}):null,t[128]=_.xopcCloudAccount,t[129]=H.cards,t[130]=ye):ye=t[130];let be,xe;t[131]===Symbol.for(`react.memo_cache_sentinel`)?(be=()=>L(!0),xe=(e,t)=>z({providerId:e,isCustom:t}),t[131]=be,t[132]=xe):(be=t[131],xe=t[132]);let Se;t[133]!==_.connectedProviders||t[134]!==H?(Se=(0,$.jsx)(Ze,{labels:_.connectedProviders,data:H,onAdd:be,onManage:xe}),t[133]=_.connectedProviders,t[134]=H,t[135]=Se):Se=t[135];let Ce;t[136]===H.cards.length?Ce=t[137]:(Ce=H.cards.length>0?(0,$.jsx)(si,{showCapabilities:!1}):null,t[136]=H.cards.length,t[137]=Ce);let we;t[138]===m?we=t[139]:(we=yt()?(0,$.jsx)(l,{className:`inline-block text-sm text-accent-fg hover:underline`,to:`/settings/computer-use`,children:m?`电脑操作设置`:`Computer use settings`}):null,t[138]=m,t[139]=we);let Te;t[140]!==ve||t[141]!==ye||t[142]!==Se||t[143]!==Ce||t[144]!==we?(Te=(0,$.jsxs)(`section`,{ref:V,tabIndex:-1,"aria-labelledby":`model-services-heading`,className:`space-y-4 scroll-mt-4 rounded-xl focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[ve,ye,Se,Ce,we]}),t[140]=ve,t[141]=ye,t[142]=Se,t[143]=Ce,t[144]=we,t[145]=Te):Te=t[145];let Ee;t[146]===Symbol.for(`react.memo_cache_sentinel`)?(Ee=()=>{U(),L(!1)},t[146]=Ee):Ee=t[146];let De;t[147]!==I||t[148]!==_.addProviderDialog||t[149]!==p||t[150]!==H.builtinRows||t[151]!==H.customConfig?(De=(0,$.jsx)(Dt,{open:I,connectOnly:!0,onOpenChange:L,builtinRows:H.builtinRows,customConfig:H.customConfig,labels:_.addProviderDialog,language:p,onSaved:Ee}),t[147]=I,t[148]=_.addProviderDialog,t[149]=p,t[150]=H.builtinRows,t[151]=H.customConfig,t[152]=De):De=t[152];let Oe;t[153]!==_.manageProviderDialog||t[154]!==p||t[155]!==R||t[156]!==H.allModels||t[157]!==H.builtinRows||t[158]!==H.customConfig?(Oe=R?(0,$.jsx)(Gr,{open:!0,onOpenChange:e=>{e||z(null)},providerId:R.providerId,isCustom:R.isCustom,builtinRows:H.builtinRows,customConfig:H.customConfig,allModels:H.allModels,labels:_.manageProviderDialog,language:p,onSaved:U}):null,t[153]=_.manageProviderDialog,t[154]=p,t[155]=R,t[156]=H.allModels,t[157]=H.builtinRows,t[158]=H.customConfig,t[159]=Oe):Oe=t[159];let ke;return t[160]!==ue||t[161]!==de||t[162]!==pe||t[163]!==Te||t[164]!==De||t[165]!==Oe?(ke=(0,$.jsxs)(Nt,{children:[ue,de,pe,Te,De,Oe]}),t[160]=ue,t[161]=de,t[162]=pe,t[163]=Te,t[164]=De,t[165]=Oe,t[166]=ke):ke=t[166],ke}function li(e){return e.id===`xopc-cloud`&&!e.isCustom}function ui(e){return e.id}function di(){Ge()}function fi(e){return e.language}export{ci as CapabilitiesSettingsPanel};
@@ -0,0 +1 @@
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{Cs as i,Hc as a,Ss as o,Ts as s,W as c,eu as l,ws as u}from"./index-CKdOZoVu.js";var d=n(),f=e(t(),1),p=r(),m=(0,f.memo)(function(e){let t=(0,d.c)(8),{value:n,onChange:r,placeholder:i,ariaLabel:a}=e,o=a===void 0?i:a,s;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(s=(0,p.jsx)(l,{className:`pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[0]=s):s=t[0];let c;t[1]===r?c=t[2]:(c=e=>r(e.currentTarget.value),t[1]=r,t[2]=c);let u;return t[3]!==o||t[4]!==i||t[5]!==c||t[6]!==n?(u=(0,p.jsxs)(`label`,{className:`relative flex h-11 min-w-0 w-full cursor-text items-center rounded-xl border border-edge bg-surface-base pl-9 pr-3 text-fg shadow-none focus-within:border-accent/60 focus-within:ring-2 focus-within:ring-accent/30 md:h-9`,children:[s,(0,p.jsx)(`input`,{type:`search`,"aria-label":o,enterKeyHint:`search`,value:n,onChange:c,placeholder:i,autoComplete:`off`,spellCheck:!1,className:`min-w-0 flex-1 appearance-none border-0 bg-transparent text-base leading-normal text-fg caret-current placeholder:text-fg-muted focus:border-0 focus:shadow-none focus:outline-none focus:ring-0 md:text-sm`})]}),t[3]=o,t[4]=i,t[5]=c,t[6]=n,t[7]=u):u=t[7],u});function h(e){let t=(0,d.c)(8),{contribution:n}=e,r=c(`(min-width: 768px)`),f;t[0]!==n||t[1]!==r?(f=n?.search?r?(0,p.jsx)(`div`,{className:`min-w-0 max-w-60 flex-1`,children:n.search}):(0,p.jsxs)(u,{children:[(0,p.jsx)(s,{asChild:!0,children:(0,p.jsx)(a,{type:`button`,variant:`secondary`,className:`size-9 shrink-0 p-0`,"aria-label":n.searchLabel,title:n.searchLabel,children:(0,p.jsx)(l,{className:`size-4`,"aria-hidden":!0})})}),(0,p.jsx)(i,{children:(0,p.jsx)(o,{align:`end`,sideOffset:8,className:`z-50 w-[min(20rem,calc(100vw-2rem))] rounded-xl border border-edge bg-surface-panel p-2 shadow-popover`,children:n.search})})]}):null,t[0]=n,t[1]=r,t[2]=f):f=t[2];let m=n?.secondary,h=n?.primary,g=n?.overflow,_;return t[3]!==f||t[4]!==m||t[5]!==h||t[6]!==g?(_=(0,p.jsxs)(`div`,{className:`flex min-w-0 items-center justify-end gap-2 xl:w-[27rem] 2xl:w-[31rem]`,children:[f,m,h,g]}),t[3]=f,t[4]=m,t[5]=h,t[6]=g,t[7]=_):_=t[7],_}export{m as n,h as t};
@@ -0,0 +1 @@
1
+ import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{f as i}from"./chunk-KS7C4IRE-B2HK1psj.js";import{t as a}from"./circle-check-C23XjkUj.js";import{t as o}from"./external-link-DjqjBmc3.js";import{t as s}from"./x-B_N4OPjy.js";import{t as c}from"./messages-CaeL_miw.js";import{t as l}from"./cn-0WouolD0.js";import{a as u,c as d,i as f,n as p,r as m}from"./locale-store-CE7L6MlS.js";import{a as h,i as g,n as _,o as v,r as y,s as b,t as x}from"./dist-BGTk37IG.js";import{i as S}from"./vendor-swr-BIWyz7Rc.js";import{Bi as C,Dl as w,G as T,Hc as E,Hn as D,Hu as O,Ic as k,Ll as A,Nc as j,On as M,Rn as N,Un as P,Wn as F,Ya as I,Zl as L,_s as R,cs as z,cu as B,fs as ee,gs as te,if as ne,iu as re,lo as ie,oo as ae}from"./index-CKdOZoVu.js";import{r as oe}from"./settings-page-layout-Dx5S-Msc.js";import{t as se}from"./browser-BLJWD7WI.js";import{t as ce}from"./schema-form-DNM2Zdyr.js";var V=e(t(),1),H=n();async function le(){return(await u(m(`/api/channels/status`))).payload?.channels||[]}function ue(){return m(`/api/channels/status`)}var de=le;function fe(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 pe=e(se(),1),U=r();async function W(e){let t=await f(m(`/api/channels/${encodeURIComponent(e.channelId)}/actions/${encodeURIComponent(e.actionId)}?locale=${encodeURIComponent(e.locale)}`),{method:`POST`,body:JSON.stringify({...e.accountId?{accountId:e.accountId}:{},...e.input===void 0?{}:{input:e.input}})}),n=await t.json().catch(()=>({}));if(!t.ok||n.ok===!1)throw Error(n.error?.message??t.statusText);return n.payload??{type:`ok`}}function G(e){return e?.type===`poll`&&e.phase===`done`}function K(e){return e&&`message`in e&&typeof e.message==`string`?e.message:null}function q(e,t){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrPayload?e.qrPayload:t===`weixin`&&e.qrcodeUrl?e.qrcodeUrl:null}function J(e){return e?.type!==`qr`&&e?.type!==`poll`?null:e.qrcodeUrl??null}function me({entry:e,locale:t,messages:n,onChanged:r,compact:i=!1}){let s=(0,V.useMemo)(()=>fe(e),[e]),c=(0,V.useMemo)(()=>({defaultBooleanLabel:n.schemaBooleanDefault,unsupportedArrayType:n.schemaUnsupportedArrayType,arrayAddPlaceholder:n.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>n.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[n]),[u,d]=(0,V.useState)({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null});(0,V.useEffect)(()=>{d({payload:null,poll:null,busy:!1,error:null,formDraft:{},generatedQr:null})},[e.id]);let f=(0,V.useCallback)(async(n,i)=>{d(e=>({...e,busy:!0,error:null}));try{let a=await W({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,V.useEffect)(()=>{let t=q(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),pe.toDataURL(t,{width:220,margin:1}).then(e=>{n||d(t=>({...t,generatedQr:e}))}),()=>{n=!0}},[e.id,u.payload]),(0,V.useEffect)(()=>{let n=u.poll;if(!n)return;let i=!1,a=window.setInterval(()=>{i||W({channelId:e.id,actionId:n.actionId,locale:t,input:{conversationId:n.conversationId}}).then(async e=>{i||(d(t=>({...t,payload:e,poll:G(e)?null:t.poll,error:null})),`configChanged`in e&&e.configChanged===!0&&await r(),G(e)&&window.clearInterval(a))}).catch(e=>{i||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=s?.[1].label??(e.configured?n.reconnect:n.connect),m=e.actions?.[`doctor.run`]?.label??n.diagnose,h=K(u.payload),g=q(u.payload,e.id),_=g?u.generatedQr:J(u.payload),v=s?.[1].result===`qr`&&(u.busy||u.payload?.type===`qr`||u.payload?.type===`poll`),y=u.payload?.type===`form`?u.payload:null,b=u.payload?.type===`diagnostics`?u.payload.checks:null;return(0,U.jsxs)(`div`,{className:i?`space-y-3`:`rounded-lg bg-surface-panel/80 p-4 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:l(`flex flex-wrap items-start gap-3`,i?`justify-end`:`justify-between`),children:[i?null:(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:n.setupTitle}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.configured?n.setupConfiguredHint:n.setupEmptyHint})]}),(0,U.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[s?(0,U.jsxs)(E,{type:`button`,variant:`primary`,disabled:u.busy,onClick:()=>void f(s[0]),children:[u.busy?(0,U.jsx)(O,{className:`size-4 animate-spin`}):(0,U.jsx)(B,{className:`size-4`}),p]}):null,e.actions?.[`doctor.run`]?(0,U.jsxs)(E,{type:`button`,variant:`secondary`,disabled:u.busy,onClick:()=>void f(`doctor.run`),children:[(0,U.jsx)(A,{className:`size-4`}),m]}):null]})]}),h?(0,U.jsx)(`p`,{className:`mt-3 text-sm text-fg-muted`,children:h}):null,u.error?(0,U.jsx)(`p`,{className:`mt-3 text-sm text-red-600 dark:text-red-400`,children:u.error}):null,v?(0,U.jsxs)(`div`,{className:l(`flex h-80 items-center justify-center gap-4 overflow-hidden rounded-lg bg-surface-base p-3 shadow-surface`,i?`mt-1 flex-col text-center sm:h-64 sm:flex-row sm:text-left`:`mt-4 flex-col sm:h-64 sm:flex-row`),children:[(0,U.jsx)(`div`,{className:`flex size-56 shrink-0 items-center justify-center rounded-lg border border-edge bg-white p-3`,children:_?(0,U.jsx)(`img`,{src:_,alt:`${e.label} setup QR`,className:`size-52 object-contain`}):(0,U.jsx)(`div`,{className:`flex size-52 items-center justify-center rounded-md bg-surface-base`,children:(0,U.jsx)(k,{className:`size-48 rounded-md`})})}),(0,U.jsxs)(`div`,{className:l(`min-w-0 max-w-sm text-sm text-fg-muted`,i&&`w-full sm:w-auto`),children:[_?(0,U.jsx)(`p`,{className:`line-clamp-3`,children:n.waitingConfirmation}):(0,U.jsxs)(`div`,{className:`space-y-2`,"aria-busy":`true`,children:[(0,U.jsx)(k,{className:`h-4 w-48 max-w-full`}),(0,U.jsx)(k,{className:`h-4 w-36 max-w-full`})]}),g?(0,U.jsxs)(`a`,{className:`mt-2 inline-flex items-center gap-1 text-accent hover:underline`,href:g,target:`_blank`,rel:`noreferrer`,children:[n.openSetupLink,(0,U.jsx)(o,{className:`size-3.5`})]}):null]})]}):null,u.payload?.type===`poll`&&u.payload.phase===`done`?(0,U.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 rounded-lg bg-surface-base px-3 py-2 text-sm shadow-surface`,children:[(0,U.jsx)(a,{className:u.payload.ok?`size-4 text-green-600`:`size-4 text-red-600`}),(0,U.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,y?(0,U.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,U.jsx)(ce,{schema:y.schema,values:u.formDraft,onChange:e=>d(t=>({...t,formDraft:e})),disabled:u.busy,labels:c}),(0,U.jsx)(E,{type:`button`,variant:`primary`,disabled:u.busy,onClick:()=>void f(y.submitAction,u.formDraft),children:n.saveSetup})]}):null,b?(0,U.jsx)(`div`,{className:`mt-4 space-y-2`,children:b.map((e,t)=>(0,U.jsxs)(`div`,{className:`rounded-lg bg-surface-base px-3 py-2 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,U.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:e.label??e.id??n.diagnosticCheckFallback.replace(`{{index}}`,String(t+1))}),(0,U.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e.status??`unknown`})]}),e.message?(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:e.message}):null]},e.id??t))}):null]})}var he=40;function Y(e){return`ui:route:channel:${e.trim().toLowerCase()}`}function ge(e,t){return e.find(e=>e.id===Y(t))?.agentId?.trim().toLowerCase()??``}function _e(e,t,n){let r=Y(t),i=e.filter(e=>e.id!==r),a=n.trim().toLowerCase();return a?[...i,{id:r,agentId:a,priority:he,enabled:!0,match:{channel:t.trim().toLowerCase(),accountId:`*`}}]:i}function ve(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 ye(e,t,n){let r=ve(e);return r.ready?r.enabled?n?t?.connected===!0?`running`:`stopped`:`checking`:`disabled`:`needs_setup`}function be(e,t=!1){return e===`drawer`?l(`xopc-drawer-right fixed right-0 top-0 flex size-full flex-col overflow-hidden border-l border-edge bg-surface-overlay shadow-popover outline-none dark:border-edge`,t?`max-w-[36rem]`:`max-w-xl`,te):l(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(calc(100dvh-2rem),52rem)] w-[min(calc(100%-2rem),32rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,t&&`h-[min(calc(100dvh-2rem),48rem)] w-[min(calc(100%-2rem),36rem)]`,te,`rounded-2xl border border-edge bg-surface-overlay outline-none dark:border-edge`)}function xe(e){let t=(0,H.c)(33),{presentation:n,open:r,onOpenChange:i,title:a,description:o,srTitle:c,srDescription:u,closeAriaLabel:d,children:f,footer:p,wide:m,headerExtra:S}=e,C=m===void 0?!1:m,w=n===`drawer`,[T,D]=(0,V.useState)(null),O;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(O=(0,U.jsx)(h,{className:l(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,R)}),t[0]=O):O=t[0];let k;t[1]!==n||t[2]!==C?(k=be(n,C),t[1]=n,t[2]=C,t[3]=k):k=t[3];let A;t[4]===c?A=t[5]:(A=c?(0,U.jsx)(b,{className:`sr-only`,children:c}):null,t[4]=c,t[5]=A);let M;t[6]===u?M=t[7]:(M=u?(0,U.jsx)(g,{className:`sr-only`,children:u}):null,t[6]=u,t[7]=M);let N;t[8]!==d||t[9]!==o||t[10]!==S||t[11]!==w||t[12]!==a?(N=w?(0,U.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge px-4 py-3`,children:[(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[a?(0,U.jsx)(`div`,{className:`text-base font-semibold text-fg`,children:a}):null,o?(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:o}):null]}),(0,U.jsx)(_,{asChild:!0,children:(0,U.jsx)(E,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 p-0`,"aria-label":d,children:(0,U.jsx)(s,{className:`size-5`,strokeWidth:1.75})})})]}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(_,{asChild:!0,children:(0,U.jsx)(`button`,{type:`button`,className:l(j,`absolute right-3 top-3 z-20 p-1.5 hover:bg-surface-hover`),"aria-label":d,children:(0,U.jsx)(s,{className:`size-4`})})}),S]}),t[8]=d,t[9]=o,t[10]=S,t[11]=w,t[12]=a,t[13]=N):N=t[13];let P=w?`p-4`:`p-6`,F;t[14]===P?F=t[15]:(F=l(`min-h-0 flex-1 overflow-y-auto`,P),t[14]=P,t[15]=F);let I;t[16]!==f||t[17]!==F?(I=(0,U.jsx)(`div`,{className:F,children:f}),t[16]=f,t[17]=F,t[18]=I):I=t[18];let L;t[19]!==p||t[20]!==T||t[21]!==A||t[22]!==M||t[23]!==N||t[24]!==I?(L=(0,U.jsxs)(ee,{layer:`modal`,portalContainer:T,children:[A,M,N,I,p]}),t[19]=p,t[20]=T,t[21]=A,t[22]=M,t[23]=N,t[24]=I,t[25]=L):L=t[25];let z;t[26]!==L||t[27]!==k?(z=(0,U.jsxs)(v,{children:[O,(0,U.jsx)(y,{ref:D,className:k,onOpenAutoFocus:Se,children:L})]}),t[26]=L,t[27]=k,t[28]=z):z=t[28];let B;return t[29]!==i||t[30]!==r||t[31]!==z?(B=(0,U.jsx)(x,{open:r,onOpenChange:i,children:z}),t[29]=i,t[30]=r,t[31]=z,t[32]=B):B=t[32],B}function Se(e){return e.preventDefault()}var Ce=(0,V.memo)(function(e){let t=(0,H.c)(10),{ch:n,refreshing:r,saveOk:i,onRefresh:a}=e,o;t[0]!==n.saved||t[1]!==i?(o=i?(0,U.jsx)(`span`,{className:`text-sm text-fg-muted`,children:n.saved}):null,t[0]=n.saved,t[1]=i,t[2]=o):o=t[2];let s;t[3]!==n.refresh||t[4]!==a||t[5]!==r?(s=(0,U.jsx)(I,{className:`size-9 shrink-0 p-0`,loading:r,label:n.refresh,onClick:a}),t[3]=n.refresh,t[4]=a,t[5]=r,t[6]=s):s=t[6];let c;return t[7]!==o||t[8]!==s?(c=(0,U.jsxs)(`div`,{className:`flex min-w-0 shrink-0 items-center justify-end gap-2`,children:[o,s]}),t[7]=o,t[8]=s,t[9]=c):c=t[9],c});function we(e){let t=(0,H.c)(24),{ch:n,dirty:r,saving:i,onCancel:a,onDiscard:o,onSave:s,showCancel:c}=e,l=c===void 0?!0:c,u;t[0]!==n.unsavedHint||t[1]!==r?(u=r?(0,U.jsx)(`p`,{className:`mb-3 text-xs text-amber-800 dark:text-amber-200`,children:n.unsavedHint}):null,t[0]=n.unsavedHint,t[1]=r,t[2]=u):u=t[2];let d;t[3]!==n.modalCancel||t[4]!==a||t[5]!==l?(d=l?(0,U.jsx)(E,{type:`button`,variant:`secondary`,onClick:a,children:n.modalCancel}):null,t[3]=n.modalCancel,t[4]=a,t[5]=l,t[6]=d):d=t[6];let f=!r||i,p;t[7]!==n.discard||t[8]!==o||t[9]!==f?(p=(0,U.jsx)(E,{type:`button`,variant:`secondary`,disabled:f,onClick:o,children:n.discard}),t[7]=n.discard,t[8]=o,t[9]=f,t[10]=p):p=t[10];let m=!r||i,h;t[11]===s?h=t[12]:(h=()=>void s(),t[11]=s,t[12]=h);let g=i?n.saving:n.save,_;t[13]!==m||t[14]!==h||t[15]!==g?(_=(0,U.jsx)(E,{type:`button`,variant:`primary`,disabled:m,onClick:h,children:g}),t[13]=m,t[14]=h,t[15]=g,t[16]=_):_=t[16];let v;t[17]!==d||t[18]!==p||t[19]!==_?(v=(0,U.jsxs)(`div`,{className:`flex flex-wrap justify-end gap-2`,children:[d,p,_]}),t[17]=d,t[18]=p,t[19]=_,t[20]=v):v=t[20];let y;return t[21]!==v||t[22]!==u?(y=(0,U.jsxs)(`div`,{className:`sticky bottom-0 shrink-0 border-t border-edge-subtle bg-surface-panel px-6 py-4 dark:border-edge-subtle`,children:[u,v]}),t[21]=v,t[22]=u,t[23]=y):y=t[23],y}function Te(e){return m(`/api/channels/catalog?locale=${encodeURIComponent(e)}`)}async function Ee(e){return(await u(Te(e))).payload?.channels??[]}function De(e,t){let n=(0,H.c)(14),r;n[0]!==e||n[1]!==t?(r=e?Te(t):null,n[0]=e,n[1]=t,n[2]=r):r=n[2];let i;n[3]===t?i=n[4]:(i=()=>Ee(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}=S(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 Oe=`channels-status`;function ke(e){if(!e||typeof e!=`object`)return null;let t=e.channels;return Array.isArray(t)?t:null}function Ae(e){let t=t=>e(t.detail);return window.addEventListener(Oe,t),()=>window.removeEventListener(Oe,t)}function je(e,t){let n=(0,H.c)(4),r=t===void 0?!0:t,i,a;n[0]!==r||n[1]!==e?(i=()=>{if(r)return Ae(e)},a=[r,e],n[0]=r,n[1]=e,n[2]=i,n[3]=a):(i=n[2],a=n[3]),(0,V.useEffect)(i,a)}function Me(e){return e?m(`/api/channels/${encodeURIComponent(e)}/config`):null}async function Ne(e){return(await u(m(`/api/channels/${encodeURIComponent(e)}/config`))).payload?.config??{}}var Pe=[`enabled`],Fe=`max-w-7xl`,Ie=`px-4 pb-7 pt-3 sm:px-6 lg:px-8 lg:pb-9 lg:pt-4`;async function Le(){let e=await u(m(`/api/config`));return{channels:e.payload?.config?.channels??{},bindings:e.payload?.config?.bindings??[]}}function Re(e){return e.split(`/`).filter(Boolean).map(e=>encodeURIComponent(e)).join(`/`)}function ze(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 Be(e,t){return e===`running`?t.connectionRunning:e===`stopped`?t.connectionStopped:e===`checking`?t.connectionChecking:e===`disabled`?t.connectionDisabled:t.connectionNeedsSetup}function Ve(e,t){return e===`running`?t.connectionRunningHint:e===`stopped`?t.connectionStoppedHint:e===`disabled`?t.connectionDisabledHint:e===`needs_setup`?t.connectionNeedsSetupHint:t.connectionChecking}function He(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 Ue(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=new Set([`dmPolicy`,`groupPolicy`,`allowFrom`,`groupAllowFrom`]),a=[...Object.keys(t).filter(e=>!e.includes(`*`)&&i.has(e.split(`.`).at(-1)??``)),...Object.keys(Z(e.configSchema?.properties)?e.configSchema.properties:{}).filter(e=>i.has(e))],o=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=>!Pe.includes(e));return Array.from(new Set([...o,...a,...n,...r])).filter(e=>!Pe.includes(e))}function Z(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function We(e){return JSON.parse(JSON.stringify(e??{type:`object`,properties:{}}))}function Ge(e,t){let n={...We(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]={...We(r[n]),properties:{}}),e===t.length-1){o[n]=We(r[n]);break}i=r[n],a=o[n]}}return n}function Ke(e){let t=e.properties;if(!Z(t))return!1;for(let[e,n]of Object.entries(t))Z(n)&&n.type===`object`&&Ke(n)&&delete t[e];return Object.keys(t).length===0}function qe(e,t){let n=We(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 Ke(n),n}function Je(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 Ye(e){let t=e.accounts;return Z(t)?Object.values(t).filter(e=>Z(e)&&e.enabled!==!1).length:+(e.configured===!0)}function Xe(e,t,n){return t==null||t===``?null:e.toLowerCase().includes(`dmpolicy`)&&typeof t==`string`?`${n.dmPolicy}: ${n.policy.dm[t]??t}`:(e.toLowerCase().includes(`stream`)||e.toLowerCase().includes(`streaming`))&&typeof t==`string`?`${n.cardStream}: ${n.policy.stream[t]??t}`:typeof t==`boolean`?t?n.enabledLabel:n.disabledLabel:String(t)}function Ze(e,t,n){let r=[],i=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=Xe(e,Q(t,e),n);i&&r.push(i)}let a=Ye(t);a>0&&r.push(n.cardAccounts.replace(`{{count}}`,String(a)))}return r.length>0?r.slice(0,2):i.ready?[n.hubStatusConfigured]:[]}function Qe(e,t){let n=X(e),r=fe(e);return n.state===`needs_setup`?r?.[1].label??t.completeSetup:!n.enabled&&n.ready?t.enableChannel:n.state===`error`?t.diagnose:n.ready?t.manageChannel:r?.[1].label??t.startConfiguration}function $e(e,t){let n=fe(e);return n?.[1].result===`qr`?t.cardSetupQrHint:n?.[1].result===`form`?t.cardSetupConfigHint:t.cardSetupGenericHint}function et(e,t){let n=e.capabilities??{},r=[];return n.login===!0&&r.push(t.cardCapabilityLogin),n.pairing===!0&&r.push(t.cardCapabilityPairing),n.multiAccount===!0&&r.push(t.cardCapabilityMultiAccount),n.streaming===!0&&r.push(t.cardCapabilityStreaming),n.media===!0&&r.push(t.cardCapabilityMedia),n.doctor===!0&&r.push(t.cardCapabilityDoctor),r.slice(0,3)}function $(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 tt({entry:e}){let[t,n]=(0,V.useState)(!1),r=(0,V.useMemo)(()=>!e.ui?.icon||t?null:new URL(m(`/api/extensions/${encodeURIComponent(e.extensionId)}/assets/${Re(e.ui.icon)}`)).toString(),[t,e.extensionId,e.ui?.icon]);return(0,U.jsx)(`span`,{className:`flex size-12 shrink-0 items-center justify-center rounded-2xl bg-surface-base text-fg`,children:r?(0,U.jsx)(`img`,{src:r,alt:``,draggable:!1,className:`size-7`,"aria-hidden":!0,onError:()=>n(!0)}):(0,U.jsx)(ie,{sourceChannel:e.id,className:`size-7`})})}function nt(e){let t=(0,H.c)(16),{checked:n,disabled:r,onToggle:i,label:a}=e,o;t[0]===i?o=t[1]:(o=e=>{e.stopPropagation(),i()},t[0]=i,t[1]=o);let s=n?`border-accent bg-accent`:`border-edge bg-surface-hover`,c=r&&`cursor-not-allowed opacity-60`,u;t[2]!==s||t[3]!==c?(u=l(`relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border transition-colors`,s,c),t[2]=s,t[3]=c,t[4]=u):u=t[4];let d=n?`translate-x-5`:`translate-x-0.5`,f;t[5]===d?f=t[6]:(f=l(`size-5 rounded-full bg-white shadow-surface transition-transform`,d),t[5]=d,t[6]=f);let p;t[7]===f?p=t[8]:(p=(0,U.jsx)(`span`,{className:f}),t[7]=f,t[8]=p);let m;return t[9]!==n||t[10]!==r||t[11]!==a||t[12]!==o||t[13]!==u||t[14]!==p?(m=(0,U.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":n,"aria-label":a,disabled:r,onClick:o,className:u,children:p}),t[9]=n,t[10]=r,t[11]=a,t[12]=o,t[13]=u,t[14]=p,t[15]=m):m=t[15],m}function rt(e){let t=(0,H.c)(71),{entry:n,config:r,runtime:i,busy:a,restarting:o,ch:s,onOpen:c,onToggle:u,onRestart:d}=e,f;t[0]===n?f=t[1]:(f=X(n),t[0]=n,t[1]=f);let p=f,m,h,g,_,v,y,b;if(t[2]!==a||t[3]!==s||t[4]!==r||t[5]!==n||t[6]!==c||t[7]!==d||t[8]!==u||t[9]!==i||t[10]!==p.enabled||t[11]!==p.ready){let e=Ze(n,r,s),o=et(n,s);m=!p.enabled&&p.ready?u:i===`stopped`?d:c,y=`flex min-h-[15.5rem] flex-col rounded-xl bg-surface-panel p-4 shadow-surface transition-colors hover:bg-surface-hover/45`;let f;t[19]===n?f=t[20]:(f=(0,U.jsx)(tt,{entry:n}),t[19]=n,t[20]=f);let x;t[21]===n.label?x=t[22]:(x=(0,U.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:n.label}),t[21]=n.label,t[22]=x);let S;t[23]===i?S=t[24]:(S=l(`mt-1 inline-flex rounded-full px-2 py-0.5 text-xs font-medium`,He(i)),t[23]=i,t[24]=S);let C;t[25]!==s||t[26]!==i?(C=Be(i,s),t[25]=s,t[26]=i,t[27]=C):C=t[27];let w;t[28]!==S||t[29]!==C?(w=(0,U.jsx)(`span`,{className:S,children:C}),t[28]=S,t[29]=C,t[30]=w):w=t[30];let T;t[31]!==w||t[32]!==x?(T=(0,U.jsxs)(`div`,{className:`min-w-0`,children:[x,w]}),t[31]=w,t[32]=x,t[33]=T):T=t[33];let E;t[34]!==T||t[35]!==f?(E=(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[f,T]}),t[34]=T,t[35]=f,t[36]=E):E=t[36];let D=p.enabled,O;t[37]!==s.toggleChannel||t[38]!==n.label?(O=s.toggleChannel.replace(`{{channel}}`,n.label),t[37]=s.toggleChannel,t[38]=n.label,t[39]=O):O=t[39];let k;t[40]!==a||t[41]!==u||t[42]!==p.enabled||t[43]!==O?(k=(0,U.jsx)(nt,{checked:D,disabled:a,label:O,onToggle:u}),t[40]=a,t[41]=u,t[42]=p.enabled,t[43]=O,t[44]=k):k=t[44],t[45]!==E||t[46]!==k?(b=(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[E,k]}),t[45]=E,t[46]=k,t[47]=b):b=t[47],h=`button`,g=c,_=`mt-5 min-h-[6.25rem] text-left`,v=p.ready?(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`p`,{className:`line-clamp-2 text-sm leading-6 text-fg-muted`,children:n.description??n.id}),e.length>0?(0,U.jsx)(`div`,{className:`mt-3 space-y-0.5 text-sm leading-5 text-fg-muted`,children:e.map(at)}):null]}):(0,U.jsxs)(`div`,{className:`rounded-lg bg-surface-base p-3`,children:[(0,U.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:s.cardSetupTitle}),(0,U.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm leading-5 text-fg-muted`,children:e[0]??$e(n,s)}),o.length>0?(0,U.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:o.map(it)}):null]}),t[2]=a,t[3]=s,t[4]=r,t[5]=n,t[6]=c,t[7]=d,t[8]=u,t[9]=i,t[10]=p.enabled,t[11]=p.ready,t[12]=m,t[13]=h,t[14]=g,t[15]=_,t[16]=v,t[17]=y,t[18]=b}else m=t[12],h=t[13],g=t[14],_=t[15],v=t[16],y=t[17],b=t[18];let x;t[48]!==h||t[49]!==g||t[50]!==_||t[51]!==v?(x=(0,U.jsx)(`button`,{type:h,onClick:g,className:_,children:v}),t[48]=h,t[49]=g,t[50]=_,t[51]=v,t[52]=x):x=t[52];let S=a||o,C;t[53]!==a||t[54]!==o?(C=a||o?(0,U.jsx)(O,{className:`size-4 animate-spin`}):null,t[53]=a,t[54]=o,t[55]=C):C=t[55];let w;t[56]!==s||t[57]!==n||t[58]!==o||t[59]!==i?(w=o?s.restartingChannel:i===`stopped`?s.restartChannel:Qe(n,s),t[56]=s,t[57]=n,t[58]=o,t[59]=i,t[60]=w):w=t[60];let T;t[61]!==m||t[62]!==C||t[63]!==w||t[64]!==S?(T=(0,U.jsx)(`div`,{className:`mt-auto pt-4`,children:(0,U.jsxs)(E,{type:`button`,variant:`secondary`,className:`w-full rounded-2xl py-2.5`,onClick:m,disabled:S,children:[C,w]})}),t[61]=m,t[62]=C,t[63]=w,t[64]=S,t[65]=T):T=t[65];let D;return t[66]!==T||t[67]!==y||t[68]!==b||t[69]!==x?(D=(0,U.jsxs)(`article`,{className:y,children:[b,x,T]}),t[66]=T,t[67]=y,t[68]=b,t[69]=x,t[70]=D):D=t[70],D}function it(e){return(0,U.jsx)(`span`,{className:`rounded-full bg-surface-hover px-2 py-0.5 text-xs text-fg-muted`,children:e},e)}function at(e){return(0,U.jsx)(`p`,{className:`truncate`,title:e,children:e},e)}function ot(e){let t=(0,H.c)(51),{runtime:n,restarting:r,checking:i,showConnectionOptions:o,canManageConnection:s,ch:c,onRestart:u,onCheck:d,onManageConnection:f}=e,p=n===`running`?a:n===`stopped`||n===`needs_setup`?ne:O,m=n===`running`&&`text-emerald-600 dark:text-emerald-400`,h=n===`stopped`&&`text-red-600 dark:text-red-400`,g=n===`checking`&&`animate-spin text-amber-600 dark:text-amber-400`,_=n===`disabled`&&`text-fg-muted`,v=n===`needs_setup`&&`text-amber-600 dark:text-amber-400`,y;t[0]!==m||t[1]!==h||t[2]!==g||t[3]!==_||t[4]!==v?(y=l(`mt-0.5 size-5 shrink-0`,m,h,g,_,v),t[0]=m,t[1]=h,t[2]=g,t[3]=_,t[4]=v,t[5]=y):y=t[5];let b;t[6]!==p||t[7]!==y?(b=(0,U.jsx)(p,{className:y}),t[6]=p,t[7]=y,t[8]=b):b=t[8];let x;t[9]===c.connectionStatus?x=t[10]:(x=(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:c.connectionStatus}),t[9]=c.connectionStatus,t[10]=x);let S;t[11]!==c||t[12]!==n?(S=Ve(n,c),t[11]=c,t[12]=n,t[13]=S):S=t[13];let C;t[14]===S?C=t[15]:(C=(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:S}),t[14]=S,t[15]=C);let w;t[16]!==C||t[17]!==x?(w=(0,U.jsxs)(`div`,{children:[x,C]}),t[16]=C,t[17]=x,t[18]=w):w=t[18];let T;t[19]!==w||t[20]!==b?(T=(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[b,w]}),t[19]=w,t[20]=b,t[21]=T):T=t[21];let D=i||r,k;t[22]===i?k=t[23]:(k=i?(0,U.jsx)(O,{className:`size-4 animate-spin`}):null,t[22]=i,t[23]=k);let A=i?c.checkingConnection:c.checkConnection,j;t[24]!==d||t[25]!==D||t[26]!==k||t[27]!==A?(j=(0,U.jsxs)(E,{type:`button`,variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,disabled:D,onClick:d,children:[k,A]}),t[24]=d,t[25]=D,t[26]=k,t[27]=A,t[28]=j):j=t[28];let M;t[29]!==c.restartChannel||t[30]!==c.restartingChannel||t[31]!==i||t[32]!==u||t[33]!==r||t[34]!==n?(M=n===`stopped`?(0,U.jsxs)(E,{type:`button`,variant:`primary`,className:`px-2.5 py-1.5 text-xs`,disabled:r||i,onClick:u,children:[r?(0,U.jsx)(O,{className:`size-4 animate-spin`}):(0,U.jsx)(re,{className:`size-4`}),r?c.restartingChannel:c.restartChannel]}):null,t[29]=c.restartChannel,t[30]=c.restartingChannel,t[31]=i,t[32]=u,t[33]=r,t[34]=n,t[35]=M):M=t[35];let N;t[36]!==s||t[37]!==c.connectionOptions||t[38]!==c.hideConnectionOptions||t[39]!==i||t[40]!==f||t[41]!==r||t[42]!==o?(N=s?(0,U.jsx)(E,{type:`button`,variant:`ghost`,className:`px-2.5 py-1.5 text-xs`,disabled:i||r,onClick:f,children:o?c.hideConnectionOptions:c.connectionOptions}):null,t[36]=s,t[37]=c.connectionOptions,t[38]=c.hideConnectionOptions,t[39]=i,t[40]=f,t[41]=r,t[42]=o,t[43]=N):N=t[43];let P;t[44]!==j||t[45]!==M||t[46]!==N?(P=(0,U.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[j,M,N]}),t[44]=j,t[45]=M,t[46]=N,t[47]=P):P=t[47];let F;return t[48]!==T||t[49]!==P?(F=(0,U.jsx)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:(0,U.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[T,P]})}),t[48]=T,t[49]=P,t[50]=F):F=t[50],F}function st(e){let t=(0,H.c)(33),{entry:n,ch:r}=e,i,a,o,s,c,l,u,d,f;if(t[0]!==r||t[1]!==n){f=Symbol.for(`react.early_return_sentinel`);bb0:{let e=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,U.jsx)(w,{className:`mt-0.5 size-4 shrink-0`}),t[11]=u):u=t[11],o=`min-w-0`,t[12]===r.setupReadinessTitle?s=t[13]:(s=(0,U.jsx)(`h3`,{className:`text-sm font-semibold`,children:r.setupReadinessTitle}),t[12]=r.setupReadinessTitle,t[13]=s);let p=e.enabled?r.setupReadinessEnabledBody:r.setupReadinessDisabledBody;t[14]===p?c=t[15]:(c=(0,U.jsx)(`p`,{className:`mt-1 text-sm leading-5 text-amber-900 dark:text-amber-200`,children:p}),t[14]=p,t[15]=c),i=`mt-2 list-disc space-y-1 pl-5 text-sm text-amber-900 dark:text-amber-200`;let m;t[16]===r?m=t[17]:(m=e=>(0,U.jsx)(`li`,{children:$(e,r)},`${e.code}:${e.fieldPath??``}`),t[16]=r,t[17]=m),a=e.issues.map(m)}t[0]=r,t[1]=n,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=d,t[10]=f}else i=t[2],a=t[3],o=t[4],s=t[5],c=t[6],l=t[7],u=t[8],d=t[9],f=t[10];if(f!==Symbol.for(`react.early_return_sentinel`))return f;let p;t[18]!==i||t[19]!==a?(p=(0,U.jsx)(`ul`,{className:i,children:a}),t[18]=i,t[19]=a,t[20]=p):p=t[20];let m;t[21]!==p||t[22]!==o||t[23]!==s||t[24]!==c?(m=(0,U.jsxs)(`div`,{className:o,children:[s,c,p]}),t[21]=p,t[22]=o,t[23]=s,t[24]=c,t[25]=m):m=t[25];let h;t[26]!==m||t[27]!==l||t[28]!==u?(h=(0,U.jsxs)(`div`,{className:l,children:[u,m]}),t[26]=m,t[27]=l,t[28]=u,t[29]=h):h=t[29];let g;return t[30]!==h||t[31]!==d?(g=(0,U.jsx)(`section`,{className:d,children:h}),t[30]=h,t[31]=d,t[32]=g):g=t[32],g}function ct({channelId:e,onHeaderActionChange:t}){let n=p(e=>e.language),r=c(n),a=d(e=>!!e.conversationId),s=i(),u=F(e),h=De(a,n),g=h.entries,{data:_,mutate:v,isValidating:y}=S(a?ue():null,de,{revalidateOnFocus:!0}),{data:b,mutate:x}=S(a?`channels-config-map`:null,Le,{revalidateOnFocus:!1}),w=b?.channels??{},E=b?.bindings??[],{data:O}=S(a?`channel-routing-agents`:null,ae,{revalidateOnFocus:!1}),k=(0,V.useMemo)(()=>g.find(e=>e.id===u),[u,g]),A=k?ze(k):null,{data:j,mutate:I}=S(a&&A?Me(A):null,()=>Ne(A)),[R,B]=(0,V.useState)(null),[ee,te]=(0,V.useState)(!1),[ne,re]=(0,V.useState)(null),[ie,se]=(0,V.useState)(null),[H,le]=(0,V.useState)(!1),[pe,W]=(0,V.useState)(null),[G,K]=(0,V.useState)(null),q=R??j??{},J=r.channelsSettings,he=(0,V.useMemo)(()=>k?.configSchema??{type:`object`,properties:{}},[k?.configSchema]),Y=(0,V.useMemo)(()=>qe(he,Pe),[he]),ve=(0,V.useMemo)(()=>Ue(k),[k]),be=(0,V.useMemo)(()=>Ge(Y,ve),[ve,Y]),Se=(0,V.useMemo)(()=>qe(Y,ve),[ve,Y]),Te=(0,V.useMemo)(()=>Je(be),[be]),Ee=k?G??ge(E,k.id):``,Oe=(0,V.useMemo)(()=>(O?.items??[]).map(e=>{let t=N(e,r.agentsSettings);return{value:e.id,label:t===e.id?t:`${t} · ${e.id}`}}),[O?.items,r.agentsSettings]),Ae=O?.items.find(e=>e.id===O.defaultId),Re=Ae?N(Ae,r.agentsSettings):O?.defaultId??``,Ve=(0,V.useMemo)(()=>({defaultBooleanLabel:J.schemaBooleanDefault,unsupportedArrayType:J.schemaUnsupportedArrayType,arrayAddPlaceholder:J.schemaArrayAddPlaceholder,unsupportedFieldType:(e,t)=>J.schemaUnsupportedFieldType.replace(`{{title}}`,e).replace(`{{type}}`,t?` (${t})`:``)}),[J]),Z=(0,V.useMemo)(()=>new Map((_??[]).map(e=>[e.name,e])),[_]),We=_!==void 0,Ke=(0,V.useCallback)(e=>ye(e,Z.get(e.id),We),[Z,We]),Q=(0,V.useCallback)(async()=>{await Promise.all([h.mutate(),v()])},[h,v]);je((0,V.useCallback)(e=>{let t=ke(e);t&&v(t,!1)},[v]),a);let Ye=(0,V.useMemo)(()=>a?{secondary:(0,U.jsx)(Ce,{ch:J,refreshing:h.isValidating||y,saveOk:!1,onRefresh:()=>void Q()})}:null,[h.isValidating,J,a,y,Q]);(0,V.useLayoutEffect)(()=>(t?.(Ye),()=>t?.(null)),[Ye,t]);let Xe=(0,V.useCallback)(e=>{s(P(e)),B(null),K(null),W(null)},[s]),Ze=(0,V.useCallback)(()=>{s(D),B(null),K(null),W(null)},[s]),Qe=(0,V.useCallback)(async e=>{se(e.id),W(null);try{let t=await f(m(`/api/channels/${encodeURIComponent(e.id)}/restart`),{method:`POST`});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}await Q()}catch(e){W(e instanceof Error?e.message:String(e))}finally{se(null)}},[Q]);(0,V.useEffect)(()=>{K(null),le(!1)},[k?.id]);let $e=(0,V.useCallback)(async()=>{if(!k||!R&&G===null)return!1;let e=ze(k);te(!0),W(null);try{let t=await f(m(`/api/config`),{method:`PATCH`,body:JSON.stringify({...R?{channels:{[e]:R}}:{},...G===null?{}:{bindings:_e(E,k.id,G)}})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error?.message??t.statusText)}return R&&await I(R,!1),await x(),await h.mutate(),B(null),K(null),!0}catch(e){return W(e instanceof Error?e.message:String(e)),!1}finally{te(!1)}},[k,G,E,h,R,x,I]),et=(0,V.useCallback)(async e=>{let t=X(e),n=ze(e),r=k?.id===e.id?R:null;if(!t.enabled&&!t.ready&&!r){Xe(e.id);return}re(e.id),W(null);try{let i=t.enabled?{enabled:!1}:r?{...r,enabled:!0}:{enabled:!0},a=await f(m(`/api/config`),{method:`PATCH`,body:JSON.stringify({channels:{[n]:i}})});if(!a.ok){let e=await a.json().catch(()=>({}));throw Error(e.error?.message??a.statusText)}await h.mutate(),await x(),await v(),k?.id===e.id&&(await I(),B(null))}catch(e){W(e instanceof Error?e.message:String(e))}finally{re(null)}},[k?.id,h,R,x,I,v,Xe]),$=k?.ui?.modal,it=$?.placement!==`replace-config`,at=k?Ke(k):`checking`,ct=k?!X(k).ready||H:!1;return a?(0,U.jsxs)(oe,{gap:`gap-4`,className:Fe,padding:Ie,children:[h.isLoading?(0,U.jsx)(M,{sections:2}):h.error?(0,U.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:String(h.error)}):(0,U.jsx)(`div`,{className:`grid gap-4 md:grid-cols-2 xl:grid-cols-3`,children:g.map(e=>(0,U.jsx)(rt,{entry:e,config:w[ze(e)]?.config,runtime:Ke(e),busy:ne===e.id,restarting:ie===e.id,ch:J,onOpen:()=>Xe(e.id),onToggle:()=>void et(e),onRestart:()=>void Qe(e)},e.id))}),pe?(0,U.jsx)(`p`,{className:`mt-4 text-sm text-red-600 dark:text-red-400`,children:pe}):null,(0,U.jsx)(xe,{presentation:`modal`,open:!!k,onOpenChange:e=>{e||Ze()},closeAriaLabel:J.close,srTitle:k?.label??J.selectChannel,srDescription:k?.description,wide:!0,footer:k?(0,U.jsx)(we,{ch:J,dirty:!!R||G!==null,saving:ee,onCancel:Ze,onDiscard:()=>{B(null),K(null)},onSave:$e}):null,children:k?(0,U.jsxs)(`div`,{className:`space-y-4`,children:[(0,U.jsx)(`div`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,children:(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,U.jsx)(tt,{entry:k}),(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:[(0,U.jsx)(`h2`,{className:`truncate text-base font-semibold text-fg`,children:k.label}),(0,U.jsx)(`span`,{className:l(`shrink-0 rounded-full px-2 py-0.5 text-xs font-medium`,He(at)),children:Be(at,J)})]}),(0,U.jsxs)(`div`,{className:`mt-1 flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-sm text-fg-muted`,children:[(0,U.jsx)(`span`,{className:`min-w-0 truncate`,children:!X(k).ready&&fe(k)?.[1].result===`qr`?J.scanLoginHint.replace(`{{channel}}`,k.label):k.description}),k.docsPath?(0,U.jsxs)(`a`,{href:k.docsPath,target:`_blank`,rel:`noreferrer`,className:`inline-flex shrink-0 items-center gap-1 text-accent hover:underline`,children:[J.docs,(0,U.jsx)(o,{className:`size-3.5`})]}):null]})]})]}),(0,U.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 pr-8`,children:[(0,U.jsx)(`span`,{className:`hidden text-xs text-fg-muted sm:inline`,children:X(k).enabled?J.enabledLabel:J.disabledLabel}),(0,U.jsx)(nt,{checked:X(k).enabled,disabled:ne===k.id,label:J.toggleChannel.replace(`{{channel}}`,k.label),onToggle:()=>void et(k)})]})]})}),(0,U.jsx)(ot,{runtime:at,restarting:ie===k.id,checking:y,showConnectionOptions:H,canManageConnection:X(k).ready&&$?.placement!==`replace-config`,ch:J,onRestart:()=>void Qe(k),onCheck:()=>void Q(),onManageConnection:()=>le(e=>!e)}),(0,U.jsx)(st,{entry:k,ch:J}),ct&&$?.placement!==`replace-config`?(0,U.jsx)(me,{entry:k,locale:n,messages:J,compact:!0,onChanged:async()=>{await I(),await Q(),await x()}},k.id):null,$?.entrypoint&&$.placement===`before-config`?(0,U.jsx)(C,{extensionId:k.extensionId,extensionName:k.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:k.id,entry:k,config:q}}):null,$?.entrypoint&&$.placement!==`before-config`?(0,U.jsx)(C,{extensionId:k.extensionId,extensionName:k.label,entrypoint:$.entrypoint,permissions:$.permissions,minHeight:$.minHeight,maxHeight:$.maxHeight,initialData:{channelId:k.id,entry:k,config:q}}):null,it&&Te?(0,U.jsxs)(`section`,{className:`rounded-xl bg-surface-panel/80 p-4 shadow-surface`,children:[(0,U.jsxs)(`div`,{className:`mb-4`,children:[(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:J.basicConfiguration}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:J.basicConfigurationHint})]}),(0,U.jsx)(ce,{schema:be,values:q,onChange:e=>B(e),disabled:ee,labels:Ve})]}):null,(0,U.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,U.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,U.jsx)(L,{className:`size-4 text-fg-muted`}),J.messageHandling]}),(0,U.jsxs)(`div`,{className:`bg-surface-base/50 p-4`,children:[(0,U.jsxs)(`div`,{className:`mb-3`,children:[(0,U.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:J.agentRouting}),(0,U.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:J.messageHandlingHint})]}),(0,U.jsx)(z,{value:Ee,options:Oe,placeholder:J.agentRoutingSelect,emptyLabel:J.agentRoutingDefault.replace(`{{agent}}`,Re||J.agentRoutingSelect),ariaLabel:J.agentRouting,disabled:ee||!O,onChange:e=>K(e)})]})]}),it&&Je(Se)?(0,U.jsx)(T,{title:J.advancedConfiguration,summary:J.messageHandlingHint,children:(0,U.jsxs)(`details`,{className:`group rounded-xl bg-surface-panel/80 shadow-surface`,children:[(0,U.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-4 py-3 text-sm font-medium text-fg marker:hidden [&::-webkit-details-marker]:hidden`,children:[(0,U.jsx)(L,{className:`size-4 text-fg-muted`}),J.advancedConfiguration]}),(0,U.jsx)(`div`,{className:`bg-surface-base/50 p-4`,children:(0,U.jsx)(ce,{schema:Se,values:q,onChange:e=>B(e),disabled:ee,labels:Ve})})]})}):null,pe?(0,U.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:pe}):null]}):null})]}):(0,U.jsx)(oe,{gap:`gap-3`,className:Fe,padding:Ie,children:(0,U.jsx)(`p`,{className:`text-sm text-fg-muted`,children:J.tokenRequired})})}export{ct as ChannelsSettingsPanel};