@xopcai/xopc 0.0.378 → 0.0.380

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 (255) 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/{activity-store-Xnu0H9yx.js → activity-store-D2oKh5ik.js} +1 -1
  4. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-sKMpwYNC.js → agent-avatar-dicebear-OKK1A-IR.js} +1 -1
  5. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-By5OXUfL.js +1 -0
  6. package/dist/gateway/static/root/assets/{agent-plugin-dialog-CxZeGEuL.js → agent-plugin-dialog-b24CxjaT.js} +1 -1
  7. package/dist/gateway/static/root/assets/{agents-admin-api-DFBVz3bV.js → agents-admin-api-D-DNV0ms.js} +1 -1
  8. package/dist/gateway/static/root/assets/agents-tJxKA9VH.js +66 -0
  9. package/dist/gateway/static/root/assets/{app-management-settings-panel-CWqbEntC.js → app-management-settings-panel-DxKh06hG.js} +1 -1
  10. package/dist/gateway/static/root/assets/{appearance-settings-QznCLnam.js → appearance-settings-C8CeHpdR.js} +1 -1
  11. package/dist/gateway/static/root/assets/{apps-page-wbVq-6PP.js → apps-page-CZSTLErb.js} +1 -1
  12. package/dist/gateway/static/root/assets/{archive-plugin-BclI5H7-.js → archive-plugin-aoEF5gna.js} +1 -1
  13. package/dist/gateway/static/root/assets/{automations-page-CTKIwPAS.js → automations-page-CSWWUZse.js} +1 -1
  14. package/dist/gateway/static/root/assets/automations-workspace-D2RJ-Lzn.js +6 -0
  15. package/dist/gateway/static/root/assets/{binary-plugins-D9FwadCs.js → binary-plugins-BM3Lr1BP.js} +1 -1
  16. package/dist/gateway/static/root/assets/{block-editor-Dqqtybdf.js → block-editor-DMZ3_pPz.js} +3 -3
  17. package/dist/gateway/static/root/assets/{browser-automation-inputs-FGALoJY8.js → browser-automation-inputs-BcBLdyVd.js} +1 -1
  18. package/dist/gateway/static/root/assets/browser-automations-page-BLSr6du1.js +3 -0
  19. package/dist/gateway/static/root/assets/browser-settings-page-BlDHSstc.js +3 -0
  20. package/dist/gateway/static/root/assets/{capabilities-CQuaJBPv.js → capabilities-BOJYAeEJ.js} +1 -1
  21. package/dist/gateway/static/root/assets/{capabilities-ClI4hof_.js → capabilities-Bf6NYuvT.js} +1 -1
  22. package/dist/gateway/static/root/assets/{capabilities-page-CbPvaNJF.js → capabilities-page-DHT4cB-Y.js} +2 -2
  23. package/dist/gateway/static/root/assets/capabilities-settings-panel-NZZNtjwZ.js +8 -0
  24. package/dist/gateway/static/root/assets/{capability-header-actions-XMz78V4c.js → capability-header-actions-V7TdNf7i.js} +1 -1
  25. package/dist/gateway/static/root/assets/{channels-CJUz97Cw.js → channels-sgWMfPkw.js} +1 -1
  26. package/dist/gateway/static/root/assets/{chat-terminal-dock-Dr3rujcs.js → chat-terminal-dock-B4HNp59x.js} +2 -2
  27. package/dist/gateway/static/root/assets/{computer-settings-page-G2lMB7CR.js → computer-settings-page-B2iwtbBu.js} +1 -1
  28. package/dist/gateway/static/root/assets/{connector-service-page-Cne5MBuz.js → connector-service-page-DTn3Z-MT.js} +1 -1
  29. package/dist/gateway/static/root/assets/connectors-page-BJii6NMu.js +1 -0
  30. package/dist/gateway/static/root/assets/{date-picker-yGmnkoC5.js → date-picker-DrUc4ivy.js} +1 -1
  31. package/dist/gateway/static/root/assets/{dependency-picker-CdKC_TNa.js → dependency-picker-Bs16sgfD.js} +1 -1
  32. package/dist/gateway/static/root/assets/{desktop-pet-C4d305Me.js → desktop-pet-Dg0Cp16O.js} +1 -1
  33. package/dist/gateway/static/root/assets/{desktop-pet-settings-hCS9Mddt.js → desktop-pet-settings-BeJg3R-X.js} +1 -1
  34. package/dist/gateway/static/root/assets/device-pairing-wizard-DPqFaLVI.js +1 -0
  35. package/dist/gateway/static/root/assets/{directory-picker-path-field-kYdBIm8m.js → directory-picker-path-field-BZkjdejC.js} +1 -1
  36. package/dist/gateway/static/root/assets/{extension-debug-page-odpIjn1q.js → extension-debug-page-CFnlTs2-.js} +1 -1
  37. package/dist/gateway/static/root/assets/{extension-page-C6Jn5baO.js → extension-page-BH25rxhA.js} +1 -1
  38. package/dist/gateway/static/root/assets/{extension-provider-DB4M3dc8.js → extension-provider-CmaIRIVP.js} +1 -1
  39. package/dist/gateway/static/root/assets/{extension-settings-page-Clx81lZy.js → extension-settings-page-D0af0S3r.js} +1 -1
  40. package/dist/gateway/static/root/assets/{fallback-models-pBVU4PxA.js → fallback-models-BD_9_8lg.js} +1 -1
  41. package/dist/gateway/static/root/assets/{gateway-config-swr-ArYo4YFd.js → gateway-config-swr-f-4qw3AG.js} +1 -1
  42. package/dist/gateway/static/root/assets/{gateway-realtime-BaE0shFY.js → gateway-realtime-BGhPOSfz.js} +1 -1
  43. package/dist/gateway/static/root/assets/gateway-realtime-store-BYe-jWB1.js +1 -0
  44. package/dist/gateway/static/root/assets/{gateway-settings-BcSr6MzW.js → gateway-settings-Bzrm6DMQ.js} +1 -1
  45. package/dist/gateway/static/root/assets/{gateway-startup-retry-BRCCiCBH.js → gateway-startup-retry-90pvxKox.js} +1 -1
  46. package/dist/gateway/static/root/assets/home-page-oHguULk0.js +2 -0
  47. package/dist/gateway/static/root/assets/{image-generation-api-B5FwRmo9.js → image-generation-api-CtDjTXwX.js} +1 -1
  48. package/dist/gateway/static/root/assets/{imports-page-7s8jzc2G.js → imports-page-CjFNSzDN.js} +1 -1
  49. package/dist/gateway/static/root/assets/index-_xgO2IDa.css +1 -0
  50. package/dist/gateway/static/root/assets/index-hn5CBddI.js +106 -0
  51. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-CyFSxteg.js → keyboard-shortcuts-settings-DKdWZ7pq.js} +1 -1
  52. package/dist/gateway/static/root/assets/{local-app-workbench-page-B-hYeH8P.js → local-app-workbench-page-CXJQpTS9.js} +1 -1
  53. package/dist/gateway/static/root/assets/{local-apps-page-CFt8G-ae.js → local-apps-page-9dyoG2s0.js} +1 -1
  54. package/dist/gateway/static/root/assets/{local-session-drafts-CLR702g5.js → local-session-drafts-CrD74S6k.js} +1 -1
  55. package/dist/gateway/static/root/assets/{locale-store-CeoW7A5a.js → locale-store-pmT2B_By.js} +1 -1
  56. package/dist/gateway/static/root/assets/logs-page-pMgnuu0O.js +2 -0
  57. package/dist/gateway/static/root/assets/{management-settings-BDuuXJ5t.js → management-settings-CxElPS5j.js} +1 -1
  58. package/dist/gateway/static/root/assets/{markdown-view-CdqdeQqI.js → markdown-view-B_7--qVD.js} +1 -1
  59. package/dist/gateway/static/root/assets/{media-plugins-hqKbHVyi.js → media-plugins-C6tT2oPH.js} +1 -1
  60. package/dist/gateway/static/root/assets/{messages-BpEhZm54.js → messages-Ib6DaUTo.js} +2 -2
  61. package/dist/gateway/static/root/assets/models-hub-cache-3slk24cw.js +1 -0
  62. package/dist/gateway/static/root/assets/note-detail-panel-4GI5kfs2.js +5 -0
  63. package/dist/gateway/static/root/assets/{notes-api-B0QQSN4M.js → notes-api-ChO4X97y.js} +1 -1
  64. package/dist/gateway/static/root/assets/notes-page-DaMnzWfF.js +8 -0
  65. package/dist/gateway/static/root/assets/{page-context-capture-button-Dp1RoS6x.js → page-context-capture-button-3bLWMSqt.js} +1 -1
  66. package/dist/gateway/static/root/assets/personal-page-BeAW5QQd.js +1 -0
  67. package/dist/gateway/static/root/assets/{product-open-page-DZyCQVVW.js → product-open-page-BiGwWy9s.js} +1 -1
  68. package/dist/gateway/static/root/assets/{product-preview-content-CrfIfrVJ.js → product-preview-content-Dvy5ieTo.js} +1 -1
  69. package/dist/gateway/static/root/assets/project-detail-page-BNgCsfeE.js +1 -0
  70. package/dist/gateway/static/root/assets/{projects-page-DZ98gcjB.js → projects-page-CATt0m8t.js} +1 -1
  71. package/dist/gateway/static/root/assets/{registry-api-Dzl61MkW.js → registry-api-Bi4muyaZ.js} +1 -1
  72. package/dist/gateway/static/root/assets/remote-access-hub-5o06KAdu.js +1 -0
  73. package/dist/gateway/static/root/assets/{runtime-tools-api-Cg9dqJon.js → runtime-tools-api-9bk1payF.js} +1 -1
  74. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-oEdBs0He.js → runtime-tools-settings-panel-BnRVbeGi.js} +1 -1
  75. package/dist/gateway/static/root/assets/{scenes-page-CVlz-PiN.js → scenes-page-BVjQ4A9S.js} +2 -2
  76. package/dist/gateway/static/root/assets/{schema-form-DIC8IlM1.js → schema-form-C0QHo3do.js} +1 -1
  77. package/dist/gateway/static/root/assets/send-session-input-BhWG0d-Z.js +1 -0
  78. package/dist/gateway/static/root/assets/{session-api-CVHFZq_A.js → session-api-D2J6VacQ.js} +1 -1
  79. package/dist/gateway/static/root/assets/session-manager-D2xce33J.js +16 -0
  80. package/dist/gateway/static/root/assets/sessions-page-BHYhAsHC.js +1 -0
  81. package/dist/gateway/static/root/assets/settings-advanced-gate-DO148Ocl.js +1 -0
  82. package/dist/gateway/static/root/assets/{settings-page-CN0_Np6E.js → settings-page-BT6dQ5nv.js} +1 -1
  83. package/dist/gateway/static/root/assets/setup-status-panel-B9EqOzrI.js +1 -0
  84. package/dist/gateway/static/root/assets/{share-link-dialog-C0gKFt8r.js → share-link-dialog-Cu1miKUo.js} +1 -1
  85. package/dist/gateway/static/root/assets/{share-preview-page-DxQ6yfYv.js → share-preview-page-CWH4BdnM.js} +1 -1
  86. package/dist/gateway/static/root/assets/{shares-api-tR66Fdly.js → shares-api-cGtd3rjc.js} +1 -1
  87. package/dist/gateway/static/root/assets/shares-settings-B3Z6sQEA.js +1 -0
  88. package/dist/gateway/static/root/assets/{skill-api-BFhU0NNu.js → skill-api-pzPKld3K.js} +1 -1
  89. package/dist/gateway/static/root/assets/{skill-reload-api-D_04Mpcb.js → skill-reload-api-VT8F0enn.js} +1 -1
  90. package/dist/gateway/static/root/assets/{skills-page-4-d-lfhq.js → skills-page-Busjd4VD.js} +1 -1
  91. package/dist/gateway/static/root/assets/{system-settings-panel-DHhaFWty.js → system-settings-panel-CDuqpAIG.js} +1 -1
  92. package/dist/gateway/static/root/assets/{task-detail-page-CHBEI5uz.js → task-detail-page-CNt-P3Kl.js} +2 -2
  93. package/dist/gateway/static/root/assets/{task-expandable-content-AGJtkFIu.js → task-expandable-content-Dgk9lYGd.js} +1 -1
  94. package/dist/gateway/static/root/assets/{theme-store-DezB9Sal.js → theme-store-D7m5Eng5.js} +1 -1
  95. package/dist/gateway/static/root/assets/{tracing-settings-page-BEHmd2wL.js → tracing-settings-page-B90frz6c.js} +1 -1
  96. package/dist/gateway/static/root/assets/{tunnel-api-Bbb_6pV4.js → tunnel-api-BJ2UEjeF.js} +1 -1
  97. package/dist/gateway/static/root/assets/{usage-page-BEiWznDq.js → usage-page-DrV2qcKO.js} +1 -1
  98. package/dist/gateway/static/root/assets/{use-autosave-BtTE5X_M.js → use-autosave-Ct1x4pqI.js} +1 -1
  99. package/dist/gateway/static/root/assets/{use-composer-attachments-BBHrVqB7.js → use-composer-attachments-CyWRo1B1.js} +1 -1
  100. package/dist/gateway/static/root/assets/{use-file-preview-expanded-CQmLEkdj.js → use-file-preview-expanded-JIgp5qPT.js} +2 -2
  101. package/dist/gateway/static/root/assets/user-model-page-CQReU8e2.js +2 -0
  102. package/dist/gateway/static/root/assets/{voice-api-key-field-tQsUdQnu.js → voice-api-key-field-CSG8Hx8V.js} +1 -1
  103. package/dist/gateway/static/root/assets/{voice-config-api-69Yqf0QM.js → voice-config-api-415pyWx8.js} +1 -1
  104. package/dist/gateway/static/root/assets/{work-discovery-overlay-Cvf8u31v.js → work-discovery-overlay-Dp107FXF.js} +1 -1
  105. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-CqYp6zjF.js → workflow-run-setup-panel-CZKJ6leF.js} +2 -2
  106. package/dist/gateway/static/root/assets/workflows-page-2HuveBs_.js +6 -0
  107. package/dist/gateway/static/root/assets/{workspace-api-Bu6Csrxf.js → workspace-api-DO_TWsiS.js} +2 -2
  108. package/dist/gateway/static/root/assets/{xopc-cloud-account-card-D3Cyk8pp.js → xopc-cloud-account-card-CBjtpPiL.js} +1 -1
  109. package/dist/gateway/static/root/index.html +27 -27
  110. package/dist/package.js +1 -1
  111. package/dist/packages/realtime-protocol/src/voice-catalog.js +7 -2
  112. package/dist/src/agent/agent-manager.js +3 -3
  113. package/dist/src/agent/background-review/run-background-review.js +1 -1
  114. package/dist/src/agent/embedded/run-turn.js +38 -0
  115. package/dist/src/agent/external-tools/endpoint-provider.js +2 -2
  116. package/dist/src/agent/prompt/response-language.js +9 -1
  117. package/dist/src/agent/service/process-direct-streaming.js +1 -1
  118. package/dist/src/agent/service.js +2 -2
  119. package/dist/src/agent/session/session-config-service.js +0 -13
  120. package/dist/src/agent/skills/index.js +1 -1
  121. package/dist/src/agent/skills/managed-store.js +1 -1
  122. package/dist/src/agent/skills/skill-manage-ops.js +1 -1
  123. package/dist/src/agent/tasks/task-judge-service.d.ts +2 -2
  124. package/dist/src/agent/tasks/task-judge-service.js +16 -9
  125. package/dist/src/agent/tools/factory.js +1 -1
  126. package/dist/src/agent/tools/personal-read-tool.js +1 -1
  127. package/dist/src/agent/tools/xopc-use-tool.js +8 -4
  128. package/dist/src/agent/workspace-runtime/registry.js +1 -1
  129. package/dist/src/agent-catalog/capabilities.js +2 -2
  130. package/dist/src/automations/capabilities/drafts.js +1 -1
  131. package/dist/src/automations/service/action-executor.js +1 -1
  132. package/dist/src/bootstrap/application-state.js +1 -1
  133. package/dist/src/capabilities/runtime/dispatcher.js +1 -1
  134. package/dist/src/capabilities/runtime/product.js +1 -1
  135. package/dist/src/chat-commands/agent-edit.js +1 -1
  136. package/dist/src/cli/bin.js +2 -2
  137. package/dist/src/cli/commands/agent.js +3 -3
  138. package/dist/src/cli/commands/agents.js +1 -1
  139. package/dist/src/cli/commands/auth.js +1 -1
  140. package/dist/src/cli/commands/extension-agent-plugin.js +1 -1
  141. package/dist/src/cli/commands/extension-dev.js +1 -1
  142. package/dist/src/cli/commands/extension-marketplace.js +1 -1
  143. package/dist/src/cli/commands/extension.js +1 -1
  144. package/dist/src/cli/commands/gateway/lifecycle.js +1 -1
  145. package/dist/src/cli/commands/gateway-ssh-tunnel.js +1 -1
  146. package/dist/src/cli/commands/import.js +1 -1
  147. package/dist/src/cli/commands/mcp.js +2 -2
  148. package/dist/src/cli/commands/models.js +3 -3
  149. package/dist/src/cli/commands/onboard/model.js +3 -3
  150. package/dist/src/cli/commands/onboard.js +1 -1
  151. package/dist/src/cli/commands/platform.js +1 -1
  152. package/dist/src/cli/commands/profile.js +1 -1
  153. package/dist/src/cli/commands/tunnel.js +1 -1
  154. package/dist/src/cli/commands/update.js +1 -1
  155. package/dist/src/cli/extension-cli-register.js +1 -1
  156. package/dist/src/cli/utils/init-workspace-core.js +1 -1
  157. package/dist/src/config/agent-profile.js +2 -2
  158. package/dist/src/config/index.js +1 -1
  159. package/dist/src/config/loader.js +1 -1
  160. package/dist/src/config/models-json.js +1 -1
  161. package/dist/src/config/schema.js +1 -1
  162. package/dist/src/extensions/agent-plugins/validation.js +1 -1
  163. package/dist/src/gateway/agents-admin.js +2 -2
  164. package/dist/src/gateway/chat-stream/mapper.d.ts +2 -0
  165. package/dist/src/gateway/chat-stream/mapper.js +4 -1
  166. package/dist/src/gateway/chat-stream/protocol.d.ts +4 -1
  167. package/dist/src/gateway/hono/lib/config-payload.js +1 -1
  168. package/dist/src/gateway/hono/routes/chat-model-config.d.ts +0 -4
  169. package/dist/src/gateway/hono/routes/chat-model-config.js +0 -6
  170. package/dist/src/gateway/hono/routes/config-patch/misc.js +2 -2
  171. package/dist/src/gateway/hono/routes/connectors.js +1 -1
  172. package/dist/src/gateway/hono/routes/context-sources.js +1 -1
  173. package/dist/src/gateway/hono/routes/notes.js +2 -2
  174. package/dist/src/gateway/hono/routes/personal-agent.js +4 -2
  175. package/dist/src/gateway/hono/routes/projects.js +2 -2
  176. package/dist/src/gateway/hono/routes/session-input-handler.js +1 -1
  177. package/dist/src/gateway/hono/routes/tasks.js +1 -1
  178. package/dist/src/gateway/hono/routes/voice.js +12 -4
  179. package/dist/src/gateway/image-generation-setup.js +1 -1
  180. package/dist/src/gateway/lock.js +1 -1
  181. package/dist/src/gateway/rate-limit/buckets.d.ts +1 -1
  182. package/dist/src/gateway/rate-limit/buckets.js +2 -2
  183. package/dist/src/gateway/run-loop.js +1 -1
  184. package/dist/src/gateway/server.js +1 -1
  185. package/dist/src/gateway/service/run-gateway-agent.js +8 -3
  186. package/dist/src/gateway/service.js +2 -2
  187. package/dist/src/gateway/side-chat/manager.js +1 -1
  188. package/dist/src/gateway/xopc-cloud-capability-setup.js +1 -1
  189. package/dist/src/local-apps/service.js +1 -1
  190. package/dist/src/personal-agent/communication.d.ts +2 -1
  191. package/dist/src/personal-agent/communication.js +4 -3
  192. package/dist/src/personal-agent/proactivity/service.js +1 -1
  193. package/dist/src/personal-agent/prompt-context.js +3 -3
  194. package/dist/src/personal-agent/prompts.d.ts +1 -0
  195. package/dist/src/personal-agent/prompts.js +29 -5
  196. package/dist/src/personal-agent/reply-composer.js +19 -4
  197. package/dist/src/personal-agent/reply-style.d.ts +4 -2
  198. package/dist/src/personal-agent/reply-style.js +57 -5
  199. package/dist/src/personal-agent/service.js +2 -2
  200. package/dist/src/providers/model-catalog-persistence.js +1 -1
  201. package/dist/src/routing/resolve-route.js +1 -1
  202. package/dist/src/routing/resolve-tui-session-key.js +1 -1
  203. package/dist/src/tasks/capabilities/read.js +2 -2
  204. package/dist/src/tasks/capabilities/write.js +10 -1
  205. package/dist/src/tasks/task-application-service.js +5 -4
  206. package/dist/src/tasks/task-context-assembler.js +1 -0
  207. package/dist/src/tasks/task-contract-definition.d.ts +1 -1
  208. package/dist/src/tasks/task-contract-definition.js +2 -2
  209. package/dist/src/tasks/task-contract-planner.d.ts +1 -0
  210. package/dist/src/tasks/task-contract-planner.js +2 -1
  211. package/dist/src/tasks/task-handoff-service.js +1 -1
  212. package/dist/src/tasks/task-language.d.ts +7 -0
  213. package/dist/src/tasks/task-language.js +15 -0
  214. package/dist/src/tasks/task-read-model-projector.js +3 -2
  215. package/dist/src/tasks/task-result-delivery-service.js +2 -1
  216. package/dist/src/tasks/task-run-coordinator.js +22 -8
  217. package/dist/src/tasks/task-run-dispatcher.js +8 -6
  218. package/dist/src/tui/backends/embedded-backend.js +2 -2
  219. package/dist/src/voice/platform-catalog.d.ts +1 -0
  220. package/dist/src/voice/platform-settings.d.ts +1 -1
  221. package/dist/src/voice/platform-settings.js +6 -2
  222. package/dist/src/voice/platform-streams.js +3 -1
  223. package/dist/src/voice/realtime/omniRoute.d.ts +1 -1
  224. package/dist/src/voice/realtime/omniRoute.js +4 -1
  225. package/dist/src/voice/realtime/persona-context.js +1 -1
  226. package/dist/src/voice/tts/providers/xopc-cloud-speech.js +6 -2
  227. package/dist/src/voice/tts/speech-provider-types.d.ts +1 -0
  228. package/package.json +4 -4
  229. package/dist/gateway/static/root/assets/agent-defaults-settings-panel-DLrGOiCS.js +0 -1
  230. package/dist/gateway/static/root/assets/agents-CUnG8q3J.js +0 -66
  231. package/dist/gateway/static/root/assets/automations-workspace-BblZP4ft.js +0 -6
  232. package/dist/gateway/static/root/assets/browser-automations-page-hQbQFWl-.js +0 -3
  233. package/dist/gateway/static/root/assets/browser-settings-page-DQvfXaeq.js +0 -3
  234. package/dist/gateway/static/root/assets/capabilities-settings-panel-CjApEiV4.js +0 -8
  235. package/dist/gateway/static/root/assets/connectors-page-CbxL6ENI.js +0 -1
  236. package/dist/gateway/static/root/assets/device-pairing-wizard-C6qeCyfO.js +0 -1
  237. package/dist/gateway/static/root/assets/gateway-realtime-store-CHAa_VNb.js +0 -1
  238. package/dist/gateway/static/root/assets/home-page-CKeRXki2.js +0 -2
  239. package/dist/gateway/static/root/assets/index-B3BVcMQj.js +0 -106
  240. package/dist/gateway/static/root/assets/index-BU0KqtLI.css +0 -1
  241. package/dist/gateway/static/root/assets/logs-page-BQ9AzAj9.js +0 -2
  242. package/dist/gateway/static/root/assets/models-hub-cache-D0yA-nf6.js +0 -1
  243. package/dist/gateway/static/root/assets/note-detail-panel-G_6LpTik.js +0 -5
  244. package/dist/gateway/static/root/assets/notes-page-kBo3rUvj.js +0 -8
  245. package/dist/gateway/static/root/assets/personal-page-Bf07rfSd.js +0 -1
  246. package/dist/gateway/static/root/assets/project-detail-page-C3wJ8U07.js +0 -1
  247. package/dist/gateway/static/root/assets/remote-access-hub-BvhaF5Pi.js +0 -1
  248. package/dist/gateway/static/root/assets/send-session-input-C449pdoe.js +0 -1
  249. package/dist/gateway/static/root/assets/session-manager-CKFTwYtq.js +0 -16
  250. package/dist/gateway/static/root/assets/sessions-page-DtB119_G.js +0 -1
  251. package/dist/gateway/static/root/assets/settings-advanced-gate-2ciK8mPP.js +0 -1
  252. package/dist/gateway/static/root/assets/setup-status-panel-VtNv07PN.js +0 -1
  253. package/dist/gateway/static/root/assets/shares-settings-C_ZOqMjz.js +0 -1
  254. package/dist/gateway/static/root/assets/user-model-page-B4Gwo5T7.js +0 -2
  255. package/dist/gateway/static/root/assets/workflows-page-DMzGl3CE.js +0 -6
