@mycadet/web 0.12.6-dev.202610091338.ee7f3e3 → 0.12.7

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 (210) hide show
  1. package/dist/assets/{a2a-invite-CNXsaRKK.js → a2a-invite-Dy_-_EJu.js} +1 -1
  2. package/dist/assets/{about-page-DXdpRqxm.js → about-page-BIJfjthi.js} +1 -1
  3. package/dist/assets/{account-page-CMTnLl7a.js → account-page-BGhpxkdO.js} +1 -1
  4. package/dist/assets/{account-shell-DoEhthHd.js → account-shell-C16ZEkR-.js} +1 -1
  5. package/dist/assets/{acp-run-detail-panel-DMW_KvFq.js → acp-run-detail-panel-LJIVIPVX.js} +1 -1
  6. package/dist/assets/{activation-list-route-ilkp0KUt.js → activation-list-route-DsNAUaWs.js} +1 -1
  7. package/dist/assets/{activity-redirect-page-CRn7aUXA.js → activity-redirect-page-DgjUj4JW.js} +1 -1
  8. package/dist/assets/{activity-steps-panel-B7wgfnQK.js → activity-steps-panel-BJsU5yRo.js} +1 -1
  9. package/dist/assets/add-credits-modal-BbRv34X8.js +1 -0
  10. package/dist/assets/{add-credits-modal-CaPldEPl.js → add-credits-modal-VxmEbPrZ.js} +1 -1
  11. package/dist/assets/{ai-page-BGC2HFRf.js → ai-page-CXPC9t0F.js} +1 -1
  12. package/dist/assets/{all-chats-page-route-BA2TDOnE.js → all-chats-page-route-CXfMd547.js} +1 -1
  13. package/dist/assets/{android-billing-handoff-BIE4-ZmX.js → android-billing-handoff-C7UYsPiM.js} +1 -1
  14. package/dist/assets/{animated-stat-square-CWpBP3Ub.js → animated-stat-square-DMsQUXPs.js} +1 -1
  15. package/dist/assets/{api-key-screen-B6XxCENo.js → api-key-screen-C6g7k9c2.js} +1 -1
  16. package/dist/assets/{app-CGtZI7qK.js → app-CPkqAi_4.js} +47 -47
  17. package/dist/assets/{app-info-DURJWXun.js → app-info-CLuEVQl-.js} +1 -1
  18. package/dist/assets/{archive-redirect-page-p87UQQpd.js → archive-redirect-page-BipIW_n7.js} +1 -1
  19. package/dist/assets/{assistant-handle-modal-j7ovsxaf.js → assistant-handle-modal-BkIX52b6.js} +1 -1
  20. package/dist/assets/{assistant-inbox-page-route-KXQx8Jj0.js → assistant-inbox-page-route-gy60plfi.js} +1 -1
  21. package/dist/assets/{assistant-status-panel-DKlo-WTD.js → assistant-status-panel-C8N9hzMO.js} +1 -1
  22. package/dist/assets/auth-store-c6dqzt4x.js +1 -0
  23. package/dist/assets/{auth-welcome-screen-8JX9NEp6.js → auth-welcome-screen-B8aQmTIq.js} +1 -1
  24. package/dist/assets/avatar-bundled-components-C7heB9xP.js +1 -0
  25. package/dist/assets/{avatar-random-SN3LzzDK.js → avatar-random-B8fJqzb-.js} +2 -2
  26. package/dist/assets/{await-org-header-settled-CNMfAkiM.js → await-org-header-settled-DJeX3ijn.js} +1 -1
  27. package/dist/assets/{background-task-detail-panel-DnXWTbUf.js → background-task-detail-panel-Cu72J5mx.js} +1 -1
  28. package/dist/assets/{billing-page-DC8cYLZi.js → billing-page-CgQpnTUo.js} +3 -3
  29. package/dist/assets/{billing-redirect-page-BnpxAqZ-.js → billing-redirect-page-DYXZdQ52.js} +1 -1
  30. package/dist/assets/{bookmarks-page-BKHCV3mG.js → bookmarks-page-pO4mLMfc.js} +1 -1
  31. package/dist/assets/{bundle-confirm-page-Cu0o0kxA.js → bundle-confirm-page-CImMlQsd.js} +1 -1
  32. package/dist/assets/camera-capture-overlay-CzsGEOve.js +1 -0
  33. package/dist/assets/{channel-transcript-panel-DBBxwKep.js → channel-transcript-panel-DaBGSuMi.js} +1 -1
  34. package/dist/assets/{channels-page-route-BJpL2HsG.js → channels-page-route-DNtLd_hv.js} +1 -1
  35. package/dist/assets/{chat-info-panel-B1eQXeGu.js → chat-info-panel-Cp0StHk_.js} +1 -1
  36. package/dist/assets/{checkout-continuation-Cx0o8fdh.js → checkout-continuation-C165OlOR.js} +1 -1
  37. package/dist/assets/{checkout-page-BAzv4kTR.js → checkout-page-Cl3gKX5M.js} +1 -1
  38. package/dist/assets/checkout-return-target-BskCWo4q.js +1 -0
  39. package/dist/assets/{command-palette-Cq22ekgU.js → command-palette-C5-1ScXi.js} +1 -1
  40. package/dist/assets/command-palette-DQxkn194.js +1 -0
  41. package/dist/assets/{command-palette-window-page-BvjoItY2.js → command-palette-window-page-Bm2eduH2.js} +1 -1
  42. package/dist/assets/{community-page-4umrRkeg.js → community-page-D4gW9H0b.js} +1 -1
  43. package/dist/assets/{companion-accent-BU7alKxo.js → companion-accent-DeN7YIfl.js} +1 -1
  44. package/dist/assets/{companion-dock-zones-page-BUqvOj4q.js → companion-dock-zones-page-CC3en_w0.js} +1 -1
  45. package/dist/assets/{companion-layout-BTU_6dHM.js → companion-layout-C4onEUYK.js} +1 -1
  46. package/dist/assets/{companion-popover-BwNjNeIR.js → companion-popover-BY9dsTkK.js} +1 -1
  47. package/dist/assets/{companion-popover-page-DP882nXD.js → companion-popover-page-DtttiULS.js} +1 -1
  48. package/dist/assets/{companion-surface-page-93R7NOXh.js → companion-surface-page-DqFzY5ai.js} +1 -1
  49. package/dist/assets/{companion-surface-DWGMiINv.js → companion-surface-s_z14fFe.js} +1 -1
  50. package/dist/assets/{companion-tour-entry-B5qpNaIX.js → companion-tour-entry-DMe04oGv.js} +1 -1
  51. package/dist/assets/{companion-watch-frame-page-DpwcsDzY.js → companion-watch-frame-page-Vyo7Qhrs.js} +1 -1
  52. package/dist/assets/{connect-page-NhT5tt4k.js → connect-page-Bqqeu7px.js} +1 -1
  53. package/dist/assets/{consent-controls-C980zz_r.js → consent-controls-ChXAokI4.js} +1 -1
  54. package/dist/assets/{contacts-gateway-b1LvYjKN.js → contacts-gateway-CjXsMIf5.js} +1 -1
  55. package/dist/assets/{contacts-page-route-WEDGq-m7.js → contacts-page-route-jhQ6zm79.js} +1 -1
  56. package/dist/assets/{copy-button-Bh_aV8el.js → copy-button-VtuhId4f.js} +1 -1
  57. package/dist/assets/{credential-entry-page-Cy1nvNBA.js → credential-entry-page-CSMf6-gH.js} +1 -1
  58. package/dist/assets/{credentials-page-Bbjah2O8.js → credentials-page-CFEC74Wl.js} +1 -1
  59. package/dist/assets/{csv-preview-JYk9XSmH.js → csv-preview-BYaPBX5Y.js} +1 -1
  60. package/dist/assets/{danger-zone-redirect-page-BMu3-qAj.js → danger-zone-redirect-page-nDGkxOH5.js} +1 -1
  61. package/dist/assets/{debug-page-D-4Y7tg-.js → debug-page-BgsSPZYq.js} +1 -1
  62. package/dist/assets/deploy-dialogs-CGCI-YQR.js +1 -0
  63. package/dist/assets/{deploy-dialogs-DB-_b3g2.js → deploy-dialogs-TtlGsmui.js} +1 -1
  64. package/dist/assets/{desktop-preview-content-K--CBLS-.js → desktop-preview-content-0PPPJXKb.js} +2 -2
  65. package/dist/assets/{desktop-status-DgJpZMAx.js → desktop-status-LMVnpw_i.js} +1 -1
  66. package/dist/assets/{desktop-viewer-CAdtrfvv.js → desktop-viewer-BvmmSS3q.js} +1 -1
  67. package/dist/assets/{detail-card-BL0RLDjz.js → detail-card-6rKFaFAS.js} +1 -1
  68. package/dist/assets/{detail-panel-stop-button-DLTLV0lw.js → detail-panel-stop-button-EtbIbCMU.js} +1 -1
  69. package/dist/assets/{detail-primitives-BZtYI-6o.js → detail-primitives-DYFVgm7V.js} +1 -1
  70. package/dist/assets/{developer-page-y3tqWZyc.js → developer-page-DvF8-ZqQ.js} +1 -1
  71. package/dist/assets/{devices-redirect-page-BiOYVLEE.js → devices-redirect-page-DPj7rsiz.js} +1 -1
  72. package/dist/assets/{dictation-overlay-page-ZVIjuxv7.js → dictation-overlay-page-Dk4SF30D.js} +1 -1
  73. package/dist/assets/{document-load-5s1-0Jtn.js → document-load-Dg7AFxco.js} +1 -1
  74. package/dist/assets/document-load-bHqC_QnQ.js +1 -0
  75. package/dist/assets/{document-viewer-page-BHzYluA4.js → document-viewer-page-02YOTCJb.js} +1 -1
  76. package/dist/assets/{emails-page-CNToGUZz.js → emails-page-CdWuX5e8.js} +1 -1
  77. package/dist/assets/{file-diff-view-Cmqq4-xy.js → file-diff-view-DMPBN50t.js} +1 -1
  78. package/dist/assets/{file-view-mode-DaBoP_wV.js → file-view-mode-Cjq3b9c7.js} +1 -1
  79. package/dist/assets/{general-page-B8eweQky.js → general-page-B3LWDnII.js} +1 -1
  80. package/dist/assets/{hatching-screen-DkAQrsbw.js → hatching-screen-Bz1rVnuU.js} +1 -1
  81. package/dist/assets/{hosting-screen-BpDvFSvR.js → hosting-screen-DjelWQN4.js} +1 -1
  82. package/dist/assets/{identity-page-route-B4DNQx38.js → identity-page-route-Bfit3ZAL.js} +1 -1
  83. package/dist/assets/{inspect-page-CAXu8K0A.js → inspect-page-DrzPnXTu.js} +3 -3
  84. package/dist/assets/{integrations-page-DhJEfC7u.js → integrations-page-D1jUq3jA.js} +1 -1
  85. package/dist/assets/{intelligence-layout-BqFqDsjN.js → intelligence-layout-D-ux-wB-.js} +1 -1
  86. package/dist/assets/{intelligence-layout-slots-store-CkjZiDAc.js → intelligence-layout-slots-store-CG-bJbCv.js} +1 -1
  87. package/dist/assets/{keyboard-shortcuts-redirect-page-iXjx_VKU.js → keyboard-shortcuts-redirect-page-Hc4YzlJe.js} +1 -1
  88. package/dist/assets/{latest-assistant-text-CMBlgmFH.js → latest-assistant-text-NX8b-PTU.js} +1 -1
  89. package/dist/assets/{library-detail-page-BDLkXOWr.js → library-detail-page-ydt47xy5.js} +1 -1
  90. package/dist/assets/{library-page-Duss3lUZ.js → library-page-CuR1I6_u.js} +1 -1
  91. package/dist/assets/local-mode-jIpWvO_O.js +1 -0
  92. package/dist/assets/{login-page-DGrBKgj2.js → login-page-BDZCTowZ.js} +1 -1
  93. package/dist/assets/{logout-page-Ce-GjYO2.js → logout-page-C92xzZ-e.js} +1 -1
  94. package/dist/assets/{logs-layout-Cx02x4Gw.js → logs-layout-P9r4D1NB.js} +1 -1
  95. package/dist/assets/{managed-export-Chsl049Z.js → managed-export-gcnDno7p.js} +1 -1
  96. package/dist/assets/{markdown-preview-C4VdI_oZ.js → markdown-preview-DZxeW7zP.js} +1 -1
  97. package/dist/assets/{media-preview-DrUC2tce.js → media-preview-XLlQ1U25.js} +1 -1
  98. package/dist/assets/{memory-page-route-BSxWjq8o.js → memory-page-route-BSnGfHWx.js} +1 -1
  99. package/dist/assets/{memory-router-playground-page-Ct5aIwFg.js → memory-router-playground-page-DdqpfMXX.js} +1 -1
  100. package/dist/assets/{message-files-panel-CBH1NJ9k.js → message-files-panel-HmSeOj-c.js} +1 -1
  101. package/dist/assets/mutation-error-B0xRAwtR.js +1 -0
  102. package/dist/assets/native-attachment-pickers-BCXzpwWi.js +1 -0
  103. package/dist/assets/native-file-sedyTNMI.js +1 -0
  104. package/dist/assets/{notifications-page-CrdqLZfC.js → notifications-page-BTVuLqLX.js} +1 -1
  105. package/dist/assets/{oauth-complete-page-DFiTmire.js → oauth-complete-page-B1U_lIbS.js} +1 -1
  106. package/dist/assets/{oauth-popup-complete-page-QXmDSzIx.js → oauth-popup-complete-page-CKl1xiuA.js} +1 -1
  107. package/dist/assets/paired-platform-identity-DVaKRZrM.js +1 -0
  108. package/dist/assets/{pairing-page-DvGpsRJ7.js → pairing-page-CRV8b0I5.js} +1 -1
  109. package/dist/assets/password-reset-page-BWEjhNyR.js +1 -0
  110. package/dist/assets/{pdf-file-preview-BNXvA76K.js → pdf-file-preview-BjwxYlB0.js} +1 -1
  111. package/dist/assets/{permission-guide-page-BrAvVjoH.js → permission-guide-page-CNoNoSR3.js} +1 -1
  112. package/dist/assets/{permission-setup-ogDRfov4.js → permission-setup-aNFAgq7H.js} +1 -1
  113. package/dist/assets/{personality-page-DCiwmPMH.js → personality-page-BJ0W1gTK.js} +1 -1
  114. package/dist/assets/{personality-page-BfkvH85g.js → personality-page-BTQWpq-E.js} +1 -1
  115. package/dist/assets/{personality-sliders-D3lTC3MT.js → personality-sliders-ZBDf-Baw.js} +1 -1
  116. package/dist/assets/{plans-page-KhgLRnZE.js → plans-page-hRm6v6LW.js} +1 -1
  117. package/dist/assets/{platform-loopback-page-BBSNoFM3.js → platform-loopback-page-DZ6HYIt6.js} +1 -1
  118. package/dist/assets/{plugin-detail-page-BPkKAOP3.js → plugin-detail-page-C7Nvkx9h.js} +1 -1
  119. package/dist/assets/{plugins-page-CC4bMb9r.js → plugins-page-D0PHx5_k.js} +1 -1
  120. package/dist/assets/plugins-surface-DlAulnxS.js +1 -0
  121. package/dist/assets/{preview-error-CivpxMQV.js → preview-error-BVZTE_Gq.js} +1 -1
  122. package/dist/assets/{privacy-page-ma0qp69u.js → privacy-page-CENU2Slx.js} +1 -1
  123. package/dist/assets/{privacy-screen-CK1lwqaO.js → privacy-screen-BhfsBIN1.js} +1 -1
  124. package/dist/assets/{profile-card-DM_tYYcS.js → profile-card-CS9g1deW.js} +1 -1
  125. package/dist/assets/{provider-callback-page-Dbe049Vs.js → provider-callback-page-C2Tcz390.js} +1 -1
  126. package/dist/assets/{provider-key-DbbpecwI.js → provider-key-ac0GCyQW.js} +1 -1
  127. package/dist/assets/{provider-signup-page-Dekfr50O.js → provider-signup-page-DGmdVrLa.js} +1 -1
  128. package/dist/assets/{quick-input-page-CmMcu8o7.js → quick-input-page-C4Iw_XJg.js} +1 -1
  129. package/dist/assets/{research-mock-page-Cw0pH_kL.js → research-mock-page-BnPVD3II.js} +1 -1
  130. package/dist/assets/{research-onboarding-route-CIzTALgH.js → research-onboarding-route-BzkZiS-h.js} +1 -1
  131. package/dist/assets/{review-terms-screen-mXZuoqSN.js → review-terms-screen-FqiYdY0P.js} +1 -1
  132. package/dist/assets/routes-DmeNA6If.js +1 -0
  133. package/dist/assets/{schedules-BzC-XvXW.js → schedules-_0jiWipo.js} +1 -1
  134. package/dist/assets/{schedules-page-D7GV0Owu.js → schedules-page-YYRCjsPX.js} +1 -1
  135. package/dist/assets/{security-redirect-page-BNtlg8vN.js → security-redirect-page-DrztWSNp.js} +1 -1
  136. package/dist/assets/{select-assistant-screen-nIqhJyu4.js → select-assistant-screen-CHRyv7xW.js} +1 -1
  137. package/dist/assets/{self-hosted-servers-BNpgXQqK.js → self-hosted-servers-BfhtAs6X.js} +1 -1
  138. package/dist/assets/{service-form-controls-Bf_KfPWP.js → service-form-controls-DEbGvmzt.js} +1 -1
  139. package/dist/assets/{setting-row-Dv0Ku9Wo.js → setting-row-BP3qssay.js} +1 -1
  140. package/dist/assets/{settings-divider-BjBGnE5r.js → settings-divider-B756HDoF.js} +1 -1
  141. package/dist/assets/{settings-layout-DxHqLVuz.js → settings-layout-Br7UDHeY.js} +1 -1
  142. package/dist/assets/share-feedback-modal-D0yLvDE-.js +1 -0
  143. package/dist/assets/{share-feedback-modal-Kous0Rq4.js → share-feedback-modal-D3cwFoqQ.js} +1 -1
  144. package/dist/assets/{sidebar-tree-BjFCzK-f.js → sidebar-tree-HQg9GmqO.js} +1 -1
  145. package/dist/assets/{signup-page-BYIdVK4U.js → signup-page-CugeXM02.js} +1 -1
  146. package/dist/assets/{signup-shell-CDMHsPj9.js → signup-shell-ys4gi58w.js} +1 -1
  147. package/dist/assets/{skill-detail-page-DVrz_O1R.js → skill-detail-page-DBAq5Bn0.js} +1 -1
  148. package/dist/assets/{skill-detail-panel-BqTSgPWR.js → skill-detail-panel-Drwq4W_A.js} +1 -1
  149. package/dist/assets/{skill-removal-dialog-DpLUsPUk.js → skill-removal-dialog-1pTs7_fK.js} +1 -1
  150. package/dist/assets/{skills-page-D7TeEKkM.js → skills-page-ByRkByh4.js} +1 -1
  151. package/dist/assets/{sounds-page-DkS94WdH.js → sounds-page-BqH9NcU1.js} +1 -1
  152. package/dist/assets/{start-screen-D9I17ne4.js → start-screen-QdPolVqs.js} +1 -1
  153. package/dist/assets/{step-detail-header-DUYVhdE0.js → step-detail-header-BuPH_i5-.js} +1 -1
  154. package/dist/assets/{stt-language-picker-modal-DLBjdKim.js → stt-language-picker-modal-DBimk9bU.js} +1 -1
  155. package/dist/assets/{subagent-detail-panel-Vbn2RB6X.js → subagent-detail-panel-DBV1nIEq.js} +1 -1
  156. package/dist/assets/{superpowers-page--1b81T_S.js → superpowers-page-Cyjc104e.js} +1 -1
  157. package/dist/assets/{system-events-page-DCzSUqqc.js → system-events-page-BT1OLy4k.js} +1 -1
  158. package/dist/assets/{system-events-redirect-page-CEg_Jxyi.js → system-events-redirect-page-Bn1Mlmrx.js} +1 -1
  159. package/dist/assets/{tabular-grid-C5L9pFzq.js → tabular-grid-OOn2S_C5.js} +1 -1
  160. package/dist/assets/{teleport-gateway-client-D-ALb4dO.js → teleport-gateway-client-CbFuQSt0.js} +1 -1
  161. package/dist/assets/{text-preview-DiJsswZP.js → text-preview-sXXhDNUX.js} +1 -1
  162. package/dist/assets/{theme-stage-page-DZnfilKQ.js → theme-stage-page-D5R8P8hx.js} +1 -1
  163. package/dist/assets/{tiptap-document-editor-DofRh4ro.js → tiptap-document-editor-DJxCQreS.js} +1 -1
  164. package/dist/assets/{tool-detail-panel-JIBv6Beb.js → tool-detail-panel-C2W_9tyR.js} +1 -1
  165. package/dist/assets/tool-detail-panel-CCaS1KuN.js +1 -0
  166. package/dist/assets/{trait-cycle-row-B6KZUSNQ.js → trait-cycle-row-CptuY2rL.js} +1 -1
  167. package/dist/assets/{upgrade-cancel-page-Dhp3XhSj.js → upgrade-cancel-page-CZcjnTkF.js} +1 -1
  168. package/dist/assets/{upgrade-success-page-m1dwmZAH.js → upgrade-success-page-DOWiDkOG.js} +1 -1
  169. package/dist/assets/{usage-redirect-page-DtWMj83d.js → usage-redirect-page-BWdqE2yR.js} +1 -1
  170. package/dist/assets/{use-app-delete-BeIx8acd.js → use-app-delete-DsCLfjVk.js} +1 -1
  171. package/dist/assets/{use-assistant-identity-details-DAjGPZa_.js → use-assistant-identity-details-DWDjVqbF.js} +1 -1
  172. package/dist/assets/{use-channel-trust-floors-64auUBhl.js → use-channel-trust-floors-BpA8XrEX.js} +1 -1
  173. package/dist/assets/{use-checkout-dismiss-refresh-BzonGik4.js → use-checkout-dismiss-refresh-AAMt1w79.js} +1 -1
  174. package/dist/assets/{use-edge-swipe-back-D4uqT-DO.js → use-edge-swipe-back-CtH4IJQV.js} +1 -1
  175. package/dist/assets/{use-hotkey-recorder-DIRQa9X4.js → use-hotkey-recorder-TqrRpvTU.js} +1 -1
  176. package/dist/assets/{use-invite-link-dialog-BmjuUoiB.js → use-invite-link-dialog-BIai7wEJ.js} +1 -1
  177. package/dist/assets/{use-plugins-list-C80Nqj9r.js → use-plugins-list-BEHmXwlp.js} +1 -1
  178. package/dist/assets/{use-return-to-short-circuit-D5pnP1Yu.js → use-return-to-short-circuit-CEjprwJ6.js} +1 -1
  179. package/dist/assets/{use-side-list-room-XdX6A31O.js → use-side-list-room-BJ5IwZkh.js} +1 -1
  180. package/dist/assets/{use-skill-actions-CJK1iCwU.js → use-skill-actions-D98yjthR.js} +1 -1
  181. package/dist/assets/{use-skill-detail-files-C7q6dovc.js → use-skill-detail-files-XJ3Mq-uM.js} +1 -1
  182. package/dist/assets/use-supports-credentials-settings-5kwj4xAE.js +1 -0
  183. package/dist/assets/{voice-page-QoyBvX5r.js → voice-page-BLDxl5d8.js} +1 -1
  184. package/dist/assets/{wake-detail-panel-6F1IA3W1.js → wake-detail-panel--GpIl1Pf.js} +1 -1
  185. package/dist/assets/{weather-forecast-display-BZQIX-uF.js → weather-forecast-display-Dozuotk6.js} +1 -1
  186. package/dist/assets/{welcome-screen-D0mfYAWX.js → welcome-screen-8lsoSWQi.js} +1 -1
  187. package/dist/assets/{workflow-detail-panel-DJSTOjO6.js → workflow-detail-panel-DnKvBE9t.js} +1 -1
  188. package/dist/assets/{workspace-page-Blj0jN4f.js → workspace-page-gxt87pPu.js} +1 -1
  189. package/dist/assets/{xlsx-preview-BjyviRzH.js → xlsx-preview-nQSldHCi.js} +1 -1
  190. package/dist/index.html +1 -1
  191. package/package.json +1 -1
  192. package/dist/assets/add-credits-modal-Bd-VLKCr.js +0 -1
  193. package/dist/assets/auth-store-c2wGkNYC.js +0 -1
  194. package/dist/assets/avatar-bundled-components-DouXFXf0.js +0 -1
  195. package/dist/assets/camera-capture-overlay-Cddyhd27.js +0 -1
  196. package/dist/assets/checkout-return-target-Dzek3DVO.js +0 -1
  197. package/dist/assets/command-palette-ysJ0pGqL.js +0 -1
  198. package/dist/assets/deploy-dialogs-C0tPyGEG.js +0 -1
  199. package/dist/assets/document-load-CDTK-Nvg.js +0 -1
  200. package/dist/assets/local-mode-BQuGGft7.js +0 -1
  201. package/dist/assets/mutation-error-DMAjw2hB.js +0 -1
  202. package/dist/assets/native-attachment-pickers-DHUbeLTb.js +0 -1
  203. package/dist/assets/native-file-Cjo1vjE-.js +0 -1
  204. package/dist/assets/paired-platform-identity-DSXdJGYm.js +0 -1
  205. package/dist/assets/password-reset-page-ByXpR8K3.js +0 -1
  206. package/dist/assets/plugins-surface-C-CI4s_y.js +0 -1
  207. package/dist/assets/routes-DDI0EQIE.js +0 -1
  208. package/dist/assets/share-feedback-modal-DjikvBId.js +0 -1
  209. package/dist/assets/tool-detail-panel-_1dc3HE3.js +0 -1
  210. package/dist/assets/use-supports-credentials-settings-CeJbM6Kf.js +0 -1
