@xopcai/xopc 0.0.450 → 0.0.451

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 (231) 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-Tn5McYcg.js → activity-store-OMq1GnqB.js} +1 -1
  4. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-BX5HhrTI.js → agent-avatar-dicebear-CIoE-FJR.js} +1 -1
  5. package/dist/gateway/static/root/assets/{agent-avatar-display-C7Dx9nt1.js → agent-avatar-display-kPb6idGG.js} +2 -2
  6. package/dist/gateway/static/root/assets/{agent-defaults-settings-panel-AAJsxEjB.js → agent-defaults-settings-panel-vKUDGEU6.js} +1 -1
  7. package/dist/gateway/static/root/assets/{agent-plugin-dialog-BhtzU8qr.js → agent-plugin-dialog-x7guoCvz.js} +1 -1
  8. package/dist/gateway/static/root/assets/{agents-CbGYb9WI.js → agents-BbwFcl87.js} +3 -3
  9. package/dist/gateway/static/root/assets/{agents-admin-api-CShyoj9I.js → agents-admin-api-tXB8Aj5K.js} +1 -1
  10. package/dist/gateway/static/root/assets/{api-B3M6ifoo.js → api-DIKAjDAK.js} +1 -1
  11. package/dist/gateway/static/root/assets/{api-BET9vZ1l.js → api-ixudT_21.js} +1 -1
  12. package/dist/gateway/static/root/assets/{app-management-settings-panel-BxOShFPO.js → app-management-settings-panel-nuDfyfZ5.js} +1 -1
  13. package/dist/gateway/static/root/assets/{appearance-settings-L450QlMW.js → appearance-settings-D4oON26V.js} +1 -1
  14. package/dist/gateway/static/root/assets/{apps-page-Bz6_fyMs.js → apps-page-BM1BfXzo.js} +1 -1
  15. package/dist/gateway/static/root/assets/{archive-plugin-BCXEOal7.js → archive-plugin-mKjfC6Sk.js} +1 -1
  16. package/dist/gateway/static/root/assets/{automation-api-B3Jnoa2G.js → automation-api-C9pjryrT.js} +1 -1
  17. package/dist/gateway/static/root/assets/{automation-result-state-BHAKc5QI.js → automation-result-state-uvg7Bi2x.js} +1 -1
  18. package/dist/gateway/static/root/assets/{automation-run-list-De7gini_.js → automation-run-list-J-R4-hVm.js} +1 -1
  19. package/dist/gateway/static/root/assets/{automation-task-card-Clf0fe_n.js → automation-task-card-CXGC8afU.js} +1 -1
  20. package/dist/gateway/static/root/assets/{automations-page-BEG5xLew.js → automations-page-CwQg9dfM.js} +1 -1
  21. package/dist/gateway/static/root/assets/{automations-workspace-Cfq1C6XB.js → automations-workspace-DhLgFY2T.js} +2 -2
  22. package/dist/gateway/static/root/assets/{binary-plugins-B7tuUWzS.js → binary-plugins-BNPDM14i.js} +1 -1
  23. package/dist/gateway/static/root/assets/{block-editor-D-YHASZr.js → block-editor-De9UqmMT.js} +1 -1
  24. package/dist/gateway/static/root/assets/{browser-settings-page-DdMMia7Y.js → browser-settings-page-B0VB5umC.js} +1 -1
  25. package/dist/gateway/static/root/assets/{capabilities-Cxh3nYa6.js → capabilities-BtJB4u5C.js} +1 -1
  26. package/dist/gateway/static/root/assets/{capabilities-YfkMBZCb.js → capabilities-Cp-rmFMM.js} +1 -1
  27. package/dist/gateway/static/root/assets/{capabilities-page-CSBeVda0.js → capabilities-page-KRaK8LKT.js} +2 -2
  28. package/dist/gateway/static/root/assets/capabilities-settings-panel-aJy-1o5H.js +8 -0
  29. package/dist/gateway/static/root/assets/{channels-DdSEH-R2.js → channels-ZJORx-he.js} +1 -1
  30. package/dist/gateway/static/root/assets/{chat-agents-api-CgasFAm4.js → chat-agents-api-CtuEaDG8.js} +1 -1
  31. package/dist/gateway/static/root/assets/{chat-chart-block-Cgks7rH3.js → chat-chart-block-ShPQBlNE.js} +1 -1
  32. package/dist/gateway/static/root/assets/{chat-page-BKLyj4IP.js → chat-page-QmBfel_Z.js} +22 -22
  33. package/dist/gateway/static/root/assets/{chat-terminal-dock-aCu4X5Jo.js → chat-terminal-dock-CvDRfHAZ.js} +1 -1
  34. package/dist/gateway/static/root/assets/{command-palette-api-Bku_h283.js → command-palette-api-NJTvEF2b.js} +1 -1
  35. package/dist/gateway/static/root/assets/composer-notifications-BkezOy9Q.js +1 -0
  36. package/dist/gateway/static/root/assets/composer-payload-handoff-CEjJusbJ.js +1 -0
  37. package/dist/gateway/static/root/assets/{computer-settings-page-zvWUPPAr.js → computer-settings-page-DG8bcw_s.js} +1 -1
  38. package/dist/gateway/static/root/assets/{connected-providers-grid-w3htbAyh.js → connected-providers-grid-BWVieU6P.js} +1 -1
  39. package/dist/gateway/static/root/assets/{connection-usage-guide-DL2T6cSN.js → connection-usage-guide-f55PDAbb.js} +1 -1
  40. package/dist/gateway/static/root/assets/{connector-service-page-a0gQC-nc.js → connector-service-page-Ca09FIBW.js} +1 -1
  41. package/dist/gateway/static/root/assets/{connectors-api-DNVUmf9M.js → connectors-api-dai-YAdK.js} +1 -1
  42. package/dist/gateway/static/root/assets/{connectors-page-D1VzTxON.js → connectors-page-C8M01Zxs.js} +1 -1
  43. package/dist/gateway/static/root/assets/{date-picker-E0cqnNlR.js → date-picker-C70ICT7u.js} +1 -1
  44. package/dist/gateway/static/root/assets/{date-time-picker-CrC_VKpw.js → date-time-picker-Czj5fnsJ.js} +1 -1
  45. package/dist/gateway/static/root/assets/{desktop-pet-D1MkNl5F.js → desktop-pet-Dq3OLpPg.js} +1 -1
  46. package/dist/gateway/static/root/assets/{desktop-pet-settings-BA6u5Md-.js → desktop-pet-settings-q4mec6zt.js} +1 -1
  47. package/dist/gateway/static/root/assets/{dev-view-store-DnqJb6NS.js → dev-view-store-lXnKsRew.js} +1 -1
  48. package/dist/gateway/static/root/assets/{device-pairing-wizard-Ba3d606o.js → device-pairing-wizard-CbUX0iit.js} +1 -1
  49. package/dist/gateway/static/root/assets/{directory-picker-path-field-lcps-hsZ.js → directory-picker-path-field-BRnwhemd.js} +1 -1
  50. package/dist/gateway/static/root/assets/{discussion-annotation-sync-BmvCn1Xn.js → discussion-annotation-sync-BnK6Ua7v.js} +1 -1
  51. package/dist/gateway/static/root/assets/{extension-debug-page-BOJbNj9D.js → extension-debug-page-Bp2BrJbB.js} +1 -1
  52. package/dist/gateway/static/root/assets/{extension-iframe-host-pbU7DAfE.js → extension-iframe-host-DjXDDmUd.js} +1 -1
  53. package/dist/gateway/static/root/assets/{extension-marketplace-api-BrLsjJLA.js → extension-marketplace-api-tk93vJL_.js} +1 -1
  54. package/dist/gateway/static/root/assets/{extension-page-BrX4Hy9P.js → extension-page-CGgneUDY.js} +1 -1
  55. package/dist/gateway/static/root/assets/{extension-provider-DUzhV5_a.js → extension-provider-BktGTwH_.js} +1 -1
  56. package/dist/gateway/static/root/assets/{extension-settings-page-BuV-Vuvb.js → extension-settings-page-BGcZIeHP.js} +1 -1
  57. package/dist/gateway/static/root/assets/{file-preview-surface-B3nLuoQO.js → file-preview-surface-BK2_4mWy.js} +1 -1
  58. package/dist/gateway/static/root/assets/{gateway-config-swr-CtZy1Qw0.js → gateway-config-swr-DsXilOaJ.js} +1 -1
  59. package/dist/gateway/static/root/assets/{gateway-realtime-CG65gHUY.js → gateway-realtime-DopPmAMl.js} +1 -1
  60. package/dist/gateway/static/root/assets/gateway-realtime-store-ZxMFPH4n.js +1 -0
  61. package/dist/gateway/static/root/assets/{gateway-restart-Cr5xtfZU.js → gateway-restart-eozrXTm7.js} +1 -1
  62. package/dist/gateway/static/root/assets/{gateway-settings-BwMwdwXh.js → gateway-settings-DddUli-p.js} +1 -1
  63. package/dist/gateway/static/root/assets/{gateway-startup-retry-DztAHGru.js → gateway-startup-retry-DMQI0ATo.js} +1 -1
  64. package/dist/gateway/static/root/assets/{global-defaults-api-yHc-ZfjU.js → global-defaults-api-D7hk1zTj.js} +1 -1
  65. package/dist/gateway/static/root/assets/home-page-C8oVgxQg.js +3 -0
  66. package/dist/gateway/static/root/assets/{image-generation-api-D5eo_stq.js → image-generation-api-BCbvDDH_.js} +1 -1
  67. package/dist/gateway/static/root/assets/imports-page-B9LF_2fO.js +1 -0
  68. package/dist/gateway/static/root/assets/index-CPXKrqLj.js +11 -0
  69. package/dist/gateway/static/root/assets/index-Dc-3QQaz.css +1 -0
  70. package/dist/gateway/static/root/assets/{install-connector-dialog-B-v1FT3P.js → install-connector-dialog-DT32t-66.js} +1 -1
  71. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-BLBASsCP.js → keyboard-shortcuts-settings-DDwoBK8g.js} +1 -1
  72. package/dist/gateway/static/root/assets/{local-app-workbench-page-3J9ABnCu.js → local-app-workbench-page-CnckB-RA.js} +1 -1
  73. package/dist/gateway/static/root/assets/{local-apps-page-Db93n4Zy.js → local-apps-page-qzxr3c8Y.js} +1 -1
  74. package/dist/gateway/static/root/assets/{local-session-drafts-C6oPrCYY.js → local-session-drafts-BU3FXj_X.js} +1 -1
  75. package/dist/gateway/static/root/assets/{locale-store-CQcW9_qA.js → locale-store-DTUQ0JiK.js} +1 -1
  76. package/dist/gateway/static/root/assets/logs-page-_nIEwZn4.js +2 -0
  77. package/dist/gateway/static/root/assets/{management-api-Dh2r5GrQ.js → management-api-C6mCD0mZ.js} +1 -1
  78. package/dist/gateway/static/root/assets/{management-settings-Fj25fafb.js → management-settings-C4BKD-_b.js} +1 -1
  79. package/dist/gateway/static/root/assets/{markdown-view-CkihBz06.js → markdown-view-DHjn1-ML.js} +1 -1
  80. package/dist/gateway/static/root/assets/{mcp-conversation-setup-page-jh3dwNfg.js → mcp-conversation-setup-page-ClgMvru5.js} +1 -1
  81. package/dist/gateway/static/root/assets/{media-plugins-BUapXtQZ.js → media-plugins-8E2KZQym.js} +1 -1
  82. package/dist/gateway/static/root/assets/{messages-orB1BMgI.js → messages-C7ruaWtK.js} +3 -3
  83. package/dist/gateway/static/root/assets/{model-selector-DYxgKUju.js → model-selector-CJY9LRsl.js} +1 -1
  84. package/dist/gateway/static/root/assets/{models-hub-cache-D2cdb8nZ.js → models-hub-cache-BTs8jhgq.js} +1 -1
  85. package/dist/gateway/static/root/assets/{note-detail-panel-BMtKrv-J.js → note-detail-panel-DiCfpcZd.js} +3 -3
  86. package/dist/gateway/static/root/assets/note-image-lightbox-kccIXJo_.js +1 -0
  87. package/dist/gateway/static/root/assets/{notes-api-BhRyWe3S.js → notes-api-BnaeXy22.js} +1 -1
  88. package/dist/gateway/static/root/assets/{notes-page-DcmRJJbt.js → notes-page-B_vTBmyx.js} +2 -2
  89. package/dist/gateway/static/root/assets/{oauth-api-D5iBtOid.js → oauth-api-BZ67vxsq.js} +1 -1
  90. package/dist/gateway/static/root/assets/{oauth-provider-connect-CmHsHynu.js → oauth-provider-connect-CZP15znW.js} +1 -1
  91. package/dist/gateway/static/root/assets/{open-capability-settings-Cvb65hQB.js → open-capability-settings-DQsmJxI7.js} +1 -1
  92. package/dist/gateway/static/root/assets/{page-context-capture-button-CTHQWfG6.js → page-context-capture-button-TpjRHhUt.js} +1 -1
  93. package/dist/gateway/static/root/assets/{page-context-draft-aApa5ApP.js → page-context-draft-BbUpxlgV.js} +1 -1
  94. package/dist/gateway/static/root/assets/page-header-store-CFntbsPj.js +1 -0
  95. package/dist/gateway/static/root/assets/{personal-avatar-Dp5LHjk3.js → personal-avatar-CVocefDp.js} +1 -1
  96. package/dist/gateway/static/root/assets/personal-page-BjnSgU89.js +1 -0
  97. package/dist/gateway/static/root/assets/{personal-settings-panel-CtJL6qIN.js → personal-settings-panel-CdMHSPCH.js} +1 -1
  98. package/dist/gateway/static/root/assets/{phone-dependencies-card-BBk6k0t0.js → phone-dependencies-card-ChRrViSc.js} +1 -1
  99. package/dist/gateway/static/root/assets/{phone-model-connection-QJt8SAb7.js → phone-model-connection-DmswEWqx.js} +1 -1
  100. package/dist/gateway/static/root/assets/{phone-model-picker-CRxUxJNZ.js → phone-model-picker-CvuOhQpk.js} +1 -1
  101. package/dist/gateway/static/root/assets/{phone-settings-page-Df64khPY.js → phone-settings-page-2hZ68I47.js} +1 -1
  102. package/dist/gateway/static/root/assets/{phone-workspace-store-DAuPd2ie.js → phone-workspace-store-BMvxfZ3g.js} +1 -1
  103. package/dist/gateway/static/root/assets/{plugin-details-dialog-Bcer4RC3.js → plugin-details-dialog-qvdi41L2.js} +1 -1
  104. package/dist/gateway/static/root/assets/{preference-select-fields-DdV7q9Bd.js → preference-select-fields-RDatqlhG.js} +1 -1
  105. package/dist/gateway/static/root/assets/{product-automation-feedback-uKndNxpU.js → product-automation-feedback-Bj9ZsasT.js} +1 -1
  106. package/dist/gateway/static/root/assets/{product-open-page-A7lyoXVv.js → product-open-page-CzXmn2MX.js} +1 -1
  107. package/dist/gateway/static/root/assets/{product-preview-content-BrdvkWOg.js → product-preview-content-Beg0t4GW.js} +1 -1
  108. package/dist/gateway/static/root/assets/{product-preview-modal-BxHKejcX.js → product-preview-modal-5ulFfVzf.js} +2 -2
  109. package/dist/gateway/static/root/assets/project-detail-page-8bnYqXLJ.js +7 -0
  110. package/dist/gateway/static/root/assets/{project-understanding-BVhSoQHu.js → project-understanding-CXf7wjwt.js} +1 -1
  111. package/dist/gateway/static/root/assets/{projects-page-DSPoyFda.js → projects-page-CyA6fCPg.js} +1 -1
  112. package/dist/gateway/static/root/assets/{providers-api-B47s6_9Q.js → providers-api-DE7kdeXc.js} +1 -1
  113. package/dist/gateway/static/root/assets/{recording-upload-B-IHTsVC.js → recording-upload-BZvpuPZT.js} +1 -1
  114. package/dist/gateway/static/root/assets/{registry-api-Bo8YiUE0.js → registry-api-C_8-f85U.js} +1 -1
  115. package/dist/gateway/static/root/assets/{remote-access-hub-BRf9znLV.js → remote-access-hub-Daxdjqs9.js} +1 -1
  116. package/dist/gateway/static/root/assets/{resource-unavailable-CAljzZx8.js → resource-unavailable-khPb8zb8.js} +1 -1
  117. package/dist/gateway/static/root/assets/route-preload-DGMUu3pm.js +2 -0
  118. package/dist/gateway/static/root/assets/{runtime-tools-api-C28pB9__.js → runtime-tools-api-2YumRxOJ.js} +1 -1
  119. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-XYeadnhL.js → runtime-tools-settings-panel-DH00p-rI.js} +1 -1
  120. package/dist/gateway/static/root/assets/{schema-form-CtRM41Re.js → schema-form-C9TYGa0_.js} +1 -1
  121. package/dist/gateway/static/root/assets/secret-input-DsjfQmDn.js +1 -0
  122. package/dist/gateway/static/root/assets/{service-recommendation-list-C6ydoBSU.js → service-recommendation-list-wXf_ZlHq.js} +1 -1
  123. package/dist/gateway/static/root/assets/{session-api-D7FWdG43.js → session-api-Dt7vRa-E.js} +1 -1
  124. package/dist/gateway/static/root/assets/session-channel-icon-BzkFo-Ci.js +1 -0
  125. package/dist/gateway/static/root/assets/{session-identity-label-BP7OIYth.js → session-identity-label-D5SAi0Uh.js} +1 -1
  126. package/dist/gateway/static/root/assets/{session-manager-C1T7WiP7.js → session-manager-5qokJQ6W.js} +1 -1
  127. package/dist/gateway/static/root/assets/{sessions-page-CyYkCsfy.js → sessions-page-CCcpMHIH.js} +1 -1
  128. package/dist/gateway/static/root/assets/settings-advanced-gate-B7-XQiJh.js +1 -0
  129. package/dist/gateway/static/root/assets/{settings-advanced-section-3HwfHbqz.js → settings-advanced-section-DRlQdj_w.js} +1 -1
  130. package/dist/gateway/static/root/assets/{settings-mode-store-BVvIXZlg.js → settings-mode-store-BE6t--iO.js} +1 -1
  131. package/dist/gateway/static/root/assets/{settings-page-C6ypo-jn.js → settings-page-_F2d9-GZ.js} +1 -1
  132. package/dist/gateway/static/root/assets/{settings-page-header-CheboxIM.js → settings-page-header-DG3MQwSF.js} +1 -1
  133. package/dist/gateway/static/root/assets/{settings-page-layout-CPFMZaLF.js → settings-page-layout-SuMAUhMb.js} +1 -1
  134. package/dist/gateway/static/root/assets/{setup-interaction-page-BbCzYq9S.js → setup-interaction-page-DyDiHKjZ.js} +1 -1
  135. package/dist/gateway/static/root/assets/{setup-status-panel-DUNgVqtz.js → setup-status-panel-CPNFWhrr.js} +1 -1
  136. package/dist/gateway/static/root/assets/{share-link-dialog-0P9ghttc.js → share-link-dialog-wu-minYF.js} +1 -1
  137. package/dist/gateway/static/root/assets/share-preview-page-BqbfuQBU.js +2 -0
  138. package/dist/gateway/static/root/assets/{shares-api-iiw4F-ra.js → shares-api-DwsEzRc6.js} +1 -1
  139. package/dist/gateway/static/root/assets/{shares-settings-BQ1qXAJn.js → shares-settings-BxutiB6Y.js} +1 -1
  140. package/dist/gateway/static/root/assets/{skill-api-CLtIjE8K.js → skill-api-C7wPB73H.js} +1 -1
  141. package/dist/gateway/static/root/assets/{skill-list-api-DY0rRlUk.js → skill-list-api-C4AjzhlY.js} +1 -1
  142. package/dist/gateway/static/root/assets/{skill-reload-api-DJC8uWLu.js → skill-reload-api-CqfS9zlG.js} +1 -1
  143. package/dist/gateway/static/root/assets/{skills-page-CQYf7s9f.js → skills-page-8VYadExR.js} +1 -1
  144. package/dist/gateway/static/root/assets/sliding-segmented-D346J92k.js +1 -0
  145. package/dist/gateway/static/root/assets/{system-settings-panel-DdBmyc93.js → system-settings-panel-BV4GHnns.js} +1 -1
  146. package/dist/gateway/static/root/assets/{task-detail-page-Bb1R4QsJ.js → task-detail-page-C9IyuxdS.js} +3 -3
  147. package/dist/gateway/static/root/assets/{task-input-card-Xl4xFjCn.js → task-input-card-NtzzVc0e.js} +1 -1
  148. package/dist/gateway/static/root/assets/{terminal-panel-store-B1EVdx4L.js → terminal-panel-store-DWdJOGMn.js} +1 -1
  149. package/dist/gateway/static/root/assets/{theme-store-BTkYFJOE.js → theme-store-FNf-kdMR.js} +1 -1
  150. package/dist/gateway/static/root/assets/{tracing-settings-page-h-gbBAtl.js → tracing-settings-page-BRPJuRpc.js} +1 -1
  151. package/dist/gateway/static/root/assets/{tunnel-api-BDoegsWD.js → tunnel-api-B7NHNrQJ.js} +1 -1
  152. package/dist/gateway/static/root/assets/{understanding-activity-store-DyFJDqHy.js → understanding-activity-store-bgCeO8bb.js} +1 -1
  153. package/dist/gateway/static/root/assets/{understanding-refresh-store-C0SRcgyd.js → understanding-refresh-store-CEhWIvsQ.js} +1 -1
  154. package/dist/gateway/static/root/assets/{usage-page-CbJsT3zT.js → usage-page-35YfpfVW.js} +1 -1
  155. package/dist/gateway/static/root/assets/{use-autosave-CB2B4NMO.js → use-autosave-D8Qtt_Tn.js} +1 -1
  156. package/dist/gateway/static/root/assets/use-composer-attachments-H-tD4Db6.js +2 -0
  157. package/dist/gateway/static/root/assets/use-file-preview-expanded-P-0xmST2.js +15 -0
  158. package/dist/gateway/static/root/assets/{use-personal-profile-r0OuOlBJ.js → use-personal-profile-Bk2rGWSy.js} +1 -1
  159. package/dist/gateway/static/root/assets/use-realtime-voice-BcokfdI0.js +1 -0
  160. package/dist/gateway/static/root/assets/{use-workspace-tree-B9Bmg8LV.js → use-workspace-tree-D0_812KH.js} +1 -1
  161. package/dist/gateway/static/root/assets/{user-model-page-BudrJ73l.js → user-model-page-BxHnOljT.js} +1 -1
  162. package/dist/gateway/static/root/assets/voice-C607F0pB.js +1 -0
  163. package/dist/gateway/static/root/assets/{voice-api-key-field-C8wd8ijq.js → voice-api-key-field-BL56KGeq.js} +1 -1
  164. package/dist/gateway/static/root/assets/voice-config-api-DVFTuHwH.js +1 -0
  165. package/dist/gateway/static/root/assets/{voice-input-shortcut-events-TAmJNcsN.js → voice-input-shortcut-events-BK-IvchL.js} +1 -1
  166. package/dist/gateway/static/root/assets/{work-discovery-overlay-DsyYo1p0.js → work-discovery-overlay-DDXae8Yc.js} +1 -1
  167. package/dist/gateway/static/root/assets/{work-discovery-page-BJ9VN5Zd.js → work-discovery-page-CxN0abrd.js} +1 -1
  168. package/dist/gateway/static/root/assets/{working-directory-picker-modal-CFj-ZOJE.js → working-directory-picker-modal-D3BUBFa0.js} +1 -1
  169. package/dist/gateway/static/root/assets/{workspace-api-DYFy9__S.js → workspace-api-ymncGc6j.js} +2 -2
  170. package/dist/gateway/static/root/assets/workspace-editor-agent-store-BQrMvAkL.js +1 -0
  171. package/dist/gateway/static/root/assets/workspace-file-preview-dialog-BKmtih6_.js +1 -0
  172. package/dist/gateway/static/root/assets/workspace-open-location-menu-BdfKT4O4.js +1 -0
  173. package/dist/gateway/static/root/assets/{xopc-cloud-account-card-DN4DdOWZ.js → xopc-cloud-account-card-BS_lsURY.js} +1 -1
  174. package/dist/gateway/static/root/index.html +91 -88
  175. package/dist/package.js +1 -1
  176. package/dist/packages/realtime-protocol/src/voice.js +32 -3
  177. package/dist/src/agent-config/schema.d.ts +30 -0
  178. package/dist/src/agent-config/schema.js +3 -1
  179. package/dist/src/cli/commands/gateway/lifecycle.js +1 -1
  180. package/dist/src/config/schema.d.ts +16 -0
  181. package/dist/src/config/schema.js +6 -0
  182. package/dist/src/gateway/hono/lib/safe-voice-config.d.ts +1 -0
  183. package/dist/src/gateway/hono/lib/safe-voice-config.js +7 -2
  184. package/dist/src/gateway/hono/routes/connectors.js +1 -1
  185. package/dist/src/gateway/hono/routes/models.js +4 -0
  186. package/dist/src/gateway/hono/routes/personal-agent.js +9 -1
  187. package/dist/src/gateway/hono/routes/voice.js +105 -12
  188. package/dist/src/gateway/security/gateway-scopes.js +1 -1
  189. package/dist/src/gateway/service/config-coordinator.d.ts +4 -0
  190. package/dist/src/gateway/service.js +4 -4
  191. package/dist/src/gateway/xopc-cloud-capability-setup.js +2 -2
  192. package/dist/src/imports/inventory.js +11 -3
  193. package/dist/src/infra/update-restart.js +1 -1
  194. package/dist/src/personal-agent/repository.d.ts +2 -3
  195. package/dist/src/personal-agent/service.d.ts +3 -6
  196. package/dist/src/personal-agent/service.js +11 -1
  197. package/dist/src/providers/model-catalog-persistence.js +2 -2
  198. package/dist/src/providers/setup/voice.js +9 -4
  199. package/dist/src/providers/xopc-cloud-model-source.js +2 -2
  200. package/dist/src/voice/platform-settings.js +1 -1
  201. package/dist/src/voice/realtime/omniEngine.d.ts +1 -0
  202. package/dist/src/voice/realtime/omniEngine.js +188 -43
  203. package/dist/src/voice/realtime/omniRoute.d.ts +5 -2
  204. package/dist/src/voice/realtime/omniRoute.js +29 -3
  205. package/dist/src/voice/realtime/runtime.js +46 -35
  206. package/dist/src/voice/realtime/runtime.types.d.ts +1 -1
  207. package/package.json +1 -1
  208. package/dist/gateway/static/root/assets/capabilities-settings-panel-C56aelvp.js +0 -8
  209. package/dist/gateway/static/root/assets/composer-payload-handoff-D1xUYD5M.js +0 -1
  210. package/dist/gateway/static/root/assets/gateway-realtime-store-Vl3uKAHV.js +0 -1
  211. package/dist/gateway/static/root/assets/home-page-DYkEc3Qb.js +0 -3
  212. package/dist/gateway/static/root/assets/imports-page-CLbpRE5i.js +0 -1
  213. package/dist/gateway/static/root/assets/index-CIeY0yyg.js +0 -11
  214. package/dist/gateway/static/root/assets/index-D1EDrkUo.css +0 -1
  215. package/dist/gateway/static/root/assets/logs-page-Dtoheh2t.js +0 -2
  216. package/dist/gateway/static/root/assets/note-image-lightbox-C6aTUp-c.js +0 -1
  217. package/dist/gateway/static/root/assets/page-header-store-B2Ahfm0W.js +0 -1
  218. package/dist/gateway/static/root/assets/personal-page-CpKBzGIk.js +0 -1
  219. package/dist/gateway/static/root/assets/project-detail-page-CobfHZo0.js +0 -7
  220. package/dist/gateway/static/root/assets/route-preload-C0oV8og1.js +0 -2
  221. package/dist/gateway/static/root/assets/secret-input-Dryrns2s.js +0 -1
  222. package/dist/gateway/static/root/assets/session-channel-icon-D1ktvt1P.js +0 -1
  223. package/dist/gateway/static/root/assets/settings-advanced-gate-B3rOBkm_.js +0 -1
  224. package/dist/gateway/static/root/assets/share-preview-page-BoLq3kSO.js +0 -2
  225. package/dist/gateway/static/root/assets/use-composer-attachments-BPMn8eY_.js +0 -2
  226. package/dist/gateway/static/root/assets/use-file-preview-expanded-4SKLb9Fh.js +0 -15
  227. package/dist/gateway/static/root/assets/voice-config-api-yBcUSvvn.js +0 -1
  228. package/dist/gateway/static/root/assets/voice-transcribe-api-D4eyeSdG.js +0 -1
  229. package/dist/gateway/static/root/assets/workspace-editor-agent-store-2Lt7rQfw.js +0 -1
  230. package/dist/gateway/static/root/assets/workspace-file-preview-dialog-DhqlVzSI.js +0 -1
  231. package/dist/gateway/static/root/assets/workspace-open-location-menu-C-ItyXwL.js +0 -1