@@ -1,8 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-swr-BIWyz7Rc.js","assets/rolldown-runtime-aKtaBQYM.js","assets/vendor-react-BOUWij0V.js"])))=>i.map(i=>d[i]);
2
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{t as i}from"./preload-helper-zJ_50EbN.js";import{f as a,g as o,m as s,r as c,t as l}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{t as u}from"./chevron-right-BweFrslA.js";import{n as d,r as f,t as p}from"./popover-select-BgSdSbCL.js";import{t as m}from"./circle-check-C23XjkUj.js";import{t as h}from"./circle-dashed-8qMD7gHf.js";import{t as g}from"./cloud-C4-yfnnk.js";import{t as _}from"./external-link-DjqjBmc3.js";import{t as v}from"./secret-input-D93UrW4C.js";import{t as y}from"./eye-CABVeTq0.js";import{t as b}from"./loader-circle-CifKLtgG.js";import{t as x}from"./mic-CuUb7zc-.js";import{t as S}from"./pencil-DmIY3Oa-.js";import{t as C}from"./play-kxZvpBg8.js";import{t as w}from"./plus-Q2yW6OE7.js";import{t as T}from"./settings-2-D-csvaET.js";import{t as E}from"./x-B_N4OPjy.js";import{t as D}from"./messages-BpEhZm54.js";import{t as O}from"./cn-JdwAhgNB.js";import{a as k,c as A,i as j,n as M,r as N}from"./locale-store-CeoW7A5a.js";import{a as P,i as F,n as I,o as L,r as R,s as ee,t as z}from"./dist-BGTk37IG.js";import{i as B}from"./vendor-swr-BIWyz7Rc.js";import{t as V}from"./button-CS04eWY9.js";import{n as te,t as ne}from"./interaction-BdhHBbYa.js";import{n as re,r as H}from"./gateway-config-swr-ArYo4YFd.js";import{a as U,o as ie,s as ae}from"./form-field-width-DJw_jULe.js";import{n as W}from"./is-masked-secret-DOkL5b_X.js";import{t as G}from"./skeleton-BwbyijEw.js";import{i as K,o as q}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{t as J}from"./electron-env-Dit0bHgy.js";import{n as Y,t as oe}from"./settings-form-draft-Dy10ldo8.js";import{i as se,r as X,t as ce}from"./models-hub-cache-D0yA-nf6.js";import{At as Z,Bc as le,Bt as ue,Cn as de,Ct as fe,Dt as pe,Et as me,Fs as he,Ft as ge,Ht as _e,Io as ve,It as ye,Lt as be,Mt as xe,No as Se,On as Ce,Oo as we,Ot as Te,Pt as Ee,Rt as De,St as Oe,Tt as ke,Ut as Ae,W as je,Wo as Me,Wt as Ne,Zo as Pe,Zr as Fe,_a as Ie,_o as Le,_t as Re,ba as ze,bt as Be,ca as Ve,co as He,da as Ue,ga as We,go as Ge,gt as Ke,ha as qe,ia as Je,jt as Ye,kt as Xe,ma as Ze,na as Qe,oo as $e,ra as et,sa as tt,ui as nt,va as rt,vs as it,vt as at,wt as ot,xt as st,ya as ct,yt as lt,zc as ut,zs as dt,zt as ft}from"./index-B3BVcMQj.js";import{t as pt}from"./page-tabs-D2xpUV26.js";import{t as mt}from"./number-input-DDeqHK-G.js";import{n as ht,r as gt}from"./settings-page-layout-X1x-2Cp9.js";import{n as _t,t as vt}from"./settings-form-section-exRhP9xn.js";import{t as yt}from"./settings-loading-skeleton-CAmWMaOT.js";import{n as bt,t as xt}from"./use-autosave-BtTE5X_M.js";import{c as St,d as Ct,i as wt,l as Tt,n as Et,o as Dt,r as Ot,s as kt,t as At}from"./voice-config-api-69Yqf0QM.js";import{t as jt}from"./voice-api-key-field-tQsUdQnu.js";import{a as Mt,i as Nt,n as Pt,o as Ft,r as It,t as Lt}from"./image-generation-api-B5FwRmo9.js";import{t as Rt}from"./xopc-cloud-account-card-D3Cyk8pp.js";var zt=n(),Q=e(t(),1),$=r(),Bt={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 必须使用“名称: 值”格式,每行一个。`}},Vt=`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 Ht(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 Ut(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 Wt({open:e,onOpenChange:t,provider:n,configured:r,language:i,onSaved:a}){let o=Bt[i],[s,c]=(0,Q.useState)(``),[l,u]=(0,Q.useState)(``),[d,f]=(0,Q.useState)(``),[m,h]=(0,Q.useState)(`bearer`),[g,_]=(0,Q.useState)(`x-api-key`),[x,S]=(0,Q.useState)(``),[C,T]=(0,Q.useState)(``),[D,k]=(0,Q.useState)(``),[A,j]=(0,Q.useState)(`/images/generations`),[M,N]=(0,Q.useState)(`/images/edits`),[B,te]=(0,Q.useState)(``),[ne,re]=(0,Q.useState)(``),[H,U]=(0,Q.useState)([Ht()]),[ie,ae]=(0,Q.useState)(``),[G,J]=(0,Q.useState)(),[Y,oe]=(0,Q.useState)(!1),[se,X]=(0,Q.useState)(),[ce,Z]=(0,Q.useState)(),[le,ue]=(0,Q.useState)();(0,Q.useEffect)(()=>{if(!e)return;let t=n?.imageGeneration;c(n?.providerId??``),u(t?.name??``),f(n?.baseUrl??``),h(t?.auth.type??`bearer`),_(t?.auth.type===`header`?t.auth.headerName:`x-api-key`),S(r?`••••••••••••`:``),T(t?.apiKeyUrl??``),k(t?.documentationUrl??``),j(t?.paths?.generations??`/images/generations`),N(t?.paths?.edits??`/images/edits`),te(t?.network?.allowedHosts.join(`
4
- `)??``),re(Object.entries(n?.headers??{}).map(([e,t])=>`${e}: ${t}`).join(`
5
- `)),U(t?.models.map(Ht)??[Ht()]),ae(t?.defaultModel??``),Z(void 0),J(void 0),oe(!1),X(void 0),ue(void 0)},[r,e,n]);let de=(0,Q.useMemo)(()=>H.filter(e=>e.id.trim()).map(e=>({value:e.id.trim(),label:e.name.trim()||e.id.trim()})),[H]),fe=(e,t)=>{U(n=>n.map((n,r)=>r===e?{...n,...t}:n))},pe=()=>{let e=s.trim(),t=H.map(e=>({...e,id:e.id.trim(),name:e.name.trim()}));if(!e||!l.trim()||!d.trim()||t.some(e=>!e.id))throw Error(o.required);if(new Set(t.map(e=>e.id)).size!==t.length)throw Error(o.duplicateModels);let n=ie||t[0]?.id;if(!n||!t.some(e=>e.id===n))throw Error(o.required);let r;try{r=Ut(ne)}catch{throw Error(o.invalidHeaders)}return{providerId:e,input:{baseUrl:d.trim(),...r?{headers:r}:{},imageGeneration:{api:`openai-images`,name:l.trim(),...D.trim()?{documentationUrl:D.trim()}:{},...C.trim()?{apiKeyUrl:C.trim()}:{},defaultModel:n,auth:m===`header`?{type:`header`,headerName:g.trim()}:{type:m},paths:{...A.trim()?{generations:A.trim()}:{},...M.trim()?{edits:M.trim()}:{}},...B.trim()?{network:{allowedHosts:B.split(`
6
- `).map(e=>e.trim()).filter(Boolean)}}:{},models:t.map(e=>({...e.original,id:e.id,...e.name?{name:e.name}:{name:void 0},capabilities:{...e.original.capabilities,generate:{...e.original.capabilities.generate,maxCount:Math.max(1,Number.parseInt(e.maxCount,10)||1),supportsSize:e.supportsSize},edit:{...e.original.capabilities.edit,enabled:e.editEnabled}},defaults:{...e.original.defaults,...e.defaultCount?{count:Math.max(1,Number.parseInt(e.defaultCount,10)||1)}:{count:void 0},...e.defaultSize.trim()?{size:e.defaultSize.trim()}:{size:void 0},...e.outputFormat?{outputFormat:e.outputFormat}:{outputFormat:void 0}}}))}}}},me=async()=>{let e=pe();return await Nt(e.providerId,e.input),m!==`none`&&x.trim()&&!W(x)&&await Mt(e.providerId,x.trim()),await a(e.providerId),e},he=async()=>{J(`save`),X(void 0),Z(void 0);try{await me(),S(m===`none`?``:`••••••••••••`),Z(o.saved)}catch(e){X(e instanceof Error?e.message:String(e))}finally{J(void 0)}},ge=async()=>{J(`test`),X(void 0),Z(void 0),ue(void 0);try{let e=await me();ue((await Ft(e.providerId,e.input.imageGeneration.defaultModel)).images[0]?.dataUrl),Z(o.testReady)}catch(e){X(e instanceof Error?e.message:String(e))}finally{J(void 0)}},_e=async()=>{if(n){if(!Y){oe(!0);return}J(`delete`),X(void 0);try{await Lt(n.providerId),await a(),t(!1)}catch(e){X(e instanceof Error?e.message:String(e))}finally{J(void 0)}}};return(0,$.jsx)(z,{open:e,onOpenChange:t,children:(0,$.jsxs)(L,{children:[(0,$.jsx)(P,{className:O(`xopc-dialog-overlay fixed inset-0 bg-scrim`,q)}),(0,$.jsxs)(R,{className:O(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(88vh,760px)] w-[min(calc(100%-2rem),52rem)] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-edge bg-surface-overlay shadow-popover`,K),onOpenAutoFocus:e=>e.preventDefault(),children:[(0,$.jsxs)(`header`,{className:`flex shrink-0 items-start justify-between gap-4 border-b border-edge px-5 py-4`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(ee,{className:`font-semibold text-fg`,children:n?o.editTitle:o.addTitle}),(0,$.jsx)(F,{className:`mt-1 text-sm text-fg-muted`,children:o.intro})]}),(0,$.jsx)(I,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:`rounded-md p-1 text-fg-muted hover:bg-surface-inset hover:text-fg`,"aria-label":o.cancel,children:(0,$.jsx)(E,{className:`size-5`})})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-6 overflow-y-auto px-5 py-4`,children:[(0,$.jsxs)(`section`,{className:`space-y-4`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-subtle`,children:o.connection}),(0,$.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.providerId,(0,$.jsx)(`input`,{value:s,disabled:!!n,onChange:e=>c(e.target.value),placeholder:`my-image-service`,className:Vt}),(0,$.jsx)(`span`,{className:`mt-1 block font-normal text-fg-subtle`,children:o.providerIdHint})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.name,(0,$.jsx)(`input`,{value:l,onChange:e=>u(e.target.value),placeholder:`My Image Service`,className:Vt})]})]}),(0,$.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[o.baseUrl,(0,$.jsx)(`input`,{value:d,onChange:e=>f(e.target.value),placeholder:`https://api.example.com/v1`,className:Vt})]}),(0,$.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.auth,(0,$.jsx)(p,{value:m,options:[{value:`bearer`,label:o.bearer},{value:`header`,label:o.header},{value:`none`,label:o.none}],placeholder:o.auth,allowEmpty:!1,onChange:e=>h(e),triggerClassName:`mt-1.5`})]}),m===`header`?(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.headerName,(0,$.jsx)(`input`,{value:g,onChange:e=>_(e.target.value),className:Vt})]}):null]}),m===`none`?null:(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`mb-1.5 flex items-center justify-between`,children:[(0,$.jsx)(`label`,{htmlFor:`custom-image-api-key`,className:`text-xs font-medium text-fg-muted`,children:o.apiKey}),C.trim()?(0,$.jsxs)(`a`,{href:C.trim(),target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent hover:underline`,children:[o.openKeyPage,(0,$.jsx)(ut,{className:`size-3.5`})]}):null]}),(0,$.jsx)(v,{id:`custom-image-api-key`,value:x,onChange:e=>S(W(x)?e.replace(/^•+/,``):e),labels:{show:o.show,hide:o.hide,copy:o.copy,copied:o.copied},reveal:()=>Ne(s).then(e=>e.apiKey),loadFailedLabel:o.revealFailed,notInConfigFile:o.notRevealable}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:o.apiKeyHint})]}),(0,$.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.apiKeyUrl,(0,$.jsx)(`input`,{value:C,onChange:e=>T(e.target.value),placeholder:`https://…`,className:Vt})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.docsUrl,(0,$.jsx)(`input`,{value:D,onChange:e=>k(e.target.value),placeholder:`https://…`,className:Vt})]})]}),(0,$.jsxs)(`details`,{className:`rounded-lg border border-edge bg-surface-inset px-3 py-2.5`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted`,children:o.paths}),(0,$.jsxs)(`div`,{className:`mt-3 grid gap-4 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.generationsPath,(0,$.jsx)(`input`,{value:A,onChange:e=>j(e.target.value),className:Vt})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.editsPath,(0,$.jsx)(`input`,{value:M,onChange:e=>N(e.target.value),className:Vt})]})]}),(0,$.jsxs)(`label`,{className:`mt-4 block text-xs font-medium text-fg-muted`,children:[o.allowedHosts,(0,$.jsx)(`textarea`,{value:B,onChange:e=>te(e.target.value),rows:2,placeholder:`127.0.0.1
7
- image-server.lan`,className:`mt-1.5 w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 font-mono text-xs text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`}),(0,$.jsx)(`span`,{className:`mt-1 block font-normal text-fg-subtle`,children:o.allowedHostsHint})]}),(0,$.jsxs)(`label`,{className:`mt-4 block text-xs font-medium text-fg-muted`,children:[o.staticHeaders,(0,$.jsx)(`textarea`,{value:ne,onChange:e=>re(e.target.value),rows:3,className:`mt-1.5 w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 font-mono text-xs text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`}),(0,$.jsx)(`span`,{className:`mt-1 block font-normal text-fg-subtle`,children:o.staticHeadersHint})]})]})]}),(0,$.jsxs)(`section`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-subtle`,children:o.models}),(0,$.jsxs)(V,{variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,onClick:()=>U(e=>[...e,Ht()]),children:[(0,$.jsx)(w,{className:`size-4`}),o.addModel]})]}),(0,$.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[o.defaultModel,(0,$.jsx)(p,{value:ie||de[0]?.value||``,options:de,placeholder:o.defaultModel,allowEmpty:!1,onChange:ae,triggerClassName:`mt-1.5 max-w-sm`})]}),H.map((e,t)=>(0,$.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,$.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.modelId,(0,$.jsx)(`input`,{value:e.id,onChange:e=>fe(t,{id:e.target.value}),placeholder:`image-1`,className:Vt})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.modelName,(0,$.jsx)(`input`,{value:e.name,onChange:e=>fe(t,{name:e.target.value}),className:Vt})]})]}),(0,$.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2 lg:grid-cols-4`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.maxCount,(0,$.jsx)(`input`,{type:`number`,min:1,value:e.maxCount,onChange:e=>fe(t,{maxCount:e.target.value}),className:Vt})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.defaultCount,(0,$.jsx)(`input`,{type:`number`,min:1,value:e.defaultCount,onChange:e=>fe(t,{defaultCount:e.target.value}),className:Vt})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.defaultSize,(0,$.jsx)(`input`,{value:e.defaultSize,onChange:e=>fe(t,{defaultSize:e.target.value}),placeholder:`1024x1024`,className:Vt})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[o.format,(0,$.jsx)(p,{value:e.outputFormat,options:[{value:`png`,label:`PNG`},{value:`jpeg`,label:`JPEG`},{value:`webp`,label:`WebP`}],placeholder:o.format,allowEmpty:!0,onChange:e=>fe(t,{outputFormat:e}),triggerClassName:`mt-1.5`})]})]}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-4`,children:[(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:e.supportsSize,onChange:e=>fe(t,{supportsSize:e.target.checked})}),o.supportsSize]}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:e.editEnabled,onChange:e=>fe(t,{editEnabled:e.target.checked})}),o.edit]}),(0,$.jsxs)(`button`,{type:`button`,disabled:H.length===1,onClick:()=>U(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)(Le,{className:`size-3.5`}),o.remove]})]})]},t))]}),le?(0,$.jsxs)(`section`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 text-sm font-medium text-fg`,children:[(0,$.jsx)(y,{className:`size-4`}),o.testReady]}),(0,$.jsx)(`img`,{src:le,alt:`Generated provider test`,className:`max-h-72 rounded-lg object-contain`})]}):null,ce?(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:ce}):null,se?(0,$.jsx)(`p`,{className:`rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-600 dark:text-red-400`,children:se}):null]}),(0,$.jsxs)(`footer`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-t border-edge px-5 py-3`,children:[n?(0,$.jsxs)(V,{variant:`secondary`,className:`border-red-500/30 text-red-600 hover:bg-red-500/10 dark:text-red-400`,disabled:!!G,onClick:()=>void _e(),children:[G===`delete`?(0,$.jsx)(b,{className:`size-4 animate-spin`}):(0,$.jsx)(Le,{className:`size-4`}),Y?o.confirmDelete:o.delete]}):null,(0,$.jsxs)(`div`,{className:`ml-auto flex gap-2`,children:[(0,$.jsx)(I,{asChild:!0,children:(0,$.jsx)(V,{variant:`secondary`,children:o.cancel})}),(0,$.jsxs)(V,{variant:`secondary`,disabled:!!G,onClick:()=>void ge(),children:[G===`test`?(0,$.jsx)(b,{className:`size-4 animate-spin`}):null,G===`test`?o.testing:o.test]}),(0,$.jsxs)(V,{variant:`primary`,disabled:!!G,onClick:()=>void he(),children:[G===`save`?(0,$.jsx)(b,{className:`size-4 animate-spin`}):null,G===`save`?o.saving:o.save]})]})]})]})]})})}var Gt=`••••••••••••`,Kt={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 qt(){let e=await k(N(`/api/image-generation/default`));if(!e.payload)throw Error(`Invalid default image generation response`);return e.payload}function Jt(e){let t=e?.indexOf(`/`)??-1;return t>0?e.slice(0,t):void 0}function Yt(e){let t=e?.indexOf(`/`)??-1;return t>0?e.slice(t+1):void 0}function Xt(e){return Object.fromEntries(e.configFields.map(t=>[t.key,e.config[t.key]??(t.required?t.options?.[0]?.value??``:``)]))}function Zt(e){let t=(0,zt.c)(11),{field:n,value:r,onChange:i}=e,a;t[0]!==n.label||t[1]!==n.options||t[2]!==n.placeholder||t[3]!==n.required||t[4]!==n.type||t[5]!==i||t[6]!==r?(a=n.type===`select`?(0,$.jsx)(p,{value:r,options:(n.options??[]).map(Qt),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 Qt(e){return{value:e.value,label:e.label}}function $t(){let e=(0,zt.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(G,{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(en)}),(0,$.jsx)(G,{className:`h-64 rounded-xl`})]}),e[1]=n):n=e[1],n}function en(e,t){return(0,$.jsx)(G,{className:`h-24 rounded-xl`},t)}function tn(){let e=M(e=>e.language),t=Kt[e],n=!!A(e=>e.conversationId),[r,a]=(0,Q.useState)(``),[o,s]=(0,Q.useState)(``),[c,l]=(0,Q.useState)(``),[u,d]=(0,Q.useState)({}),[f,h]=(0,Q.useState)(!1),[g,_]=(0,Q.useState)(),[y,x]=(0,Q.useState)(!1),[S,C]=(0,Q.useState)(!1),[E,D]=(0,Q.useState)(),{data:O,isLoading:j,error:P,mutate:F}=B(n?N(`/api/image-generation/catalog`):null,It,{revalidateOnFocus:!1}),{data:I,isLoading:L,error:R,mutate:ee}=B(n?N(`/api/image-generation/custom-providers`):null,Pt,{revalidateOnFocus:!1}),{data:z,isLoading:te,error:ne,mutate:H}=B(n?`default-image-generation`:null,qt,{revalidateOnFocus:!1});(0,Q.useEffect)(()=>{if(!O||!z)return;let e=Jt(z.model?.primary),t=O.find(t=>t.id===e)??O.find(e=>e.configured)??O[0];t&&(a(t.id),s(t.id===e&&Yt(z.model?.primary)||t.defaultModel),l(t.configured?Gt:``),d(Xt(t)))},[z,O]);let U=O?.find(e=>e.id===r),ie=U?U.apiKeyUrl??Te(U.id,e)[0]?.href:void 0,ae=(0,Q.useMemo)(()=>(U?.models??[]).map(e=>({value:e,label:e})),[U?.models]),G=z?.model?.primary,K=!!(U&&o&&(U.credentialMode!==`api-key`||U.configured||c.trim())&&U.configFields.every(e=>!e.required||u[e.key]?.trim()));if(!n)return(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.connect});if(j||L||te)return(0,$.jsx)($t,{});if(P||R||ne||!O||!I)return(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:t.loadError});let q=e=>{a(e.id),s(e.defaultModel),l(e.configured?Gt:``),d(Xt(e)),_(void 0)},J=()=>{D(void 0),C(!0)},Y=()=>{let e=I.find(e=>e.providerId===U?.id);e&&(D(e),C(!0))},oe=async e=>{let[t,n]=await Promise.all([ee(),F()]);if(e&&n?.some(t=>t.id===e)){let r=n.find(t=>t.id===e);a(r.id),s(r.defaultModel),l(r.configured?Gt:``),d(Xt(r)),D(t?.find(t=>t.providerId===e))}},se=async()=>{if(!(!U||!K)){h(!0),_(void 0),x(!1);try{let e=await k(N(`/api/image-generation/default/setup`),{method:`POST`,body:JSON.stringify({providerId:U.id,modelId:o,...c.trim()&&!W(c)?{apiKey:c.trim()}:{},providerConfig:Object.fromEntries(Object.entries(u).filter(([,e])=>e.trim()))})});if(!e.payload)throw Error(`Invalid setup response`);await Promise.all([H(e.payload.default,{revalidate:!1}),F(e.payload.providers,{revalidate:!1}),i(async()=>{let{mutate:e}=await import(`./vendor-swr-BIWyz7Rc.js`).then(e=>e.r);return{mutate:e}},__vite__mapDeps([0,1,2])).then(({mutate:e})=>Promise.all([e(`settings-agent-defaults`),e(`settings-gateway-agents`)])),re()]),l(Gt),x(!0)}catch(e){_(e instanceof Error?e.message:String(e))}finally{h(!1)}}};return(0,$.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,$.jsx)(`section`,{className:`rounded-xl bg-surface-hover/20 p-4`,children:(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,$.jsx)(`div`,{className:`rounded-lg bg-accent/10 p-2 text-accent`,children:(0,$.jsx)(dt,{className:`size-5`})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.title}),(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:t.intro})]})]})}),(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-subtle`,children:t.provider}),(0,$.jsxs)(V,{variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,onClick:J,children:[(0,$.jsx)(w,{className:`size-4`}),t.addService]})]}),(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:O.map(e=>{let n=e.id===r,i=e.id===Jt(G);return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>q(e),className:`min-h-24 rounded-xl p-4 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${n?`bg-accent-soft shadow-surface`:`bg-surface-base/55 hover:bg-surface-hover`}`,children:[(0,$.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`truncate font-medium text-fg`,children:e.label}),e.source===`custom`?(0,$.jsx)(`span`,{className:`rounded-full bg-surface-inset px-2 py-0.5 text-[10px] text-fg-subtle`,children:t.custom}):null]}),(0,$.jsx)(`span`,{"aria-hidden":!i,className:`shrink-0 rounded-full bg-accent/10 px-2 py-0.5 text-[11px] font-medium text-accent ${i?``:`invisible`}`,children:t.current})]}),(0,$.jsxs)(`span`,{className:`mt-2 flex items-center gap-1.5 text-xs ${e.configured?`text-emerald-600 dark:text-emerald-400`:`text-fg-muted`}`,children:[e.configured||e.credentialMode!==`api-key`?(0,$.jsx)(m,{className:`size-3.5`}):(0,$.jsx)(he,{className:`size-3.5`}),e.configured||e.credentialMode!==`api-key`?t.configured:t.needsKey]})]},e.id)})})]}),U?(0,$.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 p-4`,children:[(0,$.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[t.model,(0,$.jsx)(p,{value:o,options:ae,placeholder:t.selectModel,allowEmpty:!1,onChange:s,triggerClassName:`mt-1.5`})]}),U.configFields.filter(e=>e.required).map(e=>(0,$.jsx)(Zt,{field:e,value:u[e.key]??``,onChange:t=>d(n=>({...n,[e.key]:t}))},e.key))]}),U.source===`custom`?(0,$.jsx)(`div`,{className:`mt-4 flex justify-end`,children:(0,$.jsxs)(V,{variant:`secondary`,onClick:Y,children:[(0,$.jsx)(T,{className:`size-4`}),t.manageService]})}):null,U.credentialMode===`api-key`?(0,$.jsxs)(`div`,{className:`mt-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(`label`,{htmlFor:`image-generation-api-key`,className:`text-xs font-medium text-fg-muted`,children:t.apiKey}),ie?(0,$.jsxs)(`a`,{href:ie,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs font-medium text-accent hover:underline`,children:[t.getApiKey,(0,$.jsx)(ut,{className:`size-3.5`,"aria-hidden":`true`})]}):null]}),(0,$.jsx)(v,{id:`image-generation-api-key`,value:c,onChange:e=>l(W(c)?e.replace(/^•+/,``):e),placeholder:U.configured?t.existingKey:t.needsKey,labels:{show:t.show,hide:t.hide,copy:t.copy,copied:t.copied},reveal:()=>Ne(U.id).then(e=>e.apiKey),loadFailedLabel:t.revealFailed,notInConfigFile:t.keyNotRevealable,className:`mt-1.5`,autoComplete:`new-password`},U.id),(0,$.jsx)(`span`,{className:`mt-1.5 block font-normal leading-relaxed text-fg-subtle`,children:U.configured?t.savedKey:t.apiKeyHint})]}):null,U.configFields.some(e=>!e.required)?(0,$.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-base/55 px-3 py-2.5`,children:[(0,$.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 text-sm font-medium text-fg-muted`,children:[(0,$.jsx)(Se,{className:`size-4`}),t.advanced]}),(0,$.jsx)(`div`,{className:`mt-3 grid gap-3 md:grid-cols-2`,children:U.configFields.filter(e=>!e.required).map(e=>(0,$.jsx)(Zt,{field:e,value:u[e.key]??``,onChange:t=>d(n=>({...n,[e.key]:t}))},e.key))})]}):null,y?(0,$.jsx)(`p`,{className:`mt-4 rounded-lg bg-emerald-500/10 px-3 py-2 text-sm text-emerald-700 dark:text-emerald-300`,role:`status`,children:t.enabled}):null,g?(0,$.jsx)(`p`,{className:`mt-4 rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-600 dark:text-red-400`,children:g}):null,(0,$.jsx)(`div`,{className:`mt-4 flex justify-end`,children:(0,$.jsxs)(V,{variant:`primary`,disabled:!K||f,onClick:()=>void se(),children:[f?(0,$.jsx)(b,{className:`size-4 animate-spin`}):(0,$.jsx)(m,{className:`size-4`}),(0,$.jsxs)(`span`,{className:`grid`,children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`invisible col-start-1 row-start-1`,children:t.enable}),(0,$.jsx)(`span`,{"aria-hidden":!0,className:`invisible col-start-1 row-start-1`,children:t.enabling}),(0,$.jsx)(`span`,{className:`col-start-1 row-start-1`,children:f?t.enabling:t.enable})]})]})})]}):null,(0,$.jsx)(Wt,{open:S,onOpenChange:C,provider:E,configured:!!(E&&O.find(e=>e.id===E.providerId)?.configured),language:e,onSaved:oe})]})}function nn({disabled:e=!1}){let t=M(e=>e.language),n=t===`zh`,[r,i]=(0,Q.useState)(!1),[a,o]=(0,Q.useState)(``),{data:s,mutate:c,error:l}=B(N(`/api/voice/catalog`),async e=>{let t=await k(e);return rt.parse(t.payload)}),u=n?{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(s){i(!0),o(``);try{let t=await k(N(e?`/api/voice/selection`:`/api/voice/catalog/refresh`),{method:e?`PUT`:`POST`,...e?{body:JSON.stringify({revision:s.revision,selection:e})}:{}});await c(rt.parse(t.payload),!1),await re()}catch(e){o(e instanceof Error?e.message:String(e)),await c()}finally{i(!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:n?`XOPC 托管语音模型`:`XOPC managed voice models`}),(0,$.jsx)(V,{variant:`secondary`,disabled:r||e||!s,onClick:()=>void p(),children:n?`刷新目录`:`Refresh catalog`})]}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:n?`各设备共用此 Gateway 的模型设置,修改在下次调用生效。仅显示支持对应场景的已发布模型。`:`Devices share this gateway’s selections. Changes apply to the next call. Only published models supporting each mode are shown.`}),a||l?(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-red-600`,children:a||String(l)}):null,s?Object.keys(u).map(i=>{let a=s.selections.find(e=>e.mode===i),o=s.models.filter(e=>e.voice.modes.includes(i)),c=o.find(e=>e.id===a?.model);return(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[(0,$.jsx)(`span`,{children:u[i]}),(0,$.jsxs)(d,{className:`w-full`,value:a?.model??``,disabled:r||e||!o.length,onChange:e=>void p({mode:i,model:e.target.value}),children:[(0,$.jsx)(f,{value:``,disabled:!0,children:n?`选择模型`:`Choose model`}),a&&!c?(0,$.jsxs)(f,{value:a.model,disabled:!0,children:[a.model,` · `,n?`不可用`:`Unavailable`]}):null,o.map(e=>(0,$.jsx)(f,{value:e.id,children:Fe(e,t)},e.id))]}),o.length?null:(0,$.jsx)(`span`,{className:`text-xs text-fg-muted`,children:n?`暂无可用模型`:`No available model`})]}),c&&c.voice.voices.length>0?(0,$.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[(0,$.jsx)(`span`,{children:n?`音色`:`Voice`}),(0,$.jsx)(d,{className:`w-full`,value:a?.voice??``,disabled:r||e,onChange:e=>void p({mode:i,model:c.id,voice:e.target.value}),children:c.voice.voices.map(e=>(0,$.jsxs)(f,{value:e.id,children:[Fe(e,t),e.gender?` · ${n?e.gender===`female`?`女声`:`男声`:e.gender}`:``,e.style?` · ${e.style}`:``]},e.id))}),c.voice.voices.find(e=>e.id===(a?.voice??c.voice.defaultVoice))?.description?(0,$.jsx)(`span`,{className:`block text-xs text-fg-muted`,children:c.voice.voices.find(e=>e.id===(a?.voice??c.voice.defaultVoice))?.description}):null]}):null]},i)}):(0,$.jsx)(G,{className:`h-48 w-full`})]})}function rn({v:e}){let t=ct(e=>e.microphoneId),n=ct(e=>e.setMicrophoneId),[r,i]=(0,Q.useState)([]),[a,o]=(0,Q.useState)(``),[s,c]=(0,Q.useState)(!1),l=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{l.current=!0;let e=()=>{navigator.mediaDevices?.enumerateDevices().then(e=>{l.current&&i(e.filter(e=>e.kind===`audioinput`))}).catch(()=>{})};return e(),navigator.mediaDevices?.addEventListener(`devicechange`,e),()=>{l.current=!1,navigator.mediaDevices?.removeEventListener(`devicechange`,e)}},[]);let u=async()=>{c(!0),o(``);try{(await navigator.mediaDevices.getUserMedia({audio:!0})).getTracks().forEach(e=>e.stop());let e=await navigator.mediaDevices.enumerateDevices();l.current&&i(e.filter(e=>e.kind===`audioinput`))}catch(e){l.current&&o(e instanceof Error?e.message:String(e))}finally{l.current&&c(!1)}};return(0,$.jsxs)(`section`,{className:`space-y-4 rounded-xl bg-surface-hover/20 p-4`,children:[(0,$.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[(0,$.jsx)(`span`,{children:e.experience.microphone}),(0,$.jsxs)(d,{value:t,onChange:e=>n(e.target.value),children:[(0,$.jsx)(f,{value:``,children:e.experience.systemDevice}),t&&!r.some(e=>e.deviceId===t)?(0,$.jsx)(f,{value:t,children:e.experience.unavailable}):null,r.filter(e=>e.deviceId&&e.deviceId!=="default").map((t,n)=>(0,$.jsx)(f,{value:t.deviceId,children:t.label||`${e.experience.microphone} ${n+1}`},t.deviceId))]})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.experience.deviceHint}),(0,$.jsx)(V,{variant:`secondary`,disabled:s,onClick:()=>void u(),children:e.experience.refreshDevices}),a?(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-red-600`,children:a}):null]})}function an({v:e,canListen:t,canSpeak:n,disabled:r,onVerified:i}){let a=e.setup,o=(0,Q.useContext)(Ue)?.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 Tt(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 We,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:ze()}),t.signal.aborted){l();return}if(s=await Ie.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 qe(o.sampleRate,s.session.inputFormat.sampleRate),g(`listening`)}catch(e){if(t.signal.aborted){l();return}v(e instanceof Error?e.message:a.testFailed)}}let y=s===`connecting`||s===`listening`||s===`playing`;return(0,$.jsxs)(`div`,{className:`space-y-3 rounded-xl bg-surface-base/45 p-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsxs)(V,{type:`button`,variant:`primary`,disabled:o||r||!t||y,onClick:()=>void v(!0),children:[y?(0,$.jsx)(b,{className:`size-4 animate-spin`}):(0,$.jsx)(x,{className:`size-4`}),n?a.test:a.testInput]}),(0,$.jsxs)(V,{type:`button`,variant:`secondary`,disabled:o||r||!n||y,onClick:()=>void v(!1),children:[(0,$.jsx)(C,{className:`size-4`}),e.tts.test.play]}),y?(0,$.jsxs)(V,{type:`button`,variant:`ghost`,onClick:()=>{_(),g(`idle`)},children:[(0,$.jsx)(we,{className:`size-4`}),e.tts.test.stop]}):null]}),(0,$.jsxs)(`div`,{role:`status`,"aria-live":`polite`,className:`space-y-2 text-xs text-fg-muted`,children:[s===`idle`?(0,$.jsx)(`p`,{children:o?e.experience.endCallBeforeTest:r?a.saveBeforeTest:a.microphoneHint}):null,s===`connecting`?(0,$.jsx)(`p`,{children:a.connecting}):null,s===`listening`?(0,$.jsx)(`p`,{children:a.speakNow}):null,l?(0,$.jsx)(`p`,{className:`rounded-lg bg-surface-base p-3 text-sm text-fg`,children:l}):null,s===`playing`?(0,$.jsx)(`p`,{children:a.playing}):null,s===`confirm`?(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,$.jsx)(`span`,{children:a.heardQuestion}),(0,$.jsx)(V,{type:`button`,variant:`secondary`,onClick:()=>{_(),i?.({input:h.current,output:!0}),g(`passed`)},children:a.heard}),(0,$.jsx)(V,{type:`button`,variant:`ghost`,onClick:()=>{_(),g(`error`),f(a.notHeard)},children:a.notHeardButton})]}):null,s===`passed`?(0,$.jsx)(`p`,{children:h.current?n?a.passed:a.inputPassed:a.outputPassed}):null,s===`error`?(0,$.jsx)(`p`,{role:`alert`,className:`text-red-600 dark:text-red-400`,children:d}):null]})]})}function on(e,t){return{...e,stt:{...e.stt,enabled:!0,provider:t},voice:{...e.voice,realtime:{...e.voice.realtime,enabled:!0,tts:e.voice.realtime.tts?.provider===t?e.voice.realtime.tts:{provider:t,...t===`alibaba`?{voice:`Cherry`}:{}},omni:e.voice.realtime.omni?.provider===t?e.voice.realtime.omni:t===`xopc-cloud`?void 0:{provider:t,model:`qwen3-omni-flash-realtime`,voice:e.voice.realtime.omni?.voice??`Cherry`,instructions:e.voice.realtime.omni?.instructions??`Keep replies conversational and concise.`}}}}}function sn(e){let t=(0,zt.c)(118),{section:n,v:r,form:i,pending:a,apiKeyLabels:o,sttProviders:s,onChange:c}=e,u=M(fn),p=r.setup,[m,h]=(0,Q.useState)(!1),g;t[0]===i?g=t[1]:(g=JSON.stringify(i),t[0]=i,t[1]=g);let _=g,v;t[2]===_?v=t[3]:(v={signature:_,input:!1,output:!1},t[2]=_,t[3]=v);let[y,b]=(0,Q.useState)(v);y.signature!==_&&b({signature:_,input:!1,output:!1});let x;t[4]!==a||t[5]!==_?(x=a?null:[`voice-realtime-status`,_],t[4]=a,t[5]=_,t[6]=x):x=t[6];let S;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(S={revalidateOnFocus:!0},t[7]=S):S=t[7];let{data:C,error:w,isLoading:T}=B(x,At,S),E;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(E=N(`/api/voice/catalog`),t[8]=E):E=t[8];let{data:D}=B(E,dn),O=i.voice.realtime,k=i.stt.provider,A=O.tts,j=A?.provider??C?.tts?.provider,P=C?.tts?.model,F;t[9]!==P||t[10]!==j?(F=j&&P?[`realtime-voices`,j,P]:null,t[9]=P,t[10]=j,t[11]=F):F=t[11];let I;t[12]!==P||t[13]!==j?(I=()=>Et(j,P,`realtime`),t[12]=P,t[13]=j,t[14]=I):I=t[14];let L;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(L={revalidateOnFocus:!1},t[15]=L):L=t[15];let{data:R}=B(F,I,L),ee;t[16]===R?ee=t[17]:(ee=R===void 0?[]:R,t[16]=R,t[17]=ee);let z=ee,te=z,ne;t[18]===z?ne=t[19]:(ne=z.filter(un),t[18]=z,t[19]=ne);let re=ne,H=typeof i.stt.providers?.alibaba?.apiKey==`string`?i.stt.providers.alibaba.apiKey:``,U;t[20]!==H||t[21]!==s?(U=!!H||s.some(ln),t[20]=H,t[21]=s,t[22]=U):U=t[22];let ae=U,W=O.defaultEngine===`omni`,K=W?O.omni?.voice??``:A?.voice??C?.tts?.voice??``,q;t[23]!==D?.models||t[24]!==W||t[25]!==re||t[26]!==O.omni?.model||t[27]!==O.omni?.provider||t[28]!==te?(q=W?O.omni?.provider===`xopc-cloud`?D?.models.find(e=>e.id===O.omni?.model)?.voice.voices??[]:re.length?re:[`Cherry`,`Ethan`,`Serena`,`Chelsie`].map(cn):te,t[23]=D?.models,t[24]=W,t[25]=re,t[26]=O.omni?.model,t[27]=O.omni?.provider,t[28]=te,t[29]=q):q=t[29];let J=q,Y=!!(C?.enabled&&C.stt),oe=!!(C?.enabled&&C.tts),se;t[30]!==i||t[31]!==c||t[32]!==O?(se=e=>c({...i,voice:{...i.voice,realtime:{...O,...e}}}),t[30]=i,t[31]=c,t[32]=O,t[33]=se):se=t[33];let X=se,ce;t[34]!==i||t[35]!==c?(ce=e=>c(on(i,e)),t[34]=i,t[35]=c,t[36]=ce):ce=t[36];let Z=ce,le;t[37]!==a||t[38]!==O.enabled||t[39]!==p.disabled||t[40]!==p.needsSetup||t[41]!==p.pending||t[42]!==p.unverified||t[43]!==p.verified||t[44]!==_||t[45]!==y.signature?(le=(e,t)=>O.enabled?a?p.pending:e?t&&y.signature===_?p.verified:p.unverified:p.needsSetup:p.disabled,t[37]=a,t[38]=O.enabled,t[39]=p.disabled,t[40]=p.needsSetup,t[41]=p.pending,t[42]=p.unverified,t[43]=p.verified,t[44]=_,t[45]=y.signature,t[46]=le):le=t[46];let ue=le,de;t[47]!==o||t[48]!==Z||t[49]!==m||t[50]!==w||t[51]!==i||t[52]!==H||t[53]!==ae||t[54]!==c||t[55]!==a||t[56]!==k||t[57]!==O.defaultEngine||t[58]!==O.enabled||t[59]!==p.changeKey||t[60]!==p.configureConversation||t[61]!==p.customProvider||t[62]!==p.edgeHint||t[63]!==p.enable||t[64]!==p.finishSetup||t[65]!==p.hosted||t[66]!==p.hostedAccountHint||t[67]!==p.hostedHint||t[68]!==p.keyConfigured||t[69]!==p.keyHint||t[70]!==p.manageAccount||t[71]!==p.outputHint||t[72]!==p.ownKey||t[73]!==p.ownKeyHint||t[74]!==p.service||t[75]!==p.statusError||t[76]!==n||t[77]!==A||t[78]!==C?.tts||t[79]!==X||t[80]!==r.experience||t[81]!==r.stt?(de=n===`service`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 rounded-xl bg-surface-base/45 p-3`,children:(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-fg-muted`,children:[(0,$.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":O.enabled,className:`size-4 accent-accent`,checked:O.enabled,onChange:e=>{e.target.checked?Z(k===`alibaba`?`alibaba`:`xopc-cloud`):X({enabled:!1})}}),p.enable]})}),w?(0,$.jsx)(`p`,{role:`alert`,className:`text-xs text-red-600 dark:text-red-400`,children:p.statusError}):null,(0,$.jsxs)(`fieldset`,{className:`space-y-3`,children:[(0,$.jsx)(`legend`,{className:`text-sm font-medium text-fg`,children:p.service}),(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[`xopc-cloud`,`alibaba`].map(e=>(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-3 rounded-lg bg-surface-base/55 px-3 py-3 text-sm text-fg has-checked:bg-accent-soft`,children:[(0,$.jsx)(`input`,{type:`radio`,name:`realtime-service`,value:e,checked:k===e,onChange:()=>Z(e),className:`mt-1 accent-accent`}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`span`,{className:`block font-medium`,children:e===`xopc-cloud`?p.hosted:p.ownKey}),(0,$.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:e===`xopc-cloud`?p.hostedHint:p.ownKeyHint})]})]},e))})]}),k!==`alibaba`&&k!==`xopc-cloud`?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:p.customProvider.replace(`{provider}`,k)}):null,k===`alibaba`?(0,$.jsx)(`div`,{className:`space-y-2 text-xs`,children:ae&&!m?(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`text-fg-muted`,children:p.keyConfigured}),(0,$.jsx)(V,{type:`button`,variant:`ghost`,onClick:()=>h(!0),children:p.changeKey})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`label`,{htmlFor:`realtime-api-key`,className:`font-medium text-fg`,children:r.stt.apiKey}),(0,$.jsx)(jt,{kind:`stt`,providerId:`alibaba`,fieldId:`realtime-api-key`,value:H,labels:{...o,maskedHelp:``},onChange:e=>c({...i,stt:{...i.stt,providers:{...i.stt.providers,alibaba:{...i.stt.providers?.alibaba,apiKey:e}}}})}),(0,$.jsx)(`p`,{className:`text-fg-muted`,children:p.keyHint})]})}):null,k===`xopc-cloud`?(0,$.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[p.hostedAccountHint,` `,(0,$.jsx)(l,{className:`text-accent hover:underline`,to:`/settings/capabilities/models`,children:p.manageAccount})]}):null,!A&&!a&&!C?.tts&&(k===`alibaba`||k===`xopc-cloud`)?(0,$.jsxs)(`div`,{className:`rounded-lg bg-surface-base p-3 text-xs`,children:[(0,$.jsx)(`p`,{className:`font-medium text-fg`,children:p.finishSetup}),(0,$.jsx)(`p`,{className:`mt-1 text-fg-muted`,children:i.tts.provider===`edge`?p.edgeHint:p.outputHint}),(0,$.jsx)(V,{className:`mt-2`,type:`button`,variant:`secondary`,onClick:()=>Z(k),children:p.configureConversation})]}):null,(0,$.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[(0,$.jsx)(`span`,{children:r.experience.defaultMode}),(0,$.jsxs)(d,{value:O.defaultEngine,className:ie,onChange:e=>X({defaultEngine:e.target.value}),children:[(0,$.jsx)(f,{value:`agent`,children:r.experience.assistant}),(0,$.jsx)(f,{value:`omni`,children:r.experience.natural})]})]}),(0,$.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[O.defaultEngine===`agent`?r.experience.assistantHint:r.experience.naturalHint,` `,r.experience.nextCall]})]}):null,t[47]=o,t[48]=Z,t[49]=m,t[50]=w,t[51]=i,t[52]=H,t[53]=ae,t[54]=c,t[55]=a,t[56]=k,t[57]=O.defaultEngine,t[58]=O.enabled,t[59]=p.changeKey,t[60]=p.configureConversation,t[61]=p.customProvider,t[62]=p.edgeHint,t[63]=p.enable,t[64]=p.finishSetup,t[65]=p.hosted,t[66]=p.hostedAccountHint,t[67]=p.hostedHint,t[68]=p.keyConfigured,t[69]=p.keyHint,t[70]=p.manageAccount,t[71]=p.outputHint,t[72]=p.ownKey,t[73]=p.ownKeyHint,t[74]=p.service,t[75]=p.statusError,t[76]=n,t[77]=A,t[78]=C?.tts,t[79]=X,t[80]=r.experience,t[81]=r.stt,t[82]=de):de=t[82];let fe;t[83]!==K||t[84]!==u||t[85]!==W||t[86]!==j||t[87]!==O.bargeIn||t[88]!==O.omni||t[89]!==O.tts||t[90]!==p.bargeIn||t[91]!==p.defaultVoice||t[92]!==p.voice||t[93]!==n||t[94]!==A||t[95]!==C?.tts||t[96]!==X||t[97]!==r.realtime||t[98]!==J?(fe=n===`listening`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,$.jsx)(`label`,{htmlFor:`realtime-voice`,className:`text-sm font-medium text-fg`,children:p.voice}),(0,$.jsxs)(d,{id:`realtime-voice`,className:`${ie} w-full sm:w-56`,value:K,disabled:W?!O.omni:!A&&!C?.tts,onChange:e=>{if(W&&O.omni){X({omni:{...O.omni,voice:e.target.value}});return}(j===`alibaba`||j===`xopc-cloud`)&&X({tts:{...O.tts,provider:j,...e.target.value?{voice:e.target.value}:{}},...O.omni&&[`Cherry`,`Ethan`,`Serena`,`Chelsie`].includes(e.target.value)?{omni:{...O.omni,voice:e.target.value}}:{}})},children:[W?null:(0,$.jsx)(f,{value:``,children:p.defaultVoice}),K&&!J.some(e=>e.id===K)?(0,$.jsx)(f,{value:K,children:K}):null,J.map(e=>(0,$.jsxs)(f,{value:e.id,children:[Fe(e,u),`gender`in e&&e.gender?` · ${e.gender===`female`?`女声`:`男声`}`:``,`style`in e&&e.style?` · ${e.style}`:``]},e.id))]}),(()=>{let e=J.find(e=>e.id===K);return e&&`description`in e&&typeof e.description==`string`?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.description}):null})()]}),(0,$.jsxs)(`label`,{className:`flex items-center justify-between gap-4 text-sm text-fg`,children:[(0,$.jsxs)(`span`,{children:[p.bargeIn,(0,$.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:r.realtime.bargeInDescription})]}),(0,$.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":O.bargeIn,checked:O.bargeIn,className:`size-4 accent-accent`,onChange:e=>X({bargeIn:e.target.checked})})]})]}):null,t[83]=K,t[84]=u,t[85]=W,t[86]=j,t[87]=O.bargeIn,t[88]=O.omni,t[89]=O.tts,t[90]=p.bargeIn,t[91]=p.defaultVoice,t[92]=p.voice,t[93]=n,t[94]=A,t[95]=C?.tts,t[96]=X,t[97]=r.realtime,t[98]=J,t[99]=fe):fe=t[99];let pe;t[100]!==Y||t[101]!==oe||t[102]!==w||t[103]!==T||t[104]!==a||t[105]!==n||t[106]!==_||t[107]!==C||t[108]!==ue||t[109]!==r||t[110]!==y.input||t[111]!==y.output?(pe=n===`diagnostics`?(0,$.jsxs)($.Fragment,{children:[T?(0,$.jsx)(G,{className:`h-16 w-full`}):(0,$.jsxs)(`div`,{className:`space-y-2 text-sm`,role:`status`,children:[(0,$.jsxs)(`p`,{children:[r.experience.dictationReady,` · `,ue(Y,y.input)]}),(0,$.jsxs)(`p`,{children:[r.experience.agentReady,` · `,ue(Y&&oe,y.input&&y.output)]}),(0,$.jsxs)(`p`,{children:[r.experience.omniReady,` · `,ue(!!(C?.enabled&&C.omni),!1)]})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:r.experience.configurationOnly}),(0,$.jsx)(an,{v:r,canListen:Y,canSpeak:oe,disabled:a||T||!!w,onVerified:e=>b({signature:_,...e})},`${_}:${JSON.stringify(C)}`)]}):null,t[100]=Y,t[101]=oe,t[102]=w,t[103]=T,t[104]=a,t[105]=n,t[106]=_,t[107]=C,t[108]=ue,t[109]=r,t[110]=y.input,t[111]=y.output,t[112]=pe):pe=t[112];let me;return t[113]!==p.service||t[114]!==de||t[115]!==fe||t[116]!==pe?(me=(0,$.jsxs)(`section`,{className:`space-y-5 rounded-xl bg-surface-hover/20 p-4 sm:p-5`,"aria-label":p.service,children:[de,fe,pe]}),t[113]=p.service,t[114]=de,t[115]=fe,t[116]=pe,t[117]=me):me=t[117],me}function cn(e){return{id:e,name:e}}function ln(e){return e.id===`alibaba`&&e.configured}function un(e){return[`Cherry`,`Ethan`,`Serena`,`Chelsie`].includes(e.id)}async function dn(e){return rt.parse((await k(e)).payload)}function fn(e){return e.language}function pn(e){let t=(0,zt.c)(22),{value:n,onChange:r}=e,i=M(hn)===`zh`,a;t[0]===i?a=t[1]:(a=(e,t)=>i?t:e,t[0]=i,t[1]=a);let o=a,s;t[2]!==r||t[3]!==n?(s=e=>{n&&r({...n,...e})},t[2]=r,t[3]=n,t[4]=s):s=t[4];let c=s,l;t[5]===o?l=t[6]:(l=o(`Natural conversation`,`自然对话`),t[5]=o,t[6]=l);let u;t[7]===l?u=t[8]:(u=(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:l}),t[7]=l,t[8]=u);let p;t[9]===o?p=t[10]:(p=o(`Calls continue the same session using recent history. Service and credentials are shared with voice setup; override them here only when needed.`,`通话会接续同一会话的近期历史。默认共用语音服务与凭据,仅在需要独立配置时修改。`),t[9]=o,t[10]=p);let m;t[11]===p?m=t[12]:(m=(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:p}),t[11]=p,t[12]=m);let h;t[13]!==o||t[14]!==r||t[15]!==c||t[16]!==n?(h=n?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`label`,{className:`block space-y-1 text-sm`,children:[(0,$.jsx)(`span`,{children:o(`Connection`,`连接方式`)}),(0,$.jsx)(d,{value:n.provider,onChange:e=>r({model:n.model,voice:n.voice,instructions:n.instructions,provider:e.target.value}),children:(0,$.jsxs)(f,{value:`alibaba`,children:[`DashScope · `,o(`Your API key`,`自有 API Key`)]})})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.provider===`xopc-cloud`?o(`Uses your XOPC sign-in and the platform’s published Omni route and credits.`,`使用 XOPC 登录授权、平台发布的 Omni 路由和额度。`):o(`Leave empty to use the shared voice service credential.`,`留空使用语音服务中已配置的凭据。`)}),(0,$.jsx)(`p`,{className:`font-mono text-xs text-fg-muted`,children:n.model}),n.provider===`alibaba`?(0,$.jsxs)(`label`,{className:`block space-y-1 text-sm`,children:[(0,$.jsx)(`span`,{children:`API Key`}),(0,$.jsx)(`input`,{className:`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,type:`password`,autoComplete:`new-password`,value:n.apiKey??``,onChange:e=>c({apiKey:e.target.value})})]}):null,(0,$.jsx)(je,{title:o(`Custom endpoint`,`自定义服务地址`),summary:n.baseUrl||o(`Use the default endpoint`,`使用默认服务地址`),children:(0,$.jsxs)(`label`,{className:`block space-y-1 text-sm`,children:[(0,$.jsx)(`span`,{children:o(`Endpoint override (optional)`,`自定义服务地址(可选)`)}),(0,$.jsx)(`input`,{className:`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,value:n.baseUrl??``,placeholder:n.provider===`alibaba`?`wss://dashscope.aliyuncs.com/api-ws/v1/realtime`:`https://router.xopc.ai/v1`,onChange:e=>c({baseUrl:e.target.value.trim()||void 0})})]})}),(0,$.jsxs)(`label`,{className:`block space-y-1 text-sm`,children:[(0,$.jsx)(`span`,{children:o(`Voice`,`音色`)}),(0,$.jsx)(d,{value:n.voice,onChange:e=>c({voice:e.target.value}),children:[`Cherry`,`Ethan`,`Serena`,`Chelsie`].map(mn)})]}),(0,$.jsx)(je,{title:o(`Conversation instructions`,`聊天指令`),summary:o(`Current instructions remain active`,`当前聊天指令继续生效`),children:(0,$.jsxs)(`label`,{className:`block space-y-1 text-sm`,children:[(0,$.jsx)(`span`,{children:o(`Conversation instructions`,`聊天指令`)}),(0,$.jsx)(`textarea`,{className:`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,rows:3,maxLength:8e3,value:n.instructions,onChange:e=>c({instructions:e.target.value})})]})})]}):(0,$.jsx)(V,{variant:`secondary`,onClick:()=>r({provider:`alibaba`,model:`qwen3-omni-flash-realtime`,voice:`Cherry`,instructions:`You are a friendly voice companion. You cannot execute tools.`}),children:o(`Configure natural conversation`,`配置自然聊天`)}),t[13]=o,t[14]=r,t[15]=c,t[16]=n,t[17]=h):h=t[17];let g;return t[18]!==u||t[19]!==m||t[20]!==h?(g=(0,$.jsxs)(`details`,{className:`space-y-3 rounded-xl bg-surface-hover/20 p-4`,children:[u,m,h]}),t[18]=u,t[19]=m,t[20]=h,t[21]=g):g=t[21],g}function mn(e){return(0,$.jsx)(f,{value:e,children:e},e)}function hn(e){return e.language}var gn=U;function _n(){return O(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,ae,`dark:border-edge`)}function vn(){return O(ie,U)}function yn(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 xn(e,t){switch(e){case`openai`:return t.stt.openai;case`alibaba`:return t.stt.alibaba;case`groq`:return`Groq`;default:return e}}function Sn(e,t){switch(e){case`openai`:return t.tts.providerOpenai;case`alibaba`:return t.stt.alibaba;case`edge`:return t.tts.providerEdge;case`minimax`:return`MiniMax`;default:return e}}function Cn(e,t){switch(e){case`off`:return t.tts.triggerOff;case`always`:return t.tts.triggerAlways;case`inbound`:return t.tts.triggerInbound;case`tagged`:return t.tts.triggerTagged}}function wn(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 Tn(e){return{maskedHelp:e.apiKeyMaskedHelp,copy:e.apiKeyCopy,copied:e.apiKeyCopied,show:e.apiKeyShow,hide:e.apiKeyHide,notInConfigFile:e.apiKeyNotInConfigFile,loadFailed:e.apiKeyRevealFailed}}function En(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 Dn(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 On(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 kn(){let e=M(e=>e.language),t=D(e).voiceSettings,[n,r]=(0,Q.useState)(`listening`),i=de(),a=ct(e=>e.captions),o=ct(e=>e.setCaptions),s=!!A(e=>e.conversationId);(0,Q.useEffect)(()=>{!i&&n===`diagnostics`&&r(`listening`)},[n,i]);let[c,l]=(0,Q.useReducer)(On,{form:null,baseline:null}),u=c.form,p=c.baseline,[m,h]=(0,Q.useState)(null),g=(0,Q.useRef)(!1),_=(0,Q.useRef)(u);_.current=u;let v=(0,Q.useRef)({parsed:null,models:void 0}),{data:y,error:b,isLoading:x,mutate:S}=H(s),{data:C,error:w,isLoading:T,mutate:E}=B(s?N(`/api/voice/models`):null,Ot,{revalidateOnFocus:!1}),{data:O,error:k,isLoading:j}=B(s?N(`/api/voice/providers`):null,wt,{revalidateOnFocus:!1}),{data:P,error:F,isLoading:I}=B(s?N(`/api/voice/stt-providers`):null,Dt,{revalidateOnFocus:!1}),L=(0,Q.useMemo)(()=>O?.providers??[],[O]),R=(0,Q.useMemo)(()=>P?.providers??[],[P]),ee=(0,Q.useMemo)(()=>y?.payload?.config===void 0?null:kt(y.payload.config),[y]),z=(0,Q.useMemo)(()=>!u||!p?!1:JSON.stringify(u)!==JSON.stringify(p),[u,p]);s?ee!==null&&C!==void 0&&!g.current&&(v.current.parsed!==ee||v.current.models!==C)&&(v.current={parsed:ee,models:C},l({type:`sync`,value:ee}),h(C)):(v.current.parsed!==null||v.current.models!==void 0)&&(v.current={parsed:null,models:void 0},l({type:`reset`}),h(null),g.current=!1);let te=!!(s&&(ee===null||C===void 0||O===void 0||P===void 0)&&(x||T||j||I)),ne=b instanceof Error?b.message:b?String(b):w instanceof Error?w.message:w?String(w):k instanceof Error?k.message:k?String(k):F instanceof Error?F.message:F?String(F):null,re=(0,Q.useCallback)(e=>{g.current=!0,l({type:`update`,updater:t=>t?{...t,stt:{...t.stt,...e}}:null})},[]),U=(0,Q.useCallback)(e=>{g.current=!0,l({type:`update`,updater:t=>{if(!t)return null;let n=t.stt.fallback??{enabled:!1,order:[]};return{...t,stt:{...t.stt,fallback:{...n,...e}}}}})},[]),ie=(0,Q.useCallback)(e=>{g.current=!0,l({type:`update`,updater:t=>t?{...t,voice:{...t.voice,input:{...t.voice.input,refinement:{...t.voice.input.refinement,...e}}}}:null})},[]),ae=(0,Q.useCallback)(t=>{g.current=!0,l({type:`update`,updater:n=>n?{...n,voice:{...n.voice,languageMode:t,...t===`auto`?{language:e}:{}}}:null})},[e]),W=(0,Q.useCallback)(e=>{g.current=!0,l({type:`update`,updater:t=>t?{...t,voice:{...t.voice,realtime:{...t.voice.realtime,...e}}}:null})},[]),G=(0,Q.useCallback)(e=>{g.current=!0,l({type:`update`,updater:t=>t?{...t,tts:{...t.tts,...e}}:null})},[]),K=xt({value:u,dirty:z,onSave:(0,Q.useCallback)(async e=>{try{await St(e),l({type:`saved`,value:e}),g.current=!!(_.current&&JSON.stringify(_.current)!==JSON.stringify(e))}catch(e){throw Error(e instanceof Error?e.message:t.saveError)}},[t.saveError])}),q=(0,Q.useCallback)(e=>{g.current=!0,l({type:`update`,updater:()=>e})},[]);if(!s)return(0,$.jsx)(`div`,{className:`flex flex-col gap-3`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.needToken})});if(te)return(0,$.jsx)(yt,{rows:4});if(!u||m===null)return(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:ne??t.loadError}),(0,$.jsx)(V,{type:`button`,variant:`secondary`,onClick:()=>{S(),E()},children:t.retry})]});let J=u.stt,Y=u.tts,oe=u.voice.input.refinement,se=Tn(t);return(0,$.jsxs)(`div`,{className:`flex w-full flex-col gap-4`,onBlurCapture:K.onBlurCapture,children:[(0,$.jsx)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:(0,$.jsx)(bt,{status:K.status,error:K.error})}),K.error?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:K.error}):null,(0,$.jsx)(`nav`,{"aria-label":t.setup.advanced,className:`flex flex-wrap gap-2`,children:[`listening`,`input`,`devices`,`service`,...i?[`diagnostics`]:[]].map(e=>(0,$.jsx)(V,{variant:n===e?`secondary`:`ghost`,"aria-pressed":n===e,onClick:()=>r(e),children:t.experience[e]},e))}),n===`listening`||n===`service`||n===`diagnostics`?(0,$.jsx)(sn,{section:n,v:t,form:u,pending:z||K.status===`saving`||!!K.error,apiKeyLabels:se,sttProviders:R,onChange:q}):null,n===`listening`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(An,{v:t,voice:u.voice,updateLanguageMode:ae}),(0,$.jsx)(`section`,{className:`rounded-xl bg-surface-hover/20 px-4 py-5 sm:px-5`,children:(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-[minmax(0,1fr)_minmax(12rem,18rem)] sm:items-center`,children:[(0,$.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:t.experience.pace}),(0,$.jsxs)(d,{className:vn(),value:String(u.voice.realtime.silenceDurationMs),onChange:e=>W({silenceDurationMs:Number(e.target.value)}),children:[(0,$.jsx)(f,{value:`800`,children:t.experience.fast}),(0,$.jsx)(f,{value:`1200`,children:t.experience.standard}),(0,$.jsx)(f,{value:`2000`,children:t.experience.relaxed}),[800,1200,2e3].includes(u.voice.realtime.silenceDurationMs)?null:(0,$.jsxs)(f,{value:String(u.voice.realtime.silenceDurationMs),children:[u.voice.realtime.silenceDurationMs,` ms`]})]})]})})]}):null,n===`input`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`label`,{className:`flex items-center justify-between text-sm`,children:[t.experience.captions,(0,$.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":a,className:`ui-checkbox`,checked:a,onChange:e=>o(e.target.checked)})]}),(0,$.jsxs)(`label`,{className:`space-y-2 text-sm`,children:[(0,$.jsx)(`span`,{children:t.stt.refinement}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.stt.refinementDesc}),(0,$.jsxs)(d,{className:vn(),value:oe.mode,onChange:e=>ie({mode:e.target.value}),children:[(0,$.jsx)(f,{value:`off`,children:t.stt.refinementOff}),(0,$.jsx)(f,{value:`punctuation`,children:t.stt.refinementPunctuation}),(0,$.jsx)(f,{value:`light`,children:t.stt.refinementLight}),oe.mode===`custom`?(0,$.jsx)(f,{value:`custom`,children:t.setup.advanced}):null]})]}),(0,$.jsxs)(`details`,{className:`rounded-xl bg-surface-base/55 px-4 py-3`,children:[(0,$.jsxs)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:[t.setup.readout,` · `,Y.enabled?Cn(Y.trigger,t):t.overview.off]}),(0,$.jsx)(`p`,{className:`mt-3 text-xs text-fg-muted`,children:t.setup.readoutHint}),(0,$.jsx)(Nn,{v:t,apiKeyLabels:se,tts:Y,models:m,ttsProviders:L,updateTts:G})]})]}):null,n===`devices`?(0,$.jsx)(rn,{v:t}):null,n===`service`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(nn,{disabled:z||K.status===`saving`}),u.voice.realtime.enabled&&u.voice.realtime.omni?.provider===`alibaba`?(0,$.jsx)(pn,{value:u.voice.realtime.omni,onChange:e=>W({omni:e})}):null,(0,$.jsxs)(`details`,{className:`rounded-xl bg-surface-base/55 px-4 py-3`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:t.experience.technical}),(0,$.jsx)(jn,{v:t,apiKeyLabels:se,stt:J,models:m,sttProviders:R,updateStt:re,updateSttFallback:U}),(0,$.jsx)(je,{title:t.experience.technical,summary:t.notes.envVars,children:(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.notes.envVars})})]})]}):null]})}function An(e){let t=(0,zt.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=vn(),t[7]=l):l=t[7];let u;t[8]===i?u=t[9]:(u=e=>i(e.target.value),t[8]=i,t[9]=u);let p;t[10]===n.language.auto?p=t[11]:(p=(0,$.jsx)(f,{value:`auto`,children:n.language.auto}),t[10]=n.language.auto,t[11]=p);let m;t[12]===n.language.manual?m=t[13]:(m=(0,$.jsx)(f,{value:`manual`,children:n.language.manual}),t[12]=n.language.manual,t[13]=m);let h;t[14]!==u||t[15]!==p||t[16]!==m||t[17]!==r.languageMode?(h=(0,$.jsxs)(d,{className:l,value:r.languageMode,onChange:u,children:[p,m]}),t[14]=u,t[15]=p,t[16]=m,t[17]=r.languageMode,t[18]=h):h=t[18];let g;return t[19]!==c||t[20]!==h?(g=(0,$.jsx)(`section`,{className:`rounded-xl bg-surface-hover/20 px-4 py-5 sm:px-5`,children:(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-[minmax(0,1fr)_minmax(12rem,18rem)] sm:items-center`,children:[c,h]})}),t[19]=c,t[20]=h,t[21]=g):g=t[21],g}function jn(e){let t=(0,zt.c)(58),{v:n,apiKeyLabels:r,stt:i,models:a,sttProviders:o,updateStt:s,updateSttFallback:c}=e,l;if(t[0]!==o){let e=new Set;l=[];for(let t of o)e.has(t.id)||(e.add(t.id),l.push(t));t[0]=o,t[1]=l}else l=t[1];let u=l,p,m,h,g;if(t[2]!==a||t[3]!==u||t[4]!==i.provider||t[5]!==i.providers){p=u.find(e=>e.id===i.provider);let e;t[10]!==i.provider||t[11]!==i.providers?(e=i.providers?.[i.provider]??{},t[10]=i.provider,t[11]=i.providers,t[12]=e):e=t[12],h=e,m=a?.stt?.[i.provider]?.length?a.stt[i.provider]:p?.models??[],g=p?.fields.find(Mn),t[2]=a,t[3]=u,t[4]=i.provider,t[5]=i.providers,t[6]=p,t[7]=m,t[8]=h,t[9]=g}else p=t[6],m=t[7],h=t[8],g=t[9];let _=g,v=typeof h.model==`string`?h.model:void 0,y=v??(typeof _?.defaultValue==`string`?_.defaultValue:m[0]?.id),b;t[13]!==i.provider||t[14]!==i.providers||t[15]!==s?(b=e=>{s({providers:{...i.providers??{},[i.provider]:{...i.providers?.[i.provider]??{},...e}}})},t[13]=i.provider,t[14]=i.providers,t[15]=s,t[16]=b):b=t[16];let S=b,C,w;t[17]!==v||t[18]!==y||t[19]!==_||t[20]!==S?(C=()=>{_&&y&&v!==y&&S({model:y})},w=[v,y,_,S],t[17]=v,t[18]=y,t[19]=_,t[20]=S,t[21]=C,t[22]=w):(C=t[21],w=t[22]),(0,Q.useEffect)(C,w);let T;t[23]===Symbol.for(`react.memo_cache_sentinel`)?(T=(0,$.jsx)(x,{className:`size-4 text-accent`,strokeWidth:1.75}),t[23]=T):T=t[23];let E;t[24]===n.stt.title?E=t[25]:(E=(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[T,n.stt.title]}),t[24]=n.stt.title,t[25]=E);let D;t[26]===n.stt.description?D=t[27]:(D=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.stt.description}),t[26]=n.stt.description,t[27]=D);let k;t[28]!==E||t[29]!==D?(k=(0,$.jsxs)(`div`,{className:`mb-4`,children:[E,D]}),t[28]=E,t[29]=D,t[30]=k):k=t[30];let A;t[31]===s?A=t[32]:(A=e=>s({enabled:e}),t[31]=s,t[32]=A);let j;t[33]!==i.enabled||t[34]!==A||t[35]!==n.stt.enable||t[36]!==n.stt.enableDesc?(j=(0,$.jsx)(Ln,{checked:i.enabled,title:n.stt.enable,description:n.stt.enableDesc,onChange:A}),t[33]=i.enabled,t[34]=A,t[35]=n.stt.enable,t[36]=n.stt.enableDesc,t[37]=j):j=t[37];let M;t[38]!==p?.fields||t[39]!==r||t[40]!==y||t[41]!==m||t[42]!==u||t[43]!==h||t[44]!==i.enabled||t[45]!==i.fallback?.enabled||t[46]!==i.provider||t[47]!==S||t[48]!==s||t[49]!==c||t[50]!==n?(M=i.enabled?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{className:O(`flex flex-col gap-1.5`,gn),children:[(0,$.jsx)(Bn,{children:n.stt.provider}),(0,$.jsx)(d,{className:vn(),value:i.provider,onChange:e=>s({provider:e.target.value}),children:u.map(e=>(0,$.jsxs)(f,{value:e.id,children:[xn(e.id,n),e.configured?``:` *`]},e.id))})]}),(0,$.jsx)(Pn,{kind:`stt`,providerId:i.provider,fields:p?.fields??[],providerSlice:h,models:m,currentModel:y,apiKeyLabels:r,onPatch:S})]}),(0,$.jsx)(je,{title:n.stt.fallback,summary:n.stt.fallbackDesc,children:(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.stt.fallback}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.stt.fallbackDesc})]}),(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:i.fallback?.enabled??!1,onChange:e=>c({enabled:e.target.checked})})]})})]}):null,t[38]=p?.fields,t[39]=r,t[40]=y,t[41]=m,t[42]=u,t[43]=h,t[44]=i.enabled,t[45]=i.fallback?.enabled,t[46]=i.provider,t[47]=S,t[48]=s,t[49]=c,t[50]=n,t[51]=M):M=t[51];let N;t[52]!==j||t[53]!==M?(N=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[j,M]}),t[52]=j,t[53]=M,t[54]=N):N=t[54];let P;return t[55]!==N||t[56]!==k?(P=(0,$.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 px-4 py-5 sm:px-5`,children:[k,N]}),t[55]=N,t[56]=k,t[57]=P):P=t[57],P}function Mn(e){return e.key===`model`}function Nn({v:e,apiKeyLabels:t,tts:n,models:r,ttsProviders:i,updateTts:a}){let[o,s]=(0,Q.useState)(e.tts.test.sampleText),[c,l]=(0,Q.useState)({status:`idle`}),u=(0,Q.useRef)(null),p=(0,Q.useRef)(null),m=(0,Q.useRef)(null),h=(0,Q.useCallback)(()=>{m.current?.abort(),m.current=null,u.current?.pause(),u.current=null,p.current&&=(URL.revokeObjectURL(p.current),null)},[]),g=(0,Q.useMemo)(()=>{let e=new Set,t=[];for(let n of i)e.has(n.id)||(e.add(n.id),t.push(n));return t},[i]),_=g.find(e=>e.id===n.provider),v=n.providers?.[n.provider]??{},y=r?.tts?.[n.provider]?.length?r.tts[n.provider]:_?.models??[],x=_?.fields.find(e=>e.key===`model`),S=_?.fields.find(e=>e.key===`voice`),w=typeof v.model==`string`?v.model:void 0,T=w??(typeof x?.defaultValue==`string`?x.defaultValue:y[0]?.id),E=y.find(e=>e.id===T),D=r?.ttsVoices?.[n.provider]?.length?r.ttsVoices[n.provider]:_?.voices??[],{data:k=[]}=B(T?`voice:tts:${n.provider}:${T}`:null,()=>Et(n.provider,T??``),{revalidateOnFocus:!1}),A=k.length>0?k:D,j=typeof v.voice==`string`?v.voice:void 0,M=j??A.find(e=>e.id===E?.tts?.defaultVoice)?.id??(typeof S?.defaultValue==`string`?S.defaultValue:A[0]?.id),N=(_?.fields??[]).filter(e=>(e.key!==`speed`||E?.tts?.speed!==!1)&&(e.key!==`instructions`||E?.tts?.instructions!==!1)),P=!!_?.diagnostics.requiresApiKey,F=!!_?.configured||!P,I=(0,Q.useCallback)(e=>{a({providers:{...n.providers??{},[n.provider]:{...n.providers?.[n.provider]??{},...e}}})},[n.provider,n.providers,a]);(0,Q.useEffect)(()=>{let e={};x&&T&&w!==T&&(e.model=T),S&&M&&j!==M&&(e.voice=M),Object.keys(e).length>0&&I(e)},[w,j,T,M,x,I,S]),(0,Q.useEffect)(()=>()=>h(),[h]);let L=(0,Q.useCallback)(e=>{a({provider:e}),l({status:`idle`})},[a]),R=(0,Q.useCallback)(async()=>{let t=o.trim();if(!t){l({status:`error`,message:e.tts.test.emptyText});return}h();let r=new AbortController;m.current=r,l({status:`loading`});try{let i=await Ct({text:t,provider:n.provider,providerConfig:v,...T?{model:T}:{},...M?{voice:M}:{}},r.signal);if(r.signal.aborted)return;let a=bn(i.audio,i.mimeType);p.current=a;let o=new Audio(a);u.current=o;let s=[i.provider,i.format,i.latencyMs===void 0?void 0:`${i.latencyMs}ms`,yn(i.audioSize)].filter(Boolean).join(` · `);o.addEventListener(`ended`,()=>l({status:`done`,summary:s}),{once:!0}),o.addEventListener(`error`,()=>l({status:`error`,message:e.tts.test.playFailed}),{once:!0}),await o.play(),l({status:`playing`,summary:s})}catch(e){if(r.signal.aborted)return;h(),l({status:`error`,message:e instanceof Error?e.message:String(e)})}},[T,M,v,h,o,n.provider,e.tts.test.emptyText,e.tts.test.playFailed]);return(0,$.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 px-4 py-5 sm:px-5`,children:[(0,$.jsxs)(`div`,{className:`mb-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,$.jsx)(He,{className:`size-4 text-accent`,strokeWidth:1.75}),e.tts.title]}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.tts.description})]}),(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsx)(Ln,{checked:n.enabled,title:e.tts.enable,description:e.tts.enableDesc,onChange:e=>a({enabled:e})}),n.enabled?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`div`,{className:O(`flex flex-col gap-1.5`,gn),children:[(0,$.jsx)(Bn,{children:e.tts.trigger}),(0,$.jsxs)(d,{className:vn(),value:n.trigger,onChange:e=>a({trigger:e.target.value}),children:[(0,$.jsx)(f,{value:`off`,children:e.tts.triggerOff}),(0,$.jsx)(f,{value:`inbound`,children:e.tts.triggerInbound}),(0,$.jsx)(f,{value:`tagged`,children:e.tts.triggerTagged}),(0,$.jsx)(f,{value:`always`,children:e.tts.triggerAlways})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.tts.triggerHelp})]}),(0,$.jsxs)(`div`,{className:O(`flex flex-col gap-1.5`,gn),children:[(0,$.jsx)(Bn,{children:e.tts.provider}),(0,$.jsx)(d,{className:vn(),value:n.provider,onChange:e=>L(e.target.value),children:g.map(t=>(0,$.jsx)(f,{value:t.id,children:Sn(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??wn(n.provider,e)]})]})]}),(0,$.jsxs)(`details`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,open:!F,children:[(0,$.jsxs)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg marker:text-fg-muted`,children:[e.experience.service,(0,$.jsx)(`span`,{className:`ml-2 text-xs font-normal text-fg-muted`,children:e.tts.advanced.description})]}),(0,$.jsx)(`div`,{className:`mt-3`,children:(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:(0,$.jsx)(Pn,{kind:`tts`,providerId:n.provider,fields:N,providerSlice:v,models:y,voices:A,currentModel:T,currentVoice:M,apiKeyLabels:t,onPatch:I,resetVoiceOnModelChange:!0})})})]}),(0,$.jsxs)(`div`,{className:`rounded-xl bg-surface-panel/80 p-3 shadow-surface`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:e.tts.test.title}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.tts.test.description})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,$.jsxs)(V,{type:`button`,variant:`primary`,onClick:()=>void R(),disabled:c.status===`loading`,className:`h-9`,children:[c.status===`loading`?(0,$.jsx)(b,{className:`size-4 animate-spin`}):(0,$.jsx)(C,{className:`size-4`}),c.status===`loading`?e.tts.test.generating:e.tts.test.play]}),(0,$.jsxs)(V,{type:`button`,variant:`secondary`,onClick:()=>{h(),l(e=>e.status===`playing`?{status:`done`,summary:e.summary}:{status:`idle`})},disabled:c.status!==`playing`,className:`h-9`,children:[(0,$.jsx)(we,{className:`size-4`}),e.tts.test.stop]})]})]}),(0,$.jsxs)(`details`,{className:`mt-3`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-xs text-fg-muted`,children:e.setup.sampleText}),(0,$.jsx)(`textarea`,{className:O(_n(),`mt-3 min-h-20 resize-y`),value:o,onChange:e=>s(e.target.value),maxLength:1e3})]}),(0,$.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center justify-between gap-2 text-xs`,children:[(0,$.jsxs)(`span`,{className:`text-fg-subtle`,children:[o.length,`/1000`]}),c.status===`playing`||c.status===`done`?(0,$.jsxs)(`span`,{className:`text-emerald-700 dark:text-emerald-200`,children:[c.status===`playing`?e.tts.test.playing:e.tts.test.ready,` · `,c.summary]}):null,c.status===`error`?(0,$.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:c.message}):null]})]})]}):null]})]})}function Pn(e){let t=(0,zt.c)(30),{kind:n,providerId:r,fields:i,providerSlice:a,models:o,voices:s,currentModel:c,currentVoice:l,apiKeyLabels:u,onPatch:p,resetVoiceOnModelChange:m}=e,h;t[0]===s?h=t[1]:(h=s===void 0?[]:s,t[0]=s,t[1]=h);let g=h,_=m===void 0?!1:m,v=M(In),y=de(),b;if(t[2]!==u||t[3]!==c||t[4]!==l||t[5]!==i||t[6]!==n||t[7]!==v||t[8]!==o||t[9]!==p||t[10]!==r||t[11]!==a||t[12]!==_||t[13]!==y||t[14]!==g){let e;t[16]===y?e=t[17]:(e=e=>y||e.required||![`timeoutMs`,`maxTextLength`].includes(e.key),t[16]=y,t[17]=e);let s;t[18]!==u||t[19]!==c||t[20]!==l||t[21]!==n||t[22]!==v||t[23]!==o||t[24]!==p||t[25]!==r||t[26]!==a||t[27]!==_||t[28]!==g?(s=e=>e.key===`apiKey`?(0,$.jsxs)(`div`,{className:O(`flex flex-col gap-1.5`,gn),children:[(0,$.jsx)(Bn,{children:e.label}),(0,$.jsx)(jt,{kind:n,providerId:r,fieldId:`voice-${n}-${r}-api-key`,value:typeof a.apiKey==`string`?a.apiKey:``,onChange:e=>p({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:O(`flex flex-col gap-1.5`,gn),children:[(0,$.jsx)(Bn,{children:e.label}),(0,$.jsx)(d,{className:vn(),value:c??``,onChange:e=>p({model:e.target.value,..._?{voice:void 0}:{}}),children:o.map(Fn)})]},e.key):e.key===`voice`&&g.length>0?(0,$.jsxs)(`div`,{className:O(`flex flex-col gap-1.5`,gn),children:[(0,$.jsx)(Bn,{children:e.label}),(0,$.jsxs)(d,{className:vn(),value:l??``,onChange:e=>p({voice:e.target.value}),children:[l&&!g.some(e=>e.id===l)?(0,$.jsxs)(f,{value:l,children:[l,` · unavailable`]}):null,g.map(e=>(0,$.jsxs)(f,{value:e.id,children:[Fe(e,v),e.gender?` · ${e.gender===`female`?`女声`:`男声`}`:``,e.style?` · ${e.style}`:``]},e.id))]}),g.find(e=>e.id===l)?.description?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:g.find(e=>e.id===l)?.description}):null]},e.key):(0,$.jsx)(Rn,{field:e,value:En(a,e),onChange:t=>p({[e.key]:t}),className:e.type===`textarea`?`sm:col-span-2`:gn},e.key),t[18]=u,t[19]=c,t[20]=l,t[21]=n,t[22]=v,t[23]=o,t[24]=p,t[25]=r,t[26]=a,t[27]=_,t[28]=g,t[29]=s):s=t[29],b=i.filter(e).map(s),t[2]=u,t[3]=c,t[4]=l,t[5]=i,t[6]=n,t[7]=v,t[8]=o,t[9]=p,t[10]=r,t[11]=a,t[12]=_,t[13]=y,t[14]=g,t[15]=b}else b=t[15];return b}function Fn(e){return(0,$.jsx)(f,{value:e.id,children:e.name},e.id)}function In(e){return e.language}function Ln(e){let t=(0,zt.c)(27),{checked:n,title:r,description:i,onChange:a}=e,o;t[0]!==n||t[1]!==a?(o=()=>a(!n),t[0]=n,t[1]=a,t[2]=o):o=t[2];let s=n?`bg-surface-panel text-fg`:`bg-surface-panel/80 text-fg hover:bg-surface-hover`,c;t[3]===s?c=t[4]:(c=O(`group flex w-full items-center justify-between gap-4 rounded-lg bg-surface-base/55 px-3 py-3 text-left transition-colors`,ae,s),t[3]=s,t[4]=c);let l;t[5]===r?l=t[6]:(l=(0,$.jsx)(`span`,{className:`flex flex-wrap items-center gap-2 text-sm font-semibold text-fg`,children:r}),t[5]=r,t[6]=l);let u;t[7]===i?u=t[8]:(u=(0,$.jsx)(`span`,{className:`mt-1 block text-xs leading-relaxed text-fg-muted`,children:i}),t[7]=i,t[8]=u);let d;t[9]!==l||t[10]!==u?(d=(0,$.jsxs)(`span`,{className:`min-w-0`,children:[l,u]}),t[9]=l,t[10]=u,t[11]=d):d=t[11];let f=n?`border-accent bg-accent`:`border-edge bg-surface-hover group-hover:border-accent/40`,p;t[12]===f?p=t[13]:(p=O(`relative inline-flex h-6 w-11 shrink-0 items-center rounded-full border transition-colors`,f),t[12]=f,t[13]=p);let m=n?`translate-x-5`:`translate-x-0.5`,h;t[14]===m?h=t[15]:(h=O(`size-5 rounded-full bg-white shadow-surface transition-transform`,m),t[14]=m,t[15]=h);let g;t[16]===h?g=t[17]:(g=(0,$.jsx)(`span`,{className:h}),t[16]=h,t[17]=g);let _;t[18]!==g||t[19]!==p?(_=(0,$.jsx)(`span`,{className:p,"aria-hidden":!0,children:g}),t[18]=g,t[19]=p,t[20]=_):_=t[20];let v;return t[21]!==n||t[22]!==o||t[23]!==_||t[24]!==c||t[25]!==d?(v=(0,$.jsxs)(`button`,{type:`button`,role:`switch`,"aria-checked":n,onClick:o,className:c,children:[d,_]}),t[21]=n,t[22]=o,t[23]=_,t[24]=c,t[25]=d,t[26]=v):v=t[26],v}function Rn(e){let t=(0,zt.c)(36),{field:n,value:r,onChange:i,className:a}=e,o=`voice-schema-field-${n.key}`,s=n.description;if(n.type===`boolean`){let e;t[0]===a?e=t[1]:(e=O(`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,a),t[0]=a,t[1]=e);let o;t[2]===n.label?o=t[3]:(o=(0,$.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:n.label}),t[2]=n.label,t[3]=o);let c;t[4]===s?c=t[5]:(c=s?(0,$.jsx)(`span`,{className:`mt-1 block text-xs text-fg-subtle`,children:s}):null,t[4]=s,t[5]=c);let l;t[6]!==o||t[7]!==c?(l=(0,$.jsxs)(`span`,{children:[o,c]}),t[6]=o,t[7]=c,t[8]=l):l=t[8];let u=!!r,d;t[9]!==n||t[10]!==i?(d=e=>i(Dn(n,e.target.checked)),t[9]=n,t[10]=i,t[11]=d):d=t[11];let f;t[12]!==u||t[13]!==d?(f=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:u,onChange:d}),t[12]=u,t[13]=d,t[14]=f):f=t[14];let p;return t[15]!==e||t[16]!==l||t[17]!==f?(p=(0,$.jsxs)(`label`,{className:e,children:[l,f]}),t[15]=e,t[16]=l,t[17]=f,t[18]=p):p=t[18],p}let c=typeof r==`boolean`?``:String(r),l;t[19]===a?l=t[20]:(l=O(`flex flex-col gap-1.5`,a),t[19]=a,t[20]=l);let u;t[21]===n.label?u=t[22]:(u=(0,$.jsx)(Bn,{children:n.label}),t[21]=n.label,t[22]=u);let f;t[23]!==a||t[24]!==n||t[25]!==c||t[26]!==o||t[27]!==i?(f=n.type===`select`?(0,$.jsx)(d,{id:o,className:vn(),value:c,required:n.required,onChange:e=>i(Dn(n,e.target.value)),children:(n.options??[]).map(zn)}):n.type===`textarea`?(0,$.jsx)(`textarea`,{id:o,className:O(_n(),`min-h-24 resize-y`),value:c,required:n.required,placeholder:n.placeholder,onChange:e=>i(Dn(n,e.target.value))}):n.type===`password`?(0,$.jsx)(v,{id:o,className:a,value:c,onChange:e=>i(Dn(n,e)),placeholder:n.placeholder,labels:tt}):n.type===`number`?(0,$.jsx)(mt,{id:o,className:_n(),autoComplete:n.secret?`new-password`:`off`,spellCheck:!1,value:c,required:n.required,allowEmpty:!n.required,placeholder:n.placeholder,min:n.min,max:n.max,step:n.step,onChange:e=>i(Dn(n,e.target.value))}):(0,$.jsx)(`input`,{id:o,className:_n(),type:`text`,autoComplete:n.secret?`new-password`:`off`,spellCheck:!1,value:c,required:n.required,placeholder:n.placeholder,min:n.min,max:n.max,step:n.step,onChange:e=>i(Dn(n,e.target.value))}),t[23]=a,t[24]=n,t[25]=c,t[26]=o,t[27]=i,t[28]=f):f=t[28];let p;t[29]===s?p=t[30]:(p=s?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:s}):null,t[29]=s,t[30]=p);let m;return t[31]!==l||t[32]!==u||t[33]!==f||t[34]!==p?(m=(0,$.jsxs)(`div`,{className:l,children:[u,f,p]}),t[31]=l,t[32]=u,t[33]=f,t[34]=p,t[35]=m):m=t[35],m}function zn(e){return(0,$.jsx)(f,{value:e.id,children:e.name},e.id)}function Bn(e){let t=(0,zt.c)(2),{children:n}=e,r;return t[0]===n?r=t[1]:(r=(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=r),r}function Vn(e){return e.some(e=>e.disabled?!1:e.type===`searxng`?e.url.trim().length>0:e.apiKey.trim().length>0)}function Hn(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:`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 Un(e){let t=e.regionMode===`auto`?`auto`:e.regionMode===`cn`?`cn`:`global`,n={maxResults:e.maxResults,providers:e.providers.map(e=>{let t={type:e.type,apiKey:e.apiKey};return e.type===`searxng`&&e.url.trim()&&(t.url=e.url.trim().replace(/\/+$/,``)),e.disabled&&(t.disabled=!0),t})};await k(N(`/api/config`),{method:`PATCH`,body:JSON.stringify({tools:{web:{region:t,search:n,blocklist:{enabled:e.blocklistEnabled,domains:e.blocklistDomains}}}})}),re()}async function Wn(e){let t=await k(N(`/api/tools/web/reveal-search-api-key`),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({index:e})});if(!t.ok||!t.payload)throw Error(t.error?.message??`Reveal failed`);return t.payload}function Gn(e){let t=(0,zt.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 Kn(){return O(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,ae,`dark:border-edge`)}function qn(){return O(ie,U)}var Jn=[`brave`,`tavily`,`bing`,`searxng`];function Yn(){return{clientKey:crypto.randomUUID(),type:`brave`,apiKey:``,url:``,disabled:!1}}var Xn=oe();function Zn(){let e=D(M(e=>e.language)),t=e.webSearchSettings,n=e.logs,r=!!A(e=>e.conversationId),[i,a]=(0,Q.useReducer)(Xn,{form:null,baseline:null}),o=i.form,s=i.baseline,c=(0,Q.useRef)(!1),l=(0,Q.useRef)(o);l.current=o;let u=(0,Q.useRef)(null),{data:p,error:m,isLoading:h,mutate:_}=H(r);Y({enabled:r,parsed:(0,Q.useMemo)(()=>p?.payload?.config===void 0?null:Hn(p.payload.config),[p]),dirty:c.current,trackedParsedRef:u,dispatch:a,onResetDirty:()=>{c.current=!1}});let v=!!(r&&h&&p===void 0&&!m),y=m instanceof Error?m.message:m?String(m):null,b=(0,Q.useMemo)(()=>!o||!s?!1:JSON.stringify(o)!==JSON.stringify(s),[o,s]),x=(0,Q.useCallback)(e=>{c.current=!0,a({type:`patch`,patch:e})},[]),S=xt({value:o,dirty:b,onSave:(0,Q.useCallback)(async e=>{try{await Un(e),a({type:`saved`,value:e}),c.current=!!(l.current&&JSON.stringify(l.current)!==JSON.stringify(e))}catch(e){throw Error(e instanceof Error?e.message:t.saveError)}},[t.saveError])});if(!r)return(0,$.jsx)(`div`,{className:`flex flex-col gap-3`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.needToken})});if(v)return(0,$.jsx)(yt,{rows:3});if(!o)return(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:y??t.loadError}),(0,$.jsx)(V,{type:`button`,variant:`secondary`,onClick:()=>void _(),children:n.refresh})]});let C=Vn(o.providers);return(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,onBlurCapture:S.onBlurCapture,children:[S.error?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:S.error}):null,(0,$.jsxs)(vt,{children:[(0,$.jsx)(_t,{icon:Pe,title:t.sectionSearch,subtitle:t.sectionSearchHint,trailing:(0,$.jsx)(bt,{status:S.status,error:S.error})}),(0,$.jsxs)(`div`,{className:`flex max-w-2xl flex-col gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-3 rounded-lg border border-edge bg-surface-base/55 px-4 py-3`,children:[(0,$.jsx)(g,{className:`mt-0.5 size-5 shrink-0 text-accent`}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:t.cloudProvider}),(0,$.jsx)(`span`,{className:O(`rounded-full px-2 py-0.5 text-[11px] font-medium`,C?`bg-surface-panel text-fg-muted`:`bg-accent-soft text-accent`),children:C?t.cloudOverridden:t.cloudAutomatic})]}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-subtle`,children:C?t.cloudOverriddenHint:t.cloudAutomaticHint})]})]}),(0,$.jsx)(`div`,{className:`text-xs font-medium text-fg-muted`,children:t.providersTitle}),o.providers.map((n,r)=>(0,$.jsx)(Qn,{row:n,providerIndex:r,labels:t,secretLabels:Ve(e.providersSettings),onChange:e=>{let t=[...o.providers];t[r]=e,x({providers:t})},onRemove:()=>{x({providers:o.providers.filter((e,t)=>t!==r)})}},n.clientKey??r)),(0,$.jsxs)(V,{type:`button`,variant:`secondary`,className:`w-fit gap-1.5 text-sm`,onClick:()=>x({providers:[...o.providers,Yn()]}),children:[(0,$.jsx)(w,{className:`size-4`}),t.addProvider]})]})]}),(0,$.jsxs)(vt,{children:[(0,$.jsx)(_t,{icon:Se,title:t.sectionPreferences}),(0,$.jsxs)(`div`,{className:`grid max-w-2xl gap-4 sm:grid-cols-2`,children:[(0,$.jsx)(Gn,{label:t.regionLabel,description:t.regionDesc,children:(0,$.jsxs)(d,{className:qn(),value:o.regionMode,onChange:e=>x({regionMode:e.target.value}),children:[(0,$.jsx)(f,{value:`auto`,children:t.regionAuto}),(0,$.jsx)(f,{value:`cn`,children:t.regionCn}),(0,$.jsx)(f,{value:`global`,children:t.regionGlobal})]})}),(0,$.jsx)(je,{title:t.maxResultsLabel,summary:o.maxResults,children:(0,$.jsx)(Gn,{label:t.maxResultsLabel,description:t.maxResultsDesc,children:(0,$.jsx)(mt,{type:`number`,min:1,max:50,className:Kn(),value:o.maxResults,onChange:e=>x({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)(vt,{children:[(0,$.jsx)(_t,{icon:ve,title:t.sectionBlocklist,subtitle:t.sectionBlocklistHint}),(0,$.jsxs)(`div`,{className:`flex max-w-2xl flex-col gap-4`,children:[(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-sm text-fg`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox mt-0.5`,checked:o.blocklistEnabled,onChange:e=>x({blocklistEnabled:e.target.checked})}),(0,$.jsxs)(`span`,{children:[(0,$.jsx)(`span`,{className:`font-medium`,children:t.blocklistEnabled}),(0,$.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-subtle`,children:t.blocklistEnabledDesc})]})]}),o.blocklistEnabled?(0,$.jsx)(Gn,{label:t.blocklistDomains,description:t.blocklistDomainsDesc,children:(0,$.jsx)(`textarea`,{className:O(Kn(),`min-h-[6rem] font-mono text-xs`),value:o.blocklistDomains.join(`
8
- `),placeholder:t.blocklistDomainsPlaceholder,onChange:e=>{x({blocklistDomains:e.target.value.split(/\r?\n/).flatMap(e=>{let t=e.trim().toLowerCase();return t?[t]:[]})})}})}):null]})]})]})]})}function Qn(e){let t=(0,zt.c)(54),{row:n,providerIndex:r,labels:i,secretLabels:a,onChange:o,onRemove:s}=e,c;t[0]===r?c=t[1]:(c=()=>Wn(r).then($n),t[0]=r,t[1]=c);let l=c,u;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=O(qn(),`min-w-[8rem]`),t[2]=u):u=t[2];let p=n.type,m;t[3]!==o||t[4]!==n?(m=e=>o({...n,type:e.target.value,url:e.target.value===`searxng`?n.url:``}),t[3]=o,t[4]=n,t[5]=m):m=t[5];let h;t[6]===i.providerTypes?h=t[7]:(h=Jn.map(e=>(0,$.jsx)(f,{value:e,children:i.providerTypes[e]},e)),t[6]=i.providerTypes,t[7]=h);let g;t[8]!==n.type||t[9]!==m||t[10]!==h?(g=(0,$.jsx)(d,{className:u,value:p,onChange:m,children:h}),t[8]=n.type,t[9]=m,t[10]=h,t[11]=g):g=t[11];let _;t[12]!==o||t[13]!==n?(_=e=>o({...n,disabled:e.target.checked}),t[12]=o,t[13]=n,t[14]=_):_=t[14];let y;t[15]!==n.disabled||t[16]!==_?(y=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:n.disabled,onChange:_}),t[15]=n.disabled,t[16]=_,t[17]=y):y=t[17];let b;t[18]!==i.disabled||t[19]!==y?(b=(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5 text-xs text-fg-muted`,children:[y,i.disabled]}),t[18]=i.disabled,t[19]=y,t[20]=b):b=t[20];let x;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(x=(0,$.jsx)(Le,{className:`size-4`}),t[21]=x):x=t[21];let S;t[22]===s?S=t[23]:(S=(0,$.jsx)(V,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-fg-muted`,onClick:s,children:x}),t[22]=s,t[23]=S);let C;t[24]!==S||t[25]!==b?(C=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[b,S]}),t[24]=S,t[25]=b,t[26]=C):C=t[26];let w;t[27]!==C||t[28]!==g?(w=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[g,C]}),t[27]=C,t[28]=g,t[29]=w):w=t[29];let T;t[30]!==i.urlDesc||t[31]!==i.urlLabel||t[32]!==o||t[33]!==n?(T=n.type===`searxng`?(0,$.jsx)(Gn,{label:i.urlLabel,description:i.urlDesc,children:(0,$.jsx)(`input`,{type:`url`,className:Kn(),value:n.url,placeholder:`http://localhost:8080`,onChange:e=>o({...n,url:e.target.value})})}):null,t[30]=i.urlDesc,t[31]=i.urlLabel,t[32]=o,t[33]=n,t[34]=T):T=t[34];let E;t[35]!==o||t[36]!==n?(E=e=>o({...n,apiKey:e}),t[35]=o,t[36]=n,t[37]=E):E=t[37];let D;t[38]!==i.keyPlaceholder||t[39]!==i.keyPlaceholderMasked||t[40]!==i.saveError||t[41]!==l||t[42]!==n.apiKey||t[43]!==a||t[44]!==E?(D=(0,$.jsx)(v,{value:n.apiKey,onChange:E,placeholder:i.keyPlaceholder,labels:a,reveal:l,loadFailedLabel:i.saveError,notInConfigFile:i.keyPlaceholderMasked}),t[38]=i.keyPlaceholder,t[39]=i.keyPlaceholderMasked,t[40]=i.saveError,t[41]=l,t[42]=n.apiKey,t[43]=a,t[44]=E,t[45]=D):D=t[45];let k;t[46]!==i.apiKeyDesc||t[47]!==i.apiKeyLabel||t[48]!==D?(k=(0,$.jsx)(Gn,{label:i.apiKeyLabel,description:i.apiKeyDesc,children:D}),t[46]=i.apiKeyDesc,t[47]=i.apiKeyLabel,t[48]=D,t[49]=k):k=t[49];let A;return t[50]!==w||t[51]!==T||t[52]!==k?(A=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl bg-surface-panel/60 p-4`,children:[w,T,k]}),t[50]=w,t[51]=T,t[52]=k,t[53]=A):A=t[53],A}function $n(e){return e.apiKey??null}function er(e){let t=(0,zt.c)(185),{model:n,isNew:r,providerId:i,onSave:a,onClose:o,m:s}=e,c=M(nr)===`zh`,l;t[0]===n?l=t[1]:(l=()=>n?{...n}:ke(``),t[0]=n,t[1]=l);let[u,p]=(0,Q.useState)(l),[m,h]=(0,Q.useState)(tr),g;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(g=(e,t)=>{p(n=>({...n,[e]:t})),h(t=>{let n=new Map(t);return n.delete(e),n})},t[2]=g):g=t[2];let _=g,v;t[3]!==u.computerUse||t[4]!==u.contextWindow||t[5]!==u.id||t[6]!==u.input||t[7]!==u.maxTokens||t[8]!==s.modelIdRequired||t[9]!==s.mustBePositive||t[10]!==c?(v=()=>{let e=new Map;return(u.id||``).trim()||e.set(`id`,s.modelIdRequired),u.contextWindow!==void 0&&u.contextWindow<=0&&e.set(`contextWindow`,s.mustBePositive),u.maxTokens!==void 0&&u.maxTokens<=0&&e.set(`maxTokens`,s.mustBePositive),u.computerUse&&!u.input?.includes(`image`)&&e.set(`computerUse`,c?`电脑控制模型必须支持图片输入`:`Computer Use requires image input`),h(e),e.size===0},t[3]=u.computerUse,t[4]=u.contextWindow,t[5]=u.id,t[6]=u.input,t[7]=u.maxTokens,t[8]=s.modelIdRequired,t[9]=s.mustBePositive,t[10]=c,t[11]=v):v=t[11];let y=v,b;t[12]!==u||t[13]!==o||t[14]!==a||t[15]!==y?(b=()=>{if(!y())return;let e=(u.id||``).trim();a({...u,id:e,name:u.name?.trim()||e,reasoning:u.reasoning||!1,input:u.input||[`text`],contextWindow:u.contextWindow??128e3,maxTokens:u.maxTokens??16384,cost:{input:u.cost?.input??0,output:u.cost?.output??0,cacheRead:u.cost?.cacheRead??0,cacheWrite:u.cost?.cacheWrite??0}}),o()},t[12]=u,t[13]=o,t[14]=a,t[15]=y,t[16]=b):b=t[16];let x=b,S=u,C;t[17]===S?C=t[18]:(C=fe(S),t[17]=S,t[18]=C);let w=C,T=r?s.addModelTitle:s.editModelTitle,D;t[19]===T?D=t[20]:(D=(0,$.jsx)(ee,{className:`text-base font-semibold text-fg`,children:T}),t[19]=T,t[20]=D);let k;t[21]!==s.modelProviderLabel||t[22]!==i?(k=i?(0,$.jsxs)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:[s.modelProviderLabel,`: `,i]}):null,t[21]=s.modelProviderLabel,t[22]=i,t[23]=k):k=t[23];let A;t[24]!==D||t[25]!==k?(A=(0,$.jsxs)(`div`,{children:[D,k]}),t[24]=D,t[25]=k,t[26]=A):A=t[26];let j;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(j=O(ne,`p-1.5 hover:bg-surface-base`),t[27]=j):j=t[27];let N;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,$.jsx)(E,{className:`size-4`}),t[28]=N):N=t[28];let P;t[29]===s.close?P=t[30]:(P=(0,$.jsx)(I,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:j,"aria-label":s.close,children:N})}),t[29]=s.close,t[30]=P);let F;t[31]!==A||t[32]!==P?(F=(0,$.jsxs)(`div`,{className:`mb-3 flex shrink-0 items-start justify-between gap-2`,children:[A,P]}),t[31]=A,t[32]=P,t[33]=F):F=t[33];let L;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(L=(0,$.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`}),t[34]=L):L=t[34];let R;t[35]===s.modelId?R=t[36]:(R=(0,$.jsxs)(`label`,{className:`mb-1 block text-xs font-medium text-fg`,children:[s.modelId,L]}),t[35]=s.modelId,t[36]=R);let z;t[37]===m?z=t[38]:(z=O(st(),m.has(`id`)&&`border-red-500`),t[37]=m,t[38]=z);let B=u.id||``,te;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(te=e=>_(`id`,e.target.value),t[39]=te):te=t[39];let re=!r,H;t[40]!==z||t[41]!==B||t[42]!==re?(H=(0,$.jsx)(`input`,{className:z,value:B,onChange:te,placeholder:`e.g. llama3.1:8b`,disabled:re}),t[40]=z,t[41]=B,t[42]=re,t[43]=H):H=t[43];let U;t[44]===m?U=t[45]:(U=m.has(`id`)?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:m.get(`id`)}):null,t[44]=m,t[45]=U);let ie;t[46]!==R||t[47]!==H||t[48]!==U?(ie=(0,$.jsxs)(`div`,{children:[R,H,U]}),t[46]=R,t[47]=H,t[48]=U,t[49]=ie):ie=t[49];let ae;t[50]===s.displayName?ae=t[51]:(ae=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.displayName}),t[50]=s.displayName,t[51]=ae);let W;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(W=st(),t[52]=W):W=t[52];let G=u.name||``,K;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(K=e=>_(`name`,e.target.value),t[53]=K):K=t[53];let q;t[54]===G?q=t[55]:(q=(0,$.jsx)(`input`,{className:W,value:G,onChange:K}),t[54]=G,t[55]=q);let J;t[56]!==ae||t[57]!==q?(J=(0,$.jsxs)(`div`,{children:[ae,q]}),t[56]=ae,t[57]=q,t[58]=J):J=t[58];let Y;t[59]===s.inputTypes?Y=t[60]:(Y=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.inputTypes}),t[59]=s.inputTypes,t[60]=Y);let oe;t[61]===Symbol.for(`react.memo_cache_sentinel`)?(oe=ot(),t[61]=oe):oe=t[61];let se;t[62]===Symbol.for(`react.memo_cache_sentinel`)?(se=e=>_(`input`,Oe(e.target.value)),t[62]=se):se=t[62];let X;t[63]===s?X=t[64]:(X=Be.map(e=>(0,$.jsx)(f,{value:e.value,children:s[e.labelKey]},e.value)),t[63]=s,t[64]=X);let ce;t[65]!==w||t[66]!==X?(ce=(0,$.jsx)(d,{className:oe,value:w,onChange:se,children:X}),t[65]=w,t[66]=X,t[67]=ce):ce=t[67];let Z;t[68]!==Y||t[69]!==ce?(Z=(0,$.jsxs)(`div`,{children:[Y,ce]}),t[68]=Y,t[69]=ce,t[70]=Z):Z=t[70];let le=u.reasoning||!1,ue;t[71]===Symbol.for(`react.memo_cache_sentinel`)?(ue=e=>_(`reasoning`,e.target.checked),t[71]=ue):ue=t[71];let de;t[72]===le?de=t[73]:(de=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:le,onChange:ue}),t[72]=le,t[73]=de);let pe;t[74]!==s.reasoning||t[75]!==de?(pe=(0,$.jsxs)(`label`,{className:`mt-6 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[de,s.reasoning]}),t[74]=s.reasoning,t[75]=de,t[76]=pe):pe=t[76];let me;t[77]!==Z||t[78]!==pe?(me=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[Z,pe]}),t[77]=Z,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]===m?ge=t[83]:(ge=O(st(),m.has(`contextWindow`)&&`border-red-500`),t[82]=m,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)(mt,{type:`number`,min:1,className:ge,value:_e,onChange:ve}),t[85]=ge,t[86]=_e,t[87]=ye):ye=t[87];let be;t[88]===m?be=t[89]:(be=m.has(`contextWindow`)?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:m.get(`contextWindow`)}):null,t[88]=m,t[89]=be);let xe;t[90]!==he||t[91]!==ye||t[92]!==be?(xe=(0,$.jsxs)(`div`,{children:[he,ye,be]}),t[90]=he,t[91]=ye,t[92]=be,t[93]=xe):xe=t[93];let Se;t[94]===s.maxOutputTokens?Se=t[95]:(Se=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.maxOutputTokens}),t[94]=s.maxOutputTokens,t[95]=Se);let Ce;t[96]===m?Ce=t[97]:(Ce=O(st(),m.has(`maxTokens`)&&`border-red-500`),t[96]=m,t[97]=Ce);let we=u.maxTokens??16384,Te;t[98]===Symbol.for(`react.memo_cache_sentinel`)?(Te=e=>_(`maxTokens`,parseInt(e.target.value,10)||0),t[98]=Te):Te=t[98];let Ee;t[99]!==Ce||t[100]!==we?(Ee=(0,$.jsx)(mt,{type:`number`,min:1,className:Ce,value:we,onChange:Te}),t[99]=Ce,t[100]=we,t[101]=Ee):Ee=t[101];let De;t[102]===m?De=t[103]:(De=m.has(`maxTokens`)?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:m.get(`maxTokens`)}):null,t[102]=m,t[103]=De);let Ae;t[104]!==Se||t[105]!==Ee||t[106]!==De?(Ae=(0,$.jsxs)(`div`,{children:[Se,Ee,De]}),t[104]=Se,t[105]=Ee,t[106]=De,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=st(),t[115]=Pe):Pe=t[115];let Fe=u.cost?.input??0,Ie;t[116]===u.cost?Ie=t[117]:(Ie=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]=Ie);let Le;t[118]!==Fe||t[119]!==Ie?(Le=(0,$.jsx)(mt,{type:`number`,step:`any`,min:0,className:Pe,value:Fe,onChange:Ie}),t[118]=Fe,t[119]=Ie,t[120]=Le):Le=t[120];let Re;t[121]!==Ne||t[122]!==Le?(Re=(0,$.jsxs)(`div`,{children:[Ne,Le]}),t[121]=Ne,t[122]=Le,t[123]=Re):Re=t[123];let ze;t[124]===s.costOutput?ze=t[125]:(ze=(0,$.jsx)(`label`,{className:`mb-1 block text-xs text-fg-muted`,children:s.costOutput}),t[124]=s.costOutput,t[125]=ze);let Ve;t[126]===Symbol.for(`react.memo_cache_sentinel`)?(Ve=st(),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)(mt,{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]!==ze||t[133]!==We?(Ge=(0,$.jsxs)(`div`,{children:[ze,We]}),t[132]=ze,t[133]=We,t[134]=Ge):Ge=t[134];let Ke;t[135]!==Re||t[136]!==Ge?(Ke=(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[Re,Ge]}),t[135]=Re,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]!==ie||t[142]!==J||t[143]!==me||t[144]!==je||t[145]!==qe?(Je=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[ie,J,me,je,qe]}),t[141]=ie,t[142]=J,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)(f,{value:``,children:et}),t[150]=et,t[151]=tt);let nt,rt,it;t[152]===Symbol.for(`react.memo_cache_sentinel`)?(nt=(0,$.jsx)(f,{value:`gui-plus-2026-02-26`,children:`GUI-Plus (2026-02-26)`}),rt=(0,$.jsx)(f,{value:`structured-tools-v1`,children:`structured-tools-v1`}),it=(0,$.jsx)(f,{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)(d,{"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 ct=c?`协议必须与模型 API 匹配。声明协议不代表模型已通过效果验证。`:`The protocol must match the model API. Declaring a protocol does not certify model quality.`,lt;t[159]===ct?lt=t[160]:(lt=(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:ct}),t[159]=ct,t[160]=lt);let ut;t[161]===m?ut=t[162]:(ut=m.has(`computerUse`)&&(0,$.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:m.get(`computerUse`)}),t[161]=m,t[162]=ut);let dt;t[163]!==at||t[164]!==lt||t[165]!==ut?(dt=(0,$.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[at,lt,ut]}),t[163]=at,t[164]=lt,t[165]=ut,t[166]=dt):dt=t[166];let ft;t[167]!==Xe||t[168]!==dt?(ft=(0,$.jsxs)(`details`,{className:`mt-4 rounded-lg border border-edge p-3 text-sm text-fg`,children:[Xe,dt]}),t[167]=Xe,t[168]=dt,t[169]=ft):ft=t[169];let pt;t[170]!==Je||t[171]!==ft?(pt=(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pr-1`,children:[Je,ft]}),t[170]=Je,t[171]=ft,t[172]=pt):pt=t[172];let ht;t[173]===s.cancel?ht=t[174]:(ht=(0,$.jsx)(I,{asChild:!0,children:(0,$.jsx)(V,{type:`button`,variant:`secondary`,children:s.cancel})}),t[173]=s.cancel,t[174]=ht);let gt=r?s.addModelConfirm:s.saveModelConfirm,_t;t[175]!==x||t[176]!==gt?(_t=(0,$.jsx)(V,{type:`button`,variant:`primary`,className:`hover:bg-accent/90`,onClick:x,children:gt}),t[175]=x,t[176]=gt,t[177]=_t):_t=t[177];let vt;t[178]!==ht||t[179]!==_t?(vt=(0,$.jsxs)(`div`,{className:`mt-4 flex shrink-0 justify-end gap-2 border-t border-edge-subtle pt-3 dark:border-edge`,children:[ht,_t]}),t[178]=ht,t[179]=_t,t[180]=vt):vt=t[180];let yt;return t[181]!==F||t[182]!==pt||t[183]!==vt?(yt=(0,$.jsxs)($.Fragment,{children:[F,pt,vt]}),t[181]=F,t[182]=pt,t[183]=vt,t[184]=yt):yt=t[184],yt}function tr(){return new Map}function nr(e){return e.language}function rr(e){let t=(0,zt.c)(16),{open:n,onOpenChange:r,providerId:i,model:a,isNew:o,onSave:s,m:c}=e,l;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(l=(0,$.jsx)(P,{className:O(`xopc-dialog-overlay fixed inset-0 bg-scrim`,q)}),t[0]=l):l=t[0];let u;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(u=O(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(90vh,720px)] w-[min(100%-2rem,28rem)] -translate-x-1/2 -translate-y-1/2 flex-col`,K,`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)(er,{model:a,isNew:o,providerId:i,onSave:s,onClose:()=>r(!1),m:c},`${i??`none`}-${a?.id??`new`}`):null,t[2]=o,t[3]=c,t[4]=a,t[5]=r,t[6]=s,t[7]=n,t[8]=i,t[9]=d):d=t[9];let f;t[10]===d?f=t[11]:(f=(0,$.jsxs)(L,{children:[l,(0,$.jsx)(R,{className:u,onOpenAutoFocus:ir,children:d})]}),t[10]=d,t[11]=f);let p;return t[12]!==r||t[13]!==n||t[14]!==f?(p=(0,$.jsx)(z,{open:n,onOpenChange:r,children:f}),t[12]=r,t[13]=n,t[14]=f,t[15]=p):p=t[15],p}function ir(e){return e.preventDefault()}function ar(e){let t=(0,zt.c)(14),{providerId:n,inputId:r,value:i,onChange:a,labels:o}=e,s;t[0]===n?s=t[1]:(s=()=>Ne(n).then(or),t[0]=n,t[1]=s);let c=s,l;t[2]!==r||t[3]!==o.apiKeyLabel?(l=(0,$.jsx)(`label`,{htmlFor:r,className:`text-sm font-medium text-fg`,children:o.apiKeyLabel}),t[2]=r,t[3]=o.apiKeyLabel,t[4]=l):l=t[4];let u;t[5]!==r||t[6]!==o||t[7]!==a||t[8]!==c||t[9]!==i?(u=(0,$.jsx)(v,{id:r,value:i,onChange:a,placeholder:o.apiKeyPlaceholder,labels:o,reveal:c,loadFailedLabel:o.loadFailed,maskedHelp:o.maskedHelp,notInConfigFile:o.notInConfigFile}),t[5]=r,t[6]=o,t[7]=a,t[8]=c,t[9]=i,t[10]=u):u=t[10];let d;return t[11]!==l||t[12]!==u?(d=(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[l,u]}),t[11]=l,t[12]=u,t[13]=d):d=t[13],d}function or(e){return e.apiKey??null}function sr(e){let t=(0,zt.c)(20),{open:n,onOpenChange:r,providerId:i,isCustom:a,builtinRows:o,customConfig:s,allModels:c,labels:l,language:u,onSaved:d}=e,[f,p]=(0,Q.useState)(null),m;t[0]===r?m=t[1]:(m=e=>{e||p(null),r(e)},t[0]=r,t[1]=m);let h=m,g;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(g=(0,$.jsx)(P,{className:O(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,q)}),t[2]=g):g=t[2];let _;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(_=O(`xopc-dialog-content fixed left-1/2 top-1/2 flex h-[min(85vh,720px)] w-[calc(100%-2rem)] max-w-lg -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay`,K),t[3]=_):_=t[3];let v;t[4]!==c||t[5]!==o||t[6]!==s||t[7]!==h||t[8]!==a||t[9]!==l||t[10]!==u||t[11]!==r||t[12]!==d||t[13]!==i||t[14]!==f?(v=(0,$.jsxs)(L,{children:[g,(0,$.jsx)(R,{className:_,children:f?(0,$.jsx)(lt,{target:f,zh:u===`zh`,onDone:()=>h(!1)}):a?(0,$.jsx)(lr,{providerId:i,customConfig:s,labels:l,language:u,onClose:()=>r(!1),onSaved:d,onModelAdded:e=>p({providerId:i,modelIds:[e]})}):(0,$.jsx)(cr,{providerId:i,builtinRows:o,allModels:c,labels:l,language:u,onClose:()=>r(!1),onSaved:d})})]}),t[4]=c,t[5]=o,t[6]=s,t[7]=h,t[8]=a,t[9]=l,t[10]=u,t[11]=r,t[12]=d,t[13]=i,t[14]=f,t[15]=v):v=t[15];let y;return t[16]!==h||t[17]!==n||t[18]!==v?(y=(0,$.jsx)(z,{open:n,onOpenChange:h,children:v}),t[16]=h,t[17]=n,t[18]=v,t[19]=y):y=t[19],y}function cr({providerId:e,builtinRows:t,allModels:n,labels:r,language:i,onClose:a,onSaved:o}){let s=t.find(t=>t.id===e),c=pe[e],u=n.filter(t=>t.provider===e),[d,f]=(0,Q.useState)(!1),[p,h]=(0,Q.useState)(s?.apiKey??``),[g,v]=(0,Q.useState)(!1),[y,x]=(0,Q.useState)(!1),[S,C]=(0,Q.useState)(null),[w,T]=(0,Q.useState)(!1),k=D(i).providersSettings,A=s?.supportsApiKey!==!1,j=s?.supportsOAuth===!0,M=s?.authMode===`oauth`&&s.authStatus===`connected`,N=s?.configured===!0&&s.activeKeySource!==`env`&&s.activeKeySource!==`extension`&&s.activeKeySource!==`models_json`,[P,F]=(0,Q.useState)(null),[L,R]=(0,Q.useState)(null),[z,B]=(0,Q.useState)(`idle`),[ne,re]=(0,Q.useState)(null),[H,U]=(0,Q.useState)(null),[ie,W]=(0,Q.useState)(null),[G,K]=(0,Q.useState)(``),q=(0,Q.useRef)(null),J=(0,Q.useRef)(null),Y=z===`waiting`||z===`waiting_code`,oe=(0,Q.useMemo)(()=>Te(e,i),[e,i]),se=p!==(s?.apiKey??``),X=async()=>{let t=p.trim();if(!(!t||!A||_e(t))){v(!0),C(null);try{await Ae({[e]:t}),x(!0),window.setTimeout(()=>{o(),a()},600)}catch(e){C(e instanceof Error?e.message:r.saveError)}finally{v(!1)}}};(0,Q.useEffect)(()=>{if(!P||!Y)return;let e=window.setInterval(()=>{(async()=>{try{let t=await ye(P);t.status===`waiting_auth`||t.status===`waiting_code`?(B(t.status===`waiting_code`?`waiting_code`:`waiting`),R(t.message??null),re(t.authUrl??null),U(t.instructions??null),W(t.deviceCode??null),t.authUrl&&t.authUrl!==J.current&&(J.current=t.authUrl,Ye(t.authUrl,q.current).catch(()=>{}))):t.status===`completed`?(window.clearInterval(e),Z(q.current),q.current=null,B(`success`),R(t.message??k.saved),window.setTimeout(()=>{o(),a()},600)):(t.status===`failed`||t.status===`cancelled`)&&(window.clearInterval(e),Z(q.current),q.current=null,B(`error`),R(t.error??t.message??k.revokeFailed))}catch{}})()},1e3);return()=>window.clearInterval(e)},[P,Y,a,o,k.revokeFailed,k.saved]),(0,Q.useEffect)(()=>()=>{P&&ge(P).catch(()=>{})},[P]),(0,Q.useEffect)(()=>()=>{Z(q.current),q.current=null},[]);let ce=async()=>{try{await ue(e),o(),a()}catch{}},le=async()=>{Z(q.current),q.current=xe(),J.current=null,B(`waiting`),R(k.oauthStarting),re(null),U(null),W(null),C(null);try{F((await De(e)).sessionId)}catch(e){Z(q.current),q.current=null,B(`error`),R(e instanceof Error?e.message:k.revokeFailed)}},de=async()=>{if(P){try{await Ee(P)}catch{}Z(q.current),q.current=null,J.current=null,B(`idle`),R(null),F(null),re(null),U(null),W(null)}},fe=async()=>{if(!(!P||!G.trim()))try{await ft(P,G.trim()),K(``),R(k.oauthProcessingCode)}catch(e){B(`error`),R(e instanceof Error?e.message:k.revokeFailed)}},me=async()=>{try{await be(e),o(),a()}catch(e){C(e instanceof Error?e.message:k.revokeFailed)}};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b border-edge-subtle px-5 py-4`,children:[(0,$.jsx)(ee,{className:`text-base font-semibold text-fg`,children:s?.name??e}),(0,$.jsx)(I,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:O(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,te.press),children:(0,$.jsx)(E,{className:`size-4`,"aria-hidden":!0})})})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-4 overflow-y-auto px-5 py-4`,children:[c?.description?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:c.description}):null,s?.baseUrl?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:r.apiUrlLabel}),(0,$.jsx)(`code`,{className:`break-all rounded-lg border border-edge-subtle bg-surface-panel/60 px-3 py-2 font-mono text-xs text-fg-muted`,children:s.baseUrl})]}):s?.category===`extension`?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.apiUrlExtensionHint}):null,A?(0,$.jsx)(ar,{providerId:e,inputId:`manage-api-key`,value:p,onChange:e=>{h(e),x(!1)},labels:{apiKeyLabel:r.apiKeyLabel,apiKeyPlaceholder:r.apiKeyPlaceholder,maskedHelp:r.maskedHelp,copy:r.copy,copied:r.copied,show:r.showKey,hide:r.hideKey,notInConfigFile:r.notInConfigFile,loadFailed:r.loadFailed}}):s?.category===`extension`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-panel/60 px-3 py-2 text-sm text-fg-muted`,children:[(0,$.jsx)(`p`,{children:r.extensionKeyHint}),s?.extensionId?(0,$.jsxs)(l,{to:`/settings/ext/${encodeURIComponent(s.extensionId)}`,className:`inline-flex w-fit items-center gap-1 font-medium text-accent hover:underline`,title:r.extensionSettingsLinkTitle,onClick:a,children:[r.openExtensionSettings,(0,$.jsx)(_,{className:`size-3`,"aria-hidden":!0})]}):null]}):null,j?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-panel/60 p-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:k.oauth}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:M?k.sourceOauth:k.oauthHint})]}),M?(0,$.jsx)(V,{type:`button`,variant:`secondary`,className:`gap-1.5 text-red-600 dark:text-red-400`,onClick:()=>void me(),children:k.revoke}):(0,$.jsxs)(V,{type:`button`,variant:`primary`,className:`gap-1.5`,disabled:Y,onClick:()=>void le(),children:[Y?(0,$.jsx)(b,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(it,{className:`size-3.5`,"aria-hidden":!0}),k.oauth]})]}),L?(0,$.jsx)(`p`,{className:O(`text-xs`,z===`error`?`text-red-600 dark:text-red-400`:`text-fg-muted`),children:L}):null,z===`waiting`||z===`waiting_code`?(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[ne?(0,$.jsxs)(`a`,{href:ne,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1.5 rounded-md bg-accent px-3 py-2 text-sm font-medium text-on-accent hover:bg-accent-hover`,children:[(0,$.jsx)(_,{className:`size-4`,"aria-hidden":!0}),k.openAuthPage]}):null,(0,$.jsx)(V,{type:`button`,variant:`secondary`,onClick:()=>void de(),children:k.cancelOAuth})]}):null,H?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:H}):null,ie?(0,$.jsxs)(`div`,{className:`rounded-lg border border-edge-subtle bg-surface-panel px-3 py-2`,children:[(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:k.deviceCodeLabel}),(0,$.jsx)(`code`,{className:`mt-1 block select-all font-mono text-lg font-semibold tracking-widest text-fg`,children:ie}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:k.deviceCodeHint})]}):null,z===`waiting_code`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,$.jsx)(`input`,{type:`text`,value:G,onChange:e=>K(e.target.value),onKeyDown:e=>e.key===`Enter`&&void fe(),placeholder:k.pasteRedirectUrl,className:O(`min-w-0 flex-1 rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,ae)}),(0,$.jsx)(V,{type:`button`,variant:`primary`,onClick:()=>void fe(),children:k.submitCode})]}):null]}):null,oe.length>0&&A?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:oe.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)(_,{className:`size-3`,"aria-hidden":!0})]},e))}):null,u.length>0?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsxs)(`span`,{className:`text-sm font-medium text-fg`,children:[r.modelsLabel,` (`,u.length,`)`]}),(0,$.jsxs)(`label`,{className:`mb-2 flex items-center gap-2 text-xs text-fg-muted`,children:[(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:d,onChange:e=>f(e.target.checked)}),i===`zh`?`仅电脑控制模型`:`Computer Use only`]}),(0,$.jsx)(`div`,{className:`max-h-40 overflow-y-auto rounded-lg border border-edge-subtle bg-surface-panel/40 p-2`,children:(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:u.filter(e=>!d||e.computerUse).map(e=>(0,$.jsxs)(`span`,{className:`inline-block rounded-md bg-surface-hover px-2 py-1 text-xs text-fg-muted`,children:[Fe(e,i),e.computerUse?` · Computer Use`:``]},e.id))})})]}):(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r.noModels}),S?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:S}):null]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle px-5 py-3`,children:[N?(0,$.jsxs)(V,{type:`button`,variant:`ghost`,className:`gap-1.5 text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300`,onClick:()=>T(!0),children:[(0,$.jsx)(Le,{className:`size-3.5`,"aria-hidden":!0}),r.remove]}):(0,$.jsx)(`span`,{}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:A&&se&&!_e(p.trim())?(0,$.jsx)(V,{type:`button`,variant:`primary`,disabled:!p.trim()||g||y,onClick:()=>void X(),children:y?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(m,{className:`size-3.5`,"aria-hidden":!0}),r.saved]}):g?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(b,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),r.saving]}):r.save}):null})]}),(0,$.jsx)(nt,{open:w,title:r.removeConfirmTitle,description:r.removeConfirmDescription.replace(`{{provider}}`,s?.name??e),confirmLabel:r.removeConfirmAction,cancelLabel:r.cancel,destructive:!0,onConfirm:()=>void ce(),onCancel:()=>T(!1)})]})}function lr({providerId:e,customConfig:t,labels:n,language:r,onClose:i,onSaved:a,onModelAdded:o}){let s=D(r).modelsSettings,c=t?.providers[e],[l,u]=(0,Q.useState)(c?.baseUrl??``),[d,f]=(0,Q.useState)(c?.apiKey??``),[p,m]=(0,Q.useState)(c?.models??[]),[h,g]=(0,Q.useState)(!1),[_,v]=(0,Q.useState)(c?.modelDiscovery?.enabled===!0),[y,x]=(0,Q.useState)(!1),[C,T]=(0,Q.useState)(null),[k,A]=(0,Q.useState)(!1),[j,M]=(0,Q.useState)(null),[N,P]=(0,Q.useState)(!1),[F,L]=(0,Q.useState)(null),R=n=>{if(!t)return null;let r=d.trim(),i={...c,baseUrl:l.trim()||void 0,apiKey:_e(r)?c?.apiKey:r||void 0,...n};return{providers:{...t.providers,[e]:i}}},z=async()=>{let e=R({models:p,modelDiscovery:{enabled:_}});if(e){x(!0),T(null);try{await me(e),a(),i()}catch(e){T(e instanceof Error?e.message:n.saveError)}finally{x(!1)}}},B=async()=>{if(t)try{let{[e]:n,...r}=t.providers;await me({providers:r}),a(),i()}catch{}},ne=(e,t)=>{L({model:e,isNew:t}),P(!0)},re=async e=>{if(!F)return;let t=F.isNew&&!p.some(t=>t.id===e.id),r=F.isNew?[...p,e]:p.map(t=>t.id===e.id?e:t);m(r);let i=R({models:r});if(i)try{await me(i),a(),t&&!e.computerUse&&o(e.id)}catch(e){T(e instanceof Error?e.message:n.saveError)}},H=async e=>{let t=p.filter(t=>t.id!==e);m(t),M(null);let r=R({models:t});if(r)try{await me(r),a()}catch(e){T(e instanceof Error?e.message:n.saveError)}};return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-b border-edge-subtle px-5 py-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(ee,{className:`text-base font-semibold text-fg`,children:e}),(0,$.jsx)(`span`,{className:`rounded bg-surface-hover px-1.5 py-0.5 text-[10px] font-medium text-fg-subtle`,children:n.custom})]}),(0,$.jsx)(I,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:O(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,te.press),children:(0,$.jsx)(E,{className:`size-4`,"aria-hidden":!0})})})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-4 overflow-y-auto px-5 py-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`label`,{htmlFor:`manage-base-url`,className:`text-sm font-medium text-fg`,children:n.baseUrlLabel}),(0,$.jsx)(`input`,{id:`manage-base-url`,type:`url`,autoComplete:`off`,value:l,onChange:e=>u(e.target.value),className:O(`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,ae)})]}),(0,$.jsx)(ar,{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:_,onChange:e=>v(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,p.length>0?` (${p.length})`:``]}),(0,$.jsxs)(V,{type:`button`,variant:`primary`,className:`gap-1.5 px-2 py-1 text-xs`,onClick:()=>ne(null,!0),children:[(0,$.jsx)(w,{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:h,onChange:e=>g(e.target.checked)}),r===`zh`?`仅电脑控制模型`:`Computer Use only`]}),p.filter(e=>!h||e.computerUse).length===0?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:s.modelsEmpty}):(0,$.jsx)(`ul`,{className:`space-y-2`,children:p.filter(e=>!h||e.computerUse).map(e=>(0,$.jsxs)(`li`,{className:`flex items-center justify-between gap-2 rounded-lg border border-edge-subtle bg-surface-panel/40 px-3 py-2`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:`truncate text-sm font-medium text-fg`,children:e.id}),e.computerUse&&(0,$.jsx)(`span`,{className:`text-xs text-fg-muted`,children:`Computer Use`}),e.name&&e.name!==e.id?(0,$.jsx)(`div`,{className:`truncate text-xs text-fg-muted`,children:e.name}):null]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 gap-1`,children:[(0,$.jsx)(`button`,{type:`button`,className:O(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,te.press),onClick:()=>ne(e,!1),"aria-label":s.editModel,children:(0,$.jsx)(S,{className:`size-3.5`,"aria-hidden":!0})}),(0,$.jsx)(`button`,{type:`button`,className:O(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-red-600 dark:hover:text-red-400`,te.press),onClick:()=>M(e.id),"aria-label":s.removeModel,children:(0,$.jsx)(Le,{className:`size-3.5`,"aria-hidden":!0})})]})]},e.id))})]}),C?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:C}):null]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle px-5 py-3`,children:[(0,$.jsxs)(V,{type:`button`,variant:`ghost`,className:`gap-1.5 text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300`,onClick:()=>A(!0),children:[(0,$.jsx)(Le,{className:`size-3.5`,"aria-hidden":!0}),n.remove]}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,$.jsx)(V,{type:`button`,variant:`primary`,disabled:y,onClick:()=>void z(),children:y?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(b,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),n.saving]}):n.save})})]}),(0,$.jsx)(nt,{open:k,title:n.removeConfirmTitle,description:n.removeConfirmDescription.replace(`{{provider}}`,e),confirmLabel:n.removeConfirmAction,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>void B(),onCancel:()=>A(!1)}),(0,$.jsx)(nt,{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)(rr,{open:N,onOpenChange:e=>{P(e),e||L(null)},providerId:e,model:F?.model??null,isNew:F?.isNew??!1,onSave:e=>void re(e),m:s})]})}function ur(e){return e.status===`ready`?`ready`:e.status===`disabled`?`off`:e.status===`degraded`?`degraded`:e.rejected?.length?`misconfigured`:`not-configured`}function dr(e,t){if(e.startsWith(`agentCatalog.defaults.models`))return{label:t?`全局智能体默认模型`:`Global agent defaults`,href:`/settings/agent-defaults`};let n=e.match(/^agentCatalog\.agents\.([^.]+)\.models/);return n?.[1]?{label:t?`智能体 ${n[1]}`:`Agent ${n[1]}`,href:Ce(n[1])}:e.startsWith(`sessions.`)?{label:t?`会话模型覆盖`:`Session model override`,href:`/settings/sessions`}:{label:e,href:`/settings/agent-defaults`}}function fr(e,t){switch(e){case`computer-use`:return{href:`/settings/computer-use`,guidance:t?`选择兼容的电脑控制模型;本机权限需单独授权`:`Select a compatible computer model; local access requires separate approval`,action:t?`配置电脑控制`:`Configure computer use`};case`vision`:return{href:`${et(`models`)}?add=1`,guidance:t?`接入支持图片理解的模型服务`:`Connect a model service that supports vision`,action:t?`去接入模型`:`Connect model`};case`image-generation`:return{href:et(`image`),guidance:t?`选择图片模型并配置所需凭据`:`Choose an image model and configure its credentials`,action:t?`去配置图片生成`:`Configure image generation`};case`stt`:return{href:et(`voice`),guidance:t?`选择语音识别服务,或安装自管 STT 扩展`:`Choose a speech-to-text service or install a self-managed STT extension`,action:t?`去配置语音识别`:`Configure speech-to-text`};case`tts`:return{href:et(`voice`),guidance:t?`选择语音合成服务并完成凭据配置`:`Choose a text-to-speech service and configure its credentials`,action:t?`去配置语音合成`:`Configure text-to-speech`}}}function pr(e){switch(e){case`computer-use`:return`/settings/computer-use`;case`vision`:return et(`models`);case`image-generation`:return et(`image`);case`stt`:case`tts`:return et(`voice`)}}async function mr(){let e=await j(N(`/api/models/catalog`)),t=await e.json().catch(()=>null);if(!e.ok||!t?.ok||!t.payload)throw Error(t?.error?.message??`HTTP ${e.status}`);return t.payload}async function hr(){let e=await j(N(`/api/capabilities/readiness`)),t=await e.json().catch(()=>null);if(!e.ok||!t?.ok||!t.payload)throw Error(t?.error?.message??`HTTP ${e.status}`);return t.payload}function gr(){let e=M(e=>e.language)===`zh`,{data:t,error:n,isLoading:r}=B(X,mr,{revalidateOnFocus:!0,refreshInterval:6e4}),{data:i}=B(ce,hr,{revalidateOnFocus:!1}),[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(null);if(r)return(0,$.jsx)(G,{className:`h-24 w-full rounded-2xl`});let d=Object.values(t?.sources??{}),f=d.reduce((e,t)=>e+t.models.filter(e=>e.availability===`available`).length,0),p=(t?.references??[]).filter(e=>e.availability===`unavailable`),g=t?.sync.lastSuccessAt??Math.max(0,...d.map(e=>e.lastSuccessAt)),_=!!n,v=t?.sync.sourceErrors??{},y=[...t?.sync.lastError?[[`catalog`,t.sync.lastError]]:[],...Object.entries(v),...s?[[`refresh`,s]]:[],...n instanceof Error?[[`load`,n.message]]:[]],x=t?.sync.lastAttemptAt??g,S=Object.entries(i?.capabilities??{}).filter(([e])=>e!==`computer-use`||J()),C=S.some(([,e])=>{let t=ur(e);return t===`degraded`||t===`misconfigured`}),w=S.filter(([,e])=>ur(e)===`ready`).length,T=async()=>{o(!0),c(null);try{let e=await j(N(`/api/models/catalog/refresh`),{method:`POST`});if(!e.ok)throw Error(`HTTP ${e.status}`);await se()}catch(e){c(e instanceof Error?e.message:String(e))}finally{o(!1)}};return(0,$.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/25 p-4 sm:p-5`,children:[(0,$.jsxs)(`details`,{className:`group`,open:C||void 0,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer list-none rounded-lg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:(0,$.jsxs)(`div`,{className:`flex min-h-10 items-center gap-2`,children:[C?(0,$.jsx)(Ge,{className:`size-4 text-amber-500`,"aria-hidden":!0}):w===S.length&&S.length>0?(0,$.jsx)(m,{className:`size-4 text-emerald-500`,"aria-hidden":!0}):(0,$.jsx)(h,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),(0,$.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`span`,{className:`block text-sm font-semibold text-fg`,children:e?`可选能力`:`Optional capabilities`}),(0,$.jsx)(`span`,{className:`mt-0.5 block text-xs font-normal text-fg-muted`,children:e?`${w}/${S.length} 项已配置,不影响基础聊天功能`:`${w} of ${S.length} configured · Not required for chat`})]}),(0,$.jsx)(u,{className:`size-4 shrink-0 text-fg-subtle transition-transform group-open:rotate-90 motion-reduce:transition-none`,"aria-hidden":!0})]})}),i?(0,$.jsx)(`div`,{className:`mt-3 grid gap-1 sm:grid-cols-2`,children:Object.entries(i.capabilities).map(([t,n])=>{if(t===`computer-use`&&!J())return null;let r=t===`vision`?e?`图片理解`:`Vision`:t===`image-generation`?e?`图片生成`:`Image generation`:t===`computer-use`?e?`电脑控制模型`:`Computer use model`:t.toUpperCase(),i=n.selectionSource!==`explicit-config`,a=ur(n),o=a===`degraded`||a===`misconfigured`,s=fr(t,e),c=(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`min-w-0 text-xs font-medium text-fg`,children:r}),(0,$.jsx)(`span`,{className:a===`ready`?`shrink-0 text-xs text-emerald-600 dark:text-emerald-400`:a===`off`||a===`not-configured`?`shrink-0 text-xs text-fg-muted`:`shrink-0 text-xs text-amber-600 dark:text-amber-400`,children:a===`ready`?t===`computer-use`?e?`已配置`:`Configured`:e?`可用`:`Ready`:a===`off`?e?`已关闭`:`Off`:a===`not-configured`?e?`未配置`:`Not configured`:a===`degraded`?e?`正在使用备用方案`:`Using fallback`:e?`需处理`:`Needs attention`})]}),(0,$.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted`,title:n.primary?`${n.primary.provider}/${n.primary.model}`:void 0,children:n.primary?`${i?e?`自动`:`Auto`:e?`显式`:`Explicit`} · ${n.primary.provider}/${n.primary.model}`:a===`not-configured`?e?`可稍后按需配置`:`Set up later if needed`:e?`已配置的模型不可用`:`The configured model is unavailable`}),o?(0,$.jsxs)(`div`,{className:`mt-2 rounded-lg bg-amber-500/10 p-2`,children:[(0,$.jsx)(`p`,{className:`text-xs leading-5 text-amber-700 dark:text-amber-300`,children:n.status===`degraded`?e?`当前配置不可用,正在使用备用方案。${s.guidance}`:`The current configuration is unavailable, so a fallback is in use. ${s.guidance}.`:s.guidance}),(0,$.jsxs)(`span`,{className:`mt-1 inline-flex items-center gap-1 text-xs font-medium text-accent`,children:[s.action,(0,$.jsx)(le,{className:`size-3.5`,"aria-hidden":!0})]})]}):null]});return(0,$.jsx)(l,{to:o?s.href:pr(t),"aria-label":o?`${r}:${s.action}`:`${e?`配置`:`Configure`} ${r}`,className:O(`rounded-lg bg-surface-base/45 px-3 py-3 transition-colors`,o?`bg-amber-500/5 hover:bg-amber-500/10`:`hover:bg-surface-hover/30`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`),children:c},t)})}):null]}),p.length>0?(0,$.jsx)(`div`,{className:`mt-3 space-y-2`,"aria-live":`polite`,children:p.map(t=>(0,$.jsx)(`div`,{className:`rounded-lg border border-amber-500/25 bg-amber-500/5 p-3`,children:(()=>{let n=!!v[t.ref.split(`/`)[0]??``],r=dr(t.locations[0]??``,e);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(Ge,{className:`mt-0.5 size-4 shrink-0 text-amber-500`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`p`,{className:`break-words text-sm font-medium text-fg`,children:[t.ref,(0,$.jsx)(`span`,{className:`ml-2 font-normal text-amber-700 dark:text-amber-300`,children:n?e?`暂时无法验证`:`Temporarily unverified`:e?`不可用`:`Unavailable`})]}),(0,$.jsxs)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:[n?e?`模型目录同步暂时失败,当前状态可能已过期;不会影响其他可用模型。`:`Catalog sync temporarily failed, so this status may be stale. Other available models are unaffected.`:e?`此模型已无法从当前配置中解析,使用它的功能可能失败。`:`This model no longer resolves from the current configuration. Features using it may fail.`,x?` · ${e?`最近检测`:`Last checked`} ${new Date(x).toLocaleString()}`:``]}),t.suggestedRef?(0,$.jsxs)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[e?`可替换为`:`Suggested replacement`,`:`,(0,$.jsx)(`span`,{className:`font-medium text-fg`,children:t.suggestedRef})]}):null]})]}),(0,$.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1`,children:[(0,$.jsxs)(V,{className:`px-2.5 py-1.5 text-xs`,variant:`ghost`,disabled:a,onClick:()=>void T(),children:[a?(0,$.jsx)(b,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(Me,{className:`size-3.5`,"aria-hidden":!0}),a?e?`检测中…`:`Checking…`:e?`重新检测`:`Check again`]}),(0,$.jsx)(V,{asChild:!0,className:`px-2.5 py-1.5 text-xs`,variant:`ghost`,children:(0,$.jsxs)(l,{to:r.href,children:[(0,$.jsx)($e,{className:`size-3.5`,"aria-hidden":!0}),t.suggestedRef?e?`更换模型`:`Replace model`:e?`调整配置`:`Adjust configuration`]})}),(0,$.jsxs)(`details`,{className:`group/references`,children:[(0,$.jsxs)(`summary`,{className:`touch-target inline-flex cursor-pointer list-none items-center gap-1 rounded-xl px-2.5 py-1.5 text-xs font-medium text-fg-muted hover:bg-surface-hover hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[e?`查看 ${t.locations.length} 处引用`:`View ${t.locations.length} ${t.locations.length===1?`reference`:`references`}`,(0,$.jsx)(u,{className:`size-3.5 transition-transform group-open/references:rotate-90 motion-reduce:transition-none`,"aria-hidden":!0})]}),(0,$.jsx)(`ul`,{className:`mt-1 space-y-1 pl-2 text-xs text-fg-muted`,children:t.locations.map(t=>{let n=dr(t,e);return(0,$.jsx)(`li`,{children:(0,$.jsx)(l,{className:`inline-flex rounded px-1.5 py-1 text-accent hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,to:n.href,title:t,children:n.label})},t)})})]})]})]})})()},t.ref))}):null,_||s?(0,$.jsx)(`p`,{className:`mt-3 text-sm text-danger`,role:`alert`,children:_?e?`暂时无法读取模型状态,请重新检测;详细信息可在高级诊断中查看。`:`Model status is temporarily unavailable. Check again; details are available in Advanced diagnostics.`:e?`重新检测失败,请稍后重试;详细信息可在高级诊断中查看。`:`The check failed. Try again later; details are available in Advanced diagnostics.`}):null,(0,$.jsxs)(`details`,{className:`mt-4 border-t border-edge-subtle pt-3`,children:[(0,$.jsx)(`summary`,{className:`min-h-8 cursor-pointer rounded-md py-1.5 text-xs font-medium text-fg-muted hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:e?`高级诊断`:`Advanced diagnostics`}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 text-xs text-fg-muted`,children:[(0,$.jsx)(`p`,{children:e?`${d.length} 个来源,${f} 个可用模型${g?` · 最近同步 ${new Date(g).toLocaleString()}`:``}`:`${d.length} sources, ${f} available models${g?` · Last synced ${new Date(g).toLocaleString()}`:``}`}),y.length>0?(0,$.jsx)(`div`,{className:`mt-2 space-y-1 rounded-lg bg-surface-base/45 p-2 font-mono text-[11px] leading-5`,"aria-label":e?`同步错误详情`:`Sync error details`,children:y.map(([e,t],n)=>(0,$.jsxs)(`p`,{className:`break-words`,children:[e,`: `,t]},`${e}-${n}`))}):null]}),(0,$.jsxs)(V,{className:`shrink-0`,type:`button`,variant:`secondary`,disabled:a,onClick:()=>void T(),children:[a?(0,$.jsx)(b,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(Me,{className:`size-4`,"aria-hidden":!0}),a?e?`刷新中…`:`Refreshing…`:e?`刷新目录`:`Refresh catalog`]})]})]})]})}function _r(e){return Qe.includes(e)}function vr(){let e=(0,zt.c)(69),t=M(xr),n;e[0]===t?n=e[1]:(n=D(t),e[0]=t,e[1]=n);let r=n,i=r.capabilitiesSettings,u=a(),[d,f]=o(),p;if(e[2]!==d){let t=d.get(`returnTo`);p=t?.startsWith(`/chat/`)?t:null,e[2]=d,e[3]=p}else p=e[3];let m=p,{capability:h}=s(),[g,_]=(0,Q.useState)(!1),[v,y]=(0,Q.useState)(null),b=Re(),x;e[4]===b.cards?x=e[5]:(x=b.cards.some(br),e[4]=b.cards,e[5]=x);let S=x,C,w;e[6]!==h||e[7]!==d||e[8]!==f?(C=()=>{if(h!==`models`||d.get(`add`)!==`1`)return;_(!0);let e=new URLSearchParams(d);e.delete(`add`),f(e,{replace:!0})},w=[h,d,f],e[6]=h,e[7]=d,e[8]=f,e[9]=C,e[10]=w):(C=e[9],w=e[10]),(0,Q.useEffect)(C,w);let T;e[11]===i.tabs.models?T=e[12]:(T={id:`models`,icon:Pe,label:i.tabs.models},e[11]=i.tabs.models,e[12]=T);let E;e[13]===i.tabs.image?E=e[14]:(E={id:`image`,icon:dt,label:i.tabs.image},e[13]=i.tabs.image,e[14]=E);let O;e[15]!==T||e[16]!==E?(O=[T,E],e[15]=T,e[16]=E,e[17]=O):O=e[17];let k=O,A;e[18]===u?A=e[19]:(A=e=>u(et(e)),e[18]=u,e[19]=A);let j=A,N=yr;if(!_r(h)){let t;return e[20]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(c,{to:et(`models`),replace:!0}),e[20]=t):t=e[20],t}let P=h===`models`||h===`image`,F=h===`voice`?r.nav.settingsVoice:h===`search`?r.nav.settingsSearch:r.nav.settingsModels,I;e[21]===t?I=e[22]:(I=Je(t,`configuration`),e[21]=t,e[22]=I);let L;e[23]!==i.docsLink||e[24]!==F||e[25]!==I?(L=(0,$.jsx)(ht,{title:F,docsLink:I,docsLabel:i.docsLink}),e[23]=i.docsLink,e[24]=F,e[25]=I,e[26]=L):L=e[26];let R;e[27]!==h||e[28]!==m||e[29]!==t?(R=h===`voice`&&m?(0,$.jsx)(l,{to:m,className:`text-sm text-accent-fg hover:underline`,children:t===`zh`?`返回对话`:`Return to conversation`}):null,e[27]=h,e[28]=m,e[29]=t,e[30]=R):R=e[30];let ee;e[31]!==i.tabsAria||e[32]!==h||e[33]!==P||e[34]!==k||e[35]!==j?(ee=P?(0,$.jsx)(pt,{items:k,activeTab:h,onChange:j,ariaLabel:i.tabsAria,tabIdPrefix:`capability-tab`,panelIdPrefix:`capability-panel`}):null,e[31]=i.tabsAria,e[32]=h,e[33]=P,e[34]=k,e[35]=j,e[36]=ee):ee=e[36];let z=P?`tabpanel`:void 0,B=`capability-panel-${h}`,V=P?`capability-tab-${h}`:void 0,te;e[37]!==i.connectedProviders||e[38]!==i.xopcCloudAccount||e[39]!==h||e[40]!==b||e[41]!==S?(te=h===`models`?(0,$.jsxs)($.Fragment,{children:[S?(0,$.jsx)(Rt,{labels:i.xopcCloudAccount}):null,(0,$.jsx)(Ke,{labels:i.connectedProviders,data:b,onAdd:()=>_(!0),onManage:(e,t)=>y({providerId:e,isCustom:t})}),b.cards.length>0?(0,$.jsx)(gr,{}):null]}):(0,$.jsx)(Sr,{section:h}),e[37]=i.connectedProviders,e[38]=i.xopcCloudAccount,e[39]=h,e[40]=b,e[41]=S,e[42]=te):te=e[42];let ne;e[43]!==z||e[44]!==B||e[45]!==V||e[46]!==te?(ne=(0,$.jsx)(`div`,{role:z,id:B,"aria-labelledby":V,className:`flex min-w-0 flex-col gap-4`,children:te}),e[43]=z,e[44]=B,e[45]=V,e[46]=te,e[47]=ne):ne=e[47];let re;e[48]===Symbol.for(`react.memo_cache_sentinel`)?(re=()=>N(),e[48]=re):re=e[48];let H;e[49]!==g||e[50]!==i.addProviderDialog||e[51]!==t||e[52]!==b.builtinRows||e[53]!==b.customConfig?(H=(0,$.jsx)(at,{open:g,onOpenChange:_,builtinRows:b.builtinRows,customConfig:b.customConfig,labels:i.addProviderDialog,language:t,onSaved:re}),e[49]=g,e[50]=i.addProviderDialog,e[51]=t,e[52]=b.builtinRows,e[53]=b.customConfig,e[54]=H):H=e[54];let U;e[55]!==i.manageProviderDialog||e[56]!==t||e[57]!==v||e[58]!==b.allModels||e[59]!==b.builtinRows||e[60]!==b.customConfig?(U=v?(0,$.jsx)(sr,{open:!0,onOpenChange:e=>{e||y(null)},providerId:v.providerId,isCustom:v.isCustom,builtinRows:b.builtinRows,customConfig:b.customConfig,allModels:b.allModels,labels:i.manageProviderDialog,language:t,onSaved:N}):null,e[55]=i.manageProviderDialog,e[56]=t,e[57]=v,e[58]=b.allModels,e[59]=b.builtinRows,e[60]=b.customConfig,e[61]=U):U=e[61];let ie;return e[62]!==L||e[63]!==R||e[64]!==ee||e[65]!==ne||e[66]!==H||e[67]!==U?(ie=(0,$.jsxs)(gt,{children:[L,R,ee,ne,H,U]}),e[62]=L,e[63]=R,e[64]=ee,e[65]=ne,e[66]=H,e[67]=U,e[68]=ie):ie=e[68],ie}function yr(){se()}function br(e){return e.id===`xopc-cloud`&&!e.isCustom}function xr(e){return e.language}function Sr(e){let t=(0,zt.c)(3),{section:n}=e;switch(n){case`models`:return null;case`image`:{let e;return t[0]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(tn,{}),t[0]=e):e=t[0],e}case`voice`:{let e;return t[1]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(kn,{}),t[1]=e):e=t[1],e}case`search`:{let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Zn,{}),t[2]=e):e=t[2],e}}}export{vr as CapabilitiesSettingsPanel};
@@ -1 +0,0 @@
1
- import{i as e}from"./rolldown-runtime-aKtaBQYM.js";import{a as t,n,t as r}from"./vendor-react-BOUWij0V.js";import{f as i,g as a}from"./chunk-KS7C4IRE-BMYIfy9x.js";import{t as o}from"./chevron-right-BweFrslA.js";import{n as s,r as c,t as l}from"./popover-select-BgSdSbCL.js";import{t as u}from"./circle-alert-BEjgurr2.js";import{t as d}from"./circle-check-C23XjkUj.js";import{t as f}from"./clock-3-DnrAnuyZ.js";import{t as p}from"./ellipsis-0k4rZLoy.js";import{t as m}from"./external-link-DjqjBmc3.js";import{t as h}from"./loader-circle-CifKLtgG.js";import{t as g}from"./plus-Q2yW6OE7.js";import{t as _}from"./x-B_N4OPjy.js";import{t as v}from"./messages-BpEhZm54.js";import{t as y}from"./cn-JdwAhgNB.js";import{a as b,c as x,n as S,r as C}from"./locale-store-CeoW7A5a.js";import{a as w,i as T,n as E,o as D,r as O,s as k,t as A}from"./dist-BGTk37IG.js";import{r as j}from"./extension-provider-DB4M3dc8.js";import{n as M}from"./copy-to-clipboard-HOJ79TWv.js";import{t as N}from"./button-CS04eWY9.js";import{n as P}from"./interaction-BdhHBbYa.js";import{n as F,r as I}from"./gateway-config-swr-ArYo4YFd.js";import{s as L}from"./form-field-width-DJw_jULe.js";import{t as R}from"./skeleton-BwbyijEw.js";import{n as z}from"./electron-env-Dit0bHgy.js";import{$ as B,$a as V,Aa as H,An as U,Bn as W,Ca as G,Da as K,Ea as q,Fa as J,Fn as ee,Fs as te,Ga as ne,Ha as re,Ho as ie,Ia as ae,In as oe,J as se,Ja as ce,Ka as le,La as ue,Ln as Y,Mn as de,Na as fe,Oa as pe,Pa as me,Q as he,Qa as ge,Ra as _e,Rn as ve,Ro as X,Sa as ye,Ta as be,Tc as xe,Va as Se,Wa as Ce,Wo as we,X as Te,Xa as Ee,Y as De,Ya as Oe,Z,Za as ke,_o as Ae,cc as je,eo as Me,ja as Ne,jn as Pe,ka as Fe,kn as Ie,oo as Le,q as Re,qa as ze,ss as Be,ta as Ve,ui as He,vc as Ue,wa as We,wo as Ge,za as Ke,zo as qe}from"./index-B3BVcMQj.js";import{n as Je,t as Ye}from"./capability-header-actions-XMz78V4c.js";import{t as Xe}from"./connector-service-page-Cne5MBuz.js";import{t as Ze}from"./page-tabs-D2xpUV26.js";import{n as Qe}from"./agent-plugin-dialog-CxZeGEuL.js";import{t as $e}from"./number-input-DDeqHK-G.js";var Q=e(t(),1),et=n(),$=r();function tt(e){let t=(0,et.c)(57),{connector:n,installed:r,onInstall:i,onOpenDetails:a,t:o}=e,s,c,l,u,f,p;if(t[0]!==n||t[1]!==r||t[2]!==i||t[3]!==a||t[4]!==o){let e=n.capabilities.filter(nt),m=e.slice(0,2),h=Math.max(0,e.length-m.length),g=o.connect,_;t[11]!==n||t[12]!==o?(_=Te(n,o),t[11]=n,t[12]=o,t[13]=_):_=t[13];let v=_,b=n.verificationLevel===`verified`?o.connectorVerified:n.verificationLevel===`beta`?o.connectorBeta:n.verificationLevel===`experimental`?o.connectorExperimental:null,x;t[14]!==g||t[15]!==n||t[16]!==i?(x=e=>(0,$.jsxs)(N,{type:`button`,variant:`primary`,className:y(`h-8 justify-center px-2.5 text-xs font-medium`,e),onClick:()=>i(n),children:[(0,$.jsx)(Be,{className:`size-4`}),g]}),t[14]=g,t[15]=n,t[16]=i,t[17]=x):x=t[17],s=x,p=`group flex min-h-[8.75rem] flex-col rounded-xl border border-edge bg-surface-panel p-4 transition-colors hover:bg-surface-hover/45 focus-within:ring-2 focus-within:ring-accent/30`,c=`flex min-w-0 flex-1 flex-col`;let S;t[18]===n?S=t[19]:(S=(0,$.jsx)(B,{connector:n}),t[18]=n,t[19]=S);let C;t[20]!==n||t[21]!==a?(C=a?(0,$.jsx)(`button`,{type:`button`,className:`block max-w-full truncate text-left text-sm font-semibold text-fg hover:underline`,onClick:()=>a(n),children:n.displayName}):(0,$.jsx)(`h3`,{className:`truncate text-sm font-semibold text-fg`,children:n.displayName}),t[20]=n,t[21]=a,t[22]=C):C=t[22];let w;t[23]===b?w=t[24]:(w=b?(0,$.jsx)(`span`,{className:`mt-1 inline-flex rounded-full border border-edge px-1.5 py-0.5 text-[10px] font-medium text-fg-subtle`,children:b}):null,t[23]=b,t[24]=w);let T;t[25]!==w||t[26]!==C?(T=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[C,w]}),t[25]=w,t[26]=C,t[27]=T):T=t[27];let E;t[28]!==T||t[29]!==S?(E=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[S,T]}),t[28]=T,t[29]=S,t[30]=E):E=t[30];let D;t[31]!==r||t[32]!==s?(D=r?null:(0,$.jsx)(`div`,{className:`hidden shrink-0 items-center gap-1 sm:flex`,children:s()}),t[31]=r,t[32]=s,t[33]=D):D=t[33];let O;t[34]!==r||t[35]!==o.connectedBadge?(O=r?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-emerald-500/30 bg-emerald-500/10 px-2 py-0.5 text-[11px] font-medium text-emerald-700 dark:text-emerald-300`,children:[(0,$.jsx)(d,{className:`size-3`,"aria-hidden":!0}),o.connectedBadge]}):null,t[34]=r,t[35]=o.connectedBadge,t[36]=O):O=t[36];let k;t[37]!==D||t[38]!==O?(k=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start gap-2`,children:[D,O]}),t[37]=D,t[38]=O,t[39]=k):k=t[39],t[40]!==E||t[41]!==k?(l=(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[E,k]}),t[40]=E,t[41]=k,t[42]=l):l=t[42],t[43]===v?u=t[44]:(u=(0,$.jsx)(`p`,{className:`mt-3 line-clamp-2 text-sm leading-6 text-fg-muted`,title:v,children:v}),t[43]=v,t[44]=u),f=m.length>0?(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-1.5`,children:[m.map(e=>(0,$.jsx)(`span`,{className:`rounded-md bg-surface-base px-2 py-0.5 text-[11px] text-fg-muted`,children:o.connectorCapabilityLabels[e]??e},e)),h>0?(0,$.jsxs)(`span`,{className:`rounded-md bg-surface-base px-2 py-0.5 text-[11px] text-fg-subtle`,children:[`+`,h]}):null]}):null,t[0]=n,t[1]=r,t[2]=i,t[3]=a,t[4]=o,t[5]=s,t[6]=c,t[7]=l,t[8]=u,t[9]=f,t[10]=p}else s=t[5],c=t[6],l=t[7],u=t[8],f=t[9],p=t[10];let m;t[45]!==c||t[46]!==l||t[47]!==u||t[48]!==f?(m=(0,$.jsxs)(`div`,{className:c,children:[l,u,f]}),t[45]=c,t[46]=l,t[47]=u,t[48]=f,t[49]=m):m=t[49];let h;t[50]!==r||t[51]!==s?(h=r?null:(0,$.jsx)(`div`,{className:`mt-4 flex flex-col gap-2 border-t border-edge pt-3 sm:hidden`,children:s(`w-full`)}),t[50]=r,t[51]=s,t[52]=h):h=t[52];let g;return t[53]!==p||t[54]!==m||t[55]!==h?(g=(0,$.jsxs)(`div`,{className:p,children:[m,h]}),t[53]=p,t[54]=m,t[55]=h,t[56]=g):g=t[56],g}function nt(e){return!e.startsWith(`runtime.`)&&!e.startsWith(`auth.`)}var rt=[`c0`,`c1`,`c2`,`c3`,`c4`,`c5`];function it(e,t){return t.some(t=>t.connectorId===e.id)}var at=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`;function ot(){let e=(0,et.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`div`,{className:y(`size-10 shrink-0 rounded-xl`,at)}),e[0]=t):t=e[0];let n;return e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsx)(`div`,{className:`flex h-full min-h-[9.5rem] flex-col rounded-xl bg-surface-panel p-4 shadow-surface`,"aria-hidden":!0,children:(0,$.jsxs)(`div`,{className:`flex min-h-0 flex-1 items-start gap-3`,children:[t,(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,$.jsx)(`div`,{className:y(`h-4 min-w-0 flex-1`,at)}),(0,$.jsx)(`div`,{className:y(`h-8 w-[4.5rem] shrink-0 rounded-lg`,at)})]}),(0,$.jsx)(`div`,{className:y(`h-3 w-full`,at)}),(0,$.jsx)(`div`,{className:y(`h-3 w-[88%]`,at)})]})]})}),e[1]=n):n=e[1],n}var st=`animate-pulse motion-reduce:animate-none rounded-md bg-surface-hover dark:bg-surface-active/50`;function ct(){let e=(0,et.c)(4),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(`div`,{className:y(`size-10 shrink-0 rounded-xl`,st)}),e[0]=t):t=e[0];let n;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(n=(0,$.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2`,children:[(0,$.jsx)(`div`,{className:y(`h-4 w-48 max-w-full`,st)}),(0,$.jsx)(`div`,{className:y(`h-3 w-72 max-w-full`,st)})]}),e[1]=n):n=e[1];let r;e[2]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[t,(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-start justify-between gap-3`,children:[n,(0,$.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,$.jsx)(`div`,{className:y(`h-9 w-20 rounded-lg`,st)}),(0,$.jsx)(`div`,{className:y(`h-9 w-20 rounded-lg`,st)})]})]})]}),e[2]=r):r=e[2];let i;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,$.jsxs)(`div`,{className:`rounded-2xl bg-surface-panel p-4 shadow-surface`,"aria-hidden":!0,children:[r,(0,$.jsxs)(`div`,{className:`mt-4 flex flex-wrap gap-2`,children:[(0,$.jsx)(`div`,{className:y(`h-8 w-20 rounded-md`,st)}),(0,$.jsx)(`div`,{className:y(`h-8 w-24 rounded-md`,st)}),(0,$.jsx)(`div`,{className:y(`h-8 w-28 rounded-md`,st)})]}),(0,$.jsx)(`div`,{className:y(`mt-3 h-20 rounded-xl`,st)})]}),e[3]=i):i=e[3],i}var lt=[`understand`,`act`,`reach`];function ut(e){if(e.benefits?.length)return[...new Set(e.benefits)];let t=new Set(e.capabilities),n=[e.id,e.displayName,...e.tags??[]].join(` `).toLowerCase(),r=[];return(t.has(`context`)||t.has(`memory_source`)||t.has(`resources`)||e.category===`docs`||e.category===`data`||/notion|drive|document|confluence|airtable|database|knowledge|wiki/.test(n))&&r.push(`understand`),t.has(`tools`)&&r.push(`act`),(t.has(`channel`)||/slack|telegram|discord|teams|mail|message|wechat|weixin/.test(n))&&r.push(`reach`),r.length?[...new Set(r)]:[`act`]}function dt(e){return ut(e)[0]??`act`}function ft(e,t){let n=t?dt(t):`act`,r=e.connectionStatus===`connected`||e.status===`connected`||e.usage.lastHealthStatus===`ok`,i=e.status===`not_configured`||e.status===`failed`||e.status===`degraded`||e.status===`unauthorized`||e.connectionStatus===`unauthorized`||e.connectionStatus===`error`,a=n===`understand`?e.usage.lastResourceCount:n===`act`?e.usage.lastToolCount:void 0;return{benefit:n,state:r?`ready`:i?`needs_setup`:`checking`,availableCount:a}}function pt(e,t){return t.connectorCapabilityLabels[e]??e}function mt(e,t){if(e.runtime.type===`mcp`)return Z(t.connectorRuntimeMcp,{serverId:e.runtime.serverId});let n=e.runtime.type===`composio`?e.runtime.toolkit:e.runtime.type===`cli`?e.runtime.adapterId:e.runtime.sourceKind;return Z(t.connectorRuntimeGeneric,{runtime:e.runtime.type,id:n??e.runtime.type})}function ht(e,t){return e.auth.mode===`cli`?t.connectorAuthCli:e.auth.mode===`oauth`?t.connectorAuthOAuth:e.auth.mode===`apiKey`?t.connectorAuthApiKey:t.connectorAuthNone}function gt(e){let t=(0,et.c)(133),{connector:n,installed:r,onClose:i,onInstall:a,t:o}=e,s;t[0]!==n||t[1]!==o?(s=Te(n,o),t[0]=n,t[1]=o,t[2]=s):s=t[2];let c=s,l,u,f,p,m,h,g,v,b,x,S,C,j,M,F,I;if(t[3]!==n||t[4]!==c||t[5]!==r||t[6]!==i||t[7]!==o){let e=ut(n),a;t[24]!==n.setup.config||t[25]!==n.setup.secrets?(a=[...(n.setup.secrets??[]).filter(yt),...(n.setup.config??[]).filter(vt)],t[24]=n.setup.config,t[25]=n.setup.secrets,t[26]=a):a=t[26];let s=a,N=n.capabilities.filter(_t);f=A,g=!0,t[27]===i?v=t[28]:(v=e=>{e||i()},t[27]=i,t[28]=v),u=D,t[29]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,$.jsx)(w,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),t[29]=h):h=t[29],l=O,t[30]===Symbol.for(`react.memo_cache_sentinel`)?(p=y(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex h-[min(100vh-2rem,42rem)] w-[min(100%-2rem,min(92vw,44rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,`rounded-2xl border border-edge bg-surface-overlay shadow-float outline-none dark:border-edge`),t[30]=p):p=t[30];let L;t[31]===n?L=t[32]:(L=(0,$.jsx)(B,{connector:n,size:`lg`}),t[31]=n,t[32]=L);let R;t[33]===n.displayName?R=t[34]:(R=(0,$.jsx)(k,{className:`text-base font-semibold text-fg`,children:n.displayName}),t[33]=n.displayName,t[34]=R);let z;t[35]!==r||t[36]!==o.connectedBadge?(z=r?(0,$.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full bg-emerald-500/10 px-2 py-0.5 text-[11px] font-medium text-emerald-700 dark:text-emerald-300`,children:[(0,$.jsx)(d,{className:`size-3`,"aria-hidden":!0}),o.connectedBadge]}):null,t[35]=r,t[36]=o.connectedBadge,t[37]=z):z=t[37];let V;t[38]!==R||t[39]!==z?(V=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[R,z]}),t[38]=R,t[39]=z,t[40]=V):V=t[40];let H;t[41]===c?H=t[42]:(H=(0,$.jsx)(T,{className:`mt-1 line-clamp-3 text-sm leading-6 text-fg-muted`,children:c}),t[41]=c,t[42]=H);let U;t[43]!==V||t[44]!==H?(U=(0,$.jsxs)(`div`,{className:`min-w-0`,children:[V,H]}),t[43]=V,t[44]=H,t[45]=U):U=t[45];let W;t[46]!==L||t[47]!==U?(W=(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[L,U]}),t[46]=L,t[47]=U,t[48]=W):W=t[48];let G;t[49]===Symbol.for(`react.memo_cache_sentinel`)?(G=y(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,P.focusRingPanel),t[49]=G):G=t[49];let K;t[50]===Symbol.for(`react.memo_cache_sentinel`)?(K=(0,$.jsx)(_,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),t[50]=K):K=t[50];let q;t[51]===o.modalClose?q=t[52]:(q=(0,$.jsx)(E,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:G,"aria-label":o.modalClose,children:K})}),t[51]=o.modalClose,t[52]=q),t[53]!==W||t[54]!==q?(m=(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-5 py-5 sm:px-6`,children:[W,q]}),t[53]=W,t[54]=q,t[55]=m):m=t[55],M=`min-h-0 flex-1 space-y-5 overflow-y-auto px-5 py-5 sm:px-6`,F=e.length?(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:o.connectorWhyConnect}),(0,$.jsx)(`div`,{className:`mt-3 divide-y divide-edge-subtle overflow-hidden rounded-xl border border-edge bg-surface-base`,children:e.map(e=>(0,$.jsxs)(`div`,{className:`px-4 py-3`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:o.connectorBenefitHeadings[e]}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:o.connectorBenefitHints[e]})]},e))})]}):null;let J;t[56]===Symbol.for(`react.memo_cache_sentinel`)?(J=(0,$.jsx)(te,{className:`mt-0.5 size-4 shrink-0 text-fg-muted`,"aria-hidden":!0}),t[56]=J):J=t[56];let ee;t[57]===o.detailPermissions?ee=t[58]:(ee=(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:o.detailPermissions}),t[57]=o.detailPermissions,t[58]=ee);let ne;t[59]!==n||t[60]!==o?(ne=ht(n,o),t[59]=n,t[60]=o,t[61]=ne):ne=t[61];let re;t[62]===ne?re=t[63]:(re=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:ne}),t[62]=ne,t[63]=re);let ie;t[64]!==ee||t[65]!==re?(ie=(0,$.jsxs)(`div`,{className:`flex items-start gap-3 border-b border-edge-subtle px-4 py-3`,children:[J,(0,$.jsxs)(`div`,{children:[ee,re]})]}),t[64]=ee,t[65]=re,t[66]=ie):ie=t[66];let ae;t[67]===o.connectorSetupTitle?ae=t[68]:(ae=(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:o.connectorSetupTitle}),t[67]=o.connectorSetupTitle,t[68]=ae);let oe;t[69]!==s.length||t[70]!==o.connectorRequiredInputsCount||t[71]!==o.connectorSetupNone?(oe=s.length?Z(o.connectorRequiredInputsCount,{count:String(s.length)}):o.connectorSetupNone,t[69]=s.length,t[70]=o.connectorRequiredInputsCount,t[71]=o.connectorSetupNone,t[72]=oe):oe=t[72];let se;t[73]===oe?se=t[74]:(se=(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:oe}),t[73]=oe,t[74]=se);let ce;t[75]!==ae||t[76]!==se?(ce=(0,$.jsxs)(`div`,{className:`px-4 py-3`,children:[ae,se]}),t[75]=ae,t[76]=se,t[77]=ce):ce=t[77],t[78]!==ie||t[79]!==ce?(I=(0,$.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-base`,children:[ie,ce]}),t[78]=ie,t[79]=ce,t[80]=I):I=t[80],C=`rounded-xl border border-edge bg-surface-base`,t[81]===o.connectorTechnicalDetails?j=t[82]:(j=(0,$.jsx)(`summary`,{className:`cursor-pointer px-4 py-3 text-sm font-medium text-fg-muted hover:text-fg`,children:o.connectorTechnicalDetails}),t[81]=o.connectorTechnicalDetails,t[82]=j),b=`space-y-5 border-t border-edge-subtle px-4 py-4`;let le;t[83]===Symbol.for(`react.memo_cache_sentinel`)?(le=(0,$.jsx)(qe,{className:`size-3.5`,"aria-hidden":!0}),t[83]=le):le=t[83];let ue;t[84]===o.connectorRuntimeTitle?ue=t[85]:(ue=(0,$.jsxs)(`p`,{className:`flex items-center gap-2 text-xs font-medium text-fg-muted`,children:[le,o.connectorRuntimeTitle]}),t[84]=o.connectorRuntimeTitle,t[85]=ue);let Y;t[86]!==n||t[87]!==o?(Y=mt(n,o),t[86]=n,t[87]=o,t[88]=Y):Y=t[88];let de;t[89]===Y?de=t[90]:(de=(0,$.jsx)(`p`,{className:`mt-1 break-words text-xs text-fg-subtle`,children:Y}),t[89]=Y,t[90]=de),t[91]!==ue||t[92]!==de?(x=(0,$.jsxs)(`div`,{children:[ue,de]}),t[91]=ue,t[92]=de,t[93]=x):x=t[93],S=N.length?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:N.map(e=>(0,$.jsx)(`span`,{className:`rounded-md bg-surface-panel px-2 py-1 text-xs text-fg-muted`,children:pt(e,o)},e))}):null,t[3]=n,t[4]=c,t[5]=r,t[6]=i,t[7]=o,t[8]=l,t[9]=u,t[10]=f,t[11]=p,t[12]=m,t[13]=h,t[14]=g,t[15]=v,t[16]=b,t[17]=x,t[18]=S,t[19]=C,t[20]=j,t[21]=M,t[22]=F,t[23]=I}else l=t[8],u=t[9],f=t[10],p=t[11],m=t[12],h=t[13],g=t[14],v=t[15],b=t[16],x=t[17],S=t[18],C=t[19],j=t[20],M=t[21],F=t[22],I=t[23];let L;t[94]!==b||t[95]!==x||t[96]!==S?(L=(0,$.jsxs)(`div`,{className:b,children:[x,S]}),t[94]=b,t[95]=x,t[96]=S,t[97]=L):L=t[97];let R;t[98]!==L||t[99]!==C||t[100]!==j?(R=(0,$.jsxs)(`details`,{className:C,children:[j,L]}),t[98]=L,t[99]=C,t[100]=j,t[101]=R):R=t[101];let z;t[102]!==R||t[103]!==M||t[104]!==F||t[105]!==I?(z=(0,$.jsxs)(`div`,{className:M,children:[F,I,R]}),t[102]=R,t[103]=M,t[104]=F,t[105]=I,t[106]=z):z=t[106];let V;t[107]===o.modalClose?V=t[108]:(V=(0,$.jsx)(E,{asChild:!0,children:(0,$.jsx)(N,{variant:`secondary`,children:o.modalClose})}),t[107]=o.modalClose,t[108]=V);let H;t[109]!==n||t[110]!==r||t[111]!==i||t[112]!==a||t[113]!==o.connect?(H=r?null:(0,$.jsxs)(N,{variant:`primary`,onClick:()=>{a(n),i()},children:[(0,$.jsx)(Be,{className:`size-4`}),o.connect]}),t[109]=n,t[110]=r,t[111]=i,t[112]=a,t[113]=o.connect,t[114]=H):H=t[114];let U;t[115]!==V||t[116]!==H?(U=(0,$.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge-subtle px-5 py-4 sm:px-6`,children:[V,H]}),t[115]=V,t[116]=H,t[117]=U):U=t[117];let W;t[118]!==l||t[119]!==p||t[120]!==m||t[121]!==z||t[122]!==U?(W=(0,$.jsxs)(l,{className:p,children:[m,z,U]}),t[118]=l,t[119]=p,t[120]=m,t[121]=z,t[122]=U,t[123]=W):W=t[123];let G;t[124]!==u||t[125]!==h||t[126]!==W?(G=(0,$.jsxs)(u,{children:[h,W]}),t[124]=u,t[125]=h,t[126]=W,t[127]=G):G=t[127];let K;return t[128]!==f||t[129]!==g||t[130]!==v||t[131]!==G?(K=(0,$.jsx)(f,{open:g,onOpenChange:v,children:G}),t[128]=f,t[129]=g,t[130]=v,t[131]=G,t[132]=K):K=t[132],K}function _t(e){return!e.startsWith(`runtime.`)&&!e.startsWith(`auth.`)}function vt(e){return e.required}function yt(e){return e.required}var bt=(0,Q.memo)(function(e){let t=(0,et.c)(45),{onRefresh:n,refreshing:r,refreshLabel:i,onBrowseCatalog:a,onAddCustomServer:o,addLabel:s,browseLabel:c,customLabel:l,serviceLabel:u,moreActionsLabel:d}=e,[f,m]=(0,Q.useState)(!1),_;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(_=y(`touch-target flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 text-sm text-fg outline-none data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50 data-[highlighted]:bg-surface-hover`,P.transition),t[0]=_):_=t[0];let v=_,b;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(b=(0,$.jsx)(g,{className:`size-4`,strokeWidth:1.75,"aria-hidden":!0}),t[1]=b):b=t[1];let x;t[2]===s?x=t[3]:(x=(0,$.jsx)(`span`,{className:`hidden sm:inline`,children:s}),t[2]=s,t[3]=x);let S;t[4]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,$.jsx)(xe,{className:`size-3.5`,strokeWidth:1.75,"aria-hidden":!0}),t[4]=S):S=t[4];let C;t[5]!==s||t[6]!==x?(C=(0,$.jsx)(W,{asChild:!0,children:(0,$.jsxs)(N,{type:`button`,variant:`primary`,className:`shrink-0 gap-2`,"aria-label":s,children:[b,x,S]})}),t[5]=s,t[6]=x,t[7]=C):C=t[7];let w;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(Ge,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[8]=w):w=t[8];let T;t[9]!==c||t[10]!==a?(T=(0,$.jsxs)(oe,{className:v,onSelect:a,children:[w,c]}),t[9]=c,t[10]=a,t[11]=T):T=t[11];let E;t[12]===Symbol.for(`react.memo_cache_sentinel`)?(E=(0,$.jsx)(Le,{className:`size-4 text-fg-muted`,strokeWidth:1.75,"aria-hidden":!0}),t[12]=E):E=t[12];let D;t[13]!==l||t[14]!==o?(D=(0,$.jsxs)(oe,{className:v,onSelect:o,children:[E,l]}),t[13]=l,t[14]=o,t[15]=D):D=t[15];let O;t[16]!==T||t[17]!==D?(O=(0,$.jsx)(Y,{children:(0,$.jsxs)(ee,{className:`z-50 min-w-[14rem] rounded-xl border border-edge bg-surface-panel p-1 shadow-popover dark:border-edge`,sideOffset:6,align:`end`,children:[T,D]})}),t[16]=T,t[17]=D,t[18]=O):O=t[18];let k;t[19]!==O||t[20]!==C?(k=(0,$.jsxs)(ve,{children:[C,O]}),t[19]=O,t[20]=C,t[21]=k):k=t[21];let A;t[22]===f?A=t[23]:(A=(0,$.jsx)(Xe,{open:f,onOpenChange:m,hideTrigger:!0}),t[22]=f,t[23]=A);let j;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,$.jsx)(p,{className:`size-4`,"aria-hidden":!0}),t[24]=j):j=t[24];let M;t[25]===d?M=t[26]:(M=(0,$.jsx)(W,{asChild:!0,children:(0,$.jsx)(N,{type:`button`,variant:`secondary`,className:`size-9 shrink-0 p-0`,"aria-label":d,title:d,children:j})}),t[25]=d,t[26]=M);let F;t[27]!==n||t[28]!==i||t[29]!==r?(F=n?(0,$.jsxs)(oe,{className:v,disabled:r,onSelect:n,children:[r?(0,$.jsx)(h,{className:`size-4 animate-spin text-fg-muted`,"aria-hidden":!0}):(0,$.jsx)(we,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),i]}):null,t[27]=n,t[28]=i,t[29]=r,t[30]=F):F=t[30];let I,L;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(I=()=>m(!0),L=(0,$.jsx)(X,{className:`size-4 text-fg-muted`,"aria-hidden":!0}),t[31]=I,t[32]=L):(I=t[31],L=t[32]);let R;t[33]===u?R=t[34]:(R=(0,$.jsxs)(oe,{className:v,onSelect:I,children:[L,u]}),t[33]=u,t[34]=R);let z;t[35]!==F||t[36]!==R?(z=(0,$.jsx)(Y,{children:(0,$.jsxs)(ee,{className:`z-50 min-w-[14rem] rounded-xl border border-edge bg-surface-panel p-1 shadow-popover dark:border-edge`,sideOffset:6,align:`end`,children:[F,R]})}),t[35]=F,t[36]=R,t[37]=z):z=t[37];let B;t[38]!==M||t[39]!==z?(B=(0,$.jsxs)(ve,{children:[M,z]}),t[38]=M,t[39]=z,t[40]=B):B=t[40];let V;return t[41]!==k||t[42]!==A||t[43]!==B?(V=(0,$.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center justify-end gap-2`,children:[k,A,B]}),t[41]=k,t[42]=A,t[43]=B,t[44]=V):V=t[44],V});function xt(e=``,t=``){return{clientKey:crypto.randomUUID(),key:e,value:t}}var St=/^([^:=]+)[:=](.*)$/;function Ct(e){let t=e.trim();if(!t)return null;try{let e=JSON.parse(t);if(e&&typeof e==`object`&&!Array.isArray(e))return Object.entries(e).map(([e,t])=>xt(e,t==null?``:String(t)))}catch{}let n=[];for(let e of t.split(/\r?\n/)){let t=e.trim();if(!t)continue;let r=St.exec(t);r&&n.push(xt(r[1].trim(),r[2].trim()))}return n.length>0?n:null}function wt(e){let t={};for(let n of e){let e=n.key.trim();e&&(t[e]=n.value)}return Object.keys(t).length>0?t:void 0}function Tt(e){if(!e||typeof e!=`object`)return[xt()];let t=Object.entries(e).map(([e,t])=>xt(e,t==null?``:String(t)));return t.length>0?t:[xt()]}function Et(e){if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e.xopcConnector;return!!(t&&typeof t==`object`&&!Array.isArray(t)&&t.managed===!0)}function Dt(e){let t=e&&typeof e==`object`&&`mcp`in e?e.mcp:void 0,n=(t&&typeof t==`object`?t:{}).servers,r={};if(!n||typeof n!=`object`||Array.isArray(n))return r;for(let[e,t]of Object.entries(n))!t||typeof t!=`object`||Array.isArray(t)||Et(t)&&(r[e]=t);return r}function Ot(e){let t=e.trim();if(!t)return;if(t.startsWith(`[`)){let e=JSON.parse(t);if(!Array.isArray(e)||e.some(e=>typeof e!=`string`))throw Error(`Command arguments must be a JSON array of strings.`);return e}let n=[],r=``,i=``,a=!1;for(let e=0;e<t.length;e++){let o=t[e];o===`\\`&&t[e+1]&&i!==`'`?(r+=t[++e],a=!0):i?o===i?i=``:r+=o:o===`"`||o===`'`?(i=o,a=!0):/\s/.test(o)?a&&=(n.push(r),r=``,!1):(r+=o,a=!0)}if(i)throw Error(`Command arguments contain an unclosed quote.`);return a&&n.push(r),n}function kt(e){let t=e.trim();if(!t)return;let n=JSON.parse(t);if(!n||typeof n!=`object`||Array.isArray(n))throw Error(`Expected a JSON object`);return n}function At(e){let t={...e.extra,exposure:e.exposure};if(delete t.command,delete t.args,delete t.env,delete t.cwd,delete t.url,delete t.headers,delete t.type,e.transport===`stdio`){t.type=`stdio`,t.command=e.command.trim();let n=Ot(e.argsText);n&&(t.args=n),e.cwd.trim()&&(t.cwd=e.cwd.trim()),e.envJson.trim()&&(t.env=kt(e.envJson)),delete t.oauth}else{t.type=`http`,t.url=e.url.trim();let n=wt(e.headers);n&&(t.headers=n);let r={...t.oauth??{}};e.oauthClientId.trim()?r.clientId=e.oauthClientId.trim():delete r.clientId,Object.keys(r).length?t.oauth=r:delete t.oauth}return e.timeout===void 0?delete t.timeout:t.timeout=e.timeout,t}function jt(e,t){let n=t.oauth;return{clientKey:e,id:e,transport:typeof t.url==`string`?`streamable-http`:`stdio`,command:typeof t.command==`string`?t.command:``,argsText:Array.isArray(t.args)?JSON.stringify(t.args):``,envJson:t.env?JSON.stringify(t.env,null,2):``,cwd:typeof t.cwd==`string`?t.cwd:``,url:typeof t.url==`string`?t.url:``,headers:Tt(t.headers),oauthClientId:typeof n?.clientId==`string`?n.clientId:``,timeout:typeof t.timeout==`number`?t.timeout:void 0,exposure:t.exposure??`codemode`,extra:t}}function Mt(e,t){let n=`mcp`;try{n=e.transport===`streamable-http`?new URL(e.url).hostname:e.command.split(/[\\/]/).pop()||n}catch{}let r=n.replace(/[^a-zA-Z0-9_-]+/g,`_`).replace(/^_+|_+$/g,``)||`mcp`,i=new Set([...t].map(e=>e.replace(/-/g,`_`))),a=r;for(let e=2;i.has(a.replace(/-/g,`_`));e++)a=`${r}_${e}`;return a}function Nt(e){let t=e.trim(),n=new URL(/^[a-z][a-z\d+.-]*:/i.test(t)&&!/^[^/]+:\d+(?:[/?#]|$)/.test(t)?t:`${/^(localhost|127\.0\.0\.1)(:|\/|$)/i.test(t)?`http`:`https`}://${t}`);if(![`http:`,`https:`].includes(n.protocol)||n.username||n.password)throw Error(`Use an HTTP or HTTPS MCP address without embedded credentials.`);return n.href}function Pt(e){let t=JSON.parse(e);if(!t||typeof t!=`object`||Array.isArray(t))throw Error(`Expected a JSON object.`);let n=t.mcpServers??t.mcp?.servers??t.servers,r=n?Object.entries(n):[[``,t]];if(!r.length)throw Error(`No MCP servers found.`);return r.map(([e,t])=>{if(!t||typeof t!=`object`||Array.isArray(t))throw Error(`Invalid MCP server configuration.`);let n=t;if(typeof n.url!=`string`&&typeof n.command!=`string`)throw Error(`The configuration needs an MCP URL or command.`);if(n.args!==void 0&&(!Array.isArray(n.args)||n.args.some(e=>typeof e!=`string`)))throw Error(`Command arguments must be strings.`);let r=jt(e,n);return r.clientKey=crypto.randomUUID(),r.url&&=Nt(r.url),r})}function Ft(e=``){return{clientKey:crypto.randomUUID(),id:e,transport:`streamable-http`,command:``,argsText:``,envJson:``,cwd:``,url:``,headers:[],oauthClientId:``,timeout:void 0,exposure:`codemode`,extra:{}}}function It(e){let t=e?.mcp?.servers??{};return{servers:Object.entries(t).filter(([,e])=>!Et(e)).map(([e,t])=>jt(e,t)).sort((e,t)=>e.id.localeCompare(t.id))}}async function Lt(e,t={}){let n={...t};for(let r of e.servers){let e=r.id.trim();if(!/^[a-zA-Z0-9_-]+$/.test(e))throw Error(`MCP IDs require letters, digits, underscores or hyphens.`);if(t[e])throw Error(`Server id "${e}" is reserved by an installed connector.`);n[e]=At(r)}await b(C(`/api/config`),{method:`PATCH`,body:JSON.stringify({mcp:{servers:n}})}),F()}async function Rt(e,t){return(await b(C(`/api/mcp/servers/${encodeURIComponent(e)}/tools`),{method:`POST`,signal:AbortSignal.any([t,AbortSignal.timeout(95e3)])})).payload.tools}async function zt(e,t){return(await b(C(`/api/mcp/servers/${encodeURIComponent(e)}/probe`),{method:`POST`,signal:AbortSignal.any([t,AbortSignal.timeout(95e3)])})).payload}async function Bt(e){return(await b(C(`/api/mcp/servers/${encodeURIComponent(e)}/auth`),{method:`POST`})).payload}async function Vt(e,t){return(await b(C(`/api/mcp/auth/${encodeURIComponent(e)}`),{signal:t})).payload}async function Ht(e){await b(C(`/api/mcp/auth/${encodeURIComponent(e)}`),{method:`DELETE`})}async function Ut(e,t){await b(C(`/api/mcp/auth/${encodeURIComponent(e)}/redirect`),{method:`POST`,body:JSON.stringify({url:t})})}function Wt(e){let t=(0,et.c)(88),{serverId:n,t:r,onClose:i,onConfigure:a}=e,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o=[],t[0]=o):o=t[0];let[s,c]=(0,Q.useState)(o),[l,u]=(0,Q.useState)(!0),[d,f]=(0,Q.useState)(``),[p,m]=(0,Q.useState)(``),[h,g]=(0,Q.useState)(0),_;t[1]===n?_=t[2]:(_=()=>{let e=new AbortController,t=!0;return u(!0),f(``),c([]),Rt(n,e.signal).then(e=>{t&&c(e)}).catch(e=>{t&&f(e instanceof Error?e.message:String(e))}).finally(()=>{t&&u(!1)}),()=>{t=!1,e.abort()}},t[1]=n,t[2]=_);let v;t[3]!==h||t[4]!==n?(v=[n,h],t[3]=h,t[4]=n,t[5]=v):v=t[5],(0,Q.useEffect)(_,v);let y,b,x,S,C,j,M,P,F,I,L,R;if(t[6]!==d||t[7]!==l||t[8]!==i||t[9]!==a||t[10]!==p||t[11]!==n||t[12]!==r.setupConfigure||t[13]!==r.toolParameters||t[14]!==r.toolsAuthHint||t[15]!==r.toolsDialogSearchEmpty||t[16]!==r.toolsDialogSearchPlaceholder||t[17]!==r.toolsDialogSubtitle||t[18]!==r.toolsDialogTitle||t[19]!==r.toolsEmpty||t[20]!==r.toolsLoading||t[21]!==r.toolsTitle||t[22]!==s){let e=p.trim().toLowerCase(),o=s.filter(t=>`${t.name} ${t.description}`.toLowerCase().includes(e));x=A,C=!0,t[35]===i?j=t[36]:(j=e=>{e||i()},t[35]=i,t[36]=j),b=D,t[37]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,$.jsx)(w,{className:`fixed inset-0 z-[60] bg-scrim`}),t[37]=S):S=t[37],y=O,L=`fixed left-1/2 top-1/2 z-[60] flex h-[min(42rem,calc(100vh-2rem))] w-[min(48rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay`;let c;t[38]===r.toolsDialogTitle?c=t[39]:(c=(0,$.jsx)(k,{className:`font-semibold`,children:r.toolsDialogTitle}),t[38]=r.toolsDialogTitle,t[39]=c);let u;t[40]!==l||t[41]!==n||t[42]!==r.toolsDialogSubtitle||t[43]!==s.length?(u=l?n:r.toolsDialogSubtitle.replace(`{{serverId}}`,n).replace(`{{count}}`,String(s.length)),t[40]=l,t[41]=n,t[42]=r.toolsDialogSubtitle,t[43]=s.length,t[44]=u):u=t[44];let f;t[45]===u?f=t[46]:(f=(0,$.jsx)(T,{className:`mt-1 text-sm text-fg-muted`,children:u}),t[45]=u,t[46]=f);let h;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(h=e=>m(e.target.value),t[47]=h):h=t[47];let g;t[48]!==p||t[49]!==r.toolsDialogSearchPlaceholder?(g=(0,$.jsx)(`input`,{className:`mt-4 w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,value:p,onChange:h,placeholder:r.toolsDialogSearchPlaceholder,"aria-label":r.toolsDialogSearchPlaceholder}),t[48]=p,t[49]=r.toolsDialogSearchPlaceholder,t[50]=g):g=t[50],t[51]!==c||t[52]!==f||t[53]!==g?(R=(0,$.jsxs)(`div`,{className:`shrink-0 border-b border-edge p-5`,children:[c,f,g]}),t[51]=c,t[52]=f,t[53]=g,t[54]=R):R=t[54],M=`min-h-0 flex-1 overflow-y-auto p-5`,P=l,t[55]!==r.toolsTitle||t[56]!==s.length?(F=r.toolsTitle.replace(`{{count}}`,String(s.length)),t[55]=r.toolsTitle,t[56]=s.length,t[57]=F):F=t[57],I=l?(0,$.jsx)(`div`,{role:`status`,"aria-label":r.toolsLoading,className:`space-y-3`,children:[0,1,2].map(Kt)}):d?(0,$.jsxs)(`div`,{role:`alert`,className:`space-y-3`,children:[(0,$.jsx)(`p`,{className:`whitespace-pre-wrap break-words text-sm text-danger`,children:d}),(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.toolsAuthHint.replace(`{{serverId}}`,n)}),a?(0,$.jsx)(N,{variant:`secondary`,onClick:a,children:r.setupConfigure}):null]}):o.length?(0,$.jsx)(`div`,{className:`space-y-3`,children:o.map(e=>(0,$.jsxs)(`article`,{className:`rounded-lg border border-edge p-4`,children:[(0,$.jsx)(`h3`,{className:`break-all font-mono text-sm font-semibold text-fg`,children:e.name}),e.exposure?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.exposure}):null,e.description?(0,$.jsx)(`p`,{className:`mt-2 whitespace-pre-wrap break-words text-sm text-fg-muted`,children:e.description}):null,(0,$.jsxs)(`details`,{className:`mt-3`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm text-accent-fg`,children:r.toolParameters}),(0,$.jsx)(`pre`,{className:`mt-2 overflow-x-auto rounded-md bg-surface-panel p-3 text-xs text-fg`,children:JSON.stringify(e.inputSchema,null,2)})]})]},e.name))}):(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:s.length?r.toolsDialogSearchEmpty:r.toolsEmpty}),t[6]=d,t[7]=l,t[8]=i,t[9]=a,t[10]=p,t[11]=n,t[12]=r.setupConfigure,t[13]=r.toolParameters,t[14]=r.toolsAuthHint,t[15]=r.toolsDialogSearchEmpty,t[16]=r.toolsDialogSearchPlaceholder,t[17]=r.toolsDialogSubtitle,t[18]=r.toolsDialogTitle,t[19]=r.toolsEmpty,t[20]=r.toolsLoading,t[21]=r.toolsTitle,t[22]=s,t[23]=y,t[24]=b,t[25]=x,t[26]=S,t[27]=C,t[28]=j,t[29]=M,t[30]=P,t[31]=F,t[32]=I,t[33]=L,t[34]=R}else y=t[23],b=t[24],x=t[25],S=t[26],C=t[27],j=t[28],M=t[29],P=t[30],F=t[31],I=t[32],L=t[33],R=t[34];let z;t[58]!==M||t[59]!==P||t[60]!==F||t[61]!==I?(z=(0,$.jsx)(`div`,{className:M,"aria-busy":P,"aria-label":F,children:I}),t[58]=M,t[59]=P,t[60]=F,t[61]=I,t[62]=z):z=t[62];let B;t[63]===Symbol.for(`react.memo_cache_sentinel`)?(B=()=>g(Gt),t[63]=B):B=t[63];let V;t[64]!==l||t[65]!==r.refreshTools?(V=(0,$.jsx)(N,{variant:`secondary`,disabled:l,onClick:B,children:r.refreshTools}),t[64]=l,t[65]=r.refreshTools,t[66]=V):V=t[66];let H;t[67]!==i||t[68]!==r.toolsDialogClose?(H=(0,$.jsx)(E,{asChild:!0,children:(0,$.jsx)(N,{onClick:i,children:r.toolsDialogClose})}),t[67]=i,t[68]=r.toolsDialogClose,t[69]=H):H=t[69];let U;t[70]!==V||t[71]!==H?(U=(0,$.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge p-4`,children:[V,H]}),t[70]=V,t[71]=H,t[72]=U):U=t[72];let W;t[73]!==y||t[74]!==z||t[75]!==U||t[76]!==L||t[77]!==R?(W=(0,$.jsxs)(y,{className:L,children:[R,z,U]}),t[73]=y,t[74]=z,t[75]=U,t[76]=L,t[77]=R,t[78]=W):W=t[78];let G;t[79]!==b||t[80]!==S||t[81]!==W?(G=(0,$.jsxs)(b,{children:[S,W]}),t[79]=b,t[80]=S,t[81]=W,t[82]=G):G=t[82];let K;return t[83]!==x||t[84]!==C||t[85]!==j||t[86]!==G?(K=(0,$.jsx)(x,{open:C,onOpenChange:j,children:G}),t[83]=x,t[84]=C,t[85]=j,t[86]=G,t[87]=K):K=t[87],K}function Gt(e){return e+1}function Kt(e){return(0,$.jsx)(R,{className:`h-24 w-full`},e)}function qt(e){if(e.transport===`stdio`){let t=e.command.trim();if(!t)return``;let n=e.argsText.trim();return n?`${t} ${n}`:t}return e.url.trim()}function Jt(e){let t=(0,et.c)(48),{row:n,t:r,cs:i,onEdit:a,onRemove:o}=e,[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)(!1),[d,f]=(0,Q.useState)(``),p;t[0]===n.id?p=t[1]:(p=(0,$.jsx)(`h3`,{className:`text-sm font-semibold`,children:n.id}),t[0]=n.id,t[1]=p);let m;t[2]===n?m=t[3]:(m=qt(n),t[2]=n,t[3]=m);let h;t[4]===m?h=t[5]:(h=(0,$.jsx)(`p`,{className:`mt-2 break-all font-mono text-xs text-fg-muted`,children:m}),t[4]=m,t[5]=h);let g;t[6]!==a||t[7]!==p||t[8]!==h?(g=(0,$.jsxs)(`button`,{className:`block w-full text-left`,onClick:a,children:[p,h]}),t[6]=a,t[7]=p,t[8]=h,t[9]=g):g=t[9];let _;t[10]===r.setupEditHint?_=t[11]:(_=(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:r.setupEditHint}),t[10]=r.setupEditHint,t[11]=_);let v;t[12]===d?v=t[13]:(v=d?(0,$.jsx)(`p`,{className:`text-sm text-danger`,children:d}):null,t[12]=d,t[13]=v);let y;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(y=()=>c(!0),t[14]=y):y=t[14];let b;t[15]===r.viewTools?b=t[16]:(b=(0,$.jsx)(N,{variant:`secondary`,onClick:y,children:r.viewTools}),t[15]=r.viewTools,t[16]=b);let x;t[17]===Symbol.for(`react.memo_cache_sentinel`)?(x=()=>u(!0),t[17]=x):x=t[17];let S;t[18]===r.removeServer?S=t[19]:(S=(0,$.jsx)(N,{variant:`ghost`,onClick:x,children:r.removeServer}),t[18]=r.removeServer,t[19]=S);let C;t[20]!==S||t[21]!==b?(C=(0,$.jsxs)(`div`,{className:`mt-2 flex justify-end gap-2`,children:[b,S]}),t[20]=S,t[21]=b,t[22]=C):C=t[22];let w;t[23]!==a||t[24]!==n.id||t[25]!==s||t[26]!==r?(w=s?(0,$.jsx)(Wt,{serverId:n.id,t:r,onClose:()=>c(!1),onConfigure:()=>{c(!1),a()}}):null,t[23]=a,t[24]=n.id,t[25]=s,t[26]=r,t[27]=w):w=t[27];let T;t[28]!==i.removeConfirmTitle||t[29]!==n.id?(T=i.removeConfirmTitle.replace(`{{name}}`,n.id),t[28]=i.removeConfirmTitle,t[29]=n.id,t[30]=T):T=t[30];let E;t[31]===Symbol.for(`react.memo_cache_sentinel`)?(E=()=>u(!1),t[31]=E):E=t[31];let D;t[32]===o?D=t[33]:(D=()=>{u(!1),o().catch(e=>f(String(e)))},t[32]=o,t[33]=D);let O;t[34]!==l||t[35]!==i.modalCancel||t[36]!==i.removeConfirmDescription||t[37]!==r.removeServer||t[38]!==T||t[39]!==D?(O=(0,$.jsx)(He,{open:l,title:T,description:i.removeConfirmDescription,confirmLabel:r.removeServer,cancelLabel:i.modalCancel,destructive:!0,onCancel:E,onConfirm:D}),t[34]=l,t[35]=i.modalCancel,t[36]=i.removeConfirmDescription,t[37]=r.removeServer,t[38]=T,t[39]=D,t[40]=O):O=t[40];let k;return t[41]!==C||t[42]!==w||t[43]!==O||t[44]!==g||t[45]!==_||t[46]!==v?(k=(0,$.jsxs)(`div`,{className:`px-4 py-3.5`,children:[g,_,v,C,w,O]}),t[41]=C,t[42]=w,t[43]=O,t[44]=g,t[45]=_,t[46]=v,t[47]=k):k=t[47],k}function Yt(e){let t=e.connectedAt?Date.parse(e.connectedAt):0;return Number.isFinite(t)?t:0}function Xt(e,t){return e.status===`active`&&t.status!==`active`?-1:e.status!==`active`&&t.status===`active`?1:e.isCurrentAuthorization===t.isCurrentAuthorization?Yt(t)-Yt(e):e.isCurrentAuthorization?-1:1}function Zt(e){let t=new Map;for(let n of e){let e=n.accountId??n.identityKey??`authorization:${n.id}`;t.set(e,[...t.get(e)??[],n])}return[...t.entries()].map(([e,t])=>{let n=[...t].sort(Xt);return{key:e,primary:n[0],authorizations:n}}).sort((e,t)=>Xt(e.primary,t.primary))}var Qt=y(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,L);function $t(e){return e.materialized.type===`composio`?e.materialized.toolkit:null}function en(e,t){return e===`write`?t.composioScopeWrite:e===`admin`?t.composioScopeAdmin:t.composioScopeRead}function tn(e,t,n){return e.status===`connected`?Z(n.composioHealthConnected,{count:String(t)}):e.status===`reauthorization_required`?n.composioHealthReconnect:e.status===`disconnected`?n.composioHealthDisconnected:e.errorCode===`missing_credential`?n.composioHealthMissingCredential:e.errorCode===`unauthorized`?n.composioHealthUnauthorized:e.errorCode===`forbidden`?n.composioHealthForbidden:e.errorCode===`network`?n.composioHealthNetwork:e.errorCode===`timeout`?n.composioHealthTimeout:n.composioHealthDegraded}function nn(e,t){return e===`active`?t.composioConnectionHealthy:e===`pending`?t.composioConnectionPending:e===`expired`?t.composioConnectionExpired:e===`failed`?t.composioConnectionFailed:e===`revoked`||e===`disabled`?t.composioConnectionRevoked:t.composioConnectionUnknown}function rn(e,t,n){return e.status===`paused`?t?.scanEnabled===!1?n.connectorLearningPausedByPolicy:n.connectorLearningPausedByFailure:e.status===`queued`?n.connectorLearningQueued:e.status===`running`?n.connectorLearningRunning:e.status===`completed`?n.connectorLearningCompleted:n.connectorLearningFailed}function an({instance:e,t,onChanged:n}){let r=$t(e),i=S(e=>e.language)===`zh`,[a,o]=(0,Q.useState)([]),[l,f]=(0,Q.useState)([]),[p,m]=(0,Q.useState)([]),[g,_]=(0,Q.useState)(null),[v,b]=(0,Q.useState)([]),[x,C]=(0,Q.useState)(null),[w,T]=(0,Q.useState)(null),[E,D]=(0,Q.useState)([]),[O,k]=(0,Q.useState)({}),[A,j]=(0,Q.useState)(`read`),[M,P]=(0,Q.useState)(!1),[F,I]=(0,Q.useState)(null),[L,B]=(0,Q.useState)(!1),[U,W]=(0,Q.useState)(null),[G,K]=(0,Q.useState)(null),[q,ee]=(0,Q.useState)(!1),[ie,oe]=(0,Q.useState)(!1),[se,ce]=(0,Q.useState)(!1),Y=(0,Q.useRef)(0),de=(0,Q.useRef)(0),he=(0,Q.useMemo)(()=>Zt(a),[a]),ve=(0,Q.useCallback)(e=>new Promise((t,n)=>{let r=window.setTimeout(()=>n(Error(i?`连接服务响应超时,请重试。`:`The connection service timed out. Please retry.`)),15e3);e.then(t,n).finally(()=>window.clearTimeout(r))}),[i]),X=(0,Q.useCallback)(async()=>{if(!r||e.materialized.type!==`composio`||e.materialized.role===`credential`)return;P(!0),I(null);let t=++Y.current;try{let e=(await Promise.allSettled([ve(J()).then(e=>{t===Y.current&&(o(e.filter(e=>e.toolkit.toLowerCase()===r.toLowerCase())),ee(!0))}),ve(Ne(r)).then(e=>{t===Y.current&&j(e)}),ve(H(r)).then(e=>{t===Y.current&&(_(e.policy),b(e.agents))})])).find(e=>e.status===`rejected`);t===Y.current&&e?.status===`rejected`&&I(String(e.reason instanceof Error?e.reason.message:e.reason))}finally{t===Y.current&&P(!1)}},[e.materialized,r,ve]);(0,Q.useEffect)(()=>(X(),()=>{Y.current++}),[X]);let be=(0,Q.useCallback)(async()=>{if(!r)return;let e=++de.current;ce(!0),B(!1);let t=t=>n=>{e===de.current&&t(n)},n=await Promise.allSettled([ve(ae(r)).then(t(f)),ve(ue(20)).then(t(e=>m(e.filter(e=>!e.toolkit||e.toolkit.toLowerCase()===r.toLowerCase())))),ve(fe(r)).then(t(T)),ve(Fe(r)).then(t(C))]);e===de.current&&(B(n.some(e=>e.status===`rejected`)),ce(!1))},[r,ve]);(0,Q.useEffect)(()=>(ie&&be(),()=>{de.current++}),[ie,be]),(0,Q.useEffect)(()=>{let e=!1,t=Zt(a).map(e=>e.primary).filter(e=>e.supportsLearning&&e.accountId);if(t.length)return ve(_e()).then(t=>{e||D(t)}).catch(()=>{}),Promise.allSettled(t.map(async e=>[e.accountId,await ve(me(e.accountId))])).then(t=>{e||k(Object.fromEntries(t.flatMap(e=>e.status===`fulfilled`?[e.value]:[])))}),()=>{e=!0}},[a,ve]);let xe=(0,Q.useCallback)(async i=>{if(!r)return;let a=z()?null:window.open(`about:blank`,`_blank`);a&&(a.opener=null),P(!0),I(null);try{if(!z()&&!a)throw Error(`Allow popups to open the authorization page.`);let t=await le(e.connectorId,i);if(!t.authorizationUrl)throw Error(`The authorization provider did not return an authorization URL.`);if(z()){let e=await window.electronAPI?.shell?.openExternalUrl(t.authorizationUrl);if(!e?.ok)throw Error(e?.error??`Could not open the system browser.`)}else a.location.href=t.authorizationUrl;let o=await Me(r,t.connectionId,12e4,t.attemptId);if(i&&o.accountId!==i)throw Error(`A different account was authorized. The original account and its task bindings were not changed.`);await Promise.all([n?.(),X()])}catch(e){I(De(e,t))}finally{a?.close(),P(!1)}},[e.connectorId,X,n,t,r]),Se=(0,Q.useCallback)(async t=>{P(!0),I(null);try{await ge(e.instanceId,{config:{...e.config??{},authConfigId:t||void 0}}),await Promise.all([n?.(),X()])}catch(e){I(e instanceof Error?e.message:String(e))}finally{P(!1)}},[e.config,e.instanceId,X,n]),Te=async e=>{let t=z()?null:window.open(`about:blank`,`_blank`);t&&(t.opener=null),I(null);try{let n=await pe(e.id);if(n.authorizationUrl)if(z())await window.electronAPI?.shell?.openExternalUrl(n.authorizationUrl);else if(t)t.location.href=n.authorizationUrl;else throw Error(`Allow popups to reopen authorization.`);else t?.close(),await X()}catch(e){t?.close(),I(e instanceof Error?e.message:String(e))}},je=(0,Q.useCallback)(async e=>{if(r){j(e),I(null);try{await Ce(r,e)}catch(e){I(e instanceof Error?e.message:String(e)),await X()}}},[X,r]),Pe=(0,Q.useCallback)(async e=>{if(r){I(null);try{_(await ke(r,e))}catch(e){I(e instanceof Error?e.message:String(e))}}},[r]),Ie=(0,Q.useCallback)(e=>{if(!g)return;let t=g.allowedAgentIds.includes(e);t&&g.allowedAgentIds.length===1||Pe({allowedAgentIds:t?g.allowedAgentIds.filter(t=>t!==e):[...g.allowedAgentIds,e]})},[Pe,g]),Le=(0,Q.useCallback)(async e=>{P(!0),I(null);try{await e(),await X()}catch(e){I(e instanceof Error?e.message:String(e))}finally{P(!1)}},[X]);if(!r)return null;if(e.materialized.type===`composio`&&e.materialized.role===`credential`)return(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.composioApiKeyStored});let Re=he.filter(e=>e.primary.status===`active`).length,ze=Re>0?t.composioAddAccount:t.composioConnectAccount,Be=q&&Re>0,Ve=w?.requiresCustomAuthConfig===!0,Ue=w?.authConfigs.filter(e=>e.status===`ENABLED`&&e.isEnabledForToolRouter)??[];return(0,$.jsxs)(`div`,{className:`space-y-5`,children:[(0,$.jsxs)(`section`,{className:`flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsxs)(`span`,{className:y(`inline-flex items-center gap-1.5 rounded-full px-2.5 py-1 text-xs font-medium`,Be?`bg-emerald-500/10 text-emerald-700 dark:text-emerald-300`:`bg-amber-500/10 text-amber-700 dark:text-amber-300`),children:[Be?(0,$.jsx)(d,{className:`size-3.5`}):(0,$.jsx)(u,{className:`size-3.5`}),Be?t.connectionReady:q||F?t.connectionNeedsSetup:t.connectionChecking]}),q&&(0,$.jsx)(`p`,{className:`mt-2 text-sm text-fg-muted`,children:Z(t.composioAccountCount,{count:String(he.length)})})]}),(0,$.jsxs)(N,{variant:`primary`,className:`shrink-0`,disabled:M,onClick:()=>void xe(),children:[M?(0,$.jsx)(h,{className:`size-4 animate-spin`}):(0,$.jsx)(te,{className:`size-4`}),ze]})]}),F?(0,$.jsxs)(`div`,{role:`alert`,className:`flex flex-wrap items-center justify-between gap-2 rounded-xl border border-danger/20 bg-danger/5 px-3 py-2 text-sm text-danger`,children:[(0,$.jsx)(`p`,{children:F}),(0,$.jsx)(N,{variant:`secondary`,disabled:M,onClick:()=>void X(),children:t.composioRetry})]}):null,x&&!Be?(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border border-amber-500/25 bg-amber-500/5 p-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsx)(`p`,{className:`text-sm text-amber-800 dark:text-amber-200`,children:tn(x,Re,t)}),x.recovery===`none`?null:(0,$.jsx)(N,{variant:`secondary`,disabled:M,onClick:()=>void(x.recovery===`retry`?X():xe()),children:x.recovery===`retry`?t.composioRetry:t.composioReconnectAccount})]}):null,Ve&&Ue.length===0?(0,$.jsx)(`p`,{className:`rounded-xl border border-amber-500/25 bg-amber-500/5 px-4 py-3 text-sm text-amber-800 dark:text-amber-200`,children:t.composioAuthConfigEmpty}):null,g?(0,$.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-edge bg-surface-base`,children:[(0,$.jsxs)(`div`,{className:`grid gap-3 border-b border-edge-subtle px-4 py-4 sm:grid-cols-[minmax(0,1fr)_15rem] sm:items-start`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.composioAccessTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:A===`read`?t.composioAccessReadHint:A===`admin`?t.composioAccessAdminHint:t.composioAccessWriteHint})]}),(0,$.jsxs)(s,{value:A,onChange:e=>void je(e.currentTarget.value),children:[(0,$.jsx)(c,{value:`read`,children:t.composioAccessReadOnly}),(0,$.jsx)(c,{value:`write`,children:t.composioAccessReadWrite}),A===`admin`?(0,$.jsx)(c,{value:`admin`,children:t.composioAccessAdminCurrent}):null]})]}),(0,$.jsxs)(`details`,{children:[(0,$.jsx)(`summary`,{className:`cursor-pointer px-4 py-3 text-sm text-fg-muted`,children:t.composioAdvancedSettings}),(0,$.jsxs)(`div`,{className:`grid gap-3 border-b border-edge-subtle px-4 py-4 sm:grid-cols-[minmax(0,1fr)_15rem] sm:items-center`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.composioConfirmationPolicy}),(0,$.jsxs)(s,{value:g.confirmationPolicy,onChange:e=>void Pe({confirmationPolicy:e.currentTarget.value}),children:[(0,$.jsx)(c,{value:`writes`,children:t.composioConfirmWrites}),(0,$.jsx)(c,{value:`always`,children:t.composioConfirmAlways}),g.confirmationPolicy===`never`?(0,$.jsx)(c,{value:`never`,children:t.composioConfirmNever}):null]})]}),(0,$.jsxs)(`div`,{className:`px-4 py-4`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.composioAllowedAgents}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:g.allowedAgentIds.length?t.composioAllowedAgentsSelected:t.composioAllowedAgentsAll}),(0,$.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,$.jsx)(`button`,{type:`button`,className:y(`rounded-full border px-2.5 py-1 text-xs transition-colors`,g.allowedAgentIds.length===0?`border-accent bg-accent/10 text-accent`:`border-edge bg-surface-panel text-fg-muted hover:text-fg`),onClick:()=>void Pe({allowedAgentIds:[]}),children:t.composioAllowedAgentsAllOption}),v.map(e=>(0,$.jsx)(`button`,{type:`button`,className:y(`rounded-full border px-2.5 py-1 text-xs transition-colors`,g.allowedAgentIds.includes(e.id)?`border-accent bg-accent/10 text-accent`:`border-edge bg-surface-panel text-fg-muted hover:text-fg`),onClick:()=>Ie(e.id),children:e.name},e.id))]})]}),(0,$.jsxs)(`fieldset`,{className:`space-y-2 border-t border-edge-subtle p-4 text-xs text-fg-muted`,children:[(0,$.jsx)(`legend`,{children:i?`可用账号范围`:`Available accounts`}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:g.selectedAccountIds===null,disabled:M,onChange:e=>void Pe({selectedAccountIds:e.currentTarget.checked?null:[]})}),i?`所有账号(包括以后新增)`:`All accounts, including new ones`]}),g.selectedAccountIds!==null&&he.map(({primary:e})=>e.accountId&&(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,disabled:M,checked:g.selectedAccountIds.includes(e.accountId),onChange:t=>void Pe({selectedAccountIds:t.currentTarget.checked?[...g.selectedAccountIds,e.accountId]:g.selectedAccountIds.filter(t=>t!==e.accountId)})}),e.alias??e.accountEmail??e.accountId]},e.accountId)),g.selectedAccountIds?.length===0&&(0,$.jsx)(`p`,{children:i?`未选择账号,Agent 无法使用此应用。`:`No accounts selected. Agents cannot use this app.`})]})]})]}):null,(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:t.composioConnectedAccounts}),q&&(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:Z(t.composioAccountCount,{count:String(he.length)})})]}),(0,$.jsxs)(N,{variant:`ghost`,className:`h-8 px-2 text-xs`,disabled:M,onClick:()=>void X(),children:[(0,$.jsx)(we,{className:y(`size-3.5`,M&&`animate-spin`)}),t.refresh]})]}),he.length?(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-xl border border-edge bg-surface-base`,children:he.map(e=>{let r=e.primary,a=E.find(e=>r.accountId?e.accountId===r.accountId:e.connectionId===r.id),o=r.accountId?O[r.accountId]:void 0;return(0,$.jsxs)(`article`,{className:`px-4 py-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col items-start justify-between gap-3 sm:flex-row`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`div`,{className:`flex flex-wrap items-center gap-2`,children:(0,$.jsx)(`p`,{className:`truncate text-sm font-medium text-fg`,children:r.alias??r.workspace??r.accountEmail??r.username??t.composioUnnamedAuthorization})}),(0,$.jsx)(`p`,{className:`mt-1 break-all text-xs text-fg-muted`,children:r.accountEmail??r.username??r.workspace??r.accountId}),r.backendLabel&&(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:r.backendLabel}),(0,$.jsx)(`p`,{className:y(`mt-1 text-xs`,r.status===`active`?`text-emerald-700 dark:text-emerald-300`:`text-amber-700 dark:text-amber-300`),children:r.accountEnabled===!1?i?`已暂停`:`Paused`:nn(r.status,t)}),a?(0,$.jsx)(`p`,{className:y(`mt-1 text-xs`,a.status===`failed`?`text-red-600`:`text-fg-subtle`),children:Z(t.connectorLearningStatus,{status:rn(a,o,t),count:String(a.candidatesCreated)})}):null]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap gap-2`,children:[r.status===`pending`&&(0,$.jsx)(N,{variant:`secondary`,className:`h-8 px-2.5 text-xs`,onClick:()=>void Te(r),children:i?`继续授权`:`Continue authorization`}),r.accountId&&(0,$.jsx)(N,{variant:`ghost`,className:`h-8 px-2.5 text-xs text-danger`,disabled:M,onClick:()=>K(r.accountId),children:i?`断开`:`Disconnect`}),r.accountId&&r.status!==`active`&&(0,$.jsx)(N,{variant:`secondary`,className:`h-8 px-2.5 text-xs`,disabled:M,onClick:()=>void xe(r.accountId),children:t.composioReconnectAccount}),r.accountId&&(0,$.jsx)(N,{variant:`secondary`,className:`h-8 px-2.5 text-xs`,disabled:M,onClick:()=>void Le(()=>Oe(r.accountId,{enabled:r.accountEnabled===!1})),children:r.accountEnabled===!1?i?`启用`:`Enable`:i?`暂停`:`Pause`}),r.supportsLearning&&r.status===`active`&&r.accountEnabled!==!1?(0,$.jsxs)(N,{variant:`secondary`,className:`h-8 shrink-0 px-2.5 text-xs`,disabled:M,onClick:()=>void Le(async()=>{if(!r.accountId)throw Error(`Connector account is unavailable.`);await ne(r.accountId),await n?.()}),children:[(0,$.jsx)(we,{className:`size-3.5`}),t.composioSyncNow]}):null]})]}),(0,$.jsxs)(`details`,{className:`mt-3 text-xs text-fg-muted`,children:[(0,$.jsx)(`summary`,{className:`w-fit cursor-pointer font-medium hover:text-fg`,children:t.composioAccountSettings}),(0,$.jsxs)(`div`,{className:`mt-3 space-y-4 rounded-lg bg-surface-panel p-3`,children:[r.accountId&&(0,$.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,$.jsx)(`legend`,{className:`mb-2 font-medium`,children:t.composioAllowedAgents}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,disabled:M,checked:r.allowedAgentIds==null,onChange:e=>void Le(()=>Oe(r.accountId,{allowedAgentIds:e.currentTarget.checked?null:[]}))}),t.composioAllowedAgentsAllOption]}),r.allowedAgentIds!=null&&v.map(e=>(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,disabled:M,checked:r.allowedAgentIds.includes(e.id),onChange:t=>{let n=t.currentTarget.checked;Le(()=>Oe(r.accountId,{allowedAgentIds:n?[...r.allowedAgentIds,e.id]:r.allowedAgentIds.filter(t=>t!==e.id)}))}}),e.name]},e.id)),r.allowedAgentIds?.length===0&&(0,$.jsx)(`p`,{children:i?`未选择 Agent:任何 Agent 都不能使用此账号。`:`No agents selected: this account is unavailable to all agents.`})]}),r.supportsLearning&&o?(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:o.scanEnabled,disabled:M,onChange:e=>void Le(()=>V(r.accountId,{scanEnabled:e.currentTarget.checked}))}),t.connectorScheduledScan]}),o.scanEnabled?(0,$.jsxs)(`label`,{className:`sm:col-span-2`,children:[t.connectorScanInterval,(0,$.jsxs)(s,{className:`mt-1`,value:String(o.intervalMinutes??30),disabled:M,onChange:e=>void Le(()=>V(r.accountId,{intervalMinutes:Number(e.currentTarget.value)})),children:[(0,$.jsxs)(c,{value:`5`,children:[`5 `,t.connectorMinutes]}),(0,$.jsxs)(c,{value:`15`,children:[`15 `,t.connectorMinutes]}),(0,$.jsxs)(c,{value:`30`,children:[`30 `,t.connectorMinutes]}),(0,$.jsxs)(c,{value:`60`,children:[`60 `,t.connectorMinutes]})]})]}):null]}):null,(0,$.jsxs)(`label`,{className:`block`,children:[t.composioAccountAlias,(0,$.jsx)(`input`,{className:y(Qt,`mt-1 h-8 py-1 text-xs`),defaultValue:r.alias??``,onBlur:e=>{e.currentTarget.value!==(r.alias??``)&&Le(()=>Ee(r.id,{alias:e.currentTarget.value}))}})]}),(0,$.jsx)(`div`,{className:`space-y-2`,children:e.authorizations.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`p`,{className:`min-w-0 break-all font-mono text-fg-subtle`,children:[t.composioAuthorizationId,`: `,e.providerConnectionId]}),(0,$.jsx)(N,{variant:`ghost`,className:`size-7 shrink-0 p-0 text-danger`,title:t.composioRevoke,disabled:M,onClick:()=>W(e.id),children:(0,$.jsx)(Ae,{className:`size-3.5`})})]},e.id))}),(0,$.jsx)(`div`,{className:`flex justify-end gap-1`,children:(0,$.jsx)(N,{variant:`ghost`,className:`size-8 p-0`,title:t.refresh,disabled:M,onClick:()=>void Le(()=>Ke(r.id)),children:(0,$.jsx)(we,{className:`size-4`})})})]})]})]},e.key)})}):M&&!q?(0,$.jsxs)(`div`,{"aria-busy":`true`,"aria-label":t.connectionChecking,className:`space-y-3`,children:[(0,$.jsx)(R,{className:`h-16 w-full`}),(0,$.jsx)(R,{className:`h-16 w-full`})]}):q?(0,$.jsx)(`div`,{className:`rounded-xl border border-dashed border-edge px-4 py-8 text-center`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:t.composioConnectionsEmpty})}):null]}),(0,$.jsxs)(`details`,{className:`rounded-xl border border-edge bg-surface-base`,onToggle:e=>oe(e.currentTarget.open),children:[(0,$.jsx)(`summary`,{className:`cursor-pointer px-4 py-3 text-sm font-medium text-fg-muted hover:text-fg`,children:t.composioAdvancedSettings}),(0,$.jsxs)(`div`,{className:`space-y-5 border-t border-edge-subtle px-4 py-4`,children:[se?(0,$.jsx)(R,{"aria-label":t.connectionChecking,className:`h-16 w-full`}):null,L?(0,$.jsxs)(`p`,{className:`rounded-lg bg-amber-500/10 px-3 py-2 text-xs text-amber-800 dark:text-amber-200`,children:[t.composioDiagnosticsUnavailable,(0,$.jsx)(N,{variant:`ghost`,disabled:se,onClick:()=>void be(),children:t.composioRetry})]}):null,w?.mode===`byok`?(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:t.composioAuthConfigTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:Ve?t.composioAuthConfigRequiredHint:t.composioAuthConfigOptionalHint})]}),(0,$.jsx)(`a`,{className:`text-xs font-medium text-accent-fg hover:underline`,href:`https://app.composio.dev`,target:`_blank`,rel:`noreferrer`,children:t.composioAuthConfigManage})]}),(0,$.jsxs)(s,{className:`mt-3`,value:typeof e.config?.authConfigId==`string`?e.config.authConfigId:``,disabled:M,onChange:e=>void Se(e.currentTarget.value),children:[Ve?null:(0,$.jsx)(c,{value:``,children:t.composioAuthConfigManaged}),Ve&&typeof e.config?.authConfigId!=`string`?(0,$.jsx)(c,{value:``,disabled:!0,children:t.composioAuthConfigSelect}):null,Ue.map(e=>(0,$.jsxs)(c,{value:e.id,children:[e.name,` · `,e.authScheme??`OAuth`]},e.id))]})]}):null,(0,$.jsxs)(`div`,{className:`grid gap-5 sm:grid-cols-2`,children:[(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioAgentTools}),(0,$.jsx)(`div`,{className:`space-y-2`,children:l.length?l.slice(0,8).map(e=>(0,$.jsxs)(`div`,{className:`rounded-lg bg-surface-panel px-3 py-2`,children:[(0,$.jsx)(`p`,{className:`truncate font-mono text-xs text-fg`,children:e.slug}),(0,$.jsxs)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:[en(e.scope,t),e.curated?``:` ${t.composioUncuratedSuffix}`]})]},e.slug)):(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioToolsEmpty})})]}),(0,$.jsxs)(`section`,{children:[(0,$.jsx)(`p`,{className:`mb-2 text-xs font-medium uppercase tracking-wide text-fg-subtle`,children:t.composioRecentTriggers}),(0,$.jsx)(`div`,{className:`space-y-2`,children:p.length?p.slice(0,5).map(e=>(0,$.jsxs)(`div`,{className:`rounded-lg bg-surface-panel px-3 py-2`,children:[(0,$.jsx)(`p`,{className:`truncate text-xs text-fg`,children:e.trigger??e.id}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-subtle`,children:new Date(e.at).toLocaleString()})]},`${e.id}-${e.at}`)):(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:t.composioTriggersEmpty})})]})]})]})]}),(0,$.jsx)(He,{open:G!==null,title:i?`断开账号`:`Disconnect account`,description:i?`停止此账号的工具使用和学习,并撤销其全部授权。已保存的数据不会删除。`:`Stop tool access and learning for this account and revoke all its authorizations. Saved data will not be deleted.`,confirmLabel:i?`断开`:`Disconnect`,cancelLabel:t.modalCancel,destructive:!0,onConfirm:()=>{let e=G;K(null),e&&Le(()=>ye(e))},onCancel:()=>K(null)}),(0,$.jsx)(He,{open:U!==null,title:t.composioRevoke,description:t.composioRevokeConfirm,confirmLabel:t.composioRevoke,cancelLabel:t.modalCancel,destructive:!0,onConfirm:()=>{let e=U;W(null),e&&Le(()=>re(e))},onCancel:()=>W(null)})]})}var on=y(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,L);function sn(e,t){let n={};for(let r of e?.setup.config??[]){let e=t.config?.[r.key]??r.defaultValue??``;n[r.key]=typeof e==`string`?e:JSON.stringify(e,null,2)}return n}function cn(e,t){let n=t.trim();return e===`json`?n?JSON.parse(n):void 0:e===`number`?n?Number(n):void 0:e===`boolean`?n===`true`:n||void 0}function ln({instance:e,definition:t,onClose:n,onChanged:r,t:i}){let[a,o]=(0,Q.useState)(!1),[s,c]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)(!1),[d,f]=(0,Q.useState)(!1),[p,m]=(0,Q.useState)(null),[g,v]=(0,Q.useState)(()=>sn(t,e)),[b,x]=(0,Q.useState)(null),[S,C]=(0,Q.useState)(!1),[j,M]=(0,Q.useState)(null),F=t?.setup.config??[],I=(e.materialized.type===`mcp`||e.materialized.type===`memorySource`)&&F.length>0&&(t?.setup.secrets??[]).length===0,L=e.materialized.type===`mcp`,R=e.materialized.type===`composio`,z=e.materialized.type===`memorySource`,V=t?Te(t,i):null,H=(0,Q.useCallback)(async()=>{C(!0),x(null);try{let t=await ce(e.instanceId);M(t),t.ok||x(t.error??t.action??i.healthStatusLabels[t.status]),await r()}catch(e){x(e instanceof Error?e.message:String(e))}finally{C(!1)}},[e.instanceId,r,i.healthStatusLabels]),U=(0,Q.useCallback)(async()=>{o(!0),x(null);try{await Se(e.instanceId),await r(),n()}catch(e){x(e instanceof Error?e.message:String(e)),o(!1)}},[e.instanceId,r,n]),W=(0,Q.useCallback)(async()=>{if(!(!t||!I)){u(!0),x(null);try{let n={};for(let e of t.setup.config??[]){let t=cn(e.type,g[e.key]??``);t!==void 0&&(n[e.key]=t)}await ge(e.instanceId,{config:n}),await r()}catch(e){x(e instanceof Error?e.message:String(e))}finally{u(!1)}}},[g,t,e.instanceId,r,I]),G=(0,Q.useCallback)(async()=>{f(!0),m(null),x(null);try{m((await ze(e.connectorId)).recordIds.length),await r()}catch(e){x(e instanceof Error?e.message:String(e))}finally{f(!1)}},[e.connectorId,r]);return(0,$.jsxs)(A,{open:!0,onOpenChange:e=>{e||n()},children:[(0,$.jsxs)(D,{children:[(0,$.jsx)(w,{className:`xopc-dialog-overlay fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(O,{className:y(`xopc-dialog-content fixed left-1/2 top-1/2 z-[60] flex -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden`,R?`h-[min(100dvh-2rem,36rem)] w-[min(100%-2rem,40rem)]`:`h-[min(100dvh-2rem,44rem)] w-[min(100%-2rem,min(92vw,54rem))]`,`rounded-2xl border border-edge bg-surface-overlay shadow-float outline-none dark:border-edge`),children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge-subtle px-6 py-5`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3`,children:[(0,$.jsx)(B,{connector:t,size:`lg`}),(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(k,{className:`text-base font-semibold text-fg`,children:e.displayName}),(0,$.jsx)(T,{className:`mt-1 text-sm text-fg-muted`,children:V??(e.materialized.type===`mcp`?Z(i.mcpServerRuntime,{serverId:e.materialized.serverId}):Z(i.runtimeLabel,{runtime:e.materialized.type}))})]})]}),(0,$.jsx)(E,{asChild:!0,children:(0,$.jsxs)(`button`,{type:`button`,className:y(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,P.focusRingPanel),"aria-label":i.modalClose,children:[(0,$.jsx)(_,{className:`size-5`,strokeWidth:1.75,"aria-hidden":!0}),(0,$.jsx)(`span`,{className:`sr-only`,children:i.modalClose})]})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 py-5`,children:[b?(0,$.jsx)(`p`,{className:`mb-4 rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:b}):null,L?(0,$.jsxs)(`div`,{className:`space-y-3 rounded-xl border border-edge bg-surface-base p-3 text-sm`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,$.jsx)(`p`,{className:`text-fg-muted`,role:`status`,children:j?.ok?Z(i.toolsAvailable,{count:String(j.toolCount)}):j?i.healthStatusLabels[j.status]:e.usage.lastHealthStatus?i.healthStatusLabels[e.usage.lastHealthStatus]:i.healthNotTested}),(0,$.jsxs)(N,{variant:`secondary`,"aria-busy":S,disabled:S||!e.enabled,onClick:()=>void H(),children:[S?(0,$.jsx)(h,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(we,{className:`size-4`,"aria-hidden":!0}),i.test]})]}),I?F.map(e=>(0,$.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`font-medium text-fg`,children:e.label}),e.description?(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:e.description}):null,(0,$.jsx)(`input`,{className:on,value:g[e.key]??``,placeholder:e.placeholder,onChange:t=>v(n=>({...n,[e.key]:t.currentTarget.value}))})]},e.key)):null]}):null,R?(0,$.jsx)(an,{instance:e,t:i,onChanged:r}):null,z?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 rounded-xl border border-edge bg-surface-base p-4 text-sm`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`font-medium text-fg`,children:i.connectedSourceSync}),V?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:V}):null,p===null?null:(0,$.jsx)(`p`,{className:`mt-1 text-xs text-emerald-600`,children:Z(i.connectedSourceSynced,{count:String(p)})})]}),(0,$.jsxs)(N,{disabled:d,onClick:()=>void G(),children:[d?(0,$.jsx)(h,{className:`size-4 animate-spin`}):(0,$.jsx)(je,{className:`size-4`}),i.composioSyncNow]})]}),I?(0,$.jsx)(`div`,{className:`grid gap-3 rounded-xl border border-edge bg-surface-base p-4`,children:F.map(e=>(0,$.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:e.label}),e.description?(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:e.description}):null,(0,$.jsx)(`input`,{className:on,value:g[e.key]??``,placeholder:e.placeholder,onChange:t=>v(n=>({...n,[e.key]:t.currentTarget.value}))})]},e.key))}):null]}):null,!L&&!R&&!z?(0,$.jsx)(`div`,{className:`rounded-xl border border-edge bg-surface-base p-4 text-sm text-fg-muted`,children:(0,$.jsx)(`p`,{children:i.connectorPolicyHint})}):null,(0,$.jsxs)(`details`,{className:`mt-5 rounded-xl border border-edge`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer px-4 py-3 text-sm font-medium text-fg-muted hover:text-danger`,children:i.dangerZone}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 border-t border-danger/15 px-4 py-4 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsx)(`p`,{className:`text-xs leading-5 text-fg-muted`,children:i.removeConnectorHint}),(0,$.jsxs)(N,{variant:`secondary`,className:`shrink-0 border-danger/30 text-danger hover:bg-danger/10`,disabled:a,onClick:()=>c(!0),children:[a?(0,$.jsx)(h,{className:`size-4 animate-spin`}):(0,$.jsx)(Ae,{className:`size-4`}),i.remove]})]})]})]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 flex-wrap justify-end gap-2 border-t border-edge-subtle px-6 py-4`,children:[(0,$.jsx)(N,{variant:`secondary`,onClick:n,children:i.modalClose}),(L||z)&&I?(0,$.jsxs)(N,{variant:`primary`,disabled:l,onClick:()=>void W(),children:[l?(0,$.jsx)(h,{className:`size-4 animate-spin`}):(0,$.jsx)(ie,{className:`size-4`}),i.modalSave]}):null]})]})]}),(0,$.jsx)(He,{open:s,title:Z(i.removeConfirmTitle,{name:e.displayName}),description:i.removeConfirmDescription,confirmLabel:i.removeConfirmAction,cancelLabel:i.modalCancel,destructive:!0,onConfirm:()=>{c(!1),U()},onCancel:()=>{a||c(!1)}})]})}function un(e){let t=(0,et.c)(2),n;return t[0]===e?n=t[1]:(n=e.instance.materialized.type===`cli`&&e.definition?(0,$.jsx)(he,{definition:e.definition,instance:e.instance,onClose:e.onClose,onChanged:e.onChanged}):(0,$.jsx)(ln,{...e}),t[0]=e,t[1]=n),n}function dn(e){let t=(0,et.c)(55),{instance:n,definition:r,highlighted:i,onOpenDetails:a,t:s}=e,c=i===void 0?!1:i,l;t[0]!==r||t[1]!==n?(l=ft(n,r),t[0]=r,t[1]=n,t[2]=l):l=t[2];let p=l.state,m;t[3]!==r||t[4]!==s?(m=r?Te(r,s):null,t[3]=r,t[4]=s,t[5]=m):m=t[5];let h=m,g,_,v,b,x,S,C,w,T;if(t[6]!==p||t[7]!==r||t[8]!==c||t[9]!==n||t[10]!==a||t[11]!==s.connectionChecking||t[12]!==s.connectionNeedsSetup||t[13]!==s.connectionReady){g=p===`ready`?{label:s.connectionReady,Icon:d,className:`text-emerald-700 dark:text-emerald-300`}:p===`needs_setup`?{label:s.connectionNeedsSetup,Icon:u,className:`text-amber-700 dark:text-amber-300`}:{label:s.connectionChecking,Icon:f,className:`text-fg-muted`},w=`button`;let e=c&&`bg-accent-soft`;t[23]===e?T=t[24]:(T=y(`flex w-full items-center gap-3 px-4 py-3.5 text-left hover:bg-surface-hover/60`,`rounded-none first:rounded-t-[calc(var(--radius-xl)-1px)] last:rounded-b-[calc(var(--radius-xl)-1px)]`,P.transition,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-accent`,e),t[23]=e,t[24]=T),t[25]!==n||t[26]!==a?(_=()=>a(n),t[25]=n,t[26]=a,t[27]=_):_=t[27],t[28]===r?v=t[29]:(v=(0,$.jsx)(B,{connector:r}),t[28]=r,t[29]=v),C=`min-w-0 flex-1`,x=`flex min-w-0 items-center gap-2`,t[30]===n.displayName?S=t[31]:(S=(0,$.jsx)(`h3`,{className:`truncate text-sm font-medium text-fg`,children:n.displayName}),t[30]=n.displayName,t[31]=S),b=y(`inline-flex shrink-0 items-center gap-1 text-xs font-medium`,g.className),t[6]=p,t[7]=r,t[8]=c,t[9]=n,t[10]=a,t[11]=s.connectionChecking,t[12]=s.connectionNeedsSetup,t[13]=s.connectionReady,t[14]=g,t[15]=_,t[16]=v,t[17]=b,t[18]=x,t[19]=S,t[20]=C,t[21]=w,t[22]=T}else g=t[14],_=t[15],v=t[16],b=t[17],x=t[18],S=t[19],C=t[20],w=t[21],T=t[22];let E;t[32]===g.Icon?E=t[33]:(E=(0,$.jsx)(g.Icon,{className:`size-3.5`,"aria-hidden":!0}),t[32]=g.Icon,t[33]=E);let D;t[34]!==g.label||t[35]!==E||t[36]!==b?(D=(0,$.jsxs)(`span`,{className:b,children:[E,g.label]}),t[34]=g.label,t[35]=E,t[36]=b,t[37]=D):D=t[37];let O;t[38]!==D||t[39]!==x||t[40]!==S?(O=(0,$.jsxs)(`div`,{className:x,children:[S,D]}),t[38]=D,t[39]=x,t[40]=S,t[41]=O):O=t[41];let k;t[42]===h?k=t[43]:(k=h?(0,$.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted`,children:h}):null,t[42]=h,t[43]=k);let A;t[44]!==O||t[45]!==k||t[46]!==C?(A=(0,$.jsxs)(`div`,{className:C,children:[O,k]}),t[44]=O,t[45]=k,t[46]=C,t[47]=A):A=t[47];let j;t[48]===Symbol.for(`react.memo_cache_sentinel`)?(j=(0,$.jsx)(o,{className:`size-4 shrink-0 text-fg-disabled`,"aria-hidden":!0}),t[48]=j):j=t[48];let M;return t[49]!==_||t[50]!==v||t[51]!==A||t[52]!==w||t[53]!==T?(M=(0,$.jsxs)(`button`,{type:w,className:T,onClick:_,children:[v,A,j]}),t[49]=_,t[50]=v,t[51]=A,t[52]=w,t[53]=T,t[54]=M):M=t[54],M}function fn(e,t){let n=e.length+1,r=`server-${n}`,i=new Set([...e.map(e=>e.id.trim()),...t]);for(;i.has(r);)n+=1,r=`server-${n}`;return Ft(r)}function pn(){return y(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,L)}function mn({label:e,optionalLabel:t,addLabel:n,removeHeaderAria:r,pasteLabel:i,pasteFailed:a,pasteFailedTitle:o,dismissLabel:s,keyPlaceholder:c,valuePlaceholder:l,headers:u,onChange:d}){let[f,p]=(0,Q.useState)(!1),m=(e,t)=>{d(u.map((n,r)=>r===e?{...n,...t}:n))},h=()=>{d([...u,xt()])},g=e=>{let t=u.filter((t,n)=>n!==e);d(t.length>0?t:[xt()])},_=async()=>{try{let e=await M();if(!e){p(!0);return}let t=Ct(e);if(!t?.length){p(!0);return}d(t)}catch{p(!0)}};return(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 md:col-span-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-1.5 text-sm font-medium text-fg`,children:[(0,$.jsx)(`span`,{children:e}),t?(0,$.jsx)(`span`,{className:`font-normal text-fg-subtle`,children:t}):null]}),(0,$.jsxs)(N,{type:`button`,variant:`ghost`,className:`h-8 gap-1.5 px-2 text-xs`,onClick:()=>void _(),children:[(0,$.jsx)(Ue,{className:`size-3.5`,"aria-hidden":!0}),i]})]}),(0,$.jsx)(`div`,{className:`flex flex-col gap-2`,children:u.map((e,t)=>(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{className:y(pn(),`min-w-0 flex-1 font-mono text-xs`),value:e.key,placeholder:c,onChange:e=>m(t,{key:e.target.value})}),(0,$.jsx)(`input`,{className:y(pn(),`min-w-0 flex-[1.4] font-mono text-xs`),value:e.value,placeholder:l,onChange:e=>m(t,{value:e.target.value})}),(0,$.jsx)(N,{type:`button`,variant:`ghost`,className:`size-9 shrink-0 px-0`,disabled:u.length<=1&&!e.key&&!e.value,onClick:()=>g(t),"aria-label":r,children:(0,$.jsx)(Ae,{className:`size-4 text-fg-subtle`,"aria-hidden":!0})})]},e.clientKey))}),(0,$.jsx)(He,{open:f,title:o,description:a,confirmLabel:s,onConfirm:()=>p(!1),onCancel:()=>p(!1)}),(0,$.jsxs)(`button`,{type:`button`,className:y(`self-start text-sm text-accent hover:underline`,P.press),onClick:h,children:[`+ `,n]})]})}var hn=[`stdio`,`streamable-http`];function gn(e){let t=(0,et.c)(11),{label:n,description:r,required:i,children:a}=e,o;t[0]===i?o=t[1]:(o=i?(0,$.jsx)(`span`,{className:`ml-0.5 text-danger`,children:`*`}):null,t[0]=i,t[1]=o);let s;t[2]!==n||t[3]!==o?(s=(0,$.jsxs)(`div`,{className:`text-sm font-medium text-fg`,children:[n,o]}),t[2]=n,t[3]=o,t[4]=s):s=t[4];let c;t[5]===r?c=t[6]:(c=r?(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-subtle`,children:r}):null,t[5]=r,t[6]=c);let l;return t[7]!==a||t[8]!==s||t[9]!==c?(l=(0,$.jsxs)(`label`,{className:`flex flex-col gap-1.5`,children:[s,a,c]}),t[7]=a,t[8]=s,t[9]=c,t[10]=l):l=t[10],l}function _n(){return y(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,L)}function vn(e){let t=(0,et.c)(42),{row:n,t:r,onUpdate:i,idConflictMessage:a,variant:o,showTransport:l}=e,u=o===void 0?`all`:o,d=l===void 0?!0:l,f=u===`all`||u===`basic`,p=u===`all`||u===`advanced`,m;t[0]!==i||t[1]!==n.transport||t[2]!==f||t[3]!==d||t[4]!==r?(m=f&&d?(0,$.jsx)($.Fragment,{children:(0,$.jsx)(gn,{label:r.transportLabel,required:!0,children:(0,$.jsx)(s,{className:_n(),value:n.transport,onChange:e=>i({transport:e.target.value}),children:hn.map(e=>(0,$.jsx)(c,{value:e,children:r.transportLabels[e]},e))})})}):null,t[0]=i,t[1]=n.transport,t[2]=f,t[3]=d,t[4]=r,t[5]=m):m=t[5];let h;t[6]!==a||t[7]!==i||t[8]!==n.id||t[9]!==p||t[10]!==r?(h=p?(0,$.jsxs)(gn,{label:r.serverIdLabel,children:[(0,$.jsx)(`input`,{className:_n(),value:n.id,placeholder:r.serverIdPlaceholder,onChange:e=>i({id:e.target.value})}),a?(0,$.jsx)(`p`,{className:`text-xs text-red-600 dark:text-red-300`,children:a}):null]}):null,t[6]=a,t[7]=i,t[8]=n.id,t[9]=p,t[10]=r,t[11]=h):h=t[11];let g;t[12]!==i||t[13]!==n.argsText||t[14]!==n.command||t[15]!==n.cwd||t[16]!==n.envJson||t[17]!==n.headers||t[18]!==n.oauthClientId||t[19]!==n.transport||t[20]!==n.url||t[21]!==p||t[22]!==f||t[23]!==r||t[24]!==u?(g=n.transport===`stdio`?(0,$.jsxs)($.Fragment,{children:[f?(0,$.jsx)(`div`,{className:u===`basic`?`md:col-span-2`:void 0,children:(0,$.jsx)(gn,{label:r.commandLabel,required:!0,children:(0,$.jsx)(`input`,{className:_n(),value:n.command,onChange:e=>i({command:e.target.value})})})}):null,f?(0,$.jsx)(gn,{label:r.argsLabel,description:r.argsHint,children:(0,$.jsx)(`input`,{className:_n(),value:n.argsText,onChange:e=>i({argsText:e.target.value})})}):null,p?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(gn,{label:r.cwdLabel,children:(0,$.jsx)(`input`,{className:_n(),value:n.cwd,onChange:e=>i({cwd:e.target.value})})}),(0,$.jsx)(gn,{label:r.envLabel,description:r.envHint,children:(0,$.jsx)(`textarea`,{className:y(_n(),`min-h-[4rem] font-mono text-xs`),value:n.envJson,onChange:e=>i({envJson:e.target.value})})})]}):null]}):(0,$.jsxs)($.Fragment,{children:[f?(0,$.jsx)(`div`,{className:`md:col-span-2`,children:(0,$.jsx)(gn,{label:r.urlLabel,required:!0,children:(0,$.jsx)(`input`,{className:y(_n(),`font-mono text-xs`),value:n.url,placeholder:`https://example.com/mcp`,onChange:e=>i({url:e.target.value})})})}):null,p?(0,$.jsx)(gn,{label:r.oauthClientIdLabel,description:r.oauthClientIdHint,children:(0,$.jsx)(`input`,{className:_n(),value:n.oauthClientId,onChange:e=>i({oauthClientId:e.target.value})})}):null,p?(0,$.jsx)(mn,{label:r.headersLabel,optionalLabel:r.optionalSuffix,addLabel:r.addHeader,removeHeaderAria:r.removeHeader,pasteLabel:r.pasteHeaders,pasteFailed:r.pasteHeadersFailed,pasteFailedTitle:r.pasteHeadersFailedTitle,dismissLabel:r.pasteHeadersDismiss,keyPlaceholder:r.headerKeyPlaceholder,valuePlaceholder:r.headerValuePlaceholder,headers:n.headers,onChange:e=>i({headers:e})}):null]}),t[12]=i,t[13]=n.argsText,t[14]=n.command,t[15]=n.cwd,t[16]=n.envJson,t[17]=n.headers,t[18]=n.oauthClientId,t[19]=n.transport,t[20]=n.url,t[21]=p,t[22]=f,t[23]=r,t[24]=u,t[25]=g):g=t[25];let _;t[26]!==i||t[27]!==n.exposure||t[28]!==p||t[29]!==r?(_=p?(0,$.jsx)(gn,{label:r.exposureLabel,children:(0,$.jsx)(s,{className:_n(),value:n.exposure,onChange:e=>i({exposure:e.target.value}),children:[`codemode`,`deferred`,`direct`,`hidden`].map(e=>(0,$.jsx)(c,{value:e,children:r.exposureLabels[e]},e))})}):null,t[26]=i,t[27]=n.exposure,t[28]=p,t[29]=r,t[30]=_):_=t[30];let v;t[31]!==i||t[32]!==n.timeout||t[33]!==p||t[34]!==r?(v=p?(0,$.jsx)(gn,{label:r.requestTimeoutLabel,children:(0,$.jsx)($e,{allowEmpty:!0,type:`number`,min:1,className:_n(),value:n.timeout??``,placeholder:`60`,onChange:e=>i({timeout:e.target.value?Number(e.target.value):void 0})})}):null,t[31]=i,t[32]=n.timeout,t[33]=p,t[34]=r,t[35]=v):v=t[35];let b;return t[36]!==m||t[37]!==h||t[38]!==g||t[39]!==_||t[40]!==v?(b=(0,$.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[m,h,g,_,v]}),t[36]=m,t[37]=h,t[38]=g,t[39]=_,t[40]=v,t[41]=b):b=t[41],b}var yn=y(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,L);function bn(e){let{t,cs:n}=e,[r,i]=(0,Q.useState)(e.initialRow),[a,o]=(0,Q.useState)(!1),[l,u]=(0,Q.useState)(``),[f,p]=(0,Q.useState)(),[g,v]=(0,Q.useState)(),[b,x]=(0,Q.useState)(!1),[S,C]=(0,Q.useState)(``),[j,M]=(0,Q.useState)([]),[P,F]=(0,Q.useState)(``),[I,L]=(0,Q.useState)(``),R=(0,Q.useRef)(e.mode===`edit`?e.initialRow.id:``),z=(0,Q.useRef)(void 0),B=(0,Q.useRef)(void 0),V=(0,Q.useRef)(null),H=(0,Q.useRef)(``),U=(0,Q.useRef)(!0),W=(0,Q.useRef)(e.onSaved);W.current=e.onSaved;let G=g?.state===`starting`||g?.state===`authorizing`,K=a||G;(0,Q.useEffect)(()=>(U.current=!0,()=>{U.current=!1,z.current?.abort(),V.current?.close(),B.current&&Ht(B.current).catch(()=>{})}),[]),(0,Q.useEffect)(()=>{if(!g||!G)return;let e=g.id,n=new AbortController,r;async function i(){try{let r=await Vt(e,n.signal);if(n.signal.aborted)return;if(v(r),r.authorizationUrl&&H.current!==r.authorizationUrl)if(H.current=r.authorizationUrl,window.electronAPI?.shell?.openExternalUrl){let e=await window.electronAPI.shell.openExternalUrl(r.authorizationUrl);e.ok||u(e.error??t.oauthOpenFailed)}else V.current&&!V.current.closed&&V.current.location.replace(r.authorizationUrl);if(r.state===`connected`){B.current=void 0,V.current?.close(),p({state:`connected`,toolCount:r.toolCount}),u(``),await W.current();return}if(r.state===`error`||r.state===`cancelled`){V.current?.close(),u(r.error??t.setupCancelled),/client.{0,20}(id|registration)|register|registration/i.test(r.error??``)&&x(!0);return}}catch(e){if(n.signal.aborted)return;u(e instanceof Error?e.message:String(e)),v(e=>e?{...e,state:`error`}:void 0),B.current&&Ht(B.current).catch(()=>{});return}r=setTimeout(()=>void i(),1200)}return i(),()=>{n.abort(),clearTimeout(r)}},[g?.id,G,t.oauthOpenFailed,t.setupCancelled]);function q(e){i(t=>({...t,...e})),p(void 0),v(void 0),u(``)}function J(){try{let t=Pt(S);M(t),q({...t[0],clientKey:e.initialRow.clientKey}),C(``)}catch(e){u(`${t.setupImportError} ${e instanceof Error?e.message:String(e)}`)}}async function ee(){o(!0),u(``),v(void 0),z.current?.abort();let a=new AbortController;z.current=a;try{let o=e.existingCustomServers.filter(t=>t.clientKey!==e.initialRow.clientKey&&t.id!==R.current),s={...r,url:r.transport===`streamable-http`?Nt(r.url):r.url};if(s.transport===`stdio`&&!s.command.trim())throw Error(t.setupCommandRequired);let c=new Set([...e.managedServerIds,...o.map(e=>e.id)]);if(s.id=s.id.trim()||Mt(s,c),[...c].some(e=>e.replace(/-/g,`_`)===s.id.replace(/-/g,`_`)))throw Error(n.duplicateServerId);if(s.extra={...s.extra,enabled:!0},await Lt({servers:[...o,s]},Dt(e.config)),R.current=s.id,!U.current)return;i(s),await W.current();let l=await zt(s.id,a.signal);if(!U.current)return;p(l),l.state===`error`&&u(l.error??t.setupConnectionFailed)}catch(e){U.current&&!a.signal.aborted&&u(e instanceof Error?e.message:String(e))}finally{U.current&&o(!1)}}async function te(){u(``),o(!0),H.current=``,window.electronAPI?.shell?.openExternalUrl||(V.current=window.open(`about:blank`,`_blank`),V.current&&(V.current.opener=null));try{let e=await Bt(R.current);if(!U.current){V.current?.close(),Ht(e.id).catch(()=>{});return}B.current=e.id,v(e)}catch(e){V.current?.close(),u(e instanceof Error?e.message:String(e))}finally{U.current&&o(!1)}}async function ne(){let e=g?.authorizationUrl;if(e)if(window.electronAPI?.shell?.openExternalUrl){let n=await window.electronAPI.shell.openExternalUrl(e);n.ok||u(n.error??t.oauthOpenFailed)}else window.open(e,`_blank`,`noopener,noreferrer`)}async function re(){if(g){u(``);try{await Ut(g.id,P),F(``)}catch(e){u(e instanceof Error?e.message:String(e))}}}function ie(e){L(e),i(t=>({...t,headers:[...t.headers.filter(e=>e.key.toLowerCase()!==`authorization`),...e.trim()?[xt(`Authorization`,/^Bearer\s/i.test(e.trim())?e.trim():`Bearer ${e.trim()}`)]:[]]})),u(``)}return(0,$.jsx)(A,{open:e.open,onOpenChange:t=>{t||e.onClose()},children:(0,$.jsxs)(D,{children:[(0,$.jsx)(w,{className:`fixed inset-0 z-[60] bg-scrim`}),(0,$.jsxs)(O,{className:`fixed left-1/2 top-1/2 z-[60] flex h-[min(42rem,calc(100dvh-2rem))] w-[min(42rem,calc(100vw-2rem))] -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-2xl border border-edge bg-surface-overlay`,children:[(0,$.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-3 border-b border-edge p-5`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(k,{className:`font-semibold`,children:t.setupTitle}),(0,$.jsx)(T,{className:`mt-1 text-sm text-fg-muted`,children:t.setupHint})]}),(0,$.jsx)(E,{asChild:!0,children:(0,$.jsx)(`button`,{className:`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover`,"aria-label":n.modalClose,children:(0,$.jsx)(_,{className:`size-5`,"aria-hidden":!0})})})]}),(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-5`,children:[(0,$.jsxs)(`fieldset`,{disabled:K,className:`min-w-0 space-y-4`,children:[(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(N,{variant:`ghost`,onClick:()=>q({transport:r.transport===`stdio`?`streamable-http`:`stdio`}),children:r.transport===`stdio`?t.setupUseUrl:t.setupUseCommand})}),(0,$.jsx)(vn,{row:r,t,variant:`basic`,showTransport:!1,onUpdate:q}),f?.state===`token_required`?(0,$.jsxs)(`label`,{className:`block space-y-1.5 text-sm font-medium text-fg`,children:[(0,$.jsx)(`span`,{children:t.setupTokenLabel}),(0,$.jsx)(`input`,{type:`password`,autoComplete:`off`,className:yn,value:I,onChange:e=>ie(e.target.value)}),(0,$.jsx)(`span`,{className:`block text-xs font-normal text-fg-muted`,children:t.setupTokenHint})]}):null,(0,$.jsxs)(`details`,{className:`rounded-lg border border-edge p-3`,open:b,onToggle:e=>x(e.currentTarget.open),children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted`,children:t.setupAdvanced}),(0,$.jsx)(`div`,{className:`mt-4`,children:(0,$.jsx)(vn,{row:r,t,variant:`advanced`,onUpdate:q})})]}),(0,$.jsxs)(`details`,{className:`rounded-lg border border-edge p-3`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted`,children:t.setupImport}),(0,$.jsxs)(`label`,{className:`mt-3 block`,children:[(0,$.jsx)(`span`,{className:`sr-only`,children:t.setupImport}),(0,$.jsx)(`textarea`,{className:y(yn,`min-h-28 font-mono text-xs`),placeholder:`{"mcpServers": {"docs": {"url": "https://example.com/mcp"}}}`,value:S,onChange:e=>C(e.target.value)})]}),(0,$.jsx)(N,{variant:`secondary`,className:`mt-2`,disabled:!S.trim(),onClick:J,children:t.setupImportAction}),j.length>1?(0,$.jsxs)(`label`,{className:`mt-3 block text-sm text-fg`,children:[(0,$.jsx)(`span`,{children:t.setupImportChoose}),(0,$.jsx)(s,{className:y(yn,`mt-1.5`),value:r.id,onChange:t=>{let n=j.find(e=>e.id===t.target.value);n&&q({...n,clientKey:e.initialRow.clientKey})},children:j.map(e=>(0,$.jsx)(c,{value:e.id,children:e.id},e.id))})]}):null]})]}),a?(0,$.jsxs)(`p`,{role:`status`,className:`mt-4 flex items-center gap-2 text-sm text-fg-muted`,children:[(0,$.jsx)(h,{className:`size-4 animate-spin`,"aria-hidden":!0}),t.setupChecking]}):null,f?.state===`connected`?(0,$.jsxs)(`p`,{role:`status`,className:`mt-4 flex items-center gap-2 text-sm text-success`,children:[(0,$.jsx)(d,{className:`size-4`,"aria-hidden":!0}),t.setupConnected.replace(`{{count}}`,String(f.toolCount??0))]}):null,f?.state===`oauth_required`&&!G&&g?.state!==`connected`?(0,$.jsx)(`p`,{className:`mt-4 text-sm text-fg-muted`,children:t.setupOAuthRequired}):null,G?(0,$.jsxs)(`div`,{className:`mt-4 space-y-3 rounded-lg border border-edge p-4`,children:[(0,$.jsxs)(`p`,{role:`status`,className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,$.jsx)(h,{className:`size-4 animate-spin`,"aria-hidden":!0}),t.setupAuthorizing]}),g?.authorizationUrl?(0,$.jsxs)(N,{variant:`secondary`,onClick:()=>void ne(),children:[(0,$.jsx)(m,{className:`size-4`,"aria-hidden":!0}),t.oauthOpenAuthorization]}):null,g?.acceptsRedirect?(0,$.jsxs)(`details`,{children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm text-accent-fg`,children:t.setupRemoteFallback}),(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:t.setupRedirectHint}),(0,$.jsxs)(`label`,{className:`mt-2 block`,children:[(0,$.jsx)(`span`,{className:`sr-only`,children:t.setupRedirectLabel}),(0,$.jsx)(`input`,{className:yn,value:P,placeholder:`http://127.0.0.1:…/callback?code=…`,onChange:e=>F(e.target.value)})]}),(0,$.jsx)(N,{className:`mt-2`,disabled:!P.trim(),onClick:()=>void re(),children:t.setupContinue})]}):null]}):null,l?(0,$.jsx)(`p`,{role:`alert`,className:`mt-4 whitespace-pre-wrap break-words text-sm text-danger`,children:l}):null]}),(0,$.jsxs)(`div`,{className:`flex shrink-0 justify-end gap-2 border-t border-edge p-4`,children:[(0,$.jsx)(N,{variant:`secondary`,onClick:e.onClose,children:n.modalCancel}),f?.state===`connected`?(0,$.jsx)(N,{onClick:e.onClose,children:t.setupDone}):f?.state===`oauth_required`?(0,$.jsx)(N,{disabled:K,"aria-busy":K,onClick:()=>void te(),children:t.setupSignIn}):(0,$.jsx)(N,{disabled:K||f?.state===`token_required`&&!I.trim()||(r.transport===`streamable-http`?!r.url.trim():!r.command.trim()),"aria-busy":K,onClick:()=>void ee(),children:t.setupConnect})]})]})]})})}var xn=`builtin`,Sn=`composio`,Cn=`xopc-store`;function wn(e){return xn}function Tn(e){let t=e.connectorManifest;if(!t||typeof t!=`object`||Array.isArray(t))return null;let n=t;if(n.contractVersion!==1||n.id!==e.name)return null;let r=n.runtime,i=n.auth;if(!r||typeof r!=`object`||Array.isArray(r)||!i||typeof i!=`object`||Array.isArray(i))return null;let a=r,o=i;if(a.type!==`mcp`||typeof a.serverId!=`string`)return null;let s=[`code`,`docs`,`browser`,`data`,`automation`,`custom`].includes(String(n.category??``))?n.category:`custom`,c=o.mode===`oauth`?{mode:`oauth`,...typeof o.clientId==`string`?{clientId:o.clientId}:{}}:o.mode===`apiKey`?{mode:`apiKey`}:{mode:`none`};return{id:e.name,version:e.latestVersion??`store`,displayName:typeof n.displayName==`string`?n.displayName:e.name,description:typeof n.description==`string`?n.description:e.description,category:s,kind:`mcp`,source:`store`,...e.branding?.iconUrl?{branding:{logoUrl:e.branding.iconUrl,source:`registry`}}:{},capabilities:Array.isArray(n.capabilities)?n.capabilities.filter(e=>typeof e==`string`):[],tags:Array.isArray(n.tags)?n.tags.filter(e=>typeof e==`string`):[`store`],auth:c,setup:n.setup&&typeof n.setup==`object`&&!Array.isArray(n.setup)?n.setup:{},runtime:{type:`mcp`,serverId:a.serverId}}}function En(e){return e.filter((e,t,n)=>n.findIndex(t=>t.id===e.id)===t)}function Dn(e){return e?.startsWith(`/`)&&!e.startsWith(`//`)?e:`/user-model`}function On({embedded:e=!1,onHeaderActionChange:t}){let n=j().filter(e=>e.format===`agent-plugin`),r=S(e=>e.language),o=v(r),s=o.connectorsSettings,c=o.mcpSettings,u=x(e=>e.conversationId),d=!!u,f=i(),[p,m]=a(),g=p.get(`understanding`)===`1`,_=Dn(p.get(`returnTo`)),b=!!p.get(`returnTo`)&&!g,C=p.get(`tab`),[w,T]=(0,Q.useState)(!g&&C===`connected`?`connected`:`discover`),E=(0,Q.useRef)(!1),[D,O]=(0,Q.useState)({catalog:[],registryCatalog:[],instances:[],loading:!0,error:null}),[k,A]=(0,Q.useState)(!1),[M,P]=(0,Q.useState)(!1),[F,L]=(0,Q.useState)(1),[R,z]=(0,Q.useState)(void 0),[B,V]=(0,Q.useState)(``),[H,W]=(0,Q.useState)(g||b?p.get(`connector`)??``:``),[J,ee]=(0,Q.useState)(wn(g?`understanding`:`default`)),[te,ne]=(0,Q.useState)(`name`),[re,ie]=(0,Q.useState)(g?`understand`:`all`),[ae,oe]=(0,Q.useState)(null),[ce,le]=(0,Q.useState)(null),[ue,Y]=(0,Q.useState)(null),[fe,pe]=(0,Q.useState)(null),[me,he]=(0,Q.useState)(null),[ge,_e]=(0,Q.useState)(null),{data:ve,mutate:X}=I(d),ye=ve?.payload?.config,xe=(0,Q.useMemo)(()=>ye===void 0?null:It(ye),[ye]),Se=xe?.servers??[],Ce=D.instances.length+Se.length+n.reduce((e,t)=>e+(t.components?.mcp.length??0),0);(0,Q.useEffect)(()=>{},[xe]);let we=(0,Q.useCallback)(async()=>{if(!u){O({catalog:[],registryCatalog:[],instances:[],loading:!1,error:null});return}O(e=>({...e,loading:!0,error:null}));try{let[e,t]=await Promise.all([We(),be()]);O(n=>({catalog:e,registryCatalog:n.registryCatalog,instances:t,loading:!1,error:null}))}catch(e){O({catalog:[],registryCatalog:[],instances:[],loading:!1,error:e instanceof Error?e.message:String(e)})}},[u]);(0,Q.useEffect)(()=>{we()},[we]),(0,Q.useEffect)(()=>{E.current||D.loading||d&&!xe||(T(g?`discover`:Ce>0?`connected`:`discover`),E.current=!0)},[d,Ce,xe,g,D.loading]);let Te=(0,Q.useCallback)(e=>{E.current=!0,T(e)},[]),Ee=(0,Q.useMemo)(()=>[{id:Sn,displayName:s.composioSourceName},{id:Cn,displayName:s.storeSourceName}],[s.composioSourceName,s.storeSourceName]),De=(0,Q.useCallback)(async e=>{if(!d||J===`builtin`){O(e=>({...e,registryCatalog:[]})),L(1),z(void 0);return}let t=H.trim(),n=Math.max(e?.page??1,1),r=e?.append??!1,i=J===`all`?Ee:Ee.filter(e=>e.id===J);if(i.length!==0){A(!0),r?O(e=>({...e,error:null})):(L(1),z(void 0),O(e=>({...e,registryCatalog:[],error:null})));try{let e=await Promise.all(i.map(async e=>{if(e.id===`composio`){let e=await G({q:t||void 0,page:n,pageSize:24,verification:`experimental`});return{connectors:e.connectors,totalPages:e.meta.totalPages}}let r=await q({q:t||void 0,page:n,pageSize:24,sort:te===`source`?`newest`:`downloads`});return{connectors:r.items.flatMap(e=>{let t=Tn(e);return t?[t]:[]}),totalPages:r.meta.totalPages}})),a=En(e.flatMap(e=>e.connectors)),o=Math.max(1,...e.map(e=>e.totalPages??1));L(n),z(o),O(e=>({...e,registryCatalog:r?En([...e.registryCatalog,...a]):a}))}catch(e){O(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{A(!1)}}},[te,H,J,d,Ee]);(0,Q.useEffect)(()=>{if(w!==`discover`||D.loading)return;if(J===`builtin`){O(e=>({...e,registryCatalog:[]})),L(1),z(void 0);return}let e=window.setTimeout(()=>{De()},H.trim()?350:0);return()=>window.clearTimeout(e)},[H,J,De,D.loading,w]);let Oe=(0,Q.useMemo)(()=>new Set(D.instances.map(e=>e.connectorId)),[D.instances]),Z=(0,Q.useMemo)(()=>new Map([...D.catalog,...D.registryCatalog].map(e=>[e.id,e])),[D.catalog,D.registryCatalog]);(0,Q.useEffect)(()=>{if(D.loading)return;let e=p.get(`connector`),t=p.get(`instance`);if(!e&&!t)return;let n=D.instances.find(n=>t?n.instanceId===t:n.connectorId===e);if(n)E.current=!0,V(``),Y(n.instanceId),pe(n),T(`connected`);else if(e){let t=Z.get(e);if(!t)return;E.current=!0,ee(wn(g?`understanding`:`default`)),W(``),le(t),T(`discover`)}let r=new URLSearchParams(p);r.delete(`connector`),r.delete(`instance`),r.set(`tab`,n?`connected`:`discover`),m(r,{replace:!0})},[Z,g,p,m,D.instances,D.loading]);let ke=(0,Q.useCallback)(async e=>{P(!0),O(e=>({...e,error:null}));try{let t=await K(e);oe(Re(t.definition,{packageName:t.packageName,version:t.version,reviewHash:t.reviewHash,permissions:t.permissions}))}catch(e){O(t=>({...t,error:e instanceof Error?e.message:String(e)}))}finally{P(!1)}},[]),Ae=(0,Q.useMemo)(()=>new Set(D.instances.flatMap(e=>e.materialized.type===`mcp`?[e.materialized.serverId]:[])),[D.instances]),je=(0,Q.useCallback)(async e=>{!xe||ye===void 0||(await Lt({servers:Se.filter(t=>t.clientKey!==e.clientKey)},Dt(ye)),await X(),await we())},[ye,Se,we,xe,X]),Me=(0,Q.useCallback)(()=>{_e({mode:`add`,row:fn(Se,Ae)})},[Se,Ae]),Ne=Ve(e=>e.setPageHeader),Fe=Ve(e=>e.clearPageHeader),Le=(0,Q.useMemo)(()=>({searchLabel:w===`connected`?s.connectedSearchPlaceholder:s.discoverSearchPlaceholder,search:(0,$.jsx)(Je,{value:w===`connected`?B:H,onChange:w===`connected`?V:W,placeholder:w===`connected`?s.connectedSearchPlaceholder:s.discoverSearchPlaceholder}),secondary:(0,$.jsx)(bt,{onRefresh:w===`connected`&&d?we:void 0,refreshing:D.loading,refreshLabel:s.refreshConnections,onBrowseCatalog:()=>Te(`discover`),onAddCustomServer:Me,addLabel:s.addConnection,browseLabel:s.addFromCatalog,customLabel:s.addCustomServerAdvanced,serviceLabel:r.startsWith(`zh`)?`应用连接服务`:`Connection service`,moreActionsLabel:o.capabilitiesHub.moreActions})}),[B,s,H,d,r,we,o.capabilitiesHub.moreActions,Me,Te,D.loading,w]);(0,Q.useLayoutEffect)(()=>e?(t?.(Le),()=>t?.(null)):(Ne({startExtra:null,main:(0,$.jsx)(`div`,{className:`min-w-0`,children:(0,$.jsx)(`h1`,{className:`truncate text-base font-semibold tracking-tight text-fg`,children:s.title})}),end:(0,$.jsx)(Ye,{contribution:Le})}),()=>Fe()),[Fe,s.title,e,Le,t,Ne]);let ze=(0,Q.useMemo)(()=>D.instances.map(e=>({instance:e,value:ft(e,Z.get(e.connectorId))})),[Z,D.instances]),Be=(0,Q.useMemo)(()=>new Map(ze.map(({instance:e,value:t})=>[e.instanceId,t])),[ze]),He=(0,Q.useMemo)(()=>D.instances.filter(e=>Pe(e,B)).sort((e,t)=>{let n={needs_setup:0,checking:1,ready:2},r=Be.get(e.instanceId)?.state??`checking`,i=Be.get(t.instanceId)?.state??`checking`;return n[r]-n[i]||e.displayName.localeCompare(t.displayName)}),[B,Be,D.instances]),Ue=(0,Q.useMemo)(()=>He.filter(e=>Be.get(e.instanceId)?.state===`needs_setup`),[Be,He]),Ge=(0,Q.useMemo)(()=>He.filter(e=>Be.get(e.instanceId)?.state!==`needs_setup`),[Be,He]),Ke=(0,Q.useMemo)(()=>Se.filter(e=>Ie(e,B)),[B,Se]),qe=(0,Q.useMemo)(()=>{let e=B.trim().toLowerCase();return n.flatMap(t=>(t.components?.mcp??[]).filter(n=>`${t.name} ${n.name}`.toLowerCase().includes(e)).map(e=>({extension:t,server:e})))},[B,n]),Xe=He.length+Ke.length+qe.length,$e=(0,Q.useMemo)(()=>D.catalog.filter(e=>e.source===`builtin`&&e.integrationStrategy?.preferred!==!1&&de(e)),[D.catalog]),et=(0,Q.useMemo)(()=>J===`builtin`?$e:J===`all`?En([...$e,...D.registryCatalog]):D.registryCatalog,[$e,J,D.registryCatalog]),nt=(0,Q.useMemo)(()=>{let e=g?et.filter(e=>e.understanding?.mode===`activity`):et;return U(re===`all`?e:e.filter(e=>ut(e).includes(re)),H,te)},[te,H,et,g,re]),at=(0,Q.useMemo)(()=>lt.filter(e=>et.some(t=>ut(t).includes(e))),[et]);(0,Q.useEffect)(()=>{re!==`all`&&!at.includes(re)&&ie(`all`)},[at,re]);let st=w===`discover`&&J!==`builtin`&&!!(R&&F<R),dt=(0,Q.useMemo)(()=>D.instances.find(e=>e.instanceId===ue)??fe,[ue,fe,D.instances]),pt=(0,Q.useMemo)(()=>[{value:`all`,label:s.discoverSourceAll},{value:xn,label:s.discoverSourceBuiltin},...Ee.map(e=>({value:e.id,label:e.displayName}))],[s.discoverSourceAll,s.discoverSourceBuiltin,Ee]),mt=[{id:`connected`,label:s.tabConnected,count:Ce},{id:`discover`,label:s.tabDiscover}];return(0,$.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-1 flex-col bg-surface-panel`,children:(0,$.jsxs)(`div`,{className:y(`mx-auto flex w-full max-w-7xl flex-col gap-6 px-4 sm:px-6 lg:px-8`,e?`pb-7 pt-3 lg:pb-9 lg:pt-4`:`py-7 lg:py-9`),children:[d?null:(0,$.jsx)(`p`,{className:`rounded-xl border border-edge bg-surface-panel px-4 py-3 text-sm text-fg-muted`,children:s.tokenHint}),g?(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border border-accent/25 bg-accent-soft px-4 py-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:s.understandingSetupTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:s.understandingSetupHint})]}),(0,$.jsx)(N,{type:`button`,variant:`secondary`,className:`shrink-0`,onClick:()=>f(_),children:s.understandingSetupDone})]}):null,b?(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border border-accent/25 bg-accent-soft px-4 py-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`p`,{className:`text-sm font-semibold text-fg`,children:s.recoverySetupTitle}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:s.recoverySetupHint})]}),(0,$.jsx)(N,{type:`button`,variant:`secondary`,className:`min-h-11 shrink-0`,onClick:()=>f(_),children:s.recoverySetupDone})]}):null,(0,$.jsxs)(`section`,{className:`flex flex-col gap-4`,children:[(0,$.jsx)(`div`,{className:`border-b border-edge-subtle pb-3 dark:border-edge-subtle`,children:(0,$.jsx)(Ze,{items:mt,activeTab:w,onChange:Te,ariaLabel:s.navAria,tabIdPrefix:`connectors-tab`,panelIdPrefix:`connectors-panel`,className:`flex-wrap`})}),D.error?(0,$.jsx)(`p`,{className:`rounded-xl bg-red-500/10 px-3 py-2 text-sm text-red-600`,children:D.error}):null,w===`connected`&&d?(0,$.jsx)(`div`,{className:`flex flex-col gap-6`,children:D.loading?(0,$.jsx)(`div`,{className:`grid gap-3`,"aria-busy":`true`,"aria-label":s.loading,children:rt.slice(0,3).map(e=>(0,$.jsx)(ct,{},e))}):Ce===0?(0,$.jsxs)(`div`,{className:`py-14 text-center`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:s.connectionsEmpty}),(0,$.jsx)(N,{type:`button`,variant:`primary`,className:`mt-4`,onClick:()=>Te(`discover`),children:s.addFromCatalog})]}):Xe===0?(0,$.jsx)(`div`,{className:`py-14 text-center text-sm text-fg-muted`,children:s.connectionsSearchEmpty}):(0,$.jsxs)(`div`,{className:`space-y-6`,children:[Ue.length?(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:s.needsAttentionTitle}),(0,$.jsx)(`span`,{className:`text-xs tabular-nums text-amber-700 dark:text-amber-300`,children:Ue.length})]}),(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-xl border border-amber-500/25 bg-amber-500/5`,children:Ue.map(e=>(0,$.jsx)(dn,{instance:e,definition:Z.get(e.connectorId),highlighted:e.instanceId===me,onOpenDetails:e=>{he(null),Y(e.instanceId),pe(e)},t:s},e.instanceId))})]}):null,Ge.length?(0,$.jsx)(`section`,{children:(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle overflow-hidden rounded-xl border border-edge bg-surface-base`,children:Ge.map(e=>(0,$.jsx)(dn,{instance:e,definition:Z.get(e.connectorId),highlighted:e.instanceId===me,onOpenDetails:e=>{he(null),Y(e.instanceId),pe(e)},t:s},e.instanceId))})}):null,qe.map(({extension:e,server:t})=>(0,$.jsx)(Qe,{pluginId:e.pluginId,server:t,enabled:e.active},t.id)),Ke.length||!B.trim()?(0,$.jsxs)(`details`,{className:`rounded-xl border border-edge bg-surface-base`,children:[(0,$.jsxs)(`summary`,{className:`cursor-pointer px-4 py-3`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:s.customIntegrationsTitle}),(0,$.jsx)(`span`,{className:`ml-2 text-xs tabular-nums text-fg-subtle`,children:Ke.length}),(0,$.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:s.customIntegrationsHint})]}),(0,$.jsxs)(`div`,{className:`border-t border-edge-subtle`,children:[(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2 px-4 py-3`,children:(0,$.jsx)(N,{type:`button`,variant:`secondary`,className:`h-8 text-xs`,onClick:Me,children:s.addCustomServerAdvanced})}),(0,$.jsx)(`div`,{className:`divide-y divide-edge-subtle`,children:Ke.map(e=>(0,$.jsx)(Jt,{row:e,t:c,cs:s,onEdit:()=>_e({mode:`edit`,row:structuredClone(e)}),onRemove:async()=>je(e)},e.clientKey))})]})]}):null]})}):null,w===`discover`&&d?(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[g?null:(0,$.jsx)(`div`,{className:`flex min-w-0 flex-1 basis-80 flex-wrap gap-2`,role:`group`,"aria-label":s.taskFilterAria,children:[`all`,...at].map(e=>(0,$.jsx)(`button`,{type:`button`,className:y(`rounded-full border px-3 py-1.5 text-xs font-medium transition-colors`,re===e?`border-accent/40 bg-accent-soft text-accent-fg`:`border-edge bg-surface-panel text-fg-muted hover:bg-surface-hover hover:text-fg`),"aria-pressed":re===e,onClick:()=>ie(e),children:e===`all`?s.taskAll:s.connectorBenefitHeadings[e]},e))}),(0,$.jsxs)(`div`,{className:y(`ml-auto grid w-full gap-2 sm:flex sm:w-auto sm:justify-end`,g?`grid-cols-1`:`grid-cols-2`),children:[g?null:(0,$.jsx)(`div`,{className:`min-w-0 sm:w-40`,children:(0,$.jsx)(l,{value:J,options:pt,placeholder:s.discoverSourceAll,allowEmpty:!1,ariaLabel:s.registrySourceAria,triggerClassName:`h-9 bg-surface-panel text-xs`,onChange:ee})}),(0,$.jsx)(`div`,{className:`min-w-0 sm:w-40`,children:(0,$.jsx)(l,{value:te,options:[{value:`name`,label:s.sortName},{value:`source`,label:s.sortSource}],placeholder:s.sortName,allowEmpty:!1,ariaLabel:s.sortAria,triggerClassName:`h-9 bg-surface-panel text-xs`,onChange:e=>ne(e)})})]})]}),(D.loading||k)&&nt.length===0?(0,$.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,"aria-busy":`true`,"aria-label":s.loading,children:rt.map(e=>(0,$.jsx)(ot,{},e))}):nt.length===0?(0,$.jsx)(`div`,{className:`py-14 text-center text-sm text-fg-muted`,children:s.discoverEmpty}):(0,$.jsxs)(`div`,{className:`relative`,children:[k?(0,$.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-[1] flex justify-center bg-surface-panel/40 pt-[min(28vh,7.5rem)] backdrop-blur-[1px] motion-reduce:backdrop-blur-none dark:bg-surface-base/35`,"aria-busy":`true`,"aria-label":s.loading,children:(0,$.jsx)(h,{className:`size-8 shrink-0 animate-spin text-accent motion-reduce:animate-none`,strokeWidth:2,"aria-hidden":!0})}):null,(0,$.jsx)(`div`,{className:`grid gap-4 sm:grid-cols-2 xl:grid-cols-3`,children:nt.map(e=>(0,$.jsx)(tt,{connector:e,installed:Oe.has(e.id)||it(e,D.instances),onInstall:e=>{if(e.source===`store`){ke(e.id);return}oe(Re(e))},onOpenDetails:e.source===`store`?void 0:le,t:s},e.id))}),st?(0,$.jsx)(`div`,{className:`mt-4 flex justify-center`,children:(0,$.jsxs)(N,{type:`button`,variant:`secondary`,disabled:k||M,onClick:()=>void De({page:F+1,append:!0}),children:[k?(0,$.jsx)(h,{className:`size-4 animate-spin`}):null,s.loadMore]})}):null]})]}):null]}),ae?(0,$.jsx)(se,{draft:ae,onChange:oe,onClose:()=>oe(null),t:s,onInstalled:async e=>{await we(),await X(),he(e.instanceId),Te(`connected`)}}):null,ce?(0,$.jsx)(gt,{connector:ce,installed:Oe.has(ce.id)||it(ce,D.instances),onClose:()=>le(null),onInstall:e=>oe(Re(e)),t:s}):null,dt?(0,$.jsx)(un,{instance:dt,definition:Z.get(dt.connectorId),onClose:()=>{Y(null),pe(null)},onChanged:we,t:s,mcp:c}):null,ge?(0,$.jsx)(bn,{open:!0,mode:ge.mode,initialRow:ge.row,existingCustomServers:Se,config:ye,managedServerIds:Ae,t:c,cs:s,onClose:()=>_e(null),onSaved:async()=>{await X(),await we(),Te(`connected`)}},`${ge.mode}-${ge.row.clientKey}`):null]})})}export{On as ConnectorsPage};