@@ -1 +1 @@
1
- import{vS as e}from"./app-CGtZI7qK.js";function t(t){let n=typeof window<`u`?window.location.origin:``,r=new URLSearchParams({senderAssistantId:t.senderAssistantId,token:t.token});return`${n}${e.connect}?${r.toString()}`}function n(e){let t=e.get(`senderAssistantId`)?.trim(),n=e.get(`token`)?.trim();return!t||!n?null:{senderAssistantId:t,token:n}}export{n,t};
1
+ import{vS as e}from"./app-CPkqAi_4.js";function t(t){let n=typeof window<`u`?window.location.origin:``,r=new URLSearchParams({senderAssistantId:t.senderAssistantId,token:t.token});return`${n}${e.connect}?${r.toString()}`}function n(e){let t=e.get(`senderAssistantId`)?.trim(),n=e.get(`token`)?.trim();return!t||!n?null:{senderAssistantId:t,token:n}}export{n,t};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{Mg as t,kC as n,tw as r,yS as i}from"./app-CGtZI7qK.js";import{t as a,x as o}from"./react-BJ4PZBJN.js";import{w as s}from"./vendor-D-45vVY0.js";import{n as c,t as l}from"./app-info-DURJWXun.js";var u=e(o(),1),d=a();function f(){let{t:e}=s(),a=t(),[o,f]=(0,u.useState)(null);(0,u.useEffect)(()=>{l().then(f)},[]);let m=o??p;return(0,d.jsxs)(`div`,{className:`flex h-svh w-screen flex-col items-center justify-center bg-background px-8 pt-14 pb-8 text-center text-foreground select-none`,children:[(0,d.jsx)(`h1`,{className:`mt-4 text-2xl font-semibold`,children:m.appName}),(0,d.jsx)(`p`,{className:`text-muted-foreground mt-1 mb-7 text-xs`,children:e(a===`windows`?`aboutPage.taglineWindows`:`aboutPage.taglineMacOS`)}),(0,d.jsxs)(`dl`,{className:`mb-7 grid grid-cols-[auto_auto] gap-x-4 gap-y-1.5 text-sm`,children:[(0,d.jsx)(`dt`,{className:`text-muted-foreground text-right`,children:e(`aboutPage.version`)}),(0,d.jsx)(`dd`,{className:`text-left font-mono tabular-nums select-text`,children:m.version}),(0,d.jsx)(`dt`,{className:`text-muted-foreground text-right`,children:e(`aboutPage.build`)}),(0,d.jsx)(`dd`,{className:`text-left font-mono tabular-nums select-text`,children:m.commitSha})]}),(0,d.jsx)(`a`,{href:m.website,className:r(n(),`text-sm`),onClick:e=>{i()&&(e.preventDefault(),c())},children:new URL(m.website).host}),(0,d.jsx)(`div`,{className:`text-muted-foreground mt-auto pt-6 text-[11px]`,children:m.copyright})]})}var p={appName:`Cadet`,version:`—`,commitSha:`—`,copyright:`© ${new Date().getFullYear()} Cadet`,website:`https://mycadet.ai`};export{f as AboutPage};
1
+ import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{Mg as t,kC as n,tw as r,yS as i}from"./app-CPkqAi_4.js";import{t as a,x as o}from"./react-BJ4PZBJN.js";import{w as s}from"./vendor-D-45vVY0.js";import{n as c,t as l}from"./app-info-CLuEVQl-.js";var u=e(o(),1),d=a();function f(){let{t:e}=s(),a=t(),[o,f]=(0,u.useState)(null);(0,u.useEffect)(()=>{l().then(f)},[]);let m=o??p;return(0,d.jsxs)(`div`,{className:`flex h-svh w-screen flex-col items-center justify-center bg-background px-8 pt-14 pb-8 text-center text-foreground select-none`,children:[(0,d.jsx)(`h1`,{className:`mt-4 text-2xl font-semibold`,children:m.appName}),(0,d.jsx)(`p`,{className:`text-muted-foreground mt-1 mb-7 text-xs`,children:e(a===`windows`?`aboutPage.taglineWindows`:`aboutPage.taglineMacOS`)}),(0,d.jsxs)(`dl`,{className:`mb-7 grid grid-cols-[auto_auto] gap-x-4 gap-y-1.5 text-sm`,children:[(0,d.jsx)(`dt`,{className:`text-muted-foreground text-right`,children:e(`aboutPage.version`)}),(0,d.jsx)(`dd`,{className:`text-left font-mono tabular-nums select-text`,children:m.version}),(0,d.jsx)(`dt`,{className:`text-muted-foreground text-right`,children:e(`aboutPage.build`)}),(0,d.jsx)(`dd`,{className:`text-left font-mono tabular-nums select-text`,children:m.commitSha})]}),(0,d.jsx)(`a`,{href:m.website,className:r(n(),`text-sm`),onClick:e=>{i()&&(e.preventDefault(),c())},children:new URL(m.website).host}),(0,d.jsx)(`div`,{className:`text-muted-foreground mt-auto pt-6 text-[11px]`,children:m.copyright})]})}var p={appName:`Cadet`,version:`—`,commitSha:`—`,copyright:`© ${new Date().getFullYear()} Cadet`,website:`https://mycadet.ai`};export{f as AboutPage};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{Sh as t,Uy as n,fl as r,il as i,rl as a,vS as o,wh as s,yh as c}from"./app-CGtZI7qK.js";import{n as l,t as u,x as d}from"./react-BJ4PZBJN.js";import{w as f}from"./vendor-D-45vVY0.js";import{r as p,t as m}from"./account-shell-DoEhthHd.js";var h=e(d(),1),g=u();function _(){let{t:e}=f(`account`),u=t(),d=s(),_=c.use.user(),v=c.use.logout(),[y,b]=(0,h.useState)(null),[x,S]=(0,h.useState)(!1),C=async()=>{b(null),S(!0);try{await n(i,a)}catch(t){console.error(`[account] auth flow failed:`,t),b(e(`authErrors.genericFailure`)),S(!1)}};return d?(0,g.jsx)(m,{children:(0,g.jsx)(p,{title:e(`accountPage.loading`)})}):u?(0,g.jsxs)(m,{children:[(0,g.jsx)(p,{title:_?.username?e(`accountPage.signedInTitleNamed`,{name:_.username}):e(`accountPage.signedInTitle`),subtitle:e(`accountPage.signedInSubtitle`)}),(0,g.jsxs)(`div`,{className:`flex flex-col items-center gap-4`,children:[(0,g.jsx)(l,{to:o.assistant,className:`inline-flex w-full items-center justify-center gap-2 rounded-lg bg-[var(--primary-base)] px-6 py-3 text-sm font-medium text-[var(--content-inset)] no-underline transition-colors hover:bg-[var(--primary-hover)]`,children:e(`accountPage.goToAssistant`)}),(0,g.jsx)(`button`,{type:`button`,onClick:async()=>{await v(),r(o.account.login)},className:`cursor-pointer bg-transparent text-sm font-normal text-[var(--content-secondary)] transition-colors hover:text-[var(--content-default)]`,children:e(`accountPage.signOut`)})]})]}):(0,g.jsxs)(m,{children:[(0,g.jsx)(p,{title:e(`accountPage.welcomeTitle`),subtitle:e(`accountPage.welcomeSubtitle`)}),y&&(0,g.jsx)(`p`,{className:`text-center text-sm text-[var(--system-negative-strong)]`,children:y}),(0,g.jsx)(`div`,{className:`flex flex-col items-center gap-4`,children:(0,g.jsx)(`button`,{type:`button`,onClick:()=>void C(),disabled:x,className:`inline-flex w-full cursor-pointer items-center justify-center gap-2 rounded-lg bg-[var(--primary-base)] px-6 py-3 text-sm font-medium text-[var(--content-inset)] transition-colors hover:bg-[var(--primary-hover)] disabled:opacity-50`,children:e(`accountPage.signIn`)})})]})}export{_ as AccountPage};
1
+ import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{Sh as t,Uy as n,fl as r,il as i,rl as a,vS as o,wh as s,yh as c}from"./app-CPkqAi_4.js";import{n as l,t as u,x as d}from"./react-BJ4PZBJN.js";import{w as f}from"./vendor-D-45vVY0.js";import{r as p,t as m}from"./account-shell-C16ZEkR-.js";var h=e(d(),1),g=u();function _(){let{t:e}=f(`account`),u=t(),d=s(),_=c.use.user(),v=c.use.logout(),[y,b]=(0,h.useState)(null),[x,S]=(0,h.useState)(!1),C=async()=>{b(null),S(!0);try{await n(i,a)}catch(t){console.error(`[account] auth flow failed:`,t),b(e(`authErrors.genericFailure`)),S(!1)}};return d?(0,g.jsx)(m,{children:(0,g.jsx)(p,{title:e(`accountPage.loading`)})}):u?(0,g.jsxs)(m,{children:[(0,g.jsx)(p,{title:_?.username?e(`accountPage.signedInTitleNamed`,{name:_.username}):e(`accountPage.signedInTitle`),subtitle:e(`accountPage.signedInSubtitle`)}),(0,g.jsxs)(`div`,{className:`flex flex-col items-center gap-4`,children:[(0,g.jsx)(l,{to:o.assistant,className:`inline-flex w-full items-center justify-center gap-2 rounded-lg bg-[var(--primary-base)] px-6 py-3 text-sm font-medium text-[var(--content-inset)] no-underline transition-colors hover:bg-[var(--primary-hover)]`,children:e(`accountPage.goToAssistant`)}),(0,g.jsx)(`button`,{type:`button`,onClick:async()=>{await v(),r(o.account.login)},className:`cursor-pointer bg-transparent text-sm font-normal text-[var(--content-secondary)] transition-colors hover:text-[var(--content-default)]`,children:e(`accountPage.signOut`)})]})]}):(0,g.jsxs)(m,{children:[(0,g.jsx)(p,{title:e(`accountPage.welcomeTitle`),subtitle:e(`accountPage.welcomeSubtitle`)}),y&&(0,g.jsx)(`p`,{className:`text-center text-sm text-[var(--system-negative-strong)]`,children:y}),(0,g.jsx)(`div`,{className:`flex flex-col items-center gap-4`,children:(0,g.jsx)(`button`,{type:`button`,onClick:()=>void C(),disabled:x,className:`inline-flex w-full cursor-pointer items-center justify-center gap-2 rounded-lg bg-[var(--primary-base)] px-6 py-3 text-sm font-medium text-[var(--content-inset)] transition-colors hover:bg-[var(--primary-hover)] disabled:opacity-50`,children:e(`accountPage.signIn`)})})]})}export{_ as AccountPage};
@@ -1 +1 @@
1
- import{IC as e}from"./app-CGtZI7qK.js";import{t}from"./react-BJ4PZBJN.js";var n=t(),r=(0,n.jsx)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 20 20`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:(0,n.jsx)(`path`,{d:`M7.5 15L12.5 10L7.5 5`,stroke:`currentColor`,strokeWidth:`1.67`,strokeLinecap:`round`,strokeLinejoin:`round`})});function i({onSubmit:t,error:i,children:a,submitLabel:o,submittingLabel:s,isSubmitting:c,footer:l}){return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(`form`,{onSubmit:t,className:`flex flex-col gap-4`,children:[i&&(0,n.jsx)(e,{tone:`error`,children:i}),(0,n.jsx)(`div`,{className:`flex flex-col gap-3`,children:a}),(0,n.jsxs)(`button`,{type:`submit`,disabled:c,className:`mt-2 inline-flex w-full cursor-pointer items-center justify-center gap-2 rounded-lg bg-[var(--primary-base)] px-6 py-3 text-sm font-medium text-[var(--content-inset)] transition-colors hover:bg-[var(--primary-hover)] disabled:cursor-wait disabled:opacity-50`,children:[c?s:o,r]})]}),l&&(0,n.jsx)(`div`,{className:`mt-8 text-center`,children:l})]})}function a(e){return(0,n.jsx)(`input`,{...e,className:`w-full rounded-lg border border-[var(--border-base)] bg-[var(--surface-overlay)] px-4 py-3 text-sm text-[var(--content-default)] outline-none placeholder:text-[var(--content-tertiary)] focus:border-[var(--primary-base)]/50`})}function o({title:e,subtitle:t}){return(0,n.jsxs)(`div`,{className:`mb-8 text-center`,children:[(0,n.jsx)(`h1`,{className:`mb-2 font-serif text-[2rem] font-bold italic text-[var(--content-default)]`,children:e}),t&&(0,n.jsx)(`p`,{className:`text-sm text-[var(--content-secondary)]`,children:t})]})}function s({children:e}){return(0,n.jsx)(`div`,{className:`flex min-h-screen items-center justify-center bg-[var(--surface-base)]`,children:(0,n.jsx)(`div`,{className:`w-full max-w-[480px] px-6`,children:(0,n.jsx)(`div`,{className:`flex flex-col items-center gap-10`,children:(0,n.jsx)(`div`,{className:`w-full`,children:e})})})})}export{a as i,i as n,o as r,s as t};
1
+ import{IC as e}from"./app-CPkqAi_4.js";import{t}from"./react-BJ4PZBJN.js";var n=t(),r=(0,n.jsx)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 20 20`,fill:`none`,xmlns:`http://www.w3.org/2000/svg`,children:(0,n.jsx)(`path`,{d:`M7.5 15L12.5 10L7.5 5`,stroke:`currentColor`,strokeWidth:`1.67`,strokeLinecap:`round`,strokeLinejoin:`round`})});function i({onSubmit:t,error:i,children:a,submitLabel:o,submittingLabel:s,isSubmitting:c,footer:l}){return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(`form`,{onSubmit:t,className:`flex flex-col gap-4`,children:[i&&(0,n.jsx)(e,{tone:`error`,children:i}),(0,n.jsx)(`div`,{className:`flex flex-col gap-3`,children:a}),(0,n.jsxs)(`button`,{type:`submit`,disabled:c,className:`mt-2 inline-flex w-full cursor-pointer items-center justify-center gap-2 rounded-lg bg-[var(--primary-base)] px-6 py-3 text-sm font-medium text-[var(--content-inset)] transition-colors hover:bg-[var(--primary-hover)] disabled:cursor-wait disabled:opacity-50`,children:[c?s:o,r]})]}),l&&(0,n.jsx)(`div`,{className:`mt-8 text-center`,children:l})]})}function a(e){return(0,n.jsx)(`input`,{...e,className:`w-full rounded-lg border border-[var(--border-base)] bg-[var(--surface-overlay)] px-4 py-3 text-sm text-[var(--content-default)] outline-none placeholder:text-[var(--content-tertiary)] focus:border-[var(--primary-base)]/50`})}function o({title:e,subtitle:t}){return(0,n.jsxs)(`div`,{className:`mb-8 text-center`,children:[(0,n.jsx)(`h1`,{className:`mb-2 font-serif text-[2rem] font-bold italic text-[var(--content-default)]`,children:e}),t&&(0,n.jsx)(`p`,{className:`text-sm text-[var(--content-secondary)]`,children:t})]})}function s({children:e}){return(0,n.jsx)(`div`,{className:`flex min-h-screen items-center justify-center bg-[var(--surface-base)]`,children:(0,n.jsx)(`div`,{className:`w-full max-w-[480px] px-6`,children:(0,n.jsx)(`div`,{className:`flex flex-col items-center gap-10`,children:(0,n.jsx)(`div`,{className:`w-full`,children:e})})})})}export{a as i,i as n,o as r,s as t};
@@ -1,3 +1,3 @@
1
- import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{DS as t,En as n,Hn as r,Kn as i,Ln as a,QS as o,Un as s,Wn as c,XC as l,_r as u,gr as d,hr as f,jC as p,mr as m,tw as h,zC as g}from"./app-CGtZI7qK.js";import{t as _,x as v}from"./react-BJ4PZBJN.js";import{k as y,w as b}from"./vendor-D-45vVY0.js";import{$ as x,$n as S,A as C,Ai as w,Br as T,Cr as E,D,Gi as O,Ha as ee,Ii as te,Ki as ne,Nr as re,P as k,Va as ie,Ya as A,_t as ae,ha as j,kt as oe,mi as M,qi as N,vt as P,zi as F}from"./icons-Dwi7aA1Y.js";import{n as I,r as se,t as L}from"./animated-stat-square-CWpBP3Ub.js";import{o as ce,t as le}from"./detail-primitives-BZtYI-6o.js";import{t as ue}from"./file-diff-view-Cmqq4-xy.js";import{t as de}from"./detail-panel-stop-button-DLTLV0lw.js";import{t as fe}from"./status-badge-pill-Ceff-8Fw.js";var pe=A(`file-pen`,[[`path`,{d:`M12.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v9.34`,key:`o6klzx`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10.378 12.622a1 1 0 0 1 3 3.003L8.36 20.637a2 2 0 0 1-.854.506l-2.867.837a.5.5 0 0 1-.62-.62l.836-2.869a2 2 0 0 1 .506-.853z`,key:`zhnas1`}]]),R=e(v(),1),z=``;function B(e,t){switch(e){case`complete`:case`completed`:return`completed`;case`failed`:case`error`:return`error`;case void 0:return t;default:return`running`}}function me(e){return(e.messageId?.startsWith(`local-marker-`)??!1)||(e.content?.startsWith(`↻ Steering: `)??!1)}function V(e){let t=e??``;return t.startsWith(`↻ Steering: `)?t.slice(m.length):t}function H(e){let t=e[e.length-1];t&&(t.kind===`agent`||t.kind===`thinking`)&&!t.isComplete&&(e[e.length-1]={...t,isComplete:!0})}function U(e,t){if(t.updateType===`agent_message_chunk`&&me(t)){H(e),e.push({kind:`user`,id:t.messageId??`steer-${e.length}`,content:V(t.content)});return}switch(t.updateType){case`user_message_chunk`:{let n=t.messageId??z,r=V(t.content),i=e[e.length-1];i&&i.kind===`user`&&i.id===n?e[e.length-1]={...i,content:i.content+r}:(H(e),e.push({kind:`user`,id:n,content:r}));let a=e[e.length-1].content;for(let t=0;t<e.length-1;t++){let n=e[t];if(n.kind===`user`&&n.id.startsWith(`local-marker-`)&&n.content===a){e.splice(t,1);break}}return}case`agent_message_chunk`:{let n=t.messageId??z,r=e[e.length-1];if(r&&r.kind===`agent`&&r.messageId===n){e[e.length-1]={...r,content:r.content+(t.content??``)};return}if(n!==z&&r&&r.kind===`agent`&&r.messageId===z&&!r.isComplete&&r.content===(t.content??``)){e[e.length-1]={...r,messageId:n};return}H(e),e.push({kind:`agent`,messageId:n,content:t.content??``,isComplete:!1});return}case`agent_thought_chunk`:{let n=t.messageId??z,r=e[e.length-1];if(r&&r.kind===`thinking`&&r.messageId===n){e[e.length-1]={...r,content:r.content+(t.content??``)};return}H(e),e.push({kind:`thinking`,messageId:n,content:t.content??``,isComplete:!1});return}case`tool_call`:{let n=t.toolCallId;if(n===void 0)return;H(e),e.push({kind:`tool`,toolCallId:n,title:t.toolTitle??``,toolKind:t.toolKind,status:B(t.toolStatus,`running`),content:t.content,locations:W(t),rawInput:t.rawInput,rawOutput:t.rawOutput});return}case`tool_call_update`:{let n=t.toolCallId;if(n===void 0)return;let r=e.findIndex(e=>e.kind===`tool`&&e.toolCallId===n);if(r===-1)return;let i=e[r],a=W(t);e[r]={...i,title:t.toolTitle??i.title,toolKind:t.toolKind??i.toolKind,status:B(t.toolStatus,i.status),content:t.content??i.content,locations:a??i.locations,rawInput:t.rawInput===void 0?i.rawInput:t.rawInput,rawOutput:t.rawOutput===void 0?i.rawOutput:t.rawOutput};return}case`plan`:{let n=he(t.content);if(n===null)return;let r=e.findIndex(e=>e.kind===`plan`),i={kind:`plan`,entries:n};r===-1?(H(e),e.push(i)):e[r]=i;return}}}function W(e){let t=e.locations;if(!Array.isArray(t))return;let n=[];for(let e of t){let t=e??{};typeof t.path==`string`&&n.push(typeof t.line==`number`?{path:t.path,line:t.line}:{path:t.path})}return n}function he(e){if(!e)return null;let t;try{t=JSON.parse(e)}catch{return null}let n=Array.isArray(t)?t:Array.isArray(t?.entries)?t.entries:null;return n===null?null:n.map(e=>{let t=e??{},n=t.content??t.label??``;return{label:typeof n==`string`?n:String(n),checked:t.checked===!0||t.status===`completed`}})}function ge(e){let t=[];for(let n of e)U(t,n);return t}function _e(e,t){if(e===t)return{kind:`identity`};if(e===null)return{kind:`first`};if(t.length<e.length)return{kind:`fallback`};for(let n=0;n<e.length;n++)if(e[n]!==t[n])return n===e.length-1&&t.length===e.length?{kind:`mutate-last`}:{kind:`fallback`};return t.length===e.length?{kind:`identity`}:{kind:`append`,from:e.length}}function ve(){let e=null,t=[];function n(n){return t=ge(n),e=n,t}function r(r){let i=_e(e,r);switch(i.kind){case`identity`:return t;case`first`:return n(r);case`append`:{let n=t.slice();for(let e=i.from;e<r.length;e++)U(n,r[e]);return e=r,t=n,t}case`mutate-last`:case`fallback`:return n(r)}}return{project:r}}function ye(e){let t=(0,R.useRef)(null);return t.current??=ve(),t.current.project(e)}function G(e){if(!e)return[];let t;try{t=JSON.parse(e)}catch{let t=e.trimStart();return t.startsWith(`{`)||t.startsWith(`[`)?[]:[{type:`content`,text:e}]}let n=Array.isArray(t)?t:[t],r=[];for(let e of n){let t=be(e);t&&r.push(t)}return r}function be(e){if(typeof e!=`object`||!e)return null;let t=e;switch(t.type){case`content`:return{type:`content`,text:xe(t.content)};case`diff`:return typeof t.path!=`string`||typeof t.newText!=`string`?null:{type:`diff`,path:t.path,newText:t.newText,...typeof t.oldText==`string`?{oldText:t.oldText}:{}};case`terminal`:{let e=Se(t);return e===void 0?{type:`terminal`}:{type:`terminal`,text:e}}default:return null}}function xe(e){if(typeof e==`string`)return e;if(typeof e==`object`&&e){let t=e.text;if(typeof t==`string`)return t}return``}function Se(e){if(typeof e.text==`string`)return e.text;if(typeof e.output==`string`)return e.output;if(typeof e.content==`string`)return e.content;if(typeof e.content==`object`&&e.content!==null){let t=e.content.text;if(typeof t==`string`)return t}}function K(e){if(typeof e!=`object`||!e)return;let t=e.command;return typeof t==`string`?t:void 0}function q(e){return G(e).filter(e=>e.type===`content`||e.type===`terminal`).map(e=>`text`in e?e.text??``:``).filter(e=>e.length>0).join(`
1
+ import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{DS as t,En as n,Hn as r,Kn as i,Ln as a,QS as o,Un as s,Wn as c,XC as l,_r as u,gr as d,hr as f,jC as p,mr as m,tw as h,zC as g}from"./app-CPkqAi_4.js";import{t as _,x as v}from"./react-BJ4PZBJN.js";import{k as y,w as b}from"./vendor-D-45vVY0.js";import{$ as x,$n as S,A as C,Ai as w,Br as T,Cr as E,D,Gi as O,Ha as ee,Ii as te,Ki as ne,Nr as re,P as k,Va as ie,Ya as A,_t as ae,ha as j,kt as oe,mi as M,qi as N,vt as P,zi as F}from"./icons-Dwi7aA1Y.js";import{n as I,r as se,t as L}from"./animated-stat-square-DMsQUXPs.js";import{o as ce,t as le}from"./detail-primitives-DYFVgm7V.js";import{t as ue}from"./file-diff-view-DMPBN50t.js";import{t as de}from"./detail-panel-stop-button-EtbIbCMU.js";import{t as fe}from"./status-badge-pill-Ceff-8Fw.js";var pe=A(`file-pen`,[[`path`,{d:`M12.659 22H18a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v9.34`,key:`o6klzx`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10.378 12.622a1 1 0 0 1 3 3.003L8.36 20.637a2 2 0 0 1-.854.506l-2.867.837a.5.5 0 0 1-.62-.62l.836-2.869a2 2 0 0 1 .506-.853z`,key:`zhnas1`}]]),R=e(v(),1),z=``;function B(e,t){switch(e){case`complete`:case`completed`:return`completed`;case`failed`:case`error`:return`error`;case void 0:return t;default:return`running`}}function me(e){return(e.messageId?.startsWith(`local-marker-`)??!1)||(e.content?.startsWith(`↻ Steering: `)??!1)}function V(e){let t=e??``;return t.startsWith(`↻ Steering: `)?t.slice(m.length):t}function H(e){let t=e[e.length-1];t&&(t.kind===`agent`||t.kind===`thinking`)&&!t.isComplete&&(e[e.length-1]={...t,isComplete:!0})}function U(e,t){if(t.updateType===`agent_message_chunk`&&me(t)){H(e),e.push({kind:`user`,id:t.messageId??`steer-${e.length}`,content:V(t.content)});return}switch(t.updateType){case`user_message_chunk`:{let n=t.messageId??z,r=V(t.content),i=e[e.length-1];i&&i.kind===`user`&&i.id===n?e[e.length-1]={...i,content:i.content+r}:(H(e),e.push({kind:`user`,id:n,content:r}));let a=e[e.length-1].content;for(let t=0;t<e.length-1;t++){let n=e[t];if(n.kind===`user`&&n.id.startsWith(`local-marker-`)&&n.content===a){e.splice(t,1);break}}return}case`agent_message_chunk`:{let n=t.messageId??z,r=e[e.length-1];if(r&&r.kind===`agent`&&r.messageId===n){e[e.length-1]={...r,content:r.content+(t.content??``)};return}if(n!==z&&r&&r.kind===`agent`&&r.messageId===z&&!r.isComplete&&r.content===(t.content??``)){e[e.length-1]={...r,messageId:n};return}H(e),e.push({kind:`agent`,messageId:n,content:t.content??``,isComplete:!1});return}case`agent_thought_chunk`:{let n=t.messageId??z,r=e[e.length-1];if(r&&r.kind===`thinking`&&r.messageId===n){e[e.length-1]={...r,content:r.content+(t.content??``)};return}H(e),e.push({kind:`thinking`,messageId:n,content:t.content??``,isComplete:!1});return}case`tool_call`:{let n=t.toolCallId;if(n===void 0)return;H(e),e.push({kind:`tool`,toolCallId:n,title:t.toolTitle??``,toolKind:t.toolKind,status:B(t.toolStatus,`running`),content:t.content,locations:W(t),rawInput:t.rawInput,rawOutput:t.rawOutput});return}case`tool_call_update`:{let n=t.toolCallId;if(n===void 0)return;let r=e.findIndex(e=>e.kind===`tool`&&e.toolCallId===n);if(r===-1)return;let i=e[r],a=W(t);e[r]={...i,title:t.toolTitle??i.title,toolKind:t.toolKind??i.toolKind,status:B(t.toolStatus,i.status),content:t.content??i.content,locations:a??i.locations,rawInput:t.rawInput===void 0?i.rawInput:t.rawInput,rawOutput:t.rawOutput===void 0?i.rawOutput:t.rawOutput};return}case`plan`:{let n=he(t.content);if(n===null)return;let r=e.findIndex(e=>e.kind===`plan`),i={kind:`plan`,entries:n};r===-1?(H(e),e.push(i)):e[r]=i;return}}}function W(e){let t=e.locations;if(!Array.isArray(t))return;let n=[];for(let e of t){let t=e??{};typeof t.path==`string`&&n.push(typeof t.line==`number`?{path:t.path,line:t.line}:{path:t.path})}return n}function he(e){if(!e)return null;let t;try{t=JSON.parse(e)}catch{return null}let n=Array.isArray(t)?t:Array.isArray(t?.entries)?t.entries:null;return n===null?null:n.map(e=>{let t=e??{},n=t.content??t.label??``;return{label:typeof n==`string`?n:String(n),checked:t.checked===!0||t.status===`completed`}})}function ge(e){let t=[];for(let n of e)U(t,n);return t}function _e(e,t){if(e===t)return{kind:`identity`};if(e===null)return{kind:`first`};if(t.length<e.length)return{kind:`fallback`};for(let n=0;n<e.length;n++)if(e[n]!==t[n])return n===e.length-1&&t.length===e.length?{kind:`mutate-last`}:{kind:`fallback`};return t.length===e.length?{kind:`identity`}:{kind:`append`,from:e.length}}function ve(){let e=null,t=[];function n(n){return t=ge(n),e=n,t}function r(r){let i=_e(e,r);switch(i.kind){case`identity`:return t;case`first`:return n(r);case`append`:{let n=t.slice();for(let e=i.from;e<r.length;e++)U(n,r[e]);return e=r,t=n,t}case`mutate-last`:case`fallback`:return n(r)}}return{project:r}}function ye(e){let t=(0,R.useRef)(null);return t.current??=ve(),t.current.project(e)}function G(e){if(!e)return[];let t;try{t=JSON.parse(e)}catch{let t=e.trimStart();return t.startsWith(`{`)||t.startsWith(`[`)?[]:[{type:`content`,text:e}]}let n=Array.isArray(t)?t:[t],r=[];for(let e of n){let t=be(e);t&&r.push(t)}return r}function be(e){if(typeof e!=`object`||!e)return null;let t=e;switch(t.type){case`content`:return{type:`content`,text:xe(t.content)};case`diff`:return typeof t.path!=`string`||typeof t.newText!=`string`?null:{type:`diff`,path:t.path,newText:t.newText,...typeof t.oldText==`string`?{oldText:t.oldText}:{}};case`terminal`:{let e=Se(t);return e===void 0?{type:`terminal`}:{type:`terminal`,text:e}}default:return null}}function xe(e){if(typeof e==`string`)return e;if(typeof e==`object`&&e){let t=e.text;if(typeof t==`string`)return t}return``}function Se(e){if(typeof e.text==`string`)return e.text;if(typeof e.output==`string`)return e.output;if(typeof e.content==`string`)return e.content;if(typeof e.content==`object`&&e.content!==null){let t=e.content.text;if(typeof t==`string`)return t}}function K(e){if(typeof e!=`object`||!e)return;let t=e.command;return typeof t==`string`?t:void 0}function q(e){return G(e).filter(e=>e.type===`content`||e.type===`terminal`).map(e=>`text`in e?e.text??``:``).filter(e=>e.length>0).join(`
2
2
  `)}function J(e){if(e!=null){if(typeof e==`string`)return e;if(typeof e==`object`)try{return JSON.stringify(e,null,2)}catch{return String(e)}return String(e)}}function Y(e,t){let n=new Map;for(let t of e)t.type===`diff`&&n.set(t.path,{path:t.path,newText:t.newText,...t.oldText===void 0?{}:{oldText:t.oldText}});for(let e of t??[])n.has(e.path)||n.set(e.path,{path:e.path});return Array.from(n.values())}var X=_();function Ce({content:e,isComplete:t,assistantId:r}){return(0,X.jsxs)(`div`,{"data-testid":`acp-chat-agent-message`,className:`flex w-full flex-col items-start text-chat text-[var(--content-default)]`,children:[(0,X.jsx)(n,{content:e,assistantId:r}),!t&&(0,X.jsx)(a,{className:`mt-1`,"data-testid":`acp-chat-agent-streaming`})]})}function Z({entries:e}){let{t}=b(`chat`);return e.length===0?null:(0,X.jsxs)(`div`,{"data-testid":`acp-chat-plan-block`,className:`w-full rounded-lg border border-[var(--border-base)] bg-[var(--surface-overlay)] p-3`,children:[(0,X.jsxs)(`div`,{className:`mb-2 flex items-center gap-1.5 text-[var(--content-tertiary)]`,children:[(0,X.jsx)(S,{"aria-hidden":!0,className:`h-3.5 w-3.5 shrink-0`}),(0,X.jsx)(g,{variant:`body-small-emphasised`,className:`text-inherit`,children:t(`acpChatPlanBlock.plan`)})]}),(0,X.jsx)(`ul`,{className:`flex flex-col gap-1.5`,children:e.map((e,t)=>(0,X.jsxs)(`li`,{"data-testid":`acp-chat-plan-entry`,"data-checked":e.checked,className:`flex items-start gap-2`,children:[e.checked?(0,X.jsx)(F,{"aria-hidden":!0,className:`mt-0.5 h-4 w-4 shrink-0 text-[var(--system-positive-strong)]`}):(0,X.jsx)(w,{"aria-hidden":!0,className:`mt-0.5 h-4 w-4 shrink-0 text-[var(--content-disabled)]`}),(0,X.jsx)(`span`,{className:e.checked?`text-body-small-default text-[var(--content-tertiary)] line-through`:`text-body-small-default text-[var(--content-default)]`,children:e.label})]},t))})]})}function we(e){switch(e){case`max_tokens`:case`max_turn_requests`:return y(`chat:acpChatTerminalBlock.stoppedLimitReached`);case`refusal`:return y(`chat:acpChatTerminalBlock.refused`);case`cancelled`:return y(`chat:acpChatTerminalBlock.cancelled`);default:return y(`chat:acpChatTerminalBlock.completed`)}}function Te(e){return new Date(e).toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`})}function Q({completedAt:e}){let{t}=b(`chat`);return e===void 0?null:(0,X.jsx)(`span`,{"data-testid":`acp-chat-terminal-time`,children:t(`acpChatTerminalBlock.atTime`,{time:Te(e)})})}function Ee({status:e,stopReason:t,error:n,completedAt:r}){let{t:i}=b(`chat`);if(u(e))return null;if(e===`failed`)return(0,X.jsxs)(`div`,{"data-testid":`acp-chat-terminal-block`,"data-terminal-kind":`failed`,className:`flex items-start gap-2 rounded-md bg-[var(--system-negative-weak)] px-3 py-2 text-body-small-default text-[var(--system-negative-strong)]`,children:[(0,X.jsx)(`span`,{"aria-hidden":!0,"data-testid":`acp-chat-terminal-failed-icon`,className:`flex h-[12px] w-4 shrink-0 items-center justify-center`,children:(0,X.jsx)(D,{className:`h-4 w-4`})}),(0,X.jsx)(`span`,{children:n??i(`acpChatTerminalBlock.runFailed`)})]});if(e===`cancelled`)return(0,X.jsxs)(`div`,{"data-testid":`acp-chat-terminal-block`,"data-terminal-kind":`cancelled`,className:`flex items-center gap-2 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,X.jsx)(te,{"aria-hidden":!0,className:`h-4 w-4 shrink-0`}),(0,X.jsx)(`span`,{children:i(`acpChatTerminalBlock.cancelled`)}),(0,X.jsx)(Q,{completedAt:r})]});let a=we(t);return(0,X.jsxs)(`div`,{"data-testid":`acp-chat-terminal-block`,"data-terminal-kind":`completed`,className:`flex items-center gap-2 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,X.jsx)(F,{"aria-hidden":!0,className:`h-4 w-4 shrink-0 text-[var(--system-positive-strong)]`}),(0,X.jsx)(`span`,{children:a}),(0,X.jsx)(Q,{completedAt:r})]})}function De({showDot:e,isLast:t,children:n}){return(0,X.jsxs)(`div`,{className:`relative flex items-start gap-2${t?``:` pb-4`}`,children:[!t&&(0,X.jsx)(`div`,{"aria-hidden":!0,className:`absolute bottom-0 left-[6.5px] w-px bg-[var(--border-element)] ${e?`top-[16px]`:`top-0`}`}),e?(0,X.jsx)(`span`,{"aria-hidden":!0,"data-testid":`acp-chat-timeline-dot`,className:`flex h-[14px] w-[14px] shrink-0 items-center justify-center`,children:(0,X.jsx)(`span`,{className:`h-[5px] w-[5px] rounded-full bg-[var(--content-disabled)]`})}):(0,X.jsx)(`span`,{"aria-hidden":!0,className:`h-[14px] w-[14px] shrink-0`}),(0,X.jsx)(`div`,{className:`min-w-0 flex-1`,children:n})]})}function Oe({content:e,isComplete:t,assistantId:r}){let[i,o]=(0,R.useState)(null),s=i??!t,c=e.trim().length>0,l=t?`Thought process`:`Thinking`,u=t?(0,X.jsx)(j,{"aria-hidden":!0,className:`h-3.5 w-3.5 shrink-0`}):(0,X.jsx)(a,{dotSize:5,className:`shrink-0`,"data-testid":`acp-chat-thinking-streaming`});return c?(0,X.jsxs)(`div`,{"data-testid":`acp-chat-thinking-block`,className:`w-full`,children:[(0,X.jsxs)(`button`,{type:`button`,"aria-expanded":s,onClick:()=>o(!s),"data-testid":`acp-chat-thinking-toggle`,className:`flex w-full items-center gap-1.5 text-body-small-default text-[var(--content-tertiary)] transition-colors hover:text-[var(--content-secondary)]`,children:[s?(0,X.jsx)(N,{"aria-hidden":!0,className:`h-3.5 w-3.5 shrink-0`}):(0,X.jsx)(O,{"aria-hidden":!0,className:`h-3.5 w-3.5 shrink-0`}),u,(0,X.jsx)(`span`,{children:l})]}),s&&(0,X.jsx)(`div`,{"data-testid":`acp-chat-thinking-body`,className:`mt-1.5 border-l-2 border-[var(--border-base)] pl-3 text-body-small-default text-[var(--content-tertiary)]`,children:(0,X.jsx)(n,{content:e,assistantId:r})})]}):(0,X.jsx)(`div`,{"data-testid":`acp-chat-thinking-block`,className:`w-full`,children:(0,X.jsxs)(`div`,{className:`flex w-full items-center gap-1.5 text-body-small-default text-[var(--content-tertiary)]`,children:[u,(0,X.jsx)(`span`,{children:l})]})})}var ke={running:`neutral`,completed:`positive`,error:`negative`,ended:`neutral`},Ae={running:`Running`,completed:`Completed`,error:`Failed`,ended:`Ended`},je={read:`Read file`,edit:`Edit file`,delete:`Delete file`,move:`Move file`,search:`Search`,execute:`Run command`,think:`Thinking`,fetch:`Fetch`,switch_mode:`Switch mode`},Me=`Tool call`,Ne={read:T,edit:pe,delete:C,move:re,search:P,execute:k,think:j,fetch:E,switch_mode:oe},Pe=new Set([`read`,`edit`,`delete`,`move`]);function Fe({toolKind:e}){return(0,X.jsx)(e&&Ne[e]||M,{"aria-hidden":!0,className:`h-4 w-4 shrink-0 text-[var(--content-tertiary)]`})}function $({label:e,value:t,testId:n}){return(0,X.jsxs)(`div`,{"data-testid":n,children:[(0,X.jsx)(`div`,{className:`mb-1 text-body-small-default text-[var(--content-tertiary)]`,children:e}),(0,X.jsx)(`pre`,{className:`max-h-60 overflow-auto rounded-md border border-[var(--border-element)] bg-[var(--surface-base)] p-2.5 font-mono text-body-small-default text-[var(--content-secondary)]`,children:t})]})}function Ie({block:e,isTerminal:t=!1,onOpenDiff:n,onOpenOutput:r}){let{t:i}=b(`chat`),[o,s]=(0,R.useState)(!1),c=(0,R.useMemo)(()=>G(e.content),[e.content]),l=(0,R.useMemo)(()=>q(e.content),[e.content]),u=(0,R.useMemo)(()=>l.split(`
3
3
  `).map(e=>e.trim()).find(e=>e.length>0&&!e.startsWith("```"))||`View output`,[l]),d=(0,R.useMemo)(()=>Y(c,e.locations),[c,e.locations]),f=t&&e.status===`running`?`ended`:e.status,m=f===`running`,h=e.toolKind&&je[e.toolKind]||Me,_=K(e.rawInput)??e.title,v=_&&_!==h&&(!Pe.has(e.toolKind??``)||d.length===0)?_:null,y=J(e.rawInput),x=J(e.rawOutput),S=y!==void 0||x!==void 0;return(0,X.jsxs)(`div`,{"data-testid":`acp-chat-tool-card`,"data-status":e.status,className:`w-full rounded-lg border border-[var(--border-base)] bg-[var(--surface-overlay)] p-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(Fe,{toolKind:e.toolKind}),(0,X.jsx)(g,{variant:`body-small-emphasised`,className:`min-w-0 flex-1 truncate text-[var(--content-default)]`,title:e.title,children:h}),(0,X.jsx)(p,{tone:ke[f],"data-testid":`acp-chat-tool-status`,children:Ae[f]}),m&&(0,X.jsx)(a,{className:`shrink-0`,"data-testid":`acp-chat-tool-running`})]}),v&&(0,X.jsx)(`div`,{"data-testid":`acp-chat-tool-detail`,className:`mt-1.5 font-mono text-body-small-default whitespace-pre-wrap break-words text-[var(--content-secondary)]`,children:v}),d.length>0&&(0,X.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:d.map(t=>{let r=t.oldText!==void 0||t.newText!==void 0,i=`flex max-w-full items-center gap-1.5 rounded-md border border-[var(--border-base)] bg-[var(--surface-base)] px-2 py-1 text-body-small-default text-[var(--content-secondary)]`;return r?(0,X.jsxs)(`button`,{type:`button`,"data-testid":`acp-chat-tool-file-chip`,onClick:()=>n(e.toolCallId,t),title:t.path,className:`${i} cursor-pointer transition-colors hover:bg-[var(--surface-hover)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--ring)]`,children:[(0,X.jsx)(T,{"aria-hidden":!0,className:`h-3.5 w-3.5 shrink-0`}),(0,X.jsx)(`span`,{className:`truncate font-mono`,children:t.path})]},t.path):(0,X.jsxs)(`span`,{"data-testid":`acp-chat-tool-file-ref`,title:t.path,className:i,children:[(0,X.jsx)(T,{"aria-hidden":!0,className:`h-3.5 w-3.5 shrink-0`}),(0,X.jsx)(`span`,{className:`truncate font-mono`,children:t.path})]},t.path)})}),l.length>0&&(0,X.jsxs)(`button`,{type:`button`,"data-testid":`acp-chat-tool-output-open`,onClick:()=>r?.(e.toolCallId),className:`mt-2 flex w-full items-center gap-2 rounded-md border border-[var(--border-element)] bg-[var(--surface-base)] px-2.5 py-2 text-left transition-colors hover:bg-[var(--surface-hover)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--ring)]`,children:[(0,X.jsx)(k,{"aria-hidden":!0,className:`h-3.5 w-3.5 shrink-0 text-[var(--content-tertiary)]`}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-body-small-default text-[var(--content-secondary)]`,children:u}),(0,X.jsx)(O,{"aria-hidden":!0,className:`h-3.5 w-3.5 shrink-0 text-[var(--content-tertiary)]`})]}),S&&(0,X.jsxs)(`div`,{className:`mt-2`,"data-testid":`acp-chat-tool-raw`,children:[(0,X.jsxs)(`button`,{type:`button`,"data-testid":`acp-chat-tool-raw-toggle`,"aria-expanded":o,onClick:()=>s(e=>!e),className:`flex items-center gap-1 text-body-small-default text-[var(--content-tertiary)] transition-colors hover:text-[var(--content-default)]`,children:[o?(0,X.jsx)(N,{"aria-hidden":!0,className:`h-3.5 w-3.5 shrink-0`}):(0,X.jsx)(O,{"aria-hidden":!0,className:`h-3.5 w-3.5 shrink-0`}),(0,X.jsx)(`span`,{children:i(o?`acpChatToolCard.hideRaw`:`acpChatToolCard.showRaw`)})]}),o&&(0,X.jsxs)(`div`,{className:`mt-1.5 flex flex-col gap-2`,children:[y!==void 0&&(0,X.jsx)($,{label:i(`acpChatToolCard.rawInput`),value:y,testId:`acp-chat-tool-raw-input`}),x!==void 0&&(0,X.jsx)($,{label:i(`acpChatToolCard.rawOutput`),value:x,testId:`acp-chat-tool-raw-output`})]})]})]})}function Le({content:e}){return(0,X.jsx)(`div`,{"data-testid":`acp-chat-user-turn`,className:`flex w-full justify-end`,children:(0,X.jsx)(`div`,{className:`max-w-[80%] rounded-lg bg-[var(--surface-lift)] px-4 py-3 whitespace-pre-wrap text-chat text-[var(--content-default)]`,children:e})})}function Re({model:e,options:t}){let{t:n}=b(`chat`),r=t?.find(t=>t.value===e)?.label??e;return(0,X.jsx)(o,{icon:(0,X.jsx)(x,{}),value:r,label:n(`acpRunChatView.modelLabel`)})}function ze({content:e,assistantId:t}){return(0,X.jsx)(`div`,{"data-testid":`acp-chat-command-output`,className:`rounded-lg border border-[var(--border-base)] bg-[var(--surface-overlay)] p-3 [&_pre]:!max-h-none`,children:(0,X.jsx)(n,{content:q(e),hardLineBreaks:!0,assistantId:t})})}var Be=80;function Ve(e){return e.scrollHeight-e.clientHeight-e.scrollTop<=Be}function He(e){let t=(0,R.useRef)(null),n=(0,R.useRef)(!0),[r,i]=(0,R.useState)(!1),a=(0,R.useCallback)(()=>{let e=t.current;e&&(e.scrollTop=e.scrollHeight)},[]),o=(0,R.useCallback)(()=>{let e=t.current;if(!e)return;let r=Ve(e);n.current=r,i(e=>e===!r?e:!r)},[]),s=(0,R.useCallback)(()=>{n.current=!0,a(),i(!1)},[a]),c=(0,R.useCallback)(e=>{let r=t.current;r&&r.removeEventListener(`scroll`,o),t.current=e,e&&(e.addEventListener(`scroll`,o,{passive:!0}),n.current?e.scrollTop=e.scrollHeight:o())},[o]);return(0,R.useLayoutEffect)(()=>{n.current?a():o()},[e,a,o]),{scrollRef:c,showScrollToLatest:r,scrollToLatest:s}}function Ue(e,t){switch(e.kind){case`user`:return`user-${e.id||t}`;case`agent`:return`agent-${e.messageId||t}`;case`thinking`:return`thinking-${e.messageId||t}`;case`tool`:return`tool-${e.toolCallId}`;case`plan`:return`plan`}}var We=[];function Ge({entry:e,onClose:t,assistantId:n}){let{t:r}=b(`chat`),i=u(e.status),{model:a}=e,o=e.inputTokens!==void 0||e.outputTokens!==void 0,s=ye(f(t=>t.byId[e.acpSessionId]?.events??We)),[c,d]=(0,R.useState)(null),[p,m]=(0,R.useState)(e.acpSessionId);p!==e.acpSessionId&&(m(e.acpSessionId),d(null));let _=(0,R.useCallback)((e,t)=>d({kind:`diff`,toolCallId:e,path:t.path}),[]),v=(0,R.useCallback)(e=>d({kind:`output`,toolCallId:e}),[]),y=(0,R.useCallback)(()=>d(null),[]),x=(0,R.useMemo)(()=>c?s.find(e=>e.kind===`tool`&&e.toolCallId===c.toolCallId)??null:null,[c,s]),S=(0,R.useMemo)(()=>c?.kind!==`diff`||!x?null:Y(G(x.content),x.locations).find(e=>e.path===c.path)??null,[c,x]),C=c?.kind===`diff`?c.path:x?K(x.rawInput)??x.title??`Output`:`Output`,{scrollRef:w,showScrollToLatest:T,scrollToLatest:E}=He((0,R.useMemo)(()=>({blocks:s,status:e.status,completedAt:e.completedAt}),[s,e.status,e.completedAt])),D=!i;return(0,X.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden rounded-xl bg-[var(--surface-lift)]`,children:[c&&(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2 border-b border-[var(--border-hover)] px-5 py-3`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:y,title:e.agent,className:`min-w-0 shrink cursor-pointer truncate text-left text-[var(--content-default)] hover:underline`,children:(0,X.jsx)(g,{variant:`body-small-default`,as:`span`,children:e.agent})}),(0,X.jsx)(O,{className:`h-2.5 w-2.5 shrink-0 text-[var(--content-tertiary)]`,"aria-hidden":!0}),(0,X.jsx)(g,{variant:`body-small-default`,as:`span`,title:C,className:`min-w-0 shrink truncate font-mono text-[var(--content-secondary)]`,children:C})]}),(0,X.jsx)(Ke,{entry:e,isRunning:i,onClose:t,showBack:!!c,onBack:y},`header-${e.acpSessionId}`),c?(0,X.jsx)(`div`,{className:`flex-1 overflow-y-auto px-5 py-5`,children:c.kind===`diff`?(0,X.jsx)(ue,{path:c.path,oldText:S?.oldText,newText:S?.newText}):(0,X.jsx)(ze,{content:x?.content,assistantId:n})}):(0,X.jsxs)(`div`,{className:`relative min-h-0 flex-1`,children:[(0,X.jsxs)(`div`,{ref:w,"data-testid":`acp-chat-conversation`,className:`flex h-full flex-col gap-4 overflow-y-auto px-5 py-5`,children:[(o||a!==void 0)&&(0,X.jsxs)(`div`,{className:h(`grid gap-3`,o?`grid-cols-2`:`grid-cols-1`),"data-testid":`acp-run-metrics`,children:[o&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(L,{icon:(0,X.jsx)(ee,{}),target:e.inputTokens??0,format:e=>I(Math.round(e)),label:r(`acpRunChatView.inputLabel`)}),(0,X.jsx)(L,{icon:(0,X.jsx)(se,{}),target:e.outputTokens??0,format:e=>I(Math.round(e)),label:r(`acpRunChatView.outputLabel`)})]}),a!==void 0&&(0,X.jsx)(`div`,{className:o?`col-span-2`:void 0,children:(0,X.jsx)(Re,{model:a,options:e.availableModels})})]}),(0,X.jsx)(qe,{task:e.task},`objective-${e.acpSessionId}`),(0,X.jsx)(`div`,{className:`flex flex-col`,"data-testid":`acp-chat-timeline`,children:s.map((e,t)=>(0,X.jsx)(De,{showDot:t===0||t===s.length-1||e.kind===`tool`||e.kind===`plan`,isLast:t===s.length-1,children:(0,X.jsx)(Je,{block:e,isTerminal:D,onOpenDiff:_,onOpenOutput:v,assistantId:n})},Ue(e,t)))}),!i&&(0,X.jsx)(Ee,{status:e.status,stopReason:e.stopReason,error:e.error,completedAt:e.completedAt})]}),T&&(0,X.jsx)(l,{shape:`pill`,variant:`outlined`,size:`compact`,iconOnly:(0,X.jsx)(ie,{}),onClick:E,"aria-label":r(`acpRunChatView.goToNewest`),tooltip:r(`acpRunChatView.goToNewest`),"data-testid":`acp-chat-scroll-to-latest`,className:`absolute bottom-3 left-1/2 -translate-x-1/2 shadow-md`})]}),i&&!c&&(0,X.jsx)(Ye,{acpSessionId:e.acpSessionId},`steer-${e.acpSessionId}`)]})}function Ke({entry:e,isRunning:n,onClose:r,showBack:a=!1,onBack:o}){let{t:u}=b(`chat`),[f,p]=(0,R.useState)(!1),m=d(e.status,e.stopReason),h=(0,R.useCallback)(()=>{p(!0),s(e.acpSessionId).catch(e=>{p(!1),t(e,{context:`AcpRunChatView.stop`})})},[e.acpSessionId]);return(0,X.jsx)(i,{icon:(0,X.jsxs)(X.Fragment,{children:[a&&(0,X.jsx)(l,{variant:`outlined`,iconOnly:(0,X.jsx)(ne,{}),onClick:o,"aria-label":u(`acpRunChatView.backToConversationAria`),tooltip:u(`acpRunChatView.backTooltip`),"data-testid":`acp-chat-diff-back`,className:`shrink-0`}),(0,X.jsx)(c,{agent:e.agent,className:`h-5 w-5 shrink-0`})]}),title:e.agent,headerTrailing:(0,X.jsx)(fe,{color:m.color,label:m.label}),headerActions:n?(0,X.jsx)(de,{onStop:h,ariaLabel:u(`acpRunChatView.stopRunAria`),disabled:f}):void 0,closeLabel:u(`acpRunChatView.closeRunDetail`),onClose:r})}function qe({task:e}){let{t}=b(`chat`);return e?(0,X.jsxs)(`div`,{"data-testid":`acp-chat-objective`,children:[(0,X.jsx)(ce,{as:`h3`,children:t(`acpRunChatView.objective`)}),(0,X.jsx)(le,{label:t(`acpRunChatView.objective`),children:(0,X.jsx)(g,{variant:`body-medium-lighter`,as:`p`,className:`whitespace-pre-wrap break-words leading-relaxed text-[var(--content-default)]`,children:e})}),(0,X.jsx)(`div`,{className:`mt-4 h-px w-full bg-[var(--border-hover)]`})]}):null}function Je({block:e,isTerminal:t,onOpenDiff:n,onOpenOutput:r,assistantId:i}){switch(e.kind){case`user`:return(0,X.jsx)(Le,{content:e.content});case`agent`:return(0,X.jsx)(Ce,{content:e.content,isComplete:e.isComplete||t,assistantId:i});case`thinking`:return(0,X.jsx)(Oe,{content:e.content,isComplete:e.isComplete||t,assistantId:i});case`tool`:return(0,X.jsx)(Ie,{block:e,isTerminal:t,onOpenDiff:n,onOpenOutput:r});case`plan`:return(0,X.jsx)(Z,{entries:e.entries})}}function Ye({acpSessionId:e}){let{t:n}=b(`chat`),[i,a]=(0,R.useState)(``),[o,s]=(0,R.useState)(!1);return(0,X.jsx)(`form`,{onSubmit:(0,R.useCallback)(n=>{n.preventDefault();let c=i.trim();if(!c||o)return;s(!0);let l=f.getState().appendLocalMarker({acpSessionId:e,content:`${m}${c}`});r(e,c).then(()=>a(``)).catch(n=>{l&&f.getState().removeLocalMarker({acpSessionId:e,markerId:l}),t(n,{context:`AcpRunChatView.steer`})}).finally(()=>s(!1))},[i,o,e]),"data-testid":`acp-chat-steer-form`,className:`sticky bottom-0 z-10 shrink-0 border-t border-[var(--border-hover)] bg-[var(--surface-lift)] px-5 py-3`,children:(0,X.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md bg-[var(--surface-base)] px-3 py-2`,children:[(0,X.jsx)(`input`,{type:`text`,value:i,onChange:e=>a(e.target.value),placeholder:n(`acpRunChatView.steerPlaceholder`),disabled:o,"aria-label":n(`acpRunChatView.steerAria`),className:`text-body-medium-default min-w-0 flex-1 bg-transparent text-[color:var(--content-default)] placeholder:text-[color:var(--content-tertiary)] focus:outline-none disabled:opacity-50`}),(0,X.jsx)(l,{type:`submit`,variant:`primary`,size:`compact`,iconOnly:(0,X.jsx)(ae,{}),disabled:o||i.trim()===``,"aria-label":n(`acpRunChatView.sendSteerAria`),className:`shrink-0`})]})})}function Xe({entry:e,onClose:t,assistantId:n}){return(0,X.jsx)(Ge,{entry:e,onClose:t,assistantId:n})}export{Xe as AcpRunDetailPanel};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{$b as t,Hi as n,Ui as r,Vi as i,a,c as o,d as s,eu as c,s as l,vS as u}from"./app-CGtZI7qK.js";import{f as d,r as f,t as p,x as m}from"./react-BJ4PZBJN.js";import{w as h}from"./vendor-D-45vVY0.js";var g=e(m(),1),_=p();function v(){let e=d(),{t:p}=h(`activation`),m=t.use.activeAssistantId(),v=i(),y=r(),{data:b}=n(),{starters:x,items:S}=s(v??``),{launch:C,pendingTaskIds:w}=o(v??``),T=(0,g.useMemo)(()=>[...x,...S],[x,S]),E=(0,g.useCallback)(async t=>{l(await C(t),p,t=>{c(e,t)})},[C,e,p]);return v===null?y?(0,_.jsx)(f,{to:u.assistant,replace:!0}):null:(0,_.jsx)(a,{tasks:T,progress:b?.tasks,pendingTaskIds:w,onLaunch:e=>{E(e)},onOpenConversation:t=>{c(e,t)},assistantId:m??void 0})}export{v as ActivationListRoute};
1
+ import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{$b as t,Hi as n,Ui as r,Vi as i,a,c as o,d as s,eu as c,s as l,vS as u}from"./app-CPkqAi_4.js";import{f as d,r as f,t as p,x as m}from"./react-BJ4PZBJN.js";import{w as h}from"./vendor-D-45vVY0.js";var g=e(m(),1),_=p();function v(){let e=d(),{t:p}=h(`activation`),m=t.use.activeAssistantId(),v=i(),y=r(),{data:b}=n(),{starters:x,items:S}=s(v??``),{launch:C,pendingTaskIds:w}=o(v??``),T=(0,g.useMemo)(()=>[...x,...S],[x,S]),E=(0,g.useCallback)(async t=>{l(await C(t),p,t=>{c(e,t)})},[C,e,p]);return v===null?y?(0,_.jsx)(f,{to:u.assistant,replace:!0}):null:(0,_.jsx)(a,{tasks:T,progress:b?.tasks,pendingTaskIds:w,onLaunch:e=>{E(e)},onOpenConversation:t=>{c(e,t)},assistantId:m??void 0})}export{v as ActivationListRoute};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{vS as t}from"./app-CGtZI7qK.js";import{d as n,f as r,x as i}from"./react-BJ4PZBJN.js";var a=e(i(),1);function o(){let e=r(),{search:i,hash:o}=n();return(0,a.useEffect)(()=>{e(`${t.assistant}${i}${o}`,{replace:!0})},[e,i,o]),null}export{o as ActivityRedirectPage};
1
+ import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{vS as t}from"./app-CPkqAi_4.js";import{d as n,f as r,x as i}from"./react-BJ4PZBJN.js";var a=e(i(),1);function o(){let e=r(),{search:i,hash:o}=n();return(0,a.useEffect)(()=>{e(`${t.assistant}${i}${o}`,{replace:!0})},[e,i,o]),null}export{o as ActivityRedirectPage};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{At as t,Fn as n,Gn as r,Jr as i,Mt as a,Nt as o,Qr as s,Tt as c,Vt as l,XC as u,Yn as d,_t as f,ft as p,gi as m,gt as h,jt as g,kn as _,mt as v,mv as y,nc as b,ng as x,pt as S,st as C,tg as w,vt as T,xt as E,yt as D}from"./app-CGtZI7qK.js";import{t as O,x as k}from"./react-BJ4PZBJN.js";import{w as A}from"./vendor-D-45vVY0.js";import{Ki as j,Yn as M}from"./icons-Dwi7aA1Y.js";import{l as N,n as P,o as F,t as I}from"./tool-detail-panel-JIBv6Beb.js";import{n as L,t as R}from"./step-detail-header-DUYVhdE0.js";var z=e(k(),1),B=O();function V({assistantId:e,image:t,title:r,ariaLabel:i,onPreview:a}){let o=(0,z.useRef)(null),{url:s,isError:c,isPending:u}=n(e,t,g(o)||typeof IntersectionObserver>`u`),[d,f]=(0,z.useState)(null);(0,z.useEffect)(()=>{f(null)},[t.id,t.previewUrl]);let p=s===d?null:s,m=u?null:{...t,previewUrl:p??null};return(0,B.jsx)(`div`,{ref:o,"data-testid":`activity-screenshot-tile`,"data-tool-call-id":t.toolCallId,children:(0,B.jsx)(l,{attachment:m,placeholder:c?null:(0,B.jsx)(M,{className:`h-6 w-6 animate-spin`,"aria-hidden":`true`}),labels:{title:r,ariaLabel:i,secondary:null},hideCaptions:!0,onPreview:()=>a(o.current?.firstElementChild instanceof HTMLElement?o.current.firstElementChild:null),onPreviewError:()=>f(s)})})}var H=60;function U(e,t){return W(e,t.flatMap(e=>e.kind===`tool`?[e.toolCallId]:[]))}function W(e,t,n=o){let r=new Set(t),i=new Set(e.filter(e=>r.has(e.id)&&y(e.name,e.input)).map(e=>e.id)),a=new Map;for(let t of n(e,(e,t,n)=>i.has(e.id)&&t===n))a.set(t.toolCallId,t);let s=[],c=new Set;for(let e of t){if(c.has(e))continue;let t=a.get(e);t&&(c.add(e),s.push({image:t,occurrenceKey:e}))}return s}function G({payload:e,onClose:t,assistantId:n}){return(0,B.jsx)(q,{payload:e,onClose:t,assistantId:n},K(e))}function K(e){if(e.messageId!=null){if(e.wholeTurn)return JSON.stringify([`message`,e.messageId,`turn`]);let t=e.groupToolCallIds?.[0];return JSON.stringify(t==null?[`message`,e.messageId,`index`,e.groupIndex??null]:[`message`,e.messageId,`tool`,t])}let t=e.toolCalls[0]?.id;return JSON.stringify(t==null?[`snapshot`,`index`,e.groupIndex??null]:[`snapshot`,`tool`,t])}function q({payload:e,onClose:t,assistantId:n}){let{t:i}=A(`chat`),[o,s]=(0,z.useState)(null),c=L(o),l=e.groupToolCallIds?.[0]??e.toolCalls[0]?.id,f=C(e.messageId,e.groupIndex,l,e.wholeTurn),h=f?.items??e.items,g=f?.toolCalls??e.toolCalls,y=x.use.phase(),b=f?f.isLastGroup&&f.isLatestMessage:e.messageId==null,T=v(h,{active:e.active===!0&&b&&w(y)}),D=(0,z.useMemo)(()=>h.flatMap(e=>e.kind===`toolCall`?[e.toolCall.id]:[]),[h]),O=(0,z.useMemo)(()=>a(),[]),k=(0,z.useMemo)(()=>W(g,D,O),[g,D,O]),M=(0,z.useMemo)(()=>k.map(e=>e.occurrenceKey),[k]),N=(0,z.useMemo)(()=>new Map(k.map((e,t)=>[e.occurrenceKey,t])),[k]),I=(0,z.useMemo)(()=>k.map(e=>e.image),[k]),H=(0,z.useRef)(null),{openPreview:U,previewModal:G}=_(n,I,M,{scopeKey:`${n??``}:${e.messageId??``}:${l??e.groupIndex??``}`,getFallbackFocus:()=>H.current?.querySelector(`button, [role="button"][tabindex="0"]`)??null}),K=S(T.state,T.steps),q=K===`loading`,Z=p(i,K,T),Q=q&&T.currentStepTitle||Z,$=(0,z.useMemo)(()=>new Map(g.map(e=>[e.id,e])),[g]);return(0,B.jsx)(`div`,{ref:H,className:`contents`,children:(0,B.jsxs)(r,{icon:o?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(u,{variant:`outlined`,iconOnly:(0,B.jsx)(j,{}),"aria-label":i(`activityStepsPanel.backAria`),tooltip:i(`activityStepsPanel.backTooltip`),onClick:()=>s(null),className:`shrink-0`}),(0,B.jsx)(R,{detail:o,source:F})]}):void 0,title:c,titleNode:o?o.kind===`thinking`?void 0:(0,B.jsx)(P,{detail:o,source:F}):(0,B.jsx)(d,{title:q?(0,B.jsx)(m,{children:Q}):Q,count:T.stepCount}),closeLabel:i(`activityStepsPanel.closeSteps`),onClose:t,children:[o?(0,B.jsx)(X,{detail:o,assistantId:n}):(0,B.jsx)(E,{steps:T.steps,timeline:!0,renderStep:t=>(0,B.jsx)(Y,{step:t,activeDetail:o,onOpenDetail:s,lookupToolCall:e=>$.get(e),messageId:e.wholeTurn?void 0:e.messageId,groupIndex:f?.groupIndex??e.groupIndex}),renderPhaseFooter:e=>{let t=J(e,k,N);if(!t)return null;let{entry:r,step:a,index:o}=t,s=a.activity?.trim(),c=s?i(`activityStepsPanel.screenshotTitle`,{activity:s}):i(`activityStepsPanel.screenshotFallbackTitle`),l=s?i(`activityStepsPanel.screenshotAria`,{activity:s}):i(`activityStepsPanel.screenshotFallbackAria`);return(0,B.jsx)(V,{assistantId:n,image:r.image,title:c,ariaLabel:l,onPreview:e=>U(r.image,o,e)})}}),G]})})}function J(e,t,n){if(!c(e.label))return null;for(let r=e.steps.length-1;r>=0;--r){let i=e.steps[r];if(i?.kind!==`tool`)continue;let a=n.get(i.toolCallId);if(a!==void 0)return{entry:t[a],step:i,index:a}}return null}function Y({step:e,activeDetail:n,onOpenDetail:r,lookupToolCall:a,messageId:o,groupIndex:c}){let{t:l}=A(`chat`),u=t();if(e.kind===`thinking`){let t=o!=null&&e.thinkingItemIndex!=null?{messageId:o,thinkingGroupIndex:c,thinkingItemIndex:e.thinkingItemIndex}:{};return(0,B.jsx)(T,{iconName:`brain`,label:b(s(e.text),H),ariaLabel:l(`activityStepsPanel.viewThinkingAria`),active:!1,onClick:()=>r({kind:`thinking`,toolCallId:``,toolName:``,title:l(`thinkingDetail.title`),activity:``,input:{},status:`completed`,thinkingText:e.text,...t})})}if(e.kind===`web_search`)return(0,B.jsx)(f,{step:e});if(e.kind===`web_search_error`)return(0,B.jsx)(h,{step:e});if(e.kind!==`tool`)return(0,B.jsx)(D,{step:e});let d=a(e.toolCallId);return(0,B.jsx)(T,{iconName:e.iconName,label:u({activity:e.activity,actionDisplayKey:e.actionDisplayKey,fallback:e.activity||e.info||e.title}),active:n?.toolCallId===e.toolCallId,onClick:()=>{d&&r(i(d))}})}function X({detail:e,assistantId:t}){return e.kind===`thinking`?(0,B.jsx)(N,{detail:e,assistantId:t}):(0,B.jsx)(I,{detail:e,source:F,assistantId:t})}export{G as ActivityStepsPanel,U as buildActivityScreenshotGallery};
1
+ import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{At as t,Fn as n,Gn as r,Jr as i,Mt as a,Nt as o,Qr as s,Tt as c,Vt as l,XC as u,Yn as d,_t as f,ft as p,gi as m,gt as h,jt as g,kn as _,mt as v,mv as y,nc as b,ng as x,pt as S,st as C,tg as w,vt as T,xt as E,yt as D}from"./app-CPkqAi_4.js";import{t as O,x as k}from"./react-BJ4PZBJN.js";import{w as A}from"./vendor-D-45vVY0.js";import{Ki as j,Yn as M}from"./icons-Dwi7aA1Y.js";import{l as N,n as P,o as F,t as I}from"./tool-detail-panel-C2W_9tyR.js";import{n as L,t as R}from"./step-detail-header-BuPH_i5-.js";var z=e(k(),1),B=O();function V({assistantId:e,image:t,title:r,ariaLabel:i,onPreview:a}){let o=(0,z.useRef)(null),{url:s,isError:c,isPending:u}=n(e,t,g(o)||typeof IntersectionObserver>`u`),[d,f]=(0,z.useState)(null);(0,z.useEffect)(()=>{f(null)},[t.id,t.previewUrl]);let p=s===d?null:s,m=u?null:{...t,previewUrl:p??null};return(0,B.jsx)(`div`,{ref:o,"data-testid":`activity-screenshot-tile`,"data-tool-call-id":t.toolCallId,children:(0,B.jsx)(l,{attachment:m,placeholder:c?null:(0,B.jsx)(M,{className:`h-6 w-6 animate-spin`,"aria-hidden":`true`}),labels:{title:r,ariaLabel:i,secondary:null},hideCaptions:!0,onPreview:()=>a(o.current?.firstElementChild instanceof HTMLElement?o.current.firstElementChild:null),onPreviewError:()=>f(s)})})}var H=60;function U(e,t){return W(e,t.flatMap(e=>e.kind===`tool`?[e.toolCallId]:[]))}function W(e,t,n=o){let r=new Set(t),i=new Set(e.filter(e=>r.has(e.id)&&y(e.name,e.input)).map(e=>e.id)),a=new Map;for(let t of n(e,(e,t,n)=>i.has(e.id)&&t===n))a.set(t.toolCallId,t);let s=[],c=new Set;for(let e of t){if(c.has(e))continue;let t=a.get(e);t&&(c.add(e),s.push({image:t,occurrenceKey:e}))}return s}function G({payload:e,onClose:t,assistantId:n}){return(0,B.jsx)(q,{payload:e,onClose:t,assistantId:n},K(e))}function K(e){if(e.messageId!=null){if(e.wholeTurn)return JSON.stringify([`message`,e.messageId,`turn`]);let t=e.groupToolCallIds?.[0];return JSON.stringify(t==null?[`message`,e.messageId,`index`,e.groupIndex??null]:[`message`,e.messageId,`tool`,t])}let t=e.toolCalls[0]?.id;return JSON.stringify(t==null?[`snapshot`,`index`,e.groupIndex??null]:[`snapshot`,`tool`,t])}function q({payload:e,onClose:t,assistantId:n}){let{t:i}=A(`chat`),[o,s]=(0,z.useState)(null),c=L(o),l=e.groupToolCallIds?.[0]??e.toolCalls[0]?.id,f=C(e.messageId,e.groupIndex,l,e.wholeTurn),h=f?.items??e.items,g=f?.toolCalls??e.toolCalls,y=x.use.phase(),b=f?f.isLastGroup&&f.isLatestMessage:e.messageId==null,T=v(h,{active:e.active===!0&&b&&w(y)}),D=(0,z.useMemo)(()=>h.flatMap(e=>e.kind===`toolCall`?[e.toolCall.id]:[]),[h]),O=(0,z.useMemo)(()=>a(),[]),k=(0,z.useMemo)(()=>W(g,D,O),[g,D,O]),M=(0,z.useMemo)(()=>k.map(e=>e.occurrenceKey),[k]),N=(0,z.useMemo)(()=>new Map(k.map((e,t)=>[e.occurrenceKey,t])),[k]),I=(0,z.useMemo)(()=>k.map(e=>e.image),[k]),H=(0,z.useRef)(null),{openPreview:U,previewModal:G}=_(n,I,M,{scopeKey:`${n??``}:${e.messageId??``}:${l??e.groupIndex??``}`,getFallbackFocus:()=>H.current?.querySelector(`button, [role="button"][tabindex="0"]`)??null}),K=S(T.state,T.steps),q=K===`loading`,Z=p(i,K,T),Q=q&&T.currentStepTitle||Z,$=(0,z.useMemo)(()=>new Map(g.map(e=>[e.id,e])),[g]);return(0,B.jsx)(`div`,{ref:H,className:`contents`,children:(0,B.jsxs)(r,{icon:o?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(u,{variant:`outlined`,iconOnly:(0,B.jsx)(j,{}),"aria-label":i(`activityStepsPanel.backAria`),tooltip:i(`activityStepsPanel.backTooltip`),onClick:()=>s(null),className:`shrink-0`}),(0,B.jsx)(R,{detail:o,source:F})]}):void 0,title:c,titleNode:o?o.kind===`thinking`?void 0:(0,B.jsx)(P,{detail:o,source:F}):(0,B.jsx)(d,{title:q?(0,B.jsx)(m,{children:Q}):Q,count:T.stepCount}),closeLabel:i(`activityStepsPanel.closeSteps`),onClose:t,children:[o?(0,B.jsx)(X,{detail:o,assistantId:n}):(0,B.jsx)(E,{steps:T.steps,timeline:!0,renderStep:t=>(0,B.jsx)(Y,{step:t,activeDetail:o,onOpenDetail:s,lookupToolCall:e=>$.get(e),messageId:e.wholeTurn?void 0:e.messageId,groupIndex:f?.groupIndex??e.groupIndex}),renderPhaseFooter:e=>{let t=J(e,k,N);if(!t)return null;let{entry:r,step:a,index:o}=t,s=a.activity?.trim(),c=s?i(`activityStepsPanel.screenshotTitle`,{activity:s}):i(`activityStepsPanel.screenshotFallbackTitle`),l=s?i(`activityStepsPanel.screenshotAria`,{activity:s}):i(`activityStepsPanel.screenshotFallbackAria`);return(0,B.jsx)(V,{assistantId:n,image:r.image,title:c,ariaLabel:l,onPreview:e=>U(r.image,o,e)})}}),G]})})}function J(e,t,n){if(!c(e.label))return null;for(let r=e.steps.length-1;r>=0;--r){let i=e.steps[r];if(i?.kind!==`tool`)continue;let a=n.get(i.toolCallId);if(a!==void 0)return{entry:t[a],step:i,index:a}}return null}function Y({step:e,activeDetail:n,onOpenDetail:r,lookupToolCall:a,messageId:o,groupIndex:c}){let{t:l}=A(`chat`),u=t();if(e.kind===`thinking`){let t=o!=null&&e.thinkingItemIndex!=null?{messageId:o,thinkingGroupIndex:c,thinkingItemIndex:e.thinkingItemIndex}:{};return(0,B.jsx)(T,{iconName:`brain`,label:b(s(e.text),H),ariaLabel:l(`activityStepsPanel.viewThinkingAria`),active:!1,onClick:()=>r({kind:`thinking`,toolCallId:``,toolName:``,title:l(`thinkingDetail.title`),activity:``,input:{},status:`completed`,thinkingText:e.text,...t})})}if(e.kind===`web_search`)return(0,B.jsx)(f,{step:e});if(e.kind===`web_search_error`)return(0,B.jsx)(h,{step:e});if(e.kind!==`tool`)return(0,B.jsx)(D,{step:e});let d=a(e.toolCallId);return(0,B.jsx)(T,{iconName:e.iconName,label:u({activity:e.activity,actionDisplayKey:e.actionDisplayKey,fallback:e.activity||e.info||e.title}),active:n?.toolCallId===e.toolCallId,onClick:()=>{d&&r(i(d))}})}function X({detail:e,assistantId:t}){return e.kind===`thinking`?(0,B.jsx)(N,{detail:e,assistantId:t}):(0,B.jsx)(I,{detail:e,source:F,assistantId:t})}export{G as ActivityStepsPanel,U as buildActivityScreenshotGallery};
@@ -0,0 +1 @@
1
+ import{t as e}from"./add-credits-modal-VxmEbPrZ.js";export{e as AddCreditsModal};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{Bd as t,By as n,Rd as r,XC as i,gf as a,kC as o,lC as s,pC as c,tw as l,vS as u,zy as d}from"./app-CGtZI7qK.js";import{_ as f,d as p,n as m,t as h,x as g}from"./react-BJ4PZBJN.js";import{Jn as _,Zn as v,w as y}from"./vendor-D-45vVY0.js";import{Gi as b,Ui as x}from"./icons-Dwi7aA1Y.js";import{n as S}from"./android-billing-handoff-BIE4-ZmX.js";import{t as C}from"./checkout-return-target-Dzek3DVO.js";var w=e(g(),1),T=h(),E=[`10.00`,`20.00`,`30.00`,`40.00`,`50.00`,`60.00`,`70.00`,`80.00`,`90.00`,`100.00`];function D(e){let t=parseFloat(e);if(Number.isNaN(t))return`0 credits`;let n=t.toLocaleString(`en-US`,{minimumFractionDigits:2,maximumFractionDigits:2});return`${n.endsWith(`.00`)?n.slice(0,-3):n} credits`}function O(e){if(e&&typeof e==`object`){let t=e.amount;if(Array.isArray(t)&&typeof t[0]==`string`)return t[0]}return`Failed to create checkout session. Please try again.`}function k({open:e,onOpenChange:h}){let{t:g}=y(),{pathname:S}=p(),[k]=f(),A=k.toString()?`${S}?${k.toString()}`:S,{data:j,isLoading:M}=v(r()),N=j?.allowed_top_up_amounts?.length?j.allowed_top_up_amounts:E,[P,F]=(0,w.useState)(null),I=P&&N.includes(P)?P:N[0]??E[0],L=_(t());return(0,w.useEffect)(()=>n(()=>{h(!1)}),[h]),a(`deeplink.billingCheckoutComplete`,({flow:e})=>{e===`top_up`&&h(!1)}),(0,T.jsx)(c.Root,{open:e,onOpenChange:h,children:(0,T.jsxs)(c.Content,{size:`sm`,children:[(0,T.jsxs)(c.Header,{children:[(0,T.jsx)(c.Title,{children:g(`addCreditsModal.title`)}),(0,T.jsx)(c.Description,{children:g(`addCreditsModal.description`)})]}),(0,T.jsx)(c.Body,{children:(0,T.jsxs)(`div`,{className:`space-y-4`,children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`label`,{htmlFor:`add-credits-amount`,className:`block text-body-small-default text-[var(--content-tertiary)]`,children:g(`addCreditsModal.amount`)}),(0,T.jsx)(s,{id:`add-credits-amount`,value:I,onChange:e=>{F(e),L.isError&&L.reset()},disabled:M||!j,options:N.map(e=>({value:e,label:D(e)}))})]}),L.isError&&(0,T.jsxs)(`div`,{className:`flex items-center gap-2 text-body-small-default text-[var(--system-negative-strong)]`,children:[(0,T.jsx)(x,{className:`h-3.5 w-3.5 shrink-0`}),O(L.error)]}),(0,T.jsxs)(m,{to:u.settings.usageBillingConfigureTopUps,className:l(o({tone:`quiet`}),`flex items-center gap-1 text-body-small-default text-[var(--content-tertiary)]`),onClick:()=>h(!1),children:[g(`addCreditsModal.configureAutoReload`),(0,T.jsx)(b,{className:`size-4`})]}),(0,T.jsx)(`div`,{className:`h-px w-full bg-[var(--border-subtle)]`})]})}),(0,T.jsxs)(c.Footer,{children:[(0,T.jsx)(c.Close,{asChild:!0,children:(0,T.jsx)(i,{variant:`outlined`,children:g(`addCreditsModal.cancel`)})}),(0,T.jsx)(i,{variant:`primary`,loading:L.isPending,onClick:()=>{L.isPending||L.mutate({body:{amount:I,return_path:A,return_target:C()}},{onSuccess:e=>{d(e.checkout_url)}})},disabled:L.isPending||M||!j,children:g(`addCreditsModal.continue`)})]})]})})}function A(e){return S({open:e.open,path:u.settings.usageBilling,onClose:()=>e.onOpenChange(!1)})?null:(0,T.jsx)(k,{...e})}export{A as t};
1
+ import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{Bd as t,By as n,Rd as r,XC as i,gf as a,kC as o,lC as s,pC as c,tw as l,vS as u,zy as d}from"./app-CPkqAi_4.js";import{_ as f,d as p,n as m,t as h,x as g}from"./react-BJ4PZBJN.js";import{Jn as _,Zn as v,w as y}from"./vendor-D-45vVY0.js";import{Gi as b,Ui as x}from"./icons-Dwi7aA1Y.js";import{n as S}from"./android-billing-handoff-C7UYsPiM.js";import{t as C}from"./checkout-return-target-BskCWo4q.js";var w=e(g(),1),T=h(),E=[`10.00`,`20.00`,`30.00`,`40.00`,`50.00`,`60.00`,`70.00`,`80.00`,`90.00`,`100.00`];function D(e){let t=parseFloat(e);if(Number.isNaN(t))return`0 credits`;let n=t.toLocaleString(`en-US`,{minimumFractionDigits:2,maximumFractionDigits:2});return`${n.endsWith(`.00`)?n.slice(0,-3):n} credits`}function O(e){if(e&&typeof e==`object`){let t=e.amount;if(Array.isArray(t)&&typeof t[0]==`string`)return t[0]}return`Failed to create checkout session. Please try again.`}function k({open:e,onOpenChange:h}){let{t:g}=y(),{pathname:S}=p(),[k]=f(),A=k.toString()?`${S}?${k.toString()}`:S,{data:j,isLoading:M}=v(r()),N=j?.allowed_top_up_amounts?.length?j.allowed_top_up_amounts:E,[P,F]=(0,w.useState)(null),I=P&&N.includes(P)?P:N[0]??E[0],L=_(t());return(0,w.useEffect)(()=>n(()=>{h(!1)}),[h]),a(`deeplink.billingCheckoutComplete`,({flow:e})=>{e===`top_up`&&h(!1)}),(0,T.jsx)(c.Root,{open:e,onOpenChange:h,children:(0,T.jsxs)(c.Content,{size:`sm`,children:[(0,T.jsxs)(c.Header,{children:[(0,T.jsx)(c.Title,{children:g(`addCreditsModal.title`)}),(0,T.jsx)(c.Description,{children:g(`addCreditsModal.description`)})]}),(0,T.jsx)(c.Body,{children:(0,T.jsxs)(`div`,{className:`space-y-4`,children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`label`,{htmlFor:`add-credits-amount`,className:`block text-body-small-default text-[var(--content-tertiary)]`,children:g(`addCreditsModal.amount`)}),(0,T.jsx)(s,{id:`add-credits-amount`,value:I,onChange:e=>{F(e),L.isError&&L.reset()},disabled:M||!j,options:N.map(e=>({value:e,label:D(e)}))})]}),L.isError&&(0,T.jsxs)(`div`,{className:`flex items-center gap-2 text-body-small-default text-[var(--system-negative-strong)]`,children:[(0,T.jsx)(x,{className:`h-3.5 w-3.5 shrink-0`}),O(L.error)]}),(0,T.jsxs)(m,{to:u.settings.usageBillingConfigureTopUps,className:l(o({tone:`quiet`}),`flex items-center gap-1 text-body-small-default text-[var(--content-tertiary)]`),onClick:()=>h(!1),children:[g(`addCreditsModal.configureAutoReload`),(0,T.jsx)(b,{className:`size-4`})]}),(0,T.jsx)(`div`,{className:`h-px w-full bg-[var(--border-subtle)]`})]})}),(0,T.jsxs)(c.Footer,{children:[(0,T.jsx)(c.Close,{asChild:!0,children:(0,T.jsx)(i,{variant:`outlined`,children:g(`addCreditsModal.cancel`)})}),(0,T.jsx)(i,{variant:`primary`,loading:L.isPending,onClick:()=>{L.isPending||L.mutate({body:{amount:I,return_path:A,return_target:C()}},{onSuccess:e=>{d(e.checkout_url)}})},disabled:L.isPending||M||!j,children:g(`addCreditsModal.continue`)})]})]})})}function A(e){return S({open:e.open,path:u.settings.usageBilling,onClose:()=>e.onOpenChange(!1)})?null:(0,T.jsx)(k,{...e})}export{A as t};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{$ as t,Ab as n,As as r,Bb as i,Bf as a,Bp as o,Bv as s,CC as c,Cb as l,Cr as u,DC as d,DS as f,Db as p,Dm as m,Dr as h,Ds as g,Dv as _,Eb as v,Em as y,Er as b,Es as x,Fb as S,Fs as C,Fy as w,G as T,GC as E,Gb as D,Gf as O,Gn as k,Gs as A,Gt as j,HC as M,Hb as N,Hf as ee,Hs as P,IC as F,Ib as I,Iv as te,Jb as L,Ji as ne,Kb as R,Kf as re,LS as z,Lb as ie,Lg as ae,Ls as oe,Mb as se,Mm as ce,Mo as B,Ms as le,NS as ue,Nb as de,Ng as fe,No as pe,Ns as me,Ob as he,Os as ge,Pb as _e,Pg as ve,Ps as ye,QC as be,Qm as xe,Rb as Se,Rp as Ce,Rs as we,Sr as Te,TC as V,Tb as Ee,Tr as De,Ub as Oe,Uf as ke,Us as Ae,VS as H,Vb as je,Vf as Me,Vp as Ne,Vs as Pe,Vv as Fe,Wb as Ie,Wf as Le,Ws as Re,X as ze,XC as U,Xb as Be,Y as Ve,Yb as He,Yi as Ue,ZS as We,Zb as Ge,Zm as Ke,_p as qe,ah as Je,ap as Ye,by as Xe,ch as Ze,dC as Qe,dh as $e,fC as W,fh as et,gp as tt,gv as nt,hm as rt,hp as it,iC as at,ih as ot,in as st,ip as ct,iy as lt,jC as ut,jb as dt,jo as ft,js as pt,kb as mt,ks as ht,lC as G,lh as gt,mm as _t,mp as vt,np as yt,nu as bt,oh as xt,op as St,pC as K,pm as Ct,pp as wt,q as Tt,qb as Et,qf as Dt,qn as Ot,rh as kt,rp as At,sh as jt,tS as Mt,th as Nt,tp as Pt,uh as Ft,vg as It,vp as Lt,wC as Rt,wb as zt,wr as Bt,yp as Vt,zC as q,zS as Ht,zb as Ut,zm as Wt,zp as Gt,zs as Kt}from"./app-CGtZI7qK.js";import{b as qt,t as Jt,x as Yt}from"./react-BJ4PZBJN.js";import{E as Xt,Jn as Zt,Zn as J,er as Y,k as X,w as Z}from"./vendor-D-45vVY0.js";import{A as Qt,D as $t,Lt as en,Ui as tn,Xn as nn,Yn as rn,Zr as an,fr as on,vt as sn}from"./icons-Dwi7aA1Y.js";import{t as cn}from"./ellipsis-vertical-DXwTXFid.js";import{i as ln,n as un,r as dn,t as fn}from"./service-form-controls-Bf_KfPWP.js";import{o as pn}from"./detail-primitives-BZtYI-6o.js";import{d as mn,o as hn,u as gn}from"./schedules-BzC-XvXW.js";import{t as _n}from"./stt-language-picker-modal-DLBjdKim.js";var Q=e(Yt(),1);function vn(){let e=T();return(0,Q.useCallback)(async(t,n)=>{try{let{data:r}=await Xe({path:{assistant_id:e},body:{value:n,type:`api_key`,name:t},throwOnError:!0});zt(r)}catch(e){throw e instanceof Error&&e.message===`No assistant found`?W.error(X(`settings:useDaemonConfig.assistantNotReadyToast`)):W.error(X(`settings:useDaemonConfig.saveApiKeyFailedToast`,{providerName:t})),f(e,{context:`provision_provider_key`}),e}},[e])}function yn(e){let[t,n]=(0,Q.useState)(void 0);return(0,Q.useEffect)(()=>{t!==void 0&&e===t.value&&n(void 0)},[e,t]),[t===void 0?e:t.value,(0,Q.useCallback)(e=>n(e===void 0?void 0:{value:e}),[])]}var bn=`0.11.0`;function xn(){return fe(bn)}var $=Jt(),Sn=`gemini-3.1-flash-image-preview`;function Cn(e,t){return e===`openrouter`?`openrouter`:Ae(t)}function wn(){let{t:e}=Z(`settings`),t=T(),n=Y(),r=Nt(),{data:i}=J({...wt({path:{assistant_id:t}}),enabled:r,staleTime:3e4}),a=ce({onSuccess:e=>{it(n,{path:{assistant_id:t}},e)}}),o=vn(),s=i?.services?.[`image-generation`],c=(0,Q.useMemo)(()=>i?s?.mode===`managed`?`cadet`:s?.provider||z(`cadet:ai:imageGenProvider`,`gemini`):z(g,`gemini`),[i,s?.mode,s?.provider]),[l,u]=yn(c),[d,p]=(0,Q.useState)(()=>z(x,Sn)),[m,h]=(0,Q.useState)(null),_=c===`openrouter`&&typeof s?.model==`string`?s.model:void 0,v=m??_??z(`cadet:ai:imageGenModel`,`google/gemini-3.1-flash-image-preview`),y=l===`openrouter`,b=P(l),S=y?v.trim()||`google/gemini-3.1-flash-image-preview`:b.includes(d)?d:b[0]??Sn,[w,E]=(0,Q.useState)(``),[D,O]=(0,Q.useState)(!1),k=we.map(e=>({value:e,label:Kt[e]??e})),A=(0,Q.useMemo)(()=>P(l).map(e=>({value:e,label:oe[e]??e})),[l]),j=l===`gemini`||l===`openai`||l===`openrouter`,{hasStoredCredential:M}=xe({assistantId:t,credentialKind:`api_key`,credentialName:l,enabled:j}),N=(0,Q.useCallback)(e=>{u(e),e===`openrouter`&&m===null&&h(_??`google/gemini-3.1-flash-image-preview`)},[m,_,u]),ee=(0,Q.useCallback)(async()=>{O(!0);let r=w.trim(),i=j&&r.length>0;try{await ae(),i&&await o(Cn(l,S),r);let s=l===`cadet`&&!xn()?{mode:`managed`}:{provider:l,mode:l===`cadet`?`managed`:`your-own`};await a.mutateAsync({path:{assistant_id:t},body:{services:{"image-generation":s}}}).catch(t=>{throw W.error(e(`imageGenerationCard.configUpdateFailedToast`)),f(t,{context:`patch_daemon_config`}),t});try{await lt({path:{assistant_id:t},body:{modelId:S},throwOnError:!0})}catch(t){throw W.error(e(`imageGenerationCard.modelUpdateFailedToast`)),f(t,{context:`set_image_gen_model`}),t}finally{n.invalidateQueries({queryKey:vt({path:{assistant_id:t}})})}}catch{O(!1);return}O(!1);try{if(H(g,l),H(x,S),i){let e=Ke(t,`api_key`,l);n.setQueryData(e,!0),n.invalidateQueries({queryKey:e}),E(``)}W.success(e(`imageGenerationCard.savedToast`))}catch(t){f(t,{context:`settings-ai-image-gen-persist-local`}),W.error(e(`imageGenerationCard.localPreferencesFailedToast`))}},[w,l,j,S,t,a,o,n,e]),F=(0,Q.useCallback)(()=>{if(E(``),l===`openrouter`){h(C),H(x,C);return}p(Sn),H(x,Sn)},[l]),I=e(l===`openai`?`imageGenerationCard.openaiApiKeyPlaceholder`:l===`openrouter`?`imageGenerationCard.openrouterApiKeyPlaceholder`:`imageGenerationCard.geminiApiKeyPlaceholder`);return(0,$.jsx)(ln,{title:e(`imageGenerationCard.title`),subtitle:e(`imageGenerationCard.subtitle`),children:(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:e(`imageGenerationCard.providerLabel`)}),(0,$.jsx)(G,{"aria-label":e(`imageGenerationCard.providerAriaLabel`),value:l,onChange:N,options:k})]}),l===`cadet`&&(0,$.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:e(`imageGenerationCard.cadetNote`)}),j&&(0,$.jsx)(V,{label:e(`imageGenerationCard.apiKeyLabel`),type:`password`,value:w,onChange:e=>E(e.target.value),placeholder:At(I,M),fullWidth:!0}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:e(`imageGenerationCard.activeModelLabel`)}),y?(0,$.jsx)(V,{"aria-label":e(`imageGenerationCard.modelAriaLabel`),value:v,onChange:e=>h(e.target.value),placeholder:e(`imageGenerationCard.openrouterModelPlaceholder`),fullWidth:!0}):(0,$.jsx)(G,{"aria-label":e(`imageGenerationCard.modelAriaLabel`),value:S,onChange:p,options:A})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(dn,{onClick:ee,disabled:D}),D&&(0,$.jsx)(rn,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`}),j&&(0,$.jsx)(un,{onClick:F})]})]})})}function Tn({title:e,count:t,action:n,children:r}){return(0,$.jsxs)(`section`,{className:`rounded-xl border border-[var(--border-hover)] bg-[var(--surface-overlay)] px-3 py-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,$.jsx)(q,{variant:`body-large-default`,as:`h3`,className:`text-[var(--content-secondary)]`,children:e}),t==null?null:(0,$.jsxs)(q,{variant:`body-large-default`,as:`span`,"aria-label":`${t} ${e.toLowerCase()}`,className:`text-[var(--content-disabled)]`,children:[`·`,` `,t]})]}),n]}),r==null?null:(0,$.jsx)(`div`,{className:`mt-4 border-t border-[var(--border-base)]`,children:r})]})}function En(e){return e.scheduleNames.length>0||e.deferredReminderCount>0||e.scheduleLookupFailed}var Dn=5;function On({title:e,items:t,mono:n}){return(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(q,{variant:`body-small-default`,as:`p`,className:`text-(--content-tertiary)`,children:e}),(0,$.jsx)(`ul`,{className:`space-y-1 pl-1`,children:t.map(e=>(0,$.jsxs)(`li`,{className:`text-body-small-default text-(--content-secondary)`,children:[`• `,n?(0,$.jsx)(`code`,{children:e}):e]},e))})]})}function kn(e){let t=e.label||e.name,n=[];e.isActive&&n.push(X(`settings:manageProfilesBlockedDeleteModal.clauseDefaultProfile`)),e.callSiteIds.length>0&&n.push(X(`settings:manageProfilesBlockedDeleteModal.clauseActionOverrides`,{count:e.callSiteIds.length}));let r=e.scheduleNames.length,i=e.deferredReminderCount;return r>0&&i>0?n.push(X(`settings:manageProfilesBlockedDeleteModal.clauseRunsBoth`,{schedules:r,reminders:i})):r>0?n.push(X(`settings:manageProfilesBlockedDeleteModal.clauseRunsSchedules`,{count:r})):i>0&&n.push(X(`settings:manageProfilesBlockedDeleteModal.clauseRunsReminders`,{count:i})),n.length===0?X(`settings:manageProfilesBlockedDeleteModal.summaryNoReferences`,{display:t}):n.length===1?X(`settings:manageProfilesBlockedDeleteModal.summaryOneClause`,{display:t,clause1:n[0]}):n.length===2?X(`settings:manageProfilesBlockedDeleteModal.summaryTwoClauses`,{display:t,clause1:n[0],clause2:n[1]}):X(`settings:manageProfilesBlockedDeleteModal.summaryThreeClauses`,{display:t,clause1:n[0],clause2:n[1],clause3:n[2]})}function An({blocked:e,availableReplacements:t,replacement:n,onReplacementChange:r,error:i,saving:a,onClose:o,onConfirm:s}){let{t:c}=Z(`settings`),l=e?.scheduleNames??[],u=l.slice(0,Dn),d=l.length-u.length,f=e!=null&&En(e);return(0,$.jsx)(K.Root,{open:e!==null,onOpenChange:e=>{e||o()},children:(0,$.jsxs)(K.Content,{size:`sm`,children:[(0,$.jsx)(K.Header,{children:(0,$.jsx)(K.Title,{children:c(`manageProfilesBlockedDeleteModal.title`)})}),(0,$.jsxs)(K.Body,{className:`space-y-4`,children:[e&&(0,$.jsx)(q,{variant:`body-medium-default`,as:`p`,children:kn(e)}),e&&e.callSiteIds.length>0&&(0,$.jsx)(On,{title:c(`manageProfilesBlockedDeleteModal.actionOverridesTitle`),items:e.callSiteIds,mono:!0}),u.length>0&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(On,{title:c(`manageProfilesBlockedDeleteModal.schedulesTitle`),items:u}),d>0&&(0,$.jsx)(q,{variant:`body-small-default`,as:`p`,className:`pl-1 text-(--content-tertiary)`,children:c(`manageProfilesBlockedDeleteModal.moreSchedules`,{count:d})})]}),e?.scheduleLookupFailed&&(0,$.jsx)(q,{variant:`body-small-default`,as:`p`,className:`text-(--system-mid-strong)`,children:c(`manageProfilesBlockedDeleteModal.scheduleLookupFailed`)}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-(--content-tertiary)`,children:c(`manageProfilesBlockedDeleteModal.replacementLabel`)}),(0,$.jsx)(G,{"aria-label":c(`manageProfilesBlockedDeleteModal.replacementLabel`),value:n,onChange:r,placeholder:c(`manageProfilesBlockedDeleteModal.replacementPlaceholder`),options:t.map(e=>{let t=f&&e.status===`disabled`;return{value:e.name,label:Bt(e),disabled:t,tooltip:t?c(`manageProfilesBlockedDeleteModal.disabledTargetTooltip`):void 0}})})]}),i&&(0,$.jsx)(q,{variant:`body-small-default`,as:`p`,className:`text-(--system-negative-strong)`,children:i})]}),(0,$.jsxs)(K.Footer,{children:[(0,$.jsx)(U,{variant:`ghost`,size:`compact`,onClick:o,children:c(`manageProfilesBlockedDeleteModal.cancel`)}),(0,$.jsx)(U,{variant:`primary`,size:`compact`,disabled:!n||a,onClick:s,children:c(a?`manageProfilesBlockedDeleteModal.saving`:`manageProfilesBlockedDeleteModal.reassignAndDelete`)})]})]})})}function jn({profile:e,isActiveProfile:t,selected:n,connections:r,deletePending:i=!1,onOpen:a,onMakeActive:o,onSetStatus:s,onDelete:c}){let{t:l}=Z(`settings`),u=e.source===`managed`,d=e.status===`disabled`,f=e.label??e.name,p=[];e.name===`auto`&&u?p.push(l(`profileRow.autoRouting`)):e.model&&p.push(ke(e.provider??void 0,e.model,r)),u&&p.push(l(`profileRow.managedByCadet`));let m=e.availability,h=e.config_issue,g=h!=null||m?.status===`incomplete`,_=m?.message??l(`profileRow.providerUnavailableDefault`),v=h==null?m!=null&&m.status!==`ok`?g?l(`profileRow.providerUnavailableFixable`,{message:_}):_:null:l(`profileRow.providerUnavailableFixable`,{message:l(h.code===`over_output_cap`?`profileRow.configIssueOverOutputCap`:h.code===`no_input_room`?`profileRow.configIssueNoInputRoom`:`profileRow.configIssueModelUnknown`)});return(0,$.jsx)(We,{title:(0,$.jsx)(`span`,{className:d?`opacity-55`:void 0,children:f}),subtitle:p.length>0?p.join(` • `):void 0,onClick:a,showChevron:!1,selected:n,disabled:i,contentAriaLabel:l(`profileRow.openProfileAriaLabel`,{displayName:f}),trailingInteractive:!0,trailing:(0,$.jsxs)($.Fragment,{children:[v==null?null:(0,$.jsx)(be,{content:v,children:g?(0,$.jsx)(U,{variant:`ghost`,size:`compact`,iconOnly:(0,$.jsx)(tn,{}),iconOnlyGlyphClassName:`[&_svg]:size-4`,tintColor:`var(--system-mid-strong)`,expandOnMobile:!1,onClick:a,"aria-label":v}):(0,$.jsx)(`span`,{className:`inline-flex p-0.5`,tabIndex:0,children:(0,$.jsx)(tn,{className:`h-4 w-4 text-[var(--system-mid-strong)]`,"aria-label":v,role:`img`})})}),d?(0,$.jsx)(ut,{tone:`neutral`,children:l(`profileRow.disabledTag`)}):null,t?(0,$.jsx)(ut,{tone:`positive`,children:l(`profileRow.defaultTag`)}):null,(0,$.jsxs)(E.Root,{children:[(0,$.jsx)(E.Trigger,{asChild:!0,children:(0,$.jsx)(U,{variant:`ghost`,size:`compact`,iconOnly:(0,$.jsx)(cn,{}),"aria-label":l(`profileRow.actionsAriaLabel`,{displayName:f}),disabled:i})}),(0,$.jsxs)(E.Content,{align:`end`,sideOffset:4,children:[(0,$.jsx)(E.Item,{onSelect:a,children:l(u?`profileRow.view`:`profileRow.edit`)}),!t&&!d&&L(e.provider,e.model)?(0,$.jsx)(E.Item,{onSelect:o,children:l(`profileRow.makeDefault`)}):null,d?(0,$.jsx)(E.Item,{onSelect:()=>s(!0),children:l(`profileRow.enable`)}):u?null:(0,$.jsx)(E.Item,{onSelect:()=>s(!1),children:l(`profileRow.disable`)}),u?null:(0,$.jsx)(E.Item,{onSelect:c,className:M.anchored,children:l(`profileRow.delete`)})]})]})]})})}function Mn(e,t){let n=ne(),{data:r}=J({...Ce({path:{assistant_id:e}}),enabled:n,staleTime:3e4}),{profiles:i,profileOrder:a}=st(t?.llm,e);return(0,Q.useMemo)(()=>r==null?{entries:Ee(i,a).map(e=>({name:e.name,label:e.label??null,provider:e.provider??null,model:e.model??null,status:e.status===`disabled`?`disabled`:`active`,source:e.source===`managed`?`managed`:`user`,provider_connection:e.provider_connection,availability:null})),isEffectiveCatalog:!1}:{entries:r.profiles,isEffectiveCatalog:!0},[r,i,a])}var Nn=`0.10.8`;function Pn(e){return ve(Nn,e)}var Fn=`settings-ai-profile-make-active`,In=`Failed to set the active profile. Please try again.`;function Ln(e){let t=Me(),n=Y(),r=Pn(e),i=Wt({onSuccess:()=>{n.invalidateQueries({queryKey:vt({path:{assistant_id:e}})}),n.invalidateQueries({queryKey:Gt({path:{assistant_id:e}})})}});async function a(n,r,i){try{await t.mutateAsync({path:{assistant_id:e},body:{llm:n}})}catch(e){throw f(e,{context:r}),W.error(i),e}}async function o(t){if(!r){await a({activeProfile:t},Fn,In);return}try{await i.mutateAsync({path:{assistant_id:e},body:{name:t}})}catch(e){let t=ue(e);throw W.error(t??In),t||f(e,{context:Fn}),e}}return{makeActive:o,setStatus:(e,t)=>a({profiles:{[e]:{status:t?`active`:`disabled`}}},`settings-ai-profile-toggle`,`Failed to update the profile. Please try again.`),deleteProfile:(e,t,n)=>a({profiles:{[e]:null},profileOrder:t.filter(t=>t!==e),...n?.isAdvisor?{advisorProfile:null}:{}},`settings-ai-profile-delete`,`Failed to delete the profile. Please try again.`),patchLlm:a,isPending:t.isPending||i.isPending}}var Rn=`The profile was not deleted.`,zn=`Failed to move the schedules. ${Rn}`;function Bn(e){let t=ue(e);return t?`${/[.!?]$/.test(t)?t:`${t}.`} ${Rn}`:zn}function Vn(e,n,r){let i=Ln(e),a=Y(),o=t(),s=n?.llm?.activeProfile??null,c=n?.llm?.advisorProfile??null,l=n?.llm?.callSites??{},u=(0,Q.useMemo)(()=>n?.llm?.profiles??{},[n?.llm?.profiles]),d=(0,Q.useMemo)(()=>n?.llm?.profileOrder??[],[n?.llm?.profileOrder]),p=(0,Q.useMemo)(()=>Ee(u,d),[u,d]),[m,h]=(0,Q.useState)(null),[g,_]=(0,Q.useState)(null),[v,y]=(0,Q.useState)(``),[b,x]=(0,Q.useState)(!1),[S,C]=(0,Q.useState)(null),w=(0,Q.useRef)(!1);function T(e){return p.filter(t=>t.name===e?!1:t.status===`disabled`?!0:Te(t,p,{requireOwnProviderAndModel:o}))}function E(e,t){let n=T(e).filter(e=>!t||e.status!==`disabled`),r=n.find(e=>e.name===s),i=n.find(e=>e.source!==`managed`);return(r??i??n[0])?.name??``}async function D(e){try{await i.deleteProfile(e,d,{isAdvisor:e===c}),r?.onDeleted?.(e)}catch{}}async function O(t){let n=u[t]?.label??t,r=t===s,i=Object.entries(l).filter(([e,n])=>e!==`mainAgent`&&n?.profile===t).map(([e])=>e),o=[],c=0,d=!1;try{let n=(await a.fetchQuery({...Ct({path:{assistant_id:e},query:{inference_profile:t,include_all:`true`}}),retry:!1,staleTime:0})).schedules??[];o=n.filter(e=>!e.isDeferred).map(e=>e.name),c=n.filter(e=>e.isDeferred).length}catch(e){f(e,{context:`settings-ai-profile-delete-schedule-scan`}),d=!0}if(!(r||i.length>0||o.length>0||c>0)&&!d){await D(t);return}let p={name:t,label:n,isActive:r,callSiteIds:i,scheduleNames:o,deferredReminderCount:c,scheduleLookupFailed:d};h(p),y(E(t,En(p))),_(null)}function k(e){n==null||w.current||(w.current=!0,C(e),O(e).finally(()=>{w.current=!1,C(null)}))}async function A(){if(!m||!v)return;if(x(!0),_(null),En(m))try{await hn(e,m.name,v),await a.invalidateQueries({queryKey:_t({path:{assistant_id:e}})})}catch(e){f(e,{context:`settings-ai-profile-reassign-schedules`}),_(Bn(e)),x(!1);return}let t={};if(m.isActive&&(t.activeProfile=v),m.callSiteIds.length>0){let e={};for(let t of m.callSiteIds)e[t]={profile:v};t.callSites=e}if(Object.keys(t).length>0)try{await i.patchLlm(t,`settings-ai-profile-reassign-delete`,`Failed to reassign references. Please try again.`)}catch{_(`Failed to reassign references. Please try again.`),x(!1);return}let n=m.name;h(null),x(!1),D(n)}return{requestDelete:k,pendingDeleteName:S,blockedDeleteModalProps:{blocked:m,availableReplacements:T(m?.name??null),replacement:v,onReplacementChange:y,error:g,saving:b,onClose:()=>{h(null),_(null)},onConfirm:()=>void A()}}}function Hn(){}function Un({assistantId:e,config:t,connections:n,selectedProfileName:r,onOpenProfile:i,onCreateProfile:a,onProfileDeleted:o}){let{t:s}=Z(`settings`),{entries:c}=Mn(e,t),l=Ln(e),u=Vn(e,t,{onDeleted:o}),d=t?.llm?.activeProfile??null;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Tn,{title:s(`profilesSection.title`),action:(0,$.jsx)(U,{variant:`primary`,onClick:a,leftIcon:(0,$.jsx)(en,{}),disabled:t==null,children:s(`profilesSection.createProfile`)}),children:t==null?(0,$.jsx)(q,{variant:`body-medium-lighter`,as:`p`,className:`py-4 text-center text-(--content-tertiary)`,children:s(`profilesSection.loading`)}):c.length===0?(0,$.jsx)(q,{variant:`body-medium-lighter`,as:`p`,className:`py-4 text-center text-(--content-tertiary)`,children:s(`profilesSection.emptyState`)}):c.map(e=>(0,$.jsx)(jn,{profile:e,isActiveProfile:e.name===d,selected:e.name===r,connections:n,deletePending:u.pendingDeleteName===e.name,onOpen:()=>i(e.name),onMakeActive:()=>void l.makeActive(e.name).catch(Hn),onSetStatus:t=>void l.setStatus(e.name,t).catch(Hn),onDelete:()=>u.requestDelete(e.name)},e.name))}),(0,$.jsx)(An,{...u.blockedDeleteModalProps})]})}var Wn={anthropic:!0,openai:!0,gemini:!0,fireworks:!0,openrouter:!0,chatgpt:!0,cadet:!0,together:!0,"vercel-ai-gateway":!0,minimax:!0,atlascloud:!0,baseten:!0,ionet:!0,poolside:!0,litellm:!0,opencode:!0};function Gn(e){return e in Wn}function Kn(e){if(!e.baseUrl)return null;try{return new URL(e.baseUrl).host}catch{return e.baseUrl}}function qn(e){let t=Kn(e)??``,n=[];t&&n.push(t);let r=e.models?.length??0;return r>0&&n.push(`${r} ${r===1?`model`:`models`}`),e.auth.type===`none`&&n.push(`keyless`),n.join(` · `)}function Jn(e){switch(e.auth.type){case`api_key`:return`Own API key`;case`oauth_subscription`:return`ChatGPT subscription`;case`none`:return`No API key needed`;default:return null}}function Yn(e){if(e.provider===`cadet`)return`Included with your plan`;if(e.provider===`openai-compatible`)return qn(e);let t=[];if(e.provider===`ollama`||e.provider===`opencode`){let n=Kn(e);n&&t.push(n)}let n=e.provider===`chatgpt`?`openai`:e.provider,r=e.auth.type===`oauth_subscription`?O(n):Be(n),i=e.models?.length??r.length;i>0&&t.push(`${i} ${i===1?`model`:`models`}`);let a=Jn(e);return a&&t.push(a),t.join(` • `)}function Xn({connection:e,isDefault:t,supportsDefaultProvider:n,selected:r,isSettingDefault:i,onOpen:a,onSetDefault:o,onDelete:s}){let{t:c}=Z(`settings`),l=e.isManaged??!1,u=gt(e),d=Gn(e.provider),f=Yn(e),p=n&&!t&&d,m=!l&&a!=null,h=!l&&!t,g=p||m||h;return(0,$.jsx)(We,{title:u,subtitle:f.length>0?f:void 0,onClick:a,showChevron:!1,selected:r,contentAriaLabel:a?c(`providerRow.openProviderAriaLabel`,{displayName:u}):void 0,trailingInteractive:!0,trailing:(0,$.jsxs)($.Fragment,{children:[l?(0,$.jsx)(ut,{tone:`neutral`,title:c(`providerRow.managedTagTitle`),children:c(`providerRow.managedTag`)}):null,t?(0,$.jsx)(ut,{tone:`info`,title:c(`providerRow.defaultTagTitle`),children:c(`providerRow.defaultTag`)}):null,e.provider===`ollama`?(0,$.jsx)(ut,{tone:`neutral`,title:c(`providerRow.localTagTitle`),children:c(`providerRow.localTag`)}):null,e.provider===`openai-compatible`?(0,$.jsx)(ut,{tone:`neutral`,title:c(`providerRow.customTagTitle`),children:c(`providerRow.customTag`)}):null,g?(0,$.jsxs)(E.Root,{children:[(0,$.jsx)(E.Trigger,{asChild:!0,children:(0,$.jsx)(U,{variant:`ghost`,size:`compact`,iconOnly:(0,$.jsx)(cn,{}),"aria-label":c(`providerRow.actionsAriaLabel`,{displayName:u})})}),(0,$.jsxs)(E.Content,{align:`end`,sideOffset:4,children:[m?(0,$.jsx)(E.Item,{onSelect:a,children:c(`providerRow.edit`)}):null,p?(0,$.jsx)(E.Item,{disabled:i,onSelect:o,children:c(`providerRow.setAsDefault`)}):null,h?(0,$.jsx)(E.Item,{onSelect:s,className:M.anchored,children:c(`providerRow.delete`)}):null]})]}):(0,$.jsx)(`span`,{className:`inline-block w-8`,"aria-hidden":!0})]})})}function Zn(e,t){let n=Y(),r={path:{assistant_id:e}},i=Zt({...Vt(),onSuccess:()=>{n.invalidateQueries({queryKey:Lt(r)}),n.invalidateQueries({queryKey:vt(r)}),n.invalidateQueries({queryKey:Gt(r)})},onError:e=>{f(e,{context:`settings-ai-set-default-provider`}),W.error(X(`settings:useProviderActions.setDefaultFailedToast`))}});function a(t){Gn(t.provider)&&i.mutate({path:{assistant_id:e},body:{provider:t.provider,connectionName:t.name}})}function o(e){return i.isPending&&i.variables?.body?.connectionName===e}async function c(i){try{let{response:a}=await s({path:{assistant_id:e,name:i}});a?.ok||a?.status===404?(n.invalidateQueries({queryKey:Ne(r)}),t?.onDeleted?.(i)):a?.status===409?W.error(X(`settings:useProviderActions.deleteInUseToast`)):W.error(X(`settings:useProviderActions.deleteFailedToast`))}catch(e){f(e,{context:`settings-ai-provider-delete`}),W.error(X(`settings:useProviderActions.deleteFailedToast`))}}return{setDefault:a,isSettingDefault:o,deleteConnection:c}}function Qn({assistantId:e,selectedConnectionName:t,onOpenConnection:n,onAddProvider:r,onConnectionDeleted:i}){let{t:a}=Z(`settings`),{data:s,isLoading:c,isError:l}=J(o({path:{assistant_id:e}})),u=Ue(),{data:d}=J({...qe({path:{assistant_id:e}}),enabled:u}),f=u?d?.resolvedConnectionName??null:null,p=Zn(e,{onDeleted:i}),m=(0,Q.useMemo)(()=>{let e=s?.connections??[];return[...e.filter(e=>e.provider===N),...e.filter(e=>e.provider!==N)]},[s]);return(0,$.jsx)(Tn,{title:a(`providersSection.title`),action:(0,$.jsx)(U,{variant:`outlined`,onClick:r,leftIcon:(0,$.jsx)(en,{}),children:a(`providersSection.addProvider`)}),children:c?(0,$.jsx)(`div`,{className:`space-y-2 py-2`,children:[1,2,3].map(e=>(0,$.jsx)(at,{className:`h-10 rounded-lg`},e))}):l?(0,$.jsx)(q,{variant:`body-medium-default`,as:`p`,className:`py-4 text-center text-(--system-negative-strong)`,children:a(`providersSection.loadError`)}):m.length===0?(0,$.jsx)(q,{variant:`body-medium-lighter`,as:`p`,className:`py-4 text-center text-(--content-tertiary)`,children:a(`providersSection.empty`)}):m.map(e=>(0,$.jsx)(Xn,{connection:e,isDefault:e.name===f,supportsDefaultProvider:u,selected:e.name===t,isSettingDefault:p.isSettingDefault(e.name),onOpen:e.isManaged??!1?void 0:()=>n(e.name),onSetDefault:()=>p.setDefault(e),onDelete:()=>void p.deleteConnection(e.name)},e.name))})}function $n({panel:e,onOpenPanel:t,onClosePanel:n}){let{t:r}=Z(`settings`),i=T(),{data:a}=J({...wt({path:{assistant_id:i}}),staleTime:3e4}),s=Ue(),{data:c}=J({...qe({path:{assistant_id:i}}),enabled:s}),l=c?.availability,{data:u}=J({...o({path:{assistant_id:i}})}),d=u?.connections,f=a?.llm?.callSites??{},p=Object.entries(f).filter(([e,t])=>e!==`mainAgent`&&(t?.profile!=null||t?.provider!=null||t?.model!=null)).length;return(0,$.jsx)(ln,{title:r(`languageModelCard.title`),subtitle:r(`languageModelCard.subtitle`),children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[l&&l.status!==`ok`&&(0,$.jsx)(F,{tone:l.status===`unknown`?`warning`:`error`,children:l.message??r(`languageModelCard.defaultProviderUnavailable`)}),i&&(0,$.jsx)(Un,{assistantId:i,config:a,connections:d,selectedProfileName:e?.kind===`profile`?e.name:null,onOpenProfile:e=>t({kind:`profile`,name:e}),onCreateProfile:()=>t({kind:`create-profile`}),onProfileDeleted:t=>{e?.kind===`profile`&&e.name===t&&n()}}),i&&(0,$.jsx)(Qn,{assistantId:i,selectedConnectionName:e?.kind===`provider`?e.name:null,onOpenConnection:e=>t({kind:`provider`,name:e}),onAddProvider:()=>t({kind:`add-provider`}),onConnectionDeleted:t=>{e?.kind===`provider`&&e.name===t&&n()}}),(0,$.jsx)(Tn,{title:r(`languageModelCard.overridesTitle`),count:p,action:(0,$.jsx)(U,{variant:`outlined`,onClick:()=>t({kind:`overrides`}),children:r(`languageModelCard.manage`)})})]})})}function er({children:e}){return(0,$.jsxs)(w,{href:`https://www.mycadet.ai/docs/pricing`,tone:`default`,className:`inline-flex items-center gap-1`,glyph:!1,children:[e,(0,$.jsx)(an,{className:`h-3.5 w-3.5`})]})}function tr(){return(0,$.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-[var(--border-base)] bg-[var(--surface-base)] px-4 py-2.5`,children:[(0,$.jsx)(on,{className:`mt-0.5 h-4 w-4 shrink-0 text-[var(--content-tertiary)]`}),(0,$.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-secondary)]`,children:(0,$.jsx)(Xt,{i18nKey:`managedServicesBanner.body`,ns:`common`,components:{link:(0,$.jsx)(er,{})}})})]})}function nr({assistantId:e,profileName:t,onClose:n}){let{t:r}=Z(`settings`),{data:i}=J({...wt({path:{assistant_id:e}}),staleTime:3e4}),{data:s}=J({...o({path:{assistant_id:e}})}),c=s?.connections,l=(0,Q.useMemo)(()=>i?.llm?.profiles??{},[i?.llm?.profiles]),u=Object.keys(l),d=(0,Q.useMemo)(()=>{if(t==null)return;let e=l[t];return e?{name:t,...e}:void 0},[t,l]),f=t==null?`create`:d?.source===`managed`||d?.invariant===!0?`view`:`edit`,{saveProfile:p,isPending:m}=a(e,{onSaved:n}),h=ee({mode:f,profileName:t??void 0,initialValues:d,existingNames:u,connections:c,assistantId:e,onSave:p}),g=Vn(e,i,{onDeleted:()=>n()}),_=t!=null&&g.pendingDeleteName===t,v=t!=null&&i!=null&&!(t in l);(0,Q.useEffect)(()=>{v&&!h.saving&&!m&&n()},[v,h.saving,m,n]);let y=f===`view`;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(k,{title:h.effectiveMode===`create`?r(`profileDetailPanel.createTitle`):d?.label??t??r(`profileDetailPanel.defaultTitle`),closeVariant:`outlined`,onClose:n,headerTrailing:y&&h.effectiveMode!==`create`?(0,$.jsx)(ut,{tone:`neutral`,children:r(`profileDetailPanel.managedTag`)}):null,headerActions:h.effectiveMode!==`create`&&!h.isReadOnly?(0,$.jsx)(U,{variant:`dangerOutline`,loading:_,iconOnly:(0,$.jsx)(Qt,{}),"aria-label":r(_?`profileDetailPanel.deleting`:`profileDetailPanel.delete`),tooltip:r(`profileDetailPanel.delete`),onClick:()=>{t!=null&&g.requestDelete(t)},disabled:h.saving||_}):null,footer:h.isReadOnly?(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(U,{variant:`outlined`,onClick:h.switchToSaveAsNew,disabled:h.saving,children:r(`profileDetailPanel.saveAsNew`)}),h.hasViewModeChanges?(0,$.jsx)(U,{variant:`primary`,onClick:()=>void h.handleSave(),disabled:h.saving,children:h.saving?r(`profileDetailPanel.saving`):r(`profileDetailPanel.save`)}):null]}):(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(U,{variant:`primary`,onClick:()=>void h.handleSave(),disabled:h.isInvalid||h.saving,children:h.saving?r(`profileDetailPanel.saving`):h.effectiveMode===`create`?r(`profileDetailPanel.create`):r(`profileDetailPanel.saveChanges`)})}),children:(0,$.jsx)(Le,{editor:h,assistantId:e,connections:c,variant:`panel`})}),(0,$.jsx)(An,{...g.blockedDeleteModalProps})]})}function rr({value:e,profileOptions:t,disabled:n,onChange:r}){let{t:i}=Z(`settings`);return(0,$.jsx)(`div`,{className:`rounded-lg border border-[var(--border-base)] bg-[var(--surface-overlay)] p-3`,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-body-medium-default font-medium text-[var(--content-default)]`,children:i(`advisorProfileRow.title`)}),(0,$.jsx)(`p`,{className:`mt-0.5 text-body-small-lighter text-[var(--content-tertiary)]`,children:i(`advisorProfileRow.description`)})]}),(0,$.jsx)(G,{value:e,onChange:r,options:t,placeholder:i(`advisorProfileRow.chooseProfilePlaceholder`),className:`w-44`,menuMinWidth:280,menuAlign:`start`,disabled:n})]})})}var ir=`__custom__`;function ar(e){return e?!!(e.profile||e.provider||e.model):!1}function or(e,t){if(t?.provider||t?.model)return null;let n=e.defaultProfile??e.shippedDefaultProfile;return n?{profile:n,via:t?.profile===n?`override`:`default`}:null}function sr(e,t){let n=ar(e);return n===ar(t)?n?(e?.profile??null)===(t?.profile??null)&&(e?.provider??null)===(t?.provider??null)&&(e?.model??null)===(t?.model??null):!0:!1}function cr({assistantId:e,callSites:n,domains:r,persistedOverrides:i,orderedProfiles:a,onClose:o,onApplied:s}){let{t:l}=Z(`settings`),u=Me(),d=t(),p=(0,Q.useMemo)(()=>({requireOwnProviderAndModel:d,requireTextGeneration:!1}),[d]),m=(0,Q.useMemo)(()=>{let e=new Map;for(let t of n){let n=or(t,i[t.id]);n&&e.set(t.id,n)}return e},[n,i]),g=(0,Q.useMemo)(()=>{let e=new Set(Array.from(m.values(),e=>e.profile));return a.filter(t=>e.has(t.name))},[a,m]),[_,v]=(0,Q.useState)(()=>g[0]?.name??``),[y,b]=(0,Q.useState)(``),[x,S]=(0,Q.useState)(new Set),[C,w]=(0,Q.useState)(!1),T=(0,Q.useMemo)(()=>{let e=new Map(r.map(e=>[e.id,e.displayName]));return t=>e.get(t)??t},[r]),E=(0,Q.useMemo)(()=>n.filter(e=>m.get(e.id)?.profile===_),[n,m,_]),D=(0,Q.useMemo)(()=>E.map(e=>e.id).filter(e=>!x.has(e)),[E,x]),O=(0,Q.useMemo)(()=>g.map(e=>({value:e.name,label:Bt(e)})),[g]),k=(0,Q.useMemo)(()=>h(a,[],p).filter(e=>e.name!==_).map(e=>({value:e.name,label:Bt(e)})),[a,_,p]),A=he(a,_),j=he(a,y),M=x.size===0;function N(e){v(e),S(new Set),e===y&&b(``)}function ee(e,t){S(n=>{let r=new Set(n);return t?r.delete(e):r.add(e),r})}async function P(){if(!(!_||!y||D.length===0)){w(!0);try{let t={};for(let e of D)t[e]={profile:y};await u.mutateAsync({path:{assistant_id:e},body:{llm:{callSites:t}}}),W.success(l(`bulkOverrideSwapModal.successToast`,{count:D.length,targetLabel:j})),s(),o()}catch(e){let t=ue(e);W.error(t??l(`bulkOverrideSwapModal.updateFailedToast`)),t||f(e,{context:`settings-ai-bulk-override-swap`})}finally{w(!1)}}}return(0,$.jsx)(K.Root,{open:!0,onOpenChange:e=>{e||o()},children:(0,$.jsxs)(K.Content,{size:`md`,children:[(0,$.jsx)(K.Header,{children:(0,$.jsx)(K.Title,{children:l(`bulkOverrideSwapModal.title`)})}),(0,$.jsxs)(K.Body,{className:`space-y-4`,children:[(0,$.jsx)(q,{variant:`body-medium-default`,as:`p`,children:l(`bulkOverrideSwapModal.intro`)}),(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,$.jsx)(G,{id:`bulk-swap-source`,label:l(`bulkOverrideSwapModal.currentlyUsingLabel`),value:_,onChange:N,options:O}),(0,$.jsx)(G,{id:`bulk-swap-target`,label:l(`bulkOverrideSwapModal.changeToLabel`),value:y,onChange:b,options:k,placeholder:l(`bulkOverrideSwapModal.targetPlaceholder`)})]}),(0,$.jsx)(F,{tone:`info`,title:l(`bulkOverrideSwapModal.noticeTitle`),children:l(`bulkOverrideSwapModal.noticeBody`,{sourceLabel:A})}),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-baseline justify-between gap-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(q,{variant:`body-medium-default`,as:`p`,children:l(`bulkOverrideSwapModal.affectedSummary`,{count:E.length,profile:A})}),(0,$.jsx)(q,{variant:`body-small-default`,as:`p`,className:`text-[color:var(--content-secondary)]`,children:l(`bulkOverrideSwapModal.chooseActions`)})]}),(0,$.jsx)(U,{variant:`ghost`,onClick:()=>S(M?new Set(E.map(e=>e.id)):new Set),children:l(M?`bulkOverrideSwapModal.clearAll`:`bulkOverrideSwapModal.selectAll`)})]}),(0,$.jsx)(`div`,{className:`max-h-72 space-y-1 overflow-y-auto`,children:E.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md border border-[var(--border-base)] px-3 py-2`,children:[(0,$.jsx)(c,{checked:!x.has(e.id),onCheckedChange:t=>ee(e.id,t===!0),disabled:C,label:e.displayName,helperText:T(e.domain)}),(0,$.jsx)(`span`,{className:`shrink-0 text-body-small-default text-[color:var(--content-tertiary)]`,children:m.get(e.id)?.via===`override`?l(`bulkOverrideSwapModal.viaOverride`):l(`bulkOverrideSwapModal.viaDefault`)})]},e.id))})]})]}),(0,$.jsxs)(K.Footer,{children:[(0,$.jsx)(q,{variant:`body-small-default`,as:`p`,className:`mr-auto self-center text-[color:var(--content-secondary)]`,children:l(`bulkOverrideSwapModal.willChange`,{count:D.length})}),(0,$.jsx)(U,{variant:`ghost`,onClick:o,disabled:C,children:l(`bulkOverrideSwapModal.cancel`)}),(0,$.jsx)(U,{variant:`primary`,loading:C,disabled:!_||!y||D.length===0||C,onClick:()=>void P(),children:l(`bulkOverrideSwapModal.applyTo`,{count:D.length})})]})]})})}function lr({id:e,displayName:t,description:n,defaultProfileLabel:r,draft:i,profileOptions:a,connections:o,onDraftChange:s,onToggle:c}){let{t:l}=Z(`settings`),u=Et({hostedInference:Dt.use.cadetHostedInference()}),d=ar(i),f=!i||!d?``:i.provider||i.model?ir:i.profile??``,p=f===ir,m=Je(),h=kt(),g=(o??[]).some(e=>e.provider===Oe),_=[...Ie,...g?[Oe]:[]],v=m[0]??Ie[0],y=i?.provider,b=D(y)?y:y===`chatgpt`?Oe:void 0,x=b!==void 0&&_.some(e=>e===b),S=b??v,C=re(S,``,(o??[]).filter(e=>ot(e.provider,S)))?O(S):Ge(S,u),w=C.map(e=>({value:e.id,label:e.displayName})),T=typeof i?.model==`string`?i.model:``;if(T&&!C.some(e=>e.id===T)){let e=Be(S).find(e=>e.id===T)?.displayName??T;w.push({value:T,label:l(`callSiteOverridesRow.unavailableOption`,{name:e})})}let E=!!i?.provider&&!i?.model,k=[..._.map(e=>({value:e,label:R[e]??e,...h(e)})),...b&&!x?[{value:b,label:l(`callSiteOverridesRow.unavailableOption`,{name:R[b]??b})}]:[]];function A(t){t===`__custom__`?s(e,{profile:null,provider:v,model:He(v)??``}):t===``?s(e,null):s(e,{profile:t,provider:null,model:null})}function j(t){let n=He(t)??``;s(e,{...i??{},profile:null,provider:t,model:n})}function M(t){s(e,{...i??{},model:t})}return(0,$.jsxs)(`div`,{className:`rounded-lg border border-[var(--border-base)] bg-[var(--surface-overlay)] p-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`p`,{className:`text-body-medium-default font-medium text-[var(--content-default)]`,children:t}),n&&(0,$.jsxs)(`p`,{className:`mt-0.5 text-body-small-default text-[var(--content-tertiary)]`,children:[n,r&&(0,$.jsx)(`span`,{className:`ml-1.5 text-body-small-default text-[var(--content-tertiary)] opacity-60`,children:l(`callSiteOverridesRow.defaultProfileSuffix`,{label:r})})]})]}),(0,$.jsx)(Rt,{checked:d,onChange:t=>c(e,t),"aria-label":l(`callSiteOverridesRow.overrideAriaLabel`,{displayName:t}),className:`shrink-0`})]}),d&&(0,$.jsx)(`div`,{className:`mt-3`,children:(0,$.jsx)(G,{value:f,onChange:A,options:a,className:`w-44`,menuMinWidth:280,menuAlign:`start`})}),d&&p&&(0,$.jsxs)(`div`,{className:`mt-3 space-y-2 border-t border-[var(--border-base)] pt-3`,children:[(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex-1`,children:[(0,$.jsx)(`label`,{className:`mb-1 block text-body-small-default text-[var(--content-tertiary)]`,children:l(`callSiteOverridesRow.providerLabel`)}),(0,$.jsx)(G,{value:S??``,onChange:j,options:k})]}),(0,$.jsxs)(`div`,{className:`flex-1`,children:[(0,$.jsx)(`label`,{className:`mb-1 block text-body-small-default text-[var(--content-tertiary)]`,children:l(`callSiteOverridesRow.modelLabel`)}),(0,$.jsx)(G,{value:i?.model??``,onChange:M,options:w})]})]}),E&&(0,$.jsx)(`p`,{className:`text-body-small-default text-[var(--system-negative-strong)]`,children:l(`callSiteOverridesRow.pickModelError`)})]})]})}function ur({groups:e,drafts:t,buildProfileOptionsForRow:n,profileLabelFor:r,advisorMatchesSearch:i,connections:a,onDraftChange:o,onToggle:s}){let{t:c}=Z(`settings`);return(0,$.jsx)(`div`,{className:`space-y-4`,children:e.length===0?i?null:(0,$.jsx)(`p`,{className:`py-8 text-center text-body-medium-lighter text-[var(--content-tertiary)]`,children:c(`overridesCallSiteList.emptySearch`)}):e.map(({domain:e,sites:i})=>(0,$.jsxs)(`div`,{children:[(0,$.jsx)(pn,{children:e.displayName}),(0,$.jsx)(`div`,{className:`space-y-1`,children:i.map(e=>{let i=(()=>{let n=t[e.id]??null;return!n||!ar(n)?``:n.provider||n.model?ir:n.profile??``})(),c=e.shippedDefaultProfile??e.defaultProfile,l=c?r(c):null;return(0,$.jsx)(lr,{id:e.id,displayName:e.displayName,description:e.description,defaultProfileLabel:l,draft:t[e.id]??null,profileOptions:n(i===``||i===`__custom__`?null:i),connections:a,onDraftChange:o,onToggle:s},e.id)})})]},e.id))})}function dr(e,t){let n={};for(let r of Object.keys(e)){let i=e[r]??null;ar(i)?n[r]={profile:i?.profile??null,provider:i?.provider??null,model:i?.model??null}:r in t&&t[r]===null&&(n[r]=null)}return n}function fr(e){let t={};for(let n of Object.keys(e))t[n]=null;return t}function pr({catalogCallSiteIds:e,persistedOverrides:t,persistedAdvisor:n,isSeeded:r}){let[i,a]=(0,Q.useState)({}),[o,s]=(0,Q.useState)(void 0),c=(0,Q.useMemo)(()=>{if(!r)return{};let n={};for(let r of e)if(r in i)n[r]=i[r];else{let e=t[r];n[r]=e?{...e}:{}}return n},[r,e,t,i]),l=o??n,u=l!==n,d=(0,Q.useMemo)(()=>{if(!r)return!1;for(let e of Object.keys(c))if(!sr(c[e],t[e]))return!0;return!1},[r,c,t]);return{drafts:c,advisorProfile:l,advisorDirty:u,callSiteDraftsDirty:d,hasUnsavedDrafts:u||d,hasValidationError:(0,Q.useMemo)(()=>Object.values(c).some(e=>ar(e)&&!!e?.provider&&!e?.model),[c]),setDraft:(0,Q.useCallback)((e,t)=>{a(n=>({...n,[e]:t}))},[]),setAdvisor:(0,Q.useCallback)(e=>{s(e)},[]),clearEdits:(0,Q.useCallback)(()=>{a({}),s(void 0)},[]),buildSavePatch:(0,Q.useCallback)(()=>dr(c,i),[c,i]),buildResetPatch:(0,Q.useCallback)(()=>fr(c),[c])}}function mr({assistantId:e,onClose:n}){let{t:r}=Z(`settings`),{data:i}=J({...wt({path:{assistant_id:e}}),staleTime:3e4}),a=(0,Q.useMemo)(()=>i?.llm?.profiles??{},[i?.llm?.profiles]),s=(0,Q.useMemo)(()=>i?.llm?.profileOrder??[],[i?.llm?.profileOrder]),c=(0,Q.useMemo)(()=>i?.llm?.callSites??{},[i?.llm?.callSites]),l=(0,Q.useMemo)(()=>Ee(a,s),[a,s]),d=Je(),p=t(),m=(0,Q.useMemo)(()=>({requireOwnProviderAndModel:p}),[p]),g=(0,Q.useMemo)(()=>({requireOwnProviderAndModel:p,requireTextGeneration:!1}),[p]),_=Me(),[v,y]=(0,Q.useState)(``),[x,S]=(0,Q.useState)(!1),[C,w]=(0,Q.useState)(!1),[T,E]=(0,Q.useState)(!1),{data:D,isLoading:O,isError:A,refetch:j}=J({...tt({path:{assistant_id:e}}),enabled:!!e,staleTime:6e4,refetchOnWindowFocus:!1}),{data:M}=J({...o({path:{assistant_id:e}}),enabled:!!e}),N=(0,Q.useMemo)(()=>(D?.callSites??[]).filter(e=>e.id!==`mainAgent`),[D]),ee=!O&&!A&&!!D,P=!!i,I=ee&&P,te=(0,Q.useMemo)(()=>N.map(e=>e.id),[N]),L=i?.llm?.advisorProfile??``,{drafts:ne,advisorProfile:R,advisorDirty:re,callSiteDraftsDirty:z,hasUnsavedDrafts:ie,hasValidationError:ae,setDraft:oe,setAdvisor:se,clearEdits:ce,buildSavePatch:B,buildResetPatch:le}=pr({catalogCallSiteIds:te,persistedOverrides:c,persistedAdvisor:L,isSeeded:I}),ue=(0,Q.useMemo)(()=>new Set(te),[te]),de=(0,Q.useCallback)(e=>he(l,e),[l]),fe=(0,Q.useCallback)((e,t)=>({value:e.name,label:Bt(e),...u(e,l,t)===`undispatchable`?{icon:(0,$.jsx)(tn,{className:`h-3.5 w-3.5 text-[var(--system-mid-strong)]`}),tooltip:b(e)}:{}}),[l]),pe=(0,Q.useMemo)(()=>h(l,[L],m).map(e=>fe(e,m)),[l,L,fe,m]),me=(0,Q.useMemo)(()=>{let e=v.trim().toLowerCase();return e===``||`advisor`.includes(e)||`second opinion`.includes(e)},[v]),ge=(0,Q.useMemo)(()=>N.some(e=>or(e,c[e.id])!==null),[N,c]),_e=(0,Q.useMemo)(()=>Object.entries(c).some(([e,t])=>ue.has(e)&&(t?.profile!=null||t?.provider!=null||t?.model!=null)),[c,ue]),ve=(0,Q.useCallback)(e=>[...h(l,[e],g).map(e=>fe(e,g)),{value:ir,label:r(`overridesDetailPanel.customProfileOption`)}],[l,fe,g,r]),ye=(0,Q.useMemo)(()=>{if(!v.trim())return N;let e=v.toLowerCase();return N.filter(t=>(t.displayName??``).toLowerCase().includes(e)||(t.description??``).toLowerCase().includes(e)||(t.domain??``).toLowerCase().includes(e))},[N,v]),be=(0,Q.useMemo)(()=>{if(!D)return[];let e=D.domains.map(e=>e.id),t=new Map(D.domains.map(e=>[e.id,e])),n=[];for(let r of e){let e=ye.filter(e=>e.domain===r);e.length>0&&n.push({domain:t.get(r),sites:e})}let i=new Set(e),a=ye.filter(e=>!i.has(e.domain));return a.length>0&&n.push({domain:{id:`other`,displayName:r(`overridesDetailPanel.otherDomain`)},sites:a}),n},[D,ye,r]),xe=(0,Q.useCallback)((e,t)=>{if(!t){oe(e,null);return}let n=De(l,N.find(t=>t.id===e)?.defaultProfile,g);if(n)oe(e,{profile:n});else{let t=d[0]??Ie[0];oe(e,{provider:t,model:He(t)??``})}},[N,l,d,oe,g]),Se=(0,Q.useCallback)(async()=>{S(!0);try{let t=B();await _.mutateAsync({path:{assistant_id:e},body:{llm:{...z?{callSites:t}:{},...re?{advisorProfile:R}:{}}}}),n(),W.success(r(`overridesDetailPanel.overridesSavedToast`))}catch(e){W.error(r(`overridesDetailPanel.saveFailedToast`)),f(e,{context:`call_site_overrides_save`})}finally{S(!1)}},[B,z,re,R,n,_,e,r]),Ce=(0,Q.useCallback)(async()=>{S(!0);try{let t=le();await _.mutateAsync({path:{assistant_id:e},body:{llm:{callSites:t}}}),n(),W.success(r(`overridesDetailPanel.overridesResetToast`))}catch(e){W.error(r(`overridesDetailPanel.resetFailedToast`)),f(e,{context:`call_site_overrides_reset`})}finally{S(!1)}},[le,n,_,e,r]),we=(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[_e&&(0,$.jsx)(U,{variant:`outlined`,onClick:()=>w(!0),disabled:x||!I,tintColor:`var(--system-negative-strong)`,className:`mr-auto`,children:r(`overridesDetailPanel.resetToDefaults`)}),(0,$.jsx)(U,{variant:`primary`,onClick:()=>void Se(),loading:x,disabled:!ie||ae||x,children:r(`overridesDetailPanel.save`)})]});return(0,$.jsxs)(k,{title:r(`overridesDetailPanel.title`),closeVariant:`outlined`,onClose:n,footer:we,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:r(`overridesDetailPanel.description`)}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,$.jsx)(V,{type:`search`,value:v,onChange:e=>y(e.target.value),placeholder:r(`overridesDetailPanel.searchPlaceholder`),leftIcon:(0,$.jsx)(sn,{className:`h-4 w-4`}),fullWidth:!0})}),(0,$.jsx)(U,{variant:`outlined`,onClick:()=>E(!0),disabled:!I||x||ie||!ge,title:ie?r(`overridesDetailPanel.bulkChangeUnsavedTitle`):ge?void 0:r(`overridesDetailPanel.bulkChangeNoCandidatesTitle`),children:r(`overridesDetailPanel.bulkChange`)})]}),P&&me&&(0,$.jsxs)(`div`,{children:[(0,$.jsx)(pn,{children:r(`overridesDetailPanel.advisorSection`)}),(0,$.jsx)(rr,{value:R,profileOptions:pe,disabled:x,onChange:se})]}),O&&(0,$.jsx)(Ot,{placement:`panel`}),A&&(0,$.jsx)(F,{tone:`error`,title:r(`overridesDetailPanel.loadErrorTitle`),actions:(0,$.jsx)(U,{variant:`outlined`,onClick:()=>void j(),children:r(`overridesDetailPanel.retry`)}),children:r(`overridesDetailPanel.loadErrorHint`)}),!O&&!A&&D&&(0,$.jsx)(ur,{groups:be,drafts:ne,buildProfileOptionsForRow:ve,profileLabelFor:de,advisorMatchesSearch:me,connections:M?.connections,onDraftChange:oe,onToggle:xe})]})]}),T&&D&&(0,$.jsx)(cr,{assistantId:e,callSites:N,domains:D.domains,persistedOverrides:c,orderedProfiles:l,onClose:()=>E(!1),onApplied:ce}),(0,$.jsx)(Qe,{open:C,title:r(`overridesDetailPanel.resetToDefaults`),message:r(`overridesDetailPanel.resetConfirmMessage`),confirmLabel:r(`overridesDetailPanel.resetToDefaults`),destructive:!0,onConfirm:()=>{w(!1),Ce()},onCancel:()=>w(!1)})]})}var hr=e(qt(),1);function gr({mode:e,connection:t,assistantId:n,existingNames:r,connections:i,variant:a=`modal`,actionsSlot:o,onSave:s,onCancel:c}){let{t:l}=Z(`settings`),[u,d]=(0,Q.useState)(t?.label??``),f=t?.name??``,p=t?.provider??`anthropic`,m=t?.auth.type??`api_key`,[h,g]=(0,Q.useState)(()=>t?.auth.type===`api_key`?t.auth.credential:t?``:`credential/anthropic/api_key`),[_,v]=(0,Q.useState)(t?.baseUrl??``),[y,b]=(0,Q.useState)(()=>t?.models?t.models.map(e=>e.id).join(`, `):``),[x,S]=(0,Q.useState)(!1),[C,w]=(0,Q.useState)(null),T=p===`openai-compatible`,E=Ze(p),D=Ft(p),[O,k]=(0,Q.useState)(``),[A,j]=(0,Q.useState)(!1),M=Y(),N=(0,Q.useMemo)(()=>jt(h),[h]),ee=m===`api_key`&&N!==null,{hasStoredCredential:P,isLoading:F}=xe({assistantId:n,credentialKind:`credential`,credentialName:N?`${N.service}:${N.field}`:``,enabled:ee}),{credentials:I}=yt({assistantId:n,enabled:m===`api_key`});(0,Q.useEffect)(()=>{let e=t?.provider??`anthropic`;d(t?.label??``),t?.auth.type===`api_key`?g(t.auth.credential):g(t?``:`credential/${e}/api_key`),w(null),v(t?.baseUrl??``),b(t?.models?t.models.map(e=>e.id).join(`, `):``),k(``),j(!1)},[t]);let te=u.trim()!==(t?.label??``).trim(),L=T&&te?St(u,i,t?.name):null,ne=f.trim().length>0&&L===null;async function R(){if(ne){S(!0),w(null);try{let e;if(m===`api_key`){let t=h.trim()||`credential/${p}/api_key`,r=O.trim();if(r){j(!0);try{let e=jt(t);await Xe({path:{assistant_id:n},body:e?{type:`credential`,name:`${e.service}:${e.field}`,value:r}:{type:`api_key`,name:p,value:r},throwOnError:!0});let i=Ke(n,`credential`,e?`${e.service}:${e.field}`:``);M.setQueryData(i,!0),M.invalidateQueries({queryKey:rt({path:{assistant_id:n}})})}catch{w(l(`providerEditorContent.failedSaveApiKey`));return}finally{j(!1)}}e={type:`api_key`,credential:t}}else if(t)e=t.auth;else{w(l(`providerEditorContent.nothingToEdit`));return}let r=u.trim()||null,i={auth:e,label:r,...E&&{base_url:_.trim()||null},...D&&{models:y.trim()?y.split(`,`).map(e=>({id:e.trim()})).filter(e=>e.id):null}},{data:a,error:o,response:c}=await Fe({path:{assistant_id:n,name:t?.name??f.trim()},body:i});if(!c?.ok){w($e(c?.status,o)??xt(c?.status));return}if(!a){w(l(`providerEditorContent.emptyServerResponse`));return}et(a,l),s(a)}catch{w(l(`providerEditorContent.failedSaveProvider`))}finally{S(!1)}}}let re=I.filter(e=>e.service===p),z=e!==`create`&&t?.auth.type===`api_key`,ie=re.length>0||z,ae=At(l(`providerEditorContent.apiKeyPlaceholder`),P);if(e===`create`)return(0,$.jsx)(Pt,{variant:a===`panel`?`inline`:`modal`,actionsSlot:o,assistantId:n,existingNames:r,connections:i,defaultProviderType:p,onCreated:s,onCancel:c});let oe=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:(0,$.jsx)(Xt,{i18nKey:`providerEditorContent.displayNameLabel`,ns:`settings`,components:{optional:(0,$.jsx)(`span`,{className:`text-[var(--content-disabled)]`})}})}),(0,$.jsx)(V,{value:u,onChange:e=>d(e.target.value),placeholder:l(`providerEditorContent.displayNamePlaceholder`),fullWidth:!0}),L?(0,$.jsx)(q,{variant:`body-small-default`,as:`p`,className:`text-(--system-negative-strong)`,children:Ye[L]}):null]}),E&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:l(`providerEditorContent.baseUrlLabel`)}),(0,$.jsx)(V,{value:_,onChange:e=>v(e.target.value),placeholder:l(p===`ollama`?`providerEditorContent.baseUrlPlaceholderOllama`:p===`opencode`?`providerEditorContent.baseUrlPlaceholderOpencode`:`providerEditorContent.baseUrlPlaceholder`),fullWidth:!0}),p===`ollama`?(0,$.jsx)(q,{variant:`body-small-default`,as:`p`,className:`text-[var(--content-tertiary)]`,children:l(`providerEditorContent.baseUrlHintOllama`)}):null,p===`opencode`?(0,$.jsx)(q,{variant:`body-small-default`,as:`p`,className:`text-[var(--content-tertiary)]`,children:l(`providerEditorContent.baseUrlHintOpencode`)}):null]}),D&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:l(`providerEditorContent.modelsLabel`)}),(0,$.jsx)(V,{value:y,onChange:e=>b(e.target.value),placeholder:l(`providerEditorContent.modelsPlaceholder`),fullWidth:!0}),(0,$.jsx)(q,{variant:`body-small-default`,as:`p`,className:`text-[var(--content-tertiary)]`,children:l(`providerEditorContent.modelsHint`)})]}),m===`api_key`&&(0,$.jsx)(ct,{apiKeyValue:O,onApiKeyChange:k,credential:h,onCredentialChange:g,isLoadingCredential:F,apiKeyPlaceholder:ae,provider:p,providerCredentials:re,showAdvancedSection:ie,onError:w}),m===`oauth_subscription`&&(0,$.jsx)(nt,{assistantId:n,onConnected:s}),C&&(0,$.jsx)(q,{variant:`body-small-default`,as:`p`,className:`text-(--system-negative-strong)`,children:C})]}),se=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(U,{variant:`ghost`,onClick:c,children:l(`providerEditorContent.cancel`)}),(0,$.jsx)(U,{variant:`primary`,disabled:!ne||x||A,onClick:()=>void R(),children:l(x?`providerEditorContent.saving`:`providerEditorContent.saveChanges`)})]});return a===`panel`?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[oe,o===void 0?(0,$.jsx)(`div`,{className:`flex justify-end gap-2`,children:se}):o&&(0,hr.createPortal)(se,o)]}):(0,$.jsxs)(K.Content,{size:`md`,children:[(0,$.jsxs)(K.Header,{children:[(0,$.jsx)(K.Title,{children:l(`providerEditorContent.editProviderTitle`)}),(0,$.jsx)(K.Description,{children:t?l(`providerEditorContent.editingConnection`,{name:gt(t)}):l(`providerEditorContent.editProviderSettingsFallback`)})]}),(0,$.jsx)(K.Body,{children:oe}),(0,$.jsx)(K.Footer,{children:se})]})}function _r({assistantId:e,connectionName:t,onClose:n}){let{t:r}=Z(`settings`),i=Y(),[a,s]=(0,Q.useState)(null),{data:c,isLoading:l}=J(o({path:{assistant_id:e}})),u=(0,Q.useMemo)(()=>c?.connections??[],[c]),d=(0,Q.useMemo)(()=>t==null?void 0:u.find(e=>e.name===t),[t,u]),f=t!=null&&c!=null&&d==null;(0,Q.useEffect)(()=>{f&&n()},[f,n]);function p(){i.invalidateQueries({queryKey:Ne({path:{assistant_id:e}})}),i.invalidateQueries({queryKey:Lt({path:{assistant_id:e}})}),n()}return(0,$.jsx)(k,{title:d?gt(d):r(`providerDetailPanel.addProviderTitle`),closeVariant:`outlined`,onClose:n,footer:(0,$.jsx)(`div`,{ref:s,className:`flex justify-end gap-2`}),children:t!=null&&l?(0,$.jsx)(Ot,{placement:`panel`}):t==null||d!=null?(0,$.jsx)(gr,{mode:d?`edit`:`create`,connection:d,variant:`panel`,actionsSlot:a,assistantId:e,existingNames:u.map(e=>e.name),connections:u,onSave:p,onCancel:n}):null})}var vr={cadet:{provider:`cadet`},deepgram:{provider:`deepgram`,credentialService:`deepgram`},openai:{provider:`openai-whisper`,credentialService:`openai`}},yr={cadet:`cadet`,deepgram:`deepgram`,"openai-whisper":`openai`},br=`deepgram`;function xr({assistantId:e,hideSaveButton:t=!1,hideCredentialsGuide:n=!1,onSaveStateChange:r}={}){let i=T(),a=e??i,o=Nt(),s=Y(),{t:c}=Z(),l=(0,Q.useMemo)(()=>Re(It(),{displayName:c(`sttProviderForm.windowsNativeDisplayName`),subtitle:c(`sttProviderForm.windowsNativeSubtitle`),setupWarning:c(`sttProviderForm.windowsNativeSetupWarning`)}).filter(e=>!e.requiresNativeDictation||A()),[c]),u=br,{data:d}=J({...wt({path:{assistant_id:a}}),enabled:o,staleTime:3e4}),f=d?.services?.stt,p=f?.mode===`managed`?`cadet`:f?.provider,m=(0,Q.useMemo)(()=>{let e=p?yr[p]:void 0;if(e&&l.some(t=>t.id===e))return e;let t=z(ht,u);return l.some(e=>e.id===t)?t:u},[p,l,u]),h=!!p,[g,v]=yn(m),{available:y,currentCode:b,configuredProviderId:x,selectLanguage:S,selecting:C}=Tt(a),[w,E]=(0,Q.useState)(!1),D=y&&g===m&&(vr[g]?.provider===x||!!p&&!yr[p]),[O,k]=(0,Q.useState)(``),[j,M]=(0,Q.useState)(!1),[N,ee]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{let e=z(ht,u);e===`macos-native`&&!l.some(t=>t.id===e)&&H(ht,u)},[l,u]);let P=(0,Q.useMemo)(()=>l.find(e=>e.id===g)??l[0],[l,g]),F=P.apiKeyPlaceholder!==void 0;(0,Q.useEffect)(()=>{M(z(ge+g,``).length>0),k(``)},[g]);let I=(0,Q.useMemo)(()=>{let e=g!==m,t=O.trim().length>0;return e||t},[g,m,O]),L=(0,Q.useCallback)(async()=>{let e=O.trim();H(ht,g),e.length>0&&H(ge+g,e);let t=vr[g];ee(!0);try{if(t?.credentialService){let n=e.length>0?e:z(ge+g,``);if(n.length>0){let{response:e}=await te({path:{assistant_id:a},body:{service:t.credentialService,field:`api_key`,value:n,label:`${P.displayName} API Key`},throwOnError:!1});if(!e?.ok)throw Error(`Failed to store API key (HTTP ${e?.status??`?`})`)}}if(t&&(g!==m||!h)||p===`cadet`&&g!==`cadet`){let e=t?.provider??br,{response:n}=await _({path:{assistant_id:a},body:{services:{stt:{provider:e,mode:e===`cadet`?`managed`:`your-own`}}},throwOnError:!1});if(!n?.ok)throw Error(`Failed to save configuration (HTTP ${n?.status??`?`})`)}return e.length>0&&M(!0),k(``),s.invalidateQueries({queryKey:vt({path:{assistant_id:a}})}),W.success(c(`sttProviderForm.saveSuccess`)),!0}catch(e){return W.error(e instanceof Error?e.message:c(`sttProviderForm.saveFailed`)),!1}finally{ee(!1)}},[a,g,O,P,m,h,p,s,c]);(0,Q.useEffect)(()=>{r?.({hasChanges:I,saving:N,save:L})},[r,I,N,L]);let ne=(0,Q.useCallback)(()=>{H(ge+g,``),M(!1),k(``)},[g]),R=j?c(`sttProviderForm.apiKeyPlaceholderReplace`):P.apiKeyPlaceholder;return(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:c(`sttProviderForm.providerLabel`)}),(0,$.jsx)(G,{value:g,onChange:v,options:l.map(e=>({value:e.id,label:e.displayName})),"aria-label":c(`sttProviderForm.providerAriaLabel`)})]}),D&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:c(`sttProviderForm.spokenLanguage`)}),(0,$.jsx)(ze,{"aria-label":c(`sttProviderForm.spokenLanguage`),"aria-haspopup":`dialog`,onClick:()=>E(!0),value:Ve(b,x)}),(0,$.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:c(`sttProviderForm.spokenLanguageApplies`)}),(0,$.jsx)(_n,{open:w,onOpenChange:E,title:c(`sttProviderForm.spokenLanguage`),currentCode:b,configuredProviderId:x,selectLanguage:S,selecting:C})]}),F&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:c(`sttProviderForm.apiKeyLabel`)}),(0,$.jsx)(V,{type:`password`,value:O,onChange:e=>k(e.target.value),placeholder:R,fullWidth:!0})]}),P.setupWarning&&(0,$.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-[var(--border-subtle)] bg-[var(--surface-sunken)] p-3 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,$.jsx)($t,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--system-mid-strong)]`}),(0,$.jsx)(`span`,{children:P.setupWarning})]}),!n&&P.credentialsGuide&&(0,$.jsx)(fn,{guide:P.credentialsGuide}),g===`cadet`&&(0,$.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:c(`sttProviderForm.cadetTranscription`)}),(!t||j)&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!t&&(0,$.jsx)(dn,{onClick:L,disabled:!I||N}),j&&(0,$.jsx)(un,{onClick:ne})]})]})}var Sr={batch:`sttRoleOverrides.role.batch`,dictation:`sttRoleOverrides.role.dictation`,liveVoice:`sttRoleOverrides.role.liveVoice`,telephony:`sttRoleOverrides.role.telephony`,watch:`sttRoleOverrides.role.watch`};function Cr(e){let t=e?.roles;if(!t)return[];let n=e?.provider,r=n?e?.providers?.[n]?.model:void 0,i=[];for(let[e,a]of Object.entries(t)){let t=a?.provider;t&&(t===n&&a?.model===r||i.push({role:e,provider:t,...a?.model===void 0?{}:{model:a.model}}))}return i}function wr({assistantId:e}){let{t}=Z(`settings`),n=Y(),r=Nt(),[i,a]=(0,Q.useState)(null),{data:o}=J({...wt({path:{assistant_id:e}}),enabled:r,staleTime:3e4}),s=o?.services?.stt,c=Cr(s),{data:l}=J({...y({path:{assistant_id:e}}),enabled:r&&c.length>0,staleTime:5*6e4});if(c.length===0)return null;let u=e=>l?.providers?.find(t=>t.id===e)?.displayName??e,d=async r=>{a(r);try{let{response:t}=await _({path:{assistant_id:e},body:{services:{stt:{roles:{[r]:null}}}},throwOnError:!1});if(!t?.ok)throw Error(String(t?.status??``));await n.invalidateQueries({queryKey:vt({path:{assistant_id:e}})})}catch{W.error(t(`sttRoleOverrides.clearFailed`))}finally{a(null)}};return(0,$.jsxs)(`div`,{className:`mt-1 flex flex-col gap-2 border-t border-[var(--border-subtle)] pt-4`,children:[(0,$.jsx)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:t(`sttRoleOverrides.title`)}),(0,$.jsx)(`ul`,{className:`flex flex-col gap-1`,children:c.map(e=>{let n=Sr[e.role];return(0,$.jsxs)(`li`,{className:`flex items-center gap-4 rounded-md border border-[var(--border-subtle)] bg-[var(--surface-sunken)] px-3 py-2`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-body-medium-lighter text-[var(--content-default)]`,children:n?t(n):e.role}),(0,$.jsx)(`span`,{className:`min-w-0 truncate text-body-small-default text-[var(--content-default)]`,children:e.model?`${u(e.provider)} · ${e.model}`:u(e.provider)}),(0,$.jsx)(U,{variant:`ghost`,size:`compact`,"aria-label":t(`sttRoleOverrides.clearAria`,{feature:n?t(n):e.role}),className:`[--vbtn-fg:var(--content-tertiary)]`,disabled:i===e.role,onClick:()=>void d(e.role),children:t(`sttRoleOverrides.clear`)})]},e.role)})})]})}function Tr(){let{t:e}=Z(`settings`),t=T();return(0,$.jsxs)(ln,{title:e(`speechToTextCard.title`),subtitle:e(`speechToTextCard.subtitle`),children:[(0,$.jsx)(xr,{}),(0,$.jsx)(wr,{assistantId:t})]})}async function Er(e){let{provider:t,apiKey:n,voiceId:r,text:i}=e;if(n.trim().length===0)return{kind:`error`,message:`Save an API key for this provider first.`};try{return t===`elevenlabs`?await Dr(n,r,i):t===`deepgram`?await Or(n,i):t===`fish-audio`?{kind:`unsupported`,message:`Fish Audio TTS is only supported in the desktop app today. Use ElevenLabs or Deepgram to test from the browser.`}:t===`xai`?{kind:`unsupported`,message:`xAI TTS is only supported in the desktop app today. Use ElevenLabs or Deepgram to test from the browser.`}:{kind:`unsupported`,message:`TTS testing for "${t}" is not supported from the browser yet.`}}catch(e){return{kind:`error`,message:e instanceof Error?e.message:`Failed to reach the TTS provider.`}}}async function Dr(e,t,n){let r=t.trim();if(r.length===0)return{kind:`error`,message:`Enter and save a Voice ID before testing ElevenLabs.`};let i=await fetch(`https://api.elevenlabs.io/v1/text-to-speech/${encodeURIComponent(r)}?output_format=mp3_44100_128`,{method:`POST`,headers:{"xi-api-key":e,"Content-Type":`application/json`,Accept:`audio/mpeg`},body:JSON.stringify({text:n,model_id:`eleven_turbo_v2_5`})});return i.ok?{kind:`audio`,blob:await i.blob()}:{kind:`error`,message:await kr(i,`ElevenLabs rejected the request.`)}}async function Or(e,t){let n=await fetch(`https://api.deepgram.com/v1/speak?model=aura-2-thalia-en`,{method:`POST`,headers:{Authorization:`Token ${e}`,"Content-Type":`application/json`,Accept:`audio/mpeg`},body:JSON.stringify({text:t})});return n.ok?{kind:`audio`,blob:await n.blob()}:{kind:`error`,message:await kr(n,`Deepgram rejected the request.`)}}async function kr(e,t){try{let n=await e.text();if(n.length===0)return`${t} (HTTP ${e.status})`;try{let e=JSON.parse(n);if(e&&typeof e==`object`&&`detail`in e&&typeof e.detail==`string`)return e.detail;if(e&&typeof e==`object`&&`message`in e&&typeof e.message==`string`)return e.message}catch{}return n.slice(0,200)}catch{return`${t} (HTTP ${e.status})`}}function Ar({assistantId:e,value:t,onChange:n,className:r}){let{t:i}=Z(),[a,o]=(0,Q.useState)(!1),{voices:s}=B(e);if(s.length===0)return null;let c=s.find(e=>e.model===t)??s[0];return(0,$.jsxs)(d.Root,{open:a,onOpenChange:o,children:[(0,$.jsx)(d.Trigger,{asChild:!0,children:(0,$.jsx)(ze,{"aria-label":i(`voicePickerField.ariaLabel`),value:c?ft(c.description):i(`voicePickerField.selectVoice`),className:r})}),(0,$.jsx)(d.Content,{side:`bottom`,align:`start`,className:`w-[var(--radix-popover-trigger-width)] p-1`,children:(0,$.jsx)(j,{assistantId:e,value:t,onChange:n,onSelect:()=>o(!1),showSource:!0,autoScrollToSelected:!0})})]})}var jr={elevenlabs:`voiceId`,"fish-audio":`referenceId`,xai:`voiceId`};function Mr({assistantId:e,hideSaveButton:t=!1,hideCredentialsGuide:n=!1,onSaveStateChange:i}={}){let{t:a}=Z(),o=T(),s=e??o,c=Mt.use.name()??`your assistant`,l=Nt(),u=Y(),{data:d}=J({...m({path:{assistant_id:s}}),enabled:l,staleTime:1/0}),f=(0,Q.useMemo)(()=>{let e=d?.providers;if(!e)return Pe;if(e.some(e=>e.id===`cadet`))return e;let t=Pe.find(e=>e.id===`cadet`);return t?[t,...e]:e},[d]),{data:p}=J({...wt({path:{assistant_id:s}}),enabled:l,staleTime:3e4}),h=p?.services?.tts,g=h?.mode===`managed`?`cadet`:h?.provider,v=`elevenlabs`,y=(0,Q.useMemo)(()=>g??z(`cadet:voice:ttsProvider`,v),[g,v]),b=!!g,[x,S]=yn(y),[C,w]=(0,Q.useState)(``),[E,D]=(0,Q.useState)(``),[O,k]=(0,Q.useState)(``),[A,j]=(0,Q.useState)(!1),[M,N]=(0,Q.useState)(!1),[ee,P]=(0,Q.useState)(!1),{voices:F,defaultModel:I,fetched:L}=pe(s,{enabled:x===`cadet`}),ne=h?.providers?.cadet?.model??I??``,[R,re]=yn(ne),ie=F.find(e=>e.model===R)??F[0],[ae,oe]=(0,Q.useState)(null),se=F.some(e=>e.model===ne),ce=ae??(L&&ne!==``&&!se),B=(0,Q.useMemo)(()=>f.find(e=>e.id===x)??f[0],[x,f]),ue=x===`cadet`&&B.supportsVoiceSelection&&R.trim()!==``&&R.trim()!==ne,de=(0,Q.useCallback)(e=>{let t=z(r+e,``),n=z(le+e,``);j(t.length>0),D(n),k(n),w(``)},[]);(0,Q.useEffect)(()=>{de(x)},[x,de]);let fe=(0,Q.useMemo)(()=>{let e=x!==y,t=C.trim().length>0,n=E.trim()!==O;return e||t||n||ue},[x,y,C,E,O,ue]),me=(0,Q.useCallback)(async()=>{let e=C.trim(),t=E.trim(),n=B.id;H(pt,n),e.length>0&&H(r+n,e),H(le+n,t);let i=e.length>0?e:z(r+n,``),o=jr[n];P(!0);try{if(i.length>0){let{response:e}=await te({path:{assistant_id:s},body:{service:n,field:`api_key`,value:i,label:`${B.displayName} API Key`},throwOnError:!1});if(!e?.ok)throw Error(`Failed to store API key (HTTP ${e?.status??`?`})`)}let e={...x!==y||!b?{provider:n,mode:n===`cadet`?`managed`:`your-own`}:{},...o?{providers:{[n]:{[o]:t}}}:{},...ue?{providers:{cadet:{model:R.trim()}}}:{}};if(Object.keys(e).length>0){let{response:t}=await _({path:{assistant_id:s},body:{services:{tts:e}},throwOnError:!1});if(!t?.ok)throw Error(`Failed to save configuration (HTTP ${t?.status??`?`})`)}return j(i.length>0),k(t),w(``),u.invalidateQueries({queryKey:vt({path:{assistant_id:s}})}),W.success(a(`ttsProviderForm.saved`)),!0}catch(e){return W.error(e instanceof Error?e.message:a(`ttsProviderForm.saveFailed`)),!1}finally{P(!1)}},[s,x,R,ue,C,E,B,y,b,u,a]);(0,Q.useEffect)(()=>{i?.({hasChanges:fe,saving:ee,save:me})},[i,fe,ee,me]);let he=(0,Q.useCallback)(()=>{H(r+x,``),j(!1),w(``)},[x]),ge=(0,Q.useCallback)(async()=>{N(!0);try{let e=z(r+x,``),t=C.trim(),n=t.length>0?t:e;if(n.length===0){W.error(a(`ttsProviderForm.apiKeyRequired`));return}let i=z(le+x,``),o=E.trim(),s=await Er({provider:x,apiKey:n,voiceId:o.length>0?o:i,text:`Hey! It's ${c}. How does this sound?`});if(s.kind!==`audio`){W.error(s.message);return}let l=URL.createObjectURL(s.blob);try{let e=new Audio(l);await e.play(),await new Promise(t=>{e.onended=()=>t(),e.onerror=()=>t()})}finally{URL.revokeObjectURL(l)}}finally{N(!1)}},[c,C,x,E,a]),_e=A?`•••••••• (Enter a new key to replace)`:B.apiKeyPlaceholder,ve=x===`cadet`,ye=ve&&B.supportsVoiceSelection,be=(0,$.jsxs)(U,{variant:`link`,size:`compact`,className:`inline-flex h-auto items-center gap-1 px-0 underline [--vbtn-fg:var(--content-tertiary)]`,onClick:()=>{oe(!1),F.some(e=>e.model===R)||re(I||F[0]?.model||``)},children:[(0,$.jsx)(nn,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),a(`ttsProviderForm.chooseFromCatalog`)]}),xe=ye&&ce&&F.length>0?be:null;return(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:a(`ttsProviderForm.provider`)}),(0,$.jsx)(G,{value:x,onChange:S,options:f.map(e=>({value:e.id,label:e.displayName})),"aria-label":a(`ttsProviderForm.providerAriaLabel`)})]}),!ve&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:a(`ttsProviderForm.apiKey`)}),(0,$.jsx)(V,{type:`password`,value:C,onChange:e=>w(e.target.value),placeholder:_e,fullWidth:!0})]}),ye&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:a(`ttsProviderForm.voice`)}),ce?(0,$.jsx)(V,{type:`text`,value:R,onChange:e=>re(e.target.value),placeholder:a(`ttsProviderForm.voiceIdPlaceholder`),"aria-label":a(`ttsProviderForm.customVoiceIdAriaLabel`),fullWidth:!0}):ie?(0,$.jsx)(Ar,{assistantId:s,value:R,onChange:re}):L&&(0,$.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:a(`ttsProviderForm.noManagedVoices`)})]}),B.supportsVoiceSelection&&!ve&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:a(`ttsProviderForm.voiceId`)}),(0,$.jsx)(V,{type:`text`,value:E,onChange:e=>D(e.target.value),placeholder:a(`ttsProviderForm.voiceIdPlaceholder`),fullWidth:!0})]}),!n&&!ve&&(0,$.jsx)(fn,{guide:B.credentialsGuide}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!ve&&(0,$.jsx)(U,{variant:`outlined`,onClick:ge,disabled:M,children:a(M?`ttsProviderForm.testing`:`ttsProviderForm.test`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[xe,!t&&(0,$.jsx)(dn,{onClick:me,disabled:!fe||ee}),A&&!ve&&(0,$.jsx)(un,{onClick:he})]})]})]})}function Nr(){let{t:e}=Z(`settings`);return(0,$.jsx)(ln,{id:`text-to-speech`,title:e(`textToSpeechCard.title`),subtitle:e(`textToSpeechCard.subtitle`),children:(0,$.jsx)(Mr,{})})}var Pr=`default`;function Fr(){let{t:e}=Z(`settings`),t=T(),n=Y(),{data:r}=J({...wt({path:{assistant_id:t}}),staleTime:3e4}),a=ce({onSuccess:e=>{it(n,{path:{assistant_id:t}},e)}}),o=vn(),s=(0,Q.useMemo)(()=>r?r.services?.[`web-fetch`]?.provider||z(`cadet:ai:webFetchProvider`,Pr):z(me,Pr),[r]),c=(0,Q.useMemo)(()=>r?.services?.[`web-fetch`]?.apiBase??``,[r]),[u,d]=(0,Q.useState)(!1),[p,m]=yn(s),[h,g]=yn(c),[_,y]=(0,Q.useState)(``),b=I.has(p),x=ie.has(p),{hasStoredCredential:S}=xe({assistantId:t,credentialKind:`api_key`,credentialName:p,enabled:x}),C=_.trim().length>0,w=h.trim(),E=l(p,b&&w.length>0),D=p!==s||b&&w!==c.trim(),O=u||x&&!E&&!S&&!C||!D&&!C,k=At(je[p]??e(`webFetchCard.apiKeyPlaceholder`),S),A=Se[p]??``,j=(0,Q.useCallback)(async()=>{d(!0);let r=_.trim(),i=x&&r.length>0;try{i&&await o(p,r),await a.mutateAsync({path:{assistant_id:t},body:{services:{"web-fetch":{provider:p,...b?{apiBase:w}:{}}}}}).catch(t=>{throw W.error(e(`webFetchCard.configUpdateFailedToast`)),f(t,{context:`patch_daemon_config`}),t})}catch{d(!1);return}d(!1);try{if(H(me,p),i){let e=v(p);e&&H(e,r);let i=Ke(t,`api_key`,p);n.setQueryData(i,!0),n.invalidateQueries({queryKey:i}),y(``)}W.success(e(`webFetchCard.savedToast`))}catch(t){f(t,{context:`settings-ai-web-fetch-persist-local`}),W.error(e(`webFetchCard.localPreferencesFailedToast`))}},[x,a,o,n,t,_,p,b,w,e]),M=(0,Q.useCallback)(()=>{let e=v(p);e&&Ht(e),y(``),g(``),m(Pr),H(me,Pr)},[p,m,g]);return(0,$.jsx)(ln,{id:`web-fetch`,title:e(`webFetchCard.title`),subtitle:e(`webFetchCard.subtitle`),children:(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:e(`webFetchCard.providerLabel`)}),(0,$.jsx)(G,{value:p,onChange:m,options:i.map(e=>({value:e,label:Ut[e]??e}))})]}),b&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(V,{label:e(`webFetchCard.apiBaseLabel`),type:`url`,value:h,onChange:e=>g(e.target.value),placeholder:A||e(`webFetchCard.apiBasePlaceholder`),fullWidth:!0}),A?(0,$.jsx)(`p`,{className:`text-body-small-lighter text-[var(--content-tertiary)]`,children:e(`webFetchCard.apiBaseHint`,{defaultBase:A})}):null]}),x&&(0,$.jsx)(V,{label:e(`webFetchCard.apiKeyLabel`),type:`password`,value:_,onChange:e=>y(e.target.value),placeholder:k,fullWidth:!0}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(dn,{onClick:j,disabled:O}),u&&(0,$.jsx)(rn,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`}),x&&(0,$.jsx)(un,{onClick:M,filled:!0})]})]})})}var Ir=`0.10.12`;function Lr(){return fe(Ir)}function Rr(){let{t:e}=Z(`settings`),t=T(),r=Y(),i=Nt(),{data:a}=J({...wt({path:{assistant_id:t}}),enabled:i,staleTime:3e4}),o=ce({onSuccess:e=>{it(r,{path:{assistant_id:t}},e)}}),s=vn(),c=(0,Q.useMemo)(()=>{if(!a)return z(ye,`inference-provider-native`);let e=a.services?.[`web-search`];return(e?.mode===`managed`&&e?.provider!==`inference-provider-native`?`cadet`:e?.provider)||z(`cadet:ai:webSearchProvider`,`inference-provider-native`)},[a]),u=(0,Q.useMemo)(()=>a?.services?.[`web-search`]?.apiBase??``,[a]),[d,m]=(0,Q.useState)(!1),[h,g]=yn(c),[_,v]=yn(u),[y,b]=(0,Q.useState)(``),x=mt.has(h),C=n.has(h),w=dt.has(h),{hasStoredCredential:E}=xe({assistantId:t,credentialKind:`api_key`,credentialName:h,enabled:C}),D=y.trim().length>0,O=_.trim(),k=l(h,x&&O.length>0),A=h!==c||x&&O!==u.trim(),j=se[h]??``,M=C&&!w&&!k&&!E&&!D,N=x&&j.length===0&&!O,ee=d||M||N||!A&&!D,P=At(S[h]??e(`webSearchCard.apiKeyPlaceholder`),E),F=(0,Q.useCallback)(async()=>{m(!0);let n=y.trim(),i=p(h),a=C&&n.length>0;try{a&&await s(h,n),await ae();let r=h===`cadet`?Lr()?{provider:`cadet`,mode:`managed`}:{mode:`managed`}:{provider:h,mode:`your-own`,...x?{apiBase:O}:{}};await o.mutateAsync({path:{assistant_id:t},body:{services:{"web-search":r}}}).catch(t=>{throw W.error(e(`webSearchCard.configUpdateFailedToast`)),f(t,{context:`patch_daemon_config`}),t})}catch{m(!1);return}m(!1);try{if(H(ye,h),a){i&&H(i,n);let e=Ke(t,`api_key`,h);r.setQueryData(e,!0),r.invalidateQueries({queryKey:e}),b(``)}W.success(e(`webSearchCard.savedToast`))}catch(t){f(t,{context:`settings-ai-web-search-persist-local`}),W.error(e(`webSearchCard.localPreferencesFailedToast`))}},[C,o,s,r,t,y,h,x,O,e]),I=(0,Q.useCallback)(()=>{let e=p(h);e&&Ht(e),b(``),v(``),g(`inference-provider-native`),H(ye,`inference-provider-native`)},[h,g,v]);return(0,$.jsx)(ln,{title:e(`webSearchCard.title`),subtitle:e(`webSearchCard.subtitle`),children:(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:e(`webSearchCard.providerLabel`)}),(0,$.jsx)(G,{"aria-label":e(`webSearchCard.providerAriaLabel`),value:h,onChange:g,options:_e.map(e=>({value:e,label:de[e]??e}))})]}),h===`cadet`&&(0,$.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:e(`webSearchCard.cadetNote`)}),x&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(V,{label:e(`webSearchCard.apiBaseLabel`),type:`url`,value:_,onChange:e=>v(e.target.value),placeholder:j||e(`webSearchCard.apiBasePlaceholder`),fullWidth:!0}),j?(0,$.jsx)(`p`,{className:`text-body-small-lighter text-[var(--content-tertiary)]`,children:e(`webSearchCard.apiBaseHint`,{defaultBase:j})}):null]}),C&&(0,$.jsx)(V,{label:e(`webSearchCard.apiKeyLabel`),type:`password`,value:y,onChange:e=>b(e.target.value),placeholder:P,fullWidth:!0}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(dn,{onClick:F,disabled:ee}),d&&(0,$.jsx)(rn,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`}),C&&(0,$.jsx)(un,{onClick:I,filled:!0})]})]})})}function zr(){let e=T(),t=bt(),[n,r]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{let e=window.location.hash.slice(1);e&&requestAnimationFrame(()=>{document.getElementById(e)?.scrollIntoView({block:`start`})})},[]);let i=(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-5 overflow-y-auto`,children:[(0,$.jsx)(tr,{}),(0,$.jsx)($n,{panel:n,onOpenPanel:r,onClosePanel:()=>r(null)}),(0,$.jsx)(Rr,{}),(0,$.jsx)(Fr,{}),(0,$.jsx)(wn,{}),(0,$.jsx)(Nr,{}),(0,$.jsx)(Tr,{})]}),a=`${e??`none`}:${n?.kind===`profile`?`profile:${n.name}`:n?.kind===`provider`?`provider:${n.name}`:n?.kind??`closed`}`,o=n?.kind===`provider`||n?.kind===`add-provider`,s=n!=null&&e?n.kind===`overrides`?(0,$.jsx)(mr,{assistantId:e,onClose:()=>r(null)},a):o?(0,$.jsx)(_r,{assistantId:e,connectionName:n.kind===`provider`?n.name:null,onClose:()=>r(null)},a):(0,$.jsx)(nr,{assistantId:e,profileName:n.kind===`profile`?n.name:null,onClose:()=>r(null)},a):null;return s&&t?(0,$.jsx)(mn,{children:s}):s?(0,$.jsx)(gn,{storageKey:`aiSettingsDetailDrawerWidth`,detailKey:a,section:i,detail:s}):i}export{zr as AiPage};
1
+ import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{$ as t,Ab as n,As as r,Bb as i,Bf as a,Bp as o,Bv as s,CC as c,Cb as l,Cr as u,DC as d,DS as f,Db as p,Dm as m,Dr as h,Ds as g,Dv as _,Eb as v,Em as y,Er as b,Es as x,Fb as S,Fs as C,Fy as w,G as T,GC as E,Gb as D,Gf as O,Gn as k,Gs as A,Gt as j,HC as M,Hb as N,Hf as ee,Hs as P,IC as F,Ib as I,Iv as te,Jb as L,Ji as ne,Kb as R,Kf as re,LS as z,Lb as ie,Lg as ae,Ls as oe,Mb as se,Mm as ce,Mo as B,Ms as le,NS as ue,Nb as de,Ng as fe,No as pe,Ns as me,Ob as he,Os as ge,Pb as _e,Pg as ve,Ps as ye,QC as be,Qm as xe,Rb as Se,Rp as Ce,Rs as we,Sr as Te,TC as V,Tb as Ee,Tr as De,Ub as Oe,Uf as ke,Us as Ae,VS as H,Vb as je,Vf as Me,Vp as Ne,Vs as Pe,Vv as Fe,Wb as Ie,Wf as Le,Ws as Re,X as ze,XC as U,Xb as Be,Y as Ve,Yb as He,Yi as Ue,ZS as We,Zb as Ge,Zm as Ke,_p as qe,ah as Je,ap as Ye,by as Xe,ch as Ze,dC as Qe,dh as $e,fC as W,fh as et,gp as tt,gv as nt,hm as rt,hp as it,iC as at,ih as ot,in as st,ip as ct,iy as lt,jC as ut,jb as dt,jo as ft,js as pt,kb as mt,ks as ht,lC as G,lh as gt,mm as _t,mp as vt,np as yt,nu as bt,oh as xt,op as St,pC as K,pm as Ct,pp as wt,q as Tt,qb as Et,qf as Dt,qn as Ot,rh as kt,rp as At,sh as jt,tS as Mt,th as Nt,tp as Pt,uh as Ft,vg as It,vp as Lt,wC as Rt,wb as zt,wr as Bt,yp as Vt,zC as q,zS as Ht,zb as Ut,zm as Wt,zp as Gt,zs as Kt}from"./app-CPkqAi_4.js";import{b as qt,t as Jt,x as Yt}from"./react-BJ4PZBJN.js";import{E as Xt,Jn as Zt,Zn as J,er as Y,k as X,w as Z}from"./vendor-D-45vVY0.js";import{A as Qt,D as $t,Lt as en,Ui as tn,Xn as nn,Yn as rn,Zr as an,fr as on,vt as sn}from"./icons-Dwi7aA1Y.js";import{t as cn}from"./ellipsis-vertical-DXwTXFid.js";import{i as ln,n as un,r as dn,t as fn}from"./service-form-controls-DEbGvmzt.js";import{o as pn}from"./detail-primitives-DYFVgm7V.js";import{d as mn,o as hn,u as gn}from"./schedules-_0jiWipo.js";import{t as _n}from"./stt-language-picker-modal-DBimk9bU.js";var Q=e(Yt(),1);function vn(){let e=T();return(0,Q.useCallback)(async(t,n)=>{try{let{data:r}=await Xe({path:{assistant_id:e},body:{value:n,type:`api_key`,name:t},throwOnError:!0});zt(r)}catch(e){throw e instanceof Error&&e.message===`No assistant found`?W.error(X(`settings:useDaemonConfig.assistantNotReadyToast`)):W.error(X(`settings:useDaemonConfig.saveApiKeyFailedToast`,{providerName:t})),f(e,{context:`provision_provider_key`}),e}},[e])}function yn(e){let[t,n]=(0,Q.useState)(void 0);return(0,Q.useEffect)(()=>{t!==void 0&&e===t.value&&n(void 0)},[e,t]),[t===void 0?e:t.value,(0,Q.useCallback)(e=>n(e===void 0?void 0:{value:e}),[])]}var bn=`0.11.0`;function xn(){return fe(bn)}var $=Jt(),Sn=`gemini-3.1-flash-image-preview`;function Cn(e,t){return e===`openrouter`?`openrouter`:Ae(t)}function wn(){let{t:e}=Z(`settings`),t=T(),n=Y(),r=Nt(),{data:i}=J({...wt({path:{assistant_id:t}}),enabled:r,staleTime:3e4}),a=ce({onSuccess:e=>{it(n,{path:{assistant_id:t}},e)}}),o=vn(),s=i?.services?.[`image-generation`],c=(0,Q.useMemo)(()=>i?s?.mode===`managed`?`cadet`:s?.provider||z(`cadet:ai:imageGenProvider`,`gemini`):z(g,`gemini`),[i,s?.mode,s?.provider]),[l,u]=yn(c),[d,p]=(0,Q.useState)(()=>z(x,Sn)),[m,h]=(0,Q.useState)(null),_=c===`openrouter`&&typeof s?.model==`string`?s.model:void 0,v=m??_??z(`cadet:ai:imageGenModel`,`google/gemini-3.1-flash-image-preview`),y=l===`openrouter`,b=P(l),S=y?v.trim()||`google/gemini-3.1-flash-image-preview`:b.includes(d)?d:b[0]??Sn,[w,E]=(0,Q.useState)(``),[D,O]=(0,Q.useState)(!1),k=we.map(e=>({value:e,label:Kt[e]??e})),A=(0,Q.useMemo)(()=>P(l).map(e=>({value:e,label:oe[e]??e})),[l]),j=l===`gemini`||l===`openai`||l===`openrouter`,{hasStoredCredential:M}=xe({assistantId:t,credentialKind:`api_key`,credentialName:l,enabled:j}),N=(0,Q.useCallback)(e=>{u(e),e===`openrouter`&&m===null&&h(_??`google/gemini-3.1-flash-image-preview`)},[m,_,u]),ee=(0,Q.useCallback)(async()=>{O(!0);let r=w.trim(),i=j&&r.length>0;try{await ae(),i&&await o(Cn(l,S),r);let s=l===`cadet`&&!xn()?{mode:`managed`}:{provider:l,mode:l===`cadet`?`managed`:`your-own`};await a.mutateAsync({path:{assistant_id:t},body:{services:{"image-generation":s}}}).catch(t=>{throw W.error(e(`imageGenerationCard.configUpdateFailedToast`)),f(t,{context:`patch_daemon_config`}),t});try{await lt({path:{assistant_id:t},body:{modelId:S},throwOnError:!0})}catch(t){throw W.error(e(`imageGenerationCard.modelUpdateFailedToast`)),f(t,{context:`set_image_gen_model`}),t}finally{n.invalidateQueries({queryKey:vt({path:{assistant_id:t}})})}}catch{O(!1);return}O(!1);try{if(H(g,l),H(x,S),i){let e=Ke(t,`api_key`,l);n.setQueryData(e,!0),n.invalidateQueries({queryKey:e}),E(``)}W.success(e(`imageGenerationCard.savedToast`))}catch(t){f(t,{context:`settings-ai-image-gen-persist-local`}),W.error(e(`imageGenerationCard.localPreferencesFailedToast`))}},[w,l,j,S,t,a,o,n,e]),F=(0,Q.useCallback)(()=>{if(E(``),l===`openrouter`){h(C),H(x,C);return}p(Sn),H(x,Sn)},[l]),I=e(l===`openai`?`imageGenerationCard.openaiApiKeyPlaceholder`:l===`openrouter`?`imageGenerationCard.openrouterApiKeyPlaceholder`:`imageGenerationCard.geminiApiKeyPlaceholder`);return(0,$.jsx)(ln,{title:e(`imageGenerationCard.title`),subtitle:e(`imageGenerationCard.subtitle`),children:(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:e(`imageGenerationCard.providerLabel`)}),(0,$.jsx)(G,{"aria-label":e(`imageGenerationCard.providerAriaLabel`),value:l,onChange:N,options:k})]}),l===`cadet`&&(0,$.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:e(`imageGenerationCard.cadetNote`)}),j&&(0,$.jsx)(V,{label:e(`imageGenerationCard.apiKeyLabel`),type:`password`,value:w,onChange:e=>E(e.target.value),placeholder:At(I,M),fullWidth:!0}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:e(`imageGenerationCard.activeModelLabel`)}),y?(0,$.jsx)(V,{"aria-label":e(`imageGenerationCard.modelAriaLabel`),value:v,onChange:e=>h(e.target.value),placeholder:e(`imageGenerationCard.openrouterModelPlaceholder`),fullWidth:!0}):(0,$.jsx)(G,{"aria-label":e(`imageGenerationCard.modelAriaLabel`),value:S,onChange:p,options:A})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(dn,{onClick:ee,disabled:D}),D&&(0,$.jsx)(rn,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`}),j&&(0,$.jsx)(un,{onClick:F})]})]})})}function Tn({title:e,count:t,action:n,children:r}){return(0,$.jsxs)(`section`,{className:`rounded-xl border border-[var(--border-hover)] bg-[var(--surface-overlay)] px-3 py-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[(0,$.jsx)(q,{variant:`body-large-default`,as:`h3`,className:`text-[var(--content-secondary)]`,children:e}),t==null?null:(0,$.jsxs)(q,{variant:`body-large-default`,as:`span`,"aria-label":`${t} ${e.toLowerCase()}`,className:`text-[var(--content-disabled)]`,children:[`·`,` `,t]})]}),n]}),r==null?null:(0,$.jsx)(`div`,{className:`mt-4 border-t border-[var(--border-base)]`,children:r})]})}function En(e){return e.scheduleNames.length>0||e.deferredReminderCount>0||e.scheduleLookupFailed}var Dn=5;function On({title:e,items:t,mono:n}){return(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(q,{variant:`body-small-default`,as:`p`,className:`text-(--content-tertiary)`,children:e}),(0,$.jsx)(`ul`,{className:`space-y-1 pl-1`,children:t.map(e=>(0,$.jsxs)(`li`,{className:`text-body-small-default text-(--content-secondary)`,children:[`• `,n?(0,$.jsx)(`code`,{children:e}):e]},e))})]})}function kn(e){let t=e.label||e.name,n=[];e.isActive&&n.push(X(`settings:manageProfilesBlockedDeleteModal.clauseDefaultProfile`)),e.callSiteIds.length>0&&n.push(X(`settings:manageProfilesBlockedDeleteModal.clauseActionOverrides`,{count:e.callSiteIds.length}));let r=e.scheduleNames.length,i=e.deferredReminderCount;return r>0&&i>0?n.push(X(`settings:manageProfilesBlockedDeleteModal.clauseRunsBoth`,{schedules:r,reminders:i})):r>0?n.push(X(`settings:manageProfilesBlockedDeleteModal.clauseRunsSchedules`,{count:r})):i>0&&n.push(X(`settings:manageProfilesBlockedDeleteModal.clauseRunsReminders`,{count:i})),n.length===0?X(`settings:manageProfilesBlockedDeleteModal.summaryNoReferences`,{display:t}):n.length===1?X(`settings:manageProfilesBlockedDeleteModal.summaryOneClause`,{display:t,clause1:n[0]}):n.length===2?X(`settings:manageProfilesBlockedDeleteModal.summaryTwoClauses`,{display:t,clause1:n[0],clause2:n[1]}):X(`settings:manageProfilesBlockedDeleteModal.summaryThreeClauses`,{display:t,clause1:n[0],clause2:n[1],clause3:n[2]})}function An({blocked:e,availableReplacements:t,replacement:n,onReplacementChange:r,error:i,saving:a,onClose:o,onConfirm:s}){let{t:c}=Z(`settings`),l=e?.scheduleNames??[],u=l.slice(0,Dn),d=l.length-u.length,f=e!=null&&En(e);return(0,$.jsx)(K.Root,{open:e!==null,onOpenChange:e=>{e||o()},children:(0,$.jsxs)(K.Content,{size:`sm`,children:[(0,$.jsx)(K.Header,{children:(0,$.jsx)(K.Title,{children:c(`manageProfilesBlockedDeleteModal.title`)})}),(0,$.jsxs)(K.Body,{className:`space-y-4`,children:[e&&(0,$.jsx)(q,{variant:`body-medium-default`,as:`p`,children:kn(e)}),e&&e.callSiteIds.length>0&&(0,$.jsx)(On,{title:c(`manageProfilesBlockedDeleteModal.actionOverridesTitle`),items:e.callSiteIds,mono:!0}),u.length>0&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(On,{title:c(`manageProfilesBlockedDeleteModal.schedulesTitle`),items:u}),d>0&&(0,$.jsx)(q,{variant:`body-small-default`,as:`p`,className:`pl-1 text-(--content-tertiary)`,children:c(`manageProfilesBlockedDeleteModal.moreSchedules`,{count:d})})]}),e?.scheduleLookupFailed&&(0,$.jsx)(q,{variant:`body-small-default`,as:`p`,className:`text-(--system-mid-strong)`,children:c(`manageProfilesBlockedDeleteModal.scheduleLookupFailed`)}),(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-(--content-tertiary)`,children:c(`manageProfilesBlockedDeleteModal.replacementLabel`)}),(0,$.jsx)(G,{"aria-label":c(`manageProfilesBlockedDeleteModal.replacementLabel`),value:n,onChange:r,placeholder:c(`manageProfilesBlockedDeleteModal.replacementPlaceholder`),options:t.map(e=>{let t=f&&e.status===`disabled`;return{value:e.name,label:Bt(e),disabled:t,tooltip:t?c(`manageProfilesBlockedDeleteModal.disabledTargetTooltip`):void 0}})})]}),i&&(0,$.jsx)(q,{variant:`body-small-default`,as:`p`,className:`text-(--system-negative-strong)`,children:i})]}),(0,$.jsxs)(K.Footer,{children:[(0,$.jsx)(U,{variant:`ghost`,size:`compact`,onClick:o,children:c(`manageProfilesBlockedDeleteModal.cancel`)}),(0,$.jsx)(U,{variant:`primary`,size:`compact`,disabled:!n||a,onClick:s,children:c(a?`manageProfilesBlockedDeleteModal.saving`:`manageProfilesBlockedDeleteModal.reassignAndDelete`)})]})]})})}function jn({profile:e,isActiveProfile:t,selected:n,connections:r,deletePending:i=!1,onOpen:a,onMakeActive:o,onSetStatus:s,onDelete:c}){let{t:l}=Z(`settings`),u=e.source===`managed`,d=e.status===`disabled`,f=e.label??e.name,p=[];e.name===`auto`&&u?p.push(l(`profileRow.autoRouting`)):e.model&&p.push(ke(e.provider??void 0,e.model,r)),u&&p.push(l(`profileRow.managedByCadet`));let m=e.availability,h=e.config_issue,g=h!=null||m?.status===`incomplete`,_=m?.message??l(`profileRow.providerUnavailableDefault`),v=h==null?m!=null&&m.status!==`ok`?g?l(`profileRow.providerUnavailableFixable`,{message:_}):_:null:l(`profileRow.providerUnavailableFixable`,{message:l(h.code===`over_output_cap`?`profileRow.configIssueOverOutputCap`:h.code===`no_input_room`?`profileRow.configIssueNoInputRoom`:`profileRow.configIssueModelUnknown`)});return(0,$.jsx)(We,{title:(0,$.jsx)(`span`,{className:d?`opacity-55`:void 0,children:f}),subtitle:p.length>0?p.join(` • `):void 0,onClick:a,showChevron:!1,selected:n,disabled:i,contentAriaLabel:l(`profileRow.openProfileAriaLabel`,{displayName:f}),trailingInteractive:!0,trailing:(0,$.jsxs)($.Fragment,{children:[v==null?null:(0,$.jsx)(be,{content:v,children:g?(0,$.jsx)(U,{variant:`ghost`,size:`compact`,iconOnly:(0,$.jsx)(tn,{}),iconOnlyGlyphClassName:`[&_svg]:size-4`,tintColor:`var(--system-mid-strong)`,expandOnMobile:!1,onClick:a,"aria-label":v}):(0,$.jsx)(`span`,{className:`inline-flex p-0.5`,tabIndex:0,children:(0,$.jsx)(tn,{className:`h-4 w-4 text-[var(--system-mid-strong)]`,"aria-label":v,role:`img`})})}),d?(0,$.jsx)(ut,{tone:`neutral`,children:l(`profileRow.disabledTag`)}):null,t?(0,$.jsx)(ut,{tone:`positive`,children:l(`profileRow.defaultTag`)}):null,(0,$.jsxs)(E.Root,{children:[(0,$.jsx)(E.Trigger,{asChild:!0,children:(0,$.jsx)(U,{variant:`ghost`,size:`compact`,iconOnly:(0,$.jsx)(cn,{}),"aria-label":l(`profileRow.actionsAriaLabel`,{displayName:f}),disabled:i})}),(0,$.jsxs)(E.Content,{align:`end`,sideOffset:4,children:[(0,$.jsx)(E.Item,{onSelect:a,children:l(u?`profileRow.view`:`profileRow.edit`)}),!t&&!d&&L(e.provider,e.model)?(0,$.jsx)(E.Item,{onSelect:o,children:l(`profileRow.makeDefault`)}):null,d?(0,$.jsx)(E.Item,{onSelect:()=>s(!0),children:l(`profileRow.enable`)}):u?null:(0,$.jsx)(E.Item,{onSelect:()=>s(!1),children:l(`profileRow.disable`)}),u?null:(0,$.jsx)(E.Item,{onSelect:c,className:M.anchored,children:l(`profileRow.delete`)})]})]})]})})}function Mn(e,t){let n=ne(),{data:r}=J({...Ce({path:{assistant_id:e}}),enabled:n,staleTime:3e4}),{profiles:i,profileOrder:a}=st(t?.llm,e);return(0,Q.useMemo)(()=>r==null?{entries:Ee(i,a).map(e=>({name:e.name,label:e.label??null,provider:e.provider??null,model:e.model??null,status:e.status===`disabled`?`disabled`:`active`,source:e.source===`managed`?`managed`:`user`,provider_connection:e.provider_connection,availability:null})),isEffectiveCatalog:!1}:{entries:r.profiles,isEffectiveCatalog:!0},[r,i,a])}var Nn=`0.10.8`;function Pn(e){return ve(Nn,e)}var Fn=`settings-ai-profile-make-active`,In=`Failed to set the active profile. Please try again.`;function Ln(e){let t=Me(),n=Y(),r=Pn(e),i=Wt({onSuccess:()=>{n.invalidateQueries({queryKey:vt({path:{assistant_id:e}})}),n.invalidateQueries({queryKey:Gt({path:{assistant_id:e}})})}});async function a(n,r,i){try{await t.mutateAsync({path:{assistant_id:e},body:{llm:n}})}catch(e){throw f(e,{context:r}),W.error(i),e}}async function o(t){if(!r){await a({activeProfile:t},Fn,In);return}try{await i.mutateAsync({path:{assistant_id:e},body:{name:t}})}catch(e){let t=ue(e);throw W.error(t??In),t||f(e,{context:Fn}),e}}return{makeActive:o,setStatus:(e,t)=>a({profiles:{[e]:{status:t?`active`:`disabled`}}},`settings-ai-profile-toggle`,`Failed to update the profile. Please try again.`),deleteProfile:(e,t,n)=>a({profiles:{[e]:null},profileOrder:t.filter(t=>t!==e),...n?.isAdvisor?{advisorProfile:null}:{}},`settings-ai-profile-delete`,`Failed to delete the profile. Please try again.`),patchLlm:a,isPending:t.isPending||i.isPending}}var Rn=`The profile was not deleted.`,zn=`Failed to move the schedules. ${Rn}`;function Bn(e){let t=ue(e);return t?`${/[.!?]$/.test(t)?t:`${t}.`} ${Rn}`:zn}function Vn(e,n,r){let i=Ln(e),a=Y(),o=t(),s=n?.llm?.activeProfile??null,c=n?.llm?.advisorProfile??null,l=n?.llm?.callSites??{},u=(0,Q.useMemo)(()=>n?.llm?.profiles??{},[n?.llm?.profiles]),d=(0,Q.useMemo)(()=>n?.llm?.profileOrder??[],[n?.llm?.profileOrder]),p=(0,Q.useMemo)(()=>Ee(u,d),[u,d]),[m,h]=(0,Q.useState)(null),[g,_]=(0,Q.useState)(null),[v,y]=(0,Q.useState)(``),[b,x]=(0,Q.useState)(!1),[S,C]=(0,Q.useState)(null),w=(0,Q.useRef)(!1);function T(e){return p.filter(t=>t.name===e?!1:t.status===`disabled`?!0:Te(t,p,{requireOwnProviderAndModel:o}))}function E(e,t){let n=T(e).filter(e=>!t||e.status!==`disabled`),r=n.find(e=>e.name===s),i=n.find(e=>e.source!==`managed`);return(r??i??n[0])?.name??``}async function D(e){try{await i.deleteProfile(e,d,{isAdvisor:e===c}),r?.onDeleted?.(e)}catch{}}async function O(t){let n=u[t]?.label??t,r=t===s,i=Object.entries(l).filter(([e,n])=>e!==`mainAgent`&&n?.profile===t).map(([e])=>e),o=[],c=0,d=!1;try{let n=(await a.fetchQuery({...Ct({path:{assistant_id:e},query:{inference_profile:t,include_all:`true`}}),retry:!1,staleTime:0})).schedules??[];o=n.filter(e=>!e.isDeferred).map(e=>e.name),c=n.filter(e=>e.isDeferred).length}catch(e){f(e,{context:`settings-ai-profile-delete-schedule-scan`}),d=!0}if(!(r||i.length>0||o.length>0||c>0)&&!d){await D(t);return}let p={name:t,label:n,isActive:r,callSiteIds:i,scheduleNames:o,deferredReminderCount:c,scheduleLookupFailed:d};h(p),y(E(t,En(p))),_(null)}function k(e){n==null||w.current||(w.current=!0,C(e),O(e).finally(()=>{w.current=!1,C(null)}))}async function A(){if(!m||!v)return;if(x(!0),_(null),En(m))try{await hn(e,m.name,v),await a.invalidateQueries({queryKey:_t({path:{assistant_id:e}})})}catch(e){f(e,{context:`settings-ai-profile-reassign-schedules`}),_(Bn(e)),x(!1);return}let t={};if(m.isActive&&(t.activeProfile=v),m.callSiteIds.length>0){let e={};for(let t of m.callSiteIds)e[t]={profile:v};t.callSites=e}if(Object.keys(t).length>0)try{await i.patchLlm(t,`settings-ai-profile-reassign-delete`,`Failed to reassign references. Please try again.`)}catch{_(`Failed to reassign references. Please try again.`),x(!1);return}let n=m.name;h(null),x(!1),D(n)}return{requestDelete:k,pendingDeleteName:S,blockedDeleteModalProps:{blocked:m,availableReplacements:T(m?.name??null),replacement:v,onReplacementChange:y,error:g,saving:b,onClose:()=>{h(null),_(null)},onConfirm:()=>void A()}}}function Hn(){}function Un({assistantId:e,config:t,connections:n,selectedProfileName:r,onOpenProfile:i,onCreateProfile:a,onProfileDeleted:o}){let{t:s}=Z(`settings`),{entries:c}=Mn(e,t),l=Ln(e),u=Vn(e,t,{onDeleted:o}),d=t?.llm?.activeProfile??null;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(Tn,{title:s(`profilesSection.title`),action:(0,$.jsx)(U,{variant:`primary`,onClick:a,leftIcon:(0,$.jsx)(en,{}),disabled:t==null,children:s(`profilesSection.createProfile`)}),children:t==null?(0,$.jsx)(q,{variant:`body-medium-lighter`,as:`p`,className:`py-4 text-center text-(--content-tertiary)`,children:s(`profilesSection.loading`)}):c.length===0?(0,$.jsx)(q,{variant:`body-medium-lighter`,as:`p`,className:`py-4 text-center text-(--content-tertiary)`,children:s(`profilesSection.emptyState`)}):c.map(e=>(0,$.jsx)(jn,{profile:e,isActiveProfile:e.name===d,selected:e.name===r,connections:n,deletePending:u.pendingDeleteName===e.name,onOpen:()=>i(e.name),onMakeActive:()=>void l.makeActive(e.name).catch(Hn),onSetStatus:t=>void l.setStatus(e.name,t).catch(Hn),onDelete:()=>u.requestDelete(e.name)},e.name))}),(0,$.jsx)(An,{...u.blockedDeleteModalProps})]})}var Wn={anthropic:!0,openai:!0,gemini:!0,fireworks:!0,openrouter:!0,chatgpt:!0,cadet:!0,together:!0,"vercel-ai-gateway":!0,minimax:!0,atlascloud:!0,baseten:!0,ionet:!0,poolside:!0,litellm:!0,opencode:!0};function Gn(e){return e in Wn}function Kn(e){if(!e.baseUrl)return null;try{return new URL(e.baseUrl).host}catch{return e.baseUrl}}function qn(e){let t=Kn(e)??``,n=[];t&&n.push(t);let r=e.models?.length??0;return r>0&&n.push(`${r} ${r===1?`model`:`models`}`),e.auth.type===`none`&&n.push(`keyless`),n.join(` · `)}function Jn(e){switch(e.auth.type){case`api_key`:return`Own API key`;case`oauth_subscription`:return`ChatGPT subscription`;case`none`:return`No API key needed`;default:return null}}function Yn(e){if(e.provider===`cadet`)return`Included with your plan`;if(e.provider===`openai-compatible`)return qn(e);let t=[];if(e.provider===`ollama`||e.provider===`opencode`){let n=Kn(e);n&&t.push(n)}let n=e.provider===`chatgpt`?`openai`:e.provider,r=e.auth.type===`oauth_subscription`?O(n):Be(n),i=e.models?.length??r.length;i>0&&t.push(`${i} ${i===1?`model`:`models`}`);let a=Jn(e);return a&&t.push(a),t.join(` • `)}function Xn({connection:e,isDefault:t,supportsDefaultProvider:n,selected:r,isSettingDefault:i,onOpen:a,onSetDefault:o,onDelete:s}){let{t:c}=Z(`settings`),l=e.isManaged??!1,u=gt(e),d=Gn(e.provider),f=Yn(e),p=n&&!t&&d,m=!l&&a!=null,h=!l&&!t,g=p||m||h;return(0,$.jsx)(We,{title:u,subtitle:f.length>0?f:void 0,onClick:a,showChevron:!1,selected:r,contentAriaLabel:a?c(`providerRow.openProviderAriaLabel`,{displayName:u}):void 0,trailingInteractive:!0,trailing:(0,$.jsxs)($.Fragment,{children:[l?(0,$.jsx)(ut,{tone:`neutral`,title:c(`providerRow.managedTagTitle`),children:c(`providerRow.managedTag`)}):null,t?(0,$.jsx)(ut,{tone:`info`,title:c(`providerRow.defaultTagTitle`),children:c(`providerRow.defaultTag`)}):null,e.provider===`ollama`?(0,$.jsx)(ut,{tone:`neutral`,title:c(`providerRow.localTagTitle`),children:c(`providerRow.localTag`)}):null,e.provider===`openai-compatible`?(0,$.jsx)(ut,{tone:`neutral`,title:c(`providerRow.customTagTitle`),children:c(`providerRow.customTag`)}):null,g?(0,$.jsxs)(E.Root,{children:[(0,$.jsx)(E.Trigger,{asChild:!0,children:(0,$.jsx)(U,{variant:`ghost`,size:`compact`,iconOnly:(0,$.jsx)(cn,{}),"aria-label":c(`providerRow.actionsAriaLabel`,{displayName:u})})}),(0,$.jsxs)(E.Content,{align:`end`,sideOffset:4,children:[m?(0,$.jsx)(E.Item,{onSelect:a,children:c(`providerRow.edit`)}):null,p?(0,$.jsx)(E.Item,{disabled:i,onSelect:o,children:c(`providerRow.setAsDefault`)}):null,h?(0,$.jsx)(E.Item,{onSelect:s,className:M.anchored,children:c(`providerRow.delete`)}):null]})]}):(0,$.jsx)(`span`,{className:`inline-block w-8`,"aria-hidden":!0})]})})}function Zn(e,t){let n=Y(),r={path:{assistant_id:e}},i=Zt({...Vt(),onSuccess:()=>{n.invalidateQueries({queryKey:Lt(r)}),n.invalidateQueries({queryKey:vt(r)}),n.invalidateQueries({queryKey:Gt(r)})},onError:e=>{f(e,{context:`settings-ai-set-default-provider`}),W.error(X(`settings:useProviderActions.setDefaultFailedToast`))}});function a(t){Gn(t.provider)&&i.mutate({path:{assistant_id:e},body:{provider:t.provider,connectionName:t.name}})}function o(e){return i.isPending&&i.variables?.body?.connectionName===e}async function c(i){try{let{response:a}=await s({path:{assistant_id:e,name:i}});a?.ok||a?.status===404?(n.invalidateQueries({queryKey:Ne(r)}),t?.onDeleted?.(i)):a?.status===409?W.error(X(`settings:useProviderActions.deleteInUseToast`)):W.error(X(`settings:useProviderActions.deleteFailedToast`))}catch(e){f(e,{context:`settings-ai-provider-delete`}),W.error(X(`settings:useProviderActions.deleteFailedToast`))}}return{setDefault:a,isSettingDefault:o,deleteConnection:c}}function Qn({assistantId:e,selectedConnectionName:t,onOpenConnection:n,onAddProvider:r,onConnectionDeleted:i}){let{t:a}=Z(`settings`),{data:s,isLoading:c,isError:l}=J(o({path:{assistant_id:e}})),u=Ue(),{data:d}=J({...qe({path:{assistant_id:e}}),enabled:u}),f=u?d?.resolvedConnectionName??null:null,p=Zn(e,{onDeleted:i}),m=(0,Q.useMemo)(()=>{let e=s?.connections??[];return[...e.filter(e=>e.provider===N),...e.filter(e=>e.provider!==N)]},[s]);return(0,$.jsx)(Tn,{title:a(`providersSection.title`),action:(0,$.jsx)(U,{variant:`outlined`,onClick:r,leftIcon:(0,$.jsx)(en,{}),children:a(`providersSection.addProvider`)}),children:c?(0,$.jsx)(`div`,{className:`space-y-2 py-2`,children:[1,2,3].map(e=>(0,$.jsx)(at,{className:`h-10 rounded-lg`},e))}):l?(0,$.jsx)(q,{variant:`body-medium-default`,as:`p`,className:`py-4 text-center text-(--system-negative-strong)`,children:a(`providersSection.loadError`)}):m.length===0?(0,$.jsx)(q,{variant:`body-medium-lighter`,as:`p`,className:`py-4 text-center text-(--content-tertiary)`,children:a(`providersSection.empty`)}):m.map(e=>(0,$.jsx)(Xn,{connection:e,isDefault:e.name===f,supportsDefaultProvider:u,selected:e.name===t,isSettingDefault:p.isSettingDefault(e.name),onOpen:e.isManaged??!1?void 0:()=>n(e.name),onSetDefault:()=>p.setDefault(e),onDelete:()=>void p.deleteConnection(e.name)},e.name))})}function $n({panel:e,onOpenPanel:t,onClosePanel:n}){let{t:r}=Z(`settings`),i=T(),{data:a}=J({...wt({path:{assistant_id:i}}),staleTime:3e4}),s=Ue(),{data:c}=J({...qe({path:{assistant_id:i}}),enabled:s}),l=c?.availability,{data:u}=J({...o({path:{assistant_id:i}})}),d=u?.connections,f=a?.llm?.callSites??{},p=Object.entries(f).filter(([e,t])=>e!==`mainAgent`&&(t?.profile!=null||t?.provider!=null||t?.model!=null)).length;return(0,$.jsx)(ln,{title:r(`languageModelCard.title`),subtitle:r(`languageModelCard.subtitle`),children:(0,$.jsxs)(`div`,{className:`space-y-2`,children:[l&&l.status!==`ok`&&(0,$.jsx)(F,{tone:l.status===`unknown`?`warning`:`error`,children:l.message??r(`languageModelCard.defaultProviderUnavailable`)}),i&&(0,$.jsx)(Un,{assistantId:i,config:a,connections:d,selectedProfileName:e?.kind===`profile`?e.name:null,onOpenProfile:e=>t({kind:`profile`,name:e}),onCreateProfile:()=>t({kind:`create-profile`}),onProfileDeleted:t=>{e?.kind===`profile`&&e.name===t&&n()}}),i&&(0,$.jsx)(Qn,{assistantId:i,selectedConnectionName:e?.kind===`provider`?e.name:null,onOpenConnection:e=>t({kind:`provider`,name:e}),onAddProvider:()=>t({kind:`add-provider`}),onConnectionDeleted:t=>{e?.kind===`provider`&&e.name===t&&n()}}),(0,$.jsx)(Tn,{title:r(`languageModelCard.overridesTitle`),count:p,action:(0,$.jsx)(U,{variant:`outlined`,onClick:()=>t({kind:`overrides`}),children:r(`languageModelCard.manage`)})})]})})}function er({children:e}){return(0,$.jsxs)(w,{href:`https://www.mycadet.ai/docs/pricing`,tone:`default`,className:`inline-flex items-center gap-1`,glyph:!1,children:[e,(0,$.jsx)(an,{className:`h-3.5 w-3.5`})]})}function tr(){return(0,$.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-[var(--border-base)] bg-[var(--surface-base)] px-4 py-2.5`,children:[(0,$.jsx)(on,{className:`mt-0.5 h-4 w-4 shrink-0 text-[var(--content-tertiary)]`}),(0,$.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-secondary)]`,children:(0,$.jsx)(Xt,{i18nKey:`managedServicesBanner.body`,ns:`common`,components:{link:(0,$.jsx)(er,{})}})})]})}function nr({assistantId:e,profileName:t,onClose:n}){let{t:r}=Z(`settings`),{data:i}=J({...wt({path:{assistant_id:e}}),staleTime:3e4}),{data:s}=J({...o({path:{assistant_id:e}})}),c=s?.connections,l=(0,Q.useMemo)(()=>i?.llm?.profiles??{},[i?.llm?.profiles]),u=Object.keys(l),d=(0,Q.useMemo)(()=>{if(t==null)return;let e=l[t];return e?{name:t,...e}:void 0},[t,l]),f=t==null?`create`:d?.source===`managed`||d?.invariant===!0?`view`:`edit`,{saveProfile:p,isPending:m}=a(e,{onSaved:n}),h=ee({mode:f,profileName:t??void 0,initialValues:d,existingNames:u,connections:c,assistantId:e,onSave:p}),g=Vn(e,i,{onDeleted:()=>n()}),_=t!=null&&g.pendingDeleteName===t,v=t!=null&&i!=null&&!(t in l);(0,Q.useEffect)(()=>{v&&!h.saving&&!m&&n()},[v,h.saving,m,n]);let y=f===`view`;return(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(k,{title:h.effectiveMode===`create`?r(`profileDetailPanel.createTitle`):d?.label??t??r(`profileDetailPanel.defaultTitle`),closeVariant:`outlined`,onClose:n,headerTrailing:y&&h.effectiveMode!==`create`?(0,$.jsx)(ut,{tone:`neutral`,children:r(`profileDetailPanel.managedTag`)}):null,headerActions:h.effectiveMode!==`create`&&!h.isReadOnly?(0,$.jsx)(U,{variant:`dangerOutline`,loading:_,iconOnly:(0,$.jsx)(Qt,{}),"aria-label":r(_?`profileDetailPanel.deleting`:`profileDetailPanel.delete`),tooltip:r(`profileDetailPanel.delete`),onClick:()=>{t!=null&&g.requestDelete(t)},disabled:h.saving||_}):null,footer:h.isReadOnly?(0,$.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,$.jsx)(U,{variant:`outlined`,onClick:h.switchToSaveAsNew,disabled:h.saving,children:r(`profileDetailPanel.saveAsNew`)}),h.hasViewModeChanges?(0,$.jsx)(U,{variant:`primary`,onClick:()=>void h.handleSave(),disabled:h.saving,children:h.saving?r(`profileDetailPanel.saving`):r(`profileDetailPanel.save`)}):null]}):(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(U,{variant:`primary`,onClick:()=>void h.handleSave(),disabled:h.isInvalid||h.saving,children:h.saving?r(`profileDetailPanel.saving`):h.effectiveMode===`create`?r(`profileDetailPanel.create`):r(`profileDetailPanel.saveChanges`)})}),children:(0,$.jsx)(Le,{editor:h,assistantId:e,connections:c,variant:`panel`})}),(0,$.jsx)(An,{...g.blockedDeleteModalProps})]})}function rr({value:e,profileOptions:t,disabled:n,onChange:r}){let{t:i}=Z(`settings`);return(0,$.jsx)(`div`,{className:`rounded-lg border border-[var(--border-base)] bg-[var(--surface-overlay)] p-3`,children:(0,$.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0`,children:[(0,$.jsx)(`p`,{className:`text-body-medium-default font-medium text-[var(--content-default)]`,children:i(`advisorProfileRow.title`)}),(0,$.jsx)(`p`,{className:`mt-0.5 text-body-small-lighter text-[var(--content-tertiary)]`,children:i(`advisorProfileRow.description`)})]}),(0,$.jsx)(G,{value:e,onChange:r,options:t,placeholder:i(`advisorProfileRow.chooseProfilePlaceholder`),className:`w-44`,menuMinWidth:280,menuAlign:`start`,disabled:n})]})})}var ir=`__custom__`;function ar(e){return e?!!(e.profile||e.provider||e.model):!1}function or(e,t){if(t?.provider||t?.model)return null;let n=e.defaultProfile??e.shippedDefaultProfile;return n?{profile:n,via:t?.profile===n?`override`:`default`}:null}function sr(e,t){let n=ar(e);return n===ar(t)?n?(e?.profile??null)===(t?.profile??null)&&(e?.provider??null)===(t?.provider??null)&&(e?.model??null)===(t?.model??null):!0:!1}function cr({assistantId:e,callSites:n,domains:r,persistedOverrides:i,orderedProfiles:a,onClose:o,onApplied:s}){let{t:l}=Z(`settings`),u=Me(),d=t(),p=(0,Q.useMemo)(()=>({requireOwnProviderAndModel:d,requireTextGeneration:!1}),[d]),m=(0,Q.useMemo)(()=>{let e=new Map;for(let t of n){let n=or(t,i[t.id]);n&&e.set(t.id,n)}return e},[n,i]),g=(0,Q.useMemo)(()=>{let e=new Set(Array.from(m.values(),e=>e.profile));return a.filter(t=>e.has(t.name))},[a,m]),[_,v]=(0,Q.useState)(()=>g[0]?.name??``),[y,b]=(0,Q.useState)(``),[x,S]=(0,Q.useState)(new Set),[C,w]=(0,Q.useState)(!1),T=(0,Q.useMemo)(()=>{let e=new Map(r.map(e=>[e.id,e.displayName]));return t=>e.get(t)??t},[r]),E=(0,Q.useMemo)(()=>n.filter(e=>m.get(e.id)?.profile===_),[n,m,_]),D=(0,Q.useMemo)(()=>E.map(e=>e.id).filter(e=>!x.has(e)),[E,x]),O=(0,Q.useMemo)(()=>g.map(e=>({value:e.name,label:Bt(e)})),[g]),k=(0,Q.useMemo)(()=>h(a,[],p).filter(e=>e.name!==_).map(e=>({value:e.name,label:Bt(e)})),[a,_,p]),A=he(a,_),j=he(a,y),M=x.size===0;function N(e){v(e),S(new Set),e===y&&b(``)}function ee(e,t){S(n=>{let r=new Set(n);return t?r.delete(e):r.add(e),r})}async function P(){if(!(!_||!y||D.length===0)){w(!0);try{let t={};for(let e of D)t[e]={profile:y};await u.mutateAsync({path:{assistant_id:e},body:{llm:{callSites:t}}}),W.success(l(`bulkOverrideSwapModal.successToast`,{count:D.length,targetLabel:j})),s(),o()}catch(e){let t=ue(e);W.error(t??l(`bulkOverrideSwapModal.updateFailedToast`)),t||f(e,{context:`settings-ai-bulk-override-swap`})}finally{w(!1)}}}return(0,$.jsx)(K.Root,{open:!0,onOpenChange:e=>{e||o()},children:(0,$.jsxs)(K.Content,{size:`md`,children:[(0,$.jsx)(K.Header,{children:(0,$.jsx)(K.Title,{children:l(`bulkOverrideSwapModal.title`)})}),(0,$.jsxs)(K.Body,{className:`space-y-4`,children:[(0,$.jsx)(q,{variant:`body-medium-default`,as:`p`,children:l(`bulkOverrideSwapModal.intro`)}),(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,$.jsx)(G,{id:`bulk-swap-source`,label:l(`bulkOverrideSwapModal.currentlyUsingLabel`),value:_,onChange:N,options:O}),(0,$.jsx)(G,{id:`bulk-swap-target`,label:l(`bulkOverrideSwapModal.changeToLabel`),value:y,onChange:b,options:k,placeholder:l(`bulkOverrideSwapModal.targetPlaceholder`)})]}),(0,$.jsx)(F,{tone:`info`,title:l(`bulkOverrideSwapModal.noticeTitle`),children:l(`bulkOverrideSwapModal.noticeBody`,{sourceLabel:A})}),(0,$.jsxs)(`div`,{children:[(0,$.jsxs)(`div`,{className:`mb-2 flex items-baseline justify-between gap-2`,children:[(0,$.jsxs)(`div`,{children:[(0,$.jsx)(q,{variant:`body-medium-default`,as:`p`,children:l(`bulkOverrideSwapModal.affectedSummary`,{count:E.length,profile:A})}),(0,$.jsx)(q,{variant:`body-small-default`,as:`p`,className:`text-[color:var(--content-secondary)]`,children:l(`bulkOverrideSwapModal.chooseActions`)})]}),(0,$.jsx)(U,{variant:`ghost`,onClick:()=>S(M?new Set(E.map(e=>e.id)):new Set),children:l(M?`bulkOverrideSwapModal.clearAll`:`bulkOverrideSwapModal.selectAll`)})]}),(0,$.jsx)(`div`,{className:`max-h-72 space-y-1 overflow-y-auto`,children:E.map(e=>(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md border border-[var(--border-base)] px-3 py-2`,children:[(0,$.jsx)(c,{checked:!x.has(e.id),onCheckedChange:t=>ee(e.id,t===!0),disabled:C,label:e.displayName,helperText:T(e.domain)}),(0,$.jsx)(`span`,{className:`shrink-0 text-body-small-default text-[color:var(--content-tertiary)]`,children:m.get(e.id)?.via===`override`?l(`bulkOverrideSwapModal.viaOverride`):l(`bulkOverrideSwapModal.viaDefault`)})]},e.id))})]})]}),(0,$.jsxs)(K.Footer,{children:[(0,$.jsx)(q,{variant:`body-small-default`,as:`p`,className:`mr-auto self-center text-[color:var(--content-secondary)]`,children:l(`bulkOverrideSwapModal.willChange`,{count:D.length})}),(0,$.jsx)(U,{variant:`ghost`,onClick:o,disabled:C,children:l(`bulkOverrideSwapModal.cancel`)}),(0,$.jsx)(U,{variant:`primary`,loading:C,disabled:!_||!y||D.length===0||C,onClick:()=>void P(),children:l(`bulkOverrideSwapModal.applyTo`,{count:D.length})})]})]})})}function lr({id:e,displayName:t,description:n,defaultProfileLabel:r,draft:i,profileOptions:a,connections:o,onDraftChange:s,onToggle:c}){let{t:l}=Z(`settings`),u=Et({hostedInference:Dt.use.cadetHostedInference()}),d=ar(i),f=!i||!d?``:i.provider||i.model?ir:i.profile??``,p=f===ir,m=Je(),h=kt(),g=(o??[]).some(e=>e.provider===Oe),_=[...Ie,...g?[Oe]:[]],v=m[0]??Ie[0],y=i?.provider,b=D(y)?y:y===`chatgpt`?Oe:void 0,x=b!==void 0&&_.some(e=>e===b),S=b??v,C=re(S,``,(o??[]).filter(e=>ot(e.provider,S)))?O(S):Ge(S,u),w=C.map(e=>({value:e.id,label:e.displayName})),T=typeof i?.model==`string`?i.model:``;if(T&&!C.some(e=>e.id===T)){let e=Be(S).find(e=>e.id===T)?.displayName??T;w.push({value:T,label:l(`callSiteOverridesRow.unavailableOption`,{name:e})})}let E=!!i?.provider&&!i?.model,k=[..._.map(e=>({value:e,label:R[e]??e,...h(e)})),...b&&!x?[{value:b,label:l(`callSiteOverridesRow.unavailableOption`,{name:R[b]??b})}]:[]];function A(t){t===`__custom__`?s(e,{profile:null,provider:v,model:He(v)??``}):t===``?s(e,null):s(e,{profile:t,provider:null,model:null})}function j(t){let n=He(t)??``;s(e,{...i??{},profile:null,provider:t,model:n})}function M(t){s(e,{...i??{},model:t})}return(0,$.jsxs)(`div`,{className:`rounded-lg border border-[var(--border-base)] bg-[var(--surface-overlay)] p-3`,children:[(0,$.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsx)(`p`,{className:`text-body-medium-default font-medium text-[var(--content-default)]`,children:t}),n&&(0,$.jsxs)(`p`,{className:`mt-0.5 text-body-small-default text-[var(--content-tertiary)]`,children:[n,r&&(0,$.jsx)(`span`,{className:`ml-1.5 text-body-small-default text-[var(--content-tertiary)] opacity-60`,children:l(`callSiteOverridesRow.defaultProfileSuffix`,{label:r})})]})]}),(0,$.jsx)(Rt,{checked:d,onChange:t=>c(e,t),"aria-label":l(`callSiteOverridesRow.overrideAriaLabel`,{displayName:t}),className:`shrink-0`})]}),d&&(0,$.jsx)(`div`,{className:`mt-3`,children:(0,$.jsx)(G,{value:f,onChange:A,options:a,className:`w-44`,menuMinWidth:280,menuAlign:`start`})}),d&&p&&(0,$.jsxs)(`div`,{className:`mt-3 space-y-2 border-t border-[var(--border-base)] pt-3`,children:[(0,$.jsxs)(`div`,{className:`flex gap-2`,children:[(0,$.jsxs)(`div`,{className:`flex-1`,children:[(0,$.jsx)(`label`,{className:`mb-1 block text-body-small-default text-[var(--content-tertiary)]`,children:l(`callSiteOverridesRow.providerLabel`)}),(0,$.jsx)(G,{value:S??``,onChange:j,options:k})]}),(0,$.jsxs)(`div`,{className:`flex-1`,children:[(0,$.jsx)(`label`,{className:`mb-1 block text-body-small-default text-[var(--content-tertiary)]`,children:l(`callSiteOverridesRow.modelLabel`)}),(0,$.jsx)(G,{value:i?.model??``,onChange:M,options:w})]})]}),E&&(0,$.jsx)(`p`,{className:`text-body-small-default text-[var(--system-negative-strong)]`,children:l(`callSiteOverridesRow.pickModelError`)})]})]})}function ur({groups:e,drafts:t,buildProfileOptionsForRow:n,profileLabelFor:r,advisorMatchesSearch:i,connections:a,onDraftChange:o,onToggle:s}){let{t:c}=Z(`settings`);return(0,$.jsx)(`div`,{className:`space-y-4`,children:e.length===0?i?null:(0,$.jsx)(`p`,{className:`py-8 text-center text-body-medium-lighter text-[var(--content-tertiary)]`,children:c(`overridesCallSiteList.emptySearch`)}):e.map(({domain:e,sites:i})=>(0,$.jsxs)(`div`,{children:[(0,$.jsx)(pn,{children:e.displayName}),(0,$.jsx)(`div`,{className:`space-y-1`,children:i.map(e=>{let i=(()=>{let n=t[e.id]??null;return!n||!ar(n)?``:n.provider||n.model?ir:n.profile??``})(),c=e.shippedDefaultProfile??e.defaultProfile,l=c?r(c):null;return(0,$.jsx)(lr,{id:e.id,displayName:e.displayName,description:e.description,defaultProfileLabel:l,draft:t[e.id]??null,profileOptions:n(i===``||i===`__custom__`?null:i),connections:a,onDraftChange:o,onToggle:s},e.id)})})]},e.id))})}function dr(e,t){let n={};for(let r of Object.keys(e)){let i=e[r]??null;ar(i)?n[r]={profile:i?.profile??null,provider:i?.provider??null,model:i?.model??null}:r in t&&t[r]===null&&(n[r]=null)}return n}function fr(e){let t={};for(let n of Object.keys(e))t[n]=null;return t}function pr({catalogCallSiteIds:e,persistedOverrides:t,persistedAdvisor:n,isSeeded:r}){let[i,a]=(0,Q.useState)({}),[o,s]=(0,Q.useState)(void 0),c=(0,Q.useMemo)(()=>{if(!r)return{};let n={};for(let r of e)if(r in i)n[r]=i[r];else{let e=t[r];n[r]=e?{...e}:{}}return n},[r,e,t,i]),l=o??n,u=l!==n,d=(0,Q.useMemo)(()=>{if(!r)return!1;for(let e of Object.keys(c))if(!sr(c[e],t[e]))return!0;return!1},[r,c,t]);return{drafts:c,advisorProfile:l,advisorDirty:u,callSiteDraftsDirty:d,hasUnsavedDrafts:u||d,hasValidationError:(0,Q.useMemo)(()=>Object.values(c).some(e=>ar(e)&&!!e?.provider&&!e?.model),[c]),setDraft:(0,Q.useCallback)((e,t)=>{a(n=>({...n,[e]:t}))},[]),setAdvisor:(0,Q.useCallback)(e=>{s(e)},[]),clearEdits:(0,Q.useCallback)(()=>{a({}),s(void 0)},[]),buildSavePatch:(0,Q.useCallback)(()=>dr(c,i),[c,i]),buildResetPatch:(0,Q.useCallback)(()=>fr(c),[c])}}function mr({assistantId:e,onClose:n}){let{t:r}=Z(`settings`),{data:i}=J({...wt({path:{assistant_id:e}}),staleTime:3e4}),a=(0,Q.useMemo)(()=>i?.llm?.profiles??{},[i?.llm?.profiles]),s=(0,Q.useMemo)(()=>i?.llm?.profileOrder??[],[i?.llm?.profileOrder]),c=(0,Q.useMemo)(()=>i?.llm?.callSites??{},[i?.llm?.callSites]),l=(0,Q.useMemo)(()=>Ee(a,s),[a,s]),d=Je(),p=t(),m=(0,Q.useMemo)(()=>({requireOwnProviderAndModel:p}),[p]),g=(0,Q.useMemo)(()=>({requireOwnProviderAndModel:p,requireTextGeneration:!1}),[p]),_=Me(),[v,y]=(0,Q.useState)(``),[x,S]=(0,Q.useState)(!1),[C,w]=(0,Q.useState)(!1),[T,E]=(0,Q.useState)(!1),{data:D,isLoading:O,isError:A,refetch:j}=J({...tt({path:{assistant_id:e}}),enabled:!!e,staleTime:6e4,refetchOnWindowFocus:!1}),{data:M}=J({...o({path:{assistant_id:e}}),enabled:!!e}),N=(0,Q.useMemo)(()=>(D?.callSites??[]).filter(e=>e.id!==`mainAgent`),[D]),ee=!O&&!A&&!!D,P=!!i,I=ee&&P,te=(0,Q.useMemo)(()=>N.map(e=>e.id),[N]),L=i?.llm?.advisorProfile??``,{drafts:ne,advisorProfile:R,advisorDirty:re,callSiteDraftsDirty:z,hasUnsavedDrafts:ie,hasValidationError:ae,setDraft:oe,setAdvisor:se,clearEdits:ce,buildSavePatch:B,buildResetPatch:le}=pr({catalogCallSiteIds:te,persistedOverrides:c,persistedAdvisor:L,isSeeded:I}),ue=(0,Q.useMemo)(()=>new Set(te),[te]),de=(0,Q.useCallback)(e=>he(l,e),[l]),fe=(0,Q.useCallback)((e,t)=>({value:e.name,label:Bt(e),...u(e,l,t)===`undispatchable`?{icon:(0,$.jsx)(tn,{className:`h-3.5 w-3.5 text-[var(--system-mid-strong)]`}),tooltip:b(e)}:{}}),[l]),pe=(0,Q.useMemo)(()=>h(l,[L],m).map(e=>fe(e,m)),[l,L,fe,m]),me=(0,Q.useMemo)(()=>{let e=v.trim().toLowerCase();return e===``||`advisor`.includes(e)||`second opinion`.includes(e)},[v]),ge=(0,Q.useMemo)(()=>N.some(e=>or(e,c[e.id])!==null),[N,c]),_e=(0,Q.useMemo)(()=>Object.entries(c).some(([e,t])=>ue.has(e)&&(t?.profile!=null||t?.provider!=null||t?.model!=null)),[c,ue]),ve=(0,Q.useCallback)(e=>[...h(l,[e],g).map(e=>fe(e,g)),{value:ir,label:r(`overridesDetailPanel.customProfileOption`)}],[l,fe,g,r]),ye=(0,Q.useMemo)(()=>{if(!v.trim())return N;let e=v.toLowerCase();return N.filter(t=>(t.displayName??``).toLowerCase().includes(e)||(t.description??``).toLowerCase().includes(e)||(t.domain??``).toLowerCase().includes(e))},[N,v]),be=(0,Q.useMemo)(()=>{if(!D)return[];let e=D.domains.map(e=>e.id),t=new Map(D.domains.map(e=>[e.id,e])),n=[];for(let r of e){let e=ye.filter(e=>e.domain===r);e.length>0&&n.push({domain:t.get(r),sites:e})}let i=new Set(e),a=ye.filter(e=>!i.has(e.domain));return a.length>0&&n.push({domain:{id:`other`,displayName:r(`overridesDetailPanel.otherDomain`)},sites:a}),n},[D,ye,r]),xe=(0,Q.useCallback)((e,t)=>{if(!t){oe(e,null);return}let n=De(l,N.find(t=>t.id===e)?.defaultProfile,g);if(n)oe(e,{profile:n});else{let t=d[0]??Ie[0];oe(e,{provider:t,model:He(t)??``})}},[N,l,d,oe,g]),Se=(0,Q.useCallback)(async()=>{S(!0);try{let t=B();await _.mutateAsync({path:{assistant_id:e},body:{llm:{...z?{callSites:t}:{},...re?{advisorProfile:R}:{}}}}),n(),W.success(r(`overridesDetailPanel.overridesSavedToast`))}catch(e){W.error(r(`overridesDetailPanel.saveFailedToast`)),f(e,{context:`call_site_overrides_save`})}finally{S(!1)}},[B,z,re,R,n,_,e,r]),Ce=(0,Q.useCallback)(async()=>{S(!0);try{let t=le();await _.mutateAsync({path:{assistant_id:e},body:{llm:{callSites:t}}}),n(),W.success(r(`overridesDetailPanel.overridesResetToast`))}catch(e){W.error(r(`overridesDetailPanel.resetFailedToast`)),f(e,{context:`call_site_overrides_reset`})}finally{S(!1)}},[le,n,_,e,r]),we=(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[_e&&(0,$.jsx)(U,{variant:`outlined`,onClick:()=>w(!0),disabled:x||!I,tintColor:`var(--system-negative-strong)`,className:`mr-auto`,children:r(`overridesDetailPanel.resetToDefaults`)}),(0,$.jsx)(U,{variant:`primary`,onClick:()=>void Se(),loading:x,disabled:!ie||ae||x,children:r(`overridesDetailPanel.save`)})]});return(0,$.jsxs)(k,{title:r(`overridesDetailPanel.title`),closeVariant:`outlined`,onClose:n,footer:we,children:[(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:r(`overridesDetailPanel.description`)}),(0,$.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,$.jsx)(V,{type:`search`,value:v,onChange:e=>y(e.target.value),placeholder:r(`overridesDetailPanel.searchPlaceholder`),leftIcon:(0,$.jsx)(sn,{className:`h-4 w-4`}),fullWidth:!0})}),(0,$.jsx)(U,{variant:`outlined`,onClick:()=>E(!0),disabled:!I||x||ie||!ge,title:ie?r(`overridesDetailPanel.bulkChangeUnsavedTitle`):ge?void 0:r(`overridesDetailPanel.bulkChangeNoCandidatesTitle`),children:r(`overridesDetailPanel.bulkChange`)})]}),P&&me&&(0,$.jsxs)(`div`,{children:[(0,$.jsx)(pn,{children:r(`overridesDetailPanel.advisorSection`)}),(0,$.jsx)(rr,{value:R,profileOptions:pe,disabled:x,onChange:se})]}),O&&(0,$.jsx)(Ot,{placement:`panel`}),A&&(0,$.jsx)(F,{tone:`error`,title:r(`overridesDetailPanel.loadErrorTitle`),actions:(0,$.jsx)(U,{variant:`outlined`,onClick:()=>void j(),children:r(`overridesDetailPanel.retry`)}),children:r(`overridesDetailPanel.loadErrorHint`)}),!O&&!A&&D&&(0,$.jsx)(ur,{groups:be,drafts:ne,buildProfileOptionsForRow:ve,profileLabelFor:de,advisorMatchesSearch:me,connections:M?.connections,onDraftChange:oe,onToggle:xe})]})]}),T&&D&&(0,$.jsx)(cr,{assistantId:e,callSites:N,domains:D.domains,persistedOverrides:c,orderedProfiles:l,onClose:()=>E(!1),onApplied:ce}),(0,$.jsx)(Qe,{open:C,title:r(`overridesDetailPanel.resetToDefaults`),message:r(`overridesDetailPanel.resetConfirmMessage`),confirmLabel:r(`overridesDetailPanel.resetToDefaults`),destructive:!0,onConfirm:()=>{w(!1),Ce()},onCancel:()=>w(!1)})]})}var hr=e(qt(),1);function gr({mode:e,connection:t,assistantId:n,existingNames:r,connections:i,variant:a=`modal`,actionsSlot:o,onSave:s,onCancel:c}){let{t:l}=Z(`settings`),[u,d]=(0,Q.useState)(t?.label??``),f=t?.name??``,p=t?.provider??`anthropic`,m=t?.auth.type??`api_key`,[h,g]=(0,Q.useState)(()=>t?.auth.type===`api_key`?t.auth.credential:t?``:`credential/anthropic/api_key`),[_,v]=(0,Q.useState)(t?.baseUrl??``),[y,b]=(0,Q.useState)(()=>t?.models?t.models.map(e=>e.id).join(`, `):``),[x,S]=(0,Q.useState)(!1),[C,w]=(0,Q.useState)(null),T=p===`openai-compatible`,E=Ze(p),D=Ft(p),[O,k]=(0,Q.useState)(``),[A,j]=(0,Q.useState)(!1),M=Y(),N=(0,Q.useMemo)(()=>jt(h),[h]),ee=m===`api_key`&&N!==null,{hasStoredCredential:P,isLoading:F}=xe({assistantId:n,credentialKind:`credential`,credentialName:N?`${N.service}:${N.field}`:``,enabled:ee}),{credentials:I}=yt({assistantId:n,enabled:m===`api_key`});(0,Q.useEffect)(()=>{let e=t?.provider??`anthropic`;d(t?.label??``),t?.auth.type===`api_key`?g(t.auth.credential):g(t?``:`credential/${e}/api_key`),w(null),v(t?.baseUrl??``),b(t?.models?t.models.map(e=>e.id).join(`, `):``),k(``),j(!1)},[t]);let te=u.trim()!==(t?.label??``).trim(),L=T&&te?St(u,i,t?.name):null,ne=f.trim().length>0&&L===null;async function R(){if(ne){S(!0),w(null);try{let e;if(m===`api_key`){let t=h.trim()||`credential/${p}/api_key`,r=O.trim();if(r){j(!0);try{let e=jt(t);await Xe({path:{assistant_id:n},body:e?{type:`credential`,name:`${e.service}:${e.field}`,value:r}:{type:`api_key`,name:p,value:r},throwOnError:!0});let i=Ke(n,`credential`,e?`${e.service}:${e.field}`:``);M.setQueryData(i,!0),M.invalidateQueries({queryKey:rt({path:{assistant_id:n}})})}catch{w(l(`providerEditorContent.failedSaveApiKey`));return}finally{j(!1)}}e={type:`api_key`,credential:t}}else if(t)e=t.auth;else{w(l(`providerEditorContent.nothingToEdit`));return}let r=u.trim()||null,i={auth:e,label:r,...E&&{base_url:_.trim()||null},...D&&{models:y.trim()?y.split(`,`).map(e=>({id:e.trim()})).filter(e=>e.id):null}},{data:a,error:o,response:c}=await Fe({path:{assistant_id:n,name:t?.name??f.trim()},body:i});if(!c?.ok){w($e(c?.status,o)??xt(c?.status));return}if(!a){w(l(`providerEditorContent.emptyServerResponse`));return}et(a,l),s(a)}catch{w(l(`providerEditorContent.failedSaveProvider`))}finally{S(!1)}}}let re=I.filter(e=>e.service===p),z=e!==`create`&&t?.auth.type===`api_key`,ie=re.length>0||z,ae=At(l(`providerEditorContent.apiKeyPlaceholder`),P);if(e===`create`)return(0,$.jsx)(Pt,{variant:a===`panel`?`inline`:`modal`,actionsSlot:o,assistantId:n,existingNames:r,connections:i,defaultProviderType:p,onCreated:s,onCancel:c});let oe=(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:(0,$.jsx)(Xt,{i18nKey:`providerEditorContent.displayNameLabel`,ns:`settings`,components:{optional:(0,$.jsx)(`span`,{className:`text-[var(--content-disabled)]`})}})}),(0,$.jsx)(V,{value:u,onChange:e=>d(e.target.value),placeholder:l(`providerEditorContent.displayNamePlaceholder`),fullWidth:!0}),L?(0,$.jsx)(q,{variant:`body-small-default`,as:`p`,className:`text-(--system-negative-strong)`,children:Ye[L]}):null]}),E&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:l(`providerEditorContent.baseUrlLabel`)}),(0,$.jsx)(V,{value:_,onChange:e=>v(e.target.value),placeholder:l(p===`ollama`?`providerEditorContent.baseUrlPlaceholderOllama`:p===`opencode`?`providerEditorContent.baseUrlPlaceholderOpencode`:`providerEditorContent.baseUrlPlaceholder`),fullWidth:!0}),p===`ollama`?(0,$.jsx)(q,{variant:`body-small-default`,as:`p`,className:`text-[var(--content-tertiary)]`,children:l(`providerEditorContent.baseUrlHintOllama`)}):null,p===`opencode`?(0,$.jsx)(q,{variant:`body-small-default`,as:`p`,className:`text-[var(--content-tertiary)]`,children:l(`providerEditorContent.baseUrlHintOpencode`)}):null]}),D&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:l(`providerEditorContent.modelsLabel`)}),(0,$.jsx)(V,{value:y,onChange:e=>b(e.target.value),placeholder:l(`providerEditorContent.modelsPlaceholder`),fullWidth:!0}),(0,$.jsx)(q,{variant:`body-small-default`,as:`p`,className:`text-[var(--content-tertiary)]`,children:l(`providerEditorContent.modelsHint`)})]}),m===`api_key`&&(0,$.jsx)(ct,{apiKeyValue:O,onApiKeyChange:k,credential:h,onCredentialChange:g,isLoadingCredential:F,apiKeyPlaceholder:ae,provider:p,providerCredentials:re,showAdvancedSection:ie,onError:w}),m===`oauth_subscription`&&(0,$.jsx)(nt,{assistantId:n,onConnected:s}),C&&(0,$.jsx)(q,{variant:`body-small-default`,as:`p`,className:`text-(--system-negative-strong)`,children:C})]}),se=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(U,{variant:`ghost`,onClick:c,children:l(`providerEditorContent.cancel`)}),(0,$.jsx)(U,{variant:`primary`,disabled:!ne||x||A,onClick:()=>void R(),children:l(x?`providerEditorContent.saving`:`providerEditorContent.saveChanges`)})]});return a===`panel`?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[oe,o===void 0?(0,$.jsx)(`div`,{className:`flex justify-end gap-2`,children:se}):o&&(0,hr.createPortal)(se,o)]}):(0,$.jsxs)(K.Content,{size:`md`,children:[(0,$.jsxs)(K.Header,{children:[(0,$.jsx)(K.Title,{children:l(`providerEditorContent.editProviderTitle`)}),(0,$.jsx)(K.Description,{children:t?l(`providerEditorContent.editingConnection`,{name:gt(t)}):l(`providerEditorContent.editProviderSettingsFallback`)})]}),(0,$.jsx)(K.Body,{children:oe}),(0,$.jsx)(K.Footer,{children:se})]})}function _r({assistantId:e,connectionName:t,onClose:n}){let{t:r}=Z(`settings`),i=Y(),[a,s]=(0,Q.useState)(null),{data:c,isLoading:l}=J(o({path:{assistant_id:e}})),u=(0,Q.useMemo)(()=>c?.connections??[],[c]),d=(0,Q.useMemo)(()=>t==null?void 0:u.find(e=>e.name===t),[t,u]),f=t!=null&&c!=null&&d==null;(0,Q.useEffect)(()=>{f&&n()},[f,n]);function p(){i.invalidateQueries({queryKey:Ne({path:{assistant_id:e}})}),i.invalidateQueries({queryKey:Lt({path:{assistant_id:e}})}),n()}return(0,$.jsx)(k,{title:d?gt(d):r(`providerDetailPanel.addProviderTitle`),closeVariant:`outlined`,onClose:n,footer:(0,$.jsx)(`div`,{ref:s,className:`flex justify-end gap-2`}),children:t!=null&&l?(0,$.jsx)(Ot,{placement:`panel`}):t==null||d!=null?(0,$.jsx)(gr,{mode:d?`edit`:`create`,connection:d,variant:`panel`,actionsSlot:a,assistantId:e,existingNames:u.map(e=>e.name),connections:u,onSave:p,onCancel:n}):null})}var vr={cadet:{provider:`cadet`},deepgram:{provider:`deepgram`,credentialService:`deepgram`},openai:{provider:`openai-whisper`,credentialService:`openai`}},yr={cadet:`cadet`,deepgram:`deepgram`,"openai-whisper":`openai`},br=`deepgram`;function xr({assistantId:e,hideSaveButton:t=!1,hideCredentialsGuide:n=!1,onSaveStateChange:r}={}){let i=T(),a=e??i,o=Nt(),s=Y(),{t:c}=Z(),l=(0,Q.useMemo)(()=>Re(It(),{displayName:c(`sttProviderForm.windowsNativeDisplayName`),subtitle:c(`sttProviderForm.windowsNativeSubtitle`),setupWarning:c(`sttProviderForm.windowsNativeSetupWarning`)}).filter(e=>!e.requiresNativeDictation||A()),[c]),u=br,{data:d}=J({...wt({path:{assistant_id:a}}),enabled:o,staleTime:3e4}),f=d?.services?.stt,p=f?.mode===`managed`?`cadet`:f?.provider,m=(0,Q.useMemo)(()=>{let e=p?yr[p]:void 0;if(e&&l.some(t=>t.id===e))return e;let t=z(ht,u);return l.some(e=>e.id===t)?t:u},[p,l,u]),h=!!p,[g,v]=yn(m),{available:y,currentCode:b,configuredProviderId:x,selectLanguage:S,selecting:C}=Tt(a),[w,E]=(0,Q.useState)(!1),D=y&&g===m&&(vr[g]?.provider===x||!!p&&!yr[p]),[O,k]=(0,Q.useState)(``),[j,M]=(0,Q.useState)(!1),[N,ee]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{let e=z(ht,u);e===`macos-native`&&!l.some(t=>t.id===e)&&H(ht,u)},[l,u]);let P=(0,Q.useMemo)(()=>l.find(e=>e.id===g)??l[0],[l,g]),F=P.apiKeyPlaceholder!==void 0;(0,Q.useEffect)(()=>{M(z(ge+g,``).length>0),k(``)},[g]);let I=(0,Q.useMemo)(()=>{let e=g!==m,t=O.trim().length>0;return e||t},[g,m,O]),L=(0,Q.useCallback)(async()=>{let e=O.trim();H(ht,g),e.length>0&&H(ge+g,e);let t=vr[g];ee(!0);try{if(t?.credentialService){let n=e.length>0?e:z(ge+g,``);if(n.length>0){let{response:e}=await te({path:{assistant_id:a},body:{service:t.credentialService,field:`api_key`,value:n,label:`${P.displayName} API Key`},throwOnError:!1});if(!e?.ok)throw Error(`Failed to store API key (HTTP ${e?.status??`?`})`)}}if(t&&(g!==m||!h)||p===`cadet`&&g!==`cadet`){let e=t?.provider??br,{response:n}=await _({path:{assistant_id:a},body:{services:{stt:{provider:e,mode:e===`cadet`?`managed`:`your-own`}}},throwOnError:!1});if(!n?.ok)throw Error(`Failed to save configuration (HTTP ${n?.status??`?`})`)}return e.length>0&&M(!0),k(``),s.invalidateQueries({queryKey:vt({path:{assistant_id:a}})}),W.success(c(`sttProviderForm.saveSuccess`)),!0}catch(e){return W.error(e instanceof Error?e.message:c(`sttProviderForm.saveFailed`)),!1}finally{ee(!1)}},[a,g,O,P,m,h,p,s,c]);(0,Q.useEffect)(()=>{r?.({hasChanges:I,saving:N,save:L})},[r,I,N,L]);let ne=(0,Q.useCallback)(()=>{H(ge+g,``),M(!1),k(``)},[g]),R=j?c(`sttProviderForm.apiKeyPlaceholderReplace`):P.apiKeyPlaceholder;return(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:c(`sttProviderForm.providerLabel`)}),(0,$.jsx)(G,{value:g,onChange:v,options:l.map(e=>({value:e.id,label:e.displayName})),"aria-label":c(`sttProviderForm.providerAriaLabel`)})]}),D&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:c(`sttProviderForm.spokenLanguage`)}),(0,$.jsx)(ze,{"aria-label":c(`sttProviderForm.spokenLanguage`),"aria-haspopup":`dialog`,onClick:()=>E(!0),value:Ve(b,x)}),(0,$.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:c(`sttProviderForm.spokenLanguageApplies`)}),(0,$.jsx)(_n,{open:w,onOpenChange:E,title:c(`sttProviderForm.spokenLanguage`),currentCode:b,configuredProviderId:x,selectLanguage:S,selecting:C})]}),F&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:c(`sttProviderForm.apiKeyLabel`)}),(0,$.jsx)(V,{type:`password`,value:O,onChange:e=>k(e.target.value),placeholder:R,fullWidth:!0})]}),P.setupWarning&&(0,$.jsxs)(`div`,{className:`flex items-start gap-2 rounded-lg border border-[var(--border-subtle)] bg-[var(--surface-sunken)] p-3 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,$.jsx)($t,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-[var(--system-mid-strong)]`}),(0,$.jsx)(`span`,{children:P.setupWarning})]}),!n&&P.credentialsGuide&&(0,$.jsx)(fn,{guide:P.credentialsGuide}),g===`cadet`&&(0,$.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:c(`sttProviderForm.cadetTranscription`)}),(!t||j)&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!t&&(0,$.jsx)(dn,{onClick:L,disabled:!I||N}),j&&(0,$.jsx)(un,{onClick:ne})]})]})}var Sr={batch:`sttRoleOverrides.role.batch`,dictation:`sttRoleOverrides.role.dictation`,liveVoice:`sttRoleOverrides.role.liveVoice`,telephony:`sttRoleOverrides.role.telephony`,watch:`sttRoleOverrides.role.watch`};function Cr(e){let t=e?.roles;if(!t)return[];let n=e?.provider,r=n?e?.providers?.[n]?.model:void 0,i=[];for(let[e,a]of Object.entries(t)){let t=a?.provider;t&&(t===n&&a?.model===r||i.push({role:e,provider:t,...a?.model===void 0?{}:{model:a.model}}))}return i}function wr({assistantId:e}){let{t}=Z(`settings`),n=Y(),r=Nt(),[i,a]=(0,Q.useState)(null),{data:o}=J({...wt({path:{assistant_id:e}}),enabled:r,staleTime:3e4}),s=o?.services?.stt,c=Cr(s),{data:l}=J({...y({path:{assistant_id:e}}),enabled:r&&c.length>0,staleTime:5*6e4});if(c.length===0)return null;let u=e=>l?.providers?.find(t=>t.id===e)?.displayName??e,d=async r=>{a(r);try{let{response:t}=await _({path:{assistant_id:e},body:{services:{stt:{roles:{[r]:null}}}},throwOnError:!1});if(!t?.ok)throw Error(String(t?.status??``));await n.invalidateQueries({queryKey:vt({path:{assistant_id:e}})})}catch{W.error(t(`sttRoleOverrides.clearFailed`))}finally{a(null)}};return(0,$.jsxs)(`div`,{className:`mt-1 flex flex-col gap-2 border-t border-[var(--border-subtle)] pt-4`,children:[(0,$.jsx)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:t(`sttRoleOverrides.title`)}),(0,$.jsx)(`ul`,{className:`flex flex-col gap-1`,children:c.map(e=>{let n=Sr[e.role];return(0,$.jsxs)(`li`,{className:`flex items-center gap-4 rounded-md border border-[var(--border-subtle)] bg-[var(--surface-sunken)] px-3 py-2`,children:[(0,$.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-body-medium-lighter text-[var(--content-default)]`,children:n?t(n):e.role}),(0,$.jsx)(`span`,{className:`min-w-0 truncate text-body-small-default text-[var(--content-default)]`,children:e.model?`${u(e.provider)} · ${e.model}`:u(e.provider)}),(0,$.jsx)(U,{variant:`ghost`,size:`compact`,"aria-label":t(`sttRoleOverrides.clearAria`,{feature:n?t(n):e.role}),className:`[--vbtn-fg:var(--content-tertiary)]`,disabled:i===e.role,onClick:()=>void d(e.role),children:t(`sttRoleOverrides.clear`)})]},e.role)})})]})}function Tr(){let{t:e}=Z(`settings`),t=T();return(0,$.jsxs)(ln,{title:e(`speechToTextCard.title`),subtitle:e(`speechToTextCard.subtitle`),children:[(0,$.jsx)(xr,{}),(0,$.jsx)(wr,{assistantId:t})]})}async function Er(e){let{provider:t,apiKey:n,voiceId:r,text:i}=e;if(n.trim().length===0)return{kind:`error`,message:`Save an API key for this provider first.`};try{return t===`elevenlabs`?await Dr(n,r,i):t===`deepgram`?await Or(n,i):t===`fish-audio`?{kind:`unsupported`,message:`Fish Audio TTS is only supported in the desktop app today. Use ElevenLabs or Deepgram to test from the browser.`}:t===`xai`?{kind:`unsupported`,message:`xAI TTS is only supported in the desktop app today. Use ElevenLabs or Deepgram to test from the browser.`}:{kind:`unsupported`,message:`TTS testing for "${t}" is not supported from the browser yet.`}}catch(e){return{kind:`error`,message:e instanceof Error?e.message:`Failed to reach the TTS provider.`}}}async function Dr(e,t,n){let r=t.trim();if(r.length===0)return{kind:`error`,message:`Enter and save a Voice ID before testing ElevenLabs.`};let i=await fetch(`https://api.elevenlabs.io/v1/text-to-speech/${encodeURIComponent(r)}?output_format=mp3_44100_128`,{method:`POST`,headers:{"xi-api-key":e,"Content-Type":`application/json`,Accept:`audio/mpeg`},body:JSON.stringify({text:n,model_id:`eleven_turbo_v2_5`})});return i.ok?{kind:`audio`,blob:await i.blob()}:{kind:`error`,message:await kr(i,`ElevenLabs rejected the request.`)}}async function Or(e,t){let n=await fetch(`https://api.deepgram.com/v1/speak?model=aura-2-thalia-en`,{method:`POST`,headers:{Authorization:`Token ${e}`,"Content-Type":`application/json`,Accept:`audio/mpeg`},body:JSON.stringify({text:t})});return n.ok?{kind:`audio`,blob:await n.blob()}:{kind:`error`,message:await kr(n,`Deepgram rejected the request.`)}}async function kr(e,t){try{let n=await e.text();if(n.length===0)return`${t} (HTTP ${e.status})`;try{let e=JSON.parse(n);if(e&&typeof e==`object`&&`detail`in e&&typeof e.detail==`string`)return e.detail;if(e&&typeof e==`object`&&`message`in e&&typeof e.message==`string`)return e.message}catch{}return n.slice(0,200)}catch{return`${t} (HTTP ${e.status})`}}function Ar({assistantId:e,value:t,onChange:n,className:r}){let{t:i}=Z(),[a,o]=(0,Q.useState)(!1),{voices:s}=B(e);if(s.length===0)return null;let c=s.find(e=>e.model===t)??s[0];return(0,$.jsxs)(d.Root,{open:a,onOpenChange:o,children:[(0,$.jsx)(d.Trigger,{asChild:!0,children:(0,$.jsx)(ze,{"aria-label":i(`voicePickerField.ariaLabel`),value:c?ft(c.description):i(`voicePickerField.selectVoice`),className:r})}),(0,$.jsx)(d.Content,{side:`bottom`,align:`start`,className:`w-[var(--radix-popover-trigger-width)] p-1`,children:(0,$.jsx)(j,{assistantId:e,value:t,onChange:n,onSelect:()=>o(!1),showSource:!0,autoScrollToSelected:!0})})]})}var jr={elevenlabs:`voiceId`,"fish-audio":`referenceId`,xai:`voiceId`};function Mr({assistantId:e,hideSaveButton:t=!1,hideCredentialsGuide:n=!1,onSaveStateChange:i}={}){let{t:a}=Z(),o=T(),s=e??o,c=Mt.use.name()??`your assistant`,l=Nt(),u=Y(),{data:d}=J({...m({path:{assistant_id:s}}),enabled:l,staleTime:1/0}),f=(0,Q.useMemo)(()=>{let e=d?.providers;if(!e)return Pe;if(e.some(e=>e.id===`cadet`))return e;let t=Pe.find(e=>e.id===`cadet`);return t?[t,...e]:e},[d]),{data:p}=J({...wt({path:{assistant_id:s}}),enabled:l,staleTime:3e4}),h=p?.services?.tts,g=h?.mode===`managed`?`cadet`:h?.provider,v=`elevenlabs`,y=(0,Q.useMemo)(()=>g??z(`cadet:voice:ttsProvider`,v),[g,v]),b=!!g,[x,S]=yn(y),[C,w]=(0,Q.useState)(``),[E,D]=(0,Q.useState)(``),[O,k]=(0,Q.useState)(``),[A,j]=(0,Q.useState)(!1),[M,N]=(0,Q.useState)(!1),[ee,P]=(0,Q.useState)(!1),{voices:F,defaultModel:I,fetched:L}=pe(s,{enabled:x===`cadet`}),ne=h?.providers?.cadet?.model??I??``,[R,re]=yn(ne),ie=F.find(e=>e.model===R)??F[0],[ae,oe]=(0,Q.useState)(null),se=F.some(e=>e.model===ne),ce=ae??(L&&ne!==``&&!se),B=(0,Q.useMemo)(()=>f.find(e=>e.id===x)??f[0],[x,f]),ue=x===`cadet`&&B.supportsVoiceSelection&&R.trim()!==``&&R.trim()!==ne,de=(0,Q.useCallback)(e=>{let t=z(r+e,``),n=z(le+e,``);j(t.length>0),D(n),k(n),w(``)},[]);(0,Q.useEffect)(()=>{de(x)},[x,de]);let fe=(0,Q.useMemo)(()=>{let e=x!==y,t=C.trim().length>0,n=E.trim()!==O;return e||t||n||ue},[x,y,C,E,O,ue]),me=(0,Q.useCallback)(async()=>{let e=C.trim(),t=E.trim(),n=B.id;H(pt,n),e.length>0&&H(r+n,e),H(le+n,t);let i=e.length>0?e:z(r+n,``),o=jr[n];P(!0);try{if(i.length>0){let{response:e}=await te({path:{assistant_id:s},body:{service:n,field:`api_key`,value:i,label:`${B.displayName} API Key`},throwOnError:!1});if(!e?.ok)throw Error(`Failed to store API key (HTTP ${e?.status??`?`})`)}let e={...x!==y||!b?{provider:n,mode:n===`cadet`?`managed`:`your-own`}:{},...o?{providers:{[n]:{[o]:t}}}:{},...ue?{providers:{cadet:{model:R.trim()}}}:{}};if(Object.keys(e).length>0){let{response:t}=await _({path:{assistant_id:s},body:{services:{tts:e}},throwOnError:!1});if(!t?.ok)throw Error(`Failed to save configuration (HTTP ${t?.status??`?`})`)}return j(i.length>0),k(t),w(``),u.invalidateQueries({queryKey:vt({path:{assistant_id:s}})}),W.success(a(`ttsProviderForm.saved`)),!0}catch(e){return W.error(e instanceof Error?e.message:a(`ttsProviderForm.saveFailed`)),!1}finally{P(!1)}},[s,x,R,ue,C,E,B,y,b,u,a]);(0,Q.useEffect)(()=>{i?.({hasChanges:fe,saving:ee,save:me})},[i,fe,ee,me]);let he=(0,Q.useCallback)(()=>{H(r+x,``),j(!1),w(``)},[x]),ge=(0,Q.useCallback)(async()=>{N(!0);try{let e=z(r+x,``),t=C.trim(),n=t.length>0?t:e;if(n.length===0){W.error(a(`ttsProviderForm.apiKeyRequired`));return}let i=z(le+x,``),o=E.trim(),s=await Er({provider:x,apiKey:n,voiceId:o.length>0?o:i,text:`Hey! It's ${c}. How does this sound?`});if(s.kind!==`audio`){W.error(s.message);return}let l=URL.createObjectURL(s.blob);try{let e=new Audio(l);await e.play(),await new Promise(t=>{e.onended=()=>t(),e.onerror=()=>t()})}finally{URL.revokeObjectURL(l)}}finally{N(!1)}},[c,C,x,E,a]),_e=A?`•••••••• (Enter a new key to replace)`:B.apiKeyPlaceholder,ve=x===`cadet`,ye=ve&&B.supportsVoiceSelection,be=(0,$.jsxs)(U,{variant:`link`,size:`compact`,className:`inline-flex h-auto items-center gap-1 px-0 underline [--vbtn-fg:var(--content-tertiary)]`,onClick:()=>{oe(!1),F.some(e=>e.model===R)||re(I||F[0]?.model||``)},children:[(0,$.jsx)(nn,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),a(`ttsProviderForm.chooseFromCatalog`)]}),xe=ye&&ce&&F.length>0?be:null;return(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:a(`ttsProviderForm.provider`)}),(0,$.jsx)(G,{value:x,onChange:S,options:f.map(e=>({value:e.id,label:e.displayName})),"aria-label":a(`ttsProviderForm.providerAriaLabel`)})]}),!ve&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:a(`ttsProviderForm.apiKey`)}),(0,$.jsx)(V,{type:`password`,value:C,onChange:e=>w(e.target.value),placeholder:_e,fullWidth:!0})]}),ye&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:a(`ttsProviderForm.voice`)}),ce?(0,$.jsx)(V,{type:`text`,value:R,onChange:e=>re(e.target.value),placeholder:a(`ttsProviderForm.voiceIdPlaceholder`),"aria-label":a(`ttsProviderForm.customVoiceIdAriaLabel`),fullWidth:!0}):ie?(0,$.jsx)(Ar,{assistantId:s,value:R,onChange:re}):L&&(0,$.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:a(`ttsProviderForm.noManagedVoices`)})]}),B.supportsVoiceSelection&&!ve&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:a(`ttsProviderForm.voiceId`)}),(0,$.jsx)(V,{type:`text`,value:E,onChange:e=>D(e.target.value),placeholder:a(`ttsProviderForm.voiceIdPlaceholder`),fullWidth:!0})]}),!n&&!ve&&(0,$.jsx)(fn,{guide:B.credentialsGuide}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!ve&&(0,$.jsx)(U,{variant:`outlined`,onClick:ge,disabled:M,children:a(M?`ttsProviderForm.testing`:`ttsProviderForm.test`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[xe,!t&&(0,$.jsx)(dn,{onClick:me,disabled:!fe||ee}),A&&!ve&&(0,$.jsx)(un,{onClick:he})]})]})]})}function Nr(){let{t:e}=Z(`settings`);return(0,$.jsx)(ln,{id:`text-to-speech`,title:e(`textToSpeechCard.title`),subtitle:e(`textToSpeechCard.subtitle`),children:(0,$.jsx)(Mr,{})})}var Pr=`default`;function Fr(){let{t:e}=Z(`settings`),t=T(),n=Y(),{data:r}=J({...wt({path:{assistant_id:t}}),staleTime:3e4}),a=ce({onSuccess:e=>{it(n,{path:{assistant_id:t}},e)}}),o=vn(),s=(0,Q.useMemo)(()=>r?r.services?.[`web-fetch`]?.provider||z(`cadet:ai:webFetchProvider`,Pr):z(me,Pr),[r]),c=(0,Q.useMemo)(()=>r?.services?.[`web-fetch`]?.apiBase??``,[r]),[u,d]=(0,Q.useState)(!1),[p,m]=yn(s),[h,g]=yn(c),[_,y]=(0,Q.useState)(``),b=I.has(p),x=ie.has(p),{hasStoredCredential:S}=xe({assistantId:t,credentialKind:`api_key`,credentialName:p,enabled:x}),C=_.trim().length>0,w=h.trim(),E=l(p,b&&w.length>0),D=p!==s||b&&w!==c.trim(),O=u||x&&!E&&!S&&!C||!D&&!C,k=At(je[p]??e(`webFetchCard.apiKeyPlaceholder`),S),A=Se[p]??``,j=(0,Q.useCallback)(async()=>{d(!0);let r=_.trim(),i=x&&r.length>0;try{i&&await o(p,r),await a.mutateAsync({path:{assistant_id:t},body:{services:{"web-fetch":{provider:p,...b?{apiBase:w}:{}}}}}).catch(t=>{throw W.error(e(`webFetchCard.configUpdateFailedToast`)),f(t,{context:`patch_daemon_config`}),t})}catch{d(!1);return}d(!1);try{if(H(me,p),i){let e=v(p);e&&H(e,r);let i=Ke(t,`api_key`,p);n.setQueryData(i,!0),n.invalidateQueries({queryKey:i}),y(``)}W.success(e(`webFetchCard.savedToast`))}catch(t){f(t,{context:`settings-ai-web-fetch-persist-local`}),W.error(e(`webFetchCard.localPreferencesFailedToast`))}},[x,a,o,n,t,_,p,b,w,e]),M=(0,Q.useCallback)(()=>{let e=v(p);e&&Ht(e),y(``),g(``),m(Pr),H(me,Pr)},[p,m,g]);return(0,$.jsx)(ln,{id:`web-fetch`,title:e(`webFetchCard.title`),subtitle:e(`webFetchCard.subtitle`),children:(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:e(`webFetchCard.providerLabel`)}),(0,$.jsx)(G,{value:p,onChange:m,options:i.map(e=>({value:e,label:Ut[e]??e}))})]}),b&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(V,{label:e(`webFetchCard.apiBaseLabel`),type:`url`,value:h,onChange:e=>g(e.target.value),placeholder:A||e(`webFetchCard.apiBasePlaceholder`),fullWidth:!0}),A?(0,$.jsx)(`p`,{className:`text-body-small-lighter text-[var(--content-tertiary)]`,children:e(`webFetchCard.apiBaseHint`,{defaultBase:A})}):null]}),x&&(0,$.jsx)(V,{label:e(`webFetchCard.apiKeyLabel`),type:`password`,value:_,onChange:e=>y(e.target.value),placeholder:k,fullWidth:!0}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(dn,{onClick:j,disabled:O}),u&&(0,$.jsx)(rn,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`}),x&&(0,$.jsx)(un,{onClick:M,filled:!0})]})]})})}var Ir=`0.10.12`;function Lr(){return fe(Ir)}function Rr(){let{t:e}=Z(`settings`),t=T(),r=Y(),i=Nt(),{data:a}=J({...wt({path:{assistant_id:t}}),enabled:i,staleTime:3e4}),o=ce({onSuccess:e=>{it(r,{path:{assistant_id:t}},e)}}),s=vn(),c=(0,Q.useMemo)(()=>{if(!a)return z(ye,`inference-provider-native`);let e=a.services?.[`web-search`];return(e?.mode===`managed`&&e?.provider!==`inference-provider-native`?`cadet`:e?.provider)||z(`cadet:ai:webSearchProvider`,`inference-provider-native`)},[a]),u=(0,Q.useMemo)(()=>a?.services?.[`web-search`]?.apiBase??``,[a]),[d,m]=(0,Q.useState)(!1),[h,g]=yn(c),[_,v]=yn(u),[y,b]=(0,Q.useState)(``),x=mt.has(h),C=n.has(h),w=dt.has(h),{hasStoredCredential:E}=xe({assistantId:t,credentialKind:`api_key`,credentialName:h,enabled:C}),D=y.trim().length>0,O=_.trim(),k=l(h,x&&O.length>0),A=h!==c||x&&O!==u.trim(),j=se[h]??``,M=C&&!w&&!k&&!E&&!D,N=x&&j.length===0&&!O,ee=d||M||N||!A&&!D,P=At(S[h]??e(`webSearchCard.apiKeyPlaceholder`),E),F=(0,Q.useCallback)(async()=>{m(!0);let n=y.trim(),i=p(h),a=C&&n.length>0;try{a&&await s(h,n),await ae();let r=h===`cadet`?Lr()?{provider:`cadet`,mode:`managed`}:{mode:`managed`}:{provider:h,mode:`your-own`,...x?{apiBase:O}:{}};await o.mutateAsync({path:{assistant_id:t},body:{services:{"web-search":r}}}).catch(t=>{throw W.error(e(`webSearchCard.configUpdateFailedToast`)),f(t,{context:`patch_daemon_config`}),t})}catch{m(!1);return}m(!1);try{if(H(ye,h),a){i&&H(i,n);let e=Ke(t,`api_key`,h);r.setQueryData(e,!0),r.invalidateQueries({queryKey:e}),b(``)}W.success(e(`webSearchCard.savedToast`))}catch(t){f(t,{context:`settings-ai-web-search-persist-local`}),W.error(e(`webSearchCard.localPreferencesFailedToast`))}},[C,o,s,r,t,y,h,x,O,e]),I=(0,Q.useCallback)(()=>{let e=p(h);e&&Ht(e),b(``),v(``),g(`inference-provider-native`),H(ye,`inference-provider-native`)},[h,g,v]);return(0,$.jsx)(ln,{title:e(`webSearchCard.title`),subtitle:e(`webSearchCard.subtitle`),children:(0,$.jsxs)(`div`,{className:`space-y-4`,children:[(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:e(`webSearchCard.providerLabel`)}),(0,$.jsx)(G,{"aria-label":e(`webSearchCard.providerAriaLabel`),value:h,onChange:g,options:_e.map(e=>({value:e,label:de[e]??e}))})]}),h===`cadet`&&(0,$.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:e(`webSearchCard.cadetNote`)}),x&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(V,{label:e(`webSearchCard.apiBaseLabel`),type:`url`,value:_,onChange:e=>v(e.target.value),placeholder:j||e(`webSearchCard.apiBasePlaceholder`),fullWidth:!0}),j?(0,$.jsx)(`p`,{className:`text-body-small-lighter text-[var(--content-tertiary)]`,children:e(`webSearchCard.apiBaseHint`,{defaultBase:j})}):null]}),C&&(0,$.jsx)(V,{label:e(`webSearchCard.apiKeyLabel`),type:`password`,value:y,onChange:e=>b(e.target.value),placeholder:P,fullWidth:!0}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(dn,{onClick:F,disabled:ee}),d&&(0,$.jsx)(rn,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`}),C&&(0,$.jsx)(un,{onClick:I,filled:!0})]})]})})}function zr(){let e=T(),t=bt(),[n,r]=(0,Q.useState)(null);(0,Q.useEffect)(()=>{let e=window.location.hash.slice(1);e&&requestAnimationFrame(()=>{document.getElementById(e)?.scrollIntoView({block:`start`})})},[]);let i=(0,$.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-5 overflow-y-auto`,children:[(0,$.jsx)(tr,{}),(0,$.jsx)($n,{panel:n,onOpenPanel:r,onClosePanel:()=>r(null)}),(0,$.jsx)(Rr,{}),(0,$.jsx)(Fr,{}),(0,$.jsx)(wn,{}),(0,$.jsx)(Nr,{}),(0,$.jsx)(Tr,{})]}),a=`${e??`none`}:${n?.kind===`profile`?`profile:${n.name}`:n?.kind===`provider`?`provider:${n.name}`:n?.kind??`closed`}`,o=n?.kind===`provider`||n?.kind===`add-provider`,s=n!=null&&e?n.kind===`overrides`?(0,$.jsx)(mr,{assistantId:e,onClose:()=>r(null)},a):o?(0,$.jsx)(_r,{assistantId:e,connectionName:n.kind===`provider`?n.name:null,onClose:()=>r(null)},a):(0,$.jsx)(nr,{assistantId:e,profileName:n.kind===`profile`?n.name:null,onClose:()=>r(null)},a):null;return s&&t?(0,$.jsx)(mn,{children:s}):s?(0,$.jsx)(gn,{storageKey:`aiSettingsDetailDrawerWidth`,detailKey:a,section:i,detail:s}):i}export{zr as AiPage};