@@ -1,8 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-swr-CdRzEUwF.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-Czpn1I53.js";import{f as a,l as o,m as s,r as c,t as l}from"./chunk-KS7C4IRE-CiwuuyV8.js";import{a as u,i as d,l as f,n as p,o as m}from"./locale-store-CQcW9_qA.js";import{t as h}from"./messages-orB1BMgI.js";import{a as g,i as _,n as v,o as y,r as b,s as x,t as S}from"./dist-BGTk37IG.js";import{t as C}from"./arrow-right-DSSvoX71.js";import{r as w,t as T}from"./voice-call-context-CJ1ZiJWR.js";import{t as E}from"./chevron-right-BweFrslA.js";import{n as D,r as O,t as k}from"./popover-select-CLsphyzA.js";import{t as A}from"./circle-check-C23XjkUj.js";import{C as j,D as M,E as N,O as P,S as F,T as I,_ as L,a as R,b as z,c as B,d as ee,f as V,g as te,h as H,i as U,l as W,m as ne,n as re,o as G,p as K,r as ie,s as ae,t as q,u as oe,v as se,w as ce,x as J,y as le}from"./connected-providers-grid-w3htbAyh.js";import{t as ue}from"./cloud-C4-yfnnk.js";import{t as de}from"./external-link-DjqjBmc3.js";import{t as fe}from"./secret-input-Dryrns2s.js";import{t as pe}from"./eye-CABVeTq0.js";import{t as me}from"./image-Cwyalflz.js";import{t as he}from"./key-round-DWbpyU2U.js";import{t as ge}from"./loader-circle-CifKLtgG.js";import{t as _e}from"./mic-CuUb7zc-.js";import{t as ve}from"./pencil-DmIY3Oa-.js";import{t as ye}from"./play-kxZvpBg8.js";import{t as be}from"./plug-DKYPEgkR.js";import{t as xe}from"./plus-Q2yW6OE7.js";import{t as Se}from"./refresh-cw-BRlGaq2w.js";import{t as Ce}from"./settings-2-D-csvaET.js";import{t as we}from"./shield-check-BU58siTV.js";import{t as Te}from"./sliders-horizontal-DqsYor6I.js";import{t as Ee}from"./square-DMK_fB-3.js";import{t as De}from"./trash-2-DusmjVPV.js";import{t as Oe}from"./triangle-alert-2JXFNNKU.js";import{t as ke}from"./volume-2-BSJhAY97.js";import{t as Ae}from"./wrench-DFb4r8bH.js";import{t as je}from"./x-B_N4OPjy.js";import{t as Y}from"./cn-0WouolD0.js";import{t as Me}from"./skeleton-DzdOeGYz.js";import{a as Ne,c as Pe,i as Fe,m as Ie,n as Le,p as Re,u as ze}from"./schemas-CCWMleym.js";import{d as Be,f as Ve,i as He,l as Ue,r as We,t as Ge,u as Ke}from"./voice-transcribe-api-D4eyeSdG.js";import{i as X}from"./vendor-swr-CdRzEUwF.js";import{n as qe,r as Je}from"./gateway-config-swr-CtZy1Qw0.js";import{n as Ye,t as Xe}from"./registry-api-Bo8YiUE0.js";import{t as Z}from"./button-Cc4hUNTt.js";import{i as Ze,o as Qe}from"./settings-shell-dialog-layer-BU3UuiJr.js";import{t as $e}from"./open-capability-settings-Cvb65hQB.js";import{n as et,t as tt}from"./interaction-BdhHBbYa.js";import{a as nt,o as rt,s as it}from"./form-field-width-DJw_jULe.js";import{n as at}from"./is-masked-secret-DOkL5b_X.js";import{n as ot,t as st}from"./secret-input-labels-B5Jl5HqK.js";import{a as ct}from"./navigation-ByOzYT0t.js";import{t as lt}from"./electron-env-DHOGevH3.js";import{t as ut}from"./sliding-tab-list-CmcrqRzN.js";import{n as dt,t as ft}from"./settings-form-draft-Dy10ldo8.js";import{t as pt}from"./confirm-dialog-D7dQJytv.js";import{n as mt,t as ht}from"./model-sort-_Tz8s_4N.js";import{n as gt,r as _t}from"./model-selector-DYxgKUju.js";import{n as vt}from"./agents-app-path-ciChvpCS.js";import{n as yt,t as bt}from"./global-defaults-api-yHc-ZfjU.js";import{t as xt}from"./settings-loading-skeleton-CAoOV17i.js";import{i as St,r as Ct,t as wt}from"./models-hub-cache-D2cdb8nZ.js";import{a as Tt,r as Et,s as Dt,t as Ot}from"./providers-api-B47s6_9Q.js";import{a as kt,i as At,n as jt,o as Mt,r as Nt,t as Pt}from"./oauth-api-D5iBtOid.js";import{t as Ft}from"./settings-advanced-section-3HwfHbqz.js";import{n as It,r as Lt,t as Rt}from"./oauth-authorization-window-o6URRos4.js";import{t as zt}from"./number-input-El7Szeln.js";import{n as Bt,t as Vt}from"./settings-page-header-CheboxIM.js";import"./settings-page-layout-CPFMZaLF.js";import{n as Ht,t as Ut}from"./settings-form-section-num14vSv.js";import{n as Wt,t as Gt}from"./use-autosave-CB2B4NMO.js";import{c as Kt,f as qt,i as Jt,l as Yt,n as Xt,o as Zt,r as Qt,s as $t,t as en,u as tn}from"./voice-config-api-yBcUSvvn.js";import{t as nn}from"./voice-api-key-field-C8wd8ijq.js";import{a as rn,i as an,n as on,o as sn,r as cn,s as ln,t as un}from"./image-generation-api-D5eo_stq.js";import{t as dn}from"./xopc-cloud-account-card-DN4DdOWZ.js";var fn=Re({"zh-CN":Ie().min(1).optional(),en:Ie().min(1).optional()}),pn=Le([`transcription`,`transcription.stream`,`speech`,`speech.stream`,`conversation`]),mn=Re({protocolVersion:Pe(1),serviceVersion:ze().int().positive(),modes:Fe(pn),transport:Pe(`websocket-pcm`),inputFormat:Re({encoding:Pe(`pcm_s16le`),sampleRate:Pe(16e3),channels:Pe(1)}),outputFormat:Re({encoding:Pe(`pcm_s16le`),sampleRate:Pe(24e3),channels:Pe(1)}),turnDetection:Fe(Pe(`server_vad`)),bargeIn:Ne(),tools:Ne(),resumable:Pe(!1),voices:Fe(Re({id:Ie().min(1),name:Ie(),displayNames:fn.optional(),languages:Fe(Ie()),gender:Le([`female`,`male`]).optional(),style:Ie().optional(),description:Ie().optional(),modes:Fe(pn).optional()})),defaultVoice:Ie().min(1).optional(),limits:Re({maxFrameBytes:ze().int().positive().max(65536),maxSessionSeconds:ze().int().positive()})});function hn(e,t){return e.modes===void 0||e.modes.includes(t)}var gn=Re({mode:pn,model:Ie().min(1).max(200),voice:Ie().min(1).max(200).optional()}),_n=Re({revision:Ie().min(1),catalogVersion:Ie().nullable(),selections:Fe(gn),models:Fe(Re({id:Ie(),name:Ie(),displayNames:fn.optional(),voice:mn}))}),vn=n(),Q=e(t(),1),$=r(),yn={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 必须使用“名称: 值”格式,每行一个。`}},bn=`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 xn(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 Sn(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 Cn({open:e,onOpenChange:t,provider:n,configured:r,language:i,onSaved:a,portalContainer:o,onPendingChange:s}){let c=yn[i],[l,u]=(0,Q.useState)(``),[d,f]=(0,Q.useState)(``),[p,m]=(0,Q.useState)(``),[h,C]=(0,Q.useState)(`bearer`),[T,E]=(0,Q.useState)(`x-api-key`),[D,O]=(0,Q.useState)(``),[A,j]=(0,Q.useState)(``),[M,N]=(0,Q.useState)(``),[P,F]=(0,Q.useState)(`/images/generations`),[I,L]=(0,Q.useState)(`/images/edits`),[R,z]=(0,Q.useState)(``),[B,ee]=(0,Q.useState)(``),[V,te]=(0,Q.useState)([xn()]),[H,U]=(0,Q.useState)(``),[W,ne]=(0,Q.useState)(),[re,G]=(0,Q.useState)(!1),[K,ie]=(0,Q.useState)(),[ae,q]=(0,Q.useState)(),[oe,se]=(0,Q.useState)();(0,Q.useEffect)(()=>(s?.(!!W),()=>s?.(!1)),[W,s]),(0,Q.useEffect)(()=>{if(!e)return;let t=n?.imageGeneration;u(n?.providerId??``),f(t?.name??``),m(n?.baseUrl??``),C(t?.auth.type??`bearer`),E(t?.auth.type===`header`?t.auth.headerName:`x-api-key`),O(r?`••••••••••••`:``),j(t?.apiKeyUrl??``),N(t?.documentationUrl??``),F(t?.paths?.generations??`/images/generations`),L(t?.paths?.edits??`/images/edits`),z(t?.network?.allowedHosts.join(`
4
- `)??``),ee(Object.entries(n?.headers??{}).map(([e,t])=>`${e}: ${t}`).join(`
5
- `)),te(t?.models.map(xn)??[xn()]),U(t?.defaultModel??``),q(void 0),ne(void 0),G(!1),ie(void 0),se(void 0)},[r,e,n]);let ce=(0,Q.useMemo)(()=>V.filter(e=>e.id.trim()).sort(mt).map(e=>({value:e.id.trim(),label:e.name.trim()||e.id.trim()})),[V]),J=(e,t)=>{te(n=>n.map((n,r)=>r===e?{...n,...t}:n))},le=()=>{let e=l.trim(),t=V.map(e=>({...e,id:e.id.trim(),name:e.name.trim()}));if(!e||!d.trim()||!p.trim()||t.some(e=>!e.id))throw Error(c.required);if(new Set(t.map(e=>e.id)).size!==t.length)throw Error(c.duplicateModels);let n=H||t[0]?.id;if(!n||!t.some(e=>e.id===n))throw Error(c.required);let r;try{r=Sn(B)}catch{throw Error(c.invalidHeaders)}return{providerId:e,input:{baseUrl:p.trim(),...r?{headers:r}:{},imageGeneration:{api:`openai-images`,name:d.trim(),...M.trim()?{documentationUrl:M.trim()}:{},...A.trim()?{apiKeyUrl:A.trim()}:{},defaultModel:n,auth:h===`header`?{type:`header`,headerName:T.trim()}:{type:h},paths:{...P.trim()?{generations:P.trim()}:{},...I.trim()?{edits:I.trim()}:{}},...R.trim()?{network:{allowedHosts:R.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}}}))}}}},ue=async()=>{let e=le();return await an(e.providerId,e.input),h!==`none`&&D.trim()&&!at(D)&&await rn(e.providerId,D.trim()),await a(e.providerId),e},de=async()=>{ne(`save`),ie(void 0),q(void 0);try{await ue(),O(h===`none`?``:`••••••••••••`),q(c.saved)}catch(e){ie(e instanceof Error?e.message:String(e))}finally{ne(void 0)}},me=async()=>{ne(`test`),ie(void 0),q(void 0),se(void 0);try{let e=await ue(),t=await sn(e.providerId,e.input.imageGeneration.defaultModel);se(t.images[0]?.dataUrl),q(c.testReady)}catch(e){ie(e instanceof Error?e.message:String(e))}finally{ne(void 0)}},he=async()=>{if(n){if(!re){G(!0);return}ne(`delete`),ie(void 0);try{await un(n.providerId),await a(),t(!1)}catch(e){ie(e instanceof Error?e.message:String(e))}finally{ne(void 0)}}};return(0,$.jsx)(S,{open:e,onOpenChange:e=>{W||t(e)},children:(0,$.jsxs)(y,{container:o,children:[(0,$.jsx)(g,{className:Y(`xopc-dialog-overlay fixed inset-0 bg-scrim`,Qe)}),(0,$.jsxs)(b,{className:Y(`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`,Ze),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)(x,{className:`font-semibold text-fg`,children:n?c.editTitle:c.addTitle}),(0,$.jsx)(_,{className:`mt-1 text-sm text-fg-muted`,children:c.intro})]}),(0,$.jsx)(v,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,disabled:!!W,className:`rounded-md p-1 text-fg-muted hover:bg-surface-inset hover:text-fg`,"aria-label":c.cancel,children:(0,$.jsx)(je,{className:`size-5`})})})]}),(0,$.jsxs)(`fieldset`,{disabled:!!W,className:`min-h-0 min-w-0 flex-1 space-y-6 overflow-y-auto px-5 py-4`,children:[(0,$.jsxs)(`section`,{className:`space-y-4`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-subtle`,children:c.connection}),(0,$.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.providerId,(0,$.jsx)(`input`,{value:l,disabled:!!n,onChange:e=>u(e.target.value),placeholder:`my-image-service`,className:bn}),(0,$.jsx)(`span`,{className:`mt-1 block font-normal text-fg-subtle`,children:c.providerIdHint})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.name,(0,$.jsx)(`input`,{value:d,onChange:e=>f(e.target.value),placeholder:`My Image Service`,className:bn})]})]}),(0,$.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[c.baseUrl,(0,$.jsx)(`input`,{value:p,onChange:e=>m(e.target.value),placeholder:`https://api.example.com/v1`,className:bn})]}),(0,$.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.auth,(0,$.jsx)(k,{value:h,options:[{value:`bearer`,label:c.bearer},{value:`header`,label:c.header},{value:`none`,label:c.none}],placeholder:c.auth,allowEmpty:!1,onChange:e=>C(e),triggerClassName:`mt-1.5`})]}),h===`header`?(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.headerName,(0,$.jsx)(`input`,{value:T,onChange:e=>E(e.target.value),className:bn})]}):null]}),h===`none`?null:(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`mb-1.5 flex items-center justify-between`,children:[(0,$.jsx)(`label`,{htmlFor:`custom-image-api-key`,className:`text-xs font-medium text-fg-muted`,children:c.apiKey}),A.trim()?(0,$.jsxs)(`a`,{href:A.trim(),target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs text-accent hover:underline`,children:[c.openKeyPage,(0,$.jsx)(w,{className:`size-3.5`})]}):null]}),(0,$.jsx)(fe,{id:`custom-image-api-key`,value:D,onChange:e=>O(at(D)?e.replace(/^•+/,``):e),labels:{show:c.show,hide:c.hide,copy:c.copy,copied:c.copied},reveal:()=>Dt(l).then(e=>e.apiKey),loadFailedLabel:c.revealFailed,notInConfigFile:c.notRevealable}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:c.apiKeyHint})]}),(0,$.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.apiKeyUrl,(0,$.jsx)(`input`,{value:A,onChange:e=>j(e.target.value),placeholder:`https://…`,className:bn})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.docsUrl,(0,$.jsx)(`input`,{value:M,onChange:e=>N(e.target.value),placeholder:`https://…`,className:bn})]})]}),(0,$.jsxs)(`details`,{className:`rounded-lg border border-edge bg-surface-inset px-3 py-2.5`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg-muted`,children:c.paths}),(0,$.jsxs)(`div`,{className:`mt-3 grid gap-4 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.generationsPath,(0,$.jsx)(`input`,{value:P,onChange:e=>F(e.target.value),className:bn})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.editsPath,(0,$.jsx)(`input`,{value:I,onChange:e=>L(e.target.value),className:bn})]})]}),(0,$.jsxs)(`label`,{className:`mt-4 block text-xs font-medium text-fg-muted`,children:[c.allowedHosts,(0,$.jsx)(`textarea`,{value:R,onChange:e=>z(e.target.value),rows:2,placeholder:`127.0.0.1
7
- image-server.lan`,className:`mt-1.5 w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 font-mono text-xs text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`}),(0,$.jsx)(`span`,{className:`mt-1 block font-normal text-fg-subtle`,children:c.allowedHostsHint})]}),(0,$.jsxs)(`label`,{className:`mt-4 block text-xs font-medium text-fg-muted`,children:[c.staticHeaders,(0,$.jsx)(`textarea`,{value:B,onChange:e=>ee(e.target.value),rows:3,className:`mt-1.5 w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 font-mono text-xs text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/20`}),(0,$.jsx)(`span`,{className:`mt-1 block font-normal text-fg-subtle`,children:c.staticHeadersHint})]})]})]}),(0,$.jsxs)(`section`,{className:`space-y-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-subtle`,children:c.models}),(0,$.jsxs)(Z,{variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,onClick:()=>te(e=>[...e,xn()]),children:[(0,$.jsx)(xe,{className:`size-4`}),c.addModel]})]}),(0,$.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[c.defaultModel,(0,$.jsx)(k,{value:H||V.find(e=>e.id.trim())?.id.trim()||``,options:ce,placeholder:c.defaultModel,allowEmpty:!1,onChange:U,triggerClassName:`mt-1.5 max-w-sm`})]}),V.map((e,t)=>(0,$.jsxs)(`div`,{className:`rounded-lg border border-edge bg-surface-base p-3`,children:[(0,$.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.modelId,(0,$.jsx)(`input`,{value:e.id,onChange:e=>J(t,{id:e.target.value}),placeholder:`image-1`,className:bn})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.modelName,(0,$.jsx)(`input`,{value:e.name,onChange:e=>J(t,{name:e.target.value}),className:bn})]})]}),(0,$.jsxs)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2 lg:grid-cols-4`,children:[(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.maxCount,(0,$.jsx)(`input`,{type:`number`,min:1,value:e.maxCount,onChange:e=>J(t,{maxCount:e.target.value}),className:bn})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.defaultCount,(0,$.jsx)(`input`,{type:`number`,min:1,value:e.defaultCount,onChange:e=>J(t,{defaultCount:e.target.value}),className:bn})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.defaultSize,(0,$.jsx)(`input`,{value:e.defaultSize,onChange:e=>J(t,{defaultSize:e.target.value}),placeholder:`1024x1024`,className:bn})]}),(0,$.jsxs)(`label`,{className:`text-xs font-medium text-fg-muted`,children:[c.format,(0,$.jsx)(k,{value:e.outputFormat,options:[{value:`png`,label:`PNG`},{value:`jpeg`,label:`JPEG`},{value:`webp`,label:`WebP`}],placeholder:c.format,allowEmpty:!0,onChange:e=>J(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=>J(t,{supportsSize:e.target.checked})}),c.supportsSize]}),(0,$.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-fg-muted`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:e.editEnabled,onChange:e=>J(t,{editEnabled:e.target.checked})}),c.edit]}),(0,$.jsxs)(`button`,{type:`button`,disabled:V.length===1,onClick:()=>te(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)(De,{className:`size-3.5`}),c.remove]})]})]},t))]}),oe?(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)(pe,{className:`size-4`}),c.testReady]}),(0,$.jsx)(`img`,{src:oe,alt:`Generated provider test`,className:`max-h-72 rounded-lg object-contain`})]}):null,ae?(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:ae}):null,K?(0,$.jsx)(`p`,{className:`rounded-lg bg-red-500/10 px-3 py-2 text-sm text-red-600 dark:text-red-400`,children:K}):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)(Z,{variant:`secondary`,className:`border-red-500/30 text-red-600 hover:bg-red-500/10 dark:text-red-400`,disabled:!!W,onClick:()=>void he(),children:[W===`delete`?(0,$.jsx)(ge,{className:`size-4 animate-spin`}):(0,$.jsx)(De,{className:`size-4`}),re?c.confirmDelete:c.delete]}):null,(0,$.jsxs)(`div`,{className:`ml-auto flex gap-2`,children:[(0,$.jsx)(v,{asChild:!0,children:(0,$.jsx)(Z,{variant:`secondary`,disabled:!!W,children:c.cancel})}),(0,$.jsxs)(Z,{variant:`secondary`,disabled:!!W,onClick:()=>void me(),children:[W===`test`?(0,$.jsx)(ge,{className:`size-4 animate-spin`}):null,W===`test`?c.testing:c.test]}),(0,$.jsxs)(Z,{variant:`primary`,disabled:!!W,onClick:()=>void de(),children:[W===`save`?(0,$.jsx)(ge,{className:`size-4 animate-spin`}):null,W===`save`?c.saving:c.save]})]})]})]})]})})}var wn=`••••••••••••`,Tn={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 En(){let e=await m(d(`/api/image-generation/default`));if(!e.payload)throw Error(`Invalid default image generation response`);return e.payload}function Dn(e){let t=e?.indexOf(`/`)??-1;return t>0?e.slice(0,t):void 0}function On(e){let t=e?.indexOf(`/`)??-1;return t>0?e.slice(t+1):void 0}function kn(e){return Object.fromEntries(e.configFields.map(t=>[t.key,e.config[t.key]??(t.required?t.options?.[0]?.value??``:``)]))}function An(e){let t=(0,vn.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)(k,{value:r,options:(n.options??[]).map(jn),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 jn(e){return{value:e.value,label:e.label}}function Mn(){let e=(0,vn.c)(2),t;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=(0,$.jsx)(Me,{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(Nn)}),(0,$.jsx)(Me,{className:`h-64 rounded-xl`})]}),e[1]=n):n=e[1],n}function Nn(e,t){return(0,$.jsx)(Me,{className:`h-24 rounded-xl`},t)}function Pn({connectOnly:e=!1,onConnected:t,onPendingChange:n}={}){let r=p(e=>e.language),a=Tn[r],o=!!f(e=>e.conversationId),[s,c]=(0,Q.useState)(``),[l,u]=(0,Q.useState)(``),[h,g]=(0,Q.useState)(``),[_,v]=(0,Q.useState)({}),[y,b]=(0,Q.useState)(!1),[x,S]=(0,Q.useState)(!1),[C,T]=(0,Q.useState)(null);(0,Q.useEffect)(()=>(n?.(y||x),()=>n?.(!1)),[y,x,n]);let[E,D]=(0,Q.useState)(),[O,j]=(0,Q.useState)(!1),[M,N]=(0,Q.useState)(!1),[P,F]=(0,Q.useState)(),{data:I,isLoading:R,error:z,mutate:B}=X(o?d(`/api/image-generation/catalog`):null,cn,{revalidateOnFocus:!1}),{data:ee,isLoading:V,error:te,mutate:H}=X(o?d(`/api/image-generation/custom-providers`):null,on,{revalidateOnFocus:!1}),{data:U,isLoading:W,error:ne,mutate:re}=X(o?`default-image-generation`:null,En,{revalidateOnFocus:!1});(0,Q.useEffect)(()=>{if(!I||!U)return;let e=Dn(U.model?.primary),t=I.find(t=>t.id===e)??I.find(e=>e.configured)??I[0];t&&(c(t.id),u(t.id===e&&On(U.model?.primary)||t.defaultModel),g(t.configured?wn:``),v(kn(t)))},[U,I]);let G=I?.find(e=>e.id===s),K=G?G.apiKeyUrl??L(G.id,r)[0]?.href:void 0,ie=(0,Q.useMemo)(()=>[...G?.models??[]].sort(ht).map(e=>({value:e,label:e})),[G?.models]),ae=U?.model?.primary,q=!!(G&&l&&(G.credentialMode!==`api-key`||G.configured||h.trim())&&G.configFields.every(e=>!e.required||_[e.key]?.trim()));if(!o)return(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:a.connect});if(R||V||W)return(0,$.jsx)(Mn,{});if(z||te||ne||!I||!ee)return(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:a.loadError});let oe=e=>{c(e.id),u(e.defaultModel),g(e.configured?wn:``),v(kn(e)),D(void 0)},se=()=>{F(void 0),N(!0)},ce=()=>{let e=ee.find(e=>e.providerId===G?.id);e&&(F(e),N(!0))},J=async n=>{let[r,i]=await Promise.all([H(),B()]);if(n&&i?.some(e=>e.id===n)){let a=i.find(e=>e.id===n);c(a.id),u(a.defaultModel),g(a.configured?wn:``),v(kn(a)),F(r?.find(e=>e.providerId===n)),e&&a.configured&&t?.()}},le=async()=>{if(!(!G||!q)){b(!0),D(void 0),j(!1);try{if(e){h.trim()&&!at(h)&&await rn(G.id,h.trim()),Object.keys(_).length&&await m(d(`/api/config`),{method:`PATCH`,body:JSON.stringify({providersConfig:{[G.id]:_}})});let[e]=await Promise.all([B(),qe()]);if(!e?.find(e=>e.id===G.id)?.configured)throw Error(r===`zh`?`连接尚未就绪,请先完成对应服务的授权或凭据设置。`:`Connection is not ready. Complete authorization or credentials first.`);j(!0),t?.();return}let n=await m(d(`/api/image-generation/default/setup`),{method:`POST`,body:JSON.stringify({providerId:G.id,modelId:l,...h.trim()&&!at(h)?{apiKey:h.trim()}:{},providerConfig:Object.fromEntries(Object.entries(_).filter(([,e])=>e.trim()))})});if(!n.payload)throw Error(`Invalid setup response`);await Promise.all([re(n.payload.default,{revalidate:!1}),B(n.payload.providers,{revalidate:!1}),i(async()=>{let{mutate:e}=await import(`./vendor-swr-CdRzEUwF.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`)])),qe()]),g(wn),j(!0)}catch(e){D(e instanceof Error?e.message:String(e))}finally{b(!1)}}};return(0,$.jsxs)(`div`,{ref:T,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)(me,{className:`size-5`})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-semibold text-fg`,children:a.title}),(0,$.jsx)(`p`,{className:`mt-1 text-sm leading-relaxed text-fg-muted`,children:e?r===`zh`?`连接图片来源,不修改默认模型,也不发送生成测试请求。`:`Connect image sources without changing defaults or sending generation tests.`:a.intro})]})]})}),(0,$.jsxs)(`section`,{children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-fg-subtle`,children:a.provider}),(0,$.jsxs)(Z,{variant:`secondary`,className:`px-2.5 py-1.5 text-xs`,onClick:se,children:[(0,$.jsx)(xe,{className:`size-4`}),a.addService]})]}),(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2 xl:grid-cols-3`,children:I.map(e=>{let t=e.id===s,n=e.id===Dn(ae);return(0,$.jsxs)(`button`,{type:`button`,onClick:()=>oe(e),className:`min-h-24 rounded-xl p-4 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent ${t?`bg-accent-soft shadow-surface`:`bg-surface-base/55 hover:bg-surface-hover`}`,children:[(0,$.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,$.jsx)(`span`,{className:`truncate font-medium text-fg`,children:e.label}),e.source===`custom`?(0,$.jsx)(`span`,{className:`rounded-full bg-surface-inset px-2 py-0.5 text-[10px] text-fg-subtle`,children:a.custom}):null]}),(0,$.jsx)(`span`,{"aria-hidden":!n,className:`shrink-0 rounded-full bg-accent/10 px-2 py-0.5 text-[11px] font-medium text-accent ${n?``:`invisible`}`,children:a.current})]}),(0,$.jsxs)(`span`,{className:`mt-2 flex items-center gap-1.5 text-xs ${e.configured?`text-emerald-600 dark:text-emerald-400`:`text-fg-muted`}`,children:[e.configured||e.credentialMode!==`api-key`?(0,$.jsx)(A,{className:`size-3.5`}):(0,$.jsx)(he,{className:`size-3.5`}),e.configured||e.credentialMode!==`api-key`?a.configured:a.needsKey]})]},e.id)})})]}),G?(0,$.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 p-4`,children:[(0,$.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[e?null:(0,$.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[a.model,(0,$.jsx)(k,{value:l,options:ie,placeholder:a.selectModel,allowEmpty:!1,onChange:u,triggerClassName:`mt-1.5`})]}),G.configFields.filter(e=>e.required).map(e=>(0,$.jsx)(An,{field:e,value:_[e.key]??``,onChange:t=>v(n=>({...n,[e.key]:t}))},e.key))]}),G.source===`custom`?(0,$.jsx)(`div`,{className:`mt-4 flex justify-end`,children:(0,$.jsxs)(Z,{variant:`secondary`,onClick:ce,children:[(0,$.jsx)(Ce,{className:`size-4`}),a.manageService]})}):null,G.credentialMode===`api-key`?(0,$.jsxs)(`div`,{className:`mt-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(`label`,{htmlFor:`image-generation-api-key`,className:`text-xs font-medium text-fg-muted`,children:a.apiKey}),K?(0,$.jsxs)(`a`,{href:K,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-xs font-medium text-accent hover:underline`,children:[a.getApiKey,(0,$.jsx)(w,{className:`size-3.5`,"aria-hidden":`true`})]}):null]}),(0,$.jsx)(fe,{id:`image-generation-api-key`,value:h,onChange:e=>g(at(h)?e.replace(/^•+/,``):e),placeholder:G.configured?a.existingKey:a.needsKey,labels:{show:a.show,hide:a.hide,copy:a.copy,copied:a.copied},reveal:()=>Dt(G.id).then(e=>e.apiKey),loadFailedLabel:a.revealFailed,notInConfigFile:a.keyNotRevealable,className:`mt-1.5`,autoComplete:`new-password`},G.id),(0,$.jsx)(`span`,{className:`mt-1.5 block font-normal leading-relaxed text-fg-subtle`,children:G.configured?a.savedKey:a.apiKeyHint})]}):null,G.configFields.some(e=>!e.required)?(0,$.jsxs)(`details`,{className:`mt-4 rounded-lg bg-surface-base/55 px-3 py-2.5`,children:[(0,$.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 text-sm font-medium text-fg-muted`,children:[(0,$.jsx)(Te,{className:`size-4`}),a.advanced]}),(0,$.jsx)(`div`,{className:`mt-3 grid gap-3 md:grid-cols-2`,children:G.configFields.filter(e=>!e.required).map(e=>(0,$.jsx)(An,{field:e,value:_[e.key]??``,onChange:t=>v(n=>({...n,[e.key]:t}))},e.key))})]}):null,O?(0,$.jsx)(`p`,{className:`mt-4 rounded-lg bg-emerald-500/10 px-3 py-2 text-sm text-emerald-700 dark:text-emerald-300`,role:`status`,children:e?r===`zh`?`连接已保存`:`Connection saved`:a.enabled}):null,E?(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:E}):null,(0,$.jsx)(`div`,{className:`mt-4 flex justify-end`,children:(0,$.jsxs)(Z,{variant:`primary`,disabled:!q||y,onClick:()=>void le(),children:[y?(0,$.jsx)(ge,{className:`size-4 animate-spin`}):(0,$.jsx)(A,{className:`size-4`}),(0,$.jsxs)(`span`,{className:`grid`,children:[(0,$.jsx)(`span`,{"aria-hidden":!0,className:`invisible col-start-1 row-start-1`,children:a.enable}),(0,$.jsx)(`span`,{"aria-hidden":!0,className:`invisible col-start-1 row-start-1`,children:a.enabling}),(0,$.jsx)(`span`,{className:`col-start-1 row-start-1`,children:e?y?r===`zh`?`保存中…`:`Saving…`:r===`zh`?`保存图片连接`:`Save image connection`:y?a.enabling:a.enable})]})]})})]}):null,(0,$.jsx)(Cn,{portalContainer:C?.closest(`[role="dialog"]`),onPendingChange:S,open:M,onOpenChange:N,provider:P,configured:!!(P&&I.find(e=>e.id===P.providerId)?.configured),language:r,onSaved:J})]})}function Fn({disabled:e=!1,modes:t,onPendingChange:n}){let r=p(e=>e.language),i=r===`zh`,[a,o]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>(n?.(a),()=>n?.(!1)),[a,n]);let[s,c]=(0,Q.useState)(``),{data:l,mutate:u,error:f}=X(d(`/api/voice/catalog`),async e=>{let t=await m(e);return _n.parse(t.payload)}),h=i?{transcription:`录音转文字`,"transcription.stream":`实时听写 / 语音助手输入`,speech:`消息朗读`,"speech.stream":`语音助手输出`,conversation:`自然语音对话`}:{transcription:`Recorded transcription`,"transcription.stream":`Live dictation / assistant input`,speech:`Message readout`,"speech.stream":`Assistant speech`,conversation:`Natural conversation`},g=async e=>{if(l){o(!0),c(``);try{let t=await m(d(e?`/api/voice/selection`:`/api/voice/catalog/refresh`),{method:e?`PUT`:`POST`,...e?{body:JSON.stringify({revision:l.revision,selection:e})}:{}});await u(_n.parse(t.payload),!1),await qe()}catch(e){c(e instanceof Error?e.message:String(e)),await u()}finally{o(!1)}}};return(0,$.jsxs)(`section`,{className:`space-y-4 rounded-xl bg-surface-hover/20 p-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsx)(`h3`,{className:`font-medium`,children:i?`XOPC 托管语音模型`:`XOPC managed voice models`}),(0,$.jsx)(Z,{variant:`secondary`,disabled:a||e||!l,onClick:()=>void g(),children:i?`刷新目录`:`Refresh catalog`})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:i?`修改在下次调用生效。各设备共用此 Gateway 的配置。`:`Changes apply to the next call and are shared across devices.`}),s||f?(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-red-600`,children:s||String(f)}):null,l?(0,$.jsx)($.Fragment,{children:t.map(t=>{let n=l.selections.find(e=>e.mode===t),o=l.models.filter(e=>e.voice.modes.includes(t)).sort(mt),s=o.find(e=>e.id===n?.model),c=s?.voice.voices.filter(e=>hn(e,t))??[],u=n?.voice??c.find(e=>e.id===s?.voice.defaultVoice)?.id??c[0]?.id??``;return(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[(0,$.jsx)(`span`,{children:h[t]}),(0,$.jsxs)(D,{className:`w-full`,value:n?.model??``,disabled:a||e||!o.length,onChange:e=>void g({mode:t,model:e.target.value}),children:[(0,$.jsx)(O,{value:``,disabled:!0,children:i?`选择模型`:`Choose model`}),n&&!s?(0,$.jsxs)(O,{value:n.model,disabled:!0,children:[n.model,` · `,i?`不可用`:`Unavailable`]}):null,o.map(e=>(0,$.jsx)(O,{value:e.id,children:_t(e,r)},e.id))]}),o.length?null:(0,$.jsx)(`span`,{className:`text-xs text-fg-muted`,children:i?`暂无可用模型`:`No available model`})]}),s&&c.length>0?(0,$.jsxs)(`label`,{className:`space-y-1 text-sm`,children:[(0,$.jsx)(`span`,{children:i?`音色`:`Voice`}),(0,$.jsxs)(D,{className:`w-full`,value:u,disabled:a||e,onChange:e=>void g({mode:t,model:s.id,voice:e.target.value}),children:[n?.voice&&!c.some(e=>e.id===n.voice)?(0,$.jsxs)(O,{value:n.voice,disabled:!0,children:[n.voice,` · `,i?`当前场景不可用`:`Unavailable for this mode`]}):null,c.map(e=>(0,$.jsxs)(O,{value:e.id,children:[_t(e,r),e.gender?` · ${i?e.gender===`female`?`女声`:`男声`:e.gender}`:``,e.style?` · ${e.style}`:``]},e.id))]}),c.find(e=>e.id===u)?.description?(0,$.jsx)(`span`,{className:`block text-xs text-fg-muted`,children:c.find(e=>e.id===u)?.description}):null]}):null]},t)})}):(0,$.jsx)(Me,{className:`h-48 w-full`})]})}function In({v:e}){let t=Be(e=>e.microphoneId),n=Be(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)(O,{value:``,children:e.experience.systemDevice}),t&&!r.some(e=>e.deviceId===t)?(0,$.jsx)(O,{value:t,children:e.experience.unavailable}):null,r.filter(e=>e.deviceId&&e.deviceId!=="default").map((t,n)=>(0,$.jsx)(O,{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)(Z,{variant:`secondary`,disabled:s,onClick:()=>void u(),children:e.experience.refreshDevices}),a?(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-red-600`,children:a}):null]})}var Ln=(0,Q.createContext)(null);function Rn(e){let t=(0,vn.c)(18),n,r;t[0]===e?(n=t[1],r=t[2]):({to:r,...n}=e,t[0]=e,t[1]=n,t[2]=r);let[i]=s(),a=(0,Q.useContext)(Ln),o,c;t[3]===r?(o=t[4],c=t[5]):(o=new URLSearchParams(r.split(`?`)[1]??``),c=I(o.get(`configure`)),t[3]=r,t[4]=o,t[5]=c);let u=c,d;t[6]!==a||t[7]!==n||t[8]!==o||t[9]!==u?(d=e=>{n.onClick?.(e),!e.defaultPrevented&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&e.button===0&&a&&u&&o.get(`tab`)===`services`&&(e.preventDefault(),a(u))},t[6]=a,t[7]=n,t[8]=o,t[9]=u,t[10]=d):d=t[10];let f;t[11]!==i||t[12]!==r?(f=N(r,i),t[11]=i,t[12]=r,t[13]=f):f=t[13];let p;return t[14]!==n||t[15]!==d||t[16]!==f?(p=(0,$.jsx)(l,{...n,onClick:d,to:f}),t[14]=n,t[15]=d,t[16]=f,t[17]=p):p=t[17],p}function zn(e){let t=(0,vn.c)(19),{zh:n}=e,{data:r,error:i,mutate:a}=X(`voice-dictation-route`,Bn),o,s;t[0]===a?(o=t[1],s=t[2]):(o=()=>{let e=()=>{a()};return window.addEventListener(`voice-config-changed`,e),window.addEventListener(`config-reload`,e),()=>{window.removeEventListener(`voice-config-changed`,e),window.removeEventListener(`config-reload`,e)}},s=[a],t[0]=a,t[1]=o,t[2]=s),(0,Q.useEffect)(o,s);let c=n?`同时用于聊天听写`:`Also used for chat dictation`,l;t[3]===c?l=t[4]:(l=(0,$.jsx)(`h2`,{className:`font-medium text-fg`,children:c}),t[3]=c,t[4]=l);let u=n?`默认与录音识别共用模型。已有的独立听写设置会保留。`:`Dictation shares this recognition model. Existing separate dictation settings are preserved.`,d;t[5]===u?d=t[6]:(d=(0,$.jsx)(`p`,{className:`text-fg-muted`,children:u}),t[5]=u,t[6]=d);let f;t[7]!==r||t[8]!==i||t[9]!==n?(f=!r&&!i?(0,$.jsx)(Me,{className:`h-5 w-64 max-w-full`}):(0,$.jsx)(`p`,{role:i?`alert`:`status`,className:`text-fg-muted`,children:i?n?`暂时无法读取听写状态。`:`Dictation status could not be loaded.`:r?.mode===`recorded`?n?`当前使用 ${r.provider},点击完成后转为文字。`:`Using ${r.provider}. Choose Finish to transcribe.`:r?.mode===`streaming`?n?`当前使用流式识别${r.provider?` · ${r.provider}`:``}。`:`Using streaming recognition${r.provider?` · ${r.provider}`:``}.`:n?`听写未就绪,请检查识别模型或已有的流式配置。`:`Check the recognition model or existing streaming configuration.`}),t[7]=r,t[8]=i,t[9]=n,t[10]=f):f=t[10];let p;t[11]!==r?.mode||t[12]!==n?(p=r?.mode===`recorded`?null:(0,$.jsx)(Rn,{className:`inline-block text-accent-fg hover:underline`,to:`/settings/capabilities/models?tab=services&configure=transcription`,children:n?`管理识别服务`:`Manage recognition services`}),t[11]=r?.mode,t[12]=n,t[13]=p):p=t[13];let m;return t[14]!==l||t[15]!==d||t[16]!==f||t[17]!==p?(m=(0,$.jsxs)(`section`,{className:`space-y-2 rounded-xl border border-edge p-4 text-sm`,children:[l,d,f,p]}),t[14]=l,t[15]=d,t[16]=f,t[17]=p,t[18]=m):m=t[18],m}function Bn(){return Ge(AbortSignal.timeout(15e3))}function Vn({v:e,canListen:t,canSpeak:n,disabled:r,onVerified:i}){let a=e.setup,o=(0,Q.useContext)(T)?.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 Yt(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 Ue,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:Ve()}),t.signal.aborted){l();return}if(s=await Ke.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 We.start(r,{onSamples:e=>{f&&!t.signal.aborted&&s?.sendAudio(f.push(e))}}),t.signal.aborted){l();return}f=new He(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)(Z,{type:`button`,variant:`primary`,disabled:o||r||!t||y,onClick:()=>void v(!0),children:[y?(0,$.jsx)(ge,{className:`size-4 animate-spin`}):(0,$.jsx)(_e,{className:`size-4`}),n?a.test:a.testInput]}),(0,$.jsxs)(Z,{type:`button`,variant:`secondary`,disabled:o||r||!n||y,onClick:()=>void v(!1),children:[(0,$.jsx)(ye,{className:`size-4`}),e.tts.test.play]}),y?(0,$.jsxs)(Z,{type:`button`,variant:`ghost`,onClick:()=>{_(),g(`idle`)},children:[(0,$.jsx)(Ee,{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)(Z,{type:`button`,variant:`secondary`,onClick:()=>{_(),i?.({input:h.current,output:!0}),g(`passed`)},children:a.heard}),(0,$.jsx)(Z,{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 Hn(e){let t=(0,vn.c)(78),{section:n,v:r,form:i,pending:a,onChange:o}=e,s=p(qn),c=r.setup,l;t[0]===i?l=t[1]:(l=JSON.stringify(i),t[0]=i,t[1]=l);let u=l,f;t[2]===u?f=t[3]:(f={signature:u,input:!1,output:!1},t[2]=u,t[3]=f);let[m,h]=(0,Q.useState)(f);m.signature!==u&&h({signature:u,input:!1,output:!1});let g;t[4]!==a||t[5]!==u?(g=a?null:[`voice-realtime-status`,u],t[4]=a,t[5]=u,t[6]=g):g=t[6];let _;t[7]===Symbol.for(`react.memo_cache_sentinel`)?(_={revalidateOnFocus:!0},t[7]=_):_=t[7];let{data:v,error:y,isLoading:b}=X(g,en,_),x;t[8]===Symbol.for(`react.memo_cache_sentinel`)?(x=d(`/api/voice/catalog`),t[8]=x):x=t[8];let{data:S}=X(x,Kn),C=i.voice.realtime,w=C.tts,T=w?.provider??v?.tts?.provider,E=v?.tts?.model,k;t[9]!==E||t[10]!==T?(k=T&&E?[`realtime-voices`,T,E]:null,t[9]=E,t[10]=T,t[11]=k):k=t[11];let A;t[12]!==E||t[13]!==T?(A=()=>Xt(T,E,`realtime`),t[12]=E,t[13]=T,t[14]=A):A=t[14];let j;t[15]===Symbol.for(`react.memo_cache_sentinel`)?(j={revalidateOnFocus:!1},t[15]=j):j=t[15];let{data:M}=X(k,A,j),N;t[16]===M?N=t[17]:(N=M===void 0?[]:M,t[16]=M,t[17]=N);let P=N,F=P,I;t[18]===P?I=t[19]:(I=P.filter(Gn),t[18]=P,t[19]=I);let L=I,R=C.defaultEngine===`omni`,z=R?C.omni?.voice??``:w?.voice??``,B;t[20]!==S?.models||t[21]!==R||t[22]!==L||t[23]!==C.omni||t[24]!==F?(B=R&&C.omni?.provider===`qwen-token-plan-cn`?[{id:C.omni.voice,name:C.omni.voice}]:R?C.omni?.provider===`xopc-cloud`?S?.models.find(e=>e.id===C.omni?.model)?.voice.voices.filter(Wn)??[]:L.length?L:[`Cherry`,`Ethan`,`Serena`,`Chelsie`].map(Un):F,t[20]=S?.models,t[21]=R,t[22]=L,t[23]=C.omni,t[24]=F,t[25]=B):B=t[25];let ee=B,V=!!(v?.enabled&&v.stt),te=!!(v?.enabled&&v.tts),H;t[26]!==i||t[27]!==o||t[28]!==C?(H=e=>o({...i,voice:{...i.voice,realtime:{...C,...e}}}),t[26]=i,t[27]=o,t[28]=C,t[29]=H):H=t[29];let U=H,W;t[30]!==a||t[31]!==C.enabled||t[32]!==c.disabled||t[33]!==c.needsSetup||t[34]!==c.pending||t[35]!==c.unverified||t[36]!==c.verified||t[37]!==u||t[38]!==m.signature?(W=(e,t)=>C.enabled?a?c.pending:e?t&&m.signature===u?c.verified:c.unverified:c.needsSetup:c.disabled,t[30]=a,t[31]=C.enabled,t[32]=c.disabled,t[33]=c.needsSetup,t[34]=c.pending,t[35]=c.unverified,t[36]=c.verified,t[37]=u,t[38]=m.signature,t[39]=W):W=t[39];let ne=W,re;t[40]!==z||t[41]!==s||t[42]!==R||t[43]!==T||t[44]!==C.bargeIn||t[45]!==C.defaultEngine||t[46]!==C.enabled||t[47]!==C.omni||t[48]!==C.tts||t[49]!==c.bargeIn||t[50]!==c.defaultVoice||t[51]!==c.enable||t[52]!==c.voice||t[53]!==n||t[54]!==w||t[55]!==v?.tts||t[56]!==U||t[57]!==r.experience||t[58]!==r.realtime||t[59]!==ee?(re=n===`listening`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`label`,{className:`flex items-center justify-between gap-3 text-sm font-medium text-fg`,children:[(0,$.jsx)(`span`,{children:c.enable}),(0,$.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":C.enabled,className:`ui-checkbox`,checked:C.enabled,onChange:e=>U({enabled:e.target.checked})})]}),(0,$.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[(0,$.jsx)(`span`,{children:r.experience.defaultMode}),(0,$.jsxs)(D,{value:C.defaultEngine,className:rt,onChange:e=>U({defaultEngine:e.target.value}),children:[(0,$.jsx)(O,{value:`agent`,children:r.experience.assistant}),(0,$.jsx)(O,{value:`omni`,children:r.experience.natural})]})]}),(0,$.jsxs)(`p`,{className:`text-xs text-fg-muted`,children:[C.defaultEngine===`agent`?r.experience.assistantHint:r.experience.naturalHint,` `,r.experience.nextCall]}),(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,$.jsx)(`label`,{htmlFor:`realtime-voice`,className:`text-sm font-medium text-fg`,children:c.voice}),(0,$.jsxs)(D,{id:`realtime-voice`,className:`${rt} w-full sm:w-56`,value:z,disabled:R?!C.omni:!w&&!v?.tts,onChange:e=>{if(R&&C.omni){U({omni:{...C.omni,voice:e.target.value}});return}if(T===`alibaba`||T===`xopc-cloud`){let t={...C.tts,provider:T};e.target.value?t.voice=e.target.value:delete t.voice,U({tts:t})}},children:[R?null:(0,$.jsx)(O,{value:``,children:c.defaultVoice}),z&&!ee.some(e=>e.id===z)?(0,$.jsx)(O,{value:z,children:z}):null,ee.map(e=>(0,$.jsxs)(O,{value:e.id,children:[_t(e,s),`gender`in e&&e.gender?` · ${e.gender===`female`?`女声`:`男声`}`:``,`style`in e&&e.style?` · ${e.style}`:``]},e.id))]}),(()=>{let e=ee.find(e=>e.id===z);return e&&`description`in e&&typeof e.description==`string`?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:e.description}):null})()]}),(0,$.jsxs)(`label`,{className:`flex items-center justify-between gap-4 text-sm text-fg`,children:[(0,$.jsxs)(`span`,{children:[c.bargeIn,(0,$.jsx)(`span`,{className:`mt-1 block text-xs text-fg-muted`,children:r.realtime.bargeInDescription})]}),(0,$.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":C.bargeIn,checked:C.bargeIn,className:`size-4 accent-accent`,onChange:e=>U({bargeIn:e.target.checked})})]})]}):null,t[40]=z,t[41]=s,t[42]=R,t[43]=T,t[44]=C.bargeIn,t[45]=C.defaultEngine,t[46]=C.enabled,t[47]=C.omni,t[48]=C.tts,t[49]=c.bargeIn,t[50]=c.defaultVoice,t[51]=c.enable,t[52]=c.voice,t[53]=n,t[54]=w,t[55]=v?.tts,t[56]=U,t[57]=r.experience,t[58]=r.realtime,t[59]=ee,t[60]=re):re=t[60];let G;t[61]!==V||t[62]!==te||t[63]!==y||t[64]!==b||t[65]!==a||t[66]!==n||t[67]!==u||t[68]!==v||t[69]!==ne||t[70]!==r||t[71]!==m.input||t[72]!==m.output?(G=n===`diagnostics`?(0,$.jsxs)($.Fragment,{children:[b?(0,$.jsx)(Me,{className:`h-16 w-full`}):(0,$.jsxs)(`div`,{className:`space-y-2 text-sm`,role:`status`,children:[(0,$.jsxs)(`p`,{children:[r.experience.dictationReady,` · `,ne(V,m.input)]}),(0,$.jsxs)(`p`,{children:[r.experience.agentReady,` · `,ne(V&&te,m.input&&m.output)]}),(0,$.jsxs)(`p`,{children:[r.experience.omniReady,` · `,ne(!!(v?.enabled&&v.omni),!1)]})]}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:r.experience.configurationOnly}),(0,$.jsx)(Vn,{v:r,canListen:V,canSpeak:te,disabled:a||b||!!y,onVerified:e=>h({signature:u,...e})},`${u}:${JSON.stringify(v)}`)]}):null,t[61]=V,t[62]=te,t[63]=y,t[64]=b,t[65]=a,t[66]=n,t[67]=u,t[68]=v,t[69]=ne,t[70]=r,t[71]=m.input,t[72]=m.output,t[73]=G):G=t[73];let K;return t[74]!==c.service||t[75]!==re||t[76]!==G?(K=(0,$.jsxs)(`section`,{className:`space-y-5 rounded-xl bg-surface-hover/20 p-4 sm:p-5`,"aria-label":c.service,children:[re,G]}),t[74]=c.service,t[75]=re,t[76]=G,t[77]=K):K=t[77],K}function Un(e){return{id:e,name:e}}function Wn(e){return hn(e,`conversation`)}function Gn(e){return[`Cherry`,`Ethan`,`Serena`,`Chelsie`].includes(e.id)}async function Kn(e){return _n.parse((await m(e)).payload)}function qn(e){return e.language}function Jn(e){let t=(0,vn.c)(19),{value:n,onChange:r}=e,i=p(Yn)===`zh`,a=i?`通话指令`:`Conversation instructions`,o;t[0]===a?o=t[1]:(o=(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:a}),t[0]=a,t[1]=o);let s=i?`通话会接续当前会话。可在这里调整语气与回答方式。`:`Calls continue the current conversation. Adjust tone and response style here.`,c;t[2]===s?c=t[3]:(c=(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:s}),t[2]=s,t[3]=c);let l=i?`通话指令`:`Conversation instructions`,u;t[4]===l?u=t[5]:(u=(0,$.jsx)(`span`,{children:l}),t[4]=l,t[5]=u);let d;t[6]!==r||t[7]!==n?(d=e=>r({...n,instructions:e.target.value}),t[6]=r,t[7]=n,t[8]=d):d=t[8];let f;t[9]!==d||t[10]!==n.instructions?(f=(0,$.jsx)(`textarea`,{className:`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,rows:3,maxLength:8e3,value:n.instructions,onChange:d}),t[9]=d,t[10]=n.instructions,t[11]=f):f=t[11];let m;t[12]!==u||t[13]!==f?(m=(0,$.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[u,f]}),t[12]=u,t[13]=f,t[14]=m):m=t[14];let h;return t[15]!==o||t[16]!==c||t[17]!==m?(h=(0,$.jsxs)(`details`,{className:`space-y-3 rounded-xl bg-surface-hover/20 p-4`,children:[o,c,m]}),t[15]=o,t[16]=c,t[17]=m,t[18]=h):h=t[18],h}function Yn(e){return e.language}var Xn=nt;function Zn(){return Y(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,it,`dark:border-edge`)}function Qn(){return Y(rt,nt)}function $n(e){return!e||e<=0?``:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/1024/1024).toFixed(1)} MB`}function er(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 tr(e,t){switch(e){case`xopc-cloud`:return t.setup.hosted;case`openai`:return t.stt.openai;case`alibaba`:return t.stt.alibaba;case`groq`:return`Groq`;default:return e}}function nr(e,t){switch(e){case`xopc-cloud`:return t.setup.hosted;case`openai`:return t.tts.providerOpenai;case`alibaba`:return t.stt.alibaba;case`edge`:return t.tts.providerEdge;case`minimax`:return`MiniMax`;default:return e}}function rr(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 ir(e){return{maskedHelp:e.apiKeyMaskedHelp,copy:e.apiKeyCopy,copied:e.apiKeyCopied,show:e.apiKeyShow,hide:e.apiKeyHide,notInConfigFile:e.apiKeyNotInConfigFile,loadFailed:e.apiKeyRevealFailed}}function ar(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`&&``:t.defaultValue}function or(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 sr(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 cr(e){let t=(0,vn.c)(4),[n,r]=(0,Q.useState)(0),i;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=()=>r(lr),t[0]=i):i=t[0];let a;return t[1]!==n||t[2]!==e?(a=(0,$.jsx)(ur,{...e,onReload:i},n),t[1]=n,t[2]=e,t[3]=a):a=t[3],a}function lr(e){return e+1}function ur({capability:e,onPendingChange:t,disabled:n=!1,onReload:r}){let i=p(e=>e.language),a=h(i).voiceSettings,o=Be(e=>e.captions),s=Be(e=>e.setCaptions),c=!!f(e=>e.conversationId),[l,u]=(0,Q.useState)(!1),[m,g]=(0,Q.useReducer)(sr,{form:null,baseline:null}),_=m.form,v=m.baseline,[y,b]=(0,Q.useState)(null),x=(0,Q.useRef)(!1),S=(0,Q.useRef)({}),C=(0,Q.useRef)(_);C.current=_;let w=(0,Q.useRef)({parsed:null,models:void 0}),{data:T,error:E,isLoading:k,mutate:A}=Je(c),{data:j,error:M,isLoading:N,mutate:P}=X(c?d(`/api/voice/models`):null,Qt,{revalidateOnFocus:!1}),{data:F,error:I,isLoading:L}=X(c?d(`/api/voice/providers`):null,Jt,{revalidateOnFocus:!1}),{data:R,error:z,isLoading:B}=X(c?d(`/api/voice/stt-providers`):null,Zt,{revalidateOnFocus:!1}),ee=(0,Q.useMemo)(()=>F?.providers??[],[F]),V=(0,Q.useMemo)(()=>R?.providers??[],[R]),te=(0,Q.useMemo)(()=>T?.payload?.config===void 0?null:$t(T.payload.config),[T]),H=(0,Q.useMemo)(()=>!_||!v?!1:JSON.stringify(_)!==JSON.stringify(v),[_,v]);c?te!==null&&j!==void 0&&!x.current&&(w.current.parsed!==te||w.current.models!==j)&&(w.current={parsed:te,models:j},S.current=tn(T?.payload?.config),g({type:`sync`,value:te}),b(j)):(w.current.parsed!==null||w.current.models!==void 0)&&(w.current={parsed:null,models:void 0},g({type:`reset`}),b(null),x.current=!1);let U=!!(c&&(te===null||j===void 0||F===void 0||R===void 0)&&(k||N||L||B)),W=E instanceof Error?E.message:E?String(E):M instanceof Error?M.message:M?String(M):I instanceof Error?I.message:I?String(I):z instanceof Error?z.message:z?String(z):null,ne=(0,Q.useCallback)(e=>{x.current=!0,g({type:`update`,updater:t=>t?{...t,stt:{...t.stt,...e},...e.provider&&e.provider!==`xopc-cloud`?{voice:{...t.voice,realtime:{...t.voice.realtime,stt:void 0}}}:{}}:null})},[]),re=(0,Q.useCallback)(e=>{x.current=!0,g({type:`update`,updater:t=>{if(!t)return null;let n=t.stt.fallback??{enabled:!1,order:[]};return{...t,stt:{...t.stt,fallback:{...n,...e}}}}})},[]),G=(0,Q.useCallback)(e=>{x.current=!0,g({type:`update`,updater:t=>t?{...t,voice:{...t.voice,input:{...t.voice.input,refinement:{...t.voice.input.refinement,...e}}}}:null})},[]),K=(0,Q.useCallback)(e=>{x.current=!0,g({type:`update`,updater:t=>t?{...t,voice:{...t.voice,languageMode:e,...e===`auto`?{language:i}:{}}}:null})},[i]),ie=(0,Q.useCallback)(e=>{x.current=!0,g({type:`update`,updater:t=>t?{...t,voice:{...t.voice,realtime:{...t.voice.realtime,...e}}}:null})},[]),ae=(0,Q.useCallback)(e=>{x.current=!0,g({type:`update`,updater:t=>t?{...t,tts:{...t.tts,...e}}:null})},[]),q=Gt({value:_,dirty:H,onSave:(0,Q.useCallback)(async t=>{try{let n=await Kt(t,e,S.current[e]);S.current={...S.current,...n},g({type:`saved`,value:t}),x.current=!!(C.current&&JSON.stringify(C.current)!==JSON.stringify(t))}catch(e){throw Error(e instanceof Error?e.message:a.saveError)}},[a.saveError,e])});(0,Q.useEffect)(()=>{t?.(H||q.status===`saving`||l)},[H,q.status,l,t]),(0,Q.useEffect)(()=>()=>t?.(!1),[t]);let oe=(0,Q.useCallback)(e=>{x.current=!0,g({type:`update`,updater:()=>e})},[]);if(!c)return(0,$.jsx)(`div`,{className:`flex flex-col gap-3`,children:(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:a.needToken})});if(U)return(0,$.jsx)(xt,{rows:4});if(!_||y===null)return(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:W??a.loadError}),(0,$.jsx)(Z,{type:`button`,variant:`secondary`,onClick:()=>{A(),P()},children:a.retry})]});let se=_.stt,ce=_.tts,J=_.voice.input.refinement,le=ir(a);return(0,$.jsxs)(`fieldset`,{disabled:n||l,className:`flex min-w-0 flex-col gap-4`,onBlurCapture:q.error?void 0:q.onBlurCapture,children:[(0,$.jsx)(Wt,{status:q.status,error:q.error}),q.error?(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,$.jsx)(Z,{variant:`secondary`,onClick:q.retry,children:i===`zh`?`重试保存`:`Retry saving`}),(0,$.jsx)(Z,{variant:`ghost`,onClick:()=>{A().then(()=>r()).catch(()=>{})},children:i===`zh`?`重新加载(放弃未保存更改)`:`Reload and discard unsaved changes`})]}):null,e===`transcription`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(zn,{zh:i===`zh`}),(0,$.jsx)(pr,{managedModel:!0,v:a,apiKeyLabels:le,stt:se,models:y,sttProviders:V,updateStt:ne,updateSttFallback:re}),(0,$.jsx)(fr,{v:a,voice:_.voice,updateLanguageMode:K}),(0,$.jsxs)(`details`,{"data-voice-section":`input-processing`,className:`rounded-xl bg-surface-hover/20 p-4`,children:[(0,$.jsxs)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:[a.experience.inputProcessing,` · `,J.mode===`off`?a.stt.refinementOff:J.mode===`punctuation`?a.stt.refinementPunctuation:J.mode===`light`?a.stt.refinementLight:a.setup.advanced]}),(0,$.jsxs)(`label`,{className:`mt-4 block space-y-2 text-sm`,children:[(0,$.jsx)(`span`,{children:a.stt.refinement}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:a.stt.refinementDesc}),(0,$.jsxs)(D,{className:Qn(),value:J.mode,onChange:e=>G({mode:e.target.value}),children:[(0,$.jsx)(O,{value:`off`,children:a.stt.refinementOff}),(0,$.jsx)(O,{value:`punctuation`,children:a.stt.refinementPunctuation}),(0,$.jsx)(O,{value:`light`,children:a.stt.refinementLight}),J.mode===`custom`?(0,$.jsx)(O,{value:`custom`,children:a.setup.advanced}):null]})]})]}),se.provider===`xopc-cloud`?(0,$.jsxs)(`details`,{className:`rounded-xl border border-edge p-4`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium`,children:i===`zh`?`实时听写`:`Live dictation`}),(0,$.jsx)(`div`,{className:`mt-4`,children:(0,$.jsx)(Fn,{modes:[`transcription.stream`],disabled:H||q.status===`saving`,onPendingChange:u})})]}):null]}):e===`speech`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(hr,{managedModel:!0,v:a,apiKeyLabels:le,tts:ce,models:y,ttsProviders:ee,updateTts:ae}),(0,$.jsx)(dr,{v:a,tts:ce,updateTts:ae})]}):(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Hn,{section:`listening`,v:a,form:_,pending:H||q.status===`saving`||!!q.error,onChange:oe}),_.voice.realtime.defaultEngine===`omni`&&_.voice.realtime.omni?(0,$.jsx)(Jn,{value:_.voice.realtime.omni,onChange:e=>ie({omni:e})}):null,(0,$.jsx)(`section`,{className:`rounded-xl bg-surface-hover/20 px-4 py-5 sm:px-5`,children:(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-[minmax(0,1fr)_minmax(12rem,18rem)] sm:items-center`,children:[(0,$.jsx)(`div`,{className:`text-sm font-semibold text-fg`,children:a.experience.pace}),(0,$.jsxs)(D,{className:Qn(),value:String(_.voice.realtime.silenceDurationMs),onChange:e=>ie({silenceDurationMs:Number(e.target.value)}),children:[(0,$.jsx)(O,{value:`800`,children:a.experience.fast}),(0,$.jsx)(O,{value:`1200`,children:a.experience.standard}),(0,$.jsx)(O,{value:`2000`,children:a.experience.relaxed}),[800,1200,2e3].includes(_.voice.realtime.silenceDurationMs)?null:(0,$.jsxs)(O,{value:String(_.voice.realtime.silenceDurationMs),children:[_.voice.realtime.silenceDurationMs,` ms`]})]})]})}),(0,$.jsxs)(`label`,{className:`flex items-center justify-between text-sm`,children:[a.experience.captions,(0,$.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":o,className:`ui-checkbox`,checked:o,onChange:e=>s(e.target.checked)})]}),_.voice.realtime.defaultEngine===`agent`&&se.provider===`xopc-cloud`?(0,$.jsxs)(`details`,{className:`rounded-xl border border-edge p-4`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium`,children:i===`zh`?`语音助手输出`:`Assistant speech output`}),(0,$.jsx)(`div`,{className:`mt-4`,children:(0,$.jsx)(Fn,{modes:[`speech.stream`],disabled:H||q.status===`saving`,onPendingChange:u})})]}):null,(0,$.jsxs)(`details`,{className:`rounded-xl border border-edge p-4`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium`,children:i===`zh`?`麦克风、扬声器与诊断`:`Microphone, speakers and diagnostics`}),(0,$.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[(0,$.jsx)(In,{v:a}),(0,$.jsx)(Hn,{section:`diagnostics`,v:a,form:_,pending:H||q.status===`saving`||!!q.error,onChange:oe})]})]})]})]})}function dr(e){let t=(0,vn.c)(29),{v:n,tts:r,updateTts:i}=e,a;t[0]===n.setup.readout?a=t[1]:(a=(0,$.jsx)(`span`,{className:`font-medium`,children:n.setup.readout}),t[0]=n.setup.readout,t[1]=a);let o=n.setup.readout,s;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(s=Qn(),t[2]=s):s=t[2];let c=r.enabled?r.trigger:`off`,l;t[3]===i?l=t[4]:(l=e=>i({enabled:e.target.value!==`off`,trigger:e.target.value}),t[3]=i,t[4]=l);let u;t[5]===n.tts.triggerOff?u=t[6]:(u=(0,$.jsx)(O,{value:`off`,children:n.tts.triggerOff}),t[5]=n.tts.triggerOff,t[6]=u);let d;t[7]===n.tts.triggerInbound?d=t[8]:(d=(0,$.jsx)(O,{value:`inbound`,children:n.tts.triggerInbound}),t[7]=n.tts.triggerInbound,t[8]=d);let f;t[9]===n.tts.triggerAlways?f=t[10]:(f=(0,$.jsx)(O,{value:`always`,children:n.tts.triggerAlways}),t[9]=n.tts.triggerAlways,t[10]=f);let p;t[11]===n.tts.triggerTagged?p=t[12]:(p=(0,$.jsx)(O,{value:`tagged`,children:n.tts.triggerTagged}),t[11]=n.tts.triggerTagged,t[12]=p);let m;t[13]!==c||t[14]!==l||t[15]!==u||t[16]!==d||t[17]!==f||t[18]!==p||t[19]!==n.setup.readout?(m=(0,$.jsxs)(D,{"aria-label":o,className:s,value:c,onChange:l,children:[u,d,f,p]}),t[13]=c,t[14]=l,t[15]=u,t[16]=d,t[17]=f,t[18]=p,t[19]=n.setup.readout,t[20]=m):m=t[20];let h;t[21]!==a||t[22]!==m?(h=(0,$.jsxs)(`label`,{className:`block space-y-2 text-sm`,children:[a,m]}),t[21]=a,t[22]=m,t[23]=h):h=t[23];let g;t[24]===n.setup.readoutHint?g=t[25]:(g=(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.setup.readoutHint}),t[24]=n.setup.readoutHint,t[25]=g);let _;return t[26]!==h||t[27]!==g?(_=(0,$.jsxs)(`section`,{className:`space-y-2 rounded-xl bg-surface-hover/20 p-4 sm:p-5`,children:[h,g]}),t[26]=h,t[27]=g,t[28]=_):_=t[28],_}function fr(e){let t=(0,vn.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=Qn(),t[7]=l):l=t[7];let u;t[8]===i?u=t[9]:(u=e=>i(e.target.value),t[8]=i,t[9]=u);let d;t[10]===n.language.auto?d=t[11]:(d=(0,$.jsx)(O,{value:`auto`,children:n.language.auto}),t[10]=n.language.auto,t[11]=d);let f;t[12]===n.language.manual?f=t[13]:(f=(0,$.jsx)(O,{value:`manual`,children:n.language.manual}),t[12]=n.language.manual,t[13]=f);let p;t[14]!==u||t[15]!==d||t[16]!==f||t[17]!==r.languageMode?(p=(0,$.jsxs)(D,{className:l,value:r.languageMode,onChange:u,children:[d,f]}),t[14]=u,t[15]=d,t[16]=f,t[17]=r.languageMode,t[18]=p):p=t[18];let m;return t[19]!==c||t[20]!==p?(m=(0,$.jsx)(`section`,{className:`rounded-xl bg-surface-hover/20 px-4 py-5 sm:px-5`,children:(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-[minmax(0,1fr)_minmax(12rem,18rem)] sm:items-center`,children:[c,p]})}),t[19]=c,t[20]=p,t[21]=m):m=t[21],m}function pr(e){let t=(0,vn.c)(65),{v:n,apiKeyLabels:r,stt:i,models:a,sttProviders:o,updateStt:s,updateSttFallback:c,managedModel:l}=e,u=l!==void 0&&l,d;if(t[0]!==o){let e=new Set;d=[];for(let t of o)e.has(t.id)||(e.add(t.id),d.push(t));t[0]=o,t[1]=d}else d=t[1];let f=d,p,m,h,g;if(t[2]!==a||t[3]!==f||t[4]!==i.provider||t[5]!==i.providers){p=f.find(e=>e.id===i.provider);let e;t[10]!==i.provider||t[11]!==i.providers?(e=i.providers?.[i.provider]??{},t[10]=i.provider,t[11]=i.providers,t[12]=e):e=t[12],h=e,m=a?.stt?.[i.provider]?.length?a.stt[i.provider]:p?.models??[],g=p?.fields.find(mr),t[2]=a,t[3]=f,t[4]=i.provider,t[5]=i.providers,t[6]=p,t[7]=m,t[8]=h,t[9]=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 x=b,S,C;t[17]!==v||t[18]!==y||t[19]!==u||t[20]!==_||t[21]!==x?(S=()=>{!u&&_&&y&&v!==y&&x({model:y})},C=[u,v,y,_,x],t[17]=v,t[18]=y,t[19]=u,t[20]=_,t[21]=x,t[22]=S,t[23]=C):(S=t[22],C=t[23]),(0,Q.useEffect)(S,C);let w;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(w=(0,$.jsx)(_e,{"aria-hidden":`true`,className:`size-4 text-accent`,strokeWidth:1.75}),t[24]=w):w=t[24];let T;t[25]===n.stt.title?T=t[26]:(T=(0,$.jsxs)(`h3`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[w,n.stt.title]}),t[25]=n.stt.title,t[26]=T);let E;t[27]===n.stt.enable?E=t[28]:(E=(0,$.jsx)(`span`,{children:n.stt.enable}),t[27]=n.stt.enable,t[28]=E);let k;t[29]===s?k=t[30]:(k=e=>s({enabled:e.target.checked}),t[29]=s,t[30]=k);let A;t[31]!==i.enabled||t[32]!==k?(A=(0,$.jsx)(`input`,{type:`checkbox`,role:`switch`,"aria-checked":i.enabled,className:`ui-checkbox`,checked:i.enabled,onChange:k}),t[31]=i.enabled,t[32]=k,t[33]=A):A=t[33];let j;t[34]!==A||t[35]!==E?(j=(0,$.jsxs)(`label`,{className:`flex min-h-10 items-center gap-2 text-xs text-fg-muted`,children:[E,A]}),t[34]=A,t[35]=E,t[36]=j):j=t[36];let M;t[37]!==j||t[38]!==T?(M=(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[T,j]}),t[37]=j,t[38]=T,t[39]=M):M=t[39];let N;t[40]===n.stt.description?N=t[41]:(N=(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:n.stt.description}),t[40]=n.stt.description,t[41]=N);let P;t[42]!==M||t[43]!==N?(P=(0,$.jsxs)(`div`,{className:`mb-4`,children:[M,N]}),t[42]=M,t[43]=N,t[44]=P):P=t[44];let F;t[45]!==p?.fields||t[46]!==r||t[47]!==y||t[48]!==u||t[49]!==m||t[50]!==f||t[51]!==h||t[52]!==i.enabled||t[53]!==i.fallback?.enabled||t[54]!==i.provider||t[55]!==x||t[56]!==s||t[57]!==c||t[58]!==n?(F=i.enabled?(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[u?null:(0,$.jsxs)(`div`,{className:Y(`flex flex-col gap-1.5`,Xn),children:[(0,$.jsx)(Cr,{children:n.stt.provider}),(0,$.jsx)(D,{"aria-label":n.stt.provider,className:Qn(),value:i.provider,onChange:e=>s({provider:e.target.value}),children:f.map(e=>(0,$.jsxs)(O,{value:e.id,children:[tr(e.id,n),e.configured?``:` *`]},e.id))})]}),(0,$.jsx)(gr,{managedModel:u,kind:`stt`,providerId:i.provider,fields:p?.fields??[],providerSlice:h,models:m,currentModel:y,apiKeyLabels:r,onPatch:x})]}),i.provider===`alibaba`?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.setup.keyHint}):null,(0,$.jsxs)(`details`,{className:`rounded-lg border border-edge p-3`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:n.stt.fallback}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n.stt.fallback}),(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:n.stt.fallbackDesc})]}),(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:i.fallback?.enabled??!1,onChange:e=>c({enabled:e.target.checked})})]})]})]}):null,t[45]=p?.fields,t[46]=r,t[47]=y,t[48]=u,t[49]=m,t[50]=f,t[51]=h,t[52]=i.enabled,t[53]=i.fallback?.enabled,t[54]=i.provider,t[55]=x,t[56]=s,t[57]=c,t[58]=n,t[59]=F):F=t[59];let I;t[60]===F?I=t[61]:(I=(0,$.jsx)(`div`,{className:`space-y-4`,children:F}),t[60]=F,t[61]=I);let L;return t[62]!==P||t[63]!==I?(L=(0,$.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 px-4 py-5 sm:px-5`,children:[P,I]}),t[62]=P,t[63]=I,t[64]=L):L=t[64],L}function mr(e){return e.key===`model`}function hr({v:e,apiKeyLabels:t,tts:n,models:r,ttsProviders:i,updateTts:a,managedModel:o=!1}){let[s,c]=(0,Q.useState)(e.tts.test.sampleText),[l,u]=(0,Q.useState)({status:`idle`}),d=(0,Q.useRef)(null),f=(0,Q.useRef)(null),p=(0,Q.useRef)(null),m=(0,Q.useCallback)(()=>{p.current?.abort(),p.current=null,d.current?.pause(),d.current=null,f.current&&=(URL.revokeObjectURL(f.current),null)},[]),h=(0,Q.useMemo)(()=>{let e=new Set,t=[];for(let n of i)e.has(n.id)||(e.add(n.id),t.push(n));return t},[i]),g=h.find(e=>e.id===n.provider),_=n.providers?.[n.provider]??{},v=r?.tts?.[n.provider]?.length?r.tts[n.provider]:g?.models??[],y=g?.fields.find(e=>e.key===`model`),b=g?.fields.find(e=>e.key===`voice`),x=typeof _.model==`string`?_.model:void 0,S=x??(typeof y?.defaultValue==`string`?y.defaultValue:v[0]?.id),C=v.find(e=>e.id===S),w=r?.ttsVoices?.[n.provider]?.length?r.ttsVoices[n.provider]:g?.voices??[],{data:T=[]}=X(S?`voice:tts:${n.provider}:${S}`:null,()=>Xt(n.provider,S??``),{revalidateOnFocus:!1}),E=T.length>0?T:w,k=typeof _.voice==`string`?_.voice:void 0,A=k??E.find(e=>e.id===C?.tts?.defaultVoice)?.id??(typeof b?.defaultValue==`string`?b.defaultValue:E[0]?.id),j=(g?.fields??[]).filter(e=>(e.key!==`speed`||C?.tts?.speed!==!1)&&(e.key!==`instructions`||C?.tts?.instructions!==!1)),M=(0,Q.useCallback)(e=>{a({providers:{...n.providers??{},[n.provider]:{...n.providers?.[n.provider]??{},...e}}})},[n.provider,n.providers,a]);(0,Q.useEffect)(()=>{if(o)return;let e={};y&&S&&x!==S&&(e.model=S),b&&A&&k!==A&&(e.voice=A),Object.keys(e).length>0&&M(e)},[o,x,k,S,A,y,M,b]),(0,Q.useEffect)(()=>()=>m(),[m]);let N=(0,Q.useCallback)(e=>{a({provider:e}),u({status:`idle`})},[a]),P=(0,Q.useCallback)(async()=>{let t=s.trim();if(!t){u({status:`error`,message:e.tts.test.emptyText});return}m();let r=new AbortController;p.current=r,u({status:`loading`});try{let i=await qt({text:t,provider:n.provider,providerConfig:_,...S?{model:S}:{},...A?{voice:A}:{}},r.signal);if(r.signal.aborted)return;let a=er(i.audio,i.mimeType);f.current=a;let o=new Audio(a);d.current=o;let s=[i.provider,i.format,i.latencyMs===void 0?void 0:`${i.latencyMs}ms`,$n(i.audioSize)].filter(Boolean).join(` · `);o.addEventListener(`ended`,()=>u({status:`done`,summary:s}),{once:!0}),o.addEventListener(`error`,()=>u({status:`error`,message:e.tts.test.playFailed}),{once:!0}),await o.play(),u({status:`playing`,summary:s})}catch(e){if(r.signal.aborted)return;m(),u({status:`error`,message:e instanceof Error?e.message:String(e)})}},[S,A,_,m,s,n.provider,e.tts.test.emptyText,e.tts.test.playFailed]);return(0,$.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 px-4 py-5 sm:px-5`,children:[(0,$.jsxs)(`div`,{className:`mb-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2 text-sm font-semibold text-fg`,children:[(0,$.jsx)(ke,{className:`size-4 text-accent`,strokeWidth:1.75}),e.tts.title]}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.tts.description})]}),(0,$.jsx)(`div`,{className:`space-y-4`,children:(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:o?null:(0,$.jsxs)(`div`,{className:Y(`flex flex-col gap-1.5`,Xn),children:[(0,$.jsx)(Cr,{children:e.tts.provider}),(0,$.jsx)(D,{"aria-label":e.tts.provider,className:Qn(),value:n.provider,onChange:e=>N(e.target.value),children:h.map(t=>(0,$.jsx)(O,{value:t.id,children:nr(t.id,e)},t.id))}),(0,$.jsxs)(`p`,{className:`text-xs text-fg-subtle`,children:[g?.configured?e.tts.configured:g?.diagnostics.requiresApiKey?`${e.tts.needsKey} · ${g.diagnostics.envKeys?.join(`, `)??e.stt.apiKey}`:e.tts.noKeyNeeded,` · `,g?.description??rr(n.provider,e)]})]})}),(0,$.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:(0,$.jsx)(gr,{managedModel:o,kind:`tts`,providerId:n.provider,fields:j,providerSlice:_,models:v,voices:E,currentModel:S,currentVoice:A,apiKeyLabels:t,onPatch:M,resetVoiceOnModelChange:!0})}),(0,$.jsxs)(`details`,{className:`rounded-xl bg-surface-panel/80 p-3`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:e.tts.test.title}),(0,$.jsxs)(`div`,{className:`mt-3`,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between`,children:[(0,$.jsx)(`div`,{children:(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:e.tts.test.description})}),(0,$.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,$.jsxs)(Z,{type:`button`,variant:`primary`,onClick:()=>void P(),disabled:l.status===`loading`,className:`h-9`,children:[l.status===`loading`?(0,$.jsx)(ge,{className:`size-4 animate-spin`}):(0,$.jsx)(ye,{className:`size-4`}),l.status===`loading`?e.tts.test.generating:e.tts.test.play]}),(0,$.jsxs)(Z,{type:`button`,variant:`secondary`,onClick:()=>{m(),u(e=>e.status===`playing`?{status:`done`,summary:e.summary}:{status:`idle`})},disabled:l.status!==`playing`,className:`h-9`,children:[(0,$.jsx)(Ee,{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:Y(Zn(),`mt-3 min-h-20 resize-y`),value:s,onChange:e=>c(e.target.value),maxLength:1e3})]}),(0,$.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center justify-between gap-2 text-xs`,children:[(0,$.jsxs)(`span`,{className:`text-fg-subtle`,children:[s.length,`/1000`]}),l.status===`playing`||l.status===`done`?(0,$.jsxs)(`span`,{className:`text-emerald-700 dark:text-emerald-200`,children:[l.status===`playing`?e.tts.test.playing:e.tts.test.ready,` · `,l.summary]}):null,l.status===`error`?(0,$.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:l.message}):null]})]})]})]})})]})}function gr(e){let t=(0,vn.c)(48),{kind:n,providerId:r,fields:i,providerSlice:a,models:o,voices:s,currentModel:c,currentVoice:l,apiKeyLabels:u,onPatch:d,resetVoiceOnModelChange:f,managedModel:m}=e,g;t[0]===s?g=t[1]:(g=s===void 0?[]:s,t[0]=s,t[1]=g);let _=g,v=f!==void 0&&f,y=m!==void 0&&m,b=p(br),x;t[2]===b?x=t[3]:(x=h(b),t[2]=b,t[3]=x);let S=x.voiceSettings,C=y,w=yr,T=vr,E,k,A;if(t[4]!==u||t[5]!==c||t[6]!==l||t[7]!==i||t[8]!==n||t[9]!==b||t[10]!==y||t[11]!==o||t[12]!==d||t[13]!==r||t[14]!==a||t[15]!==v||t[16]!==C||t[17]!==S||t[18]!==_){let e;t[22]===C?e=t[23]:(e=e=>!C||e.key!==`model`&&!T(e),t[22]=C,t[23]=e);let s=i.filter(e),f;t[24]===Symbol.for(`react.memo_cache_sentinel`)?(f=e=>!w(e),t[24]=f):f=t[24];let p=s.filter(f),m;t[25]!==u||t[26]!==c||t[27]!==l||t[28]!==n||t[29]!==b||t[30]!==y||t[31]!==o||t[32]!==d||t[33]!==r||t[34]!==a||t[35]!==v||t[36]!==S||t[37]!==_?(m=e=>e.map(e=>y&&e.key===`model`?null:e.key===`apiKey`?(0,$.jsxs)(`div`,{className:Y(`flex flex-col gap-1.5`,Xn),children:[(0,$.jsx)(Cr,{htmlFor:`voice-${n}-${r}-api-key`,children:S.stt.apiKey}),(0,$.jsx)(nn,{kind:n,providerId:r,fieldId:`voice-${n}-${r}-api-key`,value:typeof a.apiKey==`string`?a.apiKey:``,onChange:e=>d({apiKey:e}),labels:u,placeholder:e.placeholder}),e.description?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:e.description}):null]},e.key):e.key===`model`&&o.length>0?(0,$.jsxs)(`div`,{className:Y(`flex flex-col gap-1.5`,Xn),children:[(0,$.jsx)(Cr,{htmlFor:`voice-${n}-${r}-model`,children:S.stt.model}),(0,$.jsx)(D,{id:`voice-${n}-${r}-model`,className:Qn(),value:c??``,onChange:e=>d({model:e.target.value,...v?{voice:void 0}:{}}),children:[...o].sort(mt).map(_r)})]},e.key):e.key===`voice`&&_.length>0?(0,$.jsxs)(`div`,{className:Y(`flex flex-col gap-1.5`,Xn),children:[(0,$.jsx)(Cr,{htmlFor:`voice-${n}-${r}-voice`,children:S.tts.voice}),(0,$.jsxs)(D,{id:`voice-${n}-${r}-voice`,className:Qn(),value:l??``,onChange:e=>d({voice:e.target.value}),children:[l&&!_.some(e=>e.id===l)?(0,$.jsxs)(O,{value:l,children:[l,` · unavailable`]}):null,_.map(e=>(0,$.jsxs)(O,{value:e.id,children:[_t(e,b),e.gender?` · ${e.gender===`female`?`女声`:`男声`}`:``,e.style?` · ${e.style}`:``]},e.id))]}),_.find(e=>e.id===l)?.description?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:_.find(e=>e.id===l)?.description}):null]},e.key):(0,$.jsx)(xr,{fieldId:`voice-${n}-${r}-${e.key}`,field:e,value:ar(a,e),onChange:t=>d({[e.key]:t}),className:e.type===`textarea`?`sm:col-span-2`:Xn},e.key)),t[25]=u,t[26]=c,t[27]=l,t[28]=n,t[29]=b,t[30]=y,t[31]=o,t[32]=d,t[33]=r,t[34]=a,t[35]=v,t[36]=S,t[37]=_,t[38]=m):m=t[38];let h=m;t[39]!==i||t[40]!==n||t[41]!==b||t[42]!==C?(E=C&&i.some(T)?(0,$.jsx)(Rn,{className:`text-sm text-accent-fg hover:underline`,to:`/settings/capabilities/models?tab=services&configure=${n===`stt`?`transcription`:`speech`}`,children:b===`zh`?`管理服务连接`:`Manage service connection`}):null,t[39]=i,t[40]=n,t[41]=b,t[42]=C,t[43]=E):E=t[43],k=h(s.filter(w)),A=p.length?(0,$.jsxs)(`details`,{className:`rounded-lg border border-edge p-3 sm:col-span-2`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:S.experience.providerOptions}),(0,$.jsx)(`div`,{className:`mt-3 grid gap-3 sm:grid-cols-2`,children:h(p)})]}):null,t[4]=u,t[5]=c,t[6]=l,t[7]=i,t[8]=n,t[9]=b,t[10]=y,t[11]=o,t[12]=d,t[13]=r,t[14]=a,t[15]=v,t[16]=C,t[17]=S,t[18]=_,t[19]=E,t[20]=k,t[21]=A}else E=t[19],k=t[20],A=t[21];let j;return t[44]!==E||t[45]!==k||t[46]!==A?(j=(0,$.jsxs)($.Fragment,{children:[E,k,A]}),t[44]=E,t[45]=k,t[46]=A,t[47]=j):j=t[47],j}function _r(e){return(0,$.jsx)(O,{value:e.id,children:e.name},e.id)}function vr(e){return e.secret||e.type===`password`||[`apiKey`,`baseUrl`,`region`,`groupId`].includes(e.key)}function yr(e){return e.required||[`apiKey`,`model`,`voice`].includes(e.key)}function br(e){return e.language}function xr(e){let t=(0,vn.c)(37),{fieldId:n,field:r,value:i,onChange:a,className:o}=e,s=n??`voice-schema-field-${r.key}`,c=r.description;if(r.type===`boolean`){let e;t[0]===o?e=t[1]:(e=Y(`flex items-center justify-between gap-3 rounded-xl bg-surface-hover/50 px-3 py-2.5 dark:bg-surface-hover/35`,o),t[0]=o,t[1]=e);let n;t[2]===r.label?n=t[3]:(n=(0,$.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:r.label}),t[2]=r.label,t[3]=n);let s;t[4]===c?s=t[5]:(s=c?(0,$.jsx)(`span`,{className:`mt-1 block text-xs text-fg-subtle`,children:c}):null,t[4]=c,t[5]=s);let l;t[6]!==n||t[7]!==s?(l=(0,$.jsxs)(`span`,{children:[n,s]}),t[6]=n,t[7]=s,t[8]=l):l=t[8];let u=!!i,d;t[9]!==r||t[10]!==a?(d=e=>a(or(r,e.target.checked)),t[9]=r,t[10]=a,t[11]=d):d=t[11];let f;t[12]!==u||t[13]!==d?(f=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:u,onChange:d}),t[12]=u,t[13]=d,t[14]=f):f=t[14];let p;return t[15]!==e||t[16]!==l||t[17]!==f?(p=(0,$.jsxs)(`label`,{className:e,children:[l,f]}),t[15]=e,t[16]=l,t[17]=f,t[18]=p):p=t[18],p}let l=typeof i==`boolean`?``:String(i),u;t[19]===o?u=t[20]:(u=Y(`flex flex-col gap-1.5`,o),t[19]=o,t[20]=u);let d;t[21]!==r.label||t[22]!==s?(d=(0,$.jsx)(Cr,{htmlFor:s,children:r.label}),t[21]=r.label,t[22]=s,t[23]=d):d=t[23];let f;t[24]!==o||t[25]!==r||t[26]!==l||t[27]!==s||t[28]!==a?(f=r.type===`select`?(0,$.jsx)(D,{id:s,className:Qn(),value:l,required:r.required,onChange:e=>a(or(r,e.target.value)),children:(r.options??[]).map(Sr)}):r.type===`textarea`?(0,$.jsx)(`textarea`,{id:s,className:Y(Zn(),`min-h-24 resize-y`),value:l,required:r.required,placeholder:r.placeholder,onChange:e=>a(or(r,e.target.value))}):r.type===`password`?(0,$.jsx)(fe,{id:s,className:o,value:l,onChange:e=>a(or(r,e)),placeholder:r.placeholder,labels:st}):r.type===`number`?(0,$.jsx)(zt,{id:s,className:Zn(),autoComplete:r.secret?`new-password`:`off`,spellCheck:!1,value:l,required:r.required,allowEmpty:!r.required,placeholder:r.placeholder,min:r.min,max:r.max,step:r.step,onChange:e=>a(or(r,e.target.value))}):(0,$.jsx)(`input`,{id:s,className:Zn(),type:`text`,autoComplete:r.secret?`new-password`:`off`,spellCheck:!1,value:l,required:r.required,placeholder:r.placeholder,min:r.min,max:r.max,step:r.step,onChange:e=>a(or(r,e.target.value))}),t[24]=o,t[25]=r,t[26]=l,t[27]=s,t[28]=a,t[29]=f):f=t[29];let p;t[30]===c?p=t[31]:(p=c?(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:c}):null,t[30]=c,t[31]=p);let m;return t[32]!==u||t[33]!==d||t[34]!==f||t[35]!==p?(m=(0,$.jsxs)(`div`,{className:u,children:[d,f,p]}),t[32]=u,t[33]=d,t[34]=f,t[35]=p,t[36]=m):m=t[36],m}function Sr(e){return(0,$.jsx)(O,{value:e.id,children:e.name},e.id)}function Cr(e){let t=(0,vn.c)(3),{children:n,htmlFor:r}=e,i;return t[0]!==n||t[1]!==r?(i=r?(0,$.jsx)(`label`,{htmlFor:r,className:`text-sm font-medium text-fg`,children:n}):(0,$.jsx)(`div`,{className:`text-sm font-medium text-fg`,children:n}),t[0]=n,t[1]=r,t[2]=i):i=t[2],i}function wr(e){return e.some(e=>e.disabled?!1:e.type===`searxng`?e.url.trim().length>0:e.apiKey.trim().length>0)}function Tr(e){let t=e&&typeof e==`object`&&`tools`in e?e.tools:void 0,n=t&&typeof t==`object`&&`web`in t?t.web:void 0,r=n&&typeof n==`object`&&`region`in n?n.region:void 0,i=r===`cn`||r===`global`?r:`auto`,a=n&&typeof n==`object`&&`search`in n?n.search:void 0,o=a&&typeof a==`object`?a:{},s=typeof o.maxResults==`number`&&Number.isFinite(o.maxResults)?Math.floor(o.maxResults):5,c=n&&typeof n==`object`&&`blocklist`in n?n.blocklist:void 0,l=c&&typeof c==`object`?c:{},u=Array.isArray(l.domains)?l.domains.filter(e=>typeof e==`string`&&e.trim().length>0):[],d=o.providers;return{regionMode:i,maxResults:s,providers:Array.isArray(d)?d.map((e,t)=>{let n=e&&typeof e==`object`?e:{},r=n.type,i=r===`brave`||r===`tavily`||r===`bing`||r===`searxng`||r===`deepseek`?r:`brave`;return{clientKey:`search-provider-${t}`,type:i,apiKey:typeof n.apiKey==`string`?n.apiKey:``,url:typeof n.url==`string`?n.url:``,disabled:n.disabled===!0}}):[],blocklistEnabled:l.enabled===!0,blocklistDomains:u}}async function Er(e){let t=e.regionMode===`auto`?`auto`:e.regionMode===`cn`?`cn`:`global`,n={maxResults:e.maxResults,providers:e.providers.map(e=>{let t={type:e.type,apiKey:e.apiKey};return(e.type===`searxng`||e.type===`deepseek`)&&e.url.trim()&&(t.url=e.url.trim().replace(/\/+$/,``)),e.disabled&&(t.disabled=!0),t})};await m(d(`/api/config`),{method:`PATCH`,body:JSON.stringify({tools:{web:{region:t,search:n,blocklist:{enabled:e.blocklistEnabled,domains:e.blocklistDomains}}}})}),qe()}async function Dr(e){let t=await m(d(`/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 Or(e){let t=(0,vn.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 kr(){return Y(`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg`,`placeholder:text-fg-subtle`,it,`dark:border-edge`)}function Ar(){return Y(rt,nt)}var jr=[`brave`,`tavily`,`bing`,`searxng`,`deepseek`];function Mr(){return{clientKey:crypto.randomUUID(),type:`brave`,apiKey:``,url:``,disabled:!1}}var Nr=ft();function Pr(){let e=h(p(e=>e.language)),t=e.webSearchSettings,n=e.logs,r=!!f(e=>e.conversationId),[i,a]=(0,Q.useReducer)(Nr,{form:null,baseline:null}),o=i.form,s=i.baseline,c=(0,Q.useRef)(!1),l=(0,Q.useRef)(o);l.current=o;let u=(0,Q.useRef)(null),{data:d,error:m,isLoading:g,mutate:_}=Je(r);dt({enabled:r,parsed:(0,Q.useMemo)(()=>d?.payload?.config===void 0?null:Tr(d.payload.config),[d]),dirty:c.current,trackedParsedRef:u,dispatch:a,onResetDirty:()=>{c.current=!1}});let v=!!(r&&g&&d===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=Gt({value:o,dirty:b,onSave:(0,Q.useCallback)(async e=>{try{await Er(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)(xt,{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)(Z,{type:`button`,variant:`secondary`,onClick:()=>void _(),children:n.refresh})]});let C=wr(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)(Ut,{children:[(0,$.jsx)(Ht,{icon:be,title:t.sectionSearch,subtitle:t.sectionSearchHint,trailing:(0,$.jsx)(Wt,{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)(ue,{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:Y(`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)(Fr,{row:n,providerIndex:r,labels:t,secretLabels:ot(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)(Z,{type:`button`,variant:`secondary`,className:`w-fit gap-1.5 text-sm`,onClick:()=>x({providers:[...o.providers,Mr()]}),children:[(0,$.jsx)(xe,{className:`size-4`}),t.addProvider]})]})]}),(0,$.jsxs)(Ut,{children:[(0,$.jsx)(Ht,{icon:Te,title:t.sectionPreferences}),(0,$.jsxs)(`div`,{className:`grid max-w-2xl gap-4 sm:grid-cols-2`,children:[(0,$.jsx)(Or,{label:t.regionLabel,description:t.regionDesc,children:(0,$.jsxs)(D,{className:Ar(),value:o.regionMode,onChange:e=>x({regionMode:e.target.value}),children:[(0,$.jsx)(O,{value:`auto`,children:t.regionAuto}),(0,$.jsx)(O,{value:`cn`,children:t.regionCn}),(0,$.jsx)(O,{value:`global`,children:t.regionGlobal})]})}),(0,$.jsx)(Ft,{title:t.maxResultsLabel,summary:o.maxResults,children:(0,$.jsx)(Or,{label:t.maxResultsLabel,description:t.maxResultsDesc,children:(0,$.jsx)(zt,{type:`number`,min:1,max:50,className:kr(),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)(Ut,{children:[(0,$.jsx)(Ht,{icon:we,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)(Or,{label:t.blocklistDomains,description:t.blocklistDomainsDesc,children:(0,$.jsx)(`textarea`,{className:Y(kr(),`min-h-[6rem] font-mono text-xs`),value:o.blocklistDomains.join(`
8
- `),placeholder:t.blocklistDomainsPlaceholder,onChange:e=>{let t=e.target.value.split(/\r?\n/).flatMap(e=>{let t=e.trim().toLowerCase();return t?[t]:[]});x({blocklistDomains:t})}})}):null]})]})]})]})}function Fr(e){let t=(0,vn.c)(56),{row:n,providerIndex:r,labels:i,secretLabels:a,onChange:o,onRemove:s}=e,c;t[0]===r?c=t[1]:(c=()=>Dr(r).then(Ir),t[0]=r,t[1]=c);let l=c,u;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(u=Y(Ar(),`min-w-[8rem]`),t[2]=u):u=t[2];let d=n.type,f;t[3]!==o||t[4]!==n?(f=e=>o({...n,type:e.target.value,url:``,apiKey:``}),t[3]=o,t[4]=n,t[5]=f):f=t[5];let p;t[6]===i.providerTypes?p=t[7]:(p=jr.map(e=>(0,$.jsx)(O,{value:e,children:i.providerTypes[e]},e)),t[6]=i.providerTypes,t[7]=p);let m;t[8]!==n.type||t[9]!==f||t[10]!==p?(m=(0,$.jsx)(D,{className:u,value:d,onChange:f,children:p}),t[8]=n.type,t[9]=f,t[10]=p,t[11]=m):m=t[11];let h;t[12]!==o||t[13]!==n?(h=e=>o({...n,disabled:e.target.checked}),t[12]=o,t[13]=n,t[14]=h):h=t[14];let g;t[15]!==n.disabled||t[16]!==h?(g=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:n.disabled,onChange:h}),t[15]=n.disabled,t[16]=h,t[17]=g):g=t[17];let _;t[18]!==i.disabled||t[19]!==g?(_=(0,$.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-1.5 text-xs text-fg-muted`,children:[g,i.disabled]}),t[18]=i.disabled,t[19]=g,t[20]=_):_=t[20];let v;t[21]===Symbol.for(`react.memo_cache_sentinel`)?(v=(0,$.jsx)(De,{className:`size-4`}),t[21]=v):v=t[21];let y;t[22]===s?y=t[23]:(y=(0,$.jsx)(Z,{type:`button`,variant:`ghost`,className:`h-8 px-2 text-fg-muted`,onClick:s,children:v}),t[22]=s,t[23]=y);let b;t[24]!==y||t[25]!==_?(b=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[_,y]}),t[24]=y,t[25]=_,t[26]=b):b=t[26];let x;t[27]!==b||t[28]!==m?(x=(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[m,b]}),t[27]=b,t[28]=m,t[29]=x):x=t[29];let S;t[30]!==i.deepseekUrlDesc||t[31]!==i.deepseekUrlLabel||t[32]!==i.urlDesc||t[33]!==i.urlLabel||t[34]!==o||t[35]!==n?(S=n.type===`searxng`||n.type===`deepseek`?(0,$.jsx)(Or,{label:n.type===`deepseek`?i.deepseekUrlLabel:i.urlLabel,description:n.type===`deepseek`?i.deepseekUrlDesc:i.urlDesc,children:(0,$.jsx)(`input`,{type:`url`,className:kr(),value:n.url,placeholder:n.type===`deepseek`?`https://api.deepseek.com`:`http://localhost:8080`,onChange:e=>o({...n,url:e.target.value})})}):null,t[30]=i.deepseekUrlDesc,t[31]=i.deepseekUrlLabel,t[32]=i.urlDesc,t[33]=i.urlLabel,t[34]=o,t[35]=n,t[36]=S):S=t[36];let C;t[37]!==o||t[38]!==n?(C=e=>o({...n,apiKey:e}),t[37]=o,t[38]=n,t[39]=C):C=t[39];let w;t[40]!==i.keyPlaceholder||t[41]!==i.keyPlaceholderMasked||t[42]!==i.saveError||t[43]!==l||t[44]!==n.apiKey||t[45]!==a||t[46]!==C?(w=(0,$.jsx)(fe,{value:n.apiKey,onChange:C,placeholder:i.keyPlaceholder,labels:a,reveal:l,loadFailedLabel:i.saveError,notInConfigFile:i.keyPlaceholderMasked}),t[40]=i.keyPlaceholder,t[41]=i.keyPlaceholderMasked,t[42]=i.saveError,t[43]=l,t[44]=n.apiKey,t[45]=a,t[46]=C,t[47]=w):w=t[47];let T;t[48]!==i.apiKeyDesc||t[49]!==i.apiKeyLabel||t[50]!==w?(T=(0,$.jsx)(Or,{label:i.apiKeyLabel,description:i.apiKeyDesc,children:w}),t[48]=i.apiKeyDesc,t[49]=i.apiKeyLabel,t[50]=w,t[51]=T):T=t[51];let E;return t[52]!==x||t[53]!==S||t[54]!==T?(E=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl bg-surface-panel/60 p-4`,children:[x,S,T]}),t[52]=x,t[53]=S,t[54]=T,t[55]=E):E=t[55],E}function Ir(e){return e.apiKey??null}function Lr(e,t,n=[]){return e.filter(e=>!n.includes(e.providerId)&&e.uses.some(e=>e.id===t&&e.choices.length>0))}function Rr(e){let t=(0,vn.c)(75),{use:n,data:r,language:i,labels:a,onSaved:o,inline:s,onPendingChange:c,onEditingChange:l}=e,u=s!==void 0&&s,d=i===`zh`,[f,p]=(0,Q.useState)(),[m,h]=(0,Q.useState)(!1),g;t[0]===c?g=t[1]:(g=e=>{h(e),c?.(e)},t[0]=c,t[1]=g);let _=g,v=n===`transcription`?`stt`:n===`speech`?`tts`:void 0,y,b,x;if(t[2]!==r.builtinRows||t[3]!==r.cards||t[4]!==r.customConfig?.providers||t[5]!==r.loading||t[6]!==n){let e=new Set(r.cards.filter(e=>!ee(e.id)||!!r.customConfig?.providers?.[e.id]).map(qr));y=[...new Set([...r.builtinRows.map(Kr),...e])].filter(t=>!ee(t)||e.has(t)).sort(),b=X,x=r.loading?null:[`capability-service-connections`,n,y.join(`,`)],t[2]=r.builtinRows,t[3]=r.cards,t[4]=r.customConfig?.providers,t[5]=r.loading,t[6]=n,t[7]=y,t[8]=b,t[9]=x}else y=t[7],b=t[8],x=t[9];let S;t[10]!==y||t[11]!==n||t[12]!==v?(S=async()=>{let e=v===`stt`?await Zt():v===`tts`?await Jt():void 0,t=e?.providers.filter(Gr).map(Wr),r=e?.providers.filter(Ur).map(Hr)??[],i=t?y.filter(e=>t.includes(e)):y,a=await Promise.allSettled(i.map(z));return{services:Lr(a.flatMap(Vr),n,r),failed:a.some(Br)}},t[10]=y,t[11]=n,t[12]=v,t[13]=S):S=t[13];let C;t[14]===Symbol.for(`react.memo_cache_sentinel`)?(C={revalidateOnFocus:!1},t[14]=C):C=t[14];let{data:w,error:T,isLoading:E,mutate:D}=b(x,S,C),O;t[15]===w?.services?O=t[16]:(O=new Set(w?.services.map(zr)),t[15]=w?.services,t[16]=O);let k=O,A,M;if(t[17]!==l||t[18]!==f?(A=()=>(l?.(!!f),()=>l?.(!1)),M=[f,l],t[17]=l,t[18]=f,t[19]=A,t[20]=M):(A=t[19],M=t[20]),(0,Q.useEffect)(A,M),f&&u){let e;if(t[21]!==r.builtinRows||t[22]!==f){let n;t[24]===f?n=t[25]:(n=e=>e.id===f,t[24]=f,t[25]=n),e=r.builtinRows.find(n),t[21]=r.builtinRows,t[22]=f,t[23]=e}else e=t[23];let a;t[26]===Symbol.for(`react.memo_cache_sentinel`)?(a=()=>p(void 0),t[26]=a):a=t[26];let s;t[27]!==D||t[28]!==o?(s=()=>{D(),p(void 0),o()},t[27]=D,t[28]=o,t[29]=s):s=t[29];let c;return t[30]!==i||t[31]!==f||t[32]!==_||t[33]!==e||t[34]!==s||t[35]!==n?(c=(0,$.jsx)(`section`,{className:`overflow-hidden rounded-xl border border-edge`,children:(0,$.jsx)(R,{inline:!0,providerId:f,row:e,targetUse:n,language:i,onPendingChange:_,onDone:a,onApplied:s},f)}),t[30]=i,t[31]=f,t[32]=_,t[33]=e,t[34]=s,t[35]=n,t[36]=c):c=t[36],c}let N=d?`选择服务`:`Choose a service`,P;t[37]===N?P=t[38]:(P=(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:N}),t[37]=N,t[38]=P);let F;t[39]!==r.loading||t[40]!==E?(F=r.loading||E?(0,$.jsx)(Me,{className:`h-24 w-full`}):null,t[39]=r.loading,t[40]=E,t[41]=F):F=t[41];let I;t[42]!==w?.failed||t[43]!==T||t[44]!==D||t[45]!==d?(I=T||w?.failed?(0,$.jsxs)(`p`,{role:`alert`,className:`text-sm text-fg-muted`,children:[d?`部分服务目录暂时不可用。`:`Some service catalogs are unavailable.`,(0,$.jsx)(Z,{variant:`ghost`,onClick:()=>void D(),children:d?`重试`:`Retry`})]}):null,t[42]=w?.failed,t[43]=T,t[44]=D,t[45]=d,t[46]=I):I=t[46];let L;t[47]===Symbol.for(`react.memo_cache_sentinel`)?(L=[!0,!1],t[47]=L):L=t[47];let B;t[48]!==m||t[49]!==w?.services||t[50]!==d?(B=L.map(e=>{let t=w?.services.filter(t=>t.configured===e)??[];return t.length?(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-medium text-fg-muted`,children:e?d?`已连接`:`Connected`:d?`添加服务`:`Add a service`}),t.map(t=>(0,$.jsxs)(`button`,{type:`button`,disabled:m,onClick:()=>p(t.providerId),className:`flex min-h-14 w-full items-center justify-between gap-3 rounded-lg px-3 py-3 text-left transition-colors hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent disabled:opacity-50`,children:[(0,$.jsx)(`span`,{className:`min-w-0 text-sm font-medium text-fg`,children:ae(t.providerId,t.profile.name,d)}),(0,$.jsx)(`span`,{className:`shrink-0 text-sm text-accent-fg`,children:e?d?`选择`:`Choose`:d?`连接`:`Connect`})]},t.providerId))]},String(e)):null}),t[48]=m,t[49]=w?.services,t[50]=d,t[51]=B):B=t[51];let V;t[52]!==w||t[53]!==d?(V=w&&!w.services.length&&!w.failed?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:d?`暂无支持此能力的模型服务。`:`No model services currently support this capability.`}):null,t[52]=w,t[53]=d,t[54]=V):V=t[54];let te=d?`仅列出支持${j[n][0]}的服务。`:`Only compatible services are shown. Reuse saved credentials, then return to select a model.`,H;t[55]===te?H=t[56]:(H=(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:te}),t[55]=te,t[56]=H);let U;t[57]!==r.builtinRows||t[58]!==r.customConfig||t[59]!==k||t[60]!==a||t[61]!==i||t[62]!==D||t[63]!==o||t[64]!==f||t[65]!==n?(U=f?(0,$.jsx)(ie,{open:!0,initialProviderId:f,initialUse:n,connectOnly:!0,onOpenChange:e=>{e||p(void 0)},builtinRows:r.builtinRows.filter(e=>k.has(e.id)),customConfig:r.customConfig,labels:a,language:i,onSaved:()=>{D(),p(void 0),o()}},f):null,t[57]=r.builtinRows,t[58]=r.customConfig,t[59]=k,t[60]=a,t[61]=i,t[62]=D,t[63]=o,t[64]=f,t[65]=n,t[66]=U):U=t[66];let W;return t[67]!==P||t[68]!==F||t[69]!==I||t[70]!==B||t[71]!==V||t[72]!==H||t[73]!==U?(W=(0,$.jsxs)(`section`,{className:`space-y-3 rounded-xl border border-edge p-4`,children:[P,F,I,B,V,H,U]}),t[67]=P,t[68]=F,t[69]=I,t[70]=B,t[71]=V,t[72]=H,t[73]=U,t[74]=W):W=t[74],W}function zr(e){return e.providerId}function Br(e){return e.status===`rejected`}function Vr(e){return e.status===`fulfilled`?[e.value]:[]}function Hr(e){return e.id}function Ur(e){return e.diagnostics.requiresApiKey}function Wr(e){return e.id}function Gr(e){return!e.diagnostics.requiresApiKey}function Kr(e){return e.id}function qr(e){return e.id}function Jr({zh:e,kind:t,modelServiceIds:n,onSaved:r,onPendingChange:i}){let{data:a,error:o,mutate:s}=X([`native-voice-connections`,t??`all`,n.join(`,`)],async()=>{let[e,r]=await Promise.all([t===`tts`?Promise.resolve({providers:[]}):Zt(),t===`stt`?Promise.resolve({providers:[]}):Jt()]);return[...e.providers.map(e=>({...e,kind:`stt`})),...r.providers.map(e=>({...e,kind:`tts`}))].filter(e=>e.diagnostics.requiresApiKey||!n.includes(e.id))}),[c,l]=(0,Q.useState)(``),[u,f]=(0,Q.useState)({}),[p,h]=(0,Q.useState)(!1),g=(0,Q.useRef)(!1),[_,v]=(0,Q.useState)(``);(0,Q.useEffect)(()=>(i?.(p),()=>i?.(!1)),[p,i]);let y=a?.find(e=>`${e.kind}:${e.id}`===c),b=y?.fields.filter(e=>e.secret||e.type===`password`||[`baseUrl`,`region`,`groupId`].includes(e.key))??[],x=async()=>{if(!(!y||g.current)){g.current=!0,h(!0),v(``);try{let t=Object.fromEntries(Object.entries(u).filter(([,e])=>e.trim()).map(([e,t])=>[e,t.trim()]));Object.keys(t).length&&await m(d(`/api/config`),{method:`PATCH`,body:JSON.stringify({[y.kind]:{providers:{[y.id]:t}}})});let[n]=await Promise.all([s(),St()]);if(!n?.find(e=>e.kind===y.kind&&e.id===y.id)?.configured)throw Error(e?`连接尚未就绪,请补齐所需凭据。`:`Connection is not ready. Complete the required credentials.`);f({}),r()}catch(e){v(e instanceof Error?e.message:String(e))}finally{g.current=!1,h(!1)}}};return a&&!a.length?null:(0,$.jsxs)(`details`,{className:`rounded-xl border border-edge p-4`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer text-sm font-medium text-fg`,children:e?`其他语音服务与本地语音`:`Other voice services and local speech`}),(0,$.jsxs)(`section`,{className:`mt-4 space-y-4`,children:[(0,$.jsx)(`h2`,{className:`text-sm font-semibold text-fg`,children:t===`stt`?e?`其他识别服务`:`Other recognition services`:t===`tts`?e?`其他合成服务与本地语音`:`Other synthesis services and local speech`:e?`语音 API 与本地语音`:`Voice APIs and local speech`}),!a&&!o?(0,$.jsx)(Me,{className:`h-20 w-full`}):null,o?(0,$.jsxs)(`p`,{role:`alert`,children:[e?`语音服务加载失败`:`Could not load voice services`,(0,$.jsx)(Z,{variant:`ghost`,onClick:()=>void s(),children:e?`重试`:`Retry`})]}):null,(0,$.jsxs)(D,{value:c,disabled:p,"aria-label":e?`语音服务接入`:`Connect voice service`,onChange:e=>{l(e.target.value),f({}),v(``)},children:[(0,$.jsx)(O,{value:``,children:e?`选择语音来源`:`Choose a voice source`}),a?.map(n=>(0,$.jsxs)(O,{value:`${n.kind}:${n.id}`,children:[n.displayName,t?``:` · ${n.kind.toUpperCase()}`,n.configured?e?` · 已连接`:` · Connected`:``]},`${n.kind}:${n.id}`))]}),y?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:y.diagnostics.requiresApiKey?e?`此服务使用独立的 API Key。保存连接后,可在“模型与参数”中选用。`:`This service uses its own API key. Save the connection, then choose it in Model and parameters.`:e?`此来源无需 API Key,可返回能力设置选择。`:`No API key needed. Choose this source in capability settings.`}),b.map(t=>(0,$.jsxs)(`label`,{className:`block space-y-1 text-sm text-fg`,children:[(0,$.jsx)(`span`,{children:t.label}),t.secret||t.type===`password`?(0,$.jsx)(fe,{labels:st,value:u[t.key]??``,onChange:e=>f(n=>({...n,[t.key]:e})),disabled:p}):t.options?.length?(0,$.jsxs)(D,{value:u[t.key]??``,disabled:p,onChange:e=>f(n=>({...n,[t.key]:e.target.value})),children:[(0,$.jsx)(O,{value:``,children:e?`保留现有值`:`Keep existing`}),(t.key===`model`?[...t.options].sort(mt):t.options).map(e=>(0,$.jsx)(O,{value:e.id,children:e.name},e.id))]}):(0,$.jsx)(`input`,{className:`w-full rounded-lg border border-edge bg-surface-panel p-2`,value:u[t.key]??``,disabled:p,placeholder:t.placeholder,onChange:e=>f(n=>({...n,[t.key]:e.target.value}))})]},t.key)),_?(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:_}):null,(0,$.jsx)(Z,{disabled:p||!y.configured&&y.diagnostics.requiresApiKey&&!Object.values(u).some(e=>e.trim()),onClick:()=>void x(),children:p?e?`保存中…`:`Saving…`:e?`保存连接`:`Save connection`})]}):null]})]})}function Yr({label:e,value:t,currentLabel:n,options:r,loading:i,disabled:a,zh:o,onConnect:s,onSelect:c}){let[l,u]=(0,Q.useState)(``),d=l.trim().toLowerCase().split(/\s+/).filter(Boolean),f=[...r].sort((e,t)=>(e.group??``).localeCompare(t.group??``,`en`,{numeric:!0,sensitivity:`base`})||ht(e.label,t.label)||ht(e.value,t.value)).filter(e=>{let t=`${e.label} ${e.group} ${e.value} ${e.searchText??``}`.toLowerCase();return d.every(e=>t.includes(e))}),p=r.find(e=>e.value===t),m=p?.group??r.find(e=>e.value.split(`/`)[0]===t?.split(`/`)[0])?.group,h=p?.label??(t?.endsWith(`/default`)?o?`默认模型`:`Default model`:n??t),g=m?`${h} · ${m}`:h;return!i&&!r.length?(0,$.jsx)(Z,{variant:`secondary`,className:`min-h-11 w-full sm:justify-start`,"aria-label":`${o?`连接`:`Connect`} ${e}`,disabled:a,onClick:s,children:o?`连接服务以启用`:`Connect a service to enable`}):(0,$.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,$.jsx)(k,{value:t??``,options:f,selectedLabel:h,title:g,placeholder:o?`选择模型`:`Choose a model`,ariaLabel:`${o?`选择`:`Select`} ${e}`,allowEmpty:!1,disabled:a,loading:i,onChange:c,searchPlaceholder:o?`搜索模型或服务`:`Search models or services`,searchValue:l,onSearchChange:u,statusMessage:f.length?void 0:o?`没有可用模型`:`No available models`,triggerClassName:`min-h-11`}),m?(0,$.jsx)(`p`,{className:`px-1 text-xs text-fg-muted`,children:m}):null]})}function Xr({data:e,zh:t,onChange:n,onSettings:r,onlyUse:i,disabled:a=!1,onPendingChange:o}){let{data:s,error:c,mutate:l}=X(`settings-agent-defaults`,bt),{data:u}=Je(!0),{data:d,isLoading:f,error:p,mutate:m}=X(`model-capability-media-sources`,async()=>{let e=await Promise.allSettled([Jt(),Zt(),cn()]);return{ids:[...new Set(e.flatMap(e=>e.status===`fulfilled`?(Array.isArray(e.value)?e.value:e.value.providers).filter(e=>e.configured).map(e=>e.id):[]))],failed:e.some(e=>e.status===`rejected`)}}),h=[...new Set([...e.cards.filter(t=>t.configured&&(!ee(t.id)||!!e.customConfig?.providers?.[t.id])).map(e=>e.id),...d?.ids??[]])].sort(),{data:g,isLoading:_,mutate:v}=X(e.loading?null:[`model-use-choices`,...h],async()=>{let e=await Promise.allSettled(h.map(z));return{previews:e.flatMap(e=>e.status===`fulfilled`&&e.value.configured?[e.value]:[]),failed:e.some(e=>e.status===`rejected`)}},{revalidateOnFocus:!1}),[y,b]=(0,Q.useState)(null),[x,S]=(0,Q.useState)(null),C=(0,Q.useRef)(!1),w=(0,Q.useRef)(null);(0,Q.useEffect)(()=>()=>o?.(!1),[o]);let T=async(e,t)=>{if(C.current||a)return;let n=g?.previews.find(n=>n.uses.some(n=>n.id===e&&n.choices.some(e=>e.id===t)));if(!n)return;C.current=!0,o?.(!0),b(e),S(null);let r={mode:`replace`,selected:[e],overrides:{[e]:t}};try{let t=await J(n.providerId,r);await le(n.providerId,r,t.revision),await Promise.all([l(),v()]),S({use:e})}catch(t){S({use:e,error:t instanceof Error?t.message:String(t)}),Promise.allSettled([l(),v()])}finally{C.current=!1,b(null),o?.(!1),requestAnimationFrame(()=>w.current?.querySelector(`[data-capability="${e}"] button[aria-label]`)?.focus())}},E=u?.payload?.config?$t(u.payload.config):void 0;if(!s&&!c)return(0,$.jsx)(Me,{className:`h-48 w-full rounded-xl`});if(c)return(0,$.jsxs)(`div`,{role:`alert`,className:`text-sm text-danger`,children:[t?`模型用途加载失败`:`Could not load model uses`,(0,$.jsx)(Z,{variant:`ghost`,onClick:()=>void l(),children:t?`重试`:`Retry`})]});let D=s.defaults.models,O=D.background?.primary??D.chat.primary,k=e.builtinRows.find(e=>e.id===O.split(`/`)[0])?.setupProfile?.interactiveOnly!==!0,A=g?.previews[0]?.uses.find(e=>e.id===`background`),M=A?A.current:k?O:void 0,N=[{id:`chat`,label:t?`对话与任务`:`Chat and tasks`,ref:D.chat.primary},{id:`vision`,label:t?`看图`:`Image understanding`,ref:D.imageUnderstanding?.primary},{id:`image`,label:t?`画图`:`Image generation`,ref:D.imageGeneration?.primary},{id:`background`,label:t?`后台任务`:`Background tasks`,ref:M,inherited:!D.background&&!!M},{id:`transcription`,label:t?`录音与听写`:`Recording and dictation`,ref:E?.stt.enabled?`${E.stt.provider}/${E.stt.providers?.[E.stt.provider]?.model??`default`}`:void 0},{id:`speech`,label:t?`语音合成`:`Speech synthesis`,ref:E?.tts.enabled?`${E.tts.provider}/${E.tts.providers?.[E.tts.provider]?.model??`default`}`:void 0},{id:`conversation`,label:t?`实时语音对话`:`Realtime conversation`,ref:E?.voice.realtime.enabled?E.voice.realtime.defaultEngine===`omni`&&E.voice.realtime.omni?`${E.voice.realtime.omni.provider}/${E.voice.realtime.omni.model}`:E.voice.realtime.defaultEngine===`agent`?`agent`:void 0:void 0}];return(0,$.jsxs)(`section`,{ref:w,className:`@container min-w-0`,children:[(0,$.jsx)(`h2`,{className:i?`mb-2 text-sm font-semibold text-fg`:`sr-only`,children:i?t?`当前模型`:`Current model`:t?`能力总览`:`Capabilities`}),(0,$.jsx)(`div`,{className:i?`space-y-4`:`overflow-hidden rounded-2xl border border-edge bg-surface-panel`,children:F.filter(e=>!i||e.uses.includes(i)).map(o=>(0,$.jsxs)(`section`,{className:i?`min-w-0`:`min-w-0 border-t border-edge first:border-t-0`,children:[i?null:(0,$.jsxs)(`div`,{className:`flex items-center justify-between bg-surface-inset/55 px-4 py-2`,children:[(0,$.jsx)(`h3`,{className:`text-xs font-medium text-fg-muted`,children:o.label[+!t]}),(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:o.uses[0]===`chat`?t?`基础能力`:`Core capability`:t?`按需启用`:`Optional`})]}),(0,$.jsx)(`div`,{className:i?`divide-y divide-edge-subtle`:`divide-y divide-edge-subtle px-4`,children:o.uses.filter(e=>!i||e===i).map(o=>{let s=N.find(e=>e.id===o),c=Zr(g?.previews??[],s.id,t),l=s.id===`conversation`&&E?.voice.realtime.enabled&&E.voice.realtime.defaultEngine===`agent`?t?`语音助手 · 使用对话、听写和语音输出配置`:`Voice assistant · Uses chat, dictation and voice output`:s.ref?(e=>e?_t(e,t?`zh`:`en`):s.ref)(e.allModels.find(e=>e.id===s.ref)):void 0;return(0,$.jsx)(`div`,{"data-capability":s.id,children:(0,$.jsxs)(`div`,{className:i?`py-2`:`grid grid-cols-1 items-center gap-x-3 gap-y-2 py-3 @min-[40rem]:gap-x-4 ${r?`@min-[40rem]:grid-cols-[minmax(0,1fr)_minmax(0,1.35fr)_auto]`:`@min-[40rem]:grid-cols-[minmax(0,1fr)_minmax(0,1.35fr)]`}`,children:[(0,$.jsxs)(`div`,{className:i?`hidden`:`col-start-1 row-start-1 min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,$.jsx)(`p`,{className:`text-sm font-medium text-fg`,children:j[s.id][+!t]}),(0,$.jsx)(`span`,{className:`text-xs text-fg-subtle`,children:s.ref?c.some(e=>e.value===s.ref||s.ref?.endsWith(`/default`)&&e.value.split(`/`)[0]===s.ref.split(`/`)[0])||s.ref===`agent`?null:t?`待连接`:`Connection needed`:t?`未配置`:`Not set up`})]}),(0,$.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-fg-muted`,children:G[s.id][+!t]}),s.inherited?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:t?`继承默认对话`:`Inherits chat default`}):null]}),(0,$.jsxs)(`div`,{className:i?`w-full min-w-0 space-y-1`:`row-start-2 w-full min-w-0 space-y-1 @min-[40rem]:col-span-1 @min-[40rem]:col-start-2 @min-[40rem]:row-start-1`,children:[(0,$.jsx)(Yr,{label:j[s.id][+!t],value:s.ref,currentLabel:l,options:c,loading:e.loading||_||f,disabled:y!==null||a,zh:t,onConnect:()=>n(s.id),onSelect:e=>{e!==s.ref&&T(s.id,e)}}),y===s.id?(0,$.jsx)(`p`,{role:`status`,className:`text-xs text-fg-muted`,children:t?`正在切换…`:`Switching…`}):null,x?.use===s.id?(0,$.jsx)(`div`,{role:x.error?`alert`:`status`,className:`text-xs text-fg-muted`,children:x.error?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`p`,{className:`text-danger`,children:t?`未能切换模型,请重试。`:`Could not switch models. Please retry.`}),(0,$.jsxs)(`details`,{className:`mt-1`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer`,children:t?`查看详情`:`Show details`}),(0,$.jsx)(`p`,{className:`mt-1 break-words`,children:x.error})]})]}):t?`已切换`:`Model changed`}):null]}),r&&(c.length>0||_||f)?(0,$.jsxs)(`div`,{className:`row-start-3 flex flex-wrap items-center justify-end gap-1 @min-[40rem]:col-start-3 @min-[40rem]:row-start-1`,children:[(0,$.jsx)(Z,{variant:`ghost`,disabled:y!==null||a,onClick:()=>r(s.id),children:t?`设置`:`Settings`}),(0,$.jsx)(Z,{variant:`ghost`,disabled:y!==null||a,onClick:()=>n(s.id),children:t?`管理服务`:`Manage services`})]}):null]})},s.id)})})]},o.uses[0]))}),(!r||i)&&(g?.failed||d?.failed||p)?(0,$.jsxs)(`p`,{role:`alert`,className:`mt-2 text-xs text-danger`,children:[t?`部分服务的模型加载失败`:`Some model services could not be loaded`,(0,$.jsx)(Z,{variant:`ghost`,onClick:()=>void Promise.all([m(),v()]),children:t?`重试`:`Retry`})]}):null,i||r?null:(0,$.jsx)(`p`,{className:`mt-2 text-xs text-fg-muted`,children:t?`快速与复杂任务模型随对话配置;音色、流式听写及电脑操作可在详细设置中调整。`:`Fast and complex task models follow chat setup. Voices, streaming dictation and Computer Use have detailed settings.`})]})}function Zr(e,t,n=!1){return e.flatMap(e=>e.uses.find(e=>e.id===t)?.choices.map(t=>({value:t.id,label:t.name,group:ae(e.providerId,e.profile.name,n),searchText:e.profile.name}))??[])}function Qr(e){let t=(0,vn.c)(208),{model:n,isNew:r,providerId:i,onSave:a,onClose:o,m:s}=e,c=p(ei)===`zh`,l;t[0]===n?l=t[1]:(l=()=>n?{...n}:ne(``),t[0]=n,t[1]=l);let[u,d]=(0,Q.useState)(l),[f,m]=(0,Q.useState)($r),h;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(h=(e,t)=>{d(n=>({...n,[e]:t})),m(t=>{let n=new Map(t);return n.delete(e),n})},t[2]=h):h=t[2];let g=h,_;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?(_=()=>{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`),m(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]=_):_=t[11];let y=_,b;t[12]!==u||t[13]!==o||t[14]!==a||t[15]!==y?(b=()=>{if(!y())return;let e=(u.id||``).trim(),t={...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}};a(t),o()},t[12]=u,t[13]=o,t[14]=a,t[15]=y,t[16]=b):b=t[16];let S=b,C=u,w;t[17]===C?w=t[18]:(w=V(C),t[17]=C,t[18]=w);let T=w,E=r?s.addModelTitle:s.editModelTitle,k;t[19]===E?k=t[20]:(k=(0,$.jsx)(x,{className:`text-base font-semibold text-fg`,children:E}),t[19]=E,t[20]=k);let A;t[21]!==s.modelProviderLabel||t[22]!==i?(A=i?(0,$.jsxs)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:[s.modelProviderLabel,`: `,i]}):null,t[21]=s.modelProviderLabel,t[22]=i,t[23]=A):A=t[23];let j;t[24]!==k||t[25]!==A?(j=(0,$.jsxs)(`div`,{children:[k,A]}),t[24]=k,t[25]=A,t[26]=j):j=t[26];let M;t[27]===Symbol.for(`react.memo_cache_sentinel`)?(M=Y(tt,`p-1.5 hover:bg-surface-base`),t[27]=M):M=t[27];let N;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,$.jsx)(je,{className:`size-4`}),t[28]=N):N=t[28];let P;t[29]===s.close?P=t[30]:(P=(0,$.jsx)(v,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:M,"aria-label":s.close,children:N})}),t[29]=s.close,t[30]=P);let F;t[31]!==j||t[32]!==P?(F=(0,$.jsxs)(`div`,{className:`mb-3 flex shrink-0 items-start justify-between gap-2`,children:[j,P]}),t[31]=j,t[32]=P,t[33]=F):F=t[33];let I;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,$.jsx)(`span`,{className:`text-red-600 dark:text-red-400`,children:` *`}),t[34]=I):I=t[34];let L;t[35]===s.modelId?L=t[36]:(L=(0,$.jsxs)(`label`,{className:`mb-1 block text-xs font-medium text-fg`,children:[s.modelId,I]}),t[35]=s.modelId,t[36]=L);let R;t[37]===f?R=t[38]:(R=Y(W(),f.has(`id`)&&`border-red-500`),t[37]=f,t[38]=R);let z=u.id||``,ee;t[39]===Symbol.for(`react.memo_cache_sentinel`)?(ee=e=>g(`id`,e.target.value),t[39]=ee):ee=t[39];let te=!r,H;t[40]!==R||t[41]!==z||t[42]!==te?(H=(0,$.jsx)(`input`,{className:R,value:z,onChange:ee,placeholder:`e.g. llama3.1:8b`,disabled:te}),t[40]=R,t[41]=z,t[42]=te,t[43]=H):H=t[43];let U;t[44]===f?U=t[45]:(U=f.has(`id`)?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:f.get(`id`)}):null,t[44]=f,t[45]=U);let re;t[46]!==L||t[47]!==H||t[48]!==U?(re=(0,$.jsxs)(`div`,{children:[L,H,U]}),t[46]=L,t[47]=H,t[48]=U,t[49]=re):re=t[49];let G;t[50]===s.displayName?G=t[51]:(G=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.displayName}),t[50]=s.displayName,t[51]=G);let ie;t[52]===Symbol.for(`react.memo_cache_sentinel`)?(ie=W(),t[52]=ie):ie=t[52];let ae=u.name||``,q;t[53]===Symbol.for(`react.memo_cache_sentinel`)?(q=e=>g(`name`,e.target.value),t[53]=q):q=t[53];let se;t[54]===ae?se=t[55]:(se=(0,$.jsx)(`input`,{className:ie,value:ae,onChange:q}),t[54]=ae,t[55]=se);let ce;t[56]!==G||t[57]!==se?(ce=(0,$.jsxs)(`div`,{children:[G,se]}),t[56]=G,t[57]=se,t[58]=ce):ce=t[58];let J;t[59]===s.inputTypes?J=t[60]:(J=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.inputTypes}),t[59]=s.inputTypes,t[60]=J);let le;t[61]===Symbol.for(`react.memo_cache_sentinel`)?(le=K(),t[61]=le):le=t[61];let ue;t[62]===Symbol.for(`react.memo_cache_sentinel`)?(ue=e=>g(`input`,oe(e.target.value)),t[62]=ue):ue=t[62];let de;t[63]===s?de=t[64]:(de=B.map(e=>(0,$.jsx)(O,{value:e.value,children:s[e.labelKey]},e.value)),t[63]=s,t[64]=de);let fe;t[65]!==T||t[66]!==de?(fe=(0,$.jsx)(D,{className:le,value:T,onChange:ue,children:de}),t[65]=T,t[66]=de,t[67]=fe):fe=t[67];let pe;t[68]!==J||t[69]!==fe?(pe=(0,$.jsxs)(`div`,{children:[J,fe]}),t[68]=J,t[69]=fe,t[70]=pe):pe=t[70];let me=u.reasoning||!1,he;t[71]===Symbol.for(`react.memo_cache_sentinel`)?(he=e=>g(`reasoning`,e.target.checked),t[71]=he):he=t[71];let ge;t[72]===me?ge=t[73]:(ge=(0,$.jsx)(`input`,{type:`checkbox`,className:`ui-checkbox`,checked:me,onChange:he}),t[72]=me,t[73]=ge);let _e;t[74]!==s.reasoning||t[75]!==ge?(_e=(0,$.jsxs)(`label`,{className:`mt-6 flex cursor-pointer items-center gap-2 text-sm text-fg`,children:[ge,s.reasoning]}),t[74]=s.reasoning,t[75]=ge,t[76]=_e):_e=t[76];let ve;t[77]!==pe||t[78]!==_e?(ve=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[pe,_e]}),t[77]=pe,t[78]=_e,t[79]=ve):ve=t[79];let ye;t[80]===s.contextWindow?ye=t[81]:(ye=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.contextWindow}),t[80]=s.contextWindow,t[81]=ye);let be;t[82]===f?be=t[83]:(be=Y(W(),f.has(`contextWindow`)&&`border-red-500`),t[82]=f,t[83]=be);let xe=u.contextWindow??128e3,Se;t[84]===Symbol.for(`react.memo_cache_sentinel`)?(Se=e=>g(`contextWindow`,parseInt(e.target.value,10)||0),t[84]=Se):Se=t[84];let Ce;t[85]!==be||t[86]!==xe?(Ce=(0,$.jsx)(zt,{type:`number`,min:1,className:be,value:xe,onChange:Se}),t[85]=be,t[86]=xe,t[87]=Ce):Ce=t[87];let we;t[88]===f?we=t[89]:(we=f.has(`contextWindow`)?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:f.get(`contextWindow`)}):null,t[88]=f,t[89]=we);let Te;t[90]!==ye||t[91]!==Ce||t[92]!==we?(Te=(0,$.jsxs)(`div`,{children:[ye,Ce,we]}),t[90]=ye,t[91]=Ce,t[92]=we,t[93]=Te):Te=t[93];let Ee;t[94]===s.maxOutputTokens?Ee=t[95]:(Ee=(0,$.jsx)(`label`,{className:`mb-1 block text-xs font-medium text-fg-muted`,children:s.maxOutputTokens}),t[94]=s.maxOutputTokens,t[95]=Ee);let De;t[96]===f?De=t[97]:(De=Y(W(),f.has(`maxTokens`)&&`border-red-500`),t[96]=f,t[97]=De);let Oe=u.maxTokens??16384,ke;t[98]===Symbol.for(`react.memo_cache_sentinel`)?(ke=e=>g(`maxTokens`,parseInt(e.target.value,10)||0),t[98]=ke):ke=t[98];let Ae;t[99]!==De||t[100]!==Oe?(Ae=(0,$.jsx)(zt,{type:`number`,min:1,className:De,value:Oe,onChange:ke}),t[99]=De,t[100]=Oe,t[101]=Ae):Ae=t[101];let Me;t[102]===f?Me=t[103]:(Me=f.has(`maxTokens`)?(0,$.jsx)(`p`,{className:`mt-1 text-xs text-red-600 dark:text-red-400`,children:f.get(`maxTokens`)}):null,t[102]=f,t[103]=Me);let Ne;t[104]!==Ee||t[105]!==Ae||t[106]!==Me?(Ne=(0,$.jsxs)(`div`,{children:[Ee,Ae,Me]}),t[104]=Ee,t[105]=Ae,t[106]=Me,t[107]=Ne):Ne=t[107];let Pe;t[108]!==Te||t[109]!==Ne?(Pe=(0,$.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[Te,Ne]}),t[108]=Te,t[109]=Ne,t[110]=Pe):Pe=t[110];let Fe;t[111]===s.costSection?Fe=t[112]:(Fe=(0,$.jsx)(`p`,{className:`mb-2 text-xs font-semibold text-fg`,children:s.costSection}),t[111]=s.costSection,t[112]=Fe);let Ie;t[113]===s.costInput?Ie=t[114]:(Ie=(0,$.jsx)(`label`,{className:`mb-1 block text-xs text-fg-muted`,children:s.costInput}),t[113]=s.costInput,t[114]=Ie);let Le;t[115]===Symbol.for(`react.memo_cache_sentinel`)?(Le=W(),t[115]=Le):Le=t[115];let Re=u.cost?.input??0,ze;t[116]===u.cost?ze=t[117]:(ze=e=>g(`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]=ze);let Be;t[118]!==Re||t[119]!==ze?(Be=(0,$.jsx)(zt,{type:`number`,step:`any`,min:0,className:Le,value:Re,onChange:ze}),t[118]=Re,t[119]=ze,t[120]=Be):Be=t[120];let Ve;t[121]!==Ie||t[122]!==Be?(Ve=(0,$.jsxs)(`div`,{children:[Ie,Be]}),t[121]=Ie,t[122]=Be,t[123]=Ve):Ve=t[123];let He;t[124]===s.costOutput?He=t[125]:(He=(0,$.jsx)(`label`,{className:`mb-1 block text-xs text-fg-muted`,children:s.costOutput}),t[124]=s.costOutput,t[125]=He);let Ue;t[126]===Symbol.for(`react.memo_cache_sentinel`)?(Ue=W(),t[126]=Ue):Ue=t[126];let We=u.cost?.output??0,Ge;t[127]===u.cost?Ge=t[128]:(Ge=e=>g(`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]=Ge);let Ke;t[129]!==We||t[130]!==Ge?(Ke=(0,$.jsx)(zt,{type:`number`,step:`any`,min:0,className:Ue,value:We,onChange:Ge}),t[129]=We,t[130]=Ge,t[131]=Ke):Ke=t[131];let X;t[132]!==He||t[133]!==Ke?(X=(0,$.jsxs)(`div`,{children:[He,Ke]}),t[132]=He,t[133]=Ke,t[134]=X):X=t[134];let qe;t[135]!==Ve||t[136]!==X?(qe=(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[Ve,X]}),t[135]=Ve,t[136]=X,t[137]=qe):qe=t[137];let Je;t[138]!==Fe||t[139]!==qe?(Je=(0,$.jsxs)(`div`,{className:`border-t border-edge-subtle pt-2 dark:border-edge`,children:[Fe,qe]}),t[138]=Fe,t[139]=qe,t[140]=Je):Je=t[140];let Ye;t[141]!==re||t[142]!==ce||t[143]!==ve||t[144]!==Pe||t[145]!==Je?(Ye=(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[re,ce,ve,Pe,Je]}),t[141]=re,t[142]=ce,t[143]=ve,t[144]=Pe,t[145]=Je,t[146]=Ye):Ye=t[146];let Xe=c?`高级:手机操作协议`:`Advanced: Phone Use protocol`,Ze;t[147]===Xe?Ze=t[148]:(Ze=(0,$.jsx)(`summary`,{className:`cursor-pointer`,children:Xe}),t[147]=Xe,t[148]=Ze);let Qe=c?`手机操作协议`:`Phone Use protocol`,$e=u.phoneUse?.profile??``,et;t[149]===Symbol.for(`react.memo_cache_sentinel`)?(et=e=>g(`phoneUse`,e.target.value?{profile:e.target.value}:void 0),t[149]=et):et=t[149];let nt=c?`自动识别`:`Automatic`,rt;t[150]===nt?rt=t[151]:(rt=(0,$.jsx)(O,{value:``,children:nt}),t[150]=nt,t[151]=rt);let it,at,ot,st,ct;t[152]===Symbol.for(`react.memo_cache_sentinel`)?(it=(0,$.jsx)(O,{value:`autoglm-phone-v1`,children:`AutoGLM Phone`}),at=(0,$.jsx)(O,{value:`structured-phone-v1`,children:`Structured Phone`}),ot=(0,$.jsx)(O,{value:`structured-tools-phone-v1`,children:`Visual function tools`}),st=(0,$.jsx)(O,{value:`doubao-seed-phone-v1`,children:`Doubao Seed GUI`}),ct=(0,$.jsx)(O,{value:`gui-owl-phone-v1`,children:`GUI-Owl 1.5`}),t[152]=it,t[153]=at,t[154]=ot,t[155]=st,t[156]=ct):(it=t[152],at=t[153],ot=t[154],st=t[155],ct=t[156]);let lt;t[157]!==Qe||t[158]!==$e||t[159]!==rt?(lt=(0,$.jsxs)(D,{"aria-label":Qe,value:$e,onChange:et,children:[rt,it,at,ot,st,ct]}),t[157]=Qe,t[158]=$e,t[159]=rt,t[160]=lt):lt=t[160];let ut=c?`通用视觉模型支持图片输入和工具调用时会自动显示;也可指定专用手机协议。`:`Visual models with image input and function tools appear automatically. Dedicated phone protocols can also be selected.`,dt;t[161]===ut?dt=t[162]:(dt=(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:ut}),t[161]=ut,t[162]=dt);let ft;t[163]!==lt||t[164]!==dt?(ft=(0,$.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[lt,dt]}),t[163]=lt,t[164]=dt,t[165]=ft):ft=t[165];let pt;t[166]!==Ze||t[167]!==ft?(pt=(0,$.jsxs)(`details`,{className:`mt-4 rounded-lg border border-edge p-3 text-sm text-fg`,children:[Ze,ft]}),t[166]=Ze,t[167]=ft,t[168]=pt):pt=t[168];let mt=c?`高级:电脑控制协议`:`Advanced: Computer Use protocol`,ht;t[169]===mt?ht=t[170]:(ht=(0,$.jsx)(`summary`,{className:`cursor-pointer`,children:mt}),t[169]=mt,t[170]=ht);let gt=c?`电脑控制协议`:`Computer Use protocol`,_t=u.computerUse?.profile??``,vt;t[171]===Symbol.for(`react.memo_cache_sentinel`)?(vt=e=>g(`computerUse`,e.target.value?{profile:e.target.value}:void 0),t[171]=vt):vt=t[171];let yt=c?`自动识别`:`Automatic`,bt;t[172]===yt?bt=t[173]:(bt=(0,$.jsx)(O,{value:``,children:yt}),t[172]=yt,t[173]=bt);let xt,St,Ct;t[174]===Symbol.for(`react.memo_cache_sentinel`)?(xt=(0,$.jsx)(O,{value:`gui-plus-2026-02-26`,children:`GUI-Plus (2026-02-26)`}),St=(0,$.jsx)(O,{value:`structured-tools-v1`,children:`structured-tools-v1`}),Ct=(0,$.jsx)(O,{value:`openai-responses-computer-v1`,children:`OpenAI Responses Computer`}),t[174]=xt,t[175]=St,t[176]=Ct):(xt=t[174],St=t[175],Ct=t[176]);let wt;t[177]!==gt||t[178]!==_t||t[179]!==bt?(wt=(0,$.jsxs)(D,{"aria-label":gt,value:_t,onChange:vt,children:[bt,xt,St,Ct]}),t[177]=gt,t[178]=_t,t[179]=bt,t[180]=wt):wt=t[180];let Tt=c?`协议必须与模型 API 匹配。声明协议不代表模型已通过效果验证。`:`The protocol must match the model API. Declaring a protocol does not certify model quality.`,Et;t[181]===Tt?Et=t[182]:(Et=(0,$.jsx)(`p`,{className:`text-xs leading-relaxed text-fg-muted`,children:Tt}),t[181]=Tt,t[182]=Et);let Dt;t[183]===f?Dt=t[184]:(Dt=f.has(`computerUse`)&&(0,$.jsx)(`p`,{role:`alert`,className:`text-xs text-danger`,children:f.get(`computerUse`)}),t[183]=f,t[184]=Dt);let Ot;t[185]!==Et||t[186]!==Dt||t[187]!==wt?(Ot=(0,$.jsxs)(`div`,{className:`mt-3 space-y-2`,children:[wt,Et,Dt]}),t[185]=Et,t[186]=Dt,t[187]=wt,t[188]=Ot):Ot=t[188];let kt;t[189]!==Ot||t[190]!==ht?(kt=(0,$.jsxs)(`details`,{className:`mt-4 rounded-lg border border-edge p-3 text-sm text-fg`,children:[ht,Ot]}),t[189]=Ot,t[190]=ht,t[191]=kt):kt=t[191];let At;t[192]!==kt||t[193]!==Ye||t[194]!==pt?(At=(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pr-1`,children:[Ye,pt,kt]}),t[192]=kt,t[193]=Ye,t[194]=pt,t[195]=At):At=t[195];let jt;t[196]===s.cancel?jt=t[197]:(jt=(0,$.jsx)(v,{asChild:!0,children:(0,$.jsx)(Z,{type:`button`,variant:`secondary`,children:s.cancel})}),t[196]=s.cancel,t[197]=jt);let Mt=r?s.addModelConfirm:s.saveModelConfirm,Nt;t[198]!==S||t[199]!==Mt?(Nt=(0,$.jsx)(Z,{type:`button`,variant:`primary`,className:`hover:bg-accent/90`,onClick:S,children:Mt}),t[198]=S,t[199]=Mt,t[200]=Nt):Nt=t[200];let Pt;t[201]!==jt||t[202]!==Nt?(Pt=(0,$.jsxs)(`div`,{className:`mt-4 flex shrink-0 justify-end gap-2 border-t border-edge-subtle pt-3 dark:border-edge`,children:[jt,Nt]}),t[201]=jt,t[202]=Nt,t[203]=Pt):Pt=t[203];let Ft;return t[204]!==At||t[205]!==Pt||t[206]!==F?(Ft=(0,$.jsxs)($.Fragment,{children:[F,At,Pt]}),t[204]=At,t[205]=Pt,t[206]=F,t[207]=Ft):Ft=t[207],Ft}function $r(){return new Map}function ei(e){return e.language}function ti(e){let t=(0,vn.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)(g,{className:Y(`xopc-dialog-overlay fixed inset-0 bg-scrim`,Qe)}),t[0]=l):l=t[0];let u;t[1]===Symbol.for(`react.memo_cache_sentinel`)?(u=Y(`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`,Ze,`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)(Qr,{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)(y,{children:[l,(0,$.jsx)(b,{className:u,onOpenAutoFocus:ni,children:d})]}),t[10]=d,t[11]=f);let p;return t[12]!==r||t[13]!==n||t[14]!==f?(p=(0,$.jsx)(S,{open:n,onOpenChange:r,children:f}),t[12]=r,t[13]=n,t[14]=f,t[15]=p):p=t[15],p}function ni(e){return e.preventDefault()}function ri(e){let t=(0,vn.c)(14),{providerId:n,inputId:r,value:i,onChange:a,labels:o}=e,s;t[0]===n?s=t[1]:(s=()=>Dt(n).then(ii),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)(fe,{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 ii(e){return e.apiKey??null}function ai(e){let t=(0,vn.c)(23),{open:n,onOpenChange:r,providerId:i,isCustom:a,builtinRows:o,customConfig:s,allModels:c,labels:l,language:u,onSaved:d}=e,f=(0,Q.useRef)(null),[p,m]=(0,Q.useState)(!1),[h,_]=(0,Q.useState)(null),v;t[0]===r?v=t[1]:(v=e=>{e||(_(null),m(!1)),r(e)},t[0]=r,t[1]=v);let x=v,C;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(C=(0,$.jsx)(g,{className:Y(`xopc-dialog-overlay fixed inset-0 bg-scrim backdrop-blur-[1px]`,Qe)}),t[2]=C):C=t[2];let w,T,E;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(w=()=>{f.current=document.activeElement instanceof HTMLElement?document.activeElement:null},T=e=>{f.current?.isConnected&&(e.preventDefault(),f.current.focus({preventScroll:!0}))},E=Y(`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`,Ze),t[3]=w,t[4]=T,t[5]=E):(w=t[3],T=t[4],E=t[5]);let D;t[6]!==c||t[7]!==o||t[8]!==s||t[9]!==x||t[10]!==a||t[11]!==l||t[12]!==u||t[13]!==r||t[14]!==d||t[15]!==i||t[16]!==p||t[17]!==h?(D=(0,$.jsxs)(y,{children:[C,(0,$.jsx)(b,{onOpenAutoFocus:w,onCloseAutoFocus:T,className:E,children:h?(0,$.jsx)(U,{target:h,zh:u===`zh`,onDone:()=>x(!1)}):!a&&p?(0,$.jsx)(R,{providerId:i,existingConnection:!0,row:o.find(e=>e.id===i),language:u,onApplied:d,onBack:()=>m(!1),onDone:()=>x(!1)}):a?(0,$.jsx)(si,{providerId:i,customConfig:s,labels:l,language:u,onClose:()=>r(!1),onSaved:d,onModelAdded:e=>_({providerId:i,modelIds:[e]})}):(0,$.jsx)(oi,{providerId:i,builtinRows:o,allModels:c,labels:l,language:u,onClose:()=>r(!1),onSaved:d,onQuickSetup:()=>m(!0)})})]}),t[6]=c,t[7]=o,t[8]=s,t[9]=x,t[10]=a,t[11]=l,t[12]=u,t[13]=r,t[14]=d,t[15]=i,t[16]=p,t[17]=h,t[18]=D):D=t[18];let O;return t[19]!==x||t[20]!==n||t[21]!==D?(O=(0,$.jsx)(S,{open:n,onOpenChange:x,children:D}),t[19]=x,t[20]=n,t[21]=D,t[22]=O):O=t[22],O}function oi({providerId:e,builtinRows:t,allModels:n,labels:r,language:i,onClose:a,onSaved:o,onQuickSetup:s}){let c=t.find(t=>t.id===e),u=te[e],d=n.filter(t=>t.provider===e),[f,p]=(0,Q.useState)(!1),[m,g]=(0,Q.useState)(c?.apiKey??``),[_,y]=(0,Q.useState)(!1),[b,S]=(0,Q.useState)(!1),[C,w]=(0,Q.useState)(null),[T,E]=(0,Q.useState)(!1),D=h(i).providersSettings,O=c?.supportsApiKey!==!1,k=c?.supportsOAuth===!0,j=c?.authMode===`oauth`&&c.authStatus===`connected`,N=c?.configured===!0&&c.activeKeySource!==`env`&&c.activeKeySource!==`extension`&&c.activeKeySource!==`models_json`,[P,F]=(0,Q.useState)(null),[I,R]=(0,Q.useState)(null),[z,B]=(0,Q.useState)(`idle`),[ee,V]=(0,Q.useState)(null),[H,U]=(0,Q.useState)(null),[W,ne]=(0,Q.useState)(null),[re,G]=(0,Q.useState)(``),K=(0,Q.useRef)(null),ie=(0,Q.useRef)(null),ae=z===`waiting`||z===`waiting_code`,q=(0,Q.useMemo)(()=>L(e,i),[e,i]),oe=m!==(c?.apiKey??``),ce=async()=>{let t=m.trim();if(!(!t||!O||Et(t))){y(!0),w(null);try{await Tt({[e]:t}),S(!0),window.setTimeout(()=>{o(),a()},600)}catch(e){w(e instanceof Error?e.message:r.saveError)}finally{y(!1)}}};(0,Q.useEffect)(()=>{if(!P||!ae)return;let e=window.setInterval(()=>{(async()=>{try{let t=await Nt(P);t.status===`waiting_auth`||t.status===`waiting_code`?(B(t.status===`waiting_code`?`waiting_code`:`waiting`),R(t.message??null),V(t.authUrl??null),U(t.instructions??null),ne(t.deviceCode??null),t.authUrl&&t.authUrl!==ie.current&&(ie.current=t.authUrl,It(t.authUrl,K.current).catch(()=>{}))):t.status===`completed`?(window.clearInterval(e),Rt(K.current),K.current=null,B(`success`),R(t.message??D.saved),window.setTimeout(()=>{o(),a()},600)):(t.status===`failed`||t.status===`cancelled`)&&(window.clearInterval(e),Rt(K.current),K.current=null,B(`error`),R(t.error??t.message??D.revokeFailed))}catch{}})()},1e3);return()=>window.clearInterval(e)},[P,ae,a,o,D.revokeFailed,D.saved]),(0,Q.useEffect)(()=>()=>{P&&jt(P).catch(()=>{})},[P]),(0,Q.useEffect)(()=>()=>{Rt(K.current),K.current=null},[]);let J=async()=>{try{await Ot(e),o(),a()}catch{}},le=async()=>{Rt(K.current),K.current=Lt(),ie.current=null,B(`waiting`),R(D.oauthStarting),V(null),U(null),ne(null),w(null);try{let t=await kt(e);F(t.sessionId)}catch(e){Rt(K.current),K.current=null,B(`error`),R(e instanceof Error?e.message:D.revokeFailed)}},ue=async()=>{if(P){try{await Pt(P)}catch{}Rt(K.current),K.current=null,ie.current=null,B(`idle`),R(null),F(null),V(null),U(null),ne(null)}},fe=async()=>{if(!(!P||!re.trim()))try{await Mt(P,re.trim()),G(``),R(D.oauthProcessingCode)}catch(e){B(`error`),R(e instanceof Error?e.message:D.revokeFailed)}},pe=async()=>{try{await At(e),o(),a()}catch(e){w(e instanceof Error?e.message:D.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)(x,{className:`text-base font-semibold text-fg`,children:c?.name??e}),(0,$.jsx)(v,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:Y(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,et.press),children:(0,$.jsx)(je,{className:`size-4`,"aria-hidden":!0})})})]}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-4 overflow-y-auto px-5 py-4`,children:[s?(0,$.jsx)(Z,{variant:`secondary`,onClick:s,children:i===`zh`?`配置模型用途`:`Configure model uses`}):null,u?.description?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:u.description}):null,c?.baseUrl?(0,$.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,$.jsx)(`span`,{className:`text-sm font-medium text-fg`,children:r.apiUrlLabel}),(0,$.jsx)(`code`,{className:`break-all rounded-lg border border-edge-subtle bg-surface-panel/60 px-3 py-2 font-mono text-xs text-fg-muted`,children:c.baseUrl})]}):c?.category===`extension`?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:r.apiUrlExtensionHint}):null,O?(0,$.jsx)(ri,{providerId:e,inputId:`manage-api-key`,value:m,onChange:e=>{g(e),S(!1)},labels:{apiKeyLabel:r.apiKeyLabel,apiKeyPlaceholder:r.apiKeyPlaceholder,maskedHelp:r.maskedHelp,copy:r.copy,copied:r.copied,show:r.showKey,hide:r.hideKey,notInConfigFile:r.notInConfigFile,loadFailed:r.loadFailed}}):c?.category===`extension`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-edge-subtle bg-surface-panel/60 px-3 py-2 text-sm text-fg-muted`,children:[(0,$.jsx)(`p`,{children:r.extensionKeyHint}),c?.extensionId?(0,$.jsxs)(l,{to:`/settings/ext/${encodeURIComponent(c.extensionId)}`,className:`inline-flex w-fit items-center gap-1 font-medium text-accent hover:underline`,title:r.extensionSettingsLinkTitle,onClick:a,children:[r.openExtensionSettings,(0,$.jsx)(de,{className:`size-3`,"aria-hidden":!0})]}):null]}):null,k?(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:D.oauth}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:j?D.sourceOauth:D.oauthHint})]}),j?(0,$.jsx)(Z,{type:`button`,variant:`secondary`,className:`gap-1.5 text-red-600 dark:text-red-400`,onClick:()=>void pe(),children:D.revoke}):(0,$.jsxs)(Z,{type:`button`,variant:`primary`,className:`gap-1.5`,disabled:ae,onClick:()=>void le(),children:[ae?(0,$.jsx)(ge,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(M,{className:`size-3.5`,"aria-hidden":!0}),D.oauth]})]}),I?(0,$.jsx)(`p`,{className:Y(`text-xs`,z===`error`?`text-red-600 dark:text-red-400`:`text-fg-muted`),children:I}):null,z===`waiting`||z===`waiting_code`?(0,$.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[ee?(0,$.jsxs)(`a`,{href:ee,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)(de,{className:`size-4`,"aria-hidden":!0}),D.openAuthPage]}):null,(0,$.jsx)(Z,{type:`button`,variant:`secondary`,onClick:()=>void ue(),children:D.cancelOAuth})]}):null,H?(0,$.jsx)(`p`,{className:`text-xs text-fg-muted`,children:H}):null,W?(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:D.deviceCodeLabel}),(0,$.jsx)(`code`,{className:`mt-1 block select-all font-mono text-lg font-semibold tracking-widest text-fg`,children:W}),(0,$.jsx)(`p`,{className:`mt-1 text-xs text-fg-subtle`,children:D.deviceCodeHint})]}):null,z===`waiting_code`?(0,$.jsxs)(`div`,{className:`flex flex-col gap-2 sm:flex-row`,children:[(0,$.jsx)(`input`,{type:`text`,value:re,onChange:e=>G(e.target.value),onKeyDown:e=>e.key===`Enter`&&void fe(),placeholder:D.pasteRedirectUrl,className:Y(`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`,it)}),(0,$.jsx)(Z,{type:`button`,variant:`primary`,onClick:()=>void fe(),children:D.submitCode})]}):null]}):null,q.length>0&&O?(0,$.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:q.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:[se(e,r),(0,$.jsx)(de,{className:`size-3`,"aria-hidden":!0})]},e))}):null,d.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,` (`,d.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:f,onChange:e=>p(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:d.filter(e=>!f||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:[_t(e,i),e.computerUse?` · Computer Use`:``]},e.id))})})]}):(0,$.jsx)(`p`,{className:`text-xs text-fg-subtle`,children:r.noModels}),C?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:C}):null]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle px-5 py-3`,children:[N?(0,$.jsxs)(Z,{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:()=>E(!0),children:[(0,$.jsx)(De,{className:`size-3.5`,"aria-hidden":!0}),r.remove]}):(0,$.jsx)(`span`,{}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:O&&oe&&!Et(m.trim())?(0,$.jsx)(Z,{type:`button`,variant:`primary`,disabled:!m.trim()||_||b,onClick:()=>void ce(),children:b?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(A,{className:`size-3.5`,"aria-hidden":!0}),r.saved]}):_?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(ge,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),r.saving]}):r.save}):null})]}),(0,$.jsx)(pt,{open:T,title:r.removeConfirmTitle,description:r.removeConfirmDescription.replace(`{{provider}}`,c?.name??e),confirmLabel:r.removeConfirmAction,cancelLabel:r.cancel,destructive:!0,onConfirm:()=>void J(),onCancel:()=>E(!1)})]})}function si({providerId:e,customConfig:t,labels:n,language:r,onClose:i,onSaved:a,onModelAdded:o}){let s=h(r).modelsSettings,c=t?.providers[e],[l,u]=(0,Q.useState)(c?.baseUrl??``),[d,f]=(0,Q.useState)(c?.apiKey??``),[p,m]=(0,Q.useState)(c?.models??[]),[g,_]=(0,Q.useState)(!1),[y,b]=(0,Q.useState)(c?.modelDiscovery?.enabled===!0),[S,C]=(0,Q.useState)(!1),[w,T]=(0,Q.useState)(null),[E,D]=(0,Q.useState)(!1),[O,k]=(0,Q.useState)(null),[A,j]=(0,Q.useState)(!1),[M,N]=(0,Q.useState)(null),P=n=>{if(!t)return null;let r=d.trim(),i={...c,baseUrl:l.trim()||void 0,apiKey:Et(r)?c?.apiKey:r||void 0,...n};return{providers:{...t.providers,[e]:i}}},F=async()=>{let e=P({models:p,modelDiscovery:{enabled:y}});if(e){C(!0),T(null);try{await H(e),a(),i()}catch(e){T(e instanceof Error?e.message:n.saveError)}finally{C(!1)}}},I=async()=>{if(t)try{let{[e]:n,...r}=t.providers;await H({providers:r}),a(),i()}catch{}},L=(e,t)=>{N({model:e,isNew:t}),j(!0)},R=async e=>{if(!M)return;let t=M.isNew&&!p.some(t=>t.id===e.id),r=M.isNew?[...p,e]:p.map(t=>t.id===e.id?e:t);m(r);let i=P({models:r});if(i)try{await H(i),a(),t&&!e.computerUse&&o(e.id)}catch(e){T(e instanceof Error?e.message:n.saveError)}},z=async e=>{let t=p.filter(t=>t.id!==e);m(t),k(null);let r=P({models:t});if(r)try{await H(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)(x,{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)(v,{asChild:!0,children:(0,$.jsx)(`button`,{type:`button`,className:Y(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,et.press),children:(0,$.jsx)(je,{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:Y(`rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg placeholder:text-fg-subtle`,it)})]}),(0,$.jsx)(ri,{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:y,onChange:e=>b(e.target.checked),className:`mt-0.5 size-4 rounded border-edge accent-accent`}),(0,$.jsxs)(`span`,{className:`min-w-0`,children:[(0,$.jsx)(`span`,{className:`block text-sm font-medium text-fg`,children:r===`zh`?`自动同步模型目录`:`Automatically sync model catalog`}),(0,$.jsx)(`span`,{className:`mt-0.5 block text-xs text-fg-muted`,children:r===`zh`?`启动时及定时从此服务的 /models 接口更新模型。`:`Update models from this service’s /models endpoint at startup and on schedule.`})]})]}),(0,$.jsxs)(`div`,{className:`border-t border-edge-subtle pt-3`,children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,$.jsxs)(`span`,{className:`text-sm font-semibold text-fg`,children:[s.modelsSection,p.length>0?` (${p.length})`:``]}),(0,$.jsxs)(Z,{type:`button`,variant:`primary`,className:`gap-1.5 px-2 py-1 text-xs`,onClick:()=>L(null,!0),children:[(0,$.jsx)(xe,{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:g,onChange:e=>_(e.target.checked)}),r===`zh`?`仅电脑控制模型`:`Computer Use only`]}),p.filter(e=>!g||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=>!g||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:Y(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-fg`,et.press),onClick:()=>L(e,!1),"aria-label":s.editModel,children:(0,$.jsx)(ve,{className:`size-3.5`,"aria-hidden":!0})}),(0,$.jsx)(`button`,{type:`button`,className:Y(`rounded-lg p-1.5 text-fg-muted hover:bg-surface-hover hover:text-red-600 dark:hover:text-red-400`,et.press),onClick:()=>k(e.id),"aria-label":s.removeModel,children:(0,$.jsx)(De,{className:`size-3.5`,"aria-hidden":!0})})]})]},e.id))})]}),w?(0,$.jsx)(`p`,{className:`text-sm text-red-600 dark:text-red-400`,children:w}):null]}),(0,$.jsxs)(`div`,{className:`flex items-center justify-between border-t border-edge-subtle px-5 py-3`,children:[(0,$.jsxs)(Z,{type:`button`,variant:`ghost`,className:`gap-1.5 text-red-600 hover:text-red-700 dark:text-red-400 dark:hover:text-red-300`,onClick:()=>D(!0),children:[(0,$.jsx)(De,{className:`size-3.5`,"aria-hidden":!0}),n.remove]}),(0,$.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,$.jsx)(Z,{type:`button`,variant:`primary`,disabled:S,onClick:()=>void F(),children:S?(0,$.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,$.jsx)(ge,{className:`size-3.5 animate-spin`,"aria-hidden":!0}),n.saving]}):n.save})})]}),(0,$.jsx)(pt,{open:E,title:n.removeConfirmTitle,description:n.removeConfirmDescription.replace(`{{provider}}`,e),confirmLabel:n.removeConfirmAction,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>void I(),onCancel:()=>D(!1)}),(0,$.jsx)(pt,{open:O!==null,title:s.removeModel,description:s.removeModelConfirm.replace(`{{id}}`,O??``),confirmLabel:n.removeConfirmAction,cancelLabel:n.cancel,destructive:!0,onConfirm:()=>{O&&z(O)},onCancel:()=>k(null)}),(0,$.jsx)(ti,{open:A,onOpenChange:e=>{j(e),e||N(null)},providerId:e,model:M?.model??null,isNew:M?.isNew??!1,onSave:e=>void R(e),m:s})]})}var ci=[`fast`,`reasoning`,`coding`,`review`,`vision`,`understanding`],li=`w-full rounded-lg border border-edge bg-surface-panel px-3 py-2 text-sm text-fg outline-none focus:border-accent focus:ring-2 focus:ring-accent/15`,ui={en:{fast:[`Fast tasks`,`Short, low-latency work`],reasoning:[`Complex reasoning`,`Planning and multi-step analysis`],coding:[`Coding`,`Implementation and debugging`],review:[`Review`,`Critique and verification`],vision:[`Vision`,`Image and visual analysis`],understanding:[`Understanding`,`Long-form content comprehension`]},zh:{fast:[`快速任务`,`简短、低延迟的工作`],reasoning:[`复杂推理`,`规划和多步骤分析`],coding:[`编程`,`实现、调试和代码修改`],review:[`审查`,`检查、批评和验证`],vision:[`视觉任务`,`图片和视觉内容分析`],understanding:[`内容理解`,`长内容阅读和理解`]}};function di(e,t){return{primary:t,fallbacks:e?.fallbacks??[]}}function fi(e){let t=(0,vn.c)(38),{draft:n,setDraft:r,zh:i,capability:a}=e,o;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(o={revalidateOnFocus:!1},t[0]=o):o=t[0];let s=X(Xe,Ye,o),c;t[1]===s.data?c=t[2]:(c=s.data??[],t[1]=s.data,t[2]=c);let l=c,u=i?ui.zh:ui.en,d;t[3]!==n||t[4]!==r?(d=(e,t)=>{let i={...n.models.intents};t?i[e]=di(i[e],t):delete i[e],r({...n,models:{...n.models,intents:i}})},t[3]=n,t[4]=r,t[5]=d):d=t[5];let f=d,p;t[6]!==a||t[7]!==n||t[8]!==l||t[9]!==s.error||t[10]!==s.isLoading||t[11]!==r||t[12]!==i?(p=a===`chat`?(0,$.jsx)(`section`,{className:`rounded-xl bg-surface-hover/20 p-5`,children:(0,$.jsx)(Ft,{title:i?`模型回退`:`Model fallbacks`,summary:i?`已配置 ${n.models.chat.fallbacks.length} 个备用模型。`:`${n.models.chat.fallbacks.length} fallback models configured.`,children:(0,$.jsx)(`div`,{className:`mt-6 rounded-xl bg-surface-base/45 p-4`,children:(0,$.jsx)(ln,{primary:n.models.chat.primary,value:n.models.chat.fallbacks,models:l,loading:s.isLoading,error:s.error,zh:i,onChange:e=>r({...n,models:{...n.models,chat:{...n.models.chat,fallbacks:e}}})})})})}):null,t[6]=a,t[7]=n,t[8]=l,t[9]=s.error,t[10]=s.isLoading,t[11]=r,t[12]=i,t[13]=p):p=t[13];let m;t[14]!==a||t[15]!==n||t[16]!==r||t[17]!==i?(m=a===`image`?(0,$.jsx)(`section`,{className:`rounded-xl bg-surface-hover/20 p-5`,children:n.models.imageGeneration?(0,$.jsx)(Ft,{title:i?`图片执行策略`:`Image execution policy`,summary:i?`当前超时与回退策略继续生效。`:`The current timeout and fallback policy remains active.`,children:(0,$.jsxs)(`div`,{className:`mt-5 grid gap-4 rounded-xl bg-surface-base/45 p-4 sm:grid-cols-2`,children:[(0,$.jsxs)(`label`,{className:`block text-xs font-medium text-fg-muted`,children:[i?`生成超时(毫秒)`:`Generation timeout (ms)`,(0,$.jsx)(zt,{allowEmpty:!0,type:`number`,min:1,className:`${li} mt-2`,value:n.models.imageGeneration.timeoutMs??``,onChange:e=>r({...n,models:{...n.models,imageGeneration:{...n.models.imageGeneration,timeoutMs:e.target.value?Number(e.target.value):void 0}}})})]}),(0,$.jsxs)(`div`,{className:`text-xs font-medium text-fg-muted`,children:[(0,$.jsx)(`span`,{children:i?`服务商自动回退`:`Automatic provider fallback`}),(0,$.jsx)(ut,{className:`mt-1.5 flex rounded-lg bg-surface-panel p-1`,role:`group`,"aria-label":i?`服务商自动回退`:`Automatic provider fallback`,children:[!0,!1].map(e=>(0,$.jsx)(Z,{"aria-pressed":n.models.imageGeneration?.autoProviderFallback===e,variant:n.models.imageGeneration?.autoProviderFallback===e?`secondary`:`ghost`,className:`flex-1 py-1.5 text-xs`,onClick:()=>r({...n,models:{...n.models,imageGeneration:{...n.models.imageGeneration,autoProviderFallback:e}}}),children:e?i?`开启`:`On`:i?`关闭`:`Off`},String(e)))})]})]})}):null}):null,t[14]=a,t[15]=n,t[16]=r,t[17]=i,t[18]=m):m=t[18];let h;t[19]!==a||t[20]!==n||t[21]!==l||t[22]!==s.error||t[23]!==s.isLoading||t[24]!==r||t[25]!==i?(h=a===`vision`&&n.models.imageUnderstanding?(0,$.jsx)(Ft,{title:i?`模型回退`:`Model fallbacks`,summary:i?`主模型不可用时使用已配置的备用模型。`:`Use configured fallback models when the primary is unavailable.`,children:(0,$.jsx)(ln,{primary:n.models.imageUnderstanding.primary,value:n.models.imageUnderstanding.fallbacks,models:l.filter(pi),loading:s.isLoading,error:s.error,zh:i,onChange:e=>r({...n,models:{...n.models,imageUnderstanding:{...n.models.imageUnderstanding,fallbacks:e}}})})}):null,t[19]=a,t[20]=n,t[21]=l,t[22]=s.error,t[23]=s.isLoading,t[24]=r,t[25]=i,t[26]=h):h=t[26];let g;t[27]!==a||t[28]!==u||t[29]!==n||t[30]!==f||t[31]!==i?(g=a===`chat`?(0,$.jsx)(Ft,{title:i?`任务模型路由`:`Task model routing`,summary:i?`已配置 ${Object.keys(n.models.intents).length} 类任务路由;其他任务使用默认模型。`:`${Object.keys(n.models.intents).length} task routes configured; other tasks use the default model.`,children:(0,$.jsxs)(`section`,{className:`rounded-xl bg-surface-hover/20 p-5`,children:[(0,$.jsx)(`h2`,{className:`text-base font-semibold text-fg`,children:i?`按任务选择模型`:`Route by task`}),(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:i?`仅在确实需要不同模型时设置;否则保持“使用默认对话模型”。`:`Set a route only when a task genuinely needs another model; otherwise keep the default.`}),(0,$.jsx)(`div`,{className:`mt-5 grid gap-3 lg:grid-cols-2`,children:ci.map(e=>(0,$.jsxs)(`div`,{className:`rounded-xl bg-surface-base/55 p-4`,children:[(0,$.jsxs)(`div`,{className:`mb-3`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium text-fg`,children:u[e][0]}),(0,$.jsx)(`p`,{className:`mt-0.5 text-xs text-fg-muted`,children:u[e][1]})]}),(0,$.jsx)(gt,{value:n.models.intents[e]?.primary??``,placeholder:i?`使用默认对话模型`:`Use default conversation model`,searchPlaceholder:i?`搜索模型或服务商`:`Search models or providers`,noMatches:i?`没有匹配的模型`:`No matching models`,allowEmpty:!0,emptyLabel:i?`使用默认对话模型`:`Use default conversation model`,showProviderInTrigger:!1,contentAlign:`start`,className:`w-full`,ariaLabel:i?`${u[e][0]}模型`:`${u[e][0]} model`,onChange:t=>f(e,t)})]},e))})]})}):null,t[27]=a,t[28]=u,t[29]=n,t[30]=f,t[31]=i,t[32]=g):g=t[32];let _;return t[33]!==p||t[34]!==m||t[35]!==h||t[36]!==g?(_=(0,$.jsxs)(`div`,{className:`space-y-5`,children:[p,m,h,g]}),t[33]=p,t[34]=m,t[35]=h,t[36]=g,t[37]=_):_=t[37],_}function pi(e){return e.vision}function mi(e){let t=(0,vn.c)(9),{data:n,error:r}=X(`settings-agent-defaults`,bt);if(r&&!n){let e=String(r),n;return t[0]===e?n=t[1]:(n=(0,$.jsx)(`p`,{role:`alert`,className:`text-sm text-danger`,children:e}),t[0]=e,t[1]=n),n}if(!n){let e;return t[2]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(Me,{className:`h-32 rounded-xl`}),t[2]=e):e=t[2],e}let i;t[3]===n.defaults.models?i=t[4]:(i=JSON.stringify(n.defaults.models),t[3]=n.defaults.models,t[4]=i);let a;return t[5]!==n.defaults||t[6]!==e||t[7]!==i?(a=(0,$.jsx)(hi,{...e,initial:n.defaults},i),t[5]=n.defaults,t[6]=e,t[7]=i,t[8]=a):a=t[8],a}function hi(e){let t=(0,vn.c)(36),{initial:n,capability:r,zh:i,disabled:a,onPendingChange:o}=e,s;t[0]===n?s=t[1]:(s=()=>structuredClone(n),t[0]=n,t[1]=s);let[c,l]=(0,Q.useState)(s),u;t[2]===n?u=t[3]:(u=()=>structuredClone(n),t[2]=n,t[3]=u);let[d,f]=(0,Q.useState)(u),p;t[4]===c.models?p=t[5]:(p=JSON.stringify(c.models),t[4]=c.models,t[5]=p);let m;t[6]===d.models?m=t[7]:(m=JSON.stringify(d.models),t[6]=d.models,t[7]=m);let h=p!==m,g;t[8]!==n.models||t[9]!==i?(g=async e=>{let t=await bt();if(JSON.stringify(t.defaults.models)!==JSON.stringify(n.models))throw Error(i?`模型设置已变化,请刷新后重试。`:`Model settings changed. Refresh before retrying.`);let r=await yt({...t.defaults,models:e.models},{scope:`models`,expectedModels:n.models});f(r.defaults),await St()},t[8]=n.models,t[9]=i,t[10]=g):g=t[10];let _=g,v;t[11]!==h||t[12]!==c||t[13]!==_?(v={value:c,dirty:h,onSave:_,delayMs:0},t[11]=h,t[12]=c,t[13]=_,t[14]=v):v=t[14];let y=Gt(v),b=h||y.status===`saving`||!!y.error,x,S;t[15]!==o||t[16]!==b?(x=()=>(o(b),()=>o(!1)),S=[b,o],t[15]=o,t[16]=b,t[17]=x,t[18]=S):(x=t[17],S=t[18]),(0,Q.useEffect)(x,S);let C=a||y.status===`saving`,w;t[19]!==y.error||t[20]!==y.status?(w=(0,$.jsx)(Wt,{status:y.status,error:y.error}),t[19]=y.error,t[20]=y.status,t[21]=w):w=t[21];let T;t[22]!==y.error||t[23]!==y.retry||t[24]!==i?(T=y.error?(0,$.jsx)(Z,{variant:`secondary`,onClick:y.retry,children:i?`重试保存`:`Retry saving`}):null,t[22]=y.error,t[23]=y.retry,t[24]=i,t[25]=T):T=t[25];let E;t[26]!==r||t[27]!==c||t[28]!==i?(E=(0,$.jsx)(fi,{capability:r,draft:c,setDraft:l,zh:i}),t[26]=r,t[27]=c,t[28]=i,t[29]=E):E=t[29];let D;return t[30]!==y.onBlurCapture||t[31]!==w||t[32]!==T||t[33]!==E||t[34]!==C?(D=(0,$.jsxs)(`fieldset`,{disabled:C,onBlurCapture:y.onBlurCapture,className:`min-w-0 space-y-3`,children:[w,T,E]}),t[30]=y.onBlurCapture,t[31]=w,t[32]=T,t[33]=E,t[34]=C,t[35]=D):D=t[35],D}function gi(e){return e.status===`ready`?`ready`:e.status===`disabled`?`off`:e.status===`degraded`?`degraded`:e.rejected?.length?`misconfigured`:`not-configured`}function _i(e,t){if(e.startsWith(`agentCatalog.defaults.models`))return{label:t?`模型与能力`:`Models and capabilities`,href:`/settings/capabilities/models`};let n=e.match(/^agentCatalog\.agents\.([^.]+)\.models/);return n?.[1]?{label:t?`智能体 ${n[1]}`:`Agent ${n[1]}`,href:vt(n[1])}:e.startsWith(`sessions.`)?{label:t?`会话模型覆盖`:`Session model override`,href:`/settings/sessions`}:{label:e,href:`/settings/agent-defaults`}}function vi(e,t){switch(e){case`computer-use`:return{guidance:t?`选择兼容的电脑控制模型;本机权限需单独授权`:`Select a compatible computer model; local access requires separate approval`,action:t?`配置电脑控制`:`Configure computer use`};case`vision`:return{guidance:t?`接入支持图片理解的模型服务`:`Connect a model service that supports vision`,action:t?`去接入模型`:`Connect model`};case`image-generation`:return{guidance:t?`选择图片模型并配置所需凭据`:`Choose an image model and configure its credentials`,action:t?`去配置图片生成`:`Configure image generation`};case`stt`:return{guidance:t?`选择语音识别服务,或安装自管 STT 插件`:`Choose a speech-to-text service or install a self-managed STT plugin`,action:t?`去配置语音识别`:`Configure speech-to-text`};case`tts`:return{guidance:t?`选择语音合成服务并完成凭据配置`:`Choose a text-to-speech service and configure its credentials`,action:t?`去配置语音合成`:`Configure text-to-speech`}}}async function yi(){let e=await u(d(`/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 bi(){let e=await u(d(`/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 xi({showCapabilities:e=!0,embedded:t=!1}={}){let n=p(e=>e.language)===`zh`,{data:r,error:i,isLoading:a}=X(Ct,yi,{revalidateOnFocus:!0,refreshInterval:6e4}),{data:o}=X(wt,bi,{revalidateOnFocus:!1}),[s,c]=(0,Q.useState)(!1),[f,m]=(0,Q.useState)(null),h=Object.values(r?.sources??{}),g=h.reduce((e,t)=>e+t.models.filter(e=>e.availability===`available`).length,0),_=(r?.references??[]).filter(e=>e.availability===`unavailable`),v=r?.sync.lastSuccessAt??Math.max(0,...h.map(e=>e.lastSuccessAt)),y=!!i,b=r?.sync.sourceErrors??{},x=[...r?.sync.lastError?[[`catalog`,r.sync.lastError]]:[],...Object.entries(b),...f?[[`refresh`,f]]:[],...i instanceof Error?[[`load`,i.message]]:[]],S=r?.sync.lastAttemptAt??v,w=Object.entries(o?.capabilities??{}).filter(([e])=>e!==`computer-use`||lt()),T=w.some(([,e])=>{let t=gi(e);return t===`degraded`||t===`misconfigured`}),D=w.filter(([,e])=>gi(e)===`ready`).length,O=(0,Q.useRef)(null);if((0,Q.useEffect)(()=>{T&&!a&&O.current?.setAttribute(`open`,``)},[T,a]),a)return(0,$.jsx)(Me,{className:`h-24 w-full rounded-2xl`});let k=async()=>{c(!0),m(null);try{let e=await u(d(`/api/models/catalog/refresh`),{method:`POST`});if(!e.ok)throw Error(`HTTP ${e.status}`);await St()}catch(e){m(e instanceof Error?e.message:String(e))}finally{c(!1)}},j=(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":n?`同步错误详情`:`Sync error details`,children:x.map(([e,t],n)=>(0,$.jsxs)(`p`,{className:`break-words`,children:[e,`: `,t]},`${e}-${n}`))}),M=(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:n?`${h.length} 个来源,${g} 个可用模型${v?` · 最近同步 ${new Date(v).toLocaleString()}`:``}`:`${h.length} sources, ${g} available models${v?` · Last synced ${new Date(v).toLocaleString()}`:``}`}),x.length>0?t?(0,$.jsxs)(`details`,{className:`mt-2 rounded-lg bg-surface-base/45 p-2`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer rounded text-xs font-medium focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:n?`高级诊断`:`Advanced diagnostics`}),j]}):j:null]}),(0,$.jsxs)(Z,{className:`shrink-0`,type:`button`,variant:`secondary`,disabled:s,onClick:()=>void k(),children:[s?(0,$.jsx)(ge,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(Se,{className:`size-4`,"aria-hidden":!0}),s?n?`刷新中…`:`Refreshing…`:n?`刷新目录`:`Refresh catalog`]})]});return(0,$.jsxs)(`section`,{className:t?`mt-4 border-t border-edge-subtle pt-1`:`rounded-xl bg-surface-hover/25 p-4 sm:p-5`,children:[e?(0,$.jsxs)(`details`,{ref:O,className:`group`,children:[(0,$.jsx)(`summary`,{className:`cursor-pointer list-none rounded-lg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:(0,$.jsxs)(`div`,{className:`flex min-h-10 items-center gap-2`,children:[T?(0,$.jsx)(Oe,{className:`size-4 text-amber-500`,"aria-hidden":!0}):D===w.length&&w.length>0?(0,$.jsx)(A,{className:`size-4 text-emerald-500`,"aria-hidden":!0}):(0,$.jsx)(P,{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:n?`可选能力`:`Optional capabilities`}),(0,$.jsx)(`span`,{className:`mt-0.5 block text-xs font-normal text-fg-muted`,children:n?`${D}/${w.length} 项已配置,不影响基础聊天功能`:`${D} of ${w.length} configured · Not required for chat`})]}),(0,$.jsx)(E,{className:`size-4 shrink-0 text-fg-subtle transition-transform group-open:rotate-90 motion-reduce:transition-none`,"aria-hidden":!0})]})}),o?(0,$.jsx)(`div`,{className:`mt-3 grid gap-1 sm:grid-cols-2`,children:Object.entries(o.capabilities).map(([e,t])=>{if(e===`computer-use`&&!lt())return null;let r=e===`vision`?n?`图片理解`:`Vision`:e===`image-generation`?n?`图片生成`:`Image generation`:e===`computer-use`?n?`电脑控制模型`:`Computer use model`:e.toUpperCase(),i=t.selectionSource!==`explicit-config`,a=gi(t),o=a===`degraded`||a===`misconfigured`,s=vi(e,n),c=(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,$.jsx)(`span`,{className:`min-w-0 text-xs font-medium text-fg`,children:r}),(0,$.jsx)(`span`,{className:a===`ready`?`shrink-0 text-xs text-emerald-600 dark:text-emerald-400`:a===`off`||a===`not-configured`?`shrink-0 text-xs text-fg-muted`:`shrink-0 text-xs text-amber-600 dark:text-amber-400`,children:a===`ready`?e===`computer-use`?n?`已配置`:`Configured`:n?`可用`:`Ready`:a===`off`?n?`已关闭`:`Off`:a===`not-configured`?n?`未配置`:`Not configured`:a===`degraded`?n?`正在使用备用方案`:`Using fallback`:n?`需处理`:`Needs attention`})]}),(0,$.jsx)(`p`,{className:`mt-1 truncate text-xs text-fg-muted`,title:t.primary?`${t.primary.provider}/${t.primary.model}`:void 0,children:t.primary?`${i?n?`自动`:`Auto`:n?`显式`:`Explicit`} · ${t.primary.provider}/${t.primary.model}`:a===`not-configured`?n?`可稍后按需配置`:`Set up later if needed`:n?`已配置的模型不可用`:`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:t.status===`degraded`?n?`当前配置不可用,正在使用备用方案。${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)(C,{className:`size-3.5`,"aria-hidden":!0})]})]}):null]}),u={"aria-label":o?`${r}:${s.action}`:`${n?`配置`:`Configure`} ${r}`,className:Y(`rounded-lg bg-surface-base/45 px-3 py-3 text-left transition-colors`,o?`bg-amber-500/5 hover:bg-amber-500/10`:`hover:bg-surface-hover/30`,`focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`)};if(e===`computer-use`)return(0,$.jsx)(l,{to:`/settings/computer-use`,...u,children:c},e);let d={vision:`vision`,"image-generation":`image`,stt:`transcription`,tts:`speech`}[e];return(0,$.jsx)(`button`,{type:`button`,"aria-haspopup":`dialog`,...u,onClick:()=>$e(d,o?`services`:`settings`),children:c},e)})}):null]}):null,_.length>0?(0,$.jsx)(`div`,{className:`mt-3 space-y-2`,"aria-live":`polite`,children:_.map(e=>(0,$.jsx)(`div`,{className:`rounded-lg border border-amber-500/25 bg-amber-500/5 p-3`,children:(()=>{let t=e.ref.split(`/`)[0]??``,r=!!b[t],i=_i(e.locations[0]??``,n);return(0,$.jsxs)($.Fragment,{children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,$.jsx)(Oe,{className:`mt-0.5 size-4 shrink-0 text-amber-500`,"aria-hidden":!0}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`p`,{className:`break-words text-sm font-medium text-fg`,children:[e.ref,(0,$.jsx)(`span`,{className:`ml-2 font-normal text-amber-700 dark:text-amber-300`,children:r?n?`暂时无法验证`:`Temporarily unverified`:n?`不可用`:`Unavailable`})]}),(0,$.jsxs)(`p`,{className:`mt-1 text-xs leading-5 text-fg-muted`,children:[r?n?`模型目录同步暂时失败,当前状态可能已过期;不会影响其他可用模型。`:`Catalog sync temporarily failed, so this status may be stale. Other available models are unaffected.`:n?`此模型已无法从当前配置中解析,使用它的功能可能失败。`:`This model no longer resolves from the current configuration. Features using it may fail.`,S?` · ${n?`最近检测`:`Last checked`} ${new Date(S).toLocaleString()}`:``]}),e.suggestedRef?(0,$.jsxs)(`p`,{className:`mt-1 text-xs text-fg-muted`,children:[n?`可替换为`:`Suggested replacement`,`:`,(0,$.jsx)(`span`,{className:`font-medium text-fg`,children:e.suggestedRef})]}):null]})]}),(0,$.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1`,children:[(0,$.jsxs)(Z,{className:`px-2.5 py-1.5 text-xs`,variant:`ghost`,disabled:s,onClick:()=>void k(),children:[s?(0,$.jsx)(ge,{className:`size-3.5 animate-spin`,"aria-hidden":!0}):(0,$.jsx)(Se,{className:`size-3.5`,"aria-hidden":!0}),s?n?`检测中…`:`Checking…`:n?`重新检测`:`Check again`]}),(0,$.jsx)(Z,{asChild:!0,className:`px-2.5 py-1.5 text-xs`,variant:`ghost`,children:(0,$.jsxs)(l,{to:i.href,children:[(0,$.jsx)(Ae,{className:`size-3.5`,"aria-hidden":!0}),e.suggestedRef?n?`更换模型`:`Replace model`:n?`调整配置`:`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:[n?`查看 ${e.locations.length} 处引用`:`View ${e.locations.length} ${e.locations.length===1?`reference`:`references`}`,(0,$.jsx)(E,{className:`size-3.5 transition-transform group-open/references:rotate-90 motion-reduce:transition-none`,"aria-hidden":!0})]}),(0,$.jsx)(`ul`,{className:`mt-1 space-y-1 pl-2 text-xs text-fg-muted`,children:e.locations.map(e=>{let t=_i(e,n);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:t.href,title:e,children:t.label})},e)})})]})]})]})})()},e.ref))}):null,y||f?(0,$.jsx)(`p`,{className:`mt-3 text-sm text-danger`,role:`alert`,children:y?n?`暂时无法读取模型状态,请重新检测;详细信息可在高级诊断中查看。`:`Model status is temporarily unavailable. Check again; details are available in Advanced diagnostics.`:n?`重新检测失败,请稍后重试;详细信息可在高级诊断中查看。`:`The check failed. Try again later; details are available in Advanced diagnostics.`}):null,t?M:(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:n?`高级诊断`:`Advanced diagnostics`}),M]})]})}function Si(e){let t=(0,vn.c)(171),n;t[0]===e?n=t[1]:(n=e===void 0?{}:e,t[0]=e,t[1]=n);let{inlineUse:r,inlineView:i,onViewChange:u,onPendingChange:d}=n,f=i===void 0?`settings`:i,m=p(Ei),g=m===`zh`,_;t[2]===m?_=t[3]:(_=h(m),t[2]=m,t[3]=_);let v=_.capabilitiesSettings,{capability:y}=a(),[b,x]=s(),{state:S}=o(),C;t[4]===b?C=t[5]:(C=ce(b.get(`returnTo`)),t[4]=b,t[5]=C);let w=C,[T,E]=(0,Q.useState)(),[D,O]=(0,Q.useState)(!1),[k,A]=(0,Q.useState)(!1),[j,M]=(0,Q.useState)(!1),[N,P]=(0,Q.useState)(!1),F=j||N||k,[L,R]=(0,Q.useState)(!1),[z,B]=(0,Q.useState)(null),ee=(0,Q.useRef)(null),V=re(),te;t[6]===V.cards?te=t[7]:(te=V.cards.some(Ti),t[6]=V.cards,t[7]=te);let H=te,U=wi,W,ne;t[8]!==d||t[9]!==F?(W=()=>(d?.(F),()=>d?.(!1)),ne=[F,d],t[8]=d,t[9]=F,t[10]=W,t[11]=ne):(W=t[10],ne=t[11]),(0,Q.useEffect)(W,ne);let G,K;t[12]!==y||t[13]!==r||t[14]!==S||t[15]!==b||t[16]!==x?(G=()=>{if(r||y!==`models`)return;let e=I(b.get(`configure`));if(!e&&b.get(`add`)!==`1`)return;let t=window.setTimeout(()=>{e?$e(e,b.get(`tab`)===`services`?`services`:`settings`):R(!0);let t=new URLSearchParams(b);t.delete(`configure`),t.delete(`tab`),t.delete(`add`),x(t,{replace:!0,state:S})},0);return()=>window.clearTimeout(t)},K=[y,r,b,x,S],t[12]=y,t[13]=r,t[14]=S,t[15]=b,t[16]=x,t[17]=G,t[18]=K):(G=t[17],K=t[18]),(0,Q.useEffect)(G,K);let ae;t[19]!==r||t[20]!==u||t[21]!==F?(ae=e=>{if(!F){if(!r){$e(e,`services`);return}u?.(`services`),E(void 0)}},t[19]=r,t[20]=u,t[21]=F,t[22]=ae):ae=t[22];let oe=ae,se;t[23]===u?se=t[24]:(se=e=>{U(),u?.(`settings`),E(e)},t[23]=u,t[24]=se);let J=se;if(r){let e=f===`services`,n=N||k,i;t[25]!==r||t[26]!==oe||t[27]!==V||t[28]!==n||t[29]!==g?(i=(0,$.jsx)(Xr,{data:V,zh:g,onlyUse:r,disabled:n,onPendingChange:M,onChange:oe}),t[25]=r,t[26]=oe,t[27]=V,t[28]=n,t[29]=g,t[30]=i):i=t[30];let a;t[31]!==e||t[32]!==i?(a=(0,$.jsx)(`div`,{hidden:e,children:i}),t[31]=e,t[32]=i,t[33]=a):a=t[33];let o;t[34]!==T||t[35]!==r||t[36]!==f||t[37]!==g?(o=T===r&&f===`settings`?(0,$.jsx)(`p`,{role:`status`,className:`text-sm text-fg-muted`,children:g?`服务设置已保存`:`Service settings saved`}):null,t[34]=T,t[35]=r,t[36]=f,t[37]=g,t[38]=o):o=t[38];let s=f!==`services`,c;t[39]!==J||t[40]!==r?(c=()=>J(r),t[39]=J,t[40]=r,t[41]=c):c=t[41];let l;t[42]!==v.addProviderDialog||t[43]!==r||t[44]!==m||t[45]!==V||t[46]!==c?(l=(0,$.jsx)(Rr,{inline:!0,onEditingChange:O,use:r,data:V,language:m,labels:v.addProviderDialog,onPendingChange:A,onSaved:c},r),t[42]=v.addProviderDialog,t[43]=r,t[44]=m,t[45]=V,t[46]=c,t[47]=l):l=t[47];let u;t[48]!==J||t[49]!==D||t[50]!==r||t[51]!==V.builtinRows||t[52]!==g?(u=r===`transcription`||r===`speech`?(0,$.jsx)(`div`,{hidden:D,children:(0,$.jsx)(Jr,{kind:r===`transcription`?`stt`:`tts`,modelServiceIds:V.builtinRows.map(Ci),zh:g,onPendingChange:A,onSaved:()=>J(r)},r)}):null,t[48]=J,t[49]=D,t[50]=r,t[51]=V.builtinRows,t[52]=g,t[53]=u):u=t[53];let d;t[54]!==J||t[55]!==r?(d=r===`image`?(0,$.jsx)(Pn,{connectOnly:!0,onPendingChange:A,onConnected:()=>J(r)}):null,t[54]=J,t[55]=r,t[56]=d):d=t[56];let p;t[57]!==k||t[58]!==s||t[59]!==l||t[60]!==u||t[61]!==d?(p=(0,$.jsxs)(`fieldset`,{hidden:s,disabled:k,className:`min-w-0 space-y-3`,children:[l,u,d]}),t[57]=k,t[58]=s,t[59]=l,t[60]=u,t[61]=d,t[62]=p):p=t[62];let h=f===`services`,_;t[63]!==k||t[64]!==r||t[65]!==j?(_=r===`transcription`||r===`speech`||r===`conversation`?(0,$.jsx)(cr,{capability:r,onPendingChange:P,disabled:j||k},r):null,t[63]=k,t[64]=r,t[65]=j,t[66]=_):_=t[66];let y;t[67]!==k||t[68]!==r||t[69]!==j||t[70]!==g?(y=r===`chat`||r===`vision`||r===`image`?(0,$.jsx)(mi,{capability:r,zh:g,disabled:j||k,onPendingChange:P}):null,t[67]=k,t[68]=r,t[69]=j,t[70]=g,t[71]=y):y=t[71];let b;t[72]!==r||t[73]!==g?(b=r===`background`?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:g?`使用所选模型执行自动化、定时和无人值守任务。此设置不会启用任务,也不会自动改用其他计费服务。`:`Use the selected model for automations, schedules and unattended tasks. This does not enable tasks or automatically switch billing services.`}):null,t[72]=r,t[73]=g,t[74]=b):b=t[74];let x;t[75]!==h||t[76]!==_||t[77]!==y||t[78]!==b?(x=(0,$.jsxs)(`div`,{hidden:h,className:`space-y-4`,children:[_,y,b]}),t[75]=h,t[76]=_,t[77]=y,t[78]=b,t[79]=x):x=t[79];let S;t[80]!==oe||t[81]!==o||t[82]!==p||t[83]!==x?(S=(0,$.jsxs)(Ln.Provider,{value:oe,children:[o,p,x]}),t[80]=oe,t[81]=o,t[82]=p,t[83]=x,t[84]=S):S=t[84];let C;return t[85]!==a||t[86]!==S?(C=(0,$.jsxs)(`div`,{className:`min-w-0 space-y-4`,children:[a,S]}),t[85]=a,t[86]=S,t[87]=C):C=t[87],C}if(y===`search`){let e;t[88]===m?e=t[89]:(e=h(m),t[88]=m,t[89]=e);let n;t[90]===e.nav.settingsSearch?n=t[91]:(n=(0,$.jsx)(Vt,{title:e.nav.settingsSearch}),t[90]=e.nav.settingsSearch,t[91]=n);let r;t[92]===Symbol.for(`react.memo_cache_sentinel`)?(r=(0,$.jsx)(Pr,{}),t[92]=r):r=t[92];let i;return t[93]===n?i=t[94]:(i=(0,$.jsxs)(Bt,{children:[n,r]}),t[93]=n,t[94]=i),i}if(y!==`models`){let e;return t[95]===Symbol.for(`react.memo_cache_sentinel`)?(e=(0,$.jsx)(c,{to:`/settings/capabilities/models`,replace:!0}),t[95]=e):e=t[95],e}let le=g?`模型与能力`:`Models and capabilities`,ue=g?`按用途选择模型,在设置中调整参数与服务连接。`:`Choose models by purpose. Adjust parameters and connections in settings.`,de;t[96]===m?de=t[97]:(de=ct(m,`configuration`),t[96]=m,t[97]=de);let fe;t[98]!==v.docsLink||t[99]!==de?(fe=(0,$.jsx)(`a`,{href:de,target:`_blank`,rel:`noreferrer`,className:`inline-flex min-h-11 items-center rounded-lg px-2 text-xs text-fg-muted hover:text-fg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:v.docsLink}),t[98]=v.docsLink,t[99]=de,t[100]=fe):fe=t[100];let pe;t[101]===Symbol.for(`react.memo_cache_sentinel`)?(pe=()=>{ee.current?.scrollIntoView?.({block:`start`}),ee.current?.focus({preventScroll:!0})},t[101]=pe):pe=t[101];let me=g?`服务账户`:`Service accounts`,he;t[102]!==F||t[103]!==me?(he=(0,$.jsx)(Z,{variant:`secondary`,disabled:F,onClick:pe,children:me}),t[102]=F,t[103]=me,t[104]=he):he=t[104];let ge;t[105]!==fe||t[106]!==he?(ge=(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[fe,he]}),t[105]=fe,t[106]=he,t[107]=ge):ge=t[107];let _e;t[108]!==le||t[109]!==ue||t[110]!==ge?(_e=(0,$.jsx)(Vt,{title:le,subtitle:ue,actions:ge}),t[108]=le,t[109]=ue,t[110]=ge,t[111]=_e):_e=t[111];let ve;t[112]!==w||t[113]!==g?(ve=w?(0,$.jsx)(l,{to:w,className:`text-sm text-accent-fg hover:underline`,children:w===`/settings/phone-use`?g?`返回手机控制并测试模型`:`Return to phone control and test the model`:g?`返回原来的工作`:`Return to your work`}):null,t[112]=w,t[113]=g,t[114]=ve):ve=t[114];let ye;t[115]!==w||t[116]!==g?(ye=w?(0,$.jsx)(`p`,{className:`text-sm text-fg-muted`,children:w===`/settings/phone-use`?g?`正在为手机控制连接模型服务;此处保存服务设置后,还需返回选择并测试手机模型。`:`Connect a model service for phone control, then return to select and test the phone model.`:g?`正在为原来的工作配置模型。服务保存、模型选择和实际运行验证分别生效。`:`Configure models for your work. Saving a service, choosing a model and verifying a run are separate steps.`}):null,t[115]=w,t[116]=g,t[117]=ye):ye=t[117];let be;t[118]===F?be=t[119]:(be=e=>{F||$e(e)},t[118]=F,t[119]=be);let xe;t[120]!==oe||t[121]!==V||t[122]!==F||t[123]!==be||t[124]!==g?(xe=(0,$.jsx)(Xr,{data:V,zh:g,disabled:F,onPendingChange:M,onChange:oe,onSettings:be}),t[120]=oe,t[121]=V,t[122]=F,t[123]=be,t[124]=g,t[125]=xe):xe=t[125];let Se=g?`连接的服务`:`Connected services`,Ce;t[126]===Se?Ce=t[127]:(Ce=(0,$.jsx)(`h2`,{id:`model-services-heading`,className:`text-base font-semibold text-fg`,children:Se}),t[126]=Se,t[127]=Ce);let we=g?`在这里管理账户和密钥;各项能力的模型与参数在上方调整。`:`Manage accounts and keys here. Choose models and adjust capability settings above.`,Te;t[128]===we?Te=t[129]:(Te=(0,$.jsx)(`p`,{className:`mt-1 text-sm text-fg-muted`,children:we}),t[128]=we,t[129]=Te);let Ee;t[130]!==Ce||t[131]!==Te?(Ee=(0,$.jsxs)(`div`,{children:[Ce,Te]}),t[130]=Ce,t[131]=Te,t[132]=Ee):Ee=t[132];let De;t[133]!==v.xopcCloudAccount||t[134]!==H?(De=H?(0,$.jsx)(dn,{labels:v.xopcCloudAccount,children:(0,$.jsx)(xi,{showCapabilities:!1,embedded:!0})}):null,t[133]=v.xopcCloudAccount,t[134]=H,t[135]=De):De=t[135];let Oe,ke;t[136]===Symbol.for(`react.memo_cache_sentinel`)?(Oe=()=>R(!0),ke=(e,t)=>B({providerId:e,isCustom:t}),t[136]=Oe,t[137]=ke):(Oe=t[136],ke=t[137]);let Ae;t[138]!==v.connectedProviders||t[139]!==V?(Ae=(0,$.jsx)(q,{labels:v.connectedProviders,data:V,onAdd:Oe,onManage:ke}),t[138]=v.connectedProviders,t[139]=V,t[140]=Ae):Ae=t[140];let je;t[141]!==H||t[142]!==V.cards.length?(je=!H&&V.cards.length>0?(0,$.jsx)(xi,{showCapabilities:!1}):null,t[141]=H,t[142]=V.cards.length,t[143]=je):je=t[143];let Y;t[144]!==Ee||t[145]!==De||t[146]!==Ae||t[147]!==je?(Y=(0,$.jsxs)(`section`,{ref:ee,tabIndex:-1,"aria-labelledby":`model-services-heading`,className:`space-y-4 scroll-mt-4 rounded-xl focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent`,children:[Ee,De,Ae,je]}),t[144]=Ee,t[145]=De,t[146]=Ae,t[147]=je,t[148]=Y):Y=t[148];let Me;t[149]===Symbol.for(`react.memo_cache_sentinel`)?(Me=()=>{U(),R(!1)},t[149]=Me):Me=t[149];let Ne;t[150]!==L||t[151]!==v.addProviderDialog||t[152]!==m||t[153]!==V.builtinRows||t[154]!==V.customConfig?(Ne=(0,$.jsx)(ie,{open:L,connectOnly:!0,onOpenChange:R,builtinRows:V.builtinRows,customConfig:V.customConfig,labels:v.addProviderDialog,language:m,onSaved:Me}),t[150]=L,t[151]=v.addProviderDialog,t[152]=m,t[153]=V.builtinRows,t[154]=V.customConfig,t[155]=Ne):Ne=t[155];let Pe;t[156]!==v.manageProviderDialog||t[157]!==m||t[158]!==z||t[159]!==V.allModels||t[160]!==V.builtinRows||t[161]!==V.customConfig?(Pe=z?(0,$.jsx)(ai,{open:!0,onOpenChange:e=>{e||B(null)},providerId:z.providerId,isCustom:z.isCustom,builtinRows:V.builtinRows,customConfig:V.customConfig,allModels:V.allModels,labels:v.manageProviderDialog,language:m,onSaved:U}):null,t[156]=v.manageProviderDialog,t[157]=m,t[158]=z,t[159]=V.allModels,t[160]=V.builtinRows,t[161]=V.customConfig,t[162]=Pe):Pe=t[162];let Fe;return t[163]!==_e||t[164]!==ve||t[165]!==ye||t[166]!==xe||t[167]!==Y||t[168]!==Ne||t[169]!==Pe?(Fe=(0,$.jsxs)(Bt,{children:[_e,ve,ye,xe,Y,Ne,Pe]}),t[163]=_e,t[164]=ve,t[165]=ye,t[166]=xe,t[167]=Y,t[168]=Ne,t[169]=Pe,t[170]=Fe):Fe=t[170],Fe}function Ci(e){return e.id}function wi(){St()}function Ti(e){return e.id===`xopc-cloud`&&!e.isCustom}function Ei(e){return e.language}export{Si 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{i,o as a,p as o,r as s}from"./locale-store-CQcW9_qA.js";import{t as c}from"./check-DUBLcKHA.js";import{t as l}from"./circle-alert-BEjgurr2.js";import{x as u}from"./use-file-preview-expanded-4SKLb9Fh.js";import{t as ee}from"./mic-CuUb7zc-.js";import{t as d}from"./rotate-ccw-JM1TBLpp.js";import{t as f}from"./settings-2-D-csvaET.js";import{t as te}from"./x-B_N4OPjy.js";import{t as p}from"./cn-0WouolD0.js";import{t as ne}from"./skeleton-DzdOeGYz.js";import{a as m,f as h,i as re,l as ie,n as g,r as ae,t as oe,u as se}from"./voice-transcribe-api-D4eyeSdG.js";import{d as _}from"./tasks-BTLabOMp.js";import{s as v}from"./file-preview-surface-B3nLuoQO.js";import{t as y}from"./open-capability-settings-Cvb65hQB.js";import{n as b}from"./interaction-BdhHBbYa.js";import{t as x}from"./workspace-editor-agent-store-2Lt7rQfw.js";import{l as S,p as C}from"./voice-input-shortcut-events-TAmJNcsN.js";function w(e){let t=e.task.contract?.acceptanceCriteria??[],n=new Map(e.runs.map(e=>[e.id,e])),r=e.receipts.filter(t=>n.get(t.runId)?.contractVersion===e.task.latestContractVersion).sort((e,t)=>t.finalizedAt-e.finalizedAt);return t.map((t,n)=>{let i=e.criterionReviews.find(r=>r.criterionIndex===n&&r.contractVersion===e.task.latestContractVersion&&r.criterionText===t),a={text:t,status:`unverified`,evidence:[]};for(let e of r){let n=e.verification.checks.find(e=>e.criterion===t);if(!n)continue;let r=e.evidence.filter(e=>n.evidenceTitles.includes(e.title)),i=n.status===`passed`&&_(e).has(t)?`passed`:n.status===`failed`?`failed`:`unverified`;a={text:t,status:i,evidence:r,runId:e.runId,verificationStatus:i,method:n.method,note:n.note};break}return i?{...a,status:i.status,review:i}:e.task.contract?.acceptancePolicy===`manual`?{...a,status:`unverified`}:a})}function T(e){let t=new Set(e.runs.filter(t=>t.contractVersion===e.task.latestContractVersion).map(e=>e.id));return e.receipts.filter(e=>t.has(e.runId)).sort((e,t)=>t.finalizedAt-e.finalizedAt)[0]}function E(e){let t=T(e),n=w(e);return{receipt:t,verified:n.filter(e=>e.status===`passed`).length,criteria:n.length,deliverables:e.context.filter(e=>e.role===`deliverable`).length}}function D(e){return e.task.phase===`closed`?e.task.resolution===`done`?`completed`:`ended`:e.waits.some(e=>e.kind===`paused`)?`paused`:e.attention.some(e=>e.kind===`input_required`||e.kind===`approval_required`)?`needsUser`:e.operationalState===`idle`?e.task.phase===`backlog`?`captured`:e.task.phase===`ready`?`ready`:e.task.phase===`review`?`review`:`ready`:e.operationalState}function O(e){return e===`failed`?`bg-danger/10 text-danger`:e===`needsUser`||e===`blocked`?`bg-warning/10 text-warning`:e===`completed`?`bg-success-soft text-success`:e===`running`||e===`verifying`||e===`review`?`bg-accent-soft text-accent-fg`:`bg-surface-hover text-fg-muted`}function k(e){return e===`zh`?{newWork:`交给 xopc`,dialogTitle:`现在想完成什么?`,dialogDescription:`发送后会进入新对话。xopc 会直接回答或开始处理;需要持续推进时,再转为任务。`,intentLabel:`告诉 xopc 你要做什么`,intentPlaceholder:`例如:整理这周的会议记录,提炼待办并给出下周优先级`,intentSuggestion:`整理这周的会议记录,提炼待办并给出下周优先级`,submit:`进入对话并开始`,projectLabel:`归属项目`,monitoringLabel:`跟进策略`,monitoringModes:{observe:`仅观察`,ask_before_action:`行动前询问`,auto_low_risk:`自动执行低风险操作`},existingProject:`已有项目`,newProject:`新项目`,needsAttention:`需要你处理`,waitingStatus:`当前等待`,runAttention:`运行异常`,running:`xopc 正在处理`,continue:`继续推进`,recent:`最近对话`,evidenceCount:`项证据`,remainingCount:`项待继续`,projects:`长期项目`,emptyRunning:`当前没有正在处理的对话`,emptyContinue:`还没有需要继续推进的事项`,openChat:`打开对话`,whyNow:`为什么现在`,impact:`影响`,workDone:`AI 已完成`,recommendation:`建议`,policyReason:`处理依据`,proposedAction:`拟执行动作`,actionStates:{not_authorized:`仅建议,未获自动执行授权`,approval_required:`等待你批准`,pending:`等待执行`,executing:`正在执行`,completed:`已自动执行`,rejected:`已拒绝`,failed:`执行失败`},judgmentReasons:`判断依据`,rejectedAlternatives:`未选方案`,uncertainty:`不确定性`,snooze:`明天再看`,dismiss:`忽略`,feedbackPlaceholder:`告诉 AI:以后遇到这类情况应该怎样判断…`,applyFeedback:`调整后续判断`,evidence:`证据引用`,useful:`有帮助`,notUseful:`没帮助`,taskStatuses:{pending:`待推进`,planning:`正在明确完成标准`,waiting_dependency:`等待前置任务`,running:`正在推进`,verifying:`正在验证`,needs_user:`需要你`,blocked:`已阻塞`,paused:`已暂停`,completed:`已完成`,cancelled:`已结束`},taskProgress:{title:`xopc 已接手`,open:`查看结果`,decide:`查看并决定`,evidence:`项已验证依据`,statuses:{pending:`待推进`,planning:`正在明确完成标准`,waiting_dependency:`等待前置任务`,running:`正在推进`,verifying:`正在验证`,needs_user:`需要你`,blocked:`已阻塞`,paused:`已暂停`,completed:`已完成`,cancelled:`已结束`}},detailStatuses:{allocating:`正在分配执行者`,captured:`尚未安排`,ready:`等待开始`,queued:`已进入队列`,running:`正在执行`,verifying:`正在验证`,waiting:`等待条件`,blocked:`被阻塞`,failed:`执行失败`,cancelled:`执行已取消`,needsUser:`需要你处理`,review:`等待验收`,completed:`已完成`,ended:`已结束`,paused:`已暂停`},detailStatusDescriptions:{allocating:`任务已提交,正在后台选择合适的执行者。`,captured:`任务已记录,但尚未进入执行队列。安排后,xopc 会开始推进。`,ready:`任务已经准备好,可以交给 xopc 开始执行。`,queued:`任务已进入执行队列,xopc 将在资源可用时开始。`,running:`xopc 正在推进这个任务。`,verifying:`xopc 正在根据完成标准核验结果。`,waiting:`任务正在等待外部条件满足。`,blocked:`当前存在阻塞条件,解除后才能继续。`,failed:`最近一次执行失败;查看运行记录后可以重试。`,cancelled:`最近一次执行已取消;任务仍可重新开始。`,needsUser:`xopc 需要你的输入或批准后才能继续。`,review:`执行结果已经准备好,等待你验收。`,completed:`任务已经完成并关闭。`,ended:`任务已经结束,不会继续执行。`,paused:`已暂停自动推进和催办。恢复后仍需满足其他等待条件。`},statusSummary:`当前状态`,taskLabel:`任务`,taskDescription:`任务描述与目标`,editTaskField:`编辑`,saveTaskField:`保存`,cancelTaskField:`取消`,noTaskDescription:`添加任务背景、范围和交付要求。`,taskProperties:`任务属性`,taskPhase:`阶段`,priority:`优先级`,dueDate:`截止日期`,executorLabel:`执行 Agent`,priorityLabels:{low:`低优先级`,normal:`普通优先级`,high:`高优先级`,critical:`紧急`},unassigned:`未指定执行者`,noDueDate:`无截止时间`,updatedAt:`更新于 {{date}}`,successDefinition:`怎样才算完成`,taskDefinition:`任务定义`,criteriaProgress:`{{verified}}/{{total}} 已验证`,taskRelations:`任务关系`,dependencies:`前置任务`,dependents:`后续任务`,noDependencies:`没有前置任务`,noDependents:`没有后续任务`,editDependencies:`编辑前置任务`,saveDependencies:`保存关系`,cancelDependencyEdit:`取消`,dependenciesDescription:`所选任务全部完成后,xopc 才会开始推进当前任务。`,linkDependencies:`关联前置任务`,linkedDependencies:`已关联 {{count}} 个前置任务`,dependencySearchPlaceholder:`搜索任务名称`,noDependencyMatches:`没有匹配的任务`,noDependencyCandidates:`没有可选的其他任务`,removeDependency:`移除前置任务:{{task}}`,dependencyUpdateFailed:`前置任务更新失败,请刷新后重试。`,expectedOutputs:`预期输出`,constraints:`约束与边界`,approvalRequired:`需要你批准`,latestResult:`最新结果`,remainingWork:`还差什么`,nextAction:`下一步`,yourDecision:`只需你决定`,noRemainingWork:`已覆盖全部完成标准。`,noDecisionNeeded:`暂时不需要你做任何事,xopc 会继续推进。`,contextUsed:`本次使用的上下文`,contextSources:`信息来源`,contextAssumptions:`当前假设`,contextRisks:`风险`,contextRoleLabels:{input:`输入`,reference:`参考`,constraint:`约束`,deliverable:`交付物`,evidence:`证据`},contextKindLabels:{document:`文档`,file:`文件`,url:`链接`,session:`对话`,memory:`记忆`,task:`任务`,artifact:`产物`,source:`来源`},currentTask:`当前任务`,executionHistory:`历史执行记录({{count}})`,receiptStatuses:{succeeded:`执行成功`,failed:`执行失败`,cancelled:`已取消`},unresolvedCriteria:`待验证标准`,resultFeedback:`这件事做好了吗?`,doneWell:`结果有帮助`,needsFix:`结果没帮助`,correctionPlaceholder:`告诉 xopc 哪里不对、你真正想要的结果是什么`,submitCorrection:`修正并继续`,feedbackThanks:`收到,我会据此继续改进。`,correctionStarted:`收到,已重新打开并开始修正。`,noDefinition:`系统正在进一步明确完成标准。未明确前不会把事情误判为已完成。`,backToWork:`返回任务列表`,openTaskConversation:`进入对话`,taskNotFound:`没有找到这个任务`,runTask:`开始推进`,scheduleTask:`安排执行`,scheduleRecurringTask:`定时执行`,approveTask:`确认完成`,reopenTask:`重新打开`,moreActions:`更多操作`,pauseTask:`暂停推进`,resumeTask:`继续推进`,cancelTask:`结束事项`,cancelActiveRun:`取消当前执行`,deleteTask:`永久删除任务`,deleteTaskTitle:`永久删除这个任务?`,deleteTaskDescription:`将永久删除“{{title}}”及其执行记录、上下文和回执。关联对话、工作区文件和外部产物不会被删除。`,confirmDeleteTask:`永久删除`,keepTask:`保留任务`,deleteActiveTaskBlocked:`请先结束当前执行,再永久删除任务。`,actionFailed:`操作失败,请重试。`,verificationStatuses:{passed:`已验证`,failed:`验证未通过`,unverified:`待验证`}}:{newWork:`Ask xopc`,dialogTitle:`What do you want to get done?`,dialogDescription:`This opens a new conversation. xopc will answer or start working, and create a task only when the work needs ongoing progress.`,intentLabel:`Tell xopc what you need`,intentPlaceholder:`For example: summarize this week’s meeting notes and suggest next week’s priorities`,intentSuggestion:`Summarize this week’s meeting notes and suggest next week’s priorities`,submit:`Open conversation and start`,projectLabel:`Project`,monitoringLabel:`Follow-up policy`,monitoringModes:{observe:`Observe only`,ask_before_action:`Ask before acting`,auto_low_risk:`Auto-run low-risk actions`},existingProject:`Existing project`,newProject:`New project`,needsAttention:`Needs your attention`,waitingStatus:`Current status`,runAttention:`Run issues`,running:`xopc is working`,continue:`Continue`,recent:`Recent conversations`,evidenceCount:`evidence items`,remainingCount:`remaining`,projects:`Long-term projects`,emptyRunning:`No conversations are running`,emptyContinue:`No ongoing items yet`,openChat:`Open conversation`,whyNow:`Why now`,impact:`Impact`,workDone:`AI checked`,recommendation:`Recommendation`,policyReason:`Policy decision`,proposedAction:`Proposed action`,actionStates:{not_authorized:`Suggested only; not authorized for auto-run`,approval_required:`Waiting for your approval`,pending:`Queued to run`,executing:`Running`,completed:`Auto-run completed`,rejected:`Rejected`,failed:`Execution failed`},judgmentReasons:`Why this is recommended`,rejectedAlternatives:`Alternatives not chosen`,uncertainty:`Uncertainty`,snooze:`Tomorrow`,dismiss:`Dismiss`,feedbackPlaceholder:`Tell AI how to judge this kind of event next time…`,applyFeedback:`Update future judgments`,evidence:`Evidence references`,useful:`Useful`,notUseful:`Not useful`,taskStatuses:{pending:`Pending`,planning:`Defining done`,waiting_dependency:`Waiting on dependencies`,running:`In progress`,verifying:`Verifying`,needs_user:`Needs you`,blocked:`Blocked`,paused:`Paused`,completed:`Completed`,cancelled:`Ended`},taskProgress:{title:`xopc owns this task`,open:`View task`,decide:`Review and decide`,evidence:`verified evidence`,statuses:{pending:`Pending`,planning:`Defining done`,waiting_dependency:`Waiting on dependencies`,running:`In progress`,verifying:`Verifying`,needs_user:`Needs you`,blocked:`Needs you`,paused:`Paused`,completed:`Completed`,cancelled:`Ended`}},detailStatuses:{allocating:`Assigning an executor`,captured:`Not scheduled`,ready:`Ready to start`,queued:`Queued`,running:`In progress`,verifying:`Verifying`,waiting:`Waiting`,blocked:`Blocked`,failed:`Execution failed`,cancelled:`Execution cancelled`,needsUser:`Needs your attention`,review:`Ready for review`,completed:`Completed`,ended:`Ended`,paused:`Paused`},detailStatusDescriptions:{allocating:`The task is submitted and a suitable executor is being selected in the background.`,captured:`This task is captured but has not entered the work queue. Schedule it when you are ready.`,ready:`This task is ready for xopc to start.`,queued:`This task is queued and will start when resources are available.`,running:`xopc is currently working on this task.`,verifying:`xopc is checking the result against the completion criteria.`,waiting:`This task is waiting for an external condition.`,blocked:`A blocking condition must be resolved before work can continue.`,failed:`The latest run failed. Review its result before retrying.`,cancelled:`The latest run was cancelled. This task can be started again.`,needsUser:`xopc needs your input or approval before continuing.`,review:`The result is ready for your review.`,completed:`This task is complete and closed.`,ended:`This task has ended and will not continue.`,paused:`Automatic progress and reminders are paused. Other waiting conditions still apply after resuming.`},statusSummary:`Current status`,taskLabel:`Task`,taskDescription:`Description and objective`,editTaskField:`Edit`,saveTaskField:`Save`,cancelTaskField:`Cancel`,noTaskDescription:`Add background, scope, and delivery requirements.`,taskProperties:`Task properties`,taskPhase:`Phase`,priority:`Priority`,dueDate:`Due date`,executorLabel:`Agent`,priorityLabels:{low:`Low priority`,normal:`Normal priority`,high:`High priority`,critical:`Critical`},unassigned:`No assignee`,noDueDate:`No due date`,updatedAt:`Updated {{date}}`,successDefinition:`Definition of done`,taskDefinition:`Task definition`,criteriaProgress:`{{verified}}/{{total}} verified`,taskRelations:`Task relationships`,dependencies:`Dependencies`,dependents:`Dependent tasks`,noDependencies:`No dependencies`,noDependents:`No dependent tasks`,editDependencies:`Edit dependencies`,saveDependencies:`Save relationships`,cancelDependencyEdit:`Cancel`,dependenciesDescription:`xopc starts this task after every selected task is complete.`,linkDependencies:`Link dependencies`,linkedDependencies:`Linked dependencies: {{count}}`,dependencySearchPlaceholder:`Search tasks`,noDependencyMatches:`No matching tasks`,noDependencyCandidates:`There are no other tasks to select`,removeDependency:`Remove dependency: {{task}}`,dependencyUpdateFailed:`Dependencies could not be updated. Refresh and try again.`,expectedOutputs:`Expected outputs`,constraints:`Constraints and boundaries`,approvalRequired:`Your approval is required`,latestResult:`Latest result`,remainingWork:`What remains`,nextAction:`Next action`,yourDecision:`Your one decision`,noRemainingWork:`All completion criteria are covered.`,noDecisionNeeded:`Nothing is needed from you. xopc will keep moving this forward.`,contextUsed:`Context used for this task`,contextSources:`Sources`,contextAssumptions:`Current assumptions`,contextRisks:`Risks`,contextRoleLabels:{input:`Input`,reference:`Reference`,constraint:`Constraint`,deliverable:`Deliverable`,evidence:`Evidence`},contextKindLabels:{document:`Document`,file:`File`,url:`Link`,session:`Conversation`,memory:`Memory`,task:`Task`,artifact:`Artifact`,source:`Source`},currentTask:`Current task`,executionHistory:`Execution history ({{count}})`,receiptStatuses:{succeeded:`Succeeded`,failed:`Failed`,cancelled:`Cancelled`},unresolvedCriteria:`Criteria still to verify`,resultFeedback:`Was this done well?`,doneWell:`Helpful result`,needsFix:`Unhelpful result`,correctionPlaceholder:`Tell xopc what is wrong and what the right task should be`,submitCorrection:`Fix and continue`,feedbackThanks:`Got it. I will use this to improve future work.`,correctionStarted:`Got it. This was reopened and correction has started.`,noDefinition:`xopc is still clarifying the completion criteria. It will not mark this done before they are explicit.`,backToWork:`Back to tasks`,openTaskConversation:`Open conversation`,taskNotFound:`This task was not found`,runTask:`Start working`,scheduleTask:`Schedule work`,scheduleRecurringTask:`Schedule`,approveTask:`Mark complete`,reopenTask:`Reopen`,moreActions:`More actions`,pauseTask:`Pause`,resumeTask:`Continue`,cancelTask:`End task`,cancelActiveRun:`Cancel active run`,deleteTask:`Delete task permanently`,deleteTaskTitle:`Delete this task permanently?`,deleteTaskDescription:`This permanently deletes “{{title}}” and its execution records, context, and receipts. Linked conversations, workspace files, and external artifacts are kept.`,confirmDeleteTask:`Delete permanently`,keepTask:`Keep task`,deleteActiveTaskBlocked:`End the active run before deleting this task permanently.`,actionFailed:`The action failed. Please try again.`,verificationStatuses:{passed:`Verified`,failed:`Verification failed`,unverified:`Not verified`}}}function A(e,t,n,r){return new Promise((i,a)=>{let o=!1,s=(e,n)=>{o||(o=!0,clearTimeout(l),t.removeEventListener(`abort`,c),e===void 0?i(n):a(e))},c=()=>s(t.reason??new DOMException(`Cancelled`,`AbortError`)),l=setTimeout(()=>s(new DOMException(`Voice startup timed out`,`TimeoutError`)),n);e.then(e=>{o?r?.(e):s(void 0,e)},e=>s(e)),t.addEventListener(`abort`,c,{once:!0}),t.aborted&&c()})}function j(e,t,n,r){let i=e.get(t);if(i&&(n<i.revision||i.final&&!r||n===i.revision&&(i.final||!r)))return!1;if(!e.has(t)&&e.size>=256){let t=e.keys().next().value;t!==void 0&&e.delete(t)}return e.set(t,{revision:n,final:r}),!0}var M=e(t(),1),N=null;function ce(e){return N&&N!==e?!1:(N=e,!0)}function le(e){N===e&&(N=null)}function ue(e){if(!(e instanceof Error))return!1;let t=e.body,n=typeof t?.error==`object`?t.error.code:void 0;return n===`VOICE_DISABLED`||n===`PROVIDER_UNAVAILABLE`}function de(e){if(!Number.isFinite(e)||e<0)return`0:00`;let t=Math.floor(e%60);return`${Math.floor(e/60)}:${t.toString().padStart(2,`0`)}`}function fe(e){return e===`requesting`||e===`connecting`||e===`starting`}async function pe(){if(!navigator.permissions?.query)return null;try{return(await navigator.permissions.query({name:`microphone`})).state}catch{return null}}function me(e){return e instanceof DOMException||e instanceof Error?e.name:``}function he(e,t){if(e===`permission`)return`permission`;if(e===`recorder`)return`recorder`;if(e===`session`)return`session`;let n=me(t);return n===`NotAllowedError`||n===`SecurityError`?`permission`:`device`}function ge(e){let{disabled:t,chat:n,onTranscript:r}=e,[o,c]=(0,M.useState)(`idle`),[l,ee]=(0,M.useState)(!1),d=(0,M.useRef)(null),f=(0,M.useRef)(null),te=(0,M.useRef)(void 0),[p,ne]=(0,M.useState)(0),[_,v]=(0,M.useState)(0),[y,b]=(0,M.useState)(``),[x,S]=(0,M.useState)(``),[C,w]=(0,M.useState)(``),[T,E]=(0,M.useState)([]),[D,O]=(0,M.useState)(null),[k,N]=(0,M.useState)(`idle`),[ge,_e]=(0,M.useState)(null),[ve,ye]=(0,M.useState)(!1),P=(0,M.useRef)(!1),[F,I]=(0,M.useState)(null),[be,xe]=(0,M.useState)(null),[Se,Ce]=(0,M.useState)(!1),[we,Te]=(0,M.useState)(null),L=(0,M.useRef)(void 0),R=(0,M.useRef)(null),[Ee,De]=(0,M.useState)(`dictation`),Oe=(0,M.useRef)(Symbol(`voice-capture`)),z=(0,M.useRef)(`idle`),B=(0,M.useRef)(0),V=(0,M.useRef)(null),ke=(0,M.useRef)(null),H=(0,M.useRef)(null),Ae=(0,M.useRef)(void 0),je=(0,M.useRef)(void 0),U=(0,M.useRef)(null),Me=(0,M.useRef)(null),Ne=(0,M.useRef)(null),W=(0,M.useRef)(new Map),G=(0,M.useRef)(!1),Pe=(0,M.useRef)(()=>{}),Fe=(0,M.useRef)(new Map),K=(0,M.useRef)(null),Ie=(0,M.useRef)(null),Le=(0,M.useRef)(!1),Re=(0,M.useRef)(null),ze=(0,M.useRef)(!1),Be=(0,M.useRef)(0),Ve=(0,M.useRef)(6e5),He=(0,M.useRef)(null),q=(0,M.useRef)(null),Ue=(0,M.useRef)(r);Ue.current=r;let J=(0,M.useCallback)(e=>{z.current=e,c(e)},[]),Y=(0,M.useCallback)(()=>{He.current!=null&&(clearInterval(He.current),He.current=null)},[]),X=(0,M.useCallback)(()=>{Me.current?.getTracks().forEach(e=>e.stop()),Me.current=null},[]),Z=(0,M.useCallback)(()=>{le(Oe.current),B.current+=1,R.current?.abort(),R.current=null,Y(),q.current!==null&&clearTimeout(q.current),q.current=null,U.current?.stopRingback(),X(),d.current?.cancel(),d.current=null,f.current=null,te.current=void 0,ee(!1),V.current?.cancel(),V.current=null,ke.current=null,H.current=null;let e=U.current;U.current=null,e?.close(),Ne.current=null,ne(0),v(0),b(``),S(``),w(``),N(`idle`),_e(null),E([]),O(null),Re.current=null,P.current=!1,ye(!1),Ce(!1),Fe.current.clear(),W.current.clear(),G.current=!1,K.current=null,Ie.current=null},[X,Y]),Q=(0,M.useCallback)(()=>{Z(),J(`idle`)},[Z,J]),We=(0,M.useCallback)(()=>{H.current?.stop(`user_finished`),Q(),I(null),xe(null),Te(null)},[Q]),$=(0,M.useCallback)(async e=>{if(G.current)return;G.current=!0;let t=B.current,r=e??[...W.current.values()].join(` `).trim();if(X(),Y(),V.current?.cancel(),V.current=null,J(`transcribing`),!r){u(`warning`,n.voiceTranscribeEmpty),Q();return}let o=r;try{let e=await a(i(`/api/voice/transcriptions/refine`),{method:`POST`,body:JSON.stringify({text:r}),signal:AbortSignal.any([R.current.signal,AbortSignal.timeout(15e3)])});e.payload.text.trim()&&(o=e.payload.text)}catch{if(t!==B.current)return;u(`warning`,n.voiceRefinementFailed)}t===B.current&&(Ue.current(o),Q())},[Q,n.voiceRefinementFailed,n.voiceTranscribeEmpty,X,Y,J]),Ge=(0,M.useCallback)(async()=>{if(G.current)return;G.current=!0;let e=B.current;Y(),J(`transcribing`);try{let t=d.current;if(!f.current&&t){let n=await t.stop();if(e!==B.current)return;f.current=n}if(d.current=null,X(),e!==B.current)return;let r=f.current;if(!r)throw Error(n.voiceTranscribeEmpty);let i=await g(r,r.type,AbortSignal.any([R.current.signal,AbortSignal.timeout(9e4)]),te.current);if(e!==B.current)return;G.current=!1,await $(i.text.trim())}catch(t){if(e!==B.current)return;X(),G.current=!1,I(t instanceof Error?t.message:n.voiceTranscribeFailed),xe(`session`),J(`error`)}},[$,n.voiceTranscribeEmpty,n.voiceTranscribeFailed,X,Y,J]),Ke=(0,M.useCallback)(e=>{Te(e);let t=z.current;if(!(t===`idle`||t===`error`||G.current)){if(!L.current){if(t===`transcribing`&&e===`input_committed`){$();return}Y(),X(),V.current?.cancel(),V.current=null,H.current=null,I(n.voiceTranscribeFailed),J(`error`);return}Q()}},[$,Q,n.voiceTranscribeFailed,X,Y,J]),qe=(0,M.useCallback)(()=>{Y(),He.current=setInterval(()=>{let e=Ne.current;if(e===null)return;let t=performance.now()-e;if(ne(Math.max(0,t/1e3)),t>=Ve.current&&z.current===`recording`){if(!L.current){Pe.current();return}Te(`session_limit`),H.current?.stop(`user_finished`),Q()}},200)},[Q,Y]),Je=(0,M.useCallback)(async(e,r,i,a=!1)=>{if(t||z.current!==`idle`||e===`conversation`&&!i)return;if(!ce(Oe.current)){I(n.callCaptureBusy),e===`dictation`&&u(`error`,n.callCaptureBusy);return}L.current=i;let o=new AbortController;R.current=o,I(null),xe(null),Te(null);let c=++B.current,l=()=>c===B.current;De(e),_e(e===`conversation`?`preparing`:null),(!a||!Ae.current)&&(Ae.current=crypto.randomUUID()),je.current=r,w(``),J(`connecting`);let f=performance.now(),p=(e,t,n)=>A(e,o.signal,t,n),g=`permission`;try{if(e===`conversation`){g=`recorder`;let e=new ie;if(U.current=e,await p(e.start(),1e4),!l()){e.close();return}}g=`session`;let t=e===`dictation`?await p(oe(o.signal),2e4):null;if(!l())return;if(t?.mode===`unavailable`){let e=Error(n.voiceSttNotConfigured);throw Object.assign(e,{body:{error:{code:`PROVIDER_UNAVAILABLE`}}}),e}let c=t?.mode===`recorded`,f=c?[]:await p(se.preflight({purpose:e,...e===`conversation`?{mode:r,conversationId:i}:{},signal:o.signal}),2e4);if(!l())return;g=`permission`;let _=window.electronAPI?.system,y=await p(pe(),5e3);if(!l()||!fe(z.current))return;if(_&&y!==`granted`){J(`requesting`);let e=await p(_.requestMicrophone(),6e4);if(!l())return;let t=window.electronAPI?.platform===`darwin`&&e.status!==`granted`;if(e.status===`denied`||t)throw Error(`Microphone permission denied`)}else!_&&y!==`granted`&&J(`requesting`);if(!l()||!fe(z.current))return;J(`starting`),window.dispatchEvent(new Event(`xopc-voice-recording-start`)),g=`media`;let x=await p(navigator.mediaDevices.getUserMedia({audio:h()}),15e3,e=>e.getTracks().forEach(e=>e.stop()));if(!l()||!fe(z.current)){x.getTracks().forEach(e=>e.stop());return}if(Me.current=x,c){g=`recorder`;let e=await p(m.start(x,{onAudioLevel:({level:e})=>{l()&&v(Math.min(1,e*8))}}),15e3,e=>e.cancel());if(!l()){e.cancel();return}d.current=e,te.current=t.provider,ee(!0),Ve.current=6e5,Ne.current=performance.now(),ne(0),J(`recording`),qe();return}e===`conversation`&&(_e(`dialing`),U.current?.startRingback(),q.current=setTimeout(()=>{l()&&(U.current?.stopRingback(),_e(`slow`),q.current=null)},12e3)),g=`session`,J(`connecting`),W.current.clear();let C=await p(se.connect({timingMetrics:f,logicalCallId:Ae.current,recovery:a,language:s(),purpose:e,signal:o.signal,...e===`conversation`?{mode:r,conversationId:i}:{},onEvent:t=>{if(l()&&!((t.type===`input.transcript.delta`||t.type===`input.transcript.final`)&&!j(Fe.current,t.payload.utteranceId,t.payload.revision,t.type===`input.transcript.final`))){if(t.type===`input.transcript.delta`&&b(t.payload.text),t.type===`input.transcript.final`){let n=t.payload.text.trim();b(``),S(n),n&&e===`dictation`&&(W.current.set(t.payload.utteranceId,n),[...W.current.values()].join(` `).length>=2e4&&z.current===`recording`&&Pe.current(),S([...W.current.values()].join(` `)))}if(t.type===`input.speech_stopped`&&(Re.current=performance.now()),t.type===`response.created`){if(K.current){K.current!==t.payload.responseId&&H.current?.cancelResponse(t.payload.responseId);return}K.current=t.payload.responseId,Le.current=!1,ze.current=!1,Be.current=0,w(``),E([]),O(null),N(`thinking`)}if(t.type===`task.created`&&K.current===t.payload.responseId&&(Ie.current=t.payload.taskId),t.type===`task.activity`&&Ie.current===t.payload.taskId){let e={toolCallId:t.payload.toolCallId,toolName:t.payload.toolName,status:t.payload.status};E(t=>[...t.filter(t=>t.toolCallId!==e.toolCallId),e].slice(-8))}if(t.type===`task.done`&&Ie.current===t.payload.taskId&&(Ie.current=null,E([])),t.type===`response.clarification`&&K.current===t.payload.responseId&&O(t.payload),t.type===`response.text.delta`&&K.current===t.payload.responseId&&(N(`speaking`),w(e=>e+t.payload.delta)),t.type===`response.audio.started`&&K.current===t.payload.responseId&&N(`speaking`),t.type===`response.done`&&K.current===t.payload.responseId&&(Le.current=!0,U.current?.hasPendingAudio||(K.current=null,N(`idle`))),t.type===`response.cancelled`&&K.current===t.payload.responseId&&(K.current=null,N(`idle`),U.current?.clear()),t.type===`session.error`&&t.payload.recoverable&&t.payload.code===`RESPONSE_FAILED`&&u(`warning`,n.voiceResponseFailed),t.type===`session.error`&&t.payload.recoverable&&t.payload.code===`INPUT_DROPPED`&&u(`warning`,n.voiceInputDropped),t.type===`session.error`&&!t.payload.recoverable){let r=t.payload.code===`PROVIDER_UNAVAILABLE`,i=t.payload.code===`CONTEXT_CHANGED`?n.voiceContextChanged:r?n.voiceSttNotConfigured:t.payload.message;I(i),xe(`session`),Ce(r),e===`dictation`&&u(`error`,i,void 0,r?{href:`/settings/capabilities/models?configure=transcription`}:void 0),H.current?.stop(`surface_closed`),e===`conversation`?Z():(Y(),X(),V.current?.cancel(),V.current=null,H.current=null),J(`error`)}}},onAudio:(e,t)=>{if(!l())return;let n=K.current;if(!n||t!==n)return;let r=!ze.current,i=Re.current;r&&(ze.current=!0,Re.current!==null&&H.current?.reportMetric(n,`speech_end_to_audio_received`,performance.now()-Re.current),Re.current=null);let a=U.current?.enqueue(e,()=>{K.current===n&&(Be.current+=e.byteLength,H.current?.acknowledgeAudio(n,Be.current),Le.current&&!U.current?.hasPendingAudio&&(K.current=null,N(`idle`)))});r&&i!==null&&a!==void 0&&H.current?.reportMetric(n,`speech_end_to_audio_scheduled`,performance.now()-i+a)},onClose:e=>{l()&&Ke(e)}}),2e4,e=>e.stop(`surface_closed`));if(!l()){C.stop(`surface_closed`);return}U.current?.stopRingback(),q.current!==null&&clearTimeout(q.current),q.current=null,H.current=C,Ve.current=C.session.limits.maxSessionMs,g=`recorder`,J(`starting`);let T,D=[],k=await p(ae.start(x,{onSamples:e=>{if(!l()||P.current)return;if(!T){D.push(e);return}let t=(ke.current??T).push(e);t&&C.sendAudio(t)},onAudioLevel:({level:e})=>{l()&&(P.current||v(Math.min(1,e*8)))}}),15e3,e=>e.cancel());if(!l()||!fe(z.current)){k.cancel(),C.stop(`surface_closed`),x.getTracks().forEach(e=>e.stop());return}if(V.current=k,e===`conversation`&&(await p(U.current.start(),1e4),!l()))return;C.outputReady(),T=new re(k.sampleRate,C.session.inputFormat.sampleRate),ke.current=T;for(let e of D)C.sendAudio(T.push(e));Ne.current=performance.now(),ne(0),J(`recording`),_e(null),qe()}catch(t){if(!l())return;let r=he(g,t);console.error(`[chat:voice] realtime capture start failed`,{stage:g,durationMs:Math.round(performance.now()-f),kind:r,errorName:me(t),errorMessage:t instanceof Error?t.message:String(t)}),H.current?.stop(`surface_closed`),Z(),J(r===`session`?`error`:`idle`);let i=r===`session`&&ue(t),a=me(t)===`TimeoutError`?g===`session`?n.voiceConnectionTimeout:n.voiceMicrophoneTimeout:r===`permission`?n.voiceMicDenied:r===`device`?n.voiceMicUnavailable:r===`recorder`?n.voiceRecorderFailed:i?n.voiceSttNotConfigured:t instanceof Error?t.message:n.voiceSttNotConfigured;I(a),xe(r),Ce(i),e===`dictation`&&u(`error`,a,void 0,i?{href:`/settings/capabilities/models?configure=transcription`}:void 0)}},[t,Ke,n,Z,qe,X,Y,J]),Ye=(0,M.useCallback)(()=>{if(L.current)return;if(d.current||f.current){Ge();return}if(z.current===`error`&&W.current.size){$();return}if(z.current!==`recording`)return;J(`transcribing`),Y(),X();let e=V.current,t=B.current;V.current=null,e?.stop().then(()=>{if(t!==B.current)return;let e=ke.current?.flush();e&&H.current?.sendAudio(e),H.current?.commit()}).catch(()=>{t===B.current&&(u(`error`,n.voiceTranscribeFailed),H.current?.stop(`surface_closed`),Z(),J(`error`))})},[$,Ge,n.voiceTranscribeFailed,Z,X,Y,J]);Pe.current=Ye,(0,M.useEffect)(()=>()=>{le(Oe.current),B.current+=1,R.current?.abort(),d.current?.cancel(),f.current=null,V.current?.cancel(),H.current?.stop(`surface_closed`),U.current?.close(),q.current!==null&&clearTimeout(q.current),X(),Y()},[X,Y]);let Xe=(0,M.useCallback)(()=>{if(z.current===`error`){if(f.current){Ge();return}Z(),J(`idle`),Je(Ee,je.current,L.current,!0)}},[Je,Ge,Ee,Z,J]),Ze=(0,M.useCallback)(()=>Je(`dictation`),[Je]),Qe=(0,M.useCallback)((e,t)=>Je(`conversation`,t,e),[Je]),$e=(0,M.useCallback)(()=>{let e=performance.now(),t=K.current;U.current?.clear(),K.current=null,N(`idle`),t&&(H.current?.reportMetric(t,`local_stop`,performance.now()-e),H.current?.cancelResponse(t))},[]),et=(0,M.useCallback)(()=>{let e=!P.current;P.current=e,Me.current?.getAudioTracks().forEach(t=>{t.enabled=!e});let t=V.current,n=H.current;t&&n&&(ke.current=new re(t.sampleRate,n.session.inputFormat.sampleRate)),n?.setInputMuted(e),b(``),v(0),U.current?.duck(!1),ye(e)},[]);return{phase:o,voiceActive:o!==`idle`,recordedDictation:l,elapsedLabel:de(p),audioLevel:_,partialTranscript:y,finalTranscript:x,responseText:C,activities:T,clarification:D,dismissClarification:e=>O(t=>t?.requestId===e?null:t),responsePhase:k,callConnectionStage:ge,muted:ve,error:F,failureKind:be,settingsRequired:Se,endedReason:we,mode:Ee,startVoiceInput:Ze,startVoiceConversation:Qe,interruptResponse:$e,toggleMute:et,cancelVoiceInput:We,confirmVoiceInput:Ye,retryVoiceInput:Xe}}var _e=o(e=>({path:null,line:null,projectId:null,conversationId:null,setPath:(t,n,r,i,a)=>{if(t){let e=v.getState().scope;v.getState().openFile({path:t,line:n,projectId:r||void 0,conversationId:i||(e===`new`?void 0:e),agentId:x.getState().agentId||void 0,resultRevision:a})}e({path:t,resultRevision:t?a:void 0,line:t&&typeof n==`number`&&Number.isFinite(n)&&n>0?Math.floor(n):null,projectId:t&&r?.trim()||null,conversationId:t&&i?.trim()||null})}}));function ve(e){return`${e.name}\0${e.size}`}function ye(e){if(!e)return[];let t=new Set,n=[],r=e=>{if(!e||e.size===0)return;let r=ve(e);t.has(r)||(t.add(r),n.push(e))},{files:i}=e;if(i?.length)for(let e=0;e<i.length;e++)r(i.item(e));for(let t of Array.from(e.items??[]))t.kind===`file`&&r(t.getAsFile());return n}var P=n(),F=r();function I(e){let t=(0,P.c)(10),{disabled:n,chat:r,onStart:i}=e,a=S(be),o=r.voiceInput,s;t[0]===a?s=t[1]:(s=C(a).join(`+`),t[0]=a,t[1]=s);let c=`${o} (${s})`,l;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(l=p(`relative inline-flex size-11 sm:size-8 shrink-0 items-center justify-center rounded-lg border border-transparent text-fg-subtle hover:bg-surface-hover hover:text-fg`,b.transition,b.press,b.focusRingPanel,`disabled:cursor-not-allowed disabled:opacity-50`),t[2]=l):l=t[2];let u;t[3]===i?u=t[4]:(u=()=>void i(),t[3]=i,t[4]=u);let d;t[5]===Symbol.for(`react.memo_cache_sentinel`)?(d=(0,F.jsx)(ee,{className:`size-4 stroke-[1.75]`}),t[5]=d):d=t[5];let f;return t[6]!==n||t[7]!==u||t[8]!==c?(f=(0,F.jsx)(`button`,{type:`button`,className:l,disabled:n,title:c,"aria-label":c,onClick:u,children:d}),t[6]=n,t[7]=u,t[8]=c,t[9]=f):f=t[9],f}function be(e){return e.shortcut}function xe(e,t){let n=t.trim();if(!n)return e;let r=e.trim();return r?`${r} ${n}`:n}var Se=p(`inline-flex min-h-11 min-w-11 shrink-0 gap-2 px-3 items-center justify-center rounded-lg text-fg-muted`,`hover:bg-surface-hover hover:text-fg`,b.transition,b.press,b.focusRingPanel,`disabled:cursor-not-allowed disabled:opacity-50`),Ce=(0,M.memo)(function(e){let t=(0,P.c)(47),{phase:n,elapsedLabel:r,recordedDictation:i,audioLevel:a,partialTranscript:o,finalTranscript:s,error:u,settingsRequired:ee,disabled:m,chat:h,onCancel:re,onConfirm:ie,onRetry:g}=e,ae=n===`transcribing`,oe=n===`requesting`,se=n===`connecting`,_=n===`starting`,v=n===`error`,y=v?u||h.voiceTranscribeFailed:oe?h.voiceRequestingMicrophone:se?h.voiceConnectingService:_?h.voiceStartingMicrophone:ae?h.voiceTranscribing:i?h.voiceRecordedDictationStatus:h.voiceRecordingStatus,b;t[0]!==s||t[1]!==o?(b=[s,o].filter(Boolean),t[0]=s,t[1]=o,t[2]=b):b=t[2];let x=b.join(` `),S=oe||se||_||ae,C;t[3]!==a||t[4]!==v||t[5]!==n?(C=n===`recording`?(0,F.jsx)(`div`,{className:`flex h-5 shrink-0 items-center gap-0.5`,"aria-hidden":!0,children:Array.from({length:9},(e,t)=>{let n=.35+(t%4+1)*.16;return(0,F.jsx)(`span`,{className:`w-0.5 rounded-full bg-fg-muted motion-safe:transition-[height] motion-safe:duration-75`,style:{height:Math.max(3,Math.round(18*Math.min(1,a*n+.08)))}},t)})}):v?(0,F.jsx)(l,{className:`size-4 shrink-0 text-danger`,"aria-hidden":!0}):(0,F.jsx)(ne,{className:`h-4 w-8`}),t[3]=a,t[4]=v,t[5]=n,t[6]=C):C=t[6];let w=v?`alert`:`status`,T;t[7]!==y||t[8]!==w?(T=(0,F.jsx)(`p`,{className:`min-w-0 flex-1 break-words text-sm text-fg-muted`,role:w,children:y}),t[7]=y,t[8]=w,t[9]=T):T=t[9];let E;t[10]!==r||t[11]!==n?(E=n===`recording`?(0,F.jsx)(`span`,{className:`shrink-0 text-sm tabular-nums text-fg-muted`,children:r}):null,t[10]=r,t[11]=n,t[12]=E):E=t[12];let D;t[13]!==C||t[14]!==T||t[15]!==E?(D=(0,F.jsxs)(`div`,{className:`flex items-center gap-3 px-1`,children:[C,T,E]}),t[13]=C,t[14]=T,t[15]=E,t[16]=D):D=t[16];let O;t[17]===x?O=t[18]:(O=x?(0,F.jsx)(`p`,{className:`max-h-28 overflow-y-auto overscroll-contain whitespace-pre-wrap break-words px-1 text-base text-fg`,children:x}):null,t[17]=x,t[18]=O);let k;t[19]===Symbol.for(`react.memo_cache_sentinel`)?(k=(0,F.jsx)(te,{className:`size-4`,"aria-hidden":!0}),t[19]=k):k=t[19];let A;t[20]!==h.voiceInputCancel||t[21]!==re?(A=(0,F.jsxs)(`button`,{type:`button`,className:Se,title:h.voiceInputCancel,"aria-label":h.voiceInputCancel,onClick:re,children:[k,h.voiceInputCancel]}),t[20]=h.voiceInputCancel,t[21]=re,t[22]=A):A=t[22];let j;t[23]!==m||t[24]!==v||t[25]!==h.voiceOpenSettings||t[26]!==h.voiceRetry||t[27]!==g||t[28]!==ee?(j=v&&ee?(0,F.jsxs)(`a`,{onClick:we,href:`#/settings/capabilities/models?configure=transcription`,className:p(Se,`text-accent-fg`),children:[(0,F.jsx)(f,{className:`size-4`,"aria-hidden":!0}),h.voiceOpenSettings]}):v?(0,F.jsxs)(`button`,{type:`button`,className:Se,disabled:m,"aria-label":h.voiceRetry,onClick:g,children:[(0,F.jsx)(d,{className:`size-4`,"aria-hidden":!0}),h.voiceRetry]}):null,t[23]=m,t[24]=v,t[25]=h.voiceOpenSettings,t[26]=h.voiceRetry,t[27]=g,t[28]=ee,t[29]=j):j=t[29];let M;t[30]!==m||t[31]!==v||t[32]!==s||t[33]!==h.voiceInputConfirm||t[34]!==ie||t[35]!==n?(M=n===`recording`||v&&s?(0,F.jsxs)(`button`,{type:`button`,className:p(Se,`rounded-full bg-accent text-on-accent hover:bg-accent-hover hover:text-on-accent`),disabled:m,"aria-label":h.voiceInputConfirm,onClick:ie,children:[(0,F.jsx)(c,{className:`size-4`,"aria-hidden":!0}),h.voiceInputConfirm]}):null,t[30]=m,t[31]=v,t[32]=s,t[33]=h.voiceInputConfirm,t[34]=ie,t[35]=n,t[36]=M):M=t[36];let N;t[37]!==A||t[38]!==j||t[39]!==M?(N=(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[A,j,M]}),t[37]=A,t[38]=j,t[39]=M,t[40]=N):N=t[40];let ce;return t[41]!==h.voiceInput||t[42]!==N||t[43]!==S||t[44]!==D||t[45]!==O?(ce=(0,F.jsxs)(`section`,{className:`w-full space-y-3 py-3`,"aria-label":h.voiceInput,"aria-busy":S,children:[D,O,N]}),t[41]=h.voiceInput,t[42]=N,t[43]=S,t[44]=D,t[45]=O,t[46]=ce):ce=t[46],ce});function we(e){!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&e.button===0&&(e.preventDefault(),y(`transcription`))}var Te=120*1e3,L=new Map;function R(){return typeof globalThis.crypto?.randomUUID==`function`?globalThis.crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function Ee(e){for(let[t,n]of L)n.expiresAt<=e&&L.delete(t)}function De(e,t=Date.now()){Ee(t);let n=R();return L.set(n,{attachments:e.map(e=>({...e})),expiresAt:t+Te}),n}function Oe(e,t=Date.now()){let n=L.get(e);if(!n)return null;if(n.expiresAt<=t)return L.delete(e),null;if(!n.attachments)return null;let r=n.attachments;return n.attachments=null,r}export{I as a,ge as c,k as d,T as f,E as g,w as h,xe as i,ce as l,O as m,Oe as n,ye as o,D as p,Ce as r,_e as s,De as t,le as u};
@@ -1 +0,0 @@
1
- import{p as e}from"./locale-store-CQcW9_qA.js";var t=e(()=>({connectionState:`idle`,error:null}));function n(e){t.setState(e)}export{t as n,n as t};