@vellumai/web 0.12.6-staging.1 → 0.12.6-staging.2

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 (217) hide show
  1. package/dist/assets/{a2a-invite-DvNtJAR3.js → a2a-invite-DLiMk0tx.js} +1 -1
  2. package/dist/assets/{about-page-C1cvW4yO.js → about-page-CiMOdcNb.js} +1 -1
  3. package/dist/assets/{account-page-Bgjf5RI6.js → account-page-TK116SOZ.js} +1 -1
  4. package/dist/assets/{account-shell-DRn4zar4.js → account-shell-81SeJquZ.js} +1 -1
  5. package/dist/assets/{acp-run-detail-panel-BrqZK5yq.js → acp-run-detail-panel-CmPXAFIy.js} +1 -1
  6. package/dist/assets/{activation-list-route-BSzFk01N.js → activation-list-route-CI0Q1kuF.js} +1 -1
  7. package/dist/assets/{activity-redirect-page-C9vyj4s3.js → activity-redirect-page-C_U_6GGf.js} +1 -1
  8. package/dist/assets/{activity-steps-panel-UE22AUHt.js → activity-steps-panel-C4gojUTz.js} +1 -1
  9. package/dist/assets/add-credits-modal-Cx2D0qMT.js +1 -0
  10. package/dist/assets/{add-credits-modal-BJdNKyZn.js → add-credits-modal-DckEY84t.js} +1 -1
  11. package/dist/assets/{ai-page-BRcEoO4h.js → ai-page-BmHi1DMy.js} +1 -1
  12. package/dist/assets/{all-chats-page-route-Cdywc2Lw.js → all-chats-page-route-Bar5pmkt.js} +1 -1
  13. package/dist/assets/{android-billing-handoff-DHmIdr3k.js → android-billing-handoff-CBj4G7HW.js} +1 -1
  14. package/dist/assets/{animated-stat-square-De3doWUf.js → animated-stat-square-Dh0clEOc.js} +1 -1
  15. package/dist/assets/{api-key-screen-D46IlNCg.js → api-key-screen-CEZN1wmw.js} +1 -1
  16. package/dist/assets/{app-CnOToYzw.css → app-6IVvZ0HU.css} +1 -1
  17. package/dist/assets/{app-4aEhon_S.js → app-D0NlDYsG.js} +17 -17
  18. package/dist/assets/{app-info-BEZIXj2r.js → app-info-D4RcR6ew.js} +1 -1
  19. package/dist/assets/{archive-redirect-page-f-tQTBcO.js → archive-redirect-page-BzkHSKVl.js} +1 -1
  20. package/dist/assets/{assistant-handle-modal-D2Fs4sCC.js → assistant-handle-modal-CH_OHdcF.js} +1 -1
  21. package/dist/assets/assistant-inbox-page-route-B6wflkJF.js +8 -0
  22. package/dist/assets/{assistant-status-panel-DHEoS1o_.js → assistant-status-panel-DwkD7W_2.js} +1 -1
  23. package/dist/assets/auth-store-MTbC_MGl.js +1 -0
  24. package/dist/assets/{auth-welcome-screen-BGeyvWeV.js → auth-welcome-screen-DCozLA-c.js} +1 -1
  25. package/dist/assets/avatar-bundled-components-BzBQbsbk.js +1 -0
  26. package/dist/assets/{avatar-random-D2smfcQG.js → avatar-random-DITwNAON.js} +2 -2
  27. package/dist/assets/{await-org-header-settled-DLSu8FLl.js → await-org-header-settled-qqVu2-4K.js} +1 -1
  28. package/dist/assets/{background-task-detail-panel-BZGjlvvR.js → background-task-detail-panel-DKAy68TE.js} +1 -1
  29. package/dist/assets/{billing-page-CEL1j7Pd.js → billing-page-CKfb20qY.js} +3 -3
  30. package/dist/assets/{billing-redirect-page-D0rxZiKb.js → billing-redirect-page-2osoPYFq.js} +1 -1
  31. package/dist/assets/{bookmarks-page-3DBCCW9Z.js → bookmarks-page-BjXRVnIe.js} +1 -1
  32. package/dist/assets/{bundle-confirm-page-DqZwqwSV.js → bundle-confirm-page-CrdckyMV.js} +1 -1
  33. package/dist/assets/{channel-transcript-panel-CFWSmMFa.js → channel-transcript-panel-BuZfEA7U.js} +1 -1
  34. package/dist/assets/{channels-Bj0jbmsg.js → channels--GWixc4A.js} +3 -3
  35. package/dist/assets/{channels-CrHSbYG5.js → channels-BJA5o10X.js} +3 -3
  36. package/dist/assets/{channels-B-C6ns2I.js → channels-BWlMRtuu.js} +3 -3
  37. package/dist/assets/{channels-DS5qwHtC.js → channels-BchiOW8d.js} +3 -3
  38. package/dist/assets/{channels-page-route-nwdK8POV.js → channels-page-route-Cg7kY8Ai.js} +1 -1
  39. package/dist/assets/{chat-info-panel-4xiBaedR.js → chat-info-panel-DL7X3eOQ.js} +1 -1
  40. package/dist/assets/{checkout-continuation-DiZjXso_.js → checkout-continuation-CY40TSs-.js} +1 -1
  41. package/dist/assets/{checkout-page-CpXe7B0Y.js → checkout-page-B0xOGseN.js} +1 -1
  42. package/dist/assets/checkout-return-target-gl5H9x5u.js +1 -0
  43. package/dist/assets/command-palette-BLiF3fyX.js +1 -0
  44. package/dist/assets/{command-palette-BwJ1qkwj.js → command-palette-CQYESNwG.js} +1 -1
  45. package/dist/assets/{command-palette-window-page-s0d4qct2.js → command-palette-window-page-BB81RrWx.js} +1 -1
  46. package/dist/assets/{community-page-BxJhxO_B.js → community-page-BtRNJxo9.js} +1 -1
  47. package/dist/assets/{companion-accent-IfLn8Bat.js → companion-accent-DPZ9Nluh.js} +1 -1
  48. package/dist/assets/{companion-dock-zones-page-BZ_Xjx9t.js → companion-dock-zones-page-U9kZSVxS.js} +1 -1
  49. package/dist/assets/{companion-layout-B32ZeRsg.js → companion-layout-DjM8056C.js} +1 -1
  50. package/dist/assets/{companion-popover-DJZq3u_E.js → companion-popover-DwgXZsMW.js} +1 -1
  51. package/dist/assets/{companion-popover-page-BUuymP2G.js → companion-popover-page-CcdLMpdW.js} +1 -1
  52. package/dist/assets/{companion-surface-BiEC15j-.js → companion-surface-Da1cTcgR.js} +1 -1
  53. package/dist/assets/{companion-surface-page-1aPG3-pV.js → companion-surface-page--6xuXTFM.js} +1 -1
  54. package/dist/assets/{companion-tour-entry-CT1inXph.js → companion-tour-entry-GiftNvIY.js} +1 -1
  55. package/dist/assets/{companion-watch-frame-page-CccglwW8.js → companion-watch-frame-page-BboeANE6.js} +1 -1
  56. package/dist/assets/{connect-page-CU5kFWwu.js → connect-page-BqlDwAok.js} +1 -1
  57. package/dist/assets/{consent-controls-BU14rUBI.js → consent-controls-DtYOOcoG.js} +1 -1
  58. package/dist/assets/{contacts-gateway-lKGtK3Rt.js → contacts-gateway-BUQHi3Rm.js} +1 -1
  59. package/dist/assets/{contacts-page-route-Dsl49Gyj.js → contacts-page-route-CapX1klb.js} +1 -1
  60. package/dist/assets/{copy-button-DTTBuV2S.js → copy-button-5QB6tIZi.js} +1 -1
  61. package/dist/assets/{credential-entry-page-Bcru96sp.js → credential-entry-page-C2yTTqSI.js} +1 -1
  62. package/dist/assets/{credentials-page-vIwKR2Br.js → credentials-page-DTZCc_jM.js} +1 -1
  63. package/dist/assets/{csv-preview-DC4egHwn.js → csv-preview-Dg1E9gcw.js} +1 -1
  64. package/dist/assets/{danger-zone-redirect-page-R5BXWtEi.js → danger-zone-redirect-page-BxnmBzTy.js} +1 -1
  65. package/dist/assets/{debug-page-BZtacr2-.js → debug-page-Cv3_hpaB.js} +1 -1
  66. package/dist/assets/deploy-dialogs-7jGhK4l2.js +1 -0
  67. package/dist/assets/{deploy-dialogs-B3_x3fxQ.js → deploy-dialogs-Dy1YiAUx.js} +1 -1
  68. package/dist/assets/{desktop-preview-content-CKM5RXGD.js → desktop-preview-content-_hBA655n.js} +2 -2
  69. package/dist/assets/{desktop-status-DvjcbwTJ.js → desktop-status-t3wLUynb.js} +1 -1
  70. package/dist/assets/{desktop-viewer-BMPa6Aex.js → desktop-viewer-Zm7K7Goi.js} +1 -1
  71. package/dist/assets/{detail-card-Dmas0G3E.js → detail-card-BhbwKaee.js} +1 -1
  72. package/dist/assets/{detail-panel-stop-button-DkHGogvW.js → detail-panel-stop-button-BR-k5Xmc.js} +1 -1
  73. package/dist/assets/{detail-primitives-DMIwvBhc.js → detail-primitives-Dgh4IUh2.js} +1 -1
  74. package/dist/assets/{developer-page-B6e5nSkG.js → developer-page-BeATC5qR.js} +1 -1
  75. package/dist/assets/{devices-redirect-page-mofL9eFw.js → devices-redirect-page-BjQ3ITZg.js} +1 -1
  76. package/dist/assets/{dictation-overlay-page-CwDjZbE1.js → dictation-overlay-page-Dy5vIWxC.js} +1 -1
  77. package/dist/assets/document-load-B7bN8N4u.js +1 -0
  78. package/dist/assets/{document-load-DoRmIVja.js → document-load-Ca8B9f1j.js} +1 -1
  79. package/dist/assets/{document-viewer-page-CQUX0aEC.js → document-viewer-page-BXGQ3JBX.js} +1 -1
  80. package/dist/assets/{emails-page-DwAhlaQg.js → emails-page-DJBdc2in.js} +1 -1
  81. package/dist/assets/{file-diff-view-BezobneE.js → file-diff-view-C6IviiAg.js} +1 -1
  82. package/dist/assets/{file-view-mode-jU2cqUIy.js → file-view-mode-CusGxTrO.js} +1 -1
  83. package/dist/assets/{general-page-doMlZdWO.js → general-page-BFn9KhSd.js} +1 -1
  84. package/dist/assets/{hatching-screen-D5uYMUSk.js → hatching-screen-BPBDkDXC.js} +1 -1
  85. package/dist/assets/{hosting-screen-N04Vxm7m.js → hosting-screen-C_1tvRyn.js} +1 -1
  86. package/dist/assets/{identity-page-route-DYaWHWV4.js → identity-page-route-CBYR7Ik7.js} +1 -1
  87. package/dist/assets/{inspect-page-Day-dKxu.js → inspect-page-C1_GK1MG.js} +3 -3
  88. package/dist/assets/{integrations-page-BepnHU85.js → integrations-page-tVNddBNW.js} +1 -1
  89. package/dist/assets/{intelligence-layout-8z9eS22i.js → intelligence-layout-B2AmY2BP.js} +1 -1
  90. package/dist/assets/{intelligence-layout-slots-store-J-MoKCmF.js → intelligence-layout-slots-store-D6qaMstC.js} +1 -1
  91. package/dist/assets/{keyboard-shortcuts-redirect-page-CtGxfm3n.js → keyboard-shortcuts-redirect-page-DCra2iW7.js} +1 -1
  92. package/dist/assets/{latest-assistant-text-Chtu1E3p.js → latest-assistant-text-BvuWjv7_.js} +1 -1
  93. package/dist/assets/{library-detail-page-BU3HVzyr.js → library-detail-page-DPas89E0.js} +1 -1
  94. package/dist/assets/{library-page-Co-CAon1.js → library-page-D9RL3HDn.js} +1 -1
  95. package/dist/assets/local-mode-BM0aWB6A.js +1 -0
  96. package/dist/assets/{login-page-bUkrHHVA.js → login-page-EuF3D2nA.js} +1 -1
  97. package/dist/assets/{logout-page-D2ibyaux.js → logout-page-BNacG6Tt.js} +1 -1
  98. package/dist/assets/{logs-layout-DpQF78Kt.js → logs-layout-DnsMzvJ_.js} +1 -1
  99. package/dist/assets/{markdown-preview-CId4qJWy.js → markdown-preview-C2Z0FRTc.js} +1 -1
  100. package/dist/assets/{media-preview-C1XFdtRz.js → media-preview-BcSPsOfs.js} +1 -1
  101. package/dist/assets/{memory-page-route--WvX90Lh.js → memory-page-route-CX33STIW.js} +1 -1
  102. package/dist/assets/{memory-router-playground-page-BX6jtqI2.js → memory-router-playground-page-DgzlohIX.js} +1 -1
  103. package/dist/assets/{message-files-panel-BWQX_2Z_.js → message-files-panel-Dc5JcFJT.js} +1 -1
  104. package/dist/assets/mutation-error-Bpj2rO9W.js +1 -0
  105. package/dist/assets/native-attachment-pickers-BEdhcWFZ.js +1 -0
  106. package/dist/assets/native-file-uymdgwvc.js +1 -0
  107. package/dist/assets/{notifications-page-CgWLXf5V.js → notifications-page-BXm0OpJB.js} +1 -1
  108. package/dist/assets/{oauth-complete-page-DZlImmvw.js → oauth-complete-page-D0ymRcSM.js} +1 -1
  109. package/dist/assets/{oauth-popup-complete-page-C1Dc5fk0.js → oauth-popup-complete-page-8iZS6PLm.js} +1 -1
  110. package/dist/assets/paired-platform-identity-BumKYxOS.js +1 -0
  111. package/dist/assets/{pairing-page-Dhcr9SjD.js → pairing-page-ClXvlMJw.js} +1 -1
  112. package/dist/assets/password-reset-page-C4ulvC0x.js +1 -0
  113. package/dist/assets/{pdf-file-preview-D_ClglAA.js → pdf-file-preview-Bl5mk1_3.js} +1 -1
  114. package/dist/assets/{permission-guide-page-DHZIzkOy.js → permission-guide-page-BbHEjtyD.js} +1 -1
  115. package/dist/assets/{permission-setup-Dmd2zFPe.js → permission-setup-3fJQB-KB.js} +1 -1
  116. package/dist/assets/{personality-page-BhAHEnK3.js → personality-page-BTNI4eG5.js} +1 -1
  117. package/dist/assets/{personality-page-CE8DlY9y.js → personality-page-CFaJc26z.js} +1 -1
  118. package/dist/assets/{personality-sliders-pVdEr3Fn.js → personality-sliders-CJrh8-AP.js} +1 -1
  119. package/dist/assets/{plans-page-CkIK_N4U.js → plans-page-DSDYvUo5.js} +1 -1
  120. package/dist/assets/{platform-loopback-page-C0s9CAsp.js → platform-loopback-page-BDR7i_cY.js} +1 -1
  121. package/dist/assets/{plugin-detail-page-C9zJ32IV.js → plugin-detail-page-BJfIO-HZ.js} +1 -1
  122. package/dist/assets/{plugins-page-Cf_vJwd8.js → plugins-page-b9i4h7rI.js} +1 -1
  123. package/dist/assets/plugins-surface-5VJsSvrd.js +1 -0
  124. package/dist/assets/{preview-error-Cxcn_uOl.js → preview-error-BKpqKOCK.js} +1 -1
  125. package/dist/assets/{privacy-page-v0Bl1gUD.js → privacy-page-CWwydiKF.js} +1 -1
  126. package/dist/assets/{privacy-screen-DZWucyGJ.js → privacy-screen-GBRjX2Y3.js} +1 -1
  127. package/dist/assets/{profile-card-jvtX_IRJ.js → profile-card-ClUTN6Rc.js} +1 -1
  128. package/dist/assets/{provider-callback-page-DadzY3GT.js → provider-callback-page-0z-aomMf.js} +1 -1
  129. package/dist/assets/{provider-key-DUY2mZm5.js → provider-key-DTk8I67Q.js} +1 -1
  130. package/dist/assets/{provider-signup-page-BMjPqmWY.js → provider-signup-page-BKlREM_2.js} +1 -1
  131. package/dist/assets/{quick-input-page-CSBA98SR.js → quick-input-page-Ddg_UlmO.js} +1 -1
  132. package/dist/assets/referral-modal-Bx__UjCU.js +1 -0
  133. package/dist/assets/{referral-modal-0EhqMTDP.js → referral-modal-DZObiadq.js} +1 -1
  134. package/dist/assets/{research-mock-page-pdYsSAXo.js → research-mock-page-CutRQF5f.js} +1 -1
  135. package/dist/assets/{research-onboarding-route-DQDC7A-X.js → research-onboarding-route-DBQZHDC7.js} +1 -1
  136. package/dist/assets/{review-terms-screen-D9ZsDaFc.js → review-terms-screen-dBbWlnXP.js} +1 -1
  137. package/dist/assets/routes-DEGM-k2Y.js +1 -0
  138. package/dist/assets/{schedules-BZK7XLW4.js → schedules-0KQuWZ-V.js} +1 -1
  139. package/dist/assets/{schedules-page-DzosmuUG.js → schedules-page-BvbL-8N9.js} +1 -1
  140. package/dist/assets/{security-redirect-page-BfEf2yb3.js → security-redirect-page-CH4u9S3v.js} +1 -1
  141. package/dist/assets/{select-assistant-screen-ByEWxket.js → select-assistant-screen-C5892FeX.js} +1 -1
  142. package/dist/assets/{self-hosted-servers-BnexEHid.js → self-hosted-servers-C__IKdzk.js} +1 -1
  143. package/dist/assets/{service-form-controls-L7ipWS7W.js → service-form-controls-CjcwqBZf.js} +1 -1
  144. package/dist/assets/{setting-row-CqsRGW0M.js → setting-row-oSonbOdy.js} +1 -1
  145. package/dist/assets/{settings-layout-dtUgeZGT.js → settings-layout-Cf0NuysH.js} +1 -1
  146. package/dist/assets/{share-feedback-modal-CICNVpZG.js → share-feedback-modal-C7IjV0PW.js} +1 -1
  147. package/dist/assets/share-feedback-modal-DjrtiKSJ.js +1 -0
  148. package/dist/assets/{sidebar-tree-CVlGLFk1.js → sidebar-tree-BLqbyk5v.js} +1 -1
  149. package/dist/assets/{signup-page-BawjjAk9.js → signup-page-BTkcbn24.js} +1 -1
  150. package/dist/assets/{signup-shell-C4zWZKlP.js → signup-shell-DrGfLGsz.js} +1 -1
  151. package/dist/assets/{skill-detail-page-BR1VzP5J.js → skill-detail-page-DZ_FXWFT.js} +1 -1
  152. package/dist/assets/{skill-detail-panel-Ch4YwxDI.js → skill-detail-panel-xL20TJgL.js} +1 -1
  153. package/dist/assets/{skill-removal-dialog-ph42N7Fl.js → skill-removal-dialog-C4WF7sn9.js} +1 -1
  154. package/dist/assets/{skills-page-B54_bM3G.js → skills-page-C0ikFeI-.js} +1 -1
  155. package/dist/assets/{sounds-page-B5dZjlPM.js → sounds-page-BYZulvt8.js} +1 -1
  156. package/dist/assets/{start-screen-c_PymAl2.js → start-screen-CjIOV9Ig.js} +1 -1
  157. package/dist/assets/{step-detail-header-ygmZC0KS.js → step-detail-header-BsK4vZvH.js} +1 -1
  158. package/dist/assets/{stt-language-picker-modal-CMFxMa9N.js → stt-language-picker-modal-ArB52Kbp.js} +1 -1
  159. package/dist/assets/{subagent-detail-panel-BS4IYvJn.js → subagent-detail-panel-Cqr5RNAr.js} +1 -1
  160. package/dist/assets/{superpowers-page-DKB6-Ybz.js → superpowers-page-CM-_gkRq.js} +1 -1
  161. package/dist/assets/{system-events-page-B44LpDTv.js → system-events-page-q1CCjaae.js} +1 -1
  162. package/dist/assets/{system-events-redirect-page-C62wCy1z.js → system-events-redirect-page-D0nYClwA.js} +1 -1
  163. package/dist/assets/{tabular-grid-D5w2zPZ2.js → tabular-grid-ClRQmbrS.js} +1 -1
  164. package/dist/assets/{teleport-gateway-client-B8BG_rTx.js → teleport-gateway-client-BCQlm0IG.js} +1 -1
  165. package/dist/assets/{text-preview-Ofuqm3k1.js → text-preview-DisLM6Ix.js} +1 -1
  166. package/dist/assets/{theme-stage-page--f110ocQ.js → theme-stage-page-B4lCVU0g.js} +1 -1
  167. package/dist/assets/{tiptap-document-editor-hK0z9JkB.js → tiptap-document-editor-NU9u7Q3B.js} +1 -1
  168. package/dist/assets/tool-detail-panel-BZPy9LTd.js +1 -0
  169. package/dist/assets/{tool-detail-panel-B58LHS7C.js → tool-detail-panel-BgULoaCP.js} +1 -1
  170. package/dist/assets/{trait-cycle-row-Bn8sB1ll.js → trait-cycle-row-h6tNq4lj.js} +1 -1
  171. package/dist/assets/{upgrade-cancel-page-YlN6tF2j.js → upgrade-cancel-page-CSFfsg3T.js} +1 -1
  172. package/dist/assets/{upgrade-success-page-B1qO-4bt.js → upgrade-success-page-Bb9vkeFS.js} +1 -1
  173. package/dist/assets/{usage-redirect-page-B_r-Rjza.js → usage-redirect-page-DxSTmtpM.js} +1 -1
  174. package/dist/assets/{use-app-delete-C3OP3RL_.js → use-app-delete-CyCUfXGp.js} +1 -1
  175. package/dist/assets/{use-assistant-identity-details-CgpWYPrD.js → use-assistant-identity-details-ft05GaL-.js} +1 -1
  176. package/dist/assets/use-channel-trust-floors-DeIos7Sw.js +1 -0
  177. package/dist/assets/{use-checkout-dismiss-refresh-CxHKmnto.js → use-checkout-dismiss-refresh-CVLzCRhG.js} +1 -1
  178. package/dist/assets/{use-edge-swipe-back-D0Hv2Vbo.js → use-edge-swipe-back-kH1IWvhn.js} +1 -1
  179. package/dist/assets/{use-hotkey-recorder-CPwPHbVu.js → use-hotkey-recorder-B0ho6P1Q.js} +1 -1
  180. package/dist/assets/{use-invite-link-dialog-YrW4BryT.js → use-invite-link-dialog-BWTyTo38.js} +1 -1
  181. package/dist/assets/{use-plugins-list-DbtoYlBb.js → use-plugins-list-Dg7cmWWy.js} +1 -1
  182. package/dist/assets/{use-return-to-short-circuit-DIiSf2mw.js → use-return-to-short-circuit-DZLF2zb8.js} +1 -1
  183. package/dist/assets/{use-side-list-room-DF3yxstr.js → use-side-list-room-Bm4W05s8.js} +1 -1
  184. package/dist/assets/{use-skill-actions-C-MM5fH5.js → use-skill-actions-BDB6OPDL.js} +1 -1
  185. package/dist/assets/{use-skill-detail-files-BC8o1y4B.js → use-skill-detail-files-DOJu82AO.js} +1 -1
  186. package/dist/assets/use-supports-credentials-settings-VPsbB7QL.js +1 -0
  187. package/dist/assets/{use-transcript-message-by-id-yY3_Y5YT.js → use-transcript-message-by-id-ImJNR0ZS.js} +1 -1
  188. package/dist/assets/{voice-page-C6plqSbB.js → voice-page-D6iJnwpE.js} +1 -1
  189. package/dist/assets/{wake-detail-panel-ByOMpvzL.js → wake-detail-panel-BBCXrrwt.js} +1 -1
  190. package/dist/assets/{weather-forecast-display-wWI7BbOq.js → weather-forecast-display-D38nUHK1.js} +1 -1
  191. package/dist/assets/{welcome-screen-BrWlqKCU.js → welcome-screen-CUh7JIoK.js} +1 -1
  192. package/dist/assets/{workflow-detail-panel-Tur0cTTa.js → workflow-detail-panel-Cle_xFav.js} +1 -1
  193. package/dist/assets/{workspace-page-BC6DuJ6j.js → workspace-page-BhdFaoFV.js} +1 -1
  194. package/dist/assets/{xlsx-preview-QwpwZ8Ls.js → xlsx-preview-DVein85j.js} +1 -1
  195. package/dist/index.html +2 -2
  196. package/package.json +1 -1
  197. package/dist/assets/add-credits-modal-CTwFNbFw.js +0 -1
  198. package/dist/assets/assistant-inbox-page-route-BNxtQgVH.js +0 -8
  199. package/dist/assets/auth-store-Ck9VwH27.js +0 -1
  200. package/dist/assets/avatar-bundled-components-BvhWO4x6.js +0 -1
  201. package/dist/assets/checkout-return-target-BMk9sOs5.js +0 -1
  202. package/dist/assets/command-palette-vN1QduVf.js +0 -1
  203. package/dist/assets/deploy-dialogs-gl-8Gfwg.js +0 -1
  204. package/dist/assets/document-load-vorRpGY8.js +0 -1
  205. package/dist/assets/local-mode-BDAFwrps.js +0 -1
  206. package/dist/assets/mutation-error-1lzyVoa-.js +0 -1
  207. package/dist/assets/native-attachment-pickers-C9F0ZR30.js +0 -1
  208. package/dist/assets/native-file-_gmszDPP.js +0 -1
  209. package/dist/assets/paired-platform-identity-CLNgDq2A.js +0 -1
  210. package/dist/assets/password-reset-page-DwD-Tr9u.js +0 -1
  211. package/dist/assets/plugins-surface-tkjP75qI.js +0 -1
  212. package/dist/assets/referral-modal-DpPM4ySm.js +0 -1
  213. package/dist/assets/routes--G7bm1Kz.js +0 -1
  214. package/dist/assets/share-feedback-modal-CVfT5Isv.js +0 -1
  215. package/dist/assets/tool-detail-panel-hGcjKO-7.js +0 -1
  216. package/dist/assets/use-channel-trust-floors-oeRMVBZa.js +0 -1
  217. package/dist/assets/use-supports-credentials-settings-C5z3u-mM.js +0 -1
@@ -1 +1 @@
1
- import{DS as e}from"./app-4aEhon_S.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{DS as e}from"./app-D0NlDYsG.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{Hg as t,OS as n,RC as r,uw as i}from"./app-4aEhon_S.js";import{E as a}from"./vendor-CtXGFqsu.js";import{t as o,x as s}from"./react-B9IgSVeK.js";import{n as c,t as l}from"./app-info-BEZIXj2r.js";var u=e(s(),1),d=o();function f(){let{t:e}=a(),o=t(),[s,f]=(0,u.useState)(null);(0,u.useEffect)(()=>{l().then(f)},[]);let m=s??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(o===`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:i(r(),`text-sm`),onClick:e=>{n()&&(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:`Vellum`,version:`—`,commitSha:`—`,copyright:`© ${new Date().getFullYear()} Vellum`,website:`https://vellum.ai`};export{f as AboutPage};
1
+ import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{Hg as t,OS as n,RC as r,uw as i}from"./app-D0NlDYsG.js";import{E as a}from"./vendor-CtXGFqsu.js";import{t as o,x as s}from"./react-B9IgSVeK.js";import{n as c,t as l}from"./app-info-D4RcR6ew.js";var u=e(s(),1),d=o();function f(){let{t:e}=a(),o=t(),[s,f]=(0,u.useState)(null);(0,u.useEffect)(()=>{l().then(f)},[]);let m=s??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(o===`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:i(r(),`text-sm`),onClick:e=>{n()&&(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:`Vellum`,version:`—`,commitSha:`—`,copyright:`© ${new Date().getFullYear()} Vellum`,website:`https://vellum.ai`};export{f as AboutPage};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{$y as t,DS as n,Nh as r,Oh as i,hl as a,jh as o,ol as s,sl as c}from"./app-4aEhon_S.js";import{E as l}from"./vendor-CtXGFqsu.js";import{n as u,t as d,x as f}from"./react-B9IgSVeK.js";import{r as p,t as m}from"./account-shell-DRn4zar4.js";var h=e(f(),1),g=d();function _(){let{t:e}=l(`account`),d=o(),f=r(),_=i.use.user(),v=i.use.logout(),[y,b]=(0,h.useState)(null),[x,S]=(0,h.useState)(!1),C=async()=>{b(null),S(!0);try{await t(c,s)}catch(t){console.error(`[account] auth flow failed:`,t),b(e(`authErrors.genericFailure`)),S(!1)}};return f?(0,g.jsx)(m,{children:(0,g.jsx)(p,{title:e(`accountPage.loading`)})}):d?(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)(u,{to:n.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(),a(n.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{$y as t,DS as n,Nh as r,Oh as i,hl as a,jh as o,ol as s,sl as c}from"./app-D0NlDYsG.js";import{E as l}from"./vendor-CtXGFqsu.js";import{n as u,t as d,x as f}from"./react-B9IgSVeK.js";import{r as p,t as m}from"./account-shell-81SeJquZ.js";var h=e(f(),1),g=d();function _(){let{t:e}=l(`account`),d=o(),f=r(),_=i.use.user(),v=i.use.logout(),[y,b]=(0,h.useState)(null),[x,S]=(0,h.useState)(!1),C=async()=>{b(null),S(!0);try{await t(c,s)}catch(t){console.error(`[account] auth flow failed:`,t),b(e(`authErrors.genericFailure`)),S(!1)}};return f?(0,g.jsx)(m,{children:(0,g.jsx)(p,{title:e(`accountPage.loading`)})}):d?(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)(u,{to:n.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(),a(n.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{GC as e}from"./app-4aEhon_S.js";import{t}from"./react-B9IgSVeK.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{GC as e}from"./app-D0NlDYsG.js";import{t}from"./react-B9IgSVeK.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{$n as t,BC as n,Cr as r,Er as i,Fn as a,IS as o,JC as s,Kn as c,Qn as l,Tr as u,Zn as d,aw as f,sC as p,tr as m,uw as h,wr as g}from"./app-4aEhon_S.js";import{E as _,j as v}from"./vendor-CtXGFqsu.js";import{t as y,x as b}from"./react-B9IgSVeK.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-C0wyat6T.js";import{n as I,r as se,t as L}from"./animated-stat-square-De3doWUf.js";import{o as ce,t as le}from"./detail-primitives-DMIwvBhc.js";import{t as ue}from"./file-diff-view-BezobneE.js";import{t as de}from"./detail-panel-stop-button-DkHGogvW.js";import{t as fe}from"./status-badge-pill-TVPV4D5e.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(b(),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(r.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{$n as t,BC as n,Cr as r,Er as i,Fn as a,IS as o,JC as s,Kn as c,Qn as l,Tr as u,Zn as d,aw as f,sC as p,tr as m,uw as h,wr as g}from"./app-D0NlDYsG.js";import{E as _,j as v}from"./vendor-CtXGFqsu.js";import{t as y,x as b}from"./react-B9IgSVeK.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-C0wyat6T.js";import{n as I,r as se,t as L}from"./animated-stat-square-Dh0clEOc.js";import{o as ce,t as le}from"./detail-primitives-Dgh4IUh2.js";import{t as ue}from"./file-diff-view-C6IviiAg.js";import{t as de}from"./detail-panel-stop-button-BR-k5Xmc.js";import{t as fe}from"./status-badge-pill-TVPV4D5e.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(b(),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(r.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=y();function Ce({content:e,isComplete:t,assistantId:n}){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)(a,{content:e,assistantId:n}),!t&&(0,X.jsx)(c,{className:`mt-1`,"data-testid":`acp-chat-agent-streaming`})]})}function Z({entries:e}){let{t}=_(`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)(s,{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 v(`chat:acpChatTerminalBlock.stoppedLimitReached`);case`refusal`:return v(`chat:acpChatTerminalBlock.refused`);case`cancelled`:return v(`chat:acpChatTerminalBlock.cancelled`);default:return v(`chat:acpChatTerminalBlock.completed`)}}function Te(e){return new Date(e).toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`})}function Q({completedAt:e}){let{t}=_(`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:a}=_(`chat`);if(i(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??a(`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:a(`acpChatTerminalBlock.cancelled`)}),(0,X.jsx)(Q,{completedAt:r})]});let o=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:o}),(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:n}){let[r,i]=(0,R.useState)(null),o=r??!t,s=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)(c,{dotSize:5,className:`shrink-0`,"data-testid":`acp-chat-thinking-streaming`});return s?(0,X.jsxs)(`div`,{"data-testid":`acp-chat-thinking-block`,className:`w-full`,children:[(0,X.jsxs)(`button`,{type:`button`,"aria-expanded":o,onClick:()=>i(!o),"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:[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`}),u,(0,X.jsx)(`span`,{children:l})]}),o&&(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)(a,{content:e,assistantId:n})})]}):(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:r,onOpenOutput:i}){let{t:a}=_(`chat`),[o,l]=(0,R.useState)(!1),u=(0,R.useMemo)(()=>G(e.content),[e.content]),d=(0,R.useMemo)(()=>q(e.content),[e.content]),f=(0,R.useMemo)(()=>d.split(`
3
3
  `).map(e=>e.trim()).find(e=>e.length>0&&!e.startsWith("```"))||`View output`,[d]),p=(0,R.useMemo)(()=>Y(u,e.locations),[u,e.locations]),m=t&&e.status===`running`?`ended`:e.status,h=m===`running`,g=e.toolKind&&je[e.toolKind]||Me,v=K(e.rawInput)??e.title,y=v&&v!==g&&(!Pe.has(e.toolKind??``)||p.length===0)?v:null,b=J(e.rawInput),x=J(e.rawOutput),S=b!==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)(s,{variant:`body-small-emphasised`,className:`min-w-0 flex-1 truncate text-[var(--content-default)]`,title:e.title,children:g}),(0,X.jsx)(n,{tone:ke[m],"data-testid":`acp-chat-tool-status`,children:Ae[m]}),h&&(0,X.jsx)(c,{className:`shrink-0`,"data-testid":`acp-chat-tool-running`})]}),y&&(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:y}),p.length>0&&(0,X.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:p.map(t=>{let n=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 n?(0,X.jsxs)(`button`,{type:`button`,"data-testid":`acp-chat-tool-file-chip`,onClick:()=>r(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)})}),d.length>0&&(0,X.jsxs)(`button`,{type:`button`,"data-testid":`acp-chat-tool-output-open`,onClick:()=>i?.(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:f}),(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:()=>l(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:a(o?`acpChatToolCard.hideRaw`:`acpChatToolCard.showRaw`)})]}),o&&(0,X.jsxs)(`div`,{className:`mt-1.5 flex flex-col gap-2`,children:[b!==void 0&&(0,X.jsx)($,{label:a(`acpChatToolCard.rawInput`),value:b,testId:`acp-chat-tool-raw-input`}),x!==void 0&&(0,X.jsx)($,{label:a(`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}=_(`chat`),r=t?.find(t=>t.value===e)?.label??e;return(0,X.jsx)(p,{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)(a,{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}=_(`chat`),a=i(e.status),{model:o}=e,c=e.inputTokens!==void 0||e.outputTokens!==void 0,l=ye(g(t=>t.byId[e.acpSessionId]?.events??We)),[u,d]=(0,R.useState)(null),[p,m]=(0,R.useState)(e.acpSessionId);p!==e.acpSessionId&&(m(e.acpSessionId),d(null));let v=(0,R.useCallback)((e,t)=>d({kind:`diff`,toolCallId:e,path:t.path}),[]),y=(0,R.useCallback)(e=>d({kind:`output`,toolCallId:e}),[]),b=(0,R.useCallback)(()=>d(null),[]),x=(0,R.useMemo)(()=>u?l.find(e=>e.kind===`tool`&&e.toolCallId===u.toolCallId)??null:null,[u,l]),S=(0,R.useMemo)(()=>u?.kind!==`diff`||!x?null:Y(G(x.content),x.locations).find(e=>e.path===u.path)??null,[u,x]),C=u?.kind===`diff`?u.path:x?K(x.rawInput)??x.title??`Output`:`Output`,{scrollRef:w,showScrollToLatest:T,scrollToLatest:E}=He((0,R.useMemo)(()=>({blocks:l,status:e.status,completedAt:e.completedAt}),[l,e.status,e.completedAt])),D=!a;return(0,X.jsxs)(`div`,{className:`flex h-full flex-col overflow-hidden rounded-xl bg-[var(--surface-lift)]`,children:[u&&(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:b,title:e.agent,className:`min-w-0 shrink cursor-pointer truncate text-left text-[var(--content-default)] hover:underline`,children:(0,X.jsx)(s,{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)(s,{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:a,onClose:t,showBack:!!u,onBack:b},`header-${e.acpSessionId}`),u?(0,X.jsx)(`div`,{className:`flex-1 overflow-y-auto px-5 py-5`,children:u.kind===`diff`?(0,X.jsx)(ue,{path:u.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:[(c||o!==void 0)&&(0,X.jsxs)(`div`,{className:h(`grid gap-3`,c?`grid-cols-2`:`grid-cols-1`),"data-testid":`acp-run-metrics`,children:[c&&(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`)})]}),o!==void 0&&(0,X.jsx)(`div`,{className:c?`col-span-2`:void 0,children:(0,X.jsx)(Re,{model:o,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:l.map((e,t)=>(0,X.jsx)(De,{showDot:t===0||t===l.length-1||e.kind===`tool`||e.kind===`plan`,isLast:t===l.length-1,children:(0,X.jsx)(Je,{block:e,isTerminal:D,onOpenDiff:v,onOpenOutput:y,assistantId:n})},Ue(e,t)))}),!a&&(0,X.jsx)(Ee,{status:e.status,stopReason:e.stopReason,error:e.error,completedAt:e.completedAt})]}),T&&(0,X.jsx)(f,{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`})]}),a&&!u&&(0,X.jsx)(Ye,{acpSessionId:e.acpSessionId},`steer-${e.acpSessionId}`)]})}function Ke({entry:e,isRunning:n,onClose:r,showBack:i=!1,onBack:a}){let{t:s}=_(`chat`),[c,d]=(0,R.useState)(!1),p=u(e.status,e.stopReason),h=(0,R.useCallback)(()=>{d(!0),l(e.acpSessionId).catch(e=>{d(!1),o(e,{context:`AcpRunChatView.stop`})})},[e.acpSessionId]);return(0,X.jsx)(m,{icon:(0,X.jsxs)(X.Fragment,{children:[i&&(0,X.jsx)(f,{variant:`outlined`,iconOnly:(0,X.jsx)(ne,{}),onClick:a,"aria-label":s(`acpRunChatView.backToConversationAria`),tooltip:s(`acpRunChatView.backTooltip`),"data-testid":`acp-chat-diff-back`,className:`shrink-0`}),(0,X.jsx)(t,{agent:e.agent,className:`h-5 w-5 shrink-0`})]}),title:e.agent,headerTrailing:(0,X.jsx)(fe,{color:p.color,label:p.label}),headerActions:n?(0,X.jsx)(de,{onStop:h,ariaLabel:s(`acpRunChatView.stopRunAria`),disabled:c}):void 0,closeLabel:s(`acpRunChatView.closeRunDetail`),onClose:r})}function qe({task:e}){let{t}=_(`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)(s,{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}=_(`chat`),[n,i]=(0,R.useState)(``),[a,s]=(0,R.useState)(!1);return(0,X.jsx)(`form`,{onSubmit:(0,R.useCallback)(t=>{t.preventDefault();let c=n.trim();if(!c||a)return;s(!0);let l=g.getState().appendLocalMarker({acpSessionId:e,content:`${r}${c}`});d(e,c).then(()=>i(``)).catch(t=>{l&&g.getState().removeLocalMarker({acpSessionId:e,markerId:l}),o(t,{context:`AcpRunChatView.steer`})}).finally(()=>s(!1))},[n,a,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:n,onChange:e=>i(e.target.value),placeholder:t(`acpRunChatView.steerPlaceholder`),disabled:a,"aria-label":t(`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)(f,{type:`submit`,variant:`primary`,size:`compact`,iconOnly:(0,X.jsx)(ae,{}),disabled:a||n.trim()===``,"aria-label":t(`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{DS as t,Hi as n,Ui as r,Wi as i,a,c as o,cx as s,d as c,ru as l,s as u}from"./app-4aEhon_S.js";import{E as d}from"./vendor-CtXGFqsu.js";import{f,r as p,t as m,x as h}from"./react-B9IgSVeK.js";var g=e(h(),1),_=m();function v(){let e=f(),{t:m}=d(`activation`),h=s.use.activeAssistantId(),v=n(),y=i(),{data:b}=r(),{starters:x,items:S}=c(v??``),{launch:C,pendingTaskIds:w}=o(v??``),T=(0,g.useMemo)(()=>[...x,...S],[x,S]),E=(0,g.useCallback)(async t=>{u(await C(t),m,t=>{l(e,t)})},[C,e,m]);return v===null?y?(0,_.jsx)(p,{to:t.assistant,replace:!0}):null:(0,_.jsx)(a,{tasks:T,progress:b?.tasks,pendingTaskIds:w,onLaunch:e=>{E(e)},onOpenConversation:t=>{l(e,t)},assistantId:h??void 0})}export{v as ActivationListRoute};
1
+ import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{DS as t,Hi as n,Ui as r,Wi as i,a,c as o,cx as s,d as c,ru as l,s as u}from"./app-D0NlDYsG.js";import{E as d}from"./vendor-CtXGFqsu.js";import{f,r as p,t as m,x as h}from"./react-B9IgSVeK.js";var g=e(h(),1),_=m();function v(){let e=f(),{t:m}=d(`activation`),h=s.use.activeAssistantId(),v=n(),y=i(),{data:b}=r(),{starters:x,items:S}=c(v??``),{launch:C,pendingTaskIds:w}=o(v??``),T=(0,g.useMemo)(()=>[...x,...S],[x,S]),E=(0,g.useCallback)(async t=>{u(await C(t),m,t=>{l(e,t)})},[C,e,m]);return v===null?y?(0,_.jsx)(p,{to:t.assistant,replace:!0}):null:(0,_.jsx)(a,{tasks:T,progress:b?.tasks,pendingTaskIds:w,onLaunch:e=>{E(e)},onOpenConversation:t=>{l(e,t)},assistantId:h??void 0})}export{v as ActivationListRoute};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{DS as t}from"./app-4aEhon_S.js";import{d as n,f as r,x as i}from"./react-B9IgSVeK.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{DS as t}from"./app-D0NlDYsG.js";import{d as n,f as r,x as i}from"./react-B9IgSVeK.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{$r as t,Ar as n,At as r,Bh as i,Ct as a,Et as o,Ft as s,It as c,Jr as l,Jt as u,Kt as d,Lt as f,Qt as p,Rn as m,Rt as h,St as g,Tn as _,Wn as v,Xr as y,Yr as b,Yt as x,Zr as S,Zt as C,_i as w,_t as T,_u as E,aw as D,dg as O,er as k,fg as A,ir as j,kr as M,rc as N,vt as ee,wr as P,wt as F,wv as I,xt as L,yt as R}from"./app-4aEhon_S.js";import{E as z}from"./vendor-CtXGFqsu.js";import{t as B,x as V}from"./react-B9IgSVeK.js";import{Ki as H,Yn as U}from"./icons-C0wyat6T.js";import{t as W}from"./use-transcript-message-by-id-yY3_Y5YT.js";import{l as G,n as K,o as q,t as J}from"./tool-detail-panel-B58LHS7C.js";import{n as Y,t as X}from"./step-detail-header-ygmZC0KS.js";var Z=e(V(),1),Q=B();function te({assistantId:e,image:t,title:n,ariaLabel:r,onPreview:i}){let a=(0,Z.useRef)(null),{url:o,isError:s,isPending:l}=v(e,t,c(a)||typeof IntersectionObserver>`u`),[u,f]=(0,Z.useState)(null);(0,Z.useEffect)(()=>{f(null)},[t.id,t.previewUrl]);let p=o===u?null:o,m=l?null:{...t,previewUrl:p??null};return(0,Q.jsx)(`div`,{ref:a,"data-testid":`activity-screenshot-tile`,"data-tool-call-id":t.toolCallId,children:(0,Q.jsx)(d,{attachment:m,placeholder:s?null:(0,Q.jsx)(U,{className:`h-6 w-6 animate-spin`,"aria-hidden":`true`}),labels:{title:n,ariaLabel:r,secondary:null},hideCaptions:!0,onPreview:()=>i(a.current?.firstElementChild instanceof HTMLElement?a.current.firstElementChild:null),onPreviewError:()=>f(o)})})}function ne(e,t){return e[t]?.type===`activity`&&t===e.length-1}function re(e,t){let n=t.at(-1);if(!n)return!1;let r=new Set(i(n));return i(e).some(e=>r.has(e))}function ie(e,t,n){if(!n)return e[t]?.type===`activity`?t:null;let r=t=>{let r=e[t];return!r||r.type!==`activity`?!1:b(r.items).toolCalls.some(e=>e.id===n)};if(r(t))return t;let i=e.findIndex((e,t)=>r(t));return i===-1?null:i}function ae(e,t,n){let r=x(t,n.workflow),i=e=>{let t=p(e,n.workflow.byToolUseId);if(t!==null&&r.has(t))return!0;let i=u(e,n.acpByToolUseId);if(i!==null&&n.acpById[i]!==void 0)return!0;let a=C(e);return a!==void 0&&n.backgroundTaskById[a]!==void 0},a=t.filter(e=>!i(e));if(a.length===t.length)return{items:e,toolCalls:t};let o=new Set(a.map(e=>e.id));return{items:e.filter(e=>e.kind!==`toolCall`||o.has(e.toolCall.id)),toolCalls:a}}function oe(e,t,r){let i=W(e),a=M(),o=_(),s=E.use.byId(),c=E.use.byToolUseId(),l=E.use.notFoundRunIds(),u=E.use.hydrationFailedRunIds(),d=P.use.byId(),f=P.use.byToolUseId(),p=n.use.byId();return(0,Z.useMemo)(()=>{if(!i||t==null)return null;let e=y(i.contentBlocks??[],S(i,o)),n=ie(e,t,r);if(n==null)return null;let m=e[n];if(!m||m.type!==`activity`)return null;let{cardItems:h,toolCalls:g}=b(m.items);return{...ae(h,g,{workflow:{byId:s,byToolUseId:c,notFoundRunIds:l,hydrationFailedRunIds:u},acpById:d,acpByToolUseId:f,backgroundTaskById:p}),isLastGroup:ne(e,n),isLatestMessage:re(i,a),groupIndex:n}},[i,a,t,r,o,s,c,l,u,d,f,p])}var se=60;function ce(e,t){return $(e,t.flatMap(e=>e.kind===`tool`?[e.toolCallId]:[]))}function $(e,t,n=h){let r=new Set(t),i=new Set(e.filter(e=>r.has(e.id)&&I(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 o=[],s=new Set;for(let e of t){if(s.has(e))continue;let t=a.get(e);t&&(s.add(e),o.push({image:t,occurrenceKey:e}))}return o}function le({payload:e,onClose:t,assistantId:n}){return(0,Q.jsx)(de,{payload:e,onClose:t,assistantId:n},ue(e))}function ue(e){if(e.messageId!=null){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 de({payload:e,onClose:t,assistantId:n}){let{t:r}=z(`chat`),[i,a]=(0,Z.useState)(null),s=Y(i),c=e.groupToolCallIds?.[0]??e.toolCalls[0]?.id,l=oe(e.messageId,e.groupIndex,c),u=l?.items??e.items,d=l?.toolCalls??e.toolCalls,p=A.use.phase(),h=l?l.isLastGroup&&l.isLatestMessage:e.messageId==null,g=R(u,{active:e.active===!0&&h&&O(p)}),_=(0,Z.useMemo)(()=>u.flatMap(e=>e.kind===`toolCall`?[e.toolCall.id]:[]),[u]),v=(0,Z.useMemo)(()=>f(),[]),y=(0,Z.useMemo)(()=>$(d,_,v),[d,_,v]),b=(0,Z.useMemo)(()=>y.map(e=>e.occurrenceKey),[y]),x=(0,Z.useMemo)(()=>new Map(y.map((e,t)=>[e.occurrenceKey,t])),[y]),S=(0,Z.useMemo)(()=>y.map(e=>e.image),[y]),C=(0,Z.useRef)(null),{openPreview:E,previewModal:M}=m(n,S,b,{scopeKey:`${n??``}:${e.messageId??``}:${c??e.groupIndex??``}`,getFallbackFocus:()=>C.current?.querySelector(`button, [role="button"][tabindex="0"]`)??null}),N=ee(g.state,g.steps),P=N===`loading`,F=T(r,N,g),I=P&&g.currentStepTitle||F,L=(0,Z.useMemo)(()=>new Map(d.map(e=>[e.id,e])),[d]);return(0,Q.jsx)(`div`,{ref:C,className:`contents`,children:(0,Q.jsxs)(k,{icon:i?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(D,{variant:`outlined`,iconOnly:(0,Q.jsx)(H,{}),"aria-label":r(`activityStepsPanel.backAria`),tooltip:r(`activityStepsPanel.backTooltip`),onClick:()=>a(null),className:`shrink-0`}),(0,Q.jsx)(X,{detail:i,source:q})]}):void 0,title:s,titleNode:i?i.kind===`thinking`?void 0:(0,Q.jsx)(K,{detail:i,source:q}):(0,Q.jsx)(j,{title:P?(0,Q.jsx)(w,{children:I}):I,count:g.stepCount}),closeLabel:r(`activityStepsPanel.closeSteps`),onClose:t,children:[i?(0,Q.jsx)(me,{detail:i,assistantId:n}):(0,Q.jsx)(o,{steps:g.steps,timeline:!0,renderStep:t=>(0,Q.jsx)(pe,{step:t,activeDetail:i,onOpenDetail:a,lookupToolCall:e=>L.get(e),messageId:e.messageId,groupIndex:l?.groupIndex??e.groupIndex}),renderPhaseFooter:e=>{let t=fe(e,y,x);if(!t)return null;let{entry:i,step:a,index:o}=t,s=a.activity?.trim(),c=s?r(`activityStepsPanel.screenshotTitle`,{activity:s}):r(`activityStepsPanel.screenshotFallbackTitle`),l=s?r(`activityStepsPanel.screenshotAria`,{activity:s}):r(`activityStepsPanel.screenshotFallbackAria`);return(0,Q.jsx)(te,{assistantId:n,image:i.image,title:c,ariaLabel:l,onPreview:e=>E(i.image,o,e)})}}),M]})})}function fe(e,t,n){if(!r(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 pe({step:e,activeDetail:n,onOpenDetail:r,lookupToolCall:i,messageId:o,groupIndex:c}){let{t:u}=z(`chat`),d=s();if(e.kind===`thinking`){let n=o!=null&&e.thinkingItemIndex!=null?{messageId:o,thinkingGroupIndex:c,thinkingItemIndex:e.thinkingItemIndex}:{};return(0,Q.jsx)(a,{iconName:`brain`,label:N(t(e.text),se),ariaLabel:u(`activityStepsPanel.viewThinkingAria`),active:!1,onClick:()=>r({kind:`thinking`,toolCallId:``,toolName:``,title:u(`thinkingDetail.title`),activity:``,input:{},status:`completed`,thinkingText:e.text,...n})})}if(e.kind===`web_search`)return(0,Q.jsx)(g,{step:e});if(e.kind===`web_search_error`)return(0,Q.jsx)(L,{step:e});if(e.kind!==`tool`)return(0,Q.jsx)(F,{step:e});let f=i(e.toolCallId);return(0,Q.jsx)(a,{iconName:e.iconName,label:d({activity:e.activity,actionDisplayKey:e.actionDisplayKey,fallback:e.activity||e.info||e.title}),active:n?.toolCallId===e.toolCallId,onClick:()=>{f&&r(l(f))}})}function me({detail:e,assistantId:t}){return e.kind===`thinking`?(0,Q.jsx)(G,{detail:e,assistantId:t}):(0,Q.jsx)(J,{detail:e,source:q,assistantId:t})}export{le as ActivityStepsPanel,ce as buildActivityScreenshotGallery};
1
+ import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{$r as t,Ar as n,At as r,Bh as i,Ct as a,Et as o,Ft as s,It as c,Jr as l,Jt as u,Kt as d,Lt as f,Qt as p,Rn as m,Rt as h,St as g,Tn as _,Wn as v,Xr as y,Yr as b,Yt as x,Zr as S,Zt as C,_i as w,_t as T,_u as E,aw as D,dg as O,er as k,fg as A,ir as j,kr as M,rc as N,vt as ee,wr as P,wt as F,wv as I,xt as L,yt as R}from"./app-D0NlDYsG.js";import{E as z}from"./vendor-CtXGFqsu.js";import{t as B,x as V}from"./react-B9IgSVeK.js";import{Ki as H,Yn as U}from"./icons-C0wyat6T.js";import{t as W}from"./use-transcript-message-by-id-ImJNR0ZS.js";import{l as G,n as K,o as q,t as J}from"./tool-detail-panel-BgULoaCP.js";import{n as Y,t as X}from"./step-detail-header-BsK4vZvH.js";var Z=e(V(),1),Q=B();function te({assistantId:e,image:t,title:n,ariaLabel:r,onPreview:i}){let a=(0,Z.useRef)(null),{url:o,isError:s,isPending:l}=v(e,t,c(a)||typeof IntersectionObserver>`u`),[u,f]=(0,Z.useState)(null);(0,Z.useEffect)(()=>{f(null)},[t.id,t.previewUrl]);let p=o===u?null:o,m=l?null:{...t,previewUrl:p??null};return(0,Q.jsx)(`div`,{ref:a,"data-testid":`activity-screenshot-tile`,"data-tool-call-id":t.toolCallId,children:(0,Q.jsx)(d,{attachment:m,placeholder:s?null:(0,Q.jsx)(U,{className:`h-6 w-6 animate-spin`,"aria-hidden":`true`}),labels:{title:n,ariaLabel:r,secondary:null},hideCaptions:!0,onPreview:()=>i(a.current?.firstElementChild instanceof HTMLElement?a.current.firstElementChild:null),onPreviewError:()=>f(o)})})}function ne(e,t){return e[t]?.type===`activity`&&t===e.length-1}function re(e,t){let n=t.at(-1);if(!n)return!1;let r=new Set(i(n));return i(e).some(e=>r.has(e))}function ie(e,t,n){if(!n)return e[t]?.type===`activity`?t:null;let r=t=>{let r=e[t];return!r||r.type!==`activity`?!1:b(r.items).toolCalls.some(e=>e.id===n)};if(r(t))return t;let i=e.findIndex((e,t)=>r(t));return i===-1?null:i}function ae(e,t,n){let r=x(t,n.workflow),i=e=>{let t=p(e,n.workflow.byToolUseId);if(t!==null&&r.has(t))return!0;let i=u(e,n.acpByToolUseId);if(i!==null&&n.acpById[i]!==void 0)return!0;let a=C(e);return a!==void 0&&n.backgroundTaskById[a]!==void 0},a=t.filter(e=>!i(e));if(a.length===t.length)return{items:e,toolCalls:t};let o=new Set(a.map(e=>e.id));return{items:e.filter(e=>e.kind!==`toolCall`||o.has(e.toolCall.id)),toolCalls:a}}function oe(e,t,r){let i=W(e),a=M(),o=_(),s=E.use.byId(),c=E.use.byToolUseId(),l=E.use.notFoundRunIds(),u=E.use.hydrationFailedRunIds(),d=P.use.byId(),f=P.use.byToolUseId(),p=n.use.byId();return(0,Z.useMemo)(()=>{if(!i||t==null)return null;let e=y(i.contentBlocks??[],S(i,o)),n=ie(e,t,r);if(n==null)return null;let m=e[n];if(!m||m.type!==`activity`)return null;let{cardItems:h,toolCalls:g}=b(m.items);return{...ae(h,g,{workflow:{byId:s,byToolUseId:c,notFoundRunIds:l,hydrationFailedRunIds:u},acpById:d,acpByToolUseId:f,backgroundTaskById:p}),isLastGroup:ne(e,n),isLatestMessage:re(i,a),groupIndex:n}},[i,a,t,r,o,s,c,l,u,d,f,p])}var se=60;function ce(e,t){return $(e,t.flatMap(e=>e.kind===`tool`?[e.toolCallId]:[]))}function $(e,t,n=h){let r=new Set(t),i=new Set(e.filter(e=>r.has(e.id)&&I(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 o=[],s=new Set;for(let e of t){if(s.has(e))continue;let t=a.get(e);t&&(s.add(e),o.push({image:t,occurrenceKey:e}))}return o}function le({payload:e,onClose:t,assistantId:n}){return(0,Q.jsx)(de,{payload:e,onClose:t,assistantId:n},ue(e))}function ue(e){if(e.messageId!=null){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 de({payload:e,onClose:t,assistantId:n}){let{t:r}=z(`chat`),[i,a]=(0,Z.useState)(null),s=Y(i),c=e.groupToolCallIds?.[0]??e.toolCalls[0]?.id,l=oe(e.messageId,e.groupIndex,c),u=l?.items??e.items,d=l?.toolCalls??e.toolCalls,p=A.use.phase(),h=l?l.isLastGroup&&l.isLatestMessage:e.messageId==null,g=R(u,{active:e.active===!0&&h&&O(p)}),_=(0,Z.useMemo)(()=>u.flatMap(e=>e.kind===`toolCall`?[e.toolCall.id]:[]),[u]),v=(0,Z.useMemo)(()=>f(),[]),y=(0,Z.useMemo)(()=>$(d,_,v),[d,_,v]),b=(0,Z.useMemo)(()=>y.map(e=>e.occurrenceKey),[y]),x=(0,Z.useMemo)(()=>new Map(y.map((e,t)=>[e.occurrenceKey,t])),[y]),S=(0,Z.useMemo)(()=>y.map(e=>e.image),[y]),C=(0,Z.useRef)(null),{openPreview:E,previewModal:M}=m(n,S,b,{scopeKey:`${n??``}:${e.messageId??``}:${c??e.groupIndex??``}`,getFallbackFocus:()=>C.current?.querySelector(`button, [role="button"][tabindex="0"]`)??null}),N=ee(g.state,g.steps),P=N===`loading`,F=T(r,N,g),I=P&&g.currentStepTitle||F,L=(0,Z.useMemo)(()=>new Map(d.map(e=>[e.id,e])),[d]);return(0,Q.jsx)(`div`,{ref:C,className:`contents`,children:(0,Q.jsxs)(k,{icon:i?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(D,{variant:`outlined`,iconOnly:(0,Q.jsx)(H,{}),"aria-label":r(`activityStepsPanel.backAria`),tooltip:r(`activityStepsPanel.backTooltip`),onClick:()=>a(null),className:`shrink-0`}),(0,Q.jsx)(X,{detail:i,source:q})]}):void 0,title:s,titleNode:i?i.kind===`thinking`?void 0:(0,Q.jsx)(K,{detail:i,source:q}):(0,Q.jsx)(j,{title:P?(0,Q.jsx)(w,{children:I}):I,count:g.stepCount}),closeLabel:r(`activityStepsPanel.closeSteps`),onClose:t,children:[i?(0,Q.jsx)(me,{detail:i,assistantId:n}):(0,Q.jsx)(o,{steps:g.steps,timeline:!0,renderStep:t=>(0,Q.jsx)(pe,{step:t,activeDetail:i,onOpenDetail:a,lookupToolCall:e=>L.get(e),messageId:e.messageId,groupIndex:l?.groupIndex??e.groupIndex}),renderPhaseFooter:e=>{let t=fe(e,y,x);if(!t)return null;let{entry:i,step:a,index:o}=t,s=a.activity?.trim(),c=s?r(`activityStepsPanel.screenshotTitle`,{activity:s}):r(`activityStepsPanel.screenshotFallbackTitle`),l=s?r(`activityStepsPanel.screenshotAria`,{activity:s}):r(`activityStepsPanel.screenshotFallbackAria`);return(0,Q.jsx)(te,{assistantId:n,image:i.image,title:c,ariaLabel:l,onPreview:e=>E(i.image,o,e)})}}),M]})})}function fe(e,t,n){if(!r(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 pe({step:e,activeDetail:n,onOpenDetail:r,lookupToolCall:i,messageId:o,groupIndex:c}){let{t:u}=z(`chat`),d=s();if(e.kind===`thinking`){let n=o!=null&&e.thinkingItemIndex!=null?{messageId:o,thinkingGroupIndex:c,thinkingItemIndex:e.thinkingItemIndex}:{};return(0,Q.jsx)(a,{iconName:`brain`,label:N(t(e.text),se),ariaLabel:u(`activityStepsPanel.viewThinkingAria`),active:!1,onClick:()=>r({kind:`thinking`,toolCallId:``,toolName:``,title:u(`thinkingDetail.title`),activity:``,input:{},status:`completed`,thinkingText:e.text,...n})})}if(e.kind===`web_search`)return(0,Q.jsx)(g,{step:e});if(e.kind===`web_search_error`)return(0,Q.jsx)(L,{step:e});if(e.kind!==`tool`)return(0,Q.jsx)(F,{step:e});let f=i(e.toolCallId);return(0,Q.jsx)(a,{iconName:e.iconName,label:d({activity:e.activity,actionDisplayKey:e.actionDisplayKey,fallback:e.activity||e.info||e.title}),active:n?.toolCallId===e.toolCallId,onClick:()=>{f&&r(l(f))}})}function me({detail:e,assistantId:t}){return e.kind===`thinking`?(0,Q.jsx)(G,{detail:e,assistantId:t}):(0,Q.jsx)(J,{detail:e,source:q,assistantId:t})}export{le as ActivityStepsPanel,ce as buildActivityScreenshotGallery};
@@ -0,0 +1 @@
1
+ import{t as e}from"./add-credits-modal-DckEY84t.js";export{e as AddCreditsModal};
@@ -1 +1 @@
1
- import{o as e}from"./rolldown-runtime-BM3Ffeng.js";import{DS as t,Gd as n,RC as r,SC as i,Sf as a,Ud as o,Xy as s,Yy as c,aw as l,uw as u,vC as d}from"./app-4aEhon_S.js";import{$n as f,E as p,Xn as m}from"./vendor-CtXGFqsu.js";import{_ as h,d as g,n as _,t as v,x as y}from"./react-B9IgSVeK.js";import{Gi as b,Ui as x}from"./icons-C0wyat6T.js";import{n as S}from"./android-billing-handoff-DHmIdr3k.js";import{t as C}from"./checkout-return-target-BMk9sOs5.js";var w=e(y(),1),T=v(),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:v}){let{t:y}=p(),{pathname:S}=g(),[k]=h(),A=k.toString()?`${S}?${k.toString()}`:S,{data:j,isLoading:M}=f(o()),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=m(n());return(0,w.useEffect)(()=>s(()=>{v(!1)}),[v]),a(`deeplink.billingCheckoutComplete`,({flow:e})=>{e===`top_up`&&v(!1)}),(0,T.jsx)(i.Root,{open:e,onOpenChange:v,children:(0,T.jsxs)(i.Content,{size:`sm`,children:[(0,T.jsxs)(i.Header,{children:[(0,T.jsx)(i.Title,{children:y(`addCreditsModal.title`)}),(0,T.jsx)(i.Description,{children:y(`addCreditsModal.description`)})]}),(0,T.jsx)(i.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:y(`addCreditsModal.amount`)}),(0,T.jsx)(d,{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)(_,{to:t.settings.usageBillingConfigureTopUps,className:u(r({tone:`quiet`}),`flex items-center gap-1 text-body-small-default text-[var(--content-tertiary)]`),onClick:()=>v(!1),children:[y(`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)(i.Footer,{children:[(0,T.jsx)(i.Close,{asChild:!0,children:(0,T.jsx)(l,{variant:`outlined`,children:y(`addCreditsModal.cancel`)})}),(0,T.jsx)(l,{variant:`primary`,loading:L.isPending,onClick:()=>{L.isPending||L.mutate({body:{amount:I,return_path:A,return_target:C()}},{onSuccess:e=>{c(e.checkout_url)}})},disabled:L.isPending||M||!j,children:y(`addCreditsModal.continue`)})]})]})})}function A(e){return S({open:e.open,path:t.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{DS as t,Gd as n,RC as r,SC as i,Sf as a,Ud as o,Xy as s,Yy as c,aw as l,uw as u,vC as d}from"./app-D0NlDYsG.js";import{$n as f,E as p,Xn as m}from"./vendor-CtXGFqsu.js";import{_ as h,d as g,n as _,t as v,x as y}from"./react-B9IgSVeK.js";import{Gi as b,Ui as x}from"./icons-C0wyat6T.js";import{n as S}from"./android-billing-handoff-CBj4G7HW.js";import{t as C}from"./checkout-return-target-gl5H9x5u.js";var w=e(y(),1),T=v(),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:v}){let{t:y}=p(),{pathname:S}=g(),[k]=h(),A=k.toString()?`${S}?${k.toString()}`:S,{data:j,isLoading:M}=f(o()),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=m(n());return(0,w.useEffect)(()=>s(()=>{v(!1)}),[v]),a(`deeplink.billingCheckoutComplete`,({flow:e})=>{e===`top_up`&&v(!1)}),(0,T.jsx)(i.Root,{open:e,onOpenChange:v,children:(0,T.jsxs)(i.Content,{size:`sm`,children:[(0,T.jsxs)(i.Header,{children:[(0,T.jsx)(i.Title,{children:y(`addCreditsModal.title`)}),(0,T.jsx)(i.Description,{children:y(`addCreditsModal.description`)})]}),(0,T.jsx)(i.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:y(`addCreditsModal.amount`)}),(0,T.jsx)(d,{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)(_,{to:t.settings.usageBillingConfigureTopUps,className:u(r({tone:`quiet`}),`flex items-center gap-1 text-body-small-default text-[var(--content-tertiary)]`),onClick:()=>v(!1),children:[y(`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)(i.Footer,{children:[(0,T.jsx)(i.Close,{asChild:!0,children:(0,T.jsx)(l,{variant:`outlined`,children:y(`addCreditsModal.cancel`)})}),(0,T.jsx)(l,{variant:`primary`,loading:L.isPending,onClick:()=>{L.isPending||L.mutate({body:{amount:I,return_path:A,return_target:C()}},{onSuccess:e=>{c(e.checkout_url)}})},disabled:L.isPending||M||!j,children:y(`addCreditsModal.continue`)})]})]})})}function A(e){return S({open:e.open,path:t.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,$b as n,$f as r,As as i,Ay as a,BC as o,Bb as s,Bs as c,Cm as l,Cp as u,Dp as d,Ds as f,Ep as p,Ev as m,Fb as h,Fm as g,Fs as _,GC as v,Gb as y,Gs as b,Gy as x,HS as S,Hb as C,Hs as w,IC as T,IS as E,Ib as D,Im as O,Is as k,J as A,JC as j,JS as M,Jb as N,Jm as P,Jp as F,KS as I,Kb as ee,Ks as te,Kv as ne,Lb as L,Lv as re,MC as R,Mb as z,Mo as ie,Ms as ae,NC as oe,Nb as se,No as ce,Ns as le,Og as B,Op as ue,Os as de,PC as V,Pb as fe,Po as pe,Ps as me,Q as he,Qb as ge,Qf as _e,Rb as ve,Rs as ye,SC as H,Sm as be,Sp as xe,Tp as Se,Ub as Ce,Ug as we,Us as Te,Vb as Ee,Vm as De,Wb as Oe,Wg as ke,Ws as Ae,X as je,XS as U,Xb as Me,Xf as Ne,Xi as Pe,Xp as Fe,Xv as Ie,Y as Le,Yb as Re,Yf as ze,Yi as Be,Yp as Ve,Z as He,ZC as Ue,Zb as We,Zf as Ge,Zv as Ke,_h as qe,au as Je,aw as W,ax as Ye,bC as Xe,bh as Ze,dp as Qe,en as $e,ep as et,er as tt,ew as G,ex as nt,fh as rt,fp as it,gh as at,hh as ot,hp as st,it as ct,ix as lt,js as ut,ks as dt,mh as ft,mp as pt,my as mt,np as ht,nr as gt,nt as _t,nx as vt,oC as yt,oh as bt,ot as xt,ox as St,pC as Ct,ph as wt,pn as Tt,pp as Et,q as Dt,qb as Ot,qg as kt,qp as At,rx as jt,sh as Mt,st as Nt,sw as Pt,tp as Ft,tx as It,uS as Lt,uh as Rt,up as zt,vC as K,vh as Bt,wm as Vt,wp as Ht,xC as q,xh as Ut,yh as Wt,zb as Gt,zs as Kt}from"./app-4aEhon_S.js";import{$n as J,E as Y,O as qt,Xn as Jt,j as X,nr as Z}from"./vendor-CtXGFqsu.js";import{b as Yt,t as Xt,x as Zt}from"./react-B9IgSVeK.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-C0wyat6T.js";import{t as cn}from"./ellipsis-vertical-Bg7ccW1x.js";import{i as ln,n as un,r as dn,t as fn}from"./service-form-controls-L7ipWS7W.js";import{o as pn}from"./detail-primitives-DMIwvBhc.js";import{d as mn,o as hn,u as gn}from"./schedules-BZK7XLW4.js";import{t as _n}from"./stt-language-picker-modal-CMFxMa9N.js";var Q=e(Zt(),1);function vn(){let e=_t();return(0,Q.useCallback)(async(t,n)=>{try{let{data:r}=await a({path:{assistant_id:e},body:{value:n,type:`api_key`,name:t},throwOnError:!0});se(r)}catch(e){throw e instanceof Error&&e.message===`No assistant found`?q.error(X(`settings:useDaemonConfig.assistantNotReadyToast`)):q.error(X(`settings:useDaemonConfig.saveApiKeyFailedToast`,{providerName:t})),E(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 we(bn)}var $=Xt(),Sn=`gemini-3.1-flash-image-preview`;function Cn(e,t){return e===`openrouter`?`openrouter`:Ae(t)}function wn(){let{t:e}=Y(`settings`),t=_t(),n=Z(),r=Rt(),{data:i}=J({...xe({path:{assistant_id:t}}),enabled:r,staleTime:3e4}),a=De({onSuccess:e=>{Ht(n,{path:{assistant_id:t}},e)}}),o=vn(),s=i?.services?.[`image-generation`],l=(0,Q.useMemo)(()=>i?s?.mode===`managed`?`vellum`:s?.provider||I(`vellum:ai:imageGenProvider`,`gemini`):I(de,`gemini`),[i,s?.mode,s?.provider]),[d,p]=yn(l),[m,h]=(0,Q.useState)(()=>I(f,Sn)),[g,_]=(0,Q.useState)(null),v=l===`openrouter`&&typeof s?.model==`string`?s.model:void 0,y=g??v??I(`vellum:ai:imageGenModel`,`google/gemini-3.1-flash-image-preview`),b=d===`openrouter`,x=Te(d),S=b?y.trim()||`google/gemini-3.1-flash-image-preview`:x.includes(m)?m:x[0]??Sn,[C,w]=(0,Q.useState)(``),[T,D]=(0,Q.useState)(!1),O=Kt.map(e=>({value:e,label:c[e]??e})),A=(0,Q.useMemo)(()=>Te(d).map(e=>({value:e,label:ye[e]??e})),[d]),j=d===`gemini`||d===`openai`||d===`openrouter`,{hasStoredCredential:M}=Mt({assistantId:t,credentialKind:`api_key`,credentialName:d,enabled:j}),N=(0,Q.useCallback)(e=>{p(e),e===`openrouter`&&g===null&&_(v??`google/gemini-3.1-flash-image-preview`)},[g,v,p]),P=(0,Q.useCallback)(async()=>{D(!0);let r=C.trim(),i=j&&r.length>0;try{await kt(),i&&await o(Cn(d,S),r);let s=d===`vellum`&&!xn()?{mode:`managed`}:{provider:d,mode:d===`vellum`?`managed`:`your-own`};await a.mutateAsync({path:{assistant_id:t},body:{services:{"image-generation":s}}}).catch(t=>{throw q.error(e(`imageGenerationCard.configUpdateFailedToast`)),E(t,{context:`patch_daemon_config`}),t});try{await mt({path:{assistant_id:t},body:{modelId:S},throwOnError:!0})}catch(t){throw q.error(e(`imageGenerationCard.modelUpdateFailedToast`)),E(t,{context:`set_image_gen_model`}),t}finally{n.invalidateQueries({queryKey:u({path:{assistant_id:t}})})}}catch{D(!1);return}D(!1);try{if(U(de,d),U(f,S),i){let e=bt(t,`api_key`,d);n.setQueryData(e,!0),n.invalidateQueries({queryKey:e}),w(``)}q.success(e(`imageGenerationCard.savedToast`))}catch(t){E(t,{context:`settings-ai-image-gen-persist-local`}),q.error(e(`imageGenerationCard.localPreferencesFailedToast`))}},[C,d,j,S,t,a,o,n,e]),F=(0,Q.useCallback)(()=>{if(w(``),d===`openrouter`){_(k),U(f,k);return}h(Sn),U(f,Sn)},[d]),ee=e(d===`openai`?`imageGenerationCard.openaiApiKeyPlaceholder`:d===`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)(K,{"aria-label":e(`imageGenerationCard.providerAriaLabel`),value:d,onChange:N,options:O})]}),d===`vellum`&&(0,$.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:e(`imageGenerationCard.vellumNote`)}),j&&(0,$.jsx)(V,{label:e(`imageGenerationCard.apiKeyLabel`),type:`password`,value:C,onChange:e=>w(e.target.value),placeholder:it(ee,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`)}),b?(0,$.jsx)(V,{"aria-label":e(`imageGenerationCard.modelAriaLabel`),value:y,onChange:e=>_(e.target.value),placeholder:e(`imageGenerationCard.openrouterModelPlaceholder`),fullWidth:!0}):(0,$.jsx)(K,{"aria-label":e(`imageGenerationCard.modelAriaLabel`),value:S,onChange:h,options:A})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(dn,{onClick:P,disabled:T}),T&&(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)(j,{variant:`body-large-default`,as:`h3`,className:`text-[var(--content-secondary)]`,children:e}),t==null?null:(0,$.jsxs)(j,{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)(j,{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}=Y(`settings`),l=e?.scheduleNames??[],u=l.slice(0,Dn),d=l.length-u.length,f=e!=null&&En(e);return(0,$.jsx)(H.Root,{open:e!==null,onOpenChange:e=>{e||o()},children:(0,$.jsxs)(H.Content,{size:`sm`,children:[(0,$.jsx)(H.Header,{children:(0,$.jsx)(H.Title,{children:c(`manageProfilesBlockedDeleteModal.title`)})}),(0,$.jsxs)(H.Body,{className:`space-y-4`,children:[e&&(0,$.jsx)(j,{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)(j,{variant:`body-small-default`,as:`p`,className:`pl-1 text-(--content-tertiary)`,children:c(`manageProfilesBlockedDeleteModal.moreSchedules`,{count:d})})]}),e?.scheduleLookupFailed&&(0,$.jsx)(j,{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)(K,{"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:Le(e),disabled:t,tooltip:t?c(`manageProfilesBlockedDeleteModal.disabledTargetTooltip`):void 0}})})]}),i&&(0,$.jsx)(j,{variant:`body-small-default`,as:`p`,className:`text-(--system-negative-strong)`,children:i})]}),(0,$.jsxs)(H.Footer,{children:[(0,$.jsx)(W,{variant:`ghost`,size:`compact`,onClick:o,children:c(`manageProfilesBlockedDeleteModal.cancel`)}),(0,$.jsx)(W,{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:s,onSetStatus:c,onDelete:l}){let{t:u}=Y(`settings`),d=e.source===`managed`,f=e.status===`disabled`,p=e.label??e.name,m=[];e.name===`auto`&&d?m.push(u(`profileRow.autoRouting`)):e.model&&m.push(_e(e.provider??void 0,e.model,r)),d&&m.push(u(`profileRow.managedByVellum`));let h=e.availability,g=e.config_issue,_=g!=null||h?.status===`incomplete`,v=h?.message??u(`profileRow.providerUnavailableDefault`),y=g==null?h!=null&&h.status!==`ok`?_?u(`profileRow.providerUnavailableFixable`,{message:v}):v:null:u(`profileRow.providerUnavailableFixable`,{message:u(g.code===`over_output_cap`?`profileRow.configIssueOverOutputCap`:g.code===`no_input_room`?`profileRow.configIssueNoInputRoom`:`profileRow.configIssueModelUnknown`)});return(0,$.jsx)(yt,{title:(0,$.jsx)(`span`,{className:f?`opacity-55`:void 0,children:p}),subtitle:m.length>0?m.join(` • `):void 0,onClick:a,showChevron:!1,selected:n,disabled:i,contentAriaLabel:u(`profileRow.openProfileAriaLabel`,{displayName:p}),trailingInteractive:!0,trailing:(0,$.jsxs)($.Fragment,{children:[y==null?null:(0,$.jsx)(Pt,{content:y,children:_?(0,$.jsx)(W,{variant:`ghost`,size:`compact`,iconOnly:(0,$.jsx)(tn,{}),iconOnlyGlyphClassName:`[&_svg]:size-4`,tintColor:`var(--system-mid-strong)`,expandOnMobile:!1,onClick:a,"aria-label":y}):(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":y,role:`img`})})}),f?(0,$.jsx)(o,{tone:`neutral`,children:u(`profileRow.disabledTag`)}):null,t?(0,$.jsx)(o,{tone:`positive`,children:u(`profileRow.defaultTag`)}):null,(0,$.jsxs)(G.Root,{children:[(0,$.jsx)(G.Trigger,{asChild:!0,children:(0,$.jsx)(W,{variant:`ghost`,size:`compact`,iconOnly:(0,$.jsx)(cn,{}),"aria-label":u(`profileRow.actionsAriaLabel`,{displayName:p}),disabled:i})}),(0,$.jsxs)(G.Content,{align:`end`,sideOffset:4,children:[(0,$.jsx)(G.Item,{onSelect:a,children:u(d?`profileRow.view`:`profileRow.edit`)}),!t&&!f&&jt(e.provider,e.model)?(0,$.jsx)(G.Item,{onSelect:s,children:u(`profileRow.makeDefault`)}):null,f?(0,$.jsx)(G.Item,{onSelect:()=>c(!0),children:u(`profileRow.enable`)}):d?null:(0,$.jsx)(G.Item,{onSelect:()=>c(!1),children:u(`profileRow.disable`)}),d?null:(0,$.jsx)(G.Item,{onSelect:l,className:Ue.anchored,children:u(`profileRow.delete`)})]})]})]})})}function Mn(e,t){let n=Be(),{data:r}=J({...At({path:{assistant_id:e}}),enabled:n,staleTime:3e4}),{profiles:i,profileOrder:a}=Tt(t?.llm,e);return(0,Q.useMemo)(()=>r==null?{entries:fe(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 ke(Nn,e)}var Fn=`settings-ai-profile-make-active`,In=`Failed to set the active profile. Please try again.`;function Ln(e){let t=Ne(),n=Z(),r=Pn(e),i=P({onSuccess:()=>{n.invalidateQueries({queryKey:u({path:{assistant_id:e}})}),n.invalidateQueries({queryKey:F({path:{assistant_id:e}})})}});async function a(n,r,i){try{await t.mutateAsync({path:{assistant_id:e},body:{llm:n}})}catch(e){throw E(e,{context:r}),q.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=S(e);throw q.error(t??In),t||E(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=S(e);return t?`${/[.!?]$/.test(t)?t:`${t}.`} ${Rn}`:zn}function Vn(e,n,r){let i=Ln(e),a=Z(),o=t(),s=n?.llm?.activeProfile??null,c=n?.llm?.advisorProfile??null,u=n?.llm?.callSites??{},d=(0,Q.useMemo)(()=>n?.llm?.profiles??{},[n?.llm?.profiles]),f=(0,Q.useMemo)(()=>n?.llm?.profileOrder??[],[n?.llm?.profileOrder]),p=(0,Q.useMemo)(()=>fe(d,f),[d,f]),[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:Dt(t,p,{requireOwnProviderAndModel:o}))}function D(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 O(e){try{await i.deleteProfile(e,f,{isAdvisor:e===c}),r?.onDeleted?.(e)}catch{}}async function k(t){let n=d[t]?.label??t,r=t===s,i=Object.entries(u).filter(([e,n])=>e!==`mainAgent`&&n?.profile===t).map(([e])=>e),o=[],c=0,l=!1;try{let n=(await a.fetchQuery({...be({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){E(e,{context:`settings-ai-profile-delete-schedule-scan`}),l=!0}if(!(r||i.length>0||o.length>0||c>0)&&!l){await O(t);return}let f={name:t,label:n,isActive:r,callSiteIds:i,scheduleNames:o,deferredReminderCount:c,scheduleLookupFailed:l};h(f),y(D(t,En(f))),_(null)}function A(e){n==null||w.current||(w.current=!0,C(e),k(e).finally(()=>{w.current=!1,C(null)}))}async function j(){if(!m||!v)return;if(x(!0),_(null),En(m))try{await hn(e,m.name,v),await a.invalidateQueries({queryKey:l({path:{assistant_id:e}})})}catch(e){E(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),O(n)}return{requestDelete:A,pendingDeleteName:S,blockedDeleteModalProps:{blocked:m,availableReplacements:T(m?.name??null),replacement:v,onReplacementChange:y,error:g,saving:b,onClose:()=>{h(null),_(null)},onConfirm:()=>void j()}}}function Hn(){}function Un({assistantId:e,config:t,connections:n,selectedProfileName:r,onOpenProfile:i,onCreateProfile:a,onProfileDeleted:o}){let{t:s}=Y(`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)(W,{variant:`primary`,onClick:a,leftIcon:(0,$.jsx)(en,{}),disabled:t==null,children:s(`profilesSection.createProfile`)}),children:t==null?(0,$.jsx)(j,{variant:`body-medium-lighter`,as:`p`,className:`py-4 text-center text-(--content-tertiary)`,children:s(`profilesSection.loading`)}):c.length===0?(0,$.jsx)(j,{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,vellum:!0,together:!0,"vercel-ai-gateway":!0,minimax:!0,atlascloud:!0,baseten:!0,poolside:!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===`vellum`)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`?et(n):Ye(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:s,onDelete:c}){let{t:l}=Y(`settings`),u=e.isManaged??!1,d=Bt(e),f=Gn(e.provider),p=Yn(e),m=n&&!t&&f,h=!u&&a!=null,g=!u&&!t,_=m||h||g;return(0,$.jsx)(yt,{title:d,subtitle:p.length>0?p:void 0,onClick:a,showChevron:!1,selected:r,contentAriaLabel:a?l(`providerRow.openProviderAriaLabel`,{displayName:d}):void 0,trailingInteractive:!0,trailing:(0,$.jsxs)($.Fragment,{children:[u?(0,$.jsx)(o,{tone:`neutral`,title:l(`providerRow.managedTagTitle`),children:l(`providerRow.managedTag`)}):null,t?(0,$.jsx)(o,{tone:`info`,title:l(`providerRow.defaultTagTitle`),children:l(`providerRow.defaultTag`)}):null,e.provider===`ollama`?(0,$.jsx)(o,{tone:`neutral`,title:l(`providerRow.localTagTitle`),children:l(`providerRow.localTag`)}):null,e.provider===`openai-compatible`?(0,$.jsx)(o,{tone:`neutral`,title:l(`providerRow.customTagTitle`),children:l(`providerRow.customTag`)}):null,_?(0,$.jsxs)(G.Root,{children:[(0,$.jsx)(G.Trigger,{asChild:!0,children:(0,$.jsx)(W,{variant:`ghost`,size:`compact`,iconOnly:(0,$.jsx)(cn,{}),"aria-label":l(`providerRow.actionsAriaLabel`,{displayName:d})})}),(0,$.jsxs)(G.Content,{align:`end`,sideOffset:4,children:[h?(0,$.jsx)(G.Item,{onSelect:a,children:l(`providerRow.edit`)}):null,m?(0,$.jsx)(G.Item,{disabled:i,onSelect:s,children:l(`providerRow.setAsDefault`)}):null,g?(0,$.jsx)(G.Item,{onSelect:c,className:Ue.anchored,children:l(`providerRow.delete`)}):null]})]}):(0,$.jsx)(`span`,{className:`inline-block w-8`,"aria-hidden":!0})]})})}function Zn(e,t){let n=Z(),r={path:{assistant_id:e}},i=Jt({...ue(),onSuccess:()=>{n.invalidateQueries({queryKey:d(r)}),n.invalidateQueries({queryKey:u(r)}),n.invalidateQueries({queryKey:F(r)})},onError:e=>{E(e,{context:`settings-ai-set-default-provider`}),q.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 s(i){try{let{response:a}=await Ie({path:{assistant_id:e,name:i}});a?.ok||a?.status===404?(n.invalidateQueries({queryKey:Fe(r)}),t?.onDeleted?.(i)):a?.status===409?q.error(X(`settings:useProviderActions.deleteInUseToast`)):q.error(X(`settings:useProviderActions.deleteFailedToast`))}catch(e){E(e,{context:`settings-ai-provider-delete`}),q.error(X(`settings:useProviderActions.deleteFailedToast`))}}return{setDefault:a,isSettingDefault:o,deleteConnection:s}}function Qn({assistantId:e,selectedConnectionName:t,onOpenConnection:r,onAddProvider:i,onConnectionDeleted:a}){let{t:o}=Y(`settings`),{data:s,isLoading:c,isError:l}=J(Ve({path:{assistant_id:e}})),u=Pe(),{data:d}=J({...p({path:{assistant_id:e}}),enabled:u}),f=u?d?.resolvedConnectionName??null:null,m=Zn(e,{onDeleted:a}),h=(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:o(`providersSection.title`),action:(0,$.jsx)(W,{variant:`outlined`,onClick:i,leftIcon:(0,$.jsx)(en,{}),children:o(`providersSection.addProvider`)}),children:c?(0,$.jsx)(`div`,{className:`space-y-2 py-2`,children:[1,2,3].map(e=>(0,$.jsx)(Ct,{className:`h-10 rounded-lg`},e))}):l?(0,$.jsx)(j,{variant:`body-medium-default`,as:`p`,className:`py-4 text-center text-(--system-negative-strong)`,children:o(`providersSection.loadError`)}):h.length===0?(0,$.jsx)(j,{variant:`body-medium-lighter`,as:`p`,className:`py-4 text-center text-(--content-tertiary)`,children:o(`providersSection.empty`)}):h.map(e=>(0,$.jsx)(Xn,{connection:e,isDefault:e.name===f,supportsDefaultProvider:u,selected:e.name===t,isSettingDefault:m.isSettingDefault(e.name),onOpen:e.isManaged??!1?void 0:()=>r(e.name),onSetDefault:()=>m.setDefault(e),onDelete:()=>void m.deleteConnection(e.name)},e.name))})}function $n({panel:e,onOpenPanel:t,onClosePanel:n}){let{t:r}=Y(`settings`),i=_t(),{data:a}=J({...xe({path:{assistant_id:i}}),staleTime:3e4}),o=Pe(),{data:s}=J({...p({path:{assistant_id:i}}),enabled:o}),c=s?.availability,{data:l}=J({...Ve({path:{assistant_id:i}})}),u=l?.connections,d=a?.llm?.callSites??{},f=Object.entries(d).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:[c&&c.status!==`ok`&&(0,$.jsx)(v,{tone:c.status===`unknown`?`warning`:`error`,children:c.message??r(`languageModelCard.defaultProviderUnavailable`)}),i&&(0,$.jsx)(Un,{assistantId:i,config:a,connections:u,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:f,action:(0,$.jsx)(W,{variant:`outlined`,onClick:()=>t({kind:`overrides`}),children:r(`languageModelCard.manage`)})})]})})}function er({children:e}){return(0,$.jsxs)(x,{href:`https://www.vellum.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)(qt,{i18nKey:`managedServicesBanner.body`,ns:`common`,components:{link:(0,$.jsx)(er,{})}})})]})}function nr({assistantId:e,profileName:t,onClose:n}){let{t:i}=Y(`settings`),{data:a}=J({...xe({path:{assistant_id:e}}),staleTime:3e4}),{data:s}=J({...Ve({path:{assistant_id:e}})}),c=s?.connections,l=(0,Q.useMemo)(()=>a?.llm?.profiles??{},[a?.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}=ze(e,{onSaved:n}),h=Ge({mode:f,profileName:t??void 0,initialValues:d,existingNames:u,connections:c,assistantId:e,onSave:p}),g=Vn(e,a,{onDeleted:()=>n()}),_=t!=null&&g.pendingDeleteName===t,v=t!=null&&a!=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)(tt,{title:h.effectiveMode===`create`?i(`profileDetailPanel.createTitle`):d?.label??t??i(`profileDetailPanel.defaultTitle`),closeVariant:`outlined`,onClose:n,headerTrailing:y&&h.effectiveMode!==`create`?(0,$.jsx)(o,{tone:`neutral`,children:i(`profileDetailPanel.managedTag`)}):null,headerActions:h.effectiveMode!==`create`&&!h.isReadOnly?(0,$.jsx)(W,{variant:`dangerOutline`,loading:_,iconOnly:(0,$.jsx)(Qt,{}),"aria-label":i(_?`profileDetailPanel.deleting`:`profileDetailPanel.delete`),tooltip:i(`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)(W,{variant:`outlined`,onClick:h.switchToSaveAsNew,disabled:h.saving,children:i(`profileDetailPanel.saveAsNew`)}),h.hasViewModeChanges?(0,$.jsx)(W,{variant:`primary`,onClick:()=>void h.handleSave(),disabled:h.saving,children:h.saving?i(`profileDetailPanel.saving`):i(`profileDetailPanel.save`)}):null]}):(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(W,{variant:`primary`,onClick:()=>void h.handleSave(),disabled:h.isInvalid||h.saving,children:h.saving?i(`profileDetailPanel.saving`):h.effectiveMode===`create`?i(`profileDetailPanel.create`):i(`profileDetailPanel.saveChanges`)})}),children:(0,$.jsx)(r,{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}=Y(`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)(K,{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:c}=Y(`settings`),l=Ne(),u=t(),d=(0,Q.useMemo)(()=>({requireOwnProviderAndModel:u,requireTextGeneration:!1}),[u]),f=(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]),p=(0,Q.useMemo)(()=>{let e=new Set(Array.from(f.values(),e=>e.profile));return a.filter(t=>e.has(t.name))},[a,f]),[m,h]=(0,Q.useState)(()=>p[0]?.name??``),[g,_]=(0,Q.useState)(``),[y,b]=(0,Q.useState)(new Set),[x,C]=(0,Q.useState)(!1),w=(0,Q.useMemo)(()=>{let e=new Map(r.map(e=>[e.id,e.displayName]));return t=>e.get(t)??t},[r]),T=(0,Q.useMemo)(()=>n.filter(e=>f.get(e.id)?.profile===m),[n,f,m]),D=(0,Q.useMemo)(()=>T.map(e=>e.id).filter(e=>!y.has(e)),[T,y]),O=(0,Q.useMemo)(()=>p.map(e=>({value:e.name,label:Le(e)})),[p]),k=(0,Q.useMemo)(()=>he(a,[],d).filter(e=>e.name!==m).map(e=>({value:e.name,label:Le(e)})),[a,m,d]),A=L(a,m),M=L(a,g),N=y.size===0;function P(e){h(e),b(new Set),e===g&&_(``)}function F(e,t){b(n=>{let r=new Set(n);return t?r.delete(e):r.add(e),r})}async function I(){if(!(!m||!g||D.length===0)){C(!0);try{let t={};for(let e of D)t[e]={profile:g};await l.mutateAsync({path:{assistant_id:e},body:{llm:{callSites:t}}}),q.success(c(`bulkOverrideSwapModal.successToast`,{count:D.length,targetLabel:M})),s(),o()}catch(e){let t=S(e);q.error(t??c(`bulkOverrideSwapModal.updateFailedToast`)),t||E(e,{context:`settings-ai-bulk-override-swap`})}finally{C(!1)}}}return(0,$.jsx)(H.Root,{open:!0,onOpenChange:e=>{e||o()},children:(0,$.jsxs)(H.Content,{size:`md`,children:[(0,$.jsx)(H.Header,{children:(0,$.jsx)(H.Title,{children:c(`bulkOverrideSwapModal.title`)})}),(0,$.jsxs)(H.Body,{className:`space-y-4`,children:[(0,$.jsx)(j,{variant:`body-medium-default`,as:`p`,children:c(`bulkOverrideSwapModal.intro`)}),(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,$.jsx)(K,{id:`bulk-swap-source`,label:c(`bulkOverrideSwapModal.currentlyUsingLabel`),value:m,onChange:P,options:O}),(0,$.jsx)(K,{id:`bulk-swap-target`,label:c(`bulkOverrideSwapModal.changeToLabel`),value:g,onChange:_,options:k,placeholder:c(`bulkOverrideSwapModal.targetPlaceholder`)})]}),(0,$.jsx)(v,{tone:`info`,title:c(`bulkOverrideSwapModal.noticeTitle`),children:c(`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)(j,{variant:`body-medium-default`,as:`p`,children:c(`bulkOverrideSwapModal.affectedSummary`,{count:T.length,profile:A})}),(0,$.jsx)(j,{variant:`body-small-default`,as:`p`,className:`text-[color:var(--content-secondary)]`,children:c(`bulkOverrideSwapModal.chooseActions`)})]}),(0,$.jsx)(W,{variant:`ghost`,onClick:()=>b(N?new Set(T.map(e=>e.id)):new Set),children:c(N?`bulkOverrideSwapModal.clearAll`:`bulkOverrideSwapModal.selectAll`)})]}),(0,$.jsx)(`div`,{className:`max-h-72 space-y-1 overflow-y-auto`,children:T.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)(R,{checked:!y.has(e.id),onCheckedChange:t=>F(e.id,t===!0),disabled:x,label:e.displayName,helperText:w(e.domain)}),(0,$.jsx)(`span`,{className:`shrink-0 text-body-small-default text-[color:var(--content-tertiary)]`,children:f.get(e.id)?.via===`override`?c(`bulkOverrideSwapModal.viaOverride`):c(`bulkOverrideSwapModal.viaDefault`)})]},e.id))})]})]}),(0,$.jsxs)(H.Footer,{children:[(0,$.jsx)(j,{variant:`body-small-default`,as:`p`,className:`mr-auto self-center text-[color:var(--content-secondary)]`,children:c(`bulkOverrideSwapModal.willChange`,{count:D.length})}),(0,$.jsx)(W,{variant:`ghost`,onClick:o,disabled:x,children:c(`bulkOverrideSwapModal.cancel`)}),(0,$.jsx)(W,{variant:`primary`,loading:x,disabled:!m||!g||D.length===0||x,onClick:()=>void I(),children:c(`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}=Y(`settings`),u=vt({hostedInference:ht.use.vellumHostedInference()}),d=ar(i),f=!i||!d?``:i.provider||i.model?ir:i.profile??``,p=f===ir,m=ft(),h=rt(),g=(o??[]).some(e=>e.provider===We),_=[...ge,...g?[We]:[]],v=m[0]??ge[0],y=i?.provider,b=nt(y)?y:y===`chatgpt`?We:void 0,x=b!==void 0&&_.some(e=>e===b),S=b??v,C=Ft(S,``,(o??[]).filter(e=>wt(e.provider,S)))?et(S):St(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=Ye(S).find(e=>e.id===T)?.displayName??T;w.push({value:T,label:l(`callSiteOverridesRow.unavailableOption`,{name:e})})}let E=!!i?.provider&&!i?.model,D=[..._.map(e=>({value:e,label:It[e]??e,...h(e)})),...b&&!x?[{value:b,label:l(`callSiteOverridesRow.unavailableOption`,{name:It[b]??b})}]:[]];function O(t){t===`__custom__`?s(e,{profile:null,provider:v,model:lt(v)??``}):t===``?s(e,null):s(e,{profile:t,provider:null,model:null})}function k(t){let n=lt(t)??``;s(e,{...i??{},profile:null,provider:t,model:n})}function A(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)(oe,{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)(K,{value:f,onChange:O,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)(K,{value:S??``,onChange:k,options:D})]}),(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)(K,{value:i?.model??``,onChange:A,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}=Y(`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}=Y(`settings`),{data:i}=J({...xe({path:{assistant_id:e}}),staleTime:3e4}),a=(0,Q.useMemo)(()=>i?.llm?.profiles??{},[i?.llm?.profiles]),o=(0,Q.useMemo)(()=>i?.llm?.profileOrder??[],[i?.llm?.profileOrder]),s=(0,Q.useMemo)(()=>i?.llm?.callSites??{},[i?.llm?.callSites]),c=(0,Q.useMemo)(()=>fe(a,o),[a,o]),l=ft(),u=t(),d=(0,Q.useMemo)(()=>({requireOwnProviderAndModel:u}),[u]),f=(0,Q.useMemo)(()=>({requireOwnProviderAndModel:u,requireTextGeneration:!1}),[u]),p=Ne(),[m,h]=(0,Q.useState)(``),[g,_]=(0,Q.useState)(!1),[y,b]=(0,Q.useState)(!1),[x,S]=(0,Q.useState)(!1),{data:C,isLoading:w,isError:T,refetch:D}=J({...Se({path:{assistant_id:e}}),enabled:!!e,staleTime:6e4,refetchOnWindowFocus:!1}),{data:O}=J({...Ve({path:{assistant_id:e}}),enabled:!!e}),k=(0,Q.useMemo)(()=>(C?.callSites??[]).filter(e=>e.id!==`mainAgent`),[C]),j=!w&&!T&&!!C,M=!!i,N=j&&M,P=(0,Q.useMemo)(()=>k.map(e=>e.id),[k]),F=i?.llm?.advisorProfile??``,{drafts:I,advisorProfile:ee,advisorDirty:te,callSiteDraftsDirty:ne,hasUnsavedDrafts:re,hasValidationError:R,setDraft:z,setAdvisor:ie,clearEdits:ae,buildSavePatch:oe,buildResetPatch:se}=pr({catalogCallSiteIds:P,persistedOverrides:s,persistedAdvisor:F,isSeeded:N}),ce=(0,Q.useMemo)(()=>new Set(P),[P]),le=(0,Q.useCallback)(e=>L(c,e),[c]),B=(0,Q.useCallback)((e,t)=>({value:e.name,label:Le(e),...A(e,c,t)===`undispatchable`?{icon:(0,$.jsx)(tn,{className:`h-3.5 w-3.5 text-[var(--system-mid-strong)]`}),tooltip:He(e)}:{}}),[c]),ue=(0,Q.useMemo)(()=>he(c,[F],d).map(e=>B(e,d)),[c,F,B,d]),de=(0,Q.useMemo)(()=>{let e=m.trim().toLowerCase();return e===``||`advisor`.includes(e)||`second opinion`.includes(e)},[m]),pe=(0,Q.useMemo)(()=>k.some(e=>or(e,s[e.id])!==null),[k,s]),me=(0,Q.useMemo)(()=>Object.entries(s).some(([e,t])=>ce.has(e)&&(t?.profile!=null||t?.provider!=null||t?.model!=null)),[s,ce]),_e=(0,Q.useCallback)(e=>[...he(c,[e],f).map(e=>B(e,f)),{value:ir,label:r(`overridesDetailPanel.customProfileOption`)}],[c,B,f,r]),ve=(0,Q.useMemo)(()=>{if(!m.trim())return k;let e=m.toLowerCase();return k.filter(t=>(t.displayName??``).toLowerCase().includes(e)||(t.description??``).toLowerCase().includes(e)||(t.domain??``).toLowerCase().includes(e))},[k,m]),ye=(0,Q.useMemo)(()=>{if(!C)return[];let e=C.domains.map(e=>e.id),t=new Map(C.domains.map(e=>[e.id,e])),n=[];for(let r of e){let e=ve.filter(e=>e.domain===r);e.length>0&&n.push({domain:t.get(r),sites:e})}let i=new Set(e),a=ve.filter(e=>!i.has(e.domain));return a.length>0&&n.push({domain:{id:`other`,displayName:r(`overridesDetailPanel.otherDomain`)},sites:a}),n},[C,ve,r]),H=(0,Q.useCallback)((e,t)=>{if(!t){z(e,null);return}let n=je(c,k.find(t=>t.id===e)?.defaultProfile,f);if(n)z(e,{profile:n});else{let t=l[0]??ge[0];z(e,{provider:t,model:lt(t)??``})}},[k,c,l,z,f]),be=(0,Q.useCallback)(async()=>{_(!0);try{let t=oe();await p.mutateAsync({path:{assistant_id:e},body:{llm:{...ne?{callSites:t}:{},...te?{advisorProfile:ee}:{}}}}),n(),q.success(r(`overridesDetailPanel.overridesSavedToast`))}catch(e){q.error(r(`overridesDetailPanel.saveFailedToast`)),E(e,{context:`call_site_overrides_save`})}finally{_(!1)}},[oe,ne,te,ee,n,p,e,r]),Ce=(0,Q.useCallback)(async()=>{_(!0);try{let t=se();await p.mutateAsync({path:{assistant_id:e},body:{llm:{callSites:t}}}),n(),q.success(r(`overridesDetailPanel.overridesResetToast`))}catch(e){q.error(r(`overridesDetailPanel.resetFailedToast`)),E(e,{context:`call_site_overrides_reset`})}finally{_(!1)}},[se,n,p,e,r]),we=(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[me&&(0,$.jsx)(W,{variant:`outlined`,onClick:()=>b(!0),disabled:g||!N,tintColor:`var(--system-negative-strong)`,className:`mr-auto`,children:r(`overridesDetailPanel.resetToDefaults`)}),(0,$.jsx)(W,{variant:`primary`,onClick:()=>void be(),loading:g,disabled:!re||R||g,children:r(`overridesDetailPanel.save`)})]});return(0,$.jsxs)(tt,{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:m,onChange:e=>h(e.target.value),placeholder:r(`overridesDetailPanel.searchPlaceholder`),leftIcon:(0,$.jsx)(sn,{className:`h-4 w-4`}),fullWidth:!0})}),(0,$.jsx)(W,{variant:`outlined`,onClick:()=>S(!0),disabled:!N||g||re||!pe,title:re?r(`overridesDetailPanel.bulkChangeUnsavedTitle`):pe?void 0:r(`overridesDetailPanel.bulkChangeNoCandidatesTitle`),children:r(`overridesDetailPanel.bulkChange`)})]}),M&&de&&(0,$.jsxs)(`div`,{children:[(0,$.jsx)(pn,{children:r(`overridesDetailPanel.advisorSection`)}),(0,$.jsx)(rr,{value:ee,profileOptions:ue,disabled:g,onChange:ie})]}),w&&(0,$.jsx)(gt,{placement:`panel`}),T&&(0,$.jsx)(v,{tone:`error`,title:r(`overridesDetailPanel.loadErrorTitle`),actions:(0,$.jsx)(W,{variant:`outlined`,onClick:()=>void D(),children:r(`overridesDetailPanel.retry`)}),children:r(`overridesDetailPanel.loadErrorHint`)}),!w&&!T&&C&&(0,$.jsx)(ur,{groups:ye,drafts:I,buildProfileOptionsForRow:_e,profileLabelFor:le,advisorMatchesSearch:de,connections:O?.connections,onDraftChange:z,onToggle:H})]})]}),x&&C&&(0,$.jsx)(cr,{assistantId:e,callSites:k,domains:C.domains,persistedOverrides:s,orderedProfiles:c,onClose:()=>S(!1),onApplied:ae}),(0,$.jsx)(Xe,{open:y,title:r(`overridesDetailPanel.resetToDefaults`),message:r(`overridesDetailPanel.resetConfirmMessage`),confirmLabel:r(`overridesDetailPanel.resetToDefaults`),destructive:!0,onConfirm:()=>{b(!1),Ce()},onCancel:()=>b(!1)})]})}var hr=e(Yt(),1);function gr({mode:e,connection:t,assistantId:n,existingNames:r,connections:i,variant:o=`modal`,actionsSlot:s,onSave:c,onCancel:l}){let{t:u}=Y(`settings`),[d,f]=(0,Q.useState)(t?.label??``),p=t?.name??``,h=t?.provider??`anthropic`,g=t?.auth.type??`api_key`,[_,v]=(0,Q.useState)(()=>t?.auth.type===`api_key`?t.auth.credential:t?``:`credential/anthropic/api_key`),[y,b]=(0,Q.useState)(t?.baseUrl??``),[x,S]=(0,Q.useState)(()=>t?.models?t.models.map(e=>e.id).join(`, `):``),[C,w]=(0,Q.useState)(!1),[T,E]=(0,Q.useState)(null),D=h===`openai-compatible`,O=qe(h),k=Wt(h),[A,M]=(0,Q.useState)(``),[N,P]=(0,Q.useState)(!1),F=Z(),I=(0,Q.useMemo)(()=>at(_),[_]),ee=g===`api_key`&&I!==null,{hasStoredCredential:te,isLoading:ne}=Mt({assistantId:n,credentialKind:`credential`,credentialName:I?`${I.service}:${I.field}`:``,enabled:ee}),{credentials:L}=Qe({assistantId:n,enabled:g===`api_key`});(0,Q.useEffect)(()=>{let e=t?.provider??`anthropic`;f(t?.label??``),t?.auth.type===`api_key`?v(t.auth.credential):v(t?``:`credential/${e}/api_key`),E(null),b(t?.baseUrl??``),S(t?.models?t.models.map(e=>e.id).join(`, `):``),M(``),P(!1)},[t]);let re=d.trim()!==(t?.label??``).trim(),R=D&&re?st(d,i,t?.name):null,z=p.trim().length>0&&R===null;async function ie(){if(z){w(!0),E(null);try{let e;if(g===`api_key`){let t=_.trim()||`credential/${h}/api_key`,r=A.trim();if(r){P(!0);try{let e=at(t);await a({path:{assistant_id:n},body:e?{type:`credential`,name:`${e.service}:${e.field}`,value:r}:{type:`api_key`,name:h,value:r},throwOnError:!0});let i=bt(n,`credential`,e?`${e.service}:${e.field}`:``);F.setQueryData(i,!0),F.invalidateQueries({queryKey:Vt({path:{assistant_id:n}})})}catch{E(u(`providerEditorContent.failedSaveApiKey`));return}finally{P(!1)}}e={type:`api_key`,credential:t}}else if(t)e=t.auth;else{E(u(`providerEditorContent.nothingToEdit`));return}let r=d.trim()||null,i={auth:e,label:r,...O&&{base_url:y.trim()||null},...k&&{models:x.trim()?x.split(`,`).map(e=>({id:e.trim()})).filter(e=>e.id):null}},{data:o,error:s,response:l}=await Ke({path:{assistant_id:n,name:t?.name??p.trim()},body:i});if(!l?.ok){E(Ze(l?.status,s)??ot(l?.status));return}if(!o){E(u(`providerEditorContent.emptyServerResponse`));return}Ut(o,u),c(o)}catch{E(u(`providerEditorContent.failedSaveProvider`))}finally{w(!1)}}}let ae=L.filter(e=>e.service===h),oe=e!==`create`&&t?.auth.type===`api_key`,se=ae.length>0||oe,ce=it(u(`providerEditorContent.apiKeyPlaceholder`),te);if(e===`create`)return(0,$.jsx)(zt,{variant:o===`panel`?`inline`:`modal`,actionsSlot:s,assistantId:n,existingNames:r,connections:i,defaultProviderType:h,onCreated:c,onCancel:l});let le=(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)(qt,{i18nKey:`providerEditorContent.displayNameLabel`,ns:`settings`,components:{optional:(0,$.jsx)(`span`,{className:`text-[var(--content-disabled)]`})}})}),(0,$.jsx)(V,{value:d,onChange:e=>f(e.target.value),placeholder:u(`providerEditorContent.displayNamePlaceholder`),fullWidth:!0}),R?(0,$.jsx)(j,{variant:`body-small-default`,as:`p`,className:`text-(--system-negative-strong)`,children:pt[R]}):null]}),O&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:u(`providerEditorContent.baseUrlLabel`)}),(0,$.jsx)(V,{value:y,onChange:e=>b(e.target.value),placeholder:u(h===`ollama`?`providerEditorContent.baseUrlPlaceholderOllama`:h===`opencode`?`providerEditorContent.baseUrlPlaceholderOpencode`:`providerEditorContent.baseUrlPlaceholder`),fullWidth:!0}),h===`ollama`?(0,$.jsx)(j,{variant:`body-small-default`,as:`p`,className:`text-[var(--content-tertiary)]`,children:u(`providerEditorContent.baseUrlHintOllama`)}):null,h===`opencode`?(0,$.jsx)(j,{variant:`body-small-default`,as:`p`,className:`text-[var(--content-tertiary)]`,children:u(`providerEditorContent.baseUrlHintOpencode`)}):null]}),k&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:u(`providerEditorContent.modelsLabel`)}),(0,$.jsx)(V,{value:x,onChange:e=>S(e.target.value),placeholder:u(`providerEditorContent.modelsPlaceholder`),fullWidth:!0}),(0,$.jsx)(j,{variant:`body-small-default`,as:`p`,className:`text-[var(--content-tertiary)]`,children:u(`providerEditorContent.modelsHint`)})]}),g===`api_key`&&(0,$.jsx)(Et,{apiKeyValue:A,onApiKeyChange:M,credential:_,onCredentialChange:v,isLoadingCredential:ne,apiKeyPlaceholder:ce,provider:h,providerCredentials:ae,showAdvancedSection:se,onError:E}),g===`oauth_subscription`&&(0,$.jsx)(m,{assistantId:n,onConnected:c}),T&&(0,$.jsx)(j,{variant:`body-small-default`,as:`p`,className:`text-(--system-negative-strong)`,children:T})]}),B=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(W,{variant:`ghost`,onClick:l,children:u(`providerEditorContent.cancel`)}),(0,$.jsx)(W,{variant:`primary`,disabled:!z||C||N,onClick:()=>void ie(),children:u(C?`providerEditorContent.saving`:`providerEditorContent.saveChanges`)})]});return o===`panel`?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[le,s===void 0?(0,$.jsx)(`div`,{className:`flex justify-end gap-2`,children:B}):s&&(0,hr.createPortal)(B,s)]}):(0,$.jsxs)(H.Content,{size:`md`,children:[(0,$.jsxs)(H.Header,{children:[(0,$.jsx)(H.Title,{children:u(`providerEditorContent.editProviderTitle`)}),(0,$.jsx)(H.Description,{children:t?u(`providerEditorContent.editingConnection`,{name:Bt(t)}):u(`providerEditorContent.editProviderSettingsFallback`)})]}),(0,$.jsx)(H.Body,{children:le}),(0,$.jsx)(H.Footer,{children:B})]})}function _r({assistantId:e,connectionName:t,onClose:n}){let{t:r}=Y(`settings`),i=Z(),[a,o]=(0,Q.useState)(null),{data:s,isLoading:c}=J(Ve({path:{assistant_id:e}})),l=(0,Q.useMemo)(()=>s?.connections??[],[s]),u=(0,Q.useMemo)(()=>t==null?void 0:l.find(e=>e.name===t),[t,l]),f=t!=null&&s!=null&&u==null;(0,Q.useEffect)(()=>{f&&n()},[f,n]);function p(){i.invalidateQueries({queryKey:Fe({path:{assistant_id:e}})}),i.invalidateQueries({queryKey:d({path:{assistant_id:e}})}),n()}return(0,$.jsx)(tt,{title:u?Bt(u):r(`providerDetailPanel.addProviderTitle`),closeVariant:`outlined`,onClose:n,footer:(0,$.jsx)(`div`,{ref:o,className:`flex justify-end gap-2`}),children:t!=null&&c?(0,$.jsx)(gt,{placement:`panel`}):t==null||u!=null?(0,$.jsx)(gr,{mode:u?`edit`:`create`,connection:u,variant:`panel`,actionsSlot:a,assistantId:e,existingNames:l.map(e=>e.name),connections:l,onSave:p,onCancel:n}):null})}var vr={vellum:{provider:`vellum`},deepgram:{provider:`deepgram`,credentialService:`deepgram`},openai:{provider:`openai-whisper`,credentialService:`openai`}},yr={vellum:`vellum`,deepgram:`deepgram`,"openai-whisper":`openai`},br=`deepgram`;function xr({assistantId:e,hideSaveButton:t=!1,hideCredentialsGuide:n=!1,onSaveStateChange:r}={}){let a=_t(),o=e??a,s=Rt(),c=Z(),{t:l}=Y(),d=(0,Q.useMemo)(()=>b(B(),{displayName:l(`sttProviderForm.windowsNativeDisplayName`),subtitle:l(`sttProviderForm.windowsNativeSubtitle`),setupWarning:l(`sttProviderForm.windowsNativeSetupWarning`)}).filter(e=>!e.requiresNativeDictation||te()),[l]),f=br,{data:p}=J({...xe({path:{assistant_id:o}}),enabled:s,staleTime:3e4}),m=p?.services?.stt,h=m?.mode===`managed`?`vellum`:m?.provider,g=(0,Q.useMemo)(()=>{let e=h?yr[h]:void 0;if(e&&d.some(t=>t.id===e))return e;let t=I(i,f);return d.some(e=>e.id===t)?t:f},[h,d,f]),_=!!h,[v,y]=yn(g),{available:x,currentCode:S,configuredProviderId:C,selectLanguage:w,selecting:T}=ct(o),[E,D]=(0,Q.useState)(!1),O=x&&v===g&&(vr[v]?.provider===C||!!h&&!yr[h]),[k,A]=(0,Q.useState)(``),[j,M]=(0,Q.useState)(!1),[N,P]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{let e=I(i,f);e===`macos-native`&&!d.some(t=>t.id===e)&&U(i,f)},[d,f]);let F=(0,Q.useMemo)(()=>d.find(e=>e.id===v)??d[0],[d,v]),ee=F.apiKeyPlaceholder!==void 0;(0,Q.useEffect)(()=>{M(I(dt+v,``).length>0),A(``)},[v]);let L=(0,Q.useMemo)(()=>{let e=v!==g,t=k.trim().length>0;return e||t},[v,g,k]),R=(0,Q.useCallback)(async()=>{let e=k.trim();U(i,v),e.length>0&&U(dt+v,e);let t=vr[v];P(!0);try{if(t?.credentialService){let n=e.length>0?e:I(dt+v,``);if(n.length>0){let{response:e}=await ne({path:{assistant_id:o},body:{service:t.credentialService,field:`api_key`,value:n,label:`${F.displayName} API Key`},throwOnError:!1});if(!e?.ok)throw Error(`Failed to store API key (HTTP ${e?.status??`?`})`)}}if(t&&(v!==g||!_)||h===`vellum`&&v!==`vellum`){let e=t?.provider??br,{response:n}=await re({path:{assistant_id:o},body:{services:{stt:{provider:e,mode:e===`vellum`?`managed`:`your-own`}}},throwOnError:!1});if(!n?.ok)throw Error(`Failed to save configuration (HTTP ${n?.status??`?`})`)}return e.length>0&&M(!0),A(``),c.invalidateQueries({queryKey:u({path:{assistant_id:o}})}),q.success(l(`sttProviderForm.saveSuccess`)),!0}catch(e){return q.error(e instanceof Error?e.message:l(`sttProviderForm.saveFailed`)),!1}finally{P(!1)}},[o,v,k,F,g,_,h,c,l]);(0,Q.useEffect)(()=>{r?.({hasChanges:L,saving:N,save:R})},[r,L,N,R]);let z=(0,Q.useCallback)(()=>{U(dt+v,``),M(!1),A(``)},[v]),ie=j?l(`sttProviderForm.apiKeyPlaceholderReplace`):F.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:l(`sttProviderForm.providerLabel`)}),(0,$.jsx)(K,{value:v,onChange:y,options:d.map(e=>({value:e.id,label:e.displayName})),"aria-label":l(`sttProviderForm.providerAriaLabel`)})]}),O&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:l(`sttProviderForm.spokenLanguage`)}),(0,$.jsx)(Nt,{"aria-label":l(`sttProviderForm.spokenLanguage`),"aria-haspopup":`dialog`,onClick:()=>D(!0),value:xt(S,C)}),(0,$.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:l(`sttProviderForm.spokenLanguageApplies`)}),(0,$.jsx)(_n,{open:E,onOpenChange:D,title:l(`sttProviderForm.spokenLanguage`),currentCode:S,configuredProviderId:C,selectLanguage:w,selecting:T})]}),ee&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:l(`sttProviderForm.apiKeyLabel`)}),(0,$.jsx)(V,{type:`password`,value:k,onChange:e=>A(e.target.value),placeholder:ie,fullWidth:!0})]}),F.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:F.setupWarning})]}),!n&&F.credentialsGuide&&(0,$.jsx)(fn,{guide:F.credentialsGuide}),v===`vellum`&&(0,$.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:l(`sttProviderForm.vellumTranscription`)}),(!t||j)&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!t&&(0,$.jsx)(dn,{onClick:R,disabled:!L||N}),j&&(0,$.jsx)(un,{onClick:z})]})]})}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}=Y(`settings`),n=Z(),r=Rt(),[i,a]=(0,Q.useState)(null),{data:o}=J({...xe({path:{assistant_id:e}}),enabled:r,staleTime:3e4}),s=o?.services?.stt,c=Cr(s),{data:l}=J({...g({path:{assistant_id:e}}),enabled:r&&c.length>0,staleTime:5*6e4});if(c.length===0)return null;let d=e=>l?.providers?.find(t=>t.id===e)?.displayName??e,f=async r=>{a(r);try{let{response:t}=await re({path:{assistant_id:e},body:{services:{stt:{roles:{[r]:null}}}},throwOnError:!1});if(!t?.ok)throw Error(String(t?.status??``));await n.invalidateQueries({queryKey:u({path:{assistant_id:e}})})}catch{q.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?`${d(e.provider)} · ${e.model}`:d(e.provider)}),(0,$.jsx)(W,{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 f(e.role),children:t(`sttRoleOverrides.clear`)})]},e.role)})})]})}function Tr(){let{t:e}=Y(`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}=Y(),[a,o]=(0,Q.useState)(!1),{voices:s}=ce(e);if(s.length===0)return null;let c=s.find(e=>e.model===t)??s[0];return(0,$.jsxs)(T.Root,{open:a,onOpenChange:o,children:[(0,$.jsx)(T.Trigger,{asChild:!0,children:(0,$.jsx)(Nt,{"aria-label":i(`voicePickerField.ariaLabel`),value:c?ie(c.description):i(`voicePickerField.selectVoice`),className:r})}),(0,$.jsx)(T.Content,{side:`bottom`,align:`start`,className:`w-[var(--radix-popover-trigger-width)] p-1`,children:(0,$.jsx)($e,{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:r}={}){let{t:i}=Y(),a=_t(),o=e??a,s=Lt.use.name()??`your assistant`,c=Rt(),l=Z(),{data:d}=J({...O({path:{assistant_id:o}}),enabled:c,staleTime:1/0}),f=(0,Q.useMemo)(()=>{let e=d?.providers;if(!e)return w;if(e.some(e=>e.id===`vellum`))return e;let t=w.find(e=>e.id===`vellum`);return t?[t,...e]:e},[d]),{data:p}=J({...xe({path:{assistant_id:o}}),enabled:c,staleTime:3e4}),m=p?.services?.tts,h=m?.mode===`managed`?`vellum`:m?.provider,g=`elevenlabs`,_=(0,Q.useMemo)(()=>h??I(`vellum:voice:ttsProvider`,g),[h,g]),v=!!h,[y,b]=yn(_),[x,S]=(0,Q.useState)(``),[C,T]=(0,Q.useState)(``),[E,D]=(0,Q.useState)(``),[k,A]=(0,Q.useState)(!1),[j,M]=(0,Q.useState)(!1),[N,P]=(0,Q.useState)(!1),{voices:F,defaultModel:ee,fetched:te}=pe(o,{enabled:y===`vellum`}),L=m?.providers?.vellum?.model??ee??``,[R,z]=yn(L),ie=F.find(e=>e.model===R)??F[0],[oe,se]=(0,Q.useState)(null),ce=F.some(e=>e.model===L),B=oe??(te&&L!==``&&!ce),ue=(0,Q.useMemo)(()=>f.find(e=>e.id===y)??f[0],[y,f]),de=y===`vellum`&&ue.supportsVoiceSelection&&R.trim()!==``&&R.trim()!==L,fe=(0,Q.useCallback)(e=>{let t=I(ut+e,``),n=I(le+e,``);A(t.length>0),T(n),D(n),S(``)},[]);(0,Q.useEffect)(()=>{fe(y)},[y,fe]);let me=(0,Q.useMemo)(()=>{let e=y!==_,t=x.trim().length>0,n=C.trim()!==E;return e||t||n||de},[y,_,x,C,E,de]),he=(0,Q.useCallback)(async()=>{let e=x.trim(),t=C.trim(),n=ue.id;U(ae,n),e.length>0&&U(ut+n,e),U(le+n,t);let r=e.length>0?e:I(ut+n,``),a=jr[n];P(!0);try{if(r.length>0){let{response:e}=await ne({path:{assistant_id:o},body:{service:n,field:`api_key`,value:r,label:`${ue.displayName} API Key`},throwOnError:!1});if(!e?.ok)throw Error(`Failed to store API key (HTTP ${e?.status??`?`})`)}let e={...y!==_||!v?{provider:n,mode:n===`vellum`?`managed`:`your-own`}:{},...a?{providers:{[n]:{[a]:t}}}:{},...de?{providers:{vellum:{model:R.trim()}}}:{}};if(Object.keys(e).length>0){let{response:t}=await re({path:{assistant_id:o},body:{services:{tts:e}},throwOnError:!1});if(!t?.ok)throw Error(`Failed to save configuration (HTTP ${t?.status??`?`})`)}return A(r.length>0),D(t),S(``),l.invalidateQueries({queryKey:u({path:{assistant_id:o}})}),q.success(i(`ttsProviderForm.saved`)),!0}catch(e){return q.error(e instanceof Error?e.message:i(`ttsProviderForm.saveFailed`)),!1}finally{P(!1)}},[o,y,R,de,x,C,ue,_,v,l,i]);(0,Q.useEffect)(()=>{r?.({hasChanges:me,saving:N,save:he})},[r,me,N,he]);let ge=(0,Q.useCallback)(()=>{U(ut+y,``),A(!1),S(``)},[y]),_e=(0,Q.useCallback)(async()=>{M(!0);try{let e=I(ut+y,``),t=x.trim(),n=t.length>0?t:e;if(n.length===0){q.error(i(`ttsProviderForm.apiKeyRequired`));return}let r=I(le+y,``),a=C.trim(),o=await Er({provider:y,apiKey:n,voiceId:a.length>0?a:r,text:`Hey! It's ${s}. How does this sound?`});if(o.kind!==`audio`){q.error(o.message);return}let c=URL.createObjectURL(o.blob);try{let e=new Audio(c);await e.play(),await new Promise(t=>{e.onended=()=>t(),e.onerror=()=>t()})}finally{URL.revokeObjectURL(c)}}finally{M(!1)}},[s,x,y,C,i]),ve=k?`•••••••• (Enter a new key to replace)`:ue.apiKeyPlaceholder,ye=y===`vellum`,H=ye&&ue.supportsVoiceSelection,be=(0,$.jsxs)(W,{variant:`link`,size:`compact`,className:`inline-flex h-auto items-center gap-1 px-0 underline [--vbtn-fg:var(--content-tertiary)]`,onClick:()=>{se(!1),F.some(e=>e.model===R)||z(ee||F[0]?.model||``)},children:[(0,$.jsx)(nn,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),i(`ttsProviderForm.chooseFromCatalog`)]}),Se=H&&B&&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:i(`ttsProviderForm.provider`)}),(0,$.jsx)(K,{value:y,onChange:b,options:f.map(e=>({value:e.id,label:e.displayName})),"aria-label":i(`ttsProviderForm.providerAriaLabel`)})]}),!ye&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:i(`ttsProviderForm.apiKey`)}),(0,$.jsx)(V,{type:`password`,value:x,onChange:e=>S(e.target.value),placeholder:ve,fullWidth:!0})]}),H&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:i(`ttsProviderForm.voice`)}),B?(0,$.jsx)(V,{type:`text`,value:R,onChange:e=>z(e.target.value),placeholder:i(`ttsProviderForm.voiceIdPlaceholder`),"aria-label":i(`ttsProviderForm.customVoiceIdAriaLabel`),fullWidth:!0}):ie?(0,$.jsx)(Ar,{assistantId:o,value:R,onChange:z}):te&&(0,$.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:i(`ttsProviderForm.noManagedVoices`)})]}),ue.supportsVoiceSelection&&!ye&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:i(`ttsProviderForm.voiceId`)}),(0,$.jsx)(V,{type:`text`,value:C,onChange:e=>T(e.target.value),placeholder:i(`ttsProviderForm.voiceIdPlaceholder`),fullWidth:!0})]}),!n&&!ye&&(0,$.jsx)(fn,{guide:ue.credentialsGuide}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!ye&&(0,$.jsx)(W,{variant:`outlined`,onClick:_e,disabled:j,children:i(j?`ttsProviderForm.testing`:`ttsProviderForm.test`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[Se,!t&&(0,$.jsx)(dn,{onClick:he,disabled:!me||N}),k&&!ye&&(0,$.jsx)(un,{onClick:ge})]})]})]})}function Nr(){let{t:e}=Y(`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}=Y(`settings`),t=_t(),n=Z(),{data:r}=J({...xe({path:{assistant_id:t}}),staleTime:3e4}),i=De({onSuccess:e=>{Ht(n,{path:{assistant_id:t}},e)}}),a=vn(),o=(0,Q.useMemo)(()=>r?r.services?.[`web-fetch`]?.provider||I(`vellum:ai:webFetchProvider`,Pr):I(me,Pr),[r]),s=(0,Q.useMemo)(()=>r?.services?.[`web-fetch`]?.apiBase??``,[r]),[c,l]=(0,Q.useState)(!1),[u,d]=yn(o),[f,p]=yn(s),[m,g]=(0,Q.useState)(``),_=y.has(u),v=ee.has(u),{hasStoredCredential:b}=Mt({assistantId:t,credentialKind:`api_key`,credentialName:u,enabled:v}),x=m.trim().length>0,S=f.trim(),C=z(u,_&&S.length>0),w=u!==o||_&&S!==s.trim(),T=c||v&&!C&&!b&&!x||!w&&!x,D=it(Me[u]??e(`webFetchCard.apiKeyPlaceholder`),b),O=Ot[u]??``,k=(0,Q.useCallback)(async()=>{l(!0);let r=m.trim(),o=v&&r.length>0;try{o&&await a(u,r),await i.mutateAsync({path:{assistant_id:t},body:{services:{"web-fetch":{provider:u,..._?{apiBase:S}:{}}}}}).catch(t=>{throw q.error(e(`webFetchCard.configUpdateFailedToast`)),E(t,{context:`patch_daemon_config`}),t})}catch{l(!1);return}l(!1);try{if(U(me,u),o){let e=h(u);e&&U(e,r);let i=bt(t,`api_key`,u);n.setQueryData(i,!0),n.invalidateQueries({queryKey:i}),g(``)}q.success(e(`webFetchCard.savedToast`))}catch(t){E(t,{context:`settings-ai-web-fetch-persist-local`}),q.error(e(`webFetchCard.localPreferencesFailedToast`))}},[v,i,a,n,t,m,u,_,S,e]),A=(0,Q.useCallback)(()=>{let e=h(u);e&&M(e),g(``),p(``),d(Pr),U(me,Pr)},[u,d,p]);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)(K,{value:u,onChange:d,options:Re.map(e=>({value:e,label:N[e]??e}))})]}),_&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(V,{label:e(`webFetchCard.apiBaseLabel`),type:`url`,value:f,onChange:e=>p(e.target.value),placeholder:O||e(`webFetchCard.apiBasePlaceholder`),fullWidth:!0}),O?(0,$.jsx)(`p`,{className:`text-body-small-lighter text-[var(--content-tertiary)]`,children:e(`webFetchCard.apiBaseHint`,{defaultBase:O})}):null]}),v&&(0,$.jsx)(V,{label:e(`webFetchCard.apiKeyLabel`),type:`password`,value:m,onChange:e=>g(e.target.value),placeholder:D,fullWidth:!0}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(dn,{onClick:k,disabled:T}),c&&(0,$.jsx)(rn,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`}),v&&(0,$.jsx)(un,{onClick:A,filled:!0})]})]})})}var Ir=`0.10.12`;function Lr(){return we(Ir)}function Rr(){let{t:e}=Y(`settings`),t=_t(),n=Z(),r=Rt(),{data:i}=J({...xe({path:{assistant_id:t}}),enabled:r,staleTime:3e4}),a=De({onSuccess:e=>{Ht(n,{path:{assistant_id:t}},e)}}),o=vn(),c=(0,Q.useMemo)(()=>{if(!i)return I(_,`inference-provider-native`);let e=i.services?.[`web-search`];return(e?.mode===`managed`&&e?.provider!==`inference-provider-native`?`vellum`:e?.provider)||I(`vellum:ai:webSearchProvider`,`inference-provider-native`)},[i]),l=(0,Q.useMemo)(()=>i?.services?.[`web-search`]?.apiBase??``,[i]),[u,d]=(0,Q.useState)(!1),[f,p]=yn(c),[m,h]=yn(l),[g,v]=(0,Q.useState)(``),y=ve.has(f),b=Gt.has(f),x=s.has(f),{hasStoredCredential:S}=Mt({assistantId:t,credentialKind:`api_key`,credentialName:f,enabled:b}),w=g.trim().length>0,T=m.trim(),O=z(f,y&&T.length>0),k=f!==c||y&&T!==l.trim(),A=Ee[f]??``,j=b&&!x&&!O&&!S&&!w,N=y&&A.length===0&&!T,P=u||j||N||!k&&!w,F=it(Oe[f]??e(`webSearchCard.apiKeyPlaceholder`),S),ee=(0,Q.useCallback)(async()=>{d(!0);let r=g.trim(),i=D(f),s=b&&r.length>0;try{s&&await o(f,r),await kt();let n=f===`vellum`?Lr()?{provider:`vellum`,mode:`managed`}:{mode:`managed`}:{provider:f,mode:`your-own`,...y?{apiBase:T}:{}};await a.mutateAsync({path:{assistant_id:t},body:{services:{"web-search":n}}}).catch(t=>{throw q.error(e(`webSearchCard.configUpdateFailedToast`)),E(t,{context:`patch_daemon_config`}),t})}catch{d(!1);return}d(!1);try{if(U(_,f),s){i&&U(i,r);let e=bt(t,`api_key`,f);n.setQueryData(e,!0),n.invalidateQueries({queryKey:e}),v(``)}q.success(e(`webSearchCard.savedToast`))}catch(t){E(t,{context:`settings-ai-web-search-persist-local`}),q.error(e(`webSearchCard.localPreferencesFailedToast`))}},[b,a,o,n,t,g,f,y,T,e]),te=(0,Q.useCallback)(()=>{let e=D(f);e&&M(e),v(``),h(``),p(`inference-provider-native`),U(_,`inference-provider-native`)},[f,p,h]);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)(K,{"aria-label":e(`webSearchCard.providerAriaLabel`),value:f,onChange:p,options:Ce.map(e=>({value:e,label:C[e]??e}))})]}),f===`vellum`&&(0,$.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:e(`webSearchCard.vellumNote`)}),y&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(V,{label:e(`webSearchCard.apiBaseLabel`),type:`url`,value:m,onChange:e=>h(e.target.value),placeholder:A||e(`webSearchCard.apiBasePlaceholder`),fullWidth:!0}),A?(0,$.jsx)(`p`,{className:`text-body-small-lighter text-[var(--content-tertiary)]`,children:e(`webSearchCard.apiBaseHint`,{defaultBase:A})}):null]}),b&&(0,$.jsx)(V,{label:e(`webSearchCard.apiKeyLabel`),type:`password`,value:g,onChange:e=>v(e.target.value),placeholder:F,fullWidth:!0}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(dn,{onClick:ee,disabled:P}),u&&(0,$.jsx)(rn,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`}),b&&(0,$.jsx)(un,{onClick:te,filled:!0})]})]})})}function zr(){let e=_t(),t=Je(),[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,$b as n,$f as r,As as i,Ay as a,BC as o,Bb as s,Bs as c,Cm as l,Cp as u,Dp as d,Ds as f,Ep as p,Ev as m,Fb as h,Fm as g,Fs as _,GC as v,Gb as y,Gs as b,Gy as x,HS as S,Hb as C,Hs as w,IC as T,IS as E,Ib as D,Im as O,Is as k,J as A,JC as j,JS as M,Jb as N,Jm as P,Jp as F,KS as I,Kb as ee,Ks as te,Kv as ne,Lb as L,Lv as re,MC as R,Mb as z,Mo as ie,Ms as ae,NC as oe,Nb as se,No as ce,Ns as le,Og as B,Op as ue,Os as de,PC as V,Pb as fe,Po as pe,Ps as me,Q as he,Qb as ge,Qf as _e,Rb as ve,Rs as ye,SC as H,Sm as be,Sp as xe,Tp as Se,Ub as Ce,Ug as we,Us as Te,Vb as Ee,Vm as De,Wb as Oe,Wg as ke,Ws as Ae,X as je,XS as U,Xb as Me,Xf as Ne,Xi as Pe,Xp as Fe,Xv as Ie,Y as Le,Yb as Re,Yf as ze,Yi as Be,Yp as Ve,Z as He,ZC as Ue,Zb as We,Zf as Ge,Zv as Ke,_h as qe,au as Je,aw as W,ax as Ye,bC as Xe,bh as Ze,dp as Qe,en as $e,ep as et,er as tt,ew as G,ex as nt,fh as rt,fp as it,gh as at,hh as ot,hp as st,it as ct,ix as lt,js as ut,ks as dt,mh as ft,mp as pt,my as mt,np as ht,nr as gt,nt as _t,nx as vt,oC as yt,oh as bt,ot as xt,ox as St,pC as Ct,ph as wt,pn as Tt,pp as Et,q as Dt,qb as Ot,qg as kt,qp as At,rx as jt,sh as Mt,st as Nt,sw as Pt,tp as Ft,tx as It,uS as Lt,uh as Rt,up as zt,vC as K,vh as Bt,wm as Vt,wp as Ht,xC as q,xh as Ut,yh as Wt,zb as Gt,zs as Kt}from"./app-D0NlDYsG.js";import{$n as J,E as Y,O as qt,Xn as Jt,j as X,nr as Z}from"./vendor-CtXGFqsu.js";import{b as Yt,t as Xt,x as Zt}from"./react-B9IgSVeK.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-C0wyat6T.js";import{t as cn}from"./ellipsis-vertical-Bg7ccW1x.js";import{i as ln,n as un,r as dn,t as fn}from"./service-form-controls-CjcwqBZf.js";import{o as pn}from"./detail-primitives-Dgh4IUh2.js";import{d as mn,o as hn,u as gn}from"./schedules-0KQuWZ-V.js";import{t as _n}from"./stt-language-picker-modal-ArB52Kbp.js";var Q=e(Zt(),1);function vn(){let e=_t();return(0,Q.useCallback)(async(t,n)=>{try{let{data:r}=await a({path:{assistant_id:e},body:{value:n,type:`api_key`,name:t},throwOnError:!0});se(r)}catch(e){throw e instanceof Error&&e.message===`No assistant found`?q.error(X(`settings:useDaemonConfig.assistantNotReadyToast`)):q.error(X(`settings:useDaemonConfig.saveApiKeyFailedToast`,{providerName:t})),E(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 we(bn)}var $=Xt(),Sn=`gemini-3.1-flash-image-preview`;function Cn(e,t){return e===`openrouter`?`openrouter`:Ae(t)}function wn(){let{t:e}=Y(`settings`),t=_t(),n=Z(),r=Rt(),{data:i}=J({...xe({path:{assistant_id:t}}),enabled:r,staleTime:3e4}),a=De({onSuccess:e=>{Ht(n,{path:{assistant_id:t}},e)}}),o=vn(),s=i?.services?.[`image-generation`],l=(0,Q.useMemo)(()=>i?s?.mode===`managed`?`vellum`:s?.provider||I(`vellum:ai:imageGenProvider`,`gemini`):I(de,`gemini`),[i,s?.mode,s?.provider]),[d,p]=yn(l),[m,h]=(0,Q.useState)(()=>I(f,Sn)),[g,_]=(0,Q.useState)(null),v=l===`openrouter`&&typeof s?.model==`string`?s.model:void 0,y=g??v??I(`vellum:ai:imageGenModel`,`google/gemini-3.1-flash-image-preview`),b=d===`openrouter`,x=Te(d),S=b?y.trim()||`google/gemini-3.1-flash-image-preview`:x.includes(m)?m:x[0]??Sn,[C,w]=(0,Q.useState)(``),[T,D]=(0,Q.useState)(!1),O=Kt.map(e=>({value:e,label:c[e]??e})),A=(0,Q.useMemo)(()=>Te(d).map(e=>({value:e,label:ye[e]??e})),[d]),j=d===`gemini`||d===`openai`||d===`openrouter`,{hasStoredCredential:M}=Mt({assistantId:t,credentialKind:`api_key`,credentialName:d,enabled:j}),N=(0,Q.useCallback)(e=>{p(e),e===`openrouter`&&g===null&&_(v??`google/gemini-3.1-flash-image-preview`)},[g,v,p]),P=(0,Q.useCallback)(async()=>{D(!0);let r=C.trim(),i=j&&r.length>0;try{await kt(),i&&await o(Cn(d,S),r);let s=d===`vellum`&&!xn()?{mode:`managed`}:{provider:d,mode:d===`vellum`?`managed`:`your-own`};await a.mutateAsync({path:{assistant_id:t},body:{services:{"image-generation":s}}}).catch(t=>{throw q.error(e(`imageGenerationCard.configUpdateFailedToast`)),E(t,{context:`patch_daemon_config`}),t});try{await mt({path:{assistant_id:t},body:{modelId:S},throwOnError:!0})}catch(t){throw q.error(e(`imageGenerationCard.modelUpdateFailedToast`)),E(t,{context:`set_image_gen_model`}),t}finally{n.invalidateQueries({queryKey:u({path:{assistant_id:t}})})}}catch{D(!1);return}D(!1);try{if(U(de,d),U(f,S),i){let e=bt(t,`api_key`,d);n.setQueryData(e,!0),n.invalidateQueries({queryKey:e}),w(``)}q.success(e(`imageGenerationCard.savedToast`))}catch(t){E(t,{context:`settings-ai-image-gen-persist-local`}),q.error(e(`imageGenerationCard.localPreferencesFailedToast`))}},[C,d,j,S,t,a,o,n,e]),F=(0,Q.useCallback)(()=>{if(w(``),d===`openrouter`){_(k),U(f,k);return}h(Sn),U(f,Sn)},[d]),ee=e(d===`openai`?`imageGenerationCard.openaiApiKeyPlaceholder`:d===`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)(K,{"aria-label":e(`imageGenerationCard.providerAriaLabel`),value:d,onChange:N,options:O})]}),d===`vellum`&&(0,$.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:e(`imageGenerationCard.vellumNote`)}),j&&(0,$.jsx)(V,{label:e(`imageGenerationCard.apiKeyLabel`),type:`password`,value:C,onChange:e=>w(e.target.value),placeholder:it(ee,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`)}),b?(0,$.jsx)(V,{"aria-label":e(`imageGenerationCard.modelAriaLabel`),value:y,onChange:e=>_(e.target.value),placeholder:e(`imageGenerationCard.openrouterModelPlaceholder`),fullWidth:!0}):(0,$.jsx)(K,{"aria-label":e(`imageGenerationCard.modelAriaLabel`),value:S,onChange:h,options:A})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(dn,{onClick:P,disabled:T}),T&&(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)(j,{variant:`body-large-default`,as:`h3`,className:`text-[var(--content-secondary)]`,children:e}),t==null?null:(0,$.jsxs)(j,{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)(j,{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}=Y(`settings`),l=e?.scheduleNames??[],u=l.slice(0,Dn),d=l.length-u.length,f=e!=null&&En(e);return(0,$.jsx)(H.Root,{open:e!==null,onOpenChange:e=>{e||o()},children:(0,$.jsxs)(H.Content,{size:`sm`,children:[(0,$.jsx)(H.Header,{children:(0,$.jsx)(H.Title,{children:c(`manageProfilesBlockedDeleteModal.title`)})}),(0,$.jsxs)(H.Body,{className:`space-y-4`,children:[e&&(0,$.jsx)(j,{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)(j,{variant:`body-small-default`,as:`p`,className:`pl-1 text-(--content-tertiary)`,children:c(`manageProfilesBlockedDeleteModal.moreSchedules`,{count:d})})]}),e?.scheduleLookupFailed&&(0,$.jsx)(j,{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)(K,{"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:Le(e),disabled:t,tooltip:t?c(`manageProfilesBlockedDeleteModal.disabledTargetTooltip`):void 0}})})]}),i&&(0,$.jsx)(j,{variant:`body-small-default`,as:`p`,className:`text-(--system-negative-strong)`,children:i})]}),(0,$.jsxs)(H.Footer,{children:[(0,$.jsx)(W,{variant:`ghost`,size:`compact`,onClick:o,children:c(`manageProfilesBlockedDeleteModal.cancel`)}),(0,$.jsx)(W,{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:s,onSetStatus:c,onDelete:l}){let{t:u}=Y(`settings`),d=e.source===`managed`,f=e.status===`disabled`,p=e.label??e.name,m=[];e.name===`auto`&&d?m.push(u(`profileRow.autoRouting`)):e.model&&m.push(_e(e.provider??void 0,e.model,r)),d&&m.push(u(`profileRow.managedByVellum`));let h=e.availability,g=e.config_issue,_=g!=null||h?.status===`incomplete`,v=h?.message??u(`profileRow.providerUnavailableDefault`),y=g==null?h!=null&&h.status!==`ok`?_?u(`profileRow.providerUnavailableFixable`,{message:v}):v:null:u(`profileRow.providerUnavailableFixable`,{message:u(g.code===`over_output_cap`?`profileRow.configIssueOverOutputCap`:g.code===`no_input_room`?`profileRow.configIssueNoInputRoom`:`profileRow.configIssueModelUnknown`)});return(0,$.jsx)(yt,{title:(0,$.jsx)(`span`,{className:f?`opacity-55`:void 0,children:p}),subtitle:m.length>0?m.join(` • `):void 0,onClick:a,showChevron:!1,selected:n,disabled:i,contentAriaLabel:u(`profileRow.openProfileAriaLabel`,{displayName:p}),trailingInteractive:!0,trailing:(0,$.jsxs)($.Fragment,{children:[y==null?null:(0,$.jsx)(Pt,{content:y,children:_?(0,$.jsx)(W,{variant:`ghost`,size:`compact`,iconOnly:(0,$.jsx)(tn,{}),iconOnlyGlyphClassName:`[&_svg]:size-4`,tintColor:`var(--system-mid-strong)`,expandOnMobile:!1,onClick:a,"aria-label":y}):(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":y,role:`img`})})}),f?(0,$.jsx)(o,{tone:`neutral`,children:u(`profileRow.disabledTag`)}):null,t?(0,$.jsx)(o,{tone:`positive`,children:u(`profileRow.defaultTag`)}):null,(0,$.jsxs)(G.Root,{children:[(0,$.jsx)(G.Trigger,{asChild:!0,children:(0,$.jsx)(W,{variant:`ghost`,size:`compact`,iconOnly:(0,$.jsx)(cn,{}),"aria-label":u(`profileRow.actionsAriaLabel`,{displayName:p}),disabled:i})}),(0,$.jsxs)(G.Content,{align:`end`,sideOffset:4,children:[(0,$.jsx)(G.Item,{onSelect:a,children:u(d?`profileRow.view`:`profileRow.edit`)}),!t&&!f&&jt(e.provider,e.model)?(0,$.jsx)(G.Item,{onSelect:s,children:u(`profileRow.makeDefault`)}):null,f?(0,$.jsx)(G.Item,{onSelect:()=>c(!0),children:u(`profileRow.enable`)}):d?null:(0,$.jsx)(G.Item,{onSelect:()=>c(!1),children:u(`profileRow.disable`)}),d?null:(0,$.jsx)(G.Item,{onSelect:l,className:Ue.anchored,children:u(`profileRow.delete`)})]})]})]})})}function Mn(e,t){let n=Be(),{data:r}=J({...At({path:{assistant_id:e}}),enabled:n,staleTime:3e4}),{profiles:i,profileOrder:a}=Tt(t?.llm,e);return(0,Q.useMemo)(()=>r==null?{entries:fe(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 ke(Nn,e)}var Fn=`settings-ai-profile-make-active`,In=`Failed to set the active profile. Please try again.`;function Ln(e){let t=Ne(),n=Z(),r=Pn(e),i=P({onSuccess:()=>{n.invalidateQueries({queryKey:u({path:{assistant_id:e}})}),n.invalidateQueries({queryKey:F({path:{assistant_id:e}})})}});async function a(n,r,i){try{await t.mutateAsync({path:{assistant_id:e},body:{llm:n}})}catch(e){throw E(e,{context:r}),q.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=S(e);throw q.error(t??In),t||E(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=S(e);return t?`${/[.!?]$/.test(t)?t:`${t}.`} ${Rn}`:zn}function Vn(e,n,r){let i=Ln(e),a=Z(),o=t(),s=n?.llm?.activeProfile??null,c=n?.llm?.advisorProfile??null,u=n?.llm?.callSites??{},d=(0,Q.useMemo)(()=>n?.llm?.profiles??{},[n?.llm?.profiles]),f=(0,Q.useMemo)(()=>n?.llm?.profileOrder??[],[n?.llm?.profileOrder]),p=(0,Q.useMemo)(()=>fe(d,f),[d,f]),[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:Dt(t,p,{requireOwnProviderAndModel:o}))}function D(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 O(e){try{await i.deleteProfile(e,f,{isAdvisor:e===c}),r?.onDeleted?.(e)}catch{}}async function k(t){let n=d[t]?.label??t,r=t===s,i=Object.entries(u).filter(([e,n])=>e!==`mainAgent`&&n?.profile===t).map(([e])=>e),o=[],c=0,l=!1;try{let n=(await a.fetchQuery({...be({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){E(e,{context:`settings-ai-profile-delete-schedule-scan`}),l=!0}if(!(r||i.length>0||o.length>0||c>0)&&!l){await O(t);return}let f={name:t,label:n,isActive:r,callSiteIds:i,scheduleNames:o,deferredReminderCount:c,scheduleLookupFailed:l};h(f),y(D(t,En(f))),_(null)}function A(e){n==null||w.current||(w.current=!0,C(e),k(e).finally(()=>{w.current=!1,C(null)}))}async function j(){if(!m||!v)return;if(x(!0),_(null),En(m))try{await hn(e,m.name,v),await a.invalidateQueries({queryKey:l({path:{assistant_id:e}})})}catch(e){E(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),O(n)}return{requestDelete:A,pendingDeleteName:S,blockedDeleteModalProps:{blocked:m,availableReplacements:T(m?.name??null),replacement:v,onReplacementChange:y,error:g,saving:b,onClose:()=>{h(null),_(null)},onConfirm:()=>void j()}}}function Hn(){}function Un({assistantId:e,config:t,connections:n,selectedProfileName:r,onOpenProfile:i,onCreateProfile:a,onProfileDeleted:o}){let{t:s}=Y(`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)(W,{variant:`primary`,onClick:a,leftIcon:(0,$.jsx)(en,{}),disabled:t==null,children:s(`profilesSection.createProfile`)}),children:t==null?(0,$.jsx)(j,{variant:`body-medium-lighter`,as:`p`,className:`py-4 text-center text-(--content-tertiary)`,children:s(`profilesSection.loading`)}):c.length===0?(0,$.jsx)(j,{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,vellum:!0,together:!0,"vercel-ai-gateway":!0,minimax:!0,atlascloud:!0,baseten:!0,poolside:!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===`vellum`)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`?et(n):Ye(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:s,onDelete:c}){let{t:l}=Y(`settings`),u=e.isManaged??!1,d=Bt(e),f=Gn(e.provider),p=Yn(e),m=n&&!t&&f,h=!u&&a!=null,g=!u&&!t,_=m||h||g;return(0,$.jsx)(yt,{title:d,subtitle:p.length>0?p:void 0,onClick:a,showChevron:!1,selected:r,contentAriaLabel:a?l(`providerRow.openProviderAriaLabel`,{displayName:d}):void 0,trailingInteractive:!0,trailing:(0,$.jsxs)($.Fragment,{children:[u?(0,$.jsx)(o,{tone:`neutral`,title:l(`providerRow.managedTagTitle`),children:l(`providerRow.managedTag`)}):null,t?(0,$.jsx)(o,{tone:`info`,title:l(`providerRow.defaultTagTitle`),children:l(`providerRow.defaultTag`)}):null,e.provider===`ollama`?(0,$.jsx)(o,{tone:`neutral`,title:l(`providerRow.localTagTitle`),children:l(`providerRow.localTag`)}):null,e.provider===`openai-compatible`?(0,$.jsx)(o,{tone:`neutral`,title:l(`providerRow.customTagTitle`),children:l(`providerRow.customTag`)}):null,_?(0,$.jsxs)(G.Root,{children:[(0,$.jsx)(G.Trigger,{asChild:!0,children:(0,$.jsx)(W,{variant:`ghost`,size:`compact`,iconOnly:(0,$.jsx)(cn,{}),"aria-label":l(`providerRow.actionsAriaLabel`,{displayName:d})})}),(0,$.jsxs)(G.Content,{align:`end`,sideOffset:4,children:[h?(0,$.jsx)(G.Item,{onSelect:a,children:l(`providerRow.edit`)}):null,m?(0,$.jsx)(G.Item,{disabled:i,onSelect:s,children:l(`providerRow.setAsDefault`)}):null,g?(0,$.jsx)(G.Item,{onSelect:c,className:Ue.anchored,children:l(`providerRow.delete`)}):null]})]}):(0,$.jsx)(`span`,{className:`inline-block w-8`,"aria-hidden":!0})]})})}function Zn(e,t){let n=Z(),r={path:{assistant_id:e}},i=Jt({...ue(),onSuccess:()=>{n.invalidateQueries({queryKey:d(r)}),n.invalidateQueries({queryKey:u(r)}),n.invalidateQueries({queryKey:F(r)})},onError:e=>{E(e,{context:`settings-ai-set-default-provider`}),q.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 s(i){try{let{response:a}=await Ie({path:{assistant_id:e,name:i}});a?.ok||a?.status===404?(n.invalidateQueries({queryKey:Fe(r)}),t?.onDeleted?.(i)):a?.status===409?q.error(X(`settings:useProviderActions.deleteInUseToast`)):q.error(X(`settings:useProviderActions.deleteFailedToast`))}catch(e){E(e,{context:`settings-ai-provider-delete`}),q.error(X(`settings:useProviderActions.deleteFailedToast`))}}return{setDefault:a,isSettingDefault:o,deleteConnection:s}}function Qn({assistantId:e,selectedConnectionName:t,onOpenConnection:r,onAddProvider:i,onConnectionDeleted:a}){let{t:o}=Y(`settings`),{data:s,isLoading:c,isError:l}=J(Ve({path:{assistant_id:e}})),u=Pe(),{data:d}=J({...p({path:{assistant_id:e}}),enabled:u}),f=u?d?.resolvedConnectionName??null:null,m=Zn(e,{onDeleted:a}),h=(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:o(`providersSection.title`),action:(0,$.jsx)(W,{variant:`outlined`,onClick:i,leftIcon:(0,$.jsx)(en,{}),children:o(`providersSection.addProvider`)}),children:c?(0,$.jsx)(`div`,{className:`space-y-2 py-2`,children:[1,2,3].map(e=>(0,$.jsx)(Ct,{className:`h-10 rounded-lg`},e))}):l?(0,$.jsx)(j,{variant:`body-medium-default`,as:`p`,className:`py-4 text-center text-(--system-negative-strong)`,children:o(`providersSection.loadError`)}):h.length===0?(0,$.jsx)(j,{variant:`body-medium-lighter`,as:`p`,className:`py-4 text-center text-(--content-tertiary)`,children:o(`providersSection.empty`)}):h.map(e=>(0,$.jsx)(Xn,{connection:e,isDefault:e.name===f,supportsDefaultProvider:u,selected:e.name===t,isSettingDefault:m.isSettingDefault(e.name),onOpen:e.isManaged??!1?void 0:()=>r(e.name),onSetDefault:()=>m.setDefault(e),onDelete:()=>void m.deleteConnection(e.name)},e.name))})}function $n({panel:e,onOpenPanel:t,onClosePanel:n}){let{t:r}=Y(`settings`),i=_t(),{data:a}=J({...xe({path:{assistant_id:i}}),staleTime:3e4}),o=Pe(),{data:s}=J({...p({path:{assistant_id:i}}),enabled:o}),c=s?.availability,{data:l}=J({...Ve({path:{assistant_id:i}})}),u=l?.connections,d=a?.llm?.callSites??{},f=Object.entries(d).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:[c&&c.status!==`ok`&&(0,$.jsx)(v,{tone:c.status===`unknown`?`warning`:`error`,children:c.message??r(`languageModelCard.defaultProviderUnavailable`)}),i&&(0,$.jsx)(Un,{assistantId:i,config:a,connections:u,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:f,action:(0,$.jsx)(W,{variant:`outlined`,onClick:()=>t({kind:`overrides`}),children:r(`languageModelCard.manage`)})})]})})}function er({children:e}){return(0,$.jsxs)(x,{href:`https://www.vellum.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)(qt,{i18nKey:`managedServicesBanner.body`,ns:`common`,components:{link:(0,$.jsx)(er,{})}})})]})}function nr({assistantId:e,profileName:t,onClose:n}){let{t:i}=Y(`settings`),{data:a}=J({...xe({path:{assistant_id:e}}),staleTime:3e4}),{data:s}=J({...Ve({path:{assistant_id:e}})}),c=s?.connections,l=(0,Q.useMemo)(()=>a?.llm?.profiles??{},[a?.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}=ze(e,{onSaved:n}),h=Ge({mode:f,profileName:t??void 0,initialValues:d,existingNames:u,connections:c,assistantId:e,onSave:p}),g=Vn(e,a,{onDeleted:()=>n()}),_=t!=null&&g.pendingDeleteName===t,v=t!=null&&a!=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)(tt,{title:h.effectiveMode===`create`?i(`profileDetailPanel.createTitle`):d?.label??t??i(`profileDetailPanel.defaultTitle`),closeVariant:`outlined`,onClose:n,headerTrailing:y&&h.effectiveMode!==`create`?(0,$.jsx)(o,{tone:`neutral`,children:i(`profileDetailPanel.managedTag`)}):null,headerActions:h.effectiveMode!==`create`&&!h.isReadOnly?(0,$.jsx)(W,{variant:`dangerOutline`,loading:_,iconOnly:(0,$.jsx)(Qt,{}),"aria-label":i(_?`profileDetailPanel.deleting`:`profileDetailPanel.delete`),tooltip:i(`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)(W,{variant:`outlined`,onClick:h.switchToSaveAsNew,disabled:h.saving,children:i(`profileDetailPanel.saveAsNew`)}),h.hasViewModeChanges?(0,$.jsx)(W,{variant:`primary`,onClick:()=>void h.handleSave(),disabled:h.saving,children:h.saving?i(`profileDetailPanel.saving`):i(`profileDetailPanel.save`)}):null]}):(0,$.jsx)(`div`,{className:`flex justify-end`,children:(0,$.jsx)(W,{variant:`primary`,onClick:()=>void h.handleSave(),disabled:h.isInvalid||h.saving,children:h.saving?i(`profileDetailPanel.saving`):h.effectiveMode===`create`?i(`profileDetailPanel.create`):i(`profileDetailPanel.saveChanges`)})}),children:(0,$.jsx)(r,{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}=Y(`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)(K,{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:c}=Y(`settings`),l=Ne(),u=t(),d=(0,Q.useMemo)(()=>({requireOwnProviderAndModel:u,requireTextGeneration:!1}),[u]),f=(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]),p=(0,Q.useMemo)(()=>{let e=new Set(Array.from(f.values(),e=>e.profile));return a.filter(t=>e.has(t.name))},[a,f]),[m,h]=(0,Q.useState)(()=>p[0]?.name??``),[g,_]=(0,Q.useState)(``),[y,b]=(0,Q.useState)(new Set),[x,C]=(0,Q.useState)(!1),w=(0,Q.useMemo)(()=>{let e=new Map(r.map(e=>[e.id,e.displayName]));return t=>e.get(t)??t},[r]),T=(0,Q.useMemo)(()=>n.filter(e=>f.get(e.id)?.profile===m),[n,f,m]),D=(0,Q.useMemo)(()=>T.map(e=>e.id).filter(e=>!y.has(e)),[T,y]),O=(0,Q.useMemo)(()=>p.map(e=>({value:e.name,label:Le(e)})),[p]),k=(0,Q.useMemo)(()=>he(a,[],d).filter(e=>e.name!==m).map(e=>({value:e.name,label:Le(e)})),[a,m,d]),A=L(a,m),M=L(a,g),N=y.size===0;function P(e){h(e),b(new Set),e===g&&_(``)}function F(e,t){b(n=>{let r=new Set(n);return t?r.delete(e):r.add(e),r})}async function I(){if(!(!m||!g||D.length===0)){C(!0);try{let t={};for(let e of D)t[e]={profile:g};await l.mutateAsync({path:{assistant_id:e},body:{llm:{callSites:t}}}),q.success(c(`bulkOverrideSwapModal.successToast`,{count:D.length,targetLabel:M})),s(),o()}catch(e){let t=S(e);q.error(t??c(`bulkOverrideSwapModal.updateFailedToast`)),t||E(e,{context:`settings-ai-bulk-override-swap`})}finally{C(!1)}}}return(0,$.jsx)(H.Root,{open:!0,onOpenChange:e=>{e||o()},children:(0,$.jsxs)(H.Content,{size:`md`,children:[(0,$.jsx)(H.Header,{children:(0,$.jsx)(H.Title,{children:c(`bulkOverrideSwapModal.title`)})}),(0,$.jsxs)(H.Body,{className:`space-y-4`,children:[(0,$.jsx)(j,{variant:`body-medium-default`,as:`p`,children:c(`bulkOverrideSwapModal.intro`)}),(0,$.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,$.jsx)(K,{id:`bulk-swap-source`,label:c(`bulkOverrideSwapModal.currentlyUsingLabel`),value:m,onChange:P,options:O}),(0,$.jsx)(K,{id:`bulk-swap-target`,label:c(`bulkOverrideSwapModal.changeToLabel`),value:g,onChange:_,options:k,placeholder:c(`bulkOverrideSwapModal.targetPlaceholder`)})]}),(0,$.jsx)(v,{tone:`info`,title:c(`bulkOverrideSwapModal.noticeTitle`),children:c(`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)(j,{variant:`body-medium-default`,as:`p`,children:c(`bulkOverrideSwapModal.affectedSummary`,{count:T.length,profile:A})}),(0,$.jsx)(j,{variant:`body-small-default`,as:`p`,className:`text-[color:var(--content-secondary)]`,children:c(`bulkOverrideSwapModal.chooseActions`)})]}),(0,$.jsx)(W,{variant:`ghost`,onClick:()=>b(N?new Set(T.map(e=>e.id)):new Set),children:c(N?`bulkOverrideSwapModal.clearAll`:`bulkOverrideSwapModal.selectAll`)})]}),(0,$.jsx)(`div`,{className:`max-h-72 space-y-1 overflow-y-auto`,children:T.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)(R,{checked:!y.has(e.id),onCheckedChange:t=>F(e.id,t===!0),disabled:x,label:e.displayName,helperText:w(e.domain)}),(0,$.jsx)(`span`,{className:`shrink-0 text-body-small-default text-[color:var(--content-tertiary)]`,children:f.get(e.id)?.via===`override`?c(`bulkOverrideSwapModal.viaOverride`):c(`bulkOverrideSwapModal.viaDefault`)})]},e.id))})]})]}),(0,$.jsxs)(H.Footer,{children:[(0,$.jsx)(j,{variant:`body-small-default`,as:`p`,className:`mr-auto self-center text-[color:var(--content-secondary)]`,children:c(`bulkOverrideSwapModal.willChange`,{count:D.length})}),(0,$.jsx)(W,{variant:`ghost`,onClick:o,disabled:x,children:c(`bulkOverrideSwapModal.cancel`)}),(0,$.jsx)(W,{variant:`primary`,loading:x,disabled:!m||!g||D.length===0||x,onClick:()=>void I(),children:c(`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}=Y(`settings`),u=vt({hostedInference:ht.use.vellumHostedInference()}),d=ar(i),f=!i||!d?``:i.provider||i.model?ir:i.profile??``,p=f===ir,m=ft(),h=rt(),g=(o??[]).some(e=>e.provider===We),_=[...ge,...g?[We]:[]],v=m[0]??ge[0],y=i?.provider,b=nt(y)?y:y===`chatgpt`?We:void 0,x=b!==void 0&&_.some(e=>e===b),S=b??v,C=Ft(S,``,(o??[]).filter(e=>wt(e.provider,S)))?et(S):St(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=Ye(S).find(e=>e.id===T)?.displayName??T;w.push({value:T,label:l(`callSiteOverridesRow.unavailableOption`,{name:e})})}let E=!!i?.provider&&!i?.model,D=[..._.map(e=>({value:e,label:It[e]??e,...h(e)})),...b&&!x?[{value:b,label:l(`callSiteOverridesRow.unavailableOption`,{name:It[b]??b})}]:[]];function O(t){t===`__custom__`?s(e,{profile:null,provider:v,model:lt(v)??``}):t===``?s(e,null):s(e,{profile:t,provider:null,model:null})}function k(t){let n=lt(t)??``;s(e,{...i??{},profile:null,provider:t,model:n})}function A(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)(oe,{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)(K,{value:f,onChange:O,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)(K,{value:S??``,onChange:k,options:D})]}),(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)(K,{value:i?.model??``,onChange:A,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}=Y(`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}=Y(`settings`),{data:i}=J({...xe({path:{assistant_id:e}}),staleTime:3e4}),a=(0,Q.useMemo)(()=>i?.llm?.profiles??{},[i?.llm?.profiles]),o=(0,Q.useMemo)(()=>i?.llm?.profileOrder??[],[i?.llm?.profileOrder]),s=(0,Q.useMemo)(()=>i?.llm?.callSites??{},[i?.llm?.callSites]),c=(0,Q.useMemo)(()=>fe(a,o),[a,o]),l=ft(),u=t(),d=(0,Q.useMemo)(()=>({requireOwnProviderAndModel:u}),[u]),f=(0,Q.useMemo)(()=>({requireOwnProviderAndModel:u,requireTextGeneration:!1}),[u]),p=Ne(),[m,h]=(0,Q.useState)(``),[g,_]=(0,Q.useState)(!1),[y,b]=(0,Q.useState)(!1),[x,S]=(0,Q.useState)(!1),{data:C,isLoading:w,isError:T,refetch:D}=J({...Se({path:{assistant_id:e}}),enabled:!!e,staleTime:6e4,refetchOnWindowFocus:!1}),{data:O}=J({...Ve({path:{assistant_id:e}}),enabled:!!e}),k=(0,Q.useMemo)(()=>(C?.callSites??[]).filter(e=>e.id!==`mainAgent`),[C]),j=!w&&!T&&!!C,M=!!i,N=j&&M,P=(0,Q.useMemo)(()=>k.map(e=>e.id),[k]),F=i?.llm?.advisorProfile??``,{drafts:I,advisorProfile:ee,advisorDirty:te,callSiteDraftsDirty:ne,hasUnsavedDrafts:re,hasValidationError:R,setDraft:z,setAdvisor:ie,clearEdits:ae,buildSavePatch:oe,buildResetPatch:se}=pr({catalogCallSiteIds:P,persistedOverrides:s,persistedAdvisor:F,isSeeded:N}),ce=(0,Q.useMemo)(()=>new Set(P),[P]),le=(0,Q.useCallback)(e=>L(c,e),[c]),B=(0,Q.useCallback)((e,t)=>({value:e.name,label:Le(e),...A(e,c,t)===`undispatchable`?{icon:(0,$.jsx)(tn,{className:`h-3.5 w-3.5 text-[var(--system-mid-strong)]`}),tooltip:He(e)}:{}}),[c]),ue=(0,Q.useMemo)(()=>he(c,[F],d).map(e=>B(e,d)),[c,F,B,d]),de=(0,Q.useMemo)(()=>{let e=m.trim().toLowerCase();return e===``||`advisor`.includes(e)||`second opinion`.includes(e)},[m]),pe=(0,Q.useMemo)(()=>k.some(e=>or(e,s[e.id])!==null),[k,s]),me=(0,Q.useMemo)(()=>Object.entries(s).some(([e,t])=>ce.has(e)&&(t?.profile!=null||t?.provider!=null||t?.model!=null)),[s,ce]),_e=(0,Q.useCallback)(e=>[...he(c,[e],f).map(e=>B(e,f)),{value:ir,label:r(`overridesDetailPanel.customProfileOption`)}],[c,B,f,r]),ve=(0,Q.useMemo)(()=>{if(!m.trim())return k;let e=m.toLowerCase();return k.filter(t=>(t.displayName??``).toLowerCase().includes(e)||(t.description??``).toLowerCase().includes(e)||(t.domain??``).toLowerCase().includes(e))},[k,m]),ye=(0,Q.useMemo)(()=>{if(!C)return[];let e=C.domains.map(e=>e.id),t=new Map(C.domains.map(e=>[e.id,e])),n=[];for(let r of e){let e=ve.filter(e=>e.domain===r);e.length>0&&n.push({domain:t.get(r),sites:e})}let i=new Set(e),a=ve.filter(e=>!i.has(e.domain));return a.length>0&&n.push({domain:{id:`other`,displayName:r(`overridesDetailPanel.otherDomain`)},sites:a}),n},[C,ve,r]),H=(0,Q.useCallback)((e,t)=>{if(!t){z(e,null);return}let n=je(c,k.find(t=>t.id===e)?.defaultProfile,f);if(n)z(e,{profile:n});else{let t=l[0]??ge[0];z(e,{provider:t,model:lt(t)??``})}},[k,c,l,z,f]),be=(0,Q.useCallback)(async()=>{_(!0);try{let t=oe();await p.mutateAsync({path:{assistant_id:e},body:{llm:{...ne?{callSites:t}:{},...te?{advisorProfile:ee}:{}}}}),n(),q.success(r(`overridesDetailPanel.overridesSavedToast`))}catch(e){q.error(r(`overridesDetailPanel.saveFailedToast`)),E(e,{context:`call_site_overrides_save`})}finally{_(!1)}},[oe,ne,te,ee,n,p,e,r]),Ce=(0,Q.useCallback)(async()=>{_(!0);try{let t=se();await p.mutateAsync({path:{assistant_id:e},body:{llm:{callSites:t}}}),n(),q.success(r(`overridesDetailPanel.overridesResetToast`))}catch(e){q.error(r(`overridesDetailPanel.resetFailedToast`)),E(e,{context:`call_site_overrides_reset`})}finally{_(!1)}},[se,n,p,e,r]),we=(0,$.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[me&&(0,$.jsx)(W,{variant:`outlined`,onClick:()=>b(!0),disabled:g||!N,tintColor:`var(--system-negative-strong)`,className:`mr-auto`,children:r(`overridesDetailPanel.resetToDefaults`)}),(0,$.jsx)(W,{variant:`primary`,onClick:()=>void be(),loading:g,disabled:!re||R||g,children:r(`overridesDetailPanel.save`)})]});return(0,$.jsxs)(tt,{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:m,onChange:e=>h(e.target.value),placeholder:r(`overridesDetailPanel.searchPlaceholder`),leftIcon:(0,$.jsx)(sn,{className:`h-4 w-4`}),fullWidth:!0})}),(0,$.jsx)(W,{variant:`outlined`,onClick:()=>S(!0),disabled:!N||g||re||!pe,title:re?r(`overridesDetailPanel.bulkChangeUnsavedTitle`):pe?void 0:r(`overridesDetailPanel.bulkChangeNoCandidatesTitle`),children:r(`overridesDetailPanel.bulkChange`)})]}),M&&de&&(0,$.jsxs)(`div`,{children:[(0,$.jsx)(pn,{children:r(`overridesDetailPanel.advisorSection`)}),(0,$.jsx)(rr,{value:ee,profileOptions:ue,disabled:g,onChange:ie})]}),w&&(0,$.jsx)(gt,{placement:`panel`}),T&&(0,$.jsx)(v,{tone:`error`,title:r(`overridesDetailPanel.loadErrorTitle`),actions:(0,$.jsx)(W,{variant:`outlined`,onClick:()=>void D(),children:r(`overridesDetailPanel.retry`)}),children:r(`overridesDetailPanel.loadErrorHint`)}),!w&&!T&&C&&(0,$.jsx)(ur,{groups:ye,drafts:I,buildProfileOptionsForRow:_e,profileLabelFor:le,advisorMatchesSearch:de,connections:O?.connections,onDraftChange:z,onToggle:H})]})]}),x&&C&&(0,$.jsx)(cr,{assistantId:e,callSites:k,domains:C.domains,persistedOverrides:s,orderedProfiles:c,onClose:()=>S(!1),onApplied:ae}),(0,$.jsx)(Xe,{open:y,title:r(`overridesDetailPanel.resetToDefaults`),message:r(`overridesDetailPanel.resetConfirmMessage`),confirmLabel:r(`overridesDetailPanel.resetToDefaults`),destructive:!0,onConfirm:()=>{b(!1),Ce()},onCancel:()=>b(!1)})]})}var hr=e(Yt(),1);function gr({mode:e,connection:t,assistantId:n,existingNames:r,connections:i,variant:o=`modal`,actionsSlot:s,onSave:c,onCancel:l}){let{t:u}=Y(`settings`),[d,f]=(0,Q.useState)(t?.label??``),p=t?.name??``,h=t?.provider??`anthropic`,g=t?.auth.type??`api_key`,[_,v]=(0,Q.useState)(()=>t?.auth.type===`api_key`?t.auth.credential:t?``:`credential/anthropic/api_key`),[y,b]=(0,Q.useState)(t?.baseUrl??``),[x,S]=(0,Q.useState)(()=>t?.models?t.models.map(e=>e.id).join(`, `):``),[C,w]=(0,Q.useState)(!1),[T,E]=(0,Q.useState)(null),D=h===`openai-compatible`,O=qe(h),k=Wt(h),[A,M]=(0,Q.useState)(``),[N,P]=(0,Q.useState)(!1),F=Z(),I=(0,Q.useMemo)(()=>at(_),[_]),ee=g===`api_key`&&I!==null,{hasStoredCredential:te,isLoading:ne}=Mt({assistantId:n,credentialKind:`credential`,credentialName:I?`${I.service}:${I.field}`:``,enabled:ee}),{credentials:L}=Qe({assistantId:n,enabled:g===`api_key`});(0,Q.useEffect)(()=>{let e=t?.provider??`anthropic`;f(t?.label??``),t?.auth.type===`api_key`?v(t.auth.credential):v(t?``:`credential/${e}/api_key`),E(null),b(t?.baseUrl??``),S(t?.models?t.models.map(e=>e.id).join(`, `):``),M(``),P(!1)},[t]);let re=d.trim()!==(t?.label??``).trim(),R=D&&re?st(d,i,t?.name):null,z=p.trim().length>0&&R===null;async function ie(){if(z){w(!0),E(null);try{let e;if(g===`api_key`){let t=_.trim()||`credential/${h}/api_key`,r=A.trim();if(r){P(!0);try{let e=at(t);await a({path:{assistant_id:n},body:e?{type:`credential`,name:`${e.service}:${e.field}`,value:r}:{type:`api_key`,name:h,value:r},throwOnError:!0});let i=bt(n,`credential`,e?`${e.service}:${e.field}`:``);F.setQueryData(i,!0),F.invalidateQueries({queryKey:Vt({path:{assistant_id:n}})})}catch{E(u(`providerEditorContent.failedSaveApiKey`));return}finally{P(!1)}}e={type:`api_key`,credential:t}}else if(t)e=t.auth;else{E(u(`providerEditorContent.nothingToEdit`));return}let r=d.trim()||null,i={auth:e,label:r,...O&&{base_url:y.trim()||null},...k&&{models:x.trim()?x.split(`,`).map(e=>({id:e.trim()})).filter(e=>e.id):null}},{data:o,error:s,response:l}=await Ke({path:{assistant_id:n,name:t?.name??p.trim()},body:i});if(!l?.ok){E(Ze(l?.status,s)??ot(l?.status));return}if(!o){E(u(`providerEditorContent.emptyServerResponse`));return}Ut(o,u),c(o)}catch{E(u(`providerEditorContent.failedSaveProvider`))}finally{w(!1)}}}let ae=L.filter(e=>e.service===h),oe=e!==`create`&&t?.auth.type===`api_key`,se=ae.length>0||oe,ce=it(u(`providerEditorContent.apiKeyPlaceholder`),te);if(e===`create`)return(0,$.jsx)(zt,{variant:o===`panel`?`inline`:`modal`,actionsSlot:s,assistantId:n,existingNames:r,connections:i,defaultProviderType:h,onCreated:c,onCancel:l});let le=(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)(qt,{i18nKey:`providerEditorContent.displayNameLabel`,ns:`settings`,components:{optional:(0,$.jsx)(`span`,{className:`text-[var(--content-disabled)]`})}})}),(0,$.jsx)(V,{value:d,onChange:e=>f(e.target.value),placeholder:u(`providerEditorContent.displayNamePlaceholder`),fullWidth:!0}),R?(0,$.jsx)(j,{variant:`body-small-default`,as:`p`,className:`text-(--system-negative-strong)`,children:pt[R]}):null]}),O&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:u(`providerEditorContent.baseUrlLabel`)}),(0,$.jsx)(V,{value:y,onChange:e=>b(e.target.value),placeholder:u(h===`ollama`?`providerEditorContent.baseUrlPlaceholderOllama`:h===`opencode`?`providerEditorContent.baseUrlPlaceholderOpencode`:`providerEditorContent.baseUrlPlaceholder`),fullWidth:!0}),h===`ollama`?(0,$.jsx)(j,{variant:`body-small-default`,as:`p`,className:`text-[var(--content-tertiary)]`,children:u(`providerEditorContent.baseUrlHintOllama`)}):null,h===`opencode`?(0,$.jsx)(j,{variant:`body-small-default`,as:`p`,className:`text-[var(--content-tertiary)]`,children:u(`providerEditorContent.baseUrlHintOpencode`)}):null]}),k&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:u(`providerEditorContent.modelsLabel`)}),(0,$.jsx)(V,{value:x,onChange:e=>S(e.target.value),placeholder:u(`providerEditorContent.modelsPlaceholder`),fullWidth:!0}),(0,$.jsx)(j,{variant:`body-small-default`,as:`p`,className:`text-[var(--content-tertiary)]`,children:u(`providerEditorContent.modelsHint`)})]}),g===`api_key`&&(0,$.jsx)(Et,{apiKeyValue:A,onApiKeyChange:M,credential:_,onCredentialChange:v,isLoadingCredential:ne,apiKeyPlaceholder:ce,provider:h,providerCredentials:ae,showAdvancedSection:se,onError:E}),g===`oauth_subscription`&&(0,$.jsx)(m,{assistantId:n,onConnected:c}),T&&(0,$.jsx)(j,{variant:`body-small-default`,as:`p`,className:`text-(--system-negative-strong)`,children:T})]}),B=(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(W,{variant:`ghost`,onClick:l,children:u(`providerEditorContent.cancel`)}),(0,$.jsx)(W,{variant:`primary`,disabled:!z||C||N,onClick:()=>void ie(),children:u(C?`providerEditorContent.saving`:`providerEditorContent.saveChanges`)})]});return o===`panel`?(0,$.jsxs)(`div`,{className:`space-y-4`,children:[le,s===void 0?(0,$.jsx)(`div`,{className:`flex justify-end gap-2`,children:B}):s&&(0,hr.createPortal)(B,s)]}):(0,$.jsxs)(H.Content,{size:`md`,children:[(0,$.jsxs)(H.Header,{children:[(0,$.jsx)(H.Title,{children:u(`providerEditorContent.editProviderTitle`)}),(0,$.jsx)(H.Description,{children:t?u(`providerEditorContent.editingConnection`,{name:Bt(t)}):u(`providerEditorContent.editProviderSettingsFallback`)})]}),(0,$.jsx)(H.Body,{children:le}),(0,$.jsx)(H.Footer,{children:B})]})}function _r({assistantId:e,connectionName:t,onClose:n}){let{t:r}=Y(`settings`),i=Z(),[a,o]=(0,Q.useState)(null),{data:s,isLoading:c}=J(Ve({path:{assistant_id:e}})),l=(0,Q.useMemo)(()=>s?.connections??[],[s]),u=(0,Q.useMemo)(()=>t==null?void 0:l.find(e=>e.name===t),[t,l]),f=t!=null&&s!=null&&u==null;(0,Q.useEffect)(()=>{f&&n()},[f,n]);function p(){i.invalidateQueries({queryKey:Fe({path:{assistant_id:e}})}),i.invalidateQueries({queryKey:d({path:{assistant_id:e}})}),n()}return(0,$.jsx)(tt,{title:u?Bt(u):r(`providerDetailPanel.addProviderTitle`),closeVariant:`outlined`,onClose:n,footer:(0,$.jsx)(`div`,{ref:o,className:`flex justify-end gap-2`}),children:t!=null&&c?(0,$.jsx)(gt,{placement:`panel`}):t==null||u!=null?(0,$.jsx)(gr,{mode:u?`edit`:`create`,connection:u,variant:`panel`,actionsSlot:a,assistantId:e,existingNames:l.map(e=>e.name),connections:l,onSave:p,onCancel:n}):null})}var vr={vellum:{provider:`vellum`},deepgram:{provider:`deepgram`,credentialService:`deepgram`},openai:{provider:`openai-whisper`,credentialService:`openai`}},yr={vellum:`vellum`,deepgram:`deepgram`,"openai-whisper":`openai`},br=`deepgram`;function xr({assistantId:e,hideSaveButton:t=!1,hideCredentialsGuide:n=!1,onSaveStateChange:r}={}){let a=_t(),o=e??a,s=Rt(),c=Z(),{t:l}=Y(),d=(0,Q.useMemo)(()=>b(B(),{displayName:l(`sttProviderForm.windowsNativeDisplayName`),subtitle:l(`sttProviderForm.windowsNativeSubtitle`),setupWarning:l(`sttProviderForm.windowsNativeSetupWarning`)}).filter(e=>!e.requiresNativeDictation||te()),[l]),f=br,{data:p}=J({...xe({path:{assistant_id:o}}),enabled:s,staleTime:3e4}),m=p?.services?.stt,h=m?.mode===`managed`?`vellum`:m?.provider,g=(0,Q.useMemo)(()=>{let e=h?yr[h]:void 0;if(e&&d.some(t=>t.id===e))return e;let t=I(i,f);return d.some(e=>e.id===t)?t:f},[h,d,f]),_=!!h,[v,y]=yn(g),{available:x,currentCode:S,configuredProviderId:C,selectLanguage:w,selecting:T}=ct(o),[E,D]=(0,Q.useState)(!1),O=x&&v===g&&(vr[v]?.provider===C||!!h&&!yr[h]),[k,A]=(0,Q.useState)(``),[j,M]=(0,Q.useState)(!1),[N,P]=(0,Q.useState)(!1);(0,Q.useEffect)(()=>{let e=I(i,f);e===`macos-native`&&!d.some(t=>t.id===e)&&U(i,f)},[d,f]);let F=(0,Q.useMemo)(()=>d.find(e=>e.id===v)??d[0],[d,v]),ee=F.apiKeyPlaceholder!==void 0;(0,Q.useEffect)(()=>{M(I(dt+v,``).length>0),A(``)},[v]);let L=(0,Q.useMemo)(()=>{let e=v!==g,t=k.trim().length>0;return e||t},[v,g,k]),R=(0,Q.useCallback)(async()=>{let e=k.trim();U(i,v),e.length>0&&U(dt+v,e);let t=vr[v];P(!0);try{if(t?.credentialService){let n=e.length>0?e:I(dt+v,``);if(n.length>0){let{response:e}=await ne({path:{assistant_id:o},body:{service:t.credentialService,field:`api_key`,value:n,label:`${F.displayName} API Key`},throwOnError:!1});if(!e?.ok)throw Error(`Failed to store API key (HTTP ${e?.status??`?`})`)}}if(t&&(v!==g||!_)||h===`vellum`&&v!==`vellum`){let e=t?.provider??br,{response:n}=await re({path:{assistant_id:o},body:{services:{stt:{provider:e,mode:e===`vellum`?`managed`:`your-own`}}},throwOnError:!1});if(!n?.ok)throw Error(`Failed to save configuration (HTTP ${n?.status??`?`})`)}return e.length>0&&M(!0),A(``),c.invalidateQueries({queryKey:u({path:{assistant_id:o}})}),q.success(l(`sttProviderForm.saveSuccess`)),!0}catch(e){return q.error(e instanceof Error?e.message:l(`sttProviderForm.saveFailed`)),!1}finally{P(!1)}},[o,v,k,F,g,_,h,c,l]);(0,Q.useEffect)(()=>{r?.({hasChanges:L,saving:N,save:R})},[r,L,N,R]);let z=(0,Q.useCallback)(()=>{U(dt+v,``),M(!1),A(``)},[v]),ie=j?l(`sttProviderForm.apiKeyPlaceholderReplace`):F.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:l(`sttProviderForm.providerLabel`)}),(0,$.jsx)(K,{value:v,onChange:y,options:d.map(e=>({value:e.id,label:e.displayName})),"aria-label":l(`sttProviderForm.providerAriaLabel`)})]}),O&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:l(`sttProviderForm.spokenLanguage`)}),(0,$.jsx)(Nt,{"aria-label":l(`sttProviderForm.spokenLanguage`),"aria-haspopup":`dialog`,onClick:()=>D(!0),value:xt(S,C)}),(0,$.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:l(`sttProviderForm.spokenLanguageApplies`)}),(0,$.jsx)(_n,{open:E,onOpenChange:D,title:l(`sttProviderForm.spokenLanguage`),currentCode:S,configuredProviderId:C,selectLanguage:w,selecting:T})]}),ee&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:l(`sttProviderForm.apiKeyLabel`)}),(0,$.jsx)(V,{type:`password`,value:k,onChange:e=>A(e.target.value),placeholder:ie,fullWidth:!0})]}),F.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:F.setupWarning})]}),!n&&F.credentialsGuide&&(0,$.jsx)(fn,{guide:F.credentialsGuide}),v===`vellum`&&(0,$.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:l(`sttProviderForm.vellumTranscription`)}),(!t||j)&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!t&&(0,$.jsx)(dn,{onClick:R,disabled:!L||N}),j&&(0,$.jsx)(un,{onClick:z})]})]})}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}=Y(`settings`),n=Z(),r=Rt(),[i,a]=(0,Q.useState)(null),{data:o}=J({...xe({path:{assistant_id:e}}),enabled:r,staleTime:3e4}),s=o?.services?.stt,c=Cr(s),{data:l}=J({...g({path:{assistant_id:e}}),enabled:r&&c.length>0,staleTime:5*6e4});if(c.length===0)return null;let d=e=>l?.providers?.find(t=>t.id===e)?.displayName??e,f=async r=>{a(r);try{let{response:t}=await re({path:{assistant_id:e},body:{services:{stt:{roles:{[r]:null}}}},throwOnError:!1});if(!t?.ok)throw Error(String(t?.status??``));await n.invalidateQueries({queryKey:u({path:{assistant_id:e}})})}catch{q.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?`${d(e.provider)} · ${e.model}`:d(e.provider)}),(0,$.jsx)(W,{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 f(e.role),children:t(`sttRoleOverrides.clear`)})]},e.role)})})]})}function Tr(){let{t:e}=Y(`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}=Y(),[a,o]=(0,Q.useState)(!1),{voices:s}=ce(e);if(s.length===0)return null;let c=s.find(e=>e.model===t)??s[0];return(0,$.jsxs)(T.Root,{open:a,onOpenChange:o,children:[(0,$.jsx)(T.Trigger,{asChild:!0,children:(0,$.jsx)(Nt,{"aria-label":i(`voicePickerField.ariaLabel`),value:c?ie(c.description):i(`voicePickerField.selectVoice`),className:r})}),(0,$.jsx)(T.Content,{side:`bottom`,align:`start`,className:`w-[var(--radix-popover-trigger-width)] p-1`,children:(0,$.jsx)($e,{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:r}={}){let{t:i}=Y(),a=_t(),o=e??a,s=Lt.use.name()??`your assistant`,c=Rt(),l=Z(),{data:d}=J({...O({path:{assistant_id:o}}),enabled:c,staleTime:1/0}),f=(0,Q.useMemo)(()=>{let e=d?.providers;if(!e)return w;if(e.some(e=>e.id===`vellum`))return e;let t=w.find(e=>e.id===`vellum`);return t?[t,...e]:e},[d]),{data:p}=J({...xe({path:{assistant_id:o}}),enabled:c,staleTime:3e4}),m=p?.services?.tts,h=m?.mode===`managed`?`vellum`:m?.provider,g=`elevenlabs`,_=(0,Q.useMemo)(()=>h??I(`vellum:voice:ttsProvider`,g),[h,g]),v=!!h,[y,b]=yn(_),[x,S]=(0,Q.useState)(``),[C,T]=(0,Q.useState)(``),[E,D]=(0,Q.useState)(``),[k,A]=(0,Q.useState)(!1),[j,M]=(0,Q.useState)(!1),[N,P]=(0,Q.useState)(!1),{voices:F,defaultModel:ee,fetched:te}=pe(o,{enabled:y===`vellum`}),L=m?.providers?.vellum?.model??ee??``,[R,z]=yn(L),ie=F.find(e=>e.model===R)??F[0],[oe,se]=(0,Q.useState)(null),ce=F.some(e=>e.model===L),B=oe??(te&&L!==``&&!ce),ue=(0,Q.useMemo)(()=>f.find(e=>e.id===y)??f[0],[y,f]),de=y===`vellum`&&ue.supportsVoiceSelection&&R.trim()!==``&&R.trim()!==L,fe=(0,Q.useCallback)(e=>{let t=I(ut+e,``),n=I(le+e,``);A(t.length>0),T(n),D(n),S(``)},[]);(0,Q.useEffect)(()=>{fe(y)},[y,fe]);let me=(0,Q.useMemo)(()=>{let e=y!==_,t=x.trim().length>0,n=C.trim()!==E;return e||t||n||de},[y,_,x,C,E,de]),he=(0,Q.useCallback)(async()=>{let e=x.trim(),t=C.trim(),n=ue.id;U(ae,n),e.length>0&&U(ut+n,e),U(le+n,t);let r=e.length>0?e:I(ut+n,``),a=jr[n];P(!0);try{if(r.length>0){let{response:e}=await ne({path:{assistant_id:o},body:{service:n,field:`api_key`,value:r,label:`${ue.displayName} API Key`},throwOnError:!1});if(!e?.ok)throw Error(`Failed to store API key (HTTP ${e?.status??`?`})`)}let e={...y!==_||!v?{provider:n,mode:n===`vellum`?`managed`:`your-own`}:{},...a?{providers:{[n]:{[a]:t}}}:{},...de?{providers:{vellum:{model:R.trim()}}}:{}};if(Object.keys(e).length>0){let{response:t}=await re({path:{assistant_id:o},body:{services:{tts:e}},throwOnError:!1});if(!t?.ok)throw Error(`Failed to save configuration (HTTP ${t?.status??`?`})`)}return A(r.length>0),D(t),S(``),l.invalidateQueries({queryKey:u({path:{assistant_id:o}})}),q.success(i(`ttsProviderForm.saved`)),!0}catch(e){return q.error(e instanceof Error?e.message:i(`ttsProviderForm.saveFailed`)),!1}finally{P(!1)}},[o,y,R,de,x,C,ue,_,v,l,i]);(0,Q.useEffect)(()=>{r?.({hasChanges:me,saving:N,save:he})},[r,me,N,he]);let ge=(0,Q.useCallback)(()=>{U(ut+y,``),A(!1),S(``)},[y]),_e=(0,Q.useCallback)(async()=>{M(!0);try{let e=I(ut+y,``),t=x.trim(),n=t.length>0?t:e;if(n.length===0){q.error(i(`ttsProviderForm.apiKeyRequired`));return}let r=I(le+y,``),a=C.trim(),o=await Er({provider:y,apiKey:n,voiceId:a.length>0?a:r,text:`Hey! It's ${s}. How does this sound?`});if(o.kind!==`audio`){q.error(o.message);return}let c=URL.createObjectURL(o.blob);try{let e=new Audio(c);await e.play(),await new Promise(t=>{e.onended=()=>t(),e.onerror=()=>t()})}finally{URL.revokeObjectURL(c)}}finally{M(!1)}},[s,x,y,C,i]),ve=k?`•••••••• (Enter a new key to replace)`:ue.apiKeyPlaceholder,ye=y===`vellum`,H=ye&&ue.supportsVoiceSelection,be=(0,$.jsxs)(W,{variant:`link`,size:`compact`,className:`inline-flex h-auto items-center gap-1 px-0 underline [--vbtn-fg:var(--content-tertiary)]`,onClick:()=>{se(!1),F.some(e=>e.model===R)||z(ee||F[0]?.model||``)},children:[(0,$.jsx)(nn,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),i(`ttsProviderForm.chooseFromCatalog`)]}),Se=H&&B&&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:i(`ttsProviderForm.provider`)}),(0,$.jsx)(K,{value:y,onChange:b,options:f.map(e=>({value:e.id,label:e.displayName})),"aria-label":i(`ttsProviderForm.providerAriaLabel`)})]}),!ye&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:i(`ttsProviderForm.apiKey`)}),(0,$.jsx)(V,{type:`password`,value:x,onChange:e=>S(e.target.value),placeholder:ve,fullWidth:!0})]}),H&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:i(`ttsProviderForm.voice`)}),B?(0,$.jsx)(V,{type:`text`,value:R,onChange:e=>z(e.target.value),placeholder:i(`ttsProviderForm.voiceIdPlaceholder`),"aria-label":i(`ttsProviderForm.customVoiceIdAriaLabel`),fullWidth:!0}):ie?(0,$.jsx)(Ar,{assistantId:o,value:R,onChange:z}):te&&(0,$.jsx)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:i(`ttsProviderForm.noManagedVoices`)})]}),ue.supportsVoiceSelection&&!ye&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(`label`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:i(`ttsProviderForm.voiceId`)}),(0,$.jsx)(V,{type:`text`,value:C,onChange:e=>T(e.target.value),placeholder:i(`ttsProviderForm.voiceIdPlaceholder`),fullWidth:!0})]}),!n&&!ye&&(0,$.jsx)(fn,{guide:ue.credentialsGuide}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[!ye&&(0,$.jsx)(W,{variant:`outlined`,onClick:_e,disabled:j,children:i(j?`ttsProviderForm.testing`:`ttsProviderForm.test`)}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3`,children:[Se,!t&&(0,$.jsx)(dn,{onClick:he,disabled:!me||N}),k&&!ye&&(0,$.jsx)(un,{onClick:ge})]})]})]})}function Nr(){let{t:e}=Y(`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}=Y(`settings`),t=_t(),n=Z(),{data:r}=J({...xe({path:{assistant_id:t}}),staleTime:3e4}),i=De({onSuccess:e=>{Ht(n,{path:{assistant_id:t}},e)}}),a=vn(),o=(0,Q.useMemo)(()=>r?r.services?.[`web-fetch`]?.provider||I(`vellum:ai:webFetchProvider`,Pr):I(me,Pr),[r]),s=(0,Q.useMemo)(()=>r?.services?.[`web-fetch`]?.apiBase??``,[r]),[c,l]=(0,Q.useState)(!1),[u,d]=yn(o),[f,p]=yn(s),[m,g]=(0,Q.useState)(``),_=y.has(u),v=ee.has(u),{hasStoredCredential:b}=Mt({assistantId:t,credentialKind:`api_key`,credentialName:u,enabled:v}),x=m.trim().length>0,S=f.trim(),C=z(u,_&&S.length>0),w=u!==o||_&&S!==s.trim(),T=c||v&&!C&&!b&&!x||!w&&!x,D=it(Me[u]??e(`webFetchCard.apiKeyPlaceholder`),b),O=Ot[u]??``,k=(0,Q.useCallback)(async()=>{l(!0);let r=m.trim(),o=v&&r.length>0;try{o&&await a(u,r),await i.mutateAsync({path:{assistant_id:t},body:{services:{"web-fetch":{provider:u,..._?{apiBase:S}:{}}}}}).catch(t=>{throw q.error(e(`webFetchCard.configUpdateFailedToast`)),E(t,{context:`patch_daemon_config`}),t})}catch{l(!1);return}l(!1);try{if(U(me,u),o){let e=h(u);e&&U(e,r);let i=bt(t,`api_key`,u);n.setQueryData(i,!0),n.invalidateQueries({queryKey:i}),g(``)}q.success(e(`webFetchCard.savedToast`))}catch(t){E(t,{context:`settings-ai-web-fetch-persist-local`}),q.error(e(`webFetchCard.localPreferencesFailedToast`))}},[v,i,a,n,t,m,u,_,S,e]),A=(0,Q.useCallback)(()=>{let e=h(u);e&&M(e),g(``),p(``),d(Pr),U(me,Pr)},[u,d,p]);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)(K,{value:u,onChange:d,options:Re.map(e=>({value:e,label:N[e]??e}))})]}),_&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(V,{label:e(`webFetchCard.apiBaseLabel`),type:`url`,value:f,onChange:e=>p(e.target.value),placeholder:O||e(`webFetchCard.apiBasePlaceholder`),fullWidth:!0}),O?(0,$.jsx)(`p`,{className:`text-body-small-lighter text-[var(--content-tertiary)]`,children:e(`webFetchCard.apiBaseHint`,{defaultBase:O})}):null]}),v&&(0,$.jsx)(V,{label:e(`webFetchCard.apiKeyLabel`),type:`password`,value:m,onChange:e=>g(e.target.value),placeholder:D,fullWidth:!0}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(dn,{onClick:k,disabled:T}),c&&(0,$.jsx)(rn,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`}),v&&(0,$.jsx)(un,{onClick:A,filled:!0})]})]})})}var Ir=`0.10.12`;function Lr(){return we(Ir)}function Rr(){let{t:e}=Y(`settings`),t=_t(),n=Z(),r=Rt(),{data:i}=J({...xe({path:{assistant_id:t}}),enabled:r,staleTime:3e4}),a=De({onSuccess:e=>{Ht(n,{path:{assistant_id:t}},e)}}),o=vn(),c=(0,Q.useMemo)(()=>{if(!i)return I(_,`inference-provider-native`);let e=i.services?.[`web-search`];return(e?.mode===`managed`&&e?.provider!==`inference-provider-native`?`vellum`:e?.provider)||I(`vellum:ai:webSearchProvider`,`inference-provider-native`)},[i]),l=(0,Q.useMemo)(()=>i?.services?.[`web-search`]?.apiBase??``,[i]),[u,d]=(0,Q.useState)(!1),[f,p]=yn(c),[m,h]=yn(l),[g,v]=(0,Q.useState)(``),y=ve.has(f),b=Gt.has(f),x=s.has(f),{hasStoredCredential:S}=Mt({assistantId:t,credentialKind:`api_key`,credentialName:f,enabled:b}),w=g.trim().length>0,T=m.trim(),O=z(f,y&&T.length>0),k=f!==c||y&&T!==l.trim(),A=Ee[f]??``,j=b&&!x&&!O&&!S&&!w,N=y&&A.length===0&&!T,P=u||j||N||!k&&!w,F=it(Oe[f]??e(`webSearchCard.apiKeyPlaceholder`),S),ee=(0,Q.useCallback)(async()=>{d(!0);let r=g.trim(),i=D(f),s=b&&r.length>0;try{s&&await o(f,r),await kt();let n=f===`vellum`?Lr()?{provider:`vellum`,mode:`managed`}:{mode:`managed`}:{provider:f,mode:`your-own`,...y?{apiBase:T}:{}};await a.mutateAsync({path:{assistant_id:t},body:{services:{"web-search":n}}}).catch(t=>{throw q.error(e(`webSearchCard.configUpdateFailedToast`)),E(t,{context:`patch_daemon_config`}),t})}catch{d(!1);return}d(!1);try{if(U(_,f),s){i&&U(i,r);let e=bt(t,`api_key`,f);n.setQueryData(e,!0),n.invalidateQueries({queryKey:e}),v(``)}q.success(e(`webSearchCard.savedToast`))}catch(t){E(t,{context:`settings-ai-web-search-persist-local`}),q.error(e(`webSearchCard.localPreferencesFailedToast`))}},[b,a,o,n,t,g,f,y,T,e]),te=(0,Q.useCallback)(()=>{let e=D(f);e&&M(e),v(``),h(``),p(`inference-provider-native`),U(_,`inference-provider-native`)},[f,p,h]);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)(K,{"aria-label":e(`webSearchCard.providerAriaLabel`),value:f,onChange:p,options:Ce.map(e=>({value:e,label:C[e]??e}))})]}),f===`vellum`&&(0,$.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:e(`webSearchCard.vellumNote`)}),y&&(0,$.jsxs)(`div`,{className:`space-y-1`,children:[(0,$.jsx)(V,{label:e(`webSearchCard.apiBaseLabel`),type:`url`,value:m,onChange:e=>h(e.target.value),placeholder:A||e(`webSearchCard.apiBasePlaceholder`),fullWidth:!0}),A?(0,$.jsx)(`p`,{className:`text-body-small-lighter text-[var(--content-tertiary)]`,children:e(`webSearchCard.apiBaseHint`,{defaultBase:A})}):null]}),b&&(0,$.jsx)(V,{label:e(`webSearchCard.apiKeyLabel`),type:`password`,value:g,onChange:e=>v(e.target.value),placeholder:F,fullWidth:!0}),(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(dn,{onClick:ee,disabled:P}),u&&(0,$.jsx)(rn,{className:`h-4 w-4 animate-spin text-[var(--content-disabled)]`}),b&&(0,$.jsx)(un,{onClick:te,filled:!0})]})]})})}function zr(){let e=_t(),t=Je(),[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};